From 8be2eaf4cb5a777e81952ef958f3196cfe48f7a4 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 31 Jan 2023 07:35:40 +1100 Subject: [PATCH 1/6] Draft ci action --- .github/workflows/build-firmware.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/build-firmware.yml diff --git a/.github/workflows/build-firmware.yml b/.github/workflows/build-firmware.yml new file mode 100644 index 0000000..bf6d9a7 --- /dev/null +++ b/.github/workflows/build-firmware.yml @@ -0,0 +1,17 @@ +name: CI + +on: [push, pull_request] + +jobs: + build-firmware: + runs-on: ubuntu-latest + container: + image: ghcr.io/pine64/openpinebuds:latest-sdk + steps: + - name: Build the main firmware + run: cd /usr/src/ && ./build.sh || cat /usr/src/log.txt + + - name: Archive produced firmware + uses: actions/upload-artifact@v3 + with: + path: /usr/src/out/open_source/open_source.bin From 40227d53c0b264ddcd566ffc51aa6745b46a8ca1 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 31 Jan 2023 21:18:56 +1100 Subject: [PATCH 2/6] Add clang-format to docker file --- Dockerfile | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4b820d0..0558099 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,12 +9,13 @@ ENV PATH="/root/.cargo/bin:$PATH" RUN apt-get update \ && apt-get install -y \ - bc \ - build-essential \ - curl \ - git \ - libudev-dev \ - pkg-config \ + bc \ + build-essential \ + clang-format \ + curl \ + git \ + libudev-dev \ + pkg-config \ && curl https://sh.rustup.rs -sSf | bash -s -- -y \ && git clone https://github.com/Ralim/bestool.git \ && cd /usr/src/bestool/bestool/ \ @@ -26,19 +27,19 @@ WORKDIR /usr/src RUN apt-get update \ && apt-get install -y \ - bash \ - bc \ - bzip2 \ - curl \ - ffmpeg \ - git \ - make \ - tar \ - xxd \ + bash \ + bc \ + bzip2 \ + curl \ + ffmpeg \ + git \ + make \ + tar \ + xxd \ && git config --global --add safe.directory /src \ && mkdir -pv /src \ && curl \ - https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-$(arch)-linux.tar.bz2 | tar -xj -C /src/ + https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-$(arch)-linux.tar.bz2 | tar -xj -C /src/ ENV PATH="${PATH}:/src/gcc-arm-none-eabi-9-2019-q4-major/bin" COPY --from=rust_build /usr/src/bestool/bestool/target/release/bestool /usr/local/bin/bestool From 19faa5dc4c42232cc771617f8b98b3ee32450c1a Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 31 Jan 2023 21:19:12 +1100 Subject: [PATCH 3/6] Create format actions in make file --- Makefile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Makefile b/Makefile index fbaf37f..7365e3a 100644 --- a/Makefile +++ b/Makefile @@ -1037,7 +1037,32 @@ endif PHONY += FORCE FORCE: ; +### Formatting +ALL_SOURCE = $(shell find . \( -type f \( -name '*.c' -o -name '*.cpp' \) \) ) + + +style: + @for src in $(ALL_SOURCE) $(ALL_INCLUDES); do \ + echo "Formatting $$src..." ; \ + clang-format -style=llvm -i "$$src" ; \ + done + @echo "Done" + +check-style: + @for src in $(ALL_SOURCE) $(ALL_INCLUDES) ; do \ + var=`clang-format -style=llvm "$$src" | diff "$$src" - | wc -l` ; \ + if [ $$var -ne 0 ] ; then \ + echo "$$src does not respect the coding style (diff: $$var lines)" ; \ + clang-format -style=llvm "$$src" | diff "$$src" -; \ + exit 1 ; \ + fi ; \ + done + @echo "Style check passed" + + +PHONY += style check-style # Declare the contents of the .PHONY variable as phony. We keep that # information in a variable so we can use it in if_changed and friends. .PHONY: $(PHONY) + From 3fdfaf815b72748cd212fe6bb85cab8ba15a1757 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 31 Jan 2023 21:22:20 +1100 Subject: [PATCH 4/6] Create clang-format spec --- .clang-format | 1 + Makefile | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..468ceea --- /dev/null +++ b/.clang-format @@ -0,0 +1 @@ +BasedOnStyle: LLVM \ No newline at end of file diff --git a/Makefile b/Makefile index 7365e3a..1e82a74 100644 --- a/Makefile +++ b/Makefile @@ -1044,16 +1044,16 @@ ALL_SOURCE = $(shell find . \( -type f \( -name '*.c' -o -name '*.cpp' \) \) ) style: @for src in $(ALL_SOURCE) $(ALL_INCLUDES); do \ echo "Formatting $$src..." ; \ - clang-format -style=llvm -i "$$src" ; \ + clang-format -i "$$src" ; \ done @echo "Done" check-style: @for src in $(ALL_SOURCE) $(ALL_INCLUDES) ; do \ - var=`clang-format -style=llvm "$$src" | diff "$$src" - | wc -l` ; \ + var=`clang-format "$$src" | diff "$$src" - | wc -l` ; \ if [ $$var -ne 0 ] ; then \ echo "$$src does not respect the coding style (diff: $$var lines)" ; \ - clang-format -style=llvm "$$src" | diff "$$src" -; \ + clang-format "$$src" | diff "$$src" -; \ exit 1 ; \ fi ; \ done From dcb8fed27b511cfb0c404be6a140d2fa2d89386b Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Thu, 2 Feb 2023 07:52:23 +1100 Subject: [PATCH 5/6] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0558099..50beb99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,6 @@ RUN apt-get update \ && apt-get install -y \ bc \ build-essential \ - clang-format \ curl \ git \ libudev-dev \ @@ -32,6 +31,7 @@ RUN apt-get update \ bzip2 \ curl \ ffmpeg \ + clang-format \ git \ make \ tar \ From 75381150fdd1cce6704201a4936b4e1ee8facfbf Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Thu, 2 Feb 2023 07:52:54 +1100 Subject: [PATCH 6/6] Formatting Formatting Pass 1 Lots of fixups to adding stdint and stdbool all over the place Formatting Pass 2 Formatting Pass 3 Formatting Pass 4 Update app_bt_stream.cpp --- apps/anc/inc/anc_wnr.h | 27 +- apps/anc/src/anc_assist.c | 518 +- apps/anc/src/anc_wnr.c | 2229 +- apps/anc/src/app_anc.c | 2573 +- apps/anc/src/peak_detector.c | 214 +- apps/apptester/app_audtest.cpp | 391 +- apps/apptester/audiobuffer.c | 158 +- .../a2dp_decoder/a2dp_decoder.cpp | 3290 +- .../a2dp_decoder/a2dp_decoder_aac_lc.cpp | 1730 +- .../a2dp_decoder/a2dp_decoder_cp.c | 937 +- .../a2dp_decoder/a2dp_decoder_example.cpp | 162 +- .../a2dp_decoder/a2dp_decoder_ldac.cpp | 1811 +- .../a2dp_decoder/a2dp_decoder_lhdc.cpp | 1833 +- .../a2dp_decoder/a2dp_decoder_sbc.cpp | 1652 +- .../a2dp_decoder/a2dp_decoder_scalable.cpp | 1110 +- apps/audioplayers/a2dpplay.cpp | 4875 +-- apps/audioplayers/app_audio.cpp | 1091 +- apps/audioplayers/bt_sco_chain.c | 1166 +- apps/audioplayers/bt_sco_chain_cfg_default.c | 1255 +- apps/audioplayers/bt_sco_chain_cp.c | 209 +- apps/audioplayers/bt_sco_chain_thirdparty.c | 151 +- .../bt_sco_chain_thirdparty_alango.c | 216 +- apps/audioplayers/bt_sco_chain_tuning.c | 260 +- apps/audioplayers/cvsdplay.cpp | 18 +- apps/audioplayers/digmici2splay.cpp | 34 +- apps/audioplayers/flacplay.cpp | 158 +- apps/audioplayers/fmradio.cpp | 744 +- apps/audioplayers/msbcplay.cpp | 22 +- apps/audioplayers/plc_utils.c | 401 +- apps/audioplayers/rbplay/rb_ctl.cpp | 1158 +- apps/audioplayers/rbplay/rbpcmbuf.cpp | 152 +- apps/audioplayers/rbplay/rbplay.cpp | 756 +- apps/audioplayers/rbplay/rbplaysd.cpp | 297 +- apps/audioplayers/voice_test.c | 219 +- apps/audioplayers/voicebtpcmplay.cpp | 3186 +- .../voicebtpcmplay_sco_dma_snapshot.cpp | 1264 +- apps/audioplayers/wavplay.cpp | 389 +- apps/battery/app_battery.cpp | 1261 +- apps/btusbaudio/btusb_audio.c | 463 +- apps/btusbaudio/usbaudio_thread.c | 200 +- apps/cmd/app_cmd.cpp | 72 +- apps/common/app_spec_ostimer.cpp | 81 +- apps/common/app_thread.c | 229 +- apps/common/app_thread.h | 81 +- apps/common/app_utils.c | 313 +- apps/common/randfrommic.c | 390 +- apps/factory/app_factory.cpp | 993 +- apps/factory/app_factory.h | 5 +- apps/factory/app_factory_audio.cpp | 421 +- apps/factory/app_factory_bt.cpp | 456 +- apps/factory/app_factory_cdc_comm.c | 469 +- apps/factory/sys_api_cdc_comm.c | 283 +- apps/key/app_key.cpp | 202 +- apps/key/app_key.h | 129 +- apps/main/apps.cpp | 4017 +- apps/main/apps_tester.cpp | 399 +- apps/mic/app_mic.cpp | 357 +- apps/mic_alg/app_mic_alg.cpp | 364 +- apps/pwl/app_pwl.cpp | 224 +- apps/sdmmc/app_sdmmc.cpp | 276 +- apps/usbaudio/usbaudio_entry.c | 350 +- apps/usbhost/app_usbhost.c | 5 +- apps/voice_detector/app_voice_detector.cpp | 318 +- apps/voice_detector/voice_detector.c | 1271 +- config/_default_cfg_src_/app_status_ind.c | 464 +- config/_default_cfg_src_/tgt_hardware.c | 109 +- config/bak_open/tgt_hardware.c | 407 +- config/best2300p_ibrt/tgt_hardware.c | 418 +- config/best2300p_ibrt_anc/tgt_hardware.c | 1625 +- config/mic_alg/tgt_hardware.c | 422 +- config/open_source/tgt_hardware.c | 1636 +- .../DSP_Lib/BasicMathFunctions/arm_abs_f32.c | 17 +- .../DSP_Lib/BasicMathFunctions/arm_abs_q15.c | 48 +- .../DSP_Lib/BasicMathFunctions/arm_abs_q31.c | 38 +- .../DSP_Lib/BasicMathFunctions/arm_abs_q7.c | 50 +- .../DSP_Lib/BasicMathFunctions/arm_add_f32.c | 19 +- .../DSP_Lib/BasicMathFunctions/arm_add_q15.c | 52 +- .../DSP_Lib/BasicMathFunctions/arm_add_q31.c | 22 +- .../DSP_Lib/BasicMathFunctions/arm_add_q7.c | 37 +- .../BasicMathFunctions/arm_dot_prod_f32.c | 29 +- .../BasicMathFunctions/arm_dot_prod_q15.c | 62 +- .../BasicMathFunctions/arm_dot_prod_q31.c | 48 +- .../BasicMathFunctions/arm_dot_prod_q7.c | 66 +- .../DSP_Lib/BasicMathFunctions/arm_mult_f32.c | 19 +- .../DSP_Lib/BasicMathFunctions/arm_mult_q15.c | 74 +- .../DSP_Lib/BasicMathFunctions/arm_mult_q31.c | 34 +- .../DSP_Lib/BasicMathFunctions/arm_mult_q7.c | 48 +- .../BasicMathFunctions/arm_negate_f32.c | 18 +- .../BasicMathFunctions/arm_negate_q15.c | 46 +- .../BasicMathFunctions/arm_negate_q31.c | 32 +- .../BasicMathFunctions/arm_negate_q7.c | 46 +- .../BasicMathFunctions/arm_offset_f32.c | 19 +- .../BasicMathFunctions/arm_offset_q15.c | 51 +- .../BasicMathFunctions/arm_offset_q31.c | 42 +- .../BasicMathFunctions/arm_offset_q7.c | 43 +- .../BasicMathFunctions/arm_scale_f32.c | 30 +- .../BasicMathFunctions/arm_scale_q15.c | 71 +- .../BasicMathFunctions/arm_scale_q31.c | 89 +- .../DSP_Lib/BasicMathFunctions/arm_scale_q7.c | 55 +- .../BasicMathFunctions/arm_shift_q15.c | 106 +- .../BasicMathFunctions/arm_shift_q31.c | 59 +- .../DSP_Lib/BasicMathFunctions/arm_shift_q7.c | 83 +- .../DSP_Lib/BasicMathFunctions/arm_sub_f32.c | 19 +- .../DSP_Lib/BasicMathFunctions/arm_sub_q15.c | 52 +- .../DSP_Lib/BasicMathFunctions/arm_sub_q31.c | 22 +- .../DSP_Lib/BasicMathFunctions/arm_sub_q7.c | 37 +- .../cmsis/DSP_Lib/CommonTables/CommonTables.c | 1 - .../DSP_Lib/CommonTables/arm_common_tables.c | 34648 ++++++---------- .../DSP_Lib/CommonTables/arm_const_structs.c | 457 +- .../ComplexMathFunctions/arm_cmplx_conj_f32.c | 37 +- .../ComplexMathFunctions/arm_cmplx_conj_q15.c | 75 +- .../ComplexMathFunctions/arm_cmplx_conj_q31.c | 44 +- .../arm_cmplx_dot_prod_f32.c | 29 +- .../arm_cmplx_dot_prod_q15.c | 39 +- .../arm_cmplx_dot_prod_q31.c | 38 +- .../ComplexMathFunctions/arm_cmplx_mag_f32.c | 20 +- .../ComplexMathFunctions/arm_cmplx_mag_q15.c | 84 +- .../ComplexMathFunctions/arm_cmplx_mag_q31.c | 46 +- .../arm_cmplx_mag_squared_f32.c | 20 +- .../arm_cmplx_mag_squared_q15.c | 85 +- .../arm_cmplx_mag_squared_q31.c | 47 +- .../arm_cmplx_mult_cmplx_f32.c | 34 +- .../arm_cmplx_mult_cmplx_q15.c | 44 +- .../arm_cmplx_mult_cmplx_q31.c | 46 +- .../arm_cmplx_mult_real_f32.c | 30 +- .../arm_cmplx_mult_real_q15.c | 128 +- .../arm_cmplx_mult_real_q31.c | 74 +- .../ControllerFunctions/ControllerFunctions.c | 1 - .../ControllerFunctions/arm_pid_init_f32.c | 20 +- .../ControllerFunctions/arm_pid_init_q15.c | 28 +- .../ControllerFunctions/arm_pid_init_q31.c | 30 +- .../ControllerFunctions/arm_pid_reset_f32.c | 4 +- .../ControllerFunctions/arm_pid_reset_q15.c | 4 +- .../ControllerFunctions/arm_pid_reset_q31.c | 4 +- .../ControllerFunctions/arm_sin_cos_f32.c | 74 +- .../ControllerFunctions/arm_sin_cos_q31.c | 36 +- .../FastMathFunctions/FastMathFunctions.c | 1 - .../DSP_Lib/FastMathFunctions/arm_cos_f32.c | 33 +- .../DSP_Lib/FastMathFunctions/arm_cos_q15.c | 29 +- .../DSP_Lib/FastMathFunctions/arm_cos_q31.c | 29 +- .../DSP_Lib/FastMathFunctions/arm_sin_f32.c | 30 +- .../DSP_Lib/FastMathFunctions/arm_sin_q15.c | 26 +- .../DSP_Lib/FastMathFunctions/arm_sin_q31.c | 26 +- .../DSP_Lib/FastMathFunctions/arm_sqrt_q15.c | 81 +- .../DSP_Lib/FastMathFunctions/arm_sqrt_q31.c | 81 +- .../arm_biquad_cascade_df1_32x64_init_q31.c | 54 +- .../arm_biquad_cascade_df1_32x64_q31.c | 289 +- .../arm_biquad_cascade_df1_f32.c | 193 +- .../arm_biquad_cascade_df1_fast_q15.c | 114 +- .../arm_biquad_cascade_df1_fast_q31.c | 90 +- .../arm_biquad_cascade_df1_init_f32.c | 48 +- .../arm_biquad_cascade_df1_init_q15.c | 54 +- .../arm_biquad_cascade_df1_init_q31.c | 48 +- .../arm_biquad_cascade_df1_q15.c | 190 +- .../arm_biquad_cascade_df1_q31.c | 118 +- .../arm_biquad_cascade_df2T_f32.c | 392 +- .../arm_biquad_cascade_df2T_f64.c | 502 +- .../arm_biquad_cascade_df2T_init_f32.c | 40 +- .../arm_biquad_cascade_df2T_init_f64.c | 39 +- .../arm_biquad_cascade_stereo_df2T_f32.c | 327 +- .../arm_biquad_cascade_stereo_df2T_init_f32.c | 37 +- .../DSP_Lib/FilteringFunctions/arm_conv_f32.c | 221 +- .../arm_conv_fast_opt_q15.c | 144 +- .../FilteringFunctions/arm_conv_fast_q15.c | 285 +- .../FilteringFunctions/arm_conv_fast_q31.c | 265 +- .../FilteringFunctions/arm_conv_opt_q15.c | 139 +- .../FilteringFunctions/arm_conv_opt_q7.c | 152 +- .../FilteringFunctions/arm_conv_partial_f32.c | 246 +- .../arm_conv_partial_fast_opt_q15.c | 151 +- .../arm_conv_partial_fast_q15.c | 322 +- .../arm_conv_partial_fast_q31.c | 291 +- .../arm_conv_partial_opt_q15.c | 150 +- .../arm_conv_partial_opt_q7.c | 160 +- .../FilteringFunctions/arm_conv_partial_q15.c | 362 +- .../FilteringFunctions/arm_conv_partial_q31.c | 293 +- .../FilteringFunctions/arm_conv_partial_q7.c | 406 +- .../DSP_Lib/FilteringFunctions/arm_conv_q15.c | 300 +- .../DSP_Lib/FilteringFunctions/arm_conv_q31.c | 257 +- .../DSP_Lib/FilteringFunctions/arm_conv_q7.c | 362 +- .../FilteringFunctions/arm_correlate_f32.c | 253 +- .../arm_correlate_fast_opt_q15.c | 131 +- .../arm_correlate_fast_q15.c | 285 +- .../arm_correlate_fast_q31.c | 270 +- .../arm_correlate_opt_q15.c | 126 +- .../FilteringFunctions/arm_correlate_opt_q7.c | 166 +- .../FilteringFunctions/arm_correlate_q15.c | 309 +- .../FilteringFunctions/arm_correlate_q31.c | 292 +- .../FilteringFunctions/arm_correlate_q7.c | 387 +- .../FilteringFunctions/arm_fir_decimate_f32.c | 191 +- .../arm_fir_decimate_fast_q15.c | 221 +- .../arm_fir_decimate_fast_q31.c | 171 +- .../arm_fir_decimate_init_f32.c | 36 +- .../arm_fir_decimate_init_q15.c | 37 +- .../arm_fir_decimate_init_q31.c | 36 +- .../FilteringFunctions/arm_fir_decimate_q15.c | 218 +- .../FilteringFunctions/arm_fir_decimate_q31.c | 163 +- .../DSP_Lib/FilteringFunctions/arm_fir_f32.c | 173 +- .../FilteringFunctions/arm_fir_fast_q15.c | 148 +- .../FilteringFunctions/arm_fir_fast_q31.c | 108 +- .../FilteringFunctions/arm_fir_init_f32.c | 23 +- .../FilteringFunctions/arm_fir_init_q15.c | 54 +- .../FilteringFunctions/arm_fir_init_q31.c | 22 +- .../FilteringFunctions/arm_fir_init_q7.c | 19 +- .../arm_fir_interpolate_f32.c | 244 +- .../arm_fir_interpolate_init_f32.c | 50 +- .../arm_fir_interpolate_init_q15.c | 47 +- .../arm_fir_interpolate_init_q31.c | 49 +- .../arm_fir_interpolate_q15.c | 210 +- .../arm_fir_interpolate_q31.c | 204 +- .../FilteringFunctions/arm_fir_lattice_f32.c | 131 +- .../arm_fir_lattice_init_f32.c | 21 +- .../arm_fir_lattice_init_q15.c | 18 +- .../arm_fir_lattice_init_q31.c | 18 +- .../FilteringFunctions/arm_fir_lattice_q15.c | 202 +- .../FilteringFunctions/arm_fir_lattice_q31.c | 183 +- .../DSP_Lib/FilteringFunctions/arm_fir_q15.c | 149 +- .../DSP_Lib/FilteringFunctions/arm_fir_q31.c | 141 +- .../DSP_Lib/FilteringFunctions/arm_fir_q7.c | 130 +- .../FilteringFunctions/arm_fir_sparse_f32.c | 194 +- .../arm_fir_sparse_init_f32.c | 32 +- .../arm_fir_sparse_init_q15.c | 27 +- .../arm_fir_sparse_init_q31.c | 27 +- .../arm_fir_sparse_init_q7.c | 24 +- .../FilteringFunctions/arm_fir_sparse_q15.c | 185 +- .../FilteringFunctions/arm_fir_sparse_q31.c | 183 +- .../FilteringFunctions/arm_fir_sparse_q7.c | 184 +- .../FilteringFunctions/arm_iir_lattice_f32.c | 135 +- .../arm_iir_lattice_init_f32.c | 27 +- .../arm_iir_lattice_init_q15.c | 21 +- .../arm_iir_lattice_init_q31.c | 24 +- .../FilteringFunctions/arm_iir_lattice_q15.c | 162 +- .../FilteringFunctions/arm_iir_lattice_q31.c | 132 +- .../DSP_Lib/FilteringFunctions/arm_lms_f32.c | 214 +- .../FilteringFunctions/arm_lms_init_f32.c | 26 +- .../FilteringFunctions/arm_lms_init_q15.c | 30 +- .../FilteringFunctions/arm_lms_init_q31.c | 29 +- .../FilteringFunctions/arm_lms_norm_f32.c | 212 +- .../arm_lms_norm_init_f32.c | 31 +- .../arm_lms_norm_init_q15.c | 34 +- .../arm_lms_norm_init_q31.c | 33 +- .../FilteringFunctions/arm_lms_norm_q15.c | 159 +- .../FilteringFunctions/arm_lms_norm_q31.c | 158 +- .../DSP_Lib/FilteringFunctions/arm_lms_q15.c | 131 +- .../DSP_Lib/FilteringFunctions/arm_lms_q31.c | 137 +- .../DSP_Lib/MatrixFunctions/arm_mat_add_f32.c | 39 +- .../DSP_Lib/MatrixFunctions/arm_mat_add_q15.c | 66 +- .../DSP_Lib/MatrixFunctions/arm_mat_add_q31.c | 42 +- .../MatrixFunctions/arm_mat_cmplx_mult_f32.c | 100 +- .../MatrixFunctions/arm_mat_cmplx_mult_q15.c | 177 +- .../MatrixFunctions/arm_mat_cmplx_mult_q31.c | 151 +- .../MatrixFunctions/arm_mat_init_f32.c | 13 +- .../MatrixFunctions/arm_mat_init_q15.c | 11 +- .../MatrixFunctions/arm_mat_init_q31.c | 10 +- .../MatrixFunctions/arm_mat_inverse_f32.c | 267 +- .../MatrixFunctions/arm_mat_inverse_f64.c | 253 +- .../MatrixFunctions/arm_mat_mult_f32.c | 82 +- .../MatrixFunctions/arm_mat_mult_fast_q15.c | 246 +- .../MatrixFunctions/arm_mat_mult_fast_q31.c | 182 +- .../MatrixFunctions/arm_mat_mult_q15.c | 195 +- .../MatrixFunctions/arm_mat_mult_q31.c | 105 +- .../MatrixFunctions/arm_mat_scale_f32.c | 50 +- .../MatrixFunctions/arm_mat_scale_q15.c | 87 +- .../MatrixFunctions/arm_mat_scale_q31.c | 64 +- .../DSP_Lib/MatrixFunctions/arm_mat_sub_f32.c | 39 +- .../DSP_Lib/MatrixFunctions/arm_mat_sub_q15.c | 64 +- .../DSP_Lib/MatrixFunctions/arm_mat_sub_q31.c | 45 +- .../MatrixFunctions/arm_mat_trans_f32.c | 44 +- .../MatrixFunctions/arm_mat_trans_q15.c | 61 +- .../MatrixFunctions/arm_mat_trans_q31.c | 39 +- .../DSP_Lib/StatisticsFunctions/arm_max_f32.c | 39 +- .../DSP_Lib/StatisticsFunctions/arm_max_q15.c | 39 +- .../DSP_Lib/StatisticsFunctions/arm_max_q31.c | 39 +- .../DSP_Lib/StatisticsFunctions/arm_max_q7.c | 39 +- .../StatisticsFunctions/arm_mean_f32.c | 26 +- .../StatisticsFunctions/arm_mean_q15.c | 44 +- .../StatisticsFunctions/arm_mean_q31.c | 32 +- .../DSP_Lib/StatisticsFunctions/arm_mean_q7.c | 42 +- .../DSP_Lib/StatisticsFunctions/arm_min_f32.c | 39 +- .../DSP_Lib/StatisticsFunctions/arm_min_q15.c | 40 +- .../DSP_Lib/StatisticsFunctions/arm_min_q31.c | 40 +- .../DSP_Lib/StatisticsFunctions/arm_min_q7.c | 40 +- .../StatisticsFunctions/arm_power_f32.c | 24 +- .../StatisticsFunctions/arm_power_q15.c | 54 +- .../StatisticsFunctions/arm_power_q31.c | 50 +- .../StatisticsFunctions/arm_power_q7.c | 54 +- .../DSP_Lib/StatisticsFunctions/arm_rms_f32.c | 31 +- .../DSP_Lib/StatisticsFunctions/arm_rms_q15.c | 56 +- .../DSP_Lib/StatisticsFunctions/arm_rms_q31.c | 52 +- .../DSP_Lib/StatisticsFunctions/arm_std_f32.c | 64 +- .../DSP_Lib/StatisticsFunctions/arm_std_q15.c | 71 +- .../DSP_Lib/StatisticsFunctions/arm_std_q31.c | 70 +- .../DSP_Lib/StatisticsFunctions/arm_var_f32.c | 45 +- .../DSP_Lib/StatisticsFunctions/arm_var_q15.c | 73 +- .../DSP_Lib/StatisticsFunctions/arm_var_q31.c | 70 +- .../DSP_Lib/SupportFunctions/arm_copy_f32.c | 16 +- .../DSP_Lib/SupportFunctions/arm_copy_q15.c | 20 +- .../DSP_Lib/SupportFunctions/arm_copy_q31.c | 16 +- .../DSP_Lib/SupportFunctions/arm_copy_q7.c | 18 +- .../DSP_Lib/SupportFunctions/arm_fill_f32.c | 16 +- .../DSP_Lib/SupportFunctions/arm_fill_q15.c | 22 +- .../DSP_Lib/SupportFunctions/arm_fill_q31.c | 16 +- .../DSP_Lib/SupportFunctions/arm_fill_q7.c | 20 +- .../SupportFunctions/arm_float_to_q15.c | 55 +- .../SupportFunctions/arm_float_to_q31.c | 55 +- .../SupportFunctions/arm_float_to_q7.c | 51 +- .../SupportFunctions/arm_q15_to_float.c | 35 +- .../DSP_Lib/SupportFunctions/arm_q15_to_q31.c | 31 +- .../DSP_Lib/SupportFunctions/arm_q15_to_q7.c | 48 +- .../SupportFunctions/arm_q31_to_float.c | 35 +- .../DSP_Lib/SupportFunctions/arm_q31_to_q15.c | 41 +- .../DSP_Lib/SupportFunctions/arm_q31_to_q7.c | 31 +- .../SupportFunctions/arm_q7_to_float.c | 32 +- .../DSP_Lib/SupportFunctions/arm_q7_to_q15.c | 45 +- .../DSP_Lib/SupportFunctions/arm_q7_to_q31.c | 25 +- .../TransformFunctions/arm_bitreversal.c | 278 +- .../TransformFunctions/arm_bitreversal2.c | 69 +- .../DSP_Lib/TransformFunctions/arm_cfft_f32.c | 577 +- .../DSP_Lib/TransformFunctions/arm_cfft_q15.c | 347 +- .../DSP_Lib/TransformFunctions/arm_cfft_q31.c | 306 +- .../TransformFunctions/arm_cfft_radix2_f32.c | 695 +- .../arm_cfft_radix2_init_f32.c | 66 +- .../arm_cfft_radix2_init_q15.c | 66 +- .../arm_cfft_radix2_init_q31.c | 66 +- .../TransformFunctions/arm_cfft_radix2_q15.c | 336 +- .../TransformFunctions/arm_cfft_radix2_q31.c | 425 +- .../TransformFunctions/arm_cfft_radix4_f32.c | 2059 +- .../arm_cfft_radix4_init_f32.c | 59 +- .../arm_cfft_radix4_init_q15.c | 59 +- .../arm_cfft_radix4_init_q31.c | 57 +- .../TransformFunctions/arm_cfft_radix4_q15.c | 473 +- .../TransformFunctions/arm_cfft_radix4_q31.c | 323 +- .../TransformFunctions/arm_cfft_radix8_f32.c | 471 +- .../DSP_Lib/TransformFunctions/arm_dct4_f32.c | 267 +- .../TransformFunctions/arm_dct4_init_f32.c | 26790 +++++------- .../TransformFunctions/arm_dct4_init_q15.c | 10685 +++-- .../TransformFunctions/arm_dct4_init_q31.c | 12651 ++++-- .../DSP_Lib/TransformFunctions/arm_dct4_q15.c | 161 +- .../DSP_Lib/TransformFunctions/arm_dct4_q31.c | 162 +- .../DSP_Lib/TransformFunctions/arm_rfft_f32.c | 251 +- .../TransformFunctions/arm_rfft_fast_f32.c | 400 +- .../arm_rfft_fast_init_f32.c | 122 +- .../TransformFunctions/arm_rfft_init_f32.c | 9634 +++-- .../TransformFunctions/arm_rfft_init_q15.c | 5485 ++- .../TransformFunctions/arm_rfft_init_q31.c | 2377 +- .../DSP_Lib/TransformFunctions/arm_rfft_q15.c | 394 +- .../DSP_Lib/TransformFunctions/arm_rfft_q31.c | 293 +- platform/cmsis/ca/cmsis_gic.c | 216 +- platform/cmsis/ca/irq_ctrl_gic.c | 133 +- platform/cmsis/ca/mmu_ARMCA.c | 355 +- platform/cmsis/ca/startup_ARMCA.c | 178 +- platform/cmsis/ca/system_ARMCA.c | 61 +- platform/cmsis/cmsis_nvic.c | 236 +- platform/cmsis/inc/system_ARMCM.h | 5 +- platform/cmsis/mpu_armv7m.c | 395 +- platform/cmsis/mpu_armv8m.c | 374 +- platform/cmsis/patch.c | 287 +- platform/cmsis/patch_armv7m.c | 382 +- platform/cmsis/retarget_armclang.cpp | 99 +- platform/cmsis/retarget_gcc.cpp | 112 +- platform/cmsis/stack_protector.c | 13 +- platform/cmsis/system_ARMCM.c | 78 +- platform/cmsis/system_cp.c | 230 +- platform/cmsis/system_utils.c | 295 +- .../drivers/ana/best2300p/analog_best2300p.c | 3437 +- .../drivers/ana/best2300p/pmu_best2300p.c | 6363 ++- .../drivers/ana/best2300p/usbphy_best2300p.c | 517 +- platform/drivers/bt/best2300p/bt_drv.cpp | 1903 +- .../bt/best2300p/bt_drv_calibration.cpp | 816 +- platform/drivers/bt/best2300p/bt_drv_config.c | 2383 +- platform/drivers/bt/best2300p/bt_drv_patch.c | 6163 +-- .../drivers/bt/best2300p/bt_drv_reg_op.cpp | 5249 ++- .../drivers/bt/best2300p/bt_drv_rfconfig.c | 1173 +- .../bt/best2300p/bt_drv_uart_bridge_intsys.c | 268 +- platform/drivers/bt/best2300p/iqcorrect.c | 1602 +- platform/drivers/bt/bt_drv_common.c | 751 +- platform/drivers/btpcm/btpcm.c | 2 +- .../drivers/codec/best2300p/codec_best2300p.c | 1022 +- platform/drivers/codec/codec_tlv32aic32.c | 285 +- platform/drivers/norflash/norflash_drv.c | 2302 +- platform/drivers/norflash/norflash_en25s80b.c | 175 +- .../drivers/norflash/norflash_gd25lq32c.c | 817 +- platform/drivers/norflash/norflash_gd25q32c.c | 506 +- .../drivers/usb/usb_dev/cfg/usb_dev_desc.c | 553 +- .../hal/best2300p/hal_analogif_best2300p.c | 253 +- platform/hal/best2300p/hal_cmu_best2300p.c | 4233 +- platform/hal/best2300p/hal_codec_best2300p.c | 6081 +-- platform/hal/best2300p/hal_iomux_best2300p.c | 1756 +- platform/hal/best2300p/hal_psc_best2300p.c | 145 +- .../hal/best2300p/hal_sensor_eng_best2300p.c | 310 +- platform/hal/hal_bootmode.c | 87 +- platform/hal/hal_btdump.c | 86 +- platform/hal/hal_btpcm.c | 308 +- platform/hal/hal_cache.c | 829 +- platform/hal/hal_chipid.c | 30 +- platform/hal/hal_cmd.c | 580 +- platform/hal/hal_cmu_common.c | 457 +- platform/hal/hal_codec_common.c | 114 +- platform/hal/hal_dma.c | 1488 +- platform/hal/hal_gpadc.c | 1229 +- platform/hal/hal_gpio.c | 652 +- platform/hal/hal_i2c.c | 3804 +- platform/hal/hal_i2s.c | 1116 +- platform/hal/hal_i2s_tdm.c | 424 +- platform/hal/hal_intersys.c | 818 +- platform/hal/hal_key.c | 1441 +- platform/hal/hal_mcu2cp.c | 809 +- platform/hal/hal_memsc.c | 36 +- platform/hal/hal_norflash.c | 2616 +- platform/hal/hal_norflaship_v1.c | 591 +- platform/hal/hal_norflaship_v2.c | 598 +- platform/hal/hal_overlay.c | 344 +- platform/hal/hal_overlay.h | 126 +- platform/hal/hal_phyif.c | 194 +- platform/hal/hal_psram_v1.c | 578 +- platform/hal/hal_psram_v2.c | 1185 +- platform/hal/hal_psramuhs.c | 738 +- platform/hal/hal_pwm.c | 278 +- platform/hal/hal_rtc.c | 275 +- platform/hal/hal_sdmmc.c | 4550 +- platform/hal/hal_sec_eng.c | 1665 +- platform/hal/hal_slave_i2c.c | 63 +- platform/hal/hal_sleep.c | 793 +- platform/hal/hal_spdif.c | 623 +- platform/hal/hal_spi.c | 2345 +- platform/hal/hal_sysfreq.c | 199 +- platform/hal/hal_tdm.c | 866 +- platform/hal/hal_timer.c | 873 +- platform/hal/hal_trace.c | 3898 +- platform/hal/hal_trace_mod.c | 17 +- platform/hal/hal_transq.c | 938 +- platform/hal/hal_uart.c | 2260 +- platform/hal/hal_usb.c | 4244 +- platform/hal/hal_usbhost.c | 1786 +- platform/hal/hal_wdt.c | 268 +- platform/main/main.cpp | 421 +- platform/main/noapp_main.cpp | 166 +- platform/main/nostd_main.c | 1 - rtos/rtx/TARGET_ARM7/HAL_CM.c | 36 +- rtos/rtx/TARGET_ARM7/RTX_Conf_CM.c | 85 +- rtos/rtx/TARGET_ARM7/rt_CMSIS.c | 1322 +- rtos/rtx/TARGET_ARM7/rt_Event.c | 76 +- rtos/rtx/TARGET_ARM7/rt_List.c | 82 +- rtos/rtx/TARGET_ARM7/rt_Mailbox.c | 157 +- rtos/rtx/TARGET_ARM7/rt_MemBox.c | 85 +- rtos/rtx/TARGET_ARM7/rt_Mutex.c | 91 +- rtos/rtx/TARGET_ARM7/rt_Robin.c | 16 +- rtos/rtx/TARGET_ARM7/rt_Semaphore.c | 69 +- rtos/rtx/TARGET_ARM7/rt_System.c | 157 +- rtos/rtx/TARGET_ARM7/rt_Task.c | 161 +- rtos/rtx/TARGET_ARM7/rt_Time.c | 22 +- rtos/rtx/TARGET_CORTEX_A/HAL_CA.c | 20 +- rtos/rtx/TARGET_CORTEX_A/RTX_Conf_CA.c | 136 +- .../TARGET_CORTEX_A/TOOLCHAIN_ARM/HAL_CA9.c | 546 +- rtos/rtx/TARGET_CORTEX_A/rt_CMSIS.c | 1591 +- rtos/rtx/TARGET_CORTEX_A/rt_Event.c | 72 +- rtos/rtx/TARGET_CORTEX_A/rt_List.c | 78 +- rtos/rtx/TARGET_CORTEX_A/rt_Mailbox.c | 141 +- rtos/rtx/TARGET_CORTEX_A/rt_MemBox.c | 83 +- rtos/rtx/TARGET_CORTEX_A/rt_Memory.c | 31 +- rtos/rtx/TARGET_CORTEX_A/rt_Mutex.c | 89 +- rtos/rtx/TARGET_CORTEX_A/rt_Robin.c | 14 +- rtos/rtx/TARGET_CORTEX_A/rt_Semaphore.c | 69 +- rtos/rtx/TARGET_CORTEX_A/rt_System.c | 130 +- rtos/rtx/TARGET_CORTEX_A/rt_Task.c | 190 +- rtos/rtx/TARGET_CORTEX_A/rt_Time.c | 22 +- rtos/rtx/TARGET_CORTEX_M/HAL_CM.c | 48 +- rtos/rtx/TARGET_CORTEX_M/RTX_Conf.h | 34 +- rtos/rtx/TARGET_CORTEX_M/RTX_Conf_CM.c | 171 +- .../TARGET_M0/TOOLCHAIN_ARM/HAL_CM0.c | 322 +- .../TARGET_M0P/TOOLCHAIN_ARM/HAL_CM0.c | 322 +- .../TARGET_M3/TOOLCHAIN_ARM/HAL_CM3.c | 248 +- .../TARGET_M4/TOOLCHAIN_ARM/HAL_CM4.c | 338 +- rtos/rtx/TARGET_CORTEX_M/rt_CMSIS.c | 1437 +- rtos/rtx/TARGET_CORTEX_M/rt_Event.c | 76 +- rtos/rtx/TARGET_CORTEX_M/rt_Event.h | 15 +- rtos/rtx/TARGET_CORTEX_M/rt_HAL_CM.h | 232 +- rtos/rtx/TARGET_CORTEX_M/rt_List.c | 85 +- rtos/rtx/TARGET_CORTEX_M/rt_List.h | 36 +- rtos/rtx/TARGET_CORTEX_M/rt_Mailbox.c | 157 +- rtos/rtx/TARGET_CORTEX_M/rt_Mailbox.h | 18 +- rtos/rtx/TARGET_CORTEX_M/rt_MemBox.c | 85 +- rtos/rtx/TARGET_CORTEX_M/rt_MemBox.h | 15 +- rtos/rtx/TARGET_CORTEX_M/rt_Mutex.c | 91 +- rtos/rtx/TARGET_CORTEX_M/rt_Mutex.h | 2 +- rtos/rtx/TARGET_CORTEX_M/rt_Robin.c | 16 +- rtos/rtx/TARGET_CORTEX_M/rt_Semaphore.c | 69 +- rtos/rtx/TARGET_CORTEX_M/rt_Semaphore.h | 13 +- rtos/rtx/TARGET_CORTEX_M/rt_System.c | 202 +- rtos/rtx/TARGET_CORTEX_M/rt_System.h | 21 +- rtos/rtx/TARGET_CORTEX_M/rt_Task.c | 720 +- rtos/rtx/TARGET_CORTEX_M/rt_Task.h | 57 +- rtos/rtx/TARGET_CORTEX_M/rt_Time.c | 22 +- rtos/rtx/TARGET_CORTEX_M/rt_Time.h | 16 +- rtos/rtx/TARGET_CORTEX_M/rt_TypeDef.h | 127 +- rtos/rtx5/cmsis_os1.c | 218 +- rtos/rtx5/os_systick.c | 90 +- rtos/rtx5/rtx_config/rtx_config.c | 124 +- rtos/rtx5/rtx_delay.c | 18 +- rtos/rtx5/rtx_evflags.c | 176 +- rtos/rtx5/rtx_evr.c | 1496 +- rtos/rtx5/rtx_kernel.c | 313 +- rtos/rtx5/rtx_lib.c | 737 +- rtos/rtx5/rtx_memory.c | 65 +- rtos/rtx5/rtx_mempool.c | 257 +- rtos/rtx5/rtx_msgqueue.c | 363 +- rtos/rtx5/rtx_mutex.c | 168 +- rtos/rtx5/rtx_semaphore.c | 152 +- rtos/rtx5/rtx_system.c | 71 +- rtos/rtx5/rtx_thread.c | 783 +- rtos/rtx5/rtx_thread_dump.c | 573 +- rtos/rtx5/rtx_timer.c | 153 +- services/app_ai/src/app_ai_algorithm.cpp | 503 +- services/app_ai/src/app_ai_if.cpp | 317 +- services/app_ai/src/app_ai_if_custom_ui.cpp | 133 +- services/app_ai/src/app_ai_if_gsound.cpp | 9 +- services/app_ai/src/app_ai_if_thirdparty.cpp | 133 +- services/app_ai/src/app_ai_manager_api.cpp | 112 +- services/app_ai/src/app_ai_tws.cpp | 779 +- services/app_ai/voice_sbc/voice_sbc.cpp | 272 +- services/app_ibrt/inc/app_ibrt_a2dp.h | 3 + services/app_ibrt/inc/app_ibrt_custom_cmd.h | 9 +- services/app_ibrt/inc/app_ibrt_hf.h | 2 + .../inc/app_ibrt_peripheral_manager.h | 49 +- services/app_ibrt/inc/app_ibrt_ui_test.h | 11 +- services/app_ibrt/inc/app_ibrt_voice_report.h | 29 +- services/app_ibrt/src/app_ibrt_auto_test.cpp | 196 +- .../src/app_ibrt_auto_test_cmd_handle.cpp | 670 +- services/app_ibrt/src/app_ibrt_ble_adv.cpp | 293 +- .../app_ibrt/src/app_ibrt_customif_cmd.cpp | 344 +- .../app_ibrt/src/app_ibrt_customif_ui.cpp | 1363 +- services/app_ibrt/src/app_ibrt_if.cpp | 1747 +- services/app_ibrt/src/app_ibrt_keyboard.cpp | 529 +- services/app_ibrt/src/app_ibrt_nvrecord.cpp | 287 +- services/app_ibrt/src/app_ibrt_ota_cmd.cpp | 1034 +- services/app_ibrt/src/app_ibrt_ota_update.cpp | 698 +- .../src/app_ibrt_peripheral_manager.cpp | 524 +- services/app_ibrt/src/app_ibrt_rssi.cpp | 764 +- .../app_ibrt/src/app_ibrt_search_pair_ui.cpp | 1155 +- services/app_ibrt/src/app_ibrt_ui_test.cpp | 1046 +- .../app_ibrt/src/app_ibrt_ui_test_cmd_if.cpp | 584 +- .../app_ibrt/src/app_ibrt_voice_report.cpp | 853 +- services/app_tws/inc/app_tws_if.h | 109 +- services/app_tws/src/app_tws_if.cpp | 756 +- services/audio_dump/include/audio_dump.h | 7 +- services/audio_dump/src/audio_dump.c | 287 +- services/audio_process/audio_cfg.c | 117 +- services/audio_process/audio_process.c | 1322 +- services/audio_process/audio_spectrum.cpp | 127 +- services/audioflinger/audioflinger.c | 4434 +- services/auto_test/at_thread.cpp | 194 +- services/auto_test/at_thread_user.cpp | 429 +- services/auto_test/auto_test.cpp | 3461 +- services/ble_app/app_amsc/app_amsc.c | 75 +- services/ble_app/app_amsc/app_amsc_task.c | 28 +- services/ble_app/app_ancc/app_ancc.c | 69 +- services/ble_app/app_ancc/app_ancc_task.c | 29 +- services/ble_app/app_batt/app_batt.c | 184 +- services/ble_app/app_ble_key.cpp | 111 +- services/ble_app/app_ble_uart.cpp | 175 +- .../app_datapath/app_ble_cmd_handler.c | 773 +- .../ble_app/app_datapath/app_ble_custom_cmd.c | 132 +- .../app_datapath/app_datapath_server.c | 322 +- services/ble_app/app_dis/app_dis.c | 224 +- services/ble_app/app_gfps/app_gfps.c | 1737 +- services/ble_app/app_hid/app_hid.c | 1230 +- services/ble_app/app_hrps/app_hrps.c | 184 +- services/ble_app/app_htp/app_ht.c | 506 +- services/ble_app/app_main/app.c | 1795 +- services/ble_app/app_main/app_ble_core.c | 417 +- services/ble_app/app_main/app_ble_customif.c | 199 +- .../ble_app/app_main/app_ble_mode_switch.c | 1512 +- .../ble_app/app_main/app_ble_rx_handler.c | 247 +- services/ble_app/app_main/app_task.c | 1579 +- services/ble_app/app_ota/app_ota.c | 318 +- services/ble_app/app_sec/app_sec.c | 546 +- services/ble_app/app_tota/app_tota_ble.c | 286 +- services/ble_app/app_vob/voice_over_ble.c | 1534 +- .../ble_app/app_voice/app_voicepath_ble.c | 175 +- services/ble_profiles/ams/amsc/amsc.c | 162 +- services/ble_profiles/ams/amsc/amsc_task.c | 170 +- services/ble_profiles/anc/ancc/ancc.c | 162 +- services/ble_profiles/anc/ancc/ancc_task.c | 144 +- services/ble_profiles/anp/anpc/src/anpc.c | 280 +- .../ble_profiles/anp/anpc/src/anpc_task.c | 1254 +- services/ble_profiles/anp/anps/src/anps.c | 355 +- .../ble_profiles/anp/anps/src/anps_task.c | 957 +- services/ble_profiles/bas/basc/src/basc.c | 184 +- .../ble_profiles/bas/basc/src/basc_task.c | 812 +- services/ble_profiles/bas/bass/src/bass.c | 604 +- .../ble_profiles/bas/bass/src/bass_task.c | 445 +- services/ble_profiles/blp/blpc/src/blpc.c | 226 +- .../ble_profiles/blp/blpc/src/blpc_task.c | 660 +- services/ble_profiles/blp/blps/src/blps.c | 311 +- .../ble_profiles/blp/blps/src/blps_task.c | 501 +- services/ble_profiles/cpp/cppc/src/cppc.c | 1147 +- .../ble_profiles/cpp/cppc/src/cppc_task.c | 976 +- services/ble_profiles/cpp/cpps/src/cpps.c | 2502 +- .../ble_profiles/cpp/cpps/src/cpps_task.c | 999 +- services/ble_profiles/cscp/cscpc/src/cscpc.c | 233 +- .../ble_profiles/cscp/cscpc/src/cscpc_task.c | 1275 +- services/ble_profiles/cscp/cscps/src/cscps.c | 449 +- .../ble_profiles/cscp/cscps/src/cscps_task.c | 1232 +- .../datapath/datapathps/src/datapathps.c | 243 +- .../datapath/datapathps/src/datapathps_task.c | 641 +- services/ble_profiles/dis/disc/src/disc.c | 179 +- .../ble_profiles/dis/disc/src/disc_task.c | 396 +- services/ble_profiles/dis/diss/src/diss.c | 357 +- .../ble_profiles/dis/diss/src/diss_task.c | 340 +- services/ble_profiles/find/findl/src/findl.c | 177 +- .../ble_profiles/find/findl/src/findl_task.c | 334 +- services/ble_profiles/find/findt/src/findt.c | 129 +- .../ble_profiles/find/findt/src/findt_task.c | 107 +- .../gfps/gfps_provider/src/gfps_provider.c | 524 +- .../gfps_provider/src/gfps_provider_task.c | 482 +- services/ble_profiles/glp/glpc/src/glpc.c | 561 +- .../ble_profiles/glp/glpc/src/glpc_task.c | 970 +- services/ble_profiles/glp/glps/src/glps.c | 746 +- .../ble_profiles/glp/glps/src/glps_task.c | 992 +- .../ble_profiles/hogp/hogpbh/src/hogpbh.c | 185 +- .../hogp/hogpbh/src/hogpbh_task.c | 996 +- services/ble_profiles/hogp/hogpd/src/hogpd.c | 1422 +- .../ble_profiles/hogp/hogpd/src/hogpd_task.c | 1074 +- .../ble_profiles/hogp/hogprh/src/hogprh.c | 185 +- .../hogp/hogprh/src/hogprh_task.c | 1212 +- services/ble_profiles/hrp/hrpc/src/hrpc.c | 232 +- .../ble_profiles/hrp/hrpc/src/hrpc_task.c | 776 +- services/ble_profiles/hrp/hrps/src/hrps.c | 361 +- .../ble_profiles/hrp/hrps/src/hrps_task.c | 411 +- services/ble_profiles/htp/htpc/src/htpc.c | 284 +- .../ble_profiles/htp/htpc/src/htpc_task.c | 848 +- services/ble_profiles/htp/htpt/src/htpt.c | 824 +- .../ble_profiles/htp/htpt/src/htpt_task.c | 739 +- services/ble_profiles/lan/lanc/src/lanc.c | 999 +- .../ble_profiles/lan/lanc/src/lanc_task.c | 981 +- services/ble_profiles/lan/lans/src/lans.c | 2370 +- .../ble_profiles/lan/lans/src/lans_task.c | 849 +- services/ble_profiles/ota/ota.c | 150 +- services/ble_profiles/ota/ota_task.c | 488 +- services/ble_profiles/pasp/paspc/src/paspc.c | 186 +- .../ble_profiles/pasp/paspc/src/paspc_task.c | 895 +- services/ble_profiles/pasp/pasps/src/pasps.c | 238 +- .../ble_profiles/pasp/pasps/src/pasps_task.c | 759 +- services/ble_profiles/prf/prf.c | 1072 +- services/ble_profiles/prf/prf_utils.c | 538 +- services/ble_profiles/prf/prf_utils_128.c | 228 +- services/ble_profiles/prox/proxm/src/proxm.c | 207 +- .../ble_profiles/prox/proxm/src/proxm_task.c | 642 +- services/ble_profiles/prox/proxr/src/proxr.c | 215 +- .../ble_profiles/prox/proxr/src/proxr_task.c | 309 +- services/ble_profiles/rscp/rscpc/src/rscpc.c | 233 +- .../ble_profiles/rscp/rscpc/src/rscpc_task.c | 1272 +- services/ble_profiles/rscp/rscps/src/rscps.c | 446 +- .../ble_profiles/rscp/rscps/src/rscps_task.c | 1223 +- services/ble_profiles/tip/tipc/src/tipc.c | 193 +- .../ble_profiles/tip/tipc/src/tipc_task.c | 1057 +- services/ble_profiles/tip/tips/src/tips.c | 391 +- .../ble_profiles/tip/tips/src/tips_task.c | 717 +- services/ble_profiles/tota/tota_ble.c | 179 +- services/ble_profiles/tota/tota_task.c | 494 +- .../bt_app/a2dp_codecs/aac/a2dp_codec_aac.cpp | 91 +- .../bt_app/a2dp_codecs/app_a2dp_codecs.cpp | 274 +- .../a2dp_codecs/ldac/a2dp_codec_ldac.cpp | 93 +- .../a2dp_codecs/lhdc/a2dp_codec_lhdc.cpp | 107 +- .../bt_app/a2dp_codecs/lhdc/codec_lhdc.cpp | 199 +- .../a2dp_codecs/opus/a2dp_codec_opus.cpp | 53 +- .../bt_app/a2dp_codecs/sbc/a2dp_codec_sbc.cpp | 84 +- .../scalable/a2dp_codec_scalable.cpp | 72 +- services/bt_app/app_a2dp.cpp | 6880 +-- services/bt_app/app_a2dp_source.cpp | 855 +- services/bt_app/app_bqb.cpp | 127 +- services/bt_app/app_bqb_new_profile.cpp | 293 +- services/bt_app/app_bt.cpp | 8197 ++-- services/bt_app/app_bt_func.cpp | 1375 +- services/bt_app/app_bt_hid.cpp | 295 +- services/bt_app/app_bt_media_manager.cpp | 3564 +- services/bt_app/app_bt_stream.cpp | 11502 ++--- services/bt_app/app_btgatt.cpp | 20 +- services/bt_app/app_btmap_sms.cpp | 278 +- services/bt_app/app_dip.cpp | 139 +- services/bt_app/app_fp_rfcomm.cpp | 982 +- services/bt_app/app_fp_rfcomm.h | 77 +- services/bt_app/app_hfp.cpp | 2985 +- services/bt_app/app_hsp.cpp | 444 +- services/bt_app/app_keyhandle.cpp | 1828 +- services/bt_app/app_media_player.cpp | 2288 +- services/bt_app/app_rfcomm_mgr.cpp | 520 +- services/bt_app/app_ring_merge.cpp | 579 +- services/bt_app/app_ring_merge.h | 22 +- services/bt_app/app_sec.cpp | 54 +- services/bt_app/app_spp.cpp | 282 +- services/bt_app/audio_prompt_sbc.cpp | 1646 +- services/bt_app/besmain.cpp | 455 +- services/bt_if_enhanced/inc/me_api.h | 1865 +- .../communication_cmd_handle.cpp | 107 +- .../communication_sysapi.cpp | 841 +- services/communication/communication_svr.cpp | 891 +- services/communication/communication_svr.h | 10 +- services/cp_accel/cp_accel.c | 564 +- services/cp_accel/cp_queue.c | 199 +- services/hw_dsp/src/hw_filter_codec_iir.c | 156 +- .../inc/app_tws_ibrt_cmd_sync_a2dp_status.h | 27 +- .../interconnection/umm_malloc/umm_malloc.c | 827 +- .../audio/process/anc/cfg/anc_cfg.c | 3773 +- .../audio/process/filters/cfg/eq_cfg.c | 716 +- .../audio/process/filters/cfg/eq_cfg.h | 5 +- .../process/resample/coef/resample_coef.c | 35 +- services/norflash_api/norflash_api.cpp | 2676 +- services/nv_section/aud_section/aud_section.c | 263 +- .../customparam_section/customparam_section.c | 164 +- .../customparam_section/customparam_section.h | 52 +- .../factory_section/factory_section.c | 400 +- .../factory_section/factory_section.h | 74 +- .../nv_section/fpga_section/nvrecord_ble.c | 668 +- .../nv_section/fpga_section/nvrecord_bt.c | 649 +- .../nv_section/fpga_section/nvrecord_env.c | 126 +- .../fpga_section/nvrecord_externsion.c | 740 +- .../nv_section/log_section/coredump_section.c | 286 +- .../log_section/crash_dump_section.c | 588 +- services/nv_section/log_section/log_section.c | 1004 +- services/nv_section/log_section/log_section.h | 65 +- .../userdata_section/nvrecord_ble.c | 698 +- .../nv_section/userdata_section/nvrecord_bt.c | 755 +- .../userdata_section/nvrecord_dma_config.c | 163 +- .../userdata_section/nvrecord_env.c | 132 +- .../userdata_section/nvrecord_extension.c | 1686 +- .../userdata_section/nvrecord_extension.h | 258 +- .../nvrecord_fp_account_key.c | 221 +- .../userdata_section/nvrecord_gsound.c | 628 +- .../userdata_section/nvrecord_ota.c | 217 +- services/nvrecord/list_ext.c | 121 +- services/nvrecord/nvrec_config.c | 238 +- services/nvrecord/nvrecord.c | 3156 +- services/nvrecord/nvrecord_ble.c | 489 +- services/nvrecord/nvrecord_env.c | 198 +- services/nvrecord/nvrecord_fp_account_key.c | 197 +- services/osif/ddbif_bes.c | 587 +- services/osif/osif_rtx.c | 209 +- services/ota/ota_common.cpp | 2204 +- services/overlay/app_overlay.cpp | 73 +- services/resources/resources.cpp | 246 +- services/through_put/app_through_put.cpp | 485 +- services/tota/app_spp_tota.cpp | 402 +- .../tota/app_spp_tota_general_service.cpp | 412 +- services/tota/app_tota.cpp | 297 +- services/tota/app_tota_anc.cpp | 100 +- services/tota/app_tota_audio_dump.cpp | 190 +- services/tota/app_tota_cmd_handler.cpp | 632 +- services/tota/app_tota_conn.cpp | 251 +- services/tota/app_tota_custom.cpp | 117 +- services/tota/app_tota_data_handler.cpp | 198 +- services/tota/app_tota_flash_program.cpp | 522 +- services/tota/app_tota_general.cpp | 327 +- services/tota/app_tota_mic.cpp | 120 +- services/tota/tota_buffer_manager.cpp | 194 +- services/tota/tota_stream_data_transfer.cpp | 265 +- services/tota/tota_test.cpp | 49 +- tests/anc_usb/adda_loop_app.c | 271 +- tests/anc_usb/anc_usb_app.c | 1344 +- tests/anc_usb/dualadc_audio_app.c | 366 +- tests/anc_usb/main.c | 464 +- tests/anc_usb/memutils.c | 105 +- tests/anc_usb/mic_key.c | 197 +- tests/anc_usb/safe_queue.c | 235 +- tests/anc_usb/speech_process.c | 330 +- tests/anc_usb/usb_audio_app.c | 8986 ++-- tests/anc_usb/usb_vendor_msg.c | 349 +- thirdparty/demo_lib/demo_lib.c | 14 +- thirdparty/noise_tracker_lib/noise_tracker.c | 57 +- thirdparty/userapi/app_thirdparty.cpp | 215 +- thirdparty/userapi/demo_app/LibDemo.cpp | 50 +- .../noise_tracker_app/NoiseTrackerDemo.cpp | 202 +- .../noise_tracker_callback.c | 5 +- utils/boot_struct/boot_struct.c | 177 +- utils/build_info/build_info.c | 49 +- utils/cqueue/cqueue.c | 604 +- utils/crash_catcher/CrashCatcher.c | 599 +- utils/crash_catcher/HexDump.c | 310 +- utils/crc16/crc16.c | 80 +- utils/crc32/crc32.c | 157 +- utils/crc32/crc32_rom.c | 7 +- utils/heap/heap_api.c | 262 +- utils/heap/multi_heap.c | 1158 +- utils/heap/multi_heap_internal.h | 17 +- utils/heap/pool_api.c | 123 +- utils/hexdump/hexdump.c | 101 +- utils/hwtimer_list/hwtimer_list.c | 936 +- utils/kfifo/kfifo.c | 136 +- utils/libc/libc_rom.c | 173 +- utils/list/list.c | 178 +- utils/lockcqueue/lockcqueue.c | 41 +- utils/retention_ram/retention_ram.c | 90 +- utils/sha256/sha256.c | 361 +- utils/sha256/sha256_rom.c | 25 +- utils/xyzmodem/xyzmodem.c | 593 +- 794 files changed, 240573 insertions(+), 256459 deletions(-) diff --git a/apps/anc/inc/anc_wnr.h b/apps/anc/inc/anc_wnr.h index 15d6d57..8e1ed1a 100644 --- a/apps/anc/inc/anc_wnr.h +++ b/apps/anc/inc/anc_wnr.h @@ -17,30 +17,29 @@ #define __ANC_WNR_H__ // #include "plat_types.h" +#include #ifdef __cplusplus extern "C" { #endif -typedef enum -{ - ANC_WNR_OPEN_MODE_STANDALONE = 0, - ANC_WNR_OPEN_MODE_CONFIGURE, +typedef enum { + ANC_WNR_OPEN_MODE_STANDALONE = 0, + ANC_WNR_OPEN_MODE_CONFIGURE, - ANC_WNR_OPEN_MODE_QTY + ANC_WNR_OPEN_MODE_QTY } anc_wnr_open_mode_t; void anc_release_gain(void); -typedef enum -{ - APP_WNR_NOTIFY_DETECT_RESULT, - APP_WNR_REQUEST_DETECT_RESULT, - APP_WNR_RESPONSE_DETECT_RESULT, - APP_WNR_PROCESS_DETECT_RESULT, - APP_WNR_SET_TRIGGER, - APP_WNR_EXCUTE_TRIGGER, - APP_WNR_SHARE_MODULE_INFO, +typedef enum { + APP_WNR_NOTIFY_DETECT_RESULT, + APP_WNR_REQUEST_DETECT_RESULT, + APP_WNR_RESPONSE_DETECT_RESULT, + APP_WNR_PROCESS_DETECT_RESULT, + APP_WNR_SET_TRIGGER, + APP_WNR_EXCUTE_TRIGGER, + APP_WNR_SHARE_MODULE_INFO, } anc_wnr_sync_ctrl_internal_event_e; int32_t anc_wnr_ctrl(int32_t sample_rate, int32_t frame_len); diff --git a/apps/anc/src/anc_assist.c b/apps/anc/src/anc_assist.c index 5e63926..2d66f70 100644 --- a/apps/anc/src/anc_assist.c +++ b/apps/anc/src/anc_assist.c @@ -1,6 +1,5 @@ - /*************************************************************************** * * Copyright 2015-2019 BES. @@ -17,49 +16,43 @@ * ****************************************************************************/ #include "anc_assist.h" -#include "hal_trace.h" +#include "anc_assist_algo.h" +#include "anc_process.h" #include "arm_math.h" #include "audio_dump.h" -#include "speech_cfg.h" -#include "anc_process.h" #include "audioflinger.h" -#include "anc_assist_algo.h" -#include "hal_codec.h" -#include "audioflinger.h" -#include "hal_timer.h" #include "hal_aud.h" +#include "hal_codec.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "speech_cfg.h" +#include "speech_memory.h" +#include "speech_ssat.h" #include #include #include -#include "hal_aud.h" -#include "anc_process.h" -#include "anc_assist_algo.h" -#include "speech_memory.h" -#include "speech_ssat.h" - #if defined(ANC_ASSIST_NOISE_ADAPTIVE_ENABLED) #include "main_classify.h" #endif - static void _close_mic_anc_assist(); static void _open_mic_anc_assist(); -#define _SAMPLE_RATE (16000) +#define _SAMPLE_RATE (16000) #if defined(ANC_ASSIST_NOISE_ADAPTIVE_ENABLED) -#define _FRAME_LEN (128) +#define _FRAME_LEN (128) #else -#define _FRAME_LEN (160) +#define _FRAME_LEN (160) #endif -#define _CHANNEL_NUM_MAX (3) -#define SAMPLE_BYTES (sizeof(ASSIST_PCM_T)) -#define AF_STREAM_BUFF_SIZE (_FRAME_LEN * SAMPLE_BYTES * _CHANNEL_NUM_MAX * 2) -#define ANC_ADPT_STREAM_ID AUD_STREAM_ID_3 +#define _CHANNEL_NUM_MAX (3) +#define SAMPLE_BYTES (sizeof(ASSIST_PCM_T)) +#define AF_STREAM_BUFF_SIZE (_FRAME_LEN * SAMPLE_BYTES * _CHANNEL_NUM_MAX * 2) +#define ANC_ADPT_STREAM_ID AUD_STREAM_ID_3 -#define _FRAME_LEN_MAX (160) -#define _SAMPLE_BITS_MAX (32) +#define _FRAME_LEN_MAX (160) +#define _SAMPLE_BITS_MAX (32) static uint8_t __attribute__((aligned(4))) af_stream_buff[AF_STREAM_BUFF_SIZE]; static ASSIST_PCM_T af_stream_mic1[_FRAME_LEN_MAX * (_SAMPLE_BITS_MAX / 8)]; @@ -69,377 +62,322 @@ int MIC_NUM = 0; int MIC_MAP = 0; #if defined(ANC_ASSIST_PILOT_ENABLED) -#define _PLAY_SAMPLE_RATE (8000) -#define _PLAY_FRAME_LEN (80) -#define AF_PLAY_STREAM_BUFF_SIZE (_PLAY_FRAME_LEN * SAMPLE_BYTES * 1 * 2) -static uint8_t __attribute__((aligned(4))) af_play_stream_buff[AF_PLAY_STREAM_BUFF_SIZE]; +#define _PLAY_SAMPLE_RATE (8000) +#define _PLAY_FRAME_LEN (80) +#define AF_PLAY_STREAM_BUFF_SIZE (_PLAY_FRAME_LEN * SAMPLE_BYTES * 1 * 2) +static uint8_t __attribute__((aligned(4))) +af_play_stream_buff[AF_PLAY_STREAM_BUFF_SIZE]; #endif #if defined(ANC_ASSIST_NOISE_ADAPTIVE_ENABLED) -ClassifyState * NoiseClassify_st = NULL; +ClassifyState *NoiseClassify_st = NULL; #endif -#if defined(ANC_ASSIST_PILOT_ENABLED) || defined(ANC_ASSIST_HESS_ENABLED) || defined(ANC_ASSIST_PNC_ENABLED) || defined(ANC_ASSIST_DEHOWLING_ENABLED) || defined(ANC_ASSIST_WNR_ENABLED) || defined(ANC_ASSIST_NOISE_ADAPTIVE_ENABLED) +#if defined(ANC_ASSIST_PILOT_ENABLED) || defined(ANC_ASSIST_HESS_ENABLED) || \ + defined(ANC_ASSIST_PNC_ENABLED) || \ + defined(ANC_ASSIST_DEHOWLING_ENABLED) || \ + defined(ANC_ASSIST_WNR_ENABLED) || \ + defined(ANC_ASSIST_NOISE_ADAPTIVE_ENABLED) -extern const struct_anc_cfg * anc_coef_list_48k[1]; -void anc_assist_change_curve(int curve_id){ - TRACE(2,"[%s] change anc curve %d",__func__,curve_id); - anc_set_cfg(anc_coef_list_48k[0],ANC_FEEDFORWARD,ANC_GAIN_NO_DELAY); - anc_set_cfg(anc_coef_list_48k[0],ANC_FEEDBACK,ANC_GAIN_NO_DELAY); +extern const struct_anc_cfg *anc_coef_list_48k[1]; +void anc_assist_change_curve(int curve_id) { + TRACE(2, "[%s] change anc curve %d", __func__, curve_id); + anc_set_cfg(anc_coef_list_48k[0], ANC_FEEDFORWARD, ANC_GAIN_NO_DELAY); + anc_set_cfg(anc_coef_list_48k[0], ANC_FEEDBACK, ANC_GAIN_NO_DELAY); } -bool audio_engine_tt_is_on(){ - return 1; -} - - +bool audio_engine_tt_is_on() { return 1; } #define _tgt_ff_gain (512) -void anc_assist_set_anc_gain(float gain_ch_l, float gain_ch_r,enum ANC_TYPE_T anc_type){ - - TRACE(2,"[%s] set anc gain %d",__func__,(int)(100*gain_ch_l)); - uint32_t tgt_ff_gain_l,tgt_ff_gain_r; - tgt_ff_gain_l = (uint32_t)(_tgt_ff_gain*gain_ch_l); - tgt_ff_gain_r = (uint32_t)(_tgt_ff_gain*gain_ch_r); - anc_set_gain(tgt_ff_gain_l,tgt_ff_gain_r,anc_type); +void anc_assist_set_anc_gain(float gain_ch_l, float gain_ch_r, + enum ANC_TYPE_T anc_type) { + + TRACE(2, "[%s] set anc gain %d", __func__, (int)(100 * gain_ch_l)); + uint32_t tgt_ff_gain_l, tgt_ff_gain_r; + tgt_ff_gain_l = (uint32_t)(_tgt_ff_gain * gain_ch_l); + tgt_ff_gain_r = (uint32_t)(_tgt_ff_gain * gain_ch_r); + anc_set_gain(tgt_ff_gain_l, tgt_ff_gain_r, anc_type); } #endif #if defined(ANC_ASSIST_PILOT_ENABLED) -static LeakageDetectionState * pilot_st = NULL; +static LeakageDetectionState *pilot_st = NULL; #endif - -#if defined(ANC_ASSIST_HESS_ENABLED) || defined(ANC_ASSIST_PNC_ENABLED) || defined(ANC_ASSIST_DEHOWLING_ENABLED) || defined(ANC_ASSIST_WNR_ENABLED) -static ANCAssistMultiState * anc_assist_multi_st = NULL; +#if defined(ANC_ASSIST_HESS_ENABLED) || defined(ANC_ASSIST_PNC_ENABLED) || \ + defined(ANC_ASSIST_DEHOWLING_ENABLED) || defined(ANC_ASSIST_WNR_ENABLED) +static ANCAssistMultiState *anc_assist_multi_st = NULL; #endif - - ANC_ASSIST_MODE_T g_anc_assist_mode = ANC_ASSIST_MODE_QTY; -void anc_assist_open(ANC_ASSIST_MODE_T mode){ - g_anc_assist_mode = mode; +void anc_assist_open(ANC_ASSIST_MODE_T mode) { + g_anc_assist_mode = mode; - - //normal init + // normal init #if defined(ANC_ASSIST_PILOT_ENABLED) - pilot_st = LeakageDetection_create(160,0); + pilot_st = LeakageDetection_create(160, 0); #endif -#if defined(ANC_ASSIST_HESS_ENABLED) || defined(ANC_ASSIST_PNC_ENABLED) || defined(ANC_ASSIST_DEHOWLING_ENABLED) || defined(ANC_ASSIST_WNR_ENABLED) - anc_assist_multi_st = ANCAssistMulti_create(_SAMPLE_RATE,_FRAME_LEN,128); +#if defined(ANC_ASSIST_HESS_ENABLED) || defined(ANC_ASSIST_PNC_ENABLED) || \ + defined(ANC_ASSIST_DEHOWLING_ENABLED) || defined(ANC_ASSIST_WNR_ENABLED) + anc_assist_multi_st = ANCAssistMulti_create(_SAMPLE_RATE, _FRAME_LEN, 128); #endif #if defined(ANC_ASSIST_NOISE_ADAPTIVE_ENABLED) - NoiseClassify_st = classify_create(_SAMPLE_RATE, _FRAME_LEN); + NoiseClassify_st = classify_create(_SAMPLE_RATE, _FRAME_LEN); #endif - // audio_dump_init(160,sizeof(short),3); + // audio_dump_init(160,sizeof(short),3); - - if( mode == ANC_ASSIST_MODE_QTY){ - return; + if (mode == ANC_ASSIST_MODE_QTY) { + return; + } else { + if (mode == ANC_ASSIST_STANDALONE || mode == ANC_ASSIST_MUSIC) { + _open_mic_anc_assist(); } - else{ - if(mode == ANC_ASSIST_STANDALONE || mode == ANC_ASSIST_MUSIC ){ - _open_mic_anc_assist(); - } - if(mode == ANC_ASSIST_PHONE_8K){ - // normal init 8k - } - else if(mode == ANC_ASSIST_PHONE_16K){ - // normal init 16k - } - + if (mode == ANC_ASSIST_PHONE_8K) { + // normal init 8k + } else if (mode == ANC_ASSIST_PHONE_16K) { + // normal init 16k } - - - + } } - - - -void anc_assist_close(){ +void anc_assist_close() { #if defined(ANC_ASSIST_PILOT_ENABLED) - LeakageDetection_destroy(pilot_st); + LeakageDetection_destroy(pilot_st); #endif -#if defined(ANC_ASSIST_HESS_ENABLED) || defined(ANC_ASSIST_PNC_ENABLED) || defined(ANC_ASSIST_DEHOWLING_ENABLED) || defined(ANC_ASSIST_WNR_ENABLED) - ANCAssistMulti_destroy(anc_assist_multi_st); +#if defined(ANC_ASSIST_HESS_ENABLED) || defined(ANC_ASSIST_PNC_ENABLED) || \ + defined(ANC_ASSIST_DEHOWLING_ENABLED) || defined(ANC_ASSIST_WNR_ENABLED) + ANCAssistMulti_destroy(anc_assist_multi_st); #endif #if defined(ANC_ASSIST_NOISE_ADAPTIVE_ENABLED) - classify_destroy(NoiseClassify_st); + classify_destroy(NoiseClassify_st); #endif - // ext_heap_deinit(); + // ext_heap_deinit(); - if( g_anc_assist_mode == ANC_ASSIST_MODE_QTY){ - return; + if (g_anc_assist_mode == ANC_ASSIST_MODE_QTY) { + return; + } else { + if (g_anc_assist_mode == ANC_ASSIST_STANDALONE || + g_anc_assist_mode == ANC_ASSIST_MUSIC) { + _close_mic_anc_assist(); } - else{ - if(g_anc_assist_mode == ANC_ASSIST_STANDALONE || g_anc_assist_mode == ANC_ASSIST_MUSIC ){ - _close_mic_anc_assist(); - } - if(g_anc_assist_mode == ANC_ASSIST_PHONE_8K){ - // normal init 8k - } - else if(g_anc_assist_mode == ANC_ASSIST_PHONE_16K){ - // normal init 16k - } - + if (g_anc_assist_mode == ANC_ASSIST_PHONE_8K) { + // normal init 8k + } else if (g_anc_assist_mode == ANC_ASSIST_PHONE_16K) { + // normal init 16k } - + } } - extern ASSIST_PCM_T ref_buf_data[80]; -void anc_assist_process(uint8_t * buf, int len){ +void anc_assist_process(uint8_t *buf, int len) { + int32_t frame_len = len / SAMPLE_BYTES / MIC_NUM; + ASSERT(frame_len == _FRAME_LEN, "[%s] frame len(%d) is invalid.", __func__, + frame_len); + ASSIST_PCM_T *pcm_buf = (ASSIST_PCM_T *)buf; - int32_t frame_len = len / SAMPLE_BYTES / MIC_NUM; - ASSERT(frame_len == _FRAME_LEN, "[%s] frame len(%d) is invalid.", __func__, frame_len); - ASSIST_PCM_T *pcm_buf = (ASSIST_PCM_T *)buf; + ASSIST_PCM_T *mic1 = (ASSIST_PCM_T *)af_stream_mic1; + ASSIST_PCM_T *mic2 = (ASSIST_PCM_T *)af_stream_mic2; + ASSIST_PCM_T *mic3 = (ASSIST_PCM_T *)af_stream_mic3; - ASSIST_PCM_T *mic1 = (ASSIST_PCM_T *)af_stream_mic1; - ASSIST_PCM_T *mic2 = (ASSIST_PCM_T *)af_stream_mic2; - ASSIST_PCM_T *mic3 = (ASSIST_PCM_T *)af_stream_mic3; - - for (int32_t i=0; itgt_ff_gain_l){ - pre_ff_gain_l = pre_ff_gain_l - 1; - ff_gain_l = pre_ff_gain_l; - } - - - if(pre_ff_gain_rtgt_ff_gain_r){ - pre_ff_gain_r = pre_ff_gain_r - 1; - ff_gain_r = pre_ff_gain_r; - } +static void anc_tuning_ff_gain_timer_timeout(void *param) { + timer_cnt++; + int32_t ff_gain_l = 0; + int32_t ff_gain_r = 0; + if ((timer_cnt < delta_ff_gain_l) || (timer_cnt < delta_ff_gain_r)) { + if (pre_ff_gain_l < tgt_ff_gain_l) { + pre_ff_gain_l = pre_ff_gain_l + 1; + ff_gain_l = pre_ff_gain_l; + } else if (pre_ff_gain_l > tgt_ff_gain_l) { + pre_ff_gain_l = pre_ff_gain_l - 1; + ff_gain_l = pre_ff_gain_l; + } - anc_set_gain(ff_gain_l, ff_gain_r, ANC_FEEDFORWARD); - TRACE(3,"[%s] ff_gain_l = %d, ff_gain_r = %d", __func__, ff_gain_l, ff_gain_r); + if (pre_ff_gain_r < tgt_ff_gain_r) { + pre_ff_gain_r = pre_ff_gain_r + 1; + ff_gain_r = pre_ff_gain_r; + } else if (pre_ff_gain_r > tgt_ff_gain_r) { + pre_ff_gain_r = pre_ff_gain_r - 1; + ff_gain_r = pre_ff_gain_r; + } - struct anc_tuning_ctrl *c = (struct anc_tuning_ctrl *)param; - hwtimer_start(c->timer_ff_gain_id, US_TO_TICKS(ANC_TIMER_PERIOD_GAIN)); - ff_smoothing_flag = 1; - } else { - anc_set_gain(tgt_ff_gain_l, tgt_ff_gain_r, ANC_FEEDFORWARD); - ff_smoothing_flag = 0; - } + anc_set_gain(ff_gain_l, ff_gain_r, ANC_FEEDFORWARD); + TRACE(3, "[%s] ff_gain_l = %d, ff_gain_r = %d", __func__, ff_gain_l, + ff_gain_r); + struct anc_tuning_ctrl *c = (struct anc_tuning_ctrl *)param; + hwtimer_start(c->timer_ff_gain_id, US_TO_TICKS(ANC_TIMER_PERIOD_GAIN)); + ff_smoothing_flag = 1; + } else { + anc_set_gain(tgt_ff_gain_l, tgt_ff_gain_r, ANC_FEEDFORWARD); + ff_smoothing_flag = 0; + } } #endif -static void _set_anc_ff_gain(bool update_anc_gain, float gain_coef, enum ANC_TYPE_T type) -{ +static void _set_anc_ff_gain(bool update_anc_gain, float gain_coef, + enum ANC_TYPE_T type) { #ifdef HW_SUPPORT_SMOOOTHING_GAIN - if(update_anc_gain){ - anc_get_gain(&pre_ff_gain_l, &pre_ff_gain_r, ANC_FEEDFORWARD); - anc_ff_gain_l = pre_ff_gain_l; - anc_ff_gain_r = pre_ff_gain_r; - TRACE(3, "[%s] Update anc_gain_l = %d, anc_gain_r = %d.", __func__, anc_ff_gain_l, anc_ff_gain_r); - } - tgt_ff_gain_l = (int32_t)(anc_ff_gain_l * gain_coef); - tgt_ff_gain_r = (int32_t)(anc_ff_gain_r * gain_coef); - TRACE(3, "[%s] tgt_ff_gain_l = %d, tgt_ff_gain_r = %d.", __func__, tgt_ff_gain_l, tgt_ff_gain_r); - anc_set_gain(tgt_ff_gain_l, tgt_ff_gain_r, ANC_FEEDFORWARD); + if (update_anc_gain) { + anc_get_gain(&pre_ff_gain_l, &pre_ff_gain_r, ANC_FEEDFORWARD); + anc_ff_gain_l = pre_ff_gain_l; + anc_ff_gain_r = pre_ff_gain_r; + TRACE(3, "[%s] Update anc_gain_l = %d, anc_gain_r = %d.", __func__, + anc_ff_gain_l, anc_ff_gain_r); + } + tgt_ff_gain_l = (int32_t)(anc_ff_gain_l * gain_coef); + tgt_ff_gain_r = (int32_t)(anc_ff_gain_r * gain_coef); + TRACE(3, "[%s] tgt_ff_gain_l = %d, tgt_ff_gain_r = %d.", __func__, + tgt_ff_gain_l, tgt_ff_gain_r); + anc_set_gain(tgt_ff_gain_l, tgt_ff_gain_r, ANC_FEEDFORWARD); #else - struct anc_tuning_ctrl *c = &anc_tctrl; - //uint32_t cur_time = TICKS_TO_MS(hal_sys_timer_get()); + struct anc_tuning_ctrl *c = &anc_tctrl; + // uint32_t cur_time = TICKS_TO_MS(hal_sys_timer_get()); - //reset timer - if (c->timer_ff_gain_run) { - hwtimer_stop(c->timer_ff_gain_id); - } - anc_get_gain(&pre_ff_gain_l, &pre_ff_gain_r, ANC_FEEDFORWARD); - TRACE(3,"[%s] pre_ff_gain_l = %d, pre_ff_gain_r = %d.", __func__, pre_ff_gain_l, pre_ff_gain_r); - if(update_anc_gain && !ff_smoothing_flag){ - anc_ff_gain_l = pre_ff_gain_l; - anc_ff_gain_r = pre_ff_gain_r; - TRACE(3,"[%s] Update anc_gain_l = %d, anc_gain_r = %d.", __func__, anc_ff_gain_l, anc_ff_gain_r); - } - tgt_ff_gain_l = (int32_t)(anc_ff_gain_l * gain_coef); - tgt_ff_gain_r = (int32_t)(anc_ff_gain_r * gain_coef); - delta_ff_gain_l = abs(tgt_ff_gain_l-pre_ff_gain_l); - delta_ff_gain_r = abs(tgt_ff_gain_r-pre_ff_gain_r); - TRACE(3,"[%s] tgt_ff_gain_l = %d, tgt_ff_gain_r = %d.", __func__, tgt_ff_gain_l, tgt_ff_gain_r); - - timer_cnt=0; - - //timer restart - hwtimer_start(c->timer_ff_gain_id, MS_TO_TICKS(ANC_TIMER_PERIOD_GAIN)); - c->timer_ff_gain_run = 1; - //set gain directly - //anc_set_gain(gain_ch_l, gain_ch_r, type); + // reset timer + if (c->timer_ff_gain_run) { + hwtimer_stop(c->timer_ff_gain_id); + } + anc_get_gain(&pre_ff_gain_l, &pre_ff_gain_r, ANC_FEEDFORWARD); + TRACE(3, "[%s] pre_ff_gain_l = %d, pre_ff_gain_r = %d.", __func__, + pre_ff_gain_l, pre_ff_gain_r); + if (update_anc_gain && !ff_smoothing_flag) { + anc_ff_gain_l = pre_ff_gain_l; + anc_ff_gain_r = pre_ff_gain_r; + TRACE(3, "[%s] Update anc_gain_l = %d, anc_gain_r = %d.", __func__, + anc_ff_gain_l, anc_ff_gain_r); + } + tgt_ff_gain_l = (int32_t)(anc_ff_gain_l * gain_coef); + tgt_ff_gain_r = (int32_t)(anc_ff_gain_r * gain_coef); + delta_ff_gain_l = abs(tgt_ff_gain_l - pre_ff_gain_l); + delta_ff_gain_r = abs(tgt_ff_gain_r - pre_ff_gain_r); + TRACE(3, "[%s] tgt_ff_gain_l = %d, tgt_ff_gain_r = %d.", __func__, + tgt_ff_gain_l, tgt_ff_gain_r); - //AUD_TRACE(TRACE_MASK_INFO, "set anc gain :[%d], gain_ch_l=%d, gian_ch_r=%d, type=%d", - //cur_time, gain_ch_l, gain_ch_r, (int)type); + timer_cnt = 0; + + // timer restart + hwtimer_start(c->timer_ff_gain_id, MS_TO_TICKS(ANC_TIMER_PERIOD_GAIN)); + c->timer_ff_gain_run = 1; + // set gain directly + // anc_set_gain(gain_ch_l, gain_ch_r, type); + + // AUD_TRACE(TRACE_MASK_INFO, "set anc gain :[%d], gain_ch_l=%d, gian_ch_r=%d, + // type=%d", cur_time, gain_ch_l, gain_ch_r, (int)type); #endif } -void anc_release_gain(void) -{ - TRACE(1,"[%s] ...Release FF gain", __func__); +void anc_release_gain(void) { + TRACE(1, "[%s] ...Release FF gain", __func__); - _set_anc_ff_gain(false, 1, ANC_FEEDFORWARD); + _set_anc_ff_gain(false, 1, ANC_FEEDFORWARD); } -int32_t anc_wnr_ctrl(int32_t sample_rate, int32_t frame_len) -{ - TRACE(3,"[%s] sample_rate = %d, frame_len = %d", __func__, sample_rate, frame_len); +int32_t anc_wnr_ctrl(int32_t sample_rate, int32_t frame_len) { + TRACE(3, "[%s] sample_rate = %d, frame_len = %d", __func__, sample_rate, + frame_len); - g_sample_rate = sample_rate; - g_frame_len = frame_len; + g_sample_rate = sample_rate; + g_frame_len = frame_len; - if (g_sample_rate == 16000) { - g_frame_len >>= 1; + if (g_sample_rate == 16000) { + g_frame_len >>= 1; + } + + return 0; +} + +static void app_wnr_reset_state_queue(void) { + g_anc_wnr_state_queue.index_for_normal = 0; + g_anc_wnr_state_queue.index_for_sco = 0; + g_anc_wnr_state_queue.number_for_normal = 0; + g_anc_wnr_state_queue.number_for_sco = 0; + memset(g_anc_wnr_state_queue.buf_for_normal, 0, + WNR_SYNC_COUNTER_THRESHOLD_FOR_NORMAL); + memset(g_anc_wnr_state_queue.buf_for_sco, 0, + WNR_SYNC_COUNTER_THRESHOLD_FOR_SCO); +} +static void app_wnr_push_state_to_queue(uint8_t open_mode, uint8_t arg0) { + if (open_mode == ANC_WNR_OPEN_MODE_STANDALONE) // normal mode... + { + g_anc_wnr_state_queue + .buf_for_normal[g_anc_wnr_state_queue.index_for_normal] = arg0; + + if (++g_anc_wnr_state_queue.index_for_normal >= + WNR_SYNC_COUNTER_THRESHOLD_FOR_NORMAL) { + g_anc_wnr_state_queue.index_for_normal = 0; } - return 0; -} - -static void app_wnr_reset_state_queue(void) -{ - g_anc_wnr_state_queue.index_for_normal = 0; - g_anc_wnr_state_queue.index_for_sco = 0; - g_anc_wnr_state_queue.number_for_normal = 0; - g_anc_wnr_state_queue.number_for_sco = 0; - memset(g_anc_wnr_state_queue.buf_for_normal, 0, WNR_SYNC_COUNTER_THRESHOLD_FOR_NORMAL); - memset(g_anc_wnr_state_queue.buf_for_sco, 0, WNR_SYNC_COUNTER_THRESHOLD_FOR_SCO); -} -static void app_wnr_push_state_to_queue(uint8_t open_mode, uint8_t arg0) -{ - if(open_mode == ANC_WNR_OPEN_MODE_STANDALONE)//normal mode... - { - g_anc_wnr_state_queue.buf_for_normal[g_anc_wnr_state_queue.index_for_normal] = arg0; - - if(++g_anc_wnr_state_queue.index_for_normal >= WNR_SYNC_COUNTER_THRESHOLD_FOR_NORMAL) - { - g_anc_wnr_state_queue.index_for_normal = 0; - } - - if(g_anc_wnr_state_queue.number_for_normal < WNR_SYNC_COUNTER_THRESHOLD_FOR_NORMAL) - { - g_anc_wnr_state_queue.number_for_normal++; - } + if (g_anc_wnr_state_queue.number_for_normal < + WNR_SYNC_COUNTER_THRESHOLD_FOR_NORMAL) { + g_anc_wnr_state_queue.number_for_normal++; } - else//sco mode... - { - g_anc_wnr_state_queue.buf_for_sco[g_anc_wnr_state_queue.index_for_sco] = arg0; + } else // sco mode... + { + g_anc_wnr_state_queue.buf_for_sco[g_anc_wnr_state_queue.index_for_sco] = + arg0; - if(++g_anc_wnr_state_queue.index_for_sco >= WNR_SYNC_COUNTER_THRESHOLD_FOR_SCO) - { - g_anc_wnr_state_queue.index_for_sco = 0; - } - - if(g_anc_wnr_state_queue.number_for_sco < WNR_SYNC_COUNTER_THRESHOLD_FOR_SCO) - { - g_anc_wnr_state_queue.number_for_sco++; - } + if (++g_anc_wnr_state_queue.index_for_sco >= + WNR_SYNC_COUNTER_THRESHOLD_FOR_SCO) { + g_anc_wnr_state_queue.index_for_sco = 0; } -} -static uint8_t app_wnr_get_state_from_queue(uint8_t open_mode) -{ - uint8_t counter0 = 0; - uint8_t counter1 = 0; - uint8_t counter2 = 0; -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(2,"[%s] open_mode:%d", __func__, open_mode); - TRACE(2,"[%s] index_for_normal:%d", __func__, g_anc_wnr_state_queue.index_for_normal); - TRACE(2,"[%s] index_for_sco:%d", __func__, g_anc_wnr_state_queue.index_for_sco); - TRACE(2,"[%s] number_for_normal:%d", __func__, g_anc_wnr_state_queue.number_for_normal); - TRACE(2,"[%s] number_for_sco:%d", __func__, g_anc_wnr_state_queue.number_for_sco); - TRACE(1,"[%s] buf_for_normal:", __func__); - DUMP8("%d ", g_anc_wnr_state_queue.buf_for_normal, g_anc_wnr_state_queue.number_for_normal); - TRACE(1,"[%s] buf_for_sco:", __func__); - DUMP8("%d ", g_anc_wnr_state_queue.buf_for_sco, g_anc_wnr_state_queue.number_for_sco); + if (g_anc_wnr_state_queue.number_for_sco < + WNR_SYNC_COUNTER_THRESHOLD_FOR_SCO) { + g_anc_wnr_state_queue.number_for_sco++; + } + } +} +static uint8_t app_wnr_get_state_from_queue(uint8_t open_mode) { + uint8_t counter0 = 0; + uint8_t counter1 = 0; + uint8_t counter2 = 0; + +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(2, "[%s] open_mode:%d", __func__, open_mode); + TRACE(2, "[%s] index_for_normal:%d", __func__, + g_anc_wnr_state_queue.index_for_normal); + TRACE(2, "[%s] index_for_sco:%d", __func__, + g_anc_wnr_state_queue.index_for_sco); + TRACE(2, "[%s] number_for_normal:%d", __func__, + g_anc_wnr_state_queue.number_for_normal); + TRACE(2, "[%s] number_for_sco:%d", __func__, + g_anc_wnr_state_queue.number_for_sco); + TRACE(1, "[%s] buf_for_normal:", __func__); + DUMP8("%d ", g_anc_wnr_state_queue.buf_for_normal, + g_anc_wnr_state_queue.number_for_normal); + TRACE(1, "[%s] buf_for_sco:", __func__); + DUMP8("%d ", g_anc_wnr_state_queue.buf_for_sco, + g_anc_wnr_state_queue.number_for_sco); #endif - if(open_mode == ANC_WNR_OPEN_MODE_STANDALONE)//normal mode... - { - for(uint8_t i = 0; i= counter1) - { - if(counter0 >= counter2) - { - return 0; - } - else - { - return 2; - } + if (counter0 >= counter1) { + if (counter0 >= counter2) { + return 0; + } else { + return 2; } - else - { - if(counter1 >= counter2) - { - return 1; - } - else - { - return 2; - } + } else { + if (counter1 >= counter2) { + return 1; + } else { + return 2; } + } } -static void app_wnr_trigger_internal_event(uint32_t evt, uint32_t arg0, uint32_t arg1, uint32_t arg2) -{ - APP_MESSAGE_BLOCK msg; -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(5,"[%s] evt:%d arg0:%d arg1:%d arg2:%d", __func__, evt, arg0, arg1, arg2); +static void app_wnr_trigger_internal_event(uint32_t evt, uint32_t arg0, + uint32_t arg1, uint32_t arg2) { + APP_MESSAGE_BLOCK msg; +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(5, "[%s] evt:%d arg0:%d arg1:%d arg2:%d", __func__, evt, arg0, arg1, + arg2); #endif - msg.mod_id = APP_MODUAL_WNR; - msg.msg_body.message_id = evt; - msg.msg_body.message_Param0 = arg0; - msg.msg_body.message_Param1 = arg1; - msg.msg_body.message_Param2 = arg2; - app_mailbox_put(&msg); + msg.mod_id = APP_MODUAL_WNR; + msg.msg_body.message_id = evt; + msg.msg_body.message_Param0 = arg0; + msg.msg_body.message_Param1 = arg1; + msg.msg_body.message_Param2 = arg2; + app_mailbox_put(&msg); } -static void app_wnr_share_module_info(void) -{ - uint8_t buf[3] = {0}; +static void app_wnr_share_module_info(void) { + uint8_t buf[3] = {0}; -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(2,"[%s] local_module_onoff:%d", __func__, g_local_Wind_module_onoff); +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(2, "[%s] local_module_onoff:%d", __func__, g_local_Wind_module_onoff); #endif - buf[0] = IBRT_ACTION_SYNC_WNR; - buf[1] = (uint8_t)APP_WNR_SHARE_MODULE_INFO; - buf[2] = (uint8_t)g_local_Wind_module_onoff; - - app_ibrt_ui_send_user_action(buf, 3); + buf[0] = IBRT_ACTION_SYNC_WNR; + buf[1] = (uint8_t)APP_WNR_SHARE_MODULE_INFO; + buf[2] = (uint8_t)g_local_Wind_module_onoff; + + app_ibrt_ui_send_user_action(buf, 3); } -void app_wnr_sync_state(void) -{ -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"[%s] enter...", __func__); +void app_wnr_sync_state(void) { +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "[%s] enter...", __func__); #endif - wnr_sync_counter_for_sco = 0; - wnr_sync_counter_for_normal = 0; - g_wnr_notify_flag = false; - g_wnr_request_flag = false; - g_peer_Wind_module_onoff = false; - g_peer_Windstate = 0; - - if(g_local_Wind_module_onoff == true) - { - g_wnr_sync_flag = true; - } + wnr_sync_counter_for_sco = 0; + wnr_sync_counter_for_normal = 0; + g_wnr_notify_flag = false; + g_wnr_request_flag = false; + g_peer_Wind_module_onoff = false; + g_peer_Windstate = 0; + + if (g_local_Wind_module_onoff == true) { + g_wnr_sync_flag = true; + } } #if (WNR_SYNC_SET_ANC_FF_GAIN_TWOSTAGE == 1) -static void app_wnr_twostage_handler(void const *param) -{ - float gain_coef = 0.0; +static void app_wnr_twostage_handler(void const *param) { + float gain_coef = 0.0; -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"[%s] enter...", __func__); +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "[%s] enter...", __func__); #endif - if((Twostage==1)&&(FFstate==7)) - { - FFstate = 1;//25%->50% - Twostage = 0; + if ((Twostage == 1) && (FFstate == 7)) { + FFstate = 1; // 25%->50% + Twostage = 0; + gain_coef = _SMALL_WIND_FF_GAIN_COEF; + _set_anc_ff_gain(false, gain_coef, ANC_FEEDFORWARD); + + TRACE(1, "[%s] Enable 0.5 FF ANC.", __func__); + } else if ((Twostage == 1) && (FFstate == 6)) { + FFstate = 0; // 75%->100% + Twostage = 0; + gain_coef = _NO_WIND_FF_GAIN_COEF; + _set_anc_ff_gain(false, gain_coef, ANC_FEEDFORWARD); + TRACE(1, "[%s] Enable FF ANC.", __func__); + } +} +#endif + +static void app_wnr_sync_timer_handler(void const *param) { + uint8_t temp = *((uint8_t *)param); +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(2, "[%s] arg0:%d", __func__, temp); +#endif + + if (g_local_Wind_module_onoff == true) + app_wnr_trigger_internal_event(APP_WNR_EXCUTE_TRIGGER, (uint32_t)temp, 0, + 0); +} +static void app_wnr_notify_detect_result(void) { + uint8_t buf[3] = {0}; + +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(2, "[%s] local_Windstate:%d", __func__, g_local_Windstate); +#endif + g_wnr_sync_flag = false; + g_wnr_notify_flag = true; + + buf[0] = IBRT_ACTION_SYNC_WNR; + buf[1] = (uint8_t)APP_WNR_NOTIFY_DETECT_RESULT; + buf[2] = g_local_Windstate; + + app_ibrt_ui_send_user_action(buf, 3); +} +static void app_wnr_request_detect_result(void) { + uint8_t buf[3] = {0}; + +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(2, "[%s] local_Windstate:%d", __func__, g_local_Windstate); +#endif + g_wnr_sync_flag = false; + g_wnr_request_flag = true; + + buf[0] = IBRT_ACTION_SYNC_WNR; + buf[1] = (uint8_t)APP_WNR_REQUEST_DETECT_RESULT; + buf[2] = g_local_Windstate; + + app_ibrt_ui_send_user_action(buf, 3); +} +static void app_wnr_response_detect_result(uint32_t arg0) { + uint8_t buf[3] = {0}; + +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "[%s] enter...", __func__); +#endif + + if (g_wnr_notify_flag == true) { + g_wnr_notify_flag = false; + return; + } + + g_wnr_sync_flag = false; + g_local_Windstate = app_wnr_get_state_from_queue(g_wnr_open_mode); + g_peer_Windstate = (uint8_t)arg0; + +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(3, "[%s] local_Windstate:%d peer_Windstate:%d", __func__, + g_local_Windstate, g_peer_Windstate); +#endif + + buf[0] = IBRT_ACTION_SYNC_WNR; + buf[1] = (uint8_t)APP_WNR_RESPONSE_DETECT_RESULT; + buf[2] = g_local_Windstate; + + app_ibrt_ui_send_user_action(buf, 3); +} +static void app_wnr_process_detect_result(uint32_t arg0) { + if (g_wnr_request_flag == false) { + g_local_Windstate = app_wnr_get_state_from_queue(g_wnr_open_mode); + } + + g_wnr_sync_flag = false; + g_wnr_request_flag = false; + g_peer_Windstate = (uint8_t)arg0; + +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(3, "[%s] local_Windstate:%d peer_wnr_state:%d", __func__, + g_local_Windstate, arg0); +#endif + + if (g_local_Windstate >= g_peer_Windstate) { + if (g_local_Wind_module_onoff == true) + app_wnr_trigger_internal_event(APP_WNR_SET_TRIGGER, + (uint32_t)g_local_Windstate, 0, 0); + } else { + if (g_local_Wind_module_onoff == true) + app_wnr_trigger_internal_event(APP_WNR_SET_TRIGGER, + (uint32_t)g_peer_Windstate, 0, 0); + } +} +static void app_wnr_set_trigger(uint32_t arg0, uint32_t arg1) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + uint32_t current_ticks = 0; + +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(2, "[%s] set_Windstate:%d", __func__, arg0); +#endif + + if ((app_tws_ibrt_tws_link_connected() == true) && + (p_ibrt_ctrl->nv_role == IBRT_MASTER) && + (g_peer_Wind_module_onoff == true)) { + uint8_t buf[7] = {0}; + current_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->tws_conhandle); + uint32_t tg_ticks = current_ticks + MS_TO_TICKS(WNR_SYNC_TRIGGER_DELAY); + +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(3, "[%s] current_ticks:%d tg_ticks:%d", __func__, current_ticks, + tg_ticks); +#endif + + buf[0] = IBRT_ACTION_SYNC_WNR; + buf[1] = (uint8_t)APP_WNR_SET_TRIGGER; + buf[2] = (uint8_t)arg0; + buf[3] = (uint8_t)((tg_ticks & 0xff000000) >> 24); + buf[4] = (uint8_t)((tg_ticks & 0x00ff0000) >> 16); + buf[5] = (uint8_t)((tg_ticks & 0x0000ff00) >> 8); + buf[6] = (uint8_t)(tg_ticks & 0x000000ff); + + app_ibrt_ui_send_user_action(buf, 7); + + if ((app_wnr_sync_timer != NULL) && (tg_ticks != current_ticks)) { + g_set_Windstate = (uint8_t)arg0; + osTimerStop(app_wnr_sync_timer); + osTimerStart(app_wnr_sync_timer, WNR_SYNC_TRIGGER_DELAY); + } else { + if (g_local_Wind_module_onoff == true) + app_wnr_trigger_internal_event(APP_WNR_EXCUTE_TRIGGER, arg0, 0, 0); + } + return; + } + + if ((app_tws_ibrt_tws_link_connected() == true) && + (p_ibrt_ctrl->nv_role == IBRT_SLAVE) && + (g_peer_Wind_module_onoff == true)) { + g_wnr_notify_flag = false; + current_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->tws_conhandle); + +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(3, "[%s] current_ticks:%d tg_ticks:%d", __func__, current_ticks, + arg1); +#endif + + if (arg1 > current_ticks) { + uint32_t diff_ticks = arg1 - current_ticks; + + g_set_Windstate = (uint8_t)arg0; + if (app_wnr_sync_timer != NULL) { + osTimerStop(app_wnr_sync_timer); + osTimerStart(app_wnr_sync_timer, TICKS_TO_MS(diff_ticks)); + } + } else { +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "[%s] tg_ticks < current_ticks...", __func__); +#endif + if (g_local_Wind_module_onoff == true) + app_wnr_trigger_internal_event(APP_WNR_EXCUTE_TRIGGER, arg0, 0, 0); + } + return; + } + + if ((app_tws_ibrt_tws_link_connected() == false) || + (g_peer_Wind_module_onoff == false)) { + if (g_local_Wind_module_onoff == true) + app_wnr_trigger_internal_event(APP_WNR_EXCUTE_TRIGGER, arg0, 0, 0); + return; + } +} + +static void app_wnr_excute_trigger(uint32_t arg0) { + uint8_t t_Windstate = (uint8_t)arg0; + float gain_coef = 0.0; + +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(3, "[%s] last_Windstate:%d set_Windstate:%d", __func__, g_wind_st, + t_Windstate); +#endif + + if ((t_Windstate != g_wind_st) && (app_anc_work_status())) { + if (g_wind_st > t_Windstate) { +#if (WNR_SYNC_SET_ANC_FF_GAIN_TWOSTAGE == 1) + Twostage = 1; +#endif + if (t_Windstate == 1) { +#if (WNR_SYNC_SET_ANC_FF_GAIN_TWOSTAGE == 1) + FFstate = 7; // 25% + gain_coef = _STRONG2SMALL_WIND_FF_MID_GAIN_COEF; + _set_anc_ff_gain(false, gain_coef, ANC_FEEDFORWARD); + TRACE(1, "[%s] Enable 0.25 FF ANC.", __func__); +#else gain_coef = _SMALL_WIND_FF_GAIN_COEF; _set_anc_ff_gain(false, gain_coef, ANC_FEEDFORWARD); - - TRACE(1,"[%s] Enable 0.5 FF ANC.", __func__); - } - else if((Twostage==1)&&(FFstate==6)) - { - FFstate = 0;//75%->100% - Twostage = 0; + TRACE(1, "[%s] Enable 0.5 FF ANC.", __func__); +#endif + } // 2->1 0%->25%->50% + else if (t_Windstate == 0) { +#if (WNR_SYNC_SET_ANC_FF_GAIN_TWOSTAGE == 1) + FFstate = 6; // 75% + gain_coef = _SMALL2NO_WIND_FF_MID_GAIN_COEF; + _set_anc_ff_gain(false, gain_coef, ANC_FEEDFORWARD); + TRACE(1, "[%s] Enable 0.75 FF ANC.", __func__); +#else gain_coef = _NO_WIND_FF_GAIN_COEF; _set_anc_ff_gain(false, gain_coef, ANC_FEEDFORWARD); - TRACE(1,"[%s] Enable FF ANC.", __func__); - } -} + TRACE(1, "[%s] Enable FF ANC.", __func__); #endif - -static void app_wnr_sync_timer_handler(void const *param) -{ - uint8_t temp = *((uint8_t *)param); -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(2,"[%s] arg0:%d", __func__, temp); -#endif - - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_EXCUTE_TRIGGER, (uint32_t)temp, 0, 0); -} -static void app_wnr_notify_detect_result(void) -{ - uint8_t buf[3] = {0}; - -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(2,"[%s] local_Windstate:%d", __func__, g_local_Windstate); -#endif - g_wnr_sync_flag = false; - g_wnr_notify_flag = true; - - buf[0] = IBRT_ACTION_SYNC_WNR; - buf[1] = (uint8_t)APP_WNR_NOTIFY_DETECT_RESULT; - buf[2] = g_local_Windstate; - - app_ibrt_ui_send_user_action(buf, 3); -} -static void app_wnr_request_detect_result(void) -{ - uint8_t buf[3] = {0}; - -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(2,"[%s] local_Windstate:%d", __func__, g_local_Windstate); -#endif - g_wnr_sync_flag = false; - g_wnr_request_flag = true; - - buf[0] = IBRT_ACTION_SYNC_WNR; - buf[1] = (uint8_t)APP_WNR_REQUEST_DETECT_RESULT; - buf[2] = g_local_Windstate; - - app_ibrt_ui_send_user_action(buf, 3); -} -static void app_wnr_response_detect_result(uint32_t arg0) -{ - uint8_t buf[3] = {0}; - -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"[%s] enter...", __func__); -#endif - - if(g_wnr_notify_flag == true) - { - g_wnr_notify_flag = false; - return; - } - - g_wnr_sync_flag = false; - g_local_Windstate = app_wnr_get_state_from_queue(g_wnr_open_mode); - g_peer_Windstate = (uint8_t)arg0; - -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(3,"[%s] local_Windstate:%d peer_Windstate:%d", __func__, g_local_Windstate, g_peer_Windstate); -#endif - - buf[0] = IBRT_ACTION_SYNC_WNR; - buf[1] = (uint8_t)APP_WNR_RESPONSE_DETECT_RESULT; - buf[2] = g_local_Windstate; - - app_ibrt_ui_send_user_action(buf, 3); -} -static void app_wnr_process_detect_result(uint32_t arg0) -{ - if(g_wnr_request_flag == false) - { - g_local_Windstate = app_wnr_get_state_from_queue(g_wnr_open_mode); - } - - g_wnr_sync_flag = false; - g_wnr_request_flag = false; - g_peer_Windstate = (uint8_t)arg0; - -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(3,"[%s] local_Windstate:%d peer_wnr_state:%d", __func__, g_local_Windstate, arg0); -#endif - - if(g_local_Windstate >= g_peer_Windstate) - { - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_SET_TRIGGER, (uint32_t)g_local_Windstate, 0, 0); - } - else - { - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_SET_TRIGGER, (uint32_t)g_peer_Windstate, 0, 0); - } -} -static void app_wnr_set_trigger(uint32_t arg0, uint32_t arg1) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - uint32_t current_ticks = 0; - -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(2,"[%s] set_Windstate:%d", __func__, arg0); -#endif - - if((app_tws_ibrt_tws_link_connected() == true) && (p_ibrt_ctrl->nv_role == IBRT_MASTER) && (g_peer_Wind_module_onoff == true)) - { - uint8_t buf[7] = {0}; - current_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->tws_conhandle); - uint32_t tg_ticks = current_ticks + MS_TO_TICKS(WNR_SYNC_TRIGGER_DELAY); - -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(3,"[%s] current_ticks:%d tg_ticks:%d", __func__, current_ticks, tg_ticks); -#endif - - buf[0] = IBRT_ACTION_SYNC_WNR; - buf[1] = (uint8_t)APP_WNR_SET_TRIGGER; - buf[2] = (uint8_t)arg0; - buf[3] = (uint8_t)((tg_ticks&0xff000000)>>24); - buf[4] = (uint8_t)((tg_ticks&0x00ff0000)>>16); - buf[5] = (uint8_t)((tg_ticks&0x0000ff00)>>8); - buf[6] = (uint8_t)(tg_ticks&0x000000ff); - - app_ibrt_ui_send_user_action(buf, 7); - - if((app_wnr_sync_timer != NULL) && (tg_ticks != current_ticks)) - { - g_set_Windstate = (uint8_t)arg0; - osTimerStop(app_wnr_sync_timer); - osTimerStart(app_wnr_sync_timer, WNR_SYNC_TRIGGER_DELAY); - } - else - { - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_EXCUTE_TRIGGER, arg0, 0, 0); - } - return; - } - - if((app_tws_ibrt_tws_link_connected() == true) && (p_ibrt_ctrl->nv_role == IBRT_SLAVE) && (g_peer_Wind_module_onoff == true)) - { - g_wnr_notify_flag = false; - current_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->tws_conhandle); - -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(3,"[%s] current_ticks:%d tg_ticks:%d", __func__, current_ticks, arg1); -#endif - - if(arg1 > current_ticks) - { - uint32_t diff_ticks = arg1 - current_ticks; - - g_set_Windstate = (uint8_t)arg0; - if(app_wnr_sync_timer != NULL) - { - osTimerStop(app_wnr_sync_timer); - osTimerStart(app_wnr_sync_timer, TICKS_TO_MS(diff_ticks)); - } - } - else - { -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"[%s] tg_ticks < current_ticks...", __func__); -#endif - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_EXCUTE_TRIGGER, arg0, 0, 0); - } - return; - } - - if((app_tws_ibrt_tws_link_connected() == false) || (g_peer_Wind_module_onoff == false)) - { - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_EXCUTE_TRIGGER, arg0, 0, 0); - return; - } -} - -static void app_wnr_excute_trigger(uint32_t arg0) -{ - uint8_t t_Windstate = (uint8_t)arg0; - float gain_coef = 0.0; - -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(3,"[%s] last_Windstate:%d set_Windstate:%d", __func__, g_wind_st, t_Windstate); -#endif - - if((t_Windstate != g_wind_st)&&(app_anc_work_status())) - { - if(g_wind_st > t_Windstate) - { + } // 1->0 50%->75%->100% + } else { + if (t_Windstate == 2) // 0% + { #if (WNR_SYNC_SET_ANC_FF_GAIN_TWOSTAGE == 1) - Twostage = 1; + FFstate = 2; #endif - if(t_Windstate==1){ + gain_coef = _STRONG_WIND_FF_GAIN_COEF; + _set_anc_ff_gain(false, gain_coef, ANC_FEEDFORWARD); + TRACE(1, "[%s] Disable FF ANC.", __func__); + } else if (t_Windstate == 1) // 50% + { #if (WNR_SYNC_SET_ANC_FF_GAIN_TWOSTAGE == 1) - FFstate = 7;//25% - gain_coef = _STRONG2SMALL_WIND_FF_MID_GAIN_COEF; - _set_anc_ff_gain(false, gain_coef, ANC_FEEDFORWARD); - TRACE(1,"[%s] Enable 0.25 FF ANC.", __func__); -#else - gain_coef = _SMALL_WIND_FF_GAIN_COEF; - _set_anc_ff_gain(false, gain_coef, ANC_FEEDFORWARD); - TRACE(1,"[%s] Enable 0.5 FF ANC.", __func__); + FFstate = 1; #endif - }//2->1 0%->25%->50% - else if(t_Windstate==0){ + gain_coef = _SMALL_WIND_FF_GAIN_COEF; + _set_anc_ff_gain(false, gain_coef, ANC_FEEDFORWARD); + TRACE(1, "[%s] Enable 0.5 FF ANC.", __func__); + } else { #if (WNR_SYNC_SET_ANC_FF_GAIN_TWOSTAGE == 1) - FFstate = 6;//75% - gain_coef = _SMALL2NO_WIND_FF_MID_GAIN_COEF; - _set_anc_ff_gain(false, gain_coef, ANC_FEEDFORWARD); - TRACE(1,"[%s] Enable 0.75 FF ANC.", __func__); -#else - gain_coef = _NO_WIND_FF_GAIN_COEF; - _set_anc_ff_gain(false, gain_coef, ANC_FEEDFORWARD); - TRACE(1,"[%s] Enable FF ANC.", __func__); + FFstate = 0; #endif - }//1->0 50%->75%->100% - } - else - { - if(t_Windstate==2)//0% - { -#if (WNR_SYNC_SET_ANC_FF_GAIN_TWOSTAGE == 1) - FFstate = 2; -#endif - gain_coef = _STRONG_WIND_FF_GAIN_COEF; - _set_anc_ff_gain(false, gain_coef, ANC_FEEDFORWARD); - TRACE(1,"[%s] Disable FF ANC.", __func__); - } - else if(t_Windstate==1)//50% - { -#if (WNR_SYNC_SET_ANC_FF_GAIN_TWOSTAGE == 1) - FFstate = 1; -#endif - gain_coef = _SMALL_WIND_FF_GAIN_COEF; - _set_anc_ff_gain(false, gain_coef, ANC_FEEDFORWARD); - TRACE(1,"[%s] Enable 0.5 FF ANC.", __func__); - } - else - { -#if (WNR_SYNC_SET_ANC_FF_GAIN_TWOSTAGE == 1) - FFstate = 0; -#endif - gain_coef = _NO_WIND_FF_GAIN_COEF; - _set_anc_ff_gain(false, gain_coef, ANC_FEEDFORWARD); - TRACE(1,"[%s] Enable FF ANC.", __func__); - } - } - - g_wind_st = t_Windstate; + gain_coef = _NO_WIND_FF_GAIN_COEF; + _set_anc_ff_gain(false, gain_coef, ANC_FEEDFORWARD); + TRACE(1, "[%s] Enable FF ANC.", __func__); + } } + g_wind_st = t_Windstate; + } + #if (WNR_SYNC_SET_ANC_FF_GAIN_TWOSTAGE == 1) - if(((Twostage==1)&&(FFstate==7))||((Twostage==1)&&(FFstate==6))) - { - if(app_wnr_twostage_timer != NULL) - { - osTimerStop(app_wnr_twostage_timer); - osTimerStart(app_wnr_twostage_timer, WNR_SYNC_TWOSTAGE_DELAY); - } + if (((Twostage == 1) && (FFstate == 7)) || + ((Twostage == 1) && (FFstate == 6))) { + if (app_wnr_twostage_timer != NULL) { + osTimerStop(app_wnr_twostage_timer); + osTimerStart(app_wnr_twostage_timer, WNR_SYNC_TWOSTAGE_DELAY); } + } #endif } -static int app_wnr_internal_event_process(APP_MESSAGE_BODY *msg_body) -{ - uint32_t evt = msg_body->message_id; - uint32_t arg0 = msg_body->message_Param0; - uint32_t arg1 = msg_body->message_Param1; +static int app_wnr_internal_event_process(APP_MESSAGE_BODY *msg_body) { + uint32_t evt = msg_body->message_id; + uint32_t arg0 = msg_body->message_Param0; + uint32_t arg1 = msg_body->message_Param1; -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(4,"[%s] evt:%d arg0:%d arg1:%d", __func__, evt, arg0, arg1); +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(4, "[%s] evt:%d arg0:%d arg1:%d", __func__, evt, arg0, arg1); #endif - wnr_sync_counter_for_sco = 0; - wnr_sync_counter_for_normal = 0; + wnr_sync_counter_for_sco = 0; + wnr_sync_counter_for_normal = 0; - switch (evt) - { - case APP_WNR_NOTIFY_DETECT_RESULT:app_wnr_notify_detect_result();break; - case APP_WNR_REQUEST_DETECT_RESULT:app_wnr_request_detect_result();break; - case APP_WNR_RESPONSE_DETECT_RESULT:app_wnr_response_detect_result(arg0);break; - case APP_WNR_PROCESS_DETECT_RESULT:app_wnr_process_detect_result(arg0);break; - case APP_WNR_SET_TRIGGER:app_wnr_set_trigger(arg0, arg1);break; - case APP_WNR_EXCUTE_TRIGGER:app_wnr_excute_trigger(arg0);break; - default:TRACE(2,"[%s] invalid evt:%d", __func__, evt);break; - } + switch (evt) { + case APP_WNR_NOTIFY_DETECT_RESULT: + app_wnr_notify_detect_result(); + break; + case APP_WNR_REQUEST_DETECT_RESULT: + app_wnr_request_detect_result(); + break; + case APP_WNR_RESPONSE_DETECT_RESULT: + app_wnr_response_detect_result(arg0); + break; + case APP_WNR_PROCESS_DETECT_RESULT: + app_wnr_process_detect_result(arg0); + break; + case APP_WNR_SET_TRIGGER: + app_wnr_set_trigger(arg0, arg1); + break; + case APP_WNR_EXCUTE_TRIGGER: + app_wnr_excute_trigger(arg0); + break; + default: + TRACE(2, "[%s] invalid evt:%d", __func__, evt); + break; + } - return 0; + return 0; } -void app_wnr_cmd_receive_process(uint8_t *p_buff, uint16_t length) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); +void app_wnr_cmd_receive_process(uint8_t *p_buff, uint16_t length) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"[%s] enter...", __func__); +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "[%s] enter...", __func__); #endif - if((p_buff[0] == IBRT_ACTION_SYNC_WNR) && (p_buff[1] == APP_WNR_NOTIFY_DETECT_RESULT) && (app_tws_ibrt_tws_link_connected() == true) && (p_ibrt_ctrl->nv_role == IBRT_MASTER)) - { -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"NOTIFY_DETECT_RESULT peer_wnr_state:%d", p_buff[2]); + if ((p_buff[0] == IBRT_ACTION_SYNC_WNR) && + (p_buff[1] == APP_WNR_NOTIFY_DETECT_RESULT) && + (app_tws_ibrt_tws_link_connected() == true) && + (p_ibrt_ctrl->nv_role == IBRT_MASTER)) { +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "NOTIFY_DETECT_RESULT peer_wnr_state:%d", p_buff[2]); #endif - g_peer_Wind_module_onoff = true; - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_PROCESS_DETECT_RESULT, (uint32_t)p_buff[2], 0, 0); - return; + g_peer_Wind_module_onoff = true; + if (g_local_Wind_module_onoff == true) + app_wnr_trigger_internal_event(APP_WNR_PROCESS_DETECT_RESULT, + (uint32_t)p_buff[2], 0, 0); + return; + } + + if ((p_buff[0] == IBRT_ACTION_SYNC_WNR) && + (p_buff[1] == APP_WNR_REQUEST_DETECT_RESULT) && + (app_tws_ibrt_tws_link_connected() == true) && + (p_ibrt_ctrl->nv_role == IBRT_SLAVE)) { +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "REQUEST_DETECT_RESULT peer_wnr_state:%d", p_buff[2]); +#endif + g_peer_Wind_module_onoff = true; + if (g_local_Wind_module_onoff == true) + app_wnr_trigger_internal_event(APP_WNR_RESPONSE_DETECT_RESULT, + (uint32_t)p_buff[2], 0, 0); + return; + } + + if ((p_buff[0] == IBRT_ACTION_SYNC_WNR) && + (p_buff[1] == APP_WNR_RESPONSE_DETECT_RESULT) && + (app_tws_ibrt_tws_link_connected() == true) && + (p_ibrt_ctrl->nv_role == IBRT_MASTER)) { +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "RESPONSE_DETECT_RESULT peer_wnr_state:%d", p_buff[2]); +#endif + g_peer_Wind_module_onoff = true; + if (g_local_Wind_module_onoff == true) + app_wnr_trigger_internal_event(APP_WNR_PROCESS_DETECT_RESULT, + (uint32_t)p_buff[2], 0, 0); + return; + } + + if ((p_buff[0] == IBRT_ACTION_SYNC_WNR) && + (p_buff[1] == APP_WNR_SET_TRIGGER) && + (app_tws_ibrt_tws_link_connected() == true) && + (p_ibrt_ctrl->nv_role == IBRT_SLAVE)) { +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "SET_TRIGGER set_Windstate:%d", p_buff[2]); +#endif + uint32_t tg_ticks = 0; + tg_ticks += p_buff[3]; + tg_ticks = tg_ticks << 8; + tg_ticks += p_buff[4]; + tg_ticks = tg_ticks << 8; + tg_ticks += p_buff[5]; + tg_ticks = tg_ticks << 8; + tg_ticks += p_buff[6]; + if (g_local_Wind_module_onoff == true) + app_wnr_trigger_internal_event(APP_WNR_SET_TRIGGER, (uint32_t)p_buff[2], + tg_ticks, 0); + return; + } + + if ((p_buff[0] == IBRT_ACTION_SYNC_WNR) && + (p_buff[1] == APP_WNR_SHARE_MODULE_INFO)) { +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "APP_WNR_SHARE_MODULE_INFO peer_module_onoff:%d", p_buff[2]); +#endif + g_peer_Wind_module_onoff = (bool)p_buff[2]; + + if ((app_tws_ibrt_tws_link_connected() == true) && + (p_ibrt_ctrl->nv_role == IBRT_MASTER) && + (g_local_Wind_module_onoff == true) && + (g_peer_Wind_module_onoff == true)) { + wnr_sync_counter_for_normal = 0; + wnr_sync_counter_for_sco = 0; + if (g_local_Wind_module_onoff == true) { + g_wnr_sync_flag = true; + } + return; } - - if((p_buff[0] == IBRT_ACTION_SYNC_WNR) && (p_buff[1] == APP_WNR_REQUEST_DETECT_RESULT) && (app_tws_ibrt_tws_link_connected() == true) && (p_ibrt_ctrl->nv_role == IBRT_SLAVE)) - { -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"REQUEST_DETECT_RESULT peer_wnr_state:%d", p_buff[2]); -#endif - g_peer_Wind_module_onoff = true; - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_RESPONSE_DETECT_RESULT, (uint32_t)p_buff[2], 0, 0); - return; - } - - if((p_buff[0] == IBRT_ACTION_SYNC_WNR) && (p_buff[1] == APP_WNR_RESPONSE_DETECT_RESULT) && (app_tws_ibrt_tws_link_connected() == true) && (p_ibrt_ctrl->nv_role == IBRT_MASTER)) - { -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"RESPONSE_DETECT_RESULT peer_wnr_state:%d", p_buff[2]); -#endif - g_peer_Wind_module_onoff = true; - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_PROCESS_DETECT_RESULT, (uint32_t)p_buff[2], 0, 0); - return; - } - - if((p_buff[0] == IBRT_ACTION_SYNC_WNR) && (p_buff[1] == APP_WNR_SET_TRIGGER) && (app_tws_ibrt_tws_link_connected() == true) && (p_ibrt_ctrl->nv_role == IBRT_SLAVE)) - { -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"SET_TRIGGER set_Windstate:%d", p_buff[2]); -#endif - uint32_t tg_ticks = 0; - tg_ticks += p_buff[3]; - tg_ticks = tg_ticks << 8; - tg_ticks += p_buff[4]; - tg_ticks = tg_ticks << 8; - tg_ticks += p_buff[5]; - tg_ticks = tg_ticks << 8; - tg_ticks += p_buff[6]; - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_SET_TRIGGER, (uint32_t)p_buff[2], tg_ticks, 0); - return; - } - - if((p_buff[0] == IBRT_ACTION_SYNC_WNR) && (p_buff[1] == APP_WNR_SHARE_MODULE_INFO)) - { -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"APP_WNR_SHARE_MODULE_INFO peer_module_onoff:%d", p_buff[2]); -#endif - g_peer_Wind_module_onoff = (bool)p_buff[2]; - - if((app_tws_ibrt_tws_link_connected() == true) && (p_ibrt_ctrl->nv_role == IBRT_MASTER) && (g_local_Wind_module_onoff == true) && (g_peer_Wind_module_onoff == true)) - { - wnr_sync_counter_for_normal = 0; - wnr_sync_counter_for_sco = 0; - if(g_local_Wind_module_onoff == true) - { - g_wnr_sync_flag = true; - } - return; - } - if((app_tws_ibrt_tws_link_connected() == true) && (p_ibrt_ctrl->nv_role == IBRT_SLAVE) && (g_local_Wind_module_onoff == true) && (g_peer_Wind_module_onoff == true)) - { - wnr_sync_counter_for_normal = 0; - wnr_sync_counter_for_sco = 0; - if(g_local_Wind_module_onoff == true) - { - g_wnr_sync_flag = true; - } - return; - } - return; + if ((app_tws_ibrt_tws_link_connected() == true) && + (p_ibrt_ctrl->nv_role == IBRT_SLAVE) && + (g_local_Wind_module_onoff == true) && + (g_peer_Wind_module_onoff == true)) { + wnr_sync_counter_for_normal = 0; + wnr_sync_counter_for_sco = 0; + if (g_local_Wind_module_onoff == true) { + g_wnr_sync_flag = true; + } + return; } + return; + } } static bool wnr_open_flg = 0; -int32_t anc_wnr_open(anc_wnr_open_mode_t mode) -{ - if(wnr_open_flg == 1){ - return 0; - } - TRACE(4,"[%s] mode = %d, g_sample_rate = %d, g_frame_len = %d", __func__, mode, g_sample_rate, g_frame_len); - - hal_sysfreq_req(APP_SYSFREQ_USER_ANC_WNR, HAL_CMU_FREQ_26M); - TRACE(2,"[%s] Sys freq: %d", __func__, hal_sys_timer_calc_cpu_freq(5, 0)); - - app_wnr_reset_state_queue(); - app_set_threadhandle(APP_MODUAL_WNR, app_wnr_internal_event_process); - g_local_Wind_module_onoff = true; - if (app_wnr_sync_timer == NULL) - { - app_wnr_sync_timer = osTimerCreate (osTimer(APP_WNR_SYNC_TIMER), osTimerOnce, &g_set_Windstate); - } -#if (WNR_SYNC_SET_ANC_FF_GAIN_TWOSTAGE == 1) - if (app_wnr_twostage_timer == NULL) - { - app_wnr_twostage_timer = osTimerCreate(osTimer(APP_WNR_TWOSTAGE_TIMER), osTimerOnce, NULL); - } -#endif - g_set_Windstate = 0; - g_local_Windstate = 0; - g_peer_Windstate = 0; - g_wnr_notify_flag = false; - g_wnr_request_flag = false; - g_wnr_sync_flag = false; - g_wind_st = 0; - anc_ff_gain_l = 512; - anc_ff_gain_r = 512; - app_wnr_share_module_info(); - if (mode == ANC_WNR_OPEN_MODE_STANDALONE) { - g_wnr_open_mode = ANC_WNR_OPEN_MODE_STANDALONE;//normal mode... - wnr_sync_counter_for_normal = 0; - wnr_sync_counter_for_sco = 0; - g_sample_rate = _SAMPLE_RATE; - g_frame_len = _FRAME_LEN; - wind_st = WindDetection2Mic_create(_SAMPLE_RATE,_SAMPLE_BITS, _FRAME_LEN, &wind_cfg); - - _open_mic(); - - //audio_dump_init(_FRAME_LEN, sizeof(short), 2); - - } else if (mode == ANC_WNR_OPEN_MODE_CONFIGURE) { - g_wnr_open_mode = ANC_WNR_OPEN_MODE_CONFIGURE;//sco mode... - wnr_sync_counter_for_sco = 0; - wnr_sync_counter_for_normal = 0; - ASSERT(g_sample_rate == 8000 || g_sample_rate == 16000, "[%s] g_sample_rate(%d) is invalid.", __func__, g_sample_rate); - ASSERT(g_frame_len == 60 || g_frame_len == 120, "[%s] g_frame_len(%d) is invalid.", __func__, g_frame_len); - - wind_st = WindDetection2Mic_create(_SAMPLE_RATE,_SAMPLE_BITS, g_frame_len, &wind_cfg); - - //audio_dump_init(g_frame_len, sizeof(int), 2); - - } else { - ASSERT(0, "[%s] mode(%d) is invalid.", __func__, mode); - } - -#ifndef HW_SUPPORT_SMOOOTHING_GAIN - anc_gain_tuning_init(); - - struct anc_tuning_ctrl *c = &anc_tctrl; - - if (!c->timer_init) { - c->timer_ff_gain_id = hwtimer_alloc(anc_tuning_ff_gain_timer_timeout, (void *)c); - c->timer_ff_gain_run = 0; - c->timer_init = 1; - } -#endif - - g_open_mode = mode; - - - TRACE(1,"[%s] End...", __func__); - wnr_open_flg = 1; +int32_t anc_wnr_open(anc_wnr_open_mode_t mode) { + if (wnr_open_flg == 1) { return 0; -} + } + TRACE(4, "[%s] mode = %d, g_sample_rate = %d, g_frame_len = %d", __func__, + mode, g_sample_rate, g_frame_len); -int32_t anc_wnr_close(void) -{ - TRACE(1,"[%s] ...", __func__); - -#ifndef HW_SUPPORT_SMOOOTHING_GAIN - struct anc_tuning_ctrl *c = &anc_tctrl; - if (c->timer_ff_gain_run) { - hwtimer_stop(c->timer_ff_gain_id); - } - hwtimer_free(c->timer_ff_gain_id); - c->timer_init = 0; -#endif - - if (g_open_mode == ANC_WNR_OPEN_MODE_STANDALONE) { - _close_mic(); - g_open_mode = ANC_WNR_OPEN_MODE_QTY; - } + hal_sysfreq_req(APP_SYSFREQ_USER_ANC_WNR, HAL_CMU_FREQ_26M); + TRACE(2, "[%s] Sys freq: %d", __func__, hal_sys_timer_calc_cpu_freq(5, 0)); - WindDetection2Mic_destroy(wind_st); - - // size_t total = 0, used = 0, max_used = 0; - // speech_memory_info(&total, &used, &max_used); - // TRACE(3,"ANC WNR MALLOC MEM: total - %d, used - %d, max_used - %d.", total, used, max_used); - // ASSERT(used == 0, "[%s] used != 0", __func__); - app_wnr_reset_state_queue(); - app_set_threadhandle(APP_MODUAL_WNR, NULL); - g_local_Wind_module_onoff = false; - if (app_wnr_sync_timer != NULL) - { - osTimerStop(app_wnr_sync_timer); - } + app_wnr_reset_state_queue(); + app_set_threadhandle(APP_MODUAL_WNR, app_wnr_internal_event_process); + g_local_Wind_module_onoff = true; + if (app_wnr_sync_timer == NULL) { + app_wnr_sync_timer = osTimerCreate(osTimer(APP_WNR_SYNC_TIMER), osTimerOnce, + &g_set_Windstate); + } #if (WNR_SYNC_SET_ANC_FF_GAIN_TWOSTAGE == 1) - if (app_wnr_twostage_timer != NULL) - { - osTimerStop(app_wnr_twostage_timer); - } + if (app_wnr_twostage_timer == NULL) { + app_wnr_twostage_timer = + osTimerCreate(osTimer(APP_WNR_TWOSTAGE_TIMER), osTimerOnce, NULL); + } #endif - g_wnr_open_mode = ANC_WNR_OPEN_MODE_QTY; + g_set_Windstate = 0; + g_local_Windstate = 0; + g_peer_Windstate = 0; + g_wnr_notify_flag = false; + g_wnr_request_flag = false; + g_wnr_sync_flag = false; + g_wind_st = 0; + anc_ff_gain_l = 512; + anc_ff_gain_r = 512; + app_wnr_share_module_info(); + if (mode == ANC_WNR_OPEN_MODE_STANDALONE) { + g_wnr_open_mode = ANC_WNR_OPEN_MODE_STANDALONE; // normal mode... wnr_sync_counter_for_normal = 0; wnr_sync_counter_for_sco = 0; - g_set_Windstate = 0; - g_local_Windstate = 0; - g_peer_Windstate = 0; - g_wnr_notify_flag = false; - g_wnr_request_flag = false; - g_wnr_sync_flag = false; - g_wind_st = 0; - anc_ff_gain_l = 512; - anc_ff_gain_r = 512; - app_wnr_share_module_info(); + g_sample_rate = _SAMPLE_RATE; + g_frame_len = _FRAME_LEN; + wind_st = WindDetection2Mic_create(_SAMPLE_RATE, _SAMPLE_BITS, _FRAME_LEN, + &wind_cfg); - hal_sysfreq_req(APP_SYSFREQ_USER_ANC_WNR, HAL_CMU_FREQ_32K); - wnr_open_flg = 0; - return 0; + _open_mic(); + + // audio_dump_init(_FRAME_LEN, sizeof(short), 2); + + } else if (mode == ANC_WNR_OPEN_MODE_CONFIGURE) { + g_wnr_open_mode = ANC_WNR_OPEN_MODE_CONFIGURE; // sco mode... + wnr_sync_counter_for_sco = 0; + wnr_sync_counter_for_normal = 0; + ASSERT(g_sample_rate == 8000 || g_sample_rate == 16000, + "[%s] g_sample_rate(%d) is invalid.", __func__, g_sample_rate); + ASSERT(g_frame_len == 60 || g_frame_len == 120, + "[%s] g_frame_len(%d) is invalid.", __func__, g_frame_len); + + wind_st = WindDetection2Mic_create(_SAMPLE_RATE, _SAMPLE_BITS, g_frame_len, + &wind_cfg); + + // audio_dump_init(g_frame_len, sizeof(int), 2); + + } else { + ASSERT(0, "[%s] mode(%d) is invalid.", __func__, mode); + } + +#ifndef HW_SUPPORT_SMOOOTHING_GAIN + anc_gain_tuning_init(); + + struct anc_tuning_ctrl *c = &anc_tctrl; + + if (!c->timer_init) { + c->timer_ff_gain_id = + hwtimer_alloc(anc_tuning_ff_gain_timer_timeout, (void *)c); + c->timer_ff_gain_run = 0; + c->timer_init = 1; + } +#endif + + g_open_mode = mode; + + TRACE(1, "[%s] End...", __func__); + wnr_open_flg = 1; + return 0; +} + +int32_t anc_wnr_close(void) { + TRACE(1, "[%s] ...", __func__); + +#ifndef HW_SUPPORT_SMOOOTHING_GAIN + struct anc_tuning_ctrl *c = &anc_tctrl; + if (c->timer_ff_gain_run) { + hwtimer_stop(c->timer_ff_gain_id); + } + hwtimer_free(c->timer_ff_gain_id); + c->timer_init = 0; +#endif + + if (g_open_mode == ANC_WNR_OPEN_MODE_STANDALONE) { + _close_mic(); + g_open_mode = ANC_WNR_OPEN_MODE_QTY; + } + + WindDetection2Mic_destroy(wind_st); + + // size_t total = 0, used = 0, max_used = 0; + // speech_memory_info(&total, &used, &max_used); + // TRACE(3,"ANC WNR MALLOC MEM: total - %d, used - %d, max_used - %d.", total, + // used, max_used); ASSERT(used == 0, "[%s] used != 0", __func__); + app_wnr_reset_state_queue(); + app_set_threadhandle(APP_MODUAL_WNR, NULL); + g_local_Wind_module_onoff = false; + if (app_wnr_sync_timer != NULL) { + osTimerStop(app_wnr_sync_timer); + } +#if (WNR_SYNC_SET_ANC_FF_GAIN_TWOSTAGE == 1) + if (app_wnr_twostage_timer != NULL) { + osTimerStop(app_wnr_twostage_timer); + } +#endif + g_wnr_open_mode = ANC_WNR_OPEN_MODE_QTY; + wnr_sync_counter_for_normal = 0; + wnr_sync_counter_for_sco = 0; + g_set_Windstate = 0; + g_local_Windstate = 0; + g_peer_Windstate = 0; + g_wnr_notify_flag = false; + g_wnr_request_flag = false; + g_wnr_sync_flag = false; + g_wind_st = 0; + anc_ff_gain_l = 512; + anc_ff_gain_r = 512; + app_wnr_share_module_info(); + + hal_sysfreq_req(APP_SYSFREQ_USER_ANC_WNR, HAL_CMU_FREQ_32K); + wnr_open_flg = 0; + return 0; } // TODO: Provide API to configure performance -static int32_t anc_wnr_process_frame(WNR_PCM_T *inF, WNR_PCM_T *inR, uint32_t frame_len) -{ - //static short mutetimer = 0; - //short targettimer = _TARGET_TIME; - float windictor = 0.0; - float wind_power; - - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - - if(cnt<=_PERIOD) - { -#if _SAMPLE_BITS==16 - windictor = WindDetection2Mic_process_16bit(wind_st, inF, inR, frame_len, &wind_power); +static int32_t anc_wnr_process_frame(WNR_PCM_T *inF, WNR_PCM_T *inR, + uint32_t frame_len) { + // static short mutetimer = 0; + // short targettimer = _TARGET_TIME; + float windictor = 0.0; + float wind_power; + + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + + if (cnt <= _PERIOD) { +#if _SAMPLE_BITS == 16 + windictor = WindDetection2Mic_process_16bit(wind_st, inF, inR, frame_len, + &wind_power); #else - windictor = WindDetection2Mic_process_24bit(wind_st, inF, inR, frame_len, &wind_power); + windictor = WindDetection2Mic_process_24bit(wind_st, inF, inR, frame_len, + &wind_power); #endif - //TRACE(2,"[%s] wind_power = %d.", __func__, (int)(wind_power*10000)); - windsum = windsum + windictor; - cnt = cnt + 1; - //TRACE(2,"[%s] cnt = %d, windsum = %d.", __func__, cnt, (int)windsum); - } - if(cnt==period) - { - cnt = 0; - wind_indictor = 0.8 * wind_indictor + 0.2 * windsum/period; - windsum = 0.0; - - //TRACE(2,"[%s] wind_indictor = %d.", __func__, (int)(wind_indictor*1000)); - - //float gain_coef; + // TRACE(2,"[%s] wind_power = %d.", __func__, (int)(wind_power*10000)); + windsum = windsum + windictor; + cnt = cnt + 1; + // TRACE(2,"[%s] cnt = %d, windsum = %d.", __func__, cnt, (int)windsum); + } + if (cnt == period) { + cnt = 0; + wind_indictor = 0.8 * wind_indictor + 0.2 * windsum / period; + windsum = 0.0; - static uint8_t Windstate = 0; - //Windstate = wind_state_detect(g_wind_st, wind_indictor); - //TRACE(2,"[%s] windstate = %d.", __func__, Windstate); - //mutetimer = mutetimer + 1; - wind_state_detect(g_wind_st, wind_indictor, windindicator, windthd, &Windstate); + // TRACE(2,"[%s] wind_indictor = %d.", __func__, (int)(wind_indictor*1000)); - for(int i = WINDINDICATOR_SIZE-1;i>0;i--) - { - windindicator[i] = windindicator[i-1]; + // float gain_coef; + + static uint8_t Windstate = 0; + // Windstate = wind_state_detect(g_wind_st, wind_indictor); + // TRACE(2,"[%s] windstate = %d.", __func__, Windstate); + // mutetimer = mutetimer + 1; + wind_state_detect(g_wind_st, wind_indictor, windindicator, windthd, + &Windstate); + + for (int i = WINDINDICATOR_SIZE - 1; i > 0; i--) { + windindicator[i] = windindicator[i - 1]; + } + windindicator[0] = wind_indictor; + + // TRACE(2,"[%s] windstate = %d.", __func__, Windstate); + + app_wnr_push_state_to_queue(g_wnr_open_mode, Windstate); + + if (g_wnr_open_mode == ANC_WNR_OPEN_MODE_STANDALONE) { + if (++wnr_sync_counter_for_normal >= + WNR_SYNC_COUNTER_THRESHOLD_FOR_NORMAL) { + wnr_sync_counter_for_normal = 0; + wnr_sync_counter_for_sco = 0; + g_local_Windstate = app_wnr_get_state_from_queue(g_wnr_open_mode); +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "[%s] OPEN_MODE_STANDALONE", __func__); + TRACE(2, "[%s] local_Windstate:%d", __func__, g_local_Windstate); + TRACE(2, "[%s] last_Windstate:%d", __func__, g_wind_st); +#endif + if ((app_tws_ibrt_tws_link_connected() == true) && + (p_ibrt_ctrl->nv_role == IBRT_MASTER) && + (g_wnr_sync_flag == true)) { +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "[%s] REQUEST_DETECT_RESULT", __func__); +#endif + if (g_local_Wind_module_onoff == true) + app_wnr_trigger_internal_event(APP_WNR_REQUEST_DETECT_RESULT, 0, 0, + 0); + return 0; + } + + if ((app_tws_ibrt_tws_link_connected() == true) && + (p_ibrt_ctrl->nv_role == IBRT_SLAVE) && (g_wnr_sync_flag == true)) { +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "[%s] NOTIFY_DETECT_RESULT", __func__); +#endif + if (g_local_Wind_module_onoff == true) + app_wnr_trigger_internal_event(APP_WNR_NOTIFY_DETECT_RESULT, 0, 0, + 0); + return 0; + } + + if ((app_tws_ibrt_tws_link_connected() == true) && + (p_ibrt_ctrl->nv_role == IBRT_MASTER) && + (g_local_Windstate != g_wind_st) && + (g_peer_Wind_module_onoff == true)) { +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "[%s] REQUEST_DETECT_RESULT", __func__); +#endif + if (g_local_Wind_module_onoff == true) + app_wnr_trigger_internal_event(APP_WNR_REQUEST_DETECT_RESULT, 0, 0, + 0); + return 0; + } + + if ((app_tws_ibrt_tws_link_connected() == true) && + (p_ibrt_ctrl->nv_role == IBRT_SLAVE) && + (g_local_Windstate != g_wind_st) && + (g_peer_Wind_module_onoff == true)) { +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "[%s] NOTIFY_DETECT_RESULT", __func__); +#endif + if (g_local_Wind_module_onoff == true) + app_wnr_trigger_internal_event(APP_WNR_NOTIFY_DETECT_RESULT, 0, 0, + 0); + return 0; + } + + if (((app_tws_ibrt_tws_link_connected() == false) || + (g_peer_Wind_module_onoff == false)) && + (g_local_Windstate != g_wind_st)) { +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "[%s] SET_TRIGGER", __func__); +#endif + if (g_local_Wind_module_onoff == true) + app_wnr_trigger_internal_event(APP_WNR_SET_TRIGGER, + (uint32_t)g_local_Windstate, 0, 0); + return 0; + } } - windindicator[0] = wind_indictor; - - - //TRACE(2,"[%s] windstate = %d.", __func__, Windstate); - - app_wnr_push_state_to_queue(g_wnr_open_mode, Windstate); - - if(g_wnr_open_mode == ANC_WNR_OPEN_MODE_STANDALONE) - { - if(++wnr_sync_counter_for_normal >= WNR_SYNC_COUNTER_THRESHOLD_FOR_NORMAL) - { - wnr_sync_counter_for_normal = 0; - wnr_sync_counter_for_sco = 0; - g_local_Windstate = app_wnr_get_state_from_queue(g_wnr_open_mode); -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"[%s] OPEN_MODE_STANDALONE", __func__); - TRACE(2,"[%s] local_Windstate:%d", __func__, g_local_Windstate); - TRACE(2,"[%s] last_Windstate:%d", __func__, g_wind_st); + } else { + if (++wnr_sync_counter_for_sco >= WNR_SYNC_COUNTER_THRESHOLD_FOR_SCO) { + wnr_sync_counter_for_sco = 0; + wnr_sync_counter_for_normal = 0; + g_local_Windstate = app_wnr_get_state_from_queue(g_wnr_open_mode); +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "[%s] OPEN_MODE_CONFIGURE", __func__); + TRACE(2, "[%s] local_Windstate:%d", __func__, g_local_Windstate); + TRACE(2, "[%s] last_Windstate:%d", __func__, g_wind_st); #endif - if((app_tws_ibrt_tws_link_connected() == true) && (p_ibrt_ctrl->nv_role == IBRT_MASTER) && (g_wnr_sync_flag == true)) - { -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"[%s] REQUEST_DETECT_RESULT", __func__); + if ((app_tws_ibrt_tws_link_connected() == true) && + (p_ibrt_ctrl->nv_role == IBRT_MASTER) && + (g_wnr_sync_flag == true)) { +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "[%s] REQUEST_DETECT_RESULT", __func__); #endif - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_REQUEST_DETECT_RESULT, 0, 0, 0); - return 0; - } - - if((app_tws_ibrt_tws_link_connected() == true) && (p_ibrt_ctrl->nv_role == IBRT_SLAVE) && (g_wnr_sync_flag == true)) - { -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"[%s] NOTIFY_DETECT_RESULT", __func__); -#endif - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_NOTIFY_DETECT_RESULT, 0, 0, 0); - return 0; - } - - if((app_tws_ibrt_tws_link_connected() == true) && (p_ibrt_ctrl->nv_role == IBRT_MASTER) && (g_local_Windstate != g_wind_st) && (g_peer_Wind_module_onoff == true)) - { -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"[%s] REQUEST_DETECT_RESULT", __func__); -#endif - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_REQUEST_DETECT_RESULT, 0, 0, 0); - return 0; - } - - if((app_tws_ibrt_tws_link_connected() == true) && (p_ibrt_ctrl->nv_role == IBRT_SLAVE) && (g_local_Windstate != g_wind_st) && (g_peer_Wind_module_onoff == true)) - { -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"[%s] NOTIFY_DETECT_RESULT", __func__); -#endif - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_NOTIFY_DETECT_RESULT, 0, 0, 0); - return 0; - } - - if(((app_tws_ibrt_tws_link_connected() == false) || (g_peer_Wind_module_onoff == false)) && (g_local_Windstate != g_wind_st)) - { -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"[%s] SET_TRIGGER", __func__); -#endif - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_SET_TRIGGER, (uint32_t)g_local_Windstate, 0, 0); - return 0; - } - } - } - else - { - if(++wnr_sync_counter_for_sco >= WNR_SYNC_COUNTER_THRESHOLD_FOR_SCO) - { - wnr_sync_counter_for_sco = 0; - wnr_sync_counter_for_normal = 0; - g_local_Windstate = app_wnr_get_state_from_queue(g_wnr_open_mode); -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"[%s] OPEN_MODE_CONFIGURE", __func__); - TRACE(2,"[%s] local_Windstate:%d", __func__, g_local_Windstate); - TRACE(2,"[%s] last_Windstate:%d", __func__, g_wind_st); -#endif - if((app_tws_ibrt_tws_link_connected() == true) && (p_ibrt_ctrl->nv_role == IBRT_MASTER) && (g_wnr_sync_flag == true)) - { -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"[%s] REQUEST_DETECT_RESULT", __func__); -#endif - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_REQUEST_DETECT_RESULT, 0, 0, 0); - return 0; - } - - if((app_tws_ibrt_tws_link_connected() == true) && (p_ibrt_ctrl->nv_role == IBRT_SLAVE) && (g_wnr_sync_flag == true)) - { -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"[%s] NOTIFY_DETECT_RESULT", __func__); -#endif - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_NOTIFY_DETECT_RESULT, 0, 0, 0); - return 0; - } - - if((app_tws_ibrt_tws_link_connected() == true) && (p_ibrt_ctrl->nv_role == IBRT_MASTER) && (g_local_Windstate != g_wind_st) && (g_peer_Wind_module_onoff == true)) - { -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"[%s] REQUEST_DETECT_RESULT", __func__); -#endif - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_REQUEST_DETECT_RESULT, 0, 0, 0); - return 0; - } - - if((app_tws_ibrt_tws_link_connected() == true) && (p_ibrt_ctrl->nv_role == IBRT_SLAVE) && (g_local_Windstate != g_wind_st) && (g_peer_Wind_module_onoff == true)) - { -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"[%s] NOTIFY_DETECT_RESULT", __func__); -#endif - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_NOTIFY_DETECT_RESULT, 0, 0, 0); - return 0; - } - - if(((app_tws_ibrt_tws_link_connected() == false) || (g_peer_Wind_module_onoff == false)) && (g_local_Windstate != g_wind_st)) - { -#if(WNR_SYNC_DEBUG_LOG == 1) - TRACE(1,"[%s] SET_TRIGGER", __func__); -#endif - if(g_local_Wind_module_onoff == true) - app_wnr_trigger_internal_event(APP_WNR_SET_TRIGGER, (uint32_t)g_local_Windstate, 0, 0); - return 0; - } - } - } + if (g_local_Wind_module_onoff == true) + app_wnr_trigger_internal_event(APP_WNR_REQUEST_DETECT_RESULT, 0, 0, + 0); + return 0; } - return 0; - } -static void inline stereo_resample_16k(WNR_PCM_T *pcm_buf, uint32_t pcm_len, WNR_PCM_T *mic1, WNR_PCM_T *mic2) -{ - uint32_t frame_len = pcm_len / _CHANNEL_NUM; + if ((app_tws_ibrt_tws_link_connected() == true) && + (p_ibrt_ctrl->nv_role == IBRT_SLAVE) && (g_wnr_sync_flag == true)) { +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "[%s] NOTIFY_DETECT_RESULT", __func__); +#endif + if (g_local_Wind_module_onoff == true) + app_wnr_trigger_internal_event(APP_WNR_NOTIFY_DETECT_RESULT, 0, 0, + 0); + return 0; + } - const float num[3] = {0.020083, 0.040166, 0.020083}; - const float den[3] = {1.000000, -1.561018, 0.641351}; + if ((app_tws_ibrt_tws_link_connected() == true) && + (p_ibrt_ctrl->nv_role == IBRT_MASTER) && + (g_local_Windstate != g_wind_st) && + (g_peer_Wind_module_onoff == true)) { +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "[%s] REQUEST_DETECT_RESULT", __func__); +#endif + if (g_local_Wind_module_onoff == true) + app_wnr_trigger_internal_event(APP_WNR_REQUEST_DETECT_RESULT, 0, 0, + 0); + return 0; + } - static float y0 = 0, y1 = 0, y2 = 0, x0 = 0, x1 = 0, x2 = 0; - static float Y0 = 0, Y1 = 0, Y2 = 0, X0 = 0, X1 = 0, X2 = 0; + if ((app_tws_ibrt_tws_link_connected() == true) && + (p_ibrt_ctrl->nv_role == IBRT_SLAVE) && + (g_local_Windstate != g_wind_st) && + (g_peer_Wind_module_onoff == true)) { +#if (WNR_SYNC_DEBUG_LOG == 1) + TRACE(1, "[%s] NOTIFY_DETECT_RESULT", __func__); +#endif + if (g_local_Wind_module_onoff == true) + app_wnr_trigger_internal_event(APP_WNR_NOTIFY_DETECT_RESULT, 0, 0, + 0); + return 0; + } - for (uint32_t i=0; i8k - if (g_sample_rate == 16000) { - stereo_resample_16k(tmp_buf, pcm_len, (WNR_PCM_T *)af_stream_mic1, (WNR_PCM_T *)af_stream_mic2); - // 2ch --> 1ch, 16k --> 8k - pcm_len = pcm_len / _CHANNEL_NUM / 2; - } - else{ - - WNR_PCM_T *mic1 = (WNR_PCM_T *)af_stream_mic1; - WNR_PCM_T *mic2 = (WNR_PCM_T *)af_stream_mic2; - pcm_len = pcm_len / _CHANNEL_NUM; - for (uint32_t i=0; i8k + if (g_sample_rate == 16000) { + stereo_resample_16k(tmp_buf, pcm_len, (WNR_PCM_T *)af_stream_mic1, + (WNR_PCM_T *)af_stream_mic2); + // 2ch --> 1ch, 16k --> 8k + pcm_len = pcm_len / _CHANNEL_NUM / 2; + } else { WNR_PCM_T *mic1 = (WNR_PCM_T *)af_stream_mic1; WNR_PCM_T *mic2 = (WNR_PCM_T *)af_stream_mic2; - - for(int32_t j=0; j<_LOOP_CNT; j++){ - for (int32_t i=0; i 0) - { - if (gain0_curr < gain0_tg) - { - gain0_curr++; - } + if (gain0_tg > 0) { + if (gain0_curr < gain0_tg) { + gain0_curr++; } - else - { - if (gain0_curr > gain0_tg) - { - gain0_curr--; - } + } else { + if (gain0_curr > gain0_tg) { + gain0_curr--; } + } - if (gain1_tg > 0) - { - if (gain1_curr < gain1_tg) - { - gain1_curr++; - } + if (gain1_tg > 0) { + if (gain1_curr < gain1_tg) { + gain1_curr++; } - else - { - if (gain1_curr > gain1_tg) - { - gain1_curr--; - } + } else { + if (gain1_curr > gain1_tg) { + gain1_curr--; } - hal_sys_timer_delay_us(25); + } + hal_sys_timer_delay_us(25); - anc_set_gain(gain0_curr, gain1_curr, type); + anc_set_gain(gain0_curr, gain1_curr, type); - if ((gain0_curr == gain0_tg) && (gain1_curr == gain1_tg)) - { - TRACE(3,"[%s] cur gain: %d %d", __func__, gain0_curr, gain1_curr); - return 0; - } + if ((gain0_curr == gain0_tg) && (gain1_curr == gain1_tg)) { + TRACE(3, "[%s] cur gain: %d %d", __func__, gain0_curr, gain1_curr); + return 0; + } - return 1; + return 1; } -int __anc_usb_app_fadeout(enum ANC_TYPE_T type) -{ - int32_t gain0_curr, gain1_curr; +int __anc_usb_app_fadeout(enum ANC_TYPE_T type) { + int32_t gain0_curr, gain1_curr; - anc_get_gain(&gain0_curr, &gain1_curr, type); + anc_get_gain(&gain0_curr, &gain1_curr, type); - if (gain0_curr > 0) - { - gain0_curr--; - } - else if (gain0_curr < 0) - { - gain0_curr++; - } + if (gain0_curr > 0) { + gain0_curr--; + } else if (gain0_curr < 0) { + gain0_curr++; + } - if (gain1_curr > 0) - { - gain1_curr--; - } - else if (gain1_curr < 0) - { - gain1_curr++; - } + if (gain1_curr > 0) { + gain1_curr--; + } else if (gain1_curr < 0) { + gain1_curr++; + } - // gain0_curr = gain1_curr = 0 ; - hal_sys_timer_delay_us(25); + // gain0_curr = gain1_curr = 0 ; + hal_sys_timer_delay_us(25); - anc_set_gain(gain0_curr, gain1_curr, type); + anc_set_gain(gain0_curr, gain1_curr, type); - if ((gain0_curr == 0) && (gain1_curr == 0)) - { - TRACE(3,"[%s] gain: %d, %d", __func__, gain0_curr, gain1_curr); - return 0; - } + if ((gain0_curr == 0) && (gain1_curr == 0)) { + TRACE(3, "[%s] gain: %d, %d", __func__, gain0_curr, gain1_curr); + return 0; + } - return 1; + return 1; } #if defined(ANC_FF_ENABLED) && defined(ANC_FB_ENABLED) -int __anc_usb_app_fadein_ff_fb(void) -{ - int32_t gain0_curr, gain1_curr; - int32_t gain2_curr, gain3_curr; +int __anc_usb_app_fadein_ff_fb(void) { + int32_t gain0_curr, gain1_curr; + int32_t gain2_curr, gain3_curr; - int32_t gain0_tg, gain1_tg; - int32_t gain2_tg, gain3_tg; + int32_t gain0_tg, gain1_tg; + int32_t gain2_tg, gain3_tg; + anc_get_gain(&gain0_curr, &gain1_curr, ANC_FEEDFORWARD); + anc_get_gain(&gain2_curr, &gain3_curr, ANC_FEEDBACK); + anc_get_cfg_gain(&gain0_tg, &gain1_tg, ANC_FEEDFORWARD); + anc_get_cfg_gain(&gain2_tg, &gain3_tg, ANC_FEEDBACK); - anc_get_gain(&gain0_curr, &gain1_curr, ANC_FEEDFORWARD); - anc_get_gain(&gain2_curr, &gain3_curr, ANC_FEEDBACK); - anc_get_cfg_gain(&gain0_tg, &gain1_tg, ANC_FEEDFORWARD); - anc_get_cfg_gain(&gain2_tg, &gain3_tg, ANC_FEEDBACK); + uint32_t random_factor = rand(); + random_factor %= 5; + if (random_factor == 0) + random_factor++; - uint32_t random_factor = rand(); - random_factor %= 5; - if(random_factor==0) random_factor++; + uint32_t random_factor_inverse = 5 - random_factor; + if (random_factor_inverse == 0) + random_factor_inverse++; + random_factor_inverse = 1; - uint32_t random_factor_inverse = 5-random_factor; - if(random_factor_inverse==0) random_factor_inverse++; + if (is_sbc_mode() || is_sco_mode()) { + if (gain0_tg > 0) { + if (gain0_curr < gain0_tg) { + gain0_curr = MIN(gain0_curr + random_factor_inverse, gain0_tg); + } + } else { + if (gain0_curr > gain0_tg) { + gain0_curr = MAX(gain0_curr - random_factor_inverse, gain0_tg); + } + } - random_factor_inverse =1; + if (gain1_tg > 0) { + if (gain1_curr < gain1_tg) { + gain1_curr = MIN(gain1_curr + random_factor_inverse, gain1_tg); + } + } else { + if (gain1_curr > gain1_tg) { + gain1_curr = MAX(gain1_curr - random_factor_inverse, gain1_tg); + } + } - if(is_sbc_mode() || is_sco_mode()){ - if (gain0_tg > 0) - { - if (gain0_curr < gain0_tg) - { - gain0_curr = MIN(gain0_curr+random_factor_inverse, gain0_tg); - } - } - else - { - if (gain0_curr > gain0_tg) - { - gain0_curr = MAX(gain0_curr-random_factor_inverse, gain0_tg); - } - } + if (gain2_tg > 0) { + if (gain2_curr < gain2_tg) { + gain2_curr = MIN(gain2_curr + random_factor_inverse, gain2_tg); + } + } else { + if (gain2_curr > gain2_tg) { + gain2_curr = MAX(gain2_curr - random_factor_inverse, gain2_tg); + } + } - if (gain1_tg > 0) - { - if (gain1_curr < gain1_tg) - { - gain1_curr = MIN(gain1_curr+random_factor_inverse, gain1_tg); - } - } - else - { - if (gain1_curr > gain1_tg) - { - gain1_curr = MAX(gain1_curr-random_factor_inverse, gain1_tg); - } - } + if (gain3_tg > 0) { + if (gain3_curr < gain3_tg) { + gain3_curr = MIN(gain3_curr + random_factor_inverse, gain3_tg); + } + } else { + if (gain3_curr > gain3_tg) { + gain3_curr = MAX(gain3_curr - random_factor_inverse, gain3_tg); + } + } + } else { + if (gain0_tg > 0) { + if (gain0_curr < gain0_tg) { + gain0_curr = MIN(gain0_curr + random_factor_inverse, gain0_tg); + } + } else { + if (gain0_curr > gain0_tg) { + gain0_curr = MAX(gain0_curr - random_factor_inverse, gain0_tg); + } + } - if (gain2_tg > 0) - { - if (gain2_curr < gain2_tg) - { - gain2_curr = MIN(gain2_curr+random_factor_inverse, gain2_tg); - } - } - else - { - if (gain2_curr > gain2_tg) - { - gain2_curr = MAX(gain2_curr-random_factor_inverse, gain2_tg); - } - } + if (gain1_tg > 0) { + if (gain1_curr < gain1_tg) { + gain1_curr = MIN(gain1_curr + random_factor_inverse, gain1_tg); + } + } else { + if (gain1_curr > gain1_tg) { + gain1_curr = MAX(gain1_curr - random_factor_inverse, gain1_tg); + } + } - if (gain3_tg > 0) - { - if (gain3_curr < gain3_tg) - { - gain3_curr = MIN(gain3_curr+random_factor_inverse, gain3_tg); - } - } - else - { - if (gain3_curr > gain3_tg) - { - gain3_curr = MAX(gain3_curr-random_factor_inverse, gain3_tg); - } - } - }else{ - if (gain0_tg > 0) - { - if (gain0_curr < gain0_tg) - { - gain0_curr = MIN(gain0_curr+random_factor_inverse, gain0_tg); - } - } - else - { - if (gain0_curr > gain0_tg) - { - gain0_curr = MAX(gain0_curr-random_factor_inverse, gain0_tg); - } - } + if (gain2_tg > 0) { + if (gain2_curr < gain2_tg) { + gain2_curr = MIN(gain2_curr + random_factor_inverse, gain2_tg); + } + } else { + if (gain2_curr > gain2_tg) { + gain2_curr = MAX(gain2_curr - random_factor_inverse, gain2_tg); + } + } - if (gain1_tg > 0) - { - if (gain1_curr < gain1_tg) - { - gain1_curr = MIN(gain1_curr+random_factor_inverse, gain1_tg); - } - } - else - { - if (gain1_curr > gain1_tg) - { - gain1_curr = MAX(gain1_curr-random_factor_inverse, gain1_tg); - } - } + if (gain3_tg > 0) { + if (gain3_curr < gain3_tg) { + gain3_curr = MIN(gain3_curr + random_factor_inverse, gain3_tg); + } + } else { + if (gain3_curr > gain3_tg) { + gain3_curr = MAX(gain3_curr - random_factor_inverse, gain3_tg); + } + } + } - if (gain2_tg > 0) - { - if (gain2_curr < gain2_tg) - { - gain2_curr = MIN(gain2_curr+random_factor_inverse, gain2_tg); - } - } - else - { - if (gain2_curr > gain2_tg) - { - gain2_curr = MAX(gain2_curr-random_factor_inverse, gain2_tg); - } - } + anc_set_gain(gain0_curr, gain1_curr, ANC_FEEDFORWARD); + anc_set_gain(gain2_curr, gain3_curr, ANC_FEEDBACK); - if (gain3_tg > 0) - { - if (gain3_curr < gain3_tg) - { - gain3_curr = MIN(gain3_curr+random_factor_inverse, gain3_tg); - } - } - else - { - if (gain3_curr > gain3_tg) - { - gain3_curr = MAX(gain3_curr-random_factor_inverse, gain3_tg); - } - } - } + // TRACE(5,"[%s] cur gain: %d %d %d %d", __func__, gain0_curr, gain1_curr, + // gain2_curr, gain3_curr); + // osDelay(random_factor); + + hal_sys_timer_delay_us(40); + if (gain0_curr % 40 == 0) { + // osDelay(random_factor); + } + + if ((gain0_curr == gain0_tg) && (gain1_curr == gain1_tg) && + (gain2_curr == gain2_tg) && (gain3_curr == gain3_tg)) { + anc_disable_gain_updated_when_pass0(1); anc_set_gain(gain0_curr, gain1_curr, ANC_FEEDFORWARD); - anc_set_gain(gain2_curr, gain3_curr, ANC_FEEDBACK); - - - //TRACE(5,"[%s] cur gain: %d %d %d %d", __func__, gain0_curr, gain1_curr, gain2_curr, gain3_curr); - - //osDelay(random_factor); - - hal_sys_timer_delay_us(40); - if(gain0_curr%40==0) - { - //osDelay(random_factor); - } - - if ((gain0_curr == gain0_tg) && (gain1_curr == gain1_tg) && (gain2_curr == gain2_tg) && (gain3_curr == gain3_tg)) - { - anc_disable_gain_updated_when_pass0(1); - - anc_set_gain(gain0_curr, gain1_curr, ANC_FEEDFORWARD); - anc_set_gain(gain2_curr, gain3_curr, ANC_FEEDBACK); - TRACE(5,"[%s] end cur gain: %d, %d, %d, %d", __func__, gain0_curr, gain1_curr,gain2_curr,gain3_curr); - return 0; - } - return 1; + anc_set_gain(gain2_curr, gain3_curr, ANC_FEEDBACK); + TRACE(5, "[%s] end cur gain: %d, %d, %d, %d", __func__, gain0_curr, + gain1_curr, gain2_curr, gain3_curr); + return 0; + } + return 1; } -int __anc_usb_app_fadeout_ff_fb(void) -{ - int32_t gain0_curr, gain1_curr; - int32_t gain2_curr, gain3_curr; - anc_get_gain(&gain0_curr, &gain1_curr, ANC_FEEDFORWARD); - anc_get_gain(&gain2_curr, &gain3_curr, ANC_FEEDBACK); +int __anc_usb_app_fadeout_ff_fb(void) { + int32_t gain0_curr, gain1_curr; + int32_t gain2_curr, gain3_curr; + anc_get_gain(&gain0_curr, &gain1_curr, ANC_FEEDFORWARD); + anc_get_gain(&gain2_curr, &gain3_curr, ANC_FEEDBACK); - uint32_t random_factor = rand(); - random_factor = random_factor%5; - if(random_factor==0) random_factor++; + uint32_t random_factor = rand(); + random_factor = random_factor % 5; + if (random_factor == 0) + random_factor++; - uint32_t random_factor_inverse = 5-random_factor; - if(random_factor_inverse==0) random_factor_inverse++; + uint32_t random_factor_inverse = 5 - random_factor; + if (random_factor_inverse == 0) + random_factor_inverse++; - random_factor_inverse =1; + random_factor_inverse = 1; - - if(is_sbc_mode() || is_sco_mode()){ - if (gain0_curr > 0) - { - gain0_curr = MAX(gain0_curr-random_factor_inverse,0); - } - else if (gain0_curr < 0) - { - gain0_curr = MIN(gain0_curr+random_factor_inverse,0); - } - - if (gain1_curr > 0) - { - gain1_curr = MAX(gain1_curr-random_factor_inverse,0); - } - else if (gain1_curr < 0) - { - gain1_curr = MIN(gain1_curr+random_factor_inverse,0); - } - - if (gain2_curr > 0) - { - gain2_curr = MAX(gain2_curr-random_factor_inverse,0); - } - else if (gain2_curr < 0) - { - gain2_curr = MIN(gain2_curr+random_factor_inverse,0); - } - - if (gain3_curr > 0) - { - gain3_curr = MAX(gain3_curr-random_factor_inverse,0); - } - else if (gain3_curr < 0) - { - gain3_curr = MIN(gain3_curr+random_factor_inverse,0); - } - }else{ - if (gain0_curr > 0) - { - gain0_curr = MAX(gain0_curr-random_factor_inverse,0); - } - else if (gain0_curr < 0) - { - gain0_curr = MIN(gain0_curr+random_factor_inverse,0); - } - - if (gain1_curr > 0) - { - gain1_curr = MAX(gain1_curr-random_factor_inverse,0); - } - else if (gain1_curr < 0) - { - gain1_curr = MIN(gain1_curr+random_factor_inverse,0); - } - - if (gain2_curr > 0) - { - gain2_curr = MAX(gain2_curr-random_factor_inverse,0); - } - else if (gain2_curr < 0) - { - gain2_curr = MIN(gain2_curr+random_factor_inverse,0); - } - - if (gain3_curr > 0) - { - gain3_curr = MAX(gain3_curr-random_factor_inverse,0); - } - else if (gain3_curr < 0) - { - gain3_curr = MIN(gain3_curr+random_factor_inverse,0); - } - - } - - - anc_set_gain(gain0_curr, gain1_curr, ANC_FEEDFORWARD); - anc_set_gain(gain2_curr, gain3_curr, ANC_FEEDBACK); - //TRACE(5,"[%s] cur gain: %d %d %d %d", __func__, gain0_curr, gain1_curr, gain2_curr, gain3_curr); - - - //osDelay(random_factor); - - hal_sys_timer_delay_us(40); - if(gain0_curr%40==0) - { - //osDelay(random_factor); - } - - if ((gain0_curr == 0) && (gain1_curr == 0) && (gain2_curr == 0) && (gain3_curr == 0)) - { - anc_disable_gain_updated_when_pass0(1); - - anc_set_gain(gain0_curr, gain1_curr, ANC_FEEDFORWARD); - anc_set_gain(gain2_curr, gain3_curr, ANC_FEEDBACK); - TRACE(5,"[%s] end cur gain: %d, %d, %d, %d", __func__, gain0_curr, gain1_curr,gain2_curr,gain3_curr); - return 0; + if (is_sbc_mode() || is_sco_mode()) { + if (gain0_curr > 0) { + gain0_curr = MAX(gain0_curr - random_factor_inverse, 0); + } else if (gain0_curr < 0) { + gain0_curr = MIN(gain0_curr + random_factor_inverse, 0); } - return 1; + if (gain1_curr > 0) { + gain1_curr = MAX(gain1_curr - random_factor_inverse, 0); + } else if (gain1_curr < 0) { + gain1_curr = MIN(gain1_curr + random_factor_inverse, 0); + } + + if (gain2_curr > 0) { + gain2_curr = MAX(gain2_curr - random_factor_inverse, 0); + } else if (gain2_curr < 0) { + gain2_curr = MIN(gain2_curr + random_factor_inverse, 0); + } + + if (gain3_curr > 0) { + gain3_curr = MAX(gain3_curr - random_factor_inverse, 0); + } else if (gain3_curr < 0) { + gain3_curr = MIN(gain3_curr + random_factor_inverse, 0); + } + } else { + if (gain0_curr > 0) { + gain0_curr = MAX(gain0_curr - random_factor_inverse, 0); + } else if (gain0_curr < 0) { + gain0_curr = MIN(gain0_curr + random_factor_inverse, 0); + } + + if (gain1_curr > 0) { + gain1_curr = MAX(gain1_curr - random_factor_inverse, 0); + } else if (gain1_curr < 0) { + gain1_curr = MIN(gain1_curr + random_factor_inverse, 0); + } + + if (gain2_curr > 0) { + gain2_curr = MAX(gain2_curr - random_factor_inverse, 0); + } else if (gain2_curr < 0) { + gain2_curr = MIN(gain2_curr + random_factor_inverse, 0); + } + + if (gain3_curr > 0) { + gain3_curr = MAX(gain3_curr - random_factor_inverse, 0); + } else if (gain3_curr < 0) { + gain3_curr = MIN(gain3_curr + random_factor_inverse, 0); + } + } + + anc_set_gain(gain0_curr, gain1_curr, ANC_FEEDFORWARD); + anc_set_gain(gain2_curr, gain3_curr, ANC_FEEDBACK); + // TRACE(5,"[%s] cur gain: %d %d %d %d", __func__, gain0_curr, gain1_curr, + // gain2_curr, gain3_curr); + + // osDelay(random_factor); + + hal_sys_timer_delay_us(40); + if (gain0_curr % 40 == 0) { + // osDelay(random_factor); + } + + if ((gain0_curr == 0) && (gain1_curr == 0) && (gain2_curr == 0) && + (gain3_curr == 0)) { + anc_disable_gain_updated_when_pass0(1); + + anc_set_gain(gain0_curr, gain1_curr, ANC_FEEDFORWARD); + anc_set_gain(gain2_curr, gain3_curr, ANC_FEEDBACK); + TRACE(5, "[%s] end cur gain: %d, %d, %d, %d", __func__, gain0_curr, + gain1_curr, gain2_curr, gain3_curr); + return 0; + } + + return 1; } #endif -void anc_gain_fade_handle(void) -{ - TRACE(2," %s %d ", __func__, app_anc_fade_status); - if (app_anc_fade_status == APP_ANC_FADE_OUT) - { - osSignalSet(anc_fade_thread_tid,FADE_OUT); - } +void anc_gain_fade_handle(void) { + TRACE(2, " %s %d ", __func__, app_anc_fade_status); + if (app_anc_fade_status == APP_ANC_FADE_OUT) { + osSignalSet(anc_fade_thread_tid, FADE_OUT); + } - if (app_anc_fade_status == APP_ANC_FADE_IN) - { + if (app_anc_fade_status == APP_ANC_FADE_IN) { #ifdef ANC_LED_PIN - app_anc_switch_turnled(true); + app_anc_switch_turnled(true); #endif - osSignalSet(anc_fade_thread_tid,FADE_IN); + osSignalSet(anc_fade_thread_tid, FADE_IN); - if (anc_set_dac_pa_delay) - { - anc_set_dac_pa_delay = false; -// osDelay(600); -// analog_aud_enable_dac_pa(48); - } + if (anc_set_dac_pa_delay) { + anc_set_dac_pa_delay = false; + // osDelay(600); + // analog_aud_enable_dac_pa(48); } + } } -void anc_fade_thread(void const *argument) -{ +void anc_fade_thread(void const *argument) { - osEvent evt; - evt.status = 0; - uint32_t singles = 0; + osEvent evt; + evt.status = 0; + uint32_t singles = 0; - while(1) - { - evt = osSignalWait(0,osWaitForever); - - singles = evt.value.signals; - TRACE(2,"anc_fade_thread. %d",singles); + while (1) { + evt = osSignalWait(0, osWaitForever); - if(evt.status == osEventSignal) - { + singles = evt.value.signals; + TRACE(2, "anc_fade_thread. %d", singles); - switch (singles) - { + if (evt.status == osEventSignal) { - case FADE_IN: + switch (singles) { + + case FADE_IN: #if defined(ANC_FF_ENABLED) && defined(ANC_FB_ENABLED) - anc_disable_gain_updated_when_pass0(0); - while(__anc_usb_app_fadein_ff_fb()); + anc_disable_gain_updated_when_pass0(0); + while (__anc_usb_app_fadein_ff_fb()) + ; #else #ifdef ANC_FF_ENABLED - while (__anc_usb_app_fadein(ANC_FEEDFORWARD)) - ; + while (__anc_usb_app_fadein(ANC_FEEDFORWARD)) + ; #endif #ifdef ANC_FB_ENABLED - while (__anc_usb_app_fadein(ANC_FEEDBACK)) - ; + while (__anc_usb_app_fadein(ANC_FEEDBACK)) + ; #endif #endif - app_anc_fade_status = APP_ANC_IDLE; + app_anc_fade_status = APP_ANC_IDLE; - break; - case FADE_OUT: + break; + case FADE_OUT: #if defined(ANC_FF_ENABLED) && defined(ANC_FB_ENABLED) - anc_disable_gain_updated_when_pass0(0); - while(__anc_usb_app_fadeout_ff_fb()); + anc_disable_gain_updated_when_pass0(0); + while (__anc_usb_app_fadeout_ff_fb()) + ; #else #ifdef ANC_FF_ENABLED - while (__anc_usb_app_fadeout(ANC_FEEDFORWARD)) - ; + while (__anc_usb_app_fadeout(ANC_FEEDFORWARD)) + ; #endif #ifdef ANC_FB_ENABLED - while (__anc_usb_app_fadeout(ANC_FEEDBACK)) - ; + while (__anc_usb_app_fadeout(ANC_FEEDBACK)) + ; #endif #endif - app_anc_fade_status = APP_ANC_IDLE; + app_anc_fade_status = APP_ANC_IDLE; #ifdef ANC_FB_CHECK - hal_codec_anc_fb_check_set_irq_handler(anc_fb_check_irq_handler); + hal_codec_anc_fb_check_set_irq_handler(anc_fb_check_irq_handler); - anc_fb_check_param(); -#endif - break; - case CHANGE_FROM_ANC_TO_TT_DIRECTLY: + anc_fb_check_param(); +#endif + break; + case CHANGE_FROM_ANC_TO_TT_DIRECTLY: #if defined(ANC_FF_ENABLED) && defined(ANC_FB_ENABLED) - anc_disable_gain_updated_when_pass0(0); - while(__anc_usb_app_fadeout_ff_fb()); + anc_disable_gain_updated_when_pass0(0); + while (__anc_usb_app_fadeout_ff_fb()) + ; #else #ifdef ANC_FF_ENABLED - while (__anc_usb_app_fadeout(ANC_FEEDFORWARD)); + while (__anc_usb_app_fadeout(ANC_FEEDFORWARD)) + ; #endif #ifdef ANC_FB_ENABLED - while (__anc_usb_app_fadeout(ANC_FEEDBACK)); + while (__anc_usb_app_fadeout(ANC_FEEDBACK)) + ; #endif #endif #if defined(ANC_FF_ENABLED) && defined(ANC_FB_ENABLED) - anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],anc_coef_idx,ANC_FEEDFORWARD,ANC_GAIN_DELAY); - anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],anc_coef_idx,ANC_FEEDBACK,ANC_GAIN_DELAY); + anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx, + ANC_FEEDFORWARD, ANC_GAIN_DELAY); + anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx, + ANC_FEEDBACK, ANC_GAIN_DELAY); #ifdef AUDIO_ANC_FB_MC_HW - anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],anc_coef_idx,ANC_MUSICCANCLE,ANC_GAIN_DELAY); + anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx, + ANC_MUSICCANCLE, ANC_GAIN_DELAY); #endif #else #ifdef ANC_FF_ENABLED - anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],anc_coef_idx,ANC_FEEDFORWARD,ANC_GAIN_DELAY); + anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx, + ANC_FEEDFORWARD, ANC_GAIN_DELAY); #endif - + #ifdef ANC_FB_ENABLED - anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],anc_coef_idx,ANC_FEEDBACK,ANC_GAIN_DELAY); + anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx, + ANC_FEEDBACK, ANC_GAIN_DELAY); #endif #endif #if defined(ANC_FF_ENABLED) && defined(ANC_FB_ENABLED) - anc_disable_gain_updated_when_pass0(0); - while(__anc_usb_app_fadein_ff_fb()); + anc_disable_gain_updated_when_pass0(0); + while (__anc_usb_app_fadein_ff_fb()) + ; #else #ifdef ANC_FF_ENABLED - while (__anc_usb_app_fadein(ANC_FEEDFORWARD)); + while (__anc_usb_app_fadein(ANC_FEEDFORWARD)) + ; #endif - + #ifdef ANC_FB_ENABLED - while (__anc_usb_app_fadein(ANC_FEEDBACK)); + while (__anc_usb_app_fadein(ANC_FEEDBACK)) + ; #endif #endif - app_anc_fade_status = APP_ANC_IDLE; + app_anc_fade_status = APP_ANC_IDLE; - //recommand to play "ANC SWITCH" prompt here... - - break; - default: - break; + // recommand to play "ANC SWITCH" prompt here... - } + break; + default: + break; + } - } - else - { - TRACE(2,"anc fade thread evt error"); - continue; - } + } else { + TRACE(2, "anc fade thread evt error"); + continue; } + } } -void app_anc_gain_fadein(void) -{ - APP_MESSAGE_BLOCK msg; - TRACE(1," %s ", __func__); - if (app_poweroff_flag) - return; +void app_anc_gain_fadein(void) { + APP_MESSAGE_BLOCK msg; + TRACE(1, " %s ", __func__); + if (app_poweroff_flag) + return; - app_anc_fade_status = APP_ANC_FADE_IN; + app_anc_fade_status = APP_ANC_FADE_IN; - msg.mod_id = APP_MODUAL_ANC; - msg.msg_body.message_id = ANC_EVENT_FADE_IN; - app_mailbox_put(&msg); + msg.mod_id = APP_MODUAL_ANC; + msg.msg_body.message_id = ANC_EVENT_FADE_IN; + app_mailbox_put(&msg); } -void app_anc_post_anc_codec_close(void) -{ - APP_MESSAGE_BLOCK msg; - TRACE(1," %s ", __func__); - if (app_poweroff_flag) - return; +void app_anc_post_anc_codec_close(void) { + APP_MESSAGE_BLOCK msg; + TRACE(1, " %s ", __func__); + if (app_poweroff_flag) + return; - msg.mod_id = APP_MODUAL_ANC; - msg.msg_body.message_id = SIMPLE_PLAYER_CLOSE_CODEC_EVT; - app_mailbox_put(&msg); + msg.mod_id = APP_MODUAL_ANC; + msg.msg_body.message_id = SIMPLE_PLAYER_CLOSE_CODEC_EVT; + app_mailbox_put(&msg); } -void app_anc_gain_fadeout(void) -{ - APP_MESSAGE_BLOCK msg; - TRACE(1," %s ", __func__); - if (app_poweroff_flag) - return; +void app_anc_gain_fadeout(void) { + APP_MESSAGE_BLOCK msg; + TRACE(1, " %s ", __func__); + if (app_poweroff_flag) + return; - app_anc_fade_status = APP_ANC_FADE_OUT; + app_anc_fade_status = APP_ANC_FADE_OUT; - msg.mod_id = APP_MODUAL_ANC; - msg.msg_body.message_id = ANC_EVENT_FADE_OUT; - app_mailbox_put(&msg); + msg.mod_id = APP_MODUAL_ANC; + msg.msg_body.message_id = ANC_EVENT_FADE_OUT; + app_mailbox_put(&msg); } -void app_anc_status_post(uint8_t status) -{ - APP_MESSAGE_BLOCK msg; - TRACE(2," %s status %d", __func__, status); - if (app_poweroff_flag) - return; +void app_anc_status_post(uint8_t status) { + APP_MESSAGE_BLOCK msg; + TRACE(2, " %s status %d", __func__, status); + if (app_poweroff_flag) + return; - msg.mod_id = APP_MODUAL_ANC; - msg.msg_body.message_id = ANC_EVENT_CHANGE_STATUS; - msg.msg_body.message_Param0 = status; - app_mailbox_put(&msg); + msg.mod_id = APP_MODUAL_ANC; + msg.msg_body.message_id = ANC_EVENT_CHANGE_STATUS; + msg.msg_body.message_Param0 = status; + app_mailbox_put(&msg); } -void app_anc_status_sync(uint8_t status) -{ - APP_MESSAGE_BLOCK msg; - TRACE(2," %s status %d", __func__, status); - if (app_poweroff_flag) - return; +void app_anc_status_sync(uint8_t status) { + APP_MESSAGE_BLOCK msg; + TRACE(2, " %s status %d", __func__, status); + if (app_poweroff_flag) + return; - msg.mod_id = APP_MODUAL_ANC; - msg.msg_body.message_id = ANC_EVENT_SYNC_STATUS; - msg.msg_body.message_Param0 = status; - app_mailbox_put(&msg); + msg.mod_id = APP_MODUAL_ANC; + msg.msg_body.message_id = ANC_EVENT_SYNC_STATUS; + msg.msg_body.message_Param0 = status; + app_mailbox_put(&msg); } -void app_anc_status_sync_init(void) -{ - APP_MESSAGE_BLOCK msg; - TRACE(1," %s ", __func__); - if (app_poweroff_flag) - return; +void app_anc_status_sync_init(void) { + APP_MESSAGE_BLOCK msg; + TRACE(1, " %s ", __func__); + if (app_poweroff_flag) + return; - msg.mod_id = APP_MODUAL_ANC; - msg.msg_body.message_id = ANC_EVENT_SYNC_INIT; - app_mailbox_put(&msg); + msg.mod_id = APP_MODUAL_ANC; + msg.msg_body.message_id = ANC_EVENT_SYNC_INIT; + app_mailbox_put(&msg); } -void app_anc_do_init(void) -{ - APP_MESSAGE_BLOCK msg; - TRACE(1," %s DO INIT", __func__); - if (app_poweroff_flag) - return; +void app_anc_do_init(void) { + APP_MESSAGE_BLOCK msg; + TRACE(1, " %s DO INIT", __func__); + if (app_poweroff_flag) + return; - msg.mod_id = APP_MODUAL_ANC; - msg.msg_body.message_id = ANC_EVENT_INIT; - app_mailbox_put(&msg); + msg.mod_id = APP_MODUAL_ANC; + msg.msg_body.message_id = ANC_EVENT_INIT; + app_mailbox_put(&msg); } -void app_anc_send_howl_evt(uint32_t howl) -{ - APP_MESSAGE_BLOCK msg; - TRACE(2," %s %d", __func__, howl); - if (app_poweroff_flag) - return; +void app_anc_send_howl_evt(uint32_t howl) { + APP_MESSAGE_BLOCK msg; + TRACE(2, " %s %d", __func__, howl); + if (app_poweroff_flag) + return; - msg.mod_id = APP_MODUAL_ANC; - msg.msg_body.message_id = ANC_EVENT_HOWL_PROCESS; - msg.msg_body.message_Param0 = howl; - app_mailbox_put(&msg); + msg.mod_id = APP_MODUAL_ANC; + msg.msg_body.message_id = ANC_EVENT_HOWL_PROCESS; + msg.msg_body.message_Param0 = howl; + app_mailbox_put(&msg); } -void app_anc_send_pwr_key_monitor_evt(uint8_t level) -{ - APP_MESSAGE_BLOCK msg; - TRACE(2," %s %d", __func__, level); - if (app_poweroff_flag) - return; +void app_anc_send_pwr_key_monitor_evt(uint8_t level) { + APP_MESSAGE_BLOCK msg; + TRACE(2, " %s %d", __func__, level); + if (app_poweroff_flag) + return; - msg.mod_id = APP_MODUAL_ANC; - msg.msg_body.message_id = ANC_EVENT_PWR_KEY_MONITOR; - msg.msg_body.message_Param0 = level; - app_mailbox_put(&msg); + msg.mod_id = APP_MODUAL_ANC; + msg.msg_body.message_id = ANC_EVENT_PWR_KEY_MONITOR; + msg.msg_body.message_Param0 = level; + app_mailbox_put(&msg); } extern void simple_player_delay_stop(void); -void app_anc_post_simplayer_stop_evt(void) -{ - APP_MESSAGE_BLOCK msg; - TRACE(1," %s d", __func__); +void app_anc_post_simplayer_stop_evt(void) { + APP_MESSAGE_BLOCK msg; + TRACE(1, " %s d", __func__); - msg.mod_id = APP_MODUAL_ANC; - msg.msg_body.message_id = SIMPLE_PLAYER_DELAY_STOP_EVT; - msg.msg_body.message_Param0 = 0; - app_mailbox_put(&msg); + msg.mod_id = APP_MODUAL_ANC; + msg.msg_body.message_id = SIMPLE_PLAYER_DELAY_STOP_EVT; + msg.msg_body.message_Param0 = 0; + app_mailbox_put(&msg); } -bool anc_enabled(void) -{ - return (anc_work_status == ANC_STATUS_ON); -} +bool anc_enabled(void) { return (anc_work_status == ANC_STATUS_ON); } -void app_anc_resample(uint32_t res_ratio, uint32_t *in, uint32_t *out, uint32_t samples) -{ - uint32_t flag = int_lock(); - for (int i = samples; i > 0; i--) - { - for (int j = 0; j < res_ratio; j++) - { - *(out + (i - 1) * res_ratio + j) = *(in + i - 1); - } +void app_anc_resample(uint32_t res_ratio, uint32_t *in, uint32_t *out, + uint32_t samples) { + uint32_t flag = int_lock(); + for (int i = samples; i > 0; i--) { + for (int j = 0; j < res_ratio; j++) { + *(out + (i - 1) * res_ratio + j) = *(in + i - 1); } - int_unlock(flag); + } + int_unlock(flag); } -void app_anc_select_coef(void) -{ - TRACE(2,"enter %s %d\n", __FUNCTION__, __LINE__); +void app_anc_select_coef(void) { + TRACE(2, "enter %s %d\n", __FUNCTION__, __LINE__); #ifdef ANC_FF_ENABLED - anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],anc_coef_idx, ANC_FEEDFORWARD, ANC_GAIN_DELAY); + anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx, + ANC_FEEDFORWARD, ANC_GAIN_DELAY); #endif #ifdef ANC_FB_ENABLED - anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],anc_coef_idx, ANC_FEEDBACK, ANC_GAIN_DELAY); + anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx, + ANC_FEEDBACK, ANC_GAIN_DELAY); #endif #ifdef AUDIO_ANC_FB_MC_HW - anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],anc_coef_idx, ANC_MUSICCANCLE, ANC_GAIN_NO_DELAY); + anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx, + ANC_MUSICCANCLE, ANC_GAIN_NO_DELAY); #endif - TRACE(2,"exit %s %d\n", __FUNCTION__, __LINE__); + TRACE(2, "exit %s %d\n", __FUNCTION__, __LINE__); } -void app_anc_enable(void) -{ - TRACE(2,"enter %s %d\n", __FUNCTION__, __LINE__); -//anc_active_codec(); +void app_anc_enable(void) { + TRACE(2, "enter %s %d\n", __FUNCTION__, __LINE__); +// anc_active_codec(); #ifndef __SIMPLE_INTERNAL_PLAYER_SUPPORT__ - analog_aud_codec_speaker_enable(true); + analog_aud_codec_speaker_enable(true); #endif #ifdef ANC_FF_ENABLED - anc_open(ANC_FEEDFORWARD); - anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],anc_coef_idx, ANC_FEEDFORWARD, ANC_GAIN_DELAY); + anc_open(ANC_FEEDFORWARD); + anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx, + ANC_FEEDFORWARD, ANC_GAIN_DELAY); #endif #ifdef ANC_FB_ENABLED - anc_open(ANC_FEEDBACK); - anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],anc_coef_idx, ANC_FEEDBACK, ANC_GAIN_DELAY); + anc_open(ANC_FEEDBACK); + anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx, + ANC_FEEDBACK, ANC_GAIN_DELAY); #endif #ifdef AUDIO_ANC_FB_MC_HW - anc_open(ANC_MUSICCANCLE); - anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],anc_coef_idx, ANC_MUSICCANCLE, ANC_GAIN_NO_DELAY); + anc_open(ANC_MUSICCANCLE); + anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx, + ANC_MUSICCANCLE, ANC_GAIN_NO_DELAY); #endif #ifdef AUDIO_ANC_FB_MC_HW - int32_t gain_ch_l = 0; - int32_t gain_ch_r = 0; + int32_t gain_ch_l = 0; + int32_t gain_ch_r = 0; - anc_get_cfg_gain(&gain_ch_l, &gain_ch_r, ANC_MUSICCANCLE); - anc_set_gain(gain_ch_l, gain_ch_r, ANC_MUSICCANCLE); + anc_get_cfg_gain(&gain_ch_l, &gain_ch_r, ANC_MUSICCANCLE); + anc_set_gain(gain_ch_l, gain_ch_r, ANC_MUSICCANCLE); #endif #if defined(ANC_WNR_ENABLED) - if (is_sco_mode()) { - anc_wnr_open(ANC_WNR_OPEN_MODE_CONFIGURE); - } else { - anc_wnr_open(ANC_WNR_OPEN_MODE_STANDALONE); - } + if (is_sco_mode()) { + anc_wnr_open(ANC_WNR_OPEN_MODE_CONFIGURE); + } else { + anc_wnr_open(ANC_WNR_OPEN_MODE_STANDALONE); + } #endif #if defined(ANC_ASSIST_ENABLED) - anc_assist_open(ANC_ASSIST_STANDALONE); + anc_assist_open(ANC_ASSIST_STANDALONE); #endif - TRACE(2,"exit %s %d\n", __FUNCTION__, __LINE__); + TRACE(2, "exit %s %d\n", __FUNCTION__, __LINE__); } -void app_anc_disable(void) -{ - TRACE(2,"enter %s %d\n", __FUNCTION__, __LINE__); +void app_anc_disable(void) { + TRACE(2, "enter %s %d\n", __FUNCTION__, __LINE__); #if defined(ANC_WNR_ENABLED) - anc_wnr_close(); + anc_wnr_close(); #endif #if defined(ANC_ASSIST_ENABLED) - anc_assist_close(); + anc_assist_close(); #endif #ifdef AUDIO_ANC_FB_MC_HW - anc_close(ANC_MUSICCANCLE); + anc_close(ANC_MUSICCANCLE); #endif #ifdef ANC_FF_ENABLED - anc_close(ANC_FEEDFORWARD); + anc_close(ANC_FEEDFORWARD); #endif #ifdef ANC_FB_ENABLED - anc_close(ANC_FEEDBACK); + anc_close(ANC_FEEDBACK); #endif - TRACE(2,"exit %s %d\n", __FUNCTION__, __LINE__); + TRACE(2, "exit %s %d\n", __FUNCTION__, __LINE__); } -static void anc_sample_rate_change(enum AUD_STREAM_T stream, enum AUD_SAMPRATE_T rate, enum AUD_SAMPRATE_T *new_play, enum AUD_SAMPRATE_T *new_cap) -{ - enum AUD_SAMPRATE_T play_rate, cap_rate; +static void anc_sample_rate_change(enum AUD_STREAM_T stream, + enum AUD_SAMPRATE_T rate, + enum AUD_SAMPRATE_T *new_play, + enum AUD_SAMPRATE_T *new_cap) { + enum AUD_SAMPRATE_T play_rate, cap_rate; - if (anc_sample_rate[stream] != rate) { + if (anc_sample_rate[stream] != rate) { #ifdef CHIP_BEST1000 - if (stream == AUD_STREAM_PLAYBACK) { - play_rate = rate; - cap_rate = rate * (anc_sample_rate[AUD_STREAM_CAPTURE] / anc_sample_rate[AUD_STREAM_PLAYBACK]); - } else { - play_rate = rate / (anc_sample_rate[AUD_STREAM_CAPTURE] / anc_sample_rate[AUD_STREAM_PLAYBACK]); - cap_rate = rate; - } + if (stream == AUD_STREAM_PLAYBACK) { + play_rate = rate; + cap_rate = rate * (anc_sample_rate[AUD_STREAM_CAPTURE] / + anc_sample_rate[AUD_STREAM_PLAYBACK]); + } else { + play_rate = rate / (anc_sample_rate[AUD_STREAM_CAPTURE] / + anc_sample_rate[AUD_STREAM_PLAYBACK]); + cap_rate = rate; + } #else - play_rate = rate; - cap_rate = rate; + play_rate = rate; + cap_rate = rate; #ifdef ANC_FF_ENABLED - anc_select_coef(play_rate,anc_coef_idx, ANC_FEEDFORWARD, ANC_GAIN_NO_DELAY); + anc_select_coef(play_rate, anc_coef_idx, ANC_FEEDFORWARD, + ANC_GAIN_NO_DELAY); #endif #ifdef ANC_FB_ENABLED - anc_select_coef(play_rate,anc_coef_idx, ANC_FEEDBACK, ANC_GAIN_NO_DELAY); + anc_select_coef(play_rate, anc_coef_idx, ANC_FEEDBACK, ANC_GAIN_NO_DELAY); #endif #ifdef AUDIO_ANC_FB_MC_HW - anc_select_coef(play_rate,anc_coef_idx, ANC_MUSICCANCLE, ANC_GAIN_NO_DELAY); + anc_select_coef(play_rate, anc_coef_idx, ANC_MUSICCANCLE, + ANC_GAIN_NO_DELAY); #endif +#endif // CHIP_BEST1000 -#endif //CHIP_BEST1000 + TRACE(5, "%s: Update anc sample rate from %u/%u to %u/%u", __func__, + anc_sample_rate[AUD_STREAM_PLAYBACK], + anc_sample_rate[AUD_STREAM_CAPTURE], play_rate, cap_rate); - TRACE(5,"%s: Update anc sample rate from %u/%u to %u/%u", __func__, - anc_sample_rate[AUD_STREAM_PLAYBACK], anc_sample_rate[AUD_STREAM_CAPTURE], play_rate, cap_rate); - - if (new_play) { - *new_play= play_rate; - } - if (new_cap) { - *new_cap = cap_rate; - } - - anc_sample_rate[AUD_STREAM_PLAYBACK] = play_rate; - anc_sample_rate[AUD_STREAM_CAPTURE] = cap_rate; + if (new_play) { + *new_play = play_rate; } + if (new_cap) { + *new_cap = cap_rate; + } + + anc_sample_rate[AUD_STREAM_PLAYBACK] = play_rate; + anc_sample_rate[AUD_STREAM_CAPTURE] = cap_rate; + } } -void app_anc_open_anc(void) -{ - enum AUD_SAMPRATE_T playback_rate; - enum AUD_SAMPRATE_T capture_rate; - AF_ANC_HANDLER handler; +void app_anc_open_anc(void) { + enum AUD_SAMPRATE_T playback_rate; + enum AUD_SAMPRATE_T capture_rate; + AF_ANC_HANDLER handler; - TRACE(2,"enter %s %d\n", __FUNCTION__, __LINE__); + TRACE(2, "enter %s %d\n", __FUNCTION__, __LINE__); - handler = anc_sample_rate_change; + handler = anc_sample_rate_change; #ifdef __SIMPLE_INTERNAL_PLAYER_SUPPORT__ - app_start_player_by_anc(); + app_start_player_by_anc(); #endif - if (anc_sample_rate[AUD_STREAM_PLAYBACK] == AUD_SAMPRATE_NULL) { + if (anc_sample_rate[AUD_STREAM_PLAYBACK] == AUD_SAMPRATE_NULL) { #ifdef CHIP_BEST1000 - anc_sample_rate[AUD_STREAM_PLAYBACK] = AUD_SAMPRATE_96000; - anc_sample_rate[AUD_STREAM_CAPTURE] = AUD_SAMPRATE_384000; + anc_sample_rate[AUD_STREAM_PLAYBACK] = AUD_SAMPRATE_96000; + anc_sample_rate[AUD_STREAM_CAPTURE] = AUD_SAMPRATE_384000; #else // !CHIP_BEST1000 - anc_sample_rate[AUD_STREAM_PLAYBACK] = AUD_SAMPRATE_48000; - anc_sample_rate[AUD_STREAM_CAPTURE] = AUD_SAMPRATE_48000; + anc_sample_rate[AUD_STREAM_PLAYBACK] = AUD_SAMPRATE_48000; + anc_sample_rate[AUD_STREAM_CAPTURE] = AUD_SAMPRATE_48000; #endif - anc_sample_rate[AUD_STREAM_PLAYBACK] = hal_codec_anc_convert_rate(anc_sample_rate[AUD_STREAM_PLAYBACK]); - anc_sample_rate[AUD_STREAM_CAPTURE] = hal_codec_anc_convert_rate(anc_sample_rate[AUD_STREAM_CAPTURE]); - } + anc_sample_rate[AUD_STREAM_PLAYBACK] = + hal_codec_anc_convert_rate(anc_sample_rate[AUD_STREAM_PLAYBACK]); + anc_sample_rate[AUD_STREAM_CAPTURE] = + hal_codec_anc_convert_rate(anc_sample_rate[AUD_STREAM_CAPTURE]); + } - playback_rate = anc_sample_rate[AUD_STREAM_PLAYBACK]; - capture_rate = anc_sample_rate[AUD_STREAM_CAPTURE]; + playback_rate = anc_sample_rate[AUD_STREAM_PLAYBACK]; + capture_rate = anc_sample_rate[AUD_STREAM_CAPTURE]; - pmu_anc_config(1); + pmu_anc_config(1); #ifdef ANC_FF_ENABLED - af_anc_open(ANC_FEEDFORWARD, playback_rate, capture_rate, handler); - anc_open(ANC_FEEDFORWARD); - anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],anc_coef_idx, ANC_FEEDFORWARD, ANC_GAIN_DELAY); + af_anc_open(ANC_FEEDFORWARD, playback_rate, capture_rate, handler); + anc_open(ANC_FEEDFORWARD); + anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx, + ANC_FEEDFORWARD, ANC_GAIN_DELAY); #endif #ifdef ANC_FB_ENABLED - af_anc_open(ANC_FEEDBACK, playback_rate, capture_rate, handler); - anc_open(ANC_FEEDBACK); - anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],anc_coef_idx, ANC_FEEDBACK, ANC_GAIN_DELAY); + af_anc_open(ANC_FEEDBACK, playback_rate, capture_rate, handler); + anc_open(ANC_FEEDBACK); + anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx, + ANC_FEEDBACK, ANC_GAIN_DELAY); #endif #ifdef AUDIO_ANC_FB_MC_HW - anc_open(ANC_MUSICCANCLE); - anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],anc_coef_idx, ANC_MUSICCANCLE, ANC_GAIN_NO_DELAY); + anc_open(ANC_MUSICCANCLE); + anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx, + ANC_MUSICCANCLE, ANC_GAIN_NO_DELAY); #endif #if defined(AUDIO_ANC_TT_HW) - anc_open(ANC_TALKTHRU); - anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],anc_coef_idx, ANC_TALKTHRU, ANC_GAIN_NO_DELAY); + anc_open(ANC_TALKTHRU); + anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx, + ANC_TALKTHRU, ANC_GAIN_NO_DELAY); #endif #ifdef AUDIO_ANC_FB_MC_HW - int32_t gain_ch_l = 0; - int32_t gain_ch_r = 0; + int32_t gain_ch_l = 0; + int32_t gain_ch_r = 0; - anc_get_cfg_gain(&gain_ch_l, &gain_ch_r, ANC_MUSICCANCLE); - anc_set_gain(gain_ch_l, gain_ch_r, ANC_MUSICCANCLE); + anc_get_cfg_gain(&gain_ch_l, &gain_ch_r, ANC_MUSICCANCLE); + anc_set_gain(gain_ch_l, gain_ch_r, ANC_MUSICCANCLE); #endif #if defined(ANC_WNR_ENABLED) - if (is_sco_mode()) { - anc_wnr_open(ANC_WNR_OPEN_MODE_CONFIGURE); - } else { - anc_wnr_open(ANC_WNR_OPEN_MODE_STANDALONE); - } - #endif - - #if defined(ANC_ASSIST_ENABLED) - anc_assist_open(ANC_ASSIST_STANDALONE); + if (is_sco_mode()) { + anc_wnr_open(ANC_WNR_OPEN_MODE_CONFIGURE); + } else { + anc_wnr_open(ANC_WNR_OPEN_MODE_STANDALONE); + } #endif +#if defined(ANC_ASSIST_ENABLED) + anc_assist_open(ANC_ASSIST_STANDALONE); +#endif - TRACE(2,"exit %s %d\n", __FUNCTION__, __LINE__); + TRACE(2, "exit %s %d\n", __FUNCTION__, __LINE__); } -void app_anc_close_anc(void) -{ - TRACE(2,"enter %s %d\n", __FUNCTION__, __LINE__); - anc_set_dac_pa_delay = false; +void app_anc_close_anc(void) { + TRACE(2, "enter %s %d\n", __FUNCTION__, __LINE__); + anc_set_dac_pa_delay = false; #ifdef __SUPPORT_ANC_SINGLE_MODE_WITHOUT_BT__ - if (anc_single_mode_is_on()) - { - analog_aud_codec_speaker_enable(false); - } + if (anc_single_mode_is_on()) { + analog_aud_codec_speaker_enable(false); + } #endif #ifdef ANC_WNR_ENABLED - anc_wnr_close(); + anc_wnr_close(); #endif #if defined(ANC_ASSIST_ENABLED) - anc_assist_close(); + anc_assist_close(); #endif #if defined(AUDIO_ANC_TT_HW) - anc_close(ANC_TALKTHRU); + anc_close(ANC_TALKTHRU); #endif #ifdef ANC_FF_ENABLED - anc_close(ANC_FEEDFORWARD); - af_anc_close(ANC_FEEDFORWARD); + anc_close(ANC_FEEDFORWARD); + af_anc_close(ANC_FEEDFORWARD); #endif #ifdef ANC_FB_ENABLED #if defined(AUDIO_ANC_FB_MC_HW) - anc_close(ANC_MUSICCANCLE); + anc_close(ANC_MUSICCANCLE); #endif - anc_close(ANC_FEEDBACK); - af_anc_close(ANC_FEEDBACK); + anc_close(ANC_FEEDBACK); + af_anc_close(ANC_FEEDBACK); #endif - pmu_anc_config(0); + pmu_anc_config(0); #ifdef __SIMPLE_INTERNAL_PLAYER_SUPPORT__ - app_stop_player_by_anc(); + app_stop_player_by_anc(); #endif - TRACE(2,"exit %s %d\n", __FUNCTION__, __LINE__); + TRACE(2, "exit %s %d\n", __FUNCTION__, __LINE__); } -void app_anc_bitrate_reopen(void) -{ - TRACE(2," %s status %d", __func__, anc_work_status); - if (anc_work_status == ANC_STATUS_INIT_ON) - { -// hal_codec_reconfig_pll_freq(playback_rate, capture_rate); - } - else if (anc_work_status == ANC_STATUS_ON) - { +void app_anc_bitrate_reopen(void) { + TRACE(2, " %s status %d", __func__, anc_work_status); + if (anc_work_status == ANC_STATUS_INIT_ON) { + // hal_codec_reconfig_pll_freq(playback_rate, capture_rate); + } else if (anc_work_status == ANC_STATUS_ON) { // hal_codec_reconfig_pll_freq(playback_rate, capture_rate); - } - else if (anc_work_status == ANC_STATUS_WAITING_ON) - { - } - else - { - TRACE(0,"no deal situation."); - } + } else if (anc_work_status == ANC_STATUS_WAITING_ON) { + } else { + TRACE(0, "no deal situation."); + } } -void app_anc_status_change(void) -{ +void app_anc_status_change(void) { #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (p_ibrt_ctrl->current_role == IBRT_SLAVE) - { - anc_coef_idx = anc_peer_coef_idx; - } + if (p_ibrt_ctrl->current_role == IBRT_SLAVE) { + anc_coef_idx = anc_peer_coef_idx; + } #endif - TRACE(3,"%s anc_work_status: %d anc_coef_idx: %d", __func__, anc_work_status, anc_coef_idx); + TRACE(3, "%s anc_work_status: %d anc_coef_idx: %d", __func__, anc_work_status, + anc_coef_idx); - switch (anc_work_status) - { - case ANC_STATUS_OFF: - anc_work_status = ANC_STATUS_WAITING_ON; - app_anc_timer_set(ANC_EVENT_OPEN, anc_switch_on_time); - app_anc_open_anc(); - break; - case ANC_STATUS_ON: + switch (anc_work_status) { + case ANC_STATUS_OFF: + anc_work_status = ANC_STATUS_WAITING_ON; + app_anc_timer_set(ANC_EVENT_OPEN, anc_switch_on_time); + app_anc_open_anc(); + break; + case ANC_STATUS_ON: #if (ANC_COEF_LIST_NUM > 1) #ifdef __BT_ANC_KEY__ - if(anc_status_sync_flag == false) - { - anc_coef_idx++; - } + if (anc_status_sync_flag == false) { + anc_coef_idx++; + } #endif - if (anc_coef_idx < ANC_COEF_LIST_NUM) - { - TRACE(2," %s set coef idx: %d ", __func__, anc_coef_idx); + if (anc_coef_idx < ANC_COEF_LIST_NUM) { + TRACE(2, " %s set coef idx: %d ", __func__, anc_coef_idx); #ifdef ANC_MODE_SWITCH_WITHOUT_FADE #ifdef ANC_FF_ENABLED - anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],anc_coef_idx,ANC_FEEDFORWARD,ANC_GAIN_NO_DELAY); + anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx, + ANC_FEEDFORWARD, ANC_GAIN_NO_DELAY); #endif #ifdef ANC_FB_ENABLED - anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],anc_coef_idx,ANC_FEEDBACK,ANC_GAIN_NO_DELAY); + anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx, + ANC_FEEDBACK, ANC_GAIN_NO_DELAY); #endif #ifdef AUDIO_ANC_FB_MC_HW - anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],anc_coef_idx,ANC_MUSICCANCLE,ANC_GAIN_NO_DELAY); + anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx, + ANC_MUSICCANCLE, ANC_GAIN_NO_DELAY); #endif - //recommand to play "ANC SWITCH" prompt here... + // recommand to play "ANC SWITCH" prompt here... #else - osSignalSet(anc_fade_thread_tid,CHANGE_FROM_ANC_TO_TT_DIRECTLY); + osSignalSet(anc_fade_thread_tid, CHANGE_FROM_ANC_TO_TT_DIRECTLY); #endif - } - else - { - anc_coef_idx = 0; - app_anc_timer_set(ANC_EVENT_CLOSE, anc_close_delay_time); - app_anc_gain_fadeout(); - anc_work_status = ANC_STATUS_WAITING_OFF; - } -#else - anc_coef_idx = 0; - app_anc_timer_set(ANC_EVENT_CLOSE, anc_close_delay_time); - app_anc_gain_fadeout(); - anc_work_status = ANC_STATUS_WAITING_OFF; -#endif - break; - case ANC_STATUS_INIT_ON: - app_anc_select_coef(); - app_anc_gain_fadein(); - anc_work_status = ANC_STATUS_WAITING_ON; - app_anc_timer_close(); - break; - default: - break; + } else { + anc_coef_idx = 0; + app_anc_timer_set(ANC_EVENT_CLOSE, anc_close_delay_time); + app_anc_gain_fadeout(); + anc_work_status = ANC_STATUS_WAITING_OFF; } - if(anc_status_sync_flag == true) - anc_status_sync_flag = false; +#else + anc_coef_idx = 0; + app_anc_timer_set(ANC_EVENT_CLOSE, anc_close_delay_time); + app_anc_gain_fadeout(); + anc_work_status = ANC_STATUS_WAITING_OFF; +#endif + break; + case ANC_STATUS_INIT_ON: + app_anc_select_coef(); + app_anc_gain_fadein(); + anc_work_status = ANC_STATUS_WAITING_ON; + app_anc_timer_close(); + break; + default: + break; + } + if (anc_status_sync_flag == true) + anc_status_sync_flag = false; } -static int app_anc_handle_process(APP_MESSAGE_BODY *msg_body) -{ - uint32_t evt = msg_body->message_id; - uint32_t arg0 = msg_body->message_Param0; +static int app_anc_handle_process(APP_MESSAGE_BODY *msg_body) { + uint32_t evt = msg_body->message_id; + uint32_t arg0 = msg_body->message_Param0; - TRACE(4," %s evt: %d, arg0: %d , anc status :%d", __func__, evt, arg0, anc_work_status); + TRACE(4, " %s evt: %d, arg0: %d , anc status :%d", __func__, evt, arg0, + anc_work_status); - switch (evt) - { - case ANC_EVENT_INIT: - //init anc_timer - app_anc_init_timer(); - //init anc&open codec + switch (evt) { + case ANC_EVENT_INIT: + // init anc_timer + app_anc_init_timer(); + // init anc&open codec #ifdef __AUDIO_SECTION_SUPPT__ - anc_load_cfg(); + anc_load_cfg(); #endif #ifdef __ANC_INIT_ON__ - app_anc_open_anc(); - anc_work_status = ANC_STATUS_INIT_ON; - app_anc_timer_set(ANC_EVENT_CLOSE, anc_init_switch_off_time); + app_anc_open_anc(); + anc_work_status = ANC_STATUS_INIT_ON; + app_anc_timer_set(ANC_EVENT_CLOSE, anc_init_switch_off_time); #else - anc_work_status = ANC_STATUS_OFF; + anc_work_status = ANC_STATUS_OFF; #endif #ifdef __ANC_STICK_SWITCH_USE_GPIO__ - if (app_anc_switch_get_val() == ANC_SWITCH_ON_LEVEL) - { - app_anc_switch_set_edge(ANC_SWITCH_ON_LEVEL); - app_anc_status_post(ANC_SWITCH_ON_LEVEL); - } - else - { - app_anc_switch_set_edge(!(bool)ANC_SWITCH_ON_LEVEL); - } + if (app_anc_switch_get_val() == ANC_SWITCH_ON_LEVEL) { + app_anc_switch_set_edge(ANC_SWITCH_ON_LEVEL); + app_anc_status_post(ANC_SWITCH_ON_LEVEL); + } else { + app_anc_switch_set_edge(!(bool)ANC_SWITCH_ON_LEVEL); + } #endif - //anc_coef_idx = 0; - anc_fade_thread_tid = osThreadCreate(osThread(anc_fade_thread),NULL); - break; - case ANC_EVENT_FADE_IN: - case ANC_EVENT_FADE_OUT: - anc_gain_fade_handle(); - if (evt == ANC_EVENT_FADE_IN) - { - anc_work_status = ANC_STATUS_ON; - //recommand to play "ANC ON" prompt here... - app_voice_report(APP_STATUS_INDICATION_ALEXA_START,0);//close latlatency mode - - } - if (evt == ANC_EVENT_FADE_OUT) - { - anc_work_status = ANC_STATUS_INIT_ON; - //recommand to play "ANC OFF" prompt here... - app_voice_report(APP_STATUS_INDICATION_ALEXA_STOP,0);//close latlatency mode - - } - break; - case ANC_EVENT_CHANGE_SAMPLERATE: - app_anc_bitrate_reopen(); - break; - case ANC_EVENT_CHANGE_STATUS: + // anc_coef_idx = 0; + anc_fade_thread_tid = osThreadCreate(osThread(anc_fade_thread), NULL); + break; + case ANC_EVENT_FADE_IN: + case ANC_EVENT_FADE_OUT: + anc_gain_fade_handle(); + if (evt == ANC_EVENT_FADE_IN) { + anc_work_status = ANC_STATUS_ON; + // recommand to play "ANC ON" prompt here... + app_voice_report(APP_STATUS_INDICATION_ALEXA_START, + 0); // close latlatency mode + } + if (evt == ANC_EVENT_FADE_OUT) { + anc_work_status = ANC_STATUS_INIT_ON; + // recommand to play "ANC OFF" prompt here... + app_voice_report(APP_STATUS_INDICATION_ALEXA_STOP, + 0); // close latlatency mode + } + break; + case ANC_EVENT_CHANGE_SAMPLERATE: + app_anc_bitrate_reopen(); + break; + case ANC_EVENT_CHANGE_STATUS: #ifdef __ANC_STICK_SWITCH_USE_GPIO__ - osDelay(10); - if (app_anc_switch_get_val() != (bool)arg0) - { //debonce - TRACE(0,"io level not equeue exit"); - break; - } + osDelay(10); + if (app_anc_switch_get_val() != (bool)arg0) { // debonce + TRACE(0, "io level not equeue exit"); + break; + } #ifdef __SUPPORT_ANC_SINGLE_MODE_WITHOUT_BT__ - if (anc_single_mode_is_on()) - { - if (arg0 != ANC_SWITCH_ON_LEVEL) - { - TRACE(1," Anc ON but exit %d ", app_init_done); - if (app_init_done) - { - app_anc_shutdown = true; - app_shutdown(); - } - else - { - app_anc_timer_set(ANC_EVENT_SWITCH_KEY_DEBONCE, anc_switch_key_debonce_time); - } - return 0; - } - } -#endif - if (arg0 != ANC_SWITCH_ON_LEVEL) - app_anc_switch_set_edge((!(bool)ANC_SWITCH_ON_LEVEL)); - else - app_anc_switch_set_edge(ANC_SWITCH_ON_LEVEL); - - if (((arg0 == ANC_SWITCH_ON_LEVEL) && (anc_work_status == ANC_STATUS_ON)) || - ((arg0 != ANC_SWITCH_ON_LEVEL) && (anc_work_status == ANC_STATUS_OFF))) - { - //status same, no handle - TRACE(0," Anc NOT ON, exit"); - return 0; - } -#endif - -#if defined(IBRT) - if(((BOOL)arg0 == false) && (app_anc_work_status() == false)) - { - anc_coef_idx = 0; - anc_peer_coef_idx = 0; - anc_status_sync_flag = 0; - return 0; - } - - if(((BOOL)arg0 == true) && (app_anc_work_status() == true) && (anc_coef_idx == anc_peer_coef_idx)) - { - anc_status_sync_flag = 0; - return 0; - } -#endif - app_anc_status_change(); - - break; - case ANC_EVENT_SYNC_STATUS: -#if defined(IBRT) - TRACE(4,"%s anc_work_status %d--->%d anc_coef_idx:%d ", __func__, anc_work_status, arg0, anc_coef_idx); - - if(ANC_STATUS_ON == arg0) - { - arg0 = 1; - } - else - { - arg0 = 0; - } - - uint8_t buf[3] = {0}; - buf[0] = (uint8_t)arg0; - buf[1] = (uint8_t)anc_coef_idx; - buf[2] = false;//set peer anc_status_sync_flag = false - tws_ctrl_send_cmd(APP_TWS_CMD_SYNC_ANC_STATUS, buf, 3); -#endif - break; - case ANC_EVENT_SYNC_INIT:break; - case ANC_EVENT_HOWL_PROCESS: - //disable anc,set max gain,enable anc - { - //uint32_t howl = arg0; - if (anc_work_status == ANC_STATUS_ON) - { - //__anc_usb_app_howl_set_gain(howl); - } - } - break; -#ifdef __SUPPORT_ANC_SINGLE_MODE_WITHOUT_BT__ - case ANC_EVENT_PWR_KEY_MONITOR: - osDelay(10); - - if (app_pwr_key_monitor_get_val() != (bool)arg0) //debonce - return 0; - - if ((bool)arg0) - { - app_anc_timer_set(ANC_EVENT_PWR_KEY_MONITOR_REBOOT, anc_pwr_key_monitor_time); - app_pwr_key_monitor_set_int_edge(1); - } - else - { - hwtimer_stop(anc_timerid); - app_pwr_key_monitor_set_int_edge(0); - } - - break; -#endif - case SIMPLE_PLAYER_DELAY_STOP_EVT: -#ifdef __SIMPLE_INTERNAL_PLAYER_SUPPORT__ - simple_player_delay_stop(); -#endif - break; - case SIMPLE_PLAYER_CLOSE_CODEC_EVT: - app_anc_close_anc(); - anc_work_status = ANC_STATUS_OFF; - break; - default:break; - } - - return 0; -} - -static void anc_gain_fade_timer_handler(void *p) -{ - TRACE(2," %s , request %d ", __func__, anc_timer_request); - switch (anc_timer_request) - { - case ANC_EVENT_OPEN: - app_anc_gain_fadein(); - break; - case ANC_EVENT_CLOSE: - //real close - //app_anc_close_anc(); - //anc_work_status = ANC_STATUS_OFF; - app_anc_post_anc_codec_close(); - - break; - case ANC_EVENT_PWR_KEY_MONITOR_REBOOT: - TRACE(0," reboot !"); - hal_sw_bootmode_clear(HAL_SW_BOOTMODE_REBOOT); - hal_sw_bootmode_clear(HAL_SW_BOOTMODE_REBOOT_ANC_ON); - hal_sw_bootmode_set(HAL_SW_BOOTMODE_REBOOT_BT_ON); - app_reset(); - break; - case ANC_EVENT_SWITCH_KEY_DEBONCE: - TRACE(0," ANC SWITCH KEY "); -#ifdef __ANC_STICK_SWITCH_USE_GPIO__ - if (app_switch_callback) - app_switch_callback(hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)ANC_SWITCH_PIN)); -#endif - break; - default: - break; - } - anc_timer_request = ANC_EVENT_NONE; - hwtimer_stop(anc_timerid); -} - -void app_anc_init_timer(void) -{ - if (anc_timerid == NULL) - anc_timerid = hwtimer_alloc((HWTIMER_CALLBACK_T)anc_gain_fade_timer_handler, &anc_timer_request); -} - -void app_anc_timer_set(uint32_t request, uint32_t delay) -{ - TRACE(3," %s request %d , delay %ds ", __func__, request, (TICKS_TO_MS(delay) / 1000)); - if (anc_timerid == NULL) - return; - anc_timer_request = request; - hwtimer_stop(anc_timerid); - hwtimer_start(anc_timerid, delay); -} - -void app_anc_timer_close(void) -{ - TRACE(3," %s enter...", __func__); - if (anc_timerid == NULL) - { - return; - } - - anc_timer_request = ANC_EVENT_NONE; - hwtimer_stop(anc_timerid); -} - -#if defined(IBRT) -void app_anc_cmd_receive_process(uint8_t *buf, uint16_t len) -{ - TRACE(1, "[%s] enter...", __func__); - - if(buf[0] == IBRT_ACTION_ANC_NOTIRY_MASTER_EXCHANGE_COEF) - { - switch(buf[1]) - { -#ifdef __BT_ANC_KEY__ - case 0:app_anc_key(NULL, NULL);break;//slave invoke app_anc_key(); -#endif -#ifndef __BT_ANC_KEY__ - case 1:app_anc_start();break;//slave invoke app_anc_start(); - case 2:app_anc_switch_coef(buf[2]);break;//slave invoke app_anc_switch_coef(); - case 3:app_anc_stop();break;//slave invoke app_anc_stop(); -#endif - default:TRACE(1, "[%s] cmd invalid...", __func__);break; + if (anc_single_mode_is_on()) { + if (arg0 != ANC_SWITCH_ON_LEVEL) { + TRACE(1, " Anc ON but exit %d ", app_init_done); + if (app_init_done) { + app_anc_shutdown = true; + app_shutdown(); + } else { + app_anc_timer_set(ANC_EVENT_SWITCH_KEY_DEBONCE, + anc_switch_key_debonce_time); } + return 0; + } } +#endif + if (arg0 != ANC_SWITCH_ON_LEVEL) + app_anc_switch_set_edge((!(bool)ANC_SWITCH_ON_LEVEL)); + else + app_anc_switch_set_edge(ANC_SWITCH_ON_LEVEL); + + if (((arg0 == ANC_SWITCH_ON_LEVEL) && (anc_work_status == ANC_STATUS_ON)) || + ((arg0 != ANC_SWITCH_ON_LEVEL) && + (anc_work_status == ANC_STATUS_OFF))) { + // status same, no handle + TRACE(0, " Anc NOT ON, exit"); + return 0; + } +#endif + +#if defined(IBRT) + if (((BOOL)arg0 == false) && (app_anc_work_status() == false)) { + anc_coef_idx = 0; + anc_peer_coef_idx = 0; + anc_status_sync_flag = 0; + return 0; + } + + if (((BOOL)arg0 == true) && (app_anc_work_status() == true) && + (anc_coef_idx == anc_peer_coef_idx)) { + anc_status_sync_flag = 0; + return 0; + } +#endif + app_anc_status_change(); + + break; + case ANC_EVENT_SYNC_STATUS: +#if defined(IBRT) + TRACE(4, "%s anc_work_status %d--->%d anc_coef_idx:%d ", __func__, + anc_work_status, arg0, anc_coef_idx); + + if (ANC_STATUS_ON == arg0) { + arg0 = 1; + } else { + arg0 = 0; + } + + uint8_t buf[3] = {0}; + buf[0] = (uint8_t)arg0; + buf[1] = (uint8_t)anc_coef_idx; + buf[2] = false; // set peer anc_status_sync_flag = false + tws_ctrl_send_cmd(APP_TWS_CMD_SYNC_ANC_STATUS, buf, 3); +#endif + break; + case ANC_EVENT_SYNC_INIT: + break; + case ANC_EVENT_HOWL_PROCESS: + // disable anc,set max gain,enable anc + { + // uint32_t howl = arg0; + if (anc_work_status == ANC_STATUS_ON) { + //__anc_usb_app_howl_set_gain(howl); + } + } + break; +#ifdef __SUPPORT_ANC_SINGLE_MODE_WITHOUT_BT__ + case ANC_EVENT_PWR_KEY_MONITOR: + osDelay(10); + + if (app_pwr_key_monitor_get_val() != (bool)arg0) // debonce + return 0; + + if ((bool)arg0) { + app_anc_timer_set(ANC_EVENT_PWR_KEY_MONITOR_REBOOT, + anc_pwr_key_monitor_time); + app_pwr_key_monitor_set_int_edge(1); + } else { + hwtimer_stop(anc_timerid); + app_pwr_key_monitor_set_int_edge(0); + } + + break; +#endif + case SIMPLE_PLAYER_DELAY_STOP_EVT: +#ifdef __SIMPLE_INTERNAL_PLAYER_SUPPORT__ + simple_player_delay_stop(); +#endif + break; + case SIMPLE_PLAYER_CLOSE_CODEC_EVT: + app_anc_close_anc(); + anc_work_status = ANC_STATUS_OFF; + break; + default: + break; + } + + return 0; } -static void app_anc_notify_master_to_exchange_coef(uint8_t arg0, uint8_t arg1) -{ - uint8_t buf[3] = {0}; +static void anc_gain_fade_timer_handler(void *p) { + TRACE(2, " %s , request %d ", __func__, anc_timer_request); + switch (anc_timer_request) { + case ANC_EVENT_OPEN: + app_anc_gain_fadein(); + break; + case ANC_EVENT_CLOSE: + // real close + // app_anc_close_anc(); + // anc_work_status = ANC_STATUS_OFF; + app_anc_post_anc_codec_close(); - TRACE(3,"[%s] arg0:%d arg1:%d", __func__, arg0, arg1); + break; + case ANC_EVENT_PWR_KEY_MONITOR_REBOOT: + TRACE(0, " reboot !"); + hal_sw_bootmode_clear(HAL_SW_BOOTMODE_REBOOT); + hal_sw_bootmode_clear(HAL_SW_BOOTMODE_REBOOT_ANC_ON); + hal_sw_bootmode_set(HAL_SW_BOOTMODE_REBOOT_BT_ON); + app_reset(); + break; + case ANC_EVENT_SWITCH_KEY_DEBONCE: + TRACE(0, " ANC SWITCH KEY "); +#ifdef __ANC_STICK_SWITCH_USE_GPIO__ + if (app_switch_callback) + app_switch_callback( + hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)ANC_SWITCH_PIN)); +#endif + break; + default: + break; + } + anc_timer_request = ANC_EVENT_NONE; + hwtimer_stop(anc_timerid); +} - buf[0] = IBRT_ACTION_ANC_NOTIRY_MASTER_EXCHANGE_COEF; - buf[1] = arg0; - buf[2] = arg1; - - app_ibrt_ui_send_user_action(buf, 3); +void app_anc_init_timer(void) { + if (anc_timerid == NULL) + anc_timerid = hwtimer_alloc((HWTIMER_CALLBACK_T)anc_gain_fade_timer_handler, + &anc_timer_request); +} + +void app_anc_timer_set(uint32_t request, uint32_t delay) { + TRACE(3, " %s request %d , delay %ds ", __func__, request, + (TICKS_TO_MS(delay) / 1000)); + if (anc_timerid == NULL) + return; + anc_timer_request = request; + hwtimer_stop(anc_timerid); + hwtimer_start(anc_timerid, delay); +} + +void app_anc_timer_close(void) { + TRACE(3, " %s enter...", __func__); + if (anc_timerid == NULL) { + return; + } + + anc_timer_request = ANC_EVENT_NONE; + hwtimer_stop(anc_timerid); +} + +#if defined(IBRT) +void app_anc_cmd_receive_process(uint8_t *buf, uint16_t len) { + TRACE(1, "[%s] enter...", __func__); + + if (buf[0] == IBRT_ACTION_ANC_NOTIRY_MASTER_EXCHANGE_COEF) { + switch (buf[1]) { +#ifdef __BT_ANC_KEY__ + case 0: + app_anc_key(NULL, NULL); + break; // slave invoke app_anc_key(); +#endif +#ifndef __BT_ANC_KEY__ + case 1: + app_anc_start(); + break; // slave invoke app_anc_start(); + case 2: + app_anc_switch_coef(buf[2]); + break; // slave invoke app_anc_switch_coef(); + case 3: + app_anc_stop(); + break; // slave invoke app_anc_stop(); +#endif + default: + TRACE(1, "[%s] cmd invalid...", __func__); + break; + } + } +} + +static void app_anc_notify_master_to_exchange_coef(uint8_t arg0, uint8_t arg1) { + uint8_t buf[3] = {0}; + + TRACE(3, "[%s] arg0:%d arg1:%d", __func__, arg0, arg1); + + buf[0] = IBRT_ACTION_ANC_NOTIRY_MASTER_EXCHANGE_COEF; + buf[1] = arg0; + buf[2] = arg1; + + app_ibrt_ui_send_user_action(buf, 3); } #endif #ifdef __BT_ANC_KEY__ -void app_anc_key(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s anc_work_st:%d , timer:%d", __func__, anc_work_status, anc_timer_request); - bool flag = app_anc_work_status(); +void app_anc_key(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s anc_work_st:%d , timer:%d", __func__, anc_work_status, + anc_timer_request); + bool flag = app_anc_work_status(); #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - TRACE(2,"[%s] current_role: %d", __func__, p_ibrt_ctrl->current_role); - if (p_ibrt_ctrl->current_role == IBRT_SLAVE) - { - app_anc_notify_master_to_exchange_coef(0,0); - return; - } - app_anc_status_sync(!flag); + TRACE(2, "[%s] current_role: %d", __func__, p_ibrt_ctrl->current_role); + if (p_ibrt_ctrl->current_role == IBRT_SLAVE) { + app_anc_notify_master_to_exchange_coef(0, 0); + return; + } + app_anc_status_sync(!flag); #endif - app_anc_status_post(!flag); + app_anc_status_post(!flag); } #endif #ifndef __BT_ANC_KEY__ -int app_anc_start(void) -{ - TRACE(1,"[%s] enter...", __func__); - bool flag = app_anc_work_status(); +int app_anc_start(void) { + TRACE(1, "[%s] enter...", __func__); + bool flag = app_anc_work_status(); - if(flag == true) - { - TRACE(1,"[%s] anc has been on...", __func__); - return -1; - } + if (flag == true) { + TRACE(1, "[%s] anc has been on...", __func__); + return -1; + } #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - TRACE(2,"[%s] current_role: %d", __func__, p_ibrt_ctrl->current_role); - if (p_ibrt_ctrl->current_role == IBRT_SLAVE) - { - app_anc_notify_master_to_exchange_coef(1,0); - return -1; - } - anc_coef_idx = 0; - app_anc_status_sync(!flag); + TRACE(2, "[%s] current_role: %d", __func__, p_ibrt_ctrl->current_role); + if (p_ibrt_ctrl->current_role == IBRT_SLAVE) { + app_anc_notify_master_to_exchange_coef(1, 0); + return -1; + } + anc_coef_idx = 0; + app_anc_status_sync(!flag); #endif - anc_coef_idx = 0; - app_anc_status_post(!flag); + anc_coef_idx = 0; + app_anc_status_post(!flag); - return 0; + return 0; } -int app_anc_switch_coef(uint8_t index) -{ - TRACE(1,"[%s] enter...", __func__); - bool flag = app_anc_work_status(); +int app_anc_switch_coef(uint8_t index) { + TRACE(1, "[%s] enter...", __func__); + bool flag = app_anc_work_status(); - if(flag == false) - { - TRACE(1,"[%s] anc has been off...", __func__); - return -1; - } + if (flag == false) { + TRACE(1, "[%s] anc has been off...", __func__); + return -1; + } - if(index == anc_coef_idx) - { - TRACE(1,"[%s] anc coef has been load...", __func__); - return -1; - } + if (index == anc_coef_idx) { + TRACE(1, "[%s] anc coef has been load...", __func__); + return -1; + } #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - TRACE(2,"[%s] current_role: %d", __func__, p_ibrt_ctrl->current_role); - if (p_ibrt_ctrl->current_role == IBRT_SLAVE) - { - app_anc_notify_master_to_exchange_coef(2,index); - return -1; - } - anc_coef_idx = index; - app_anc_status_sync(!flag); + TRACE(2, "[%s] current_role: %d", __func__, p_ibrt_ctrl->current_role); + if (p_ibrt_ctrl->current_role == IBRT_SLAVE) { + app_anc_notify_master_to_exchange_coef(2, index); + return -1; + } + anc_coef_idx = index; + app_anc_status_sync(!flag); #endif - anc_coef_idx = index; - app_anc_status_post(!flag); + anc_coef_idx = index; + app_anc_status_post(!flag); - return 0; + return 0; } -int app_anc_stop(void) -{ - TRACE(1,"[%s] enter...", __func__); - bool flag = app_anc_work_status(); +int app_anc_stop(void) { + TRACE(1, "[%s] enter...", __func__); + bool flag = app_anc_work_status(); - if(flag == false) - { - TRACE(1,"[%s] anc has been off...", __func__); - return -1; - } + if (flag == false) { + TRACE(1, "[%s] anc has been off...", __func__); + return -1; + } #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - TRACE(2,"[%s] current_role: %d", __func__, p_ibrt_ctrl->current_role); - if (p_ibrt_ctrl->current_role == IBRT_SLAVE) - { - app_anc_notify_master_to_exchange_coef(3,0); - return -1; - } - anc_coef_idx = ANC_COEF_NUM; - app_anc_status_sync(!flag); + TRACE(2, "[%s] current_role: %d", __func__, p_ibrt_ctrl->current_role); + if (p_ibrt_ctrl->current_role == IBRT_SLAVE) { + app_anc_notify_master_to_exchange_coef(3, 0); + return -1; + } + anc_coef_idx = ANC_COEF_NUM; + app_anc_status_sync(!flag); #endif - anc_coef_idx = ANC_COEF_NUM; - app_anc_status_post(!flag); + anc_coef_idx = ANC_COEF_NUM; + app_anc_status_post(!flag); - return 0; + return 0; } #endif -void app_anc_ios_init(void) -{ +void app_anc_ios_init(void) { #ifdef __ANC_STICK_SWITCH_USE_GPIO__ - if (cfg_anc_switch.pin != HAL_IOMUX_PIN_NUM) - { - hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)&cfg_anc_switch, 1); - hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)cfg_anc_switch.pin, HAL_GPIO_DIR_IN, 0); - } + if (cfg_anc_switch.pin != HAL_IOMUX_PIN_NUM) { + hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)&cfg_anc_switch, 1); + hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)cfg_anc_switch.pin, + HAL_GPIO_DIR_IN, 0); + } #endif #ifdef __SUPPORT_ANC_SINGLE_MODE_WITHOUT_BT__ - if (cfg_pwr_key_monitor.pin != HAL_IOMUX_PIN_NUM) - { - hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)&cfg_pwr_key_monitor, 1); - hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)cfg_pwr_key_monitor.pin, HAL_GPIO_DIR_IN, 0); - } - if (cfg_anc_led.pin != HAL_IOMUX_PIN_NUM) - { - hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)&cfg_anc_led, 1); - hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)cfg_anc_led.pin, HAL_GPIO_DIR_OUT, 0); - } + if (cfg_pwr_key_monitor.pin != HAL_IOMUX_PIN_NUM) { + hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)&cfg_pwr_key_monitor, + 1); + hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)cfg_pwr_key_monitor.pin, + HAL_GPIO_DIR_IN, 0); + } + if (cfg_anc_led.pin != HAL_IOMUX_PIN_NUM) { + hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)&cfg_anc_led, 1); + hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)cfg_anc_led.pin, HAL_GPIO_DIR_OUT, + 0); + } #endif #ifdef ANC_SWITCH_PIN - uint8_t gpio_val = hal_gpio_pin_get_val(ANC_SWITCH_PIN); - if (gpio_val) - { - app_anc_switch_turnled(true); - TRACE(1," %s turn on led", __func__); - } - else - { - app_anc_switch_turnled(false); - TRACE(1," %s turn off led", __func__); - } + uint8_t gpio_val = hal_gpio_pin_get_val(ANC_SWITCH_PIN); + if (gpio_val) { + app_anc_switch_turnled(true); + TRACE(1, " %s turn on led", __func__); + } else { + app_anc_switch_turnled(false); + TRACE(1, " %s turn off led", __func__); + } #endif } -int app_anc_open_module(void) -{ - TRACE(1,"%s ", __func__); - //set app module - app_set_threadhandle(APP_MODUAL_ANC, app_anc_handle_process); - app_anc_do_init(); +int app_anc_open_module(void) { + TRACE(1, "%s ", __func__); + // set app module + app_set_threadhandle(APP_MODUAL_ANC, app_anc_handle_process); + app_anc_do_init(); #ifdef __ANC_STICK_SWITCH_USE_GPIO__ - app_anc_switch_init(app_anc_status_post); - app_anc_switch_set_edge(app_anc_switch_get_val()); + app_anc_switch_init(app_anc_status_post); + app_anc_switch_set_edge(app_anc_switch_get_val()); #endif #ifdef __SUPPORT_ANC_SINGLE_MODE_WITHOUT_BT__ - if (anc_single_mode_is_on()) - { - // app_pwr_key_monitor_init(app_anc_send_pwr_key_monitor_evt); - // app_pwr_key_monitor_set_int_edge(app_pwr_key_monitor_get_val()); - } + if (anc_single_mode_is_on()) { + // app_pwr_key_monitor_init(app_anc_send_pwr_key_monitor_evt); + // app_pwr_key_monitor_set_int_edge(app_pwr_key_monitor_get_val()); + } #endif - return 0; + return 0; } -int app_anc_close_module(void) -{ - TRACE(1," %s ", __func__); +int app_anc_close_module(void) { + TRACE(1, " %s ", __func__); - anc_timer_request = ANC_EVENT_NONE; - if (anc_timerid) - { - hwtimer_stop(anc_timerid); - hwtimer_free(anc_timerid); - anc_timerid = NULL; - } - if (app_anc_get_anc_status() != ANC_STATUS_OFF) - { - anc_work_status = ANC_STATUS_OFF; - app_anc_disable(); - app_anc_close_anc(); - } - app_set_threadhandle(APP_MODUAL_ANC, NULL); - return 0; + anc_timer_request = ANC_EVENT_NONE; + if (anc_timerid) { + hwtimer_stop(anc_timerid); + hwtimer_free(anc_timerid); + anc_timerid = NULL; + } + if (app_anc_get_anc_status() != ANC_STATUS_OFF) { + anc_work_status = ANC_STATUS_OFF; + app_anc_disable(); + app_anc_close_anc(); + } + app_set_threadhandle(APP_MODUAL_ANC, NULL); + return 0; } -enum AUD_SAMPRATE_T app_anc_get_play_rate(void) -{ - return anc_sample_rate[AUD_STREAM_PLAYBACK]; +enum AUD_SAMPRATE_T app_anc_get_play_rate(void) { + return anc_sample_rate[AUD_STREAM_PLAYBACK]; } -bool app_anc_work_status(void) -{ - // TRACE(2," %s st %d", __func__, anc_work_status); - return (anc_work_status == ANC_STATUS_ON || anc_work_status == ANC_STATUS_WAITING_ON); +bool app_anc_work_status(void) { + // TRACE(2," %s st %d", __func__, anc_work_status); + return (anc_work_status == ANC_STATUS_ON || + anc_work_status == ANC_STATUS_WAITING_ON); } -uint32_t app_anc_get_anc_status(void) -{ - return anc_work_status; +uint32_t app_anc_get_anc_status(void) { return anc_work_status; } + +void test_anc(void) { + app_anc_open_anc(); + app_anc_enable(); } -void test_anc(void) -{ - app_anc_open_anc(); +void test_anc_switch_coef(void) { + anc_coef_idx++; + + TRACE(2, " %s set coef idx: %d ", __func__, anc_coef_idx); + + if (ANC_STATUS_OFF == anc_work_status || + ANC_STATUS_INIT_ON == anc_work_status) { + app_anc_status_change(); + anc_coef_idx = 0; + return; + } + if (anc_coef_idx < (ANC_COEF_LIST_NUM)) { +#ifdef ANC_FF_ENABLED + while (__anc_usb_app_fadeout(ANC_FEEDFORWARD)) + ; +#endif +#ifdef ANC_FB_ENABLED + while (__anc_usb_app_fadeout(ANC_FEEDBACK)) + ; +#endif + + app_anc_disable(); + anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx, + ANC_FEEDFORWARD, ANC_GAIN_DELAY); app_anc_enable(); -} - -void test_anc_switch_coef(void) -{ - anc_coef_idx++; - - TRACE(2," %s set coef idx: %d ", __func__, anc_coef_idx); - - if (ANC_STATUS_OFF == anc_work_status || ANC_STATUS_INIT_ON == anc_work_status) - { - app_anc_status_change(); - anc_coef_idx = 0; - return; - } - if (anc_coef_idx < (ANC_COEF_LIST_NUM)) - { -#ifdef ANC_FF_ENABLED - while (__anc_usb_app_fadeout(ANC_FEEDFORWARD)) - ; -#endif -#ifdef ANC_FB_ENABLED - while (__anc_usb_app_fadeout(ANC_FEEDBACK)) - ; -#endif - - app_anc_disable(); - anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],anc_coef_idx,ANC_FEEDFORWARD,ANC_GAIN_DELAY); - app_anc_enable(); #ifdef ANC_FF_ENABLED - while (__anc_usb_app_fadein(ANC_FEEDFORWARD)) - ; + while (__anc_usb_app_fadein(ANC_FEEDFORWARD)) + ; #endif #ifdef ANC_FB_ENABLED - while (__anc_usb_app_fadein(ANC_FEEDBACK)) - ; + while (__anc_usb_app_fadein(ANC_FEEDBACK)) + ; #endif - } - else - { - anc_coef_idx = 0; - app_anc_timer_set(ANC_EVENT_CLOSE, anc_close_delay_time); - app_anc_gain_fadeout(); - anc_work_status = ANC_STATUS_WAITING_OFF; - } + } else { + anc_coef_idx = 0; + app_anc_timer_set(ANC_EVENT_CLOSE, anc_close_delay_time); + app_anc_gain_fadeout(); + anc_work_status = ANC_STATUS_WAITING_OFF; + } } #if defined(IBRT) -void app_anc_sync_status(void) -{ - uint8_t buf[3] = {0}; +void app_anc_sync_status(void) { + uint8_t buf[3] = {0}; - bool flag = app_anc_work_status(); - - buf[0] = (uint8_t)flag; + bool flag = app_anc_work_status(); - if(flag == true) - { - buf[1] = (uint8_t)anc_coef_idx; - } - else - { - buf[1] = (uint8_t)ANC_COEF_NUM; - } + buf[0] = (uint8_t)flag; - buf[2] = true;//set peer anc_status_sync_flag = true - - anc_peer_coef_idx = 0; - - TRACE(4,"%s anc_work_status:%d, anc_coef_idx:%d, anc_sync_status_flag:%d", __func__, buf[0], buf[1], buf[2]); - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (flag == true) { + buf[1] = (uint8_t)anc_coef_idx; + } else { + buf[1] = (uint8_t)ANC_COEF_NUM; + } - if (p_ibrt_ctrl->current_role == IBRT_MASTER) - { - tws_ctrl_send_cmd(APP_TWS_CMD_SYNC_ANC_STATUS, buf, 3); - } + buf[2] = true; // set peer anc_status_sync_flag = true + + anc_peer_coef_idx = 0; + + TRACE(4, "%s anc_work_status:%d, anc_coef_idx:%d, anc_sync_status_flag:%d", + __func__, buf[0], buf[1], buf[2]); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + + if (p_ibrt_ctrl->current_role == IBRT_MASTER) { + tws_ctrl_send_cmd(APP_TWS_CMD_SYNC_ANC_STATUS, buf, 3); + } } #endif - diff --git a/apps/anc/src/peak_detector.c b/apps/anc/src/peak_detector.c index f40766a..6c925d1 100644 --- a/apps/anc/src/peak_detector.c +++ b/apps/anc/src/peak_detector.c @@ -13,8 +13,8 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "math.h" #include "peak_detector.h" +#include "math.h" // #define PKD_FACTOR_UP (0.6) // #define PKD_FACTOR_DOWN (2.0) @@ -27,93 +27,93 @@ static float pkd_factor1 = 0.0f; static float pkd_factor2 = 0.0f; static float pkd_reduce_rate = 1.0f; -#define FABS(x) ( (x) >= 0.f ? (x) : -(x) ) -#define Max(a,b) ((a)>(b) ? (a):(b)) +#define FABS(x) ((x) >= 0.f ? (x) : -(x)) +#define Max(a, b) ((a) > (b) ? (a) : (b)) // Depend on codec_dac_vol -// const float pkd_vol_multiple[18] = {0.089125, 0.0, 0.005623, 0.007943, 0.011220, 0.015849, 0.022387, 0.031623, 0.044668, 0.063096, 0.089125, 0.125893, 0.177828, 0.251189, 0.354813, 0.501187, 0.707946, 1.000000}; +// const float pkd_vol_multiple[18] = {0.089125, 0.0, 0.005623, 0.007943, +// 0.011220, 0.015849, 0.022387, 0.031623, 0.044668, 0.063096, 0.089125, +// 0.125893, 0.177828, 0.251189, 0.354813, 0.501187, 0.707946, 1.000000}; // static uint32_t test_num = 0; // int app_bt_stream_local_volume_get(void); // y = 20log(x) -static inline float convert_multiple_to_db(float multiple) -{ - return 20*(float)log10(multiple); +static inline float convert_multiple_to_db(float multiple) { + return 20 * (float)log10(multiple); } // x = 10^(y/20) -static inline float convert_db_to_multiple(float db) -{ - return (float)pow(10, db/20); +static inline float convert_db_to_multiple(float db) { + return (float)pow(10, db / 20); } -void peak_detector_init(void) -{ - pkd_alphaR = 0.0f; - pkd_alphaA = 0.0f; - pkd_factor1 = 0.0f; - pkd_factor2 = 0.0f; - pkd_reduce_rate = 1.0f; - // TRACE(3,"[%s] pkd_alphaR = %f, pkd_alphaA = %f", __func__, (double)pkd_alphaR, (double)pkd_alphaA); +void peak_detector_init(void) { + pkd_alphaR = 0.0f; + pkd_alphaA = 0.0f; + pkd_factor1 = 0.0f; + pkd_factor2 = 0.0f; + pkd_reduce_rate = 1.0f; + // TRACE(3,"[%s] pkd_alphaR = %f, pkd_alphaA = %f", __func__, + // (double)pkd_alphaR, (double)pkd_alphaA); } -void peak_detector_setup(PEAK_DETECTOR_CFG_T *cfg) -{ - pkd_samp_bits = cfg->bits; - pkd_alphaR = (float)exp(-1/(cfg->factor_down * cfg->fs)); - pkd_alphaA = (float)exp(-1/(cfg->factor_up * cfg->fs)); - pkd_reduce_rate = convert_db_to_multiple(cfg->reduce_dB); +void peak_detector_setup(PEAK_DETECTOR_CFG_T *cfg) { + pkd_samp_bits = cfg->bits; + pkd_alphaR = (float)exp(-1 / (cfg->factor_down * cfg->fs)); + pkd_alphaA = (float)exp(-1 / (cfg->factor_up * cfg->fs)); + pkd_reduce_rate = convert_db_to_multiple(cfg->reduce_dB); } -static void peak_detector_run_16bits(int16_t *buf, uint32_t len, float vol_multiple) -{ - float normal_rate = 1.0; - float tgt_rate = 1.0; +static void peak_detector_run_16bits(int16_t *buf, uint32_t len, + float vol_multiple) { + float normal_rate = 1.0; + float tgt_rate = 1.0; - for(uint32_t i = 0; i < len; i++) - { - pkd_factor1 = Max(buf[i], pkd_alphaR * pkd_factor1); - pkd_factor2 = pkd_alphaA * pkd_factor2 + (1 - pkd_alphaA) * pkd_factor1; + for (uint32_t i = 0; i < len; i++) { + pkd_factor1 = Max(buf[i], pkd_alphaR * pkd_factor1); + pkd_factor2 = pkd_alphaA * pkd_factor2 + (1 - pkd_alphaA) * pkd_factor1; - normal_rate = pkd_factor2/32768; + normal_rate = pkd_factor2 / 32768; - tgt_rate = pkd_reduce_rate / normal_rate / vol_multiple; + tgt_rate = pkd_reduce_rate / normal_rate / vol_multiple; - if(tgt_rate > 1.0) - { - tgt_rate = 1.0; - } - - // rate += (tgt_rate - rate) / 10000.0; - - // if(pkd_factor2>) - // { - // normal_rate = 0.25; - // } - // else - // { - // normal_rate = 0.25; - // } - // normal_rate *= 1.0 - pkd_factor2/32768; - - buf[i] = (int16_t)(buf[i] * tgt_rate); - // buf[i] = 0; - // - // TRACE(2,"%d, %d", buf[i], pkd_factor2); + if (tgt_rate > 1.0) { + tgt_rate = 1.0; } - // if(test_num == 500) + // rate += (tgt_rate - rate) / 10000.0; + + // if(pkd_factor2>) // { - // test_num = 0; - // TRACE(0,"START>>>"); - // TRACE(2,"vol_level = %d, pkd_vol_multiple = %f", vol_level, pkd_vol_multiple[vol_level]); - // TRACE(3,"buf = %d, pkd_alphaR = %f, pkd_alphaA = %f", buf[len-1], pkd_alphaR, pkd_alphaA); - // TRACE(4,"pkd_factor1 = %f, pkd_factor2 = %f, normal_rate = %f, tgt_rate = %f", pkd_factor1, pkd_factor2, normal_rate, tgt_rate); - // TRACE(0,"END<<<"); - // // TRACE(7,"[%s] buf = %d, pkd_alphaR = %f, pkd_alphaA = %f, pkd_factor1 = %f, pkd_factor2 = %f, normal_rate = %f", __func__, buf[len-1], pkd_alphaR, pkd_alphaA, pkd_factor1, pkd_factor2, (1.0 - pkd_factor2/32768)); + // normal_rate = 0.25; // } + // else + // { + // normal_rate = 0.25; + // } + // normal_rate *= 1.0 - pkd_factor2/32768; + + buf[i] = (int16_t)(buf[i] * tgt_rate); + // buf[i] = 0; + // + // TRACE(2,"%d, %d", buf[i], pkd_factor2); + } + + // if(test_num == 500) + // { + // test_num = 0; + // TRACE(0,"START>>>"); + // TRACE(2,"vol_level = %d, pkd_vol_multiple = %f", vol_level, + // pkd_vol_multiple[vol_level]); TRACE(3,"buf = %d, pkd_alphaR = %f, + // pkd_alphaA = %f", buf[len-1], pkd_alphaR, pkd_alphaA); + // TRACE(4,"pkd_factor1 = %f, pkd_factor2 = %f, normal_rate = %f, tgt_rate = + // %f", pkd_factor1, pkd_factor2, normal_rate, tgt_rate); TRACE(0,"END<<<"); + // // TRACE(7,"[%s] buf = %d, pkd_alphaR = %f, pkd_alphaA = %f, pkd_factor1 = + // %f, pkd_factor2 = %f, normal_rate = %f", __func__, buf[len-1], pkd_alphaR, + // pkd_alphaA, pkd_factor1, pkd_factor2, (1.0 - pkd_factor2/32768)); + // } #if 0 short sample; @@ -139,58 +139,54 @@ static void peak_detector_run_16bits(int16_t *buf, uint32_t len, float vol_multi #endif } -static void peak_detector_run_24bits(int32_t *buf, uint32_t len, float vol_multiple) -{ - float normal_rate = 1.0; - float tgt_rate = 1.0; +static void peak_detector_run_24bits(int32_t *buf, uint32_t len, + float vol_multiple) { + float normal_rate = 1.0; + float tgt_rate = 1.0; - for(uint32_t i = 0; i < len; i++) - { - pkd_factor1 = Max(buf[i], pkd_alphaR * pkd_factor1); - pkd_factor2 = pkd_alphaA * pkd_factor2 + (1 - pkd_alphaA) * pkd_factor1; + for (uint32_t i = 0; i < len; i++) { + pkd_factor1 = Max(buf[i], pkd_alphaR * pkd_factor1); + pkd_factor2 = pkd_alphaA * pkd_factor2 + (1 - pkd_alphaA) * pkd_factor1; - normal_rate = pkd_factor2/32768; + normal_rate = pkd_factor2 / 32768; - tgt_rate = pkd_reduce_rate / normal_rate / vol_multiple; + tgt_rate = pkd_reduce_rate / normal_rate / vol_multiple; - if(tgt_rate > 1.0) - { - tgt_rate = 1.0; - } - - // rate += (tgt_rate - rate) / 10000.0; - - // if(pkd_factor2>) - // { - // normal_rate = 0.25; - // } - // else - // { - // normal_rate = 0.25; - // } - // normal_rate *= 1.0 - pkd_factor2/32768; - - buf[i] = (int32_t)(buf[i] * tgt_rate); - // buf[i] = 0; - // - // TRACE(2,"%d, %d", buf[i], pkd_factor2); - } -} - -void peak_detector_run(uint8_t *buf, uint32_t len, float vol_multiple) -{ - // int vol_level = 0; - - if (pkd_samp_bits <= AUD_BITS_16) { - len = len / sizeof(int16_t); - peak_detector_run_16bits((int16_t *)buf, len, vol_multiple); - } else { - len = len / sizeof(int32_t); - peak_detector_run_24bits((int32_t *)buf, len, vol_multiple); + if (tgt_rate > 1.0) { + tgt_rate = 1.0; } - // test_num++; + // rate += (tgt_rate - rate) / 10000.0; - // vol_level = app_bt_stream_local_volume_get(); + // if(pkd_factor2>) + // { + // normal_rate = 0.25; + // } + // else + // { + // normal_rate = 0.25; + // } + // normal_rate *= 1.0 - pkd_factor2/32768; + + buf[i] = (int32_t)(buf[i] * tgt_rate); + // buf[i] = 0; + // + // TRACE(2,"%d, %d", buf[i], pkd_factor2); + } } +void peak_detector_run(uint8_t *buf, uint32_t len, float vol_multiple) { + // int vol_level = 0; + + if (pkd_samp_bits <= AUD_BITS_16) { + len = len / sizeof(int16_t); + peak_detector_run_16bits((int16_t *)buf, len, vol_multiple); + } else { + len = len / sizeof(int32_t); + peak_detector_run_24bits((int32_t *)buf, len, vol_multiple); + } + + // test_num++; + + // vol_level = app_bt_stream_local_volume_get(); +} diff --git a/apps/apptester/app_audtest.cpp b/apps/apptester/app_audtest.cpp index b48b306..2ab1b3c 100644 --- a/apps/apptester/app_audtest.cpp +++ b/apps/apptester/app_audtest.cpp @@ -13,20 +13,20 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "app_thread.h" #include "cmsis_os.h" #include "hal_trace.h" -#include "app_thread.h" -#include "hal_timer.h" #include "app_audtest_pattern.h" +#include "hal_timer.h" -#include "hal_aud.h" -#include "audioflinger.h" +#include "app_utils.h" #include "audiobuffer.h" +#include "audioflinger.h" +#include "eq_export.h" +#include "hal_aud.h" #include "stdbool.h" #include -#include "eq_export.h" -#include "app_utils.h" #if defined(APP_TEST_AUDIO) && defined(ANC_APP) #include "anc_usb_app.h" @@ -35,28 +35,28 @@ //#include "dualadc_audio_app.h" #endif -#define USB_AUDIO_PLAYBACK_BUFF_SIZE (FRAME_SIZE_PLAYBACK * 4) -#define USB_AUDIO_CAPTURE_BUFF_SIZE (FRAME_SIZE_CAPTURE * 4) +#define USB_AUDIO_PLAYBACK_BUFF_SIZE (FRAME_SIZE_PLAYBACK * 4) +#define USB_AUDIO_CAPTURE_BUFF_SIZE (FRAME_SIZE_CAPTURE * 4) -#define USB_AUDIO_RECV_BUFF_SIZE (FRAME_SIZE_RECV * 8) -#define USB_AUDIO_SEND_BUFF_SIZE (FRAME_SIZE_SEND * 8) +#define USB_AUDIO_RECV_BUFF_SIZE (FRAME_SIZE_RECV * 8) +#define USB_AUDIO_SEND_BUFF_SIZE (FRAME_SIZE_SEND * 8) -#define APP_TEST_PLAYBACK_BUFF_SIZE (128 * 20) -#define APP_TEST_CAPTURE_BUFF_SIZE (128 * 20) +#define APP_TEST_PLAYBACK_BUFF_SIZE (128 * 20) +#define APP_TEST_CAPTURE_BUFF_SIZE (128 * 20) #if (USB_AUDIO_PLAYBACK_BUFF_SIZE > APP_TEST_PLAYBACK_BUFF_SIZE) -#define REAL_PLAYBACK_BUFF_SIZE USB_AUDIO_PLAYBACK_BUFF_SIZE +#define REAL_PLAYBACK_BUFF_SIZE USB_AUDIO_PLAYBACK_BUFF_SIZE #else -#define REAL_PLAYBACK_BUFF_SIZE APP_TEST_PLAYBACK_BUFF_SIZE +#define REAL_PLAYBACK_BUFF_SIZE APP_TEST_PLAYBACK_BUFF_SIZE #endif #if (USB_AUDIO_CAPTURE_BUFF_SIZE > APP_TEST_CAPTURE_BUFF_SIZE) -#define REAL_CAPTURE_BUFF_SIZE USB_AUDIO_CAPTURE_BUFF_SIZE +#define REAL_CAPTURE_BUFF_SIZE USB_AUDIO_CAPTURE_BUFF_SIZE #else -#define REAL_CAPTURE_BUFF_SIZE APP_TEST_CAPTURE_BUFF_SIZE +#define REAL_CAPTURE_BUFF_SIZE APP_TEST_CAPTURE_BUFF_SIZE #endif -#define ALIGNED4 ALIGNED(4) +#define ALIGNED4 ALIGNED(4) static uint8_t ALIGNED4 app_test_playback_buff[REAL_PLAYBACK_BUFF_SIZE]; static uint8_t ALIGNED4 app_test_capture_buff[REAL_CAPTURE_BUFF_SIZE]; @@ -66,242 +66,225 @@ static uint8_t ALIGNED4 app_test_recv_buff[USB_AUDIO_RECV_BUFF_SIZE]; static uint8_t ALIGNED4 app_test_send_buff[USB_AUDIO_SEND_BUFF_SIZE]; #endif -uint32_t pcm_1ksin_more_data(uint8_t *buf, uint32_t len) -{ - static uint32_t nextPbufIdx = 0; - uint32_t remain_size = len; - uint32_t curr_size = 0; - static uint32_t pcm_preIrqTime = 0;; - uint32_t stime = 0; +uint32_t pcm_1ksin_more_data(uint8_t *buf, uint32_t len) { + static uint32_t nextPbufIdx = 0; + uint32_t remain_size = len; + uint32_t curr_size = 0; + static uint32_t pcm_preIrqTime = 0; + ; + uint32_t stime = 0; + stime = hal_sys_timer_get(); + TRACE(3, "pcm_1ksin_more_data irqDur:%d readbuff:0x%08x %d\n ", + TICKS_TO_MS(stime - pcm_preIrqTime), buf, len); + pcm_preIrqTime = stime; - stime = hal_sys_timer_get(); - TRACE(3,"pcm_1ksin_more_data irqDur:%d readbuff:0x%08x %d\n ", TICKS_TO_MS(stime - pcm_preIrqTime), buf, len); - pcm_preIrqTime = stime; - - // TRACE(2,"[pcm_1ksin_more_data] len=%d nextBuf:%d\n", len, nextPbufIdx); - if (remain_size > sizeof(sinwave)) - { - do{ - if (nextPbufIdx) - { - curr_size = sizeof(sinwave)-nextPbufIdx; - memcpy(buf,&sinwave[nextPbufIdx/2], curr_size); - remain_size -= curr_size; - nextPbufIdx = 0; - } - else if (remain_size>sizeof(sinwave)) - { - memcpy(buf+curr_size,sinwave,sizeof(sinwave)); - curr_size += sizeof(sinwave); - remain_size -= sizeof(sinwave); - } - else - { - memcpy(buf+curr_size,sinwave,remain_size); - nextPbufIdx = remain_size; - remain_size = 0; - } - }while(remain_size); - } - else - { - if ((sizeof(sinwave) - nextPbufIdx) >= len) - { - memcpy(buf, &sinwave[nextPbufIdx/2],len); - nextPbufIdx += len; - } - else - { - curr_size = sizeof(sinwave)-nextPbufIdx; - memcpy(buf, &sinwave[nextPbufIdx/2],curr_size); - nextPbufIdx = len - curr_size; - memcpy(buf+curr_size,sinwave, nextPbufIdx); - } + // TRACE(2,"[pcm_1ksin_more_data] len=%d nextBuf:%d\n", len, nextPbufIdx); + if (remain_size > sizeof(sinwave)) { + do { + if (nextPbufIdx) { + curr_size = sizeof(sinwave) - nextPbufIdx; + memcpy(buf, &sinwave[nextPbufIdx / 2], curr_size); + remain_size -= curr_size; + nextPbufIdx = 0; + } else if (remain_size > sizeof(sinwave)) { + memcpy(buf + curr_size, sinwave, sizeof(sinwave)); + curr_size += sizeof(sinwave); + remain_size -= sizeof(sinwave); + } else { + memcpy(buf + curr_size, sinwave, remain_size); + nextPbufIdx = remain_size; + remain_size = 0; + } + } while (remain_size); + } else { + if ((sizeof(sinwave) - nextPbufIdx) >= len) { + memcpy(buf, &sinwave[nextPbufIdx / 2], len); + nextPbufIdx += len; + } else { + curr_size = sizeof(sinwave) - nextPbufIdx; + memcpy(buf, &sinwave[nextPbufIdx / 2], curr_size); + nextPbufIdx = len - curr_size; + memcpy(buf + curr_size, sinwave, nextPbufIdx); } + } - return 0; + return 0; } -uint32_t pcm_mute_more_data(uint8_t *buf, uint32_t len) -{ - memset(buf, 0 , len); - return 0; +uint32_t pcm_mute_more_data(uint8_t *buf, uint32_t len) { + memset(buf, 0, len); + return 0; } -void da_output_sin1k(bool on) -{ - static bool isRun = false; - struct AF_STREAM_CONFIG_T stream_cfg; - memset(&stream_cfg, 0, sizeof(stream_cfg)); +void da_output_sin1k(bool on) { + static bool isRun = false; + struct AF_STREAM_CONFIG_T stream_cfg; + memset(&stream_cfg, 0, sizeof(stream_cfg)); - if (isRun==on) - return; - else - isRun=on; - TRACE(2,"%s %d\n", __func__, on); + if (isRun == on) + return; + else + isRun = on; + TRACE(2, "%s %d\n", __func__, on); - if (on){ - stream_cfg.bits = AUD_BITS_16; - stream_cfg.channel_num = AUD_CHANNEL_NUM_2; - stream_cfg.sample_rate = AUD_SAMPRATE_44100; + if (on) { + stream_cfg.bits = AUD_BITS_16; + stream_cfg.channel_num = AUD_CHANNEL_NUM_2; + stream_cfg.sample_rate = AUD_SAMPRATE_44100; - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; - stream_cfg.vol = 16; + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; + stream_cfg.vol = 16; - stream_cfg.handler = pcm_1ksin_more_data; - stream_cfg.data_ptr = app_test_playback_buff; - stream_cfg.data_size = APP_TEST_PLAYBACK_BUFF_SIZE; - - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - }else{ - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - } + stream_cfg.handler = pcm_1ksin_more_data; + stream_cfg.data_ptr = app_test_playback_buff; + stream_cfg.data_size = APP_TEST_PLAYBACK_BUFF_SIZE; + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + } else { + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + } } -void da_tester(uint8_t on) -{ - da_output_sin1k(on); -} +void da_tester(uint8_t on) { da_output_sin1k(on); } extern int voicecvsd_audio_init(void); extern uint32_t voicecvsd_audio_more_data(uint8_t *buf, uint32_t len); extern int get_voicecvsd_buffer_size(void); extern int store_voice_pcm2cvsd(unsigned char *buf, unsigned int len); -static uint32_t pcm_data_capture(uint8_t *buf, uint32_t len) -{ - uint32_t stime, etime; - static uint32_t preIrqTime = 0; +static uint32_t pcm_data_capture(uint8_t *buf, uint32_t len) { + uint32_t stime, etime; + static uint32_t preIrqTime = 0; - stime = hal_sys_timer_get(); -// audio_buffer_set_stereo2mono_16bits(buf, len, 1); - audio_buffer_set(buf, len); - etime = hal_sys_timer_get(); - TRACE(4,"%s irqDur:%d fsSpend:%d, Len:%d", __func__, TICKS_TO_MS(stime - preIrqTime), TICKS_TO_MS(etime - stime), len); - preIrqTime = stime; - return 0; + stime = hal_sys_timer_get(); + // audio_buffer_set_stereo2mono_16bits(buf, len, 1); + audio_buffer_set(buf, len); + etime = hal_sys_timer_get(); + TRACE(4, "%s irqDur:%d fsSpend:%d, Len:%d", __func__, + TICKS_TO_MS(stime - preIrqTime), TICKS_TO_MS(etime - stime), len); + preIrqTime = stime; + return 0; } -static uint32_t pcm_data_playback(uint8_t *buf, uint32_t len) -{ - uint32_t stime, etime; - static uint32_t preIrqTime = 0; - stime = hal_sys_timer_get(); -// audio_buffer_get_mono2stereo_16bits(buf, len); - audio_buffer_get(buf, len); - etime = hal_sys_timer_get(); - TRACE(4,"%s irqDur:%d fsSpend:%d, Len:%d", __func__, TICKS_TO_MS(stime - preIrqTime), TICKS_TO_MS(etime - stime), len); - preIrqTime = stime; - return 0; +static uint32_t pcm_data_playback(uint8_t *buf, uint32_t len) { + uint32_t stime, etime; + static uint32_t preIrqTime = 0; + stime = hal_sys_timer_get(); + // audio_buffer_get_mono2stereo_16bits(buf, len); + audio_buffer_get(buf, len); + etime = hal_sys_timer_get(); + TRACE(4, "%s irqDur:%d fsSpend:%d, Len:%d", __func__, + TICKS_TO_MS(stime - preIrqTime), TICKS_TO_MS(etime - stime), len); + preIrqTime = stime; + return 0; } -uint32_t pcm_cvsd_data_capture(uint8_t *buf, uint32_t len) -{ - uint32_t stime, etime; - static uint32_t preIrqTime = 0; +uint32_t pcm_cvsd_data_capture(uint8_t *buf, uint32_t len) { + uint32_t stime, etime; + static uint32_t preIrqTime = 0; - //TRACE(1,"%s enter", __func__); - stime = hal_sys_timer_get(); - len >>= 1; - audio_stereo2mono_16bits(0, (uint16_t *)buf, (uint16_t *)buf, len); - store_voice_pcm2cvsd(buf, len); - etime = hal_sys_timer_get(); - TRACE(4,"%s exit irqDur:%d fsSpend:%d, add:%d", __func__, TICKS_TO_MS(stime - preIrqTime), TICKS_TO_MS(etime - stime), len); - preIrqTime = stime; - return 0; + // TRACE(1,"%s enter", __func__); + stime = hal_sys_timer_get(); + len >>= 1; + audio_stereo2mono_16bits(0, (uint16_t *)buf, (uint16_t *)buf, len); + store_voice_pcm2cvsd(buf, len); + etime = hal_sys_timer_get(); + TRACE(4, "%s exit irqDur:%d fsSpend:%d, add:%d", __func__, + TICKS_TO_MS(stime - preIrqTime), TICKS_TO_MS(etime - stime), len); + preIrqTime = stime; + return 0; } -uint32_t pcm_cvsd_data_playback(uint8_t *buf, uint32_t len) -{ - int n; - uint32_t stime, etime; - static uint32_t preIrqTime = 0; +uint32_t pcm_cvsd_data_playback(uint8_t *buf, uint32_t len) { + int n; + uint32_t stime, etime; + static uint32_t preIrqTime = 0; - //TRACE(1,"%s enter", __func__); - stime = hal_sys_timer_get(); - pcm_1ksin_more_data(buf, len); - voicecvsd_audio_more_data(buf, len); - n = get_voicecvsd_buffer_size(); - etime = hal_sys_timer_get(); - TRACE(5,"%s exit irqDur:%d fsSpend:%d, get:%d remain:%d", __func__, TICKS_TO_MS(stime - preIrqTime), TICKS_TO_MS(etime - stime), len, n); - preIrqTime = stime; - return 0; + // TRACE(1,"%s enter", __func__); + stime = hal_sys_timer_get(); + pcm_1ksin_more_data(buf, len); + voicecvsd_audio_more_data(buf, len); + n = get_voicecvsd_buffer_size(); + etime = hal_sys_timer_get(); + TRACE(5, "%s exit irqDur:%d fsSpend:%d, get:%d remain:%d", __func__, + TICKS_TO_MS(stime - preIrqTime), TICKS_TO_MS(etime - stime), len, n); + preIrqTime = stime; + return 0; } -void adc_looptester(bool on, enum AUD_IO_PATH_T input_path, enum AUD_SAMPRATE_T sample_rate) -{ - struct AF_STREAM_CONFIG_T stream_cfg; +void adc_looptester(bool on, enum AUD_IO_PATH_T input_path, + enum AUD_SAMPRATE_T sample_rate) { + struct AF_STREAM_CONFIG_T stream_cfg; - static bool isRun = false; + static bool isRun = false; - if (isRun==on) - return; - else - isRun=on; + if (isRun == on) + return; + else + isRun = on; - if (on){ - audio_buffer_init(); - memset(&stream_cfg, 0, sizeof(stream_cfg)); + if (on) { + audio_buffer_init(); + memset(&stream_cfg, 0, sizeof(stream_cfg)); - stream_cfg.bits = AUD_BITS_16; - stream_cfg.channel_num = AUD_CHANNEL_NUM_2; - stream_cfg.sample_rate = sample_rate; + stream_cfg.bits = AUD_BITS_16; + stream_cfg.channel_num = AUD_CHANNEL_NUM_2; + stream_cfg.sample_rate = sample_rate; - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; - stream_cfg.io_path = input_path; - stream_cfg.vol = 0x03; + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; + stream_cfg.io_path = input_path; + stream_cfg.vol = 0x03; - stream_cfg.handler = pcm_data_capture; + stream_cfg.handler = pcm_data_capture; - stream_cfg.data_ptr = app_test_capture_buff; - stream_cfg.data_size = APP_TEST_CAPTURE_BUFF_SIZE; - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); + stream_cfg.data_ptr = app_test_capture_buff; + stream_cfg.data_size = APP_TEST_CAPTURE_BUFF_SIZE; + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); - stream_cfg.handler = pcm_data_playback; - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; + stream_cfg.handler = pcm_data_playback; + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; - stream_cfg.data_ptr = app_test_playback_buff; - stream_cfg.data_size = APP_TEST_PLAYBACK_BUFF_SIZE; - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); + stream_cfg.data_ptr = app_test_playback_buff; + stream_cfg.data_size = APP_TEST_PLAYBACK_BUFF_SIZE; + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - }else{ - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - } + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + } else { + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + } } #if defined(APP_TEST_AUDIO) && defined(ANC_APP) -void app_anc_usb_init(void) -{ - app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_52M); +void app_anc_usb_init(void) { + app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_52M); - anc_usb_app_init(AUD_INPUT_PATH_MAINMIC, AUD_SAMPRATE_96000, AUD_SAMPRATE_192000); + anc_usb_app_init(AUD_INPUT_PATH_MAINMIC, AUD_SAMPRATE_96000, + AUD_SAMPRATE_192000); - struct USB_AUDIO_BUF_CFG cfg; + struct USB_AUDIO_BUF_CFG cfg; - memset(&cfg, 0, sizeof(cfg)); - cfg.play_buf = app_test_playback_buff; - cfg.play_size = USB_AUDIO_PLAYBACK_BUFF_SIZE; - cfg.cap_buf = app_test_capture_buff; - cfg.cap_size = USB_AUDIO_CAPTURE_BUFF_SIZE; - cfg.recv_buf = app_test_recv_buff; - cfg.recv_size = USB_AUDIO_RECV_BUFF_SIZE; - cfg.send_buf = app_test_send_buff; - cfg.send_size = USB_AUDIO_SEND_BUFF_SIZE; + memset(&cfg, 0, sizeof(cfg)); + cfg.play_buf = app_test_playback_buff; + cfg.play_size = USB_AUDIO_PLAYBACK_BUFF_SIZE; + cfg.cap_buf = app_test_capture_buff; + cfg.cap_size = USB_AUDIO_CAPTURE_BUFF_SIZE; + cfg.recv_buf = app_test_recv_buff; + cfg.recv_size = USB_AUDIO_RECV_BUFF_SIZE; + cfg.send_buf = app_test_send_buff; + cfg.send_size = USB_AUDIO_SEND_BUFF_SIZE; - usb_audio_app_init(&cfg); + usb_audio_app_init(&cfg); - //dualadc_audio_app_init(app_test_playback_buff, USB_AUDIO_PLAYBACK_BUFF_SIZE, - //app_test_capture_buff, USB_AUDIO_CAPTURE_BUFF_SIZE); + // dualadc_audio_app_init(app_test_playback_buff, + // USB_AUDIO_PLAYBACK_BUFF_SIZE, app_test_capture_buff, + // USB_AUDIO_CAPTURE_BUFF_SIZE); } #endif - diff --git a/apps/apptester/audiobuffer.c b/apps/apptester/audiobuffer.c index b7c9925..47b779c 100644 --- a/apps/apptester/audiobuffer.c +++ b/apps/apptester/audiobuffer.c @@ -13,11 +13,10 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "audiobuffer.h" #include "cmsis_os.h" #include "cqueue.h" #include "string.h" -#include "audiobuffer.h" - #ifndef _AUDIO_NO_THREAD_ static osMutexId g_audio_queue_mutex_id = NULL; @@ -25,122 +24,121 @@ osMutexDef(g_audio_queue_mutex); #endif static CQueue audio_queue; -static unsigned char audio_queue_buf[AUDIO_BUFFER_FRAME_SIZE*AUDIO_BUFFER_FRAME_NUM]; +static unsigned char + audio_queue_buf[AUDIO_BUFFER_FRAME_SIZE * AUDIO_BUFFER_FRAME_NUM]; -void audio_mono2stereo_16bits(uint16_t *dst_buf, uint16_t *src_buf, uint32_t src_len) -{ - uint32_t i = 0; - for (i = 0; i < src_len; ++i) { - dst_buf[i*2 + 0] = dst_buf[i*2 + 1] = src_buf[i]; - } +void audio_mono2stereo_16bits(uint16_t *dst_buf, uint16_t *src_buf, + uint32_t src_len) { + uint32_t i = 0; + for (i = 0; i < src_len; ++i) { + dst_buf[i * 2 + 0] = dst_buf[i * 2 + 1] = src_buf[i]; + } } -void audio_stereo2mono_16bits(uint8_t chnlsel, uint16_t *dst_buf, uint16_t *src_buf, uint32_t src_len) -{ - uint32_t i = 0; - for (i = 0; i < src_len; i+=2) { - dst_buf[i/2] = src_buf[i + chnlsel]; - } +void audio_stereo2mono_16bits(uint8_t chnlsel, uint16_t *dst_buf, + uint16_t *src_buf, uint32_t src_len) { + uint32_t i = 0; + for (i = 0; i < src_len; i += 2) { + dst_buf[i / 2] = src_buf[i + chnlsel]; + } } -void audio_buffer_init(void) -{ +void audio_buffer_init(void) { #ifndef _AUDIO_NO_THREAD_ - if (g_audio_queue_mutex_id == NULL) - g_audio_queue_mutex_id = osMutexCreate((osMutex(g_audio_queue_mutex))); + if (g_audio_queue_mutex_id == NULL) + g_audio_queue_mutex_id = osMutexCreate((osMutex(g_audio_queue_mutex))); #endif - InitCQueue(&audio_queue, sizeof(audio_queue_buf), (unsigned char *)&audio_queue_buf); - memset(&audio_queue_buf, 0x00, sizeof(audio_queue_buf)); + InitCQueue(&audio_queue, sizeof(audio_queue_buf), + (unsigned char *)&audio_queue_buf); + memset(&audio_queue_buf, 0x00, sizeof(audio_queue_buf)); } -int audio_buffer_length(void) -{ - int len; +int audio_buffer_length(void) { + int len; #ifndef _AUDIO_NO_THREAD_ - osMutexWait(g_audio_queue_mutex_id, osWaitForever); + osMutexWait(g_audio_queue_mutex_id, osWaitForever); #endif - len = LengthOfCQueue(&audio_queue); + len = LengthOfCQueue(&audio_queue); #ifndef _AUDIO_NO_THREAD_ - osMutexRelease(g_audio_queue_mutex_id); + osMutexRelease(g_audio_queue_mutex_id); #endif - return len; + return len; } -int audio_buffer_set(uint8_t *buff, uint16_t len) -{ - int status; +int audio_buffer_set(uint8_t *buff, uint16_t len) { + int status; #ifndef _AUDIO_NO_THREAD_ - osMutexWait(g_audio_queue_mutex_id, osWaitForever); + osMutexWait(g_audio_queue_mutex_id, osWaitForever); #endif - status = EnCQueue(&audio_queue, buff, len); + status = EnCQueue(&audio_queue, buff, len); #ifndef _AUDIO_NO_THREAD_ - osMutexRelease(g_audio_queue_mutex_id); + osMutexRelease(g_audio_queue_mutex_id); #endif - return status; + return status; } -int audio_buffer_get(uint8_t *buff, uint16_t len) -{ - uint8_t *e1 = NULL, *e2 = NULL; - unsigned int len1 = 0, len2 = 0; - int status; +int audio_buffer_get(uint8_t *buff, uint16_t len) { + uint8_t *e1 = NULL, *e2 = NULL; + unsigned int len1 = 0, len2 = 0; + int status; #ifndef _AUDIO_NO_THREAD_ - osMutexWait(g_audio_queue_mutex_id, osWaitForever); + osMutexWait(g_audio_queue_mutex_id, osWaitForever); #endif - status = PeekCQueue(&audio_queue, len, &e1, &len1, &e2, &len2); - if (len==(len1+len2)){ - memcpy(buff,e1,len1); - memcpy(buff+len1,e2,len2); - DeCQueue(&audio_queue, 0, len); - DeCQueue(&audio_queue, 0, len2); - }else{ - memset(buff, 0x00, len); - status = -1; - } + status = PeekCQueue(&audio_queue, len, &e1, &len1, &e2, &len2); + if (len == (len1 + len2)) { + memcpy(buff, e1, len1); + memcpy(buff + len1, e2, len2); + DeCQueue(&audio_queue, 0, len); + DeCQueue(&audio_queue, 0, len2); + } else { + memset(buff, 0x00, len); + status = -1; + } #ifndef _AUDIO_NO_THREAD_ - osMutexRelease(g_audio_queue_mutex_id); + osMutexRelease(g_audio_queue_mutex_id); #endif - return status; + return status; } -int audio_buffer_set_stereo2mono_16bits(uint8_t *buff, uint16_t len, uint8_t chnlsel) -{ - int status; +int audio_buffer_set_stereo2mono_16bits(uint8_t *buff, uint16_t len, + uint8_t chnlsel) { + int status; #ifndef _AUDIO_NO_THREAD_ - osMutexWait(g_audio_queue_mutex_id, osWaitForever); + osMutexWait(g_audio_queue_mutex_id, osWaitForever); #endif - audio_stereo2mono_16bits(chnlsel, (uint16_t *)buff, (uint16_t *)buff, len>>1); - status = EnCQueue(&audio_queue, buff, len>>1); + audio_stereo2mono_16bits(chnlsel, (uint16_t *)buff, (uint16_t *)buff, + len >> 1); + status = EnCQueue(&audio_queue, buff, len >> 1); #ifndef _AUDIO_NO_THREAD_ - osMutexRelease(g_audio_queue_mutex_id); + osMutexRelease(g_audio_queue_mutex_id); #endif - return status; + return status; } -int audio_buffer_get_mono2stereo_16bits(uint8_t *buff, uint16_t len) -{ - uint8_t *e1 = NULL, *e2 = NULL; - unsigned int len1 = 0, len2 = 0; - int status; +int audio_buffer_get_mono2stereo_16bits(uint8_t *buff, uint16_t len) { + uint8_t *e1 = NULL, *e2 = NULL; + unsigned int len1 = 0, len2 = 0; + int status; #ifndef _AUDIO_NO_THREAD_ - osMutexWait(g_audio_queue_mutex_id, osWaitForever); + osMutexWait(g_audio_queue_mutex_id, osWaitForever); #endif - status = PeekCQueue(&audio_queue, len>>1, &e1, &len1, &e2, &len2); - if (len>>1== len1+len2){ - audio_mono2stereo_16bits((uint16_t *)buff, (uint16_t *)e1, len1>>1); - audio_mono2stereo_16bits((uint16_t *)(buff+(len1<<1)), (uint16_t *)e2, len2>>1); - DeCQueue(&audio_queue, 0, len1); - DeCQueue(&audio_queue, 0, len2); - status = len; - }else{ - memset(buff, 0x00, len); - status = -1; - } + status = PeekCQueue(&audio_queue, len >> 1, &e1, &len1, &e2, &len2); + if (len >> 1 == len1 + len2) { + audio_mono2stereo_16bits((uint16_t *)buff, (uint16_t *)e1, len1 >> 1); + audio_mono2stereo_16bits((uint16_t *)(buff + (len1 << 1)), (uint16_t *)e2, + len2 >> 1); + DeCQueue(&audio_queue, 0, len1); + DeCQueue(&audio_queue, 0, len2); + status = len; + } else { + memset(buff, 0x00, len); + status = -1; + } #ifndef _AUDIO_NO_THREAD_ - osMutexRelease(g_audio_queue_mutex_id); + osMutexRelease(g_audio_queue_mutex_id); #endif - return status; + return status; } diff --git a/apps/audioplayers/a2dp_decoder/a2dp_decoder.cpp b/apps/audioplayers/a2dp_decoder/a2dp_decoder.cpp index 982d504..f1e246c 100644 --- a/apps/audioplayers/a2dp_decoder/a2dp_decoder.cpp +++ b/apps/audioplayers/a2dp_decoder/a2dp_decoder.cpp @@ -14,62 +14,62 @@ * ****************************************************************************/ // Standard C Included Files -#include "cmsis.h" -#include "cmsis_os.h" -#include "plat_types.h" -#include -#include "heap_api.h" -#include "hal_location.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "app_bt_media_manager.h" -#include "app_bt.h" -#include "bt_drv_reg_op.h" -#include "app_audio.h" -#include "codec_sbc.h" -#include "avdtp_api.h" #include "a2dp_decoder.h" #include "a2dp_decoder_internal.h" +#include "app_audio.h" +#include "app_bt.h" +#include "app_bt_media_manager.h" +#include "audioflinger.h" +#include "avdtp_api.h" +#include "bt_drv_reg_op.h" +#include "cmsis.h" +#include "cmsis_os.h" +#include "codec_sbc.h" +#include "hal_location.h" +#include "hal_timer.h" +#include "heap_api.h" +#include "plat_types.h" +#include #if defined(IBRT) -#include "btapp.h" -#include "bt_drv_interface.h" #include "app_ibrt_if.h" #include "app_tws_ctrl_thread.h" -#include "app_tws_ibrt_cmd_handler.h" #include "app_tws_ibrt_audio_analysis.h" #include "app_tws_ibrt_audio_sync.h" +#include "app_tws_ibrt_cmd_handler.h" +#include "bt_drv_interface.h" +#include "btapp.h" #endif -#include "crc32.h" #include "audio_prompt_sbc.h" +#include "crc32.h" #ifndef A2DP_AUDIO_MEMPOOL_SIZE #if defined(A2DP_LDAC_ON) -#define A2DP_AUDIO_LDAC_MEMPOOL_SIZE (76*1024) +#define A2DP_AUDIO_LDAC_MEMPOOL_SIZE (76 * 1024) #endif -#define A2DP_AUDIO_MEMPOOL_SIZE (72*1024) +#define A2DP_AUDIO_MEMPOOL_SIZE (72 * 1024) #endif -#define A2DP_AUDIO_WAIT_TIMEOUT_MS (500) -#define A2DP_AUDIO_MUTE_FRAME_CNT_AFTER_NO_CACHE (25) -#define A2DP_AUDIO_SKIP_FRAME_LIMIT_AFTER_NO_CACHE (50) +#define A2DP_AUDIO_WAIT_TIMEOUT_MS (500) +#define A2DP_AUDIO_MUTE_FRAME_CNT_AFTER_NO_CACHE (25) +#define A2DP_AUDIO_SKIP_FRAME_LIMIT_AFTER_NO_CACHE (50) -#define A2DP_AUDIO_REFILL_AFTER_NO_CACHE (1) +#define A2DP_AUDIO_REFILL_AFTER_NO_CACHE (1) #ifdef __A2DP_AUDIO_SYNC_FIX_DIFF_NOPID__ -#define A2DP_AUDIO_SYNC_INTERVAL (25) +#define A2DP_AUDIO_SYNC_INTERVAL (25) #else -#define A2DP_AUDIO_SYNC_INTERVAL (1000) +#define A2DP_AUDIO_SYNC_INTERVAL (1000) #endif -#define A2DP_AUDIO_LATENCY_LOW_FACTOR (1.0f) -#define A2DP_AUDIO_LATENCY_HIGH_FACTOR (1.6f) -#define A2DP_AUDIO_LATENCY_MORE_FACTOR (1.2f) +#define A2DP_AUDIO_LATENCY_LOW_FACTOR (1.0f) +#define A2DP_AUDIO_LATENCY_HIGH_FACTOR (1.6f) +#define A2DP_AUDIO_LATENCY_MORE_FACTOR (1.2f) -#define A2DP_AUDIO_SYNC_FACTOR_REFERENCE (1.0f) -#define A2DP_AUDIO_SYNC_FACTOR_FAST_LIMIT ( 0.00015f) -#define A2DP_AUDIO_SYNC_FACTOR_SLOW_LIMIT (-0.00035f) -#define A2DP_AUDIO_SYNC_FACTOR_NEED_FAST_CACHE (-0.001f) +#define A2DP_AUDIO_SYNC_FACTOR_REFERENCE (1.0f) +#define A2DP_AUDIO_SYNC_FACTOR_FAST_LIMIT (0.00015f) +#define A2DP_AUDIO_SYNC_FACTOR_SLOW_LIMIT (-0.00035f) +#define A2DP_AUDIO_SYNC_FACTOR_NEED_FAST_CACHE (-0.001f) -#define A2DP_AUDIO_UNDERFLOW_CAUSE_AUDIO_RETRIGGER (1) +#define A2DP_AUDIO_UNDERFLOW_CAUSE_AUDIO_RETRIGGER (1) extern A2DP_AUDIO_DECODER_T a2dp_audio_sbc_decoder_config; #if defined(A2DP_AAC_ON) @@ -83,7 +83,6 @@ extern A2DP_AUDIO_DECODER_T a2dp_audio_lhdc_decoder_config; extern A2DP_AUDIO_DECODER_T a2dp_audio_ldac_decoder_config; #endif - #if defined(A2DP_SCALABLE_ON) extern A2DP_AUDIO_DECODER_T a2dp_audio_scalable_decoder_config; #endif @@ -96,9 +95,9 @@ osMutexDef(audio_stop_mutex); #ifdef __A2DP_AUDIO_SYNC_FIX_DIFF_NOPID__ //#define A2DP_AUDIO_SYNC_FIX_DIFF_INTERVA_PRINT_FLOAT (1) -#define A2DP_AUDIO_SYNC_FIX_DIFF_INTERVAL (640) -#define A2DP_AUDIO_SYNC_FIX_DIFF_FAST_LIMIT ( 0.003f) -#define A2DP_AUDIO_SYNC_FIX_DIFF_SLOW_LIMIT (-0.003f) +#define A2DP_AUDIO_SYNC_FIX_DIFF_INTERVAL (640) +#define A2DP_AUDIO_SYNC_FIX_DIFF_FAST_LIMIT (0.003f) +#define A2DP_AUDIO_SYNC_FIX_DIFF_SLOW_LIMIT (-0.003f) extern uint32_t app_bt_stream_get_dma_buffer_samples(void); static int a2dp_audio_sync_fix_diff_proc(uint32_t tick); @@ -106,16 +105,16 @@ static int a2dp_audio_sync_fix_diff_stop(uint32_t tick); static int32_t a2dp_audio_sync_fix_diff_reset(void); static int32_t a2dp_audio_sync_fix_diff_start(uint32_t tick); -typedef enum{ - A2DP_AUDIO_SYNC_FIX_DIFF_STATUS_IDLE, - A2DP_AUDIO_SYNC_FIX_DIFF_STATUS_START, - A2DP_AUDIO_SYNC_FIX_DIFF_STATUS_STOP, -}A2DP_AUDIO_SYNC_FIX_DIFF_STATUS; +typedef enum { + A2DP_AUDIO_SYNC_FIX_DIFF_STATUS_IDLE, + A2DP_AUDIO_SYNC_FIX_DIFF_STATUS_START, + A2DP_AUDIO_SYNC_FIX_DIFF_STATUS_STOP, +} A2DP_AUDIO_SYNC_FIX_DIFF_STATUS; typedef struct { - int32_t tick; - A2DP_AUDIO_SYNC_FIX_DIFF_STATUS status; -}A2DP_AUDIO_SYNC_FIX_DIFF_T; + int32_t tick; + A2DP_AUDIO_SYNC_FIX_DIFF_STATUS status; +} A2DP_AUDIO_SYNC_FIX_DIFF_T; static A2DP_AUDIO_SYNC_FIX_DIFF_T a2dp_audio_sync_fix_diff; #endif @@ -126,8 +125,10 @@ static heap_handle_t a2dp_audio_heap; static A2DP_AUDIO_LASTFRAME_INFO_T a2dp_audio_lastframe_info; -static A2DP_AUDIO_DETECT_NEXT_PACKET_CALLBACK a2dp_audio_detect_next_packet_callback = NULL; -static A2DP_AUDIO_DETECT_NEXT_PACKET_CALLBACK a2dp_audio_store_packet_callback = NULL; +static A2DP_AUDIO_DETECT_NEXT_PACKET_CALLBACK + a2dp_audio_detect_next_packet_callback = NULL; +static A2DP_AUDIO_DETECT_NEXT_PACKET_CALLBACK a2dp_audio_store_packet_callback = + NULL; static float a2dp_audio_latency_factor = A2DP_AUDIO_LATENCY_LOW_FACTOR; static float sync_tune_dest_ratio = 1.0f; @@ -136,890 +137,897 @@ static uint32_t store_packet_history_loctime = 0; static uint32_t check_sum_seed = 0; -static int a2dp_audio_internal_lastframe_info_ptr_get(A2DP_AUDIO_LASTFRAME_INFO_T **lastframe_info); +static int a2dp_audio_internal_lastframe_info_ptr_get( + A2DP_AUDIO_LASTFRAME_INFO_T **lastframe_info); float a2dp_audio_get_sample_reference(void); int8_t a2dp_audio_get_current_buf_size(void); -void a2dp_audio_heap_init(void *begin_addr, uint32_t size) -{ - a2dp_audio_heap = heap_register(begin_addr,size); +void a2dp_audio_heap_init(void *begin_addr, uint32_t size) { + a2dp_audio_heap = heap_register(begin_addr, size); } -void *a2dp_audio_heap_malloc(uint32_t size) -{ - void *ptr = heap_malloc(a2dp_audio_heap,size); - ASSERT_A2DP_DECODER(ptr, "%s size:%d", __func__, size); - return ptr; +void *a2dp_audio_heap_malloc(uint32_t size) { + void *ptr = heap_malloc(a2dp_audio_heap, size); + ASSERT_A2DP_DECODER(ptr, "%s size:%d", __func__, size); + return ptr; } -void *a2dp_audio_heap_cmalloc(uint32_t size) -{ - void *ptr = heap_malloc(a2dp_audio_heap,size); - ASSERT_A2DP_DECODER(ptr, "%s size:%d", __func__, size); - memset(ptr, 0, size); - return ptr; +void *a2dp_audio_heap_cmalloc(uint32_t size) { + void *ptr = heap_malloc(a2dp_audio_heap, size); + ASSERT_A2DP_DECODER(ptr, "%s size:%d", __func__, size); + memset(ptr, 0, size); + return ptr; } -void *a2dp_audio_heap_realloc(void *rmem, uint32_t newsize) -{ - void *ptr = heap_realloc(a2dp_audio_heap, rmem, newsize); - ASSERT_A2DP_DECODER(ptr, "%s rmem:%p size:%d", __func__, rmem,newsize); - return ptr; +void *a2dp_audio_heap_realloc(void *rmem, uint32_t newsize) { + void *ptr = heap_realloc(a2dp_audio_heap, rmem, newsize); + ASSERT_A2DP_DECODER(ptr, "%s rmem:%p size:%d", __func__, rmem, newsize); + return ptr; } -void a2dp_audio_heap_free(void *rmem) -{ - ASSERT_A2DP_DECODER(rmem, "%s rmem:%p", __func__, rmem); - heap_free(a2dp_audio_heap,rmem); +void a2dp_audio_heap_free(void *rmem) { + ASSERT_A2DP_DECODER(rmem, "%s rmem:%p", __func__, rmem); + heap_free(a2dp_audio_heap, rmem); } -void a2dp_audio_heap_info(size_t *total, size_t *used, size_t *max_used) -{ - multi_heap_info_t info; - heap_get_info(a2dp_audio_heap, &info); +void a2dp_audio_heap_info(size_t *total, size_t *used, size_t *max_used) { + multi_heap_info_t info; + heap_get_info(a2dp_audio_heap, &info); - if (total != NULL) - *total = info.total_bytes; + if (total != NULL) + *total = info.total_bytes; - if (used != NULL) - *used = info.total_allocated_bytes; + if (used != NULL) + *used = info.total_allocated_bytes; - if (max_used != NULL) - *max_used = info.total_bytes - info.minimum_free_bytes; + if (max_used != NULL) + *max_used = info.total_bytes - info.minimum_free_bytes; } +int inline a2dp_audio_semaphore_init(void) { + if (a2dp_audio_context.audio_semaphore.semaphore == NULL) { + a2dp_audio_context.audio_semaphore.semaphore = + osSemaphoreCreate(osSemaphore(audio_buffer_semaphore), 0); + } + a2dp_audio_context.audio_semaphore.enalbe = false; + return 0; +} -int inline a2dp_audio_semaphore_init(void) -{ - if (a2dp_audio_context.audio_semaphore.semaphore == NULL){ - a2dp_audio_context.audio_semaphore.semaphore = osSemaphoreCreate(osSemaphore(audio_buffer_semaphore), 0); - } +int inline a2dp_audio_buffer_mutex_init(void) { + if (a2dp_audio_context.audio_buffer_mutex == NULL) { + a2dp_audio_context.audio_buffer_mutex = + osMutexCreate((osMutex(audio_buffer_mutex))); + } + return 0; +} + +int inline a2dp_audio_buffer_mutex_lock(void) { + osMutexWait((osMutexId)a2dp_audio_context.audio_buffer_mutex, osWaitForever); + return 0; +} + +int inline a2dp_audio_buffer_mutex_unlock(void) { + osMutexRelease((osMutexId)a2dp_audio_context.audio_buffer_mutex); + return 0; +} + +int inline a2dp_audio_status_mutex_init(void) { + if (a2dp_audio_context.audio_status_mutex == NULL) { + a2dp_audio_context.audio_status_mutex = + osMutexCreate((osMutex(audio_status_mutex))); + } + return 0; +} + +int inline a2dp_audio_status_mutex_lock(void) { + osMutexWait((osMutexId)a2dp_audio_context.audio_status_mutex, osWaitForever); + return 0; +} + +int inline a2dp_audio_status_mutex_unlock(void) { + osMutexRelease((osMutexId)a2dp_audio_context.audio_status_mutex); + return 0; +} + +int inline a2dp_audio_semaphore_wait(uint32_t timeout_ms) { + osSemaphoreId semaphore_id = + (osSemaphoreId)a2dp_audio_context.audio_semaphore.semaphore; + + a2dp_audio_buffer_mutex_lock(); + a2dp_audio_context.audio_semaphore.enalbe = true; + a2dp_audio_buffer_mutex_unlock(); + + int32_t nRet = osSemaphoreWait(semaphore_id, timeout_ms); + if ((0 == nRet) || (-1 == nRet)) { + TRACE_A2DP_DECODER_W("%s wait timerout", __func__); + return -1; + } + return 0; +} + +int inline a2dp_audio_semaphore_release(void) { + bool enalbe = false; + + a2dp_audio_buffer_mutex_lock(); + if (a2dp_audio_context.audio_semaphore.enalbe) { a2dp_audio_context.audio_semaphore.enalbe = false; - return 0; + enalbe = true; + } + a2dp_audio_buffer_mutex_unlock(); + + if (enalbe) { + osSemaphoreId semaphore_id = + (osSemaphoreId)a2dp_audio_context.audio_semaphore.semaphore; + osSemaphoreRelease(semaphore_id); + } + return 0; } -int inline a2dp_audio_buffer_mutex_init(void) -{ - if (a2dp_audio_context.audio_buffer_mutex == NULL){ - a2dp_audio_context.audio_buffer_mutex = osMutexCreate((osMutex(audio_buffer_mutex))); - } - return 0; +list_node_t *a2dp_audio_list_begin(const list_t *list) { + a2dp_audio_buffer_mutex_lock(); + list_node_t *node = list_begin(list); + a2dp_audio_buffer_mutex_unlock(); + return node; } -int inline a2dp_audio_buffer_mutex_lock(void) -{ - osMutexWait((osMutexId)a2dp_audio_context.audio_buffer_mutex, osWaitForever); - return 0; +list_node_t *a2dp_audio_list_end(const list_t *list) { + a2dp_audio_buffer_mutex_lock(); + list_node_t *node = list_end(list); + a2dp_audio_buffer_mutex_unlock(); + return node; } -int inline a2dp_audio_buffer_mutex_unlock(void) -{ - osMutexRelease((osMutexId)a2dp_audio_context.audio_buffer_mutex); - return 0; +uint32_t a2dp_audio_list_length(const list_t *list) { + a2dp_audio_buffer_mutex_lock(); + uint32_t length = list_length(list); + a2dp_audio_buffer_mutex_unlock(); + return length; } -int inline a2dp_audio_status_mutex_init(void) -{ - if (a2dp_audio_context.audio_status_mutex == NULL){ - a2dp_audio_context.audio_status_mutex = osMutexCreate((osMutex(audio_status_mutex))); - } - return 0; +void *a2dp_audio_list_node(const list_node_t *node) { + a2dp_audio_buffer_mutex_lock(); + void *data = list_node(node); + a2dp_audio_buffer_mutex_unlock(); + return data; } -int inline a2dp_audio_status_mutex_lock(void) -{ - osMutexWait((osMutexId)a2dp_audio_context.audio_status_mutex, osWaitForever); - return 0; +list_node_t *a2dp_audio_list_next(const list_node_t *node) { + a2dp_audio_buffer_mutex_lock(); + list_node_t *next = list_next(node); + a2dp_audio_buffer_mutex_unlock(); + return next; } -int inline a2dp_audio_status_mutex_unlock(void) -{ - osMutexRelease((osMutexId)a2dp_audio_context.audio_status_mutex); - return 0; +bool a2dp_audio_list_remove(list_t *list, void *data) { + a2dp_audio_buffer_mutex_lock(); + bool nRet = list_remove(list, data); + a2dp_audio_buffer_mutex_unlock(); + return nRet; } -int inline a2dp_audio_semaphore_wait(uint32_t timeout_ms) -{ - osSemaphoreId semaphore_id = (osSemaphoreId)a2dp_audio_context.audio_semaphore.semaphore; - - a2dp_audio_buffer_mutex_lock(); - a2dp_audio_context.audio_semaphore.enalbe = true; - a2dp_audio_buffer_mutex_unlock(); - - int32_t nRet = osSemaphoreWait(semaphore_id, timeout_ms); - if ((0 == nRet) || (-1 == nRet)){ - TRACE_A2DP_DECODER_W("%s wait timerout", __func__); - return -1; - } - return 0; +bool a2dp_audio_list_append(list_t *list, void *data) { + a2dp_audio_buffer_mutex_lock(); + bool nRet = list_append(list, data); + a2dp_audio_buffer_mutex_unlock(); + return nRet; } -int inline a2dp_audio_semaphore_release(void) -{ - bool enalbe = false; - - a2dp_audio_buffer_mutex_lock(); - if (a2dp_audio_context.audio_semaphore.enalbe){ - a2dp_audio_context.audio_semaphore.enalbe = false; - enalbe = true; - } - a2dp_audio_buffer_mutex_unlock(); - - if (enalbe){ - osSemaphoreId semaphore_id = (osSemaphoreId)a2dp_audio_context.audio_semaphore.semaphore; - osSemaphoreRelease(semaphore_id); - } - return 0; +void a2dp_audio_list_clear(list_t *list) { + a2dp_audio_buffer_mutex_lock(); + list_clear(list); + a2dp_audio_buffer_mutex_unlock(); } -list_node_t *a2dp_audio_list_begin(const list_t *list) -{ - a2dp_audio_buffer_mutex_lock(); - list_node_t *node = list_begin(list); - a2dp_audio_buffer_mutex_unlock(); - return node; +void a2dp_audio_list_free(list_t *list) { + a2dp_audio_buffer_mutex_lock(); + list_free(list); + a2dp_audio_buffer_mutex_unlock(); } -list_node_t *a2dp_audio_list_end(const list_t *list) -{ - a2dp_audio_buffer_mutex_lock(); - list_node_t *node = list_end(list); - a2dp_audio_buffer_mutex_unlock(); - return node; +list_t *a2dp_audio_list_new(list_free_cb callback, list_mempool_zmalloc zmalloc, + list_mempool_free free) { + a2dp_audio_buffer_mutex_lock(); + list_t *list = list_new(callback, zmalloc, free); + a2dp_audio_buffer_mutex_unlock(); + return list; } -uint32_t a2dp_audio_list_length(const list_t *list) -{ - a2dp_audio_buffer_mutex_lock(); - uint32_t length = list_length(list); - a2dp_audio_buffer_mutex_unlock(); - return length; -} - -void *a2dp_audio_list_node(const list_node_t *node) -{ - a2dp_audio_buffer_mutex_lock(); - void *data = list_node(node); - a2dp_audio_buffer_mutex_unlock(); - return data; -} - -list_node_t *a2dp_audio_list_next(const list_node_t *node) -{ - a2dp_audio_buffer_mutex_lock(); - list_node_t *next =list_next(node); - a2dp_audio_buffer_mutex_unlock(); - return next; -} - -bool a2dp_audio_list_remove(list_t *list, void *data) -{ - a2dp_audio_buffer_mutex_lock(); - bool nRet = list_remove(list, data); - a2dp_audio_buffer_mutex_unlock(); - return nRet; -} - -bool a2dp_audio_list_append(list_t *list, void *data) -{ - a2dp_audio_buffer_mutex_lock(); - bool nRet = list_append(list, data); - a2dp_audio_buffer_mutex_unlock(); - return nRet; -} - -void a2dp_audio_list_clear(list_t *list) -{ - a2dp_audio_buffer_mutex_lock(); - list_clear(list); - a2dp_audio_buffer_mutex_unlock(); -} - -void a2dp_audio_list_free(list_t *list) -{ - a2dp_audio_buffer_mutex_lock(); - list_free(list); - a2dp_audio_buffer_mutex_unlock(); -} - -list_t *a2dp_audio_list_new(list_free_cb callback, list_mempool_zmalloc zmalloc, list_mempool_free free) -{ - a2dp_audio_buffer_mutex_lock(); - list_t *list =list_new(callback, zmalloc, free); - a2dp_audio_buffer_mutex_unlock(); - return list; -} - -uint32_t a2dp_audio_get_passed(uint32_t curr_ticks, uint32_t prev_ticks, uint32_t max_ticks) -{ - if(curr_ticks < prev_ticks) - return ((max_ticks - prev_ticks + 1) + curr_ticks); - else - return (curr_ticks - prev_ticks); +uint32_t a2dp_audio_get_passed(uint32_t curr_ticks, uint32_t prev_ticks, + uint32_t max_ticks) { + if (curr_ticks < prev_ticks) + return ((max_ticks - prev_ticks + 1) + curr_ticks); + else + return (curr_ticks - prev_ticks); } #ifdef A2DP_CP_ACCEL extern "C" uint32_t get_in_cp_frame_cnt(void); extern "C" uint32_t get_in_cp_frame_delay(void); #else -static uint32_t get_in_cp_frame_cnt(void) -{ - return 0; -} +static uint32_t get_in_cp_frame_cnt(void) { return 0; } -static uint32_t get_in_cp_frame_delay(void) -{ - return 0; -} +static uint32_t get_in_cp_frame_delay(void) { return 0; } #endif -int inline a2dp_audio_set_status(enum A2DP_AUDIO_DECODER_STATUS decoder_status) -{ - a2dp_audio_status_mutex_lock(); - a2dp_audio_context.audio_decoder_status = decoder_status; - a2dp_audio_status_mutex_unlock(); +int inline a2dp_audio_set_status( + enum A2DP_AUDIO_DECODER_STATUS decoder_status) { + a2dp_audio_status_mutex_lock(); + a2dp_audio_context.audio_decoder_status = decoder_status; + a2dp_audio_status_mutex_unlock(); - return 0; + return 0; } -enum A2DP_AUDIO_DECODER_STATUS inline a2dp_audio_get_status(void) -{ - enum A2DP_AUDIO_DECODER_STATUS decoder_status; - a2dp_audio_status_mutex_lock(); - decoder_status = a2dp_audio_context.audio_decoder_status; - a2dp_audio_status_mutex_unlock(); +enum A2DP_AUDIO_DECODER_STATUS inline a2dp_audio_get_status(void) { + enum A2DP_AUDIO_DECODER_STATUS decoder_status; + a2dp_audio_status_mutex_lock(); + decoder_status = a2dp_audio_context.audio_decoder_status; + a2dp_audio_status_mutex_unlock(); - return decoder_status; + return decoder_status; } -int inline a2dp_audio_set_store_packet_status(enum A2DP_AUDIO_DECODER_STORE_PACKET_STATUS store_packet_status) -{ - a2dp_audio_status_mutex_lock(); - a2dp_audio_context.store_packet_status = store_packet_status; - a2dp_audio_status_mutex_unlock(); +int inline a2dp_audio_set_store_packet_status( + enum A2DP_AUDIO_DECODER_STORE_PACKET_STATUS store_packet_status) { + a2dp_audio_status_mutex_lock(); + a2dp_audio_context.store_packet_status = store_packet_status; + a2dp_audio_status_mutex_unlock(); - return 0; + return 0; } -enum A2DP_AUDIO_DECODER_STORE_PACKET_STATUS inline a2dp_audio_get_store_packet_status(void) -{ - enum A2DP_AUDIO_DECODER_STORE_PACKET_STATUS store_packet_status; - a2dp_audio_status_mutex_lock(); - store_packet_status = a2dp_audio_context.store_packet_status; - a2dp_audio_status_mutex_unlock(); +enum A2DP_AUDIO_DECODER_STORE_PACKET_STATUS inline a2dp_audio_get_store_packet_status( + void) { + enum A2DP_AUDIO_DECODER_STORE_PACKET_STATUS store_packet_status; + a2dp_audio_status_mutex_lock(); + store_packet_status = a2dp_audio_context.store_packet_status; + a2dp_audio_status_mutex_unlock(); - return store_packet_status; + return store_packet_status; } -int inline a2dp_audio_set_playback_status(enum A2DP_AUDIO_DECODER_PLAYBACK_STATUS playback_status) -{ - a2dp_audio_status_mutex_lock(); - a2dp_audio_context.playback_status = playback_status; - a2dp_audio_status_mutex_unlock(); +int inline a2dp_audio_set_playback_status( + enum A2DP_AUDIO_DECODER_PLAYBACK_STATUS playback_status) { + a2dp_audio_status_mutex_lock(); + a2dp_audio_context.playback_status = playback_status; + a2dp_audio_status_mutex_unlock(); - return 0; + return 0; } -enum A2DP_AUDIO_DECODER_PLAYBACK_STATUS inline a2dp_audio_get_playback_status(void) -{ - enum A2DP_AUDIO_DECODER_PLAYBACK_STATUS playback_status; - a2dp_audio_status_mutex_lock(); - playback_status = a2dp_audio_context.playback_status; - a2dp_audio_status_mutex_unlock(); +enum A2DP_AUDIO_DECODER_PLAYBACK_STATUS inline a2dp_audio_get_playback_status( + void) { + enum A2DP_AUDIO_DECODER_PLAYBACK_STATUS playback_status; + a2dp_audio_status_mutex_lock(); + playback_status = a2dp_audio_context.playback_status; + a2dp_audio_status_mutex_unlock(); - return playback_status; + return playback_status; } -static void a2dp_decoder_info_checker(void) -{ -// app_bt_start_custom_function_in_app_thread(0, 0, (uint32_t)bt_drv_reg_op_bt_info_checker); +static void a2dp_decoder_info_checker(void) { + // app_bt_start_custom_function_in_app_thread(0, 0, + // (uint32_t)bt_drv_reg_op_bt_info_checker); } -int a2dp_audio_sync_pid_config(void) -{ - A2DP_AUDIO_SYNC_T *audio_sync = &a2dp_audio_context.audio_sync; +int a2dp_audio_sync_pid_config(void) { + A2DP_AUDIO_SYNC_T *audio_sync = &a2dp_audio_context.audio_sync; + A2DP_AUDIO_SYNC_PID_T *pid = &audio_sync->pid; + + pid->proportiongain = 0.4f; + pid->integralgain = 0.1f; + pid->derivativegain = 0.6f; + + return 0; +} + +int a2dp_audio_sync_reset_data(void) { + A2DP_AUDIO_SYNC_T *audio_sync = &a2dp_audio_context.audio_sync; + + a2dp_audio_status_mutex_lock(); + audio_sync->tick = 0; + audio_sync->cnt = 0; + a2dp_audio_sync_pid_config(); +#ifdef __A2DP_AUDIO_SYNC_FIX_DIFF_NOPID__ + a2dp_audio_sync_fix_diff_reset(); +#endif + a2dp_audio_status_mutex_unlock(); + + TRACE_A2DP_DECODER_I("[SYNC]reset_data"); + return 0; +} + +int a2dp_audio_sync_init(double ratio) { +#ifdef __A2DP_AUDIO_SYNC_FIX_DIFF_NOPID__ + a2dp_audio_sync_fix_diff_reset(); +#endif + a2dp_audio_sync_reset_data(); + a2dp_audio_sync_tune_sample_rate(ratio); + sync_tune_dest_ratio = (float)ratio; + return 0; +} + +int a2dp_audio_sync_tune_sample_rate(double ratio) { + float resample_rate_ratio; + bool need_tune = false; + + a2dp_audio_status_mutex_lock(); + if (a2dp_audio_context.output_cfg.factor_reference != (float)ratio) { + a2dp_audio_context.output_cfg.factor_reference = (float)ratio; + resample_rate_ratio = (float)(ratio - (double)1.0); + need_tune = true; + } + // a2dp_audio_status_mutex_unlock(); + + if (need_tune) { + app_audio_manager_tune_samplerate_ratio(AUD_STREAM_PLAYBACK, + resample_rate_ratio); + TRACE_A2DP_DECODER_I("[SYNC] ppb:%d ratio:%08d", + (int32_t)(resample_rate_ratio * 10000000), + (int32_t)(ratio * 10000000)); + } + a2dp_audio_status_mutex_unlock(); + + return 0; +} + +int a2dp_audio_sync_direct_tune_sample_rate(double ratio) { + float resample_rate_ratio; + bool need_tune = false; + + a2dp_audio_status_mutex_lock(); + if (a2dp_audio_context.output_cfg.factor_reference != (float)ratio) { + a2dp_audio_context.output_cfg.factor_reference = (float)ratio; + resample_rate_ratio = (float)(ratio - (double)1.0); + need_tune = true; + } + + if (need_tune) { + af_codec_direct_tune(AUD_STREAM_PLAYBACK, resample_rate_ratio); + + TRACE_A2DP_DECODER_I("[SYNC] ppb:%d ratio:%08d", + (int32_t)(resample_rate_ratio * 10000000), + (int32_t)(ratio * 10000000)); + } + a2dp_audio_status_mutex_unlock(); + + return 0; +} + +bool a2dp_audio_sync_tune_onprocess(void) { + bool nRet = false; + ; + if (a2dp_audio_context.output_cfg.factor_reference != sync_tune_dest_ratio) { + nRet = true; + } + return nRet; +} + +int a2dp_audio_sync_tune(float ratio) { + int nRet = 0; + if (sync_tune_dest_ratio == ratio) { + goto exit; + } + sync_tune_dest_ratio = ratio; +#if defined(IBRT) + if (app_ibrt_ui_is_profile_exchanged()) { + if (app_tws_ibrt_mobile_link_connected()) { + APP_TWS_IBRT_AUDIO_SYNC_TUNE_T sync_tune; + sync_tune.factor_reference = ratio; + if (!app_tws_ibrt_audio_sync_tune_need_skip()) { + tws_ctrl_send_cmd(APP_TWS_CMD_SYNC_TUNE, (uint8_t *)&sync_tune, + sizeof(APP_TWS_IBRT_AUDIO_SYNC_TUNE_T)); + } else { + a2dp_audio_sync_tune_cancel(); + nRet = -1; + } + } + } else { + a2dp_audio_sync_tune_sample_rate(ratio); + } +#else + a2dp_audio_sync_tune_sample_rate(ratio); +#endif +exit: + return nRet; +} + +int a2dp_audio_sync_tune_cancel(void) { + sync_tune_dest_ratio = a2dp_audio_context.output_cfg.factor_reference; + return 0; +} + +float a2dp_audio_sync_pid_calc(A2DP_AUDIO_SYNC_PID_T *pid, float diff) { + float increment; + float pError, dError, iError; + + pid->error[0] = diff; + pError = pid->error[0] - pid->error[1]; + iError = pid->error[0]; + dError = pid->error[0] - 2 * pid->error[1] + pid->error[2]; + + increment = pid->proportiongain * pError + pid->integralgain * iError + + pid->derivativegain * dError; + + pid->error[2] = pid->error[1]; + pid->error[1] = pid->error[0]; + + pid->result += increment; + + return pid->result; +} + +#ifdef __A2DP_AUDIO_SYNC_FIX_DIFF_NOPID__ +static int a2dp_audio_sync_fix_diff_proc(uint32_t tick) { + if (a2dp_audio_sync_fix_diff.status == + A2DP_AUDIO_SYNC_FIX_DIFF_STATUS_START) { + if (a2dp_audio_sync_fix_diff.tick > 0) { + a2dp_audio_sync_fix_diff.tick--; + } else { + a2dp_audio_sync_fix_diff_stop(0); + } + } + return 0; +} + +static int32_t a2dp_audio_sync_fix_diff_start(uint32_t tick) { + TRACE_A2DP_DECODER_I("[SYNC] fix diff start"); + + a2dp_audio_sync_fix_diff.status = A2DP_AUDIO_SYNC_FIX_DIFF_STATUS_START; + a2dp_audio_sync_fix_diff.tick = tick; + return 0; +} + +static int a2dp_audio_sync_fix_diff_stop(uint32_t tick) { + TRACE_A2DP_DECODER_I("[SYNC] fix diff stop"); + + a2dp_audio_sync_fix_diff.status = A2DP_AUDIO_SYNC_FIX_DIFF_STATUS_STOP; + a2dp_audio_sync_fix_diff.tick = 0; + + return 0; +} + +static int32_t a2dp_audio_sync_fix_diff_reset(void) { + TRACE_A2DP_DECODER_I("[SYNC] fix diff reset"); + + a2dp_audio_sync_fix_diff.status = A2DP_AUDIO_SYNC_FIX_DIFF_STATUS_IDLE; + a2dp_audio_sync_fix_diff.tick = 0; + + return 0; +} + +static A2DP_AUDIO_SYNC_FIX_DIFF_STATUS +a2dp_audio_sync_fix_diff_status_get(void) { + return a2dp_audio_sync_fix_diff.status; +} + +int a2dp_audio_sync_handler(uint8_t *buffer, uint32_t buffer_bytes) { + A2DP_AUDIO_LASTFRAME_INFO_T *lastframe_info = NULL; + A2DP_AUDIO_SYNC_T *audio_sync = &a2dp_audio_context.audio_sync; + float diff_mtu = 0; + bool need_tune = false; + bool force_slow = false; + +#if defined(IBRT) + if (!app_tws_ibrt_mobile_link_connected()) { + return -1; + } +#endif + if (a2dp_audio_internal_lastframe_info_ptr_get(&lastframe_info) < 0) { + return -1; + } + + a2dp_audio_sync_fix_diff_proc(audio_sync->tick); + if (a2dp_audio_sync_fix_diff_status_get() == + A2DP_AUDIO_SYNC_FIX_DIFF_STATUS_STOP) { +#if defined(IBRT) + if (!app_tws_ibrt_audio_sync_tune_onprocess() && + !a2dp_audio_sync_tune_onprocess() +#else + if (!a2dp_audio_sync_tune_onprocess() +#endif + ) { + int sync_tune_result = 0; + if (a2dp_audio_context.output_cfg.factor_reference != + a2dp_audio_context.init_factor_reference) { + sync_tune_result = + a2dp_audio_sync_tune(a2dp_audio_context.init_factor_reference); + } + if (!sync_tune_result) { + a2dp_audio_sync_fix_diff_reset(); +#ifdef A2DP_AUDIO_SYNC_FIX_DIFF_INTERVA_PRINT_FLOAT + TRACE_A2DP_DECODER_I("[SYNC] tune ratio normal %f mut:%5.3f->%d", + (double)a2dp_audio_context.init_factor_reference, + (double)a2dp_audio_context.average_packet_mut, + a2dp_audio_context.dest_packet_mut); +#else + TRACE_A2DP_DECODER_I( + "[SYNC] tune ratio normal %d mut:%d->%d", + (int32_t)(a2dp_audio_context.init_factor_reference * 10000000), + (int32_t)(a2dp_audio_context.average_packet_mut + 0.5f), + a2dp_audio_context.dest_packet_mut); +#endif + } else { + TRACE_A2DP_DECODER_I("[SYNC] tune ratio normal busy"); + } + + } else { +#ifdef A2DP_AUDIO_SYNC_FIX_DIFF_INTERVA_PRINT_FLOAT + TRACE_A2DP_DECODER_I("[SYNC] tune ratio busy %f mut:%5.3f->%d", + (double)a2dp_audio_context.init_factor_reference, + (double)a2dp_audio_context.average_packet_mut, + a2dp_audio_context.dest_packet_mut); +#else + TRACE_A2DP_DECODER_I( + "[SYNC] tune ratio busy %d mut:%d->%d", + (int32_t)(a2dp_audio_context.init_factor_reference * 10000000), + (int32_t)(a2dp_audio_context.average_packet_mut + 0.5f), + a2dp_audio_context.dest_packet_mut); +#endif + } + goto exit; + } + + if (audio_sync->tick % A2DP_AUDIO_SYNC_INTERVAL == 0) { + diff_mtu = a2dp_audio_context.average_packet_mut - + (float)a2dp_audio_context.dest_packet_mut; + if (ABS(diff_mtu) < 0.6f) { +#ifdef A2DP_AUDIO_SYNC_FIX_DIFF_INTERVA_PRINT_FLOAT + TRACE_A2DP_DECODER_I("[SYNC] skip mut:%5.3f", (double)diff_mtu); +#else + TRACE_A2DP_DECODER_I("[SYNC] skip mut:0.%d", (int32_t)(diff_mtu * 10)); +#endif + goto exit; + } else if (diff_mtu / a2dp_audio_context.dest_packet_mut < -0.2f) { + float curr_ratio = a2dp_audio_context.output_cfg.factor_reference; + float ref_ratio = a2dp_audio_context.init_factor_reference; + if (curr_ratio != (ref_ratio + A2DP_AUDIO_SYNC_FIX_DIFF_SLOW_LIMIT)) { +#ifdef A2DP_AUDIO_SYNC_FIX_DIFF_INTERVA_PRINT_FLOAT + TRACE_A2DP_DECODER_I("[SYNC] force slow mut:%5.3f", (double)diff_mtu); +#else + TRACE_A2DP_DECODER_I("[SYNC] force slow mut:0.%d", + (int32_t)(diff_mtu * 10)); +#endif + force_slow = true; + } + } + if (a2dp_audio_sync_fix_diff_status_get() == + A2DP_AUDIO_SYNC_FIX_DIFF_STATUS_IDLE || + force_slow) { + uint32_t dma_buffer_samples, samples, dma_interval; + double ratio = 1.0, limit_ratio = 1.0; + float sampleRate, ref_ratio, curr_ratio; + float ref_us = 0; + float dest_us = 0; + float sample_us = 0; + + dma_buffer_samples = app_bt_stream_get_dma_buffer_samples() / 2; + dma_interval = A2DP_AUDIO_SYNC_FIX_DIFF_INTERVAL; + + ref_ratio = a2dp_audio_context.init_factor_reference; + curr_ratio = a2dp_audio_context.output_cfg.factor_reference; + + samples = dma_interval * dma_buffer_samples; + sampleRate = lastframe_info->stream_info.sample_rate * ref_ratio; + + sample_us = 1e6 / sampleRate; + ref_us = sample_us * (float)samples; + dest_us = sample_us * (float)(lastframe_info->frame_samples * diff_mtu); + ratio = ref_us / (ref_us - dest_us) * curr_ratio; + + if (ratio > (double)(ref_ratio + A2DP_AUDIO_SYNC_FIX_DIFF_FAST_LIMIT)) { + limit_ratio = ref_ratio + A2DP_AUDIO_SYNC_FIX_DIFF_FAST_LIMIT; + } else if (ratio < + double(ref_ratio + A2DP_AUDIO_SYNC_FIX_DIFF_SLOW_LIMIT)) { + limit_ratio = ref_ratio + A2DP_AUDIO_SYNC_FIX_DIFF_SLOW_LIMIT; + } else { + limit_ratio = ratio; + } + TRACE_A2DP_DECODER_I( + "[SYNC] sampleRate:%d ref_ratio:%d samples:%d %d->%d", + (int32_t)sampleRate, (int32_t)(ref_ratio * 10000000), samples, + (int32_t)ref_us, (int32_t)dest_us); + need_tune = true; +#if defined(IBRT) + if (!app_tws_ibrt_audio_sync_tune_onprocess() && + !a2dp_audio_sync_tune_onprocess() && +#else + if (!a2dp_audio_sync_tune_onprocess() && +#endif + need_tune) { + if (!a2dp_audio_sync_tune((float)limit_ratio)) { + a2dp_audio_sync_fix_diff_start(dma_interval); +#ifdef A2DP_AUDIO_SYNC_FIX_DIFF_INTERVA_PRINT_FLOAT + TRACE_A2DP_DECODER_I("[SYNC] tune ratio %f mut:%5.3f->%d", + limit_ratio, + (double)a2dp_audio_context.average_packet_mut, + a2dp_audio_context.dest_packet_mut); +#else + TRACE_A2DP_DECODER_I( + "[SYNC] tune ratio %d mut:%d->%d", + (int32_t)(limit_ratio * 10000000), + (int32_t)(a2dp_audio_context.average_packet_mut + 0.5f), + a2dp_audio_context.dest_packet_mut); +#endif + } else { + TRACE_A2DP_DECODER_I("[SYNC] tune ratio busy"); + } + } + } else { + TRACE_A2DP_DECODER_I( + "[SYNC] avg_mut:%d dest_mtu:%d", + (int32_t)(a2dp_audio_context.average_packet_mut + 0.5f), + a2dp_audio_context.dest_packet_mut); + } + } else { + } +exit: + audio_sync->tick++; + return 0; +} +#else +int a2dp_audio_sync_handler(uint8_t *buffer, uint32_t buffer_bytes) { + A2DP_AUDIO_LASTFRAME_INFO_T *lastframe_info = NULL; + A2DP_AUDIO_SYNC_T *audio_sync = &a2dp_audio_context.audio_sync; + float dest_pid_result = .0f; + float diff_mtu = 0; + int32_t frame_mtu = 0; + int32_t total_mtu = 0; + float diff_factor = 0; + +#if defined(IBRT) + if (!app_tws_ibrt_mobile_link_connected()) { + return -1; + } +#endif + if (a2dp_audio_internal_lastframe_info_ptr_get(&lastframe_info) < 0) { + return -1; + } + + if (audio_sync->tick++ % A2DP_AUDIO_SYNC_INTERVAL == 0) { + list_t *list = a2dp_audio_context.audio_datapath.input_raw_packet_list; A2DP_AUDIO_SYNC_PID_T *pid = &audio_sync->pid; - - pid->proportiongain = 0.4f; - pid->integralgain = 0.1f; - pid->derivativegain = 0.6f; - - return 0; -} - -int a2dp_audio_sync_reset_data(void) -{ - A2DP_AUDIO_SYNC_T *audio_sync = &a2dp_audio_context.audio_sync; - - a2dp_audio_status_mutex_lock(); - audio_sync->tick = 0; - audio_sync->cnt = 0; - a2dp_audio_sync_pid_config(); -#ifdef __A2DP_AUDIO_SYNC_FIX_DIFF_NOPID__ - a2dp_audio_sync_fix_diff_reset(); -#endif - a2dp_audio_status_mutex_unlock(); - - TRACE_A2DP_DECODER_I("[SYNC]reset_data"); - return 0; -} - -int a2dp_audio_sync_init(double ratio) -{ -#ifdef __A2DP_AUDIO_SYNC_FIX_DIFF_NOPID__ - a2dp_audio_sync_fix_diff_reset(); -#endif - a2dp_audio_sync_reset_data(); - a2dp_audio_sync_tune_sample_rate(ratio); - sync_tune_dest_ratio = (float)ratio; - return 0; -} - -int a2dp_audio_sync_tune_sample_rate(double ratio) -{ - float resample_rate_ratio; - bool need_tune = false; - - a2dp_audio_status_mutex_lock(); - if (a2dp_audio_context.output_cfg.factor_reference != (float)ratio){ - a2dp_audio_context.output_cfg.factor_reference = (float)ratio; - resample_rate_ratio = (float)(ratio - (double)1.0); - need_tune = true; + // valid limter 0x80000 + if (audio_sync->cnt < 0x80000) { + audio_sync->cnt += A2DP_AUDIO_SYNC_INTERVAL; } - //a2dp_audio_status_mutex_unlock(); - - if (need_tune){ - app_audio_manager_tune_samplerate_ratio(AUD_STREAM_PLAYBACK, resample_rate_ratio); - TRACE_A2DP_DECODER_I("[SYNC] ppb:%d ratio:%08d", - (int32_t)(resample_rate_ratio * 10000000), - (int32_t)(ratio * 10000000)); - } - a2dp_audio_status_mutex_unlock(); - - return 0; -} - -int a2dp_audio_sync_direct_tune_sample_rate(double ratio) -{ - float resample_rate_ratio; - bool need_tune = false; - - a2dp_audio_status_mutex_lock(); - if (a2dp_audio_context.output_cfg.factor_reference != (float)ratio){ - a2dp_audio_context.output_cfg.factor_reference = (float)ratio; - resample_rate_ratio = (float)(ratio - (double)1.0); - need_tune = true; - } - - if (need_tune){ - af_codec_direct_tune(AUD_STREAM_PLAYBACK, resample_rate_ratio); - - TRACE_A2DP_DECODER_I("[SYNC] ppb:%d ratio:%08d", - (int32_t)(resample_rate_ratio * 10000000), - (int32_t)(ratio * 10000000)); - } - a2dp_audio_status_mutex_unlock(); - - return 0; -} - -bool a2dp_audio_sync_tune_onprocess(void) -{ - bool nRet = false;; - if (a2dp_audio_context.output_cfg.factor_reference != sync_tune_dest_ratio){ - nRet = true; - } - return nRet; -} - -int a2dp_audio_sync_tune(float ratio) -{ - int nRet = 0; - if (sync_tune_dest_ratio == ratio){ - goto exit; - } - sync_tune_dest_ratio = ratio; -#if defined(IBRT) - if (app_ibrt_ui_is_profile_exchanged()){ - if (app_tws_ibrt_mobile_link_connected()){ - APP_TWS_IBRT_AUDIO_SYNC_TUNE_T sync_tune; - sync_tune.factor_reference = ratio; - if (!app_tws_ibrt_audio_sync_tune_need_skip()){ - tws_ctrl_send_cmd(APP_TWS_CMD_SYNC_TUNE, (uint8_t*)&sync_tune, sizeof(APP_TWS_IBRT_AUDIO_SYNC_TUNE_T)); - }else{ - a2dp_audio_sync_tune_cancel(); - nRet = -1; - } - } - }else{ - a2dp_audio_sync_tune_sample_rate(ratio); - } -#else - a2dp_audio_sync_tune_sample_rate(ratio); -#endif -exit: - return nRet; -} - -int a2dp_audio_sync_tune_cancel(void) -{ - sync_tune_dest_ratio = a2dp_audio_context.output_cfg.factor_reference; - return 0; -} - -float a2dp_audio_sync_pid_calc(A2DP_AUDIO_SYNC_PID_T *pid, float diff) -{ - float increment; - float pError,dError,iError; - - pid->error[0] = diff; - pError=pid->error[0]-pid->error[1]; - iError=pid->error[0]; - dError=pid->error[0]-2*pid->error[1]+pid->error[2]; - - increment = pid->proportiongain*pError+pid->integralgain*iError+pid->derivativegain*dError; - - pid->error[2] = pid->error[1]; - pid->error[1] = pid->error[0]; - - pid->result += increment; - - return pid->result; -} - -#ifdef __A2DP_AUDIO_SYNC_FIX_DIFF_NOPID__ -static int a2dp_audio_sync_fix_diff_proc(uint32_t tick) -{ - if (a2dp_audio_sync_fix_diff.status == A2DP_AUDIO_SYNC_FIX_DIFF_STATUS_START){ - if (a2dp_audio_sync_fix_diff.tick > 0){ - a2dp_audio_sync_fix_diff.tick--; - }else{ - a2dp_audio_sync_fix_diff_stop(0); - } - } - return 0; -} - -static int32_t a2dp_audio_sync_fix_diff_start(uint32_t tick) -{ - TRACE_A2DP_DECODER_I("[SYNC] fix diff start"); - - a2dp_audio_sync_fix_diff.status = A2DP_AUDIO_SYNC_FIX_DIFF_STATUS_START; - a2dp_audio_sync_fix_diff.tick = tick; - return 0; -} - -static int a2dp_audio_sync_fix_diff_stop(uint32_t tick) -{ - TRACE_A2DP_DECODER_I("[SYNC] fix diff stop"); - - a2dp_audio_sync_fix_diff.status = A2DP_AUDIO_SYNC_FIX_DIFF_STATUS_STOP; - a2dp_audio_sync_fix_diff.tick = 0; - - return 0; -} - -static int32_t a2dp_audio_sync_fix_diff_reset(void) -{ - TRACE_A2DP_DECODER_I("[SYNC] fix diff reset"); - - a2dp_audio_sync_fix_diff.status = A2DP_AUDIO_SYNC_FIX_DIFF_STATUS_IDLE; - a2dp_audio_sync_fix_diff.tick = 0; - - return 0; -} - -static A2DP_AUDIO_SYNC_FIX_DIFF_STATUS a2dp_audio_sync_fix_diff_status_get(void) -{ - return a2dp_audio_sync_fix_diff.status; -} - -int a2dp_audio_sync_handler(uint8_t *buffer, uint32_t buffer_bytes) -{ - A2DP_AUDIO_LASTFRAME_INFO_T *lastframe_info = NULL; - A2DP_AUDIO_SYNC_T *audio_sync = &a2dp_audio_context.audio_sync; - float diff_mtu = 0; - bool need_tune = false; - bool force_slow = false; - -#if defined(IBRT) - if (!app_tws_ibrt_mobile_link_connected()){ - return -1; - } -#endif - if (a2dp_audio_internal_lastframe_info_ptr_get(&lastframe_info) < 0){ - return -1; - } - - a2dp_audio_sync_fix_diff_proc(audio_sync->tick); - if (a2dp_audio_sync_fix_diff_status_get() == A2DP_AUDIO_SYNC_FIX_DIFF_STATUS_STOP){ -#if defined(IBRT) - if (!app_tws_ibrt_audio_sync_tune_onprocess() && - !a2dp_audio_sync_tune_onprocess() -#else - if (!a2dp_audio_sync_tune_onprocess() -#endif - ){ - int sync_tune_result = 0; - if (a2dp_audio_context.output_cfg.factor_reference != a2dp_audio_context.init_factor_reference){ - sync_tune_result = a2dp_audio_sync_tune(a2dp_audio_context.init_factor_reference); - } - if (!sync_tune_result){ - a2dp_audio_sync_fix_diff_reset(); -#ifdef A2DP_AUDIO_SYNC_FIX_DIFF_INTERVA_PRINT_FLOAT - TRACE_A2DP_DECODER_I("[SYNC] tune ratio normal %f mut:%5.3f->%d", (double)a2dp_audio_context.init_factor_reference, - (double)a2dp_audio_context.average_packet_mut, - a2dp_audio_context.dest_packet_mut); -#else - TRACE_A2DP_DECODER_I("[SYNC] tune ratio normal %d mut:%d->%d", (int32_t)(a2dp_audio_context.init_factor_reference * 10000000), - (int32_t)(a2dp_audio_context.average_packet_mut+0.5f), - a2dp_audio_context.dest_packet_mut); -#endif - }else{ - TRACE_A2DP_DECODER_I("[SYNC] tune ratio normal busy"); - } - - }else{ -#ifdef A2DP_AUDIO_SYNC_FIX_DIFF_INTERVA_PRINT_FLOAT - TRACE_A2DP_DECODER_I("[SYNC] tune ratio busy %f mut:%5.3f->%d", (double)a2dp_audio_context.init_factor_reference, - (double)a2dp_audio_context.average_packet_mut, - a2dp_audio_context.dest_packet_mut); -#else - TRACE_A2DP_DECODER_I("[SYNC] tune ratio busy %d mut:%d->%d", (int32_t)(a2dp_audio_context.init_factor_reference * 10000000), - (int32_t)(a2dp_audio_context.average_packet_mut+0.5f), - a2dp_audio_context.dest_packet_mut); -#endif - } - goto exit; - } - - if (audio_sync->tick%A2DP_AUDIO_SYNC_INTERVAL == 0){ - diff_mtu = a2dp_audio_context.average_packet_mut-(float)a2dp_audio_context.dest_packet_mut; - if (ABS(diff_mtu) < 0.6f){ -#ifdef A2DP_AUDIO_SYNC_FIX_DIFF_INTERVA_PRINT_FLOAT - TRACE_A2DP_DECODER_I("[SYNC] skip mut:%5.3f", (double)diff_mtu); -#else - TRACE_A2DP_DECODER_I("[SYNC] skip mut:0.%d", (int32_t)(diff_mtu*10)); -#endif - goto exit; - }else if (diff_mtu/a2dp_audio_context.dest_packet_mut < -0.2f){ - float curr_ratio = a2dp_audio_context.output_cfg.factor_reference; - float ref_ratio = a2dp_audio_context.init_factor_reference; - if (curr_ratio != (ref_ratio + A2DP_AUDIO_SYNC_FIX_DIFF_SLOW_LIMIT)){ -#ifdef A2DP_AUDIO_SYNC_FIX_DIFF_INTERVA_PRINT_FLOAT - TRACE_A2DP_DECODER_I("[SYNC] force slow mut:%5.3f", (double)diff_mtu); -#else - TRACE_A2DP_DECODER_I("[SYNC] force slow mut:0.%d", (int32_t)(diff_mtu*10)); -#endif - force_slow = true; - } - } - if (a2dp_audio_sync_fix_diff_status_get() == A2DP_AUDIO_SYNC_FIX_DIFF_STATUS_IDLE || - force_slow){ - uint32_t dma_buffer_samples, samples, dma_interval; - double ratio = 1.0, limit_ratio = 1.0; - float sampleRate, ref_ratio, curr_ratio; - float ref_us = 0; - float dest_us = 0; - float sample_us =0; - - dma_buffer_samples = app_bt_stream_get_dma_buffer_samples()/2; - dma_interval = A2DP_AUDIO_SYNC_FIX_DIFF_INTERVAL; - - ref_ratio = a2dp_audio_context.init_factor_reference; - curr_ratio = a2dp_audio_context.output_cfg.factor_reference; - - samples = dma_interval*dma_buffer_samples; - sampleRate = lastframe_info->stream_info.sample_rate * ref_ratio; - - sample_us = 1e6 / sampleRate; - ref_us = sample_us * (float)samples; - dest_us = sample_us * (float)(lastframe_info->frame_samples * diff_mtu); - ratio = ref_us/(ref_us - dest_us)*curr_ratio; - - if (ratio > (double)(ref_ratio + A2DP_AUDIO_SYNC_FIX_DIFF_FAST_LIMIT)){ - limit_ratio = ref_ratio + A2DP_AUDIO_SYNC_FIX_DIFF_FAST_LIMIT; - }else if (ratio < double(ref_ratio + A2DP_AUDIO_SYNC_FIX_DIFF_SLOW_LIMIT)){ - limit_ratio = ref_ratio + A2DP_AUDIO_SYNC_FIX_DIFF_SLOW_LIMIT; - }else{ - limit_ratio = ratio; - } - TRACE_A2DP_DECODER_I("[SYNC] sampleRate:%d ref_ratio:%d samples:%d %d->%d", (int32_t)sampleRate, - (int32_t)(ref_ratio * 10000000), - samples, - (int32_t)ref_us, - (int32_t)dest_us); - need_tune = true; -#if defined(IBRT) - if (!app_tws_ibrt_audio_sync_tune_onprocess() && - !a2dp_audio_sync_tune_onprocess() && -#else - if (!a2dp_audio_sync_tune_onprocess() && -#endif - need_tune){ - if (!a2dp_audio_sync_tune((float)limit_ratio)){ - a2dp_audio_sync_fix_diff_start(dma_interval); -#ifdef A2DP_AUDIO_SYNC_FIX_DIFF_INTERVA_PRINT_FLOAT - TRACE_A2DP_DECODER_I("[SYNC] tune ratio %f mut:%5.3f->%d", limit_ratio, - (double)a2dp_audio_context.average_packet_mut, - a2dp_audio_context.dest_packet_mut); -#else - TRACE_A2DP_DECODER_I("[SYNC] tune ratio %d mut:%d->%d", (int32_t)(limit_ratio * 10000000), - (int32_t)(a2dp_audio_context.average_packet_mut+0.5f), - a2dp_audio_context.dest_packet_mut); -#endif - }else{ - TRACE_A2DP_DECODER_I("[SYNC] tune ratio busy"); - } - } - }else{ - TRACE_A2DP_DECODER_I("[SYNC] avg_mut:%d dest_mtu:%d", (int32_t)(a2dp_audio_context.average_packet_mut+0.5f), - a2dp_audio_context.dest_packet_mut); - } - }else{ - - } -exit: - audio_sync->tick++; - return 0; -} -#else -int a2dp_audio_sync_handler(uint8_t *buffer, uint32_t buffer_bytes) -{ - A2DP_AUDIO_LASTFRAME_INFO_T *lastframe_info = NULL; - A2DP_AUDIO_SYNC_T *audio_sync = &a2dp_audio_context.audio_sync; - float dest_pid_result = .0f; - float diff_mtu = 0; - int32_t frame_mtu = 0; - int32_t total_mtu = 0; - float diff_factor = 0; - -#if defined(IBRT) - if (!app_tws_ibrt_mobile_link_connected()){ - return -1; - } -#endif - if (a2dp_audio_internal_lastframe_info_ptr_get(&lastframe_info) < 0){ - return -1; - } - - if (audio_sync->tick++%A2DP_AUDIO_SYNC_INTERVAL == 0){ - list_t *list = a2dp_audio_context.audio_datapath.input_raw_packet_list; - A2DP_AUDIO_SYNC_PID_T *pid = &audio_sync->pid; - //valid limter 0x80000 - if (audio_sync->cnt < 0x80000){ - audio_sync->cnt += A2DP_AUDIO_SYNC_INTERVAL; - } - frame_mtu = lastframe_info->stream_info.frame_samples/lastframe_info->frame_samples; - total_mtu = audio_sync->cnt * frame_mtu; - diff_mtu = a2dp_audio_context.average_packet_mut-(float)a2dp_audio_context.dest_packet_mut; + frame_mtu = lastframe_info->stream_info.frame_samples / + lastframe_info->frame_samples; + total_mtu = audio_sync->cnt * frame_mtu; + diff_mtu = a2dp_audio_context.average_packet_mut - + (float)a2dp_audio_context.dest_packet_mut; #if 1 - TRACE_A2DP_DECODER_I("[SYNC] sample:%d/%d diff:%d/%d/%d/%d curr:%d", lastframe_info->frame_samples, - lastframe_info->stream_info.frame_samples, - (int32_t)(diff_mtu+0.5f), - (int32_t)(a2dp_audio_context.average_packet_mut+0.5f), - a2dp_audio_context.dest_packet_mut, - total_mtu, - a2dp_audio_list_length(list) + get_in_cp_frame_cnt()); + TRACE_A2DP_DECODER_I( + "[SYNC] sample:%d/%d diff:%d/%d/%d/%d curr:%d", + lastframe_info->frame_samples, + lastframe_info->stream_info.frame_samples, (int32_t)(diff_mtu + 0.5f), + (int32_t)(a2dp_audio_context.average_packet_mut + 0.5f), + a2dp_audio_context.dest_packet_mut, total_mtu, + a2dp_audio_list_length(list) + get_in_cp_frame_cnt()); #else - TRACE_A2DP_DECODER_I("[SYNC] diff:%10.9f/%10.9f frame_mut:%d dest:%d total:%d curr:%d", (double)diff_mtu, (double)a2dp_audio_context.average_packet_mut, frame_mtu, - a2dp_audio_context.dest_packet_mut, total_mtu, a2dp_audio_list_length(list)); - TRACE_A2DP_DECODER_I("[SYNC] try tune:%d, %10.9f %10.9f", diff_mtu != 0.f && audio_sync->tick != 1 ? ABS(diff_mtu) > ((float)frame_mtu * 0.2f): 0, - (double)ABS(diff_mtu), (double)((float)frame_mtu * 0.2f)); + TRACE_A2DP_DECODER_I( + "[SYNC] diff:%10.9f/%10.9f frame_mut:%d dest:%d total:%d curr:%d", + (double)diff_mtu, (double)a2dp_audio_context.average_packet_mut, + frame_mtu, a2dp_audio_context.dest_packet_mut, total_mtu, + a2dp_audio_list_length(list)); + TRACE_A2DP_DECODER_I("[SYNC] try tune:%d, %10.9f %10.9f", + diff_mtu != 0.f && audio_sync->tick != 1 + ? ABS(diff_mtu) > ((float)frame_mtu * 0.2f) + : 0, + (double)ABS(diff_mtu), + (double)((float)frame_mtu * 0.2f)); #endif - //TRACE(2,"audio_sync tune %d/%d tick", app_tws_ibrt_audio_sync_tune_onprocess(), a2dp_audio_sync_tune_onprocess(), audio_sync->tick); + // TRACE(2,"audio_sync tune %d/%d tick", + // app_tws_ibrt_audio_sync_tune_onprocess(), + // a2dp_audio_sync_tune_onprocess(), audio_sync->tick); #if defined(IBRT) - if ((!app_tws_ibrt_audio_sync_tune_onprocess() && - !a2dp_audio_sync_tune_onprocess()) && + if ((!app_tws_ibrt_audio_sync_tune_onprocess() && + !a2dp_audio_sync_tune_onprocess()) && #else - if (!a2dp_audio_sync_tune_onprocess() && + if (!a2dp_audio_sync_tune_onprocess() && #endif - diff_mtu != 0.f && audio_sync->tick != 1 && - ((ABS(diff_mtu) > ((float)frame_mtu * 0.25f) && diff_mtu > 0)|| - (ABS(diff_mtu) > ((float)frame_mtu * 0.1f) && diff_mtu < 0))){ - diff_factor = diff_mtu/a2dp_audio_context.average_packet_mut; - if (a2dp_audio_sync_pid_calc(pid, diff_factor)){ - dest_pid_result = a2dp_audio_context.output_cfg.factor_reference + pid->result; + diff_mtu != 0.f && audio_sync->tick != 1 && + ((ABS(diff_mtu) > ((float)frame_mtu * 0.25f) && diff_mtu > 0) || + (ABS(diff_mtu) > ((float)frame_mtu * 0.1f) && diff_mtu < 0))) { + diff_factor = diff_mtu / a2dp_audio_context.average_packet_mut; + if (a2dp_audio_sync_pid_calc(pid, diff_factor)) { + dest_pid_result = + a2dp_audio_context.output_cfg.factor_reference + pid->result; - if (dest_pid_result > (A2DP_AUDIO_SYNC_FACTOR_REFERENCE + A2DP_AUDIO_SYNC_FACTOR_FAST_LIMIT)){ - dest_pid_result = A2DP_AUDIO_SYNC_FACTOR_REFERENCE + A2DP_AUDIO_SYNC_FACTOR_FAST_LIMIT; - }else if (dest_pid_result < (A2DP_AUDIO_SYNC_FACTOR_REFERENCE + A2DP_AUDIO_SYNC_FACTOR_SLOW_LIMIT)){ - dest_pid_result = A2DP_AUDIO_SYNC_FACTOR_REFERENCE + A2DP_AUDIO_SYNC_FACTOR_SLOW_LIMIT; - } + if (dest_pid_result > (A2DP_AUDIO_SYNC_FACTOR_REFERENCE + + A2DP_AUDIO_SYNC_FACTOR_FAST_LIMIT)) { + dest_pid_result = A2DP_AUDIO_SYNC_FACTOR_REFERENCE + + A2DP_AUDIO_SYNC_FACTOR_FAST_LIMIT; + } else if (dest_pid_result < (A2DP_AUDIO_SYNC_FACTOR_REFERENCE + + A2DP_AUDIO_SYNC_FACTOR_SLOW_LIMIT)) { + dest_pid_result = A2DP_AUDIO_SYNC_FACTOR_REFERENCE + + A2DP_AUDIO_SYNC_FACTOR_SLOW_LIMIT; + } - if (a2dp_audio_context.output_cfg.factor_reference != dest_pid_result){ - if (!a2dp_audio_sync_tune(dest_pid_result)){ - audio_sync->cnt = 0; - } - TRACE_A2DP_DECODER_I("[SYNC] tune diff_factor:%10.9f pid:%10.9f tune:%10.9f", (double)diff_factor, (double)pid->result, (double)dest_pid_result); - }else{ - TRACE_A2DP_DECODER_I("[SYNC] tune skip same"); - } - } - }else{ -/* - TRACE_A2DP_DECODER_I("[SYNC] tune busy skip proc:%d/%d mtu:%d tick:%d >0:%d <0:%d tick:%d", app_tws_ibrt_audio_sync_tune_onprocess(), - a2dp_audio_sync_tune_onprocess(), - diff_mtu != 0.f, - audio_sync->tick != 1, - (ABS(diff_mtu) > ((float)frame_mtu * 0.25f) && diff_mtu > 0), - (ABS(diff_mtu) > ((float)frame_mtu * 0.1f) && diff_mtu < 0), - audio_sync->tick); -*/ - } - }else{ - bool need_tune = false; - if (lastframe_info->undecode_min_frames*10 <= a2dp_audio_context.dest_packet_mut*10/3){ - dest_pid_result = a2dp_audio_context.init_factor_reference + A2DP_AUDIO_SYNC_FACTOR_NEED_FAST_CACHE; - need_tune = true; - }else if (lastframe_info->undecode_min_frames*10 <= a2dp_audio_context.dest_packet_mut*20/3){ - dest_pid_result = a2dp_audio_context.init_factor_reference + A2DP_AUDIO_SYNC_FACTOR_SLOW_LIMIT; - need_tune = true; - } -#if defined(IBRT) - if (!app_tws_ibrt_audio_sync_tune_onprocess() && - !a2dp_audio_sync_tune_onprocess() && -#else - if (!a2dp_audio_sync_tune_onprocess() && -#endif - - need_tune){ - if (a2dp_audio_context.output_cfg.factor_reference != dest_pid_result){ - a2dp_audio_sync_reset_data(); - a2dp_audio_sync_tune(dest_pid_result); - TRACE_A2DP_DECODER_I("[SYNC] tune ratio force slow %d/%d->%d", lastframe_info->undecode_min_frames, - lastframe_info->undecode_max_frames, - a2dp_audio_context.dest_packet_mut); - } + if (a2dp_audio_context.output_cfg.factor_reference != dest_pid_result) { + if (!a2dp_audio_sync_tune(dest_pid_result)) { + audio_sync->cnt = 0; + } + TRACE_A2DP_DECODER_I( + "[SYNC] tune diff_factor:%10.9f pid:%10.9f tune:%10.9f", + (double)diff_factor, (double)pid->result, + (double)dest_pid_result); + } else { + TRACE_A2DP_DECODER_I("[SYNC] tune skip same"); } + } + } else { + /* + TRACE_A2DP_DECODER_I("[SYNC] tune busy skip proc:%d/%d mtu:%d + tick:%d >0:%d <0:%d tick:%d", app_tws_ibrt_audio_sync_tune_onprocess(), + a2dp_audio_sync_tune_onprocess(), + diff_mtu != 0.f, + audio_sync->tick != 1, + (ABS(diff_mtu) > + ((float)frame_mtu * 0.25f) && diff_mtu > 0), (ABS(diff_mtu) > + ((float)frame_mtu * 0.1f) && diff_mtu < 0), audio_sync->tick); + */ } - return 0; + } else { + bool need_tune = false; + if (lastframe_info->undecode_min_frames * 10 <= + a2dp_audio_context.dest_packet_mut * 10 / 3) { + dest_pid_result = a2dp_audio_context.init_factor_reference + + A2DP_AUDIO_SYNC_FACTOR_NEED_FAST_CACHE; + need_tune = true; + } else if (lastframe_info->undecode_min_frames * 10 <= + a2dp_audio_context.dest_packet_mut * 20 / 3) { + dest_pid_result = a2dp_audio_context.init_factor_reference + + A2DP_AUDIO_SYNC_FACTOR_SLOW_LIMIT; + need_tune = true; + } +#if defined(IBRT) + if (!app_tws_ibrt_audio_sync_tune_onprocess() && + !a2dp_audio_sync_tune_onprocess() && +#else + if (!a2dp_audio_sync_tune_onprocess() && +#endif + + need_tune) { + if (a2dp_audio_context.output_cfg.factor_reference != dest_pid_result) { + a2dp_audio_sync_reset_data(); + a2dp_audio_sync_tune(dest_pid_result); + TRACE_A2DP_DECODER_I("[SYNC] tune ratio force slow %d/%d->%d", + lastframe_info->undecode_min_frames, + lastframe_info->undecode_max_frames, + a2dp_audio_context.dest_packet_mut); + } + } + } + return 0; } #endif #if A2DP_DECODER_HISTORY_SEQ_SAVE -static int a2dp_audio_reset_history_seq(void) -{ - a2dp_audio_status_mutex_lock(); - for (uint8_t i=0; isequenceNumber - historySeqPre)!= 1){ - TRACE_A2DP_DECODER_W("[INPUT] SEQ ERR %d/%d",historySeqPre, header->sequenceNumber); - a2dp_audio_show_history_seq(); - } + a2dp_audio_status_mutex_lock(); + historySeq_idx = a2dp_audio_context.historySeq_idx; + if (historySeq_idx) { + historySeq_idx = (historySeq_idx - 1) % A2DP_DECODER_HISTORY_SEQ_SAVE; + historySeqPre = a2dp_audio_context.historySeq[historySeq_idx]; + if ((header->sequenceNumber - historySeqPre) != 1) { + TRACE_A2DP_DECODER_W("[INPUT] SEQ ERR %d/%d", historySeqPre, + header->sequenceNumber); + a2dp_audio_show_history_seq(); } - historySeq_idx = a2dp_audio_context.historySeq_idx%A2DP_DECODER_HISTORY_SEQ_SAVE; - a2dp_audio_context.historySeq[historySeq_idx] = header->sequenceNumber; + } + historySeq_idx = + a2dp_audio_context.historySeq_idx % A2DP_DECODER_HISTORY_SEQ_SAVE; + a2dp_audio_context.historySeq[historySeq_idx] = header->sequenceNumber; #ifdef A2DP_DECODER_HISTORY_LOCTIME_SAVE - a2dp_audio_context.historyLoctime[historySeq_idx] = hal_fast_sys_timer_get(); + a2dp_audio_context.historyLoctime[historySeq_idx] = hal_fast_sys_timer_get(); #endif #ifdef A2DP_DECODER_HISTORY_CHECK_SUM_SAVE - a2dp_audio_context.historyChecksum[historySeq_idx] = crc32(0, buf, len); + a2dp_audio_context.historyChecksum[historySeq_idx] = crc32(0, buf, len); #endif - a2dp_audio_context.historySeq_idx++; - a2dp_audio_status_mutex_unlock(); + a2dp_audio_context.historySeq_idx++; + a2dp_audio_status_mutex_unlock(); - return 0; + return 0; } -int a2dp_audio_show_history_seq(void) -{ - uint8_t i = 0, j = 1; - uint16_t reordHistorySeq[A2DP_DECODER_HISTORY_SEQ_SAVE]; +int a2dp_audio_show_history_seq(void) { + uint8_t i = 0, j = 1; + uint16_t reordHistorySeq[A2DP_DECODER_HISTORY_SEQ_SAVE]; #ifdef A2DP_DECODER_HISTORY_LOCTIME_SAVE - int32_t diff_max_idx = 0; - int32_t diff_max_ms = 0; - int64_t diff_avg_ms = 0; - int32_t diff_avg_cnt = 0; - uint32_t historyLoctime[A2DP_DECODER_HISTORY_SEQ_SAVE]; + int32_t diff_max_idx = 0; + int32_t diff_max_ms = 0; + int64_t diff_avg_ms = 0; + int32_t diff_avg_cnt = 0; + uint32_t historyLoctime[A2DP_DECODER_HISTORY_SEQ_SAVE]; #endif #ifdef A2DP_DECODER_HISTORY_CHECK_SUM_SAVE - uint32_t historyChecksum[A2DP_DECODER_HISTORY_SEQ_SAVE]; + uint32_t historyChecksum[A2DP_DECODER_HISTORY_SEQ_SAVE]; #endif - a2dp_audio_status_mutex_lock(); - for (i=0; i reordHistorySeq[j+1]) { - uint16_t temp_seq = reordHistorySeq[j]; - reordHistorySeq[j] = reordHistorySeq[j+1]; - reordHistorySeq[j+1] = temp_seq; + for (i = 0; i < A2DP_DECODER_HISTORY_SEQ_SAVE - 1; i++) { + for (j = 0; j < A2DP_DECODER_HISTORY_SEQ_SAVE - 1 - i; j++) { + if (reordHistorySeq[j] > reordHistorySeq[j + 1]) { + uint16_t temp_seq = reordHistorySeq[j]; + reordHistorySeq[j] = reordHistorySeq[j + 1]; + reordHistorySeq[j + 1] = temp_seq; #ifdef A2DP_DECODER_HISTORY_LOCTIME_SAVE - uint32_t temp_Loctime = historyLoctime[j]; - historyLoctime[j] = historyLoctime[j+1]; - historyLoctime[j+1] = temp_Loctime; + uint32_t temp_Loctime = historyLoctime[j]; + historyLoctime[j] = historyLoctime[j + 1]; + historyLoctime[j + 1] = temp_Loctime; #endif #ifdef A2DP_DECODER_HISTORY_CHECK_SUM_SAVE - uint32_t temp_Checksum = historyChecksum[j]; - historyChecksum[j] = historyChecksum[j+1]; - historyChecksum[j+1] = temp_Checksum; + uint32_t temp_Checksum = historyChecksum[j]; + historyChecksum[j] = historyChecksum[j + 1]; + historyChecksum[j + 1] = temp_Checksum; #endif - } - } + } } + } #ifdef A2DP_DECODER_HISTORY_LOCTIME_SAVE - for (i = 0, j = 1; i diff_max_ms){ - diff_max_ms = tmp_ms; - diff_max_idx = i; - } - if (tmp_ms > (int32_t)MS_TO_FAST_TICKS(50)){ - TRACE_A2DP_DECODER_I("[INPUT] > 30ms seq:%d diff:%d :%d / %d", reordHistorySeq[i], FAST_TICKS_TO_MS(tmp_ms), historyLoctime[i], historyLoctime[j]); - } + for (i = 0, j = 1; i < A2DP_DECODER_HISTORY_SEQ_SAVE - 1; i++, j++) { + int32_t tmp_ms = historyLoctime[j] - historyLoctime[i]; + diff_avg_ms += tmp_ms; + diff_avg_cnt++; + if (tmp_ms > diff_max_ms) { + diff_max_ms = tmp_ms; + diff_max_idx = i; } - diff_avg_ms /= diff_avg_cnt; - TRACE_A2DP_DECODER_I("[INPUT] max_diff:%dms idx:%d avg:%dus", FAST_TICKS_TO_MS(diff_max_ms), diff_max_idx, FAST_TICKS_TO_US(diff_avg_ms)); + if (tmp_ms > (int32_t)MS_TO_FAST_TICKS(50)) { + TRACE_A2DP_DECODER_I("[INPUT] > 30ms seq:%d diff:%d :%d / %d", + reordHistorySeq[i], FAST_TICKS_TO_MS(tmp_ms), + historyLoctime[i], historyLoctime[j]); + } + } + diff_avg_ms /= diff_avg_cnt; + TRACE_A2DP_DECODER_I("[INPUT] max_diff:%dms idx:%d avg:%dus", + FAST_TICKS_TO_MS(diff_max_ms), diff_max_idx, + FAST_TICKS_TO_US(diff_avg_ms)); #endif // DUMP16("%d ", reordHistorySeq, A2DP_DECODER_HISTORY_SEQ_SAVE); #ifdef A2DP_DECODER_HISTORY_LOCTIME_SAVE - DUMP32("%x ", historyLoctime, A2DP_DECODER_HISTORY_SEQ_SAVE); + DUMP32("%x ", historyLoctime, A2DP_DECODER_HISTORY_SEQ_SAVE); #endif #ifdef A2DP_DECODER_HISTORY_CHECK_SUM_SAVE - DUMP32("%x ", historyChecksum, A2DP_DECODER_HISTORY_SEQ_SAVE); + DUMP32("%x ", historyChecksum, A2DP_DECODER_HISTORY_SEQ_SAVE); #endif - a2dp_audio_status_mutex_unlock(); + a2dp_audio_status_mutex_unlock(); - return 0; + return 0; } #endif @@ -1034,1003 +1042,1023 @@ int a2dp_audio_show_history_seq(void) #define AUDIO_ALPHA_PRAMS_1 (3) #define AUDIO_ALPHA_PRAMS_2 (4) -static inline float a2dp_audio_alpha_filter(float y, float x) -{ - if (y){ - y = ((AUDIO_ALPHA_PRAMS_1*y)+x)/AUDIO_ALPHA_PRAMS_2; - }else{ - y = x; - } - return y; +static inline float a2dp_audio_alpha_filter(float y, float x) { + if (y) { + y = ((AUDIO_ALPHA_PRAMS_1 * y) + x) / AUDIO_ALPHA_PRAMS_2; + } else { + y = x; + } + return y; } -static void inline a2dp_audio_convert_16bit_to_24bit(int32_t *out, int16_t *in, int len) -{ - for (int i = len - 1; i >= 0; i--) { - out[i] = ((int32_t)in[i] << 8); - } +static void inline a2dp_audio_convert_16bit_to_24bit(int32_t *out, int16_t *in, + int len) { + for (int i = len - 1; i >= 0; i--) { + out[i] = ((int32_t)in[i] << 8); + } } -static void inline a2dp_audio_channel_select(A2DP_AUDIO_CHANNEL_SELECT_E chnl_sel, uint8_t *buffer, uint32_t buffer_bytes) -{ - uint32_t samples; - uint32_t i; +static void inline a2dp_audio_channel_select( + A2DP_AUDIO_CHANNEL_SELECT_E chnl_sel, uint8_t *buffer, + uint32_t buffer_bytes) { + uint32_t samples; + uint32_t i; - ASSERT_A2DP_DECODER(a2dp_audio_context.output_cfg.num_channels == 2, "%s num_channels:%d", __func__, a2dp_audio_context.output_cfg.num_channels); + ASSERT_A2DP_DECODER(a2dp_audio_context.output_cfg.num_channels == 2, + "%s num_channels:%d", __func__, + a2dp_audio_context.output_cfg.num_channels); - if (a2dp_audio_context.output_cfg.bits_depth == 24){ - int32_t *buf_l_p = (int32_t *)buffer; - int32_t *buf_r_p = (int32_t *)buffer + 1; + if (a2dp_audio_context.output_cfg.bits_depth == 24) { + int32_t *buf_l_p = (int32_t *)buffer; + int32_t *buf_r_p = (int32_t *)buffer + 1; - samples = buffer_bytes/4/2; - switch (chnl_sel) - { - case A2DP_AUDIO_CHANNEL_SELECT_LRMERGE: - for (i = 0; i>1; - *buf_l_p = tmp_sample; - *buf_r_p = tmp_sample; - } - break; - case A2DP_AUDIO_CHANNEL_SELECT_LCHNL: - for (i = 0; i>1; - *buf_l_p = tmp_sample; - *buf_r_p = tmp_sample; - } - break; - case A2DP_AUDIO_CHANNEL_SELECT_LCHNL: - for (i = 0; i> 1; + *buf_l_p = tmp_sample; + *buf_r_p = tmp_sample; + } + break; + case A2DP_AUDIO_CHANNEL_SELECT_LCHNL: + for (i = 0; i < samples; i++, buf_l_p += 2, buf_r_p += 2) { + *buf_r_p = *buf_l_p; + } + break; + case A2DP_AUDIO_CHANNEL_SELECT_RCHNL: + for (i = 0; i < samples; i++, buf_l_p += 2, buf_r_p += 2) { + *buf_l_p = *buf_r_p; + } + break; + case A2DP_AUDIO_CHANNEL_SELECT_STEREO: + default: + break; } -} + } else { + int16_t *buf_l_p = (int16_t *)buffer; + int16_t *buf_r_p = (int16_t *)buffer + 1; + samples = buffer_bytes / 2 / 2; + switch (chnl_sel) { + case A2DP_AUDIO_CHANNEL_SELECT_LRMERGE: + for (i = 0; i < samples; i++, buf_l_p += 2, buf_r_p += 2) { + int16_t tmp_sample = ((int32_t)*buf_l_p + (int32_t)*buf_r_p) >> 1; + *buf_l_p = tmp_sample; + *buf_r_p = tmp_sample; + } + break; + case A2DP_AUDIO_CHANNEL_SELECT_LCHNL: + for (i = 0; i < samples; i++, buf_l_p += 2, buf_r_p += 2) { + *buf_r_p = *buf_l_p; + } + break; + case A2DP_AUDIO_CHANNEL_SELECT_RCHNL: + for (i = 0; i < samples; i++, buf_l_p += 2, buf_r_p += 2) { + *buf_l_p = *buf_r_p; + } + break; + case A2DP_AUDIO_CHANNEL_SELECT_STEREO: + default: + break; + } + } +} #ifdef A2DP_CP_ACCEL extern "C" bool is_cp_need_reset(void); extern uint32_t app_bt_stream_get_dma_buffer_samples(void); -static uint32_t get_cp_frame_mtus(A2DP_AUDIO_LASTFRAME_INFO_T* info) -{ - uint32_t cp_frame_mtus = app_bt_stream_get_dma_buffer_samples()/2; - if (cp_frame_mtus %(info->frame_samples) ){ - cp_frame_mtus = cp_frame_mtus /(info->frame_samples) +1; - }else{ - cp_frame_mtus = cp_frame_mtus /(info->frame_samples); - } +static uint32_t get_cp_frame_mtus(A2DP_AUDIO_LASTFRAME_INFO_T *info) { + uint32_t cp_frame_mtus = app_bt_stream_get_dma_buffer_samples() / 2; + if (cp_frame_mtus % (info->frame_samples)) { + cp_frame_mtus = cp_frame_mtus / (info->frame_samples) + 1; + } else { + cp_frame_mtus = cp_frame_mtus / (info->frame_samples); + } - TRACE_A2DP_DECODER_I("[CP] cp_frame_mtus:%d", cp_frame_mtus); + TRACE_A2DP_DECODER_I("[CP] cp_frame_mtus:%d", cp_frame_mtus); - return cp_frame_mtus; + return cp_frame_mtus; } #else -bool is_cp_need_reset(void) -{ - return false; -} - +bool is_cp_need_reset(void) { return false; } #endif -#define A2DP_AUDIO_SYSFREQ_BOOST_RESUME_CNT (20) +#define A2DP_AUDIO_SYSFREQ_BOOST_RESUME_CNT (20) uint32_t a2dp_audio_sysfreq_cnt = UINT32_MAX; uint32_t a2dp_audio_sysfreq_dest_boost_cnt = 0; APP_SYSFREQ_FREQ_T a2dp_audio_sysfreq_normalfreq = APP_SYSFREQ_52M; -int a2dp_audio_sysfreq_boost_init(uint32_t normalfreq) -{ +int a2dp_audio_sysfreq_boost_init(uint32_t normalfreq) { + a2dp_audio_sysfreq_cnt = UINT32_MAX; + a2dp_audio_sysfreq_dest_boost_cnt = 0; + a2dp_audio_sysfreq_normalfreq = (APP_SYSFREQ_FREQ_T)normalfreq; + TRACE_A2DP_DECODER_I("[BOOST] freq:%d", normalfreq); + return 0; +} + +int a2dp_audio_sysfreq_boost_start(uint32_t boost_cnt) { + enum APP_SYSFREQ_FREQ_T sysfreq = APP_SYSFREQ_104M; + + a2dp_audio_sysfreq_cnt = 0; + a2dp_audio_sysfreq_dest_boost_cnt = boost_cnt; + if (a2dp_audio_sysfreq_normalfreq >= APP_SYSFREQ_52M) { + sysfreq = APP_SYSFREQ_104M; + } else { + sysfreq = APP_SYSFREQ_52M; + } + TRACE_A2DP_DECODER_I("[BOOST] freq:%d cnt:%d", sysfreq, boost_cnt); + app_sysfreq_req(APP_SYSFREQ_USER_BT_A2DP, sysfreq); + return 0; +} + +static int a2dp_audio_sysfreq_boost_porc(void) { + if (a2dp_audio_sysfreq_cnt == UINT32_MAX) { + // do nothing + } else if (a2dp_audio_sysfreq_cnt >= a2dp_audio_sysfreq_dest_boost_cnt) { a2dp_audio_sysfreq_cnt = UINT32_MAX; - a2dp_audio_sysfreq_dest_boost_cnt = 0; - a2dp_audio_sysfreq_normalfreq = (APP_SYSFREQ_FREQ_T)normalfreq; - TRACE_A2DP_DECODER_I("[BOOST] freq:%d", normalfreq); - return 0; + TRACE_A2DP_DECODER_I("[BOOST] freq:%d", a2dp_audio_sysfreq_normalfreq); + app_sysfreq_req(APP_SYSFREQ_USER_BT_A2DP, a2dp_audio_sysfreq_normalfreq); + } else { + a2dp_audio_sysfreq_cnt++; + } + return 0; } -int a2dp_audio_sysfreq_boost_start(uint32_t boost_cnt) -{ - enum APP_SYSFREQ_FREQ_T sysfreq = APP_SYSFREQ_104M; - - a2dp_audio_sysfreq_cnt = 0; - a2dp_audio_sysfreq_dest_boost_cnt = boost_cnt; - if (a2dp_audio_sysfreq_normalfreq >= APP_SYSFREQ_52M){ - sysfreq = APP_SYSFREQ_104M; - }else{ - sysfreq = APP_SYSFREQ_52M; - } - TRACE_A2DP_DECODER_I("[BOOST] freq:%d cnt:%d", sysfreq, boost_cnt); - app_sysfreq_req(APP_SYSFREQ_USER_BT_A2DP, sysfreq); - return 0; +int a2dp_audio_sysfreq_boost_running(void) { + return a2dp_audio_sysfreq_cnt == UINT32_MAX ? 0 : 1; } -static int a2dp_audio_sysfreq_boost_porc(void) -{ - if (a2dp_audio_sysfreq_cnt == UINT32_MAX){ - //do nothing - }else if (a2dp_audio_sysfreq_cnt >= a2dp_audio_sysfreq_dest_boost_cnt){ - a2dp_audio_sysfreq_cnt = UINT32_MAX; - TRACE_A2DP_DECODER_I("[BOOST] freq:%d", a2dp_audio_sysfreq_normalfreq); - app_sysfreq_req(APP_SYSFREQ_USER_BT_A2DP, a2dp_audio_sysfreq_normalfreq); - }else{ - a2dp_audio_sysfreq_cnt++; - } - return 0; +int a2dp_audio_store_packet_checker_start(void) { + store_packet_history_loctime = 0; + return 0; } -int a2dp_audio_sysfreq_boost_running(void) -{ - return a2dp_audio_sysfreq_cnt == UINT32_MAX ? 0 : 1; -} +int a2dp_audio_store_packet_checker(btif_media_header_t *header) { + bool show_info = false; + uint32_t fast_sys_tick = hal_fast_sys_timer_get(); + int32_t tmp_ms = 0; -int a2dp_audio_store_packet_checker_start(void) -{ - store_packet_history_loctime = 0; - return 0; -} - -int a2dp_audio_store_packet_checker(btif_media_header_t *header) -{ - bool show_info = false; - uint32_t fast_sys_tick = hal_fast_sys_timer_get(); - int32_t tmp_ms = 0; - - if (store_packet_history_loctime){ - tmp_ms = fast_sys_tick - store_packet_history_loctime; - if (tmp_ms > (int32_t)MS_TO_FAST_TICKS(50)){ - show_info = true; - } + if (store_packet_history_loctime) { + tmp_ms = fast_sys_tick - store_packet_history_loctime; + if (tmp_ms > (int32_t)MS_TO_FAST_TICKS(50)) { + show_info = true; } + } - if (show_info){ - //TRACE_A2DP_DECODER_I("[INPUT] >50ms seq:%d diff:%d", header->sequenceNumber, FAST_TICKS_TO_MS(tmp_ms)); - a2dp_decoder_info_checker(); - } + if (show_info) { + // TRACE_A2DP_DECODER_I("[INPUT] >50ms seq:%d diff:%d", + // header->sequenceNumber, FAST_TICKS_TO_MS(tmp_ms)); + a2dp_decoder_info_checker(); + } - store_packet_history_loctime = fast_sys_tick; + store_packet_history_loctime = fast_sys_tick; - if (a2dp_audio_context.historySeq_idx && - ((a2dp_audio_context.historySeq_idx-1)%A2DP_DECODER_HISTORY_SEQ_SAVE == 0)){ - a2dp_audio_show_history_seq(); - } + if (a2dp_audio_context.historySeq_idx && + ((a2dp_audio_context.historySeq_idx - 1) % + A2DP_DECODER_HISTORY_SEQ_SAVE == + 0)) { + a2dp_audio_show_history_seq(); + } - return 0; + return 0; } //#define DECODER_ERR_TEST -int a2dp_audio_store_packet(btif_media_header_t * header, unsigned char *buf, unsigned int len) -{ - int nRet = A2DP_DECODER_NO_ERROR; +int a2dp_audio_store_packet(btif_media_header_t *header, unsigned char *buf, + unsigned int len) { + int nRet = A2DP_DECODER_NO_ERROR; + + if (a2dp_audio_get_status() == + A2DP_AUDIO_DECODER_STATUS_NULL) { // if mem deinit , drop data + return nRet; + } + a2dp_audio_status_mutex_lock(); - if( a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_NULL) - {//if mem deinit , drop data - return nRet; - } - a2dp_audio_status_mutex_lock(); - #ifdef DECODER_ERR_TEST - static uint16_t cnt = 0; - static uint16_t limit = 500; - cnt++; - if(cnt%limit==0){ - cnt = 0; - limit = rand()%500; - uint16_t len2 = rand()%len; - memset(buf+len-len2,0,len2); - TRACE_A2DP_DECODER_I("[INPUT] Fill Err!!!! seq:%d", header->sequenceNumber); - } + static uint16_t cnt = 0; + static uint16_t limit = 500; + cnt++; + if (cnt % limit == 0) { + cnt = 0; + limit = rand() % 500; + uint16_t len2 = rand() % len; + memset(buf + len - len2, 0, len2); + TRACE_A2DP_DECODER_I("[INPUT] Fill Err!!!! seq:%d", header->sequenceNumber); + } #endif #if A2DP_DECODER_HISTORY_SEQ_SAVE - a2dp_audio_save_history_seq(header, buf, len); + a2dp_audio_save_history_seq(header, buf, len); #endif - a2dp_audio_set_store_packet_status(A2DP_AUDIO_DECODER_STORE_PACKET_STATUS_BUSY); - if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START){ - a2dp_audio_store_packet_checker(header); - if (a2dp_audio_context.need_detect_first_packet){ - a2dp_audio_context.need_detect_first_packet = false; - a2dp_audio_context.audio_decoder.audio_decoder_preparse_packet(header, buf, len); - } + a2dp_audio_set_store_packet_status( + A2DP_AUDIO_DECODER_STORE_PACKET_STATUS_BUSY); + if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START) { + a2dp_audio_store_packet_checker(header); + if (a2dp_audio_context.need_detect_first_packet) { + a2dp_audio_context.need_detect_first_packet = false; + a2dp_audio_context.audio_decoder.audio_decoder_preparse_packet(header, + buf, len); + } - if (a2dp_audio_detect_next_packet_callback){ - a2dp_audio_detect_next_packet_callback(header, buf, len); - } + if (a2dp_audio_detect_next_packet_callback) { + a2dp_audio_detect_next_packet_callback(header, buf, len); + } - nRet = a2dp_audio_context.audio_decoder.audio_decoder_store_packet(header, buf, len); + nRet = a2dp_audio_context.audio_decoder.audio_decoder_store_packet( + header, buf, len); #if defined(IBRT) - if (is_cp_need_reset()){ - TRACE_A2DP_DECODER_I("[CP] find cp error need restart"); - app_ibrt_if_force_audio_retrigger(); - + if (is_cp_need_reset()) { + TRACE_A2DP_DECODER_I("[CP] find cp error need restart"); + app_ibrt_if_force_audio_retrigger(); + } + if (nRet == A2DP_DECODER_MTU_LIMTER_ERROR) { + if (app_tws_ibrt_mobile_link_connected()) { + // try again + // a2dp_audio_semaphore_wait(A2DP_AUDIO_WAIT_TIMEOUT_MS); + nRet = a2dp_audio_context.audio_decoder.audio_decoder_store_packet( + header, buf, len); + } + if (nRet == A2DP_DECODER_MTU_LIMTER_ERROR) { + int dest_discards_samples = 0; + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (p_ibrt_ctrl == NULL) { + return A2DP_DECODER_NOT_SUPPORT; } - if (nRet == A2DP_DECODER_MTU_LIMTER_ERROR){ - if (app_tws_ibrt_mobile_link_connected()){ - // try again - //a2dp_audio_semaphore_wait(A2DP_AUDIO_WAIT_TIMEOUT_MS); - nRet = a2dp_audio_context.audio_decoder.audio_decoder_store_packet(header, buf, len); - } - if (nRet == A2DP_DECODER_MTU_LIMTER_ERROR){ - int dest_discards_samples = 0; - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if(p_ibrt_ctrl == NULL) - { - return A2DP_DECODER_NOT_SUPPORT; - } - if (app_tws_ibrt_mobile_link_connected()){ - bt_syn_trig_checker(p_ibrt_ctrl->mobile_conhandle); - }else if (app_tws_ibrt_slave_ibrt_link_connected()){ - bt_syn_trig_checker(p_ibrt_ctrl->ibrt_conhandle); - } - dest_discards_samples = app_bt_stream_get_dma_buffer_samples()/2; - a2dp_audio_discards_samples(dest_discards_samples*2); - a2dp_audio_context.audio_decoder.audio_decoder_store_packet(header, buf, len); - TRACE_A2DP_DECODER_I("[INPUT] MTU_LIMTER so discards_packet"); - } + if (app_tws_ibrt_mobile_link_connected()) { + bt_syn_trig_checker(p_ibrt_ctrl->mobile_conhandle); + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + bt_syn_trig_checker(p_ibrt_ctrl->ibrt_conhandle); } + dest_discards_samples = app_bt_stream_get_dma_buffer_samples() / 2; + a2dp_audio_discards_samples(dest_discards_samples * 2); + a2dp_audio_context.audio_decoder.audio_decoder_store_packet(header, buf, + len); + TRACE_A2DP_DECODER_I("[INPUT] MTU_LIMTER so discards_packet"); + } + } #else - if (is_cp_need_reset()){ - TRACE_A2DP_DECODER_I("[CP] find cp error need restart"); - app_audio_decode_err_force_trigger(); - } + if (is_cp_need_reset()) { + TRACE_A2DP_DECODER_I("[CP] find cp error need restart"); + app_audio_decode_err_force_trigger(); + } - if (nRet == A2DP_DECODER_MTU_LIMTER_ERROR){ - a2dp_audio_synchronize_dest_packet_mut(a2dp_audio_context.dest_packet_mut); - a2dp_audio_context.audio_decoder.audio_decoder_store_packet(header, buf, len); - TRACE_A2DP_DECODER_W("[INPUT] MTU_LIMTER so discards_packet"); - } + if (nRet == A2DP_DECODER_MTU_LIMTER_ERROR) { + a2dp_audio_synchronize_dest_packet_mut( + a2dp_audio_context.dest_packet_mut); + a2dp_audio_context.audio_decoder.audio_decoder_store_packet(header, buf, + len); + TRACE_A2DP_DECODER_W("[INPUT] MTU_LIMTER so discards_packet"); + } #endif - }else{ - TRACE(2,"[INPUT] skip packet status:%d", a2dp_audio_get_status()); - } + } else { + TRACE(2, "[INPUT] skip packet status:%d", a2dp_audio_get_status()); + } - if (a2dp_audio_store_packet_callback){ - a2dp_audio_store_packet_callback(header, buf, len); - } + if (a2dp_audio_store_packet_callback) { + a2dp_audio_store_packet_callback(header, buf, len); + } - a2dp_audio_set_store_packet_status(A2DP_AUDIO_DECODER_STORE_PACKET_STATUS_IDLE); - a2dp_audio_status_mutex_unlock(); - return 0; + a2dp_audio_set_store_packet_status( + A2DP_AUDIO_DECODER_STORE_PACKET_STATUS_IDLE); + a2dp_audio_status_mutex_unlock(); + return 0; } -uint32_t a2dp_audio_playback_handler(uint8_t *buffer, uint32_t buffer_bytes) -{ - uint32_t len = buffer_bytes; - int nRet = A2DP_DECODER_NO_ERROR; - A2DP_AUDIO_LASTFRAME_INFO_T *lastframe_info = NULL; - list_t *list = a2dp_audio_context.audio_datapath.input_raw_packet_list; +uint32_t a2dp_audio_playback_handler(uint8_t *buffer, uint32_t buffer_bytes) { + uint32_t len = buffer_bytes; + int nRet = A2DP_DECODER_NO_ERROR; + A2DP_AUDIO_LASTFRAME_INFO_T *lastframe_info = NULL; + list_t *list = a2dp_audio_context.audio_datapath.input_raw_packet_list; - a2dp_audio_set_playback_status(A2DP_AUDIO_DECODER_PLAYBACK_STATUS_BUSY); - if (a2dp_audio_get_status() != A2DP_AUDIO_DECODER_STATUS_START){ - TRACE_A2DP_DECODER_W("[PLAYBACK] skip handler status:%d", a2dp_audio_get_status()); - goto exit; - } + a2dp_audio_set_playback_status(A2DP_AUDIO_DECODER_PLAYBACK_STATUS_BUSY); + if (a2dp_audio_get_status() != A2DP_AUDIO_DECODER_STATUS_START) { + TRACE_A2DP_DECODER_W("[PLAYBACK] skip handler status:%d", + a2dp_audio_get_status()); + goto exit; + } - a2dp_audio_sysfreq_boost_porc(); - if (a2dp_audio_context.average_packet_mut == 0){ - A2DP_AUDIO_HEADFRAME_INFO_T headframe_info; - a2dp_audio_decoder_headframe_info_get(&headframe_info); - a2dp_audio_context.average_packet_mut = a2dp_audio_list_length(list); - TRACE_A2DP_DECODER_I("[PLAYBACK] init average_packet_mut:%d seq:%d", (uint16_t)(a2dp_audio_context.average_packet_mut+0.5f), headframe_info.sequenceNumber); - }else{ - if (!a2dp_audio_refill_packet()){ - uint16_t packet_mut = 0; - if (!a2dp_audio_internal_lastframe_info_ptr_get(&lastframe_info)){ - packet_mut = a2dp_audio_list_length(list) + get_in_cp_frame_cnt() + get_in_cp_frame_delay() * (lastframe_info->frame_samples /lastframe_info->list_samples); - a2dp_audio_context.average_packet_mut = a2dp_audio_alpha_filter((float)a2dp_audio_context.average_packet_mut, (float)packet_mut); - a2dp_audio_sync_handler(buffer, buffer_bytes); - } - } + a2dp_audio_sysfreq_boost_porc(); + if (a2dp_audio_context.average_packet_mut == 0) { + A2DP_AUDIO_HEADFRAME_INFO_T headframe_info; + a2dp_audio_decoder_headframe_info_get(&headframe_info); + a2dp_audio_context.average_packet_mut = a2dp_audio_list_length(list); + TRACE_A2DP_DECODER_I( + "[PLAYBACK] init average_packet_mut:%d seq:%d", + (uint16_t)(a2dp_audio_context.average_packet_mut + 0.5f), + headframe_info.sequenceNumber); + } else { + if (!a2dp_audio_refill_packet()) { + uint16_t packet_mut = 0; + if (!a2dp_audio_internal_lastframe_info_ptr_get(&lastframe_info)) { + packet_mut = a2dp_audio_list_length(list) + get_in_cp_frame_cnt() + + get_in_cp_frame_delay() * (lastframe_info->frame_samples / + lastframe_info->list_samples); + a2dp_audio_context.average_packet_mut = a2dp_audio_alpha_filter( + (float)a2dp_audio_context.average_packet_mut, (float)packet_mut); + a2dp_audio_sync_handler(buffer, buffer_bytes); + } } + } #if defined(A2DP_AUDIO_REFILL_AFTER_NO_CACHE) - if (a2dp_audio_context.skip_frame_cnt_after_no_cache){ + if (a2dp_audio_context.skip_frame_cnt_after_no_cache) { #if defined(A2DP_CP_ACCEL) uint32_t cp_delay_mtus = get_in_cp_frame_delay(); - cp_delay_mtus *= get_cp_frame_mtus(&a2dp_audio_lastframe_info); - if (a2dp_audio_list_length(list) >= (a2dp_audio_context.dest_packet_mut - cp_delay_mtus)){ - a2dp_audio_context.skip_frame_cnt_after_no_cache = 0; + cp_delay_mtus *= get_cp_frame_mtus(&a2dp_audio_lastframe_info); + if (a2dp_audio_list_length(list) >= + (a2dp_audio_context.dest_packet_mut - cp_delay_mtus)) { + a2dp_audio_context.skip_frame_cnt_after_no_cache = 0; } #else - if (a2dp_audio_list_length(list) >= a2dp_audio_context.dest_packet_mut){ - a2dp_audio_context.skip_frame_cnt_after_no_cache = 0; - } -#endif - - memset(buffer, 0, buffer_bytes); - TRACE_A2DP_DECODER_I("[PLAYBACK] decode refill skip_cnt:%d, list:%d", a2dp_audio_context.skip_frame_cnt_after_no_cache, a2dp_audio_list_length(list)); - a2dp_decoder_info_checker(); - if (a2dp_audio_context.skip_frame_cnt_after_no_cache > 0){ - a2dp_audio_context.skip_frame_cnt_after_no_cache--; - }else{ - a2dp_audio_context.mute_frame_cnt_after_no_cache = A2DP_AUDIO_MUTE_FRAME_CNT_AFTER_NO_CACHE; - } - }else -#endif - { - if (a2dp_audio_context.output_cfg.bits_depth == 24 && - 16 == bt_sbc_player_get_sample_bit()){ - - len = len / (sizeof(int32_t) / sizeof(int16_t)); - - nRet = a2dp_audio_context.audio_decoder.audio_decoder_decode_frame(buffer, len); - if (nRet < 0 || a2dp_audio_context.mute_frame_cnt_after_no_cache){ - TRACE_A2DP_DECODER_I("[PLAYBACK] decode failed nRet=%d mute_cnt:%d", nRet, a2dp_audio_context.mute_frame_cnt_after_no_cache); - a2dp_decoder_info_checker(); - //mute frame - memset(buffer, 0, len); - } - a2dp_audio_convert_16bit_to_24bit((int32_t *)buffer, (int16_t *)buffer, len / sizeof(int16_t)); - - // Restore len to 24-bit sample buffer length - len = len * (sizeof(int32_t) / sizeof(int16_t)); - - }else if (a2dp_audio_context.output_cfg.bits_depth == - a2dp_audio_context.audio_decoder.stream_info.bits_depth){ - - nRet = a2dp_audio_context.audio_decoder.audio_decoder_decode_frame(buffer, len); - if (nRet < 0 || a2dp_audio_context.mute_frame_cnt_after_no_cache){ - //mute frame - TRACE_A2DP_DECODER_I("[PLAYBACK] decode failed nRet=%d mute_cnt:%d", nRet, a2dp_audio_context.mute_frame_cnt_after_no_cache); - a2dp_decoder_info_checker(); - memset(buffer, 0, len); - } - - } - a2dp_audio_channel_select(a2dp_audio_context.chnl_sel, buffer, buffer_bytes); + if (a2dp_audio_list_length(list) >= a2dp_audio_context.dest_packet_mut) { + a2dp_audio_context.skip_frame_cnt_after_no_cache = 0; } - a2dp_audio_semaphore_release(); +#endif - if (nRet == A2DP_DECODER_CACHE_UNDERFLOW_ERROR) - { - if (a2dp_audio_internal_lastframe_info_ptr_get(&lastframe_info) < 0) - { - goto exit; - } - TRACE(2,"CACHE_UNDERFLOW lastseq:%d ftick:%d", lastframe_info->sequenceNumber, hal_fast_sys_timer_get()); - a2dp_audio_show_history_seq(); - uint32_t mute_frames = A2DP_AUDIO_MUTE_FRAME_CNT_AFTER_NO_CACHE; - uint32_t skip_frames = A2DP_AUDIO_SKIP_FRAME_LIMIT_AFTER_NO_CACHE - get_in_cp_frame_delay(); - a2dp_audio_context.mute_frame_cnt_after_no_cache = (uint32_t)((float)mute_frames * - a2dp_audio_latency_factor_get()); - a2dp_audio_context.skip_frame_cnt_after_no_cache = (uint32_t)((float)skip_frames * - a2dp_audio_latency_factor_get()); + memset(buffer, 0, buffer_bytes); + TRACE_A2DP_DECODER_I("[PLAYBACK] decode refill skip_cnt:%d, list:%d", + a2dp_audio_context.skip_frame_cnt_after_no_cache, + a2dp_audio_list_length(list)); + a2dp_decoder_info_checker(); + if (a2dp_audio_context.skip_frame_cnt_after_no_cache > 0) { + a2dp_audio_context.skip_frame_cnt_after_no_cache--; + } else { + a2dp_audio_context.mute_frame_cnt_after_no_cache = + A2DP_AUDIO_MUTE_FRAME_CNT_AFTER_NO_CACHE; + } + } else +#endif + { + if (a2dp_audio_context.output_cfg.bits_depth == 24 && + 16 == bt_sbc_player_get_sample_bit()) { - a2dp_audio_context.average_packet_mut = 0; - a2dp_audio_sync_reset_data(); + len = len / (sizeof(int32_t) / sizeof(int16_t)); + + nRet = a2dp_audio_context.audio_decoder.audio_decoder_decode_frame(buffer, + len); + if (nRet < 0 || a2dp_audio_context.mute_frame_cnt_after_no_cache) { + TRACE_A2DP_DECODER_I("[PLAYBACK] decode failed nRet=%d mute_cnt:%d", + nRet, + a2dp_audio_context.mute_frame_cnt_after_no_cache); + a2dp_decoder_info_checker(); + // mute frame + memset(buffer, 0, len); + } + a2dp_audio_convert_16bit_to_24bit((int32_t *)buffer, (int16_t *)buffer, + len / sizeof(int16_t)); + + // Restore len to 24-bit sample buffer length + len = len * (sizeof(int32_t) / sizeof(int16_t)); + + } else if (a2dp_audio_context.output_cfg.bits_depth == + a2dp_audio_context.audio_decoder.stream_info.bits_depth) { + + nRet = a2dp_audio_context.audio_decoder.audio_decoder_decode_frame(buffer, + len); + if (nRet < 0 || a2dp_audio_context.mute_frame_cnt_after_no_cache) { + // mute frame + TRACE_A2DP_DECODER_I("[PLAYBACK] decode failed nRet=%d mute_cnt:%d", + nRet, + a2dp_audio_context.mute_frame_cnt_after_no_cache); + a2dp_decoder_info_checker(); + memset(buffer, 0, len); + } + } + a2dp_audio_channel_select(a2dp_audio_context.chnl_sel, buffer, + buffer_bytes); + } + a2dp_audio_semaphore_release(); + + if (nRet == A2DP_DECODER_CACHE_UNDERFLOW_ERROR) { + if (a2dp_audio_internal_lastframe_info_ptr_get(&lastframe_info) < 0) { + goto exit; + } + TRACE(2, "CACHE_UNDERFLOW lastseq:%d ftick:%d", + lastframe_info->sequenceNumber, hal_fast_sys_timer_get()); + a2dp_audio_show_history_seq(); + uint32_t mute_frames = A2DP_AUDIO_MUTE_FRAME_CNT_AFTER_NO_CACHE; + uint32_t skip_frames = + A2DP_AUDIO_SKIP_FRAME_LIMIT_AFTER_NO_CACHE - get_in_cp_frame_delay(); + a2dp_audio_context.mute_frame_cnt_after_no_cache = + (uint32_t)((float)mute_frames * a2dp_audio_latency_factor_get()); + a2dp_audio_context.skip_frame_cnt_after_no_cache = + (uint32_t)((float)skip_frames * a2dp_audio_latency_factor_get()); + + a2dp_audio_context.average_packet_mut = 0; + a2dp_audio_sync_reset_data(); #if defined(IBRT) - a2dp_audio_sync_tune_sample_rate(app_tws_ibrt_audio_sync_config_factor_reference_get()); + a2dp_audio_sync_tune_sample_rate( + app_tws_ibrt_audio_sync_config_factor_reference_get()); #else - a2dp_audio_sync_tune_sample_rate(a2dp_audio_context.init_factor_reference); + a2dp_audio_sync_tune_sample_rate(a2dp_audio_context.init_factor_reference); #endif - a2dp_decoder_info_checker(); - }else{ - if (a2dp_audio_context.mute_frame_cnt_after_no_cache > 0){ - a2dp_audio_context.mute_frame_cnt_after_no_cache--; - a2dp_audio_context.average_packet_mut = 0; - if (a2dp_audio_context.mute_frame_cnt_after_no_cache >= 1){ - a2dp_audio_synchronize_dest_packet_mut(a2dp_audio_context.dest_packet_mut); - } - } - } - if (!a2dp_audio_internal_lastframe_info_ptr_get(&lastframe_info)){ - lastframe_info->stream_info.factor_reference = a2dp_audio_context.output_cfg.factor_reference; - lastframe_info->average_frames = (uint32_t)(a2dp_audio_context.average_packet_mut + 0.5f); + a2dp_decoder_info_checker(); + } else { + if (a2dp_audio_context.mute_frame_cnt_after_no_cache > 0) { + a2dp_audio_context.mute_frame_cnt_after_no_cache--; + a2dp_audio_context.average_packet_mut = 0; + if (a2dp_audio_context.mute_frame_cnt_after_no_cache >= 1) { + a2dp_audio_synchronize_dest_packet_mut( + a2dp_audio_context.dest_packet_mut); + } } + } + if (!a2dp_audio_internal_lastframe_info_ptr_get(&lastframe_info)) { + lastframe_info->stream_info.factor_reference = + a2dp_audio_context.output_cfg.factor_reference; + lastframe_info->average_frames = + (uint32_t)(a2dp_audio_context.average_packet_mut + 0.5f); + } exit: - a2dp_audio_set_playback_status(A2DP_AUDIO_DECODER_PLAYBACK_STATUS_IDLE); + a2dp_audio_set_playback_status(A2DP_AUDIO_DECODER_PLAYBACK_STATUS_IDLE); #if defined(IBRT) - if (nRet == A2DP_DECODER_CACHE_UNDERFLOW_ERROR){ + if (nRet == A2DP_DECODER_CACHE_UNDERFLOW_ERROR) { #if defined(A2DP_AUDIO_UNDERFLOW_CAUSE_AUDIO_RETRIGGER) - bool force_audio_retrigger = true; + bool force_audio_retrigger = true; #else - bool force_audio_retrigger = false; + bool force_audio_retrigger = false; #endif - if (a2dp_audio_latency_factor_get() == A2DP_AUDIO_LATENCY_LOW_FACTOR && - app_tws_ibrt_mobile_link_connected()){ - a2dp_audio_latency_factor_sethigh(); - if (app_tws_ibrt_tws_link_connected() && - app_ibrt_ui_is_profile_exchanged()){ - float latency_factor = a2dp_audio_latency_factor_get(); - tws_ctrl_send_cmd(APP_TWS_CMD_SET_LATENCYFACTOR, (uint8_t*)&latency_factor, sizeof(latency_factor)); - force_audio_retrigger = true; - } - } - if (force_audio_retrigger && !a2dp_audio_context.underflow_onporcess){ - a2dp_audio_context.underflow_onporcess = true; - app_ibrt_if_force_audio_retrigger(); - } + if (a2dp_audio_latency_factor_get() == A2DP_AUDIO_LATENCY_LOW_FACTOR && + app_tws_ibrt_mobile_link_connected()) { + a2dp_audio_latency_factor_sethigh(); + if (app_tws_ibrt_tws_link_connected() && + app_ibrt_ui_is_profile_exchanged()) { + float latency_factor = a2dp_audio_latency_factor_get(); + tws_ctrl_send_cmd(APP_TWS_CMD_SET_LATENCYFACTOR, + (uint8_t *)&latency_factor, sizeof(latency_factor)); + force_audio_retrigger = true; + } } + if (force_audio_retrigger && !a2dp_audio_context.underflow_onporcess) { + a2dp_audio_context.underflow_onporcess = true; + app_ibrt_if_force_audio_retrigger(); + } + } #else - if (nRet == A2DP_DECODER_CACHE_UNDERFLOW_ERROR){ - app_audio_decode_err_force_trigger(); - } + if (nRet == A2DP_DECODER_CACHE_UNDERFLOW_ERROR) { + app_audio_decode_err_force_trigger(); + } #endif - return len; + return len; } -static void a2dp_audio_packet_free(void *packet) -{ - if (a2dp_audio_context.audio_decoder.audio_decoder_packet_free){ - a2dp_audio_context.audio_decoder.audio_decoder_packet_free(packet); - }else{ - a2dp_audio_heap_free(packet); - } +static void a2dp_audio_packet_free(void *packet) { + if (a2dp_audio_context.audio_decoder.audio_decoder_packet_free) { + a2dp_audio_context.audio_decoder.audio_decoder_packet_free(packet); + } else { + a2dp_audio_heap_free(packet); + } } -void a2dp_audio_clear_input_raw_packet_list(void) -{ - //just clean the packet list to start receive ai data again - if(a2dp_audio_context.audio_datapath.input_raw_packet_list) - a2dp_audio_list_clear(a2dp_audio_context.audio_datapath.input_raw_packet_list); +void a2dp_audio_clear_input_raw_packet_list(void) { + // just clean the packet list to start receive ai data again + if (a2dp_audio_context.audio_datapath.input_raw_packet_list) + a2dp_audio_list_clear( + a2dp_audio_context.audio_datapath.input_raw_packet_list); } -int a2dp_audio_init(uint32_t sysfreq, A2DP_AUDIO_CODEC_TYPE codec_type, A2DP_AUDIO_OUTPUT_CONFIG_T *config, A2DP_AUDIO_CHANNEL_SELECT_E chnl_sel, uint16_t dest_packet_mut) -{ - uint8_t *heap_buff = NULL; - uint32_t heap_size = 0; - double ratio = 0; +int a2dp_audio_init(uint32_t sysfreq, A2DP_AUDIO_CODEC_TYPE codec_type, + A2DP_AUDIO_OUTPUT_CONFIG_T *config, + A2DP_AUDIO_CHANNEL_SELECT_E chnl_sel, + uint16_t dest_packet_mut) { + uint8_t *heap_buff = NULL; + uint32_t heap_size = 0; + double ratio = 0; - A2DP_AUDIO_OUTPUT_CONFIG_T decoder_output_config; - TRACE_A2DP_DECODER_I("[INIT] freq:%d codec:%d chnl:%d", sysfreq, codec_type, chnl_sel); - TRACE_A2DP_DECODER_I("[INIT] out:%d-%d-%d smp:%d dest:%d", - config->sample_rate, - config->num_channels, - config->bits_depth, - config->frame_samples, - dest_packet_mut); - a2dp_audio_sysfreq_boost_init(sysfreq); - a2dp_audio_sysfreq_boost_start(A2DP_AUDIO_SYSFREQ_BOOST_RESUME_CNT); - a2dp_audio_semaphore_init(); - a2dp_audio_buffer_mutex_init(); - a2dp_audio_status_mutex_init(); + A2DP_AUDIO_OUTPUT_CONFIG_T decoder_output_config; + TRACE_A2DP_DECODER_I("[INIT] freq:%d codec:%d chnl:%d", sysfreq, codec_type, + chnl_sel); + TRACE_A2DP_DECODER_I("[INIT] out:%d-%d-%d smp:%d dest:%d", + config->sample_rate, config->num_channels, + config->bits_depth, config->frame_samples, + dest_packet_mut); + a2dp_audio_sysfreq_boost_init(sysfreq); + a2dp_audio_sysfreq_boost_start(A2DP_AUDIO_SYSFREQ_BOOST_RESUME_CNT); + a2dp_audio_semaphore_init(); + a2dp_audio_buffer_mutex_init(); + a2dp_audio_status_mutex_init(); - a2dp_audio_status_mutex_lock(); - - a2dp_audio_detect_next_packet_callback_register(NULL); - a2dp_audio_detect_store_packet_callback_register(NULL); + a2dp_audio_status_mutex_lock(); + a2dp_audio_detect_next_packet_callback_register(NULL); + a2dp_audio_detect_store_packet_callback_register(NULL); #if defined(A2DP_LDAC_ON) - if(bt_sbc_player_get_codec_type()==BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - { - heap_size = A2DP_AUDIO_LDAC_MEMPOOL_SIZE; - } - else + if (bt_sbc_player_get_codec_type() == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + heap_size = A2DP_AUDIO_LDAC_MEMPOOL_SIZE; + } else #endif - { - heap_size = A2DP_AUDIO_MEMPOOL_SIZE; - } - app_audio_mempool_get_buff(&heap_buff, heap_size); - ASSERT_A2DP_DECODER(heap_buff, "%s size:%d", __func__, heap_size); - a2dp_audio_heap_init(heap_buff, heap_size); + { + heap_size = A2DP_AUDIO_MEMPOOL_SIZE; + } + app_audio_mempool_get_buff(&heap_buff, heap_size); + ASSERT_A2DP_DECODER(heap_buff, "%s size:%d", __func__, heap_size); + a2dp_audio_heap_init(heap_buff, heap_size); - memset(&a2dp_audio_lastframe_info, 0, sizeof(A2DP_AUDIO_LASTFRAME_INFO_T)); + memset(&a2dp_audio_lastframe_info, 0, sizeof(A2DP_AUDIO_LASTFRAME_INFO_T)); - a2dp_audio_context.audio_datapath.input_raw_packet_list = a2dp_audio_list_new(a2dp_audio_packet_free, - (list_mempool_zmalloc)a2dp_audio_heap_cmalloc, - (list_mempool_free)a2dp_audio_heap_free); + a2dp_audio_context.audio_datapath.input_raw_packet_list = a2dp_audio_list_new( + a2dp_audio_packet_free, (list_mempool_zmalloc)a2dp_audio_heap_cmalloc, + (list_mempool_free)a2dp_audio_heap_free); - a2dp_audio_context.audio_datapath.output_pcm_packet_list = a2dp_audio_list_new(a2dp_audio_packet_free, - (list_mempool_zmalloc)a2dp_audio_heap_cmalloc, - (list_mempool_free)a2dp_audio_heap_free); + a2dp_audio_context.audio_datapath.output_pcm_packet_list = + a2dp_audio_list_new(a2dp_audio_packet_free, + (list_mempool_zmalloc)a2dp_audio_heap_cmalloc, + (list_mempool_free)a2dp_audio_heap_free); - memcpy(&(a2dp_audio_context.output_cfg), config, sizeof(A2DP_AUDIO_OUTPUT_CONFIG_T)); - ratio = a2dp_audio_context.output_cfg.factor_reference; - a2dp_audio_context.output_cfg.factor_reference = 0; + memcpy(&(a2dp_audio_context.output_cfg), config, + sizeof(A2DP_AUDIO_OUTPUT_CONFIG_T)); + ratio = a2dp_audio_context.output_cfg.factor_reference; + a2dp_audio_context.output_cfg.factor_reference = 0; - a2dp_audio_context.init_factor_reference = config->factor_reference; - a2dp_audio_context.chnl_sel = chnl_sel; - a2dp_audio_context.dest_packet_mut = dest_packet_mut; - a2dp_audio_context.average_packet_mut = 0; + a2dp_audio_context.init_factor_reference = config->factor_reference; + a2dp_audio_context.chnl_sel = chnl_sel; + a2dp_audio_context.dest_packet_mut = dest_packet_mut; + a2dp_audio_context.average_packet_mut = 0; - switch (codec_type) - { - case A2DP_AUDIO_CODEC_TYPE_SBC: - decoder_output_config.sample_rate = config->sample_rate; - decoder_output_config.num_channels = 2; - decoder_output_config.bits_depth = 16; - decoder_output_config.frame_samples = config->frame_samples; - decoder_output_config.factor_reference = 1.0f; - memcpy(&(a2dp_audio_context.audio_decoder), &a2dp_audio_sbc_decoder_config, sizeof(A2DP_AUDIO_DECODER_T)); - break; + switch (codec_type) { + case A2DP_AUDIO_CODEC_TYPE_SBC: + decoder_output_config.sample_rate = config->sample_rate; + decoder_output_config.num_channels = 2; + decoder_output_config.bits_depth = 16; + decoder_output_config.frame_samples = config->frame_samples; + decoder_output_config.factor_reference = 1.0f; + memcpy(&(a2dp_audio_context.audio_decoder), &a2dp_audio_sbc_decoder_config, + sizeof(A2DP_AUDIO_DECODER_T)); + break; #if defined(A2DP_AAC_ON) - case A2DP_AUDIO_CODEC_TYPE_MPEG2_4_AAC: - decoder_output_config.sample_rate = config->sample_rate; - decoder_output_config.num_channels = 2; - decoder_output_config.bits_depth = 16; - decoder_output_config.frame_samples = config->frame_samples; - decoder_output_config.factor_reference = 1.0f; - memcpy(&(a2dp_audio_context.audio_decoder), &a2dp_audio_aac_lc_decoder_config, sizeof(A2DP_AUDIO_DECODER_T)); - break; + case A2DP_AUDIO_CODEC_TYPE_MPEG2_4_AAC: + decoder_output_config.sample_rate = config->sample_rate; + decoder_output_config.num_channels = 2; + decoder_output_config.bits_depth = 16; + decoder_output_config.frame_samples = config->frame_samples; + decoder_output_config.factor_reference = 1.0f; + memcpy(&(a2dp_audio_context.audio_decoder), + &a2dp_audio_aac_lc_decoder_config, sizeof(A2DP_AUDIO_DECODER_T)); + break; #endif #if defined(A2DP_SCALABLE_ON) - case A2DP_AUDIO_CODEC_TYPE_SCALABL: - decoder_output_config.sample_rate = config->sample_rate; - decoder_output_config.num_channels = 2; - decoder_output_config.bits_depth = config->curr_bits; - decoder_output_config.frame_samples = config->frame_samples; - decoder_output_config.factor_reference = 1.0f; - memcpy(&(a2dp_audio_context.audio_decoder), &a2dp_audio_scalable_decoder_config, sizeof(A2DP_AUDIO_DECODER_T)); - break; + case A2DP_AUDIO_CODEC_TYPE_SCALABL: + decoder_output_config.sample_rate = config->sample_rate; + decoder_output_config.num_channels = 2; + decoder_output_config.bits_depth = config->curr_bits; + decoder_output_config.frame_samples = config->frame_samples; + decoder_output_config.factor_reference = 1.0f; + memcpy(&(a2dp_audio_context.audio_decoder), + &a2dp_audio_scalable_decoder_config, sizeof(A2DP_AUDIO_DECODER_T)); + break; #endif #if defined(A2DP_LHDC_ON) - case A2DP_AUDIO_CODEC_TYPE_LHDC: - decoder_output_config.sample_rate = config->sample_rate; - decoder_output_config.num_channels = 2; - decoder_output_config.bits_depth = config->curr_bits; - decoder_output_config.frame_samples = config->frame_samples; - decoder_output_config.factor_reference = 1.0f; - memcpy(&(a2dp_audio_context.audio_decoder), &a2dp_audio_lhdc_decoder_config, sizeof(A2DP_AUDIO_DECODER_T)); - break; + case A2DP_AUDIO_CODEC_TYPE_LHDC: + decoder_output_config.sample_rate = config->sample_rate; + decoder_output_config.num_channels = 2; + decoder_output_config.bits_depth = config->curr_bits; + decoder_output_config.frame_samples = config->frame_samples; + decoder_output_config.factor_reference = 1.0f; + memcpy(&(a2dp_audio_context.audio_decoder), &a2dp_audio_lhdc_decoder_config, + sizeof(A2DP_AUDIO_DECODER_T)); + break; #endif #if defined(A2DP_LDAC_ON) - case A2DP_AUDIO_CODEC_TYPE_LDAC: - decoder_output_config.sample_rate = config->sample_rate; - decoder_output_config.num_channels = 2; - decoder_output_config.bits_depth = config->curr_bits; - decoder_output_config.frame_samples = config->frame_samples; - decoder_output_config.factor_reference = 1.0f; - memcpy(&(a2dp_audio_context.audio_decoder), &a2dp_audio_ldac_decoder_config, sizeof(A2DP_AUDIO_DECODER_T)); - break; + case A2DP_AUDIO_CODEC_TYPE_LDAC: + decoder_output_config.sample_rate = config->sample_rate; + decoder_output_config.num_channels = 2; + decoder_output_config.bits_depth = config->curr_bits; + decoder_output_config.frame_samples = config->frame_samples; + decoder_output_config.factor_reference = 1.0f; + memcpy(&(a2dp_audio_context.audio_decoder), &a2dp_audio_ldac_decoder_config, + sizeof(A2DP_AUDIO_DECODER_T)); + break; #endif - default: - ASSERT_A2DP_DECODER(0, "%s invalid codec_type:%d", __func__, codec_type); - break; - } + default: + ASSERT_A2DP_DECODER(0, "%s invalid codec_type:%d", __func__, codec_type); + break; + } - a2dp_audio_context.audio_decoder.audio_decoder_init(&decoder_output_config, (void *)&a2dp_audio_context); - a2dp_audio_context.need_detect_first_packet = true; - a2dp_audio_context.underflow_onporcess = false; - a2dp_audio_context.skip_frame_cnt_after_no_cache = 0; - a2dp_audio_context.mute_frame_cnt_after_no_cache = 0; + a2dp_audio_context.audio_decoder.audio_decoder_init( + &decoder_output_config, (void *)&a2dp_audio_context); + a2dp_audio_context.need_detect_first_packet = true; + a2dp_audio_context.underflow_onporcess = false; + a2dp_audio_context.skip_frame_cnt_after_no_cache = 0; + a2dp_audio_context.mute_frame_cnt_after_no_cache = 0; - a2dp_audio_context.audio_decoder_status = A2DP_AUDIO_DECODER_STATUS_READY; + a2dp_audio_context.audio_decoder_status = A2DP_AUDIO_DECODER_STATUS_READY; - a2dp_audio_context.store_packet_status = A2DP_AUDIO_DECODER_STORE_PACKET_STATUS_IDLE; - a2dp_audio_context.playback_status = A2DP_AUDIO_DECODER_PLAYBACK_STATUS_IDLE; + a2dp_audio_context.store_packet_status = + A2DP_AUDIO_DECODER_STORE_PACKET_STATUS_IDLE; + a2dp_audio_context.playback_status = A2DP_AUDIO_DECODER_PLAYBACK_STATUS_IDLE; - a2dp_audio_sync_init(ratio); + a2dp_audio_sync_init(ratio); #if A2DP_DECODER_HISTORY_SEQ_SAVE - a2dp_audio_reset_history_seq(); + a2dp_audio_reset_history_seq(); #endif - a2dp_audio_store_packet_checker_start(); + a2dp_audio_store_packet_checker_start(); - a2dp_audio_status_mutex_unlock(); + a2dp_audio_status_mutex_unlock(); - return 0; + return 0; } -int a2dp_audio_deinit(void) -{ - TRACE_A2DP_DECODER_I("[DEINIT]"); +int a2dp_audio_deinit(void) { + TRACE_A2DP_DECODER_I("[DEINIT]"); - a2dp_audio_status_mutex_lock(); + a2dp_audio_status_mutex_lock(); - a2dp_audio_detect_next_packet_callback_register(NULL); - a2dp_audio_detect_store_packet_callback_register(NULL); + a2dp_audio_detect_next_packet_callback_register(NULL); + a2dp_audio_detect_store_packet_callback_register(NULL); - a2dp_audio_context.audio_decoder.audio_decoder_deinit(); - memset(&(a2dp_audio_context.audio_decoder), 0, sizeof(A2DP_AUDIO_DECODER_T)); - memset(&(a2dp_audio_context.output_cfg), 0, sizeof(A2DP_AUDIO_OUTPUT_CONFIG_T)); - a2dp_audio_list_clear(a2dp_audio_context.audio_datapath.input_raw_packet_list); - a2dp_audio_list_free(a2dp_audio_context.audio_datapath.input_raw_packet_list); - a2dp_audio_context.audio_datapath.input_raw_packet_list = NULL; - a2dp_audio_list_clear(a2dp_audio_context.audio_datapath.output_pcm_packet_list); - a2dp_audio_list_free(a2dp_audio_context.audio_datapath.output_pcm_packet_list); - a2dp_audio_context.audio_datapath.output_pcm_packet_list = NULL; + a2dp_audio_context.audio_decoder.audio_decoder_deinit(); + memset(&(a2dp_audio_context.audio_decoder), 0, sizeof(A2DP_AUDIO_DECODER_T)); + memset(&(a2dp_audio_context.output_cfg), 0, + sizeof(A2DP_AUDIO_OUTPUT_CONFIG_T)); + a2dp_audio_list_clear( + a2dp_audio_context.audio_datapath.input_raw_packet_list); + a2dp_audio_list_free(a2dp_audio_context.audio_datapath.input_raw_packet_list); + a2dp_audio_context.audio_datapath.input_raw_packet_list = NULL; + a2dp_audio_list_clear( + a2dp_audio_context.audio_datapath.output_pcm_packet_list); + a2dp_audio_list_free( + a2dp_audio_context.audio_datapath.output_pcm_packet_list); + a2dp_audio_context.audio_datapath.output_pcm_packet_list = NULL; - size_t total = 0, used = 0, max_used = 0; - a2dp_audio_heap_info(&total, &used, &max_used); - TRACE_A2DP_DECODER_I("[DEINIT] heap info: total - %d, used - %d, max_used - %d.", total, used, max_used); - //ASSERT_A2DP_DECODER(used == 0, "[%s] used != 0", __func__); + size_t total = 0, used = 0, max_used = 0; + a2dp_audio_heap_info(&total, &used, &max_used); + TRACE_A2DP_DECODER_I( + "[DEINIT] heap info: total - %d, used - %d, max_used - %d.", total, used, + max_used); + // ASSERT_A2DP_DECODER(used == 0, "[%s] used != 0", __func__); - a2dp_audio_set_store_packet_status(A2DP_AUDIO_DECODER_STORE_PACKET_STATUS_IDLE); - a2dp_audio_set_playback_status(A2DP_AUDIO_DECODER_PLAYBACK_STATUS_IDLE); - a2dp_audio_set_status(A2DP_AUDIO_DECODER_STATUS_NULL); + a2dp_audio_set_store_packet_status( + A2DP_AUDIO_DECODER_STORE_PACKET_STATUS_IDLE); + a2dp_audio_set_playback_status(A2DP_AUDIO_DECODER_PLAYBACK_STATUS_IDLE); + a2dp_audio_set_status(A2DP_AUDIO_DECODER_STATUS_NULL); #if A2DP_DECODER_HISTORY_SEQ_SAVE - a2dp_audio_reset_history_seq(); + a2dp_audio_reset_history_seq(); #endif - a2dp_audio_status_mutex_unlock(); + a2dp_audio_status_mutex_unlock(); - return 0; + return 0; } -int a2dp_audio_stop(void) -{ - TRACE_A2DP_DECODER_I("[STOP]"); - int cnt = 0; - - a2dp_audio_set_status(A2DP_AUDIO_DECODER_STATUS_STOP); - a2dp_audio_semaphore_release(); +int a2dp_audio_stop(void) { + TRACE_A2DP_DECODER_I("[STOP]"); + int cnt = 0; - cnt = 50; + a2dp_audio_set_status(A2DP_AUDIO_DECODER_STATUS_STOP); + a2dp_audio_semaphore_release(); + + cnt = 50; + do { + if (a2dp_audio_get_playback_status() == + A2DP_AUDIO_DECODER_PLAYBACK_STATUS_IDLE) { + TRACE_A2DP_DECODER_I("[DEINIT]PLAYBACK_STATUS_IDLE cnt:%d", cnt); + break; + } else { + osThreadYield(); + } + } while (--cnt > 0); + cnt = 50; + do { + if (a2dp_audio_get_store_packet_status() == + A2DP_AUDIO_DECODER_STORE_PACKET_STATUS_IDLE) { + TRACE_A2DP_DECODER_I("[DEINIT] STORE_PACKET_STATUS_IDLE cnt:%d", cnt); + break; + } else { + osThreadYield(); + } + } while (--cnt > 0); + + return 0; +} + +int a2dp_audio_start(void) { + TRACE_A2DP_DECODER_I("[START]"); + a2dp_audio_status_mutex_lock(); + a2dp_audio_set_status(A2DP_AUDIO_DECODER_STATUS_START); + a2dp_audio_status_mutex_unlock(); + return 0; +} + +int a2dp_audio_detect_next_packet_callback_register( + A2DP_AUDIO_DETECT_NEXT_PACKET_CALLBACK callback) { + a2dp_audio_status_mutex_lock(); + a2dp_audio_detect_next_packet_callback = callback; + a2dp_audio_status_mutex_unlock(); + + return 0; +} + +int a2dp_audio_detect_store_packet_callback_register( + A2DP_AUDIO_DETECT_NEXT_PACKET_CALLBACK callback) { + a2dp_audio_status_mutex_lock(); + a2dp_audio_store_packet_callback = callback; + a2dp_audio_status_mutex_unlock(); + + return 0; +} + +int a2dp_audio_detect_first_packet(void) { + a2dp_audio_status_mutex_lock(); + a2dp_audio_context.need_detect_first_packet = true; + a2dp_audio_status_mutex_unlock(); + return 0; +} + +int a2dp_audio_detect_first_packet_clear(void) { + a2dp_audio_status_mutex_lock(); + a2dp_audio_context.need_detect_first_packet = false; + a2dp_audio_status_mutex_unlock(); + return 0; +} + +int a2dp_audio_discards_packet(uint32_t packets) { + int nRet = 0; + + if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START) { + a2dp_audio_status_mutex_lock(); + nRet = + a2dp_audio_context.audio_decoder.audio_decoder_discards_packet(packets); + a2dp_audio_status_mutex_unlock(); + } else { + nRet = -1; + } + + return nRet; +} + +int a2dp_audio_synchronize_dest_packet_mut(uint32_t mtu) { + int nRet = 0; + int cnt = 50; + if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START) { do { - if (a2dp_audio_get_playback_status() == A2DP_AUDIO_DECODER_PLAYBACK_STATUS_IDLE){ - TRACE_A2DP_DECODER_I("[DEINIT]PLAYBACK_STATUS_IDLE cnt:%d", cnt); - break; - }else{ - osThreadYield(); - } - }while(--cnt > 0); - cnt = 50; - do { - if (a2dp_audio_get_store_packet_status() == A2DP_AUDIO_DECODER_STORE_PACKET_STATUS_IDLE){ - TRACE_A2DP_DECODER_I("[DEINIT] STORE_PACKET_STATUS_IDLE cnt:%d", cnt); - break; - }else{ - osThreadYield(); - } - }while(--cnt > 0); + if (a2dp_audio_get_playback_status() == + A2DP_AUDIO_DECODER_PLAYBACK_STATUS_IDLE) { + nRet = a2dp_audio_context.audio_decoder + .audio_decoder_synchronize_dest_packet_mut(mtu); + break; + } else { + osThreadYield(); + } + } while (--cnt > 0); + } else { + nRet = -1; + } - return 0; + return nRet; } -int a2dp_audio_start(void) -{ - TRACE_A2DP_DECODER_I("[START]"); - a2dp_audio_status_mutex_lock(); - a2dp_audio_set_status(A2DP_AUDIO_DECODER_STATUS_START); - a2dp_audio_status_mutex_unlock(); - return 0; +int a2dp_audio_discards_samples(uint32_t samples) { + return a2dp_audio_context.audio_decoder.a2dp_audio_discards_samples(samples); } -int a2dp_audio_detect_next_packet_callback_register(A2DP_AUDIO_DETECT_NEXT_PACKET_CALLBACK callback) -{ - a2dp_audio_status_mutex_lock(); - a2dp_audio_detect_next_packet_callback = callback; - a2dp_audio_status_mutex_unlock(); - - return 0; +int a2dp_audio_convert_list_to_samples(uint32_t *samples) { + return a2dp_audio_context.audio_decoder.a2dp_audio_convert_list_to_samples( + samples); } -int a2dp_audio_detect_store_packet_callback_register(A2DP_AUDIO_DETECT_NEXT_PACKET_CALLBACK callback) -{ - a2dp_audio_status_mutex_lock(); - a2dp_audio_store_packet_callback = callback; - a2dp_audio_status_mutex_unlock(); +int a2dp_audio_get_packet_samples(void) { + A2DP_AUDIO_LASTFRAME_INFO_T lastframe_info; + uint32_t packet_samples = 0; + uint16_t totalSubSequenceNumber = 1; - return 0; + a2dp_audio_lastframe_info_get(&lastframe_info); + + if (lastframe_info.totalSubSequenceNumber) { + totalSubSequenceNumber = lastframe_info.totalSubSequenceNumber; + } + + packet_samples = totalSubSequenceNumber * lastframe_info.frame_samples; + + return packet_samples; } -int a2dp_audio_detect_first_packet(void) -{ - a2dp_audio_status_mutex_lock(); - a2dp_audio_context.need_detect_first_packet = true; - a2dp_audio_status_mutex_unlock(); - return 0; +static int a2dp_audio_internal_lastframe_info_ptr_get( + A2DP_AUDIO_LASTFRAME_INFO_T **lastframe_info) { + int nRet = 0; + + if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START) { + *lastframe_info = &a2dp_audio_lastframe_info; + } else { + *lastframe_info = NULL; + nRet = -1; + } + + return nRet; } -int a2dp_audio_detect_first_packet_clear(void) -{ - a2dp_audio_status_mutex_lock(); - a2dp_audio_context.need_detect_first_packet = false; - a2dp_audio_status_mutex_unlock(); - return 0; -} +int a2dp_audio_lastframe_info_get(A2DP_AUDIO_LASTFRAME_INFO_T *lastframe_info) { + int nRet = 0; -int a2dp_audio_discards_packet(uint32_t packets) -{ - int nRet = 0; - - if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START){ - a2dp_audio_status_mutex_lock(); - nRet = a2dp_audio_context.audio_decoder.audio_decoder_discards_packet(packets); - a2dp_audio_status_mutex_unlock(); - }else{ - nRet = -1; - } - - return nRet; -} - -int a2dp_audio_synchronize_dest_packet_mut(uint32_t mtu) -{ - int nRet = 0; - int cnt = 50; - if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START){ - do { - if (a2dp_audio_get_playback_status() == A2DP_AUDIO_DECODER_PLAYBACK_STATUS_IDLE){ - nRet = a2dp_audio_context.audio_decoder.audio_decoder_synchronize_dest_packet_mut(mtu); - break; - }else{ - osThreadYield(); - } - }while(--cnt > 0); - }else{ - nRet = -1; - } - - return nRet; -} - -int a2dp_audio_discards_samples(uint32_t samples) -{ - return a2dp_audio_context.audio_decoder.a2dp_audio_discards_samples(samples); -} - -int a2dp_audio_convert_list_to_samples(uint32_t *samples) -{ - return a2dp_audio_context.audio_decoder.a2dp_audio_convert_list_to_samples(samples); -} - -int a2dp_audio_get_packet_samples(void) -{ - A2DP_AUDIO_LASTFRAME_INFO_T lastframe_info; - uint32_t packet_samples = 0; - uint16_t totalSubSequenceNumber = 1; - - a2dp_audio_lastframe_info_get(&lastframe_info); - - if (lastframe_info.totalSubSequenceNumber){ - totalSubSequenceNumber = lastframe_info.totalSubSequenceNumber; - } - - packet_samples = totalSubSequenceNumber * lastframe_info.frame_samples; - - return packet_samples; -} - -static int a2dp_audio_internal_lastframe_info_ptr_get(A2DP_AUDIO_LASTFRAME_INFO_T **lastframe_info) -{ - int nRet = 0; - - if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START){ - *lastframe_info = &a2dp_audio_lastframe_info; - }else{ - *lastframe_info = NULL; - nRet = -1; - } - - return nRet; -} - -int a2dp_audio_lastframe_info_get(A2DP_AUDIO_LASTFRAME_INFO_T *lastframe_info) -{ - int nRet = 0; - - if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START){ - a2dp_audio_buffer_mutex_lock(); - memcpy(lastframe_info, &a2dp_audio_lastframe_info, sizeof(A2DP_AUDIO_LASTFRAME_INFO_T)); - a2dp_audio_buffer_mutex_unlock(); - }else{ - memset(lastframe_info, 0, sizeof(A2DP_AUDIO_LASTFRAME_INFO_T)); - nRet = -1; - } - - return nRet; -} - -int a2dp_audio_decoder_internal_check_sum_reset(void) -{ - check_sum_seed = 0; - return 0; -} - -uint32_t a2dp_audio_decoder_internal_check_sum_generate(const uint8_t *buf, uint32_t len) -{ -#if A2DP_DECODER_CHECKER - check_sum_seed = crc32(check_sum_seed, buf, len); -#else - check_sum_seed = 0; -#endif - return check_sum_seed; -} - -int a2dp_audio_lastframe_info_reset_undecodeframe(void) -{ - int nRet = 0; - - if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START){ - a2dp_audio_buffer_mutex_lock(); - a2dp_audio_lastframe_info.undecode_frames = 0; - a2dp_audio_lastframe_info.undecode_max_frames = 0; - a2dp_audio_lastframe_info.undecode_min_frames = 0xffff; - a2dp_audio_decoder_internal_check_sum_reset(); - a2dp_audio_lastframe_info.check_sum = 0; - a2dp_audio_buffer_mutex_unlock(); - }else{ - nRet = -1; - } - - return nRet; -} - -int a2dp_audio_decoder_internal_lastframe_info_set(A2DP_AUDIO_DECODER_LASTFRAME_INFO_T *lastframe_info) -{ + if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START) { a2dp_audio_buffer_mutex_lock(); - a2dp_audio_lastframe_info.sequenceNumber = lastframe_info->sequenceNumber; - a2dp_audio_lastframe_info.timestamp = lastframe_info->timestamp; - a2dp_audio_lastframe_info.curSubSequenceNumber = lastframe_info->curSubSequenceNumber; - a2dp_audio_lastframe_info.totalSubSequenceNumber= lastframe_info->totalSubSequenceNumber; - a2dp_audio_lastframe_info.frame_samples = lastframe_info->frame_samples; - a2dp_audio_lastframe_info.list_samples = lastframe_info->list_samples; - a2dp_audio_lastframe_info.decoded_frames = lastframe_info->decoded_frames; - a2dp_audio_lastframe_info.undecode_frames = lastframe_info->undecode_frames; - - a2dp_audio_lastframe_info.undecode_max_frames = - MAX(a2dp_audio_lastframe_info.undecode_frames, a2dp_audio_lastframe_info.undecode_max_frames); - a2dp_audio_lastframe_info.undecode_min_frames = - MIN(a2dp_audio_lastframe_info.undecode_frames, a2dp_audio_lastframe_info.undecode_min_frames); - - a2dp_audio_lastframe_info.stream_info = lastframe_info->stream_info; - a2dp_audio_lastframe_info.check_sum = lastframe_info->check_sum; + memcpy(lastframe_info, &a2dp_audio_lastframe_info, + sizeof(A2DP_AUDIO_LASTFRAME_INFO_T)); a2dp_audio_buffer_mutex_unlock(); + } else { + memset(lastframe_info, 0, sizeof(A2DP_AUDIO_LASTFRAME_INFO_T)); + nRet = -1; + } - return 0; + return nRet; } -int a2dp_audio_synchronize_packet(A2DP_AUDIO_SYNCFRAME_INFO_T *sync_info, uint32_t mask) -{ - int nRet = 0; +int a2dp_audio_decoder_internal_check_sum_reset(void) { + check_sum_seed = 0; + return 0; +} - if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START){ - a2dp_audio_status_mutex_lock(); - nRet = a2dp_audio_context.audio_decoder.audio_decoder_synchronize_packet(sync_info, mask); - if (nRet == A2DP_DECODER_NOT_SUPPORT){ - //can't support synchronize packet, so return fake val; - nRet = A2DP_DECODER_NO_ERROR; - } - a2dp_audio_status_mutex_unlock(); - }else{ - nRet = -1; +uint32_t a2dp_audio_decoder_internal_check_sum_generate(const uint8_t *buf, + uint32_t len) { +#if A2DP_DECODER_CHECKER + check_sum_seed = crc32(check_sum_seed, buf, len); +#else + check_sum_seed = 0; +#endif + return check_sum_seed; +} + +int a2dp_audio_lastframe_info_reset_undecodeframe(void) { + int nRet = 0; + + if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START) { + a2dp_audio_buffer_mutex_lock(); + a2dp_audio_lastframe_info.undecode_frames = 0; + a2dp_audio_lastframe_info.undecode_max_frames = 0; + a2dp_audio_lastframe_info.undecode_min_frames = 0xffff; + a2dp_audio_decoder_internal_check_sum_reset(); + a2dp_audio_lastframe_info.check_sum = 0; + a2dp_audio_buffer_mutex_unlock(); + } else { + nRet = -1; + } + + return nRet; +} + +int a2dp_audio_decoder_internal_lastframe_info_set( + A2DP_AUDIO_DECODER_LASTFRAME_INFO_T *lastframe_info) { + a2dp_audio_buffer_mutex_lock(); + a2dp_audio_lastframe_info.sequenceNumber = lastframe_info->sequenceNumber; + a2dp_audio_lastframe_info.timestamp = lastframe_info->timestamp; + a2dp_audio_lastframe_info.curSubSequenceNumber = + lastframe_info->curSubSequenceNumber; + a2dp_audio_lastframe_info.totalSubSequenceNumber = + lastframe_info->totalSubSequenceNumber; + a2dp_audio_lastframe_info.frame_samples = lastframe_info->frame_samples; + a2dp_audio_lastframe_info.list_samples = lastframe_info->list_samples; + a2dp_audio_lastframe_info.decoded_frames = lastframe_info->decoded_frames; + a2dp_audio_lastframe_info.undecode_frames = lastframe_info->undecode_frames; + + a2dp_audio_lastframe_info.undecode_max_frames = + MAX(a2dp_audio_lastframe_info.undecode_frames, + a2dp_audio_lastframe_info.undecode_max_frames); + a2dp_audio_lastframe_info.undecode_min_frames = + MIN(a2dp_audio_lastframe_info.undecode_frames, + a2dp_audio_lastframe_info.undecode_min_frames); + + a2dp_audio_lastframe_info.stream_info = lastframe_info->stream_info; + a2dp_audio_lastframe_info.check_sum = lastframe_info->check_sum; + a2dp_audio_buffer_mutex_unlock(); + + return 0; +} + +int a2dp_audio_synchronize_packet(A2DP_AUDIO_SYNCFRAME_INFO_T *sync_info, + uint32_t mask) { + int nRet = 0; + + if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START) { + a2dp_audio_status_mutex_lock(); + nRet = a2dp_audio_context.audio_decoder.audio_decoder_synchronize_packet( + sync_info, mask); + if (nRet == A2DP_DECODER_NOT_SUPPORT) { + // can't support synchronize packet, so return fake val; + nRet = A2DP_DECODER_NO_ERROR; } + a2dp_audio_status_mutex_unlock(); + } else { + nRet = -1; + } - return nRet; + return nRet; } -int a2dp_audio_decoder_headframe_info_get(A2DP_AUDIO_HEADFRAME_INFO_T *headframe_info) -{ - int nRet = 0; +int a2dp_audio_decoder_headframe_info_get( + A2DP_AUDIO_HEADFRAME_INFO_T *headframe_info) { + int nRet = 0; - if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START){ - nRet = a2dp_audio_context.audio_decoder.audio_decoder_headframe_info_get(headframe_info); - }else{ - memset(headframe_info, 0, sizeof(A2DP_AUDIO_HEADFRAME_INFO_T)); - nRet = -1; - } + if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START) { + nRet = a2dp_audio_context.audio_decoder.audio_decoder_headframe_info_get( + headframe_info); + } else { + memset(headframe_info, 0, sizeof(A2DP_AUDIO_HEADFRAME_INFO_T)); + nRet = -1; + } - return nRet; + return nRet; } -int a2dp_audio_refill_packet(void) -{ - int refill_cnt = 0; +int a2dp_audio_refill_packet(void) { + int refill_cnt = 0; #if defined(A2DP_AUDIO_REFILL_AFTER_NO_CACHE) - refill_cnt += a2dp_audio_context.skip_frame_cnt_after_no_cache; + refill_cnt += a2dp_audio_context.skip_frame_cnt_after_no_cache; #endif - refill_cnt += a2dp_audio_context.mute_frame_cnt_after_no_cache; + refill_cnt += a2dp_audio_context.mute_frame_cnt_after_no_cache; - return refill_cnt; + return refill_cnt; } -bool a2dp_audio_auto_synchronize_support(void) -{ - bool nRet = 0; +bool a2dp_audio_auto_synchronize_support(void) { + bool nRet = 0; - if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START){ - a2dp_audio_buffer_mutex_lock(); - nRet = a2dp_audio_context.audio_decoder.auto_synchronize_support > 0 ? true: false; - a2dp_audio_buffer_mutex_unlock(); - }else{ - nRet = 0; + if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START) { + a2dp_audio_buffer_mutex_lock(); + nRet = a2dp_audio_context.audio_decoder.auto_synchronize_support > 0 + ? true + : false; + a2dp_audio_buffer_mutex_unlock(); + } else { + nRet = 0; + } + + return nRet; +} + +A2DP_AUDIO_OUTPUT_CONFIG_T *a2dp_audio_get_output_config(void) { + A2DP_AUDIO_OUTPUT_CONFIG_T *output_config = NULL; + + if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START) { + a2dp_audio_buffer_mutex_lock(); + output_config = &a2dp_audio_context.output_cfg; + a2dp_audio_buffer_mutex_unlock(); + } else { + output_config = NULL; + } + + return output_config; +} + +int a2dp_audio_latency_factor_setlow(void) { + a2dp_audio_latency_factor = A2DP_AUDIO_LATENCY_LOW_FACTOR; + return 0; +} + +int a2dp_audio_latency_factor_sethigh(void) { + a2dp_audio_latency_factor = A2DP_AUDIO_LATENCY_HIGH_FACTOR; + return 0; +} + +float a2dp_audio_latency_factor_get(void) { return a2dp_audio_latency_factor; } + +int a2dp_audio_latency_factor_set(float factor) { + a2dp_audio_latency_factor = factor; + return 0; +} + +int a2dp_audio_latency_factor_status_get( + A2DP_AUDIO_LATENCY_STATUS_E *latency_status, float *more_latency_factor) { + if (a2dp_audio_latency_factor == A2DP_AUDIO_LATENCY_HIGH_FACTOR) { + *latency_status = A2DP_AUDIO_LATENCY_STATUS_HIGH; + *more_latency_factor = A2DP_AUDIO_LATENCY_MORE_FACTOR; + } else { + *latency_status = A2DP_AUDIO_LATENCY_STATUS_LOW; + *more_latency_factor = 1.0f; + } + return 0; +} + +int a2dp_audio_frame_delay_get(void) { return get_in_cp_frame_delay(); } + +int a2dp_audio_dest_packet_mut_get(void) { + return a2dp_audio_context.dest_packet_mut; +} + +int a2dp_audio_set_channel_select(A2DP_AUDIO_CHANNEL_SELECT_E chnl_sel) { + int nRet = A2DP_DECODER_NO_ERROR; + + if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START) { + a2dp_audio_context.chnl_sel = chnl_sel; + if (a2dp_audio_context.audio_decoder.audio_decoder_channel_select) { + nRet = a2dp_audio_context.audio_decoder.audio_decoder_channel_select( + chnl_sel); } + } - return nRet; + return nRet; } -A2DP_AUDIO_OUTPUT_CONFIG_T *a2dp_audio_get_output_config(void) -{ - A2DP_AUDIO_OUTPUT_CONFIG_T *output_config = NULL; - - if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START){ - a2dp_audio_buffer_mutex_lock(); - output_config = &a2dp_audio_context.output_cfg; - a2dp_audio_buffer_mutex_unlock(); - }else{ - output_config = NULL; - } - - return output_config; +float a2dp_audio_get_sample_reference(void) { + TRACE(1, "a2dp_audio_get_sample_reference:%d", + (int32_t)(a2dp_audio_context.output_cfg.factor_reference * 10000000)); + return a2dp_audio_context.output_cfg.factor_reference; } -int a2dp_audio_latency_factor_setlow(void) -{ - a2dp_audio_latency_factor = A2DP_AUDIO_LATENCY_LOW_FACTOR; - return 0; -} - -int a2dp_audio_latency_factor_sethigh(void) -{ - a2dp_audio_latency_factor = A2DP_AUDIO_LATENCY_HIGH_FACTOR; - return 0; -} - -float a2dp_audio_latency_factor_get(void) -{ - return a2dp_audio_latency_factor; -} - -int a2dp_audio_latency_factor_set(float factor) -{ - a2dp_audio_latency_factor = factor; - return 0; -} - -int a2dp_audio_latency_factor_status_get(A2DP_AUDIO_LATENCY_STATUS_E *latency_status, float *more_latency_factor) -{ - if (a2dp_audio_latency_factor == A2DP_AUDIO_LATENCY_HIGH_FACTOR){ - *latency_status = A2DP_AUDIO_LATENCY_STATUS_HIGH; - *more_latency_factor = A2DP_AUDIO_LATENCY_MORE_FACTOR; - }else{ - *latency_status = A2DP_AUDIO_LATENCY_STATUS_LOW; - *more_latency_factor = 1.0f; - } - return 0; -} - -int a2dp_audio_frame_delay_get(void) -{ - return get_in_cp_frame_delay(); -} - -int a2dp_audio_dest_packet_mut_get(void) -{ - return a2dp_audio_context.dest_packet_mut; -} - -int a2dp_audio_set_channel_select(A2DP_AUDIO_CHANNEL_SELECT_E chnl_sel) -{ - int nRet = A2DP_DECODER_NO_ERROR; - - if (a2dp_audio_get_status() == A2DP_AUDIO_DECODER_STATUS_START){ - a2dp_audio_context.chnl_sel = chnl_sel; - if (a2dp_audio_context.audio_decoder.audio_decoder_channel_select) { - nRet = a2dp_audio_context.audio_decoder.audio_decoder_channel_select(chnl_sel); - } - } - - return nRet; -} - -float a2dp_audio_get_sample_reference(void) -{ - TRACE(1,"a2dp_audio_get_sample_reference:%d", (int32_t)(a2dp_audio_context.output_cfg.factor_reference * 10000000)); - return a2dp_audio_context.output_cfg.factor_reference; -} - -int8_t a2dp_audio_get_current_buf_size(void) -{ - TRACE(1,"a2dp_audio_get_current_buf_size:%d",(int8_t)(a2dp_audio_context.average_packet_mut+0.5f)); - return (int8_t)(a2dp_audio_context.average_packet_mut+0.5f); +int8_t a2dp_audio_get_current_buf_size(void) { + TRACE(1, "a2dp_audio_get_current_buf_size:%d", + (int8_t)(a2dp_audio_context.average_packet_mut + 0.5f)); + return (int8_t)(a2dp_audio_context.average_packet_mut + 0.5f); } diff --git a/apps/audioplayers/a2dp_decoder/a2dp_decoder_aac_lc.cpp b/apps/audioplayers/a2dp_decoder/a2dp_decoder_aac_lc.cpp index f061a5e..9cde66a 100644 --- a/apps/audioplayers/a2dp_decoder/a2dp_decoder_aac_lc.cpp +++ b/apps/audioplayers/a2dp_decoder/a2dp_decoder_aac_lc.cpp @@ -14,35 +14,35 @@ * ****************************************************************************/ // Standard C Included Files +#include "a2dp_decoder_internal.h" #include "cmsis.h" -#include "plat_types.h" -#include -#include "heap_api.h" +#include "cmsis_os.h" #include "hal_location.h" #include "hal_timer.h" -#include "a2dp_decoder_internal.h" -#include "cmsis_os.h" +#include "heap_api.h" +#include "plat_types.h" +#include #if defined(A2DP_AAC_ON) -#include "heap_api.h" #include "aacdecoder_lib.h" #include "aacenc_lib.h" +#include "heap_api.h" #ifndef AAC_MTU_LIMITER #define AAC_MTU_LIMITER (32) /*must <= 23*/ #endif #define AAC_OUTPUT_FRAME_SAMPLES (1024) -#define DECODE_AAC_PCM_FRAME_LENGTH (2048) +#define DECODE_AAC_PCM_FRAME_LENGTH (2048) #define AAC_READBUF_SIZE (900) #define AAC_MEMPOOL_SIZE (40596) typedef struct { - uint16_t sequenceNumber; - uint32_t timestamp; - uint8_t *aac_buffer; - uint32_t aac_buffer_len; + uint16_t sequenceNumber; + uint32_t timestamp; + uint8_t *aac_buffer; + uint32_t aac_buffer_len; } a2dp_audio_aac_decoder_frame_t; int a2dp_audio_aac_lc_reorder_init(void); @@ -59,70 +59,70 @@ static A2DP_AUDIO_DECODER_LASTFRAME_INFO_T a2dp_audio_aac_lastframe_info; static uint16_t aac_mtu_limiter = AAC_MTU_LIMITER; static a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_reorder_p = NULL; -static a2dp_audio_aac_decoder_frame_t aac_decoder_last_valid_frame = {0,}; +static a2dp_audio_aac_decoder_frame_t aac_decoder_last_valid_frame = { + 0, +}; static bool aac_decoder_last_valid_frame_ready = false; -static void *a2dp_audio_aac_lc_frame_malloc(uint32_t packet_len) -{ - a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = NULL; - uint8_t *aac_buffer = NULL; +static void *a2dp_audio_aac_lc_frame_malloc(uint32_t packet_len) { + a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = NULL; + uint8_t *aac_buffer = NULL; - aac_buffer = (uint8_t *)a2dp_audio_heap_malloc(AAC_READBUF_SIZE); - aac_decoder_frame_p = (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_heap_malloc(sizeof(a2dp_audio_aac_decoder_frame_t)); - aac_decoder_frame_p->aac_buffer = aac_buffer; - aac_decoder_frame_p->aac_buffer_len = packet_len; - return (void *)aac_decoder_frame_p; + aac_buffer = (uint8_t *)a2dp_audio_heap_malloc(AAC_READBUF_SIZE); + aac_decoder_frame_p = + (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_heap_malloc( + sizeof(a2dp_audio_aac_decoder_frame_t)); + aac_decoder_frame_p->aac_buffer = aac_buffer; + aac_decoder_frame_p->aac_buffer_len = packet_len; + return (void *)aac_decoder_frame_p; } -static void a2dp_audio_aac_lc_free(void *packet) -{ - a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = (a2dp_audio_aac_decoder_frame_t *)packet; - a2dp_audio_heap_free(aac_decoder_frame_p->aac_buffer); - a2dp_audio_heap_free(aac_decoder_frame_p); +static void a2dp_audio_aac_lc_free(void *packet) { + a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = + (a2dp_audio_aac_decoder_frame_t *)packet; + a2dp_audio_heap_free(aac_decoder_frame_p->aac_buffer); + a2dp_audio_heap_free(aac_decoder_frame_p); } -static void a2dp_audio_aac_lc_decoder_init(void) -{ - if (aacDec_handle == NULL){ - TRANSPORT_TYPE transportFmt = TT_MP4_LATM_MCP1; +static void a2dp_audio_aac_lc_decoder_init(void) { + if (aacDec_handle == NULL) { + TRANSPORT_TYPE transportFmt = TT_MP4_LATM_MCP1; - aacDec_handle = aacDecoder_Open(transportFmt, 1 /* nrOfLayers */); - ASSERT_A2DP_DECODER(aacDec_handle, "aacDecoder_Open failed"); + aacDec_handle = aacDecoder_Open(transportFmt, 1 /* nrOfLayers */); + ASSERT_A2DP_DECODER(aacDec_handle, "aacDecoder_Open failed"); - aacDecoder_SetParam(aacDec_handle,AAC_PCM_LIMITER_ENABLE,0); - aacDecoder_SetParam(aacDec_handle, AAC_DRC_ATTENUATION_FACTOR, 0); - aacDecoder_SetParam(aacDec_handle, AAC_DRC_BOOST_FACTOR, 0); - } + aacDecoder_SetParam(aacDec_handle, AAC_PCM_LIMITER_ENABLE, 0); + aacDecoder_SetParam(aacDec_handle, AAC_DRC_ATTENUATION_FACTOR, 0); + aacDecoder_SetParam(aacDec_handle, AAC_DRC_BOOST_FACTOR, 0); + } } -static void a2dp_audio_aac_lc_decoder_deinit(void) -{ - if (aacDec_handle){ - aacDecoder_Close(aacDec_handle); - aacDec_handle = NULL; - } +static void a2dp_audio_aac_lc_decoder_deinit(void) { + if (aacDec_handle) { + aacDecoder_Close(aacDec_handle); + aacDec_handle = NULL; + } } -static void a2dp_audio_aac_lc_decoder_reinit(void) -{ - if (aacDec_handle){ - a2dp_audio_aac_lc_decoder_deinit(); - } - a2dp_audio_aac_lc_decoder_init(); +static void a2dp_audio_aac_lc_decoder_reinit(void) { + if (aacDec_handle) { + a2dp_audio_aac_lc_decoder_deinit(); + } + a2dp_audio_aac_lc_decoder_init(); } #ifdef A2DP_CP_ACCEL struct A2DP_CP_AAC_LC_IN_FRM_INFO_T { - uint16_t sequenceNumber; - uint32_t timestamp; + uint16_t sequenceNumber; + uint32_t timestamp; }; struct A2DP_CP_AAC_LC_OUT_FRM_INFO_T { - struct A2DP_CP_AAC_LC_IN_FRM_INFO_T in_info; - uint16_t frame_samples; - uint16_t decoded_frames; - uint16_t frame_idx; - uint16_t pcm_len; + struct A2DP_CP_AAC_LC_IN_FRM_INFO_T in_info; + uint16_t frame_samples; + uint16_t decoded_frames; + uint16_t frame_idx; + uint16_t pcm_len; }; static bool cp_codec_reset; @@ -133,880 +133,976 @@ extern uint32_t app_bt_stream_get_dma_buffer_samples(void); int a2dp_cp_aac_lc_cp_decode(void); -static int TEXT_AAC_LOC a2dp_cp_aac_lc_after_cache_underflow(void) -{ +static int TEXT_AAC_LOC a2dp_cp_aac_lc_after_cache_underflow(void) { #ifdef A2DP_CP_ACCEL - cp_codec_reset = true; + cp_codec_reset = true; #endif - return 0; + return 0; } -static int a2dp_cp_aac_lc_mcu_decode(uint8_t *buffer, uint32_t buffer_bytes) -{ - a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = NULL; - list_node_t *node = NULL; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - int ret, dec_ret; - struct A2DP_CP_AAC_LC_IN_FRM_INFO_T in_info; - struct A2DP_CP_AAC_LC_OUT_FRM_INFO_T *p_out_info; - uint8_t *out; - uint32_t out_len; - uint32_t out_frame_len; - uint32_t check_sum = 0; +static int a2dp_cp_aac_lc_mcu_decode(uint8_t *buffer, uint32_t buffer_bytes) { + a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = NULL; + list_node_t *node = NULL; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + int ret, dec_ret; + struct A2DP_CP_AAC_LC_IN_FRM_INFO_T in_info; + struct A2DP_CP_AAC_LC_OUT_FRM_INFO_T *p_out_info; + uint8_t *out; + uint32_t out_len; + uint32_t out_frame_len; + uint32_t check_sum = 0; + uint32_t cp_buffer_frames_max = 0; + cp_buffer_frames_max = app_bt_stream_get_dma_buffer_samples() / 2; + if (cp_buffer_frames_max % (a2dp_audio_aac_lastframe_info.frame_samples)) { + cp_buffer_frames_max = + cp_buffer_frames_max / (a2dp_audio_aac_lastframe_info.frame_samples) + + 1; + } else { + cp_buffer_frames_max = + cp_buffer_frames_max / (a2dp_audio_aac_lastframe_info.frame_samples); + } - uint32_t cp_buffer_frames_max = 0; - cp_buffer_frames_max = app_bt_stream_get_dma_buffer_samples()/2; - if (cp_buffer_frames_max %(a2dp_audio_aac_lastframe_info.frame_samples) ){ - cp_buffer_frames_max = cp_buffer_frames_max /(a2dp_audio_aac_lastframe_info.frame_samples) +1 ; - }else{ - cp_buffer_frames_max = cp_buffer_frames_max /(a2dp_audio_aac_lastframe_info.frame_samples) ; + out_frame_len = sizeof(*p_out_info) + buffer_bytes; + + ret = a2dp_cp_decoder_init(out_frame_len, cp_buffer_frames_max * 2); + if (ret) { + TRACE_A2DP_DECODER_W("[MCU][AAC] cp_decoder_init failed: ret=%d", ret); + set_cp_reset_flag(true); + return A2DP_DECODER_DECODE_ERROR; + } + while ((node = a2dp_audio_list_begin(list)) != NULL) { + aac_decoder_frame_p = + (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_list_node(node); + + in_info.sequenceNumber = aac_decoder_frame_p->sequenceNumber; + in_info.timestamp = aac_decoder_frame_p->timestamp; + + ret = a2dp_cp_put_in_frame(&in_info, sizeof(in_info), + aac_decoder_frame_p->aac_buffer, + aac_decoder_frame_p->aac_buffer_len); + if (ret) { + TRACE_A2DP_DECODER_D("[MCU][AAC] piff !!!!!!ret: %d ", ret); + break; } - - out_frame_len = sizeof(*p_out_info) + buffer_bytes; - - ret = a2dp_cp_decoder_init(out_frame_len, cp_buffer_frames_max * 2); - if (ret){ - TRACE_A2DP_DECODER_W("[MCU][AAC] cp_decoder_init failed: ret=%d", ret); - set_cp_reset_flag(true); - return A2DP_DECODER_DECODE_ERROR; + check_sum = a2dp_audio_decoder_internal_check_sum_generate( + aac_decoder_frame_p->aac_buffer, aac_decoder_frame_p->aac_buffer_len); + a2dp_audio_list_remove(list, aac_decoder_frame_p); + } + ret = a2dp_cp_get_full_out_frame((void **)&out, &out_len); + if (ret) { + if (!get_in_cp_frame_cnt()) { + TRACE_A2DP_DECODER_I("[MCU][AAC] cp cache underflow list:%d in_cp:%d", + a2dp_audio_list_length(list), get_in_cp_frame_cnt()); + return A2DP_DECODER_CACHE_UNDERFLOW_ERROR; } - while ((node = a2dp_audio_list_begin(list)) != NULL) { - aac_decoder_frame_p = (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_list_node(node); - - in_info.sequenceNumber = aac_decoder_frame_p->sequenceNumber; - in_info.timestamp = aac_decoder_frame_p->timestamp; - - ret = a2dp_cp_put_in_frame(&in_info, sizeof(in_info), aac_decoder_frame_p->aac_buffer, aac_decoder_frame_p->aac_buffer_len); - if (ret) { - TRACE_A2DP_DECODER_D("[MCU][AAC] piff !!!!!!ret: %d ", ret); - break; - } - check_sum = a2dp_audio_decoder_internal_check_sum_generate(aac_decoder_frame_p->aac_buffer, aac_decoder_frame_p->aac_buffer_len); - a2dp_audio_list_remove(list, aac_decoder_frame_p); + if (!a2dp_audio_sysfreq_boost_running()) { + a2dp_audio_sysfreq_boost_start(1); } + osDelay(12); ret = a2dp_cp_get_full_out_frame((void **)&out, &out_len); if (ret) { - if (!get_in_cp_frame_cnt()){ - TRACE_A2DP_DECODER_I("[MCU][AAC] cp cache underflow list:%d in_cp:%d",a2dp_audio_list_length(list), get_in_cp_frame_cnt()); - return A2DP_DECODER_CACHE_UNDERFLOW_ERROR; - } - if (!a2dp_audio_sysfreq_boost_running()){ - a2dp_audio_sysfreq_boost_start(1); - } - osDelay(12); - ret = a2dp_cp_get_full_out_frame((void **)&out, &out_len); - if (ret) { - TRACE_A2DP_DECODER_I("[MCU][AAC] cp cache underflow list:%d in_cp:%d",a2dp_audio_list_length(list), get_in_cp_frame_cnt()); - a2dp_cp_aac_lc_after_cache_underflow(); - return A2DP_DECODER_CACHE_UNDERFLOW_ERROR; - } + TRACE_A2DP_DECODER_I("[MCU][AAC] cp cache underflow list:%d in_cp:%d", + a2dp_audio_list_length(list), get_in_cp_frame_cnt()); + a2dp_cp_aac_lc_after_cache_underflow(); + return A2DP_DECODER_CACHE_UNDERFLOW_ERROR; } + } - if (out_len == 0) { - memset(buffer, 0, buffer_bytes); - a2dp_cp_consume_full_out_frame(); - TRACE_A2DP_DECODER_I("[MCU][AAC] olz!!!%d ", __LINE__); - return A2DP_DECODER_NO_ERROR; - } - if (out_len != out_frame_len){ - TRACE_A2DP_DECODER_I("[MCU][AAC] Bad out len %u (should be %u)", out_len, out_frame_len); - set_cp_reset_flag(true); - return A2DP_DECODER_DECODE_ERROR; - } - p_out_info = (struct A2DP_CP_AAC_LC_OUT_FRM_INFO_T *)out; - if (p_out_info->pcm_len) { - a2dp_audio_aac_lastframe_info.sequenceNumber = p_out_info->in_info.sequenceNumber; - a2dp_audio_aac_lastframe_info.timestamp = p_out_info->in_info.timestamp; - a2dp_audio_aac_lastframe_info.curSubSequenceNumber = 0; - a2dp_audio_aac_lastframe_info.totalSubSequenceNumber = 0; - a2dp_audio_aac_lastframe_info.frame_samples = p_out_info->frame_samples; - a2dp_audio_aac_lastframe_info.decoded_frames += p_out_info->decoded_frames; - a2dp_audio_aac_lastframe_info.undecode_frames = - a2dp_audio_list_length(list) + a2dp_cp_get_in_frame_cnt_by_index(p_out_info->frame_idx) - 1; - a2dp_audio_aac_lastframe_info.check_sum= check_sum?check_sum:a2dp_audio_aac_lastframe_info.check_sum; - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_aac_lastframe_info); - } + if (out_len == 0) { + memset(buffer, 0, buffer_bytes); + a2dp_cp_consume_full_out_frame(); + TRACE_A2DP_DECODER_I("[MCU][AAC] olz!!!%d ", __LINE__); + return A2DP_DECODER_NO_ERROR; + } + if (out_len != out_frame_len) { + TRACE_A2DP_DECODER_I("[MCU][AAC] Bad out len %u (should be %u)", out_len, + out_frame_len); + set_cp_reset_flag(true); + return A2DP_DECODER_DECODE_ERROR; + } + p_out_info = (struct A2DP_CP_AAC_LC_OUT_FRM_INFO_T *)out; + if (p_out_info->pcm_len) { + a2dp_audio_aac_lastframe_info.sequenceNumber = + p_out_info->in_info.sequenceNumber; + a2dp_audio_aac_lastframe_info.timestamp = p_out_info->in_info.timestamp; + a2dp_audio_aac_lastframe_info.curSubSequenceNumber = 0; + a2dp_audio_aac_lastframe_info.totalSubSequenceNumber = 0; + a2dp_audio_aac_lastframe_info.frame_samples = p_out_info->frame_samples; + a2dp_audio_aac_lastframe_info.decoded_frames += p_out_info->decoded_frames; + a2dp_audio_aac_lastframe_info.undecode_frames = + a2dp_audio_list_length(list) + + a2dp_cp_get_in_frame_cnt_by_index(p_out_info->frame_idx) - 1; + a2dp_audio_aac_lastframe_info.check_sum = + check_sum ? check_sum : a2dp_audio_aac_lastframe_info.check_sum; + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_aac_lastframe_info); + } - if (p_out_info->pcm_len == buffer_bytes) { - memcpy(buffer, p_out_info + 1, p_out_info->pcm_len); - dec_ret = A2DP_DECODER_NO_ERROR; - } else { - TRACE_A2DP_DECODER_I("[MCU][AAC] olne!!!%d ", __LINE__); - set_cp_reset_flag(true); - return A2DP_DECODER_DECODE_ERROR; - } + if (p_out_info->pcm_len == buffer_bytes) { + memcpy(buffer, p_out_info + 1, p_out_info->pcm_len); + dec_ret = A2DP_DECODER_NO_ERROR; + } else { + TRACE_A2DP_DECODER_I("[MCU][AAC] olne!!!%d ", __LINE__); + set_cp_reset_flag(true); + return A2DP_DECODER_DECODE_ERROR; + } - ret = a2dp_cp_consume_full_out_frame(); - if (ret){ + ret = a2dp_cp_consume_full_out_frame(); + if (ret) { - TRACE_A2DP_DECODER_I("[MCU][AAC] cp consume_full_out_frame() failed: ret=%d", ret); - set_cp_reset_flag(true); - return A2DP_DECODER_DECODE_ERROR; - } - return dec_ret; + TRACE_A2DP_DECODER_I( + "[MCU][AAC] cp consume_full_out_frame() failed: ret=%d", ret); + set_cp_reset_flag(true); + return A2DP_DECODER_DECODE_ERROR; + } + return dec_ret; } - #ifdef __CP_EXCEPTION_TEST__ -static bool _cp_assert = false; - int cp_assert(void) -{ - _cp_assert = true; - return 0; +static bool _cp_assert = false; +int cp_assert(void) { + _cp_assert = true; + return 0; } #endif TEXT_AAC_LOC -int a2dp_cp_aac_lc_cp_decode(void) -{ - int ret; - enum CP_EMPTY_OUT_FRM_T out_frm_st; - uint8_t *out; - uint32_t out_len; - bool need_refill = false; - uint8_t *dec_start; - uint32_t dec_len; - struct A2DP_CP_AAC_LC_IN_FRM_INFO_T *p_in_info; - struct A2DP_CP_AAC_LC_OUT_FRM_INFO_T *p_out_info; - uint8_t *in_buf; - uint32_t in_len; - uint32_t dec_sum; - int error; - uint32_t aac_maxreadBytes = AAC_READBUF_SIZE; - UINT bufferSize = 0, bytesValid = 0; - AAC_DECODER_ERROR decoder_err = AAC_DEC_OK; - CStreamInfo *stream_info=NULL; - if (cp_codec_reset) { - cp_codec_reset = false; - a2dp_audio_aac_lc_decoder_init(); - } +int a2dp_cp_aac_lc_cp_decode(void) { + int ret; + enum CP_EMPTY_OUT_FRM_T out_frm_st; + uint8_t *out; + uint32_t out_len; + bool need_refill = false; + uint8_t *dec_start; + uint32_t dec_len; + struct A2DP_CP_AAC_LC_IN_FRM_INFO_T *p_in_info; + struct A2DP_CP_AAC_LC_OUT_FRM_INFO_T *p_out_info; + uint8_t *in_buf; + uint32_t in_len; + uint32_t dec_sum; + int error; + uint32_t aac_maxreadBytes = AAC_READBUF_SIZE; + UINT bufferSize = 0, bytesValid = 0; + AAC_DECODER_ERROR decoder_err = AAC_DEC_OK; + CStreamInfo *stream_info = NULL; + if (cp_codec_reset) { + cp_codec_reset = false; + a2dp_audio_aac_lc_decoder_init(); + } #ifdef __CP_EXCEPTION_TEST__ - if (_cp_assert){ - _cp_assert = false; - *(int*) 0 = 1; - //ASSERT_A2DP_DECODER(0, "ASSERT_A2DP_DECODER %s %d", __func__, __LINE__); - } + if (_cp_assert) { + _cp_assert = false; + *(int *)0 = 1; + // ASSERT_A2DP_DECODER(0, "ASSERT_A2DP_DECODER %s %d", __func__, __LINE__); + } #endif - out_frm_st = a2dp_cp_get_emtpy_out_frame((void **)&out, &out_len); - if (out_frm_st != CP_EMPTY_OUT_FRM_OK && out_frm_st != CP_EMPTY_OUT_FRM_WORKING) { - return 1; - } - ASSERT_A2DP_DECODER(out_len > sizeof(*p_out_info), "%s: Bad out_len %u (should > %u)", __func__, out_len, sizeof(*p_out_info)); + out_frm_st = a2dp_cp_get_emtpy_out_frame((void **)&out, &out_len); + if (out_frm_st != CP_EMPTY_OUT_FRM_OK && + out_frm_st != CP_EMPTY_OUT_FRM_WORKING) { + return 1; + } + ASSERT_A2DP_DECODER(out_len > sizeof(*p_out_info), + "%s: Bad out_len %u (should > %u)", __func__, out_len, + sizeof(*p_out_info)); - p_out_info = (struct A2DP_CP_AAC_LC_OUT_FRM_INFO_T *)out; - if (out_frm_st == CP_EMPTY_OUT_FRM_OK) { - p_out_info->pcm_len = 0; - p_out_info->decoded_frames = 0; - } - ASSERT_A2DP_DECODER(out_len > sizeof(*p_out_info) + p_out_info->pcm_len, "%s: Bad out_len %u (should > %u + %u)", __func__, out_len, sizeof(*p_out_info), p_out_info->pcm_len); + p_out_info = (struct A2DP_CP_AAC_LC_OUT_FRM_INFO_T *)out; + if (out_frm_st == CP_EMPTY_OUT_FRM_OK) { + p_out_info->pcm_len = 0; + p_out_info->decoded_frames = 0; + } + ASSERT_A2DP_DECODER(out_len > sizeof(*p_out_info) + p_out_info->pcm_len, + "%s: Bad out_len %u (should > %u + %u)", __func__, + out_len, sizeof(*p_out_info), p_out_info->pcm_len); - dec_start = (uint8_t *)(p_out_info + 1) + p_out_info->pcm_len; - dec_len = out_len - (dec_start - (uint8_t *)out); + dec_start = (uint8_t *)(p_out_info + 1) + p_out_info->pcm_len; + dec_len = out_len - (dec_start - (uint8_t *)out); - if(dec_len < DECODE_AAC_PCM_FRAME_LENGTH){ - TRACE_A2DP_DECODER_W("[CP][AAC] aac_lc_decode pcm_len = %d \n", dec_len); - return 2; + if (dec_len < DECODE_AAC_PCM_FRAME_LENGTH) { + TRACE_A2DP_DECODER_W("[CP][AAC] aac_lc_decode pcm_len = %d \n", dec_len); + return 2; + } + if (!aacDec_handle) { + TRACE_A2DP_DECODER_W("[CP][AAC] aac_lc_decode not ready"); + return 3; + } + + dec_sum = 0; + error = 0; + + while (dec_sum < dec_len && error == 0) { + ret = a2dp_cp_get_in_frame((void **)&in_buf, &in_len); + if (ret) { + return 4; } - if(!aacDec_handle){ - TRACE_A2DP_DECODER_W("[CP][AAC] aac_lc_decode not ready"); - return 3; + ASSERT_A2DP_DECODER(in_len > sizeof(*p_in_info), + "[CP][AAC] Bad in_len %u (should > %u)", in_len, + sizeof(*p_in_info)); + + p_in_info = (struct A2DP_CP_AAC_LC_IN_FRM_INFO_T *)in_buf; + if (need_refill) { + p_in_info->sequenceNumber = UINT16_MAX; + } + in_buf += sizeof(*p_in_info); + in_len -= sizeof(*p_in_info); + + if (in_len < 64) + aac_maxreadBytes = 64; + else if (in_len < 128) + aac_maxreadBytes = 128; + else if (in_len < 256) + aac_maxreadBytes = 256; + else if (in_len < 512) + aac_maxreadBytes = 512; + else if (in_len < 1024) + aac_maxreadBytes = 1024; + + bufferSize = aac_maxreadBytes; + bytesValid = aac_maxreadBytes; + decoder_err = + aacDecoder_Fill(aacDec_handle, &in_buf, &bufferSize, &bytesValid); + if (decoder_err != AAC_DEC_OK) { + TRACE_A2DP_DECODER_W("[CP][AAC] decoder_Fill failed:0x%x", decoder_err); + // if aac failed reopen it again + if (is_aacDecoder_Close(aacDec_handle)) { + a2dp_audio_aac_lc_decoder_reinit(); + TRACE_A2DP_DECODER_I("[CP][AAC] aac_lc_decode reinin codec \n"); + } + error = 1; + goto end_decode; } - dec_sum = 0; - error = 0; - - while (dec_sum < dec_len && error == 0) { - ret = a2dp_cp_get_in_frame((void **)&in_buf, &in_len); - if (ret) { - return 4; - } - ASSERT_A2DP_DECODER(in_len > sizeof(*p_in_info), "[CP][AAC] Bad in_len %u (should > %u)", in_len, sizeof(*p_in_info)); - - p_in_info = (struct A2DP_CP_AAC_LC_IN_FRM_INFO_T *)in_buf; - if (need_refill){ - p_in_info->sequenceNumber = UINT16_MAX; - } - in_buf += sizeof(*p_in_info); - in_len -= sizeof(*p_in_info); - - if (in_len < 64) - aac_maxreadBytes = 64; - else if (in_len < 128) - aac_maxreadBytes = 128; - else if (in_len < 256) - aac_maxreadBytes = 256; - else if (in_len < 512) - aac_maxreadBytes = 512; - else if (in_len < 1024) - aac_maxreadBytes = 1024; - - bufferSize = aac_maxreadBytes; - bytesValid = aac_maxreadBytes; - decoder_err = aacDecoder_Fill(aacDec_handle, &in_buf, &bufferSize, &bytesValid); - if (decoder_err != AAC_DEC_OK) { - TRACE_A2DP_DECODER_W("[CP][AAC] decoder_Fill failed:0x%x", decoder_err); - //if aac failed reopen it again - if(is_aacDecoder_Close(aacDec_handle)){ - a2dp_audio_aac_lc_decoder_reinit(); - TRACE_A2DP_DECODER_I("[CP][AAC] aac_lc_decode reinin codec \n"); - } - error = 1; - goto end_decode; - } - - /* decode one AAC frame */ - decoder_err = aacDecoder_DecodeFrame(aacDec_handle, (short *)(dec_start + dec_sum), (dec_len - dec_sum) / 2, 0 /* flags */); - TRACE_A2DP_DECODER_D("[CP][AAC] decoder seq:%d len:%d err:%x", p_in_info->sequenceNumber, - (dec_len - dec_sum), - decoder_err); - if (decoder_err != AAC_DEC_OK){ - TRACE_A2DP_DECODER_W("[CP][AAC] aac_lc_decode failed:0x%x seq:%d", decoder_err, p_in_info->sequenceNumber); - //if aac failed reopen it again - a2dp_audio_aac_lc_decoder_reinit(); - TRACE_A2DP_DECODER_I("[CP][AAC]aac_lc_decode reinin codec \n"); - if(!need_refill){ - need_refill = true; - ret = a2dp_cp_consume_in_frame(); - ASSERT(ret == 0, "%s: a2dp_cp_consume_in_frame() failed: ret=%d", __func__, ret); - continue; - }else{ - need_refill = false; - error = 1; - goto end_decode; - } - } - - stream_info = aacDecoder_GetStreamInfo(aacDec_handle); - if (!stream_info || stream_info->sampleRate <= 0) { - TRACE_A2DP_DECODER_I("[CP][AAC]aac_lc_decode invalid stream info"); - error = 1; - goto end_decode; - } - - bufferSize = stream_info->frameSize * stream_info->numChannels * 2;//sizeof(pcm_buffer[0]); - ASSERT_A2DP_DECODER(AAC_OUTPUT_FRAME_SAMPLES == bufferSize/4, "aac_lc_decode output mismatch samples:%d", bufferSize/4); - - dec_sum += bufferSize; - -end_decode: - memcpy(&p_out_info->in_info, p_in_info, sizeof(*p_in_info)); - p_out_info->decoded_frames++; - p_out_info->frame_samples = AAC_OUTPUT_FRAME_SAMPLES; - p_out_info->frame_idx = a2dp_cp_get_in_frame_index(); - if (need_refill){ - TRACE_A2DP_DECODER_W("[CP][AAC] resume refill seq:%d", p_in_info->sequenceNumber); - }else{ - ret = a2dp_cp_consume_in_frame(); - ASSERT_A2DP_DECODER(ret == 0, "[CP][AAC] a2dp_cp_consume_in_frame() failed: ret=%d", ret); - } + /* decode one AAC frame */ + decoder_err = + aacDecoder_DecodeFrame(aacDec_handle, (short *)(dec_start + dec_sum), + (dec_len - dec_sum) / 2, 0 /* flags */); + TRACE_A2DP_DECODER_D("[CP][AAC] decoder seq:%d len:%d err:%x", + p_in_info->sequenceNumber, (dec_len - dec_sum), + decoder_err); + if (decoder_err != AAC_DEC_OK) { + TRACE_A2DP_DECODER_W("[CP][AAC] aac_lc_decode failed:0x%x seq:%d", + decoder_err, p_in_info->sequenceNumber); + // if aac failed reopen it again + a2dp_audio_aac_lc_decoder_reinit(); + TRACE_A2DP_DECODER_I("[CP][AAC]aac_lc_decode reinin codec \n"); + if (!need_refill) { + need_refill = true; + ret = a2dp_cp_consume_in_frame(); + ASSERT(ret == 0, "%s: a2dp_cp_consume_in_frame() failed: ret=%d", + __func__, ret); + continue; + } else { + need_refill = false; + error = 1; + goto end_decode; + } } - p_out_info->pcm_len += dec_sum; - - if (error || out_len <= sizeof(*p_out_info) + p_out_info->pcm_len) { - ret = a2dp_cp_consume_emtpy_out_frame(); - ASSERT_A2DP_DECODER(ret == 0, "[CP][AAC] a2dp_cp_consume_emtpy_out_frame() failed: ret=%d", ret); + stream_info = aacDecoder_GetStreamInfo(aacDec_handle); + if (!stream_info || stream_info->sampleRate <= 0) { + TRACE_A2DP_DECODER_I("[CP][AAC]aac_lc_decode invalid stream info"); + error = 1; + goto end_decode; } - return error; + bufferSize = stream_info->frameSize * stream_info->numChannels * + 2; // sizeof(pcm_buffer[0]); + ASSERT_A2DP_DECODER(AAC_OUTPUT_FRAME_SAMPLES == bufferSize / 4, + "aac_lc_decode output mismatch samples:%d", + bufferSize / 4); + + dec_sum += bufferSize; + + end_decode: + memcpy(&p_out_info->in_info, p_in_info, sizeof(*p_in_info)); + p_out_info->decoded_frames++; + p_out_info->frame_samples = AAC_OUTPUT_FRAME_SAMPLES; + p_out_info->frame_idx = a2dp_cp_get_in_frame_index(); + if (need_refill) { + TRACE_A2DP_DECODER_W("[CP][AAC] resume refill seq:%d", + p_in_info->sequenceNumber); + } else { + ret = a2dp_cp_consume_in_frame(); + ASSERT_A2DP_DECODER( + ret == 0, "[CP][AAC] a2dp_cp_consume_in_frame() failed: ret=%d", ret); + } + } + + p_out_info->pcm_len += dec_sum; + + if (error || out_len <= sizeof(*p_out_info) + p_out_info->pcm_len) { + ret = a2dp_cp_consume_emtpy_out_frame(); + ASSERT_A2DP_DECODER( + ret == 0, "[CP][AAC] a2dp_cp_consume_emtpy_out_frame() failed: ret=%d", + ret); + } + + return error; } #endif -static int a2dp_audio_aac_lc_list_checker(void) -{ - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = NULL; - int cnt = 0; +static int a2dp_audio_aac_lc_list_checker(void) { + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = NULL; + int cnt = 0; - do { - aac_decoder_frame_p = (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_aac_lc_frame_malloc(0); - if (aac_decoder_frame_p){ - a2dp_audio_list_append(list, aac_decoder_frame_p); - } - cnt++; - }while(aac_decoder_frame_p && cnt < AAC_MTU_LIMITER); - - do { - if ((node = a2dp_audio_list_begin(list)) != NULL){ - aac_decoder_frame_p = (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_list_node(node); - a2dp_audio_list_remove(list, aac_decoder_frame_p); - } - }while(node); - - TRACE_A2DP_DECODER_I("[AAC][INIT] cnt:%d list:%d", cnt, a2dp_audio_list_length(list)); - - return 0; -} - -int a2dp_audio_aac_lc_channel_select(A2DP_AUDIO_CHANNEL_SELECT_E chnl_sel) -{ - AAC_DECODER_CHANNEL_SELECT_E aac_decoder_channel_select = AAC_DECODER_CHANNEL_SELECT_SELECT_STEREO; - switch(chnl_sel) - { - case A2DP_AUDIO_CHANNEL_SELECT_STEREO: - aac_decoder_channel_select = AAC_DECODER_CHANNEL_SELECT_SELECT_STEREO; - break; - case A2DP_AUDIO_CHANNEL_SELECT_LRMERGE: - aac_decoder_channel_select = AAC_DECODER_CHANNEL_SELECT_SELECT_LRMERGE; - break; - case A2DP_AUDIO_CHANNEL_SELECT_LCHNL: - aac_decoder_channel_select = AAC_DECODER_CHANNEL_SELECT_LCHNL; - break; - case A2DP_AUDIO_CHANNEL_SELECT_RCHNL: - aac_decoder_channel_select = AAC_DECODER_CHANNEL_SELECT_RCHNL; - default: - break; + do { + aac_decoder_frame_p = + (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_aac_lc_frame_malloc(0); + if (aac_decoder_frame_p) { + a2dp_audio_list_append(list, aac_decoder_frame_p); } - aacDecoder_DecodeFrame_Config(aac_decoder_channel_select); + cnt++; + } while (aac_decoder_frame_p && cnt < AAC_MTU_LIMITER); - return 0; + do { + if ((node = a2dp_audio_list_begin(list)) != NULL) { + aac_decoder_frame_p = + (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_list_node(node); + a2dp_audio_list_remove(list, aac_decoder_frame_p); + } + } while (node); + + TRACE_A2DP_DECODER_I("[AAC][INIT] cnt:%d list:%d", cnt, + a2dp_audio_list_length(list)); + + return 0; } -int a2dp_audio_aac_lc_init(A2DP_AUDIO_OUTPUT_CONFIG_T *config, void *context) -{ - TRACE_A2DP_DECODER_I("[AAC] init"); +int a2dp_audio_aac_lc_channel_select(A2DP_AUDIO_CHANNEL_SELECT_E chnl_sel) { + AAC_DECODER_CHANNEL_SELECT_E aac_decoder_channel_select = + AAC_DECODER_CHANNEL_SELECT_SELECT_STEREO; + switch (chnl_sel) { + case A2DP_AUDIO_CHANNEL_SELECT_STEREO: + aac_decoder_channel_select = AAC_DECODER_CHANNEL_SELECT_SELECT_STEREO; + break; + case A2DP_AUDIO_CHANNEL_SELECT_LRMERGE: + aac_decoder_channel_select = AAC_DECODER_CHANNEL_SELECT_SELECT_LRMERGE; + break; + case A2DP_AUDIO_CHANNEL_SELECT_LCHNL: + aac_decoder_channel_select = AAC_DECODER_CHANNEL_SELECT_LCHNL; + break; + case A2DP_AUDIO_CHANNEL_SELECT_RCHNL: + aac_decoder_channel_select = AAC_DECODER_CHANNEL_SELECT_RCHNL; + default: + break; + } + aacDecoder_DecodeFrame_Config(aac_decoder_channel_select); - a2dp_audio_context_p = (A2DP_AUDIO_CONTEXT_T *)context; + return 0; +} - memset(&a2dp_audio_aac_lastframe_info, 0, sizeof(A2DP_AUDIO_DECODER_LASTFRAME_INFO_T)); - a2dp_audio_aac_lastframe_info.stream_info = *config; - a2dp_audio_aac_lastframe_info.frame_samples = AAC_OUTPUT_FRAME_SAMPLES; - a2dp_audio_aac_lastframe_info.list_samples = AAC_OUTPUT_FRAME_SAMPLES; - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_aac_lastframe_info); +int a2dp_audio_aac_lc_init(A2DP_AUDIO_OUTPUT_CONFIG_T *config, void *context) { + TRACE_A2DP_DECODER_I("[AAC] init"); - ASSERT_A2DP_DECODER(a2dp_audio_context_p->dest_packet_mut < AAC_MTU_LIMITER, "%s MTU OVERFLOW:%u/%u", __func__, a2dp_audio_context_p->dest_packet_mut, AAC_MTU_LIMITER); + a2dp_audio_context_p = (A2DP_AUDIO_CONTEXT_T *)context; - aac_mempoll = (uint8_t *)a2dp_audio_heap_malloc(AAC_MEMPOOL_SIZE); - ASSERT_A2DP_DECODER(aac_mempoll, "aac_mempoll = NULL"); - aac_memhandle = heap_register(aac_mempoll, AAC_MEMPOOL_SIZE); + memset(&a2dp_audio_aac_lastframe_info, 0, + sizeof(A2DP_AUDIO_DECODER_LASTFRAME_INFO_T)); + a2dp_audio_aac_lastframe_info.stream_info = *config; + a2dp_audio_aac_lastframe_info.frame_samples = AAC_OUTPUT_FRAME_SAMPLES; + a2dp_audio_aac_lastframe_info.list_samples = AAC_OUTPUT_FRAME_SAMPLES; + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_aac_lastframe_info); + + ASSERT_A2DP_DECODER(a2dp_audio_context_p->dest_packet_mut < AAC_MTU_LIMITER, + "%s MTU OVERFLOW:%u/%u", __func__, + a2dp_audio_context_p->dest_packet_mut, AAC_MTU_LIMITER); + + aac_mempoll = (uint8_t *)a2dp_audio_heap_malloc(AAC_MEMPOOL_SIZE); + ASSERT_A2DP_DECODER(aac_mempoll, "aac_mempoll = NULL"); + aac_memhandle = heap_register(aac_mempoll, AAC_MEMPOOL_SIZE); #ifdef A2DP_CP_ACCEL - int ret; + int ret; - cp_codec_reset = true; - ret = a2dp_cp_init(a2dp_cp_aac_lc_cp_decode, CP_PROC_DELAY_2_FRAMES); - ASSERT_A2DP_DECODER(ret == 0, "%s: a2dp_cp_init() failed: ret=%d", __func__, ret); + cp_codec_reset = true; + ret = a2dp_cp_init(a2dp_cp_aac_lc_cp_decode, CP_PROC_DELAY_2_FRAMES); + ASSERT_A2DP_DECODER(ret == 0, "%s: a2dp_cp_init() failed: ret=%d", __func__, + ret); #else - a2dp_audio_aac_lc_decoder_init(); + a2dp_audio_aac_lc_decoder_init(); #endif - a2dp_audio_aac_lc_reorder_init(); - a2dp_audio_aac_lc_list_checker(); + a2dp_audio_aac_lc_reorder_init(); + a2dp_audio_aac_lc_list_checker(); - a2dp_audio_aac_lc_channel_select(a2dp_audio_context_p->chnl_sel); + a2dp_audio_aac_lc_channel_select(a2dp_audio_context_p->chnl_sel); - return A2DP_DECODER_NO_ERROR; + return A2DP_DECODER_NO_ERROR; } - -int a2dp_audio_aac_lc_deinit(void) -{ +int a2dp_audio_aac_lc_deinit(void) { #ifdef A2DP_CP_ACCEL - a2dp_cp_deinit(); + a2dp_cp_deinit(); #endif - a2dp_audio_aac_lc_decoder_deinit(); - a2dp_audio_aac_lc_reorder_deinit(); - size_t total = 0, used = 0, max_used = 0; - heap_memory_info(aac_memhandle, &total, &used, &max_used); - a2dp_audio_heap_free(aac_mempoll); - TRACE_A2DP_DECODER_I("[AAC] deinit MEM: total - %d, used - %d, max_used - %d.", - total, used, max_used); + a2dp_audio_aac_lc_decoder_deinit(); + a2dp_audio_aac_lc_reorder_deinit(); + size_t total = 0, used = 0, max_used = 0; + heap_memory_info(aac_memhandle, &total, &used, &max_used); + a2dp_audio_heap_free(aac_mempoll); + TRACE_A2DP_DECODER_I( + "[AAC] deinit MEM: total - %d, used - %d, max_used - %d.", total, used, + max_used); + return A2DP_DECODER_NO_ERROR; +} + +int a2dp_audio_aac_lc_mcu_decode_frame(uint8_t *buffer, uint32_t buffer_bytes) { + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = NULL; + + UINT bufferSize = 0, bytesValid = 0; + AAC_DECODER_ERROR decoder_err = AAC_DEC_OK; + CStreamInfo *stream_info = NULL; + + bool cache_underflow = false; + uint32_t aac_maxreadBytes = AAC_READBUF_SIZE; + int output_byte = 0; + + if (buffer_bytes < DECODE_AAC_PCM_FRAME_LENGTH) { + TRACE_A2DP_DECODER_W("[MCU][AAC] pcm_len = %d \n", buffer_bytes); return A2DP_DECODER_NO_ERROR; -} + } + if (!aacDec_handle) { + TRACE_A2DP_DECODER_W("[MCU][AAC] aac_lc_decode not ready"); + return A2DP_DECODER_NO_ERROR; + } -int a2dp_audio_aac_lc_mcu_decode_frame(uint8_t *buffer, uint32_t buffer_bytes) -{ - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = NULL; + node = a2dp_audio_list_begin(list); + if (!node) { + TRACE_A2DP_DECODER_W("[MCU][AAC] cache underflow"); + cache_underflow = true; + goto exit; + } else { + aac_decoder_frame_p = + (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_list_node(node); - UINT bufferSize = 0, bytesValid = 0; - AAC_DECODER_ERROR decoder_err = AAC_DEC_OK; - CStreamInfo *stream_info=NULL; + if (aac_decoder_frame_p->aac_buffer_len < 64) + aac_maxreadBytes = 64; + else if (aac_decoder_frame_p->aac_buffer_len < 128) + aac_maxreadBytes = 128; + else if (aac_decoder_frame_p->aac_buffer_len < 256) + aac_maxreadBytes = 256; + else if (aac_decoder_frame_p->aac_buffer_len < 512) + aac_maxreadBytes = 512; + else if (aac_decoder_frame_p->aac_buffer_len < 1024) + aac_maxreadBytes = 1024; - bool cache_underflow = false; - uint32_t aac_maxreadBytes = AAC_READBUF_SIZE; - int output_byte = 0; - - if(buffer_bytes < DECODE_AAC_PCM_FRAME_LENGTH){ - TRACE_A2DP_DECODER_W("[MCU][AAC] pcm_len = %d \n", buffer_bytes); - return A2DP_DECODER_NO_ERROR; - } - if(!aacDec_handle){ - TRACE_A2DP_DECODER_W("[MCU][AAC] aac_lc_decode not ready"); - return A2DP_DECODER_NO_ERROR; + bufferSize = aac_maxreadBytes; + bytesValid = aac_maxreadBytes; + decoder_err = + aacDecoder_Fill(aacDec_handle, &(aac_decoder_frame_p->aac_buffer), + &bufferSize, &bytesValid); + if (decoder_err != AAC_DEC_OK) { + TRACE_A2DP_DECODER_W("[MCU][AAC] aacDecoder_Fill failed:0x%x", + decoder_err); + // if aac failed reopen it again + if (is_aacDecoder_Close(aacDec_handle)) { + a2dp_audio_aac_lc_decoder_reinit(); + TRACE_A2DP_DECODER_I("[MCU][AAC] aac_lc_decode reinin codec \n"); + } + goto end_decode; } - node = a2dp_audio_list_begin(list); - if (!node){ - TRACE_A2DP_DECODER_W("[MCU][AAC] cache underflow"); - cache_underflow = true; - goto exit; - }else{ - aac_decoder_frame_p = (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_list_node(node); - - if (aac_decoder_frame_p->aac_buffer_len < 64) - aac_maxreadBytes = 64; - else if (aac_decoder_frame_p->aac_buffer_len < 128) - aac_maxreadBytes = 128; - else if (aac_decoder_frame_p->aac_buffer_len < 256) - aac_maxreadBytes = 256; - else if (aac_decoder_frame_p->aac_buffer_len < 512) - aac_maxreadBytes = 512; - else if (aac_decoder_frame_p->aac_buffer_len < 1024) - aac_maxreadBytes = 1024; - - bufferSize = aac_maxreadBytes; - bytesValid = aac_maxreadBytes; - decoder_err = aacDecoder_Fill(aacDec_handle, &(aac_decoder_frame_p->aac_buffer), &bufferSize, &bytesValid); - if (decoder_err != AAC_DEC_OK) { - TRACE_A2DP_DECODER_W("[MCU][AAC] aacDecoder_Fill failed:0x%x", decoder_err); - //if aac failed reopen it again - if(is_aacDecoder_Close(aacDec_handle)){ - a2dp_audio_aac_lc_decoder_reinit(); - TRACE_A2DP_DECODER_I("[MCU][AAC] aac_lc_decode reinin codec \n"); - } - goto end_decode; - } - - /* decode one AAC frame */ - decoder_err = aacDecoder_DecodeFrame(aacDec_handle, (short *)buffer, buffer_bytes/2, 0 /* flags */); - TRACE_A2DP_DECODER_D("[MCU][AAC] decoder seq:%d len:%d err:%x", aac_decoder_frame_p->sequenceNumber, - aac_decoder_frame_p->aac_buffer_len, - decoder_err); - if (decoder_err != AAC_DEC_OK){ - TRACE_A2DP_DECODER_W("[MCU][AAC]aac_lc_decode failed:0x%x", decoder_err); - //if aac failed reopen it again - if(is_aacDecoder_Close(aacDec_handle)){ - a2dp_audio_aac_lc_decoder_reinit(); - TRACE_A2DP_DECODER_I("[MCU][AAC]aac_lc_decode reinin codec \n"); - } - goto end_decode; - } - - stream_info = aacDecoder_GetStreamInfo(aacDec_handle); - if (!stream_info || stream_info->sampleRate <= 0) { - TRACE_A2DP_DECODER_W("[MCU][AAC]aac_lc_decode invalid stream info"); - goto end_decode; - } - - output_byte = stream_info->frameSize * stream_info->numChannels * 2;//sizeof(pcm_buffer[0]); - ASSERT_A2DP_DECODER(AAC_OUTPUT_FRAME_SAMPLES == output_byte/4, "aac_lc_decode output mismatch samples:%d", output_byte/4); -end_decode: - a2dp_audio_aac_lastframe_info.sequenceNumber = aac_decoder_frame_p->sequenceNumber; - a2dp_audio_aac_lastframe_info.timestamp = aac_decoder_frame_p->timestamp; - a2dp_audio_aac_lastframe_info.curSubSequenceNumber = 0; - a2dp_audio_aac_lastframe_info.totalSubSequenceNumber = 0; - a2dp_audio_aac_lastframe_info.frame_samples = AAC_OUTPUT_FRAME_SAMPLES; - a2dp_audio_aac_lastframe_info.decoded_frames++; - a2dp_audio_aac_lastframe_info.undecode_frames = a2dp_audio_list_length(list)-1; - a2dp_audio_aac_lastframe_info.check_sum= a2dp_audio_decoder_internal_check_sum_generate(aac_decoder_frame_p->aac_buffer, aac_decoder_frame_p->aac_buffer_len); - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_aac_lastframe_info); - a2dp_audio_list_remove(list, aac_decoder_frame_p); + /* decode one AAC frame */ + decoder_err = aacDecoder_DecodeFrame(aacDec_handle, (short *)buffer, + buffer_bytes / 2, 0 /* flags */); + TRACE_A2DP_DECODER_D("[MCU][AAC] decoder seq:%d len:%d err:%x", + aac_decoder_frame_p->sequenceNumber, + aac_decoder_frame_p->aac_buffer_len, decoder_err); + if (decoder_err != AAC_DEC_OK) { + TRACE_A2DP_DECODER_W("[MCU][AAC]aac_lc_decode failed:0x%x", decoder_err); + // if aac failed reopen it again + if (is_aacDecoder_Close(aacDec_handle)) { + a2dp_audio_aac_lc_decoder_reinit(); + TRACE_A2DP_DECODER_I("[MCU][AAC]aac_lc_decode reinin codec \n"); + } + goto end_decode; } -exit: - if(cache_underflow){ - a2dp_audio_aac_lastframe_info.undecode_frames = 0; - a2dp_audio_aac_lastframe_info.check_sum = 0; - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_aac_lastframe_info); - output_byte = A2DP_DECODER_CACHE_UNDERFLOW_ERROR; + + stream_info = aacDecoder_GetStreamInfo(aacDec_handle); + if (!stream_info || stream_info->sampleRate <= 0) { + TRACE_A2DP_DECODER_W("[MCU][AAC]aac_lc_decode invalid stream info"); + goto end_decode; } - return output_byte; -} -int a2dp_audio_aac_lc_decode_frame(uint8_t *buffer, uint32_t buffer_bytes) -{ -#ifdef A2DP_CP_ACCEL - return a2dp_cp_aac_lc_mcu_decode(buffer, buffer_bytes); -#else - return a2dp_audio_aac_lc_mcu_decode_frame(buffer, buffer_bytes); -#endif -} - -int a2dp_audio_aac_lc_preparse_packet(btif_media_header_t * header, uint8_t *buffer, uint32_t buffer_bytes) -{ - a2dp_audio_aac_lastframe_info.sequenceNumber = header->sequenceNumber; - a2dp_audio_aac_lastframe_info.timestamp = header->timestamp; + output_byte = stream_info->frameSize * stream_info->numChannels * + 2; // sizeof(pcm_buffer[0]); + ASSERT_A2DP_DECODER(AAC_OUTPUT_FRAME_SAMPLES == output_byte / 4, + "aac_lc_decode output mismatch samples:%d", + output_byte / 4); + end_decode: + a2dp_audio_aac_lastframe_info.sequenceNumber = + aac_decoder_frame_p->sequenceNumber; + a2dp_audio_aac_lastframe_info.timestamp = aac_decoder_frame_p->timestamp; a2dp_audio_aac_lastframe_info.curSubSequenceNumber = 0; a2dp_audio_aac_lastframe_info.totalSubSequenceNumber = 0; a2dp_audio_aac_lastframe_info.frame_samples = AAC_OUTPUT_FRAME_SAMPLES; - a2dp_audio_aac_lastframe_info.list_samples = AAC_OUTPUT_FRAME_SAMPLES; - a2dp_audio_aac_lastframe_info.decoded_frames = 0; + a2dp_audio_aac_lastframe_info.decoded_frames++; + a2dp_audio_aac_lastframe_info.undecode_frames = + a2dp_audio_list_length(list) - 1; + a2dp_audio_aac_lastframe_info.check_sum = + a2dp_audio_decoder_internal_check_sum_generate( + aac_decoder_frame_p->aac_buffer, + aac_decoder_frame_p->aac_buffer_len); + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_aac_lastframe_info); + a2dp_audio_list_remove(list, aac_decoder_frame_p); + } +exit: + if (cache_underflow) { a2dp_audio_aac_lastframe_info.undecode_frames = 0; a2dp_audio_aac_lastframe_info.check_sum = 0; - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_aac_lastframe_info); - - TRACE_A2DP_DECODER_I("[AAC][PRE] seq:%d timestamp:%08x", header->sequenceNumber, header->timestamp); - - return A2DP_DECODER_NO_ERROR; + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_aac_lastframe_info); + output_byte = A2DP_DECODER_CACHE_UNDERFLOW_ERROR; + } + return output_byte; } -int a2dp_audio_aac_lc_reorder_init(void) -{ - aac_decoder_frame_reorder_p = NULL; - aac_decoder_last_valid_frame_ready = false; - aac_decoder_last_valid_frame.sequenceNumber = 0; - aac_decoder_last_valid_frame.timestamp = 0; - aac_decoder_last_valid_frame.aac_buffer = NULL; - aac_decoder_last_valid_frame.aac_buffer_len = 0; - - return A2DP_DECODER_NO_ERROR; +int a2dp_audio_aac_lc_decode_frame(uint8_t *buffer, uint32_t buffer_bytes) { +#ifdef A2DP_CP_ACCEL + return a2dp_cp_aac_lc_mcu_decode(buffer, buffer_bytes); +#else + return a2dp_audio_aac_lc_mcu_decode_frame(buffer, buffer_bytes); +#endif } -int a2dp_audio_aac_lc_reorder_deinit(void) -{ - aac_decoder_frame_reorder_p = NULL; - aac_decoder_last_valid_frame_ready = false; - aac_decoder_last_valid_frame.sequenceNumber = 0; - aac_decoder_last_valid_frame.timestamp = 0; - aac_decoder_last_valid_frame.aac_buffer = NULL; - aac_decoder_last_valid_frame.aac_buffer_len = 0; - return A2DP_DECODER_NO_ERROR; +int a2dp_audio_aac_lc_preparse_packet(btif_media_header_t *header, + uint8_t *buffer, uint32_t buffer_bytes) { + a2dp_audio_aac_lastframe_info.sequenceNumber = header->sequenceNumber; + a2dp_audio_aac_lastframe_info.timestamp = header->timestamp; + a2dp_audio_aac_lastframe_info.curSubSequenceNumber = 0; + a2dp_audio_aac_lastframe_info.totalSubSequenceNumber = 0; + a2dp_audio_aac_lastframe_info.frame_samples = AAC_OUTPUT_FRAME_SAMPLES; + a2dp_audio_aac_lastframe_info.list_samples = AAC_OUTPUT_FRAME_SAMPLES; + a2dp_audio_aac_lastframe_info.decoded_frames = 0; + a2dp_audio_aac_lastframe_info.undecode_frames = 0; + a2dp_audio_aac_lastframe_info.check_sum = 0; + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_aac_lastframe_info); + + TRACE_A2DP_DECODER_I("[AAC][PRE] seq:%d timestamp:%08x", + header->sequenceNumber, header->timestamp); + + return A2DP_DECODER_NO_ERROR; } -int a2dp_audio_aac_lc_reorder_store_packet(a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p, - btif_media_header_t * header, uint8_t *buffer, uint32_t buffer_bytes) -{ +int a2dp_audio_aac_lc_reorder_init(void) { + aac_decoder_frame_reorder_p = NULL; + aac_decoder_last_valid_frame_ready = false; + aac_decoder_last_valid_frame.sequenceNumber = 0; + aac_decoder_last_valid_frame.timestamp = 0; + aac_decoder_last_valid_frame.aac_buffer = NULL; + aac_decoder_last_valid_frame.aac_buffer_len = 0; + + return A2DP_DECODER_NO_ERROR; +} + +int a2dp_audio_aac_lc_reorder_deinit(void) { + aac_decoder_frame_reorder_p = NULL; + aac_decoder_last_valid_frame_ready = false; + aac_decoder_last_valid_frame.sequenceNumber = 0; + aac_decoder_last_valid_frame.timestamp = 0; + aac_decoder_last_valid_frame.aac_buffer = NULL; + aac_decoder_last_valid_frame.aac_buffer_len = 0; + return A2DP_DECODER_NO_ERROR; +} + +int a2dp_audio_aac_lc_reorder_store_packet( + a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p, + btif_media_header_t *header, uint8_t *buffer, uint32_t buffer_bytes) { + aac_decoder_frame_p->sequenceNumber = header->sequenceNumber; + aac_decoder_frame_p->timestamp = header->timestamp; + memcpy(aac_decoder_frame_p->aac_buffer, buffer, buffer_bytes); + aac_decoder_frame_p->aac_buffer_len = buffer_bytes; + return A2DP_DECODER_NO_ERROR; +} + +int a2dp_audio_aac_lc_reorder_proc( + a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p, + btif_media_header_t *header, uint8_t *buffer, uint32_t buffer_bytes) { + uint8_t *dest_buf = NULL; + if ((aac_decoder_frame_p->aac_buffer_len + buffer_bytes) > AAC_READBUF_SIZE) { + return A2DP_DECODER_NO_ERROR; + } + TRACE_A2DP_DECODER_W("[AAC][INPUT][REORDER] proc enter seq:%d len:%d", + aac_decoder_frame_p->sequenceNumber, + aac_decoder_frame_p->aac_buffer_len); + dest_buf = + &aac_decoder_frame_p->aac_buffer[aac_decoder_frame_p->aac_buffer_len]; + memcpy(dest_buf, buffer, buffer_bytes); + aac_decoder_frame_p->aac_buffer_len += buffer_bytes; + TRACE_A2DP_DECODER_W("[AAC][INPUT][REORDER] proc exit seq:%d len:%d", + aac_decoder_frame_p->sequenceNumber, + aac_decoder_frame_p->aac_buffer_len); + + return A2DP_DECODER_NO_ERROR; +} + +int a2dp_audio_aac_lc_packet_recover_save_last( + a2dp_audio_aac_decoder_frame_t *aac_decoder_frame) { + aac_decoder_last_valid_frame_ready = true; + aac_decoder_last_valid_frame.sequenceNumber = + aac_decoder_frame->sequenceNumber; + aac_decoder_last_valid_frame.timestamp = aac_decoder_frame->timestamp; + return 0; +} + +int a2dp_audio_aac_lc_packet_recover_find_missing( + a2dp_audio_aac_decoder_frame_t *aac_decoder_frame) { + uint16_t diff_seq = 0; + uint32_t diff_timestamp = 0; + uint32_t diff = 0; + float tmp_pkt_cnt = 0; + uint32_t need_recover_pkt = 0; + + if (!aac_decoder_last_valid_frame_ready) { + return need_recover_pkt; + } + + diff_seq = a2dp_audio_get_passed(aac_decoder_frame->sequenceNumber, + aac_decoder_last_valid_frame.sequenceNumber, + UINT16_MAX); + diff_timestamp = + a2dp_audio_get_passed(aac_decoder_frame->timestamp, + aac_decoder_last_valid_frame.timestamp, UINT32_MAX); + + if (diff_seq > 1) { + TRACE_A2DP_DECODER_W("[AAC][INPUT][PLC] seq:%d/%d stmp:%d/%d", + aac_decoder_frame->sequenceNumber, + aac_decoder_last_valid_frame.sequenceNumber, + aac_decoder_frame->timestamp, + aac_decoder_last_valid_frame.timestamp); + diff = diff_timestamp / diff_seq; + if (diff % AAC_OUTPUT_FRAME_SAMPLES == 0) { + tmp_pkt_cnt = diff_timestamp / AAC_OUTPUT_FRAME_SAMPLES; + } else { + tmp_pkt_cnt = + (float)diff_timestamp / + ((1000.f / (float)a2dp_audio_context_p->output_cfg.sample_rate) * + (float)AAC_OUTPUT_FRAME_SAMPLES); + } + need_recover_pkt = (uint32_t)(tmp_pkt_cnt + 0.5f); + TRACE_A2DP_DECODER_W( + "[AAC][INPUT][PLC] diff_seq:%d diff_stmp:%d diff:%d missing:%d", + diff_seq, diff_timestamp, diff, need_recover_pkt); + if (need_recover_pkt == diff_seq) { + need_recover_pkt--; + TRACE_A2DP_DECODER_W("[AAC][INPUT][PLC] need_recover_pkt seq:%d", + need_recover_pkt); + } else { + need_recover_pkt = 0; + } + } + return need_recover_pkt; +} + +int a2dp_audio_aac_lc_packet_recover_proc( + a2dp_audio_aac_decoder_frame_t *aac_decoder_frame) { + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + int missing_pkt_cnt = 0; + missing_pkt_cnt = + a2dp_audio_aac_lc_packet_recover_find_missing(aac_decoder_frame); + if (missing_pkt_cnt <= 4 && + a2dp_audio_list_length(list) + missing_pkt_cnt < aac_mtu_limiter) { + for (uint8_t i = 0; i < missing_pkt_cnt; i++) { + a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = + (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_aac_lc_frame_malloc( + aac_decoder_frame->aac_buffer_len); + aac_decoder_frame_p->sequenceNumber = UINT16_MAX; + aac_decoder_frame_p->timestamp = UINT32_MAX; + memcpy(aac_decoder_frame_p->aac_buffer, aac_decoder_frame->aac_buffer, + aac_decoder_frame->aac_buffer_len); + aac_decoder_frame_p->aac_buffer_len = aac_decoder_frame->aac_buffer_len; + a2dp_audio_list_append(list, aac_decoder_frame_p); + } + } + + return A2DP_DECODER_NO_ERROR; +} + +int inline a2dp_audio_aac_lc_packet_append( + a2dp_audio_aac_decoder_frame_t *aac_decoder_frame) { + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + a2dp_audio_aac_lc_packet_recover_proc(aac_decoder_frame); + a2dp_audio_aac_lc_packet_recover_save_last(aac_decoder_frame); + a2dp_audio_list_append(list, aac_decoder_frame); + return 0; +} + +#if 1 +int a2dp_audio_aac_lc_store_packet(btif_media_header_t *header, uint8_t *buffer, + uint32_t buffer_bytes) { + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + int nRet = A2DP_DECODER_NO_ERROR; + a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = NULL; + + if (a2dp_audio_list_length(list) < aac_mtu_limiter && + buffer_bytes <= AAC_READBUF_SIZE) { + if (aac_decoder_frame_reorder_p == NULL) { + aac_decoder_frame_p = + (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_aac_lc_frame_malloc( + buffer_bytes); + aac_decoder_frame_reorder_p = aac_decoder_frame_p; + TRACE_A2DP_DECODER_W("[AAC][INPUT][REORDER] start seq:%d len:%d", + header->sequenceNumber, buffer_bytes); + a2dp_audio_aac_lc_reorder_store_packet(aac_decoder_frame_p, header, + buffer, buffer_bytes); + } else { + if (aac_decoder_frame_reorder_p->aac_buffer[0] == buffer[0] && + aac_decoder_frame_reorder_p->aac_buffer[1] == buffer[1]) { + a2dp_audio_aac_lc_packet_append(aac_decoder_frame_reorder_p); + aac_decoder_frame_p = + (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_aac_lc_frame_malloc( + buffer_bytes); + aac_decoder_frame_reorder_p = aac_decoder_frame_p; + a2dp_audio_aac_lc_reorder_store_packet(aac_decoder_frame_p, header, + buffer, buffer_bytes); + } else { + aac_decoder_frame_p = aac_decoder_frame_reorder_p; + a2dp_audio_aac_lc_reorder_proc(aac_decoder_frame_p, header, buffer, + buffer_bytes); + a2dp_audio_aac_lc_packet_append(aac_decoder_frame_p); + aac_decoder_frame_reorder_p = NULL; + } + } + nRet = A2DP_DECODER_NO_ERROR; + } else { + TRACE_A2DP_DECODER_W( + "[AAC][INPUT] list full current list_len:%d buff_len:%d", + a2dp_audio_list_length(list), buffer_bytes); + nRet = A2DP_DECODER_MTU_LIMTER_ERROR; + } + + return nRet; +} +#else +int a2dp_audio_aac_lc_store_packet(btif_media_header_t *header, uint8_t *buffer, + uint32_t buffer_bytes) { + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + int nRet = A2DP_DECODER_NO_ERROR; + + if (!a2dp_audio_aac_lc_reorder_valid(header, buffer, buffer_bytes)) { + return A2DP_DECODER_NO_ERROR; + } + + if (a2dp_audio_list_length(list) < aac_mtu_limiter && + buffer_bytes <= AAC_READBUF_SIZE) { + a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = + (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_aac_lc_frame_malloc( + buffer_bytes); + TRACE_A2DP_DECODER_D("[AAC][INPUT]seq:%d len:%d", header->sequenceNumber, + buffer_bytes); aac_decoder_frame_p->sequenceNumber = header->sequenceNumber; aac_decoder_frame_p->timestamp = header->timestamp; memcpy(aac_decoder_frame_p->aac_buffer, buffer, buffer_bytes); aac_decoder_frame_p->aac_buffer_len = buffer_bytes; - return A2DP_DECODER_NO_ERROR; -} + a2dp_audio_aac_lc_reorder_history(aac_decoder_frame_p); + a2dp_audio_list_append(list, aac_decoder_frame_p); + nRet = A2DP_DECODER_NO_ERROR; + } else { + TRACE_A2DP_DECODER_I( + "[AAC][INPUT] list full current list_len:%d buff_len:%d", + a2dp_audio_list_length(list), buffer_bytes); + nRet = A2DP_DECODER_MTU_LIMTER_ERROR; + } -int a2dp_audio_aac_lc_reorder_proc(a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p, - btif_media_header_t * header, uint8_t *buffer, uint32_t buffer_bytes) -{ - uint8_t *dest_buf = NULL; - if ((aac_decoder_frame_p->aac_buffer_len + buffer_bytes) > AAC_READBUF_SIZE){ - return A2DP_DECODER_NO_ERROR; - } - TRACE_A2DP_DECODER_W("[AAC][INPUT][REORDER] proc enter seq:%d len:%d", aac_decoder_frame_p->sequenceNumber, aac_decoder_frame_p->aac_buffer_len); - dest_buf = &aac_decoder_frame_p->aac_buffer[aac_decoder_frame_p->aac_buffer_len]; - memcpy(dest_buf, buffer, buffer_bytes); - aac_decoder_frame_p->aac_buffer_len += buffer_bytes; - TRACE_A2DP_DECODER_W("[AAC][INPUT][REORDER] proc exit seq:%d len:%d", aac_decoder_frame_p->sequenceNumber, aac_decoder_frame_p->aac_buffer_len); - - return A2DP_DECODER_NO_ERROR; -} - -int a2dp_audio_aac_lc_packet_recover_save_last(a2dp_audio_aac_decoder_frame_t *aac_decoder_frame) -{ - aac_decoder_last_valid_frame_ready = true; - aac_decoder_last_valid_frame.sequenceNumber = aac_decoder_frame->sequenceNumber; - aac_decoder_last_valid_frame.timestamp = aac_decoder_frame->timestamp; - return 0; -} - -int a2dp_audio_aac_lc_packet_recover_find_missing(a2dp_audio_aac_decoder_frame_t *aac_decoder_frame) -{ - uint16_t diff_seq = 0; - uint32_t diff_timestamp = 0; - uint32_t diff = 0; - float tmp_pkt_cnt = 0; - uint32_t need_recover_pkt = 0; - - if (!aac_decoder_last_valid_frame_ready){ - return need_recover_pkt; - } - - diff_seq = a2dp_audio_get_passed(aac_decoder_frame->sequenceNumber, aac_decoder_last_valid_frame.sequenceNumber, UINT16_MAX); - diff_timestamp = a2dp_audio_get_passed(aac_decoder_frame->timestamp, aac_decoder_last_valid_frame.timestamp, UINT32_MAX); - - if (diff_seq > 1){ - TRACE_A2DP_DECODER_W("[AAC][INPUT][PLC] seq:%d/%d stmp:%d/%d", aac_decoder_frame->sequenceNumber, aac_decoder_last_valid_frame.sequenceNumber, - aac_decoder_frame->timestamp, aac_decoder_last_valid_frame.timestamp); - diff = diff_timestamp/diff_seq; - if (diff%AAC_OUTPUT_FRAME_SAMPLES == 0){ - tmp_pkt_cnt = diff_timestamp/AAC_OUTPUT_FRAME_SAMPLES; - }else{ - tmp_pkt_cnt = (float)diff_timestamp/ - ((1000.f/(float)a2dp_audio_context_p->output_cfg.sample_rate)*(float)AAC_OUTPUT_FRAME_SAMPLES); - } - need_recover_pkt = (uint32_t)(tmp_pkt_cnt+0.5f); - TRACE_A2DP_DECODER_W("[AAC][INPUT][PLC] diff_seq:%d diff_stmp:%d diff:%d missing:%d", diff_seq, diff_timestamp, diff, need_recover_pkt); - if (need_recover_pkt == diff_seq){ - need_recover_pkt--; - TRACE_A2DP_DECODER_W("[AAC][INPUT][PLC] need_recover_pkt seq:%d", need_recover_pkt); - }else{ - need_recover_pkt = 0; - } - } - return need_recover_pkt; -} - -int a2dp_audio_aac_lc_packet_recover_proc(a2dp_audio_aac_decoder_frame_t *aac_decoder_frame) -{ - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - int missing_pkt_cnt = 0; - missing_pkt_cnt = a2dp_audio_aac_lc_packet_recover_find_missing(aac_decoder_frame); - if (missing_pkt_cnt <= 4 && a2dp_audio_list_length(list) + missing_pkt_cnt < aac_mtu_limiter){ - for (uint8_t i=0; iaac_buffer_len); - aac_decoder_frame_p->sequenceNumber = UINT16_MAX; - aac_decoder_frame_p->timestamp = UINT32_MAX; - memcpy(aac_decoder_frame_p->aac_buffer, aac_decoder_frame->aac_buffer, aac_decoder_frame->aac_buffer_len); - aac_decoder_frame_p->aac_buffer_len = aac_decoder_frame->aac_buffer_len; - a2dp_audio_list_append(list, aac_decoder_frame_p); - } - } - - return A2DP_DECODER_NO_ERROR; -} - -int inline a2dp_audio_aac_lc_packet_append(a2dp_audio_aac_decoder_frame_t *aac_decoder_frame) -{ - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - a2dp_audio_aac_lc_packet_recover_proc(aac_decoder_frame); - a2dp_audio_aac_lc_packet_recover_save_last(aac_decoder_frame); - a2dp_audio_list_append(list, aac_decoder_frame); - return 0; -} - -#if 1 -int a2dp_audio_aac_lc_store_packet(btif_media_header_t * header, uint8_t *buffer, uint32_t buffer_bytes) -{ - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - int nRet = A2DP_DECODER_NO_ERROR; - a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = NULL; - - if (a2dp_audio_list_length(list) < aac_mtu_limiter && - buffer_bytes <= AAC_READBUF_SIZE){ - if (aac_decoder_frame_reorder_p == NULL){ - aac_decoder_frame_p = (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_aac_lc_frame_malloc(buffer_bytes); - aac_decoder_frame_reorder_p = aac_decoder_frame_p; - TRACE_A2DP_DECODER_W("[AAC][INPUT][REORDER] start seq:%d len:%d", header->sequenceNumber, buffer_bytes); - a2dp_audio_aac_lc_reorder_store_packet(aac_decoder_frame_p, header, buffer, buffer_bytes); - }else{ - if (aac_decoder_frame_reorder_p->aac_buffer[0] == buffer[0] && - aac_decoder_frame_reorder_p->aac_buffer[1] == buffer[1]){ - a2dp_audio_aac_lc_packet_append(aac_decoder_frame_reorder_p); - aac_decoder_frame_p = (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_aac_lc_frame_malloc(buffer_bytes); - aac_decoder_frame_reorder_p = aac_decoder_frame_p; - a2dp_audio_aac_lc_reorder_store_packet(aac_decoder_frame_p, header, buffer, buffer_bytes); - }else{ - aac_decoder_frame_p = aac_decoder_frame_reorder_p; - a2dp_audio_aac_lc_reorder_proc(aac_decoder_frame_p, header, buffer, buffer_bytes); - a2dp_audio_aac_lc_packet_append(aac_decoder_frame_p); - aac_decoder_frame_reorder_p = NULL; - } - } - nRet = A2DP_DECODER_NO_ERROR; - }else{ - TRACE_A2DP_DECODER_W("[AAC][INPUT] list full current list_len:%d buff_len:%d", a2dp_audio_list_length(list), buffer_bytes); - nRet = A2DP_DECODER_MTU_LIMTER_ERROR; - } - - return nRet; -} -#else -int a2dp_audio_aac_lc_store_packet(btif_media_header_t * header, uint8_t *buffer, uint32_t buffer_bytes) -{ - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - int nRet = A2DP_DECODER_NO_ERROR; - - if (!a2dp_audio_aac_lc_reorder_valid(header, buffer, buffer_bytes)){ - return A2DP_DECODER_NO_ERROR; - } - - if (a2dp_audio_list_length(list) < aac_mtu_limiter && - buffer_bytes <= AAC_READBUF_SIZE){ - a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_aac_lc_frame_malloc(buffer_bytes); - TRACE_A2DP_DECODER_D("[AAC][INPUT]seq:%d len:%d", header->sequenceNumber, buffer_bytes); - aac_decoder_frame_p->sequenceNumber = header->sequenceNumber; - aac_decoder_frame_p->timestamp = header->timestamp; - memcpy(aac_decoder_frame_p->aac_buffer, buffer, buffer_bytes); - aac_decoder_frame_p->aac_buffer_len = buffer_bytes; - a2dp_audio_aac_lc_reorder_history(aac_decoder_frame_p); - a2dp_audio_list_append(list, aac_decoder_frame_p); - nRet = A2DP_DECODER_NO_ERROR; - }else{ - TRACE_A2DP_DECODER_I("[AAC][INPUT] list full current list_len:%d buff_len:%d", a2dp_audio_list_length(list), buffer_bytes); - nRet = A2DP_DECODER_MTU_LIMTER_ERROR; - } - - return nRet; + return nRet; } #endif -int a2dp_audio_aac_lc_discards_packet(uint32_t packets) -{ - int nRet = A2DP_DECODER_MEMORY_ERROR; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = NULL; +int a2dp_audio_aac_lc_discards_packet(uint32_t packets) { + int nRet = A2DP_DECODER_MEMORY_ERROR; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = NULL; #ifdef A2DP_CP_ACCEL - a2dp_cp_reset_frame(); + a2dp_cp_reset_frame(); #endif - if (packets <= a2dp_audio_list_length(list)){ - for (uint8_t i=0; iaudio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - a2dp_audio_aac_decoder_frame_t *aac_decoder_frame = NULL; +int a2dp_audio_aac_lc_headframe_info_get( + A2DP_AUDIO_HEADFRAME_INFO_T *headframe_info) { + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + a2dp_audio_aac_decoder_frame_t *aac_decoder_frame = NULL; - if (a2dp_audio_list_length(list) && ((node = a2dp_audio_list_begin(list)) != NULL)){ - aac_decoder_frame = (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_list_node(node); - headframe_info->sequenceNumber = aac_decoder_frame->sequenceNumber; - headframe_info->timestamp = aac_decoder_frame->timestamp; - headframe_info->curSubSequenceNumber = 0; - headframe_info->totalSubSequenceNumber = 0; - }else{ - memset(headframe_info, 0, sizeof(A2DP_AUDIO_HEADFRAME_INFO_T)); - } + if (a2dp_audio_list_length(list) && + ((node = a2dp_audio_list_begin(list)) != NULL)) { + aac_decoder_frame = + (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_list_node(node); + headframe_info->sequenceNumber = aac_decoder_frame->sequenceNumber; + headframe_info->timestamp = aac_decoder_frame->timestamp; + headframe_info->curSubSequenceNumber = 0; + headframe_info->totalSubSequenceNumber = 0; + } else { + memset(headframe_info, 0, sizeof(A2DP_AUDIO_HEADFRAME_INFO_T)); + } - return A2DP_DECODER_NO_ERROR; + return A2DP_DECODER_NO_ERROR; } -int a2dp_audio_aac_lc_info_get(void *info) -{ - return A2DP_DECODER_NO_ERROR; -} +int a2dp_audio_aac_lc_info_get(void *info) { return A2DP_DECODER_NO_ERROR; } -int a2dp_audio_aac_lc_synchronize_packet(A2DP_AUDIO_SYNCFRAME_INFO_T *sync_info, uint32_t mask) -{ - int nRet = A2DP_DECODER_SYNC_ERROR; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - int list_len; - a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = NULL; +int a2dp_audio_aac_lc_synchronize_packet(A2DP_AUDIO_SYNCFRAME_INFO_T *sync_info, + uint32_t mask) { + int nRet = A2DP_DECODER_SYNC_ERROR; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + int list_len; + a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = NULL; #ifdef A2DP_CP_ACCEL - a2dp_cp_reset_frame(); + a2dp_cp_reset_frame(); #endif - list_len = a2dp_audio_list_length(list); - - for (uint16_t i=0; isequenceNumber, sync_info->sequenceNumber, - aac_decoder_frame_p->timestamp, sync_info->timestamp); - if (A2DP_AUDIO_SYNCFRAME_CHK(aac_decoder_frame_p->sequenceNumber == sync_info->sequenceNumber, A2DP_AUDIO_SYNCFRAME_MASK_SEQ, mask)&& - A2DP_AUDIO_SYNCFRAME_CHK(aac_decoder_frame_p->timestamp == sync_info->timestamp, A2DP_AUDIO_SYNCFRAME_MASK_TIMESTAMP, mask)){ - nRet = A2DP_DECODER_NO_ERROR; - break; - } - a2dp_audio_list_remove(list, aac_decoder_frame_p); - } - } + list_len = a2dp_audio_list_length(list); + for (uint16_t i = 0; i < list_len; i++) { node = a2dp_audio_list_begin(list); - if (node){ - aac_decoder_frame_p = (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_list_node(node); - TRACE_A2DP_DECODER_I("[MCU][SYNC][AAC] sync pkt nRet:%d SEQ:%d timestamp:%d", nRet, aac_decoder_frame_p->sequenceNumber, aac_decoder_frame_p->timestamp); - }else{ - TRACE_A2DP_DECODER_I("[MCU][SYNC][AAC] sync pkt nRet:%d", nRet); - } - - return nRet; -} - -int a2dp_audio_aac_lc_synchronize_dest_packet_mut(uint16_t packet_mut) -{ - list_node_t *node = NULL; - uint32_t list_len = 0; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = NULL; - - list_len = a2dp_audio_list_length(list); - if (list_len > packet_mut){ - do{ - node = a2dp_audio_list_begin(list); - if (node){ - aac_decoder_frame_p = (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_list_node(node); - a2dp_audio_list_remove(list, aac_decoder_frame_p); - } - }while(a2dp_audio_list_length(list) > packet_mut); - } - - if (packet_mut == 0){ - if (aac_decoder_frame_reorder_p){ - a2dp_audio_aac_lc_free(aac_decoder_frame_reorder_p); - a2dp_audio_aac_lc_reorder_init(); - } - } - - TRACE_A2DP_DECODER_I("[MCU][SYNC][AAC] dest pkt list:%d", a2dp_audio_list_length(list)); - return A2DP_DECODER_NO_ERROR; -} - -int a2dp_audio_aac_lc_convert_list_to_samples(uint32_t *samples) -{ - uint32_t list_len = 0; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - - list_len = a2dp_audio_list_length(list); - *samples = AAC_OUTPUT_FRAME_SAMPLES*list_len; - - TRACE_A2DP_DECODER_I("AUD][DECODER][MCU][AAC] list:%d samples:%d", list_len, *samples); - - return A2DP_DECODER_NO_ERROR; -} - -int a2dp_audio_aac_lc_discards_samples(uint32_t samples) -{ - int nRet = A2DP_DECODER_SYNC_ERROR; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = NULL; - list_node_t *node = NULL; - int need_remove_list = 0; - uint32_t list_samples = 0; - ASSERT_A2DP_DECODER(!(samples%AAC_OUTPUT_FRAME_SAMPLES), "%s samples err:%d", __func__, samples); - - a2dp_audio_aac_lc_convert_list_to_samples(&list_samples); - if (list_samples >= samples){ - need_remove_list = samples/AAC_OUTPUT_FRAME_SAMPLES; - for (int i=0; isequenceNumber, sync_info->sequenceNumber, + aac_decoder_frame_p->timestamp, sync_info->timestamp); + if (A2DP_AUDIO_SYNCFRAME_CHK(aac_decoder_frame_p->sequenceNumber == + sync_info->sequenceNumber, + A2DP_AUDIO_SYNCFRAME_MASK_SEQ, mask) && + A2DP_AUDIO_SYNCFRAME_CHK(aac_decoder_frame_p->timestamp == + sync_info->timestamp, + A2DP_AUDIO_SYNCFRAME_MASK_TIMESTAMP, mask)) { nRet = A2DP_DECODER_NO_ERROR; + break; + } + a2dp_audio_list_remove(list, aac_decoder_frame_p); } + } - return nRet; + node = a2dp_audio_list_begin(list); + if (node) { + aac_decoder_frame_p = + (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_list_node(node); + TRACE_A2DP_DECODER_I( + "[MCU][SYNC][AAC] sync pkt nRet:%d SEQ:%d timestamp:%d", nRet, + aac_decoder_frame_p->sequenceNumber, aac_decoder_frame_p->timestamp); + } else { + TRACE_A2DP_DECODER_I("[MCU][SYNC][AAC] sync pkt nRet:%d", nRet); + } + + return nRet; +} + +int a2dp_audio_aac_lc_synchronize_dest_packet_mut(uint16_t packet_mut) { + list_node_t *node = NULL; + uint32_t list_len = 0; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = NULL; + + list_len = a2dp_audio_list_length(list); + if (list_len > packet_mut) { + do { + node = a2dp_audio_list_begin(list); + if (node) { + aac_decoder_frame_p = + (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_list_node(node); + a2dp_audio_list_remove(list, aac_decoder_frame_p); + } + } while (a2dp_audio_list_length(list) > packet_mut); + } + + if (packet_mut == 0) { + if (aac_decoder_frame_reorder_p) { + a2dp_audio_aac_lc_free(aac_decoder_frame_reorder_p); + a2dp_audio_aac_lc_reorder_init(); + } + } + + TRACE_A2DP_DECODER_I("[MCU][SYNC][AAC] dest pkt list:%d", + a2dp_audio_list_length(list)); + return A2DP_DECODER_NO_ERROR; +} + +int a2dp_audio_aac_lc_convert_list_to_samples(uint32_t *samples) { + uint32_t list_len = 0; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + + list_len = a2dp_audio_list_length(list); + *samples = AAC_OUTPUT_FRAME_SAMPLES * list_len; + + TRACE_A2DP_DECODER_I("AUD][DECODER][MCU][AAC] list:%d samples:%d", list_len, + *samples); + + return A2DP_DECODER_NO_ERROR; +} + +int a2dp_audio_aac_lc_discards_samples(uint32_t samples) { + int nRet = A2DP_DECODER_SYNC_ERROR; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + a2dp_audio_aac_decoder_frame_t *aac_decoder_frame_p = NULL; + list_node_t *node = NULL; + int need_remove_list = 0; + uint32_t list_samples = 0; + ASSERT_A2DP_DECODER(!(samples % AAC_OUTPUT_FRAME_SAMPLES), + "%s samples err:%d", __func__, samples); + + a2dp_audio_aac_lc_convert_list_to_samples(&list_samples); + if (list_samples >= samples) { + need_remove_list = samples / AAC_OUTPUT_FRAME_SAMPLES; + for (int i = 0; i < need_remove_list; i++) { + node = a2dp_audio_list_begin(list); + if (node) { + aac_decoder_frame_p = + (a2dp_audio_aac_decoder_frame_t *)a2dp_audio_list_node(node); + a2dp_audio_list_remove(list, aac_decoder_frame_p); + } + } + nRet = A2DP_DECODER_NO_ERROR; + } + + return nRet; } A2DP_AUDIO_DECODER_T a2dp_audio_aac_lc_decoder_config = { - {44100, 2, 16}, - 1, - a2dp_audio_aac_lc_init, - a2dp_audio_aac_lc_deinit, - a2dp_audio_aac_lc_decode_frame, - a2dp_audio_aac_lc_preparse_packet, - a2dp_audio_aac_lc_store_packet, - a2dp_audio_aac_lc_discards_packet, - a2dp_audio_aac_lc_synchronize_packet, - a2dp_audio_aac_lc_synchronize_dest_packet_mut, - a2dp_audio_aac_lc_convert_list_to_samples, - a2dp_audio_aac_lc_discards_samples, - a2dp_audio_aac_lc_headframe_info_get, - a2dp_audio_aac_lc_info_get, - a2dp_audio_aac_lc_free, - a2dp_audio_aac_lc_channel_select, - } ; + {44100, 2, 16}, + 1, + a2dp_audio_aac_lc_init, + a2dp_audio_aac_lc_deinit, + a2dp_audio_aac_lc_decode_frame, + a2dp_audio_aac_lc_preparse_packet, + a2dp_audio_aac_lc_store_packet, + a2dp_audio_aac_lc_discards_packet, + a2dp_audio_aac_lc_synchronize_packet, + a2dp_audio_aac_lc_synchronize_dest_packet_mut, + a2dp_audio_aac_lc_convert_list_to_samples, + a2dp_audio_aac_lc_discards_samples, + a2dp_audio_aac_lc_headframe_info_get, + a2dp_audio_aac_lc_info_get, + a2dp_audio_aac_lc_free, + a2dp_audio_aac_lc_channel_select, +}; #else -A2DP_AUDIO_DECODER_T a2dp_audio_aac_lc_decoder_config = {0,} ; +A2DP_AUDIO_DECODER_T a2dp_audio_aac_lc_decoder_config = { + 0, +}; #endif diff --git a/apps/audioplayers/a2dp_decoder/a2dp_decoder_cp.c b/apps/audioplayers/a2dp_decoder/a2dp_decoder_cp.c index 6704b56..bfda048 100644 --- a/apps/audioplayers/a2dp_decoder/a2dp_decoder_cp.c +++ b/apps/audioplayers/a2dp_decoder/a2dp_decoder_cp.c @@ -15,8 +15,8 @@ ****************************************************************************/ #ifdef A2DP_CP_ACCEL -#include "a2dp_decoder_internal.h" #include "a2dp_decoder_cp.h" +#include "a2dp_decoder_internal.h" #include "cp_accel.h" #include "hal_location.h" #include "hal_timer.h" @@ -24,33 +24,33 @@ #include "heap_api.h" #include "norflash_api.h" -#define CP_IN_FRAME_CNT 100 -#define CP_OUT_FRAME_CNT 3 +#define CP_IN_FRAME_CNT 100 +#define CP_OUT_FRAME_CNT 3 -#define CP_IN_CACHE_SIZE (1024 * 10) +#define CP_IN_CACHE_SIZE (1024 * 10) #if defined(A2DP_LHDC_V3) -#define CP_HEAP_SIZE (1024 * 64) +#define CP_HEAP_SIZE (1024 * 64) #else -#define CP_HEAP_SIZE (1024 * 32) +#define CP_HEAP_SIZE (1024 * 32) #endif enum CP_DEC_STATE_T { - CP_DEC_STATE_IDLE, - CP_DEC_STATE_WORKING, - CP_DEC_STATE_DONE, - CP_DEC_STATE_INIT_DONE, + CP_DEC_STATE_IDLE, + CP_DEC_STATE_WORKING, + CP_DEC_STATE_DONE, + CP_DEC_STATE_INIT_DONE, }; struct CP_IN_FRAME_INFO_T { - uint32_t pos; - uint32_t len; + uint32_t pos; + uint32_t len; }; struct CP_OUT_FRAME_INFO_T { - enum CP_DEC_STATE_T state; - uint32_t pos; - uint32_t len; + enum CP_DEC_STATE_T state; + uint32_t pos; + uint32_t len; }; static CP_BSS_LOC uint32_t cp_heap_buf[CP_HEAP_SIZE / 4]; @@ -82,537 +82,512 @@ static enum CP_PROC_DELAY_T proc_delay; static bool cp_need_reset; CP_TEXT_SRAM_LOC -unsigned int set_cp_reset_flag(uint8_t evt) -{ - cp_need_reset = true; - return 0; +unsigned int set_cp_reset_flag(uint8_t evt) { + cp_need_reset = true; + return 0; } -bool is_cp_need_reset(void) -{ - bool ret = cp_need_reset; - cp_need_reset = false; - return ret; -} - -bool is_cp_init_done(void) -{ - return cp_accel_init_done(); +bool is_cp_need_reset(void) { + bool ret = cp_need_reset; + cp_need_reset = false; + return ret; } +bool is_cp_init_done(void) { return cp_accel_init_done(); } CP_TEXT_SRAM_LOC -static void reset_frame_info(void) -{ - uint32_t idle_cnt; - int i; +static void reset_frame_info(void) { + uint32_t idle_cnt; + int i; - if (proc_delay == CP_PROC_DELAY_0_FRAME) { - idle_cnt = CP_OUT_FRAME_CNT; - } else if (proc_delay == CP_PROC_DELAY_1_FRAME) { - idle_cnt = CP_OUT_FRAME_CNT - 1; + if (proc_delay == CP_PROC_DELAY_0_FRAME) { + idle_cnt = CP_OUT_FRAME_CNT; + } else if (proc_delay == CP_PROC_DELAY_1_FRAME) { + idle_cnt = CP_OUT_FRAME_CNT - 1; + } else { + idle_cnt = CP_OUT_FRAME_CNT - 2; + } + + for (i = 0; i < CP_OUT_FRAME_CNT; i++) { + if (i < idle_cnt) { + out_frames[i].state = CP_DEC_STATE_IDLE; } else { - idle_cnt = CP_OUT_FRAME_CNT - 2; + out_frames[i].state = CP_DEC_STATE_INIT_DONE; } + } - for (i = 0; i < CP_OUT_FRAME_CNT; i++) { - if (i < idle_cnt) { - out_frames[i].state = CP_DEC_STATE_IDLE; - } else { - out_frames[i].state = CP_DEC_STATE_INIT_DONE; - } - } + cp_in_widx = 0; + cp_in_ridx = 0; + cp_out_widx = 0; + cp_out_ridx = idle_cnt; - cp_in_widx = 0; - cp_in_ridx = 0; - cp_out_widx = 0; - cp_out_ridx = idle_cnt; - - reset_frames = false; + reset_frames = false; } CP_TEXT_SRAM_LOC -static unsigned int cp_a2dp_main(uint8_t event) -{ - int ret; +static unsigned int cp_a2dp_main(uint8_t event) { + int ret; #ifdef A2DP_TRACE_CP_DEC_TIME - uint32_t stime; - uint32_t etime; + uint32_t stime; + uint32_t etime; #endif - if (!mcu_dec_inited) { - return 0; - } + if (!mcu_dec_inited) { + return 0; + } - if (decode_frame) { - do { + if (decode_frame) { + do { #ifdef A2DP_TRACE_CP_DEC_TIME - stime = hal_fast_sys_timer_get(); + stime = hal_fast_sys_timer_get(); #endif - ret = decode_frame(); + ret = decode_frame(); #ifdef A2DP_TRACE_CP_DEC_TIME - etime = hal_fast_sys_timer_get(); - TRACE_A2DP_DECODER_I("cp_decode: %5u us in %5u us", FAST_TICKS_TO_US(etime - stime), FAST_TICKS_TO_US(etime - cp_last_dec_time)); - cp_last_dec_time = etime; + etime = hal_fast_sys_timer_get(); + TRACE_A2DP_DECODER_I("cp_decode: %5u us in %5u us", + FAST_TICKS_TO_US(etime - stime), + FAST_TICKS_TO_US(etime - cp_last_dec_time)); + cp_last_dec_time = etime; #endif - } while (ret == 0); - } + } while (ret == 0); + } - if (reset_frames) { - reset_frame_info(); -#ifdef A2DP_TRACE_CP_ACCEL - TRACE_A2DP_DECODER_I("%s: Reset frames", __func__); -#endif - } - - return 0; -} - -static struct cp_task_desc TASK_DESC_A2DP = {CP_ACCEL_STATE_CLOSED, cp_a2dp_main, NULL, NULL, set_cp_reset_flag}; -int a2dp_cp_init(A2DP_CP_DECODE_T decode_func, enum CP_PROC_DELAY_T delay) -{ - if (delay >= CP_PROC_DELAY_QTY) { - return 1; - } - mcu_dec_inited = false; - decode_frame = decode_func; - proc_delay = delay; -#ifdef A2DP_TRACE_CP_DEC_TIME - cp_last_dec_time = hal_fast_sys_timer_get(); -#endif - - norflash_api_flush_disable(NORFLASH_API_USER_CP,(uint32_t)cp_accel_init_done); - cp_accel_open(CP_TASK_A2DP_DECODE, &TASK_DESC_A2DP); - while(cp_accel_init_done() == false) { - hal_sys_timer_delay_us(100); - } - norflash_api_flush_enable(NORFLASH_API_USER_CP); - return 0; -} -int a2dp_cp_deinit(void) -{ - cp_accel_close(CP_TASK_A2DP_DECODE); - - return 0; -} - -SRAM_TEXT_LOC -int a2dp_cp_decoder_init(uint32_t out_frame_len, uint8_t max_frames) -{ - uint32_t i; - max_buffer_frames = max_frames; - if (!mcu_dec_inited) { -#ifdef A2DP_TRACE_CP_ACCEL - TRACE_A2DP_DECODER_I("%s: Decoder init", __func__); -#endif - if(cp_accel_init_done() == false){ - TRACE_A2DP_DECODER_I("%s: CP ACCEL not init yet", __func__); - return 6; - } - - cp_heap = heap_register(cp_heap_buf, sizeof(cp_heap_buf)); - if (cp_heap == NULL) { - return 1; - } - - in_frames = heap_malloc(cp_heap, sizeof(in_frames[0]) * CP_IN_FRAME_CNT); - if (in_frames == NULL) { - return 2; - } - - out_frames = heap_malloc(cp_heap, sizeof(out_frames[0]) * CP_OUT_FRAME_CNT); - if (out_frames == NULL) { - return 3; - } - - cp_in_cache = heap_malloc(cp_heap, CP_IN_CACHE_SIZE); - if (cp_in_cache == NULL) { - return 4; - } - - cp_out_cache = heap_malloc(cp_heap, out_frame_len * CP_OUT_FRAME_CNT); - if (cp_out_cache == NULL) { - return 5; - } - - for (i = 0; i < CP_OUT_FRAME_CNT; i++) { - out_frames[i].pos = out_frame_len * i; - out_frames[i].len = out_frame_len; - } - reset_frame_info(); - - mcu_dec_inited = true; - } - - return 0; -} - -CP_TEXT_SRAM_LOC -static uint32_t get_in_frame_cnt(uint32_t in_widx, uint32_t in_ridx) -{ - uint32_t cnt; - - if (in_widx >= in_ridx) { - cnt = in_widx - in_ridx; - } else { - cnt = CP_IN_FRAME_CNT - in_ridx + in_widx; - } - - return cnt; -} - -uint32_t get_in_cp_frame_cnt(void) -{ - return get_in_frame_cnt(cp_in_widx, cp_in_ridx); -} - -uint32_t get_in_cp_frame_delay(void) -{ - return proc_delay; -} - -SRAM_TEXT_LOC -static uint32_t get_in_frame_free_cnt(uint32_t in_widx, uint32_t in_ridx) -{ - uint32_t free_cnt; - - if (in_widx >= in_ridx) { - free_cnt = CP_IN_FRAME_CNT - in_widx + in_ridx; - } else { - free_cnt = in_ridx - in_widx; - } - free_cnt -= 1; - - return free_cnt; -} - -SRAM_TEXT_LOC -int a2dp_cp_put_in_frame(const void *buf1, uint32_t len1, const void *buf2, uint32_t len2) -{ - uint16_t free_cnt; - uint16_t in_widx; - uint16_t in_ridx; - uint16_t prev_in_widx; - uint32_t free_len; - uint32_t in_wpos; - uint32_t in_rpos; - uint32_t aligned_len; - - if (reset_frames) { - return -1; - } - - in_widx = cp_in_widx; - in_ridx = cp_in_ridx; - - if (max_buffer_frames < get_in_cp_frame_cnt()){ - return 1; - } - - free_cnt = get_in_frame_free_cnt(in_widx, in_ridx); - if (free_cnt == 0) { - return 1; - } - - if (in_widx == in_ridx) { - in_wpos = 0; - in_rpos = 0; - } else { - if (in_widx == 0) { - prev_in_widx = CP_IN_FRAME_CNT - 1; - } else { - prev_in_widx = in_widx - 1; - } - in_wpos = in_frames[prev_in_widx].pos + in_frames[prev_in_widx].len; - if (in_wpos >= CP_IN_CACHE_SIZE) { - in_wpos -= CP_IN_CACHE_SIZE; - } - in_rpos = in_frames[in_ridx].pos; - } - - // Align to word boundary - in_wpos = (in_wpos + 3) & ~3; - if (in_wpos >= CP_IN_CACHE_SIZE) { - in_wpos -= CP_IN_CACHE_SIZE; - } - aligned_len = (len1 + len2 + 3) & ~3; - - if (in_wpos >= in_rpos) { - free_len = CP_IN_CACHE_SIZE - in_wpos; - if (in_rpos == 0) { - free_len -= 1; - } - if (free_len < aligned_len) { - free_len = (in_rpos > 0) ? (in_rpos - 1) : 0; - if (free_len < aligned_len) { - return 2; - } - in_wpos = 0; - } - } else { - free_len = in_rpos - in_wpos - 1; - if (free_len < aligned_len) { - return 3; - } - } - - in_frames[in_widx].pos = in_wpos; - in_frames[in_widx].len = len1 + len2; - - if (len1) { - memcpy(&cp_in_cache[in_wpos], buf1, len1); - in_wpos += len1; - } - if (len2) { - memcpy(&cp_in_cache[in_wpos], buf2, len2); - in_wpos += len2; - } - - in_widx += 1; - if (in_widx >= CP_IN_FRAME_CNT) { - in_widx -= CP_IN_FRAME_CNT; - } - cp_in_widx = in_widx; - - return 0; -} - -CP_TEXT_SRAM_LOC -int a2dp_cp_get_in_frame(void **p_buf, uint32_t *p_len) -{ - uint16_t in_widx; - uint16_t in_ridx; - uint32_t in_rpos; - - if (reset_frames) { - return -1; - } - - in_widx = cp_in_widx; - in_ridx = cp_in_ridx; - - if (in_widx == in_ridx) { - return 1; - } - - in_rpos = in_frames[in_ridx].pos; - - if (p_buf) { - *p_buf = &cp_in_cache[in_rpos]; - } - if (p_len) { - *p_len = in_frames[in_ridx].len; - } - - return 0; -} - -CP_TEXT_SRAM_LOC -int a2dp_cp_consume_in_frame(void) -{ - uint16_t in_widx; - uint16_t in_ridx; - - if (reset_frames) { - return 0; - } - - in_widx = cp_in_widx; - in_ridx = cp_in_ridx; - - if (in_widx == in_ridx) { - return 1; - } - - in_ridx += 1; - if (in_ridx >= CP_IN_FRAME_CNT) { - in_ridx -= CP_IN_FRAME_CNT; - } - cp_in_ridx = in_ridx; - - return 0; -} - -CP_TEXT_SRAM_LOC -uint32_t a2dp_cp_get_in_frame_index(void) -{ - return cp_in_ridx; -} - -SRAM_TEXT_LOC -uint32_t a2dp_cp_get_in_frame_cnt_by_index(uint32_t ridx) -{ - return get_in_frame_cnt(cp_in_widx, ridx); -} - -SRAM_TEXT_LOC -void a2dp_cp_reset_frame(void) -{ + if (reset_frames) { + reset_frame_info(); #ifdef A2DP_TRACE_CP_ACCEL TRACE_A2DP_DECODER_I("%s: Reset frames", __func__); #endif + } - reset_frames = true; + return 0; +} - // Notify CP to work again - cp_accel_send_event_mcu2cp(1); +static struct cp_task_desc TASK_DESC_A2DP = { + CP_ACCEL_STATE_CLOSED, cp_a2dp_main, NULL, NULL, set_cp_reset_flag}; +int a2dp_cp_init(A2DP_CP_DECODE_T decode_func, enum CP_PROC_DELAY_T delay) { + if (delay >= CP_PROC_DELAY_QTY) { + return 1; + } + mcu_dec_inited = false; + decode_frame = decode_func; + proc_delay = delay; +#ifdef A2DP_TRACE_CP_DEC_TIME + cp_last_dec_time = hal_fast_sys_timer_get(); +#endif + + norflash_api_flush_disable(NORFLASH_API_USER_CP, + (uint32_t)cp_accel_init_done); + cp_accel_open(CP_TASK_A2DP_DECODE, &TASK_DESC_A2DP); + while (cp_accel_init_done() == false) { + hal_sys_timer_delay_us(100); + } + norflash_api_flush_enable(NORFLASH_API_USER_CP); + return 0; +} +int a2dp_cp_deinit(void) { + cp_accel_close(CP_TASK_A2DP_DECODE); + + return 0; } SRAM_TEXT_LOC -bool a2dp_cp_get_frame_reset_status(void) -{ - return reset_frames; +int a2dp_cp_decoder_init(uint32_t out_frame_len, uint8_t max_frames) { + uint32_t i; + max_buffer_frames = max_frames; + if (!mcu_dec_inited) { +#ifdef A2DP_TRACE_CP_ACCEL + TRACE_A2DP_DECODER_I("%s: Decoder init", __func__); +#endif + if (cp_accel_init_done() == false) { + TRACE_A2DP_DECODER_I("%s: CP ACCEL not init yet", __func__); + return 6; + } + + cp_heap = heap_register(cp_heap_buf, sizeof(cp_heap_buf)); + if (cp_heap == NULL) { + return 1; + } + + in_frames = heap_malloc(cp_heap, sizeof(in_frames[0]) * CP_IN_FRAME_CNT); + if (in_frames == NULL) { + return 2; + } + + out_frames = heap_malloc(cp_heap, sizeof(out_frames[0]) * CP_OUT_FRAME_CNT); + if (out_frames == NULL) { + return 3; + } + + cp_in_cache = heap_malloc(cp_heap, CP_IN_CACHE_SIZE); + if (cp_in_cache == NULL) { + return 4; + } + + cp_out_cache = heap_malloc(cp_heap, out_frame_len * CP_OUT_FRAME_CNT); + if (cp_out_cache == NULL) { + return 5; + } + + for (i = 0; i < CP_OUT_FRAME_CNT; i++) { + out_frames[i].pos = out_frame_len * i; + out_frames[i].len = out_frame_len; + } + reset_frame_info(); + + mcu_dec_inited = true; + } + + return 0; } CP_TEXT_SRAM_LOC -enum CP_EMPTY_OUT_FRM_T a2dp_cp_get_emtpy_out_frame(void **p_buf, uint32_t *p_len) -{ - enum CP_EMPTY_OUT_FRM_T ret; - uint8_t out_widx; - uint32_t out_wpos; - enum CP_DEC_STATE_T state ; +static uint32_t get_in_frame_cnt(uint32_t in_widx, uint32_t in_ridx) { + uint32_t cnt; - if (reset_frames) { - return CP_EMPTY_OUT_FRM_ERR; - } + if (in_widx >= in_ridx) { + cnt = in_widx - in_ridx; + } else { + cnt = CP_IN_FRAME_CNT - in_ridx + in_widx; + } - out_widx = cp_out_widx; - state = out_frames[out_widx].state; + return cnt; +} - if (state != CP_DEC_STATE_IDLE && state != CP_DEC_STATE_WORKING) { - return CP_EMPTY_OUT_FRM_ERR; - } +uint32_t get_in_cp_frame_cnt(void) { + return get_in_frame_cnt(cp_in_widx, cp_in_ridx); +} - if (state == CP_DEC_STATE_WORKING) { - ret = CP_EMPTY_OUT_FRM_WORKING; +uint32_t get_in_cp_frame_delay(void) { return proc_delay; } + +SRAM_TEXT_LOC +static uint32_t get_in_frame_free_cnt(uint32_t in_widx, uint32_t in_ridx) { + uint32_t free_cnt; + + if (in_widx >= in_ridx) { + free_cnt = CP_IN_FRAME_CNT - in_widx + in_ridx; + } else { + free_cnt = in_ridx - in_widx; + } + free_cnt -= 1; + + return free_cnt; +} + +SRAM_TEXT_LOC +int a2dp_cp_put_in_frame(const void *buf1, uint32_t len1, const void *buf2, + uint32_t len2) { + uint16_t free_cnt; + uint16_t in_widx; + uint16_t in_ridx; + uint16_t prev_in_widx; + uint32_t free_len; + uint32_t in_wpos; + uint32_t in_rpos; + uint32_t aligned_len; + + if (reset_frames) { + return -1; + } + + in_widx = cp_in_widx; + in_ridx = cp_in_ridx; + + if (max_buffer_frames < get_in_cp_frame_cnt()) { + return 1; + } + + free_cnt = get_in_frame_free_cnt(in_widx, in_ridx); + if (free_cnt == 0) { + return 1; + } + + if (in_widx == in_ridx) { + in_wpos = 0; + in_rpos = 0; + } else { + if (in_widx == 0) { + prev_in_widx = CP_IN_FRAME_CNT - 1; } else { - out_frames[out_widx].state = CP_DEC_STATE_WORKING; - ret = CP_EMPTY_OUT_FRM_OK; + prev_in_widx = in_widx - 1; } + in_wpos = in_frames[prev_in_widx].pos + in_frames[prev_in_widx].len; + if (in_wpos >= CP_IN_CACHE_SIZE) { + in_wpos -= CP_IN_CACHE_SIZE; + } + in_rpos = in_frames[in_ridx].pos; + } - out_wpos = out_frames[out_widx].pos; + // Align to word boundary + in_wpos = (in_wpos + 3) & ~3; + if (in_wpos >= CP_IN_CACHE_SIZE) { + in_wpos -= CP_IN_CACHE_SIZE; + } + aligned_len = (len1 + len2 + 3) & ~3; + if (in_wpos >= in_rpos) { + free_len = CP_IN_CACHE_SIZE - in_wpos; + if (in_rpos == 0) { + free_len -= 1; + } + if (free_len < aligned_len) { + free_len = (in_rpos > 0) ? (in_rpos - 1) : 0; + if (free_len < aligned_len) { + return 2; + } + in_wpos = 0; + } + } else { + free_len = in_rpos - in_wpos - 1; + if (free_len < aligned_len) { + return 3; + } + } + + in_frames[in_widx].pos = in_wpos; + in_frames[in_widx].len = len1 + len2; + + if (len1) { + memcpy(&cp_in_cache[in_wpos], buf1, len1); + in_wpos += len1; + } + if (len2) { + memcpy(&cp_in_cache[in_wpos], buf2, len2); + in_wpos += len2; + } + + in_widx += 1; + if (in_widx >= CP_IN_FRAME_CNT) { + in_widx -= CP_IN_FRAME_CNT; + } + cp_in_widx = in_widx; + + return 0; +} + +CP_TEXT_SRAM_LOC +int a2dp_cp_get_in_frame(void **p_buf, uint32_t *p_len) { + uint16_t in_widx; + uint16_t in_ridx; + uint32_t in_rpos; + + if (reset_frames) { + return -1; + } + + in_widx = cp_in_widx; + in_ridx = cp_in_ridx; + + if (in_widx == in_ridx) { + return 1; + } + + in_rpos = in_frames[in_ridx].pos; + + if (p_buf) { + *p_buf = &cp_in_cache[in_rpos]; + } + if (p_len) { + *p_len = in_frames[in_ridx].len; + } + + return 0; +} + +CP_TEXT_SRAM_LOC +int a2dp_cp_consume_in_frame(void) { + uint16_t in_widx; + uint16_t in_ridx; + + if (reset_frames) { + return 0; + } + + in_widx = cp_in_widx; + in_ridx = cp_in_ridx; + + if (in_widx == in_ridx) { + return 1; + } + + in_ridx += 1; + if (in_ridx >= CP_IN_FRAME_CNT) { + in_ridx -= CP_IN_FRAME_CNT; + } + cp_in_ridx = in_ridx; + + return 0; +} + +CP_TEXT_SRAM_LOC +uint32_t a2dp_cp_get_in_frame_index(void) { return cp_in_ridx; } + +SRAM_TEXT_LOC +uint32_t a2dp_cp_get_in_frame_cnt_by_index(uint32_t ridx) { + return get_in_frame_cnt(cp_in_widx, ridx); +} + +SRAM_TEXT_LOC +void a2dp_cp_reset_frame(void) { +#ifdef A2DP_TRACE_CP_ACCEL + TRACE_A2DP_DECODER_I("%s: Reset frames", __func__); +#endif + + reset_frames = true; + + // Notify CP to work again + cp_accel_send_event_mcu2cp(1); +} + +SRAM_TEXT_LOC +bool a2dp_cp_get_frame_reset_status(void) { return reset_frames; } + +CP_TEXT_SRAM_LOC +enum CP_EMPTY_OUT_FRM_T a2dp_cp_get_emtpy_out_frame(void **p_buf, + uint32_t *p_len) { + enum CP_EMPTY_OUT_FRM_T ret; + uint8_t out_widx; + uint32_t out_wpos; + enum CP_DEC_STATE_T state; + + if (reset_frames) { + return CP_EMPTY_OUT_FRM_ERR; + } + + out_widx = cp_out_widx; + state = out_frames[out_widx].state; + + if (state != CP_DEC_STATE_IDLE && state != CP_DEC_STATE_WORKING) { + return CP_EMPTY_OUT_FRM_ERR; + } + + if (state == CP_DEC_STATE_WORKING) { + ret = CP_EMPTY_OUT_FRM_WORKING; + } else { + out_frames[out_widx].state = CP_DEC_STATE_WORKING; + ret = CP_EMPTY_OUT_FRM_OK; + } + + out_wpos = out_frames[out_widx].pos; + + if (p_buf) { + *p_buf = &cp_out_cache[out_wpos]; + } + if (p_len) { + *p_len = out_frames[out_widx].len; + } + + return ret; +} + +CP_TEXT_SRAM_LOC +int a2dp_cp_consume_emtpy_out_frame(void) { + uint8_t out_widx; + + if (reset_frames) { + return 0; + } + + out_widx = cp_out_widx; + + if (out_frames[out_widx].state != CP_DEC_STATE_WORKING) { + return 1; + } + + out_frames[out_widx].state = CP_DEC_STATE_DONE; + +#ifdef A2DP_TRACE_CP_ACCEL + TRACE_A2DP_DECODER_I("AD2P-CP out frame W[%d]", out_widx); +#endif + + out_widx += 1; + if (out_widx >= CP_OUT_FRAME_CNT) { + out_widx -= CP_OUT_FRAME_CNT; + } + cp_out_widx = out_widx; + + return 0; +} + +SRAM_TEXT_LOC +int a2dp_cp_get_full_out_frame(void **p_buf, uint32_t *p_len) { + uint8_t out_ridx; + uint32_t out_rpos; + enum CP_DEC_STATE_T state; + + if (reset_frames) { + return -1; + } + + out_ridx = cp_out_ridx; + state = out_frames[out_ridx].state; + + if (state != CP_DEC_STATE_DONE && state != CP_DEC_STATE_INIT_DONE) { + // Notify CP to work again + cp_accel_send_event_mcu2cp( + CP_BUILD_ID(CP_TASK_A2DP_DECODE, CP_EVENT_A2DP_DECODE)); + if (state == CP_DEC_STATE_WORKING) { + return CP_EMPTY_OUT_FRM_WORKING; + } else { + return (10 + state); + } + } + + out_rpos = out_frames[out_ridx].pos; + + if (state == CP_DEC_STATE_DONE) { if (p_buf) { - *p_buf = &cp_out_cache[out_wpos]; + *p_buf = &cp_out_cache[out_rpos]; } if (p_len) { - *p_len = out_frames[out_widx].len; + *p_len = out_frames[out_ridx].len; } - - return ret; -} - -CP_TEXT_SRAM_LOC -int a2dp_cp_consume_emtpy_out_frame(void) -{ - uint8_t out_widx; - - if (reset_frames) { - return 0; + } else { + if (p_buf) { + *p_buf = NULL; } - - out_widx = cp_out_widx; - - if (out_frames[out_widx].state != CP_DEC_STATE_WORKING) { - return 1; + if (p_len) { + *p_len = 0; } + } - out_frames[out_widx].state = CP_DEC_STATE_DONE; - -#ifdef A2DP_TRACE_CP_ACCEL - TRACE_A2DP_DECODER_I("AD2P-CP out frame W[%d]", out_widx); -#endif - - out_widx += 1; - if (out_widx >= CP_OUT_FRAME_CNT) { - out_widx -= CP_OUT_FRAME_CNT; - } - cp_out_widx = out_widx; - - return 0; + return 0; } SRAM_TEXT_LOC -int a2dp_cp_get_full_out_frame(void **p_buf, uint32_t *p_len) -{ - uint8_t out_ridx; - uint32_t out_rpos; - enum CP_DEC_STATE_T state ; - - if (reset_frames) { - return -1; - } - - out_ridx = cp_out_ridx; - state = out_frames[out_ridx].state; - - if (state != CP_DEC_STATE_DONE && state != CP_DEC_STATE_INIT_DONE) { - // Notify CP to work again - cp_accel_send_event_mcu2cp(CP_BUILD_ID(CP_TASK_A2DP_DECODE, CP_EVENT_A2DP_DECODE)); - if (state == CP_DEC_STATE_WORKING){ - return CP_EMPTY_OUT_FRM_WORKING; - }else{ - return (10 + state); - } - } - - out_rpos = out_frames[out_ridx].pos; - - if (state == CP_DEC_STATE_DONE) { - if (p_buf) { - *p_buf = &cp_out_cache[out_rpos]; - } - if (p_len) { - *p_len = out_frames[out_ridx].len; - } - } else { - if (p_buf) { - *p_buf = NULL; - } - if (p_len) { - *p_len = 0; - } - } +int a2dp_cp_consume_full_out_frame(void) { + uint8_t out_ridx; + enum CP_DEC_STATE_T state; + if (reset_frames) { return 0; -} + } -SRAM_TEXT_LOC -int a2dp_cp_consume_full_out_frame(void) -{ - uint8_t out_ridx; - enum CP_DEC_STATE_T state ; + out_ridx = cp_out_ridx; + state = out_frames[out_ridx].state; - if (reset_frames) { - return 0; - } - - out_ridx = cp_out_ridx; - state = out_frames[out_ridx].state; - - if (state != CP_DEC_STATE_DONE && state != CP_DEC_STATE_INIT_DONE) { - return 1; - } + if (state != CP_DEC_STATE_DONE && state != CP_DEC_STATE_INIT_DONE) { + return 1; + } #ifdef A2DP_TRACE_CP_ACCEL - TRACE_A2DP_DECODER_I("AD2P-CP out frame R[%d]", out_ridx); + TRACE_A2DP_DECODER_I("AD2P-CP out frame R[%d]", out_ridx); #endif - out_frames[out_ridx].state = CP_DEC_STATE_IDLE; + out_frames[out_ridx].state = CP_DEC_STATE_IDLE; - out_ridx += 1; - if (out_ridx >= CP_OUT_FRAME_CNT) { - out_ridx -= CP_OUT_FRAME_CNT; - } - cp_out_ridx = out_ridx; + out_ridx += 1; + if (out_ridx >= CP_OUT_FRAME_CNT) { + out_ridx -= CP_OUT_FRAME_CNT; + } + cp_out_ridx = out_ridx; - // Notify CP to work again - cp_accel_send_event_mcu2cp(CP_BUILD_ID(CP_TASK_A2DP_DECODE, CP_EVENT_A2DP_DECODE)); + // Notify CP to work again + cp_accel_send_event_mcu2cp( + CP_BUILD_ID(CP_TASK_A2DP_DECODE, CP_EVENT_A2DP_DECODE)); - return 0; + return 0; } #endif - diff --git a/apps/audioplayers/a2dp_decoder/a2dp_decoder_example.cpp b/apps/audioplayers/a2dp_decoder/a2dp_decoder_example.cpp index 34595c0..76381ca 100644 --- a/apps/audioplayers/a2dp_decoder/a2dp_decoder_example.cpp +++ b/apps/audioplayers/a2dp_decoder/a2dp_decoder_example.cpp @@ -14,124 +14,116 @@ * ****************************************************************************/ // Standard C Included Files +#include "a2dp_decoder_internal.h" #include "cmsis.h" +#include "hal_location.h" +#include "heap_api.h" #include "plat_types.h" #include -#include "heap_api.h" -#include "hal_location.h" -#include "a2dp_decoder_internal.h" static A2DP_AUDIO_CONTEXT_T *a2dp_audio_context_p = NULL; static A2DP_AUDIO_DECODER_LASTFRAME_INFO_T a2dp_audio_ldac_example_info; static A2DP_AUDIO_OUTPUT_CONFIG_T a2dp_audio_example_output_config; typedef struct { - uint16_t sequenceNumber; - uint32_t timestamp; - uint8_t *buffer; - uint32_t buffer_len; + uint16_t sequenceNumber; + uint32_t timestamp; + uint8_t *buffer; + uint32_t buffer_len; } a2dp_audio_example_decoder_frame_t; - -int a2dp_audio_example_decode_frame(uint8_t *buffer, uint32_t buffer_bytes) -{ - return A2DP_DECODER_NO_ERROR; +int a2dp_audio_example_decode_frame(uint8_t *buffer, uint32_t buffer_bytes) { + return A2DP_DECODER_NO_ERROR; } -int a2dp_audio_example_preparse_packet(btif_media_header_t * header, uint8_t *buffer, uint32_t buffer_bytes) -{ - return A2DP_DECODER_NO_ERROR; +int a2dp_audio_example_preparse_packet(btif_media_header_t *header, + uint8_t *buffer, uint32_t buffer_bytes) { + return A2DP_DECODER_NO_ERROR; } +static void *a2dp_audio_example_frame_malloc(uint32_t packet_len) { + a2dp_audio_example_decoder_frame_t *decoder_frame_p = NULL; + uint8_t *buffer = NULL; -static void *a2dp_audio_example_frame_malloc(uint32_t packet_len) -{ - a2dp_audio_example_decoder_frame_t *decoder_frame_p = NULL; - uint8_t *buffer = NULL; - - buffer = (uint8_t *)a2dp_audio_heap_malloc(packet_len); - decoder_frame_p = (a2dp_audio_example_decoder_frame_t *)a2dp_audio_heap_malloc(sizeof(a2dp_audio_example_decoder_frame_t)); - decoder_frame_p->buffer = buffer; - decoder_frame_p->buffer_len = packet_len; - return (void *)decoder_frame_p; + buffer = (uint8_t *)a2dp_audio_heap_malloc(packet_len); + decoder_frame_p = + (a2dp_audio_example_decoder_frame_t *)a2dp_audio_heap_malloc( + sizeof(a2dp_audio_example_decoder_frame_t)); + decoder_frame_p->buffer = buffer; + decoder_frame_p->buffer_len = packet_len; + return (void *)decoder_frame_p; } -void a2dp_audio_example_free(void *packet) -{ - a2dp_audio_example_decoder_frame_t *decoder_frame_p = (a2dp_audio_example_decoder_frame_t *)packet; - a2dp_audio_heap_free(decoder_frame_p->buffer); - a2dp_audio_heap_free(decoder_frame_p); +void a2dp_audio_example_free(void *packet) { + a2dp_audio_example_decoder_frame_t *decoder_frame_p = + (a2dp_audio_example_decoder_frame_t *)packet; + a2dp_audio_heap_free(decoder_frame_p->buffer); + a2dp_audio_heap_free(decoder_frame_p); } -int a2dp_audio_example_store_packet(btif_media_header_t * header, uint8_t *buffer, uint32_t buffer_bytes) -{ - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - a2dp_audio_example_decoder_frame_t *decoder_frame_p = (a2dp_audio_example_decoder_frame_t *)a2dp_audio_example_frame_malloc(buffer_bytes); +int a2dp_audio_example_store_packet(btif_media_header_t *header, + uint8_t *buffer, uint32_t buffer_bytes) { + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + a2dp_audio_example_decoder_frame_t *decoder_frame_p = + (a2dp_audio_example_decoder_frame_t *)a2dp_audio_example_frame_malloc( + buffer_bytes); - decoder_frame_p->sequenceNumber = header->sequenceNumber; - decoder_frame_p->timestamp = header->timestamp; - memcpy(decoder_frame_p->buffer, buffer, buffer_bytes); - decoder_frame_p->buffer_len = buffer_bytes; - a2dp_audio_list_append(list, decoder_frame_p); + decoder_frame_p->sequenceNumber = header->sequenceNumber; + decoder_frame_p->timestamp = header->timestamp; + memcpy(decoder_frame_p->buffer, buffer, buffer_bytes); + decoder_frame_p->buffer_len = buffer_bytes; + a2dp_audio_list_append(list, decoder_frame_p); - return A2DP_DECODER_NO_ERROR; + return A2DP_DECODER_NO_ERROR; } -int a2dp_audio_example_discards_packet(uint32_t packets) -{ - return A2DP_DECODER_NO_ERROR; +int a2dp_audio_example_discards_packet(uint32_t packets) { + return A2DP_DECODER_NO_ERROR; } -int a2dp_audio_example_headframe_info_get(A2DP_AUDIO_HEADFRAME_INFO_T* headframe_info) -{ - return A2DP_DECODER_NO_ERROR; +int a2dp_audio_example_headframe_info_get( + A2DP_AUDIO_HEADFRAME_INFO_T *headframe_info) { + return A2DP_DECODER_NO_ERROR; } -int a2dp_audio_example_info_get(void *info) -{ - return A2DP_DECODER_NO_ERROR; +int a2dp_audio_example_info_get(void *info) { return A2DP_DECODER_NO_ERROR; } + +int a2dp_audio_example_init(A2DP_AUDIO_OUTPUT_CONFIG_T *config, void *context) { + TRACE_A2DP_DECODER_D("%s", __func__); + a2dp_audio_context_p = (A2DP_AUDIO_CONTEXT_T *)context; + + memset(&a2dp_audio_ldac_example_info, 0, + sizeof(A2DP_AUDIO_DECODER_LASTFRAME_INFO_T)); + memcpy(&a2dp_audio_example_output_config, config, + sizeof(A2DP_AUDIO_OUTPUT_CONFIG_T)); + a2dp_audio_ldac_example_info.stream_info = &a2dp_audio_example_output_config; + + return A2DP_DECODER_NO_ERROR; } -int a2dp_audio_example_init(A2DP_AUDIO_OUTPUT_CONFIG_T *config, void *context) -{ - TRACE_A2DP_DECODER_D("%s", __func__); - a2dp_audio_context_p = (A2DP_AUDIO_CONTEXT_T *)context; +int a2dp_audio_example_deinit(void) { return A2DP_DECODER_NO_ERROR; } - memset(&a2dp_audio_ldac_example_info, 0, sizeof(A2DP_AUDIO_DECODER_LASTFRAME_INFO_T)); - memcpy(&a2dp_audio_example_output_config, config, sizeof(A2DP_AUDIO_OUTPUT_CONFIG_T)); - a2dp_audio_ldac_example_info.stream_info = &a2dp_audio_example_output_config; - - return A2DP_DECODER_NO_ERROR; +int a2dp_audio_example_synchronize_packet( + A2DP_AUDIO_SYNCFRAME_INFO_T *sync_info, uint32_t mask) { + return A2DP_DECODER_NO_ERROR; } -int a2dp_audio_example_deinit(void) -{ - return A2DP_DECODER_NO_ERROR; -} - -int a2dp_audio_example_synchronize_packet(A2DP_AUDIO_SYNCFRAME_INFO_T *sync_info, uint32_t mask) -{ - return A2DP_DECODER_NO_ERROR; -} - -int a2dp_audio_example_synchronize_dest_packet_mut(uint16_t packet_mut) -{ - return A2DP_DECODER_NO_ERROR; +int a2dp_audio_example_synchronize_dest_packet_mut(uint16_t packet_mut) { + return A2DP_DECODER_NO_ERROR; } A2DP_AUDIO_DECODER_T a2dp_audio_example_decoder_config = { - {44100, 2, 16}, - 0, - a2dp_audio_example_init, - a2dp_audio_example_deinit, - a2dp_audio_example_decode_frame, - a2dp_audio_example_preparse_packet, - a2dp_audio_example_store_packet, - a2dp_audio_example_discards_packet, - a2dp_audio_example_synchronize_packet, - a2dp_audio_example_synchronize_dest_packet_mut, - a2dp_audio_example_headframe_info_get, - a2dp_audio_example_info_get, - a2dp_audio_example_free, - } ; - + {44100, 2, 16}, + 0, + a2dp_audio_example_init, + a2dp_audio_example_deinit, + a2dp_audio_example_decode_frame, + a2dp_audio_example_preparse_packet, + a2dp_audio_example_store_packet, + a2dp_audio_example_discards_packet, + a2dp_audio_example_synchronize_packet, + a2dp_audio_example_synchronize_dest_packet_mut, + a2dp_audio_example_headframe_info_get, + a2dp_audio_example_info_get, + a2dp_audio_example_free, +}; diff --git a/apps/audioplayers/a2dp_decoder/a2dp_decoder_ldac.cpp b/apps/audioplayers/a2dp_decoder/a2dp_decoder_ldac.cpp index e03aa3a..2f578ce 100644 --- a/apps/audioplayers/a2dp_decoder/a2dp_decoder_ldac.cpp +++ b/apps/audioplayers/a2dp_decoder/a2dp_decoder_ldac.cpp @@ -14,262 +14,236 @@ * ****************************************************************************/ // Standard C Included Files -#include "cmsis.h" -#include "plat_types.h" -#include -#include "heap_api.h" -#include "hal_location.h" #include "a2dp_decoder_internal.h" #include "btapp.h" -#include"ldacBT.h" +#include "cmsis.h" +#include "hal_location.h" +#include "heap_api.h" +#include "ldacBT.h" +#include "plat_types.h" +#include -typedef struct -{ - uint16_t sequenceNumber; - uint32_t timestamp; - uint32_t frame_samples; - uint16_t curSubSequenceNumber; - uint16_t totalSubSequenceNumber; - uint8_t *buffer; - uint32_t buffer_len; +typedef struct { + uint16_t sequenceNumber; + uint32_t timestamp; + uint32_t frame_samples; + uint16_t curSubSequenceNumber; + uint16_t totalSubSequenceNumber; + uint8_t *buffer; + uint32_t buffer_len; } a2dp_audio_ldac_decoder_frame_t; - - #ifndef LDAC_MTU_LIMITER #define LDAC_MTU_LIMITER (200) #endif -#define DECODE_LDAC_PCM_FRAME_LENGTH (256*4*2*2) +#define DECODE_LDAC_PCM_FRAME_LENGTH (256 * 4 * 2 * 2) #define LDAC_LIST_SAMPLES (256) - static A2DP_AUDIO_CONTEXT_T *a2dp_audio_context_p = NULL; static A2DP_AUDIO_DECODER_LASTFRAME_INFO_T a2dp_audio_ldac_lastframe_info; static uint16_t ldac_mtu_limiter = LDAC_MTU_LIMITER; -//static btif_media_header_t ldac_header_parser_header_prev = {0,}; -//static bool ldac_header_parser_ready = false; -//static bool ldac_chnl_mode_mono = false; +// static btif_media_header_t ldac_header_parser_header_prev = {0,}; +// static bool ldac_header_parser_ready = false; +// static bool ldac_chnl_mode_mono = false; HANDLE_LDAC_BT LdacDecHandle = NULL; -//static uint8_t *ldac_mempoll = NULL; +// static uint8_t *ldac_mempoll = NULL; heap_handle_t ldac_memhandle = NULL; static uint32_t l2cap_frame_samples = LDAC_LIST_SAMPLES; /* Convert LDAC Error Code to string */ -#define CASE_RETURN_STR(const) case const: return #const; -static const char * ldac_ErrCode2Str( int ErrCode ) -{ - switch(ErrCode) - { - CASE_RETURN_STR(LDACBT_ERR_NONE); - CASE_RETURN_STR(LDACBT_ERR_NON_FATAL); - CASE_RETURN_STR(LDACBT_ERR_BIT_ALLOCATION); - CASE_RETURN_STR(LDACBT_ERR_NOT_IMPLEMENTED); - CASE_RETURN_STR(LDACBT_ERR_NON_FATAL_ENCODE); - CASE_RETURN_STR(LDACBT_ERR_FATAL); - CASE_RETURN_STR(LDACBT_ERR_SYNTAX_BAND); - CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_A); - CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_B); - CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_C); - CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_D); - CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_E); - CASE_RETURN_STR(LDACBT_ERR_SYNTAX_IDSF); - CASE_RETURN_STR(LDACBT_ERR_SYNTAX_SPEC); - CASE_RETURN_STR(LDACBT_ERR_BIT_PACKING); - CASE_RETURN_STR(LDACBT_ERR_ALLOC_MEMORY); - CASE_RETURN_STR(LDACBT_ERR_FATAL_HANDLE); - CASE_RETURN_STR(LDACBT_ERR_ILL_SYNCWORD); - CASE_RETURN_STR(LDACBT_ERR_ILL_SMPL_FORMAT); - CASE_RETURN_STR(LDACBT_ERR_ILL_PARAM); - CASE_RETURN_STR(LDACBT_ERR_ASSERT_SAMPLING_FREQ); - CASE_RETURN_STR(LDACBT_ERR_ASSERT_SUP_SAMPLING_FREQ); - CASE_RETURN_STR(LDACBT_ERR_CHECK_SAMPLING_FREQ); - CASE_RETURN_STR(LDACBT_ERR_ASSERT_CHANNEL_CONFIG); - CASE_RETURN_STR(LDACBT_ERR_CHECK_CHANNEL_CONFIG); - CASE_RETURN_STR(LDACBT_ERR_ASSERT_FRAME_LENGTH); - CASE_RETURN_STR(LDACBT_ERR_ASSERT_SUP_FRAME_LENGTH); - CASE_RETURN_STR(LDACBT_ERR_ASSERT_FRAME_STATUS); - CASE_RETURN_STR(LDACBT_ERR_ASSERT_NSHIFT); - CASE_RETURN_STR(LDACBT_ERR_ASSERT_CHANNEL_MODE); - CASE_RETURN_STR(LDACBT_ERR_ENC_INIT_ALLOC); - CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADMODE); - CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADPAR_A); - CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADPAR_B); - CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADPAR_C); - CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADPAR_D); - CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_NBANDS); - CASE_RETURN_STR(LDACBT_ERR_PACK_BLOCK_FAILED); - CASE_RETURN_STR(LDACBT_ERR_DEC_INIT_ALLOC); - CASE_RETURN_STR(LDACBT_ERR_INPUT_BUFFER_SIZE); - CASE_RETURN_STR(LDACBT_ERR_UNPACK_BLOCK_FAILED); - CASE_RETURN_STR(LDACBT_ERR_UNPACK_BLOCK_ALIGN); - CASE_RETURN_STR(LDACBT_ERR_UNPACK_FRAME_ALIGN); - CASE_RETURN_STR(LDACBT_ERR_FRAME_LENGTH_OVER); - CASE_RETURN_STR(LDACBT_ERR_FRAME_ALIGN_OVER); - CASE_RETURN_STR(LDACBT_ERR_ALTER_EQMID_LIMITED); - CASE_RETURN_STR(LDACBT_ERR_ILL_EQMID); - CASE_RETURN_STR(LDACBT_ERR_ILL_SAMPLING_FREQ); - CASE_RETURN_STR(LDACBT_ERR_ILL_NUM_CHANNEL); - CASE_RETURN_STR(LDACBT_ERR_ILL_MTU_SIZE); - CASE_RETURN_STR(LDACBT_ERR_HANDLE_NOT_INIT); - default: - return "unknown-error-code"; - } +#define CASE_RETURN_STR(const) \ + case const: \ + return #const; +static const char *ldac_ErrCode2Str(int ErrCode) { + switch (ErrCode) { + CASE_RETURN_STR(LDACBT_ERR_NONE); + CASE_RETURN_STR(LDACBT_ERR_NON_FATAL); + CASE_RETURN_STR(LDACBT_ERR_BIT_ALLOCATION); + CASE_RETURN_STR(LDACBT_ERR_NOT_IMPLEMENTED); + CASE_RETURN_STR(LDACBT_ERR_NON_FATAL_ENCODE); + CASE_RETURN_STR(LDACBT_ERR_FATAL); + CASE_RETURN_STR(LDACBT_ERR_SYNTAX_BAND); + CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_A); + CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_B); + CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_C); + CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_D); + CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_E); + CASE_RETURN_STR(LDACBT_ERR_SYNTAX_IDSF); + CASE_RETURN_STR(LDACBT_ERR_SYNTAX_SPEC); + CASE_RETURN_STR(LDACBT_ERR_BIT_PACKING); + CASE_RETURN_STR(LDACBT_ERR_ALLOC_MEMORY); + CASE_RETURN_STR(LDACBT_ERR_FATAL_HANDLE); + CASE_RETURN_STR(LDACBT_ERR_ILL_SYNCWORD); + CASE_RETURN_STR(LDACBT_ERR_ILL_SMPL_FORMAT); + CASE_RETURN_STR(LDACBT_ERR_ILL_PARAM); + CASE_RETURN_STR(LDACBT_ERR_ASSERT_SAMPLING_FREQ); + CASE_RETURN_STR(LDACBT_ERR_ASSERT_SUP_SAMPLING_FREQ); + CASE_RETURN_STR(LDACBT_ERR_CHECK_SAMPLING_FREQ); + CASE_RETURN_STR(LDACBT_ERR_ASSERT_CHANNEL_CONFIG); + CASE_RETURN_STR(LDACBT_ERR_CHECK_CHANNEL_CONFIG); + CASE_RETURN_STR(LDACBT_ERR_ASSERT_FRAME_LENGTH); + CASE_RETURN_STR(LDACBT_ERR_ASSERT_SUP_FRAME_LENGTH); + CASE_RETURN_STR(LDACBT_ERR_ASSERT_FRAME_STATUS); + CASE_RETURN_STR(LDACBT_ERR_ASSERT_NSHIFT); + CASE_RETURN_STR(LDACBT_ERR_ASSERT_CHANNEL_MODE); + CASE_RETURN_STR(LDACBT_ERR_ENC_INIT_ALLOC); + CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADMODE); + CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADPAR_A); + CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADPAR_B); + CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADPAR_C); + CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADPAR_D); + CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_NBANDS); + CASE_RETURN_STR(LDACBT_ERR_PACK_BLOCK_FAILED); + CASE_RETURN_STR(LDACBT_ERR_DEC_INIT_ALLOC); + CASE_RETURN_STR(LDACBT_ERR_INPUT_BUFFER_SIZE); + CASE_RETURN_STR(LDACBT_ERR_UNPACK_BLOCK_FAILED); + CASE_RETURN_STR(LDACBT_ERR_UNPACK_BLOCK_ALIGN); + CASE_RETURN_STR(LDACBT_ERR_UNPACK_FRAME_ALIGN); + CASE_RETURN_STR(LDACBT_ERR_FRAME_LENGTH_OVER); + CASE_RETURN_STR(LDACBT_ERR_FRAME_ALIGN_OVER); + CASE_RETURN_STR(LDACBT_ERR_ALTER_EQMID_LIMITED); + CASE_RETURN_STR(LDACBT_ERR_ILL_EQMID); + CASE_RETURN_STR(LDACBT_ERR_ILL_SAMPLING_FREQ); + CASE_RETURN_STR(LDACBT_ERR_ILL_NUM_CHANNEL); + CASE_RETURN_STR(LDACBT_ERR_ILL_MTU_SIZE); + CASE_RETURN_STR(LDACBT_ERR_HANDLE_NOT_INIT); + default: + return "unknown-error-code"; + } } - char a_ErrorCodeStr[128]; -const char * get_error_code_string( int error_code ) -{ - int errApi, errHdl, errBlk; +const char *get_error_code_string(int error_code) { + int errApi, errHdl, errBlk; - errApi = LDACBT_API_ERR( error_code ); - errHdl = LDACBT_HANDLE_ERR( error_code ); - errBlk = LDACBT_BLOCK_ERR( error_code ); + errApi = LDACBT_API_ERR(error_code); + errHdl = LDACBT_HANDLE_ERR(error_code); + errBlk = LDACBT_BLOCK_ERR(error_code); - a_ErrorCodeStr[0] = '\0'; - strcat( a_ErrorCodeStr, "API:" ); - strcat( a_ErrorCodeStr, ldac_ErrCode2Str( errApi ) ); - strcat( a_ErrorCodeStr, " Handle:" ); - strcat( a_ErrorCodeStr, ldac_ErrCode2Str( errHdl ) ); - strcat( a_ErrorCodeStr, " Block:" ); - strcat( a_ErrorCodeStr, ldac_ErrCode2Str( errBlk ) ); - return a_ErrorCodeStr; + a_ErrorCodeStr[0] = '\0'; + strcat(a_ErrorCodeStr, "API:"); + strcat(a_ErrorCodeStr, ldac_ErrCode2Str(errApi)); + strcat(a_ErrorCodeStr, " Handle:"); + strcat(a_ErrorCodeStr, ldac_ErrCode2Str(errHdl)); + strcat(a_ErrorCodeStr, " Block:"); + strcat(a_ErrorCodeStr, ldac_ErrCode2Str(errBlk)); + return a_ErrorCodeStr; } +#define LDAC_FRAME_LEN_INDEX_106 106 +#define LDAC_FRAME_LEN_INDEX_128 128 +#define LDAC_FRAME_LEN_INDEX_160 160 +#define LDAC_FRAME_LEN_INDEX_216 216 +#define LDAC_FRAME_LEN_INDEX_326 326 +#define LDAC_FRAME_LEN_INDEX_161 161 -#define LDAC_FRAME_LEN_INDEX_106 106 -#define LDAC_FRAME_LEN_INDEX_128 128 -#define LDAC_FRAME_LEN_INDEX_160 160 -#define LDAC_FRAME_LEN_INDEX_216 216 -#define LDAC_FRAME_LEN_INDEX_326 326 -#define LDAC_FRAME_LEN_INDEX_161 161 - -static uint8_t get_ldac_frame_num_by_rawdata(uint8_t *buffer, uint32_t buffer_bytes) -{ - uint32_t frame_len = 0; - uint32_t frame_len_with_head = 0; - uint16_t data1 = 0; - uint16_t data2 = 0; - uint8_t frame_cnt = 0; - for(uint32_t i=0; i> 2 & 0xFFFF)); - //TRACE("#frame len:%d",frame_len); - //for ldac head - frame_len_with_head = frame_len + 4; - } - return frame_cnt; +static uint8_t get_ldac_frame_num_by_rawdata(uint8_t *buffer, + uint32_t buffer_bytes) { + uint32_t frame_len = 0; + uint32_t frame_len_with_head = 0; + uint16_t data1 = 0; + uint16_t data2 = 0; + uint8_t frame_cnt = 0; + for (uint32_t i = 0; i < buffer_bytes; + i += frame_len_with_head, frame_cnt++) { + // TRACE(4,"buffer:%x %x %x %x + // ",buffer[i],buffer[i+1],buffer[i+2],buffer[i+3]); + data1 = (uint16_t)(buffer[i + 1] & 0x07); + data2 = (uint16_t)buffer[i + 2]; + frame_len = ((data1 << 6 & 0xFFFF) | (data2 >> 2 & 0xFFFF)); + // TRACE("#frame len:%d",frame_len); + // for ldac head + frame_len_with_head = frame_len + 4; + } + return frame_cnt; } -#define LDAC_READBUF_SIZE 1024 /* pick something big enough to hold a bunch of frames */ - - +#define LDAC_READBUF_SIZE \ + 1024 /* pick something big enough to hold a bunch of frames */ /** * Decode LDAC data... */ //#include "os_tcb.h" -extern const char * get_error_code_string( int error_code ); +extern const char *get_error_code_string(int error_code); -#define DCODE_LDAC_PCM_FRAME_LENGTH 10224 *2 +#define DCODE_LDAC_PCM_FRAME_LENGTH 10224 * 2 -int check_ldac_header(uint8_t *buffer,uint32_t buff_len) -{ - int channel_mode =0; - int sample_rate=0; - int ret=0; - if(buff_len <2) - ret=-1; - sample_rate=bt_get_ladc_sample_rate(); - channel_mode=bt_ldac_player_get_channelmode(); - //TRACE(3,"%s,%d,%d",__func__,sample_rate,channel_mode); +int check_ldac_header(uint8_t *buffer, uint32_t buff_len) { + int channel_mode = 0; + int sample_rate = 0; + int ret = 0; + if (buff_len < 2) + ret = -1; + sample_rate = bt_get_ladc_sample_rate(); + channel_mode = bt_ldac_player_get_channelmode(); + // TRACE(3,"%s,%d,%d",__func__,sample_rate,channel_mode); - uint32_t i=0; - unsigned char sync2 = 0; - unsigned char cci = 0; + uint32_t i = 0; + unsigned char sync2 = 0; + unsigned char cci = 0; + switch (channel_mode) { + case LDACBT_CHANNEL_MODE_MONO: + cci = LDAC_CCI_MONO; + break; + case LDACBT_CHANNEL_MODE_DUAL_CHANNEL: + cci = LDAC_CCI_DUAL_CHANNEL; + break; + case LDACBT_CHANNEL_MODE_STEREO: + default: + cci = LDAC_CCI_STEREO; + break; + } - switch(channel_mode) - { - case LDACBT_CHANNEL_MODE_MONO: - cci = LDAC_CCI_MONO; - break; - case LDACBT_CHANNEL_MODE_DUAL_CHANNEL: - cci = LDAC_CCI_DUAL_CHANNEL; - break; - case LDACBT_CHANNEL_MODE_STEREO: - default: - cci = LDAC_CCI_STEREO; - break; - } - - if(sample_rate == 1*44100) - { - sync2 = (0 << 5) | (cci << 3); - } - else if(sample_rate == 1*48000) - { - sync2 = (1 << 5) | (cci << 3); - } - else if(sample_rate == 2*44100) - { - sync2 = (2 << 5) | (cci << 3); - } - else if(sample_rate == 2*48000) - { - sync2 = (3 << 5) | (cci << 3); - } - else - { - TRACE(0,"sample rate not surpoort !"); - ret=-2; - return ret; - } - - for(i=0; i=buff_len) - { - TRACE(0,"no find ldac header "); - ret=-3; - } - + if (sample_rate == 1 * 44100) { + sync2 = (0 << 5) | (cci << 3); + } else if (sample_rate == 1 * 48000) { + sync2 = (1 << 5) | (cci << 3); + } else if (sample_rate == 2 * 44100) { + sync2 = (2 << 5) | (cci << 3); + } else if (sample_rate == 2 * 48000) { + sync2 = (3 << 5) | (cci << 3); + } else { + TRACE(0, "sample rate not surpoort !"); + ret = -2; return ret; + } + + for (i = 0; i < buff_len; i++) { + if (buffer[i] == 0xAA) { + if ((buffer[i + 1] & 0xF8) == sync2) { + // TRACE(0,"find ldac header "); + break; + } + } + } + if (i >= buff_len) { + TRACE(0, "no find ldac header "); + ret = -3; + } + + return ret; } #ifdef A2DP_CP_ACCEL -struct A2DP_CP_LDAC_IN_FRM_INFO_T -{ - uint16_t sequenceNumber; - uint32_t timestamp; - uint16_t curSubSequenceNumber; - uint16_t totalSubSequenceNumber; +struct A2DP_CP_LDAC_IN_FRM_INFO_T { + uint16_t sequenceNumber; + uint32_t timestamp; + uint16_t curSubSequenceNumber; + uint16_t totalSubSequenceNumber; }; -struct A2DP_CP_LDAC_OUT_FRM_INFO_T -{ - struct A2DP_CP_LDAC_IN_FRM_INFO_T in_info; - uint16_t frame_samples; - uint16_t decoded_frames; - uint16_t frame_idx; - uint16_t pcm_len; +struct A2DP_CP_LDAC_OUT_FRM_INFO_T { + struct A2DP_CP_LDAC_IN_FRM_INFO_T in_info; + uint16_t frame_samples; + uint16_t decoded_frames; + uint16_t frame_idx; + uint16_t pcm_len; }; extern "C" uint32_t get_in_cp_frame_cnt(void); @@ -279,511 +253,508 @@ extern uint32_t app_bt_stream_get_dma_buffer_samples(void); int a2dp_cp_ldac_cp_decode(void); TEXT_LDAC_LOC -static int a2dp_cp_ldac_after_cache_underflow(void) -{ - TRACE(1,"%s", __func__); - int ret = 0; - a2dp_cp_deinit(); - ret = a2dp_cp_init(a2dp_cp_ldac_cp_decode, CP_PROC_DELAY_2_FRAMES); - ASSERT(ret == 0, "%s: a2dp_cp_init() failed: ret=%d", __func__, ret); +static int a2dp_cp_ldac_after_cache_underflow(void) { + TRACE(1, "%s", __func__); + int ret = 0; + a2dp_cp_deinit(); + ret = a2dp_cp_init(a2dp_cp_ldac_cp_decode, CP_PROC_DELAY_2_FRAMES); + ASSERT(ret == 0, "%s: a2dp_cp_init() failed: ret=%d", __func__, ret); - return ret; + return ret; } -static int a2dp_cp_ldac_mcu_decode(uint8_t *buffer, uint32_t buffer_bytes) -{ - a2dp_audio_ldac_decoder_frame_t *ldac_decoder_frame_p = NULL; - list_node_t *node = NULL; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - int ret, dec_ret; - struct A2DP_CP_LDAC_IN_FRM_INFO_T in_info; - struct A2DP_CP_LDAC_OUT_FRM_INFO_T *p_out_info; +static int a2dp_cp_ldac_mcu_decode(uint8_t *buffer, uint32_t buffer_bytes) { + a2dp_audio_ldac_decoder_frame_t *ldac_decoder_frame_p = NULL; + list_node_t *node = NULL; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + int ret, dec_ret; + struct A2DP_CP_LDAC_IN_FRM_INFO_T in_info; + struct A2DP_CP_LDAC_OUT_FRM_INFO_T *p_out_info; - uint8_t *out; - uint32_t out_len; - uint32_t out_frame_len; - // uint8_t count=0; + uint8_t *out; + uint32_t out_len; + uint32_t out_frame_len; + // uint8_t count=0; - uint32_t cp_buffer_frames_max = 0; + uint32_t cp_buffer_frames_max = 0; - if((buffer_bytes < DECODE_LDAC_PCM_FRAME_LENGTH && (LDACBT_CHANNEL_MODE_MONO != bt_ldac_player_get_channelmode())) - || (buffer_bytes < DECODE_LDAC_PCM_FRAME_LENGTH/2 && (LDACBT_CHANNEL_MODE_MONO == bt_ldac_player_get_channelmode()))) - { - TRACE(1,"ldac_decode pcm_len = %d \n", buffer_bytes); - return A2DP_DECODER_NO_ERROR; + if ((buffer_bytes < DECODE_LDAC_PCM_FRAME_LENGTH && + (LDACBT_CHANNEL_MODE_MONO != bt_ldac_player_get_channelmode())) || + (buffer_bytes < DECODE_LDAC_PCM_FRAME_LENGTH / 2 && + (LDACBT_CHANNEL_MODE_MONO == bt_ldac_player_get_channelmode()))) { + TRACE(1, "ldac_decode pcm_len = %d \n", buffer_bytes); + return A2DP_DECODER_NO_ERROR; + } + + if (!LdacDecHandle) { + TRACE(0, "ldac decode not ready"); + return A2DP_DECODER_NO_ERROR; + } + + cp_buffer_frames_max = app_bt_stream_get_dma_buffer_samples() / 2; + + if (cp_buffer_frames_max % (a2dp_audio_ldac_lastframe_info.frame_samples)) { + cp_buffer_frames_max = + cp_buffer_frames_max / (a2dp_audio_ldac_lastframe_info.frame_samples) + + 1; + } else { + cp_buffer_frames_max = + cp_buffer_frames_max / (a2dp_audio_ldac_lastframe_info.frame_samples); + } + + out_frame_len = sizeof(*p_out_info) + buffer_bytes; + + ret = a2dp_cp_decoder_init(out_frame_len, cp_buffer_frames_max * 8); + + if (ret) { + TRACE(2, "%s: a2dp_cp_decoder_init() failed: ret=%d", __func__, ret); + set_cp_reset_flag(true); + return A2DP_DECODER_DECODE_ERROR; + } + + while ((node = a2dp_audio_list_begin(list)) != NULL) { + ldac_decoder_frame_p = + (a2dp_audio_ldac_decoder_frame_t *)a2dp_audio_list_node(node); + + in_info.sequenceNumber = ldac_decoder_frame_p->sequenceNumber; + in_info.timestamp = ldac_decoder_frame_p->timestamp; + in_info.curSubSequenceNumber = ldac_decoder_frame_p->curSubSequenceNumber; + in_info.totalSubSequenceNumber = + ldac_decoder_frame_p->totalSubSequenceNumber; + ret = a2dp_cp_put_in_frame(&in_info, sizeof(in_info), + ldac_decoder_frame_p->buffer, + ldac_decoder_frame_p->buffer_len); + + if (ret) { + // TRACE(2,"%s piff !!!!!!ret: %d ",__func__, ret); + break; } + // count++; + // TRACE(2,"%s count !!!!!!: %d ",__func__,count); + // TRACE(3,"put seq:%d %d + // %d",in_info.sequenceNumber,in_info.curSubSequenceNumber,in_info.totalSubSequenceNumber); + a2dp_audio_list_remove(list, ldac_decoder_frame_p); + } - if(!LdacDecHandle) - { - TRACE(0,"ldac decode not ready"); - return A2DP_DECODER_NO_ERROR; - } + ret = a2dp_cp_get_full_out_frame((void **)&out, &out_len); - cp_buffer_frames_max = app_bt_stream_get_dma_buffer_samples()/2; + if (ret) { + TRACE(0, "%s %d cp find cache underflow", __func__, __LINE__); + TRACE(2, "aud_list_len:%d. cp_get_in_frame:%d", + a2dp_audio_list_length(list), get_in_cp_frame_cnt()); + a2dp_cp_ldac_after_cache_underflow(); + return A2DP_DECODER_CACHE_UNDERFLOW_ERROR; + } - if (cp_buffer_frames_max %(a2dp_audio_ldac_lastframe_info.frame_samples) ) - { - cp_buffer_frames_max = cp_buffer_frames_max /(a2dp_audio_ldac_lastframe_info.frame_samples) +1 ; - } - else - { - cp_buffer_frames_max = cp_buffer_frames_max /(a2dp_audio_ldac_lastframe_info.frame_samples) ; - } + if (out_len == 0) { + memset(buffer, 0, buffer_bytes); + a2dp_cp_consume_full_out_frame(); + TRACE(1, "%s olz!!!", __func__); + return A2DP_DECODER_NO_ERROR; + } + if (out_len != out_frame_len) { + TRACE(3, "%s: Bad out len %u (should be %u)", __func__, out_len, + out_frame_len); + set_cp_reset_flag(true); + return A2DP_DECODER_DECODE_ERROR; + } + p_out_info = (struct A2DP_CP_LDAC_OUT_FRM_INFO_T *)out; + if (p_out_info->pcm_len) { + a2dp_audio_ldac_lastframe_info.sequenceNumber = + p_out_info->in_info.sequenceNumber; + a2dp_audio_ldac_lastframe_info.timestamp = p_out_info->in_info.timestamp; + a2dp_audio_ldac_lastframe_info.curSubSequenceNumber = + p_out_info->in_info.curSubSequenceNumber; + a2dp_audio_ldac_lastframe_info.totalSubSequenceNumber = + p_out_info->in_info.totalSubSequenceNumber; + a2dp_audio_ldac_lastframe_info.frame_samples = p_out_info->frame_samples; + a2dp_audio_ldac_lastframe_info.decoded_frames += p_out_info->decoded_frames; + a2dp_audio_ldac_lastframe_info.undecode_frames = + a2dp_audio_list_length(list) + + a2dp_cp_get_in_frame_cnt_by_index(p_out_info->frame_idx) - 1; + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_ldac_lastframe_info); + } - out_frame_len = sizeof(*p_out_info) + buffer_bytes; + if (p_out_info->pcm_len == buffer_bytes) { + memcpy(buffer, p_out_info + 1, p_out_info->pcm_len); + dec_ret = A2DP_DECODER_NO_ERROR; + } else { + TRACE(2, "%s %d cp decoder error !!!!!!", __func__, __LINE__); + set_cp_reset_flag(true); + return A2DP_DECODER_DECODE_ERROR; + } - ret = a2dp_cp_decoder_init(out_frame_len, cp_buffer_frames_max * 8); + ret = a2dp_cp_consume_full_out_frame(); + if (ret) { - if (ret) - { - TRACE(2,"%s: a2dp_cp_decoder_init() failed: ret=%d", __func__, ret); - set_cp_reset_flag(true); - return A2DP_DECODER_DECODE_ERROR; - } - - while ((node = a2dp_audio_list_begin(list)) != NULL) - { - ldac_decoder_frame_p = (a2dp_audio_ldac_decoder_frame_t *)a2dp_audio_list_node(node); - - in_info.sequenceNumber = ldac_decoder_frame_p->sequenceNumber; - in_info.timestamp = ldac_decoder_frame_p->timestamp; - in_info.curSubSequenceNumber = ldac_decoder_frame_p->curSubSequenceNumber; - in_info.totalSubSequenceNumber = ldac_decoder_frame_p->totalSubSequenceNumber; - ret = a2dp_cp_put_in_frame(&in_info, sizeof(in_info), ldac_decoder_frame_p->buffer, ldac_decoder_frame_p->buffer_len); - - if (ret) - { - //TRACE(2,"%s piff !!!!!!ret: %d ",__func__, ret); - break; - } - // count++; - // TRACE(2,"%s count !!!!!!: %d ",__func__,count); - //TRACE(3,"put seq:%d %d %d",in_info.sequenceNumber,in_info.curSubSequenceNumber,in_info.totalSubSequenceNumber); - a2dp_audio_list_remove(list, ldac_decoder_frame_p); - } - - ret = a2dp_cp_get_full_out_frame((void **)&out, &out_len); - - if (ret) - { - TRACE(0,"%s %d cp find cache underflow",__func__, __LINE__); - TRACE(2,"aud_list_len:%d. cp_get_in_frame:%d", a2dp_audio_list_length(list), get_in_cp_frame_cnt()); - a2dp_cp_ldac_after_cache_underflow(); - return A2DP_DECODER_CACHE_UNDERFLOW_ERROR; - } - - if (out_len == 0) - { - memset(buffer, 0, buffer_bytes); - a2dp_cp_consume_full_out_frame(); - TRACE(1,"%s olz!!!",__func__); - return A2DP_DECODER_NO_ERROR; - } - if (out_len != out_frame_len) - { - TRACE(3,"%s: Bad out len %u (should be %u)", __func__, out_len, out_frame_len); - set_cp_reset_flag(true); - return A2DP_DECODER_DECODE_ERROR; - } - p_out_info = (struct A2DP_CP_LDAC_OUT_FRM_INFO_T *)out; - if (p_out_info->pcm_len) - { - a2dp_audio_ldac_lastframe_info.sequenceNumber = p_out_info->in_info.sequenceNumber; - a2dp_audio_ldac_lastframe_info.timestamp = p_out_info->in_info.timestamp; - a2dp_audio_ldac_lastframe_info.curSubSequenceNumber = p_out_info->in_info.curSubSequenceNumber; - a2dp_audio_ldac_lastframe_info.totalSubSequenceNumber = p_out_info->in_info.totalSubSequenceNumber; - a2dp_audio_ldac_lastframe_info.frame_samples = p_out_info->frame_samples; - a2dp_audio_ldac_lastframe_info.decoded_frames += p_out_info->decoded_frames; - a2dp_audio_ldac_lastframe_info.undecode_frames = - a2dp_audio_list_length(list) + a2dp_cp_get_in_frame_cnt_by_index(p_out_info->frame_idx) - 1; - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_ldac_lastframe_info); - } - - if (p_out_info->pcm_len == buffer_bytes) - { - memcpy(buffer, p_out_info + 1, p_out_info->pcm_len); - dec_ret = A2DP_DECODER_NO_ERROR; - } - else - { - TRACE(2,"%s %d cp decoder error !!!!!!", __func__, __LINE__); - set_cp_reset_flag(true); - return A2DP_DECODER_DECODE_ERROR; - } - - ret = a2dp_cp_consume_full_out_frame(); - if (ret) - { - - TRACE(2,"%s: a2dp_cp_consume_full_out_frame() failed: ret=%d", __func__, ret); - set_cp_reset_flag(true); - return A2DP_DECODER_DECODE_ERROR; - } - return dec_ret; + TRACE(2, "%s: a2dp_cp_consume_full_out_frame() failed: ret=%d", __func__, + ret); + set_cp_reset_flag(true); + return A2DP_DECODER_DECODE_ERROR; + } + return dec_ret; } TEXT_LDAC_LOC -int a2dp_cp_ldac_cp_decode(void) -{ - int ret; - enum CP_EMPTY_OUT_FRM_T out_frm_st; - uint8_t *out; - uint32_t out_len; - uint8_t *dec_start; - uint32_t dec_len; - struct A2DP_CP_LDAC_IN_FRM_INFO_T *p_in_info; - struct A2DP_CP_LDAC_OUT_FRM_INFO_T *p_out_info; - uint8_t *in_buf; - uint32_t in_len; +int a2dp_cp_ldac_cp_decode(void) { + int ret; + enum CP_EMPTY_OUT_FRM_T out_frm_st; + uint8_t *out; + uint32_t out_len; + uint8_t *dec_start; + uint32_t dec_len; + struct A2DP_CP_LDAC_IN_FRM_INFO_T *p_in_info; + struct A2DP_CP_LDAC_OUT_FRM_INFO_T *p_out_info; + uint8_t *in_buf; + uint32_t in_len; - int32_t dec_sum; + int32_t dec_sum; - int used_bytes=0; - int wrote_bytes=0; + int used_bytes = 0; + int wrote_bytes = 0; - out_frm_st = a2dp_cp_get_emtpy_out_frame((void **)&out, &out_len); + out_frm_st = a2dp_cp_get_emtpy_out_frame((void **)&out, &out_len); - if (out_frm_st != CP_EMPTY_OUT_FRM_OK && out_frm_st != CP_EMPTY_OUT_FRM_WORKING) - { - return out_frm_st; + if (out_frm_st != CP_EMPTY_OUT_FRM_OK && + out_frm_st != CP_EMPTY_OUT_FRM_WORKING) { + return out_frm_st; + } + + ASSERT(out_len > sizeof(*p_out_info), "%s: Bad out_len %u (should > %u)", + __func__, out_len, sizeof(*p_out_info)); + + p_out_info = (struct A2DP_CP_LDAC_OUT_FRM_INFO_T *)out; + if (out_frm_st == CP_EMPTY_OUT_FRM_OK) { + p_out_info->pcm_len = 0; + p_out_info->decoded_frames = 0; + } + + ASSERT(out_len > sizeof(*p_out_info) + p_out_info->pcm_len, + "%s: Bad out_len %u (should > %u + %u)", __func__, out_len, + sizeof(*p_out_info), p_out_info->pcm_len); + + dec_start = (uint8_t *)(p_out_info + 1) + p_out_info->pcm_len; + dec_len = out_len - (dec_start - (uint8_t *)out); + + dec_sum = 0; + + while (dec_sum < (int32_t)dec_len) { + ret = a2dp_cp_get_in_frame((void **)&in_buf, &in_len); + + if (ret) { + TRACE(1, "cp_get_int_frame fail, ret=%d", ret); + return 4; } - ASSERT(out_len > sizeof(*p_out_info), "%s: Bad out_len %u (should > %u)", __func__, out_len, sizeof(*p_out_info)); + ASSERT(in_len > sizeof(*p_in_info), "%s: Bad in_len %u (should > %u)", + __func__, in_len, sizeof(*p_in_info)); - p_out_info = (struct A2DP_CP_LDAC_OUT_FRM_INFO_T *)out; - if (out_frm_st == CP_EMPTY_OUT_FRM_OK) - { - p_out_info->pcm_len = 0; - p_out_info->decoded_frames = 0; + p_in_info = (struct A2DP_CP_LDAC_IN_FRM_INFO_T *)in_buf; + in_buf += sizeof(*p_in_info); + in_len -= sizeof(*p_in_info); + // TRACE(2,"decode:seq %d %d %d", p_in_info->sequenceNumber, + // p_in_info->curSubSequenceNumber,p_in_info->totalSubSequenceNumber); + + if (in_buf[0] != 0xaa) { + TRACE(2, "decode:seq %d %d", p_in_info->sequenceNumber, + p_in_info->curSubSequenceNumber); + DUMP8("%x ", in_buf, 30); } - ASSERT(out_len > sizeof(*p_out_info) + p_out_info->pcm_len, "%s: Bad out_len %u (should > %u + %u)", __func__, out_len, sizeof(*p_out_info), p_out_info->pcm_len); - - dec_start = (uint8_t *)(p_out_info + 1) + p_out_info->pcm_len; - dec_len = out_len - (dec_start - (uint8_t *)out); - - dec_sum = 0; - - while (dec_sum < (int32_t)dec_len) - { - ret = a2dp_cp_get_in_frame((void **)&in_buf, &in_len); - - - - if (ret) - { - TRACE(1,"cp_get_int_frame fail, ret=%d", ret); - return 4; - } - - ASSERT(in_len > sizeof(*p_in_info), "%s: Bad in_len %u (should > %u)", __func__, in_len, sizeof(*p_in_info)); - - p_in_info = (struct A2DP_CP_LDAC_IN_FRM_INFO_T *)in_buf; - in_buf += sizeof(*p_in_info); - in_len -= sizeof(*p_in_info); - //TRACE(2,"decode:seq %d %d %d", p_in_info->sequenceNumber, p_in_info->curSubSequenceNumber,p_in_info->totalSubSequenceNumber); - - if(in_buf[0] != 0xaa) - { - TRACE(2,"decode:seq %d %d", p_in_info->sequenceNumber, p_in_info->curSubSequenceNumber); - DUMP8("%x ",in_buf,30); - } - - ret = ldacBT_decode(LdacDecHandle, in_buf, dec_start+dec_sum, LDACBT_SMPL_FMT_S16, in_len, &used_bytes, &wrote_bytes); - //TRACE("%s wb:%d bb:%d pb:%d",__func__,wrote_bytes,dec_len,dec_sum); - dec_sum += wrote_bytes; - if(ret !=0) - { - TRACE(1,"ldac decode error %d",ret); - TRACE(1,"LdacDecHandle error_code:%d",ldacBT_get_error_code(LdacDecHandle)); - ret=A2DP_DECODER_DECODE_ERROR; - return -1; - } - - ret = a2dp_cp_consume_in_frame(); - - if (ret != 0) - { - TRACE(2,"%s: a2dp_cp_consume_in_frame() failed: ret=%d", __func__, ret); - } - ASSERT(ret == 0, "%s: a2dp_cp_consume_in_frame() failed: ret=%d", __func__, ret); - - memcpy(&p_out_info->in_info, p_in_info, sizeof(*p_in_info)); - p_out_info->decoded_frames++; - p_out_info->frame_samples = 256; - p_out_info->frame_idx = a2dp_cp_get_in_frame_index(); + ret = ldacBT_decode(LdacDecHandle, in_buf, dec_start + dec_sum, + LDACBT_SMPL_FMT_S16, in_len, &used_bytes, &wrote_bytes); + // TRACE("%s wb:%d bb:%d pb:%d",__func__,wrote_bytes,dec_len,dec_sum); + dec_sum += wrote_bytes; + if (ret != 0) { + TRACE(1, "ldac decode error %d", ret); + TRACE(1, "LdacDecHandle error_code:%d", + ldacBT_get_error_code(LdacDecHandle)); + ret = A2DP_DECODER_DECODE_ERROR; + return -1; } - if ( dec_sum != (int32_t)dec_len ) - { - TRACE(2,"error!!! dec_sum:%d != dec_len:%d", dec_sum, dec_len); - ASSERT(0, "%s", __func__); + ret = a2dp_cp_consume_in_frame(); + + if (ret != 0) { + TRACE(2, "%s: a2dp_cp_consume_in_frame() failed: ret=%d", __func__, ret); } + ASSERT(ret == 0, "%s: a2dp_cp_consume_in_frame() failed: ret=%d", __func__, + ret); - p_out_info->pcm_len += dec_sum; + memcpy(&p_out_info->in_info, p_in_info, sizeof(*p_in_info)); + p_out_info->decoded_frames++; + p_out_info->frame_samples = 256; + p_out_info->frame_idx = a2dp_cp_get_in_frame_index(); + } - if (out_len <= sizeof(*p_out_info) + p_out_info->pcm_len) - { - ret = a2dp_cp_consume_emtpy_out_frame(); - ASSERT(ret == 0, "%s: a2dp_cp_consume_emtpy_out_frame() failed: ret=%d", __func__, ret); - } + if (dec_sum != (int32_t)dec_len) { + TRACE(2, "error!!! dec_sum:%d != dec_len:%d", dec_sum, dec_len); + ASSERT(0, "%s", __func__); + } - return 0; + p_out_info->pcm_len += dec_sum; + + if (out_len <= sizeof(*p_out_info) + p_out_info->pcm_len) { + ret = a2dp_cp_consume_emtpy_out_frame(); + ASSERT(ret == 0, "%s: a2dp_cp_consume_emtpy_out_frame() failed: ret=%d", + __func__, ret); + } + + return 0; } #endif -int a2dp_audio_ldac_mcu_decode_frame(uint8_t *buffer,uint32_t buffer_bytes) -{ +int a2dp_audio_ldac_mcu_decode_frame(uint8_t *buffer, uint32_t buffer_bytes) { - list_node_t *node=NULL; - uint8_t *temp_buf_ptr1=NULL; - uint8_t *temp_buf_ptr2=NULL; - uint16_t pcm_output_bytes; - uint32_t lock; + list_node_t *node = NULL; + uint8_t *temp_buf_ptr1 = NULL; + uint8_t *temp_buf_ptr2 = NULL; + uint16_t pcm_output_bytes; + uint32_t lock; - a2dp_audio_ldac_decoder_frame_t *ldac_decoder_frame_p=NULL; - int used_bytes=0; - int wrote_bytes=0; - bool cache_underflow=false; - int output_count = 0; - int result=0; + a2dp_audio_ldac_decoder_frame_t *ldac_decoder_frame_p = NULL; + int used_bytes = 0; + int wrote_bytes = 0; + bool cache_underflow = false; + int output_count = 0; + int result = 0; + if ((buffer_bytes < DECODE_LDAC_PCM_FRAME_LENGTH && + (LDACBT_CHANNEL_MODE_MONO != bt_ldac_player_get_channelmode())) || + (buffer_bytes < DECODE_LDAC_PCM_FRAME_LENGTH / 2 && + (LDACBT_CHANNEL_MODE_MONO == bt_ldac_player_get_channelmode()))) { + TRACE(1, "ldac_decode pcm_len = %d \n", buffer_bytes); + return A2DP_DECODER_NO_ERROR; + } - if((buffer_bytes < DECODE_LDAC_PCM_FRAME_LENGTH && (LDACBT_CHANNEL_MODE_MONO != bt_ldac_player_get_channelmode())) - || (buffer_bytes < DECODE_LDAC_PCM_FRAME_LENGTH/2 && (LDACBT_CHANNEL_MODE_MONO == bt_ldac_player_get_channelmode()))) - { - TRACE(1,"ldac_decode pcm_len = %d \n", buffer_bytes); - return A2DP_DECODER_NO_ERROR; - } - - if(!LdacDecHandle) - { - TRACE(0,"ldac decode not ready"); - return A2DP_DECODER_NO_ERROR; - } - - list_t *list=a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - - - //TRACE("jtx~~"); - - for(pcm_output_bytes=0; pcm_output_bytesbuffer; - temp_buf_ptr2=buffer+wrote_bytes*output_count; - - if(temp_buf_ptr1[0] != 0xaa) - { - TRACE(2,"decode:seq %d %d",ldac_decoder_frame_p->sequenceNumber,ldac_decoder_frame_p->curSubSequenceNumber); - DUMP8("%x ",temp_buf_ptr1,30); - - } - - lock = int_lock(); - result = ldacBT_decode(LdacDecHandle,temp_buf_ptr1,temp_buf_ptr2, LDACBT_SMPL_FMT_S16, ldac_decoder_frame_p->buffer_len, &used_bytes, &wrote_bytes); - output_count++; - int_unlock(lock); - - // TRACE("%s wb:%d bb:%d pb:%d",__func__,wrote_bytes,buffer_bytes,pcm_output_bytes); - - // DUMP8("%x ",temp_buf_ptr2,10); - - - if(result !=0) - { - output_count=0; - TRACE(4,"%s wb:%d bb:%d pb:%d",__func__,wrote_bytes,buffer_bytes,pcm_output_bytes); - TRACE(2,"decode:seq %d %d",ldac_decoder_frame_p->sequenceNumber,ldac_decoder_frame_p->curSubSequenceNumber); - DUMP8("%x ",temp_buf_ptr1,10); - TRACE(1,"ldac decode error %d",result); - result=A2DP_DECODER_DECODE_ERROR; - goto exit; - } - } - a2dp_audio_ldac_lastframe_info.sequenceNumber=ldac_decoder_frame_p->sequenceNumber; - a2dp_audio_ldac_lastframe_info.timestamp=ldac_decoder_frame_p->timestamp; - a2dp_audio_ldac_lastframe_info.curSubSequenceNumber = ldac_decoder_frame_p->curSubSequenceNumber; - a2dp_audio_ldac_lastframe_info.totalSubSequenceNumber = ldac_decoder_frame_p->totalSubSequenceNumber; - a2dp_audio_ldac_lastframe_info.frame_samples =ldac_decoder_frame_p->frame_samples ; - a2dp_audio_ldac_lastframe_info.decoded_frames++; - a2dp_audio_ldac_lastframe_info.undecode_frames = a2dp_audio_list_length(list)-1; - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_ldac_lastframe_info); - a2dp_audio_list_remove(list, ldac_decoder_frame_p); + if (!LdacDecHandle) { + TRACE(0, "ldac decode not ready"); + return A2DP_DECODER_NO_ERROR; + } + + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + + // TRACE("jtx~~"); + + for (pcm_output_bytes = 0; pcm_output_bytes < buffer_bytes; + pcm_output_bytes += wrote_bytes) { + node = a2dp_audio_list_begin(list); + if (!node) { + TRACE(0, "ldac decode cache underflow !"); + cache_underflow = true; + goto exit; + } else { + ldac_decoder_frame_p = + (a2dp_audio_ldac_decoder_frame_t *)a2dp_audio_list_node(node); + temp_buf_ptr1 = ldac_decoder_frame_p->buffer; + temp_buf_ptr2 = buffer + wrote_bytes * output_count; + + if (temp_buf_ptr1[0] != 0xaa) { + TRACE(2, "decode:seq %d %d", ldac_decoder_frame_p->sequenceNumber, + ldac_decoder_frame_p->curSubSequenceNumber); + DUMP8("%x ", temp_buf_ptr1, 30); + } + + lock = int_lock(); + result = ldacBT_decode( + LdacDecHandle, temp_buf_ptr1, temp_buf_ptr2, LDACBT_SMPL_FMT_S16, + ldac_decoder_frame_p->buffer_len, &used_bytes, &wrote_bytes); + output_count++; + int_unlock(lock); + + // TRACE("%s wb:%d bb:%d + // pb:%d",__func__,wrote_bytes,buffer_bytes,pcm_output_bytes); + + // DUMP8("%x ",temp_buf_ptr2,10); + + if (result != 0) { + output_count = 0; + TRACE(4, "%s wb:%d bb:%d pb:%d", __func__, wrote_bytes, buffer_bytes, + pcm_output_bytes); + TRACE(2, "decode:seq %d %d", ldac_decoder_frame_p->sequenceNumber, + ldac_decoder_frame_p->curSubSequenceNumber); + DUMP8("%x ", temp_buf_ptr1, 10); + TRACE(1, "ldac decode error %d", result); + result = A2DP_DECODER_DECODE_ERROR; + goto exit; + } } + a2dp_audio_ldac_lastframe_info.sequenceNumber = + ldac_decoder_frame_p->sequenceNumber; + a2dp_audio_ldac_lastframe_info.timestamp = ldac_decoder_frame_p->timestamp; + a2dp_audio_ldac_lastframe_info.curSubSequenceNumber = + ldac_decoder_frame_p->curSubSequenceNumber; + a2dp_audio_ldac_lastframe_info.totalSubSequenceNumber = + ldac_decoder_frame_p->totalSubSequenceNumber; + a2dp_audio_ldac_lastframe_info.frame_samples = + ldac_decoder_frame_p->frame_samples; + a2dp_audio_ldac_lastframe_info.decoded_frames++; + a2dp_audio_ldac_lastframe_info.undecode_frames = + a2dp_audio_list_length(list) - 1; + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_ldac_lastframe_info); + a2dp_audio_list_remove(list, ldac_decoder_frame_p); + } exit: - if(cache_underflow) - { - a2dp_audio_ldac_lastframe_info.undecode_frames = 0; - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_ldac_lastframe_info); - result = A2DP_DECODER_CACHE_UNDERFLOW_ERROR; - } - return result; - -} - -int a2dp_audio_ldac_decode_frame(uint8_t *buffer, uint32_t buffer_bytes) -{ - int ret = 0; - if (bt_ldac_player_get_channelmode() == LDACBT_CHANNEL_MODE_MONO) - { -#ifdef A2DP_CP_ACCEL - ret = a2dp_cp_ldac_mcu_decode(buffer, buffer_bytes / sizeof(int16_t)); -#else - ret = a2dp_audio_ldac_mcu_decode_frame(buffer, buffer_bytes / sizeof(int16_t)); -#endif - int16_t *out_int16 = (int16_t *)buffer; - int16_t wrote_samples = buffer_bytes / sizeof(int16_t); - for (int32_t i = wrote_samples - 1; i >= 0; i--) { - out_int16[2 * i + 1] = out_int16[i]; - out_int16[2 * i] = out_int16[i]; - } - }else -#ifdef A2DP_CP_ACCEL - ret = a2dp_cp_ldac_mcu_decode(buffer, buffer_bytes); -#else - ret = a2dp_audio_ldac_mcu_decode_frame(buffer, buffer_bytes); -#endif - return ret; -} - -int a2dp_audio_ldac_preparse_packet(btif_media_header_t * header, uint8_t *buffer, uint32_t buffer_bytes) -{ - a2dp_audio_ldac_lastframe_info.sequenceNumber = header->sequenceNumber; - a2dp_audio_ldac_lastframe_info.timestamp = header->timestamp; - a2dp_audio_ldac_lastframe_info.curSubSequenceNumber = 0; - a2dp_audio_ldac_lastframe_info.totalSubSequenceNumber = 0; - a2dp_audio_ldac_lastframe_info.frame_samples = LDAC_LIST_SAMPLES; - a2dp_audio_ldac_lastframe_info.list_samples = LDAC_LIST_SAMPLES; - a2dp_audio_ldac_lastframe_info.decoded_frames = 0; + if (cache_underflow) { a2dp_audio_ldac_lastframe_info.undecode_frames = 0; - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_ldac_lastframe_info); - - TRACE(4,"%s seq:%d timestamp:%d frame samples:%d", __func__, header->sequenceNumber, header->timestamp, a2dp_audio_ldac_lastframe_info.frame_samples); - - return A2DP_DECODER_NO_ERROR; - + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_ldac_lastframe_info); + result = A2DP_DECODER_CACHE_UNDERFLOW_ERROR; + } + return result; } - -static void *a2dp_audio_ldac_frame_malloc(uint32_t packet_len) -{ - a2dp_audio_ldac_decoder_frame_t *decoder_frame_p = NULL; - uint8_t *buffer = NULL; - - buffer = (uint8_t *)a2dp_audio_heap_malloc(packet_len); - decoder_frame_p = (a2dp_audio_ldac_decoder_frame_t *)a2dp_audio_heap_malloc(sizeof(a2dp_audio_ldac_decoder_frame_t)); - decoder_frame_p->buffer = buffer; - decoder_frame_p->buffer_len = packet_len; - return (void *)decoder_frame_p; -} - -void a2dp_audio_ldac_free(void *packet) -{ - a2dp_audio_ldac_decoder_frame_t *decoder_frame_p = (a2dp_audio_ldac_decoder_frame_t *)packet; - a2dp_audio_heap_free(decoder_frame_p->buffer); - a2dp_audio_heap_free(decoder_frame_p); -} - -int a2dp_audio_ldac_header_parser(btif_media_header_t *header,uint32_t frame_num) -{ - return 0; -} - - -int a2dp_audio_ldac_store_packet(btif_media_header_t * header, uint8_t *buffer, uint32_t buffer_bytes) -{ - - int nRet = A2DP_DECODER_NOT_SUPPORT; - int check_header_status=0; - - uint32_t frame_cnt = 0; - uint32_t frame_num = 0; - uint32_t frame_len = 0; - uint32_t frame_len_with_head = 0; - uint16_t data1 = 0; - uint16_t data2 = 0; - - - buffer++; - buffer_bytes--; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - - // TRACE("buffer:%x %x %x %x %x %x %x",buffer[0],buffer[1],buffer[2],buffer[3],buffer[4],buffer[5],buffer[6]); - //TRACE(1,"buffer:%x",buffer[2]); - - data1 = (uint16_t)(buffer[1]&0x07); - data2 = (uint16_t)buffer[2]; - frame_len = ((data1<< 6 &0xFFFF) | (data2 >> 2 & 0xFFFF)); - //TRACE("#frame len:%d",frame_len); - frame_num = get_ldac_frame_num_by_rawdata(buffer, buffer_bytes); - - - if ((a2dp_audio_list_length(list)+frame_num) < ldac_mtu_limiter) - { - for(uint32_t i=0; i> 2 & 0xFFFF)); - //TRACE("#frame len:%d",frame_len); - // frame_num = get_ldac_frame_num(frame_len); - // if (!frame_num) - // { - // TRACE(1,"ERROR LDAC FRAME !!! frame_num:%d", frame_num); - // DUMP8("%02x ", buffer, 4); - // return A2DP_DECODER_DECODE_ERROR; - // } - //for ldac head - frame_len_with_head =frame_len+4; - //TRACE(2,"frame len:%d num:%d %d",frame_len,frame_num,a2dp_audio_list_length(list)); - l2cap_frame_samples=256*frame_num; - - //TRACE("i %d buffer bytes:%d",i,buffer_bytes); - check_header_status=check_ldac_header(buffer+i,frame_len_with_head); - if(!check_header_status) - { - a2dp_audio_ldac_decoder_frame_t *ldac_decoder_frame_p=(a2dp_audio_ldac_decoder_frame_t *)a2dp_audio_ldac_frame_malloc(frame_len_with_head); - - ldac_decoder_frame_p->sequenceNumber=header->sequenceNumber; - ldac_decoder_frame_p->curSubSequenceNumber=frame_cnt; - ldac_decoder_frame_p->totalSubSequenceNumber=frame_num; - ldac_decoder_frame_p->timestamp=header->timestamp; - ldac_decoder_frame_p->buffer_len=frame_len_with_head; - ldac_decoder_frame_p->frame_samples=256; - memcpy(ldac_decoder_frame_p->buffer,buffer+i,frame_len_with_head); - //TRACE(5,"seq:%d len:%d i:%d buffer bytes:%d data:%x",header->sequenceNumber, frame_len,i,buffer_bytes,ldac_decoder_frame_p->buffer[0]); - //TRACE(5,"store seq:%d %d %d",header->sequenceNumber,ldac_decoder_frame_p->curSubSequenceNumber,ldac_decoder_frame_p->totalSubSequenceNumber); - a2dp_audio_list_append(list, ldac_decoder_frame_p); - } - else - { - TRACE(1,"ERROR LDAC FRAME ret:%d",check_header_status); - DUMP8("%02x ",buffer+i, 6); - break; - } - nRet = A2DP_DECODER_NO_ERROR; - - - } - +int a2dp_audio_ldac_decode_frame(uint8_t *buffer, uint32_t buffer_bytes) { + int ret = 0; + if (bt_ldac_player_get_channelmode() == LDACBT_CHANNEL_MODE_MONO) { +#ifdef A2DP_CP_ACCEL + ret = a2dp_cp_ldac_mcu_decode(buffer, buffer_bytes / sizeof(int16_t)); +#else + ret = a2dp_audio_ldac_mcu_decode_frame(buffer, + buffer_bytes / sizeof(int16_t)); +#endif + int16_t *out_int16 = (int16_t *)buffer; + int16_t wrote_samples = buffer_bytes / sizeof(int16_t); + for (int32_t i = wrote_samples - 1; i >= 0; i--) { + out_int16[2 * i + 1] = out_int16[i]; + out_int16[2 * i] = out_int16[i]; } - else - { + } else +#ifdef A2DP_CP_ACCEL + ret = a2dp_cp_ldac_mcu_decode(buffer, buffer_bytes); +#else + ret = a2dp_audio_ldac_mcu_decode_frame(buffer, buffer_bytes); +#endif + return ret; +} + +int a2dp_audio_ldac_preparse_packet(btif_media_header_t *header, + uint8_t *buffer, uint32_t buffer_bytes) { + a2dp_audio_ldac_lastframe_info.sequenceNumber = header->sequenceNumber; + a2dp_audio_ldac_lastframe_info.timestamp = header->timestamp; + a2dp_audio_ldac_lastframe_info.curSubSequenceNumber = 0; + a2dp_audio_ldac_lastframe_info.totalSubSequenceNumber = 0; + a2dp_audio_ldac_lastframe_info.frame_samples = LDAC_LIST_SAMPLES; + a2dp_audio_ldac_lastframe_info.list_samples = LDAC_LIST_SAMPLES; + a2dp_audio_ldac_lastframe_info.decoded_frames = 0; + a2dp_audio_ldac_lastframe_info.undecode_frames = 0; + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_ldac_lastframe_info); + + TRACE(4, "%s seq:%d timestamp:%d frame samples:%d", __func__, + header->sequenceNumber, header->timestamp, + a2dp_audio_ldac_lastframe_info.frame_samples); + + return A2DP_DECODER_NO_ERROR; +} + +static void *a2dp_audio_ldac_frame_malloc(uint32_t packet_len) { + a2dp_audio_ldac_decoder_frame_t *decoder_frame_p = NULL; + uint8_t *buffer = NULL; + + buffer = (uint8_t *)a2dp_audio_heap_malloc(packet_len); + decoder_frame_p = (a2dp_audio_ldac_decoder_frame_t *)a2dp_audio_heap_malloc( + sizeof(a2dp_audio_ldac_decoder_frame_t)); + decoder_frame_p->buffer = buffer; + decoder_frame_p->buffer_len = packet_len; + return (void *)decoder_frame_p; +} + +void a2dp_audio_ldac_free(void *packet) { + a2dp_audio_ldac_decoder_frame_t *decoder_frame_p = + (a2dp_audio_ldac_decoder_frame_t *)packet; + a2dp_audio_heap_free(decoder_frame_p->buffer); + a2dp_audio_heap_free(decoder_frame_p); +} + +int a2dp_audio_ldac_header_parser(btif_media_header_t *header, + uint32_t frame_num) { + return 0; +} + +int a2dp_audio_ldac_store_packet(btif_media_header_t *header, uint8_t *buffer, + uint32_t buffer_bytes) { + + int nRet = A2DP_DECODER_NOT_SUPPORT; + int check_header_status = 0; + + uint32_t frame_cnt = 0; + uint32_t frame_num = 0; + uint32_t frame_len = 0; + uint32_t frame_len_with_head = 0; + uint16_t data1 = 0; + uint16_t data2 = 0; + + buffer++; + buffer_bytes--; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + + // TRACE("buffer:%x %x %x %x %x %x + // %x",buffer[0],buffer[1],buffer[2],buffer[3],buffer[4],buffer[5],buffer[6]); + // TRACE(1,"buffer:%x",buffer[2]); + + data1 = (uint16_t)(buffer[1] & 0x07); + data2 = (uint16_t)buffer[2]; + frame_len = ((data1 << 6 & 0xFFFF) | (data2 >> 2 & 0xFFFF)); + // TRACE("#frame len:%d",frame_len); + frame_num = get_ldac_frame_num_by_rawdata(buffer, buffer_bytes); + + if ((a2dp_audio_list_length(list) + frame_num) < ldac_mtu_limiter) { + for (uint32_t i = 0; i < buffer_bytes; + i += frame_len_with_head, frame_cnt++) { + + // TRACE(4,"buffer:%x %x %x %x + // ",buffer[i],buffer[i+1],buffer[i+2],buffer[i+3]); + data1 = (uint16_t)(buffer[i + 1] & 0x07); + data2 = (uint16_t)buffer[i + 2]; + frame_len = ((data1 << 6 & 0xFFFF) | (data2 >> 2 & 0xFFFF)); + // TRACE("#frame len:%d",frame_len); + // frame_num = get_ldac_frame_num(frame_len); + // if (!frame_num) + // { + // TRACE(1,"ERROR LDAC FRAME !!! frame_num:%d", frame_num); + // DUMP8("%02x ", buffer, 4); + // return A2DP_DECODER_DECODE_ERROR; + // } + // for ldac head + frame_len_with_head = frame_len + 4; + // TRACE(2,"frame len:%d num:%d + // %d",frame_len,frame_num,a2dp_audio_list_length(list)); + l2cap_frame_samples = 256 * frame_num; + + // TRACE("i %d buffer bytes:%d",i,buffer_bytes); + check_header_status = check_ldac_header(buffer + i, frame_len_with_head); + if (!check_header_status) { + a2dp_audio_ldac_decoder_frame_t *ldac_decoder_frame_p = + (a2dp_audio_ldac_decoder_frame_t *)a2dp_audio_ldac_frame_malloc( + frame_len_with_head); + + ldac_decoder_frame_p->sequenceNumber = header->sequenceNumber; + ldac_decoder_frame_p->curSubSequenceNumber = frame_cnt; + ldac_decoder_frame_p->totalSubSequenceNumber = frame_num; + ldac_decoder_frame_p->timestamp = header->timestamp; + ldac_decoder_frame_p->buffer_len = frame_len_with_head; + ldac_decoder_frame_p->frame_samples = 256; + memcpy(ldac_decoder_frame_p->buffer, buffer + i, frame_len_with_head); + // TRACE(5,"seq:%d len:%d i:%d buffer bytes:%d + // data:%x",header->sequenceNumber, + // frame_len,i,buffer_bytes,ldac_decoder_frame_p->buffer[0]); + // TRACE(5,"store seq:%d %d + // %d",header->sequenceNumber,ldac_decoder_frame_p->curSubSequenceNumber,ldac_decoder_frame_p->totalSubSequenceNumber); + a2dp_audio_list_append(list, ldac_decoder_frame_p); + } else { + TRACE(1, "ERROR LDAC FRAME ret:%d", check_header_status); + DUMP8("%02x ", buffer + i, 6); + break; + } + nRet = A2DP_DECODER_NO_ERROR; + } + + } else { #if 0 a2dp_audio_ldac_decoder_frame_t *ldac_decoder_frame_p = NULL; @@ -795,309 +766,280 @@ int a2dp_audio_ldac_store_packet(btif_media_header_t * header, uint8_t *buffer, } while(ldac_decoder_frame_p->curSubSequenceNumber!=0); #endif - TRACE(3,"%s list full current list_len step1:%d buff_len:%d", __func__, a2dp_audio_list_length(list), buffer_bytes); - nRet = A2DP_DECODER_MTU_LIMTER_ERROR; - - } - - - - - - return nRet; + TRACE(3, "%s list full current list_len step1:%d buff_len:%d", __func__, + a2dp_audio_list_length(list), buffer_bytes); + nRet = A2DP_DECODER_MTU_LIMTER_ERROR; + } + return nRet; } -int a2dp_audio_ldac_discards_packet(uint32_t packets) -{ - int nRet = A2DP_DECODER_MEMORY_ERROR; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - a2dp_audio_ldac_decoder_frame_t *ldac_decoder_frame_p = NULL; +int a2dp_audio_ldac_discards_packet(uint32_t packets) { + int nRet = A2DP_DECODER_MEMORY_ERROR; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + a2dp_audio_ldac_decoder_frame_t *ldac_decoder_frame_p = NULL; #ifdef A2DP_CP_ACCEL - a2dp_cp_reset_frame(); + a2dp_cp_reset_frame(); #endif - if (packets <= a2dp_audio_list_length(list)) - { - for (uint8_t i=0; iaudio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - a2dp_audio_ldac_decoder_frame_t *ldac_decoder_frame_p = NULL; - int cnt = 0; - - do - { - - //TRACE(1,"cnt:%d",cnt); - ldac_decoder_frame_p = (a2dp_audio_ldac_decoder_frame_t *)a2dp_audio_ldac_frame_malloc(216+4); - if (ldac_decoder_frame_p) - { - a2dp_audio_list_append(list, ldac_decoder_frame_p); - } - cnt++; - } - while(ldac_decoder_frame_p && cnt < LDAC_MTU_LIMITER); - - do - { - node = a2dp_audio_list_begin(list); - if (node) - { - ldac_decoder_frame_p = (a2dp_audio_ldac_decoder_frame_t *)a2dp_audio_list_node(node); - a2dp_audio_list_remove(list, ldac_decoder_frame_p); - } - } - while(node); - - TRACE(3,"%s cnt:%d list:%d", __func__, cnt, a2dp_audio_list_length(list)); - - - return 0; -} - - - -int a2dp_audio_ldac_init(A2DP_AUDIO_OUTPUT_CONFIG_T *config, void *context) -{ - TRACE(1,"%s", __func__); - a2dp_audio_context_p = (A2DP_AUDIO_CONTEXT_T *)context; - - memset(&a2dp_audio_ldac_lastframe_info, 0, sizeof(A2DP_AUDIO_DECODER_LASTFRAME_INFO_T)); - a2dp_audio_ldac_lastframe_info.stream_info = *config; - a2dp_audio_ldac_lastframe_info.frame_samples= 256; - a2dp_audio_ldac_lastframe_info.list_samples = 256; - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_ldac_lastframe_info); - - ASSERT(a2dp_audio_context_p->dest_packet_mut < LDAC_MTU_LIMITER, "%s MTU OVERFLOW:%u/%u", __func__, a2dp_audio_context_p->dest_packet_mut, LDAC_MTU_LIMITER); - -#ifdef A2DP_CP_ACCEL - int ret; - ret = a2dp_cp_init(a2dp_cp_ldac_cp_decode, CP_PROC_DELAY_2_FRAMES); - ASSERT(ret == 0, "%s: a2dp_cp_init() failed: ret=%d", __func__, ret); -#endif - a2dp_audio_ldac_decoder_init(); - a2dp_audio_ldac_list_checker(); - - return A2DP_DECODER_NO_ERROR; -} - - -int a2dp_audio_ldac_deinit(void) -{ - -#ifdef A2DP_CP_ACCEL - a2dp_cp_deinit(); -#endif - a2dp_audio_ldac_decoder_deinit(); - return A2DP_DECODER_NO_ERROR; -} - - - - -int a2dp_audio_ldac_synchronize_packet(A2DP_AUDIO_SYNCFRAME_INFO_T *sync_info,uint32_t mask) -{ - int nRet = A2DP_DECODER_SYNC_ERROR; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - int list_len; - a2dp_audio_ldac_decoder_frame_t *ldac_decoder_frame_p = NULL; - - list_len = a2dp_audio_list_length(list); - - for (uint16_t i=0; isequenceNumber == sync_info->sequenceNumber, A2DP_AUDIO_SYNCFRAME_MASK_SEQ, mask)&& - // A2DP_AUDIO_SYNCFRAME_CHK(ldac_decoder_frame_p->timestamp == sync_info->timestamp, A2DP_AUDIO_SYNCFRAME_MASK_TIMESTAMP, mask)) - - if(A2DP_AUDIO_SYNCFRAME_CHK(ldac_decoder_frame_p->sequenceNumber == sync_info->sequenceNumber, A2DP_AUDIO_SYNCFRAME_MASK_SEQ, mask)&& - A2DP_AUDIO_SYNCFRAME_CHK(ldac_decoder_frame_p->curSubSequenceNumber == sync_info->curSubSequenceNumber, A2DP_AUDIO_SYNCFRAME_MASK_CURRSUBSEQ, mask)&& - A2DP_AUDIO_SYNCFRAME_CHK(ldac_decoder_frame_p->totalSubSequenceNumber == sync_info->totalSubSequenceNumber,A2DP_AUDIO_SYNCFRAME_MASK_TOTALSUBSEQ,mask)) - { - nRet = A2DP_DECODER_NO_ERROR; - break; - } - a2dp_audio_list_remove(list, ldac_decoder_frame_p); +static int a2dp_audio_ldac_list_checker(void) { + + // return 0; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + a2dp_audio_ldac_decoder_frame_t *ldac_decoder_frame_p = NULL; + int cnt = 0; + + do { + + // TRACE(1,"cnt:%d",cnt); + ldac_decoder_frame_p = + (a2dp_audio_ldac_decoder_frame_t *)a2dp_audio_ldac_frame_malloc(216 + + 4); + if (ldac_decoder_frame_p) { + a2dp_audio_list_append(list, ldac_decoder_frame_p); } + cnt++; + } while (ldac_decoder_frame_p && cnt < LDAC_MTU_LIMITER); + do { node = a2dp_audio_list_begin(list); - if (node) - { - ldac_decoder_frame_p = (a2dp_audio_ldac_decoder_frame_t *)a2dp_audio_list_node(node); - TRACE(4,"%s nRet:%d SEQ:%d timestamp:%d", __func__, nRet, ldac_decoder_frame_p->sequenceNumber, ldac_decoder_frame_p->timestamp); - } - else - { - TRACE(2,"%s nRet:%d", __func__, nRet); - // TRACE(5,"nRet:%d SEQ:%d timestamp:%d sync %d/%d", nRet, ldac_decoder_frame_p->sequenceNumber, ldac_decoder_frame_p->timestamp,sync_info->sequenceNumber,sync_info->timestamp); + if (node) { + ldac_decoder_frame_p = + (a2dp_audio_ldac_decoder_frame_t *)a2dp_audio_list_node(node); + a2dp_audio_list_remove(list, ldac_decoder_frame_p); } + } while (node); - return nRet; + TRACE(3, "%s cnt:%d list:%d", __func__, cnt, a2dp_audio_list_length(list)); + return 0; } -int a2dp_audio_ldac_synchronize_dest_packet_mut(uint16_t packet_mut) -{ - list_node_t *node = NULL; - uint32_t list_len = 0; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - a2dp_audio_ldac_decoder_frame_t *ldac_decoder_frame_p = NULL; +int a2dp_audio_ldac_init(A2DP_AUDIO_OUTPUT_CONFIG_T *config, void *context) { + TRACE(1, "%s", __func__); + a2dp_audio_context_p = (A2DP_AUDIO_CONTEXT_T *)context; - list_len = a2dp_audio_list_length(list); - if (list_len > packet_mut) - { - do - { - node = a2dp_audio_list_begin(list); - ldac_decoder_frame_p = (a2dp_audio_ldac_decoder_frame_t *)a2dp_audio_list_node(node); - a2dp_audio_list_remove(list, ldac_decoder_frame_p); - } - while(a2dp_audio_list_length(list) > packet_mut); - } + memset(&a2dp_audio_ldac_lastframe_info, 0, + sizeof(A2DP_AUDIO_DECODER_LASTFRAME_INFO_T)); + a2dp_audio_ldac_lastframe_info.stream_info = *config; + a2dp_audio_ldac_lastframe_info.frame_samples = 256; + a2dp_audio_ldac_lastframe_info.list_samples = 256; + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_ldac_lastframe_info); - TRACE(2,"%s list:%d", __func__, a2dp_audio_list_length(list)); - return A2DP_DECODER_NO_ERROR; + ASSERT(a2dp_audio_context_p->dest_packet_mut < LDAC_MTU_LIMITER, + "%s MTU OVERFLOW:%u/%u", __func__, + a2dp_audio_context_p->dest_packet_mut, LDAC_MTU_LIMITER); +#ifdef A2DP_CP_ACCEL + int ret; + ret = a2dp_cp_init(a2dp_cp_ldac_cp_decode, CP_PROC_DELAY_2_FRAMES); + ASSERT(ret == 0, "%s: a2dp_cp_init() failed: ret=%d", __func__, ret); +#endif + a2dp_audio_ldac_decoder_init(); + a2dp_audio_ldac_list_checker(); + + return A2DP_DECODER_NO_ERROR; } -static int a2dp_audio_ldac_headframe_info_get(A2DP_AUDIO_HEADFRAME_INFO_T* headframe_info) -{ - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - a2dp_audio_ldac_decoder_frame_t *decoder_frame_p = NULL; +int a2dp_audio_ldac_deinit(void) { - if (a2dp_audio_list_length(list)) - { - node = a2dp_audio_list_begin(list); - decoder_frame_p = (a2dp_audio_ldac_decoder_frame_t *)a2dp_audio_list_node(node); - headframe_info->sequenceNumber = decoder_frame_p->sequenceNumber; - headframe_info->timestamp = decoder_frame_p->timestamp; - headframe_info->curSubSequenceNumber = decoder_frame_p->curSubSequenceNumber; - headframe_info->totalSubSequenceNumber = decoder_frame_p->totalSubSequenceNumber; - } - else - { - memset(headframe_info, 0, sizeof(A2DP_AUDIO_HEADFRAME_INFO_T)); - } - - return A2DP_DECODER_NO_ERROR; +#ifdef A2DP_CP_ACCEL + a2dp_cp_deinit(); +#endif + a2dp_audio_ldac_decoder_deinit(); + return A2DP_DECODER_NO_ERROR; } -int a2dp_audio_ldac_convert_list_to_samples(uint32_t *samples) -{ - uint32_t list_len = 0; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; +int a2dp_audio_ldac_synchronize_packet(A2DP_AUDIO_SYNCFRAME_INFO_T *sync_info, + uint32_t mask) { + int nRet = A2DP_DECODER_SYNC_ERROR; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + int list_len; + a2dp_audio_ldac_decoder_frame_t *ldac_decoder_frame_p = NULL; - list_len = a2dp_audio_list_length(list); - *samples = LDAC_LIST_SAMPLES*list_len; + list_len = a2dp_audio_list_length(list); - TRACE(3, "%s list:%d samples:%d", __func__, list_len, *samples); + for (uint16_t i = 0; i < list_len; i++) { + node = a2dp_audio_list_begin(list); + ldac_decoder_frame_p = + (a2dp_audio_ldac_decoder_frame_t *)a2dp_audio_list_node(node); + // if (A2DP_AUDIO_SYNCFRAME_CHK(ldac_decoder_frame_p->sequenceNumber == + // sync_info->sequenceNumber, A2DP_AUDIO_SYNCFRAME_MASK_SEQ, mask)&& + // A2DP_AUDIO_SYNCFRAME_CHK(ldac_decoder_frame_p->timestamp == + // sync_info->timestamp, A2DP_AUDIO_SYNCFRAME_MASK_TIMESTAMP, + // mask)) - return A2DP_DECODER_NO_ERROR; -} - -int a2dp_audio_ldac_discards_samples(uint32_t samples) -{ - int nRet = A2DP_DECODER_SYNC_ERROR; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - a2dp_audio_ldac_decoder_frame_t *ldac_decoder_frame = NULL; - list_node_t *node = NULL; - int need_remove_list = 0; - uint32_t list_samples = 0; - ASSERT(!(samples%LDAC_LIST_SAMPLES), "%s samples err:%d", __func__, samples); - - a2dp_audio_ldac_convert_list_to_samples(&list_samples); - if (list_samples >= samples) - { - need_remove_list = samples/LDAC_LIST_SAMPLES; - for (int i=0; isequenceNumber,ldac_decoder_frame->curSubSequenceNumber,ldac_decoder_frame->totalSubSequenceNumber); - a2dp_audio_list_remove(list, ldac_decoder_frame); - } - nRet = A2DP_DECODER_NO_ERROR; + if (A2DP_AUDIO_SYNCFRAME_CHK(ldac_decoder_frame_p->sequenceNumber == + sync_info->sequenceNumber, + A2DP_AUDIO_SYNCFRAME_MASK_SEQ, mask) && + A2DP_AUDIO_SYNCFRAME_CHK(ldac_decoder_frame_p->curSubSequenceNumber == + sync_info->curSubSequenceNumber, + A2DP_AUDIO_SYNCFRAME_MASK_CURRSUBSEQ, mask) && + A2DP_AUDIO_SYNCFRAME_CHK(ldac_decoder_frame_p->totalSubSequenceNumber == + sync_info->totalSubSequenceNumber, + A2DP_AUDIO_SYNCFRAME_MASK_TOTALSUBSEQ, mask)) { + nRet = A2DP_DECODER_NO_ERROR; + break; } + a2dp_audio_list_remove(list, ldac_decoder_frame_p); + } - return nRet; + node = a2dp_audio_list_begin(list); + if (node) { + ldac_decoder_frame_p = + (a2dp_audio_ldac_decoder_frame_t *)a2dp_audio_list_node(node); + TRACE(4, "%s nRet:%d SEQ:%d timestamp:%d", __func__, nRet, + ldac_decoder_frame_p->sequenceNumber, + ldac_decoder_frame_p->timestamp); + } else { + TRACE(2, "%s nRet:%d", __func__, nRet); + // TRACE(5,"nRet:%d SEQ:%d timestamp:%d sync %d/%d", nRet, + // ldac_decoder_frame_p->sequenceNumber, + // ldac_decoder_frame_p->timestamp,sync_info->sequenceNumber,sync_info->timestamp); + } + + return nRet; } +int a2dp_audio_ldac_synchronize_dest_packet_mut(uint16_t packet_mut) { + list_node_t *node = NULL; + uint32_t list_len = 0; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + a2dp_audio_ldac_decoder_frame_t *ldac_decoder_frame_p = NULL; -A2DP_AUDIO_DECODER_T a2dp_audio_ldac_decoder_config = -{ + list_len = a2dp_audio_list_length(list); + if (list_len > packet_mut) { + do { + node = a2dp_audio_list_begin(list); + ldac_decoder_frame_p = + (a2dp_audio_ldac_decoder_frame_t *)a2dp_audio_list_node(node); + a2dp_audio_list_remove(list, ldac_decoder_frame_p); + } while (a2dp_audio_list_length(list) > packet_mut); + } + + TRACE(2, "%s list:%d", __func__, a2dp_audio_list_length(list)); + return A2DP_DECODER_NO_ERROR; +} + +static int a2dp_audio_ldac_headframe_info_get( + A2DP_AUDIO_HEADFRAME_INFO_T *headframe_info) { + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + a2dp_audio_ldac_decoder_frame_t *decoder_frame_p = NULL; + + if (a2dp_audio_list_length(list)) { + node = a2dp_audio_list_begin(list); + decoder_frame_p = + (a2dp_audio_ldac_decoder_frame_t *)a2dp_audio_list_node(node); + headframe_info->sequenceNumber = decoder_frame_p->sequenceNumber; + headframe_info->timestamp = decoder_frame_p->timestamp; + headframe_info->curSubSequenceNumber = + decoder_frame_p->curSubSequenceNumber; + headframe_info->totalSubSequenceNumber = + decoder_frame_p->totalSubSequenceNumber; + } else { + memset(headframe_info, 0, sizeof(A2DP_AUDIO_HEADFRAME_INFO_T)); + } + + return A2DP_DECODER_NO_ERROR; +} + +int a2dp_audio_ldac_convert_list_to_samples(uint32_t *samples) { + uint32_t list_len = 0; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + + list_len = a2dp_audio_list_length(list); + *samples = LDAC_LIST_SAMPLES * list_len; + + TRACE(3, "%s list:%d samples:%d", __func__, list_len, *samples); + + return A2DP_DECODER_NO_ERROR; +} + +int a2dp_audio_ldac_discards_samples(uint32_t samples) { + int nRet = A2DP_DECODER_SYNC_ERROR; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + a2dp_audio_ldac_decoder_frame_t *ldac_decoder_frame = NULL; + list_node_t *node = NULL; + int need_remove_list = 0; + uint32_t list_samples = 0; + ASSERT(!(samples % LDAC_LIST_SAMPLES), "%s samples err:%d", __func__, + samples); + + a2dp_audio_ldac_convert_list_to_samples(&list_samples); + if (list_samples >= samples) { + need_remove_list = samples / LDAC_LIST_SAMPLES; + for (int i = 0; i < need_remove_list; i++) { + node = a2dp_audio_list_begin(list); + ldac_decoder_frame = + (a2dp_audio_ldac_decoder_frame_t *)a2dp_audio_list_node(node); + + TRACE(1, "discard seq:%d %d %d", ldac_decoder_frame->sequenceNumber, + ldac_decoder_frame->curSubSequenceNumber, + ldac_decoder_frame->totalSubSequenceNumber); + a2dp_audio_list_remove(list, ldac_decoder_frame); + } + nRet = A2DP_DECODER_NO_ERROR; + } + + return nRet; +} + +A2DP_AUDIO_DECODER_T a2dp_audio_ldac_decoder_config = { {96000, 2, 16}, 0, a2dp_audio_ldac_init, @@ -1114,4 +1056,3 @@ A2DP_AUDIO_DECODER_T a2dp_audio_ldac_decoder_config = a2dp_audio_ldac_info_get, a2dp_audio_ldac_free, }; - diff --git a/apps/audioplayers/a2dp_decoder/a2dp_decoder_lhdc.cpp b/apps/audioplayers/a2dp_decoder/a2dp_decoder_lhdc.cpp index 7b50ef1..1bc0d87 100644 --- a/apps/audioplayers/a2dp_decoder/a2dp_decoder_lhdc.cpp +++ b/apps/audioplayers/a2dp_decoder/a2dp_decoder_lhdc.cpp @@ -14,22 +14,21 @@ * ****************************************************************************/ // Standard C Included Files +#include "a2dp_decoder_internal.h" #include "cmsis.h" -#include "plat_types.h" -#include -#include "heap_api.h" #include "hal_location.h" #include "hal_timer.h" -#include "a2dp_decoder_internal.h" +#include "heap_api.h" +#include "plat_types.h" +#include -typedef struct -{ - uint16_t sequenceNumber; - uint32_t timestamp; - uint16_t curSubSequenceNumber; - uint16_t totalSubSequenceNumber; - uint8_t *buffer; - uint32_t buffer_len; +typedef struct { + uint16_t sequenceNumber; + uint32_t timestamp; + uint16_t curSubSequenceNumber; + uint16_t totalSubSequenceNumber; + uint8_t *buffer; + uint32_t buffer_len; } a2dp_audio_lhdc_decoder_frame_t; #define LHDC_MTU_LIMITER (100) @@ -42,9 +41,9 @@ typedef struct #define A2DP_LHDC_DEFAULT_LATENCY (1) #if defined(A2DP_LHDC_V3) -#define PACKET_BUFFER_LENGTH (2 * 1024) +#define PACKET_BUFFER_LENGTH (2 * 1024) #else -#define PACKET_BUFFER_LENGTH (4 * 1024) +#define PACKET_BUFFER_LENGTH (4 * 1024) #endif #define LHDC_READBUF_SIZE (512) @@ -52,12 +51,14 @@ typedef struct #define A2DP_LHDC_HDR_F_MSK 0x80 #define A2DP_LHDC_HDR_S_MSK 0x40 #define A2DP_LHDC_HDR_L_MSK 0x20 -#define A2DP_LHDC_HDR_FLAG_MSK (A2DP_LHDC_HDR_F_MSK | A2DP_LHDC_HDR_S_MSK | A2DP_LHDC_HDR_L_MSK) +#define A2DP_LHDC_HDR_FLAG_MSK \ + (A2DP_LHDC_HDR_F_MSK | A2DP_LHDC_HDR_S_MSK | A2DP_LHDC_HDR_L_MSK) -#define A2DP_LHDC_HDR_LATENCY_LOW 0x00 -#define A2DP_LHDC_HDR_LATENCY_MID 0x01 -#define A2DP_LHDC_HDR_LATENCY_HIGH 0x02 -#define A2DP_LHDC_HDR_LATENCY_MASK (A2DP_LHDC_HDR_LATENCY_MID | A2DP_LHDC_HDR_LATENCY_HIGH) +#define A2DP_LHDC_HDR_LATENCY_LOW 0x00 +#define A2DP_LHDC_HDR_LATENCY_MID 0x01 +#define A2DP_LHDC_HDR_LATENCY_HIGH 0x02 +#define A2DP_LHDC_HDR_LATENCY_MASK \ + (A2DP_LHDC_HDR_LATENCY_MID | A2DP_LHDC_HDR_LATENCY_HIGH) #if defined(A2DP_LHDC_V3) #define A2DP_LHDC_HDR_FRAME_NO_MASK 0xfc @@ -65,17 +66,12 @@ typedef struct #define A2DP_LHDC_HDR_FRAME_NO_MASK 0x1c #endif -typedef enum -{ - ASM_PKT_WAT_STR, - ASM_PKT_WAT_LST, +typedef enum { + ASM_PKT_WAT_STR, + ASM_PKT_WAT_LST, } ASM_PKT_STATUS; -typedef enum -{ - VERSION_2 = 200, - VERSION_3 = 300 -} lhdc_ver_t; +typedef enum { VERSION_2 = 200, VERSION_3 = 300 } lhdc_ver_t; /** * get lhdc frame header @@ -84,59 +80,57 @@ typedef enum /** LHDC frame */ -typedef struct _lhdc_frame_Info -{ - uint32_t frame_len; // 该 frame 的长处,若是分离压缩,则表示å•ä¸€å£°é“çš„ frame 长度。 - uint32_t isSplit; // 是å¦ä¸ºåˆ†ç¦»æ–¹å¼åŽ‹ç¼© - uint32_t isLeft; // å·¦å£°é“ == true, å³å£°é“ == false +typedef struct _lhdc_frame_Info { + uint32_t + frame_len; // 该 frame 的长处,若是分离压缩,则表示å•ä¸€å£°é“çš„ frame 长度。 + uint32_t isSplit; // 是å¦ä¸ºåˆ†ç¦»æ–¹å¼åŽ‹ç¼© + uint32_t isLeft; // å·¦å£°é“ == true, å³å£°é“ == false } lhdc_frame_Info_t; #ifdef A2DP_CP_ACCEL -struct A2DP_CP_LHDC_IN_FRM_INFO_T -{ - uint16_t sequenceNumber; - uint32_t timestamp; - uint16_t curSubSequenceNumber; - uint16_t totalSubSequenceNumber; +struct A2DP_CP_LHDC_IN_FRM_INFO_T { + uint16_t sequenceNumber; + uint32_t timestamp; + uint16_t curSubSequenceNumber; + uint16_t totalSubSequenceNumber; }; -struct A2DP_CP_LHDC_OUT_FRM_INFO_T -{ - struct A2DP_CP_LHDC_IN_FRM_INFO_T in_info; - uint16_t frame_samples; - uint16_t decoded_frames; - uint16_t frame_idx; - uint16_t pcm_len; +struct A2DP_CP_LHDC_OUT_FRM_INFO_T { + struct A2DP_CP_LHDC_IN_FRM_INFO_T in_info; + uint16_t frame_samples; + uint16_t decoded_frames; + uint16_t frame_idx; + uint16_t pcm_len; }; #endif -extern "C" -{ - typedef struct bes_bt_local_info_t - { - uint8_t bt_addr[BTIF_BD_ADDR_SIZE]; - const char *bt_name; - uint8_t bt_len; - uint8_t ble_addr[BTIF_BD_ADDR_SIZE]; - const char *ble_name; - uint8_t ble_len; - } bes_bt_local_info; +extern "C" { +typedef struct bes_bt_local_info_t { + uint8_t bt_addr[BTIF_BD_ADDR_SIZE]; + const char *bt_name; + uint8_t bt_len; + uint8_t ble_addr[BTIF_BD_ADDR_SIZE]; + const char *ble_name; + uint8_t ble_len; +} bes_bt_local_info; - typedef int (*LHDC_GET_BT_INFO)(bes_bt_local_info *bt_info); +typedef int (*LHDC_GET_BT_INFO)(bes_bt_local_info *bt_info); - void lhdcInit(uint32_t bitPerSample, uint32_t sampleRate, uint32_t scaleTo16Bits, lhdc_ver_t version); - //void lhdcInit(uint32_t bitPerSample, uint32_t sampleRate, uint32_t scaleTo16Bits); +void lhdcInit(uint32_t bitPerSample, uint32_t sampleRate, + uint32_t scaleTo16Bits, lhdc_ver_t version); +// void lhdcInit(uint32_t bitPerSample, uint32_t sampleRate, uint32_t +// scaleTo16Bits); #if defined(A2DP_LHDC_V3) - uint32_t lhdcPutData(uint8_t *pIn, uint32_t len); +uint32_t lhdcPutData(uint8_t *pIn, uint32_t len); #else - uint32_t lhdcPutData(uint8_t *pIn, int32_t len); +uint32_t lhdcPutData(uint8_t *pIn, int32_t len); #endif - uint32_t lhdcDecodeProcess(uint8_t *pOutBuf); - void lhdcDestroy(); - bool lhdcSetLicenseKeyTable(uint8_t *licTable, LHDC_GET_BT_INFO pFunc); - const char *getVersionCode(); - bool larcIsEnabled(); +uint32_t lhdcDecodeProcess(uint8_t *pOutBuf); +void lhdcDestroy(); +bool lhdcSetLicenseKeyTable(uint8_t *licTable, LHDC_GET_BT_INFO pFunc); +const char *getVersionCode(); +bool larcIsEnabled(); } static A2DP_AUDIO_CONTEXT_T *a2dp_audio_context_p = NULL; @@ -155,270 +149,244 @@ static uint32_t lhdc_total_frame_nb = 0; static uint32_t lhdc_drop_frame = 0; static uint32_t lhdc_last_time = 0; static struct A2DP_CP_LHDC_IN_FRM_INFO_T last_frame_info; -//static uint16_t demo_frame_cnt = 0; +// static uint16_t demo_frame_cnt = 0; #endif - extern int bes_bt_local_info_get(bes_bt_local_info *local_info); -//Local API declare +// Local API declare void sav_lhdc_log_bytes_len(uint32_t bytes_len); -#define STATISTICS_UPDATE_INTERVAL 1000 // in ms -#define INTERVAL_TIMEBASE 1000 //in ms -typedef struct -{ - uint32_t sum_bytes; - uint32_t last_times; //in ms - float last_avg_val; - int32_t update_interval; //in ms +#define STATISTICS_UPDATE_INTERVAL 1000 // in ms +#define INTERVAL_TIMEBASE 1000 // in ms +typedef struct { + uint32_t sum_bytes; + uint32_t last_times; // in ms + float last_avg_val; + int32_t update_interval; // in ms } LHDC_TRACFIC_STATISTICS; LHDC_TRACFIC_STATISTICS statistic = {0, 0, 0, STATISTICS_UPDATE_INTERVAL}; -void sav_lhdc_log_bytes_len(uint32_t bytes_len) -{ - uint32_t time_current = GET_CURRENT_MS(); - float time_diff = time_current - statistic.last_times; - statistic.sum_bytes += bytes_len; - if (time_diff >= statistic.update_interval) - { +void sav_lhdc_log_bytes_len(uint32_t bytes_len) { + uint32_t time_current = GET_CURRENT_MS(); + float time_diff = time_current - statistic.last_times; + statistic.sum_bytes += bytes_len; + if (time_diff >= statistic.update_interval) { - statistic.last_avg_val = ((float)(statistic.sum_bytes * 8) / 1000) / (time_diff / INTERVAL_TIMEBASE); - TRACE_A2DP_DECODER_I("Avarage rate about %d kbps", (int)statistic.last_avg_val); + statistic.last_avg_val = ((float)(statistic.sum_bytes * 8) / 1000) / + (time_diff / INTERVAL_TIMEBASE); + TRACE_A2DP_DECODER_I("Avarage rate about %d kbps", + (int)statistic.last_avg_val); - statistic.sum_bytes = 0; - statistic.last_times = time_current; - } + statistic.sum_bytes = 0; + statistic.last_times = time_current; + } } #if defined(A2DP_LHDC_LARC) && defined(A2DP_LHDC_V3) -static void sav_lhdc_save_last_info(struct A2DP_CP_LHDC_IN_FRM_INFO_T *f_info) -{ +static void sav_lhdc_save_last_info(struct A2DP_CP_LHDC_IN_FRM_INFO_T *f_info) { - memcpy(&last_frame_info, f_info, sizeof(struct A2DP_CP_LHDC_IN_FRM_INFO_T)); + memcpy(&last_frame_info, f_info, sizeof(struct A2DP_CP_LHDC_IN_FRM_INFO_T)); } -static void sav_lhdc_get_next_info(struct A2DP_CP_LHDC_IN_FRM_INFO_T *f_info) -{ - f_info->timestamp = last_frame_info.timestamp; - f_info->sequenceNumber = last_frame_info.sequenceNumber; - f_info->totalSubSequenceNumber = last_frame_info.totalSubSequenceNumber; - f_info->curSubSequenceNumber = last_frame_info.curSubSequenceNumber + 1; - if (f_info->curSubSequenceNumber > last_frame_info.totalSubSequenceNumber) - { - f_info->curSubSequenceNumber = 1; - f_info->timestamp = last_frame_info.timestamp + (A2DP_LHDC_OUTPUT_FRAME_SAMPLES * last_frame_info.totalSubSequenceNumber); - f_info->sequenceNumber = last_frame_info.sequenceNumber + 1; - } +static void sav_lhdc_get_next_info(struct A2DP_CP_LHDC_IN_FRM_INFO_T *f_info) { + f_info->timestamp = last_frame_info.timestamp; + f_info->sequenceNumber = last_frame_info.sequenceNumber; + f_info->totalSubSequenceNumber = last_frame_info.totalSubSequenceNumber; + f_info->curSubSequenceNumber = last_frame_info.curSubSequenceNumber + 1; + if (f_info->curSubSequenceNumber > last_frame_info.totalSubSequenceNumber) { + f_info->curSubSequenceNumber = 1; + f_info->timestamp = + last_frame_info.timestamp + (A2DP_LHDC_OUTPUT_FRAME_SAMPLES * + last_frame_info.totalSubSequenceNumber); + f_info->sequenceNumber = last_frame_info.sequenceNumber + 1; + } } #endif -static void *a2dp_audio_lhdc_frame_malloc(uint32_t packet_len) -{ - a2dp_audio_lhdc_decoder_frame_t *decoder_frame_p = NULL; - uint8_t *buffer = NULL; +static void *a2dp_audio_lhdc_frame_malloc(uint32_t packet_len) { + a2dp_audio_lhdc_decoder_frame_t *decoder_frame_p = NULL; + uint8_t *buffer = NULL; - buffer = (uint8_t *)a2dp_audio_heap_malloc(packet_len); - decoder_frame_p = (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_heap_malloc(sizeof(a2dp_audio_lhdc_decoder_frame_t)); - decoder_frame_p->buffer = buffer; - decoder_frame_p->buffer_len = packet_len; - return (void *)decoder_frame_p; + buffer = (uint8_t *)a2dp_audio_heap_malloc(packet_len); + decoder_frame_p = (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_heap_malloc( + sizeof(a2dp_audio_lhdc_decoder_frame_t)); + decoder_frame_p->buffer = buffer; + decoder_frame_p->buffer_len = packet_len; + return (void *)decoder_frame_p; } -static void reset_lhdc_assmeble_packet(void) -{ - is_synced = false; - asm_pkt_st = ASM_PKT_WAT_STR; - packet_buf_len = 0; +static void reset_lhdc_assmeble_packet(void) { + is_synced = false; + asm_pkt_st = ASM_PKT_WAT_STR; + packet_buf_len = 0; } -static void initial_lhdc_assemble_packet(bool splitFlg) -{ - memset(packet_buffer, 0, PACKET_BUFFER_LENGTH); - reset_lhdc_assmeble_packet(); - serial_no = 0xff; +static void initial_lhdc_assemble_packet(bool splitFlg) { + memset(packet_buffer, 0, PACKET_BUFFER_LENGTH); + reset_lhdc_assmeble_packet(); + serial_no = 0xff; } /** * A2DP packet 组包 */ #if defined(A2DP_LHDC_V3) -int assemble_lhdc_packet(uint8_t *input, uint32_t input_len, uint8_t **pLout, uint32_t *pLlen) -{ - uint8_t hdr = 0, seqno = 0xff; - int ret = -1; - uint32_t status = 0; +int assemble_lhdc_packet(uint8_t *input, uint32_t input_len, uint8_t **pLout, + uint32_t *pLlen) { + uint8_t hdr = 0, seqno = 0xff; + int ret = -1; + uint32_t status = 0; - hdr = (*input); - input++; - seqno = (*input); - input++; - input_len -= 2; + hdr = (*input); + input++; + seqno = (*input); + input++; + input_len -= 2; - //Check latency and update value when changed. - status = hdr & A2DP_LHDC_HDR_LATENCY_MASK; + // Check latency and update value when changed. + status = hdr & A2DP_LHDC_HDR_LATENCY_MASK; - //Get number of frame in packet. - status = (hdr & A2DP_LHDC_HDR_FRAME_NO_MASK) >> 2; - if (status <= 0) - { - TRACE_A2DP_DECODER_I("No any frame in packet."); - return 0; - } - lhdc_total_frame_nb = status; - if (seqno != serial_no) - { - TRACE_A2DP_DECODER_I("Packet lost! now(%d), expect(%d)", seqno, serial_no); - } - serial_no = seqno + 1; + // Get number of frame in packet. + status = (hdr & A2DP_LHDC_HDR_FRAME_NO_MASK) >> 2; + if (status <= 0) { + TRACE_A2DP_DECODER_I("No any frame in packet."); + return 0; + } + lhdc_total_frame_nb = status; + if (seqno != serial_no) { + TRACE_A2DP_DECODER_I("Packet lost! now(%d), expect(%d)", seqno, serial_no); + } + serial_no = seqno + 1; - sav_lhdc_log_bytes_len(input_len); + sav_lhdc_log_bytes_len(input_len); - if (pLlen && pLout) - { - *pLlen = input_len; - *pLout = input; - } - ret = lhdc_total_frame_nb; + if (pLlen && pLout) { + *pLlen = input_len; + *pLout = input; + } + ret = lhdc_total_frame_nb; - return ret; + return ret; } #else -int assemble_lhdc_packet(uint8_t *input, uint32_t input_len, uint8_t **pLout, uint32_t *pLlen) -{ - uint8_t hdr = 0, seqno = 0xff; - int ret = -1; - //uint32_t status = 0; +int assemble_lhdc_packet(uint8_t *input, uint32_t input_len, uint8_t **pLout, + uint32_t *pLlen) { + uint8_t hdr = 0, seqno = 0xff; + int ret = -1; + // uint32_t status = 0; - hdr = (*input); - input++; - seqno = (*input); - input++; - input_len -= 2; + hdr = (*input); + input++; + seqno = (*input); + input++; + input_len -= 2; - if (is_synced) - { - if (seqno != serial_no) - { - reset_lhdc_assmeble_packet(); - if ((hdr & A2DP_LHDC_HDR_FLAG_MSK) == 0 || - (hdr & A2DP_LHDC_HDR_S_MSK) != 0) - { - goto lhdc_start; - } - else - TRACE_A2DP_DECODER_I("drop packet No. %u", seqno); - return 0; - } - serial_no = seqno + 1; + if (is_synced) { + if (seqno != serial_no) { + reset_lhdc_assmeble_packet(); + if ((hdr & A2DP_LHDC_HDR_FLAG_MSK) == 0 || + (hdr & A2DP_LHDC_HDR_S_MSK) != 0) { + goto lhdc_start; + } else + TRACE_A2DP_DECODER_I("drop packet No. %u", seqno); + return 0; } + serial_no = seqno + 1; + } lhdc_start: - switch (asm_pkt_st) - { - case ASM_PKT_WAT_STR: - { - if ((hdr & A2DP_LHDC_HDR_FLAG_MSK) == 0) - { - memcpy(&packet_buffer[0], input, input_len); - if (pLlen && pLout) - { - *pLlen = input_len; - *pLout = packet_buffer; - } - //TRACE_A2DP_DECODER_I("Single payload size = %d", *pLlen); - asm_pkt_st = ASM_PKT_WAT_STR; - packet_buf_len = 0; //= packet_buf_left_len = packet_buf_right_len = 0; - lhdc_total_frame_nb = (hdr & A2DP_LHDC_HDR_FRAME_NO_MASK) >> 2; - ; - //TRACE_A2DP_DECODER_I("Single packet. total %d frames", lhdc_total_frame_nb); - ret = lhdc_total_frame_nb; - } - else if (hdr & A2DP_LHDC_HDR_S_MSK) - { - ret = 0; - if (packet_buf_len + input_len >= PACKET_BUFFER_LENGTH) - { - packet_buf_len = 0; - asm_pkt_st = ASM_PKT_WAT_STR; - TRACE_A2DP_DECODER_I("ASM_PKT_WAT_STR:Frame buffer overflow!(%d)", packet_buf_len); - break; - } - memcpy(&packet_buffer, input, input_len); - packet_buf_len = input_len; - asm_pkt_st = ASM_PKT_WAT_LST; - lhdc_total_frame_nb = (hdr & A2DP_LHDC_HDR_FRAME_NO_MASK) >> 2; - //TRACE_A2DP_DECODER_I("start of multi packet."); - } - else - ret = -1; - - if (ret >= 0) - { - if (!is_synced) - { - is_synced = true; - serial_no = seqno + 1; - } - } + switch (asm_pkt_st) { + case ASM_PKT_WAT_STR: { + if ((hdr & A2DP_LHDC_HDR_FLAG_MSK) == 0) { + memcpy(&packet_buffer[0], input, input_len); + if (pLlen && pLout) { + *pLlen = input_len; + *pLout = packet_buffer; + } + // TRACE_A2DP_DECODER_I("Single payload size = %d", *pLlen); + asm_pkt_st = ASM_PKT_WAT_STR; + packet_buf_len = 0; //= packet_buf_left_len = packet_buf_right_len = 0; + lhdc_total_frame_nb = (hdr & A2DP_LHDC_HDR_FRAME_NO_MASK) >> 2; + ; + // TRACE_A2DP_DECODER_I("Single packet. total %d frames", + // lhdc_total_frame_nb); + ret = lhdc_total_frame_nb; + } else if (hdr & A2DP_LHDC_HDR_S_MSK) { + ret = 0; + if (packet_buf_len + input_len >= PACKET_BUFFER_LENGTH) { + packet_buf_len = 0; + asm_pkt_st = ASM_PKT_WAT_STR; + TRACE_A2DP_DECODER_I("ASM_PKT_WAT_STR:Frame buffer overflow!(%d)", + packet_buf_len); break; - } - case ASM_PKT_WAT_LST: - { - if (packet_buf_len + input_len >= PACKET_BUFFER_LENGTH) - { - packet_buf_len = 0; - asm_pkt_st = ASM_PKT_WAT_STR; - TRACE_A2DP_DECODER_I("ASM_PKT_WAT_LST:Frame buffer overflow(%d)", packet_buf_len); - break; - } - memcpy(&packet_buffer[packet_buf_len], input, input_len); - //TRACE_A2DP_DECODER_I("multi:payload size = %d", input_len); - packet_buf_len += input_len; - ret = 0; + } + memcpy(&packet_buffer, input, input_len); + packet_buf_len = input_len; + asm_pkt_st = ASM_PKT_WAT_LST; + lhdc_total_frame_nb = (hdr & A2DP_LHDC_HDR_FRAME_NO_MASK) >> 2; + // TRACE_A2DP_DECODER_I("start of multi packet."); + } else + ret = -1; - if (hdr & A2DP_LHDC_HDR_L_MSK) - { + if (ret >= 0) { + if (!is_synced) { + is_synced = true; + serial_no = seqno + 1; + } + } + break; + } + case ASM_PKT_WAT_LST: { + if (packet_buf_len + input_len >= PACKET_BUFFER_LENGTH) { + packet_buf_len = 0; + asm_pkt_st = ASM_PKT_WAT_STR; + TRACE_A2DP_DECODER_I("ASM_PKT_WAT_LST:Frame buffer overflow(%d)", + packet_buf_len); + break; + } + memcpy(&packet_buffer[packet_buf_len], input, input_len); + // TRACE_A2DP_DECODER_I("multi:payload size = %d", input_len); + packet_buf_len += input_len; + ret = 0; - if (pLlen && pLout) - { - *pLlen = packet_buf_len; - *pLout = packet_buffer; - } - //TRACE_A2DP_DECODER_I("end of multi packet. total %d frames.", lhdc_total_frame_nb); - packet_buf_len = 0; //packet_buf_left_len = packet_buf_right_len = 0; - ret = lhdc_total_frame_nb; - asm_pkt_st = ASM_PKT_WAT_STR; - } - break; + if (hdr & A2DP_LHDC_HDR_L_MSK) { + + if (pLlen && pLout) { + *pLlen = packet_buf_len; + *pLout = packet_buffer; + } + // TRACE_A2DP_DECODER_I("end of multi packet. total %d frames.", + // lhdc_total_frame_nb); + packet_buf_len = 0; // packet_buf_left_len = packet_buf_right_len = 0; + ret = lhdc_total_frame_nb; + asm_pkt_st = ASM_PKT_WAT_STR; } - default: - ret = 0; - break; - } - return ret; + break; + } + default: + ret = 0; + break; + } + return ret; } #endif -static int parse_lhdc_info(uint8_t *in, lhdc_frame_Info_t *h) -{ +static int parse_lhdc_info(uint8_t *in, lhdc_frame_Info_t *h) { #define LHDC_HDR_LEN 4 - uint32_t hdr = 0; - int ret = -1; - memcpy(&hdr, in, LHDC_HDR_LEN); - h->frame_len = (int)((hdr >> 8) & 0x1fff); - h->isSplit = ((hdr & 0x00600000) == 0x00600000); - h->isLeft = ((hdr & 0xf) == 0); + uint32_t hdr = 0; + int ret = -1; + memcpy(&hdr, in, LHDC_HDR_LEN); + h->frame_len = (int)((hdr >> 8) & 0x1fff); + h->isSplit = ((hdr & 0x00600000) == 0x00600000); + h->isLeft = ((hdr & 0xf) == 0); - if ((hdr & 0xff000000) != 0x4c000000) - { - } - else - { - ret = 0; - } - return ret; + if ((hdr & 0xff000000) != 0x4c000000) { + } else { + ret = 0; + } + return ret; } #ifdef A2DP_CP_ACCEL @@ -430,570 +398,573 @@ extern uint32_t app_bt_stream_get_dma_buffer_samples(void); int a2dp_cp_lhdc_cp_decode(void); TEXT_LHDC_LOC -static int a2dp_cp_lhdc_after_cache_underflow(void) -{ - int ret = 0; +static int a2dp_cp_lhdc_after_cache_underflow(void) { + int ret = 0; #ifdef A2DP_CP_ACCEL - a2dp_cp_deinit(); - lhdcDestroy(); - ret = a2dp_cp_init(a2dp_cp_lhdc_cp_decode, CP_PROC_DELAY_2_FRAMES); - ASSERT(ret == 0, "%s: a2dp_cp_init() failed: ret=%d", __func__, ret); + a2dp_cp_deinit(); + lhdcDestroy(); + ret = a2dp_cp_init(a2dp_cp_lhdc_cp_decode, CP_PROC_DELAY_2_FRAMES); + ASSERT(ret == 0, "%s: a2dp_cp_init() failed: ret=%d", __func__, ret); #endif - return ret; + return ret; } -//uint32_t demoTimer = 0; -static int a2dp_cp_lhdc_mcu_decode(uint8_t *buffer, uint32_t buffer_bytes) -{ - a2dp_audio_lhdc_decoder_frame_t *lhdc_decoder_frame_p = NULL; - list_node_t *node = NULL; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - int ret, dec_ret; - struct A2DP_CP_LHDC_IN_FRM_INFO_T in_info; - struct A2DP_CP_LHDC_OUT_FRM_INFO_T *p_out_info; +// uint32_t demoTimer = 0; +static int a2dp_cp_lhdc_mcu_decode(uint8_t *buffer, uint32_t buffer_bytes) { + a2dp_audio_lhdc_decoder_frame_t *lhdc_decoder_frame_p = NULL; + list_node_t *node = NULL; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + int ret, dec_ret; + struct A2DP_CP_LHDC_IN_FRM_INFO_T in_info; + struct A2DP_CP_LHDC_OUT_FRM_INFO_T *p_out_info; - uint8_t *out; - uint32_t out_len; - uint32_t out_frame_len; - uint32_t cp_buffer_frames_max = 0; + uint8_t *out; + uint32_t out_len; + uint32_t out_frame_len; + uint32_t cp_buffer_frames_max = 0; #if defined(A2DP_LHDC_LARC) - //bool forceRecovery = false; - bool larcEnabled = larcIsEnabled(); - uint32_t frame_number = 0; + // bool forceRecovery = false; + bool larcEnabled = larcIsEnabled(); + uint32_t frame_number = 0; - if (larcEnabled) - { - /* The LARC is enabled. */ + if (larcEnabled) { + /* The LARC is enabled. */ - uint32_t time_diff = 0, time_now = GET_CURRENT_MS(); + uint32_t time_diff = 0, time_now = GET_CURRENT_MS(); - if (lhdc_last_time == 0) - { - lhdc_last_time = time_now; - } - // if (demoTimer == 0) { - // demoTimer = time_now; - // } - time_diff = time_now - lhdc_last_time; - lhdc_last_time = time_now; - - frame_number = (uint32_t)((float)time_diff / ((A2DP_LHDC_OUTPUT_FRAME_SAMPLES * 1000) / a2dp_audio_lhdc_output_config.sample_rate)); - - TRACE_A2DP_DECODER_I("%s:current total list len %d, need frames %d", __func__, a2dp_audio_list_length(list) + get_in_cp_frame_cnt(), frame_number); - // if (time_now - demoTimer >= (5 * 1000)) { - // forceRecovery = true; - // demoTimer = time_now; - // demo_frame_cnt = (a2dp_audio_lhdc_output_config.sample_rate * 120) / (A2DP_LHDC_OUTPUT_FRAME_SAMPLES * 1000); - // } + if (lhdc_last_time == 0) { + lhdc_last_time = time_now; } + // if (demoTimer == 0) { + // demoTimer = time_now; + // } + time_diff = time_now - lhdc_last_time; + lhdc_last_time = time_now; + + frame_number = (uint32_t)((float)time_diff / + ((A2DP_LHDC_OUTPUT_FRAME_SAMPLES * 1000) / + a2dp_audio_lhdc_output_config.sample_rate)); + + TRACE_A2DP_DECODER_I( + "%s:current total list len %d, need frames %d", __func__, + a2dp_audio_list_length(list) + get_in_cp_frame_cnt(), frame_number); + // if (time_now - demoTimer >= (5 * 1000)) { + // forceRecovery = true; + // demoTimer = time_now; + // demo_frame_cnt = (a2dp_audio_lhdc_output_config.sample_rate * 120) / + // (A2DP_LHDC_OUTPUT_FRAME_SAMPLES * 1000); + // } + } #endif - cp_buffer_frames_max = app_bt_stream_get_dma_buffer_samples() / 2; + cp_buffer_frames_max = app_bt_stream_get_dma_buffer_samples() / 2; - if (cp_buffer_frames_max % (a2dp_audio_lhdc_lastframe_info.frame_samples)) - { - cp_buffer_frames_max = cp_buffer_frames_max / (a2dp_audio_lhdc_lastframe_info.frame_samples) + 1; - } - else - { - cp_buffer_frames_max = cp_buffer_frames_max / (a2dp_audio_lhdc_lastframe_info.frame_samples); - } + if (cp_buffer_frames_max % (a2dp_audio_lhdc_lastframe_info.frame_samples)) { + cp_buffer_frames_max = + cp_buffer_frames_max / (a2dp_audio_lhdc_lastframe_info.frame_samples) + + 1; + } else { + cp_buffer_frames_max = + cp_buffer_frames_max / (a2dp_audio_lhdc_lastframe_info.frame_samples); + } - out_frame_len = sizeof(*p_out_info) + buffer_bytes; + out_frame_len = sizeof(*p_out_info) + buffer_bytes; - ret = a2dp_cp_decoder_init(out_frame_len, cp_buffer_frames_max * 8); - if (ret) - { - TRACE_A2DP_DECODER_I("%s: a2dp_cp_decoder_init() failed: ret=%d", __func__, ret); - set_cp_reset_flag(true); - return A2DP_DECODER_DECODE_ERROR; - } + ret = a2dp_cp_decoder_init(out_frame_len, cp_buffer_frames_max * 8); + if (ret) { + TRACE_A2DP_DECODER_I("%s: a2dp_cp_decoder_init() failed: ret=%d", __func__, + ret); + set_cp_reset_flag(true); + return A2DP_DECODER_DECODE_ERROR; + } #if defined(A2DP_LHDC_LARC) - uint32_t put_cnt = 0; - uint32_t drop_cnt = 0; - while (larcEnabled && - ((a2dp_audio_list_length(list) < frame_number && get_in_cp_frame_cnt() == 0))) - { - sav_lhdc_get_next_info(&in_info); - ret = a2dp_cp_put_in_frame(&in_info, sizeof(in_info), NULL, 0x55); - if (ret) - { - //TRACE_A2DP_DECODER_I("%s piff !!!!!!ret: %d ",__func__, ret); - break; - } - sav_lhdc_save_last_info(&in_info); - lhdc_drop_frame++; - frame_number--; - //demo_frame_cnt--; - put_cnt++; + uint32_t put_cnt = 0; + uint32_t drop_cnt = 0; + while (larcEnabled && ((a2dp_audio_list_length(list) < frame_number && + get_in_cp_frame_cnt() == 0))) { + sav_lhdc_get_next_info(&in_info); + ret = a2dp_cp_put_in_frame(&in_info, sizeof(in_info), NULL, 0x55); + if (ret) { + // TRACE_A2DP_DECODER_I("%s piff !!!!!!ret: %d ",__func__, ret); + break; } - //forceRecovery = false; - TRACE_A2DP_DECODER_I("Recover %d frames", put_cnt); - put_cnt = 0; - drop_cnt = 0; + sav_lhdc_save_last_info(&in_info); + lhdc_drop_frame++; + frame_number--; + // demo_frame_cnt--; + put_cnt++; + } + // forceRecovery = false; + TRACE_A2DP_DECODER_I("Recover %d frames", put_cnt); + put_cnt = 0; + drop_cnt = 0; #endif - while ((node = a2dp_audio_list_begin(list)) != NULL) - { - lhdc_decoder_frame_p = (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_list_node(node); - in_info.sequenceNumber = lhdc_decoder_frame_p->sequenceNumber; - in_info.timestamp = lhdc_decoder_frame_p->timestamp; - in_info.curSubSequenceNumber = lhdc_decoder_frame_p->curSubSequenceNumber; - in_info.totalSubSequenceNumber = lhdc_decoder_frame_p->totalSubSequenceNumber; + while ((node = a2dp_audio_list_begin(list)) != NULL) { + lhdc_decoder_frame_p = + (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_list_node(node); + in_info.sequenceNumber = lhdc_decoder_frame_p->sequenceNumber; + in_info.timestamp = lhdc_decoder_frame_p->timestamp; + in_info.curSubSequenceNumber = lhdc_decoder_frame_p->curSubSequenceNumber; + in_info.totalSubSequenceNumber = + lhdc_decoder_frame_p->totalSubSequenceNumber; #if defined(A2DP_LHDC_LARC) - if (!lhdc_drop_frame) - { - ret = a2dp_cp_put_in_frame(&in_info, sizeof(in_info), lhdc_decoder_frame_p->buffer, lhdc_decoder_frame_p->buffer_len); - if (ret) - { - //TRACE_A2DP_DECODER_I("%s piff !!!!!!ret: %d ",__func__, ret); - break; - } - sav_lhdc_save_last_info(&in_info); - put_cnt++; - } - else - { - lhdc_drop_frame--; - drop_cnt++; - } + if (!lhdc_drop_frame) { + ret = a2dp_cp_put_in_frame(&in_info, sizeof(in_info), + lhdc_decoder_frame_p->buffer, + lhdc_decoder_frame_p->buffer_len); + if (ret) { + // TRACE_A2DP_DECODER_I("%s piff !!!!!!ret: %d ",__func__, ret); + break; + } + sav_lhdc_save_last_info(&in_info); + put_cnt++; + } else { + lhdc_drop_frame--; + drop_cnt++; + } #else - ret = a2dp_cp_put_in_frame(&in_info, sizeof(in_info), lhdc_decoder_frame_p->buffer, lhdc_decoder_frame_p->buffer_len); - if (ret) - { - //TRACE_A2DP_DECODER_I("%s piff !!!!!!ret: %d ",__func__, ret); - break; - } -#endif - a2dp_audio_list_remove(list, lhdc_decoder_frame_p); - node = a2dp_audio_list_begin(list); + ret = a2dp_cp_put_in_frame(&in_info, sizeof(in_info), + lhdc_decoder_frame_p->buffer, + lhdc_decoder_frame_p->buffer_len); + if (ret) { + // TRACE_A2DP_DECODER_I("%s piff !!!!!!ret: %d ",__func__, ret); + break; } +#endif + a2dp_audio_list_remove(list, lhdc_decoder_frame_p); + node = a2dp_audio_list_begin(list); + } #if defined(A2DP_LHDC_LARC) - TRACE_A2DP_DECODER_I("Put %d frames, drop %d frames", put_cnt, drop_cnt); + TRACE_A2DP_DECODER_I("Put %d frames, drop %d frames", put_cnt, drop_cnt); #endif - ret = a2dp_cp_get_full_out_frame((void **)&out, &out_len); + ret = a2dp_cp_get_full_out_frame((void **)&out, &out_len); - if (ret) - { - TRACE_A2DP_DECODER_I("%s %d cp find cache underflow", __func__, ret); - TRACE_A2DP_DECODER_I("aud_list_len:%d. cp_get_in_frame:%d", a2dp_audio_list_length(list), get_in_cp_frame_cnt()); - a2dp_cp_lhdc_after_cache_underflow(); - return A2DP_DECODER_CACHE_UNDERFLOW_ERROR; - } + if (ret) { + TRACE_A2DP_DECODER_I("%s %d cp find cache underflow", __func__, ret); + TRACE_A2DP_DECODER_I("aud_list_len:%d. cp_get_in_frame:%d", + a2dp_audio_list_length(list), get_in_cp_frame_cnt()); + a2dp_cp_lhdc_after_cache_underflow(); + return A2DP_DECODER_CACHE_UNDERFLOW_ERROR; + } - if (out_len == 0) - { - memset(buffer, 0, buffer_bytes); - a2dp_cp_consume_full_out_frame(); - TRACE_A2DP_DECODER_I("%s olz!!!%d ", __func__, __LINE__); - return A2DP_DECODER_NO_ERROR; - } - if (out_len != out_frame_len) - { - TRACE_A2DP_DECODER_I("%s: Bad out len %u (should be %u)", __func__, out_len, out_frame_len); - set_cp_reset_flag(true); - return A2DP_DECODER_DECODE_ERROR; - } - p_out_info = (struct A2DP_CP_LHDC_OUT_FRM_INFO_T *)out; - if (p_out_info->pcm_len) - { - a2dp_audio_lhdc_lastframe_info.sequenceNumber = p_out_info->in_info.sequenceNumber; - a2dp_audio_lhdc_lastframe_info.timestamp = p_out_info->in_info.timestamp; - a2dp_audio_lhdc_lastframe_info.curSubSequenceNumber = p_out_info->in_info.curSubSequenceNumber; - a2dp_audio_lhdc_lastframe_info.totalSubSequenceNumber = p_out_info->in_info.totalSubSequenceNumber; - a2dp_audio_lhdc_lastframe_info.frame_samples = p_out_info->frame_samples; - a2dp_audio_lhdc_lastframe_info.decoded_frames += p_out_info->decoded_frames; - a2dp_audio_lhdc_lastframe_info.undecode_frames = - a2dp_audio_list_length(list) + a2dp_cp_get_in_frame_cnt_by_index(p_out_info->frame_idx) - 1; - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_lhdc_lastframe_info); + if (out_len == 0) { + memset(buffer, 0, buffer_bytes); + a2dp_cp_consume_full_out_frame(); + TRACE_A2DP_DECODER_I("%s olz!!!%d ", __func__, __LINE__); + return A2DP_DECODER_NO_ERROR; + } + if (out_len != out_frame_len) { + TRACE_A2DP_DECODER_I("%s: Bad out len %u (should be %u)", __func__, out_len, + out_frame_len); + set_cp_reset_flag(true); + return A2DP_DECODER_DECODE_ERROR; + } + p_out_info = (struct A2DP_CP_LHDC_OUT_FRM_INFO_T *)out; + if (p_out_info->pcm_len) { + a2dp_audio_lhdc_lastframe_info.sequenceNumber = + p_out_info->in_info.sequenceNumber; + a2dp_audio_lhdc_lastframe_info.timestamp = p_out_info->in_info.timestamp; + a2dp_audio_lhdc_lastframe_info.curSubSequenceNumber = + p_out_info->in_info.curSubSequenceNumber; + a2dp_audio_lhdc_lastframe_info.totalSubSequenceNumber = + p_out_info->in_info.totalSubSequenceNumber; + a2dp_audio_lhdc_lastframe_info.frame_samples = p_out_info->frame_samples; + a2dp_audio_lhdc_lastframe_info.decoded_frames += p_out_info->decoded_frames; + a2dp_audio_lhdc_lastframe_info.undecode_frames = + a2dp_audio_list_length(list) + + a2dp_cp_get_in_frame_cnt_by_index(p_out_info->frame_idx) - 1; + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_lhdc_lastframe_info); - TRACE_A2DP_DECODER_I("lhdc_decoder seq:%d cursub:%d ttlsub:%d decoded:%d/%d", - a2dp_audio_lhdc_lastframe_info.sequenceNumber, - a2dp_audio_lhdc_lastframe_info.curSubSequenceNumber, - a2dp_audio_lhdc_lastframe_info.totalSubSequenceNumber, - a2dp_audio_lhdc_lastframe_info.decoded_frames, - a2dp_audio_lhdc_lastframe_info.undecode_frames); - } + TRACE_A2DP_DECODER_I( + "lhdc_decoder seq:%d cursub:%d ttlsub:%d decoded:%d/%d", + a2dp_audio_lhdc_lastframe_info.sequenceNumber, + a2dp_audio_lhdc_lastframe_info.curSubSequenceNumber, + a2dp_audio_lhdc_lastframe_info.totalSubSequenceNumber, + a2dp_audio_lhdc_lastframe_info.decoded_frames, + a2dp_audio_lhdc_lastframe_info.undecode_frames); + } - if (p_out_info->pcm_len == buffer_bytes) - { - memcpy(buffer, p_out_info + 1, p_out_info->pcm_len); - dec_ret = A2DP_DECODER_NO_ERROR; - } - else - { - TRACE_A2DP_DECODER_I("%s %d cp decoder error !!!!!!", __func__, __LINE__); - set_cp_reset_flag(true); - return A2DP_DECODER_DECODE_ERROR; - } + if (p_out_info->pcm_len == buffer_bytes) { + memcpy(buffer, p_out_info + 1, p_out_info->pcm_len); + dec_ret = A2DP_DECODER_NO_ERROR; + } else { + TRACE_A2DP_DECODER_I("%s %d cp decoder error !!!!!!", __func__, __LINE__); + set_cp_reset_flag(true); + return A2DP_DECODER_DECODE_ERROR; + } - ret = a2dp_cp_consume_full_out_frame(); - if (ret) - { + ret = a2dp_cp_consume_full_out_frame(); + if (ret) { - TRACE_A2DP_DECODER_I("%s: a2dp_cp_consume_full_out_frame() failed: ret=%d", __func__, ret); - set_cp_reset_flag(true); - return A2DP_DECODER_DECODE_ERROR; - } - return dec_ret; + TRACE_A2DP_DECODER_I("%s: a2dp_cp_consume_full_out_frame() failed: ret=%d", + __func__, ret); + set_cp_reset_flag(true); + return A2DP_DECODER_DECODE_ERROR; + } + return dec_ret; } #ifdef __CP_EXCEPTION_TEST__ static bool _cp_assert = false; -int cp_assert(void) -{ - _cp_assert = true; - return 0; +int cp_assert(void) { + _cp_assert = true; + return 0; } #endif #define LHDC_DECODED_FRAME_SIZE 1024 TEXT_LHDC_LOC -int a2dp_cp_lhdc_cp_decode(void) -{ - int ret; - enum CP_EMPTY_OUT_FRM_T out_frm_st; - uint8_t *out; - uint32_t out_len; - uint8_t *dec_start; - uint32_t dec_len; - struct A2DP_CP_LHDC_IN_FRM_INFO_T *p_in_info; - struct A2DP_CP_LHDC_OUT_FRM_INFO_T *p_out_info; - uint8_t *in_buf; - uint32_t in_len; +int a2dp_cp_lhdc_cp_decode(void) { + int ret; + enum CP_EMPTY_OUT_FRM_T out_frm_st; + uint8_t *out; + uint32_t out_len; + uint8_t *dec_start; + uint32_t dec_len; + struct A2DP_CP_LHDC_IN_FRM_INFO_T *p_in_info; + struct A2DP_CP_LHDC_OUT_FRM_INFO_T *p_out_info; + uint8_t *in_buf; + uint32_t in_len; - int32_t dec_sum; - uint32_t lhdc_out_len = 0; + int32_t dec_sum; + uint32_t lhdc_out_len = 0; #ifdef __CP_EXCEPTION_TEST__ - if (_cp_assert) - { - _cp_assert = false; - *(int *)0 = 1; - //ASSERT(0, "ASSERT %s %d", __func__, __LINE__); - } + if (_cp_assert) { + _cp_assert = false; + *(int *)0 = 1; + // ASSERT(0, "ASSERT %s %d", __func__, __LINE__); + } #endif - out_frm_st = a2dp_cp_get_emtpy_out_frame((void **)&out, &out_len); + out_frm_st = a2dp_cp_get_emtpy_out_frame((void **)&out, &out_len); - if (out_frm_st != CP_EMPTY_OUT_FRM_OK && out_frm_st != CP_EMPTY_OUT_FRM_WORKING) - { - return out_frm_st; - } - ASSERT(out_len > sizeof(*p_out_info), "%s: Bad out_len %u (should > %u)", __func__, out_len, sizeof(*p_out_info)); + if (out_frm_st != CP_EMPTY_OUT_FRM_OK && + out_frm_st != CP_EMPTY_OUT_FRM_WORKING) { + return out_frm_st; + } + ASSERT(out_len > sizeof(*p_out_info), "%s: Bad out_len %u (should > %u)", + __func__, out_len, sizeof(*p_out_info)); - p_out_info = (struct A2DP_CP_LHDC_OUT_FRM_INFO_T *)out; - if (out_frm_st == CP_EMPTY_OUT_FRM_OK) - { - p_out_info->pcm_len = 0; - p_out_info->decoded_frames = 0; + p_out_info = (struct A2DP_CP_LHDC_OUT_FRM_INFO_T *)out; + if (out_frm_st == CP_EMPTY_OUT_FRM_OK) { + p_out_info->pcm_len = 0; + p_out_info->decoded_frames = 0; + } + + ASSERT(out_len > sizeof(*p_out_info) + p_out_info->pcm_len, + "%s: Bad out_len %u (should > %u + %u)", __func__, out_len, + sizeof(*p_out_info), p_out_info->pcm_len); + + dec_start = (uint8_t *)(p_out_info + 1) + p_out_info->pcm_len; + dec_len = out_len - (dec_start - (uint8_t *)out); + + dec_sum = 0; + + while (dec_sum < (int32_t)dec_len) { + uint32_t lhdc_decode_temp = 0; + + ret = a2dp_cp_get_in_frame((void **)&in_buf, &in_len); + + if (ret) { + TRACE_A2DP_DECODER_I("cp_get_int_frame fail, ret=%d", ret); + return 4; } - ASSERT(out_len > sizeof(*p_out_info) + p_out_info->pcm_len, "%s: Bad out_len %u (should > %u + %u)", __func__, out_len, sizeof(*p_out_info), p_out_info->pcm_len); + ASSERT(in_len > sizeof(*p_in_info), "%s: Bad in_len %u (should > %u)", + __func__, in_len, sizeof(*p_in_info)); - dec_start = (uint8_t *)(p_out_info + 1) + p_out_info->pcm_len; - dec_len = out_len - (dec_start - (uint8_t *)out); - - dec_sum = 0; - - while (dec_sum < (int32_t)dec_len) - { - uint32_t lhdc_decode_temp = 0; - - ret = a2dp_cp_get_in_frame((void **)&in_buf, &in_len); - - if (ret) - { - TRACE_A2DP_DECODER_I("cp_get_int_frame fail, ret=%d", ret); - return 4; - } - - ASSERT(in_len > sizeof(*p_in_info), "%s: Bad in_len %u (should > %u)", __func__, in_len, sizeof(*p_in_info)); - - p_in_info = (struct A2DP_CP_LHDC_IN_FRM_INFO_T *)in_buf; - in_buf += sizeof(*p_in_info); - in_len -= sizeof(*p_in_info); + p_in_info = (struct A2DP_CP_LHDC_IN_FRM_INFO_T *)in_buf; + in_buf += sizeof(*p_in_info); + in_len -= sizeof(*p_in_info); #if defined(A2DP_LHDC_V3) #if defined(A2DP_LHDC_LARC) - if (in_len == 0x55 && larcIsEnabled()) - { - //TRACE_A2DP_DECODER_I("recover:sn(%d), tt(%d), csssn(%d), ttsssn(%d)", p_in_info->sequenceNumber, p_in_info->timestamp, p_in_info->curSubSequenceNumber, p_in_info->totalSubSequenceNumber); - in_len = 0; - } + if (in_len == 0x55 && larcIsEnabled()) { + // TRACE_A2DP_DECODER_I("recover:sn(%d), tt(%d), csssn(%d), ttsssn(%d)", + // p_in_info->sequenceNumber, p_in_info->timestamp, + // p_in_info->curSubSequenceNumber, p_in_info->totalSubSequenceNumber); + in_len = 0; + } #endif - lhdcPutData(in_buf, in_len); - //TRACE_A2DP_DECODER_I("%s:put length=%d, dec_len=%d", __func__, in_len, dec_len); + lhdcPutData(in_buf, in_len); + // TRACE_A2DP_DECODER_I("%s:put length=%d, dec_len=%d", __func__, in_len, + // dec_len); #else - lhdcPutData(in_buf, in_len); + lhdcPutData(in_buf, in_len); #endif - uint32_t loop_cnt = 0; - do - { - //TRACE_A2DP_DECODER_I("loop %d , dec_start %p, dec_sum %d, lhdc_decode_temp %d", loop_cnt, dec_start, dec_sum, lhdc_decode_temp); - lhdc_out_len = lhdcDecodeProcess(dec_start + dec_sum + lhdc_decode_temp); - if (lhdc_out_len > 0) - { - lhdc_decode_temp += lhdc_out_len; - loop_cnt++; - } - else - { - //TRACE_A2DP_DECODER_I("decodeProcess error!!! ret=%d", lhdc_out_len); - break; - } - } while (lhdc_decode_temp < dec_len && lhdc_decode_temp > 0); + uint32_t loop_cnt = 0; + do { + // TRACE_A2DP_DECODER_I("loop %d , dec_start %p, dec_sum %d, + // lhdc_decode_temp %d", loop_cnt, dec_start, dec_sum, lhdc_decode_temp); + lhdc_out_len = lhdcDecodeProcess(dec_start + dec_sum + lhdc_decode_temp); + if (lhdc_out_len > 0) { + lhdc_decode_temp += lhdc_out_len; + loop_cnt++; + } else { + // TRACE_A2DP_DECODER_I("decodeProcess error!!! ret=%d", lhdc_out_len); + break; + } + } while (lhdc_decode_temp < dec_len && lhdc_decode_temp > 0); - //TRACE_A2DP_DECODER_I("lhdc_cp_decode seq:%d len:%d err:%d", p_in_info->sequenceNumber, - // dec_len - dec_sum, - // lhdc_out_len); + // TRACE_A2DP_DECODER_I("lhdc_cp_decode seq:%d len:%d err:%d", + // p_in_info->sequenceNumber, + // dec_len - dec_sum, + // lhdc_out_len); - //TRACE_A2DP_DECODER_I("%s:decode loop run times=%d, lhdc_decode_temp=%d", __func__, loop_cnt, lhdc_decode_temp); - dec_sum += lhdc_decode_temp; + // TRACE_A2DP_DECODER_I("%s:decode loop run times=%d, lhdc_decode_temp=%d", + // __func__, loop_cnt, lhdc_decode_temp); + dec_sum += lhdc_decode_temp; - if ((lhdc_decode_temp % LHDC_DECODED_FRAME_SIZE)) - { - TRACE_A2DP_DECODER_I("error!!! dec_sum: %d decode_temp: %d", dec_sum, lhdc_decode_temp); - return -1; - } - - ret = a2dp_cp_consume_in_frame(); - - if (ret != 0) - { - TRACE_A2DP_DECODER_I("%s: a2dp_cp_consume_in_frame() failed: ret=%d", __func__, ret); - } - ASSERT(ret == 0, "%s: a2dp_cp_consume_in_frame() failed: ret=%d", __func__, ret); - - memcpy(&p_out_info->in_info, p_in_info, sizeof(*p_in_info)); - p_out_info->decoded_frames++; - p_out_info->frame_samples = A2DP_LHDC_OUTPUT_FRAME_SAMPLES; - p_out_info->frame_idx = a2dp_cp_get_in_frame_index(); + if ((lhdc_decode_temp % LHDC_DECODED_FRAME_SIZE)) { + TRACE_A2DP_DECODER_I("error!!! dec_sum: %d decode_temp: %d", dec_sum, + lhdc_decode_temp); + return -1; } - if ((dec_sum % LHDC_DECODED_FRAME_SIZE)) - { - TRACE_A2DP_DECODER_I("error!!! dec_sum:%d != dec_len:%d", dec_sum, dec_len); - ASSERT(0, "%s", __func__); + ret = a2dp_cp_consume_in_frame(); + + if (ret != 0) { + TRACE_A2DP_DECODER_I("%s: a2dp_cp_consume_in_frame() failed: ret=%d", + __func__, ret); } + ASSERT(ret == 0, "%s: a2dp_cp_consume_in_frame() failed: ret=%d", __func__, + ret); - p_out_info->pcm_len += dec_sum; + memcpy(&p_out_info->in_info, p_in_info, sizeof(*p_in_info)); + p_out_info->decoded_frames++; + p_out_info->frame_samples = A2DP_LHDC_OUTPUT_FRAME_SAMPLES; + p_out_info->frame_idx = a2dp_cp_get_in_frame_index(); + } - if (out_len <= sizeof(*p_out_info) + p_out_info->pcm_len) - { - ret = a2dp_cp_consume_emtpy_out_frame(); - ASSERT(ret == 0, "%s: a2dp_cp_consume_emtpy_out_frame() failed: ret=%d", __func__, ret); - } + if ((dec_sum % LHDC_DECODED_FRAME_SIZE)) { + TRACE_A2DP_DECODER_I("error!!! dec_sum:%d != dec_len:%d", dec_sum, + dec_len); + ASSERT(0, "%s", __func__); + } - return 0; + p_out_info->pcm_len += dec_sum; + + if (out_len <= sizeof(*p_out_info) + p_out_info->pcm_len) { + ret = a2dp_cp_consume_emtpy_out_frame(); + ASSERT(ret == 0, "%s: a2dp_cp_consume_emtpy_out_frame() failed: ret=%d", + __func__, ret); + } + + return 0; } #endif #if 1 -static int a2dp_audio_lhdc_list_checker(void) -{ - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - a2dp_audio_lhdc_decoder_frame_t *lhdc_decoder_frame_p = NULL; - int cnt = 0; +static int a2dp_audio_lhdc_list_checker(void) { + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + a2dp_audio_lhdc_decoder_frame_t *lhdc_decoder_frame_p = NULL; + int cnt = 0; - do - { - lhdc_decoder_frame_p = (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_lhdc_frame_malloc(LHDC_READBUF_SIZE); - if (lhdc_decoder_frame_p) - { - a2dp_audio_list_append(list, lhdc_decoder_frame_p); - } - cnt++; - } while (lhdc_decoder_frame_p && cnt < LHDC_MTU_LIMITER); - - do - { - node = a2dp_audio_list_begin(list); - if (node) - { - lhdc_decoder_frame_p = (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_list_node(node); - a2dp_audio_list_remove(list, lhdc_decoder_frame_p); - } - } while (node); - - TRACE_A2DP_DECODER_I("%s cnt:%d list:%d", __func__, cnt, a2dp_audio_list_length(list)); - - return 0; -} -#endif - -int a2dp_audio_lhdc_mcu_decode_frame(uint8_t *buffer, uint32_t buffer_bytes) -{ - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - a2dp_audio_lhdc_decoder_frame_t *lhdc_decoder_frame_p = NULL; - - bool cache_underflow = false; - int output_byte = 0; - - uint32_t lhdc_out_len = 0; + do { + lhdc_decoder_frame_p = + (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_lhdc_frame_malloc( + LHDC_READBUF_SIZE); + if (lhdc_decoder_frame_p) { + a2dp_audio_list_append(list, lhdc_decoder_frame_p); + } + cnt++; + } while (lhdc_decoder_frame_p && cnt < LHDC_MTU_LIMITER); + do { node = a2dp_audio_list_begin(list); - if (!node) - { - TRACE_A2DP_DECODER_I("lhdc_decode cache underflow"); - cache_underflow = true; - goto exit; + if (node) { + lhdc_decoder_frame_p = + (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_list_node(node); + a2dp_audio_list_remove(list, lhdc_decoder_frame_p); } - else - { - lhdc_decoder_frame_p = (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_list_node(node); + } while (node); + + TRACE_A2DP_DECODER_I("%s cnt:%d list:%d", __func__, cnt, + a2dp_audio_list_length(list)); + + return 0; +} +#endif + +int a2dp_audio_lhdc_mcu_decode_frame(uint8_t *buffer, uint32_t buffer_bytes) { + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + a2dp_audio_lhdc_decoder_frame_t *lhdc_decoder_frame_p = NULL; + + bool cache_underflow = false; + int output_byte = 0; + + uint32_t lhdc_out_len = 0; + + node = a2dp_audio_list_begin(list); + if (!node) { + TRACE_A2DP_DECODER_I("lhdc_decode cache underflow"); + cache_underflow = true; + goto exit; + } else { + lhdc_decoder_frame_p = + (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_list_node(node); #if defined(A2DP_LHDC_V3) - lhdcPutData(lhdc_decoder_frame_p->buffer, lhdc_decoder_frame_p->buffer_len); + lhdcPutData(lhdc_decoder_frame_p->buffer, lhdc_decoder_frame_p->buffer_len); #else - lhdcPutData(lhdc_decoder_frame_p->buffer, lhdc_decoder_frame_p->buffer_len); + lhdcPutData(lhdc_decoder_frame_p->buffer, lhdc_decoder_frame_p->buffer_len); #endif - do - { - lhdc_out_len = lhdcDecodeProcess(buffer + output_byte); - if (lhdc_out_len > 0) - { - output_byte += lhdc_out_len; - } - else - { - break; - } - } while (output_byte < (int)buffer_bytes && output_byte > 0); + do { + lhdc_out_len = lhdcDecodeProcess(buffer + output_byte); + if (lhdc_out_len > 0) { + output_byte += lhdc_out_len; + } else { + break; + } + } while (output_byte < (int)buffer_bytes && output_byte > 0); - if (output_byte != (int)buffer_bytes) - { - TRACE_A2DP_DECODER_I("[warning] lhdc_decode_frame output_byte:%d lhdc_out_len:%d buffer_bytes:%d", output_byte, lhdc_out_len, buffer_bytes); - TRACE_A2DP_DECODER_I("[warning] lhdc_decode_frame frame_len:%d rtp seq:%d timestamp:%d decoder_frame:%d/%d ", - lhdc_decoder_frame_p->buffer_len, - lhdc_decoder_frame_p->sequenceNumber, - lhdc_decoder_frame_p->timestamp, - lhdc_decoder_frame_p->curSubSequenceNumber, - lhdc_decoder_frame_p->totalSubSequenceNumber); - output_byte = buffer_bytes; - int32_t dump_byte = lhdc_decoder_frame_p->buffer_len; - int32_t dump_offset = 0; - while (1) - { - uint32_t dump_byte_output = 0; - dump_byte_output = dump_byte > 32 ? 32 : dump_byte; - DUMP8("%02x ", lhdc_decoder_frame_p->buffer + dump_offset, dump_byte_output); - dump_offset += dump_byte_output; - dump_byte -= dump_byte_output; - if (dump_byte <= 0) - { - break; - } - } - ASSERT(0, "%s", __func__); + if (output_byte != (int)buffer_bytes) { + TRACE_A2DP_DECODER_I("[warning] lhdc_decode_frame output_byte:%d " + "lhdc_out_len:%d buffer_bytes:%d", + output_byte, lhdc_out_len, buffer_bytes); + TRACE_A2DP_DECODER_I("[warning] lhdc_decode_frame frame_len:%d rtp " + "seq:%d timestamp:%d decoder_frame:%d/%d ", + lhdc_decoder_frame_p->buffer_len, + lhdc_decoder_frame_p->sequenceNumber, + lhdc_decoder_frame_p->timestamp, + lhdc_decoder_frame_p->curSubSequenceNumber, + lhdc_decoder_frame_p->totalSubSequenceNumber); + output_byte = buffer_bytes; + int32_t dump_byte = lhdc_decoder_frame_p->buffer_len; + int32_t dump_offset = 0; + while (1) { + uint32_t dump_byte_output = 0; + dump_byte_output = dump_byte > 32 ? 32 : dump_byte; + DUMP8("%02x ", lhdc_decoder_frame_p->buffer + dump_offset, + dump_byte_output); + dump_offset += dump_byte_output; + dump_byte -= dump_byte_output; + if (dump_byte <= 0) { + break; } + } + ASSERT(0, "%s", __func__); + } - a2dp_audio_lhdc_lastframe_info.sequenceNumber = lhdc_decoder_frame_p->sequenceNumber; - a2dp_audio_lhdc_lastframe_info.timestamp = lhdc_decoder_frame_p->timestamp; - a2dp_audio_lhdc_lastframe_info.curSubSequenceNumber = lhdc_decoder_frame_p->curSubSequenceNumber; - a2dp_audio_lhdc_lastframe_info.totalSubSequenceNumber = lhdc_decoder_frame_p->totalSubSequenceNumber; - a2dp_audio_lhdc_lastframe_info.frame_samples = A2DP_LHDC_OUTPUT_FRAME_SAMPLES; - a2dp_audio_lhdc_lastframe_info.decoded_frames++; - a2dp_audio_lhdc_lastframe_info.undecode_frames = a2dp_audio_list_length(list) - 1; - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_lhdc_lastframe_info); - a2dp_audio_list_remove(list, lhdc_decoder_frame_p); - } + a2dp_audio_lhdc_lastframe_info.sequenceNumber = + lhdc_decoder_frame_p->sequenceNumber; + a2dp_audio_lhdc_lastframe_info.timestamp = lhdc_decoder_frame_p->timestamp; + a2dp_audio_lhdc_lastframe_info.curSubSequenceNumber = + lhdc_decoder_frame_p->curSubSequenceNumber; + a2dp_audio_lhdc_lastframe_info.totalSubSequenceNumber = + lhdc_decoder_frame_p->totalSubSequenceNumber; + a2dp_audio_lhdc_lastframe_info.frame_samples = + A2DP_LHDC_OUTPUT_FRAME_SAMPLES; + a2dp_audio_lhdc_lastframe_info.decoded_frames++; + a2dp_audio_lhdc_lastframe_info.undecode_frames = + a2dp_audio_list_length(list) - 1; + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_lhdc_lastframe_info); + a2dp_audio_list_remove(list, lhdc_decoder_frame_p); + } exit: - if (cache_underflow) - { - reset_lhdc_assmeble_packet(); - a2dp_audio_lhdc_lastframe_info.undecode_frames = 0; - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_lhdc_lastframe_info); - output_byte = A2DP_DECODER_CACHE_UNDERFLOW_ERROR; - } - return output_byte; + if (cache_underflow) { + reset_lhdc_assmeble_packet(); + a2dp_audio_lhdc_lastframe_info.undecode_frames = 0; + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_lhdc_lastframe_info); + output_byte = A2DP_DECODER_CACHE_UNDERFLOW_ERROR; + } + return output_byte; } -int a2dp_audio_lhdc_decode_frame(uint8_t *buffer, uint32_t buffer_bytes) -{ +int a2dp_audio_lhdc_decode_frame(uint8_t *buffer, uint32_t buffer_bytes) { #ifdef A2DP_CP_ACCEL - return a2dp_cp_lhdc_mcu_decode(buffer, buffer_bytes); + return a2dp_cp_lhdc_mcu_decode(buffer, buffer_bytes); #else - return a2dp_audio_lhdc_mcu_decode_frame(buffer, buffer_bytes); + return a2dp_audio_lhdc_mcu_decode_frame(buffer, buffer_bytes); #endif } -int a2dp_audio_lhdc_preparse_packet(btif_media_header_t *header, uint8_t *buffer, uint32_t buffer_bytes) -{ - a2dp_audio_lhdc_lastframe_info.sequenceNumber = header->sequenceNumber; - a2dp_audio_lhdc_lastframe_info.timestamp = header->timestamp; - a2dp_audio_lhdc_lastframe_info.curSubSequenceNumber = 0; - a2dp_audio_lhdc_lastframe_info.totalSubSequenceNumber = 0; - a2dp_audio_lhdc_lastframe_info.frame_samples = A2DP_LHDC_OUTPUT_FRAME_SAMPLES; - a2dp_audio_lhdc_lastframe_info.list_samples = A2DP_LHDC_OUTPUT_FRAME_SAMPLES; - a2dp_audio_lhdc_lastframe_info.decoded_frames = 0; - a2dp_audio_lhdc_lastframe_info.undecode_frames = 0; - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_lhdc_lastframe_info); +int a2dp_audio_lhdc_preparse_packet(btif_media_header_t *header, + uint8_t *buffer, uint32_t buffer_bytes) { + a2dp_audio_lhdc_lastframe_info.sequenceNumber = header->sequenceNumber; + a2dp_audio_lhdc_lastframe_info.timestamp = header->timestamp; + a2dp_audio_lhdc_lastframe_info.curSubSequenceNumber = 0; + a2dp_audio_lhdc_lastframe_info.totalSubSequenceNumber = 0; + a2dp_audio_lhdc_lastframe_info.frame_samples = A2DP_LHDC_OUTPUT_FRAME_SAMPLES; + a2dp_audio_lhdc_lastframe_info.list_samples = A2DP_LHDC_OUTPUT_FRAME_SAMPLES; + a2dp_audio_lhdc_lastframe_info.decoded_frames = 0; + a2dp_audio_lhdc_lastframe_info.undecode_frames = 0; + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_lhdc_lastframe_info); - TRACE_A2DP_DECODER_I("%s seq:%d timestamp:%08x", __func__, header->sequenceNumber, header->timestamp); + TRACE_A2DP_DECODER_I("%s seq:%d timestamp:%08x", __func__, + header->sequenceNumber, header->timestamp); - return A2DP_DECODER_NO_ERROR; + return A2DP_DECODER_NO_ERROR; } -void a2dp_audio_lhdc_free(void *packet) -{ - a2dp_audio_lhdc_decoder_frame_t *decoder_frame_p = (a2dp_audio_lhdc_decoder_frame_t *)packet; - a2dp_audio_heap_free(decoder_frame_p->buffer); - a2dp_audio_heap_free(decoder_frame_p); +void a2dp_audio_lhdc_free(void *packet) { + a2dp_audio_lhdc_decoder_frame_t *decoder_frame_p = + (a2dp_audio_lhdc_decoder_frame_t *)packet; + a2dp_audio_heap_free(decoder_frame_p->buffer); + a2dp_audio_heap_free(decoder_frame_p); } -int a2dp_audio_lhdc_store_packet(btif_media_header_t *header, uint8_t *buffer, uint32_t buffer_bytes) -{ - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - int nRet = A2DP_DECODER_NO_ERROR; - uint32_t frame_num = 0; - uint32_t frame_cnt = 0; - uint32_t lSize = 0; - uint8_t *lPTR = NULL; - lhdc_frame_Info_t lhdc_frame_Info; - uint32_t ptr_offset = 0; +int a2dp_audio_lhdc_store_packet(btif_media_header_t *header, uint8_t *buffer, + uint32_t buffer_bytes) { + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + int nRet = A2DP_DECODER_NO_ERROR; + uint32_t frame_num = 0; + uint32_t frame_cnt = 0; + uint32_t lSize = 0; + uint8_t *lPTR = NULL; + lhdc_frame_Info_t lhdc_frame_Info; + uint32_t ptr_offset = 0; - if ((frame_num = assemble_lhdc_packet(buffer, buffer_bytes, &lPTR, &lSize)) > 0) - { - if (lPTR != NULL && lSize != 0) - { - ptr_offset = 0; - //TRACE_A2DP_DECODER_I("%s: There are %d frames in packet", __func__, frame_num); - while (parse_lhdc_info(lPTR + ptr_offset, &lhdc_frame_Info) == 0 && ptr_offset < lSize && frame_cnt < frame_num) - { - a2dp_audio_lhdc_decoder_frame_t *decoder_frame_p = NULL; - if (!lhdc_frame_Info.frame_len) - { - DUMP8("%02x ", lPTR + ptr_offset, 32); - ASSERT(0, "lhdc_frame_Info error frame_len:%d offset:%d ptr:%08x/%08x", lhdc_frame_Info.frame_len, ptr_offset, (uint32_t)buffer, (uint32_t)lPTR); - } - ASSERT(lhdc_frame_Info.frame_len <= (lSize - ptr_offset), "%s frame_len:%d ptr_offset:%d buffer_bytes:%d", - __func__, lhdc_frame_Info.frame_len, ptr_offset, lSize); - uint32_t list_length = a2dp_audio_list_length(list); - if (list_length < lhdc_mtu_limiter) - { - decoder_frame_p = (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_lhdc_frame_malloc(lhdc_frame_Info.frame_len); - } - else - { - nRet = A2DP_DECODER_MTU_LIMTER_ERROR; - break; - } - frame_cnt++; + if ((frame_num = assemble_lhdc_packet(buffer, buffer_bytes, &lPTR, &lSize)) > + 0) { + if (lPTR != NULL && lSize != 0) { + ptr_offset = 0; + // TRACE_A2DP_DECODER_I("%s: There are %d frames in packet", __func__, + // frame_num); + while (parse_lhdc_info(lPTR + ptr_offset, &lhdc_frame_Info) == 0 && + ptr_offset < lSize && frame_cnt < frame_num) { + a2dp_audio_lhdc_decoder_frame_t *decoder_frame_p = NULL; + if (!lhdc_frame_Info.frame_len) { + DUMP8("%02x ", lPTR + ptr_offset, 32); + ASSERT(0, + "lhdc_frame_Info error frame_len:%d offset:%d ptr:%08x/%08x", + lhdc_frame_Info.frame_len, ptr_offset, (uint32_t)buffer, + (uint32_t)lPTR); + } + ASSERT(lhdc_frame_Info.frame_len <= (lSize - ptr_offset), + "%s frame_len:%d ptr_offset:%d buffer_bytes:%d", __func__, + lhdc_frame_Info.frame_len, ptr_offset, lSize); + uint32_t list_length = a2dp_audio_list_length(list); + if (list_length < lhdc_mtu_limiter) { + decoder_frame_p = + (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_lhdc_frame_malloc( + lhdc_frame_Info.frame_len); + } else { + nRet = A2DP_DECODER_MTU_LIMTER_ERROR; + break; + } + frame_cnt++; - decoder_frame_p->sequenceNumber = header->sequenceNumber; - decoder_frame_p->timestamp = header->timestamp; - decoder_frame_p->curSubSequenceNumber = frame_cnt; - decoder_frame_p->totalSubSequenceNumber = frame_num; - memcpy(decoder_frame_p->buffer, lPTR + ptr_offset, lhdc_frame_Info.frame_len); - decoder_frame_p->buffer_len = lhdc_frame_Info.frame_len; - a2dp_audio_list_append(list, decoder_frame_p); + decoder_frame_p->sequenceNumber = header->sequenceNumber; + decoder_frame_p->timestamp = header->timestamp; + decoder_frame_p->curSubSequenceNumber = frame_cnt; + decoder_frame_p->totalSubSequenceNumber = frame_num; + memcpy(decoder_frame_p->buffer, lPTR + ptr_offset, + lhdc_frame_Info.frame_len); + decoder_frame_p->buffer_len = lhdc_frame_Info.frame_len; + a2dp_audio_list_append(list, decoder_frame_p); - ptr_offset += lhdc_frame_Info.frame_len; + ptr_offset += lhdc_frame_Info.frame_len; #if 0 TRACE_A2DP_DECODER_I("lhdc_store_packet save seq:%d timestamp:%d len:%d lSize:%d list_length:%d frame_len:%d Split:%d/%d", header->sequenceNumber, @@ -1005,245 +976,245 @@ int a2dp_audio_lhdc_store_packet(btif_media_header_t *header, uint8_t *buffer, u lhdc_frame_Info.isSplit, lhdc_frame_Info.isLeft); #endif - } - } - } - else - { - // TRACE_A2DP_DECODER_I("lhdc_store_packet skip seq:%d timestamp:%d len:%d l:%d", header->sequenceNumber, header->timestamp,buffer_bytes, lSize); + } } + } else { + // TRACE_A2DP_DECODER_I("lhdc_store_packet skip seq:%d timestamp:%d + // len:%d l:%d", header->sequenceNumber, + // header->timestamp,buffer_bytes, lSize); + } - return nRet; + return nRet; } -int a2dp_audio_lhdc_discards_packet(uint32_t packets) -{ +int a2dp_audio_lhdc_discards_packet(uint32_t packets) { #ifdef A2DP_CP_ACCEL - a2dp_cp_reset_frame(); + a2dp_cp_reset_frame(); #endif - int nRet = a2dp_audio_context_p->audio_decoder.audio_decoder_synchronize_dest_packet_mut(a2dp_audio_context_p->dest_packet_mut); + int nRet = a2dp_audio_context_p->audio_decoder + .audio_decoder_synchronize_dest_packet_mut( + a2dp_audio_context_p->dest_packet_mut); - reset_lhdc_assmeble_packet(); + reset_lhdc_assmeble_packet(); #if defined(A2DP_LHDC_LARC) - lhdc_drop_frame = 0; + lhdc_drop_frame = 0; #endif - return nRet; + return nRet; } -static int a2dp_audio_lhdc_headframe_info_get(A2DP_AUDIO_HEADFRAME_INFO_T *headframe_info) -{ - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - a2dp_audio_lhdc_decoder_frame_t *decoder_frame_p = NULL; +static int a2dp_audio_lhdc_headframe_info_get( + A2DP_AUDIO_HEADFRAME_INFO_T *headframe_info) { + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + a2dp_audio_lhdc_decoder_frame_t *decoder_frame_p = NULL; - if (a2dp_audio_list_length(list)) - { - node = a2dp_audio_list_begin(list); - decoder_frame_p = (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_list_node(node); - headframe_info->sequenceNumber = decoder_frame_p->sequenceNumber; - headframe_info->timestamp = decoder_frame_p->timestamp; - headframe_info->curSubSequenceNumber = 0; - headframe_info->totalSubSequenceNumber = 0; - } - else - { - memset(headframe_info, 0, sizeof(A2DP_AUDIO_HEADFRAME_INFO_T)); - } + if (a2dp_audio_list_length(list)) { + node = a2dp_audio_list_begin(list); + decoder_frame_p = + (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_list_node(node); + headframe_info->sequenceNumber = decoder_frame_p->sequenceNumber; + headframe_info->timestamp = decoder_frame_p->timestamp; + headframe_info->curSubSequenceNumber = 0; + headframe_info->totalSubSequenceNumber = 0; + } else { + memset(headframe_info, 0, sizeof(A2DP_AUDIO_HEADFRAME_INFO_T)); + } - return A2DP_DECODER_NO_ERROR; + return A2DP_DECODER_NO_ERROR; } -int a2dp_audio_lhdc_info_get(void *info) -{ - return A2DP_DECODER_NO_ERROR; -} +int a2dp_audio_lhdc_info_get(void *info) { return A2DP_DECODER_NO_ERROR; } extern uint32_t __lhdc_license_start[]; -int a2dp_audio_lhdc_init(A2DP_AUDIO_OUTPUT_CONFIG_T *config, void *context) -{ - TRACE_A2DP_DECODER_I("%s %s ch:%d freq:%d bits:%d", __func__, getVersionCode(), - config->num_channels, - config->sample_rate, - config->bits_depth); +int a2dp_audio_lhdc_init(A2DP_AUDIO_OUTPUT_CONFIG_T *config, void *context) { + TRACE_A2DP_DECODER_I("%s %s ch:%d freq:%d bits:%d", __func__, + getVersionCode(), config->num_channels, + config->sample_rate, config->bits_depth); - uint8_t lhdc_license_key = 0; - uint8_t *lhdc_license_data=(uint8_t * )__lhdc_license_start + 0x98; - TRACE(5,"lhdc_license_data:%p, lhdc license %02x %02x %02x %02x",lhdc_license_data, - lhdc_license_data[0],lhdc_license_data[1],lhdc_license_data[2],lhdc_license_data[3]); + uint8_t lhdc_license_key = 0; + uint8_t *lhdc_license_data = (uint8_t *)__lhdc_license_start + 0x98; + TRACE(5, "lhdc_license_data:%p, lhdc license %02x %02x %02x %02x", + lhdc_license_data, lhdc_license_data[0], lhdc_license_data[1], + lhdc_license_data[2], lhdc_license_data[3]); + a2dp_audio_context_p = (A2DP_AUDIO_CONTEXT_T *)context; - a2dp_audio_context_p = (A2DP_AUDIO_CONTEXT_T *)context; + memset(&a2dp_audio_lhdc_lastframe_info, 0, + sizeof(A2DP_AUDIO_DECODER_LASTFRAME_INFO_T)); + memcpy(&a2dp_audio_lhdc_output_config, config, + sizeof(A2DP_AUDIO_OUTPUT_CONFIG_T)); + a2dp_audio_lhdc_lastframe_info.stream_info = a2dp_audio_lhdc_output_config; + a2dp_audio_lhdc_lastframe_info.frame_samples = A2DP_LHDC_OUTPUT_FRAME_SAMPLES; + a2dp_audio_lhdc_lastframe_info.list_samples = A2DP_LHDC_OUTPUT_FRAME_SAMPLES; + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_lhdc_lastframe_info); - memset(&a2dp_audio_lhdc_lastframe_info, 0, sizeof(A2DP_AUDIO_DECODER_LASTFRAME_INFO_T)); - memcpy(&a2dp_audio_lhdc_output_config, config, sizeof(A2DP_AUDIO_OUTPUT_CONFIG_T)); - a2dp_audio_lhdc_lastframe_info.stream_info = a2dp_audio_lhdc_output_config; - a2dp_audio_lhdc_lastframe_info.frame_samples = A2DP_LHDC_OUTPUT_FRAME_SAMPLES; - a2dp_audio_lhdc_lastframe_info.list_samples = A2DP_LHDC_OUTPUT_FRAME_SAMPLES; - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_lhdc_lastframe_info); + lhdc_license_key = + lhdcSetLicenseKeyTable(lhdc_license_data, bes_bt_local_info_get); - lhdc_license_key = lhdcSetLicenseKeyTable(lhdc_license_data, bes_bt_local_info_get); - - TRACE_A2DP_DECODER_I("lhdc_license_key:%d", lhdc_license_key); + TRACE_A2DP_DECODER_I("lhdc_license_key:%d", lhdc_license_key); #if defined(A2DP_LHDC_V3) - lhdcInit(config->bits_depth, config->sample_rate, 0, VERSION_3); + lhdcInit(config->bits_depth, config->sample_rate, 0, VERSION_3); #else - lhdcInit(config->bits_depth, config->sample_rate, 0, VERSION_2); + lhdcInit(config->bits_depth, config->sample_rate, 0, VERSION_2); #endif - initial_lhdc_assemble_packet(false); + initial_lhdc_assemble_packet(false); #ifdef A2DP_CP_ACCEL - int ret; - ret = a2dp_cp_init(a2dp_cp_lhdc_cp_decode, CP_PROC_DELAY_2_FRAMES); - ASSERT(ret == 0, "%s: a2dp_cp_init() failed: ret=%d", __func__, ret); + int ret; + ret = a2dp_cp_init(a2dp_cp_lhdc_cp_decode, CP_PROC_DELAY_2_FRAMES); + ASSERT(ret == 0, "%s: a2dp_cp_init() failed: ret=%d", __func__, ret); #endif - a2dp_audio_lhdc_list_checker(); + a2dp_audio_lhdc_list_checker(); #if defined(A2DP_LHDC_LARC) - lhdc_last_time = 0; - lhdc_drop_frame = 0; + lhdc_last_time = 0; + lhdc_drop_frame = 0; #endif - return A2DP_DECODER_NO_ERROR; + return A2DP_DECODER_NO_ERROR; } -int a2dp_audio_lhdc_deinit(void) -{ +int a2dp_audio_lhdc_deinit(void) { #ifdef A2DP_CP_ACCEL - a2dp_cp_deinit(); + a2dp_cp_deinit(); #endif - lhdcDestroy(); - return A2DP_DECODER_NO_ERROR; + lhdcDestroy(); + return A2DP_DECODER_NO_ERROR; } -int a2dp_audio_lhdc_synchronize_packet(A2DP_AUDIO_SYNCFRAME_INFO_T *sync_info, uint32_t mask) -{ - int nRet = A2DP_DECODER_SYNC_ERROR; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - int list_len; - a2dp_audio_lhdc_decoder_frame_t *lhdc_decoder_frame; +int a2dp_audio_lhdc_synchronize_packet(A2DP_AUDIO_SYNCFRAME_INFO_T *sync_info, + uint32_t mask) { + int nRet = A2DP_DECODER_SYNC_ERROR; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + int list_len; + a2dp_audio_lhdc_decoder_frame_t *lhdc_decoder_frame; #ifdef A2DP_CP_ACCEL - a2dp_cp_reset_frame(); + a2dp_cp_reset_frame(); #endif - list_len = a2dp_audio_list_length(list); + list_len = a2dp_audio_list_length(list); - for (uint16_t i = 0; i < list_len; i++) - { - node = a2dp_audio_list_begin(list); - lhdc_decoder_frame = (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_list_node(node); - if (A2DP_AUDIO_SYNCFRAME_CHK(lhdc_decoder_frame->sequenceNumber == sync_info->sequenceNumber, A2DP_AUDIO_SYNCFRAME_MASK_SEQ, mask) && - A2DP_AUDIO_SYNCFRAME_CHK(lhdc_decoder_frame->curSubSequenceNumber == sync_info->curSubSequenceNumber, A2DP_AUDIO_SYNCFRAME_MASK_CURRSUBSEQ, mask) && - A2DP_AUDIO_SYNCFRAME_CHK(lhdc_decoder_frame->totalSubSequenceNumber == sync_info->totalSubSequenceNumber, A2DP_AUDIO_SYNCFRAME_MASK_TOTALSUBSEQ, mask)) - { - nRet = A2DP_DECODER_NO_ERROR; - break; - } - a2dp_audio_list_remove(list, lhdc_decoder_frame); + for (uint16_t i = 0; i < list_len; i++) { + node = a2dp_audio_list_begin(list); + lhdc_decoder_frame = + (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_list_node(node); + if (A2DP_AUDIO_SYNCFRAME_CHK(lhdc_decoder_frame->sequenceNumber == + sync_info->sequenceNumber, + A2DP_AUDIO_SYNCFRAME_MASK_SEQ, mask) && + A2DP_AUDIO_SYNCFRAME_CHK(lhdc_decoder_frame->curSubSequenceNumber == + sync_info->curSubSequenceNumber, + A2DP_AUDIO_SYNCFRAME_MASK_CURRSUBSEQ, mask) && + A2DP_AUDIO_SYNCFRAME_CHK(lhdc_decoder_frame->totalSubSequenceNumber == + sync_info->totalSubSequenceNumber, + A2DP_AUDIO_SYNCFRAME_MASK_TOTALSUBSEQ, mask)) { + nRet = A2DP_DECODER_NO_ERROR; + break; } + a2dp_audio_list_remove(list, lhdc_decoder_frame); + } + + node = a2dp_audio_list_begin(list); + if (node) { + lhdc_decoder_frame = + (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_list_node(node); + TRACE_A2DP_DECODER_I("%s nRet:%d SEQ:%d timestamp:%d %d/%d", __func__, nRet, + lhdc_decoder_frame->sequenceNumber, + lhdc_decoder_frame->timestamp, + lhdc_decoder_frame->curSubSequenceNumber, + lhdc_decoder_frame->totalSubSequenceNumber); + } else { + TRACE_A2DP_DECODER_I("%s nRet:%d", __func__, nRet); + } + + return nRet; +} + +int a2dp_audio_lhdc_synchronize_dest_packet_mut(uint16_t packet_mut) { + list_node_t *node = NULL; + uint32_t list_len = 0; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + a2dp_audio_lhdc_decoder_frame_t *lhdc_decoder_frame_p = NULL; + + list_len = a2dp_audio_list_length(list); + if (list_len > packet_mut) { + do { + node = a2dp_audio_list_begin(list); + lhdc_decoder_frame_p = + (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_list_node(node); + a2dp_audio_list_remove(list, lhdc_decoder_frame_p); + } while (a2dp_audio_list_length(list) > packet_mut); + } + + TRACE_A2DP_DECODER_I("%s list:%d", __func__, a2dp_audio_list_length(list)); + return A2DP_DECODER_NO_ERROR; +} + +int a2dp_audio_lhdc_convert_list_to_samples(uint32_t *samples) { + uint32_t list_len = 0; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + + list_len = a2dp_audio_list_length(list); + + *samples = A2DP_LHDC_OUTPUT_FRAME_SAMPLES * list_len; + + TRACE_A2DP_DECODER_I("%s list:%d samples:%d", __func__, list_len, *samples); + + return A2DP_DECODER_NO_ERROR; +} + +int a2dp_audio_lhdc_discards_samples(uint32_t samples) { + int nRet = A2DP_DECODER_SYNC_ERROR; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + a2dp_audio_lhdc_decoder_frame_t *lhdc_decoder_frame_p = NULL; + list_node_t *node = NULL; + int need_remove_list = 0; + uint32_t list_samples = 0; + + ASSERT(!(samples % A2DP_LHDC_OUTPUT_FRAME_SAMPLES), "%s samples err:%d", + __func__, samples); + + a2dp_audio_lhdc_convert_list_to_samples(&list_samples); + if (list_samples >= samples) { + need_remove_list = samples / A2DP_LHDC_OUTPUT_FRAME_SAMPLES; + for (int i = 0; i < need_remove_list; i++) { + node = a2dp_audio_list_begin(list); + lhdc_decoder_frame_p = + (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_list_node(node); + a2dp_audio_list_remove(list, lhdc_decoder_frame_p); + } + nRet = A2DP_DECODER_NO_ERROR; node = a2dp_audio_list_begin(list); - if (node) - { - lhdc_decoder_frame = (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_list_node(node); - TRACE_A2DP_DECODER_I("%s nRet:%d SEQ:%d timestamp:%d %d/%d", __func__, nRet, lhdc_decoder_frame->sequenceNumber, lhdc_decoder_frame->timestamp, - lhdc_decoder_frame->curSubSequenceNumber, lhdc_decoder_frame->totalSubSequenceNumber); - } - else - { - TRACE_A2DP_DECODER_I("%s nRet:%d", __func__, nRet); - } + lhdc_decoder_frame_p = + (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_list_node(node); + TRACE_A2DP_DECODER_I("%s discard %d sample cur seq:%d", __func__, samples, + lhdc_decoder_frame_p->sequenceNumber); + } - return nRet; -} - -int a2dp_audio_lhdc_synchronize_dest_packet_mut(uint16_t packet_mut) -{ - list_node_t *node = NULL; - uint32_t list_len = 0; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - a2dp_audio_lhdc_decoder_frame_t *lhdc_decoder_frame_p = NULL; - - list_len = a2dp_audio_list_length(list); - if (list_len > packet_mut) - { - do - { - node = a2dp_audio_list_begin(list); - lhdc_decoder_frame_p = (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_list_node(node); - a2dp_audio_list_remove(list, lhdc_decoder_frame_p); - } while (a2dp_audio_list_length(list) > packet_mut); - } - - TRACE_A2DP_DECODER_I("%s list:%d", __func__, a2dp_audio_list_length(list)); - return A2DP_DECODER_NO_ERROR; -} - -int a2dp_audio_lhdc_convert_list_to_samples(uint32_t *samples) -{ - uint32_t list_len = 0; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - - list_len = a2dp_audio_list_length(list); - - *samples = A2DP_LHDC_OUTPUT_FRAME_SAMPLES * list_len; - - TRACE_A2DP_DECODER_I("%s list:%d samples:%d", __func__, list_len, *samples); - - return A2DP_DECODER_NO_ERROR; -} - -int a2dp_audio_lhdc_discards_samples(uint32_t samples) -{ - int nRet = A2DP_DECODER_SYNC_ERROR; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - a2dp_audio_lhdc_decoder_frame_t *lhdc_decoder_frame_p = NULL; - list_node_t *node = NULL; - int need_remove_list = 0; - uint32_t list_samples = 0; - - ASSERT(!(samples % A2DP_LHDC_OUTPUT_FRAME_SAMPLES), "%s samples err:%d", __func__, samples); - - a2dp_audio_lhdc_convert_list_to_samples(&list_samples); - if (list_samples >= samples) - { - need_remove_list = samples / A2DP_LHDC_OUTPUT_FRAME_SAMPLES; - for (int i = 0; i < need_remove_list; i++) - { - node = a2dp_audio_list_begin(list); - lhdc_decoder_frame_p = (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_list_node(node); - a2dp_audio_list_remove(list, lhdc_decoder_frame_p); - } - nRet = A2DP_DECODER_NO_ERROR; - - node = a2dp_audio_list_begin(list); - lhdc_decoder_frame_p = (a2dp_audio_lhdc_decoder_frame_t *)a2dp_audio_list_node(node); - TRACE_A2DP_DECODER_I("%s discard %d sample cur seq:%d", __func__, samples, lhdc_decoder_frame_p->sequenceNumber); - } - - return nRet; + return nRet; } A2DP_AUDIO_DECODER_T a2dp_audio_lhdc_decoder_config = { - {96000, 2, 24}, - 1, - a2dp_audio_lhdc_init, - a2dp_audio_lhdc_deinit, - a2dp_audio_lhdc_decode_frame, - a2dp_audio_lhdc_preparse_packet, - a2dp_audio_lhdc_store_packet, - a2dp_audio_lhdc_discards_packet, - a2dp_audio_lhdc_synchronize_packet, - a2dp_audio_lhdc_synchronize_dest_packet_mut, - a2dp_audio_lhdc_convert_list_to_samples, - a2dp_audio_lhdc_discards_samples, - a2dp_audio_lhdc_headframe_info_get, - a2dp_audio_lhdc_info_get, - a2dp_audio_lhdc_free, - } ; - + {96000, 2, 24}, + 1, + a2dp_audio_lhdc_init, + a2dp_audio_lhdc_deinit, + a2dp_audio_lhdc_decode_frame, + a2dp_audio_lhdc_preparse_packet, + a2dp_audio_lhdc_store_packet, + a2dp_audio_lhdc_discards_packet, + a2dp_audio_lhdc_synchronize_packet, + a2dp_audio_lhdc_synchronize_dest_packet_mut, + a2dp_audio_lhdc_convert_list_to_samples, + a2dp_audio_lhdc_discards_samples, + a2dp_audio_lhdc_headframe_info_get, + a2dp_audio_lhdc_info_get, + a2dp_audio_lhdc_free, +}; diff --git a/apps/audioplayers/a2dp_decoder/a2dp_decoder_sbc.cpp b/apps/audioplayers/a2dp_decoder/a2dp_decoder_sbc.cpp index e53066c..713cb53 100644 --- a/apps/audioplayers/a2dp_decoder/a2dp_decoder_sbc.cpp +++ b/apps/audioplayers/a2dp_decoder/a2dp_decoder_sbc.cpp @@ -14,15 +14,15 @@ * ****************************************************************************/ // Standard C Included Files +#include "a2dp_decoder_internal.h" #include "cmsis.h" +#include "cmsis_os.h" +#include "codec_sbc.h" +#include "hal_location.h" +#include "hal_timer.h" +#include "heap_api.h" #include "plat_types.h" #include -#include "heap_api.h" -#include "hal_location.h" -#include "codec_sbc.h" -#include "a2dp_decoder_internal.h" -#include "hal_timer.h" -#include "cmsis_os.h" #ifndef SBC_MTU_LIMITER #define SBC_MTU_LIMITER (250) /*must <= 332*/ @@ -34,18 +34,18 @@ static A2DP_AUDIO_CONTEXT_T *a2dp_audio_context_p = NULL; extern A2DP_AUDIO_DECODER_T a2dp_audio_sbc_decoder_config; -typedef struct { - btif_sbc_decoder_t *sbc_decoder; - btif_sbc_pcm_data_t *pcm_data; +typedef struct { + btif_sbc_decoder_t *sbc_decoder; + btif_sbc_pcm_data_t *pcm_data; } a2dp_audio_sbc_decoder_t; typedef struct { - uint16_t sequenceNumber; - uint32_t timestamp; - uint16_t curSubSequenceNumber; - uint16_t totalSubSequenceNumber; - uint8_t *sbc_buffer; - uint32_t sbc_buffer_len; + uint16_t sequenceNumber; + uint32_t timestamp; + uint16_t curSubSequenceNumber; + uint16_t totalSubSequenceNumber; + uint8_t *sbc_buffer; + uint32_t sbc_buffer_len; } a2dp_audio_sbc_decoder_frame_t; static a2dp_audio_sbc_decoder_t a2dp_audio_sbc_decoder; @@ -55,53 +55,55 @@ static A2DP_AUDIO_DECODER_LASTFRAME_INFO_T a2dp_audio_sbc_lastframe_info; static uint16_t sbc_mtu_limiter = SBC_MTU_LIMITER; -static btif_media_header_t sbc_decoder_last_valid_frame = {0,}; +static btif_media_header_t sbc_decoder_last_valid_frame = { + 0, +}; static bool sbc_decoder_last_valid_frame_ready = false; static bool sbc_chnl_mode_mono = false; static int a2dp_audio_sbc_header_parser_init(void); -static void *a2dp_audio_sbc_subframe_malloc(uint32_t sbc_len) -{ - a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame_p = NULL; - uint8_t *sbc_buffer = NULL; +static void *a2dp_audio_sbc_subframe_malloc(uint32_t sbc_len) { + a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame_p = NULL; + uint8_t *sbc_buffer = NULL; - sbc_buffer = (uint8_t *)a2dp_audio_heap_malloc(sbc_len); - sbc_decoder_frame_p = (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_heap_malloc(sizeof(a2dp_audio_sbc_decoder_frame_t)); - sbc_decoder_frame_p->sbc_buffer = sbc_buffer; - sbc_decoder_frame_p->sbc_buffer_len = sbc_len; - return (void *)sbc_decoder_frame_p; + sbc_buffer = (uint8_t *)a2dp_audio_heap_malloc(sbc_len); + sbc_decoder_frame_p = + (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_heap_malloc( + sizeof(a2dp_audio_sbc_decoder_frame_t)); + sbc_decoder_frame_p->sbc_buffer = sbc_buffer; + sbc_decoder_frame_p->sbc_buffer_len = sbc_len; + return (void *)sbc_decoder_frame_p; } -static void a2dp_audio_sbc_subframe_free(void *packet) -{ - a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame_p = (a2dp_audio_sbc_decoder_frame_t *)packet; - a2dp_audio_heap_free(sbc_decoder_frame_p->sbc_buffer); - a2dp_audio_heap_free(sbc_decoder_frame_p); +static void a2dp_audio_sbc_subframe_free(void *packet) { + a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame_p = + (a2dp_audio_sbc_decoder_frame_t *)packet; + a2dp_audio_heap_free(sbc_decoder_frame_p->sbc_buffer); + a2dp_audio_heap_free(sbc_decoder_frame_p); } -static void sbc_codec_init(void) -{ - btif_sbc_init_decoder(a2dp_audio_sbc_decoder.sbc_decoder); - a2dp_audio_sbc_decoder.sbc_decoder->maxPcmLen = SBC_PCMLEN_DEFAULT; - a2dp_audio_sbc_decoder.pcm_data->data = NULL; - a2dp_audio_sbc_decoder.pcm_data->dataLen = 0; +static void sbc_codec_init(void) { + btif_sbc_init_decoder(a2dp_audio_sbc_decoder.sbc_decoder); + a2dp_audio_sbc_decoder.sbc_decoder->maxPcmLen = SBC_PCMLEN_DEFAULT; + a2dp_audio_sbc_decoder.pcm_data->data = NULL; + a2dp_audio_sbc_decoder.pcm_data->dataLen = 0; } #ifdef A2DP_CP_ACCEL struct A2DP_CP_SBC_IN_FRM_INFO_T { - uint16_t sequenceNumber; - uint32_t timestamp; - uint16_t curSubSequenceNumber; - uint16_t totalSubSequenceNumber; + uint16_t sequenceNumber; + uint32_t timestamp; + uint16_t curSubSequenceNumber; + uint16_t totalSubSequenceNumber; }; struct A2DP_CP_SBC_OUT_FRM_INFO_T { - struct A2DP_CP_SBC_IN_FRM_INFO_T in_info; - uint16_t frame_samples; - uint16_t decoded_frames; - uint16_t frame_idx; - uint16_t pcm_len; + struct A2DP_CP_SBC_IN_FRM_INFO_T in_info; + uint16_t frame_samples; + uint16_t decoded_frames; + uint16_t frame_idx; + uint16_t pcm_len; }; static bool cp_codec_reset; @@ -112,858 +114,940 @@ int a2dp_cp_sbc_cp_decode(void); extern uint32_t app_bt_stream_get_dma_buffer_samples(void); -static int TEXT_SBC_LOC a2dp_cp_sbc_after_cache_underflow(void) -{ +static int TEXT_SBC_LOC a2dp_cp_sbc_after_cache_underflow(void) { #ifdef A2DP_CP_ACCEL - cp_codec_reset = true; + cp_codec_reset = true; #endif - return 0; + return 0; } -static int a2dp_cp_sbc_mcu_decode(uint8_t *buffer, uint32_t buffer_bytes) -{ - a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame = NULL; - list_node_t *node = NULL; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - int ret, dec_ret; - struct A2DP_CP_SBC_IN_FRM_INFO_T in_info; - struct A2DP_CP_SBC_OUT_FRM_INFO_T *p_out_info = NULL; - uint8_t *out = NULL; - uint32_t out_len; - uint32_t out_frame_len; - uint32_t cp_buffer_frames_max = 0; - uint32_t check_sum = 0; +static int a2dp_cp_sbc_mcu_decode(uint8_t *buffer, uint32_t buffer_bytes) { + a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame = NULL; + list_node_t *node = NULL; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + int ret, dec_ret; + struct A2DP_CP_SBC_IN_FRM_INFO_T in_info; + struct A2DP_CP_SBC_OUT_FRM_INFO_T *p_out_info = NULL; + uint8_t *out = NULL; + uint32_t out_len; + uint32_t out_frame_len; + uint32_t cp_buffer_frames_max = 0; + uint32_t check_sum = 0; - cp_buffer_frames_max = app_bt_stream_get_dma_buffer_samples()/2; - if (cp_buffer_frames_max %(a2dp_audio_sbc_lastframe_info.frame_samples) ){ - cp_buffer_frames_max = cp_buffer_frames_max /(a2dp_audio_sbc_lastframe_info.frame_samples) +1 ; - }else{ - cp_buffer_frames_max = cp_buffer_frames_max /(a2dp_audio_sbc_lastframe_info.frame_samples) ; + cp_buffer_frames_max = app_bt_stream_get_dma_buffer_samples() / 2; + if (cp_buffer_frames_max % (a2dp_audio_sbc_lastframe_info.frame_samples)) { + cp_buffer_frames_max = + cp_buffer_frames_max / (a2dp_audio_sbc_lastframe_info.frame_samples) + + 1; + } else { + cp_buffer_frames_max = + cp_buffer_frames_max / (a2dp_audio_sbc_lastframe_info.frame_samples); + } + + out_frame_len = sizeof(*p_out_info) + buffer_bytes; + ret = a2dp_cp_decoder_init(out_frame_len, cp_buffer_frames_max * 2); + if (ret) { + TRACE_A2DP_DECODER_W("[SBC][INIT] cp_decoder_init() failed: ret=%d", ret); + set_cp_reset_flag(true); + return A2DP_DECODER_DECODE_ERROR; + } + while ((node = a2dp_audio_list_begin(list)) != NULL) { + sbc_decoder_frame = + (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_list_node(node); + + in_info.sequenceNumber = sbc_decoder_frame->sequenceNumber; + in_info.timestamp = sbc_decoder_frame->timestamp; + in_info.curSubSequenceNumber = sbc_decoder_frame->curSubSequenceNumber; + in_info.totalSubSequenceNumber = sbc_decoder_frame->totalSubSequenceNumber; + + ret = a2dp_cp_put_in_frame(&in_info, sizeof(in_info), + sbc_decoder_frame->sbc_buffer, + sbc_decoder_frame->sbc_buffer_len); + if (ret) { + TRACE_A2DP_DECODER_D("[MCU][SBC] piff !!!!!!ret: %d ", ret); + break; } + check_sum = a2dp_audio_decoder_internal_check_sum_generate( + sbc_decoder_frame->sbc_buffer, sbc_decoder_frame->sbc_buffer_len); + a2dp_audio_list_remove(list, sbc_decoder_frame); + } - out_frame_len = sizeof(*p_out_info) + buffer_bytes; - ret = a2dp_cp_decoder_init(out_frame_len, cp_buffer_frames_max * 2); - if (ret){ - TRACE_A2DP_DECODER_W("[SBC][INIT] cp_decoder_init() failed: ret=%d", ret); - set_cp_reset_flag(true); - return A2DP_DECODER_DECODE_ERROR; + ret = a2dp_cp_get_full_out_frame((void **)&out, &out_len); + if (ret) { + if (!get_in_cp_frame_cnt()) { + TRACE_A2DP_DECODER_I("[MCU][SBC] cp cache underflow list:%d in_cp:%d", + a2dp_audio_list_length(list), get_in_cp_frame_cnt()); + return A2DP_DECODER_CACHE_UNDERFLOW_ERROR; } - while ((node = a2dp_audio_list_begin(list)) != NULL) { - sbc_decoder_frame = (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_list_node(node); - - in_info.sequenceNumber = sbc_decoder_frame->sequenceNumber; - in_info.timestamp = sbc_decoder_frame->timestamp; - in_info.curSubSequenceNumber = sbc_decoder_frame->curSubSequenceNumber; - in_info.totalSubSequenceNumber = sbc_decoder_frame->totalSubSequenceNumber; - - ret = a2dp_cp_put_in_frame(&in_info, sizeof(in_info), sbc_decoder_frame->sbc_buffer, sbc_decoder_frame->sbc_buffer_len); - if (ret) { - TRACE_A2DP_DECODER_D("[MCU][SBC] piff !!!!!!ret: %d ", ret); - break; - } - check_sum = a2dp_audio_decoder_internal_check_sum_generate(sbc_decoder_frame->sbc_buffer, sbc_decoder_frame->sbc_buffer_len); - a2dp_audio_list_remove(list, sbc_decoder_frame); + if (!a2dp_audio_sysfreq_boost_running()) { + a2dp_audio_sysfreq_boost_start(1); } - + osDelay(8); ret = a2dp_cp_get_full_out_frame((void **)&out, &out_len); if (ret) { - if (!get_in_cp_frame_cnt()){ - TRACE_A2DP_DECODER_I("[MCU][SBC] cp cache underflow list:%d in_cp:%d",a2dp_audio_list_length(list), get_in_cp_frame_cnt()); - return A2DP_DECODER_CACHE_UNDERFLOW_ERROR; - } - if (!a2dp_audio_sysfreq_boost_running()){ - a2dp_audio_sysfreq_boost_start(1); - } - osDelay(8); - ret = a2dp_cp_get_full_out_frame((void **)&out, &out_len); - if (ret) { - TRACE_A2DP_DECODER_I("[MCU][SBC] cp cache underflow list:%d in_cp:%d",a2dp_audio_list_length(list), get_in_cp_frame_cnt()); - a2dp_cp_sbc_after_cache_underflow(); - return A2DP_DECODER_CACHE_UNDERFLOW_ERROR; - } + TRACE_A2DP_DECODER_I("[MCU][SBC] cp cache underflow list:%d in_cp:%d", + a2dp_audio_list_length(list), get_in_cp_frame_cnt()); + a2dp_cp_sbc_after_cache_underflow(); + return A2DP_DECODER_CACHE_UNDERFLOW_ERROR; } + } - if (out_len == 0) { - TRACE_A2DP_DECODER_I("[MCU][SBC] olz!!!%d ",__LINE__); - memset(buffer, 0, buffer_bytes); - a2dp_cp_consume_full_out_frame(); - return A2DP_DECODER_NO_ERROR; - } - if(out_len != out_frame_len){ - TRACE_A2DP_DECODER_I("[MCU][SBC] Bad out len %u (should be %u)", out_len, out_frame_len); - set_cp_reset_flag(true); - return A2DP_DECODER_DECODE_ERROR; - } - p_out_info = (struct A2DP_CP_SBC_OUT_FRM_INFO_T *)out; - if (p_out_info->pcm_len) { - a2dp_audio_sbc_lastframe_info.sequenceNumber = p_out_info->in_info.sequenceNumber; - a2dp_audio_sbc_lastframe_info.timestamp = p_out_info->in_info.timestamp; - a2dp_audio_sbc_lastframe_info.curSubSequenceNumber = p_out_info->in_info.curSubSequenceNumber; - a2dp_audio_sbc_lastframe_info.totalSubSequenceNumber = p_out_info->in_info.totalSubSequenceNumber; - a2dp_audio_sbc_lastframe_info.frame_samples = p_out_info->frame_samples; - a2dp_audio_sbc_lastframe_info.decoded_frames += p_out_info->decoded_frames; - a2dp_audio_sbc_lastframe_info.undecode_frames = - a2dp_audio_list_length(list) + a2dp_cp_get_in_frame_cnt_by_index(p_out_info->frame_idx) - 1; - a2dp_audio_sbc_lastframe_info.check_sum= check_sum?check_sum:a2dp_audio_sbc_lastframe_info.check_sum; - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_sbc_lastframe_info); - } + if (out_len == 0) { + TRACE_A2DP_DECODER_I("[MCU][SBC] olz!!!%d ", __LINE__); + memset(buffer, 0, buffer_bytes); + a2dp_cp_consume_full_out_frame(); + return A2DP_DECODER_NO_ERROR; + } + if (out_len != out_frame_len) { + TRACE_A2DP_DECODER_I("[MCU][SBC] Bad out len %u (should be %u)", out_len, + out_frame_len); + set_cp_reset_flag(true); + return A2DP_DECODER_DECODE_ERROR; + } + p_out_info = (struct A2DP_CP_SBC_OUT_FRM_INFO_T *)out; + if (p_out_info->pcm_len) { + a2dp_audio_sbc_lastframe_info.sequenceNumber = + p_out_info->in_info.sequenceNumber; + a2dp_audio_sbc_lastframe_info.timestamp = p_out_info->in_info.timestamp; + a2dp_audio_sbc_lastframe_info.curSubSequenceNumber = + p_out_info->in_info.curSubSequenceNumber; + a2dp_audio_sbc_lastframe_info.totalSubSequenceNumber = + p_out_info->in_info.totalSubSequenceNumber; + a2dp_audio_sbc_lastframe_info.frame_samples = p_out_info->frame_samples; + a2dp_audio_sbc_lastframe_info.decoded_frames += p_out_info->decoded_frames; + a2dp_audio_sbc_lastframe_info.undecode_frames = + a2dp_audio_list_length(list) + + a2dp_cp_get_in_frame_cnt_by_index(p_out_info->frame_idx) - 1; + a2dp_audio_sbc_lastframe_info.check_sum = + check_sum ? check_sum : a2dp_audio_sbc_lastframe_info.check_sum; + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_sbc_lastframe_info); + } - if (p_out_info->pcm_len == buffer_bytes) { - memcpy(buffer, p_out_info + 1, p_out_info->pcm_len); - dec_ret = A2DP_DECODER_NO_ERROR; - } else { - TRACE_A2DP_DECODER_I("[MCU][SBC] line:%d cp decoder error !!!!!!", __LINE__); - set_cp_reset_flag(true); - return A2DP_DECODER_DECODE_ERROR; - } + if (p_out_info->pcm_len == buffer_bytes) { + memcpy(buffer, p_out_info + 1, p_out_info->pcm_len); + dec_ret = A2DP_DECODER_NO_ERROR; + } else { + TRACE_A2DP_DECODER_I("[MCU][SBC] line:%d cp decoder error !!!!!!", + __LINE__); + set_cp_reset_flag(true); + return A2DP_DECODER_DECODE_ERROR; + } - ret = a2dp_cp_consume_full_out_frame(); - if(ret){ - TRACE_A2DP_DECODER_I("[MCU][SBC] cp_consume_full_out_frame failed: ret=%d", ret); - set_cp_reset_flag(true); - return A2DP_DECODER_DECODE_ERROR; - } - return dec_ret; + ret = a2dp_cp_consume_full_out_frame(); + if (ret) { + TRACE_A2DP_DECODER_I("[MCU][SBC] cp_consume_full_out_frame failed: ret=%d", + ret); + set_cp_reset_flag(true); + return A2DP_DECODER_DECODE_ERROR; + } + return dec_ret; } - #ifdef __CP_EXCEPTION_TEST__ -static bool _cp_assert = false; - int cp_assert_sbc(void) -{ - _cp_assert = true; - return 0; +static bool _cp_assert = false; +int cp_assert_sbc(void) { + _cp_assert = true; + return 0; } #endif - TEXT_SBC_LOC -int a2dp_cp_sbc_cp_decode(void) -{ - int ret = 0; - enum CP_EMPTY_OUT_FRM_T out_frm_st; - uint8_t *out = NULL; - uint32_t out_len = 0; - uint8_t *dec_start = NULL; - uint32_t dec_len = 0; - struct A2DP_CP_SBC_IN_FRM_INFO_T *p_in_info = NULL; - struct A2DP_CP_SBC_OUT_FRM_INFO_T *p_out_info = NULL; - uint8_t *in_buf = NULL; - uint32_t in_len = 0; - uint16_t bytes_parsed = 0; - float sbc_subbands_gain[8]={1,1,1,1,1,1,1,1}; - btif_sbc_decoder_t *sbc_decoder = NULL; - btif_sbc_pcm_data_t *pcm_data = NULL; - bt_status_t decoder_err = 0; - int error = 0; +int a2dp_cp_sbc_cp_decode(void) { + int ret = 0; + enum CP_EMPTY_OUT_FRM_T out_frm_st; + uint8_t *out = NULL; + uint32_t out_len = 0; + uint8_t *dec_start = NULL; + uint32_t dec_len = 0; + struct A2DP_CP_SBC_IN_FRM_INFO_T *p_in_info = NULL; + struct A2DP_CP_SBC_OUT_FRM_INFO_T *p_out_info = NULL; + uint8_t *in_buf = NULL; + uint32_t in_len = 0; + uint16_t bytes_parsed = 0; + float sbc_subbands_gain[8] = {1, 1, 1, 1, 1, 1, 1, 1}; + btif_sbc_decoder_t *sbc_decoder = NULL; + btif_sbc_pcm_data_t *pcm_data = NULL; + bt_status_t decoder_err = 0; + int error = 0; - if (cp_codec_reset) { - cp_codec_reset = false; - sbc_codec_init(); - } - - -#ifdef __CP_EXCEPTION_TEST__ - if (_cp_assert){ - _cp_assert = false; - *(int*) 0 = 1; - //ASSERT_A2DP_DECODER(0, "ASSERT_A2DP_DECODER %s %d", __func__, __LINE__); - } -#endif - - sbc_decoder = a2dp_audio_sbc_decoder.sbc_decoder; - pcm_data = a2dp_audio_sbc_decoder.pcm_data; - - out_frm_st = a2dp_cp_get_emtpy_out_frame((void **)&out, &out_len); - if (out_frm_st != CP_EMPTY_OUT_FRM_OK && out_frm_st != CP_EMPTY_OUT_FRM_WORKING) { - return 1; - } - - ASSERT_A2DP_DECODER(out_len > sizeof(*p_out_info), "[CP][SBC] Bad out_len %u (should > %u)", out_len, sizeof(*p_out_info)); - - p_out_info = (struct A2DP_CP_SBC_OUT_FRM_INFO_T *)out; - if (out_frm_st == CP_EMPTY_OUT_FRM_OK) { - p_out_info->pcm_len = 0; - p_out_info->decoded_frames = 0; - } - ASSERT_A2DP_DECODER(out_len > sizeof(*p_out_info) + p_out_info->pcm_len, "[CP][SBC] Bad out_len %u (should > %u + %u)", out_len, sizeof(*p_out_info), p_out_info->pcm_len); - - dec_start = (uint8_t *)(p_out_info + 1) + p_out_info->pcm_len; - dec_len = out_len - (dec_start - (uint8_t *)out); - - pcm_data->data = dec_start; - pcm_data->dataLen = 0; - error = 0; - - while (pcm_data->dataLen < dec_len && error == 0) { - ret = a2dp_cp_get_in_frame((void **)&in_buf, &in_len); - if (ret) { - p_out_info->pcm_len += pcm_data->dataLen; - return 4; - } - ASSERT_A2DP_DECODER(in_len > sizeof(*p_in_info), "%s: Bad in_len %u (should > %u)", __func__, in_len, sizeof(*p_in_info)); - - p_in_info = (struct A2DP_CP_SBC_IN_FRM_INFO_T *)in_buf; - in_buf += sizeof(*p_in_info); - in_len -= sizeof(*p_in_info); - - decoder_err = btif_sbc_decode_frames(sbc_decoder, in_buf, in_len, - &bytes_parsed, - pcm_data, - dec_len, - sbc_subbands_gain); - switch (decoder_err) - { - case BT_STS_SUCCESS: - case BT_STS_CONTINUE: - break; - case BT_STS_NO_RESOURCES: - error = 1; - ASSERT_A2DP_DECODER(0, "sbc_decode BT_STS_NO_RESOURCES pcm has no more buffer, i think can't reach here"); - break; - case BT_STS_FAILED: - default: - error = 1; - sbc_codec_init(); - break; - } - - memcpy(&p_out_info->in_info, p_in_info, sizeof(*p_in_info)); - p_out_info->decoded_frames++; - p_out_info->frame_samples = sbc_decoder->maxPcmLen/4; - p_out_info->frame_idx = a2dp_cp_get_in_frame_index(); - - ret = a2dp_cp_consume_in_frame(); - ASSERT_A2DP_DECODER(ret == 0, "%s: a2dp_cp_consume_in_frame() failed: ret=%d", __func__, ret); - } - - p_out_info->pcm_len += pcm_data->dataLen; - - if (error || out_len <= sizeof(*p_out_info) + p_out_info->pcm_len) { - ret = a2dp_cp_consume_emtpy_out_frame(); - ASSERT_A2DP_DECODER(ret == 0, "%s: a2dp_cp_consume_emtpy_out_frame() failed: ret=%d", __func__, ret); - } - - return error; -} -#endif - -static int a2dp_audio_sbc_list_checker(void) -{ - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame = NULL; - int cnt = 0; - - do { - sbc_decoder_frame = (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_sbc_subframe_malloc(SBC_LIST_SAMPLES); - if (sbc_decoder_frame){ - a2dp_audio_list_append(list, sbc_decoder_frame); - } - cnt++; - }while(sbc_decoder_frame && cnt < SBC_MTU_LIMITER); - - do { - node = a2dp_audio_list_begin(list); - if (node){ - sbc_decoder_frame = (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_list_node(node); - a2dp_audio_list_remove(list, sbc_decoder_frame); - } - }while(node); - - TRACE_A2DP_DECODER_I("[SBC][INIT] cnt:%d list:%d", cnt, a2dp_audio_list_length(list)); - - return 0; -} - -int a2dp_audio_sbc_init(A2DP_AUDIO_OUTPUT_CONFIG_T *config, void *context) -{ - TRACE_A2DP_DECODER_I("[SBC][INIT]"); - - a2dp_audio_context_p = (A2DP_AUDIO_CONTEXT_T *)context; - - a2dp_audio_sbc_header_parser_init(); - memset(&a2dp_audio_sbc_lastframe_info, 0, sizeof(A2DP_AUDIO_DECODER_LASTFRAME_INFO_T)); - a2dp_audio_sbc_lastframe_info.stream_info = *config; - a2dp_audio_sbc_lastframe_info.frame_samples= SBC_LIST_SAMPLES; - a2dp_audio_sbc_lastframe_info.list_samples = SBC_LIST_SAMPLES; - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_sbc_lastframe_info); - - ASSERT_A2DP_DECODER(a2dp_audio_context_p->dest_packet_mut < SBC_MTU_LIMITER, "%s MTU OVERFLOW:%u/%u", __func__, a2dp_audio_context_p->dest_packet_mut, SBC_MTU_LIMITER); - - a2dp_audio_sbc_decoder.sbc_decoder = (btif_sbc_decoder_t *)a2dp_audio_heap_malloc(sizeof(btif_sbc_decoder_t)); - a2dp_audio_sbc_decoder.pcm_data = (btif_sbc_pcm_data_t *)a2dp_audio_heap_malloc(sizeof(btif_sbc_pcm_data_t)); - a2dp_audio_sbc_decoder_preparse = (btif_sbc_decoder_t *)a2dp_audio_heap_malloc(sizeof(btif_sbc_decoder_t)); -#ifdef A2DP_CP_ACCEL - int ret; - cp_codec_reset = true; - ret = a2dp_cp_init(a2dp_cp_sbc_cp_decode, CP_PROC_DELAY_2_FRAMES); - ASSERT_A2DP_DECODER(ret == 0, "%s: a2dp_cp_init() failed: ret=%d", __func__, ret); -#else + if (cp_codec_reset) { + cp_codec_reset = false; sbc_codec_init(); + } + +#ifdef __CP_EXCEPTION_TEST__ + if (_cp_assert) { + _cp_assert = false; + *(int *)0 = 1; + // ASSERT_A2DP_DECODER(0, "ASSERT_A2DP_DECODER %s %d", __func__, __LINE__); + } #endif - a2dp_audio_sbc_list_checker(); - sbc_chnl_mode_mono = false; - return A2DP_DECODER_NO_ERROR; + + sbc_decoder = a2dp_audio_sbc_decoder.sbc_decoder; + pcm_data = a2dp_audio_sbc_decoder.pcm_data; + + out_frm_st = a2dp_cp_get_emtpy_out_frame((void **)&out, &out_len); + if (out_frm_st != CP_EMPTY_OUT_FRM_OK && + out_frm_st != CP_EMPTY_OUT_FRM_WORKING) { + return 1; + } + + ASSERT_A2DP_DECODER(out_len > sizeof(*p_out_info), + "[CP][SBC] Bad out_len %u (should > %u)", out_len, + sizeof(*p_out_info)); + + p_out_info = (struct A2DP_CP_SBC_OUT_FRM_INFO_T *)out; + if (out_frm_st == CP_EMPTY_OUT_FRM_OK) { + p_out_info->pcm_len = 0; + p_out_info->decoded_frames = 0; + } + ASSERT_A2DP_DECODER(out_len > sizeof(*p_out_info) + p_out_info->pcm_len, + "[CP][SBC] Bad out_len %u (should > %u + %u)", out_len, + sizeof(*p_out_info), p_out_info->pcm_len); + + dec_start = (uint8_t *)(p_out_info + 1) + p_out_info->pcm_len; + dec_len = out_len - (dec_start - (uint8_t *)out); + + pcm_data->data = dec_start; + pcm_data->dataLen = 0; + error = 0; + + while (pcm_data->dataLen < dec_len && error == 0) { + ret = a2dp_cp_get_in_frame((void **)&in_buf, &in_len); + if (ret) { + p_out_info->pcm_len += pcm_data->dataLen; + return 4; + } + ASSERT_A2DP_DECODER(in_len > sizeof(*p_in_info), + "%s: Bad in_len %u (should > %u)", __func__, in_len, + sizeof(*p_in_info)); + + p_in_info = (struct A2DP_CP_SBC_IN_FRM_INFO_T *)in_buf; + in_buf += sizeof(*p_in_info); + in_len -= sizeof(*p_in_info); + + decoder_err = + btif_sbc_decode_frames(sbc_decoder, in_buf, in_len, &bytes_parsed, + pcm_data, dec_len, sbc_subbands_gain); + switch (decoder_err) { + case BT_STS_SUCCESS: + case BT_STS_CONTINUE: + break; + case BT_STS_NO_RESOURCES: + error = 1; + ASSERT_A2DP_DECODER(0, "sbc_decode BT_STS_NO_RESOURCES pcm has no more " + "buffer, i think can't reach here"); + break; + case BT_STS_FAILED: + default: + error = 1; + sbc_codec_init(); + break; + } + + memcpy(&p_out_info->in_info, p_in_info, sizeof(*p_in_info)); + p_out_info->decoded_frames++; + p_out_info->frame_samples = sbc_decoder->maxPcmLen / 4; + p_out_info->frame_idx = a2dp_cp_get_in_frame_index(); + + ret = a2dp_cp_consume_in_frame(); + ASSERT_A2DP_DECODER(ret == 0, + "%s: a2dp_cp_consume_in_frame() failed: ret=%d", + __func__, ret); + } + + p_out_info->pcm_len += pcm_data->dataLen; + + if (error || out_len <= sizeof(*p_out_info) + p_out_info->pcm_len) { + ret = a2dp_cp_consume_emtpy_out_frame(); + ASSERT_A2DP_DECODER(ret == 0, + "%s: a2dp_cp_consume_emtpy_out_frame() failed: ret=%d", + __func__, ret); + } + + return error; +} +#endif + +static int a2dp_audio_sbc_list_checker(void) { + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame = NULL; + int cnt = 0; + + do { + sbc_decoder_frame = + (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_sbc_subframe_malloc( + SBC_LIST_SAMPLES); + if (sbc_decoder_frame) { + a2dp_audio_list_append(list, sbc_decoder_frame); + } + cnt++; + } while (sbc_decoder_frame && cnt < SBC_MTU_LIMITER); + + do { + node = a2dp_audio_list_begin(list); + if (node) { + sbc_decoder_frame = + (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_list_node(node); + a2dp_audio_list_remove(list, sbc_decoder_frame); + } + } while (node); + + TRACE_A2DP_DECODER_I("[SBC][INIT] cnt:%d list:%d", cnt, + a2dp_audio_list_length(list)); + + return 0; } -int a2dp_audio_sbc_deinit(void) -{ +int a2dp_audio_sbc_init(A2DP_AUDIO_OUTPUT_CONFIG_T *config, void *context) { + TRACE_A2DP_DECODER_I("[SBC][INIT]"); + + a2dp_audio_context_p = (A2DP_AUDIO_CONTEXT_T *)context; + + a2dp_audio_sbc_header_parser_init(); + memset(&a2dp_audio_sbc_lastframe_info, 0, + sizeof(A2DP_AUDIO_DECODER_LASTFRAME_INFO_T)); + a2dp_audio_sbc_lastframe_info.stream_info = *config; + a2dp_audio_sbc_lastframe_info.frame_samples = SBC_LIST_SAMPLES; + a2dp_audio_sbc_lastframe_info.list_samples = SBC_LIST_SAMPLES; + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_sbc_lastframe_info); + + ASSERT_A2DP_DECODER(a2dp_audio_context_p->dest_packet_mut < SBC_MTU_LIMITER, + "%s MTU OVERFLOW:%u/%u", __func__, + a2dp_audio_context_p->dest_packet_mut, SBC_MTU_LIMITER); + + a2dp_audio_sbc_decoder.sbc_decoder = + (btif_sbc_decoder_t *)a2dp_audio_heap_malloc(sizeof(btif_sbc_decoder_t)); + a2dp_audio_sbc_decoder.pcm_data = + (btif_sbc_pcm_data_t *)a2dp_audio_heap_malloc( + sizeof(btif_sbc_pcm_data_t)); + a2dp_audio_sbc_decoder_preparse = + (btif_sbc_decoder_t *)a2dp_audio_heap_malloc(sizeof(btif_sbc_decoder_t)); #ifdef A2DP_CP_ACCEL - a2dp_cp_deinit(); + int ret; + cp_codec_reset = true; + ret = a2dp_cp_init(a2dp_cp_sbc_cp_decode, CP_PROC_DELAY_2_FRAMES); + ASSERT_A2DP_DECODER(ret == 0, "%s: a2dp_cp_init() failed: ret=%d", __func__, + ret); +#else + sbc_codec_init(); #endif - a2dp_audio_heap_free(a2dp_audio_sbc_decoder_preparse); - a2dp_audio_heap_free(a2dp_audio_sbc_decoder.sbc_decoder); - a2dp_audio_heap_free(a2dp_audio_sbc_decoder.pcm_data); - - TRACE_A2DP_DECODER_I("[SBC][DEINIT]"); - - return A2DP_DECODER_NO_ERROR; + a2dp_audio_sbc_list_checker(); + sbc_chnl_mode_mono = false; + return A2DP_DECODER_NO_ERROR; } -int a2dp_audio_sbc_mcu_decode_frame(uint8_t *buffer, uint32_t buffer_bytes) -{ - bt_status_t ret = BT_STS_SUCCESS; - uint16_t bytes_parsed = 0; - float sbc_subbands_gain[8]={1,1,1,1,1,1,1,1}; - btif_sbc_decoder_t *sbc_decoder = NULL; - btif_sbc_pcm_data_t *pcm_data = NULL; - uint16_t frame_pcmbyte = 0; - uint16_t pcm_output_byte = 0; - bool cache_underflow = false; +int a2dp_audio_sbc_deinit(void) { +#ifdef A2DP_CP_ACCEL + a2dp_cp_deinit(); +#endif + a2dp_audio_heap_free(a2dp_audio_sbc_decoder_preparse); + a2dp_audio_heap_free(a2dp_audio_sbc_decoder.sbc_decoder); + a2dp_audio_heap_free(a2dp_audio_sbc_decoder.pcm_data); - sbc_decoder = a2dp_audio_sbc_decoder.sbc_decoder; - pcm_data = a2dp_audio_sbc_decoder.pcm_data; - frame_pcmbyte = sbc_decoder->maxPcmLen; + TRACE_A2DP_DECODER_I("[SBC][DEINIT]"); + return A2DP_DECODER_NO_ERROR; +} - a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame = NULL; - list_node_t *node = NULL; +int a2dp_audio_sbc_mcu_decode_frame(uint8_t *buffer, uint32_t buffer_bytes) { + bt_status_t ret = BT_STS_SUCCESS; + uint16_t bytes_parsed = 0; + float sbc_subbands_gain[8] = {1, 1, 1, 1, 1, 1, 1, 1}; + btif_sbc_decoder_t *sbc_decoder = NULL; + btif_sbc_pcm_data_t *pcm_data = NULL; + uint16_t frame_pcmbyte = 0; + uint16_t pcm_output_byte = 0; + bool cache_underflow = false; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + sbc_decoder = a2dp_audio_sbc_decoder.sbc_decoder; + pcm_data = a2dp_audio_sbc_decoder.pcm_data; + frame_pcmbyte = sbc_decoder->maxPcmLen; - pcm_data->data = buffer; - pcm_data->dataLen = 0; + a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame = NULL; + list_node_t *node = NULL; - TRACE_A2DP_DECODER_D("[MCU][SBC] size:%d", a2dp_audio_list_length(list)); + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - for (pcm_output_byte = 0; pcm_output_bytedata = buffer; + pcm_data->dataLen = 0; - if (node){ - uint32_t lock; + TRACE_A2DP_DECODER_D("[MCU][SBC] size:%d", a2dp_audio_list_length(list)); - sbc_decoder_frame = (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_list_node(node); + for (pcm_output_byte = 0; pcm_output_byte < buffer_bytes; + pcm_output_byte += frame_pcmbyte) { + node = a2dp_audio_list_begin(list); - lock = int_lock(); - ret = btif_sbc_decode_frames(sbc_decoder, sbc_decoder_frame->sbc_buffer, sbc_decoder_frame->sbc_buffer_len, - &bytes_parsed, - pcm_data, - buffer_bytes, - sbc_subbands_gain); - int_unlock(lock); - TRACE_A2DP_DECODER_D("[MCU][SBC] seq:%d/%d/%d len:%d ret:%d used:%d", - sbc_decoder_frame->curSubSequenceNumber, - sbc_decoder_frame->totalSubSequenceNumber, - sbc_decoder_frame->sequenceNumber, - sbc_decoder_frame->sbc_buffer_len, - ret, - bytes_parsed); + if (node) { + uint32_t lock; - a2dp_audio_sbc_lastframe_info.sequenceNumber = sbc_decoder_frame->sequenceNumber; - a2dp_audio_sbc_lastframe_info.timestamp = sbc_decoder_frame->timestamp; - a2dp_audio_sbc_lastframe_info.curSubSequenceNumber = sbc_decoder_frame->curSubSequenceNumber; - a2dp_audio_sbc_lastframe_info.totalSubSequenceNumber = sbc_decoder_frame->totalSubSequenceNumber; - a2dp_audio_sbc_lastframe_info.frame_samples = sbc_decoder->maxPcmLen/4; - a2dp_audio_sbc_lastframe_info.decoded_frames++; - a2dp_audio_sbc_lastframe_info.undecode_frames = a2dp_audio_list_length(list)-1; - a2dp_audio_sbc_lastframe_info.check_sum = a2dp_audio_decoder_internal_check_sum_generate(sbc_decoder_frame->sbc_buffer, sbc_decoder_frame->sbc_buffer_len); - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_sbc_lastframe_info); - a2dp_audio_list_remove(list, sbc_decoder_frame); - switch (ret) - { - case BT_STS_SUCCESS: - if (pcm_data->dataLen != buffer_bytes){ - TRACE_A2DP_DECODER_W("[MCU][SBC] WARNING pcm buff mismatch %d/%d", pcm_data->dataLen, buffer_bytes); - } - if (pcm_data->dataLen == buffer_bytes){ - if (pcm_output_byte+frame_pcmbyte != buffer_bytes){ - TRACE_A2DP_DECODER_W("[MCU][SBC]WARNING loop not break %d/%d frame_pcm:%d", pcm_output_byte, buffer_bytes, frame_pcmbyte); - goto exit; - } - } - break; - case BT_STS_CONTINUE: - continue; - break; - case BT_STS_NO_RESOURCES: - ASSERT_A2DP_DECODER(0, "sbc_decode BT_STS_NO_RESOURCES pcm has no more buffer, i think can't reach here"); - break; - case BT_STS_FAILED: - default: - sbc_codec_init(); - goto exit; - } - }else{ - TRACE_A2DP_DECODER_W("[MCU][SBC] A2DP PACKET CACHE UNDERFLOW"); - ret = BT_STS_FAILED; - cache_underflow = true; + sbc_decoder_frame = + (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_list_node(node); + + lock = int_lock(); + ret = btif_sbc_decode_frames(sbc_decoder, sbc_decoder_frame->sbc_buffer, + sbc_decoder_frame->sbc_buffer_len, + &bytes_parsed, pcm_data, buffer_bytes, + sbc_subbands_gain); + int_unlock(lock); + TRACE_A2DP_DECODER_D("[MCU][SBC] seq:%d/%d/%d len:%d ret:%d used:%d", + sbc_decoder_frame->curSubSequenceNumber, + sbc_decoder_frame->totalSubSequenceNumber, + sbc_decoder_frame->sequenceNumber, + sbc_decoder_frame->sbc_buffer_len, ret, + bytes_parsed); + + a2dp_audio_sbc_lastframe_info.sequenceNumber = + sbc_decoder_frame->sequenceNumber; + a2dp_audio_sbc_lastframe_info.timestamp = sbc_decoder_frame->timestamp; + a2dp_audio_sbc_lastframe_info.curSubSequenceNumber = + sbc_decoder_frame->curSubSequenceNumber; + a2dp_audio_sbc_lastframe_info.totalSubSequenceNumber = + sbc_decoder_frame->totalSubSequenceNumber; + a2dp_audio_sbc_lastframe_info.frame_samples = sbc_decoder->maxPcmLen / 4; + a2dp_audio_sbc_lastframe_info.decoded_frames++; + a2dp_audio_sbc_lastframe_info.undecode_frames = + a2dp_audio_list_length(list) - 1; + a2dp_audio_sbc_lastframe_info.check_sum = + a2dp_audio_decoder_internal_check_sum_generate( + sbc_decoder_frame->sbc_buffer, sbc_decoder_frame->sbc_buffer_len); + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_sbc_lastframe_info); + a2dp_audio_list_remove(list, sbc_decoder_frame); + switch (ret) { + case BT_STS_SUCCESS: + if (pcm_data->dataLen != buffer_bytes) { + TRACE_A2DP_DECODER_W("[MCU][SBC] WARNING pcm buff mismatch %d/%d", + pcm_data->dataLen, buffer_bytes); + } + if (pcm_data->dataLen == buffer_bytes) { + if (pcm_output_byte + frame_pcmbyte != buffer_bytes) { + TRACE_A2DP_DECODER_W( + "[MCU][SBC]WARNING loop not break %d/%d frame_pcm:%d", + pcm_output_byte, buffer_bytes, frame_pcmbyte); goto exit; + } } - + break; + case BT_STS_CONTINUE: + continue; + break; + case BT_STS_NO_RESOURCES: + ASSERT_A2DP_DECODER(0, "sbc_decode BT_STS_NO_RESOURCES pcm has no more " + "buffer, i think can't reach here"); + break; + case BT_STS_FAILED: + default: + sbc_codec_init(); + goto exit; + } + } else { + TRACE_A2DP_DECODER_W("[MCU][SBC] A2DP PACKET CACHE UNDERFLOW"); + ret = BT_STS_FAILED; + cache_underflow = true; + goto exit; } + } exit: - if (cache_underflow){ - TRACE_A2DP_DECODER_W("[MCU][SBC] A2DP PACKET CACHE UNDERFLOW need add some process"); - a2dp_audio_sbc_lastframe_info.undecode_frames = 0; - a2dp_audio_sbc_lastframe_info.check_sum = 0; - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_sbc_lastframe_info); - ret = A2DP_DECODER_CACHE_UNDERFLOW_ERROR; - } - return ret; + if (cache_underflow) { + TRACE_A2DP_DECODER_W( + "[MCU][SBC] A2DP PACKET CACHE UNDERFLOW need add some process"); + a2dp_audio_sbc_lastframe_info.undecode_frames = 0; + a2dp_audio_sbc_lastframe_info.check_sum = 0; + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_sbc_lastframe_info); + ret = A2DP_DECODER_CACHE_UNDERFLOW_ERROR; + } + return ret; } -int a2dp_audio_sbc_decode_frame(uint8_t *buffer, uint32_t buffer_bytes) -{ - int nRet = 0; - if (sbc_chnl_mode_mono){ - int i = 0; - int16_t *src = NULL,*dest = NULL; +int a2dp_audio_sbc_decode_frame(uint8_t *buffer, uint32_t buffer_bytes) { + int nRet = 0; + if (sbc_chnl_mode_mono) { + int i = 0; + int16_t *src = NULL, *dest = NULL; #ifdef A2DP_CP_ACCEL - nRet = a2dp_cp_sbc_mcu_decode(buffer, buffer_bytes/2); + nRet = a2dp_cp_sbc_mcu_decode(buffer, buffer_bytes / 2); #else - nRet = a2dp_audio_sbc_mcu_decode_frame(buffer, buffer_bytes/2); + nRet = a2dp_audio_sbc_mcu_decode_frame(buffer, buffer_bytes / 2); #endif - i = buffer_bytes / 2; - dest = (int16_t *)buffer + i - 1; - i = i / 2; - src = (int16_t *)buffer + i - 1; - for (; i>=0; i--){ - *dest = *src; - dest--; - *dest = *src; - dest--; - src--; - } - }else{ + i = buffer_bytes / 2; + dest = (int16_t *)buffer + i - 1; + i = i / 2; + src = (int16_t *)buffer + i - 1; + for (; i >= 0; i--) { + *dest = *src; + dest--; + *dest = *src; + dest--; + src--; + } + } else { #ifdef A2DP_CP_ACCEL - nRet = a2dp_cp_sbc_mcu_decode(buffer, buffer_bytes); + nRet = a2dp_cp_sbc_mcu_decode(buffer, buffer_bytes); #else - nRet = a2dp_audio_sbc_mcu_decode_frame(buffer, buffer_bytes); + nRet = a2dp_audio_sbc_mcu_decode_frame(buffer, buffer_bytes); #endif - } - return nRet; + } + return nRet; } -int a2dp_audio_sbc_preparse_packet(btif_media_header_t * header, uint8_t *buffer, uint32_t buffer_bytes) -{ - uint16_t bytes_parsed = 0; - uint32_t frame_num = 0; - uint8_t *parser_p = buffer; +int a2dp_audio_sbc_preparse_packet(btif_media_header_t *header, uint8_t *buffer, + uint32_t buffer_bytes) { + uint16_t bytes_parsed = 0; + uint32_t frame_num = 0; + uint8_t *parser_p = buffer; - frame_num = *parser_p; - parser_p++; - buffer_bytes--; + frame_num = *parser_p; + parser_p++; + buffer_bytes--; - // TODO: Remove the following sbc init and decode codes. They might conflict with the calls - // during CP process. CP process is triggered by audioflinger PCM callback. + // TODO: Remove the following sbc init and decode codes. They might conflict + // with the calls + // during CP process. CP process is triggered by audioflinger PCM + // callback. + if (*parser_p != 0x9c) { + TRACE_A2DP_DECODER_I("[SBC][PRE] ERROR SBC FRAME !!! frame_num:%d", + frame_num); + DUMP8("%02x ", parser_p, 12); + } else { + btif_sbc_decode_frames_parser(a2dp_audio_sbc_decoder_preparse, parser_p, + buffer_bytes, &bytes_parsed); + TRACE_A2DP_DECODER_I( + "[SBC][PRE] seq:%d tStmp:%08x smpR:%d ch:%d len:%d", + header->sequenceNumber, header->timestamp, + a2dp_audio_sbc_decoder_preparse->streamInfo.sampleFreq, + a2dp_audio_sbc_decoder_preparse->streamInfo.channelMode, + a2dp_audio_sbc_decoder_preparse->maxPcmLen); + TRACE_A2DP_DECODER_I("[SBC][PRE] frmN:%d par:%d/%d", frame_num, + buffer_bytes, bytes_parsed); - if (*parser_p != 0x9c){ - TRACE_A2DP_DECODER_I("[SBC][PRE] ERROR SBC FRAME !!! frame_num:%d", frame_num); - DUMP8("%02x ", parser_p, 12); - }else{ - btif_sbc_decode_frames_parser(a2dp_audio_sbc_decoder_preparse,parser_p, buffer_bytes, &bytes_parsed); - TRACE_A2DP_DECODER_I("[SBC][PRE] seq:%d tStmp:%08x smpR:%d ch:%d len:%d", - header->sequenceNumber, - header->timestamp, - a2dp_audio_sbc_decoder_preparse->streamInfo.sampleFreq, - a2dp_audio_sbc_decoder_preparse->streamInfo.channelMode, - a2dp_audio_sbc_decoder_preparse->maxPcmLen); - TRACE_A2DP_DECODER_I("[SBC][PRE] frmN:%d par:%d/%d", frame_num, buffer_bytes, bytes_parsed); - - a2dp_audio_sbc_lastframe_info.sequenceNumber = header->sequenceNumber; - a2dp_audio_sbc_lastframe_info.timestamp = header->timestamp; - a2dp_audio_sbc_lastframe_info.curSubSequenceNumber = 0; - a2dp_audio_sbc_lastframe_info.totalSubSequenceNumber = frame_num; - a2dp_audio_sbc_lastframe_info.frame_samples = a2dp_audio_sbc_decoder_preparse->maxPcmLen/4; - a2dp_audio_sbc_lastframe_info.list_samples = SBC_LIST_SAMPLES; - a2dp_audio_sbc_lastframe_info.decoded_frames = 0; - a2dp_audio_sbc_lastframe_info.undecode_frames = 0; - a2dp_audio_decoder_internal_lastframe_info_set(&a2dp_audio_sbc_lastframe_info); - } - if (a2dp_audio_sbc_decoder_preparse->streamInfo.channelMode == BTIF_SBC_CHNL_MODE_MONO){ - sbc_chnl_mode_mono = true; - } - return A2DP_DECODER_NO_ERROR; + a2dp_audio_sbc_lastframe_info.sequenceNumber = header->sequenceNumber; + a2dp_audio_sbc_lastframe_info.timestamp = header->timestamp; + a2dp_audio_sbc_lastframe_info.curSubSequenceNumber = 0; + a2dp_audio_sbc_lastframe_info.totalSubSequenceNumber = frame_num; + a2dp_audio_sbc_lastframe_info.frame_samples = + a2dp_audio_sbc_decoder_preparse->maxPcmLen / 4; + a2dp_audio_sbc_lastframe_info.list_samples = SBC_LIST_SAMPLES; + a2dp_audio_sbc_lastframe_info.decoded_frames = 0; + a2dp_audio_sbc_lastframe_info.undecode_frames = 0; + a2dp_audio_decoder_internal_lastframe_info_set( + &a2dp_audio_sbc_lastframe_info); + } + if (a2dp_audio_sbc_decoder_preparse->streamInfo.channelMode == + BTIF_SBC_CHNL_MODE_MONO) { + sbc_chnl_mode_mono = true; + } + return A2DP_DECODER_NO_ERROR; } - -static int a2dp_audio_sbc_header_parser_init(void) -{ - a2dp_audio_sbc_decoder_config.auto_synchronize_support = true; - sbc_decoder_last_valid_frame_ready = false; - memset(&sbc_decoder_last_valid_frame, 0, sizeof(sbc_decoder_last_valid_frame)); - return 0; +static int a2dp_audio_sbc_header_parser_init(void) { + a2dp_audio_sbc_decoder_config.auto_synchronize_support = true; + sbc_decoder_last_valid_frame_ready = false; + memset(&sbc_decoder_last_valid_frame, 0, + sizeof(sbc_decoder_last_valid_frame)); + return 0; } -static int a2dp_audio_sbc_packet_recover_save_last(btif_media_header_t *sbc_decoder_frame) -{ - sbc_decoder_last_valid_frame = *sbc_decoder_frame; - sbc_decoder_last_valid_frame_ready = true; - return 0; +static int a2dp_audio_sbc_packet_recover_save_last( + btif_media_header_t *sbc_decoder_frame) { + sbc_decoder_last_valid_frame = *sbc_decoder_frame; + sbc_decoder_last_valid_frame_ready = true; + return 0; } -static int a2dp_audio_sbc_packet_recover_find_missing(btif_media_header_t *sbc_decoder_frame, uint8_t frame_cnt) -{ - uint16_t diff_seq = 0; - uint32_t diff_timestamp = 0; - uint32_t diff = 0; - uint32_t need_recover_pkt = 0; - - if (!sbc_decoder_last_valid_frame_ready){ - return need_recover_pkt; - } - - diff_seq = a2dp_audio_get_passed(sbc_decoder_frame->sequenceNumber, sbc_decoder_last_valid_frame.sequenceNumber, UINT16_MAX); - diff_timestamp = a2dp_audio_get_passed(sbc_decoder_frame->timestamp, sbc_decoder_last_valid_frame.timestamp, UINT32_MAX); - if (diff_seq > 1){ - diff = diff_timestamp/diff_seq; - if (diff%SBC_LIST_SAMPLES == 0){ - need_recover_pkt = diff_timestamp/SBC_LIST_SAMPLES; - if (need_recover_pkt > frame_cnt){ - need_recover_pkt -= frame_cnt; - } - }else{ - diff_seq--; - need_recover_pkt = diff_seq * frame_cnt; - } - TRACE_A2DP_DECODER_W("[SBC][INPUT][PLC] seq:%d/%d stmp:%d/%d", sbc_decoder_frame->sequenceNumber, sbc_decoder_last_valid_frame.sequenceNumber, - sbc_decoder_frame->timestamp, sbc_decoder_last_valid_frame.timestamp); - TRACE_A2DP_DECODER_W("[SBC][INPUT][PLC] diff_seq:%d diff_stmp:%d diff:%d missing:%d", diff_seq, diff_timestamp, diff, need_recover_pkt); - } +static int a2dp_audio_sbc_packet_recover_find_missing( + btif_media_header_t *sbc_decoder_frame, uint8_t frame_cnt) { + uint16_t diff_seq = 0; + uint32_t diff_timestamp = 0; + uint32_t diff = 0; + uint32_t need_recover_pkt = 0; + if (!sbc_decoder_last_valid_frame_ready) { return need_recover_pkt; + } + + diff_seq = a2dp_audio_get_passed(sbc_decoder_frame->sequenceNumber, + sbc_decoder_last_valid_frame.sequenceNumber, + UINT16_MAX); + diff_timestamp = + a2dp_audio_get_passed(sbc_decoder_frame->timestamp, + sbc_decoder_last_valid_frame.timestamp, UINT32_MAX); + if (diff_seq > 1) { + diff = diff_timestamp / diff_seq; + if (diff % SBC_LIST_SAMPLES == 0) { + need_recover_pkt = diff_timestamp / SBC_LIST_SAMPLES; + if (need_recover_pkt > frame_cnt) { + need_recover_pkt -= frame_cnt; + } + } else { + diff_seq--; + need_recover_pkt = diff_seq * frame_cnt; + } + TRACE_A2DP_DECODER_W("[SBC][INPUT][PLC] seq:%d/%d stmp:%d/%d", + sbc_decoder_frame->sequenceNumber, + sbc_decoder_last_valid_frame.sequenceNumber, + sbc_decoder_frame->timestamp, + sbc_decoder_last_valid_frame.timestamp); + TRACE_A2DP_DECODER_W( + "[SBC][INPUT][PLC] diff_seq:%d diff_stmp:%d diff:%d missing:%d", + diff_seq, diff_timestamp, diff, need_recover_pkt); + } + + return need_recover_pkt; } -static int a2dp_audio_sbc_packet_recover_proc(btif_media_header_t *sbc_decoder_frame, a2dp_audio_sbc_decoder_frame_t *sbc_raw_frame, uint8_t frame_cnt) -{ - int nRet = A2DP_DECODER_NO_ERROR; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - int missing_pkt_cnt = 0; - missing_pkt_cnt = a2dp_audio_sbc_packet_recover_find_missing(sbc_decoder_frame, frame_cnt); - if (missing_pkt_cnt && sbc_raw_frame && - (a2dp_audio_list_length(list)+missing_pkt_cnt) < sbc_mtu_limiter){ - for (uint8_t i =0; isbc_buffer_len); - if (!frame_p){ - nRet = A2DP_DECODER_MEMORY_ERROR; - goto exit; - } - frame_p->sequenceNumber = UINT16_MAX; - frame_p->timestamp = UINT32_MAX; - memcpy(frame_p->sbc_buffer, sbc_raw_frame->sbc_buffer, sbc_raw_frame->sbc_buffer_len); - frame_p->sbc_buffer_len = sbc_raw_frame->sbc_buffer_len; - a2dp_audio_list_append(list, frame_p); - } +static int a2dp_audio_sbc_packet_recover_proc( + btif_media_header_t *sbc_decoder_frame, + a2dp_audio_sbc_decoder_frame_t *sbc_raw_frame, uint8_t frame_cnt) { + int nRet = A2DP_DECODER_NO_ERROR; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + int missing_pkt_cnt = 0; + missing_pkt_cnt = + a2dp_audio_sbc_packet_recover_find_missing(sbc_decoder_frame, frame_cnt); + if (missing_pkt_cnt && sbc_raw_frame && + (a2dp_audio_list_length(list) + missing_pkt_cnt) < sbc_mtu_limiter) { + for (uint8_t i = 0; i < missing_pkt_cnt; i++) { + a2dp_audio_sbc_decoder_frame_t *frame_p = + (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_sbc_subframe_malloc( + sbc_raw_frame->sbc_buffer_len); + if (!frame_p) { + nRet = A2DP_DECODER_MEMORY_ERROR; + goto exit; + } + frame_p->sequenceNumber = UINT16_MAX; + frame_p->timestamp = UINT32_MAX; + memcpy(frame_p->sbc_buffer, sbc_raw_frame->sbc_buffer, + sbc_raw_frame->sbc_buffer_len); + frame_p->sbc_buffer_len = sbc_raw_frame->sbc_buffer_len; + a2dp_audio_list_append(list, frame_p); } + } exit: - return nRet; + return nRet; } #define FRAME_LIST_MAX (20) -int a2dp_audio_sbc_store_packet(btif_media_header_t * header, uint8_t *buffer, uint32_t buffer_bytes) -{ - int nRet = A2DP_DECODER_NO_ERROR; +int a2dp_audio_sbc_store_packet(btif_media_header_t *header, uint8_t *buffer, + uint32_t buffer_bytes) { + int nRet = A2DP_DECODER_NO_ERROR; - uint32_t frame_cnt = 0; - uint32_t frame_num = 0; - uint32_t frame_len = 0; - uint8_t *parser_p = buffer; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - uint16_t bytes_parsed = 0; - a2dp_audio_sbc_decoder_frame_t *frame_list[FRAME_LIST_MAX] = {0,}; - uint8_t frame_list_idx = 0; - bool find_err = false; - uint32_t i = 0; + uint32_t frame_cnt = 0; + uint32_t frame_num = 0; + uint32_t frame_len = 0; + uint8_t *parser_p = buffer; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + uint16_t bytes_parsed = 0; + a2dp_audio_sbc_decoder_frame_t *frame_list[FRAME_LIST_MAX] = { + 0, + }; + uint8_t frame_list_idx = 0; + bool find_err = false; + uint32_t i = 0; - frame_num = *parser_p; + frame_num = *parser_p; - if (!frame_num){ - TRACE_A2DP_DECODER_W("[SBC][INPUT] ERROR SBC FRAME !!! frame_num:%d", frame_num); - DUMP8("%02x ", parser_p, 12); - return A2DP_DECODER_DECODE_ERROR; - } + if (!frame_num) { + TRACE_A2DP_DECODER_W("[SBC][INPUT] ERROR SBC FRAME !!! frame_num:%d", + frame_num); + DUMP8("%02x ", parser_p, 12); + return A2DP_DECODER_DECODE_ERROR; + } - parser_p++; - buffer_bytes--; - frame_len = buffer_bytes/frame_num; + parser_p++; + buffer_bytes--; + frame_len = buffer_bytes / frame_num; - if ((a2dp_audio_list_length(list)+frame_num) < sbc_mtu_limiter){ - for (i=0; isequenceNumber = header->sequenceNumber; - frame_p->timestamp = header->timestamp; - frame_p->curSubSequenceNumber = frame_cnt; - frame_p->totalSubSequenceNumber = frame_num; - memcpy(frame_p->sbc_buffer, (parser_p+i), bytes_parsed); - frame_p->sbc_buffer_len = bytes_parsed; - frame_list[frame_list_idx++] = frame_p; - if (frame_list_idx >= FRAME_LIST_MAX){ - find_err = true; - break; - } - }else{ - TRACE_A2DP_DECODER_W("[SBC][INPUT] ERROR SBC FRAME !!!"); - DUMP8("%02x ", parser_p+i, 12); - find_err = true; - break; - } + if ((a2dp_audio_list_length(list) + frame_num) < sbc_mtu_limiter) { + for (i = 0; i < buffer_bytes; i += bytes_parsed, frame_cnt++) { + bytes_parsed = 0; + if (*(parser_p + i) == 0x9c) { + if (btif_sbc_decode_frames_parser(a2dp_audio_sbc_decoder_preparse, + parser_p + i, buffer_bytes, + &bytes_parsed) != BT_STS_SUCCESS) { + bytes_parsed = frame_len; + TRACE_A2DP_DECODER_W("[SBC][INPUT] ERROR SBC FRAME PARSER !!!"); + DUMP8("%02x ", parser_p + i, 12); + find_err = true; + break; } - if (find_err){ - TRACE_A2DP_DECODER_W("[SBC][INPUT] FIND ERR !!!"); - for (i = 0; isequenceNumber = header->sequenceNumber; + frame_p->timestamp = header->timestamp; + frame_p->curSubSequenceNumber = frame_cnt; + frame_p->totalSubSequenceNumber = frame_num; + memcpy(frame_p->sbc_buffer, (parser_p + i), bytes_parsed); + frame_p->sbc_buffer_len = bytes_parsed; + frame_list[frame_list_idx++] = frame_p; + if (frame_list_idx >= FRAME_LIST_MAX) { + find_err = true; + break; + } + } else { + TRACE_A2DP_DECODER_W("[SBC][INPUT] ERROR SBC FRAME !!!"); + DUMP8("%02x ", parser_p + i, 12); + find_err = true; + break; + } } + if (find_err) { + TRACE_A2DP_DECODER_W("[SBC][INPUT] FIND ERR !!!"); + for (i = 0; i < frame_list_idx; i++) { + a2dp_audio_sbc_subframe_free(frame_list[i]); + } + nRet = A2DP_DECODER_DECODE_ERROR; + } else { + a2dp_audio_sbc_packet_recover_proc(header, frame_list[0], frame_num); + a2dp_audio_sbc_packet_recover_save_last(header); + for (i = 0; i < frame_list_idx; i++) { + a2dp_audio_list_append(list, frame_list[i]); + } + nRet = A2DP_DECODER_NO_ERROR; + } + } else { + TRACE_A2DP_DECODER_W("[SBC][INPUT] OVERFLOW list:%d", + a2dp_audio_list_length(list)); + nRet = A2DP_DECODER_MTU_LIMTER_ERROR; + } - return nRet; + return nRet; } -int a2dp_audio_sbc_discards_packet(uint32_t packets) -{ - int nRet = A2DP_DECODER_MEMORY_ERROR; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame = NULL; - uint16_t totalSubSequenceNumber; - uint8_t j = 0; +int a2dp_audio_sbc_discards_packet(uint32_t packets) { + int nRet = A2DP_DECODER_MEMORY_ERROR; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame = NULL; + uint16_t totalSubSequenceNumber; + uint8_t j = 0; #ifdef A2DP_CP_ACCEL - a2dp_cp_reset_frame(); + a2dp_cp_reset_frame(); #endif - node = a2dp_audio_list_begin(list); - if (!node){ - goto exit; - } - sbc_decoder_frame = (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_list_node(node); + node = a2dp_audio_list_begin(list); + if (!node) { + goto exit; + } + sbc_decoder_frame = + (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_list_node(node); - for (j=0; jcurSubSequenceNumber != 0) { + a2dp_audio_list_remove(list, sbc_decoder_frame); + } else { + break; + } + } + + node = a2dp_audio_list_begin(list); + if (!node) { + goto exit; + } + sbc_decoder_frame = + (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_list_node(node); + ASSERT_A2DP_DECODER(sbc_decoder_frame->curSubSequenceNumber == 0, + "sbc_discards_packet not align curSubSequenceNumber:%d", + sbc_decoder_frame->curSubSequenceNumber); + + totalSubSequenceNumber = sbc_decoder_frame->totalSubSequenceNumber; + + if (packets <= a2dp_audio_list_length(list) / totalSubSequenceNumber) { + for (uint8_t i = 0; i < packets; i++) { + for (j = 0; j < totalSubSequenceNumber; j++) { node = a2dp_audio_list_begin(list); - if (!node){ - goto exit; - } - sbc_decoder_frame = (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_list_node(node); - if (sbc_decoder_frame->curSubSequenceNumber != 0){ - a2dp_audio_list_remove(list, sbc_decoder_frame); - }else{ - break; + if (!node) { + goto exit; } + sbc_decoder_frame = + (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_list_node(node); + a2dp_audio_list_remove(list, sbc_decoder_frame); + } } - - node = a2dp_audio_list_begin(list); - if (!node){ - goto exit; - } - sbc_decoder_frame = (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_list_node(node); - ASSERT_A2DP_DECODER(sbc_decoder_frame->curSubSequenceNumber == 0, "sbc_discards_packet not align curSubSequenceNumber:%d", - sbc_decoder_frame->curSubSequenceNumber); - - totalSubSequenceNumber = sbc_decoder_frame->totalSubSequenceNumber; - - if (packets <= a2dp_audio_list_length(list)/totalSubSequenceNumber){ - for (uint8_t i=0; iaudio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame = NULL; +int a2dp_audio_sbc_headframe_info_get( + A2DP_AUDIO_HEADFRAME_INFO_T *headframe_info) { + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame = NULL; - if (a2dp_audio_list_length(list) && ((node = a2dp_audio_list_begin(list)) != NULL)){ - sbc_decoder_frame = (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_list_node(node); - headframe_info->sequenceNumber = sbc_decoder_frame->sequenceNumber; - headframe_info->timestamp = sbc_decoder_frame->timestamp; - headframe_info->curSubSequenceNumber = sbc_decoder_frame->curSubSequenceNumber; - headframe_info->totalSubSequenceNumber = sbc_decoder_frame->totalSubSequenceNumber; - }else{ - memset(headframe_info, 0, sizeof(A2DP_AUDIO_HEADFRAME_INFO_T)); - } + if (a2dp_audio_list_length(list) && + ((node = a2dp_audio_list_begin(list)) != NULL)) { + sbc_decoder_frame = + (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_list_node(node); + headframe_info->sequenceNumber = sbc_decoder_frame->sequenceNumber; + headframe_info->timestamp = sbc_decoder_frame->timestamp; + headframe_info->curSubSequenceNumber = + sbc_decoder_frame->curSubSequenceNumber; + headframe_info->totalSubSequenceNumber = + sbc_decoder_frame->totalSubSequenceNumber; + } else { + memset(headframe_info, 0, sizeof(A2DP_AUDIO_HEADFRAME_INFO_T)); + } - return A2DP_DECODER_NO_ERROR; + return A2DP_DECODER_NO_ERROR; } -int a2dp_audio_sbc_info_get(void *info) -{ - return A2DP_DECODER_NO_ERROR; -} +int a2dp_audio_sbc_info_get(void *info) { return A2DP_DECODER_NO_ERROR; } -int a2dp_audio_sbc_synchronize_packet(A2DP_AUDIO_SYNCFRAME_INFO_T *sync_info, uint32_t mask) -{ - int nRet = A2DP_DECODER_SYNC_ERROR; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - int list_len; - a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame = NULL; +int a2dp_audio_sbc_synchronize_packet(A2DP_AUDIO_SYNCFRAME_INFO_T *sync_info, + uint32_t mask) { + int nRet = A2DP_DECODER_SYNC_ERROR; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + int list_len; + a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame = NULL; #ifdef A2DP_CP_ACCEL - a2dp_cp_reset_frame(); + a2dp_cp_reset_frame(); #endif - list_len = a2dp_audio_list_length(list); - - for (uint16_t i=0; isequenceNumber == sync_info->sequenceNumber, A2DP_AUDIO_SYNCFRAME_MASK_SEQ, mask)&& - A2DP_AUDIO_SYNCFRAME_CHK(sbc_decoder_frame->curSubSequenceNumber == sync_info->curSubSequenceNumber, A2DP_AUDIO_SYNCFRAME_MASK_CURRSUBSEQ, mask)&& - A2DP_AUDIO_SYNCFRAME_CHK(sbc_decoder_frame->totalSubSequenceNumber == sync_info->totalSubSequenceNumber,A2DP_AUDIO_SYNCFRAME_MASK_TOTALSUBSEQ,mask)){ - nRet = A2DP_DECODER_NO_ERROR; - break; - } - a2dp_audio_list_remove(list, sbc_decoder_frame); - } - } + list_len = a2dp_audio_list_length(list); + for (uint16_t i = 0; i < list_len; i++) { node = a2dp_audio_list_begin(list); - if (node){ - sbc_decoder_frame = (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_list_node(node); - TRACE_A2DP_DECODER_I("[MCU][SYNC][SBC] sync pkt nRet:%d SEQ:%d timestamp:%d %d/%d", - nRet, sbc_decoder_frame->sequenceNumber, sbc_decoder_frame->timestamp, - sbc_decoder_frame->curSubSequenceNumber, sbc_decoder_frame->totalSubSequenceNumber); - }else{ - TRACE_A2DP_DECODER_I("[MCU][SYNC][SBC] sync pkt nRet:%d", nRet); - } - - return nRet; -} - -int a2dp_audio_sbc_synchronize_dest_packet_mut(uint16_t packet_mut) -{ - list_node_t *node = NULL; - uint32_t list_len = 0; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame = NULL; - - list_len = a2dp_audio_list_length(list); - if (list_len > packet_mut){ - do{ - node = a2dp_audio_list_begin(list); - if (node){ - sbc_decoder_frame = (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_list_node(node); - a2dp_audio_list_remove(list, sbc_decoder_frame); - } - }while(a2dp_audio_list_length(list) > packet_mut); - } - - TRACE_A2DP_DECODER_I("[MCU][SYNC][SBC] dest pkt list:%d", a2dp_audio_list_length(list)); - - return A2DP_DECODER_NO_ERROR; -} - -int a2dp_audio_sbc_convert_list_to_samples(uint32_t *samples) -{ - uint32_t list_len = 0; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - - list_len = a2dp_audio_list_length(list); - *samples = SBC_LIST_SAMPLES*list_len; - - TRACE_A2DP_DECODER_I("[MCU][SBC] list:%d samples:%d", list_len, *samples); - - return A2DP_DECODER_NO_ERROR; -} - -int a2dp_audio_sbc_discards_samples(uint32_t samples) -{ - int nRet = A2DP_DECODER_SYNC_ERROR; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame = NULL; - list_node_t *node = NULL; - int need_remove_list = 0; - uint32_t list_samples = 0; - ASSERT_A2DP_DECODER(!(samples%SBC_LIST_SAMPLES), "%s samples err:%d", __func__, samples); - - a2dp_audio_sbc_convert_list_to_samples(&list_samples); - if (list_samples >= samples){ - need_remove_list = samples/SBC_LIST_SAMPLES; - for (int i=0; isequenceNumber == + sync_info->sequenceNumber, + A2DP_AUDIO_SYNCFRAME_MASK_SEQ, mask) && + A2DP_AUDIO_SYNCFRAME_CHK(sbc_decoder_frame->curSubSequenceNumber == + sync_info->curSubSequenceNumber, + A2DP_AUDIO_SYNCFRAME_MASK_CURRSUBSEQ, + mask) && + A2DP_AUDIO_SYNCFRAME_CHK(sbc_decoder_frame->totalSubSequenceNumber == + sync_info->totalSubSequenceNumber, + A2DP_AUDIO_SYNCFRAME_MASK_TOTALSUBSEQ, + mask)) { nRet = A2DP_DECODER_NO_ERROR; + break; + } + a2dp_audio_list_remove(list, sbc_decoder_frame); } + } - return nRet; + node = a2dp_audio_list_begin(list); + if (node) { + sbc_decoder_frame = + (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_list_node(node); + TRACE_A2DP_DECODER_I( + "[MCU][SYNC][SBC] sync pkt nRet:%d SEQ:%d timestamp:%d %d/%d", nRet, + sbc_decoder_frame->sequenceNumber, sbc_decoder_frame->timestamp, + sbc_decoder_frame->curSubSequenceNumber, + sbc_decoder_frame->totalSubSequenceNumber); + } else { + TRACE_A2DP_DECODER_I("[MCU][SYNC][SBC] sync pkt nRet:%d", nRet); + } + + return nRet; } -int a2dp_audio_sbc_channel_select(A2DP_AUDIO_CHANNEL_SELECT_E chnl_sel) -{ - return A2DP_DECODER_NO_ERROR; +int a2dp_audio_sbc_synchronize_dest_packet_mut(uint16_t packet_mut) { + list_node_t *node = NULL; + uint32_t list_len = 0; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame = NULL; + + list_len = a2dp_audio_list_length(list); + if (list_len > packet_mut) { + do { + node = a2dp_audio_list_begin(list); + if (node) { + sbc_decoder_frame = + (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_list_node(node); + a2dp_audio_list_remove(list, sbc_decoder_frame); + } + } while (a2dp_audio_list_length(list) > packet_mut); + } + + TRACE_A2DP_DECODER_I("[MCU][SYNC][SBC] dest pkt list:%d", + a2dp_audio_list_length(list)); + + return A2DP_DECODER_NO_ERROR; +} + +int a2dp_audio_sbc_convert_list_to_samples(uint32_t *samples) { + uint32_t list_len = 0; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + + list_len = a2dp_audio_list_length(list); + *samples = SBC_LIST_SAMPLES * list_len; + + TRACE_A2DP_DECODER_I("[MCU][SBC] list:%d samples:%d", list_len, *samples); + + return A2DP_DECODER_NO_ERROR; +} + +int a2dp_audio_sbc_discards_samples(uint32_t samples) { + int nRet = A2DP_DECODER_SYNC_ERROR; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + a2dp_audio_sbc_decoder_frame_t *sbc_decoder_frame = NULL; + list_node_t *node = NULL; + int need_remove_list = 0; + uint32_t list_samples = 0; + ASSERT_A2DP_DECODER(!(samples % SBC_LIST_SAMPLES), "%s samples err:%d", + __func__, samples); + + a2dp_audio_sbc_convert_list_to_samples(&list_samples); + if (list_samples >= samples) { + need_remove_list = samples / SBC_LIST_SAMPLES; + for (int i = 0; i < need_remove_list; i++) { + node = a2dp_audio_list_begin(list); + if (node) { + sbc_decoder_frame = + (a2dp_audio_sbc_decoder_frame_t *)a2dp_audio_list_node(node); + a2dp_audio_list_remove(list, sbc_decoder_frame); + } + } + nRet = A2DP_DECODER_NO_ERROR; + } + + return nRet; +} + +int a2dp_audio_sbc_channel_select(A2DP_AUDIO_CHANNEL_SELECT_E chnl_sel) { + return A2DP_DECODER_NO_ERROR; } A2DP_AUDIO_DECODER_T a2dp_audio_sbc_decoder_config = { - {44100, 2, 16}, - 1, - a2dp_audio_sbc_init, - a2dp_audio_sbc_deinit, - a2dp_audio_sbc_decode_frame, - a2dp_audio_sbc_preparse_packet, - a2dp_audio_sbc_store_packet, - a2dp_audio_sbc_discards_packet, - a2dp_audio_sbc_synchronize_packet, - a2dp_audio_sbc_synchronize_dest_packet_mut, - a2dp_audio_sbc_convert_list_to_samples, - a2dp_audio_sbc_discards_samples, - a2dp_audio_sbc_headframe_info_get, - a2dp_audio_sbc_info_get, - a2dp_audio_sbc_subframe_free, - a2dp_audio_sbc_channel_select, - } ; - + {44100, 2, 16}, + 1, + a2dp_audio_sbc_init, + a2dp_audio_sbc_deinit, + a2dp_audio_sbc_decode_frame, + a2dp_audio_sbc_preparse_packet, + a2dp_audio_sbc_store_packet, + a2dp_audio_sbc_discards_packet, + a2dp_audio_sbc_synchronize_packet, + a2dp_audio_sbc_synchronize_dest_packet_mut, + a2dp_audio_sbc_convert_list_to_samples, + a2dp_audio_sbc_discards_samples, + a2dp_audio_sbc_headframe_info_get, + a2dp_audio_sbc_info_get, + a2dp_audio_sbc_subframe_free, + a2dp_audio_sbc_channel_select, +}; diff --git a/apps/audioplayers/a2dp_decoder/a2dp_decoder_scalable.cpp b/apps/audioplayers/a2dp_decoder/a2dp_decoder_scalable.cpp index 9fcf02a..2f2410e 100644 --- a/apps/audioplayers/a2dp_decoder/a2dp_decoder_scalable.cpp +++ b/apps/audioplayers/a2dp_decoder/a2dp_decoder_scalable.cpp @@ -14,19 +14,19 @@ * ****************************************************************************/ // Standard C Included Files -#include "cmsis.h" -#include "plat_types.h" -#include -#include "heap_api.h" -#include "hal_location.h" #include "a2dp_decoder_internal.h" #include "app_audio.h" +#include "cmsis.h" +#include "hal_location.h" +#include "heap_api.h" +#include "plat_types.h" +#include #if defined(A2DP_SCALABLE_ON) #include "heap_api.h" #include "ssc.h" #define SCALABLE_MTU_LIMITER (32) -#define SCALABLE_MEMPOOL_SIZE 1024 +#define SCALABLE_MEMPOOL_SIZE 1024 #define SCALABLE_OUTPUT_FRAME_SAMPLES (SCALABLE_FRAME_SIZE) @@ -36,686 +36,700 @@ static A2DP_AUDIO_OUTPUT_CONFIG_T output_config; static unsigned char *scalable_decoder_place = NULL; static unsigned char *scalable_decoder_temp_buf = NULL; -static short ss_pcm_buff[SCALABLE_FRAME_SIZE*4]; +static short ss_pcm_buff[SCALABLE_FRAME_SIZE * 4]; static int scalable_uhq_flag __attribute__((unused)) = 0; static HANDLE_DECODER scalableDec_handle = NULL; static A2DP_AUDIO_DECODER_LASTFRAME_INFO_T lastframe_info; - typedef struct { - uint16_t sequenceNumber; - uint32_t timestamp; - uint8_t *buffer; - int buffer_len; + uint16_t sequenceNumber; + uint32_t timestamp; + uint8_t *buffer; + int buffer_len; } a2dp_audio_scalable_decoder_frame_t; -static void ss_to_24bit_buf(int32_t * out, int32_t * in, int size) -{ - for (int i = 0; i < size; i++) { +static void ss_to_24bit_buf(int32_t *out, int32_t *in, int size) { + for (int i = 0; i < size; i++) { out[i] = in[i]; - } + } } -static void a2dp_audio_scalable_decoder_init(void) -{ - if (scalableDec_handle == NULL) { - scalableDec_handle = scalable_decoder_place; +static void a2dp_audio_scalable_decoder_init(void) { + if (scalableDec_handle == NULL) { + scalableDec_handle = scalable_decoder_place; - - ssc_decoder_init(scalableDec_handle, output_config.num_channels, output_config.sample_rate); - - } + ssc_decoder_init(scalableDec_handle, output_config.num_channels, + output_config.sample_rate); + } } -static int scalableDecoder_Close(HANDLE_DECODER handle) -{ - if (handle) { +static int scalableDecoder_Close(HANDLE_DECODER handle) { + if (handle) { a2dp_audio_heap_free(handle); a2dp_audio_heap_free(scalable_decoder_temp_buf); - } + } - return 0; + return 0; } -static void a2dp_audio_scalable_decoder_deinit(void) -{ - if (scalableDec_handle) { +static void a2dp_audio_scalable_decoder_deinit(void) { + if (scalableDec_handle) { scalableDecoder_Close(scalableDec_handle); scalableDec_handle = NULL; - } + } } -static void a2dp_audio_scalable_decoder_reinit(void) -{ - if (scalableDec_handle) { +static void a2dp_audio_scalable_decoder_reinit(void) { + if (scalableDec_handle) { a2dp_audio_scalable_decoder_deinit(); - } - a2dp_audio_scalable_decoder_init(); + } + a2dp_audio_scalable_decoder_init(); } -static bool is_valid_frame(a2dp_audio_scalable_decoder_frame_t * decoder_frame_p) -{ - int hw_tmp, len, bitrate_bps, frame_len, frame_size; +static bool +is_valid_frame(a2dp_audio_scalable_decoder_frame_t *decoder_frame_p) { + int hw_tmp, len, bitrate_bps, frame_len, frame_size; - int sampling_rate = 44100; - unsigned char *input_buf = decoder_frame_p->buffer; - if (decoder_frame_p->buffer_len < SCALABLE_HEAD_SIZE) { - TRACE_A2DP_DECODER_E("invalid scalable a2dp frame, length < SCALABLE_HEAD_SIZE !!!!!!!"); - return false; - } + int sampling_rate = 44100; + unsigned char *input_buf = decoder_frame_p->buffer; + if (decoder_frame_p->buffer_len < SCALABLE_HEAD_SIZE) { + TRACE_A2DP_DECODER_E( + "invalid scalable a2dp frame, length < SCALABLE_HEAD_SIZE !!!!!!!"); + return false; + } - scalable_uhq_flag = 0; + scalable_uhq_flag = 0; - switch ((input_buf[3]&0xf7)) { - case 0xF0: - bitrate_bps = 88000; - break; - case 0xF1: - bitrate_bps = 96000; - break; - case 0xF2: - bitrate_bps = 128000; - break; - case 0xF3: - bitrate_bps = 192000; - break; - case 0xF4: - bitrate_bps = 229000; - break; - case 0xF5: - scalable_uhq_flag = 1; - bitrate_bps = 328000; - sampling_rate = 96000; - break; - default: - bitrate_bps = 192000; - break; - } + switch ((input_buf[3] & 0xf7)) { + case 0xF0: + bitrate_bps = 88000; + break; + case 0xF1: + bitrate_bps = 96000; + break; + case 0xF2: + bitrate_bps = 128000; + break; + case 0xF3: + bitrate_bps = 192000; + break; + case 0xF4: + bitrate_bps = 229000; + break; + case 0xF5: + scalable_uhq_flag = 1; + bitrate_bps = 328000; + sampling_rate = 96000; + break; + default: + bitrate_bps = 192000; + break; + } - frame_size = SCALABLE_FRAME_SIZE; + frame_size = SCALABLE_FRAME_SIZE; - len = bitrate_bps * frame_size / sampling_rate / 8; - if (scalable_uhq_flag == 0) { + len = bitrate_bps * frame_size / sampling_rate / 8; + if (scalable_uhq_flag == 0) { hw_tmp = (len * 3) >> 7; len = hw_tmp + len; len = len + ((len & 1) ^ 1); - } else { - len = 369; //744/2-4+1 - } - TRACE_A2DP_DECODER_D - ("scalable a2dp frame, length:%d bitrate:%d sampling_rate:%d", - decoder_frame_p->buffer_len, bitrate_bps, sampling_rate); - frame_len = SCALABLE_HEAD_SIZE + len - 1; + } else { + len = 369; // 744/2-4+1 + } + TRACE_A2DP_DECODER_D( + "scalable a2dp frame, length:%d bitrate:%d sampling_rate:%d", + decoder_frame_p->buffer_len, bitrate_bps, sampling_rate); + frame_len = SCALABLE_HEAD_SIZE + len - 1; - if (decoder_frame_p->buffer_len < frame_len) { - TRACE_A2DP_DECODER_E - ("invalid scalable a2dp frame, length:%d < %d !!!!!!!", decoder_frame_p->buffer_len, frame_len); + if (decoder_frame_p->buffer_len < frame_len) { + TRACE_A2DP_DECODER_E( + "invalid scalable a2dp frame, length:%d < %d !!!!!!!", + decoder_frame_p->buffer_len, frame_len); return false; - } - return true; - + } + return true; } - #ifdef A2DP_CP_ACCEL struct A2DP_CP_scalable_IN_FRM_INFO_T { - uint16_t sequenceNumber; - uint32_t timestamp; + uint16_t sequenceNumber; + uint32_t timestamp; }; struct A2DP_CP_scalable_OUT_FRM_INFO_T { - struct A2DP_CP_scalable_IN_FRM_INFO_T in_info; - uint16_t frame_samples; - uint16_t decoded_frames; - uint16_t frame_idx; - uint16_t pcm_len; + struct A2DP_CP_scalable_IN_FRM_INFO_T in_info; + uint16_t frame_samples; + uint16_t decoded_frames; + uint16_t frame_idx; + uint16_t pcm_len; }; static bool cp_codec_reset; extern uint32_t app_bt_stream_get_dma_buffer_samples(void); -TEXT_SSC_LOC static int a2dp_cp_scalable_mcu_decode(uint8_t * buffer, uint32_t buffer_bytes) -{ - a2dp_audio_scalable_decoder_frame_t *decoder_frame_p = NULL; - list_node_t *node = NULL; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - int ret, dec_ret; - struct A2DP_CP_scalable_IN_FRM_INFO_T in_info; - struct A2DP_CP_scalable_OUT_FRM_INFO_T *p_out_info; - uint8_t *out; - uint32_t out_len; - uint32_t out_frame_len; - uint32_t cp_buffer_frames_max = 0; +TEXT_SSC_LOC static int a2dp_cp_scalable_mcu_decode(uint8_t *buffer, + uint32_t buffer_bytes) { + a2dp_audio_scalable_decoder_frame_t *decoder_frame_p = NULL; + list_node_t *node = NULL; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + int ret, dec_ret; + struct A2DP_CP_scalable_IN_FRM_INFO_T in_info; + struct A2DP_CP_scalable_OUT_FRM_INFO_T *p_out_info; + uint8_t *out; + uint32_t out_len; + uint32_t out_frame_len; + uint32_t cp_buffer_frames_max = 0; - cp_buffer_frames_max = app_bt_stream_get_dma_buffer_samples()/2; - if (cp_buffer_frames_max %(lastframe_info.frame_samples) ){ - cp_buffer_frames_max = cp_buffer_frames_max /(lastframe_info.frame_samples) +1; - }else{ - cp_buffer_frames_max = cp_buffer_frames_max /(lastframe_info.frame_samples); + cp_buffer_frames_max = app_bt_stream_get_dma_buffer_samples() / 2; + if (cp_buffer_frames_max % (lastframe_info.frame_samples)) { + cp_buffer_frames_max = + cp_buffer_frames_max / (lastframe_info.frame_samples) + 1; + } else { + cp_buffer_frames_max = + cp_buffer_frames_max / (lastframe_info.frame_samples); + } + + out_frame_len = sizeof(*p_out_info) + buffer_bytes; + ret = a2dp_cp_decoder_init(out_frame_len, cp_buffer_frames_max * 2); + + ASSERT(ret == 0, "%s: a2dp_cp_decoder_init() failed: ret=%d", __func__, ret); + + while ((node = a2dp_audio_list_begin(list)) != NULL) { + decoder_frame_p = + (a2dp_audio_scalable_decoder_frame_t *)a2dp_audio_list_node(node); + + if (false == is_valid_frame(decoder_frame_p)) { + return A2DP_DECODER_DECODE_ERROR; } - out_frame_len = sizeof(*p_out_info) + buffer_bytes; - ret = a2dp_cp_decoder_init(out_frame_len, cp_buffer_frames_max * 2); + in_info.sequenceNumber = decoder_frame_p->sequenceNumber; + in_info.timestamp = decoder_frame_p->timestamp; - ASSERT(ret == 0, "%s: a2dp_cp_decoder_init() failed: ret=%d", __func__, ret); - - while ((node = a2dp_audio_list_begin(list)) != NULL) { - decoder_frame_p = (a2dp_audio_scalable_decoder_frame_t *) - a2dp_audio_list_node(node); - - if (false == is_valid_frame(decoder_frame_p)) { - return A2DP_DECODER_DECODE_ERROR; - } - - in_info.sequenceNumber = decoder_frame_p->sequenceNumber; - in_info.timestamp = decoder_frame_p->timestamp; - - ret = a2dp_cp_put_in_frame(&in_info, sizeof(in_info), decoder_frame_p->buffer, decoder_frame_p->buffer_len); - if (ret) { - break; - } - - a2dp_audio_list_remove(list, decoder_frame_p); - } - - ret = a2dp_cp_get_full_out_frame((void **)&out, &out_len); + ret = + a2dp_cp_put_in_frame(&in_info, sizeof(in_info), decoder_frame_p->buffer, + decoder_frame_p->buffer_len); if (ret) { - return A2DP_DECODER_DECODE_ERROR; - } - if (out_len == 0) { - memset(buffer, 0, buffer_bytes); - a2dp_cp_consume_full_out_frame(); - return A2DP_DECODER_NO_ERROR; - } - ASSERT(out_len == out_frame_len, "%s: Bad out len %u (should be %u)", __func__, out_len, out_frame_len); - - p_out_info = (struct A2DP_CP_scalable_OUT_FRM_INFO_T *)out; - if (p_out_info->pcm_len) { - lastframe_info.sequenceNumber = p_out_info->in_info.sequenceNumber; - lastframe_info.timestamp = p_out_info->in_info.timestamp; - lastframe_info.curSubSequenceNumber = 0; - lastframe_info.totalSubSequenceNumber = 0; - lastframe_info.frame_samples = p_out_info->frame_samples; - lastframe_info.decoded_frames += p_out_info->decoded_frames; - lastframe_info.undecode_frames = - a2dp_audio_list_length(list) + a2dp_cp_get_in_frame_cnt_by_index(p_out_info->frame_idx) - 1; - a2dp_audio_decoder_internal_lastframe_info_set(&lastframe_info); + break; } - if (p_out_info->pcm_len == buffer_bytes) { - memcpy(buffer, p_out_info + 1, p_out_info->pcm_len); - dec_ret = A2DP_DECODER_NO_ERROR; - } else { - dec_ret = A2DP_DECODER_DECODE_ERROR; - } + a2dp_audio_list_remove(list, decoder_frame_p); + } - ret = a2dp_cp_consume_full_out_frame(); - ASSERT(ret == 0, "%s: a2dp_cp_consume_full_out_frame() failed: ret=%d", __func__, ret); + ret = a2dp_cp_get_full_out_frame((void **)&out, &out_len); + if (ret) { + return A2DP_DECODER_DECODE_ERROR; + } + if (out_len == 0) { + memset(buffer, 0, buffer_bytes); + a2dp_cp_consume_full_out_frame(); + return A2DP_DECODER_NO_ERROR; + } + ASSERT(out_len == out_frame_len, "%s: Bad out len %u (should be %u)", + __func__, out_len, out_frame_len); - return dec_ret; -} - -TEXT_SSC_LOC int a2dp_cp_scalable_cp_decode(void) -{ - int ret; - enum CP_EMPTY_OUT_FRM_T out_frm_st; - uint8_t *out; - uint32_t out_len; - uint8_t *dec_start; - uint32_t dec_len; - struct A2DP_CP_scalable_IN_FRM_INFO_T *p_in_info; - struct A2DP_CP_scalable_OUT_FRM_INFO_T *p_out_info; - uint8_t *in_buf; - uint32_t in_len; - uint32_t dec_sum; - int error, output_samples = 0,output_byte = 0; - - if (cp_codec_reset) - { - cp_codec_reset = false; - a2dp_audio_scalable_decoder_init(); - } - - out_frm_st = a2dp_cp_get_emtpy_out_frame((void **)&out, &out_len); - - if (out_frm_st != CP_EMPTY_OUT_FRM_OK && out_frm_st != CP_EMPTY_OUT_FRM_WORKING) - { - return 1; - } - - ASSERT(out_len > sizeof(*p_out_info), "%s: Bad out_len %u (should > %u)", __func__, out_len, sizeof(*p_out_info)); - - p_out_info = (struct A2DP_CP_scalable_OUT_FRM_INFO_T *)out; - if (out_frm_st == CP_EMPTY_OUT_FRM_OK) - { - p_out_info->pcm_len = 0; - p_out_info->decoded_frames = 0; - } - - ASSERT(out_len > sizeof(*p_out_info) + p_out_info->pcm_len, - "%s: Bad out_len %u (should > %u + %u)", __func__, out_len, sizeof(*p_out_info), p_out_info->pcm_len); - - dec_start = (uint8_t *) (p_out_info + 1) + p_out_info->pcm_len; - dec_len = out_len - (dec_start - (uint8_t *) out); - if (!scalableDec_handle) { - TRACE(0,"scalable_decode not ready"); - return 3; - } - - dec_sum = 0; - error = 0; - - while (dec_sum < dec_len && error == 0) - { - ret = a2dp_cp_get_in_frame((void * *) &in_buf, &in_len); - - if (ret) - { - break; - } - - ASSERT(in_len > sizeof(*p_in_info), "%s: Bad in_len %u (should > %u)", __func__, in_len, sizeof(*p_in_info)); - p_in_info = (struct A2DP_CP_scalable_IN_FRM_INFO_T *)in_buf; - in_buf += sizeof(*p_in_info); - in_len -= sizeof(*p_in_info); - /* decode one SSC frame */ - output_samples = ssc_decode(scalableDec_handle,(const unsigned char*)in_buf, ss_pcm_buff, SCALABLE_FRAME_SIZE, 0, 2); - if (0 == output_samples) - { - a2dp_audio_scalable_decoder_reinit(); - TRACE(0, "scalable_decode reinin codec \n"); - error = A2DP_DECODER_DECODE_ERROR; - goto exit; - } - - ss_to_24bit_buf((int32_t *) (dec_start+dec_sum), (int32_t *) ss_pcm_buff, output_samples); - output_byte = output_samples * 4; - dec_sum += output_byte; -exit: - memcpy(&p_out_info->in_info, ss_pcm_buff, sizeof(*p_in_info)); - p_out_info->decoded_frames++; - p_out_info->frame_samples = SCALABLE_OUTPUT_FRAME_SAMPLES; - p_out_info->frame_idx = a2dp_cp_get_in_frame_index(); - - ret = a2dp_cp_consume_in_frame(); - ASSERT(ret == 0, "%s: a2dp_cp_consume_in_frame() failed: ret=%d", __func__, ret); - } - - p_out_info->pcm_len += dec_sum; - - if (error || out_len <= sizeof(*p_out_info) + p_out_info->pcm_len) { - ret = a2dp_cp_consume_emtpy_out_frame(); - ASSERT(ret == 0, "%s: a2dp_cp_consume_emtpy_out_frame() failed: ret=%d", __func__, ret); - } - - return error; -} -#endif - -static int a2dp_audio_scalable_init(A2DP_AUDIO_OUTPUT_CONFIG_T * config, void *context) -{ - TRACE_A2DP_DECODER_D("%s", __func__); - - TRACE(0,"\n\nA2DP SSC-LC INIT\n"); - - a2dp_audio_context_p = (A2DP_AUDIO_CONTEXT_T *) context; - - memcpy(&output_config, config, sizeof(A2DP_AUDIO_OUTPUT_CONFIG_T)); - - memset(&lastframe_info, 0, sizeof(A2DP_AUDIO_DECODER_LASTFRAME_INFO_T)); - lastframe_info.stream_info = output_config; - lastframe_info.frame_samples = SCALABLE_FRAME_SIZE; - lastframe_info.list_samples = SCALABLE_FRAME_SIZE; + p_out_info = (struct A2DP_CP_scalable_OUT_FRM_INFO_T *)out; + if (p_out_info->pcm_len) { + lastframe_info.sequenceNumber = p_out_info->in_info.sequenceNumber; + lastframe_info.timestamp = p_out_info->in_info.timestamp; + lastframe_info.curSubSequenceNumber = 0; + lastframe_info.totalSubSequenceNumber = 0; + lastframe_info.frame_samples = p_out_info->frame_samples; + lastframe_info.decoded_frames += p_out_info->decoded_frames; + lastframe_info.undecode_frames = + a2dp_audio_list_length(list) + + a2dp_cp_get_in_frame_cnt_by_index(p_out_info->frame_idx) - 1; a2dp_audio_decoder_internal_lastframe_info_set(&lastframe_info); + } - ASSERT(a2dp_audio_context_p->dest_packet_mut < SCALABLE_MTU_LIMITER, - "%s MTU OVERFLOW:%u/%u", __func__, a2dp_audio_context_p->dest_packet_mut, SCALABLE_MTU_LIMITER); + if (p_out_info->pcm_len == buffer_bytes) { + memcpy(buffer, p_out_info + 1, p_out_info->pcm_len); + dec_ret = A2DP_DECODER_NO_ERROR; + } else { + dec_ret = A2DP_DECODER_DECODE_ERROR; + } - int decoder_size; + ret = a2dp_cp_consume_full_out_frame(); + ASSERT(ret == 0, "%s: a2dp_cp_consume_full_out_frame() failed: ret=%d", + __func__, ret); - decoder_size = ssc_decoder_get_size(output_config.num_channels); //todo: get size with codec capability + return dec_ret; +} - TRACE(0, "decoder size %d", decoder_size); - - scalable_decoder_place = (unsigned char *)a2dp_audio_heap_malloc(decoder_size); - ASSERT_A2DP_DECODER(scalable_decoder_place, "no memory resource for scalable_decoder_place"); +TEXT_SSC_LOC int a2dp_cp_scalable_cp_decode(void) { + int ret; + enum CP_EMPTY_OUT_FRM_T out_frm_st; + uint8_t *out; + uint32_t out_len; + uint8_t *dec_start; + uint32_t dec_len; + struct A2DP_CP_scalable_IN_FRM_INFO_T *p_in_info; + struct A2DP_CP_scalable_OUT_FRM_INFO_T *p_out_info; + uint8_t *in_buf; + uint32_t in_len; + uint32_t dec_sum; + int error, output_samples = 0, output_byte = 0; - scalable_decoder_temp_buf = (unsigned char *)a2dp_audio_heap_malloc(SCALABLE_FRAME_SIZE * 16); - ASSERT_A2DP_DECODER(scalable_decoder_temp_buf, "no memory resource for scalable_decoder_temp_buf"); - -#ifdef A2DP_CP_ACCEL - int ret; - cp_codec_reset = true; - ret = a2dp_cp_init(a2dp_cp_scalable_cp_decode, CP_PROC_DELAY_1_FRAME); - ASSERT(ret == 0, "%s: a2dp_cp_init() failed: ret=%d", __func__, ret); -#else + if (cp_codec_reset) { + cp_codec_reset = false; a2dp_audio_scalable_decoder_init(); + } + + out_frm_st = a2dp_cp_get_emtpy_out_frame((void **)&out, &out_len); + + if (out_frm_st != CP_EMPTY_OUT_FRM_OK && + out_frm_st != CP_EMPTY_OUT_FRM_WORKING) { + return 1; + } + + ASSERT(out_len > sizeof(*p_out_info), "%s: Bad out_len %u (should > %u)", + __func__, out_len, sizeof(*p_out_info)); + + p_out_info = (struct A2DP_CP_scalable_OUT_FRM_INFO_T *)out; + if (out_frm_st == CP_EMPTY_OUT_FRM_OK) { + p_out_info->pcm_len = 0; + p_out_info->decoded_frames = 0; + } + + ASSERT(out_len > sizeof(*p_out_info) + p_out_info->pcm_len, + "%s: Bad out_len %u (should > %u + %u)", __func__, out_len, + sizeof(*p_out_info), p_out_info->pcm_len); + + dec_start = (uint8_t *)(p_out_info + 1) + p_out_info->pcm_len; + dec_len = out_len - (dec_start - (uint8_t *)out); + if (!scalableDec_handle) { + TRACE(0, "scalable_decode not ready"); + return 3; + } + + dec_sum = 0; + error = 0; + + while (dec_sum < dec_len && error == 0) { + ret = a2dp_cp_get_in_frame((void **)&in_buf, &in_len); + + if (ret) { + break; + } + + ASSERT(in_len > sizeof(*p_in_info), "%s: Bad in_len %u (should > %u)", + __func__, in_len, sizeof(*p_in_info)); + p_in_info = (struct A2DP_CP_scalable_IN_FRM_INFO_T *)in_buf; + in_buf += sizeof(*p_in_info); + in_len -= sizeof(*p_in_info); + /* decode one SSC frame */ + output_samples = + ssc_decode(scalableDec_handle, (const unsigned char *)in_buf, + ss_pcm_buff, SCALABLE_FRAME_SIZE, 0, 2); + if (0 == output_samples) { + a2dp_audio_scalable_decoder_reinit(); + TRACE(0, "scalable_decode reinin codec \n"); + error = A2DP_DECODER_DECODE_ERROR; + goto exit; + } + + ss_to_24bit_buf((int32_t *)(dec_start + dec_sum), (int32_t *)ss_pcm_buff, + output_samples); + output_byte = output_samples * 4; + dec_sum += output_byte; + exit: + memcpy(&p_out_info->in_info, ss_pcm_buff, sizeof(*p_in_info)); + p_out_info->decoded_frames++; + p_out_info->frame_samples = SCALABLE_OUTPUT_FRAME_SAMPLES; + p_out_info->frame_idx = a2dp_cp_get_in_frame_index(); + + ret = a2dp_cp_consume_in_frame(); + ASSERT(ret == 0, "%s: a2dp_cp_consume_in_frame() failed: ret=%d", __func__, + ret); + } + + p_out_info->pcm_len += dec_sum; + + if (error || out_len <= sizeof(*p_out_info) + p_out_info->pcm_len) { + ret = a2dp_cp_consume_emtpy_out_frame(); + ASSERT(ret == 0, "%s: a2dp_cp_consume_emtpy_out_frame() failed: ret=%d", + __func__, ret); + } + + return error; +} #endif - return A2DP_DECODER_NO_ERROR; -} +static int a2dp_audio_scalable_init(A2DP_AUDIO_OUTPUT_CONFIG_T *config, + void *context) { + TRACE_A2DP_DECODER_D("%s", __func__); + + TRACE(0, "\n\nA2DP SSC-LC INIT\n"); + + a2dp_audio_context_p = (A2DP_AUDIO_CONTEXT_T *)context; + + memcpy(&output_config, config, sizeof(A2DP_AUDIO_OUTPUT_CONFIG_T)); + + memset(&lastframe_info, 0, sizeof(A2DP_AUDIO_DECODER_LASTFRAME_INFO_T)); + lastframe_info.stream_info = output_config; + lastframe_info.frame_samples = SCALABLE_FRAME_SIZE; + lastframe_info.list_samples = SCALABLE_FRAME_SIZE; + a2dp_audio_decoder_internal_lastframe_info_set(&lastframe_info); + + ASSERT(a2dp_audio_context_p->dest_packet_mut < SCALABLE_MTU_LIMITER, + "%s MTU OVERFLOW:%u/%u", __func__, + a2dp_audio_context_p->dest_packet_mut, SCALABLE_MTU_LIMITER); + + int decoder_size; + + decoder_size = ssc_decoder_get_size( + output_config.num_channels); // todo: get size with codec capability + + TRACE(0, "decoder size %d", decoder_size); + + scalable_decoder_place = + (unsigned char *)a2dp_audio_heap_malloc(decoder_size); + ASSERT_A2DP_DECODER(scalable_decoder_place, + "no memory resource for scalable_decoder_place"); + + scalable_decoder_temp_buf = + (unsigned char *)a2dp_audio_heap_malloc(SCALABLE_FRAME_SIZE * 16); + ASSERT_A2DP_DECODER(scalable_decoder_temp_buf, + "no memory resource for scalable_decoder_temp_buf"); -static int a2dp_audio_scalable_deinit(void) -{ #ifdef A2DP_CP_ACCEL - a2dp_cp_deinit(); + int ret; + cp_codec_reset = true; + ret = a2dp_cp_init(a2dp_cp_scalable_cp_decode, CP_PROC_DELAY_1_FRAME); + ASSERT(ret == 0, "%s: a2dp_cp_init() failed: ret=%d", __func__, ret); +#else + a2dp_audio_scalable_decoder_init(); #endif - a2dp_audio_scalable_decoder_deinit(); - - TRACE(0,"\n\nA2DP SCALABLE DEINIT\n"); - - return A2DP_DECODER_NO_ERROR; + return A2DP_DECODER_NO_ERROR; } -int a2dp_audio_scalable_mcu_decode_frame(uint8_t * buffer, uint32_t buffer_bytes) -{ - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - a2dp_audio_scalable_decoder_frame_t *decoder_frame_p = NULL; - int ret = A2DP_DECODER_NO_ERROR; +static int a2dp_audio_scalable_deinit(void) { +#ifdef A2DP_CP_ACCEL + a2dp_cp_deinit(); +#endif - bool cache_underflow = false; - int output_byte = 0, output_samples = 0; - uint8_t *output = buffer; - // TRACE(1,"bbd %d",buffer_bytes ); - if (buffer_bytes < (SCALABLE_FRAME_SIZE * output_config.num_channels * output_config.bits_depth / 8)) { - TRACE(1,"scalable_decode pcm_len = %d \n", buffer_bytes); + a2dp_audio_scalable_decoder_deinit(); + + TRACE(0, "\n\nA2DP SCALABLE DEINIT\n"); + + return A2DP_DECODER_NO_ERROR; +} + +int a2dp_audio_scalable_mcu_decode_frame(uint8_t *buffer, + uint32_t buffer_bytes) { + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + a2dp_audio_scalable_decoder_frame_t *decoder_frame_p = NULL; + int ret = A2DP_DECODER_NO_ERROR; + + bool cache_underflow = false; + int output_byte = 0, output_samples = 0; + uint8_t *output = buffer; + // TRACE(1,"bbd %d",buffer_bytes ); + if (buffer_bytes < (SCALABLE_FRAME_SIZE * output_config.num_channels * + output_config.bits_depth / 8)) { + TRACE(1, "scalable_decode pcm_len = %d \n", buffer_bytes); return A2DP_DECODER_NO_ERROR; - } - if (!scalableDec_handle) { - TRACE(0,"scalable_decode not ready"); - return A2DP_DECODER_NO_ERROR; - } + } + if (!scalableDec_handle) { + TRACE(0, "scalable_decode not ready"); + return A2DP_DECODER_NO_ERROR; + } - while (output < buffer + buffer_bytes) { - node = a2dp_audio_list_begin(list); - if (!node) { - TRACE(0,"scalable_decode cache underflow"); - cache_underflow = true; - goto exit; + while (output < buffer + buffer_bytes) { + node = a2dp_audio_list_begin(list); + if (!node) { + TRACE(0, "scalable_decode cache underflow"); + cache_underflow = true; + goto exit; } else { - decoder_frame_p = (a2dp_audio_scalable_decoder_frame_t *) - a2dp_audio_list_node(node); + decoder_frame_p = + (a2dp_audio_scalable_decoder_frame_t *)a2dp_audio_list_node(node); - if (false == is_valid_frame(decoder_frame_p)) { + if (false == is_valid_frame(decoder_frame_p)) { TRACE_A2DP_DECODER_E("%s %d invalid a2dp frame", __func__, __LINE__); ret = A2DP_DECODER_DECODE_ERROR; goto exit; - } + } - /* decode one SSC frame */ - output_samples = - ssc_decode(scalableDec_handle, - decoder_frame_p->buffer, ss_pcm_buff, SCALABLE_FRAME_SIZE,0,2); + /* decode one SSC frame */ + output_samples = ssc_decode(scalableDec_handle, decoder_frame_p->buffer, + ss_pcm_buff, SCALABLE_FRAME_SIZE, 0, 2); - TRACE_A2DP_DECODER_D - ("scalable_decode seq:%d len:%d output_samples:%d", - decoder_frame_p->sequenceNumber, decoder_frame_p->buffer_len, output_samples); + TRACE_A2DP_DECODER_D("scalable_decode seq:%d len:%d output_samples:%d", + decoder_frame_p->sequenceNumber, + decoder_frame_p->buffer_len, output_samples); - if (0 == output_samples) { - TRACE(0,"scalable_decode failed !!!!!!"); - //if failed reopen it again + if (0 == output_samples) { + TRACE(0, "scalable_decode failed !!!!!!"); + // if failed reopen it again a2dp_audio_scalable_decoder_reinit(); - TRACE(0,"scalable_decode reinin codec \n"); + TRACE(0, "scalable_decode reinin codec \n"); ret = A2DP_DECODER_DECODE_ERROR; goto exit; - } - ss_to_24bit_buf((int32_t *) output, (int32_t *) ss_pcm_buff, output_samples * 2); - output_byte = output_samples * 8; - - - output += output_byte; - ASSERT(SCALABLE_FRAME_SIZE == output_samples, "scalable_decode output mismatch samples:%d", output_samples); - lastframe_info.sequenceNumber = decoder_frame_p->sequenceNumber; - lastframe_info.timestamp = decoder_frame_p->timestamp; - lastframe_info.curSubSequenceNumber = 0; - lastframe_info.totalSubSequenceNumber = 0; - lastframe_info.frame_samples = SCALABLE_FRAME_SIZE; - lastframe_info.decoded_frames++; - lastframe_info.undecode_frames = a2dp_audio_list_length(list) - 1; - a2dp_audio_decoder_internal_lastframe_info_set(&lastframe_info); - a2dp_audio_list_remove(list, decoder_frame_p); + } + ss_to_24bit_buf((int32_t *)output, (int32_t *)ss_pcm_buff, + output_samples * 2); + output_byte = output_samples * 8; + output += output_byte; + ASSERT(SCALABLE_FRAME_SIZE == output_samples, + "scalable_decode output mismatch samples:%d", output_samples); + lastframe_info.sequenceNumber = decoder_frame_p->sequenceNumber; + lastframe_info.timestamp = decoder_frame_p->timestamp; + lastframe_info.curSubSequenceNumber = 0; + lastframe_info.totalSubSequenceNumber = 0; + lastframe_info.frame_samples = SCALABLE_FRAME_SIZE; + lastframe_info.decoded_frames++; + lastframe_info.undecode_frames = a2dp_audio_list_length(list) - 1; + a2dp_audio_decoder_internal_lastframe_info_set(&lastframe_info); + a2dp_audio_list_remove(list, decoder_frame_p); } + } - } - - exit: - if (cache_underflow) { +exit: + if (cache_underflow) { lastframe_info.undecode_frames = 0; a2dp_audio_decoder_internal_lastframe_info_set(&lastframe_info); ret = A2DP_DECODER_CACHE_UNDERFLOW_ERROR; - } - //TRACE(0,"abd"); - return ret; + } + // TRACE(0,"abd"); + return ret; } -static int a2dp_audio_scalable_decode_frame(uint8_t * buffer, uint32_t buffer_bytes) -{ +static int a2dp_audio_scalable_decode_frame(uint8_t *buffer, + uint32_t buffer_bytes) { #ifdef A2DP_CP_ACCEL - return a2dp_cp_scalable_mcu_decode(buffer, buffer_bytes); + return a2dp_cp_scalable_mcu_decode(buffer, buffer_bytes); #else - return a2dp_audio_scalable_mcu_decode_frame(buffer, buffer_bytes); + return a2dp_audio_scalable_mcu_decode_frame(buffer, buffer_bytes); #endif } -static int a2dp_audio_scalable_preparse_packet(btif_media_header_t * header, uint8_t * buffer, uint32_t buffer_bytes) -{ - lastframe_info.sequenceNumber = header->sequenceNumber; - lastframe_info.timestamp = header->timestamp; - lastframe_info.curSubSequenceNumber = 0; - lastframe_info.totalSubSequenceNumber = 0; - lastframe_info.frame_samples = SCALABLE_FRAME_SIZE; - lastframe_info.list_samples = SCALABLE_FRAME_SIZE; - lastframe_info.decoded_frames = 0; - lastframe_info.undecode_frames = 0; - a2dp_audio_decoder_internal_lastframe_info_set(&lastframe_info); +static int a2dp_audio_scalable_preparse_packet(btif_media_header_t *header, + uint8_t *buffer, + uint32_t buffer_bytes) { + lastframe_info.sequenceNumber = header->sequenceNumber; + lastframe_info.timestamp = header->timestamp; + lastframe_info.curSubSequenceNumber = 0; + lastframe_info.totalSubSequenceNumber = 0; + lastframe_info.frame_samples = SCALABLE_FRAME_SIZE; + lastframe_info.list_samples = SCALABLE_FRAME_SIZE; + lastframe_info.decoded_frames = 0; + lastframe_info.undecode_frames = 0; + a2dp_audio_decoder_internal_lastframe_info_set(&lastframe_info); - TRACE(3,"%s seq:%d timestamp:%08x", __func__, header->sequenceNumber, header->timestamp); + TRACE(3, "%s seq:%d timestamp:%08x", __func__, header->sequenceNumber, + header->timestamp); - return A2DP_DECODER_NO_ERROR; + return A2DP_DECODER_NO_ERROR; } -static void *a2dp_audio_scalable_frame_malloc(uint32_t packet_len) -{ - a2dp_audio_scalable_decoder_frame_t *decoder_frame_p = NULL; - uint8_t *buffer = NULL; +static void *a2dp_audio_scalable_frame_malloc(uint32_t packet_len) { + a2dp_audio_scalable_decoder_frame_t *decoder_frame_p = NULL; + uint8_t *buffer = NULL; - buffer = (uint8_t *) a2dp_audio_heap_malloc(SCALABLE_READBUF_SIZE); - decoder_frame_p = (a2dp_audio_scalable_decoder_frame_t *) - a2dp_audio_heap_malloc(sizeof(a2dp_audio_scalable_decoder_frame_t)); - decoder_frame_p->buffer = buffer; - decoder_frame_p->buffer_len = packet_len; - return (void *)decoder_frame_p; + buffer = (uint8_t *)a2dp_audio_heap_malloc(SCALABLE_READBUF_SIZE); + decoder_frame_p = + (a2dp_audio_scalable_decoder_frame_t *)a2dp_audio_heap_malloc( + sizeof(a2dp_audio_scalable_decoder_frame_t)); + decoder_frame_p->buffer = buffer; + decoder_frame_p->buffer_len = packet_len; + return (void *)decoder_frame_p; } -static void a2dp_audio_scalable_free(void *packet) -{ - a2dp_audio_scalable_decoder_frame_t *decoder_frame_p = (a2dp_audio_scalable_decoder_frame_t *) packet; - a2dp_audio_heap_free(decoder_frame_p->buffer); - a2dp_audio_heap_free(decoder_frame_p); +static void a2dp_audio_scalable_free(void *packet) { + a2dp_audio_scalable_decoder_frame_t *decoder_frame_p = + (a2dp_audio_scalable_decoder_frame_t *)packet; + a2dp_audio_heap_free(decoder_frame_p->buffer); + a2dp_audio_heap_free(decoder_frame_p); } -static int a2dp_audio_scalable_store_packet(btif_media_header_t * header, uint8_t * buffer, uint32_t buffer_bytes) -{ - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - int nRet = A2DP_DECODER_NO_ERROR; - if (a2dp_audio_list_length(list) < SCALABLE_MTU_LIMITER) { - a2dp_audio_scalable_decoder_frame_t *decoder_frame_p = (a2dp_audio_scalable_decoder_frame_t *) - a2dp_audio_scalable_frame_malloc(buffer_bytes); - TRACE_A2DP_DECODER_D("%s seq:%d len:%d", __func__, header->sequenceNumber, buffer_bytes); +static int a2dp_audio_scalable_store_packet(btif_media_header_t *header, + uint8_t *buffer, + uint32_t buffer_bytes) { + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + int nRet = A2DP_DECODER_NO_ERROR; + if (a2dp_audio_list_length(list) < SCALABLE_MTU_LIMITER) { + a2dp_audio_scalable_decoder_frame_t *decoder_frame_p = + (a2dp_audio_scalable_decoder_frame_t *)a2dp_audio_scalable_frame_malloc( + buffer_bytes); + TRACE_A2DP_DECODER_D("%s seq:%d len:%d", __func__, header->sequenceNumber, + buffer_bytes); decoder_frame_p->sequenceNumber = header->sequenceNumber; decoder_frame_p->timestamp = header->timestamp; memcpy(decoder_frame_p->buffer, buffer, buffer_bytes); decoder_frame_p->buffer_len = buffer_bytes; a2dp_audio_list_append(list, decoder_frame_p); nRet = A2DP_DECODER_NO_ERROR; - } else { - TRACE(2,"%s list full current len:%d", __func__, a2dp_audio_list_length(list)); + } else { + TRACE(2, "%s list full current len:%d", __func__, + a2dp_audio_list_length(list)); nRet = A2DP_DECODER_MTU_LIMTER_ERROR; - } + } - return nRet; + return nRet; } -static int a2dp_audio_scalable_discards_packet(uint32_t packets) -{ - int nRet = A2DP_DECODER_MEMORY_ERROR; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - a2dp_audio_scalable_decoder_frame_t *decoder_frame_p = NULL; +static int a2dp_audio_scalable_discards_packet(uint32_t packets) { + int nRet = A2DP_DECODER_MEMORY_ERROR; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + a2dp_audio_scalable_decoder_frame_t *decoder_frame_p = NULL; #ifdef A2DP_CP_ACCEL - a2dp_cp_reset_frame(); + a2dp_cp_reset_frame(); #endif - if (packets <= a2dp_audio_list_length(list)) { + if (packets <= a2dp_audio_list_length(list)) { for (uint8_t i = 0; i < packets; i++) { - if ((node = a2dp_audio_list_begin(list)) != NULL){ - decoder_frame_p = (a2dp_audio_scalable_decoder_frame_t *) - a2dp_audio_list_node(node); - a2dp_audio_list_remove(list, decoder_frame_p); - } + if ((node = a2dp_audio_list_begin(list)) != NULL) { + decoder_frame_p = + (a2dp_audio_scalable_decoder_frame_t *)a2dp_audio_list_node(node); + a2dp_audio_list_remove(list, decoder_frame_p); + } } nRet = A2DP_DECODER_NO_ERROR; + } + + TRACE(3, "%s packets:%d nRet:%d", __func__, packets, nRet); + return nRet; +} + +static int a2dp_audio_scalable_headframe_info_get( + A2DP_AUDIO_HEADFRAME_INFO_T *headframe_info) { + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + a2dp_audio_scalable_decoder_frame_t *decoder_frame_p = NULL; + + if (a2dp_audio_list_length(list)) { + if ((node = a2dp_audio_list_begin(list)) != NULL) { + decoder_frame_p = + (a2dp_audio_scalable_decoder_frame_t *)a2dp_audio_list_node(node); + headframe_info->sequenceNumber = decoder_frame_p->sequenceNumber; + headframe_info->timestamp = decoder_frame_p->timestamp; + headframe_info->curSubSequenceNumber = 0; + headframe_info->totalSubSequenceNumber = 0; } + } else { + memset(headframe_info, 0, sizeof(A2DP_AUDIO_HEADFRAME_INFO_T)); + } - TRACE(3,"%s packets:%d nRet:%d", __func__, packets, nRet); - return nRet; + return A2DP_DECODER_NO_ERROR; } -static int a2dp_audio_scalable_headframe_info_get(A2DP_AUDIO_HEADFRAME_INFO_T* headframe_info) -{ - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - a2dp_audio_scalable_decoder_frame_t *decoder_frame_p = NULL; - - if (a2dp_audio_list_length(list)){ - if ((node = a2dp_audio_list_begin(list)) != NULL){ - decoder_frame_p = (a2dp_audio_scalable_decoder_frame_t *)a2dp_audio_list_node(node); - headframe_info->sequenceNumber = decoder_frame_p->sequenceNumber; - headframe_info->timestamp = decoder_frame_p->timestamp; - headframe_info->curSubSequenceNumber = 0; - headframe_info->totalSubSequenceNumber = 0; - } - }else{ - memset(headframe_info, 0, sizeof(A2DP_AUDIO_HEADFRAME_INFO_T)); - } - - return A2DP_DECODER_NO_ERROR; +static int a2dp_audio_scalable_info_get(void *info) { + return A2DP_DECODER_NO_ERROR; } -static int a2dp_audio_scalable_info_get(void *info) -{ - return A2DP_DECODER_NO_ERROR; -} - -static int a2dp_audio_scalable_synchronize_packet(A2DP_AUDIO_SYNCFRAME_INFO_T * sync_info, uint32_t mask) -{ - int nRet = A2DP_DECODER_SYNC_ERROR; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - list_node_t *node = NULL; - int list_len; - a2dp_audio_scalable_decoder_frame_t *decoder_frame_p = NULL; +static int +a2dp_audio_scalable_synchronize_packet(A2DP_AUDIO_SYNCFRAME_INFO_T *sync_info, + uint32_t mask) { + int nRet = A2DP_DECODER_SYNC_ERROR; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + list_node_t *node = NULL; + int list_len; + a2dp_audio_scalable_decoder_frame_t *decoder_frame_p = NULL; #ifdef A2DP_CP_ACCEL - a2dp_cp_reset_frame(); + a2dp_cp_reset_frame(); #endif - list_len = a2dp_audio_list_length(list); + list_len = a2dp_audio_list_length(list); - for (uint16_t i = 0; i < list_len; i++) { - if ((node = a2dp_audio_list_begin(list)) != NULL){ - decoder_frame_p = (a2dp_audio_scalable_decoder_frame_t *) - a2dp_audio_list_node(node); - if (A2DP_AUDIO_SYNCFRAME_CHK(decoder_frame_p->sequenceNumber == sync_info->sequenceNumber, A2DP_AUDIO_SYNCFRAME_MASK_SEQ, mask)&& - A2DP_AUDIO_SYNCFRAME_CHK(decoder_frame_p->timestamp == sync_info->timestamp, A2DP_AUDIO_SYNCFRAME_MASK_TIMESTAMP, mask)) { - nRet = A2DP_DECODER_NO_ERROR; - break; - } - a2dp_audio_list_remove(list, decoder_frame_p); - } - } - - node = a2dp_audio_list_begin(list); - if (node) { - decoder_frame_p = (a2dp_audio_scalable_decoder_frame_t *) - a2dp_audio_list_node(node); - TRACE(4,"%s nRet:%d SEQ:%d timestamp:%d", __func__, nRet, - decoder_frame_p->sequenceNumber, decoder_frame_p->timestamp); - } else { - TRACE(2,"%s nRet:%d", __func__, nRet); - } - - return nRet; -} - -static int a2dp_audio_scalable_synchronize_dest_packet_mut(uint16_t packet_mut) -{ - list_node_t *node = NULL; - uint32_t list_len = 0; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - a2dp_audio_scalable_decoder_frame_t *decoder_frame_p = NULL; - - list_len = a2dp_audio_list_length(list); - if (list_len > packet_mut) { - do { - node = a2dp_audio_list_begin(list); - if (node) - { - decoder_frame_p = (a2dp_audio_scalable_decoder_frame_t *) - a2dp_audio_list_node(node); - a2dp_audio_list_remove(list, decoder_frame_p); - } - } while (a2dp_audio_list_length(list) > packet_mut); - } - - TRACE(2,"%s list:%d", __func__, a2dp_audio_list_length(list)); - - return A2DP_DECODER_NO_ERROR; -} - -int a2dp_audio_scalable_convert_list_to_samples(uint32_t *samples) -{ - uint32_t list_len = 0; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - - list_len = a2dp_audio_list_length(list); - *samples = SCALABLE_FRAME_SIZE*list_len; - - TRACE(3, "%s list:%d samples:%d", __func__, list_len, *samples); - - return A2DP_DECODER_NO_ERROR; -} - -int a2dp_audio_scalable_discards_samples(uint32_t samples) -{ - int nRet = A2DP_DECODER_SYNC_ERROR; - list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; - a2dp_audio_scalable_decoder_frame_t *scalable_decoder_frame = NULL; - list_node_t *node = NULL; - int need_remove_list = 0; - uint32_t list_samples = 0; - ASSERT(!(samples%SCALABLE_FRAME_SIZE), "%s samples err:%d", __func__, samples); - - a2dp_audio_scalable_convert_list_to_samples(&list_samples); - if (list_samples >= samples){ - need_remove_list = samples/SCALABLE_FRAME_SIZE; - for (int i=0; isequenceNumber == + sync_info->sequenceNumber, + A2DP_AUDIO_SYNCFRAME_MASK_SEQ, mask) && + A2DP_AUDIO_SYNCFRAME_CHK(decoder_frame_p->timestamp == + sync_info->timestamp, + A2DP_AUDIO_SYNCFRAME_MASK_TIMESTAMP, mask)) { nRet = A2DP_DECODER_NO_ERROR; + break; + } + a2dp_audio_list_remove(list, decoder_frame_p); } + } - return nRet; + node = a2dp_audio_list_begin(list); + if (node) { + decoder_frame_p = + (a2dp_audio_scalable_decoder_frame_t *)a2dp_audio_list_node(node); + TRACE(4, "%s nRet:%d SEQ:%d timestamp:%d", __func__, nRet, + decoder_frame_p->sequenceNumber, decoder_frame_p->timestamp); + } else { + TRACE(2, "%s nRet:%d", __func__, nRet); + } + + return nRet; +} + +static int +a2dp_audio_scalable_synchronize_dest_packet_mut(uint16_t packet_mut) { + list_node_t *node = NULL; + uint32_t list_len = 0; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + a2dp_audio_scalable_decoder_frame_t *decoder_frame_p = NULL; + + list_len = a2dp_audio_list_length(list); + if (list_len > packet_mut) { + do { + node = a2dp_audio_list_begin(list); + if (node) { + decoder_frame_p = + (a2dp_audio_scalable_decoder_frame_t *)a2dp_audio_list_node(node); + a2dp_audio_list_remove(list, decoder_frame_p); + } + } while (a2dp_audio_list_length(list) > packet_mut); + } + + TRACE(2, "%s list:%d", __func__, a2dp_audio_list_length(list)); + + return A2DP_DECODER_NO_ERROR; +} + +int a2dp_audio_scalable_convert_list_to_samples(uint32_t *samples) { + uint32_t list_len = 0; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + + list_len = a2dp_audio_list_length(list); + *samples = SCALABLE_FRAME_SIZE * list_len; + + TRACE(3, "%s list:%d samples:%d", __func__, list_len, *samples); + + return A2DP_DECODER_NO_ERROR; +} + +int a2dp_audio_scalable_discards_samples(uint32_t samples) { + int nRet = A2DP_DECODER_SYNC_ERROR; + list_t *list = a2dp_audio_context_p->audio_datapath.input_raw_packet_list; + a2dp_audio_scalable_decoder_frame_t *scalable_decoder_frame = NULL; + list_node_t *node = NULL; + int need_remove_list = 0; + uint32_t list_samples = 0; + ASSERT(!(samples % SCALABLE_FRAME_SIZE), "%s samples err:%d", __func__, + samples); + + a2dp_audio_scalable_convert_list_to_samples(&list_samples); + if (list_samples >= samples) { + need_remove_list = samples / SCALABLE_FRAME_SIZE; + for (int i = 0; i < need_remove_list; i++) { + node = a2dp_audio_list_begin(list); + if (node) { + scalable_decoder_frame = + (a2dp_audio_scalable_decoder_frame_t *)a2dp_audio_list_node(node); + a2dp_audio_list_remove(list, scalable_decoder_frame); + } + } + nRet = A2DP_DECODER_NO_ERROR; + } + + return nRet; } A2DP_AUDIO_DECODER_T a2dp_audio_scalable_decoder_config = { {44100, 2, 16}, @@ -735,5 +749,7 @@ A2DP_AUDIO_DECODER_T a2dp_audio_scalable_decoder_config = { a2dp_audio_scalable_free, }; #else -A2DP_AUDIO_DECODER_T a2dp_audio_scalable_decoder_config = { 0, }; +A2DP_AUDIO_DECODER_T a2dp_audio_scalable_decoder_config = { + 0, +}; #endif diff --git a/apps/audioplayers/a2dpplay.cpp b/apps/audioplayers/a2dpplay.cpp index 5ac03f4..834b4c7 100644 --- a/apps/audioplayers/a2dpplay.cpp +++ b/apps/audioplayers/a2dpplay.cpp @@ -20,29 +20,28 @@ #include "rtos.h" #endif // Standard C Included Files -#include +#include "tgt_hardware.h" #include #include -#include #include -#include "tgt_hardware.h" +#include +#include #ifdef MBED #include "SDFileSystem.h" #endif -#include "hal_uart.h" -#include "hal_timer.h" -#include "hal_trace.h" -#include "hal_codec.h" -#include "audioflinger.h" -#include "cqueue.h" +#include "analog.h" #include "app_audio.h" #include "app_overlay.h" -#include "analog.h" +#include "audioflinger.h" +#include "cqueue.h" +#include "hal_codec.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" #ifdef RTOS #include "cmsis_os.h" #endif - extern "C" { #if defined(A2DP_LHDC_ON) #include "hal_sysfreq.h" @@ -54,8 +53,8 @@ extern "C" { #if defined(A2DP_LDAC_ON) #include "hal_sysfreq.h" //#include "speech_memory.h" -#include"ldacBT.h" -#define MED_MEM_HEAP_SIZE (1024*20) +#include "ldacBT.h" +#define MED_MEM_HEAP_SIZE (1024 * 20) HANDLE_LDAC_BT hLdacData = NULL; #endif } @@ -63,61 +62,61 @@ HANDLE_LDAC_BT hLdacData = NULL; #include "a2dp_api.h" #if defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE) -#include "hal_sysfreq.h" -#include "hal_chipid.h" #include "audio_resample_ex.h" +#include "hal_chipid.h" +#include "hal_sysfreq.h" #endif #include "btapp.h" -#include "hal_location.h" #include "cmsis.h" +#include "hal_location.h" -#define TEXT_A2DP_LOC_A(n, l) __attribute__((section(#n "." #l))) -#define TEXT_A2DP_LOC(n, l) TEXT_A2DP_LOC_A(n, l) +#define TEXT_A2DP_LOC_A(n, l) __attribute__((section(#n "." #l))) +#define TEXT_A2DP_LOC(n, l) TEXT_A2DP_LOC_A(n, l) -#define TEXT_SBC_LOC TEXT_A2DP_LOC(.overlay_a2dp_sbc, __LINE__) -#define TEXT_AAC_LOC TEXT_A2DP_LOC(.overlay_a2dp_aac, __LINE__) -#define TEXT_SSC_LOC TEXT_A2DP_LOC(.overlay_a2dp_ssc, __LINE__) -#define TEXT_LDAC_LOC TEXT_A2DP_LOC(.overlay_a2dp_ldac, __LINE__) -#define TEXT_LHDC_LOC TEXT_A2DP_LOC(.overlay_a2dp_lhdc, __LINE__) +#define TEXT_SBC_LOC TEXT_A2DP_LOC(.overlay_a2dp_sbc, __LINE__) +#define TEXT_AAC_LOC TEXT_A2DP_LOC(.overlay_a2dp_aac, __LINE__) +#define TEXT_SSC_LOC TEXT_A2DP_LOC(.overlay_a2dp_ssc, __LINE__) +#define TEXT_LDAC_LOC TEXT_A2DP_LOC(.overlay_a2dp_ldac, __LINE__) +#define TEXT_LHDC_LOC TEXT_A2DP_LOC(.overlay_a2dp_lhdc, __LINE__) //#define A2DP_AUDIO_SYNC_WITH_LOCAL (1) -#define A2DP_AUDIO_SYNC_TRACE(s,...) -//TRACE(s, ##__VA_ARGS__) +#define A2DP_AUDIO_SYNC_TRACE(s, ...) +// TRACE(s, ##__VA_ARGS__) #ifdef A2DP_AUDIO_SYNC_WITH_LOCAL #define A2DP_AUDIO_SYNC_WITH_LOCAL_SAMPLERATE_DEFAULT (0) -#define A2DP_AUDIO_SYNC_WITH_LOCAL_SAMPLERATE_INC (2) -#define A2DP_AUDIO_SYNC_WITH_LOCAL_SAMPLERATE_DEC (-2) -#define A2DP_AUDIO_SYNC_WITH_LOCAL_SAMPLERATE_STEP (0.00005f) +#define A2DP_AUDIO_SYNC_WITH_LOCAL_SAMPLERATE_INC (2) +#define A2DP_AUDIO_SYNC_WITH_LOCAL_SAMPLERATE_DEC (-2) +#define A2DP_AUDIO_SYNC_WITH_LOCAL_SAMPLERATE_STEP (0.00005f) #define A2DPPLAY_SYNC_STATUS_SET (0x01) #define A2DPPLAY_SYNC_STATUS_RESET (0x02) #define A2DPPLAY_SYNC_STATUS_PROC (0x04) enum A2DP_AUDIO_SYNC_STATUS { - A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_DEC, - A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_INC, - A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_DEFAULT, + A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_DEC, + A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_INC, + A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_DEFAULT, }; #endif -#define A2DPPLAY_CACHE_OK_THRESHOLD (sbc_frame_size<<6) +#define A2DPPLAY_CACHE_OK_THRESHOLD (sbc_frame_size << 6) enum A2DPPLAY_STRTEAM_T { - A2DPPLAY_STRTEAM_PUT= 0, - A2DPPLAY_STRTEAM_GET, - A2DPPLAY_STRTEAM_QTY, + A2DPPLAY_STRTEAM_PUT = 0, + A2DPPLAY_STRTEAM_GET, + A2DPPLAY_STRTEAM_QTY, }; /* sbc queue */ #define SBC_TEMP_BUFFER_SIZE 128 -#define SBC_QUEUE_SIZE_DEFAULT (SBC_TEMP_BUFFER_SIZE*64) -#define SBC_QUEUE_SIZE (1024*11) +#define SBC_QUEUE_SIZE_DEFAULT (SBC_TEMP_BUFFER_SIZE * 64) +#define SBC_QUEUE_SIZE (1024 * 11) /* sbc decoder */ static bool need_init_decoder = true; -static btif_sbc_decoder_t* sbc_decoder = NULL; +static btif_sbc_decoder_t *sbc_decoder = NULL; static float sbc_eq_band_gain[CFG_HW_AUD_EQ_NUM_BANDS]; @@ -156,32 +155,36 @@ static const bool allow_resample = true; extern int a2dp_timestamp_parser_needsync(void); -#define A2DP_SYNC_WITH_GET_MUTUX_ALLOC() do{ \ - if (a2dp_put_thread_tid == NULL){ \ - a2dp_put_thread_tid = osThreadGetId(); \ - } \ - }while(0) +#define A2DP_SYNC_WITH_GET_MUTUX_ALLOC() \ + do { \ + if (a2dp_put_thread_tid == NULL) { \ + a2dp_put_thread_tid = osThreadGetId(); \ + } \ + } while (0) -#define A2DP_SYNC_WITH_GET_MUTUX_FREE() do{ \ - a2dp_put_thread_tid = NULL; \ - }while(0) +#define A2DP_SYNC_WITH_GET_MUTUX_FREE() \ + do { \ + a2dp_put_thread_tid = NULL; \ + } while (0) -#define A2DP_SYNC_WITH_GET_MUTUX_WAIT() do{ \ - a2dp_get_need_sync = true; \ - if (a2dp_put_thread_tid){ \ - osSignalClear(a2dp_put_thread_tid, 0x80); \ - osSignalWait(0x80, A2DP_SYNC_WITH_GET_MUTUX_TIMEROUT_MS); \ - }\ - }while(0) +#define A2DP_SYNC_WITH_GET_MUTUX_WAIT() \ + do { \ + a2dp_get_need_sync = true; \ + if (a2dp_put_thread_tid) { \ + osSignalClear(a2dp_put_thread_tid, 0x80); \ + osSignalWait(0x80, A2DP_SYNC_WITH_GET_MUTUX_TIMEROUT_MS); \ + } \ + } while (0) -#define A2DP_SYNC_WITH_GET_MUTUX_SET() do{ \ - if (a2dp_get_need_sync){ \ - a2dp_get_need_sync = false; \ - if (a2dp_put_thread_tid){ \ - osSignalSet(a2dp_put_thread_tid, 0x80); \ - } \ - } \ - }while(0) +#define A2DP_SYNC_WITH_GET_MUTUX_SET() \ + do { \ + if (a2dp_get_need_sync) { \ + a2dp_get_need_sync = false; \ + if (a2dp_put_thread_tid) { \ + osSignalSet(a2dp_put_thread_tid, 0x80); \ + } \ + } \ + } while (0) //#define A2DP_SYNC_WITH_PUT_MUTUX (1) #define A2DP_SYNC_WITH_PUT_MUTUX_TIMEROUT_CNT (1) @@ -189,126 +192,129 @@ extern int a2dp_timestamp_parser_needsync(void); static osThreadId a2dp_get_thread_tid = NULL; static bool a2dp_get_put_sync = false; -#define A2DP_SYNC_WITH_PUT_MUTUX_ALLOC() do{ \ - if (a2dp_get_thread_tid == NULL){ \ - a2dp_get_thread_tid = osThreadGetId(); \ - } \ - }while(0) +#define A2DP_SYNC_WITH_PUT_MUTUX_ALLOC() \ + do { \ + if (a2dp_get_thread_tid == NULL) { \ + a2dp_get_thread_tid = osThreadGetId(); \ + } \ + } while (0) -#define A2DP_SYNC_WITH_PUT_MUTUX_FREE() do{ \ - a2dp_get_thread_tid = NULL; \ - }while(0) +#define A2DP_SYNC_WITH_PUT_MUTUX_FREE() \ + do { \ + a2dp_get_thread_tid = NULL; \ + } while (0) -#define A2DP_SYNC_WITH_PUT_MUTUX_WAIT() do{ \ - a2dp_get_put_sync = true; \ - if (a2dp_get_thread_tid){\ - osSignalClear(a2dp_get_thread_tid, 0x80); \ - osSignalWait(0x5, A2DP_SYNC_WITH_PUT_MUTUX_TIMEROUT_MS); \ - }\ - }while(0) +#define A2DP_SYNC_WITH_PUT_MUTUX_WAIT() \ + do { \ + a2dp_get_put_sync = true; \ + if (a2dp_get_thread_tid) { \ + osSignalClear(a2dp_get_thread_tid, 0x80); \ + osSignalWait(0x5, A2DP_SYNC_WITH_PUT_MUTUX_TIMEROUT_MS); \ + } \ + } while (0) -#define A2DP_SYNC_WITH_PUT_MUTUX_SET() do{ \ - if (a2dp_get_put_sync){ \ - a2dp_get_put_sync = false; \ - if (a2dp_get_thread_tid){\ - osSignalSet(a2dp_get_thread_tid, 0x80); \ - }\ - } \ - }while(0) - - -int a2dp_audio_sbc_set_frame_info(int rcv_len, int frame_num) -{ - if ((!rcv_len)||(!frame_num)){ - return 0; - } - - if (sbc_frame_rev_len != rcv_len || sbc_frame_num != frame_num){ - sbc_frame_rev_len = rcv_len; - sbc_frame_num = frame_num; - sbc_frame_size = rcv_len/frame_num; - } +#define A2DP_SYNC_WITH_PUT_MUTUX_SET() \ + do { \ + if (a2dp_get_put_sync) { \ + a2dp_get_put_sync = false; \ + if (a2dp_get_thread_tid) { \ + osSignalSet(a2dp_get_thread_tid, 0x80); \ + } \ + } \ + } while (0) +int a2dp_audio_sbc_set_frame_info(int rcv_len, int frame_num) { + if ((!rcv_len) || (!frame_num)) { return 0; + } + + if (sbc_frame_rev_len != rcv_len || sbc_frame_num != frame_num) { + sbc_frame_rev_len = rcv_len; + sbc_frame_num = frame_num; + sbc_frame_size = rcv_len / frame_num; + } + + return 0; } -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; extern uint8_t a2dp_channel_num[BT_DEVICE_NUM]; -void expand_1_channel_to_2_channels_16bits(unsigned char *in, unsigned int in_len) -{ - int cnt = 0; - int len = in_len; - short* ptr = (short*)in + in_len/2; - short* ptr_out = (short*)in + in_len; +void expand_1_channel_to_2_channels_16bits(unsigned char *in, + unsigned int in_len) { + int cnt = 0; + int len = in_len; + short *ptr = (short *)in + in_len / 2; + short *ptr_out = (short *)in + in_len; - while(len > 0){ - *(ptr_out - 2*cnt - 1) = *(ptr - cnt); - *(ptr_out - 2*cnt - 2) = *(ptr - cnt); - cnt += 1; - len -= 2; - } + while (len > 0) { + *(ptr_out - 2 * cnt - 1) = *(ptr - cnt); + *(ptr_out - 2 * cnt - 2) = *(ptr - cnt); + cnt += 1; + len -= 2; + } } #ifdef A2DP_AUDIO_SYNC_WITH_LOCAL -static enum A2DP_AUDIO_SYNC_STATUS sync_status = A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_DEFAULT; +static enum A2DP_AUDIO_SYNC_STATUS sync_status = + A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_DEFAULT; -static int a2dp_audio_sync_proc(uint8_t status, int shift) -{ +static int a2dp_audio_sync_proc(uint8_t status, int shift) { #if !(defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE)) - struct AF_STREAM_CONFIG_T *cfg; + struct AF_STREAM_CONFIG_T *cfg; - bool need_shift = false; - static int cur_shift = 0; - static int dest_shift = 0; + bool need_shift = false; + static int cur_shift = 0; + static int dest_shift = 0; - LOCK_APP_AUDIO_QUEUE(); - if (status & A2DPPLAY_SYNC_STATUS_RESET){ - sync_status = A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_DEFAULT; - cur_shift = 0; - dest_shift = 0; + LOCK_APP_AUDIO_QUEUE(); + if (status & A2DPPLAY_SYNC_STATUS_RESET) { + sync_status = A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_DEFAULT; + cur_shift = 0; + dest_shift = 0; + } + if (status & A2DPPLAY_SYNC_STATUS_SET) { + dest_shift = shift; + } + if (cur_shift > dest_shift) { + cur_shift--; + need_shift = true; + } + if (cur_shift < dest_shift) { + cur_shift++; + need_shift = true; + } + if (need_shift) { + A2DP_AUDIO_SYNC_TRACE(1, "a2dp_audio_sync_proc shift:%d\n", cur_shift); + uint32_t ret = + af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &cfg, false); + if (0 == ret) { + af_codec_tune(AUD_STREAM_PLAYBACK, + A2DP_AUDIO_SYNC_WITH_LOCAL_SAMPLERATE_STEP * cur_shift); } - if (status & A2DPPLAY_SYNC_STATUS_SET){ - dest_shift = shift; - } - if (cur_shift > dest_shift){ - cur_shift--; - need_shift = true; - } - if (cur_shift= A2DPPLAY_STRTEAM_QTY) - return false; + if (stream >= A2DPPLAY_STRTEAM_QTY) + return false; - stream_running[stream] = run; + stream_running[stream] = run; - if (stream_running[A2DPPLAY_STRTEAM_PUT] && stream_running[A2DPPLAY_STRTEAM_GET]) - return true; - else - return false; + if (stream_running[A2DPPLAY_STRTEAM_PUT] && + stream_running[A2DPPLAY_STRTEAM_GET]) + return true; + else + return false; } #if defined(A2DP_AAC_ON) -#define AAC_READBUF_SIZE (2048) +#define AAC_READBUF_SIZE (2048) uint32_t aac_maxreadBytes = AAC_READBUF_SIZE; uint32_t aac_frame_mute = 0; @@ -318,83 +324,82 @@ int decode_aac_frame(unsigned char *pcm_buffer, unsigned int pcm_len); #if defined(A2DP_LHDC_ON) #include "hal_timer.h" -#define A2DP_LHDC_DEFAULT_LATENCY 1 +#define A2DP_LHDC_DEFAULT_LATENCY 1 uint8_t latencyIndex = 0; uint8_t latencyUpdated = 0; uint16_t latencyTable[] = {50, 150, 300}; -uint8_t magicTag[] = {'l','h','d','c'}; +uint8_t magicTag[] = {'l', 'h', 'd', 'c'}; typedef struct { - uint8_t tag[4]; - uint32_t packetLen; - uint8_t dptr[0]; + uint8_t tag[4]; + uint32_t packetLen; + uint8_t dptr[0]; } LHDC_HEADER; typedef struct { - uint16_t frame_len; - bool isSplit; - bool isLeft; + uint16_t frame_len; + bool isSplit; + bool isLeft; } LHDC_FRAME_HDR; -#define LHDC_READBUF_SIZE 1024 * 4 /* pick something big enough to hold a bunch of frames */ +#define LHDC_READBUF_SIZE \ + 1024 * 4 /* pick something big enough to hold a bunch of frames */ uint8_t lhdcTempBuf[LHDC_READBUF_SIZE]; uint8_t lhdc_input_mid_buf[LHDC_READBUF_SIZE]; -#define L2CAP_MTU 672 -#define PACKET_MTU_SIZE (L2CAP_MTU-12) - +#define L2CAP_MTU 672 +#define PACKET_MTU_SIZE (L2CAP_MTU - 12) void initial_lhdc_assemble_packet(bool splitFlg); /** * get lhdc frame header */ -bool get_lhdc_header(uint8_t * in, LHDC_FRAME_HDR * h); +bool get_lhdc_header(uint8_t *in, LHDC_FRAME_HDR *h); -uint32_t get_lhdc_frame(uint8_t * frame_q, size_t q_available_size, uint8_t * out_buf, uint32_t * out_size, uint32_t * out_frames); +uint32_t get_lhdc_frame(uint8_t *frame_q, size_t q_available_size, + uint8_t *out_buf, uint32_t *out_size, + uint32_t *out_frames); /** * Grabe lhdc data from queue */ -int get_lhdc_data(unsigned char * frame, unsigned int len); -int assemble_lhdc_packet(uint8_t * input, uint32_t input_len, - uint8_t** pLout, uint32_t * pLlen, - uint8_t** pRout, uint32_t * pRlen); +int get_lhdc_data(unsigned char *frame, unsigned int len); +int assemble_lhdc_packet(uint8_t *input, uint32_t input_len, uint8_t **pLout, + uint32_t *pLlen, uint8_t **pRout, uint32_t *pRlen); #endif #if defined(A2DP_LDAC_ON) -#define LDAC_FRAME_LEN_INDEX_106 106 -#define LDAC_FRAME_LEN_INDEX_128 128 -#define LDAC_FRAME_LEN_INDEX_160 160 -#define LDAC_FRAME_LEN_INDEX_216 216 -#define LDAC_FRAME_LEN_INDEX_326 326 +#define LDAC_FRAME_LEN_INDEX_106 106 +#define LDAC_FRAME_LEN_INDEX_128 128 +#define LDAC_FRAME_LEN_INDEX_160 160 +#define LDAC_FRAME_LEN_INDEX_216 216 +#define LDAC_FRAME_LEN_INDEX_326 326 -uint8_t get_ldac_frame_num(uint16_t frame_length_index){ - uint8_t frame_num = 0; - switch(frame_length_index) - { - case LDAC_FRAME_LEN_INDEX_106: - frame_num = 6; - break; - case LDAC_FRAME_LEN_INDEX_128: - frame_num = 5; - break; - case LDAC_FRAME_LEN_INDEX_160: - frame_num = 4; - break; - case LDAC_FRAME_LEN_INDEX_216: - frame_num = 3; - break; - case LDAC_FRAME_LEN_INDEX_326: - frame_num = 2; - break; - default: - ASSERT(0, "Unknown ldac frame format: %d !!!!!",frame_length_index); - break; - } - return frame_num; +uint8_t get_ldac_frame_num(uint16_t frame_length_index) { + uint8_t frame_num = 0; + switch (frame_length_index) { + case LDAC_FRAME_LEN_INDEX_106: + frame_num = 6; + break; + case LDAC_FRAME_LEN_INDEX_128: + frame_num = 5; + break; + case LDAC_FRAME_LEN_INDEX_160: + frame_num = 4; + break; + case LDAC_FRAME_LEN_INDEX_216: + frame_num = 3; + break; + case LDAC_FRAME_LEN_INDEX_326: + frame_num = 2; + break; + default: + ASSERT(0, "Unknown ldac frame format: %d !!!!!", frame_length_index); + break; + } + return frame_num; } #endif - #define DELAY_MTU_LIMIT 8 static volatile int delay_mtu_limit = DELAY_MTU_LIMIT; @@ -403,10 +408,7 @@ static volatile int delay_mtu_count = 0; bool app_bt_stream_trigger_onprocess(void); void app_bt_stream_trigger_start(uint8_t offset); -void a2dp_audio_set_mtu_limit(uint8_t mut) -{ - delay_mtu_limit = mut; -} +void a2dp_audio_set_mtu_limit(uint8_t mut) { delay_mtu_limit = mut; } static uint32_t old_t = 0; static uint32_t ssb_err = 0; @@ -416,572 +418,577 @@ static uint32_t lagest_mtu_in1s = 0; static uint32_t least_mtu_in1s = 0xffffffff; static uint32_t check_interval = 50; -int store_sbc_buffer(unsigned char *buf, unsigned int len) -{ - int POSSIBLY_UNUSED size; - int cnt = 0; - int nRet = 0; +int store_sbc_buffer(unsigned char *buf, unsigned int len) { + int POSSIBLY_UNUSED size; + int cnt = 0; + int nRet = 0; #if defined(A2DP_LHDC_ON) - uint32_t newLen = 0; - bool mtu_plus = false; + uint32_t newLen = 0; + bool mtu_plus = false; #endif #if defined(A2DP_LDAC_ON) - uint16_t frame_length_index = 0; + uint16_t frame_length_index = 0; #endif - uint32_t now_t = TICKS_TO_MS(hal_sys_timer_get()); - ssb_err = now_t - old_t; - old_t = now_t; + uint32_t now_t = TICKS_TO_MS(hal_sys_timer_get()); + ssb_err = now_t - old_t; + old_t = now_t; - if(ssb_err < 500){ - if(ssb_err_max < ssb_err) - ssb_err_max = ssb_err; - if(ssb_err_min > ssb_err) - ssb_err_min = ssb_err; - } + if (ssb_err < 500) { + if (ssb_err_max < ssb_err) + ssb_err_max = ssb_err; + if (ssb_err_min > ssb_err) + ssb_err_min = ssb_err; + } - if (!a2dp_audio_isrunning(A2DPPLAY_STRTEAM_PUT, true)){ - TRACE(3,"%s not ready:%d cache_status:%d",__func__, len, a2dp_cache_status); - } - uint8_t overlay_id = app_get_current_overlay(); + if (!a2dp_audio_isrunning(A2DPPLAY_STRTEAM_PUT, true)) { + TRACE(3, "%s not ready:%d cache_status:%d", __func__, len, + a2dp_cache_status); + } + uint8_t overlay_id = app_get_current_overlay(); - if(overlay_id == APP_OVERLAY_A2DP) - { - //TRACE(8,"sbc %d %x %x %x %x mtu_count:%d sbcqueue:%d,sbc_frame_rev_len=%d", len, buf[0], - // buf[1],buf[2],buf[3],mtu_count,APP_AUDIO_LengthOfCQueue(&sbc_queue),sbc_frame_rev_len); - } + if (overlay_id == APP_OVERLAY_A2DP) { + // TRACE(8,"sbc %d %x %x %x %x mtu_count:%d + // sbcqueue:%d,sbc_frame_rev_len=%d", len, buf[0], + // buf[1],buf[2],buf[3],mtu_count,APP_AUDIO_LengthOfCQueue(&sbc_queue),sbc_frame_rev_len); + } #if defined(A2DP_LDAC_ON) - else if(overlay_id == APP_OVERLAY_A2DP_LDAC) - { - uint16_t data1 = (uint16_t)(buf[1]&0x07); - uint16_t data2 = (uint16_t)buf[2]; - frame_length_index = ((data1<< 6 &0xFFFF) | (data2 >> 2 & 0xFFFF)); - sbc_frame_num = get_ldac_frame_num(frame_length_index); - //TRACE(10,"ldac %d %d %x %x %x %x mtu_count:%d sbcqueue:%d,sbc_frame_rev_len=%d,sbc_frame_num %d", len, sbc_frame_size,buf[0], - // buf[1],buf[2],buf[3],mtu_count,APP_AUDIO_LengthOfCQueue(&sbc_queue),sbc_frame_rev_len,sbc_frame_num); + else if (overlay_id == APP_OVERLAY_A2DP_LDAC) { + uint16_t data1 = (uint16_t)(buf[1] & 0x07); + uint16_t data2 = (uint16_t)buf[2]; + frame_length_index = ((data1 << 6 & 0xFFFF) | (data2 >> 2 & 0xFFFF)); + sbc_frame_num = get_ldac_frame_num(frame_length_index); + // TRACE(10,"ldac %d %d %x %x %x %x mtu_count:%d + // sbcqueue:%d,sbc_frame_rev_len=%d,sbc_frame_num %d", len, + // sbc_frame_size,buf[0], + // buf[1],buf[2],buf[3],mtu_count,APP_AUDIO_LengthOfCQueue(&sbc_queue),sbc_frame_rev_len,sbc_frame_num); + } +#endif + else { + // TRACE(8,"AAC %d %x %x %x %x mtu_count:%d + // sbcqueue:%d,sbc_frame_rev_len=%d", len, buf[0], + // buf[1],buf[2],buf[3],mtu_count,APP_AUDIO_LengthOfCQueue(&sbc_queue),sbc_frame_rev_len); + } + + switch (a2dp_cache_status) { + case APP_AUDIO_CACHE_CACHEING: { +#if defined(A2DP_LHDC_ON) + newLen = 0; + if (overlay_id == APP_OVERLAY_A2DP_LHDC) { + uint32_t lSize = 0, rSize = 0; + uint8_t *lPTR = NULL, *rPTR = NULL; + // TRACE(2,"%s:APP_AUDIO_CACHE_CACHEING Enter len = %d",__func__, len); + // TRACE(2,"%s: input len(%d)",__func__, len); + if (assemble_lhdc_packet(buf, len, &lPTR, &lSize, &rPTR, &rSize) > 0) { + if (lPTR != NULL && lSize != 0) { + newLen = lSize + sizeof(LHDC_HEADER); + memcpy(lhdcTempBuf + sizeof(LHDC_HEADER), lPTR, lSize); + memcpy(lhdcTempBuf, magicTag, sizeof(magicTag)); + memcpy(lhdcTempBuf + sizeof(magicTag), &lSize, sizeof(unsigned int)); + mtu_plus = true; + } + } else { + nRet = 0; + } } #endif - else - { - //TRACE(8,"AAC %d %x %x %x %x mtu_count:%d sbcqueue:%d,sbc_frame_rev_len=%d", len, buf[0], - // buf[1],buf[2],buf[3],mtu_count,APP_AUDIO_LengthOfCQueue(&sbc_queue),sbc_frame_rev_len); - } - switch (a2dp_cache_status) { - case APP_AUDIO_CACHE_CACHEING: - { + LOCK_APP_AUDIO_QUEUE(); #if defined(A2DP_LHDC_ON) - newLen = 0; - if(overlay_id == APP_OVERLAY_A2DP_LHDC){ - uint32_t lSize = 0, rSize = 0; - uint8_t *lPTR = NULL, *rPTR = NULL; - //TRACE(2,"%s:APP_AUDIO_CACHE_CACHEING Enter len = %d",__func__, len); - //TRACE(2,"%s: input len(%d)",__func__, len); - if (assemble_lhdc_packet(buf, len, &lPTR, &lSize, &rPTR, &rSize) > 0){ - if (lPTR != NULL && lSize != 0){ - newLen = lSize + sizeof(LHDC_HEADER); - memcpy(lhdcTempBuf + sizeof(LHDC_HEADER), lPTR, lSize); - memcpy(lhdcTempBuf, magicTag, sizeof(magicTag)); - memcpy(lhdcTempBuf + sizeof(magicTag), &lSize, sizeof(unsigned int)); - mtu_plus = true; - } - }else { - nRet = 0; - } - - } -#endif - - LOCK_APP_AUDIO_QUEUE(); -#if defined(A2DP_LHDC_ON) - if(overlay_id == APP_OVERLAY_A2DP_LHDC){ - nRet = APP_AUDIO_EnCQueue(&sbc_queue, lhdcTempBuf, newLen); - size = APP_AUDIO_LengthOfCQueue(&sbc_queue); - }else + if (overlay_id == APP_OVERLAY_A2DP_LHDC) { + nRet = APP_AUDIO_EnCQueue(&sbc_queue, lhdcTempBuf, newLen); + size = APP_AUDIO_LengthOfCQueue(&sbc_queue); + } else #endif #if defined(A2DP_LDAC_ON) - if(overlay_id == APP_OVERLAY_A2DP_LDAC){ - //if(bt_sbc_player_get_codec_type() == BTIF_AVDTP_CODEC_TYPE_NON_A2DP){ - nRet = APP_AUDIO_EnCQueue(&sbc_queue, buf, len); - size = APP_AUDIO_LengthOfCQueue(&sbc_queue); - }else + if (overlay_id == APP_OVERLAY_A2DP_LDAC) { + // if(bt_sbc_player_get_codec_type() == BTIF_AVDTP_CODEC_TYPE_NON_A2DP){ + nRet = APP_AUDIO_EnCQueue(&sbc_queue, buf, len); + size = APP_AUDIO_LengthOfCQueue(&sbc_queue); + } else #endif #if defined(A2DP_AAC_ON) - if(overlay_id == APP_OVERLAY_A2DP_AAC){ - nRet = AvailableOfCQueue(&sbc_queue); - if (nRet >= (int)(len + 2)) - { - nRet = APP_AUDIO_EnCQueue(&sbc_queue, (uint8_t *)&len, 2); - nRet = APP_AUDIO_EnCQueue(&sbc_queue, buf, len); - } - else - nRet = CQ_ERR; - }else + if (overlay_id == APP_OVERLAY_A2DP_AAC) { + nRet = AvailableOfCQueue(&sbc_queue); + if (nRet >= (int)(len + 2)) { + nRet = APP_AUDIO_EnCQueue(&sbc_queue, (uint8_t *)&len, 2); + nRet = APP_AUDIO_EnCQueue(&sbc_queue, buf, len); + } else + nRet = CQ_ERR; + } else #endif - { - nRet = APP_AUDIO_EnCQueue(&sbc_queue, buf, len); - } - size = APP_AUDIO_LengthOfCQueue(&sbc_queue); + { + nRet = APP_AUDIO_EnCQueue(&sbc_queue, buf, len); + } + size = APP_AUDIO_LengthOfCQueue(&sbc_queue); #if defined(A2DP_LHDC_ON) - if(overlay_id == APP_OVERLAY_A2DP_LHDC){ - if (mtu_plus) { - if (delay_mtu_count == 0) - mtu_count = 0; - delay_mtu_count++; - mtu_count++; - mtu_plus = false; - } - }else{ + if (overlay_id == APP_OVERLAY_A2DP_LHDC) { + if (mtu_plus) { + if (delay_mtu_count == 0) + mtu_count = 0; + delay_mtu_count++; + mtu_count++; + mtu_plus = false; + } + } else { #endif - if(overlay_id == APP_OVERLAY_A2DP + if (overlay_id == APP_OVERLAY_A2DP #if defined(A2DP_LDAC_ON) - || overlay_id == APP_OVERLAY_A2DP_LDAC + || overlay_id == APP_OVERLAY_A2DP_LDAC #endif - ){ - if (delay_mtu_count == 0) - mtu_count = 0; - delay_mtu_count += sbc_frame_num; - mtu_count += sbc_frame_num; -// TRACE(1,"+mtu_count = %d",mtu_count); - }else{ - if (delay_mtu_count == 0) - mtu_count = 0; - delay_mtu_count++; - mtu_count++; - } + ) { + if (delay_mtu_count == 0) + mtu_count = 0; + delay_mtu_count += sbc_frame_num; + mtu_count += sbc_frame_num; + // TRACE(1,"+mtu_count = + //%d",mtu_count); + } else { + if (delay_mtu_count == 0) + mtu_count = 0; + delay_mtu_count++; + mtu_count++; + } #if defined(A2DP_LHDC_ON) - } + } #endif - UNLOCK_APP_AUDIO_QUEUE(); - bool flag = 0; + UNLOCK_APP_AUDIO_QUEUE(); + bool flag = 0; #if defined(A2DP_AAC_ON) - if(overlay_id == APP_OVERLAY_A2DP_AAC) - flag = 1; + if (overlay_id == APP_OVERLAY_A2DP_AAC) + flag = 1; #endif #if defined(A2DP_SCALABLE_ON) - if(overlay_id == APP_OVERLAY_A2DP_SCALABLE) - flag = 1; + if (overlay_id == APP_OVERLAY_A2DP_SCALABLE) + flag = 1; #endif #if defined(A2DP_LHDC_ON) - if(overlay_id == APP_OVERLAY_A2DP_LHDC) - flag = 1; + if (overlay_id == APP_OVERLAY_A2DP_LHDC) + flag = 1; #endif #if defined(A2DP_LDAC_ON) - if(overlay_id == APP_OVERLAY_A2DP_LDAC) - { - flag = 1; - TRACE(0,"y# ldac cache"); - } + if (overlay_id == APP_OVERLAY_A2DP_LDAC) { + flag = 1; + TRACE(0, "y# ldac cache"); + } #endif - if(flag) - { + if (flag) { #ifdef __A2DP_PLAYER_USE_BT_TRIGGER__ - if(app_bt_stream_trigger_onprocess()&&mtu_count){ - TRACE(0,"cache ok use dma trigger\n"); - a2dp_cache_status = APP_AUDIO_CACHE_OK; - app_bt_stream_trigger_start(0); - } + if (app_bt_stream_trigger_onprocess() && mtu_count) { + TRACE(0, "cache ok use dma trigger\n"); + a2dp_cache_status = APP_AUDIO_CACHE_OK; + app_bt_stream_trigger_start(0); + } #else - if (delay_mtu_count >= delay_mtu_limit){ - TRACE(2,"aac cache ok:%d,mtu_count=%d\n", size,mtu_count); - a2dp_cache_status = APP_AUDIO_CACHE_OK; - } + if (delay_mtu_count >= delay_mtu_limit) { + TRACE(2, "aac cache ok:%d,mtu_count=%d\n", size, mtu_count); + a2dp_cache_status = APP_AUDIO_CACHE_OK; + } #endif - }else{ + } else { #ifdef __A2DP_PLAYER_USE_BT_TRIGGER__ - if(app_bt_stream_trigger_onprocess()&&mtu_count){ - TRACE(0,"cache ok use dma trigger\n"); - a2dp_cache_status = APP_AUDIO_CACHE_OK; - app_bt_stream_trigger_start(0); - } + if (app_bt_stream_trigger_onprocess() && mtu_count) { + TRACE(0, "cache ok use dma trigger\n"); + a2dp_cache_status = APP_AUDIO_CACHE_OK; + app_bt_stream_trigger_start(0); + } #else - if (delay_mtu_count >= delay_mtu_limit){ - TRACE(4,"cache ok:%d,%d,%d,mtu_count=%d\n", size,len,sbc_frame_size,mtu_count); - a2dp_cache_status = APP_AUDIO_CACHE_OK; - }else if (sbc_frame_size && (size>=A2DPPLAY_CACHE_OK_THRESHOLD)){ - TRACE(2,"cache ok:%d,mtu_count=%d\n", size,mtu_count); - a2dp_cache_status = APP_AUDIO_CACHE_OK; - }else{ - TRACE(1,"cache add:%d\n", len); - } + if (delay_mtu_count >= delay_mtu_limit) { + TRACE(4, "cache ok:%d,%d,%d,mtu_count=%d\n", size, len, sbc_frame_size, + mtu_count); + a2dp_cache_status = APP_AUDIO_CACHE_OK; + } else if (sbc_frame_size && (size >= A2DPPLAY_CACHE_OK_THRESHOLD)) { + TRACE(2, "cache ok:%d,mtu_count=%d\n", size, mtu_count); + a2dp_cache_status = APP_AUDIO_CACHE_OK; + } else { + TRACE(1, "cache add:%d\n", len); + } #endif - } + } - if(nRet == CQ_ERR){ - TRACE(0,"cache add overflow\n"); - a2dp_cache_status = APP_AUDIO_CACHE_OK; - } - if (a2dp_cache_status == APP_AUDIO_CACHE_OK){ - old_t = 0; - ssb_err = 0; - ssb_err_max = 0; - ssb_err_min = 0xffffffff; - lagest_mtu_in1s = 0; - least_mtu_in1s = 0xffffffff; - check_interval = 50; + if (nRet == CQ_ERR) { + TRACE(0, "cache add overflow\n"); + a2dp_cache_status = APP_AUDIO_CACHE_OK; + } + if (a2dp_cache_status == APP_AUDIO_CACHE_OK) { + old_t = 0; + ssb_err = 0; + ssb_err_max = 0; + ssb_err_min = 0xffffffff; + lagest_mtu_in1s = 0; + least_mtu_in1s = 0xffffffff; + check_interval = 50; #ifdef __LOCK_AUDIO_THREAD__ - af_unlock_thread(); + af_unlock_thread(); #endif - A2DP_SYNC_WITH_GET_MUTUX_ALLOC(); - A2DP_SYNC_WITH_GET_MUTUX_WAIT(); + A2DP_SYNC_WITH_GET_MUTUX_ALLOC(); + A2DP_SYNC_WITH_GET_MUTUX_WAIT(); #ifdef __LOCK_AUDIO_THREAD__ - af_lock_thread(); + af_lock_thread(); #endif - } - break; + } + break; + } + case APP_AUDIO_CACHE_OK: { + delay_mtu_count = 0; +#if defined(A2DP_LHDC_ON) + newLen = 0; + if (overlay_id == APP_OVERLAY_A2DP_LHDC) { + uint32_t lSize = 0, rSize = 0; + uint8_t *lPTR = NULL, *rPTR = NULL; + // TRACE(2,"%s: input len(%d)",__func__, len); + if (assemble_lhdc_packet(buf, len, &lPTR, &lSize, &rPTR, &rSize) > 0) { + if (lPTR != NULL && lSize != 0) { + newLen = lSize + sizeof(LHDC_HEADER); + memcpy(lhdcTempBuf + sizeof(LHDC_HEADER), lPTR, lSize); + memcpy(lhdcTempBuf, magicTag, sizeof(magicTag)); + memcpy(lhdcTempBuf + sizeof(magicTag), &lSize, sizeof(unsigned int)); + mtu_plus = true; } - case APP_AUDIO_CACHE_OK: - { - delay_mtu_count = 0; -#if defined(A2DP_LHDC_ON) - newLen = 0; - if(overlay_id == APP_OVERLAY_A2DP_LHDC){ - uint32_t lSize = 0, rSize = 0; - uint8_t *lPTR = NULL, *rPTR = NULL; - //TRACE(2,"%s: input len(%d)",__func__, len); - if (assemble_lhdc_packet(buf, len, &lPTR, &lSize, &rPTR, &rSize) > 0){ - if (lPTR != NULL && lSize != 0){ - newLen = lSize + sizeof(LHDC_HEADER); - memcpy(lhdcTempBuf + sizeof(LHDC_HEADER), lPTR, lSize); - memcpy(lhdcTempBuf, magicTag, sizeof(magicTag)); - memcpy(lhdcTempBuf + sizeof(magicTag), &lSize, sizeof(unsigned int)); - mtu_plus = true; - } - } - - } + } + } #endif - do{ - LOCK_APP_AUDIO_QUEUE(); + do { + LOCK_APP_AUDIO_QUEUE(); #if defined(A2DP_LHDC_ON) - if(overlay_id == APP_OVERLAY_A2DP_LHDC){ - nRet = APP_AUDIO_EnCQueue(&sbc_queue, lhdcTempBuf, newLen); - }else + if (overlay_id == APP_OVERLAY_A2DP_LHDC) { + nRet = APP_AUDIO_EnCQueue(&sbc_queue, lhdcTempBuf, newLen); + } else #endif #if defined(A2DP_AAC_ON) - if(overlay_id == APP_OVERLAY_A2DP_AAC){ - nRet = AvailableOfCQueue(&sbc_queue); - if (nRet >= (int)(len + 2)) - { - nRet = APP_AUDIO_EnCQueue(&sbc_queue, (uint8_t *)&len, 2); - nRet = APP_AUDIO_EnCQueue(&sbc_queue, buf, len); - } - else - nRet = CQ_ERR; - }else + if (overlay_id == APP_OVERLAY_A2DP_AAC) { + nRet = AvailableOfCQueue(&sbc_queue); + if (nRet >= (int)(len + 2)) { + nRet = APP_AUDIO_EnCQueue(&sbc_queue, (uint8_t *)&len, 2); + nRet = APP_AUDIO_EnCQueue(&sbc_queue, buf, len); + } else + nRet = CQ_ERR; + } else #endif - { - nRet = APP_AUDIO_EnCQueue(&sbc_queue, buf, len); - } - if (CQ_OK == nRet){ + { + nRet = APP_AUDIO_EnCQueue(&sbc_queue, buf, len); + } + if (CQ_OK == nRet) { #if defined(A2DP_LHDC_ON) - if(overlay_id == APP_OVERLAY_A2DP_LHDC){ - if (mtu_plus) { - mtu_count++; - mtu_plus = false; - } - } else { + if (overlay_id == APP_OVERLAY_A2DP_LHDC) { + if (mtu_plus) { + mtu_count++; + mtu_plus = false; + } + } else { #endif - if(overlay_id == APP_OVERLAY_A2DP + if (overlay_id == APP_OVERLAY_A2DP #if defined(A2DP_LDAC_ON) - || overlay_id == APP_OVERLAY_A2DP_LDAC + || overlay_id == APP_OVERLAY_A2DP_LDAC #endif - ){ - mtu_count += sbc_frame_num; -// TRACE(1,"+mtu_count = %d",mtu_count); - }else{ - mtu_count++; - } + ) { + mtu_count += sbc_frame_num; + // TRACE(1,"+mtu_count + //= %d",mtu_count); + } else { + mtu_count++; + } #if defined(A2DP_LHDC_ON) - } -#endif - } -// size = APP_AUDIO_LengthOfCQueue(&sbc_queue); - UNLOCK_APP_AUDIO_QUEUE(); -// TRACE(3,"cache add:%d %d/%d \n", len, size, g_sbc_queue_size); - if (CQ_OK == nRet){ - nRet = 0; - break; - }else{ - TRACE(1,"cache flow control:%d\n", cnt); -#ifdef A2DP_AUDIO_SYNC_WITH_LOCAL - a2dp_audio_sync_proc(A2DPPLAY_SYNC_STATUS_SET, 0); -#endif - nRet = -1; -#ifdef __LOCK_AUDIO_THREAD__ - af_unlock_thread(); -#endif - A2DP_SYNC_WITH_GET_MUTUX_ALLOC(); - A2DP_SYNC_WITH_GET_MUTUX_WAIT(); -#ifdef __LOCK_AUDIO_THREAD__ - af_lock_thread(); -#endif - } - }while(cnt++= A2DP_SYNC_WITH_PUT_MUTUX_TIMEROUT_CNT){ - TRACE(0,"ldac No Data return"); - result = 1; - break; - } - continue; - } - - if (ldac_recovery) { - uint32_t parse_bytes; - - result = ldac_seek_header(len, &parse_bytes); - if (result == 0) { - ldac_recovery = false; - } - LOCK_APP_AUDIO_QUEUE(); - DeCQueue(&sbc_queue, 0, parse_bytes); - UNLOCK_APP_AUDIO_QUEUE(); - continue; - } + if (hLdacData == NULL) { + return 1; + } + while (true) { + len = get_ldac_data(ldac_input_mid_buf, LDAC_READBUF_SIZE); + if (len == 0) { + if (retry++ >= A2DP_SYNC_WITH_PUT_MUTUX_TIMEROUT_CNT) { + TRACE(0, "ldac No Data return"); + result = 1; break; + } + continue; } - if(skip_ldac_frame > 0){ - skip_ldac_frame--; + if (ldac_recovery) { + uint32_t parse_bytes; + + result = ldac_seek_header(len, &parse_bytes); + if (result == 0) { + ldac_recovery = false; + } + LOCK_APP_AUDIO_QUEUE(); + DeCQueue(&sbc_queue, 0, parse_bytes); + UNLOCK_APP_AUDIO_QUEUE(); + continue; } + + break; + } + + if (skip_ldac_frame > 0) { + skip_ldac_frame--; + } #endif - return result; + return result; } TEXT_LDAC_LOC -int decode_ldac_frame(uint8_t *out, uint32_t out_max, uint32_t *p_out_len, const uint8_t *in, uint32_t in_len, uint32_t *p_consume_len) -{ - int result; - int n_read_bytes, used_bytes, wrote_bytes; +int decode_ldac_frame(uint8_t *out, uint32_t out_max, uint32_t *p_out_len, + const uint8_t *in, uint32_t in_len, + uint32_t *p_consume_len) { + int result; + int n_read_bytes, used_bytes, wrote_bytes; - n_read_bytes = LDAC_READBUF_SIZE; + n_read_bytes = LDAC_READBUF_SIZE; - result = ldacBT_decode(hLdacData, ldac_input_mid_buf, out, LDACBT_SMPL_FMT_S16, n_read_bytes, &used_bytes, &wrote_bytes); + result = + ldacBT_decode(hLdacData, ldac_input_mid_buf, out, LDACBT_SMPL_FMT_S16, + n_read_bytes, &used_bytes, &wrote_bytes); - if (p_out_len) { - *p_out_len = wrote_bytes; - } - if (p_consume_len) { - *p_consume_len = used_bytes; - } + if (p_out_len) { + *p_out_len = wrote_bytes; + } + if (p_consume_len) { + *p_consume_len = used_bytes; + } - return result; + return result; } TEXT_LDAC_LOC -int consume_ldac_frame(const uint8_t *data, uint32_t len) -{ - LOCK_APP_AUDIO_QUEUE(); - DeCQueue(&sbc_queue, 0, len); - mtu_count--; - UNLOCK_APP_AUDIO_QUEUE(); +int consume_ldac_frame(const uint8_t *data, uint32_t len) { + LOCK_APP_AUDIO_QUEUE(); + DeCQueue(&sbc_queue, 0, len); + mtu_count--; + UNLOCK_APP_AUDIO_QUEUE(); - return 0; + return 0; } TEXT_LDAC_LOC -void decode_ldac_end(uint32_t expect_out_len, uint32_t out_len, uint32_t in_len) -{ - if (expect_out_len != out_len) { - if (hLdacData) { - int error_code; - error_code = ldacBT_get_error_code(hLdacData); - TRACE(6,"error_code = %4d, %4d, %4d,FrameHeader[%02x:%02x:%02x]\n", LDACBT_API_ERR(error_code), LDACBT_HANDLE_ERR(error_code),\ - LDACBT_BLOCK_ERR(error_code), ldac_input_mid_buf[0], ldac_input_mid_buf[1], ldac_input_mid_buf[2]); - if( LDACBT_FATAL(error_code) ){ - ldac_dec_deinit(); - } - } - if (hLdacData == NULL) { - /* Recovery Process */ - int result; - result = ldac_dec_init(); - if (result) { - ldac_dec_deinit(); - } - ldac_recovery = true; - } +void decode_ldac_end(uint32_t expect_out_len, uint32_t out_len, + uint32_t in_len) { + if (expect_out_len != out_len) { + if (hLdacData) { + int error_code; + error_code = ldacBT_get_error_code(hLdacData); + TRACE(6, "error_code = %4d, %4d, %4d,FrameHeader[%02x:%02x:%02x]\n", + LDACBT_API_ERR(error_code), LDACBT_HANDLE_ERR(error_code), + LDACBT_BLOCK_ERR(error_code), ldac_input_mid_buf[0], + ldac_input_mid_buf[1], ldac_input_mid_buf[2]); + if (LDACBT_FATAL(error_code)) { + ldac_dec_deinit(); + } } + if (hLdacData == NULL) { + /* Recovery Process */ + int result; + result = ldac_dec_init(); + if (result) { + ldac_dec_deinit(); + } + ldac_recovery = true; + } + } } #endif @@ -989,7 +996,7 @@ void decode_ldac_end(uint32_t expect_out_len, uint32_t out_len, uint32_t in_len) #include "aacdecoder_lib.h" #include "aacenc_lib.h" #include "heap_api.h" -#define DECODE_AAC_PCM_FRAME_LENGTH (1024*4) +#define DECODE_AAC_PCM_FRAME_LENGTH (1024 * 4) HANDLE_AACDECODER aacDec_handle = NULL; #define AAC_MEMPOLL_SIZE (40596) @@ -1000,167 +1007,166 @@ static unsigned char aac_input_mid_buf[AAC_READBUF_SIZE]; STATIC_ASSERT(sizeof(aac_input_mid_buf) >= 2048, "aac_input_mid_buf too small"); static uint32_t byte_in_buffer = 0; -int aac_meminit() -{ - int ret = 1; - if (aac_mempoll == NULL) - ret = app_audio_mempool_get_buff((uint8_t **)&aac_mempoll, AAC_MEMPOLL_SIZE); - if (ret > 0 && aac_memhandle == NULL) - { - aac_memhandle = heap_register(aac_mempoll,AAC_MEMPOLL_SIZE); - } - return ret; +int aac_meminit() { + int ret = 1; + if (aac_mempoll == NULL) + ret = + app_audio_mempool_get_buff((uint8_t **)&aac_mempoll, AAC_MEMPOLL_SIZE); + if (ret > 0 && aac_memhandle == NULL) { + aac_memhandle = heap_register(aac_mempoll, AAC_MEMPOLL_SIZE); + } + return ret; } -void aac_memdeinit() -{ - extern int total_calloc; - aac_mempoll = 0; - aac_memhandle = 0; - total_calloc = 0; - byte_in_buffer = 0; +void aac_memdeinit() { + extern int total_calloc; + aac_mempoll = 0; + aac_memhandle = 0; + total_calloc = 0; + byte_in_buffer = 0; } volatile int aac_slave_codec_patch_bytes = 0; -int aacdec_init(void) -{ - if (aacDec_handle == NULL) { - TRANSPORT_TYPE transportFmt = TT_MP4_LATM_MCP1; - aacDec_handle = aacDecoder_Open(transportFmt, 1 /* nrOfLayers */); +int aacdec_init(void) { + if (aacDec_handle == NULL) { + TRANSPORT_TYPE transportFmt = TT_MP4_LATM_MCP1; + aacDec_handle = aacDecoder_Open(transportFmt, 1 /* nrOfLayers */); - if (!aacDec_handle) - { - TRACE(1,"%s Error initializing AAC decoder", __func__); - return 1; - } - aacDecoder_SetParam(aacDec_handle,AAC_PCM_LIMITER_ENABLE,0); - aacDecoder_SetParam(aacDec_handle, AAC_DRC_ATTENUATION_FACTOR, 0); - aacDecoder_SetParam(aacDec_handle, AAC_DRC_BOOST_FACTOR, 0); + if (!aacDec_handle) { + TRACE(1, "%s Error initializing AAC decoder", __func__); + return 1; } - return 0; + aacDecoder_SetParam(aacDec_handle, AAC_PCM_LIMITER_ENABLE, 0); + aacDecoder_SetParam(aacDec_handle, AAC_DRC_ATTENUATION_FACTOR, 0); + aacDecoder_SetParam(aacDec_handle, AAC_DRC_BOOST_FACTOR, 0); + } + return 0; } -int aacdec_deinit(void) -{ - if (aacDec_handle != NULL) { - aacDecoder_Close(aacDec_handle); - aacDec_handle = NULL; - size_t total = 0, used = 0, max_used = 0; - heap_memory_info(aac_memhandle,&total, &used, &max_used); - TRACE(3,"AAC MALLOC MEM: total - %d, used - %d, max_used - %d.", - total, used, max_used); - } - return 0; +int aacdec_deinit(void) { + if (aacDec_handle != NULL) { + aacDecoder_Close(aacDec_handle); + aacDec_handle = NULL; + size_t total = 0, used = 0, max_used = 0; + heap_memory_info(aac_memhandle, &total, &used, &max_used); + TRACE(3, "AAC MALLOC MEM: total - %d, used - %d, max_used - %d.", total, + used, max_used); + } + return 0; } TEXT_AAC_LOC -static int pcm_buffer_read_no_protction(CQueue *queue, uint8_t *buff, uint16_t len) -{ - uint8_t *e1 = NULL, *e2 = NULL; - unsigned int len1 = 0, len2 = 0; - int status; - status = PeekCQueue(queue, len, &e1, &len1, &e2, &len2); - //TRACE(5,"pcm_buffer_read_no_protction len=%d,len1=%d,len2=%d,e1=0x%x,e2=0x%x",len,len1,len2,e1,e2); - if (len==(len1+len2)){ - memcpy(buff,e1,len1); - memcpy(buff+len1,e2,len2); - DeCQueue(queue, 0, len); - }else{ - memset(buff, 0x00, len); - status = -1; - } - return status; +static int pcm_buffer_read_no_protction(CQueue *queue, uint8_t *buff, + uint16_t len) { + uint8_t *e1 = NULL, *e2 = NULL; + unsigned int len1 = 0, len2 = 0; + int status; + status = PeekCQueue(queue, len, &e1, &len1, &e2, &len2); + // TRACE(5,"pcm_buffer_read_no_protction + // len=%d,len1=%d,len2=%d,e1=0x%x,e2=0x%x",len,len1,len2,e1,e2); + if (len == (len1 + len2)) { + memcpy(buff, e1, len1); + memcpy(buff + len1, e2, len2); + DeCQueue(queue, 0, len); + } else { + memset(buff, 0x00, len); + status = -1; + } + return status; } TEXT_AAC_LOC -int load_aac_frame(uint8_t **p_data, uint32_t *p_len) -{ - //uint32_t lock; - unsigned short aac_len =0 ; - int status; +int load_aac_frame(uint8_t **p_data, uint32_t *p_len) { + // uint32_t lock; + unsigned short aac_len = 0; + int status; - LOCK_APP_AUDIO_QUEUE(); - status = pcm_buffer_read_no_protction(&sbc_queue, (uint8_t *)&aac_len, 2); - if(status != CQ_OK){ - UNLOCK_APP_AUDIO_QUEUE(); - //a2dp_cache_status = APP_AUDIO_CACHE_CACHEING; - return 1; - } - - if (aac_len < 64) { - aac_maxreadBytes = 64; - } else if (aac_len < 128) { - aac_maxreadBytes = 128; - } else if (aac_len < 256) { - aac_maxreadBytes = 256; - } else if (aac_len < 512) { - aac_maxreadBytes = 512; - } else if (aac_len < 1024) { - aac_maxreadBytes = 1024; - } else { - if (aac_len >= 2048) { - // Header is bad! - dec_reset_queue = true; - return 2; - } - aac_maxreadBytes = 2048; - } - - status = pcm_buffer_read_no_protction(&sbc_queue,aac_input_mid_buf, aac_len); - if(status != CQ_OK){ - UNLOCK_APP_AUDIO_QUEUE(); - //a2dp_cache_status = APP_AUDIO_CACHE_CACHEING; - return 1; - } - mtu_count--; + LOCK_APP_AUDIO_QUEUE(); + status = pcm_buffer_read_no_protction(&sbc_queue, (uint8_t *)&aac_len, 2); + if (status != CQ_OK) { UNLOCK_APP_AUDIO_QUEUE(); + // a2dp_cache_status = APP_AUDIO_CACHE_CACHEING; + return 1; + } - //uint32_t a2dp_queue_bytes = LengthOfCQueue(&sbc_queue); - //TRACE(3,"d aac_len=%d, a2dp_bytes=%d, aac_maxreadBytes=%d\n", aac_len, a2dp_queue_bytes, aac_maxreadBytes); - - if (p_data) { - *p_data = (unsigned char *)aac_input_mid_buf; - } - if (p_len) { - *p_len = aac_maxreadBytes; + if (aac_len < 64) { + aac_maxreadBytes = 64; + } else if (aac_len < 128) { + aac_maxreadBytes = 128; + } else if (aac_len < 256) { + aac_maxreadBytes = 256; + } else if (aac_len < 512) { + aac_maxreadBytes = 512; + } else if (aac_len < 1024) { + aac_maxreadBytes = 1024; + } else { + if (aac_len >= 2048) { + // Header is bad! + dec_reset_queue = true; + return 2; } + aac_maxreadBytes = 2048; + } - return 0; + status = pcm_buffer_read_no_protction(&sbc_queue, aac_input_mid_buf, aac_len); + if (status != CQ_OK) { + UNLOCK_APP_AUDIO_QUEUE(); + // a2dp_cache_status = APP_AUDIO_CACHE_CACHEING; + return 1; + } + mtu_count--; + UNLOCK_APP_AUDIO_QUEUE(); + + // uint32_t a2dp_queue_bytes = LengthOfCQueue(&sbc_queue); + // TRACE(3,"d aac_len=%d, a2dp_bytes=%d, aac_maxreadBytes=%d\n", aac_len, + // a2dp_queue_bytes, aac_maxreadBytes); + + if (p_data) { + *p_data = (unsigned char *)aac_input_mid_buf; + } + if (p_len) { + *p_len = aac_maxreadBytes; + } + + return 0; } TEXT_AAC_LOC -int decode_aac_frame(uint8_t *out, uint32_t out_max, uint32_t *p_out_len, const uint8_t *in, uint32_t in_len, uint32_t *p_consume_len) -{ - unsigned int bufferSize = in_len; - unsigned int bytesValid = in_len; - AAC_DECODER_ERROR err = AAC_DEC_OK; - CStreamInfo* info=NULL; +int decode_aac_frame(uint8_t *out, uint32_t out_max, uint32_t *p_out_len, + const uint8_t *in, uint32_t in_len, + uint32_t *p_consume_len) { + unsigned int bufferSize = in_len; + unsigned int bytesValid = in_len; + AAC_DECODER_ERROR err = AAC_DEC_OK; + CStreamInfo *info = NULL; - //at leat should large than AAC_MAX_NSAMPS*2 (one channel) - if(out_max < 2048){ - TRACE(2,"%s daac pcm_len = %d \n", __func__, out_max); - return 1; - } + // at leat should large than AAC_MAX_NSAMPS*2 (one channel) + if (out_max < 2048) { + TRACE(2, "%s daac pcm_len = %d \n", __func__, out_max); + return 1; + } - if(a2dp_channel_num[app_bt_device.curr_a2dp_stream_id] == 1){ - out_max >>= 1; - } + if (a2dp_channel_num[app_bt_device.curr_a2dp_stream_id] == 1) { + out_max >>= 1; + } - //int tt = hal_sys_timer_get(); - err = aacDecoder_Fill(aacDec_handle, (uint8_t **)&in, &bufferSize, &bytesValid); - if (err != AAC_DEC_OK) { - TRACE(1,"aacDecoder_Fill failed:0x%x", err); - //if aac failed reopen it again - if(is_aacDecoder_Close(aacDec_handle)){ - aacDec_handle = NULL; - aacdec_init(); - TRACE(1,"%s reopen aac codec \n", __func__); - } - return 2; + // int tt = hal_sys_timer_get(); + err = + aacDecoder_Fill(aacDec_handle, (uint8_t **)&in, &bufferSize, &bytesValid); + if (err != AAC_DEC_OK) { + TRACE(1, "aacDecoder_Fill failed:0x%x", err); + // if aac failed reopen it again + if (is_aacDecoder_Close(aacDec_handle)) { + aacDec_handle = NULL; + aacdec_init(); + TRACE(1, "%s reopen aac codec \n", __func__); } - /* decode one AAC frame */ - err = aacDecoder_DecodeFrame(aacDec_handle, (short *)out, out_max/2, 0 /* flags */); + return 2; + } + /* decode one AAC frame */ + err = aacDecoder_DecodeFrame(aacDec_handle, (short *)out, out_max / 2, + 0 /* flags */); #if 0 TRACE_IMM(0," "); @@ -1170,48 +1176,48 @@ int decode_aac_frame(uint8_t *out, uint32_t out_max, uint32_t *p_out_len, const } #endif - if (err != AAC_DEC_OK) - { - TRACE(1,"aacDecoder_DecodeFrame failed:0x%x", err); - //if aac failed reopen it again - if(is_aacDecoder_Close(aacDec_handle)){ - aacDec_handle = NULL; - aacdec_init(); - TRACE(1,"%s reopen aac codec \n", __func__); - } - return 3; + if (err != AAC_DEC_OK) { + TRACE(1, "aacDecoder_DecodeFrame failed:0x%x", err); + // if aac failed reopen it again + if (is_aacDecoder_Close(aacDec_handle)) { + aacDec_handle = NULL; + aacdec_init(); + TRACE(1, "%s reopen aac codec \n", __func__); } + return 3; + } - info = aacDecoder_GetStreamInfo(aacDec_handle); + info = aacDecoder_GetStreamInfo(aacDec_handle); - if (!info || info->sampleRate <= 0) { - TRACE(2,"%s Invalid stream info %d", __func__, info->sampleRate); - return 4; - } - int frame_len = info->frameSize * info->numChannels * 2;//sizeof(pcm_buffer[0]); - //TRACE(4,"aac: %d,frameSize=%d,numChannels=%d use %d ms\n", frame_len,info->frameSize,info->numChannels,TICKS_TO_MS(hal_sys_timer_get()-tt)); + if (!info || info->sampleRate <= 0) { + TRACE(2, "%s Invalid stream info %d", __func__, info->sampleRate); + return 4; + } + int frame_len = + info->frameSize * info->numChannels * 2; // sizeof(pcm_buffer[0]); + // TRACE(4,"aac: %d,frameSize=%d,numChannels=%d use %d ms\n", + // frame_len,info->frameSize,info->numChannels,TICKS_TO_MS(hal_sys_timer_get()-tt)); - if (p_out_len) { - *p_out_len = frame_len; - } - if (p_consume_len) { - *p_consume_len = in_len - bytesValid; - } + if (p_out_len) { + *p_out_len = frame_len; + } + if (p_consume_len) { + *p_consume_len = in_len - bytesValid; + } - if(a2dp_channel_num[app_bt_device.curr_a2dp_stream_id] == 1){ - expand_1_channel_to_2_channels_16bits(out, frame_len); - *p_out_len = frame_len << 1; - } - return 0; + if (a2dp_channel_num[app_bt_device.curr_a2dp_stream_id] == 1) { + expand_1_channel_to_2_channels_16bits(out, frame_len); + *p_out_len = frame_len << 1; + } + return 0; } #endif #ifdef A2DP_EQ_24BIT -static void convert_16bit_to_24bit(int32_t *out, int16_t *in, int len) -{ - for (int i = len - 1; i >= 0; i--) { - out[i] = ((int32_t)in[i] << 8); - } +static void convert_16bit_to_24bit(int32_t *out, int16_t *in, int len) { + for (int i = len - 1; i >= 0; i--) { + out[i] = ((int32_t)in[i] << 8); + } } #endif @@ -1221,7 +1227,6 @@ extern "C" { #include "ssc.h" } - unsigned char *scalable_input_mid_buf = NULL; unsigned char *scalable_decoder_place = NULL; unsigned char *scalable_decoder_temp_buf = NULL; @@ -1231,190 +1236,183 @@ void *hSSDecoder = NULL; uint8_t ss_dump[484*10]; uint32_t ss_dump_index = 0; #endif -extern "C" int ssc_decoder_init( - void *s, - int channels, - int Fs -); +extern "C" int ssc_decoder_init(void *s, int channels, int Fs); TEXT_SSC_LOC -void ss_to_24bit_buf(int32_t *out, int32_t *in, int size) -{ - for(int i = 0; i < size; i++) { - out[i] = in[i]; - } +void ss_to_24bit_buf(int32_t *out, int32_t *in, int size) { + for (int i = 0; i < size; i++) { + out[i] = in[i]; + } } TEXT_SSC_LOC -void ss_to_16bit_buf(int16_t *out, int32_t *in, int size) -{ - for(int i = 0; i < size; i++) { - out[i] = in[i]; - } +void ss_to_16bit_buf(int16_t *out, int32_t *in, int size) { + for (int i = 0; i < size; i++) { + out[i] = in[i]; + } } static int ss_pcm_buff[SCALABLE_FRAME_SIZE << 1]; static int scalable_uhq_flag = 0; TEXT_SSC_LOC -int load_scalable_frame(uint8_t **p_data, uint32_t *p_len) -{ - int hw_tmp,len,bitrate_bps,frame_size; - int r = 0; - unsigned char *e1 = NULL, *e2 = NULL; - unsigned int len1 = 0, len2 = 0; - int sampling_rate = 44100; - int extends_flag; +int load_scalable_frame(uint8_t **p_data, uint32_t *p_len) { + int hw_tmp, len, bitrate_bps, frame_size; + int r = 0; + unsigned char *e1 = NULL, *e2 = NULL; + unsigned int len1 = 0, len2 = 0; + int sampling_rate = 44100; + int extends_flag; - TRACE(0,"##decode_scalable_frame"); - uint8_t head[4]; + TRACE(0, "##decode_scalable_frame"); + uint8_t head[4]; + LOCK_APP_AUDIO_QUEUE(); + len1 = len2 = 0; + e1 = e2 = 0; + r = PeekCQueue(&sbc_queue, SCALABLE_HEAD_SIZE, &e1, &len1, &e2, &len2); + UNLOCK_APP_AUDIO_QUEUE(); + if (r == CQ_ERR) { + // osDelay(2); + TRACE(2, "no data head xxx %d/%d", LengthOfCQueue(&sbc_queue), + AvailableOfCQueue(&sbc_queue)); + // goto get_scalable_head_again; LOCK_APP_AUDIO_QUEUE(); - len1 = len2 = 0; - e1 = e2 = 0; - r = PeekCQueue(&sbc_queue, SCALABLE_HEAD_SIZE, &e1, &len1, &e2, &len2); + DeCQueue(&sbc_queue, head, 4); UNLOCK_APP_AUDIO_QUEUE(); - if(r == CQ_ERR) { - //osDelay(2); - TRACE(2,"no data head xxx %d/%d" , LengthOfCQueue(&sbc_queue),AvailableOfCQueue(&sbc_queue)); - //goto get_scalable_head_again; - LOCK_APP_AUDIO_QUEUE(); - DeCQueue(&sbc_queue, head, 4); - UNLOCK_APP_AUDIO_QUEUE(); - hal_trace_dump("sss %01x",1,4,head); - return 1; + hal_trace_dump("sss %01x", 1, 4, head); + return 1; + } else { + // normal + if (e1) { + memcpy(scalable_input_mid_buf, e1, len1); } - else { - // normal - if (e1) { - memcpy(scalable_input_mid_buf, e1, len1); - } - if (e2) { - memcpy(scalable_input_mid_buf + len1, e2, len2); - } + if (e2) { + memcpy(scalable_input_mid_buf + len1, e2, len2); } + } - LOCK_APP_AUDIO_QUEUE(); - DeCQueue(&sbc_queue, 0, 4); + LOCK_APP_AUDIO_QUEUE(); + DeCQueue(&sbc_queue, 0, 4); + UNLOCK_APP_AUDIO_QUEUE(); + + scalable_uhq_flag = 0; + + extends_flag = ((scalable_input_mid_buf[3] >> 3) & 1); + switch ((scalable_input_mid_buf[3] & 0xf7)) { + case 0xF0: + bitrate_bps = 88000; + break; + case 0xF1: + bitrate_bps = 96000; + break; + case 0xF2: + bitrate_bps = 128000; + break; + case 0xF3: + bitrate_bps = 192000; + break; + case 0xF5: + scalable_uhq_flag = 1; + bitrate_bps = 328000; + sampling_rate = 96000; + break; + default: + bitrate_bps = 88000; + break; + } + + frame_size = SCALABLE_FRAME_SIZE; + + len = bitrate_bps * frame_size / sampling_rate / 8; + if (scalable_uhq_flag == 0) { + hw_tmp = (len * 3) >> 7; + len = hw_tmp + len; + len = len + ((len & 1) ^ 1); + } else { + len = 369; // 744/2-4+1 + } + TRACE(4, "len %d,uhq:%d ext:%d extbitrate_bps %d", len, scalable_uhq_flag, + extends_flag, bitrate_bps); + + LOCK_APP_AUDIO_QUEUE(); + len1 = len2 = 0; + e1 = e2 = 0; + r = PeekCQueue(&sbc_queue, len - 1, &e1, &len1, &e2, &len2); + if (r == CQ_ERR) { + // osDelay(2); + TRACE(0, "no data "); UNLOCK_APP_AUDIO_QUEUE(); - - scalable_uhq_flag = 0; - - extends_flag = ((scalable_input_mid_buf[3]>>3)&1); - switch ((scalable_input_mid_buf[3]&0xf7)) { - case 0xF0: - bitrate_bps = 88000; - break; - case 0xF1: - bitrate_bps = 96000; - break; - case 0xF2: - bitrate_bps = 128000; - break; - case 0xF3: - bitrate_bps = 192000; - break; - case 0xF5: - scalable_uhq_flag = 1; - bitrate_bps = 328000; - sampling_rate = 96000; - break; - default: - bitrate_bps = 88000; - break; + return 2; + } else { + // normal + if (e1) { + memcpy(scalable_input_mid_buf + 4, e1, len1); } - - frame_size = SCALABLE_FRAME_SIZE; - - len = bitrate_bps*frame_size/sampling_rate/8; - if(scalable_uhq_flag == 0) - { - hw_tmp = (len*3)>>7; - len = hw_tmp+len; - len = len+((len & 1)^1); - } - else{ - len=369;//744/2-4+1 - } - TRACE(4,"len %d,uhq:%d ext:%d extbitrate_bps %d", len,scalable_uhq_flag, extends_flag,bitrate_bps); - - LOCK_APP_AUDIO_QUEUE(); - len1 = len2 = 0; - e1 = e2 = 0; - r = PeekCQueue(&sbc_queue, len-1, &e1, &len1, &e2, &len2); - if(r == CQ_ERR) { - //osDelay(2); - TRACE(0,"no data "); - UNLOCK_APP_AUDIO_QUEUE(); - return 2; + if (e2) { + memcpy(scalable_input_mid_buf + 4 + len1, e2, len2); } - else { - // normal - if (e1) { - memcpy(scalable_input_mid_buf+4, e1, len1); - } - if (e2) { - memcpy(scalable_input_mid_buf+4+len1, e2, len2); - } - } -// UNLOCK_APP_AUDIO_QUEUE(); + } + // UNLOCK_APP_AUDIO_QUEUE(); - // LOCK_APP_AUDIO_QUEUE(); - DeCQueue(&sbc_queue, 0, len-1); - UNLOCK_APP_AUDIO_QUEUE(); -// TRACE(2,"len1 %d, len2 %d\n", len1, len2); + // LOCK_APP_AUDIO_QUEUE(); + DeCQueue(&sbc_queue, 0, len - 1); + UNLOCK_APP_AUDIO_QUEUE(); + // TRACE(2,"len1 %d, len2 %d\n", len1, len2); - if (p_data) { - *p_data = scalable_input_mid_buf; - } - if (p_len) { - *p_len = len - 1; - } + if (p_data) { + *p_data = scalable_input_mid_buf; + } + if (p_len) { + *p_len = len - 1; + } - return 0; + return 0; } TEXT_SSC_LOC -int decode_scalable_frame(uint8_t *out, uint32_t out_max, uint32_t *p_out_len, const uint8_t *in, uint32_t in_len, uint32_t *p_consume_len) -{ - uint32_t out_len; - int decoder_size; - int output_samples; - int err; +int decode_scalable_frame(uint8_t *out, uint32_t out_max, uint32_t *p_out_len, + const uint8_t *in, uint32_t in_len, + uint32_t *p_consume_len) { + uint32_t out_len; + int decoder_size; + int output_samples; + int err; - out_len = SCALABLE_FRAME_SIZE * 2; + out_len = SCALABLE_FRAME_SIZE * 2; - if (hSSDecoder == NULL) { - hSSDecoder = (void *)scalable_decoder_place; - //err = ssc_decoder_create(44100, 2, hSSDecoder); - decoder_size = ssc_decoder_get_size(2,96000); - err = ssc_decoder_init(hSSDecoder,2,96000); - TRACE(2,"decoder_size %d init ret %d\n", decoder_size,err); - } + if (hSSDecoder == NULL) { + hSSDecoder = (void *)scalable_decoder_place; + // err = ssc_decoder_create(44100, 2, hSSDecoder); + decoder_size = ssc_decoder_get_size(2, 96000); + err = ssc_decoder_init(hSSDecoder, 2, 96000); + TRACE(2, "decoder_size %d init ret %d\n", decoder_size, err); + } - if(a2dp_channel_num[app_bt_device.curr_a2dp_stream_id] == 1){ - ASSERT(0, "UHQ should check audio channel number"); - } - output_samples = ssc_decode(hSSDecoder, scalable_input_mid_buf, (int *)ss_pcm_buff, SCALABLE_FRAME_SIZE, scalable_decoder_temp_buf); - if (scalable_uhq_flag) { - ss_to_24bit_buf((int32_t *)out, (int32_t *)ss_pcm_buff, out_len); - out_len *= 4; - } - else { - ss_to_16bit_buf((int16_t *)out, (int32_t *)ss_pcm_buff, out_len); - out_len *= 2; - } + if (a2dp_channel_num[app_bt_device.curr_a2dp_stream_id] == 1) { + ASSERT(0, "UHQ should check audio channel number"); + } + output_samples = + ssc_decode(hSSDecoder, scalable_input_mid_buf, (int *)ss_pcm_buff, + SCALABLE_FRAME_SIZE, scalable_decoder_temp_buf); + if (scalable_uhq_flag) { + ss_to_24bit_buf((int32_t *)out, (int32_t *)ss_pcm_buff, out_len); + out_len *= 4; + } else { + ss_to_16bit_buf((int16_t *)out, (int32_t *)ss_pcm_buff, out_len); + out_len *= 2; + } - TRACE(2,"pcm_len %d o:%d", out_len, output_samples); + TRACE(2, "pcm_len %d o:%d", out_len, output_samples); - if (p_out_len) { - *p_out_len = out_len; - } - if (p_consume_len) { - *p_consume_len = 0; - } + if (p_out_len) { + *p_out_len = out_len; + } + if (p_consume_len) { + *p_consume_len = 0; + } - return 0; + return 0; } #endif @@ -1423,234 +1421,238 @@ static btif_sbc_pcm_data_t sbc_pcm_data; static uint8_t sbc_underflow; TEXT_SBC_LOC -void decode_sbc_begin(void) -{ - sbc_underflow = 0; -} +void decode_sbc_begin(void) { sbc_underflow = 0; } TEXT_SBC_LOC -int load_sbc_frame(uint8_t **p_data, uint32_t *p_len) -{ - unsigned char retry = 0; - int r = 0; - unsigned char *e1 = NULL, *e2 = NULL; - unsigned int len1 = 0, len2 = 0; +int load_sbc_frame(uint8_t **p_data, uint32_t *p_len) { + unsigned char retry = 0; + int r = 0; + unsigned char *e1 = NULL, *e2 = NULL; + unsigned int len1 = 0, len2 = 0; - if (!sbc_next_frame_size){ - sbc_next_frame_size = sbc_frame_size; - } + if (!sbc_next_frame_size) { + sbc_next_frame_size = sbc_frame_size; + } - if (need_init_decoder) { - sbc_next_frame_size = sbc_frame_size; - } + if (need_init_decoder) { + sbc_next_frame_size = sbc_frame_size; + } get_again: - LOCK_APP_AUDIO_QUEUE(); - len1 = len2 = 0; - r = PeekCQueue(&sbc_queue, sbc_next_frame_size, &e1, &len1, &e2, &len2); - UNLOCK_APP_AUDIO_QUEUE(); - if(r == CQ_ERR) { -#ifdef __LOCK_AUDIO_THREAD__ - TRACE(1,"cache sbc_underflow retry:%d\n", retry); - goto exit; -#elif defined (A2DP_SYNC_WITH_PUT_MUTUX) - int size; - A2DP_SYNC_WITH_PUT_MUTUX_ALLOC(); - A2DP_SYNC_WITH_PUT_MUTUX_WAIT(); - if (retry++>= 1; + } + + uint32_t lock = int_lock(); + ret = btif_sbc_decode_frames(sbc_decoder, (uint8_t *)in, in_len, &parse_len, + &sbc_pcm_data, out_max, sbc_eq_band_gain); + int_unlock(lock); + parse_len_total_frame += parse_len; + if (parse_len_total_frame >= sbc_frame_size) { + mtu_count--; + // TRACE(1,"-mtu_count = %d",mtu_count); + parse_len_total_frame -= sbc_frame_size; + } + if (ret == BT_STS_SUCCESS) { + sbc_next_frame_size = sbc_frame_size; + } else { + sbc_next_frame_size = (sbc_frame_size > parse_len) + ? (sbc_frame_size - parse_len) + : sbc_frame_size; + + if (ret == BT_STS_FAILED) { + need_init_decoder = true; + TRACE(1, "err mutelen:%d\n", sbc_pcm_data.dataLen); + } else if (ret == BT_STS_NO_RESOURCES) { + TRACE(1, "no_res mutelen:%d\n", sbc_pcm_data.dataLen); } + } - need_init_decoder = false; + if (p_out_len) { + *p_out_len = sbc_pcm_data.dataLen; + } + if (p_consume_len) { + *p_consume_len = parse_len; + } - sbc_pcm_data.data = out; - sbc_pcm_data.dataLen = 0; + if (a2dp_channel_num[app_bt_device.curr_a2dp_stream_id] == 1) { + expand_1_channel_to_2_channels_16bits(sbc_pcm_data.data, + sbc_pcm_data.dataLen); + sbc_pcm_data.dataLen <<= 1; + *p_out_len = sbc_pcm_data.dataLen; + } - if(a2dp_channel_num[app_bt_device.curr_a2dp_stream_id] == 1){ - out_max >>= 1; - } - - uint32_t lock = int_lock(); - ret = btif_sbc_decode_frames(sbc_decoder, (uint8_t *)in, in_len, - &parse_len, - &sbc_pcm_data, - out_max, - sbc_eq_band_gain); - int_unlock(lock); - parse_len_total_frame += parse_len; - if(parse_len_total_frame >= sbc_frame_size){ - mtu_count --; - // TRACE(1,"-mtu_count = %d",mtu_count); - parse_len_total_frame -= sbc_frame_size; - } - if (ret == BT_STS_SUCCESS) { - sbc_next_frame_size = sbc_frame_size; - } else { - sbc_next_frame_size = (sbc_frame_size > parse_len) ? (sbc_frame_size - parse_len) : sbc_frame_size; - - if (ret == BT_STS_FAILED) { - need_init_decoder = true; - TRACE(1,"err mutelen:%d\n",sbc_pcm_data.dataLen); - } else if(ret == BT_STS_NO_RESOURCES) { - TRACE(1,"no_res mutelen:%d\n",sbc_pcm_data.dataLen); - } - } - - if (p_out_len) { - *p_out_len = sbc_pcm_data.dataLen; - } - if (p_consume_len) { - *p_consume_len = parse_len; - } - - if(a2dp_channel_num[app_bt_device.curr_a2dp_stream_id] == 1){ - expand_1_channel_to_2_channels_16bits(sbc_pcm_data.data, sbc_pcm_data.dataLen); - sbc_pcm_data.dataLen <<= 1; - *p_out_len = sbc_pcm_data.dataLen; - } - - return (ret == BT_STS_CONTINUE || ret == BT_STS_SUCCESS) ? 0 : 1; + return (ret == BT_STS_CONTINUE || ret == BT_STS_SUCCESS) ? 0 : 1; } TEXT_SBC_LOC -int consume_sbc_frame(const uint8_t *data, uint32_t len) -{ - LOCK_APP_AUDIO_QUEUE(); - DeCQueue(&sbc_queue, 0, len); - UNLOCK_APP_AUDIO_QUEUE(); +int consume_sbc_frame(const uint8_t *data, uint32_t len) { + LOCK_APP_AUDIO_QUEUE(); + DeCQueue(&sbc_queue, 0, len); + UNLOCK_APP_AUDIO_QUEUE(); - return 0; + return 0; } TEXT_SBC_LOC -void decode_sbc_end(uint32_t expect_out_len, uint32_t out_len, uint32_t in_len) -{ +void decode_sbc_end(uint32_t expect_out_len, uint32_t out_len, + uint32_t in_len) { #ifndef A2DP_TRACE_DEC_TIME - if (sbc_underflow || need_init_decoder) { - dec_trace_time = true; - } + if (sbc_underflow || need_init_decoder) { + dec_trace_time = true; + } #endif #ifdef A2DP_AUDIO_SYNC_WITH_LOCAL - if(expect_out_len == out_len){ - int size; - LOCK_APP_AUDIO_QUEUE(); - size = LengthOfCQueue(&sbc_queue); - UNLOCK_APP_AUDIO_QUEUE(); -// TRACE(2,"decode_sbc_frame Queue remain size:%d frame_size:%d\n",size, sbc_frame_size); - A2DP_AUDIO_SYNC_TRACE(6,"sync status:%d qsize:%d/%d fsize:%d, thr:%d used:%d", sync_status,size, g_sbc_queue_size, sbc_frame_size, A2DPPLAY_CACHE_OK_THRESHOLD, in_len); -/* -nor: - if (size>7488+1170*2) - goto inc - if (size<7488-1170) - goto dec -dec: - if (size>=7488+1170) - goto nor -inc: - if (size<=7488) - goto nor -*/ - switch (sync_status) { - case A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_DEC: - if (size >= (A2DPPLAY_CACHE_OK_THRESHOLD + in_len)){ - a2dp_audio_sync_proc(A2DPPLAY_SYNC_STATUS_SET, A2DP_AUDIO_SYNC_WITH_LOCAL_SAMPLERATE_DEFAULT); - sync_status = A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_DEFAULT; - A2DP_AUDIO_SYNC_TRACE(0,"default pll freq"); - }else{ - a2dp_audio_sync_proc(A2DPPLAY_SYNC_STATUS_PROC, 0); - } - break; - case A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_INC: - if (size <= (A2DPPLAY_CACHE_OK_THRESHOLD)){ - a2dp_audio_sync_proc(A2DPPLAY_SYNC_STATUS_SET, A2DP_AUDIO_SYNC_WITH_LOCAL_SAMPLERATE_DEFAULT); - sync_status = A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_DEFAULT; - A2DP_AUDIO_SYNC_TRACE(0,"default pll freq"); - }else{ - a2dp_audio_sync_proc(A2DPPLAY_SYNC_STATUS_PROC, 0); - } - break; - case A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_DEFAULT: - default: - if (size > (A2DPPLAY_CACHE_OK_THRESHOLD + (in_len<<1))){ - a2dp_audio_sync_proc(A2DPPLAY_SYNC_STATUS_SET, A2DP_AUDIO_SYNC_WITH_LOCAL_SAMPLERATE_INC); - sync_status = A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_INC; - A2DP_AUDIO_SYNC_TRACE(0,"inc pll freq"); - }else if (size < (A2DPPLAY_CACHE_OK_THRESHOLD - in_len)){ - a2dp_audio_sync_proc(A2DPPLAY_SYNC_STATUS_SET, A2DP_AUDIO_SYNC_WITH_LOCAL_SAMPLERATE_DEC); - sync_status = A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_DEC; - A2DP_AUDIO_SYNC_TRACE(0,"dec pll freq"); - }else{ - a2dp_audio_sync_proc(A2DPPLAY_SYNC_STATUS_PROC, 0); - } - break; - } + if (expect_out_len == out_len) { + int size; + LOCK_APP_AUDIO_QUEUE(); + size = LengthOfCQueue(&sbc_queue); + UNLOCK_APP_AUDIO_QUEUE(); + // TRACE(2,"decode_sbc_frame Queue remain size:%d + // frame_size:%d\n",size, sbc_frame_size); + A2DP_AUDIO_SYNC_TRACE(6, + "sync status:%d qsize:%d/%d fsize:%d, thr:%d used:%d", + sync_status, size, g_sbc_queue_size, sbc_frame_size, + A2DPPLAY_CACHE_OK_THRESHOLD, in_len); + /* + nor: + if (size>7488+1170*2) + goto inc + if (size<7488-1170) + goto dec + dec: + if (size>=7488+1170) + goto nor + inc: + if (size<=7488) + goto nor + */ + switch (sync_status) { + case A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_DEC: + if (size >= (A2DPPLAY_CACHE_OK_THRESHOLD + in_len)) { + a2dp_audio_sync_proc(A2DPPLAY_SYNC_STATUS_SET, + A2DP_AUDIO_SYNC_WITH_LOCAL_SAMPLERATE_DEFAULT); + sync_status = A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_DEFAULT; + A2DP_AUDIO_SYNC_TRACE(0, "default pll freq"); + } else { + a2dp_audio_sync_proc(A2DPPLAY_SYNC_STATUS_PROC, 0); + } + break; + case A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_INC: + if (size <= (A2DPPLAY_CACHE_OK_THRESHOLD)) { + a2dp_audio_sync_proc(A2DPPLAY_SYNC_STATUS_SET, + A2DP_AUDIO_SYNC_WITH_LOCAL_SAMPLERATE_DEFAULT); + sync_status = A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_DEFAULT; + A2DP_AUDIO_SYNC_TRACE(0, "default pll freq"); + } else { + a2dp_audio_sync_proc(A2DPPLAY_SYNC_STATUS_PROC, 0); + } + break; + case A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_DEFAULT: + default: + if (size > (A2DPPLAY_CACHE_OK_THRESHOLD + (in_len << 1))) { + a2dp_audio_sync_proc(A2DPPLAY_SYNC_STATUS_SET, + A2DP_AUDIO_SYNC_WITH_LOCAL_SAMPLERATE_INC); + sync_status = A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_INC; + A2DP_AUDIO_SYNC_TRACE(0, "inc pll freq"); + } else if (size < (A2DPPLAY_CACHE_OK_THRESHOLD - in_len)) { + a2dp_audio_sync_proc(A2DPPLAY_SYNC_STATUS_SET, + A2DP_AUDIO_SYNC_WITH_LOCAL_SAMPLERATE_DEC); + sync_status = A2DP_AUDIO_SYNC_STATUS_SAMPLERATE_DEC; + A2DP_AUDIO_SYNC_TRACE(0, "dec pll freq"); + } else { + a2dp_audio_sync_proc(A2DPPLAY_SYNC_STATUS_PROC, 0); + } + break; } + } #endif } #if defined(A2DP_LHDC_ON) -#define PACKET_BUFFER_LENGTH 4 * 1024 +#define PACKET_BUFFER_LENGTH 4 * 1024 uint8_t serial_no; bool is_synced; @@ -1660,345 +1662,337 @@ uint8_t packet_buffer[PACKET_BUFFER_LENGTH]; uint32_t packet_buf_len = 0; uint32_t frames_nb_in_buffer = 0; uint32_t total_frame_nb = 0; -void reset_lhdc_assmeble_packet() -{ - is_synced = false; - asm_pkt_st = ASM_PKT_WAT_STR; - packet_buf_len = 0; - total_frame_nb = 0; +void reset_lhdc_assmeble_packet() { + is_synced = false; + asm_pkt_st = ASM_PKT_WAT_STR; + packet_buf_len = 0; + total_frame_nb = 0; } -void initial_lhdc_assemble_packet(bool splitFlg){ - memset(packet_buffer, 0, PACKET_BUFFER_LENGTH); - reset_lhdc_assmeble_packet(); - serial_no = 0xff; - is_splited = splitFlg; - TRACE(1,"is_splited = %s\n", splitFlg ? "true" : "false"); +void initial_lhdc_assemble_packet(bool splitFlg) { + memset(packet_buffer, 0, PACKET_BUFFER_LENGTH); + reset_lhdc_assmeble_packet(); + serial_no = 0xff; + is_splited = splitFlg; + TRACE(1, "is_splited = %s\n", splitFlg ? "true" : "false"); } - /** * get lhdc frame header */ -bool get_lhdc_header(uint8_t * in, LHDC_FRAME_HDR * h) { - #define LHDC_HDR_LEN 4 - uint32_t hdr = 0; - bool ret = false; - memcpy(&hdr, in , LHDC_HDR_LEN); - h->frame_len = ( int)( ( hdr >> 8) & 0x1fff); - h->isSplit = ( ( hdr & 0x00600000) == 0x00600000); - h->isLeft = ((hdr & 0xf) == 0); +bool get_lhdc_header(uint8_t *in, LHDC_FRAME_HDR *h) { +#define LHDC_HDR_LEN 4 + uint32_t hdr = 0; + bool ret = false; + memcpy(&hdr, in, LHDC_HDR_LEN); + h->frame_len = (int)((hdr >> 8) & 0x1fff); + h->isSplit = ((hdr & 0x00600000) == 0x00600000); + h->isLeft = ((hdr & 0xf) == 0); - if ( ( hdr & 0xff000000) != 0x4c000000){ - TRACE(0,"lhdc hdr err!\n"); - ret = false; - } else { - //TRACE(4,"frame_len = %d, g_lhdc_split = %s, g_lhdc_channel = %s(%d)", h->frame_len, h->isSplit ? "true" : "false", h->isLeft ? "left" : "right", (hdr & 0xf) ); - ret = true; - } - return ret; + if ((hdr & 0xff000000) != 0x4c000000) { + TRACE(0, "lhdc hdr err!\n"); + ret = false; + } else { + // TRACE(4,"frame_len = %d, g_lhdc_split = %s, g_lhdc_channel = %s(%d)", + // h->frame_len, h->isSplit ? "true" : "false", h->isLeft ? "left" : + // "right", (hdr & 0xf) ); + ret = true; + } + return ret; } /** *Get splited lhdc frames fit to MTU size */ -uint32_t get_lhdc_frame(uint8_t * frame_q, size_t q_available_size, uint8_t * out_buf, uint32_t * out_size, uint32_t * out_frames){ - LHDC_FRAME_HDR hdr; - size_t emptSize = q_available_size >= PACKET_MTU_SIZE ? PACKET_MTU_SIZE : q_available_size; - uint32_t * offset = out_size; - //uint32_t * frame_cnt = out_frames; - bool start = TRUE; - *offset = 0; // *frame_cnt = 0; - while (start) { +uint32_t get_lhdc_frame(uint8_t *frame_q, size_t q_available_size, + uint8_t *out_buf, uint32_t *out_size, + uint32_t *out_frames) { + LHDC_FRAME_HDR hdr; + size_t emptSize = + q_available_size >= PACKET_MTU_SIZE ? PACKET_MTU_SIZE : q_available_size; + uint32_t *offset = out_size; + // uint32_t * frame_cnt = out_frames; + bool start = TRUE; + *offset = 0; // *frame_cnt = 0; + while (start) { - if (get_lhdc_header(frame_q + *offset, &hdr) == false ){ - start = false; - continue; - } - - if (emptSize < hdr.frame_len) { - start = false; - continue; - } - - memcpy(out_buf + *offset, frame_q + *offset, hdr.frame_len); - emptSize -= hdr.frame_len; - *offset += hdr.frame_len; - (*out_frames)++; + if (get_lhdc_header(frame_q + *offset, &hdr) == false) { + start = false; + continue; } - return *offset; + + if (emptSize < hdr.frame_len) { + start = false; + continue; + } + + memcpy(out_buf + *offset, frame_q + *offset, hdr.frame_len); + emptSize -= hdr.frame_len; + *offset += hdr.frame_len; + (*out_frames)++; + } + return *offset; } /** * Grabe lhdc data from queue */ -int get_lhdc_data(unsigned char * frame, unsigned int len) -{ - int status; - unsigned int len1 = 0, len2 = 0; - unsigned char *e1 = NULL, *e2 = NULL; - LOCK_APP_AUDIO_QUEUE(); - unsigned int queu_len = (unsigned int)LengthOfCQueue(&sbc_queue); - len = queu_len < len ? queu_len : len; - status = PeekCQueue(&sbc_queue, len, &e1, &len1, &e2, &len2); - UNLOCK_APP_AUDIO_QUEUE(); - if(status != CQ_OK){ - return 0; - } +int get_lhdc_data(unsigned char *frame, unsigned int len) { + int status; + unsigned int len1 = 0, len2 = 0; + unsigned char *e1 = NULL, *e2 = NULL; + LOCK_APP_AUDIO_QUEUE(); + unsigned int queu_len = (unsigned int)LengthOfCQueue(&sbc_queue); + len = queu_len < len ? queu_len : len; + status = PeekCQueue(&sbc_queue, len, &e1, &len1, &e2, &len2); + UNLOCK_APP_AUDIO_QUEUE(); + if (status != CQ_OK) { + return 0; + } - if (e1) { - memcpy(frame, e1, len1); - } - if (e2) { - memcpy(frame + len1, e2, len2); - } - return len; + if (e1) { + memcpy(frame, e1, len1); + } + if (e2) { + memcpy(frame + len1, e2, len2); + } + return len; } +int assemble_lhdc_packet(uint8_t *input, uint32_t input_len, uint8_t **pLout, + uint32_t *pLlen, uint8_t **pRout, uint32_t *pRlen) { + uint8_t hdr = 0, seqno = 0xff; + int ret = -1; + uint32_t status = 0; -int assemble_lhdc_packet(uint8_t * input, uint32_t input_len, uint8_t** pLout, uint32_t * pLlen, uint8_t** pRout, uint32_t * pRlen){ - uint8_t hdr = 0, seqno = 0xff; - int ret = -1; - uint32_t status = 0; + hdr = (*input); + input++; + seqno = (*input); + input++; + input_len -= 2; - hdr = (*input); - input++; - seqno = (*input); - input++; - input_len -= 2; + status = hdr & A2DP_LHDC_HDR_LATENCY_MASK; + if (latencyUpdated != (uint8_t)status) { + latencyUpdated = (uint8_t)status; + TRACE(1, "New latency setting = 0x%02x", latencyUpdated); + } - status = hdr & A2DP_LHDC_HDR_LATENCY_MASK; - if (latencyUpdated != (uint8_t)status) { - latencyUpdated = (uint8_t)status; - TRACE(1,"New latency setting = 0x%02x", latencyUpdated); + if (is_synced) { + if (seqno != serial_no) { + reset_lhdc_assmeble_packet(); + if ((hdr & A2DP_LHDC_HDR_FLAG_MSK) == 0 || + (hdr & A2DP_LHDC_HDR_S_MSK) != 0) { + goto lhdc_start; + } else + TRACE(1, "drop packet No. %u", seqno); + return 0; } - - if( is_synced) - { - if( seqno != serial_no ) - { - reset_lhdc_assmeble_packet(); - if( (hdr & A2DP_LHDC_HDR_FLAG_MSK) == 0 || - (hdr & A2DP_LHDC_HDR_S_MSK) != 0 ) - { - goto lhdc_start; - } - else - TRACE(1,"drop packet No. %u", seqno); - return 0; - } - serial_no = seqno + 1; - } + serial_no = seqno + 1; + } lhdc_start: - switch (asm_pkt_st) { - case ASM_PKT_WAT_STR:{ - if( (hdr & A2DP_LHDC_HDR_FLAG_MSK) == 0 ) - { - memcpy(&packet_buffer[0], input, input_len); - if (pLlen && pLout) { - *pLlen = input_len; - *pLout = packet_buffer; - } - if (pRout && pRlen) { - *pRout = NULL; - *pRlen = 0; - } - //TRACE(1,"Single payload size = %d", *pLlen); - asm_pkt_st = ASM_PKT_WAT_STR; - packet_buf_len = 0;//= packet_buf_left_len = packet_buf_right_len = 0; - total_frame_nb = 0; - ret = 1; - } - else if( hdr & A2DP_LHDC_HDR_S_MSK ) - { - ret = 0; - if (packet_buf_len + input_len >= PACKET_BUFFER_LENGTH) { - packet_buf_len = 0; - asm_pkt_st = ASM_PKT_WAT_STR; - TRACE(1,"ASM_PKT_WAT_STR:Frame buffer overflow!(%d)", packet_buf_len); - break; - } - memcpy(&packet_buffer, input, input_len); - packet_buf_len = input_len; - asm_pkt_st = ASM_PKT_WAT_LST; - //TRACE(1,"multi:first payload size = %d", input_len); - } - else - ret = -1; - - if( ret >= 0 ) - { - if( !is_synced ) - { - is_synced = true; - serial_no = seqno + 1; - } - } - break; - } - case ASM_PKT_WAT_LST:{ - if (packet_buf_len + input_len >= PACKET_BUFFER_LENGTH) { - packet_buf_len = 0; - asm_pkt_st = ASM_PKT_WAT_STR; - TRACE(1,"ASM_PKT_WAT_LST:Frame buffer overflow(%d)", packet_buf_len); - break; - } - memcpy(&packet_buffer[packet_buf_len], input, input_len); - //TRACE(1,"multi:payload size = %d", input_len); - packet_buf_len += input_len; - ret = 0; - - if( hdr & A2DP_LHDC_HDR_L_MSK ) - { - - if (pLlen && pLout) { - *pLlen = packet_buf_len; - *pLout = packet_buffer; - } - //TRACE(1,"multi: all payload size = %d", packet_buf_len); - packet_buf_len = 0; //packet_buf_left_len = packet_buf_right_len = 0; - total_frame_nb = 0; - ret = 1; - asm_pkt_st = ASM_PKT_WAT_STR; - } - break; - } - default: - ret = 0; + switch (asm_pkt_st) { + case ASM_PKT_WAT_STR: { + if ((hdr & A2DP_LHDC_HDR_FLAG_MSK) == 0) { + memcpy(&packet_buffer[0], input, input_len); + if (pLlen && pLout) { + *pLlen = input_len; + *pLout = packet_buffer; + } + if (pRout && pRlen) { + *pRout = NULL; + *pRlen = 0; + } + // TRACE(1,"Single payload size = %d", *pLlen); + asm_pkt_st = ASM_PKT_WAT_STR; + packet_buf_len = 0; //= packet_buf_left_len = packet_buf_right_len = 0; + total_frame_nb = 0; + ret = 1; + } else if (hdr & A2DP_LHDC_HDR_S_MSK) { + ret = 0; + if (packet_buf_len + input_len >= PACKET_BUFFER_LENGTH) { + packet_buf_len = 0; + asm_pkt_st = ASM_PKT_WAT_STR; + TRACE(1, "ASM_PKT_WAT_STR:Frame buffer overflow!(%d)", packet_buf_len); break; + } + memcpy(&packet_buffer, input, input_len); + packet_buf_len = input_len; + asm_pkt_st = ASM_PKT_WAT_LST; + // TRACE(1,"multi:first payload size = %d", input_len); + } else + ret = -1; + if (ret >= 0) { + if (!is_synced) { + is_synced = true; + serial_no = seqno + 1; + } } - return ret; + break; + } + case ASM_PKT_WAT_LST: { + if (packet_buf_len + input_len >= PACKET_BUFFER_LENGTH) { + packet_buf_len = 0; + asm_pkt_st = ASM_PKT_WAT_STR; + TRACE(1, "ASM_PKT_WAT_LST:Frame buffer overflow(%d)", packet_buf_len); + break; + } + memcpy(&packet_buffer[packet_buf_len], input, input_len); + // TRACE(1,"multi:payload size = %d", input_len); + packet_buf_len += input_len; + ret = 0; + + if (hdr & A2DP_LHDC_HDR_L_MSK) { + + if (pLlen && pLout) { + *pLlen = packet_buf_len; + *pLout = packet_buffer; + } + // TRACE(1,"multi: all payload size = %d", packet_buf_len); + packet_buf_len = 0; // packet_buf_left_len = packet_buf_right_len = 0; + total_frame_nb = 0; + ret = 1; + asm_pkt_st = ASM_PKT_WAT_STR; + } + break; + } + default: + ret = 0; + break; + } + return ret; } /** * Decode LHDC data... */ TEXT_LHDC_LOC -int load_lhdc_frame(uint8_t **p_data, uint32_t *p_len) -{ - int ret; - LHDC_HEADER *ph = NULL; - uint8_t retry = 0; - int status; - uint8_t *_buff = NULL; - uint32_t _buff_len = 0; +int load_lhdc_frame(uint8_t **p_data, uint32_t *p_len) { + int ret; + LHDC_HEADER *ph = NULL; + uint8_t retry = 0; + int status; + uint8_t *_buff = NULL; + uint32_t _buff_len = 0; - ret = 1; + ret = 1; - A2DP_SYNC_WITH_PUT_MUTUX_ALLOC(); + A2DP_SYNC_WITH_PUT_MUTUX_ALLOC(); - if (latencyIndex != latencyUpdated) { - latencyIndex = latencyUpdated; - goto _exit; - } + if (latencyIndex != latencyUpdated) { + latencyIndex = latencyUpdated; + goto _exit; + } - while (true) { - int result = lhdcReadyForInput(); - if (result == 1) { - /* code */ - status = get_lhdc_data(lhdc_input_mid_buf, sizeof(LHDC_HEADER)); - if(status == 0){ - //No data return... - if (retry++ >= A2DP_SYNC_WITH_PUT_MUTUX_TIMEROUT_CNT){ - TRACE(1,"%s:No Data return", __func__); - break; - } - A2DP_SYNC_WITH_PUT_MUTUX_WAIT(); - continue; - } - retry = 0; - ph = (LHDC_HEADER *)&lhdc_input_mid_buf[0]; - result = memcmp((const char*)magicTag, (const char*)ph->tag, sizeof(magicTag)); - if (result != 0) { - uint8_t tmp[sizeof(magicTag) + 1]; - size_t i; - for ( i = 0; i < sizeof(magicTag); i++) { - sprintf((char*)&tmp[i], "%c", (char)ph->tag[i]); - } - tmp[i] = 0; - continue; - } - - status = get_lhdc_data(lhdc_input_mid_buf, sizeof(LHDC_HEADER) + ph->packetLen); - if(status == 0){ - //No data return... - TRACE(1,"Fetch data error[lenght = %d]", ph->packetLen); - continue; - } - ph = (LHDC_HEADER *)&lhdc_input_mid_buf[0]; - - //TRACE(2,"%s:Get packet[%d]", __func__, ph->packetLen); - - LOCK_APP_AUDIO_QUEUE(); - DeCQueue(&sbc_queue, 0, sizeof(LHDC_HEADER) + ph->packetLen); - mtu_count--; - UNLOCK_APP_AUDIO_QUEUE(); - _buff = ph->dptr; - _buff_len = ph->packetLen; - ret = 0; - } else { - _buff = NULL; - _buff_len = 0; - ret = 0; + while (true) { + int result = lhdcReadyForInput(); + if (result == 1) { + /* code */ + status = get_lhdc_data(lhdc_input_mid_buf, sizeof(LHDC_HEADER)); + if (status == 0) { + // No data return... + if (retry++ >= A2DP_SYNC_WITH_PUT_MUTUX_TIMEROUT_CNT) { + TRACE(1, "%s:No Data return", __func__); + break; } - break; + A2DP_SYNC_WITH_PUT_MUTUX_WAIT(); + continue; + } + retry = 0; + ph = (LHDC_HEADER *)&lhdc_input_mid_buf[0]; + result = memcmp((const char *)magicTag, (const char *)ph->tag, + sizeof(magicTag)); + if (result != 0) { + uint8_t tmp[sizeof(magicTag) + 1]; + size_t i; + for (i = 0; i < sizeof(magicTag); i++) { + sprintf((char *)&tmp[i], "%c", (char)ph->tag[i]); + } + tmp[i] = 0; + continue; + } + + status = get_lhdc_data(lhdc_input_mid_buf, + sizeof(LHDC_HEADER) + ph->packetLen); + if (status == 0) { + // No data return... + TRACE(1, "Fetch data error[lenght = %d]", ph->packetLen); + continue; + } + ph = (LHDC_HEADER *)&lhdc_input_mid_buf[0]; + + // TRACE(2,"%s:Get packet[%d]", __func__, ph->packetLen); + + LOCK_APP_AUDIO_QUEUE(); + DeCQueue(&sbc_queue, 0, sizeof(LHDC_HEADER) + ph->packetLen); + mtu_count--; + UNLOCK_APP_AUDIO_QUEUE(); + _buff = ph->dptr; + _buff_len = ph->packetLen; + ret = 0; + } else { + _buff = NULL; + _buff_len = 0; + ret = 0; } + break; + } _exit: - A2DP_SYNC_WITH_PUT_MUTUX_FREE(); + A2DP_SYNC_WITH_PUT_MUTUX_FREE(); - if (p_data) { - *p_data = _buff; - } - if (p_len) { - *p_len = _buff_len; - } + if (p_data) { + *p_data = _buff; + } + if (p_len) { + *p_len = _buff_len; + } - return ret; + return ret; } TEXT_LHDC_LOC -int decode_lhdc_frame(uint8_t *out, uint32_t out_max, uint32_t *p_out_len, const uint8_t *in, uint32_t in_len, uint32_t *p_consume_len) -{ - uint32_t need_again; - uint32_t out_len; +int decode_lhdc_frame(uint8_t *out, uint32_t out_max, uint32_t *p_out_len, + const uint8_t *in, uint32_t in_len, + uint32_t *p_consume_len) { + uint32_t need_again; + uint32_t out_len; - if(a2dp_channel_num[app_bt_device.curr_a2dp_stream_id] == 1){ - ASSERT(0, "lhdc should check audio channel number"); - } + if (a2dp_channel_num[app_bt_device.curr_a2dp_stream_id] == 1) { + ASSERT(0, "lhdc should check audio channel number"); + } - out_len = lhdcDecodeProcess(out, (uint8_t *)in, in_len, &need_again); + out_len = lhdcDecodeProcess(out, (uint8_t *)in, in_len, &need_again); - if (p_out_len) { - *p_out_len = (out_len >= 0) ? out_len : 0; - } - if (p_consume_len) { - *p_consume_len = (out_len >= 0) ? in_len : 0; - } + if (p_out_len) { + *p_out_len = (out_len >= 0) ? out_len : 0; + } + if (p_consume_len) { + *p_consume_len = (out_len >= 0) ? in_len : 0; + } - return (out_len >= 0) ? 0 : 1; + return (out_len >= 0) ? 0 : 1; } TEXT_LHDC_LOC -void decode_lhdc_end(uint32_t expect_out_len, uint32_t out_len, uint32_t in_len) -{ - if (expect_out_len != out_len) { - dec_reset_queue = true; - } +void decode_lhdc_end(uint32_t expect_out_len, uint32_t out_len, + uint32_t in_len) { + if (expect_out_len != out_len) { + dec_reset_queue = true; + } } #endif #ifdef A2DP_CP_ACCEL #include "cp_accel.h" -#define CP_CACHE_ATTR ALIGNED(4) CP_BSS_LOC -#define CP_DEC_SLOT_CNT 3 +#define CP_CACHE_ATTR ALIGNED(4) CP_BSS_LOC +#define CP_DEC_SLOT_CNT 3 enum CP_DEC_STATE_T { - CP_DEC_STATE_IDLE, - CP_DEC_STATE_WORKING, - CP_DEC_STATE_DONE, - CP_DEC_STATE_FAILED, + CP_DEC_STATE_IDLE, + CP_DEC_STATE_WORKING, + CP_DEC_STATE_DONE, + CP_DEC_STATE_FAILED, }; static CP_CACHE_ATTR uint8_t cp_in_cache[1024 * 10]; @@ -2025,1153 +2019,1173 @@ static uint32_t cp_out_size; static uint32_t cp_out_loop_size; static uint32_t cp_get_in_cache_data_len(uint32_t in_wpos, uint32_t in_rpos); -static void cp_get_in_cache_data(uint8_t *data, uint32_t len, uint32_t in_wpos, uint32_t in_rpos); +static void cp_get_in_cache_data(uint8_t *data, uint32_t len, uint32_t in_wpos, + uint32_t in_rpos); static uint32_t cp_update_in_cache_pos(uint32_t in_pos, uint32_t len); #if defined(A2DP_LDAC_ON) static CP_BSS_LOC bool cp_ldac_fatal_error; TEXT_LDAC_LOC -int cp_load_ldac_frame(uint8_t **p_data, uint32_t *p_len) -{ - uint32_t len; - uint32_t in_rpos; - uint32_t in_wpos; +int cp_load_ldac_frame(uint8_t **p_data, uint32_t *p_len) { + uint32_t len; + uint32_t in_rpos; + uint32_t in_wpos; - if (hLdacData == NULL || cp_ldac_fatal_error){ - return 1; - } + if (hLdacData == NULL || cp_ldac_fatal_error) { + return 1; + } - in_rpos = cp_in_rpos; - in_wpos = cp_in_wpos; + in_rpos = cp_in_rpos; + in_wpos = cp_in_wpos; _get_hdr: - len = cp_get_in_cache_data_len(in_wpos, in_rpos); - if (len == 0) { - return 2; - } - if (len > LDAC_READBUF_SIZE) { - len = LDAC_READBUF_SIZE; + len = cp_get_in_cache_data_len(in_wpos, in_rpos); + if (len == 0) { + return 2; + } + if (len > LDAC_READBUF_SIZE) { + len = LDAC_READBUF_SIZE; + } + + cp_get_in_cache_data(&ldac_input_mid_buf[0], len, in_wpos, in_rpos); + + if (ldac_recovery) { + uint32_t parse_bytes; + int result; + + result = ldac_seek_header(len, &parse_bytes); + if (result == 0) { + ldac_recovery = false; } + in_rpos = cp_update_in_cache_pos(in_rpos, parse_bytes); + goto _get_hdr; + } - cp_get_in_cache_data(&ldac_input_mid_buf[0], len, in_wpos, in_rpos); - - if (ldac_recovery) { - uint32_t parse_bytes; - int result; - - result = ldac_seek_header(len, &parse_bytes); - if (result == 0) { - ldac_recovery = false; - } - in_rpos = cp_update_in_cache_pos(in_rpos, parse_bytes); - goto _get_hdr; - } - - return 0; + return 0; } TEXT_LDAC_LOC -static int cp_consume_ldac_frame(const uint8_t *data, uint32_t len) -{ - cp_in_rpos = cp_update_in_cache_pos(cp_in_rpos, len); +static int cp_consume_ldac_frame(const uint8_t *data, uint32_t len) { + cp_in_rpos = cp_update_in_cache_pos(cp_in_rpos, len); - return 0; + return 0; } TEXT_LDAC_LOC -void cp_decode_ldac_end(uint32_t expect_out_len, uint32_t out_len, uint32_t in_len) -{ - if (expect_out_len != out_len) { - if (hLdacData) { - int error_code; - error_code = ldacBT_get_error_code(hLdacData); - TRACE(6,"error_code = %4d, %4d, %4d,FrameHeader[%02x:%02x:%02x]\n", LDACBT_API_ERR(error_code), LDACBT_HANDLE_ERR(error_code),\ - LDACBT_BLOCK_ERR(error_code), ldac_input_mid_buf[0], ldac_input_mid_buf[1], ldac_input_mid_buf[2]); - if( LDACBT_FATAL(error_code) ){ - cp_ldac_fatal_error = true; - } - } +void cp_decode_ldac_end(uint32_t expect_out_len, uint32_t out_len, + uint32_t in_len) { + if (expect_out_len != out_len) { + if (hLdacData) { + int error_code; + error_code = ldacBT_get_error_code(hLdacData); + TRACE(6, "error_code = %4d, %4d, %4d,FrameHeader[%02x:%02x:%02x]\n", + LDACBT_API_ERR(error_code), LDACBT_HANDLE_ERR(error_code), + LDACBT_BLOCK_ERR(error_code), ldac_input_mid_buf[0], + ldac_input_mid_buf[1], ldac_input_mid_buf[2]); + if (LDACBT_FATAL(error_code)) { + cp_ldac_fatal_error = true; + } } + } } TEXT_LDAC_LOC -void mcu_decode_ldac_end(uint32_t expect_out_len, uint32_t out_len, uint32_t in_len) -{ - if (expect_out_len != out_len) { - if (cp_ldac_fatal_error) { - ldac_dec_deinit(); - } - if (hLdacData == NULL) { - /* Recovery Process */ - int result; - result = ldac_dec_init(); - if (result) { - ldac_dec_deinit(); - } - ldac_recovery = true; - cp_ldac_fatal_error = false; - } +void mcu_decode_ldac_end(uint32_t expect_out_len, uint32_t out_len, + uint32_t in_len) { + if (expect_out_len != out_len) { + if (cp_ldac_fatal_error) { + ldac_dec_deinit(); } + if (hLdacData == NULL) { + /* Recovery Process */ + int result; + result = ldac_dec_init(); + if (result) { + ldac_dec_deinit(); + } + ldac_recovery = true; + cp_ldac_fatal_error = false; + } + } } #endif #if defined(A2DP_LHDC_ON) TEXT_LHDC_LOC -int cp_load_lhdc_frame(uint8_t **p_data, uint32_t *p_len) -{ - int ret; - LHDC_HEADER ph; - uint32_t len; - uint32_t in_rpos; - uint32_t in_wpos; - uint8_t *frame_buf = NULL; - uint32_t frame_len = 0; - int result; +int cp_load_lhdc_frame(uint8_t **p_data, uint32_t *p_len) { + int ret; + LHDC_HEADER ph; + uint32_t len; + uint32_t in_rpos; + uint32_t in_wpos; + uint8_t *frame_buf = NULL; + uint32_t frame_len = 0; + int result; - ret = 1; + ret = 1; - if (latencyIndex != latencyUpdated) { - latencyIndex = latencyUpdated; - goto _exit; - } + if (latencyIndex != latencyUpdated) { + latencyIndex = latencyUpdated; + goto _exit; + } - result = lhdcReadyForInput(); - if (result == 0) { - ret = 0; - goto _exit; - } + result = lhdcReadyForInput(); + if (result == 0) { + ret = 0; + goto _exit; + } - in_rpos = cp_in_rpos; - in_wpos = cp_in_wpos; + in_rpos = cp_in_rpos; + in_wpos = cp_in_wpos; _get_hdr: - len = cp_get_in_cache_data_len(in_wpos, in_rpos); - if (len < sizeof(ph)) { - goto _exit; - } + len = cp_get_in_cache_data_len(in_wpos, in_rpos); + if (len < sizeof(ph)) { + goto _exit; + } - cp_get_in_cache_data(&lhdc_input_mid_buf[0], sizeof(ph), in_wpos, in_rpos); + cp_get_in_cache_data(&lhdc_input_mid_buf[0], sizeof(ph), in_wpos, in_rpos); - memcpy(&ph, &lhdc_input_mid_buf[0], sizeof(ph)); - result = memcmp((const char*)magicTag, (const char*)ph.tag, sizeof(magicTag)); - if (result != 0) { - in_rpos = cp_update_in_cache_pos(in_rpos, 1); - goto _get_hdr; - } + memcpy(&ph, &lhdc_input_mid_buf[0], sizeof(ph)); + result = + memcmp((const char *)magicTag, (const char *)ph.tag, sizeof(magicTag)); + if (result != 0) { + in_rpos = cp_update_in_cache_pos(in_rpos, 1); + goto _get_hdr; + } - if (len < sizeof(ph) + ph.packetLen) { - goto _exit; - } + if (len < sizeof(ph) + ph.packetLen) { + goto _exit; + } - in_rpos = cp_update_in_cache_pos(in_rpos, sizeof(ph)); + in_rpos = cp_update_in_cache_pos(in_rpos, sizeof(ph)); - cp_get_in_cache_data(&lhdc_input_mid_buf[sizeof(ph)], ph.packetLen, in_wpos, in_rpos); + cp_get_in_cache_data(&lhdc_input_mid_buf[sizeof(ph)], ph.packetLen, in_wpos, + in_rpos); - in_rpos = cp_update_in_cache_pos(in_rpos, ph.packetLen); - cp_in_rpos = in_rpos; + in_rpos = cp_update_in_cache_pos(in_rpos, ph.packetLen); + cp_in_rpos = in_rpos; - frame_buf = &((LHDC_HEADER *)&lhdc_input_mid_buf[0])->dptr[0]; - frame_len = ph.packetLen; + frame_buf = &((LHDC_HEADER *)&lhdc_input_mid_buf[0])->dptr[0]; + frame_len = ph.packetLen; - ret = 0; + ret = 0; _exit: - if (p_data) { - *p_data = frame_buf; - } - if (p_len) { - *p_len = frame_len; - } + if (p_data) { + *p_data = frame_buf; + } + if (p_len) { + *p_len = frame_len; + } - return ret; + return ret; } #endif #if defined(A2DP_AAC_ON) TEXT_AAC_LOC -int cp_load_aac_frame(uint8_t **p_data, uint32_t *p_len) -{ - uint32_t len; - unsigned short aac_len = 0; - uint32_t in_rpos; - uint32_t in_wpos; +int cp_load_aac_frame(uint8_t **p_data, uint32_t *p_len) { + uint32_t len; + unsigned short aac_len = 0; + uint32_t in_rpos; + uint32_t in_wpos; - in_rpos = cp_in_rpos; - in_wpos = cp_in_wpos; + in_rpos = cp_in_rpos; + in_wpos = cp_in_wpos; - len = cp_get_in_cache_data_len(in_wpos, in_rpos); - if (len < 2) { - return 1; + len = cp_get_in_cache_data_len(in_wpos, in_rpos); + if (len < 2) { + return 1; + } + + if (in_wpos > in_rpos || cp_in_size >= in_rpos + 2) { + aac_len = cp_in_cache[in_rpos] | (cp_in_cache[in_rpos + 1] << 8); + } else { + aac_len = cp_in_cache[in_rpos] | (cp_in_cache[0] << 8); + } + in_rpos = cp_update_in_cache_pos(in_rpos, 2); + + if (aac_len < 64) { + aac_maxreadBytes = 64; + } else if (aac_len < 128) { + aac_maxreadBytes = 128; + } else if (aac_len < 256) { + aac_maxreadBytes = 256; + } else if (aac_len < 512) { + aac_maxreadBytes = 512; + } else if (aac_len < 1024) { + aac_maxreadBytes = 1024; + } else { + if (aac_len >= 2048) { + // Header is bad! + dec_reset_queue = true; + return 2; } + aac_maxreadBytes = 2048; + } - if (in_wpos > in_rpos || cp_in_size >= in_rpos + 2) { - aac_len = cp_in_cache[in_rpos] | (cp_in_cache[in_rpos + 1] << 8); - } else { - aac_len = cp_in_cache[in_rpos] | (cp_in_cache[0] << 8); - } - in_rpos = cp_update_in_cache_pos(in_rpos, 2); + if (len < 2 + (uint32_t)aac_len) { + return 3; + } - if (aac_len < 64) { - aac_maxreadBytes = 64; - } else if (aac_len < 128) { - aac_maxreadBytes = 128; - } else if (aac_len < 256) { - aac_maxreadBytes = 256; - } else if (aac_len < 512) { - aac_maxreadBytes = 512; - } else if (aac_len < 1024) { - aac_maxreadBytes = 1024; - } else { - if (aac_len >= 2048) { - // Header is bad! - dec_reset_queue = true; - return 2; - } - aac_maxreadBytes = 2048; - } + cp_dec_mtu_cnt[cp_dec_idx]++; - if (len < 2 + (uint32_t)aac_len) { - return 3; - } + cp_get_in_cache_data(&aac_input_mid_buf[0], aac_len, in_wpos, in_rpos); + // Consume the packet + in_rpos = cp_update_in_cache_pos(in_rpos, aac_len); + cp_in_rpos = in_rpos; - cp_dec_mtu_cnt[cp_dec_idx]++; + if (p_data) { + *p_data = (unsigned char *)aac_input_mid_buf; + } + if (p_len) { + *p_len = aac_maxreadBytes; + } - cp_get_in_cache_data(&aac_input_mid_buf[0], aac_len, in_wpos, in_rpos); - // Consume the packet - in_rpos = cp_update_in_cache_pos(in_rpos, aac_len); - cp_in_rpos = in_rpos; - - if (p_data) { - *p_data = (unsigned char *)aac_input_mid_buf; - } - if (p_len) { - *p_len = aac_maxreadBytes; - } - - return 0; + return 0; } #endif TEXT_SBC_LOC -int cp_load_sbc_frame(uint8_t **p_data, uint32_t *p_len) -{ - uint32_t len; - uint32_t in_wpos; - uint32_t in_rpos; +int cp_load_sbc_frame(uint8_t **p_data, uint32_t *p_len) { + uint32_t len; + uint32_t in_wpos; + uint32_t in_rpos; - if (!sbc_next_frame_size){ - sbc_next_frame_size = sbc_frame_size; - } + if (!sbc_next_frame_size) { + sbc_next_frame_size = sbc_frame_size; + } - if (need_init_decoder) { - sbc_next_frame_size = sbc_frame_size; - } + if (need_init_decoder) { + sbc_next_frame_size = sbc_frame_size; + } - in_wpos = cp_in_wpos; - in_rpos = cp_in_rpos; + in_wpos = cp_in_wpos; + in_rpos = cp_in_rpos; - if (in_wpos == in_rpos) { - return 1; - } + if (in_wpos == in_rpos) { + return 1; + } - if (in_wpos > in_rpos) { - len = in_wpos - in_rpos; - } else { - len = cp_in_size - in_rpos; - } + if (in_wpos > in_rpos) { + len = in_wpos - in_rpos; + } else { + len = cp_in_size - in_rpos; + } - if (len > sbc_next_frame_size) { - len = sbc_next_frame_size; - } + if (len > sbc_next_frame_size) { + len = sbc_next_frame_size; + } - if (p_data) { - *p_data = &cp_in_cache[in_rpos]; - } - if (p_len) { - *p_len = len; - } + if (p_data) { + *p_data = &cp_in_cache[in_rpos]; + } + if (p_len) { + *p_len = len; + } - return 0; + return 0; } TEXT_SBC_LOC -static int cp_consume_sbc_frame(const uint8_t *data, uint32_t len) -{ - cp_in_rpos = cp_update_in_cache_pos(cp_in_rpos, len); +static int cp_consume_sbc_frame(const uint8_t *data, uint32_t len) { + cp_in_rpos = cp_update_in_cache_pos(cp_in_rpos, len); - return 0; + return 0; } CP_TEXT_SRAM_LOC -static uint32_t cp_get_in_cache_data_len(uint32_t in_wpos, uint32_t in_rpos) -{ - uint32_t len; +static uint32_t cp_get_in_cache_data_len(uint32_t in_wpos, uint32_t in_rpos) { + uint32_t len; - if (in_wpos >= in_rpos) { - len = in_wpos - in_rpos; - } else { - len = cp_in_size - in_rpos + in_wpos; - } + if (in_wpos >= in_rpos) { + len = in_wpos - in_rpos; + } else { + len = cp_in_size - in_rpos + in_wpos; + } - return len; + return len; } CP_TEXT_SRAM_LOC -static void cp_get_in_cache_data(uint8_t *data, uint32_t len, uint32_t in_wpos, uint32_t in_rpos) -{ - // Assuming cp_get_in_cache_data_len(in_wpos, in_rpos) >= len +static void cp_get_in_cache_data(uint8_t *data, uint32_t len, uint32_t in_wpos, + uint32_t in_rpos) { + // Assuming cp_get_in_cache_data_len(in_wpos, in_rpos) >= len - if (in_wpos > in_rpos || cp_in_size >= in_rpos + len) { - memcpy(&data[0], &cp_in_cache[in_rpos], len); - } else { - uint32_t copy_len; + if (in_wpos > in_rpos || cp_in_size >= in_rpos + len) { + memcpy(&data[0], &cp_in_cache[in_rpos], len); + } else { + uint32_t copy_len; - copy_len = cp_in_size - in_rpos; - memcpy(&data[0], &cp_in_cache[in_rpos], copy_len); - memcpy(&data[copy_len], &cp_in_cache[0], len - copy_len); - } + copy_len = cp_in_size - in_rpos; + memcpy(&data[0], &cp_in_cache[in_rpos], copy_len); + memcpy(&data[copy_len], &cp_in_cache[0], len - copy_len); + } } CP_TEXT_SRAM_LOC -static uint32_t cp_update_in_cache_pos(uint32_t in_pos, uint32_t len) -{ - // Consume the packet - in_pos += len; - if (in_pos >= cp_in_size) { - in_pos -= cp_in_size; - } +static uint32_t cp_update_in_cache_pos(uint32_t in_pos, uint32_t len) { + // Consume the packet + in_pos += len; + if (in_pos >= cp_in_size) { + in_pos -= cp_in_size; + } - return in_pos; + return in_pos; } CP_TEXT_SRAM_LOC -static int cp_decode_a2dp_begin(enum APP_OVERLAY_ID_T overlay_type) -{ - cp_dec_start_time = hal_fast_sys_timer_get(); +static int cp_decode_a2dp_begin(enum APP_OVERLAY_ID_T overlay_type) { + cp_dec_start_time = hal_fast_sys_timer_get(); #ifndef A2DP_TRACE_CP_DEC_TIME - cp_dec_trace_time = false; + cp_dec_trace_time = false; #endif - if (cp_dec_state[cp_dec_idx] != CP_DEC_STATE_IDLE && cp_dec_state[cp_dec_idx] != CP_DEC_STATE_WORKING) { - return 1; - } + if (cp_dec_state[cp_dec_idx] != CP_DEC_STATE_IDLE && + cp_dec_state[cp_dec_idx] != CP_DEC_STATE_WORKING) { + return 1; + } - if (cp_dec_state[cp_dec_idx] == CP_DEC_STATE_IDLE) { - cp_dec_state[cp_dec_idx] = CP_DEC_STATE_WORKING; - cp_out_len[cp_dec_idx] = 0; - cp_dec_mtu_cnt[cp_dec_idx] = 0; - } + if (cp_dec_state[cp_dec_idx] == CP_DEC_STATE_IDLE) { + cp_dec_state[cp_dec_idx] = CP_DEC_STATE_WORKING; + cp_out_len[cp_dec_idx] = 0; + cp_dec_mtu_cnt[cp_dec_idx] = 0; + } - return 0; + return 0; } CP_TEXT_SRAM_LOC -static int cp_load_a2dp_encoded_data(enum APP_OVERLAY_ID_T overlay_type, uint8_t **p_data, uint32_t *p_len) -{ - int ret = -1; +static int cp_load_a2dp_encoded_data(enum APP_OVERLAY_ID_T overlay_type, + uint8_t **p_data, uint32_t *p_len) { + int ret = -1; - if (0) { + if (0) { #if defined(A2DP_LDAC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { - ret = cp_load_ldac_frame(p_data, p_len); + } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { + ret = cp_load_ldac_frame(p_data, p_len); #endif #if defined(A2DP_LHDC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_LHDC) { - ret = cp_load_lhdc_frame(p_data, p_len); + } else if (overlay_type == APP_OVERLAY_A2DP_LHDC) { + ret = cp_load_lhdc_frame(p_data, p_len); #endif #if defined(A2DP_AAC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_AAC) { - ret = cp_load_aac_frame(p_data, p_len); + } else if (overlay_type == APP_OVERLAY_A2DP_AAC) { + ret = cp_load_aac_frame(p_data, p_len); #endif - } else if (overlay_type == APP_OVERLAY_A2DP) { - ret = cp_load_sbc_frame(p_data, p_len); - } + } else if (overlay_type == APP_OVERLAY_A2DP) { + ret = cp_load_sbc_frame(p_data, p_len); + } - return ret; + return ret; } CP_TEXT_SRAM_LOC -static int cp_decode_a2dp_process(enum APP_OVERLAY_ID_T overlay_type, uint8_t *out, uint32_t out_max, uint32_t *p_out_len, - const uint8_t *in, uint32_t in_len, uint32_t *p_consume_len) -{ - int ret = -1; +static int cp_decode_a2dp_process(enum APP_OVERLAY_ID_T overlay_type, + uint8_t *out, uint32_t out_max, + uint32_t *p_out_len, const uint8_t *in, + uint32_t in_len, uint32_t *p_consume_len) { + int ret = -1; - if (p_out_len) { - *p_out_len = 0; - } - if (p_consume_len) { - *p_consume_len = 0; - } + if (p_out_len) { + *p_out_len = 0; + } + if (p_consume_len) { + *p_consume_len = 0; + } - if (0) { + if (0) { #if defined(A2DP_LDAC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { - ret = decode_ldac_frame(out, out_max, p_out_len, in, in_len, p_consume_len); + } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { + ret = decode_ldac_frame(out, out_max, p_out_len, in, in_len, p_consume_len); #endif #if defined(A2DP_AAC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_AAC) { - ret = decode_aac_frame(out, out_max, p_out_len, in, in_len, p_consume_len); + } else if (overlay_type == APP_OVERLAY_A2DP_AAC) { + ret = decode_aac_frame(out, out_max, p_out_len, in, in_len, p_consume_len); #endif #if defined(A2DP_SCALABLE_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_SCALABLE) { - ret = decode_scalable_frame(out, out_max, p_out_len, in, in_len, p_consume_len); + } else if (overlay_type == APP_OVERLAY_A2DP_SCALABLE) { + ret = decode_scalable_frame(out, out_max, p_out_len, in, in_len, + p_consume_len); #endif #if defined(A2DP_LHDC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_LHDC) { - ret = decode_lhdc_frame(out, out_max, p_out_len, in, in_len, p_consume_len); + } else if (overlay_type == APP_OVERLAY_A2DP_LHDC) { + ret = decode_lhdc_frame(out, out_max, p_out_len, in, in_len, p_consume_len); #endif - } else if (overlay_type == APP_OVERLAY_A2DP) { - ret = decode_sbc_frame(out, out_max, p_out_len, in, in_len, p_consume_len); - } + } else if (overlay_type == APP_OVERLAY_A2DP) { + ret = decode_sbc_frame(out, out_max, p_out_len, in, in_len, p_consume_len); + } - return ret; + return ret; } CP_TEXT_SRAM_LOC -static int cp_consume_a2dp_encoded_data(enum APP_OVERLAY_ID_T overlay_type, const uint8_t *data, uint32_t len) -{ - if (0) { +static int cp_consume_a2dp_encoded_data(enum APP_OVERLAY_ID_T overlay_type, + const uint8_t *data, uint32_t len) { + if (0) { #if defined(A2DP_LDAC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { - cp_consume_ldac_frame(data, len); + } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { + cp_consume_ldac_frame(data, len); #endif - } else if (overlay_type == APP_OVERLAY_A2DP) { - cp_consume_sbc_frame(data, len); - } + } else if (overlay_type == APP_OVERLAY_A2DP) { + cp_consume_sbc_frame(data, len); + } - return 0; + return 0; } CP_TEXT_SRAM_LOC -static void cp_decode_a2dp_end(enum APP_OVERLAY_ID_T overlay_type, uint32_t expect_out_len, uint32_t out_len, uint32_t in_len, bool retry) -{ - uint32_t etime; - uint8_t old_cp_dec_idx; +static void cp_decode_a2dp_end(enum APP_OVERLAY_ID_T overlay_type, + uint32_t expect_out_len, uint32_t out_len, + uint32_t in_len, bool retry) { + uint32_t etime; + uint8_t old_cp_dec_idx; - if (0) { + if (0) { #if defined(A2DP_LDAC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { - cp_decode_ldac_end(expect_out_len, out_len, in_len); + } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { + cp_decode_ldac_end(expect_out_len, out_len, in_len); #endif + } + + old_cp_dec_idx = cp_dec_idx; + + cp_out_len[cp_dec_idx] += out_len; + + if (!retry) { + if (expect_out_len == out_len) { + cp_dec_state[cp_dec_idx] = CP_DEC_STATE_DONE; + } else { + cp_dec_state[cp_dec_idx] = CP_DEC_STATE_FAILED; } - old_cp_dec_idx = cp_dec_idx; - - cp_out_len[cp_dec_idx] += out_len; - - if (!retry) { - if (expect_out_len == out_len) { - cp_dec_state[cp_dec_idx] = CP_DEC_STATE_DONE; - } else { - cp_dec_state[cp_dec_idx] = CP_DEC_STATE_FAILED; - } - - cp_dec_idx++; - if (cp_dec_idx >= CP_DEC_SLOT_CNT) { - cp_dec_idx = 0; - } + cp_dec_idx++; + if (cp_dec_idx >= CP_DEC_SLOT_CNT) { + cp_dec_idx = 0; } + } - etime = hal_fast_sys_timer_get(); - if (cp_dec_trace_time) { - TRACE(4,"cp_decode[%u]: %u us in %u us (r=%u)", old_cp_dec_idx, FAST_TICKS_TO_US(etime - cp_dec_start_time), FAST_TICKS_TO_US(etime - cp_last_dec_time), retry); - } + etime = hal_fast_sys_timer_get(); + if (cp_dec_trace_time) { + TRACE(4, "cp_decode[%u]: %u us in %u us (r=%u)", old_cp_dec_idx, + FAST_TICKS_TO_US(etime - cp_dec_start_time), + FAST_TICKS_TO_US(etime - cp_last_dec_time), retry); + } #ifdef A2DP_TRACE_CP_ACCEL - if (retry) { - TRACE(3,"cp_decode[%u]:retry: cp_out_len=%u out_len=%u", old_cp_dec_idx, cp_out_len[old_cp_dec_idx], out_len); - } + if (retry) { + TRACE(3, "cp_decode[%u]:retry: cp_out_len=%u out_len=%u", old_cp_dec_idx, + cp_out_len[old_cp_dec_idx], out_len); + } #endif - cp_last_dec_time = etime; + cp_last_dec_time = etime; } CP_TEXT_SRAM_LOC -static int cp_decode_a2dp_frame(enum APP_OVERLAY_ID_T overlay_type, unsigned char *pcm_buffer, unsigned int pcm_len) -{ - uint32_t all_out_len = 0, all_in_len = 0; - int ret, ret2; - uint32_t out_len; - uint8_t *enc_data; - uint32_t enc_len; - uint32_t consume_len; - bool retry = false; +static int cp_decode_a2dp_frame(enum APP_OVERLAY_ID_T overlay_type, + unsigned char *pcm_buffer, + unsigned int pcm_len) { + uint32_t all_out_len = 0, all_in_len = 0; + int ret, ret2; + uint32_t out_len; + uint8_t *enc_data; + uint32_t enc_len; + uint32_t consume_len; + bool retry = false; - ret = cp_decode_a2dp_begin(overlay_type); + ret = cp_decode_a2dp_begin(overlay_type); + if (ret) { + return 0; + } + + while (all_out_len < pcm_len) { + ret = cp_load_a2dp_encoded_data(overlay_type, &enc_data, &enc_len); if (ret) { - return 0; + retry = true; + break; } - while (all_out_len < pcm_len) { - ret = cp_load_a2dp_encoded_data(overlay_type, &enc_data, &enc_len); - if (ret) { - retry = true; - break; - } + ret = cp_decode_a2dp_process(overlay_type, &pcm_buffer[all_out_len], + pcm_len - all_out_len, &out_len, enc_data, + enc_len, &consume_len); - ret = cp_decode_a2dp_process(overlay_type, &pcm_buffer[all_out_len], pcm_len - all_out_len, &out_len, enc_data, enc_len, &consume_len); + ret2 = cp_consume_a2dp_encoded_data(overlay_type, enc_data, consume_len); - ret2 = cp_consume_a2dp_encoded_data(overlay_type, enc_data, consume_len); + all_out_len += out_len; - all_out_len += out_len; - - if (ret || ret2) { - break; - } + if (ret || ret2) { + break; } + } - cp_decode_a2dp_end(overlay_type, pcm_len, all_out_len, all_in_len, retry); + cp_decode_a2dp_end(overlay_type, pcm_len, all_out_len, all_in_len, retry); - return all_out_len; + return all_out_len; } CP_TEXT_SRAM_LOC -unsigned int cp_a2dp_main(uint8_t event) -{ - uint32_t out_wpos; - uint32_t out_len; - uint32_t pcm_len; +unsigned int cp_a2dp_main(uint8_t event) { + uint32_t out_wpos; + uint32_t out_len; + uint32_t pcm_len; - do { - if (cp_dec_state[cp_dec_idx] == CP_DEC_STATE_WORKING) { - if (cp_out_len[cp_dec_idx] < cp_out_loop_size) { - pcm_len = cp_out_loop_size - cp_out_len[cp_dec_idx]; - } else { - cp_out_len[cp_dec_idx] = 0; - pcm_len = cp_out_loop_size; - } - } else { - pcm_len = cp_out_loop_size; - } - out_wpos = cp_out_loop_size * cp_dec_idx + cp_out_loop_size - pcm_len; + do { + if (cp_dec_state[cp_dec_idx] == CP_DEC_STATE_WORKING) { + if (cp_out_len[cp_dec_idx] < cp_out_loop_size) { + pcm_len = cp_out_loop_size - cp_out_len[cp_dec_idx]; + } else { + cp_out_len[cp_dec_idx] = 0; + pcm_len = cp_out_loop_size; + } + } else { + pcm_len = cp_out_loop_size; + } + out_wpos = cp_out_loop_size * cp_dec_idx + cp_out_loop_size - pcm_len; - out_len = cp_decode_a2dp_frame(cp_overlay_type, &cp_out_cache[out_wpos], cp_out_loop_size); - } while (out_len == pcm_len); + out_len = cp_decode_a2dp_frame(cp_overlay_type, &cp_out_cache[out_wpos], + cp_out_loop_size); + } while (out_len == pcm_len); - return 0; + return 0; } FRAM_TEXT_LOC -static void mcu_decode_a2dp_init(uint32_t out_max) -{ - uint32_t i; +static void mcu_decode_a2dp_init(uint32_t out_max) { + uint32_t i; - if (mcu_dec_inited == false) { - mcu_dec_inited = true; + if (mcu_dec_inited == false) { + mcu_dec_inited = true; - cp_in_size = sizeof(cp_in_cache); - cp_out_size = out_max * CP_DEC_SLOT_CNT; - ASSERT(cp_out_size <= sizeof(cp_out_cache), "%s: cp_out_cache too small (should >= %u)", __func__, cp_out_size); - cp_out_loop_size = out_max; + cp_in_size = sizeof(cp_in_cache); + cp_out_size = out_max * CP_DEC_SLOT_CNT; + ASSERT(cp_out_size <= sizeof(cp_out_cache), + "%s: cp_out_cache too small (should >= %u)", __func__, cp_out_size); + cp_out_loop_size = out_max; - cp_overlay_type = app_get_current_overlay(); + cp_overlay_type = app_get_current_overlay(); - for (i = 0; i < CP_DEC_SLOT_CNT; i++) { - cp_dec_state[i] = CP_DEC_STATE_IDLE; - cp_dec_mtu_cnt[i] = 0; - cp_out_len[i] = 0; - } + for (i = 0; i < CP_DEC_SLOT_CNT; i++) { + cp_dec_state[i] = CP_DEC_STATE_IDLE; + cp_dec_mtu_cnt[i] = 0; + cp_out_len[i] = 0; + } #if defined(A2DP_LHDC_ON) - // Increase latency to improve data buffering - mcu_dec_idx = 1; + // Increase latency to improve data buffering + mcu_dec_idx = 1; #else - mcu_dec_idx = CP_DEC_SLOT_CNT - 1; + mcu_dec_idx = CP_DEC_SLOT_CNT - 1; #endif - for (i = mcu_dec_idx; i < CP_DEC_SLOT_CNT; i++) { - cp_dec_state[i] = CP_DEC_STATE_DONE; - cp_out_len[i] = cp_out_loop_size; - } + for (i = mcu_dec_idx; i < CP_DEC_SLOT_CNT; i++) { + cp_dec_state[i] = CP_DEC_STATE_DONE; + cp_out_len[i] = cp_out_loop_size; } + } } FRAM_TEXT_LOC -static int mcu_load_a2dp_encoded_data(uint8_t **p_data, uint32_t *p_len) -{ - uint32_t free_len; - uint32_t in_wpos, in_rpos; - uint32_t size; - int r = 0; - unsigned char *e1 = NULL, *e2 = NULL; - unsigned int len1 = 0, len2 = 0; +static int mcu_load_a2dp_encoded_data(uint8_t **p_data, uint32_t *p_len) { + uint32_t free_len; + uint32_t in_wpos, in_rpos; + uint32_t size; + int r = 0; + unsigned char *e1 = NULL, *e2 = NULL; + unsigned int len1 = 0, len2 = 0; - in_wpos = cp_in_wpos; - in_rpos = cp_in_rpos; + in_wpos = cp_in_wpos; + in_rpos = cp_in_rpos; - if (in_wpos < in_rpos) { - free_len = in_rpos - in_wpos - 1; - } else { - free_len = cp_in_size - in_wpos + in_rpos - 1; - } - - if (free_len == 0) { - return 0; - } - - LOCK_APP_AUDIO_QUEUE(); - size = LengthOfCQueue(&sbc_queue); - UNLOCK_APP_AUDIO_QUEUE(); - - if (size > free_len) { - size = free_len; - } - - LOCK_APP_AUDIO_QUEUE(); - r = PeekCQueue(&sbc_queue, size, &e1, &len1, &e2, &len2); - UNLOCK_APP_AUDIO_QUEUE(); - - if (r == CQ_ERR) { - TRACE(2,"%s: Failed to get %u from sbc_queue", __func__, size); - return 1; - } - - if (in_wpos < in_rpos) { - if (len1) { - memcpy(&cp_in_cache[in_wpos], e1, len1); - in_wpos += len1; - } - if (len2) { - memcpy(&cp_in_cache[in_wpos], e2, len2); - in_wpos += len2; - } - } else { - free_len = cp_in_size - in_wpos; - if (len1) { - if (free_len > len1) { - free_len = len1; - } - memcpy(&cp_in_cache[in_wpos], e1, free_len); - len1 -= free_len; - e1 += free_len; - in_wpos = cp_update_in_cache_pos(in_wpos, free_len); - if (len1) { - memcpy(&cp_in_cache[in_wpos], e1, len1); - in_wpos = cp_update_in_cache_pos(in_wpos, len1); - } - if (in_wpos < in_rpos) { - free_len = in_rpos - in_wpos - 1; - } else { - free_len = cp_in_size - in_wpos; - } - } - if (len2) { - if (free_len > len2) { - free_len = len2; - } - memcpy(&cp_in_cache[in_wpos], e2, free_len); - len2 -= free_len; - e2 += free_len; - in_wpos = cp_update_in_cache_pos(in_wpos, free_len); - if (len2) { - memcpy(&cp_in_cache[in_wpos], e2, len2); - in_wpos = cp_update_in_cache_pos(in_wpos, len2); - } - } - } - - cp_in_wpos = in_wpos; - - LOCK_APP_AUDIO_QUEUE(); - DeCQueue(&sbc_queue, NULL, size); - UNLOCK_APP_AUDIO_QUEUE(); + if (in_wpos < in_rpos) { + free_len = in_rpos - in_wpos - 1; + } else { + free_len = cp_in_size - in_wpos + in_rpos - 1; + } + if (free_len == 0) { return 0; + } + + LOCK_APP_AUDIO_QUEUE(); + size = LengthOfCQueue(&sbc_queue); + UNLOCK_APP_AUDIO_QUEUE(); + + if (size > free_len) { + size = free_len; + } + + LOCK_APP_AUDIO_QUEUE(); + r = PeekCQueue(&sbc_queue, size, &e1, &len1, &e2, &len2); + UNLOCK_APP_AUDIO_QUEUE(); + + if (r == CQ_ERR) { + TRACE(2, "%s: Failed to get %u from sbc_queue", __func__, size); + return 1; + } + + if (in_wpos < in_rpos) { + if (len1) { + memcpy(&cp_in_cache[in_wpos], e1, len1); + in_wpos += len1; + } + if (len2) { + memcpy(&cp_in_cache[in_wpos], e2, len2); + in_wpos += len2; + } + } else { + free_len = cp_in_size - in_wpos; + if (len1) { + if (free_len > len1) { + free_len = len1; + } + memcpy(&cp_in_cache[in_wpos], e1, free_len); + len1 -= free_len; + e1 += free_len; + in_wpos = cp_update_in_cache_pos(in_wpos, free_len); + if (len1) { + memcpy(&cp_in_cache[in_wpos], e1, len1); + in_wpos = cp_update_in_cache_pos(in_wpos, len1); + } + if (in_wpos < in_rpos) { + free_len = in_rpos - in_wpos - 1; + } else { + free_len = cp_in_size - in_wpos; + } + } + if (len2) { + if (free_len > len2) { + free_len = len2; + } + memcpy(&cp_in_cache[in_wpos], e2, free_len); + len2 -= free_len; + e2 += free_len; + in_wpos = cp_update_in_cache_pos(in_wpos, free_len); + if (len2) { + memcpy(&cp_in_cache[in_wpos], e2, len2); + in_wpos = cp_update_in_cache_pos(in_wpos, len2); + } + } + } + + cp_in_wpos = in_wpos; + + LOCK_APP_AUDIO_QUEUE(); + DeCQueue(&sbc_queue, NULL, size); + UNLOCK_APP_AUDIO_QUEUE(); + + return 0; } FRAM_TEXT_LOC -static int mcu_decode_a2dp_process(uint8_t *out, uint32_t out_max, uint32_t *p_out_len, - const uint8_t *in, uint32_t in_len, uint32_t *p_consume_len) -{ - int ret = 0; - uint32_t out_rpos; +static int mcu_decode_a2dp_process(uint8_t *out, uint32_t out_max, + uint32_t *p_out_len, const uint8_t *in, + uint32_t in_len, uint32_t *p_consume_len) { + int ret = 0; + uint32_t out_rpos; #ifdef A2DP_TRACE_CP_ACCEL - TRACE(3,"mcu_dec_proc[%u]: state=%u len=%u", mcu_dec_idx, cp_dec_state[mcu_dec_idx], cp_out_len[mcu_dec_idx]); + TRACE(3, "mcu_dec_proc[%u]: state=%u len=%u", mcu_dec_idx, + cp_dec_state[mcu_dec_idx], cp_out_len[mcu_dec_idx]); #endif - cp_accel_send_event_mcu2cp(CP_BUILD_ID(CP_TASK_A2DP_DECODE, CP_EVENT_A2DP_DECODE)); + cp_accel_send_event_mcu2cp( + CP_BUILD_ID(CP_TASK_A2DP_DECODE, CP_EVENT_A2DP_DECODE)); - if (cp_dec_state[mcu_dec_idx] != CP_DEC_STATE_DONE) { - ret = 1; - goto _exit; - } - if (cp_out_len[mcu_dec_idx] != out_max) { - ret = 2; - goto _exit; - } + if (cp_dec_state[mcu_dec_idx] != CP_DEC_STATE_DONE) { + ret = 1; + goto _exit; + } + if (cp_out_len[mcu_dec_idx] != out_max) { + ret = 2; + goto _exit; + } - out_rpos = cp_out_loop_size * mcu_dec_idx; + out_rpos = cp_out_loop_size * mcu_dec_idx; - memcpy(out, &cp_out_cache[out_rpos], out_max); + memcpy(out, &cp_out_cache[out_rpos], out_max); - if (p_out_len) { - *p_out_len = out_max; - } + if (p_out_len) { + *p_out_len = out_max; + } _exit: - if (cp_dec_state[mcu_dec_idx] == CP_DEC_STATE_DONE || cp_dec_state[mcu_dec_idx] == CP_DEC_STATE_FAILED) { - if (mtu_count > cp_dec_mtu_cnt[mcu_dec_idx]) { - mtu_count -= cp_dec_mtu_cnt[mcu_dec_idx]; - } else { - mtu_count = 0; - } - - cp_dec_state[mcu_dec_idx] = CP_DEC_STATE_IDLE; - - mcu_dec_idx++; - if (mcu_dec_idx >= CP_DEC_SLOT_CNT) { - mcu_dec_idx = 0; - } + if (cp_dec_state[mcu_dec_idx] == CP_DEC_STATE_DONE || + cp_dec_state[mcu_dec_idx] == CP_DEC_STATE_FAILED) { + if (mtu_count > cp_dec_mtu_cnt[mcu_dec_idx]) { + mtu_count -= cp_dec_mtu_cnt[mcu_dec_idx]; + } else { + mtu_count = 0; } - return ret; -} + cp_dec_state[mcu_dec_idx] = CP_DEC_STATE_IDLE; -static struct cp_task_desc TASK_DESC_A2DP = {CP_ACCEL_STATE_CLOSED, cp_a2dp_main, NULL, NULL, NULL}; -void cp_a2dp_init(void) -{ - mcu_dec_inited = false; - norflash_api_flush_disable(NORFLASH_API_USER_CP,(uint32_t)cp_accel_init_done); - cp_accel_open(CP_TASK_A2DP_DECODE, &TASK_DESC_A2DP); - while(cp_accel_init_done() == false) { - hal_sys_timer_delay_us(100); + mcu_dec_idx++; + if (mcu_dec_idx >= CP_DEC_SLOT_CNT) { + mcu_dec_idx = 0; } - norflash_api_flush_enable(NORFLASH_API_USER_CP); + } + + return ret; } -void cp_a2dp_deinit(void) -{ - cp_accel_close(CP_TASK_A2DP_DECODE); +static struct cp_task_desc TASK_DESC_A2DP = {CP_ACCEL_STATE_CLOSED, + cp_a2dp_main, NULL, NULL, NULL}; +void cp_a2dp_init(void) { + mcu_dec_inited = false; + norflash_api_flush_disable(NORFLASH_API_USER_CP, + (uint32_t)cp_accel_init_done); + cp_accel_open(CP_TASK_A2DP_DECODE, &TASK_DESC_A2DP); + while (cp_accel_init_done() == false) { + hal_sys_timer_delay_us(100); + } + norflash_api_flush_enable(NORFLASH_API_USER_CP); } + +void cp_a2dp_deinit(void) { cp_accel_close(CP_TASK_A2DP_DECODE); } #endif FRAM_TEXT_LOC -static int decode_a2dp_begin(enum APP_OVERLAY_ID_T overlay_type) -{ +static int decode_a2dp_begin(enum APP_OVERLAY_ID_T overlay_type) { #ifdef TIMER1_BASE - dec_start_time = hal_fast_sys_timer_get(); + dec_start_time = hal_fast_sys_timer_get(); #else - dec_start_time = hal_sys_timer_get(); + dec_start_time = hal_sys_timer_get(); #endif #ifndef A2DP_TRACE_DEC_TIME - dec_trace_time = false; + dec_trace_time = false; #endif #ifndef A2DP_CP_ACCEL - if (overlay_type == APP_OVERLAY_A2DP) { - decode_sbc_begin(); - } + if (overlay_type == APP_OVERLAY_A2DP) { + decode_sbc_begin(); + } #endif - return 0; + return 0; } FRAM_TEXT_LOC -static int load_a2dp_encoded_data(enum APP_OVERLAY_ID_T overlay_type, uint8_t **p_data, uint32_t *p_len) -{ - int ret = -1; +static int load_a2dp_encoded_data(enum APP_OVERLAY_ID_T overlay_type, + uint8_t **p_data, uint32_t *p_len) { + int ret = -1; #ifdef A2DP_CP_ACCEL - ret = mcu_load_a2dp_encoded_data(p_data, p_len); + ret = mcu_load_a2dp_encoded_data(p_data, p_len); #else - if (0) { + if (0) { #if defined(A2DP_LDAC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { - ret = load_ldac_frame(p_data, p_len); + } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { + ret = load_ldac_frame(p_data, p_len); #endif #if defined(A2DP_AAC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_AAC) { - ret = load_aac_frame(p_data, p_len); + } else if (overlay_type == APP_OVERLAY_A2DP_AAC) { + ret = load_aac_frame(p_data, p_len); #endif #if defined(A2DP_SCALABLE_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_SCALABLE) { - ret = load_scalable_frame(p_data, p_len); + } else if (overlay_type == APP_OVERLAY_A2DP_SCALABLE) { + ret = load_scalable_frame(p_data, p_len); #endif #if defined(A2DP_LHDC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_LHDC) { - ret = load_lhdc_frame(p_data, p_len); + } else if (overlay_type == APP_OVERLAY_A2DP_LHDC) { + ret = load_lhdc_frame(p_data, p_len); #endif - } else if (overlay_type == APP_OVERLAY_A2DP) { - ret = load_sbc_frame(p_data, p_len); - } + } else if (overlay_type == APP_OVERLAY_A2DP) { + ret = load_sbc_frame(p_data, p_len); + } #endif - return ret; + return ret; } FRAM_TEXT_LOC -static int decode_a2dp_process(enum APP_OVERLAY_ID_T overlay_type, uint8_t *out, uint32_t out_max, uint32_t *p_out_len, - const uint8_t *in, uint32_t in_len, uint32_t *p_consume_len) -{ - int ret = -1; +static int decode_a2dp_process(enum APP_OVERLAY_ID_T overlay_type, uint8_t *out, + uint32_t out_max, uint32_t *p_out_len, + const uint8_t *in, uint32_t in_len, + uint32_t *p_consume_len) { + int ret = -1; - if (p_out_len) { - *p_out_len = 0; - } - if (p_consume_len) { - *p_consume_len = 0; - } + if (p_out_len) { + *p_out_len = 0; + } + if (p_consume_len) { + *p_consume_len = 0; + } #ifdef A2DP_CP_ACCEL - ret = mcu_decode_a2dp_process(out, out_max, p_out_len, in, in_len, p_consume_len); + ret = mcu_decode_a2dp_process(out, out_max, p_out_len, in, in_len, + p_consume_len); #else - if (0) { + if (0) { #if defined(A2DP_LDAC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { - ret = decode_ldac_frame(out, out_max, p_out_len, in, in_len, p_consume_len); + } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { + ret = decode_ldac_frame(out, out_max, p_out_len, in, in_len, p_consume_len); #endif #if defined(A2DP_AAC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_AAC) { - ret = decode_aac_frame(out, out_max, p_out_len, in, in_len, p_consume_len); + } else if (overlay_type == APP_OVERLAY_A2DP_AAC) { + ret = decode_aac_frame(out, out_max, p_out_len, in, in_len, p_consume_len); #endif #if defined(A2DP_SCALABLE_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_SCALABLE) { - ret = decode_scalable_frame(out, out_max, p_out_len, in, in_len, p_consume_len); + } else if (overlay_type == APP_OVERLAY_A2DP_SCALABLE) { + ret = decode_scalable_frame(out, out_max, p_out_len, in, in_len, + p_consume_len); #endif #if defined(A2DP_LHDC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_LHDC) { - ret = decode_lhdc_frame(out, out_max, p_out_len, in, in_len, p_consume_len); + } else if (overlay_type == APP_OVERLAY_A2DP_LHDC) { + ret = decode_lhdc_frame(out, out_max, p_out_len, in, in_len, p_consume_len); #endif - } else if (overlay_type == APP_OVERLAY_A2DP) { - ret = decode_sbc_frame(out, out_max, p_out_len, in, in_len, p_consume_len); - } + } else if (overlay_type == APP_OVERLAY_A2DP) { + ret = decode_sbc_frame(out, out_max, p_out_len, in, in_len, p_consume_len); + } #endif - return ret; + return ret; } FRAM_TEXT_LOC -static int consume_a2dp_encoded_data(enum APP_OVERLAY_ID_T overlay_type, const uint8_t *data, uint32_t len) -{ +static int consume_a2dp_encoded_data(enum APP_OVERLAY_ID_T overlay_type, + const uint8_t *data, uint32_t len) { #ifndef A2DP_CP_ACCEL - if (0) { + if (0) { #if defined(A2DP_LDAC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { - consume_ldac_frame(data, len); + } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { + consume_ldac_frame(data, len); #endif - } else if (overlay_type == APP_OVERLAY_A2DP) { - consume_sbc_frame(data, len); - } + } else if (overlay_type == APP_OVERLAY_A2DP) { + consume_sbc_frame(data, len); + } #endif - return 0; + return 0; } FRAM_TEXT_LOC -static void decode_a2dp_end(enum APP_OVERLAY_ID_T overlay_type, uint32_t expect_out_len, uint32_t out_len, uint32_t in_len) -{ - uint32_t etime; +static void decode_a2dp_end(enum APP_OVERLAY_ID_T overlay_type, + uint32_t expect_out_len, uint32_t out_len, + uint32_t in_len) { + uint32_t etime; #ifdef A2DP_CP_ACCEL - if (0) { + if (0) { #if defined(A2DP_LDAC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { - mcu_decode_ldac_end(expect_out_len, out_len, in_len); + } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { + mcu_decode_ldac_end(expect_out_len, out_len, in_len); #endif - } + } #else - if (0) { + if (0) { #if defined(A2DP_LDAC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { - decode_ldac_end(expect_out_len, out_len, in_len); + } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { + decode_ldac_end(expect_out_len, out_len, in_len); #endif #if defined(A2DP_LHDC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_LHDC) { - decode_lhdc_end(expect_out_len, out_len, in_len); + } else if (overlay_type == APP_OVERLAY_A2DP_LHDC) { + decode_lhdc_end(expect_out_len, out_len, in_len); #endif - } else if (overlay_type == APP_OVERLAY_A2DP) { - decode_sbc_end(expect_out_len, out_len, in_len); - } + } else if (overlay_type == APP_OVERLAY_A2DP) { + decode_sbc_end(expect_out_len, out_len, in_len); + } #endif - if (dec_reset_queue) { - dec_reset_queue = false; - LOCK_APP_AUDIO_QUEUE(); - ResetCQueue(&sbc_queue); - TRACE(0,"Reset queue"); - UNLOCK_APP_AUDIO_QUEUE(); - } + if (dec_reset_queue) { + dec_reset_queue = false; + LOCK_APP_AUDIO_QUEUE(); + ResetCQueue(&sbc_queue); + TRACE(0, "Reset queue"); + UNLOCK_APP_AUDIO_QUEUE(); + } #ifdef TIMER1_BASE - etime = hal_fast_sys_timer_get(); - if (dec_trace_time) { - TRACE(2,"a2dp decode: %u us in %u us", FAST_TICKS_TO_US(etime - dec_start_time), FAST_TICKS_TO_US(etime - last_dec_time)); - } + etime = hal_fast_sys_timer_get(); + if (dec_trace_time) { + TRACE(2, "a2dp decode: %u us in %u us", + FAST_TICKS_TO_US(etime - dec_start_time), + FAST_TICKS_TO_US(etime - last_dec_time)); + } #else - etime = hal_sys_timer_get(); - if (dec_trace_time) { - TRACE(2,"a2dp decode: %u ms in %u ms", TICKS_TO_MS(etime - dec_start_time), TICKS_TO_MS(etime - last_dec_time)); - } + etime = hal_sys_timer_get(); + if (dec_trace_time) { + TRACE(2, "a2dp decode: %u ms in %u ms", TICKS_TO_MS(etime - dec_start_time), + TICKS_TO_MS(etime - last_dec_time)); + } #endif - last_dec_time = etime; + last_dec_time = etime; } FRAM_TEXT_LOC -static int decode_a2dp_frame(enum APP_OVERLAY_ID_T overlay_type, unsigned char *pcm_buffer, unsigned int pcm_len) -{ - uint32_t all_out_len = 0, all_in_len = 0; - int ret, ret2; - uint32_t out_len; - uint8_t *enc_data; - uint32_t enc_len; - uint32_t consume_len; +static int decode_a2dp_frame(enum APP_OVERLAY_ID_T overlay_type, + unsigned char *pcm_buffer, unsigned int pcm_len) { + uint32_t all_out_len = 0, all_in_len = 0; + int ret, ret2; + uint32_t out_len; + uint8_t *enc_data; + uint32_t enc_len; + uint32_t consume_len; #ifdef A2DP_CP_ACCEL - mcu_decode_a2dp_init(pcm_len); + mcu_decode_a2dp_init(pcm_len); #endif - ret = decode_a2dp_begin(overlay_type); + ret = decode_a2dp_begin(overlay_type); + if (ret) { + return 0; + } + + while (all_out_len < pcm_len) { + ret = load_a2dp_encoded_data(overlay_type, &enc_data, &enc_len); if (ret) { - return 0; + break; } - while (all_out_len < pcm_len) { - ret = load_a2dp_encoded_data(overlay_type, &enc_data, &enc_len); - if (ret) { - break; - } + ret = decode_a2dp_process(overlay_type, pcm_buffer + all_out_len, + pcm_len - all_out_len, &out_len, enc_data, + enc_len, &consume_len); - ret = decode_a2dp_process(overlay_type, pcm_buffer + all_out_len, pcm_len - all_out_len, &out_len, enc_data, enc_len, &consume_len); + ret2 = consume_a2dp_encoded_data(overlay_type, enc_data, consume_len); - ret2 = consume_a2dp_encoded_data(overlay_type, enc_data, consume_len); + all_out_len += out_len; + all_in_len += consume_len; - all_out_len += out_len; - all_in_len += consume_len; - - if (ret || ret2) { - break; - } + if (ret || ret2) { + break; } + } - decode_a2dp_end(overlay_type, pcm_len, all_out_len, all_in_len); + decode_a2dp_end(overlay_type, pcm_len, all_out_len, all_in_len); - return all_out_len; + return all_out_len; } #if defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE) -#define AAC_RESAMPLE_ITER_LEN (1024 * 2 * 2) -#define SBC_RESAMPLE_ITER_LEN (128 * 2 * 2) +#define AAC_RESAMPLE_ITER_LEN (1024 * 2 * 2) +#define SBC_RESAMPLE_ITER_LEN (128 * 2 * 2) static struct APP_RESAMPLE_T *a2dp_resample; FRAM_TEXT_LOC -static int a2dp_resample_iter(uint8_t *buf, uint32_t len) -{ - enum APP_OVERLAY_ID_T overlay_type; +static int a2dp_resample_iter(uint8_t *buf, uint32_t len) { + enum APP_OVERLAY_ID_T overlay_type; - overlay_type = app_get_current_overlay(); + overlay_type = app_get_current_overlay(); - uint32_t l = decode_a2dp_frame(overlay_type, buf, len); - if (l != len) { - TRACE(2,"a2dp_audio_more_data decode err %d/%d", l, len); - return 1; - } - return 0; + uint32_t l = decode_a2dp_frame(overlay_type, buf, len); + if (l != len) { + TRACE(2, "a2dp_audio_more_data decode err %d/%d", l, len); + return 1; + } + return 0; } #endif extern bool process_delay(int32_t delay_ms); -void static attempt_slow_samplerate(uint8_t overlay_type) -{ - uint32_t current_mtu_conut =0; - if (check_interval >0) - check_interval--; - assumed_mtu_interval = 20; - current_mtu_conut = mtu_count; +void static attempt_slow_samplerate(uint8_t overlay_type) { + uint32_t current_mtu_conut = 0; + if (check_interval > 0) + check_interval--; + assumed_mtu_interval = 20; + current_mtu_conut = mtu_count; - if (lagest_mtu_in1s < current_mtu_conut) - lagest_mtu_in1s = current_mtu_conut; - if (least_mtu_in1s > current_mtu_conut) - least_mtu_in1s = current_mtu_conut; + if (lagest_mtu_in1s < current_mtu_conut) + lagest_mtu_in1s = current_mtu_conut; + if (least_mtu_in1s > current_mtu_conut) + least_mtu_in1s = current_mtu_conut; - if (check_interval == 0) - { - int32_t delay_ms = 0; - if(overlay_type == APP_OVERLAY_A2DP){ - delay_ms = (delay_mtu_limit-(int)lagest_mtu_in1s)*128*1000/a2dp_sample_rate; - }else + if (check_interval == 0) { + int32_t delay_ms = 0; + if (overlay_type == APP_OVERLAY_A2DP) { + delay_ms = (delay_mtu_limit - (int)lagest_mtu_in1s) * 128 * 1000 / + a2dp_sample_rate; + } else #if defined(A2DP_AAC_ON) - if(overlay_type == APP_OVERLAY_A2DP_AAC){ - delay_ms = (delay_mtu_limit-(int)lagest_mtu_in1s)*1024*1000/a2dp_sample_rate; - }else + if (overlay_type == APP_OVERLAY_A2DP_AAC) { + delay_ms = (delay_mtu_limit - (int)lagest_mtu_in1s) * 1024 * 1000 / + a2dp_sample_rate; + } else #endif #if defined(A2DP_SCALABLE_ON) - if(overlay_type == APP_OVERLAY_A2DP_SCALABLE){ - delay_ms = (delay_mtu_limit-(int)lagest_mtu_in1s)*864*1000/a2dp_sample_rate; - }else + if (overlay_type == APP_OVERLAY_A2DP_SCALABLE) { + delay_ms = (delay_mtu_limit - (int)lagest_mtu_in1s) * 864 * 1000 / + a2dp_sample_rate; + } else #endif #if defined(A2DP_LHDC_ON) - if(overlay_type == APP_OVERLAY_A2DP_LHDC){ - delay_ms = (delay_mtu_limit-(int)lagest_mtu_in1s)*512*1000/a2dp_sample_rate; - }else + if (overlay_type == APP_OVERLAY_A2DP_LHDC) { + delay_ms = (delay_mtu_limit - (int)lagest_mtu_in1s) * 512 * 1000 / + a2dp_sample_rate; + } else #endif #if defined(A2DP_LDAC_ON) - if(overlay_type == APP_OVERLAY_A2DP_LDAC){ - delay_ms = (delay_mtu_limit-(int)lagest_mtu_in1s)*256*1000/a2dp_sample_rate; - }else + if (overlay_type == APP_OVERLAY_A2DP_LDAC) { + delay_ms = (delay_mtu_limit - (int)lagest_mtu_in1s) * 256 * 1000 / + a2dp_sample_rate; + } else #endif - { - delay_ms = (delay_mtu_limit-(int)lagest_mtu_in1s)*assumed_mtu_interval; - } - TRACE(6,"store_interval=%d,lagest_mtu_in1s=%d,least_mtu_in1s=%d,delay_ms=%d,frame_len=%d,mtu_count=%d",ssb_err_max,lagest_mtu_in1s,least_mtu_in1s,delay_ms,sbc_frame_rev_len,mtu_count); - process_delay(delay_ms); - check_interval = 50; - lagest_mtu_in1s = 0; - least_mtu_in1s = 0xffffffff; + { + delay_ms = + (delay_mtu_limit - (int)lagest_mtu_in1s) * assumed_mtu_interval; } + TRACE(6, + "store_interval=%d,lagest_mtu_in1s=%d,least_mtu_in1s=%d,delay_ms=%d," + "frame_len=%d,mtu_count=%d", + ssb_err_max, lagest_mtu_in1s, least_mtu_in1s, delay_ms, + sbc_frame_rev_len, mtu_count); + process_delay(delay_ms); + check_interval = 50; + lagest_mtu_in1s = 0; + least_mtu_in1s = 0xffffffff; + } } // A2DP_EQ_24BIT == 1, buf should be 32bit(24bit) // A2DP_EQ_24BIT == 0, buf should be 16bit -uint32_t a2dp_audio_more_data(uint8_t overlay_type, uint8_t *buf, uint32_t len) -{ - uint32_t l = 0; +uint32_t a2dp_audio_more_data(uint8_t overlay_type, uint8_t *buf, + uint32_t len) { + uint32_t l = 0; - if (!a2dp_audio_isrunning(A2DPPLAY_STRTEAM_GET, true)){ - } + if (!a2dp_audio_isrunning(A2DPPLAY_STRTEAM_GET, true)) { + } #ifdef A2DP_EQ_24BIT - // Change len to 16-bit sample buffer length - if ((bt_sbc_player_get_sample_bit() == 16) + // Change len to 16-bit sample buffer length + if ((bt_sbc_player_get_sample_bit() == 16) #if defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE) - || allow_resample + || allow_resample #endif - ) { - len = len / (sizeof(int32_t) / sizeof(int16_t)); - } + ) { + len = len / (sizeof(int32_t) / sizeof(int16_t)); + } #endif - if (a2dp_cache_status == APP_AUDIO_CACHE_CACHEING){ -#if FPGA==0 - TRACE(1,"a2dp_audio_more_data cache not ready skip frame %d\n" ,overlay_type); + if (a2dp_cache_status == APP_AUDIO_CACHE_CACHEING) { +#if FPGA == 0 + TRACE(1, "a2dp_audio_more_data cache not ready skip frame %d\n", + overlay_type); #endif - } else { + } else { #if defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE) - if (allow_resample) - { - app_playback_resample_run(a2dp_resample, buf, len); - } - else + if (allow_resample) { + app_playback_resample_run(a2dp_resample, buf, len); + } else #endif - { - l = decode_a2dp_frame((enum APP_OVERLAY_ID_T)overlay_type, buf, len); - if (l != len) { - TRACE(2,"a2dp_audio_more_data decode err %d/%d", l, len); - if (l < len){ - memset(buf + l, 0, len - l); - //a2dp_cache_status = APP_AUDIO_CACHE_CACHEING; - TRACE(0,"set to APP_AUDIO_CACHE_CACHEING"); - } - } else { - //TRACE(2,"a2dp_audio_more_data decode success %d/%d", l, len); - } - } - if (a2dp_cache_status == APP_AUDIO_CACHE_OK) { - attempt_slow_samplerate(overlay_type); + { + l = decode_a2dp_frame((enum APP_OVERLAY_ID_T)overlay_type, buf, len); + if (l != len) { + TRACE(2, "a2dp_audio_more_data decode err %d/%d", l, len); + if (l < len) { + memset(buf + l, 0, len - l); + // a2dp_cache_status = APP_AUDIO_CACHE_CACHEING; + TRACE(0, "set to APP_AUDIO_CACHE_CACHEING"); } + } else { + // TRACE(2,"a2dp_audio_more_data decode success %d/%d", l, len); + } } + if (a2dp_cache_status == APP_AUDIO_CACHE_OK) { + attempt_slow_samplerate(overlay_type); + } + } #ifdef A2DP_EQ_24BIT - if ((bt_sbc_player_get_sample_bit() == 16) + if ((bt_sbc_player_get_sample_bit() == 16) #if defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE) - || allow_resample + || allow_resample #endif - ) { - convert_16bit_to_24bit((int32_t *)buf, (int16_t *)buf, len / sizeof(int16_t)); - // Restore len to 24-bit sample buffer length - len = len * (sizeof(int32_t) / sizeof(int16_t)); - } + ) { + convert_16bit_to_24bit((int32_t *)buf, (int16_t *)buf, + len / sizeof(int16_t)); + // Restore len to 24-bit sample buffer length + len = len * (sizeof(int32_t) / sizeof(int16_t)); + } #endif - A2DP_SYNC_WITH_GET_MUTUX_SET(); + A2DP_SYNC_WITH_GET_MUTUX_SET(); - return len; + return len; } #if defined(A2DP_LDAC_ON) /* Convert LDAC Error Code to string */ -#define CASE_RETURN_STR(const) case const: return #const; -static const char * ldac_ErrCode2Str( int ErrCode ) -{ - switch(ErrCode){ - CASE_RETURN_STR(LDACBT_ERR_NONE); - CASE_RETURN_STR(LDACBT_ERR_NON_FATAL); - CASE_RETURN_STR(LDACBT_ERR_BIT_ALLOCATION); - CASE_RETURN_STR(LDACBT_ERR_NOT_IMPLEMENTED); - CASE_RETURN_STR(LDACBT_ERR_NON_FATAL_ENCODE); - CASE_RETURN_STR(LDACBT_ERR_FATAL); - CASE_RETURN_STR(LDACBT_ERR_SYNTAX_BAND); - CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_A); - CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_B); - CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_C); - CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_D); - CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_E); - CASE_RETURN_STR(LDACBT_ERR_SYNTAX_IDSF); - CASE_RETURN_STR(LDACBT_ERR_SYNTAX_SPEC); - CASE_RETURN_STR(LDACBT_ERR_BIT_PACKING); - CASE_RETURN_STR(LDACBT_ERR_ALLOC_MEMORY); - CASE_RETURN_STR(LDACBT_ERR_FATAL_HANDLE); - CASE_RETURN_STR(LDACBT_ERR_ILL_SYNCWORD); - CASE_RETURN_STR(LDACBT_ERR_ILL_SMPL_FORMAT); - CASE_RETURN_STR(LDACBT_ERR_ILL_PARAM); - CASE_RETURN_STR(LDACBT_ERR_ASSERT_SAMPLING_FREQ); - CASE_RETURN_STR(LDACBT_ERR_ASSERT_SUP_SAMPLING_FREQ); - CASE_RETURN_STR(LDACBT_ERR_CHECK_SAMPLING_FREQ); - CASE_RETURN_STR(LDACBT_ERR_ASSERT_CHANNEL_CONFIG); - CASE_RETURN_STR(LDACBT_ERR_CHECK_CHANNEL_CONFIG); - CASE_RETURN_STR(LDACBT_ERR_ASSERT_FRAME_LENGTH); - CASE_RETURN_STR(LDACBT_ERR_ASSERT_SUP_FRAME_LENGTH); - CASE_RETURN_STR(LDACBT_ERR_ASSERT_FRAME_STATUS); - CASE_RETURN_STR(LDACBT_ERR_ASSERT_NSHIFT); - CASE_RETURN_STR(LDACBT_ERR_ASSERT_CHANNEL_MODE); - CASE_RETURN_STR(LDACBT_ERR_ENC_INIT_ALLOC); - CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADMODE); - CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADPAR_A); - CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADPAR_B); - CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADPAR_C); - CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADPAR_D); - CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_NBANDS); - CASE_RETURN_STR(LDACBT_ERR_PACK_BLOCK_FAILED); - CASE_RETURN_STR(LDACBT_ERR_DEC_INIT_ALLOC); - CASE_RETURN_STR(LDACBT_ERR_INPUT_BUFFER_SIZE); - CASE_RETURN_STR(LDACBT_ERR_UNPACK_BLOCK_FAILED); - CASE_RETURN_STR(LDACBT_ERR_UNPACK_BLOCK_ALIGN); - CASE_RETURN_STR(LDACBT_ERR_UNPACK_FRAME_ALIGN); - CASE_RETURN_STR(LDACBT_ERR_FRAME_LENGTH_OVER); - CASE_RETURN_STR(LDACBT_ERR_FRAME_ALIGN_OVER); - CASE_RETURN_STR(LDACBT_ERR_ALTER_EQMID_LIMITED); - CASE_RETURN_STR(LDACBT_ERR_ILL_EQMID); - CASE_RETURN_STR(LDACBT_ERR_ILL_SAMPLING_FREQ); - CASE_RETURN_STR(LDACBT_ERR_ILL_NUM_CHANNEL); - CASE_RETURN_STR(LDACBT_ERR_ILL_MTU_SIZE); - CASE_RETURN_STR(LDACBT_ERR_HANDLE_NOT_INIT); - default: - return "unknown-error-code"; - } +#define CASE_RETURN_STR(const) \ + case const: \ + return #const; +static const char *ldac_ErrCode2Str(int ErrCode) { + switch (ErrCode) { + CASE_RETURN_STR(LDACBT_ERR_NONE); + CASE_RETURN_STR(LDACBT_ERR_NON_FATAL); + CASE_RETURN_STR(LDACBT_ERR_BIT_ALLOCATION); + CASE_RETURN_STR(LDACBT_ERR_NOT_IMPLEMENTED); + CASE_RETURN_STR(LDACBT_ERR_NON_FATAL_ENCODE); + CASE_RETURN_STR(LDACBT_ERR_FATAL); + CASE_RETURN_STR(LDACBT_ERR_SYNTAX_BAND); + CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_A); + CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_B); + CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_C); + CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_D); + CASE_RETURN_STR(LDACBT_ERR_SYNTAX_GRAD_E); + CASE_RETURN_STR(LDACBT_ERR_SYNTAX_IDSF); + CASE_RETURN_STR(LDACBT_ERR_SYNTAX_SPEC); + CASE_RETURN_STR(LDACBT_ERR_BIT_PACKING); + CASE_RETURN_STR(LDACBT_ERR_ALLOC_MEMORY); + CASE_RETURN_STR(LDACBT_ERR_FATAL_HANDLE); + CASE_RETURN_STR(LDACBT_ERR_ILL_SYNCWORD); + CASE_RETURN_STR(LDACBT_ERR_ILL_SMPL_FORMAT); + CASE_RETURN_STR(LDACBT_ERR_ILL_PARAM); + CASE_RETURN_STR(LDACBT_ERR_ASSERT_SAMPLING_FREQ); + CASE_RETURN_STR(LDACBT_ERR_ASSERT_SUP_SAMPLING_FREQ); + CASE_RETURN_STR(LDACBT_ERR_CHECK_SAMPLING_FREQ); + CASE_RETURN_STR(LDACBT_ERR_ASSERT_CHANNEL_CONFIG); + CASE_RETURN_STR(LDACBT_ERR_CHECK_CHANNEL_CONFIG); + CASE_RETURN_STR(LDACBT_ERR_ASSERT_FRAME_LENGTH); + CASE_RETURN_STR(LDACBT_ERR_ASSERT_SUP_FRAME_LENGTH); + CASE_RETURN_STR(LDACBT_ERR_ASSERT_FRAME_STATUS); + CASE_RETURN_STR(LDACBT_ERR_ASSERT_NSHIFT); + CASE_RETURN_STR(LDACBT_ERR_ASSERT_CHANNEL_MODE); + CASE_RETURN_STR(LDACBT_ERR_ENC_INIT_ALLOC); + CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADMODE); + CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADPAR_A); + CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADPAR_B); + CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADPAR_C); + CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_GRADPAR_D); + CASE_RETURN_STR(LDACBT_ERR_ENC_ILL_NBANDS); + CASE_RETURN_STR(LDACBT_ERR_PACK_BLOCK_FAILED); + CASE_RETURN_STR(LDACBT_ERR_DEC_INIT_ALLOC); + CASE_RETURN_STR(LDACBT_ERR_INPUT_BUFFER_SIZE); + CASE_RETURN_STR(LDACBT_ERR_UNPACK_BLOCK_FAILED); + CASE_RETURN_STR(LDACBT_ERR_UNPACK_BLOCK_ALIGN); + CASE_RETURN_STR(LDACBT_ERR_UNPACK_FRAME_ALIGN); + CASE_RETURN_STR(LDACBT_ERR_FRAME_LENGTH_OVER); + CASE_RETURN_STR(LDACBT_ERR_FRAME_ALIGN_OVER); + CASE_RETURN_STR(LDACBT_ERR_ALTER_EQMID_LIMITED); + CASE_RETURN_STR(LDACBT_ERR_ILL_EQMID); + CASE_RETURN_STR(LDACBT_ERR_ILL_SAMPLING_FREQ); + CASE_RETURN_STR(LDACBT_ERR_ILL_NUM_CHANNEL); + CASE_RETURN_STR(LDACBT_ERR_ILL_MTU_SIZE); + CASE_RETURN_STR(LDACBT_ERR_HANDLE_NOT_INIT); + default: + return "unknown-error-code"; + } } - char a_ErrorCodeStr[128]; -const char * get_error_code_string( int error_code ) -{ - int errApi, errHdl, errBlk; +const char *get_error_code_string(int error_code) { + int errApi, errHdl, errBlk; - errApi = LDACBT_API_ERR( error_code ); - errHdl = LDACBT_HANDLE_ERR( error_code ); - errBlk = LDACBT_BLOCK_ERR( error_code ); + errApi = LDACBT_API_ERR(error_code); + errHdl = LDACBT_HANDLE_ERR(error_code); + errBlk = LDACBT_BLOCK_ERR(error_code); - a_ErrorCodeStr[0] = '\0'; - strcat( a_ErrorCodeStr, "API:" ); - strcat( a_ErrorCodeStr, ldac_ErrCode2Str( errApi ) ); - strcat( a_ErrorCodeStr, " Handle:" ); - strcat( a_ErrorCodeStr, ldac_ErrCode2Str( errHdl ) ); - strcat( a_ErrorCodeStr, " Block:" ); - strcat( a_ErrorCodeStr, ldac_ErrCode2Str( errBlk ) ); - return a_ErrorCodeStr; + a_ErrorCodeStr[0] = '\0'; + strcat(a_ErrorCodeStr, "API:"); + strcat(a_ErrorCodeStr, ldac_ErrCode2Str(errApi)); + strcat(a_ErrorCodeStr, " Handle:"); + strcat(a_ErrorCodeStr, ldac_ErrCode2Str(errHdl)); + strcat(a_ErrorCodeStr, " Block:"); + strcat(a_ErrorCodeStr, ldac_ErrCode2Str(errBlk)); + return a_ErrorCodeStr; } #endif @@ -3180,296 +3194,299 @@ extern uint8_t bt_sbc_player_get_bitsDepth(void); uint32_t ldac_buffer_used = 0; #endif -static const char *a2dp_get_codec_name(enum APP_OVERLAY_ID_T overlay_type) -{ - const char *codec_name; +static const char *a2dp_get_codec_name(enum APP_OVERLAY_ID_T overlay_type) { + const char *codec_name; - if (0) { + if (0) { #if defined(A2DP_LDAC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { - codec_name = "LDAC"; + } else if (overlay_type == APP_OVERLAY_A2DP_LDAC) { + codec_name = "LDAC"; #endif #if defined(A2DP_AAC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_AAC) { - codec_name = "AAC"; + } else if (overlay_type == APP_OVERLAY_A2DP_AAC) { + codec_name = "AAC"; #endif #if defined(A2DP_SCALABLE_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_SCALABLE) { - codec_name = "SCALABLE"; + } else if (overlay_type == APP_OVERLAY_A2DP_SCALABLE) { + codec_name = "SCALABLE"; #endif #if defined(A2DP_LHDC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_LHDC) { - codec_name = "LHDC"; + } else if (overlay_type == APP_OVERLAY_A2DP_LHDC) { + codec_name = "LHDC"; #endif - } else if (overlay_type == APP_OVERLAY_A2DP) { - codec_name = "SBC"; - } else { - codec_name = "UNKNOWN"; - } + } else if (overlay_type == APP_OVERLAY_A2DP) { + codec_name = "SBC"; + } else { + codec_name = "UNKNOWN"; + } - return codec_name; + return codec_name; } -static void a2dp_trace_codec_name(const char *prefix, enum APP_OVERLAY_ID_T overlay_type) -{ - TRACE(3,"\n\n%s: codecType=%x->:%s\n", prefix, overlay_type,a2dp_get_codec_name(overlay_type)); +static void a2dp_trace_codec_name(const char *prefix, + enum APP_OVERLAY_ID_T overlay_type) { + TRACE(3, "\n\n%s: codecType=%x->:%s\n", prefix, overlay_type, + a2dp_get_codec_name(overlay_type)); } -int a2dp_audio_init(void) -{ - const float EQLevel[25] = { - 0.0630957, 0.0794328, 0.1, 0.1258925, 0.1584893, - 0.1995262, 0.2511886, 0.3162278, 0.398107 , 0.5011872, - 0.6309573, 0.794328 , 1, 1.258925 , 1.584893 , - 1.995262 , 2.5118864, 3.1622776, 3.9810717, 5.011872 , - 6.309573 , 7.943282 , 10 , 12.589254, 15.848932 - };//-12~12 - uint8_t *buff = NULL; - uint8_t i; +int a2dp_audio_init(void) { + const float EQLevel[25] = { + 0.0630957, 0.0794328, 0.1, 0.1258925, 0.1584893, + 0.1995262, 0.2511886, 0.3162278, 0.398107, 0.5011872, + 0.6309573, 0.794328, 1, 1.258925, 1.584893, + 1.995262, 2.5118864, 3.1622776, 3.9810717, 5.011872, + 6.309573, 7.943282, 10, 12.589254, 15.848932}; //-12~12 + uint8_t *buff = NULL; + uint8_t i; - enum APP_OVERLAY_ID_T overlay_type; + enum APP_OVERLAY_ID_T overlay_type; - overlay_type = app_get_current_overlay(); + overlay_type = app_get_current_overlay(); - a2dp_trace_codec_name(__func__, overlay_type); + a2dp_trace_codec_name(__func__, overlay_type); #if defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE) - APP_RESAMPLE_ITER_CALLBACK iter_cb; + APP_RESAMPLE_ITER_CALLBACK iter_cb; - uint32_t iter_len; + uint32_t iter_len; - iter_cb = a2dp_resample_iter; + iter_cb = a2dp_resample_iter; - if (0) { + if (0) { #if defined(A2DP_AAC_ON) - } else if (overlay_type == APP_OVERLAY_A2DP_AAC) { - iter_len = AAC_RESAMPLE_ITER_LEN; + } else if (overlay_type == APP_OVERLAY_A2DP_AAC) { + iter_len = AAC_RESAMPLE_ITER_LEN; #endif - } else if (overlay_type == APP_OVERLAY_A2DP) { - iter_len = SBC_RESAMPLE_ITER_LEN; - } else { - ASSERT(false, "%s: Bad app overlay type for play resample: %d", __func__, overlay_type); - } + } else if (overlay_type == APP_OVERLAY_A2DP) { + iter_len = SBC_RESAMPLE_ITER_LEN; + } else { + ASSERT(false, "%s: Bad app overlay type for play resample: %d", __func__, + overlay_type); + } #ifdef CHIP_BEST1000 - if(hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_2 && hal_sysfreq_get() <= HAL_CMU_FREQ_52M) - { - allow_resample = true; - } + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_2 && + hal_sysfreq_get() <= HAL_CMU_FREQ_52M) { + allow_resample = true; + } #endif - if (allow_resample) - { + if (allow_resample) { #ifdef RESAMPLE_ANY_SAMPLE_RATE - float ratio; - if (a2dp_sample_rate % AUD_SAMPRATE_8000) { - ratio = (float)CODEC_FREQ_22P5792M * ((float)a2dp_sample_rate / AUD_SAMPRATE_44100) / CODEC_FREQ_26M; - } else { - ratio = (float)CODEC_FREQ_24P576M * ((float)a2dp_sample_rate / AUD_SAMPRATE_48000) / CODEC_FREQ_26M; - } - a2dp_resample = app_playback_resample_any_open(AUD_CHANNEL_NUM_2, - iter_cb, iter_len, ratio); + float ratio; + if (a2dp_sample_rate % AUD_SAMPRATE_8000) { + ratio = (float)CODEC_FREQ_22P5792M * + ((float)a2dp_sample_rate / AUD_SAMPRATE_44100) / CODEC_FREQ_26M; + } else { + ratio = (float)CODEC_FREQ_24P576M * + ((float)a2dp_sample_rate / AUD_SAMPRATE_48000) / CODEC_FREQ_26M; + } + a2dp_resample = app_playback_resample_any_open(AUD_CHANNEL_NUM_2, iter_cb, + iter_len, ratio); #else - a2dp_resample = app_playback_resample_open(a2dp_sample_rate, AUD_CHANNEL_NUM_2, - iter_cb, iter_len); + a2dp_resample = app_playback_resample_open( + a2dp_sample_rate, AUD_CHANNEL_NUM_2, iter_cb, iter_len); #endif - } + } #endif - for (i=0; i= 24 ? 1 : 0); - //extern const char __testkey_start[]; - extern const char testkey_bin[]; - lhdcSetLicenseKeyTable((uint8_t *)testkey_bin); + // lhdcInit(bits_depth, sample_rate, bits_depth >= 24 ? 1 : 0); + // extern const char __testkey_start[]; + extern const char testkey_bin[]; + lhdcSetLicenseKeyTable((uint8_t *)testkey_bin); - TRACE(0,"lhdcSetLicenseKeyTable,testkey_bin:\n"); - for(uint8_t i=0;i<128;i++){ - TRACE(1,"i = %d", i); - DUMP8("0x%02x ", &testkey_bin[i], 32); - i+= 31; - } - lhdcInit(bits_depth, sample_rate, 0); - initial_lhdc_assemble_packet(false); + TRACE(0, "lhdcSetLicenseKeyTable,testkey_bin:\n"); + for (uint8_t i = 0; i < 128; i++) { + TRACE(1, "i = %d", i); + DUMP8("0x%02x ", &testkey_bin[i], 32); + i += 31; } + lhdcInit(bits_depth, sample_rate, 0); + initial_lhdc_assemble_packet(false); + } #endif #ifdef SBC_QUEUE_SIZE - if (0) { + if (0) { #if defined(A2DP_AAC_ON) || defined(A2DP_SCALABLE_ON) || defined(A2DP_LHDC_ON) - } else if(overlay_type == APP_OVERLAY_A2DP_AAC){ - #if defined(MIX_MIC_DURING_MUSIC) - g_sbc_queue_size = app_audio_mempool_free_buff_size() - 4096; - #else - g_sbc_queue_size = app_audio_mempool_free_buff_size(); - #endif -#endif -#if defined(A2DP_SCALABLE_ON) - } else if(overlay_type == APP_OVERLAY_A2DP_SCALABLE){ - #if defined(MIX_MIC_DURING_MUSIC) - g_sbc_queue_size = app_audio_mempool_free_buff_size() - 4096; - #else - g_sbc_queue_size = app_audio_mempool_free_buff_size(); - #endif -#endif -#if defined(A2DP_LHDC_ON) - } else if(overlay_type == APP_OVERLAY_A2DP_LHDC){ - #if defined(MIX_MIC_DURING_MUSIC) - g_sbc_queue_size = app_audio_mempool_free_buff_size() - 4096; - #else - g_sbc_queue_size = app_audio_mempool_free_buff_size(); - #endif -#endif - } else { - g_sbc_queue_size = SBC_QUEUE_SIZE; - } + } else if (overlay_type == APP_OVERLAY_A2DP_AAC) { +#if defined(MIX_MIC_DURING_MUSIC) + g_sbc_queue_size = app_audio_mempool_free_buff_size() - 4096; #else g_sbc_queue_size = app_audio_mempool_free_buff_size(); #endif - -#if defined(A2DP_LDAC_ON) - if(overlay_type == APP_OVERLAY_A2DP_LDAC) - { - //if((bt_sbc_player_get_codec_type() == BTIF_AVDTP_CODEC_TYPE_NON_A2DP)){ - //app_audio_mempool_get_buff(&g_medMemHeap, MED_MEM_HEAP_SIZE); - //speech_heap_init((uint8_t *)(&g_medMemHeap[0]), MED_MEM_HEAP_SIZE); - g_sbc_queue_size = app_audio_mempool_free_buff_size() - MED_MEM_HEAP_SIZE; - TRACE(1,"A2DP_LDAC_ON g_sbc_queue_size %d\n", g_sbc_queue_size); - } +#endif +#if defined(A2DP_SCALABLE_ON) + } else if (overlay_type == APP_OVERLAY_A2DP_SCALABLE) { +#if defined(MIX_MIC_DURING_MUSIC) + g_sbc_queue_size = app_audio_mempool_free_buff_size() - 4096; +#else + g_sbc_queue_size = app_audio_mempool_free_buff_size(); +#endif +#endif +#if defined(A2DP_LHDC_ON) + } else if (overlay_type == APP_OVERLAY_A2DP_LHDC) { +#if defined(MIX_MIC_DURING_MUSIC) + g_sbc_queue_size = app_audio_mempool_free_buff_size() - 4096; +#else + g_sbc_queue_size = app_audio_mempool_free_buff_size(); +#endif +#endif + } else { + g_sbc_queue_size = SBC_QUEUE_SIZE; + } +#else + g_sbc_queue_size = app_audio_mempool_free_buff_size(); #endif - app_audio_mempool_get_buff(&buff, g_sbc_queue_size); - ASSERT((buff!=NULL), "%s:get sbc queue buff fail, size %d bytes!", __func__, g_sbc_queue_size); - memset(buff, 0, g_sbc_queue_size); - a2dp_audio_isrunning(A2DPPLAY_STRTEAM_PUT, false); - a2dp_audio_isrunning(A2DPPLAY_STRTEAM_GET, false); +#if defined(A2DP_LDAC_ON) + if (overlay_type == APP_OVERLAY_A2DP_LDAC) { + // if((bt_sbc_player_get_codec_type() == BTIF_AVDTP_CODEC_TYPE_NON_A2DP)){ + // app_audio_mempool_get_buff(&g_medMemHeap, MED_MEM_HEAP_SIZE); + // speech_heap_init((uint8_t *)(&g_medMemHeap[0]), MED_MEM_HEAP_SIZE); + g_sbc_queue_size = app_audio_mempool_free_buff_size() - MED_MEM_HEAP_SIZE; + TRACE(1, "A2DP_LDAC_ON g_sbc_queue_size %d\n", g_sbc_queue_size); + } +#endif - LOCK_APP_AUDIO_QUEUE(); - APP_AUDIO_InitCQueue(&sbc_queue, g_sbc_queue_size, buff); - UNLOCK_APP_AUDIO_QUEUE(); + app_audio_mempool_get_buff(&buff, g_sbc_queue_size); + ASSERT((buff != NULL), "%s:get sbc queue buff fail, size %d bytes!", __func__, + g_sbc_queue_size); + memset(buff, 0, g_sbc_queue_size); + a2dp_audio_isrunning(A2DPPLAY_STRTEAM_PUT, false); + a2dp_audio_isrunning(A2DPPLAY_STRTEAM_GET, false); + + LOCK_APP_AUDIO_QUEUE(); + APP_AUDIO_InitCQueue(&sbc_queue, g_sbc_queue_size, buff); + UNLOCK_APP_AUDIO_QUEUE(); #if defined(A2DP_LDAC_ON) - if(overlay_type == APP_OVERLAY_A2DP_LDAC){ - ldac_buffer_used = app_audio_mempool_total_buf() - app_audio_mempool_free_buff_size(); - ldac_recovery = false; - ldac_dec_init(); - } + if (overlay_type == APP_OVERLAY_A2DP_LDAC) { + ldac_buffer_used = + app_audio_mempool_total_buf() - app_audio_mempool_free_buff_size(); + ldac_recovery = false; + ldac_dec_init(); + } #endif #ifdef A2DP_AUDIO_SYNC_WITH_LOCAL - a2dp_audio_sync_proc(A2DPPLAY_SYNC_STATUS_SET|A2DPPLAY_SYNC_STATUS_RESET, A2DP_AUDIO_SYNC_WITH_LOCAL_SAMPLERATE_DEFAULT); + a2dp_audio_sync_proc(A2DPPLAY_SYNC_STATUS_SET | A2DPPLAY_SYNC_STATUS_RESET, + A2DP_AUDIO_SYNC_WITH_LOCAL_SAMPLERATE_DEFAULT); #endif #ifdef A2DP_CP_ACCEL - cp_a2dp_init(); + cp_a2dp_init(); #endif - a2dp_cache_status = APP_AUDIO_CACHE_CACHEING; - need_init_decoder = true; - dec_reset_queue = false; + a2dp_cache_status = APP_AUDIO_CACHE_CACHEING; + need_init_decoder = true; + dec_reset_queue = false; - sbc_frame_rev_len = 0; - sbc_frame_num = 0; - sbc_frame_size = SBC_TEMP_BUFFER_SIZE; - mtu_count = 0; - assumed_mtu_interval = 0; - return 0; + sbc_frame_rev_len = 0; + sbc_frame_num = 0; + sbc_frame_size = SBC_TEMP_BUFFER_SIZE; + mtu_count = 0; + assumed_mtu_interval = 0; + return 0; } -int a2dp_audio_deinit(void) -{ - enum APP_OVERLAY_ID_T overlay_type; +int a2dp_audio_deinit(void) { + enum APP_OVERLAY_ID_T overlay_type; - overlay_type = app_get_current_overlay(); + overlay_type = app_get_current_overlay(); - a2dp_trace_codec_name(__func__, overlay_type); + a2dp_trace_codec_name(__func__, overlay_type); #if defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE) - if (allow_resample) { - app_playback_resample_close(a2dp_resample); - a2dp_resample = NULL; + if (allow_resample) { + app_playback_resample_close(a2dp_resample); + a2dp_resample = NULL; #ifdef CHIP_BEST1000 - allow_resample = false; + allow_resample = false; #endif - } + } #endif #ifdef A2DP_CP_ACCEL - cp_a2dp_deinit(); + cp_a2dp_deinit(); #endif #if defined(A2DP_LDAC_ON) - if(overlay_type == APP_OVERLAY_A2DP_LDAC){ - ldac_dec_deinit(); - } + if (overlay_type == APP_OVERLAY_A2DP_LDAC) { + ldac_dec_deinit(); + } #endif #if defined(A2DP_LHDC_ON) - if(overlay_type == APP_OVERLAY_A2DP_LHDC){ - lhdcDestroy(); - } + if (overlay_type == APP_OVERLAY_A2DP_LHDC) { + lhdcDestroy(); + } #endif #if defined(A2DP_AAC_ON) - aacdec_deinit(); - aac_memdeinit(); + aacdec_deinit(); + aac_memdeinit(); #endif - A2DP_SYNC_WITH_GET_MUTUX_SET(); - A2DP_SYNC_WITH_PUT_MUTUX_SET(); + A2DP_SYNC_WITH_GET_MUTUX_SET(); + A2DP_SYNC_WITH_PUT_MUTUX_SET(); - A2DP_SYNC_WITH_GET_MUTUX_FREE(); - A2DP_SYNC_WITH_PUT_MUTUX_FREE(); + A2DP_SYNC_WITH_GET_MUTUX_FREE(); + A2DP_SYNC_WITH_PUT_MUTUX_FREE(); - a2dp_audio_isrunning(A2DPPLAY_STRTEAM_PUT, false); - a2dp_audio_isrunning(A2DPPLAY_STRTEAM_GET, false); + a2dp_audio_isrunning(A2DPPLAY_STRTEAM_PUT, false); + a2dp_audio_isrunning(A2DPPLAY_STRTEAM_GET, false); - a2dp_cache_status = APP_AUDIO_CACHE_QTY; - need_init_decoder = true; + a2dp_cache_status = APP_AUDIO_CACHE_QTY; + need_init_decoder = true; - sbc_frame_rev_len = 0; - sbc_frame_num = 0; - sbc_frame_size = SBC_TEMP_BUFFER_SIZE; - mtu_count = 0; - assumed_mtu_interval = 0; + sbc_frame_rev_len = 0; + sbc_frame_num = 0; + sbc_frame_size = SBC_TEMP_BUFFER_SIZE; + mtu_count = 0; + assumed_mtu_interval = 0; - return 0; + return 0; } -float a2dp_audio_latency_factor_get(void) -{ - return 1.0f; -} +float a2dp_audio_latency_factor_get(void) { return 1.0f; } #endif diff --git a/apps/audioplayers/app_audio.cpp b/apps/audioplayers/app_audio.cpp index b85a1ec..d7e666a 100644 --- a/apps/audioplayers/app_audio.cpp +++ b/apps/audioplayers/app_audio.cpp @@ -13,25 +13,25 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "cmsis_os.h" #include "app_bt_trace.h" +#include "cmsis_os.h" #include "string.h" -#include "cqueue.h" -#include "list.h" -#include "hal_aud.h" -#include "resources.h" -#include "app_thread.h" #include "app_audio.h" #include "app_media_player.h" #include "app_ring_merge.h" +#include "app_thread.h" +#include "cqueue.h" +#include "hal_aud.h" +#include "list.h" #include "nvrecord.h" +#include "resources.h" #include #include "a2dp_api.h" -#include "btapp.h" #include "app_bt_media_manager.h" +#include "btapp.h" extern uint8_t __StackLimit[]; extern uint8_t __HeapLimit[]; @@ -41,49 +41,50 @@ static const size_t heap_size = __StackLimit - __HeapLimit - 512; static bool app_audio_init = false; static uint32_t capture_audio_buff_size_used; -// from the bottom of the system available memory pool, size is APP_CAPTURE_AUDIO_BUFFER_SIZE -// can be overlayed with the sco used audio buffer -static uint8_t* capture_audio_buffer = __HeapLimit + heap_size - APP_CAPTURE_AUDIO_BUFFER_SIZE; +// from the bottom of the system available memory pool, size is +// APP_CAPTURE_AUDIO_BUFFER_SIZE can be overlayed with the sco used audio buffer +static uint8_t *capture_audio_buffer = + __HeapLimit + heap_size - APP_CAPTURE_AUDIO_BUFFER_SIZE; -int app_capture_audio_mempool_init(void) -{ - TRACE_AUD_HDL_I("[CAPMEM][INIT] size %d.", APP_CAPTURE_AUDIO_BUFFER_SIZE); - capture_audio_buff_size_used = 0; - memset((uint8_t *)capture_audio_buffer, 0, APP_CAPTURE_AUDIO_BUFFER_SIZE); +int app_capture_audio_mempool_init(void) { + TRACE_AUD_HDL_I("[CAPMEM][INIT] size %d.", APP_CAPTURE_AUDIO_BUFFER_SIZE); + capture_audio_buff_size_used = 0; + memset((uint8_t *)capture_audio_buffer, 0, APP_CAPTURE_AUDIO_BUFFER_SIZE); - return 0; + return 0; } -uint32_t app_capture_audio_mempool_free_buff_size() -{ - return APP_CAPTURE_AUDIO_BUFFER_SIZE - capture_audio_buff_size_used; +uint32_t app_capture_audio_mempool_free_buff_size() { + return APP_CAPTURE_AUDIO_BUFFER_SIZE - capture_audio_buff_size_used; } -int app_capture_audio_mempool_get_buff(uint8_t **buff, uint32_t size) -{ - uint32_t buff_size_free; - uint8_t* capture_buf_addr = (uint8_t *)capture_audio_buffer; - buff_size_free = app_capture_audio_mempool_free_buff_size(); +int app_capture_audio_mempool_get_buff(uint8_t **buff, uint32_t size) { + uint32_t buff_size_free; + uint8_t *capture_buf_addr = (uint8_t *)capture_audio_buffer; + buff_size_free = app_capture_audio_mempool_free_buff_size(); - if (size % 4){ - size = size + (4 - size % 4); - } + if (size % 4) { + size = size + (4 - size % 4); + } - TRACE_AUD_HDL_I("[CAPMEM][GET] current free %d to allocate %d", buff_size_free, size); + TRACE_AUD_HDL_I("[CAPMEM][GET] current free %d to allocate %d", + buff_size_free, size); - ASSERT(size <= buff_size_free, "[%s] size = %d > free size = %d", __func__, size, buff_size_free); + ASSERT(size <= buff_size_free, "[%s] size = %d > free size = %d", __func__, + size, buff_size_free); - *buff = capture_buf_addr + capture_audio_buff_size_used; + *buff = capture_buf_addr + capture_audio_buff_size_used; - capture_audio_buff_size_used += size; - TRACE_AUD_HDL_I("[CAPMEM][GET] %d, now used %d left %d", - size, capture_audio_buff_size_used, app_capture_audio_mempool_free_buff_size()); + capture_audio_buff_size_used += size; + TRACE_AUD_HDL_I("[CAPMEM][GET] %d, now used %d left %d", size, + capture_audio_buff_size_used, + app_capture_audio_mempool_free_buff_size()); - return 0; + return 0; } -osPoolDef (app_audio_status_mempool, 20, APP_AUDIO_STATUS); -osPoolId app_audio_status_mempool = NULL; +osPoolDef(app_audio_status_mempool, 20, APP_AUDIO_STATUS); +osPoolId app_audio_status_mempool = NULL; // control queue access osMutexId g_app_audio_queue_mutex_id = NULL; @@ -98,694 +99,622 @@ osMutexDef(app_audio_pcmbuff_mutex); typedef struct { list_t *audio_list; -}APP_AUDIO_CONFIG; +} APP_AUDIO_CONFIG; -APP_AUDIO_CONFIG app_audio_conifg = { - .audio_list = NULL -}; +APP_AUDIO_CONFIG app_audio_conifg = {.audio_list = NULL}; #endif -void LOCK_APP_AUDIO_QUEUE() -{ - osMutexWait(g_app_audio_queue_mutex_id, osWaitForever); +void LOCK_APP_AUDIO_QUEUE() { + osMutexWait(g_app_audio_queue_mutex_id, osWaitForever); } -void UNLOCK_APP_AUDIO_QUEUE() -{ - osMutexRelease(g_app_audio_queue_mutex_id); -} +void UNLOCK_APP_AUDIO_QUEUE() { osMutexRelease(g_app_audio_queue_mutex_id); } -uint32_t app_audio_lr_balance(uint8_t *buf, uint32_t len, int8_t balance) -{ - short *balance_buf=(short *)buf; - uint32_t balance_len = len/2; - float factor; +uint32_t app_audio_lr_balance(uint8_t *buf, uint32_t len, int8_t balance) { + short *balance_buf = (short *)buf; + uint32_t balance_len = len / 2; + float factor; - ASSERT((balance >= -100) && (balance <= 100), "balance = %d is invalid!", balance); + ASSERT((balance >= -100) && (balance <= 100), "balance = %d is invalid!", + balance); - if(balance > 0) - { - //reduce L channel - factor = 1 - 0.01 * balance; - for(uint32_t i=0; i 0) { + // reduce L channel + factor = 1 - 0.01 * balance; + for (uint32_t i = 0; i < balance_len; i += 2) { + balance_buf[i] = (short)(factor * balance_buf[i]); } - else if(balance < 0) - { - //reduce R channel - factor = 1 + 0.01 * balance; - for(uint32_t i=0; iid == APP_PLAY_BACK_AUDIO) - num++; +static uint8_t app_audio_get_list_playback_num(void) { + APP_AUDIO_STATUS *audio_handle = NULL; + list_node_t *node = NULL; + uint8_t num = 0; + for (node = list_begin(app_audio_conifg.audio_list); + node != list_end(app_audio_conifg.audio_list); node = list_next(node)) { + audio_handle = (APP_AUDIO_STATUS *)list_node(node); + if (audio_handle == NULL) { + return num; } - return num; + if (audio_handle->id == APP_PLAY_BACK_AUDIO) + num++; + } + return num; } #endif #endif static bool need_flush_flash_switch_audio = false; -void app_audio_switch_flash_flush_req(void) -{ - uint32_t lock; +void app_audio_switch_flash_flush_req(void) { + uint32_t lock; - lock = int_lock(); - need_flush_flash_switch_audio = true; - int_unlock(lock); + lock = int_lock(); + need_flush_flash_switch_audio = true; + int_unlock(lock); } -static void app_audio_switch_flash_proc(void) -{ - // no need to do this across the audio switch, - // will use suspend flash erase to assure that no audio - // irq is missing for handling caused by long time global irq disabling - // during flash erase. - // Just flash the nvrecord flash periodically - return; +static void app_audio_switch_flash_proc(void) { + // no need to do this across the audio switch, + // will use suspend flash erase to assure that no audio + // irq is missing for handling caused by long time global irq disabling + // during flash erase. + // Just flash the nvrecord flash periodically + return; - uint32_t lock; - bool need_flush_flash = false; + uint32_t lock; + bool need_flush_flash = false; - lock = int_lock(); - if (need_flush_flash_switch_audio){ - need_flush_flash_switch_audio = false; - need_flush_flash = true; - } - int_unlock(lock); + lock = int_lock(); + if (need_flush_flash_switch_audio) { + need_flush_flash_switch_audio = false; + need_flush_flash = true; + } + int_unlock(lock); - if (need_flush_flash){ + if (need_flush_flash) { #ifndef FPGA - nv_record_flash_flush(); + nv_record_flash_flush(); #endif - } + } } #ifdef VOICE_DATAPATH -static bool app_audio_handle_pre_processing(APP_MESSAGE_BODY *msg_body) -{ - uint16_t stream_type; - APP_AUDIO_GET_AUD_ID(msg_body->message_ptr, stream_type); +static bool app_audio_handle_pre_processing(APP_MESSAGE_BODY *msg_body) { + uint16_t stream_type; + APP_AUDIO_GET_AUD_ID(msg_body->message_ptr, stream_type); - bool isToResetCaptureStream = false; - if ((BT_STREAM_SBC == stream_type) || (BT_STREAM_MEDIA == stream_type)) - { - if (app_audio_manager_capture_is_active()) - { - isToResetCaptureStream = true; - } + bool isToResetCaptureStream = false; + if ((BT_STREAM_SBC == stream_type) || (BT_STREAM_MEDIA == stream_type)) { + if (app_audio_manager_capture_is_active()) { + isToResetCaptureStream = true; } + } - if (isToResetCaptureStream) - { - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, - BT_STREAM_CAPTURE, 0, 0); + if (isToResetCaptureStream) { + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_CAPTURE, + 0, 0); - APP_MESSAGE_BLOCK msg; - msg.msg_body = *msg_body; - msg.mod_id = APP_MODUAL_AUDIO_MANAGE; - app_mailbox_put(&msg); - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, - BT_STREAM_CAPTURE, 0, 0); + APP_MESSAGE_BLOCK msg; + msg.msg_body = *msg_body; + msg.mod_id = APP_MODUAL_AUDIO_MANAGE; + app_mailbox_put(&msg); + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, + BT_STREAM_CAPTURE, 0, 0); - return false; - } - else - { - return true; - } + return false; + } else { + return true; + } } #endif -static int app_audio_handle_process(APP_MESSAGE_BODY *msg_body) -{ - int nRet = -1; +static int app_audio_handle_process(APP_MESSAGE_BODY *msg_body) { + int nRet = -1; - APP_AUDIO_STATUS aud_status; + APP_AUDIO_STATUS aud_status; - if (app_audio_init == false) - return -1; + if (app_audio_init == false) + return -1; #ifdef VOICE_DATAPATH - bool isContinue = app_audio_handle_pre_processing(msg_body); - if (!isContinue) - { - return -1; - } + bool isContinue = app_audio_handle_pre_processing(msg_body); + if (!isContinue) { + return -1; + } #endif - APP_AUDIO_GET_ID(msg_body->message_id, aud_status.id); - APP_AUDIO_GET_STATUS(msg_body->message_id, aud_status.status); - APP_AUDIO_GET_AUD_ID(msg_body->message_ptr, aud_status.aud_id); - APP_AUDIO_GET_FREQ(msg_body->message_Param0, aud_status.freq); + APP_AUDIO_GET_ID(msg_body->message_id, aud_status.id); + APP_AUDIO_GET_STATUS(msg_body->message_id, aud_status.status); + APP_AUDIO_GET_AUD_ID(msg_body->message_ptr, aud_status.aud_id); + APP_AUDIO_GET_FREQ(msg_body->message_Param0, aud_status.freq); - switch (aud_status.status) - { - case APP_BT_SETTING_OPEN: + switch (aud_status.status) { + case APP_BT_SETTING_OPEN: #ifdef __AUDIO_QUEUE_SUPPORT__ - TRACE_AUD_HDL_I( - "[OPEN] before status_id: 0x%x%s, aud_id: %d, len = %d", - aud_status.id, - player2str(aud_status.id), - aud_status.aud_id, + TRACE_AUD_HDL_I("[OPEN] before status_id: 0x%x%s, aud_id: %d, len = %d", + aud_status.id, player2str(aud_status.id), aud_status.aud_id, list_length(app_audio_conifg.audio_list)); - if (app_audio_list_append(&aud_status)) - { - app_bt_stream_open(&aud_status); - TRACE_AUD_HDL_I( - "[OPEN] after status_id: 0x%x%s, len = %d", - aud_status.id, - player2str(aud_status.id), - list_length(app_audio_conifg.audio_list)); - } + if (app_audio_list_append(&aud_status)) { + app_bt_stream_open(&aud_status); + TRACE_AUD_HDL_I("[OPEN] after status_id: 0x%x%s, len = %d", aud_status.id, + player2str(aud_status.id), + list_length(app_audio_conifg.audio_list)); + } #else - app_bt_stream_open(&aud_status); + app_bt_stream_open(&aud_status); #endif - break; - case APP_BT_SETTING_CLOSE: - app_audio_switch_flash_proc(); + break; + case APP_BT_SETTING_CLOSE: + app_audio_switch_flash_proc(); #ifdef __AUDIO_QUEUE_SUPPORT__ - APP_AUDIO_STATUS next_status; - TRACE_AUD_HDL_I( - "[CLOSE] current id: 0x%x%s", - aud_status.id, + APP_AUDIO_STATUS next_status; + TRACE_AUD_HDL_I("[CLOSE] current id: 0x%x%s", aud_status.id, player2str(aud_status.id)); - app_bt_stream_close(aud_status.id); - app_audio_switch_flash_proc(); + app_bt_stream_close(aud_status.id); + app_audio_switch_flash_proc(); #ifdef MEDIA_PLAYER_SUPPORT - if (aud_status.id == APP_PLAY_BACK_AUDIO) - { - TRACE_AUD_HDL_I("[CLOSE] list: %d", app_audio_get_list_playback_num()); - if (app_audio_get_list_playback_num() == 1) - { - TRACE_AUD_HDL_I("=======>APP_BT_SETTING_CLOSE MEDIA"); - bt_media_stop(BT_STREAM_MEDIA, BT_DEVICE_ID_1); - } - } + if (aud_status.id == APP_PLAY_BACK_AUDIO) { + TRACE_AUD_HDL_I("[CLOSE] list: %d", app_audio_get_list_playback_num()); + if (app_audio_get_list_playback_num() == 1) { + TRACE_AUD_HDL_I("=======>APP_BT_SETTING_CLOSE MEDIA"); + bt_media_stop(BT_STREAM_MEDIA, BT_DEVICE_ID_1); + } + } #endif - if (app_audio_list_rmv_callback(&aud_status, &next_status, APP_BT_SETTING_Q_POS_HEAD, false)) - { - TRACE_AUD_HDL_I( - "[CLOSE] %p, next id: 0x%x%s, status %d", - &next_status, - next_status.id, - player2str(next_status.id), - next_status.status); - app_bt_stream_open(&next_status); - } + if (app_audio_list_rmv_callback(&aud_status, &next_status, + APP_BT_SETTING_Q_POS_HEAD, false)) { + TRACE_AUD_HDL_I("[CLOSE] %p, next id: 0x%x%s, status %d", &next_status, + next_status.id, player2str(next_status.id), + next_status.status); + app_bt_stream_open(&next_status); + } #else - app_bt_stream_close(aud_status.id); - app_audio_switch_flash_proc(); + app_bt_stream_close(aud_status.id); + app_audio_switch_flash_proc(); #endif - break; - case APP_BT_SETTING_SETUP: - app_bt_stream_setup(aud_status.id, msg_body->message_ptr); - break; - case APP_BT_SETTING_RESTART: - app_bt_stream_restart(&aud_status); - break; - case APP_BT_SETTING_CLOSEALL: - app_bt_stream_closeall(); + break; + case APP_BT_SETTING_SETUP: + app_bt_stream_setup(aud_status.id, msg_body->message_ptr); + break; + case APP_BT_SETTING_RESTART: + app_bt_stream_restart(&aud_status); + break; + case APP_BT_SETTING_CLOSEALL: + app_bt_stream_closeall(); #ifdef __AUDIO_QUEUE_SUPPORT__ - app_audio_list_clear(); + app_audio_list_clear(); #endif - app_audio_switch_flash_proc(); - break; - default: - break; - } + app_audio_switch_flash_proc(); + break; + default: + break; + } - return nRet; + return nRet; } #ifdef __AUDIO_QUEUE_SUPPORT__ -static void app_audio_handle_free(void* data) -{ +static void app_audio_handle_free(void *data) { #ifdef MEDIA_PLAYER_SUPPORT - APP_AUDIO_STATUS * status = (APP_AUDIO_STATUS * )data; + APP_AUDIO_STATUS *status = (APP_AUDIO_STATUS *)data; - if(status->id == APP_PLAY_BACK_AUDIO) - { - TRACE_AUD_HDL_I("[HANDLE_FREE] , aud_id: 0x%x, type = 0x%x", status->aud_id, status->aud_type); - } + if (status->id == APP_PLAY_BACK_AUDIO) { + TRACE_AUD_HDL_I("[HANDLE_FREE] , aud_id: 0x%x, type = 0x%x", status->aud_id, + status->aud_type); + } #endif - osPoolFree (app_audio_status_mempool, data); + osPoolFree(app_audio_status_mempool, data); } -void app_audio_list_create() -{ - if (app_audio_conifg.audio_list == NULL) - { - app_audio_conifg.audio_list = list_new(app_audio_handle_free, NULL, NULL); +void app_audio_list_create() { + if (app_audio_conifg.audio_list == NULL) { + app_audio_conifg.audio_list = list_new(app_audio_handle_free, NULL, NULL); + } +} + +bool app_audio_list_stream_exist() { + APP_AUDIO_STATUS *audio_handle = NULL; + list_node_t *node = NULL; + + for (node = list_begin(app_audio_conifg.audio_list); + node != list_end(app_audio_conifg.audio_list); node = list_next(node)) { + + audio_handle = (APP_AUDIO_STATUS *)list_node(node); + if (audio_handle == NULL) { + return false; } -} - -bool app_audio_list_stream_exist() -{ - APP_AUDIO_STATUS *audio_handle = NULL; - list_node_t *node = NULL; - - for (node = list_begin(app_audio_conifg.audio_list); node != list_end(app_audio_conifg.audio_list); node = list_next(node)) { - - audio_handle = (APP_AUDIO_STATUS *)list_node(node); - if(audio_handle == NULL) - { - return false; - } - if (audio_handle->id == APP_BT_STREAM_HFP_PCM || - audio_handle->id == APP_BT_STREAM_HFP_CVSD || - audio_handle->id == APP_BT_STREAM_HFP_VENDOR || - audio_handle->id == APP_BT_STREAM_A2DP_SBC || - audio_handle->id == APP_BT_STREAM_A2DP_AAC || + if (audio_handle->id == APP_BT_STREAM_HFP_PCM || + audio_handle->id == APP_BT_STREAM_HFP_CVSD || + audio_handle->id == APP_BT_STREAM_HFP_VENDOR || + audio_handle->id == APP_BT_STREAM_A2DP_SBC || + audio_handle->id == APP_BT_STREAM_A2DP_AAC || #ifdef VOICE_DATAPATH - audio_handle->id == APP_BT_STREAM_VOICEPATH || + audio_handle->id == APP_BT_STREAM_VOICEPATH || #endif #ifdef __AI_VOICE__ - audio_handle->id == APP_BT_STREAM_AI_VOICE || + audio_handle->id == APP_BT_STREAM_AI_VOICE || #endif #ifdef __THIRDPARTY - audio_handle->id == APP_BT_STREAM_THIRDPARTY_VOICE || + audio_handle->id == APP_BT_STREAM_THIRDPARTY_VOICE || #endif - audio_handle->id == APP_BT_STREAM_A2DP_VENDOR - ) { - TRACE_AUD_HDL_I("[STREAM_LIST][EXIST] id 0x%x", audio_handle->id); - return true; - } + audio_handle->id == APP_BT_STREAM_A2DP_VENDOR) { + TRACE_AUD_HDL_I("[STREAM_LIST][EXIST] id 0x%x", audio_handle->id); + return true; } + } - return false; + return false; } -bool app_audio_list_filter_exist(APP_AUDIO_STATUS* aud_status) -{ +bool app_audio_list_filter_exist(APP_AUDIO_STATUS *aud_status) { #ifdef MEDIA_PLAYER_SUPPORT - APP_AUDIO_STATUS *audio_handle = NULL; - list_node_t *node = NULL; - uint8_t cnt = 0; + APP_AUDIO_STATUS *audio_handle = NULL; + list_node_t *node = NULL; + uint8_t cnt = 0; - if (aud_status->id == APP_PLAY_BACK_AUDIO){ - if(aud_status->aud_id == AUD_ID_BT_CALL_INCOMING_CALL) { - for (node = list_begin(app_audio_conifg.audio_list); node != list_end(app_audio_conifg.audio_list); node = list_next(node)) { - audio_handle = (APP_AUDIO_STATUS *)list_node(node); - if(audio_handle == NULL) - { - return false; - } - if (audio_handle->id == APP_PLAY_BACK_AUDIO && audio_handle->aud_id == AUD_ID_BT_CALL_INCOMING_CALL) { - TRACE_AUD_HDL_I("[STREAM_LIST][FILTER] id 0x%x", audio_handle->id); - return true; - } - } - } else { - for (node = list_begin(app_audio_conifg.audio_list); node != list_end(app_audio_conifg.audio_list); node = list_next(node)) { - audio_handle = (APP_AUDIO_STATUS *)list_node(node); - if (cnt++ > 1) { - TRACE_AUD_HDL_I("[STREAM_LIST][FILTER] cnt %d", cnt); - return true; - } - } - } - } -#endif - return false; -} - -bool app_audio_list_playback_exist(void) -{ -#ifdef MEDIA_PLAYER_SUPPORT - APP_AUDIO_STATUS *audio_handle = NULL; - list_node_t *node = NULL; - - for (node = list_begin(app_audio_conifg.audio_list); node != list_end(app_audio_conifg.audio_list); node = list_next(node)) { + if (aud_status->id == APP_PLAY_BACK_AUDIO) { + if (aud_status->aud_id == AUD_ID_BT_CALL_INCOMING_CALL) { + for (node = list_begin(app_audio_conifg.audio_list); + node != list_end(app_audio_conifg.audio_list); + node = list_next(node)) { audio_handle = (APP_AUDIO_STATUS *)list_node(node); - if(audio_handle == NULL) - { - return false; + if (audio_handle == NULL) { + return false; } - if (audio_handle->id == APP_PLAY_BACK_AUDIO) { - TRACE_AUD_HDL_I("[STREAM_LIST][PLAYBACK_EXIST]"); - return true; + if (audio_handle->id == APP_PLAY_BACK_AUDIO && + audio_handle->aud_id == AUD_ID_BT_CALL_INCOMING_CALL) { + TRACE_AUD_HDL_I("[STREAM_LIST][FILTER] id 0x%x", audio_handle->id); + return true; } - } -#endif - return false; -} - -void app_audio_list_playback_clear(void) -{ -#ifdef MEDIA_PLAYER_SUPPORT - APP_AUDIO_STATUS *audio_handle = NULL; - list_node_t *node = NULL; - - for (node = list_begin(app_audio_conifg.audio_list); node != list_end(app_audio_conifg.audio_list); node = list_next(node)) { + } + } else { + for (node = list_begin(app_audio_conifg.audio_list); + node != list_end(app_audio_conifg.audio_list); + node = list_next(node)) { audio_handle = (APP_AUDIO_STATUS *)list_node(node); - if(audio_handle == NULL) - { - TRACE_AUD_HDL_I("[STREAM_LIST][CLR] find null\n "); - return; - } - if (audio_handle->id == APP_PLAY_BACK_AUDIO){ - list_remove(app_audio_conifg.audio_list, list_node(node)); + if (cnt++ > 1) { + TRACE_AUD_HDL_I("[STREAM_LIST][FILTER] cnt %d", cnt); + return true; } + } } + } #endif + return false; } -bool app_audio_list_append(APP_AUDIO_STATUS* aud_status) -{ - APP_AUDIO_STATUS *data_to_append = NULL; - bool add_data_to_head_of_list = false; - bool ret = true; - TRACE_AUD_HDL_I("[STREAM_LIST][APPEND] id 0x%x%s", aud_status->id, player2str(aud_status->id)); +bool app_audio_list_playback_exist(void) { #ifdef MEDIA_PLAYER_SUPPORT - if (aud_status->id == APP_PLAY_BACK_AUDIO) - { - //ignore redundant ring ind from hfp... - if (app_audio_list_filter_exist(aud_status)) - { - return false; - } + APP_AUDIO_STATUS *audio_handle = NULL; + list_node_t *node = NULL; - if (app_audio_list_playback_exist()) - { - if (list_length(app_audio_conifg.audio_list) >= MAX_AUDIO_BUF_LIST) - { - if (app_audio_list_stream_exist()) - { - data_to_append = (APP_AUDIO_STATUS *)osPoolCAlloc (app_audio_status_mempool); - if(data_to_append == NULL) - { - return false; - } - memcpy(data_to_append, (const void *)list_front(app_audio_conifg.audio_list), sizeof(APP_AUDIO_STATUS)); - add_data_to_head_of_list = true; - } - - app_audio_list_clear(); - TRACE_AUD_HDL_E("[STREAM_LIST][APPEND] FIXME!!!!\n "); - } - else - { - ret = false; - } - } + for (node = list_begin(app_audio_conifg.audio_list); + node != list_end(app_audio_conifg.audio_list); node = list_next(node)) { + audio_handle = (APP_AUDIO_STATUS *)list_node(node); + if (audio_handle == NULL) { + return false; } - else + if (audio_handle->id == APP_PLAY_BACK_AUDIO) { + TRACE_AUD_HDL_I("[STREAM_LIST][PLAYBACK_EXIST]"); + return true; + } + } #endif - { - add_data_to_head_of_list = true; - } - - if (data_to_append == NULL) - { - data_to_append = (APP_AUDIO_STATUS *)osPoolCAlloc (app_audio_status_mempool); - if(data_to_append == NULL) - { - return false; - } - memcpy(data_to_append, aud_status, sizeof(APP_AUDIO_STATUS)); - } - - if (add_data_to_head_of_list) - { - list_prepend(app_audio_conifg.audio_list, (void*)data_to_append); - } - else - { - list_append(app_audio_conifg.audio_list, (void*)data_to_append); - } - - TRACE_AUD_HDL_I("[STREAM_LIST][APPEND] id 0x%x%s status %d len %d ret %d", data_to_append->id, player2str(data_to_append->id), \ - data_to_append->status, list_length(app_audio_conifg.audio_list), ret); - return ret; + return false; } -bool app_audio_list_rmv_callback(APP_AUDIO_STATUS *status_close, APP_AUDIO_STATUS *status_next, enum APP_BT_AUDIO_Q_POS pos, bool pop_next) -{ - void *data_to_remove = NULL; - bool ret = false; +void app_audio_list_playback_clear(void) { +#ifdef MEDIA_PLAYER_SUPPORT + APP_AUDIO_STATUS *audio_handle = NULL; + list_node_t *node = NULL; - //for status: first bt_a2dp->APP_BT_SETTING_CLOSE,then ring-> APP_BT_SETTING_CLOSE - TRACE_AUD_HDL_I("[STREAM_LIST][RMV] audio list len %d close_id 0x%x%s", list_length(app_audio_conifg.audio_list), \ - status_close->id, player2str(status_close->id)); - if(list_length(app_audio_conifg.audio_list) == 0) - { - return false; + for (node = list_begin(app_audio_conifg.audio_list); + node != list_end(app_audio_conifg.audio_list); node = list_next(node)) { + audio_handle = (APP_AUDIO_STATUS *)list_node(node); + if (audio_handle == NULL) { + TRACE_AUD_HDL_I("[STREAM_LIST][CLR] find null\n "); + return; } + if (audio_handle->id == APP_PLAY_BACK_AUDIO) { + list_remove(app_audio_conifg.audio_list, list_node(node)); + } + } +#endif +} + +bool app_audio_list_append(APP_AUDIO_STATUS *aud_status) { + APP_AUDIO_STATUS *data_to_append = NULL; + bool add_data_to_head_of_list = false; + bool ret = true; + TRACE_AUD_HDL_I("[STREAM_LIST][APPEND] id 0x%x%s", aud_status->id, + player2str(aud_status->id)); +#ifdef MEDIA_PLAYER_SUPPORT + if (aud_status->id == APP_PLAY_BACK_AUDIO) { + // ignore redundant ring ind from hfp... + if (app_audio_list_filter_exist(aud_status)) { + return false; + } + + if (app_audio_list_playback_exist()) { + if (list_length(app_audio_conifg.audio_list) >= MAX_AUDIO_BUF_LIST) { + if (app_audio_list_stream_exist()) { + data_to_append = + (APP_AUDIO_STATUS *)osPoolCAlloc(app_audio_status_mempool); + if (data_to_append == NULL) { + return false; + } + memcpy(data_to_append, + (const void *)list_front(app_audio_conifg.audio_list), + sizeof(APP_AUDIO_STATUS)); + add_data_to_head_of_list = true; + } + + app_audio_list_clear(); + TRACE_AUD_HDL_E("[STREAM_LIST][APPEND] FIXME!!!!\n "); + } else { + ret = false; + } + } + } else +#endif + { + add_data_to_head_of_list = true; + } + + if (data_to_append == NULL) { + data_to_append = (APP_AUDIO_STATUS *)osPoolCAlloc(app_audio_status_mempool); + if (data_to_append == NULL) { + return false; + } + memcpy(data_to_append, aud_status, sizeof(APP_AUDIO_STATUS)); + } + + if (add_data_to_head_of_list) { + list_prepend(app_audio_conifg.audio_list, (void *)data_to_append); + } else { + list_append(app_audio_conifg.audio_list, (void *)data_to_append); + } + + TRACE_AUD_HDL_I("[STREAM_LIST][APPEND] id 0x%x%s status %d len %d ret %d", + data_to_append->id, player2str(data_to_append->id), + data_to_append->status, + list_length(app_audio_conifg.audio_list), ret); + return ret; +} + +bool app_audio_list_rmv_callback(APP_AUDIO_STATUS *status_close, + APP_AUDIO_STATUS *status_next, + enum APP_BT_AUDIO_Q_POS pos, bool pop_next) { + void *data_to_remove = NULL; + bool ret = false; + + // for status: first bt_a2dp->APP_BT_SETTING_CLOSE,then ring-> + // APP_BT_SETTING_CLOSE + TRACE_AUD_HDL_I("[STREAM_LIST][RMV] audio list len %d close_id 0x%x%s", + list_length(app_audio_conifg.audio_list), status_close->id, + player2str(status_close->id)); + if (list_length(app_audio_conifg.audio_list) == 0) { + return false; + } #ifdef MEDIA_PLAYER_SUPPORT - APP_AUDIO_STATUS *audio_handle = NULL; - list_node_t *node = NULL; - if (status_close->id == APP_PLAY_BACK_AUDIO) - { - for (node = list_begin(app_audio_conifg.audio_list); node != list_end(app_audio_conifg.audio_list); node = list_next(node)) - { - audio_handle = (APP_AUDIO_STATUS *)list_node(node); - if(audio_handle == NULL) - { - return ret; - } - if (audio_handle->id == APP_PLAY_BACK_AUDIO) - { - list_node_t *nod_next = list_next(node); - data_to_remove = list_node(node); + APP_AUDIO_STATUS *audio_handle = NULL; + list_node_t *node = NULL; + if (status_close->id == APP_PLAY_BACK_AUDIO) { + for (node = list_begin(app_audio_conifg.audio_list); + node != list_end(app_audio_conifg.audio_list); + node = list_next(node)) { + audio_handle = (APP_AUDIO_STATUS *)list_node(node); + if (audio_handle == NULL) { + return ret; + } + if (audio_handle->id == APP_PLAY_BACK_AUDIO) { + list_node_t *nod_next = list_next(node); + data_to_remove = list_node(node); - if (pop_next) - { - memcpy(status_next, list_node(node), sizeof(APP_AUDIO_STATUS)); - ret = true; - break; - } - if (nod_next != NULL) - { - memcpy(status_next, list_node(nod_next), sizeof(APP_AUDIO_STATUS)); - ASSERT(status_next->id == APP_PLAY_BACK_AUDIO, "[%s] 111ERROR: status_next->id != APP_PLAY_BACK_AUDIO", __func__); - - ret = true; - } - else if (app_audio_list_stream_exist()) - { - void *indata = list_front(app_audio_conifg.audio_list); - if(indata == NULL) - { - return ret; - } - memcpy(status_next, indata, sizeof(APP_AUDIO_STATUS)); - ASSERT(status_next->id != APP_PLAY_BACK_AUDIO, "[%s] 222ERROR: status_next->id != APP_PLAY_BACK_AUDIO", __func__); - - ret = true; - } - break; - } + if (pop_next) { + memcpy(status_next, list_node(node), sizeof(APP_AUDIO_STATUS)); + ret = true; + break; } + if (nod_next != NULL) { + memcpy(status_next, list_node(nod_next), sizeof(APP_AUDIO_STATUS)); + ASSERT(status_next->id == APP_PLAY_BACK_AUDIO, + "[%s] 111ERROR: status_next->id != APP_PLAY_BACK_AUDIO", + __func__); + + ret = true; + } else if (app_audio_list_stream_exist()) { + void *indata = list_front(app_audio_conifg.audio_list); + if (indata == NULL) { + return ret; + } + memcpy(status_next, indata, sizeof(APP_AUDIO_STATUS)); + ASSERT(status_next->id != APP_PLAY_BACK_AUDIO, + "[%s] 222ERROR: status_next->id != APP_PLAY_BACK_AUDIO", + __func__); + + ret = true; + } + break; + } } - else //maybe...a2dp send >> APP_BT_SETTING_CLOSE, when ring + } else // maybe...a2dp send >> APP_BT_SETTING_CLOSE, when ring #endif - { - if (app_audio_list_stream_exist()) - { - if(pos == APP_BT_SETTING_Q_POS_HEAD) - { - data_to_remove = list_front(app_audio_conifg.audio_list); - } - else if (pos == APP_BT_SETTING_Q_POS_TAIL) - { - data_to_remove = list_back(app_audio_conifg.audio_list); - } - } + { + if (app_audio_list_stream_exist()) { + if (pos == APP_BT_SETTING_Q_POS_HEAD) { + data_to_remove = list_front(app_audio_conifg.audio_list); + } else if (pos == APP_BT_SETTING_Q_POS_TAIL) { + data_to_remove = list_back(app_audio_conifg.audio_list); + } } + } - if (data_to_remove) - { - list_remove(app_audio_conifg.audio_list, data_to_remove); - } - TRACE_AUD_HDL_I("[STREAM_LIST][RMV] end len:%d ret %d data %p", list_length(app_audio_conifg.audio_list), ret, data_to_remove); - return ret; + if (data_to_remove) { + list_remove(app_audio_conifg.audio_list, data_to_remove); + } + TRACE_AUD_HDL_I("[STREAM_LIST][RMV] end len:%d ret %d data %p", + list_length(app_audio_conifg.audio_list), ret, + data_to_remove); + return ret; } -void app_audio_list_clear() -{ - list_clear(app_audio_conifg.audio_list); -} +void app_audio_list_clear() { list_clear(app_audio_conifg.audio_list); } #endif -void app_audio_open(void) -{ - if(app_audio_init) - { - return; - } - if (g_app_audio_queue_mutex_id == NULL) - { - g_app_audio_queue_mutex_id = osMutexCreate((osMutex(g_app_audio_queue_mutex))); - } - else - { - ASSERT(0, "[%s] ERROR: g_app_audio_queue_mutex_id != NULL", __func__); - } +void app_audio_open(void) { + if (app_audio_init) { + return; + } + if (g_app_audio_queue_mutex_id == NULL) { + g_app_audio_queue_mutex_id = + osMutexCreate((osMutex(g_app_audio_queue_mutex))); + } else { + ASSERT(0, "[%s] ERROR: g_app_audio_queue_mutex_id != NULL", __func__); + } - if (app_audio_status_mempool == NULL) - app_audio_status_mempool = osPoolCreate(osPool(app_audio_status_mempool)); - ASSERT(app_audio_status_mempool, "[%s] ERROR: app_audio_status_mempool != NULL", __func__); + if (app_audio_status_mempool == NULL) + app_audio_status_mempool = osPoolCreate(osPool(app_audio_status_mempool)); + ASSERT(app_audio_status_mempool, + "[%s] ERROR: app_audio_status_mempool != NULL", __func__); #ifdef __AUDIO_QUEUE_SUPPORT__ - app_audio_list_create(); + app_audio_list_create(); #endif - app_ring_merge_init(); + app_ring_merge_init(); - app_set_threadhandle(APP_MODUAL_AUDIO, app_audio_handle_process); + app_set_threadhandle(APP_MODUAL_AUDIO, app_audio_handle_process); - app_bt_stream_init(); + app_bt_stream_init(); - app_audio_init = true; + app_audio_init = true; } -void app_audio_close(void) -{ - app_set_threadhandle(APP_MODUAL_AUDIO, NULL); - app_audio_init = false; +void app_audio_close(void) { + app_set_threadhandle(APP_MODUAL_AUDIO, NULL); + app_audio_init = false; } - - diff --git a/apps/audioplayers/bt_sco_chain.c b/apps/audioplayers/bt_sco_chain.c index 1ef715a..44100c8 100644 --- a/apps/audioplayers/bt_sco_chain.c +++ b/apps/audioplayers/bt_sco_chain.c @@ -19,70 +19,89 @@ // RX: Receive process // 16k: base 25M/208M(1300,1302) base 28M/104M(1400,1402) |-------|--------------------|-----------------------------------|----------------------------------|-----------|----------------------| -| TX/RX | New | Old | description | MIPS(M) | Note | -| | | | | 16k 8k | | +| TX/RX | New | Old | description +| MIPS(M) | Note | | | | | | 16k 8k | +| |-------|--------------------|-----------------------------------|----------------------------------|-----------|----------------------| -| | SPEECH_TX_DC_FILTER| | Direct Current filter | 1~2 \ | | -| | SPEECH_TX_AEC | SPEECH_ECHO_CANCEL | Acoustic Echo Cancellation(old) | 40 \ | HWFFT: 37 | -| | SPEECH_TX_AEC2 | SPEECH_AEC_FIX | Acoustic Echo Cancellation(new) | 39 \ | enable NLP | -| | SPEECH_TX_AEC3 | | Acoustic Echo Cancellation(new) | 14/18 \ | 2 filters/4 filters | -| | SPEECH_TX_AEC2FLOAT| | Acoustic Echo Cancellation(new) | 23/22 \ | nlp/af(blocks=1) | -| | SPEECH_TX_AEC2FLOAT| | Acoustic Echo Cancellation(ns) | 14/10 \ | banks=256/banks=128 | -| | (ns_enabled) | | | 8/6 \ | banks=64/banks=32 | -| | SPEECH_TX_NS | SPEECH_NOISE_SUPPRESS | 1 mic noise suppress(old) | 30 \ | HWFFT: 19 | -| | SPEECH_TX_NS2 | LC_MMSE_NOISE_SUPPRESS | 1 mic noise suppress(new) | 16 \ | HWFFT: 12 | -| | SPEECH_TX_NS3 | | 1 mic noise suppress(new) | 26 \ | | -| | SPEECH_TX_NS2FLOAT | LC_MMSE_NOISE_SUPPRESS_FLOAT | 1 mic noise suppress(new float) | 12.5 \ | banks=64 | -| TX | SPEECH_TX_2MIC_NS | DUAL_MIC_DENOISE | 2 mic noise suppres(long space) | \ | | -| | SPEECH_TX_2MIC_NS2 | 2MIC_DENOISE | 2 mic noise suppres(short space) | 22 | delay_taps 5M | -| | freq_smooth_enable 1.5M | | -| | wnr_enable 1.5M | -| | SPEECH_TX_2MIC_NS4 | SENSORMIC_DENOISE | sensor mic noise suppress | 31.5 | | -| | SPEECH_TX_2MIC_NS3 | FAR_FIELD_SPEECH_ENHANCEMENT | 2 mic noise suppres(far field) | \ | | -| | SPEECH_TX_2MIC_NS5 | LEFTRIGHT_DENOISE | 2 mic noise suppr(left right end)| \ | | -| | SPEECH_TX_2MIC_NS6 | FF_2MIC_DENOISE | 2 mic noise suppr(far field) | 70 | | -| | SPEECH_TX_AGC | SPEECH_AGC | Automatic Gain Control | 3 | | -| | SPEECH_TX_COMPEXP | | Compressor and expander | 4 | | -| | SPEECH_TX_EQ | SPEECH_WEIGHTING_FILTER_SUPPRESS | Default EQ | 0.5 \ | each section | +| | SPEECH_TX_DC_FILTER| | Direct +Current filter | 1~2 \ | | | | +SPEECH_TX_AEC | SPEECH_ECHO_CANCEL | Acoustic Echo +Cancellation(old) | 40 \ | HWFFT: 37 | | | SPEECH_TX_AEC2 +| SPEECH_AEC_FIX | Acoustic Echo Cancellation(new) | 39 \ | +enable NLP | | | SPEECH_TX_AEC3 | | Acoustic Echo +Cancellation(new) | 14/18 \ | 2 filters/4 filters | | | +SPEECH_TX_AEC2FLOAT| | Acoustic Echo +Cancellation(new) | 23/22 \ | nlp/af(blocks=1) | | | +SPEECH_TX_AEC2FLOAT| | Acoustic Echo +Cancellation(ns) | 14/10 \ | banks=256/banks=128 | | | (ns_enabled) +| | | 8/6 \ +| banks=64/banks=32 | | | SPEECH_TX_NS | SPEECH_NOISE_SUPPRESS | +1 mic noise suppress(old) | 30 \ | HWFFT: 19 | | | +SPEECH_TX_NS2 | LC_MMSE_NOISE_SUPPRESS | 1 mic noise +suppress(new) | 16 \ | HWFFT: 12 | | | +SPEECH_TX_NS3 | | 1 mic noise +suppress(new) | 26 \ | | | | +SPEECH_TX_NS2FLOAT | LC_MMSE_NOISE_SUPPRESS_FLOAT | 1 mic noise +suppress(new float) | 12.5 \ | banks=64 | | TX | +SPEECH_TX_2MIC_NS | DUAL_MIC_DENOISE | 2 mic noise +suppres(long space) | \ | | | | +SPEECH_TX_2MIC_NS2 | 2MIC_DENOISE | 2 mic noise +suppres(short space) | 22 | delay_taps 5M | | | +freq_smooth_enable 1.5M | | | | wnr_enable 1.5M | | +| SPEECH_TX_2MIC_NS4 | SENSORMIC_DENOISE | sensor mic noise +suppress | 31.5 | | | | +SPEECH_TX_2MIC_NS3 | FAR_FIELD_SPEECH_ENHANCEMENT | 2 mic noise suppres(far +field) | \ | | | | SPEECH_TX_2MIC_NS5 | +LEFTRIGHT_DENOISE | 2 mic noise suppr(left right end)| \ | | | +| SPEECH_TX_2MIC_NS6 | FF_2MIC_DENOISE | 2 mic noise suppr(far +field) | 70 | | | | SPEECH_TX_AGC | +SPEECH_AGC | Automatic Gain Control | 3 | | | +| SPEECH_TX_COMPEXP | | Compressor and +expander | 4 | | | | SPEECH_TX_EQ | +SPEECH_WEIGHTING_FILTER_SUPPRESS | Default EQ | 0.5 \ +| each section | |-------|--------------------|-----------------------------------|----------------------------------|-----------|----------------------| -| | SPEECH_RX_NS | SPEAKER_NOISE_SUPPRESS | 1 mic noise suppress(old) | 30 \ | | -| RX | SPEECH_RX_NS2 | LC_MMSE_NOISE_SUPPRESS_SPK | 1 mic noise suppress(new) | 16 \ | | -| | SPEECH_RX_AGC | SPEECH_AGC_SPK | Automatic Gain Control | 3 | | -| | SPEECH_RX_EQ | SPEAKER_WEIGHTING_FILTER_SUPPRESS | Default EQ | 0.5 \ | each section | +| | SPEECH_RX_NS | SPEAKER_NOISE_SUPPRESS | 1 mic noise +suppress(old) | 30 \ | | | RX | +SPEECH_RX_NS2 | LC_MMSE_NOISE_SUPPRESS_SPK | 1 mic noise +suppress(new) | 16 \ | | | | +SPEECH_RX_AGC | SPEECH_AGC_SPK | Automatic Gain Control +| 3 | | | | SPEECH_RX_EQ | +SPEAKER_WEIGHTING_FILTER_SUPPRESS | Default EQ | 0.5 \ +| each section | |-------|--------------------|-----------------------------------|----------------------------------|-----------|----------------------| **/ -#include "plat_types.h" -#include "hal_trace.h" -#include "hal_timer.h" -#include "audio_dump.h" -#include "speech_cfg.h" #include "bt_sco_chain.h" +#include "audio_dump.h" #include "bt_sco_chain_cfg.h" #include "bt_sco_chain_tuning.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "plat_types.h" +#include "speech_cfg.h" #if defined(SPEECH_TX_2MIC_NS4) #include "app_anc.h" #endif #include "app_utils.h" #if defined(SCO_CP_ACCEL) -#include "hal_location.h" #include "bt_sco_chain_cp.h" +#include "hal_location.h" #define SCO_CP_ACCEL_ALGO_START() \ - *_pcm_len = pcm_len; \ - } \ - CP_TEXT_SRAM_LOC \ - void _speech_tx_process_mid(short *pcm_buf, short *ref_buf, int *_pcm_len) \ - { \ - int pcm_len = *_pcm_len; + *_pcm_len = pcm_len; \ + } \ + CP_TEXT_SRAM_LOC \ + void _speech_tx_process_mid(short *pcm_buf, short *ref_buf, int *_pcm_len) { \ + int pcm_len = *_pcm_len; -#define SCO_CP_ACCEL_ALGO_END() \ - *_pcm_len = pcm_len; \ - } \ - void _speech_tx_process_post(short *pcm_buf, short *ref_buf, int *_pcm_len) \ - { \ - int pcm_len = *_pcm_len; +#define SCO_CP_ACCEL_ALGO_END() \ + *_pcm_len = pcm_len; \ + } \ + void _speech_tx_process_post(short *pcm_buf, short *ref_buf, \ + int *_pcm_len) { \ + int pcm_len = *_pcm_len; #define SPEECH_TX_AEC2FLOAT_CORE 1 #define SPEECH_TX_NS2FLOAT_CORE 0 @@ -125,7 +144,8 @@ static int32_t *tx_pcmbuf32 = NULL; short *aec_echo_buf = NULL; #endif -#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) +#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || \ + defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) // Use to free buffer #if defined(SPEECH_TX_24BIT) static int32_t *aec_echo_buf_ptr; @@ -152,7 +172,6 @@ SpeechFirCalibState *speech_tx_mic_fir_calib_st = NULL; extern const SpeechFirCalibConfig speech_tx_mic_fir_calib_cfg; #endif - // AEC #if defined(SPEECH_TX_AEC) SpeechAecState *speech_tx_aec_st = NULL; @@ -167,17 +186,12 @@ SpeechAec2State *speech_tx_aec2_st = NULL; short delay = 70; short bufferstate[356]; short buf_out[256]; -void CODEC_OpVecCpy( - short *pshwDes, - short *pshwSrc, - short swLen) -{ - short i = 0; +void CODEC_OpVecCpy(short *pshwDes, short *pshwSrc, short swLen) { + short i = 0; - for (i = 0; i < swLen; i++) - { - pshwDes[i] = pshwSrc[i]; - } + for (i = 0; i < swLen; i++) { + pshwDes[i] = pshwSrc[i]; + } } SubBandAecState *speech_tx_aec3_st = NULL; @@ -189,7 +203,8 @@ static Ec2FloatState *speech_tx_aec2float_st = NULL; // 2MIC NS #if defined(SPEECH_TX_2MIC_NS) -// float mic2_ft_caliration[] = {0.395000,0.809000,0.939000,1.748000,1.904000,1.957000,1.944000,1.906000,1.935000,1.940000,1.937000,1.931000,1.929000,1.911000,1.887000,1.871000,1.846000,1.779000,1.748000,2.086000,2.055000,2.002000,1.903000,1.885000,1.854000,1.848000,1.848000,1.844000,1.852000,1.870000,1.866000,1.843000,1.838000,1.824000,1.861000,1.871000,1.866000,1.833000,1.800000,1.769000,1.749000,1.690000,1.664000,1.573000,1.602000,1.692000,1.759000,1.758000,1.698000,1.628000,1.525000,1.509000,1.492000,1.515000,1.530000,1.644000,1.653000,1.617000,1.667000,1.746000,1.663000,1.606000,1.560000,1.500000,1.579000,1.632000,1.623000,1.549000,1.524000,1.512000,1.493000,1.476000,1.421000,1.396000,1.386000,1.459000,1.463000,1.496000,1.568000,1.544000,1.555000,1.547000,1.619000,1.630000,1.574000,1.491000,1.414000,1.383000,1.352000,1.464000,1.474000,1.450000,1.419000,1.425000,1.411000,1.479000,1.517000,1.486000,1.428000,1.389000,1.330000,1.284000,1.267000,1.249000,1.256000,1.215000,1.250000,1.402000,1.386000,1.334000,1.287000,1.329000,1.337000,1.292000,1.226000,1.212000,1.142000,1.087000,1.086000,1.112000,1.145000,1.194000,1.163000,1.131000,1.162000,1.166000,1.259000,1.218000,1.218000,1.322000,1.347000,1.436000,1.890000,1.693000,1.591000,1.518000,1.422000,1.345000,1.331000,1.308000,1.330000,1.305000,1.218000,1.286000,1.340000,1.399000,1.406000,1.353000,1.280000,1.246000,1.185000,1.129000,1.014000,0.985000,0.981000,1.189000,1.533000,1.694000,1.613000,1.464000,1.419000,1.448000,1.449000,1.442000,1.367000,1.283000,1.232000,1.381000,1.484000,1.497000,1.554000,1.438000,1.365000,1.326000,1.332000,1.335000,1.367000,1.301000,1.288000,1.168000,1.103000,1.067000,1.026000,1.076000,1.126000,1.068000,1.045000,0.978000,0.926000,0.939000,0.854000,0.772000,0.902000,0.742000,1.073000,1.220000,1.177000,1.762000,1.573000,1.390000,1.406000,1.148000,1.054000,1.210000,1.344000,1.849000,2.078000,1.756000,1.646000,1.597000,1.447000,1.322000,1.279000,1.007000,0.921000,0.871000,0.864000,1.067000,1.129000,1.128000,1.027000,0.983000,0.889000,0.774000,0.759000,0.724000,0.949000,1.237000,1.499000,1.658000,1.837000,1.492000,1.452000,1.151000,1.100000,0.996000,0.986000,1.023000,1.071000,1.252000,1.295000,1.309000,1.343000,1.220000,1.161000,1.142000,1.041000,0.974000,0.885000,0.799000,0.669000,0.732000,0.953000,0.861000,0.881000,0.988000,0.891000}; +// float mic2_ft_caliration[] = +// {0.395000,0.809000,0.939000,1.748000,1.904000,1.957000,1.944000,1.906000,1.935000,1.940000,1.937000,1.931000,1.929000,1.911000,1.887000,1.871000,1.846000,1.779000,1.748000,2.086000,2.055000,2.002000,1.903000,1.885000,1.854000,1.848000,1.848000,1.844000,1.852000,1.870000,1.866000,1.843000,1.838000,1.824000,1.861000,1.871000,1.866000,1.833000,1.800000,1.769000,1.749000,1.690000,1.664000,1.573000,1.602000,1.692000,1.759000,1.758000,1.698000,1.628000,1.525000,1.509000,1.492000,1.515000,1.530000,1.644000,1.653000,1.617000,1.667000,1.746000,1.663000,1.606000,1.560000,1.500000,1.579000,1.632000,1.623000,1.549000,1.524000,1.512000,1.493000,1.476000,1.421000,1.396000,1.386000,1.459000,1.463000,1.496000,1.568000,1.544000,1.555000,1.547000,1.619000,1.630000,1.574000,1.491000,1.414000,1.383000,1.352000,1.464000,1.474000,1.450000,1.419000,1.425000,1.411000,1.479000,1.517000,1.486000,1.428000,1.389000,1.330000,1.284000,1.267000,1.249000,1.256000,1.215000,1.250000,1.402000,1.386000,1.334000,1.287000,1.329000,1.337000,1.292000,1.226000,1.212000,1.142000,1.087000,1.086000,1.112000,1.145000,1.194000,1.163000,1.131000,1.162000,1.166000,1.259000,1.218000,1.218000,1.322000,1.347000,1.436000,1.890000,1.693000,1.591000,1.518000,1.422000,1.345000,1.331000,1.308000,1.330000,1.305000,1.218000,1.286000,1.340000,1.399000,1.406000,1.353000,1.280000,1.246000,1.185000,1.129000,1.014000,0.985000,0.981000,1.189000,1.533000,1.694000,1.613000,1.464000,1.419000,1.448000,1.449000,1.442000,1.367000,1.283000,1.232000,1.381000,1.484000,1.497000,1.554000,1.438000,1.365000,1.326000,1.332000,1.335000,1.367000,1.301000,1.288000,1.168000,1.103000,1.067000,1.026000,1.076000,1.126000,1.068000,1.045000,0.978000,0.926000,0.939000,0.854000,0.772000,0.902000,0.742000,1.073000,1.220000,1.177000,1.762000,1.573000,1.390000,1.406000,1.148000,1.054000,1.210000,1.344000,1.849000,2.078000,1.756000,1.646000,1.597000,1.447000,1.322000,1.279000,1.007000,0.921000,0.871000,0.864000,1.067000,1.129000,1.128000,1.027000,0.983000,0.889000,0.774000,0.759000,0.724000,0.949000,1.237000,1.499000,1.658000,1.837000,1.492000,1.452000,1.151000,1.100000,0.996000,0.986000,1.023000,1.071000,1.252000,1.295000,1.309000,1.343000,1.220000,1.161000,1.142000,1.041000,0.974000,0.885000,0.799000,0.669000,0.732000,0.953000,0.861000,0.881000,0.988000,0.891000}; #endif #if defined(SPEECH_TX_2MIC_NS2) @@ -298,17 +313,17 @@ SpeechGainState *speech_rx_post_gain_st = NULL; #endif #if defined(BONE_SENSOR_TDM) -#define SPEECH_TX_CHANNEL_NUM (SPEECH_CODEC_CAPTURE_CHANNEL_NUM + 1) +#define SPEECH_TX_CHANNEL_NUM (SPEECH_CODEC_CAPTURE_CHANNEL_NUM + 1) #else -#define SPEECH_TX_CHANNEL_NUM (SPEECH_CODEC_CAPTURE_CHANNEL_NUM) +#define SPEECH_TX_CHANNEL_NUM (SPEECH_CODEC_CAPTURE_CHANNEL_NUM) #endif static bool dualmic_enable = true; -void switch_dualmic_status(void) -{ - TRACE(3,"[%s] dualmic status: %d -> %d", __FUNCTION__, dualmic_enable, !dualmic_enable); - dualmic_enable ^= true; +void switch_dualmic_status(void) { + TRACE(3, "[%s] dualmic status: %d -> %d", __FUNCTION__, dualmic_enable, + !dualmic_enable); + dualmic_enable ^= true; } static int speech_tx_sample_rate = 16000; @@ -318,824 +333,847 @@ static int speech_rx_frame_len = 256; static bool speech_tx_frame_resizer_enable = false; static bool speech_rx_frame_resizer_enable = false; -static int32_t _speech_tx_process_(void *pcm_buf, void *ref_buf, int32_t *pcm_len); +static int32_t _speech_tx_process_(void *pcm_buf, void *ref_buf, + int32_t *pcm_len); static int32_t _speech_rx_process_(void *pcm_buf, int32_t *pcm_len); enum APP_SYSFREQ_FREQ_T speech_get_proper_sysfreq(int *needed_mips); +void *speech_get_ext_buff(int size) { + void *pBuff = NULL; + if (size % 4) { + size = size + (4 - size % 4); + } -void *speech_get_ext_buff(int size) -{ - void *pBuff = NULL; - if (size % 4) - { - size = size + (4 - size % 4); - } + pBuff = speech_calloc(size, sizeof(uint8_t)); + TRACE(2, "[%s] len:%d", __func__, size); - pBuff = speech_calloc(size, sizeof(uint8_t)); - TRACE(2,"[%s] len:%d", __func__, size); - - return pBuff; + return pBuff; } -int speech_store_config(const SpeechConfig *cfg) -{ - if (speech_cfg) - { - memcpy(speech_cfg, cfg, sizeof(SpeechConfig)); - } - else - { - TRACE(1,"[%s] WARNING: Please phone call...", __func__); - } +int speech_store_config(const SpeechConfig *cfg) { + if (speech_cfg) { + memcpy(speech_cfg, cfg, sizeof(SpeechConfig)); + } else { + TRACE(1, "[%s] WARNING: Please phone call...", __func__); + } - return 0; + return 0; } -int speech_tx_init(int sample_rate, int frame_len) -{ - TRACE(3,"[%s] Start, sample_rate: %d, frame_len: %d", __func__, sample_rate, frame_len); +int speech_tx_init(int sample_rate, int frame_len) { + TRACE(3, "[%s] Start, sample_rate: %d, frame_len: %d", __func__, sample_rate, + frame_len); #if defined(SPEECH_TX_DC_FILTER) - int channel_num = SPEECH_TX_CHANNEL_NUM; - int data_separation = 0; + int channel_num = SPEECH_TX_CHANNEL_NUM; + int data_separation = 0; - speech_tx_dc_filter_st = speech_dc_filter_create(sample_rate, &speech_cfg->tx_dc_filter); - speech_dc_filter_ctl(speech_tx_dc_filter_st, SPEECH_DC_FILTER_SET_CHANNEL_NUM, &channel_num); - speech_dc_filter_ctl(speech_tx_dc_filter_st, SPEECH_DC_FILTER_SET_DATA_SEPARATION, &data_separation); + speech_tx_dc_filter_st = + speech_dc_filter_create(sample_rate, &speech_cfg->tx_dc_filter); + speech_dc_filter_ctl(speech_tx_dc_filter_st, SPEECH_DC_FILTER_SET_CHANNEL_NUM, + &channel_num); + speech_dc_filter_ctl(speech_tx_dc_filter_st, + SPEECH_DC_FILTER_SET_DATA_SEPARATION, &data_separation); #endif #if defined(SPEECH_TX_MIC_CALIBRATION) - speech_tx_mic_calib_st = speech_iir_calib_init(sample_rate, frame_len, &speech_tx_mic_calib_cfg); + speech_tx_mic_calib_st = + speech_iir_calib_init(sample_rate, frame_len, &speech_tx_mic_calib_cfg); #endif #if defined(SPEECH_TX_MIC_FIR_CALIBRATION) - speech_tx_mic_fir_calib_st = speech_fir_calib_init(sample_rate, frame_len, &speech_tx_mic_fir_calib_cfg); + speech_tx_mic_fir_calib_st = speech_fir_calib_init( + sample_rate, frame_len, &speech_tx_mic_fir_calib_cfg); #endif -#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) -// #if !(defined(__AUDIO_RESAMPLE__) && defined(SW_SCO_RESAMPLE)) - aec_out_buf = (short *)speech_calloc(frame_len, sizeof(short)); +#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || \ + defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) + // #if !(defined(__AUDIO_RESAMPLE__) && defined(SW_SCO_RESAMPLE)) + aec_out_buf = (short *)speech_calloc(frame_len, sizeof(short)); #if defined(SPEECH_TX_24BIT) - aec_echo_buf = (int32_t *)speech_calloc(frame_len, sizeof(int32_t)); + aec_echo_buf = (int32_t *)speech_calloc(frame_len, sizeof(int32_t)); #else - aec_echo_buf = (short *)speech_calloc(frame_len, sizeof(short)); + aec_echo_buf = (short *)speech_calloc(frame_len, sizeof(short)); #endif - aec_echo_buf_ptr = aec_echo_buf; + aec_echo_buf_ptr = aec_echo_buf; // #endif #endif #if defined(SPEECH_TX_AEC) - speech_tx_aec_st = speech_aec_create(sample_rate, frame_len, &speech_cfg->tx_aec); - speech_aec_ctl(speech_tx_aec_st, SPEECH_AEC_GET_LIB_ST, &speech_tx_aec_lib_st); + speech_tx_aec_st = + speech_aec_create(sample_rate, frame_len, &speech_cfg->tx_aec); + speech_aec_ctl(speech_tx_aec_st, SPEECH_AEC_GET_LIB_ST, + &speech_tx_aec_lib_st); #endif #if defined(SPEECH_TX_AEC2) - speech_tx_aec2_st = speech_aec2_create(sample_rate, frame_len, &speech_cfg->tx_aec2); + speech_tx_aec2_st = + speech_aec2_create(sample_rate, frame_len, &speech_cfg->tx_aec2); #endif #if defined(SPEECH_TX_AEC3) - speech_tx_aec3_st = SubBandAec_init(sample_rate, frame_len, &speech_cfg->tx_aec3); + speech_tx_aec3_st = + SubBandAec_init(sample_rate, frame_len, &speech_cfg->tx_aec3); #endif #if defined(SPEECH_TX_AEC2FLOAT) - speech_tx_aec2float_st = ec2float_create(sample_rate, frame_len, SPEECH_TX_AEC2FLOAT_CORE, &speech_cfg->tx_aec2float); + speech_tx_aec2float_st = + ec2float_create(sample_rate, frame_len, SPEECH_TX_AEC2FLOAT_CORE, + &speech_cfg->tx_aec2float); #endif #if defined(SPEECH_TX_2MIC_NS) - dual_mic_denoise_init(sample_rate, frame_len, &speech_cfg->tx_2mic_ns, NULL); - // dual_mic_denoise_ctl(DUAL_MIC_DENOISE_SET_CALIBRATION_COEF, mic2_ft_caliration); + dual_mic_denoise_init(sample_rate, frame_len, &speech_cfg->tx_2mic_ns, NULL); + // dual_mic_denoise_ctl(DUAL_MIC_DENOISE_SET_CALIBRATION_COEF, + // mic2_ft_caliration); #endif #if defined(SPEECH_TX_2MIC_NS2) - speech_tx_2mic_ns2_st = speech_2mic_ns2_create(sample_rate, frame_len, &speech_cfg->tx_2mic_ns2); + speech_tx_2mic_ns2_st = + speech_2mic_ns2_create(sample_rate, frame_len, &speech_cfg->tx_2mic_ns2); #endif -// #if defined(SPEECH_CS_VAD) -// speech_cs_vad_st = VAD_process_state_init(sample_rate, 64, &speech_cfg->cs_vad); -// #endif + // #if defined(SPEECH_CS_VAD) + // speech_cs_vad_st = VAD_process_state_init(sample_rate, 64, + // &speech_cfg->cs_vad); + // #endif #if defined(SPEECH_TX_2MIC_NS3) - far_field_speech_enhancement_init(); - far_field_speech_enhancement_start(); + far_field_speech_enhancement_init(); + far_field_speech_enhancement_start(); #endif #if defined(SPEECH_TX_2MIC_NS5) - speech_tx_2mic_ns5_st = leftright_denoise_create(sample_rate, 64, &speech_cfg->tx_2mic_ns5); + speech_tx_2mic_ns5_st = + leftright_denoise_create(sample_rate, 64, &speech_cfg->tx_2mic_ns5); #endif #if defined(SPEECH_TX_2MIC_NS6) - speech_tx_2mic_ns6_st = speech_ff_2mic_ns2_create(16000,128); + speech_tx_2mic_ns6_st = speech_ff_2mic_ns2_create(16000, 128); #endif #if defined(SPEECH_TX_2MIC_NS4) - //speech_tx_2mic_ns4_st = sensormic_denoise_create(sample_rate, 64, &speech_cfg->tx_2mic_ns4); - speech_tx_2mic_ns4_st = sensormic_denoise_create(sample_rate, 128, 256, 31, &speech_cfg->tx_2mic_ns4); + // speech_tx_2mic_ns4_st = sensormic_denoise_create(sample_rate, 64, + // &speech_cfg->tx_2mic_ns4); + speech_tx_2mic_ns4_st = sensormic_denoise_create(sample_rate, 128, 256, 31, + &speech_cfg->tx_2mic_ns4); #endif #if defined(SPEECH_TX_3MIC_NS) - speech_tx_3mic_ns_st = speech_3mic_ns_create(sample_rate, 64, &speech_cfg->tx_3mic_ns); + speech_tx_3mic_ns_st = + speech_3mic_ns_create(sample_rate, 64, &speech_cfg->tx_3mic_ns); #endif #if defined(SPEECH_TX_3MIC_NS3) - speech_tx_3mic_ns3_st = triple_mic_denoise3_init(sample_rate, frame_len, &speech_cfg->tx_3mic_ns3); + speech_tx_3mic_ns3_st = triple_mic_denoise3_init(sample_rate, frame_len, + &speech_cfg->tx_3mic_ns3); #endif #if defined(SPEECH_TX_NS) - speech_tx_ns_st = speech_ns_create(sample_rate, frame_len, &speech_cfg->tx_ns); + speech_tx_ns_st = + speech_ns_create(sample_rate, frame_len, &speech_cfg->tx_ns); #if defined(SPEECH_TX_AEC) - speech_ns_ctl(speech_tx_ns_st, SPEECH_NS_SET_AEC_STATE, speech_tx_aec_lib_st); - int32_t echo_supress = -39; - speech_ns_ctl(speech_tx_ns_st, SPEECH_NS_SET_AEC_SUPPRESS, &echo_supress); + speech_ns_ctl(speech_tx_ns_st, SPEECH_NS_SET_AEC_STATE, speech_tx_aec_lib_st); + int32_t echo_supress = -39; + speech_ns_ctl(speech_tx_ns_st, SPEECH_NS_SET_AEC_SUPPRESS, &echo_supress); #endif #endif #if defined(SPEECH_TX_NS2) - speech_tx_ns2_st = speech_ns2_create(sample_rate, frame_len, &speech_cfg->tx_ns2); + speech_tx_ns2_st = + speech_ns2_create(sample_rate, frame_len, &speech_cfg->tx_ns2); #if defined(SPEECH_TX_AEC) - speech_ns2_set_echo_state(speech_tx_ns2_st, speech_tx_aec_lib_st); - speech_ns2_set_echo_suppress(speech_tx_ns2_st, -40); + speech_ns2_set_echo_state(speech_tx_ns2_st, speech_tx_aec_lib_st); + speech_ns2_set_echo_suppress(speech_tx_ns2_st, -40); #endif #endif #if defined(SPEECH_TX_NS2FLOAT) - speech_tx_ns2float_st = speech_ns2float_create(sample_rate, frame_len, SPEECH_TX_NS2FLOAT_CORE, &speech_cfg->tx_ns2float); + speech_tx_ns2float_st = + speech_ns2float_create(sample_rate, frame_len, SPEECH_TX_NS2FLOAT_CORE, + &speech_cfg->tx_ns2float); #if defined(SPEECH_TX_AEC) - speech_ns2float_set_echo_state(speech_tx_ns2float_st, speech_tx_aec_lib_st); - speech_ns2float_set_echo_suppress(speech_tx_ns2float_st, -40); + speech_ns2float_set_echo_state(speech_tx_ns2float_st, speech_tx_aec_lib_st); + speech_ns2float_set_echo_suppress(speech_tx_ns2float_st, -40); #endif #endif #if defined(SPEECH_TX_NS3) - speech_tx_ns3_st = ns3_create(sample_rate, frame_len, &speech_cfg->tx_ns3); + speech_tx_ns3_st = ns3_create(sample_rate, frame_len, &speech_cfg->tx_ns3); #endif #if defined(SPEECH_TX_WNR) - speech_tx_wnr_st = wnr_create(sample_rate, frame_len, &speech_cfg->tx_wnr); + speech_tx_wnr_st = wnr_create(sample_rate, frame_len, &speech_cfg->tx_wnr); #endif #if defined(SPEECH_TX_NOISE_GATE) - speech_tx_noise_gate_st = speech_noise_gate_create(sample_rate, frame_len, &speech_cfg->tx_noise_gate); + speech_tx_noise_gate_st = speech_noise_gate_create( + sample_rate, frame_len, &speech_cfg->tx_noise_gate); #endif #if defined(SPEECH_TX_COMPEXP) - speech_tx_compexp_st = compexp_create(sample_rate, frame_len, &speech_cfg->tx_compexp); + speech_tx_compexp_st = + compexp_create(sample_rate, frame_len, &speech_cfg->tx_compexp); #endif #if defined(SPEECH_TX_AGC) - speech_tx_agc_st = agc_state_create(sample_rate, frame_len, &speech_cfg->tx_agc); + speech_tx_agc_st = + agc_state_create(sample_rate, frame_len, &speech_cfg->tx_agc); #endif #if defined(SPEECH_TX_EQ) - speech_tx_eq_st = eq_init(sample_rate, frame_len, &speech_cfg->tx_eq); + speech_tx_eq_st = eq_init(sample_rate, frame_len, &speech_cfg->tx_eq); #endif #if defined(SPEECH_TX_POST_GAIN) - speech_tx_post_gain_st = speech_gain_create(sample_rate, frame_len, &speech_cfg->tx_post_gain); + speech_tx_post_gain_st = + speech_gain_create(sample_rate, frame_len, &speech_cfg->tx_post_gain); #endif - TRACE(1,"[%s] End", __func__); + TRACE(1, "[%s] End", __func__); - return 0; + return 0; } -int speech_rx_init(int sample_rate, int frame_len) -{ - TRACE(3,"[%s] Start, sample_rate: %d, frame_len: %d", __func__, sample_rate, frame_len); +int speech_rx_init(int sample_rate, int frame_len) { + TRACE(3, "[%s] Start, sample_rate: %d, frame_len: %d", __func__, sample_rate, + frame_len); -#if defined (SPEECH_RX_NS) - speech_rx_ns_st = speech_ns_create(sample_rate, frame_len, &speech_cfg->rx_ns); +#if defined(SPEECH_RX_NS) + speech_rx_ns_st = + speech_ns_create(sample_rate, frame_len, &speech_cfg->rx_ns); #endif #if defined(SPEECH_RX_NS2) - speech_rx_ns2_st = speech_ns2_create(sample_rate, frame_len, &speech_cfg->rx_ns2); + speech_rx_ns2_st = + speech_ns2_create(sample_rate, frame_len, &speech_cfg->rx_ns2); #endif #if defined(SPEECH_RX_NS2FLOAT) - speech_rx_ns2float_st = speech_ns2float_create(sample_rate, frame_len, SPEECH_RX_NS2FLOAT_CORE, &speech_cfg->rx_ns2float); + speech_rx_ns2float_st = + speech_ns2float_create(sample_rate, frame_len, SPEECH_RX_NS2FLOAT_CORE, + &speech_cfg->rx_ns2float); #endif #if defined(SPEECH_RX_NS3) - speech_rx_ns3_st = ns3_create(sample_rate, frame_len, &speech_cfg->rx_ns3); + speech_rx_ns3_st = ns3_create(sample_rate, frame_len, &speech_cfg->rx_ns3); #endif #if defined(SPEECH_RX_AGC) - speech_rx_agc_st = agc_state_create(sample_rate, frame_len, &speech_cfg->rx_agc); + speech_rx_agc_st = + agc_state_create(sample_rate, frame_len, &speech_cfg->rx_agc); #endif #if defined(SPEECH_RX_EQ) - speech_rx_eq_st = eq_init(sample_rate, frame_len, &speech_cfg->rx_eq); + speech_rx_eq_st = eq_init(sample_rate, frame_len, &speech_cfg->rx_eq); #endif #if defined(SPEECH_RX_POST_GAIN) - speech_rx_post_gain_st = speech_gain_create(sample_rate, frame_len, &speech_cfg->rx_post_gain); + speech_rx_post_gain_st = + speech_gain_create(sample_rate, frame_len, &speech_cfg->rx_post_gain); #endif - TRACE(1,"[%s] End", __func__); + TRACE(1, "[%s] End", __func__); - return 0; + return 0; } -int speech_init(int tx_sample_rate, int rx_sample_rate, - int tx_frame_ms, int rx_frame_ms, - int sco_frame_ms, - uint8_t *buf, int len) -{ - TRACE(1,"[%s] Start...", __func__); +int speech_init(int tx_sample_rate, int rx_sample_rate, int tx_frame_ms, + int rx_frame_ms, int sco_frame_ms, uint8_t *buf, int len) { + TRACE(1, "[%s] Start...", __func__); - //ASSERT(frame_ms == SPEECH_PROCESS_FRAME_MS, "[%s] frame_ms(%d) != SPEECH_PROCESS_FRAME_MS(%d)", __func__, - // frame_ms, - // SPEECH_PROCESS_FRAME_MS); + // ASSERT(frame_ms == SPEECH_PROCESS_FRAME_MS, "[%s] frame_ms(%d) != + // SPEECH_PROCESS_FRAME_MS(%d)", __func__, + // frame_ms, + // SPEECH_PROCESS_FRAME_MS); - speech_tx_sample_rate = tx_sample_rate; - speech_rx_sample_rate = rx_sample_rate; - speech_tx_frame_len = SPEECH_FRAME_MS_TO_LEN(tx_sample_rate, tx_frame_ms); - speech_rx_frame_len = SPEECH_FRAME_MS_TO_LEN(rx_sample_rate, rx_frame_ms); + speech_tx_sample_rate = tx_sample_rate; + speech_rx_sample_rate = rx_sample_rate; + speech_tx_frame_len = SPEECH_FRAME_MS_TO_LEN(tx_sample_rate, tx_frame_ms); + speech_rx_frame_len = SPEECH_FRAME_MS_TO_LEN(rx_sample_rate, rx_frame_ms); - speech_heap_init(buf, len); + speech_heap_init(buf, len); #if defined(SCO_OPTIMIZE_FOR_RAM) - TRACE(2,"[%s] sco_overlay_ram_buf_len = %d", __func__, sco_overlay_ram_buf_len); - if (sco_overlay_ram_buf_len >= 1024) - { - speech_heap_add_block(sco_overlay_ram_buf, sco_overlay_ram_buf_len); - } + TRACE(2, "[%s] sco_overlay_ram_buf_len = %d", __func__, + sco_overlay_ram_buf_len); + if (sco_overlay_ram_buf_len >= 1024) { + speech_heap_add_block(sco_overlay_ram_buf, sco_overlay_ram_buf_len); + } #endif - // When phone call again, speech cfg will be default. - // If do not want to reset speech cfg, need define bt_sco_chain_init() - // and call in apps.cpp: app_init() - speech_cfg = (SpeechConfig *)speech_calloc(1, sizeof(SpeechConfig)); - speech_store_config(&speech_cfg_default); + // When phone call again, speech cfg will be default. + // If do not want to reset speech cfg, need define bt_sco_chain_init() + // and call in apps.cpp: app_init() + speech_cfg = (SpeechConfig *)speech_calloc(1, sizeof(SpeechConfig)); + speech_store_config(&speech_cfg_default); #if defined(BT_SCO_CHAIN_AUDIO_DUMP) - audio_dump_init(speech_tx_frame_len, sizeof(short), 2); + audio_dump_init(speech_tx_frame_len, sizeof(short), 2); #endif #ifdef AUDIO_DEBUG_V0_1_0 - speech_tuning_open(); + speech_tuning_open(); #endif - int aec_enable = 0; -#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) - aec_enable = 1; + int aec_enable = 0; +#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || \ + defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) + aec_enable = 1; #endif - int capture_sample_size = sizeof(int16_t), playback_sample_size = sizeof(int16_t); + int capture_sample_size = sizeof(int16_t), + playback_sample_size = sizeof(int16_t); #if defined(SPEECH_TX_24BIT) - capture_sample_size = sizeof(int32_t); + capture_sample_size = sizeof(int32_t); #endif #if defined(SPEECH_RX_24BIT) - playback_sample_size = sizeof(int32_t); + playback_sample_size = sizeof(int32_t); #endif - CAPTURE_HANDLER_T tx_handler = (tx_frame_ms == sco_frame_ms) ? NULL : _speech_tx_process_; - PLAYBACK_HANDLER_T rx_handler = (rx_frame_ms == sco_frame_ms) ? NULL : _speech_rx_process_; + CAPTURE_HANDLER_T tx_handler = + (tx_frame_ms == sco_frame_ms) ? NULL : _speech_tx_process_; + PLAYBACK_HANDLER_T rx_handler = + (rx_frame_ms == sco_frame_ms) ? NULL : _speech_rx_process_; - speech_tx_frame_resizer_enable = (tx_handler != NULL); - speech_rx_frame_resizer_enable = (rx_handler != NULL); + speech_tx_frame_resizer_enable = (tx_handler != NULL); + speech_rx_frame_resizer_enable = (rx_handler != NULL); - if (speech_tx_frame_resizer_enable || speech_rx_frame_resizer_enable) { - speech_frame_resize_st = frame_resize_create(SPEECH_FRAME_MS_TO_LEN(tx_sample_rate, sco_frame_ms), - SPEECH_TX_CHANNEL_NUM, - speech_tx_frame_len, - capture_sample_size, - playback_sample_size, - aec_enable, - tx_handler, - rx_handler - ); - } + if (speech_tx_frame_resizer_enable || speech_rx_frame_resizer_enable) { + speech_frame_resize_st = frame_resize_create( + SPEECH_FRAME_MS_TO_LEN(tx_sample_rate, sco_frame_ms), + SPEECH_TX_CHANNEL_NUM, speech_tx_frame_len, capture_sample_size, + playback_sample_size, aec_enable, tx_handler, rx_handler); + } #if defined(SCO_CP_ACCEL) - // NOTE: change channel number for different case. - sco_cp_init(speech_tx_frame_len, 1); + // NOTE: change channel number for different case. + sco_cp_init(speech_tx_frame_len, 1); #endif - speech_tx_init(speech_tx_sample_rate, speech_tx_frame_len); - speech_rx_init(speech_rx_sample_rate, speech_rx_frame_len); + speech_tx_init(speech_tx_sample_rate, speech_tx_frame_len); + speech_rx_init(speech_rx_sample_rate, speech_rx_frame_len); #if !defined(SCO_CP_ACCEL) - int needed_freq = 0; - enum APP_SYSFREQ_FREQ_T min_system_freq = speech_get_proper_sysfreq(&needed_freq); - enum APP_SYSFREQ_FREQ_T freq = hal_sysfreq_get(); + int needed_freq = 0; + enum APP_SYSFREQ_FREQ_T min_system_freq = + speech_get_proper_sysfreq(&needed_freq); + enum APP_SYSFREQ_FREQ_T freq = hal_sysfreq_get(); - if (freq < min_system_freq) { - freq = min_system_freq; + if (freq < min_system_freq) { + freq = min_system_freq; - app_sysfreq_req(APP_SYSFREQ_USER_BT_SCO, freq); + app_sysfreq_req(APP_SYSFREQ_USER_BT_SCO, freq); - int system_freq = hal_sys_timer_calc_cpu_freq(5, 0); - TRACE(2,"[%s]: app_sysfreq_req %d", __FUNCTION__, freq); - TRACE(2,"[%s]: sys freq calc : %d\n", __FUNCTION__, system_freq); + int system_freq = hal_sys_timer_calc_cpu_freq(5, 0); + TRACE(2, "[%s]: app_sysfreq_req %d", __FUNCTION__, freq); + TRACE(2, "[%s]: sys freq calc : %d\n", __FUNCTION__, system_freq); - if (system_freq <= needed_freq * 1000 * 1000) { - TRACE(3,"[%s] WARNING: system freq(%d) seems to be lower than needed(%d).", __FUNCTION__, system_freq/1000000, needed_freq); - } + if (system_freq <= needed_freq * 1000 * 1000) { + TRACE(3, + "[%s] WARNING: system freq(%d) seems to be lower than needed(%d).", + __FUNCTION__, system_freq / 1000000, needed_freq); } + } #endif - TRACE(1,"[%s] End", __func__); + TRACE(1, "[%s] End", __func__); - return 0; + return 0; } -int speech_tx_deinit(void) -{ - TRACE(1,"[%s] Start...", __func__); +int speech_tx_deinit(void) { + TRACE(1, "[%s] Start...", __func__); #if defined(SPEECH_TX_POST_GAIN) - speech_gain_destroy(speech_tx_post_gain_st); + speech_gain_destroy(speech_tx_post_gain_st); #endif #if defined(SPEECH_TX_EQ) - eq_destroy(speech_tx_eq_st); + eq_destroy(speech_tx_eq_st); #endif #if defined(SPEECH_TX_AGC) - agc_state_destroy(speech_tx_agc_st); + agc_state_destroy(speech_tx_agc_st); #endif #if defined(SPEECH_TX_3MIC_NS) - speech_3mic_ns_destroy(speech_tx_3mic_ns_st); + speech_3mic_ns_destroy(speech_tx_3mic_ns_st); #endif #if defined(SPEECH_TX_3MIC_NS3) - triple_mic_denoise3_destroy(speech_tx_3mic_ns3_st); + triple_mic_denoise3_destroy(speech_tx_3mic_ns3_st); #endif #if defined(SPEECH_TX_2MIC_NS) - dual_mic_denoise_deinit(); + dual_mic_denoise_deinit(); #endif #if defined(SPEECH_TX_2MIC_NS2) - speech_2mic_ns2_destroy(speech_tx_2mic_ns2_st); + speech_2mic_ns2_destroy(speech_tx_2mic_ns2_st); #endif -// #if defined(SPEECH_CS_VAD) -// VAD_destroy(speech_cs_vad_st); -// #endif + // #if defined(SPEECH_CS_VAD) + // VAD_destroy(speech_cs_vad_st); + // #endif #if defined(SPEECH_TX_2MIC_NS3) - far_field_speech_enhancement_deinit(); + far_field_speech_enhancement_deinit(); #endif #if defined(SPEECH_TX_2MIC_NS4) - sensormic_denoise_destroy(speech_tx_2mic_ns4_st); + sensormic_denoise_destroy(speech_tx_2mic_ns4_st); #endif #if defined(SPEECH_TX_2MIC_NS5) - leftright_denoise_destroy(speech_tx_2mic_ns5_st); + leftright_denoise_destroy(speech_tx_2mic_ns5_st); #endif #if defined(SPEECH_TX_2MIC_NS6) - speech_ff_2mic_ns2_destroy(speech_tx_2mic_ns6_st); + speech_ff_2mic_ns2_destroy(speech_tx_2mic_ns6_st); #endif #if defined(SPEECH_TX_NS) - speech_ns_destroy(speech_tx_ns_st); + speech_ns_destroy(speech_tx_ns_st); #endif #if defined(SPEECH_TX_NS2) - speech_ns2_destroy(speech_tx_ns2_st); + speech_ns2_destroy(speech_tx_ns2_st); #endif #if defined(SPEECH_TX_NS2FLOAT) - speech_ns2float_destroy(speech_tx_ns2float_st); + speech_ns2float_destroy(speech_tx_ns2float_st); #endif #ifdef SPEECH_TX_NS3 - ns3_destroy(speech_tx_ns3_st); + ns3_destroy(speech_tx_ns3_st); #endif #ifdef SPEECH_TX_WNR - wnr_destroy(speech_tx_wnr_st); + wnr_destroy(speech_tx_wnr_st); #endif #ifdef SPEECH_TX_NOISE_GATE - speech_noise_gate_destroy(speech_tx_noise_gate_st); + speech_noise_gate_destroy(speech_tx_noise_gate_st); #endif #ifdef SPEECH_TX_COMPEXP - compexp_destroy(speech_tx_compexp_st); + compexp_destroy(speech_tx_compexp_st); #endif #if defined(SPEECH_TX_AEC) - speech_aec_destroy(speech_tx_aec_st); + speech_aec_destroy(speech_tx_aec_st); #endif #if defined(SPEECH_TX_AEC2) - speech_aec2_destroy(speech_tx_aec2_st); + speech_aec2_destroy(speech_tx_aec2_st); #endif #if defined(SPEECH_TX_AEC3) - SubBandAec_destroy(speech_tx_aec3_st); + SubBandAec_destroy(speech_tx_aec3_st); #endif #if defined(SPEECH_TX_AEC2FLOAT) - ec2float_destroy(speech_tx_aec2float_st); + ec2float_destroy(speech_tx_aec2float_st); #endif -#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) - speech_free(aec_echo_buf_ptr); - speech_free(aec_out_buf); +#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || \ + defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) + speech_free(aec_echo_buf_ptr); + speech_free(aec_out_buf); #endif #if defined(SPEECH_TX_MIC_CALIBRATION) - speech_iir_calib_destroy(speech_tx_mic_calib_st); + speech_iir_calib_destroy(speech_tx_mic_calib_st); #endif #if defined(SPEECH_TX_MIC_FIR_CALIBRATION) - speech_fir_calib_destroy(speech_tx_mic_fir_calib_st); + speech_fir_calib_destroy(speech_tx_mic_fir_calib_st); #endif #if defined(SPEECH_TX_DC_FILTER) - speech_dc_filter_destroy(speech_tx_dc_filter_st); + speech_dc_filter_destroy(speech_tx_dc_filter_st); #endif - TRACE(1,"[%s] End", __func__); + TRACE(1, "[%s] End", __func__); - return 0; + return 0; } -int speech_rx_deinit(void) -{ - TRACE(1,"[%s] Start...", __func__); +int speech_rx_deinit(void) { + TRACE(1, "[%s] Start...", __func__); #if defined(SPEECH_RX_POST_GAIN) - speech_gain_destroy(speech_rx_post_gain_st); + speech_gain_destroy(speech_rx_post_gain_st); #endif #if defined(SPEECH_RX_EQ) - eq_destroy(speech_rx_eq_st); + eq_destroy(speech_rx_eq_st); #endif #if defined(SPEECH_RX_AGC) - agc_state_destroy(speech_rx_agc_st); + agc_state_destroy(speech_rx_agc_st); #endif #if defined(SPEECH_RX_NS) - speech_ns_destroy(speech_rx_ns_st); + speech_ns_destroy(speech_rx_ns_st); #endif #if defined(SPEECH_RX_NS2) - speech_ns2_destroy(speech_rx_ns2_st); + speech_ns2_destroy(speech_rx_ns2_st); #endif #if defined(SPEECH_RX_NS2FLOAT) - speech_ns2float_destroy(speech_rx_ns2float_st); + speech_ns2float_destroy(speech_rx_ns2float_st); #endif #ifdef SPEECH_RX_NS3 - ns3_destroy(speech_rx_ns3_st); + ns3_destroy(speech_rx_ns3_st); #endif - TRACE(1,"[%s] End", __func__); + TRACE(1, "[%s] End", __func__); - return 0; + return 0; } -int speech_deinit(void) -{ - TRACE(1,"[%s] Start...", __func__); +int speech_deinit(void) { + TRACE(1, "[%s] Start...", __func__); - speech_rx_deinit(); - speech_tx_deinit(); + speech_rx_deinit(); + speech_tx_deinit(); #if defined(SCO_CP_ACCEL) - sco_cp_deinit(); + sco_cp_deinit(); #endif - if (speech_frame_resize_st != NULL) { - frame_resize_destroy(speech_frame_resize_st); - speech_tx_frame_resizer_enable = false; - speech_rx_frame_resizer_enable = false; - } + if (speech_frame_resize_st != NULL) { + frame_resize_destroy(speech_frame_resize_st); + speech_tx_frame_resizer_enable = false; + speech_rx_frame_resizer_enable = false; + } #ifdef AUDIO_DEBUG_V0_1_0 - speech_tuning_close(); + speech_tuning_close(); #endif #if defined(BT_SCO_CHAIN_AUDIO_DUMP) - audio_dump_deinit(); + audio_dump_deinit(); #endif - speech_free(speech_cfg); - speech_cfg = NULL; + speech_free(speech_cfg); + speech_cfg = NULL; - size_t total = 0, used = 0, max_used = 0; - speech_memory_info(&total, &used, &max_used); - TRACE(3,"SPEECH MALLOC MEM: total - %d, used - %d, max_used - %d.", total, used, max_used); - ASSERT(used == 0, "[%s] used != 0", __func__); + size_t total = 0, used = 0, max_used = 0; + speech_memory_info(&total, &used, &max_used); + TRACE(3, "SPEECH MALLOC MEM: total - %d, used - %d, max_used - %d.", total, + used, max_used); + ASSERT(used == 0, "[%s] used != 0", __func__); - TRACE(1,"[%s] End", __func__); + TRACE(1, "[%s] End", __func__); - return 0; + return 0; } -float speech_tx_get_required_mips(void) -{ - float mips = 0; +float speech_tx_get_required_mips(void) { + float mips = 0; #if defined(SPEECH_TX_DC_FILTER) - mips += speech_dc_filter_get_required_mips(speech_tx_dc_filter_st); + mips += speech_dc_filter_get_required_mips(speech_tx_dc_filter_st); #endif #if defined(SPEECH_TX_MIC_CALIBRATION) - mips += speech_iir_calib_get_required_mips(speech_tx_mic_calib_st); + mips += speech_iir_calib_get_required_mips(speech_tx_mic_calib_st); #endif #if defined(SPEECH_TX_MIC_FIR_CALIBRATION) - mips += speech_fir_calib_get_required_mips(speech_tx_mic_fir_calib_st); + mips += speech_fir_calib_get_required_mips(speech_tx_mic_fir_calib_st); #endif #if defined(SPEECH_TX_AEC) - mips += speech_aec_get_required_mips(speech_tx_aec_st); + mips += speech_aec_get_required_mips(speech_tx_aec_st); #endif #if defined(SPEECH_TX_AEC2) - mips += speech_aec2_get_required_mips(speech_tx_aec2_st); + mips += speech_aec2_get_required_mips(speech_tx_aec2_st); #endif #if defined(SPEECH_TX_AEC3) - mips += SubBandAec_get_required_mips(speech_tx_aec3_st); + mips += SubBandAec_get_required_mips(speech_tx_aec3_st); #endif #if defined(SPEECH_TX_AEC2FLOAT) - mips += ec2float_get_required_mips(speech_tx_aec2float_st); + mips += ec2float_get_required_mips(speech_tx_aec2float_st); #endif #if defined(SPEECH_TX_2MIC_NS) - mips += dual_mic_denoise_get_required_mips(); + mips += dual_mic_denoise_get_required_mips(); #endif #if defined(SPEECH_TX_2MIC_NS2) - mips += speech_2mic_ns2_get_required_mips(speech_tx_2mic_ns2_st); + mips += speech_2mic_ns2_get_required_mips(speech_tx_2mic_ns2_st); #endif -// #if defined(SPEECH_CS_VAD) -// mips += VAD_process_get_required_mips(speech_cs_vad_st); -// #endif + // #if defined(SPEECH_CS_VAD) + // mips += VAD_process_get_required_mips(speech_cs_vad_st); + // #endif #if defined(SPEECH_TX_2MIC_NS3) - mips += far_field_speech_enhancement_get_required_mips(); + mips += far_field_speech_enhancement_get_required_mips(); #endif #if defined(SPEECH_TX_2MIC_NS5) - mips += leftright_denoise_get_required_mips(speech_tx_2mic_ns5_st); + mips += leftright_denoise_get_required_mips(speech_tx_2mic_ns5_st); #endif #if defined(SPEECH_TX_2MIC_NS6) - mips += speech_ff_2mic_ns2_get_required_mips(speech_tx_2mic_ns6_st); + mips += speech_ff_2mic_ns2_get_required_mips(speech_tx_2mic_ns6_st); #endif #if defined(SPEECH_TX_2MIC_NS4) - mips += sensormic_denoise_get_required_mips(speech_tx_2mic_ns4_st); + mips += sensormic_denoise_get_required_mips(speech_tx_2mic_ns4_st); #endif #if defined(SPEECH_TX_3MIC_NS) - mips += speech_3mic_get_required_mips(speech_tx_3mic_ns_st); + mips += speech_3mic_get_required_mips(speech_tx_3mic_ns_st); #endif #if defined(SPEECH_TX_3MIC_NS3) - mips += triple_mic_denoise3_get_required_mips(speech_tx_3mic_ns3_st); + mips += triple_mic_denoise3_get_required_mips(speech_tx_3mic_ns3_st); #endif #if defined(SPEECH_TX_NS) - mips += speech_ns_get_required_mips(speech_tx_ns_st); + mips += speech_ns_get_required_mips(speech_tx_ns_st); #endif #if defined(SPEECH_TX_NS2) - mips += speech_ns2_get_required_mips(speech_tx_ns2_st); + mips += speech_ns2_get_required_mips(speech_tx_ns2_st); #endif #if defined(SPEECH_TX_NS2FLOAT) - mips += speech_ns2float_get_required_mips(speech_tx_ns2float_st); + mips += speech_ns2float_get_required_mips(speech_tx_ns2float_st); #endif #if defined(SPEECH_TX_NS3) - mips += ns3_get_required_mips(speech_tx_ns3_st); + mips += ns3_get_required_mips(speech_tx_ns3_st); #endif #if defined(SPEECH_TX_WNR) - mips += wnr_get_required_mips(speech_tx_wnr_st); + mips += wnr_get_required_mips(speech_tx_wnr_st); #endif #if defined(SPEECH_TX_NOISE_GATE) - mips += speech_noise_gate_get_required_mips(speech_tx_noise_gate_st); + mips += speech_noise_gate_get_required_mips(speech_tx_noise_gate_st); #endif #if defined(SPEECH_TX_COMPEXP) - mips += compexp_get_required_mips(speech_tx_compexp_st); + mips += compexp_get_required_mips(speech_tx_compexp_st); #endif #if defined(SPEECH_TX_AGC) - mips += agc_get_required_mips(speech_tx_agc_st); + mips += agc_get_required_mips(speech_tx_agc_st); #endif #if defined(SPEECH_TX_EQ) - mips += eq_get_required_mips(speech_tx_eq_st); + mips += eq_get_required_mips(speech_tx_eq_st); #endif #if defined(SPEECH_TX_POST_GAIN) - mips += speech_gain_get_required_mips(speech_tx_post_gain_st); + mips += speech_gain_get_required_mips(speech_tx_post_gain_st); #endif - return mips; + return mips; } -float speech_rx_get_required_mips(void) -{ - float mips = 0; +float speech_rx_get_required_mips(void) { + float mips = 0; -#if defined (SPEECH_RX_NS) - mips += speech_ns_get_required_mips(speech_rx_ns_st); +#if defined(SPEECH_RX_NS) + mips += speech_ns_get_required_mips(speech_rx_ns_st); #endif #if defined(SPEECH_RX_NS2) - mips += speech_ns2_get_required_mips(speech_rx_ns2_st); + mips += speech_ns2_get_required_mips(speech_rx_ns2_st); #endif #if defined(SPEECH_RX_NS2FLOAT) - mips += speech_ns2float_get_required_mips(speech_rx_ns2float_st); + mips += speech_ns2float_get_required_mips(speech_rx_ns2float_st); #endif #if defined(SPEECH_RX_NS3) - mips += ns3_get_required_mips(speech_rx_ns3_st); + mips += ns3_get_required_mips(speech_rx_ns3_st); #endif #if defined(SPEECH_RX_AGC) - mips += agc_get_required_mips(speech_rx_agc_st); + mips += agc_get_required_mips(speech_rx_agc_st); #endif #if defined(SPEECH_RX_EQ) - mips += eq_get_required_mips(speech_rx_eq_st); + mips += eq_get_required_mips(speech_rx_eq_st); #endif #if defined(SPEECH_RX_POST_GAIN) - mips += speech_gain_get_required_mips(speech_rx_post_gain_st); + mips += speech_gain_get_required_mips(speech_rx_post_gain_st); #endif - return mips; + return mips; } -float speech_get_required_mips(void) -{ - return speech_tx_get_required_mips() + speech_rx_get_required_mips(); +float speech_get_required_mips(void) { + return speech_tx_get_required_mips() + speech_rx_get_required_mips(); } #define SYSTEM_BASE_MIPS (18) -enum APP_SYSFREQ_FREQ_T speech_get_proper_sysfreq(int *needed_mips) -{ - enum APP_SYSFREQ_FREQ_T freq = APP_SYSFREQ_32K; - int required_mips = (int)ceilf(speech_get_required_mips() + SYSTEM_BASE_MIPS); +enum APP_SYSFREQ_FREQ_T speech_get_proper_sysfreq(int *needed_mips) { + enum APP_SYSFREQ_FREQ_T freq = APP_SYSFREQ_32K; + int required_mips = (int)ceilf(speech_get_required_mips() + SYSTEM_BASE_MIPS); - if (required_mips >= 104) - freq = APP_SYSFREQ_208M; - else if (required_mips >= 78) - freq = APP_SYSFREQ_104M; - else if (required_mips >= 52) - freq = APP_SYSFREQ_78M; - else if (required_mips >= 26) - freq = APP_SYSFREQ_52M; - else - freq = APP_SYSFREQ_26M; + if (required_mips >= 104) + freq = APP_SYSFREQ_208M; + else if (required_mips >= 78) + freq = APP_SYSFREQ_104M; + else if (required_mips >= 52) + freq = APP_SYSFREQ_78M; + else if (required_mips >= 26) + freq = APP_SYSFREQ_52M; + else + freq = APP_SYSFREQ_26M; - *needed_mips = required_mips; + *needed_mips = required_mips; - return freq; + return freq; } -int speech_set_config(const SpeechConfig *cfg) -{ +int speech_set_config(const SpeechConfig *cfg) { #if defined(SPEECH_TX_DC_FILTER) - speech_dc_filter_set_config(speech_tx_dc_filter_st, &cfg->tx_dc_filter); + speech_dc_filter_set_config(speech_tx_dc_filter_st, &cfg->tx_dc_filter); #endif #if defined(SPEECH_TX_AEC) - speech_aec_set_config(speech_tx_aec_st, &cfg->tx_aec); + speech_aec_set_config(speech_tx_aec_st, &cfg->tx_aec); #endif #if defined(SPEECH_TX_AEC2) - speech_aec2_set_config(speech_tx_aec2_st, &cfg->tx_aec2); + speech_aec2_set_config(speech_tx_aec2_st, &cfg->tx_aec2); #endif #if defined(SPEECH_TX_AEC2FLOAT) - ec2float_set_config(speech_tx_aec2float_st, &cfg->tx_aec2float, SPEECH_TX_AEC2FLOAT_CORE); + ec2float_set_config(speech_tx_aec2float_st, &cfg->tx_aec2float, + SPEECH_TX_AEC2FLOAT_CORE); #endif #if defined(SPEECH_TX_2MIC_NS) - TRACE(1,"[%s] WARNING: Can not support tuning SPEECH_TX_2MIC_NS", __func__); + TRACE(1, "[%s] WARNING: Can not support tuning SPEECH_TX_2MIC_NS", __func__); #endif #if defined(SPEECH_TX_2MIC_NS2) - speech_2mic_ns2_set_config(speech_tx_2mic_ns2_st, &cfg->tx_2mic_ns2); + speech_2mic_ns2_set_config(speech_tx_2mic_ns2_st, &cfg->tx_2mic_ns2); #endif #if defined(SPEECH_TX_2MIC_NS4) - sensormic_denoise_set_config(speech_tx_2mic_ns4_st, &cfg->tx_2mic_ns4); + sensormic_denoise_set_config(speech_tx_2mic_ns4_st, &cfg->tx_2mic_ns4); #endif #if defined(SPEECH_TX_2MIC_NS5) - leftright_denoise_set_config(speech_tx_2mic_ns5_st, &cfg->tx_2mic_ns5); + leftright_denoise_set_config(speech_tx_2mic_ns5_st, &cfg->tx_2mic_ns5); #endif #if defined(SPEECH_TX_3MIC_NS) - speech_3mic_ns_set_config(speech_tx_3mic_ns_st, &cfg->tx_3mic_ns); + speech_3mic_ns_set_config(speech_tx_3mic_ns_st, &cfg->tx_3mic_ns); #endif #if defined(SPEECH_TX_NS) - speech_ns_set_config(speech_tx_ns_st, &cfg->tx_ns); + speech_ns_set_config(speech_tx_ns_st, &cfg->tx_ns); #endif #if defined(SPEECH_TX_NS2) - speech_ns2_set_config(speech_tx_ns2_st, &cfg->tx_ns2); + speech_ns2_set_config(speech_tx_ns2_st, &cfg->tx_ns2); #endif #if defined(SPEECH_TX_NS2FLOAT) - speech_ns2float_set_config(speech_tx_ns2float_st, &cfg->tx_ns2float); + speech_ns2float_set_config(speech_tx_ns2float_st, &cfg->tx_ns2float); #endif #if defined(SPEECH_TX_NS3) - ns3_set_config(speech_tx_ns3_st, &cfg->tx_ns3); + ns3_set_config(speech_tx_ns3_st, &cfg->tx_ns3); #endif #if defined(SPEECH_TX_NOISE_GATE) - speech_noise_gate_set_config(speech_tx_noise_gate_st, &cfg->tx_noise_gate); + speech_noise_gate_set_config(speech_tx_noise_gate_st, &cfg->tx_noise_gate); #endif #if defined(SPEECH_TX_COMPEXP) - compexp_set_config(speech_tx_compexp_st, &cfg->tx_compexp); + compexp_set_config(speech_tx_compexp_st, &cfg->tx_compexp); #endif #if defined(SPEECH_TX_AGC) - agc_set_config(speech_tx_agc_st, &cfg->tx_agc); + agc_set_config(speech_tx_agc_st, &cfg->tx_agc); #endif #if defined(SPEECH_TX_EQ) - eq_set_config(speech_tx_eq_st, &cfg->tx_eq); + eq_set_config(speech_tx_eq_st, &cfg->tx_eq); #endif #if defined(SPEECH_TX_POST_GAIN) - speech_gain_set_config(speech_tx_post_gain_st, &cfg->tx_post_gain); + speech_gain_set_config(speech_tx_post_gain_st, &cfg->tx_post_gain); #endif // #if defined(SPEECH_CS_VAD) // VAD_set_config(speech_cs_vad_st, &cfg->cs_vad); // #endif #if defined(SPEECH_RX_NS) - speech_ns_set_config(speech_rx_ns_st, &cfg->rx_ns); + speech_ns_set_config(speech_rx_ns_st, &cfg->rx_ns); #endif #if defined(SPEECH_RX_NS2) - speech_ns2_set_config(speech_rx_ns2_st, &cfg->rx_ns2); + speech_ns2_set_config(speech_rx_ns2_st, &cfg->rx_ns2); #endif #if defined(SPEECH_RX_NS2FLOAT) - speech_ns2float_set_config(speech_rx_ns2float_st, &cfg->rx_ns2float, SPEECH_RX_NS2FLOAT_CORE); + speech_ns2float_set_config(speech_rx_ns2float_st, &cfg->rx_ns2float, + SPEECH_RX_NS2FLOAT_CORE); #endif #if defined(SPEECH_RX_NS3) - ns3_set_config(speech_rx_ns3_st, &cfg->rx_ns3); + ns3_set_config(speech_rx_ns3_st, &cfg->rx_ns3); #endif #if defined(SPEECH_RX_NOISE_GATE) - speech_noise_gate_set_config(speech_rx_noise_gate_st, &cfg->rx_noise_gate); + speech_noise_gate_set_config(speech_rx_noise_gate_st, &cfg->rx_noise_gate); #endif #if defined(SPEECH_RX_COMPEXP) - compexp_set_config(speech_rx_compexp_st, &cfg->rx_compexp); + compexp_set_config(speech_rx_compexp_st, &cfg->rx_compexp); #endif #if defined(SPEECH_RX_AGC) - agc_set_config(speech_rx_agc_st, &cfg->rx_agc); + agc_set_config(speech_rx_agc_st, &cfg->rx_agc); #endif #if defined(SPEECH_RX_EQ) - eq_set_config(speech_rx_eq_st, &cfg->rx_eq); + eq_set_config(speech_rx_eq_st, &cfg->rx_eq); #endif #if defined(SPEECH_RX_POST_GAIN) - speech_gain_set_config(speech_rx_post_gain_st, &cfg->rx_post_gain); + speech_gain_set_config(speech_rx_post_gain_st, &cfg->rx_post_gain); #endif - // Add more process + // Add more process - return 0; + return 0; } -void _speech_tx_process_pre(short *pcm_buf, short *ref_buf, int *_pcm_len) -{ - int pcm_len = *_pcm_len; +void _speech_tx_process_pre(short *pcm_buf, short *ref_buf, int *_pcm_len) { + int pcm_len = *_pcm_len; #if defined(BT_SCO_CHAIN_PROFILE) - tx_start_ticks = hal_fast_sys_timer_get(); + tx_start_ticks = hal_fast_sys_timer_get(); #endif - // TRACE(2,"[%s] pcm_len = %d", __func__, pcm_len); + // TRACE(2,"[%s] pcm_len = %d", __func__, pcm_len); #ifdef AUDIO_DEBUG_V0_1_0 - if (speech_tuning_get_status()) - { - speech_set_config(speech_cfg); + if (speech_tuning_get_status()) { + speech_set_config(speech_cfg); - speech_tuning_set_status(false); + speech_tuning_set_status(false); - // If has MIPS problem, can move this block code into speech_rx_process or return directly - // return 0 - } + // If has MIPS problem, can move this block code into speech_rx_process or + // return directly return 0 + } #endif #if defined(SPEECH_TX_24BIT) -#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) - tx_refbuf16 = (int16_t *)ref_buf; - tx_refbuf32 = (int32_t *)ref_buf; - for (int i = 0; i < pcm_len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM; i++) { - tx_refbuf16[i] = (tx_refbuf32[i] >> 8); - } +#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || \ + defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) + tx_refbuf16 = (int16_t *)ref_buf; + tx_refbuf32 = (int32_t *)ref_buf; + for (int i = 0; i < pcm_len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM; i++) { + tx_refbuf16[i] = (tx_refbuf32[i] >> 8); + } #endif - tx_pcmbuf16 = (int16_t *)pcm_buf; - tx_pcmbuf32 = (int32_t *)pcm_buf; - for (int i = 0; i < pcm_len; i++) { - tx_pcmbuf16[i] = (tx_pcmbuf32[i] >> 8); - } + tx_pcmbuf16 = (int16_t *)pcm_buf; + tx_pcmbuf32 = (int32_t *)pcm_buf; + for (int i = 0; i < pcm_len; i++) { + tx_pcmbuf16[i] = (tx_pcmbuf32[i] >> 8); + } #endif #if defined(BT_SCO_CHAIN_AUDIO_DUMP) - audio_dump_clear_up(); + audio_dump_clear_up(); #endif #if 0 @@ -1151,333 +1189,341 @@ void _speech_tx_process_pre(short *pcm_buf, short *ref_buf, int *_pcm_len) #endif #if defined(SPEECH_TX_DC_FILTER) - speech_dc_filter_process(speech_tx_dc_filter_st, pcm_buf, pcm_len); + speech_dc_filter_process(speech_tx_dc_filter_st, pcm_buf, pcm_len); #endif -#if (SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 2) && defined(AUDIO_DUMP) && defined(BT_SCO_CHAIN_AUDIO_DUMP) - audio_dump_add_channel_data_from_multi_channels(0, pcm_buf, pcm_len / 2, 2, 0); - audio_dump_add_channel_data_from_multi_channels(1, pcm_buf, pcm_len / 2, 2, 1); +#if (SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 2) && defined(AUDIO_DUMP) && \ + defined(BT_SCO_CHAIN_AUDIO_DUMP) + audio_dump_add_channel_data_from_multi_channels(0, pcm_buf, pcm_len / 2, 2, + 0); + audio_dump_add_channel_data_from_multi_channels(1, pcm_buf, pcm_len / 2, 2, + 1); #endif #if defined(SPEECH_TX_MIC_CALIBRATION) - speech_iir_calib_process(speech_tx_mic_calib_st, pcm_buf, pcm_len); + speech_iir_calib_process(speech_tx_mic_calib_st, pcm_buf, pcm_len); #endif #if defined(SPEECH_TX_MIC_FIR_CALIBRATION) - speech_fir_calib_process(speech_tx_mic_fir_calib_st, pcm_buf, pcm_len); + speech_fir_calib_process(speech_tx_mic_fir_calib_st, pcm_buf, pcm_len); #endif -#if (SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 2) && defined(AUDIO_DUMP) && defined(BT_SCO_CHAIN_AUDIO_DUMP) - audio_dump_add_channel_data_from_multi_channels(2, pcm_buf, pcm_len / 2, 2, 0); - audio_dump_add_channel_data_from_multi_channels(3, pcm_buf, pcm_len / 2, 2, 1); +#if (SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 2) && defined(AUDIO_DUMP) && \ + defined(BT_SCO_CHAIN_AUDIO_DUMP) + audio_dump_add_channel_data_from_multi_channels(2, pcm_buf, pcm_len / 2, 2, + 0); + audio_dump_add_channel_data_from_multi_channels(3, pcm_buf, pcm_len / 2, 2, + 1); #endif #if defined(SPEECH_TX_2MIC_NS) - dual_mic_denoise_run(pcm_buf, pcm_len, pcm_buf); - // Channel num: two-->one - pcm_len >>= 1; + dual_mic_denoise_run(pcm_buf, pcm_len, pcm_buf); + // Channel num: two-->one + pcm_len >>= 1; #endif #if defined(SPEECH_TX_2MIC_NS2) - speech_2mic_ns2_process(speech_tx_2mic_ns2_st, pcm_buf, pcm_len, pcm_buf); - // Channel num: two-->one - pcm_len >>= 1; + speech_2mic_ns2_process(speech_tx_2mic_ns2_st, pcm_buf, pcm_len, pcm_buf); + // Channel num: two-->one + pcm_len >>= 1; #endif #if defined(SPEECH_TX_2MIC_NS4) - if (dualmic_enable == true) { + if (dualmic_enable == true) { #if defined(ANC_APP) - sensormic_denoise_set_anc_status(speech_tx_2mic_ns4_st, app_anc_work_status()); + sensormic_denoise_set_anc_status(speech_tx_2mic_ns4_st, + app_anc_work_status()); #endif - sensormic_denoise_process(speech_tx_2mic_ns4_st, pcm_buf, pcm_len, pcm_buf); - } else { - int16_t *pcm16 = (int16_t *)pcm_buf; - for (int i = 0, j = 0; i < pcm_len / 2; i++, j += 2) - pcm16[i] = pcm16[j]; - } - // Channel num: two-->one - pcm_len >>= 1; + sensormic_denoise_process(speech_tx_2mic_ns4_st, pcm_buf, pcm_len, pcm_buf); + } else { + int16_t *pcm16 = (int16_t *)pcm_buf; + for (int i = 0, j = 0; i < pcm_len / 2; i++, j += 2) + pcm16[i] = pcm16[j]; + } + // Channel num: two-->one + pcm_len >>= 1; #endif #if defined(SPEECH_TX_2MIC_NS5) - leftright_denoise_process(speech_tx_2mic_ns5_st, pcm_buf, pcm_len, pcm_buf); - // Channel num: two-->one - pcm_len >>= 1; + leftright_denoise_process(speech_tx_2mic_ns5_st, pcm_buf, pcm_len, pcm_buf); + // Channel num: two-->one + pcm_len >>= 1; #endif #if defined(SPEECH_TX_2MIC_NS6) - //TRACE(0,"NS6"); - speech_2mic_ns6_process(speech_tx_2mic_ns6_st, pcm_buf, pcm_len, pcm_buf); - // Channel num: two-->one - pcm_len >>= 1; + // TRACE(0,"NS6"); + speech_2mic_ns6_process(speech_tx_2mic_ns6_st, pcm_buf, pcm_len, pcm_buf); + // Channel num: two-->one + pcm_len >>= 1; #endif #if defined(SPEECH_TX_3MIC_NS) - speech_3mic_ns_process(speech_tx_3mic_ns_st, pcm_buf, pcm_len, pcm_buf); - // Channel num: three-->one - pcm_len = pcm_len / 3; + speech_3mic_ns_process(speech_tx_3mic_ns_st, pcm_buf, pcm_len, pcm_buf); + // Channel num: three-->one + pcm_len = pcm_len / 3; #endif #if defined(SPEECH_TX_3MIC_NS3) - triple_mic_denoise3_process(speech_tx_3mic_ns3_st, pcm_buf, pcm_len, pcm_buf); - // Channel num: three-->one - pcm_len = pcm_len / 3; + triple_mic_denoise3_process(speech_tx_3mic_ns3_st, pcm_buf, pcm_len, pcm_buf); + // Channel num: three-->one + pcm_len = pcm_len / 3; #endif #if defined(BT_SCO_CHAIN_AUDIO_DUMP) - audio_dump_add_channel_data(0, pcm_buf, pcm_len); -#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) - audio_dump_add_channel_data(1, ref_buf, pcm_len); + audio_dump_add_channel_data(0, pcm_buf, pcm_len); +#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || \ + defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) + audio_dump_add_channel_data(1, ref_buf, pcm_len); #else - audio_dump_add_channel_data(1, pcm_buf, pcm_len); + audio_dump_add_channel_data(1, pcm_buf, pcm_len); #endif #endif #if defined(SPEECH_TX_AEC) - speech_aec_process(speech_tx_aec_st, pcm_buf, ref_buf, pcm_len, aec_out_buf); - speech_copy_int16(pcm_buf, aec_out_buf, pcm_len); + speech_aec_process(speech_tx_aec_st, pcm_buf, ref_buf, pcm_len, aec_out_buf); + speech_copy_int16(pcm_buf, aec_out_buf, pcm_len); #endif #if defined(SPEECH_TX_AEC2) - speech_aec2_process(speech_tx_aec2_st, pcm_buf, ref_buf, pcm_len); + speech_aec2_process(speech_tx_aec2_st, pcm_buf, ref_buf, pcm_len); #endif #if defined(SPEECH_TX_AEC3) - CODEC_OpVecCpy(bufferstate + delay, ref_buf, pcm_len); - CODEC_OpVecCpy(buf_out, bufferstate, pcm_len); - CODEC_OpVecCpy(bufferstate, bufferstate + pcm_len, delay); - SubBandAec_process(speech_tx_aec3_st, pcm_buf, buf_out, pcm_buf, pcm_len); - //audio_dump_add_channel_data(1, pcm_buf, pcm_len); + CODEC_OpVecCpy(bufferstate + delay, ref_buf, pcm_len); + CODEC_OpVecCpy(buf_out, bufferstate, pcm_len); + CODEC_OpVecCpy(bufferstate, bufferstate + pcm_len, delay); + SubBandAec_process(speech_tx_aec3_st, pcm_buf, buf_out, pcm_buf, pcm_len); + // audio_dump_add_channel_data(1, pcm_buf, pcm_len); #endif - SCO_CP_ACCEL_ALGO_START(); + SCO_CP_ACCEL_ALGO_START(); #if defined(SPEECH_TX_AEC2FLOAT) #if defined(SPEECH_TX_2MIC_NS4) - if (dualmic_enable == true) - TRACE(2,"[%s] vad: %d", __FUNCTION__, sensormic_denoise_get_vad(speech_tx_2mic_ns4_st)); - ec2float_set_external_vad(speech_tx_aec2float_st, sensormic_denoise_get_vad(speech_tx_2mic_ns4_st)); + if (dualmic_enable == true) + TRACE(2, "[%s] vad: %d", __FUNCTION__, + sensormic_denoise_get_vad(speech_tx_2mic_ns4_st)); + ec2float_set_external_vad(speech_tx_aec2float_st, + sensormic_denoise_get_vad(speech_tx_2mic_ns4_st)); #endif - ec2float_process(speech_tx_aec2float_st, pcm_buf, ref_buf, pcm_len, aec_out_buf); - speech_copy_int16(pcm_buf, aec_out_buf, pcm_len); + ec2float_process(speech_tx_aec2float_st, pcm_buf, ref_buf, pcm_len, + aec_out_buf); + speech_copy_int16(pcm_buf, aec_out_buf, pcm_len); #endif - SCO_CP_ACCEL_ALGO_END(); + SCO_CP_ACCEL_ALGO_END(); #if defined(BT_SCO_CHAIN_AUDIO_DUMP) - audio_dump_add_channel_data(2, pcm_buf, pcm_len); + audio_dump_add_channel_data(2, pcm_buf, pcm_len); #endif #if defined(SPEECH_TX_NS) - speech_ns_process(speech_tx_ns_st, pcm_buf, pcm_len); + speech_ns_process(speech_tx_ns_st, pcm_buf, pcm_len); #endif #if defined(SPEECH_TX_NS2) - speech_ns2_process(speech_tx_ns2_st, pcm_buf, pcm_len); + speech_ns2_process(speech_tx_ns2_st, pcm_buf, pcm_len); #endif #if defined(SPEECH_TX_NS2FLOAT) #if defined(SPEECH_TX_2MIC_NS4) - if (dualmic_enable == true) - speech_ns2float_set_external_vad(speech_tx_ns2float_st, sensormic_denoise_get_vad(speech_tx_2mic_ns4_st)); + if (dualmic_enable == true) + speech_ns2float_set_external_vad( + speech_tx_ns2float_st, + sensormic_denoise_get_vad(speech_tx_2mic_ns4_st)); #endif - speech_ns2float_process(speech_tx_ns2float_st, pcm_buf, pcm_len); + speech_ns2float_process(speech_tx_ns2float_st, pcm_buf, pcm_len); #endif #if defined(SPEECH_TX_NS3) - ns3_process(speech_tx_ns3_st, pcm_buf, pcm_len); + ns3_process(speech_tx_ns3_st, pcm_buf, pcm_len); #endif #if defined(SPEECH_TX_WNR) - wnr_process(speech_tx_wnr_st, pcm_buf, pcm_len); + wnr_process(speech_tx_wnr_st, pcm_buf, pcm_len); #endif #if defined(BT_SCO_CHAIN_AUDIO_DUMP) - audio_dump_add_channel_data(3, pcm_buf, pcm_len); + audio_dump_add_channel_data(3, pcm_buf, pcm_len); #endif #if defined(SPEECH_TX_NOISE_GATE) - speech_noise_gate_process(speech_tx_noise_gate_st, pcm_buf, pcm_len); + speech_noise_gate_process(speech_tx_noise_gate_st, pcm_buf, pcm_len); #endif #if defined(BT_SCO_CHAIN_AUDIO_DUMP) - audio_dump_add_channel_data(4, pcm_buf, pcm_len); + audio_dump_add_channel_data(4, pcm_buf, pcm_len); #endif #if defined(SPEECH_TX_COMPEXP) - compexp_process(speech_tx_compexp_st, pcm_buf, pcm_len); + compexp_process(speech_tx_compexp_st, pcm_buf, pcm_len); #endif #if defined(SPEECH_TX_AGC) - agc_process(speech_tx_agc_st, pcm_buf, pcm_len); + agc_process(speech_tx_agc_st, pcm_buf, pcm_len); #endif #if defined(SPEECH_TX_EQ) - eq_process(speech_tx_eq_st, pcm_buf, pcm_len); + eq_process(speech_tx_eq_st, pcm_buf, pcm_len); #endif #if defined(BT_SCO_CHAIN_AUDIO_DUMP) - // audio_dump_add_channel_data(0, pcm_buf, pcm_len); + // audio_dump_add_channel_data(0, pcm_buf, pcm_len); #endif #if defined(SPEECH_TX_POST_GAIN) - speech_gain_process(speech_tx_post_gain_st, pcm_buf, pcm_len); + speech_gain_process(speech_tx_post_gain_st, pcm_buf, pcm_len); #endif #if defined(BT_SCO_CHAIN_AUDIO_DUMP) - // audio_dump_add_channel_data(1, pcm_buf, pcm_len); + // audio_dump_add_channel_data(1, pcm_buf, pcm_len); - audio_dump_add_channel_data(5, pcm_buf, pcm_len); - audio_dump_run(); + audio_dump_add_channel_data(5, pcm_buf, pcm_len); + audio_dump_run(); #endif #if defined(SPEECH_TX_24BIT) - tx_pcmbuf16 = (int16_t *)pcm_buf; - tx_pcmbuf32 = (int32_t *)pcm_buf; - for (int i = pcm_len - 1; i >= 0; i--) { - tx_pcmbuf32[i] = ((int32_t)tx_pcmbuf16[i] << 8); - } + tx_pcmbuf16 = (int16_t *)pcm_buf; + tx_pcmbuf32 = (int32_t *)pcm_buf; + for (int i = pcm_len - 1; i >= 0; i--) { + tx_pcmbuf32[i] = ((int32_t)tx_pcmbuf16[i] << 8); + } #endif - *_pcm_len = pcm_len; + *_pcm_len = pcm_len; #if defined(BT_SCO_CHAIN_PROFILE) - tx_end_ticks = hal_fast_sys_timer_get(); - TRACE(2,"[%s] takes %d us", __FUNCTION__, - FAST_TICKS_TO_US(tx_end_ticks - tx_start_ticks)); + tx_end_ticks = hal_fast_sys_timer_get(); + TRACE(2, "[%s] takes %d us", __FUNCTION__, + FAST_TICKS_TO_US(tx_end_ticks - tx_start_ticks)); #endif } #if defined(SCO_CP_ACCEL) CP_TEXT_SRAM_LOC -int sco_cp_algo(short *pcm_buf, short *ref_buf, int *_pcm_len) -{ +int sco_cp_algo(short *pcm_buf, short *ref_buf, int *_pcm_len) { #if defined(SCO_TRACE_CP_ACCEL) - TRACE(1,"[%s] ...", __func__); + TRACE(1, "[%s] ...", __func__); #endif - _speech_tx_process_mid(pcm_buf, ref_buf, _pcm_len); + _speech_tx_process_mid(pcm_buf, ref_buf, _pcm_len); - return 0; + return 0; } #endif -int32_t _speech_tx_process_(void *pcm_buf, void *ref_buf, int32_t *_pcm_len) -{ - _speech_tx_process_pre(pcm_buf, ref_buf, (int *)_pcm_len); +int32_t _speech_tx_process_(void *pcm_buf, void *ref_buf, int32_t *_pcm_len) { + _speech_tx_process_pre(pcm_buf, ref_buf, (int *)_pcm_len); #if defined(SCO_CP_ACCEL) - sco_cp_process(pcm_buf, ref_buf, (int *)_pcm_len); - _speech_tx_process_post(pcm_buf, ref_buf, (int *)_pcm_len); + sco_cp_process(pcm_buf, ref_buf, (int *)_pcm_len); + _speech_tx_process_post(pcm_buf, ref_buf, (int *)_pcm_len); #endif - return 0; + return 0; } -int32_t _speech_rx_process_(void *pcm_buf, int32_t *_pcm_len) -{ - int32_t pcm_len = *_pcm_len; +int32_t _speech_rx_process_(void *pcm_buf, int32_t *_pcm_len) { + int32_t pcm_len = *_pcm_len; #if defined(BT_SCO_CHAIN_PROFILE) - uint32_t start_ticks = hal_fast_sys_timer_get(); + uint32_t start_ticks = hal_fast_sys_timer_get(); #endif #if defined(SPEECH_RX_24BIT) - int32_t *buf32 = (int32_t *)pcm_buf; - int16_t *buf16 = (int16_t *)pcm_buf; - for (int i = 0; i < pcm_len; i++) { - buf16[i] = (int16_t)(buf32[i] >> 8); - } + int32_t *buf32 = (int32_t *)pcm_buf; + int16_t *buf16 = (int16_t *)pcm_buf; + for (int i = 0; i < pcm_len; i++) { + buf16[i] = (int16_t)(buf32[i] >> 8); + } #endif #if defined(BT_SCO_CHAIN_AUDIO_DUMP) - // audio_dump_add_channel_data(0, pcm_buf, pcm_len); + // audio_dump_add_channel_data(0, pcm_buf, pcm_len); #endif #if defined(SPEECH_RX_NS) - speech_ns_process(speech_rx_ns_st, pcm_buf, pcm_len); + speech_ns_process(speech_rx_ns_st, pcm_buf, pcm_len); #endif -#if defined(SPEECH_RX_NS2) - // fix 0dB signal - int16_t *pcm_buf16 = (int16_t *)pcm_buf; - for(int i=0; i= 0; i--) { - buf32[i] = ((int32_t)buf16[i] << 8); - } + for (int i = pcm_len - 1; i >= 0; i--) { + buf32[i] = ((int32_t)buf16[i] << 8); + } #endif #if defined(SPEECH_RX_EQ) #if defined(SPEECH_RX_24BIT) - eq_process_int24(speech_rx_eq_st, pcm_buf, pcm_len); + eq_process_int24(speech_rx_eq_st, pcm_buf, pcm_len); #else - eq_process(speech_rx_eq_st, pcm_buf, pcm_len); + eq_process(speech_rx_eq_st, pcm_buf, pcm_len); #endif #endif #if defined(SPEECH_RX_POST_GAIN) - speech_gain_process(speech_rx_post_gain_st, pcm_buf, pcm_len); + speech_gain_process(speech_rx_post_gain_st, pcm_buf, pcm_len); #endif #if defined(BT_SCO_CHAIN_AUDIO_DUMP) - // audio_dump_add_channel_data(1, pcm_buf, pcm_len); - // audio_dump_run(); + // audio_dump_add_channel_data(1, pcm_buf, pcm_len); + // audio_dump_run(); #endif - *_pcm_len = pcm_len; + *_pcm_len = pcm_len; #if defined(BT_SCO_CHAIN_PROFILE) - uint32_t end_ticks = hal_fast_sys_timer_get(); - TRACE(2,"[%s] takes %d us", __FUNCTION__, + uint32_t end_ticks = hal_fast_sys_timer_get(); + TRACE(2, "[%s] takes %d us", __FUNCTION__, FAST_TICKS_TO_US(end_ticks - start_ticks)); #endif - return 0; + return 0; } -int speech_tx_process(void *pcm_buf, void *ref_buf, int *pcm_len) -{ - if (speech_tx_frame_resizer_enable == false) { - _speech_tx_process_(pcm_buf, ref_buf, (int32_t *)pcm_len); - } else { - // MUST use (int32_t *)?????? - frame_resize_process_capture(speech_frame_resize_st, pcm_buf, ref_buf, (int32_t *)pcm_len); - } +int speech_tx_process(void *pcm_buf, void *ref_buf, int *pcm_len) { + if (speech_tx_frame_resizer_enable == false) { + _speech_tx_process_(pcm_buf, ref_buf, (int32_t *)pcm_len); + } else { + // MUST use (int32_t *)?????? + frame_resize_process_capture(speech_frame_resize_st, pcm_buf, ref_buf, + (int32_t *)pcm_len); + } - return 0; + return 0; } -int speech_rx_process(void *pcm_buf, int *pcm_len) -{ - if (speech_rx_frame_resizer_enable == false) { - _speech_rx_process_(pcm_buf, (int32_t *)pcm_len); - } else { - frame_resize_process_playback(speech_frame_resize_st, pcm_buf, (int32_t *)pcm_len); - } +int speech_rx_process(void *pcm_buf, int *pcm_len) { + if (speech_rx_frame_resizer_enable == false) { + _speech_rx_process_(pcm_buf, (int32_t *)pcm_len); + } else { + frame_resize_process_playback(speech_frame_resize_st, pcm_buf, + (int32_t *)pcm_len); + } - return 0; + return 0; } diff --git a/apps/audioplayers/bt_sco_chain_cfg_default.c b/apps/audioplayers/bt_sco_chain_cfg_default.c index d01b833..cbc8059 100644 --- a/apps/audioplayers/bt_sco_chain_cfg_default.c +++ b/apps/audioplayers/bt_sco_chain_cfg_default.c @@ -13,11 +13,13 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" #include "bt_sco_chain_cfg.h" +#include "plat_types.h" #if defined(SPEECH_TX_2MIC_NS4) -static float ff_fb_h[256] = {1.f, }; +static float ff_fb_h[256] = { + 1.f, +}; #endif #if defined(SPEECH_TX_MIC_CALIBRATION) @@ -27,29 +29,23 @@ static float ff_fb_h[256] = {1.f, }; * Parameters: * bypass(0/1): bypass enable or disable. * mic_num(1~4): the number of microphones. The filter num is (mic_num - 1) - * calib: {bypass, gain, num, {type, frequency, gain, q}}. Please refer to SPEECH_TX_EQ section - * in this file - * Resource consumption: - * RAM: None - * FLASE: None - * MIPS: fs = 16kHz, 0.5M/section; - * Note: - * None -****************************************************************************************************/ -const SpeechIirCalibConfig WEAK speech_tx_mic_calib_cfg = -{ + * calib: {bypass, gain, num, {type, frequency, gain, q}}. Please refer to + *SPEECH_TX_EQ section in this file Resource consumption: RAM: None FLASE: + *None MIPS: fs = 16kHz, 0.5M/section; Note: None + ****************************************************************************************************/ +const SpeechIirCalibConfig WEAK speech_tx_mic_calib_cfg = { .bypass = 0, .mic_num = 2, - .calib = { + .calib = { - .bypass = 0, - .gain = 0.f, - .num = 0, - .params = { - {IIR_BIQUARD_LOWSHELF, 150, -2.5, 0.707}, - } + {.bypass = 0, + .gain = 0.f, + .num = 0, + .params = + { + {IIR_BIQUARD_LOWSHELF, 150, -2.5, 0.707}, + }}, }, - }, }; #endif @@ -60,566 +56,561 @@ const SpeechIirCalibConfig WEAK speech_tx_mic_calib_cfg = * Parameters: * bypass(0/1): bypass enable or disable. * mic_num(1~4): the number of microphones. The filter num is (mic_num - 1) - * calib: {filter, filter_length, nfft}. + * calib: {filter, filter_length, nfft}. * Resource consumption: * RAM: None * FLASE: None * MIPS: fs = 16kHz, 0.5M/section; * Note: * None -****************************************************************************************************/ -float mic2_ft_caliration[256] = {1.f, }; -const SpeechFirCalibConfig WEAK speech_tx_mic_fir_calib_cfg = -{ + ****************************************************************************************************/ +float mic2_ft_caliration[256] = { + 1.f, +}; +const SpeechFirCalibConfig WEAK speech_tx_mic_fir_calib_cfg = { .bypass = 0, .mic_num = SPEECH_CODEC_CAPTURE_CHANNEL_NUM, .delay = 0, - .calib = { + .calib = { - .filter = mic2_ft_caliration, - .filter_length = ARRAY_SIZE(mic2_ft_caliration), + { + .filter = mic2_ft_caliration, + .filter_length = ARRAY_SIZE(mic2_ft_caliration), + }, }, - }, }; #endif const SpeechConfig WEAK speech_cfg_default = { #if defined(SPEECH_TX_DC_FILTER) - .tx_dc_filter = { - .bypass = 0, - .gain = 0, - }, + .tx_dc_filter = + { + .bypass = 0, + .gain = 0, + }, #endif #if defined(SPEECH_TX_AEC) -/**************************************************************************************************** - * Describtion: - * Acoustic Echo Cancellation - * Parameters: - * bypass(0/1): bypass enable or disable. - * delay(>0): delay samples from mic to speak, unit(sample). - * leak_estimate(0~32767): echo supression value. This is a fixed mode. It has relatively large - * echo supression and large damage to speech signal. - * leak_estimate_shift(0~8): echo supression value. if leak_estimate == 0, then leak_estimate_shift - * can take effect. This is a adaptive mode. It has relatively small echo supression and also - * small damage to speech signal. - * Resource consumption: - * RAM: None - * FLASE: None - * MIPS: fs = 16kHz, 40M; - * Note: - * If possible, use SPEECH_TX_AEC2FLOAT -****************************************************************************************************/ - .tx_aec = { - .bypass = 0, - .delay = 60, - .leak_estimate = 16383, - .leak_estimate_shift = 4, - }, + /**************************************************************************************************** + * Describtion: + * Acoustic Echo Cancellation + * Parameters: + * bypass(0/1): bypass enable or disable. + * delay(>0): delay samples from mic to speak, unit(sample). + * leak_estimate(0~32767): echo supression value. This is a fixed mode. + *It has relatively large echo supression and large damage to speech signal. + * leak_estimate_shift(0~8): echo supression value. if leak_estimate == + *0, then leak_estimate_shift can take effect. This is a adaptive mode. It + *has relatively small echo supression and also small damage to speech + *signal. Resource consumption: RAM: None FLASE: None MIPS: fs = + *16kHz, 40M; Note: If possible, use SPEECH_TX_AEC2FLOAT + ****************************************************************************************************/ + .tx_aec = + { + .bypass = 0, + .delay = 60, + .leak_estimate = 16383, + .leak_estimate_shift = 4, + }, #endif #if defined(SPEECH_TX_AEC2) -/**************************************************************************************************** - * Describtion: - * Acoustic Echo Cancellation - * Parameters: - * bypass(0/1): bypass enable or disable. - * . - * . - * . - * Resource consumption: - * RAM: None - * FLASE: None - * MIPS: fs = 16kHz, enNlpEnable = 1, 39M; - * Note: - * If possible, use SPEECH_TX_AEC2FLOAT -****************************************************************************************************/ - .tx_aec2 = { - .bypass = 0, - .enEAecEnable = 1, - .enHpfEnable = 1, - .enAfEnable = 0, - .enNsEnable = 0, - .enNlpEnable = 1, - .enCngEnable = 0, - .shwDelayLength = 0, - .shwNlpBandSortIdx = 0.75f, - .shwNlpBandSortIdxLow = 0.5f, - .shwNlpTargetSupp = 3.0f, - .shwNlpMinOvrd = 1.0f, - }, + /**************************************************************************************************** + * Describtion: + * Acoustic Echo Cancellation + * Parameters: + * bypass(0/1): bypass enable or disable. + * . + * . + * . + * Resource consumption: + * RAM: None + * FLASE: None + * MIPS: fs = 16kHz, enNlpEnable = 1, 39M; + * Note: + * If possible, use SPEECH_TX_AEC2FLOAT + ****************************************************************************************************/ + .tx_aec2 = + { + .bypass = 0, + .enEAecEnable = 1, + .enHpfEnable = 1, + .enAfEnable = 0, + .enNsEnable = 0, + .enNlpEnable = 1, + .enCngEnable = 0, + .shwDelayLength = 0, + .shwNlpBandSortIdx = 0.75f, + .shwNlpBandSortIdxLow = 0.5f, + .shwNlpTargetSupp = 3.0f, + .shwNlpMinOvrd = 1.0f, + }, #endif #if defined(SPEECH_TX_AEC2FLOAT) -/**************************************************************************************************** - * Describtion: - * Acoustic Echo Cancellation - * Parameters: - * bypass(0/1): bypass enable or disable. - * hpf_enabled(0/1): high pass filter enable or disable. Used to remove DC for Near and Ref signals. - * af_enabled(0/1): adaptive filter enable or disable. If the echo signal is very large, enable this - * nlp_enabled(0/1): non-linear process enable or disable. Enable this by default. - * ns_enabled(0/1): noise supression enable or disable. Enable this by default. - * cng_enabled(0/1): comfort noise generator enable or disable. - * blocks(1~8): the length of adaptive filter = blocks * frame length - * delay(>0): delay samples from mic to speak, unit(sample). - * min_ovrd(1~6): supression factor, min_ovrd becomes larger and echo suppression becomes larger. - * target_supp(<0): target echo suppression, unit(dB) - * noise_supp(-30~0): noise suppression, unit(dB) - * cng_type(0/1): noise type(0: White noise; 1: Pink noise) - * cng_level(<0): noise gain, unit(dB) - * Resource consumption: - * RAM: None - * FLASE: None - * MIPS: fs = 16kHz; - * Note: - * This is the recommended AEC -****************************************************************************************************/ - .tx_aec2float = { - .bypass = 0, - .hpf_enabled = false, - .af_enabled = false, - .nlp_enabled = true, - .clip_enabled = false, - .stsupp_enabled = false, - .ns_enabled = true, - .cng_enabled = false, - .blocks = 1, - .delay = 70, - .min_ovrd = 2, - .target_supp = -40, - .noise_supp = -15, - .cng_type = 1, - .cng_level = -60, - .clip_threshold = -20.f, - .banks = 64, - }, + /**************************************************************************************************** + * Describtion: + * Acoustic Echo Cancellation + * Parameters: + * bypass(0/1): bypass enable or disable. + * hpf_enabled(0/1): high pass filter enable or disable. Used to remove + *DC for Near and Ref signals. af_enabled(0/1): adaptive filter enable or + *disable. If the echo signal is very large, enable this nlp_enabled(0/1): + *non-linear process enable or disable. Enable this by default. + * ns_enabled(0/1): noise supression enable or disable. Enable this by + *default. cng_enabled(0/1): comfort noise generator enable or disable. + * blocks(1~8): the length of adaptive filter = blocks * frame length + * delay(>0): delay samples from mic to speak, unit(sample). + * min_ovrd(1~6): supression factor, min_ovrd becomes larger and echo + *suppression becomes larger. target_supp(<0): target echo suppression, + *unit(dB) noise_supp(-30~0): noise suppression, unit(dB) cng_type(0/1): + *noise type(0: White noise; 1: Pink noise) cng_level(<0): noise gain, + *unit(dB) Resource consumption: RAM: None FLASE: None MIPS: fs = + *16kHz; Note: This is the recommended AEC + ****************************************************************************************************/ + .tx_aec2float = + { + .bypass = 0, + .hpf_enabled = false, + .af_enabled = false, + .nlp_enabled = true, + .clip_enabled = false, + .stsupp_enabled = false, + .ns_enabled = true, + .cng_enabled = false, + .blocks = 1, + .delay = 70, + .min_ovrd = 2, + .target_supp = -40, + .noise_supp = -15, + .cng_type = 1, + .cng_level = -60, + .clip_threshold = -20.f, + .banks = 64, + }, #endif #if defined(SPEECH_TX_AEC3) - .tx_aec3 = { - .bypass = 0, - .filter_size = 16, - }, + .tx_aec3 = + { + .bypass = 0, + .filter_size = 16, + }, #endif #if defined(SPEECH_TX_2MIC_NS) -/**************************************************************************************************** - * Describtion: - * 2 MICs Noise Suppression - * Parameters: - * bypass(0/1): bypass enable or disable. - * Resource consumption: - * RAM: None - * FLASE: None - * MIPS: fs = 16kHz; - * Note: - * None -****************************************************************************************************/ - .tx_2mic_ns = { - .bypass = 0, - .alpha_h = 0.8, - .alpha_slow = 0.9, - .alpha_fast = 0.6, - .thegma = 0.01, - .thre_corr = 0.2, - .thre_filter_diff = 0.2, - .cal_left_gain = 1.0, - .cal_right_gain = 1.0, - .delay_mono_sample = 6, - .wnr_enable = 0, - }, + /**************************************************************************************************** + * Describtion: + * 2 MICs Noise Suppression + * Parameters: + * bypass(0/1): bypass enable or disable. + * Resource consumption: + * RAM: None + * FLASE: None + * MIPS: fs = 16kHz; + * Note: + * None + ****************************************************************************************************/ + .tx_2mic_ns = + { + .bypass = 0, + .alpha_h = 0.8, + .alpha_slow = 0.9, + .alpha_fast = 0.6, + .thegma = 0.01, + .thre_corr = 0.2, + .thre_filter_diff = 0.2, + .cal_left_gain = 1.0, + .cal_right_gain = 1.0, + .delay_mono_sample = 6, + .wnr_enable = 0, + }, #endif #if defined(SPEECH_TX_2MIC_NS2) -/**************************************************************************************************** - * Describtion: - * 2 MICs Noise Suppression - * Parameters: - * bypass(0/1): bypass enable or disable. - * delay_taps(0~4): ceil{[d(MIC1~mouth) - d(MIC2~mouth)] / 2}. - * ceil: Returns the largest integer less than or equal to the specified data - * d(MIC~mouth): The dinstance from MIC to mouth - * e.g. 0: 0~2cm; 1: 2~4; 2: 5~6... - * freq_smooth_enable(1): Must enable - * wnr_enable(0/1): wind noise reduction enable or disable. This is also useful for improving - * noise suppression, but it also has some damage to speech signal. - * Resource consumption: - * RAM: None - * FLASE: None - * MIPS: fs = 16kHz, 32M; - * Note: - * None -****************************************************************************************************/ - .tx_2mic_ns2 = { - .bypass = 0, - .delay_taps = 0.f, - .freq_smooth_enable = 1, - .wnr_enable = 1, - }, + /**************************************************************************************************** + * Describtion: + * 2 MICs Noise Suppression + * Parameters: + * bypass(0/1): bypass enable or disable. + * delay_taps(0~4): ceil{[d(MIC1~mouth) - d(MIC2~mouth)] / 2}. + * ceil: Returns the largest integer less than or equal to the + *specified data d(MIC~mouth): The dinstance from MIC to mouth e.g. 0: + *0~2cm; 1: 2~4; 2: 5~6... freq_smooth_enable(1): Must enable + * wnr_enable(0/1): wind noise reduction enable or disable. This is also + *useful for improving noise suppression, but it also has some damage to + *speech signal. Resource consumption: RAM: None FLASE: None MIPS: fs + *= 16kHz, 32M; Note: None + ****************************************************************************************************/ + .tx_2mic_ns2 = + { + .bypass = 0, + .delay_taps = 0.f, + .freq_smooth_enable = 1, + .wnr_enable = 1, + }, #endif #if defined(SPEECH_TX_2MIC_NS5) -/**************************************************************************************************** - * Describtion: - * 2 MICs Noise Suppression - * Parameters: - * bypass(0/1): bypass enable or disable. - * delay_taps(0~4): ceil{[d(MIC1~mouth) - d(MIC2~mouth)] / 2}. Default as 0 - * ceil: Returns the largest integer less than or equal to the specified data - * d(MIC~mouth): The dinstance from MIC to mouth - * e.g. 0: 0~2cm; 1: 2~4; 2: 5~6... - * freq_smooth_enable(1): Must enable - * wnr_enable(0/1): wind noise reduction enable or disable. This is also useful for improving - * noise suppression, but it also has some damage to speech signal. - * delay_enable(0/1): enable the delay_taps or not. Ideally, never need to enable the delay and - * delay_taps will be a useless parameter. - * Resource consumption: - * RAM: None - * FLASE: None - * MIPS: fs = 16kHz, 32M; - * Note: - * None -****************************************************************************************************/ - .tx_2mic_ns5 = { - .bypass = 0, - .delay_taps = 0.0f, - .freq_smooth_enable = 1, - .wnr_enable = 0, - .delay_enable = 0, - }, + /**************************************************************************************************** + * Describtion: + * 2 MICs Noise Suppression + * Parameters: + * bypass(0/1): bypass enable or disable. + * delay_taps(0~4): ceil{[d(MIC1~mouth) - d(MIC2~mouth)] / 2}. Default + *as 0 ceil: Returns the largest integer less than or equal to the specified + *data d(MIC~mouth): The dinstance from MIC to mouth e.g. 0: 0~2cm; 1: 2~4; + *2: 5~6... freq_smooth_enable(1): Must enable wnr_enable(0/1): wind noise + *reduction enable or disable. This is also useful for improving noise + *suppression, but it also has some damage to speech signal. + * delay_enable(0/1): enable the delay_taps or not. Ideally, never need + *to enable the delay and delay_taps will be a useless parameter. Resource + *consumption: RAM: None FLASE: None MIPS: fs = 16kHz, 32M; Note: + * None + ****************************************************************************************************/ + .tx_2mic_ns5 = + { + .bypass = 0, + .delay_taps = 0.0f, + .freq_smooth_enable = 1, + .wnr_enable = 0, + .delay_enable = 0, + }, #endif #if defined(SPEECH_TX_2MIC_NS4) -/**************************************************************************************************** - * Describtion: - * 2 MICs Noise Suppression - * Parameters: - * bypass(0/1): bypass enable or disable. - * Resource consumption: - * RAM: None - * FLASE: None - * MIPS: fs = 16kHz; - * Note: - * None -****************************************************************************************************/ - .tx_2mic_ns4 = { - .bypass = 0, - .blend_en = 1, - // .left_gain = 1.0f, - // .right_gain = 1.0f, - .delay_tapsM = 0, - .delay_tapsS = 0, - // .delay_tapsC = 32, - //////////////////////////{{a0,a1,a2,a3,a4},{b0,b1,b2,b3,b4}}/////////////////////////// - // .coefH[0] = {1.0, -1.88561808316413, 1.55555555555556, -0.628539361054709, 0.111111111111111}, - // .coefH[1] = {0.323801506930344, -1.29520602772138, 1.94280904158206, -1.29520602772138, 0.323801506930344}, - // .coefL[0] = {1.0, -1.88561808316413, 1.55555555555556, -0.628539361054709, 0.111111111111111}, - // .coefL[1] = {0.00953182640298944, 0.0381273056119578, 0.0571909584179366, 0.0381273056119578, 0.00953182640298944}, - .crossover_freq = 1000, - .ff_fb_coeff = ff_fb_h, - .ff_fb_coeff_len = ARRAY_SIZE(ff_fb_h), - }, + /**************************************************************************************************** + * Describtion: + * 2 MICs Noise Suppression + * Parameters: + * bypass(0/1): bypass enable or disable. + * Resource consumption: + * RAM: None + * FLASE: None + * MIPS: fs = 16kHz; + * Note: + * None + ****************************************************************************************************/ + .tx_2mic_ns4 = + { + .bypass = 0, + .blend_en = 1, + // .left_gain = 1.0f, + // .right_gain = 1.0f, + .delay_tapsM = 0, + .delay_tapsS = 0, + // .delay_tapsC = 32, + //////////////////////////{{a0,a1,a2,a3,a4},{b0,b1,b2,b3,b4}}/////////////////////////// + // .coefH[0] = {1.0, -1.88561808316413, 1.55555555555556, + // -0.628539361054709, 0.111111111111111}, .coefH[1] = + // {0.323801506930344, -1.29520602772138, 1.94280904158206, + // -1.29520602772138, 0.323801506930344}, .coefL[0] = + // {1.0, -1.88561808316413, 1.55555555555556, -0.628539361054709, + // 0.111111111111111}, .coefL[1] = {0.00953182640298944, + // 0.0381273056119578, 0.0571909584179366, 0.0381273056119578, + // 0.00953182640298944}, + .crossover_freq = 1000, + .ff_fb_coeff = ff_fb_h, + .ff_fb_coeff_len = ARRAY_SIZE(ff_fb_h), + }, #endif #if defined(SPEECH_TX_3MIC_NS) -/**************************************************************************************************** - * Describtion: - * 3 MICs Noise Suppression - * Parameters: - * bypass(0/1): bypass enable or disable. - * delay_tapsM(0~4): MIC L/R delay samples. Refer to SPEECH_TX_2MIC_NS2 delay_taps - * delay_tapsS(0~4): MIC L/S delay samples. Refer to SPEECH_TX_2MIC_NS2 delay_taps - * freq_smooth_enable(1): Must enable - * wnr_enable(0/1): wind noise reduction enable or disable. This is also useful for improving - * noise suppression, but it also has some damage to speech signal. - * Resource consumption: - * RAM: None - * FLASE: None - * MIPS: fs = 16kHz; - * Note: - * None -****************************************************************************************************/ - .tx_3mic_ns = { - .bypass = 0, - .blend_en = 1, - .authen_en = 1, - .delay_tapsM = 0.65f, - .delay_tapsS = 2, - .denoise_dB = -15.0f, - // .coefH[0] = {1.0,-3.3384,4.2195,-2.3924,0.5136}, - // .coefH[1] = {0.7165,-2.8660,4.2990,-2.8660,0.7165}, - // .coefL[0] = {1.0,-3.3384,4.2195,-2.3924,0.5136}, - // .coefL[1] = {0.00014,0.00056,0.00084,0.00056,0.00014}, - .crossover_freq = 1000, - .freq_smooth_enable = 1, - .wnr_enable = 0, - }, + /**************************************************************************************************** + * Describtion: + * 3 MICs Noise Suppression + * Parameters: + * bypass(0/1): bypass enable or disable. + * delay_tapsM(0~4): MIC L/R delay samples. Refer to SPEECH_TX_2MIC_NS2 + *delay_taps delay_tapsS(0~4): MIC L/S delay samples. Refer to + *SPEECH_TX_2MIC_NS2 delay_taps freq_smooth_enable(1): Must enable + * wnr_enable(0/1): wind noise reduction enable or disable. This is also + *useful for improving noise suppression, but it also has some damage to + *speech signal. Resource consumption: RAM: None FLASE: None MIPS: fs + *= 16kHz; Note: None + ****************************************************************************************************/ + .tx_3mic_ns = + { + .bypass = 0, + .blend_en = 1, + .authen_en = 1, + .delay_tapsM = 0.65f, + .delay_tapsS = 2, + .denoise_dB = -15.0f, + // .coefH[0] = {1.0,-3.3384,4.2195,-2.3924,0.5136}, + // .coefH[1] = {0.7165,-2.8660,4.2990,-2.8660,0.7165}, + // .coefL[0] = {1.0,-3.3384,4.2195,-2.3924,0.5136}, + // .coefL[1] = {0.00014,0.00056,0.00084,0.00056,0.00014}, + .crossover_freq = 1000, + .freq_smooth_enable = 1, + .wnr_enable = 0, + }, #endif #if defined(SPEECH_TX_3MIC_NS3) -/**************************************************************************************************** - * Describtion: - * 3 MICs Noise Suppression - * Parameters: - * bypass(0/1): bypass enable or disable. - * delay_taps(0~4): ceil{[d(MIC1~mouth) - d(MIC2~mouth)] / 2}. - * ceil: Returns the largest integer less than or equal to the specified data - * d(MIC~mouth): The dinstance from MIC to mouth - * e.g. 0: 0~2cm; 1: 2~4; 2: 5~6... - * freq_smooth_enable(1): Must enable - * wnr_enable(0/1): wind noise reduction enable or disable. This is also useful for improving - * noise suppression, but it also has some damage to speech signal. - * Resource consumption: - * RAM: None - * FLASE: None - * MIPS: fs = 16kHz, 32M; - * Note: - * None -****************************************************************************************************/ - .tx_3mic_ns3 = { - .bypass = 0, - .endfire_enable = 1, - .broadside_enable = 1, - .delay_taps = 0.7f, - .freq_smooth_enable = 1, - .wnr_enable = 0, - }, + /**************************************************************************************************** + * Describtion: + * 3 MICs Noise Suppression + * Parameters: + * bypass(0/1): bypass enable or disable. + * delay_taps(0~4): ceil{[d(MIC1~mouth) - d(MIC2~mouth)] / 2}. + * ceil: Returns the largest integer less than or equal to the + *specified data d(MIC~mouth): The dinstance from MIC to mouth e.g. 0: + *0~2cm; 1: 2~4; 2: 5~6... freq_smooth_enable(1): Must enable + * wnr_enable(0/1): wind noise reduction enable or disable. This is also + *useful for improving noise suppression, but it also has some damage to + *speech signal. Resource consumption: RAM: None FLASE: None MIPS: fs + *= 16kHz, 32M; Note: None + ****************************************************************************************************/ + .tx_3mic_ns3 = + { + .bypass = 0, + .endfire_enable = 1, + .broadside_enable = 1, + .delay_taps = 0.7f, + .freq_smooth_enable = 1, + .wnr_enable = 0, + }, #endif #if defined(SPEECH_TX_NS) -/**************************************************************************************************** - * Describtion: - * Noise Suppression - * Parameters: - * bypass(0/1): bypass enable or disable. - * Resource consumption: - * RAM: None - * FLASE: None - * MIPS: fs = 16kHz, 30M; - * Note: - * If possible, use SPEECH_TX_NS2 or SPEECH_TX_NS2FLOAT -****************************************************************************************************/ - .tx_ns = { - .bypass = 0, - .denoise_dB = -12, - }, + /**************************************************************************************************** + * Describtion: + * Noise Suppression + * Parameters: + * bypass(0/1): bypass enable or disable. + * Resource consumption: + * RAM: None + * FLASE: None + * MIPS: fs = 16kHz, 30M; + * Note: + * If possible, use SPEECH_TX_NS2 or SPEECH_TX_NS2FLOAT + ****************************************************************************************************/ + .tx_ns = + { + .bypass = 0, + .denoise_dB = -12, + }, #endif #if defined(SPEECH_TX_NS2) -/**************************************************************************************************** - * Describtion: - * Noise Suppression - * Parameters: - * bypass(0/1): bypass enable or disable. - * denoise_dB(-30~0): noise suppression, unit(dB). - * e.g. -15: Can reduce 15dB of stationary noise. - * Resource consumption: - * RAM: fs = 16k: RAM = 8k; - * fs = 8k: RAM = 4k; - * RAM = frame_size * 30 - * FLASE: None - * MIPS: fs = 16kHz, 16M; - * Note: - * None -****************************************************************************************************/ - .tx_ns2 = { - .bypass = 0, - .denoise_dB = -15, - }, + /**************************************************************************************************** + * Describtion: + * Noise Suppression + * Parameters: + * bypass(0/1): bypass enable or disable. + * denoise_dB(-30~0): noise suppression, unit(dB). + * e.g. -15: Can reduce 15dB of stationary noise. + * Resource consumption: + * RAM: fs = 16k: RAM = 8k; + * fs = 8k: RAM = 4k; + * RAM = frame_size * 30 + * FLASE: None + * MIPS: fs = 16kHz, 16M; + * Note: + * None + ****************************************************************************************************/ + .tx_ns2 = + { + .bypass = 0, + .denoise_dB = -15, + }, #endif #if defined(SPEECH_TX_NS2FLOAT) -/**************************************************************************************************** - * Describtion: - * Noise Suppression - * Parameters: - * bypass(0/1): bypass enable or disable. - * denoise_dB(-30~0): noise suppression, unit(dB). - * e.g. -15: Can reduce 15dB of stationary noise. - * Resource consumption: - * RAM: None - * FLASE: None - * MIPS: fs = 16kHz; - * Note: - * This is a 'float' version for SPEECH_TX_NS2. - * It needs more MIPS and RAM, but can redece quantization noise. -****************************************************************************************************/ - .tx_ns2float = { - .bypass = 0, - .denoise_dB = -15, - .banks = 64, - }, + /**************************************************************************************************** + * Describtion: + * Noise Suppression + * Parameters: + * bypass(0/1): bypass enable or disable. + * denoise_dB(-30~0): noise suppression, unit(dB). + * e.g. -15: Can reduce 15dB of stationary noise. + * Resource consumption: + * RAM: None + * FLASE: None + * MIPS: fs = 16kHz; + * Note: + * This is a 'float' version for SPEECH_TX_NS2. + * It needs more MIPS and RAM, but can redece quantization noise. + ****************************************************************************************************/ + .tx_ns2float = + { + .bypass = 0, + .denoise_dB = -15, + .banks = 64, + }, #endif #if defined(SPEECH_TX_NS3) -/**************************************************************************************************** - * Describtion: - * Noise Suppression - * Parameters: - * bypass(0/1): bypass enable or disable. - * mode: None - * Resource consumption: - * RAM: None - * FLASE: None - * MIPS: fs = 16kHz; - * Note: - * None -****************************************************************************************************/ - .tx_ns3 = { - .bypass = 0, - .mode = NS3_SUPPRESSION_HIGH, - }, + /**************************************************************************************************** + * Describtion: + * Noise Suppression + * Parameters: + * bypass(0/1): bypass enable or disable. + * mode: None + * Resource consumption: + * RAM: None + * FLASE: None + * MIPS: fs = 16kHz; + * Note: + * None + ****************************************************************************************************/ + .tx_ns3 = + { + .bypass = 0, + .mode = NS3_SUPPRESSION_HIGH, + }, #endif #if defined(SPEECH_TX_WNR) -/**************************************************************************************************** - * Describtion: - * Wind Noise Suppression - * Parameters: - * bypass(0/1): bypass enable or disable. - * lpf_cutoff: lowpass filter for wind noise detection - * hpf_cutoff: highpass filter for wind noise suppression - * power_ratio_thr: ratio of the power spectrum of the lower frequencies over the total power - spectrum for all frequencies - * power_thr: normalized power of the low frequencies - * Resource consumption: - * RAM: None - * FLASE: None - * MIPS: fs = 16kHz; - * Note: - * None -****************************************************************************************************/ - .tx_wnr = { - .bypass = 0, - .lpf_cutoff = 1000, - .hpf_cutoff = 400, - .power_ratio_thr = 0.9f, - .power_thr = 1.f, - }, + /**************************************************************************************************** + * Describtion: + * Wind Noise Suppression + * Parameters: + * bypass(0/1): bypass enable or disable. + * lpf_cutoff: lowpass filter for wind noise detection + * hpf_cutoff: highpass filter for wind noise suppression + * power_ratio_thr: ratio of the power spectrum of the lower frequencies + over the total power spectrum for all frequencies + * power_thr: normalized power of the low frequencies + * Resource consumption: + * RAM: None + * FLASE: None + * MIPS: fs = 16kHz; + * Note: + * None + ****************************************************************************************************/ + .tx_wnr = + { + .bypass = 0, + .lpf_cutoff = 1000, + .hpf_cutoff = 400, + .power_ratio_thr = 0.9f, + .power_thr = 1.f, + }, #endif #if defined(SPEECH_TX_NOISE_GATE) -/**************************************************************************************************** - * Describtion: - * Noise Gate - * Parameters: - * bypass(0/1): bypass enable or disable. - * data_threshold(0~32767): distinguish between noise and speech, unit(sample). - * data_shift(1~3): 1: -6dB; 2: -12dB; 3: -18dB - * factor_up(float): attack time, unit(s) - * factor_down(float): release time, unit(s) - * Resource consumption: - * RAM: None - * FLASE: None - * MIPS: fs = 16kHz; - * Note: - * None -****************************************************************************************************/ - .tx_noise_gate = { - .bypass = 0, - .data_threshold = 640, - .data_shift = 1, - .factor_up = 0.001f, - .factor_down = 0.5f, - }, + /**************************************************************************************************** + * Describtion: + * Noise Gate + * Parameters: + * bypass(0/1): bypass enable or disable. + * data_threshold(0~32767): distinguish between noise and speech, + *unit(sample). data_shift(1~3): 1: -6dB; 2: -12dB; 3: -18dB + * factor_up(float): attack time, unit(s) + * factor_down(float): release time, unit(s) + * Resource consumption: + * RAM: None + * FLASE: None + * MIPS: fs = 16kHz; + * Note: + * None + ****************************************************************************************************/ + .tx_noise_gate = + { + .bypass = 0, + .data_threshold = 640, + .data_shift = 1, + .factor_up = 0.001f, + .factor_down = 0.5f, + }, #endif #if defined(SPEECH_TX_COMPEXP) -/**************************************************************************************************** - * Describtion: - * Compressor and expander - * Parameters: - * bypass(0/1): bypass enable or disable. - * ... - * Resource consumption: - * RAM: None - * FLASE: None - * MIPS: fs = 16kHz; - * Note: - * None -****************************************************************************************************/ - .tx_compexp = { - .bypass = 0, - .comp_threshold = -10.f, - .comp_ratio = 2.f, - .expand_threshold = -45.f, - .expand_ratio = 0.5556f, - .attack_time = 0.001f, - .release_time = 0.6f, - .makeup_gain = 6, - .delay = 128, - }, + /**************************************************************************************************** + * Describtion: + * Compressor and expander + * Parameters: + * bypass(0/1): bypass enable or disable. + * ... + * Resource consumption: + * RAM: None + * FLASE: None + * MIPS: fs = 16kHz; + * Note: + * None + ****************************************************************************************************/ + .tx_compexp = + { + .bypass = 0, + .comp_threshold = -10.f, + .comp_ratio = 2.f, + .expand_threshold = -45.f, + .expand_ratio = 0.5556f, + .attack_time = 0.001f, + .release_time = 0.6f, + .makeup_gain = 6, + .delay = 128, + }, #endif #if defined(SPEECH_TX_AGC) -/**************************************************************************************************** - * Describtion: - * Automatic Gain Control - * Parameters: - * bypass(0/1): bypass enable or disable. - * target_level(>0): signal can not exceed (-1 * target_level)dB. - * compression_gain(>0): excepted gain. - * limiter_enable(0/1): 0: target_level does not take effect; 1: target_level takes effect. - * Resource consumption: - * RAM: None - * FLASE: None - * MIPS: fs = 16kHz, 3M; - * Note: - * None -****************************************************************************************************/ - .tx_agc = { - .bypass = 0, - .target_level = 3, - .compression_gain = 6, - .limiter_enable = 1, - }, + /**************************************************************************************************** + * Describtion: + * Automatic Gain Control + * Parameters: + * bypass(0/1): bypass enable or disable. + * target_level(>0): signal can not exceed (-1 * target_level)dB. + * compression_gain(>0): excepted gain. + * limiter_enable(0/1): 0: target_level does not take effect; 1: + *target_level takes effect. Resource consumption: RAM: None FLASE: None + * MIPS: fs = 16kHz, 3M; + * Note: + * None + ****************************************************************************************************/ + .tx_agc = + { + .bypass = 0, + .target_level = 3, + .compression_gain = 6, + .limiter_enable = 1, + }, #endif #if defined(SPEECH_TX_EQ) -/**************************************************************************************************** - * Describtion: - * Equalizer, implementation with 2 order iir filters - * Parameters: - * bypass(0/1): bypass enable or disable. - * gain(float): normalized gain. It is usually less than or equal to 0 - * num(0~6): the number of EQs - * params: {type, frequency, gain, q}. It supports a lot of types, please refer to iirfilt.h file - * Resource consumption: - * RAM: None - * FLASE: None - * MIPS: fs = 16kHz, 0.5M/section; - * Note: - * None -****************************************************************************************************/ - .tx_eq = { - .bypass = 0, - .gain = 0.f, - .num = 1, - .params = { - {IIR_BIQUARD_HPF, {{60, 0, 0.707f}}}, + /**************************************************************************************************** + * Describtion: + * Equalizer, implementation with 2 order iir filters + * Parameters: + * bypass(0/1): bypass enable or disable. + * gain(float): normalized gain. It is usually less than or equal to 0 + * num(0~6): the number of EQs + * params: {type, frequency, gain, q}. It supports a lot of types, + *please refer to iirfilt.h file Resource consumption: RAM: None FLASE: + *None MIPS: fs = 16kHz, 0.5M/section; Note: None + ****************************************************************************************************/ + .tx_eq = + { + .bypass = 0, + .gain = 0.f, + .num = 1, + .params = + { + {IIR_BIQUARD_HPF, {{60, 0, 0.707f}}}, + }, }, - }, #endif #if defined(SPEECH_TX_POST_GAIN) -/**************************************************************************************************** - * Describtion: - * Linear Gain - * Parameters: - * bypass(0/1): bypass enable or disable. - * Resource consumption: - * RAM: None - * FLASE: None - * MIPS: fs = 16kHz; - * Note: - * None -****************************************************************************************************/ - .tx_post_gain = { - .bypass = 0, - .gain_dB = 6.0f, - }, + /**************************************************************************************************** + * Describtion: + * Linear Gain + * Parameters: + * bypass(0/1): bypass enable or disable. + * Resource consumption: + * RAM: None + * FLASE: None + * MIPS: fs = 16kHz; + * Note: + * None + ****************************************************************************************************/ + .tx_post_gain = + { + .bypass = 0, + .gain_dB = 6.0f, + }, #endif // #if defined(SPEECH_CS_VAD) @@ -642,155 +633,165 @@ const SpeechConfig WEAK speech_cfg_default = { // #endif #if defined(SPEECH_RX_NS) -/**************************************************************************************************** - * Describtion: - * Acoustic Echo Cancellation - * Parameters: - * Refer to SPEECH_TX_NS - * Note: - * None -****************************************************************************************************/ - .rx_ns = { - .bypass = 0, - .denoise_dB = -12, - }, + /**************************************************************************************************** + * Describtion: + * Acoustic Echo Cancellation + * Parameters: + * Refer to SPEECH_TX_NS + * Note: + * None + ****************************************************************************************************/ + .rx_ns = + { + .bypass = 0, + .denoise_dB = -12, + }, #endif #if defined(SPEECH_RX_NS2) -/**************************************************************************************************** - * Describtion: - * Acoustic Echo Cancellation - * Parameters: - * Refer to SPEECH_TX_NS2 - * Note: - * None -****************************************************************************************************/ - .rx_ns2 = { - .bypass = 0, - .denoise_dB = -15, - }, + /**************************************************************************************************** + * Describtion: + * Acoustic Echo Cancellation + * Parameters: + * Refer to SPEECH_TX_NS2 + * Note: + * None + ****************************************************************************************************/ + .rx_ns2 = + { + .bypass = 0, + .denoise_dB = -15, + }, #endif #if defined(SPEECH_RX_NS2FLOAT) -/**************************************************************************************************** - * Describtion: - * Acoustic Echo Cancellation - * Parameters: - * Refer to SPEECH_TX_NS2FLOAT - * Note: - * None -****************************************************************************************************/ - .rx_ns2float = { - .bypass = 0, - .denoise_dB = -15, - .banks = 64, - }, + /**************************************************************************************************** + * Describtion: + * Acoustic Echo Cancellation + * Parameters: + * Refer to SPEECH_TX_NS2FLOAT + * Note: + * None + ****************************************************************************************************/ + .rx_ns2float = + { + .bypass = 0, + .denoise_dB = -15, + .banks = 64, + }, #endif #if defined(SPEECH_RX_NS3) -/**************************************************************************************************** - * Describtion: - * Acoustic Echo Cancellation - * Parameters: - * Refer to SPEECH_TX_NS3 - * Note: - * None -****************************************************************************************************/ - .rx_ns3 = { - .bypass = 0, - .mode = NS3_SUPPRESSION_HIGH, - }, + /**************************************************************************************************** + * Describtion: + * Acoustic Echo Cancellation + * Parameters: + * Refer to SPEECH_TX_NS3 + * Note: + * None + ****************************************************************************************************/ + .rx_ns3 = + { + .bypass = 0, + .mode = NS3_SUPPRESSION_HIGH, + }, #endif #if defined(SPEECH_RX_NOISE_GATE) -/**************************************************************************************************** - * Describtion: - * Noise Gate - * Parameters: - * Refer to SPEECH_TX_NOISE_GATE - * Note: - * None -****************************************************************************************************/ - .rx_noise_gate = { - .bypass = 0, - .data_threshold = 640, - .data_shift = 1, - .factor_up = 0.001f, - .factor_down = 0.5f, - }, + /**************************************************************************************************** + * Describtion: + * Noise Gate + * Parameters: + * Refer to SPEECH_TX_NOISE_GATE + * Note: + * None + ****************************************************************************************************/ + .rx_noise_gate = + { + .bypass = 0, + .data_threshold = 640, + .data_shift = 1, + .factor_up = 0.001f, + .factor_down = 0.5f, + }, #endif #if defined(SPEECH_RX_COMPEXP) -/**************************************************************************************************** - * Describtion: - * Compressor and expander - * Parameters: - * Refer to SPEECH_TX_COMPEXP - * Note: - * None -****************************************************************************************************/ - .rx_compexp = { - .bypass = 0, - .comp_threshold = -10.f, - .comp_slope = 0.5f, - .expand_threshold = -40.f, - .expand_slope = -0.5f, - .attack_time = 0.01f, - .release_time = 0.6f, - .makeup_gain = 6, - .delay = 128, - }, + /**************************************************************************************************** + * Describtion: + * Compressor and expander + * Parameters: + * Refer to SPEECH_TX_COMPEXP + * Note: + * None + ****************************************************************************************************/ + .rx_compexp = + { + .bypass = 0, + .comp_threshold = -10.f, + .comp_slope = 0.5f, + .expand_threshold = -40.f, + .expand_slope = -0.5f, + .attack_time = 0.01f, + .release_time = 0.6f, + .makeup_gain = 6, + .delay = 128, + }, #endif #if defined(SPEECH_RX_AGC) -/**************************************************************************************************** - * Describtion: - * Automatic Gain Control - * Parameters: - * Refer to SPEECH_TX_AGC - * Note: - * None -****************************************************************************************************/ - .rx_agc = { - .bypass = 0, - .target_level = 3, - .compression_gain = 6, - .limiter_enable = 1, - }, + /**************************************************************************************************** + * Describtion: + * Automatic Gain Control + * Parameters: + * Refer to SPEECH_TX_AGC + * Note: + * None + ****************************************************************************************************/ + .rx_agc = + { + .bypass = 0, + .target_level = 3, + .compression_gain = 6, + .limiter_enable = 1, + }, #endif #if defined(SPEECH_RX_EQ) -/**************************************************************************************************** - * Describtion: - * Equalizer, implementation with 2 order iir filters - * Parameters: - * Refer to SPEECH_TX_EQ - * Note: - * None -****************************************************************************************************/ - .rx_eq = { - .bypass = 0, - .gain = 0.f, - .num = 1, - .params = { - {IIR_BIQUARD_HPF, {{60, 0, 0.707f}}}, + /**************************************************************************************************** + * Describtion: + * Equalizer, implementation with 2 order iir filters + * Parameters: + * Refer to SPEECH_TX_EQ + * Note: + * None + ****************************************************************************************************/ + .rx_eq = + { + .bypass = 0, + .gain = 0.f, + .num = 1, + .params = + { + {IIR_BIQUARD_HPF, {{60, 0, 0.707f}}}, + }, }, - }, #endif #if defined(SPEECH_RX_POST_GAIN) -/**************************************************************************************************** - * Describtion: - * Linear Gain - * Parameters: - * Refer to SPEECH_TX_POST_GAIN - * Note: - * None -****************************************************************************************************/ - .rx_post_gain = { - .bypass = 0, - .gain_dB = 6.0f, - }, + /**************************************************************************************************** + * Describtion: + * Linear Gain + * Parameters: + * Refer to SPEECH_TX_POST_GAIN + * Note: + * None + ****************************************************************************************************/ + .rx_post_gain = + { + .bypass = 0, + .gain_dB = 6.0f, + }, #endif }; diff --git a/apps/audioplayers/bt_sco_chain_cp.c b/apps/audioplayers/bt_sco_chain_cp.c index 0d19521..a8db425 100644 --- a/apps/audioplayers/bt_sco_chain_cp.c +++ b/apps/audioplayers/bt_sco_chain_cp.c @@ -17,14 +17,18 @@ * Usage: * 1. Enable SCO_CP_ACCEL ?= 1 to enable dual core in sco * 2. Enable SCO_TRACE_CP_ACCEL ?= 1 to see debug log. - * 3. Change channel number if the algo(run in cp) input is more than one channel: sco_cp_init(speech_tx_frame_len, 1); - * 4. The code between SCO_CP_ACCEL_ALGO_START(); and SCO_CP_ACCEL_ALGO_END(); will run in CP core. - * 5. These algorithms will work in AP. Need to move this algorithms from overlay to fast ram. + * 3. Change channel number if the algo(run in cp) input is more than one + *channel: sco_cp_init(speech_tx_frame_len, 1); + * 4. The code between SCO_CP_ACCEL_ALGO_START(); and SCO_CP_ACCEL_ALGO_END(); + *will run in CP core. + * 5. These algorithms will work in AP. Need to move this algorithms from + *overlay to fast ram. * * NOTE: - * 1. spx fft and hw fft will share buffer, so just one core can use these fft. - * 2. audio_dump_add_channel_data function can not work correctly in CP core, because - * audio_dump_add_channel_data is possible called after audio_dump_run(); + * 1. spx fft and hw fft will share buffer, so just one core can use these + *fft. + * 2. audio_dump_add_channel_data function can not work correctly in CP core, + *because audio_dump_add_channel_data is possible called after audio_dump_run(); * 3. AP and CP just can use 85% * * @@ -33,30 +37,30 @@ * 1. FFT, RAM, CODE overlay **/ #if defined(SCO_CP_ACCEL) +#include "cmsis_os.h" #include "cp_accel.h" #include "hal_location.h" -#include "hal_trace.h" #include "hal_timer.h" -#include "cmsis_os.h" -#include "speech_cfg.h" +#include "hal_trace.h" #include "math.h" #include "norflash_api.h" +#include "speech_cfg.h" // malloc data from pool in init function -#define FRAME_LEN_MAX (256) -#define CHANNEL_NUM_MAX (2) +#define FRAME_LEN_MAX (256) +#define CHANNEL_NUM_MAX (2) enum CP_SCO_STATE_T { - CP_SCO_STATE_NONE = 0, - CP_SCO_STATE_IDLE, - CP_SCO_STATE_WORKING, + CP_SCO_STATE_NONE = 0, + CP_SCO_STATE_IDLE, + CP_SCO_STATE_WORKING, }; enum SCO_CP_CMD_T { - SCO_CP_CMD_PRO = 0, - SCO_CP_CMD_OTHER, + SCO_CP_CMD_PRO = 0, + SCO_CP_CMD_OTHER, - SCO_CP_CMD_QTY, + SCO_CP_CMD_QTY, }; static CP_DATA_LOC enum CP_SCO_STATE_T g_cp_state = CP_SCO_STATE_NONE; @@ -74,45 +78,43 @@ static CP_BSS_LOC int g_channel_num; static int g_require_cnt = 0; static int g_run_cnt = 0; -int sco_cp_process(short *pcm_buf, short *ref_buf, int *_pcm_len) -{ - int32_t pcm_len = *_pcm_len; - uint32_t wait_cnt = 0; +int sco_cp_process(short *pcm_buf, short *ref_buf, int *_pcm_len) { + int32_t pcm_len = *_pcm_len; + uint32_t wait_cnt = 0; - ASSERT(g_frame_len * g_channel_num == pcm_len, "[%s] g_frame_len(%d) * g_channel_num(%d) != pcm_len(%d)", __func__, g_frame_len, g_channel_num, pcm_len); + ASSERT(g_frame_len * g_channel_num == pcm_len, + "[%s] g_frame_len(%d) * g_channel_num(%d) != pcm_len(%d)", __func__, + g_frame_len, g_channel_num, pcm_len); - // Check CP has new data to get and can get data from buffer + // Check CP has new data to get and can get data from buffer #if defined(SCO_TRACE_CP_ACCEL) - TRACE(4,"[%s] g_require_cnt: %d, status: %d, pcm_len: %d", __func__, g_require_cnt, g_cp_state, pcm_len); + TRACE(4, "[%s] g_require_cnt: %d, status: %d, pcm_len: %d", __func__, + g_require_cnt, g_cp_state, pcm_len); #endif - while (g_cp_state == CP_SCO_STATE_WORKING) - { - hal_sys_timer_delay_us(10); + while (g_cp_state == CP_SCO_STATE_WORKING) { + hal_sys_timer_delay_us(10); - if (wait_cnt++ > 300000) { // 3s - ASSERT(0, "cp is hung %d", g_cp_state); - } + if (wait_cnt++ > 300000) { // 3s + ASSERT(0, "cp is hung %d", g_cp_state); } + } - if (g_cp_state == CP_SCO_STATE_IDLE) - { - speech_copy_int16(g_in_pcm_buf, pcm_buf, pcm_len); - if (ref_buf) - { - speech_copy_int16(g_in_ref_buf, ref_buf, pcm_len / g_channel_num); - } - speech_copy_int16(pcm_buf, g_out_pcm_buf, g_pcm_len); - *_pcm_len = g_pcm_len; - g_pcm_len = pcm_len; - - g_require_cnt++; - g_cp_state = CP_SCO_STATE_WORKING; - cp_accel_send_event_mcu2cp(CP_BUILD_ID(CP_TASK_SCO, CP_EVENT_SCO_PROCESSING)); + if (g_cp_state == CP_SCO_STATE_IDLE) { + speech_copy_int16(g_in_pcm_buf, pcm_buf, pcm_len); + if (ref_buf) { + speech_copy_int16(g_in_ref_buf, ref_buf, pcm_len / g_channel_num); } - else - { - // Multi channels to one channel + speech_copy_int16(pcm_buf, g_out_pcm_buf, g_pcm_len); + *_pcm_len = g_pcm_len; + g_pcm_len = pcm_len; + + g_require_cnt++; + g_cp_state = CP_SCO_STATE_WORKING; + cp_accel_send_event_mcu2cp( + CP_BUILD_ID(CP_TASK_SCO, CP_EVENT_SCO_PROCESSING)); + } else { + // Multi channels to one channel #if 0 for (int i = 0; i < pcm_len / g_channel_num; i++) { @@ -122,26 +124,25 @@ int sco_cp_process(short *pcm_buf, short *ref_buf, int *_pcm_len) *_pcm_len = pcm_len / g_channel_num; #endif - // Check abs(g_require_cnt - g_run_cnt) > threshold, reset or assert + // Check abs(g_require_cnt - g_run_cnt) > threshold, reset or assert - TRACE(2,"[%s] ERROR: status = %d", __func__, g_cp_state); - } + TRACE(2, "[%s] ERROR: status = %d", __func__, g_cp_state); + } - return 0; + return 0; } extern int sco_cp_algo(short *pcm_buf, short *ref_buf, int *_pcm_len); CP_TEXT_SRAM_LOC -static unsigned int sco_cp_main(uint8_t event) -{ +static unsigned int sco_cp_main(uint8_t event) { #if defined(SCO_TRACE_CP_ACCEL) - TRACE(2,"[%s] g_run_cnt: %d", __func__, g_run_cnt); + TRACE(2, "[%s] g_run_cnt: %d", __func__, g_run_cnt); #endif - // LOCK BUFFER + // LOCK BUFFER - // process pcm + // process pcm #if 0 // speech_copy_int16(g_out_pcm_buf, g_in_pcm_buf, g_pcm_len); @@ -150,79 +151,81 @@ static unsigned int sco_cp_main(uint8_t event) g_out_pcm_buf[i] = (short)(sinf(2 * 3.1415926 * i / 16 ) * 10000); } #else - sco_cp_algo(g_in_pcm_buf, g_in_ref_buf, &g_pcm_len); - speech_copy_int16(g_out_pcm_buf, g_in_pcm_buf, g_pcm_len); + sco_cp_algo(g_in_pcm_buf, g_in_ref_buf, &g_pcm_len); + speech_copy_int16(g_out_pcm_buf, g_in_pcm_buf, g_pcm_len); #endif - // set status - g_run_cnt++; - g_cp_state = CP_SCO_STATE_IDLE; + // set status + g_run_cnt++; + g_cp_state = CP_SCO_STATE_IDLE; #if defined(SCO_TRACE_CP_ACCEL) - TRACE(1,"[%s] CP_SCO_STATE_IDLE", __func__); + TRACE(1, "[%s] CP_SCO_STATE_IDLE", __func__); #endif - // UNLOCK BUFFER + // UNLOCK BUFFER - return 0; + return 0; } -static struct cp_task_desc TASK_DESC_SCO = {CP_ACCEL_STATE_CLOSED, sco_cp_main, NULL, NULL, NULL}; -int sco_cp_init(int frame_len, int channel_num) -{ - TRACE(3,"[%s] frame_len: %d, channel_num: %d", __func__, frame_len, channel_num); - ASSERT(frame_len <= FRAME_LEN_MAX, "[%s] frame_len(%d) > FRAME_LEN_MAX", __func__, frame_len); - ASSERT(channel_num <= CHANNEL_NUM_MAX, "[%s] channel_num(%d) > CHANNEL_NUM_MAX", __func__, channel_num); +static struct cp_task_desc TASK_DESC_SCO = {CP_ACCEL_STATE_CLOSED, sco_cp_main, + NULL, NULL, NULL}; +int sco_cp_init(int frame_len, int channel_num) { + TRACE(3, "[%s] frame_len: %d, channel_num: %d", __func__, frame_len, + channel_num); + ASSERT(frame_len <= FRAME_LEN_MAX, "[%s] frame_len(%d) > FRAME_LEN_MAX", + __func__, frame_len); + ASSERT(channel_num <= CHANNEL_NUM_MAX, + "[%s] channel_num(%d) > CHANNEL_NUM_MAX", __func__, channel_num); - g_require_cnt = 0; - g_run_cnt = 0; + g_require_cnt = 0; + g_run_cnt = 0; - norflash_api_flush_disable(NORFLASH_API_USER_CP,(uint32_t)cp_accel_init_done); - cp_accel_open(CP_TASK_SCO, &TASK_DESC_SCO); + norflash_api_flush_disable(NORFLASH_API_USER_CP, + (uint32_t)cp_accel_init_done); + cp_accel_open(CP_TASK_SCO, &TASK_DESC_SCO); - uint32_t cnt=0; - while(cp_accel_init_done() == false) { - hal_sys_timer_delay_us(100); - - cnt++; - if (cnt % 10 == 0) { - if (cnt == 10 * 200) { // 200ms - ASSERT(0, "[%s] ERROR: Can not init cp!!!", __func__); - } else { - TRACE(1, "[%s] Wait CP init done...%d(ms)", __func__, cnt/10); - } - } + uint32_t cnt = 0; + while (cp_accel_init_done() == false) { + hal_sys_timer_delay_us(100); + + cnt++; + if (cnt % 10 == 0) { + if (cnt == 10 * 200) { // 200ms + ASSERT(0, "[%s] ERROR: Can not init cp!!!", __func__); + } else { + TRACE(1, "[%s] Wait CP init done...%d(ms)", __func__, cnt / 10); + } } - norflash_api_flush_enable(NORFLASH_API_USER_CP); + } + norflash_api_flush_enable(NORFLASH_API_USER_CP); #if 0 speech_heap_cp_start(); speech_heap_add_block(g_cp_heap_buf, sizeof(g_cp_heap_buf)); speech_heap_cp_end(); #endif - g_frame_len = frame_len; - g_channel_num = channel_num; - g_pcm_len = frame_len; // Initialize output pcm_len + g_frame_len = frame_len; + g_channel_num = channel_num; + g_pcm_len = frame_len; // Initialize output pcm_len - speech_set_int16(g_in_pcm_buf, 0, g_frame_len * g_channel_num); - speech_set_int16(g_out_pcm_buf, 0, g_frame_len * g_channel_num); - speech_set_int16(g_in_ref_buf, 0, g_frame_len); - g_cp_state = CP_SCO_STATE_IDLE; + speech_set_int16(g_in_pcm_buf, 0, g_frame_len * g_channel_num); + speech_set_int16(g_out_pcm_buf, 0, g_frame_len * g_channel_num); + speech_set_int16(g_in_ref_buf, 0, g_frame_len); + g_cp_state = CP_SCO_STATE_IDLE; - TRACE(2,"[%s] status = %d", __func__, g_cp_state); - - return 0; + TRACE(2, "[%s] status = %d", __func__, g_cp_state); + return 0; } -int sco_cp_deinit(void) -{ - TRACE(1,"[%s] ...", __func__); +int sco_cp_deinit(void) { + TRACE(1, "[%s] ...", __func__); - cp_accel_close(CP_TASK_SCO); + cp_accel_close(CP_TASK_SCO); - g_cp_state = CP_SCO_STATE_NONE; + g_cp_state = CP_SCO_STATE_NONE; - return 0; + return 0; } #endif diff --git a/apps/audioplayers/bt_sco_chain_thirdparty.c b/apps/audioplayers/bt_sco_chain_thirdparty.c index a82f36f..188eacf 100644 --- a/apps/audioplayers/bt_sco_chain_thirdparty.c +++ b/apps/audioplayers/bt_sco_chain_thirdparty.c @@ -1,9 +1,9 @@ +#include "audio_dump.h" #include "bt_sco_chain.h" +#include "hal_trace.h" +#include "speech_cfg.h" #include "speech_memory.h" #include "speech_utils.h" -#include "hal_trace.h" -#include "audio_dump.h" -#include "speech_cfg.h" #if defined(SPEECH_TX_24BIT) int32_t *aec_echo_buf = NULL; @@ -27,129 +27,134 @@ static short *aec_echo_buf_ptr; SpeechDcFilterState *speech_tx_dc_filter_st = NULL; #endif -int speech_init(int tx_sample_rate, int rx_sample_rate, - int tx_frame_ms, int rx_frame_ms, - int sco_frame_ms, - uint8_t *buf, int len) -{ - // we shoule keep a minmum buffer for speech heap - // MSBC_16K_SAMPLE_RATE = 0, 560 bytes - // MSBC_16K_SAMPLE_RATE = 1, 2568 bytes - speech_heap_init(buf, SPEECH_HEAP_RESERVE_SIZE); +int speech_init(int tx_sample_rate, int rx_sample_rate, int tx_frame_ms, + int rx_frame_ms, int sco_frame_ms, uint8_t *buf, int len) { + // we shoule keep a minmum buffer for speech heap + // MSBC_16K_SAMPLE_RATE = 0, 560 bytes + // MSBC_16K_SAMPLE_RATE = 1, 2568 bytes + speech_heap_init(buf, SPEECH_HEAP_RESERVE_SIZE); - uint8_t *free_buf = buf + SPEECH_HEAP_RESERVE_SIZE; - int free_len = len - SPEECH_HEAP_RESERVE_SIZE; + uint8_t *free_buf = buf + SPEECH_HEAP_RESERVE_SIZE; + int free_len = len - SPEECH_HEAP_RESERVE_SIZE; - // use free_buf for your algorithm - memset(free_buf, 0, free_len); + // use free_buf for your algorithm + memset(free_buf, 0, free_len); - int frame_len = SPEECH_FRAME_MS_TO_LEN(tx_sample_rate, tx_frame_ms); + int frame_len = SPEECH_FRAME_MS_TO_LEN(tx_sample_rate, tx_frame_ms); #if defined(SPEECH_TX_24BIT) - aec_echo_buf = (int32_t *)speech_calloc(frame_len, sizeof(int32_t)); + aec_echo_buf = (int32_t *)speech_calloc(frame_len, sizeof(int32_t)); #else - aec_echo_buf = (short *)speech_calloc(frame_len, sizeof(short)); + aec_echo_buf = (short *)speech_calloc(frame_len, sizeof(short)); #endif - aec_echo_buf_ptr = aec_echo_buf; + aec_echo_buf_ptr = aec_echo_buf; #if defined(SPEECH_TX_DC_FILTER) - int channel_num = SPEECH_CODEC_CAPTURE_CHANNEL_NUM; - int data_separation = 0; + int channel_num = SPEECH_CODEC_CAPTURE_CHANNEL_NUM; + int data_separation = 0; - SpeechDcFilterConfig dc_filter_cfg = { - .bypass = 0, - .gain = 0.f, - }; + SpeechDcFilterConfig dc_filter_cfg = { + .bypass = 0, + .gain = 0.f, + }; - speech_tx_dc_filter_st = speech_dc_filter_create(tx_sample_rate, frame_len, &dc_filter_cfg); - speech_dc_filter_ctl(speech_tx_dc_filter_st, SPEECH_DC_FILTER_SET_CHANNEL_NUM, &channel_num); - speech_dc_filter_ctl(speech_tx_dc_filter_st, SPEECH_DC_FILTER_SET_DATA_SEPARATION, &data_separation); + speech_tx_dc_filter_st = + speech_dc_filter_create(tx_sample_rate, frame_len, &dc_filter_cfg); + speech_dc_filter_ctl(speech_tx_dc_filter_st, SPEECH_DC_FILTER_SET_CHANNEL_NUM, + &channel_num); + speech_dc_filter_ctl(speech_tx_dc_filter_st, + SPEECH_DC_FILTER_SET_DATA_SEPARATION, &data_separation); #endif - audio_dump_init(frame_len, sizeof(int16_t), 3); + audio_dump_init(frame_len, sizeof(int16_t), 3); - return 0; + return 0; } -int speech_deinit(void) -{ +int speech_deinit(void) { #if defined(SPEECH_TX_DC_FILTER) - speech_dc_filter_destroy(speech_tx_dc_filter_st); + speech_dc_filter_destroy(speech_tx_dc_filter_st); #endif - speech_free(aec_echo_buf_ptr); + speech_free(aec_echo_buf_ptr); - size_t total = 0, used = 0, max_used = 0; - speech_memory_info(&total, &used, &max_used); - TRACE(3,"SPEECH MALLOC MEM: total - %d, used - %d, max_used - %d.", total, used, max_used); - ASSERT(used == 0, "[%s] used != 0", __func__); + size_t total = 0, used = 0, max_used = 0; + speech_memory_info(&total, &used, &max_used); + TRACE(3, "SPEECH MALLOC MEM: total - %d, used - %d, max_used - %d.", total, + used, max_used); + ASSERT(used == 0, "[%s] used != 0", __func__); - return 0; + return 0; } #if defined(BONE_SENSOR_TDM) extern void bt_sco_get_tdm_buffer(uint8_t **buf, uint32_t *len); #endif -int speech_tx_process(void *_pcm_buf, void *_ref_buf, int *_pcm_len) -{ +int speech_tx_process(void *_pcm_buf, void *_ref_buf, int *_pcm_len) { #if defined(SPEECH_TX_24BIT) - int32_t *pcm_buf = (int32_t *)_pcm_buf; - int32_t *ref_buf = (int32_t *)_ref_buf; + int32_t *pcm_buf = (int32_t *)_pcm_buf; + int32_t *ref_buf = (int32_t *)_ref_buf; #else - int16_t *pcm_buf = (int16_t *)_pcm_buf; - int16_t *ref_buf = (int16_t *)_ref_buf; + int16_t *pcm_buf = (int16_t *)_pcm_buf; + int16_t *ref_buf = (int16_t *)_ref_buf; #endif - int pcm_len = *_pcm_len; + int pcm_len = *_pcm_len; #if defined(BONE_SENSOR_TDM) - uint8_t *bone_buf = NULL; - uint32_t bone_len = 0; - bt_sco_get_tdm_buffer(&bone_buf, &bone_len); + uint8_t *bone_buf = NULL; + uint32_t bone_len = 0; + bt_sco_get_tdm_buffer(&bone_buf, &bone_len); #endif - audio_dump_clear_up(); - audio_dump_add_channel_data(0, ref_buf, pcm_len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM); - audio_dump_add_channel_data_from_multi_channels(1, pcm_buf, pcm_len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM, SPEECH_CODEC_CAPTURE_CHANNEL_NUM, 0); - audio_dump_add_channel_data_from_multi_channels(2, pcm_buf, pcm_len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM, SPEECH_CODEC_CAPTURE_CHANNEL_NUM, 1); + audio_dump_clear_up(); + audio_dump_add_channel_data(0, ref_buf, + pcm_len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM); + audio_dump_add_channel_data_from_multi_channels( + 1, pcm_buf, pcm_len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM, + SPEECH_CODEC_CAPTURE_CHANNEL_NUM, 0); + audio_dump_add_channel_data_from_multi_channels( + 2, pcm_buf, pcm_len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM, + SPEECH_CODEC_CAPTURE_CHANNEL_NUM, 1); #if defined(BONE_SENSOR_TDM) - audio_dump_add_channel_data(3, bone_buf, pcm16_len/SPEECH_CODEC_CAPTURE_CHANNEL_NUM); + audio_dump_add_channel_data(3, bone_buf, + pcm16_len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM); #endif - audio_dump_run(); + audio_dump_run(); #if defined(SPEECH_TX_DC_FILTER) #if defined(SPEECH_TX_24BIT) - speech_dc_filter_process_int24(speech_tx_dc_filter_st, pcm_buf, pcm_len); + speech_dc_filter_process_int24(speech_tx_dc_filter_st, pcm_buf, pcm_len); #else - speech_dc_filter_process(speech_tx_dc_filter_st, pcm_buf, pcm_len); + speech_dc_filter_process(speech_tx_dc_filter_st, pcm_buf, pcm_len); #endif #endif - // Add your algrithm here and disable #if macro + // Add your algrithm here and disable #if macro #if 1 - for (int i = 0, j = 0; i < pcm_len; i += SPEECH_CODEC_CAPTURE_CHANNEL_NUM, j++) { - // choose main microphone data - pcm_buf[j] = pcm_buf[i]; - // choose reference data, i.e. loopback - //pcm16_buf[j] = ref16_buf[j]; - } - pcm_len /= SPEECH_CODEC_CAPTURE_CHANNEL_NUM; + for (int i = 0, j = 0; i < pcm_len; + i += SPEECH_CODEC_CAPTURE_CHANNEL_NUM, j++) { + // choose main microphone data + pcm_buf[j] = pcm_buf[i]; + // choose reference data, i.e. loopback + // pcm16_buf[j] = ref16_buf[j]; + } + pcm_len /= SPEECH_CODEC_CAPTURE_CHANNEL_NUM; #endif #if defined(BONE_SENSOR_TDM) - memcpy(pcm_buf, bone_buf, bone_len); + memcpy(pcm_buf, bone_buf, bone_len); #endif - *_pcm_len = pcm_len; + *_pcm_len = pcm_len; - return 0; + return 0; } -int speech_rx_process(void *pcm_buf, int *pcm_len) -{ - // Add your algorithm here - return 0; +int speech_rx_process(void *pcm_buf, int *pcm_len) { + // Add your algorithm here + return 0; } \ No newline at end of file diff --git a/apps/audioplayers/bt_sco_chain_thirdparty_alango.c b/apps/audioplayers/bt_sco_chain_thirdparty_alango.c index 980e58e..ed70f30 100644 --- a/apps/audioplayers/bt_sco_chain_thirdparty_alango.c +++ b/apps/audioplayers/bt_sco_chain_thirdparty_alango.c @@ -1,12 +1,12 @@ +#include "audio_dump.h" #include "bt_sco_chain.h" +#include "hal_trace.h" #include "speech_memory.h" #include "speech_utils.h" -#include "hal_trace.h" -#include "audio_dump.h" -#include "vcp-api.h" #include "spf-postapi.h" +#include "vcp-api.h" -#define ALANGO_TRACE(s, ...) TRACE(1,"%s: " s, __FUNCTION__, ## __VA_ARGS__) +#define ALANGO_TRACE(s, ...) TRACE(1, "%s: " s, __FUNCTION__, ##__VA_ARGS__) short *aec_echo_buf = NULL; @@ -17,7 +17,7 @@ static void *mem; extern void *voicebtpcm_get_ext_buff(int size); -extern char* vcp_errorv(err_t err); +extern char *vcp_errorv(err_t err); extern PROFILE_TYPE(t) alango_profile; @@ -28,121 +28,130 @@ mem_reg_t reg[NUM_MEM_REGIONS]; #if SPEECH_CODEC_CAPTURE_CHANNEL_NUM >= 2 static int16_t *deinterleaved_buf = NULL; -static void deinterleave_audio(int16_t *dst, int16_t *src, uint32_t len, uint32_t ch_num) -{ - uint32_t samples_per_channel = len / ch_num; +static void deinterleave_audio(int16_t *dst, int16_t *src, uint32_t len, + uint32_t ch_num) { + uint32_t samples_per_channel = len / ch_num; - for (uint32_t i = 0; i < samples_per_channel; i++) { - for (uint32_t j = 0; j < ch_num; j++) { - dst[samples_per_channel * j + i] = src[ch_num * i + j]; - } + for (uint32_t i = 0; i < samples_per_channel; i++) { + for (uint32_t j = 0; j < ch_num; j++) { + dst[samples_per_channel * j + i] = src[ch_num * i + j]; } + } } #endif -int speech_init(int tx_sample_rate, int rx_sample_rate, - int tx_frame_ms, int rx_frame_ms, - int sco_frame_ms, - uint8_t *buf, int len) -{ - speech_heap_init(buf, len); +int speech_init(int tx_sample_rate, int rx_sample_rate, int tx_frame_ms, + int rx_frame_ms, int sco_frame_ms, uint8_t *buf, int len) { + speech_heap_init(buf, len); - int frame_len = SPEECH_FRAME_MS_TO_LEN(tx_sample_rate, tx_frame_ms); + int frame_len = SPEECH_FRAME_MS_TO_LEN(tx_sample_rate, tx_frame_ms); - aec_echo_buf = (short *)speech_calloc(frame_len, sizeof(short)); - aec_echo_buf_ptr = aec_echo_buf; + aec_echo_buf = (short *)speech_calloc(frame_len, sizeof(short)); + aec_echo_buf_ptr = aec_echo_buf; - // init alango - // check profile - curr_profile = &alango_profile; - err_t err = vcp_check_profile(curr_profile); - if (err.err) { - if (err.err == ERR_INVALID_CRC) - ALANGO_TRACE(0,"Profile error: Invalid CRC!"); - else - ALANGO_TRACE(1,"Profile error: %d", err.err); - } + // init alango + // check profile + curr_profile = &alango_profile; + err_t err = vcp_check_profile(curr_profile); + if (err.err) { + if (err.err == ERR_INVALID_CRC) + ALANGO_TRACE(0, "Profile error: Invalid CRC!"); + else + ALANGO_TRACE(1, "Profile error: %d", err.err); + } - ASSERT(frame_len % curr_profile->p_gen->frlen == 0, "Profile error: frame_len(%d) should be divided by frlen(%d)", frame_len, curr_profile->p_gen->frlen); + ASSERT(frame_len % curr_profile->p_gen->frlen == 0, + "Profile error: frame_len(%d) should be divided by frlen(%d)", + frame_len, curr_profile->p_gen->frlen); - unsigned int smem = vcp_get_hook_size(); - mem = speech_malloc(smem); + unsigned int smem = vcp_get_hook_size(); + mem = speech_malloc(smem); - vcp_get_mem_size(curr_profile, reg, mem); + vcp_get_mem_size(curr_profile, reg, mem); - ALANGO_TRACE(0,"Hello, I am VCP8!"); + ALANGO_TRACE(0, "Hello, I am VCP8!"); - for (int i = 0; i < NUM_MEM_REGIONS; i++) { - reg[i].mem = (void *)speech_malloc(reg[i].size); - ALANGO_TRACE(2,"I need %d bytes of memory in memory region %d to work.\n", reg[i].size, i + 1); - } + for (int i = 0; i < NUM_MEM_REGIONS; i++) { + reg[i].mem = (void *)speech_malloc(reg[i].size); + ALANGO_TRACE(2, "I need %d bytes of memory in memory region %d to work.\n", + reg[i].size, i + 1); + } - err = vcp_init_debug(curr_profile, reg); - if (err.err == ERR_NOT_ENOUGH_MEMORY) { - ALANGO_TRACE(2,"%d more bytes needed in region %d!\n", -reg[err.pid].size, err.pid); - } else if (err.err == ERR_UNKNOWN) { - ALANGO_TRACE(0,"vcp_init_debug() returns UNKNOWN error\n!"); - } else if (err.err != ERR_NO_ERROR) { - ALANGO_TRACE(2,"vcp_init_debug() returns error %d, pid %d!\n", err.err, err.pid); - } + err = vcp_init_debug(curr_profile, reg); + if (err.err == ERR_NOT_ENOUGH_MEMORY) { + ALANGO_TRACE(2, "%d more bytes needed in region %d!\n", -reg[err.pid].size, + err.pid); + } else if (err.err == ERR_UNKNOWN) { + ALANGO_TRACE(0, "vcp_init_debug() returns UNKNOWN error\n!"); + } else if (err.err != ERR_NO_ERROR) { + ALANGO_TRACE(2, "vcp_init_debug() returns error %d, pid %d!\n", err.err, + err.pid); + } #if SPEECH_CODEC_CAPTURE_CHANNEL_NUM >= 2 - deinterleaved_buf = speech_malloc(curr_profile->p_gen->frlen * SPEECH_CODEC_CAPTURE_CHANNEL_NUM * sizeof(int16_t)); + deinterleaved_buf = + speech_malloc(curr_profile->p_gen->frlen * + SPEECH_CODEC_CAPTURE_CHANNEL_NUM * sizeof(int16_t)); #endif - audio_dump_init(frame_len, sizeof(int16_t), 3); + audio_dump_init(frame_len, sizeof(int16_t), 3); - return 0; + return 0; } -int speech_deinit(void) -{ - speech_free(aec_echo_buf_ptr); - speech_free(mem); +int speech_deinit(void) { + speech_free(aec_echo_buf_ptr); + speech_free(mem); - for (int i = 0; i < NUM_MEM_REGIONS; i++) - speech_free(reg[i].mem); + for (int i = 0; i < NUM_MEM_REGIONS; i++) + speech_free(reg[i].mem); #if SPEECH_CODEC_CAPTURE_CHANNEL_NUM >= 2 - speech_free(deinterleaved_buf); + speech_free(deinterleaved_buf); #endif - size_t total = 0, used = 0, max_used = 0; - speech_memory_info(&total, &used, &max_used); - TRACE(3,"SPEECH MALLOC MEM: total - %d, used - %d, max_used - %d.", total, used, max_used); - ASSERT(used == 0, "[%s] used != 0", __func__); + size_t total = 0, used = 0, max_used = 0; + speech_memory_info(&total, &used, &max_used); + TRACE(3, "SPEECH MALLOC MEM: total - %d, used - %d, max_used - %d.", total, + used, max_used); + ASSERT(used == 0, "[%s] used != 0", __func__); - return 0; + return 0; } #if defined(BONE_SENSOR_TDM) extern void bt_sco_get_tdm_buffer(uint8_t **buf, uint32_t *len); #endif -int speech_tx_process(void *pcm_buf, void *ref_buf, int *pcm_len) -{ - int16_t *pcm16_buf = (int16_t *)pcm_buf; - int16_t *ref16_buf = (int16_t *)ref_buf; - int pcm16_len = *pcm_len; +int speech_tx_process(void *pcm_buf, void *ref_buf, int *pcm_len) { + int16_t *pcm16_buf = (int16_t *)pcm_buf; + int16_t *ref16_buf = (int16_t *)ref_buf; + int pcm16_len = *pcm_len; #if defined(BONE_SENSOR_TDM) - uint8_t *bone_buf = NULL; - uint32_t bone_len = 0; - bt_sco_get_tdm_buffer(&bone_buf, &bone_len); + uint8_t *bone_buf = NULL; + uint32_t bone_len = 0; + bt_sco_get_tdm_buffer(&bone_buf, &bone_len); #endif - audio_dump_clear_up(); - audio_dump_add_channel_data(0, ref_buf, pcm16_len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM); - audio_dump_add_channel_data_from_multi_channels(1, pcm16_buf, pcm16_len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM, SPEECH_CODEC_CAPTURE_CHANNEL_NUM, 0); - audio_dump_add_channel_data_from_multi_channels(2, pcm16_buf, pcm16_len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM, SPEECH_CODEC_CAPTURE_CHANNEL_NUM, 1); + audio_dump_clear_up(); + audio_dump_add_channel_data(0, ref_buf, + pcm16_len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM); + audio_dump_add_channel_data_from_multi_channels( + 1, pcm16_buf, pcm16_len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM, + SPEECH_CODEC_CAPTURE_CHANNEL_NUM, 0); + audio_dump_add_channel_data_from_multi_channels( + 2, pcm16_buf, pcm16_len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM, + SPEECH_CODEC_CAPTURE_CHANNEL_NUM, 1); #if defined(BONE_SENSOR_TDM) - audio_dump_add_channel_data(3, bone_buf, pcm16_len/SPEECH_CODEC_CAPTURE_CHANNEL_NUM); + audio_dump_add_channel_data(3, bone_buf, + pcm16_len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM); #endif - audio_dump_run(); + audio_dump_run(); - // Add your algrithm here and disable #if macro + // Add your algrithm here and disable #if macro #if 0 for (int i = 0, j = 0; i < pcm16_len; i += SPEECH_CODEC_CAPTURE_CHANNEL_NUM, j++) { // choose main microphone data @@ -152,41 +161,48 @@ int speech_tx_process(void *pcm_buf, void *ref_buf, int *pcm_len) } pcm16_len /= SPEECH_CODEC_CAPTURE_CHANNEL_NUM; #else - for (int i = 0, j = 0; i < pcm16_len; i += curr_profile->p_gen->frlen * SPEECH_CODEC_CAPTURE_CHANNEL_NUM, j += curr_profile->p_gen->frlen) { + for (int i = 0, j = 0; i < pcm16_len; + i += curr_profile->p_gen->frlen * SPEECH_CODEC_CAPTURE_CHANNEL_NUM, + j += curr_profile->p_gen->frlen) { #if SPEECH_CODEC_CAPTURE_CHANNEL_NUM >= 2 - deinterleave_audio(deinterleaved_buf, &pcm16_buf[i], curr_profile->p_gen->frlen * SPEECH_CODEC_CAPTURE_CHANNEL_NUM, SPEECH_CODEC_CAPTURE_CHANNEL_NUM); - err_t err = vcp_process_tx(reg, deinterleaved_buf, &ref16_buf[j], &pcm16_buf[j]); - //memcpy(&pcm16_buf[j], deinterleaved_buf, curr_profile->p_gen->frlen * sizeof(int16_t)); + deinterleave_audio(deinterleaved_buf, &pcm16_buf[i], + curr_profile->p_gen->frlen * + SPEECH_CODEC_CAPTURE_CHANNEL_NUM, + SPEECH_CODEC_CAPTURE_CHANNEL_NUM); + err_t err = + vcp_process_tx(reg, deinterleaved_buf, &ref16_buf[j], &pcm16_buf[j]); + // memcpy(&pcm16_buf[j], deinterleaved_buf, curr_profile->p_gen->frlen * + // sizeof(int16_t)); #else - err_t err = vcp_process_tx(reg, &pcm16_buf[i], &ref16_buf[j], &pcm16_buf[j]); + err_t err = + vcp_process_tx(reg, &pcm16_buf[i], &ref16_buf[j], &pcm16_buf[j]); #endif - if (err.err != ERR_NO_ERROR) { - ALANGO_TRACE(1,"vcp_process_tx error: %d", err.err); - } + if (err.err != ERR_NO_ERROR) { + ALANGO_TRACE(1, "vcp_process_tx error: %d", err.err); } - pcm16_len /= SPEECH_CODEC_CAPTURE_CHANNEL_NUM; + } + pcm16_len /= SPEECH_CODEC_CAPTURE_CHANNEL_NUM; #endif #if defined(BONE_SENSOR_TDM) - memcpy(pcm_buf, bone_buf, bone_len); + memcpy(pcm_buf, bone_buf, bone_len); #endif - *pcm_len = pcm16_len; + *pcm_len = pcm16_len; - return 0; + return 0; } -int speech_rx_process(void *pcm_buf, int *pcm_len) -{ - int16_t *pcm16_buf = (int16_t *)pcm_buf; - int pcm16_len = *pcm_len; +int speech_rx_process(void *pcm_buf, int *pcm_len) { + int16_t *pcm16_buf = (int16_t *)pcm_buf; + int pcm16_len = *pcm_len; - for (int i = 0; i < pcm16_len; i += curr_profile->p_gen->frlen) { - err_t err = vcp_process_rx(reg, &pcm16_buf[i], &pcm16_buf[i]); - if (err.err != ERR_NO_ERROR) { - ALANGO_TRACE(1,"vcp_process_tx error: %d", err.err); - } + for (int i = 0; i < pcm16_len; i += curr_profile->p_gen->frlen) { + err_t err = vcp_process_rx(reg, &pcm16_buf[i], &pcm16_buf[i]); + if (err.err != ERR_NO_ERROR) { + ALANGO_TRACE(1, "vcp_process_tx error: %d", err.err); } + } - return 0; + return 0; } \ No newline at end of file diff --git a/apps/audioplayers/bt_sco_chain_tuning.c b/apps/audioplayers/bt_sco_chain_tuning.c index 190ae4d..936aaec 100644 --- a/apps/audioplayers/bt_sco_chain_tuning.c +++ b/apps/audioplayers/bt_sco_chain_tuning.c @@ -13,8 +13,8 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "bt_sco_chain_cfg.h" #include "aud_section.h" +#include "bt_sco_chain_cfg.h" #include "hal_trace.h" static bool speech_tuning_status = false; @@ -23,202 +23,178 @@ extern int speech_store_config(const SpeechConfig *cfg); #ifdef AUDIO_SECTION_ENABLE typedef struct { - uint8_t reserved[AUDIO_SECTION_CFG_RESERVED_LEN]; - SpeechConfig cfg; + uint8_t reserved[AUDIO_SECTION_CFG_RESERVED_LEN]; + SpeechConfig cfg; } AUDIO_SECTION_SPEECH_CFG_T; static AUDIO_SECTION_SPEECH_CFG_T audio_section_speech_cfg; -int store_speech_cfg_into_audio_section(SpeechConfig *cfg) -{ - int res = 0; +int store_speech_cfg_into_audio_section(SpeechConfig *cfg) { + int res = 0; - memcpy(&audio_section_speech_cfg.cfg, cfg, sizeof(SpeechConfig)); + memcpy(&audio_section_speech_cfg.cfg, cfg, sizeof(SpeechConfig)); - res = audio_section_store_cfg(AUDIO_SECTION_DEVICE_SPEECH, + res = audio_section_store_cfg(AUDIO_SECTION_DEVICE_SPEECH, (uint8_t *)&audio_section_speech_cfg, sizeof(AUDIO_SECTION_SPEECH_CFG_T)); + if (res) { + TRACE(2, "[%s] ERROR: res = %d", __func__, res); + } else { + TRACE(1, "[%s] Store speech cfg into audio section!!!", __func__); + } - if(res) - { - TRACE(2,"[%s] ERROR: res = %d", __func__, res); - } - else - { - TRACE(1,"[%s] Store speech cfg into audio section!!!", __func__); - } - - return res; + return res; } -void *load_speech_cfg_from_audio_section(void) -{ - int res = 0; - res = audio_section_load_cfg(AUDIO_SECTION_DEVICE_SPEECH, - (uint8_t *)&audio_section_speech_cfg, - sizeof(AUDIO_SECTION_SPEECH_CFG_T)); +void *load_speech_cfg_from_audio_section(void) { + int res = 0; + res = audio_section_load_cfg(AUDIO_SECTION_DEVICE_SPEECH, + (uint8_t *)&audio_section_speech_cfg, + sizeof(AUDIO_SECTION_SPEECH_CFG_T)); - void *res_ptr = NULL; + void *res_ptr = NULL; - if (res) - { - TRACE(2,"[%s] ERROR: res = %d", __func__, res); - res_ptr = NULL; - } - else - { - TRACE(1,"[%s] Load speech cfg from audio section!!!", __func__); - res_ptr = (void *)&audio_section_speech_cfg.cfg; - } + if (res) { + TRACE(2, "[%s] ERROR: res = %d", __func__, res); + res_ptr = NULL; + } else { + TRACE(1, "[%s] Load speech cfg from audio section!!!", __func__); + res_ptr = (void *)&audio_section_speech_cfg.cfg; + } - return res_ptr; + return res_ptr; } #endif -int speech_tuning_set_status(bool en) -{ - speech_tuning_status = en; +int speech_tuning_set_status(bool en) { + speech_tuning_status = en; - return 0; + return 0; } -bool speech_tuning_get_status(void) -{ - return speech_tuning_status; +bool speech_tuning_get_status(void) { return speech_tuning_status; } + +uint32_t speech_tuning_check(unsigned char *buf, uint32_t len) { + uint32_t res = 0; + + // Check valid + uint32_t config_size = sizeof(SpeechConfig); + + if (config_size != len) { + TRACE(2, "[speech tuning] len(%d) != config_size(%d)", len, config_size); + res = 1; + } else { + TRACE(1, "[speech tuning] len(%d) is OK", len); + // SpeechConfig POSSIBLY_UNUSED *cfg = (SpeechConfig *)buf; + + // Test parameters + //#if defined(SPEECH_TX_2MIC_NS2) + // TRACE(1,"[speech tuning] TX: delay_taps(x100): %d", + // (int)(cfg->tx_2mic_ns2.delay_taps * 100)); + //#endif + //#if defined(SPEECH_TX_NOISE_GATE) + // TRACE(1,"[speech tuning] TX: data_threshold: %d", + // cfg->tx_noise_gate.data_threshold); + //#endif + //#if defined(SPEECH_TX_EQ) + // TRACE(1,"[speech tuning] TX: eq num: %d", cfg->tx_eq.num); + //#endif + //#if defined(SPEECH_RX_EQ) + // TRACE(1,"[speech tuning] RX: eq num: %d", cfg->rx_eq.num); + //#endif + } + + return res; } -uint32_t speech_tuning_check(unsigned char *buf, uint32_t len) -{ - uint32_t res = 0; +uint32_t speech_tuning_rx_callback(unsigned char *buf, uint32_t len) { + uint32_t res = 0; - // Check valid - uint32_t config_size = sizeof(SpeechConfig); + res = speech_tuning_check(buf, len); - if (config_size != len) - { - TRACE(2,"[speech tuning] len(%d) != config_size(%d)", len, config_size); - res = 1; - } - else - { - TRACE(1,"[speech tuning] len(%d) is OK", len); - //SpeechConfig POSSIBLY_UNUSED *cfg = (SpeechConfig *)buf; + if (res) { + TRACE(1, "[speech tuning] ERROR: Send check res = %d", res); + TRACE(0, "[Speech Tuning] res : 1; info : Send len(%d) != config_size(%d);", + len, sizeof(SpeechConfig)); + } else { + // Save cfg + speech_store_config((SpeechConfig *)buf); - // Test parameters -//#if defined(SPEECH_TX_2MIC_NS2) -// TRACE(1,"[speech tuning] TX: delay_taps(x100): %d", (int)(cfg->tx_2mic_ns2.delay_taps * 100)); -//#endif -//#if defined(SPEECH_TX_NOISE_GATE) -// TRACE(1,"[speech tuning] TX: data_threshold: %d", cfg->tx_noise_gate.data_threshold); -//#endif -//#if defined(SPEECH_TX_EQ) -// TRACE(1,"[speech tuning] TX: eq num: %d", cfg->tx_eq.num); -//#endif -//#if defined(SPEECH_RX_EQ) -// TRACE(1,"[speech tuning] RX: eq num: %d", cfg->rx_eq.num); -//#endif - } + // Set status + speech_tuning_set_status(true); - return res; -} + TRACE(0, "[speech tuning] OK: Send cfg"); + TRACE(0, "[Speech Tuning] res : 0;"); + } -uint32_t speech_tuning_rx_callback(unsigned char *buf, uint32_t len) -{ - uint32_t res = 0; - - res = speech_tuning_check(buf, len); - - if (res) - { - TRACE(1,"[speech tuning] ERROR: Send check res = %d", res); - TRACE(0,"[Speech Tuning] res : 1; info : Send len(%d) != config_size(%d);", len, sizeof(SpeechConfig)); - } - else - { - // Save cfg - speech_store_config((SpeechConfig *)buf); - - // Set status - speech_tuning_set_status(true); - - TRACE(0,"[speech tuning] OK: Send cfg"); - TRACE(0,"[Speech Tuning] res : 0;"); - } - - return res; + return res; } #ifdef AUDIO_SECTION_ENABLE -uint32_t speech_tuning_burn_rx_callback(unsigned char *buf, uint32_t len) -{ - uint32_t res = 0; +uint32_t speech_tuning_burn_rx_callback(unsigned char *buf, uint32_t len) { + uint32_t res = 0; - res = speech_tuning_check(buf, len); + res = speech_tuning_check(buf, len); - if (res) - { - TRACE(1,"[speech tuning] ERROR: Burn check res = %d", res); - TRACE(0,"[Speech Tuning] res : 1; info : Burn len(%d) != config_size(%d);", len, sizeof(SpeechConfig)); + if (res) { + TRACE(1, "[speech tuning] ERROR: Burn check res = %d", res); + TRACE(0, "[Speech Tuning] res : 1; info : Burn len(%d) != config_size(%d);", + len, sizeof(SpeechConfig)); + } else { + res = store_speech_cfg_into_audio_section((SpeechConfig *)buf); + + if (res) { + TRACE(1, "[speech tuning] ERROR: Store res = %d", res); + res += 100; + TRACE(0, "[Speech Tuning] res : 2; info : Do not enable " + "AUDIO_SECTION_ENABLE;"); + } else { + TRACE(0, "[speech tuning] OK: Store cfg"); + TRACE(0, "[Speech Tuning] res : 0;"); } - else - { - res = store_speech_cfg_into_audio_section((SpeechConfig *)buf); + } - if(res) - { - TRACE(1,"[speech tuning] ERROR: Store res = %d", res); - res += 100; - TRACE(0,"[Speech Tuning] res : 2; info : Do not enable AUDIO_SECTION_ENABLE;"); - } - else - { - TRACE(0,"[speech tuning] OK: Store cfg"); - TRACE(0,"[Speech Tuning] res : 0;"); - } - } - - return res; + return res; } #endif -int speech_tuning_init(void) -{ +int speech_tuning_init(void) { #if defined(HAL_TRACE_RX_ENABLE) && !defined(SPEECH_TX_THIRDPARTY) - hal_trace_rx_register("Speech Tuning", (HAL_TRACE_RX_CALLBACK_T)speech_tuning_rx_callback); + hal_trace_rx_register("Speech Tuning", + (HAL_TRACE_RX_CALLBACK_T)speech_tuning_rx_callback); #ifdef AUDIO_SECTION_ENABLE - hal_trace_rx_register("Speech Tuning Burn", (HAL_TRACE_RX_CALLBACK_T)speech_tuning_burn_rx_callback); + hal_trace_rx_register( + "Speech Tuning Burn", + (HAL_TRACE_RX_CALLBACK_T)speech_tuning_burn_rx_callback); #endif #endif - speech_tuning_set_status(false); + speech_tuning_set_status(false); - return 0; + return 0; } -int speech_tuning_open(void) -{ +int speech_tuning_open(void) { #ifdef AUDIO_SECTION_ENABLE - SpeechConfig *speech_cfg_load = NULL; + SpeechConfig *speech_cfg_load = NULL; - speech_cfg_load = (SpeechConfig *)load_speech_cfg_from_audio_section(); + speech_cfg_load = (SpeechConfig *)load_speech_cfg_from_audio_section(); - if (speech_cfg_load) - { - speech_store_config(speech_cfg_load); - } + if (speech_cfg_load) { + speech_store_config(speech_cfg_load); + } #endif - speech_tuning_set_status(false); + speech_tuning_set_status(false); - return 0; + return 0; } -int speech_tuning_close(void) -{ - speech_tuning_set_status(false); +int speech_tuning_close(void) { + speech_tuning_set_status(false); - return 0; + return 0; } diff --git a/apps/audioplayers/cvsdplay.cpp b/apps/audioplayers/cvsdplay.cpp index d3c8127..d610093 100644 --- a/apps/audioplayers/cvsdplay.cpp +++ b/apps/audioplayers/cvsdplay.cpp @@ -17,23 +17,22 @@ #include "mbed.h" #endif // Standard C Included Files -#include #include #include -#include #include +#include +#include #ifdef MBED //#include "rtos.h" #endif #ifdef MBED #include "SDFileSystem.h" #endif +#include "app_audio.h" #include "cqueue.h" -#include "hal_uart.h" #include "hal_timer.h" #include "hal_trace.h" -#include "app_audio.h" - +#include "hal_uart.h" // BT @@ -44,16 +43,15 @@ osMutexDef(g_voicecvsd_queue_mutex); /* cvsd queue */ #define VOICECVSD_TEMP_BUFFER_SIZE 128 -#define VOICECVSD_QUEUE_SIZE (VOICECVSD_TEMP_BUFFER_SIZE*20) +#define VOICECVSD_QUEUE_SIZE (VOICECVSD_TEMP_BUFFER_SIZE * 20) CQueue voicecvsd_queue; static enum APP_AUDIO_CACHE_T voicecvsd_cache_status = APP_AUDIO_CACHE_QTY; -#define LOCK_VOICECVSD_QUEUE() \ - osMutexWait(g_voicecvsd_queue_mutex_id, osWaitForever) +#define LOCK_VOICECVSD_QUEUE() \ + osMutexWait(g_voicecvsd_queue_mutex_id, osWaitForever) -#define UNLOCK_VOICECVSD_QUEUE() \ - osMutexRelease(g_voicecvsd_queue_mutex_id) +#define UNLOCK_VOICECVSD_QUEUE() osMutexRelease(g_voicecvsd_queue_mutex_id) void xLOCK_VOICECVSD_QUEUE(void) { diff --git a/apps/audioplayers/digmici2splay.cpp b/apps/audioplayers/digmici2splay.cpp index b332b93..307e282 100644 --- a/apps/audioplayers/digmici2splay.cpp +++ b/apps/audioplayers/digmici2splay.cpp @@ -14,34 +14,32 @@ * ****************************************************************************/ // Standard C Included Files -#include -#include -#include -#include -#include #include "cqueue.h" -#include "hal_uart.h" #include "hal_timer.h" #include "hal_trace.h" +#include "hal_uart.h" +#include +#include +#include +#include +#include -uint8_t digmic_buf[100*1024]; +uint8_t digmic_buf[100 * 1024]; uint32_t digmic_buf_len = 0; -uint32_t dig_mic_audio_more_data(uint8_t *buf, uint32_t len) -{ - TRACE(2,"%s:%d\n", __func__, __LINE__); - memcpy(buf, digmic_buf, len); +uint32_t dig_mic_audio_more_data(uint8_t *buf, uint32_t len) { + TRACE(2, "%s:%d\n", __func__, __LINE__); + memcpy(buf, digmic_buf, len); - return len; + return len; } -uint32_t dig_mic_audio_data_come(uint8_t *buf, uint32_t len) -{ - TRACE(2,"%s:%d\n", __func__, __LINE__); +uint32_t dig_mic_audio_data_come(uint8_t *buf, uint32_t len) { + TRACE(2, "%s:%d\n", __func__, __LINE__); - memcpy(digmic_buf + digmic_buf_len, buf, len); + memcpy(digmic_buf + digmic_buf_len, buf, len); #if 1 - digmic_buf_len = (digmic_buf_len + len)%(100*1024); + digmic_buf_len = (digmic_buf_len + len) % (100 * 1024); #endif - return len; + return len; } diff --git a/apps/audioplayers/flacplay.cpp b/apps/audioplayers/flacplay.cpp index f3d1c6a..cb3cd93 100644 --- a/apps/audioplayers/flacplay.cpp +++ b/apps/audioplayers/flacplay.cpp @@ -14,15 +14,15 @@ * ****************************************************************************/ // Standard C Included Files -#include -#include -#include -#include -#include #include "cqueue.h" -#include "hal_uart.h" #include "hal_timer.h" #include "hal_trace.h" +#include "hal_uart.h" +#include +#include +#include +#include +#include #ifdef RTOS #include "cmsis_os.h" #endif @@ -33,106 +33,102 @@ osMutexDef(g_flac_queue_mutex); /* flac queue */ #define FLAC_TEMP_BUFFER_SIZE 2048 -#define FLAC_QUEUE_SIZE (FLAC_TEMP_BUFFER_SIZE*4) +#define FLAC_QUEUE_SIZE (FLAC_TEMP_BUFFER_SIZE * 4) unsigned char flac_queue_buf[FLAC_QUEUE_SIZE]; CQueue flac_queue; static uint32_t ok_to_decode = 0; -#define LOCK_FLAC_QUEUE() \ - osMutexWait(g_flac_queue_mutex_id, osWaitForever) +#define LOCK_FLAC_QUEUE() osMutexWait(g_flac_queue_mutex_id, osWaitForever) -#define UNLOCK_FLAC_QUEUE() \ - osMutexRelease(g_flac_queue_mutex_id) +#define UNLOCK_FLAC_QUEUE() osMutexRelease(g_flac_queue_mutex_id) -static void copy_one_trace_to_two_track_16bits(uint16_t *src_buf, uint16_t *dst_buf, uint32_t src_len) -{ - uint32_t i = 0; - for (i = 0; i < src_len; ++i) { - dst_buf[i*2 + 0] = dst_buf[i*2 + 1] = src_buf[i]; - } +static void copy_one_trace_to_two_track_16bits(uint16_t *src_buf, + uint16_t *dst_buf, + uint32_t src_len) { + uint32_t i = 0; + for (i = 0; i < src_len; ++i) { + dst_buf[i * 2 + 0] = dst_buf[i * 2 + 1] = src_buf[i]; + } } -int store_flac_buffer(unsigned char *buf, unsigned int len) -{ - LOCK_FLAC_QUEUE(); - EnCQueue(&flac_queue, buf, len); - if (LengthOfCQueue(&flac_queue) > FLAC_TEMP_BUFFER_SIZE*2) { - ok_to_decode = 1; - } - UNLOCK_FLAC_QUEUE(); +int store_flac_buffer(unsigned char *buf, unsigned int len) { + LOCK_FLAC_QUEUE(); + EnCQueue(&flac_queue, buf, len); + if (LengthOfCQueue(&flac_queue) > FLAC_TEMP_BUFFER_SIZE * 2) { + ok_to_decode = 1; + } + UNLOCK_FLAC_QUEUE(); - return 0; + return 0; } -int decode_flac_frame(unsigned char *pcm_buffer, unsigned int pcm_len) -{ - uint32_t r = 0, got_len = 0; - unsigned char *e1 = NULL, *e2 = NULL; - unsigned int len1 = 0, len2 = 0; +int decode_flac_frame(unsigned char *pcm_buffer, unsigned int pcm_len) { + uint32_t r = 0, got_len = 0; + unsigned char *e1 = NULL, *e2 = NULL; + unsigned int len1 = 0, len2 = 0; get_again: - LOCK_FLAC_QUEUE(); - r = PeekCQueue(&flac_queue, (pcm_len - got_len)/2, &e1, &len1, &e2, &len2); - UNLOCK_FLAC_QUEUE(); + LOCK_FLAC_QUEUE(); + r = PeekCQueue(&flac_queue, (pcm_len - got_len) / 2, &e1, &len1, &e2, &len2); + UNLOCK_FLAC_QUEUE(); - if(r == CQ_ERR || len1 == 0) { - osDelay(2); - goto get_again; - } + if (r == CQ_ERR || len1 == 0) { + osDelay(2); + goto get_again; + } - //memcpy(pcm_buffer + got_len, e1, len1); - copy_one_trace_to_two_track_16bits((uint16_t *)e1, (uint16_t *)(pcm_buffer + got_len), len1/2); + // memcpy(pcm_buffer + got_len, e1, len1); + copy_one_trace_to_two_track_16bits( + (uint16_t *)e1, (uint16_t *)(pcm_buffer + got_len), len1 / 2); + + LOCK_FLAC_QUEUE(); + DeCQueue(&flac_queue, 0, len1); + UNLOCK_FLAC_QUEUE(); + + got_len += len1 * 2; + + if (len2 != 0) { + // memcpy(pcm_buffer + got_len, e2, len2); + copy_one_trace_to_two_track_16bits( + (uint16_t *)e2, (uint16_t *)(pcm_buffer + got_len), len2 / 2); LOCK_FLAC_QUEUE(); - DeCQueue(&flac_queue, 0, len1); + DeCQueue(&flac_queue, 0, len2); UNLOCK_FLAC_QUEUE(); + } - got_len += len1*2; + got_len += len2 * 2; - if (len2 != 0) { - //memcpy(pcm_buffer + got_len, e2, len2); - copy_one_trace_to_two_track_16bits((uint16_t *)e2, (uint16_t *)(pcm_buffer + got_len), len2/2); + if (got_len < pcm_len) + goto get_again; - LOCK_FLAC_QUEUE(); - DeCQueue(&flac_queue, 0, len2); - UNLOCK_FLAC_QUEUE(); - } - - got_len += len2*2; - - if (got_len < pcm_len) - goto get_again; - - return pcm_len; + return pcm_len; } -uint32_t flac_audio_data_come(uint8_t *buf, uint32_t len) -{ - TRACE(1,"data come %d\n", len); +uint32_t flac_audio_data_come(uint8_t *buf, uint32_t len) { + TRACE(1, "data come %d\n", len); + return 0; +} + +uint32_t flac_audio_more_data(uint8_t *buf, uint32_t len) { + uint32_t l = 0; + // uint32_t cur_ticks = 0, ticks = 0; + + if (ok_to_decode == 0) return 0; + + // ticks = hal_sys_timer_get(); + l = decode_flac_frame(buf, len); + // cur_ticks = hal_sys_timer_get(); + // TRACE(1,"flac %d t\n", (cur_ticks-ticks)); + + return l; } -uint32_t flac_audio_more_data(uint8_t *buf, uint32_t len) -{ - uint32_t l = 0; - //uint32_t cur_ticks = 0, ticks = 0; +int flac_audio_init(void) { + g_flac_queue_mutex_id = osMutexCreate((osMutex(g_flac_queue_mutex))); + /* flac queue*/ + InitCQueue(&flac_queue, FLAC_QUEUE_SIZE, (unsigned char *)&flac_queue_buf); - if (ok_to_decode == 0) - return 0; - - //ticks = hal_sys_timer_get(); - l = decode_flac_frame(buf, len); - //cur_ticks = hal_sys_timer_get(); -// TRACE(1,"flac %d t\n", (cur_ticks-ticks)); - - return l; -} - -int flac_audio_init(void) -{ - g_flac_queue_mutex_id = osMutexCreate((osMutex(g_flac_queue_mutex))); - /* flac queue*/ - InitCQueue(&flac_queue, FLAC_QUEUE_SIZE, (unsigned char *)&flac_queue_buf); - - return 0; + return 0; } diff --git a/apps/audioplayers/fmradio.cpp b/apps/audioplayers/fmradio.cpp index 82b6a4a..44211d2 100644 --- a/apps/audioplayers/fmradio.cpp +++ b/apps/audioplayers/fmradio.cpp @@ -15,154 +15,151 @@ ****************************************************************************/ #ifdef CHIP_BEST1000 +#include "app_audio.h" +#include "app_overlay.h" +#include "app_utils.h" +#include "audiobuffer.h" +#include "audioflinger.h" #include "cmsis.h" #include "cmsis_os.h" -#include "hal_trace.h" +#include "cqueue.h" #include "fmdec.h" -#include "hal_dma.h" -#include "hal_timer.h" -#include "hal_cmu.h" #include "hal_analogif.h" #include "hal_chipid.h" -#include "audioflinger.h" -#include "audiobuffer.h" -#include "cqueue.h" -#include "app_audio.h" -#include "app_utils.h" -#include "app_overlay.h" -#include "string.h" +#include "hal_cmu.h" +#include "hal_dma.h" +#include "hal_timer.h" +#include "hal_trace.h" #include "pmu.h" +#include "string.h" //#define FM_DEBUG 1 #define FM_DIGITAL_REG(a) *(volatile uint32_t *)(a) -#define fm_read_rf_reg(reg,val) hal_analogif_reg_read(reg,val) -#define fm_write_rf_reg(reg,val) hal_analogif_reg_write(reg,val) +#define fm_read_rf_reg(reg, val) hal_analogif_reg_read(reg, val) +#define fm_write_rf_reg(reg, val) hal_analogif_reg_write(reg, val) #define FM_FRAME_NUM 4 #define FM_SAMPLE_NUM NUMOFSAMPLE #ifdef ATAN2_HARDWARE #ifdef FM_NEWMODE -#define FM_SAMPLE_BUFFER_SIZE (FM_FRAME_NUM*FM_SAMPLE_NUM*4) +#define FM_SAMPLE_BUFFER_SIZE (FM_FRAME_NUM * FM_SAMPLE_NUM * 4) #else -#define FM_SAMPLE_BUFFER_SIZE (FM_FRAME_NUM*FM_SAMPLE_NUM/2*4) +#define FM_SAMPLE_BUFFER_SIZE (FM_FRAME_NUM * FM_SAMPLE_NUM / 2 * 4) #endif #else -#define FM_SAMPLE_BUFFER_SIZE (FM_FRAME_NUM*FM_SAMPLE_NUM*4) +#define FM_SAMPLE_BUFFER_SIZE (FM_FRAME_NUM * FM_SAMPLE_NUM * 4) #endif #define FM_AUDIO_BUFFER_SIZE (4096) extern int app_bt_stream_local_volume_get(void); static int32_t *fm_sample_buffer_p; -static void fm_handler(uint8_t chan, uint32_t remains, uint32_t error, struct HAL_DMA_DESC_T *lli) -{ - static int cnt = 0; - int16_t fm_decbuf[(FM_SAMPLE_NUM/9)]; - FmDemodulate((int16_t *)(fm_sample_buffer_p +((cnt%FM_FRAME_NUM)*FM_SAMPLE_NUM)), fm_decbuf,FM_SAMPLE_NUM); - cnt++; - app_audio_pcmbuff_put((uint8_t *)fm_decbuf, (FM_SAMPLE_NUM/9)<<1); - FmDemodulate((int16_t *)(fm_sample_buffer_p +((cnt%FM_FRAME_NUM)*FM_SAMPLE_NUM)), fm_decbuf,FM_SAMPLE_NUM); - cnt++; - app_audio_pcmbuff_put((uint8_t *)fm_decbuf, (FM_SAMPLE_NUM/9)<<1); +static void fm_handler(uint8_t chan, uint32_t remains, uint32_t error, + struct HAL_DMA_DESC_T *lli) { + static int cnt = 0; + int16_t fm_decbuf[(FM_SAMPLE_NUM / 9)]; + FmDemodulate( + (int16_t *)(fm_sample_buffer_p + ((cnt % FM_FRAME_NUM) * FM_SAMPLE_NUM)), + fm_decbuf, FM_SAMPLE_NUM); + cnt++; + app_audio_pcmbuff_put((uint8_t *)fm_decbuf, (FM_SAMPLE_NUM / 9) << 1); + FmDemodulate( + (int16_t *)(fm_sample_buffer_p + ((cnt % FM_FRAME_NUM) * FM_SAMPLE_NUM)), + fm_decbuf, FM_SAMPLE_NUM); + cnt++; + app_audio_pcmbuff_put((uint8_t *)fm_decbuf, (FM_SAMPLE_NUM / 9) << 1); #ifdef FM_DEBUG - { - static uint32_t preTicks; - uint32_t diff_ticks = 0; - uint32_t cur_ticks; + { + static uint32_t preTicks; + uint32_t diff_ticks = 0; + uint32_t cur_ticks; - cur_ticks = hal_sys_timer_get(); - if (!preTicks){ - preTicks = cur_ticks; - }else{ - diff_ticks = TICKS_TO_MS(cur_ticks - preTicks); - preTicks = cur_ticks; - } - TRACE(3,"[fm_handler] diff=%d add:%d remain:%d input", diff_ticks, (FM_SAMPLE_NUM/9)<<1, app_audio_pcmbuff_length()); + cur_ticks = hal_sys_timer_get(); + if (!preTicks) { + preTicks = cur_ticks; + } else { + diff_ticks = TICKS_TO_MS(cur_ticks - preTicks); + preTicks = cur_ticks; } + TRACE(3, "[fm_handler] diff=%d add:%d remain:%d input", diff_ticks, + (FM_SAMPLE_NUM / 9) << 1, app_audio_pcmbuff_length()); + } #endif } -uint32_t fm_pcm_more_data(uint8_t *buf, uint32_t len) -{ - app_audio_pcmbuff_get(buf, len); +uint32_t fm_pcm_more_data(uint8_t *buf, uint32_t len) { + app_audio_pcmbuff_get(buf, len); #ifdef FM_DEBUG - { - static uint32_t preTicks; - uint32_t diff_ticks = 0; - uint32_t cur_ticks= hal_sys_timer_get(); - if (!preTicks){ - preTicks = cur_ticks; - }else{ - diff_ticks = TICKS_TO_MS(cur_ticks - preTicks); - preTicks = cur_ticks; - } - - TRACE(5,"[fm_pcm_more_data] diff=%d get:%d remain:%d output isr:0x%08x cnt:%d", diff_ticks, len/2, app_audio_pcmbuff_length(), FM_DIGITAL_REG(0x40160020), FM_DIGITAL_REG(0x40160028)); + { + static uint32_t preTicks; + uint32_t diff_ticks = 0; + uint32_t cur_ticks = hal_sys_timer_get(); + if (!preTicks) { + preTicks = cur_ticks; + } else { + diff_ticks = TICKS_TO_MS(cur_ticks - preTicks); + preTicks = cur_ticks; } + + TRACE( + 5, + "[fm_pcm_more_data] diff=%d get:%d remain:%d output isr:0x%08x cnt:%d", + diff_ticks, len / 2, app_audio_pcmbuff_length(), + FM_DIGITAL_REG(0x40160020), FM_DIGITAL_REG(0x40160028)); + } #endif - return 0; + return 0; } -uint32_t fm_capture_more_data(uint8_t *buf, uint32_t len) -{ - fm_handler(0,0,0,NULL); - return len; +uint32_t fm_capture_more_data(uint8_t *buf, uint32_t len) { + fm_handler(0, 0, 0, NULL); + return len; } -void fm_radio_digit_init(void) -{ - FM_DIGITAL_REG(0xd0350244) = (FM_DIGITAL_REG(0xd0350244) & ~0x01fff) | 0x20f; //-890k -> 0 if_shift, for 110.5292m adc - -// FM_DIGITAL_REG(0x40180e0c) = 0x34; - //FM_DIGITAL_REG(0x4000a050) = (FM_DIGITAL_REG(0x4000a050) & ~0x18000) | 0x18000; - - +void fm_radio_digit_init(void) { + FM_DIGITAL_REG(0xd0350244) = (FM_DIGITAL_REG(0xd0350244) & ~0x01fff) | + 0x20f; //-890k -> 0 if_shift, for 110.5292m adc + // FM_DIGITAL_REG(0x40180e0c) = 0x34; + // FM_DIGITAL_REG(0x4000a050) = (FM_DIGITAL_REG(0x4000a050) & ~0x18000) | + // 0x18000; #ifdef ATAN2_HARDWARE - - FM_DIGITAL_REG(0xd0330038) |= (1 << 11); - FM_DIGITAL_REG(0xd0330038) |= (1 << 17); - FM_DIGITAL_REG(0xd0350248) = 0x80c00000; -// FM_DIGITAL_REG(0x40160030) = 1; - // FM_DIGITAL_REG(0x40160000) = 0x21; - + FM_DIGITAL_REG(0xd0330038) |= (1 << 11); + FM_DIGITAL_REG(0xd0330038) |= (1 << 17); + FM_DIGITAL_REG(0xd0350248) = 0x80c00000; + // FM_DIGITAL_REG(0x40160030) = 1; + // FM_DIGITAL_REG(0x40160000) = 0x21; #else - - - FM_DIGITAL_REG(0xd0330038) |= (1 << 11); - FM_DIGITAL_REG(0xd0350248) = 0x80c00000; -// FM_DIGITAL_REG(0x40160030) = 1; -// FM_DIGITAL_REG(0x40160000) = 1; + FM_DIGITAL_REG(0xd0330038) |= (1 << 11); + FM_DIGITAL_REG(0xd0350248) = 0x80c00000; + // FM_DIGITAL_REG(0x40160030) = 1; + // FM_DIGITAL_REG(0x40160000) = 1; #endif - - #ifdef SINGLECHANLE - //0x4000a010 bit2 д0 µ¥channel dac - FM_DIGITAL_REG(0x4000a010) = (1 << 5) |(1<<4); + // 0x4000a010 bit2 д0 µ¥channel dac + FM_DIGITAL_REG(0x4000a010) = (1 << 5) | (1 << 4); #else - FM_DIGITAL_REG(0x4000a010) = (1 << 5) | (1 << 2)|(1<<4); + FM_DIGITAL_REG(0x4000a010) = (1 << 5) | (1 << 2) | (1 << 4); #endif + FM_DIGITAL_REG(0x4000a020) = ~0UL; + FM_DIGITAL_REG(0x4000a02c) = 4; + FM_DIGITAL_REG(0x4000a030) = 4; + FM_DIGITAL_REG(0x4000a034) = (1 << 2) | (1 << 1) | (1 << 0); - FM_DIGITAL_REG(0x4000a020) = ~0UL; - FM_DIGITAL_REG(0x4000a02c) = 4; - FM_DIGITAL_REG(0x4000a030) = 4; - - FM_DIGITAL_REG(0x4000a034) = (1 << 2) | (1 << 1) | (1 << 0); - - // Start DAC - // FM_DIGITAL_REG(0x4000a010) |= (1 << 1); + // Start DAC + // FM_DIGITAL_REG(0x4000a010) |= (1 << 1); #if 0 //52M @@ -185,345 +182,324 @@ void fm_radio_digit_init(void) FM_DIGITAL_REG(0x40000064) = (FM_DIGITAL_REG(0x40000064) & ~0xFF) | 0x7A | (1 << 10) | (1<<30); #endif - FM_DIGITAL_REG(0x4000a040) = 0xc0810000; - FM_DIGITAL_REG(0x4000a044) = 0x08040c04; - FM_DIGITAL_REG(0x4000a048) = 0x0e01f268; - FM_DIGITAL_REG(0x4000a04c) = 0x00005100; - // FM_DIGITAL_REG(0x40010010) = 0; - // FM_DIGITAL_REG(0x40010014) = 0x03a80005; - //FM_DIGITAL_REG(0x40010018) = 0x00200019; - FM_DIGITAL_REG(0x4000a050) = 0x24200000; //for adc_div_3_6 bypass - FM_DIGITAL_REG(0x4000a050) = (FM_DIGITAL_REG(0x4000a050) & ~0x780) | 0x380; // for channel 1 adc volume, bit10~7 - FM_DIGITAL_REG(0x4000a050) = (FM_DIGITAL_REG(0x4000a050) & ~0x18000) | 0x18000; // for dual channel adc/dac + FM_DIGITAL_REG(0x4000a040) = 0xc0810000; + FM_DIGITAL_REG(0x4000a044) = 0x08040c04; + FM_DIGITAL_REG(0x4000a048) = 0x0e01f268; + FM_DIGITAL_REG(0x4000a04c) = 0x00005100; + // FM_DIGITAL_REG(0x40010010) = 0; + // FM_DIGITAL_REG(0x40010014) = 0x03a80005; + // FM_DIGITAL_REG(0x40010018) = 0x00200019; + FM_DIGITAL_REG(0x4000a050) = 0x24200000; // for adc_div_3_6 bypass + FM_DIGITAL_REG(0x4000a050) = (FM_DIGITAL_REG(0x4000a050) & ~0x780) | + 0x380; // for channel 1 adc volume, bit10~7 + FM_DIGITAL_REG(0x4000a050) = (FM_DIGITAL_REG(0x4000a050) & ~0x18000) | + 0x18000; // for dual channel adc/dac #ifdef SINGLECHANLE - //0x4000a050 bit16 д0 µ¥channel dac for codec - FM_DIGITAL_REG(0x4000a050) =(FM_DIGITAL_REG(0x4000a050) & ~ (1 << 16)); + // 0x4000a050 bit16 д0 µ¥channel dac for codec + FM_DIGITAL_REG(0x4000a050) = (FM_DIGITAL_REG(0x4000a050) & ~(1 << 16)); #endif + FM_DIGITAL_REG(0x4000a048) = (FM_DIGITAL_REG(0x4000a048) & ~0x00000f00) | + 0x40000900; // set for sdm gain + FM_DIGITAL_REG(0x4000a044) = (FM_DIGITAL_REG(0x4000a044) & ~0x60000000) | + 0x60000000; // for adc en, and dac en - FM_DIGITAL_REG(0x4000a048) = (FM_DIGITAL_REG(0x4000a048) & ~0x00000f00) | 0x40000900; //set for sdm gain - FM_DIGITAL_REG(0x4000a044) = (FM_DIGITAL_REG(0x4000a044) & ~0x60000000) | 0x60000000; //for adc en, and dac en + // Start DAC + FM_DIGITAL_REG(0x4000a010) |= (1 << 1); - // Start DAC - FM_DIGITAL_REG(0x4000a010) |= (1 << 1); - - - -// Delay 2 ms -// for (volatile int kk = 0; kk < 1000/64; kk++); - osDelay(2); - - //hal_sys_timer_delay(MS_TO_TICKS(2)); - // Start ADC - // FM_DIGITAL_REG(0x4000a010) |= (1 << 0); + // Delay 2 ms + // for (volatile int kk = 0; kk < 1000/64; kk++); + osDelay(2); + // hal_sys_timer_delay(MS_TO_TICKS(2)); + // Start ADC + // FM_DIGITAL_REG(0x4000a010) |= (1 << 0); #ifdef ATAN2_HARDWARE - #ifdef FM_NEWMODE - FM_DIGITAL_REG(0x40160030) = 1; - FM_DIGITAL_REG(0x40160000) = 0x1; + FM_DIGITAL_REG(0x40160030) = 1; + FM_DIGITAL_REG(0x40160000) = 0x1; #else - FM_DIGITAL_REG(0x40160030) = 1; - FM_DIGITAL_REG(0x40160000) = 0x21; + FM_DIGITAL_REG(0x40160030) = 1; + FM_DIGITAL_REG(0x40160000) = 0x21; #endif #else - //start FM - FM_DIGITAL_REG(0x40160030) = 1; - FM_DIGITAL_REG(0x40160000) =1; + // start FM + FM_DIGITAL_REG(0x40160030) = 1; + FM_DIGITAL_REG(0x40160000) = 1; #endif } -int fm_radio_analog_init(void) +int fm_radio_analog_init(void) { + int ret; + + /* + + // fm initial + rfspi_wvalue( 8'h2c , 16'b0111_0000_0101_1100 ) ; // dig_vtoi_en + rfspi_wvalue( 8'h01 , 16'b1010_1101_1111_1111 ) ; // power on fm lna + rfspi_wvalue( 8'h02 , 16'b1000_0000_1001_0100 ) ; // reg_fm_lna_pu_mixersw + + rfspi_wvalue( 8'h1a , 16'b0101_0000_1011_0000 ) ; // + reg_bt_vco_fm_buff_vctrl_dr=1 + + rfspi_wvalue( 8'h18 , 16'b0000_0110_1000_0000 ) ; // power on vco + + rfspi_wvalue( 8'h19 , 16'b0110_0100_0100_0000 ) ; // reg_bt_vco_fm_buff_vctrl + rfspi_wvalue( 8'h1d , 16'b0111_1000_1010_0100 ) ; // reg_bt_rfpll_pu_dr + rfspi_wvalue( 8'h1c , 16'b0000_0000_1100_1000 ) ; // reg_bt_vco_fm_lo_en + reg_bt_vco_fm_div_ctrl=8 + + rfspi_wvalue( 8'h0a , 16'b0001_0010_0010_1111 ) ; // reg_btfm_flt_fm_en + + rfspi_wvalue( 8'h2d , 16'b0000_0111_1000_0010 ) ; // bb ldo on + reg_bb_ldo_pu_vddr15a_dr rfspi_wvalue( 8'h07 , 16'b0000_0010_1011_1001 ) ; // + reg_btfm_flt_pu_dr + + rfspi_wvalue( 8'h2a , 16'b0001_0110_1100_0000 ) ; // reg_bt_rfpll_sdm_freq_dr + rfspi_wvalue( 8'h26 , 16'b0000_0000_0000_0000 ) ; // vco freq[31:16] ( 2400 + + x )*2^25/26MHZ*N (2400+x= frf) rfspi_wvalue( 8'h25 , 16'b0000_0000_0000_0000 ) + ; // vco freq[15:00] fm_freq = frf/(4*reg_bt_vco_fm_div_ctrl) rfspi_wvalue( + 8'h17 , 16'b1000_0000_0000_0000 ) ; // reg_bt_vco_calen + + */ + + fm_write_rf_reg(0x2c, 0b0111000001011100); // dig_vtoi_en + fm_write_rf_reg(0x01, 0b1010110111111111); // power on fm lna + fm_write_rf_reg(0x02, 0b1000000010010100); // reg_fm_lna_pu_mixersw + + fm_write_rf_reg(0x1a, 0b0101000010110000); // reg_bt_vco_fm_buff_vctrl_dr=1 + + fm_write_rf_reg(0x18, 0b0000011010000000); // power on vco + + fm_write_rf_reg(0x19, 0b0110010001000000); // reg_bt_vco_fm_buff_vctrl + fm_write_rf_reg(0x1d, 0b0111100010100100); // reg_bt_rfpll_pu_dr + fm_write_rf_reg( + 0x1c, 0b0000000011001000); // reg_bt_vco_fm_lo_en reg_bt_vco_fm_div_ctrl=8 + + fm_write_rf_reg(0x0a, 0b0001001000101111); // reg_btfm_flt_fm_en + + fm_write_rf_reg(0x2d, + 0b0000011110000010); // bb ldo on reg_bb_ldo_pu_vddr15a_dr + fm_write_rf_reg(0x07, 0b0000001010111001); // reg_btfm_flt_pu_dr + + fm_write_rf_reg(0x2a, 0b0001011011000000); // reg_bt_rfpll_sdm_freq_dr + fm_write_rf_reg(0x26, 0b0000000000000000); // vco freq[31:16] ( 2400 + x + // )*2^25/26MHZ*N (2400+x= frf) + fm_write_rf_reg(0x25, 0b0000000000000000); // vco freq[15:00] fm_freq = + // frf/(4*reg_bt_vco_fm_div_ctrl) + fm_write_rf_reg(0x17, 0b1000000000000000); // reg_bt_vco_calen + + // adcÒ²Òª¿ªµÄ»°£¬ÐèÒªÅä cmu + // 0x40000060[29] = 1 ×îºÃÏȶÁÔÙд£¬·ñÔò°Ñ±ðµÄbit³åµôÁË¡£ + + //ÐèÒªÅäÖõÄspi¼Ä´æÆ÷£ºana interface: + + // 0x05 = 0xFCB1 // Audio Pll + // 0x06 = 0x881C + // 0x31 = 0x0100 // audio_freq_en + // 0x37 = 0x1000 // codec_bbpll1_fm_adc_clk_en + // 0x31 = 0x0130 // codec_tx_en_ldac codec_tx_en_rdac + + ret = fm_write_rf_reg(0x05, 0xfcb1); + if (ret) { + return ret; + } + ret = fm_write_rf_reg(0x06, 0x881c); + if (ret) { + return ret; + } + + ret = fm_write_rf_reg(0x3a, 0xe644); + if (ret) { + return ret; + } + ret = fm_write_rf_reg(0x31, 0x0100); + if (ret) { + return ret; + } + ret = fm_write_rf_reg(0x37, 0x1000); + if (ret) { + return ret; + } + ret = fm_write_rf_reg(0x31, 0x01f0); + if (ret) { + return ret; + } + + // delay 32ms + osDelay(32); + + ret = fm_write_rf_reg(0x31, 0x0130); + if (ret) { + return ret; + } + + //[FM_RX] + fm_write_rf_reg(0x01, 0x91ff); // pu fm + fm_write_rf_reg(0x2d, 0x07fa); // ldo on + fm_write_rf_reg(0x2e, 0x6aaa); // tune fm filter IF + fm_write_rf_reg(0x02, 0xe694); + fm_write_rf_reg(0x03, 0xfe3a); + fm_write_rf_reg(0x04, 0x52a8); + fm_write_rf_reg(0x07, 0x02b9); + fm_write_rf_reg(0x0a, 0x1a2c); + fm_write_rf_reg(0x0b, 0x402b); + fm_write_rf_reg(0x0c, 0x7584); + fm_write_rf_reg(0x0e, 0x0000); + fm_write_rf_reg(0x0f, 0x2e18); + fm_write_rf_reg(0x10, 0x02b4); + fm_write_rf_reg(0x13, 0x0a48); + + //[vco init] + fm_write_rf_reg(0x18, 0x077f); + fm_write_rf_reg(0x19, 0x3ff8); + fm_write_rf_reg(0x1a, 0xc090); + fm_write_rf_reg(0x1b, 0x0f88); + fm_write_rf_reg(0x1c, 0x04c6); //[3:0] 5,6,7,8 --> vco/2 + + return 0; +} + +void fm_radio_poweron(void) + { - int ret; + hal_cmu_reset_clear(HAL_CMU_MOD_BTCPU); + osDelay(2000); + { + // wakp interface + unsigned short read_val; - /* + fm_read_rf_reg(0x50, &read_val); + } - // fm initial - rfspi_wvalue( 8'h2c , 16'b0111_0000_0101_1100 ) ; // dig_vtoi_en - rfspi_wvalue( 8'h01 , 16'b1010_1101_1111_1111 ) ; // power on fm lna - rfspi_wvalue( 8'h02 , 16'b1000_0000_1001_0100 ) ; // reg_fm_lna_pu_mixersw + pmu_fm_config(1); - rfspi_wvalue( 8'h1a , 16'b0101_0000_1011_0000 ) ; // reg_bt_vco_fm_buff_vctrl_dr=1 + fm_write_rf_reg(0x0c, 0x3584); + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2 || + hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_3) //// + { + FM_DIGITAL_REG(0xc00003b4) = 0x00060020; // turn off bt sleep + } else if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_4) { + FM_DIGITAL_REG(0xc00003b0) = 0x00060020; // turn off bt sleep + } else { + FM_DIGITAL_REG(0xc00003ac) = 0x00060020; // turn off bt sleep + } + FM_DIGITAL_REG(0xd0330038) = 0x00008D0D; + FM_DIGITAL_REG(0xd0340020) = 0x010E01C0; // open ana rxon for open adc clk + // fm_write_rf_reg(0x02, 0xe694); +} - rfspi_wvalue( 8'h18 , 16'b0000_0110_1000_0000 ) ; // power on vco +void *fm_radio_get_ext_buff(int size) { + uint8_t *pBuff = NULL; + size = size + size % 4; + app_audio_mempool_get_buff(&pBuff, size); + return (void *)pBuff; +} - rfspi_wvalue( 8'h19 , 16'b0110_0100_0100_0000 ) ; // reg_bt_vco_fm_buff_vctrl - rfspi_wvalue( 8'h1d , 16'b0111_1000_1010_0100 ) ; // reg_bt_rfpll_pu_dr - rfspi_wvalue( 8'h1c , 16'b0000_0000_1100_1000 ) ; // reg_bt_vco_fm_lo_en reg_bt_vco_fm_div_ctrl=8 - - rfspi_wvalue( 8'h0a , 16'b0001_0010_0010_1111 ) ; // reg_btfm_flt_fm_en - - rfspi_wvalue( 8'h2d , 16'b0000_0111_1000_0010 ) ; // bb ldo on reg_bb_ldo_pu_vddr15a_dr - rfspi_wvalue( 8'h07 , 16'b0000_0010_1011_1001 ) ; // reg_btfm_flt_pu_dr - - rfspi_wvalue( 8'h2a , 16'b0001_0110_1100_0000 ) ; // reg_bt_rfpll_sdm_freq_dr - rfspi_wvalue( 8'h26 , 16'b0000_0000_0000_0000 ) ; // vco freq[31:16] ( 2400 + x )*2^25/26MHZ*N (2400+x= frf) - rfspi_wvalue( 8'h25 , 16'b0000_0000_0000_0000 ) ; // vco freq[15:00] fm_freq = frf/(4*reg_bt_vco_fm_div_ctrl) - rfspi_wvalue( 8'h17 , 16'b1000_0000_0000_0000 ) ; // reg_bt_vco_calen - - */ - - - - - - - fm_write_rf_reg( 0x2c , 0b0111000001011100 ) ; // dig_vtoi_en - fm_write_rf_reg( 0x01 , 0b1010110111111111 ) ; // power on fm lna - fm_write_rf_reg( 0x02 , 0b1000000010010100 ) ; // reg_fm_lna_pu_mixersw - - fm_write_rf_reg( 0x1a , 0b0101000010110000 ) ; // reg_bt_vco_fm_buff_vctrl_dr=1 - - fm_write_rf_reg( 0x18 , 0b0000011010000000 ) ; // power on vco - - fm_write_rf_reg( 0x19 , 0b0110010001000000 ) ; // reg_bt_vco_fm_buff_vctrl - fm_write_rf_reg( 0x1d , 0b0111100010100100 ) ; // reg_bt_rfpll_pu_dr - fm_write_rf_reg( 0x1c , 0b0000000011001000 ) ; // reg_bt_vco_fm_lo_en reg_bt_vco_fm_div_ctrl=8 - - fm_write_rf_reg( 0x0a , 0b0001001000101111 ) ; // reg_btfm_flt_fm_en - - fm_write_rf_reg( 0x2d , 0b0000011110000010 ) ; // bb ldo on reg_bb_ldo_pu_vddr15a_dr - fm_write_rf_reg( 0x07 , 0b0000001010111001 ) ; // reg_btfm_flt_pu_dr - - fm_write_rf_reg( 0x2a , 0b0001011011000000 ) ; // reg_bt_rfpll_sdm_freq_dr - fm_write_rf_reg( 0x26 , 0b0000000000000000 ) ; // vco freq[31:16] ( 2400 + x )*2^25/26MHZ*N (2400+x= frf) - fm_write_rf_reg( 0x25 , 0b0000000000000000 ) ; // vco freq[15:00] fm_freq = frf/(4*reg_bt_vco_fm_div_ctrl) - fm_write_rf_reg( 0x17 , 0b1000000000000000 ) ; // reg_bt_vco_calen - - - - - - - - //adcÒ²Òª¿ªµÄ»°£¬ÐèÒªÅä cmu - //0x40000060[29] = 1 ×îºÃÏȶÁÔÙд£¬·ñÔò°Ñ±ðµÄbit³åµôÁË¡£ - - - - - //ÐèÒªÅäÖõÄspi¼Ä´æÆ÷£ºana interface: - - //0x05 = 0xFCB1 // Audio Pll - //0x06 = 0x881C - //0x31 = 0x0100 // audio_freq_en - //0x37 = 0x1000 // codec_bbpll1_fm_adc_clk_en - //0x31 = 0x0130 // codec_tx_en_ldac codec_tx_en_rdac - - - ret = fm_write_rf_reg(0x05 , 0xfcb1); - if (ret) { - return ret; - } - ret = fm_write_rf_reg(0x06 , 0x881c); - if (ret) { - return ret; - } - - ret = fm_write_rf_reg(0x3a , 0xe644); - if (ret) { - return ret; - } - ret = fm_write_rf_reg(0x31 , 0x0100); - if (ret) { - return ret; - } - ret = fm_write_rf_reg(0x37 , 0x1000); - if (ret) { - return ret; - } - ret = fm_write_rf_reg(0x31 , 0x01f0); - if (ret) { - return ret; - } - - - //delay 32ms - osDelay(32); - - - ret = fm_write_rf_reg(0x31 , 0x0130); - if (ret) { - return ret; - } - - //[FM_RX] - fm_write_rf_reg(0x01,0x91ff); //pu fm - fm_write_rf_reg(0x2d,0x07fa); //ldo on - fm_write_rf_reg(0x2e,0x6aaa); //tune fm filter IF - fm_write_rf_reg(0x02,0xe694); - fm_write_rf_reg(0x03,0xfe3a); - fm_write_rf_reg(0x04,0x52a8); - fm_write_rf_reg(0x07,0x02b9); - fm_write_rf_reg(0x0a,0x1a2c); - fm_write_rf_reg(0x0b,0x402b); - fm_write_rf_reg(0x0c,0x7584); - fm_write_rf_reg(0x0e,0x0000); - fm_write_rf_reg(0x0f,0x2e18); - fm_write_rf_reg(0x10,0x02b4); - fm_write_rf_reg(0x13,0x0a48); - - //[vco init] - fm_write_rf_reg(0x18,0x077f); - fm_write_rf_reg(0x19,0x3ff8); - fm_write_rf_reg(0x1a,0xc090); - fm_write_rf_reg(0x1b,0x0f88); - fm_write_rf_reg(0x1c,0x04c6); //[3:0] 5,6,7,8 --> vco/2 +int fm_radio_player(bool on) { + static struct AF_STREAM_CONFIG_T stream_cfg; + static bool isRun = false; + uint8_t *buff = NULL; + TRACE(2, "fm_radio_player work:%d op:%d", isRun, on); + if (isRun == on) return 0; -} -void fm_radio_poweron(void) - -{ - hal_cmu_reset_clear(HAL_CMU_MOD_BTCPU); - osDelay(2000); - - { - //wakp interface - unsigned short read_val; - - fm_read_rf_reg(0x50, &read_val); - } - - pmu_fm_config(1); - - fm_write_rf_reg(0x0c, 0x3584); - if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2 || hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_3) //// - { - FM_DIGITAL_REG(0xc00003b4)=0x00060020;//turn off bt sleep - } - else if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_4) - { - FM_DIGITAL_REG(0xc00003b0)=0x00060020;//turn off bt sleep - } - else - { - FM_DIGITAL_REG(0xc00003ac)=0x00060020;//turn off bt sleep - } - FM_DIGITAL_REG(0xd0330038) = 0x00008D0D; - FM_DIGITAL_REG(0xd0340020)=0x010E01C0;// open ana rxon for open adc clk - //fm_write_rf_reg(0x02, 0xe694); -} - -void* fm_radio_get_ext_buff(int size) -{ - uint8_t *pBuff = NULL; - size = size+size%4; - app_audio_mempool_get_buff(&pBuff, size); - return (void*)pBuff; -} - -int fm_radio_player(bool on) -{ - static struct AF_STREAM_CONFIG_T stream_cfg; - static bool isRun = false; - uint8_t *buff = NULL; - - TRACE(2,"fm_radio_player work:%d op:%d", isRun, on); - if (isRun==on) - return 0; - - if (on){ - app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_52M); - app_audio_mempool_init(); - fm_radio_poweron(); - fm_radio_analog_init(); - fm_radio_digit_init(); - osDelay(200); - buff = (uint8_t *)fm_radio_get_ext_buff(FM_AUDIO_BUFFER_SIZE*2); - app_audio_pcmbuff_init(buff, FM_AUDIO_BUFFER_SIZE*2); - fm_sample_buffer_p = (int32_t *)fm_radio_get_ext_buff(FM_SAMPLE_BUFFER_SIZE); -#if FPGA==0 - app_overlay_select(APP_OVERLAY_FM); + if (on) { + app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_52M); + app_audio_mempool_init(); + fm_radio_poweron(); + fm_radio_analog_init(); + fm_radio_digit_init(); + osDelay(200); + buff = (uint8_t *)fm_radio_get_ext_buff(FM_AUDIO_BUFFER_SIZE * 2); + app_audio_pcmbuff_init(buff, FM_AUDIO_BUFFER_SIZE * 2); + fm_sample_buffer_p = + (int32_t *)fm_radio_get_ext_buff(FM_SAMPLE_BUFFER_SIZE); +#if FPGA == 0 + app_overlay_select(APP_OVERLAY_FM); #endif - memset(&stream_cfg, 0, sizeof(stream_cfg)); - stream_cfg.vol = app_bt_stream_local_volume_get(); - stream_cfg.handler = fm_capture_more_data; - stream_cfg.data_ptr = (uint8_t *)fm_sample_buffer_p; - stream_cfg.data_size = FM_SAMPLE_BUFFER_SIZE; - stream_cfg.device = AUD_STREAM_USE_DPD_RX; - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + memset(&stream_cfg, 0, sizeof(stream_cfg)); + stream_cfg.vol = app_bt_stream_local_volume_get(); + stream_cfg.handler = fm_capture_more_data; + stream_cfg.data_ptr = (uint8_t *)fm_sample_buffer_p; + stream_cfg.data_size = FM_SAMPLE_BUFFER_SIZE; + stream_cfg.device = AUD_STREAM_USE_DPD_RX; + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - memset(&stream_cfg, 0, sizeof(stream_cfg)); - buff = (uint8_t *)fm_radio_get_ext_buff(FM_AUDIO_BUFFER_SIZE); - stream_cfg.bits = AUD_BITS_16; - stream_cfg.channel_num = AUD_CHANNEL_NUM_1; - stream_cfg.sample_rate = AUD_SAMPRATE_48000; -#if FPGA==0 - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; + memset(&stream_cfg, 0, sizeof(stream_cfg)); + buff = (uint8_t *)fm_radio_get_ext_buff(FM_AUDIO_BUFFER_SIZE); + stream_cfg.bits = AUD_BITS_16; + stream_cfg.channel_num = AUD_CHANNEL_NUM_1; + stream_cfg.sample_rate = AUD_SAMPRATE_48000; +#if FPGA == 0 + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; #else - stream_cfg.device = AUD_STREAM_USE_EXT_CODEC; + stream_cfg.device = AUD_STREAM_USE_EXT_CODEC; #endif - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; - stream_cfg.vol = app_bt_stream_local_volume_get(); - stream_cfg.handler = fm_pcm_more_data; - stream_cfg.data_ptr = buff; - stream_cfg.data_size = FM_AUDIO_BUFFER_SIZE; - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; + stream_cfg.vol = app_bt_stream_local_volume_get(); + stream_cfg.handler = fm_pcm_more_data; + stream_cfg.data_ptr = buff; + stream_cfg.data_size = FM_AUDIO_BUFFER_SIZE; + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - }else{ - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_32K); - } + } else { + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_32K); + } - isRun=on; - return 0; + isRun = on; + return 0; } -int fm_tune(uint32_t freqkhz) -{ - uint32_t reg; - unsigned long long tmp = 0; +int fm_tune(uint32_t freqkhz) { + uint32_t reg; + unsigned long long tmp = 0; + //[rfpll_cal] + fm_write_rf_reg(0x21, 0x3979); // ref sel 52MHz + fm_write_rf_reg(0x22, 0x7A22); // doubler setting + fm_write_rf_reg(0x23, 0x0380); + fm_write_rf_reg(0x2b, 0x32a0); // sdm + fm_write_rf_reg(0x2a, 0x12d1); // cal ini - //[rfpll_cal] - fm_write_rf_reg(0x21,0x3979); // ref sel 52MHz - fm_write_rf_reg(0x22,0x7A22); // doubler setting - fm_write_rf_reg(0x23,0x0380); - fm_write_rf_reg(0x2b,0x32a0); // sdm - fm_write_rf_reg(0x2a,0x12d1); // cal ini + //(freq(Mhz)-0.89(Mhz))*(2^28)*3/26 + tmp = freqkhz; + reg = (((tmp - 890)) << 27) * 3 / 13 / 1000; - //(freq(Mhz)-0.89(Mhz))*(2^28)*3/26 - tmp = freqkhz; - reg =(((tmp-890))<<27)*3/13/1000; + fm_write_rf_reg(0x25, (reg & 0xffff0000) >> 16); + fm_write_rf_reg(0x26, reg & 0x0000ffff); - fm_write_rf_reg(0x25, (reg&0xffff0000)>>16); - fm_write_rf_reg(0x26, reg&0x0000ffff); + fm_write_rf_reg(0x1d, 0x58e4); // pll_cal_en + fm_write_rf_reg(0xf7, 0x5597); // rst and enable pll_cal clk + fm_write_rf_reg(0xf7, 0x55d7); // rst and enable pll_cal clk + fm_write_rf_reg(0x1d, 0x7ae4); // pll cal start + fm_write_rf_reg(0xff, 0x0000); // wait 100us - fm_write_rf_reg(0x1d,0x58e4); // pll_cal_en - fm_write_rf_reg(0xf7,0x5597); // rst and enable pll_cal clk - fm_write_rf_reg(0xf7,0x55d7); // rst and enable pll_cal clk - fm_write_rf_reg(0x1d,0x7ae4); // pll cal start - fm_write_rf_reg(0xff,0x0000); // wait 100us + osDelay(20); - osDelay(20); + fm_write_rf_reg(0x1d, 0x7ac4); // close pll loop - - fm_write_rf_reg(0x1d,0x7ac4); // close pll loop - - return 0; + return 0; } -void fm_test_main(void) -{ - fm_radio_player(true); - osDelay(20); - fm_tune(90500); +void fm_test_main(void) { + fm_radio_player(true); + osDelay(20); + fm_tune(90500); } #endif - diff --git a/apps/audioplayers/msbcplay.cpp b/apps/audioplayers/msbcplay.cpp index 13cd2cc..174ab1a 100644 --- a/apps/audioplayers/msbcplay.cpp +++ b/apps/audioplayers/msbcplay.cpp @@ -14,20 +14,19 @@ * ****************************************************************************/ // Standard C Included Files -#include -#include -#include -#include -#include #include "cmsis_os.h" #include "cqueue.h" -#include "hal_uart.h" #include "hal_timer.h" #include "hal_trace.h" +#include "hal_uart.h" +#include +#include +#include +#include +#include // BT - #if 0 /* mutex */ osMutexId g_voicemsbc_queue_mutex_id; @@ -35,16 +34,15 @@ osMutexDef(g_voicemsbc_queue_mutex); /* msbc queue */ #define VOICEMSBC_TEMP_BUFFER_SIZE 128 -#define VOICEMSBC_QUEUE_SIZE (VOICEMSBC_TEMP_BUFFER_SIZE*100) +#define VOICEMSBC_QUEUE_SIZE (VOICEMSBC_TEMP_BUFFER_SIZE * 100) unsigned char voicemsbc_queue_buf[VOICEMSBC_QUEUE_SIZE]; CQueue voicemsbc_queue; static uint32_t ok_to_decode = 0; -#define LOCK_VOICEMSBC_QUEUE() \ - osMutexWait(g_voicemsbc_queue_mutex_id, osWaitForever) +#define LOCK_VOICEMSBC_QUEUE() \ + osMutexWait(g_voicemsbc_queue_mutex_id, osWaitForever) -#define UNLOCK_VOICEMSBC_QUEUE() \ - osMutexRelease(g_voicemsbc_queue_mutex_id) +#define UNLOCK_VOICEMSBC_QUEUE() osMutexRelease(g_voicemsbc_queue_mutex_id) static void dump_buffer_to_psram(char *buf, unsigned int len) { diff --git a/apps/audioplayers/plc_utils.c b/apps/audioplayers/plc_utils.c index a475edd..a6f5c29 100644 --- a/apps/audioplayers/plc_utils.c +++ b/apps/audioplayers/plc_utils.c @@ -1,9 +1,10 @@ -#include -#include #include "plc_utils.h" #include "hal_trace.h" +#include +#include -#if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) +#if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) || \ + defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) #define MSBC_MUTE_PATTERN (0x55) #else #define MSBC_MUTE_PATTERN (0x00) @@ -19,9 +20,8 @@ //#define ENABLE_PAD_CHECK /* - * if msbc frame is filled by 10+ samples in the trail, crc maybe not detect this - * satuation. - * Do not check this by default + * if msbc frame is filled by 10+ samples in the trail, crc maybe not detect + * this satuation. Do not check this by default */ //#define ENABLE_TRAILING_ZERO_CHECK @@ -58,271 +58,256 @@ static const uint8_t sbc_crc_tbl[256] = { 0x10, 0x0D, 0x2A, 0x37, 0x64, 0x79, 0x5E, 0x43, 0xB2, 0xAF, 0x88, 0x95, 0xC6, 0xDB, 0xFC, 0xE1, 0x5A, 0x47, 0x60, 0x7D, 0x2E, 0x33, 0x14, 0x09, 0x7F, 0x62, 0x45, 0x58, 0x0B, 0x16, 0x31, 0x2C, 0x97, 0x8A, 0xAD, 0xB0, - 0xE3, 0xFE, 0xD9, 0xC4 -}; + 0xE3, 0xFE, 0xD9, 0xC4}; #endif -static int sco_parse_synchronization_header(uint8_t *buf, uint8_t *sn) -{ - uint8_t sn1, sn2; +static int sco_parse_synchronization_header(uint8_t *buf, uint8_t *sn) { + uint8_t sn1, sn2; #ifdef ENABLE_CRC_CHECK - uint8_t fcs = 0x0F; - uint8_t crc = 0; - uint8_t i, sb, bit, shift; - uint8_t ind = 6, bitOffset = 24; + uint8_t fcs = 0x0F; + uint8_t crc = 0; + uint8_t i, sb, bit, shift; + uint8_t ind = 6, bitOffset = 24; #endif - *sn = 0xff; + *sn = 0xff; #if defined(MSBC_SYNC_HACKER) - if (((buf[0] != 0x01) && (buf[0] != 0x00)) || - ((buf[1] & 0x0f) != 0x08) || - (buf[2] != 0xad)) { - return -1; - } + if (((buf[0] != 0x01) && (buf[0] != 0x00)) || ((buf[1] & 0x0f) != 0x08) || + (buf[2] != 0xad)) { + return -1; + } #else - if ((buf[0] != 0x01) || - ((buf[1] & 0x0f) != 0x08) || - (buf[2] != 0xad)) { - return -1; - } + if ((buf[0] != 0x01) || ((buf[1] & 0x0f) != 0x08) || (buf[2] != 0xad)) { + return -1; + } #endif - sn1 = (buf[1] & 0x30) >> 4; - sn2 = (buf[1] & 0xc0) >> 6; - if ((sn1 != 0) && (sn1 != 0x3)) { - return -2; - } - if ((sn2 != 0) && (sn2 != 0x3)) { - return -3; - } + sn1 = (buf[1] & 0x30) >> 4; + sn2 = (buf[1] & 0xc0) >> 6; + if ((sn1 != 0) && (sn1 != 0x3)) { + return -2; + } + if ((sn2 != 0) && (sn2 != 0x3)) { + return -3; + } #ifdef ENABLE_CRC_CHECK - fcs = sbc_crc_tbl[fcs ^ buf[3]]; - if (buf[3] != 0x00) - return -4; - fcs = sbc_crc_tbl[fcs ^ buf[4]]; - if (buf[4] != 0x00) - return -4; - crc = buf[5]; - for (sb = 0; sb < 8; sb++) { - if (bitOffset % 8) { - /* Sum the whole byte */ - fcs = sbc_crc_tbl[fcs ^ buf[ind]]; - ind = ind + 1; - } - else { - if (sb == 7) { - /* Sum the next 4 bits */ + fcs = sbc_crc_tbl[fcs ^ buf[3]]; + if (buf[3] != 0x00) + return -4; + fcs = sbc_crc_tbl[fcs ^ buf[4]]; + if (buf[4] != 0x00) + return -4; + crc = buf[5]; + for (sb = 0; sb < 8; sb++) { + if (bitOffset % 8) { + /* Sum the whole byte */ + fcs = sbc_crc_tbl[fcs ^ buf[ind]]; + ind = ind + 1; + } else { + if (sb == 7) { + /* Sum the next 4 bits */ - /* Just sum the most significant 4 bits */ - shift = 7; - for (i = 0; i < 4; i++) { - bit = (uint8_t)((0x01 & (buf[ind] >> shift--)) ^ (fcs >> 7)); - if (bit) { - fcs = (uint8_t)(((fcs << 1) | bit) ^ 0x1C); - } - else { - fcs = (uint8_t)((fcs << 1)); - } - } - } + /* Just sum the most significant 4 bits */ + shift = 7; + for (i = 0; i < 4; i++) { + bit = (uint8_t)((0x01 & (buf[ind] >> shift--)) ^ (fcs >> 7)); + if (bit) { + fcs = (uint8_t)(((fcs << 1) | bit) ^ 0x1C); + } else { + fcs = (uint8_t)((fcs << 1)); + } } - - bitOffset += 4; + } } - //TRACE(2,"msbc crc:%d fcs:%d", crc,fcs); - if (crc != fcs) - return -4; + + bitOffset += 4; + } + // TRACE(2,"msbc crc:%d fcs:%d", crc,fcs); + if (crc != fcs) + return -4; #endif - *sn = (sn1 & 0x01) | (sn2 & 0x02); + *sn = (sn1 & 0x01) | (sn2 & 0x02); #ifdef ENABLE_PAD_CHECK - // when pad error detected, we should return sn - if (buf[MSBC_PKTSIZE - 1] != 0x0) { - return -5; - } + // when pad error detected, we should return sn + if (buf[MSBC_PKTSIZE - 1] != 0x0) { + return -5; + } #endif - return 0; + return 0; } #ifdef ENABLE_BLE_CONFLICT_CHECK -static bool memcmp_U8(uint8_t *x, uint8_t *y, uint16_t size) -{ - for (int i = 0; i < size; i++) { - if (x[i] != y[i]) - return true; - } +static bool memcmp_U8(uint8_t *x, uint8_t *y, uint16_t size) { + for (int i = 0; i < size; i++) { + if (x[i] != y[i]) + return true; + } - return false; + return false; } -// when signal is mute, msbc data remains the same except seq num. We should check history flag, -// otherwise a single conflict may be detected twice -static bool update_ble_sco_conflict(PacketLossState* st, uint8_t *last_pkt, uint8_t *pkt) -{ - // do not check padding byte as it maybe useless when msbc_offset is 1 - bool ret = (st->prev_ble_sco_conflict_flag[1] == false && memcmp_U8(last_pkt, pkt, MSBC_PKTSIZE - 1) == false); +// when signal is mute, msbc data remains the same except seq num. We should +// check history flag, otherwise a single conflict may be detected twice +static bool update_ble_sco_conflict(PacketLossState *st, uint8_t *last_pkt, + uint8_t *pkt) { + // do not check padding byte as it maybe useless when msbc_offset is 1 + bool ret = (st->prev_ble_sco_conflict_flag[1] == false && + memcmp_U8(last_pkt, pkt, MSBC_PKTSIZE - 1) == false); - memcpy(&last_pkt[0], &last_pkt[MSBC_PKTSIZE], MSBC_PKTSIZE); - memcpy(&last_pkt[MSBC_PKTSIZE], pkt, MSBC_PKTSIZE); + memcpy(&last_pkt[0], &last_pkt[MSBC_PKTSIZE], MSBC_PKTSIZE); + memcpy(&last_pkt[MSBC_PKTSIZE], pkt, MSBC_PKTSIZE); - return ret; + return ret; } -static bool check_ble_sco_conflict(PacketLossState* st, bool ret) -{ - st->prev_ble_sco_conflict_flag[1] = st->prev_ble_sco_conflict_flag[0]; - st->prev_ble_sco_conflict_flag[0] = ret; +static bool check_ble_sco_conflict(PacketLossState *st, bool ret) { + st->prev_ble_sco_conflict_flag[1] = st->prev_ble_sco_conflict_flag[0]; + st->prev_ble_sco_conflict_flag[0] = ret; - return ret; + return ret; } #endif -static bool msbc_check_controller_mute_pattern(uint8_t *pkt, uint8_t pattern) -{ - // do not check padding byte as it maybe useless when msbc_offset is 1 - for (int i = 0; i < MSBC_PKTSIZE - 1; i++) - if (pkt[i] != pattern) - return false; +static bool msbc_check_controller_mute_pattern(uint8_t *pkt, uint8_t pattern) { + // do not check padding byte as it maybe useless when msbc_offset is 1 + for (int i = 0; i < MSBC_PKTSIZE - 1; i++) + if (pkt[i] != pattern) + return false; - return true; + return true; } #ifdef ENABLE_TRAILING_ZERO_CHECK -static int msbc_check_pkt_trailing_zeros(uint8_t *pkt) -{ - int idx = MSBC_PKTSIZE; +static int msbc_check_pkt_trailing_zeros(uint8_t *pkt) { + int idx = MSBC_PKTSIZE; - for (int i = MSBC_PKTSIZE - 1; i >= 0; i--) { - if (pkt[i] != 0) { - idx = i; - break; - } + for (int i = MSBC_PKTSIZE - 1; i >= 0; i--) { + if (pkt[i] != 0) { + idx = i; + break; } + } - return (MSBC_PKTSIZE - 1 - idx); + return (MSBC_PKTSIZE - 1 - idx); } #endif -static uint8_t get_next_sequence_num(uint8_t seq_num) -{ - return (seq_num + 1 == 4) ? 0 : (seq_num + 1); +static uint8_t get_next_sequence_num(uint8_t seq_num) { + return (seq_num + 1 == 4) ? 0 : (seq_num + 1); } -void packet_loss_detection_init(PacketLossState *st) -{ +void packet_loss_detection_init(PacketLossState *st) { + st->last_seq_num = 0xff; + + memset(st->last_pkt, 0, sizeof(st->last_pkt)); + memset(st->prev_ble_sco_conflict_flag, 0, + sizeof(st->prev_ble_sco_conflict_flag)); + memset(st->hist, 0, sizeof(st->hist)); +} + +plc_type_t packet_loss_detection_process(PacketLossState *st, + uint8_t *sbc_buf) { + plc_type_t plc_type = PLC_TYPE_PASS; + +#ifdef ENABLE_BLE_CONFLICT_CHECK + bool ble_sco_conflict = update_ble_sco_conflict(st, st->last_pkt, sbc_buf); +#endif + + uint8_t seq_num; + if (msbc_check_controller_mute_pattern(sbc_buf, MSBC_MUTE_PATTERN) == true) { + plc_type = PLC_TYPE_CONTROLLER_MUTE; st->last_seq_num = 0xff; - - memset(st->last_pkt, 0, sizeof(st->last_pkt)); - memset(st->prev_ble_sco_conflict_flag, 0, sizeof(st->prev_ble_sco_conflict_flag)); - memset(st->hist, 0, sizeof(st->hist)); -} - -plc_type_t packet_loss_detection_process(PacketLossState *st, uint8_t *sbc_buf) -{ - plc_type_t plc_type = PLC_TYPE_PASS; - + } #ifdef ENABLE_BLE_CONFLICT_CHECK - bool ble_sco_conflict = update_ble_sco_conflict(st, st->last_pkt, sbc_buf); + else if (check_ble_sco_conflict(st, ble_sco_conflict) == true) { + plc_type = PLC_TYPE_BLE_CONFLICT; + st->last_seq_num = 0xff; + } #endif - - uint8_t seq_num; - if (msbc_check_controller_mute_pattern(sbc_buf, MSBC_MUTE_PATTERN) == true) { - plc_type = PLC_TYPE_CONTROLLER_MUTE; - st->last_seq_num = 0xff; + else { + int err = sco_parse_synchronization_header(sbc_buf, &seq_num); + if (err < 0 && err >= -3) { + plc_type = PLC_TYPE_HEADER_ERROR; + st->last_seq_num = 0xff; } -#ifdef ENABLE_BLE_CONFLICT_CHECK - else if (check_ble_sco_conflict(st, ble_sco_conflict) == true) { - plc_type = PLC_TYPE_BLE_CONFLICT; - st->last_seq_num = 0xff; +#ifdef ENABLE_CRC_CHECK + else if (err == -4) { + plc_type = PLC_TYPE_CRC_ERROR; + st->last_seq_num = 0xff; + } +#endif +#ifdef ENABLE_PAD_CHECK + else if (err == -5) { + plc_type = PLC_TYPE_PAD_ERROR; + st->last_seq_num = seq_num; + } +#endif +#ifdef ENABLE_TRAILING_ZERO_CHECK + else if (msbc_check_pkt_trailing_zeros(sbc_buf) > 10) { + plc_type = PLC_TYPE_DATA_MISSING; + st->last_seq_num = 0xff; } #endif else { - int err = sco_parse_synchronization_header(sbc_buf, &seq_num); - if (err < 0 && err >= -3) { - plc_type = PLC_TYPE_HEADER_ERROR; - st->last_seq_num = 0xff; - } -#ifdef ENABLE_CRC_CHECK - else if (err == -4) { - plc_type = PLC_TYPE_CRC_ERROR; - st->last_seq_num = 0xff; - } -#endif -#ifdef ENABLE_PAD_CHECK - else if (err == -5) { - plc_type = PLC_TYPE_PAD_ERROR; - st->last_seq_num = seq_num; - } -#endif -#ifdef ENABLE_TRAILING_ZERO_CHECK - else if (msbc_check_pkt_trailing_zeros(sbc_buf) > 10) { - plc_type = PLC_TYPE_DATA_MISSING; - st->last_seq_num = 0xff; - } -#endif - else { #ifdef ENABLE_SEQ_CHECK - if (st->last_seq_num == 0xff) { - if (seq_num == 0xff) { - plc_type = PLC_TYPE_SEQUENCE_DISCONTINUE; - } - else { - plc_type = PLC_TYPE_PASS; - } - st->last_seq_num = seq_num; - } - else { - if (seq_num == 0xff) { - st->last_seq_num = 0xff; - plc_type = PLC_TYPE_SEQUENCE_DISCONTINUE; - } - else if (seq_num == get_next_sequence_num(st->last_seq_num)) { - st->last_seq_num = seq_num; - plc_type = PLC_TYPE_PASS; - } - else { - st->last_seq_num = 0xff; - plc_type = PLC_TYPE_SEQUENCE_DISCONTINUE; - } - } -#else - plc_type = PLC_TYPE_PASS; -#endif + if (st->last_seq_num == 0xff) { + if (seq_num == 0xff) { + plc_type = PLC_TYPE_SEQUENCE_DISCONTINUE; + } else { + plc_type = PLC_TYPE_PASS; } + st->last_seq_num = seq_num; + } else { + if (seq_num == 0xff) { + st->last_seq_num = 0xff; + plc_type = PLC_TYPE_SEQUENCE_DISCONTINUE; + } else if (seq_num == get_next_sequence_num(st->last_seq_num)) { + st->last_seq_num = seq_num; + plc_type = PLC_TYPE_PASS; + } else { + st->last_seq_num = 0xff; + plc_type = PLC_TYPE_SEQUENCE_DISCONTINUE; + } + } +#else + plc_type = PLC_TYPE_PASS; +#endif } + } - packet_loss_detection_update_histogram(st, plc_type); + packet_loss_detection_update_histogram(st, plc_type); - return plc_type; + return plc_type; } -void packet_loss_detection_update_histogram(PacketLossState *st, plc_type_t plc_type) -{ - if (plc_type < 0 || plc_type >= PLC_TYPE_NUM) { - TRACE(2,"[%s] plc type %d is invalid", __FUNCTION__, plc_type); - return; - } +void packet_loss_detection_update_histogram(PacketLossState *st, + plc_type_t plc_type) { + if (plc_type < 0 || plc_type >= PLC_TYPE_NUM) { + TRACE(2, "[%s] plc type %d is invalid", __FUNCTION__, plc_type); + return; + } - // The packet is detected as PLC_TYPE_PASS, but causes a decoder error. - if (plc_type == PLC_TYPE_DECODER_ERROR) { - st->hist[0] -= 1; - } + // The packet is detected as PLC_TYPE_PASS, but causes a decoder error. + if (plc_type == PLC_TYPE_DECODER_ERROR) { + st->hist[0] -= 1; + } - st->hist[plc_type] += 1; + st->hist[plc_type] += 1; } -void packet_loss_detection_report(PacketLossState *st) -{ - uint32_t packet_loss_num = 0; +void packet_loss_detection_report(PacketLossState *st) { + uint32_t packet_loss_num = 0; - for (uint8_t i = 1; i < PLC_TYPE_NUM; i++) { - TRACE(3,"[%s] plc type %d occurs %d times", __FUNCTION__, i, st->hist[i]); - packet_loss_num += st->hist[i]; - } + for (uint8_t i = 1; i < PLC_TYPE_NUM; i++) { + TRACE(3, "[%s] plc type %d occurs %d times", __FUNCTION__, i, st->hist[i]); + packet_loss_num += st->hist[i]; + } - uint32_t packet_total_num = st->hist[0] + packet_loss_num; - TRACE(4,"[%s] packet loss percent %d/10000(%d/%d)", __FUNCTION__, - (int32_t)(10000.f * packet_loss_num/ packet_total_num), packet_loss_num, packet_total_num); + uint32_t packet_total_num = st->hist[0] + packet_loss_num; + TRACE(4, "[%s] packet loss percent %d/10000(%d/%d)", __FUNCTION__, + (int32_t)(10000.f * packet_loss_num / packet_total_num), + packet_loss_num, packet_total_num); } \ No newline at end of file diff --git a/apps/audioplayers/rbplay/rb_ctl.cpp b/apps/audioplayers/rbplay/rb_ctl.cpp index 4120dec..5f58101 100644 --- a/apps/audioplayers/rbplay/rb_ctl.cpp +++ b/apps/audioplayers/rbplay/rb_ctl.cpp @@ -20,50 +20,50 @@ #include "mbed.h" #include "rtos.h" #endif -#include -#include -#include -#include -#include -#include -#include -#include #include "SDFileSystem.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "hal_trace.h" +#include "app_audio.h" #include "audioflinger.h" #include "cqueue.h" -#include "app_audio.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include +#include +#include +#include +#include +#include +#include +#include -#include "eq.h" -#include "pga.h" -#include "metadata.h" -#include "dsp_core.h" -#include "codecs.h" -#include "codeclib.h" -#include "compressor.h" -#include "channel_mode.h" #include "audiohw.h" +#include "channel_mode.h" #include "codec_platform.h" +#include "codeclib.h" +#include "codecs.h" +#include "compressor.h" +#include "dsp_core.h" +#include "eq.h" +#include "metadata.h" #include "metadata_parsers.h" +#include "pga.h" -#include "hal_overlay.h" +#include "app_key.h" #include "app_overlay.h" -#include "rbpcmbuf.h" -#include "rbplay.h" #include "app_thread.h" #include "app_utils.h" -#include "app_key.h" +#include "hal_overlay.h" +#include "rbpcmbuf.h" +#include "rbplay.h" -#include "rbplaysd.h" #include "rb_ctl.h" +#include "rbplaysd.h" /* Internals */ void rb_ctl_wait_lock_thread(bool lock); void app_rbcodec_ctl_set_play_status(bool st); -extern bool app_rbcodec_check_hfp_active(void ); +extern bool app_rbcodec_check_hfp_active(void); #include "SDFileSystem.h" @@ -73,20 +73,28 @@ extern "C" void hal_sysfreq_print(void); #undef __attribute__(a) #define RBPLAY_DEBUG 1 -#if RBPLAY_DEBUG -#define _LOG_DBG(str,...) TRACE(0,_LOG_TAG""str, ##__VA_ARGS__) -#define _LOG_ERR(str,...) TRACE(0,_LOG_TAG"err:"""str, ##__VA_ARGS__) +#if RBPLAY_DEBUG +#define _LOG_DBG(str, ...) TRACE(0, _LOG_TAG "" str, ##__VA_ARGS__) +#define _LOG_ERR(str, ...) \ + TRACE(0, \ + _LOG_TAG "err:" \ + "" str, \ + ##__VA_ARGS__) #else -#define _LOG_DBG(str,...) -#define _LOG_ERR(str,...) TRACE(0,_LOG_TAG"err:"""str, ##__VA_ARGS__) +#define _LOG_DBG(str, ...) +#define _LOG_ERR(str, ...) \ + TRACE(0, \ + _LOG_TAG "err:" \ + "" str, \ + ##__VA_ARGS__) #endif #include "rb_ctl.h" void rb_thread_send_resume(void); typedef struct { - uint32_t evt; - uint32_t arg; + uint32_t evt; + uint32_t arg; } RBCTL_MSG_BLOCK; static osThreadId rb_ctl_tid; @@ -95,320 +103,309 @@ static int rb_ctl_default_priority; osThreadDef(rb_ctl_thread, osPriorityHigh, 1, 1024 * 4, "rb_ctl"); #define RBCTL_MAILBOX_MAX (20) -osMailQDef (rb_ctl_mailbox, RBCTL_MAILBOX_MAX, RBCTL_MSG_BLOCK); +osMailQDef(rb_ctl_mailbox, RBCTL_MAILBOX_MAX, RBCTL_MSG_BLOCK); static osMailQId rb_ctl_mailbox = NULL; -int rb_ctl_mailbox_put(RBCTL_MSG_BLOCK* msg_src); +int rb_ctl_mailbox_put(RBCTL_MSG_BLOCK *msg_src); -//playlist +// playlist extern playlist_struct sd_playlist; - rb_ctl_struct rb_ctl_context; -extern void rb_thread_set_decode_vars(int fd, int type ,void* id3); +extern void rb_thread_set_decode_vars(int fd, int type, void *id3); extern void rb_play_codec_run(void); -extern void rb_codec_set_halt(int halt); +extern void rb_codec_set_halt(int halt); extern void rb_player_sync_set_wait_thread(osThreadId tid); -extern void rb_player_sync_wait_close(void ); -extern bool rb_pcmbuf_suspend_play_loop(void); -void app_rbplay_load_playlist(playlist_struct *list ); -int rb_thread_post_msg(RB_MODULE_EVT evt,uint32_t arg ); +extern void rb_player_sync_wait_close(void); +extern bool rb_pcmbuf_suspend_play_loop(void); +void app_rbplay_load_playlist(playlist_struct *list); +int rb_thread_post_msg(RB_MODULE_EVT evt, uint32_t arg); -static rb_ctl_status rb_ctl_get_status(void) -{ - return rb_ctl_context.status; +static rb_ctl_status rb_ctl_get_status(void) { return rb_ctl_context.status; } + +bool rb_ctl_parse_file(const char *file_path) { + /* open file */ + + _LOG_DBG(1, "open file %s\n", file_path); + rb_ctl_context.file_handle = open((const char *)file_path, O_RDWR); + if (rb_ctl_context.file_handle <= 0) { + _LOG_DBG(1, "open file %s failed\n", file_path); + return false; + } + + if (!get_metadata(&rb_ctl_context.song_id3, rb_ctl_context.file_handle, + rb_ctl_context.rb_fname)) { + _LOG_DBG(0, "get_metadata failed\n"); + close(rb_ctl_context.file_handle); + return false; + } + + _LOG_DBG(4, "%s bitr:%d,saps %d, freq:%d\n", __func__, + rb_ctl_context.song_id3.bitrate, rb_ctl_context.song_id3.samples, + rb_ctl_context.song_id3.frequency); + + rb_thread_set_decode_vars(rb_ctl_context.file_handle, + rb_ctl_context.song_id3.codectype, + &rb_ctl_context.song_id3); + + return true; } -bool rb_ctl_parse_file(const char* file_path) -{ - /* open file */ +void rb_ctl_vol_operation(bool inc) { + uint32_t ret; + struct AF_STREAM_CONFIG_T *stream_cfg = NULL; - _LOG_DBG(1,"open file %s\n", file_path); - rb_ctl_context.file_handle = open((const char *)file_path, O_RDWR); - if (rb_ctl_context.file_handle <= 0) { - _LOG_DBG(1,"open file %s failed\n", file_path); - return false; + _LOG_DBG(2, "%s inc:%d , ", __func__, inc); + + if (inc) { + if (rb_ctl_context.rb_player_vol < 16) { + rb_ctl_context.rb_player_vol++; } - - if (!get_metadata(&rb_ctl_context.song_id3, rb_ctl_context.file_handle, rb_ctl_context.rb_fname)) { - _LOG_DBG(0,"get_metadata failed\n"); - close(rb_ctl_context.file_handle); - return false; + } else { + if (rb_ctl_context.rb_player_vol > 1) { + rb_ctl_context.rb_player_vol--; } + } + if (rb_ctl_context.status != RB_CTL_PLAYING) + return; - _LOG_DBG(4,"%s bitr:%d,saps %d, freq:%d\n",__func__,rb_ctl_context.song_id3.bitrate,rb_ctl_context.song_id3.samples,rb_ctl_context.song_id3.frequency); - - rb_thread_set_decode_vars(rb_ctl_context.file_handle, rb_ctl_context.song_id3.codectype,&rb_ctl_context.song_id3); - - return true; + ret = af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg, + true); + if (ret == 0) { + stream_cfg->vol = rb_ctl_context.rb_player_vol; + af_stream_setup(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, stream_cfg); + } } -void rb_ctl_vol_operation(bool inc ) -{ - uint32_t ret; - struct AF_STREAM_CONFIG_T *stream_cfg = NULL; - - _LOG_DBG(2,"%s inc:%d , ",__func__,inc); - - if(inc ) { - if(rb_ctl_context.rb_player_vol < 16 ) { - rb_ctl_context.rb_player_vol++; - - } - } else { - if(rb_ctl_context.rb_player_vol > 1 ) { - rb_ctl_context.rb_player_vol--; - } - } - if(rb_ctl_context.status != RB_CTL_PLAYING) - return ; - - ret = af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg, true); - if (ret == 0) { - stream_cfg->vol = rb_ctl_context.rb_player_vol; - af_stream_setup(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, stream_cfg); - } +bool rb_ctl_is_playing(void) { + return (rb_ctl_context.status == RB_CTL_PLAYING); } -bool rb_ctl_is_playing(void) -{ - return (rb_ctl_context.status == RB_CTL_PLAYING); +void rb_ctl_set_vol(uint32_t vol) { + uint32_t ret; + struct AF_STREAM_CONFIG_T *stream_cfg = NULL; + + _LOG_DBG(2, "%s set vol as :%d , ", __func__, vol); + + if (rb_ctl_context.status != RB_CTL_PLAYING) + return; + + vol = (vol > 16) ? 16 : vol; + rb_ctl_context.rb_player_vol = vol; + + ret = af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg, + true); + if (ret == 0) { + stream_cfg->vol = rb_ctl_context.rb_player_vol; + af_stream_setup(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, stream_cfg); + } } -void rb_ctl_set_vol(uint32_t vol) -{ - uint32_t ret; - struct AF_STREAM_CONFIG_T *stream_cfg = NULL; +void rb_ctl_stop_play(void) { + _LOG_DBG(1, "%s \n", __func__); - _LOG_DBG(2,"%s set vol as :%d , ",__func__,vol); + rb_codec_set_halt(1); + // close file + _LOG_DBG(0, " af stream stop \n"); + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + _LOG_DBG(0, " af stream close \n"); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + _LOG_DBG(0, " close file \n"); + if (rb_ctl_context.file_handle != -1) + close(rb_ctl_context.file_handle); + rb_ctl_context.file_handle = -1; + // release frequency + _LOG_DBG(0, " release freq \n"); - if(rb_ctl_context.status != RB_CTL_PLAYING) - return ; - - vol = (vol > 16)?16:vol; - rb_ctl_context.rb_player_vol = vol; - - ret = af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg, true); - if (ret == 0) { - stream_cfg->vol = rb_ctl_context.rb_player_vol; - af_stream_setup(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, stream_cfg); - } + return; } -void rb_ctl_stop_play(void ) -{ - _LOG_DBG(1,"%s \n",__func__); +void rb_ctl_sync_stop_play(void) { + rb_player_sync_set_wait_thread(osThreadGetId()); - rb_codec_set_halt(1); -//close file - _LOG_DBG(0," af stream stop \n"); - af_stream_stop(AUD_STREAM_ID_0,AUD_STREAM_PLAYBACK); - _LOG_DBG(0," af stream close \n"); - af_stream_close(AUD_STREAM_ID_0,AUD_STREAM_PLAYBACK); - _LOG_DBG(0," close file \n"); - if(rb_ctl_context.file_handle != -1) - close(rb_ctl_context.file_handle ); - rb_ctl_context.file_handle = -1; -//release frequency - _LOG_DBG(0," release freq \n"); - - return ; + rb_ctl_stop_play(); + + rb_player_sync_wait_close(); + // close file + _LOG_DBG(0, " close file \n"); + if (rb_ctl_context.file_handle != -1) + close(rb_ctl_context.file_handle); + rb_ctl_context.file_handle = -1; } -void rb_ctl_sync_stop_play(void ) -{ - rb_player_sync_set_wait_thread(osThreadGetId()); +void rb_ctl_pause_playing(void) { + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + _LOG_DBG(0, " af stream close \n"); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + // wait decoder suspend + // osDelay(200); + // while(!rb_pcmbuf_suspend_play_loop()) { + // osThreadYield(); + // osDelay(1); + // } - rb_ctl_stop_play(); - - rb_player_sync_wait_close(); - //close file - _LOG_DBG(0," close file \n"); - if(rb_ctl_context.file_handle != -1) - close(rb_ctl_context.file_handle ); - rb_ctl_context.file_handle = -1; + _LOG_DBG(1, "%s sucessed ", __func__); } -void rb_ctl_pause_playing(void ) -{ - af_stream_stop(AUD_STREAM_ID_0,AUD_STREAM_PLAYBACK); - _LOG_DBG(0," af stream close \n"); - af_stream_close(AUD_STREAM_ID_0,AUD_STREAM_PLAYBACK); -//wait decoder suspend - //osDelay(200); - // while(!rb_pcmbuf_suspend_play_loop()) { - //osThreadYield(); - // osDelay(1); - // } - - _LOG_DBG(1,"%s sucessed ",__func__); -} - -void rb_ctl_resume_playing(void ) -{ +void rb_ctl_resume_playing(void) { #ifndef __TWS__ - rb_pcmbuf_init(); + rb_pcmbuf_init(); #endif } - -void rb_ctl_set_priority(int priority) -{ - osThreadSetPriority(rb_ctl_tid, (osPriority)priority); +void rb_ctl_set_priority(int priority) { + osThreadSetPriority(rb_ctl_tid, (osPriority)priority); } -int rb_ctl_get_priority(void) -{ - return (int)osThreadGetPriority(rb_ctl_tid); -} +int rb_ctl_get_priority(void) { return (int)osThreadGetPriority(rb_ctl_tid); } -int rb_ctl_get_default_priority(void) -{ - return rb_ctl_default_priority; -} +int rb_ctl_get_default_priority(void) { return rb_ctl_default_priority; } -void rb_ctl_reset_priority(void) -{ - osThreadSetPriority(rb_ctl_tid, (osPriority)rb_ctl_default_priority); +void rb_ctl_reset_priority(void) { + osThreadSetPriority(rb_ctl_tid, (osPriority)rb_ctl_default_priority); } #ifdef __IAG_BLE_INCLUDE__ extern "C" void app_ble_inform_music_switch(uint16_t index); #endif -static int rb_ctl_handle_event(RBCTL_MSG_BLOCK *msg_body) -{ - RB_MODULE_EVT evt =(RB_MODULE_EVT) msg_body->evt; - uint32_t arg = msg_body->arg; -// hal_sysfreq_print(); +static int rb_ctl_handle_event(RBCTL_MSG_BLOCK *msg_body) { + RB_MODULE_EVT evt = (RB_MODULE_EVT)msg_body->evt; + uint32_t arg = msg_body->arg; + // hal_sysfreq_print(); + switch (evt) { + case RB_MODULE_EVT_PLAY: + if (rb_ctl_context.status != RB_CTL_IDLE) { + if (rb_ctl_context.status == RB_CTL_SUSPEND) + rb_thread_send_resume(); + else + _LOG_DBG(2, "%s st %d not in idle \n", __func__, + rb_ctl_context.status); + break; + } + _LOG_DBG(3, " %s start %d/%d ", __func__, rb_ctl_context.curr_song_idx, + sd_playlist.total_songs); + if (sd_playlist.total_songs > 0) { + playlist_item *it; - switch(evt) { - case RB_MODULE_EVT_PLAY: - if(rb_ctl_context.status != RB_CTL_IDLE) { - if(rb_ctl_context.status == RB_CTL_SUSPEND) - rb_thread_send_resume(); - else - _LOG_DBG(2,"%s st %d not in idle \n",__func__,rb_ctl_context.status); - break; - } - _LOG_DBG(3," %s start %d/%d ",__func__, rb_ctl_context.curr_song_idx ,sd_playlist.total_songs); - if(sd_playlist.total_songs > 0 ) { - playlist_item *it; + it = app_rbplay_get_playitem(rb_ctl_context.curr_song_idx); - it = app_rbplay_get_playitem(rb_ctl_context.curr_song_idx) ; + if (it == NULL) { + _LOG_DBG(2, " %s get item fail idx %d", __func__, + rb_ctl_context.curr_song_idx); + } - if(it == NULL) { - _LOG_DBG(2," %s get item fail idx %d",__func__,rb_ctl_context.curr_song_idx); - } + _LOG_DBG(2, "%s start songidx %d \n", __func__, + rb_ctl_context.curr_song_idx); - _LOG_DBG(2,"%s start songidx %d \n",__func__,rb_ctl_context.curr_song_idx); + memcpy(rb_ctl_context.rb_audio_file, it->file_path, + sizeof(uint16_t) * FILE_PATH_LEN - 4); + memcpy(rb_ctl_context.rb_fname, it->file_name, + sizeof(rb_ctl_context.rb_fname)); - memcpy(rb_ctl_context.rb_audio_file,it->file_path,sizeof(uint16_t)*FILE_PATH_LEN - 4); - memcpy(rb_ctl_context.rb_fname,it->file_name,sizeof(rb_ctl_context.rb_fname)); + if (rb_ctl_parse_file((const char *)rb_ctl_context.rb_audio_file)) { + _LOG_DBG(2, "%s start init, the tid 0x%x\n", __func__, + osThreadGetId()); + rb_play_codec_init(); + _LOG_DBG(1, "%s start run\n", __func__); + rb_play_codec_run(); + rb_ctl_context.status = RB_CTL_PLAYING; + app_rbcodec_ctl_set_play_status(true); + break; + } else { + _LOG_DBG(2, "%s evt %d parse fail,find next\n", __func__, + msg_body->evt); + rb_thread_post_msg(RB_MODULE_EVT_PLAY_NEXT, true); + } - if(rb_ctl_parse_file((const char*)rb_ctl_context.rb_audio_file)) { - _LOG_DBG(2,"%s start init, the tid 0x%x\n",__func__,osThreadGetId()); - rb_play_codec_init(); - _LOG_DBG(1,"%s start run\n",__func__); - rb_play_codec_run(); - rb_ctl_context.status = RB_CTL_PLAYING; - app_rbcodec_ctl_set_play_status(true); - break; - } else { - _LOG_DBG(2,"%s evt %d parse fail,find next\n",__func__,msg_body->evt); - rb_thread_post_msg(RB_MODULE_EVT_PLAY_NEXT,true); - } + } else { + _LOG_DBG(2, "%s evt %d no songs\n", __func__, msg_body->evt); + } + break; + case RB_MODULE_EVT_STOP: + if (rb_ctl_context.status == RB_CTL_IDLE) { + _LOG_DBG(2, "%s st %d in idle \n", __func__, rb_ctl_context.status); + break; + } + if (rb_ctl_context.status == RB_CTL_SUSPEND) { + // osDelay(100); + rb_ctl_resume_playing(); + rb_ctl_context.status = RB_CTL_PLAYING; + } + rb_ctl_sync_stop_play(); + rb_ctl_context.status = RB_CTL_IDLE; + app_rbcodec_ctl_set_play_status(false); + break; + case RB_MODULE_EVT_SUSPEND: + if (rb_ctl_context.status != RB_CTL_PLAYING) { + _LOG_DBG(2, "%s st %d not running \n", __func__, rb_ctl_context.status); + break; + } + rb_ctl_pause_playing(); + rb_ctl_context.status = RB_CTL_SUSPEND; + break; + case RB_MODULE_EVT_RESUME: + if (rb_ctl_context.status != RB_CTL_SUSPEND) { + _LOG_DBG(2, "%s st %d not suspend \n", __func__, rb_ctl_context.status); + break; + } + rb_ctl_resume_playing(); + rb_ctl_context.status = RB_CTL_PLAYING; + break; + case RB_MODULE_EVT_PLAY_NEXT: + if (rb_ctl_context.status == RB_CTL_PLAYING) { + rb_thread_post_msg(RB_MODULE_EVT_STOP, 0); + } else if (rb_ctl_context.status == RB_CTL_SUSPEND) { + rb_thread_post_msg(RB_MODULE_EVT_STOP, 0); + } else { + } + if (arg == 0) { + rb_ctl_context.curr_song_idx--; - } else { - _LOG_DBG(2,"%s evt %d no songs\n",__func__,msg_body->evt); - } - break; - case RB_MODULE_EVT_STOP: - if(rb_ctl_context.status == RB_CTL_IDLE) { - _LOG_DBG(2,"%s st %d in idle \n",__func__,rb_ctl_context.status); - break; - } - if(rb_ctl_context.status == RB_CTL_SUSPEND) { - //osDelay(100); - rb_ctl_resume_playing(); - rb_ctl_context.status = RB_CTL_PLAYING; - } - rb_ctl_sync_stop_play(); - rb_ctl_context.status = RB_CTL_IDLE; - app_rbcodec_ctl_set_play_status(false); - break; - case RB_MODULE_EVT_SUSPEND: - if (rb_ctl_context.status != RB_CTL_PLAYING) { - _LOG_DBG(2,"%s st %d not running \n",__func__,rb_ctl_context.status); - break; - } - rb_ctl_pause_playing(); - rb_ctl_context.status = RB_CTL_SUSPEND; - break; - case RB_MODULE_EVT_RESUME: - if (rb_ctl_context.status != RB_CTL_SUSPEND) { - _LOG_DBG(2,"%s st %d not suspend \n",__func__,rb_ctl_context.status); - break; - } - rb_ctl_resume_playing(); - rb_ctl_context.status = RB_CTL_PLAYING; - break; - case RB_MODULE_EVT_PLAY_NEXT: - if( rb_ctl_context.status == RB_CTL_PLAYING) { - rb_thread_post_msg(RB_MODULE_EVT_STOP,0 ); - } else if( rb_ctl_context.status == RB_CTL_SUSPEND) { - rb_thread_post_msg(RB_MODULE_EVT_STOP,0 ); - } else { + if (rb_ctl_context.curr_song_idx == 0xffff) + rb_ctl_context.curr_song_idx = sd_playlist.total_songs - 1; - } - if(arg == 0) { - rb_ctl_context.curr_song_idx--; + } else { - if(rb_ctl_context.curr_song_idx == 0xffff) - rb_ctl_context.curr_song_idx = sd_playlist.total_songs -1; + rb_ctl_context.curr_song_idx++; - } else { + if (rb_ctl_context.curr_song_idx >= sd_playlist.total_songs) + rb_ctl_context.curr_song_idx = 0; + } - rb_ctl_context.curr_song_idx++; +#ifdef __IAG_BLE_INCLUDE__ + app_ble_inform_music_switch(rb_ctl_context.curr_song_idx); +#endif - if(rb_ctl_context.curr_song_idx >= sd_playlist.total_songs) - rb_ctl_context.curr_song_idx = 0; - } - - #ifdef __IAG_BLE_INCLUDE__ - app_ble_inform_music_switch(rb_ctl_context.curr_song_idx); - #endif - - rb_thread_post_msg(RB_MODULE_EVT_PLAY,0 ); - break; - case RB_MODULE_EVT_CHANGE_VOL: - rb_ctl_vol_operation(arg); - break; - case RB_MODULE_EVT_SET_VOL: - rb_ctl_set_vol(arg); - break; - case RB_MODULE_EVT_CHANGE_IDLE: - rb_ctl_stop_play(); - rb_ctl_context.status = RB_CTL_IDLE; - break; - case RB_MODULE_EVT_PLAY_IDX: - if(arg > sd_playlist.total_songs -1 ) { - break; - } - if( rb_ctl_context.status == RB_CTL_PLAYING) { - rb_thread_post_msg(RB_MODULE_EVT_STOP,0 ); - } else if( rb_ctl_context.status == RB_CTL_SUSPEND) { - rb_thread_post_msg(RB_MODULE_EVT_STOP,0 ); - } else { + rb_thread_post_msg(RB_MODULE_EVT_PLAY, 0); + break; + case RB_MODULE_EVT_CHANGE_VOL: + rb_ctl_vol_operation(arg); + break; + case RB_MODULE_EVT_SET_VOL: + rb_ctl_set_vol(arg); + break; + case RB_MODULE_EVT_CHANGE_IDLE: + rb_ctl_stop_play(); + rb_ctl_context.status = RB_CTL_IDLE; + break; + case RB_MODULE_EVT_PLAY_IDX: + if (arg > sd_playlist.total_songs - 1) { + break; + } + if (rb_ctl_context.status == RB_CTL_PLAYING) { + rb_thread_post_msg(RB_MODULE_EVT_STOP, 0); + } else if (rb_ctl_context.status == RB_CTL_SUSPEND) { + rb_thread_post_msg(RB_MODULE_EVT_STOP, 0); + } else { + } - } + rb_ctl_context.curr_song_idx = (uint16_t)arg; - rb_ctl_context.curr_song_idx = (uint16_t)arg; - - rb_thread_post_msg(RB_MODULE_EVT_PLAY,0 ); - break; -//for voice cocah + rb_thread_post_msg(RB_MODULE_EVT_PLAY, 0); + break; +// for voice cocah #if 0 case SBCREADER_ACTION_INIT: //prepare fs @@ -428,348 +425,314 @@ static int rb_ctl_handle_event(RBCTL_MSG_BLOCK *msg_body) #endif #ifdef __TWS__ - case RB_MODULE_EVT_RESTORE_DUAL_PLAY: - extern void rb_restore_dual_play(uint8_t stream_type); - rb_restore_dual_play(arg); - break; + case RB_MODULE_EVT_RESTORE_DUAL_PLAY: + extern void rb_restore_dual_play(uint8_t stream_type); + rb_restore_dual_play(arg); + break; #endif - case RB_MODULE_EVT_DEL_FILE: - static rb_ctl_status prev_status = rb_ctl_context.status; - if( rb_ctl_context.status == RB_CTL_PLAYING) { - rb_thread_post_msg(RB_MODULE_EVT_STOP,0 ); - rb_thread_post_msg(RB_MODULE_EVT_DEL_FILE,arg); - } else if( rb_ctl_context.status == RB_CTL_SUSPEND) { - rb_thread_post_msg(RB_MODULE_EVT_STOP,0 ); - rb_thread_post_msg(RB_MODULE_EVT_DEL_FILE,arg); - } else { - app_ctl_remove_file(arg); - if(prev_status == RB_CTL_PLAYING) { - rb_thread_post_msg(RB_MODULE_EVT_PLAY,0 ); - } - } - - break; -#if defined(TWS_LINEIN_PLAYER) - case RB_MODULE_EVT_LINEIN_START: - extern int app_linein_codec_start(void); - app_linein_codec_start(); - break; + case RB_MODULE_EVT_DEL_FILE: + static rb_ctl_status prev_status = rb_ctl_context.status; + if (rb_ctl_context.status == RB_CTL_PLAYING) { + rb_thread_post_msg(RB_MODULE_EVT_STOP, 0); + rb_thread_post_msg(RB_MODULE_EVT_DEL_FILE, arg); + } else if (rb_ctl_context.status == RB_CTL_SUSPEND) { + rb_thread_post_msg(RB_MODULE_EVT_STOP, 0); + rb_thread_post_msg(RB_MODULE_EVT_DEL_FILE, arg); + } else { + app_ctl_remove_file(arg); + if (prev_status == RB_CTL_PLAYING) { + rb_thread_post_msg(RB_MODULE_EVT_PLAY, 0); + } + } - case RB_MODULE_EVT_RECONFIG_STREAM: - extern void rb_tws_reconfig_stream(uint32_t arg); - rb_tws_reconfig_stream(arg); - break; + break; +#if defined(TWS_LINEIN_PLAYER) + case RB_MODULE_EVT_LINEIN_START: + extern int app_linein_codec_start(void); + app_linein_codec_start(); + break; - case RB_MODULE_EVT_SET_TWS_MODE: - break; -#endif + case RB_MODULE_EVT_RECONFIG_STREAM: + extern void rb_tws_reconfig_stream(uint32_t arg); + rb_tws_reconfig_stream(arg); + break; + + case RB_MODULE_EVT_SET_TWS_MODE: + break; +#endif #ifdef SBC_RECORD_TEST - case SBC_RECORD_ACTION_START: - { - rb_ctl_context.sbc_record_on = true; - app_rbplay_set_store_flag(true); - app_rbplay_open_sbc_file(); + case SBC_RECORD_ACTION_START: { + rb_ctl_context.sbc_record_on = true; + app_rbplay_set_store_flag(true); + app_rbplay_open_sbc_file(); - } - break; - - case SBC_RECORD_ACTION_DATA_IND: - { - if(rb_ctl_context.sbc_record_on) { - app_rbplay_process_sbc_data(); - } - } - break; - - case SBC_RECORD_ACTION_STOP: - { - rb_ctl_context.sbc_record_on = false; - app_rbplay_set_store_flag(false); - app_rbplay_close_sbc_file(); - } - break; -#endif - default: - break; + } break; + + case SBC_RECORD_ACTION_DATA_IND: { + if (rb_ctl_context.sbc_record_on) { + app_rbplay_process_sbc_data(); } - if(SBC_RECORD_ACTION_DATA_IND !=msg_body->evt) - _LOG_DBG(3,"%s rbcodec evt %d ,st %d ended\n",__func__,msg_body->evt,rb_ctl_context.status); + } break; + + case SBC_RECORD_ACTION_STOP: { + rb_ctl_context.sbc_record_on = false; + app_rbplay_set_store_flag(false); + app_rbplay_close_sbc_file(); + } break; +#endif + default: + break; + } + if (SBC_RECORD_ACTION_DATA_IND != msg_body->evt) + _LOG_DBG(3, "%s rbcodec evt %d ,st %d ended\n", __func__, msg_body->evt, + rb_ctl_context.status); + return 0; +} + +int rb_thread_post_msg(RB_MODULE_EVT evt, uint32_t arg) { + int ret; + RBCTL_MSG_BLOCK msg; + + if (!rb_ctl_tid) return 0; + /* APIs */ + msg.evt = (uint32_t)evt; + msg.arg = (uint32_t)arg; + ret = rb_ctl_mailbox_put(&msg); + + _LOG_DBG(3, "%s ret %d evt:%d\n", __func__, ret, evt); + return 0; } -int rb_thread_post_msg(RB_MODULE_EVT evt,uint32_t arg ) -{ - int ret; - RBCTL_MSG_BLOCK msg; - - if(!rb_ctl_tid) - return 0; - /* APIs */ - msg.evt = (uint32_t)evt; - msg.arg = (uint32_t)arg; - ret = rb_ctl_mailbox_put(&msg); - - _LOG_DBG(3,"%s ret %d evt:%d\n",__func__,ret ,evt); - return 0; +void app_wait_player_stoped(void) { + while (rb_ctl_context.status != RB_CTL_IDLE) + osThreadYield(); } -void app_wait_player_stoped(void ) -{ - while(rb_ctl_context.status != RB_CTL_IDLE) - osThreadYield(); +void app_wait_player_suspend(void) { + if (rb_ctl_context.status == RB_CTL_IDLE) + return; + + while (rb_ctl_context.status != RB_CTL_SUSPEND) + osThreadYield(); } -void app_wait_player_suspend(void ) -{ - if(rb_ctl_context.status == RB_CTL_IDLE) - return; - - while(rb_ctl_context.status != RB_CTL_SUSPEND) - osThreadYield(); +void app_wait_player_resumed(void) { + if (rb_ctl_context.status == RB_CTL_IDLE) + return; + + while (rb_ctl_context.status != RB_CTL_PLAYING) + osThreadYield(); } -void app_wait_player_resumed(void ) -{ - if(rb_ctl_context.status == RB_CTL_IDLE) - return; - - while(rb_ctl_context.status != RB_CTL_PLAYING) - osThreadYield(); +void rb_thread_send_play(void) { + _LOG_DBG(1, " %s ", __FUNCTION__); + rb_thread_post_msg(RB_MODULE_EVT_PLAY, (uint32_t)osThreadGetId()); } -void rb_thread_send_play(void ) -{ - _LOG_DBG(1," %s ",__FUNCTION__); - rb_thread_post_msg(RB_MODULE_EVT_PLAY, (uint32_t)osThreadGetId()); +void rb_thread_send_stop(void) { + _LOG_DBG(1, " %s ", __FUNCTION__); + rb_thread_post_msg(RB_MODULE_EVT_STOP, (uint32_t)osThreadGetId()); + + osDelay(200); + app_wait_player_stoped(); } -void rb_thread_send_stop(void ) -{ - _LOG_DBG(1," %s ",__FUNCTION__); - rb_thread_post_msg(RB_MODULE_EVT_STOP, (uint32_t)osThreadGetId()); - - osDelay(200); - app_wait_player_stoped(); +void rb_thread_send_pause(void) { + _LOG_DBG(1, " %s ", __FUNCTION__); + + rb_thread_post_msg(RB_MODULE_EVT_SUSPEND, (uint32_t)osThreadGetId()); + app_wait_player_suspend(); + + _LOG_DBG(1, " %s end", __FUNCTION__); } -void rb_thread_send_pause(void) -{ - _LOG_DBG(1," %s ",__FUNCTION__); +void rb_thread_send_resume(void) { + _LOG_DBG(1, " %s ", __FUNCTION__); - rb_thread_post_msg(RB_MODULE_EVT_SUSPEND,(uint32_t)osThreadGetId()); - app_wait_player_suspend(); - - _LOG_DBG(1," %s end",__FUNCTION__); + rb_thread_post_msg(RB_MODULE_EVT_RESUME, (uint32_t)osThreadGetId()); + + _LOG_DBG(1, " %s end", __FUNCTION__); } -void rb_thread_send_resume(void) -{ - _LOG_DBG(1," %s ",__FUNCTION__); +void rb_play_dual_play_restore(uint8_t stream_type) { + _LOG_DBG(2, "%s %d \n", __func__, __LINE__); - rb_thread_post_msg(RB_MODULE_EVT_RESUME,(uint32_t)osThreadGetId()); - - _LOG_DBG(1," %s end",__FUNCTION__); + rb_thread_post_msg(RB_MODULE_EVT_RESTORE_DUAL_PLAY, stream_type); + _LOG_DBG(2, "%s %d \n", __func__, __LINE__); } -void rb_play_dual_play_restore(uint8_t stream_type ) -{ - _LOG_DBG(2,"%s %d \n", __func__, __LINE__); +void rb_thread_send_switch(bool next) { + _LOG_DBG(2, "%s %d \n", __func__, __LINE__); - rb_thread_post_msg(RB_MODULE_EVT_RESTORE_DUAL_PLAY, stream_type); - _LOG_DBG(2,"%s %d \n", __func__, __LINE__); + rb_thread_post_msg(RB_MODULE_EVT_PLAY_NEXT, next); + + _LOG_DBG(2, "%s %d \n", __func__, __LINE__); } -void rb_thread_send_switch(bool next) -{ - _LOG_DBG(2,"%s %d \n", __func__, __LINE__); +void rb_play_linein_start(void) { + _LOG_DBG(2, "%s %d \n", __func__, __LINE__); - rb_thread_post_msg(RB_MODULE_EVT_PLAY_NEXT,next); - - _LOG_DBG(2,"%s %d \n", __func__, __LINE__); + rb_thread_post_msg(RB_MODULE_EVT_LINEIN_START, 0); + _LOG_DBG(2, "%s %d \n", __func__, __LINE__); } -void rb_play_linein_start(void ) -{ - _LOG_DBG(2,"%s %d \n", __func__, __LINE__); +void rb_play_reconfig_stream(uint32_t arg) { + _LOG_DBG(3, "%s %d arg:0x%x\n", __func__, __LINE__, arg); - rb_thread_post_msg(RB_MODULE_EVT_LINEIN_START, 0); - _LOG_DBG(2,"%s %d \n", __func__, __LINE__); + rb_thread_post_msg(RB_MODULE_EVT_RECONFIG_STREAM, arg); + _LOG_DBG(2, "%s %d \n", __func__, __LINE__); } -void rb_play_reconfig_stream(uint32_t arg ) -{ - _LOG_DBG(3,"%s %d arg:0x%x\n", __func__, __LINE__, arg); +void rb_play_set_tws_mode(uint32_t arg) { + _LOG_DBG(3, "%s %d arg:0x%x\n", __func__, __LINE__, arg); - rb_thread_post_msg(RB_MODULE_EVT_RECONFIG_STREAM, arg); - _LOG_DBG(2,"%s %d \n", __func__, __LINE__); + rb_thread_post_msg(RB_MODULE_EVT_SET_TWS_MODE, arg); + _LOG_DBG(2, "%s %d \n", __func__, __LINE__); } -void rb_play_set_tws_mode(uint32_t arg ) -{ - _LOG_DBG(3,"%s %d arg:0x%x\n", __func__, __LINE__, arg); +void rb_thread_send_play_idx(uint32_t array_subidx) { + _LOG_DBG(2, " %s array_subidx %d, ", __FUNCTION__, array_subidx); - rb_thread_post_msg(RB_MODULE_EVT_SET_TWS_MODE, arg); - _LOG_DBG(2,"%s %d \n", __func__, __LINE__); + rb_thread_post_msg(RB_MODULE_EVT_PLAY_IDX, array_subidx); } -void rb_thread_send_play_idx(uint32_t array_subidx) -{ - _LOG_DBG(2," %s array_subidx %d, ",__FUNCTION__,array_subidx); +void rb_thread_send_vol(bool inc) { + _LOG_DBG(2, " %s inc %d, ", __FUNCTION__, inc); - rb_thread_post_msg(RB_MODULE_EVT_PLAY_IDX,array_subidx); + rb_thread_post_msg(RB_MODULE_EVT_CHANGE_VOL, inc); } +void rb_thread_send_status_change(void) { + _LOG_DBG(1, " %s , ", __FUNCTION__); -void rb_thread_send_vol(bool inc) -{ - _LOG_DBG(2," %s inc %d, ",__FUNCTION__,inc); - - rb_thread_post_msg(RB_MODULE_EVT_CHANGE_VOL,inc); + rb_thread_post_msg(RB_MODULE_EVT_CHANGE_IDLE, 0); } -void rb_thread_send_status_change(void ) -{ - _LOG_DBG(1," %s , ",__FUNCTION__); +void rb_thread_set_vol(uint32_t vol) { + _LOG_DBG(1, " %s , ", __FUNCTION__); - rb_thread_post_msg(RB_MODULE_EVT_CHANGE_IDLE,0); + rb_thread_post_msg(RB_MODULE_EVT_SET_VOL, vol); } -void rb_thread_set_vol(uint32_t vol) -{ - _LOG_DBG(1," %s , ",__FUNCTION__); +void rb_thread_send_del_file(uint16_t idx) { + _LOG_DBG(1, " %s , ", __FUNCTION__); - rb_thread_post_msg(RB_MODULE_EVT_SET_VOL, vol); + rb_thread_post_msg(RB_MODULE_EVT_DEL_FILE, idx); } -void rb_thread_send_del_file(uint16_t idx ) -{ - _LOG_DBG(1," %s , ",__FUNCTION__); +void rb_thread_send_sbc_record_start(void) { + _LOG_DBG(1, " %s , ", __FUNCTION__); - rb_thread_post_msg(RB_MODULE_EVT_DEL_FILE,idx); + rb_thread_post_msg(SBC_RECORD_ACTION_START, (uint32_t)osThreadGetId()); } -void rb_thread_send_sbc_record_start(void ) -{ - _LOG_DBG(1," %s , ",__FUNCTION__); - - rb_thread_post_msg(SBC_RECORD_ACTION_START,(uint32_t)osThreadGetId()); -} - -void rb_thread_send_sbc_record_data_ind(void ) -{ - if(!rb_ctl_context.sbc_record_on) - return ; +void rb_thread_send_sbc_record_data_ind(void) { + if (!rb_ctl_context.sbc_record_on) + return; // _LOG_DBG(1," %s , ",__FUNCTION__); - rb_thread_post_msg(SBC_RECORD_ACTION_DATA_IND,(uint32_t)osThreadGetId()); + rb_thread_post_msg(SBC_RECORD_ACTION_DATA_IND, (uint32_t)osThreadGetId()); } -void rb_thread_send_sbc_record_stop(void ) -{ - _LOG_DBG(1," %s , ",__FUNCTION__); +void rb_thread_send_sbc_record_stop(void) { + _LOG_DBG(1, " %s , ", __FUNCTION__); - rb_thread_post_msg(SBC_RECORD_ACTION_STOP,(uint32_t)osThreadGetId()); + rb_thread_post_msg(SBC_RECORD_ACTION_STOP, (uint32_t)osThreadGetId()); } - -//interface for audio module +// interface for audio module static bool user_key_pause_stream = false; -void app_rbplay_audio_reset_pause_status(void) -{ - user_key_pause_stream = false; +void app_rbplay_audio_reset_pause_status(void) { + user_key_pause_stream = false; } -int app_rbplay_audio_onoff(bool onoff, uint16_t aud_id) -{ - _LOG_DBG(3," %s onoff %d, get status:%d",__FUNCTION__,onoff, rb_ctl_get_status()); +int app_rbplay_audio_onoff(bool onoff, uint16_t aud_id) { + _LOG_DBG(3, " %s onoff %d, get status:%d", __FUNCTION__, onoff, + rb_ctl_get_status()); - if(app_rbcodec_check_hfp_active()&& !onoff) { - if( RB_CTL_PLAYING == rb_ctl_get_status()) { - rb_thread_send_pause(); - } - } else if ( !onoff) { - //rb_thread_send_stop(); - rb_thread_send_pause(); - } else { - if(!user_key_pause_stream) { - if( RB_CTL_SUSPEND == rb_ctl_get_status()) { - rb_thread_send_resume(); - app_wait_player_resumed(); - } else { - rb_thread_send_play(); + if (app_rbcodec_check_hfp_active() && !onoff) { + if (RB_CTL_PLAYING == rb_ctl_get_status()) { + rb_thread_send_pause(); } - } - } - - return 0; -} - -void app_rbplay_pause_resume(void) -{ - _LOG_DBG(2," %s get status:%d",__func__, rb_ctl_get_status()); - - user_key_pause_stream = true; - if( RB_CTL_SUSPEND == rb_ctl_get_status()) { - user_key_pause_stream = false; + } else if (!onoff) { + // rb_thread_send_stop(); + rb_thread_send_pause(); + } else { + if (!user_key_pause_stream) { + if (RB_CTL_SUSPEND == rb_ctl_get_status()) { rb_thread_send_resume(); + app_wait_player_resumed(); + } else { + rb_thread_send_play(); + } } - if( RB_CTL_PLAYING == rb_ctl_get_status()) { - user_key_pause_stream = true; - rb_thread_send_pause(); - } -} -//sbc reader run within thread + } -static int rb_ctl_mailbox_init(void) -{ - rb_ctl_mailbox = osMailCreate(osMailQ(rb_ctl_mailbox), NULL); - if (rb_ctl_mailbox == NULL) { - TRACE(0,"Failed to Create rb_ctl_mailbox\n"); - return -1; - } - return 0; + return 0; } -int rb_ctl_mailbox_put(RBCTL_MSG_BLOCK* msg_src) -{ - osStatus status; +void app_rbplay_pause_resume(void) { + _LOG_DBG(2, " %s get status:%d", __func__, rb_ctl_get_status()); - RBCTL_MSG_BLOCK *msg_p = NULL; - - msg_p = (RBCTL_MSG_BLOCK*)osMailAlloc(rb_ctl_mailbox, 0); - if(!msg_p) { - TRACE(3,"%s fail, evt:%d,arg=%d \n",__func__,msg_src->evt,msg_src->arg); - return -1; - } - - ASSERT(msg_p, "osMailAlloc error"); - - msg_p->evt = msg_src->evt; - msg_p->arg = msg_src->arg; - - status = osMailPut(rb_ctl_mailbox, msg_p); - - return (int)status; + user_key_pause_stream = true; + if (RB_CTL_SUSPEND == rb_ctl_get_status()) { + user_key_pause_stream = false; + rb_thread_send_resume(); + } + if (RB_CTL_PLAYING == rb_ctl_get_status()) { + user_key_pause_stream = true; + rb_thread_send_pause(); + } } +// sbc reader run within thread -int rb_ctl_mailbox_free(RBCTL_MSG_BLOCK* msg_p) -{ - osStatus status; - - status = osMailFree(rb_ctl_mailbox, msg_p); - - return (int)status; -} - -int rb_ctl_mailbox_get(RBCTL_MSG_BLOCK** msg_p) -{ - osEvent evt; - evt = osMailGet(rb_ctl_mailbox, osWaitForever); - if (evt.status == osEventMail) { - *msg_p = (RBCTL_MSG_BLOCK *)evt.value.p; - return 0; - } +static int rb_ctl_mailbox_init(void) { + rb_ctl_mailbox = osMailCreate(osMailQ(rb_ctl_mailbox), NULL); + if (rb_ctl_mailbox == NULL) { + TRACE(0, "Failed to Create rb_ctl_mailbox\n"); return -1; + } + return 0; +} + +int rb_ctl_mailbox_put(RBCTL_MSG_BLOCK *msg_src) { + osStatus status; + + RBCTL_MSG_BLOCK *msg_p = NULL; + + msg_p = (RBCTL_MSG_BLOCK *)osMailAlloc(rb_ctl_mailbox, 0); + if (!msg_p) { + TRACE(3, "%s fail, evt:%d,arg=%d \n", __func__, msg_src->evt, msg_src->arg); + return -1; + } + + ASSERT(msg_p, "osMailAlloc error"); + + msg_p->evt = msg_src->evt; + msg_p->arg = msg_src->arg; + + status = osMailPut(rb_ctl_mailbox, msg_p); + + return (int)status; +} + +int rb_ctl_mailbox_free(RBCTL_MSG_BLOCK *msg_p) { + osStatus status; + + status = osMailFree(rb_ctl_mailbox, msg_p); + + return (int)status; +} + +int rb_ctl_mailbox_get(RBCTL_MSG_BLOCK **msg_p) { + osEvent evt; + evt = osMailGet(rb_ctl_mailbox, osWaitForever); + if (evt.status == osEventMail) { + *msg_p = (RBCTL_MSG_BLOCK *)evt.value.p; + return 0; + } + return -1; } #if 0 @@ -807,81 +770,64 @@ void rb_ctl_action_stop(void) } #endif -static void rb_ctl_thread(void const *argument) -{ - osEvent evt; +static void rb_ctl_thread(void const *argument) { + osEvent evt; #if 1 - app_sysfreq_req(APP_SYSFREQ_USER_APP_PLAYER, APP_SYSFREQ_208M); + app_sysfreq_req(APP_SYSFREQ_USER_APP_PLAYER, APP_SYSFREQ_208M); - app_rbplay_load_playlist(&sd_playlist); + app_rbplay_load_playlist(&sd_playlist); #endif - memset(&rb_ctl_context,0x0,sizeof(rb_ctl_struct)); - rb_ctl_context.rb_player_vol = 6; - rb_ctl_context.status = RB_CTL_IDLE; + memset(&rb_ctl_context, 0x0, sizeof(rb_ctl_struct)); + rb_ctl_context.rb_player_vol = 6; + rb_ctl_context.status = RB_CTL_IDLE; + rb_ctl_context.curr_song_idx = 0; + // load playlist here - rb_ctl_context.curr_song_idx = 0; - //load playlist here + // voiceCocah_init(); - //voiceCocah_init(); - - rb_ctl_context.init_done = true; - - while(1) { - RBCTL_MSG_BLOCK *msg_p = NULL; + rb_ctl_context.init_done = true; - app_sysfreq_req(APP_SYSFREQ_USER_APP_PLAYER, APP_SYSFREQ_32K); + while (1) { + RBCTL_MSG_BLOCK *msg_p = NULL; - if (!rb_ctl_mailbox_get(&msg_p)) { - app_sysfreq_req(APP_SYSFREQ_USER_APP_PLAYER, APP_SYSFREQ_104M); + app_sysfreq_req(APP_SYSFREQ_USER_APP_PLAYER, APP_SYSFREQ_32K); - rb_ctl_handle_event(msg_p); + if (!rb_ctl_mailbox_get(&msg_p)) { + app_sysfreq_req(APP_SYSFREQ_USER_APP_PLAYER, APP_SYSFREQ_104M); - rb_ctl_mailbox_free(msg_p); - } + rb_ctl_handle_event(msg_p); + + rb_ctl_mailbox_free(msg_p); } + } } +int rb_ctl_init(void) { + _LOG_DBG(1, "%s \n", __func__); -int rb_ctl_init(void) -{ - _LOG_DBG(1,"%s \n",__func__); + rb_ctl_context.init_done = false; + rb_ctl_context.sbc_record_on = false; - rb_ctl_context.init_done = false; - rb_ctl_context.sbc_record_on = false; - - app_rbplay_open(); + app_rbplay_open(); - rb_ctl_mailbox_init(); + rb_ctl_mailbox_init(); - rb_ctl_tid = osThreadCreate(osThread(rb_ctl_thread), NULL); - rb_ctl_default_priority = osPriorityAboveNormal; + rb_ctl_tid = osThreadCreate(osThread(rb_ctl_thread), NULL); + rb_ctl_default_priority = osPriorityAboveNormal; - if (rb_ctl_tid == NULL) { - TRACE(0,"Failed to Create rb_ctl_thread\n"); - return 0; - } - _LOG_DBG(1,"Leave %s \n",__func__); - return 0; + if (rb_ctl_tid == NULL) { + TRACE(0, "Failed to Create rb_ctl_thread\n"); + return 0; + } + _LOG_DBG(1, "Leave %s \n", __func__); + return 0; } -uint8_t rb_ctl_get_vol(void) -{ - return rb_ctl_context.rb_player_vol; -} +uint8_t rb_ctl_get_vol(void) { return rb_ctl_context.rb_player_vol; } -bool rb_ctl_is_init_done(void) -{ - return rb_ctl_context.init_done; -} +bool rb_ctl_is_init_done(void) { return rb_ctl_context.init_done; } -bool rb_ctl_is_paused(void) -{ - return ( RB_CTL_SUSPEND == rb_ctl_get_status()); -} - -uint16_t rb_ctl_songs_count(void) -{ - return sd_playlist.total_songs; -} +bool rb_ctl_is_paused(void) { return (RB_CTL_SUSPEND == rb_ctl_get_status()); } +uint16_t rb_ctl_songs_count(void) { return sd_playlist.total_songs; } diff --git a/apps/audioplayers/rbplay/rbpcmbuf.cpp b/apps/audioplayers/rbplay/rbpcmbuf.cpp index ff41f92..b2342c8 100644 --- a/apps/audioplayers/rbplay/rbpcmbuf.cpp +++ b/apps/audioplayers/rbplay/rbpcmbuf.cpp @@ -15,28 +15,28 @@ ****************************************************************************/ /* rbpcmbuf source */ /* pcmbuf management & af control & mixer */ -#include -#include -#include #include +#include +#include +#include #include #ifdef MBED #include "mbed.h" #include "rtos.h" #endif -#include "audioflinger.h" -#include "cqueue.h" #include "app_audio.h" #include "app_utils.h" +#include "audioflinger.h" +#include "cqueue.h" #include "hal_trace.h" -#include "rbplay.h" #include "rbpcmbuf.h" +#include "rbplay.h" #include "utils.h" -#define RB_PCMBUF_DMA_BUFFER_SIZE (1024*12) -#define RB_PCMBUF_MEDIA_BUFFER_SIZE (1024*12) +#define RB_PCMBUF_DMA_BUFFER_SIZE (1024 * 12) +#define RB_PCMBUF_MEDIA_BUFFER_SIZE (1024 * 12) #define RB_DECODE_OUT_BUFFER_SIZE 1024 static uint8_t *rb_decode_out_buff; @@ -46,95 +46,93 @@ static CQueue rb_pcmbuf_media_buf_queue; static osMutexId _rb_media_buf_queue_mutex_id = NULL; static osMutexDef(_rb_media_buf_queue_mutex); -#define LOCK_MEDIA_BUF_QUEUE() \ - if(osErrorISR == osMutexWait(_rb_media_buf_queue_mutex_id, osWaitForever)) {\ - error("%s LOCK_MEDIA_BUF_QUEUE from IRQ!!!!!!!\n",__func__);\ - }\ +#define LOCK_MEDIA_BUF_QUEUE() \ + if (osErrorISR == \ + osMutexWait(_rb_media_buf_queue_mutex_id, osWaitForever)) { \ + error("%s LOCK_MEDIA_BUF_QUEUE from IRQ!!!!!!!\n", __func__); \ + } -#define UNLOCK_MEDIA_BUF_QUEUE() \ - if(osErrorISR == osMutexRelease(_rb_media_buf_queue_mutex_id)){ \ - error("%s UNLOCK_MEDIA_BUF_QUEUE from IRQ!!!!!!\n"); \ - } \ +#define UNLOCK_MEDIA_BUF_QUEUE() \ + if (osErrorISR == osMutexRelease(_rb_media_buf_queue_mutex_id)) { \ + error("%s UNLOCK_MEDIA_BUF_QUEUE from IRQ!!!!!!\n"); \ + } -static uint32_t rbplay_more_data(uint8_t *buf, uint32_t len) -{ - CQItemType *e1 = NULL; - CQItemType *e2 = NULL; - unsigned int len1 = 0; - unsigned int len2 = 0; +static uint32_t rbplay_more_data(uint8_t *buf, uint32_t len) { + CQItemType *e1 = NULL; + CQItemType *e2 = NULL; + unsigned int len1 = 0; + unsigned int len2 = 0; + LOCK_MEDIA_BUF_QUEUE(); + int ret = PeekCQueue(&rb_pcmbuf_media_buf_queue, len, &e1, &len1, &e2, &len2); + UNLOCK_MEDIA_BUF_QUEUE(); + + if (ret == CQ_OK) { + if (len1 > 0) + memcpy(buf, e1, len1); + if (len2 > 0) + memcpy(buf + len1, e2, len - len1); LOCK_MEDIA_BUF_QUEUE(); - int ret = PeekCQueue(&rb_pcmbuf_media_buf_queue, len, &e1, &len1, &e2, &len2); + DeCQueue(&rb_pcmbuf_media_buf_queue, 0, len); UNLOCK_MEDIA_BUF_QUEUE(); + } else { + warn("RBplay cache underflow"); + } - if (ret == CQ_OK) { - if (len1 > 0) - memcpy(buf, e1, len1); - if (len2 > 0) - memcpy(buf + len1, e2, len - len1); - LOCK_MEDIA_BUF_QUEUE(); - DeCQueue(&rb_pcmbuf_media_buf_queue, 0, len); - UNLOCK_MEDIA_BUF_QUEUE(); - } else { - warn("RBplay cache underflow"); - } - - return len; + return len; } extern uint8_t rb_ctl_get_vol(void); -void rb_pcmbuf_init(void) -{ - info("pcmbuff init"); - if(!_rb_media_buf_queue_mutex_id) - _rb_media_buf_queue_mutex_id = osMutexCreate((osMutex(_rb_media_buf_queue_mutex))); +void rb_pcmbuf_init(void) { + info("pcmbuff init"); + if (!_rb_media_buf_queue_mutex_id) + _rb_media_buf_queue_mutex_id = + osMutexCreate((osMutex(_rb_media_buf_queue_mutex))); - app_audio_mempool_init(); + app_audio_mempool_init(); - app_audio_mempool_get_buff(&rb_pcmbuf_media_buf, RB_PCMBUF_MEDIA_BUFFER_SIZE); - InitCQueue(&rb_pcmbuf_media_buf_queue, RB_PCMBUF_MEDIA_BUFFER_SIZE, (unsigned char *)rb_pcmbuf_media_buf); + app_audio_mempool_get_buff(&rb_pcmbuf_media_buf, RB_PCMBUF_MEDIA_BUFFER_SIZE); + InitCQueue(&rb_pcmbuf_media_buf_queue, RB_PCMBUF_MEDIA_BUFFER_SIZE, + (unsigned char *)rb_pcmbuf_media_buf); - app_audio_mempool_get_buff(&rbplay_dma_buffer, RB_PCMBUF_DMA_BUFFER_SIZE); - app_audio_mempool_get_buff(&rb_decode_out_buff, RB_DECODE_OUT_BUFFER_SIZE); + app_audio_mempool_get_buff(&rbplay_dma_buffer, RB_PCMBUF_DMA_BUFFER_SIZE); + app_audio_mempool_get_buff(&rb_decode_out_buff, RB_DECODE_OUT_BUFFER_SIZE); - struct AF_STREAM_CONFIG_T stream_cfg; + struct AF_STREAM_CONFIG_T stream_cfg; - memset(&stream_cfg, 0, sizeof(stream_cfg)); + memset(&stream_cfg, 0, sizeof(stream_cfg)); - stream_cfg.bits = AUD_BITS_16; - stream_cfg.channel_num = AUD_CHANNEL_NUM_2; - stream_cfg.sample_rate = AUD_SAMPRATE_44100; - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; - stream_cfg.vol = rb_ctl_get_vol(); - stream_cfg.handler = rbplay_more_data; - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(rbplay_dma_buffer); - stream_cfg.data_size = RB_PCMBUF_DMA_BUFFER_SIZE; + stream_cfg.bits = AUD_BITS_16; + stream_cfg.channel_num = AUD_CHANNEL_NUM_2; + stream_cfg.sample_rate = AUD_SAMPRATE_44100; + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; + stream_cfg.vol = rb_ctl_get_vol(); + stream_cfg.handler = rbplay_more_data; + stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(rbplay_dma_buffer); + stream_cfg.data_size = RB_PCMBUF_DMA_BUFFER_SIZE; - af_stream_open(AUD_STREAM_ID_0,AUD_STREAM_PLAYBACK, &stream_cfg); - af_stream_start(AUD_STREAM_ID_0,AUD_STREAM_PLAYBACK); + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); } -void *rb_pcmbuf_request_buffer(int *size) -{ - *size = RB_DECODE_OUT_BUFFER_SIZE / 4; - return rb_decode_out_buff; +void *rb_pcmbuf_request_buffer(int *size) { + *size = RB_DECODE_OUT_BUFFER_SIZE / 4; + return rb_decode_out_buff; } -void rb_pcmbuf_write(unsigned int size) -{ - int ret ; - do { - LOCK_MEDIA_BUF_QUEUE(); - ret = EnCQueue(&rb_pcmbuf_media_buf_queue, (CQItemType *)rb_decode_out_buff, size*(2*2)); - UNLOCK_MEDIA_BUF_QUEUE(); - osThreadYield(); - } while (ret == CQ_ERR); +void rb_pcmbuf_write(unsigned int size) { + int ret; + do { + LOCK_MEDIA_BUF_QUEUE(); + ret = EnCQueue(&rb_pcmbuf_media_buf_queue, (CQItemType *)rb_decode_out_buff, + size * (2 * 2)); + UNLOCK_MEDIA_BUF_QUEUE(); + osThreadYield(); + } while (ret == CQ_ERR); } -void rb_pcmbuf_stop(void) -{ - af_stream_stop(AUD_STREAM_ID_0,AUD_STREAM_PLAYBACK); - af_stream_close(AUD_STREAM_ID_0,AUD_STREAM_PLAYBACK); +void rb_pcmbuf_stop(void) { + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); } - diff --git a/apps/audioplayers/rbplay/rbplay.cpp b/apps/audioplayers/rbplay/rbplay.cpp index dee5d3e..72e1679 100644 --- a/apps/audioplayers/rbplay/rbplay.cpp +++ b/apps/audioplayers/rbplay/rbplay.cpp @@ -16,34 +16,34 @@ /* rbplay source */ /* playback control & rockbox codec porting & codec thread */ -#include +#include +#include #include #include -#include #include -#include -#include +#include +#include #include #ifdef MBED #include "mbed.h" #include "rtos.h" #endif -#include "metadata.h" +#include "app_overlay.h" +#include "apps.h" +#include "audioflinger.h" #include "codecs.h" #include "eq_export.h" #include "hal_overlay.h" -#include "app_overlay.h" -#include "audioflinger.h" #include "hal_trace.h" -#include "apps.h" +#include "metadata.h" -#include "rbpcmbuf.h" -#include "rbplaysd.h" +#include "app_key.h" #include "app_thread.h" #include "app_utils.h" -#include "app_key.h" +#include "rbpcmbuf.h" #include "rbplay.h" +#include "rbplaysd.h" #include "utils.h" #ifdef __TWS__ @@ -51,28 +51,30 @@ #endif // TODO: remove -#define BT_STREAM_RBCODEC 0x10 //from rockbox decoder +#define BT_STREAM_RBCODEC 0x10 // from rockbox decoder extern "C" { - void flac_codec_main(int r); - void flac_codec_run(void); - void wav_codec_main(int r); - void wav_codec_run(void); - void mpa_codec_main(int r); - void mpa_codec_run(void); - void ape_codec_main(int r); - void ape_codec_run(void); - void sbc_codec_main(int r); - void sbc_codec_run(void); +void flac_codec_main(int r); +void flac_codec_run(void); +void wav_codec_main(int r); +void wav_codec_run(void); +void mpa_codec_main(int r); +void mpa_codec_run(void); +void ape_codec_main(int r); +void ape_codec_run(void); +void sbc_codec_main(int r); +void sbc_codec_run(void); } -extern void rb_pcm_player_open(enum AUD_BITS_T bits,enum AUD_SAMPRATE_T sample_rate,enum AUD_CHANNEL_NUM_T channel_num,uint8_t vol) ; +extern void rb_pcm_player_open(enum AUD_BITS_T bits, + enum AUD_SAMPRATE_T sample_rate, + enum AUD_CHANNEL_NUM_T channel_num, uint8_t vol); #if defined(__TWS__) -typedef struct _rb_tws_codec_info{ - uint8_t update_codec_info; - int32_t sample_freq; - uint8_t channel_num; +typedef struct _rb_tws_codec_info { + uint8_t update_codec_info; + int32_t sample_freq; + uint8_t channel_num; } rb_tws_codec_info; rb_tws_codec_info codec_info = {1, 44100, 2}; @@ -82,17 +84,18 @@ static osThreadId rb_decode_tid = NULL; static osThreadId rb_caller_tid = NULL; typedef struct { - uint32_t evt; - uint32_t arg; + uint32_t evt; + uint32_t arg; } RBTHREAD_MSG_BLOCK; #define RBTHREAD_MAILBOX_MAX (10) -osMailQDef (rb_decode_mailbox, RBTHREAD_MAILBOX_MAX, RBTHREAD_MSG_BLOCK); -int rb_decode_mailbox_put(RBTHREAD_MSG_BLOCK* msg_src); +osMailQDef(rb_decode_mailbox, RBTHREAD_MAILBOX_MAX, RBTHREAD_MSG_BLOCK); +int rb_decode_mailbox_put(RBTHREAD_MSG_BLOCK *msg_src); static osMailQId rb_decode_mailbox = NULL; static void rb_decode_thread(void const *argument); -osThreadDef(rb_decode_thread, osPriorityAboveNormal, 1, 1024 * 2, "rb_decorder"); +osThreadDef(rb_decode_thread, osPriorityAboveNormal, 1, 1024 * 2, + "rb_decorder"); // rbcodec info static int song_fd; @@ -115,226 +118,203 @@ uint16_t g_rbplayer_curr_song_idx = 0; extern void app_rbplay_exit(void); -extern void bt_change_to_iic(APP_KEY_STATUS *status, void *param); +extern void bt_change_to_iic(APP_KEY_STATUS *status, void *param); -extern void rb_thread_send_switch(bool next); -extern void rb_thread_send_status_change(void ); +extern void rb_thread_send_switch(bool next); +extern void rb_thread_send_status_change(void); enum APP_SYSFREQ_FREQ_T rb_player_get_work_freq(void); -static void rb_player_sync_close_done(void) -{ - thread_tid_waiter = NULL; -} +static void rb_player_sync_close_done(void) { thread_tid_waiter = NULL; } extern void rb_check_stream_reconfig(int32_t freq, uint8_t ch); -static void f_codec_pcmbuf_insert_callback( - const void *ch1, const void *ch2, int count) -{ - struct dsp_buffer src; - struct dsp_buffer dst; +static void f_codec_pcmbuf_insert_callback(const void *ch1, const void *ch2, + int count) { + struct dsp_buffer src; + struct dsp_buffer dst; - src.remcount = count; - src.pin[0] = (const unsigned char *)ch1; - src.pin[1] = (const unsigned char *)ch2; - src.proc_mask = 0; + src.remcount = count; + src.pin[0] = (const unsigned char *)ch1; + src.pin[1] = (const unsigned char *)ch2; + src.proc_mask = 0; - if (rb_codec_running() == 0) - return ; + if (rb_codec_running() == 0) + return; #ifndef __TWS__ - while (src.remcount > 0) { - dst.remcount = 0; - dst.p16out = (short *)rb_pcmbuf_request_buffer(&dst.bufcount); + while (src.remcount > 0) { + dst.remcount = 0; + dst.p16out = (short *)rb_pcmbuf_request_buffer(&dst.bufcount); - if (dst.p16out == NULL) { - warn("No pcm buffer"); - osThreadYield(); - } else { - dsp_process(ci->dsp, &src, &dst); + if (dst.p16out == NULL) { + warn("No pcm buffer"); + osThreadYield(); + } else { + dsp_process(ci->dsp, &src, &dst); - if (dst.remcount > 0) { - rb_pcmbuf_write(dst.remcount); - } - } + if (dst.remcount > 0) { + rb_pcmbuf_write(dst.remcount); + } } + } #else - if(codec_info.update_codec_info){ - rb_set_sbc_encoder_freq_ch(codec_info.sample_freq, codec_info.channel_num); //should call this to set trigger timer - rb_check_stream_reconfig(codec_info.sample_freq, codec_info.channel_num); - codec_info.update_codec_info = 0; + if (codec_info.update_codec_info) { + rb_set_sbc_encoder_freq_ch( + codec_info.sample_freq, + codec_info.channel_num); // should call this to set trigger timer + rb_check_stream_reconfig(codec_info.sample_freq, codec_info.channel_num); + codec_info.update_codec_info = 0; + } + + if (tws_local_player_need_tran_2_slave()) { + rb_tws_start_master_player(BT_STREAM_RBCODEC); + } + while (1) { + uint8_t *pcm_buff = NULL; + dst.remcount = 0; + dst.bufcount = MIN(src.remcount, 128); /* Arbitrary min request */ + dst.p16out = (short *)rb_pcmbuf_request_buffer(&dst.bufcount); + pcm_buff = (uint8_t *)dst.p16out; + ASSERT(pcm_buff, "Should request buffer"); + + dsp_process(ci->dsp, &src, &dst); + + if (dst.remcount > 0) { + while (rb_push_pcm_in_tws_buffer(pcm_buff, dst.remcount * 2 * 2) == 0) { + osDelay(2); + } } - if(tws_local_player_need_tran_2_slave()){ - rb_tws_start_master_player(BT_STREAM_RBCODEC); - } - while(1){ - uint8_t * pcm_buff = NULL; - dst.remcount = 0; - dst.bufcount = MIN(src.remcount, 128); /* Arbitrary min request */ - dst.p16out = (short *)rb_pcmbuf_request_buffer(&dst.bufcount); - pcm_buff = (uint8_t *)dst.p16out; - ASSERT(pcm_buff, "Should request buffer"); - - dsp_process(ci->dsp, &src, &dst); - - if (dst.remcount > 0) { - while(rb_push_pcm_in_tws_buffer(pcm_buff, dst.remcount*2*2) == 0){ - osDelay(2); - } - } - - if (src.remcount <= 0) { - return; /* No input remains and DSP purged */ - } + if (src.remcount <= 0) { + return; /* No input remains and DSP purged */ } + } #endif } -static void f_audio_codec_update_elapsed(unsigned long elapsed) -{ - //info("Update elapsed: %d", elapsed); - return; +static void f_audio_codec_update_elapsed(unsigned long elapsed) { + // info("Update elapsed: %d", elapsed); + return; } -static size_t f_codec_filebuf_callback(void *ptr, size_t size) -{ - ssize_t ret; - ret = read(song_fd, ptr, size); - if(ret < 0) { - error("File read error: %d",ret); - } - - return ret; +static size_t f_codec_filebuf_callback(void *ptr, size_t size) { + ssize_t ret; + ret = read(song_fd, ptr, size); + if (ret < 0) { + error("File read error: %d", ret); + } + return ret; } -static void * f_codec_request_buffer_callback(size_t *realsize, size_t reqsize) -{ +static void *f_codec_request_buffer_callback(size_t *realsize, size_t reqsize) { + return NULL; +} + +static void *f_codec_advance_buffer_callback(size_t amount) { + off_t ret = lseek(song_fd, (off_t)(ci->curpos + amount), SEEK_SET); + if (ret < 0) { + error("File seek fail"); return NULL; + } + + ci->curpos += amount; + return (void *)ci; } -static void * f_codec_advance_buffer_callback(size_t amount) -{ - off_t ret = lseek(song_fd, (off_t)(ci->curpos + amount), SEEK_SET); - if(ret < 0) { - error("File seek fail"); - return NULL; - } - - ci->curpos += amount; - return (void *)ci; +static bool f_codec_seek_buffer_callback(size_t newpos) { + off_t ret = lseek(song_fd, (off_t)newpos, SEEK_SET); + if (ret < 0) { + error("File seek fail"); + return false; + } + ci->curpos = newpos; + return true; } -static bool f_codec_seek_buffer_callback(size_t newpos) -{ - off_t ret = lseek(song_fd, (off_t)newpos, SEEK_SET); - if(ret < 0) { - error("File seek fail"); - return false; - } - - ci->curpos = newpos; - return true; +static void f_codec_seek_complete_callback(void) { + info("Seek complete"); + dsp_configure(ci->dsp, DSP_FLUSH, 0); } -static void f_codec_seek_complete_callback(void) -{ - info("Seek complete"); - dsp_configure(ci->dsp, DSP_FLUSH, 0); -} +static void f_audio_codec_update_offset(size_t offset) {} -static void f_audio_codec_update_offset(size_t offset) -{ -} - -static void f_codec_configure_callback(int setting, intptr_t value) -{ - dsp_configure(ci->dsp, setting, value); +static void f_codec_configure_callback(int setting, intptr_t value) { + dsp_configure(ci->dsp, setting, value); #ifdef __TWS__ - if(setting == DSP_SET_FREQUENCY){ - if(codec_info.sample_freq != value) - codec_info.update_codec_info = 1; - codec_info.sample_freq = value; - } - else if(setting == DSP_SET_STEREO_MODE){ - if(codec_info.channel_num != (value == STEREO_MONO ? 1 : 2)) - codec_info.update_codec_info = 1; - codec_info.channel_num = value == STEREO_MONO ? 1 : 2; - } + if (setting == DSP_SET_FREQUENCY) { + if (codec_info.sample_freq != value) + codec_info.update_codec_info = 1; + codec_info.sample_freq = value; + } else if (setting == DSP_SET_STEREO_MODE) { + if (codec_info.channel_num != (value == STEREO_MONO ? 1 : 2)) + codec_info.update_codec_info = 1; + codec_info.channel_num = value == STEREO_MONO ? 1 : 2; + } #endif } -static enum codec_command_action f_codec_get_command_callback(intptr_t *param) -{ - if (rb_decode_halt_flag == 1) - return CODEC_ACTION_HALT ; +static enum codec_command_action f_codec_get_command_callback(intptr_t *param) { + if (rb_decode_halt_flag == 1) + return CODEC_ACTION_HALT; - return CODEC_ACTION_NULL; + return CODEC_ACTION_NULL; } -static bool f_codec_loop_track_callback(void) -{ - return false; +static bool f_codec_loop_track_callback(void) { return false; } + +static void init_ci_file(void) { + ci->codec_get_buffer = 0; + ci->pcmbuf_insert = f_codec_pcmbuf_insert_callback; + ci->set_elapsed = f_audio_codec_update_elapsed; + ci->read_filebuf = f_codec_filebuf_callback; + ci->request_buffer = f_codec_request_buffer_callback; + ci->advance_buffer = f_codec_advance_buffer_callback; + ci->seek_buffer = f_codec_seek_buffer_callback; + ci->seek_complete = f_codec_seek_complete_callback; + ci->set_offset = f_audio_codec_update_offset; + ci->configure = f_codec_configure_callback; + ci->get_command = f_codec_get_command_callback; + ci->loop_track = f_codec_loop_track_callback; } -static void init_ci_file(void) -{ - ci->codec_get_buffer = 0; - ci->pcmbuf_insert = f_codec_pcmbuf_insert_callback; - ci->set_elapsed = f_audio_codec_update_elapsed; - ci->read_filebuf = f_codec_filebuf_callback; - ci->request_buffer = f_codec_request_buffer_callback; - ci->advance_buffer = f_codec_advance_buffer_callback; - ci->seek_buffer = f_codec_seek_buffer_callback; - ci->seek_complete = f_codec_seek_complete_callback; - ci->set_offset = f_audio_codec_update_offset; - ci->configure = f_codec_configure_callback; - ci->get_command = f_codec_get_command_callback; - ci->loop_track = f_codec_loop_track_callback; -} +static void rb_play_init(void) { + init_dsp(); -static void rb_play_init(void) -{ - init_dsp(); - - init_ci_file(); + init_ci_file(); #ifndef __TWS__ - rb_pcmbuf_init(); + rb_pcmbuf_init(); #endif } -void rb_play_codec_init(void) -{ - RBTHREAD_MSG_BLOCK msg; - msg.evt = (uint32_t)RB_CTRL_CMD_CODEC_INIT; - msg.arg = (uint32_t)0; - rb_decode_mailbox_put(&msg); +void rb_play_codec_init(void) { + RBTHREAD_MSG_BLOCK msg; + msg.evt = (uint32_t)RB_CTRL_CMD_CODEC_INIT; + msg.arg = (uint32_t)0; + rb_decode_mailbox_put(&msg); } -void rb_play_codec_run(void) -{ - RBTHREAD_MSG_BLOCK msg; - msg.evt = (uint32_t)RB_CTRL_CMD_CODEC_RUN; - msg.arg = (uint32_t)0; - rb_decode_mailbox_put(&msg); +void rb_play_codec_run(void) { + RBTHREAD_MSG_BLOCK msg; + msg.evt = (uint32_t)RB_CTRL_CMD_CODEC_RUN; + msg.arg = (uint32_t)0; + rb_decode_mailbox_put(&msg); } -static int rb_codec_init_desc(void ) -{ - info("Init decode format: %d", song_format); +static int rb_codec_init_desc(void) { + info("Init decode format: %d", song_format); - switch (song_format) { - case AFMT_MPA_L1: - case AFMT_MPA_L2: - case AFMT_MPA_L3: - app_overlay_select(APP_OVERLAY_MPA); - mpa_codec_main(CODEC_LOAD); - break; - // TODO: add APP_OVERLAY_APE + switch (song_format) { + case AFMT_MPA_L1: + case AFMT_MPA_L2: + case AFMT_MPA_L3: + app_overlay_select(APP_OVERLAY_MPA); + mpa_codec_main(CODEC_LOAD); + break; + // TODO: add APP_OVERLAY_APE #if 0 case AFMT_APE: app_overlay_select(APP_OVERLAY_APE); @@ -353,26 +333,25 @@ static int rb_codec_init_desc(void ) wav_codec_main(CODEC_LOAD); break; #endif - default: - error("unkown codec type init\n"); - break; - } + default: + error("unkown codec type init\n"); + break; + } - return 0; + return 0; } -static int rb_codec_loop_on(void) -{ +static int rb_codec_loop_on(void) { #ifdef __TWS__ - //set start transfer to slave - tws_local_player_set_tran_2_slave_flag(1); + // set start transfer to slave + tws_local_player_set_tran_2_slave_flag(1); #endif - switch (song_format) { - case AFMT_MPA_L1: - case AFMT_MPA_L2: - case AFMT_MPA_L3: - mpa_codec_run(); - break; + switch (song_format) { + case AFMT_MPA_L1: + case AFMT_MPA_L2: + case AFMT_MPA_L3: + mpa_codec_run(); + break; #if 0 case AFMT_SBC: sbc_codec_run(); @@ -387,229 +366,210 @@ static int rb_codec_loop_on(void) ape_codec_run(); break; #endif - default: - error("unkown codec type run\n"); - break; - } - return 0; + default: + error("unkown codec type run\n"); + break; + } + return 0; } -static int rb_thread_process_evt(RB_CTRL_CMD_T evt) -{ - info("Decode event:%d", evt); +static int rb_thread_process_evt(RB_CTRL_CMD_T evt) { + info("Decode event:%d", evt); - switch(evt) { - case RB_CTRL_CMD_CODEC_INIT: - rb_decode_halt_flag = 0; + switch (evt) { + case RB_CTRL_CMD_CODEC_INIT: + rb_decode_halt_flag = 0; - rb_play_init(); + rb_play_init(); - /* get id3 */ - /* init ci info */ - ci->filesize = filesize(song_fd); - ci->id3 = current_id3; - ci->curpos = 0; + /* get id3 */ + /* init ci info */ + ci->filesize = filesize(song_fd); + ci->id3 = current_id3; + ci->curpos = 0; - dsp_configure(ci->dsp, DSP_RESET, 0); - dsp_configure(ci->dsp, DSP_FLUSH, 0); + dsp_configure(ci->dsp, DSP_RESET, 0); + dsp_configure(ci->dsp, DSP_FLUSH, 0); - rb_codec_init_desc(); - break; - case RB_CTRL_CMD_CODEC_RUN: - rbplay_loop_on = 1; + rb_codec_init_desc(); + break; + case RB_CTRL_CMD_CODEC_RUN: + rbplay_loop_on = 1; - info("Play start"); - app_sysfreq_req(APP_SYSFREQ_USER_APP_PLAYER, rb_player_get_work_freq()); - app_stop_10_second_timer(APP_POWEROFF_TIMER_ID); - rb_codec_loop_on(); + info("Play start"); + app_sysfreq_req(APP_SYSFREQ_USER_APP_PLAYER, rb_player_get_work_freq()); + app_stop_10_second_timer(APP_POWEROFF_TIMER_ID); + rb_codec_loop_on(); #if defined(__BTIF_AUTOPOWEROFF__) - app_start_10_second_timer(APP_POWEROFF_TIMER_ID); + app_start_10_second_timer(APP_POWEROFF_TIMER_ID); #endif - song_fd = 0; - rb_decode_halt_flag = 1; - if(thread_tid_waiter) { - rb_player_sync_close_done(); - } else { - rb_thread_send_status_change(); - rb_thread_send_switch(true); - } + song_fd = 0; + rb_decode_halt_flag = 1; + if (thread_tid_waiter) { + rb_player_sync_close_done(); + } else { + rb_thread_send_status_change(); + rb_thread_send_switch(true); + } #ifdef __TWS__ - //should update codec info after play one music - codec_info.update_codec_info = 1; + // should update codec info after play one music + codec_info.update_codec_info = 1; #endif - rbplay_loop_on = 0; - info("Play end"); - break; - default: - error("Unkown rb cmd %d\n",evt); - break; - } + rbplay_loop_on = 0; + info("Play end"); + break; + default: + error("Unkown rb cmd %d\n", evt); + break; + } - return 0; + return 0; } -int rb_decode_mailbox_put(RBTHREAD_MSG_BLOCK* msg_src) -{ - osStatus status; +int rb_decode_mailbox_put(RBTHREAD_MSG_BLOCK *msg_src) { + osStatus status; - RBTHREAD_MSG_BLOCK *msg_p = NULL; + RBTHREAD_MSG_BLOCK *msg_p = NULL; - msg_p = (RBTHREAD_MSG_BLOCK*)osMailAlloc(rb_decode_mailbox, 0); - if(!msg_p) { - TRACE(3,"%s fail, evt:%d,arg=%d \n",__func__,msg_src->evt,msg_src->arg); - return -1; - } - - msg_p->evt = msg_src->evt; - msg_p->arg = msg_src->arg; - - status = osMailPut(rb_decode_mailbox, msg_p); - - return (int)status; -} - -int rb_decode_mailbox_free(RBTHREAD_MSG_BLOCK* msg_p) -{ - osStatus status; - - status = osMailFree(rb_decode_mailbox, msg_p); - - return (int)status; -} - -int rb_decode_mailbox_get(RBTHREAD_MSG_BLOCK** msg_p) -{ - osEvent evt; - evt = osMailGet(rb_decode_mailbox, osWaitForever); - if (evt.status == osEventMail) { - *msg_p = (RBTHREAD_MSG_BLOCK *)evt.value.p; - return 0; - } + msg_p = (RBTHREAD_MSG_BLOCK *)osMailAlloc(rb_decode_mailbox, 0); + if (!msg_p) { + TRACE(3, "%s fail, evt:%d,arg=%d \n", __func__, msg_src->evt, msg_src->arg); return -1; + } + + msg_p->evt = msg_src->evt; + msg_p->arg = msg_src->arg; + + status = osMailPut(rb_decode_mailbox, msg_p); + + return (int)status; } -static void rb_decode_thread(void const *argument) -{ - RB_CTRL_CMD_T action; - RBTHREAD_MSG_BLOCK* msg_p; +int rb_decode_mailbox_free(RBTHREAD_MSG_BLOCK *msg_p) { + osStatus status; - while(1) { - app_sysfreq_req(APP_SYSFREQ_USER_APP_PLAYER, APP_SYSFREQ_32K); - // evt = osSignalWait(0, osWaitForever); - if(0 == rb_decode_mailbox_get(&msg_p)) { - app_sysfreq_req(APP_SYSFREQ_USER_APP_PLAYER, APP_SYSFREQ_104M); + status = osMailFree(rb_decode_mailbox, msg_p); - action = (RB_CTRL_CMD_T) msg_p->evt; - rb_caller_tid = (osThreadId) msg_p->arg ; - - TRACE(3,"[%s] action:%d ,tid,0x%x", __func__, action,rb_caller_tid); - rb_thread_process_evt(action); - - rb_decode_mailbox_free(msg_p); - if( rb_caller_tid) - osSignalSet(rb_decode_tid, 0x1203); - rb_caller_tid = NULL; - } - - } + return (int)status; } -int app_rbplay_open(void) -{ - if (rb_decode_tid != NULL) { - warn("Decode thread reopen"); - return -1; - } - - rb_decode_mailbox = osMailCreate(osMailQ(rb_decode_mailbox), NULL); - if (rb_decode_mailbox == NULL) { - error("Failed to Create rb_decode_mailbox"); - return -1; - } - - rb_decode_tid = osThreadCreate(osThread(rb_decode_thread), NULL); - if (rb_decode_tid == NULL) { - error("Failed to Create rb_thread \n"); - return -1; - } - +int rb_decode_mailbox_get(RBTHREAD_MSG_BLOCK **msg_p) { + osEvent evt; + evt = osMailGet(rb_decode_mailbox, osWaitForever); + if (evt.status == osEventMail) { + *msg_p = (RBTHREAD_MSG_BLOCK *)evt.value.p; return 0; + } + return -1; } -int rb_codec_running(void) -{ - return ((rb_decode_halt_flag == 0)?1:0); -} +static void rb_decode_thread(void const *argument) { + RB_CTRL_CMD_T action; + RBTHREAD_MSG_BLOCK *msg_p; -void rb_codec_set_halt(int halt) -{ - rb_decode_halt_flag = halt; -} + while (1) { + app_sysfreq_req(APP_SYSFREQ_USER_APP_PLAYER, APP_SYSFREQ_32K); + // evt = osSignalWait(0, osWaitForever); + if (0 == rb_decode_mailbox_get(&msg_p)) { + app_sysfreq_req(APP_SYSFREQ_USER_APP_PLAYER, APP_SYSFREQ_104M); -void rb_thread_set_decode_vars(int fd, int type ,void* id3) -{ - song_fd =fd; - song_format = type; - current_id3 = (struct mp3entry *)id3; -} + action = (RB_CTRL_CMD_T)msg_p->evt; + rb_caller_tid = (osThreadId)msg_p->arg; -void rb_player_sync_set_wait_thread(osThreadId tid) -{ - if(rbplay_loop_on) - thread_tid_waiter = tid; - else - thread_tid_waiter = NULL; -} + TRACE(3, "[%s] action:%d ,tid,0x%x", __func__, action, rb_caller_tid); + rb_thread_process_evt(action); -void rb_player_sync_wait_close(void ) -{ - while(NULL != thread_tid_waiter) { - osThreadYield(); + rb_decode_mailbox_free(msg_p); + if (rb_caller_tid) + osSignalSet(rb_decode_tid, 0x1203); + rb_caller_tid = NULL; } + } } -enum APP_SYSFREQ_FREQ_T rb_player_get_work_freq(void) -{ - enum APP_SYSFREQ_FREQ_T freq; +int app_rbplay_open(void) { + if (rb_decode_tid != NULL) { + warn("Decode thread reopen"); + return -1; + } - hal_sysfreq_print(); + rb_decode_mailbox = osMailCreate(osMailQ(rb_decode_mailbox), NULL); + if (rb_decode_mailbox == NULL) { + error("Failed to Create rb_decode_mailbox"); + return -1; + } - info("bitrate:%d freq:%d\n", ci->id3->bitrate, ci->id3->frequency); + rb_decode_tid = osThreadCreate(osThread(rb_decode_thread), NULL); + if (rb_decode_tid == NULL) { + error("Failed to Create rb_thread \n"); + return -1; + } + + return 0; +} + +int rb_codec_running(void) { return ((rb_decode_halt_flag == 0) ? 1 : 0); } + +void rb_codec_set_halt(int halt) { rb_decode_halt_flag = halt; } + +void rb_thread_set_decode_vars(int fd, int type, void *id3) { + song_fd = fd; + song_format = type; + current_id3 = (struct mp3entry *)id3; +} + +void rb_player_sync_set_wait_thread(osThreadId tid) { + if (rbplay_loop_on) + thread_tid_waiter = tid; + else + thread_tid_waiter = NULL; +} + +void rb_player_sync_wait_close(void) { + while (NULL != thread_tid_waiter) { + osThreadYield(); + } +} + +enum APP_SYSFREQ_FREQ_T rb_player_get_work_freq(void) { + enum APP_SYSFREQ_FREQ_T freq; + + hal_sysfreq_print(); + + info("bitrate:%d freq:%d\n", ci->id3->bitrate, ci->id3->frequency); #ifndef __TWS__ - enum AUD_SAMPRATE_T sample_rate = AUD_SAMPRATE_44100; - sample_rate =(enum AUD_SAMPRATE_T ) ci->id3->frequency; - if(sample_rate > AUD_SAMPRATE_48000) - freq = APP_SYSFREQ_208M; - else if (sample_rate > AUD_SAMPRATE_44100) - freq = APP_SYSFREQ_104M; - else - freq = APP_SYSFREQ_52M; - - if(ci->id3->bitrate > 192) - freq = APP_SYSFREQ_208M; - else if (ci->id3->bitrate > 128) - freq = APP_SYSFREQ_104M; - else - freq = APP_SYSFREQ_52M; - - switch( song_format ) { - case AFMT_APE: - freq = APP_SYSFREQ_208M; - break; - case AFMT_FLAC: - freq = APP_SYSFREQ_208M; - break; - case AFMT_PCM_WAV: - freq = APP_SYSFREQ_208M; - break; - default: - break; - } -#else + enum AUD_SAMPRATE_T sample_rate = AUD_SAMPRATE_44100; + sample_rate = (enum AUD_SAMPRATE_T)ci->id3->frequency; + if (sample_rate > AUD_SAMPRATE_48000) freq = APP_SYSFREQ_208M; + else if (sample_rate > AUD_SAMPRATE_44100) + freq = APP_SYSFREQ_104M; + else + freq = APP_SYSFREQ_52M; + + if (ci->id3->bitrate > 192) + freq = APP_SYSFREQ_208M; + else if (ci->id3->bitrate > 128) + freq = APP_SYSFREQ_104M; + else + freq = APP_SYSFREQ_52M; + + switch (song_format) { + case AFMT_APE: + freq = APP_SYSFREQ_208M; + break; + case AFMT_FLAC: + freq = APP_SYSFREQ_208M; + break; + case AFMT_PCM_WAV: + freq = APP_SYSFREQ_208M; + break; + default: + break; + } +#else + freq = APP_SYSFREQ_208M; #endif - info("Decode thread run at: %d", freq); - return freq; + info("Decode thread run at: %d", freq); + return freq; } - - diff --git a/apps/audioplayers/rbplay/rbplaysd.cpp b/apps/audioplayers/rbplay/rbplaysd.cpp index 68281dc..443cce8 100644 --- a/apps/audioplayers/rbplay/rbplaysd.cpp +++ b/apps/audioplayers/rbplay/rbplaysd.cpp @@ -16,18 +16,18 @@ /* rbplay source */ /* playback control & rockbox codec porting & codec thread */ -#include +#include +#include #include #include -#include #include -#include -#include +#include +#include #include +#include "SDFileSystem.h" #include "hal_trace.h" #include "metadata.h" -#include "SDFileSystem.h" #include "rbplaysd.h" #include "utils.h" @@ -41,185 +41,182 @@ static playlist_item sd_curritem; playlist_struct sd_playlist; -static void playlist_insert(playlist_item* item) -{ - int fd; - fd = open(PLAYLIST_PATH, O_RDWR | O_CREAT); - if (fd <= 0) { - error("Playlist open fail"); - return; - } +static void playlist_insert(playlist_item *item) { + int fd; + fd = open(PLAYLIST_PATH, O_RDWR | O_CREAT); + if (fd <= 0) { + error("Playlist open fail"); + return; + } - lseek(fd, item->song_idx * sizeof(playlist_item), SEEK_SET); - write(fd, item, sizeof(playlist_item)); - close(fd); + lseek(fd, item->song_idx * sizeof(playlist_item), SEEK_SET); + write(fd, item, sizeof(playlist_item)); + close(fd); } -static bool sdcard_mount(void) -{ - if (sdfs) { - info("SD card already mount"); - return true; - } - - sdfs = new SDFileSystem(SD_LABEL); - if (sdfs == NULL) { - error("No memory for sd file system"); - return false; - } - - DIR *d; - d = opendir("/" SD_LABEL); - - if (!d) { - warn("SD card mount error"); - return false; - } - - closedir(d); +static bool sdcard_mount(void) { + if (sdfs) { + info("SD card already mount"); return true; + } + + sdfs = new SDFileSystem(SD_LABEL); + if (sdfs == NULL) { + error("No memory for sd file system"); + return false; + } + + DIR *d; + d = opendir("/" SD_LABEL); + + if (!d) { + warn("SD card mount error"); + return false; + } + + closedir(d); + return true; } -static void app_rbplay_gen_playlist(playlist_struct *list) -{ - struct dirent *p; - DIR *d; - uint32_t total; - int fd = 0; - struct mp3entry current_id3; - playlist_item* sd_curritem_p = &sd_curritem; +static void app_rbplay_gen_playlist(playlist_struct *list) { + struct dirent *p; + DIR *d; + uint32_t total; + int fd = 0; + struct mp3entry current_id3; + playlist_item *sd_curritem_p = &sd_curritem; - memset(list,0x0,sizeof(playlist_struct)); + memset(list, 0x0, sizeof(playlist_struct)); - d = opendir("/" SD_LABEL); - if (!d) { - error("SD card open fail"); - return; + d = opendir("/" SD_LABEL); + if (!d) { + error("SD card open fail"); + return; + } + + info("---------gen audio list---------"); + + total = 0; + while (p = readdir(d)) { + if (probe_file_format(p->d_name) == AFMT_UNKNOWN) + continue; + + memset(&sd_curritem, 0x0, sizeof(playlist_item)); + sd_curritem.song_idx = total; + + sprintf(sd_curritem.file_path, "/" SD_LABEL "/%s", p->d_name); + sprintf(sd_curritem.file_name, "%s", p->d_name); + + info("Adding music: %s", sd_curritem.file_path); + + fd = open(sd_curritem.file_path, O_RDONLY); + + if (fd <= 0) { + error("File %s open error", p->d_name); + break; } - info("---------gen audio list---------"); + get_metadata(¤t_id3, fd, sd_curritem.file_path); + close(fd); - total = 0; - while (p = readdir(d)) { - if (probe_file_format(p->d_name) == AFMT_UNKNOWN) - continue; + if (current_id3.bitrate == 0 || current_id3.filesize == 0 || + current_id3.length == 0) + break; - memset(&sd_curritem,0x0,sizeof(playlist_item)); - sd_curritem.song_idx = total; + info("bits:%d, type:%d, freq:%d", current_id3.bitrate, + current_id3.codectype, current_id3.frequency); - sprintf(sd_curritem.file_path, "/" SD_LABEL "/%s", p->d_name); - sprintf(sd_curritem.file_name, "%s", p->d_name); - - info("Adding music: %s", sd_curritem.file_path); - - fd = open(sd_curritem.file_path, O_RDONLY); - - if (fd <= 0) { - error("File %s open error", p->d_name); - break; - } - - get_metadata(¤t_id3, fd, sd_curritem.file_path); - close(fd); - - if(current_id3.bitrate == 0 || current_id3.filesize == 0 || current_id3.length == 0) - break; - - info("bits:%d, type:%d, freq:%d", current_id3.bitrate, - current_id3.codectype, current_id3.frequency); - - sd_curritem_p->bitrate = current_id3.bitrate; - sd_curritem_p->codectype = current_id3.codectype; - sd_curritem_p->filesize = current_id3.filesize; - sd_curritem_p->length = current_id3.length; - sd_curritem_p->frequency = current_id3.frequency; + sd_curritem_p->bitrate = current_id3.bitrate; + sd_curritem_p->codectype = current_id3.codectype; + sd_curritem_p->filesize = current_id3.filesize; + sd_curritem_p->length = current_id3.length; + sd_curritem_p->frequency = current_id3.frequency; #ifdef PARSER_DETAIL - char *str; - str = current_id3.title; - if(str != NULL) { - memset(sd_curritem_p->title,0x0,MP3_TITLE_LEN); - memcpy(sd_curritem_p->title ,str,strlen(str)>MP3_TITLE_LEN?MP3_TITLE_LEN:strlen(str)); - } + char *str; + str = current_id3.title; + if (str != NULL) { + memset(sd_curritem_p->title, 0x0, MP3_TITLE_LEN); + memcpy(sd_curritem_p->title, str, + strlen(str) > MP3_TITLE_LEN ? MP3_TITLE_LEN : strlen(str)); + } - str = current_id3.artist; - if(str != NULL) { - memset(sd_curritem_p->artist,0x0,MP3_ARTIST_LEN); - memcpy(sd_curritem_p->artist ,str,strlen(str)>MP3_ARTIST_LEN?MP3_ARTIST_LEN:strlen(str)); - } + str = current_id3.artist; + if (str != NULL) { + memset(sd_curritem_p->artist, 0x0, MP3_ARTIST_LEN); + memcpy(sd_curritem_p->artist, str, + strlen(str) > MP3_ARTIST_LEN ? MP3_ARTIST_LEN : strlen(str)); + } - str = current_id3.album; - if(str != NULL) { - memset(sd_curritem_p->album,0x0,MP3_ALBUM_LEN); - memcpy(sd_curritem_p->album ,str,strlen(str)>MP3_ALBUM_LEN?MP3_ALBUM_LEN:strlen(str)); - } + str = current_id3.album; + if (str != NULL) { + memset(sd_curritem_p->album, 0x0, MP3_ALBUM_LEN); + memcpy(sd_curritem_p->album, str, + strlen(str) > MP3_ALBUM_LEN ? MP3_ALBUM_LEN : strlen(str)); + } - str = current_id3.genre_string; - if(str != NULL) { - memset(sd_curritem_p->genre,0x0,MP3_GENRE_LEN); - memcpy(sd_curritem_p->genre ,str,strlen(str)>MP3_GENRE_LEN?MP3_GENRE_LEN:strlen(str)); - } + str = current_id3.genre_string; + if (str != NULL) { + memset(sd_curritem_p->genre, 0x0, MP3_GENRE_LEN); + memcpy(sd_curritem_p->genre, str, + strlen(str) > MP3_GENRE_LEN ? MP3_GENRE_LEN : strlen(str)); + } - str = current_id3.composer; - if(str != NULL) { - memset(sd_curritem_p->composer,0x0,MP3_COMPOSER_LEN); - memcpy(sd_curritem_p->composer ,str,strlen(str)>MP3_COMPOSER_LEN?MP3_COMPOSER_LEN:strlen(str)); - } + str = current_id3.composer; + if (str != NULL) { + memset(sd_curritem_p->composer, 0x0, MP3_COMPOSER_LEN); + memcpy(sd_curritem_p->composer, str, + strlen(str) > MP3_COMPOSER_LEN ? MP3_COMPOSER_LEN : strlen(str)); + } #endif - playlist_insert(sd_curritem_p); - total++; - } + playlist_insert(sd_curritem_p); + total++; + } - list->total_songs = total ; - list->current_item = sd_curritem_p; - - closedir(d); - info("---------%d audio file searched---------" , total); + list->total_songs = total; + list->current_item = sd_curritem_p; + closedir(d); + info("---------%d audio file searched---------", total); } -void app_rbplay_load_playlist(playlist_struct *list) -{ - if(sdcard_mount() == false) - return; +void app_rbplay_load_playlist(playlist_struct *list) { + if (sdcard_mount() == false) + return; - remove(PLAYLIST_PATH); + remove(PLAYLIST_PATH); - app_rbplay_gen_playlist(list); + app_rbplay_gen_playlist(list); } -playlist_item *app_rbplay_get_playitem(const int idx) -{ - int fd; - if(idx >= sd_playlist.total_songs) { - warn("Index exceed: %d / %d", idx, sd_playlist.total_songs); - return NULL; - } +playlist_item *app_rbplay_get_playitem(const int idx) { + int fd; + if (idx >= sd_playlist.total_songs) { + warn("Index exceed: %d / %d", idx, sd_playlist.total_songs); + return NULL; + } - fd = open(PLAYLIST_PATH, O_RDONLY); + fd = open(PLAYLIST_PATH, O_RDONLY); - if (fd <= 0) { - warn("SD card playlist can not open"); - return NULL; - } + if (fd <= 0) { + warn("SD card playlist can not open"); + return NULL; + } - lseek(fd, sizeof(playlist_item) * idx, SEEK_SET); - read(fd, sd_playlist.current_item, sizeof(playlist_item)); - info("Get playitem: %d: %s", idx, sd_playlist.current_item->file_path); + lseek(fd, sizeof(playlist_item) * idx, SEEK_SET); + read(fd, sd_playlist.current_item, sizeof(playlist_item)); + info("Get playitem: %d: %s", idx, sd_playlist.current_item->file_path); - close(fd); + close(fd); - return sd_playlist.current_item; + return sd_playlist.current_item; } -int app_ctl_remove_file(const int idx) -{ - playlist_item *item = app_rbplay_get_playitem(idx); - if (!item) - return -1; - remove(item->file_path); +int app_ctl_remove_file(const int idx) { + playlist_item *item = app_rbplay_get_playitem(idx); + if (!item) + return -1; + remove(item->file_path); - return 0; + return 0; } - - diff --git a/apps/audioplayers/voice_test.c b/apps/audioplayers/voice_test.c index ba47baf..7f98e04 100644 --- a/apps/audioplayers/voice_test.c +++ b/apps/audioplayers/voice_test.c @@ -13,39 +13,37 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "cmsis_os.h" #include "app_utils.h" +#include "audio_dump.h" #include "audioflinger.h" +#include "cmsis_os.h" #include "hal_timer.h" #include "hal_trace.h" #include "string.h" -#include "audio_dump.h" // #include "local_wav.h" -#define CHANNEL_NUM (2) +#define CHANNEL_NUM (2) -#define CHAR_BYTES (1) -#define SHORT_BYTES (2) -#define INT_BYTES (4) +#define CHAR_BYTES (1) +#define SHORT_BYTES (2) +#define INT_BYTES (4) -#define SAMPLE_BITS (16) -#define SAMPLE_BYTES (SAMPLE_BITS / 8) +#define SAMPLE_BITS (16) +#define SAMPLE_BYTES (SAMPLE_BITS / 8) +#define TX_SAMPLE_RATE (16000) +#define RX_SAMPLE_RATE (16000) -#define TX_SAMPLE_RATE (16000) -#define RX_SAMPLE_RATE (16000) +#define TX_FRAME_LEN (256) +#define RX_FRAME_LEN (256) - -#define TX_FRAME_LEN (256) -#define RX_FRAME_LEN (256) - -#define TX_BUF_SIZE (TX_FRAME_LEN * CHANNEL_NUM * SAMPLE_BYTES * 2) -#define RX_BUF_SIZE (RX_FRAME_LEN * CHANNEL_NUM * SAMPLE_BYTES * 2) +#define TX_BUF_SIZE (TX_FRAME_LEN * CHANNEL_NUM * SAMPLE_BYTES * 2) +#define RX_BUF_SIZE (RX_FRAME_LEN * CHANNEL_NUM * SAMPLE_BYTES * 2) #if SAMPLE_BYTES == SHORT_BYTES -typedef short VOICE_PCM_T; +typedef short VOICE_PCM_T; #elif SAMPLE_BYTES == INT_BYTES -typedef int VOICE_PCM_T; +typedef int VOICE_PCM_T; #else #error "Invalid SAMPLE_BYTES!!!" #endif @@ -56,130 +54,127 @@ static uint8_t POSSIBLY_UNUSED codec_playback_buf[RX_BUF_SIZE]; static uint32_t POSSIBLY_UNUSED codec_capture_cnt = 0; static uint32_t POSSIBLY_UNUSED codec_playback_cnt = 0; -#define CODEC_STREAM_ID AUD_STREAM_ID_0 +#define CODEC_STREAM_ID AUD_STREAM_ID_0 -static uint32_t codec_capture_callback(uint8_t *buf, uint32_t len) -{ - int POSSIBLY_UNUSED pcm_len = len / sizeof(VOICE_PCM_T) / CHANNEL_NUM; - VOICE_PCM_T POSSIBLY_UNUSED *pcm_buf[CHANNEL_NUM]; - int interval_len = len * 2 / CHANNEL_NUM; +static uint32_t codec_capture_callback(uint8_t *buf, uint32_t len) { + int POSSIBLY_UNUSED pcm_len = len / sizeof(VOICE_PCM_T) / CHANNEL_NUM; + VOICE_PCM_T POSSIBLY_UNUSED *pcm_buf[CHANNEL_NUM]; + int interval_len = len * 2 / CHANNEL_NUM; - for (int i=0; i -#include -#include -#include -#include -#include "cmsis_os.h" -#include "plat_types.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "hal_trace.h" -#include "cqueue.h" #include "app_audio.h" #include "app_overlay.h" #include "app_ring_merge.h" -#include "tgt_hardware.h" -#include "bt_sco_chain.h" -#include "iir_resample.h" -#include "hfp_api.h" #include "audio_prompt_sbc.h" +#include "bt_sco_chain.h" +#include "cmsis_os.h" +#include "cqueue.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "hfp_api.h" +#include "iir_resample.h" +#include "plat_types.h" +#include "tgt_hardware.h" +#include +#include +#include +#include +#include #ifdef TX_RX_PCM_MASK #include "bt_drv_interface.h" #endif @@ -44,8 +44,8 @@ // BT #include "a2dp_api.h" #ifdef TX_RX_PCM_MASK -#include "hal_chipid.h" #include "bt_drv_interface.h" +#include "hal_chipid.h" #endif @@ -74,7 +74,8 @@ extern int32_t *aec_echo_buf; extern short *aec_echo_buf; #endif -#if defined( SPEECH_TX_AEC ) || defined( SPEECH_TX_AEC2 ) || defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) +#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || \ + defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) #if defined(__AUDIO_RESAMPLE__) && defined(SW_SCO_RESAMPLE) static uint8_t *echo_buf_queue; static uint16_t echo_buf_q_size; @@ -83,7 +84,7 @@ static uint16_t echo_buf_q_rpos; static bool echo_buf_q_full; #endif #endif -static void *speech_plc; +static void *speech_plc; } //#define PENDING_MSBC_DECODER_ALG @@ -96,7 +97,7 @@ int16_t *audio_dump_temp_buf = NULL; #endif // app_bt_stream.cpp::bt_sco_player(), used buffer size -#define APP_BT_STREAM_USE_BUF_SIZE (1024*2) +#define APP_BT_STREAM_USE_BUF_SIZE (1024 * 2) #if defined(SCO_OPTIMIZE_FOR_RAM) uint8_t *sco_overlay_ram_buf = NULL; int sco_overlay_ram_buf_len = 0; @@ -110,17 +111,21 @@ static int16_t *downsample_buf_for_msbc = NULL; static IirResampleState *upsample_st = NULL; static IirResampleState *downsample_st = NULL; -#define VOICEBTPCM_TRACE(s,...) -//TRACE(s, ##__VA_ARGS__) +#define VOICEBTPCM_TRACE(s, ...) +// TRACE(s, ##__VA_ARGS__) /* voicebtpcm_pcm queue */ #define FRAME_NUM (4) -#define VOICEBTPCM_PCM_16k_FRAME_LENGTH (SPEECH_FRAME_MS_TO_LEN(16000, SPEECH_SCO_FRAME_MS)) -#define VOICEBTPCM_PCM_16K_QUEUE_SIZE (VOICEBTPCM_PCM_16k_FRAME_LENGTH*FRAME_NUM) +#define VOICEBTPCM_PCM_16k_FRAME_LENGTH \ + (SPEECH_FRAME_MS_TO_LEN(16000, SPEECH_SCO_FRAME_MS)) +#define VOICEBTPCM_PCM_16K_QUEUE_SIZE \ + (VOICEBTPCM_PCM_16k_FRAME_LENGTH * FRAME_NUM) -#define VOICEBTPCM_PCM_8k_FRAME_LENGTH (SPEECH_FRAME_MS_TO_LEN(8000, SPEECH_SCO_FRAME_MS)) -#define VOICEBTPCM_PCM_8K_QUEUE_SIZE (VOICEBTPCM_PCM_8k_FRAME_LENGTH*FRAME_NUM) +#define VOICEBTPCM_PCM_8k_FRAME_LENGTH \ + (SPEECH_FRAME_MS_TO_LEN(8000, SPEECH_SCO_FRAME_MS)) +#define VOICEBTPCM_PCM_8K_QUEUE_SIZE \ + (VOICEBTPCM_PCM_8k_FRAME_LENGTH * FRAME_NUM) // #endif CQueue voicebtpcm_p2m_pcm_queue; @@ -141,11 +146,13 @@ extern bool bt_sco_codec_is_msbc(void); #define MSBC_FRAME_SIZE (60) #if defined(HFP_1_6_ENABLE) static btif_sbc_decoder_t msbc_decoder; -#if FPGA==1 +#if FPGA == 1 #define CFG_HW_AUD_EQ_NUM_BANDS (8) -const int8_t cfg_hw_aud_eq_band_settings[CFG_HW_AUD_EQ_NUM_BANDS] = {0, 0, 0, 0, 0, 0, 0, 0}; +const int8_t cfg_hw_aud_eq_band_settings[CFG_HW_AUD_EQ_NUM_BANDS] = { + 0, 0, 0, 0, 0, 0, 0, 0}; #endif -static float msbc_eq_band_gain[CFG_HW_AUD_EQ_NUM_BANDS]= {0,0,0,0,0,0,0,0}; +static float msbc_eq_band_gain[CFG_HW_AUD_EQ_NUM_BANDS] = {0, 0, 0, 0, + 0, 0, 0, 0}; #define MSBC_ENCODE_PCM_LEN (240) @@ -166,8 +173,8 @@ static uint8_t enc_tmp_buf[MSBC_FRAME_SIZE - 3]; static uint8_t dec_tmp_buf[MSBC_ENCODE_PCM_LEN]; #endif -//static sbc_encoder_t sbc_Encoder1; -//static btif_sbc_pcm_data_t PcmEncData1; +// static sbc_encoder_t sbc_Encoder1; +// static btif_sbc_pcm_data_t PcmEncData1; static btif_sbc_encoder_t *msbc_encoder; static btif_sbc_pcm_data_t msbc_encoder_pcmdata; static unsigned char msbc_counter = 0x08; @@ -176,151 +183,139 @@ static unsigned char msbc_counter = 0x08; int decode_msbc_frame(unsigned char *pcm_buffer, unsigned int pcm_len); int decode_cvsd_frame(unsigned char *pcm_buffer, unsigned int pcm_len); -//playback flow -//bt-->store_voicebtpcm_m2p_buffer-->decode_voicebtpcm_m2p_frame-->audioflinger playback-->speaker -//used by playback, store data from bt to memory -int store_voicebtpcm_m2p_buffer(unsigned char *buf, unsigned int len) -{ - //TRACE(2,"[%s]: %d", __FUNCTION__, FAST_TICKS_TO_US(hal_fast_sys_timer_get())); - int size; +// playback flow +// bt-->store_voicebtpcm_m2p_buffer-->decode_voicebtpcm_m2p_frame-->audioflinger +// playback-->speaker used by playback, store data from bt to memory +int store_voicebtpcm_m2p_buffer(unsigned char *buf, unsigned int len) { + // TRACE(2,"[%s]: %d", __FUNCTION__, + // FAST_TICKS_TO_US(hal_fast_sys_timer_get())); + int size; #if defined(HFP_1_6_ENABLE) - if (bt_sco_codec_is_msbc()) - { - decode_msbc_frame(buf, len); - } - else + if (bt_sco_codec_is_msbc()) { + decode_msbc_frame(buf, len); + } else #endif - { + { #if defined(CVSD_BYPASS) - decode_cvsd_frame(buf, len); + decode_cvsd_frame(buf, len); #endif - if(speech_plc){ - speech_plc_8000((PlcSt_8000 *)speech_plc, (short *)buf, len); - } - LOCK_APP_AUDIO_QUEUE(); - APP_AUDIO_EnCQueue(&voicebtpcm_m2p_pcm_queue, (unsigned char *)buf, len); - UNLOCK_APP_AUDIO_QUEUE(); + if (speech_plc) { + speech_plc_8000((PlcSt_8000 *)speech_plc, (short *)buf, len); } + LOCK_APP_AUDIO_QUEUE(); + APP_AUDIO_EnCQueue(&voicebtpcm_m2p_pcm_queue, (unsigned char *)buf, len); + UNLOCK_APP_AUDIO_QUEUE(); + } - size = APP_AUDIO_LengthOfCQueue(&voicebtpcm_m2p_pcm_queue); + size = APP_AUDIO_LengthOfCQueue(&voicebtpcm_m2p_pcm_queue); - if (size >= voicebtpcm_m2p_cache_threshold) - { - voicebtpcm_cache_m2p_status = APP_AUDIO_CACHE_OK; - } + if (size >= voicebtpcm_m2p_cache_threshold) { + voicebtpcm_cache_m2p_status = APP_AUDIO_CACHE_OK; + } - //TRACE(2,"m2p :%d/%d", len, size); + // TRACE(2,"m2p :%d/%d", len, size); - return 0; + return 0; } - #if defined(CVSD_BYPASS) #define VOICECVSD_TEMP_BUFFER_SIZE 120 #define VOICECVSD_ENC_SIZE 60 -static short cvsd_decode_buff[VOICECVSD_TEMP_BUFFER_SIZE*2]; +static short cvsd_decode_buff[VOICECVSD_TEMP_BUFFER_SIZE * 2]; -int decode_cvsd_frame(unsigned char *pcm_buffer, unsigned int pcm_len) -{ - uint32_t r = 0, decode_len = 0; - unsigned char *e1 = NULL, *e2 = NULL; - unsigned int len1 = 0, len2 = 0; +int decode_cvsd_frame(unsigned char *pcm_buffer, unsigned int pcm_len) { + uint32_t r = 0, decode_len = 0; + unsigned char *e1 = NULL, *e2 = NULL; + unsigned int len1 = 0, len2 = 0; - while (decode_len < pcm_len) - { - LOCK_APP_AUDIO_QUEUE(); - len1 = len2 = 0; - e1 = e2 = 0; - r = APP_AUDIO_PeekCQueue(&voicebtpcm_m2p_pcm_queue, VOICECVSD_TEMP_BUFFER_SIZE, &e1, &len1, &e2, &len2); - UNLOCK_APP_AUDIO_QUEUE(); + while (decode_len < pcm_len) { + LOCK_APP_AUDIO_QUEUE(); + len1 = len2 = 0; + e1 = e2 = 0; + r = APP_AUDIO_PeekCQueue(&voicebtpcm_m2p_pcm_queue, + VOICECVSD_TEMP_BUFFER_SIZE, &e1, &len1, &e2, + &len2); + UNLOCK_APP_AUDIO_QUEUE(); - if (r == CQ_ERR) - { - memset(pcm_buffer, 0, pcm_len); - TRACE(0,"cvsd spk buff underflow"); - return 0; - } - - if (len1 != 0) - { - CvsdToPcm8k(e1, (short *)(cvsd_decode_buff), len1, 0); - - LOCK_APP_AUDIO_QUEUE(); - DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, len1); - UNLOCK_APP_AUDIO_QUEUE(); - - decode_len += len1*2; - } - - if (len2 != 0) - { - CvsdToPcm8k(e2, (short *)(cvsd_decode_buff), len2, 0); - - LOCK_APP_AUDIO_QUEUE(); - DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, len2); - UNLOCK_APP_AUDIO_QUEUE(); - - decode_len += len2*2; - } + if (r == CQ_ERR) { + memset(pcm_buffer, 0, pcm_len); + TRACE(0, "cvsd spk buff underflow"); + return 0; } - memcpy(pcm_buffer, cvsd_decode_buff, decode_len); + if (len1 != 0) { + CvsdToPcm8k(e1, (short *)(cvsd_decode_buff), len1, 0); - return decode_len; + LOCK_APP_AUDIO_QUEUE(); + DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, len1); + UNLOCK_APP_AUDIO_QUEUE(); + + decode_len += len1 * 2; + } + + if (len2 != 0) { + CvsdToPcm8k(e2, (short *)(cvsd_decode_buff), len2, 0); + + LOCK_APP_AUDIO_QUEUE(); + DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, len2); + UNLOCK_APP_AUDIO_QUEUE(); + + decode_len += len2 * 2; + } + } + + memcpy(pcm_buffer, cvsd_decode_buff, decode_len); + + return decode_len; } -int encode_cvsd_frame(unsigned char *pcm_buffer, unsigned int pcm_len) -{ - uint32_t r = 0; - unsigned char *e1 = NULL, *e2 = NULL; - unsigned int len1 = 0, len2 = 0; - uint32_t processed_len = 0; - uint32_t remain_len = 0, enc_len = 0; +int encode_cvsd_frame(unsigned char *pcm_buffer, unsigned int pcm_len) { + uint32_t r = 0; + unsigned char *e1 = NULL, *e2 = NULL; + unsigned int len1 = 0, len2 = 0; + uint32_t processed_len = 0; + uint32_t remain_len = 0, enc_len = 0; - while (processed_len < pcm_len) - { - remain_len = pcm_len-processed_len; + while (processed_len < pcm_len) { + remain_len = pcm_len - processed_len; - if (remain_len>=(VOICECVSD_ENC_SIZE*2)) - { - enc_len = VOICECVSD_ENC_SIZE*2; - } - else - { - enc_len = remain_len; - } - - LOCK_APP_AUDIO_QUEUE(); - len1 = len2 = 0; - e1 = e2 = 0; - r = APP_AUDIO_PeekCQueue(&voicebtpcm_p2m_pcm_queue, enc_len, &e1, &len1, &e2, &len2); - UNLOCK_APP_AUDIO_QUEUE(); - - if (r == CQ_ERR) - { - memset(pcm_buffer, 0x55, pcm_len); - TRACE(0,"cvsd spk buff underflow"); - return 0; - } - - if (e1) - { - Pcm8kToCvsd((short *)e1, (unsigned char *)(pcm_buffer + processed_len), len1/2); - LOCK_APP_AUDIO_QUEUE(); - DeCQueue(&voicebtpcm_p2m_pcm_queue, NULL, len1); - UNLOCK_APP_AUDIO_QUEUE(); - processed_len += len1; - } - if (e2) - { - Pcm8kToCvsd((short *)e2, (unsigned char *)(pcm_buffer + processed_len), len2/2); - LOCK_APP_AUDIO_QUEUE(); - DeCQueue(&voicebtpcm_p2m_pcm_queue, NULL, len2); - UNLOCK_APP_AUDIO_QUEUE(); - processed_len += len2; - } + if (remain_len >= (VOICECVSD_ENC_SIZE * 2)) { + enc_len = VOICECVSD_ENC_SIZE * 2; + } else { + enc_len = remain_len; } + LOCK_APP_AUDIO_QUEUE(); + len1 = len2 = 0; + e1 = e2 = 0; + r = APP_AUDIO_PeekCQueue(&voicebtpcm_p2m_pcm_queue, enc_len, &e1, &len1, + &e2, &len2); + UNLOCK_APP_AUDIO_QUEUE(); + + if (r == CQ_ERR) { + memset(pcm_buffer, 0x55, pcm_len); + TRACE(0, "cvsd spk buff underflow"); + return 0; + } + + if (e1) { + Pcm8kToCvsd((short *)e1, (unsigned char *)(pcm_buffer + processed_len), + len1 / 2); + LOCK_APP_AUDIO_QUEUE(); + DeCQueue(&voicebtpcm_p2m_pcm_queue, NULL, len1); + UNLOCK_APP_AUDIO_QUEUE(); + processed_len += len1; + } + if (e2) { + Pcm8kToCvsd((short *)e2, (unsigned char *)(pcm_buffer + processed_len), + len2 / 2); + LOCK_APP_AUDIO_QUEUE(); + DeCQueue(&voicebtpcm_p2m_pcm_queue, NULL, len2); + UNLOCK_APP_AUDIO_QUEUE(); + processed_len += len2; + } + } + #if 0 for (int cc = 0; cc < 32; ++cc) { @@ -328,43 +323,43 @@ int encode_cvsd_frame(unsigned char *pcm_buffer, unsigned int pcm_len) } #endif - TRACE(3,"%s: processed_len %d, pcm_len %d", __func__, processed_len, pcm_len); + TRACE(3, "%s: processed_len %d, pcm_len %d", __func__, processed_len, + pcm_len); - return processed_len; + return processed_len; } #endif #if defined(HFP_1_6_ENABLE) -inline int sco_parse_synchronization_header(uint8_t *buf, uint8_t *sn) -{ - uint8_t sn1, sn2; - *sn = 0xff; - if ((buf[0] != 0x01) || - ((buf[1]&0x0f) != 0x08) || - (buf[2] != 0xad)){ - return -1; - } +inline int sco_parse_synchronization_header(uint8_t *buf, uint8_t *sn) { + uint8_t sn1, sn2; + *sn = 0xff; + if ((buf[0] != 0x01) || ((buf[1] & 0x0f) != 0x08) || (buf[2] != 0xad)) { + return -1; + } - sn1 = (buf[1]&0x30)>>4; - sn2 = (buf[1]&0xc0)>>6; - if ((sn1 != 0) && (sn1 != 0x3)){ - return -2; - } - if ((sn2 != 0) && (sn2 != 0x3)){ - return -3; - } + sn1 = (buf[1] & 0x30) >> 4; + sn2 = (buf[1] & 0xc0) >> 6; + if ((sn1 != 0) && (sn1 != 0x3)) { + return -2; + } + if ((sn2 != 0) && (sn2 != 0x3)) { + return -3; + } - *sn = (sn1&0x01)|(sn2&0x02); + *sn = (sn1 & 0x01) | (sn2 & 0x02); - return 0; + return 0; } #if 1 -#define MSBC_LEN_FORMBT_PER_FRAME (120) //Bytes; only for BES platform. +#define MSBC_LEN_FORMBT_PER_FRAME (120) // Bytes; only for BES platform. #define SAMPLES_LEN_PER_FRAME (120) -#define MSBC_LEN_PER_FRAME (57+3) +#define MSBC_LEN_PER_FRAME (57 + 3) -#if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) || defined(CHIP_BEST2001) +#if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) || \ + defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) || \ + defined(CHIP_BEST2001) #define MSBC_MUTE_PATTERN (0x5555) #else #define MSBC_MUTE_PATTERN (0x0000) @@ -373,376 +368,371 @@ inline int sco_parse_synchronization_header(uint8_t *buf, uint8_t *sn) #if !defined(PENDING_MSBC_DECODER_ALG) short DecPcmBuf[SAMPLES_LEN_PER_FRAME]; unsigned char DecMsbcBuf[MSBC_LEN_PER_FRAME]; -unsigned short DecMsbcBufAll[MSBC_LEN_FORMBT_PER_FRAME*5]; +unsigned short DecMsbcBufAll[MSBC_LEN_FORMBT_PER_FRAME * 5]; unsigned int next_frame_flag = 0; static int msbc_find_first_sync = 0; static unsigned int msbc_offset = 0; static PacketLossState pld; -int decode_msbc_frame(unsigned char *msbc_btpcm_buffer, unsigned int msbc_len) -{ +int decode_msbc_frame(unsigned char *msbc_btpcm_buffer, unsigned int msbc_len) { - btif_sbc_pcm_data_t pcm_data; - unsigned int msbc_offset_lowdelay = 0; - unsigned int i,j; - unsigned short *msbc_buffer=(unsigned short *)msbc_btpcm_buffer; - int frame_flag[6]; // 1: good frame; 0:bad frame; - bt_status_t ret; - unsigned int frame_counter=0; - unsigned short byte_decode = 0; - unsigned int msbc_offset_total = 0; - int msbc_offset_drift[6] = {0, }; + btif_sbc_pcm_data_t pcm_data; + unsigned int msbc_offset_lowdelay = 0; + unsigned int i, j; + unsigned short *msbc_buffer = (unsigned short *)msbc_btpcm_buffer; + int frame_flag[6]; // 1: good frame; 0:bad frame; + bt_status_t ret; + unsigned int frame_counter = 0; + unsigned short byte_decode = 0; + unsigned int msbc_offset_total = 0; + int msbc_offset_drift[6] = { + 0, + }; - //unsigned int timer_begin=hal_sys_timer_get(); + // unsigned int timer_begin=hal_sys_timer_get(); - //TRACE(1,"decode_msbc_frame,msbc_len:%d",msbc_len); + // TRACE(1,"decode_msbc_frame,msbc_len:%d",msbc_len); #ifdef TX_RX_PCM_MASK - if(btdrv_is_pcm_mask_enable() ==1) - { - memcpy((uint8_t *)DecMsbcBufAll,msbc_buffer,msbc_len); - } - else + if (btdrv_is_pcm_mask_enable() == 1) { + memcpy((uint8_t *)DecMsbcBufAll, msbc_buffer, msbc_len); + } else #endif - { - for(i =0; i= + msbc_offset_total) + frame_flag[j] = 3; else -#endif - { - - if (next_frame_flag == 1) - { - next_frame_flag = 0; - frame_flag[j] = 1; - continue; - } - if(msbc_offset_lowdelay==0&&j==0) - { - headerm1=0x0100; - } - else - { - headerm1 = DecMsbcBufAll[msbc_offset_lowdelay + j*(MSBC_LEN_FORMBT_PER_FRAME / 2)-1]; - } - - header0 = DecMsbcBufAll[msbc_offset_lowdelay + j*(MSBC_LEN_FORMBT_PER_FRAME / 2)]; - header1 = DecMsbcBufAll[msbc_offset_lowdelay + j*(MSBC_LEN_FORMBT_PER_FRAME / 2) + 1]; - header2 = DecMsbcBufAll[msbc_offset_lowdelay + j*(MSBC_LEN_FORMBT_PER_FRAME / 2) + 2]; - header3 = DecMsbcBufAll[msbc_offset_lowdelay + j*(MSBC_LEN_FORMBT_PER_FRAME / 2) + 3]; - - /*if ((headerm1 == 0x0100) && ((header0 & 0x0f00) == 0x0800) && (header1 == 0xad00) || - (header0 == 0x0100) && ((header1 & 0x0f00) == 0x0800) && (header2 == 0xad00) || - (header1 == 0x0100) && ((header2 & 0x0f00) == 0x0800) && (header3 == 0xad00)) - { - frame_flag[j] = 0; - }*/ - - if ((headerm1 == 0x0100) && ((header0 & 0x0f00) == 0x0800) && (header1 == 0xad00)) - { - frame_flag[j] = 0; - // It seems that offset is reduced by 1 - msbc_offset_drift[j] = -1; - TRACE(1,"[%s] msbc_offset is reduced by 1", __FUNCTION__); - /* tail0 = DecMsbcBufAll[msbc_offset_lowdelay + j*(MSBC_LEN_FORMBT_PER_FRAME / 2) + 59 - 1]; - if (tail0 == 0x0000 || tail0 == 0x0100|| tail0==0xff00) - { - frame_flag[j] = 0; - } - else - { - frame_flag[j] = 1; - next_frame_flag = 1; - }*/ - } - else if ((header0 == 0x0100) && ((header1 & 0x0f00) == 0x0800) && (header2 == 0xad00)) - { - frame_flag[j] = 0; -/* tail0 = DecMsbcBufAll[msbc_offset_lowdelay + j*(MSBC_LEN_FORMBT_PER_FRAME / 2) + 59]; - if (tail0 == 0x0000 || tail0 == 0x0100|| tail0==0xff00) - { - frame_flag[j] = 0; - } - else - { - frame_flag[j] = 1; - next_frame_flag = 1; - } - */ - } - else if ((header1 == 0x0100) && ((header2 & 0x0f00) == 0x0800) && (header3 == 0xad00)) - { - frame_flag[j] = 0; - msbc_offset_drift[j] = 1; - TRACE(1,"[%s] msbc_offset is increased by 1", __FUNCTION__); -/* tail0 = DecMsbcBufAll[msbc_offset_lowdelay + j*(MSBC_LEN_FORMBT_PER_FRAME / 2) + 59 + 1]; - if (tail0 == 0x0000 || tail0==0x0100|| tail0==0xff00) - { - frame_flag[j] = 0; - } - else - { - frame_flag[j] = 1; - next_frame_flag = 1; - }*/ - } - else - { - if ((header0 == MSBC_MUTE_PATTERN)&& ((header1 & 0x0f00) == MSBC_MUTE_PATTERN) && (header2 == MSBC_MUTE_PATTERN)) - { - frame_flag[j]=1; - } - else - { - if((msbc_offset_lowdelay+j*(MSBC_LEN_FORMBT_PER_FRAME / 2))>=msbc_offset_total) - frame_flag[j]=3; - else - frame_flag[j]=1; - } - } - } - + frame_flag[j] = 1; + } } + } + } #ifdef TX_RX_PCM_MASK - if(btdrv_is_pcm_mask_enable() ==0) + if (btdrv_is_pcm_mask_enable() == 0) #endif - { - for(j =0; j1)msbc_find_first_sync=0; - } + { + for (j = 0; j < msbc_len / MSBC_LEN_FORMBT_PER_FRAME; j++) { + value = value | frame_flag[j]; + } + // abnormal msbc packet. + if (value > 1) + msbc_find_first_sync = 0; + } + } + + while (frame_counter < msbc_len / MSBC_LEN_FORMBT_PER_FRAME) { + // TRACE(3,"[%s] decoding, offset %d, offset drift %d", __FUNCTION__, + // msbc_offset, msbc_offset_drift[frame_counter]); + // skip first byte when msbc_offset == 0 and msbc_offset_drift == -1 + unsigned int start_idx = 0; + if (msbc_offset_lowdelay == 0 && msbc_offset_drift[frame_counter] == -1) { + start_idx = 1; + DecMsbcBuf[0] = 0x01; + } + for (i = start_idx; i < MSBC_LEN_PER_FRAME; i++) { + // DecMsbcBuf[i]=DecMsbcBufAll[i+msbc_offset_lowdelay+frame_counter*(MSBC_LEN_FORMBT_PER_FRAME/2)+2]>>8; + DecMsbcBuf[i] = + DecMsbcBufAll[i + msbc_offset_lowdelay + + msbc_offset_drift[frame_counter] + + frame_counter * (MSBC_LEN_FORMBT_PER_FRAME / 2)] >> + 8; } - while(frame_counter>8; - DecMsbcBuf[i]=DecMsbcBufAll[i+msbc_offset_lowdelay+msbc_offset_drift[frame_counter]+frame_counter*(MSBC_LEN_FORMBT_PER_FRAME/2)]>>8; - } - - //TRACE(1,"msbc header:0x%x",DecMsbcBuf[0]); + // TRACE(1,"msbc header:0x%x",DecMsbcBuf[0]); #ifdef SPEECH_RX_PLC_DUMP_DATA - audio_dump_add_channel_data(2, (short *)DecMsbcBuf, MSBC_LEN_PER_FRAME/2); + audio_dump_add_channel_data(2, (short *)DecMsbcBuf, MSBC_LEN_PER_FRAME / 2); #endif - plc_type_t plc_type = packet_loss_detection_process(&pld, DecMsbcBuf); + plc_type_t plc_type = packet_loss_detection_process(&pld, DecMsbcBuf); - if(plc_type != PLC_TYPE_PASS) { - memset(DecPcmBuf, 0, sizeof(DecPcmBuf)); - goto do_plc; - } + if (plc_type != PLC_TYPE_PASS) { + memset(DecPcmBuf, 0, sizeof(DecPcmBuf)); + goto do_plc; + } - pcm_data.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; - pcm_data.numChannels = 1; - pcm_data.dataLen = 0; - pcm_data.data = (uint8_t *)DecPcmBuf; + pcm_data.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; + pcm_data.numChannels = 1; + pcm_data.dataLen = 0; + pcm_data.data = (uint8_t *)DecPcmBuf; - ret = btif_sbc_decode_frames(&msbc_decoder, - (unsigned char *)DecMsbcBuf, - MSBC_LEN_PER_FRAME, &byte_decode, - &pcm_data, SAMPLES_LEN_PER_FRAME*2, - msbc_eq_band_gain); + ret = btif_sbc_decode_frames(&msbc_decoder, (unsigned char *)DecMsbcBuf, + MSBC_LEN_PER_FRAME, &byte_decode, &pcm_data, + SAMPLES_LEN_PER_FRAME * 2, msbc_eq_band_gain); - //ASSERT(ret == BT_STS_SUCCESS, "[%s] msbc decoder should never fail", __FUNCTION__); - if (ret != BT_STS_SUCCESS) { - plc_type = PLC_TYPE_DECODER_ERROR; - packet_loss_detection_update_histogram(&pld, plc_type); - } + // ASSERT(ret == BT_STS_SUCCESS, "[%s] msbc decoder should never fail", + // __FUNCTION__); + if (ret != BT_STS_SUCCESS) { + plc_type = PLC_TYPE_DECODER_ERROR; + packet_loss_detection_update_histogram(&pld, plc_type); + } -do_plc: - if (plc_type == PLC_TYPE_PASS) { + do_plc: + if (plc_type == PLC_TYPE_PASS) { #if defined(ENABLE_LPC_PLC) - lpc_plc_save(msbc_plc_state, DecPcmBuf); + lpc_plc_save(msbc_plc_state, DecPcmBuf); #else - PLC_good_frame(&msbc_plc_state, DecPcmBuf, DecPcmBuf); + PLC_good_frame(&msbc_plc_state, DecPcmBuf, DecPcmBuf); #endif #ifdef SPEECH_RX_PLC_DUMP_DATA - audio_dump_add_channel_data(0, (short *)DecPcmBuf, MSBC_ENCODE_PCM_LEN/2); + audio_dump_add_channel_data(0, (short *)DecPcmBuf, + MSBC_ENCODE_PCM_LEN / 2); #endif - } - else - { - TRACE(1,"PLC bad frame, plc_type: %d", plc_type); + } else { + TRACE(1, "PLC bad frame, plc_type: %d", plc_type); #if defined(PLC_DEBUG_PRINT_DATA) - DUMP8("0x%02x, ", DecMsbcBuf, 60); + DUMP8("0x%02x, ", DecMsbcBuf, 60); #endif #ifdef SPEECH_RX_PLC_DUMP_DATA - for(uint32_t i=0; i< MSBC_ENCODE_PCM_LEN/2; i++) - { - audio_dump_temp_buf[i] = (plc_type - 1) * 5000; - } - audio_dump_add_channel_data(0, audio_dump_temp_buf, MSBC_ENCODE_PCM_LEN/2); + for (uint32_t i = 0; i < MSBC_ENCODE_PCM_LEN / 2; i++) { + audio_dump_temp_buf[i] = (plc_type - 1) * 5000; + } + audio_dump_add_channel_data(0, audio_dump_temp_buf, + MSBC_ENCODE_PCM_LEN / 2); #endif #if defined(ENABLE_LPC_PLC) - lpc_plc_generate(msbc_plc_state, DecPcmBuf, + lpc_plc_generate(msbc_plc_state, DecPcmBuf, #if defined(ENABLE_PLC_ENCODER) - msbc_plc_encoder_buffer + msbc_plc_encoder_buffer #else - NULL + NULL #endif - ); + ); #if defined(ENABLE_PLC_ENCODER) - pcm_data.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; - pcm_data.numChannels = 1; - pcm_data.dataLen = MSBC_ENCODE_PCM_LEN; - pcm_data.data = (uint8_t *)(msbc_plc_encoder_buffer + MSBC_CODEC_DELAY); + pcm_data.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; + pcm_data.numChannels = 1; + pcm_data.dataLen = MSBC_ENCODE_PCM_LEN; + pcm_data.data = (uint8_t *)(msbc_plc_encoder_buffer + MSBC_CODEC_DELAY); - uint16_t encoded_bytes = 0, buf_len = MSBC_FRAME_SIZE - 3; - ret = btif_sbc_encode_frames(msbc_plc_encoder, &pcm_data, &encoded_bytes, enc_tmp_buf, &buf_len, 0xFFFF); - ASSERT(ret == BT_STS_SUCCESS, "[%s] plc encoder must success", __FUNCTION__); - ASSERT(encoded_bytes == MSBC_ENCODE_PCM_LEN, "[%s] plc encoder encoded bytes error", __FUNCTION__); - ASSERT(buf_len == MSBC_FRAME_SIZE - 3, "[%s] plc encoder encoded stream length error", __FUNCTION__); + uint16_t encoded_bytes = 0, buf_len = MSBC_FRAME_SIZE - 3; + ret = btif_sbc_encode_frames(msbc_plc_encoder, &pcm_data, &encoded_bytes, + enc_tmp_buf, &buf_len, 0xFFFF); + ASSERT(ret == BT_STS_SUCCESS, "[%s] plc encoder must success", + __FUNCTION__); + ASSERT(encoded_bytes == MSBC_ENCODE_PCM_LEN, + "[%s] plc encoder encoded bytes error", __FUNCTION__); + ASSERT(buf_len == MSBC_FRAME_SIZE - 3, + "[%s] plc encoder encoded stream length error", __FUNCTION__); - pcm_data.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; - pcm_data.numChannels = 1; - pcm_data.dataLen = 0; - pcm_data.data = dec_tmp_buf; - ret = btif_sbc_decode_frames(&msbc_decoder, enc_tmp_buf, MSBC_FRAME_SIZE - 3, &byte_decode, &pcm_data, MSBC_ENCODE_PCM_LEN, msbc_eq_band_gain); - ASSERT(ret == BT_STS_SUCCESS, "[%s] plc decoder must success", __FUNCTION__); - ASSERT(byte_decode == MSBC_FRAME_SIZE - 3, "[%s] plc decoder decoded bytes error", __FUNCTION__); + pcm_data.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; + pcm_data.numChannels = 1; + pcm_data.dataLen = 0; + pcm_data.data = dec_tmp_buf; + ret = btif_sbc_decode_frames(&msbc_decoder, enc_tmp_buf, + MSBC_FRAME_SIZE - 3, &byte_decode, &pcm_data, + MSBC_ENCODE_PCM_LEN, msbc_eq_band_gain); + ASSERT(ret == BT_STS_SUCCESS, "[%s] plc decoder must success", + __FUNCTION__); + ASSERT(byte_decode == MSBC_FRAME_SIZE - 3, + "[%s] plc decoder decoded bytes error", __FUNCTION__); #endif #else - pcm_data.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; - pcm_data.numChannels = 1; - pcm_data.dataLen = 0; - pcm_data.data = (uint8_t *)DecPcmBuf; + pcm_data.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; + pcm_data.numChannels = 1; + pcm_data.dataLen = 0; + pcm_data.data = (uint8_t *)DecPcmBuf; - ret = btif_sbc_decode_frames(&msbc_decoder, - (unsigned char *)indices0, - MSBC_LEN_PER_FRAME, &byte_decode, - &pcm_data, SAMPLES_LEN_PER_FRAME*2, - msbc_eq_band_gain); + ret = + btif_sbc_decode_frames(&msbc_decoder, (unsigned char *)indices0, + MSBC_LEN_PER_FRAME, &byte_decode, &pcm_data, + SAMPLES_LEN_PER_FRAME * 2, msbc_eq_band_gain); - PLC_bad_frame(&msbc_plc_state, DecPcmBuf, DecPcmBuf); + PLC_bad_frame(&msbc_plc_state, DecPcmBuf, DecPcmBuf); - ASSERT(ret == BT_STS_SUCCESS, "[%s] msbc decoder should never fail", __FUNCTION__); + ASSERT(ret == BT_STS_SUCCESS, "[%s] msbc decoder should never fail", + __FUNCTION__); #endif - } + } #ifdef SPEECH_RX_PLC_DUMP_DATA - audio_dump_add_channel_data(1, (short *)DecPcmBuf, MSBC_ENCODE_PCM_LEN/2); - audio_dump_run(); + audio_dump_add_channel_data(1, (short *)DecPcmBuf, MSBC_ENCODE_PCM_LEN / 2); + audio_dump_run(); #endif - LOCK_APP_AUDIO_QUEUE(); - APP_AUDIO_EnCQueue(&voicebtpcm_m2p_pcm_queue, (unsigned char *)DecPcmBuf, (unsigned int)(SAMPLES_LEN_PER_FRAME*2)); - UNLOCK_APP_AUDIO_QUEUE(); - frame_counter++; - } + LOCK_APP_AUDIO_QUEUE(); + APP_AUDIO_EnCQueue(&voicebtpcm_m2p_pcm_queue, (unsigned char *)DecPcmBuf, + (unsigned int)(SAMPLES_LEN_PER_FRAME * 2)); + UNLOCK_APP_AUDIO_QUEUE(); + frame_counter++; + } #ifdef TX_RX_PCM_MASK - if(btdrv_is_pcm_mask_enable() ==0) + if (btdrv_is_pcm_mask_enable() == 0) #endif - { - for(i =0; i MSBC_LEN_PER_FRAME*2) - msbc_queue_len = MSBC_LEN_PER_FRAME*2; - else if(msbc_queue_len < MSBC_LEN_PER_FRAME) - return 0; - - r = APP_AUDIO_PeekCQueue(&msbc_temp_queue, msbc_queue_len, &e1, &len1, &e2, &len2); - if(r == CQ_OK) - { - if (len1) - { - memcpy(DecVerifyMsbcBuf, e1, len1); - } - if (len2 != 0) - { - memcpy(DecVerifyMsbcBuf + len1, e2, len2); - } - }else{ - //can't happen + msbc_queue_len = APP_AUDIO_LengthOfCQueue(&msbc_temp_queue); + TRACE(1, "length = %d", msbc_queue_len); + if (msbc_queue_len > MSBC_LEN_PER_FRAME * 2) + msbc_queue_len = MSBC_LEN_PER_FRAME * 2; + else if (msbc_queue_len < MSBC_LEN_PER_FRAME) + return 0; + r = APP_AUDIO_PeekCQueue(&msbc_temp_queue, msbc_queue_len, &e1, &len1, &e2, + &len2); + if (r == CQ_OK) { + if (len1) { + memcpy(DecVerifyMsbcBuf, e1, len1); } - - //DUMP8("%02x", DecVerifyMsbcBuf, msbc_queue_len); - //find sync head - for(int i = 0; i < (msbc_queue_len - 3); i ++){ - //verify sync success - if(sco_parse_synchronization_header(DecVerifyMsbcBuf + i, &sync_num) >= 0){ - verify_result = 1; - msbc_sync_offset = i; - break; - } + if (len2 != 0) { + memcpy(DecVerifyMsbcBuf + len1, e2, len2); } - TRACE(3,"%02x %02x %02x", (DecVerifyMsbcBuf +msbc_sync_offset)[0], - (DecVerifyMsbcBuf +msbc_sync_offset)[1], - (DecVerifyMsbcBuf +msbc_sync_offset)[2]); - TRACE(5,"msbc:%d %d %d %d %d\n", - verify_result, - msbc_queue_len, - msbc_sync_offset, - last_msbc_sync_num, - sync_num); + } else { + // can't happen + } - if(!verify_result){ - //remove msbc frame remain 3 byted as it may include syn head - APP_AUDIO_DeCQueue(&msbc_temp_queue, 0, msbc_queue_len - 3); - goto msbc_find_sync_again; - }else{ - //remove invalid msbc frame space - APP_AUDIO_DeCQueue(&msbc_temp_queue, 0, msbc_sync_offset); - if(msbc_sync_offset >= MSBC_LEN_PER_FRAME) - goto msbc_find_sync_again; + // DUMP8("%02x", DecVerifyMsbcBuf, msbc_queue_len); + // find sync head + for (int i = 0; i < (msbc_queue_len - 3); i++) { + // verify sync success + if (sco_parse_synchronization_header(DecVerifyMsbcBuf + i, &sync_num) >= + 0) { + verify_result = 1; + msbc_sync_offset = i; + break; } + } + TRACE(3, "%02x %02x %02x", (DecVerifyMsbcBuf + msbc_sync_offset)[0], + (DecVerifyMsbcBuf + msbc_sync_offset)[1], + (DecVerifyMsbcBuf + msbc_sync_offset)[2]); + TRACE(5, "msbc:%d %d %d %d %d\n", verify_result, msbc_queue_len, + msbc_sync_offset, last_msbc_sync_num, sync_num); - //cal plc number - if((last_msbc_sync_num + 1)%4 == sync_num){ - plc_num = 0; - }else{ - for(int i = 0; i < 4; i ++){ - if((last_msbc_sync_num + i)%4 == sync_num){ - break; - } - plc_num ++; - } + if (!verify_result) { + // remove msbc frame remain 3 byted as it may include syn head + APP_AUDIO_DeCQueue(&msbc_temp_queue, 0, msbc_queue_len - 3); + goto msbc_find_sync_again; + } else { + // remove invalid msbc frame space + APP_AUDIO_DeCQueue(&msbc_temp_queue, 0, msbc_sync_offset); + if (msbc_sync_offset >= MSBC_LEN_PER_FRAME) + goto msbc_find_sync_again; + } + + // cal plc number + if ((last_msbc_sync_num + 1) % 4 == sync_num) { + plc_num = 0; + } else { + for (int i = 0; i < 4; i++) { + if ((last_msbc_sync_num + i) % 4 == sync_num) { + break; + } + plc_num++; } - last_msbc_sync_num = sync_num; + } + last_msbc_sync_num = sync_num; - //failed check sync should do plc - if(plc_num > 0){ - for(int i = 0; i < plc_num; i ++){ - ret = btif_sbc_decode_frames(&msbc_decoder, - (unsigned char *)indices0, - MSBC_LEN_PER_FRAME, &byte_decode, - &pcm_data, SAMPLES_LEN_PER_FRAME*2, - msbc_eq_band_gain); + // failed check sync should do plc + if (plc_num > 0) { + for (int i = 0; i < plc_num; i++) { + ret = + btif_sbc_decode_frames(&msbc_decoder, (unsigned char *)indices0, + MSBC_LEN_PER_FRAME, &byte_decode, &pcm_data, + SAMPLES_LEN_PER_FRAME * 2, msbc_eq_band_gain); - if (ret == BT_STS_SUCCESS) - { - TRACE(1,"PLC bad frame:%d\n", ret); - //timer_begin=hal_sys_timer_get(); - PLC_bad_frame(&msbc_plc_state, DecPcmBuf, DecPcmBuf); - //TRACE(1,"msbc + plc:%d", (hal_sys_timer_get()-timer_begin)); - pcm_data.data = (unsigned char*)DecPcmBuf; - pcm_data.dataLen = 0; - LOCK_APP_AUDIO_QUEUE(); - APP_AUDIO_EnCQueue(&voicebtpcm_m2p_pcm_queue, - (unsigned char *)DecPcmBuf, - (unsigned int)(SAMPLES_LEN_PER_FRAME*2)); - UNLOCK_APP_AUDIO_QUEUE(); - } - else - { - ASSERT(0, "ERROR inices0", __func__); - } - } - } - - { - ret = btif_sbc_decode_frames(&msbc_decoder, - (unsigned char *)DecVerifyMsbcBuf + msbc_sync_offset + 2, - MSBC_LEN_PER_FRAME, &byte_decode, - &pcm_data, SAMPLES_LEN_PER_FRAME*2, - msbc_eq_band_gain); - - if (ret == BT_STS_SUCCESS) - { - PLC_good_frame(&msbc_plc_state, DecPcmBuf, DecPcmBuf); - pcm_data.data = (unsigned char*)DecPcmBuf; - pcm_data.dataLen = 0; - } - else - { - TRACE(1,"PLC bad frame:%d\n"); - PLC_bad_frame(&msbc_plc_state, DecPcmBuf, DecPcmBuf); - pcm_data.data = (unsigned char*)DecPcmBuf; - pcm_data.dataLen = 0; - TRACE(1,"ERROR msbc frame!ret:%d\n",ret); - } - //remove msbc frame - APP_AUDIO_DeCQueue(&msbc_temp_queue, 0, MSBC_LEN_PER_FRAME); + if (ret == BT_STS_SUCCESS) { + TRACE(1, "PLC bad frame:%d\n", ret); + // timer_begin=hal_sys_timer_get(); + PLC_bad_frame(&msbc_plc_state, DecPcmBuf, DecPcmBuf); + // TRACE(1,"msbc + plc:%d", (hal_sys_timer_get()-timer_begin)); + pcm_data.data = (unsigned char *)DecPcmBuf; + pcm_data.dataLen = 0; LOCK_APP_AUDIO_QUEUE(); APP_AUDIO_EnCQueue(&voicebtpcm_m2p_pcm_queue, - (unsigned char *)DecPcmBuf, - (unsigned int)(SAMPLES_LEN_PER_FRAME*2)); + (unsigned char *)DecPcmBuf, + (unsigned int)(SAMPLES_LEN_PER_FRAME * 2)); UNLOCK_APP_AUDIO_QUEUE(); - frame_decode_num ++; - if(frame_decode_num <= (msbc_len/(MSBC_LEN_PER_FRAME*2) - 1)) - goto msbc_find_sync_again; + } else { + ASSERT(0, "ERROR inices0", __func__); + } } - return 0; + } + + { + ret = btif_sbc_decode_frames( + &msbc_decoder, (unsigned char *)DecVerifyMsbcBuf + msbc_sync_offset + 2, + MSBC_LEN_PER_FRAME, &byte_decode, &pcm_data, SAMPLES_LEN_PER_FRAME * 2, + msbc_eq_band_gain); + + if (ret == BT_STS_SUCCESS) { + PLC_good_frame(&msbc_plc_state, DecPcmBuf, DecPcmBuf); + pcm_data.data = (unsigned char *)DecPcmBuf; + pcm_data.dataLen = 0; + } else { + TRACE(1, "PLC bad frame:%d\n"); + PLC_bad_frame(&msbc_plc_state, DecPcmBuf, DecPcmBuf); + pcm_data.data = (unsigned char *)DecPcmBuf; + pcm_data.dataLen = 0; + TRACE(1, "ERROR msbc frame!ret:%d\n", ret); + } + // remove msbc frame + APP_AUDIO_DeCQueue(&msbc_temp_queue, 0, MSBC_LEN_PER_FRAME); + LOCK_APP_AUDIO_QUEUE(); + APP_AUDIO_EnCQueue(&voicebtpcm_m2p_pcm_queue, (unsigned char *)DecPcmBuf, + (unsigned int)(SAMPLES_LEN_PER_FRAME * 2)); + UNLOCK_APP_AUDIO_QUEUE(); + frame_decode_num++; + if (frame_decode_num <= (msbc_len / (MSBC_LEN_PER_FRAME * 2) - 1)) + goto msbc_find_sync_again; + } + return 0; } -#endif // #if !defined(PENDING_MSBC_DECODER_ALG) +#endif // #if !defined(PENDING_MSBC_DECODER_ALG) #else -int decode_msbc_frame(unsigned char *pcm_buffer, unsigned int pcm_len) -{ - int ttt = 0; - //int t = 0; - uint8_t underflow = 0; +int decode_msbc_frame(unsigned char *pcm_buffer, unsigned int pcm_len) { + int ttt = 0; + // int t = 0; + uint8_t underflow = 0; #if defined(MSBC_PLC_ENABLE) - uint8_t plc_type = 0; - uint8_t need_check_pkt = 1; - uint8_t msbc_raw_sn = 0xff; - static uint8_t msbc_raw_sn_pre; - static uint8_t msbc_raw_sn_pre2; - static bool msbc_find_first_sync = 0; + uint8_t plc_type = 0; + uint8_t need_check_pkt = 1; + uint8_t msbc_raw_sn = 0xff; + static uint8_t msbc_raw_sn_pre; + static uint8_t msbc_raw_sn_pre2; + static bool msbc_find_first_sync = 0; #endif - int r = 0; - unsigned char *e1 = NULL, *e2 = NULL, *msbc_buff = NULL; - unsigned int len1 = 0, len2 = 0; - static btif_sbc_pcm_data_t pcm_data; - static unsigned int msbc_next_frame_size; - bt_status_t ret = BT_STS_SUCCESS; - unsigned short byte_decode = 0; + int r = 0; + unsigned char *e1 = NULL, *e2 = NULL, *msbc_buff = NULL; + unsigned int len1 = 0, len2 = 0; + static btif_sbc_pcm_data_t pcm_data; + static unsigned int msbc_next_frame_size; + bt_status_t ret = BT_STS_SUCCESS; + unsigned short byte_decode = 0; - unsigned int pcm_offset = 0; - unsigned int pcm_processed = 0; + unsigned int pcm_offset = 0; + unsigned int pcm_processed = 0; #if defined(MSBC_PLC_ENABLE) - pcm_data.data = (unsigned char*)msbc_buf_before_plc; + pcm_data.data = (unsigned char *)msbc_buf_before_plc; #else - pcm_data.data = (unsigned char*)pcm_buffer; + pcm_data.data = (unsigned char *)pcm_buffer; #endif - if (!msbc_next_frame_size) - { - msbc_next_frame_size = MSBC_FRAME_SIZE; - } + if (!msbc_next_frame_size) { + msbc_next_frame_size = MSBC_FRAME_SIZE; + } -//reinit: - if(need_init_decoder) - { - TRACE(0,"init msbc decoder\n"); - pcm_data.data = (unsigned char*)(pcm_buffer + pcm_offset); - pcm_data.dataLen = 0; + // reinit: + if (need_init_decoder) { + TRACE(0, "init msbc decoder\n"); + pcm_data.data = (unsigned char *)(pcm_buffer + pcm_offset); + pcm_data.dataLen = 0; - btif_sbc_init_decoder(&msbc_decoder); + btif_sbc_init_decoder(&msbc_decoder); - msbc_decoder.streamInfo.mSbcFlag = 1; - msbc_decoder.streamInfo.bitPool = 26; - msbc_decoder.streamInfo.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; - msbc_decoder.streamInfo.channelMode = BTIF_SBC_CHNL_MODE_MONO; - msbc_decoder.streamInfo.allocMethod = BTIF_SBC_ALLOC_METHOD_LOUDNESS; - /* Number of blocks used to encode the stream (4, 8, 12, or 16) */ - msbc_decoder.streamInfo.numBlocks = BTIF_MSBC_BLOCKS; - /* The number of subbands in the stream (4 or 8) */ - msbc_decoder.streamInfo.numSubBands = 8; - msbc_decoder.streamInfo.numChannels = 1; + msbc_decoder.streamInfo.mSbcFlag = 1; + msbc_decoder.streamInfo.bitPool = 26; + msbc_decoder.streamInfo.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; + msbc_decoder.streamInfo.channelMode = BTIF_SBC_CHNL_MODE_MONO; + msbc_decoder.streamInfo.allocMethod = BTIF_SBC_ALLOC_METHOD_LOUDNESS; + /* Number of blocks used to encode the stream (4, 8, 12, or 16) */ + msbc_decoder.streamInfo.numBlocks = BTIF_MSBC_BLOCKS; + /* The number of subbands in the stream (4 or 8) */ + msbc_decoder.streamInfo.numSubBands = 8; + msbc_decoder.streamInfo.numChannels = 1; #if defined(MSBC_PLC_ENCODER) - btif_sbc_init_encoder(&sbc_Encoder1); - sbc_Encoder1.streamInfo.mSbcFlag = 1; - sbc_Encoder1.streamInfo.numChannels = 1; - sbc_Encoder1.streamInfo.channelMode = BTIF_SBC_CHNL_MODE_MONO; + btif_sbc_init_encoder(&sbc_Encoder1); + sbc_Encoder1.streamInfo.mSbcFlag = 1; + sbc_Encoder1.streamInfo.numChannels = 1; + sbc_Encoder1.streamInfo.channelMode = BTIF_SBC_CHNL_MODE_MONO; - sbc_Encoder1.streamInfo.bitPool = 26; - sbc_Encoder1.streamInfo.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; - sbc_Encoder1.streamInfo.allocMethod = BTIF_SBC_ALLOC_METHOD_LOUDNESS; - sbc_Encoder1.streamInfo.numBlocks = BTIF_MSBC_BLOCKS; - sbc_Encoder1.streamInfo.numSubBands = 8; + sbc_Encoder1.streamInfo.bitPool = 26; + sbc_Encoder1.streamInfo.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; + sbc_Encoder1.streamInfo.allocMethod = BTIF_SBC_ALLOC_METHOD_LOUDNESS; + sbc_Encoder1.streamInfo.numBlocks = BTIF_MSBC_BLOCKS; + sbc_Encoder1.streamInfo.numSubBands = 8; #endif #if defined(MSBC_PLC_ENABLE) - InitPLC(&msbc_plc_state); - msbc_need_check_sync_header = 0; - msbc_raw_sn_pre = 0xff; - msbc_raw_sn_pre2 = 0xff; - msbc_find_first_sync = true; + InitPLC(&msbc_plc_state); + msbc_need_check_sync_header = 0; + msbc_raw_sn_pre = 0xff; + msbc_raw_sn_pre2 = 0xff; + msbc_find_first_sync = true; #endif - } + } #if defined(MSBC_PLC_ENABLE) - need_check_pkt = 1; + need_check_pkt = 1; #endif - msbc_buff = msbc_buf_before_decode; + msbc_buff = msbc_buf_before_decode; get_again: + LOCK_APP_AUDIO_QUEUE(); + len1 = len2 = 0; + e1 = e2 = 0; + r = APP_AUDIO_PeekCQueue(&voicebtpcm_m2p_pcm_queue, msbc_next_frame_size, &e1, + &len1, &e2, &len2); + UNLOCK_APP_AUDIO_QUEUE(); + + if (r == CQ_ERR) { + pcm_processed = pcm_len; + memset(pcm_buffer, 0, pcm_len); + TRACE(0, "msbc spk buff underflow"); + goto exit; + } + + if (!len1) { + TRACE(2, "len1 underflow %d/%d\n", len1, len2); + goto get_again; + } + + if (len1 > 0 && e1) { + memcpy(msbc_buff, e1, len1); + } + if (len2 > 0 && e2) { + memcpy(msbc_buff + len1, e2, len2); + } + + if (msbc_find_first_sync) { + + for (uint8_t i = 0; i < MSBC_FRAME_SIZE - 3; i++) { + if (!sco_parse_synchronization_header(&msbc_buff[i], &msbc_raw_sn)) { + TRACE(2, "1 msbc find sync sn:%d offset:%d", msbc_raw_sn, i); + msbc_find_first_sync = false; + goto start_decoder; + } + } LOCK_APP_AUDIO_QUEUE(); - len1 = len2 = 0; - e1 = e2 = 0; - r = APP_AUDIO_PeekCQueue(&voicebtpcm_m2p_pcm_queue, msbc_next_frame_size, &e1, &len1, &e2, &len2); + APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, MSBC_FRAME_SIZE - 3); UNLOCK_APP_AUDIO_QUEUE(); + memset(pcm_buffer, 0, pcm_len); + pcm_processed = pcm_len; + goto exit; + } +start_decoder: - if (r == CQ_ERR) - { - pcm_processed = pcm_len; - memset(pcm_buffer, 0, pcm_len); - TRACE(0,"msbc spk buff underflow"); - goto exit; - } + // DUMP8("%02x ", msbc_buf_before_decode, 8); +#if defined(MSBC_PLC_ENABLE) + // [0]-1,msbc sync byte + // [1]-seqno + // code_frame(57 bytes) + // padding(1 byte) + if (need_check_pkt) { - if (!len1) - { - TRACE(2,"len1 underflow %d/%d\n", len1, len2); - goto get_again; - } - - if (len1 > 0 && e1) - { - memcpy(msbc_buff, e1, len1); - } - if (len2 > 0 && e2) - { - memcpy(msbc_buff + len1, e2, len2); - } - - if (msbc_find_first_sync){ - - for(uint8_t i=0;i 0 && sync_offset != (MSBC_FRAME_SIZE - 3)) { LOCK_APP_AUDIO_QUEUE(); - APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, MSBC_FRAME_SIZE-3); + APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, sync_offset); UNLOCK_APP_AUDIO_QUEUE(); - memset(pcm_buffer,0,pcm_len); - pcm_processed = pcm_len; - goto exit; + TRACE(1, "fix sync:%d", sync_offset); + msbc_raw_sn_pre = (msbc_raw_sn + 3) % 4; // Find pre sn + msbc_raw_sn_pre2 = msbc_raw_sn_pre; + goto get_again; + // TRACE(4,"***msbc_need_check_sync %d :%x %x %x\n", sync_offset, + // msbc_buf_before_decode[0], + // msbc_buf_before_decode[1], + // msbc_buf_before_decode[2]); + } else if (sync_offset == (MSBC_FRAME_SIZE - 3)) { + // APP_AUDIO_DeCQueue(&voicebtpcm_m2p_queue, 0, sync_offset); + // just jump sync length + padding length(1byte) + // will in plc again, so can check sync again + // TRACE(4,"***msbc_need_check_sync %d :%x %x %x\n", sync_offset, + // msbc_buf_before_decode[0], + // msbc_buf_before_decode[1], + // msbc_buf_before_decode[2]); + msbc_next_frame_size = (MSBC_FRAME_SIZE - 3) - 1; + } else if (!sync_offset) { + + } else { + TRACE(1, "3 msbc_need_check_sync %d\n", sync_offset); + } } - start_decoder: + // 0 - normal decode without plc proc, 1 - normal decode with plc proc, 2 - + // special decode with plc proc + plc_type = 0; - //DUMP8("%02x ", msbc_buf_before_decode, 8); -#if defined(MSBC_PLC_ENABLE) - // [0]-1,msbc sync byte - // [1]-seqno - // code_frame(57 bytes) - // padding(1 byte) - if (need_check_pkt) - { - -#if 1 - if(!sco_parse_synchronization_header(msbc_buf_before_decode, &msbc_raw_sn)) - { - if (msbc_raw_sn_pre2 == 0xff){ - // do nothing - msbc_raw_sn_pre2 = msbc_raw_sn; - }else{ - if (((msbc_raw_sn_pre2+1)%4) == msbc_raw_sn){ - // do nothing - msbc_raw_sn_pre2 = msbc_raw_sn; - }else if (msbc_raw_sn == 0xff){ - TRACE(1,"xxxxxx: sbchd err:%d", MSBC_FRAME_SIZE-3); - }else{ - TRACE(2,"xxxxxx: seq err:%d/%d", msbc_raw_sn, msbc_raw_sn_pre2); - msbc_raw_sn_pre2 = (msbc_raw_sn_pre2+1)%4; -#if 1 - memset(msbc_buf_before_decode, 0, MSBC_FRAME_SIZE); -#else - if (msbc_raw_sn_pre2 == 0) - { - msbc_buf_before_decode[1] = 0x08; - } - else if (msbc_raw_sn_pre2 == 1) - { - msbc_buf_before_decode[1] = 0x38; - } - else if (msbc_raw_sn_pre2 == 2) - { - msbc_buf_before_decode[1] = 0xc8; - } - else if (msbc_raw_sn_pre2 == 3) - { - msbc_buf_before_decode[1] = 0xf8; - } - else - { - ASSERT(0, "msbc_raw_sn_pre2(%d) error", __func__); - } -#endif - } - } - } -#endif - unsigned int sync_offset = 0; - if(msbc_need_check_sync_header) - { - do - { - if(!sco_parse_synchronization_header(&msbc_buff[sync_offset], &msbc_raw_sn)){ - break; - } - sync_offset ++; - } - while(sync_offset < (MSBC_FRAME_SIZE - 3)); - - msbc_need_check_sync_header = 0; - if(sync_offset > 0 && sync_offset != (MSBC_FRAME_SIZE - 3)) - { - LOCK_APP_AUDIO_QUEUE(); - APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, sync_offset); - UNLOCK_APP_AUDIO_QUEUE(); - TRACE(1,"fix sync:%d", sync_offset); - msbc_raw_sn_pre = (msbc_raw_sn+3)%4; // Find pre sn - msbc_raw_sn_pre2 = msbc_raw_sn_pre; - goto get_again; - //TRACE(4,"***msbc_need_check_sync %d :%x %x %x\n", sync_offset, msbc_buf_before_decode[0], - // msbc_buf_before_decode[1], - // msbc_buf_before_decode[2]); - } - else if(sync_offset == (MSBC_FRAME_SIZE - 3)) - { - //APP_AUDIO_DeCQueue(&voicebtpcm_m2p_queue, 0, sync_offset); - //just jump sync length + padding length(1byte) - //will in plc again, so can check sync again - //TRACE(4,"***msbc_need_check_sync %d :%x %x %x\n", sync_offset, msbc_buf_before_decode[0], - // msbc_buf_before_decode[1], - // msbc_buf_before_decode[2]); - msbc_next_frame_size = (MSBC_FRAME_SIZE - 3) - 1; - }else if (!sync_offset){ - - }else{ - TRACE(1,"3 msbc_need_check_sync %d\n", sync_offset); - } - } - // 0 - normal decode without plc proc, 1 - normal decode with plc proc, 2 - special decode with plc proc - plc_type = 0; - - if (msbc_can_plc) - { - if (sco_parse_synchronization_header(msbc_buf_before_decode, &msbc_raw_sn)){ - plc_type = 2; - msbc_need_check_sync_header = 1; - }else{ - plc_type = 1; - } - } - else - { - plc_type = 0; - } - - if (msbc_raw_sn_pre == 0xff){ - // do nothing - msbc_raw_sn_pre = msbc_raw_sn; - }else{ - if (((msbc_raw_sn_pre+1)%4) == msbc_raw_sn){ - // do nothing - msbc_raw_sn_pre = msbc_raw_sn; - }else if (msbc_raw_sn == 0xff){ - TRACE(1,"sbchd err:%d", MSBC_FRAME_SIZE-3); - msbc_need_check_sync_header = 1; - LOCK_APP_AUDIO_QUEUE(); - APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, MSBC_FRAME_SIZE-3); - UNLOCK_APP_AUDIO_QUEUE(); - msbc_raw_sn_pre = (msbc_raw_sn_pre+1)%4; - plc_type = 2; - }else{ - TRACE(2,"seq err:%d/%d", msbc_raw_sn, msbc_raw_sn_pre); - msbc_need_check_sync_header = 1; - plc_type = 2; - msbc_raw_sn_pre = (msbc_raw_sn_pre+1)%4; - } - } - - need_check_pkt = 0; + if (msbc_can_plc) { + if (sco_parse_synchronization_header(msbc_buf_before_decode, + &msbc_raw_sn)) { + plc_type = 2; + msbc_need_check_sync_header = 1; + } else { + plc_type = 1; + } + } else { + plc_type = 0; } - //TRACE(3,"type %d, seqno 0x%x, q_space %d\n", plc_type, cur_pkt_seqno, APP_AUDIO_AvailableOfCQueue(&voicebtpcm_m2p_queue)); + + if (msbc_raw_sn_pre == 0xff) { + // do nothing + msbc_raw_sn_pre = msbc_raw_sn; + } else { + if (((msbc_raw_sn_pre + 1) % 4) == msbc_raw_sn) { + // do nothing + msbc_raw_sn_pre = msbc_raw_sn; + } else if (msbc_raw_sn == 0xff) { + TRACE(1, "sbchd err:%d", MSBC_FRAME_SIZE - 3); + msbc_need_check_sync_header = 1; + LOCK_APP_AUDIO_QUEUE(); + APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, MSBC_FRAME_SIZE - 3); + UNLOCK_APP_AUDIO_QUEUE(); + msbc_raw_sn_pre = (msbc_raw_sn_pre + 1) % 4; + plc_type = 2; + } else { + TRACE(2, "seq err:%d/%d", msbc_raw_sn, msbc_raw_sn_pre); + msbc_need_check_sync_header = 1; + plc_type = 2; + msbc_raw_sn_pre = (msbc_raw_sn_pre + 1) % 4; + } + } + + need_check_pkt = 0; + } + // TRACE(3,"type %d, seqno 0x%x, q_space %d\n", plc_type, cur_pkt_seqno, + // APP_AUDIO_AvailableOfCQueue(&voicebtpcm_m2p_queue)); #endif - //DUMP8("%02x ", msbc_buf_before_decode, msbc_next_frame_size); - //TRACE(0,"\n"); + // DUMP8("%02x ", msbc_buf_before_decode, msbc_next_frame_size); + // TRACE(0,"\n"); #if defined(MSBC_PLC_ENABLE) - if (plc_type == 1) - { - ret = btif_sbc_decode_frames(&msbc_decoder, (unsigned char *)msbc_buf_before_decode, - msbc_next_frame_size, &byte_decode, - &pcm_data, pcm_len - pcm_offset, - msbc_eq_band_gain); + if (plc_type == 1) { + ret = btif_sbc_decode_frames(&msbc_decoder, + (unsigned char *)msbc_buf_before_decode, + msbc_next_frame_size, &byte_decode, &pcm_data, + pcm_len - pcm_offset, msbc_eq_band_gain); - ttt = hal_sys_timer_get(); + ttt = hal_sys_timer_get(); #if defined(MSBC_PCM_PLC_ENABLE) - speech_plc_16000_AddToHistory((PlcSt_16000 *)speech_plc, (short *)pcm_data.data, pcm_len/2); - memcpy(pcm_buffer, pcm_data.data, pcm_len); + speech_plc_16000_AddToHistory((PlcSt_16000 *)speech_plc, + (short *)pcm_data.data, pcm_len / 2); + memcpy(pcm_buffer, pcm_data.data, pcm_len); #else - PLC_good_frame(&msbc_plc_state, (short *)pcm_data.data, (short *)pcm_buffer); + PLC_good_frame(&msbc_plc_state, (short *)pcm_data.data, + (short *)pcm_buffer); #endif #ifdef SPEECH_RX_PLC_DUMP_DATA - audio_dump_add_channel_data(0, (short *)pcm_buffer, pcm_len/2); + audio_dump_add_channel_data(0, (short *)pcm_buffer, pcm_len / 2); #endif - } - else if (plc_type == 2) - { + } else if (plc_type == 2) { #if defined(MSBC_PCM_PLC_ENABLE) - ret = BT_STS_SUCCESS; - ttt = hal_sys_timer_get(); + ret = BT_STS_SUCCESS; + ttt = hal_sys_timer_get(); #if defined(MSBC_PLC_ENCODER) - speech_plc_16000_Dofe((PlcSt_16000 *)speech_plc, (short *)pcm_buffer, EncInBuf, pcm_len/2); + speech_plc_16000_Dofe((PlcSt_16000 *)speech_plc, (short *)pcm_buffer, + EncInBuf, pcm_len / 2); #else - speech_plc_16000_Dofe((PlcSt_16000 *)speech_plc, (short *)pcm_buffer, NULL, pcm_len/2); + speech_plc_16000_Dofe((PlcSt_16000 *)speech_plc, (short *)pcm_buffer, NULL, + pcm_len / 2); #endif #else - PLC_bad_frame(&msbc_plc_state, (short *)pcm_data.data, (short *)pcm_buffer); + PLC_bad_frame(&msbc_plc_state, (short *)pcm_data.data, (short *)pcm_buffer); #endif #if defined(MSBC_PLC_ENCODER) - { - uint16_t bytes_encoded = 0, buf_len = MSBC_ENCODE_PCM_LEN; - PcmEncData1.data = (uint8_t *)(EncInBuf+MSBC_ENC_BUFFER_OFFSET); - PcmEncData1.dataLen = pcm_len; - PcmEncData1.numChannels = 1; - PcmEncData1.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; - btif_sbc_encode_frames(&sbc_Encoder1, &PcmEncData1, &bytes_encoded, Encodedbuf1, &buf_len, 0xFFFF); - #ifdef __SBC_FUNC_IN_ROM__ - ret = SBC_ROM_FUNC.sbc_frames_decode(&msbc_decoder, Encodedbuf1, MSBC_FRAME_SIZE-3, &byte_decode, - &pcm_data, pcm_len - pcm_offset, msbc_eq_band_gain); - #else - ret = btif_sbc_decode_frames(&msbc_decoder, Encodedbuf1, MSBC_FRAME_SIZE-3, &byte_decode, - &pcm_data, pcm_len - pcm_offset, msbc_eq_band_gain); - #endif - - } -#endif - TRACE(2,"b t:%d ret:%d\n", (hal_sys_timer_get()-ttt), ret); -#ifdef SPEECH_RX_PLC_DUMP_DATA - for(uint32_t i=0; i< pcm_len/2; i++) - { - audio_dump_temp_buf[i] = 32767; - } - audio_dump_add_channel_data(0, audio_dump_temp_buf, pcm_len/2); -#endif - } - else -#endif { - ret = btif_sbc_decode_frames(&msbc_decoder, (unsigned char *)msbc_buf_before_decode, - msbc_next_frame_size, &byte_decode, - &pcm_data, pcm_len - pcm_offset, - msbc_eq_band_gain); -#if defined(MSBC_PCM_PLC_ENABLE) - speech_plc_16000_AddToHistory((PlcSt_16000 *)speech_plc, (short *)pcm_data.data, pcm_len/2); - memcpy(pcm_buffer, pcm_data.data, pcm_len); -#endif -#ifdef SPEECH_RX_PLC_DUMP_DATA - for(uint32_t i=0; i< pcm_len/2; i++) - { - audio_dump_temp_buf[i] = -32767; - } - audio_dump_add_channel_data(0, audio_dump_temp_buf, pcm_len/2); + uint16_t bytes_encoded = 0, buf_len = MSBC_ENCODE_PCM_LEN; + PcmEncData1.data = (uint8_t *)(EncInBuf + MSBC_ENC_BUFFER_OFFSET); + PcmEncData1.dataLen = pcm_len; + PcmEncData1.numChannels = 1; + PcmEncData1.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; + btif_sbc_encode_frames(&sbc_Encoder1, &PcmEncData1, &bytes_encoded, + Encodedbuf1, &buf_len, 0xFFFF); +#ifdef __SBC_FUNC_IN_ROM__ + ret = SBC_ROM_FUNC.sbc_frames_decode( + &msbc_decoder, Encodedbuf1, MSBC_FRAME_SIZE - 3, &byte_decode, + &pcm_data, pcm_len - pcm_offset, msbc_eq_band_gain); +#else + ret = btif_sbc_decode_frames(&msbc_decoder, Encodedbuf1, + MSBC_FRAME_SIZE - 3, &byte_decode, &pcm_data, + pcm_len - pcm_offset, msbc_eq_band_gain); #endif } +#endif + TRACE(2, "b t:%d ret:%d\n", (hal_sys_timer_get() - ttt), ret); +#ifdef SPEECH_RX_PLC_DUMP_DATA + for (uint32_t i = 0; i < pcm_len / 2; i++) { + audio_dump_temp_buf[i] = 32767; + } + audio_dump_add_channel_data(0, audio_dump_temp_buf, pcm_len / 2); +#endif + } else +#endif + { + ret = btif_sbc_decode_frames(&msbc_decoder, + (unsigned char *)msbc_buf_before_decode, + msbc_next_frame_size, &byte_decode, &pcm_data, + pcm_len - pcm_offset, msbc_eq_band_gain); +#if defined(MSBC_PCM_PLC_ENABLE) + speech_plc_16000_AddToHistory((PlcSt_16000 *)speech_plc, + (short *)pcm_data.data, pcm_len / 2); + memcpy(pcm_buffer, pcm_data.data, pcm_len); +#endif +#ifdef SPEECH_RX_PLC_DUMP_DATA + for (uint32_t i = 0; i < pcm_len / 2; i++) { + audio_dump_temp_buf[i] = -32767; + } + audio_dump_add_channel_data(0, audio_dump_temp_buf, pcm_len / 2); +#endif + } #ifdef SPEECH_RX_PLC_DUMP_DATA - audio_dump_add_channel_data(1, (short *)pcm_buffer, pcm_len/2); - audio_dump_run(); + audio_dump_add_channel_data(1, (short *)pcm_buffer, pcm_len / 2); + audio_dump_run(); #endif #if 0 @@ -1276,328 +1233,293 @@ get_again: TRACE(1,"[4] %x", msbc_buf_before_decode[4]); #endif - //TRACE(2,"sbcd ret %d %d\n", ret, byte_decode); + // TRACE(2,"sbcd ret %d %d\n", ret, byte_decode); - if(ret == BT_STS_CONTINUE) - { - need_init_decoder = false; - LOCK_APP_AUDIO_QUEUE(); - VOICEBTPCM_TRACE(2,"000000 byte_decode =%d, current_len1 =%d",byte_decode, msbc_next_frame_size); - APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, byte_decode); - UNLOCK_APP_AUDIO_QUEUE(); + if (ret == BT_STS_CONTINUE) { + need_init_decoder = false; + LOCK_APP_AUDIO_QUEUE(); + VOICEBTPCM_TRACE(2, "000000 byte_decode =%d, current_len1 =%d", byte_decode, + msbc_next_frame_size); + APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, byte_decode); + UNLOCK_APP_AUDIO_QUEUE(); - msbc_next_frame_size = (MSBC_FRAME_SIZE -byte_decode)>0?(MSBC_FRAME_SIZE -byte_decode):MSBC_FRAME_SIZE; - goto get_again; - } + msbc_next_frame_size = (MSBC_FRAME_SIZE - byte_decode) > 0 + ? (MSBC_FRAME_SIZE - byte_decode) + : MSBC_FRAME_SIZE; + goto get_again; + } - else if(ret == BT_STS_SUCCESS) - { - need_init_decoder = false; - pcm_processed = pcm_data.dataLen; - pcm_data.dataLen = 0; + else if (ret == BT_STS_SUCCESS) { + need_init_decoder = false; + pcm_processed = pcm_data.dataLen; + pcm_data.dataLen = 0; - LOCK_APP_AUDIO_QUEUE(); + LOCK_APP_AUDIO_QUEUE(); #if defined(MSBC_PLC_ENABLE) - if (plc_type == 0) - { - byte_decode += 1;//padding - APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, byte_decode); - } - else - { + if (plc_type == 0) { + byte_decode += 1; // padding + APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, byte_decode); + } else { #if defined(MSBC_PCM_PLC_ENABLE) - if (plc_type == 2){ - pcm_processed = pcm_len; - }else{ - if(msbc_next_frame_size < MSBC_FRAME_SIZE) - msbc_next_frame_size += 1; //padding - APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, msbc_next_frame_size); - } -#else - if(msbc_next_frame_size < MSBC_FRAME_SIZE) - msbc_next_frame_size += 1; //padding - APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, msbc_next_frame_size); -#endif - } -#else - if(msbc_next_frame_size < MSBC_FRAME_SIZE) - msbc_next_frame_size += 1; //padding + if (plc_type == 2) { + pcm_processed = pcm_len; + } else { + if (msbc_next_frame_size < MSBC_FRAME_SIZE) + msbc_next_frame_size += 1; // padding APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, msbc_next_frame_size); + } +#else + if (msbc_next_frame_size < MSBC_FRAME_SIZE) + msbc_next_frame_size += 1; // padding + APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, msbc_next_frame_size); #endif - UNLOCK_APP_AUDIO_QUEUE(); + } +#else + if (msbc_next_frame_size < MSBC_FRAME_SIZE) + msbc_next_frame_size += 1; // padding + APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, msbc_next_frame_size); +#endif + UNLOCK_APP_AUDIO_QUEUE(); - msbc_next_frame_size = MSBC_FRAME_SIZE; + msbc_next_frame_size = MSBC_FRAME_SIZE; #if defined(MSBC_PLC_ENABLE) - // plc after a good frame - if (!msbc_can_plc) - { - msbc_can_plc = true; - } + // plc after a good frame + if (!msbc_can_plc) { + msbc_can_plc = true; + } #endif - } - else if(ret == BT_STS_FAILED) - { - need_init_decoder = true; - pcm_processed = pcm_len; - pcm_data.dataLen = 0; + } else if (ret == BT_STS_FAILED) { + need_init_decoder = true; + pcm_processed = pcm_len; + pcm_data.dataLen = 0; - memset(pcm_buffer, 0, pcm_len); - TRACE(1,"err mutelen:%d\n",pcm_processed); + memset(pcm_buffer, 0, pcm_len); + TRACE(1, "err mutelen:%d\n", pcm_processed); - LOCK_APP_AUDIO_QUEUE(); - APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, byte_decode); - UNLOCK_APP_AUDIO_QUEUE(); + LOCK_APP_AUDIO_QUEUE(); + APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, byte_decode); + UNLOCK_APP_AUDIO_QUEUE(); - msbc_next_frame_size = MSBC_FRAME_SIZE; + msbc_next_frame_size = MSBC_FRAME_SIZE; - /* leave */ - } - else if(ret == BT_STS_NO_RESOURCES) - { - need_init_decoder = true; - pcm_processed = pcm_len; - pcm_data.dataLen = 0; + /* leave */ + } else if (ret == BT_STS_NO_RESOURCES) { + need_init_decoder = true; + pcm_processed = pcm_len; + pcm_data.dataLen = 0; - memset(pcm_buffer, 0, pcm_len); - TRACE(1,"no_res mutelen:%d\n",pcm_processed); + memset(pcm_buffer, 0, pcm_len); + TRACE(1, "no_res mutelen:%d\n", pcm_processed); - LOCK_APP_AUDIO_QUEUE(); - APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, byte_decode); - UNLOCK_APP_AUDIO_QUEUE(); + LOCK_APP_AUDIO_QUEUE(); + APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, byte_decode); + UNLOCK_APP_AUDIO_QUEUE(); - msbc_next_frame_size = MSBC_FRAME_SIZE; - } + msbc_next_frame_size = MSBC_FRAME_SIZE; + } exit: - if (underflow||need_init_decoder) - { - TRACE(2,"media_msbc_decoder underflow len:%d,need_init_decoder=%d\n ", pcm_len,need_init_decoder); - } + if (underflow || need_init_decoder) { + TRACE(2, "media_msbc_decoder underflow len:%d,need_init_decoder=%d\n ", + pcm_len, need_init_decoder); + } -// TRACE(1,"pcm_processed %d", pcm_processed); + // TRACE(1,"pcm_processed %d", pcm_processed); - return pcm_processed; + return pcm_processed; } #endif #endif -//capture flow -//mic-->audioflinger capture-->store_voicebtpcm_p2m_buffer-->get_voicebtpcm_p2m_frame-->bt -//used by capture, store data from mic to memory -int store_voicebtpcm_p2m_buffer(unsigned char *buf, unsigned int len) -{ - int POSSIBLY_UNUSED size; - unsigned int avail_size = 0; - LOCK_APP_AUDIO_QUEUE(); -// merge_two_trace_to_one_track_16bits(0, (uint16_t *)buf, (uint16_t *)buf, len>>1); -// r = APP_AUDIO_EnCQueue(&voicebtpcm_p2m_queue, buf, len>>1); - avail_size = APP_AUDIO_AvailableOfCQueue(&voicebtpcm_p2m_pcm_queue); - if (len <= avail_size) - { - APP_AUDIO_EnCQueue(&voicebtpcm_p2m_pcm_queue, buf, len); - } - else - { - VOICEBTPCM_TRACE(2,"mic buff overflow %d/%d", len, avail_size); - APP_AUDIO_DeCQueue(&voicebtpcm_p2m_pcm_queue, 0, len - avail_size); - APP_AUDIO_EnCQueue(&voicebtpcm_p2m_pcm_queue, buf, len); - } - size = APP_AUDIO_LengthOfCQueue(&voicebtpcm_p2m_pcm_queue); - UNLOCK_APP_AUDIO_QUEUE(); +// capture flow +// mic-->audioflinger +// capture-->store_voicebtpcm_p2m_buffer-->get_voicebtpcm_p2m_frame-->bt used by +// capture, store data from mic to memory +int store_voicebtpcm_p2m_buffer(unsigned char *buf, unsigned int len) { + int POSSIBLY_UNUSED size; + unsigned int avail_size = 0; + LOCK_APP_AUDIO_QUEUE(); + // merge_two_trace_to_one_track_16bits(0, (uint16_t *)buf, (uint16_t *)buf, + // len>>1); r = APP_AUDIO_EnCQueue(&voicebtpcm_p2m_queue, buf, len>>1); + avail_size = APP_AUDIO_AvailableOfCQueue(&voicebtpcm_p2m_pcm_queue); + if (len <= avail_size) { + APP_AUDIO_EnCQueue(&voicebtpcm_p2m_pcm_queue, buf, len); + } else { + VOICEBTPCM_TRACE(2, "mic buff overflow %d/%d", len, avail_size); + APP_AUDIO_DeCQueue(&voicebtpcm_p2m_pcm_queue, 0, len - avail_size); + APP_AUDIO_EnCQueue(&voicebtpcm_p2m_pcm_queue, buf, len); + } + size = APP_AUDIO_LengthOfCQueue(&voicebtpcm_p2m_pcm_queue); + UNLOCK_APP_AUDIO_QUEUE(); - VOICEBTPCM_TRACE(2,"p2m :%d/%d", len, size); + VOICEBTPCM_TRACE(2, "p2m :%d/%d", len, size); - return 0; + return 0; } #if defined(HFP_1_6_ENABLE) -unsigned char get_msbc_counter(void) -{ - if (msbc_counter == 0x08) - { - msbc_counter = 0x38; - } - else if (msbc_counter == 0x38) - { - msbc_counter = 0xC8; - } - else if (msbc_counter == 0xC8) - { - msbc_counter = 0xF8; - } - else if (msbc_counter == 0xF8) - { - msbc_counter = 0x08; - } +unsigned char get_msbc_counter(void) { + if (msbc_counter == 0x08) { + msbc_counter = 0x38; + } else if (msbc_counter == 0x38) { + msbc_counter = 0xC8; + } else if (msbc_counter == 0xC8) { + msbc_counter = 0xF8; + } else if (msbc_counter == 0xF8) { + msbc_counter = 0x08; + } - return msbc_counter; + return msbc_counter; } #endif #if defined(TX_RX_PCM_MASK) CQueue Tx_esco_queue; CQueue Rx_esco_queue; -CQueue* get_tx_esco_queue_ptr() -{ - return &Tx_esco_queue; -} -CQueue* get_rx_esco_queue_ptr() -{ - return &Rx_esco_queue; -} +CQueue *get_tx_esco_queue_ptr() { return &Tx_esco_queue; } +CQueue *get_rx_esco_queue_ptr() { return &Rx_esco_queue; } #endif -//used by capture, get the memory data which has be stored by store_voicebtpcm_p2m_buffer() -int get_voicebtpcm_p2m_frame(unsigned char *buf, unsigned int len) -{ - int got_len = 0; +// used by capture, get the memory data which has be stored by +// store_voicebtpcm_p2m_buffer() +int get_voicebtpcm_p2m_frame(unsigned char *buf, unsigned int len) { + int got_len = 0; - // TRACE(2,"[%s] pcm_len = %d", __func__, len / 2); - if (voicebtpcm_cache_p2m_status == APP_AUDIO_CACHE_CACHEING) - { - app_audio_memset_16bit((short *)buf, 0, len/2); - TRACE(1,"[%s] APP_AUDIO_CACHE_CACHEING", __func__); - return len; - } + // TRACE(2,"[%s] pcm_len = %d", __func__, len / 2); + if (voicebtpcm_cache_p2m_status == APP_AUDIO_CACHE_CACHEING) { + app_audio_memset_16bit((short *)buf, 0, len / 2); + TRACE(1, "[%s] APP_AUDIO_CACHE_CACHEING", __func__); + return len; + } - int msbc_encode_temp_len = MSBC_FRAME_SIZE * 2; + int msbc_encode_temp_len = MSBC_FRAME_SIZE * 2; - ASSERT(len % msbc_encode_temp_len == 0 , "[%s] len(%d) is invalid", __func__, len); + ASSERT(len % msbc_encode_temp_len == 0, "[%s] len(%d) is invalid", __func__, + len); - int loop_cnt = len / msbc_encode_temp_len; - len = msbc_encode_temp_len; + int loop_cnt = len / msbc_encode_temp_len; + len = msbc_encode_temp_len; - for (int cnt=0; cnt48K single phase coef Number:=24, upsample factor:=6, - 64, -311, 210, -320, 363, -407, 410, -356, 196, 191,-1369,30721, 3861,-2265, 1680,-1321, 1049, -823, 625, -471, 297, -327, 34, 19, - 72, -254, 75, -117, 46, 58, -256, 583,-1141, 2197,-4866,28131,10285,-4611, 2935,-2061, 1489,-1075, 755, -523, 310, -291, -19, 31, - 65, -175, -73, 84, -245, 457, -786, 1276,-2040, 3377,-6428,23348,17094,-6200, 3592,-2347, 1588,-1073, 703, -447, 236, -203, -92, 49, - 49, -92, -203, 236, -447, 703,-1073, 1588,-2347, 3592,-6200,17094,23348,-6428, 3377,-2040, 1276, -786, 457, -245, 84, -73, -175, 65, - 31, -19, -291, 310, -523, 755,-1075, 1489,-2061, 2935,-4611,10285,28131,-4866, 2197,-1141, 583, -256, 58, 46, -117, 75, -254, 72, - 19, 34, -327, 297, -471, 625, -823, 1049,-1321, 1680,-2265, 3861,30721,-1369, 191, 196, -356, 410, -407, 363, -320, 210, -311, 64, + 64, -311, 210, -320, 363, -407, 410, -356, 196, 191,-1369,30721, +3861,-2265, 1680,-1321, 1049, -823, 625, -471, 297, -327, 34, 19, 72, +-254, 75, -117, 46, 58, -256, 583,-1141, 2197,-4866,28131,10285,-4611, +2935,-2061, 1489,-1075, 755, -523, 310, -291, -19, 31, 65, -175, -73, 84, +-245, 457, -786, 1276,-2040, 3377,-6428,23348,17094,-6200, 3592,-2347, +1588,-1073, 703, -447, 236, -203, -92, 49, 49, -92, -203, 236, -447, +703,-1073, 1588,-2347, 3592,-6200,17094,23348,-6428, 3377,-2040, 1276, -786, +457, -245, 84, -73, -175, 65, 31, -19, -291, 310, -523, 755,-1075, +1489,-2061, 2935,-4611,10285,28131,-4866, 2197,-1141, 583, -256, 58, 46, +-117, 75, -254, 72, 19, 34, -327, 297, -471, 625, -823, 1049,-1321, +1680,-2265, 3861,30721,-1369, 191, 196, -356, 410, -407, 363, -320, 210, +-311, 64, */ -const static short coef_8k_upto_48k[6][US_COEF_NUM]__attribute__((section(".sram_data"))) = -{ - {64, -311, 210, -320, 363, -407, 410, -356, 196, 191,-1369,30721, 3861,-2265, 1680,-1321, 1049, -823, 625, -471, 297, -327, 34, 19}, - {72, -254, 75, -117, 46, 58, -256, 583,-1141, 2197,-4866,28131,10285,-4611, 2935,-2061, 1489,-1075, 755, -523, 310, -291, -19, 31 }, - {65, -175, -73, 84, -245, 457, -786, 1276,-2040, 3377,-6428,23348,17094,-6200, 3592,-2347, 1588,-1073, 703, -447, 236, -203, -92, 49 }, - {49, -92, -203, 236, -447, 703,-1073, 1588,-2347, 3592,-6200,17094,23348,-6428, 3377,-2040, 1276, -786, 457, -245, 84, -73, -175, 65 }, - {31, -19, -291, 310, -523, 755,-1075, 1489,-2061, 2935,-4611,10285,28131,-4866, 2197,-1141, 583, -256, 58, 46, -117, 75, -254, 72 }, - {19, 34, -327, 297, -471, 625, -823, 1049,-1321, 1680,-2265, 3861,30721,-1369, 191, 196, -356, 410, -407, 363, -320, 210, -311, 64 } -}; +const static short coef_8k_upto_48k[6][US_COEF_NUM] __attribute__(( + section(".sram_data"))) = { + {64, -311, 210, -320, 363, -407, 410, -356, 196, 191, -1369, 30721, + 3861, -2265, 1680, -1321, 1049, -823, 625, -471, 297, -327, 34, 19}, + {72, -254, 75, -117, 46, 58, -256, 583, + -1141, 2197, -4866, 28131, 10285, -4611, 2935, -2061, + 1489, -1075, 755, -523, 310, -291, -19, 31}, + {65, -175, -73, 84, -245, 457, -786, 1276, + -2040, 3377, -6428, 23348, 17094, -6200, 3592, -2347, + 1588, -1073, 703, -447, 236, -203, -92, 49}, + {49, -92, -203, 236, -447, 703, -1073, 1588, + -2347, 3592, -6200, 17094, 23348, -6428, 3377, -2040, + 1276, -786, 457, -245, 84, -73, -175, 65}, + {31, -19, -291, 310, -523, 755, -1075, 1489, + -2061, 2935, -4611, 10285, 28131, -4866, 2197, -1141, + 583, -256, 58, 46, -117, 75, -254, 72}, + {19, 34, -327, 297, -471, 625, -823, 1049, -1321, 1680, -2265, 3861, + 30721, -1369, 191, 196, -356, 410, -407, 363, -320, 210, -311, 64}}; /* 16K -->48K single phase coef Number:=24, upsample factor:=3, - 1, -291, 248, -327, 383, -405, 362, -212, -129, 875,-2948,29344, 7324,-3795, 2603,-1913, 1418,-1031, 722, -478, 292, -220, -86, 16, - 26, -212, 6, 45, -185, 414, -764, 1290,-2099, 3470,-6431,20320,20320,-6431, 3470,-2099, 1290, -764, 414, -185, 45, 6, -212, 26, - 16, -86, -220, 292, -478, 722,-1031, 1418,-1913, 2603,-3795, 7324,29344,-2948, 875, -129, -212, 362, -405, 383, -327, 248, -291, 1, + 1, -291, 248, -327, 383, -405, 362, -212, -129, 875,-2948,29344, +7324,-3795, 2603,-1913, 1418,-1031, 722, -478, 292, -220, -86, 16, 26, +-212, 6, 45, -185, 414, -764, 1290,-2099, 3470,-6431,20320,20320,-6431, +3470,-2099, 1290, -764, 414, -185, 45, 6, -212, 26, 16, -86, -220, 292, +-478, 722,-1031, 1418,-1913, 2603,-3795, 7324,29344,-2948, 875, -129, -212, +362, -405, 383, -327, 248, -291, 1, */ -const static short coef_16k_upto_48k[3][US_COEF_NUM] __attribute__((section(".sram_data"))) = -{ - {1, -291, 248, -327, 383, -405, 362, -212, -129, 875,-2948,29344, 7324,-3795, 2603,-1913, 1418,-1031, 722, -478, 292, -220, -86, 16}, - {26, -212, 6, 45, -185, 414, -764, 1290,-2099, 3470,-6431,20320,20320,-6431, 3470,-2099, 1290, -764, 414, -185, 45, 6, -212, 26}, - {16, -86, -220, 292, -478, 722,-1031, 1418,-1913, 2603,-3795, 7324,29344,-2948, 875, -129, -212, 362, -405, 383, -327, 248, -291, 1} -}; +const static short coef_16k_upto_48k[3][US_COEF_NUM] __attribute__(( + section(".sram_data"))) = { + {1, -291, 248, -327, 383, -405, 362, -212, -129, 875, -2948, 29344, + 7324, -3795, 2603, -1913, 1418, -1031, 722, -478, 292, -220, -86, 16}, + {26, -212, 6, 45, -185, 414, -764, 1290, + -2099, 3470, -6431, 20320, 20320, -6431, 3470, -2099, + 1290, -764, 414, -185, 45, 6, -212, 26}, + {16, -86, -220, 292, -478, 722, -1031, 1418, -1913, 2603, -3795, 7324, + 29344, -2948, 875, -129, -212, 362, -405, 383, -327, 248, -291, 1}}; -static short us_para_lst[US_COEF_NUM-1]; +static short us_para_lst[US_COEF_NUM - 1]; -static inline short us_get_coef_para(U32 samp_idx,U32 coef_idx) -{ - if(bt_sco_samplerate_ratio == 6) - return coef_8k_upto_48k[samp_idx][coef_idx]; - else - return coef_16k_upto_48k[samp_idx][coef_idx]; +static inline short us_get_coef_para(U32 samp_idx, U32 coef_idx) { + if (bt_sco_samplerate_ratio == 6) + return coef_8k_upto_48k[samp_idx][coef_idx]; + else + return coef_16k_upto_48k[samp_idx][coef_idx]; } -void us_fir_init (void) -{ - app_audio_memset_16bit(us_para_lst, 0, sizeof(us_para_lst)/sizeof(short)); +void us_fir_init(void) { + app_audio_memset_16bit(us_para_lst, 0, sizeof(us_para_lst) / sizeof(short)); } +__attribute__((section(".fast_text_sram"))) U32 +us_fir_run(short *src_buf, short *dst_buf, U32 in_samp_num) { + U32 in_idx, samp_idx, coef_idx, real_idx, out_idx; + int para, out; -__attribute__((section(".fast_text_sram"))) U32 us_fir_run (short* src_buf, short* dst_buf, U32 in_samp_num) -{ - U32 in_idx, samp_idx, coef_idx, real_idx, out_idx; - int para, out; + for (in_idx = 0, out_idx = 0; in_idx < in_samp_num; in_idx++) { + for (samp_idx = 0; samp_idx < bt_sco_samplerate_ratio; samp_idx++) { + out = 0; + for (coef_idx = 0; coef_idx < US_COEF_NUM; coef_idx++) { + real_idx = coef_idx + in_idx; + para = (real_idx < (US_COEF_NUM - 1)) + ? us_para_lst[real_idx] + : src_buf[real_idx - (US_COEF_NUM - 1)]; + out += para * us_get_coef_para(samp_idx, coef_idx); + } - for (in_idx = 0, out_idx = 0; in_idx < in_samp_num; in_idx++) - { - for (samp_idx = 0; samp_idx < bt_sco_samplerate_ratio; samp_idx++) - { - out = 0; - for (coef_idx = 0; coef_idx < US_COEF_NUM; coef_idx++) - { - real_idx = coef_idx + in_idx; - para = (real_idx < (US_COEF_NUM-1))?us_para_lst[real_idx]:src_buf[real_idx - (US_COEF_NUM-1)]; - out += para * us_get_coef_para(samp_idx,coef_idx); - } - - dst_buf[out_idx] = (short)(out>>16); - out_idx++; - } + dst_buf[out_idx] = (short)(out >> 16); + out_idx++; } + } - if (in_samp_num >= (US_COEF_NUM-1)) - { - app_audio_memcpy_16bit(us_para_lst, - (src_buf+in_samp_num-US_COEF_NUM+1), - (US_COEF_NUM-1)); - } - else - { - U32 start_idx = (US_COEF_NUM-1-in_samp_num); + if (in_samp_num >= (US_COEF_NUM - 1)) { + app_audio_memcpy_16bit(us_para_lst, + (src_buf + in_samp_num - US_COEF_NUM + 1), + (US_COEF_NUM - 1)); + } else { + U32 start_idx = (US_COEF_NUM - 1 - in_samp_num); - app_audio_memcpy_16bit(us_para_lst, - (us_para_lst+in_samp_num), - start_idx); + app_audio_memcpy_16bit(us_para_lst, (us_para_lst + in_samp_num), start_idx); - app_audio_memcpy_16bit((us_para_lst + start_idx), - src_buf, - in_samp_num); - } - return out_idx; + app_audio_memcpy_16bit((us_para_lst + start_idx), src_buf, in_samp_num); + } + return out_idx; } -uint32_t voicebtpcm_pcm_resample (short* src_samp_buf, uint32_t src_smpl_cnt, short* dst_samp_buf) -{ - return us_fir_run (src_samp_buf, dst_samp_buf, src_smpl_cnt); +uint32_t voicebtpcm_pcm_resample(short *src_samp_buf, uint32_t src_smpl_cnt, + short *dst_samp_buf) { + return us_fir_run(src_samp_buf, dst_samp_buf, src_smpl_cnt); } #endif static int speech_tx_aec_frame_len = 0; -int speech_tx_aec_get_frame_len(void) -{ - return speech_tx_aec_frame_len; -} +int speech_tx_aec_get_frame_len(void) { return speech_tx_aec_frame_len; } -void speech_tx_aec_set_frame_len(int len) -{ - TRACE(2,"[%s] len = %d", __func__, len); - speech_tx_aec_frame_len = len; +void speech_tx_aec_set_frame_len(int len) { + TRACE(2, "[%s] len = %d", __func__, len); + speech_tx_aec_frame_len = len; } #if 1 -//used by capture, store data from mic to memory -uint32_t voicebtpcm_pcm_audio_data_come(uint8_t *buf, uint32_t len) -{ - int16_t POSSIBLY_UNUSED ret = 0; - bool POSSIBLY_UNUSED vdt = false; - int size = 0; +// used by capture, store data from mic to memory +uint32_t voicebtpcm_pcm_audio_data_come(uint8_t *buf, uint32_t len) { + int16_t POSSIBLY_UNUSED ret = 0; + bool POSSIBLY_UNUSED vdt = false; + int size = 0; -#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) +#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || \ + defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) #if defined(__AUDIO_RESAMPLE__) && defined(SW_SCO_RESAMPLE) - uint32_t queue_len; + uint32_t queue_len; - uint32_t len_per_channel = len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM; + uint32_t len_per_channel = len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM; - ASSERT(len_per_channel == speech_tx_aec_get_frame_len() * sizeof(short), "%s: Unmatched len: %u != %u", __func__, len_per_channel, speech_tx_aec_get_frame_len() * sizeof(short)); - ASSERT(echo_buf_q_rpos + len_per_channel <= echo_buf_q_size, "%s: rpos (%u) overflow: len=%u size=%u", __func__, echo_buf_q_rpos, len_per_channel, echo_buf_q_size); + ASSERT(len_per_channel == speech_tx_aec_get_frame_len() * sizeof(short), + "%s: Unmatched len: %u != %u", __func__, len_per_channel, + speech_tx_aec_get_frame_len() * sizeof(short)); + ASSERT(echo_buf_q_rpos + len_per_channel <= echo_buf_q_size, + "%s: rpos (%u) overflow: len=%u size=%u", __func__, echo_buf_q_rpos, + len_per_channel, echo_buf_q_size); - if (echo_buf_q_rpos == echo_buf_q_wpos) { - queue_len = echo_buf_q_full ? echo_buf_q_size : 0; - echo_buf_q_full = false; - } else if (echo_buf_q_rpos < echo_buf_q_wpos) { - queue_len = echo_buf_q_wpos - echo_buf_q_rpos; - } else { - queue_len = echo_buf_q_size + echo_buf_q_wpos - echo_buf_q_rpos; - } - ASSERT(queue_len >= len_per_channel, "%s: queue underflow: q_len=%u len=%u rpos=%u wpos=%u size=%u", - __func__, queue_len, len_per_channel, echo_buf_q_rpos, echo_buf_q_wpos, echo_buf_q_size); + if (echo_buf_q_rpos == echo_buf_q_wpos) { + queue_len = echo_buf_q_full ? echo_buf_q_size : 0; + echo_buf_q_full = false; + } else if (echo_buf_q_rpos < echo_buf_q_wpos) { + queue_len = echo_buf_q_wpos - echo_buf_q_rpos; + } else { + queue_len = echo_buf_q_size + echo_buf_q_wpos - echo_buf_q_rpos; + } + ASSERT(queue_len >= len_per_channel, + "%s: queue underflow: q_len=%u len=%u rpos=%u wpos=%u size=%u", + __func__, queue_len, len_per_channel, echo_buf_q_rpos, echo_buf_q_wpos, + echo_buf_q_size); - aec_echo_buf = (int16_t *)(echo_buf_queue + echo_buf_q_rpos); - echo_buf_q_rpos += len_per_channel; - if (echo_buf_q_rpos >= echo_buf_q_size) { - echo_buf_q_rpos = 0; - } + aec_echo_buf = (int16_t *)(echo_buf_queue + echo_buf_q_rpos); + echo_buf_q_rpos += len_per_channel; + if (echo_buf_q_rpos >= echo_buf_q_size) { + echo_buf_q_rpos = 0; + } #endif #endif - short *pcm_buf = (short*)buf; + short *pcm_buf = (short *)buf; #if defined(SPEECH_TX_24BIT) - int pcm_len = len / sizeof(int32_t); + int pcm_len = len / sizeof(int32_t); #else - int pcm_len = len / sizeof(int16_t); + int pcm_len = len / sizeof(int16_t); #endif - if(app_get_current_overlay() == APP_OVERLAY_HFP){ - speech_tx_process(pcm_buf, aec_echo_buf, &pcm_len); + if (app_get_current_overlay() == APP_OVERLAY_HFP) { + speech_tx_process(pcm_buf, aec_echo_buf, &pcm_len); #if defined(SPEECH_TX_24BIT) - int32_t *buf24 = (int32_t *)pcm_buf; - int16_t *buf16 = (int16_t *)pcm_buf; - for (int i = 0; i < pcm_len; i++) - buf16[i] = (buf24[i] >> 8); + int32_t *buf24 = (int32_t *)pcm_buf; + int16_t *buf16 = (int16_t *)pcm_buf; + for (int i = 0; i < pcm_len; i++) + buf16[i] = (buf24[i] >> 8); #endif - if (resample_needed_flag == true) { - iir_resample_process(upsample_st, pcm_buf, upsample_buf_for_msbc, pcm_len); - pcm_buf = upsample_buf_for_msbc; - pcm_len = sco_frame_length; - } - }else{ - memset(buf, 0, len); + if (resample_needed_flag == true) { + iir_resample_process(upsample_st, pcm_buf, upsample_buf_for_msbc, + pcm_len); + pcm_buf = upsample_buf_for_msbc; + pcm_len = sco_frame_length; } + } else { + memset(buf, 0, len); + } - LOCK_APP_AUDIO_QUEUE(); - store_voicebtpcm_p2m_buffer((uint8_t *)pcm_buf, pcm_len * sizeof(short)); - size = APP_AUDIO_LengthOfCQueue(&voicebtpcm_p2m_pcm_queue); - UNLOCK_APP_AUDIO_QUEUE(); + LOCK_APP_AUDIO_QUEUE(); + store_voicebtpcm_p2m_buffer((uint8_t *)pcm_buf, pcm_len * sizeof(short)); + size = APP_AUDIO_LengthOfCQueue(&voicebtpcm_p2m_pcm_queue); + UNLOCK_APP_AUDIO_QUEUE(); - if (size >= voicebtpcm_p2m_cache_threshold) - { - voicebtpcm_cache_p2m_status = APP_AUDIO_CACHE_OK; - } + if (size >= voicebtpcm_p2m_cache_threshold) { + voicebtpcm_cache_p2m_status = APP_AUDIO_CACHE_OK; + } - return pcm_len*2; + return pcm_len * 2; } #else -//used by capture, store data from mic to memory -uint32_t voicebtpcm_pcm_audio_data_come(uint8_t *buf, uint32_t len) -{ - int16_t POSSIBLY_UNUSED ret = 0; - bool POSSIBLY_UNUSED vdt = false; - int size = 0; +// used by capture, store data from mic to memory +uint32_t voicebtpcm_pcm_audio_data_come(uint8_t *buf, uint32_t len) { + int16_t POSSIBLY_UNUSED ret = 0; + bool POSSIBLY_UNUSED vdt = false; + int size = 0; - short *pcm_buf = (short*)buf; - uint32_t pcm_len = len / 2; + short *pcm_buf = (short *)buf; + uint32_t pcm_len = len / 2; - // TRACE(2,"[%s] pcm_len = %d", __func__, pcm_len); + // TRACE(2,"[%s] pcm_len = %d", __func__, pcm_len); - LOCK_APP_AUDIO_QUEUE(); - store_voicebtpcm_p2m_buffer((uint8_t *)pcm_buf, pcm_len*2); - size = APP_AUDIO_LengthOfCQueue(&voicebtpcm_p2m_queue); - UNLOCK_APP_AUDIO_QUEUE(); + LOCK_APP_AUDIO_QUEUE(); + store_voicebtpcm_p2m_buffer((uint8_t *)pcm_buf, pcm_len * 2); + size = APP_AUDIO_LengthOfCQueue(&voicebtpcm_p2m_queue); + UNLOCK_APP_AUDIO_QUEUE(); - if (size > VOICEBTPCM_PCM_TEMP_BUFFER_SIZE) - { - voicebtpcm_cache_p2m_status = APP_AUDIO_CACHE_OK; - } + if (size > VOICEBTPCM_PCM_TEMP_BUFFER_SIZE) { + voicebtpcm_cache_p2m_status = APP_AUDIO_CACHE_OK; + } - return pcm_len*2; + return pcm_len * 2; } #endif -//used by playback, play data from memory to speaker -uint32_t voicebtpcm_pcm_audio_more_data(uint8_t *buf, uint32_t len) -{ - uint32_t l = 0; - //TRACE(3,"[%s]: pcm_len = %d, %d", __FUNCTION__, len / 2, FAST_TICKS_TO_US(hal_fast_sys_timer_get())); - if ((voicebtpcm_cache_m2p_status == APP_AUDIO_CACHE_CACHEING) +// used by playback, play data from memory to speaker +uint32_t voicebtpcm_pcm_audio_more_data(uint8_t *buf, uint32_t len) { + uint32_t l = 0; + // TRACE(3,"[%s]: pcm_len = %d, %d", __FUNCTION__, len / 2, + // FAST_TICKS_TO_US(hal_fast_sys_timer_get())); + if ((voicebtpcm_cache_m2p_status == APP_AUDIO_CACHE_CACHEING) #ifndef FPGA - ||(app_get_current_overlay() != APP_OVERLAY_HFP) + || (app_get_current_overlay() != APP_OVERLAY_HFP) #endif - ) - { - app_audio_memset_16bit((short *)buf, 0, len/2); - l = len; - } - else - { -#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) || defined(SPEECH_TX_THIRDPARTY) + ) { + app_audio_memset_16bit((short *)buf, 0, len / 2); + l = len; + } else { +#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || \ + defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) || \ + defined(SPEECH_TX_THIRDPARTY) #if !(defined(__AUDIO_RESAMPLE__) && defined(SW_SCO_RESAMPLE)) #if defined(SPEECH_TX_24BIT) && defined(SPEECH_RX_24BIT) - memcpy(aec_echo_buf, buf, len / sizeof(int16_t) * sizeof(int32_t)); + memcpy(aec_echo_buf, buf, len / sizeof(int16_t) * sizeof(int32_t)); #elif defined(SPEECH_TX_24BIT) && !defined(SPEECH_RX_24BIT) - short *buf_p=(short *)buf; - for (uint32_t i = 0; i < len / sizeof(int16_t); i++) { - aec_echo_buf[i] = ((int32_t)buf_p[i] << 8); - } -#elif !defined(SPEECH_TX_24BIT) && defined(SPEECH_RX_24BIT) - int32_t *buf32_p = (int32_t *)buf; - for (uint32_t i = 0; i < len / sizeof(int16_t); i++) { - aec_echo_buf[i] = (buf32_p[i] >> 8); - } -#else - app_audio_memcpy_16bit((int16_t *)aec_echo_buf, (int16_t *)buf, len/2); -#endif -#endif -#endif - - int decode_len = len; - uint8_t *decode_buf = buf; - - if (resample_needed_flag == true) { - decode_len = sco_frame_length * 2; - decode_buf = (uint8_t *)downsample_buf_for_msbc; - } - - unsigned int len1 = 0, len2 = 0; - unsigned char *e1 = NULL, *e2 = NULL; - int r = 0; - - LOCK_APP_AUDIO_QUEUE(); - len1 = len2 = 0; - e1 = e2 = 0; - r = APP_AUDIO_PeekCQueue(&voicebtpcm_m2p_pcm_queue, decode_len, &e1, &len1, &e2, &len2); - UNLOCK_APP_AUDIO_QUEUE(); - if (r == CQ_ERR) - { - TRACE(0,"pcm buff underflow"); - memset(decode_buf, 0, decode_len); - l = len; - goto fail; - } - - if (!len1) - { - TRACE(2,"pcm len1 underflow %d/%d\n", len1, len2); - memset(decode_buf, 0, decode_len); - l = len; - goto fail; - } - - if (len1 > 0 && e1) - { - memcpy(decode_buf, e1, len1); - } - if (len2 > 0 && e2) - { - memcpy(decode_buf + len1, e2, len2); - } - LOCK_APP_AUDIO_QUEUE(); - APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, decode_len); - UNLOCK_APP_AUDIO_QUEUE(); - } // if (voicebtpcm_cache_m2p_status == APP_AUDIO_CACHE_CACHEING) - - // downsample_buf_for_msbc size is len * 2 - if (resample_needed_flag == true) { - iir_resample_process(downsample_st, downsample_buf_for_msbc, (int16_t *)buf, sco_frame_length); + short *buf_p = (short *)buf; + for (uint32_t i = 0; i < len / sizeof(int16_t); i++) { + aec_echo_buf[i] = ((int32_t)buf_p[i] << 8); } +#elif !defined(SPEECH_TX_24BIT) && defined(SPEECH_RX_24BIT) + int32_t *buf32_p = (int32_t *)buf; + for (uint32_t i = 0; i < len / sizeof(int16_t); i++) { + aec_echo_buf[i] = (buf32_p[i] >> 8); + } +#else + app_audio_memcpy_16bit((int16_t *)aec_echo_buf, (int16_t *)buf, len / 2); +#endif +#endif +#endif + + int decode_len = len; + uint8_t *decode_buf = buf; + + if (resample_needed_flag == true) { + decode_len = sco_frame_length * 2; + decode_buf = (uint8_t *)downsample_buf_for_msbc; + } + + unsigned int len1 = 0, len2 = 0; + unsigned char *e1 = NULL, *e2 = NULL; + int r = 0; + + LOCK_APP_AUDIO_QUEUE(); + len1 = len2 = 0; + e1 = e2 = 0; + r = APP_AUDIO_PeekCQueue(&voicebtpcm_m2p_pcm_queue, decode_len, &e1, &len1, + &e2, &len2); + UNLOCK_APP_AUDIO_QUEUE(); + if (r == CQ_ERR) { + TRACE(0, "pcm buff underflow"); + memset(decode_buf, 0, decode_len); + l = len; + goto fail; + } + + if (!len1) { + TRACE(2, "pcm len1 underflow %d/%d\n", len1, len2); + memset(decode_buf, 0, decode_len); + l = len; + goto fail; + } + + if (len1 > 0 && e1) { + memcpy(decode_buf, e1, len1); + } + if (len2 > 0 && e2) { + memcpy(decode_buf + len1, e2, len2); + } + LOCK_APP_AUDIO_QUEUE(); + APP_AUDIO_DeCQueue(&voicebtpcm_m2p_pcm_queue, 0, decode_len); + UNLOCK_APP_AUDIO_QUEUE(); + } // if (voicebtpcm_cache_m2p_status == APP_AUDIO_CACHE_CACHEING) + + // downsample_buf_for_msbc size is len * 2 + if (resample_needed_flag == true) { + iir_resample_process(downsample_st, downsample_buf_for_msbc, (int16_t *)buf, + sco_frame_length); + } fail: - short * POSSIBLY_UNUSED pcm_buf = (short*)buf; - int POSSIBLY_UNUSED pcm_len = len / 2; + short *POSSIBLY_UNUSED pcm_buf = (short *)buf; + int POSSIBLY_UNUSED pcm_len = len / 2; #if defined(SPEECH_RX_24BIT) - int32_t *buf32 = (int32_t *)buf; - for (int i = pcm_len - 1; i >= 0; i--) { - buf32[i] = ((int32_t)pcm_buf[i] << 8); - } + int32_t *buf32 = (int32_t *)buf; + for (int i = pcm_len - 1; i >= 0; i--) { + buf32[i] = ((int32_t)pcm_buf[i] << 8); + } #endif - speech_rx_process(pcm_buf, &pcm_len); + speech_rx_process(pcm_buf, &pcm_len); - buf = (uint8_t *)pcm_buf; - len = pcm_len * sizeof(short); + buf = (uint8_t *)pcm_buf; + len = pcm_len * sizeof(short); #if defined(SPEECH_RX_24BIT) - len = len / sizeof(int16_t) * sizeof(int32_t); + len = len / sizeof(int16_t) * sizeof(int32_t); #endif -#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) +#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || \ + defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) #if defined(__AUDIO_RESAMPLE__) && defined(SW_SCO_RESAMPLE) - uint32_t queue_len; + uint32_t queue_len; - ASSERT(len == speech_tx_aec_get_frame_len() * sizeof(short), "%s: Unmatched len: %u != %u", __func__, len, speech_tx_aec_get_frame_len() * sizeof(short)); - ASSERT(echo_buf_q_wpos + len <= echo_buf_q_size, "%s: wpos (%u) overflow: len=%u size=%u", __func__, echo_buf_q_wpos, len, echo_buf_q_size); + ASSERT(len == speech_tx_aec_get_frame_len() * sizeof(short), + "%s: Unmatched len: %u != %u", __func__, len, + speech_tx_aec_get_frame_len() * sizeof(short)); + ASSERT(echo_buf_q_wpos + len <= echo_buf_q_size, + "%s: wpos (%u) overflow: len=%u size=%u", __func__, echo_buf_q_wpos, + len, echo_buf_q_size); - if (echo_buf_q_rpos == echo_buf_q_wpos) { - queue_len = echo_buf_q_full ? echo_buf_q_size : 0; - } else if (echo_buf_q_rpos < echo_buf_q_wpos) { - queue_len = echo_buf_q_wpos - echo_buf_q_rpos; - } else { - queue_len = echo_buf_q_size + echo_buf_q_wpos - echo_buf_q_rpos; - } - ASSERT(queue_len + len <= echo_buf_q_size, "%s: queue overflow: q_len=%u len=%u rpos=%u wpos=%u size=%u", - __func__, queue_len, len, echo_buf_q_rpos, echo_buf_q_wpos, echo_buf_q_size); + if (echo_buf_q_rpos == echo_buf_q_wpos) { + queue_len = echo_buf_q_full ? echo_buf_q_size : 0; + } else if (echo_buf_q_rpos < echo_buf_q_wpos) { + queue_len = echo_buf_q_wpos - echo_buf_q_rpos; + } else { + queue_len = echo_buf_q_size + echo_buf_q_wpos - echo_buf_q_rpos; + } + ASSERT(queue_len + len <= echo_buf_q_size, + "%s: queue overflow: q_len=%u len=%u rpos=%u wpos=%u size=%u", + __func__, queue_len, len, echo_buf_q_rpos, echo_buf_q_wpos, + echo_buf_q_size); - app_audio_memcpy_16bit((int16_t *)(echo_buf_queue + echo_buf_q_wpos), (int16_t *)buf, len / 2); - echo_buf_q_wpos += len; - if (echo_buf_q_wpos >= echo_buf_q_size) { - echo_buf_q_wpos = 0; - } - if (echo_buf_q_rpos == echo_buf_q_wpos) { - echo_buf_q_full = true; - } -#endif -#endif - - return l; -} - -void *voicebtpcm_get_ext_buff(int size) -{ - uint8_t *pBuff = NULL; - if (size % 4) - { - size = size + (4 - size % 4); - } - app_audio_mempool_get_buff(&pBuff, size); - VOICEBTPCM_TRACE(2,"[%s] len:%d", __func__, size); - return (void*)pBuff; -} - -int voicebtpcm_pcm_echo_buf_queue_init(uint32_t size) -{ -#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) -#if defined(__AUDIO_RESAMPLE__) && defined(SW_SCO_RESAMPLE) - echo_buf_queue = (uint8_t *)voicebtpcm_get_ext_buff(size); - echo_buf_q_size = size; + app_audio_memcpy_16bit((int16_t *)(echo_buf_queue + echo_buf_q_wpos), + (int16_t *)buf, len / 2); + echo_buf_q_wpos += len; + if (echo_buf_q_wpos >= echo_buf_q_size) { echo_buf_q_wpos = 0; - echo_buf_q_rpos = 0; - echo_buf_q_full = false; + } + if (echo_buf_q_rpos == echo_buf_q_wpos) { + echo_buf_q_full = true; + } #endif #endif - return 0; + + return l; } -void voicebtpcm_pcm_echo_buf_queue_reset(void) -{ -#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) +void *voicebtpcm_get_ext_buff(int size) { + uint8_t *pBuff = NULL; + if (size % 4) { + size = size + (4 - size % 4); + } + app_audio_mempool_get_buff(&pBuff, size); + VOICEBTPCM_TRACE(2, "[%s] len:%d", __func__, size); + return (void *)pBuff; +} + +int voicebtpcm_pcm_echo_buf_queue_init(uint32_t size) { +#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || \ + defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) #if defined(__AUDIO_RESAMPLE__) && defined(SW_SCO_RESAMPLE) - echo_buf_q_wpos = 0; - echo_buf_q_rpos = 0; - echo_buf_q_full = false; + echo_buf_queue = (uint8_t *)voicebtpcm_get_ext_buff(size); + echo_buf_q_size = size; + echo_buf_q_wpos = 0; + echo_buf_q_rpos = 0; + echo_buf_q_full = false; +#endif +#endif + return 0; +} + +void voicebtpcm_pcm_echo_buf_queue_reset(void) { +#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || \ + defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) +#if defined(__AUDIO_RESAMPLE__) && defined(SW_SCO_RESAMPLE) + echo_buf_q_wpos = 0; + echo_buf_q_rpos = 0; + echo_buf_q_full = false; #endif #endif } -void voicebtpcm_pcm_echo_buf_queue_deinit(void) -{ -#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) +void voicebtpcm_pcm_echo_buf_queue_deinit(void) { +#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || \ + defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) #if defined(__AUDIO_RESAMPLE__) && defined(SW_SCO_RESAMPLE) - echo_buf_queue = NULL; - echo_buf_q_size = 0; - echo_buf_q_wpos = 0; - echo_buf_q_rpos = 0; - echo_buf_q_full = false; + echo_buf_queue = NULL; + echo_buf_q_size = 0; + echo_buf_q_wpos = 0; + echo_buf_q_rpos = 0; + echo_buf_q_full = false; #endif #endif } @@ -2044,232 +1979,247 @@ extern enum AUD_SAMPRATE_T speech_codec_get_sample_rate(void); // sco sample rate: encoder/decoder sample rate // codec sample rate: hardware sample rate -int voicebtpcm_pcm_audio_init(int sco_sample_rate, int codec_sample_rate) -{ - uint8_t POSSIBLY_UNUSED *speech_buf = NULL; - int POSSIBLY_UNUSED speech_len = 0; +int voicebtpcm_pcm_audio_init(int sco_sample_rate, int codec_sample_rate) { + uint8_t POSSIBLY_UNUSED *speech_buf = NULL; + int POSSIBLY_UNUSED speech_len = 0; - sco_frame_length = SPEECH_FRAME_MS_TO_LEN(sco_sample_rate, SPEECH_SCO_FRAME_MS); - codec_frame_length = SPEECH_FRAME_MS_TO_LEN(codec_sample_rate, SPEECH_SCO_FRAME_MS); + sco_frame_length = + SPEECH_FRAME_MS_TO_LEN(sco_sample_rate, SPEECH_SCO_FRAME_MS); + codec_frame_length = + SPEECH_FRAME_MS_TO_LEN(codec_sample_rate, SPEECH_SCO_FRAME_MS); - TRACE(3,"[%s] TX: sample rate = %d, frame len = %d", __func__, codec_sample_rate, codec_frame_length); - TRACE(3,"[%s] RX: sample rate = %d, frame len = %d", __func__, codec_sample_rate, codec_frame_length); + TRACE(3, "[%s] TX: sample rate = %d, frame len = %d", __func__, + codec_sample_rate, codec_frame_length); + TRACE(3, "[%s] RX: sample rate = %d, frame len = %d", __func__, + codec_sample_rate, codec_frame_length); - // init cqueue - uint8_t *p2m_pcm_buff = NULL; - uint8_t *m2p_pcm_buff = NULL; + // init cqueue + uint8_t *p2m_pcm_buff = NULL; + uint8_t *m2p_pcm_buff = NULL; #if defined(TX_RX_PCM_MASK) - uint8_t *Mic_frame_buff = NULL; - uint8_t *Rx_esco_buff = NULL; - uint32_t pcm_buf_size= 240*sizeof(uint8_t); + uint8_t *Mic_frame_buff = NULL; + uint8_t *Rx_esco_buff = NULL; + uint32_t pcm_buf_size = 240 * sizeof(uint8_t); #endif - if (bt_sco_codec_is_msbc()) - { - voicebtpcm_p2m_pcm_cache_size=VOICEBTPCM_PCM_16K_QUEUE_SIZE; - voicebtpcm_m2p_pcm_cache_size=VOICEBTPCM_PCM_16K_QUEUE_SIZE; - } - else - { - voicebtpcm_p2m_pcm_cache_size=VOICEBTPCM_PCM_8K_QUEUE_SIZE; - voicebtpcm_m2p_pcm_cache_size=VOICEBTPCM_PCM_8K_QUEUE_SIZE; - } + if (bt_sco_codec_is_msbc()) { + voicebtpcm_p2m_pcm_cache_size = VOICEBTPCM_PCM_16K_QUEUE_SIZE; + voicebtpcm_m2p_pcm_cache_size = VOICEBTPCM_PCM_16K_QUEUE_SIZE; + } else { + voicebtpcm_p2m_pcm_cache_size = VOICEBTPCM_PCM_8K_QUEUE_SIZE; + voicebtpcm_m2p_pcm_cache_size = VOICEBTPCM_PCM_8K_QUEUE_SIZE; + } - voicebtpcm_p2m_cache_threshold=voicebtpcm_p2m_pcm_cache_size/2; - voicebtpcm_m2p_cache_threshold=voicebtpcm_m2p_pcm_cache_size/2; + voicebtpcm_p2m_cache_threshold = voicebtpcm_p2m_pcm_cache_size / 2; + voicebtpcm_m2p_cache_threshold = voicebtpcm_m2p_pcm_cache_size / 2; - app_audio_mempool_get_buff(&p2m_pcm_buff, voicebtpcm_p2m_pcm_cache_size); - app_audio_mempool_get_buff(&m2p_pcm_buff, voicebtpcm_m2p_pcm_cache_size); + app_audio_mempool_get_buff(&p2m_pcm_buff, voicebtpcm_p2m_pcm_cache_size); + app_audio_mempool_get_buff(&m2p_pcm_buff, voicebtpcm_m2p_pcm_cache_size); #if defined(TX_RX_PCM_MASK) - app_audio_mempool_get_buff(&Mic_frame_buff, pcm_buf_size); - app_audio_mempool_get_buff(&Rx_esco_buff, pcm_buf_size); + app_audio_mempool_get_buff(&Mic_frame_buff, pcm_buf_size); + app_audio_mempool_get_buff(&Rx_esco_buff, pcm_buf_size); #endif - LOCK_APP_AUDIO_QUEUE(); - APP_AUDIO_InitCQueue(&voicebtpcm_p2m_pcm_queue, voicebtpcm_p2m_pcm_cache_size, p2m_pcm_buff); - APP_AUDIO_InitCQueue(&voicebtpcm_m2p_pcm_queue, voicebtpcm_m2p_pcm_cache_size, m2p_pcm_buff); + LOCK_APP_AUDIO_QUEUE(); + APP_AUDIO_InitCQueue(&voicebtpcm_p2m_pcm_queue, voicebtpcm_p2m_pcm_cache_size, + p2m_pcm_buff); + APP_AUDIO_InitCQueue(&voicebtpcm_m2p_pcm_queue, voicebtpcm_m2p_pcm_cache_size, + m2p_pcm_buff); #if defined(TX_RX_PCM_MASK) - APP_AUDIO_InitCQueue(&Tx_esco_queue,pcm_buf_size,Mic_frame_buff); - APP_AUDIO_InitCQueue(&Rx_esco_queue,pcm_buf_size,Rx_esco_buff); + APP_AUDIO_InitCQueue(&Tx_esco_queue, pcm_buf_size, Mic_frame_buff); + APP_AUDIO_InitCQueue(&Rx_esco_queue, pcm_buf_size, Rx_esco_buff); #endif - UNLOCK_APP_AUDIO_QUEUE(); + UNLOCK_APP_AUDIO_QUEUE(); - voicebtpcm_cache_m2p_status = APP_AUDIO_CACHE_CACHEING; - voicebtpcm_cache_p2m_status = APP_AUDIO_CACHE_CACHEING; + voicebtpcm_cache_m2p_status = APP_AUDIO_CACHE_CACHEING; + voicebtpcm_cache_p2m_status = APP_AUDIO_CACHE_CACHEING; #if defined(HFP_1_6_ENABLE) - memset(DecPcmBuf,0,SAMPLES_LEN_PER_FRAME*sizeof(short)); - memset(DecMsbcBuf,0,MSBC_LEN_PER_FRAME*sizeof(unsigned char)); - memset(DecMsbcBufAll,0, sizeof(DecMsbcBufAll)); + memset(DecPcmBuf, 0, SAMPLES_LEN_PER_FRAME * sizeof(short)); + memset(DecMsbcBuf, 0, MSBC_LEN_PER_FRAME * sizeof(unsigned char)); + memset(DecMsbcBufAll, 0, sizeof(DecMsbcBufAll)); - if (bt_sco_codec_is_msbc()) - { - app_audio_mempool_get_buff((uint8_t **)&msbc_encoder, sizeof(btif_sbc_encoder_t)); + if (bt_sco_codec_is_msbc()) { + app_audio_mempool_get_buff((uint8_t **)&msbc_encoder, + sizeof(btif_sbc_encoder_t)); #if !defined(PENDING_MSBC_DECODER_ALG) - app_audio_mempool_get_buff(&temp_msbc_buf, MSBC_ENCODE_PCM_LEN); - app_audio_mempool_get_buff(&temp_msbc_buf1, MSBC_FRAME_SIZE); + app_audio_mempool_get_buff(&temp_msbc_buf, MSBC_ENCODE_PCM_LEN); + app_audio_mempool_get_buff(&temp_msbc_buf1, MSBC_FRAME_SIZE); #else - app_audio_mempool_get_buff(&msbc_buf_before_decode, MSBC_FRAME_SIZE * sizeof(short)); - app_audio_mempool_get_buff(&temp_msbc_buf, MSBC_ENCODE_PCM_LEN * sizeof(short)); - app_audio_mempool_get_buff(&temp_msbc_buf1, MSBC_ENCODE_PCM_LEN * sizeof(short)); + app_audio_mempool_get_buff(&msbc_buf_before_decode, + MSBC_FRAME_SIZE * sizeof(short)); + app_audio_mempool_get_buff(&temp_msbc_buf, + MSBC_ENCODE_PCM_LEN * sizeof(short)); + app_audio_mempool_get_buff(&temp_msbc_buf1, + MSBC_ENCODE_PCM_LEN * sizeof(short)); #endif - //init msbc encoder - btif_sbc_init_encoder(msbc_encoder); - msbc_encoder->streamInfo.mSbcFlag = 1; - msbc_encoder->streamInfo.numChannels = 1; - msbc_encoder->streamInfo.channelMode = BTIF_SBC_CHNL_MODE_MONO; + // init msbc encoder + btif_sbc_init_encoder(msbc_encoder); + msbc_encoder->streamInfo.mSbcFlag = 1; + msbc_encoder->streamInfo.numChannels = 1; + msbc_encoder->streamInfo.channelMode = BTIF_SBC_CHNL_MODE_MONO; - msbc_encoder->streamInfo.bitPool = 26; - msbc_encoder->streamInfo.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; - msbc_encoder->streamInfo.allocMethod = BTIF_SBC_ALLOC_METHOD_LOUDNESS; - msbc_encoder->streamInfo.numBlocks = BTIF_MSBC_BLOCKS; - msbc_encoder->streamInfo.numSubBands = 8; + msbc_encoder->streamInfo.bitPool = 26; + msbc_encoder->streamInfo.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; + msbc_encoder->streamInfo.allocMethod = BTIF_SBC_ALLOC_METHOD_LOUDNESS; + msbc_encoder->streamInfo.numBlocks = BTIF_MSBC_BLOCKS; + msbc_encoder->streamInfo.numSubBands = 8; - msbc_counter = 0x08; + msbc_counter = 0x08; - //init msbc decoder - const float EQLevel[25] = - { - 0.0630957, 0.0794328, 0.1, 0.1258925, 0.1584893, - 0.1995262, 0.2511886, 0.3162278, 0.398107, 0.5011872, - 0.6309573, 0.794328, 1, 1.258925, 1.584893, - 1.995262, 2.5118864, 3.1622776, 3.9810717, 5.011872, - 6.309573, 7.943282, 10, 12.589254, 15.848932 - };//-12~12 - uint8_t i; + // init msbc decoder + const float EQLevel[25] = { + 0.0630957, 0.0794328, 0.1, 0.1258925, 0.1584893, + 0.1995262, 0.2511886, 0.3162278, 0.398107, 0.5011872, + 0.6309573, 0.794328, 1, 1.258925, 1.584893, + 1.995262, 2.5118864, 3.1622776, 3.9810717, 5.011872, + 6.309573, 7.943282, 10, 12.589254, 15.848932}; //-12~12 + uint8_t i; - for (i=0; istreamInfo.mSbcFlag = 1; - msbc_plc_encoder->streamInfo.bitPool = 26; - msbc_plc_encoder->streamInfo.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; - msbc_plc_encoder->streamInfo.channelMode = BTIF_SBC_CHNL_MODE_MONO; - msbc_plc_encoder->streamInfo.allocMethod = BTIF_SBC_ALLOC_METHOD_LOUDNESS; - /* Number of blocks used to encode the stream (4, 8, 12, or 16) */ - msbc_plc_encoder->streamInfo.numBlocks = BTIF_MSBC_BLOCKS; - /* The number of subbands in the stream (4 or 8) */ - msbc_plc_encoder->streamInfo.numSubBands = 8; - msbc_plc_encoder->streamInfo.numChannels = 1; - app_audio_mempool_get_buff((uint8_t **)&msbc_plc_encoder_buffer, sizeof(int16_t) * (SAMPLES_LEN_PER_FRAME + MSBC_CODEC_DELAY)); + app_audio_mempool_get_buff((uint8_t **)&msbc_plc_encoder, + sizeof(btif_sbc_encoder_t)); + btif_sbc_init_encoder(msbc_plc_encoder); + msbc_plc_encoder->streamInfo.mSbcFlag = 1; + msbc_plc_encoder->streamInfo.bitPool = 26; + msbc_plc_encoder->streamInfo.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; + msbc_plc_encoder->streamInfo.channelMode = BTIF_SBC_CHNL_MODE_MONO; + msbc_plc_encoder->streamInfo.allocMethod = BTIF_SBC_ALLOC_METHOD_LOUDNESS; + /* Number of blocks used to encode the stream (4, 8, 12, or 16) */ + msbc_plc_encoder->streamInfo.numBlocks = BTIF_MSBC_BLOCKS; + /* The number of subbands in the stream (4 or 8) */ + msbc_plc_encoder->streamInfo.numSubBands = 8; + msbc_plc_encoder->streamInfo.numChannels = 1; + app_audio_mempool_get_buff((uint8_t **)&msbc_plc_encoder_buffer, + sizeof(int16_t) * + (SAMPLES_LEN_PER_FRAME + MSBC_CODEC_DELAY)); #endif - } - else + } else #endif - { - speech_plc = (PlcSt_8000 *)speech_plc_8000_init(voicebtpcm_get_ext_buff); - } + { + speech_plc = (PlcSt_8000 *)speech_plc_8000_init(voicebtpcm_get_ext_buff); + } #if defined(CVSD_BYPASS) - Pcm8k_CvsdInit(); + Pcm8k_CvsdInit(); #endif #ifdef SPEECH_RX_PLC_DUMP_DATA - audio_dump_temp_buf = (int16_t *)voicebtpcm_get_ext_buff(sizeof(int16_t) * 120); - audio_dump_init(120, sizeof(short), 3); + audio_dump_temp_buf = + (int16_t *)voicebtpcm_get_ext_buff(sizeof(int16_t) * 120); + audio_dump_init(120, sizeof(short), 3); #endif - resample_needed_flag = (sco_sample_rate == codec_sample_rate) ? 0 : 1; + resample_needed_flag = (sco_sample_rate == codec_sample_rate) ? 0 : 1; - if (resample_needed_flag == true) { - // upsample_buf_for_msbc -> uplink resampler - // downsample_buf_for_msbc -> downlink resampler - // store msbc pcm buffer - upsample_buf_for_msbc = (int16_t *)voicebtpcm_get_ext_buff(sizeof(int16_t) * sco_frame_length); - downsample_buf_for_msbc = (int16_t *)voicebtpcm_get_ext_buff(sizeof(int16_t) * sco_frame_length); - } + if (resample_needed_flag == true) { + // upsample_buf_for_msbc -> uplink resampler + // downsample_buf_for_msbc -> downlink resampler + // store msbc pcm buffer + upsample_buf_for_msbc = + (int16_t *)voicebtpcm_get_ext_buff(sizeof(int16_t) * sco_frame_length); + downsample_buf_for_msbc = + (int16_t *)voicebtpcm_get_ext_buff(sizeof(int16_t) * sco_frame_length); + } #if defined(SCO_OPTIMIZE_FOR_RAM) - sco_overlay_ram_buf_len = hal_overlay_get_text_free_size((enum HAL_OVERLAY_ID_T)APP_OVERLAY_HFP); - sco_overlay_ram_buf = (uint8_t *)hal_overlay_get_text_free_addr((enum HAL_OVERLAY_ID_T)APP_OVERLAY_HFP); + sco_overlay_ram_buf_len = + hal_overlay_get_text_free_size((enum HAL_OVERLAY_ID_T)APP_OVERLAY_HFP); + sco_overlay_ram_buf = (uint8_t *)hal_overlay_get_text_free_addr( + (enum HAL_OVERLAY_ID_T)APP_OVERLAY_HFP); #endif - speech_len = app_audio_mempool_free_buff_size() - APP_BT_STREAM_USE_BUF_SIZE; - speech_buf = (uint8_t *)voicebtpcm_get_ext_buff(speech_len); + speech_len = app_audio_mempool_free_buff_size() - APP_BT_STREAM_USE_BUF_SIZE; + speech_buf = (uint8_t *)voicebtpcm_get_ext_buff(speech_len); - int tx_frame_ms = SPEECH_PROCESS_FRAME_MS; - int rx_frame_ms = SPEECH_PROCESS_FRAME_MS; + int tx_frame_ms = SPEECH_PROCESS_FRAME_MS; + int rx_frame_ms = SPEECH_PROCESS_FRAME_MS; #if !defined(SPEECH_RX_NS2FLOAT) - rx_frame_ms = SPEECH_SCO_FRAME_MS; + rx_frame_ms = SPEECH_SCO_FRAME_MS; #endif - speech_init(codec_sample_rate, codec_sample_rate, tx_frame_ms, rx_frame_ms, SPEECH_SCO_FRAME_MS, speech_buf, speech_len); + speech_init(codec_sample_rate, codec_sample_rate, tx_frame_ms, rx_frame_ms, + SPEECH_SCO_FRAME_MS, speech_buf, speech_len); - if (resample_needed_flag == true) { - // Resample state must be created after speech init, as it uses speech heap - upsample_st = iir_resample_init(codec_frame_length, iir_resample_choose_mode(codec_sample_rate, sco_sample_rate)); - downsample_st = iir_resample_init(sco_frame_length, iir_resample_choose_mode(sco_sample_rate, codec_sample_rate)); - } + if (resample_needed_flag == true) { + // Resample state must be created after speech init, as it uses speech heap + upsample_st = iir_resample_init( + codec_frame_length, + iir_resample_choose_mode(codec_sample_rate, sco_sample_rate)); + downsample_st = iir_resample_init( + sco_frame_length, + iir_resample_choose_mode(sco_sample_rate, codec_sample_rate)); + } #if defined(HFP_1_6_ENABLE) && defined(ENABLE_LPC_PLC) - msbc_plc_state = lpc_plc_create(sco_sample_rate); + msbc_plc_state = lpc_plc_create(sco_sample_rate); #endif - return 0; + return 0; } -int voicebtpcm_pcm_audio_deinit(void) -{ - TRACE(1,"[%s] Close...", __func__); - // TRACE(2,"[%s] app audio buffer free = %d", __func__, app_audio_mempool_free_buff_size()); +int voicebtpcm_pcm_audio_deinit(void) { + TRACE(1, "[%s] Close...", __func__); + // TRACE(2,"[%s] app audio buffer free = %d", __func__, + // app_audio_mempool_free_buff_size()); #if defined(HFP_1_6_ENABLE) && defined(ENABLE_LPC_PLC) - lpc_plc_destroy(msbc_plc_state); + lpc_plc_destroy(msbc_plc_state); #endif - if (resample_needed_flag == true) { - iir_resample_destroy(upsample_st); - iir_resample_destroy(downsample_st); - } + if (resample_needed_flag == true) { + iir_resample_destroy(upsample_st); + iir_resample_destroy(downsample_st); + } - speech_deinit(); + speech_deinit(); #if defined(HFP_1_6_ENABLE) #if !defined(PENDING_MSBC_DECODER_ALG) - packet_loss_detection_report(&pld); + packet_loss_detection_report(&pld); #endif #endif #if defined(SCO_OPTIMIZE_FOR_RAM) - sco_overlay_ram_buf = NULL; - sco_overlay_ram_buf_len = 0; + sco_overlay_ram_buf = NULL; + sco_overlay_ram_buf_len = 0; #endif - voicebtpcm_pcm_echo_buf_queue_deinit(); + voicebtpcm_pcm_echo_buf_queue_deinit(); - // TRACE(1,"Free buf = %d", app_audio_mempool_free_buff_size()); + // TRACE(1,"Free buf = %d", app_audio_mempool_free_buff_size()); - return 0; + return 0; } \ No newline at end of file diff --git a/apps/audioplayers/voicebtpcmplay_sco_dma_snapshot.cpp b/apps/audioplayers/voicebtpcmplay_sco_dma_snapshot.cpp index 65e8c29..2497530 100644 --- a/apps/audioplayers/voicebtpcmplay_sco_dma_snapshot.cpp +++ b/apps/audioplayers/voicebtpcmplay_sco_dma_snapshot.cpp @@ -14,25 +14,25 @@ * ****************************************************************************/ // Standard C Included Files -#include -#include -#include -#include -#include -#include "cmsis_os.h" -#include "plat_types.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "hal_trace.h" -#include "cqueue.h" #include "app_audio.h" #include "app_overlay.h" #include "app_ring_merge.h" -#include "tgt_hardware.h" -#include "bt_sco_chain.h" -#include "iir_resample.h" -#include "hfp_api.h" #include "audio_prompt_sbc.h" +#include "bt_sco_chain.h" +#include "cmsis_os.h" +#include "cqueue.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "hfp_api.h" +#include "iir_resample.h" +#include "plat_types.h" +#include "tgt_hardware.h" +#include +#include +#include +#include +#include #ifdef TX_RX_PCM_MASK #include "bt_drv_interface.h" #endif @@ -58,7 +58,7 @@ extern "C" { #include "Pcm8k_Cvsd.h" #endif #ifndef ENABLE_LPC_PLC -static void *speech_plc; +static void *speech_plc; #endif } @@ -84,7 +84,7 @@ int16_t *audio_dump_temp_buf = NULL; #endif // app_bt_stream.cpp::bt_sco_player(), used buffer size -#define APP_BT_STREAM_USE_BUF_SIZE (1024*2) +#define APP_BT_STREAM_USE_BUF_SIZE (1024 * 2) #if defined(SCO_OPTIMIZE_FOR_RAM) uint8_t *sco_overlay_ram_buf = NULL; int sco_overlay_ram_buf_len = 0; @@ -101,7 +101,8 @@ static IirResampleState *downlink_resample_st = NULL; #if defined(HFP_1_6_ENABLE) static btif_sbc_decoder_t *msbc_decoder; -static float msbc_eq_band_gain[CFG_HW_AUD_EQ_NUM_BANDS]= {0,0,0,0,0,0,0,0}; +static float msbc_eq_band_gain[CFG_HW_AUD_EQ_NUM_BANDS] = {0, 0, 0, 0, + 0, 0, 0, 0}; #define MSBC_ENCODE_PCM_LEN (240) @@ -122,21 +123,23 @@ static btif_sbc_encoder_t *msbc_encoder; LpcPlcState *msbc_plc_state = NULL; #endif -#define VOICEBTPCM_TRACE(s,...) -//TRACE(s, ##__VA_ARGS__) +#define VOICEBTPCM_TRACE(s, ...) +// TRACE(s, ##__VA_ARGS__) -#if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) || defined(CHIP_BEST2001) +#if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) || \ + defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) || \ + defined(CHIP_BEST2001) #define MSBC_MUTE_PATTERN (0x55) #else #define MSBC_MUTE_PATTERN (0x00) #endif -#define MSBC_LEN_FORMBT_PER_FRAME (60) //Bytes; only for BES platform. +#define MSBC_LEN_FORMBT_PER_FRAME (60) // Bytes; only for BES platform. #define SAMPLES_LEN_PER_FRAME (120) -#define MSBC_LEN_PER_FRAME (57+3) -#define BYTES_PER_PCM_FRAME (SAMPLES_LEN_PER_FRAME*2) +#define MSBC_LEN_PER_FRAME (57 + 3) +#define BYTES_PER_PCM_FRAME (SAMPLES_LEN_PER_FRAME * 2) // Add 1 to ensure it never be out of bounds when msbc_offset is 1 -unsigned char msbc_buf_all[MSBC_LEN_FORMBT_PER_FRAME*3+1]; +unsigned char msbc_buf_all[MSBC_LEN_FORMBT_PER_FRAME * 3 + 1]; #if defined(HFP_1_6_ENABLE) static int msbc_find_first_sync = 0; static unsigned int msbc_offset = 0; @@ -146,547 +149,567 @@ static PacketLossState pld; extern bool bt_sco_codec_is_msbc(void); -int process_downlink_msbc_frames(unsigned char *msbc_buf, unsigned int msbc_len, unsigned char *pcm_buf,unsigned int pcm_len); -int process_downlink_cvsd_frames(unsigned char *cvsd_buf, unsigned int cvsd_len, unsigned char *pcm_buf,unsigned int pcm_len); -int process_uplink_msbc_frames(unsigned char *pcm_buf, unsigned int pcm_len, unsigned char *msbc_buf,unsigned int msbc_len); -int process_uplink_cvsd_frames(unsigned char *pcm_buf, unsigned int pcm_len, unsigned char *cvsd_buf,unsigned int cvsd_len); +int process_downlink_msbc_frames(unsigned char *msbc_buf, unsigned int msbc_len, + unsigned char *pcm_buf, unsigned int pcm_len); +int process_downlink_cvsd_frames(unsigned char *cvsd_buf, unsigned int cvsd_len, + unsigned char *pcm_buf, unsigned int pcm_len); +int process_uplink_msbc_frames(unsigned char *pcm_buf, unsigned int pcm_len, + unsigned char *msbc_buf, unsigned int msbc_len); +int process_uplink_cvsd_frames(unsigned char *pcm_buf, unsigned int pcm_len, + unsigned char *cvsd_buf, unsigned int cvsd_len); - -int process_downlink_bt_voice_frames(uint8_t *in_buf, uint32_t in_len, uint8_t *out_buf,uint32_t out_len,int32_t codec_type) -{ - //TRACE(3,"[%s] in_len = %d, out_len = %d", __FUNCTION__, in_len, out_len); +int process_downlink_bt_voice_frames(uint8_t *in_buf, uint32_t in_len, + uint8_t *out_buf, uint32_t out_len, + int32_t codec_type) { + // TRACE(3,"[%s] in_len = %d, out_len = %d", __FUNCTION__, in_len, out_len); #if defined(SPEECH_RX_24BIT) - out_len /= 2; + out_len /= 2; #endif - int16_t *pcm_buf = (int16_t *)out_buf; - int pcm_len = out_len / sizeof(int16_t); + int16_t *pcm_buf = (int16_t *)out_buf; + int pcm_len = out_len / sizeof(int16_t); - if (resample_needed_flag == true) { - pcm_buf = resample_buf; - pcm_len = sco_frame_length; + if (resample_needed_flag == true) { + pcm_buf = resample_buf; + pcm_len = sco_frame_length; + } + + if (bt_sco_codec_is_msbc()) { + process_downlink_msbc_frames(in_buf, in_len, (uint8_t *)pcm_buf, + pcm_len * sizeof(int16_t)); + + // Down sampling + if (resample_needed_flag) { + iir_resample_process(downlink_resample_st, pcm_buf, (int16_t *)out_buf, + pcm_len); + pcm_buf = (int16_t *)out_buf; + pcm_len >>= 1; } + } else { + process_downlink_cvsd_frames(in_buf, in_len, (uint8_t *)pcm_buf, + pcm_len * sizeof(int16_t)); - if (bt_sco_codec_is_msbc()) { - process_downlink_msbc_frames(in_buf, in_len, (uint8_t *)pcm_buf, pcm_len * sizeof(int16_t)); - - // Down sampling - if (resample_needed_flag) { - iir_resample_process(downlink_resample_st, pcm_buf, (int16_t *)out_buf, pcm_len); - pcm_buf = (int16_t *)out_buf; - pcm_len >>= 1; - } - } else { - process_downlink_cvsd_frames(in_buf, in_len, (uint8_t *)pcm_buf, pcm_len * sizeof(int16_t)); - - // Up sampling - if (resample_needed_flag) { - iir_resample_process(downlink_resample_st, pcm_buf, (int16_t *)out_buf, pcm_len); - pcm_buf = (int16_t *)out_buf; - pcm_len <<= 1; - } + // Up sampling + if (resample_needed_flag) { + iir_resample_process(downlink_resample_st, pcm_buf, (int16_t *)out_buf, + pcm_len); + pcm_buf = (int16_t *)out_buf; + pcm_len <<= 1; } + } #if defined(SPEECH_RX_24BIT) - int32_t *buf32 = (int32_t *)out_buf; - for (int i = pcm_len - 1; i >= 0; i--) { - buf32[i] = ((int32_t)pcm_buf[i] << 8); - } + int32_t *buf32 = (int32_t *)out_buf; + for (int i = pcm_len - 1; i >= 0; i--) { + buf32[i] = ((int32_t)pcm_buf[i] << 8); + } #endif - speech_rx_process(pcm_buf, &pcm_len); + speech_rx_process(pcm_buf, &pcm_len); #if defined(SPEECH_RX_24BIT) - out_len *= 2; + out_len *= 2; #endif - return 0; + return 0; } -int process_uplink_bt_voice_frames(uint8_t *in_buf, uint32_t in_len, uint8_t *ref_buf, uint32_t ref_len, uint8_t *out_buf,uint32_t out_len,int32_t codec_type) -{ - //TRACE(3,"[%s] in_len = %d, out_len = %d", __FUNCTION__, in_len, out_len); +int process_uplink_bt_voice_frames(uint8_t *in_buf, uint32_t in_len, + uint8_t *ref_buf, uint32_t ref_len, + uint8_t *out_buf, uint32_t out_len, + int32_t codec_type) { + // TRACE(3,"[%s] in_len = %d, out_len = %d", __FUNCTION__, in_len, out_len); #if defined(SPEECH_TX_24BIT) - int32_t *pcm_buf = (int32_t *)in_buf; - int pcm_len = in_len / sizeof(int32_t); + int32_t *pcm_buf = (int32_t *)in_buf; + int pcm_len = in_len / sizeof(int32_t); #else - int16_t *pcm_buf = (int16_t *)in_buf; - int pcm_len = in_len / sizeof(int16_t); + int16_t *pcm_buf = (int16_t *)in_buf; + int pcm_len = in_len / sizeof(int16_t); #endif #if defined(SPEECH_TX_AEC_CODEC_REF) - ASSERT(pcm_len % (SPEECH_CODEC_CAPTURE_CHANNEL_NUM + 1) == 0, "[%s] pcm_len(%d) should be divided by %d", __FUNCTION__, pcm_len, SPEECH_CODEC_CAPTURE_CHANNEL_NUM + 1); - // copy reference buffer -#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) || defined(SPEECH_TX_THIRDPARTY) - for (int i = SPEECH_CODEC_CAPTURE_CHANNEL_NUM, j = 0; i < pcm_len; i += SPEECH_CODEC_CAPTURE_CHANNEL_NUM + 1, j++) { - aec_echo_buf[j] = pcm_buf[i]; - } + ASSERT(pcm_len % (SPEECH_CODEC_CAPTURE_CHANNEL_NUM + 1) == 0, + "[%s] pcm_len(%d) should be divided by %d", __FUNCTION__, pcm_len, + SPEECH_CODEC_CAPTURE_CHANNEL_NUM + 1); + // copy reference buffer +#if defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || \ + defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) || \ + defined(SPEECH_TX_THIRDPARTY) + for (int i = SPEECH_CODEC_CAPTURE_CHANNEL_NUM, j = 0; i < pcm_len; + i += SPEECH_CODEC_CAPTURE_CHANNEL_NUM + 1, j++) { + aec_echo_buf[j] = pcm_buf[i]; + } #endif - for (int i = 0, j = 0; i < pcm_len; i += SPEECH_CODEC_CAPTURE_CHANNEL_NUM + 1, j += SPEECH_CODEC_CAPTURE_CHANNEL_NUM) { - for (int k = 0; k < SPEECH_CODEC_CAPTURE_CHANNEL_NUM; k++) - pcm_buf[j + k] = pcm_buf[i + k]; - } - pcm_len = pcm_len / (SPEECH_CODEC_CAPTURE_CHANNEL_NUM + 1) * SPEECH_CODEC_CAPTURE_CHANNEL_NUM; -#elif (defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) || defined(SPEECH_TX_THIRDPARTY)) - int ref_pcm_len = ref_len / sizeof(int16_t); - ASSERT(pcm_len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM == ref_pcm_len, "[%s] Length error: %d / %d != %d", __func__, pcm_len, SPEECH_CODEC_CAPTURE_CHANNEL_NUM, ref_pcm_len); + for (int i = 0, j = 0; i < pcm_len; i += SPEECH_CODEC_CAPTURE_CHANNEL_NUM + 1, + j += SPEECH_CODEC_CAPTURE_CHANNEL_NUM) { + for (int k = 0; k < SPEECH_CODEC_CAPTURE_CHANNEL_NUM; k++) + pcm_buf[j + k] = pcm_buf[i + k]; + } + pcm_len = pcm_len / (SPEECH_CODEC_CAPTURE_CHANNEL_NUM + 1) * + SPEECH_CODEC_CAPTURE_CHANNEL_NUM; +#elif (defined(SPEECH_TX_AEC) || defined(SPEECH_TX_AEC2) || \ + defined(SPEECH_TX_AEC3) || defined(SPEECH_TX_AEC2FLOAT) || \ + defined(SPEECH_TX_THIRDPARTY)) + int ref_pcm_len = ref_len / sizeof(int16_t); + ASSERT(pcm_len / SPEECH_CODEC_CAPTURE_CHANNEL_NUM == ref_pcm_len, + "[%s] Length error: %d / %d != %d", __func__, pcm_len, + SPEECH_CODEC_CAPTURE_CHANNEL_NUM, ref_pcm_len); - for (int i = 0; i < ref_pcm_len; i++) { - aec_echo_buf[i] = ref_buf[i]; - } + for (int i = 0; i < ref_pcm_len; i++) { + aec_echo_buf[i] = ref_buf[i]; + } #endif - speech_tx_process(pcm_buf, aec_echo_buf, &pcm_len); + speech_tx_process(pcm_buf, aec_echo_buf, &pcm_len); #if defined(SPEECH_TX_24BIT) - int32_t *buf24 = (int32_t *)pcm_buf; - int16_t *buf16 = (int16_t *)pcm_buf; - for (int i = 0; i < pcm_len; i++) - buf16[i] = (buf24[i] >> 8); + int32_t *buf24 = (int32_t *)pcm_buf; + int16_t *buf16 = (int16_t *)pcm_buf; + for (int i = 0; i < pcm_len; i++) + buf16[i] = (buf24[i] >> 8); #endif - int16_t *pcm_buf_16bits = (int16_t *)pcm_buf; + int16_t *pcm_buf_16bits = (int16_t *)pcm_buf; - if (bt_sco_codec_is_msbc()) { - // Up sampling - if (resample_needed_flag) { - iir_resample_process(uplink_resample_st, (int16_t *)pcm_buf_16bits, resample_buf, pcm_len); - pcm_buf_16bits = resample_buf; - pcm_len = sco_frame_length; - } - - process_uplink_msbc_frames((uint8_t *)pcm_buf_16bits, pcm_len * sizeof(int16_t), out_buf, out_len); - } else { - // Down sampling - if (resample_needed_flag) { - iir_resample_process(uplink_resample_st, (int16_t *)pcm_buf_16bits, resample_buf, pcm_len); - pcm_buf_16bits = resample_buf; - pcm_len = sco_frame_length; - } - - process_uplink_cvsd_frames((uint8_t *)pcm_buf_16bits, pcm_len * sizeof(int16_t), out_buf, out_len); + if (bt_sco_codec_is_msbc()) { + // Up sampling + if (resample_needed_flag) { + iir_resample_process(uplink_resample_st, (int16_t *)pcm_buf_16bits, + resample_buf, pcm_len); + pcm_buf_16bits = resample_buf; + pcm_len = sco_frame_length; } - return 0; + + process_uplink_msbc_frames((uint8_t *)pcm_buf_16bits, + pcm_len * sizeof(int16_t), out_buf, out_len); + } else { + // Down sampling + if (resample_needed_flag) { + iir_resample_process(uplink_resample_st, (int16_t *)pcm_buf_16bits, + resample_buf, pcm_len); + pcm_buf_16bits = resample_buf; + pcm_len = sco_frame_length; + } + + process_uplink_cvsd_frames((uint8_t *)pcm_buf_16bits, + pcm_len * sizeof(int16_t), out_buf, out_len); + } + return 0; } -int process_downlink_msbc_frames(unsigned char *msbc_buf, unsigned int msbc_len, unsigned char *pcm_buf,unsigned int pcm_len) -{ +int process_downlink_msbc_frames(unsigned char *msbc_buf, unsigned int msbc_len, + unsigned char *pcm_buf, unsigned int pcm_len) { #if defined(HFP_1_6_ENABLE) + btif_sbc_pcm_data_t pcm_data; + unsigned int msbc_offset_lowdelay = 0; + unsigned int i, j; + unsigned char *msbc_buffer = (unsigned char *)msbc_buf; + int frame_flag[6]; // 1: good frame; 0:bad frame; + bt_status_t ret; + unsigned int frame_counter = 0; + unsigned short byte_decode = 0; + unsigned int msbc_offset_total = 0; + int msbc_offset_drift[6] = { + 0, + }; - btif_sbc_pcm_data_t pcm_data; - unsigned int msbc_offset_lowdelay = 0; - unsigned int i,j; - unsigned char *msbc_buffer=(unsigned char *)msbc_buf; - int frame_flag[6]; // 1: good frame; 0:bad frame; - bt_status_t ret; - unsigned int frame_counter=0; - unsigned short byte_decode = 0; - unsigned int msbc_offset_total = 0; - int msbc_offset_drift[6] = {0, }; + short *dec_pcm_buf = (short *)pcm_buf; + unsigned char dec_msbc_buf[MSBC_LEN_PER_FRAME] = { + 0, + }; - short *dec_pcm_buf=( short *)pcm_buf; - unsigned char dec_msbc_buf[MSBC_LEN_PER_FRAME] = {0, }; + // unsigned int timer_begin=hal_sys_timer_get(); - //unsigned int timer_begin=hal_sys_timer_get(); + // TRACE(2,"process_downlink_msbc_frames:pcm_len:%d,msbc_len:%d",pcm_len,msbc_len); - //TRACE(2,"process_downlink_msbc_frames:pcm_len:%d,msbc_len:%d",pcm_len,msbc_len); + // TRACE(1,"decode_msbc_frame,msbc_len:%d",msbc_len); + for (i = 0; i < msbc_len; i++) { + msbc_buf_all[i + MSBC_LEN_FORMBT_PER_FRAME] = msbc_buffer[i]; + } - //TRACE(1,"decode_msbc_frame,msbc_len:%d",msbc_len); - for(i =0; i= + msbc_offset_total) { + frame_flag[j] = 3; + } else { frame_flag[j] = 1; + } } - } + } } - if(msbc_find_first_sync==1) - { - int value=0; - unsigned char headerm1 = 0; - unsigned char header0 = 0; - unsigned char header1 = 0; - unsigned char header2 = 0; - unsigned char header3 = 0; -// unsigned char tail0 = 0; - - if(msbc_offset==0||msbc_offset==1) - { - msbc_offset_lowdelay=msbc_offset+60; - //msbc_offset_lowdelay=msbc_offset; + for (j = 0; j < msbc_len / MSBC_LEN_FORMBT_PER_FRAME; j++) { + value = value | frame_flag[j]; } - else - { - msbc_offset_lowdelay=msbc_offset; + // abnormal msbc packet. + if (value > 1) + msbc_find_first_sync = 0; + } + + while ((frame_counter < msbc_len / MSBC_LEN_FORMBT_PER_FRAME) && + (frame_counter < pcm_len / BYTES_PER_PCM_FRAME)) { + // TRACE(3,"[%s] decoding, offset %d, offset drift %d", __FUNCTION__, + // msbc_offset, msbc_offset_drift[frame_counter]); + // skip first byte when msbc_offset == 0 and msbc_offset_drift == -1 + unsigned int start_idx = 0; + if (msbc_offset_lowdelay == 0 && msbc_offset_drift[frame_counter] == -1) { + start_idx = 1; + dec_msbc_buf[0] = 0x01; + } + for (i = start_idx; i < MSBC_LEN_PER_FRAME; i++) { + // DecMsbcBuf[i]=DecMsbcBufAll[i+msbc_offset_lowdelay+frame_counter*MSBC_LEN_FORMBT_PER_FRAME+2]; + dec_msbc_buf[i] = msbc_buf_all[i + msbc_offset_lowdelay + + msbc_offset_drift[frame_counter] + + frame_counter * MSBC_LEN_FORMBT_PER_FRAME]; } - - //check again - for(j =0; j<(msbc_len/MSBC_LEN_FORMBT_PER_FRAME); j++) - { - if (next_frame_flag == 1) - { - next_frame_flag = 0; - frame_flag[j] = 1; - continue; - } - if(msbc_offset_lowdelay==0&&j==0) - { - headerm1=0x01; - } - else - { - headerm1 = msbc_buf_all[msbc_offset_lowdelay + j*MSBC_LEN_FORMBT_PER_FRAME-1]; - } - - header0 = msbc_buf_all[msbc_offset_lowdelay + j*MSBC_LEN_FORMBT_PER_FRAME]; - header1 = msbc_buf_all[msbc_offset_lowdelay + j*MSBC_LEN_FORMBT_PER_FRAME + 1]; - header2 = msbc_buf_all[msbc_offset_lowdelay + j*MSBC_LEN_FORMBT_PER_FRAME + 2]; - header3 = msbc_buf_all[msbc_offset_lowdelay + j*MSBC_LEN_FORMBT_PER_FRAME + 3]; - - /*if ((headerm1 == 0x01) && ((header0 & 0x0f) == 0x08) && (header1 == 0xad) || - (header0 == 0x01) && ((header1 & 0x0f) == 0x08) && (header2 == 0xad) || - (header1 == 0x01) && ((header2 & 0x0f) == 0x08) && (header3 == 0xad)) - { - frame_flag[j] = 0; - }*/ - if ((headerm1 == 0x01) && ((header0 & 0x0f) == 0x08) && (header1 == 0xad)) - { - frame_flag[j] = 0; - // It seems that offset is reduced by 1 - msbc_offset_drift[j] = -1; - TRACE(1,"[%s] msbc_offset is reduced by 1", __FUNCTION__); - /* - tail0 = msbc_buf_all[msbc_offset_lowdelay + j*MSBC_LEN_FORMBT_PER_FRAME + 59 - 1]; - if (tail0 == 0x00 || tail0 == 0x01|| tail0==0xff) - { - frame_flag[j] = 0; - } - else - { - frame_flag[j] = 1; - next_frame_flag = 1; - } - */ - } - else if ((header0 == 0x01) && ((header1 & 0x0f) == 0x08) && (header2 == 0xad)) - { - frame_flag[j] = 0; - /* - tail0 = msbc_buf_all[msbc_offset_lowdelay + j*MSBC_LEN_FORMBT_PER_FRAME + 59]; - if (tail0 == 0x00 || tail0 == 0x01|| tail0==0xff) - { - frame_flag[j] = 0; - } - else - { - frame_flag[j] = 1; - next_frame_flag = 1; - } - */ - } - else if ((header1 == 0x01) && ((header2 & 0x0f) == 0x08) && (header3 == 0xad)) - { - frame_flag[j] = 0; - msbc_offset_drift[j] = 1; - TRACE(1,"[%s] msbc_offset is increased by 1", __FUNCTION__); - /* - tail0 = msbc_buf_all[msbc_offset_lowdelay + j*MSBC_LEN_FORMBT_PER_FRAME + 59 + 1]; - if (tail0 == 0x00 || tail0==0x01|| tail0==0xff) - { - frame_flag[j] = 0; - } - else - { - frame_flag[j] = 1; - next_frame_flag = 1; - } - */ - } - else - { - if ((header0 == MSBC_MUTE_PATTERN)&& ((header1 & 0x0f) == (MSBC_MUTE_PATTERN & 0x0f)) && (header2 == MSBC_MUTE_PATTERN)) - { - frame_flag[j]=1; - } - else - { - if((msbc_offset_lowdelay+j*MSBC_LEN_FORMBT_PER_FRAME)>=msbc_offset_total) - { - frame_flag[j]=3; - } - else - { - frame_flag[j]=1; - } - } - } - } - - for(j =0; j1)msbc_find_first_sync=0; - } - - while((frame_counterstreamInfo.mSbcFlag = 1; - msbc_encoder->streamInfo.numChannels = 1; - msbc_encoder->streamInfo.channelMode = BTIF_SBC_CHNL_MODE_MONO; + // init msbc encoder + btif_sbc_init_encoder(msbc_encoder); + msbc_encoder->streamInfo.mSbcFlag = 1; + msbc_encoder->streamInfo.numChannels = 1; + msbc_encoder->streamInfo.channelMode = BTIF_SBC_CHNL_MODE_MONO; - msbc_encoder->streamInfo.bitPool = 26; - msbc_encoder->streamInfo.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; - msbc_encoder->streamInfo.allocMethod = BTIF_SBC_ALLOC_METHOD_LOUDNESS; - msbc_encoder->streamInfo.numBlocks = BTIF_MSBC_BLOCKS; - msbc_encoder->streamInfo.numSubBands = 8; + msbc_encoder->streamInfo.bitPool = 26; + msbc_encoder->streamInfo.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; + msbc_encoder->streamInfo.allocMethod = BTIF_SBC_ALLOC_METHOD_LOUDNESS; + msbc_encoder->streamInfo.numBlocks = BTIF_MSBC_BLOCKS; + msbc_encoder->streamInfo.numSubBands = 8; - //init msbc decoder - const float EQLevel[25] = - { - 0.0630957, 0.0794328, 0.1, 0.1258925, 0.1584893, - 0.1995262, 0.2511886, 0.3162278, 0.398107, 0.5011872, - 0.6309573, 0.794328, 1, 1.258925, 1.584893, - 1.995262, 2.5118864, 3.1622776, 3.9810717, 5.011872, - 6.309573, 7.943282, 10, 12.589254, 15.848932 - };//-12~12 - uint8_t i; + // init msbc decoder + const float EQLevel[25] = { + 0.0630957, 0.0794328, 0.1, 0.1258925, 0.1584893, + 0.1995262, 0.2511886, 0.3162278, 0.398107, 0.5011872, + 0.6309573, 0.794328, 1, 1.258925, 1.584893, + 1.995262, 2.5118864, 3.1622776, 3.9810717, 5.011872, + 6.309573, 7.943282, 10, 12.589254, 15.848932}; //-12~12 + uint8_t i; - for (i=0; istreamInfo.mSbcFlag = 1; - msbc_decoder->streamInfo.bitPool = 26; - msbc_decoder->streamInfo.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; - msbc_decoder->streamInfo.channelMode = BTIF_SBC_CHNL_MODE_MONO; - msbc_decoder->streamInfo.allocMethod = BTIF_SBC_ALLOC_METHOD_LOUDNESS; - /* Number of blocks used to encode the stream (4, 8, 12, or 16) */ - msbc_decoder->streamInfo.numBlocks = BTIF_MSBC_BLOCKS; - /* The number of subbands in the stream (4 or 8) */ - msbc_decoder->streamInfo.numSubBands = 8; - msbc_decoder->streamInfo.numChannels = 1; + msbc_decoder->streamInfo.mSbcFlag = 1; + msbc_decoder->streamInfo.bitPool = 26; + msbc_decoder->streamInfo.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; + msbc_decoder->streamInfo.channelMode = BTIF_SBC_CHNL_MODE_MONO; + msbc_decoder->streamInfo.allocMethod = BTIF_SBC_ALLOC_METHOD_LOUDNESS; + /* Number of blocks used to encode the stream (4, 8, 12, or 16) */ + msbc_decoder->streamInfo.numBlocks = BTIF_MSBC_BLOCKS; + /* The number of subbands in the stream (4 or 8) */ + msbc_decoder->streamInfo.numSubBands = 8; + msbc_decoder->streamInfo.numChannels = 1; - //init msbc plc + // init msbc plc #ifndef ENABLE_LPC_PLC - InitPLC(&msbc_plc_state); + InitPLC(&msbc_plc_state); #endif - next_frame_flag = 0; - msbc_find_first_sync = 0; + next_frame_flag = 0; + msbc_find_first_sync = 0; - packet_loss_detection_init(&pld); + packet_loss_detection_init(&pld); #if defined(ENABLE_PLC_ENCODER) - app_audio_mempool_get_buff((uint8_t **)&msbc_plc_encoder, sizeof(btif_sbc_encoder_t)); - btif_sbc_init_encoder(msbc_plc_encoder); - msbc_plc_encoder->streamInfo.mSbcFlag = 1; - msbc_plc_encoder->streamInfo.bitPool = 26; - msbc_plc_encoder->streamInfo.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; - msbc_plc_encoder->streamInfo.channelMode = BTIF_SBC_CHNL_MODE_MONO; - msbc_plc_encoder->streamInfo.allocMethod = BTIF_SBC_ALLOC_METHOD_LOUDNESS; - /* Number of blocks used to encode the stream (4, 8, 12, or 16) */ - msbc_plc_encoder->streamInfo.numBlocks = BTIF_MSBC_BLOCKS; - /* The number of subbands in the stream (4 or 8) */ - msbc_plc_encoder->streamInfo.numSubBands = 8; - msbc_plc_encoder->streamInfo.numChannels = 1; - app_audio_mempool_get_buff((uint8_t **)&msbc_plc_encoder_buffer, sizeof(int16_t) * (SAMPLES_LEN_PER_FRAME + MSBC_CODEC_DELAY)); + app_audio_mempool_get_buff((uint8_t **)&msbc_plc_encoder, + sizeof(btif_sbc_encoder_t)); + btif_sbc_init_encoder(msbc_plc_encoder); + msbc_plc_encoder->streamInfo.mSbcFlag = 1; + msbc_plc_encoder->streamInfo.bitPool = 26; + msbc_plc_encoder->streamInfo.sampleFreq = BTIF_SBC_CHNL_SAMPLE_FREQ_16; + msbc_plc_encoder->streamInfo.channelMode = BTIF_SBC_CHNL_MODE_MONO; + msbc_plc_encoder->streamInfo.allocMethod = BTIF_SBC_ALLOC_METHOD_LOUDNESS; + /* Number of blocks used to encode the stream (4, 8, 12, or 16) */ + msbc_plc_encoder->streamInfo.numBlocks = BTIF_MSBC_BLOCKS; + /* The number of subbands in the stream (4 or 8) */ + msbc_plc_encoder->streamInfo.numSubBands = 8; + msbc_plc_encoder->streamInfo.numChannels = 1; + app_audio_mempool_get_buff((uint8_t **)&msbc_plc_encoder_buffer, + sizeof(int16_t) * + (SAMPLES_LEN_PER_FRAME + MSBC_CODEC_DELAY)); #endif - } - else + } else #endif - { + { #ifndef ENABLE_LPC_PLC - speech_plc = (PlcSt_8000 *)speech_plc_8000_init(voicebtpcm_get_ext_buff); + speech_plc = (PlcSt_8000 *)speech_plc_8000_init(voicebtpcm_get_ext_buff); #endif - } + } #if defined(CVSD_BYPASS) - Pcm8k_CvsdInit(); + Pcm8k_CvsdInit(); #endif #ifdef SPEECH_RX_PLC_DUMP_DATA - audio_dump_temp_buf = (int16_t *)voicebtpcm_get_ext_buff(sizeof(int16_t) * 120); - audio_dump_init(120, sizeof(short), 3); + audio_dump_temp_buf = + (int16_t *)voicebtpcm_get_ext_buff(sizeof(int16_t) * 120); + audio_dump_init(120, sizeof(short), 3); #endif - resample_needed_flag = (sco_sample_rate == codec_sample_rate) ? 0 : 1; + resample_needed_flag = (sco_sample_rate == codec_sample_rate) ? 0 : 1; - if (resample_needed_flag) { - TRACE(1, "[%s] SCO <-- Resample --> CODEC", __func__); - resample_buf = (int16_t *)voicebtpcm_get_ext_buff(sizeof(int16_t) * sco_frame_length); - } + if (resample_needed_flag) { + TRACE(1, "[%s] SCO <-- Resample --> CODEC", __func__); + resample_buf = + (int16_t *)voicebtpcm_get_ext_buff(sizeof(int16_t) * sco_frame_length); + } #if defined(SCO_OPTIMIZE_FOR_RAM) - sco_overlay_ram_buf_len = hal_overlay_get_text_free_size((enum HAL_OVERLAY_ID_T)APP_OVERLAY_HFP); - sco_overlay_ram_buf = (uint8_t *)hal_overlay_get_text_free_addr((enum HAL_OVERLAY_ID_T)APP_OVERLAY_HFP); + sco_overlay_ram_buf_len = + hal_overlay_get_text_free_size((enum HAL_OVERLAY_ID_T)APP_OVERLAY_HFP); + sco_overlay_ram_buf = (uint8_t *)hal_overlay_get_text_free_addr( + (enum HAL_OVERLAY_ID_T)APP_OVERLAY_HFP); #endif - speech_len = app_audio_mempool_free_buff_size() - APP_BT_STREAM_USE_BUF_SIZE; - speech_buf = (uint8_t *)voicebtpcm_get_ext_buff(speech_len); + speech_len = app_audio_mempool_free_buff_size() - APP_BT_STREAM_USE_BUF_SIZE; + speech_buf = (uint8_t *)voicebtpcm_get_ext_buff(speech_len); - int tx_frame_ms = SPEECH_PROCESS_FRAME_MS; - int rx_frame_ms = SPEECH_SCO_FRAME_MS; - speech_init(codec_sample_rate, codec_sample_rate, tx_frame_ms, rx_frame_ms, SPEECH_SCO_FRAME_MS, speech_buf, speech_len); + int tx_frame_ms = SPEECH_PROCESS_FRAME_MS; + int rx_frame_ms = SPEECH_SCO_FRAME_MS; + speech_init(codec_sample_rate, codec_sample_rate, tx_frame_ms, rx_frame_ms, + SPEECH_SCO_FRAME_MS, speech_buf, speech_len); - if (resample_needed_flag) { - uplink_resample_st = iir_resample_init(codec_frame_length, iir_resample_choose_mode(codec_sample_rate, sco_sample_rate)); - downlink_resample_st = iir_resample_init(sco_frame_length, iir_resample_choose_mode(sco_sample_rate, codec_sample_rate)); - } + if (resample_needed_flag) { + uplink_resample_st = iir_resample_init( + codec_frame_length, + iir_resample_choose_mode(codec_sample_rate, sco_sample_rate)); + downlink_resample_st = iir_resample_init( + sco_frame_length, + iir_resample_choose_mode(sco_sample_rate, codec_sample_rate)); + } #if defined(ENABLE_LPC_PLC) - msbc_plc_state = lpc_plc_create(sco_sample_rate); + msbc_plc_state = lpc_plc_create(sco_sample_rate); #endif - return 0; + return 0; } -int voicebtpcm_pcm_audio_deinit(void) -{ - TRACE(1,"[%s] Close...", __func__); - // TRACE(2,"[%s] app audio buffer free = %d", __func__, app_audio_mempool_free_buff_size()); +int voicebtpcm_pcm_audio_deinit(void) { + TRACE(1, "[%s] Close...", __func__); + // TRACE(2,"[%s] app audio buffer free = %d", __func__, + // app_audio_mempool_free_buff_size()); #if defined(ENABLE_LPC_PLC) - lpc_plc_destroy(msbc_plc_state); + lpc_plc_destroy(msbc_plc_state); #endif - if (resample_needed_flag) { - iir_resample_destroy(uplink_resample_st); - iir_resample_destroy(downlink_resample_st); - } + if (resample_needed_flag) { + iir_resample_destroy(uplink_resample_st); + iir_resample_destroy(downlink_resample_st); + } - speech_deinit(); + speech_deinit(); - packet_loss_detection_report(&pld); + packet_loss_detection_report(&pld); #if defined(SCO_OPTIMIZE_FOR_RAM) - sco_overlay_ram_buf = NULL; - sco_overlay_ram_buf_len = 0; + sco_overlay_ram_buf = NULL; + sco_overlay_ram_buf_len = 0; #endif - // TRACE(1,"Free buf = %d", app_audio_mempool_free_buff_size()); + // TRACE(1,"Free buf = %d", app_audio_mempool_free_buff_size()); - return 0; + return 0; } \ No newline at end of file diff --git a/apps/audioplayers/wavplay.cpp b/apps/audioplayers/wavplay.cpp index 9a19c7b..f5c9491 100644 --- a/apps/audioplayers/wavplay.cpp +++ b/apps/audioplayers/wavplay.cpp @@ -17,46 +17,44 @@ #include "mbed.h" #endif // Standard C Included Files -#include #include #include -#include #include +#include +#include -#include "hal_uart.h" -#include "hal_trace.h" #include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" /*! * * @brief Standard Winodws PCM wave file header length * */ -#define WAVE_FILE_HEADER_SIZE 0x2CU +#define WAVE_FILE_HEADER_SIZE 0x2CU -typedef struct wave_header -{ - uint8_t riff[4]; - uint32_t size; - uint8_t waveFlag[4]; - uint8_t fmt[4]; - uint32_t fmtLen; - uint16_t tag; - uint16_t channels; - uint32_t sampFreq; - uint32_t byteRate; - uint16_t blockAlign; - uint16_t bitSamp; - uint8_t dataFlag[4]; - uint32_t length; +typedef struct wave_header { + uint8_t riff[4]; + uint32_t size; + uint8_t waveFlag[4]; + uint8_t fmt[4]; + uint32_t fmtLen; + uint16_t tag; + uint16_t channels; + uint32_t sampFreq; + uint32_t byteRate; + uint16_t blockAlign; + uint16_t bitSamp; + uint8_t dataFlag[4]; + uint32_t length; } wave_header_t; /*! * * @brief Wave file structure * */ -typedef struct wave_file -{ - wave_header_t header; - uint32_t *data; -}wave_file_t; +typedef struct wave_file { + wave_header_t header; + uint32_t *data; +} wave_file_t; /* player */ static unsigned int g_total_play_count = 0; @@ -66,188 +64,179 @@ static unsigned int g_curr_play_index = 0; wave_file_t g_wave_file_info; static char g_wav_header[WAVE_FILE_HEADER_SIZE]; FILE *g_wave_file_handle = NULL; -static int32_t (*wav_file_playback_callback)(int32_t ) = NULL; +static int32_t (*wav_file_playback_callback)(int32_t) = NULL; //////////////////////////////////////////////////////////////////////////////// // Code //////////////////////////////////////////////////////////////////////////////// -void wav_file_set_playeback_cb(int32_t (* cb)(int32_t)) -{ - wav_file_playback_callback = cb; +void wav_file_set_playeback_cb(int32_t (*cb)(int32_t)) { + wav_file_playback_callback = cb; } -bool wav_file_isplaydone(void) -{ - return (g_curr_play_index >= g_total_play_count)? true : false; +bool wav_file_isplaydone(void) { + return (g_curr_play_index >= g_total_play_count) ? true : false; } -uint32_t wav_file_audio_more_data(uint8_t *buf, uint32_t len) -{ -// static uint32_t g_preIrqTime = 0; - uint32_t reallen = 0; -// int32_t stime,etime; - int32_t status; +uint32_t wav_file_audio_more_data(uint8_t *buf, uint32_t len) { + // static uint32_t g_preIrqTime = 0; + uint32_t reallen = 0; + // int32_t stime,etime; + int32_t status; - /* play done ? */ - if(wav_file_isplaydone()) { - memset(buf, 0, len); - status = 0; - if (wav_file_playback_callback) - wav_file_playback_callback(status); - return (len); - } -// stime = hal_sys_timer_get(); - /* read file */ - if (g_wave_file_handle) - reallen = fread(buf, 1, len, g_wave_file_handle); -// etime = hal_sys_timer_get(); - if (reallen != len){ - memset(buf, 0, len); - status = -1; - if (wav_file_playback_callback) - wav_file_playback_callback(status); - return (len); - } - -// TRACE(5,"wav_file_audio_more_data irqDur:%d fsSpend:%d, readbuff:0x%08x %d/%d\n ", TICKS_TO_MS(stime - g_preIrqTime),TICKS_TO_MS(etime - stime),buf,reallen,len); -// g_preIrqTime = stime; - - /* walk index */ - g_curr_play_index += reallen; - - return reallen; -} - -uint32_t get_wav_data(wave_file_t *waveFile) -{ - uint8_t *dataTemp = (uint8_t *)waveFile->data; - - // check for RIFF - memcpy(waveFile->header.riff, dataTemp, 4); - dataTemp += 4; - if( memcmp( (uint8_t*)waveFile->header.riff, "RIFF", 4) ) - { - return 0; - } - - // Get size - memcpy(&waveFile->header.size, dataTemp, 4); - dataTemp += 4; - - TRACE(1,"WAV header size [%d]\n", waveFile->header.size); - - // .wav file flag - memcpy(waveFile->header.waveFlag, dataTemp, 4); - dataTemp += 4; - if( memcmp( (uint8_t*)waveFile->header.waveFlag, "WAVE", 4) ) - { - return 0; - } - - // fmt - memcpy(waveFile->header.fmt, dataTemp, 4); - dataTemp += 4; - if( memcmp( (uint8_t*)waveFile->header.fmt, "fmt ", 4) ) - { - return 0; - } - - // fmt length - memcpy(&waveFile->header.fmtLen, dataTemp, 4); - dataTemp += 4; - - // Tag: PCM or not - memcpy(&waveFile->header.tag, dataTemp, 4); - dataTemp += 2; - - // Channels - memcpy(&waveFile->header.channels, dataTemp, 4); - dataTemp += 2; - - TRACE(1,"WAV channels [%d]\n", waveFile->header.channels); - - // Sample Rate in Hz - memcpy(&waveFile->header.sampFreq, dataTemp, 4); - dataTemp += 4; - memcpy(&waveFile->header.byteRate, dataTemp, 4); - dataTemp += 4; - - TRACE(1,"WAV sample_rate [%d]\n", waveFile->header.sampFreq); - TRACE(1,"WAV byteRate [%d]\n", waveFile->header.byteRate); - - // quantize bytes for per samp point - memcpy(&waveFile->header.blockAlign, dataTemp, 4); - dataTemp += 2; - memcpy(&waveFile->header.bitSamp, dataTemp, 4); - dataTemp += 2; - - TRACE(1,"WAV bitSamp [%d]\n", waveFile->header.bitSamp); - - // Data - memcpy(waveFile->header.dataFlag, dataTemp, 4); - dataTemp += 4; - if( memcmp( (uint8_t*)waveFile->header.dataFlag, "data ", 4) ) - { - return 0; - } - memcpy(&waveFile->header.length, dataTemp, 4); - dataTemp += 4; - - return 0; -} - - -void audio_wav_init(wave_file_t *newWav) -{ - get_wav_data(newWav); - - // Configure the play audio g_format - //g_format.bits = newWav->header.bitSamp; - //g_format.sample_rate = newWav->header.sampFreq; - //g_format.mclk = 256 * g_format.sample_rate ; - //g_format.mono_streo = (sai_mono_streo_t)((newWav->header.channels) - 1); -} - -uint32_t play_wav_file(char *file_path) -{ - uint32_t bytesToRead = 0; - - wave_file_t *newWav = &g_wave_file_info; - - memset(&g_wave_file_info, 0, sizeof(g_wave_file_info)); - - g_wave_file_handle = fopen(file_path, "rb"); - - if(g_wave_file_handle == NULL) { - TRACE(1,"WAV file %s open fail\n", file_path); - return 1; - } - - fread(&g_wav_header, WAVE_FILE_HEADER_SIZE, 1, g_wave_file_handle); - - newWav->data = (uint32_t *)&g_wav_header; - - audio_wav_init(newWav); - - // Remove header size from byte count - // Adjust note duration by divider value, wav tables in pcm_data.h are 200ms by default - bytesToRead = (newWav->header.length - WAVE_FILE_HEADER_SIZE); - - g_curr_play_index = 0; - g_total_play_count = bytesToRead; - - return newWav->header.sampFreq; -} - -uint32_t stop_wav_file(void) -{ - memset(&g_wave_file_info, 0, sizeof(g_wave_file_info)); - g_curr_play_index = 0; - g_total_play_count = 0; - if (g_wave_file_handle){ - fclose(g_wave_file_handle); - g_wave_file_handle = NULL; - } + /* play done ? */ + if (wav_file_isplaydone()) { + memset(buf, 0, len); + status = 0; if (wav_file_playback_callback) - wav_file_playback_callback = NULL; + wav_file_playback_callback(status); + return (len); + } + // stime = hal_sys_timer_get(); + /* read file */ + if (g_wave_file_handle) + reallen = fread(buf, 1, len, g_wave_file_handle); + // etime = hal_sys_timer_get(); + if (reallen != len) { + memset(buf, 0, len); + status = -1; + if (wav_file_playback_callback) + wav_file_playback_callback(status); + return (len); + } - return 0; + // TRACE(5,"wav_file_audio_more_data irqDur:%d fsSpend:%d, readbuff:0x%08x + // %d/%d\n ", TICKS_TO_MS(stime - g_preIrqTime),TICKS_TO_MS(etime - + // stime),buf,reallen,len); + // g_preIrqTime = stime; + + /* walk index */ + g_curr_play_index += reallen; + + return reallen; +} + +uint32_t get_wav_data(wave_file_t *waveFile) { + uint8_t *dataTemp = (uint8_t *)waveFile->data; + + // check for RIFF + memcpy(waveFile->header.riff, dataTemp, 4); + dataTemp += 4; + if (memcmp((uint8_t *)waveFile->header.riff, "RIFF", 4)) { + return 0; + } + + // Get size + memcpy(&waveFile->header.size, dataTemp, 4); + dataTemp += 4; + + TRACE(1, "WAV header size [%d]\n", waveFile->header.size); + + // .wav file flag + memcpy(waveFile->header.waveFlag, dataTemp, 4); + dataTemp += 4; + if (memcmp((uint8_t *)waveFile->header.waveFlag, "WAVE", 4)) { + return 0; + } + + // fmt + memcpy(waveFile->header.fmt, dataTemp, 4); + dataTemp += 4; + if (memcmp((uint8_t *)waveFile->header.fmt, "fmt ", 4)) { + return 0; + } + + // fmt length + memcpy(&waveFile->header.fmtLen, dataTemp, 4); + dataTemp += 4; + + // Tag: PCM or not + memcpy(&waveFile->header.tag, dataTemp, 4); + dataTemp += 2; + + // Channels + memcpy(&waveFile->header.channels, dataTemp, 4); + dataTemp += 2; + + TRACE(1, "WAV channels [%d]\n", waveFile->header.channels); + + // Sample Rate in Hz + memcpy(&waveFile->header.sampFreq, dataTemp, 4); + dataTemp += 4; + memcpy(&waveFile->header.byteRate, dataTemp, 4); + dataTemp += 4; + + TRACE(1, "WAV sample_rate [%d]\n", waveFile->header.sampFreq); + TRACE(1, "WAV byteRate [%d]\n", waveFile->header.byteRate); + + // quantize bytes for per samp point + memcpy(&waveFile->header.blockAlign, dataTemp, 4); + dataTemp += 2; + memcpy(&waveFile->header.bitSamp, dataTemp, 4); + dataTemp += 2; + + TRACE(1, "WAV bitSamp [%d]\n", waveFile->header.bitSamp); + + // Data + memcpy(waveFile->header.dataFlag, dataTemp, 4); + dataTemp += 4; + if (memcmp((uint8_t *)waveFile->header.dataFlag, "data ", 4)) { + return 0; + } + memcpy(&waveFile->header.length, dataTemp, 4); + dataTemp += 4; + + return 0; +} + +void audio_wav_init(wave_file_t *newWav) { + get_wav_data(newWav); + + // Configure the play audio g_format + // g_format.bits = newWav->header.bitSamp; + // g_format.sample_rate = newWav->header.sampFreq; + // g_format.mclk = 256 * g_format.sample_rate ; + // g_format.mono_streo = (sai_mono_streo_t)((newWav->header.channels) - 1); +} + +uint32_t play_wav_file(char *file_path) { + uint32_t bytesToRead = 0; + + wave_file_t *newWav = &g_wave_file_info; + + memset(&g_wave_file_info, 0, sizeof(g_wave_file_info)); + + g_wave_file_handle = fopen(file_path, "rb"); + + if (g_wave_file_handle == NULL) { + TRACE(1, "WAV file %s open fail\n", file_path); + return 1; + } + + fread(&g_wav_header, WAVE_FILE_HEADER_SIZE, 1, g_wave_file_handle); + + newWav->data = (uint32_t *)&g_wav_header; + + audio_wav_init(newWav); + + // Remove header size from byte count + // Adjust note duration by divider value, wav tables in pcm_data.h are 200ms + // by default + bytesToRead = (newWav->header.length - WAVE_FILE_HEADER_SIZE); + + g_curr_play_index = 0; + g_total_play_count = bytesToRead; + + return newWav->header.sampFreq; +} + +uint32_t stop_wav_file(void) { + memset(&g_wave_file_info, 0, sizeof(g_wave_file_info)); + g_curr_play_index = 0; + g_total_play_count = 0; + if (g_wave_file_handle) { + fclose(g_wave_file_handle); + g_wave_file_handle = NULL; + } + if (wav_file_playback_callback) + wav_file_playback_callback = NULL; + + return 0; } diff --git a/apps/battery/app_battery.cpp b/apps/battery/app_battery.cpp index 5a7d47c..20a5e41 100644 --- a/apps/battery/app_battery.cpp +++ b/apps/battery/app_battery.cpp @@ -13,19 +13,19 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "app_battery.h" +#include "app_status_ind.h" +#include "app_thread.h" +#include "apps.h" #include "cmsis_os.h" -#include "tgt_hardware.h" -#include "pmu.h" -#include "hal_timer.h" +#include "hal_chipid.h" #include "hal_gpadc.h" -#include "hal_trace.h" #include "hal_gpio.h" #include "hal_iomux.h" -#include "hal_chipid.h" -#include "app_thread.h" -#include "app_battery.h" -#include "apps.h" -#include "app_status_ind.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "pmu.h" +#include "tgt_hardware.h" #ifdef BT_USB_AUDIO_DUAL_MODE #include "btusb_audio.h" #endif @@ -39,7 +39,7 @@ extern "C" bool app_usbaudio_mode_on(void); #endif -#define APP_BATTERY_TRACE(s,...) +#define APP_BATTERY_TRACE(s, ...) // TRACE(s, ##__VA_ARGS__) #ifndef APP_BATTERY_MIN_MV @@ -51,7 +51,7 @@ extern "C" bool app_usbaudio_mode_on(void); #endif #ifndef APP_BATTERY_PD_MV -#define APP_BATTERY_PD_MV (3100) +#define APP_BATTERY_PD_MV (3100) #endif #ifndef APP_BATTERY_CHARGE_TIMEOUT_MIN @@ -74,21 +74,31 @@ extern "C" bool app_usbaudio_mode_on(void); #define CHARGER_PLUGINOUT_DEBOUNCE_CNT (3) #endif -#define APP_BATTERY_CHARGING_PLUGOUT_DEDOUNCE_CNT (APP_BATTERY_CHARGING_PERIODIC_MS<500?3:1) +#define APP_BATTERY_CHARGING_PLUGOUT_DEDOUNCE_CNT \ + (APP_BATTERY_CHARGING_PERIODIC_MS < 500 ? 3 : 1) -#define APP_BATTERY_CHARGING_EXTPIN_MEASURE_CNT (APP_BATTERY_CHARGING_PERIODIC_MS<2*1000?2*1000/APP_BATTERY_CHARGING_PERIODIC_MS:1) +#define APP_BATTERY_CHARGING_EXTPIN_MEASURE_CNT \ + (APP_BATTERY_CHARGING_PERIODIC_MS < 2 * 1000 \ + ? 2 * 1000 / APP_BATTERY_CHARGING_PERIODIC_MS \ + : 1) #define APP_BATTERY_CHARGING_EXTPIN_DEDOUNCE_CNT (6) -#define APP_BATTERY_CHARGING_OVERVOLT_MEASURE_CNT (APP_BATTERY_CHARGING_PERIODIC_MS<2*1000?2*1000/APP_BATTERY_CHARGING_PERIODIC_MS:1) +#define APP_BATTERY_CHARGING_OVERVOLT_MEASURE_CNT \ + (APP_BATTERY_CHARGING_PERIODIC_MS < 2 * 1000 \ + ? 2 * 1000 / APP_BATTERY_CHARGING_PERIODIC_MS \ + : 1) #define APP_BATTERY_CHARGING_OVERVOLT_DEDOUNCE_CNT (3) -#define APP_BATTERY_CHARGING_SLOPE_MEASURE_CNT (APP_BATTERY_CHARGING_PERIODIC_MS<20*1000?20*1000/APP_BATTERY_CHARGING_PERIODIC_MS:1) +#define APP_BATTERY_CHARGING_SLOPE_MEASURE_CNT \ + (APP_BATTERY_CHARGING_PERIODIC_MS < 20 * 1000 \ + ? 20 * 1000 / APP_BATTERY_CHARGING_PERIODIC_MS \ + : 1) #define APP_BATTERY_CHARGING_SLOPE_TABLE_COUNT (6) - #define APP_BATTERY_REPORT_INTERVAL (5) -#define APP_BATTERY_MV_BASE ((APP_BATTERY_MAX_MV-APP_BATTERY_PD_MV)/(APP_BATTERY_LEVEL_NUM)) +#define APP_BATTERY_MV_BASE \ + ((APP_BATTERY_MAX_MV - APP_BATTERY_PD_MV) / (APP_BATTERY_LEVEL_NUM)) #define APP_BATTERY_STABLE_COUNT (5) #define APP_BATTERY_MEASURE_PERIODIC_FAST_MS (200) @@ -97,737 +107,697 @@ extern "C" bool app_usbaudio_mode_on(void); #else #define APP_BATTERY_MEASURE_PERIODIC_NORMAL_MS (10000) #endif -#define APP_BATTERY_CHARGING_PERIODIC_MS (APP_BATTERY_MEASURE_PERIODIC_NORMAL_MS) +#define APP_BATTERY_CHARGING_PERIODIC_MS \ + (APP_BATTERY_MEASURE_PERIODIC_NORMAL_MS) -#define APP_BATTERY_SET_MESSAGE(appevt, status, volt) (appevt = (((uint32_t)status&0xffff)<<16)|(volt&0xffff)) -#define APP_BATTERY_GET_STATUS(appevt, status) (status = (appevt>>16)&0xffff) -#define APP_BATTERY_GET_VOLT(appevt, volt) (volt = appevt&0xffff) -#define APP_BATTERY_GET_PRAMS(appevt, prams) ((prams) = appevt&0xffff) +#define APP_BATTERY_SET_MESSAGE(appevt, status, volt) \ + (appevt = (((uint32_t)status & 0xffff) << 16) | (volt & 0xffff)) +#define APP_BATTERY_GET_STATUS(appevt, status) \ + (status = (appevt >> 16) & 0xffff) +#define APP_BATTERY_GET_VOLT(appevt, volt) (volt = appevt & 0xffff) +#define APP_BATTERY_GET_PRAMS(appevt, prams) ((prams) = appevt & 0xffff) -enum APP_BATTERY_MEASURE_PERIODIC_T -{ - APP_BATTERY_MEASURE_PERIODIC_FAST = 0, - APP_BATTERY_MEASURE_PERIODIC_NORMAL, - APP_BATTERY_MEASURE_PERIODIC_CHARGING, +enum APP_BATTERY_MEASURE_PERIODIC_T { + APP_BATTERY_MEASURE_PERIODIC_FAST = 0, + APP_BATTERY_MEASURE_PERIODIC_NORMAL, + APP_BATTERY_MEASURE_PERIODIC_CHARGING, - APP_BATTERY_MEASURE_PERIODIC_QTY, + APP_BATTERY_MEASURE_PERIODIC_QTY, }; -struct APP_BATTERY_MEASURE_CHARGER_STATUS_T -{ - HAL_GPADC_MV_T prevolt; - int32_t slope_1000[APP_BATTERY_CHARGING_SLOPE_TABLE_COUNT]; - int slope_1000_index; - int cnt; +struct APP_BATTERY_MEASURE_CHARGER_STATUS_T { + HAL_GPADC_MV_T prevolt; + int32_t slope_1000[APP_BATTERY_CHARGING_SLOPE_TABLE_COUNT]; + int slope_1000_index; + int cnt; }; +typedef void (*APP_BATTERY_EVENT_CB_T)(enum APP_BATTERY_STATUS_T, + APP_BATTERY_MV_T volt); -typedef void (*APP_BATTERY_EVENT_CB_T)(enum APP_BATTERY_STATUS_T, APP_BATTERY_MV_T volt); - -struct APP_BATTERY_MEASURE_T -{ - uint32_t start_time; - enum APP_BATTERY_STATUS_T status; +struct APP_BATTERY_MEASURE_T { + uint32_t start_time; + enum APP_BATTERY_STATUS_T status; #ifdef __INTERCONNECTION__ - uint8_t currentBatteryInfo; - uint8_t lastBatteryInfo; - uint8_t isMobileSupportSelfDefinedCommand; + uint8_t currentBatteryInfo; + uint8_t lastBatteryInfo; + uint8_t isMobileSupportSelfDefinedCommand; #else - uint8_t currlevel; + uint8_t currlevel; #endif - APP_BATTERY_MV_T currvolt; - APP_BATTERY_MV_T lowvolt; - APP_BATTERY_MV_T highvolt; - APP_BATTERY_MV_T pdvolt; - uint32_t chargetimeout; - enum APP_BATTERY_MEASURE_PERIODIC_T periodic; - HAL_GPADC_MV_T voltage[APP_BATTERY_STABLE_COUNT]; - uint16_t index; - struct APP_BATTERY_MEASURE_CHARGER_STATUS_T charger_status; - APP_BATTERY_EVENT_CB_T cb; - APP_BATTERY_CB_T user_cb; + APP_BATTERY_MV_T currvolt; + APP_BATTERY_MV_T lowvolt; + APP_BATTERY_MV_T highvolt; + APP_BATTERY_MV_T pdvolt; + uint32_t chargetimeout; + enum APP_BATTERY_MEASURE_PERIODIC_T periodic; + HAL_GPADC_MV_T voltage[APP_BATTERY_STABLE_COUNT]; + uint16_t index; + struct APP_BATTERY_MEASURE_CHARGER_STATUS_T charger_status; + APP_BATTERY_EVENT_CB_T cb; + APP_BATTERY_CB_T user_cb; }; static enum APP_BATTERY_CHARGER_T app_battery_charger_forcegetstatus(void); static void app_battery_pluginout_debounce_start(void); static void app_battery_pluginout_debounce_handler(void const *param); -osTimerDef (APP_BATTERY_PLUGINOUT_DEBOUNCE, app_battery_pluginout_debounce_handler); +osTimerDef(APP_BATTERY_PLUGINOUT_DEBOUNCE, + app_battery_pluginout_debounce_handler); static osTimerId app_battery_pluginout_debounce_timer = NULL; static uint32_t app_battery_pluginout_debounce_ctx = 0; static uint32_t app_battery_pluginout_debounce_cnt = 0; static void app_battery_timer_handler(void const *param); -osTimerDef (APP_BATTERY, app_battery_timer_handler); +osTimerDef(APP_BATTERY, app_battery_timer_handler); static osTimerId app_battery_timer = NULL; static struct APP_BATTERY_MEASURE_T app_battery_measure; static int app_battery_charger_handle_process(void); #ifdef __INTERCONNECTION__ -uint8_t* app_battery_get_mobile_support_self_defined_command_p(void) -{ - return &app_battery_measure.isMobileSupportSelfDefinedCommand; +uint8_t *app_battery_get_mobile_support_self_defined_command_p(void) { + return &app_battery_measure.isMobileSupportSelfDefinedCommand; } #endif - -void app_battery_irqhandler(uint16_t irq_val, HAL_GPADC_MV_T volt) -{ - uint8_t i; - uint32_t meanBattVolt = 0; - HAL_GPADC_MV_T vbat = volt; - APP_BATTERY_TRACE(2,"%s %d",__func__, vbat); - if (vbat == HAL_GPADC_BAD_VALUE) - { - app_battery_measure.cb(APP_BATTERY_STATUS_INVALID, vbat); - return; - } +void app_battery_irqhandler(uint16_t irq_val, HAL_GPADC_MV_T volt) { + uint8_t i; + uint32_t meanBattVolt = 0; + HAL_GPADC_MV_T vbat = volt; + APP_BATTERY_TRACE(2, "%s %d", __func__, vbat); + if (vbat == HAL_GPADC_BAD_VALUE) { + app_battery_measure.cb(APP_BATTERY_STATUS_INVALID, vbat); + return; + } #if (defined(BTUSB_AUDIO_MODE) || defined(BTUSB_AUDIO_MODE)) - if(app_usbaudio_mode_on()) return ; + if (app_usbaudio_mode_on()) + return; #endif - app_battery_measure.voltage[app_battery_measure.index++%APP_BATTERY_STABLE_COUNT] = vbat<<2; + app_battery_measure + .voltage[app_battery_measure.index++ % APP_BATTERY_STABLE_COUNT] = vbat + << 2; - if (app_battery_measure.index > APP_BATTERY_STABLE_COUNT) - { - for (i=0; iapp_battery_measure.highvolt) - { - app_battery_measure.cb(APP_BATTERY_STATUS_OVERVOLT, meanBattVolt); - } - else if((meanBattVolt>app_battery_measure.pdvolt) && (meanBattVolt APP_BATTERY_STABLE_COUNT) { + for (i = 0; i < APP_BATTERY_STABLE_COUNT; i++) { + meanBattVolt += app_battery_measure.voltage[i]; } - else - { - int8_t level = 0; - meanBattVolt = vbat<<2; - level = (meanBattVolt-APP_BATTERY_PD_MV)/APP_BATTERY_MV_BASE; - - if (levelAPP_BATTERY_LEVEL_MAX) - level = APP_BATTERY_LEVEL_MAX; - - app_battery_measure.currvolt = meanBattVolt; -#ifdef __INTERCONNECTION__ - APP_BATTERY_INFO_T* pBatteryInfo = (APP_BATTERY_INFO_T*)&app_battery_measure.currentBatteryInfo; - pBatteryInfo->batteryLevel = level; -#else - app_battery_measure.currlevel = level; -#endif + meanBattVolt /= APP_BATTERY_STABLE_COUNT; + if (app_battery_measure.cb) { + if (meanBattVolt > app_battery_measure.highvolt) { + app_battery_measure.cb(APP_BATTERY_STATUS_OVERVOLT, meanBattVolt); + } else if ((meanBattVolt > app_battery_measure.pdvolt) && + (meanBattVolt < app_battery_measure.lowvolt)) { + app_battery_measure.cb(APP_BATTERY_STATUS_UNDERVOLT, meanBattVolt); + } else if (meanBattVolt < app_battery_measure.pdvolt) { + app_battery_measure.cb(APP_BATTERY_STATUS_PDVOLT, meanBattVolt); + } else { + app_battery_measure.cb(APP_BATTERY_STATUS_NORMAL, meanBattVolt); + } } -} - -static void app_battery_timer_start(enum APP_BATTERY_MEASURE_PERIODIC_T periodic) -{ - uint32_t periodic_millisec = 0; - - if (app_battery_measure.periodic != periodic){ - app_battery_measure.periodic = periodic; - switch (periodic) - { - case APP_BATTERY_MEASURE_PERIODIC_FAST: - periodic_millisec = APP_BATTERY_MEASURE_PERIODIC_FAST_MS; - break; - case APP_BATTERY_MEASURE_PERIODIC_CHARGING: - periodic_millisec = APP_BATTERY_CHARGING_PERIODIC_MS; - break; - case APP_BATTERY_MEASURE_PERIODIC_NORMAL: - periodic_millisec = APP_BATTERY_MEASURE_PERIODIC_NORMAL_MS; - default: - break; - } - osTimerStop(app_battery_timer); - osTimerStart(app_battery_timer, periodic_millisec); - } -} - -static void app_battery_timer_handler(void const *param) -{ - hal_gpadc_open(HAL_GPADC_CHAN_BATTERY, HAL_GPADC_ATP_ONESHOT, app_battery_irqhandler); -} - -static void app_battery_event_process(enum APP_BATTERY_STATUS_T status, APP_BATTERY_MV_T volt) -{ - uint32_t app_battevt; - APP_MESSAGE_BLOCK msg; - - APP_BATTERY_TRACE(3,"%s %d,%d",__func__, status, volt); - msg.mod_id = APP_MODUAL_BATTERY; - APP_BATTERY_SET_MESSAGE(app_battevt, status, volt); - msg.msg_body.message_id = app_battevt; - msg.msg_body.message_ptr = (uint32_t)NULL; - app_mailbox_put(&msg); - -} - -int app_battery_handle_process_normal(uint32_t status, union APP_BATTERY_MSG_PRAMS prams) -{ + } else { int8_t level = 0; + meanBattVolt = vbat << 2; + level = (meanBattVolt - APP_BATTERY_PD_MV) / APP_BATTERY_MV_BASE; - switch (status) - { - case APP_BATTERY_STATUS_UNDERVOLT: - TRACE(1,"UNDERVOLT:%d", prams.volt); - app_status_indication_set(APP_STATUS_INDICATION_CHARGENEED); + if (level < APP_BATTERY_LEVEL_MIN) + level = APP_BATTERY_LEVEL_MIN; + if (level > APP_BATTERY_LEVEL_MAX) + level = APP_BATTERY_LEVEL_MAX; + + app_battery_measure.currvolt = meanBattVolt; +#ifdef __INTERCONNECTION__ + APP_BATTERY_INFO_T *pBatteryInfo = + (APP_BATTERY_INFO_T *)&app_battery_measure.currentBatteryInfo; + pBatteryInfo->batteryLevel = level; +#else + app_battery_measure.currlevel = level; +#endif + } +} + +static void +app_battery_timer_start(enum APP_BATTERY_MEASURE_PERIODIC_T periodic) { + uint32_t periodic_millisec = 0; + + if (app_battery_measure.periodic != periodic) { + app_battery_measure.periodic = periodic; + switch (periodic) { + case APP_BATTERY_MEASURE_PERIODIC_FAST: + periodic_millisec = APP_BATTERY_MEASURE_PERIODIC_FAST_MS; + break; + case APP_BATTERY_MEASURE_PERIODIC_CHARGING: + periodic_millisec = APP_BATTERY_CHARGING_PERIODIC_MS; + break; + case APP_BATTERY_MEASURE_PERIODIC_NORMAL: + periodic_millisec = APP_BATTERY_MEASURE_PERIODIC_NORMAL_MS; + default: + break; + } + osTimerStop(app_battery_timer); + osTimerStart(app_battery_timer, periodic_millisec); + } +} + +static void app_battery_timer_handler(void const *param) { + hal_gpadc_open(HAL_GPADC_CHAN_BATTERY, HAL_GPADC_ATP_ONESHOT, + app_battery_irqhandler); +} + +static void app_battery_event_process(enum APP_BATTERY_STATUS_T status, + APP_BATTERY_MV_T volt) { + uint32_t app_battevt; + APP_MESSAGE_BLOCK msg; + + APP_BATTERY_TRACE(3, "%s %d,%d", __func__, status, volt); + msg.mod_id = APP_MODUAL_BATTERY; + APP_BATTERY_SET_MESSAGE(app_battevt, status, volt); + msg.msg_body.message_id = app_battevt; + msg.msg_body.message_ptr = (uint32_t)NULL; + app_mailbox_put(&msg); +} + +int app_battery_handle_process_normal(uint32_t status, + union APP_BATTERY_MSG_PRAMS prams) { + int8_t level = 0; + + switch (status) { + case APP_BATTERY_STATUS_UNDERVOLT: + TRACE(1, "UNDERVOLT:%d", prams.volt); + app_status_indication_set(APP_STATUS_INDICATION_CHARGENEED); #ifdef MEDIA_PLAYER_SUPPORT #if defined(IBRT) #else - app_voice_report(APP_STATUS_INDICATION_CHARGENEED, 0); + app_voice_report(APP_STATUS_INDICATION_CHARGENEED, 0); #endif #endif - case APP_BATTERY_STATUS_NORMAL: - case APP_BATTERY_STATUS_OVERVOLT: - app_battery_measure.currvolt = prams.volt; - level = (prams.volt-APP_BATTERY_PD_MV)/APP_BATTERY_MV_BASE; + case APP_BATTERY_STATUS_NORMAL: + case APP_BATTERY_STATUS_OVERVOLT: + app_battery_measure.currvolt = prams.volt; + level = (prams.volt - APP_BATTERY_PD_MV) / APP_BATTERY_MV_BASE; - if (levelAPP_BATTERY_LEVEL_MAX) - level = APP_BATTERY_LEVEL_MAX; + if (level < APP_BATTERY_LEVEL_MIN) + level = APP_BATTERY_LEVEL_MIN; + if (level > APP_BATTERY_LEVEL_MAX) + level = APP_BATTERY_LEVEL_MAX; #ifdef __INTERCONNECTION__ - APP_BATTERY_INFO_T* pBatteryInfo; - pBatteryInfo = (APP_BATTERY_INFO_T*)&app_battery_measure.currentBatteryInfo; - pBatteryInfo->batteryLevel = level; - if(level == APP_BATTERY_LEVEL_MAX) - { - level = 9; - } - else - { - level /= 10; - } + APP_BATTERY_INFO_T *pBatteryInfo; + pBatteryInfo = + (APP_BATTERY_INFO_T *)&app_battery_measure.currentBatteryInfo; + pBatteryInfo->batteryLevel = level; + if (level == APP_BATTERY_LEVEL_MAX) { + level = 9; + } else { + level /= 10; + } #else - app_battery_measure.currlevel = level; + app_battery_measure.currlevel = level; #endif - app_status_battery_report(level); - break; - case APP_BATTERY_STATUS_PDVOLT: + app_status_battery_report(level); + break; + case APP_BATTERY_STATUS_PDVOLT: #ifndef BT_USB_AUDIO_DUAL_MODE - TRACE(1,"PDVOLT-->POWEROFF:%d", prams.volt); - osTimerStop(app_battery_timer); - app_shutdown(); + TRACE(1, "PDVOLT-->POWEROFF:%d", prams.volt); + osTimerStop(app_battery_timer); + app_shutdown(); #endif - break; - case APP_BATTERY_STATUS_CHARGING: - TRACE(1,"CHARGING-->APP_BATTERY_CHARGER :%d", prams.charger); - if (prams.charger == APP_BATTERY_CHARGER_PLUGIN) - { + break; + case APP_BATTERY_STATUS_CHARGING: + TRACE(1, "CHARGING-->APP_BATTERY_CHARGER :%d", prams.charger); + if (prams.charger == APP_BATTERY_CHARGER_PLUGIN) { #ifdef BT_USB_AUDIO_DUAL_MODE - TRACE(1,"%s:PLUGIN.", __func__); - btusb_switch(BTUSB_MODE_USB); + TRACE(1, "%s:PLUGIN.", __func__); + btusb_switch(BTUSB_MODE_USB); #else #if CHARGER_PLUGINOUT_RESET - app_reset(); + app_reset(); #else - app_battery_measure.status = APP_BATTERY_STATUS_CHARGING; + app_battery_measure.status = APP_BATTERY_STATUS_CHARGING; #endif #endif - }else{ - app_reset(); - } - break; - case APP_BATTERY_STATUS_INVALID: - default: - break; + } else { + app_reset(); } + break; + case APP_BATTERY_STATUS_INVALID: + default: + break; + } - app_battery_timer_start(APP_BATTERY_MEASURE_PERIODIC_NORMAL); - return 0; + app_battery_timer_start(APP_BATTERY_MEASURE_PERIODIC_NORMAL); + return 0; } -int app_battery_handle_process_charging(uint32_t status, union APP_BATTERY_MSG_PRAMS prams) -{ - switch (status) - { - case APP_BATTERY_STATUS_OVERVOLT: - case APP_BATTERY_STATUS_NORMAL: - case APP_BATTERY_STATUS_UNDERVOLT: - app_battery_measure.currvolt = prams.volt; - app_status_battery_report(prams.volt); - break; - case APP_BATTERY_STATUS_CHARGING: - TRACE(1,"CHARGING:%d", prams.charger); - if (prams.charger == APP_BATTERY_CHARGER_PLUGOUT) - { +int app_battery_handle_process_charging(uint32_t status, + union APP_BATTERY_MSG_PRAMS prams) { + switch (status) { + case APP_BATTERY_STATUS_OVERVOLT: + case APP_BATTERY_STATUS_NORMAL: + case APP_BATTERY_STATUS_UNDERVOLT: + app_battery_measure.currvolt = prams.volt; + app_status_battery_report(prams.volt); + break; + case APP_BATTERY_STATUS_CHARGING: + TRACE(1, "CHARGING:%d", prams.charger); + if (prams.charger == APP_BATTERY_CHARGER_PLUGOUT) { #ifdef BT_USB_AUDIO_DUAL_MODE - TRACE(1,"%s:PlUGOUT.", __func__); - btusb_switch(BTUSB_MODE_BT); + TRACE(1, "%s:PlUGOUT.", __func__); + btusb_switch(BTUSB_MODE_BT); #else #if CHARGER_PLUGINOUT_RESET - TRACE(0,"CHARGING-->RESET"); - app_reset(); + TRACE(0, "CHARGING-->RESET"); + app_reset(); #else - app_battery_measure.status = APP_BATTERY_STATUS_NORMAL; + app_battery_measure.status = APP_BATTERY_STATUS_NORMAL; #endif #endif - } - else if (prams.charger == APP_BATTERY_CHARGER_PLUGIN) - { + } else if (prams.charger == APP_BATTERY_CHARGER_PLUGIN) { #ifdef BT_USB_AUDIO_DUAL_MODE - TRACE(1,"%s:PLUGIN.", __func__); - btusb_switch(BTUSB_MODE_USB); + TRACE(1, "%s:PLUGIN.", __func__); + btusb_switch(BTUSB_MODE_USB); #endif - } - break; - case APP_BATTERY_STATUS_INVALID: - default: - break; } + break; + case APP_BATTERY_STATUS_INVALID: + default: + break; + } - if (app_battery_charger_handle_process()<=0) - { - if (app_status_indication_get() != APP_STATUS_INDICATION_FULLCHARGE) - { - TRACE(1,"FULL_CHARGING:%d", app_battery_measure.currvolt); - app_status_indication_set(APP_STATUS_INDICATION_FULLCHARGE); - app_shutdown(); + if (app_battery_charger_handle_process() <= 0) { + if (app_status_indication_get() != APP_STATUS_INDICATION_FULLCHARGE) { + TRACE(1, "FULL_CHARGING:%d", app_battery_measure.currvolt); + app_status_indication_set(APP_STATUS_INDICATION_FULLCHARGE); + app_shutdown(); #ifdef MEDIA_PLAYER_SUPPORT #if defined(BT_USB_AUDIO_DUAL_MODE) || defined(IBRT) #else - app_voice_report(APP_STATUS_INDICATION_FULLCHARGE, 0); + app_voice_report(APP_STATUS_INDICATION_FULLCHARGE, 0); #endif #endif - } } + } - app_battery_timer_start(APP_BATTERY_MEASURE_PERIODIC_CHARGING); + app_battery_timer_start(APP_BATTERY_MEASURE_PERIODIC_CHARGING); - return 0; + return 0; } -static int app_battery_handle_process(APP_MESSAGE_BODY *msg_body) -{ - uint8_t status; - union APP_BATTERY_MSG_PRAMS msg_prams; +static int app_battery_handle_process(APP_MESSAGE_BODY *msg_body) { + uint8_t status; + union APP_BATTERY_MSG_PRAMS msg_prams; - APP_BATTERY_GET_STATUS(msg_body->message_id, status); - APP_BATTERY_GET_PRAMS(msg_body->message_id, msg_prams.prams); + APP_BATTERY_GET_STATUS(msg_body->message_id, status); + APP_BATTERY_GET_PRAMS(msg_body->message_id, msg_prams.prams); - uint32_t generatedSeed = hal_sys_timer_get(); - for (uint8_t index = 0; index < sizeof(bt_addr); index++) - { - generatedSeed ^= (((uint32_t)(bt_addr[index])) << (hal_sys_timer_get()&0xF)); + uint32_t generatedSeed = hal_sys_timer_get(); + for (uint8_t index = 0; index < sizeof(bt_addr); index++) { + generatedSeed ^= + (((uint32_t)(bt_addr[index])) << (hal_sys_timer_get() & 0xF)); + } + srand(generatedSeed); + + if (status == APP_BATTERY_STATUS_PLUGINOUT) { + app_battery_pluginout_debounce_start(); + } else { + switch (app_battery_measure.status) { + case APP_BATTERY_STATUS_NORMAL: + app_battery_handle_process_normal((uint32_t)status, msg_prams); + break; + + case APP_BATTERY_STATUS_CHARGING: + app_battery_handle_process_charging((uint32_t)status, msg_prams); + break; + + default: + break; } - srand(generatedSeed); - - if (status == APP_BATTERY_STATUS_PLUGINOUT){ - app_battery_pluginout_debounce_start(); - } - else - { - switch (app_battery_measure.status) - { - case APP_BATTERY_STATUS_NORMAL: - app_battery_handle_process_normal((uint32_t)status, msg_prams); - break; - - case APP_BATTERY_STATUS_CHARGING: - app_battery_handle_process_charging((uint32_t)status, msg_prams); - break; - - default: - break; - } - } - if (NULL != app_battery_measure.user_cb) - { - uint8_t batteryLevel; + } + if (NULL != app_battery_measure.user_cb) { + uint8_t batteryLevel; #ifdef __INTERCONNECTION__ - APP_BATTERY_INFO_T* pBatteryInfo; - pBatteryInfo = (APP_BATTERY_INFO_T*)&app_battery_measure.currentBatteryInfo; - pBatteryInfo->chargingStatus = ((app_battery_measure.status == APP_BATTERY_STATUS_CHARGING)? 1:0); - batteryLevel = pBatteryInfo->batteryLevel; + APP_BATTERY_INFO_T *pBatteryInfo; + pBatteryInfo = + (APP_BATTERY_INFO_T *)&app_battery_measure.currentBatteryInfo; + pBatteryInfo->chargingStatus = + ((app_battery_measure.status == APP_BATTERY_STATUS_CHARGING) ? 1 : 0); + batteryLevel = pBatteryInfo->batteryLevel; #else - batteryLevel = app_battery_measure.currlevel; + batteryLevel = app_battery_measure.currlevel; #endif - app_battery_measure.user_cb(app_battery_measure.currvolt, - batteryLevel, app_battery_measure.status,status,msg_prams); - } + app_battery_measure.user_cb(app_battery_measure.currvolt, batteryLevel, + app_battery_measure.status, status, msg_prams); + } + return 0; +} + +int app_battery_register(APP_BATTERY_CB_T user_cb) { + if (NULL == app_battery_measure.user_cb) { + app_battery_measure.user_cb = user_cb; return 0; + } + return 1; } -int app_battery_register(APP_BATTERY_CB_T user_cb) -{ - if(NULL == app_battery_measure.user_cb) - { - app_battery_measure.user_cb = user_cb; - return 0; - } - return 1; -} +int app_battery_get_info(APP_BATTERY_MV_T *currvolt, uint8_t *currlevel, + enum APP_BATTERY_STATUS_T *status) { + if (currvolt) { + *currvolt = app_battery_measure.currvolt; + } -int app_battery_get_info(APP_BATTERY_MV_T *currvolt, uint8_t *currlevel, enum APP_BATTERY_STATUS_T *status) -{ - if (currvolt) - { - *currvolt = app_battery_measure.currvolt; - } - - if (currlevel) - { + if (currlevel) { #ifdef __INTERCONNECTION__ - *currlevel = app_battery_measure.currentBatteryInfo; + *currlevel = app_battery_measure.currentBatteryInfo; #else - *currlevel = app_battery_measure.currlevel; + *currlevel = app_battery_measure.currlevel; #endif - } + } - if (status) - { - *status = app_battery_measure.status; - } + if (status) { + *status = app_battery_measure.status; + } - return 0; + return 0; } -int app_battery_open(void) -{ - APP_BATTERY_TRACE(3,"%s batt range:%d~%d",__func__, APP_BATTERY_MIN_MV, APP_BATTERY_MAX_MV); - int nRet = APP_BATTERY_OPEN_MODE_INVALID; +int app_battery_open(void) { + APP_BATTERY_TRACE(3, "%s batt range:%d~%d", __func__, APP_BATTERY_MIN_MV, + APP_BATTERY_MAX_MV); + int nRet = APP_BATTERY_OPEN_MODE_INVALID; - if (app_battery_timer == NULL) - app_battery_timer = osTimerCreate (osTimer(APP_BATTERY), osTimerPeriodic, NULL); + if (app_battery_timer == NULL) + app_battery_timer = + osTimerCreate(osTimer(APP_BATTERY), osTimerPeriodic, NULL); - if (app_battery_pluginout_debounce_timer == NULL) - app_battery_pluginout_debounce_timer = osTimerCreate (osTimer(APP_BATTERY_PLUGINOUT_DEBOUNCE), osTimerOnce, &app_battery_pluginout_debounce_ctx); + if (app_battery_pluginout_debounce_timer == NULL) + app_battery_pluginout_debounce_timer = + osTimerCreate(osTimer(APP_BATTERY_PLUGINOUT_DEBOUNCE), osTimerOnce, + &app_battery_pluginout_debounce_ctx); - app_battery_measure.status = APP_BATTERY_STATUS_NORMAL; + app_battery_measure.status = APP_BATTERY_STATUS_NORMAL; #ifdef __INTERCONNECTION__ - app_battery_measure.currentBatteryInfo = APP_BATTERY_DEFAULT_INFO; - app_battery_measure.lastBatteryInfo = APP_BATTERY_DEFAULT_INFO; - app_battery_measure.isMobileSupportSelfDefinedCommand = 0; + app_battery_measure.currentBatteryInfo = APP_BATTERY_DEFAULT_INFO; + app_battery_measure.lastBatteryInfo = APP_BATTERY_DEFAULT_INFO; + app_battery_measure.isMobileSupportSelfDefinedCommand = 0; #else - app_battery_measure.currlevel = APP_BATTERY_LEVEL_MAX; + app_battery_measure.currlevel = APP_BATTERY_LEVEL_MAX; #endif - app_battery_measure.currvolt = APP_BATTERY_MAX_MV; - app_battery_measure.lowvolt = APP_BATTERY_MIN_MV; - app_battery_measure.highvolt = APP_BATTERY_MAX_MV; - app_battery_measure.pdvolt = APP_BATTERY_PD_MV; - app_battery_measure.chargetimeout = APP_BATTERY_CHARGE_TIMEOUT_MIN; + app_battery_measure.currvolt = APP_BATTERY_MAX_MV; + app_battery_measure.lowvolt = APP_BATTERY_MIN_MV; + app_battery_measure.highvolt = APP_BATTERY_MAX_MV; + app_battery_measure.pdvolt = APP_BATTERY_PD_MV; + app_battery_measure.chargetimeout = APP_BATTERY_CHARGE_TIMEOUT_MIN; - app_battery_measure.periodic = APP_BATTERY_MEASURE_PERIODIC_QTY; - app_battery_measure.cb = app_battery_event_process; - app_battery_measure.user_cb = NULL; + app_battery_measure.periodic = APP_BATTERY_MEASURE_PERIODIC_QTY; + app_battery_measure.cb = app_battery_event_process; + app_battery_measure.user_cb = NULL; - app_battery_measure.charger_status.prevolt = 0; - app_battery_measure.charger_status.slope_1000_index = 0; - app_battery_measure.charger_status.cnt = 0; + app_battery_measure.charger_status.prevolt = 0; + app_battery_measure.charger_status.slope_1000_index = 0; + app_battery_measure.charger_status.cnt = 0; - app_set_threadhandle(APP_MODUAL_BATTERY, app_battery_handle_process); + app_set_threadhandle(APP_MODUAL_BATTERY, app_battery_handle_process); - if (app_battery_ext_charger_detecter_cfg.pin != HAL_IOMUX_PIN_NUM) - { - hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)&app_battery_ext_charger_detecter_cfg, 1); - hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)app_battery_ext_charger_detecter_cfg.pin, HAL_GPIO_DIR_IN, 1); + if (app_battery_ext_charger_detecter_cfg.pin != HAL_IOMUX_PIN_NUM) { + hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP + *)&app_battery_ext_charger_detecter_cfg, + 1); + hal_gpio_pin_set_dir( + (enum HAL_GPIO_PIN_T)app_battery_ext_charger_detecter_cfg.pin, + HAL_GPIO_DIR_IN, 1); + } + + if (app_battery_ext_charger_enable_cfg.pin != HAL_IOMUX_PIN_NUM) { + hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP + *)&app_battery_ext_charger_detecter_cfg, + 1); + hal_gpio_pin_set_dir( + (enum HAL_GPIO_PIN_T)app_battery_ext_charger_detecter_cfg.pin, + HAL_GPIO_DIR_OUT, 1); + } + + if (app_battery_charger_indication_open() == APP_BATTERY_CHARGER_PLUGIN) { + app_battery_measure.status = APP_BATTERY_STATUS_CHARGING; + app_battery_measure.start_time = hal_sys_timer_get(); + // pmu_charger_plugin_config(); + if (app_battery_ext_charger_enable_cfg.pin != HAL_IOMUX_PIN_NUM) { + hal_gpio_pin_set_dir( + (enum HAL_GPIO_PIN_T)app_battery_ext_charger_detecter_cfg.pin, + HAL_GPIO_DIR_OUT, 0); } - if (app_battery_ext_charger_enable_cfg.pin != HAL_IOMUX_PIN_NUM) - { - hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)&app_battery_ext_charger_detecter_cfg, 1); - hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)app_battery_ext_charger_detecter_cfg.pin, HAL_GPIO_DIR_OUT, 1); - } - - if (app_battery_charger_indication_open() == APP_BATTERY_CHARGER_PLUGIN) - { - app_battery_measure.status = APP_BATTERY_STATUS_CHARGING; - app_battery_measure.start_time = hal_sys_timer_get(); - //pmu_charger_plugin_config(); - if (app_battery_ext_charger_enable_cfg.pin != HAL_IOMUX_PIN_NUM) - { - hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)app_battery_ext_charger_detecter_cfg.pin, HAL_GPIO_DIR_OUT, 0); - } - #if (CHARGER_PLUGINOUT_RESET == 0) - nRet = APP_BATTERY_OPEN_MODE_CHARGING_PWRON; + nRet = APP_BATTERY_OPEN_MODE_CHARGING_PWRON; #else - nRet = APP_BATTERY_OPEN_MODE_CHARGING; + nRet = APP_BATTERY_OPEN_MODE_CHARGING; #endif + } else { + app_battery_measure.status = APP_BATTERY_STATUS_NORMAL; + // pmu_charger_plugout_config(); + nRet = APP_BATTERY_OPEN_MODE_NORMAL; + } + return nRet; +} + +int app_battery_start(void) { + APP_BATTERY_TRACE(2, "%s %d", __func__, APP_BATTERY_MEASURE_PERIODIC_FAST_MS); + + app_battery_timer_start(APP_BATTERY_MEASURE_PERIODIC_FAST); + + return 0; +} + +int app_battery_stop(void) { + osTimerStop(app_battery_timer); + + return 0; +} + +int app_battery_close(void) { + hal_gpadc_close(HAL_GPADC_CHAN_BATTERY); + + return 0; +} + +static int32_t app_battery_charger_slope_calc(int32_t t1, int32_t v1, + int32_t t2, int32_t v2) { + int32_t slope_1000; + slope_1000 = (v2 - v1) * 1000 / (t2 - t1); + return slope_1000; +} + +static int app_battery_charger_handle_process(void) { + int nRet = 1; + int8_t i = 0, cnt = 0; + uint32_t slope_1000 = 0; + uint32_t charging_min; + static uint8_t overvolt_full_charge_cnt = 0; + static uint8_t ext_pin_full_charge_cnt = 0; + + charging_min = hal_sys_timer_get() - app_battery_measure.start_time; + charging_min = TICKS_TO_MS(charging_min) / 1000 / 60; + if (charging_min >= app_battery_measure.chargetimeout) { + // TRACE(0,"TIMEROUT-->FULL_CHARGING"); + nRet = -1; + goto exit; + } + + if ((app_battery_measure.charger_status.cnt++ % + APP_BATTERY_CHARGING_OVERVOLT_MEASURE_CNT) == 0) { + if (app_battery_measure.currvolt >= + (app_battery_measure.highvolt + APP_BATTERY_CHARGE_OFFSET_MV)) { + overvolt_full_charge_cnt++; + } else { + overvolt_full_charge_cnt = 0; } - else - { - app_battery_measure.status = APP_BATTERY_STATUS_NORMAL; - //pmu_charger_plugout_config(); - nRet = APP_BATTERY_OPEN_MODE_NORMAL; + if (overvolt_full_charge_cnt >= + APP_BATTERY_CHARGING_OVERVOLT_DEDOUNCE_CNT) { + // TRACE(0,"OVERVOLT-->FULL_CHARGING"); + nRet = -1; + goto exit; } - return nRet; -} + } -int app_battery_start(void) -{ - APP_BATTERY_TRACE(2,"%s %d",__func__, APP_BATTERY_MEASURE_PERIODIC_FAST_MS); - - app_battery_timer_start(APP_BATTERY_MEASURE_PERIODIC_FAST); - - return 0; -} - -int app_battery_stop(void) -{ - osTimerStop(app_battery_timer); - - return 0; -} - -int app_battery_close(void) -{ - hal_gpadc_close(HAL_GPADC_CHAN_BATTERY); - - return 0; -} - - -static int32_t app_battery_charger_slope_calc(int32_t t1, int32_t v1, int32_t t2, int32_t v2) -{ - int32_t slope_1000; - slope_1000 = (v2-v1)*1000/(t2-t1); - return slope_1000; -} - -static int app_battery_charger_handle_process(void) -{ - int nRet = 1; - int8_t i=0,cnt=0; - uint32_t slope_1000 = 0; - uint32_t charging_min; - static uint8_t overvolt_full_charge_cnt = 0; - static uint8_t ext_pin_full_charge_cnt = 0; - - charging_min = hal_sys_timer_get() - app_battery_measure.start_time; - charging_min = TICKS_TO_MS(charging_min)/1000/60; - if (charging_min >= app_battery_measure.chargetimeout) - { - // TRACE(0,"TIMEROUT-->FULL_CHARGING"); + if ((app_battery_measure.charger_status.cnt++ % + APP_BATTERY_CHARGING_EXTPIN_MEASURE_CNT) == 0) { + if (app_battery_ext_charger_detecter_cfg.pin != HAL_IOMUX_PIN_NUM) { + if (hal_gpio_pin_get_val( + (enum HAL_GPIO_PIN_T)app_battery_ext_charger_detecter_cfg.pin)) { + ext_pin_full_charge_cnt++; + } else { + ext_pin_full_charge_cnt = 0; + } + if (ext_pin_full_charge_cnt >= APP_BATTERY_CHARGING_EXTPIN_DEDOUNCE_CNT) { + TRACE(0, "EXT PIN-->FULL_CHARGING"); nRet = -1; goto exit; + } } + } - if ((app_battery_measure.charger_status.cnt++%APP_BATTERY_CHARGING_OVERVOLT_MEASURE_CNT) == 0) - { - if (app_battery_measure.currvolt>=(app_battery_measure.highvolt+APP_BATTERY_CHARGE_OFFSET_MV)) - { - overvolt_full_charge_cnt++; - } + if ((app_battery_measure.charger_status.cnt++ % + APP_BATTERY_CHARGING_SLOPE_MEASURE_CNT) == 0) { + if (!app_battery_measure.charger_status.prevolt) { + app_battery_measure.charger_status + .slope_1000[app_battery_measure.charger_status.slope_1000_index % + APP_BATTERY_CHARGING_SLOPE_TABLE_COUNT] = slope_1000; + app_battery_measure.charger_status.prevolt = app_battery_measure.currvolt; + for (i = 0; i < APP_BATTERY_CHARGING_SLOPE_TABLE_COUNT; i++) { + app_battery_measure.charger_status.slope_1000[i] = 100; + } + } else { + slope_1000 = app_battery_charger_slope_calc( + 0, app_battery_measure.charger_status.prevolt, + APP_BATTERY_CHARGING_PERIODIC_MS * + APP_BATTERY_CHARGING_SLOPE_MEASURE_CNT / 1000, + app_battery_measure.currvolt); + app_battery_measure.charger_status + .slope_1000[app_battery_measure.charger_status.slope_1000_index % + APP_BATTERY_CHARGING_SLOPE_TABLE_COUNT] = slope_1000; + app_battery_measure.charger_status.prevolt = app_battery_measure.currvolt; + for (i = 0; i < APP_BATTERY_CHARGING_SLOPE_TABLE_COUNT; i++) { + if (app_battery_measure.charger_status.slope_1000[i] > 0) + cnt++; else - { - overvolt_full_charge_cnt = 0; - } - if (overvolt_full_charge_cnt>=APP_BATTERY_CHARGING_OVERVOLT_DEDOUNCE_CNT) - { - //TRACE(0,"OVERVOLT-->FULL_CHARGING"); - nRet = -1; - goto exit; + cnt--; + TRACE(3, "slope_1000[%d]=%d cnt:%d", i, + app_battery_measure.charger_status.slope_1000[i], cnt); + } + TRACE(3, "app_battery_charger_slope_proc slope*1000=%d cnt:%d nRet:%d", + slope_1000, cnt, nRet); + if (cnt > 1) { + nRet = 1; + } /*else (3>=cnt && cnt>=-3){ + nRet = 0; + }*/ + else { + if (app_battery_measure.currvolt >= + (app_battery_measure.highvolt - APP_BATTERY_CHARGE_OFFSET_MV)) { + TRACE(0, "SLOPE-->FULL_CHARGING"); + nRet = -1; } + } } - - if ((app_battery_measure.charger_status.cnt++%APP_BATTERY_CHARGING_EXTPIN_MEASURE_CNT) == 0) - { - if (app_battery_ext_charger_detecter_cfg.pin != HAL_IOMUX_PIN_NUM) - { - if (hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)app_battery_ext_charger_detecter_cfg.pin)) - { - ext_pin_full_charge_cnt++; - } - else - { - ext_pin_full_charge_cnt = 0; - } - if (ext_pin_full_charge_cnt>=APP_BATTERY_CHARGING_EXTPIN_DEDOUNCE_CNT) - { - TRACE(0,"EXT PIN-->FULL_CHARGING"); - nRet = -1; - goto exit; - } - } - } - - if ((app_battery_measure.charger_status.cnt++%APP_BATTERY_CHARGING_SLOPE_MEASURE_CNT) == 0) - { - if (!app_battery_measure.charger_status.prevolt) - { - app_battery_measure.charger_status.slope_1000[app_battery_measure.charger_status.slope_1000_index%APP_BATTERY_CHARGING_SLOPE_TABLE_COUNT] = slope_1000; - app_battery_measure.charger_status.prevolt = app_battery_measure.currvolt; - for (i=0; i0) - cnt++; - else - cnt--; - TRACE(3,"slope_1000[%d]=%d cnt:%d", i,app_battery_measure.charger_status.slope_1000[i], cnt); - } - TRACE(3,"app_battery_charger_slope_proc slope*1000=%d cnt:%d nRet:%d", slope_1000, cnt, nRet); - if (cnt>1) - { - nRet = 1; - }/*else (3>=cnt && cnt>=-3){ - nRet = 0; - }*/else - { - if (app_battery_measure.currvolt>=(app_battery_measure.highvolt-APP_BATTERY_CHARGE_OFFSET_MV)) - { - TRACE(0,"SLOPE-->FULL_CHARGING"); - nRet = -1; - } - } - } - app_battery_measure.charger_status.slope_1000_index++; - } + app_battery_measure.charger_status.slope_1000_index++; + } exit: - return nRet; + return nRet; } -static enum APP_BATTERY_CHARGER_T app_battery_charger_forcegetstatus(void) -{ - enum APP_BATTERY_CHARGER_T status = APP_BATTERY_CHARGER_QTY; - enum PMU_CHARGER_STATUS_T charger; +static enum APP_BATTERY_CHARGER_T app_battery_charger_forcegetstatus(void) { + enum APP_BATTERY_CHARGER_T status = APP_BATTERY_CHARGER_QTY; + enum PMU_CHARGER_STATUS_T charger; - charger = pmu_charger_get_status(); + charger = pmu_charger_get_status(); - if (charger == PMU_CHARGER_PLUGIN) - { - status = APP_BATTERY_CHARGER_PLUGIN; - // TRACE(0,"force APP_BATTERY_CHARGER_PLUGIN"); - } - else - { - status = APP_BATTERY_CHARGER_PLUGOUT; - // TRACE(0,"force APP_BATTERY_CHARGER_PLUGOUT"); - } + if (charger == PMU_CHARGER_PLUGIN) { + status = APP_BATTERY_CHARGER_PLUGIN; + // TRACE(0,"force APP_BATTERY_CHARGER_PLUGIN"); + } else { + status = APP_BATTERY_CHARGER_PLUGOUT; + // TRACE(0,"force APP_BATTERY_CHARGER_PLUGOUT"); + } - return status; + return status; } -static void app_battery_charger_handler(enum PMU_CHARGER_STATUS_T status) -{ - TRACE(2,"%s: status=%d", __func__, status); - pmu_charger_set_irq_handler(NULL); - app_battery_event_process(APP_BATTERY_STATUS_PLUGINOUT, - (status == PMU_CHARGER_PLUGIN) ? APP_BATTERY_CHARGER_PLUGIN : APP_BATTERY_CHARGER_PLUGOUT); +static void app_battery_charger_handler(enum PMU_CHARGER_STATUS_T status) { + TRACE(2, "%s: status=%d", __func__, status); + pmu_charger_set_irq_handler(NULL); + app_battery_event_process(APP_BATTERY_STATUS_PLUGINOUT, + (status == PMU_CHARGER_PLUGIN) + ? APP_BATTERY_CHARGER_PLUGIN + : APP_BATTERY_CHARGER_PLUGOUT); } -static void app_battery_pluginout_debounce_start(void) -{ - TRACE(1,"%s", __func__); - app_battery_pluginout_debounce_ctx = (uint32_t)app_battery_charger_forcegetstatus(); - app_battery_pluginout_debounce_cnt = 1; - osTimerStart(app_battery_pluginout_debounce_timer, CHARGER_PLUGINOUT_DEBOUNCE_MS); +static void app_battery_pluginout_debounce_start(void) { + TRACE(1, "%s", __func__); + app_battery_pluginout_debounce_ctx = + (uint32_t)app_battery_charger_forcegetstatus(); + app_battery_pluginout_debounce_cnt = 1; + osTimerStart(app_battery_pluginout_debounce_timer, + CHARGER_PLUGINOUT_DEBOUNCE_MS); } -static void app_battery_pluginout_debounce_handler(void const *param) -{ - enum APP_BATTERY_CHARGER_T status_charger = app_battery_charger_forcegetstatus(); +static void app_battery_pluginout_debounce_handler(void const *param) { + enum APP_BATTERY_CHARGER_T status_charger = + app_battery_charger_forcegetstatus(); - if(app_battery_pluginout_debounce_ctx == (uint32_t) status_charger){ - app_battery_pluginout_debounce_cnt++; + if (app_battery_pluginout_debounce_ctx == (uint32_t)status_charger) { + app_battery_pluginout_debounce_cnt++; + } else { + TRACE(2, "%s dithering cnt %u", __func__, + app_battery_pluginout_debounce_cnt); + app_battery_pluginout_debounce_cnt = 0; + app_battery_pluginout_debounce_ctx = (uint32_t)status_charger; + } + + if (app_battery_pluginout_debounce_cnt >= CHARGER_PLUGINOUT_DEBOUNCE_CNT) { + TRACE(2, "%s %s", __func__, + status_charger == APP_BATTERY_CHARGER_PLUGOUT ? "PLUGOUT" : "PLUGIN"); + if (status_charger == APP_BATTERY_CHARGER_PLUGIN) { + if (app_battery_ext_charger_enable_cfg.pin != HAL_IOMUX_PIN_NUM) { + hal_gpio_pin_set_dir( + (enum HAL_GPIO_PIN_T)app_battery_ext_charger_detecter_cfg.pin, + HAL_GPIO_DIR_OUT, 0); + } + app_battery_measure.start_time = hal_sys_timer_get(); + } else { + if (app_battery_ext_charger_enable_cfg.pin != HAL_IOMUX_PIN_NUM) { + hal_gpio_pin_set_dir( + (enum HAL_GPIO_PIN_T)app_battery_ext_charger_detecter_cfg.pin, + HAL_GPIO_DIR_OUT, 1); + } } - else - { - TRACE(2,"%s dithering cnt %u", __func__, app_battery_pluginout_debounce_cnt); - app_battery_pluginout_debounce_cnt = 0; - app_battery_pluginout_debounce_ctx = (uint32_t)status_charger; - } - - if (app_battery_pluginout_debounce_cnt >= CHARGER_PLUGINOUT_DEBOUNCE_CNT){ - TRACE(2,"%s %s", __func__, status_charger == APP_BATTERY_CHARGER_PLUGOUT ? "PLUGOUT" : "PLUGIN"); - if (status_charger == APP_BATTERY_CHARGER_PLUGIN) - { - if (app_battery_ext_charger_enable_cfg.pin != HAL_IOMUX_PIN_NUM) - { - hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)app_battery_ext_charger_detecter_cfg.pin, HAL_GPIO_DIR_OUT, 0); - } - app_battery_measure.start_time = hal_sys_timer_get(); - } - else - { - if (app_battery_ext_charger_enable_cfg.pin != HAL_IOMUX_PIN_NUM) - { - hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)app_battery_ext_charger_detecter_cfg.pin, HAL_GPIO_DIR_OUT, 1); - } - } - app_battery_event_process(APP_BATTERY_STATUS_CHARGING, status_charger); - pmu_charger_set_irq_handler(app_battery_charger_handler); - osTimerStop(app_battery_pluginout_debounce_timer); - }else{ - osTimerStart(app_battery_pluginout_debounce_timer, CHARGER_PLUGINOUT_DEBOUNCE_MS); - } -} - -int app_battery_charger_indication_open(void) -{ - enum APP_BATTERY_CHARGER_T status = APP_BATTERY_CHARGER_QTY; - uint8_t cnt = 0; - - APP_BATTERY_TRACE(1,"%s",__func__); - - pmu_charger_init(); - - do - { - status = app_battery_charger_forcegetstatus(); - if (status == APP_BATTERY_CHARGER_PLUGIN) - break; - osDelay(20); - } - while(cnt++<5); - - if (app_battery_ext_charger_detecter_cfg.pin != HAL_IOMUX_PIN_NUM) - { - if (!hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)app_battery_ext_charger_detecter_cfg.pin)) - { - status = APP_BATTERY_CHARGER_PLUGIN; - } - } - + app_battery_event_process(APP_BATTERY_STATUS_CHARGING, status_charger); pmu_charger_set_irq_handler(app_battery_charger_handler); - - return status; + osTimerStop(app_battery_pluginout_debounce_timer); + } else { + osTimerStart(app_battery_pluginout_debounce_timer, + CHARGER_PLUGINOUT_DEBOUNCE_MS); + } } -int8_t app_battery_current_level(void) -{ +int app_battery_charger_indication_open(void) { + enum APP_BATTERY_CHARGER_T status = APP_BATTERY_CHARGER_QTY; + uint8_t cnt = 0; + + APP_BATTERY_TRACE(1, "%s", __func__); + + pmu_charger_init(); + + do { + status = app_battery_charger_forcegetstatus(); + if (status == APP_BATTERY_CHARGER_PLUGIN) + break; + osDelay(20); + } while (cnt++ < 5); + + if (app_battery_ext_charger_detecter_cfg.pin != HAL_IOMUX_PIN_NUM) { + if (!hal_gpio_pin_get_val( + (enum HAL_GPIO_PIN_T)app_battery_ext_charger_detecter_cfg.pin)) { + status = APP_BATTERY_CHARGER_PLUGIN; + } + } + + pmu_charger_set_irq_handler(app_battery_charger_handler); + + return status; +} + +int8_t app_battery_current_level(void) { #ifdef __INTERCONNECTION__ - return app_battery_measure.currentBatteryInfo & 0x7f; + return app_battery_measure.currentBatteryInfo & 0x7f; #else - return app_battery_measure.currlevel; + return app_battery_measure.currlevel; #endif } -int8_t app_battery_is_charging(void) -{ - return (APP_BATTERY_STATUS_CHARGING == app_battery_measure.status); +int8_t app_battery_is_charging(void) { + return (APP_BATTERY_STATUS_CHARGING == app_battery_measure.status); } typedef uint16_t NTP_VOLTAGE_MV_T; @@ -840,64 +810,61 @@ typedef uint16_t NTP_TEMPERATURE_C_T; typedef void (*NTC_CAPTURE_MEASURE_CB_T)(NTP_TEMPERATURE_C_T); -struct NTC_CAPTURE_MEASURE_T -{ - NTP_TEMPERATURE_C_T temperature; - NTP_VOLTAGE_MV_T currvolt; - NTP_VOLTAGE_MV_T voltage[NTC_CAPTURE_STABLE_COUNT]; - uint16_t index; - NTC_CAPTURE_MEASURE_CB_T cb; +struct NTC_CAPTURE_MEASURE_T { + NTP_TEMPERATURE_C_T temperature; + NTP_VOLTAGE_MV_T currvolt; + NTP_VOLTAGE_MV_T voltage[NTC_CAPTURE_STABLE_COUNT]; + uint16_t index; + NTC_CAPTURE_MEASURE_CB_T cb; }; static struct NTC_CAPTURE_MEASURE_T ntc_capture_measure; -void ntc_capture_irqhandler(uint16_t irq_val, HAL_GPADC_MV_T volt) -{ - uint32_t meanVolt = 0; - TRACE(3,"%s %d irq:0x%04x",__func__, volt, irq_val); +void ntc_capture_irqhandler(uint16_t irq_val, HAL_GPADC_MV_T volt) { + uint32_t meanVolt = 0; + TRACE(3, "%s %d irq:0x%04x", __func__, volt, irq_val); - if (volt == HAL_GPADC_BAD_VALUE) - { - return; - } + if (volt == HAL_GPADC_BAD_VALUE) { + return; + } - ntc_capture_measure.voltage[ntc_capture_measure.index++%NTC_CAPTURE_STABLE_COUNT] = volt; + ntc_capture_measure + .voltage[ntc_capture_measure.index++ % NTC_CAPTURE_STABLE_COUNT] = volt; - if (ntc_capture_measure.index > NTC_CAPTURE_STABLE_COUNT) - { - for (uint8_t i=0; i NTC_CAPTURE_STABLE_COUNT) { + for (uint8_t i = 0; i < NTC_CAPTURE_STABLE_COUNT; i++) { + meanVolt += ntc_capture_measure.voltage[i]; } - else if (!ntc_capture_measure.currvolt) - { - ntc_capture_measure.currvolt = volt; - } - ntc_capture_measure.temperature = ((int32_t)ntc_capture_measure.currvolt - NTC_CAPTURE_VOLTAGE_REF)/NTC_CAPTURE_TEMPERATURE_STEP + NTC_CAPTURE_TEMPERATURE_REF; - pmu_ntc_capture_disable(); - TRACE(3,"%s ad:%d temperature:%d",__func__, ntc_capture_measure.currvolt, ntc_capture_measure.temperature); + meanVolt /= NTC_CAPTURE_STABLE_COUNT; + ntc_capture_measure.currvolt = meanVolt; + } else if (!ntc_capture_measure.currvolt) { + ntc_capture_measure.currvolt = volt; + } + ntc_capture_measure.temperature = + ((int32_t)ntc_capture_measure.currvolt - NTC_CAPTURE_VOLTAGE_REF) / + NTC_CAPTURE_TEMPERATURE_STEP + + NTC_CAPTURE_TEMPERATURE_REF; + pmu_ntc_capture_disable(); + TRACE(3, "%s ad:%d temperature:%d", __func__, ntc_capture_measure.currvolt, + ntc_capture_measure.temperature); } -int ntc_capture_open(void) -{ +int ntc_capture_open(void) { - ntc_capture_measure.currvolt = 0; - ntc_capture_measure.index = 0; - ntc_capture_measure.temperature = 0; - ntc_capture_measure.cb = NULL; + ntc_capture_measure.currvolt = 0; + ntc_capture_measure.index = 0; + ntc_capture_measure.temperature = 0; + ntc_capture_measure.cb = NULL; - pmu_ntc_capture_enable(); - hal_gpadc_open(HAL_GPADC_CHAN_0, HAL_GPADC_ATP_ONESHOT, ntc_capture_irqhandler); - return 0; + pmu_ntc_capture_enable(); + hal_gpadc_open(HAL_GPADC_CHAN_0, HAL_GPADC_ATP_ONESHOT, + ntc_capture_irqhandler); + return 0; } -int ntc_capture_start(void) -{ - pmu_ntc_capture_enable(); - hal_gpadc_open(HAL_GPADC_CHAN_0, HAL_GPADC_ATP_ONESHOT, ntc_capture_irqhandler); - return 0; +int ntc_capture_start(void) { + pmu_ntc_capture_enable(); + hal_gpadc_open(HAL_GPADC_CHAN_0, HAL_GPADC_ATP_ONESHOT, + ntc_capture_irqhandler); + return 0; } - diff --git a/apps/btusbaudio/btusb_audio.c b/apps/btusbaudio/btusb_audio.c index 06b4875..5769820 100644 --- a/apps/btusbaudio/btusb_audio.c +++ b/apps/btusbaudio/btusb_audio.c @@ -13,22 +13,22 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "stdio.h" +#include "app_audio.h" #include "cmsis_os.h" #include "hal_timer.h" #include "hal_trace.h" -#include "app_audio.h" +#include "stdio.h" #include "a2dp_api.h" #include "app_bt.h" #include "btapp.h" -#include "usb_audio_app.h" #include "btusb_audio.h" +#include "usb_audio_app.h" extern void btusbaudio_entry(void); extern void btusbaudio_exit(void); -extern a2dp_stream_t* app_bt_get_steam(enum BT_DEVICE_ID_T id); -extern int app_bt_get_bt_addr(enum BT_DEVICE_ID_T id,bt_bdaddr_t *bdaddr); +extern a2dp_stream_t *app_bt_get_steam(enum BT_DEVICE_ID_T id); +extern int app_bt_get_bt_addr(enum BT_DEVICE_ID_T id, bt_bdaddr_t *bdaddr); extern bool app_bt_a2dp_service_is_connected(void); int app_bt_A2DP_OpenStream(a2dp_stream_t *Stream, bt_bdaddr_t *Addr); int app_bt_A2DP_CloseStream(a2dp_stream_t *Stream); @@ -38,270 +38,223 @@ static bool btusb_usb_is_on = false; static enum BTUSB_MODE btusb_mode = BTUSB_MODE_INVALID; static bool btusb_bt_audio_is_suspend = false; -#define BT_USB_DEBUG() //TRACE(2,"_debug: %s,%d",__func__,__LINE__) -extern struct BT_DEVICE_T app_bt_device; +#define BT_USB_DEBUG() // TRACE(2,"_debug: %s,%d",__func__,__LINE__) +extern struct BT_DEVICE_T app_bt_device; -static void _btusb_stream_open(unsigned int timeout_ms) -{ - a2dp_stream_t *stream = NULL; - bt_bdaddr_t bdaddr; - uint32_t stime = 0; - uint32_t etime = 0; +static void _btusb_stream_open(unsigned int timeout_ms) { + a2dp_stream_t *stream = NULL; + bt_bdaddr_t bdaddr; + uint32_t stime = 0; + uint32_t etime = 0; - stime = hal_sys_timer_get(); - //BT_USB_DEBUG(); - stream = (a2dp_stream_t*)app_bt_get_steam(BT_DEVICE_ID_1); + stime = hal_sys_timer_get(); + // BT_USB_DEBUG(); + stream = (a2dp_stream_t *)app_bt_get_steam(BT_DEVICE_ID_1); - app_bt_get_bt_addr(BT_DEVICE_ID_1,&bdaddr); - if(stream) - { - //struct BT_DEVICE_T *bt_dev = &app_bt_device; - //A2DP_Register((a2dp_stream_t *)bt_dev->a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream, &a2dp_avdtpcodec, NULL, (A2dpCallback) a2dp_callback); - //AVRCP_Register((AvrcpChannel *)bt_dev->avrcp_channel[BT_DEVICE_ID_1]->avrcp_channel_handle, (AvrcpCallback)avrcp_callback_CT, BTIF_AVRCP_CT_CATEGORY_1 | BTIF_AVRCP_CT_CATEGORY_2 | BTIF_AVRCP_TG_CATEGORY_2); - BT_USB_DEBUG(); - osDelay(10); - app_bt_A2DP_OpenStream(stream,&bdaddr); + app_bt_get_bt_addr(BT_DEVICE_ID_1, &bdaddr); + if (stream) { + // struct BT_DEVICE_T *bt_dev = &app_bt_device; + // A2DP_Register((a2dp_stream_t + // *)bt_dev->a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream, &a2dp_avdtpcodec, + // NULL, (A2dpCallback) a2dp_callback); AVRCP_Register((AvrcpChannel + // *)bt_dev->avrcp_channel[BT_DEVICE_ID_1]->avrcp_channel_handle, + // (AvrcpCallback)avrcp_callback_CT, BTIF_AVRCP_CT_CATEGORY_1 | + // BTIF_AVRCP_CT_CATEGORY_2 | BTIF_AVRCP_TG_CATEGORY_2); + BT_USB_DEBUG(); + osDelay(10); + app_bt_A2DP_OpenStream(stream, &bdaddr); + } else { + BT_USB_DEBUG(); + return; + } + while (1) { + if (app_bt_a2dp_service_is_connected()) { + etime = hal_sys_timer_get(); + TRACE(1, "_debug: a2dp service connected, wait time = 0x%x.", + TICKS_TO_MS(etime - stime)); + break; + } else { + etime = hal_sys_timer_get(); + if (TICKS_TO_MS(etime - stime) >= timeout_ms) { + TRACE(1, "_debug: a2dp service connect timeout = 0x%x.", + TICKS_TO_MS(etime - stime)); + break; + } + osDelay(10); } - else - { - BT_USB_DEBUG(); + } + // BT_USB_DEBUG(); +} + +static void _btusb_stream_close(unsigned int timeout_ms) { + a2dp_stream_t *stream = NULL; + uint32_t stime = 0; + uint32_t etime = 0; + + stime = hal_sys_timer_get(); + BT_USB_DEBUG(); + stream = (a2dp_stream_t *)app_bt_get_steam(BT_DEVICE_ID_1); + if (stream) { + BT_USB_DEBUG(); + app_bt_A2DP_CloseStream(stream); + } else { + BT_USB_DEBUG(); + return; + } + stime = hal_sys_timer_get(); + while (1) { + if (!app_bt_a2dp_service_is_connected()) { + // struct BT_DEVICE_T *bt_dev = &app_bt_device; + // AVRCP_Deregister(bt_dev->avrcp_channel[BT_DEVICE_ID_1]->avrcp_channel_handle); + // A2DP_Deregister(stream); + etime = hal_sys_timer_get(); + TRACE(1, "a2dp service diconnected, wait time = 0x%x.", + TICKS_TO_MS(etime - stime)); + break; + } else { + etime = hal_sys_timer_get(); + if (TICKS_TO_MS(etime - stime) >= timeout_ms) { + TRACE(1, "a2dp service diconnect timeout = 0x%x.", + TICKS_TO_MS(etime - stime)); + break; + } + osDelay(10); + } + } + BT_USB_DEBUG(); +} + +static void btusb_usbaudio_entry(void) { + BT_USB_DEBUG(); + btusbaudio_entry(); + btusb_usb_is_on = true; +} + +void btusb_usbaudio_open(void) { + BT_USB_DEBUG(); + if (!btusb_usb_is_on) { + btusb_usbaudio_entry(); + BT_USB_DEBUG(); + } else { + usb_audio_app(1); + } + BT_USB_DEBUG(); +} + +void btusb_usbaudio_close(void) { + BT_USB_DEBUG(); + if (btusb_usb_is_on) { + usb_audio_app(0); + BT_USB_DEBUG(); + } else { + BT_USB_DEBUG(); + } +} + +void btusb_btaudio_close(bool is_wait) { + BT_USB_DEBUG(); + // if(!btusb_bt_audio_is_suspend) + { + BT_USB_DEBUG(); + if (is_wait) { + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, + (uint8_t)APP_BT_SETTING_CLOSEALL, 0); + _btusb_stream_close(BTUSB_OUTTIME_MS); + } else { + _btusb_stream_close(0); + } + btusb_bt_audio_is_suspend = true; + } +} + +void btusb_btaudio_open(bool is_wait) { + BT_USB_DEBUG(); + // if(btusb_bt_audio_is_suspend) + { + TRACE(2, "%s: %d.", __func__, __LINE__); + if (is_wait) { + _btusb_stream_open(BTUSB_OUTTIME_MS); + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_CLOSE, + 0); + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_SETUP, + 0); + } else { + _btusb_stream_open(0); + } + TRACE(2, "%s: %d.", __func__, __LINE__); + btusb_bt_audio_is_suspend = false; + } +} + +void btusb_switch(enum BTUSB_MODE mode) { + // BT_USB_DEBUG(); + if (mode != BTUSB_MODE_BT && mode != BTUSB_MODE_USB) { + ASSERT(0, "%s:%d, mode = %d.", __func__, __LINE__, mode); + } + + if (btusb_mode == mode) { + BT_USB_DEBUG(); + return; + } + + if (btusb_mode == BTUSB_MODE_INVALID) { + if (mode == BTUSB_MODE_BT) { + TRACE(1, "%s: switch to BT mode.", __func__); + btusb_mode = BTUSB_MODE_BT; + } else { + TRACE(1, "%s: switch to USB mode.", __func__); + // btusb_btaudio_close(true); + osDelay(500); + btusb_usbaudio_open(); + btusb_mode = BTUSB_MODE_USB; + } + } else { + if (mode == BTUSB_MODE_BT) { + TRACE(1, "%s: switch to BT mode.", __func__); + if (btusb_usb_is_on) { + TRACE(1, "%s: btusb_usbaudio_close.", __func__); + btusb_usbaudio_close(); + TRACE(1, "%s: btusb_usbaudio_close done.", __func__); + osDelay(500); + } + btusb_mode = BTUSB_MODE_BT; + btusb_btaudio_open(true); + TRACE(1, "%s: switch to BT mode done.", __func__); + } else { + if (btapp_hfp_is_call_active() == 1) { + TRACE(1, "%s: hfp is call active.", __func__); return; + } + TRACE(1, "%s: switch to USB mode.", __func__); + btusb_btaudio_close(true); + TRACE(1, "%s: btusb_btaudio_close done.", __func__); + osDelay(500); + btusb_usbaudio_open(); + btusb_mode = BTUSB_MODE_USB; + TRACE(1, "%s: switch to USB mode done.", __func__); } - while(1) - { - if(app_bt_a2dp_service_is_connected()){ - etime = hal_sys_timer_get(); - TRACE(1,"_debug: a2dp service connected, wait time = 0x%x.",TICKS_TO_MS(etime - stime)); - break; - } - else - { - etime = hal_sys_timer_get(); - if(TICKS_TO_MS(etime - stime) >= timeout_ms) - { - TRACE(1,"_debug: a2dp service connect timeout = 0x%x.", - TICKS_TO_MS(etime - stime)); - break; - } - osDelay(10); - } - } - //BT_USB_DEBUG(); + } } -static void _btusb_stream_close(unsigned int timeout_ms) -{ - a2dp_stream_t *stream = NULL; - uint32_t stime = 0; - uint32_t etime = 0; - - stime = hal_sys_timer_get(); - BT_USB_DEBUG(); - stream = (a2dp_stream_t*)app_bt_get_steam(BT_DEVICE_ID_1); - if(stream) - { - BT_USB_DEBUG(); - app_bt_A2DP_CloseStream(stream); - } - else - { - BT_USB_DEBUG(); - return; - } - stime = hal_sys_timer_get(); - while(1) - { - if(!app_bt_a2dp_service_is_connected()){ - //struct BT_DEVICE_T *bt_dev = &app_bt_device; - //AVRCP_Deregister(bt_dev->avrcp_channel[BT_DEVICE_ID_1]->avrcp_channel_handle); - //A2DP_Deregister(stream); - etime = hal_sys_timer_get(); - TRACE(1,"a2dp service diconnected, wait time = 0x%x.", - TICKS_TO_MS(etime - stime)); - break; - } - else - { - etime = hal_sys_timer_get(); - if(TICKS_TO_MS(etime - stime) >= timeout_ms) - { - TRACE(1,"a2dp service diconnect timeout = 0x%x.", - TICKS_TO_MS(etime - stime)); - break; - } - osDelay(10); - } - } - BT_USB_DEBUG(); +bool btusb_is_bt_mode(void) { + BT_USB_DEBUG(); + return btusb_mode == BTUSB_MODE_BT ? true : false; } -static void btusb_usbaudio_entry(void) -{ - BT_USB_DEBUG(); - btusbaudio_entry(); - btusb_usb_is_on = true ; +bool btusb_is_usb_mode(void) { + return btusb_mode == BTUSB_MODE_USB ? true : false; } -void btusb_usbaudio_open(void) -{ - BT_USB_DEBUG(); - if(!btusb_usb_is_on) - { - btusb_usbaudio_entry(); - BT_USB_DEBUG(); - } - else - { - usb_audio_app(1); - } - BT_USB_DEBUG(); -} - -void btusb_usbaudio_close(void) -{ - BT_USB_DEBUG(); - if(btusb_usb_is_on) - { - usb_audio_app(0); - BT_USB_DEBUG(); - } - else - { - BT_USB_DEBUG(); - } -} - -void btusb_btaudio_close(bool is_wait) -{ - BT_USB_DEBUG(); - //if(!btusb_bt_audio_is_suspend) - { - BT_USB_DEBUG(); - if(is_wait) - { - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_CLOSEALL, 0); - _btusb_stream_close(BTUSB_OUTTIME_MS); - } - else - { - _btusb_stream_close(0); - } - btusb_bt_audio_is_suspend = true; - } -} - -void btusb_btaudio_open(bool is_wait) -{ - BT_USB_DEBUG(); - //if(btusb_bt_audio_is_suspend) - { - TRACE(2,"%s: %d.",__func__,__LINE__); - if(is_wait) - { - _btusb_stream_open(BTUSB_OUTTIME_MS); - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_CLOSE, 0); - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_SETUP, 0); - } - else - { - _btusb_stream_open(0); - } - TRACE(2,"%s: %d.",__func__,__LINE__); - btusb_bt_audio_is_suspend = false; - } -} - -void btusb_switch(enum BTUSB_MODE mode) -{ - //BT_USB_DEBUG(); - if(mode != BTUSB_MODE_BT && mode != BTUSB_MODE_USB) - { - ASSERT(0, "%s:%d, mode = %d.",__func__,__LINE__,mode); - } - - if(btusb_mode == mode) { - BT_USB_DEBUG(); - return; - } - - if(btusb_mode == BTUSB_MODE_INVALID) - { - if(mode == BTUSB_MODE_BT) { - TRACE(1,"%s: switch to BT mode.",__func__); - btusb_mode = BTUSB_MODE_BT; - } - else { - TRACE(1,"%s: switch to USB mode.",__func__); - //btusb_btaudio_close(true); - osDelay(500); - btusb_usbaudio_open(); - btusb_mode = BTUSB_MODE_USB; - } - } - else - { - if(mode == BTUSB_MODE_BT) { - TRACE(1,"%s: switch to BT mode.",__func__); - if(btusb_usb_is_on) - { - TRACE(1,"%s: btusb_usbaudio_close.",__func__); - btusb_usbaudio_close(); - TRACE(1,"%s: btusb_usbaudio_close done.",__func__); - osDelay(500); - } - btusb_mode = BTUSB_MODE_BT; - btusb_btaudio_open(true); - TRACE(1,"%s: switch to BT mode done.",__func__); - } - else { - if(btapp_hfp_is_call_active() == 1) - { - TRACE(1,"%s: hfp is call active.",__func__); - return; - } - TRACE(1,"%s: switch to USB mode.",__func__); - btusb_btaudio_close(true); - TRACE(1,"%s: btusb_btaudio_close done.",__func__); - osDelay(500); - btusb_usbaudio_open(); - btusb_mode = BTUSB_MODE_USB; - TRACE(1,"%s: switch to USB mode done.",__func__); - } - } -} - -bool btusb_is_bt_mode(void) -{ - BT_USB_DEBUG(); - return btusb_mode == BTUSB_MODE_BT ? true : false; -} - -bool btusb_is_usb_mode(void) -{ - return btusb_mode == BTUSB_MODE_USB ? true : false; -} - - #if defined(BT_USB_AUDIO_DUAL_MODE_TEST) -void test_btusb_switch(void) -{ - if(btusb_mode == BTUSB_MODE_BT) - { - btusb_switch(BTUSB_MODE_USB); - } - else - { - btusb_switch(BTUSB_MODE_BT); - } +void test_btusb_switch(void) { + if (btusb_mode == BTUSB_MODE_BT) { + btusb_switch(BTUSB_MODE_USB); + } else { + btusb_switch(BTUSB_MODE_BT); + } } -void test_btusb_switch_to_bt(void) -{ - btusb_switch(BTUSB_MODE_BT); -} +void test_btusb_switch_to_bt(void) { btusb_switch(BTUSB_MODE_BT); } -void test_btusb_switch_to_usb(void) -{ - btusb_switch(BTUSB_MODE_USB); -} +void test_btusb_switch_to_usb(void) { btusb_switch(BTUSB_MODE_USB); } #endif diff --git a/apps/btusbaudio/usbaudio_thread.c b/apps/btusbaudio/usbaudio_thread.c index 1772489..ce537d1 100644 --- a/apps/btusbaudio/usbaudio_thread.c +++ b/apps/btusbaudio/usbaudio_thread.c @@ -13,127 +13,119 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "usbaudio_thread.h" +#include "app_utils.h" #include "cmsis_os.h" #include "hal_trace.h" -#include "app_utils.h" #include "usb_audio_app.h" -#include "usbaudio_thread.h" static void usb_thread(void const *argument); osThreadDef(usb_thread, osPriorityHigh, 1, 2048, "usb"); -osMailQDef (usb_mailbox, USB_MAILBOX_MAX, USB_MESSAGE); +osMailQDef(usb_mailbox, USB_MAILBOX_MAX, USB_MESSAGE); static osMailQId usb_mailbox = NULL; static uint8_t usb_mailbox_cnt = 0; #define USBAUDIO_DEBUG TRACE -static int usb_mailbox_init(void) -{ - USBAUDIO_DEBUG("%s,%d",__func__,__LINE__); - usb_mailbox = osMailCreate(osMailQ(usb_mailbox), NULL); - if (usb_mailbox == NULL) { - USBAUDIO_DEBUG("Failed to Create usb_mailbox\n"); - return -1; - } - usb_mailbox_cnt = 0; - return 0; +static int usb_mailbox_init(void) { + USBAUDIO_DEBUG("%s,%d", __func__, __LINE__); + usb_mailbox = osMailCreate(osMailQ(usb_mailbox), NULL); + if (usb_mailbox == NULL) { + USBAUDIO_DEBUG("Failed to Create usb_mailbox\n"); + return -1; + } + usb_mailbox_cnt = 0; + return 0; } -int usb_mailbox_put(USB_MESSAGE* msg_src) -{ - osStatus status; - USB_MESSAGE *msg_p = NULL; +int usb_mailbox_put(USB_MESSAGE *msg_src) { + osStatus status; + USB_MESSAGE *msg_p = NULL; - USBAUDIO_DEBUG("%s,%d",__func__,__LINE__); - if(usb_mailbox_cnt >= 1) - { - USBAUDIO_DEBUG("%s,%d usb_mailbox_cnt = %d.", - __func__,__LINE__,usb_mailbox_cnt); - return 0; + USBAUDIO_DEBUG("%s,%d", __func__, __LINE__); + if (usb_mailbox_cnt >= 1) { + USBAUDIO_DEBUG("%s,%d usb_mailbox_cnt = %d.", __func__, __LINE__, + usb_mailbox_cnt); + return 0; + } + msg_p = (USB_MESSAGE *)osMailAlloc(usb_mailbox, 0); + ASSERT(msg_p, "osMailAlloc error"); + msg_p->id = msg_src->id; + msg_p->ptr = msg_src->ptr; + msg_p->param0 = msg_src->param0; + msg_p->param1 = msg_src->param1; + + status = osMailPut(usb_mailbox, msg_p); + if (osOK == status) + usb_mailbox_cnt++; + USBAUDIO_DEBUG("%s,%d,usb_mailbox_cnt = %d.", __func__, __LINE__, + usb_mailbox_cnt); + return (int)status; +} + +int usb_mailbox_free(USB_MESSAGE *msg_p) { + osStatus status; + + USBAUDIO_DEBUG("%s,%d", __func__, __LINE__); + status = osMailFree(usb_mailbox, msg_p); + if (osOK == status) + usb_mailbox_cnt--; + USBAUDIO_DEBUG("%s,%d,usb_mailbox_cnt = %d.", __func__, __LINE__, + usb_mailbox_cnt); + return (int)status; +} + +int usb_mailbox_get(USB_MESSAGE **msg_p) { + osEvent evt; + evt = osMailGet(usb_mailbox, osWaitForever); + if (evt.status == osEventMail) { + *msg_p = (USB_MESSAGE *)evt.value.p; + return 0; + } + return -1; +} + +static void usb_thread(void const *argument) { + // USB_FUNC_T usb_funcp; + USBAUDIO_DEBUG("%s,%d", __func__, __LINE__); + while (1) { + USB_MESSAGE *msg_p = NULL; + + if (!usb_mailbox_get(&msg_p)) { + // TRACE(2,"_debug: %s,%d",__func__,__LINE__); + USBAUDIO_DEBUG( + "usb_thread: id = 0x%x, ptr = 0x%x,param0 = 0x%x,param1 = 0x%x.", + msg_p->id, msg_p->ptr, msg_p->param0, msg_p->param1); + usb_mailbox_free(msg_p); + usb_audio_app_loop(); } - msg_p = (USB_MESSAGE*)osMailAlloc(usb_mailbox, 0); - ASSERT(msg_p, "osMailAlloc error"); - msg_p->id = msg_src->id; - msg_p->ptr = msg_src->ptr; - msg_p->param0 = msg_src->param0; - msg_p->param1 = msg_src->param1; - - status = osMailPut(usb_mailbox, msg_p); - if (osOK == status) - usb_mailbox_cnt++; - USBAUDIO_DEBUG("%s,%d,usb_mailbox_cnt = %d.",__func__,__LINE__,usb_mailbox_cnt); - return (int)status; + } } -int usb_mailbox_free(USB_MESSAGE* msg_p) -{ - osStatus status; +static void usb_enqueue_cmd(uint32_t data) { + USB_MESSAGE usb_msg; - USBAUDIO_DEBUG("%s,%d",__func__,__LINE__); - status = osMailFree(usb_mailbox, msg_p); - if (osOK == status) - usb_mailbox_cnt--; - USBAUDIO_DEBUG("%s,%d,usb_mailbox_cnt = %d.",__func__,__LINE__,usb_mailbox_cnt); - return (int)status; + usb_msg.id = 0; + usb_msg.param0 = 0; + usb_msg.param1 = 0; + usb_msg.ptr = 0; + usb_mailbox_put(&usb_msg); } -int usb_mailbox_get(USB_MESSAGE **msg_p) -{ - osEvent evt; - evt = osMailGet(usb_mailbox, osWaitForever); - if (evt.status == osEventMail) { - *msg_p = (USB_MESSAGE*)evt.value.p; - return 0; - } - return -1; +int usb_os_init(void) { + osThreadId usb_tid; + + USBAUDIO_DEBUG("%s,%d", __func__, __LINE__); + if (usb_mailbox_init()) { + USBAUDIO_DEBUG("_debug: %s,%d", __func__, __LINE__); + return -1; + } + usb_tid = osThreadCreate(osThread(usb_thread), NULL); + if (usb_tid == NULL) { + USBAUDIO_DEBUG("Failed to Create usb_thread\n"); + return 0; + } + + usb_audio_set_enqueue_cmd_callback(usb_enqueue_cmd); + + return 0; } - -static void usb_thread(void const *argument) -{ - // USB_FUNC_T usb_funcp; - USBAUDIO_DEBUG("%s,%d",__func__,__LINE__); - while(1){ - USB_MESSAGE *msg_p = NULL; - - if (!usb_mailbox_get(&msg_p)) { - //TRACE(2,"_debug: %s,%d",__func__,__LINE__); - USBAUDIO_DEBUG("usb_thread: id = 0x%x, ptr = 0x%x,param0 = 0x%x,param1 = 0x%x.", - msg_p->id,msg_p->ptr,msg_p->param0,msg_p->param1); - usb_mailbox_free(msg_p); - usb_audio_app_loop(); - - } - } -} - -static void usb_enqueue_cmd(uint32_t data) -{ - USB_MESSAGE usb_msg; - - usb_msg.id = 0; - usb_msg.param0 = 0; - usb_msg.param1 = 0; - usb_msg.ptr = 0; - usb_mailbox_put(&usb_msg); -} - -int usb_os_init(void) -{ - osThreadId usb_tid; - - USBAUDIO_DEBUG("%s,%d",__func__,__LINE__); - if (usb_mailbox_init()) { - USBAUDIO_DEBUG("_debug: %s,%d",__func__,__LINE__); - return -1; - } - usb_tid = osThreadCreate(osThread(usb_thread), NULL); - if (usb_tid == NULL) { - USBAUDIO_DEBUG("Failed to Create usb_thread\n"); - return 0; - } - - usb_audio_set_enqueue_cmd_callback(usb_enqueue_cmd); - - return 0; -} - - diff --git a/apps/cmd/app_cmd.cpp b/apps/cmd/app_cmd.cpp index be00252..1bf22f9 100644 --- a/apps/cmd/app_cmd.cpp +++ b/apps/cmd/app_cmd.cpp @@ -14,58 +14,52 @@ * ****************************************************************************/ #ifdef __PC_CMD_UART__ -#include "cmsis_os.h" -#include "list.h" -#include "string.h" -#include "app_thread.h" #include "app_cmd.h" +#include "app_thread.h" +#include "audio_process.h" +#include "cmsis_os.h" #include "hal_cmd.h" #include "hal_trace.h" -#include "audio_process.h" +#include "list.h" +#include "string.h" -#define APP_CMD_TRACE(s,...) TRACE(s, ##__VA_ARGS__) - -void cmd_event_process(hal_cmd_rx_status_t status) -{ - APP_CMD_TRACE(1,"%s",__func__); - APP_MESSAGE_BLOCK msg; - msg.mod_id = APP_MODUAL_CMD; - msg.msg_body.message_id = status; - msg.msg_body.message_ptr = (uint32_t)NULL; - app_mailbox_put(&msg); - return; +#define APP_CMD_TRACE(s, ...) TRACE(s, ##__VA_ARGS__) + +void cmd_event_process(hal_cmd_rx_status_t status) { + APP_CMD_TRACE(1, "%s", __func__); + APP_MESSAGE_BLOCK msg; + msg.mod_id = APP_MODUAL_CMD; + msg.msg_body.message_id = status; + msg.msg_body.message_ptr = (uint32_t)NULL; + app_mailbox_put(&msg); + return; } -static int app_cmd_handle_process(APP_MESSAGE_BODY *msg_body) -{ - hal_cmd_run((hal_cmd_rx_status_t)msg_body->message_id); - return 0; +static int app_cmd_handle_process(APP_MESSAGE_BODY *msg_body) { + hal_cmd_run((hal_cmd_rx_status_t)msg_body->message_id); + return 0; } uint8_t app_cmd_flag = 0; -void app_cmd_open(void) -{ - APP_CMD_TRACE(1,"%s",__func__); +void app_cmd_open(void) { + APP_CMD_TRACE(1, "%s", __func__); - app_cmd_flag = 1; + app_cmd_flag = 1; - app_set_threadhandle(APP_MODUAL_CMD, app_cmd_handle_process); - hal_cmd_set_callback(cmd_event_process); - hal_cmd_open(); - return; + app_set_threadhandle(APP_MODUAL_CMD, app_cmd_handle_process); + hal_cmd_set_callback(cmd_event_process); + hal_cmd_open(); + return; } -void app_cmd_close(void) -{ - APP_CMD_TRACE(1,"%s",__func__); - if(app_cmd_flag) - { - app_cmd_flag = 0; - hal_cmd_close(); - app_set_threadhandle(APP_MODUAL_CMD, NULL); - } - return; +void app_cmd_close(void) { + APP_CMD_TRACE(1, "%s", __func__); + if (app_cmd_flag) { + app_cmd_flag = 0; + hal_cmd_close(); + app_set_threadhandle(APP_MODUAL_CMD, NULL); + } + return; } #endif - diff --git a/apps/common/app_spec_ostimer.cpp b/apps/common/app_spec_ostimer.cpp index 7d94eb6..8b391c5 100644 --- a/apps/common/app_spec_ostimer.cpp +++ b/apps/common/app_spec_ostimer.cpp @@ -13,69 +13,66 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "cmsis_os.h" -#include "stdint.h" #include "app_spec_ostimer.h" +#include "cmsis_os.h" #include "hal_trace.h" - +#include "stdint.h" /// Create timer -osStatus app_spec_timer_create (SPEC_TIMER_CTX_T *spec_timer_ctx, const osTimerDef_t *timer_def, os_timer_type type, void *argument) -{ - spec_timer_ctx->type = type; - spec_timer_ctx->argument = argument; - spec_timer_ctx->timerid = osTimerCreate(timer_def, type, spec_timer_ctx); - return spec_timer_ctx->timerid ? osOK: osErrorOS; +osStatus app_spec_timer_create(SPEC_TIMER_CTX_T *spec_timer_ctx, + const osTimerDef_t *timer_def, + os_timer_type type, void *argument) { + spec_timer_ctx->type = type; + spec_timer_ctx->argument = argument; + spec_timer_ctx->timerid = osTimerCreate(timer_def, type, spec_timer_ctx); + return spec_timer_ctx->timerid ? osOK : osErrorOS; } /// Start or restart timer -osStatus app_spec_timer_start (SPEC_TIMER_CTX_T *spec_timer_ctx, uint32_t millisec) -{ - osStatus status; +osStatus app_spec_timer_start(SPEC_TIMER_CTX_T *spec_timer_ctx, + uint32_t millisec) { + osStatus status; - //TRACE(1,"%s", __func__); - if (millisec > UINT16_MAX){ - spec_timer_ctx->interval = millisec; - spec_timer_ctx->ctx = millisec; - status = osTimerStart(spec_timer_ctx->timerid, UINT16_MAX); - }else{ - spec_timer_ctx->interval = millisec; - spec_timer_ctx->ctx = millisec; - status = osTimerStart(spec_timer_ctx->timerid, (uint32_t)millisec); - } + // TRACE(1,"%s", __func__); + if (millisec > UINT16_MAX) { + spec_timer_ctx->interval = millisec; + spec_timer_ctx->ctx = millisec; + status = osTimerStart(spec_timer_ctx->timerid, UINT16_MAX); + } else { + spec_timer_ctx->interval = millisec; + spec_timer_ctx->ctx = millisec; + status = osTimerStart(spec_timer_ctx->timerid, (uint32_t)millisec); + } - return status; + return status; } /// Stop timer -osStatus app_spec_timer_stop (SPEC_TIMER_CTX_T *spec_timer_ctx) -{ +osStatus app_spec_timer_stop(SPEC_TIMER_CTX_T *spec_timer_ctx) { return osTimerStop(spec_timer_ctx->timerid); } /// Delete timer -osStatus app_spec_timer_delete (SPEC_TIMER_CTX_T *spec_timer_ctx) -{ +osStatus app_spec_timer_delete(SPEC_TIMER_CTX_T *spec_timer_ctx) { return osTimerDelete(spec_timer_ctx->timerid); } -void app_spec_timer_handler(void const *para) -{ - SPEC_TIMER_CTX_T *spec_timer_ctx = (SPEC_TIMER_CTX_T *)para; +void app_spec_timer_handler(void const *para) { + SPEC_TIMER_CTX_T *spec_timer_ctx = (SPEC_TIMER_CTX_T *)para; - if (spec_timer_ctx->ctx > UINT16_MAX){ - spec_timer_ctx->ctx -= UINT16_MAX; - if (spec_timer_ctx->ctx > UINT16_MAX){ - osTimerStart(spec_timer_ctx->timerid, UINT16_MAX); - }else{ - osTimerStart(spec_timer_ctx->timerid, spec_timer_ctx->ctx); - } - }else{ - (*spec_timer_ctx->ptimer)(spec_timer_ctx->argument); - if (spec_timer_ctx->type == osTimerPeriodic){ - app_spec_timer_start(spec_timer_ctx, spec_timer_ctx->interval); - } + if (spec_timer_ctx->ctx > UINT16_MAX) { + spec_timer_ctx->ctx -= UINT16_MAX; + if (spec_timer_ctx->ctx > UINT16_MAX) { + osTimerStart(spec_timer_ctx->timerid, UINT16_MAX); + } else { + osTimerStart(spec_timer_ctx->timerid, spec_timer_ctx->ctx); } + } else { + (*spec_timer_ctx->ptimer)(spec_timer_ctx->argument); + if (spec_timer_ctx->type == osTimerPeriodic) { + app_spec_timer_start(spec_timer_ctx, spec_timer_ctx->interval); + } + } } #if 0 diff --git a/apps/common/app_thread.c b/apps/common/app_thread.c index 14cce17..160d2df 100644 --- a/apps/common/app_thread.c +++ b/apps/common/app_thread.c @@ -13,152 +13,141 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "cmsis_os.h" -#include "hal_trace.h" -#include "hal_timer.h" -#include "app_utils.h" #include "app_thread.h" - +#include "app_utils.h" +#include "cmsis_os.h" +#include "hal_timer.h" +#include "hal_trace.h" static APP_MOD_HANDLER_T mod_handler[APP_MODUAL_NUM]; static void app_thread(void const *argument); -osThreadDef(app_thread, osPriorityHigh, 1, 1024*3, "app_thread"); +osThreadDef(app_thread, osPriorityHigh, 1, 1024 * 3, "app_thread"); -osMailQDef (app_mailbox, APP_MAILBOX_MAX, APP_MESSAGE_BLOCK); +osMailQDef(app_mailbox, APP_MAILBOX_MAX, APP_MESSAGE_BLOCK); static osMailQId app_mailbox = NULL; static uint8_t app_mailbox_cnt = 0; osThreadId app_thread_tid; -static int app_mailbox_init(void) -{ - app_mailbox = osMailCreate(osMailQ(app_mailbox), NULL); - if (app_mailbox == NULL) { - TRACE(0,"Failed to Create app_mailbox\n"); - return -1; - } - app_mailbox_cnt = 0; - return 0; +static int app_mailbox_init(void) { + app_mailbox = osMailCreate(osMailQ(app_mailbox), NULL); + if (app_mailbox == NULL) { + TRACE(0, "Failed to Create app_mailbox\n"); + return -1; + } + app_mailbox_cnt = 0; + return 0; } -int app_mailbox_put(APP_MESSAGE_BLOCK* msg_src) -{ - osStatus status; +int app_mailbox_put(APP_MESSAGE_BLOCK *msg_src) { + osStatus status; + APP_MESSAGE_BLOCK *msg_p = NULL; + + msg_p = (APP_MESSAGE_BLOCK *)osMailAlloc(app_mailbox, 0); + + if (!msg_p) { + osEvent evt; + TRACE_IMM(0, "osMailAlloc error dump"); + for (uint8_t i = 0; i < APP_MAILBOX_MAX; i++) { + evt = osMailGet(app_mailbox, 0); + if (evt.status == osEventMail) { + TRACE_IMM( + 9, + "cnt:%d mod:%d src:%08x tim:%d id:%x ptr:%08x para:%08x/%08x/%08x", + i, ((APP_MESSAGE_BLOCK *)(evt.value.p))->mod_id, + ((APP_MESSAGE_BLOCK *)(evt.value.p))->src_thread, + ((APP_MESSAGE_BLOCK *)(evt.value.p))->system_time, + ((APP_MESSAGE_BLOCK *)(evt.value.p))->msg_body.message_id, + ((APP_MESSAGE_BLOCK *)(evt.value.p))->msg_body.message_ptr, + ((APP_MESSAGE_BLOCK *)(evt.value.p))->msg_body.message_Param0, + ((APP_MESSAGE_BLOCK *)(evt.value.p))->msg_body.message_Param1, + ((APP_MESSAGE_BLOCK *)(evt.value.p))->msg_body.message_Param2); + } else { + TRACE_IMM(2, "cnt:%d %d", i, evt.status); + break; + } + } + TRACE_IMM(0, "osMailAlloc error dump end"); + } + + ASSERT(msg_p, "osMailAlloc error"); + msg_p->src_thread = (uint32_t)osThreadGetId(); + msg_p->dest_thread = (uint32_t)NULL; + msg_p->system_time = hal_sys_timer_get(); + msg_p->mod_id = msg_src->mod_id; + msg_p->msg_body.message_id = msg_src->msg_body.message_id; + msg_p->msg_body.message_ptr = msg_src->msg_body.message_ptr; + msg_p->msg_body.message_Param0 = msg_src->msg_body.message_Param0; + msg_p->msg_body.message_Param1 = msg_src->msg_body.message_Param1; + msg_p->msg_body.message_Param2 = msg_src->msg_body.message_Param2; + + status = osMailPut(app_mailbox, msg_p); + if (osOK == status) + app_mailbox_cnt++; + return (int)status; +} + +int app_mailbox_free(APP_MESSAGE_BLOCK *msg_p) { + osStatus status; + + status = osMailFree(app_mailbox, msg_p); + if (osOK == status) + app_mailbox_cnt--; + + return (int)status; +} + +int app_mailbox_get(APP_MESSAGE_BLOCK **msg_p) { + osEvent evt; + evt = osMailGet(app_mailbox, osWaitForever); + if (evt.status == osEventMail) { + *msg_p = (APP_MESSAGE_BLOCK *)evt.value.p; + return 0; + } + return -1; +} + +static void app_thread(void const *argument) { + while (1) { APP_MESSAGE_BLOCK *msg_p = NULL; - msg_p = (APP_MESSAGE_BLOCK*)osMailAlloc(app_mailbox, 0); - - if (!msg_p){ - osEvent evt; - TRACE_IMM(0,"osMailAlloc error dump"); - for (uint8_t i=0; imod_id, - ((APP_MESSAGE_BLOCK *)(evt.value.p))->src_thread, - ((APP_MESSAGE_BLOCK *)(evt.value.p))->system_time, - ((APP_MESSAGE_BLOCK *)(evt.value.p))->msg_body.message_id, - ((APP_MESSAGE_BLOCK *)(evt.value.p))->msg_body.message_ptr, - ((APP_MESSAGE_BLOCK *)(evt.value.p))->msg_body.message_Param0, - ((APP_MESSAGE_BLOCK *)(evt.value.p))->msg_body.message_Param1, - ((APP_MESSAGE_BLOCK *)(evt.value.p))->msg_body.message_Param2); - }else{ - TRACE_IMM(2,"cnt:%d %d", i, evt.status); - break; - } + if (!app_mailbox_get(&msg_p)) { + if (msg_p->mod_id < APP_MODUAL_NUM) { + if (mod_handler[msg_p->mod_id]) { + int ret = mod_handler[msg_p->mod_id](&(msg_p->msg_body)); + if (ret) + TRACE(2, "mod_handler[%d] ret=%d", msg_p->mod_id, ret); } - TRACE_IMM(0,"osMailAlloc error dump end"); + } + app_mailbox_free(msg_p); } - - ASSERT(msg_p, "osMailAlloc error"); - msg_p->src_thread = (uint32_t)osThreadGetId(); - msg_p->dest_thread = (uint32_t)NULL; - msg_p->system_time = hal_sys_timer_get(); - msg_p->mod_id = msg_src->mod_id; - msg_p->msg_body.message_id = msg_src->msg_body.message_id; - msg_p->msg_body.message_ptr = msg_src->msg_body.message_ptr; - msg_p->msg_body.message_Param0 = msg_src->msg_body.message_Param0; - msg_p->msg_body.message_Param1 = msg_src->msg_body.message_Param1; - msg_p->msg_body.message_Param2 = msg_src->msg_body.message_Param2; - - status = osMailPut(app_mailbox, msg_p); - if (osOK == status) - app_mailbox_cnt++; - return (int)status; + } } -int app_mailbox_free(APP_MESSAGE_BLOCK* msg_p) -{ - osStatus status; - - status = osMailFree(app_mailbox, msg_p); - if (osOK == status) - app_mailbox_cnt--; - - return (int)status; -} - -int app_mailbox_get(APP_MESSAGE_BLOCK** msg_p) -{ - osEvent evt; - evt = osMailGet(app_mailbox, osWaitForever); - if (evt.status == osEventMail) { - *msg_p = (APP_MESSAGE_BLOCK *)evt.value.p; - return 0; - } +int app_os_init(void) { + if (app_mailbox_init()) return -1; -} -static void app_thread(void const *argument) -{ - while(1){ - APP_MESSAGE_BLOCK *msg_p = NULL; - - if (!app_mailbox_get(&msg_p)) { - if (msg_p->mod_id < APP_MODUAL_NUM) { - if (mod_handler[msg_p->mod_id]) { - int ret = mod_handler[msg_p->mod_id](&(msg_p->msg_body)); - if (ret) - TRACE(2,"mod_handler[%d] ret=%d", msg_p->mod_id, ret); - } - } - app_mailbox_free(msg_p); - } - } -} - -int app_os_init(void) -{ - if (app_mailbox_init()) - return -1; - - app_thread_tid = osThreadCreate(osThread(app_thread), NULL); - if (app_thread_tid == NULL) { - TRACE(0,"Failed to Create app_thread\n"); - return 0; - } + app_thread_tid = osThreadCreate(osThread(app_thread), NULL); + if (app_thread_tid == NULL) { + TRACE(0, "Failed to Create app_thread\n"); return 0; + } + return 0; } -int app_set_threadhandle(enum APP_MODUAL_ID_T mod_id, APP_MOD_HANDLER_T handler) -{ - if (mod_id>=APP_MODUAL_NUM) - return -1; +int app_set_threadhandle(enum APP_MODUAL_ID_T mod_id, + APP_MOD_HANDLER_T handler) { + if (mod_id >= APP_MODUAL_NUM) + return -1; - mod_handler[mod_id] = handler; - return 0; + mod_handler[mod_id] = handler; + return 0; } -void * app_os_tid_get(void) -{ - return (void *)app_thread_tid; -} +void *app_os_tid_get(void) { return (void *)app_thread_tid; } -bool app_is_module_registered(enum APP_MODUAL_ID_T mod_id) -{ - return mod_handler[mod_id]; +bool app_is_module_registered(enum APP_MODUAL_ID_T mod_id) { + return mod_handler[mod_id]; } - diff --git a/apps/common/app_thread.h b/apps/common/app_thread.h index fe763d4..148a01d 100644 --- a/apps/common/app_thread.h +++ b/apps/common/app_thread.h @@ -15,6 +15,8 @@ ****************************************************************************/ #ifndef __APP_THREAD_H__ #define __APP_THREAD_H__ +#include +#include #ifdef __cplusplus extern "C" { @@ -23,70 +25,71 @@ extern "C" { #define APP_MAILBOX_MAX (20) enum APP_MODUAL_ID_T { - APP_MODUAL_KEY = 0, - APP_MODUAL_AUDIO, - APP_MODUAL_BATTERY, - APP_MODUAL_BT, - APP_MODUAL_FM, - APP_MODUAL_SD, - APP_MODUAL_LINEIN, - APP_MODUAL_USBHOST, - APP_MODUAL_USBDEVICE, - APP_MODUAL_WATCHDOG, - APP_MODUAL_AUDIO_MANAGE, - APP_MODUAL_ANC, - APP_MODUAL_SMART_MIC, -#ifdef __PC_CMD_UART__ - APP_MODUAL_CMD, + APP_MODUAL_KEY = 0, + APP_MODUAL_AUDIO, + APP_MODUAL_BATTERY, + APP_MODUAL_BT, + APP_MODUAL_FM, + APP_MODUAL_SD, + APP_MODUAL_LINEIN, + APP_MODUAL_USBHOST, + APP_MODUAL_USBDEVICE, + APP_MODUAL_WATCHDOG, + APP_MODUAL_AUDIO_MANAGE, + APP_MODUAL_ANC, + APP_MODUAL_SMART_MIC, +#ifdef __PC_CMD_UART__ + APP_MODUAL_CMD, #endif #ifdef TILE_DATAPATH - APP_MODUAL_TILE, + APP_MODUAL_TILE, #endif - APP_MODUAL_MIC, + APP_MODUAL_MIC, #ifdef VOICE_DETECTOR_EN - APP_MODUAL_VOICE_DETECTOR, + APP_MODUAL_VOICE_DETECTOR, #endif - APP_MODUAL_CUSTOM_FUNCTION, - APP_MODUAL_OHTER, - APP_MODUAL_WNR, + APP_MODUAL_CUSTOM_FUNCTION, + APP_MODUAL_OHTER, + APP_MODUAL_WNR, - APP_MODUAL_NUM + APP_MODUAL_NUM }; typedef struct { - uint32_t message_id; - uint32_t message_ptr; - uint32_t message_Param0; - uint32_t message_Param1; - uint32_t message_Param2; + uint32_t message_id; + uint32_t message_ptr; + uint32_t message_Param0; + uint32_t message_Param1; + uint32_t message_Param2; } APP_MESSAGE_BODY; typedef struct { - uint32_t src_thread; - uint32_t dest_thread; - uint32_t system_time; - uint32_t mod_id; - APP_MESSAGE_BODY msg_body; + uint32_t src_thread; + uint32_t dest_thread; + uint32_t system_time; + uint32_t mod_id; + APP_MESSAGE_BODY msg_body; } APP_MESSAGE_BLOCK; typedef int (*APP_MOD_HANDLER_T)(APP_MESSAGE_BODY *); -int app_mailbox_put(APP_MESSAGE_BLOCK* msg_src); +int app_mailbox_put(APP_MESSAGE_BLOCK *msg_src); -int app_mailbox_free(APP_MESSAGE_BLOCK* msg_p); +int app_mailbox_free(APP_MESSAGE_BLOCK *msg_p); -int app_mailbox_get(APP_MESSAGE_BLOCK** msg_p); +int app_mailbox_get(APP_MESSAGE_BLOCK **msg_p); int app_os_init(void); -int app_set_threadhandle(enum APP_MODUAL_ID_T mod_id, APP_MOD_HANDLER_T handler); +int app_set_threadhandle(enum APP_MODUAL_ID_T mod_id, + APP_MOD_HANDLER_T handler); -void * app_os_tid_get(void); +void *app_os_tid_get(void); bool app_is_module_registered(enum APP_MODUAL_ID_T mod_id); #ifdef __cplusplus - } +} #endif -#endif//__FMDEC_H__ +#endif //__FMDEC_H__ diff --git a/apps/common/app_utils.c b/apps/common/app_utils.c index 0849b14..b5e63ad 100644 --- a/apps/common/app_utils.c +++ b/apps/common/app_utils.c @@ -13,23 +13,23 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "app_utils.h" +#include "analog.h" #include "cmsis.h" -#include "hal_trace.h" #include "hal_timer.h" +#include "hal_trace.h" #include "hal_wdt.h" #include "pmu.h" -#include "analog.h" -#include "app_utils.h" #ifdef RTOS #include "cmsis_os.h" #endif -#define FREQ_FREE 0UL -#define FREQ_26M 26UL -#define FREQ_52M 52UL -#define FREQ_78M 78UL -#define FREQ_104M 104UL -#define FREQ_208M 208UL +#define FREQ_FREE 0UL +#define FREQ_26M 26UL +#define FREQ_52M 52UL +#define FREQ_78M 78UL +#define FREQ_104M 104UL +#define FREQ_208M 208UL /* * qos_users, quality of services users, this kind of user must run with the @@ -41,22 +41,19 @@ */ /* * NOTE: - * The macro QOS_USERS works only when the APP_SYSFREQ_USER_APP_XXX is not large than - * 32, currently this works, but if the are more user, another way needed + * The macro QOS_USERS works only when the APP_SYSFREQ_USER_APP_XXX is not large + * than 32, currently this works, but if the are more user, another way needed */ -#define QOS_USERS ((1 << (APP_SYSFREQ_USER_AI_VOICE)) | \ - (1 << (APP_SYSFREQ_USER_BT_A2DP))) +#define QOS_USERS \ + ((1 << (APP_SYSFREQ_USER_AI_VOICE)) | (1 << (APP_SYSFREQ_USER_BT_A2DP))) -static const uint32_t freq_map[] = { - [HAL_CMU_FREQ_32K] = FREQ_FREE, - [HAL_CMU_FREQ_26M] = FREQ_26M, - [HAL_CMU_FREQ_52M] = FREQ_52M, - [HAL_CMU_FREQ_78M] = FREQ_78M, - [HAL_CMU_FREQ_104M] = FREQ_104M, - [HAL_CMU_FREQ_208M] = FREQ_208M, +static const uint32_t freq_map[] = { + [HAL_CMU_FREQ_32K] = FREQ_FREE, [HAL_CMU_FREQ_26M] = FREQ_26M, + [HAL_CMU_FREQ_52M] = FREQ_52M, [HAL_CMU_FREQ_78M] = FREQ_78M, + [HAL_CMU_FREQ_104M] = FREQ_104M, [HAL_CMU_FREQ_208M] = FREQ_208M, }; -static const uint32_t user_map[] = { +static const uint32_t user_map[] = { [0] = APP_SYSFREQ_USER_AI_VOICE, [1] = APP_SYSFREQ_USER_BT_A2DP, }; @@ -89,95 +86,97 @@ static uint32_t qos_freqs_map; */ static uint32_t qos_users_map; -static int app_qosfreq_req(enum APP_SYSFREQ_USER_T user, enum APP_SYSFREQ_FREQ_T freq) -{ - int ret; - int qos_freq_num = 0; - uint32_t max_qos_freq = 0; - int user_idx; - int i; - uint32_t lock; +static int app_qosfreq_req(enum APP_SYSFREQ_USER_T user, + enum APP_SYSFREQ_FREQ_T freq) { + int ret; + int qos_freq_num = 0; + uint32_t max_qos_freq = 0; + int user_idx; + int i; + uint32_t lock; - if (freq >= APP_SYSFREQ_FREQ_QTY) - return -1; + if (freq >= APP_SYSFREQ_FREQ_QTY) + return -1; - lock = int_lock(); - for (i = 0; i < ARRAY_SIZE(user_map); i++) { - if (user == user_map[i]) { - break; - } + lock = int_lock(); + for (i = 0; i < ARRAY_SIZE(user_map); i++) { + if (user == user_map[i]) { + break; } + } - if (i >= ARRAY_SIZE(user_map)) { - int_unlock(lock); - ASSERT(0, "can not find qos user"); - return 0; - } - - user_idx = i; - if ((int)freq != (int)HAL_CMU_FREQ_32K) { // require freq - qos_freqs_map &= ~(0xf << (4 * i)); - qos_freqs_map |= freq << (4 * i); - qos_users_map |= 1 << user_idx; - } else { //release freq - qos_freqs_map &= ~(0xf << (4 * i)); - qos_users_map &= ~ (1 << user_idx); - } - - //scan the qos_user_map and sum every user's request freq - for(i = 0; i < ARRAY_SIZE(user_map); i++) { - if ((qos_users_map >> i) & 0x1) { - uint32_t real_freq; - int freq_num; - - freq_num = (qos_freqs_map >> (4 * i )) & 0xf; - real_freq = freq_map[freq_num]; - max_qos_freq += real_freq; - } - } - - for (i = 0; i < ARRAY_SIZE(freq_map); i++) { - if (i) { - if ((max_qos_freq > freq_map[i-1]) && (max_qos_freq <= freq_map[i])) { - qos_freq_num = i; - break; - } - } else { - if (max_qos_freq == freq_map[i]) { - qos_freq_num = i; - break; - } - } - } - - if (i >= ARRAY_SIZE(freq_map)) { - qos_freq_num = (HAL_CMU_FREQ_QTY - 1); - int_unlock(lock); - TRACE(0, "WARNING: required sysfreq exceed"); - // ASSERT(0, "can not find actual freq"); - return 0; - } - - user = APP_SYSFREQ_USER_QOS; - TRACE(2, "User %d require sysfreq %d", user, qos_freq_num); - ret = hal_sysfreq_req((enum HAL_SYSFREQ_USER_T)user, (enum HAL_CMU_FREQ_T)qos_freq_num); - + if (i >= ARRAY_SIZE(user_map)) { int_unlock(lock); - return ret; + ASSERT(0, "can not find qos user"); + return 0; + } + + user_idx = i; + if ((int)freq != (int)HAL_CMU_FREQ_32K) { // require freq + qos_freqs_map &= ~(0xf << (4 * i)); + qos_freqs_map |= freq << (4 * i); + qos_users_map |= 1 << user_idx; + } else { // release freq + qos_freqs_map &= ~(0xf << (4 * i)); + qos_users_map &= ~(1 << user_idx); + } + + // scan the qos_user_map and sum every user's request freq + for (i = 0; i < ARRAY_SIZE(user_map); i++) { + if ((qos_users_map >> i) & 0x1) { + uint32_t real_freq; + int freq_num; + + freq_num = (qos_freqs_map >> (4 * i)) & 0xf; + real_freq = freq_map[freq_num]; + max_qos_freq += real_freq; + } + } + + for (i = 0; i < ARRAY_SIZE(freq_map); i++) { + if (i) { + if ((max_qos_freq > freq_map[i - 1]) && (max_qos_freq <= freq_map[i])) { + qos_freq_num = i; + break; + } + } else { + if (max_qos_freq == freq_map[i]) { + qos_freq_num = i; + break; + } + } + } + + if (i >= ARRAY_SIZE(freq_map)) { + qos_freq_num = (HAL_CMU_FREQ_QTY - 1); + int_unlock(lock); + TRACE(0, "WARNING: required sysfreq exceed"); + // ASSERT(0, "can not find actual freq"); + return 0; + } + + user = APP_SYSFREQ_USER_QOS; + TRACE(2, "User %d require sysfreq %d", user, qos_freq_num); + ret = hal_sysfreq_req((enum HAL_SYSFREQ_USER_T)user, + (enum HAL_CMU_FREQ_T)qos_freq_num); + + int_unlock(lock); + return ret; } -int app_sysfreq_req(enum APP_SYSFREQ_USER_T user, enum APP_SYSFREQ_FREQ_T freq) -{ - int ret; +int app_sysfreq_req(enum APP_SYSFREQ_USER_T user, + enum APP_SYSFREQ_FREQ_T freq) { + int ret; - // if user is qos user - if ((1 << user) & QOS_USERS) { - ret = app_qosfreq_req(user, freq); - } else { // if user is NOT qos user - ret = hal_sysfreq_req((enum HAL_SYSFREQ_USER_T)user, (enum HAL_CMU_FREQ_T)freq); - } + // if user is qos user + if ((1 << user) & QOS_USERS) { + ret = app_qosfreq_req(user, freq); + } else { // if user is NOT qos user + ret = hal_sysfreq_req((enum HAL_SYSFREQ_USER_T)user, + (enum HAL_CMU_FREQ_T)freq); + } - return ret; + return ret; } #ifdef RTOS @@ -188,94 +187,86 @@ static osTimerId wdt_ping_timer_id; osTimerDef(wdt_ping_timer, watchdog_ping_handler); static uint32_t wdt_ping_period; -static void watchdog_ping(void) -{ - hal_wdt_ping(HAL_WDT_ID_0); +static void watchdog_ping(void) { + hal_wdt_ping(HAL_WDT_ID_0); #ifndef CHIP_BEST2000 - pmu_wdt_feed(); + pmu_wdt_feed(); #endif } -static void app_wdt_irq_handle(enum HAL_WDT_ID_T id, uint32_t status) -{ - analog_aud_codec_mute(); - ASSERT(0, "%s id:%d status:%d",__func__, id, status); +static void app_wdt_irq_handle(enum HAL_WDT_ID_T id, uint32_t status) { + analog_aud_codec_mute(); + ASSERT(0, "%s id:%d status:%d", __func__, id, status); } -static void pmu_wdt_irq_handle(void) -{ - analog_aud_codec_mute(); - ASSERT(1, "%s", __func__); +static void pmu_wdt_irq_handle(void) { + analog_aud_codec_mute(); + ASSERT(1, "%s", __func__); } -static void watchdog_ping_handler(void const *unused) -{ - int ret; +static void watchdog_ping_handler(void const *unused) { + int ret; - watchdog_ping(); - ret = rtx_task_idle_health_check(); - if (ret < 0) { - ASSERT(0, "System soft lockup"); - } + watchdog_ping(); + ret = rtx_task_idle_health_check(); + if (ret < 0) { + ASSERT(0, "System soft lockup"); + } - osTimerStart(wdt_ping_timer_id, wdt_ping_period); + osTimerStart(wdt_ping_timer_id, wdt_ping_period); } -int app_wdt_open(int seconds) -{ - uint32_t lock = int_lock(); +int app_wdt_open(int seconds) { + uint32_t lock = int_lock(); - hal_wdt_set_irq_callback(HAL_WDT_ID_0, app_wdt_irq_handle); - hal_wdt_set_timeout(HAL_WDT_ID_0, seconds); - hal_wdt_start(HAL_WDT_ID_0); - pmu_wdt_set_irq_handler(pmu_wdt_irq_handle); + hal_wdt_set_irq_callback(HAL_WDT_ID_0, app_wdt_irq_handle); + hal_wdt_set_timeout(HAL_WDT_ID_0, seconds); + hal_wdt_start(HAL_WDT_ID_0); + pmu_wdt_set_irq_handler(pmu_wdt_irq_handle); #ifndef CHIP_BEST2000 - pmu_wdt_config(seconds * 1100, seconds * 1100); - pmu_wdt_start(); + pmu_wdt_config(seconds * 1100, seconds * 1100); + pmu_wdt_start(); #endif - int_unlock(lock); - wdt_ping_timer_id = osTimerCreate(osTimer(wdt_ping_timer), osTimerOnce, NULL); - if (!wdt_ping_timer_id) { - TRACE(0,"Warning: can not create watchdog ping timer"); - return -1; - } - wdt_ping_period = seconds * 1000 / 4; + int_unlock(lock); + wdt_ping_timer_id = osTimerCreate(osTimer(wdt_ping_timer), osTimerOnce, NULL); + if (!wdt_ping_timer_id) { + TRACE(0, "Warning: can not create watchdog ping timer"); + return -1; + } + wdt_ping_period = seconds * 1000 / 4; - osTimerStart(wdt_ping_timer_id, wdt_ping_period); - return 0; + osTimerStart(wdt_ping_timer_id, wdt_ping_period); + return 0; } -int app_wdt_reopen(int seconds) -{ - uint32_t lock = int_lock(); - hal_wdt_stop(HAL_WDT_ID_0); - hal_wdt_set_timeout(HAL_WDT_ID_0, seconds); - hal_wdt_start(HAL_WDT_ID_0); +int app_wdt_reopen(int seconds) { + uint32_t lock = int_lock(); + hal_wdt_stop(HAL_WDT_ID_0); + hal_wdt_set_timeout(HAL_WDT_ID_0, seconds); + hal_wdt_start(HAL_WDT_ID_0); #ifndef CHIP_BEST2000 - pmu_wdt_config(seconds * 1000, seconds * 1000); - pmu_wdt_start(); + pmu_wdt_config(seconds * 1000, seconds * 1000); + pmu_wdt_start(); #endif - int_unlock(lock); + int_unlock(lock); - osTimerStart(wdt_ping_timer_id, wdt_ping_period); - return 0; + osTimerStart(wdt_ping_timer_id, wdt_ping_period); + return 0; } -int app_wdt_close(void) -{ - uint32_t lock; +int app_wdt_close(void) { + uint32_t lock; - osTimerStop(wdt_ping_timer_id); + osTimerStop(wdt_ping_timer_id); - lock = int_lock(); - hal_wdt_stop(HAL_WDT_ID_0); + lock = int_lock(); + hal_wdt_stop(HAL_WDT_ID_0); #ifndef CHIP_BEST2000 - pmu_wdt_stop(); + pmu_wdt_stop(); #endif - int_unlock(lock); + int_unlock(lock); - return 0; + return 0; } #endif - diff --git a/apps/common/randfrommic.c b/apps/common/randfrommic.c index ffa16eb..42bdbb1 100644 --- a/apps/common/randfrommic.c +++ b/apps/common/randfrommic.c @@ -1,23 +1,23 @@ #ifdef __RAND_FROM_MIC__ -#include "audioflinger.h" -#include "hal_trace.h" -#include "app_utils.h" -#include "string.h" -#include "stdlib.h" -#include "stdio.h" -#include "app_bt_stream.h" #include "randfrommic.h" -#include "hal_timer.h" -#include "cmsis_os.h" -#include "cmsis_gcc.h" #include "app_audio.h" +#include "app_bt_stream.h" +#include "app_utils.h" +#include "audioflinger.h" +#include "cmsis_gcc.h" +#include "cmsis_os.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "stdio.h" +#include "stdlib.h" +#include "string.h" #if BT_DRV_DEBUG -#define RAND_TRACE(n, fmt, ...) TRACE(n, fmt, ##__VA_ARGS__) -#define RAND_DUMP(s,buff,len) DUMP8(s,buff,len) +#define RAND_TRACE(n, fmt, ...) TRACE(n, fmt, ##__VA_ARGS__) +#define RAND_DUMP(s, buff, len) DUMP8(s, buff, len) #else #define RAND_TRACE(n, fmt, ...) -#define RAND_DUMP(s,buff,len) +#define RAND_DUMP(s, buff, len) #endif static void generateRand(bool on); @@ -29,239 +29,201 @@ static uint32_t randSeed = 1; static bool randInitialised = false; // 4 bytes aligned -#define RAND_GRAB_BITS_PER_SAMPLE 4 -#define RAND_GRAB_BITS_MASK_PER_SAMPLE ((1 << RAND_GRAB_BITS_PER_SAMPLE)-1) +#define RAND_GRAB_BITS_PER_SAMPLE 4 +#define RAND_GRAB_BITS_MASK_PER_SAMPLE ((1 << RAND_GRAB_BITS_PER_SAMPLE) - 1) -RAND_NUMBER_T randomBuffer = -{ +RAND_NUMBER_T randomBuffer = { 25, RAND_STATUS_CLOSE, }; /** - * Description: parse mic data according to the stream cfg(bit mode and channel number) - * only the lowest byte of each frame is taken - * ADC format: - * 16bit mode -> [15:0] is valid - * 24bit mode -> [23:4] is valid - * 32bit mode -> [31:12] is valid + * Description: parse mic data according to the stream cfg(bit mode and channel + * number) only the lowest byte of each frame is taken ADC format: 16bit mode -> + * [15:0] is valid 24bit mode -> [23:4] is valid 32bit mode -> [31:12] is valid * */ static int randDataParse(uint8_t *buf, uint32_t len, enum AUD_BITS_T bits, - enum AUD_CHANNEL_NUM_T ch_num) -{ - uint8_t index = 0; + enum AUD_CHANNEL_NUM_T ch_num) { + uint8_t index = 0; - union { - uint32_t seedValue; - uint8_t value[4]; - }seedData; + union { + uint32_t seedValue; + uint8_t value[4]; + } seedData; - if ((NULL == buf) || - ((RANDOM_CAPTURE_BUFFER_SIZE/2) > len)) // ping-pong buffer - { - return -1; + if ((NULL == buf) || + ((RANDOM_CAPTURE_BUFFER_SIZE / 2) > len)) // ping-pong buffer + { + return -1; + } + + RAND_TRACE(1, "%s", __func__); + RAND_DUMP("%x ", buf, 16); + + switch (bits) { + case AUD_BITS_16: { + uint16_t *content = (uint16_t *)buf; + + for (index = 0; index < 4; index++) { + seedData.value[index] = + ((*content) & RAND_GRAB_BITS_MASK_PER_SAMPLE) | + (((*(content + ch_num)) & RAND_GRAB_BITS_MASK_PER_SAMPLE) + << RAND_GRAB_BITS_PER_SAMPLE); + content += ((8 / RAND_GRAB_BITS_PER_SAMPLE) * ch_num); } - - RAND_TRACE(1, "%s", __func__); - RAND_DUMP("%x ",buf, 16); - - switch (bits) - { - case AUD_BITS_16: - { - uint16_t* content = (uint16_t *)buf; - - for (index = 0;index < 4; index++) - { - seedData.value[index] = ((*content) & RAND_GRAB_BITS_MASK_PER_SAMPLE) | - (((*(content+ch_num)) & RAND_GRAB_BITS_MASK_PER_SAMPLE) << RAND_GRAB_BITS_PER_SAMPLE); - content += ((8/RAND_GRAB_BITS_PER_SAMPLE)*ch_num); - } - break; - } - case AUD_BITS_24: - { - uint32_t* content = (uint32_t *)buf; - for (index = 0;index < 4; index++) - { - // bit 23:4 are valid - seedData.value[index] = (((*content) >> 4) & RAND_GRAB_BITS_MASK_PER_SAMPLE) | - ((((*(content+ch_num)) >> 4)&RAND_GRAB_BITS_MASK_PER_SAMPLE) << RAND_GRAB_BITS_PER_SAMPLE); - content += ((8/RAND_GRAB_BITS_PER_SAMPLE)*ch_num); - } - break; - } - case AUD_BITS_32: - { - uint32_t* content = (uint32_t *)buf; - for (index = 0;index < 4; index++) - { - // bit 31:12 are valid - seedData.value[index] = (((*content) >> 12) & RAND_GRAB_BITS_MASK_PER_SAMPLE) | - ((((*(content+ch_num)) >> 12) & RAND_GRAB_BITS_MASK_PER_SAMPLE) << RAND_GRAB_BITS_PER_SAMPLE); - content += ((8/RAND_GRAB_BITS_PER_SAMPLE)*ch_num); - } - break; - } - default: - { - return -1; - } - break; + break; + } + case AUD_BITS_24: { + uint32_t *content = (uint32_t *)buf; + for (index = 0; index < 4; index++) { + // bit 23:4 are valid + seedData.value[index] = + (((*content) >> 4) & RAND_GRAB_BITS_MASK_PER_SAMPLE) | + ((((*(content + ch_num)) >> 4) & RAND_GRAB_BITS_MASK_PER_SAMPLE) + << RAND_GRAB_BITS_PER_SAMPLE); + content += ((8 / RAND_GRAB_BITS_PER_SAMPLE) * ch_num); } + break; + } + case AUD_BITS_32: { + uint32_t *content = (uint32_t *)buf; + for (index = 0; index < 4; index++) { + // bit 31:12 are valid + seedData.value[index] = + (((*content) >> 12) & RAND_GRAB_BITS_MASK_PER_SAMPLE) | + ((((*(content + ch_num)) >> 12) & RAND_GRAB_BITS_MASK_PER_SAMPLE) + << RAND_GRAB_BITS_PER_SAMPLE); + content += ((8 / RAND_GRAB_BITS_PER_SAMPLE) * ch_num); + } + break; + } + default: { + return -1; + } break; + } - randSeed = seedData.seedValue; + randSeed = seedData.seedValue; - return 0; + return 0; } -static void generateRand(bool on) -{ - struct AF_STREAM_CONFIG_T stream_cfg; +static void generateRand(bool on) { + struct AF_STREAM_CONFIG_T stream_cfg; - RAND_TRACE(2, "%s op:%d", __func__, on); + RAND_TRACE(2, "%s op:%d", __func__, on); - if (on) - { - randomBuffer.skipRound = 10; + if (on) { + randomBuffer.skipRound = 10; - randomBuffer.status = random_mic_is_on(&deviceId); - RAND_TRACE(2, "%s random status = %d", __func__, randomBuffer.status); + randomBuffer.status = random_mic_is_on(&deviceId); + RAND_TRACE(2, "%s random status = %d", __func__, randomBuffer.status); - if (RAND_STATUS_CLOSE == randomBuffer.status) - { - app_sysfreq_req(APP_SYSFREQ_USER_RANDOM, APP_SYSFREQ_208M); - app_capture_audio_mempool_init(); - app_capture_audio_mempool_get_buff(&captureBuffer, - RANDOM_CAPTURE_BUFFER_SIZE); - memset(&stream_cfg, 0, sizeof(stream_cfg)); - stream_cfg.bits = AUD_BITS_16; - stream_cfg.channel_num = AUD_CHANNEL_NUM_1; - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; - stream_cfg.sample_rate = AUD_SAMPRATE_8000; - stream_cfg.vol = TGT_VOLUME_LEVEL_15; - stream_cfg.io_path = AUD_INPUT_PATH_MAINMIC; - stream_cfg.handler = rand_data_handle; + if (RAND_STATUS_CLOSE == randomBuffer.status) { + app_sysfreq_req(APP_SYSFREQ_USER_RANDOM, APP_SYSFREQ_208M); + app_capture_audio_mempool_init(); + app_capture_audio_mempool_get_buff(&captureBuffer, + RANDOM_CAPTURE_BUFFER_SIZE); + memset(&stream_cfg, 0, sizeof(stream_cfg)); + stream_cfg.bits = AUD_BITS_16; + stream_cfg.channel_num = AUD_CHANNEL_NUM_1; + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; + stream_cfg.sample_rate = AUD_SAMPRATE_8000; + stream_cfg.vol = TGT_VOLUME_LEVEL_15; + stream_cfg.io_path = AUD_INPUT_PATH_MAINMIC; + stream_cfg.handler = rand_data_handle; - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(captureBuffer); - stream_cfg.data_size = RANDOM_CAPTURE_BUFFER_SIZE; - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - randomBuffer.status = RAND_STATUS_OPEN; - } - else if(RAND_STATUS_MIC_OPENED == randomBuffer.status) - { - af_stream_start(deviceId, AUD_STREAM_CAPTURE); - } + stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(captureBuffer); + stream_cfg.data_size = RANDOM_CAPTURE_BUFFER_SIZE; + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + randomBuffer.status = RAND_STATUS_OPEN; + } else if (RAND_STATUS_MIC_OPENED == randomBuffer.status) { + af_stream_start(deviceId, AUD_STREAM_CAPTURE); } - else - { - // release the acquired system clock - app_sysfreq_req(APP_SYSFREQ_USER_RANDOM, APP_SYSFREQ_32K); - if (RAND_STATUS_MIC_OPENED == randomBuffer.status) - { - af_stream_stop(deviceId, AUD_STREAM_CAPTURE); - } - else if (RAND_STATUS_OPEN == randomBuffer.status) - { - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - } - randomBuffer.status = RAND_STATUS_CLOSE; + } else { + // release the acquired system clock + app_sysfreq_req(APP_SYSFREQ_USER_RANDOM, APP_SYSFREQ_32K); + if (RAND_STATUS_MIC_OPENED == randomBuffer.status) { + af_stream_stop(deviceId, AUD_STREAM_CAPTURE); + } else if (RAND_STATUS_OPEN == randomBuffer.status) { + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); } + randomBuffer.status = RAND_STATUS_CLOSE; + } } -static uint32_t rand_data_handle(uint8_t *buf, uint32_t len) -{ - if (buf == NULL) - { - return len; - } +static uint32_t rand_data_handle(uint8_t *buf, uint32_t len) { + if (buf == NULL) { + return len; + } - if ((1 == randomBuffer.skipRound) && - (!randDataParse(buf, len, AUD_BITS_16, AUD_CHANNEL_NUM_1))) - { + if ((1 == randomBuffer.skipRound) && + (!randDataParse(buf, len, AUD_BITS_16, AUD_CHANNEL_NUM_1))) { + generateRand(false); + randomBuffer.skipRound = 0; + } else if (1 != randomBuffer.skipRound) { + randomBuffer.skipRound--; + } + + return len; +} + +void initSeed(void) { + uint8_t count = 100; // avoid deed loop + + RAND_TRACE(2, "%s:+++ initialised = %d", __func__, randInitialised); + + if (randInitialised) { + generateRand(true); + + while ((0 != randomBuffer.skipRound) && (0 != count)) { + osDelay(10); + count--; + } + } + + if ((0 == count) || (false == randInitialised)) { + RAND_TRACE(1, "%s not ready", __func__); + randSeed = (uint32_t)hal_sys_timer_get(); + generateRand(false); + } + + srand(randSeed); + RAND_TRACE(2, "%s:--- count = %d", __func__, count); +} + +void random_status_sync(void) { + if (RAND_STATUS_OPEN == randomBuffer.status) { + RAND_TRACE(1, "%s random mic has already on,should be closed", __func__); + generateRand(false); + } +} + +void random_data_process(uint8_t *buf, uint32_t len, enum AUD_BITS_T bits, + enum AUD_CHANNEL_NUM_T ch_num) { + if (buf == NULL) { + return; + } + + if ((RAND_STATUS_MIC_STARTED == randomBuffer.status) || + (RAND_STATUS_MIC_OPENED == randomBuffer.status)) { + if (len >= RANDOM_CAPTURE_BUFFER_SIZE / 2) { + RAND_TRACE(4, "%s buf address = 0x%p, bits = %d, channel num = %d", + __func__, buf, bits, ch_num); + RAND_DUMP("%02x ", buf, 32); + if ((1 == randomBuffer.skipRound) && + (!randDataParse(buf, len, bits, ch_num))) { generateRand(false); randomBuffer.skipRound = 0; - } - else if (1 != randomBuffer.skipRound) - { + } else if (1 != randomBuffer.skipRound) { randomBuffer.skipRound--; + } } - - return len; + } } -void initSeed(void) -{ - uint8_t count = 100; // avoid deed loop - - RAND_TRACE(2, "%s:+++ initialised = %d", __func__, randInitialised); - - if (randInitialised) - { - generateRand(true); - - while ((0 != randomBuffer.skipRound) && (0 != count)) - { - osDelay(10); - count --; - } - } - - if ((0 == count) || (false == randInitialised)) - { - RAND_TRACE(1, "%s not ready", __func__); - randSeed = (uint32_t)hal_sys_timer_get(); - generateRand(false); - } - - srand(randSeed); - RAND_TRACE(2, "%s:--- count = %d", __func__, count); -} - -void random_status_sync(void) -{ - if (RAND_STATUS_OPEN == randomBuffer.status) - { - RAND_TRACE(1, "%s random mic has already on,should be closed", __func__); - generateRand(false); - } -} - -void random_data_process(uint8_t *buf, uint32_t len,enum AUD_BITS_T bits, - enum AUD_CHANNEL_NUM_T ch_num) -{ - if (buf == NULL) - { - return; - } - - if ((RAND_STATUS_MIC_STARTED == randomBuffer.status) || - (RAND_STATUS_MIC_OPENED == randomBuffer.status)) - { - if (len >= RANDOM_CAPTURE_BUFFER_SIZE/2) - { - RAND_TRACE(4, "%s buf address = 0x%p, bits = %d, channel num = %d", __func__, buf, bits, ch_num); - RAND_DUMP("%02x ", buf, 32); - if ((1 == randomBuffer.skipRound) && - (!randDataParse(buf, len, bits, ch_num))) - { - generateRand(false); - randomBuffer.skipRound = 0; - } - else if (1 != randomBuffer.skipRound) - { - randomBuffer.skipRound--; - } - } - } -} - -void randInit(void) -{ - randInitialised = true; -} +void randInit(void) { randInitialised = true; } #endif diff --git a/apps/factory/app_factory.cpp b/apps/factory/app_factory.cpp index 653b387..f935518 100644 --- a/apps/factory/app_factory.cpp +++ b/apps/factory/app_factory.cpp @@ -13,46 +13,44 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "app_factory.h" +#include "app_bt_stream.h" +#include "app_key.h" +#include "app_media_player.h" +#include "bluetooth.h" +#include "bt_drv_interface.h" +#include "bt_drv_reg_op.h" #include "cmsis_os.h" -#include "list.h" -#include "hal_trace.h" #include "hal_bootmode.h" #include "hal_cmu.h" #include "hal_sleep.h" -#include "app_key.h" -#include "app_factory.h" -#include "bt_drv_interface.h" -#include "bt_drv_reg_op.h" -#include "bluetooth.h" +#include "hal_trace.h" +#include "list.h" #include "nvrecord.h" #include "nvrecord_dev.h" #include "nvrecord_env.h" -#include "resources.h" -#include "app_bt_stream.h" -#include "app_media_player.h" #include "pmu.h" +#include "resources.h" // for init -#include "apps.h" +#include "app_battery.h" +#include "app_key.h" +#include "app_overlay.h" +#include "app_pwl.h" #include "app_status_ind.h" #include "app_thread.h" -#include "app_key.h" -#include "app_pwl.h" -#include "app_overlay.h" -#include "app_battery.h" #include "app_utils.h" +#include "apps.h" // for bt -#include "besbt.h" #include "app_bt.h" #include "app_factory_bt.h" +#include "besbt.h" // for audio -#include "audioflinger.h" #include "app_audio.h" #include "app_utils.h" - - +#include "audioflinger.h" // for progress #include "hal_uart.h" @@ -65,625 +63,622 @@ #define APP_FACTORYMODE_RETRY_LIMITED (2) typedef enum APP_FACTORYMODE_STATUS_INDICATION_T { - APP_FACTORYMODE_STATUS_INDICATION_RUNNING = 0, - APP_FACTORYMODE_STATUS_INDICATION_PASS, - APP_FACTORYMODE_STATUS_INDICATION_FAILED, - APP_FACTORYMODE_STATUS_INDICATION_INVALID, + APP_FACTORYMODE_STATUS_INDICATION_RUNNING = 0, + APP_FACTORYMODE_STATUS_INDICATION_PASS, + APP_FACTORYMODE_STATUS_INDICATION_FAILED, + APP_FACTORYMODE_STATUS_INDICATION_INVALID, - APP_FACTORYMODE_STATUS_INDICATION_NUM -}APP_FACTORYMODE_STATUS_INDICATION_T; + APP_FACTORYMODE_STATUS_INDICATION_NUM +} APP_FACTORYMODE_STATUS_INDICATION_T; static void app_factorymode_timehandler(void const *param); void app_bt_key_shutdown(APP_KEY_STATUS *status, void *param); void app_factorymode_result_set(bool result); -static osThreadId app_factorymode_tid= NULL; -static struct message_t send_msg = { { PREFIX_CHAR, }, }; +static osThreadId app_factorymode_tid = NULL; +static struct message_t send_msg = { + { + PREFIX_CHAR, + }, +}; static unsigned char send_seq = 0; osTimerId app_factory_timer = NULL; -osTimerDef (APP_FACTORY_TIMER, app_factorymode_timehandler); +osTimerDef(APP_FACTORY_TIMER, app_factorymode_timehandler); -int app_factorymode_languageswitch_proc(void) -{ +int app_factorymode_languageswitch_proc(void) { #ifdef MEDIA_PLAYER_SUPPORT - int lan; - int new_lan; - struct nvrecord_env_t *nvrecord_env; + int lan; + int new_lan; + struct nvrecord_env_t *nvrecord_env; + APP_FACTORY_TRACE(1, "%s", __func__); + lan = app_play_audio_get_lang(); + new_lan = lan; + app_play_audio_set_lang(new_lan); - APP_FACTORY_TRACE(1,"%s",__func__); - lan = app_play_audio_get_lang(); - new_lan = lan; - app_play_audio_set_lang(new_lan); + nv_record_env_get(&nvrecord_env); + nvrecord_env->media_language.language = new_lan; + nv_record_env_set(nvrecord_env); - nv_record_env_get(&nvrecord_env); - nvrecord_env->media_language.language = new_lan; - nv_record_env_set(nvrecord_env); - - APP_FACTORY_TRACE(2,"languages old:%d new:%d",lan ,new_lan); - media_PlayAudio(AUD_ID_LANGUAGE_SWITCH, 0); + APP_FACTORY_TRACE(2, "languages old:%d new:%d", lan, new_lan); + media_PlayAudio(AUD_ID_LANGUAGE_SWITCH, 0); #endif - return 0; + return 0; } -void app_factorymode_languageswitch(APP_KEY_STATUS *status, void *param) -{ - app_factorymode_languageswitch_proc(); +void app_factorymode_languageswitch(APP_KEY_STATUS *status, void *param) { + app_factorymode_languageswitch_proc(); } -void app_factorymode_enter(void) -{ - APP_FACTORY_TRACE(1,"%s",__func__); - hal_sw_bootmode_set(HAL_SW_BOOTMODE_TEST_MODE|HAL_SW_BOOTMODE_TEST_SIGNALINGMODE); - hal_cmu_sys_reboot(); +void app_factorymode_enter(void) { + APP_FACTORY_TRACE(1, "%s", __func__); + hal_sw_bootmode_set(HAL_SW_BOOTMODE_TEST_MODE | + HAL_SW_BOOTMODE_TEST_SIGNALINGMODE); + hal_cmu_sys_reboot(); } extern "C" { static bool isInFactoryMode = false; -bool app_factorymode_get(void) -{ - return isInFactoryMode; -} - -void app_factorymode_set(bool set) -{ - isInFactoryMode = set; -} +bool app_factorymode_get(void) { return isInFactoryMode; } +void app_factorymode_set(bool set) { isInFactoryMode = set; } } #ifdef POWERKEY_I2C_SWITCH -void app_factorymode_i2c_switch(APP_KEY_STATUS *status, void *param) -{ - static int i = 0; +void app_factorymode_i2c_switch(APP_KEY_STATUS *status, void *param) { + static int i = 0; - i++; - if (i & 1) { - TRACE(0,"set analog i2c mode !!!"); - osDelay(100); - hal_iomux_set_analog_i2c(); - } else { - hal_iomux_set_uart0(); - osDelay(100); - TRACE(0,"hal_iomux_set_uart0 !!!"); - } + i++; + if (i & 1) { + TRACE(0, "set analog i2c mode !!!"); + osDelay(100); + hal_iomux_set_analog_i2c(); + } else { + hal_iomux_set_uart0(); + osDelay(100); + TRACE(0, "hal_iomux_set_uart0 !!!"); + } } #endif #ifdef __IBRT_IBRT_TESTMODE__ void bt_drv_ibrt_test_key_click(APP_KEY_STATUS *status, void *param); -void bt_drv_ibrt_test_key_click(APP_KEY_STATUS *status, void *param) -{ - btdrv_connect_ibrt_device(bt_addr); +void bt_drv_ibrt_test_key_click(APP_KEY_STATUS *status, void *param) { + btdrv_connect_ibrt_device(bt_addr); } #endif -void app_factorymode_key_init(void) -{ - const APP_KEY_HANDLE app_factorymode_handle_cfg[] = { +void app_factorymode_key_init(void) { + const APP_KEY_HANDLE app_factorymode_handle_cfg[] = { #ifdef POWERKEY_I2C_SWITCH - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_RAMPAGECLICK},"bt i2c key",app_factorymode_i2c_switch, NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_RAMPAGECLICK}, + "bt i2c key", + app_factorymode_i2c_switch, + NULL}, #endif #ifdef __POWERKEY_CTRL_ONOFF_ONLY__ - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_UP},"bt function key",app_bt_key_shutdown, NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_UP}, + "bt function key", + app_bt_key_shutdown, + NULL}, #else - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_LONGLONGPRESS},"bt function key",app_bt_key_shutdown, NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_LONGLONGPRESS}, + "bt function key", + app_bt_key_shutdown, + NULL}, #endif #ifdef __IBRT_IBRT_TESTMODE__ - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_CLICK},"bt function key",bt_drv_ibrt_test_key_click, NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_CLICK}, + "bt function key", + bt_drv_ibrt_test_key_click, + NULL}, #else - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_CLICK},"bt function key",app_factorymode_languageswitch, NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_CLICK}, + "bt function key", + app_factorymode_languageswitch, + NULL}, #endif - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_DOUBLECLICK},"bt function key",app_factorymode_bt_xtalcalib, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_LONGPRESS},"bt function key",app_factorymode_bt_signalingtest, NULL}, - }; + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_DOUBLECLICK}, + "bt function key", + app_factorymode_bt_xtalcalib, + NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_LONGPRESS}, + "bt function key", + app_factorymode_bt_signalingtest, + NULL}, + }; - uint8_t i = 0; + uint8_t i = 0; - APP_FACTORY_TRACE(1,"%s",__func__); + APP_FACTORY_TRACE(1, "%s", __func__); - app_key_handle_clear(); - for (i=0; i<(sizeof(app_factorymode_handle_cfg)/sizeof(APP_KEY_HANDLE)); i++){ - app_key_handle_registration(&app_factorymode_handle_cfg[i]); + app_key_handle_clear(); + for (i = 0; i < (sizeof(app_factorymode_handle_cfg) / sizeof(APP_KEY_HANDLE)); + i++) { + app_key_handle_registration(&app_factorymode_handle_cfg[i]); + } +} + +static void app_factorymode_audioloopswitch(APP_KEY_STATUS *status, + void *param) { + static bool onaudioloop = false; + + onaudioloop = onaudioloop ? false : true; + + if (onaudioloop) + app_audio_sendrequest(APP_FACTORYMODE_AUDIO_LOOP, + (uint8_t)APP_BT_SETTING_OPEN, 0); + else + app_audio_sendrequest(APP_FACTORYMODE_AUDIO_LOOP, + (uint8_t)APP_BT_SETTING_CLOSE, 0); +} + +void app_factorymode_test_key_init(void) { + const APP_KEY_HANDLE app_factorymode_handle_cfg[] = { + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_CLICK}, + "bt function key", + app_factorymode_audioloopswitch, + NULL}, + }; + + uint8_t i = 0; + APP_FACTORY_TRACE(1, "%s", __func__); + for (i = 0; i < (sizeof(app_factorymode_handle_cfg) / sizeof(APP_KEY_HANDLE)); + i++) { + app_key_handle_registration(&app_factorymode_handle_cfg[i]); + } +} + +void app_factorymode_result_clean(void) { + osSignalClear(app_factorymode_tid, 0x01); + osSignalClear(app_factorymode_tid, 0x02); +} + +void app_factorymode_result_set(bool result) { + if (result) + osSignalSet(app_factorymode_tid, 0x01); + else + osSignalSet(app_factorymode_tid, 0x02); +} + +bool app_factorymode_result_wait(void) { + bool nRet; + osEvent evt; + + while (1) { + // wait any signal + evt = osSignalWait(0x0, osWaitForever); + + // get role from signal value + if (evt.status == osEventSignal) { + if (evt.value.signals & 0x01) { + nRet = true; + break; + } else if (evt.value.signals & 0x02) { + nRet = false; + break; + } } + } + return nRet; } -static void app_factorymode_audioloopswitch(APP_KEY_STATUS *status, void *param) -{ - static bool onaudioloop = false; +static int app_factorymode_send_progress(uint8_t progress) { + APP_MESSAGE_BLOCK msg; - onaudioloop = onaudioloop?false:true; + msg.mod_id = APP_MODUAL_OHTER; + msg.msg_body.message_id = 2; + msg.msg_body.message_Param0 = progress; + app_mailbox_put(&msg); - if (onaudioloop) - app_audio_sendrequest(APP_FACTORYMODE_AUDIO_LOOP, (uint8_t)APP_BT_SETTING_OPEN, 0); - else - app_audio_sendrequest(APP_FACTORYMODE_AUDIO_LOOP, (uint8_t)APP_BT_SETTING_CLOSE, 0); + return 0; } -void app_factorymode_test_key_init(void) -{ - const APP_KEY_HANDLE app_factorymode_handle_cfg[] = { - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_CLICK},"bt function key",app_factorymode_audioloopswitch, NULL}, - }; +static int app_factorymode_send_code(uint32_t progress) { + APP_MESSAGE_BLOCK msg; - uint8_t i = 0; - APP_FACTORY_TRACE(1,"%s",__func__); - for (i=0; i<(sizeof(app_factorymode_handle_cfg)/sizeof(APP_KEY_HANDLE)); i++){ - app_key_handle_registration(&app_factorymode_handle_cfg[i]); - } + msg.mod_id = APP_MODUAL_OHTER; + msg.msg_body.message_id = 3; + msg.msg_body.message_Param0 = progress; + app_mailbox_put(&msg); + + return 0; } -void app_factorymode_result_clean(void) -{ - osSignalClear(app_factorymode_tid, 0x01); - osSignalClear(app_factorymode_tid, 0x02); -} +int app_factorymode_proc(void) { + uint8_t cnt = 0; + bool nRet; + app_factorymode_tid = osThreadGetId(); -void app_factorymode_result_set(bool result) -{ - if (result) - osSignalSet(app_factorymode_tid ,0x01); - else - osSignalSet(app_factorymode_tid ,0x02); -} + app_factorymode_send_progress(60); + app_factorymode_bt_init_connect(); -bool app_factorymode_result_wait(void) -{ - bool nRet; - osEvent evt; - - while(1) - { - //wait any signal - evt = osSignalWait(0x0, osWaitForever); - - //get role from signal value - if(evt.status == osEventSignal) - { - if(evt.value.signals & 0x01) - { - nRet = true; - break; - } - else if(evt.value.signals & 0x02) - { - nRet = false; - break; - } - } - } - return nRet; -} - -static int app_factorymode_send_progress (uint8_t progress) -{ - APP_MESSAGE_BLOCK msg; - - msg.mod_id = APP_MODUAL_OHTER; - msg.msg_body.message_id = 2; - msg.msg_body.message_Param0 = progress; - app_mailbox_put(&msg); - - return 0; -} - -static int app_factorymode_send_code (uint32_t progress) -{ - APP_MESSAGE_BLOCK msg; - - msg.mod_id = APP_MODUAL_OHTER; - msg.msg_body.message_id = 3; - msg.msg_body.message_Param0 = progress; - app_mailbox_put(&msg); - - return 0; -} - -int app_factorymode_proc(void) -{ - uint8_t cnt = 0; - bool nRet; - app_factorymode_tid = osThreadGetId(); - - app_factorymode_send_progress(60); - app_factorymode_bt_init_connect(); - - do{ - app_factorymode_result_clean(); - app_factorymode_bt_create_connect(); - nRet = app_factorymode_result_wait(); - }while(!nRet && ++cnt < APP_FACTORYMODE_RETRY_LIMITED); - - if (!nRet) - goto exit; - app_factorymode_send_progress(90); + do { app_factorymode_result_clean(); - if (!nRet) - goto exit; - app_factorymode_send_progress(100); - osDelay(100); + app_factorymode_bt_create_connect(); + nRet = app_factorymode_result_wait(); + } while (!nRet && ++cnt < APP_FACTORYMODE_RETRY_LIMITED); + + if (!nRet) + goto exit; + app_factorymode_send_progress(90); + app_factorymode_result_clean(); + if (!nRet) + goto exit; + app_factorymode_send_progress(100); + osDelay(100); exit: - app_factorymode_result_clean(); - if (nRet){ - return 0; - }else{ - return -1; - } -} - -static unsigned char app_factorymode_msg_check_sum(unsigned char *buf, unsigned char len) -{ - int i; - unsigned char sum = 0; - - for (i = 0; i < len; i++) { - sum += buf[i]; - } - - return sum; -} - -static int app_factorymode_msg_uart_send(const unsigned char *buf, size_t len) -{ - uint32_t sent = 0; - - while (sent < len) { - hal_uart_blocked_putc(HAL_UART_ID_0, buf[sent++]); - } - - if (sent != len) { - return 1; - } - + app_factorymode_result_clean(); + if (nRet) { return 0; + } else { + return -1; + } } -static int app_factorymode_msg_send_ping(void) -{ - int ret; +static unsigned char app_factorymode_msg_check_sum(unsigned char *buf, + unsigned char len) { + int i; + unsigned char sum = 0; - send_msg.hdr.type = 0x88; - send_msg.hdr.seq = send_seq++; - send_msg.hdr.len = 2; - send_msg.data[0] = 0xaa; - send_msg.data[1] = 0x55; - send_msg.data[2] = ~app_factorymode_msg_check_sum((unsigned char *)&send_msg, MSG_TOTAL_LEN(&send_msg) - 1); + for (i = 0; i < len; i++) { + sum += buf[i]; + } - ret = app_factorymode_msg_uart_send((unsigned char *)&send_msg, MSG_TOTAL_LEN(&send_msg)); - - return ret; + return sum; } -static int app_factorymode_msg_send_progress (uint8_t progress) -{ - int ret; +static int app_factorymode_msg_uart_send(const unsigned char *buf, size_t len) { + uint32_t sent = 0; - send_msg.hdr.type = 0x88; - send_msg.hdr.seq = send_seq++; - send_msg.hdr.len = 2; - send_msg.data[0] = progress; - send_msg.data[1] = 100; - send_msg.data[2] = ~app_factorymode_msg_check_sum((unsigned char *)&send_msg, MSG_TOTAL_LEN(&send_msg) - 1); + while (sent < len) { + hal_uart_blocked_putc(HAL_UART_ID_0, buf[sent++]); + } - ret = app_factorymode_msg_uart_send((unsigned char *)&send_msg, MSG_TOTAL_LEN(&send_msg)); + if (sent != len) { + return 1; + } - return ret; + return 0; } -static int app_factorymode_msg_send_32bitcode(uint32_t code) -{ - int ret; +static int app_factorymode_msg_send_ping(void) { + int ret; - send_msg.hdr.type = 0x88; - send_msg.hdr.seq = send_seq++; - send_msg.hdr.len = 4; - send_msg.data[0] = 0xf2; - *(uint32_t *)&(send_msg.data[1]) = code; - send_msg.data[4] = ~app_factorymode_msg_check_sum((unsigned char *)&send_msg, MSG_TOTAL_LEN(&send_msg) - 1); + send_msg.hdr.type = 0x88; + send_msg.hdr.seq = send_seq++; + send_msg.hdr.len = 2; + send_msg.data[0] = 0xaa; + send_msg.data[1] = 0x55; + send_msg.data[2] = ~app_factorymode_msg_check_sum( + (unsigned char *)&send_msg, MSG_TOTAL_LEN(&send_msg) - 1); - ret = app_factorymode_msg_uart_send((unsigned char *)&send_msg, MSG_TOTAL_LEN(&send_msg)); + ret = app_factorymode_msg_uart_send((unsigned char *)&send_msg, + MSG_TOTAL_LEN(&send_msg)); - return ret; + return ret; } -static int app_factorymode_process(APP_MESSAGE_BODY *msg_body) -{ - if (msg_body->message_id == 1){ - app_factorymode_msg_send_ping(); - } - if (msg_body->message_id == 2){ - app_factorymode_msg_send_progress(msg_body->message_Param0); - } - if (msg_body->message_id == 3){ - app_factorymode_msg_send_32bitcode(msg_body->message_Param0); - } - return 0; +static int app_factorymode_msg_send_progress(uint8_t progress) { + int ret; + + send_msg.hdr.type = 0x88; + send_msg.hdr.seq = send_seq++; + send_msg.hdr.len = 2; + send_msg.data[0] = progress; + send_msg.data[1] = 100; + send_msg.data[2] = ~app_factorymode_msg_check_sum( + (unsigned char *)&send_msg, MSG_TOTAL_LEN(&send_msg) - 1); + + ret = app_factorymode_msg_uart_send((unsigned char *)&send_msg, + MSG_TOTAL_LEN(&send_msg)); + + return ret; } -static int app_factorymode_uart_init(void) -{ - struct HAL_UART_CFG_T uart_cfg; +static int app_factorymode_msg_send_32bitcode(uint32_t code) { + int ret; - memset(&uart_cfg, 0, sizeof(struct HAL_UART_CFG_T)); - uart_cfg.parity = HAL_UART_PARITY_NONE, - uart_cfg.stop = HAL_UART_STOP_BITS_1, - uart_cfg.data = HAL_UART_DATA_BITS_8, - uart_cfg.flow = HAL_UART_FLOW_CONTROL_NONE,//HAL_UART_FLOW_CONTROL_RTSCTS, - uart_cfg.tx_level = HAL_UART_FIFO_LEVEL_1_2, - uart_cfg.rx_level = HAL_UART_FIFO_LEVEL_1_4, - uart_cfg.baud = 921600, - uart_cfg.dma_rx = false, - uart_cfg.dma_tx = false, - uart_cfg.dma_rx_stop_on_err = false; - hal_uart_close(HAL_UART_ID_0); - hal_uart_open(HAL_UART_ID_0, &uart_cfg); + send_msg.hdr.type = 0x88; + send_msg.hdr.seq = send_seq++; + send_msg.hdr.len = 4; + send_msg.data[0] = 0xf2; + *(uint32_t *)&(send_msg.data[1]) = code; + send_msg.data[4] = ~app_factorymode_msg_check_sum( + (unsigned char *)&send_msg, MSG_TOTAL_LEN(&send_msg) - 1); - return 0; + ret = app_factorymode_msg_uart_send((unsigned char *)&send_msg, + MSG_TOTAL_LEN(&send_msg)); + + return ret; } - -static void app_factorymode_timehandler(void const *param) -{ - APP_MESSAGE_BLOCK msg; - - msg.mod_id = APP_MODUAL_OHTER; - msg.msg_body.message_id = 1; - app_mailbox_put(&msg); +static int app_factorymode_process(APP_MESSAGE_BODY *msg_body) { + if (msg_body->message_id == 1) { + app_factorymode_msg_send_ping(); + } + if (msg_body->message_id == 2) { + app_factorymode_msg_send_progress(msg_body->message_Param0); + } + if (msg_body->message_id == 3) { + app_factorymode_msg_send_32bitcode(msg_body->message_Param0); + } + return 0; } -static uint8_t app_factorymode_indication_init(void) -{ - struct APP_PWL_CFG_T cfg; +static int app_factorymode_uart_init(void) { + struct HAL_UART_CFG_T uart_cfg; - memset(&cfg, 0, sizeof(struct APP_PWL_CFG_T)); - app_pwl_open(); - app_pwl_setup(APP_PWL_ID_0, &cfg); - app_pwl_setup(APP_PWL_ID_1, &cfg); - return 0; + memset(&uart_cfg, 0, sizeof(struct HAL_UART_CFG_T)); + uart_cfg.parity = HAL_UART_PARITY_NONE, uart_cfg.stop = HAL_UART_STOP_BITS_1, + uart_cfg.data = HAL_UART_DATA_BITS_8, + uart_cfg.flow = HAL_UART_FLOW_CONTROL_NONE, // HAL_UART_FLOW_CONTROL_RTSCTS, + uart_cfg.tx_level = HAL_UART_FIFO_LEVEL_1_2, + uart_cfg.rx_level = HAL_UART_FIFO_LEVEL_1_4, uart_cfg.baud = 921600, + uart_cfg.dma_rx = false, uart_cfg.dma_tx = false, + uart_cfg.dma_rx_stop_on_err = false; + hal_uart_close(HAL_UART_ID_0); + hal_uart_open(HAL_UART_ID_0, &uart_cfg); + + return 0; } -static uint8_t app_factorymode_status_indication(APP_FACTORYMODE_STATUS_INDICATION_T status) -{ - struct APP_PWL_CFG_T cfg0; - struct APP_PWL_CFG_T cfg1; - APP_FACTORY_TRACE(2,"%s %d",__func__, status); - memset(&cfg0, 0, sizeof(struct APP_PWL_CFG_T)); - memset(&cfg1, 0, sizeof(struct APP_PWL_CFG_T)); - app_pwl_stop(APP_PWL_ID_0); - app_pwl_stop(APP_PWL_ID_1); - switch (status) { - case APP_FACTORYMODE_STATUS_INDICATION_RUNNING: - cfg0.part[0].level = 0; - cfg0.part[0].time = (300); - cfg0.part[1].level = 1; - cfg0.part[1].time = (300); - cfg0.parttotal = 2; - cfg0.startlevel = 0; - cfg0.periodic = true; +static void app_factorymode_timehandler(void const *param) { + APP_MESSAGE_BLOCK msg; - cfg1.part[0].level = 1; - cfg1.part[0].time = (300); - cfg1.part[1].level = 0; - cfg1.part[1].time = (300); - cfg1.parttotal = 2; - cfg1.startlevel = 1; - cfg1.periodic = true; - - app_pwl_setup(APP_PWL_ID_0, &cfg0); - app_pwl_start(APP_PWL_ID_0); - app_pwl_setup(APP_PWL_ID_1, &cfg1); - app_pwl_start(APP_PWL_ID_1); - break; - case APP_FACTORYMODE_STATUS_INDICATION_PASS: - cfg0.part[0].level = 1; - cfg0.part[0].time = (5000); - cfg0.parttotal = 1; - cfg0.startlevel = 1; - cfg0.periodic = false; - - app_pwl_setup(APP_PWL_ID_0, &cfg0); - app_pwl_start(APP_PWL_ID_0); - break; - case APP_FACTORYMODE_STATUS_INDICATION_FAILED: - cfg1.part[0].level = 1; - cfg1.part[0].time = (5000); - cfg1.parttotal = 1; - cfg1.startlevel = 1; - cfg1.periodic = false; - - app_pwl_setup(APP_PWL_ID_1, &cfg1); - app_pwl_start(APP_PWL_ID_1); - - break; - - default: - break; - } - return 0; + msg.mod_id = APP_MODUAL_OHTER; + msg.msg_body.message_id = 1; + app_mailbox_put(&msg); } -int app_factorymode_init(uint32_t factorymode) -{ - uint8_t cnt = 0; - int nRet = 0; - uint32_t capval = 0x00; - struct nvrecord_env_t *nvrecord_env; - APP_FACTORY_TRACE(1,"app_factorymode_init mode:%x\n", factorymode); +static uint8_t app_factorymode_indication_init(void) { + struct APP_PWL_CFG_T cfg; - osThreadSetPriority(osThreadGetId(), osPriorityRealtime); - app_factorymode_uart_init(); + memset(&cfg, 0, sizeof(struct APP_PWL_CFG_T)); + app_pwl_open(); + app_pwl_setup(APP_PWL_ID_0, &cfg); + app_pwl_setup(APP_PWL_ID_1, &cfg); + return 0; +} + +static uint8_t +app_factorymode_status_indication(APP_FACTORYMODE_STATUS_INDICATION_T status) { + struct APP_PWL_CFG_T cfg0; + struct APP_PWL_CFG_T cfg1; + APP_FACTORY_TRACE(2, "%s %d", __func__, status); + memset(&cfg0, 0, sizeof(struct APP_PWL_CFG_T)); + memset(&cfg1, 0, sizeof(struct APP_PWL_CFG_T)); + app_pwl_stop(APP_PWL_ID_0); + app_pwl_stop(APP_PWL_ID_1); + switch (status) { + case APP_FACTORYMODE_STATUS_INDICATION_RUNNING: + cfg0.part[0].level = 0; + cfg0.part[0].time = (300); + cfg0.part[1].level = 1; + cfg0.part[1].time = (300); + cfg0.parttotal = 2; + cfg0.startlevel = 0; + cfg0.periodic = true; + + cfg1.part[0].level = 1; + cfg1.part[0].time = (300); + cfg1.part[1].level = 0; + cfg1.part[1].time = (300); + cfg1.parttotal = 2; + cfg1.startlevel = 1; + cfg1.periodic = true; + + app_pwl_setup(APP_PWL_ID_0, &cfg0); + app_pwl_start(APP_PWL_ID_0); + app_pwl_setup(APP_PWL_ID_1, &cfg1); + app_pwl_start(APP_PWL_ID_1); + break; + case APP_FACTORYMODE_STATUS_INDICATION_PASS: + cfg0.part[0].level = 1; + cfg0.part[0].time = (5000); + cfg0.parttotal = 1; + cfg0.startlevel = 1; + cfg0.periodic = false; + + app_pwl_setup(APP_PWL_ID_0, &cfg0); + app_pwl_start(APP_PWL_ID_0); + break; + case APP_FACTORYMODE_STATUS_INDICATION_FAILED: + cfg1.part[0].level = 1; + cfg1.part[0].time = (5000); + cfg1.parttotal = 1; + cfg1.startlevel = 1; + cfg1.periodic = false; + + app_pwl_setup(APP_PWL_ID_1, &cfg1); + app_pwl_start(APP_PWL_ID_1); + + break; + + default: + break; + } + return 0; +} + +int app_factorymode_init(uint32_t factorymode) { + uint8_t cnt = 0; + int nRet = 0; + uint32_t capval = 0x00; + struct nvrecord_env_t *nvrecord_env; + APP_FACTORY_TRACE(1, "app_factorymode_init mode:%x\n", factorymode); + + osThreadSetPriority(osThreadGetId(), osPriorityRealtime); + app_factorymode_uart_init(); #ifdef __WATCHER_DOG_RESET__ - app_wdt_open(60); + app_wdt_open(60); #endif - app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_52M); - list_init(); - app_os_init(); - app_factorymode_indication_init(); - app_battery_open(); - if (app_key_open(false)){ - nRet = -1; - goto exit; - } - app_set_threadhandle(APP_MODUAL_OHTER, app_factorymode_process); - app_factory_timer = osTimerCreate (osTimer(APP_FACTORY_TIMER), osTimerPeriodic, NULL); - osTimerStart(app_factory_timer, 300); - app_factorymode_send_progress(10); + app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_52M); + list_init(); + app_os_init(); + app_factorymode_indication_init(); + app_battery_open(); + if (app_key_open(false)) { + nRet = -1; + goto exit; + } + app_set_threadhandle(APP_MODUAL_OHTER, app_factorymode_process); + app_factory_timer = + osTimerCreate(osTimer(APP_FACTORY_TIMER), osTimerPeriodic, NULL); + osTimerStart(app_factory_timer, 300); + app_factorymode_send_progress(10); - app_bt_init(); - af_open(); - app_audio_open(); - app_overlay_open(); + app_bt_init(); + af_open(); + app_audio_open(); + app_overlay_open(); - nv_record_env_init(); - nvrec_dev_data_open(); - nv_record_env_get(&nvrecord_env); + nv_record_env_init(); + nvrec_dev_data_open(); + nv_record_env_get(&nvrecord_env); #ifdef MEDIA_PLAYER_SUPPORT - app_play_audio_set_lang(nvrecord_env->media_language.language); - app_voice_report(APP_STATUS_INDICATION_POWERON, 0); + app_play_audio_set_lang(nvrecord_env->media_language.language); + app_voice_report(APP_STATUS_INDICATION_POWERON, 0); #endif - app_status_indication_set(APP_STATUS_INDICATION_POWERON); - app_factorymode_status_indication(APP_FACTORYMODE_STATUS_INDICATION_RUNNING); - - if (factorymode&HAL_SW_BOOTMODE_CALIB){ - btdrv_start_bt(); - app_factorymode_send_progress(20); - - do { - nRet = app_factorymode_bt_xtalcalib_proc(); - }while(nRet && cnt++ +#include +#define APP_FACTORY_TRACE(s, ...) TRACE(s, ##__VA_ARGS__) void app_factorymode_result_set(bool result); diff --git a/apps/factory/app_factory_audio.cpp b/apps/factory/app_factory_audio.cpp index fdef587..61f0009 100644 --- a/apps/factory/app_factory_audio.cpp +++ b/apps/factory/app_factory_audio.cpp @@ -13,171 +13,159 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "app_bt_stream.h" +#include "app_factory.h" +#include "app_media_player.h" #include "cmsis_os.h" #include "hal_trace.h" #include "resources.h" -#include "app_bt_stream.h" -#include "app_media_player.h" -#include "app_factory.h" #include "string.h" // for audio -#include "audioflinger.h" #include "app_audio.h" #include "app_utils.h" +#include "audioflinger.h" #include "app_factory_audio.h" - #ifdef __FACTORY_MODE_SUPPORT__ -#define BT_AUDIO_FACTORMODE_BUFF_SIZE (1024*2) +#define BT_AUDIO_FACTORMODE_BUFF_SIZE (1024 * 2) static enum APP_AUDIO_CACHE_T a2dp_cache_status = APP_AUDIO_CACHE_QTY; static int16_t *app_audioloop_play_cache = NULL; -static uint32_t app_factorymode_data_come(uint8_t *buf, uint32_t len) -{ - DUMP16("%d,",(int*)buf,30); +static uint32_t app_factorymode_data_come(uint8_t *buf, uint32_t len) { + DUMP16("%d,", (int *)buf, 30); - app_audio_pcmbuff_put(buf, len); - if (a2dp_cache_status == APP_AUDIO_CACHE_QTY){ - a2dp_cache_status = APP_AUDIO_CACHE_OK; - } - return len; + app_audio_pcmbuff_put(buf, len); + if (a2dp_cache_status == APP_AUDIO_CACHE_QTY) { + a2dp_cache_status = APP_AUDIO_CACHE_OK; + } + return len; } -static uint32_t app_factorymode_more_data(uint8_t *buf, uint32_t len) -{ - if (a2dp_cache_status != APP_AUDIO_CACHE_QTY){ - app_audio_pcmbuff_get((uint8_t *)app_audioloop_play_cache, len/2); - app_bt_stream_copy_track_one_to_two_16bits((int16_t *)buf, app_audioloop_play_cache, len/2/2); - } - return len; +static uint32_t app_factorymode_more_data(uint8_t *buf, uint32_t len) { + if (a2dp_cache_status != APP_AUDIO_CACHE_QTY) { + app_audio_pcmbuff_get((uint8_t *)app_audioloop_play_cache, len / 2); + app_bt_stream_copy_track_one_to_two_16bits( + (int16_t *)buf, app_audioloop_play_cache, len / 2 / 2); + } + return len; } -int app_factorymode_audioloop(bool on, enum APP_SYSFREQ_FREQ_T freq) -{ - uint8_t *buff_play = NULL; - uint8_t *buff_capture = NULL; - uint8_t *buff_loop = NULL; - struct AF_STREAM_CONFIG_T stream_cfg; - static bool isRun = false; - APP_FACTORY_TRACE(3,"app_factorymode_audioloop work:%d op:%d freq:%d", isRun, on, freq); +int app_factorymode_audioloop(bool on, enum APP_SYSFREQ_FREQ_T freq) { + uint8_t *buff_play = NULL; + uint8_t *buff_capture = NULL; + uint8_t *buff_loop = NULL; + struct AF_STREAM_CONFIG_T stream_cfg; + static bool isRun = false; + APP_FACTORY_TRACE(3, "app_factorymode_audioloop work:%d op:%d freq:%d", isRun, + on, freq); - if (isRun==on) - return 0; + if (isRun == on) + return 0; - if (on){ - if (freq < APP_SYSFREQ_52M) { - freq = APP_SYSFREQ_52M; - } - app_sysfreq_req(APP_SYSFREQ_USER_APP_0, freq); + if (on) { + if (freq < APP_SYSFREQ_52M) { + freq = APP_SYSFREQ_52M; + } + app_sysfreq_req(APP_SYSFREQ_USER_APP_0, freq); - a2dp_cache_status = APP_AUDIO_CACHE_QTY; - app_audio_mempool_init(); - app_audio_mempool_get_buff(&buff_capture, BT_AUDIO_FACTORMODE_BUFF_SIZE); - app_audio_mempool_get_buff(&buff_play, BT_AUDIO_FACTORMODE_BUFF_SIZE*2); - app_audio_mempool_get_buff((uint8_t **)&app_audioloop_play_cache, BT_AUDIO_FACTORMODE_BUFF_SIZE*2/2/2); - app_audio_mempool_get_buff(&buff_loop, BT_AUDIO_FACTORMODE_BUFF_SIZE<<2); - app_audio_pcmbuff_init(buff_loop, BT_AUDIO_FACTORMODE_BUFF_SIZE<<2); - memset(&stream_cfg, 0, sizeof(stream_cfg)); - stream_cfg.bits = AUD_BITS_16; - //stream_cfg.channel_num = AUD_CHANNEL_NUM_1; + a2dp_cache_status = APP_AUDIO_CACHE_QTY; + app_audio_mempool_init(); + app_audio_mempool_get_buff(&buff_capture, BT_AUDIO_FACTORMODE_BUFF_SIZE); + app_audio_mempool_get_buff(&buff_play, BT_AUDIO_FACTORMODE_BUFF_SIZE * 2); + app_audio_mempool_get_buff((uint8_t **)&app_audioloop_play_cache, + BT_AUDIO_FACTORMODE_BUFF_SIZE * 2 / 2 / 2); + app_audio_mempool_get_buff(&buff_loop, BT_AUDIO_FACTORMODE_BUFF_SIZE << 2); + app_audio_pcmbuff_init(buff_loop, BT_AUDIO_FACTORMODE_BUFF_SIZE << 2); + memset(&stream_cfg, 0, sizeof(stream_cfg)); + stream_cfg.bits = AUD_BITS_16; + // stream_cfg.channel_num = AUD_CHANNEL_NUM_1; #ifdef SPEECH_TX_AEC_CODEC_REF - stream_cfg.channel_num = AUD_CHANNEL_NUM_2; + stream_cfg.channel_num = AUD_CHANNEL_NUM_2; #else - stream_cfg.channel_num = AUD_CHANNEL_NUM_1; + stream_cfg.channel_num = AUD_CHANNEL_NUM_1; #endif #if defined(__AUDIO_RESAMPLE__) && defined(SW_CAPTURE_RESAMPLE) - stream_cfg.sample_rate = AUD_SAMPRATE_8463; + stream_cfg.sample_rate = AUD_SAMPRATE_8463; #else - stream_cfg.sample_rate = AUD_SAMPRATE_8000; + stream_cfg.sample_rate = AUD_SAMPRATE_8000; #endif -#if FPGA==0 - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; +#if FPGA == 0 + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; #else - stream_cfg.device = AUD_STREAM_USE_EXT_CODEC; + stream_cfg.device = AUD_STREAM_USE_EXT_CODEC; #endif - stream_cfg.vol = TGT_VOLUME_LEVEL_15; - stream_cfg.io_path = AUD_INPUT_PATH_MAINMIC; - stream_cfg.handler = app_factorymode_data_come; + stream_cfg.vol = TGT_VOLUME_LEVEL_15; + stream_cfg.io_path = AUD_INPUT_PATH_MAINMIC; + stream_cfg.handler = app_factorymode_data_come; - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(buff_capture); - stream_cfg.data_size = BT_AUDIO_FACTORMODE_BUFF_SIZE; - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); + stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(buff_capture); + stream_cfg.data_size = BT_AUDIO_FACTORMODE_BUFF_SIZE; + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); - stream_cfg.channel_num = AUD_CHANNEL_NUM_2; - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; - stream_cfg.handler = app_factorymode_more_data; + stream_cfg.channel_num = AUD_CHANNEL_NUM_2; + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; + stream_cfg.handler = app_factorymode_more_data; - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(buff_play); - stream_cfg.data_size = BT_AUDIO_FACTORMODE_BUFF_SIZE*2; - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); + stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(buff_play); + stream_cfg.data_size = BT_AUDIO_FACTORMODE_BUFF_SIZE * 2; + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - APP_FACTORY_TRACE(0,"app_factorymode_audioloop on"); - } else { - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - APP_FACTORY_TRACE(0,"app_factorymode_audioloop off"); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + APP_FACTORY_TRACE(0, "app_factorymode_audioloop on"); + } else { + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + APP_FACTORY_TRACE(0, "app_factorymode_audioloop off"); - app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_32K); - } + app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_32K); + } - isRun=on; - return 0; + isRun = on; + return 0; } -int app_factorymode_output_pcmpatten(audio_test_pcmpatten_t *pcmpatten, uint8_t *buf, uint32_t len) -{ - uint32_t remain_size = len; - uint32_t curr_size = 0; +int app_factorymode_output_pcmpatten(audio_test_pcmpatten_t *pcmpatten, + uint8_t *buf, uint32_t len) { + uint32_t remain_size = len; + uint32_t curr_size = 0; - if (remain_size > pcmpatten->len) - { - do{ - if (pcmpatten->cuur_buf_pos) - { - curr_size = pcmpatten->len-pcmpatten->cuur_buf_pos; - memcpy(buf,&(pcmpatten->buf[pcmpatten->cuur_buf_pos/2]), curr_size); - remain_size -= curr_size; - pcmpatten->cuur_buf_pos = 0; - } - else if (remain_size>pcmpatten->len) - { - memcpy(buf+curr_size, pcmpatten->buf, pcmpatten->len); - curr_size += pcmpatten->len; - remain_size -= pcmpatten->len; - } - else - { - memcpy(buf+curr_size,pcmpatten->buf, remain_size); - pcmpatten->cuur_buf_pos = remain_size; - remain_size = 0; - } - }while(remain_size); + if (remain_size > pcmpatten->len) { + do { + if (pcmpatten->cuur_buf_pos) { + curr_size = pcmpatten->len - pcmpatten->cuur_buf_pos; + memcpy(buf, &(pcmpatten->buf[pcmpatten->cuur_buf_pos / 2]), curr_size); + remain_size -= curr_size; + pcmpatten->cuur_buf_pos = 0; + } else if (remain_size > pcmpatten->len) { + memcpy(buf + curr_size, pcmpatten->buf, pcmpatten->len); + curr_size += pcmpatten->len; + remain_size -= pcmpatten->len; + } else { + memcpy(buf + curr_size, pcmpatten->buf, remain_size); + pcmpatten->cuur_buf_pos = remain_size; + remain_size = 0; + } + } while (remain_size); + } else { + if ((pcmpatten->len - pcmpatten->cuur_buf_pos) >= len) { + memcpy(buf, &(pcmpatten->buf[pcmpatten->cuur_buf_pos / 2]), len); + pcmpatten->cuur_buf_pos += len; + } else { + curr_size = pcmpatten->len - pcmpatten->cuur_buf_pos; + memcpy(buf, &(pcmpatten->buf[pcmpatten->cuur_buf_pos / 2]), curr_size); + pcmpatten->cuur_buf_pos = len - curr_size; + memcpy(buf + curr_size, pcmpatten->buf, pcmpatten->cuur_buf_pos); } - else - { - if ((pcmpatten->len - pcmpatten->cuur_buf_pos) >= len) - { - memcpy(buf, &(pcmpatten->buf[pcmpatten->cuur_buf_pos/2]),len); - pcmpatten->cuur_buf_pos += len; - } - else - { - curr_size = pcmpatten->len-pcmpatten->cuur_buf_pos; - memcpy(buf, &(pcmpatten->buf[pcmpatten->cuur_buf_pos/2]),curr_size); - pcmpatten->cuur_buf_pos = len - curr_size; - memcpy(buf+curr_size, pcmpatten->buf, pcmpatten->cuur_buf_pos); - } - } - - return 0; + } + + return 0; } #include "fft128dot.h" @@ -185,111 +173,118 @@ int app_factorymode_output_pcmpatten(audio_test_pcmpatten_t *pcmpatten, uint8_t #define N 64 #define NFFT 128 -struct mic_st_t{ - FftTwiddle_t w[N]; - FftTwiddle_t w128[N*2]; - FftData_t x[N*2]; - FftData_t data_odd[N]; - FftData_t data_even[N]; - FftData_t data_odd_d[N]; - FftData_t data_even_d[N]; - FftData_t data[N*2]; - signed long out[N]; +struct mic_st_t { + FftTwiddle_t w[N]; + FftTwiddle_t w128[N * 2]; + FftData_t x[N * 2]; + FftData_t data_odd[N]; + FftData_t data_even[N]; + FftData_t data_odd_d[N]; + FftData_t data_even_d[N]; + FftData_t data[N * 2]; + signed long out[N]; }; -int app_factorymode_mic_cancellation_run(void * mic_st, signed short *inbuf, int sample) -{ - struct mic_st_t *st = (struct mic_st_t *)mic_st; - int i,k,jj,ii; - //int dataWidth = 16; // input word format is 16 bit twos complement fractional format 1.15 - int twiddleWidth = 16; // input word format is 16 bit twos complement fractional format 2.14 - FftMode_t ifft = FFT_MODE; +int app_factorymode_mic_cancellation_run(void *mic_st, signed short *inbuf, + int sample) { + struct mic_st_t *st = (struct mic_st_t *)mic_st; + int i, k, jj, ii; + // int dataWidth = 16; // input word format is 16 bit twos complement + // fractional format 1.15 + int twiddleWidth = + 16; // input word format is 16 bit twos complement fractional format 2.14 + FftMode_t ifft = FFT_MODE; - make_symmetric_twiddles(st->w,N,twiddleWidth); - make_symmetric_twiddles(st->w128,N*2,twiddleWidth); - // input data - for (i=0; ix[i].re = inbuf[i]; - st->x[i].im = 0; + make_symmetric_twiddles(st->w, N, twiddleWidth); + make_symmetric_twiddles(st->w128, N * 2, twiddleWidth); + // input data + for (i = 0; i < sample; i++) { + st->x[i].re = inbuf[i]; + st->x[i].im = 0; + } + + for (ii = 0; ii < 1; ii++) { + k = 0; + for (jj = 0; jj < N * 2; jj += 2) { + FftData_t tmp; + + tmp.re = st->x[jj].re; + tmp.im = st->x[jj].im; + + st->data_even[k].re = + tmp.re; //(int) (double(tmp.re)*double(1 << FFTR4_INPUT_FORMAT_Y)) ; + st->data_even[k].im = + tmp.im; //(int) (double(tmp.im)*double(1 << FFTR4_INPUT_FORMAT_Y)) ; + tmp.re = st->x[jj + 1].re; + tmp.im = st->x[jj + 1].im; + st->data_odd[k].re = + tmp.re; //(int) (double(tmp.re)*double(1 << FFTR4_INPUT_FORMAT_Y)) ; + st->data_odd[k].im = + tmp.im; //(int) (double(tmp.im)*double(1 << FFTR4_INPUT_FORMAT_Y)) ; + k++; } - for(ii = 0; ii < 1; ii++) - { - k = 0; - for (jj = 0; jj < N*2; jj+=2) - { - FftData_t tmp; + fftr4(NFFT / 2, st->data_even, st->w, FFTR4_TWIDDLE_WIDTH, FFTR4_DATA_WIDTH, + ifft); + fftr4(NFFT / 2, st->data_odd, st->w, FFTR4_TWIDDLE_WIDTH, FFTR4_DATA_WIDTH, + ifft); - tmp.re = st->x[jj].re; - tmp.im = st->x[jj].im; + for (jj = 0; jj < NFFT / 2; jj++) { - st->data_even[k].re = tmp.re;//(int) (double(tmp.re)*double(1 << FFTR4_INPUT_FORMAT_Y)) ; - st->data_even[k].im = tmp.im;//(int) (double(tmp.im)*double(1 << FFTR4_INPUT_FORMAT_Y)) ; - tmp.re = st->x[jj+1].re; - tmp.im = st->x[jj+1].im; - st->data_odd[k].re = tmp.re;//(int) (double(tmp.re)*double(1 << FFTR4_INPUT_FORMAT_Y)) ; - st->data_odd[k].im = tmp.im;//(int) (double(tmp.im)*double(1 << FFTR4_INPUT_FORMAT_Y)) ; - k++; - } - - fftr4(NFFT/2, st->data_even, st->w, FFTR4_TWIDDLE_WIDTH, FFTR4_DATA_WIDTH, ifft); - fftr4(NFFT/2, st->data_odd, st->w, FFTR4_TWIDDLE_WIDTH, FFTR4_DATA_WIDTH, ifft); - - for (jj = 0; jj < NFFT/2; jj++) - { - - int idx = dibit_reverse_int(jj, NFFT/2); - st->data_even_d[jj].re = st->data_even[idx].re; - st->data_even_d[jj].im = st->data_even[idx].im; - st->data_odd_d[jj].re = st->data_odd[idx].re; - st->data_odd_d[jj].im = st->data_odd[idx].im; - } - for (jj=0;jjdata_odd_d[jj].re) * st->w128[jj].re - (long long)(st->data_odd_d[jj].im) * st->w128[jj].im; - mbi = (long long)(st->data_odd_d[jj].im) * st->w128[jj].re + (long long)(st->data_odd_d[jj].re) * st->w128[jj].im; - ta.re = int(mbr>>(FFTR4_TWIDDLE_WIDTH-2)); - ta.im = int(mbi>>(FFTR4_TWIDDLE_WIDTH-2)); - st->data[jj].re = (st->data_even_d[jj].re + ta.re)/2; - st->data[jj].im = (st->data_even_d[jj].im + ta.im)/2; - //data[jj] = sat(data[jj],FFTR4_DATA_WIDTH); - st->data[jj+NFFT/2].re = (st->data_even_d[jj].re - ta.re)/2; - st->data[jj+NFFT/2].im = (st->data_even_d[jj].im - ta.im)/2; - //data[jj+NFFT/2] = sat(data[jj+NFFT/2],FFTR4_DATA_WIDTH); - - a = st->data[jj].re;///double(1 << FFTR4_OUTPUT_FORMAT_Y);// * double(1 << FFTR4_SCALE); - tmp.re = (int)a; - a = st->data[jj].im;///double(1 << FFTR4_OUTPUT_FORMAT_Y);// * double(1 << FFTR4_SCALE); - tmp.im = (int)a; - st->x[ii*NFFT+jj].re = (int) tmp.re; - st->x[ii*NFFT+jj].im = (int) tmp.im; - a = st->data[jj+NFFT/2].re;///double(1 << FFTR4_OUTPUT_FORMAT_Y);// * double(1 << FFTR4_SCALE); - tmp.re = (int)a; - a = st->data[jj+NFFT/2].im;///double(1 << FFTR4_OUTPUT_FORMAT_Y);// * double(1 << FFTR4_SCALE); - tmp.im = (int)a; - st->x[ii*NFFT+jj+NFFT/2].re = (int) tmp.re; - st->x[ii*NFFT+jj+NFFT/2].im = (int) tmp.im; - } + int idx = dibit_reverse_int(jj, NFFT / 2); + st->data_even_d[jj].re = st->data_even[idx].re; + st->data_even_d[jj].im = st->data_even[idx].im; + st->data_odd_d[jj].re = st->data_odd[idx].re; + st->data_odd_d[jj].im = st->data_odd[idx].im; } + for (jj = 0; jj < NFFT / 2; jj++) { + long long mbr, mbi; + FftData_t ta; + FftData_t tmp; + double a; + mbr = (long long)(st->data_odd_d[jj].re) * st->w128[jj].re - + (long long)(st->data_odd_d[jj].im) * st->w128[jj].im; + mbi = (long long)(st->data_odd_d[jj].im) * st->w128[jj].re + + (long long)(st->data_odd_d[jj].re) * st->w128[jj].im; + ta.re = int(mbr >> (FFTR4_TWIDDLE_WIDTH - 2)); + ta.im = int(mbi >> (FFTR4_TWIDDLE_WIDTH - 2)); + st->data[jj].re = (st->data_even_d[jj].re + ta.re) / 2; + st->data[jj].im = (st->data_even_d[jj].im + ta.im) / 2; + // data[jj] = sat(data[jj],FFTR4_DATA_WIDTH); + st->data[jj + NFFT / 2].re = (st->data_even_d[jj].re - ta.re) / 2; + st->data[jj + NFFT / 2].im = (st->data_even_d[jj].im - ta.im) / 2; + // data[jj+NFFT/2] = sat(data[jj+NFFT/2],FFTR4_DATA_WIDTH); - for (i=0; iout[i] = st->x[i].re * st->x[i].re + st->x[i].im * st->x[i].im; + a = st->data[jj].re; /// double(1 << FFTR4_OUTPUT_FORMAT_Y);// * double(1 + /// << FFTR4_SCALE); + tmp.re = (int)a; + a = st->data[jj].im; /// double(1 << FFTR4_OUTPUT_FORMAT_Y);// * double(1 + /// << FFTR4_SCALE); + tmp.im = (int)a; + st->x[ii * NFFT + jj].re = (int)tmp.re; + st->x[ii * NFFT + jj].im = (int)tmp.im; + a = st->data[jj + NFFT / 2].re; /// double(1 << FFTR4_OUTPUT_FORMAT_Y);// + /// * double(1 << FFTR4_SCALE); + tmp.re = (int)a; + a = st->data[jj + NFFT / 2].im; /// double(1 << FFTR4_OUTPUT_FORMAT_Y);// + /// * double(1 << FFTR4_SCALE); + tmp.im = (int)a; + st->x[ii * NFFT + jj + NFFT / 2].re = (int)tmp.re; + st->x[ii * NFFT + jj + NFFT / 2].im = (int)tmp.im; } + } - return 0; + for (i = 0; i < N; i++) { + st->out[i] = st->x[i].re * st->x[i].re + st->x[i].im * st->x[i].im; + } + return 0; } -void *app_factorymode_mic_cancellation_init(void* (* alloc_ext)(int)) -{ - struct mic_st_t *mic_st; - mic_st = (struct mic_st_t *)alloc_ext(sizeof(struct mic_st_t)); - return (void *)mic_st; +void *app_factorymode_mic_cancellation_init(void *(*alloc_ext)(int)) { + struct mic_st_t *mic_st; + mic_st = (struct mic_st_t *)alloc_ext(sizeof(struct mic_st_t)); + return (void *)mic_st; } #endif - diff --git a/apps/factory/app_factory_bt.cpp b/apps/factory/app_factory_bt.cpp index 9f2dc20..c031afc 100644 --- a/apps/factory/app_factory_bt.cpp +++ b/apps/factory/app_factory_bt.cpp @@ -13,128 +13,120 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "cmsis_os.h" -#include "hal_trace.h" -#include "hal_sleep.h" -#include "bt_drv_interface.h" -#include "intersyshci.h" -#include "apps.h" -#include "app_factory.h" #include "app_factory_bt.h" +#include "app_battery.h" +#include "app_factory.h" #include "app_utils.h" +#include "apps.h" #include "bluetooth.h" +#include "bt_drv_interface.h" +#include "bt_drv_reg_op.h" +#include "cmsis_os.h" +#include "conmgr_api.h" +#include "hal_bootmode.h" +#include "hal_chipid.h" +#include "hal_sleep.h" +#include "hal_trace.h" +#include "intersyshci.h" +#include "me_api.h" #include "nvrecord.h" #include "nvrecord_dev.h" #include "pmu.h" #include "tgt_hardware.h" -#include "app_battery.h" -#include "bt_drv_reg_op.h" -#include "conmgr_api.h" -#include "me_api.h" -#include "hal_bootmode.h" -#include "hal_chipid.h" - -#define APP_FACT_CPU_WAKE_LOCK HAL_CPU_WAKE_LOCK_USER_3 +#define APP_FACT_CPU_WAKE_LOCK HAL_CPU_WAKE_LOCK_USER_3 #ifdef __FACTORY_MODE_SUPPORT__ -static uint8_t inquiry_buff[] = {0x01, 0x72, 0x77, 0xb0, 0x18, 0x57, 0x60,\ - 0x01, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00}; - +static uint8_t inquiry_buff[] = {0x01, 0x72, 0x77, 0xb0, 0x18, 0x57, 0x60, 0x01, + 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00}; static btif_cmgr_handler_t *app_factorymode_cmgrHandler; - static void bt_error_check_timer_handler(void const *param); osTimerDef(bt_error_check_timer, bt_error_check_timer_handler); static osTimerId bt_error_check_timer_id = NULL; -uint8_t test_mode_type=0; -static void bt_error_check_timer_handler(void const *param) -{ - //dump rssi - bt_drv_rssi_dump_handler(); - //check BT core status - if(bt_drv_error_check_handler()) - { - if(test_mode_type==1) - { - hal_sw_bootmode_set(HAL_SW_BOOTMODE_TEST_MODE|HAL_SW_BOOTMODE_TEST_SIGNALINGMODE); - } - else if(test_mode_type==2) - { - hal_sw_bootmode_set(HAL_SW_BOOTMODE_TEST_MODE|HAL_SW_BOOTMODE_TEST_NOSIGNALINGMODE); - } - hal_cmu_sys_reboot(); +uint8_t test_mode_type = 0; +static void bt_error_check_timer_handler(void const *param) { + // dump rssi + bt_drv_rssi_dump_handler(); + // check BT core status + if (bt_drv_error_check_handler()) { + if (test_mode_type == 1) { + hal_sw_bootmode_set(HAL_SW_BOOTMODE_TEST_MODE | + HAL_SW_BOOTMODE_TEST_SIGNALINGMODE); + } else if (test_mode_type == 2) { + hal_sw_bootmode_set(HAL_SW_BOOTMODE_TEST_MODE | + HAL_SW_BOOTMODE_TEST_NOSIGNALINGMODE); } + hal_cmu_sys_reboot(); + } } -static void app_factorymode_bt_inquiry_buff_update(void) -{ - bt_bdaddr_t flsh_dongle_addr; - int ret = -1; +static void app_factorymode_bt_inquiry_buff_update(void) { + bt_bdaddr_t flsh_dongle_addr; + int ret = -1; - ret = nvrec_dev_get_dongleaddr(&flsh_dongle_addr); - if(0 == ret) { - memcpy((void *)&inquiry_buff[1],(void *)flsh_dongle_addr.address,BTIF_BD_ADDR_SIZE); - DUMP8("0x%02x ", &inquiry_buff[2], BTIF_BD_ADDR_SIZE); - } + ret = nvrec_dev_get_dongleaddr(&flsh_dongle_addr); + if (0 == ret) { + memcpy((void *)&inquiry_buff[1], (void *)flsh_dongle_addr.address, + BTIF_BD_ADDR_SIZE); + DUMP8("0x%02x ", &inquiry_buff[2], BTIF_BD_ADDR_SIZE); + } } static void app_factorymode_CmgrCallback(btif_cmgr_handler_t *cHandler, - cmgr_event_t Event, - bt_status_t Status) -{ - APP_FACTORY_TRACE(4,"%s cHandler:%p Event:%d status:%d", __func__, cHandler, Event, Status); - if (Event == BTIF_CMEVENT_DATA_LINK_CON_CNF){ - if (Status == BT_STS_SUCCESS){ - APP_FACTORY_TRACE(0,"connect ok"); - app_factorymode_result_set(true); - btif_cmgr_remove_data_link(cHandler); + cmgr_event_t Event, + bt_status_t Status) { + APP_FACTORY_TRACE(4, "%s cHandler:%p Event:%d status:%d", __func__, cHandler, + Event, Status); + if (Event == BTIF_CMEVENT_DATA_LINK_CON_CNF) { + if (Status == BT_STS_SUCCESS) { + APP_FACTORY_TRACE(0, "connect ok"); + app_factorymode_result_set(true); + btif_cmgr_remove_data_link(cHandler); - }else{ - APP_FACTORY_TRACE(0,"connect failed"); - app_factorymode_result_set(false); - } + } else { + APP_FACTORY_TRACE(0, "connect failed"); + app_factorymode_result_set(false); } + } - if (Event == BTIF_CMEVENT_DATA_LINK_DIS){ - if (Status == BT_STS_SUCCESS){ - APP_FACTORY_TRACE(0,"disconnect ok"); - }else{ - APP_FACTORY_TRACE(0,"disconnect failed"); - } + if (Event == BTIF_CMEVENT_DATA_LINK_DIS) { + if (Status == BT_STS_SUCCESS) { + APP_FACTORY_TRACE(0, "disconnect ok"); + } else { + APP_FACTORY_TRACE(0, "disconnect failed"); } + } } -static void app_factorymode_bt_InquiryResult_add(void) -{ - U8 len = 15; - bool rssi = false, extended = false; - U8* parm = (U8*)inquiry_buff; +static void app_factorymode_bt_InquiryResult_add(void) { + U8 len = 15; + bool rssi = false, extended = false; + U8 *parm = (U8 *)inquiry_buff; - /* Found one or more devices. Report to clients */ - APP_FACTORY_TRACE(4,"%s len:%d rssi:%d extended:%d", __func__, len, rssi, extended); - DUMP8("0x%02x ", parm, len); - btif_me_inquiry_result_setup(parm, rssi, extended); + /* Found one or more devices. Report to clients */ + APP_FACTORY_TRACE(4, "%s len:%d rssi:%d extended:%d", __func__, len, rssi, + extended); + DUMP8("0x%02x ", parm, len); + btif_me_inquiry_result_setup(parm, rssi, extended); } -void app_factorymode_bt_create_connect(void) -{ - bt_status_t status; - bt_bdaddr_t *bdAddr = (bt_bdaddr_t *)(inquiry_buff+1); +void app_factorymode_bt_create_connect(void) { + bt_status_t status; + bt_bdaddr_t *bdAddr = (bt_bdaddr_t *)(inquiry_buff + 1); - status = btif_cmgr_create_data_link(app_factorymode_cmgrHandler, bdAddr); - APP_FACTORY_TRACE(2,"%s:%d", __func__, status); + status = btif_cmgr_create_data_link(app_factorymode_cmgrHandler, bdAddr); + APP_FACTORY_TRACE(2, "%s:%d", __func__, status); } -void app_factorymode_bt_init_connect(void) -{ - app_factorymode_cmgrHandler = btif_cmgr_handler_create(); +void app_factorymode_bt_init_connect(void) { + app_factorymode_cmgrHandler = btif_cmgr_handler_create(); - btif_cmgr_register_handler(app_factorymode_cmgrHandler, - app_factorymode_CmgrCallback); - app_factorymode_bt_inquiry_buff_update(); - app_factorymode_bt_InquiryResult_add(); + btif_cmgr_register_handler(app_factorymode_cmgrHandler, + app_factorymode_CmgrCallback); + app_factorymode_bt_inquiry_buff_update(); + app_factorymode_bt_InquiryResult_add(); } extern osTimerId app_bt_accessmode_timer; @@ -145,187 +137,187 @@ extern osTimerId app_bt_accessmode_timer; #define XTAL_FCAP_RANGE (0xFF) #endif -void app_factorymode_bt_xtalrangetest(APP_KEY_STATUS *status, void *param) -{ - dev_addr_name devinfo; - uint32_t fcap = 0; - APP_FACTORY_TRACE(1,"%s",__func__); +void app_factorymode_bt_xtalrangetest(APP_KEY_STATUS *status, void *param) { + dev_addr_name devinfo; + uint32_t fcap = 0; + APP_FACTORY_TRACE(1, "%s", __func__); #ifdef __WATCHER_DOG_RESET__ - app_wdt_close(); + app_wdt_close(); #endif - hal_cpu_wake_lock(APP_FACT_CPU_WAKE_LOCK); - app_stop_10_second_timer(APP_PAIR_TIMER_ID); - app_stop_10_second_timer(APP_POWEROFF_TIMER_ID); - if (app_bt_accessmode_timer){ - osTimerStop(app_bt_accessmode_timer); - } - if (!bt_error_check_timer_id){ - bt_error_check_timer_id = osTimerCreate(osTimer(bt_error_check_timer), osTimerPeriodic, NULL); - } - if (bt_error_check_timer_id != NULL) { - osTimerStart(bt_error_check_timer_id, 1000); - } - test_mode_type = 1; - app_status_indication_set(APP_STATUS_INDICATION_TESTMODE); - pmu_sleep_en(0); - BESHCI_Close(); - btdrv_hciopen(); - btdrv_hci_reset(); + hal_cpu_wake_lock(APP_FACT_CPU_WAKE_LOCK); + app_stop_10_second_timer(APP_PAIR_TIMER_ID); + app_stop_10_second_timer(APP_POWEROFF_TIMER_ID); + if (app_bt_accessmode_timer) { + osTimerStop(app_bt_accessmode_timer); + } + if (!bt_error_check_timer_id) { + bt_error_check_timer_id = + osTimerCreate(osTimer(bt_error_check_timer), osTimerPeriodic, NULL); + } + if (bt_error_check_timer_id != NULL) { + osTimerStart(bt_error_check_timer_id, 1000); + } + test_mode_type = 1; + app_status_indication_set(APP_STATUS_INDICATION_TESTMODE); + pmu_sleep_en(0); + BESHCI_Close(); + btdrv_hciopen(); + btdrv_hci_reset(); #ifndef BT_50_FUNCTION - btdrv_sleep_config(0); - osDelay(2000); - btdrv_ins_patch_test_init(); - btdrv_feature_default(); + btdrv_sleep_config(0); + osDelay(2000); + btdrv_ins_patch_test_init(); + btdrv_feature_default(); #endif - devinfo.btd_addr = bt_addr; - devinfo.ble_addr = ble_addr; - devinfo.localname = BT_LOCAL_NAME; - nvrec_dev_localname_addr_init(&devinfo); - btdrv_write_localinfo((char *)devinfo.localname, strlen(devinfo.localname) + 1, devinfo.btd_addr); + devinfo.btd_addr = bt_addr; + devinfo.ble_addr = ble_addr; + devinfo.localname = BT_LOCAL_NAME; + nvrec_dev_localname_addr_init(&devinfo); + btdrv_write_localinfo((char *)devinfo.localname, + strlen(devinfo.localname) + 1, devinfo.btd_addr); - btdrv_vco_test_start(78); - while(1){ - btdrv_rf_set_xtal_fcap(fcap%XTAL_FCAP_RANGE, 1); - osDelay(300); - TRACE(2,"xtal tune:%d", fcap%XTAL_FCAP_RANGE); - fcap++; - } + btdrv_vco_test_start(78); + while (1) { + btdrv_rf_set_xtal_fcap(fcap % XTAL_FCAP_RANGE, 1); + osDelay(300); + TRACE(2, "xtal tune:%d", fcap % XTAL_FCAP_RANGE); + fcap++; + } } -void app_factorymode_bt_signalingtest(APP_KEY_STATUS *status, void *param) -{ - dev_addr_name devinfo; - APP_FACTORY_TRACE(1,"%s",__func__); +void app_factorymode_bt_signalingtest(APP_KEY_STATUS *status, void *param) { + dev_addr_name devinfo; + APP_FACTORY_TRACE(1, "%s", __func__); #ifdef __WATCHER_DOG_RESET__ - app_wdt_close(); + app_wdt_close(); #endif - hal_cpu_wake_lock(APP_FACT_CPU_WAKE_LOCK); - app_stop_10_second_timer(APP_PAIR_TIMER_ID); - app_stop_10_second_timer(APP_POWEROFF_TIMER_ID); - if (app_bt_accessmode_timer){ - osTimerStop(app_bt_accessmode_timer); - } - if (!bt_error_check_timer_id){ - bt_error_check_timer_id = osTimerCreate(osTimer(bt_error_check_timer), osTimerPeriodic, NULL); - } - if (bt_error_check_timer_id != NULL) { - osTimerStart(bt_error_check_timer_id, 1000); - } - test_mode_type = 1; - app_status_indication_set(APP_STATUS_INDICATION_TESTMODE); - pmu_sleep_en(0); - BESHCI_Close(); - btdrv_hciopen(); - btdrv_ins_patch_test_init(); - btdrv_hci_reset(); + hal_cpu_wake_lock(APP_FACT_CPU_WAKE_LOCK); + app_stop_10_second_timer(APP_PAIR_TIMER_ID); + app_stop_10_second_timer(APP_POWEROFF_TIMER_ID); + if (app_bt_accessmode_timer) { + osTimerStop(app_bt_accessmode_timer); + } + if (!bt_error_check_timer_id) { + bt_error_check_timer_id = + osTimerCreate(osTimer(bt_error_check_timer), osTimerPeriodic, NULL); + } + if (bt_error_check_timer_id != NULL) { + osTimerStart(bt_error_check_timer_id, 1000); + } + test_mode_type = 1; + app_status_indication_set(APP_STATUS_INDICATION_TESTMODE); + pmu_sleep_en(0); + BESHCI_Close(); + btdrv_hciopen(); + btdrv_ins_patch_test_init(); + btdrv_hci_reset(); #ifndef BT_50_FUNCTION - btdrv_sleep_config(0); - osDelay(2000); - btdrv_testmode_start(); - btdrv_feature_default(); + btdrv_sleep_config(0); + osDelay(2000); + btdrv_testmode_start(); + btdrv_feature_default(); #endif - devinfo.btd_addr = bt_addr; - devinfo.ble_addr = ble_addr; - devinfo.localname = BT_LOCAL_NAME; - devinfo.ble_name= BT_LOCAL_NAME; - nvrec_dev_localname_addr_init(&devinfo); + devinfo.btd_addr = bt_addr; + devinfo.ble_addr = ble_addr; + devinfo.localname = BT_LOCAL_NAME; + devinfo.ble_name = BT_LOCAL_NAME; + nvrec_dev_localname_addr_init(&devinfo); #ifdef __IBRT_IBRT_TESTMODE__ - uint8_t ibrt_address[6] = {0x11,0x22,0x33,0x44,0x55,0x66}; - memcpy(bt_addr,ibrt_address,6); - memcpy(devinfo.btd_addr,ibrt_address,6); + uint8_t ibrt_address[6] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66}; + memcpy(bt_addr, ibrt_address, 6); + memcpy(devinfo.btd_addr, ibrt_address, 6); #endif - btdrv_write_localinfo((char *)devinfo.localname, strlen(devinfo.localname) + 1, devinfo.btd_addr); - bt_drv_extra_config_after_init(); - btdrv_enable_dut(); + btdrv_write_localinfo((char *)devinfo.localname, + strlen(devinfo.localname) + 1, devinfo.btd_addr); + bt_drv_extra_config_after_init(); + btdrv_enable_dut(); #ifdef __IBRT_IBRT_TESTMODE__ - btdrv_enable_ibrt_test(); + btdrv_enable_ibrt_test(); #endif } int app_battery_stop(void); -void app_factorymode_bt_nosignalingtest(APP_KEY_STATUS *status, void *param) -{ - dev_addr_name devinfo; - APP_FACTORY_TRACE(1,"%s",__func__); +void app_factorymode_bt_nosignalingtest(APP_KEY_STATUS *status, void *param) { + dev_addr_name devinfo; + APP_FACTORY_TRACE(1, "%s", __func__); #ifdef __WATCHER_DOG_RESET__ - app_wdt_close(); + app_wdt_close(); #endif - hal_cpu_wake_lock(APP_FACT_CPU_WAKE_LOCK); - app_stop_10_second_timer(APP_PAIR_TIMER_ID); - app_stop_10_second_timer(APP_POWEROFF_TIMER_ID); - app_status_indication_set(APP_STATUS_INDICATION_TESTMODE1); - osTimerStop(app_bt_accessmode_timer); - if (!bt_error_check_timer_id){ - bt_error_check_timer_id = osTimerCreate(osTimer(bt_error_check_timer), osTimerPeriodic, NULL); - } - if (bt_error_check_timer_id != NULL) { - osTimerStart(bt_error_check_timer_id, 1000); - } - test_mode_type = 2; - app_battery_stop(); - pmu_sleep_en(0); - BESHCI_Close(); - btdrv_hciopen(); - btdrv_ins_patch_test_init(); - bt_drv_reg_op_key_gen_after_reset(false); - btdrv_hci_reset(); + hal_cpu_wake_lock(APP_FACT_CPU_WAKE_LOCK); + app_stop_10_second_timer(APP_PAIR_TIMER_ID); + app_stop_10_second_timer(APP_POWEROFF_TIMER_ID); + app_status_indication_set(APP_STATUS_INDICATION_TESTMODE1); + osTimerStop(app_bt_accessmode_timer); + if (!bt_error_check_timer_id) { + bt_error_check_timer_id = + osTimerCreate(osTimer(bt_error_check_timer), osTimerPeriodic, NULL); + } + if (bt_error_check_timer_id != NULL) { + osTimerStart(bt_error_check_timer_id, 1000); + } + test_mode_type = 2; + app_battery_stop(); + pmu_sleep_en(0); + BESHCI_Close(); + btdrv_hciopen(); + btdrv_ins_patch_test_init(); + bt_drv_reg_op_key_gen_after_reset(false); + btdrv_hci_reset(); #ifndef BT_50_FUNCTION - btdrv_sleep_config(0); + btdrv_sleep_config(0); #endif - osDelay(2000); - btdrv_testmode_start(); + osDelay(2000); + btdrv_testmode_start(); #ifndef BT_50_FUNCTION - btdrv_feature_default(); - devinfo.btd_addr = bt_addr; - devinfo.ble_addr = ble_addr; - devinfo.localname = BT_LOCAL_NAME; - devinfo.ble_name= BT_LOCAL_NAME; - nvrec_dev_localname_addr_init(&devinfo); - btdrv_write_localinfo((char *)devinfo.localname, strlen(devinfo.localname) + 1, devinfo.btd_addr); + btdrv_feature_default(); + devinfo.btd_addr = bt_addr; + devinfo.ble_addr = ble_addr; + devinfo.localname = BT_LOCAL_NAME; + devinfo.ble_name = BT_LOCAL_NAME; + nvrec_dev_localname_addr_init(&devinfo); + btdrv_write_localinfo((char *)devinfo.localname, + strlen(devinfo.localname) + 1, devinfo.btd_addr); #endif - bt_drv_extra_config_after_init(); - btdrv_hcioff(); + bt_drv_extra_config_after_init(); + btdrv_hcioff(); #ifdef __BT_DEBUG_TPORTS__ - { - extern void bt_enable_tports(void); - bt_enable_tports(); - //hal_iomux_tportopen(); - } + { + extern void bt_enable_tports(void); + bt_enable_tports(); + // hal_iomux_tportopen(); + } #endif - btdrv_uart_bridge_loop(); + btdrv_uart_bridge_loop(); } -int app_factorymode_bt_xtalcalib_proc(void) -{ - uint32_t capval = 0x80; - int nRet; +int app_factorymode_bt_xtalcalib_proc(void) { + uint32_t capval = 0x80; + int nRet; - APP_FACTORY_TRACE(1,"%s",__func__); - hal_cpu_wake_lock(APP_FACT_CPU_WAKE_LOCK); - APP_FACTORY_TRACE(1,"calib default, capval:%d", capval); - btdrv_hciopen(); - btdrv_hci_reset(); + APP_FACTORY_TRACE(1, "%s", __func__); + hal_cpu_wake_lock(APP_FACT_CPU_WAKE_LOCK); + APP_FACTORY_TRACE(1, "calib default, capval:%d", capval); + btdrv_hciopen(); + btdrv_hci_reset(); #ifndef BT_50_FUNCTION - btdrv_ins_patch_test_init(); + btdrv_ins_patch_test_init(); #endif - btdrv_hcioff(); - capval = 0x80; - bt_drv_calib_open(); - nRet = bt_drv_calib_result_porc(&capval); - bt_drv_calib_close(); - TRACE(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!calib ret:%d, capval:%d", nRet, capval); - if (!nRet) - nvrec_dev_set_xtal_fcap((unsigned int)capval); + btdrv_hcioff(); + capval = 0x80; + bt_drv_calib_open(); + nRet = bt_drv_calib_result_porc(&capval); + bt_drv_calib_close(); + TRACE(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!calib ret:%d, capval:%d", nRet, capval); + if (!nRet) + nvrec_dev_set_xtal_fcap((unsigned int)capval); - return nRet; + return nRet; } -void app_factorymode_bt_xtalcalib(APP_KEY_STATUS *status, void *param) -{ - APP_FACTORY_TRACE(1,"%s",__func__); - app_factorymode_bt_xtalcalib_proc(); +void app_factorymode_bt_xtalcalib(APP_KEY_STATUS *status, void *param) { + APP_FACTORY_TRACE(1, "%s", __func__); + app_factorymode_bt_xtalcalib_proc(); } #endif - diff --git a/apps/factory/app_factory_cdc_comm.c b/apps/factory/app_factory_cdc_comm.c index f67f90d..fe6bba4 100644 --- a/apps/factory/app_factory_cdc_comm.c +++ b/apps/factory/app_factory_cdc_comm.c @@ -1,179 +1,180 @@ #ifdef __USB_COMM__ -#include "stdint.h" -#include "stdbool.h" -#include "plat_types.h" -#include "string.h" -#include "stdio.h" -#include "tool_msg.h" -#include "sys_api_cdc_comm.h" #include "app_factory_cdc_comm.h" +#include "plat_types.h" +#include "stdbool.h" +#include "stdint.h" +#include "stdio.h" +#include "string.h" +#include "sys_api_cdc_comm.h" +#include "tool_msg.h" static enum PARSE_STATE parse_state; static struct message_t recv_msg; -static struct message_t send_msg = { { PREFIX_CHAR, }, }; +static struct message_t send_msg = { + { + PREFIX_CHAR, + }, +}; -static unsigned char check_sum(unsigned char *buf, unsigned char len) -{ - int i; - unsigned char sum = 0; +static unsigned char check_sum(unsigned char *buf, unsigned char len) { + int i; + unsigned char sum = 0; - for (i = 0; i < len; i++) { - sum += buf[i]; - } + for (i = 0; i < len; i++) { + sum += buf[i]; + } - return sum; + return sum; } -int send_reply(const unsigned char *payload, unsigned int len) -{ - int ret = 0; +int send_reply(const unsigned char *payload, unsigned int len) { + int ret = 0; - if (len + 1 > sizeof(send_msg.data)) { - TRACE(1,"Packet length too long: %u", len); - return -1; - } + if (len + 1 > sizeof(send_msg.data)) { + TRACE(1, "Packet length too long: %u", len); + return -1; + } - send_msg.hdr.type = recv_msg.hdr.type; - send_msg.hdr.seq = recv_msg.hdr.seq; - send_msg.hdr.len = len; - memcpy(&send_msg.data[0], payload, len); - send_msg.data[len] = ~check_sum((unsigned char *)&send_msg, MSG_TOTAL_LEN(&send_msg) - 1); + send_msg.hdr.type = recv_msg.hdr.type; + send_msg.hdr.seq = recv_msg.hdr.seq; + send_msg.hdr.len = len; + memcpy(&send_msg.data[0], payload, len); + send_msg.data[len] = + ~check_sum((unsigned char *)&send_msg, MSG_TOTAL_LEN(&send_msg) - 1); - ret = send_data((unsigned char *)&send_msg, MSG_TOTAL_LEN(&send_msg)); + ret = send_data((unsigned char *)&send_msg, MSG_TOTAL_LEN(&send_msg)); - return ret; + return ret; } -static void reset_parse_state(unsigned char **buf, size_t *len) -{ - parse_state = PARSE_HEADER; - memset(&recv_msg.hdr, 0, sizeof(recv_msg.hdr)); +static void reset_parse_state(unsigned char **buf, size_t *len) { + parse_state = PARSE_HEADER; + memset(&recv_msg.hdr, 0, sizeof(recv_msg.hdr)); - *buf = (unsigned char *)&recv_msg.hdr; - *len = sizeof(recv_msg.hdr); + *buf = (unsigned char *)&recv_msg.hdr; + *len = sizeof(recv_msg.hdr); } -static enum ERR_CODE check_msg_hdr(void) -{ - enum ERR_CODE errcode = ERR_NONE; +static enum ERR_CODE check_msg_hdr(void) { + enum ERR_CODE errcode = ERR_NONE; - switch (recv_msg.hdr.type) { - case TYPE_SYS: - if (recv_msg.hdr.len != 1 && recv_msg.hdr.len != 5) { - //TRACE(1,"SYS msg length error: %u", recv_msg.hdr.len); - errcode = ERR_LEN; - } - break; - case TYPE_READ: - if (recv_msg.hdr.len != 4) { - //TRACE(1,"READ msg length error: %u", recv_msg.hdr.len); - errcode = ERR_LEN; - } - break; - case TYPE_WRITE: - if (recv_msg.hdr.len <= 4 || recv_msg.hdr.len > 20) { - //TRACE(1,"WRITE msg length error: %u", recv_msg.hdr.len); - errcode = ERR_LEN; - } - break; - default: - break; + switch (recv_msg.hdr.type) { + case TYPE_SYS: + if (recv_msg.hdr.len != 1 && recv_msg.hdr.len != 5) { + // TRACE(1,"SYS msg length error: %u", recv_msg.hdr.len); + errcode = ERR_LEN; } - - if (errcode == ERR_NONE && recv_msg.hdr.len + 1 > sizeof(recv_msg.data)) { - errcode = ERR_LEN; + break; + case TYPE_READ: + if (recv_msg.hdr.len != 4) { + // TRACE(1,"READ msg length error: %u", recv_msg.hdr.len); + errcode = ERR_LEN; } + break; + case TYPE_WRITE: + if (recv_msg.hdr.len <= 4 || recv_msg.hdr.len > 20) { + // TRACE(1,"WRITE msg length error: %u", recv_msg.hdr.len); + errcode = ERR_LEN; + } + break; + default: + break; + } - return errcode; + if (errcode == ERR_NONE && recv_msg.hdr.len + 1 > sizeof(recv_msg.data)) { + errcode = ERR_LEN; + } + + return errcode; } -static enum ERR_CODE handle_sys_cmd(enum SYS_CMD_TYPE cmd, unsigned char *param, unsigned int len) -{ - unsigned char cret[5]; - unsigned int bootmode; +static enum ERR_CODE handle_sys_cmd(enum SYS_CMD_TYPE cmd, unsigned char *param, + unsigned int len) { + unsigned char cret[5]; + unsigned int bootmode; - cret[0] = ERR_NONE; + cret[0] = ERR_NONE; - if (cmd == SYS_CMD_SET_BOOTMODE || cmd == SYS_CMD_CLR_BOOTMODE) { - if (len != 4) { - TRACE(2,"Invalid SYS CMD len %u for cmd: 0x%x", len, cmd); - return ERR_DATA_LEN; - } - } else { - if (len != 0) { - TRACE(2,"Invalid SYS CMD len %u for cmd: 0x%x", len, cmd); - return ERR_DATA_LEN; - } + if (cmd == SYS_CMD_SET_BOOTMODE || cmd == SYS_CMD_CLR_BOOTMODE) { + if (len != 4) { + TRACE(2, "Invalid SYS CMD len %u for cmd: 0x%x", len, cmd); + return ERR_DATA_LEN; } - - switch (cmd) { - case SYS_CMD_REBOOT: { - TRACE(0,"--- Reboot---"); - send_reply(cret, 1); - system_reboot(); - break; - } - case SYS_CMD_SHUTDOWN: { - TRACE(0,"--- Shutdown ---"); - send_reply(cret, 1); - system_shutdown(); - break; - } - case SYS_CMD_SET_BOOTMODE: { - TRACE(0,"--- Set bootmode ---"); - memcpy(&bootmode, param, 4); - system_set_bootmode(bootmode); - send_reply(cret, 1); - break; - } - case SYS_CMD_CLR_BOOTMODE: { - TRACE(0,"--- Clear bootmode ---"); - memcpy(&bootmode, param, 4); - system_clear_bootmode(bootmode); - send_reply(cret, 1); - break; - } - case SYS_CMD_GET_BOOTMODE: { - TRACE(0,"--- Get bootmode ---"); - bootmode = system_get_bootmode(); - memcpy(&cret[1], &bootmode, 4); - send_reply(cret, 5); - break; - } - default: { - TRACE(1,"Invalid command: 0x%x", recv_msg.data[0]); - return ERR_SYS_CMD; - } + } else { + if (len != 0) { + TRACE(2, "Invalid SYS CMD len %u for cmd: 0x%x", len, cmd); + return ERR_DATA_LEN; } + } - return ERR_NONE; + switch (cmd) { + case SYS_CMD_REBOOT: { + TRACE(0, "--- Reboot---"); + send_reply(cret, 1); + system_reboot(); + break; + } + case SYS_CMD_SHUTDOWN: { + TRACE(0, "--- Shutdown ---"); + send_reply(cret, 1); + system_shutdown(); + break; + } + case SYS_CMD_SET_BOOTMODE: { + TRACE(0, "--- Set bootmode ---"); + memcpy(&bootmode, param, 4); + system_set_bootmode(bootmode); + send_reply(cret, 1); + break; + } + case SYS_CMD_CLR_BOOTMODE: { + TRACE(0, "--- Clear bootmode ---"); + memcpy(&bootmode, param, 4); + system_clear_bootmode(bootmode); + send_reply(cret, 1); + break; + } + case SYS_CMD_GET_BOOTMODE: { + TRACE(0, "--- Get bootmode ---"); + bootmode = system_get_bootmode(); + memcpy(&cret[1], &bootmode, 4); + send_reply(cret, 5); + break; + } + default: { + TRACE(1, "Invalid command: 0x%x", recv_msg.data[0]); + return ERR_SYS_CMD; + } + } + + return ERR_NONE; } -static enum ERR_CODE handle_data(unsigned char **buf, size_t *len, int *extra) -{ - enum ERR_CODE errcode = ERR_NONE; +static enum ERR_CODE handle_data(unsigned char **buf, size_t *len, int *extra) { + enum ERR_CODE errcode = ERR_NONE; #if 0 uint32_t rlen = 0; #endif - *extra = 0; + *extra = 0; - // Checksum - if (check_sum((unsigned char *)&recv_msg, MSG_TOTAL_LEN(&recv_msg)) != 0xFF) { - TRACE(0,"Checksum error"); - return ERR_CHECKSUM; + // Checksum + if (check_sum((unsigned char *)&recv_msg, MSG_TOTAL_LEN(&recv_msg)) != 0xFF) { + TRACE(0, "Checksum error"); + return ERR_CHECKSUM; + } + + switch (recv_msg.hdr.type) { + case TYPE_SYS: { + TRACE_TIME(0, "------ SYS CMD ------"); + errcode = handle_sys_cmd((enum SYS_CMD_TYPE)recv_msg.data[0], + &recv_msg.data[1], recv_msg.hdr.len - 1); + if (errcode != ERR_NONE) { + return errcode; } - - switch (recv_msg.hdr.type) { - case TYPE_SYS: { - TRACE_TIME(0,"------ SYS CMD ------"); - errcode = handle_sys_cmd((enum SYS_CMD_TYPE)recv_msg.data[0], &recv_msg.data[1], recv_msg.hdr.len - 1); - if (errcode != ERR_NONE) { - return errcode; - } - break; - } - case TYPE_READ: { - TRACE_TIME(0,"------ READ CMD ------"); + break; + } + case TYPE_READ: { + TRACE_TIME(0, "------ READ CMD ------"); #if 0 uint32_t addr = (recv_msg.data[0] << 16) | (recv_msg.data[1] << 8) | recv_msg.data[2]; uint8_t data[4] = {0}; @@ -184,10 +185,10 @@ static enum ERR_CODE handle_data(unsigned char **buf, size_t *len, int *extra) send_reply(data, rlen); } #endif - break; - } - case TYPE_WRITE: { - TRACE_TIME(0,"------ WRITE CMD ------"); + break; + } + case TYPE_WRITE: { + TRACE_TIME(0, "------ WRITE CMD ------"); #if 0 uint32_t addr = (recv_msg.data[0] << 16) | (recv_msg.data[1] << 8) | recv_msg.data[2]; uint32_t wdata = (recv_msg.data[3] << 24) | (recv_msg.data[4] << 16) | (recv_msg.data[5] << 8) | recv_msg.data[6]; @@ -198,117 +199,115 @@ static enum ERR_CODE handle_data(unsigned char **buf, size_t *len, int *extra) else send_reply(data, 1); #endif - break; - } + break; + } - default: - break; - } + default: + break; + } - return ERR_NONE; + return ERR_NONE; } -static int parse_packet(unsigned char **buf, size_t *len) -{ - enum ERR_CODE errcode; - int rlen = *len; - unsigned char *data; - int i; - int extra; - unsigned char cret; +static int parse_packet(unsigned char **buf, size_t *len) { + enum ERR_CODE errcode; + int rlen = *len; + unsigned char *data; + int i; + int extra; + unsigned char cret; - switch (parse_state) { - case PARSE_HEADER: - ASSERT(rlen > 0 && rlen <= sizeof(recv_msg.hdr), "Invalid rlen!"); + switch (parse_state) { + case PARSE_HEADER: + ASSERT(rlen > 0 && rlen <= sizeof(recv_msg.hdr), "Invalid rlen!"); - if (recv_msg.hdr.prefix == PREFIX_CHAR) { - errcode = check_msg_hdr(); - if (errcode != ERR_NONE) { - goto _err; - } - parse_state = PARSE_DATA; - *buf = &recv_msg.data[0]; - *len = recv_msg.hdr.len + 1; - } else { - data = (unsigned char *)&recv_msg.hdr.prefix; - for (i = 1; i < rlen; i++) { - if (data[i] == PREFIX_CHAR) { - memmove(&recv_msg.hdr.prefix, &data[i], rlen - i); - break; - } - } - *buf = &data[rlen - i]; - *len = sizeof(recv_msg.hdr) + i - rlen; - } - break; - case PARSE_DATA: - errcode = handle_data(buf, len, &extra); - if (errcode != ERR_NONE) { - goto _err; - } - // Receive next message - reset_parse_state(buf, len); - break; - default: - TRACE(1,"Invalid parse_state: %d", parse_state); - break; + if (recv_msg.hdr.prefix == PREFIX_CHAR) { + errcode = check_msg_hdr(); + if (errcode != ERR_NONE) { + goto _err; + } + parse_state = PARSE_DATA; + *buf = &recv_msg.data[0]; + *len = recv_msg.hdr.len + 1; + } else { + data = (unsigned char *)&recv_msg.hdr.prefix; + for (i = 1; i < rlen; i++) { + if (data[i] == PREFIX_CHAR) { + memmove(&recv_msg.hdr.prefix, &data[i], rlen - i); + break; + } + } + *buf = &data[rlen - i]; + *len = sizeof(recv_msg.hdr) + i - rlen; } + break; + case PARSE_DATA: + errcode = handle_data(buf, len, &extra); + if (errcode != ERR_NONE) { + goto _err; + } + // Receive next message + reset_parse_state(buf, len); + break; + default: + TRACE(1, "Invalid parse_state: %d", parse_state); + break; + } - return 0; + return 0; _err: - cancel_input(); - cret = (unsigned char)errcode; - send_reply(&cret, 1); + cancel_input(); + cret = (unsigned char)errcode; + send_reply(&cret, 1); - return 1; + return 1; } -void comm_loop(void) -{ - int ret; - unsigned char *buf = NULL; - size_t len = 0; - size_t buf_len, rlen; +void comm_loop(void) { + int ret; + unsigned char *buf = NULL; + size_t len = 0; + size_t buf_len, rlen; _sync: - reset_transport(); - reset_parse_state(&buf, &len); + reset_transport(); + reset_parse_state(&buf, &len); - while (1) { - rlen = 0; - if (parse_state == PARSE_HEADER) { - set_recv_timeout(default_recv_timeout_idle); - } else { - set_recv_timeout(default_recv_timeout_short); - } - buf_len = 0; - - ret = recv_data_ex(buf, buf_len, len, &rlen); - if (ret) { - TRACE(1,"Receiving data failed: %d", ret); - goto _err; - } - - if (len != rlen) { - TRACE(2,"Receiving part of the data: expect=%u real=%u", len, rlen); - goto _err; - } - - ret = parse_packet(&buf, &len); - if (ret) { - TRACE(0,"Parsing packet failed"); - goto _err; - } + while (1) { + rlen = 0; + if (parse_state == PARSE_HEADER) { + set_recv_timeout(default_recv_timeout_idle); + } else { + set_recv_timeout(default_recv_timeout_short); } + buf_len = 0; + + ret = recv_data_ex(buf, buf_len, len, &rlen); + if (ret) { + TRACE(1, "Receiving data failed: %d", ret); + goto _err; + } + + if (len != rlen) { + TRACE(2, "Receiving part of the data: expect=%u real=%u", len, rlen); + goto _err; + } + + ret = parse_packet(&buf, &len); + if (ret) { + TRACE(0, "Parsing packet failed"); + goto _err; + } + } _err: - ret = handle_error(); - if (ret == 0) { - TRACE(0,"retry ..."); - goto _sync; - } + ret = handle_error(); + if (ret == 0) { + TRACE(0, "retry ..."); + goto _sync; + } - return; + return; } #endif diff --git a/apps/factory/sys_api_cdc_comm.c b/apps/factory/sys_api_cdc_comm.c index 2ae4a6b..88af8f4 100644 --- a/apps/factory/sys_api_cdc_comm.c +++ b/apps/factory/sys_api_cdc_comm.c @@ -8,10 +8,11 @@ #include "usb_cdc.h" #endif -#define TIMEOUT_INFINITE ((uint32_t)-1) +#define TIMEOUT_INFINITE ((uint32_t)-1) const unsigned int default_recv_timeout_short = MS_TO_TICKS(500); -const unsigned int default_recv_timeout_idle = TIMEOUT_INFINITE; //MS_TO_TICKS(10 * 60 * 1000); +const unsigned int default_recv_timeout_idle = + TIMEOUT_INFINITE; // MS_TO_TICKS(10 * 60 * 1000); const unsigned int default_recv_timeout_4k_data = MS_TO_TICKS(500); const unsigned int default_send_timeout = MS_TO_TICKS(500); @@ -29,201 +30,165 @@ static const struct USB_SERIAL_CFG_T cdc_cfg = { .mode = USB_SERIAL_API_NONBLOCKING, }; -void reset_transport(void) -{ - cancel_xfer = false; +void reset_transport(void) { + cancel_xfer = false; - if (xfer_timer) { - hwtimer_stop(xfer_timer); - } else { - xfer_timer = hwtimer_alloc(NULL, NULL); - } + if (xfer_timer) { + hwtimer_stop(xfer_timer); + } else { + xfer_timer = hwtimer_alloc(NULL, NULL); + } - usb_serial_flush_recv_buffer(); - usb_serial_init_xfer(); - set_recv_timeout(default_recv_timeout_short); - set_send_timeout(default_send_timeout); + usb_serial_flush_recv_buffer(); + usb_serial_init_xfer(); + set_recv_timeout(default_recv_timeout_short); + set_send_timeout(default_send_timeout); } -void set_recv_timeout(unsigned int timeout) -{ - recv_timeout = timeout; +void set_recv_timeout(unsigned int timeout) { recv_timeout = timeout; } + +void set_send_timeout(unsigned int timeout) { send_timeout = timeout; } + +static void usb_send_timeout(void *param) { usb_serial_cancel_send(); } + +static void usb_send_timer_start(void) { + if (send_timeout == TIMEOUT_INFINITE) { + return; + } + + if (xfer_timer) { + hwtimer_update_then_start(xfer_timer, usb_send_timeout, NULL, send_timeout); + } } -void set_send_timeout(unsigned int timeout) -{ - send_timeout = timeout; +static void usb_send_timer_stop(void) { + if (xfer_timer) { + hwtimer_stop(xfer_timer); + } } -static void usb_send_timeout(void *param) -{ - usb_serial_cancel_send(); +static int usb_send_data(const unsigned char *buf, size_t len) { + int ret; + + usb_send_timer_start(); + ret = usb_serial_send(buf, len); + usb_send_timer_stop(); + return ret; } -static void usb_send_timer_start(void) -{ - if (send_timeout == TIMEOUT_INFINITE) { - return; - } - - if (xfer_timer) { - hwtimer_update_then_start(xfer_timer, usb_send_timeout, NULL, send_timeout); - } +int send_data(const unsigned char *buf, size_t len) { + if (cancel_xfer) { + return -1; + } + return usb_send_data(buf, len); } -static void usb_send_timer_stop(void) -{ - if (xfer_timer) { - hwtimer_stop(xfer_timer); - } +static void usb_recv_timeout(void *param) { usb_serial_cancel_recv(); } + +static void usb_recv_timer_start(void) { + if (recv_timeout == TIMEOUT_INFINITE) { + return; + } + + if (xfer_timer) { + hwtimer_update_then_start(xfer_timer, usb_recv_timeout, NULL, recv_timeout); + } } -static int usb_send_data(const unsigned char *buf, size_t len) -{ - int ret; - - usb_send_timer_start(); - ret = usb_serial_send(buf, len); - usb_send_timer_stop(); - return ret; +static void usb_recv_timer_stop(void) { + if (xfer_timer) { + hwtimer_stop(xfer_timer); + } } -int send_data(const unsigned char *buf, size_t len) -{ - if (cancel_xfer) { - return -1; - } - return usb_send_data(buf, len); +static int usb_recv_data(unsigned char *buf, size_t len, size_t *rlen) { + int ret; + + usb_recv_timer_start(); + ret = usb_serial_recv(buf, len); + usb_recv_timer_stop(); + if (ret == 0) { + *rlen = len; + } + return ret; } -static void usb_recv_timeout(void *param) -{ - usb_serial_cancel_recv(); +int recv_data_ex(unsigned char *buf, size_t len, size_t expect, size_t *rlen) { + if (cancel_xfer) { + return -1; + } + return usb_recv_data(buf, expect, rlen); } -static void usb_recv_timer_start(void) -{ - if (recv_timeout == TIMEOUT_INFINITE) { - return; - } +static int usb_handle_error(void) { + int ret; - if (xfer_timer) { - hwtimer_update_then_start(xfer_timer, usb_recv_timeout, NULL, recv_timeout); - } + TRACE(0, "****** Send break ******"); + + // Send break signal, to tell the peer to reset the connection + ret = usb_serial_send_break(); + if (ret) { + TRACE(1, "Sending break failed: %d", ret); + } + return ret; } -static void usb_recv_timer_stop(void) -{ - if (xfer_timer) { - hwtimer_stop(xfer_timer); - } +int handle_error(void) { + int ret = 0; + uint32_t err_time; + + hal_sys_timer_delay(MS_TO_TICKS(50)); + + if (!cancel_xfer) { + ret = usb_handle_error(); + } + + err_time = hal_sys_timer_get(); + if (xfer_err_cnt == 0 || err_time - xfer_err_time > MS_TO_TICKS(5000)) { + xfer_err_cnt = 0; + xfer_err_time = err_time; + } + xfer_err_cnt++; + if (xfer_err_cnt < 3) { + hal_sys_timer_delay(MS_TO_TICKS(100)); + } else if (xfer_err_cnt < 5) { + hal_sys_timer_delay(MS_TO_TICKS(500)); + } else { + hal_sys_timer_delay(MS_TO_TICKS(2000)); + } + + return ret; } -static int usb_recv_data(unsigned char *buf, size_t len, size_t *rlen) -{ - int ret; +static int usb_cancel_input(void) { return usb_serial_flush_recv_buffer(); } - usb_recv_timer_start(); - ret = usb_serial_recv(buf, len); - usb_recv_timer_stop(); - if (ret == 0) { - *rlen = len; - } - return ret; +int cancel_input(void) { return usb_cancel_input(); } + +void system_reboot(void) { + hal_sys_timer_delay(MS_TO_TICKS(10)); + hal_cmu_sys_reboot(); } -int recv_data_ex(unsigned char *buf, size_t len, size_t expect, size_t *rlen) -{ - if (cancel_xfer) { - return -1; - } - return usb_recv_data(buf, expect, rlen); -} - -static int usb_handle_error(void) -{ - int ret; - - TRACE(0,"****** Send break ******"); - - // Send break signal, to tell the peer to reset the connection - ret = usb_serial_send_break(); - if (ret) { - TRACE(1,"Sending break failed: %d", ret); - } - return ret; -} - -int handle_error(void) -{ - int ret = 0; - uint32_t err_time; - - hal_sys_timer_delay(MS_TO_TICKS(50)); - - if (!cancel_xfer) { - ret = usb_handle_error(); - } - - err_time = hal_sys_timer_get(); - if (xfer_err_cnt == 0 || err_time - xfer_err_time > MS_TO_TICKS(5000)) { - xfer_err_cnt = 0; - xfer_err_time = err_time; - } - xfer_err_cnt++; - if (xfer_err_cnt < 3) { - hal_sys_timer_delay(MS_TO_TICKS(100)); - } else if (xfer_err_cnt < 5) { - hal_sys_timer_delay(MS_TO_TICKS(500)); - } else { - hal_sys_timer_delay(MS_TO_TICKS(2000)); - } - - return ret; -} - -static int usb_cancel_input(void) -{ - return usb_serial_flush_recv_buffer(); -} - -int cancel_input(void) -{ - return usb_cancel_input(); -} - -void system_reboot(void) -{ - hal_sys_timer_delay(MS_TO_TICKS(10)); - hal_cmu_sys_reboot(); -} - -void system_shutdown(void) -{ +void system_shutdown(void) { #if 0 if (dld_transport == TRANSPORT_USB) { // Avoid PC usb serial driver hanging usb_serial_close(); } #endif - hal_sys_timer_delay(MS_TO_TICKS(10)); - pmu_shutdown(); + hal_sys_timer_delay(MS_TO_TICKS(10)); + pmu_shutdown(); } -void system_set_bootmode(unsigned int bootmode) -{ - bootmode &= ~(HAL_SW_BOOTMODE_READ_ENABLED | HAL_SW_BOOTMODE_WRITE_ENABLED); - hal_sw_bootmode_set(bootmode); +void system_set_bootmode(unsigned int bootmode) { + bootmode &= ~(HAL_SW_BOOTMODE_READ_ENABLED | HAL_SW_BOOTMODE_WRITE_ENABLED); + hal_sw_bootmode_set(bootmode); } -void system_clear_bootmode(unsigned int bootmode) -{ - bootmode &= ~(HAL_SW_BOOTMODE_READ_ENABLED | HAL_SW_BOOTMODE_WRITE_ENABLED); - hal_sw_bootmode_clear(bootmode); +void system_clear_bootmode(unsigned int bootmode) { + bootmode &= ~(HAL_SW_BOOTMODE_READ_ENABLED | HAL_SW_BOOTMODE_WRITE_ENABLED); + hal_sw_bootmode_clear(bootmode); } -unsigned int system_get_bootmode(void) -{ - return hal_sw_bootmode_get(); -} +unsigned int system_get_bootmode(void) { return hal_sw_bootmode_get(); } #endif diff --git a/apps/key/app_key.cpp b/apps/key/app_key.cpp index 73ce657..acd44c0 100644 --- a/apps/key/app_key.cpp +++ b/apps/key/app_key.cpp @@ -13,155 +13,145 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "app_key.h" +#include "app_thread.h" #include "cmsis_os.h" +#include "hal_trace.h" #include "list.h" #include "string.h" -#include "app_thread.h" -#include "app_key.h" -#include "hal_trace.h" -#define APP_KEY_TRACE(s,...) //TRACE(s, ##__VA_ARGS__) +#define APP_KEY_TRACE(s, ...) // TRACE(s, ##__VA_ARGS__) #define KEY_EVENT_CNT_LIMIT (3) typedef struct { list_t *key_list; -}APP_KEY_CONFIG; +} APP_KEY_CONFIG; -APP_KEY_CONFIG app_key_conifg = { - .key_list = NULL -}; +APP_KEY_CONFIG app_key_conifg = {.key_list = NULL}; -osPoolDef (app_key_handle_mempool, 20, APP_KEY_HANDLE); -osPoolId app_key_handle_mempool = NULL; +osPoolDef(app_key_handle_mempool, 20, APP_KEY_HANDLE); +osPoolId app_key_handle_mempool = NULL; static uint8_t key_event_cnt = 0; -static int key_event_process(uint32_t key_code, uint8_t key_event) -{ - uint32_t app_keyevt; - APP_MESSAGE_BLOCK msg; - - if (key_event_cnt>KEY_EVENT_CNT_LIMIT){ - return 0; - }else{ - key_event_cnt++; - } - - msg.mod_id = APP_MODUAL_KEY; - APP_KEY_SET_MESSAGE(app_keyevt, key_code, key_event); - msg.msg_body.message_id = app_keyevt; - msg.msg_body.message_ptr = (uint32_t)NULL; - app_mailbox_put(&msg); +static int key_event_process(uint32_t key_code, uint8_t key_event) { + uint32_t app_keyevt; + APP_MESSAGE_BLOCK msg; + if (key_event_cnt > KEY_EVENT_CNT_LIMIT) { return 0; + } else { + key_event_cnt++; + } + + msg.mod_id = APP_MODUAL_KEY; + APP_KEY_SET_MESSAGE(app_keyevt, key_code, key_event); + msg.msg_body.message_id = app_keyevt; + msg.msg_body.message_ptr = (uint32_t)NULL; + app_mailbox_put(&msg); + + return 0; } -void app_key_simulate_key_event(uint32_t key_code, uint8_t key_event) -{ - key_event_process(key_code, key_event); +void app_key_simulate_key_event(uint32_t key_code, uint8_t key_event) { + key_event_process(key_code, key_event); } -static void app_key_handle_free(void *key_handle) -{ - osPoolFree (app_key_handle_mempool, key_handle); +static void app_key_handle_free(void *key_handle) { + osPoolFree(app_key_handle_mempool, key_handle); } -static APP_KEY_HANDLE *app_key_handle_find(const APP_KEY_STATUS *key_status) -{ - APP_KEY_HANDLE *key_handle = NULL; - list_node_t *node = NULL; +static APP_KEY_HANDLE *app_key_handle_find(const APP_KEY_STATUS *key_status) { + APP_KEY_HANDLE *key_handle = NULL; + list_node_t *node = NULL; - for (node = list_begin(app_key_conifg.key_list); node != list_end(app_key_conifg.key_list); node = list_next(node)) { - key_handle = (APP_KEY_HANDLE *)list_node(node); - if ((key_handle->key_status.code == key_status->code)&&(key_handle->key_status.event == key_status->event)) - return key_handle; - } + for (node = list_begin(app_key_conifg.key_list); + node != list_end(app_key_conifg.key_list); node = list_next(node)) { + key_handle = (APP_KEY_HANDLE *)list_node(node); + if ((key_handle->key_status.code == key_status->code) && + (key_handle->key_status.event == key_status->event)) + return key_handle; + } - return NULL; + return NULL; } -static int app_key_handle_process(APP_MESSAGE_BODY *msg_body) -{ - APP_KEY_STATUS key_status; - APP_KEY_HANDLE *key_handle = NULL; +static int app_key_handle_process(APP_MESSAGE_BODY *msg_body) { + APP_KEY_STATUS key_status; + APP_KEY_HANDLE *key_handle = NULL; - APP_KEY_GET_CODE(msg_body->message_id, key_status.code); - APP_KEY_GET_EVENT(msg_body->message_id, key_status.event); + APP_KEY_GET_CODE(msg_body->message_id, key_status.code); + APP_KEY_GET_EVENT(msg_body->message_id, key_status.event); - APP_KEY_TRACE(3,"%s code:%d event:%d",__func__,key_status.code, key_status.event); + APP_KEY_TRACE(3, "%s code:%d event:%d", __func__, key_status.code, + key_status.event); - key_event_cnt--; + key_event_cnt--; - key_handle = app_key_handle_find(&key_status); + key_handle = app_key_handle_find(&key_status); - if (key_handle != NULL && key_handle->function!= NULL) - ((APP_KEY_HANDLE_CB_T)key_handle->function)(&key_status,key_handle->param); + if (key_handle != NULL && key_handle->function != NULL) + ((APP_KEY_HANDLE_CB_T)key_handle->function)(&key_status, key_handle->param); - return 0; + return 0; } -int app_key_handle_registration(const APP_KEY_HANDLE *key_handle) -{ - APP_KEY_HANDLE *dest_key_handle = NULL; - APP_KEY_TRACE(1,"%s",__func__); - dest_key_handle = app_key_handle_find(&(key_handle->key_status)); +int app_key_handle_registration(const APP_KEY_HANDLE *key_handle) { + APP_KEY_HANDLE *dest_key_handle = NULL; + APP_KEY_TRACE(1, "%s", __func__); + dest_key_handle = app_key_handle_find(&(key_handle->key_status)); - APP_KEY_TRACE(2,"%s dest handle:0x%x",__func__,dest_key_handle); - if (dest_key_handle == NULL){ - dest_key_handle = (APP_KEY_HANDLE *)osPoolCAlloc (app_key_handle_mempool); - APP_KEY_TRACE(2,"%s malloc:0x%x",__func__,dest_key_handle); - list_append(app_key_conifg.key_list, dest_key_handle); - } - if (dest_key_handle == NULL) - return -1; - APP_KEY_TRACE(5,"%s set handle:0x%x code:%d event:%d function:%x",__func__,dest_key_handle, key_handle->key_status.code, key_handle->key_status.event, key_handle->function); - dest_key_handle->key_status.code = key_handle->key_status.code; - dest_key_handle->key_status.event = key_handle->key_status.event; - dest_key_handle->string = key_handle->string; - dest_key_handle->function = key_handle->function; - dest_key_handle->param = key_handle->param;; + APP_KEY_TRACE(2, "%s dest handle:0x%x", __func__, dest_key_handle); + if (dest_key_handle == NULL) { + dest_key_handle = (APP_KEY_HANDLE *)osPoolCAlloc(app_key_handle_mempool); + APP_KEY_TRACE(2, "%s malloc:0x%x", __func__, dest_key_handle); + list_append(app_key_conifg.key_list, dest_key_handle); + } + if (dest_key_handle == NULL) + return -1; + APP_KEY_TRACE(5, "%s set handle:0x%x code:%d event:%d function:%x", __func__, + dest_key_handle, key_handle->key_status.code, + key_handle->key_status.event, key_handle->function); + dest_key_handle->key_status.code = key_handle->key_status.code; + dest_key_handle->key_status.event = key_handle->key_status.event; + dest_key_handle->string = key_handle->string; + dest_key_handle->function = key_handle->function; + dest_key_handle->param = key_handle->param; + ; - return 0; + return 0; } -void app_key_handle_clear(void) -{ - list_clear(app_key_conifg.key_list); +void app_key_handle_clear(void) { list_clear(app_key_conifg.key_list); } + +int app_key_open(int checkPwrKey) { + APP_KEY_TRACE(2, "%s %x", __func__, app_key_conifg.key_list); + + if (app_key_conifg.key_list == NULL) + app_key_conifg.key_list = list_new(app_key_handle_free, NULL, NULL); + + if (app_key_handle_mempool == NULL) + app_key_handle_mempool = osPoolCreate(osPool(app_key_handle_mempool)); + + app_set_threadhandle(APP_MODUAL_KEY, app_key_handle_process); + + return hal_key_open(checkPwrKey, key_event_process); } -int app_key_open(int checkPwrKey) -{ - APP_KEY_TRACE(2,"%s %x",__func__, app_key_conifg.key_list); - - if (app_key_conifg.key_list == NULL) - app_key_conifg.key_list = list_new(app_key_handle_free, NULL, NULL); - - if (app_key_handle_mempool == NULL) - app_key_handle_mempool = osPoolCreate(osPool(app_key_handle_mempool)); - - app_set_threadhandle(APP_MODUAL_KEY, app_key_handle_process); - - return hal_key_open(checkPwrKey, key_event_process); +int app_key_close(void) { + hal_key_close(); + if (app_key_conifg.key_list != NULL) + list_free(app_key_conifg.key_list); + app_set_threadhandle(APP_MODUAL_KEY, NULL); + return 0; } -int app_key_close(void) -{ - hal_key_close(); - if (app_key_conifg.key_list != NULL) - list_free(app_key_conifg.key_list); - app_set_threadhandle(APP_MODUAL_KEY, NULL); - return 0; -} - -uint32_t app_key_read_status(uint32_t code) -{ - return (uint32_t)hal_key_read_status((enum HAL_KEY_CODE_T)code); +uint32_t app_key_read_status(uint32_t code) { + return (uint32_t)hal_key_read_status((enum HAL_KEY_CODE_T)code); } #if defined(_AUTO_TEST_) -int simul_key_event_process(uint32_t key_code, uint8_t key_event) -{ - return key_event_process(key_code, key_event); +int simul_key_event_process(uint32_t key_code, uint8_t key_event) { + return key_event_process(key_code, key_event); } #endif - diff --git a/apps/key/app_key.h b/apps/key/app_key.h index e7cccc5..5695101 100644 --- a/apps/key/app_key.h +++ b/apps/key/app_key.h @@ -13,82 +13,87 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "hal_key.h" + #ifndef __APP_KEY_H__ #define __APP_KEY_H__ -#include "hal_key.h" +#ifdef __cplusplus +extern "C" { +#endif -#define APP_KEY_SET_MESSAGE(appevt, code, evt) (appevt = (((uint32_t)code&0xffffff)<<8)|(evt&0xff)) -#define APP_KEY_GET_CODE(appevt, code) (code = (appevt>>8)&0xffffff) -#define APP_KEY_GET_EVENT(appevt, evt) (evt = appevt&0xff) +#define APP_KEY_SET_MESSAGE(appevt, code, evt) \ + (appevt = (((uint32_t)code & 0xffffff) << 8) | (evt & 0xff)) +#define APP_KEY_GET_CODE(appevt, code) (code = (appevt >> 8) & 0xffffff) +#define APP_KEY_GET_EVENT(appevt, evt) (evt = appevt & 0xff) -#define APP_KEY_CODE_GOOGLE APP_KEY_CODE_FN15 -#define APP_KEY_CODE_VOICEPATH APP_KEY_CODE_FN15 -#define APP_KEY_CODE_TILE APP_KEY_CODE_FN15 +#define APP_KEY_CODE_GOOGLE APP_KEY_CODE_FN15 +#define APP_KEY_CODE_VOICEPATH APP_KEY_CODE_FN15 +#define APP_KEY_CODE_TILE APP_KEY_CODE_FN15 enum APP_KEY_CODE_T { - APP_KEY_CODE_NONE = HAL_KEY_CODE_NONE, - APP_KEY_CODE_PWR = HAL_KEY_CODE_PWR, - APP_KEY_CODE_FN1 = HAL_KEY_CODE_FN1, - APP_KEY_CODE_FN2 = HAL_KEY_CODE_FN2, - APP_KEY_CODE_FN3 = HAL_KEY_CODE_FN3, - APP_KEY_CODE_FN4 = HAL_KEY_CODE_FN4, - APP_KEY_CODE_FN5 = HAL_KEY_CODE_FN5, - APP_KEY_CODE_FN6 = HAL_KEY_CODE_FN6, - APP_KEY_CODE_FN7 = HAL_KEY_CODE_FN7, - APP_KEY_CODE_FN8 = HAL_KEY_CODE_FN8, - APP_KEY_CODE_FN9 = HAL_KEY_CODE_FN9, - APP_KEY_CODE_FN10 = HAL_KEY_CODE_FN10, - APP_KEY_CODE_FN11 = HAL_KEY_CODE_FN11, - APP_KEY_CODE_FN12 = HAL_KEY_CODE_FN12, - APP_KEY_CODE_FN13 = HAL_KEY_CODE_FN13, - APP_KEY_CODE_FN14 = HAL_KEY_CODE_FN14, - APP_KEY_CODE_FN15 = HAL_KEY_CODE_FN15, + APP_KEY_CODE_NONE = HAL_KEY_CODE_NONE, + APP_KEY_CODE_PWR = HAL_KEY_CODE_PWR, + APP_KEY_CODE_FN1 = HAL_KEY_CODE_FN1, + APP_KEY_CODE_FN2 = HAL_KEY_CODE_FN2, + APP_KEY_CODE_FN3 = HAL_KEY_CODE_FN3, + APP_KEY_CODE_FN4 = HAL_KEY_CODE_FN4, + APP_KEY_CODE_FN5 = HAL_KEY_CODE_FN5, + APP_KEY_CODE_FN6 = HAL_KEY_CODE_FN6, + APP_KEY_CODE_FN7 = HAL_KEY_CODE_FN7, + APP_KEY_CODE_FN8 = HAL_KEY_CODE_FN8, + APP_KEY_CODE_FN9 = HAL_KEY_CODE_FN9, + APP_KEY_CODE_FN10 = HAL_KEY_CODE_FN10, + APP_KEY_CODE_FN11 = HAL_KEY_CODE_FN11, + APP_KEY_CODE_FN12 = HAL_KEY_CODE_FN12, + APP_KEY_CODE_FN13 = HAL_KEY_CODE_FN13, + APP_KEY_CODE_FN14 = HAL_KEY_CODE_FN14, + APP_KEY_CODE_FN15 = HAL_KEY_CODE_FN15, }; enum APP_KEY_EVENT_T { - APP_KEY_EVENT_NONE = HAL_KEY_EVENT_NONE, - APP_KEY_EVENT_DOWN = HAL_KEY_EVENT_DOWN, - APP_KEY_EVENT_FIRST_DOWN = HAL_KEY_EVENT_FIRST_DOWN, - APP_KEY_EVENT_CONTINUED_DOWN = HAL_KEY_EVENT_CONTINUED_DOWN, - APP_KEY_EVENT_UP = HAL_KEY_EVENT_UP, - APP_KEY_EVENT_UP_AFTER_LONGPRESS = HAL_KEY_EVENT_UP_AFTER_LONGPRESS, - APP_KEY_EVENT_LONGPRESS = HAL_KEY_EVENT_LONGPRESS, - APP_KEY_EVENT_LONGLONGPRESS = HAL_KEY_EVENT_LONGLONGPRESS, - APP_KEY_EVENT_CLICK = HAL_KEY_EVENT_CLICK, - APP_KEY_EVENT_DOUBLECLICK = HAL_KEY_EVENT_DOUBLECLICK, - APP_KEY_EVENT_TRIPLECLICK = HAL_KEY_EVENT_TRIPLECLICK, - APP_KEY_EVENT_ULTRACLICK = HAL_KEY_EVENT_ULTRACLICK, - APP_KEY_EVENT_RAMPAGECLICK = HAL_KEY_EVENT_RAMPAGECLICK, - APP_KEY_EVENT_SIXTHCLICK = HAL_KEY_EVENT_SIXTHCLICK, - APP_KEY_EVENT_SEVENTHCLICK = HAL_KEY_EVENT_SEVENTHCLICK, - APP_KEY_EVENT_EIGHTHCLICK = HAL_KEY_EVENT_EIGHTHCLICK, - APP_KEY_EVENT_NINETHCLICK = HAL_KEY_EVENT_NINETHCLICK, - APP_KEY_EVENT_TENTHCLICK = HAL_KEY_EVENT_TENTHCLICK, - APP_KEY_EVENT_REPEAT = HAL_KEY_EVENT_REPEAT, - APP_KEY_EVENT_GROUPKEY_DOWN = HAL_KEY_EVENT_GROUPKEY_DOWN, - APP_KEY_EVENT_GROUPKEY_REPEAT = HAL_KEY_EVENT_GROUPKEY_REPEAT, - APP_KEY_EVENT_INITDOWN = HAL_KEY_EVENT_INITDOWN, - APP_KEY_EVENT_INITUP = HAL_KEY_EVENT_INITUP, - APP_KEY_EVENT_INITLONGPRESS = HAL_KEY_EVENT_INITLONGPRESS, - APP_KEY_EVENT_INITLONGLONGPRESS = HAL_KEY_EVENT_INITLONGLONGPRESS, - APP_KEY_EVENT_INITFINISHED = HAL_KEY_EVENT_INITFINISHED, + APP_KEY_EVENT_NONE = HAL_KEY_EVENT_NONE, + APP_KEY_EVENT_DOWN = HAL_KEY_EVENT_DOWN, + APP_KEY_EVENT_FIRST_DOWN = HAL_KEY_EVENT_FIRST_DOWN, + APP_KEY_EVENT_CONTINUED_DOWN = HAL_KEY_EVENT_CONTINUED_DOWN, + APP_KEY_EVENT_UP = HAL_KEY_EVENT_UP, + APP_KEY_EVENT_UP_AFTER_LONGPRESS = HAL_KEY_EVENT_UP_AFTER_LONGPRESS, + APP_KEY_EVENT_LONGPRESS = HAL_KEY_EVENT_LONGPRESS, + APP_KEY_EVENT_LONGLONGPRESS = HAL_KEY_EVENT_LONGLONGPRESS, + APP_KEY_EVENT_CLICK = HAL_KEY_EVENT_CLICK, + APP_KEY_EVENT_DOUBLECLICK = HAL_KEY_EVENT_DOUBLECLICK, + APP_KEY_EVENT_TRIPLECLICK = HAL_KEY_EVENT_TRIPLECLICK, + APP_KEY_EVENT_ULTRACLICK = HAL_KEY_EVENT_ULTRACLICK, + APP_KEY_EVENT_RAMPAGECLICK = HAL_KEY_EVENT_RAMPAGECLICK, + APP_KEY_EVENT_SIXTHCLICK = HAL_KEY_EVENT_SIXTHCLICK, + APP_KEY_EVENT_SEVENTHCLICK = HAL_KEY_EVENT_SEVENTHCLICK, + APP_KEY_EVENT_EIGHTHCLICK = HAL_KEY_EVENT_EIGHTHCLICK, + APP_KEY_EVENT_NINETHCLICK = HAL_KEY_EVENT_NINETHCLICK, + APP_KEY_EVENT_TENTHCLICK = HAL_KEY_EVENT_TENTHCLICK, + APP_KEY_EVENT_REPEAT = HAL_KEY_EVENT_REPEAT, + APP_KEY_EVENT_GROUPKEY_DOWN = HAL_KEY_EVENT_GROUPKEY_DOWN, + APP_KEY_EVENT_GROUPKEY_REPEAT = HAL_KEY_EVENT_GROUPKEY_REPEAT, + APP_KEY_EVENT_INITDOWN = HAL_KEY_EVENT_INITDOWN, + APP_KEY_EVENT_INITUP = HAL_KEY_EVENT_INITUP, + APP_KEY_EVENT_INITLONGPRESS = HAL_KEY_EVENT_INITLONGPRESS, + APP_KEY_EVENT_INITLONGLONGPRESS = HAL_KEY_EVENT_INITLONGLONGPRESS, + APP_KEY_EVENT_INITFINISHED = HAL_KEY_EVENT_INITFINISHED, - APP_KEY_EVENT_NUM = HAL_KEY_EVENT_NUM, + APP_KEY_EVENT_NUM = HAL_KEY_EVENT_NUM, }; typedef struct { - uint32_t code; - uint8_t event; -}APP_KEY_STATUS; + uint32_t code; + uint8_t event; +} APP_KEY_STATUS; -typedef void (*APP_KEY_HANDLE_CB_T)(APP_KEY_STATUS*, void *param); +typedef void (*APP_KEY_HANDLE_CB_T)(APP_KEY_STATUS *, void *param); typedef struct { - APP_KEY_STATUS key_status; - const char* string; - APP_KEY_HANDLE_CB_T function; - void *param; + APP_KEY_STATUS key_status; + const char *string; + APP_KEY_HANDLE_CB_T function; + void *param; } APP_KEY_HANDLE; int app_key_open(int checkPwrKey); @@ -106,4 +111,8 @@ void app_key_simulate_key_event(uint32_t key_code, uint8_t key_event); #if defined(_AUTO_TEST_) int simul_key_event_process(uint32_t key_code, uint8_t key_event); #endif -#endif//__FMDEC_H__ + +#ifdef __cplusplus +}; +#endif +#endif //__FMDEC_H__ diff --git a/apps/main/apps.cpp b/apps/main/apps.cpp index 09e4cd6..818392e 100644 --- a/apps/main/apps.cpp +++ b/apps/main/apps.cpp @@ -13,51 +13,51 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "stdio.h" +#include "apps.h" +#include "a2dp_api.h" +#include "app_audio.h" +#include "app_battery.h" +#include "app_ble_include.h" +#include "app_bt.h" +#include "app_bt_func.h" +#include "app_bt_media_manager.h" +#include "app_key.h" +#include "app_overlay.h" +#include "app_pwl.h" +#include "app_status_ind.h" +#include "app_thread.h" +#include "app_utils.h" +#include "audioflinger.h" +#include "besbt.h" +#include "bt_drv_interface.h" +#include "bt_if.h" +#include "btapp.h" #include "cmsis_os.h" -#include "list.h" -#include "string.h" +#include "crash_dump_section.h" +#include "factory_section.h" +#include "gapm_task.h" +#include "hal_bootmode.h" +#include "hal_i2c.h" +#include "hal_sleep.h" #include "hal_timer.h" #include "hal_trace.h" -#include "hal_bootmode.h" -#include "hal_sleep.h" -#include "pmu.h" -#include "audioflinger.h" -#include "apps.h" -#include "app_thread.h" -#include "app_key.h" -#include "app_bt_media_manager.h" -#include "app_pwl.h" -#include "app_audio.h" -#include "app_overlay.h" -#include "app_battery.h" -#include "app_utils.h" -#include "app_status_ind.h" -#include "bt_drv_interface.h" -#include "besbt.h" +#include "list.h" +#include "log_section.h" +#include "me_api.h" #include "norflash_api.h" #include "nvrecord.h" #include "nvrecord_dev.h" #include "nvrecord_env.h" -#include "crash_dump_section.h" -#include "log_section.h" -#include "factory_section.h" -#include "a2dp_api.h" -#include "me_api.h" #include "os_api.h" -#include "btapp.h" -#include "app_bt.h" -#include "bt_if.h" -#include "gapm_task.h" -#include "app_ble_include.h" -#include "app_bt_func.h" +#include "pmu.h" +#include "stdio.h" +#include "string.h" #include "tgt_hardware.h" -#include "hal_i2c.h" #ifdef __AI_VOICE__ -#include "app_ai_if.h" -#include "app_ai_tws.h" #include "ai_manager.h" +#include "app_ai_if.h" #include "app_ai_manager_api.h" +#include "app_ai_tws.h" #endif #include "app_tws_ibrt_cmd_handler.h" #include "audio_process.h" @@ -72,10 +72,10 @@ #endif #ifdef __INTERCONNECTION__ +#include "app_ble_mode_switch.h" #include "app_interconnection.h" #include "app_interconnection_ble.h" #include "app_interconnection_logic_protocol.h" -#include "app_ble_mode_switch.h" #endif #ifdef __INTERACTION__ @@ -84,10 +84,10 @@ #ifdef BISTO_ENABLED #include "app_ai_manager_api.h" -#include "gsound_custom_reset.h" -#include "nvrecord_gsound.h" #include "gsound_custom_actions.h" #include "gsound_custom_ota.h" +#include "gsound_custom_reset.h" +#include "nvrecord_gsound.h" #endif #ifdef IBRT_OTA @@ -95,8 +95,8 @@ #endif #ifdef MEDIA_PLAYER_SUPPORT -#include "resources.h" #include "app_media_player.h" +#include "resources.h" #endif #ifdef VOICE_DATAPATH @@ -113,12 +113,12 @@ #endif #if defined(IBRT) -#include "app_ibrt_if.h" +#include "app_ibrt_customif_cmd.h" #include "app_ibrt_customif_ui.h" +#include "app_ibrt_if.h" #include "app_ibrt_ui_test.h" #include "app_ibrt_voice_report.h" #include "app_tws_if.h" -#include "app_ibrt_customif_cmd.h" #endif #ifdef GFPS_ENABLED @@ -142,7 +142,6 @@ #include "ota_common.h" #endif - #ifdef WL_DET #include "app_mic_alg.h" #endif @@ -152,7 +151,7 @@ extern "C" int speech_tuning_init(void); #endif #if (defined(BTUSB_AUDIO_MODE) || defined(BT_USB_AUDIO_DUAL_MODE)) -extern "C" bool app_usbaudio_mode_on(void) ; +extern "C" bool app_usbaudio_mode_on(void); #endif #ifdef BES_OTA_BASIC @@ -160,26 +159,26 @@ extern "C" void ota_flash_init(void); #endif #define APP_BATTERY_LEVEL_LOWPOWERTHRESHOLD (1) -#define POWERON_PRESSMAXTIME_THRESHOLD_MS (5000) +#define POWERON_PRESSMAXTIME_THRESHOLD_MS (5000) #ifdef FPGA uint32_t __ota_upgrade_log_start[100]; #endif enum APP_POWERON_CASE_T { - APP_POWERON_CASE_NORMAL = 0, - APP_POWERON_CASE_DITHERING, - APP_POWERON_CASE_REBOOT, - APP_POWERON_CASE_ALARM, - APP_POWERON_CASE_CALIB, - APP_POWERON_CASE_BOTHSCAN, - APP_POWERON_CASE_CHARGING, - APP_POWERON_CASE_FACTORY, - APP_POWERON_CASE_TEST, - APP_POWERON_CASE_LINKLOSE_REBOOT, - APP_POWERON_CASE_INVALID, + APP_POWERON_CASE_NORMAL = 0, + APP_POWERON_CASE_DITHERING, + APP_POWERON_CASE_REBOOT, + APP_POWERON_CASE_ALARM, + APP_POWERON_CASE_CALIB, + APP_POWERON_CASE_BOTHSCAN, + APP_POWERON_CASE_CHARGING, + APP_POWERON_CASE_FACTORY, + APP_POWERON_CASE_TEST, + APP_POWERON_CASE_LINKLOSE_REBOOT, + APP_POWERON_CASE_INVALID, - APP_POWERON_CASE_NUM + APP_POWERON_CASE_NUM }; #ifdef RB_CODEC @@ -191,10 +190,7 @@ extern void app_rbplay_audio_reset_pause_status(void); #ifdef __SUPPORT_ANC_SINGLE_MODE_WITHOUT_BT__ extern bool app_pwr_key_monitor_get_val(void); static bool anc_single_mode_on = false; -extern "C" bool anc_single_mode_is_on(void) -{ - return anc_single_mode_on; -} +extern "C" bool anc_single_mode_is_on(void) { return anc_single_mode_on; } #endif #ifdef __ANC_STICK_SWITCH_USE_GPIO__ @@ -205,19 +201,20 @@ extern bool app_anc_switch_get_val(void); extern "C" void app_fast_pairing_timeout_timehandler(void); #endif -uint8_t app_poweroff_flag = 0; +uint8_t app_poweroff_flag = 0; static enum APP_POWERON_CASE_T g_pwron_case = APP_POWERON_CASE_INVALID; #ifndef APP_TEST_MODE -static uint8_t app_status_indication_init(void) -{ - struct APP_PWL_CFG_T cfg; - hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)cfg_hw_pinmux_pwl, sizeof(cfg_hw_pinmux_pwl)/sizeof(struct HAL_IOMUX_PIN_FUNCTION_MAP)); - memset(&cfg, 0, sizeof(struct APP_PWL_CFG_T)); - app_pwl_open(); - app_pwl_setup(APP_PWL_ID_0, &cfg); - app_pwl_setup(APP_PWL_ID_1, &cfg); - return 0; +static uint8_t app_status_indication_init(void) { + struct APP_PWL_CFG_T cfg; + hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)cfg_hw_pinmux_pwl, + sizeof(cfg_hw_pinmux_pwl) / + sizeof(struct HAL_IOMUX_PIN_FUNCTION_MAP)); + memset(&cfg, 0, sizeof(struct APP_PWL_CFG_T)); + app_pwl_open(); + app_pwl_setup(APP_PWL_ID_0, &cfg); + app_pwl_setup(APP_PWL_ID_1, &cfg); + return 0; } #endif @@ -231,398 +228,379 @@ void app_pair_timerout(void); void app_poweroff_timerout(void); void CloseEarphone(void); -typedef struct -{ - uint8_t timer_id; - uint8_t timer_en; - uint8_t timer_count; - uint8_t timer_period; - APP_10_SECOND_TIMER_CB_T cb; -}APP_10_SECOND_TIMER_STRUCT; +typedef struct { + uint8_t timer_id; + uint8_t timer_en; + uint8_t timer_count; + uint8_t timer_period; + APP_10_SECOND_TIMER_CB_T cb; +} APP_10_SECOND_TIMER_STRUCT; -#define INIT_APP_TIMER(_id, _en, _count, _period, _cb) \ - { \ - .timer_id = _id, \ - .timer_en = _en, \ - .timer_count = _count, \ - .timer_period = _period, \ - .cb = _cb, \ - } +#define INIT_APP_TIMER(_id, _en, _count, _period, _cb) \ + { \ + .timer_id = _id, .timer_en = _en, .timer_count = _count, \ + .timer_period = _period, .cb = _cb, \ + } -APP_10_SECOND_TIMER_STRUCT app_10_second_array[] = -{ +APP_10_SECOND_TIMER_STRUCT app_10_second_array[] = { INIT_APP_TIMER(APP_PAIR_TIMER_ID, 0, 0, 6, PairingTransferToConnectable), INIT_APP_TIMER(APP_POWEROFF_TIMER_ID, 0, 0, 90, CloseEarphone), #ifdef GFPS_ENABLED - INIT_APP_TIMER(APP_FASTPAIR_LASTING_TIMER_ID, 0, 0, APP_FAST_PAIRING_TIMEOUT_IN_SECOND/10, - app_fast_pairing_timeout_timehandler), + INIT_APP_TIMER(APP_FASTPAIR_LASTING_TIMER_ID, 0, 0, + APP_FAST_PAIRING_TIMEOUT_IN_SECOND / 10, + app_fast_pairing_timeout_timehandler), #endif }; -void app_stop_10_second_timer(uint8_t timer_id) -{ - APP_10_SECOND_TIMER_STRUCT *timer = &app_10_second_array[timer_id]; +void app_stop_10_second_timer(uint8_t timer_id) { + APP_10_SECOND_TIMER_STRUCT *timer = &app_10_second_array[timer_id]; - timer->timer_en = 0; - timer->timer_count = 0; + timer->timer_en = 0; + timer->timer_count = 0; } -void app_start_10_second_timer(uint8_t timer_id) -{ - APP_10_SECOND_TIMER_STRUCT *timer = &app_10_second_array[timer_id]; +void app_start_10_second_timer(uint8_t timer_id) { + APP_10_SECOND_TIMER_STRUCT *timer = &app_10_second_array[timer_id]; - timer->timer_en = 0; - timer->timer_count = 0; + timer->timer_en = 0; + timer->timer_count = 0; } -void app_set_10_second_timer(uint8_t timer_id, uint8_t enable, uint8_t period) -{ - APP_10_SECOND_TIMER_STRUCT *timer = &app_10_second_array[timer_id]; +void app_set_10_second_timer(uint8_t timer_id, uint8_t enable, uint8_t period) { + APP_10_SECOND_TIMER_STRUCT *timer = &app_10_second_array[timer_id]; - timer->timer_en = enable; - timer->timer_count = period; + timer->timer_en = enable; + timer->timer_count = period; } -void app_10_second_timer_check(void) -{ - APP_10_SECOND_TIMER_STRUCT *timer = app_10_second_array; - unsigned int i; +void app_10_second_timer_check(void) { + APP_10_SECOND_TIMER_STRUCT *timer = app_10_second_array; + unsigned int i; - for(i = 0; i < ARRAY_SIZE(app_10_second_array); i++) { - if (timer->timer_en) { - timer->timer_count++; - if (timer->timer_count >= timer->timer_period) { - timer->timer_en = 0; - if (timer->cb) - timer->cb(); - } - } - timer++; + for (i = 0; i < ARRAY_SIZE(app_10_second_array); i++) { + if (timer->timer_en) { + timer->timer_count++; + if (timer->timer_count >= timer->timer_period) { + timer->timer_en = 0; + if (timer->cb) + timer->cb(); + } } + timer++; + } } -void CloseEarphone(void) -{ - int activeCons; - osapi_lock_stack(); - activeCons = btif_me_get_activeCons(); - osapi_unlock_stack(); +void CloseEarphone(void) { + int activeCons; + osapi_lock_stack(); + activeCons = btif_me_get_activeCons(); + osapi_unlock_stack(); #ifdef ANC_APP - if(app_anc_work_status()) { - app_set_10_second_timer(APP_POWEROFF_TIMER_ID, 1, 30); - return; - } + if (app_anc_work_status()) { + app_set_10_second_timer(APP_POWEROFF_TIMER_ID, 1, 30); + return; + } #endif /* ANC_APP */ - if(activeCons == 0) { - TRACE(0,"!!!CloseEarphone\n"); - app_shutdown(); - } + if (activeCons == 0) { + TRACE(0, "!!!CloseEarphone\n"); + app_shutdown(); + } } #endif /* #if defined(__BTIF_EARPHONE__) && defined(__BTIF_AUTOPOWEROFF__) */ int signal_send_to_main_thread(uint32_t signals); uint8_t stack_ready_flag = 0; -void app_notify_stack_ready(uint8_t ready_flag) -{ - TRACE(2,"app_notify_stack_ready %d %d", stack_ready_flag, ready_flag); +void app_notify_stack_ready(uint8_t ready_flag) { + TRACE(2, "app_notify_stack_ready %d %d", stack_ready_flag, ready_flag); - stack_ready_flag |= ready_flag; + stack_ready_flag |= ready_flag; #ifdef __IAG_BLE_INCLUDE__ - if(stack_ready_flag == (STACK_READY_BT|STACK_READY_BLE)) + if (stack_ready_flag == (STACK_READY_BT | STACK_READY_BLE)) #endif - { - signal_send_to_main_thread(0x3); - } + { + signal_send_to_main_thread(0x3); + } } -bool app_is_stack_ready(void) -{ - bool ret = false; +bool app_is_stack_ready(void) { + bool ret = false; - if (stack_ready_flag == (STACK_READY_BT + if (stack_ready_flag == (STACK_READY_BT #ifdef __IAG_BLE_INCLUDE__ - | STACK_READY_BLE + | STACK_READY_BLE #endif - )) - { - ret = true; - } + )) { + ret = true; + } - return ret; + return ret; } -static void app_stack_ready_cb(void) -{ - TRACE(0,"stack init done"); +static void app_stack_ready_cb(void) { + TRACE(0, "stack init done"); #ifdef BLE_ENABLE - app_ble_stub_user_init(); - app_ble_start_connectable_adv(BLE_ADVERTISING_INTERVAL); + app_ble_stub_user_init(); + app_ble_start_connectable_adv(BLE_ADVERTISING_INTERVAL); #endif } -//#if (HF_CUSTOM_FEATURE_SUPPORT & HF_CUSTOM_FEATURE_BATTERY_REPORT) || (HF_SDK_FEATURES & HF_FEATURE_HF_INDICATORS) +// #if (HF_CUSTOM_FEATURE_SUPPORT & HF_CUSTOM_FEATURE_BATTERY_REPORT) || +//(HF_SDK_FEATURES & HF_FEATURE_HF_INDICATORS) #if defined(SUPPORT_BATTERY_REPORT) || defined(SUPPORT_HF_INDICATORS) extern void app_hfp_set_battery_level(uint8_t level); #endif -int app_status_battery_report(uint8_t level) -{ +int app_status_battery_report(uint8_t level) { #ifdef __SUPPORT_ANC_SINGLE_MODE_WITHOUT_BT__ - if (anc_single_mode_on) //anc power on,anc only mode - return 0; + if (anc_single_mode_on) // anc power on,anc only mode + return 0; #endif #if defined(__BTIF_EARPHONE__) - if (app_is_stack_ready()) - { - app_bt_state_checker(); - } - app_10_second_timer_check(); + if (app_is_stack_ready()) { + app_bt_state_checker(); + } + app_10_second_timer_check(); #endif - if (level <= APP_BATTERY_LEVEL_LOWPOWERTHRESHOLD) - { - //add something - } + if (level <= APP_BATTERY_LEVEL_LOWPOWERTHRESHOLD) { + // add something + } - if (app_is_stack_ready()) - { -// #if (HF_CUSTOM_FEATURE_SUPPORT & HF_CUSTOM_FEATURE_BATTERY_REPORT) || (HF_SDK_FEATURES & HF_FEATURE_HF_INDICATORS) + if (app_is_stack_ready()) { +// #if (HF_CUSTOM_FEATURE_SUPPORT & HF_CUSTOM_FEATURE_BATTERY_REPORT) || +// (HF_SDK_FEATURES & HF_FEATURE_HF_INDICATORS) #if defined(SUPPORT_BATTERY_REPORT) || defined(SUPPORT_HF_INDICATORS) #if defined(IBRT) - if (app_tws_ibrt_mobile_link_connected()) - { - app_hfp_set_battery_level(level); - } -#else - app_hfp_set_battery_level(level); -#endif -#else - TRACE(1,"[%s] Can not enable SUPPORT_BATTERY_REPORT", __func__); -#endif - osapi_notify_evm(); + if (app_tws_ibrt_mobile_link_connected()) { + app_hfp_set_battery_level(level); } - return 0; +#else + app_hfp_set_battery_level(level); +#endif +#else + TRACE(1, "[%s] Can not enable SUPPORT_BATTERY_REPORT", __func__); +#endif + osapi_notify_evm(); + } + return 0; } void stopAuto_Shutdowm_Timer(void); -void app_bt_power_off_customize() -{ -#if(TWS_Sync_Shutdowm) - app_ibrt_poweroff_notify_force(); +void app_bt_power_off_customize() { +#if (TWS_Sync_Shutdowm) + app_ibrt_poweroff_notify_force(); #endif - app_shutdown(); + app_shutdown(); } #ifdef MEDIA_PLAYER_SUPPORT -void app_status_set_num(const char* p) -{ - media_Set_IncomingNumber(p); -} +void app_status_set_num(const char *p) { media_Set_IncomingNumber(p); } static u8 last_voice_waring = APP_STATUS_INDICATION_NUM; -int app_voice_report_handler(APP_STATUS_INDICATION_T status, uint8_t device_id, uint8_t isMerging) -{ +int app_voice_report_handler(APP_STATUS_INDICATION_T status, uint8_t device_id, + uint8_t isMerging) { #if (defined(BTUSB_AUDIO_MODE) || defined(BT_USB_AUDIO_DUAL_MODE)) - if(app_usbaudio_mode_on()) return 0; + if (app_usbaudio_mode_on()) + return 0; #endif - TRACE(3,"%s %d",__func__, status); - AUD_ID_ENUM id = MAX_RECORD_NUM; + TRACE(3, "%s %d", __func__, status); + AUD_ID_ENUM id = MAX_RECORD_NUM; #ifdef __SUPPORT_ANC_SINGLE_MODE_WITHOUT_BT__ - if(anc_single_mode_on) - return 0; + if (anc_single_mode_on) + return 0; #endif -if(((last_voice_waring == APP_STATUS_INDICATION_POWERON)&&(status == APP_STATUS_INDICATION_POWERON))|| - ((last_voice_waring == APP_STATUS_INDICATION_BOTHSCAN)&&(status == APP_STATUS_INDICATION_BOTHSCAN))|| - ((last_voice_waring == APP_STATUS_INDICATION_BOTHSCAN)&&(status == APP_STATUS_INDICATION_DISCONNECTED))){ - last_voice_waring = status; - return 0; - } - if (app_poweroff_flag == 1){ - switch (status) { - case APP_STATUS_INDICATION_POWEROFF: - id = AUD_ID_POWER_OFF; - break; - default: - return 0; - break; - } - }else{ - switch (status) { - case APP_STATUS_INDICATION_POWERON: - id = AUD_ID_POWER_ON; - break; - case APP_STATUS_INDICATION_POWEROFF: - id = AUD_ID_POWER_OFF; - break; - case APP_STATUS_INDICATION_CONNECTED: - id = AUD_ID_BT_CONNECTED; - break; - case APP_STATUS_INDICATION_DISCONNECTED: - id = AUD_ID_BT_DIS_CONNECT; - break; - case APP_STATUS_INDICATION_CALLNUMBER: - id = AUD_ID_BT_CALL_INCOMING_NUMBER; - break; - case APP_STATUS_INDICATION_CHARGENEED: - id = AUD_ID_BT_CHARGE_PLEASE; - break; - case APP_STATUS_INDICATION_FULLCHARGE: - id = AUD_ID_BT_CHARGE_FINISH; - break; - case APP_STATUS_INDICATION_PAIRSUCCEED: - id = AUD_ID_BT_PAIRING_SUC; - break; - case APP_STATUS_INDICATION_PAIRFAIL: - id = AUD_ID_BT_PAIRING_FAIL; - break; + if (((last_voice_waring == APP_STATUS_INDICATION_POWERON) && + (status == APP_STATUS_INDICATION_POWERON)) || + ((last_voice_waring == APP_STATUS_INDICATION_BOTHSCAN) && + (status == APP_STATUS_INDICATION_BOTHSCAN)) || + ((last_voice_waring == APP_STATUS_INDICATION_BOTHSCAN) && + (status == APP_STATUS_INDICATION_DISCONNECTED))) { + last_voice_waring = status; + return 0; + } + if (app_poweroff_flag == 1) { + switch (status) { + case APP_STATUS_INDICATION_POWEROFF: + id = AUD_ID_POWER_OFF; + break; + default: + return 0; + break; + } + } else { + switch (status) { + case APP_STATUS_INDICATION_POWERON: + id = AUD_ID_POWER_ON; + break; + case APP_STATUS_INDICATION_POWEROFF: + id = AUD_ID_POWER_OFF; + break; + case APP_STATUS_INDICATION_CONNECTED: + id = AUD_ID_BT_CONNECTED; + break; + case APP_STATUS_INDICATION_DISCONNECTED: + id = AUD_ID_BT_DIS_CONNECT; + break; + case APP_STATUS_INDICATION_CALLNUMBER: + id = AUD_ID_BT_CALL_INCOMING_NUMBER; + break; + case APP_STATUS_INDICATION_CHARGENEED: + id = AUD_ID_BT_CHARGE_PLEASE; + break; + case APP_STATUS_INDICATION_FULLCHARGE: + id = AUD_ID_BT_CHARGE_FINISH; + break; + case APP_STATUS_INDICATION_PAIRSUCCEED: + id = AUD_ID_BT_PAIRING_SUC; + break; + case APP_STATUS_INDICATION_PAIRFAIL: + id = AUD_ID_BT_PAIRING_FAIL; + break; - case APP_STATUS_INDICATION_HANGUPCALL: - id = AUD_ID_BT_CALL_HUNG_UP; - break; + case APP_STATUS_INDICATION_HANGUPCALL: + id = AUD_ID_BT_CALL_HUNG_UP; + break; - case APP_STATUS_INDICATION_REFUSECALL: - id = AUD_ID_BT_CALL_REFUSE; - isMerging = false; - break; + case APP_STATUS_INDICATION_REFUSECALL: + id = AUD_ID_BT_CALL_REFUSE; + isMerging = false; + break; - case APP_STATUS_INDICATION_ANSWERCALL: - id = AUD_ID_BT_CALL_ANSWER; - break; + case APP_STATUS_INDICATION_ANSWERCALL: + id = AUD_ID_BT_CALL_ANSWER; + break; - case APP_STATUS_INDICATION_CLEARSUCCEED: - id = AUD_ID_BT_CLEAR_SUCCESS; - break; + case APP_STATUS_INDICATION_CLEARSUCCEED: + id = AUD_ID_BT_CLEAR_SUCCESS; + break; - case APP_STATUS_INDICATION_CLEARFAIL: - id = AUD_ID_BT_CLEAR_FAIL; - break; - case APP_STATUS_INDICATION_INCOMINGCALL: - id = AUD_ID_BT_CALL_INCOMING_CALL; - break; - case APP_STATUS_INDICATION_BOTHSCAN: - id = AUD_ID_BT_PAIR_ENABLE; - break; - case APP_STATUS_INDICATION_WARNING: - id = AUD_ID_BT_WARNING; - break; - case APP_STATUS_INDICATION_ALEXA_START: - id = AUDIO_ID_BT_ALEXA_START; - break; - case APP_STATUS_INDICATION_ALEXA_STOP: - id = AUDIO_ID_BT_ALEXA_STOP; - break; - case APP_STATUS_INDICATION_GSOUND_MIC_OPEN: - id = AUDIO_ID_BT_GSOUND_MIC_OPEN; - break; - case APP_STATUS_INDICATION_GSOUND_MIC_CLOSE: - id = AUDIO_ID_BT_GSOUND_MIC_CLOSE; - break; - case APP_STATUS_INDICATION_GSOUND_NC: - id = AUDIO_ID_BT_GSOUND_NC; - break; + case APP_STATUS_INDICATION_CLEARFAIL: + id = AUD_ID_BT_CLEAR_FAIL; + break; + case APP_STATUS_INDICATION_INCOMINGCALL: + id = AUD_ID_BT_CALL_INCOMING_CALL; + break; + case APP_STATUS_INDICATION_BOTHSCAN: + id = AUD_ID_BT_PAIR_ENABLE; + break; + case APP_STATUS_INDICATION_WARNING: + id = AUD_ID_BT_WARNING; + break; + case APP_STATUS_INDICATION_ALEXA_START: + id = AUDIO_ID_BT_ALEXA_START; + break; + case APP_STATUS_INDICATION_ALEXA_STOP: + id = AUDIO_ID_BT_ALEXA_STOP; + break; + case APP_STATUS_INDICATION_GSOUND_MIC_OPEN: + id = AUDIO_ID_BT_GSOUND_MIC_OPEN; + break; + case APP_STATUS_INDICATION_GSOUND_MIC_CLOSE: + id = AUDIO_ID_BT_GSOUND_MIC_CLOSE; + break; + case APP_STATUS_INDICATION_GSOUND_NC: + id = AUDIO_ID_BT_GSOUND_NC; + break; #ifdef __BT_WARNING_TONE_MERGE_INTO_STREAM_SBC__ - case APP_STATUS_RING_WARNING: - id = AUD_ID_RING_WARNING; - break; + case APP_STATUS_RING_WARNING: + id = AUD_ID_RING_WARNING; + break; #endif - case APP_STATUS_INDICATION_MUTE: - id = AUDIO_ID_BT_MUTE; - break; + case APP_STATUS_INDICATION_MUTE: + id = AUDIO_ID_BT_MUTE; + break; #ifdef __INTERACTION__ - case APP_STATUS_INDICATION_FINDME: - id = AUD_ID_BT_FINDME; - break; -#endif - case APP_STATUS_INDICATION_FIND_MY_BUDS: - id = AUDIO_ID_FIND_MY_BUDS; - break; - case APP_STATUS_INDICATION_TILE_FIND: - id = AUDIO_ID_FIND_TILE; - break; - case APP_STATUS_INDICATION_DUDU: - id = AUDIO_ID_BT_DUDU; - break; - case APP_STATUS_INDICATION_DU: - id = AUDIO_ID_BT_DU; - break; - default: - break; - } - } - - uint16_t aud_pram = 0; - if (isMerging){ - aud_pram |= PROMOT_ID_BIT_MASK_MERGING; - } -#ifdef BT_USB_AUDIO_DUAL_MODE - if(!btusb_is_usb_mode()) - { -#if defined(IBRT) - app_ibrt_if_voice_report_handler(id, aud_pram); -#else - trigger_media_play(id, device_id, aud_pram); + case APP_STATUS_INDICATION_FINDME: + id = AUD_ID_BT_FINDME; + break; #endif + case APP_STATUS_INDICATION_FIND_MY_BUDS: + id = AUDIO_ID_FIND_MY_BUDS; + break; + case APP_STATUS_INDICATION_TILE_FIND: + id = AUDIO_ID_FIND_TILE; + break; + case APP_STATUS_INDICATION_DUDU: + id = AUDIO_ID_BT_DUDU; + break; + case APP_STATUS_INDICATION_DU: + id = AUDIO_ID_BT_DU; + break; + default: + break; } + } -#else + uint16_t aud_pram = 0; + if (isMerging) { + aud_pram |= PROMOT_ID_BIT_MASK_MERGING; + } +#ifdef BT_USB_AUDIO_DUAL_MODE + if (!btusb_is_usb_mode()) { #if defined(IBRT) - aud_pram |= PROMOT_ID_BIT_MASK_CHNLSEl_ALL; app_ibrt_if_voice_report_handler(id, aud_pram); #else trigger_media_play(id, device_id, aud_pram); +#endif + } + +#else +#if defined(IBRT) + aud_pram |= PROMOT_ID_BIT_MASK_CHNLSEl_ALL; + app_ibrt_if_voice_report_handler(id, aud_pram); +#else + trigger_media_play(id, device_id, aud_pram); #endif #endif - return 0; + return 0; } -extern "C" int app_voice_report(APP_STATUS_INDICATION_T status, uint8_t device_id) -{ - return app_voice_report_handler(status, device_id, true); +extern "C" int app_voice_report(APP_STATUS_INDICATION_T status, + uint8_t device_id) { + return app_voice_report_handler(status, device_id, true); } -extern "C" int app_voice_report_generic(APP_STATUS_INDICATION_T status, uint8_t device_id, uint8_t isMerging) -{ - return app_voice_report_handler(status, device_id, isMerging); +extern "C" int app_voice_report_generic(APP_STATUS_INDICATION_T status, + uint8_t device_id, uint8_t isMerging) { + return app_voice_report_handler(status, device_id, isMerging); } -extern "C" int app_voice_stop(APP_STATUS_INDICATION_T status, uint8_t device_id) -{ - AUD_ID_ENUM id = MAX_RECORD_NUM; +extern "C" int app_voice_stop(APP_STATUS_INDICATION_T status, + uint8_t device_id) { + AUD_ID_ENUM id = MAX_RECORD_NUM; - TRACE(2,"%s %d", __func__, status); + TRACE(2, "%s %d", __func__, status); - if (status == APP_STATUS_INDICATION_FIND_MY_BUDS) - id = AUDIO_ID_FIND_MY_BUDS; + if (status == APP_STATUS_INDICATION_FIND_MY_BUDS) + id = AUDIO_ID_FIND_MY_BUDS; - if (id != MAX_RECORD_NUM) - trigger_media_stop(id, device_id); + if (id != MAX_RECORD_NUM) + trigger_media_stop(id, device_id); - return 0; + return 0; } #endif -#if 1//!defined(BLE_ONLY_ENABLED) +#if 1 //! defined(BLE_ONLY_ENABLED) -static void app_poweron_normal(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); - g_pwron_case = APP_POWERON_CASE_NORMAL; +static void app_poweron_normal(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); + g_pwron_case = APP_POWERON_CASE_NORMAL; - signal_send_to_main_thread(0x2); + signal_send_to_main_thread(0x2); } -static void app_poweron_scan(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); - g_pwron_case = APP_POWERON_CASE_BOTHSCAN; +static void app_poweron_scan(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); + g_pwron_case = APP_POWERON_CASE_BOTHSCAN; - signal_send_to_main_thread(0x2); + signal_send_to_main_thread(0x2); } #endif -#if 0//def __ENGINEER_MODE_SUPPORT__ +#if 0 // def __ENGINEER_MODE_SUPPORT__ #if !defined(BLE_ONLY_ENABLED) static void app_poweron_factorymode(APP_KEY_STATUS *status, void *param) { @@ -635,184 +613,194 @@ static void app_poweron_factorymode(APP_KEY_STATUS *status, void *param) #ifndef __POWERKEY_CTRL_ONOFF_ONLY__ static bool g_pwron_finished = false; -static void app_poweron_finished(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); - g_pwron_finished = true; - signal_send_to_main_thread(0x2); +static void app_poweron_finished(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); + g_pwron_finished = true; + signal_send_to_main_thread(0x2); } #endif -void app_poweron_wait_finished(void) -{ +void app_poweron_wait_finished(void) { #ifndef __POWERKEY_CTRL_ONOFF_ONLY__ - if (!g_pwron_finished) + if (!g_pwron_finished) #endif - { - osSignalWait(0x2, osWaitForever); - } + { + osSignalWait(0x2, osWaitForever); + } } -#if defined(__POWERKEY_CTRL_ONOFF_ONLY__) +#if defined(__POWERKEY_CTRL_ONOFF_ONLY__) void app_bt_key_shutdown(APP_KEY_STATUS *status, void *param); -const APP_KEY_HANDLE pwron_key_handle_cfg[] = { - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_UP}, "power on: shutdown" , app_bt_key_shutdown, NULL}, +const APP_KEY_HANDLE pwron_key_handle_cfg[] = { + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_UP}, + "power on: shutdown", + app_bt_key_shutdown, + NULL}, }; #elif defined(__ENGINEER_MODE_SUPPORT__) -const APP_KEY_HANDLE pwron_key_handle_cfg[] = { - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_INITUP}, "power on: normal" , app_poweron_normal, NULL}, +const APP_KEY_HANDLE pwron_key_handle_cfg[] = { + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_INITUP}, + "power on: normal", + app_poweron_normal, + NULL}, #if !defined(BLE_ONLY_ENABLED) - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_INITLONGPRESS}, "power on: both scan" , app_poweron_scan , NULL}, -// {{APP_KEY_CODE_PWR,APP_KEY_EVENT_INITLONGLONGPRESS},"power on: factory mode", app_poweron_factorymode , NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_INITLONGPRESS}, + "power on: both scan", + app_poweron_scan, + NULL}, +// {{APP_KEY_CODE_PWR,APP_KEY_EVENT_INITLONGLONGPRESS},"power on: factory +// mode", app_poweron_factorymode , NULL}, #endif - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_INITFINISHED}, "power on: finished" , app_poweron_finished , NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_INITFINISHED}, + "power on: finished", + app_poweron_finished, + NULL}, }; #else -const APP_KEY_HANDLE pwron_key_handle_cfg[] = { - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_INITUP}, "power on: normal" , app_poweron_normal, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_INITLONGPRESS}, "power on: both scan" , app_poweron_scan , NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_INITFINISHED}, "power on: finished" , app_poweron_finished , NULL}, +const APP_KEY_HANDLE pwron_key_handle_cfg[] = { + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_INITUP}, + "power on: normal", + app_poweron_normal, + NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_INITLONGPRESS}, + "power on: both scan", + app_poweron_scan, + NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_INITFINISHED}, + "power on: finished", + app_poweron_finished, + NULL}, }; #endif #ifndef APP_TEST_MODE -static void app_poweron_key_init(void) -{ - uint8_t i = 0; - TRACE(1,"%s",__func__); +static void app_poweron_key_init(void) { + uint8_t i = 0; + TRACE(1, "%s", __func__); - for (i=0; i<(sizeof(pwron_key_handle_cfg)/sizeof(APP_KEY_HANDLE)); i++){ - app_key_handle_registration(&pwron_key_handle_cfg[i]); - } + for (i = 0; i < (sizeof(pwron_key_handle_cfg) / sizeof(APP_KEY_HANDLE)); + i++) { + app_key_handle_registration(&pwron_key_handle_cfg[i]); + } } -static uint8_t app_poweron_wait_case(void) -{ +static uint8_t app_poweron_wait_case(void) { #ifdef __POWERKEY_CTRL_ONOFF_ONLY__ - g_pwron_case = APP_POWERON_CASE_NORMAL; + g_pwron_case = APP_POWERON_CASE_NORMAL; #else - uint32_t stime = 0, etime = 0; + uint32_t stime = 0, etime = 0; - TRACE(1,"poweron_wait_case enter:%d", g_pwron_case); - if (g_pwron_case == APP_POWERON_CASE_INVALID){ - stime = hal_sys_timer_get(); - osSignalWait(0x2, POWERON_PRESSMAXTIME_THRESHOLD_MS); - etime = hal_sys_timer_get(); - } - TRACE(2,"powon raw case:%d time:%d", g_pwron_case, TICKS_TO_MS(etime - stime)); + TRACE(1, "poweron_wait_case enter:%d", g_pwron_case); + if (g_pwron_case == APP_POWERON_CASE_INVALID) { + stime = hal_sys_timer_get(); + osSignalWait(0x2, POWERON_PRESSMAXTIME_THRESHOLD_MS); + etime = hal_sys_timer_get(); + } + TRACE(2, "powon raw case:%d time:%d", g_pwron_case, + TICKS_TO_MS(etime - stime)); #endif - return g_pwron_case; - + return g_pwron_case; } #endif -static void app_wait_stack_ready(void) -{ - uint32_t stime, etime; - stime = hal_sys_timer_get(); - osSignalWait(0x3, 1000); - etime = hal_sys_timer_get(); - TRACE(1,"app_wait_stack_ready: wait:%d ms", TICKS_TO_MS(etime - stime)); +static void app_wait_stack_ready(void) { + uint32_t stime, etime; + stime = hal_sys_timer_get(); + osSignalWait(0x3, 1000); + etime = hal_sys_timer_get(); + TRACE(1, "app_wait_stack_ready: wait:%d ms", TICKS_TO_MS(etime - stime)); - app_stack_ready_cb(); + app_stack_ready_cb(); } extern "C" int system_shutdown(void); -int app_shutdown(void) -{ - system_shutdown(); - return 0; +int app_shutdown(void) { + system_shutdown(); + return 0; } int system_reset(void); -int app_reset(void) -{ - system_reset(); - return 0; +int app_reset(void) { + system_reset(); + return 0; } static void app_postponed_reset_timer_handler(void const *param); osTimerDef(APP_POSTPONED_RESET_TIMER, app_postponed_reset_timer_handler); static osTimerId app_postponed_reset_timer = NULL; -#define APP_RESET_PONTPONED_TIME_IN_MS 2000 -static void app_postponed_reset_timer_handler(void const *param) -{ -// hal_cmu_sys_reboot(); - app_reset(); +#define APP_RESET_PONTPONED_TIME_IN_MS 2000 +static void app_postponed_reset_timer_handler(void const *param) { + // hal_cmu_sys_reboot(); + app_reset(); } -void app_start_postponed_reset(void) -{ - if (NULL == app_postponed_reset_timer) - { - app_postponed_reset_timer = osTimerCreate(osTimer(APP_POSTPONED_RESET_TIMER), osTimerOnce, NULL); - } +void app_start_postponed_reset(void) { + if (NULL == app_postponed_reset_timer) { + app_postponed_reset_timer = + osTimerCreate(osTimer(APP_POSTPONED_RESET_TIMER), osTimerOnce, NULL); + } - hal_sw_bootmode_set(HAL_SW_BOOTMODE_ENTER_HIDE_BOOT); + hal_sw_bootmode_set(HAL_SW_BOOTMODE_ENTER_HIDE_BOOT); - osTimerStart(app_postponed_reset_timer, APP_RESET_PONTPONED_TIME_IN_MS); + osTimerStart(app_postponed_reset_timer, APP_RESET_PONTPONED_TIME_IN_MS); } -void app_bt_key_shutdown(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); +void app_bt_key_shutdown(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); #ifdef __POWERKEY_CTRL_ONOFF_ONLY__ - hal_sw_bootmode_clear(HAL_SW_BOOTMODE_REBOOT); - app_reset(); + hal_sw_bootmode_clear(HAL_SW_BOOTMODE_REBOOT); + app_reset(); #else - app_shutdown(); + app_shutdown(); #endif } -void app_bt_key_enter_testmode(APP_KEY_STATUS *status, void *param) -{ - TRACE(1,"%s\n",__FUNCTION__); +void app_bt_key_enter_testmode(APP_KEY_STATUS *status, void *param) { + TRACE(1, "%s\n", __FUNCTION__); - if(app_status_indication_get() == APP_STATUS_INDICATION_BOTHSCAN){ + if (app_status_indication_get() == APP_STATUS_INDICATION_BOTHSCAN) { #ifdef __FACTORY_MODE_SUPPORT__ - app_factorymode_bt_signalingtest(status, param); + app_factorymode_bt_signalingtest(status, param); #endif - } + } } -void app_bt_key_enter_nosignal_mode(APP_KEY_STATUS *status, void *param) -{ - TRACE(1,"%s\n",__FUNCTION__); - if(app_status_indication_get() == APP_STATUS_INDICATION_BOTHSCAN){ +void app_bt_key_enter_nosignal_mode(APP_KEY_STATUS *status, void *param) { + TRACE(1, "%s\n", __FUNCTION__); + if (app_status_indication_get() == APP_STATUS_INDICATION_BOTHSCAN) { #ifdef __FACTORY_MODE_SUPPORT__ - app_factorymode_bt_nosignalingtest(status, param); + app_factorymode_bt_nosignalingtest(status, param); #endif - } + } } extern "C" void OS_NotifyEvm(void); -#define PRESS_KEY_TO_ENTER_OTA_INTERVEL (15000) // press key 15s enter to ota -#define PRESS_KEY_TO_ENTER_OTA_REPEAT_CNT ((PRESS_KEY_TO_ENTER_OTA_INTERVEL - 2000) / 500) -void app_otaMode_enter(APP_KEY_STATUS *status, void *param) -{ - TRACE(1,"%s",__func__); +#define PRESS_KEY_TO_ENTER_OTA_INTERVEL (15000) // press key 15s enter to ota +#define PRESS_KEY_TO_ENTER_OTA_REPEAT_CNT \ + ((PRESS_KEY_TO_ENTER_OTA_INTERVEL - 2000) / 500) +void app_otaMode_enter(APP_KEY_STATUS *status, void *param) { + TRACE(1, "%s", __func__); - hal_norflash_disable_protection(HAL_NORFLASH_ID_0); + hal_norflash_disable_protection(HAL_NORFLASH_ID_0); - hal_sw_bootmode_set(HAL_SW_BOOTMODE_ENTER_HIDE_BOOT); + hal_sw_bootmode_set(HAL_SW_BOOTMODE_ENTER_HIDE_BOOT); #ifdef __KMATE106__ - app_status_indication_set(APP_STATUS_INDICATION_OTA); - app_voice_report(APP_STATUS_INDICATION_WARNING, 0); - osDelay(1200); + app_status_indication_set(APP_STATUS_INDICATION_OTA); + app_voice_report(APP_STATUS_INDICATION_WARNING, 0); + osDelay(1200); #endif - hal_cmu_sys_reboot(); + hal_cmu_sys_reboot(); } #ifdef __USB_COMM__ -void app_usb_cdc_comm_key_handler(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d", __func__, status->code, status->event); - hal_sw_bootmode_clear(HAL_SW_BOOTMODE_REBOOT); - hal_sw_bootmode_set(HAL_SW_BOOTMODE_CDC_COMM); - pmu_usb_config(PMU_USB_CONFIG_TYPE_DEVICE); - hal_cmu_reset_set(HAL_CMU_MOD_GLOBAL); +void app_usb_cdc_comm_key_handler(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); + hal_sw_bootmode_clear(HAL_SW_BOOTMODE_REBOOT); + hal_sw_bootmode_set(HAL_SW_BOOTMODE_CDC_COMM); + pmu_usb_config(PMU_USB_CONFIG_TYPE_DEVICE); + hal_cmu_reset_set(HAL_CMU_MOD_GLOBAL); } #endif @@ -826,258 +814,232 @@ void app_dfu_key_handler(APP_KEY_STATUS *status, void *param) hal_cmu_reset_set(HAL_CMU_MOD_GLOBAL); } #else -void app_dfu_key_handler(APP_KEY_STATUS *status, void *param) -{ - TRACE(1,"%s ",__func__); - hal_sw_bootmode_clear(0xffffffff); - hal_sw_bootmode_set(HAL_SW_BOOTMODE_FORCE_USB_DLD | HAL_SW_BOOTMODE_SKIP_FLASH_BOOT); - pmu_usb_config(PMU_USB_CONFIG_TYPE_DEVICE); - hal_cmu_reset_set(HAL_CMU_MOD_GLOBAL); +void app_dfu_key_handler(APP_KEY_STATUS *status, void *param) { + TRACE(1, "%s ", __func__); + hal_sw_bootmode_clear(0xffffffff); + hal_sw_bootmode_set(HAL_SW_BOOTMODE_FORCE_USB_DLD | + HAL_SW_BOOTMODE_SKIP_FLASH_BOOT); + pmu_usb_config(PMU_USB_CONFIG_TYPE_DEVICE); + hal_cmu_reset_set(HAL_CMU_MOD_GLOBAL); } #endif -void app_ota_key_handler(APP_KEY_STATUS *status, void *param) -{ - static uint32_t time = hal_sys_timer_get(); - static uint16_t cnt = 0; +void app_ota_key_handler(APP_KEY_STATUS *status, void *param) { + static uint32_t time = hal_sys_timer_get(); + static uint16_t cnt = 0; - TRACE(3,"%s %d,%d",__func__, status->code, status->event); + TRACE(3, "%s %d,%d", __func__, status->code, status->event); - if (TICKS_TO_MS(hal_sys_timer_get() - time) > 600) // 600 = (repeat key intervel)500 + (margin)100 - cnt = 0; - else - cnt++; + if (TICKS_TO_MS(hal_sys_timer_get() - time) > + 600) // 600 = (repeat key intervel)500 + (margin)100 + cnt = 0; + else + cnt++; - if (cnt == PRESS_KEY_TO_ENTER_OTA_REPEAT_CNT) { - app_otaMode_enter(NULL, NULL); - } + if (cnt == PRESS_KEY_TO_ENTER_OTA_REPEAT_CNT) { + app_otaMode_enter(NULL, NULL); + } - time = hal_sys_timer_get(); + time = hal_sys_timer_get(); } -extern "C" void app_bt_key(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); +extern "C" void app_bt_key(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); #define DEBUG_CODE_USE 0 - switch(status->event) - { - case APP_KEY_EVENT_CLICK: - TRACE(0,"first blood!"); + switch (status->event) { + case APP_KEY_EVENT_CLICK: + TRACE(0, "first blood!"); #if DEBUG_CODE_USE - if (status->code == APP_KEY_CODE_PWR) - { + if (status->code == APP_KEY_CODE_PWR) { #ifdef __INTERCONNECTION__ - // add favorite music - // app_interconnection_handle_favorite_music_through_ccmp(1); + // add favorite music + // app_interconnection_handle_favorite_music_through_ccmp(1); - // ask for ota update - ota_update_request(); - return; + // ask for ota update + ota_update_request(); + return; #else - static int m = 0; - if (m == 0) { - m = 1; - hal_iomux_set_analog_i2c(); - } - else { - m = 0; - hal_iomux_set_uart0(); - } + static int m = 0; + if (m == 0) { + m = 1; + hal_iomux_set_analog_i2c(); + } else { + m = 0; + hal_iomux_set_uart0(); + } #endif - } + } #endif - break; - case APP_KEY_EVENT_DOUBLECLICK: - TRACE(0,"double kill"); + break; + case APP_KEY_EVENT_DOUBLECLICK: + TRACE(0, "double kill"); #if DEBUG_CODE_USE - if (status->code == APP_KEY_CODE_PWR) - { + if (status->code == APP_KEY_CODE_PWR) { #ifdef __INTERCONNECTION__ - // play favorite music - app_interconnection_handle_favorite_music_through_ccmp(2); + // play favorite music + app_interconnection_handle_favorite_music_through_ccmp(2); #else - app_otaMode_enter(NULL, NULL); + app_otaMode_enter(NULL, NULL); #endif - return; - } + return; + } #endif - break; - case APP_KEY_EVENT_TRIPLECLICK: - TRACE(0,"triple kill"); - if (status->code == APP_KEY_CODE_PWR) - { + break; + case APP_KEY_EVENT_TRIPLECLICK: + TRACE(0, "triple kill"); + if (status->code == APP_KEY_CODE_PWR) { #ifndef __BT_ONE_BRING_TWO__ - if(btif_me_get_activeCons() < 1){ + if (btif_me_get_activeCons() < 1) { #else - if(btif_me_get_activeCons() < 2){ + if (btif_me_get_activeCons() < 2) { #endif - app_bt_accessmode_set(BTIF_BT_DEFAULT_ACCESS_MODE_PAIR); + app_bt_accessmode_set(BTIF_BT_DEFAULT_ACCESS_MODE_PAIR); #ifdef __INTERCONNECTION__ - app_interceonnection_start_discoverable_adv(INTERCONNECTION_BLE_FAST_ADVERTISING_INTERVAL, - APP_INTERCONNECTION_FAST_ADV_TIMEOUT_IN_MS); - return; + app_interceonnection_start_discoverable_adv( + INTERCONNECTION_BLE_FAST_ADVERTISING_INTERVAL, + APP_INTERCONNECTION_FAST_ADV_TIMEOUT_IN_MS); + return; #endif #ifdef GFPS_ENABLED - app_enter_fastpairing_mode(); + app_enter_fastpairing_mode(); #endif - app_voice_report(APP_STATUS_INDICATION_BOTHSCAN,0); - } - return; - } - break; - case APP_KEY_EVENT_ULTRACLICK: - TRACE(0,"ultra kill"); - break; - case APP_KEY_EVENT_RAMPAGECLICK: - TRACE(0,"rampage kill!you are crazy!"); - break; - - case APP_KEY_EVENT_UP: - break; + app_voice_report(APP_STATUS_INDICATION_BOTHSCAN, 0); + } + return; } -#if 0//def __FACTORY_MODE_SUPPORT__ + break; + case APP_KEY_EVENT_ULTRACLICK: + TRACE(0, "ultra kill"); + break; + case APP_KEY_EVENT_RAMPAGECLICK: + TRACE(0, "rampage kill!you are crazy!"); + break; + + case APP_KEY_EVENT_UP: + break; + } +#if 0 // def __FACTORY_MODE_SUPPORT__ if (app_status_indication_get() == APP_STATUS_INDICATION_BOTHSCAN && (status->event == APP_KEY_EVENT_DOUBLECLICK)){ app_factorymode_languageswitch_proc(); }else #endif - { + { #ifdef __SUPPORT_ANC_SINGLE_MODE_WITHOUT_BT__ - if(!anc_single_mode_on) + if (!anc_single_mode_on) #endif - bt_key_send(status); - } + bt_key_send(status); + } } #ifdef RB_CODEC -extern bool app_rbcodec_check_hfp_active(void ); -void app_switch_player_key(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); +extern bool app_rbcodec_check_hfp_active(void); +void app_switch_player_key(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); - if(!rb_ctl_is_init_done()) { - TRACE(0,"rb ctl not init done"); - return ; - } + if (!rb_ctl_is_init_done()) { + TRACE(0, "rb ctl not init done"); + return; + } - if( app_rbcodec_check_hfp_active() ) { - app_bt_key(status,param); - return; - } + if (app_rbcodec_check_hfp_active()) { + app_bt_key(status, param); + return; + } - app_rbplay_audio_reset_pause_status(); - - if(app_rbplay_mode_switch()) { - app_voice_report(APP_STATUS_INDICATION_POWERON, 0); - app_rbcodec_ctr_play_onoff(true); - } else { - app_rbcodec_ctr_play_onoff(false); - app_voice_report(APP_STATUS_INDICATION_POWEROFF, 0); - } - return ; + app_rbplay_audio_reset_pause_status(); + if (app_rbplay_mode_switch()) { + app_voice_report(APP_STATUS_INDICATION_POWERON, 0); + app_rbcodec_ctr_play_onoff(true); + } else { + app_rbcodec_ctr_play_onoff(false); + app_voice_report(APP_STATUS_INDICATION_POWEROFF, 0); + } + return; } #endif -void app_voice_assistant_key(APP_KEY_STATUS *status, void *param) -{ - TRACE(2,"%s event %d", __func__, status->event); +void app_voice_assistant_key(APP_KEY_STATUS *status, void *param) { + TRACE(2, "%s event %d", __func__, status->event); #if defined(BISTO_ENABLED) || defined(__AI_VOICE__) - if (app_ai_manager_is_in_multi_ai_mode()) - { - if (app_ai_manager_spec_get_status_is_in_invalid()) { - TRACE(0,"AI feature has been diabled"); - return; - } + if (app_ai_manager_is_in_multi_ai_mode()) { + if (app_ai_manager_spec_get_status_is_in_invalid()) { + TRACE(0, "AI feature has been diabled"); + return; + } #ifdef MAI_TYPE_REBOOT_WITHOUT_OEM_APP - if (app_ai_manager_get_spec_update_flag()) { - TRACE(0,"device reboot is ongoing..."); - return; - } -#endif - - if (app_ai_manager_is_need_reboot()) - { - TRACE(1, "%s ai need to reboot", __func__); - return; - } - - if(app_ai_manager_voicekey_is_enable()) { - if (AI_SPEC_GSOUND == app_ai_manager_get_current_spec()) { -#ifdef BISTO_ENABLED - gsound_custom_actions_handle_key(status, param); -#endif - } else if(AI_SPEC_INIT != app_ai_manager_get_current_spec()) { - app_ai_key_event_handle(status, 0); - } - } + if (app_ai_manager_get_spec_update_flag()) { + TRACE(0, "device reboot is ongoing..."); + return; } - else - { - app_ai_key_event_handle(status, 0); -#if defined(BISTO_ENABLED) +#endif + + if (app_ai_manager_is_need_reboot()) { + TRACE(1, "%s ai need to reboot", __func__); + return; + } + + if (app_ai_manager_voicekey_is_enable()) { + if (AI_SPEC_GSOUND == app_ai_manager_get_current_spec()) { +#ifdef BISTO_ENABLED gsound_custom_actions_handle_key(status, param); #endif + } else if (AI_SPEC_INIT != app_ai_manager_get_current_spec()) { + app_ai_key_event_handle(status, 0); + } } + } else { + app_ai_key_event_handle(status, 0); +#if defined(BISTO_ENABLED) + gsound_custom_actions_handle_key(status, param); +#endif + } #endif } #ifdef IS_MULTI_AI_ENABLED -void app_voice_gva_onoff_key(APP_KEY_STATUS *status, void *param) -{ - uint8_t current_ai_spec = app_ai_manager_get_current_spec(); +void app_voice_gva_onoff_key(APP_KEY_STATUS *status, void *param) { + uint8_t current_ai_spec = app_ai_manager_get_current_spec(); - TRACE(2,"%s current_ai_spec %d", __func__, current_ai_spec); - if (current_ai_spec == AI_SPEC_INIT) - { - app_ai_manager_enable(true, AI_SPEC_GSOUND); - } - else if(current_ai_spec == AI_SPEC_GSOUND) - { - app_ai_manager_enable(false, AI_SPEC_GSOUND); - } - else if(current_ai_spec == AI_SPEC_AMA) - { - app_ai_manager_switch_spec(AI_SPEC_GSOUND); - } - app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); + TRACE(2, "%s current_ai_spec %d", __func__, current_ai_spec); + if (current_ai_spec == AI_SPEC_INIT) { + app_ai_manager_enable(true, AI_SPEC_GSOUND); + } else if (current_ai_spec == AI_SPEC_GSOUND) { + app_ai_manager_enable(false, AI_SPEC_GSOUND); + } else if (current_ai_spec == AI_SPEC_AMA) { + app_ai_manager_switch_spec(AI_SPEC_GSOUND); + } + app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); } -void app_voice_ama_onoff_key(APP_KEY_STATUS *status, void *param) -{ - uint8_t current_ai_spec = app_ai_manager_get_current_spec(); +void app_voice_ama_onoff_key(APP_KEY_STATUS *status, void *param) { + uint8_t current_ai_spec = app_ai_manager_get_current_spec(); - TRACE(2,"%s current_ai_spec %d", __func__, current_ai_spec); - if (current_ai_spec == AI_SPEC_INIT) - { - app_ai_manager_enable(true, AI_SPEC_AMA); - } - else if(current_ai_spec == AI_SPEC_AMA) - { - app_ai_manager_enable(false, AI_SPEC_AMA); - } - else if(current_ai_spec == AI_SPEC_GSOUND) - { - app_ai_manager_switch_spec(AI_SPEC_AMA); - } - app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); + TRACE(2, "%s current_ai_spec %d", __func__, current_ai_spec); + if (current_ai_spec == AI_SPEC_INIT) { + app_ai_manager_enable(true, AI_SPEC_AMA); + } else if (current_ai_spec == AI_SPEC_AMA) { + app_ai_manager_enable(false, AI_SPEC_AMA); + } else if (current_ai_spec == AI_SPEC_GSOUND) { + app_ai_manager_switch_spec(AI_SPEC_AMA); + } + app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); } #endif #if defined(BT_USB_AUDIO_DUAL_MODE_TEST) && defined(BT_USB_AUDIO_DUAL_MODE) extern "C" void test_btusb_switch(void); -void app_btusb_audio_dual_mode_test(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"test_btusb_switch"); - test_btusb_switch(); +void app_btusb_audio_dual_mode_test(APP_KEY_STATUS *status, void *param) { + TRACE(0, "test_btusb_switch"); + test_btusb_switch(); } #endif extern void switch_dualmic_status(void); -void app_switch_dualmic_key(APP_KEY_STATUS *status, void *param) -{ - switch_dualmic_status(); +void app_switch_dualmic_key(APP_KEY_STATUS *status, void *param) { + switch_dualmic_status(); } #ifdef POWERKEY_I2C_SWITCH @@ -1090,32 +1052,80 @@ extern "C" void app_tile_key_handler(APP_KEY_STATUS *status, void *param); #ifdef __POWERKEY_CTRL_ONOFF_ONLY__ #if defined(__APP_KEY_FN_STYLE_A__) -const APP_KEY_HANDLE app_key_handle_cfg[] = { - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_UP},"bt function key",app_bt_key_shutdown, NULL}, - {{APP_KEY_CODE_FN1,APP_KEY_EVENT_LONGPRESS},"bt function key",app_bt_key, NULL}, - {{APP_KEY_CODE_FN1,APP_KEY_EVENT_UP},"bt function key",app_bt_key, NULL}, - {{APP_KEY_CODE_FN1,APP_KEY_EVENT_DOUBLECLICK},"bt function key",app_bt_key, NULL}, - {{APP_KEY_CODE_FN2,APP_KEY_EVENT_UP},"bt volume up key",app_bt_key, NULL}, - {{APP_KEY_CODE_FN2,APP_KEY_EVENT_LONGPRESS},"bt play backward key",app_bt_key, NULL}, - {{APP_KEY_CODE_FN3,APP_KEY_EVENT_UP},"bt volume down key",app_bt_key, NULL}, - {{APP_KEY_CODE_FN3,APP_KEY_EVENT_LONGPRESS},"bt play forward key",app_bt_key, NULL}, +const APP_KEY_HANDLE app_key_handle_cfg[] = { + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_UP}, + "bt function key", + app_bt_key_shutdown, + NULL}, + {{APP_KEY_CODE_FN1, APP_KEY_EVENT_LONGPRESS}, + "bt function key", + app_bt_key, + NULL}, + {{APP_KEY_CODE_FN1, APP_KEY_EVENT_UP}, "bt function key", app_bt_key, NULL}, + {{APP_KEY_CODE_FN1, APP_KEY_EVENT_DOUBLECLICK}, + "bt function key", + app_bt_key, + NULL}, + {{APP_KEY_CODE_FN2, APP_KEY_EVENT_UP}, + "bt volume up key", + app_bt_key, + NULL}, + {{APP_KEY_CODE_FN2, APP_KEY_EVENT_LONGPRESS}, + "bt play backward key", + app_bt_key, + NULL}, + {{APP_KEY_CODE_FN3, APP_KEY_EVENT_UP}, + "bt volume down key", + app_bt_key, + NULL}, + {{APP_KEY_CODE_FN3, APP_KEY_EVENT_LONGPRESS}, + "bt play forward key", + app_bt_key, + NULL}, #ifdef SUPPORT_SIRI - {{APP_KEY_CODE_NONE ,APP_KEY_EVENT_NONE},"none function key",app_bt_key, NULL}, + {{APP_KEY_CODE_NONE, APP_KEY_EVENT_NONE}, + "none function key", + app_bt_key, + NULL}, #endif }; -#else //#elif defined(__APP_KEY_FN_STYLE_B__) -const APP_KEY_HANDLE app_key_handle_cfg[] = { - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_UP},"bt function key",app_bt_key_shutdown, NULL}, - {{APP_KEY_CODE_FN1,APP_KEY_EVENT_LONGPRESS},"bt function key",app_bt_key, NULL}, - {{APP_KEY_CODE_FN1,APP_KEY_EVENT_UP},"bt function key",app_bt_key, NULL}, - {{APP_KEY_CODE_FN1,APP_KEY_EVENT_DOUBLECLICK},"bt function key",app_bt_key, NULL}, - {{APP_KEY_CODE_FN2,APP_KEY_EVENT_REPEAT},"bt volume up key",app_bt_key, NULL}, - {{APP_KEY_CODE_FN2,APP_KEY_EVENT_UP},"bt play backward key",app_bt_key, NULL}, - {{APP_KEY_CODE_FN3,APP_KEY_EVENT_REPEAT},"bt volume down key",app_bt_key, NULL}, - {{APP_KEY_CODE_FN3,APP_KEY_EVENT_UP},"bt play forward key",app_bt_key, NULL}, +#else // #elif defined(__APP_KEY_FN_STYLE_B__) +const APP_KEY_HANDLE app_key_handle_cfg[] = { + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_UP}, + "bt function key", + app_bt_key_shutdown, + NULL}, + {{APP_KEY_CODE_FN1, APP_KEY_EVENT_LONGPRESS}, + "bt function key", + app_bt_key, + NULL}, + {{APP_KEY_CODE_FN1, APP_KEY_EVENT_UP}, "bt function key", app_bt_key, NULL}, + {{APP_KEY_CODE_FN1, APP_KEY_EVENT_DOUBLECLICK}, + "bt function key", + app_bt_key, + NULL}, + {{APP_KEY_CODE_FN2, APP_KEY_EVENT_REPEAT}, + "bt volume up key", + app_bt_key, + NULL}, + {{APP_KEY_CODE_FN2, APP_KEY_EVENT_UP}, + "bt play backward key", + app_bt_key, + NULL}, + {{APP_KEY_CODE_FN3, APP_KEY_EVENT_REPEAT}, + "bt volume down key", + app_bt_key, + NULL}, + {{APP_KEY_CODE_FN3, APP_KEY_EVENT_UP}, + "bt play forward key", + app_bt_key, + NULL}, #ifdef SUPPORT_SIRI - {{APP_KEY_CODE_NONE ,APP_KEY_EVENT_NONE},"none function key",app_bt_key, NULL}, + {{APP_KEY_CODE_NONE, APP_KEY_EVENT_NONE}, + "none function key", + app_bt_key, + NULL}, #endif }; @@ -1123,148 +1133,281 @@ const APP_KEY_HANDLE app_key_handle_cfg[] = { #else #if defined(__APP_KEY_FN_STYLE_A__) //-- -const APP_KEY_HANDLE app_key_handle_cfg[] = { - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_LONGLONGPRESS},"bt function key",app_bt_key_shutdown, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_LONGPRESS},"bt function key",app_bt_key, NULL}, +const APP_KEY_HANDLE app_key_handle_cfg[] = { + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_LONGLONGPRESS}, + "bt function key", + app_bt_key_shutdown, + NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_LONGPRESS}, + "bt function key", + app_bt_key, + NULL}, #if defined(BT_USB_AUDIO_DUAL_MODE_TEST) && defined(BT_USB_AUDIO_DUAL_MODE) - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_CLICK},"bt function key",app_bt_key, NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_CLICK}, + "bt function key", + app_bt_key, + NULL}, #ifdef RB_CODEC - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_CLICK},"bt function key",app_switch_player_key, NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_CLICK}, + "bt function key", + app_switch_player_key, + NULL}, #else - //{{APP_KEY_CODE_PWR,APP_KEY_EVENT_CLICK},"btusb mode switch key.",app_btusb_audio_dual_mode_test, NULL}, +//{{APP_KEY_CODE_PWR,APP_KEY_EVENT_CLICK},"btusb mode switch +// key.",app_btusb_audio_dual_mode_test, NULL}, #endif #endif - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_DOUBLECLICK},"bt function key",app_bt_key, NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_DOUBLECLICK}, + "bt function key", + app_bt_key, + NULL}, #ifdef TILE_DATAPATH - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_TRIPLECLICK},"bt function key",app_tile_key_handler, NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_TRIPLECLICK}, + "bt function key", + app_tile_key_handler, + NULL}, #else - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_TRIPLECLICK},"bt function key",app_bt_key, NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_TRIPLECLICK}, + "bt function key", + app_bt_key, + NULL}, #endif #if RAMPAGECLICK_TEST_MODE - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_ULTRACLICK},"bt function key",app_bt_key_enter_nosignal_mode, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_RAMPAGECLICK},"bt function key",app_bt_key_enter_testmode, NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_ULTRACLICK}, + "bt function key", + app_bt_key_enter_nosignal_mode, + NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_RAMPAGECLICK}, + "bt function key", + app_bt_key_enter_testmode, + NULL}, #endif #ifdef POWERKEY_I2C_SWITCH - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_RAMPAGECLICK},"bt i2c key",app_factorymode_i2c_switch, NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_RAMPAGECLICK}, + "bt i2c key", + app_factorymode_i2c_switch, + NULL}, #endif - //{{APP_KEY_CODE_FN1,APP_KEY_EVENT_UP},"bt volume up key",app_bt_key, NULL}, - //{{APP_KEY_CODE_FN1,APP_KEY_EVENT_LONGPRESS},"bt play backward key",app_bt_key, NULL}, -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) - {{APP_KEY_CODE_FN1,APP_KEY_EVENT_DOUBLECLICK},"bt mode src snk key",app_bt_key, NULL}, +//{{APP_KEY_CODE_FN1,APP_KEY_EVENT_UP},"bt volume up key",app_bt_key, NULL}, +//{{APP_KEY_CODE_FN1,APP_KEY_EVENT_LONGPRESS},"bt play backward key",app_bt_key, +// NULL}, +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) + {{APP_KEY_CODE_FN1, APP_KEY_EVENT_DOUBLECLICK}, + "bt mode src snk key", + app_bt_key, + NULL}, #endif - //{{APP_KEY_CODE_FN2,APP_KEY_EVENT_UP},"bt volume down key",app_bt_key, NULL}, - //{{APP_KEY_CODE_FN2,APP_KEY_EVENT_LONGPRESS},"bt play forward key",app_bt_key, NULL}, - //{{APP_KEY_CODE_FN15,APP_KEY_EVENT_UP},"bt volume down key",app_bt_key, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_CLICK},"bt function key",app_bt_key, NULL}, + //{{APP_KEY_CODE_FN2,APP_KEY_EVENT_UP},"bt volume down key",app_bt_key, NULL}, + //{{APP_KEY_CODE_FN2,APP_KEY_EVENT_LONGPRESS},"bt play forward + // key",app_bt_key, NULL}, + //{{APP_KEY_CODE_FN15,APP_KEY_EVENT_UP},"bt volume down key",app_bt_key, + // NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_CLICK}, + "bt function key", + app_bt_key, + NULL}, #ifdef SUPPORT_SIRI - {{APP_KEY_CODE_NONE ,APP_KEY_EVENT_NONE},"none function key",app_bt_key, NULL}, + {{APP_KEY_CODE_NONE, APP_KEY_EVENT_NONE}, + "none function key", + app_bt_key, + NULL}, #endif -#if defined( __BT_ANC_KEY__)&&defined(ANC_APP) +#if defined(__BT_ANC_KEY__) && defined(ANC_APP) #if defined(IBRT) - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_CLICK},"bt anc key",app_anc_key, NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_CLICK}, "bt anc key", app_anc_key, NULL}, #else - {{APP_KEY_CODE_FN2,APP_KEY_EVENT_CLICK},"bt anc key",app_anc_key, NULL}, + {{APP_KEY_CODE_FN2, APP_KEY_EVENT_CLICK}, "bt anc key", app_anc_key, NULL}, #endif #endif #ifdef TILE_DATAPATH - {{APP_KEY_CODE_TILE, APP_KEY_EVENT_DOWN}, "tile function key", app_tile_key_handler, NULL}, - {{APP_KEY_CODE_TILE, APP_KEY_EVENT_UP}, "tile function key", app_tile_key_handler, NULL}, + {{APP_KEY_CODE_TILE, APP_KEY_EVENT_DOWN}, + "tile function key", + app_tile_key_handler, + NULL}, + {{APP_KEY_CODE_TILE, APP_KEY_EVENT_UP}, + "tile function key", + app_tile_key_handler, + NULL}, #endif #if defined(VOICE_DATAPATH) || defined(__AI_VOICE__) - {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_FIRST_DOWN}, "google assistant key", app_voice_assistant_key, NULL}, -#if defined(IS_GSOUND_BUTTION_HANDLER_WORKAROUND_ENABLED) || defined(PUSH_AND_HOLD_ENABLED) || defined(__TENCENT_VOICE__) - {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_UP}, "google assistant key", app_voice_assistant_key, NULL}, + {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_FIRST_DOWN}, + "google assistant key", + app_voice_assistant_key, + NULL}, +#if defined(IS_GSOUND_BUTTION_HANDLER_WORKAROUND_ENABLED) || \ + defined(PUSH_AND_HOLD_ENABLED) || defined(__TENCENT_VOICE__) + {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_UP}, + "google assistant key", + app_voice_assistant_key, + NULL}, #endif - {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_UP_AFTER_LONGPRESS}, "google assistant key", app_voice_assistant_key, NULL}, - {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_LONGPRESS}, "google assistant key", app_voice_assistant_key, NULL}, - {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_CLICK}, "google assistant key", app_voice_assistant_key, NULL}, - {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_DOUBLECLICK}, "google assistant key", app_voice_assistant_key, NULL}, + {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_UP_AFTER_LONGPRESS}, + "google assistant key", + app_voice_assistant_key, + NULL}, + {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_LONGPRESS}, + "google assistant key", + app_voice_assistant_key, + NULL}, + {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_CLICK}, + "google assistant key", + app_voice_assistant_key, + NULL}, + {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_DOUBLECLICK}, + "google assistant key", + app_voice_assistant_key, + NULL}, #endif #ifdef IS_MULTI_AI_ENABLED - {{APP_KEY_CODE_FN13, APP_KEY_EVENT_CLICK}, "gva on-off key", app_voice_gva_onoff_key, NULL}, - {{APP_KEY_CODE_FN14, APP_KEY_EVENT_CLICK}, "ama on-off key", app_voice_ama_onoff_key, NULL}, + {{APP_KEY_CODE_FN13, APP_KEY_EVENT_CLICK}, + "gva on-off key", + app_voice_gva_onoff_key, + NULL}, + {{APP_KEY_CODE_FN14, APP_KEY_EVENT_CLICK}, + "ama on-off key", + app_voice_ama_onoff_key, + NULL}, #endif #if defined(BT_USB_AUDIO_DUAL_MODE_TEST) && defined(BT_USB_AUDIO_DUAL_MODE) - {{APP_KEY_CODE_FN15, APP_KEY_EVENT_CLICK}, "btusb mode switch key.", app_btusb_audio_dual_mode_test, NULL}, + {{APP_KEY_CODE_FN15, APP_KEY_EVENT_CLICK}, + "btusb mode switch key.", + app_btusb_audio_dual_mode_test, + NULL}, #endif }; -#else //#elif defined(__APP_KEY_FN_STYLE_B__) -const APP_KEY_HANDLE app_key_handle_cfg[] = { - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_LONGLONGPRESS},"bt function key",app_bt_key_shutdown, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_LONGPRESS},"bt function key",app_bt_key, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_CLICK},"bt function key",app_bt_key, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_DOUBLECLICK},"bt function key",app_bt_key, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_TRIPLECLICK},"bt function key",app_bt_key, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_ULTRACLICK},"bt function key",app_bt_key_enter_nosignal_mode, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_RAMPAGECLICK},"bt function key",app_bt_key_enter_testmode, NULL}, - {{APP_KEY_CODE_FN1,APP_KEY_EVENT_REPEAT},"bt volume up key",app_bt_key, NULL}, - {{APP_KEY_CODE_FN1,APP_KEY_EVENT_UP},"bt play backward key",app_bt_key, NULL}, - {{APP_KEY_CODE_FN2,APP_KEY_EVENT_REPEAT},"bt volume down key",app_bt_key, NULL}, - {{APP_KEY_CODE_FN2,APP_KEY_EVENT_UP},"bt play forward key",app_bt_key, NULL}, +#else // #elif defined(__APP_KEY_FN_STYLE_B__) +const APP_KEY_HANDLE app_key_handle_cfg[] = { + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_LONGLONGPRESS}, + "bt function key", + app_bt_key_shutdown, + NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_LONGPRESS}, + "bt function key", + app_bt_key, + NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_CLICK}, + "bt function key", + app_bt_key, + NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_DOUBLECLICK}, + "bt function key", + app_bt_key, + NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_TRIPLECLICK}, + "bt function key", + app_bt_key, + NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_ULTRACLICK}, + "bt function key", + app_bt_key_enter_nosignal_mode, + NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_RAMPAGECLICK}, + "bt function key", + app_bt_key_enter_testmode, + NULL}, + {{APP_KEY_CODE_FN1, APP_KEY_EVENT_REPEAT}, + "bt volume up key", + app_bt_key, + NULL}, + {{APP_KEY_CODE_FN1, APP_KEY_EVENT_UP}, + "bt play backward key", + app_bt_key, + NULL}, + {{APP_KEY_CODE_FN2, APP_KEY_EVENT_REPEAT}, + "bt volume down key", + app_bt_key, + NULL}, + {{APP_KEY_CODE_FN2, APP_KEY_EVENT_UP}, + "bt play forward key", + app_bt_key, + NULL}, #ifdef SUPPORT_SIRI - {{APP_KEY_CODE_NONE ,APP_KEY_EVENT_NONE},"none function key",app_bt_key, NULL}, + {{APP_KEY_CODE_NONE, APP_KEY_EVENT_NONE}, + "none function key", + app_bt_key, + NULL}, #endif - {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_FIRST_DOWN}, "google assistant key", app_voice_assistant_key, NULL}, -#if defined(IS_GSOUND_BUTTION_HANDLER_WORKAROUND_ENABLED) || defined(PUSH_AND_HOLD_ENABLED) - {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_UP}, "google assistant key", app_voice_assistant_key, NULL}, + {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_FIRST_DOWN}, + "google assistant key", + app_voice_assistant_key, + NULL}, +#if defined(IS_GSOUND_BUTTION_HANDLER_WORKAROUND_ENABLED) || \ + defined(PUSH_AND_HOLD_ENABLED) + {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_UP}, + "google assistant key", + app_voice_assistant_key, + NULL}, #endif - {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_UP_AFTER_LONGPRESS}, "google assistant key", app_voice_assistant_key, NULL}, - {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_LONGPRESS}, "google assistant key", app_voice_assistant_key, NULL}, - {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_CLICK}, "google assistant key", app_voice_assistant_key, NULL}, - {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_DOUBLECLICK}, "google assistant key", app_voice_assistant_key, NULL}, + {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_UP_AFTER_LONGPRESS}, + "google assistant key", + app_voice_assistant_key, + NULL}, + {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_LONGPRESS}, + "google assistant key", + app_voice_assistant_key, + NULL}, + {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_CLICK}, + "google assistant key", + app_voice_assistant_key, + NULL}, + {{APP_KEY_CODE_GOOGLE, APP_KEY_EVENT_DOUBLECLICK}, + "google assistant key", + app_voice_assistant_key, + NULL}, }; #endif #endif -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; extern uint8_t avrcp_get_media_status(void); /******************************delay_report_tone_timer*********************************************************/ APP_STATUS_INDICATION_T delay_report_tone_num = APP_STATUS_INDICATION_NUM; osTimerId delay_report_toneid = NULL; -void startdelay_report_tone(int ms,APP_STATUS_INDICATION_T status); +void startdelay_report_tone(int ms, APP_STATUS_INDICATION_T status); void stopdelay_report_tone(void); static void delay_report_tonefun(const void *); -osTimerDef(defdelay_report_tone,delay_report_tonefun); -void delay_report_toneinit(void) -{ - delay_report_toneid = osTimerCreate(osTimer(defdelay_report_tone),osTimerOnce,(void *)0); +osTimerDef(defdelay_report_tone, delay_report_tonefun); +void delay_report_toneinit(void) { + delay_report_toneid = + osTimerCreate(osTimer(defdelay_report_tone), osTimerOnce, (void *)0); } -static void delay_report_tonefun(const void *) -{ - TRACE(3,"\n\n!!!!!!enter %s,delay_report_tone_num = %d \n\n",__func__,delay_report_tone_num); - if(MobileLinkLose_reboot){ - return; - } - //static ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - //uint8_t default_mobileaddr[6] = {0x0,0x0,0x0,0x0,0x0,0x0}; - //DUMP8("%02x ", p_ibrt_ctrl->mobile_addr.address, 6); - //app_status_indication_set(APP_STATUS_INDICATION_TWS_CONNECTED); - if(Curr_Is_Master()){ - app_ibrt_sync_volume_info(); - } - if(delay_report_tone_num == APP_STATUS_INDICATION_DUDU){ - if(Curr_Is_Master()&&(avrcp_get_media_status() != 1)&&(app_bt_device.hfchan_call[BT_DEVICE_ID_1] == BTIF_HF_CALL_NONE)){ - app_voice_report(delay_report_tone_num,0); - /*if((!memcmp(default_mobileaddr,p_ibrt_ctrl->mobile_addr.address,6))&&(p_ibrt_ctrl->access_mode == 0x3)){ - TRACE(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - app_voice_report(APP_STATUS_INDICATION_BOTHSCAN,0); - }*/ - if((nv_record_get_paired_dev_count()==1)){ - app_voice_report(APP_STATUS_INDICATION_BOTHSCAN,0); - } - } - } - delay_report_tone_num = APP_STATUS_INDICATION_NUM; +static void delay_report_tonefun(const void *) { + TRACE(3, "\n\n!!!!!!enter %s,delay_report_tone_num = %d \n\n", __func__, + delay_report_tone_num); + if (MobileLinkLose_reboot) { + return; + } + // static ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + // uint8_t default_mobileaddr[6] = {0x0,0x0,0x0,0x0,0x0,0x0}; + // DUMP8("%02x ", p_ibrt_ctrl->mobile_addr.address, 6); + // app_status_indication_set(APP_STATUS_INDICATION_TWS_CONNECTED); + if (Curr_Is_Master()) { + app_ibrt_sync_volume_info(); + } + if (delay_report_tone_num == APP_STATUS_INDICATION_DUDU) { + if (Curr_Is_Master() && (avrcp_get_media_status() != 1) && + (app_bt_device.hfchan_call[BT_DEVICE_ID_1] == BTIF_HF_CALL_NONE)) { + app_voice_report(delay_report_tone_num, 0); + /*if((!memcmp(default_mobileaddr,p_ibrt_ctrl->mobile_addr.address,6))&&(p_ibrt_ctrl->access_mode + == 0x3)){ + TRACE(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); + app_voice_report(APP_STATUS_INDICATION_BOTHSCAN,0); + }*/ + if ((nv_record_get_paired_dev_count() == 1)) { + app_voice_report(APP_STATUS_INDICATION_BOTHSCAN, 0); + } + } + } + delay_report_tone_num = APP_STATUS_INDICATION_NUM; } -void startdelay_report_tone(int ms,APP_STATUS_INDICATION_T status) -{ - TRACE(3,"\n\n !!!!!!!!!!start %s\n\n",__func__); - delay_report_tone_num = status; - osTimerStart(delay_report_toneid,ms); +void startdelay_report_tone(int ms, APP_STATUS_INDICATION_T status) { + TRACE(3, "\n\n !!!!!!!!!!start %s\n\n", __func__); + delay_report_tone_num = status; + osTimerStart(delay_report_toneid, ms); } /********************************delay_report_tone_timer*******************************************************/ @@ -1276,85 +1419,77 @@ osTimerId low_latlatency_delay_switchid = NULL; void startlow_latlatency_delay_switch(int ms); void stoplow_latlatency_delay_switch(void); static void low_latlatency_delay_switchfun(const void *); -osTimerDef(deflow_latlatency_delay_switch,low_latlatency_delay_switchfun); -void low_latlatency_delay_switchinit(void) -{ - low_latlatency_delay_switchid = osTimerCreate(osTimer(deflow_latlatency_delay_switch),osTimerOnce,(void *)0); +osTimerDef(deflow_latlatency_delay_switch, low_latlatency_delay_switchfun); +void low_latlatency_delay_switchinit(void) { + low_latlatency_delay_switchid = osTimerCreate( + osTimer(deflow_latlatency_delay_switch), osTimerOnce, (void *)0); } -void app_ibrt_ui_test_mtu_change_sync_notify(void) -{ - extern volatile uint8_t avdtp_playback_delay_sbc_mtu; - extern volatile uint8_t avdtp_playback_delay_aac_mtu; +void app_ibrt_ui_test_mtu_change_sync_notify(void) { + extern volatile uint8_t avdtp_playback_delay_sbc_mtu; + extern volatile uint8_t avdtp_playback_delay_aac_mtu; - TRACE(3,"SWITC GAME MODE !!!latency_mode_is_open = %d###",latency_mode_is_open); - if(!latency_mode_is_open) - { - avdtp_playback_delay_sbc_mtu = 32; - avdtp_playback_delay_aac_mtu = 3; - app_ibrt_if_force_audio_retrigger_slave_sync(); - } - else - { - avdtp_playback_delay_sbc_mtu = 50; - avdtp_playback_delay_aac_mtu = 6; - app_ibrt_if_force_audio_retrigger_slave_sync(); - } - latency_mode_is_open = !latency_mode_is_open; - TRACE(3,"set SBC_MTU=%d AAC_MTU=%d\n", avdtp_playback_delay_sbc_mtu, avdtp_playback_delay_aac_mtu); + TRACE(3, "SWITC GAME MODE !!!latency_mode_is_open = %d###", + latency_mode_is_open); + if (!latency_mode_is_open) { + avdtp_playback_delay_sbc_mtu = 32; + avdtp_playback_delay_aac_mtu = 3; + app_ibrt_if_force_audio_retrigger_slave_sync(); + } else { + avdtp_playback_delay_sbc_mtu = 50; + avdtp_playback_delay_aac_mtu = 6; + app_ibrt_if_force_audio_retrigger_slave_sync(); + } + latency_mode_is_open = !latency_mode_is_open; + TRACE(3, "set SBC_MTU=%d AAC_MTU=%d\n", avdtp_playback_delay_sbc_mtu, + avdtp_playback_delay_aac_mtu); } -static void low_latlatency_delay_switchfun(const void *) -{ - extern volatile uint8_t avdtp_playback_delay_sbc_mtu; - extern volatile uint8_t avdtp_playback_delay_aac_mtu; +static void low_latlatency_delay_switchfun(const void *) { + extern volatile uint8_t avdtp_playback_delay_sbc_mtu; + extern volatile uint8_t avdtp_playback_delay_aac_mtu; - latency_mode_is_open = !latency_mode_is_open; - if(latency_mode_is_open){ - avdtp_playback_delay_sbc_mtu = 32; - avdtp_playback_delay_aac_mtu = 3; - TRACE(3,"%s latency_mode_is_open!!",__func__); - }else{ - avdtp_playback_delay_sbc_mtu = 50; - avdtp_playback_delay_aac_mtu = 6; - TRACE(3,"%s latency_mode_is_close!!",__func__); - } - app_ibrt_if_force_audio_retrigger(); - app_ibrt_customif_test3_cmd_send(&latency_mode_is_open,1); + latency_mode_is_open = !latency_mode_is_open; + if (latency_mode_is_open) { + avdtp_playback_delay_sbc_mtu = 32; + avdtp_playback_delay_aac_mtu = 3; + TRACE(3, "%s latency_mode_is_open!!", __func__); + } else { + avdtp_playback_delay_sbc_mtu = 50; + avdtp_playback_delay_aac_mtu = 6; + TRACE(3, "%s latency_mode_is_close!!", __func__); + } + app_ibrt_if_force_audio_retrigger(); + app_ibrt_customif_test3_cmd_send(&latency_mode_is_open, 1); } -void startlow_latlatency_delay_switch(int ms) -{ - osTimerStart(low_latlatency_delay_switchid,ms); +void startlow_latlatency_delay_switch(int ms) { + osTimerStart(low_latlatency_delay_switchid, ms); } -void stoplow_latlatency_delay_switch(void) -{ - osTimerStop(low_latlatency_delay_switchid); - +void stoplow_latlatency_delay_switch(void) { + osTimerStop(low_latlatency_delay_switchid); } - - /********************************low_latlatency_delay_switch_timer*******************************************************/ +void app_latency_switch_key_handler(void) { - -void app_latency_switch_key_handler(void) -{ - - if((btif_me_get_activeCons() > 0)&&(app_bt_device.hfchan_call[BT_DEVICE_ID_1] == BTIF_HF_CALL_NONE)&&(app_bt_device.hfchan_callSetup[BT_DEVICE_ID_1] == BTIF_HF_CALL_SETUP_NONE)) - { - if(latency_mode_is_open){ - app_voice_report(APP_STATUS_INDICATION_ALEXA_STOP,0);//close latlatency mode - }else{ - app_voice_report(APP_STATUS_INDICATION_ALEXA_START,0);//close latlatency mode - } - startlow_latlatency_delay_switch(1500); - } + if ((btif_me_get_activeCons() > 0) && + (app_bt_device.hfchan_call[BT_DEVICE_ID_1] == BTIF_HF_CALL_NONE) && + (app_bt_device.hfchan_callSetup[BT_DEVICE_ID_1] == + BTIF_HF_CALL_SETUP_NONE)) { + if (latency_mode_is_open) { + app_voice_report(APP_STATUS_INDICATION_ALEXA_STOP, + 0); // close latlatency mode + } else { + app_voice_report(APP_STATUS_INDICATION_ALEXA_START, + 0); // close latlatency mode + } + startlow_latlatency_delay_switch(1500); + } } - /* * handling of touch events when the devices are turned on @@ -1365,13 +1500,13 @@ void app_latency_switch_key_handler(void) * Double tap : Next track * Hold : ANC on/off * Triple tap : Volume Up - * + * * Left Ear: * Single tap : Play/Pause * Double tap : Previous track * Hold : ANC on/off * Triple tap : Volume Down - + * Single pod active: * Single tap : Play/Pause @@ -1379,182 +1514,191 @@ void app_latency_switch_key_handler(void) * Hold : Previous track * Triple tap : Volume Up * Quad tap : Volume Down - - - - * We use app_ibrt_if_start_user_action for handling actions, as this will apply locally if we are link master + + + + * We use app_ibrt_if_start_user_action for handling actions, as this will apply + locally if we are link master * OR send it over the link to the other bud if we are not */ -void send_vol_up(void){ - uint8_t action[] = {IBRT_ACTION_LOCAL_VOLUP}; +void send_vol_up(void) { + uint8_t action[] = {IBRT_ACTION_LOCAL_VOLUP}; + app_ibrt_if_start_user_action(action, sizeof(action)); +} +void send_play_pause(void) { + if (app_bt_device.a2dp_play_pause_flag != 0) { + uint8_t action[] = {IBRT_ACTION_PAUSE}; app_ibrt_if_start_user_action(action, sizeof(action)); -} -void send_play_pause(void){ - if (app_bt_device.a2dp_play_pause_flag!=0) { - uint8_t action[] = {IBRT_ACTION_PAUSE}; - app_ibrt_if_start_user_action(action, sizeof(action)); - }else { - uint8_t action[] = {IBRT_ACTION_PLAY}; - app_ibrt_if_start_user_action(action, sizeof(action)); - } -} -void send_vol_down(void){ - uint8_t action[] = {IBRT_ACTION_LOCAL_VOLDN}; + } else { + uint8_t action[] = {IBRT_ACTION_PLAY}; app_ibrt_if_start_user_action(action, sizeof(action)); + } +} +void send_vol_down(void) { + uint8_t action[] = {IBRT_ACTION_LOCAL_VOLDN}; + app_ibrt_if_start_user_action(action, sizeof(action)); } -void send_next_track(void){ - uint8_t action[] = {IBRT_ACTION_FORWARD}; - app_ibrt_if_start_user_action(action, sizeof(action)); +void send_next_track(void) { + uint8_t action[] = {IBRT_ACTION_FORWARD}; + app_ibrt_if_start_user_action(action, sizeof(action)); } -void send_prev_track(void){ - uint8_t action[] = {IBRT_ACTION_BACKWARD}; - app_ibrt_if_start_user_action(action, sizeof(action)); +void send_prev_track(void) { + uint8_t action[] = {IBRT_ACTION_BACKWARD}; + app_ibrt_if_start_user_action(action, sizeof(action)); } -void app_key_single_tap(APP_KEY_STATUS *status, void *param){ - TRACE(2,"%s event %d", __func__, status->event); +void app_key_single_tap(APP_KEY_STATUS *status, void *param) { + TRACE(2, "%s event %d", __func__, status->event); - if (!app_tws_ibrt_tws_link_connected()){ - //No other bud paired - TRACE(0,"Handling %s in single bud mode",__func__); - send_play_pause(); - }else { - //Bud's are working as a pair - if (app_tws_is_left_side()){ - TRACE(0,"Handling %s as left bud",__func__); - //Lefty - send_play_pause(); - }else { - TRACE(0,"Handling %s as right bud",__func__); - //Righty - send_play_pause(); - } + if (!app_tws_ibrt_tws_link_connected()) { + // No other bud paired + TRACE(0, "Handling %s in single bud mode", __func__); + send_play_pause(); + } else { + // Bud's are working as a pair + if (app_tws_is_left_side()) { + TRACE(0, "Handling %s as left bud", __func__); + // Lefty + send_play_pause(); + } else { + TRACE(0, "Handling %s as right bud", __func__); + // Righty + send_play_pause(); } - + } } -void app_key_double_tap(APP_KEY_STATUS *status, void *param){ - TRACE(2,"%s event %d", __func__, status->event); +void app_key_double_tap(APP_KEY_STATUS *status, void *param) { + TRACE(2, "%s event %d", __func__, status->event); - if (!app_tws_ibrt_tws_link_connected()){ - //No other bud paired - TRACE(0,"Handling %s in single bud mode",__func__); - send_next_track(); - }else { - //Bud's are working as a pair - if (app_tws_is_left_side()){ - TRACE(0,"Handling %s as left bud",__func__); - //Lefty - send_prev_track(); - }else { - TRACE(0,"Handling %s as right bud",__func__); - //Righty - send_next_track(); - } + if (!app_tws_ibrt_tws_link_connected()) { + // No other bud paired + TRACE(0, "Handling %s in single bud mode", __func__); + send_next_track(); + } else { + // Bud's are working as a pair + if (app_tws_is_left_side()) { + TRACE(0, "Handling %s as left bud", __func__); + // Lefty + send_prev_track(); + } else { + TRACE(0, "Handling %s as right bud", __func__); + // Righty + send_next_track(); } - + } } +void app_key_triple_tap(APP_KEY_STATUS *status, void *param) { + TRACE(2, "%s event %d", __func__, status->event); -void app_key_triple_tap(APP_KEY_STATUS *status, void *param){ - TRACE(2,"%s event %d", __func__, status->event); - - if (!app_tws_ibrt_tws_link_connected()){ - //No other bud paired - TRACE(0,"Handling %s in single bud mode",__func__); - send_vol_up(); - }else { - //Bud's are working as a pair - if (app_tws_is_left_side()){ - TRACE(0,"Handling %s as left bud",__func__); - //Lefty - send_vol_down(); - }else { - TRACE(0,"Handling %s as right bud",__func__); - //Righty - send_vol_up(); - } + if (!app_tws_ibrt_tws_link_connected()) { + // No other bud paired + TRACE(0, "Handling %s in single bud mode", __func__); + send_vol_up(); + } else { + // Bud's are working as a pair + if (app_tws_is_left_side()) { + TRACE(0, "Handling %s as left bud", __func__); + // Lefty + send_vol_down(); + } else { + TRACE(0, "Handling %s as right bud", __func__); + // Righty + send_vol_up(); } - + } } -void app_key_quad_tap(APP_KEY_STATUS *status, void *param){ - TRACE(2,"%s event %d", __func__, status->event); +void app_key_quad_tap(APP_KEY_STATUS *status, void *param) { + TRACE(2, "%s event %d", __func__, status->event); - if (!app_tws_ibrt_tws_link_connected()){ - //No other bud paired - TRACE(0,"Handling %s in single bud mode",__func__); - send_vol_down(); - }else { - //Bud's are working as a pair - if (app_tws_is_left_side()){ - TRACE(0,"Handling %s as left bud",__func__); - //Lefty - }else { - TRACE(0,"Handling %s as right bud",__func__); - //Righty - } + if (!app_tws_ibrt_tws_link_connected()) { + // No other bud paired + TRACE(0, "Handling %s in single bud mode", __func__); + send_vol_down(); + } else { + // Bud's are working as a pair + if (app_tws_is_left_side()) { + TRACE(0, "Handling %s as left bud", __func__); + // Lefty + } else { + TRACE(0, "Handling %s as right bud", __func__); + // Righty } + } } -void app_key_long_press_down(APP_KEY_STATUS *status, void *param) -{ - TRACE(2,"%s event %d", __func__, status->event); +void app_key_long_press_down(APP_KEY_STATUS *status, void *param) { + TRACE(2, "%s event %d", __func__, status->event); - if (!app_tws_ibrt_tws_link_connected()){ - //No other bud paired - TRACE(0,"Handling %s in single bud mode",__func__); - send_prev_track(); - }else { - //Bud's are working as a pair - app_anc_key(status,param); - } + if (!app_tws_ibrt_tws_link_connected()) { + // No other bud paired + TRACE(0, "Handling %s in single bud mode", __func__); + send_prev_track(); + } else { + // Bud's are working as a pair + app_anc_key(status, param); + } } - - -void app_key_reboot(APP_KEY_STATUS *status, void *param) -{ - TRACE(1,"%s ",__func__); - hal_cmu_sys_reboot(); +void app_key_reboot(APP_KEY_STATUS *status, void *param) { + TRACE(1, "%s ", __func__); + hal_cmu_sys_reboot(); } +void app_key_init(void) { + uint8_t i = 0; + TRACE(1, "%s", __func__); -void app_key_init(void) -{ - uint8_t i = 0; - TRACE(1,"%s",__func__); + const APP_KEY_HANDLE key_cfg[] = { - const APP_KEY_HANDLE key_cfg[] = { - - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_CLICK},"",app_key_single_tap, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_DOUBLECLICK},"",app_key_double_tap, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_TRIPLECLICK},"",app_key_triple_tap, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_ULTRACLICK},"",app_key_quad_tap, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_LONGPRESS},"",app_key_long_press_down, NULL}, - }; + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_CLICK}, "", app_key_single_tap, NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_DOUBLECLICK}, + "", + app_key_double_tap, + NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_TRIPLECLICK}, + "", + app_key_triple_tap, + NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_ULTRACLICK}, + "", + app_key_quad_tap, + NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_LONGPRESS}, + "", + app_key_long_press_down, + NULL}, + }; - app_key_handle_clear(); - for (i=0; i<(sizeof(key_cfg)/sizeof(APP_KEY_HANDLE)); i++){ - app_key_handle_registration(&key_cfg[i]); - } + app_key_handle_clear(); + for (i = 0; i < (sizeof(key_cfg) / sizeof(APP_KEY_HANDLE)); i++) { + app_key_handle_registration(&key_cfg[i]); + } } -void app_key_init_on_charging(void) -{ - uint8_t i = 0; - const APP_KEY_HANDLE key_cfg[] = { - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_LONGLONGPRESS},"long press reboot",app_key_reboot, NULL}, - // {{APP_KEY_CODE_PWR,APP_KEY_EVENT_CLICK},"bt function key",app_dfu_key_handler, NULL}, +void app_key_init_on_charging(void) { + uint8_t i = 0; + const APP_KEY_HANDLE key_cfg[] = { + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_LONGLONGPRESS}, + "long press reboot", + app_key_reboot, + NULL}, + // {{APP_KEY_CODE_PWR,APP_KEY_EVENT_CLICK},"bt function + // key",app_dfu_key_handler, NULL}, #ifdef __USB_COMM__ - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_LONGPRESS},"usb cdc key",app_usb_cdc_comm_key_handler, NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_LONGPRESS}, + "usb cdc key", + app_usb_cdc_comm_key_handler, + NULL}, #endif - }; + }; - TRACE(1,"%s",__func__); - for (i=0; i<(sizeof(key_cfg)/sizeof(APP_KEY_HANDLE)); i++){ - app_key_handle_registration(&key_cfg[i]); - } + TRACE(1, "%s", __func__); + for (i = 0; i < (sizeof(key_cfg) / sizeof(APP_KEY_HANDLE)); i++) { + app_key_handle_registration(&key_cfg[i]); + } } void stopAuto_Shutdowm_Timer(void); @@ -1564,94 +1708,96 @@ bool IsMobileLinkLossing = FALSE; bool IsTwsLinkLossing = FALSE; bool enterpairing_flag = false; bool IsTwsLinkdiscon = false; -bool reconnect_fail_fail_flag= false; +bool reconnect_fail_fail_flag = false; static void app_enterpairing_timehandler(void const *param); -osTimerDef (APP_ENTERPAIRING_TIMER, app_enterpairing_timehandler); +osTimerDef(APP_ENTERPAIRING_TIMER, app_enterpairing_timehandler); static osTimerId enterpairing_timer = NULL; -static void app_enterpairing_timehandler(void const *param) -{ - static ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - static app_ibrt_ui_t *p_ui_ctrl = app_ibrt_ui_get_ctx(); - TRACE(3,"xqd log --%s\n", __func__); - TRACE(3,"MyLog: is_tws_con = %d, nv_role = 0x%x", app_tws_ibrt_tws_link_connected(), p_ibrt_ctrl->nv_role); - reconnect_fail_fail_flag = true; - enterpairing_flag = false; - if(IsMobileLinkLossing) - { - TRACE(3,"xqd---log:return evt 0!!!\n"); - return; - } - if(p_ui_ctrl->box_state == IBRT_IN_BOX_CLOSED){ - TRACE(3,"xqd---log:return evt 1!!!\n"); - return; - } - if((app_battery_is_charging())||((app_device_bt_is_connected())&&(app_tws_ibrt_mobile_link_connected())&&(app_tws_ibrt_mobile_link_connected())))return; +static void app_enterpairing_timehandler(void const *param) { + static ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + static app_ibrt_ui_t *p_ui_ctrl = app_ibrt_ui_get_ctx(); + TRACE(3, "xqd log --%s\n", __func__); + TRACE(3, "MyLog: is_tws_con = %d, nv_role = 0x%x", + app_tws_ibrt_tws_link_connected(), p_ibrt_ctrl->nv_role); + reconnect_fail_fail_flag = true; + enterpairing_flag = false; + if (IsMobileLinkLossing) { + TRACE(3, "xqd---log:return evt 0!!!\n"); + return; + } + if (p_ui_ctrl->box_state == IBRT_IN_BOX_CLOSED) { + TRACE(3, "xqd---log:return evt 1!!!\n"); + return; + } + if ((app_battery_is_charging()) || ((app_device_bt_is_connected()) && + (app_tws_ibrt_mobile_link_connected()) && + (app_tws_ibrt_mobile_link_connected()))) + return; - if (app_tws_ibrt_mobile_link_connected() || app_tws_ibrt_slave_ibrt_link_connected()) { - TRACE(3,"xqd---log:return evt 2!!!\n"); - return; - } - - if (app_ibrt_ui_get_enter_pairing_mode()) { - TRACE(3,"xqd---log:return evt 3!!!\n"); - if((IBRT_UNKNOW != p_ibrt_ctrl->nv_role)&&(nv_record_get_paired_dev_count()>=2)){ - app_voice_report(APP_STATUS_INDICATION_BOTHSCAN,0); - } - app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); - return; - } - - if(app_tws_ibrt_tws_link_connected() && (p_ibrt_ctrl->current_role == IBRT_MASTER)) - { - TRACE(3,"xqd---log:return evt 4!!!\n"); - - //p_ui_ctrl->config.enter_pairing_on_reconnect_mobile_failed = true; - //p_ui_ctrl->config.nv_slave_enter_pairing_on_mobile_disconnect = true; - //app_ibrt_if_enter_freeman_pairing(); - //app_ibrt_if_enter_pairing_after_tws_connected(); - app_ibrt_ui_set_enter_pairing_mode(IBRT_CONNECT_MOBILE_FAILED); - app_ibrt_ui_judge_scan_type(IBRT_CONNECTE_TRIGGER,MOBILE_LINK, 0); - app_voice_report(APP_STATUS_INDICATION_BOTHSCAN,0); - } - else if ((!app_tws_ibrt_tws_link_connected()) && (p_ibrt_ctrl->nv_role == IBRT_MASTER)&&(p_ibrt_ctrl->access_mode != 0x3)) - { - TRACE(3,"xqd---log:return evt 5!!!\n"); - app_ibrt_ui_set_enter_pairing_mode(IBRT_CONNECT_MOBILE_FAILED); - app_ibrt_ui_judge_scan_type(IBRT_CONNECTE_TRIGGER,MOBILE_LINK, 0); - app_voice_report(APP_STATUS_INDICATION_BOTHSCAN,0); - } - else if((!app_tws_ibrt_tws_link_connected()) && (p_ibrt_ctrl->nv_role == IBRT_SLAVE)) - { - app_ibrt_ui_set_enter_pairing_mode(IBRT_CONNECT_MOBILE_FAILED); - app_ibrt_ui_judge_scan_type(IBRT_CONNECTE_TRIGGER, MOBILE_LINK, 0); - app_voice_report(APP_STATUS_INDICATION_BOTHSCAN,0); - } - -} -void app_enterpairing_timer_start(void) -{ - static ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - TRACE(3,"xqd log --app_enterpairing_timer_start, enterpairing_flag = %d,nv_role = %d\n", enterpairing_flag,p_ibrt_ctrl->nv_role); - if(p_ibrt_ctrl->nv_role == IBRT_UNKNOW)return; + if (app_tws_ibrt_mobile_link_connected() || + app_tws_ibrt_slave_ibrt_link_connected()) { + TRACE(3, "xqd---log:return evt 2!!!\n"); + return; + } - enterpairing_flag = true; - - osTimerStop(enterpairing_timer); - osTimerStart(enterpairing_timer, 11000); -} -void app_enterpairing_timer_stop(void) -{ - TRACE(3,"xqd log --app_enterpairing_timer_stop\n"); - if(enterpairing_flag) - osTimerStop(enterpairing_timer); -} -void app_enterpairing_timer_open(void) -{ - if(NULL == enterpairing_timer) - { - enterpairing_timer = osTimerCreate (osTimer(APP_ENTERPAIRING_TIMER), osTimerOnce, (void *)0); + if (app_ibrt_ui_get_enter_pairing_mode()) { + TRACE(3, "xqd---log:return evt 3!!!\n"); + if ((IBRT_UNKNOW != p_ibrt_ctrl->nv_role) && + (nv_record_get_paired_dev_count() >= 2)) { + app_voice_report(APP_STATUS_INDICATION_BOTHSCAN, 0); } - + app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); + return; + } + + if (app_tws_ibrt_tws_link_connected() && + (p_ibrt_ctrl->current_role == IBRT_MASTER)) { + TRACE(3, "xqd---log:return evt 4!!!\n"); + + // p_ui_ctrl->config.enter_pairing_on_reconnect_mobile_failed = true; + // p_ui_ctrl->config.nv_slave_enter_pairing_on_mobile_disconnect = true; + // app_ibrt_if_enter_freeman_pairing(); + // app_ibrt_if_enter_pairing_after_tws_connected(); + app_ibrt_ui_set_enter_pairing_mode(IBRT_CONNECT_MOBILE_FAILED); + app_ibrt_ui_judge_scan_type(IBRT_CONNECTE_TRIGGER, MOBILE_LINK, 0); + app_voice_report(APP_STATUS_INDICATION_BOTHSCAN, 0); + } else if ((!app_tws_ibrt_tws_link_connected()) && + (p_ibrt_ctrl->nv_role == IBRT_MASTER) && + (p_ibrt_ctrl->access_mode != 0x3)) { + TRACE(3, "xqd---log:return evt 5!!!\n"); + app_ibrt_ui_set_enter_pairing_mode(IBRT_CONNECT_MOBILE_FAILED); + app_ibrt_ui_judge_scan_type(IBRT_CONNECTE_TRIGGER, MOBILE_LINK, 0); + app_voice_report(APP_STATUS_INDICATION_BOTHSCAN, 0); + } else if ((!app_tws_ibrt_tws_link_connected()) && + (p_ibrt_ctrl->nv_role == IBRT_SLAVE)) { + app_ibrt_ui_set_enter_pairing_mode(IBRT_CONNECT_MOBILE_FAILED); + app_ibrt_ui_judge_scan_type(IBRT_CONNECTE_TRIGGER, MOBILE_LINK, 0); + app_voice_report(APP_STATUS_INDICATION_BOTHSCAN, 0); + } +} +void app_enterpairing_timer_start(void) { + static ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + TRACE(3, + "xqd log --app_enterpairing_timer_start, enterpairing_flag = " + "%d,nv_role = %d\n", + enterpairing_flag, p_ibrt_ctrl->nv_role); + if (p_ibrt_ctrl->nv_role == IBRT_UNKNOW) + return; + + enterpairing_flag = true; + + osTimerStop(enterpairing_timer); + osTimerStart(enterpairing_timer, 11000); +} +void app_enterpairing_timer_stop(void) { + TRACE(3, "xqd log --app_enterpairing_timer_stop\n"); + if (enterpairing_flag) + osTimerStop(enterpairing_timer); +} +void app_enterpairing_timer_open(void) { + if (NULL == enterpairing_timer) { + enterpairing_timer = + osTimerCreate(osTimer(APP_ENTERPAIRING_TIMER), osTimerOnce, (void *)0); + } } extern bool IsMobileLinkLossing; extern bool IsTwsLinkLossing; @@ -1661,93 +1807,94 @@ osTimerId Auto_Shutdowm_Timerid = NULL; void startAuto_Shutdowm_Timer(int ms); static void Auto_Shutdowm_Timerfun(const void *); -osTimerDef(defAuto_Shutdowm_Timer,Auto_Shutdowm_Timerfun); -void Auto_Shutdowm_Timerinit(void) -{ - Auto_Shutdowm_Timerid = osTimerCreate(osTimer(defAuto_Shutdowm_Timer),osTimerPeriodic,(void *)0); - startAuto_Shutdowm_Timer(5000); +osTimerDef(defAuto_Shutdowm_Timer, Auto_Shutdowm_Timerfun); +void Auto_Shutdowm_Timerinit(void) { + Auto_Shutdowm_Timerid = osTimerCreate(osTimer(defAuto_Shutdowm_Timer), + osTimerPeriodic, (void *)0); + startAuto_Shutdowm_Timer(5000); } extern struct btdevice_volume *btdevice_volume_p; -static void Auto_Shutdowm_Timerfun(const void *) -{ - static uint32_t auto_shutdown_cnt = 0; - static ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - static app_ibrt_ui_t *p_ui_ctrl = app_ibrt_ui_get_ctx(); - struct nvrecord_env_t *nvrecord_env; - nv_record_env_get(&nvrecord_env); - static uint8_t trace_cnt = 0; - APP_BATTERY_MV_T currvolt =0; - //static uint8_t charge_full_timeout_cnt = 0; - trace_cnt ++; - if(trace_cnt >= 2){ - trace_cnt = 0; - /* - TRACE(0,"xqd---log:curr_role = %d,nv_role = %d,box_state = %d,access_mode = %d,channel = %d",p_ibrt_ctrl->current_role,p_ibrt_ctrl->nv_role,p_ui_ctrl->box_state,p_ibrt_ctrl->access_mode,tgt_tws_get_channel_is_right()); - TRACE(0,"curr_avrcp_status = %d£¬localbat = %d,slave_bat = %d",avrcp_get_media_status(),p_ibrt_ctrl->local_battery_volt,p_ibrt_ctrl->peer_battery_volt); - TRACE(0,"a2dp vol : %d", btdevice_volume_p->a2dp_vol); - // TRACE(0,"hfp vol: %d", btdevice_volume_p->hfp_vol); - TRACE(0,"qxw---nv_ibrt_mode addr:"); - DUMP8("0x%x ", nvrecord_env->ibrt_mode.record.bdAddr.address, 6); - TRACE(0,"qxw---peer addr:"); - DUMP8("%02x ", p_ibrt_ctrl->peer_addr.address, 6); - TRACE(0,"qxw---local addr:"); - DUMP8("%02x ", p_ibrt_ctrl->local_addr.address, 6); - TRACE(0,"qxw---nv_master addr:"); - DUMP8("%02x ", nvrecord_env->master_bdaddr.address, 6); - TRACE(0,"qxw---nv_slave addr:"); - DUMP8("%02x ", nvrecord_env->slave_bdaddr.address, 6);*/ - //TRACE(2,"charge_gpio statu:%d,chargefull_gpio statu:%d,curr_charge status = %d!",hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)cfg_hw_charge_indication_cfg.pin),hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)cfg_hw_charge_full_indication_cfg.pin),app_battery_is_charging()); - } +static void Auto_Shutdowm_Timerfun(const void *) { + static uint32_t auto_shutdown_cnt = 0; + static ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + static app_ibrt_ui_t *p_ui_ctrl = app_ibrt_ui_get_ctx(); + struct nvrecord_env_t *nvrecord_env; + nv_record_env_get(&nvrecord_env); + static uint8_t trace_cnt = 0; + APP_BATTERY_MV_T currvolt = 0; + // static uint8_t charge_full_timeout_cnt = 0; + trace_cnt++; + if (trace_cnt >= 2) { + trace_cnt = 0; + /* + TRACE(0,"xqd---log:curr_role = %d,nv_role = %d,box_state = %d,access_mode = + %d,channel = + %d",p_ibrt_ctrl->current_role,p_ibrt_ctrl->nv_role,p_ui_ctrl->box_state,p_ibrt_ctrl->access_mode,tgt_tws_get_channel_is_right()); + TRACE(0,"curr_avrcp_status = %d£¬localbat = %d,slave_bat = + %d",avrcp_get_media_status(),p_ibrt_ctrl->local_battery_volt,p_ibrt_ctrl->peer_battery_volt); + TRACE(0,"a2dp vol : %d", btdevice_volume_p->a2dp_vol); + // TRACE(0,"hfp vol: %d", btdevice_volume_p->hfp_vol); + TRACE(0,"qxw---nv_ibrt_mode addr:"); + DUMP8("0x%x ", nvrecord_env->ibrt_mode.record.bdAddr.address, 6); + TRACE(0,"qxw---peer addr:"); + DUMP8("%02x ", p_ibrt_ctrl->peer_addr.address, 6); + TRACE(0,"qxw---local addr:"); + DUMP8("%02x ", p_ibrt_ctrl->local_addr.address, 6); + TRACE(0,"qxw---nv_master addr:"); + DUMP8("%02x ", nvrecord_env->master_bdaddr.address, 6); + TRACE(0,"qxw---nv_slave addr:"); + DUMP8("%02x ", nvrecord_env->slave_bdaddr.address, 6);*/ + // TRACE(2,"charge_gpio statu:%d,chargefull_gpio statu:%d,curr_charge status + // = %d!",hal_gpio_pin_get_val((enum + // HAL_GPIO_PIN_T)cfg_hw_charge_indication_cfg.pin),hal_gpio_pin_get_val((enum + // HAL_GPIO_PIN_T)cfg_hw_charge_full_indication_cfg.pin),app_battery_is_charging()); + } - //TRACE(3,"GIOI25 = %d,charge sta = %d!!!!!",hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)app_battery_charger_full_indicator_cfg.pin),app_battery_is_charging()); - if(app_battery_is_charging()){ - if((p_ui_ctrl->box_state != IBRT_IN_BOX_CLOSED)){ - app_ibrt_ui_event_entry(IBRT_CLOSE_BOX_EVENT); - } - } - app_battery_get_info(&currvolt, NULL, NULL); - if(p_ui_ctrl->box_state == IBRT_OUT_BOX){ - if(app_device_bt_is_connected()) - { - IsMobileLinkLossing = FALSE; - IsTwsLinkLossing = FALSE; - MobileLinkLose_reboot = FALSE; - } - if((!app_device_bt_is_connected())&& p_ibrt_ctrl->current_role != BTIF_BCR_SLAVE) - { - auto_shutdown_cnt++; - if(auto_shutdown_cnt == Auto_Shutdowm_TIME/5) - { - TRACE(0,"xqd---shutdown!!@@@@@@!!"); - auto_shutdown_cnt = 0; - app_bt_power_off_customize(); - } - } - else - { - auto_shutdown_cnt = 0; - } - /*if((auto_shutdown_cnt % 4 == 0)&&(MobileLinkLose_reboot)&&(!app_qxw_bt_is_connected())&&(p_ibrt_ctrl->current_role != BTIF_BCR_SLAVE)){ - app_ibrt_if_event_entry(IBRT_PHONE_CONNECT_EVENT); - }*/ - }else{ - auto_shutdown_cnt = 0; - } + // TRACE(3,"GIOI25 = %d,charge sta = %d!!!!!",hal_gpio_pin_get_val((enum + // HAL_GPIO_PIN_T)app_battery_charger_full_indicator_cfg.pin),app_battery_is_charging()); + if (app_battery_is_charging()) { + if ((p_ui_ctrl->box_state != IBRT_IN_BOX_CLOSED)) { + app_ibrt_ui_event_entry(IBRT_CLOSE_BOX_EVENT); + } + } + app_battery_get_info(&currvolt, NULL, NULL); + if (p_ui_ctrl->box_state == IBRT_OUT_BOX) { + if (app_device_bt_is_connected()) { + IsMobileLinkLossing = FALSE; + IsTwsLinkLossing = FALSE; + MobileLinkLose_reboot = FALSE; + } + if ((!app_device_bt_is_connected()) && + p_ibrt_ctrl->current_role != BTIF_BCR_SLAVE) { + auto_shutdown_cnt++; + if (auto_shutdown_cnt == Auto_Shutdowm_TIME / 5) { + TRACE(0, "xqd---shutdown!!@@@@@@!!"); + auto_shutdown_cnt = 0; + app_bt_power_off_customize(); + } + } else { + auto_shutdown_cnt = 0; + } + /*if((auto_shutdown_cnt % 4 == + 0)&&(MobileLinkLose_reboot)&&(!app_qxw_bt_is_connected())&&(p_ibrt_ctrl->current_role + != BTIF_BCR_SLAVE)){ app_ibrt_if_event_entry(IBRT_PHONE_CONNECT_EVENT); + }*/ + } else { + auto_shutdown_cnt = 0; + } -#if(QXW_TOUCH_INEAR_DET) - last_tws_con_status = app_tws_ibrt_tws_link_connected(); -#endif +#if (QXW_TOUCH_INEAR_DET) + last_tws_con_status = app_tws_ibrt_tws_link_connected(); +#endif } -void startAuto_Shutdowm_Timer(int ms) -{ - osTimerStart(Auto_Shutdowm_Timerid,ms); +void startAuto_Shutdowm_Timer(int ms) { + osTimerStart(Auto_Shutdowm_Timerid, ms); } -void stopAuto_Shutdowm_Timer(void) -{ - TRACE(0,"%s",__func__); - osTimerStop(Auto_Shutdowm_Timerid); +void stopAuto_Shutdowm_Timer(void) { + TRACE(0, "%s", __func__); + osTimerStop(Auto_Shutdowm_Timerid); } /********************************Auto_Shutdowm_Timer_timer*******************************************************/ @@ -1758,382 +1905,375 @@ osTimerId once_delay_event_Timer_id = NULL; void startonce_delay_event_Timer_(int ms); void stoponce_delay_event_Timer_(void); static void once_delay_event_Timer_fun(const void *); -osTimerDef(defonce_delay_event_Timer_,once_delay_event_Timer_fun); -void once_delay_event_Timer_init(void) -{ - TRACE(3,"%s",__func__); - once_delay_event_Timer_id = osTimerCreate(osTimer(defonce_delay_event_Timer_),osTimerOnce,(void *)0); +osTimerDef(defonce_delay_event_Timer_, once_delay_event_Timer_fun); +void once_delay_event_Timer_init(void) { + TRACE(3, "%s", __func__); + once_delay_event_Timer_id = osTimerCreate(osTimer(defonce_delay_event_Timer_), + osTimerOnce, (void *)0); } -static void once_delay_event_Timer_fun(const void *) -{ - static ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if((p_ibrt_ctrl->current_role == IBRT_SLAVE)) - { - once_event_case = 0; - TRACE(3,"delay_report_tonefun RETURN!!!"); - return; - } - TRACE(3,"\n\n!!!!!!enter %s,mobile_link = %d,event = %d\n\n",__func__,app_tws_ibrt_mobile_link_connected(),once_event_case); - switch(once_event_case) - { - case 1: - if(/*(avrcp_get_media_status() != 1)&&*/(app_bt_device.a2dp_state[BT_DEVICE_ID_1] == 1)&&(app_bt_device.hfchan_callSetup[BT_DEVICE_ID_1] == 0)&& - (p_ibrt_ctrl->current_role == IBRT_MASTER)) - app_voice_report(APP_STATUS_INDICATION_CONNECTED,0); - break; - case 2: - if((IsMobileLinkLossing || app_device_bt_is_connected()))break; - app_voice_report(APP_STATUS_INDICATION_DISCONNECTED,0); - app_voice_report(APP_STATUS_INDICATION_BOTHSCAN,0); - app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); - //once_event_case = 3; - // startonce_delay_event_Timer_(2000); - break; - case 3: - if(IsMobileLinkLossing) - { - return; - } - if((app_device_bt_is_connected()))return; - app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); - app_voice_report(APP_STATUS_INDICATION_BOTHSCAN,0); - if(p_ibrt_ctrl->nv_role == IBRT_MASTER) - { - app_ibrt_if_enter_pairing_after_tws_connected(); - } - else if(p_ibrt_ctrl->nv_role == IBRT_SLAVE) - { - app_ibrt_ui_set_enter_pairing_mode(IBRT_CONNECT_MOBILE_FAILED); - app_ibrt_ui_judge_scan_type(IBRT_CONNECTE_TRIGGER,MOBILE_LINK, 0); - } - else if(p_ibrt_ctrl->nv_role == IBRT_UNKNOW) - { - app_ibrt_ui_judge_scan_type(IBRT_FREEMAN_PAIR_TRIGGER,NO_LINK_TYPE, IBRT_UI_NO_ERROR); - app_ibrt_ui_set_freeman_enable(); - } - break; - - case 4: - if(!app_device_bt_is_connected()){ - app_voice_report_generic(APP_STATUS_INDICATION_DISCONNECTED, 0,0); - } - LINKLOSE_REBOOT_ENABLE = true; - break; - case 5: - if(!app_device_bt_is_connected()&&!app_tws_ibrt_tws_link_connected()){ - app_voice_report_generic(APP_STATUS_INDICATION_DISCONNECTED, 0,0); - } - LINKLOSE_REBOOT_ENABLE = true; - break; - case 8: - app_ibrt_sync_volume_info(); - break; - case 9: - break; - default: - break; - - } - once_event_case = 0; +static void once_delay_event_Timer_fun(const void *) { + static ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if ((p_ibrt_ctrl->current_role == IBRT_SLAVE)) { + once_event_case = 0; + TRACE(3, "delay_report_tonefun RETURN!!!"); + return; + } + TRACE(3, "\n\n!!!!!!enter %s,mobile_link = %d,event = %d\n\n", __func__, + app_tws_ibrt_mobile_link_connected(), once_event_case); + switch (once_event_case) { + case 1: + if (/*(avrcp_get_media_status() != 1)&&*/ ( + app_bt_device.a2dp_state[BT_DEVICE_ID_1] == 1) && + (app_bt_device.hfchan_callSetup[BT_DEVICE_ID_1] == 0) && + (p_ibrt_ctrl->current_role == IBRT_MASTER)) + app_voice_report(APP_STATUS_INDICATION_CONNECTED, 0); + break; + case 2: + if ((IsMobileLinkLossing || app_device_bt_is_connected())) + break; + app_voice_report(APP_STATUS_INDICATION_DISCONNECTED, 0); + app_voice_report(APP_STATUS_INDICATION_BOTHSCAN, 0); + app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); + // once_event_case = 3; + // startonce_delay_event_Timer_(2000); + break; + case 3: + if (IsMobileLinkLossing) { + return; + } + if ((app_device_bt_is_connected())) + return; + app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); + app_voice_report(APP_STATUS_INDICATION_BOTHSCAN, 0); + if (p_ibrt_ctrl->nv_role == IBRT_MASTER) { + app_ibrt_if_enter_pairing_after_tws_connected(); + } else if (p_ibrt_ctrl->nv_role == IBRT_SLAVE) { + app_ibrt_ui_set_enter_pairing_mode(IBRT_CONNECT_MOBILE_FAILED); + app_ibrt_ui_judge_scan_type(IBRT_CONNECTE_TRIGGER, MOBILE_LINK, 0); + } else if (p_ibrt_ctrl->nv_role == IBRT_UNKNOW) { + app_ibrt_ui_judge_scan_type(IBRT_FREEMAN_PAIR_TRIGGER, NO_LINK_TYPE, + IBRT_UI_NO_ERROR); + app_ibrt_ui_set_freeman_enable(); + } + break; + + case 4: + if (!app_device_bt_is_connected()) { + app_voice_report_generic(APP_STATUS_INDICATION_DISCONNECTED, 0, 0); + } + LINKLOSE_REBOOT_ENABLE = true; + break; + case 5: + if (!app_device_bt_is_connected() && !app_tws_ibrt_tws_link_connected()) { + app_voice_report_generic(APP_STATUS_INDICATION_DISCONNECTED, 0, 0); + } + LINKLOSE_REBOOT_ENABLE = true; + break; + case 8: + app_ibrt_sync_volume_info(); + break; + case 9: + break; + default: + break; + } + once_event_case = 0; } -void startonce_delay_event_Timer_(int ms) -{ - TRACE(3,"\n\n !!!!!!!!!!start %s\n\n",__func__); - osTimerStart(once_delay_event_Timer_id,ms); +void startonce_delay_event_Timer_(int ms) { + TRACE(3, "\n\n !!!!!!!!!!start %s\n\n", __func__); + osTimerStart(once_delay_event_Timer_id, ms); } -void stoponce_delay_event_Timer_(void) -{ - TRACE(3,"\n\n!!!!!!!!!! stop %s\n\n",__func__); - osTimerStop(once_delay_event_Timer_id); +void stoponce_delay_event_Timer_(void) { + TRACE(3, "\n\n!!!!!!!!!! stop %s\n\n", __func__); + osTimerStop(once_delay_event_Timer_id); } /********************************once_delay_event_Timer__timer*******************************************************/ /***********************************************************************************************/ #include "hal_gpio.h" #include "tgt_hardware.h" -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; extern void hal_gpio_pin_set(enum HAL_GPIO_PIN_T pin); - -bool Curr_Is_Master(void) -{ - static ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if(p_ibrt_ctrl->current_role == IBRT_MASTER) - return 1; - else - return 0; +bool Curr_Is_Master(void) { + static ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (p_ibrt_ctrl->current_role == IBRT_MASTER) + return 1; + else + return 0; } -bool Curr_Is_Slave(void) -{ - static ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if(p_ibrt_ctrl->current_role == IBRT_SLAVE) - return 1; - else - return 0; +bool Curr_Is_Slave(void) { + static ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (p_ibrt_ctrl->current_role == IBRT_SLAVE) + return 1; + else + return 0; } -uint8_t get_curr_role(void) -{ - static ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - return p_ibrt_ctrl->current_role; +uint8_t get_curr_role(void) { + static ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + return p_ibrt_ctrl->current_role; } -uint8_t get_nv_role(void) -{ - static ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - return p_ibrt_ctrl->nv_role; +uint8_t get_nv_role(void) { + static ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + return p_ibrt_ctrl->nv_role; } extern bt_status_t LinkDisconnectDirectly(bool PowerOffFlag); void a2dp_suspend_music_force(void); -bool app_is_power_off_in_progress(void) -{ - return app_poweroff_flag?TRUE:FALSE; +bool app_is_power_off_in_progress(void) { + return app_poweroff_flag ? TRUE : FALSE; } #if GFPS_ENABLED -#define APP_GFPS_BATTERY_TIMEROUT_VALUE (10000) +#define APP_GFPS_BATTERY_TIMEROUT_VALUE (10000) static void app_gfps_battery_show_timeout_timer_cb(void const *n); -osTimerDef (GFPS_BATTERY_SHOW_TIMEOUT_TIMER, app_gfps_battery_show_timeout_timer_cb); +osTimerDef(GFPS_BATTERY_SHOW_TIMEOUT_TIMER, + app_gfps_battery_show_timeout_timer_cb); static osTimerId app_gfps_battery_show_timer_id = NULL; #include "app_gfps.h" -static void app_gfps_battery_show_timeout_timer_cb(void const *n) -{ - TRACE(1,"%s", __func__); - app_gfps_set_battery_datatype(HIDE_UI_INDICATION); +static void app_gfps_battery_show_timeout_timer_cb(void const *n) { + TRACE(1, "%s", __func__); + app_gfps_set_battery_datatype(HIDE_UI_INDICATION); } -void app_gfps_battery_show_timer_start() -{ - if (app_gfps_battery_show_timer_id == NULL) - app_gfps_battery_show_timer_id = osTimerCreate(osTimer(GFPS_BATTERY_SHOW_TIMEOUT_TIMER), osTimerOnce, NULL); - osTimerStart(app_gfps_battery_show_timer_id, APP_GFPS_BATTERY_TIMEROUT_VALUE); +void app_gfps_battery_show_timer_start() { + if (app_gfps_battery_show_timer_id == NULL) + app_gfps_battery_show_timer_id = osTimerCreate( + osTimer(GFPS_BATTERY_SHOW_TIMEOUT_TIMER), osTimerOnce, NULL); + osTimerStart(app_gfps_battery_show_timer_id, APP_GFPS_BATTERY_TIMEROUT_VALUE); } -void app_gfps_battery_show_timer_stop() -{ - if (app_gfps_battery_show_timer_id) - osTimerStop(app_gfps_battery_show_timer_id); +void app_gfps_battery_show_timer_stop() { + if (app_gfps_battery_show_timer_id) + osTimerStop(app_gfps_battery_show_timer_id); } #endif -int app_deinit(int deinit_case) -{ - int nRet = 0; - TRACE(2,"%s case:%d",__func__, deinit_case); - app_tws_if_trigger_role_switch(); - osDelay(200); // This is a hack; a hackkitttyy hack. To wait for the tws exchange to occur +int app_deinit(int deinit_case) { + int nRet = 0; + TRACE(2, "%s case:%d", __func__, deinit_case); + app_tws_if_trigger_role_switch(); + osDelay(200); // This is a hack; a hackkitttyy hack. To wait for the tws + // exchange to occur #ifdef WL_DET - app_mic_alg_audioloop(false,APP_SYSFREQ_78M); + app_mic_alg_audioloop(false, APP_SYSFREQ_78M); #endif #ifdef __PC_CMD_UART__ - app_cmd_close(); + app_cmd_close(); #endif #if (defined(BTUSB_AUDIO_MODE) || defined(BT_USB_AUDIO_DUAL_MODE)) - if(app_usbaudio_mode_on()) return 0; + if (app_usbaudio_mode_on()) + return 0; #endif - if (!deinit_case){ - app_poweroff_flag = 1; + if (!deinit_case) { + app_poweroff_flag = 1; #if defined(APP_LINEIN_A2DP_SOURCE) - app_audio_sendrequest(APP_A2DP_SOURCE_LINEIN_AUDIO, (uint8_t)APP_BT_SETTING_CLOSE,0); + app_audio_sendrequest(APP_A2DP_SOURCE_LINEIN_AUDIO, + (uint8_t)APP_BT_SETTING_CLOSE, 0); #endif #if defined(APP_I2S_A2DP_SOURCE) - app_audio_sendrequest(APP_A2DP_SOURCE_I2S_AUDIO, (uint8_t)APP_BT_SETTING_CLOSE,0); + app_audio_sendrequest(APP_A2DP_SOURCE_I2S_AUDIO, + (uint8_t)APP_BT_SETTING_CLOSE, 0); #endif - app_status_indication_filter_set(APP_STATUS_INDICATION_BOTHSCAN); - app_audio_sendrequest(APP_BT_STREAM_INVALID, (uint8_t)APP_BT_SETTING_CLOSEALL, 0); - osDelay(500); - LinkDisconnectDirectly(true); - osDelay(500); - app_status_indication_set(APP_STATUS_INDICATION_POWEROFF); + app_status_indication_filter_set(APP_STATUS_INDICATION_BOTHSCAN); + app_audio_sendrequest(APP_BT_STREAM_INVALID, + (uint8_t)APP_BT_SETTING_CLOSEALL, 0); + osDelay(500); + LinkDisconnectDirectly(true); + osDelay(500); + app_status_indication_set(APP_STATUS_INDICATION_POWEROFF); #ifdef MEDIA_PLAYER_SUPPORT - app_voice_report(APP_STATUS_INDICATION_POWEROFF, 0); + app_voice_report(APP_STATUS_INDICATION_POWEROFF, 0); #endif #ifdef __THIRDPARTY - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1,THIRDPARTY_DEINIT); + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1, + THIRDPARTY_DEINIT); #endif -#if FPGA==0 - nv_record_flash_flush(); - norflash_api_flush_all(); +#if FPGA == 0 + nv_record_flash_flush(); + norflash_api_flush_all(); #if defined(DUMP_LOG_ENABLE) - log_dump_flush_all(); + log_dump_flush_all(); #endif #endif - osDelay(1000); - af_close(); - } + osDelay(1000); + af_close(); + } - return nRet; + return nRet; } #ifdef APP_TEST_MODE extern void app_test_init(void); -int app_init(void) -{ - int nRet = 0; - //uint8_t pwron_case = APP_POWERON_CASE_INVALID; - TRACE(1,"%s",__func__); - app_poweroff_flag = 0; +int app_init(void) { + int nRet = 0; + // uint8_t pwron_case = APP_POWERON_CASE_INVALID; + TRACE(1, "%s", __func__); + app_poweroff_flag = 0; - app_sysfreq_req(APP_SYSFREQ_USER_APP_INIT, APP_SYSFREQ_52M); - list_init(); - af_open(); - app_os_init(); - app_pwl_open(); - app_audio_open(); - app_audio_manager_open(); - app_overlay_open(); - if (app_key_open(true)) - { - nRet = -1; - goto exit; - } + app_sysfreq_req(APP_SYSFREQ_USER_APP_INIT, APP_SYSFREQ_52M); + list_init(); + af_open(); + app_os_init(); + app_pwl_open(); + app_audio_open(); + app_audio_manager_open(); + app_overlay_open(); + if (app_key_open(true)) { + nRet = -1; + goto exit; + } - app_test_init(); + app_test_init(); exit: - app_sysfreq_req(APP_SYSFREQ_USER_APP_INIT, APP_SYSFREQ_32K); - return nRet; + app_sysfreq_req(APP_SYSFREQ_USER_APP_INIT, APP_SYSFREQ_32K); + return nRet; } #else /* !defined(APP_TEST_MODE) */ -int app_bt_connect2tester_init(void) -{ - btif_device_record_t rec; - bt_bdaddr_t tester_addr; - uint8_t i; - bool find_tester = false; - struct nvrecord_env_t *nvrecord_env; - btdevice_profile *btdevice_plf_p; - nv_record_env_get(&nvrecord_env); - - if (nvrecord_env->factory_tester_status.status != NVRAM_ENV_FACTORY_TESTER_STATUS_DEFAULT) - return 0; - - if (!nvrec_dev_get_dongleaddr(&tester_addr)){ - nv_record_open(section_usrdata_ddbrecord); - for (i = 0; nv_record_enum_dev_records(i, &rec) == BT_STS_SUCCESS; i++) { - if (!memcmp(rec.bdAddr.address, tester_addr.address, BTIF_BD_ADDR_SIZE)){ - find_tester = true; - } - } - if(i==0 && !find_tester){ - memset(&rec, 0, sizeof(btif_device_record_t)); - memcpy(rec.bdAddr.address, tester_addr.address, BTIF_BD_ADDR_SIZE); - nv_record_add(section_usrdata_ddbrecord, &rec); - btdevice_plf_p = (btdevice_profile *)app_bt_profile_active_store_ptr_get(rec.bdAddr.address); - nv_record_btdevicerecord_set_hfp_profile_active_state(btdevice_plf_p, true); - nv_record_btdevicerecord_set_a2dp_profile_active_state(btdevice_plf_p, true); - } - if (find_tester && i>2){ - nv_record_ddbrec_delete(&tester_addr); - nvrecord_env->factory_tester_status.status = NVRAM_ENV_FACTORY_TESTER_STATUS_TEST_PASS; - nv_record_env_set(nvrecord_env); - } - } +int app_bt_connect2tester_init(void) { + btif_device_record_t rec; + bt_bdaddr_t tester_addr; + uint8_t i; + bool find_tester = false; + struct nvrecord_env_t *nvrecord_env; + btdevice_profile *btdevice_plf_p; + nv_record_env_get(&nvrecord_env); + if (nvrecord_env->factory_tester_status.status != + NVRAM_ENV_FACTORY_TESTER_STATUS_DEFAULT) return 0; + + if (!nvrec_dev_get_dongleaddr(&tester_addr)) { + nv_record_open(section_usrdata_ddbrecord); + for (i = 0; nv_record_enum_dev_records(i, &rec) == BT_STS_SUCCESS; i++) { + if (!memcmp(rec.bdAddr.address, tester_addr.address, BTIF_BD_ADDR_SIZE)) { + find_tester = true; + } + } + if (i == 0 && !find_tester) { + memset(&rec, 0, sizeof(btif_device_record_t)); + memcpy(rec.bdAddr.address, tester_addr.address, BTIF_BD_ADDR_SIZE); + nv_record_add(section_usrdata_ddbrecord, &rec); + btdevice_plf_p = (btdevice_profile *)app_bt_profile_active_store_ptr_get( + rec.bdAddr.address); + nv_record_btdevicerecord_set_hfp_profile_active_state(btdevice_plf_p, + true); + nv_record_btdevicerecord_set_a2dp_profile_active_state(btdevice_plf_p, + true); + } + if (find_tester && i > 2) { + nv_record_ddbrec_delete(&tester_addr); + nvrecord_env->factory_tester_status.status = + NVRAM_ENV_FACTORY_TESTER_STATUS_TEST_PASS; + nv_record_env_set(nvrecord_env); + } + } + + return 0; } -int app_nvrecord_rebuild(void) -{ - struct nvrecord_env_t *nvrecord_env; - nv_record_env_get(&nvrecord_env); +int app_nvrecord_rebuild(void) { + struct nvrecord_env_t *nvrecord_env; + nv_record_env_get(&nvrecord_env); - nv_record_sector_clear(); - nv_record_env_init(); - nv_record_update_factory_tester_status(NVRAM_ENV_FACTORY_TESTER_STATUS_TEST_PASS); - nv_record_env_set(nvrecord_env); - nv_record_flash_flush(); + nv_record_sector_clear(); + nv_record_env_init(); + nv_record_update_factory_tester_status( + NVRAM_ENV_FACTORY_TESTER_STATUS_TEST_PASS); + nv_record_env_set(nvrecord_env); + nv_record_flash_flush(); - return 0; + return 0; } #if (defined(BTUSB_AUDIO_MODE) || defined(BT_USB_AUDIO_DUAL_MODE)) #include "app_audio.h" -#include "usb_audio_frm_defs.h" #include "usb_audio_app.h" +#include "usb_audio_frm_defs.h" static bool app_usbaudio_mode = false; extern "C" void btusbaudio_entry(void); -void app_usbaudio_entry(void) -{ - btusbaudio_entry(); - app_usbaudio_mode = true ; +void app_usbaudio_entry(void) { + btusbaudio_entry(); + app_usbaudio_mode = true; } -bool app_usbaudio_mode_on(void) -{ - return app_usbaudio_mode; +bool app_usbaudio_mode_on(void) { return app_usbaudio_mode; } + +void app_usb_key(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); } -void app_usb_key(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); - -} - -const APP_KEY_HANDLE app_usb_handle_cfg[] = { - {{APP_KEY_CODE_FN1,APP_KEY_EVENT_UP},"USB HID FN1 UP key",app_usb_key, NULL}, - {{APP_KEY_CODE_FN2,APP_KEY_EVENT_UP},"USB HID FN2 UP key",app_usb_key, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_UP},"USB HID PWR UP key",app_usb_key, NULL}, +const APP_KEY_HANDLE app_usb_handle_cfg[] = { + {{APP_KEY_CODE_FN1, APP_KEY_EVENT_UP}, + "USB HID FN1 UP key", + app_usb_key, + NULL}, + {{APP_KEY_CODE_FN2, APP_KEY_EVENT_UP}, + "USB HID FN2 UP key", + app_usb_key, + NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_UP}, + "USB HID PWR UP key", + app_usb_key, + NULL}, }; -void app_usb_key_init(void) -{ - uint8_t i = 0; - TRACE(1,"%s",__func__); - for (i=0; i<(sizeof(app_usb_handle_cfg)/sizeof(APP_KEY_HANDLE)); i++){ - app_key_handle_registration(&app_usb_handle_cfg[i]); - } +void app_usb_key_init(void) { + uint8_t i = 0; + TRACE(1, "%s", __func__); + for (i = 0; i < (sizeof(app_usb_handle_cfg) / sizeof(APP_KEY_HANDLE)); i++) { + app_key_handle_registration(&app_usb_handle_cfg[i]); + } } #endif /* (defined(BTUSB_AUDIO_MODE) || defined(BT_USB_AUDIO_DUAL_MODE)) */ -//#define OS_HAS_CPU_STAT 1 +// #define OS_HAS_CPU_STAT 1 #if OS_HAS_CPU_STAT extern "C" void rtx_show_all_threads_usage(void); #define _CPU_STATISTICS_PEROID_ 6000 -#define CPU_USAGE_TIMER_TMO_VALUE (_CPU_STATISTICS_PEROID_/3) +#define CPU_USAGE_TIMER_TMO_VALUE (_CPU_STATISTICS_PEROID_ / 3) static void cpu_usage_timer_handler(void const *param); osTimerDef(cpu_usage_timer, cpu_usage_timer_handler); static osTimerId cpu_usage_timer_id = NULL; -static void cpu_usage_timer_handler(void const *param) -{ - rtx_show_all_threads_usage(); +static void cpu_usage_timer_handler(void const *param) { + rtx_show_all_threads_usage(); } #endif #ifdef USER_REBOOT_PLAY_MUSIC_AUTO bool a2dp_need_to_play = false; #endif -extern void btif_me_write_bt_sleep_enable(uint8_t sleep_en); +extern void btif_me_write_bt_sleep_enable(uint8_t sleep_en); int btdrv_tportopen(void); - -void app_ibrt_init(void) -{ - app_bt_global_handle_init(); +void app_ibrt_init(void) { + app_bt_global_handle_init(); #if defined(IBRT) - ibrt_config_t config; - app_tws_ibrt_init(); - app_ibrt_ui_init(); - app_ibrt_ui_test_init(); - app_ibrt_if_config_load(&config); - app_ibrt_customif_ui_start(); + ibrt_config_t config; + app_tws_ibrt_init(); + app_ibrt_ui_init(); + app_ibrt_ui_test_init(); + app_ibrt_if_config_load(&config); + app_ibrt_customif_ui_start(); #ifdef IBRT_SEARCH_UI - app_tws_ibrt_start(&config, true); - app_ibrt_search_ui_init(false,IBRT_NONE_EVENT); + app_tws_ibrt_start(&config, true); + app_ibrt_search_ui_init(false, IBRT_NONE_EVENT); #else - app_tws_ibrt_start(&config, false); + app_tws_ibrt_start(&config, false); #endif #ifdef POWER_ON_ENTER_TWS_PAIRING_ENABLED - app_ibrt_ui_event_entry(IBRT_TWS_PAIRING_EVENT); + app_ibrt_ui_event_entry(IBRT_TWS_PAIRING_EVENT); #endif #endif @@ -2141,43 +2281,32 @@ void app_ibrt_init(void) #ifdef GFPS_ENABLED static void app_tell_battery_info_handler(uint8_t *batteryValueCount, - uint8_t *batteryValue) -{ - GFPS_BATTERY_STATUS_E status; - if (app_battery_is_charging()) - { - status = BATTERY_CHARGING; - } - else - { - status = BATTERY_NOT_CHARGING; - } + uint8_t *batteryValue) { + GFPS_BATTERY_STATUS_E status; + if (app_battery_is_charging()) { + status = BATTERY_CHARGING; + } else { + status = BATTERY_NOT_CHARGING; + } - // TODO: add the charger case's battery level + // TODO: add the charger case's battery level #ifdef IBRT - if (app_tws_ibrt_tws_link_connected()) - { - *batteryValueCount = 2; - } - else - { - *batteryValueCount = 1; - } -#else + if (app_tws_ibrt_tws_link_connected()) { + *batteryValueCount = 2; + } else { *batteryValueCount = 1; + } +#else + *batteryValueCount = 1; #endif - TRACE(2,"%s,*batteryValueCount is %d",__func__,*batteryValueCount); - if (1 == *batteryValueCount) - { - batteryValue[0] = ((app_battery_current_level()+1) * 10) | (status << 7); - } - else - { - batteryValue[0] = ((app_battery_current_level()+1) * 10) | (status << 7); - batteryValue[1] = ((app_battery_current_level()+1) * 10) | (status << 7); - - } + TRACE(2, "%s,*batteryValueCount is %d", __func__, *batteryValueCount); + if (1 == *batteryValueCount) { + batteryValue[0] = ((app_battery_current_level() + 1) * 10) | (status << 7); + } else { + batteryValue[0] = ((app_battery_current_level() + 1) * 10) | (status << 7); + batteryValue[1] = ((app_battery_current_level() + 1) * 10) | (status << 7); + } } #endif /* @@ -2190,106 +2319,99 @@ static void app_tell_battery_info_handler(uint8_t *batteryValueCount, #define decice_firstreg 0x00 */ -void touch_evt_handler(enum HAL_GPIO_PIN_T pin) -{ - TRACE(3,"SCL_TOUCH !!!!"); - - /* - unsigned char keyEventBUff0 ; - unsigned char keyEventBUff1 ; - unsigned char keyEventBUff2 ; - unsigned char keyEventBUff3 ; - unsigned char temp = 0; - //hal_gpio_i2c_simple_recv((unsigned char)0x60, 0x40, 1,&keyEventBUff,4); - I2C_ReadByte(regaddr0,&keyEventBUff0); - I2C_ReadByte(regaddr1,&keyEventBUff1); - I2C_ReadByte(regaddr2,&keyEventBUff2); - I2C_ReadByte(regaddr3,&keyEventBUff3); - unsigned char firstaddr; - - I2C_ReadByte(decice_firstreg,&firstaddr); - TRACE(3,"0X00 REG = 0x%x",firstaddr); - unsigned char keyEventBUff4byte[4] ; - I2C_Read4Byte(regaddr0,keyEventBUff4byte); - - I2C_ReadByte(0xC8,&temp); - temp |= 0x01; - I2C_WriteByte(0xC8,temp); - TRACE(3,"REG0X40 = 0x%x, REG0X41 = 0x%x, REG0X42 = 0x%x, REG0X43 = 0x%x",keyEventBUff0,keyEventBUff1,keyEventBUff2,keyEventBUff3); - TRACE(3,"keyEventBUff4BYTE :"); - DUMP8("0x%02x ",keyEventBUff4byte,4); - - uint8_t keyEventBUff0[4]; - uint8_t keyEventBUff4[1]; - - touch_key_i2c_read(regaddr0,&keyEventBUff0[0],1); - touch_key_i2c_read(regaddr1,&keyEventBUff0[1],1); - touch_key_i2c_read(regaddr2,&keyEventBUff0[2],1); - touch_key_i2c_read(regaddr3,&keyEventBUff0[3],1); - touch_key_i2c_read(regaddr4,keyEventBUff4,1); - TRACE(3,"keyEventBUff0 :"); - DUMP8("0x%02x ",keyEventBUff0,4); - TRACE(3,"keyEventBUff1 :"); - DUMP8("0x%02x ",keyEventBUff4,1); - keyEventBUff4[0] |= 0x1; - touch_key_i2c_write(0,regaddr4,1,keyEventBUff4); - */ -} +void touch_evt_handler(enum HAL_GPIO_PIN_T pin) { + TRACE(3, "SCL_TOUCH !!!!"); + /* + unsigned char keyEventBUff0 ; + unsigned char keyEventBUff1 ; + unsigned char keyEventBUff2 ; + unsigned char keyEventBUff3 ; + unsigned char temp = 0; + //hal_gpio_i2c_simple_recv((unsigned char)0x60, 0x40, 1,&keyEventBUff,4); + I2C_ReadByte(regaddr0,&keyEventBUff0); + I2C_ReadByte(regaddr1,&keyEventBUff1); + I2C_ReadByte(regaddr2,&keyEventBUff2); + I2C_ReadByte(regaddr3,&keyEventBUff3); + unsigned char firstaddr; + + I2C_ReadByte(decice_firstreg,&firstaddr); + TRACE(3,"0X00 REG = 0x%x",firstaddr); + unsigned char keyEventBUff4byte[4] ; + I2C_Read4Byte(regaddr0,keyEventBUff4byte); + + I2C_ReadByte(0xC8,&temp); + temp |= 0x01; + I2C_WriteByte(0xC8,temp); + TRACE(3,"REG0X40 = 0x%x, REG0X41 = 0x%x, REG0X42 = 0x%x, REG0X43 = + 0x%x",keyEventBUff0,keyEventBUff1,keyEventBUff2,keyEventBUff3); + TRACE(3,"keyEventBUff4BYTE :"); + DUMP8("0x%02x ",keyEventBUff4byte,4); + + uint8_t keyEventBUff0[4]; + uint8_t keyEventBUff4[1]; + + touch_key_i2c_read(regaddr0,&keyEventBUff0[0],1); + touch_key_i2c_read(regaddr1,&keyEventBUff0[1],1); + touch_key_i2c_read(regaddr2,&keyEventBUff0[2],1); + touch_key_i2c_read(regaddr3,&keyEventBUff0[3],1); + touch_key_i2c_read(regaddr4,keyEventBUff4,1); + TRACE(3,"keyEventBUff0 :"); + DUMP8("0x%02x ",keyEventBUff0,4); + TRACE(3,"keyEventBUff1 :"); + DUMP8("0x%02x ",keyEventBUff4,1); + keyEventBUff4[0] |= 0x1; + touch_key_i2c_write(0,regaddr4,1,keyEventBUff4); + */ +} /******************************LED_status_timer*********************************************************/ osTimerId LED_statusid = NULL; void startLED_status(int ms); void stopLED_status(void); static void LED_statusfun(const void *); -osTimerDef(defLED_status,LED_statusfun); -void LED_statusinit(void) -{ - LED_statusid = osTimerCreate(osTimer(defLED_status),osTimerOnce,(void *)0); +osTimerDef(defLED_status, LED_statusfun); +void LED_statusinit(void) { + LED_statusid = osTimerCreate(osTimer(defLED_status), osTimerOnce, (void *)0); } -static void LED_statusfun(const void *) -{ - //TRACE("\n\n!!!!!!enter %s\n\n",__func__); - if((Curr_Is_Slave()||app_device_bt_is_connected())&&(!app_battery_is_charging())){ - app_status_indication_set(APP_STATUS_INDICATION_CONNECTED); - }else if(!app_device_bt_is_connected()&&(!app_battery_is_charging())){ - app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); - }else if(app_battery_is_charging()){ - app_status_indication_set(APP_STATUS_INDICATION_CHARGING); - } - //unsigned char firstaddr; - //I2C_ReadByte(decice_firstreg,&firstaddr); - //TRACE(3,"0X00 REG = 0x%x",firstaddr); - startLED_status(1000); +static void LED_statusfun(const void *) { + // TRACE("\n\n!!!!!!enter %s\n\n",__func__); + if ((Curr_Is_Slave() || app_device_bt_is_connected()) && + (!app_battery_is_charging())) { + app_status_indication_set(APP_STATUS_INDICATION_CONNECTED); + } else if (!app_device_bt_is_connected() && (!app_battery_is_charging())) { + app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); + } else if (app_battery_is_charging()) { + app_status_indication_set(APP_STATUS_INDICATION_CHARGING); + } + // unsigned char firstaddr; + // I2C_ReadByte(decice_firstreg,&firstaddr); + // TRACE(3,"0X00 REG = 0x%x",firstaddr); + startLED_status(1000); } -void startLED_status(int ms) -{ - //TRACE("\n\n !!!!!!!!!!start %s\n\n",__func__); - osTimerStart(LED_statusid,ms); +void startLED_status(int ms) { + // TRACE("\n\n !!!!!!!!!!start %s\n\n",__func__); + osTimerStart(LED_statusid, ms); } -void stopLED_status(void) -{ - //TRACE("\n\n!!!!!!!!!! stop %s\n\n",__func__); - osTimerStop(LED_statusid); +void stopLED_status(void) { + // TRACE("\n\n!!!!!!!!!! stop %s\n\n",__func__); + osTimerStop(LED_statusid); } /********************************LED_status_timer*******************************************************/ - - /********************************TOUCH_INT_TEST_timer*******************************************************/ -void user_io_timer_init(void) -{ - //app_mute_ctrl_init(); - LED_statusinit(); - //pwrkey_detinit(); - Auto_Shutdowm_Timerinit(); - delay_report_toneinit(); - once_delay_event_Timer_init(); - //app_i2c_demo_init(); - //tou_io_init(); +void user_io_timer_init(void) { + // app_mute_ctrl_init(); + LED_statusinit(); + // pwrkey_detinit(); + Auto_Shutdowm_Timerinit(); + delay_report_toneinit(); + once_delay_event_Timer_init(); + // app_i2c_demo_init(); + // tou_io_init(); } extern uint32_t __coredump_section_start[]; @@ -2303,603 +2425,606 @@ extern uint32_t __userdata_start[]; extern uint32_t __factory_start[]; #if defined(A2DP_LHDC_ON) -extern "C" -{ - typedef struct bes_bt_local_info_t - { - uint8_t bt_addr[BTIF_BD_ADDR_SIZE]; - const char *bt_name; - uint8_t bt_len; - uint8_t ble_addr[BTIF_BD_ADDR_SIZE]; - const char *ble_name; - uint8_t ble_len; - } bes_bt_local_info; +extern "C" { +typedef struct bes_bt_local_info_t { + uint8_t bt_addr[BTIF_BD_ADDR_SIZE]; + const char *bt_name; + uint8_t bt_len; + uint8_t ble_addr[BTIF_BD_ADDR_SIZE]; + const char *ble_name; + uint8_t ble_len; +} bes_bt_local_info; - typedef int (*LHDC_GET_BT_INFO)(bes_bt_local_info *bt_info); - extern bool lhdcSetLicenseKeyTable(uint8_t * licTable, LHDC_GET_BT_INFO pFunc); +typedef int (*LHDC_GET_BT_INFO)(bes_bt_local_info *bt_info); +extern bool lhdcSetLicenseKeyTable(uint8_t *licTable, LHDC_GET_BT_INFO pFunc); } extern int bes_bt_local_info_get(bes_bt_local_info *local_info); -void lhdc_license_check() -{ - uint8_t lhdc_license_key = 0; - uint8_t *lhdc_license_data=(uint8_t * )__lhdc_license_start + 0x98; - TRACE(5,"lhdc_license_data:%p, lhdc license %02x %02x %02x %02x",lhdc_license_data, - lhdc_license_data[0],lhdc_license_data[1],lhdc_license_data[2],lhdc_license_data[3]); - - app_overlay_select(APP_OVERLAY_A2DP_LHDC); - TRACE(1, "current_overlay = %d", app_get_current_overlay()); - - lhdc_license_key = lhdcSetLicenseKeyTable(lhdc_license_data, bes_bt_local_info_get); - TRACE(0, "lhdc_license_key:%d", lhdc_license_key); - - if(lhdc_license_key) - { - TRACE(0, "LHDC OK"); - } - else - { - TRACE(0, "LHDC ERROR"); - } +void lhdc_license_check() { + uint8_t lhdc_license_key = 0; + uint8_t *lhdc_license_data = (uint8_t *)__lhdc_license_start + 0x98; + TRACE(5, "lhdc_license_data:%p, lhdc license %02x %02x %02x %02x", + lhdc_license_data, lhdc_license_data[0], lhdc_license_data[1], + lhdc_license_data[2], lhdc_license_data[3]); + + app_overlay_select(APP_OVERLAY_A2DP_LHDC); + TRACE(1, "current_overlay = %d", app_get_current_overlay()); + + lhdc_license_key = + lhdcSetLicenseKeyTable(lhdc_license_data, bes_bt_local_info_get); + TRACE(0, "lhdc_license_key:%d", lhdc_license_key); + + if (lhdc_license_key) { + TRACE(0, "LHDC OK"); + } else { + TRACE(0, "LHDC ERROR"); + } } #endif -int app_init(void) -{ - int nRet = 0; - struct nvrecord_env_t *nvrecord_env; +int app_init(void) { + int nRet = 0; + struct nvrecord_env_t *nvrecord_env; #ifdef POWER_ON_ENTER_TWS_PAIRING_ENABLED - bool need_check_key = false; + bool need_check_key = false; #else - bool need_check_key = false; + bool need_check_key = false; #endif - uint8_t pwron_case = APP_POWERON_CASE_INVALID; + uint8_t pwron_case = APP_POWERON_CASE_INVALID; #ifdef BT_USB_AUDIO_DUAL_MODE - uint8_t usb_plugin = 0; + uint8_t usb_plugin = 0; #endif #ifdef IBRT_SEARCH_UI - bool is_charging_poweron=false; + bool is_charging_poweron = false; #endif - TRACE(0,"please check all sections sizes and heads is correct ........"); - TRACE(2,"__coredump_section_start: %p length: 0x%x", __coredump_section_start, CORE_DUMP_SECTION_SIZE); - TRACE(2,"__ota_upgrade_log_start: %p length: 0x%x", __ota_upgrade_log_start, OTA_UPGRADE_LOG_SIZE); - TRACE(2,"__log_dump_start: %p length: 0x%x", __log_dump_start, LOG_DUMP_SECTION_SIZE); - TRACE(2,"__crash_dump_start: %p length: 0x%x", __crash_dump_start, CRASH_DUMP_SECTION_SIZE); - TRACE(2,"__custom_parameter_start: %p length: 0x%x", __custom_parameter_start, CUSTOM_PARAMETER_SECTION_SIZE); - TRACE(2,"__lhdc_license_start: %p length: 0x%x", __lhdc_license_start, LHDC_LICENSE_SECTION_SIZE); - TRACE(2,"__userdata_start: %p length: 0x%x", __userdata_start, USERDATA_SECTION_SIZE*2); - TRACE(2,"__aud_start: %p length: 0x%x", __aud_start, AUD_SECTION_SIZE); - TRACE(2,"__factory_start: %p length: 0x%x", __factory_start, FACTORY_SECTION_SIZE); + TRACE(0, "please check all sections sizes and heads is correct ........"); + TRACE(2, "__coredump_section_start: %p length: 0x%x", + __coredump_section_start, CORE_DUMP_SECTION_SIZE); + TRACE(2, "__ota_upgrade_log_start: %p length: 0x%x", __ota_upgrade_log_start, + OTA_UPGRADE_LOG_SIZE); + TRACE(2, "__log_dump_start: %p length: 0x%x", __log_dump_start, + LOG_DUMP_SECTION_SIZE); + TRACE(2, "__crash_dump_start: %p length: 0x%x", __crash_dump_start, + CRASH_DUMP_SECTION_SIZE); + TRACE(2, "__custom_parameter_start: %p length: 0x%x", + __custom_parameter_start, CUSTOM_PARAMETER_SECTION_SIZE); + TRACE(2, "__lhdc_license_start: %p length: 0x%x", __lhdc_license_start, + LHDC_LICENSE_SECTION_SIZE); + TRACE(2, "__userdata_start: %p length: 0x%x", __userdata_start, + USERDATA_SECTION_SIZE * 2); + TRACE(2, "__aud_start: %p length: 0x%x", __aud_start, AUD_SECTION_SIZE); + TRACE(2, "__factory_start: %p length: 0x%x", __factory_start, + FACTORY_SECTION_SIZE); - TRACE(0,"app_init\n"); - app_tws_set_side_from_gpio(); + TRACE(0, "app_init\n"); + app_tws_set_side_from_gpio(); #ifdef __RPC_ENABLE__ -extern int rpc_service_setup(void); - rpc_service_setup(); + extern int rpc_service_setup(void); + rpc_service_setup(); #endif #ifdef IBRT - // init tws interface - app_tws_if_init(); + // init tws interface + app_tws_if_init(); #endif // #ifdef IBRT - nv_record_init(); - factory_section_init(); + nv_record_init(); + factory_section_init(); #ifdef ANC_APP - app_anc_ios_init(); + app_anc_ios_init(); #endif - app_sysfreq_req(APP_SYSFREQ_USER_APP_INIT, APP_SYSFREQ_104M); + app_sysfreq_req(APP_SYSFREQ_USER_APP_INIT, APP_SYSFREQ_104M); #if defined(MCU_HIGH_PERFORMANCE_MODE) - TRACE(1,"sys freq calc : %d\n", hal_sys_timer_calc_cpu_freq(5, 0)); + TRACE(1, "sys freq calc : %d\n", hal_sys_timer_calc_cpu_freq(5, 0)); #endif - list_init(); - nRet = app_os_init(); - if (nRet) { - goto exit; - } + list_init(); + nRet = app_os_init(); + if (nRet) { + goto exit; + } #if OS_HAS_CPU_STAT - cpu_usage_timer_id = osTimerCreate(osTimer(cpu_usage_timer), osTimerPeriodic, NULL); - if (cpu_usage_timer_id != NULL) { - osTimerStart(cpu_usage_timer_id, CPU_USAGE_TIMER_TMO_VALUE); - } + cpu_usage_timer_id = + osTimerCreate(osTimer(cpu_usage_timer), osTimerPeriodic, NULL); + if (cpu_usage_timer_id != NULL) { + osTimerStart(cpu_usage_timer_id, CPU_USAGE_TIMER_TMO_VALUE); + } #endif - //app_status_indication_init(); + // app_status_indication_init(); #ifdef BTADDR_FOR_DEBUG - gen_bt_addr_for_debug(); + gen_bt_addr_for_debug(); #endif #ifdef FORCE_SIGNALINGMODE - hal_sw_bootmode_clear(HAL_SW_BOOTMODE_TEST_NOSIGNALINGMODE); - hal_sw_bootmode_set(HAL_SW_BOOTMODE_TEST_MODE | HAL_SW_BOOTMODE_TEST_SIGNALINGMODE); + hal_sw_bootmode_clear(HAL_SW_BOOTMODE_TEST_NOSIGNALINGMODE); + hal_sw_bootmode_set(HAL_SW_BOOTMODE_TEST_MODE | + HAL_SW_BOOTMODE_TEST_SIGNALINGMODE); #elif defined FORCE_NOSIGNALINGMODE - hal_sw_bootmode_clear(HAL_SW_BOOTMODE_TEST_SIGNALINGMODE); - hal_sw_bootmode_set(HAL_SW_BOOTMODE_TEST_MODE | HAL_SW_BOOTMODE_TEST_NOSIGNALINGMODE); + hal_sw_bootmode_clear(HAL_SW_BOOTMODE_TEST_SIGNALINGMODE); + hal_sw_bootmode_set(HAL_SW_BOOTMODE_TEST_MODE | + HAL_SW_BOOTMODE_TEST_NOSIGNALINGMODE); #endif - if (hal_sw_bootmode_get() & HAL_SW_BOOTMODE_REBOOT_FROM_CRASH){ - hal_sw_bootmode_clear(HAL_SW_BOOTMODE_REBOOT_FROM_CRASH); - TRACE(0,"Crash happened!!!"); - #ifdef VOICE_DATAPATH - gsound_dump_set_flag(true); - #endif - } + if (hal_sw_bootmode_get() & HAL_SW_BOOTMODE_REBOOT_FROM_CRASH) { + hal_sw_bootmode_clear(HAL_SW_BOOTMODE_REBOOT_FROM_CRASH); + TRACE(0, "Crash happened!!!"); +#ifdef VOICE_DATAPATH + gsound_dump_set_flag(true); +#endif + } - if (hal_sw_bootmode_get() & HAL_SW_BOOTMODE_REBOOT){ - hal_sw_bootmode_clear(HAL_SW_BOOTMODE_REBOOT); - pwron_case = APP_POWERON_CASE_REBOOT; - need_check_key = false; - TRACE(0,"Initiative REBOOT happens!!!"); + if (hal_sw_bootmode_get() & HAL_SW_BOOTMODE_REBOOT) { + hal_sw_bootmode_clear(HAL_SW_BOOTMODE_REBOOT); + pwron_case = APP_POWERON_CASE_REBOOT; + need_check_key = false; + TRACE(0, "Initiative REBOOT happens!!!"); #ifdef USER_REBOOT_PLAY_MUSIC_AUTO - if(hal_sw_bootmode_get() & HAL_SW_BOOTMODE_LOCAL_PLAYER) - { - hal_sw_bootmode_clear(HAL_SW_BOOTMODE_LOCAL_PLAYER); - a2dp_need_to_play = true; - TRACE(0,"a2dp_need_to_play = true"); - } + if (hal_sw_bootmode_get() & HAL_SW_BOOTMODE_LOCAL_PLAYER) { + hal_sw_bootmode_clear(HAL_SW_BOOTMODE_LOCAL_PLAYER); + a2dp_need_to_play = true; + TRACE(0, "a2dp_need_to_play = true"); + } #endif - } - - if (hal_sw_bootmode_get() & HAL_SW_BOOTMODE_TEST_MODE){ - hal_sw_bootmode_clear(HAL_SW_BOOTMODE_TEST_MODE); - pwron_case = APP_POWERON_CASE_TEST; - need_check_key = false; - TRACE(0,"To enter test mode!!!"); - } + } + if (hal_sw_bootmode_get() & HAL_SW_BOOTMODE_TEST_MODE) { + hal_sw_bootmode_clear(HAL_SW_BOOTMODE_TEST_MODE); + pwron_case = APP_POWERON_CASE_TEST; + need_check_key = false; + TRACE(0, "To enter test mode!!!"); + } #ifdef BT_USB_AUDIO_DUAL_MODE - usb_os_init(); + usb_os_init(); #endif - nRet = app_battery_open(); - TRACE(1,"Yin BATTERY %d",nRet); - if (pwron_case != APP_POWERON_CASE_TEST){ + nRet = app_battery_open(); + TRACE(1, "Yin BATTERY %d", nRet); + if (pwron_case != APP_POWERON_CASE_TEST) { #ifdef USER_REBOOT_PLAY_MUSIC_AUTO - TRACE(0,"hal_sw_bootmode_clear HAL_SW_BOOTMODE_LOCAL_PLAYER!!!!!!"); - hal_sw_bootmode_clear(HAL_SW_BOOTMODE_LOCAL_PLAYER); + TRACE(0, "hal_sw_bootmode_clear HAL_SW_BOOTMODE_LOCAL_PLAYER!!!!!!"); + hal_sw_bootmode_clear(HAL_SW_BOOTMODE_LOCAL_PLAYER); #endif - switch (nRet) { - case APP_BATTERY_OPEN_MODE_NORMAL: - nRet = 0; - break; - case APP_BATTERY_OPEN_MODE_CHARGING: - app_status_indication_set(APP_STATUS_INDICATION_CHARGING); - TRACE(0,"CHARGING!"); - app_battery_start(); + switch (nRet) { + case APP_BATTERY_OPEN_MODE_NORMAL: + nRet = 0; + break; + case APP_BATTERY_OPEN_MODE_CHARGING: + app_status_indication_set(APP_STATUS_INDICATION_CHARGING); + TRACE(0, "CHARGING!"); + app_battery_start(); - app_key_open(false); - app_key_init_on_charging(); - nRet = 0; + app_key_open(false); + app_key_init_on_charging(); + nRet = 0; #if defined(BT_USB_AUDIO_DUAL_MODE) - usb_plugin = 1; + usb_plugin = 1; #elif defined(BTUSB_AUDIO_MODE) - goto exit; + goto exit; #endif - goto exit; - break; - case APP_BATTERY_OPEN_MODE_CHARGING_PWRON: - TRACE(0,"CHARGING PWRON!"); + goto exit; + break; + case APP_BATTERY_OPEN_MODE_CHARGING_PWRON: + TRACE(0, "CHARGING PWRON!"); #ifdef IBRT_SEARCH_UI - is_charging_poweron=true; + is_charging_poweron = true; #endif - app_status_indication_set(APP_STATUS_INDICATION_CHARGING); - need_check_key = false; - nRet = 0; - break; - case APP_BATTERY_OPEN_MODE_INVALID: - default: - nRet = -1; - goto exit; - break; - } + app_status_indication_set(APP_STATUS_INDICATION_CHARGING); + need_check_key = false; + nRet = 0; + break; + case APP_BATTERY_OPEN_MODE_INVALID: + default: + nRet = -1; + goto exit; + break; } + } - if (app_key_open(need_check_key)){ - TRACE(0,"PWR KEY DITHER!"); - nRet = -1; - goto exit; - } + if (app_key_open(need_check_key)) { + TRACE(0, "PWR KEY DITHER!"); + nRet = -1; + goto exit; + } - hal_sw_bootmode_set(HAL_SW_BOOTMODE_REBOOT); - app_poweron_key_init(); + hal_sw_bootmode_set(HAL_SW_BOOTMODE_REBOOT); + app_poweron_key_init(); #if defined(_AUTO_TEST_) - AUTO_TEST_SEND("Power on."); + AUTO_TEST_SEND("Power on."); #endif - app_bt_init(); - af_open(); - app_audio_open(); - app_audio_manager_open(); - app_overlay_open(); + app_bt_init(); + af_open(); + app_audio_open(); + app_audio_manager_open(); + app_overlay_open(); - nv_record_env_init(); - nvrec_dev_data_open(); - factory_section_open(); - - /*****************************************************************************/ -// app_bt_connect2tester_init(); - nv_record_env_get(&nvrecord_env); + nv_record_env_init(); + nvrec_dev_data_open(); + factory_section_open(); + /*****************************************************************************/ + // app_bt_connect2tester_init(); + nv_record_env_get(&nvrecord_env); #ifdef AUDIO_LOOPBACK #ifdef WL_DET - app_mic_alg_audioloop(true,APP_SYSFREQ_78M); + app_mic_alg_audioloop(true, APP_SYSFREQ_78M); #endif - while(1); + while (1) + ; #endif #ifdef BISTO_ENABLED - nv_record_gsound_rec_init(); + nv_record_gsound_rec_init(); #endif #ifdef BLE_ENABLE - app_ble_mode_init(); - app_ble_customif_init(); + app_ble_mode_init(); + app_ble_customif_init(); #ifdef IBRT - app_ble_force_switch_adv(BLE_SWITCH_USER_IBRT, false); + app_ble_force_switch_adv(BLE_SWITCH_USER_IBRT, false); #endif // #ifdef IBRT #endif - audio_process_init(); + audio_process_init(); #ifdef __PC_CMD_UART__ - app_cmd_open(); + app_cmd_open(); #endif #ifdef AUDIO_DEBUG_V0_1_0 - speech_tuning_init(); + speech_tuning_init(); #endif #ifdef ANC_APP - app_anc_open_module(); + app_anc_open_module(); #endif #ifdef MEDIA_PLAYER_SUPPORT - app_play_audio_set_lang(nvrecord_env->media_language.language); + app_play_audio_set_lang(nvrecord_env->media_language.language); #endif - app_bt_stream_volume_ptr_update(NULL); + app_bt_stream_volume_ptr_update(NULL); #ifdef __THIRDPARTY - app_thirdparty_init(); - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO2,THIRDPARTY_INIT); + app_thirdparty_init(); + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO2, + THIRDPARTY_INIT); #endif - // TODO: freddie->unify all of the OTA modules + // TODO: freddie->unify all of the OTA modules #if defined(IBRT_OTA) - ota_flash_init(); + ota_flash_init(); #endif #ifdef OTA_ENABLED - /// init OTA common module - ota_common_init_handler(); + /// init OTA common module + ota_common_init_handler(); #endif // OTA_ENABLED #ifdef IBRT - // for TWS side decision, the last bit is 1:right, 0:left - if (app_tws_is_unknown_side()) - { - //app_tws_set_side_from_addr(factory_section_get_bt_address()); - app_tws_set_side_from_gpio(); - } + // for TWS side decision, the last bit is 1:right, 0:left + if (app_tws_is_unknown_side()) { + // app_tws_set_side_from_addr(factory_section_get_bt_address()); + app_tws_set_side_from_gpio(); + } #endif - - btdrv_start_bt(); -#if defined (__GMA_VOICE__) && defined(IBRT_SEARCH_UI) - app_ibrt_reconfig_btAddr_from_nv(); + btdrv_start_bt(); +#if defined(__GMA_VOICE__) && defined(IBRT_SEARCH_UI) + app_ibrt_reconfig_btAddr_from_nv(); #endif - if (pwron_case != APP_POWERON_CASE_TEST) { - BesbtInit(); - app_wait_stack_ready(); - bt_drv_extra_config_after_init(); - bt_generate_ecdh_key_pair(); - app_bt_start_custom_function_in_bt_thread((uint32_t)0, - 0, (uint32_t)app_ibrt_init); - } + if (pwron_case != APP_POWERON_CASE_TEST) { + BesbtInit(); + app_wait_stack_ready(); + bt_drv_extra_config_after_init(); + bt_generate_ecdh_key_pair(); + app_bt_start_custom_function_in_bt_thread((uint32_t)0, 0, + (uint32_t)app_ibrt_init); + } #if defined(BLE_ENABLE) && defined(IBRT) - app_ble_force_switch_adv(BLE_SWITCH_USER_IBRT, true); + app_ble_force_switch_adv(BLE_SWITCH_USER_IBRT, true); #endif - app_sysfreq_req(APP_SYSFREQ_USER_APP_INIT, APP_SYSFREQ_52M); - TRACE(1,"\n\n\nbt_stack_init_done:%d\n\n\n", pwron_case); + app_sysfreq_req(APP_SYSFREQ_USER_APP_INIT, APP_SYSFREQ_52M); + TRACE(1, "\n\n\nbt_stack_init_done:%d\n\n\n", pwron_case); - if (pwron_case == APP_POWERON_CASE_REBOOT){ - app_status_indication_init(); - user_io_timer_init(); - app_status_indication_set(APP_STATUS_INDICATION_POWERON); + if (pwron_case == APP_POWERON_CASE_REBOOT) { + app_status_indication_init(); + user_io_timer_init(); + app_status_indication_set(APP_STATUS_INDICATION_POWERON); #ifdef MEDIA_PLAYER_SUPPORT - app_voice_report(APP_STATUS_INDICATION_POWERON, 0); + app_voice_report(APP_STATUS_INDICATION_POWERON, 0); #endif - app_bt_start_custom_function_in_bt_thread((uint32_t)1, - 0, (uint32_t)btif_me_write_bt_sleep_enable); - btdrv_set_lpo_times(); + app_bt_start_custom_function_in_bt_thread( + (uint32_t)1, 0, (uint32_t)btif_me_write_bt_sleep_enable); + btdrv_set_lpo_times(); #if defined(IBRT_OTA) - bes_ota_init(); + bes_ota_init(); #endif - //app_bt_accessmode_set(BTIF_BAM_NOT_ACCESSIBLE); + // app_bt_accessmode_set(BTIF_BAM_NOT_ACCESSIBLE); #if defined(IBRT) #ifdef IBRT_SEARCH_UI - if(is_charging_poweron==false) - { - if(IBRT_UNKNOW == nvrecord_env->ibrt_mode.mode) - { - TRACE(0,"ibrt_ui_log:power on unknow mode"); - app_ibrt_enter_limited_mode(); - //if(app_tws_is_right_side()) - if(1) - { - TRACE(0,"app_start_tws_serching_direactly"); - app_start_tws_serching_direactly(); - } + if (is_charging_poweron == false) { + if (IBRT_UNKNOW == nvrecord_env->ibrt_mode.mode) { + TRACE(0, "ibrt_ui_log:power on unknow mode"); + app_ibrt_enter_limited_mode(); + // if(app_tws_is_right_side()) + if (1) { + TRACE(0, "app_start_tws_serching_direactly"); + app_start_tws_serching_direactly(); + } + } else { + TRACE(1, "ibrt_ui_log:power on %d fetch out", + nvrecord_env->ibrt_mode.mode); + app_ibrt_ui_event_entry(IBRT_FETCH_OUT_EVENT); + } + // startLED_status(1000); + once_event_case = 9; + startonce_delay_event_Timer_(1000); + // startpwrkey_det(200); + } +#elif defined(IS_MULTI_AI_ENABLED) + // when ama and bisto switch, earphone need reconnect with peer, master need + // reconnect with phone + uint8_t box_action = app_ai_tws_reboot_get_box_action(); + if (box_action != 0xFF) { + TRACE(2, "%s box_actionstate %d", __func__, box_action); + app_ibrt_ui_event_entry(box_action | IBRT_SKIP_FALSE_TRIGGER_MASK); + } +#endif +#else + app_bt_accessmode_set(BTIF_BAM_NOT_ACCESSIBLE); +#endif + + app_key_init(); + app_battery_start(); +#if defined(__BTIF_EARPHONE__) && defined(__BTIF_AUTOPOWEROFF__) + app_start_10_second_timer(APP_POWEROFF_TIMER_ID); +#endif + +#if defined(__IAG_BLE_INCLUDE__) && defined(BTIF_BLE_APP_DATAPATH_SERVER) + BLE_custom_command_init(); +#endif +#ifdef __THIRDPARTY + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1, + THIRDPARTY_INIT); + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1, + THIRDPARTY_START); + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO2, + THIRDPARTY_BT_CONNECTABLE); + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO3, + THIRDPARTY_START); +#endif +#if defined(__BTIF_EARPHONE__) && defined(__BTIF_BT_RECONNECT__) +#if !defined(IBRT) + app_bt_profile_connect_manager_opening_reconnect(); +#endif +#endif + } +#ifdef __ENGINEER_MODE_SUPPORT__ + else if (pwron_case == APP_POWERON_CASE_TEST) { + app_status_indication_init(); + app_factorymode_set(true); + app_status_indication_set(APP_STATUS_INDICATION_POWERON); +#ifdef MEDIA_PLAYER_SUPPORT + app_voice_report(APP_STATUS_INDICATION_POWERON, 0); +#endif +#ifdef __WATCHER_DOG_RESET__ + app_wdt_close(); +#endif + TRACE(0, "!!!!!ENGINEER_MODE!!!!!\n"); + nRet = 0; + app_nvrecord_rebuild(); + app_factorymode_key_init(); + if (hal_sw_bootmode_get() & HAL_SW_BOOTMODE_TEST_SIGNALINGMODE) { + hal_sw_bootmode_clear(HAL_SW_BOOTMODE_TEST_MASK); + app_factorymode_bt_signalingtest(NULL, NULL); + } + if (hal_sw_bootmode_get() & HAL_SW_BOOTMODE_TEST_NOSIGNALINGMODE) { + hal_sw_bootmode_clear(HAL_SW_BOOTMODE_TEST_MASK); + app_factorymode_bt_nosignalingtest(NULL, NULL); + } + } +#endif + else { + user_io_timer_init(); + app_status_indication_init(); + app_status_indication_set(APP_STATUS_INDICATION_POWERON); +#ifdef MEDIA_PLAYER_SUPPORT + app_voice_report(APP_STATUS_INDICATION_POWERON, 0); +#endif + if (need_check_key) { + pwron_case = app_poweron_wait_case(); + } else { + pwron_case = APP_POWERON_CASE_NORMAL; + } + if (need_check_key) { +#ifndef __POWERKEY_CTRL_ONOFF_ONLY__ + app_poweron_wait_finished(); +#endif + } + if (pwron_case != APP_POWERON_CASE_INVALID && + pwron_case != APP_POWERON_CASE_DITHERING) { + TRACE(1, "power on case:%d\n", pwron_case); + nRet = 0; +#ifndef __POWERKEY_CTRL_ONOFF_ONLY__ + // app_status_indication_set(APP_STATUS_INDICATION_INITIAL); +#endif + app_bt_start_custom_function_in_bt_thread( + (uint32_t)1, 0, (uint32_t)btif_me_write_bt_sleep_enable); + btdrv_set_lpo_times(); + +#ifdef IBRT_OTA + bes_ota_init(); +#endif + +#ifdef __INTERCONNECTION__ + app_interconnection_init(); +#endif + +#ifdef __INTERACTION__ + app_interaction_init(); +#endif + +#if defined(__IAG_BLE_INCLUDE__) && defined(BTIF_BLE_APP_DATAPATH_SERVER) + BLE_custom_command_init(); +#endif +#ifdef GFPS_ENABLED + app_gfps_set_battery_info_acquire_handler(app_tell_battery_info_handler); + app_gfps_set_battery_datatype(SHOW_UI_INDICATION); +#endif + osDelay(500); + + switch (pwron_case) { + case APP_POWERON_CASE_CALIB: + break; + case APP_POWERON_CASE_BOTHSCAN: + app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); +#ifdef MEDIA_PLAYER_SUPPORT + app_voice_report(APP_STATUS_INDICATION_BOTHSCAN, 0); +#endif +#if defined(__BTIF_EARPHONE__) +#if defined(IBRT) +#ifdef IBRT_SEARCH_UI + if (false == is_charging_poweron) + app_ibrt_enter_limited_mode(); +#endif +#else + app_bt_accessmode_set(BTIF_BT_DEFAULT_ACCESS_MODE_PAIR); +#endif +#ifdef GFPS_ENABLED + app_enter_fastpairing_mode(); +#endif +#if defined(__BTIF_AUTOPOWEROFF__) + app_start_10_second_timer(APP_PAIR_TIMER_ID); +#endif +#endif +#ifdef __THIRDPARTY + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO2, + THIRDPARTY_BT_DISCOVERABLE); +#endif + break; + case APP_POWERON_CASE_NORMAL: +#if defined(__BTIF_EARPHONE__) && !defined(__EARPHONE_STAY_BOTH_SCAN__) +#if defined(IBRT) +#ifdef IBRT_SEARCH_UI + app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); + if (is_charging_poweron == false) { + startLED_status(1000); + once_event_case = 9; + startonce_delay_event_Timer_(1000); + if (IBRT_UNKNOW == nvrecord_env->ibrt_mode.mode) { + TRACE(0, "ibrt_ui_log:power on unknow mode"); + app_ibrt_enter_limited_mode(); + if (app_tws_is_right_side()) { + app_start_tws_serching_direactly(); } - else - { - TRACE(1,"ibrt_ui_log:power on %d fetch out", nvrecord_env->ibrt_mode.mode); - app_ibrt_ui_event_entry(IBRT_FETCH_OUT_EVENT); - } - //startLED_status(1000); - once_event_case = 9; - startonce_delay_event_Timer_(1000); - //startpwrkey_det(200); + } else { + TRACE(1, "ibrt_ui_log:power on %d fetch out", + nvrecord_env->ibrt_mode.mode); + app_ibrt_ui_event_entry(IBRT_FETCH_OUT_EVENT); + // app_status_indication_set(APP_STATUS_INDICATION_CHARGING); + // break; + } + // startpwrkey_det(200); } #elif defined(IS_MULTI_AI_ENABLED) - //when ama and bisto switch, earphone need reconnect with peer, master need reconnect with phone - uint8_t box_action = app_ai_tws_reboot_get_box_action(); - if (box_action != 0xFF) - { - TRACE(2, "%s box_actionstate %d", __func__, box_action); - app_ibrt_ui_event_entry(box_action|IBRT_SKIP_FALSE_TRIGGER_MASK); - } + // when ama and bisto switch, earphone need reconnect with peer, master + // need reconnect with phone + // app_ibrt_ui_event_entry(IBRT_OPEN_BOX_EVENT); + // TRACE(1,"ibrt_ui_log:power on %d fetch out", + // nvrecord_env->ibrt_mode.mode); + // app_ibrt_ui_event_entry(IBRT_FETCH_OUT_EVENT); #endif #else app_bt_accessmode_set(BTIF_BAM_NOT_ACCESSIBLE); #endif - - app_key_init(); - app_battery_start(); -#if defined(__BTIF_EARPHONE__) && defined(__BTIF_AUTOPOWEROFF__) - app_start_10_second_timer(APP_POWEROFF_TIMER_ID); #endif - -#if defined(__IAG_BLE_INCLUDE__) && defined(BTIF_BLE_APP_DATAPATH_SERVER) - BLE_custom_command_init(); -#endif -#ifdef __THIRDPARTY - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1,THIRDPARTY_INIT); - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1,THIRDPARTY_START); - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO2,THIRDPARTY_BT_CONNECTABLE); - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO3,THIRDPARTY_START); -#endif -#if defined( __BTIF_EARPHONE__) && defined(__BTIF_BT_RECONNECT__) -#if !defined(IBRT) + case APP_POWERON_CASE_REBOOT: + case APP_POWERON_CASE_ALARM: + default: + // app_status_indication_set(APP_STATUS_INDICATION_PAGESCAN); +#if defined(__BTIF_EARPHONE__) && defined(__BTIF_BT_RECONNECT__) && \ + !defined(IBRT) app_bt_profile_connect_manager_opening_reconnect(); #endif -#endif - } -#ifdef __ENGINEER_MODE_SUPPORT__ - else if(pwron_case == APP_POWERON_CASE_TEST){ - app_status_indication_init(); - app_factorymode_set(true); - app_status_indication_set(APP_STATUS_INDICATION_POWERON); -#ifdef MEDIA_PLAYER_SUPPORT - app_voice_report(APP_STATUS_INDICATION_POWERON, 0); -#endif -#ifdef __WATCHER_DOG_RESET__ - app_wdt_close(); -#endif - TRACE(0,"!!!!!ENGINEER_MODE!!!!!\n"); - nRet = 0; - app_nvrecord_rebuild(); - app_factorymode_key_init(); - if (hal_sw_bootmode_get() & HAL_SW_BOOTMODE_TEST_SIGNALINGMODE){ - hal_sw_bootmode_clear(HAL_SW_BOOTMODE_TEST_MASK); - app_factorymode_bt_signalingtest(NULL, NULL); - } - if (hal_sw_bootmode_get() & HAL_SW_BOOTMODE_TEST_NOSIGNALINGMODE){ - hal_sw_bootmode_clear(HAL_SW_BOOTMODE_TEST_MASK); - app_factorymode_bt_nosignalingtest(NULL, NULL); - } - } -#endif - else{ - user_io_timer_init(); - app_status_indication_init(); - app_status_indication_set(APP_STATUS_INDICATION_POWERON); -#ifdef MEDIA_PLAYER_SUPPORT - app_voice_report(APP_STATUS_INDICATION_POWERON, 0); -#endif - if (need_check_key){ - pwron_case = app_poweron_wait_case(); - } - else - { - pwron_case = APP_POWERON_CASE_NORMAL; - } - if (need_check_key) - { -#ifndef __POWERKEY_CTRL_ONOFF_ONLY__ - app_poweron_wait_finished(); -#endif - } - if (pwron_case != APP_POWERON_CASE_INVALID && pwron_case != APP_POWERON_CASE_DITHERING){ - TRACE(1,"power on case:%d\n", pwron_case); - nRet = 0; -#ifndef __POWERKEY_CTRL_ONOFF_ONLY__ - //app_status_indication_set(APP_STATUS_INDICATION_INITIAL); -#endif - app_bt_start_custom_function_in_bt_thread((uint32_t)1, - 0, (uint32_t)btif_me_write_bt_sleep_enable); - btdrv_set_lpo_times(); - -#ifdef IBRT_OTA - bes_ota_init(); -#endif - -#ifdef __INTERCONNECTION__ - app_interconnection_init(); -#endif - -#ifdef __INTERACTION__ - app_interaction_init(); -#endif - -#if defined(__IAG_BLE_INCLUDE__) && defined(BTIF_BLE_APP_DATAPATH_SERVER) - BLE_custom_command_init(); -#endif -#ifdef GFPS_ENABLED - app_gfps_set_battery_info_acquire_handler(app_tell_battery_info_handler); - app_gfps_set_battery_datatype(SHOW_UI_INDICATION); -#endif - osDelay(500); - - switch (pwron_case) { - case APP_POWERON_CASE_CALIB: - break; - case APP_POWERON_CASE_BOTHSCAN: - app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); -#ifdef MEDIA_PLAYER_SUPPORT - app_voice_report(APP_STATUS_INDICATION_BOTHSCAN,0); -#endif -#if defined( __BTIF_EARPHONE__) -#if defined(IBRT) -#ifdef IBRT_SEARCH_UI - if(false==is_charging_poweron) - app_ibrt_enter_limited_mode(); -#endif -#else - app_bt_accessmode_set(BTIF_BT_DEFAULT_ACCESS_MODE_PAIR); -#endif -#ifdef GFPS_ENABLED - app_enter_fastpairing_mode(); -#endif -#if defined(__BTIF_AUTOPOWEROFF__) - app_start_10_second_timer(APP_PAIR_TIMER_ID); -#endif -#endif #ifdef __THIRDPARTY - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO2,THIRDPARTY_BT_DISCOVERABLE); -#endif - break; - case APP_POWERON_CASE_NORMAL: -#if defined( __BTIF_EARPHONE__ ) && !defined(__EARPHONE_STAY_BOTH_SCAN__) -#if defined(IBRT) -#ifdef IBRT_SEARCH_UI - app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); - if(is_charging_poweron==false) - { - startLED_status(1000); - once_event_case = 9; - startonce_delay_event_Timer_(1000); - if(IBRT_UNKNOW == nvrecord_env->ibrt_mode.mode) - { - TRACE(0,"ibrt_ui_log:power on unknow mode"); - app_ibrt_enter_limited_mode(); - if(app_tws_is_right_side()){ - app_start_tws_serching_direactly(); - } - } - else - { - TRACE(1,"ibrt_ui_log:power on %d fetch out", nvrecord_env->ibrt_mode.mode); - app_ibrt_ui_event_entry(IBRT_FETCH_OUT_EVENT); - // app_status_indication_set(APP_STATUS_INDICATION_CHARGING); - //break; - } - //startpwrkey_det(200); - } -#elif defined(IS_MULTI_AI_ENABLED) - //when ama and bisto switch, earphone need reconnect with peer, master need reconnect with phone - //app_ibrt_ui_event_entry(IBRT_OPEN_BOX_EVENT); - //TRACE(1,"ibrt_ui_log:power on %d fetch out", nvrecord_env->ibrt_mode.mode); - //app_ibrt_ui_event_entry(IBRT_FETCH_OUT_EVENT); -#endif -#else - app_bt_accessmode_set(BTIF_BAM_NOT_ACCESSIBLE); -#endif -#endif - case APP_POWERON_CASE_REBOOT: - case APP_POWERON_CASE_ALARM: - default: - //app_status_indication_set(APP_STATUS_INDICATION_PAGESCAN); -#if defined( __BTIF_EARPHONE__) && defined(__BTIF_BT_RECONNECT__) && !defined(IBRT) - app_bt_profile_connect_manager_opening_reconnect(); -#endif -#ifdef __THIRDPARTY - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO2,THIRDPARTY_BT_CONNECTABLE); + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO2, + THIRDPARTY_BT_CONNECTABLE); #endif - break; - } + break; + } - app_key_init(); - app_battery_start(); + app_key_init(); + app_battery_start(); #if defined(A2DP_LHDC_ON) - lhdc_license_check(); + lhdc_license_check(); #endif #if defined(__BTIF_EARPHONE__) && defined(__BTIF_AUTOPOWEROFF__) - app_start_10_second_timer(APP_POWEROFF_TIMER_ID); + app_start_10_second_timer(APP_POWEROFF_TIMER_ID); #endif #ifdef __THIRDPARTY - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1,THIRDPARTY_INIT); - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1,THIRDPARTY_START); - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO3,THIRDPARTY_START); + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1, + THIRDPARTY_INIT); + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1, + THIRDPARTY_START); + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO3, + THIRDPARTY_START); #endif #ifdef RB_CODEC - rb_ctl_init(); + rb_ctl_init(); #endif - }else{ - af_close(); - app_key_close(); - nRet = -1; - } + } else { + af_close(); + app_key_close(); + nRet = -1; } + } exit: #ifdef IS_MULTI_AI_ENABLED - app_ai_tws_clear_reboot_box_state(); + app_ai_tws_clear_reboot_box_state(); #endif #ifdef __BT_DEBUG_TPORTS__ - { - extern void bt_enable_tports(void); - bt_enable_tports(); - //hal_iomux_tportopen(); - } + { + extern void bt_enable_tports(void); + bt_enable_tports(); + // hal_iomux_tportopen(); + } #endif #ifdef ANC_APP - app_anc_set_init_done(); + app_anc_set_init_done(); #endif #ifdef BT_USB_AUDIO_DUAL_MODE - if(usb_plugin) - { - btusb_switch(BTUSB_MODE_USB); - } - else - { - btusb_switch(BTUSB_MODE_BT); - } -#else //BT_USB_AUDIO_DUAL_MODE + if (usb_plugin) { + btusb_switch(BTUSB_MODE_USB); + } else { + btusb_switch(BTUSB_MODE_BT); + } +#else // BT_USB_AUDIO_DUAL_MODE #if defined(BTUSB_AUDIO_MODE) - if(pwron_case == APP_POWERON_CASE_CHARGING) { + if (pwron_case == APP_POWERON_CASE_CHARGING) { #ifdef __WATCHER_DOG_RESET__ - app_wdt_close(); + app_wdt_close(); #endif - af_open(); - app_key_handle_clear(); - app_usb_key_init(); - app_usbaudio_entry(); - } + af_open(); + app_key_handle_clear(); + app_usb_key_init(); + app_usbaudio_entry(); + } #endif // BTUSB_AUDIO_MODE #endif // BT_USB_AUDIO_DUAL_MODE - app_sysfreq_req(APP_SYSFREQ_USER_APP_INIT, APP_SYSFREQ_32K); + app_sysfreq_req(APP_SYSFREQ_USER_APP_INIT, APP_SYSFREQ_32K); - return nRet; + return nRet; } #endif /* APP_TEST_MODE */ diff --git a/apps/main/apps_tester.cpp b/apps/main/apps_tester.cpp index cfead04..d0d2edf 100644 --- a/apps/main/apps_tester.cpp +++ b/apps/main/apps_tester.cpp @@ -13,21 +13,21 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "stdio.h" #include "cmsis_os.h" +#include "stdio.h" #include "string.h" -#include "hal_iomux.h" #include "app_key.h" -#include "hal_trace.h" +#include "hal_iomux.h" #include "hal_sleep.h" +#include "hal_trace.h" -#include "audioflinger.h" -#include "audiobuffer.h" #include "app_thread.h" #include "app_utils.h" -#include "bt_drv_interface.h" +#include "audiobuffer.h" +#include "audioflinger.h" #include "besbt.h" +#include "bt_drv_interface.h" #if defined(APP_TEST_AUDIO) && defined(ANC_APP) #include "anc_usb_app.h" @@ -35,278 +35,299 @@ //#include "dualadc_audio_app.h" #endif -#define APP_TESTER_CPU_WAKE_LOCK HAL_CPU_WAKE_LOCK_USER_3 +#define APP_TESTER_CPU_WAKE_LOCK HAL_CPU_WAKE_LOCK_USER_3 -extern "C" int hal_analogif_reg_write(unsigned short reg, unsigned short val); +extern "C" int hal_analogif_reg_write(unsigned short reg, unsigned short val); extern "C" void OS_NotifyEvm(void); extern void app_anc_usb_init(void); #define REG(a) *(volatile uint32_t *)(a) -void bt_signaling_test(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); +void bt_signaling_test(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); - hal_cpu_wake_lock(APP_TESTER_CPU_WAKE_LOCK); - btdrv_testmode_start(); - btdrv_enable_dut(); + hal_cpu_wake_lock(APP_TESTER_CPU_WAKE_LOCK); + btdrv_testmode_start(); + btdrv_enable_dut(); } -void bt_stack_test(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); +void bt_stack_test(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); - btdrv_start_bt(); - BesbtInit(); + btdrv_start_bt(); + BesbtInit(); } -void bt_ble_test(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); +void bt_ble_test(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); - hal_cpu_wake_lock(APP_TESTER_CPU_WAKE_LOCK); - btdrv_testmode_start(); + hal_cpu_wake_lock(APP_TESTER_CPU_WAKE_LOCK); + btdrv_testmode_start(); - btdrv_hcioff(); - hal_iomux_set_uart1(); - btdrv_uart_bridge_loop(); + btdrv_hcioff(); + hal_iomux_set_uart1(); + btdrv_uart_bridge_loop(); } -void bt_test_104m(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); +void bt_test_104m(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); - hal_analogif_reg_write(0x35,0x0); - hal_analogif_reg_write(0x36,0x8000); - hal_analogif_reg_write(0x37,0x1000); - hal_analogif_reg_write(0x31,0xfd31); - REG(0xd0350248) = 0X80C00000; - hal_analogif_reg_write(0xC,0x3790); + hal_analogif_reg_write(0x35, 0x0); + hal_analogif_reg_write(0x36, 0x8000); + hal_analogif_reg_write(0x37, 0x1000); + hal_analogif_reg_write(0x31, 0xfd31); + REG(0xd0350248) = 0X80C00000; + hal_analogif_reg_write(0xC, 0x3790); } -void bt_change_to_iic(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); +void bt_change_to_iic(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); - hal_iomux_set_analog_i2c(); + hal_iomux_set_analog_i2c(); } -void bt_change_to_uart0(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); +void bt_change_to_uart0(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); - hal_iomux_set_uart0(); + hal_iomux_set_uart0(); } -void app_switch_i2c_uart(APP_KEY_STATUS *status, void *param) -{ - static uint32_t flag = 1; +void app_switch_i2c_uart(APP_KEY_STATUS *status, void *param) { + static uint32_t flag = 1; - TRACE(2,"[%s] flag = %d",__func__, flag); - if(flag) - { - bt_change_to_iic(NULL, NULL); - } - else - { - bt_change_to_uart0(NULL, NULL); - } - flag = !flag; + TRACE(2, "[%s] flag = %d", __func__, flag); + if (flag) { + bt_change_to_iic(NULL, NULL); + } else { + bt_change_to_uart0(NULL, NULL); + } + flag = !flag; } -void test_power_off(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"app_power_off\n"); +void test_power_off(APP_KEY_STATUS *status, void *param) { + TRACE(0, "app_power_off\n"); } extern APP_KEY_STATUS bt_key; -void test_bt_key(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); - if(bt_key.code == 0xff) - { - bt_key.code = status->code; - bt_key.event = status->event; - OS_NotifyEvm(); - } +void test_bt_key(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); + if (bt_key.code == 0xff) { + bt_key.code = status->code; + bt_key.event = status->event; + OS_NotifyEvm(); + } } #ifdef __APP_TEST_SDMMC__ #include "app_sdmmc.h" #define SD_BUF_SIZE (10) -uint8_t sd_buf[SD_BUF_SIZE]={0,1,2,3,4,5,6,7,8,9}; +uint8_t sd_buf[SD_BUF_SIZE] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; -void test_sd_card() -{ - sd_open(); +void test_sd_card() { + sd_open(); - dump_data2sd(APP_SDMMC_DUMP_OPEN, NULL , 0); - dump_data2sd(APP_SDMMC_DUMP_WRITE,sd_buf, SD_BUF_SIZE); - dump_data2sd(APP_SDMMC_DUMP_CLOSE, NULL, 0); + dump_data2sd(APP_SDMMC_DUMP_OPEN, NULL, 0); + dump_data2sd(APP_SDMMC_DUMP_WRITE, sd_buf, SD_BUF_SIZE); + dump_data2sd(APP_SDMMC_DUMP_CLOSE, NULL, 0); } #endif #ifdef APP_TEST_AUDIO -extern void adc_looptester(bool on, enum AUD_IO_PATH_T input_path, enum AUD_SAMPRATE_T sample_rate); -void test_codec_loop(APP_KEY_STATUS *status, void *param) -{ - audio_buffer_init(); - adc_looptester(true, AUD_INPUT_PATH_MAINMIC, AUD_SAMPRATE_8000); +extern void adc_looptester(bool on, enum AUD_IO_PATH_T input_path, + enum AUD_SAMPRATE_T sample_rate); +void test_codec_loop(APP_KEY_STATUS *status, void *param) { + audio_buffer_init(); + adc_looptester(true, AUD_INPUT_PATH_MAINMIC, AUD_SAMPRATE_8000); } #ifdef ANC_APP -void test_anc(APP_KEY_STATUS *status, void *param) -{ - anc_usb_app((bool)param); -} +void test_anc(APP_KEY_STATUS *status, void *param) { anc_usb_app((bool)param); } -void test_usb_audio(APP_KEY_STATUS *status, void *param) -{ - usb_audio_app((bool)param); - //dualadc_audio_app((bool)param); +void test_usb_audio(APP_KEY_STATUS *status, void *param) { + usb_audio_app((bool)param); + // dualadc_audio_app((bool)param); } #endif #endif -void bt_change_to_jlink(APP_KEY_STATUS *status, void *param) -{ - hal_iomux_set_jtag(); - - hal_cmu_jtag_clock_enable(); +void bt_change_to_jlink(APP_KEY_STATUS *status, void *param) { + hal_iomux_set_jtag(); + hal_cmu_jtag_clock_enable(); } -void bt_enable_tports(void) -{ - hal_iomux_set_bt_tport(); - bt_drv_bt_tport_type_config(); +void bt_enable_tports(void) { + hal_iomux_set_bt_tport(); + bt_drv_bt_tport_type_config(); } #ifdef APP_TEST_AUDIO extern void da_tester(uint8_t on); -void bt_test_dsp_process(APP_KEY_STATUS *status, void *param) -{ - da_tester(1); -} +void bt_test_dsp_process(APP_KEY_STATUS *status, void *param) { da_tester(1); } #endif #define MENU_TITLE_MAX_SIZE (50) -APP_KEY_HANDLE app_testcase[] = { +APP_KEY_HANDLE app_testcase[] = { #if defined(APP_TEST_AUDIO) && defined(ANC_APP) - {{APP_KEY_CODE_FN2,APP_KEY_EVENT_UP},"USB AUDIO TEST OFF",test_usb_audio, (void *)0}, - {{APP_KEY_CODE_FN5,APP_KEY_EVENT_UP},"USB AUDIO TEST ON",test_usb_audio, (void *)1}, - {{APP_KEY_CODE_FN3,APP_KEY_EVENT_UP},"ANC TEST OFF",test_anc, (void *)0}, - {{APP_KEY_CODE_FN6,APP_KEY_EVENT_UP},"ANC TEST ON",test_anc, (void *)1}, + {{APP_KEY_CODE_FN2, APP_KEY_EVENT_UP}, + "USB AUDIO TEST OFF", + test_usb_audio, + (void *)0}, + {{APP_KEY_CODE_FN5, APP_KEY_EVENT_UP}, + "USB AUDIO TEST ON", + test_usb_audio, + (void *)1}, + {{APP_KEY_CODE_FN3, APP_KEY_EVENT_UP}, "ANC TEST OFF", test_anc, (void *)0}, + {{APP_KEY_CODE_FN6, APP_KEY_EVENT_UP}, "ANC TEST ON", test_anc, (void *)1}, #else #ifdef APP_TEST_AUDIO - {{APP_KEY_CODE_FN1,APP_KEY_EVENT_LONGPRESS},"LONGPRESS: test_codec_loop",test_codec_loop, NULL}, + {{APP_KEY_CODE_FN1, APP_KEY_EVENT_LONGPRESS}, + "LONGPRESS: test_codec_loop", + test_codec_loop, + NULL}, #endif - {{APP_KEY_CODE_FN1,APP_KEY_EVENT_UP},"bt_signaling_test",bt_signaling_test, NULL}, - {{APP_KEY_CODE_FN2,APP_KEY_EVENT_UP},"bt gogogogo" ,bt_stack_test, NULL}, - {{APP_KEY_CODE_FN3,APP_KEY_EVENT_UP},"bt change to 104m",bt_test_104m, NULL}, - {{APP_KEY_CODE_FN4,APP_KEY_EVENT_UP},"ble test mode" ,bt_ble_test, NULL}, + {{APP_KEY_CODE_FN1, APP_KEY_EVENT_UP}, + "bt_signaling_test", + bt_signaling_test, + NULL}, + {{APP_KEY_CODE_FN2, APP_KEY_EVENT_UP}, "bt gogogogo", bt_stack_test, NULL}, + {{APP_KEY_CODE_FN3, APP_KEY_EVENT_UP}, + "bt change to 104m", + bt_test_104m, + NULL}, + {{APP_KEY_CODE_FN4, APP_KEY_EVENT_UP}, "ble test mode", bt_ble_test, NULL}, #ifdef APP_TEST_AUDIO - {{APP_KEY_CODE_FN5,APP_KEY_EVENT_UP},"dsp eq test" ,bt_test_dsp_process, NULL}, + {{APP_KEY_CODE_FN5, APP_KEY_EVENT_UP}, + "dsp eq test", + bt_test_dsp_process, + NULL}, #endif - {{APP_KEY_CODE_FN5,APP_KEY_EVENT_LONGPRESS},"LONGPRESS: bt volume up key" ,test_bt_key, NULL}, + {{APP_KEY_CODE_FN5, APP_KEY_EVENT_LONGPRESS}, + "LONGPRESS: bt volume up key", + test_bt_key, + NULL}, - {{APP_KEY_CODE_FN6,APP_KEY_EVENT_UP},"bt volume down key" ,test_bt_key, NULL}, - {{APP_KEY_CODE_FN6,APP_KEY_EVENT_LONGPRESS},"LONGPRESS: bt volume down key" ,test_bt_key, NULL}, + {{APP_KEY_CODE_FN6, APP_KEY_EVENT_UP}, + "bt volume down key", + test_bt_key, + NULL}, + {{APP_KEY_CODE_FN6, APP_KEY_EVENT_LONGPRESS}, + "LONGPRESS: bt volume down key", + test_bt_key, + NULL}, - {{APP_KEY_CODE_FN7,APP_KEY_EVENT_CLICK},"bt function key" ,test_bt_key, NULL}, - {{APP_KEY_CODE_FN7,APP_KEY_EVENT_DOUBLECLICK},"DOUBLECLICK: bt function key" ,test_bt_key, NULL}, - {{APP_KEY_CODE_FN7,APP_KEY_EVENT_LONGPRESS},"LONGPRESS: bt function key" ,test_bt_key, NULL}, + {{APP_KEY_CODE_FN7, APP_KEY_EVENT_CLICK}, + "bt function key", + test_bt_key, + NULL}, + {{APP_KEY_CODE_FN7, APP_KEY_EVENT_DOUBLECLICK}, + "DOUBLECLICK: bt function key", + test_bt_key, + NULL}, + {{APP_KEY_CODE_FN7, APP_KEY_EVENT_LONGPRESS}, + "LONGPRESS: bt function key", + test_bt_key, + NULL}, - {{APP_KEY_CODE_FN8,APP_KEY_EVENT_UP},"open jlink" ,bt_change_to_jlink, NULL}, - {{APP_KEY_CODE_FN9,APP_KEY_EVENT_UP},"iic_map2_P3_0" ,bt_change_to_iic, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_LONGPRESS},"LONGPRESS: power off" ,test_power_off, NULL}, + {{APP_KEY_CODE_FN8, APP_KEY_EVENT_UP}, + "open jlink", + bt_change_to_jlink, + NULL}, + {{APP_KEY_CODE_FN9, APP_KEY_EVENT_UP}, + "iic_map2_P3_0", + bt_change_to_iic, + NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_LONGPRESS}, + "LONGPRESS: power off", + test_power_off, + NULL}, #endif // !(APP_TEST_AUDIO && ANC_APP) {{0xff, APP_KEY_EVENT_NONE}, NULL, (uint32_t)NULL, 0}, }; -int app_testcase_disp_menu(APP_KEY_HANDLE* testcase, bool printall) -{ - char buf[MENU_TITLE_MAX_SIZE+1]; - if (strlen(testcase->string)>(MENU_TITLE_MAX_SIZE-15)){ - TRACE(0,"string too long, please check again\n"); - return -1; - } +int app_testcase_disp_menu(APP_KEY_HANDLE *testcase, bool printall) { + char buf[MENU_TITLE_MAX_SIZE + 1]; + if (strlen(testcase->string) > (MENU_TITLE_MAX_SIZE - 15)) { + TRACE(0, "string too long, please check again\n"); + return -1; + } - if (printall){ - memset(buf, '-', sizeof(buf)-3); - buf[0] = '|'; - buf[MENU_TITLE_MAX_SIZE-3] = '|'; - buf[MENU_TITLE_MAX_SIZE-2] = '\r'; - buf[MENU_TITLE_MAX_SIZE-1] = '\n'; - buf[MENU_TITLE_MAX_SIZE] = '\0'; - TRACE(1,"%s", buf); - osDelay(1); - } + if (printall) { + memset(buf, '-', sizeof(buf) - 3); + buf[0] = '|'; + buf[MENU_TITLE_MAX_SIZE - 3] = '|'; + buf[MENU_TITLE_MAX_SIZE - 2] = '\r'; + buf[MENU_TITLE_MAX_SIZE - 1] = '\n'; + buf[MENU_TITLE_MAX_SIZE] = '\0'; + TRACE(1, "%s", buf); + osDelay(1); + } - do{ - snprintf(buf, sizeof(buf), "| (0x%X)%s", testcase->key_status.code, testcase->string); - memset(buf+strlen(buf), ' ', sizeof(buf)-strlen(buf)-3); - buf[MENU_TITLE_MAX_SIZE-3] = '|'; - buf[MENU_TITLE_MAX_SIZE-2] = '\r'; - buf[MENU_TITLE_MAX_SIZE-1] = '\n'; - buf[MENU_TITLE_MAX_SIZE] = '\0'; - TRACE(1,"%s", buf); - testcase++; - }while(testcase->key_status.code != 0xff && printall); + do { + snprintf(buf, sizeof(buf), "| (0x%X)%s", testcase->key_status.code, + testcase->string); + memset(buf + strlen(buf), ' ', sizeof(buf) - strlen(buf) - 3); + buf[MENU_TITLE_MAX_SIZE - 3] = '|'; + buf[MENU_TITLE_MAX_SIZE - 2] = '\r'; + buf[MENU_TITLE_MAX_SIZE - 1] = '\n'; + buf[MENU_TITLE_MAX_SIZE] = '\0'; + TRACE(1, "%s", buf); + testcase++; + } while (testcase->key_status.code != 0xff && printall); - if (printall){ - memset(buf, '-', sizeof(buf)-3); - buf[0] = '|'; - buf[MENU_TITLE_MAX_SIZE-3] = '|'; - buf[MENU_TITLE_MAX_SIZE-2] = '\r'; - buf[MENU_TITLE_MAX_SIZE-1] = '\n'; - buf[MENU_TITLE_MAX_SIZE] = '\0'; - TRACE(1,"%s", buf); - osDelay(1); - } + if (printall) { + memset(buf, '-', sizeof(buf) - 3); + buf[0] = '|'; + buf[MENU_TITLE_MAX_SIZE - 3] = '|'; + buf[MENU_TITLE_MAX_SIZE - 2] = '\r'; + buf[MENU_TITLE_MAX_SIZE - 1] = '\n'; + buf[MENU_TITLE_MAX_SIZE] = '\0'; + TRACE(1, "%s", buf); + osDelay(1); + } - return 0; + return 0; } -int app_testcase_key_response(APP_MESSAGE_BODY *msg_body) -{ - uint8_t i = 0; - APP_KEY_STATUS key_status; +int app_testcase_key_response(APP_MESSAGE_BODY *msg_body) { + uint8_t i = 0; + APP_KEY_STATUS key_status; - APP_KEY_GET_CODE(msg_body->message_id, key_status.code); - APP_KEY_GET_EVENT(msg_body->message_id, key_status.event); + APP_KEY_GET_CODE(msg_body->message_id, key_status.code); + APP_KEY_GET_EVENT(msg_body->message_id, key_status.event); - if ((key_status.code)>(sizeof(app_testcase)/sizeof(APP_KEY_HANDLE))) - return -1; + if ((key_status.code) > (sizeof(app_testcase) / sizeof(APP_KEY_HANDLE))) + return -1; - for (i=0; i<(sizeof(app_testcase)/sizeof(APP_KEY_HANDLE)); i++){ - if (app_testcase[i].key_status.code == key_status.code && (app_testcase[i].key_status.event == key_status.event)) - break; - } + for (i = 0; i < (sizeof(app_testcase) / sizeof(APP_KEY_HANDLE)); i++) { + if (app_testcase[i].key_status.code == key_status.code && + (app_testcase[i].key_status.event == key_status.event)) + break; + } - if (i>=(sizeof(app_testcase)/sizeof(APP_KEY_HANDLE))) - return -1; + if (i >= (sizeof(app_testcase) / sizeof(APP_KEY_HANDLE))) + return -1; - if (app_testcase[i].function != (uint32_t)NULL){ - if (app_testcase[i].string != (uint32_t)NULL) - app_testcase_disp_menu(&app_testcase[i],0); - ((APP_KEY_HANDLE_CB_T)app_testcase[i].function)(&key_status,app_testcase[i].param); - } + if (app_testcase[i].function != (uint32_t)NULL) { + if (app_testcase[i].string != (uint32_t)NULL) + app_testcase_disp_menu(&app_testcase[i], 0); + ((APP_KEY_HANDLE_CB_T)app_testcase[i].function)(&key_status, + app_testcase[i].param); + } - return 0; + return 0; } -void app_test_init(void) -{ - uint8_t i = 0; - TRACE(1,"%s",__func__); - for (i=0; i<(sizeof(app_testcase)/sizeof(APP_KEY_HANDLE)); i++){ - app_key_handle_registration(&app_testcase[i]); - } - app_testcase_disp_menu(app_testcase, 1); +void app_test_init(void) { + uint8_t i = 0; + TRACE(1, "%s", __func__); + for (i = 0; i < (sizeof(app_testcase) / sizeof(APP_KEY_HANDLE)); i++) { + app_key_handle_registration(&app_testcase[i]); + } + app_testcase_disp_menu(app_testcase, 1); #if defined(APP_TEST_AUDIO) && defined(ANC_APP) - app_anc_usb_init(); + app_anc_usb_init(); #endif } diff --git a/apps/mic/app_mic.cpp b/apps/mic/app_mic.cpp index aadf058..f46b4c9 100644 --- a/apps/mic/app_mic.cpp +++ b/apps/mic/app_mic.cpp @@ -14,241 +14,212 @@ * ****************************************************************************/ //#include "mbed.h" -#include #include +#include -#include "cmsis_os.h" -#include "tgt_hardware.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_trace.h" -#include "hal_cmu.h" -#include "hal_chipid.h" #include "analog.h" +#include "app_audio.h" #include "app_bt_stream.h" #include "app_overlay.h" -#include "app_audio.h" #include "app_utils.h" +#include "apps.h" +#include "audioflinger.h" +#include "cmsis_os.h" +#include "hal_chipid.h" +#include "hal_cmu.h" +#include "hal_codec.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "lockcqueue.h" #include "nvrecord.h" #include "nvrecord_env.h" -#include "hal_codec.h" -#include "apps.h" +#include "tgt_hardware.h" #include "app_ring_merge.h" -#include "bt_drv.h" -#include "bt_xtal_sync.h" -#include "besbt.h" #include "app_bt_func.h" #include "app_mic.h" +#include "besbt.h" +#include "bt_drv.h" +#include "bt_xtal_sync.h" - -#include "app_thread.h" -#include "cqueue.h" -#include "btapp.h" #include "app_bt_media_manager.h" -#include "string.h" -#include "hal_location.h" -#include "hal_codec.h" -#include "hal_sleep.h" #include "app_hfp.h" +#include "app_thread.h" +#include "btapp.h" +#include "cqueue.h" +#include "hal_codec.h" +#include "hal_location.h" +#include "hal_sleep.h" +#include "string.h" extern bool app_hfp_siri_is_active(void); extern int a2dp_volume_2_level_convert(uint8_t vol); extern bool mic_is_already_on; typedef enum { - MIC_EVENT_START, - MIC_EVENT_STOP, - MIC_EVENT_CHECK, -}MIC_EVENT_TYPE; + MIC_EVENT_START, + MIC_EVENT_STOP, + MIC_EVENT_CHECK, +} MIC_EVENT_TYPE; static MIC_APP_TYPE current_mictype = MIC_APP_NONE; static struct AF_STREAM_CONFIG_T mic_config[MIC_APP_MAX]; osMutexId app_mic_mutex_id = NULL; osMutexDef(app_mic_mutex); - // flag of is first mic date, if true ,will delete to avoid POP voice bool first_mic_in = false; -static int internal_mic_start(MIC_APP_TYPE new_mictype) -{ - TRACE(1,"MIC_EVENT_START,current_mictype=%d",current_mictype); - assert(new_mictype != MIC_APP_NONE); - if (current_mictype != MIC_APP_NONE) { - TRACE(0,"MIC START ERROR################"); - return false; - } - if (new_mictype == MIC_APP_SOC_CALL) - { - if (btapp_hfp_get_call_state() || app_hfp_siri_is_active()) - { - TRACE(2,"[%s] tws_mic_start_telephone_call: %d", __func__, mic_config[new_mictype].sample_rate); - if (mic_config[new_mictype].data_ptr != NULL) - { - } - else - { - TRACE(1,"[%s] Warning sco play not started",__func__); - } - current_mictype = MIC_APP_SOC_CALL; - } - } - else if (new_mictype == MIC_APP_SPEECH_RECO) - { - } - else if (new_mictype == MIC_APP_CSPOTTER) - { - first_mic_in = true; - current_mictype = MIC_APP_CSPOTTER; - } - else if (new_mictype == MIC_APP_MICRECORD) - { - current_mictype = MIC_APP_MICRECORD; - } - else if (new_mictype == MIC_APP_OTHER) - { - TRACE(0,"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); - } - - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &mic_config[new_mictype]); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); +static int internal_mic_start(MIC_APP_TYPE new_mictype) { + TRACE(1, "MIC_EVENT_START,current_mictype=%d", current_mictype); + assert(new_mictype != MIC_APP_NONE); + if (current_mictype != MIC_APP_NONE) { + TRACE(0, "MIC START ERROR################"); return false; -} - -static int internal_mic_stop(MIC_APP_TYPE new_mictype) -{ - TRACE(1,"MIC_EVENT_STOP,current_mictype=%d",current_mictype); - //assert(currentMicStauts == currentStatus); - if (new_mictype != current_mictype) { - TRACE(0,"MIC STOP ERROR ################"); - return false; + } + if (new_mictype == MIC_APP_SOC_CALL) { + if (btapp_hfp_get_call_state() || app_hfp_siri_is_active()) { + TRACE(2, "[%s] tws_mic_start_telephone_call: %d", __func__, + mic_config[new_mictype].sample_rate); + if (mic_config[new_mictype].data_ptr != NULL) { + } else { + TRACE(1, "[%s] Warning sco play not started", __func__); + } + current_mictype = MIC_APP_SOC_CALL; } - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - first_mic_in = false; - current_mictype = MIC_APP_NONE; - app_sysfreq_req(APP_SYSFREQ_USER_APP_3, APP_SYSFREQ_32K); - return true; + } else if (new_mictype == MIC_APP_SPEECH_RECO) { + } else if (new_mictype == MIC_APP_CSPOTTER) { + first_mic_in = true; + current_mictype = MIC_APP_CSPOTTER; + } else if (new_mictype == MIC_APP_MICRECORD) { + current_mictype = MIC_APP_MICRECORD; + } else if (new_mictype == MIC_APP_OTHER) { + TRACE(0, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + } + + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &mic_config[new_mictype]); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + return false; } -static int app_mic_process(APP_MESSAGE_BODY *msg_body) -{ - MIC_EVENT_TYPE mic_event = (MIC_EVENT_TYPE)msg_body->message_id; - MIC_APP_TYPE new_mictype = (MIC_APP_TYPE)msg_body->message_ptr; - int ret = -1; - TRACE(4,"%s mic_event:%d new_mictype:%d current_mictype:%d",__func__,mic_event, new_mictype, current_mictype); +static int internal_mic_stop(MIC_APP_TYPE new_mictype) { + TRACE(1, "MIC_EVENT_STOP,current_mictype=%d", current_mictype); + // assert(currentMicStauts == currentStatus); + if (new_mictype != current_mictype) { + TRACE(0, "MIC STOP ERROR ################"); + return false; + } + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + first_mic_in = false; + current_mictype = MIC_APP_NONE; + app_sysfreq_req(APP_SYSFREQ_USER_APP_3, APP_SYSFREQ_32K); + return true; +} +static int app_mic_process(APP_MESSAGE_BODY *msg_body) { + MIC_EVENT_TYPE mic_event = (MIC_EVENT_TYPE)msg_body->message_id; + MIC_APP_TYPE new_mictype = (MIC_APP_TYPE)msg_body->message_ptr; + int ret = -1; + TRACE(4, "%s mic_event:%d new_mictype:%d current_mictype:%d", __func__, + mic_event, new_mictype, current_mictype); + + osMutexWait(app_mic_mutex_id, osWaitForever); + if (mic_event == MIC_EVENT_START) + ret = internal_mic_start(new_mictype); + else if (mic_event == MIC_EVENT_STOP) + ret = internal_mic_stop(new_mictype); + else if (mic_event == MIC_EVENT_CHECK) { + TRACE(1, "MIC_EVENT_CHECK,current_mictype=%d", current_mictype); + if (current_mictype != new_mictype) { + if (current_mictype != MIC_APP_NONE) + internal_mic_stop(current_mictype); + if (new_mictype != MIC_APP_CSPOTTER) + internal_mic_start(new_mictype); + ret = 0; + } + } else + assert(0); + osMutexRelease(app_mic_mutex_id); + return ret; +} + +void app_mic_init() { + app_mic_mutex_id = osMutexCreate((osMutex(app_mic_mutex))); + app_set_threadhandle(APP_MODUAL_MIC, app_mic_process); +} + +int app_mic_register(MIC_APP_TYPE mic_type, + struct AF_STREAM_CONFIG_T *newStream) { + TRACE(2, "app_mic_registration mic_type:%d,newStream=%p\n", mic_type, + newStream); + if (mic_type > MIC_APP_NONE && mic_type < MIC_APP_MAX) { osMutexWait(app_mic_mutex_id, osWaitForever); - if (mic_event == MIC_EVENT_START) - ret = internal_mic_start(new_mictype); - else if (mic_event == MIC_EVENT_STOP) - ret = internal_mic_stop(new_mictype); - else if (mic_event == MIC_EVENT_CHECK) - { - TRACE(1,"MIC_EVENT_CHECK,current_mictype=%d",current_mictype); - if (current_mictype != new_mictype) - { - if (current_mictype != MIC_APP_NONE) - internal_mic_stop(current_mictype); - if (new_mictype != MIC_APP_CSPOTTER) - internal_mic_start(new_mictype); - ret = 0; - } + if (memcmp(&mic_config[mic_type], newStream, + sizeof(struct AF_STREAM_CONFIG_T)) != 0) { + TRACE(0, "app_mic_registration Warning mic stream config changed!!!"); } - else - assert(0); + memcpy(&mic_config[mic_type], newStream, sizeof(struct AF_STREAM_CONFIG_T)); osMutexRelease(app_mic_mutex_id); - return ret; + return 0; + } + return -1; } -void app_mic_init() -{ - app_mic_mutex_id = osMutexCreate((osMutex(app_mic_mutex))); - app_set_threadhandle(APP_MODUAL_MIC, app_mic_process); -} - -int app_mic_register(MIC_APP_TYPE mic_type, struct AF_STREAM_CONFIG_T *newStream) -{ - TRACE(2,"app_mic_registration mic_type:%d,newStream=%p\n",mic_type,newStream); - if (mic_type > MIC_APP_NONE && mic_type < MIC_APP_MAX) - { - osMutexWait(app_mic_mutex_id, osWaitForever); - if (memcmp(&mic_config[mic_type],newStream,sizeof(struct AF_STREAM_CONFIG_T)) != 0) - { - TRACE(0,"app_mic_registration Warning mic stream config changed!!!"); - } - memcpy(&mic_config[mic_type],newStream,sizeof(struct AF_STREAM_CONFIG_T)); - osMutexRelease(app_mic_mutex_id); - return 0; - } - return -1; -} - -int app_mic_deregister(MIC_APP_TYPE mic_type) -{ - TRACE(1,"app_mic_deregister mic_type:%d\n",mic_type); - if (mic_type > MIC_APP_NONE && mic_type < MIC_APP_MAX) - { - osMutexWait(app_mic_mutex_id, osWaitForever); - memset(&mic_config[mic_type],0,sizeof(struct AF_STREAM_CONFIG_T)); - osMutexRelease(app_mic_mutex_id); - return 0; - } - return -1; -} - -bool app_mic_is_registed(MIC_APP_TYPE mic_type) -{ - TRACE(1,"app_mic_is_registed mic_type:%d\n",mic_type); - bool ret = false; - if (mic_type > MIC_APP_NONE && mic_type < MIC_APP_MAX) - { - osMutexWait(app_mic_mutex_id, osWaitForever); - ret = mic_config[mic_type].data_ptr != NULL; - osMutexRelease(app_mic_mutex_id); - } - return ret; -} - -bool app_mic_start(MIC_APP_TYPE mic_type) -{ - APP_MESSAGE_BLOCK msg; - msg.mod_id = APP_MODUAL_MIC; - msg.msg_body.message_id = MIC_EVENT_START; - msg.msg_body.message_ptr = mic_type; - app_mailbox_put(&msg); - return true; -} - -bool app_mic_stop(MIC_APP_TYPE mic_type) -{ - APP_MESSAGE_BLOCK msg; - msg.mod_id = APP_MODUAL_MIC; - msg.msg_body.message_id = MIC_EVENT_STOP; - msg.msg_body.message_ptr = mic_type; - app_mailbox_put(&msg); - return true; -} - -void app_mic_check(MIC_APP_TYPE mic_type) -{ - APP_MESSAGE_BLOCK msg; - msg.mod_id = APP_MODUAL_MIC; - msg.msg_body.message_id = MIC_EVENT_CHECK; - msg.msg_body.message_ptr = mic_type; - app_mailbox_put(&msg); -} - -MIC_APP_TYPE app_mic_status(void) -{ - MIC_APP_TYPE ret; +int app_mic_deregister(MIC_APP_TYPE mic_type) { + TRACE(1, "app_mic_deregister mic_type:%d\n", mic_type); + if (mic_type > MIC_APP_NONE && mic_type < MIC_APP_MAX) { osMutexWait(app_mic_mutex_id, osWaitForever); - ret= current_mictype; + memset(&mic_config[mic_type], 0, sizeof(struct AF_STREAM_CONFIG_T)); osMutexRelease(app_mic_mutex_id); - return ret; + return 0; + } + return -1; } +bool app_mic_is_registed(MIC_APP_TYPE mic_type) { + TRACE(1, "app_mic_is_registed mic_type:%d\n", mic_type); + bool ret = false; + if (mic_type > MIC_APP_NONE && mic_type < MIC_APP_MAX) { + osMutexWait(app_mic_mutex_id, osWaitForever); + ret = mic_config[mic_type].data_ptr != NULL; + osMutexRelease(app_mic_mutex_id); + } + return ret; +} + +bool app_mic_start(MIC_APP_TYPE mic_type) { + APP_MESSAGE_BLOCK msg; + msg.mod_id = APP_MODUAL_MIC; + msg.msg_body.message_id = MIC_EVENT_START; + msg.msg_body.message_ptr = mic_type; + app_mailbox_put(&msg); + return true; +} + +bool app_mic_stop(MIC_APP_TYPE mic_type) { + APP_MESSAGE_BLOCK msg; + msg.mod_id = APP_MODUAL_MIC; + msg.msg_body.message_id = MIC_EVENT_STOP; + msg.msg_body.message_ptr = mic_type; + app_mailbox_put(&msg); + return true; +} + +void app_mic_check(MIC_APP_TYPE mic_type) { + APP_MESSAGE_BLOCK msg; + msg.mod_id = APP_MODUAL_MIC; + msg.msg_body.message_id = MIC_EVENT_CHECK; + msg.msg_body.message_ptr = mic_type; + app_mailbox_put(&msg); +} + +MIC_APP_TYPE app_mic_status(void) { + MIC_APP_TYPE ret; + osMutexWait(app_mic_mutex_id, osWaitForever); + ret = current_mictype; + osMutexRelease(app_mic_mutex_id); + return ret; +} diff --git a/apps/mic_alg/app_mic_alg.cpp b/apps/mic_alg/app_mic_alg.cpp index 74250fd..c937fa8 100644 --- a/apps/mic_alg/app_mic_alg.cpp +++ b/apps/mic_alg/app_mic_alg.cpp @@ -13,18 +13,18 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "app_bt_stream.h" +#include "app_media_player.h" #include "cmsis_os.h" #include "hal_trace.h" #include "resources.h" -#include "app_bt_stream.h" -#include "app_media_player.h" //#include "app_factory.h" #include "string.h" // for audio -#include "audioflinger.h" #include "app_audio.h" #include "app_utils.h" +#include "audioflinger.h" #include "hal_timer.h" #include "app_mic_alg.h" @@ -42,26 +42,22 @@ #include "apps.h" - #ifdef WEBRTC_AGC #include "agc_main.h" #endif #ifdef WL_NSX -#define WEBRTC_NSX_BUFF_SIZE (14000) +#define WEBRTC_NSX_BUFF_SIZE (14000) #endif - #ifdef WL_VAD #include "vad_user.h" #endif - #ifdef WL_DEBUG_MODE #include "nvrecord_env.h" #endif - #ifdef REMOTE_UART #include "app_remoter_uart.h" #endif @@ -75,78 +71,70 @@ #include "app_i2c_sensor.h" #endif -static inline float clampf(float v, float min, float max){ - return v < min ? min : (v > max ? max : v); +static inline float clampf(float v, float min, float max) { + return v < min ? min : (v > max ? max : v); } - - #ifdef WL_NSX_5MS -#define BT_AUDIO_FACTORMODE_BUFF_SIZE (160*2) +#define BT_AUDIO_FACTORMODE_BUFF_SIZE (160 * 2) #else -#define BT_AUDIO_FACTORMODE_BUFF_SIZE (6*320*16) +#define BT_AUDIO_FACTORMODE_BUFF_SIZE (6 * 320 * 16) #endif - - #define NSX_FRAME_SIZE 160 - static enum APP_AUDIO_CACHE_T a2dp_cache_status = APP_AUDIO_CACHE_QTY; - #if defined(WL_AEC) -static short POSSIBLY_UNUSED aec_out[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2]; -static short POSSIBLY_UNUSED far_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2]; +static short POSSIBLY_UNUSED aec_out[BT_AUDIO_FACTORMODE_BUFF_SIZE >> 2]; +static short POSSIBLY_UNUSED far_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE >> 2]; #endif +static short POSSIBLY_UNUSED out_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE >> 2]; +static short POSSIBLY_UNUSED tmp_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE >> 2]; -static short POSSIBLY_UNUSED out_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2]; -static short POSSIBLY_UNUSED tmp_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2]; +// static short revert_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2]; +// static short audio_uart_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2]; -//static short revert_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2]; -//static short audio_uart_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2]; +#if SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 2 +static short POSSIBLY_UNUSED one_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE >> 2]; +static short POSSIBLY_UNUSED two_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE >> 2]; -#if SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 2 +static short POSSIBLY_UNUSED left_out[BT_AUDIO_FACTORMODE_BUFF_SIZE >> 2]; +static short POSSIBLY_UNUSED right_out[BT_AUDIO_FACTORMODE_BUFF_SIZE >> 2]; -static short POSSIBLY_UNUSED one_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2]; -static short POSSIBLY_UNUSED two_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2]; - -static short POSSIBLY_UNUSED left_out[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2]; -static short POSSIBLY_UNUSED right_out[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2]; - -static void POSSIBLY_UNUSED aaudio_div_stero_to_rmono(int16_t *dst_buf, int16_t *src_buf, uint32_t src_len) -{ - // Copy from tail so that it works even if dst_buf == src_buf - for (uint32_t i = 0; i < src_len>>1; i++) - { - dst_buf[i] = src_buf[i*2 + 1]; - } +static void POSSIBLY_UNUSED aaudio_div_stero_to_rmono(int16_t *dst_buf, + int16_t *src_buf, + uint32_t src_len) { + // Copy from tail so that it works even if dst_buf == src_buf + for (uint32_t i = 0; i < src_len >> 1; i++) { + dst_buf[i] = src_buf[i * 2 + 1]; + } } -static void POSSIBLY_UNUSED aaudio_div_stero_to_lmono(int16_t *dst_buf, int16_t *src_buf, uint32_t src_len) -{ - // Copy from tail so that it works even if dst_buf == src_buf - for (uint32_t i = 0; i < src_len>>1; i++) - { - dst_buf[i] = src_buf[i*2 + 0]; - } +static void POSSIBLY_UNUSED aaudio_div_stero_to_lmono(int16_t *dst_buf, + int16_t *src_buf, + uint32_t src_len) { + // Copy from tail so that it works even if dst_buf == src_buf + for (uint32_t i = 0; i < src_len >> 1; i++) { + dst_buf[i] = src_buf[i * 2 + 0]; + } } - -static void POSSIBLY_UNUSED audio_mono2stereo_16bits(int16_t *dst_buf, int16_t *left_buf, int16_t *right_buf, uint32_t src_len) -{ - uint32_t i = 0; - for (i = 0; i < src_len; ++i) { - dst_buf[i*2 + 0] = left_buf[i]; - dst_buf[i*2 + 1] = right_buf[i]; - } +static void POSSIBLY_UNUSED audio_mono2stereo_16bits(int16_t *dst_buf, + int16_t *left_buf, + int16_t *right_buf, + uint32_t src_len) { + uint32_t i = 0; + for (i = 0; i < src_len; ++i) { + dst_buf[i * 2 + 0] = left_buf[i]; + dst_buf[i * 2 + 1] = right_buf[i]; + } } -#elif SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 3 +#elif SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 3 - -#elif SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 4 +#elif SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 4 #endif @@ -155,120 +143,109 @@ extern uint32_t transfer_factor; extern uint32_t diff_energy; extern uint32_t level_shift; -static inline double convert_multiple_to_db(uint32_t multiple) -{ - return 20*log10(multiple); +static inline double convert_multiple_to_db(uint32_t multiple) { + return 20 * log10(multiple); } -#define DUMP_FRAME_LEN 0x3C0 -static short POSSIBLY_UNUSED revert_buff[2+1*DUMP_FRAME_LEN]; +#define DUMP_FRAME_LEN 0x3C0 +static short POSSIBLY_UNUSED revert_buff[2 + 1 * DUMP_FRAME_LEN]; int32_t tx_pcmbuf32[960]; - extern int app_reset(void); extern void app_bt_volumeup(); extern void app_bt_volumedown(); -void vol_state_process(uint32_t db_val) -{ - TRACE(2,"db value is:%d volume_is:%d ",db_val,app_bt_stream_local_volume_get()); - - if((db_val < 52) && (app_bt_stream_local_volume_get() > 10)) - { - app_bt_volumedown(); - } - else if((db_val > 60) && (app_bt_stream_local_volume_get() < 13)) - { - app_bt_volumeup(); - } - else if((db_val > 72) && (app_bt_stream_local_volume_get() < 15)) - { - app_bt_volumeup(); - } +void vol_state_process(uint32_t db_val) { + TRACE(2, "db value is:%d volume_is:%d ", db_val, + app_bt_stream_local_volume_get()); + if ((db_val < 52) && (app_bt_stream_local_volume_get() > 10)) { + app_bt_volumedown(); + } else if ((db_val > 60) && (app_bt_stream_local_volume_get() < 13)) { + app_bt_volumeup(); + } else if ((db_val > 72) && (app_bt_stream_local_volume_get() < 15)) { + app_bt_volumeup(); + } } -static uint32_t app_mic_alg_data_come(uint8_t *buf, uint32_t len) -{ - uint32_t pcm_len = len>>1; +static uint32_t app_mic_alg_data_come(uint8_t *buf, uint32_t len) { + uint32_t pcm_len = len >> 1; - short POSSIBLY_UNUSED *tx_pcmbuf16 = (short*)buf; + short POSSIBLY_UNUSED *tx_pcmbuf16 = (short *)buf; - //DUMP16("%d, ",tx_pcmbuf16,30); - // memcpy(tmp_buff,pcm_buff,len); + // DUMP16("%d, ",tx_pcmbuf16,30); + // memcpy(tmp_buff,pcm_buff,len); - int32_t stime = 0; - static int32_t nsx_cnt = 0; - static int32_t dump_cnt = 0; + int32_t stime = 0; + static int32_t nsx_cnt = 0; + static int32_t dump_cnt = 0; + nsx_cnt++; + dump_cnt++; - nsx_cnt++; - dump_cnt++; - - DUMP16("%d,",tx_pcmbuf16,30); - if(false == (nsx_cnt & 0x3F)) - { - stime = hal_sys_timer_get(); - //TRACE("aecm echo time: lens:%d g_time_cnt:%d ",len, g_time_cnt); - } + DUMP16("%d,", tx_pcmbuf16, 30); + if (false == (nsx_cnt & 0x3F)) { + stime = hal_sys_timer_get(); + // TRACE("aecm echo time: lens:%d g_time_cnt:%d ",len, g_time_cnt); + } #ifdef WL_DET - if(nsx_cnt > 100) - { - static double last_sum = 0,last_avg = 0; + if (nsx_cnt > 100) { + static double last_sum = 0, last_avg = 0; - uint32_t sum_ss = 0; - //short db_val = 0; - double db_sum = 0; - for (uint32_t i_cnt = 0; i_cnt < pcm_len; i_cnt++) - { - sum_ss += ABS(tx_pcmbuf16[i_cnt]); - } - - sum_ss = 1*sum_ss/pcm_len; - - db_sum = convert_multiple_to_db(sum_ss); - //db_val = (short)(100*db_sum); - last_sum += db_sum; - last_avg = last_sum/nsx_cnt; - - db_sum = db_sum*(double)0.02 + last_avg*(double)0.98; - - //TRACE(2,"db value is:%d sum_ss:%d ",(uint32_t)db_sum,sum_ss); - //TRACE(2,"db value is:%d ",(uint32_t)db_sum); - vol_state_process((uint32_t)db_sum); + uint32_t sum_ss = 0; + // short db_val = 0; + double db_sum = 0; + for (uint32_t i_cnt = 0; i_cnt < pcm_len; i_cnt++) { + sum_ss += ABS(tx_pcmbuf16[i_cnt]); } + sum_ss = 1 * sum_ss / pcm_len; + + db_sum = convert_multiple_to_db(sum_ss); + // db_val = (short)(100*db_sum); + last_sum += db_sum; + last_avg = last_sum / nsx_cnt; + + db_sum = db_sum * (double)0.02 + last_avg * (double)0.98; + + // TRACE(2,"db value is:%d sum_ss:%d ",(uint32_t)db_sum,sum_ss); + // TRACE(2,"db value is:%d ",(uint32_t)db_sum); + vol_state_process((uint32_t)db_sum); + } + #endif + if (false == (nsx_cnt & 0x3F)) { + // TRACE("drc 48 mic_alg 16k nsx 3 agc 15 closed speed time:%d ms and + // pcm_lens:%d freq:%d ", TICKS_TO_MS(hal_sys_timer_get() - stime), + // pcm_len,hal_sysfreq_get()); TRACE("notch 500 mic_alg 16k nsx 3 agc 15 + // closed speed time:%d ms and pcm_lens:%d freq:%d ", + // TICKS_TO_MS(hal_sys_timer_get() - stime), pcm_len,hal_sysfreq_get()); + TRACE(2, "denoise det speed time:%d ms and pcm_lens:%d freq:%d ", + TICKS_TO_MS(hal_sys_timer_get() - stime), pcm_len, hal_sysfreq_get()); + } - if(false == (nsx_cnt & 0x3F)) - { - //TRACE("drc 48 mic_alg 16k nsx 3 agc 15 closed speed time:%d ms and pcm_lens:%d freq:%d ", TICKS_TO_MS(hal_sys_timer_get() - stime), pcm_len,hal_sysfreq_get()); - //TRACE("notch 500 mic_alg 16k nsx 3 agc 15 closed speed time:%d ms and pcm_lens:%d freq:%d ", TICKS_TO_MS(hal_sys_timer_get() - stime), pcm_len,hal_sysfreq_get()); - TRACE(2,"denoise det speed time:%d ms and pcm_lens:%d freq:%d ", TICKS_TO_MS(hal_sys_timer_get() - stime), pcm_len,hal_sysfreq_get()); - } - - - if (a2dp_cache_status == APP_AUDIO_CACHE_QTY){ - a2dp_cache_status = APP_AUDIO_CACHE_OK; - } - return len; + if (a2dp_cache_status == APP_AUDIO_CACHE_QTY) { + a2dp_cache_status = APP_AUDIO_CACHE_OK; + } + return len; } // static uint32_t app_mic_uart_playback_data(uint8_t *buf, uint32_t len) // { // if (a2dp_cache_status != APP_AUDIO_CACHE_QTY){ -// #if SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 2 +// #if SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 2 // #ifdef WL_AEC // app_audio_pcmbuff_get((uint8_t *)app_audioloop_play_cache, len/2); -// app_bt_stream_copy_track_one_to_two_16bits((int16_t *)buf, app_audioloop_play_cache, len/2/2); -// #else +// app_bt_stream_copy_track_one_to_two_16bits((int16_t *)buf, +// app_audioloop_play_cache, len/2/2); #else // app_audio_pcmbuff_get((uint8_t *)buf, len); // #endif // #else // app_audio_pcmbuff_get((uint8_t *)app_audioloop_play_cache, len/2); -// app_bt_stream_copy_track_one_to_two_16bits((int16_t *)buf, app_audioloop_play_cache, len/2/2); +// app_bt_stream_copy_track_one_to_two_16bits((int16_t *)buf, +// app_audioloop_play_cache, len/2/2); // #endif // } // return len; @@ -276,68 +253,63 @@ static uint32_t app_mic_alg_data_come(uint8_t *buf, uint32_t len) static uint8_t buff_capture[BT_AUDIO_FACTORMODE_BUFF_SIZE]; -int app_mic_alg_audioloop(bool on, enum APP_SYSFREQ_FREQ_T freq) -{ - struct AF_STREAM_CONFIG_T stream_cfg; - static bool isRun = false; +int app_mic_alg_audioloop(bool on, enum APP_SYSFREQ_FREQ_T freq) { + struct AF_STREAM_CONFIG_T stream_cfg; + static bool isRun = false; - TRACE(2,"app_mic_alg work:%d op:%d freq:%d", isRun, on, freq); + TRACE(2, "app_mic_alg work:%d op:%d freq:%d", isRun, on, freq); - if (isRun==on) - return 0; - - if (on){ - - - app_sysfreq_req(APP_SYSFREQ_USER_APP_0, freq); - - a2dp_cache_status = APP_AUDIO_CACHE_QTY; - - memset(&stream_cfg, 0, sizeof(stream_cfg)); - - - stream_cfg.bits = AUD_BITS_16; - - stream_cfg.channel_num = AUD_CHANNEL_NUM_1; - - stream_cfg.sample_rate = AUD_SAMPRATE_48000; - - - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; - - stream_cfg.vol = CODEC_SADC_VOL; - stream_cfg.io_path = AUD_INPUT_PATH_ASRMIC; - - stream_cfg.handler = app_mic_alg_data_come; - - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(buff_capture); - stream_cfg.data_size = BT_AUDIO_FACTORMODE_BUFF_SIZE*stream_cfg.channel_num; - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); - - // stream_cfg.channel_num = AUD_CHANNEL_NUM_2; - // stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; - // stream_cfg.handler = app_mic_uart_playback_data; - - // stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(buff_play); - // stream_cfg.data_size = BT_AUDIO_FACTORMODE_BUFF_SIZE*2; - // af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); - - //af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - TRACE(2,"app_mic_uart ss loopback on"); - - } else { - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - //af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - //af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - TRACE(2,"app_mic_16k loopback off"); - - //app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_32K); - } - - isRun=on; + if (isRun == on) return 0; + + if (on) { + + app_sysfreq_req(APP_SYSFREQ_USER_APP_0, freq); + + a2dp_cache_status = APP_AUDIO_CACHE_QTY; + + memset(&stream_cfg, 0, sizeof(stream_cfg)); + + stream_cfg.bits = AUD_BITS_16; + + stream_cfg.channel_num = AUD_CHANNEL_NUM_1; + + stream_cfg.sample_rate = AUD_SAMPRATE_48000; + + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; + + stream_cfg.vol = CODEC_SADC_VOL; + stream_cfg.io_path = AUD_INPUT_PATH_ASRMIC; + + stream_cfg.handler = app_mic_alg_data_come; + + stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(buff_capture); + stream_cfg.data_size = + BT_AUDIO_FACTORMODE_BUFF_SIZE * stream_cfg.channel_num; + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); + + // stream_cfg.channel_num = AUD_CHANNEL_NUM_2; + // stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; + // stream_cfg.handler = app_mic_uart_playback_data; + + // stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(buff_play); + // stream_cfg.data_size = BT_AUDIO_FACTORMODE_BUFF_SIZE*2; + // af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); + + // af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + TRACE(2, "app_mic_uart ss loopback on"); + + } else { + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + // af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + // af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + TRACE(2, "app_mic_16k loopback off"); + + // app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_32K); + } + + isRun = on; + return 0; } - - diff --git a/apps/pwl/app_pwl.cpp b/apps/pwl/app_pwl.cpp index 2e657c9..6a4b818 100644 --- a/apps/pwl/app_pwl.cpp +++ b/apps/pwl/app_pwl.cpp @@ -13,173 +13,179 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "app_pwl.h" #include "cmsis_os.h" -#include "tgt_hardware.h" #include "hal_gpio.h" #include "hal_iomux.h" #include "hal_trace.h" #include "pmu.h" -#include "app_pwl.h" #include "string.h" +#include "tgt_hardware.h" -#define APP_PWL_TRACE(s,...) -//TRACE(s, ##__VA_ARGS__) +#define APP_PWL_TRACE(s, ...) +// TRACE(s, ##__VA_ARGS__) #if (CFG_HW_PLW_NUM > 0) static void app_pwl_timehandler(void const *param); -osTimerDef (APP_PWL_TIMER0, app_pwl_timehandler); // define timers +osTimerDef(APP_PWL_TIMER0, app_pwl_timehandler); // define timers #if (CFG_HW_PLW_NUM == 2) -osTimerDef (APP_PWL_TIMER1, app_pwl_timehandler); +osTimerDef(APP_PWL_TIMER1, app_pwl_timehandler); #endif struct APP_PWL_T { - enum APP_PWL_ID_T id; - struct APP_PWL_CFG_T config; - uint8_t partidx; - osTimerId timer; + enum APP_PWL_ID_T id; + struct APP_PWL_CFG_T config; + uint8_t partidx; + osTimerId timer; }; static struct APP_PWL_T app_pwl[APP_PWL_ID_QTY]; -static void app_pwl_timehandler(void const *param) -{ - struct APP_PWL_T *pwl = (struct APP_PWL_T *)param; - struct APP_PWL_CFG_T *cfg = &(pwl->config); - APP_PWL_TRACE(2,"%s %x",__func__, param); +static void app_pwl_timehandler(void const *param) { + struct APP_PWL_T *pwl = (struct APP_PWL_T *)param; + struct APP_PWL_CFG_T *cfg = &(pwl->config); + APP_PWL_TRACE(2, "%s %x", __func__, param); - osTimerStop(pwl->timer); + osTimerStop(pwl->timer); - pwl->partidx++; - if (cfg->periodic){ - if (pwl->partidx >= cfg->parttotal){ - pwl->partidx = 0; - } - }else{ - if (pwl->partidx >= cfg->parttotal){ - return; - } + pwl->partidx++; + if (cfg->periodic) { + if (pwl->partidx >= cfg->parttotal) { + pwl->partidx = 0; } - - APP_PWL_TRACE(3,"idx:%d pin:%d lvl:%d", pwl->partidx, cfg_hw_pinmux_pwl[pwl->id].pin, cfg->part[pwl->partidx].level); - if(!cfg->part[pwl->partidx].level){ -#if defined(__PMU_VIO_DYNAMIC_CTRL_MODE__) - pmu_viorise_req(pwl->id == APP_PWL_ID_0 ? PMU_VIORISE_REQ_USER_PWL0 : PMU_VIORISE_REQ_USER_PWL1, true); -#endif - hal_gpio_pin_set((enum HAL_GPIO_PIN_T)cfg_hw_pinmux_pwl[pwl->id].pin); - }else{ - hal_gpio_pin_clr((enum HAL_GPIO_PIN_T)cfg_hw_pinmux_pwl[pwl->id].pin); -#if defined(__PMU_VIO_DYNAMIC_CTRL_MODE__) - pmu_viorise_req(pwl->id == APP_PWL_ID_0 ? PMU_VIORISE_REQ_USER_PWL0 : PMU_VIORISE_REQ_USER_PWL1, false); -#endif + } else { + if (pwl->partidx >= cfg->parttotal) { + return; } - osTimerStart(pwl->timer, cfg->part[pwl->partidx].time); + } + + APP_PWL_TRACE(3, "idx:%d pin:%d lvl:%d", pwl->partidx, + cfg_hw_pinmux_pwl[pwl->id].pin, cfg->part[pwl->partidx].level); + if (!cfg->part[pwl->partidx].level) { +#if defined(__PMU_VIO_DYNAMIC_CTRL_MODE__) + pmu_viorise_req(pwl->id == APP_PWL_ID_0 ? PMU_VIORISE_REQ_USER_PWL0 + : PMU_VIORISE_REQ_USER_PWL1, + true); +#endif + hal_gpio_pin_set((enum HAL_GPIO_PIN_T)cfg_hw_pinmux_pwl[pwl->id].pin); + } else { + hal_gpio_pin_clr((enum HAL_GPIO_PIN_T)cfg_hw_pinmux_pwl[pwl->id].pin); +#if defined(__PMU_VIO_DYNAMIC_CTRL_MODE__) + pmu_viorise_req(pwl->id == APP_PWL_ID_0 ? PMU_VIORISE_REQ_USER_PWL0 + : PMU_VIORISE_REQ_USER_PWL1, + false); +#endif + } + osTimerStart(pwl->timer, cfg->part[pwl->partidx].time); } #endif -int app_pwl_open(void) -{ +int app_pwl_open(void) { #if (CFG_HW_PLW_NUM > 0) - uint8_t i; - APP_PWL_TRACE(1,"%s",__func__); - for (i=0;i 0) - struct APP_PWL_T *pwl = NULL; - struct APP_PWL_CFG_T *cfg = NULL; + struct APP_PWL_T *pwl = NULL; + struct APP_PWL_CFG_T *cfg = NULL; + if (id >= APP_PWL_ID_QTY) { + return -1; + } - if (id >= APP_PWL_ID_QTY) { - return -1; - } + APP_PWL_TRACE(2, "%s %d", __func__, id); - APP_PWL_TRACE(2,"%s %d",__func__, id); + pwl = &app_pwl[id]; + cfg = &(pwl->config); - pwl = &app_pwl[id]; - cfg = &(pwl->config); + if (pwl->id == APP_PWL_ID_QTY) { + return -1; + } - if (pwl->id == APP_PWL_ID_QTY){ - return -1; - } + pwl->partidx = 0; + if (pwl->partidx >= cfg->parttotal) { + return -1; + } - pwl->partidx = 0; - if (pwl->partidx >= cfg->parttotal){ - return -1; - } + osTimerStop(pwl->timer); - osTimerStop(pwl->timer); - - APP_PWL_TRACE(3,"idx:%d pin:%d lvl:%d", pwl->partidx, cfg_hw_pinmux_pwl[pwl->id].pin, cfg->part[pwl->partidx].level); - if(!cfg->part[pwl->partidx].level){ + APP_PWL_TRACE(3, "idx:%d pin:%d lvl:%d", pwl->partidx, + cfg_hw_pinmux_pwl[pwl->id].pin, cfg->part[pwl->partidx].level); + if (!cfg->part[pwl->partidx].level) { #if defined(__PMU_VIO_DYNAMIC_CTRL_MODE__) - pmu_viorise_req(pwl->id == APP_PWL_ID_0 ? PMU_VIORISE_REQ_USER_PWL0 : PMU_VIORISE_REQ_USER_PWL1, false); + pmu_viorise_req(pwl->id == APP_PWL_ID_0 ? PMU_VIORISE_REQ_USER_PWL0 + : PMU_VIORISE_REQ_USER_PWL1, + false); #endif - hal_gpio_pin_set((enum HAL_GPIO_PIN_T)cfg_hw_pinmux_pwl[pwl->id].pin); - }else{ - hal_gpio_pin_clr((enum HAL_GPIO_PIN_T)cfg_hw_pinmux_pwl[pwl->id].pin); + hal_gpio_pin_set((enum HAL_GPIO_PIN_T)cfg_hw_pinmux_pwl[pwl->id].pin); + } else { + hal_gpio_pin_clr((enum HAL_GPIO_PIN_T)cfg_hw_pinmux_pwl[pwl->id].pin); #if defined(__PMU_VIO_DYNAMIC_CTRL_MODE__) - pmu_viorise_req(pwl->id == APP_PWL_ID_0 ? PMU_VIORISE_REQ_USER_PWL0 : PMU_VIORISE_REQ_USER_PWL1, false); + pmu_viorise_req(pwl->id == APP_PWL_ID_0 ? PMU_VIORISE_REQ_USER_PWL0 + : PMU_VIORISE_REQ_USER_PWL1, + false); #endif - } - osTimerStart(pwl->timer, cfg->part[pwl->partidx].time); + } + osTimerStart(pwl->timer, cfg->part[pwl->partidx].time); #endif - return 0; + return 0; } -int app_pwl_setup(enum APP_PWL_ID_T id, struct APP_PWL_CFG_T *cfg) -{ +int app_pwl_setup(enum APP_PWL_ID_T id, struct APP_PWL_CFG_T *cfg) { #if (CFG_HW_PLW_NUM > 0) - if (cfg == NULL || id >= APP_PWL_ID_QTY) { - return -1; - } - APP_PWL_TRACE(2,"%s %d",__func__, id); + if (cfg == NULL || id >= APP_PWL_ID_QTY) { + return -1; + } + APP_PWL_TRACE(2, "%s %d", __func__, id); - hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)cfg_hw_pinmux_pwl[id].pin, HAL_GPIO_DIR_OUT, cfg->startlevel?0:1); - app_pwl[id].id = id; - memcpy(&(app_pwl[id].config), cfg, sizeof(struct APP_PWL_CFG_T)); + hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)cfg_hw_pinmux_pwl[id].pin, + HAL_GPIO_DIR_OUT, cfg->startlevel ? 0 : 1); + app_pwl[id].id = id; + memcpy(&(app_pwl[id].config), cfg, sizeof(struct APP_PWL_CFG_T)); - osTimerStop(app_pwl[id].timer); + osTimerStop(app_pwl[id].timer); #endif - return 0; + return 0; } -int app_pwl_stop(enum APP_PWL_ID_T id) -{ +int app_pwl_stop(enum APP_PWL_ID_T id) { #if (CFG_HW_PLW_NUM > 0) - if (id >= APP_PWL_ID_QTY) { - return -1; - } + if (id >= APP_PWL_ID_QTY) { + return -1; + } - osTimerStop(app_pwl[id].timer); - hal_gpio_pin_set((enum HAL_GPIO_PIN_T)cfg_hw_pinmux_pwl[id].pin); + osTimerStop(app_pwl[id].timer); + hal_gpio_pin_set((enum HAL_GPIO_PIN_T)cfg_hw_pinmux_pwl[id].pin); #endif - return 0; + return 0; } -int app_pwl_close(void) -{ +int app_pwl_close(void) { #if (CFG_HW_PLW_NUM > 0) - uint8_t i; - for (i=0;id_name, len); - } - closedir(d); - TRACE(0,"--------root end-------\n"); + TRACE(0, "---------root---------\n"); + struct dirent *p; + while ((p = readdir(d))) { + int len = sizeof(dirent); + TRACE(2, "%s %d\n", p->d_name, len); + } + closedir(d); + TRACE(0, "--------root end-------\n"); } extern uint32_t play_wav_file(char *file_path); extern uint32_t stop_wav_file(void); extern uint32_t wav_file_audio_more_data(uint8_t *buf, uint32_t len); -void test_wave_play(bool on) -{ - struct AF_STREAM_CONFIG_T stream_cfg; - uint32_t reallen; - uint32_t totalreadsize; - uint32_t stime, etime; +void test_wave_play(bool on) { + struct AF_STREAM_CONFIG_T stream_cfg; + uint32_t reallen; + uint32_t totalreadsize; + uint32_t stime, etime; - char wave[] = "/sd/test_music.wav"; + char wave[] = "/sd/test_music.wav"; - static bool isRun = false; - - if (isRun==on) - return; - else - isRun=on; - - - TRACE(2,"%s %d\n", __func__, on); - memset(&stream_cfg, 0, sizeof(stream_cfg)); - if (on){ - play_wav_file(wave); - - stream_cfg.bits = AUD_BITS_16; - stream_cfg.channel_num = AUD_CHANNEL_NUM_2; - stream_cfg.sample_rate = AUD_SAMPRATE_48000; - - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; - stream_cfg.vol = 0x03; - - stream_cfg.handler = wav_file_audio_more_data; - stream_cfg.data_ptr = app_test_playback_buff; - stream_cfg.data_size = APP_TEST_PLAYBACK_BUFF_SIZE; - - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - }else{ - stop_wav_file(); - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - } + static bool isRun = false; + if (isRun == on) return; -} + else + isRun = on; + TRACE(2, "%s %d\n", __func__, on); + memset(&stream_cfg, 0, sizeof(stream_cfg)); + if (on) { + play_wav_file(wave); + + stream_cfg.bits = AUD_BITS_16; + stream_cfg.channel_num = AUD_CHANNEL_NUM_2; + stream_cfg.sample_rate = AUD_SAMPRATE_48000; + + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; + stream_cfg.vol = 0x03; + + stream_cfg.handler = wav_file_audio_more_data; + stream_cfg.data_ptr = app_test_playback_buff; + stream_cfg.data_size = APP_TEST_PLAYBACK_BUFF_SIZE; + + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + } else { + stop_wav_file(); + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + } + + return; +} FIL pcm_fil; FRESULT pcm_res; UINT pcm_num; -uint32_t pcm_save_more_data(uint8_t *buf, uint32_t len) -{ -// TRACE(2,"%s\n len:%d", __func__, len); +uint32_t pcm_save_more_data(uint8_t *buf, uint32_t len) { + // TRACE(2,"%s\n len:%d", __func__, len); - audio_buffer_set_stereo2mono_16bits(buf, len, 1); - pcm_res = f_write(&pcm_fil,(uint8_t *)buf,len>>1,&pcm_num); - if(pcm_res != FR_OK) - { - TRACE(2,"[%s]:error-->res = %d", __func__, pcm_res); - } - return 0; + audio_buffer_set_stereo2mono_16bits(buf, len, 1); + pcm_res = f_write(&pcm_fil, (uint8_t *)buf, len >> 1, &pcm_num); + if (pcm_res != FR_OK) { + TRACE(2, "[%s]:error-->res = %d", __func__, pcm_res); + } + return 0; } -void ad_tester(bool run) -{ - char filename[] = "/sd/audio_dump.bin"; +void ad_tester(bool run) { + char filename[] = "/sd/audio_dump.bin"; - struct AF_STREAM_CONFIG_T stream_cfg; + struct AF_STREAM_CONFIG_T stream_cfg; - TRACE(2,"%s %d\n", __func__, run); + TRACE(2, "%s %d\n", __func__, run); - if (run){ - memset(&stream_cfg, 0, sizeof(stream_cfg)); - pcm_res = f_open(&pcm_fil,"test2.bin",FA_CREATE_ALWAYS | FA_WRITE); - if (pcm_res) { - TRACE(2,"[%s]:Cannot creat test2.bin...%d",__func__, pcm_res); - return; - } - - stream_cfg.bits = AUD_BITS_16; - stream_cfg.channel_num = AUD_CHANNEL_NUM_2; - stream_cfg.sample_rate = AUD_SAMPRATE_48000; - - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; - stream_cfg.io_path = AUD_INPUT_PATH_MAINMIC; - stream_cfg.vol = 0x03; - - stream_cfg.handler = pcm_save_more_data; - stream_cfg.data_ptr = app_test_playback_buff; - stream_cfg.data_size = APP_TEST_PLAYBACK_BUFF_SIZE; - - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - }else{ - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - osDelay(1000); - - f_close(&pcm_fil); + if (run) { + memset(&stream_cfg, 0, sizeof(stream_cfg)); + pcm_res = f_open(&pcm_fil, "test2.bin", FA_CREATE_ALWAYS | FA_WRITE); + if (pcm_res) { + TRACE(2, "[%s]:Cannot creat test2.bin...%d", __func__, pcm_res); + return; } + + stream_cfg.bits = AUD_BITS_16; + stream_cfg.channel_num = AUD_CHANNEL_NUM_2; + stream_cfg.sample_rate = AUD_SAMPRATE_48000; + + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; + stream_cfg.io_path = AUD_INPUT_PATH_MAINMIC; + stream_cfg.vol = 0x03; + + stream_cfg.handler = pcm_save_more_data; + stream_cfg.data_ptr = app_test_playback_buff; + stream_cfg.data_size = APP_TEST_PLAYBACK_BUFF_SIZE; + + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + } else { + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + osDelay(1000); + + f_close(&pcm_fil); + } } // if dump data into sd, buffer length should make sd card speed enough -// Bench32.exe can test sd card speed in PC, then make sure bufer length, buffer length < 16k(sd driver) -void dump_data2sd(enum APP_SDMMC_DUMP_T opt, uint8_t *buf, uint32_t len) -{ - static FIL sd_fil; - FRESULT res; +// Bench32.exe can test sd card speed in PC, then make sure bufer length, buffer +// length < 16k(sd driver) +void dump_data2sd(enum APP_SDMMC_DUMP_T opt, uint8_t *buf, uint32_t len) { + static FIL sd_fil; + FRESULT res; - - ASSERT(opt < APP_SDMMC_DUMP_NUM, "[%s] opt(%d) >= APP_SDMMC_DUMP_NUM", __func__, opt); - - if(opt == APP_SDMMC_DUMP_OPEN) - { -// res = f_open(&sd_fil,"dump.bin",FA_CREATE_ALWAYS | FA_WRITE); - res = f_open(&sd_fil,"test.txt",FA_READ); - -// ASSERT(pcm_res == FR_OK,"[%s]:Cannot creat dump.bin, res = %d",__func__, pcm_res); - } - if(opt == APP_SDMMC_DUMP_READ) - { - res = f_read(&sd_fil, buf, len, &pcm_num); - -// ASSERT(pcm_res == FR_OK,"[%s]:Cannot creat dump.bin, res = %d",__func__, pcm_res); - } - else if(opt == APP_SDMMC_DUMP_WRITE) - { - res = f_write(&sd_fil, buf, len, &pcm_num); + ASSERT(opt < APP_SDMMC_DUMP_NUM, "[%s] opt(%d) >= APP_SDMMC_DUMP_NUM", + __func__, opt); -// ASSERT(pcm_res == FR_OK,"[%s]:Write dump.bin failed, res = %d", __func__, pcm_res); - } - else if(opt == APP_SDMMC_DUMP_CLOSE) - { - res = f_close(&sd_fil); - } + if (opt == APP_SDMMC_DUMP_OPEN) { + // res = f_open(&sd_fil,"dump.bin",FA_CREATE_ALWAYS | FA_WRITE); + res = f_open(&sd_fil, "test.txt", FA_READ); - if(res == FR_OK) - { - TRACE(3,"[%s] SUCESS: opt = %d, res = %d",__func__, opt, res); - } - else - { - TRACE(3,"[%s] ERROR: opt = %d, res = %d",__func__, opt, res); - } + // ASSERT(pcm_res == FR_OK,"[%s]:Cannot creat dump.bin, res = + // %d",__func__, pcm_res); + } + if (opt == APP_SDMMC_DUMP_READ) { + res = f_read(&sd_fil, buf, len, &pcm_num); + + // ASSERT(pcm_res == FR_OK,"[%s]:Cannot creat dump.bin, res = + // %d",__func__, pcm_res); + } else if (opt == APP_SDMMC_DUMP_WRITE) { + res = f_write(&sd_fil, buf, len, &pcm_num); + + // ASSERT(pcm_res == FR_OK,"[%s]:Write dump.bin failed, res = %d", + // __func__, pcm_res); + } else if (opt == APP_SDMMC_DUMP_CLOSE) { + res = f_close(&sd_fil); + } + + if (res == FR_OK) { + TRACE(3, "[%s] SUCESS: opt = %d, res = %d", __func__, opt, res); + } else { + TRACE(3, "[%s] ERROR: opt = %d, res = %d", __func__, opt, res); + } } diff --git a/apps/usbaudio/usbaudio_entry.c b/apps/usbaudio/usbaudio_entry.c index 3afc6bf..ec4703d 100644 --- a/apps/usbaudio/usbaudio_entry.c +++ b/apps/usbaudio/usbaudio_entry.c @@ -13,30 +13,30 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_addr_map.h" +#include "analog.h" +#include "audioflinger.h" +#include "cmsis.h" #include "hal_cmu.h" -#include "hal_timer.h" -#include "hal_trace.h" -#include "hal_iomux.h" #include "hal_dma.h" -#include "hal_key.h" #include "hal_gpadc.h" +#include "hal_iomux.h" +#include "hal_key.h" #include "hal_sleep.h" #include "hal_sysfreq.h" -#include "cmsis.h" -#include "pmu.h" -#include "analog.h" -#include "string.h" +#include "hal_timer.h" +#include "hal_trace.h" #include "hwtimer_list.h" -#include "audioflinger.h" +#include "plat_addr_map.h" +#include "pmu.h" +#include "string.h" #if defined(ANC_APP) #include "anc_usb_app.h" #endif -#include "usb_audio_app.h" -#include "dualadc_audio_app.h" -#include "usb_audio_frm_defs.h" -#include "tgt_hardware.h" #include "audio_process.h" +#include "dualadc_audio_app.h" +#include "tgt_hardware.h" +#include "usb_audio_app.h" +#include "usb_audio_frm_defs.h" #ifdef RTOS #include "cmsis_os.h" @@ -46,75 +46,97 @@ #endif #ifdef USB_AUDIO_SPEECH -#define CODEC_BUFF_FRAME_NUM (2 * 16) -#define USB_BUFF_FRAME_NUM (CODEC_BUFF_FRAME_NUM * 2) +#define CODEC_BUFF_FRAME_NUM (2 * 16) +#define USB_BUFF_FRAME_NUM (CODEC_BUFF_FRAME_NUM * 2) #else -#define CODEC_BUFF_FRAME_NUM 4 -#define USB_BUFF_FRAME_NUM 8 +#define CODEC_BUFF_FRAME_NUM 4 +#define USB_BUFF_FRAME_NUM 8 #endif #if (CODEC_BUFF_FRAME_NUM >= USB_BUFF_FRAME_NUM) -#error "Codec buffer frame num should be less than usb buffer frame num (on the requirement of conflict ctrl)" +#error \ + "Codec buffer frame num should be less than usb buffer frame num (on the requirement of conflict ctrl)" #endif #ifdef USB_AUDIO_DYN_CFG -#define USB_AUDIO_PLAYBACK_BUFF_SIZE NON_EXP_ALIGN(MAX_FRAME_SIZE_PLAYBACK * CODEC_BUFF_FRAME_NUM, DAC_BUFF_ALIGN) -#define USB_AUDIO_CAPTURE_BUFF_SIZE NON_EXP_ALIGN(MAX_FRAME_SIZE_CAPTURE * CODEC_BUFF_FRAME_NUM, ADC_BUFF_ALIGN) +#define USB_AUDIO_PLAYBACK_BUFF_SIZE \ + NON_EXP_ALIGN(MAX_FRAME_SIZE_PLAYBACK *CODEC_BUFF_FRAME_NUM, DAC_BUFF_ALIGN) +#define USB_AUDIO_CAPTURE_BUFF_SIZE \ + NON_EXP_ALIGN(MAX_FRAME_SIZE_CAPTURE *CODEC_BUFF_FRAME_NUM, ADC_BUFF_ALIGN) -#define USB_AUDIO_RECV_BUFF_SIZE NON_EXP_ALIGN(MAX_FRAME_SIZE_RECV * USB_BUFF_FRAME_NUM, RECV_BUFF_ALIGN) -#define USB_AUDIO_SEND_BUFF_SIZE NON_EXP_ALIGN(MAX_FRAME_SIZE_SEND * USB_BUFF_FRAME_NUM, SEND_BUFF_ALIGN) +#define USB_AUDIO_RECV_BUFF_SIZE \ + NON_EXP_ALIGN(MAX_FRAME_SIZE_RECV *USB_BUFF_FRAME_NUM, RECV_BUFF_ALIGN) +#define USB_AUDIO_SEND_BUFF_SIZE \ + NON_EXP_ALIGN(MAX_FRAME_SIZE_SEND *USB_BUFF_FRAME_NUM, SEND_BUFF_ALIGN) #if defined(CHIP_BEST1000) // FIR EQ is working on 16-bit // FIR_EQ_buffer_size = max_playback_symbol_number_in_buffer * sizeof(int16_t) -#define USB_AUDIO_FIR_EQ_BUFF_SIZE USB_AUDIO_PLAYBACK_BUFF_SIZE +#define USB_AUDIO_FIR_EQ_BUFF_SIZE USB_AUDIO_PLAYBACK_BUFF_SIZE #elif defined(CHIP_BEST2000) // FIR EQ is working on 32-bit // FIR_EQ_buffer_size = max_playback_symbol_number_in_buffer * sizeof(int32_t) -#define USB_AUDIO_FIR_EQ_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE*2) +#define USB_AUDIO_FIR_EQ_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE * 2) #elif defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) // FIR EQ is working on 32-bit // FIR_EQ_buffer_size = max_playback_symbol_number_in_buffer * sizeof(int32_t) -#define USB_AUDIO_FIR_EQ_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE*2) +#define USB_AUDIO_FIR_EQ_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE * 2) #endif #else -#define USB_AUDIO_PLAYBACK_BUFF_SIZE NON_EXP_ALIGN(FRAME_SIZE_PLAYBACK * CODEC_BUFF_FRAME_NUM, DAC_BUFF_ALIGN) -#define USB_AUDIO_CAPTURE_BUFF_SIZE NON_EXP_ALIGN(FRAME_SIZE_CAPTURE * CODEC_BUFF_FRAME_NUM, ADC_BUFF_ALIGN) +#define USB_AUDIO_PLAYBACK_BUFF_SIZE \ + NON_EXP_ALIGN(FRAME_SIZE_PLAYBACK *CODEC_BUFF_FRAME_NUM, DAC_BUFF_ALIGN) +#define USB_AUDIO_CAPTURE_BUFF_SIZE \ + NON_EXP_ALIGN(FRAME_SIZE_CAPTURE *CODEC_BUFF_FRAME_NUM, ADC_BUFF_ALIGN) -#define USB_AUDIO_RECV_BUFF_SIZE NON_EXP_ALIGN(FRAME_SIZE_RECV * USB_BUFF_FRAME_NUM, RECV_BUFF_ALIGN) -#define USB_AUDIO_SEND_BUFF_SIZE NON_EXP_ALIGN(FRAME_SIZE_SEND * USB_BUFF_FRAME_NUM, SEND_BUFF_ALIGN) +#define USB_AUDIO_RECV_BUFF_SIZE \ + NON_EXP_ALIGN(FRAME_SIZE_RECV *USB_BUFF_FRAME_NUM, RECV_BUFF_ALIGN) +#define USB_AUDIO_SEND_BUFF_SIZE \ + NON_EXP_ALIGN(FRAME_SIZE_SEND *USB_BUFF_FRAME_NUM, SEND_BUFF_ALIGN) #if defined(CHIP_BEST1000) // FIR EQ is working on 16-bit -#define USB_AUDIO_FIR_EQ_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE * sizeof(int16_t) / SAMPLE_SIZE_PLAYBACK) +#define USB_AUDIO_FIR_EQ_BUFF_SIZE \ + (USB_AUDIO_PLAYBACK_BUFF_SIZE * sizeof(int16_t) / SAMPLE_SIZE_PLAYBACK) #elif defined(CHIP_BEST2000) // FIR EQ is working on 16-bit -#define USB_AUDIO_FIR_EQ_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE * sizeof(int32_t) / SAMPLE_SIZE_PLAYBACK) +#define USB_AUDIO_FIR_EQ_BUFF_SIZE \ + (USB_AUDIO_PLAYBACK_BUFF_SIZE * sizeof(int32_t) / SAMPLE_SIZE_PLAYBACK) #elif defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) // FIR EQ is working on 16-bit -#define USB_AUDIO_FIR_EQ_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE * sizeof(int32_t) / SAMPLE_SIZE_PLAYBACK) +#define USB_AUDIO_FIR_EQ_BUFF_SIZE \ + (USB_AUDIO_PLAYBACK_BUFF_SIZE * sizeof(int32_t) / SAMPLE_SIZE_PLAYBACK) #endif #endif -#if (defined(CHIP_BEST1000) && (defined(ANC_APP) || defined(_DUAL_AUX_MIC_))) && (CHAN_NUM_CAPTURE == CHAN_NUM_SEND) -// Resample input buffer size should be (half_of_max_sample_num * SAMPLE_SIZE_CAPTURE * CHAN_NUM_CAPTURE). -// half_of_max_sample_num = 48000 / 1000 * CODEC_BUFF_FRAME_NUM / 2 * 48 / 44 -#define RESAMPLE_INPUT_BUFF_SIZE ALIGN(48000 / 1000 * SAMPLE_SIZE_CAPTURE * CHAN_NUM_CAPTURE * CODEC_BUFF_FRAME_NUM / 2 * 48 / 44, 4) +#if (defined(CHIP_BEST1000) && \ + (defined(ANC_APP) || defined(_DUAL_AUX_MIC_))) && \ + (CHAN_NUM_CAPTURE == CHAN_NUM_SEND) +// Resample input buffer size should be (half_of_max_sample_num * +// SAMPLE_SIZE_CAPTURE * CHAN_NUM_CAPTURE). half_of_max_sample_num = 48000 / +// 1000 * CODEC_BUFF_FRAME_NUM / 2 * 48 / 44 +#define RESAMPLE_INPUT_BUFF_SIZE \ + ALIGN(48000 / 1000 * SAMPLE_SIZE_CAPTURE * CHAN_NUM_CAPTURE * \ + CODEC_BUFF_FRAME_NUM / 2 * 48 / 44, \ + 4) #else -#define RESAMPLE_INPUT_BUFF_SIZE 0 +#define RESAMPLE_INPUT_BUFF_SIZE 0 #endif // Resample history buffer size should be -// sizeof(struct RESAMPLE_CTRL_T) + ((SAMPLE_NUM + phase_coef_num) * SAMPLE_SIZE_CAPTURE * CHAN_NUM_CAPTURE) -#define RESAMPLE_HISTORY_BUFF_SIZE (50 + (256 * SAMPLE_SIZE_CAPTURE * CHAN_NUM_CAPTURE)) -#define USB_AUDIO_RESAMPLE_BUFF_SIZE (RESAMPLE_INPUT_BUFF_SIZE + RESAMPLE_HISTORY_BUFF_SIZE) +// sizeof(struct RESAMPLE_CTRL_T) + ((SAMPLE_NUM + phase_coef_num) * +// SAMPLE_SIZE_CAPTURE * CHAN_NUM_CAPTURE) +#define RESAMPLE_HISTORY_BUFF_SIZE \ + (50 + (256 * SAMPLE_SIZE_CAPTURE * CHAN_NUM_CAPTURE)) +#define USB_AUDIO_RESAMPLE_BUFF_SIZE \ + (RESAMPLE_INPUT_BUFF_SIZE + RESAMPLE_HISTORY_BUFF_SIZE) -#define ALIGNED4 ALIGNED(4) +#define ALIGNED4 ALIGNED(4) #if defined(USB_AUDIO_APP) || defined(DUALADC_AUDIO_TEST) #ifdef AUDIO_ANC_FB_MC -static uint8_t ALIGNED4 playback_buff[USB_AUDIO_PLAYBACK_BUFF_SIZE * 9];//max 48->384 or 44.1->44.1*8; +static uint8_t ALIGNED4 playback_buff[USB_AUDIO_PLAYBACK_BUFF_SIZE * + 9]; // max 48->384 or 44.1->44.1*8; #else static uint8_t ALIGNED4 playback_buff[USB_AUDIO_PLAYBACK_BUFF_SIZE]; #endif @@ -125,7 +147,8 @@ static uint8_t ALIGNED4 capture_buff[USB_AUDIO_CAPTURE_BUFF_SIZE]; #ifdef USB_AUDIO_APP #if defined(__HW_FIR_EQ_PROCESS__) && defined(__HW_IIR_EQ_PROCESS__) -static uint8_t ALIGNED4 eq_buff[USB_AUDIO_FIR_EQ_BUFF_SIZE+USB_AUDIO_IIR_EQ_BUFF_SIZE]; +static uint8_t ALIGNED4 + eq_buff[USB_AUDIO_FIR_EQ_BUFF_SIZE + USB_AUDIO_IIR_EQ_BUFF_SIZE]; #elif defined(__HW_FIR_EQ_PROCESS__) && !defined(__HW_IIR_EQ_PROCESS__) static uint8_t ALIGNED4 eq_buff[USB_AUDIO_FIR_EQ_BUFF_SIZE]; #elif !defined(__HW_FIR_EQ_PROCESS__) && defined(__HW_IIR_EQ_PROCESS__) @@ -146,202 +169,195 @@ static uint8_t ALIGNED4 send_buff[USB_AUDIO_SEND_BUFF_SIZE]; #ifdef CFG_HW_KEY_LED_PIN const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_key_led[1] = { - {CFG_HW_KEY_LED_PIN, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_NOPULL}, + {CFG_HW_KEY_LED_PIN, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_NOPULL}, }; #endif #ifdef CFG_MIC_KEY -extern void mic_key_open (void); +extern void mic_key_open(void); #endif -static void uart_i2c_switch(void) -{ - static int flag = 0; +static void uart_i2c_switch(void) { + static int flag = 0; - flag ^= 1; + flag ^= 1; - if (flag) { - hal_iomux_set_analog_i2c(); - } else { - hal_iomux_set_uart0(); - } + if (flag) { + hal_iomux_set_analog_i2c(); + } else { + hal_iomux_set_uart0(); + } } -static int POSSIBLY_UNUSED key_event_process(uint32_t key_code, uint8_t key_event) -{ - TRACE(3,"%s: code=0x%X, event=%u", __FUNCTION__, key_code, key_event); +static int POSSIBLY_UNUSED key_event_process(uint32_t key_code, + uint8_t key_event) { + TRACE(3, "%s: code=0x%X, event=%u", __FUNCTION__, key_code, key_event); #ifdef CFG_HW_KEY_LED_PIN - if (key_event == HAL_KEY_EVENT_DOWN) { - hal_gpio_pin_set(CFG_HW_KEY_LED_PIN); - } else if (key_event == HAL_KEY_EVENT_UP) { - hal_gpio_pin_clr(CFG_HW_KEY_LED_PIN); - } + if (key_event == HAL_KEY_EVENT_DOWN) { + hal_gpio_pin_set(CFG_HW_KEY_LED_PIN); + } else if (key_event == HAL_KEY_EVENT_UP) { + hal_gpio_pin_clr(CFG_HW_KEY_LED_PIN); + } #endif #ifdef USB_AUDIO_APP - if (usb_audio_app_key(key_code, key_event) == 0) { - return 0; - } + if (usb_audio_app_key(key_code, key_event) == 0) { + return 0; + } #endif #ifdef ANC_APP - if (anc_usb_app_key(key_code, key_event) == 0) { - return 0; - } + if (anc_usb_app_key(key_code, key_event) == 0) { + return 0; + } #endif - if (key_event == HAL_KEY_EVENT_CLICK) { - if (key_code == HAL_KEY_CODE_FN9) { - uart_i2c_switch(); - } + if (key_event == HAL_KEY_EVENT_CLICK) { + if (key_code == HAL_KEY_CODE_FN9) { + uart_i2c_switch(); } + } - return 0; + return 0; } -void anc_usb_open(void) -{ - TRACE(1,"%s", __FUNCTION__); +void anc_usb_open(void) { + TRACE(1, "%s", __FUNCTION__); #ifdef __AUDIO_RESAMPLE__ - hal_cmu_audio_resample_enable(); + hal_cmu_audio_resample_enable(); #endif #ifdef USB_AUDIO_APP - struct USB_AUDIO_BUF_CFG cfg; + struct USB_AUDIO_BUF_CFG cfg; - memset(&cfg, 0, sizeof(cfg)); - cfg.play_buf = playback_buff; + memset(&cfg, 0, sizeof(cfg)); + cfg.play_buf = playback_buff; #ifdef AUDIO_ANC_FB_MC - cfg.play_size = sizeof(playback_buff) / 9; + cfg.play_size = sizeof(playback_buff) / 9; #else - cfg.play_size = sizeof(playback_buff); + cfg.play_size = sizeof(playback_buff); #endif - cfg.cap_buf = capture_buff; - cfg.cap_size = sizeof(capture_buff); - cfg.recv_buf = recv_buff; - cfg.recv_size = sizeof(recv_buff); - cfg.send_buf = send_buff; - cfg.send_size = sizeof(send_buff); - cfg.eq_buf = eq_buff; - cfg.eq_size = sizeof(eq_buff); - cfg.resample_buf = resample_buff; - cfg.resample_size = sizeof(resample_buff); + cfg.cap_buf = capture_buff; + cfg.cap_size = sizeof(capture_buff); + cfg.recv_buf = recv_buff; + cfg.recv_size = sizeof(recv_buff); + cfg.send_buf = send_buff; + cfg.send_size = sizeof(send_buff); + cfg.eq_buf = eq_buff; + cfg.eq_size = sizeof(eq_buff); + cfg.resample_buf = resample_buff; + cfg.resample_size = sizeof(resample_buff); - usb_audio_app_init(&cfg); - usb_audio_app(1); + usb_audio_app_init(&cfg); + usb_audio_app(1); #endif #ifdef ANC_APP - anc_usb_app_init(AUD_INPUT_PATH_MAINMIC, SAMPLE_RATE_PLAYBACK, SAMPLE_RATE_CAPTURE); + anc_usb_app_init(AUD_INPUT_PATH_MAINMIC, SAMPLE_RATE_PLAYBACK, + SAMPLE_RATE_CAPTURE); #endif #ifdef DUALADC_AUDIO_TEST - dualadc_audio_app_init(playback_buff, USB_AUDIO_PLAYBACK_BUFF_SIZE, - capture_buff, USB_AUDIO_CAPTURE_BUFF_SIZE); - dualadc_audio_app(1); + dualadc_audio_app_init(playback_buff, USB_AUDIO_PLAYBACK_BUFF_SIZE, + capture_buff, USB_AUDIO_CAPTURE_BUFF_SIZE); + dualadc_audio_app(1); #endif #if defined(CFG_MIC_KEY) - mic_key_open(); + mic_key_open(); #endif #ifdef BT_USB_AUDIO_DUAL_MODE - return; + return; #endif - // Allow sleep - hal_sysfreq_req(HAL_SYSFREQ_USER_INIT, HAL_CMU_FREQ_32K); + // Allow sleep + hal_sysfreq_req(HAL_SYSFREQ_USER_INIT, HAL_CMU_FREQ_32K); - while (1) { + while (1) { #ifdef USB_AUDIO_APP - usb_audio_app_loop(); + usb_audio_app_loop(); #endif #ifdef ANC_APP - anc_usb_app_loop(); + anc_usb_app_loop(); #endif #ifdef RTOS - // Let the task sleep - osDelay(20); + // Let the task sleep + osDelay(20); #else // !RTOS #ifdef __PC_CMD_UART__ - hal_cmd_run(); + hal_cmd_run(); #endif - hal_sleep_enter_sleep(); + hal_sleep_enter_sleep(); #endif // !RTOS - } + } } -void anc_usb_close(void) -{ - usb_audio_app(0); -} +void anc_usb_close(void) { usb_audio_app(0); } #ifdef CFG_HW_GPADCKEY -void gpadc_key_handler(uint16_t irq_val, HAL_GPADC_MV_T volt) -{ - static uint16_t stable_cnt = 0; - static uint16_t click_cnt = 0; - static uint32_t click_time; - uint32_t time; - enum HAL_KEY_EVENT_T event; - bool send_event = false; +void gpadc_key_handler(uint16_t irq_val, HAL_GPADC_MV_T volt) { + static uint16_t stable_cnt = 0; + static uint16_t click_cnt = 0; + static uint32_t click_time; + uint32_t time; + enum HAL_KEY_EVENT_T event; + bool send_event = false; - time = hal_sys_timer_get(); + time = hal_sys_timer_get(); - if (volt < 100) { - stable_cnt++; - //TRACE(5,"adc_key down: volt=%u stable=%u click_cnt=%u click_time=%u time=%u", volt, stable_cnt, click_cnt, click_time, time); - } else { - if (stable_cnt > 1) { - //TRACE(5,"adc_key up: volt=%u stable=%u click_cnt=%u click_time=%u time=%u", volt, stable_cnt, click_cnt, click_time, time); - if (click_cnt == 0 || (time - click_time) < MS_TO_TICKS(500)) { - click_time = time; - click_cnt++; - if (click_cnt >= 3) { - send_event = true; - } - } else { - send_event = true; - } - } - stable_cnt = 0; - - if (click_cnt > 0 && (time - click_time) >= MS_TO_TICKS(500)) { - send_event = true; - } - - if (send_event) { - //TRACE(5,"adc_key click: volt=%u stable=%u click_cnt=%u click_time=%u time=%u", volt, stable_cnt, click_cnt, click_time, time); - if (click_cnt == 1) { - event = HAL_KEY_EVENT_CLICK; - } else if (click_cnt == 2) { - event = HAL_KEY_EVENT_DOUBLECLICK; - } else { - event = HAL_KEY_EVENT_TRIPLECLICK; - } - key_event_process(CFG_HW_GPADCKEY, event); - click_cnt = 0; + if (volt < 100) { + stable_cnt++; + // TRACE(5,"adc_key down: volt=%u stable=%u click_cnt=%u click_time=%u + // time=%u", volt, stable_cnt, click_cnt, click_time, time); + } else { + if (stable_cnt > 1) { + // TRACE(5,"adc_key up: volt=%u stable=%u click_cnt=%u click_time=%u + // time=%u", volt, stable_cnt, click_cnt, click_time, time); + if (click_cnt == 0 || (time - click_time) < MS_TO_TICKS(500)) { + click_time = time; + click_cnt++; + if (click_cnt >= 3) { + send_event = true; } + } else { + send_event = true; + } } + stable_cnt = 0; + + if (click_cnt > 0 && (time - click_time) >= MS_TO_TICKS(500)) { + send_event = true; + } + + if (send_event) { + // TRACE(5,"adc_key click: volt=%u stable=%u click_cnt=%u click_time=%u + // time=%u", volt, stable_cnt, click_cnt, click_time, time); + if (click_cnt == 1) { + event = HAL_KEY_EVENT_CLICK; + } else if (click_cnt == 2) { + event = HAL_KEY_EVENT_DOUBLECLICK; + } else { + event = HAL_KEY_EVENT_TRIPLECLICK; + } + key_event_process(CFG_HW_GPADCKEY, event); + click_cnt = 0; + } + } } #endif // GDB can set a breakpoint on the main function only if it is // declared as below, when linking with STD libraries. -int btusbaudio_entry(void) -{ - anc_usb_open(); - return 0; +int btusbaudio_entry(void) { + anc_usb_open(); + return 0; } -void btusbaudio_exit(void) -{ - anc_usb_close(); -} - - +void btusbaudio_exit(void) { anc_usb_close(); } diff --git a/apps/usbhost/app_usbhost.c b/apps/usbhost/app_usbhost.c index 464546b..35c02c1 100644 --- a/apps/usbhost/app_usbhost.c +++ b/apps/usbhost/app_usbhost.c @@ -13,9 +13,6 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "app_thread.h" #include "cmsis_os.h" #include "hal_trace.h" -#include "app_thread.h" - - - diff --git a/apps/voice_detector/app_voice_detector.cpp b/apps/voice_detector/app_voice_detector.cpp index 77f40e0..019c135 100644 --- a/apps/voice_detector/app_voice_detector.cpp +++ b/apps/voice_detector/app_voice_detector.cpp @@ -1,20 +1,22 @@ -#include -#include -#include "cmsis_os.h" -#include "tgt_hardware.h" -#include "audioflinger.h" -#include "hal_trace.h" -#include "hal_timer.h" -#include "app_thread.h" -#include "voice_detector.h" #include "app_voice_detector.h" +#include "app_thread.h" +#include "audioflinger.h" +#include "cmsis_os.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "tgt_hardware.h" +#include "voice_detector.h" +#include +#include #define APP_VD_DEBUG #ifdef APP_VD_DEBUG #define APP_VD_LOG(str, ...) LOG_DEBUG(LOG_MOD(AUD), str, ##__VA_ARGS__) #else -#define APP_VD_LOG(...) do{}while(0) +#define APP_VD_LOG(...) \ + do { \ + } while (0) #endif #define APP_VD_ERR(str, ...) LOG_ERROR(LOG_MOD(AUD), str, ##__VA_ARGS__) @@ -22,10 +24,8 @@ osMutexId vd_mutex_id = NULL; osMutexDef(vd_mutex); static int cmd_arr_evt_vad_start[] = { - VOICE_DET_CMD_AUD_CAP_STOP, - VOICE_DET_CMD_AUD_CAP_CLOSE, - VOICE_DET_CMD_VAD_OPEN, - VOICE_DET_CMD_VAD_START, + VOICE_DET_CMD_AUD_CAP_STOP, VOICE_DET_CMD_AUD_CAP_CLOSE, + VOICE_DET_CMD_VAD_OPEN, VOICE_DET_CMD_VAD_START, VOICE_DET_CMD_SYS_CLK_32K, }; #if 0 @@ -44,10 +44,8 @@ static int cmd_arr_evt_cap_start[] = { }; #endif static int cmd_arr_evt_close[] = { - VOICE_DET_CMD_AUD_CAP_STOP, - VOICE_DET_CMD_AUD_CAP_CLOSE, - VOICE_DET_CMD_VAD_STOP, - VOICE_DET_CMD_VAD_CLOSE, + VOICE_DET_CMD_AUD_CAP_STOP, VOICE_DET_CMD_AUD_CAP_CLOSE, + VOICE_DET_CMD_VAD_STOP, VOICE_DET_CMD_VAD_CLOSE, VOICE_DET_CMD_EXIT, }; #if 1 @@ -63,205 +61,191 @@ static int cmd_arr_evt_vad_close[] = { VOICE_DET_CMD_EXIT, }; -static int app_voice_detector_process(APP_MESSAGE_BODY *msg_body) -{ - enum voice_detector_id id = (enum voice_detector_id)msg_body->message_id; - enum voice_detector_evt evt = (enum voice_detector_evt)msg_body->message_ptr; - int ret = 0, num, *cmds; +static int app_voice_detector_process(APP_MESSAGE_BODY *msg_body) { + enum voice_detector_id id = (enum voice_detector_id)msg_body->message_id; + enum voice_detector_evt evt = (enum voice_detector_evt)msg_body->message_ptr; + int ret = 0, num, *cmds; - voice_detector_enhance_perform(id);// set sys clock to 104M or 208M + voice_detector_enhance_perform(id); // set sys clock to 104M or 208M - osMutexWait(vd_mutex_id, osWaitForever); - switch(evt) { - case VOICE_DET_EVT_VAD_START: - if (voice_detector_query_status(id) == VOICE_DET_STATE_VAD_CLOSE) { - cmds = &cmd_arr_evt_vad_start[0]; - num = ARRAY_SIZE(cmd_arr_evt_vad_start); - } else { - cmds = &cmd_arr_evt_vad_start[2]; - num = ARRAY_SIZE(cmd_arr_evt_vad_start) - 2; - } - break; - case VOICE_DET_EVT_AUD_CAP_START: - cmds = cmd_arr_evt_cap_start; - num = ARRAY_SIZE(cmd_arr_evt_cap_start); - break; - case VOICE_DET_EVT_CLOSE: - if (voice_detector_query_status(id) == VOICE_DET_STATE_VAD_CLOSE) { - cmds = &cmd_arr_evt_cap_close[0]; - num = ARRAY_SIZE(cmd_arr_evt_cap_close); - } else { - cmds = &cmd_arr_evt_vad_close[0]; - num = ARRAY_SIZE(cmd_arr_evt_vad_close); - } - break; - default: - cmds = cmd_arr_evt_close; - num = ARRAY_SIZE(cmd_arr_evt_close); - break; + osMutexWait(vd_mutex_id, osWaitForever); + switch (evt) { + case VOICE_DET_EVT_VAD_START: + if (voice_detector_query_status(id) == VOICE_DET_STATE_VAD_CLOSE) { + cmds = &cmd_arr_evt_vad_start[0]; + num = ARRAY_SIZE(cmd_arr_evt_vad_start); + } else { + cmds = &cmd_arr_evt_vad_start[2]; + num = ARRAY_SIZE(cmd_arr_evt_vad_start) - 2; } - ret = voice_detector_send_cmd_array(id, cmds, num); - if (ret) { - APP_VD_ERR("%s, send cmd error %d", __func__, ret); + break; + case VOICE_DET_EVT_AUD_CAP_START: + cmds = cmd_arr_evt_cap_start; + num = ARRAY_SIZE(cmd_arr_evt_cap_start); + break; + case VOICE_DET_EVT_CLOSE: + if (voice_detector_query_status(id) == VOICE_DET_STATE_VAD_CLOSE) { + cmds = &cmd_arr_evt_cap_close[0]; + num = ARRAY_SIZE(cmd_arr_evt_cap_close); + } else { + cmds = &cmd_arr_evt_vad_close[0]; + num = ARRAY_SIZE(cmd_arr_evt_vad_close); } - ret = voice_detector_run(id, VOICE_DET_MODE_EXEC_CMD); - if (ret) { - APP_VD_ERR("%s, run cmd error %d", __func__, ret); - } - if (evt == VOICE_DET_EVT_CLOSE) { - voice_detector_close(id); - } - osMutexRelease(vd_mutex_id); - return ret; + break; + default: + cmds = cmd_arr_evt_close; + num = ARRAY_SIZE(cmd_arr_evt_close); + break; + } + ret = voice_detector_send_cmd_array(id, cmds, num); + if (ret) { + APP_VD_ERR("%s, send cmd error %d", __func__, ret); + } + ret = voice_detector_run(id, VOICE_DET_MODE_EXEC_CMD); + if (ret) { + APP_VD_ERR("%s, run cmd error %d", __func__, ret); + } + if (evt == VOICE_DET_EVT_CLOSE) { + voice_detector_close(id); + } + osMutexRelease(vd_mutex_id); + return ret; } -static void voice_detector_send_msg(uint32_t id, uint32_t evt) -{ - APP_MESSAGE_BLOCK msg; +static void voice_detector_send_msg(uint32_t id, uint32_t evt) { + APP_MESSAGE_BLOCK msg; - msg.mod_id = APP_MODUAL_VOICE_DETECTOR; - msg.msg_body.message_id = id; - msg.msg_body.message_ptr = evt; + msg.mod_id = APP_MODUAL_VOICE_DETECTOR; + msg.msg_body.message_id = id; + msg.msg_body.message_ptr = evt; - app_mailbox_put(&msg); + app_mailbox_put(&msg); } -static void voice_detector_wakeup_system(int state, void *param) -{ - enum voice_detector_id id = VOICE_DETECTOR_ID_0; +static void voice_detector_wakeup_system(int state, void *param) { + enum voice_detector_id id = VOICE_DETECTOR_ID_0; - if (voice_detector_query_status(id) == VOICE_DET_STATE_VAD_START) { - app_voice_detector_send_event(id, VOICE_DET_EVT_AUD_CAP_START); - } + if (voice_detector_query_status(id) == VOICE_DET_STATE_VAD_START) { + app_voice_detector_send_event(id, VOICE_DET_EVT_AUD_CAP_START); + } - APP_VD_LOG("%s, state=%d", __func__, state); - // APP_VD_LOG("cpu freq=%d", hal_sys_timer_calc_cpu_freq(5,0)); + APP_VD_LOG("%s, state=%d", __func__, state); + // APP_VD_LOG("cpu freq=%d", hal_sys_timer_calc_cpu_freq(5,0)); } -static void voice_not_detector_wakeup_system(int state, void *param) -{ - enum voice_detector_id id = VOICE_DETECTOR_ID_0; +static void voice_not_detector_wakeup_system(int state, void *param) { + enum voice_detector_id id = VOICE_DETECTOR_ID_0; - if (voice_detector_query_status(id) == VOICE_DET_STATE_VAD_START) { - app_voice_detector_send_event(id, VOICE_DET_EVT_VAD_START); - } + if (voice_detector_query_status(id) == VOICE_DET_STATE_VAD_START) { + app_voice_detector_send_event(id, VOICE_DET_EVT_VAD_START); + } - APP_VD_LOG("%s, state=%d", __func__, state); - // APP_VD_LOG("cpu freq=%d", hal_sys_timer_calc_cpu_freq(5,0)); + APP_VD_LOG("%s, state=%d", __func__, state); + // APP_VD_LOG("cpu freq=%d", hal_sys_timer_calc_cpu_freq(5,0)); } -void app_voice_detector_init(void) -{ - APP_VD_LOG("%s", __func__); +void app_voice_detector_init(void) { + APP_VD_LOG("%s", __func__); - if(vd_mutex_id == NULL){ - vd_mutex_id = osMutexCreate((osMutex(vd_mutex))); - app_set_threadhandle(APP_MODUAL_VOICE_DETECTOR, app_voice_detector_process); - } + if (vd_mutex_id == NULL) { + vd_mutex_id = osMutexCreate((osMutex(vd_mutex))); + app_set_threadhandle(APP_MODUAL_VOICE_DETECTOR, app_voice_detector_process); + } } -int app_voice_detector_open(enum voice_detector_id id, enum AUD_VAD_TYPE_T vad_type) -{ - int r; +int app_voice_detector_open(enum voice_detector_id id, + enum AUD_VAD_TYPE_T vad_type) { + int r; - APP_VD_LOG("%s", __func__); + APP_VD_LOG("%s", __func__); - if (!vd_mutex_id) { - APP_VD_LOG("%s, mutex is null", __func__); - return -1; - } - osMutexWait(vd_mutex_id, osWaitForever); - r = voice_detector_open(id, vad_type); - if (!r) { - voice_detector_setup_callback(id, VOICE_DET_FIND_APP, - voice_detector_wakeup_system, NULL); - voice_detector_setup_callback(id, VOICE_DET_NOT_FIND_APP, - voice_not_detector_wakeup_system, NULL); - } - osMutexRelease(vd_mutex_id); - return r; + if (!vd_mutex_id) { + APP_VD_LOG("%s, mutex is null", __func__); + return -1; + } + osMutexWait(vd_mutex_id, osWaitForever); + r = voice_detector_open(id, vad_type); + if (!r) { + voice_detector_setup_callback(id, VOICE_DET_FIND_APP, + voice_detector_wakeup_system, NULL); + voice_detector_setup_callback(id, VOICE_DET_NOT_FIND_APP, + voice_not_detector_wakeup_system, NULL); + } + osMutexRelease(vd_mutex_id); + return r; } int app_voice_detector_setup_vad(enum voice_detector_id id, - struct AUD_VAD_CONFIG_T *conf) -{ - int r; + struct AUD_VAD_CONFIG_T *conf) { + int r; - APP_VD_LOG("%s", __func__); + APP_VD_LOG("%s", __func__); - if (!vd_mutex_id) { - APP_VD_LOG("%s, mutex is null", __func__); - return -1; - } - osMutexWait(vd_mutex_id, osWaitForever); - r = voice_detector_setup_vad(id, conf); - osMutexRelease(vd_mutex_id); - return r; + if (!vd_mutex_id) { + APP_VD_LOG("%s, mutex is null", __func__); + return -1; + } + osMutexWait(vd_mutex_id, osWaitForever); + r = voice_detector_setup_vad(id, conf); + osMutexRelease(vd_mutex_id); + return r; } int app_voice_detector_setup_stream(enum voice_detector_id id, enum AUD_STREAM_T stream_id, - struct AF_STREAM_CONFIG_T *stream) -{ - int r; + struct AF_STREAM_CONFIG_T *stream) { + int r; - APP_VD_LOG("%s", __func__); + APP_VD_LOG("%s", __func__); - if (!vd_mutex_id) { - APP_VD_LOG("%s, mutex is null", __func__); - return -1; - } - osMutexWait(vd_mutex_id, osWaitForever); - r = voice_detector_setup_stream(id, stream_id, stream); - osMutexRelease(vd_mutex_id); - return r; + if (!vd_mutex_id) { + APP_VD_LOG("%s, mutex is null", __func__); + return -1; + } + osMutexWait(vd_mutex_id, osWaitForever); + r = voice_detector_setup_stream(id, stream_id, stream); + osMutexRelease(vd_mutex_id); + return r; } int app_voice_detector_setup_callback(enum voice_detector_id id, enum voice_detector_cb_id func_id, - voice_detector_cb_t func, - void *param) -{ - int r; + voice_detector_cb_t func, void *param) { + int r; - APP_VD_LOG("%s", __func__); + APP_VD_LOG("%s", __func__); - if (!vd_mutex_id) { - APP_VD_LOG("%s, mutex is null", __func__); - return -1; - } - osMutexWait(vd_mutex_id, osWaitForever); - r = voice_detector_setup_callback(id, func_id, func, param); - osMutexRelease(vd_mutex_id); - return r; + if (!vd_mutex_id) { + APP_VD_LOG("%s, mutex is null", __func__); + return -1; + } + osMutexWait(vd_mutex_id, osWaitForever); + r = voice_detector_setup_callback(id, func_id, func, param); + osMutexRelease(vd_mutex_id); + return r; } int app_voice_detector_send_event(enum voice_detector_id id, - enum voice_detector_evt evt) -{ - APP_VD_LOG("%s, id=%d, evt=%d", __func__, id, evt); + enum voice_detector_evt evt) { + APP_VD_LOG("%s, id=%d, evt=%d", __func__, id, evt); - voice_detector_send_msg(id, evt); - return 0; + voice_detector_send_msg(id, evt); + return 0; } -void app_voice_detector_close(enum voice_detector_id id) -{ - APP_VD_LOG("%s", __func__); +void app_voice_detector_close(enum voice_detector_id id) { + APP_VD_LOG("%s", __func__); - voice_detector_send_msg(id, VOICE_DET_EVT_CLOSE); + voice_detector_send_msg(id, VOICE_DET_EVT_CLOSE); } -void app_voice_detector_capture_start(enum voice_detector_id id) -{ - APP_VD_LOG("%s", __func__); +void app_voice_detector_capture_start(enum voice_detector_id id) { + APP_VD_LOG("%s", __func__); - voice_detector_send_msg(id, VOICE_DET_EVT_AUD_CAP_START); + voice_detector_send_msg(id, VOICE_DET_EVT_AUD_CAP_START); } -void app_voice_detector_get_vad_data_info(enum voice_detector_id id, - struct CODEC_VAD_BUF_INFO_T* vad_buf_info) -{ - voice_detector_get_vad_data_info(id, vad_buf_info); +void app_voice_detector_get_vad_data_info( + enum voice_detector_id id, struct CODEC_VAD_BUF_INFO_T *vad_buf_info) { + voice_detector_get_vad_data_info(id, vad_buf_info); } - diff --git a/apps/voice_detector/voice_detector.c b/apps/voice_detector/voice_detector.c index a0d864d..c1defbf 100644 --- a/apps/voice_detector/voice_detector.c +++ b/apps/voice_detector/voice_detector.c @@ -1,16 +1,16 @@ -#include "hal_trace.h" -#include "hal_cmu.h" -#include "hal_aud.h" -#include "hal_timer.h" -#include "hal_sleep.h" #include "analog.h" #include "audioflinger.h" +#include "hal_aud.h" +#include "hal_cmu.h" +#include "hal_sleep.h" +#include "hal_timer.h" +#include "hal_trace.h" //#include "app_audio.h" #include "app_utils.h" -#include "voice_detector.h" -#include #include "audio_dump.h" #include "speech_ssat.h" +#include "voice_detector.h" +#include #include "pmu.h" #ifdef __CYBERON @@ -27,37 +27,41 @@ #ifdef VD_DEBUG #define VD_LOG TRACE #else -#define VD_LOG(...) do{}while(0) +#define VD_LOG(...) \ + do { \ + } while (0) #endif #ifdef VD_TEST #define VD_TRACE TRACE #else -#define VD_TRACE(...) do{}while(0) +#define VD_TRACE(...) \ + do { \ + } while (0) #endif #define CMD_QUEUE_DATA_SIZE 15 struct command_queue { - int idx; - int out; - int data[CMD_QUEUE_DATA_SIZE]; + int idx; + int out; + int data[CMD_QUEUE_DATA_SIZE]; }; struct voice_detector_dev { - uint8_t init; - uint8_t dfl; - uint8_t run; - enum voice_detector_state state; - uint32_t wakeup_cnt; - uint32_t arguments[VOICE_DET_CB_QTY]; - voice_detector_cb_t callback[VOICE_DET_CB_QTY]; - struct command_queue cmd_queue; - struct AUD_VAD_CONFIG_T conf; - struct AF_STREAM_CONFIG_T cap_conf; - struct AF_STREAM_CONFIG_T ply_conf; - struct CODEC_VAD_BUF_INFO_T vad_buf_info; - uint32_t sys_clk; + uint8_t init; + uint8_t dfl; + uint8_t run; + enum voice_detector_state state; + uint32_t wakeup_cnt; + uint32_t arguments[VOICE_DET_CB_QTY]; + voice_detector_cb_t callback[VOICE_DET_CB_QTY]; + struct command_queue cmd_queue; + struct AUD_VAD_CONFIG_T conf; + struct AF_STREAM_CONFIG_T cap_conf; + struct AF_STREAM_CONFIG_T ply_conf; + struct CODEC_VAD_BUF_INFO_T vad_buf_info; + uint32_t sys_clk; }; static struct voice_detector_dev voice_det_devs[VOICE_DETECTOR_QTY]; @@ -66,839 +70,814 @@ uint32_t vad_buf_len = 0; short vad_buf[VAD_BUFFER_LEN] = {0}; #ifdef __CYBERON -static uint32_t POSSIBLY_UNUSED cyb_buf[20*1024]; +static uint32_t POSSIBLY_UNUSED cyb_buf[20 * 1024]; static uint32_t POSSIBLY_UNUSED cyb_buf_used = 0; extern unsigned char __g_cybase_start[]; extern unsigned char __g_cygroup_start[]; #define BASE_MODEL_DATA (__g_cybase_start) -#define COMMAND_MODEL_DATA (__g_cygroup_start) +#define COMMAND_MODEL_DATA (__g_cygroup_start) HANDLE h_CSpotter = NULL; #endif static void voice_detector_vad_callback(int found); static void voice_detector_exec_callback(struct voice_detector_dev *pdev, - enum voice_detector_cb_id id); + enum voice_detector_cb_id id); #define to_voice_dev(id) (&voice_det_devs[(id)]) -static int cmd_queue_enqueue(struct command_queue *q, int c) -{ - if (q->idx >= CMD_QUEUE_DATA_SIZE) { - VD_LOG(2, "%s, overflow cmd=%d", __func__, c); - return -2; - } - if (q->idx < 0) { - q->idx = 0; - } - q->data[q->idx++] = c; -// VD_LOG(2, "%s, cmd=%d", __func__, c); - return 0; +static int cmd_queue_enqueue(struct command_queue *q, int c) { + if (q->idx >= CMD_QUEUE_DATA_SIZE) { + VD_LOG(2, "%s, overflow cmd=%d", __func__, c); + return -2; + } + if (q->idx < 0) { + q->idx = 0; + } + q->data[q->idx++] = c; + // VD_LOG(2, "%s, cmd=%d", __func__, c); + return 0; } -static int cmd_queue_dequeue(struct command_queue *q) -{ - int cmd; +static int cmd_queue_dequeue(struct command_queue *q) { + int cmd; - if (q->idx < 0) { -// VD_LOG(1, "%s, empty", __func__); - return -2; - } - if (q->out < 0) { - q->out = 0; - } - cmd = q->data[q->out++]; - if (q->out >= q->idx) { - q->out = -1; - q->idx = -1; - } -// VD_LOG(2, "%s, cmd=%d", __func__, cmd); - return cmd; + if (q->idx < 0) { + // VD_LOG(1, "%s, empty", __func__); + return -2; + } + if (q->out < 0) { + q->out = 0; + } + cmd = q->data[q->out++]; + if (q->out >= q->idx) { + q->out = -1; + q->idx = -1; + } + // VD_LOG(2, "%s, cmd=%d", __func__, cmd); + return cmd; } -static int cmd_queue_is_empty(struct command_queue *q) -{ - return (q->idx < 0) ? 1 : 0; +static int cmd_queue_is_empty(struct command_queue *q) { + return (q->idx < 0) ? 1 : 0; } -static void voice_detector_init_cmd_queue(struct command_queue *q) -{ - if (q) { - q->idx = -1; - q->out = -1; - } +static void voice_detector_init_cmd_queue(struct command_queue *q) { + if (q) { + q->idx = -1; + q->out = -1; + } } -static void voice_detector_init_vad(struct AUD_VAD_CONFIG_T *c, int id, enum AUD_VAD_TYPE_T vad_type) -{ - if (c) { - c->type = vad_type; +static void voice_detector_init_vad(struct AUD_VAD_CONFIG_T *c, int id, + enum AUD_VAD_TYPE_T vad_type) { + if (c) { + c->type = vad_type; #ifdef VAD_USE_8K_SAMPLE_RATE - c->sample_rate = AUD_SAMPRATE_8000; + c->sample_rate = AUD_SAMPRATE_8000; #else - c->sample_rate = AUD_SAMPRATE_16000; + c->sample_rate = AUD_SAMPRATE_16000; #endif - c->bits = AUD_BITS_16; - c->handler = voice_detector_vad_callback; - c->udc = VAD_DEFAULT_UDC; - c->upre = VAD_DEFAULT_UPRE; + c->bits = AUD_BITS_16; + c->handler = voice_detector_vad_callback; + c->udc = VAD_DEFAULT_UDC; + c->upre = VAD_DEFAULT_UPRE; #ifdef I2C_VAD - c->frame_len = VAD_DEFAULT_SENSOR_FRAME_LEN; + c->frame_len = VAD_DEFAULT_SENSOR_FRAME_LEN; #else - c->frame_len = VAD_DEFAULT_MIC_FRAME_LEN; + c->frame_len = VAD_DEFAULT_MIC_FRAME_LEN; #endif - c->mvad = VAD_DEFAULT_MVAD; - c->dig_mode = VAD_DEFAULT_DIG_MODE; - c->pre_gain = VAD_DEFAULT_PRE_GAIN; - c->sth = VAD_DEFAULT_STH; - c->dc_bypass = VAD_DEFAULT_DC_BYPASS; - c->frame_th[0] = VAD_DEFAULT_FRAME_TH0; - c->frame_th[1] = VAD_DEFAULT_FRAME_TH0; - c->frame_th[2] = VAD_DEFAULT_FRAME_TH0; - c->range[0] = VAD_DEFAULT_RANGE0; - c->range[1] = VAD_DEFAULT_RANGE1; - c->range[2] = VAD_DEFAULT_RANGE2; - c->range[3] = VAD_DEFAULT_RANGE3; - c->psd_th[0] = VAD_DEFAULT_PSD_TH0; - c->psd_th[1] = VAD_DEFAULT_PSD_TH1; - } + c->mvad = VAD_DEFAULT_MVAD; + c->dig_mode = VAD_DEFAULT_DIG_MODE; + c->pre_gain = VAD_DEFAULT_PRE_GAIN; + c->sth = VAD_DEFAULT_STH; + c->dc_bypass = VAD_DEFAULT_DC_BYPASS; + c->frame_th[0] = VAD_DEFAULT_FRAME_TH0; + c->frame_th[1] = VAD_DEFAULT_FRAME_TH0; + c->frame_th[2] = VAD_DEFAULT_FRAME_TH0; + c->range[0] = VAD_DEFAULT_RANGE0; + c->range[1] = VAD_DEFAULT_RANGE1; + c->range[2] = VAD_DEFAULT_RANGE2; + c->range[3] = VAD_DEFAULT_RANGE3; + c->psd_th[0] = VAD_DEFAULT_PSD_TH0; + c->psd_th[1] = VAD_DEFAULT_PSD_TH1; + } } -int voice_detector_open(enum voice_detector_id id, enum AUD_VAD_TYPE_T vad_type) -{ - struct voice_detector_dev *pdev; +int voice_detector_open(enum voice_detector_id id, + enum AUD_VAD_TYPE_T vad_type) { + struct voice_detector_dev *pdev; - if (id >= VOICE_DETECTOR_QTY) { - VD_LOG(1, "%s, invalid id=%d", __func__, id); - return -1; - } + if (id >= VOICE_DETECTOR_QTY) { + VD_LOG(1, "%s, invalid id=%d", __func__, id); + return -1; + } - pdev = to_voice_dev(id); - if (pdev->init) { - VD_LOG(1, "%s, dev already open", __func__); - return -2; - } + pdev = to_voice_dev(id); + if (pdev->init) { + VD_LOG(1, "%s, dev already open", __func__); + return -2; + } + if (pdev->run) { + VD_LOG(1, "%s, dev not stoped", __func__); + return -3; + } + + memset(pdev, 0x0, sizeof(struct voice_detector_dev)); + memset(&pdev->cap_conf, 0x0, sizeof(struct AF_STREAM_CONFIG_T)); + memset(&pdev->ply_conf, 0x0, sizeof(struct AF_STREAM_CONFIG_T)); + voice_detector_init_cmd_queue(&pdev->cmd_queue); + voice_detector_init_vad(&pdev->conf, id, vad_type); + pdev->state = VOICE_DET_STATE_IDLE; + pdev->run = 0; + pdev->dfl = 1; + pdev->init = 1; + + return 0; +} + +void voice_detector_close(enum voice_detector_id id) { + struct voice_detector_dev *pdev; + + if (id >= VOICE_DETECTOR_QTY) { + VD_LOG(2, "%s, invalid id=%d", __func__, id); + return; + } + + pdev = to_voice_dev(id); + if (pdev->init) { if (pdev->run) { - VD_LOG(1, "%s, dev not stoped", __func__); - return -3; - } - - memset(pdev, 0x0, sizeof(struct voice_detector_dev)); - memset(&pdev->cap_conf, 0x0, sizeof(struct AF_STREAM_CONFIG_T)); - memset(&pdev->ply_conf, 0x0, sizeof(struct AF_STREAM_CONFIG_T)); - voice_detector_init_cmd_queue(&pdev->cmd_queue); - voice_detector_init_vad(&pdev->conf, id, vad_type); - pdev->state = VOICE_DET_STATE_IDLE; - pdev->run = 0; - pdev->dfl = 1; - pdev->init = 1; - - return 0; -} - -void voice_detector_close(enum voice_detector_id id) -{ - struct voice_detector_dev *pdev; - - if (id >= VOICE_DETECTOR_QTY) { - VD_LOG(2, "%s, invalid id=%d", __func__, id); - return; - } - - pdev = to_voice_dev(id); - if (pdev->init) { - if (pdev->run) { - cmd_queue_enqueue(&pdev->cmd_queue, VOICE_DET_CMD_EXIT); - } - pdev->init = 0; + cmd_queue_enqueue(&pdev->cmd_queue, VOICE_DET_CMD_EXIT); } + pdev->init = 0; + } } int voice_detector_setup_vad(enum voice_detector_id id, - struct AUD_VAD_CONFIG_T *conf) -{ - struct voice_detector_dev *pdev; + struct AUD_VAD_CONFIG_T *conf) { + struct voice_detector_dev *pdev; - if (id >= VOICE_DETECTOR_QTY) { - VD_LOG(2, "%s, invalid id=%d", __func__, id); - return -1; - } + if (id >= VOICE_DETECTOR_QTY) { + VD_LOG(2, "%s, invalid id=%d", __func__, id); + return -1; + } - pdev = to_voice_dev(id); - if (!pdev->init) { - VD_LOG(1, "%s, dev not open", __func__); - return -2; - } + pdev = to_voice_dev(id); + if (!pdev->init) { + VD_LOG(1, "%s, dev not open", __func__); + return -2; + } - if (conf) { - memcpy(&pdev->conf, conf, sizeof(*conf)); - pdev->conf.handler = voice_detector_vad_callback; - pdev->dfl = 0; - } - return 0; + if (conf) { + memcpy(&pdev->conf, conf, sizeof(*conf)); + pdev->conf.handler = voice_detector_vad_callback; + pdev->dfl = 0; + } + return 0; } int voice_detector_setup_stream(enum voice_detector_id id, - enum AUD_STREAM_T stream_id, struct AF_STREAM_CONFIG_T *stream) -{ - struct voice_detector_dev *pdev; + enum AUD_STREAM_T stream_id, + struct AF_STREAM_CONFIG_T *stream) { + struct voice_detector_dev *pdev; - if (id >= VOICE_DETECTOR_QTY) { - VD_LOG(2, "%s, invalid id=%d", __func__, id); - return -1; - } + if (id >= VOICE_DETECTOR_QTY) { + VD_LOG(2, "%s, invalid id=%d", __func__, id); + return -1; + } - pdev = to_voice_dev(id); - if (!pdev->init) { - VD_LOG(1, "%s, dev not open", __func__); - return -2; - } + pdev = to_voice_dev(id); + if (!pdev->init) { + VD_LOG(1, "%s, dev not open", __func__); + return -2; + } - if (stream_id == AUD_STREAM_CAPTURE) - memcpy(&pdev->cap_conf, stream, sizeof(struct AF_STREAM_CONFIG_T)); - else - memcpy(&pdev->ply_conf, stream, sizeof(struct AF_STREAM_CONFIG_T)); + if (stream_id == AUD_STREAM_CAPTURE) + memcpy(&pdev->cap_conf, stream, sizeof(struct AF_STREAM_CONFIG_T)); + else + memcpy(&pdev->ply_conf, stream, sizeof(struct AF_STREAM_CONFIG_T)); - return 0; + return 0; } int voice_detector_setup_callback(enum voice_detector_id id, - enum voice_detector_cb_id func_id, voice_detector_cb_t func, void *param) -{ - struct voice_detector_dev *pdev; + enum voice_detector_cb_id func_id, + voice_detector_cb_t func, void *param) { + struct voice_detector_dev *pdev; - if (id >= VOICE_DETECTOR_QTY) { - VD_LOG(2, "%s, invalid id=%d", __func__, id); - return -1; - } + if (id >= VOICE_DETECTOR_QTY) { + VD_LOG(2, "%s, invalid id=%d", __func__, id); + return -1; + } - pdev = to_voice_dev(id); - if (!pdev->init) { - VD_LOG(1, "%s, dev not open", __func__); - return -2; - } + pdev = to_voice_dev(id); + if (!pdev->init) { + VD_LOG(1, "%s, dev not open", __func__); + return -2; + } - if (func_id >= VOICE_DET_CB_QTY) { - VD_LOG(2, "%s, invalid func_id=%d", __func__, func_id); - return -3; - } - pdev->arguments[func_id] = (uint32_t)param; - pdev->callback[func_id] = func; - return 0; + if (func_id >= VOICE_DET_CB_QTY) { + VD_LOG(2, "%s, invalid func_id=%d", __func__, func_id); + return -3; + } + pdev->arguments[func_id] = (uint32_t)param; + pdev->callback[func_id] = func; + return 0; } -int voice_detector_send_cmd(enum voice_detector_id id, enum voice_detector_cmd cmd) -{ - int r; - struct voice_detector_dev *pdev; +int voice_detector_send_cmd(enum voice_detector_id id, + enum voice_detector_cmd cmd) { + int r; + struct voice_detector_dev *pdev; - if (id >= VOICE_DETECTOR_QTY) { - VD_LOG(2, "%s, invalid id=%d", __func__, id); - return -1; - } - pdev = to_voice_dev(id); + if (id >= VOICE_DETECTOR_QTY) { + VD_LOG(2, "%s, invalid id=%d", __func__, id); + return -1; + } + pdev = to_voice_dev(id); - r = cmd_queue_enqueue(&pdev->cmd_queue, (int)cmd); - return r; + r = cmd_queue_enqueue(&pdev->cmd_queue, (int)cmd); + return r; } -int voice_detector_send_cmd_array(enum voice_detector_id id, int *cmd_array, int num) -{ - int r, i; - struct voice_detector_dev *pdev; +int voice_detector_send_cmd_array(enum voice_detector_id id, int *cmd_array, + int num) { + int r, i; + struct voice_detector_dev *pdev; - if (id >= VOICE_DETECTOR_QTY) { - VD_LOG(2, "%s, invalid id=%d", __func__, id); - return -1; - } - pdev = to_voice_dev(id); + if (id >= VOICE_DETECTOR_QTY) { + VD_LOG(2, "%s, invalid id=%d", __func__, id); + return -1; + } + pdev = to_voice_dev(id); - for(i = 0; i < num; i++) { - r = cmd_queue_enqueue(&pdev->cmd_queue, cmd_array[i]); - if (r) - return r; - } - return 0; + for (i = 0; i < num; i++) { + r = cmd_queue_enqueue(&pdev->cmd_queue, cmd_array[i]); + if (r) + return r; + } + return 0; } -enum voice_detector_state voice_detector_query_status(enum voice_detector_id id) -{ - struct voice_detector_dev *pdev; +enum voice_detector_state +voice_detector_query_status(enum voice_detector_id id) { + struct voice_detector_dev *pdev; - if (id >= VOICE_DETECTOR_QTY) { - return VOICE_DET_STATE_IDLE; - } - pdev = to_voice_dev(id); + if (id >= VOICE_DETECTOR_QTY) { + return VOICE_DET_STATE_IDLE; + } + pdev = to_voice_dev(id); - VD_LOG(2, "%s, state=%d", __func__, pdev->state); - return pdev->state; + VD_LOG(2, "%s, state=%d", __func__, pdev->state); + return pdev->state; } -static void voice_detector_vad_callback(int found) -{ - struct voice_detector_dev *pdev; - enum voice_detector_id id = VOICE_DETECTOR_ID_0; +static void voice_detector_vad_callback(int found) { + struct voice_detector_dev *pdev; + enum voice_detector_id id = VOICE_DETECTOR_ID_0; - pdev = to_voice_dev(id); + pdev = to_voice_dev(id); - pdev->wakeup_cnt++; + pdev->wakeup_cnt++; - VD_LOG(3, "%s, voice detector[%d], wakeup_cnt=%d", - __func__, id, pdev->wakeup_cnt); + VD_LOG(3, "%s, voice detector[%d], wakeup_cnt=%d", __func__, id, + pdev->wakeup_cnt); - if (pdev->wakeup_cnt == 1) { - /* - * VOICE_DET_CB_APP should be called only once - * after CPU is waked up from sleeping. - * The VAD already can gernerates interrupts at this monment or later. - */ - voice_detector_exec_callback(pdev, found ? VOICE_DET_FIND_APP : VOICE_DET_NOT_FIND_APP); - } + if (pdev->wakeup_cnt == 1) { + /* + * VOICE_DET_CB_APP should be called only once + * after CPU is waked up from sleeping. + * The VAD already can gernerates interrupts at this monment or later. + */ + voice_detector_exec_callback(pdev, found ? VOICE_DET_FIND_APP + : VOICE_DET_NOT_FIND_APP); + } } -static int voice_detector_vad_open(struct voice_detector_dev *pdev) -{ - struct AUD_VAD_CONFIG_T *c = &pdev->conf; +static int voice_detector_vad_open(struct voice_detector_dev *pdev) { + struct AUD_VAD_CONFIG_T *c = &pdev->conf; - if (pdev->dfl) { - VD_LOG(1, "%s, use dfl vad", __func__); - } - af_vad_open(c); + if (pdev->dfl) { + VD_LOG(1, "%s, use dfl vad", __func__); + } + af_vad_open(c); #ifdef I2C_VAD - vad_sensor_open(); + vad_sensor_open(); #endif - return 0; + return 0; } -static int voice_detector_vad_start(struct voice_detector_dev *pdev) -{ - /* wakeup_cnt is cleared while VAD starts */ - pdev->wakeup_cnt = 0; - af_vad_start(); +static int voice_detector_vad_start(struct voice_detector_dev *pdev) { + /* wakeup_cnt is cleared while VAD starts */ + pdev->wakeup_cnt = 0; + af_vad_start(); #ifdef I2C_VAD - vad_sensor_engine_start(); + vad_sensor_engine_start(); #endif - return 0; + return 0; } -static int voice_detector_vad_stop(struct voice_detector_dev *pdev) -{ - af_vad_stop(); +static int voice_detector_vad_stop(struct voice_detector_dev *pdev) { + af_vad_stop(); #ifdef I2C_VAD - vad_sensor_engine_stop(); + vad_sensor_engine_stop(); #else - /* get vad buf info after stopping it */ - af_vad_get_data_info(&(pdev->vad_buf_info)); - TRACE(4,"vad_buf base_addr:0x%x, buf_size:0x%x, data_count:%d, addr_count:%d", - pdev->vad_buf_info.base_addr, pdev->vad_buf_info.buf_size, - pdev->vad_buf_info.data_count, pdev->vad_buf_info.addr_count); + /* get vad buf info after stopping it */ + af_vad_get_data_info(&(pdev->vad_buf_info)); + TRACE(4, + "vad_buf base_addr:0x%x, buf_size:0x%x, data_count:%d, addr_count:%d", + pdev->vad_buf_info.base_addr, pdev->vad_buf_info.buf_size, + pdev->vad_buf_info.data_count, pdev->vad_buf_info.addr_count); #if defined(CHIP_BEST2300) - vad_buf_len = pdev->vad_buf_info.data_count/2; + vad_buf_len = pdev->vad_buf_info.data_count / 2; #else - vad_buf_len = pdev->vad_buf_info.data_count; + vad_buf_len = pdev->vad_buf_info.data_count; #endif #endif - return 0; + return 0; } -void voice_detector_get_vad_data_info(enum voice_detector_id id, - struct CODEC_VAD_BUF_INFO_T* vad_buf_info) -{ +void voice_detector_get_vad_data_info( + enum voice_detector_id id, struct CODEC_VAD_BUF_INFO_T *vad_buf_info) { - struct voice_detector_dev *pdev; + struct voice_detector_dev *pdev; - pdev = to_voice_dev(id); - - vad_buf_info->base_addr = pdev->vad_buf_info.base_addr; - vad_buf_info->buf_size = pdev->vad_buf_info.buf_size; - vad_buf_info->data_count = pdev->vad_buf_info.data_count; - vad_buf_info->addr_count = pdev->vad_buf_info.addr_count; + pdev = to_voice_dev(id); + vad_buf_info->base_addr = pdev->vad_buf_info.base_addr; + vad_buf_info->buf_size = pdev->vad_buf_info.buf_size; + vad_buf_info->data_count = pdev->vad_buf_info.data_count; + vad_buf_info->addr_count = pdev->vad_buf_info.addr_count; } -static int voice_detector_vad_close(struct voice_detector_dev *pdev) -{ +static int voice_detector_vad_close(struct voice_detector_dev *pdev) { #ifdef I2C_VAD - vad_sensor_close(); + vad_sensor_close(); #endif - af_vad_close(); - return 0; + af_vad_close(); + return 0; } -static int voice_detector_aud_cap_open(struct voice_detector_dev *pdev) -{ - struct AF_STREAM_CONFIG_T *conf = &pdev->cap_conf; +static int voice_detector_aud_cap_open(struct voice_detector_dev *pdev) { + struct AF_STREAM_CONFIG_T *conf = &pdev->cap_conf; - if ((!conf->handler) || (!conf->data_ptr)) { - VD_LOG(1, "%s, capture stream is null", __func__); - return -1; - } - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, conf); - return 0; + if ((!conf->handler) || (!conf->data_ptr)) { + VD_LOG(1, "%s, capture stream is null", __func__); + return -1; + } + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, conf); + return 0; } -static int voice_detector_aud_cap_start(struct voice_detector_dev *pdev) -{ - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - return 0; +static int voice_detector_aud_cap_start(struct voice_detector_dev *pdev) { + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + return 0; } -static int voice_detector_aud_cap_stop(struct voice_detector_dev *pdev) -{ - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - return 0; +static int voice_detector_aud_cap_stop(struct voice_detector_dev *pdev) { + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + return 0; } -static int voice_detector_aud_cap_close(struct voice_detector_dev *pdev) -{ - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - return 0; +static int voice_detector_aud_cap_close(struct voice_detector_dev *pdev) { + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + return 0; } -static int voice_detector_sys_clk(struct voice_detector_dev *pdev) -{ +static int voice_detector_sys_clk(struct voice_detector_dev *pdev) { #ifdef VD_TEST - app_sysfreq_req(APP_SYSFREQ_USER_APP_0, (enum APP_SYSFREQ_FREQ_T)(pdev->sys_clk)); + app_sysfreq_req(APP_SYSFREQ_USER_APP_0, + (enum APP_SYSFREQ_FREQ_T)(pdev->sys_clk)); #else - app_sysfreq_req(APP_SYSFREQ_USER_AI_VOICE, (enum APP_SYSFREQ_FREQ_T)(pdev->sys_clk)); + app_sysfreq_req(APP_SYSFREQ_USER_AI_VOICE, + (enum APP_SYSFREQ_FREQ_T)(pdev->sys_clk)); #endif -// VD_TRACE(2,"%s, cpu freq=%d", __func__, hal_sys_timer_calc_cpu_freq(5,0)); - return 0; + // VD_TRACE(2,"%s, cpu freq=%d", __func__, + // hal_sys_timer_calc_cpu_freq(5,0)); + return 0; } -static int voice_detector_exit(struct voice_detector_dev *pdev) -{ - //TODO: exit process - return 0; +static int voice_detector_exit(struct voice_detector_dev *pdev) { + // TODO: exit process + return 0; } -static int voice_detector_idle(struct voice_detector_dev *pdev) -{ - //TODO: idle process - return 0; +static int voice_detector_idle(struct voice_detector_dev *pdev) { + // TODO: idle process + return 0; } struct cmd_vector { - const char *name; - int cmd; - int (*func)(struct voice_detector_dev *pdev); + const char *name; + int cmd; + int (*func)(struct voice_detector_dev *pdev); }; static struct cmd_vector cmd_vectors[] = { - {"idle", VOICE_DET_CMD_IDLE, voice_detector_idle}, - {"exit", VOICE_DET_CMD_EXIT, voice_detector_exit}, - {"vad open", VOICE_DET_CMD_VAD_OPEN, voice_detector_vad_open}, - {"vad start",VOICE_DET_CMD_VAD_START, voice_detector_vad_start}, - {"vad stop", VOICE_DET_CMD_VAD_STOP, voice_detector_vad_stop}, - {"vad close",VOICE_DET_CMD_VAD_CLOSE, voice_detector_vad_close}, - {"cap start",VOICE_DET_CMD_AUD_CAP_START, voice_detector_aud_cap_start}, - {"cap stop", VOICE_DET_CMD_AUD_CAP_STOP, voice_detector_aud_cap_stop}, - {"cap open", VOICE_DET_CMD_AUD_CAP_OPEN, voice_detector_aud_cap_open}, - {"cap close",VOICE_DET_CMD_AUD_CAP_CLOSE, voice_detector_aud_cap_close}, - {"clk32k", VOICE_DET_CMD_SYS_CLK_32K, voice_detector_sys_clk}, - {"clk26m", VOICE_DET_CMD_SYS_CLK_26M, voice_detector_sys_clk}, - {"clk52m", VOICE_DET_CMD_SYS_CLK_52M, voice_detector_sys_clk}, - {"clk104m", VOICE_DET_CMD_SYS_CLK_104M, voice_detector_sys_clk}, + {"idle", VOICE_DET_CMD_IDLE, voice_detector_idle}, + {"exit", VOICE_DET_CMD_EXIT, voice_detector_exit}, + {"vad open", VOICE_DET_CMD_VAD_OPEN, voice_detector_vad_open}, + {"vad start", VOICE_DET_CMD_VAD_START, voice_detector_vad_start}, + {"vad stop", VOICE_DET_CMD_VAD_STOP, voice_detector_vad_stop}, + {"vad close", VOICE_DET_CMD_VAD_CLOSE, voice_detector_vad_close}, + {"cap start", VOICE_DET_CMD_AUD_CAP_START, voice_detector_aud_cap_start}, + {"cap stop", VOICE_DET_CMD_AUD_CAP_STOP, voice_detector_aud_cap_stop}, + {"cap open", VOICE_DET_CMD_AUD_CAP_OPEN, voice_detector_aud_cap_open}, + {"cap close", VOICE_DET_CMD_AUD_CAP_CLOSE, voice_detector_aud_cap_close}, + {"clk32k", VOICE_DET_CMD_SYS_CLK_32K, voice_detector_sys_clk}, + {"clk26m", VOICE_DET_CMD_SYS_CLK_26M, voice_detector_sys_clk}, + {"clk52m", VOICE_DET_CMD_SYS_CLK_52M, voice_detector_sys_clk}, + {"clk104m", VOICE_DET_CMD_SYS_CLK_104M, voice_detector_sys_clk}, }; -static int voice_detector_process_cmd(struct voice_detector_dev *pdev, int cmd) -{ - int err; +static int voice_detector_process_cmd(struct voice_detector_dev *pdev, + int cmd) { + int err; - VD_LOG(3, "%s, cmd[%d]: %s", __func__, cmd, cmd_vectors[(int)cmd].name); + VD_LOG(3, "%s, cmd[%d]: %s", __func__, cmd, cmd_vectors[(int)cmd].name); - switch(cmd) { - case VOICE_DET_CMD_SYS_CLK_32K: - pdev->sys_clk = APP_SYSFREQ_32K; - break; - case VOICE_DET_CMD_SYS_CLK_26M: - pdev->sys_clk = APP_SYSFREQ_26M; - break; - case VOICE_DET_CMD_SYS_CLK_52M: - pdev->sys_clk = APP_SYSFREQ_52M; - break; - case VOICE_DET_CMD_SYS_CLK_104M: - pdev->sys_clk = APP_SYSFREQ_104M; - break; - default: - break; - } - err = cmd_vectors[(int)cmd].func(pdev); - return err; + switch (cmd) { + case VOICE_DET_CMD_SYS_CLK_32K: + pdev->sys_clk = APP_SYSFREQ_32K; + break; + case VOICE_DET_CMD_SYS_CLK_26M: + pdev->sys_clk = APP_SYSFREQ_26M; + break; + case VOICE_DET_CMD_SYS_CLK_52M: + pdev->sys_clk = APP_SYSFREQ_52M; + break; + case VOICE_DET_CMD_SYS_CLK_104M: + pdev->sys_clk = APP_SYSFREQ_104M; + break; + default: + break; + } + err = cmd_vectors[(int)cmd].func(pdev); + return err; } -static void voice_detector_set_status(struct voice_detector_dev *pdev, enum voice_detector_state s) -{ - if ((s == VOICE_DET_STATE_SYS_CLK_104M) - || (s == VOICE_DET_STATE_SYS_CLK_52M) - || (s == VOICE_DET_STATE_SYS_CLK_26M) - || (s == VOICE_DET_STATE_SYS_CLK_32K)) { - return; - } - pdev->state = s; - VD_LOG(2, "%s, state=%d", __func__, pdev->state); +static void voice_detector_set_status(struct voice_detector_dev *pdev, + enum voice_detector_state s) { + if ((s == VOICE_DET_STATE_SYS_CLK_104M) || + (s == VOICE_DET_STATE_SYS_CLK_52M) || + (s == VOICE_DET_STATE_SYS_CLK_26M) || + (s == VOICE_DET_STATE_SYS_CLK_32K)) { + return; + } + pdev->state = s; + VD_LOG(2, "%s, state=%d", __func__, pdev->state); } static void voice_detector_exec_callback(struct voice_detector_dev *pdev, - enum voice_detector_cb_id id) -{ - voice_detector_cb_t func; + enum voice_detector_cb_id id) { + voice_detector_cb_t func; - func = pdev->callback[id]; - if (func) { - void *argv = (void *)(pdev->arguments[id]); + func = pdev->callback[id]; + if (func) { + void *argv = (void *)(pdev->arguments[id]); - func(pdev->state, argv); - } + func(pdev->state, argv); + } } -int voice_detector_enhance_perform(enum voice_detector_id id) -{ - struct voice_detector_dev *pdev = to_voice_dev(id); +int voice_detector_enhance_perform(enum voice_detector_id id) { + struct voice_detector_dev *pdev = to_voice_dev(id); - pdev->sys_clk = APP_SYSFREQ_26M; + pdev->sys_clk = APP_SYSFREQ_26M; - return app_sysfreq_req(APP_SYSFREQ_USER_AI_VOICE, - (enum APP_SYSFREQ_FREQ_T)(pdev->sys_clk)); + return app_sysfreq_req(APP_SYSFREQ_USER_AI_VOICE, + (enum APP_SYSFREQ_FREQ_T)(pdev->sys_clk)); } -int voice_detector_run(enum voice_detector_id id, int continous) -{ - int exit = 0; - int exit_code = 0; - struct voice_detector_dev *pdev; +int voice_detector_run(enum voice_detector_id id, int continous) { + int exit = 0; + int exit_code = 0; + struct voice_detector_dev *pdev; - if (id >= VOICE_DETECTOR_QTY) { - return -1; + if (id >= VOICE_DETECTOR_QTY) { + return -1; + } + + pdev = to_voice_dev(id); + if (!pdev->init) + return -2; + + voice_detector_exec_callback(pdev, VOICE_DET_CB_PREVIOUS); + pdev->run = 1; + while (1) { + int err = 0; + int cmd = cmd_queue_dequeue(&pdev->cmd_queue); + + if (cmd < 0) { + // cmd is invalid, invoke waitting callback + voice_detector_exec_callback(pdev, VOICE_DET_CB_RUN_WAIT); + } else { + // cmd is okay, process it + err = voice_detector_process_cmd(pdev, cmd); + if (!err) { + voice_detector_set_status(pdev, (enum voice_detector_state)cmd); + voice_detector_exec_callback(pdev, VOICE_DET_CB_RUN_DONE); + } else { + voice_detector_exec_callback(pdev, VOICE_DET_CB_ERROR); + VD_LOG(3, "%s, process cmd %d error, %d", __func__, cmd, err); + } } - - pdev = to_voice_dev(id); - if (!pdev->init) - return -2; - - voice_detector_exec_callback(pdev, VOICE_DET_CB_PREVIOUS); - pdev->run = 1; - while (1) { - int err = 0; - int cmd = cmd_queue_dequeue(&pdev->cmd_queue); - - if (cmd < 0) { - // cmd is invalid, invoke waitting callback - voice_detector_exec_callback(pdev, VOICE_DET_CB_RUN_WAIT); - } else { - // cmd is okay, process it - err = voice_detector_process_cmd(pdev, cmd); - if (!err) { - voice_detector_set_status(pdev, (enum voice_detector_state)cmd); - voice_detector_exec_callback(pdev, VOICE_DET_CB_RUN_DONE); - } else { - voice_detector_exec_callback(pdev, VOICE_DET_CB_ERROR); - VD_LOG(3, "%s, process cmd %d error, %d", __func__, cmd, err); - } - } - switch(continous) { - case VOICE_DET_MODE_ONESHOT: - // not continous, run only once - exit_code = err; - exit = 1; - break; - case VOICE_DET_MODE_EXEC_CMD: - // continous run,exit until cmd queue is empty - if (cmd_queue_is_empty(&pdev->cmd_queue)) { - exit = 1; - exit_code = err; - // invoke waitting callback - voice_detector_exec_callback(pdev, VOICE_DET_CB_RUN_WAIT); - } - break; - case VOICE_DET_MODE_LOOP: - //continous run forever, exit until receive VOICE_DET_CMD_EXIT - if (cmd == VOICE_DET_CMD_EXIT) { - exit = 1; - exit_code = err; - } - break; - default: - break; - } - if (exit) { - break; - } + switch (continous) { + case VOICE_DET_MODE_ONESHOT: + // not continous, run only once + exit_code = err; + exit = 1; + break; + case VOICE_DET_MODE_EXEC_CMD: + // continous run,exit until cmd queue is empty + if (cmd_queue_is_empty(&pdev->cmd_queue)) { + exit = 1; + exit_code = err; + // invoke waitting callback + voice_detector_exec_callback(pdev, VOICE_DET_CB_RUN_WAIT); + } + break; + case VOICE_DET_MODE_LOOP: + // continous run forever, exit until receive VOICE_DET_CMD_EXIT + if (cmd == VOICE_DET_CMD_EXIT) { + exit = 1; + exit_code = err; + } + break; + default: + break; } - pdev->run = 0; - voice_detector_exec_callback(pdev, VOICE_DET_CB_POST); + if (exit) { + break; + } + } + pdev->run = 0; + voice_detector_exec_callback(pdev, VOICE_DET_CB_POST); - return exit_code; + return exit_code; } #ifdef VD_TEST #include "app_voice_detector.h" -#define AUDIO_CAP_BUFF_SIZE (160*2*2*2) +#define AUDIO_CAP_BUFF_SIZE (160 * 2 * 2 * 2) -static uint32_t buff_capture[AUDIO_CAP_BUFF_SIZE/4]; +static uint32_t buff_capture[AUDIO_CAP_BUFF_SIZE / 4]; static uint32_t voice_det_evt = 0; -static uint8_t vad_data_buf[8 * 1024]; +static uint8_t vad_data_buf[8 * 1024]; -static void voice_detector_send_evt(uint32_t evt) -{ - voice_det_evt = evt; +static void voice_detector_send_evt(uint32_t evt) { voice_det_evt = evt; } + +static void print_vad_raw_data(uint8_t *buf, uint32_t len) { + VD_TRACE(3, "%s, buf=%x, len=%d", __func__, (uint32_t)buf, len); + // TODO: print data } -static void print_vad_raw_data(uint8_t *buf, uint32_t len) -{ - VD_TRACE(3,"%s, buf=%x, len=%d", __func__, (uint32_t)buf, len); - //TODO: print data -} - - static int State_M_1 = 0; -void dc_filter_f(short *in, int len, float left_gain, float right_gain) -{ - int tmp1; - for (int i = 0; i> 4; - tmp1 = in[i]; - tmp1 -= State_M_1; - in[i] = speech_ssat_int16(tmp1); - } +void dc_filter_f(short *in, int len, float left_gain, float right_gain) { + int tmp1; + for (int i = 0; i < len; i += 1) { + State_M_1 = (15 * State_M_1 + in[i]) >> 4; + tmp1 = in[i]; + tmp1 -= State_M_1; + in[i] = speech_ssat_int16(tmp1); + } } +static uint32_t mic_data_come(uint8_t *buf, uint32_t len) { + static int come_cnt = 0; + short *p16data = (short *)buf; + uint32_t sample_len = len / 2; + int retcode = 0; -static uint32_t mic_data_come(uint8_t *buf, uint32_t len) -{ - static int come_cnt = 0; - short *p16data = (short *)buf; - uint32_t sample_len = len / 2; - int retcode = 0; + dc_filter_f(p16data, sample_len, 0.0, 0.0); - dc_filter_f(p16data, sample_len, 0.0, 0.0); - - audio_dump_clear_up(); - audio_dump_add_channel_data(0, p16data, sample_len); - //audio_dump_add_channel_data(1, temp_buf, sample_len); - audio_dump_run(); + audio_dump_clear_up(); + audio_dump_add_channel_data(0, p16data, sample_len); + // audio_dump_add_channel_data(1, temp_buf, sample_len); + audio_dump_run(); #ifdef __CYBERON - retcode = CSpotter_AddSample(h_CSpotter, p16data, sample_len); + retcode = CSpotter_AddSample(h_CSpotter, p16data, sample_len); - if (retcode == CSPOTTER_SUCCESS) { - int id, score; + if (retcode == CSPOTTER_SUCCESS) { + int id, score; - id = CSpotter_GetResult(h_CSpotter); - TRACE(1,"##### CSpotterGetResult return ID : %d\n", id); + id = CSpotter_GetResult(h_CSpotter); + TRACE(1, "##### CSpotterGetResult return ID : %d\n", id); - score = CSpotter_GetResultScore(h_CSpotter); - TRACE(1,"CSpotter_GetResultScore return Score: %d", score); + score = CSpotter_GetResultScore(h_CSpotter); + TRACE(1, "CSpotter_GetResultScore return Score: %d", score); - CSpotter_Reset(h_CSpotter); - - } + CSpotter_Reset(h_CSpotter); + } #endif - if(come_cnt % 100 == 0) { - TRACE(1,"retcode: %d", retcode); - } - come_cnt++; - //if ((come_cnt % 200) == 0) { - // VD_TRACE(3,"%s, buf=%x, len=%d", __func__, (uint32_t)buf, len); - // } - if ((come_cnt % 300) == 0) { - come_cnt = 0; - voice_detector_send_evt(VOICE_DET_EVT_VAD_START); - VD_TRACE(1,"%s, close audio stream ...", __func__); - } + if (come_cnt % 100 == 0) { + TRACE(1, "retcode: %d", retcode); + } + come_cnt++; + // if ((come_cnt % 200) == 0) { + // VD_TRACE(3,"%s, buf=%x, len=%d", __func__, (uint32_t)buf, len); + // } + if ((come_cnt % 300) == 0) { + come_cnt = 0; + voice_detector_send_evt(VOICE_DET_EVT_VAD_START); + VD_TRACE(1, "%s, close audio stream ...", __func__); + } - return 0; + return 0; } #ifdef __CYBERON -static int CSpotter_Init_bes() -{ +static int CSpotter_Init_bes() { #define TIMES (1000) - int err; - int state_size, mem_size; - uint8_t *state_buffer, *mem_pool; - uint8_t *p_combuf = (uint8_t *)cyb_buf; + int err; + int state_size, mem_size; + uint8_t *state_buffer, *mem_pool; + uint8_t *p_combuf = (uint8_t *)cyb_buf; - TRACE(1,"%s",__func__); + TRACE(1, "%s", __func__); - state_size = CSpotter_GetStateSize((BYTE*)COMMAND_MODEL_DATA); - TRACE(2,"%s, state_size=%d",__func__, state_size); + state_size = CSpotter_GetStateSize((BYTE *)COMMAND_MODEL_DATA); + TRACE(2, "%s, state_size=%d", __func__, state_size); - state_buffer = p_combuf+ cyb_buf_used; - cyb_buf_used += state_size; - if (!state_buffer) { - TRACE(0,"alloc state buff failed"); - err = -1; - goto fail; - } + state_buffer = p_combuf + cyb_buf_used; + cyb_buf_used += state_size; + if (!state_buffer) { + TRACE(0, "alloc state buff failed"); + err = -1; + goto fail; + } - mem_size = CSpotter_GetMemoryUsage_Sep((BYTE*)BASE_MODEL_DATA, (BYTE*)COMMAND_MODEL_DATA, TIMES); - TRACE(1,"mem_size=%d",mem_size); + mem_size = CSpotter_GetMemoryUsage_Sep((BYTE *)BASE_MODEL_DATA, + (BYTE *)COMMAND_MODEL_DATA, TIMES); + TRACE(1, "mem_size=%d", mem_size); - mem_pool = p_combuf+ cyb_buf_used; - cyb_buf_used += mem_size; - if (!mem_pool) { - TRACE(0,"alloc mem pool failed"); - err = -2; - goto fail; - } + mem_pool = p_combuf + cyb_buf_used; + cyb_buf_used += mem_size; + if (!mem_pool) { + TRACE(0, "alloc mem pool failed"); + err = -2; + goto fail; + } - h_CSpotter = CSpotter_Init_Sep((BYTE*)BASE_MODEL_DATA, (BYTE*)COMMAND_MODEL_DATA, - TIMES, mem_pool, mem_size, state_buffer, state_size, &err); - if (!h_CSpotter) { - TRACE(1,"CSpotter Init fail! err : %d\n", err); - err = -3; - goto fail; - } + h_CSpotter = CSpotter_Init_Sep((BYTE *)BASE_MODEL_DATA, + (BYTE *)COMMAND_MODEL_DATA, TIMES, mem_pool, + mem_size, state_buffer, state_size, &err); + if (!h_CSpotter) { + TRACE(1, "CSpotter Init fail! err : %d\n", err); + err = -3; + goto fail; + } - return 0; + return 0; fail: - return err; + return err; } #endif -static void cmd_wait_handler(int state, void *param) -{ - voice_detector_send_evt(VOICE_DET_EVT_IDLE); +static void cmd_wait_handler(int state, void *param) { + voice_detector_send_evt(VOICE_DET_EVT_IDLE); - VD_TRACE(2,"%s, state=%d", __func__, state); -// hal_sys_timer_delay(MS_TO_TICKS(100)); -// while(1); + VD_TRACE(2, "%s, state=%d", __func__, state); + // hal_sys_timer_delay(MS_TO_TICKS(100)); + // while(1); -// hal_sleep_enter_sleep(); + // hal_sleep_enter_sleep(); } -static void cmd_done_handler(int state, void *param) -{ - VD_TRACE(2,"%s, state=%d", __func__, state); +static void cmd_done_handler(int state, void *param) { + VD_TRACE(2, "%s, state=%d", __func__, state); } -static void cpu_det_find_wakeup_handler(int state, void *param) -{ - static uint32_t cpu_wakeup_cnt = 0; +static void cpu_det_find_wakeup_handler(int state, void *param) { + static uint32_t cpu_wakeup_cnt = 0; - cpu_wakeup_cnt++; - VD_TRACE(3,"%s, state=%d, cnt=%d", __func__, state, cpu_wakeup_cnt); - //VD_TRACE(2,"%s, calc sys freq=%d", __func__, hal_sys_timer_calc_cpu_freq(5,0)); + cpu_wakeup_cnt++; + VD_TRACE(3, "%s, state=%d, cnt=%d", __func__, state, cpu_wakeup_cnt); + // VD_TRACE(2,"%s, calc sys freq=%d", __func__, + // hal_sys_timer_calc_cpu_freq(5,0)); - voice_detector_send_evt(VOICE_DET_EVT_AUD_CAP_START); + voice_detector_send_evt(VOICE_DET_EVT_AUD_CAP_START); } -static void cpu_det_notfind_wakeup_handler(int state, void *param) -{ +static void cpu_det_notfind_wakeup_handler(int state, void *param) { - VD_TRACE(2,"%s, state=%d", __func__, state); - //VD_TRACE(2,"%s, calc sys freq=%d", __func__, hal_sys_timer_calc_cpu_freq(5,0)); + VD_TRACE(2, "%s, state=%d", __func__, state); + // VD_TRACE(2,"%s, calc sys freq=%d", __func__, + // hal_sys_timer_calc_cpu_freq(5,0)); - voice_detector_send_evt(VOICE_DET_EVT_VAD_START); + voice_detector_send_evt(VOICE_DET_EVT_VAD_START); } -void voice_detector_test(void) -{ - enum voice_detector_id id = VOICE_DETECTOR_ID_0; - int r, run; - struct AF_STREAM_CONFIG_T stream_cfg; - enum HAL_SLEEP_STATUS_T sleep; - uint32_t len; +void voice_detector_test(void) { + enum voice_detector_id id = VOICE_DETECTOR_ID_0; + int r, run; + struct AF_STREAM_CONFIG_T stream_cfg; + enum HAL_SLEEP_STATUS_T sleep; + uint32_t len; - VD_TRACE(1,"%s, start", __func__); + VD_TRACE(1, "%s, start", __func__); - af_open(); + af_open(); - memset(&stream_cfg, 0, sizeof(stream_cfg)); + memset(&stream_cfg, 0, sizeof(stream_cfg)); - stream_cfg.sample_rate = AUD_SAMPRATE_16000; - stream_cfg.bits = AUD_BITS_16; - stream_cfg.vol = 16; - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; - stream_cfg.io_path = AUD_INPUT_PATH_VADMIC; - stream_cfg.channel_num = AUD_CHANNEL_NUM_1; - stream_cfg.handler = mic_data_come; - stream_cfg.data_ptr = (uint8_t *)buff_capture; - stream_cfg.data_size = AUDIO_CAP_BUFF_SIZE; + stream_cfg.sample_rate = AUD_SAMPRATE_16000; + stream_cfg.bits = AUD_BITS_16; + stream_cfg.vol = 16; + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; + stream_cfg.io_path = AUD_INPUT_PATH_VADMIC; + stream_cfg.channel_num = AUD_CHANNEL_NUM_1; + stream_cfg.handler = mic_data_come; + stream_cfg.data_ptr = (uint8_t *)buff_capture; + stream_cfg.data_size = AUDIO_CAP_BUFF_SIZE; - audio_dump_init(AUDIO_CAP_BUFF_SIZE / 2 / 2, sizeof(short), 1); + audio_dump_init(AUDIO_CAP_BUFF_SIZE / 2 / 2, sizeof(short), 1); #ifdef __CYBERON - CSpotter_Init_bes(); + CSpotter_Init_bes(); #endif - r = voice_detector_open(id); - if (r) { - VD_TRACE(2,"%s, error %d", __func__, r); - return; + r = voice_detector_open(id); + if (r) { + VD_TRACE(2, "%s, error %d", __func__, r); + return; + } + + voice_detector_setup_stream(id, AUD_STREAM_CAPTURE, &stream_cfg); + voice_detector_setup_callback(id, VOICE_DET_CB_RUN_WAIT, cmd_wait_handler, + NULL); + voice_detector_setup_callback(id, VOICE_DET_CB_RUN_DONE, cmd_done_handler, + NULL); + voice_detector_setup_callback(id, VOICE_DET_FIND_APP, + cpu_det_find_wakeup_handler, NULL); + voice_detector_setup_callback(id, VOICE_DET_NOT_FIND_APP, + cpu_det_notfind_wakeup_handler, NULL); + + VD_TRACE(2, "%s, calc sys freq=%d", __func__, + hal_sys_timer_calc_cpu_freq(5, 0)); + + voice_detector_send_cmd(id, VOICE_DET_CMD_AUD_CAP_OPEN); + voice_detector_send_cmd(id, VOICE_DET_CMD_AUD_CAP_CLOSE); + voice_detector_send_evt(VOICE_DET_EVT_VAD_START); + run = 0; + + while (1) { + if (voice_det_evt != VOICE_DET_EVT_IDLE) { + switch (voice_det_evt) { + case VOICE_DET_EVT_VAD_START: + if (voice_detector_query_status(id) == VOICE_DET_STATE_VAD_CLOSE) { + voice_detector_send_cmd(id, VOICE_DET_CMD_AUD_CAP_STOP); + voice_detector_send_cmd(id, VOICE_DET_CMD_AUD_CAP_CLOSE); + } + // TODO: save current system clock + voice_detector_send_cmd(id, VOICE_DET_CMD_VAD_OPEN); + voice_detector_send_cmd(id, VOICE_DET_CMD_VAD_START); + voice_detector_send_cmd(id, VOICE_DET_CMD_SYS_CLK_32K); + run = 1; + break; + case VOICE_DET_EVT_AUD_CAP_START: + voice_detector_send_cmd(id, VOICE_DET_CMD_SYS_CLK_26M); + voice_detector_send_cmd(id, VOICE_DET_CMD_AUD_CAP_OPEN); + voice_detector_send_cmd(id, VOICE_DET_CMD_AUD_CAP_START); + voice_detector_send_cmd(id, VOICE_DET_CMD_VAD_STOP); + voice_detector_send_cmd(id, VOICE_DET_CMD_VAD_CLOSE); + // voice_detector_send_cmd(id, VOICE_DET_CMD_AUD_CAP_OPEN); + // voice_detector_send_cmd(id, VOICE_DET_CMD_AUD_CAP_START); + run = 1; + break; + default: + run = 0; + break; + } + voice_det_evt = VOICE_DET_EVT_IDLE; + } + if (run) { + run = 0; + voice_detector_run(id, VOICE_DET_MODE_EXEC_CMD); } - - voice_detector_setup_stream(id, AUD_STREAM_CAPTURE, &stream_cfg); - voice_detector_setup_callback(id, VOICE_DET_CB_RUN_WAIT, cmd_wait_handler, NULL); - voice_detector_setup_callback(id, VOICE_DET_CB_RUN_DONE, cmd_done_handler, NULL); - voice_detector_setup_callback(id, VOICE_DET_FIND_APP, cpu_det_find_wakeup_handler, NULL); - voice_detector_setup_callback(id, VOICE_DET_NOT_FIND_APP, cpu_det_notfind_wakeup_handler, NULL); - - VD_TRACE(2,"%s, calc sys freq=%d", __func__, hal_sys_timer_calc_cpu_freq(5,0)); - - voice_detector_send_cmd(id, VOICE_DET_CMD_AUD_CAP_OPEN); - voice_detector_send_cmd(id, VOICE_DET_CMD_AUD_CAP_CLOSE); - voice_detector_send_evt(VOICE_DET_EVT_VAD_START); - run = 0; - - while (1) { - if (voice_det_evt != VOICE_DET_EVT_IDLE) { - switch(voice_det_evt) { - case VOICE_DET_EVT_VAD_START: - if (voice_detector_query_status(id) == VOICE_DET_STATE_VAD_CLOSE) { - voice_detector_send_cmd(id, VOICE_DET_CMD_AUD_CAP_STOP); - voice_detector_send_cmd(id, VOICE_DET_CMD_AUD_CAP_CLOSE); - } - //TODO: save current system clock - voice_detector_send_cmd(id, VOICE_DET_CMD_VAD_OPEN); - voice_detector_send_cmd(id, VOICE_DET_CMD_VAD_START); - voice_detector_send_cmd(id, VOICE_DET_CMD_SYS_CLK_32K); - run = 1; - break; - case VOICE_DET_EVT_AUD_CAP_START: - voice_detector_send_cmd(id, VOICE_DET_CMD_SYS_CLK_26M); - voice_detector_send_cmd(id, VOICE_DET_CMD_AUD_CAP_OPEN); - voice_detector_send_cmd(id, VOICE_DET_CMD_AUD_CAP_START); - voice_detector_send_cmd(id, VOICE_DET_CMD_VAD_STOP); - voice_detector_send_cmd(id, VOICE_DET_CMD_VAD_CLOSE); - //voice_detector_send_cmd(id, VOICE_DET_CMD_AUD_CAP_OPEN); - //voice_detector_send_cmd(id, VOICE_DET_CMD_AUD_CAP_START); - run = 1; - break; - default: - run = 0; - break; - } - voice_det_evt = VOICE_DET_EVT_IDLE; - } - if (run) { - run = 0; - voice_detector_run(id, VOICE_DET_MODE_EXEC_CMD); - } #ifndef RTOS - extern void af_thread(void const *argument); - af_thread(NULL); + extern void af_thread(void const *argument); + af_thread(NULL); #endif -// while(1); - sleep = hal_sleep_enter_sleep(); - if (sleep == HAL_SLEEP_STATUS_DEEP) { - VD_TRACE(0,"wake up from deep sleep"); - } - - len = voice_detector_recv_vad_data(VOICE_DETECTOR_ID_0, - vad_data_buf, sizeof(vad_data_buf)); - if (len) { - print_vad_raw_data(vad_data_buf, len); - } + // while(1); + sleep = hal_sleep_enter_sleep(); + if (sleep == HAL_SLEEP_STATUS_DEEP) { + VD_TRACE(0, "wake up from deep sleep"); } + + len = voice_detector_recv_vad_data(VOICE_DETECTOR_ID_0, vad_data_buf, + sizeof(vad_data_buf)); + if (len) { + print_vad_raw_data(vad_data_buf, len); + } + } } #endif diff --git a/config/_default_cfg_src_/app_status_ind.c b/config/_default_cfg_src_/app_status_ind.c index 8c278aa..6b6d2e2 100644 --- a/config/_default_cfg_src_/app_status_ind.c +++ b/config/_default_cfg_src_/app_status_ind.c @@ -13,18 +13,18 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "cmsis_os.h" -#include "stdbool.h" -#include "hal_trace.h" -#include "app_pwl.h" #include "app_status_ind.h" +#include "app_pwl.h" +#include "cmsis_os.h" +#include "hal_trace.h" +#include "stdbool.h" #include "string.h" static APP_STATUS_INDICATION_T app_status = APP_STATUS_INDICATION_NUM; -static APP_STATUS_INDICATION_T app_status_ind_filter = APP_STATUS_INDICATION_NUM; +static APP_STATUS_INDICATION_T app_status_ind_filter = + APP_STATUS_INDICATION_NUM; -const char *app_status_indication_str[] = -{ +const char *app_status_indication_str[] = { "[POWERON]", "[INITIAL]", "[PAGESCAN]", @@ -57,246 +57,236 @@ const char *app_status_indication_str[] = "[TESTMODE]", "[TESTMODE1]", "[RING_WARNING]", -#ifdef __INTERACTION__ +#ifdef __INTERACTION__ "[FINDME]", -#endif +#endif "[MY_BUDS_FIND]", "[TILE_FIND]", }; +const char *status2str(uint16_t status) { + const char *str = NULL; -const char *status2str(uint16_t status) -{ - const char *str = NULL; + if (status >= 0 && status < APP_STATUS_INDICATION_NUM) { + str = app_status_indication_str[status]; + } else { + str = "[UNKNOWN]"; + } - if (status >= 0 && status < APP_STATUS_INDICATION_NUM) - { - str = app_status_indication_str[status]; - } - else - { - str = "[UNKNOWN]"; - } - - return str; + return str; } -int app_status_indication_filter_set(APP_STATUS_INDICATION_T status) -{ - app_status_ind_filter = status; +int app_status_indication_filter_set(APP_STATUS_INDICATION_T status) { + app_status_ind_filter = status; + return 0; +} + +APP_STATUS_INDICATION_T app_status_indication_get(void) { return app_status; } + +int app_status_indication_set(APP_STATUS_INDICATION_T status) { + struct APP_PWL_CFG_T cfg0; + struct APP_PWL_CFG_T cfg1; + + if (app_status == status) return 0; -} -APP_STATUS_INDICATION_T app_status_indication_get(void) -{ - return app_status; -} - -int app_status_indication_set(APP_STATUS_INDICATION_T status) -{ - struct APP_PWL_CFG_T cfg0; - struct APP_PWL_CFG_T cfg1; - - if (app_status == status) - return 0; - - if (app_status_ind_filter == status) - return 0; - - TRACE(2,"%s %d",__func__, status); - - app_status = status; - memset(&cfg0, 0, sizeof(struct APP_PWL_CFG_T)); - memset(&cfg1, 0, sizeof(struct APP_PWL_CFG_T)); - app_pwl_stop(APP_PWL_ID_0); - app_pwl_stop(APP_PWL_ID_1); - switch (status) { - case APP_STATUS_INDICATION_POWERON: - cfg0.part[0].level = 1; - cfg0.part[0].time = (3000); - cfg0.part[1].level = 0; - cfg0.part[1].time = (200); - cfg0.parttotal = 2; - cfg0.startlevel = 1; - cfg0.periodic = false; - - app_pwl_setup(APP_PWL_ID_0, &cfg0); - app_pwl_start(APP_PWL_ID_0); - - break; - case APP_STATUS_INDICATION_INITIAL: - break; - case APP_STATUS_INDICATION_PAGESCAN: - cfg0.part[0].level = 1; - cfg0.part[0].time = (300); - cfg0.part[1].level = 0; - cfg0.part[1].time = (8000); - cfg0.parttotal = 2; - cfg0.startlevel = 1; - cfg0.periodic = true; - app_pwl_setup(APP_PWL_ID_0, &cfg0); - app_pwl_start(APP_PWL_ID_0); - break; - case APP_STATUS_INDICATION_BOTHSCAN: - cfg0.part[0].level = 0; - cfg0.part[0].time = (300); - cfg0.part[1].level = 1; - cfg0.part[1].time = (300); - cfg0.parttotal = 2; - cfg0.startlevel = 0; - cfg0.periodic = true; - - cfg1.part[0].level = 1; - cfg1.part[0].time = (300); - cfg1.part[1].level = 0; - cfg1.part[1].time = (300); - cfg1.parttotal = 2; - cfg1.startlevel = 1; - cfg1.periodic = true; - - app_pwl_setup(APP_PWL_ID_0, &cfg0); - app_pwl_start(APP_PWL_ID_0); - app_pwl_setup(APP_PWL_ID_1, &cfg1); - app_pwl_start(APP_PWL_ID_1); - break; - case APP_STATUS_INDICATION_CONNECTING: - // LED's alternating Red/Blue - cfg0.part[0].level = 1; - cfg0.part[0].time = (300); - cfg0.part[1].level = 0; - cfg0.part[1].time = (300); - cfg0.parttotal = 2; - cfg0.startlevel = 0; - cfg0.periodic = true; - - cfg1.part[0].level = 1; - cfg1.part[0].time = (300); - cfg1.part[1].level = 0; - cfg1.part[1].time = (300); - cfg1.parttotal = 2; - cfg1.startlevel = 1; - cfg1.periodic = true; - - app_pwl_setup(APP_PWL_ID_0, &cfg0); - app_pwl_start(APP_PWL_ID_0); - app_pwl_setup(APP_PWL_ID_1, &cfg1); - app_pwl_start(APP_PWL_ID_1); - break; - case APP_STATUS_INDICATION_CONNECTED: - cfg0.part[0].level = 1; - cfg0.part[0].time = (500); - cfg0.part[1].level = 0; - cfg0.part[1].time = (3000); - cfg0.parttotal = 2; - cfg0.startlevel = 1; - cfg0.periodic = true; - - cfg1.part[0].level = 0; - cfg1.part[0].time = (500); - cfg1.part[1].level = 0; - cfg1.part[1].time = (3000); - cfg1.parttotal = 2; - cfg1.startlevel = 0; - cfg1.periodic = true; - app_pwl_setup(APP_PWL_ID_0, &cfg0); - app_pwl_start(APP_PWL_ID_0); - app_pwl_setup(APP_PWL_ID_1, &cfg1); - app_pwl_start(APP_PWL_ID_1); - break; - case APP_STATUS_INDICATION_CHARGING: - cfg1.part[0].level = 1; - cfg1.part[0].time = (5000); - cfg1.parttotal = 1; - cfg1.startlevel = 1; - cfg1.periodic = true; - app_pwl_setup(APP_PWL_ID_1, &cfg1); - app_pwl_start(APP_PWL_ID_1); - break; - case APP_STATUS_INDICATION_FULLCHARGE: - cfg0.part[0].level = 0; - cfg0.part[0].time = (5000); - cfg0.parttotal = 1; - cfg0.startlevel = 1; - cfg0.periodic = false; - app_pwl_setup(APP_PWL_ID_0, &cfg0); - app_pwl_start(APP_PWL_ID_0); - app_pwl_setup(APP_PWL_ID_1, &cfg0); - app_pwl_start(APP_PWL_ID_1); - break; - case APP_STATUS_INDICATION_POWEROFF: - cfg1.part[0].level = 0; - cfg1.part[0].time = (100); - cfg1.parttotal = 1; - cfg1.startlevel = 1; - cfg1.periodic = false; - cfg0.part[0].level = 0; - cfg0.part[0].time = (100); - cfg0.parttotal = 1; - cfg0.startlevel = 1; - cfg0.periodic = false; - - app_pwl_setup(APP_PWL_ID_1, &cfg1); - app_pwl_start(APP_PWL_ID_1); - app_pwl_setup(APP_PWL_ID_0, &cfg0); - app_pwl_start(APP_PWL_ID_0); - break; - case APP_STATUS_INDICATION_CHARGENEED: - cfg1.part[0].level = 1; - cfg1.part[0].time = (500); - cfg1.part[1].level = 0; - cfg1.part[1].time = (2000); - cfg1.parttotal = 2; - cfg1.startlevel = 1; - cfg1.periodic = true; - app_pwl_setup(APP_PWL_ID_1, &cfg1); - app_pwl_start(APP_PWL_ID_1); - break; - case APP_STATUS_INDICATION_TESTMODE: - cfg0.part[0].level = 0; - cfg0.part[0].time = (300); - cfg0.part[1].level = 1; - cfg0.part[1].time = (300); - cfg0.parttotal = 2; - cfg0.startlevel = 0; - cfg0.periodic = true; - - cfg1.part[0].level = 0; - cfg1.part[0].time = (300); - cfg1.part[1].level = 1; - cfg1.part[1].time = (300); - cfg1.parttotal = 2; - cfg1.startlevel = 1; - cfg1.periodic = true; - - app_pwl_setup(APP_PWL_ID_0, &cfg0); - app_pwl_start(APP_PWL_ID_0); - app_pwl_setup(APP_PWL_ID_1, &cfg1); - app_pwl_start(APP_PWL_ID_1); - break; - case APP_STATUS_INDICATION_TESTMODE1: - cfg0.part[0].level = 0; - cfg0.part[0].time = (1000); - cfg0.part[1].level = 1; - cfg0.part[1].time = (1000); - cfg0.parttotal = 2; - cfg0.startlevel = 0; - cfg0.periodic = true; - - cfg1.part[0].level = 0; - cfg1.part[0].time = (1000); - cfg1.part[1].level = 1; - cfg1.part[1].time = (1000); - cfg1.parttotal = 2; - cfg1.startlevel = 1; - cfg1.periodic = true; - - app_pwl_setup(APP_PWL_ID_0, &cfg0); - app_pwl_start(APP_PWL_ID_0); - app_pwl_setup(APP_PWL_ID_1, &cfg1); - app_pwl_start(APP_PWL_ID_1); - break; - default: - break; - } + if (app_status_ind_filter == status) return 0; + + TRACE(2, "%s %d", __func__, status); + + app_status = status; + memset(&cfg0, 0, sizeof(struct APP_PWL_CFG_T)); + memset(&cfg1, 0, sizeof(struct APP_PWL_CFG_T)); + app_pwl_stop(APP_PWL_ID_0); + app_pwl_stop(APP_PWL_ID_1); + switch (status) { + case APP_STATUS_INDICATION_POWERON: + cfg0.part[0].level = 1; + cfg0.part[0].time = (3000); + cfg0.part[1].level = 0; + cfg0.part[1].time = (200); + cfg0.parttotal = 2; + cfg0.startlevel = 1; + cfg0.periodic = false; + + app_pwl_setup(APP_PWL_ID_0, &cfg0); + app_pwl_start(APP_PWL_ID_0); + + break; + case APP_STATUS_INDICATION_INITIAL: + break; + case APP_STATUS_INDICATION_PAGESCAN: + cfg0.part[0].level = 1; + cfg0.part[0].time = (300); + cfg0.part[1].level = 0; + cfg0.part[1].time = (8000); + cfg0.parttotal = 2; + cfg0.startlevel = 1; + cfg0.periodic = true; + app_pwl_setup(APP_PWL_ID_0, &cfg0); + app_pwl_start(APP_PWL_ID_0); + break; + case APP_STATUS_INDICATION_BOTHSCAN: + cfg0.part[0].level = 0; + cfg0.part[0].time = (300); + cfg0.part[1].level = 1; + cfg0.part[1].time = (300); + cfg0.parttotal = 2; + cfg0.startlevel = 0; + cfg0.periodic = true; + + cfg1.part[0].level = 1; + cfg1.part[0].time = (300); + cfg1.part[1].level = 0; + cfg1.part[1].time = (300); + cfg1.parttotal = 2; + cfg1.startlevel = 1; + cfg1.periodic = true; + + app_pwl_setup(APP_PWL_ID_0, &cfg0); + app_pwl_start(APP_PWL_ID_0); + app_pwl_setup(APP_PWL_ID_1, &cfg1); + app_pwl_start(APP_PWL_ID_1); + break; + case APP_STATUS_INDICATION_CONNECTING: + // LED's alternating Red/Blue + cfg0.part[0].level = 1; + cfg0.part[0].time = (300); + cfg0.part[1].level = 0; + cfg0.part[1].time = (300); + cfg0.parttotal = 2; + cfg0.startlevel = 0; + cfg0.periodic = true; + + cfg1.part[0].level = 1; + cfg1.part[0].time = (300); + cfg1.part[1].level = 0; + cfg1.part[1].time = (300); + cfg1.parttotal = 2; + cfg1.startlevel = 1; + cfg1.periodic = true; + + app_pwl_setup(APP_PWL_ID_0, &cfg0); + app_pwl_start(APP_PWL_ID_0); + app_pwl_setup(APP_PWL_ID_1, &cfg1); + app_pwl_start(APP_PWL_ID_1); + break; + case APP_STATUS_INDICATION_CONNECTED: + cfg0.part[0].level = 1; + cfg0.part[0].time = (500); + cfg0.part[1].level = 0; + cfg0.part[1].time = (3000); + cfg0.parttotal = 2; + cfg0.startlevel = 1; + cfg0.periodic = true; + + cfg1.part[0].level = 0; + cfg1.part[0].time = (500); + cfg1.part[1].level = 0; + cfg1.part[1].time = (3000); + cfg1.parttotal = 2; + cfg1.startlevel = 0; + cfg1.periodic = true; + app_pwl_setup(APP_PWL_ID_0, &cfg0); + app_pwl_start(APP_PWL_ID_0); + app_pwl_setup(APP_PWL_ID_1, &cfg1); + app_pwl_start(APP_PWL_ID_1); + break; + case APP_STATUS_INDICATION_CHARGING: + cfg1.part[0].level = 1; + cfg1.part[0].time = (5000); + cfg1.parttotal = 1; + cfg1.startlevel = 1; + cfg1.periodic = true; + app_pwl_setup(APP_PWL_ID_1, &cfg1); + app_pwl_start(APP_PWL_ID_1); + break; + case APP_STATUS_INDICATION_FULLCHARGE: + cfg0.part[0].level = 0; + cfg0.part[0].time = (5000); + cfg0.parttotal = 1; + cfg0.startlevel = 1; + cfg0.periodic = false; + app_pwl_setup(APP_PWL_ID_0, &cfg0); + app_pwl_start(APP_PWL_ID_0); + app_pwl_setup(APP_PWL_ID_1, &cfg0); + app_pwl_start(APP_PWL_ID_1); + break; + case APP_STATUS_INDICATION_POWEROFF: + cfg1.part[0].level = 0; + cfg1.part[0].time = (100); + cfg1.parttotal = 1; + cfg1.startlevel = 1; + cfg1.periodic = false; + cfg0.part[0].level = 0; + cfg0.part[0].time = (100); + cfg0.parttotal = 1; + cfg0.startlevel = 1; + cfg0.periodic = false; + + app_pwl_setup(APP_PWL_ID_1, &cfg1); + app_pwl_start(APP_PWL_ID_1); + app_pwl_setup(APP_PWL_ID_0, &cfg0); + app_pwl_start(APP_PWL_ID_0); + break; + case APP_STATUS_INDICATION_CHARGENEED: + cfg1.part[0].level = 1; + cfg1.part[0].time = (500); + cfg1.part[1].level = 0; + cfg1.part[1].time = (2000); + cfg1.parttotal = 2; + cfg1.startlevel = 1; + cfg1.periodic = true; + app_pwl_setup(APP_PWL_ID_1, &cfg1); + app_pwl_start(APP_PWL_ID_1); + break; + case APP_STATUS_INDICATION_TESTMODE: + cfg0.part[0].level = 0; + cfg0.part[0].time = (300); + cfg0.part[1].level = 1; + cfg0.part[1].time = (300); + cfg0.parttotal = 2; + cfg0.startlevel = 0; + cfg0.periodic = true; + + cfg1.part[0].level = 0; + cfg1.part[0].time = (300); + cfg1.part[1].level = 1; + cfg1.part[1].time = (300); + cfg1.parttotal = 2; + cfg1.startlevel = 1; + cfg1.periodic = true; + + app_pwl_setup(APP_PWL_ID_0, &cfg0); + app_pwl_start(APP_PWL_ID_0); + app_pwl_setup(APP_PWL_ID_1, &cfg1); + app_pwl_start(APP_PWL_ID_1); + break; + case APP_STATUS_INDICATION_TESTMODE1: + cfg0.part[0].level = 0; + cfg0.part[0].time = (1000); + cfg0.part[1].level = 1; + cfg0.part[1].time = (1000); + cfg0.parttotal = 2; + cfg0.startlevel = 0; + cfg0.periodic = true; + + cfg1.part[0].level = 0; + cfg1.part[0].time = (1000); + cfg1.part[1].level = 1; + cfg1.part[1].time = (1000); + cfg1.parttotal = 2; + cfg1.startlevel = 1; + cfg1.periodic = true; + + app_pwl_setup(APP_PWL_ID_0, &cfg0); + app_pwl_start(APP_PWL_ID_0); + app_pwl_setup(APP_PWL_ID_1, &cfg1); + app_pwl_start(APP_PWL_ID_1); + break; + default: + break; + } + return 0; } diff --git a/config/_default_cfg_src_/tgt_hardware.c b/config/_default_cfg_src_/tgt_hardware.c index d5419d1..bb17ebd 100644 --- a/config/_default_cfg_src_/tgt_hardware.c +++ b/config/_default_cfg_src_/tgt_hardware.c @@ -15,85 +15,88 @@ ****************************************************************************/ #include "tgt_hardware.h" -const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_pinmux_pwl[CFG_HW_PLW_NUM] = { -}; +const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_pinmux_pwl[CFG_HW_PLW_NUM] = {}; -//adckey define +// adckey define const uint16_t CFG_HW_ADCKEY_MAP_TABLE[CFG_HW_ADCKEY_NUMBER] = { - HAL_KEY_CODE_FN9,HAL_KEY_CODE_FN8,HAL_KEY_CODE_FN7, - HAL_KEY_CODE_FN6,HAL_KEY_CODE_FN5,HAL_KEY_CODE_FN4, - HAL_KEY_CODE_FN3,HAL_KEY_CODE_FN2,HAL_KEY_CODE_FN1 -}; + HAL_KEY_CODE_FN9, HAL_KEY_CODE_FN8, HAL_KEY_CODE_FN7, + HAL_KEY_CODE_FN6, HAL_KEY_CODE_FN5, HAL_KEY_CODE_FN4, + HAL_KEY_CODE_FN3, HAL_KEY_CODE_FN2, HAL_KEY_CODE_FN1}; -//gpiokey define -const struct HAL_KEY_GPIOKEY_CFG_T cfg_hw_gpio_key_cfg[CFG_HW_GPIOKEY_NUM] = { -}; +// gpiokey define +const struct HAL_KEY_GPIOKEY_CFG_T cfg_hw_gpio_key_cfg[CFG_HW_GPIOKEY_NUM] = {}; -//bt config +// bt config const char *BT_LOCAL_NAME = TO_STRING(BT_DEV_NAME) "\0"; const char *BLE_DEFAULT_NAME = "BES_BLE"; uint8_t ble_addr[6] = { #ifdef BLE_DEV_ADDR - BLE_DEV_ADDR + BLE_DEV_ADDR #else - 0xBE,0x99,0x34,0x45,0x56,0x67 + 0xBE, 0x99, 0x34, 0x45, + 0x56, 0x67 #endif }; uint8_t bt_addr[6] = { #ifdef BT_DEV_ADDR - BT_DEV_ADDR + BT_DEV_ADDR #else - 0x1e,0x57,0x34,0x45,0x56,0x67 + 0x1e, 0x57, 0x34, 0x45, + 0x56, 0x67 #endif }; -//audio config -//freq bands range {[0k:2.5K], [2.5k:5K], [5k:7.5K], [7.5K:10K], [10K:12.5K], [12.5K:15K], [15K:17.5K], [17.5K:20K]} -//gain range -12~+12 -const int8_t cfg_hw_aud_eq_band_settings[CFG_HW_AUD_EQ_NUM_BANDS] = {0, 0, 0, 0, 0, 0, 0, 0}; +// audio config +// freq bands range {[0k:2.5K], [2.5k:5K], [5k:7.5K], [7.5K:10K], [10K:12.5K], +// [12.5K:15K], [15K:17.5K], [17.5K:20K]} gain range -12~+12 +const int8_t cfg_hw_aud_eq_band_settings[CFG_HW_AUD_EQ_NUM_BANDS] = { + 0, 0, 0, 0, 0, 0, 0, 0}; -#define TX_PA_GAIN CODEC_TX_PA_GAIN_DEFAULT +#define TX_PA_GAIN CODEC_TX_PA_GAIN_DEFAULT const struct CODEC_DAC_VOL_T codec_dac_vol[TGT_VOLUME_LEVEL_QTY] = { - {TX_PA_GAIN,0x03,-11}, - {TX_PA_GAIN,0x03,-99}, - {TX_PA_GAIN,0x03,-45}, - {TX_PA_GAIN,0x03,-42}, - {TX_PA_GAIN,0x03,-39}, - {TX_PA_GAIN,0x03,-36}, - {TX_PA_GAIN,0x03,-33}, - {TX_PA_GAIN,0x03,-30}, - {TX_PA_GAIN,0x03,-27}, - {TX_PA_GAIN,0x03,-24}, - {TX_PA_GAIN,0x03,-21}, - {TX_PA_GAIN,0x03,-18}, - {TX_PA_GAIN,0x03,-15}, - {TX_PA_GAIN,0x03,-12}, - {TX_PA_GAIN,0x03, -9}, - {TX_PA_GAIN,0x03, -6}, - {TX_PA_GAIN,0x03, -3}, - {TX_PA_GAIN,0x03, 0}, //0dBm + {TX_PA_GAIN, 0x03, -11}, {TX_PA_GAIN, 0x03, -99}, + {TX_PA_GAIN, 0x03, -45}, {TX_PA_GAIN, 0x03, -42}, + {TX_PA_GAIN, 0x03, -39}, {TX_PA_GAIN, 0x03, -36}, + {TX_PA_GAIN, 0x03, -33}, {TX_PA_GAIN, 0x03, -30}, + {TX_PA_GAIN, 0x03, -27}, {TX_PA_GAIN, 0x03, -24}, + {TX_PA_GAIN, 0x03, -21}, {TX_PA_GAIN, 0x03, -18}, + {TX_PA_GAIN, 0x03, -15}, {TX_PA_GAIN, 0x03, -12}, + {TX_PA_GAIN, 0x03, -9}, {TX_PA_GAIN, 0x03, -6}, + {TX_PA_GAIN, 0x03, -3}, {TX_PA_GAIN, 0x03, 0}, // 0dBm }; -#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (AUD_CHANNEL_MAP_CH0 | AUD_VMIC_MAP_VMIC1) -#define CFG_HW_AUD_INPUT_PATH_LINEIN_DEV (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1) -#define CFG_HW_AUD_INPUT_PATH_VADMIC_DEV (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC1) -const struct AUD_IO_PATH_CFG_T cfg_audio_input_path_cfg[CFG_HW_AUD_INPUT_PATH_NUM] = { - { AUD_INPUT_PATH_MAINMIC, CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV, }, - { AUD_INPUT_PATH_LINEIN, CFG_HW_AUD_INPUT_PATH_LINEIN_DEV, }, - { AUD_INPUT_PATH_VADMIC, CFG_HW_AUD_INPUT_PATH_VADMIC_DEV, }, +#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_VMIC_MAP_VMIC1) +#define CFG_HW_AUD_INPUT_PATH_LINEIN_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1) +#define CFG_HW_AUD_INPUT_PATH_VADMIC_DEV \ + (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC1) +const struct AUD_IO_PATH_CFG_T + cfg_audio_input_path_cfg[CFG_HW_AUD_INPUT_PATH_NUM] = { + { + AUD_INPUT_PATH_MAINMIC, + CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV, + }, + { + AUD_INPUT_PATH_LINEIN, + CFG_HW_AUD_INPUT_PATH_LINEIN_DEV, + }, + { + AUD_INPUT_PATH_VADMIC, + CFG_HW_AUD_INPUT_PATH_VADMIC_DEV, + }, }; const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_enable_cfg = { - HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; + HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_detecter_cfg = { - HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; - -const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_indicator_cfg = { - HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; + HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; +const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_indicator_cfg = + {HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; diff --git a/config/bak_open/tgt_hardware.c b/config/bak_open/tgt_hardware.c index 74deb4f..1306c4a 100644 --- a/config/bak_open/tgt_hardware.c +++ b/config/bak_open/tgt_hardware.c @@ -14,301 +14,317 @@ * ****************************************************************************/ #include "tgt_hardware.h" -#include "iir_process.h" -#include "fir_process.h" #include "drc.h" +#include "fir_process.h" +#include "iir_process.h" #include "limiter.h" #include "spectrum_fix.h" const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_pinmux_pwl[CFG_HW_PLW_NUM] = { #if (CFG_HW_PLW_NUM > 0) - {HAL_IOMUX_PIN_LED2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_LED1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_LED2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_LED1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}, #endif }; #ifdef __APP_USE_LED_INDICATE_IBRT_STATUS__ const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_ibrt_indication_pinmux_pwl[3] = { - {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_LED1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VBAT, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_LED2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VBAT, HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_LED1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VBAT, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_LED2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VBAT, + HAL_IOMUX_PIN_PULLUP_ENABLE}, }; #endif #ifdef __KNOWLES const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_pinmux_uart[2] = { - {HAL_IOMUX_PIN_P2_2, HAL_IOMUX_FUNC_UART2_RX, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P2_3, HAL_IOMUX_FUNC_UART2_TX, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P2_2, HAL_IOMUX_FUNC_UART2_RX, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P2_3, HAL_IOMUX_FUNC_UART2_TX, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_NOPULL}, }; #endif -//adckey define +// adckey define const uint16_t CFG_HW_ADCKEY_MAP_TABLE[CFG_HW_ADCKEY_NUMBER] = { #if (CFG_HW_ADCKEY_NUMBER > 0) - HAL_KEY_CODE_FN9,HAL_KEY_CODE_FN8,HAL_KEY_CODE_FN7, - HAL_KEY_CODE_FN6,HAL_KEY_CODE_FN5,HAL_KEY_CODE_FN4, - HAL_KEY_CODE_FN3,HAL_KEY_CODE_FN2,HAL_KEY_CODE_FN1, + HAL_KEY_CODE_FN9, HAL_KEY_CODE_FN8, HAL_KEY_CODE_FN7, + HAL_KEY_CODE_FN6, HAL_KEY_CODE_FN5, HAL_KEY_CODE_FN4, + HAL_KEY_CODE_FN3, HAL_KEY_CODE_FN2, HAL_KEY_CODE_FN1, #endif }; -//gpiokey define -#define CFG_HW_GPIOKEY_DOWN_LEVEL (0) -#define CFG_HW_GPIOKEY_UP_LEVEL (1) +// gpiokey define +#define CFG_HW_GPIOKEY_DOWN_LEVEL (0) +#define CFG_HW_GPIOKEY_UP_LEVEL (1) const struct HAL_KEY_GPIOKEY_CFG_T cfg_hw_gpio_key_cfg[CFG_HW_GPIOKEY_NUM] = { -/* -#if (CFG_HW_GPIOKEY_NUM > 0) -#ifdef BES_AUDIO_DEV_Main_Board_9v0 - {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P0_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P0_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN4,{HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - //{HAL_KEY_CODE_FN5,{HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - // {HAL_KEY_CODE_FN6,{HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, -#else -#ifndef TPORTS_KEY_COEXIST - {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - // {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, -#else - {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, -#endif -#endif -#ifdef IS_MULTI_AI_ENABLED - //{HAL_KEY_CODE_FN13,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - //{HAL_KEY_CODE_FN14,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, -#endif -#endif -*/ - {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + /* + #if (CFG_HW_GPIOKEY_NUM > 0) + #ifdef BES_AUDIO_DEV_Main_Board_9v0 + {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P0_0, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P0_1, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN4,{HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + //{HAL_KEY_CODE_FN5,{HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + // {HAL_KEY_CODE_FN6,{HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, #else #ifndef + TPORTS_KEY_COEXIST {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, + HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, {HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P1_0, + HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, + // {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, #else + {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, #endif #endif + #ifdef IS_MULTI_AI_ENABLED + //{HAL_KEY_CODE_FN13,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + //{HAL_KEY_CODE_FN14,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, #endif #endif + */ + {HAL_KEY_CODE_FN1, + {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, }; -//bt config -//const char *BT_LOCAL_NAME = TO_STRING(BT_DEV_NAME) "\0"; +// bt config +// const char *BT_LOCAL_NAME = TO_STRING(BT_DEV_NAME) "\0"; const char *BT_LOCAL_NAME = "PineBuds Pro"; const char *BLE_DEFAULT_NAME = "BES_BLE"; uint8_t ble_addr[6] = { #ifdef BLE_DEV_ADDR - BLE_DEV_ADDR + BLE_DEV_ADDR #else - 0xBE,0x99,0x34,0x45,0x56,0x67 + 0xBE, 0x99, 0x34, 0x45, + 0x56, 0x67 #endif }; uint8_t bt_addr[6] = { #ifdef BT_DEV_ADDR - BT_DEV_ADDR + BT_DEV_ADDR #else - 0x1e,0x57,0x34,0x45,0x56,0x67 + 0x1e, 0x57, 0x34, 0x45, + 0x56, 0x67 #endif }; -//audio config -//freq bands range {[0k:2.5K], [2.5k:5K], [5k:7.5K], [7.5K:10K], [10K:12.5K], [12.5K:15K], [15K:17.5K], [17.5K:20K]} -//gain range -12~+12 -const int8_t cfg_aud_eq_sbc_band_settings[CFG_HW_AUD_EQ_NUM_BANDS] = {0, 0, 0, 0, 0, 0, 0, 0}; +// audio config +// freq bands range {[0k:2.5K], [2.5k:5K], [5k:7.5K], [7.5K:10K], [10K:12.5K], +// [12.5K:15K], [15K:17.5K], [17.5K:20K]} gain range -12~+12 +const int8_t cfg_aud_eq_sbc_band_settings[CFG_HW_AUD_EQ_NUM_BANDS] = { + 0, 0, 0, 0, 0, 0, 0, 0}; -#define TX_PA_GAIN CODEC_TX_PA_GAIN_DEFAULT +#define TX_PA_GAIN CODEC_TX_PA_GAIN_DEFAULT const struct CODEC_DAC_VOL_T codec_dac_vol[TGT_VOLUME_LEVEL_QTY] = { - {TX_PA_GAIN,0x03,-21}, - {TX_PA_GAIN,0x03,-99}, - {TX_PA_GAIN,0x03,-45}, - {TX_PA_GAIN,0x03,-42}, - {TX_PA_GAIN,0x03,-39}, - {TX_PA_GAIN,0x03,-36}, - {TX_PA_GAIN,0x03,-33}, - {TX_PA_GAIN,0x03,-30}, - {TX_PA_GAIN,0x03,-27}, - {TX_PA_GAIN,0x03,-24}, - {TX_PA_GAIN,0x03,-21}, - {TX_PA_GAIN,0x03,-18}, - {TX_PA_GAIN,0x03,-15}, - {TX_PA_GAIN,0x03,-12}, - {TX_PA_GAIN,0x03, -9}, - {TX_PA_GAIN,0x03, -6}, - {TX_PA_GAIN,0x03, -3}, - {TX_PA_GAIN,0x03, 0}, //0dBm + {TX_PA_GAIN, 0x03, -21}, {TX_PA_GAIN, 0x03, -99}, + {TX_PA_GAIN, 0x03, -45}, {TX_PA_GAIN, 0x03, -42}, + {TX_PA_GAIN, 0x03, -39}, {TX_PA_GAIN, 0x03, -36}, + {TX_PA_GAIN, 0x03, -33}, {TX_PA_GAIN, 0x03, -30}, + {TX_PA_GAIN, 0x03, -27}, {TX_PA_GAIN, 0x03, -24}, + {TX_PA_GAIN, 0x03, -21}, {TX_PA_GAIN, 0x03, -18}, + {TX_PA_GAIN, 0x03, -15}, {TX_PA_GAIN, 0x03, -12}, + {TX_PA_GAIN, 0x03, -9}, {TX_PA_GAIN, 0x03, -6}, + {TX_PA_GAIN, 0x03, -3}, {TX_PA_GAIN, 0x03, 0}, // 0dBm }; #if SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 2 -#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC2|AUD_VMIC_MAP_VMIC3) +#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC2 | \ + AUD_VMIC_MAP_VMIC3) #elif SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 3 -#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1 | AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC1) +#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1 | AUD_CHANNEL_MAP_CH4 | \ + AUD_VMIC_MAP_VMIC1) #else -#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC3) +#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV \ + (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC3) #endif -#define CFG_HW_AUD_INPUT_PATH_LINEIN_DEV (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1) +#define CFG_HW_AUD_INPUT_PATH_LINEIN_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1) #ifdef VOICE_DETECTOR_EN -#define CFG_HW_AUD_INPUT_PATH_VADMIC_DEV (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC1) +#define CFG_HW_AUD_INPUT_PATH_VADMIC_DEV \ + (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC1) #else -#define CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC3) +#define CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV \ + (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC3) #endif -const struct AUD_IO_PATH_CFG_T cfg_audio_input_path_cfg[CFG_HW_AUD_INPUT_PATH_NUM] = { +const struct AUD_IO_PATH_CFG_T + cfg_audio_input_path_cfg[CFG_HW_AUD_INPUT_PATH_NUM] = { #if defined(SPEECH_TX_AEC_CODEC_REF) - // NOTE: If enable Ch5 and CH6, need to add channel_num when setup audioflinger stream - { AUD_INPUT_PATH_MAINMIC, CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV | AUD_CHANNEL_MAP_CH4, }, + // NOTE: If enable Ch5 and CH6, need to add channel_num when setup + // audioflinger stream + { + AUD_INPUT_PATH_MAINMIC, + CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV | AUD_CHANNEL_MAP_CH4, + }, #else - { AUD_INPUT_PATH_MAINMIC, CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV, }, + { + AUD_INPUT_PATH_MAINMIC, + CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV, + }, #endif - { AUD_INPUT_PATH_LINEIN, CFG_HW_AUD_INPUT_PATH_LINEIN_DEV, }, + { + AUD_INPUT_PATH_LINEIN, + CFG_HW_AUD_INPUT_PATH_LINEIN_DEV, + }, #ifdef VOICE_DETECTOR_EN - { AUD_INPUT_PATH_VADMIC, CFG_HW_AUD_INPUT_PATH_VADMIC_DEV, }, + { + AUD_INPUT_PATH_VADMIC, + CFG_HW_AUD_INPUT_PATH_VADMIC_DEV, + }, #else - { AUD_INPUT_PATH_ASRMIC, CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV, }, + { + AUD_INPUT_PATH_ASRMIC, + CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV, + }, #endif }; const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_enable_cfg = { - HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; + HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_detecter_cfg = { - HAL_IOMUX_PIN_P1_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; - -const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_indicator_cfg = { - HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; + HAL_IOMUX_PIN_P1_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; +const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_indicator_cfg = + {HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; /* const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_INT ={ - HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE + HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, +HAL_IOMUX_PIN_PULLUP_ENABLE }; */ -const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SDA ={ - HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; - -const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SCL ={ - HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; +const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SDA = { + HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; +const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SCL = { + HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; const IIR_CFG_T audio_eq_sw_iir_cfg = { .gain0 = 0, .gain1 = 0, .num = 5, - .param = { - {IIR_TYPE_PEAK, .0, 200, 2}, - {IIR_TYPE_PEAK, .0, 600, 2}, - {IIR_TYPE_PEAK, .0, 2000.0, 2}, - {IIR_TYPE_PEAK, .0, 6000.0, 2}, - {IIR_TYPE_PEAK, .0, 12000.0, 2} - } -}; + .param = {{IIR_TYPE_PEAK, .0, 200, 2}, + {IIR_TYPE_PEAK, .0, 600, 2}, + {IIR_TYPE_PEAK, .0, 2000.0, 2}, + {IIR_TYPE_PEAK, .0, 6000.0, 2}, + {IIR_TYPE_PEAK, .0, 12000.0, 2}}}; -const IIR_CFG_T * const audio_eq_sw_iir_cfg_list[EQ_SW_IIR_LIST_NUM]={ +const IIR_CFG_T *const audio_eq_sw_iir_cfg_list[EQ_SW_IIR_LIST_NUM] = { &audio_eq_sw_iir_cfg, }; -const FIR_CFG_T audio_eq_hw_fir_cfg_44p1k = { - .gain = 0.0f, - .len = 384, - .coef = - { - (1<<23)-1, - } -}; +const FIR_CFG_T audio_eq_hw_fir_cfg_44p1k = {.gain = 0.0f, + .len = 384, + .coef = { + (1 << 23) - 1, + }}; -const FIR_CFG_T audio_eq_hw_fir_cfg_48k = { - .gain = 0.0f, - .len = 384, - .coef = - { - (1<<23)-1, - } -}; +const FIR_CFG_T audio_eq_hw_fir_cfg_48k = {.gain = 0.0f, + .len = 384, + .coef = { + (1 << 23) - 1, + }}; +const FIR_CFG_T audio_eq_hw_fir_cfg_96k = {.gain = 0.0f, + .len = 384, + .coef = { + (1 << 23) - 1, + }}; -const FIR_CFG_T audio_eq_hw_fir_cfg_96k = { - .gain = 0.0f, - .len = 384, - .coef = - { - (1<<23)-1, - } -}; - -const FIR_CFG_T * const audio_eq_hw_fir_cfg_list[EQ_HW_FIR_LIST_NUM]={ +const FIR_CFG_T *const audio_eq_hw_fir_cfg_list[EQ_HW_FIR_LIST_NUM] = { &audio_eq_hw_fir_cfg_44p1k, &audio_eq_hw_fir_cfg_48k, - &audio_eq_hw_fir_cfg_96k, + &audio_eq_hw_fir_cfg_96k, }; -//hardware dac iir eq -const IIR_CFG_T audio_eq_hw_dac_iir_cfg = { - .gain0 = 0, - .gain1 = 0, - .num = 8, - .param = { - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - } +// hardware dac iir eq +const IIR_CFG_T audio_eq_hw_dac_iir_cfg = {.gain0 = 0, + .gain1 = 0, + .num = 8, + .param = { + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + }}; + +const IIR_CFG_T *const POSSIBLY_UNUSED + audio_eq_hw_dac_iir_cfg_list[EQ_HW_DAC_IIR_LIST_NUM] = { + &audio_eq_hw_dac_iir_cfg, }; -const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_dac_iir_cfg_list[EQ_HW_DAC_IIR_LIST_NUM]={ - &audio_eq_hw_dac_iir_cfg, -}; - -//hardware dac iir eq +// hardware dac iir eq const IIR_CFG_T audio_eq_hw_adc_iir_adc_cfg = { .gain0 = 0, .gain1 = 0, .num = 1, .param = { - {IIR_TYPE_PEAK, 0.0, 1000.0, 0.7}, - } + {IIR_TYPE_PEAK, 0.0, 1000.0, 0.7}, + }}; + +const IIR_CFG_T *const POSSIBLY_UNUSED + audio_eq_hw_adc_iir_cfg_list[EQ_HW_ADC_IIR_LIST_NUM] = { + &audio_eq_hw_adc_iir_adc_cfg, }; -const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_adc_iir_cfg_list[EQ_HW_ADC_IIR_LIST_NUM]={ - &audio_eq_hw_adc_iir_adc_cfg, +// hardware iir eq +const IIR_CFG_T audio_eq_hw_iir_cfg = {.gain0 = 0, + .gain1 = 0, + .num = 8, + .param = { + {IIR_TYPE_PEAK, -10.1, 100.0, 7}, + {IIR_TYPE_PEAK, -10.1, 400.0, 7}, + {IIR_TYPE_PEAK, -10.1, 700.0, 7}, + {IIR_TYPE_PEAK, -10.1, 1000.0, 7}, + {IIR_TYPE_PEAK, -10.1, 3000.0, 7}, + {IIR_TYPE_PEAK, -10.1, 5000.0, 7}, + {IIR_TYPE_PEAK, -10.1, 7000.0, 7}, + {IIR_TYPE_PEAK, -10.1, 9000.0, 7}, + + }}; + +const IIR_CFG_T *const POSSIBLY_UNUSED + audio_eq_hw_iir_cfg_list[EQ_HW_IIR_LIST_NUM] = { + &audio_eq_hw_iir_cfg, }; - - -//hardware iir eq -const IIR_CFG_T audio_eq_hw_iir_cfg = { - .gain0 = 0, - .gain1 = 0, - .num = 8, - .param = { - {IIR_TYPE_PEAK, -10.1, 100.0, 7}, - {IIR_TYPE_PEAK, -10.1, 400.0, 7}, - {IIR_TYPE_PEAK, -10.1, 700.0, 7}, - {IIR_TYPE_PEAK, -10.1, 1000.0, 7}, - {IIR_TYPE_PEAK, -10.1, 3000.0, 7}, - {IIR_TYPE_PEAK, -10.1, 5000.0, 7}, - {IIR_TYPE_PEAK, -10.1, 7000.0, 7}, - {IIR_TYPE_PEAK, -10.1, 9000.0, 7}, - - } -}; - -const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_iir_cfg_list[EQ_HW_IIR_LIST_NUM]={ - &audio_eq_hw_iir_cfg, -}; - -const DrcConfig audio_drc_cfg = { - .knee = 3, - .filter_type = {14, -1}, - .band_num = 2, - .look_ahead_time = 10, - .band_settings = { - {-20, 0, 2, 3, 3000, 1}, - {-20, 0, 2, 3, 3000, 1}, - } - }; +const DrcConfig audio_drc_cfg = {.knee = 3, + .filter_type = {14, -1}, + .band_num = 2, + .look_ahead_time = 10, + .band_settings = { + {-20, 0, 2, 3, 3000, 1}, + {-20, 0, 2, 3, 3000, 1}, + }}; const LimiterConfig audio_drc2_cfg = { .knee = 2, @@ -324,4 +340,3 @@ const SpectrumFixConfig audio_spectrum_cfg = { .freq_num = 9, .freq_list = {200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800}, }; - diff --git a/config/best2300p_ibrt/tgt_hardware.c b/config/best2300p_ibrt/tgt_hardware.c index cf6bcba..d093ac6 100644 --- a/config/best2300p_ibrt/tgt_hardware.c +++ b/config/best2300p_ibrt/tgt_hardware.c @@ -14,188 +14,224 @@ * ****************************************************************************/ #include "tgt_hardware.h" -#include "iir_process.h" -#include "fir_process.h" #include "drc.h" +#include "fir_process.h" +#include "iir_process.h" #include "limiter.h" #include "spectrum_fix.h" const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_pinmux_pwl[CFG_HW_PLW_NUM] = { #if (CFG_HW_PLW_NUM > 0) - {HAL_IOMUX_PIN_LED2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_LED1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_LED2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_LED1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}, #endif }; #ifdef __APP_USE_LED_INDICATE_IBRT_STATUS__ const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_ibrt_indication_pinmux_pwl[3] = { - {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_LED1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VBAT, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_LED2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VBAT, HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_LED1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VBAT, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_LED2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VBAT, + HAL_IOMUX_PIN_PULLUP_ENABLE}, }; #endif #ifdef __KNOWLES const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_pinmux_uart[2] = { - {HAL_IOMUX_PIN_P2_2, HAL_IOMUX_FUNC_UART2_RX, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P2_3, HAL_IOMUX_FUNC_UART2_TX, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P2_2, HAL_IOMUX_FUNC_UART2_RX, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P2_3, HAL_IOMUX_FUNC_UART2_TX, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_NOPULL}, }; #endif -//adckey define +// adckey define const uint16_t CFG_HW_ADCKEY_MAP_TABLE[CFG_HW_ADCKEY_NUMBER] = { #if (CFG_HW_ADCKEY_NUMBER > 0) - HAL_KEY_CODE_FN9,HAL_KEY_CODE_FN8,HAL_KEY_CODE_FN7, - HAL_KEY_CODE_FN6,HAL_KEY_CODE_FN5,HAL_KEY_CODE_FN4, - HAL_KEY_CODE_FN3,HAL_KEY_CODE_FN2,HAL_KEY_CODE_FN1, + HAL_KEY_CODE_FN9, HAL_KEY_CODE_FN8, HAL_KEY_CODE_FN7, + HAL_KEY_CODE_FN6, HAL_KEY_CODE_FN5, HAL_KEY_CODE_FN4, + HAL_KEY_CODE_FN3, HAL_KEY_CODE_FN2, HAL_KEY_CODE_FN1, #endif }; -//gpiokey define -#define CFG_HW_GPIOKEY_DOWN_LEVEL (0) -#define CFG_HW_GPIOKEY_UP_LEVEL (1) +// gpiokey define +#define CFG_HW_GPIOKEY_DOWN_LEVEL (0) +#define CFG_HW_GPIOKEY_UP_LEVEL (1) const struct HAL_KEY_GPIOKEY_CFG_T cfg_hw_gpio_key_cfg[CFG_HW_GPIOKEY_NUM] = { -/* -#if (CFG_HW_GPIOKEY_NUM > 0) -#ifdef BES_AUDIO_DEV_Main_Board_9v0 - {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P0_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P0_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN4,{HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - //{HAL_KEY_CODE_FN5,{HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - // {HAL_KEY_CODE_FN6,{HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, -#else -#ifndef TPORTS_KEY_COEXIST - {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - // {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, -#else - {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, -#endif -#endif -#ifdef IS_MULTI_AI_ENABLED - //{HAL_KEY_CODE_FN13,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - //{HAL_KEY_CODE_FN14,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, -#endif -#endif -*/ - {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + /* + #if (CFG_HW_GPIOKEY_NUM > 0) + #ifdef BES_AUDIO_DEV_Main_Board_9v0 + {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P0_0, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P0_1, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN4,{HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + //{HAL_KEY_CODE_FN5,{HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + // {HAL_KEY_CODE_FN6,{HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, #else #ifndef + TPORTS_KEY_COEXIST {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, + HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, {HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P1_0, + HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, + // {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, #else + {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, #endif #endif + #ifdef IS_MULTI_AI_ENABLED + //{HAL_KEY_CODE_FN13,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + //{HAL_KEY_CODE_FN14,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, #endif #endif + */ + {HAL_KEY_CODE_FN1, + {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, }; -//bt config +// bt config const char *BT_LOCAL_NAME = TO_STRING(BT_DEV_NAME) "\0"; const char *BLE_DEFAULT_NAME = "BES_BLE"; uint8_t ble_addr[6] = { #ifdef BLE_DEV_ADDR - BLE_DEV_ADDR + BLE_DEV_ADDR #else - 0xBE,0x99,0x34,0x45,0x56,0x67 + 0xBE, 0x99, 0x34, 0x45, + 0x56, 0x67 #endif }; uint8_t bt_addr[6] = { #ifdef BT_DEV_ADDR - BT_DEV_ADDR + BT_DEV_ADDR #else - 0x1e,0x57,0x34,0x45,0x56,0x67 + 0x1e, 0x57, 0x34, 0x45, + 0x56, 0x67 #endif }; -//audio config -//freq bands range {[0k:2.5K], [2.5k:5K], [5k:7.5K], [7.5K:10K], [10K:12.5K], [12.5K:15K], [15K:17.5K], [17.5K:20K]} -//gain range -12~+12 -const int8_t cfg_aud_eq_sbc_band_settings[CFG_HW_AUD_EQ_NUM_BANDS] = {0, 0, 0, 0, 0, 0, 0, 0}; +// audio config +// freq bands range {[0k:2.5K], [2.5k:5K], [5k:7.5K], [7.5K:10K], [10K:12.5K], +// [12.5K:15K], [15K:17.5K], [17.5K:20K]} gain range -12~+12 +const int8_t cfg_aud_eq_sbc_band_settings[CFG_HW_AUD_EQ_NUM_BANDS] = { + 0, 0, 0, 0, 0, 0, 0, 0}; -#define TX_PA_GAIN CODEC_TX_PA_GAIN_DEFAULT +#define TX_PA_GAIN CODEC_TX_PA_GAIN_DEFAULT const struct CODEC_DAC_VOL_T codec_dac_vol[TGT_VOLUME_LEVEL_QTY] = { - {TX_PA_GAIN,0x03,-21}, - {TX_PA_GAIN,0x03,-99}, - {TX_PA_GAIN,0x03,-45}, - {TX_PA_GAIN,0x03,-42}, - {TX_PA_GAIN,0x03,-39}, - {TX_PA_GAIN,0x03,-36}, - {TX_PA_GAIN,0x03,-33}, - {TX_PA_GAIN,0x03,-30}, - {TX_PA_GAIN,0x03,-27}, - {TX_PA_GAIN,0x03,-24}, - {TX_PA_GAIN,0x03,-21}, - {TX_PA_GAIN,0x03,-18}, - {TX_PA_GAIN,0x03,-15}, - {TX_PA_GAIN,0x03,-12}, - {TX_PA_GAIN,0x03, -9}, - {TX_PA_GAIN,0x03, -6}, - {TX_PA_GAIN,0x03, -3}, - {TX_PA_GAIN,0x03, 0}, //0dBm + {TX_PA_GAIN, 0x03, -21}, {TX_PA_GAIN, 0x03, -99}, + {TX_PA_GAIN, 0x03, -45}, {TX_PA_GAIN, 0x03, -42}, + {TX_PA_GAIN, 0x03, -39}, {TX_PA_GAIN, 0x03, -36}, + {TX_PA_GAIN, 0x03, -33}, {TX_PA_GAIN, 0x03, -30}, + {TX_PA_GAIN, 0x03, -27}, {TX_PA_GAIN, 0x03, -24}, + {TX_PA_GAIN, 0x03, -21}, {TX_PA_GAIN, 0x03, -18}, + {TX_PA_GAIN, 0x03, -15}, {TX_PA_GAIN, 0x03, -12}, + {TX_PA_GAIN, 0x03, -9}, {TX_PA_GAIN, 0x03, -6}, + {TX_PA_GAIN, 0x03, -3}, {TX_PA_GAIN, 0x03, 0}, // 0dBm }; #if SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 2 -#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC2|AUD_VMIC_MAP_VMIC3) +#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC2 | \ + AUD_VMIC_MAP_VMIC3) #elif SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 3 -#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1 | AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC1) +#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1 | AUD_CHANNEL_MAP_CH4 | \ + AUD_VMIC_MAP_VMIC1) #else -#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC3) +#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV \ + (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC3) #endif -#define CFG_HW_AUD_INPUT_PATH_LINEIN_DEV (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1) +#define CFG_HW_AUD_INPUT_PATH_LINEIN_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1) #ifdef VOICE_DETECTOR_EN -#define CFG_HW_AUD_INPUT_PATH_VADMIC_DEV (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC1) +#define CFG_HW_AUD_INPUT_PATH_VADMIC_DEV \ + (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC1) #else -#define CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV (AUD_CHANNEL_MAP_CH0 | AUD_VMIC_MAP_VMIC1) +#define CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_VMIC_MAP_VMIC1) #endif -const struct AUD_IO_PATH_CFG_T cfg_audio_input_path_cfg[CFG_HW_AUD_INPUT_PATH_NUM] = { +const struct AUD_IO_PATH_CFG_T + cfg_audio_input_path_cfg[CFG_HW_AUD_INPUT_PATH_NUM] = { #if defined(SPEECH_TX_AEC_CODEC_REF) - // NOTE: If enable Ch5 and CH6, need to add channel_num when setup audioflinger stream - { AUD_INPUT_PATH_MAINMIC, CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV | AUD_CHANNEL_MAP_CH4, }, + // NOTE: If enable Ch5 and CH6, need to add channel_num when setup + // audioflinger stream + { + AUD_INPUT_PATH_MAINMIC, + CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV | AUD_CHANNEL_MAP_CH4, + }, #else - { AUD_INPUT_PATH_MAINMIC, CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV, }, + { + AUD_INPUT_PATH_MAINMIC, + CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV, + }, #endif - { AUD_INPUT_PATH_LINEIN, CFG_HW_AUD_INPUT_PATH_LINEIN_DEV, }, + { + AUD_INPUT_PATH_LINEIN, + CFG_HW_AUD_INPUT_PATH_LINEIN_DEV, + }, #ifdef VOICE_DETECTOR_EN - { AUD_INPUT_PATH_VADMIC, CFG_HW_AUD_INPUT_PATH_VADMIC_DEV, }, + { + AUD_INPUT_PATH_VADMIC, + CFG_HW_AUD_INPUT_PATH_VADMIC_DEV, + }, #else - { AUD_INPUT_PATH_ASRMIC, CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV, }, + { + AUD_INPUT_PATH_ASRMIC, + CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV, + }, #endif }; - - const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_enable_cfg = { - HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; + HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_detecter_cfg = { - HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; + HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; -const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_indicator_cfg = { - HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; +const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_indicator_cfg = + {HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; -const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_tws_channel_cfg = { - HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE//HAL_IOMUX_PIN_P1_5 500:HAL_IOMUX_PIN_P2_5 +const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_tws_channel_cfg = { + HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE // HAL_IOMUX_PIN_P1_5 + // 500:HAL_IOMUX_PIN_P2_5 }; /* const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_INT ={ - HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE + HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, +HAL_IOMUX_PIN_PULLUP_ENABLE }; */ -const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SDA ={ - HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; +const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SDA = { + HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; -const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SCL ={ - HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; -bool tgt_tws_get_channel_is_right(void) -{ +const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SCL = { + HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; +bool tgt_tws_get_channel_is_right(void) { #ifdef __FIXED_TWS_EAR_SIDE__ - return TWS_EAR_SIDE_ROLE; + return TWS_EAR_SIDE_ROLE; #else - return hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)cfg_hw_tws_channel_cfg.pin); + return hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)cfg_hw_tws_channel_cfg.pin); #endif } @@ -203,122 +239,103 @@ const IIR_CFG_T audio_eq_sw_iir_cfg = { .gain0 = 0, .gain1 = 0, .num = 5, - .param = { - {IIR_TYPE_PEAK, .0, 200, 2}, - {IIR_TYPE_PEAK, .0, 600, 2}, - {IIR_TYPE_PEAK, .0, 2000.0, 2}, - {IIR_TYPE_PEAK, .0, 6000.0, 2}, - {IIR_TYPE_PEAK, .0, 12000.0, 2} - } -}; + .param = {{IIR_TYPE_PEAK, .0, 200, 2}, + {IIR_TYPE_PEAK, .0, 600, 2}, + {IIR_TYPE_PEAK, .0, 2000.0, 2}, + {IIR_TYPE_PEAK, .0, 6000.0, 2}, + {IIR_TYPE_PEAK, .0, 12000.0, 2}}}; -const IIR_CFG_T * const audio_eq_sw_iir_cfg_list[EQ_SW_IIR_LIST_NUM]={ +const IIR_CFG_T *const audio_eq_sw_iir_cfg_list[EQ_SW_IIR_LIST_NUM] = { &audio_eq_sw_iir_cfg, }; -const FIR_CFG_T audio_eq_hw_fir_cfg_44p1k = { - .gain = 0.0f, - .len = 384, - .coef = - { - (1<<23)-1, - } -}; +const FIR_CFG_T audio_eq_hw_fir_cfg_44p1k = {.gain = 0.0f, + .len = 384, + .coef = { + (1 << 23) - 1, + }}; -const FIR_CFG_T audio_eq_hw_fir_cfg_48k = { - .gain = 0.0f, - .len = 384, - .coef = - { - (1<<23)-1, - } -}; +const FIR_CFG_T audio_eq_hw_fir_cfg_48k = {.gain = 0.0f, + .len = 384, + .coef = { + (1 << 23) - 1, + }}; +const FIR_CFG_T audio_eq_hw_fir_cfg_96k = {.gain = 0.0f, + .len = 384, + .coef = { + (1 << 23) - 1, + }}; -const FIR_CFG_T audio_eq_hw_fir_cfg_96k = { - .gain = 0.0f, - .len = 384, - .coef = - { - (1<<23)-1, - } -}; - -const FIR_CFG_T * const audio_eq_hw_fir_cfg_list[EQ_HW_FIR_LIST_NUM]={ +const FIR_CFG_T *const audio_eq_hw_fir_cfg_list[EQ_HW_FIR_LIST_NUM] = { &audio_eq_hw_fir_cfg_44p1k, &audio_eq_hw_fir_cfg_48k, - &audio_eq_hw_fir_cfg_96k, + &audio_eq_hw_fir_cfg_96k, }; -//hardware dac iir eq -const IIR_CFG_T audio_eq_hw_dac_iir_cfg = { - .gain0 = 0, - .gain1 = 0, - .num = 8, - .param = { - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - } +// hardware dac iir eq +const IIR_CFG_T audio_eq_hw_dac_iir_cfg = {.gain0 = 0, + .gain1 = 0, + .num = 8, + .param = { + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + }}; + +const IIR_CFG_T *const POSSIBLY_UNUSED + audio_eq_hw_dac_iir_cfg_list[EQ_HW_DAC_IIR_LIST_NUM] = { + &audio_eq_hw_dac_iir_cfg, }; -const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_dac_iir_cfg_list[EQ_HW_DAC_IIR_LIST_NUM]={ - &audio_eq_hw_dac_iir_cfg, -}; - -//hardware dac iir eq +// hardware dac iir eq const IIR_CFG_T audio_eq_hw_adc_iir_adc_cfg = { .gain0 = 0, .gain1 = 0, .num = 1, .param = { - {IIR_TYPE_PEAK, 0.0, 1000.0, 0.7}, - } + {IIR_TYPE_PEAK, 0.0, 1000.0, 0.7}, + }}; + +const IIR_CFG_T *const POSSIBLY_UNUSED + audio_eq_hw_adc_iir_cfg_list[EQ_HW_ADC_IIR_LIST_NUM] = { + &audio_eq_hw_adc_iir_adc_cfg, }; -const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_adc_iir_cfg_list[EQ_HW_ADC_IIR_LIST_NUM]={ - &audio_eq_hw_adc_iir_adc_cfg, +// hardware iir eq +const IIR_CFG_T audio_eq_hw_iir_cfg = {.gain0 = 0, + .gain1 = 0, + .num = 8, + .param = { + {IIR_TYPE_PEAK, -10.1, 100.0, 7}, + {IIR_TYPE_PEAK, -10.1, 400.0, 7}, + {IIR_TYPE_PEAK, -10.1, 700.0, 7}, + {IIR_TYPE_PEAK, -10.1, 1000.0, 7}, + {IIR_TYPE_PEAK, -10.1, 3000.0, 7}, + {IIR_TYPE_PEAK, -10.1, 5000.0, 7}, + {IIR_TYPE_PEAK, -10.1, 7000.0, 7}, + {IIR_TYPE_PEAK, -10.1, 9000.0, 7}, + + }}; + +const IIR_CFG_T *const POSSIBLY_UNUSED + audio_eq_hw_iir_cfg_list[EQ_HW_IIR_LIST_NUM] = { + &audio_eq_hw_iir_cfg, }; - - -//hardware iir eq -const IIR_CFG_T audio_eq_hw_iir_cfg = { - .gain0 = 0, - .gain1 = 0, - .num = 8, - .param = { - {IIR_TYPE_PEAK, -10.1, 100.0, 7}, - {IIR_TYPE_PEAK, -10.1, 400.0, 7}, - {IIR_TYPE_PEAK, -10.1, 700.0, 7}, - {IIR_TYPE_PEAK, -10.1, 1000.0, 7}, - {IIR_TYPE_PEAK, -10.1, 3000.0, 7}, - {IIR_TYPE_PEAK, -10.1, 5000.0, 7}, - {IIR_TYPE_PEAK, -10.1, 7000.0, 7}, - {IIR_TYPE_PEAK, -10.1, 9000.0, 7}, - - } -}; - -const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_iir_cfg_list[EQ_HW_IIR_LIST_NUM]={ - &audio_eq_hw_iir_cfg, -}; - -const DrcConfig audio_drc_cfg = { - .knee = 3, - .filter_type = {14, -1}, - .band_num = 2, - .look_ahead_time = 10, - .band_settings = { - {-20, 0, 2, 3, 3000, 1}, - {-20, 0, 2, 3, 3000, 1}, - } - }; +const DrcConfig audio_drc_cfg = {.knee = 3, + .filter_type = {14, -1}, + .band_num = 2, + .look_ahead_time = 10, + .band_settings = { + {-20, 0, 2, 3, 3000, 1}, + {-20, 0, 2, 3, 3000, 1}, + }}; const LimiterConfig audio_drc2_cfg = { .knee = 2, @@ -334,4 +351,3 @@ const SpectrumFixConfig audio_spectrum_cfg = { .freq_num = 9, .freq_list = {200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800}, }; - diff --git a/config/best2300p_ibrt_anc/tgt_hardware.c b/config/best2300p_ibrt_anc/tgt_hardware.c index 1a2e752..1c070ee 100644 --- a/config/best2300p_ibrt_anc/tgt_hardware.c +++ b/config/best2300p_ibrt_anc/tgt_hardware.c @@ -15,139 +15,183 @@ ****************************************************************************/ #include "tgt_hardware.h" #include "aud_section.h" -#include "iir_process.h" -#include "fir_process.h" #include "drc.h" +#include "fir_process.h" +#include "iir_process.h" #include "limiter.h" #include "spectrum_fix.h" const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_pinmux_pwl[CFG_HW_PLW_NUM] = { #if (CFG_HW_PLW_NUM > 0) - {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_P1_4, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_P1_4, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}, #endif }; -//adckey define +// adckey define const uint16_t CFG_HW_ADCKEY_MAP_TABLE[CFG_HW_ADCKEY_NUMBER] = { #if (CFG_HW_ADCKEY_NUMBER > 0) - HAL_KEY_CODE_FN9,HAL_KEY_CODE_FN8,HAL_KEY_CODE_FN7, - HAL_KEY_CODE_FN6,HAL_KEY_CODE_FN5,HAL_KEY_CODE_FN4, - HAL_KEY_CODE_FN3,HAL_KEY_CODE_FN2,HAL_KEY_CODE_FN1, + HAL_KEY_CODE_FN9, HAL_KEY_CODE_FN8, HAL_KEY_CODE_FN7, + HAL_KEY_CODE_FN6, HAL_KEY_CODE_FN5, HAL_KEY_CODE_FN4, + HAL_KEY_CODE_FN3, HAL_KEY_CODE_FN2, HAL_KEY_CODE_FN1, #endif }; -//gpiokey define -#define CFG_HW_GPIOKEY_DOWN_LEVEL (0) -#define CFG_HW_GPIOKEY_UP_LEVEL (1) +// gpiokey define +#define CFG_HW_GPIOKEY_DOWN_LEVEL (0) +#define CFG_HW_GPIOKEY_UP_LEVEL (1) const struct HAL_KEY_GPIOKEY_CFG_T cfg_hw_gpio_key_cfg[CFG_HW_GPIOKEY_NUM] = { #if (CFG_HW_GPIOKEY_NUM > 0) #ifdef BES_AUDIO_DEV_Main_Board_9v0 - {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P0_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P0_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN4,{HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN5,{HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN6,{HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN1, + {HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN2, + {HAL_IOMUX_PIN_P0_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN3, + {HAL_IOMUX_PIN_P0_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN4, + {HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN5, + {HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN6, + {HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, #else #ifndef TPORTS_KEY_COEXIST - {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - // {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN1, + {HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN2, + {HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, + // {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, + // HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN15, + {HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, #else - {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN1, + {HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN15, + {HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, #endif #endif #ifdef IS_MULTI_AI_ENABLED - //{HAL_KEY_CODE_FN13,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - //{HAL_KEY_CODE_FN14,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, +//{HAL_KEY_CODE_FN13,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, +// HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, +//{HAL_KEY_CODE_FN14,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, +// HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, #endif #endif }; -//bt config +// bt config const char *BT_LOCAL_NAME = TO_STRING(BT_DEV_NAME) "\0"; const char *BLE_DEFAULT_NAME = "BES_BLE"; uint8_t ble_addr[6] = { #ifdef BLE_DEV_ADDR - BLE_DEV_ADDR + BLE_DEV_ADDR #else - 0xBE,0x99,0x34,0x45,0x56,0x67 + 0xBE, 0x99, 0x34, 0x45, + 0x56, 0x67 #endif }; uint8_t bt_addr[6] = { #ifdef BT_DEV_ADDR - BT_DEV_ADDR + BT_DEV_ADDR #else - 0x1e,0x57,0x34,0x45,0x56,0x67 + 0x1e, 0x57, 0x34, 0x45, + 0x56, 0x67 #endif }; -//audio config -//freq bands range {[0k:2.5K], [2.5k:5K], [5k:7.5K], [7.5K:10K], [10K:12.5K], [12.5K:15K], [15K:17.5K], [17.5K:20K]} -//gain range -12~+12 -const int8_t cfg_aud_eq_sbc_band_settings[CFG_HW_AUD_EQ_NUM_BANDS] = {0, 0, 0, 0, 0, 0, 0, 0}; +// audio config +// freq bands range {[0k:2.5K], [2.5k:5K], [5k:7.5K], [7.5K:10K], [10K:12.5K], +// [12.5K:15K], [15K:17.5K], [17.5K:20K]} gain range -12~+12 +const int8_t cfg_aud_eq_sbc_band_settings[CFG_HW_AUD_EQ_NUM_BANDS] = { + 0, 0, 0, 0, 0, 0, 0, 0}; -#define TX_PA_GAIN CODEC_TX_PA_GAIN_DEFAULT +#define TX_PA_GAIN CODEC_TX_PA_GAIN_DEFAULT const struct CODEC_DAC_VOL_T codec_dac_vol[TGT_VOLUME_LEVEL_QTY] = { - {TX_PA_GAIN,0x03,-11}, - {TX_PA_GAIN,0x03,-99}, - {TX_PA_GAIN,0x03,-45}, - {TX_PA_GAIN,0x03,-42}, - {TX_PA_GAIN,0x03,-39}, - {TX_PA_GAIN,0x03,-36}, - {TX_PA_GAIN,0x03,-33}, - {TX_PA_GAIN,0x03,-30}, - {TX_PA_GAIN,0x03,-27}, - {TX_PA_GAIN,0x03,-24}, - {TX_PA_GAIN,0x03,-21}, - {TX_PA_GAIN,0x03,-18}, - {TX_PA_GAIN,0x03,-15}, - {TX_PA_GAIN,0x03,-12}, - {TX_PA_GAIN,0x03, -9}, - {TX_PA_GAIN,0x03, -6}, - {TX_PA_GAIN,0x03, -3}, - {TX_PA_GAIN,0x03, 0}, //0dBm + {TX_PA_GAIN, 0x03, -11}, {TX_PA_GAIN, 0x03, -99}, + {TX_PA_GAIN, 0x03, -45}, {TX_PA_GAIN, 0x03, -42}, + {TX_PA_GAIN, 0x03, -39}, {TX_PA_GAIN, 0x03, -36}, + {TX_PA_GAIN, 0x03, -33}, {TX_PA_GAIN, 0x03, -30}, + {TX_PA_GAIN, 0x03, -27}, {TX_PA_GAIN, 0x03, -24}, + {TX_PA_GAIN, 0x03, -21}, {TX_PA_GAIN, 0x03, -18}, + {TX_PA_GAIN, 0x03, -15}, {TX_PA_GAIN, 0x03, -12}, + {TX_PA_GAIN, 0x03, -9}, {TX_PA_GAIN, 0x03, -6}, + {TX_PA_GAIN, 0x03, -3}, {TX_PA_GAIN, 0x03, 0}, // 0dBm }; #if SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 2 -#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1 | AUD_VMIC_MAP_VMIC1) +#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1 | AUD_VMIC_MAP_VMIC1) #elif SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 3 -#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1 | AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC1) +#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1 | AUD_CHANNEL_MAP_CH4 | \ + AUD_VMIC_MAP_VMIC1) #else -#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (AUD_CHANNEL_MAP_CH0 | AUD_VMIC_MAP_VMIC1) +#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_VMIC_MAP_VMIC1) #endif -#define CFG_HW_AUD_INPUT_PATH_LINEIN_DEV (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1) -#define CFG_HW_AUD_INPUT_PATH_VADMIC_DEV (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC1) -#define CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV (AUD_CHANNEL_MAP_CH0 | AUD_VMIC_MAP_VMIC1) +#define CFG_HW_AUD_INPUT_PATH_LINEIN_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1) +#define CFG_HW_AUD_INPUT_PATH_VADMIC_DEV \ + (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC1) +#define CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_VMIC_MAP_VMIC1) -const struct AUD_IO_PATH_CFG_T cfg_audio_input_path_cfg[CFG_HW_AUD_INPUT_PATH_NUM] = { +const struct AUD_IO_PATH_CFG_T + cfg_audio_input_path_cfg[CFG_HW_AUD_INPUT_PATH_NUM] = { #if defined(SPEECH_TX_AEC_CODEC_REF) - // NOTE: If enable Ch5 and CH6, need to add channel_num when setup audioflinger stream - { AUD_INPUT_PATH_MAINMIC, CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV | AUD_CHANNEL_MAP_ECMIC_CH0, }, + // NOTE: If enable Ch5 and CH6, need to add channel_num when setup + // audioflinger stream + { + AUD_INPUT_PATH_MAINMIC, + CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV | AUD_CHANNEL_MAP_ECMIC_CH0, + }, #else - { AUD_INPUT_PATH_MAINMIC, CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV, }, + { + AUD_INPUT_PATH_MAINMIC, + CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV, + }, #endif - { AUD_INPUT_PATH_LINEIN, CFG_HW_AUD_INPUT_PATH_LINEIN_DEV, }, - { AUD_INPUT_PATH_VADMIC, CFG_HW_AUD_INPUT_PATH_VADMIC_DEV, }, - { AUD_INPUT_PATH_ASRMIC, CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV, }, + { + AUD_INPUT_PATH_LINEIN, + CFG_HW_AUD_INPUT_PATH_LINEIN_DEV, + }, + { + AUD_INPUT_PATH_VADMIC, + CFG_HW_AUD_INPUT_PATH_VADMIC_DEV, + }, + { + AUD_INPUT_PATH_ASRMIC, + CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV, + }, }; const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_enable_cfg = { - HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; + HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_detecter_cfg = { - HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; - -const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_indicator_cfg = { - HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; + HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; +const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_indicator_cfg = + {HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; /* @@ -167,7 +211,7 @@ Filter4_B=[ 131758190, -257297054, 126191415]; Filter4_A=[ 134217728, -257297054, 123731878]; - + */ #define IIR_COUNTER_FF_L (6) @@ -175,177 +219,173 @@ Filter4_A=[ 134217728, -257297054, 123731878]; #define IIR_COUNTER_FB_L (5) #define IIR_COUNTER_FB_R (5) - -static const struct_anc_cfg POSSIBLY_UNUSED AncFirCoef_50p7k_mode0 = { - .anc_cfg_ff_l = { - // .total_gain = 440, - .total_gain = 350, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FF_L, - - .iir_coef[0].coef_b={42462788, -84862242, 42399478}, - .iir_coef[0].coef_a={134217728, -268358003, 134140286}, - - .iir_coef[1].coef_b={135905569, -267224817, 131334465}, - .iir_coef[1].coef_a={134217728, -267224817, 133022306}, - - .iir_coef[2].coef_b={132936489, -263935268, 131067941}, - .iir_coef[2].coef_a={134217728, -263935268, 129786702}, - - .iir_coef[3].coef_b={131758190, -257297054, 126191415}, - .iir_coef[3].coef_a={134217728, -257297054, 123731878}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = +static const struct_anc_cfg POSSIBLY_UNUSED + AncFirCoef_50p7k_mode0 = { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, - .anc_cfg_ff_r = { - // .total_gain = 382, - .total_gain = 350, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FF_R, - - .iir_coef[0].coef_b={42462788, -84862242, 42399478}, - .iir_coef[0].coef_a={134217728, -268358003, 134140286}, - - .iir_coef[1].coef_b={135905569, -267224817, 131334465}, - .iir_coef[1].coef_a={134217728, -267224817, 133022306}, - - .iir_coef[2].coef_b={132936489, -263935268, 131067941}, - .iir_coef[2].coef_a={134217728, -263935268, 129786702}, - - .iir_coef[3].coef_b={131758190, -257297054, 126191415}, - .iir_coef[3].coef_a={134217728, -257297054, 123731878}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = - { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, + .anc_cfg_ff_l = + { + // .total_gain = 440, + .total_gain = 350, + + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FF_L, + + .iir_coef[0].coef_b = {42462788, -84862242, 42399478}, + .iir_coef[0].coef_a = {134217728, -268358003, 134140286}, + + .iir_coef[1].coef_b = {135905569, -267224817, 131334465}, + .iir_coef[1].coef_a = {134217728, -267224817, 133022306}, + + .iir_coef[2].coef_b = {132936489, -263935268, 131067941}, + .iir_coef[2].coef_a = {134217728, -263935268, 129786702}, + + .iir_coef[3].coef_b = {131758190, -257297054, 126191415}, + .iir_coef[3].coef_a = {134217728, -257297054, 123731878}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + .anc_cfg_ff_r = + { + // .total_gain = 382, + .total_gain = 350, + + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FF_R, + + .iir_coef[0].coef_b = {42462788, -84862242, 42399478}, + .iir_coef[0].coef_a = {134217728, -268358003, 134140286}, + + .iir_coef[1].coef_b = {135905569, -267224817, 131334465}, + .iir_coef[1].coef_a = {134217728, -267224817, 133022306}, + + .iir_coef[2].coef_b = {132936489, -263935268, 131067941}, + .iir_coef[2].coef_a = {134217728, -263935268, 129786702}, + + .iir_coef[3].coef_b = {131758190, -257297054, 126191415}, + .iir_coef[3].coef_a = {134217728, -257297054, 123731878}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + + /* + + Filter1_B=[ 27461831, -54408898, 27001841]; + Filter1_A=[ 134217728, -216605724, 82606056]; + + Filter2_B=[ 138294078, -267600712, 129323227]; + Filter2_A=[ 134217728, -267600712, 133399577]; + + Filter3_B=[ 134500015, -268177932, 133678688]; + Filter3_A=[ 134217728, -268177932, 133960975]; + + Filter4_B=[ 133629164, -264794659, 131257050]; + Filter4_A=[ 134217728, -264794659, 130668486]; -/* + */ -Filter1_B=[ 27461831, -54408898, 27001841]; -Filter1_A=[ 134217728, -216605724, 82606056]; + .anc_cfg_fb_l = + { + .total_gain = 350, -Filter2_B=[ 138294078, -267600712, 129323227]; -Filter2_A=[ 134217728, -267600712, 133399577]; + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FB_L, -Filter3_B=[ 134500015, -268177932, 133678688]; -Filter3_A=[ 134217728, -268177932, 133960975]; + .iir_coef[0].coef_b = {27461831, -54408898, 27001841}, + .iir_coef[0].coef_a = {134217728, -216605724, 82606056}, -Filter4_B=[ 133629164, -264794659, 131257050]; -Filter4_A=[ 134217728, -264794659, 130668486]; + .iir_coef[1].coef_b = {138294078, -267600712, 129323227}, + .iir_coef[1].coef_a = {134217728, -267600712, 133399577}, + .iir_coef[2].coef_b = {134500015, -268177932, 133678688}, + .iir_coef[2].coef_a = {134217728, -268177932, 133960975}, -*/ - - .anc_cfg_fb_l = { - .total_gain = 350, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FB_L, - - .iir_coef[0].coef_b={ 27461831, -54408898, 27001841}, - .iir_coef[0].coef_a={134217728, -216605724, 82606056}, - - .iir_coef[1].coef_b={138294078, -267600712, 129323227}, - .iir_coef[1].coef_a={134217728, -267600712, 133399577}, - - .iir_coef[2].coef_b={134500015, -268177932, 133678688}, - .iir_coef[2].coef_a={134217728, -268177932, 133960975}, - - .iir_coef[3].coef_b={133629164, -264794659, 131257050}, - .iir_coef[3].coef_a={134217728, -264794659, 130668486}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = - { - 32767, - }, -*/ + .iir_coef[3].coef_b = {133629164, -264794659, 131257050}, + .iir_coef[3].coef_a = {134217728, -264794659, 130668486}, + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + .anc_cfg_fb_r = + { + .total_gain = 350, - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, - .anc_cfg_fb_r = { - .total_gain = 350, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FB_R, - - .iir_coef[0].coef_b={ 27461831, -54408898, 27001841}, - .iir_coef[0].coef_a={134217728, -216605724, 82606056}, - - .iir_coef[1].coef_b={138294078, -267600712, 129323227}, - .iir_coef[1].coef_a={134217728, -267600712, 133399577}, - - .iir_coef[2].coef_b={134500015, -268177932, 133678688}, - .iir_coef[2].coef_a={134217728, -268177932, 133960975}, - - .iir_coef[3].coef_b={133629164, -264794659, 131257050}, - .iir_coef[3].coef_a={134217728, -264794659, 130668486}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = - { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FB_R, + .iir_coef[0].coef_b = {27461831, -54408898, 27001841}, + .iir_coef[0].coef_a = {134217728, -216605724, 82606056}, + + .iir_coef[1].coef_b = {138294078, -267600712, 129323227}, + .iir_coef[1].coef_a = {134217728, -267600712, 133399577}, + + .iir_coef[2].coef_b = {134500015, -268177932, 133678688}, + .iir_coef[2].coef_a = {134217728, -268177932, 133960975}, + + .iir_coef[3].coef_b = {133629164, -264794659, 131257050}, + .iir_coef[3].coef_a = {134217728, -264794659, 130668486}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, - }; - /* //ff @@ -364,277 +404,278 @@ Filter4_B=[ 131621817, -256639526, 125746382]; Filter4_A=[ 134217728, -256639526, 123150471]; - -*/ - -static const struct_anc_cfg POSSIBLY_UNUSED AncFirCoef_48k_mode0 = { - .anc_cfg_ff_l = { - // .total_gain = 440, - .total_gain = 312, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FF_L, - - .iir_coef[0].coef_b={42463913, -84860822, 42396935}, - .iir_coef[0].coef_a={134217728, -268353516, 134135801}, - - .iir_coef[1].coef_b={136002894, -267154076, 131168209}, - .iir_coef[1].coef_a={134217728, -267154076, 132953376}, - - .iir_coef[2].coef_b={132863566, -263674901, 130888668}, - .iir_coef[2].coef_a={134217728, -263674901, 129534506}, - - .iir_coef[3].coef_b={131621817, -256639526, 125746382}, - .iir_coef[3].coef_a={134217728, -256639526, 123150471}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = - { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, - .anc_cfg_ff_r = { - // .total_gain = 382, - .total_gain = 288, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FF_R, - - .iir_coef[0].coef_b={42463913, -84860822, 42396935}, - .iir_coef[0].coef_a={134217728, -268353516, 134135801}, - - .iir_coef[1].coef_b={136002894, -267154076, 131168209}, - .iir_coef[1].coef_a={134217728, -267154076, 132953376}, - - .iir_coef[2].coef_b={132863566, -263674901, 130888668}, - .iir_coef[2].coef_a={134217728, -263674901, 129534506}, - - .iir_coef[3].coef_b={131621817, -256639526, 125746382}, - .iir_coef[3].coef_a={134217728, -256639526, 123150471}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = - { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, - - -/* - -Filter1_B=[ 27172676, -53803459, 26691412]; -Filter1_A=[ 134217728, -214195429, 80219070]; - -Filter2_B=[ 138529480, -267551490, 129040578]; -Filter2_A=[ 134217728, -267551490, 133352330]; - -Filter3_B=[ 134516353, -268162980, 133647489]; -Filter3_A=[ 134217728, -268162980, 133946114]; - -Filter4_B=[ 133595549, -264581113, 131087955]; -Filter4_A=[ 134217728, -264581113, 130465777]; - */ - - .anc_cfg_fb_l = { - .total_gain = 511, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FB_L, - - .iir_coef[0].coef_b={ 27172676, -53803459, 26691412}, - .iir_coef[0].coef_a={134217728, -214195429, 80219070}, - - .iir_coef[1].coef_b={138529480, -267551490, 129040578}, - .iir_coef[1].coef_a={134217728, -267551490, 133352330}, - - .iir_coef[2].coef_b={134516353, -268162980, 133647489}, - .iir_coef[2].coef_a={134217728, -268162980, 133946114}, - - .iir_coef[3].coef_b={133595549, -264581113, 131087955}, - .iir_coef[3].coef_a={134217728, -264581113, 130465777}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = + +static const struct_anc_cfg POSSIBLY_UNUSED + AncFirCoef_48k_mode0 = { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, - .anc_cfg_fb_r = { - .total_gain = 511, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FB_R, - - .iir_coef[0].coef_b={ 27172676, -53803459, 26691412}, - .iir_coef[0].coef_a={134217728, -214195429, 80219070}, - - .iir_coef[1].coef_b={138529480, -267551490, 129040578}, - .iir_coef[1].coef_a={134217728, -267551490, 133352330}, - - .iir_coef[2].coef_b={134516353, -268162980, 133647489}, - .iir_coef[2].coef_a={134217728, -268162980, 133946114}, - - .iir_coef[3].coef_b={133595549, -264581113, 131087955}, - .iir_coef[3].coef_a={134217728, -264581113, 130465777}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = - { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, + .anc_cfg_ff_l = + { + // .total_gain = 440, + .total_gain = 312, + + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FF_L, + + .iir_coef[0].coef_b = {42463913, -84860822, 42396935}, + .iir_coef[0].coef_a = {134217728, -268353516, 134135801}, + + .iir_coef[1].coef_b = {136002894, -267154076, 131168209}, + .iir_coef[1].coef_a = {134217728, -267154076, 132953376}, + + .iir_coef[2].coef_b = {132863566, -263674901, 130888668}, + .iir_coef[2].coef_a = {134217728, -263674901, 129534506}, + + .iir_coef[3].coef_b = {131621817, -256639526, 125746382}, + .iir_coef[3].coef_a = {134217728, -256639526, 123150471}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + .anc_cfg_ff_r = + { + // .total_gain = 382, + .total_gain = 288, + + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FF_R, + + .iir_coef[0].coef_b = {42463913, -84860822, 42396935}, + .iir_coef[0].coef_a = {134217728, -268353516, 134135801}, + + .iir_coef[1].coef_b = {136002894, -267154076, 131168209}, + .iir_coef[1].coef_a = {134217728, -267154076, 132953376}, + + .iir_coef[2].coef_b = {132863566, -263674901, 130888668}, + .iir_coef[2].coef_a = {134217728, -263674901, 129534506}, + + .iir_coef[3].coef_b = {131621817, -256639526, 125746382}, + .iir_coef[3].coef_a = {134217728, -256639526, 123150471}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + + /* + + Filter1_B=[ 27172676, -53803459, 26691412]; + Filter1_A=[ 134217728, -214195429, 80219070]; + + Filter2_B=[ 138529480, -267551490, 129040578]; + Filter2_A=[ 134217728, -267551490, 133352330]; + + Filter3_B=[ 134516353, -268162980, 133647489]; + Filter3_A=[ 134217728, -268162980, 133946114]; + + Filter4_B=[ 133595549, -264581113, 131087955]; + Filter4_A=[ 134217728, -264581113, 130465777]; + + + */ + + .anc_cfg_fb_l = + { + .total_gain = 511, + + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FB_L, + + .iir_coef[0].coef_b = {27172676, -53803459, 26691412}, + .iir_coef[0].coef_a = {134217728, -214195429, 80219070}, + + .iir_coef[1].coef_b = {138529480, -267551490, 129040578}, + .iir_coef[1].coef_a = {134217728, -267551490, 133352330}, + + .iir_coef[2].coef_b = {134516353, -268162980, 133647489}, + .iir_coef[2].coef_a = {134217728, -268162980, 133946114}, + + .iir_coef[3].coef_b = {133595549, -264581113, 131087955}, + .iir_coef[3].coef_a = {134217728, -264581113, 130465777}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + .anc_cfg_fb_r = + { + .total_gain = 511, + + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FB_R, + + .iir_coef[0].coef_b = {27172676, -53803459, 26691412}, + .iir_coef[0].coef_a = {134217728, -214195429, 80219070}, + + .iir_coef[1].coef_b = {138529480, -267551490, 129040578}, + .iir_coef[1].coef_a = {134217728, -267551490, 133352330}, + + .iir_coef[2].coef_b = {134516353, -268162980, 133647489}, + .iir_coef[2].coef_a = {134217728, -268162980, 133946114}, + + .iir_coef[3].coef_b = {133595549, -264581113, 131087955}, + .iir_coef[3].coef_a = {134217728, -264581113, 130465777}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, #if (AUD_SECTION_STRUCT_VERSION == 2) - -/* -1.0000000000000000,-1.5858874672928407,0.6974239598044429,0.2832267077115959,-0.3117526885614825,0.1400624733614886, -Filter1_B=[ 4751756, -5230342, 2349858]; -Filter1_A=[ 16777216, -26606777, 11700832]; + /* + 1.0000000000000000,-1.5858874672928407,0.6974239598044429,0.2832267077115959,-0.3117526885614825,0.1400624733614886, + Filter1_B=[ 4751756, -5230342, 2349858]; + Filter1_A=[ 16777216, -26606777, 11700832]; -1.0000000000000000,-1.7971697583202608,0.8159624512785459,0.9540998606028980,-1.7971697583202608,0.8618625906756480, -Filter2_B=[ 16007139, -30151505, 14459655]; -Filter2_A=[ 16777216, -30151505, 13689578]; + 1.0000000000000000,-1.7971697583202608,0.8159624512785459,0.9540998606028980,-1.7971697583202608,0.8618625906756480, + Filter2_B=[ 16007139, -30151505, 14459655]; + Filter2_A=[ 16777216, -30151505, 13689578]; -1.0000000000000000,-1.9694050640918992,0.9705681145972464,0.3200483744622364,-0.6223829329788905,0.3034976090220014, -Filter3_B=[ 5369521, -10441853, 5091845]; -Filter3_A=[ 16777216, -33041134, 16283431]; + 1.0000000000000000,-1.9694050640918992,0.9705681145972464,0.3200483744622364,-0.6223829329788905,0.3034976090220014, + Filter3_B=[ 5369521, -10441853, 5091845]; + Filter3_A=[ 16777216, -33041134, 16283431]; -1.0000000000000000,-1.9921619776276678,0.9921812243512138,0.9968660174712476,-1.9921712178765081,0.9953059666311256, -Filter4_B=[ 16724636, -33423087, 16698463]; -Filter4_A=[ 16777216, -33422932, 16646039]; -*/ + 1.0000000000000000,-1.9921619776276678,0.9921812243512138,0.9968660174712476,-1.9921712178765081,0.9953059666311256, + Filter4_B=[ 16724636, -33423087, 16698463]; + Filter4_A=[ 16777216, -33422932, 16646039]; + */ -/* + /* -1.0000000000000000,-1.9868580074509832,0.9869011854430232,1.1834688902733632,-2.3614075958038656,1.1779451659756268, -Filter1_B=[ 19855313, -39617845, 19762640]; -Filter1_A=[ 16777216, -33333946, 16557454]; + 1.0000000000000000,-1.9868580074509832,0.9869011854430232,1.1834688902733632,-2.3614075958038656,1.1779451659756268, + Filter1_B=[ 19855313, -39617845, 19762640]; + Filter1_A=[ 16777216, -33333946, 16557454]; -1.0000000000000000,-1.0329261527674278,0.0418392318218667,0.5812322628931170,-1.0329261527674278,0.4606069689287498, -Filter2_B=[ 9751459, -17329625, 7727703]; -Filter2_A=[ 16777216, -17329625, 701946]; + 1.0000000000000000,-1.0329261527674278,0.0418392318218667,0.5812322628931170,-1.0329261527674278,0.4606069689287498, + Filter2_B=[ 9751459, -17329625, 7727703]; + Filter2_A=[ 16777216, -17329625, 701946]; -1.0000000000000000,-1.9576081396140492,0.9591185490154677,1.0729914166044796,-1.9576081396140492,0.8861271324109881, -Filter3_B=[ 18001809, -32843215, 14866746]; -Filter3_A=[ 16777216, -32843215, 16091339]; + 1.0000000000000000,-1.9576081396140492,0.9591185490154677,1.0729914166044796,-1.9576081396140492,0.8861271324109881, + Filter3_B=[ 18001809, -32843215, 14866746]; + Filter3_A=[ 16777216, -32843215, 16091339]; -1.0000000000000000,-1.9197071583239940,0.9219883336398085,0.7545642546264146,-1.4392920140632206,0.6870089347526202, -Filter4_B=[ 12659487, -24147313, 11526097]; -Filter4_A=[ 16777216, -32207342, 15468397]; + 1.0000000000000000,-1.9197071583239940,0.9219883336398085,0.7545642546264146,-1.4392920140632206,0.6870089347526202, + Filter4_B=[ 12659487, -24147313, 11526097]; + Filter4_A=[ 16777216, -32207342, 15468397]; -1.0000000000000000,-1.9102108535747602,0.9139876710346515,0.9829076121866517,-1.9102108535747602,0.9310800588479999, -Filter5_B=[ 16490453, -32048020, 15620931]; -Filter5_A=[ 16777216, -32048020, 15334169]; -*/ + 1.0000000000000000,-1.9102108535747602,0.9139876710346515,0.9829076121866517,-1.9102108535747602,0.9310800588479999, + Filter5_B=[ 16490453, -32048020, 15620931]; + Filter5_A=[ 16777216, -32048020, 15334169]; + */ + .anc_cfg_mc_l = + { + .total_gain = 1228, + .iir_bypass_flag = 0, + .iir_counter = 5, + .iir_coef[0].coef_b = {19855313, -39617845, 19762640}, + .iir_coef[0].coef_a = {16777216, -33333946, 16557454}, - .anc_cfg_mc_l = { - .total_gain = 1228, - - .iir_bypass_flag=0, - .iir_counter=5, - - .iir_coef[0].coef_b={19855313, -39617845, 19762640}, - .iir_coef[0].coef_a={16777216, -33333946, 16557454}, - - .iir_coef[1].coef_b={9751459, -17329625, 7727703}, - .iir_coef[1].coef_a={16777216, -17329625, 701946}, - - .iir_coef[2].coef_b={18001809, -32843215, 14866746}, - .iir_coef[2].coef_a={16777216, -32843215, 16091339}, - - .iir_coef[3].coef_b={12659487, -24147313, 11526097}, - .iir_coef[3].coef_a={16777216, -32207342, 15468397}, - - .iir_coef[4].coef_b={16490453, -32048020, 15620931}, - .iir_coef[4].coef_a={16777216, -32048020, 15334169}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - + .iir_coef[1].coef_b = {9751459, -17329625, 7727703}, + .iir_coef[1].coef_a = {16777216, -17329625, 701946}, - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, - .anc_cfg_mc_r = { - .total_gain = 1331, - - .iir_bypass_flag=0, - .iir_counter=5, - - .iir_coef[0].coef_b={19855313, -39617845, 19762640}, - .iir_coef[0].coef_a={16777216, -33333946, 16557454}, - - .iir_coef[1].coef_b={9751459, -17329625, 7727703}, - .iir_coef[1].coef_a={16777216, -17329625, 701946}, - - .iir_coef[2].coef_b={18001809, -32843215, 14866746}, - .iir_coef[2].coef_a={16777216, -32843215, 16091339}, - - .iir_coef[3].coef_b={12659487, -24147313, 11526097}, - .iir_coef[3].coef_a={16777216, -32207342, 15468397}, - - .iir_coef[4].coef_b={16490453, -32048020, 15620931}, - .iir_coef[4].coef_a={16777216, -32048020, 15334169}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - + .iir_coef[2].coef_b = {18001809, -32843215, 14866746}, + .iir_coef[2].coef_a = {16777216, -32843215, 16091339}, - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, + .iir_coef[3].coef_b = {12659487, -24147313, 11526097}, + .iir_coef[3].coef_a = {16777216, -32207342, 15468397}, + + .iir_coef[4].coef_b = {16490453, -32048020, 15620931}, + .iir_coef[4].coef_a = {16777216, -32048020, 15334169}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + .anc_cfg_mc_r = + { + .total_gain = 1331, + + .iir_bypass_flag = 0, + .iir_counter = 5, + + .iir_coef[0].coef_b = {19855313, -39617845, 19762640}, + .iir_coef[0].coef_a = {16777216, -33333946, 16557454}, + + .iir_coef[1].coef_b = {9751459, -17329625, 7727703}, + .iir_coef[1].coef_a = {16777216, -17329625, 701946}, + + .iir_coef[2].coef_b = {18001809, -32843215, 14866746}, + .iir_coef[2].coef_a = {16777216, -32843215, 16091339}, + + .iir_coef[3].coef_b = {12659487, -24147313, 11526097}, + .iir_coef[3].coef_a = {16777216, -32207342, 15468397}, + + .iir_coef[4].coef_b = {16490453, -32048020, 15620931}, + .iir_coef[4].coef_a = {16777216, -32048020, 15334169}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, #endif }; @@ -658,296 +699,284 @@ Filter4_A=[ 134217728, -255575175, 122217496]; */ - - -static const struct_anc_cfg POSSIBLY_UNUSED AncFirCoef_44p1k_mode0 = { - .anc_cfg_ff_l = { - // .total_gain = 440, - .total_gain =312, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FF_L, - - .iir_coef[0].coef_b={42465729, -84858529, 42392831}, - .iir_coef[0].coef_a={134217728, -268346271, 134128558}, - - .iir_coef[1].coef_b={136159949, -267039705, 130899919}, - .iir_coef[1].coef_a={134217728, -267039705, 132842140}, - - .iir_coef[2].coef_b={132746107, -263254540, 130599907}, - .iir_coef[2].coef_a={134217728, -263254540, 129128286}, - - .iir_coef[3].coef_b={131402980, -255575175, 125032243}, - .iir_coef[3].coef_a={ 134217728, -255575175, 122217496}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = +static const struct_anc_cfg POSSIBLY_UNUSED + AncFirCoef_44p1k_mode0 = { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, - .anc_cfg_ff_r = { - // .total_gain = 382, - .total_gain = 288, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FF_R, - - .iir_coef[0].coef_b={42465729, -84858529, 42392831}, - .iir_coef[0].coef_a={134217728, -268346271, 134128558}, - - .iir_coef[1].coef_b={136159949, -267039705, 130899919}, - .iir_coef[1].coef_a={134217728, -267039705, 132842140}, - - .iir_coef[2].coef_b={132746107, -263254540, 130599907}, - .iir_coef[2].coef_a={134217728, -263254540, 129128286}, - - .iir_coef[3].coef_b={131402980, -255575175, 125032243}, - .iir_coef[3].coef_a={ 134217728, -255575175, 122217496}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = - { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, + .anc_cfg_ff_l = + { + // .total_gain = 440, + .total_gain = 312, -/* + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FF_L, -Filter1_B=[ 26719020, -52852829, 26204379]; -Filter1_A=[ 134217728, -210410903, 76474119]; + .iir_coef[0].coef_b = {42465729, -84858529, 42392831}, + .iir_coef[0].coef_a = {134217728, -268346271, 134128558}, -Filter2_B=[ 138909433, -267471808, 128584365]; -Filter2_A=[ 134217728, -267471808, 133276071]; + .iir_coef[1].coef_b = {136159949, -267039705, 130899919}, + .iir_coef[1].coef_a = {134217728, -267039705, 132842140}, -Filter3_B=[ 134542733, -268138827, 133597115]; -Filter3_A=[ 134217728, -268138827, 133922120]; + .iir_coef[2].coef_b = {132746107, -263254540, 130599907}, + .iir_coef[2].coef_a = {134217728, -263254540, 129128286}, -Filter4_B=[ 133541379, -264235686, 130815458]; -Filter4_A=[ 134217728, -264235686, 130139109]; + .iir_coef[3].coef_b = {131402980, -255575175, 125032243}, + .iir_coef[3].coef_a = {134217728, -255575175, 122217496}, -*/ + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, - - .anc_cfg_fb_l = { - .total_gain = 511, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FB_L, - - .iir_coef[0].coef_b={26719020, -52852829, 26204379}, - .iir_coef[0].coef_a={134217728, -210410903, 76474119}, - - .iir_coef[1].coef_b={138909433, -267471808, 128584365}, - .iir_coef[1].coef_a={134217728, -267471808, 133276071}, - - .iir_coef[2].coef_b={134542733, -268138827, 133597115}, - .iir_coef[2].coef_a={134217728, -268138827, 133922120}, - - .iir_coef[3].coef_b={133541379, -264235686, 130815458}, - .iir_coef[3].coef_a={134217728, -264235686, 130139109}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = - { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, - .anc_cfg_fb_r = { - .total_gain = 511, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FB_R, - - .iir_coef[0].coef_b={26719020, -52852829, 26204379}, - .iir_coef[0].coef_a={134217728, -210410903, 76474119}, - - .iir_coef[1].coef_b={138909433, -267471808, 128584365}, - .iir_coef[1].coef_a={134217728, -267471808, 133276071}, - - .iir_coef[2].coef_b={134542733, -268138827, 133597115}, - .iir_coef[2].coef_a={134217728, -268138827, 133922120}, - - .iir_coef[3].coef_b={133541379, -264235686, 130815458}, - .iir_coef[3].coef_a={134217728, -264235686, 130139109}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = - { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + .anc_cfg_ff_r = + { + // .total_gain = 382, + .total_gain = 288, + + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FF_R, + + .iir_coef[0].coef_b = {42465729, -84858529, 42392831}, + .iir_coef[0].coef_a = {134217728, -268346271, 134128558}, + + .iir_coef[1].coef_b = {136159949, -267039705, 130899919}, + .iir_coef[1].coef_a = {134217728, -267039705, 132842140}, + + .iir_coef[2].coef_b = {132746107, -263254540, 130599907}, + .iir_coef[2].coef_a = {134217728, -263254540, 129128286}, + + .iir_coef[3].coef_b = {131402980, -255575175, 125032243}, + .iir_coef[3].coef_a = {134217728, -255575175, 122217496}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + + /* + + Filter1_B=[ 26719020, -52852829, 26204379]; + Filter1_A=[ 134217728, -210410903, 76474119]; + + Filter2_B=[ 138909433, -267471808, 128584365]; + Filter2_A=[ 134217728, -267471808, 133276071]; + + Filter3_B=[ 134542733, -268138827, 133597115]; + Filter3_A=[ 134217728, -268138827, 133922120]; + + Filter4_B=[ 133541379, -264235686, 130815458]; + Filter4_A=[ 134217728, -264235686, 130139109]; + + */ + + .anc_cfg_fb_l = + { + .total_gain = 511, + + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FB_L, + + .iir_coef[0].coef_b = {26719020, -52852829, 26204379}, + .iir_coef[0].coef_a = {134217728, -210410903, 76474119}, + + .iir_coef[1].coef_b = {138909433, -267471808, 128584365}, + .iir_coef[1].coef_a = {134217728, -267471808, 133276071}, + + .iir_coef[2].coef_b = {134542733, -268138827, 133597115}, + .iir_coef[2].coef_a = {134217728, -268138827, 133922120}, + + .iir_coef[3].coef_b = {133541379, -264235686, 130815458}, + .iir_coef[3].coef_a = {134217728, -264235686, 130139109}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + .anc_cfg_fb_r = + { + .total_gain = 511, + + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FB_R, + + .iir_coef[0].coef_b = {26719020, -52852829, 26204379}, + .iir_coef[0].coef_a = {134217728, -210410903, 76474119}, + + .iir_coef[1].coef_b = {138909433, -267471808, 128584365}, + .iir_coef[1].coef_a = {134217728, -267471808, 133276071}, + + .iir_coef[2].coef_b = {134542733, -268138827, 133597115}, + .iir_coef[2].coef_a = {134217728, -268138827, 133922120}, + + .iir_coef[3].coef_b = {133541379, -264235686, 130815458}, + .iir_coef[3].coef_a = {134217728, -264235686, 130139109}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, #if (AUD_SECTION_STRUCT_VERSION == 2) + /* + Filter1_B=[ 19847881, -39594823, 19747071]; + Filter1_A=[ 16777216, -33314517, 16538159]; -/* + Filter2_B=[ 9442890, -16603187, 7330251]; + Filter2_A=[ 16777216, -16603187, -4075]; -Filter1_B=[ 19847881, -39594823, 19747071]; -Filter1_A=[ 16777216, -33314517, 16538159]; + Filter3_B=[ 18107639, -32779315, 14701642]; + Filter3_A=[ 16777216, -32779315, 16032065]; -Filter2_B=[ 9442890, -16603187, 7330251]; -Filter2_A=[ 16777216, -16603187, -4075]; + Filter4_B=[ 12666347, -24058210, 11437046]; + Filter4_A=[ 16777216, -32089673, 15357640]; -Filter3_B=[ 18107639, -32779315, 14701642]; -Filter3_A=[ 16777216, -32779315, 16032065]; + Filter5_B=[ 16466312, -31915122, 15523589]; + Filter5_A=[ 16777216, -31915122, 15212684]; + */ -Filter4_B=[ 12666347, -24058210, 11437046]; -Filter4_A=[ 16777216, -32089673, 15357640]; + .anc_cfg_mc_l = + { + .total_gain = 1228, -Filter5_B=[ 16466312, -31915122, 15523589]; -Filter5_A=[ 16777216, -31915122, 15212684]; -*/ + .iir_bypass_flag = 0, + .iir_counter = 5, + .iir_coef[0].coef_b = {19847881, -39594823, 19747071}, + .iir_coef[0].coef_a = {16777216, -33314517, 16538159}, + .iir_coef[1].coef_b = {9442890, -16603187, 7330251}, + .iir_coef[1].coef_a = {16777216, -16603187, -4075}, + .iir_coef[2].coef_b = {18107639, -32779315, 14701642}, + .iir_coef[2].coef_a = {16777216, -32779315, 16032065}, - .anc_cfg_mc_l = { - .total_gain = 1228, - - .iir_bypass_flag=0, - .iir_counter=5, - - .iir_coef[0].coef_b={19847881, -39594823, 19747071}, - .iir_coef[0].coef_a={16777216, -33314517, 16538159}, - - .iir_coef[1].coef_b={9442890, -16603187, 7330251}, - .iir_coef[1].coef_a={16777216, -16603187, -4075}, - - .iir_coef[2].coef_b={18107639, -32779315, 14701642}, - .iir_coef[2].coef_a={16777216, -32779315, 16032065}, - - .iir_coef[3].coef_b={12666347, -24058210, 11437046}, - .iir_coef[3].coef_a={16777216, -32089673, 15357640}, - - .iir_coef[4].coef_b={16466312, -31915122, 15523589}, - .iir_coef[4].coef_a={16777216, -31915122, 15212684}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - + .iir_coef[3].coef_b = {12666347, -24058210, 11437046}, + .iir_coef[3].coef_a = {16777216, -32089673, 15357640}, - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, - .anc_cfg_mc_r = { - .total_gain = 1331, - - .iir_bypass_flag=0, - .iir_counter=5, - - .iir_coef[0].coef_b={19847881, -39594823, 19747071}, - .iir_coef[0].coef_a={16777216, -33314517, 16538159}, - - .iir_coef[1].coef_b={9442890, -16603187, 7330251}, - .iir_coef[1].coef_a={16777216, -16603187, -4075}, - - .iir_coef[2].coef_b={18107639, -32779315, 14701642}, - .iir_coef[2].coef_a={16777216, -32779315, 16032065}, - - .iir_coef[3].coef_b={12666347, -24058210, 11437046}, - .iir_coef[3].coef_a={16777216, -32089673, 15357640}, - - .iir_coef[4].coef_b={16466312, -31915122, 15523589}, - .iir_coef[4].coef_a={16777216, -31915122, 15212684}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - + .iir_coef[4].coef_b = {16466312, -31915122, 15523589}, + .iir_coef[4].coef_a = {16777216, -31915122, 15212684}, - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + .anc_cfg_mc_r = + { + .total_gain = 1331, + + .iir_bypass_flag = 0, + .iir_counter = 5, + + .iir_coef[0].coef_b = {19847881, -39594823, 19747071}, + .iir_coef[0].coef_a = {16777216, -33314517, 16538159}, + + .iir_coef[1].coef_b = {9442890, -16603187, 7330251}, + .iir_coef[1].coef_a = {16777216, -16603187, -4075}, + + .iir_coef[2].coef_b = {18107639, -32779315, 14701642}, + .iir_coef[2].coef_a = {16777216, -32779315, 16032065}, + + .iir_coef[3].coef_b = {12666347, -24058210, 11437046}, + .iir_coef[3].coef_a = {16777216, -32089673, 15357640}, + + .iir_coef[4].coef_b = {16466312, -31915122, 15523589}, + .iir_coef[4].coef_a = {16777216, -31915122, 15212684}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, #endif }; -const struct_anc_cfg * anc_coef_list_50p7k[ANC_COEF_LIST_NUM] = { +const struct_anc_cfg *anc_coef_list_50p7k[ANC_COEF_LIST_NUM] = { &AncFirCoef_50p7k_mode0, #if (ANC_COEF_LIST_NUM == 2) &AncFirCoef_50p7k_mode0, #endif -#if(ANC_COEF_LIST_NUM == 3) - &AncFirCoef_50p7k_mode0, - &AncFirCoef_50p7k_mode0, +#if (ANC_COEF_LIST_NUM == 3) + &AncFirCoef_50p7k_mode0, &AncFirCoef_50p7k_mode0, #endif -#if(ANC_COEF_LIST_NUM == 4) - &AncFirCoef_50p7k_mode0, - &AncFirCoef_50p7k_mode0, - &AncFirCoef_50p7k_mode0, +#if (ANC_COEF_LIST_NUM == 4) + &AncFirCoef_50p7k_mode0, &AncFirCoef_50p7k_mode0, &AncFirCoef_50p7k_mode0, #endif }; -const struct_anc_cfg * anc_coef_list_48k[ANC_COEF_LIST_NUM] = { +const struct_anc_cfg *anc_coef_list_48k[ANC_COEF_LIST_NUM] = { &AncFirCoef_48k_mode0, #if (ANC_COEF_LIST_NUM == 2) &AncFirCoef_48k_mode0, #endif -#if(ANC_COEF_LIST_NUM == 3) - &AncFirCoef_48k_mode0, - &AncFirCoef_48k_mode0, +#if (ANC_COEF_LIST_NUM == 3) + &AncFirCoef_48k_mode0, &AncFirCoef_48k_mode0, #endif -#if(ANC_COEF_LIST_NUM == 4) - &AncFirCoef_48k_mode0, - &AncFirCoef_48k_mode0, - &AncFirCoef_48k_mode0, +#if (ANC_COEF_LIST_NUM == 4) + &AncFirCoef_48k_mode0, &AncFirCoef_48k_mode0, &AncFirCoef_48k_mode0, #endif }; -const struct_anc_cfg * anc_coef_list_44p1k[ANC_COEF_LIST_NUM] = { +const struct_anc_cfg *anc_coef_list_44p1k[ANC_COEF_LIST_NUM] = { &AncFirCoef_44p1k_mode0, #if (ANC_COEF_LIST_NUM == 2) &AncFirCoef_44p1k_mode0, #endif -#if(ANC_COEF_LIST_NUM == 3) - &AncFirCoef_44p1k_mode0, - &AncFirCoef_44p1k_mode0, +#if (ANC_COEF_LIST_NUM == 3) + &AncFirCoef_44p1k_mode0, &AncFirCoef_44p1k_mode0, #endif -#if(ANC_COEF_LIST_NUM == 4) - &AncFirCoef_44p1k_mode0, - &AncFirCoef_44p1k_mode0, - &AncFirCoef_44p1k_mode0, +#if (ANC_COEF_LIST_NUM == 4) + &AncFirCoef_44p1k_mode0, &AncFirCoef_44p1k_mode0, &AncFirCoef_44p1k_mode0, #endif }; @@ -955,122 +984,103 @@ const IIR_CFG_T audio_eq_sw_iir_cfg = { .gain0 = 0, .gain1 = 0, .num = 5, - .param = { - {IIR_TYPE_PEAK, .0, 200, 2}, - {IIR_TYPE_PEAK, .0, 600, 2}, - {IIR_TYPE_PEAK, .0, 2000.0, 2}, - {IIR_TYPE_PEAK, .0, 6000.0, 2}, - {IIR_TYPE_PEAK, .0, 12000.0, 2} - } -}; + .param = {{IIR_TYPE_PEAK, .0, 200, 2}, + {IIR_TYPE_PEAK, .0, 600, 2}, + {IIR_TYPE_PEAK, .0, 2000.0, 2}, + {IIR_TYPE_PEAK, .0, 6000.0, 2}, + {IIR_TYPE_PEAK, .0, 12000.0, 2}}}; -const IIR_CFG_T * const audio_eq_sw_iir_cfg_list[EQ_SW_IIR_LIST_NUM]={ +const IIR_CFG_T *const audio_eq_sw_iir_cfg_list[EQ_SW_IIR_LIST_NUM] = { &audio_eq_sw_iir_cfg, }; -const FIR_CFG_T audio_eq_hw_fir_cfg_44p1k = { - .gain = 0.0f, - .len = 384, - .coef = - { - (1<<23)-1, - } -}; +const FIR_CFG_T audio_eq_hw_fir_cfg_44p1k = {.gain = 0.0f, + .len = 384, + .coef = { + (1 << 23) - 1, + }}; -const FIR_CFG_T audio_eq_hw_fir_cfg_48k = { - .gain = 0.0f, - .len = 384, - .coef = - { - (1<<23)-1, - } -}; +const FIR_CFG_T audio_eq_hw_fir_cfg_48k = {.gain = 0.0f, + .len = 384, + .coef = { + (1 << 23) - 1, + }}; +const FIR_CFG_T audio_eq_hw_fir_cfg_96k = {.gain = 0.0f, + .len = 384, + .coef = { + (1 << 23) - 1, + }}; -const FIR_CFG_T audio_eq_hw_fir_cfg_96k = { - .gain = 0.0f, - .len = 384, - .coef = - { - (1<<23)-1, - } -}; - -const FIR_CFG_T * const audio_eq_hw_fir_cfg_list[EQ_HW_FIR_LIST_NUM]={ +const FIR_CFG_T *const audio_eq_hw_fir_cfg_list[EQ_HW_FIR_LIST_NUM] = { &audio_eq_hw_fir_cfg_44p1k, &audio_eq_hw_fir_cfg_48k, - &audio_eq_hw_fir_cfg_96k, + &audio_eq_hw_fir_cfg_96k, }; -//hardware dac iir eq -const IIR_CFG_T audio_eq_hw_dac_iir_cfg = { - .gain0 = 0, - .gain1 = 0, - .num = 8, - .param = { - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - } +// hardware dac iir eq +const IIR_CFG_T audio_eq_hw_dac_iir_cfg = {.gain0 = 0, + .gain1 = 0, + .num = 8, + .param = { + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + }}; + +const IIR_CFG_T *const POSSIBLY_UNUSED + audio_eq_hw_dac_iir_cfg_list[EQ_HW_DAC_IIR_LIST_NUM] = { + &audio_eq_hw_dac_iir_cfg, }; -const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_dac_iir_cfg_list[EQ_HW_DAC_IIR_LIST_NUM]={ - &audio_eq_hw_dac_iir_cfg, -}; - -//hardware dac iir eq +// hardware dac iir eq const IIR_CFG_T audio_eq_hw_adc_iir_adc_cfg = { .gain0 = 0, .gain1 = 0, .num = 1, .param = { - {IIR_TYPE_PEAK, 0.0, 1000.0, 0.7}, - } + {IIR_TYPE_PEAK, 0.0, 1000.0, 0.7}, + }}; + +const IIR_CFG_T *const POSSIBLY_UNUSED + audio_eq_hw_adc_iir_cfg_list[EQ_HW_ADC_IIR_LIST_NUM] = { + &audio_eq_hw_adc_iir_adc_cfg, }; -const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_adc_iir_cfg_list[EQ_HW_ADC_IIR_LIST_NUM]={ - &audio_eq_hw_adc_iir_adc_cfg, +// hardware iir eq +const IIR_CFG_T audio_eq_hw_iir_cfg = {.gain0 = 0, + .gain1 = 0, + .num = 8, + .param = { + {IIR_TYPE_PEAK, -10.1, 100.0, 7}, + {IIR_TYPE_PEAK, -10.1, 400.0, 7}, + {IIR_TYPE_PEAK, -10.1, 700.0, 7}, + {IIR_TYPE_PEAK, -10.1, 1000.0, 7}, + {IIR_TYPE_PEAK, -10.1, 3000.0, 7}, + {IIR_TYPE_PEAK, -10.1, 5000.0, 7}, + {IIR_TYPE_PEAK, -10.1, 7000.0, 7}, + {IIR_TYPE_PEAK, -10.1, 9000.0, 7}, + + }}; + +const IIR_CFG_T *const POSSIBLY_UNUSED + audio_eq_hw_iir_cfg_list[EQ_HW_IIR_LIST_NUM] = { + &audio_eq_hw_iir_cfg, }; - - -//hardware iir eq -const IIR_CFG_T audio_eq_hw_iir_cfg = { - .gain0 = 0, - .gain1 = 0, - .num = 8, - .param = { - {IIR_TYPE_PEAK, -10.1, 100.0, 7}, - {IIR_TYPE_PEAK, -10.1, 400.0, 7}, - {IIR_TYPE_PEAK, -10.1, 700.0, 7}, - {IIR_TYPE_PEAK, -10.1, 1000.0, 7}, - {IIR_TYPE_PEAK, -10.1, 3000.0, 7}, - {IIR_TYPE_PEAK, -10.1, 5000.0, 7}, - {IIR_TYPE_PEAK, -10.1, 7000.0, 7}, - {IIR_TYPE_PEAK, -10.1, 9000.0, 7}, - - } -}; - -const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_iir_cfg_list[EQ_HW_IIR_LIST_NUM]={ - &audio_eq_hw_iir_cfg, -}; - -const DrcConfig audio_drc_cfg = { - .knee = 3, - .filter_type = {14, -1}, - .band_num = 2, - .look_ahead_time = 10, - .band_settings = { - {-20, 0, 2, 3, 3000, 1}, - {-20, 0, 2, 3, 3000, 1}, - } - }; +const DrcConfig audio_drc_cfg = {.knee = 3, + .filter_type = {14, -1}, + .band_num = 2, + .look_ahead_time = 10, + .band_settings = { + {-20, 0, 2, 3, 3000, 1}, + {-20, 0, 2, 3, 3000, 1}, + }}; const LimiterConfig audio_drc2_cfg = { .knee = 2, @@ -1086,4 +1096,3 @@ const SpectrumFixConfig audio_spectrum_cfg = { .freq_num = 9, .freq_list = {200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800}, }; - diff --git a/config/mic_alg/tgt_hardware.c b/config/mic_alg/tgt_hardware.c index 5fefb88..fa8dad5 100644 --- a/config/mic_alg/tgt_hardware.c +++ b/config/mic_alg/tgt_hardware.c @@ -14,190 +14,228 @@ * ****************************************************************************/ #include "tgt_hardware.h" -#include "iir_process.h" -#include "fir_process.h" #include "drc.h" +#include "fir_process.h" +#include "iir_process.h" #include "limiter.h" #include "spectrum_fix.h" const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_pinmux_pwl[CFG_HW_PLW_NUM] = { #if (CFG_HW_PLW_NUM > 0) - {HAL_IOMUX_PIN_LED2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_LED1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_LED2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_LED1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}, #endif }; #ifdef __APP_USE_LED_INDICATE_IBRT_STATUS__ const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_ibrt_indication_pinmux_pwl[3] = { - {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_LED1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VBAT, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_LED2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VBAT, HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_LED1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VBAT, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_LED2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VBAT, + HAL_IOMUX_PIN_PULLUP_ENABLE}, }; #endif #ifdef __KNOWLES const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_pinmux_uart[2] = { - {HAL_IOMUX_PIN_P2_2, HAL_IOMUX_FUNC_UART2_RX, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P2_3, HAL_IOMUX_FUNC_UART2_TX, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P2_2, HAL_IOMUX_FUNC_UART2_RX, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P2_3, HAL_IOMUX_FUNC_UART2_TX, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_NOPULL}, }; #endif -//adckey define +// adckey define const uint16_t CFG_HW_ADCKEY_MAP_TABLE[CFG_HW_ADCKEY_NUMBER] = { #if (CFG_HW_ADCKEY_NUMBER > 0) - HAL_KEY_CODE_FN9,HAL_KEY_CODE_FN8,HAL_KEY_CODE_FN7, - HAL_KEY_CODE_FN6,HAL_KEY_CODE_FN5,HAL_KEY_CODE_FN4, - HAL_KEY_CODE_FN3,HAL_KEY_CODE_FN2,HAL_KEY_CODE_FN1, + HAL_KEY_CODE_FN9, HAL_KEY_CODE_FN8, HAL_KEY_CODE_FN7, + HAL_KEY_CODE_FN6, HAL_KEY_CODE_FN5, HAL_KEY_CODE_FN4, + HAL_KEY_CODE_FN3, HAL_KEY_CODE_FN2, HAL_KEY_CODE_FN1, #endif }; -//gpiokey define -#define CFG_HW_GPIOKEY_DOWN_LEVEL (0) -#define CFG_HW_GPIOKEY_UP_LEVEL (1) +// gpiokey define +#define CFG_HW_GPIOKEY_DOWN_LEVEL (0) +#define CFG_HW_GPIOKEY_UP_LEVEL (1) const struct HAL_KEY_GPIOKEY_CFG_T cfg_hw_gpio_key_cfg[CFG_HW_GPIOKEY_NUM] = { -/* -#if (CFG_HW_GPIOKEY_NUM > 0) -#ifdef BES_AUDIO_DEV_Main_Board_9v0 - {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P0_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P0_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN4,{HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - //{HAL_KEY_CODE_FN5,{HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - // {HAL_KEY_CODE_FN6,{HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, -#else -#ifndef TPORTS_KEY_COEXIST - {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - // {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, -#else - {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, -#endif -#endif -#ifdef IS_MULTI_AI_ENABLED - //{HAL_KEY_CODE_FN13,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - //{HAL_KEY_CODE_FN14,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, -#endif -#endif -*/ - {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + /* + #if (CFG_HW_GPIOKEY_NUM > 0) + #ifdef BES_AUDIO_DEV_Main_Board_9v0 + {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P0_0, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P0_1, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN4,{HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + //{HAL_KEY_CODE_FN5,{HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + // {HAL_KEY_CODE_FN6,{HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, #else #ifndef + TPORTS_KEY_COEXIST {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, + HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, {HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P1_0, + HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, + // {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, #else + {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, #endif #endif + #ifdef IS_MULTI_AI_ENABLED + //{HAL_KEY_CODE_FN13,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + //{HAL_KEY_CODE_FN14,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, #endif #endif + */ + {HAL_KEY_CODE_FN1, + {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, }; -//bt config +// bt config const char *BT_LOCAL_NAME = TO_STRING(BT_DEV_NAME) "\0"; const char *BLE_DEFAULT_NAME = "BES_BLE"; uint8_t ble_addr[6] = { #ifdef BLE_DEV_ADDR - BLE_DEV_ADDR + BLE_DEV_ADDR #else - 0xBE,0x99,0x34,0x45,0x56,0x67 + 0xBE, 0x99, 0x34, 0x45, + 0x56, 0x67 #endif }; uint8_t bt_addr[6] = { #ifdef BT_DEV_ADDR - BT_DEV_ADDR + BT_DEV_ADDR #else - 0x1e,0x57,0x34,0x45,0x56,0x67 + 0x1e, 0x57, 0x34, 0x45, + 0x56, 0x67 #endif }; -//audio config -//freq bands range {[0k:2.5K], [2.5k:5K], [5k:7.5K], [7.5K:10K], [10K:12.5K], [12.5K:15K], [15K:17.5K], [17.5K:20K]} -//gain range -12~+12 -const int8_t cfg_aud_eq_sbc_band_settings[CFG_HW_AUD_EQ_NUM_BANDS] = {0, 0, 0, 0, 0, 0, 0, 0}; +// audio config +// freq bands range {[0k:2.5K], [2.5k:5K], [5k:7.5K], [7.5K:10K], [10K:12.5K], +// [12.5K:15K], [15K:17.5K], [17.5K:20K]} gain range -12~+12 +const int8_t cfg_aud_eq_sbc_band_settings[CFG_HW_AUD_EQ_NUM_BANDS] = { + 0, 0, 0, 0, 0, 0, 0, 0}; -#define TX_PA_GAIN CODEC_TX_PA_GAIN_DEFAULT +#define TX_PA_GAIN CODEC_TX_PA_GAIN_DEFAULT const struct CODEC_DAC_VOL_T codec_dac_vol[TGT_VOLUME_LEVEL_QTY] = { - {TX_PA_GAIN,0x03,-21}, - {TX_PA_GAIN,0x03,-99}, - {TX_PA_GAIN,0x03,-45}, - {TX_PA_GAIN,0x03,-42}, - {TX_PA_GAIN,0x03,-39}, - {TX_PA_GAIN,0x03,-36}, - {TX_PA_GAIN,0x03,-33}, - {TX_PA_GAIN,0x03,-30}, - {TX_PA_GAIN,0x03,-27}, - {TX_PA_GAIN,0x03,-24}, - {TX_PA_GAIN,0x03,-21}, - {TX_PA_GAIN,0x03,-18}, - {TX_PA_GAIN,0x03,-15}, - {TX_PA_GAIN,0x03,-12}, - {TX_PA_GAIN,0x03, -9}, - {TX_PA_GAIN,0x03, -6}, - {TX_PA_GAIN,0x03, -3}, - {TX_PA_GAIN,0x03, 0}, //0dBm + {TX_PA_GAIN, 0x03, -21}, {TX_PA_GAIN, 0x03, -99}, + {TX_PA_GAIN, 0x03, -45}, {TX_PA_GAIN, 0x03, -42}, + {TX_PA_GAIN, 0x03, -39}, {TX_PA_GAIN, 0x03, -36}, + {TX_PA_GAIN, 0x03, -33}, {TX_PA_GAIN, 0x03, -30}, + {TX_PA_GAIN, 0x03, -27}, {TX_PA_GAIN, 0x03, -24}, + {TX_PA_GAIN, 0x03, -21}, {TX_PA_GAIN, 0x03, -18}, + {TX_PA_GAIN, 0x03, -15}, {TX_PA_GAIN, 0x03, -12}, + {TX_PA_GAIN, 0x03, -9}, {TX_PA_GAIN, 0x03, -6}, + {TX_PA_GAIN, 0x03, -3}, {TX_PA_GAIN, 0x03, 0}, // 0dBm }; #if SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 2 -#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC2|AUD_VMIC_MAP_VMIC3) +#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC2 | \ + AUD_VMIC_MAP_VMIC3) #elif SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 3 -#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1 | AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC1) +#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1 | AUD_CHANNEL_MAP_CH4 | \ + AUD_VMIC_MAP_VMIC1) #else -#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC3) +#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV \ + (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC3) #endif -#define CFG_HW_AUD_INPUT_PATH_LINEIN_DEV (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1) +#define CFG_HW_AUD_INPUT_PATH_LINEIN_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1) #ifdef VOICE_DETECTOR_EN -#define CFG_HW_AUD_INPUT_PATH_VADMIC_DEV (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC1) +#define CFG_HW_AUD_INPUT_PATH_VADMIC_DEV \ + (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC1) #else -#define CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC3) +#define CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV \ + (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC3) #endif -const struct AUD_IO_PATH_CFG_T cfg_audio_input_path_cfg[CFG_HW_AUD_INPUT_PATH_NUM] = { +const struct AUD_IO_PATH_CFG_T + cfg_audio_input_path_cfg[CFG_HW_AUD_INPUT_PATH_NUM] = { #if defined(SPEECH_TX_AEC_CODEC_REF) - // NOTE: If enable Ch5 and CH6, need to add channel_num when setup audioflinger stream - { AUD_INPUT_PATH_MAINMIC, CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV | AUD_CHANNEL_MAP_CH4, }, + // NOTE: If enable Ch5 and CH6, need to add channel_num when setup + // audioflinger stream + { + AUD_INPUT_PATH_MAINMIC, + CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV | AUD_CHANNEL_MAP_CH4, + }, #else - { AUD_INPUT_PATH_MAINMIC, CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV, }, + { + AUD_INPUT_PATH_MAINMIC, + CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV, + }, #endif - { AUD_INPUT_PATH_LINEIN, CFG_HW_AUD_INPUT_PATH_LINEIN_DEV, }, + { + AUD_INPUT_PATH_LINEIN, + CFG_HW_AUD_INPUT_PATH_LINEIN_DEV, + }, #ifdef VOICE_DETECTOR_EN - { AUD_INPUT_PATH_VADMIC, CFG_HW_AUD_INPUT_PATH_VADMIC_DEV, }, + { + AUD_INPUT_PATH_VADMIC, + CFG_HW_AUD_INPUT_PATH_VADMIC_DEV, + }, #else - { AUD_INPUT_PATH_ASRMIC, CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV, }, + { + AUD_INPUT_PATH_ASRMIC, + CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV, + }, #endif }; -const struct HAL_IOMUX_PIN_FUNCTION_MAP MuteOutPwl ={ - HAL_IOMUX_PIN_P1_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_NOPULL -}; +const struct HAL_IOMUX_PIN_FUNCTION_MAP MuteOutPwl = { + HAL_IOMUX_PIN_P1_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_NOPULL}; const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_enable_cfg = { - HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; + HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_detecter_cfg = { - HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; + HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; -const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_indicator_cfg = { - HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; +const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_indicator_cfg = + {HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; -const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_tws_channel_cfg = { - HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE//HAL_IOMUX_PIN_P1_5 500:HAL_IOMUX_PIN_P2_5 +const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_tws_channel_cfg = { + HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE // HAL_IOMUX_PIN_P1_5 + // 500:HAL_IOMUX_PIN_P2_5 }; /* const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_INT ={ - HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE + HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, +HAL_IOMUX_PIN_PULLUP_ENABLE }; */ -const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SDA ={ - HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; +const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SDA = { + HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; -const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SCL ={ - HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; -bool tgt_tws_get_channel_is_right(void) -{ +const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SCL = { + HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; +bool tgt_tws_get_channel_is_right(void) { #ifdef __FIXED_TWS_EAR_SIDE__ - return TWS_EAR_SIDE_ROLE; + return TWS_EAR_SIDE_ROLE; #else - return hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)cfg_hw_tws_channel_cfg.pin); + return hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)cfg_hw_tws_channel_cfg.pin); #endif } @@ -205,122 +243,103 @@ const IIR_CFG_T audio_eq_sw_iir_cfg = { .gain0 = 0, .gain1 = 0, .num = 5, - .param = { - {IIR_TYPE_PEAK, .0, 200, 2}, - {IIR_TYPE_PEAK, .0, 600, 2}, - {IIR_TYPE_PEAK, .0, 2000.0, 2}, - {IIR_TYPE_PEAK, .0, 6000.0, 2}, - {IIR_TYPE_PEAK, .0, 12000.0, 2} - } -}; + .param = {{IIR_TYPE_PEAK, .0, 200, 2}, + {IIR_TYPE_PEAK, .0, 600, 2}, + {IIR_TYPE_PEAK, .0, 2000.0, 2}, + {IIR_TYPE_PEAK, .0, 6000.0, 2}, + {IIR_TYPE_PEAK, .0, 12000.0, 2}}}; -const IIR_CFG_T * const audio_eq_sw_iir_cfg_list[EQ_SW_IIR_LIST_NUM]={ +const IIR_CFG_T *const audio_eq_sw_iir_cfg_list[EQ_SW_IIR_LIST_NUM] = { &audio_eq_sw_iir_cfg, }; -const FIR_CFG_T audio_eq_hw_fir_cfg_44p1k = { - .gain = 0.0f, - .len = 384, - .coef = - { - (1<<23)-1, - } -}; +const FIR_CFG_T audio_eq_hw_fir_cfg_44p1k = {.gain = 0.0f, + .len = 384, + .coef = { + (1 << 23) - 1, + }}; -const FIR_CFG_T audio_eq_hw_fir_cfg_48k = { - .gain = 0.0f, - .len = 384, - .coef = - { - (1<<23)-1, - } -}; +const FIR_CFG_T audio_eq_hw_fir_cfg_48k = {.gain = 0.0f, + .len = 384, + .coef = { + (1 << 23) - 1, + }}; +const FIR_CFG_T audio_eq_hw_fir_cfg_96k = {.gain = 0.0f, + .len = 384, + .coef = { + (1 << 23) - 1, + }}; -const FIR_CFG_T audio_eq_hw_fir_cfg_96k = { - .gain = 0.0f, - .len = 384, - .coef = - { - (1<<23)-1, - } -}; - -const FIR_CFG_T * const audio_eq_hw_fir_cfg_list[EQ_HW_FIR_LIST_NUM]={ +const FIR_CFG_T *const audio_eq_hw_fir_cfg_list[EQ_HW_FIR_LIST_NUM] = { &audio_eq_hw_fir_cfg_44p1k, &audio_eq_hw_fir_cfg_48k, - &audio_eq_hw_fir_cfg_96k, + &audio_eq_hw_fir_cfg_96k, }; -//hardware dac iir eq -const IIR_CFG_T audio_eq_hw_dac_iir_cfg = { - .gain0 = 0, - .gain1 = 0, - .num = 8, - .param = { - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, - } +// hardware dac iir eq +const IIR_CFG_T audio_eq_hw_dac_iir_cfg = {.gain0 = 0, + .gain1 = 0, + .num = 8, + .param = { + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + {IIR_TYPE_PEAK, 0, 1000.0, 0.7}, + }}; + +const IIR_CFG_T *const POSSIBLY_UNUSED + audio_eq_hw_dac_iir_cfg_list[EQ_HW_DAC_IIR_LIST_NUM] = { + &audio_eq_hw_dac_iir_cfg, }; -const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_dac_iir_cfg_list[EQ_HW_DAC_IIR_LIST_NUM]={ - &audio_eq_hw_dac_iir_cfg, -}; - -//hardware dac iir eq +// hardware dac iir eq const IIR_CFG_T audio_eq_hw_adc_iir_adc_cfg = { .gain0 = 0, .gain1 = 0, .num = 1, .param = { - {IIR_TYPE_PEAK, 0.0, 1000.0, 0.7}, - } + {IIR_TYPE_PEAK, 0.0, 1000.0, 0.7}, + }}; + +const IIR_CFG_T *const POSSIBLY_UNUSED + audio_eq_hw_adc_iir_cfg_list[EQ_HW_ADC_IIR_LIST_NUM] = { + &audio_eq_hw_adc_iir_adc_cfg, }; -const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_adc_iir_cfg_list[EQ_HW_ADC_IIR_LIST_NUM]={ - &audio_eq_hw_adc_iir_adc_cfg, +// hardware iir eq +const IIR_CFG_T audio_eq_hw_iir_cfg = {.gain0 = 0, + .gain1 = 0, + .num = 8, + .param = { + {IIR_TYPE_PEAK, -10.1, 100.0, 7}, + {IIR_TYPE_PEAK, -10.1, 400.0, 7}, + {IIR_TYPE_PEAK, -10.1, 700.0, 7}, + {IIR_TYPE_PEAK, -10.1, 1000.0, 7}, + {IIR_TYPE_PEAK, -10.1, 3000.0, 7}, + {IIR_TYPE_PEAK, -10.1, 5000.0, 7}, + {IIR_TYPE_PEAK, -10.1, 7000.0, 7}, + {IIR_TYPE_PEAK, -10.1, 9000.0, 7}, + + }}; + +const IIR_CFG_T *const POSSIBLY_UNUSED + audio_eq_hw_iir_cfg_list[EQ_HW_IIR_LIST_NUM] = { + &audio_eq_hw_iir_cfg, }; - - -//hardware iir eq -const IIR_CFG_T audio_eq_hw_iir_cfg = { - .gain0 = 0, - .gain1 = 0, - .num = 8, - .param = { - {IIR_TYPE_PEAK, -10.1, 100.0, 7}, - {IIR_TYPE_PEAK, -10.1, 400.0, 7}, - {IIR_TYPE_PEAK, -10.1, 700.0, 7}, - {IIR_TYPE_PEAK, -10.1, 1000.0, 7}, - {IIR_TYPE_PEAK, -10.1, 3000.0, 7}, - {IIR_TYPE_PEAK, -10.1, 5000.0, 7}, - {IIR_TYPE_PEAK, -10.1, 7000.0, 7}, - {IIR_TYPE_PEAK, -10.1, 9000.0, 7}, - - } -}; - -const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_iir_cfg_list[EQ_HW_IIR_LIST_NUM]={ - &audio_eq_hw_iir_cfg, -}; - -const DrcConfig audio_drc_cfg = { - .knee = 3, - .filter_type = {14, -1}, - .band_num = 2, - .look_ahead_time = 10, - .band_settings = { - {-20, 0, 2, 3, 3000, 1}, - {-20, 0, 2, 3, 3000, 1}, - } - }; +const DrcConfig audio_drc_cfg = {.knee = 3, + .filter_type = {14, -1}, + .band_num = 2, + .look_ahead_time = 10, + .band_settings = { + {-20, 0, 2, 3, 3000, 1}, + {-20, 0, 2, 3, 3000, 1}, + }}; const LimiterConfig audio_drc2_cfg = { .knee = 2, @@ -336,4 +355,3 @@ const SpectrumFixConfig audio_spectrum_cfg = { .freq_num = 9, .freq_list = {200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800}, }; - diff --git a/config/open_source/tgt_hardware.c b/config/open_source/tgt_hardware.c index ee525cd..3a22426 100644 --- a/config/open_source/tgt_hardware.c +++ b/config/open_source/tgt_hardware.c @@ -15,105 +15,123 @@ ****************************************************************************/ #include "tgt_hardware.h" #include "aud_section.h" -#include "iir_process.h" -#include "fir_process.h" #include "drc.h" +#include "fir_process.h" +#include "iir_process.h" #include "limiter.h" #include "spectrum_fix.h" const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_pinmux_pwl[CFG_HW_PLW_NUM] = { #if (CFG_HW_PLW_NUM > 0) - {HAL_IOMUX_PIN_LED2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_LED1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_LED2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_LED1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}, #endif }; #ifdef __APP_USE_LED_INDICATE_IBRT_STATUS__ const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_ibrt_indication_pinmux_pwl[3] = { - {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_LED1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VBAT, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_LED2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VBAT, HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_LED1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VBAT, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_LED2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VBAT, + HAL_IOMUX_PIN_PULLUP_ENABLE}, }; #endif #ifdef __KNOWLES const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_pinmux_uart[2] = { - {HAL_IOMUX_PIN_P2_2, HAL_IOMUX_FUNC_UART2_RX, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P2_3, HAL_IOMUX_FUNC_UART2_TX, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P2_2, HAL_IOMUX_FUNC_UART2_RX, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P2_3, HAL_IOMUX_FUNC_UART2_TX, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_NOPULL}, }; #endif -//adckey define +// adckey define const uint16_t CFG_HW_ADCKEY_MAP_TABLE[CFG_HW_ADCKEY_NUMBER] = { #if (CFG_HW_ADCKEY_NUMBER > 0) - HAL_KEY_CODE_FN9,HAL_KEY_CODE_FN8,HAL_KEY_CODE_FN7, - HAL_KEY_CODE_FN6,HAL_KEY_CODE_FN5,HAL_KEY_CODE_FN4, - HAL_KEY_CODE_FN3,HAL_KEY_CODE_FN2,HAL_KEY_CODE_FN1, + HAL_KEY_CODE_FN9, HAL_KEY_CODE_FN8, HAL_KEY_CODE_FN7, + HAL_KEY_CODE_FN6, HAL_KEY_CODE_FN5, HAL_KEY_CODE_FN4, + HAL_KEY_CODE_FN3, HAL_KEY_CODE_FN2, HAL_KEY_CODE_FN1, #endif }; -//gpiokey define -#define CFG_HW_GPIOKEY_DOWN_LEVEL (0) -#define CFG_HW_GPIOKEY_UP_LEVEL (1) +// gpiokey define +#define CFG_HW_GPIOKEY_DOWN_LEVEL (0) +#define CFG_HW_GPIOKEY_UP_LEVEL (1) const struct HAL_KEY_GPIOKEY_CFG_T cfg_hw_gpio_key_cfg[CFG_HW_GPIOKEY_NUM] = { -/* -#if (CFG_HW_GPIOKEY_NUM > 0) -#ifdef BES_AUDIO_DEV_Main_Board_9v0 - {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P0_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P0_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN4,{HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - //{HAL_KEY_CODE_FN5,{HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - // {HAL_KEY_CODE_FN6,{HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, -#else -#ifndef TPORTS_KEY_COEXIST - {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - // {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, -#else - {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - {HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, -#endif -#endif -#ifdef IS_MULTI_AI_ENABLED - //{HAL_KEY_CODE_FN13,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, - //{HAL_KEY_CODE_FN14,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, -#endif -#endif -*/ - // {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + /* + #if (CFG_HW_GPIOKEY_NUM > 0) + #ifdef BES_AUDIO_DEV_Main_Board_9v0 + {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P0_0, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P0_1, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN4,{HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + //{HAL_KEY_CODE_FN5,{HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + // {HAL_KEY_CODE_FN6,{HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, #else #ifndef + TPORTS_KEY_COEXIST {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, + HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, {HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P1_0, + HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}}, + // {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, #else + {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + {HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, #endif #endif + #ifdef IS_MULTI_AI_ENABLED + //{HAL_KEY_CODE_FN13,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, + //{HAL_KEY_CODE_FN14,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, #endif #endif + */ + // {HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, + // HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}}, }; -//bt config -//const char *BT_LOCAL_NAME = TO_STRING(BT_DEV_NAME) "\0"; +// bt config +// const char *BT_LOCAL_NAME = TO_STRING(BT_DEV_NAME) "\0"; const char *BT_LOCAL_NAME = "PineBuds Pro"; const char *BLE_DEFAULT_NAME = "BES_BLE"; uint8_t ble_addr[6] = { #ifdef BLE_DEV_ADDR - BLE_DEV_ADDR + BLE_DEV_ADDR #else - 0xBE,0x99,0x34,0x45,0x56,0x67 + 0xBE, 0x99, 0x34, 0x45, + 0x56, 0x67 #endif }; uint8_t bt_addr[6] = { #ifdef BT_DEV_ADDR - BT_DEV_ADDR + BT_DEV_ADDR #else - 0x1e,0x57,0x34,0x45,0x56,0x67 + 0x1e, 0x57, 0x34, 0x45, + 0x56, 0x67 #endif }; -const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_tws_channel_cfg = { - HAL_IOMUX_PIN_P1_4, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; +const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_tws_channel_cfg = { + HAL_IOMUX_PIN_P1_4, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; -bool tgt_tws_get_channel_is_right(void) -{ +bool tgt_tws_get_channel_is_right(void) { #ifdef __FIXED_TWS_EAR_SIDE__ - return TWS_EAR_SIDE_ROLE; + return TWS_EAR_SIDE_ROLE; #else - hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)&cfg_hw_tws_channel_cfg,1); + hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)&cfg_hw_tws_channel_cfg, + 1); // Pinebuds pull down to 0 for right ear, but float to 1 for left ear return (hal_gpio_pin_get_val( @@ -121,265 +139,282 @@ bool tgt_tws_get_channel_is_right(void) #endif } -//audio config -//freq bands range {[0k:2.5K], [2.5k:5K], [5k:7.5K], [7.5K:10K], [10K:12.5K], [12.5K:15K], [15K:17.5K], [17.5K:20K]} -//gain range -12~+12 -const int8_t cfg_aud_eq_sbc_band_settings[CFG_HW_AUD_EQ_NUM_BANDS] = {0, 0, 0, 0, 0, 0, 0, 0}; +// audio config +// freq bands range {[0k:2.5K], [2.5k:5K], [5k:7.5K], [7.5K:10K], [10K:12.5K], +// [12.5K:15K], [15K:17.5K], [17.5K:20K]} gain range -12~+12 +const int8_t cfg_aud_eq_sbc_band_settings[CFG_HW_AUD_EQ_NUM_BANDS] = { + 0, 0, 0, 0, 0, 0, 0, 0}; -#define TX_PA_GAIN CODEC_TX_PA_GAIN_DEFAULT +#define TX_PA_GAIN CODEC_TX_PA_GAIN_DEFAULT const struct CODEC_DAC_VOL_T codec_dac_vol[TGT_VOLUME_LEVEL_QTY] = { - {TX_PA_GAIN,0x03,-21}, - {TX_PA_GAIN,0x03,-99}, - {TX_PA_GAIN,0x03,-45}, - {TX_PA_GAIN,0x03,-42}, - {TX_PA_GAIN,0x03,-39}, - {TX_PA_GAIN,0x03,-36}, - {TX_PA_GAIN,0x03,-33}, - {TX_PA_GAIN,0x03,-30}, - {TX_PA_GAIN,0x03,-27}, - {TX_PA_GAIN,0x03,-24}, - {TX_PA_GAIN,0x03,-21}, - {TX_PA_GAIN,0x03,-18}, - {TX_PA_GAIN,0x03,-15}, - {TX_PA_GAIN,0x03,-12}, - {TX_PA_GAIN,0x03, -9}, - {TX_PA_GAIN,0x03, -6}, - {TX_PA_GAIN,0x03, -3}, - {TX_PA_GAIN,0x03, 0}, //0dBm + {TX_PA_GAIN, 0x03, -21}, {TX_PA_GAIN, 0x03, -99}, + {TX_PA_GAIN, 0x03, -45}, {TX_PA_GAIN, 0x03, -42}, + {TX_PA_GAIN, 0x03, -39}, {TX_PA_GAIN, 0x03, -36}, + {TX_PA_GAIN, 0x03, -33}, {TX_PA_GAIN, 0x03, -30}, + {TX_PA_GAIN, 0x03, -27}, {TX_PA_GAIN, 0x03, -24}, + {TX_PA_GAIN, 0x03, -21}, {TX_PA_GAIN, 0x03, -18}, + {TX_PA_GAIN, 0x03, -15}, {TX_PA_GAIN, 0x03, -12}, + {TX_PA_GAIN, 0x03, -9}, {TX_PA_GAIN, 0x03, -6}, + {TX_PA_GAIN, 0x03, -3}, {TX_PA_GAIN, 0x03, 0}, // 0dBm }; #if SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 2 -#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC2|AUD_VMIC_MAP_VMIC3) +#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC2 | \ + AUD_VMIC_MAP_VMIC3) #elif SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 3 -#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1 | AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC1) +#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1 | AUD_CHANNEL_MAP_CH4 | \ + AUD_VMIC_MAP_VMIC1) #else -#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC3) +#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV \ + (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC3) #endif -#define CFG_HW_AUD_INPUT_PATH_LINEIN_DEV (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1) +#define CFG_HW_AUD_INPUT_PATH_LINEIN_DEV \ + (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1) #ifdef VOICE_DETECTOR_EN -#define CFG_HW_AUD_INPUT_PATH_VADMIC_DEV (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC1) +#define CFG_HW_AUD_INPUT_PATH_VADMIC_DEV \ + (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC1) #else -#define CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC3) +#define CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV \ + (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC3) #endif -const struct AUD_IO_PATH_CFG_T cfg_audio_input_path_cfg[CFG_HW_AUD_INPUT_PATH_NUM] = { +const struct AUD_IO_PATH_CFG_T + cfg_audio_input_path_cfg[CFG_HW_AUD_INPUT_PATH_NUM] = { #if defined(SPEECH_TX_AEC_CODEC_REF) - // NOTE: If enable Ch5 and CH6, need to add channel_num when setup audioflinger stream - { AUD_INPUT_PATH_MAINMIC, CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV | AUD_CHANNEL_MAP_CH4, }, + // NOTE: If enable Ch5 and CH6, need to add channel_num when setup + // audioflinger stream + { + AUD_INPUT_PATH_MAINMIC, + CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV | AUD_CHANNEL_MAP_CH4, + }, #else - { AUD_INPUT_PATH_MAINMIC, CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV, }, + { + AUD_INPUT_PATH_MAINMIC, + CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV, + }, #endif - { AUD_INPUT_PATH_LINEIN, CFG_HW_AUD_INPUT_PATH_LINEIN_DEV, }, + { + AUD_INPUT_PATH_LINEIN, + CFG_HW_AUD_INPUT_PATH_LINEIN_DEV, + }, #ifdef VOICE_DETECTOR_EN - { AUD_INPUT_PATH_VADMIC, CFG_HW_AUD_INPUT_PATH_VADMIC_DEV, }, + { + AUD_INPUT_PATH_VADMIC, + CFG_HW_AUD_INPUT_PATH_VADMIC_DEV, + }, #else - { AUD_INPUT_PATH_ASRMIC, CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV, }, + { + AUD_INPUT_PATH_ASRMIC, + CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV, + }, #endif }; const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_enable_cfg = { - HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; + HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_detecter_cfg = { - HAL_IOMUX_PIN_P1_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; - -const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_indicator_cfg = { - HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE -}; + HAL_IOMUX_PIN_P1_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; +const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_indicator_cfg = + {HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; /* const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_INT ={ - HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE + HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, +HAL_IOMUX_PIN_PULLUP_ENABLE }; */ // const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SDA ={ -// HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE +// HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, +// HAL_IOMUX_PIN_PULLUP_ENABLE // }; // const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SCL ={ -// HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE +// HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, +// HAL_IOMUX_PIN_PULLUP_ENABLE // }; - - #define IIR_COUNTER_FF_L (6) #define IIR_COUNTER_FF_R (6) #define IIR_COUNTER_FB_L (5) #define IIR_COUNTER_FB_R (5) - -static const struct_anc_cfg POSSIBLY_UNUSED AncFirCoef_50p7k_mode0 = { - .anc_cfg_ff_l = { - // .total_gain = 440, - .total_gain = 350, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FF_L, - - .iir_coef[0].coef_b={42462788, -84862242, 42399478}, - .iir_coef[0].coef_a={134217728, -268358003, 134140286}, - - .iir_coef[1].coef_b={135905569, -267224817, 131334465}, - .iir_coef[1].coef_a={134217728, -267224817, 133022306}, - - .iir_coef[2].coef_b={132936489, -263935268, 131067941}, - .iir_coef[2].coef_a={134217728, -263935268, 129786702}, - - .iir_coef[3].coef_b={131758190, -257297054, 126191415}, - .iir_coef[3].coef_a={134217728, -257297054, 123731878}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = +static const struct_anc_cfg POSSIBLY_UNUSED + AncFirCoef_50p7k_mode0 = { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, - .anc_cfg_ff_r = { - // .total_gain = 382, - .total_gain = 350, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FF_R, - - .iir_coef[0].coef_b={42462788, -84862242, 42399478}, - .iir_coef[0].coef_a={134217728, -268358003, 134140286}, - - .iir_coef[1].coef_b={135905569, -267224817, 131334465}, - .iir_coef[1].coef_a={134217728, -267224817, 133022306}, - - .iir_coef[2].coef_b={132936489, -263935268, 131067941}, - .iir_coef[2].coef_a={134217728, -263935268, 129786702}, - - .iir_coef[3].coef_b={131758190, -257297054, 126191415}, - .iir_coef[3].coef_a={134217728, -257297054, 123731878}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = - { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, + .anc_cfg_ff_l = + { + // .total_gain = 440, + .total_gain = 350, + + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FF_L, + + .iir_coef[0].coef_b = {42462788, -84862242, 42399478}, + .iir_coef[0].coef_a = {134217728, -268358003, 134140286}, + + .iir_coef[1].coef_b = {135905569, -267224817, 131334465}, + .iir_coef[1].coef_a = {134217728, -267224817, 133022306}, + + .iir_coef[2].coef_b = {132936489, -263935268, 131067941}, + .iir_coef[2].coef_a = {134217728, -263935268, 129786702}, + + .iir_coef[3].coef_b = {131758190, -257297054, 126191415}, + .iir_coef[3].coef_a = {134217728, -257297054, 123731878}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + .anc_cfg_ff_r = + { + // .total_gain = 382, + .total_gain = 350, + + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FF_R, + + .iir_coef[0].coef_b = {42462788, -84862242, 42399478}, + .iir_coef[0].coef_a = {134217728, -268358003, 134140286}, + + .iir_coef[1].coef_b = {135905569, -267224817, 131334465}, + .iir_coef[1].coef_a = {134217728, -267224817, 133022306}, + + .iir_coef[2].coef_b = {132936489, -263935268, 131067941}, + .iir_coef[2].coef_a = {134217728, -263935268, 129786702}, + + .iir_coef[3].coef_b = {131758190, -257297054, 126191415}, + .iir_coef[3].coef_a = {134217728, -257297054, 123731878}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + + /* + + Filter1_B=[ 27461831, -54408898, 27001841]; + Filter1_A=[ 134217728, -216605724, 82606056]; + + Filter2_B=[ 138294078, -267600712, 129323227]; + Filter2_A=[ 134217728, -267600712, 133399577]; + + Filter3_B=[ 134500015, -268177932, 133678688]; + Filter3_A=[ 134217728, -268177932, 133960975]; + + Filter4_B=[ 133629164, -264794659, 131257050]; + Filter4_A=[ 134217728, -264794659, 130668486]; -/* + */ -Filter1_B=[ 27461831, -54408898, 27001841]; -Filter1_A=[ 134217728, -216605724, 82606056]; + .anc_cfg_fb_l = + { + .total_gain = 350, -Filter2_B=[ 138294078, -267600712, 129323227]; -Filter2_A=[ 134217728, -267600712, 133399577]; + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FB_L, -Filter3_B=[ 134500015, -268177932, 133678688]; -Filter3_A=[ 134217728, -268177932, 133960975]; + .iir_coef[0].coef_b = {27461831, -54408898, 27001841}, + .iir_coef[0].coef_a = {134217728, -216605724, 82606056}, -Filter4_B=[ 133629164, -264794659, 131257050]; -Filter4_A=[ 134217728, -264794659, 130668486]; + .iir_coef[1].coef_b = {138294078, -267600712, 129323227}, + .iir_coef[1].coef_a = {134217728, -267600712, 133399577}, + .iir_coef[2].coef_b = {134500015, -268177932, 133678688}, + .iir_coef[2].coef_a = {134217728, -268177932, 133960975}, -*/ - - .anc_cfg_fb_l = { - .total_gain = 350, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FB_L, - - .iir_coef[0].coef_b={ 27461831, -54408898, 27001841}, - .iir_coef[0].coef_a={134217728, -216605724, 82606056}, - - .iir_coef[1].coef_b={138294078, -267600712, 129323227}, - .iir_coef[1].coef_a={134217728, -267600712, 133399577}, - - .iir_coef[2].coef_b={134500015, -268177932, 133678688}, - .iir_coef[2].coef_a={134217728, -268177932, 133960975}, - - .iir_coef[3].coef_b={133629164, -264794659, 131257050}, - .iir_coef[3].coef_a={134217728, -264794659, 130668486}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = - { - 32767, - }, -*/ + .iir_coef[3].coef_b = {133629164, -264794659, 131257050}, + .iir_coef[3].coef_a = {134217728, -264794659, 130668486}, - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, - .anc_cfg_fb_r = { - .total_gain = 350, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FB_R, - - .iir_coef[0].coef_b={ 27461831, -54408898, 27001841}, - .iir_coef[0].coef_a={134217728, -216605724, 82606056}, - - .iir_coef[1].coef_b={138294078, -267600712, 129323227}, - .iir_coef[1].coef_a={134217728, -267600712, 133399577}, - - .iir_coef[2].coef_b={134500015, -268177932, 133678688}, - .iir_coef[2].coef_a={134217728, -268177932, 133960975}, - - .iir_coef[3].coef_b={133629164, -264794659, 131257050}, - .iir_coef[3].coef_a={134217728, -264794659, 130668486}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = - { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + .anc_cfg_fb_r = + { + .total_gain = 350, + + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FB_R, + + .iir_coef[0].coef_b = {27461831, -54408898, 27001841}, + .iir_coef[0].coef_a = {134217728, -216605724, 82606056}, + + .iir_coef[1].coef_b = {138294078, -267600712, 129323227}, + .iir_coef[1].coef_a = {134217728, -267600712, 133399577}, + + .iir_coef[2].coef_b = {134500015, -268177932, 133678688}, + .iir_coef[2].coef_a = {134217728, -268177932, 133960975}, + + .iir_coef[3].coef_b = {133629164, -264794659, 131257050}, + .iir_coef[3].coef_a = {134217728, -264794659, 130668486}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, - }; - /* //ff @@ -398,277 +433,278 @@ Filter4_B=[ 131621817, -256639526, 125746382]; Filter4_A=[ 134217728, -256639526, 123150471]; - -*/ - -static const struct_anc_cfg POSSIBLY_UNUSED AncFirCoef_48k_mode0 = { - .anc_cfg_ff_l = { - // .total_gain = 440, - .total_gain = 312, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FF_L, - - .iir_coef[0].coef_b={42463913, -84860822, 42396935}, - .iir_coef[0].coef_a={134217728, -268353516, 134135801}, - - .iir_coef[1].coef_b={136002894, -267154076, 131168209}, - .iir_coef[1].coef_a={134217728, -267154076, 132953376}, - - .iir_coef[2].coef_b={132863566, -263674901, 130888668}, - .iir_coef[2].coef_a={134217728, -263674901, 129534506}, - - .iir_coef[3].coef_b={131621817, -256639526, 125746382}, - .iir_coef[3].coef_a={134217728, -256639526, 123150471}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = - { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, - .anc_cfg_ff_r = { - // .total_gain = 382, - .total_gain = 288, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FF_R, - - .iir_coef[0].coef_b={42463913, -84860822, 42396935}, - .iir_coef[0].coef_a={134217728, -268353516, 134135801}, - - .iir_coef[1].coef_b={136002894, -267154076, 131168209}, - .iir_coef[1].coef_a={134217728, -267154076, 132953376}, - - .iir_coef[2].coef_b={132863566, -263674901, 130888668}, - .iir_coef[2].coef_a={134217728, -263674901, 129534506}, - - .iir_coef[3].coef_b={131621817, -256639526, 125746382}, - .iir_coef[3].coef_a={134217728, -256639526, 123150471}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = - { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, - - -/* - -Filter1_B=[ 27172676, -53803459, 26691412]; -Filter1_A=[ 134217728, -214195429, 80219070]; - -Filter2_B=[ 138529480, -267551490, 129040578]; -Filter2_A=[ 134217728, -267551490, 133352330]; - -Filter3_B=[ 134516353, -268162980, 133647489]; -Filter3_A=[ 134217728, -268162980, 133946114]; - -Filter4_B=[ 133595549, -264581113, 131087955]; -Filter4_A=[ 134217728, -264581113, 130465777]; - */ - - .anc_cfg_fb_l = { - .total_gain = 511, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FB_L, - - .iir_coef[0].coef_b={ 27172676, -53803459, 26691412}, - .iir_coef[0].coef_a={134217728, -214195429, 80219070}, - - .iir_coef[1].coef_b={138529480, -267551490, 129040578}, - .iir_coef[1].coef_a={134217728, -267551490, 133352330}, - - .iir_coef[2].coef_b={134516353, -268162980, 133647489}, - .iir_coef[2].coef_a={134217728, -268162980, 133946114}, - - .iir_coef[3].coef_b={133595549, -264581113, 131087955}, - .iir_coef[3].coef_a={134217728, -264581113, 130465777}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = + +static const struct_anc_cfg POSSIBLY_UNUSED + AncFirCoef_48k_mode0 = { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, - .anc_cfg_fb_r = { - .total_gain = 511, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FB_R, - - .iir_coef[0].coef_b={ 27172676, -53803459, 26691412}, - .iir_coef[0].coef_a={134217728, -214195429, 80219070}, - - .iir_coef[1].coef_b={138529480, -267551490, 129040578}, - .iir_coef[1].coef_a={134217728, -267551490, 133352330}, - - .iir_coef[2].coef_b={134516353, -268162980, 133647489}, - .iir_coef[2].coef_a={134217728, -268162980, 133946114}, - - .iir_coef[3].coef_b={133595549, -264581113, 131087955}, - .iir_coef[3].coef_a={134217728, -264581113, 130465777}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = - { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, + .anc_cfg_ff_l = + { + // .total_gain = 440, + .total_gain = 312, + + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FF_L, + + .iir_coef[0].coef_b = {42463913, -84860822, 42396935}, + .iir_coef[0].coef_a = {134217728, -268353516, 134135801}, + + .iir_coef[1].coef_b = {136002894, -267154076, 131168209}, + .iir_coef[1].coef_a = {134217728, -267154076, 132953376}, + + .iir_coef[2].coef_b = {132863566, -263674901, 130888668}, + .iir_coef[2].coef_a = {134217728, -263674901, 129534506}, + + .iir_coef[3].coef_b = {131621817, -256639526, 125746382}, + .iir_coef[3].coef_a = {134217728, -256639526, 123150471}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + .anc_cfg_ff_r = + { + // .total_gain = 382, + .total_gain = 288, + + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FF_R, + + .iir_coef[0].coef_b = {42463913, -84860822, 42396935}, + .iir_coef[0].coef_a = {134217728, -268353516, 134135801}, + + .iir_coef[1].coef_b = {136002894, -267154076, 131168209}, + .iir_coef[1].coef_a = {134217728, -267154076, 132953376}, + + .iir_coef[2].coef_b = {132863566, -263674901, 130888668}, + .iir_coef[2].coef_a = {134217728, -263674901, 129534506}, + + .iir_coef[3].coef_b = {131621817, -256639526, 125746382}, + .iir_coef[3].coef_a = {134217728, -256639526, 123150471}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + + /* + + Filter1_B=[ 27172676, -53803459, 26691412]; + Filter1_A=[ 134217728, -214195429, 80219070]; + + Filter2_B=[ 138529480, -267551490, 129040578]; + Filter2_A=[ 134217728, -267551490, 133352330]; + + Filter3_B=[ 134516353, -268162980, 133647489]; + Filter3_A=[ 134217728, -268162980, 133946114]; + + Filter4_B=[ 133595549, -264581113, 131087955]; + Filter4_A=[ 134217728, -264581113, 130465777]; + + + */ + + .anc_cfg_fb_l = + { + .total_gain = 511, + + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FB_L, + + .iir_coef[0].coef_b = {27172676, -53803459, 26691412}, + .iir_coef[0].coef_a = {134217728, -214195429, 80219070}, + + .iir_coef[1].coef_b = {138529480, -267551490, 129040578}, + .iir_coef[1].coef_a = {134217728, -267551490, 133352330}, + + .iir_coef[2].coef_b = {134516353, -268162980, 133647489}, + .iir_coef[2].coef_a = {134217728, -268162980, 133946114}, + + .iir_coef[3].coef_b = {133595549, -264581113, 131087955}, + .iir_coef[3].coef_a = {134217728, -264581113, 130465777}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + .anc_cfg_fb_r = + { + .total_gain = 511, + + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FB_R, + + .iir_coef[0].coef_b = {27172676, -53803459, 26691412}, + .iir_coef[0].coef_a = {134217728, -214195429, 80219070}, + + .iir_coef[1].coef_b = {138529480, -267551490, 129040578}, + .iir_coef[1].coef_a = {134217728, -267551490, 133352330}, + + .iir_coef[2].coef_b = {134516353, -268162980, 133647489}, + .iir_coef[2].coef_a = {134217728, -268162980, 133946114}, + + .iir_coef[3].coef_b = {133595549, -264581113, 131087955}, + .iir_coef[3].coef_a = {134217728, -264581113, 130465777}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, #if (AUD_SECTION_STRUCT_VERSION == 2) - -/* -1.0000000000000000,-1.5858874672928407,0.6974239598044429,0.2832267077115959,-0.3117526885614825,0.1400624733614886, -Filter1_B=[ 4751756, -5230342, 2349858]; -Filter1_A=[ 16777216, -26606777, 11700832]; + /* + 1.0000000000000000,-1.5858874672928407,0.6974239598044429,0.2832267077115959,-0.3117526885614825,0.1400624733614886, + Filter1_B=[ 4751756, -5230342, 2349858]; + Filter1_A=[ 16777216, -26606777, 11700832]; -1.0000000000000000,-1.7971697583202608,0.8159624512785459,0.9540998606028980,-1.7971697583202608,0.8618625906756480, -Filter2_B=[ 16007139, -30151505, 14459655]; -Filter2_A=[ 16777216, -30151505, 13689578]; + 1.0000000000000000,-1.7971697583202608,0.8159624512785459,0.9540998606028980,-1.7971697583202608,0.8618625906756480, + Filter2_B=[ 16007139, -30151505, 14459655]; + Filter2_A=[ 16777216, -30151505, 13689578]; -1.0000000000000000,-1.9694050640918992,0.9705681145972464,0.3200483744622364,-0.6223829329788905,0.3034976090220014, -Filter3_B=[ 5369521, -10441853, 5091845]; -Filter3_A=[ 16777216, -33041134, 16283431]; + 1.0000000000000000,-1.9694050640918992,0.9705681145972464,0.3200483744622364,-0.6223829329788905,0.3034976090220014, + Filter3_B=[ 5369521, -10441853, 5091845]; + Filter3_A=[ 16777216, -33041134, 16283431]; -1.0000000000000000,-1.9921619776276678,0.9921812243512138,0.9968660174712476,-1.9921712178765081,0.9953059666311256, -Filter4_B=[ 16724636, -33423087, 16698463]; -Filter4_A=[ 16777216, -33422932, 16646039]; -*/ + 1.0000000000000000,-1.9921619776276678,0.9921812243512138,0.9968660174712476,-1.9921712178765081,0.9953059666311256, + Filter4_B=[ 16724636, -33423087, 16698463]; + Filter4_A=[ 16777216, -33422932, 16646039]; + */ -/* + /* -1.0000000000000000,-1.9868580074509832,0.9869011854430232,1.1834688902733632,-2.3614075958038656,1.1779451659756268, -Filter1_B=[ 19855313, -39617845, 19762640]; -Filter1_A=[ 16777216, -33333946, 16557454]; + 1.0000000000000000,-1.9868580074509832,0.9869011854430232,1.1834688902733632,-2.3614075958038656,1.1779451659756268, + Filter1_B=[ 19855313, -39617845, 19762640]; + Filter1_A=[ 16777216, -33333946, 16557454]; -1.0000000000000000,-1.0329261527674278,0.0418392318218667,0.5812322628931170,-1.0329261527674278,0.4606069689287498, -Filter2_B=[ 9751459, -17329625, 7727703]; -Filter2_A=[ 16777216, -17329625, 701946]; + 1.0000000000000000,-1.0329261527674278,0.0418392318218667,0.5812322628931170,-1.0329261527674278,0.4606069689287498, + Filter2_B=[ 9751459, -17329625, 7727703]; + Filter2_A=[ 16777216, -17329625, 701946]; -1.0000000000000000,-1.9576081396140492,0.9591185490154677,1.0729914166044796,-1.9576081396140492,0.8861271324109881, -Filter3_B=[ 18001809, -32843215, 14866746]; -Filter3_A=[ 16777216, -32843215, 16091339]; + 1.0000000000000000,-1.9576081396140492,0.9591185490154677,1.0729914166044796,-1.9576081396140492,0.8861271324109881, + Filter3_B=[ 18001809, -32843215, 14866746]; + Filter3_A=[ 16777216, -32843215, 16091339]; -1.0000000000000000,-1.9197071583239940,0.9219883336398085,0.7545642546264146,-1.4392920140632206,0.6870089347526202, -Filter4_B=[ 12659487, -24147313, 11526097]; -Filter4_A=[ 16777216, -32207342, 15468397]; + 1.0000000000000000,-1.9197071583239940,0.9219883336398085,0.7545642546264146,-1.4392920140632206,0.6870089347526202, + Filter4_B=[ 12659487, -24147313, 11526097]; + Filter4_A=[ 16777216, -32207342, 15468397]; -1.0000000000000000,-1.9102108535747602,0.9139876710346515,0.9829076121866517,-1.9102108535747602,0.9310800588479999, -Filter5_B=[ 16490453, -32048020, 15620931]; -Filter5_A=[ 16777216, -32048020, 15334169]; -*/ + 1.0000000000000000,-1.9102108535747602,0.9139876710346515,0.9829076121866517,-1.9102108535747602,0.9310800588479999, + Filter5_B=[ 16490453, -32048020, 15620931]; + Filter5_A=[ 16777216, -32048020, 15334169]; + */ + .anc_cfg_mc_l = + { + .total_gain = 1228, + .iir_bypass_flag = 0, + .iir_counter = 5, + .iir_coef[0].coef_b = {19855313, -39617845, 19762640}, + .iir_coef[0].coef_a = {16777216, -33333946, 16557454}, - .anc_cfg_mc_l = { - .total_gain = 1228, - - .iir_bypass_flag=0, - .iir_counter=5, - - .iir_coef[0].coef_b={19855313, -39617845, 19762640}, - .iir_coef[0].coef_a={16777216, -33333946, 16557454}, - - .iir_coef[1].coef_b={9751459, -17329625, 7727703}, - .iir_coef[1].coef_a={16777216, -17329625, 701946}, - - .iir_coef[2].coef_b={18001809, -32843215, 14866746}, - .iir_coef[2].coef_a={16777216, -32843215, 16091339}, - - .iir_coef[3].coef_b={12659487, -24147313, 11526097}, - .iir_coef[3].coef_a={16777216, -32207342, 15468397}, - - .iir_coef[4].coef_b={16490453, -32048020, 15620931}, - .iir_coef[4].coef_a={16777216, -32048020, 15334169}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - + .iir_coef[1].coef_b = {9751459, -17329625, 7727703}, + .iir_coef[1].coef_a = {16777216, -17329625, 701946}, - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, - .anc_cfg_mc_r = { - .total_gain = 1331, - - .iir_bypass_flag=0, - .iir_counter=5, - - .iir_coef[0].coef_b={19855313, -39617845, 19762640}, - .iir_coef[0].coef_a={16777216, -33333946, 16557454}, - - .iir_coef[1].coef_b={9751459, -17329625, 7727703}, - .iir_coef[1].coef_a={16777216, -17329625, 701946}, - - .iir_coef[2].coef_b={18001809, -32843215, 14866746}, - .iir_coef[2].coef_a={16777216, -32843215, 16091339}, - - .iir_coef[3].coef_b={12659487, -24147313, 11526097}, - .iir_coef[3].coef_a={16777216, -32207342, 15468397}, - - .iir_coef[4].coef_b={16490453, -32048020, 15620931}, - .iir_coef[4].coef_a={16777216, -32048020, 15334169}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - + .iir_coef[2].coef_b = {18001809, -32843215, 14866746}, + .iir_coef[2].coef_a = {16777216, -32843215, 16091339}, - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, + .iir_coef[3].coef_b = {12659487, -24147313, 11526097}, + .iir_coef[3].coef_a = {16777216, -32207342, 15468397}, + + .iir_coef[4].coef_b = {16490453, -32048020, 15620931}, + .iir_coef[4].coef_a = {16777216, -32048020, 15334169}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + .anc_cfg_mc_r = + { + .total_gain = 1331, + + .iir_bypass_flag = 0, + .iir_counter = 5, + + .iir_coef[0].coef_b = {19855313, -39617845, 19762640}, + .iir_coef[0].coef_a = {16777216, -33333946, 16557454}, + + .iir_coef[1].coef_b = {9751459, -17329625, 7727703}, + .iir_coef[1].coef_a = {16777216, -17329625, 701946}, + + .iir_coef[2].coef_b = {18001809, -32843215, 14866746}, + .iir_coef[2].coef_a = {16777216, -32843215, 16091339}, + + .iir_coef[3].coef_b = {12659487, -24147313, 11526097}, + .iir_coef[3].coef_a = {16777216, -32207342, 15468397}, + + .iir_coef[4].coef_b = {16490453, -32048020, 15620931}, + .iir_coef[4].coef_a = {16777216, -32048020, 15334169}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, #endif }; @@ -692,390 +728,367 @@ Filter4_A=[ 134217728, -255575175, 122217496]; */ - - -static const struct_anc_cfg POSSIBLY_UNUSED AncFirCoef_44p1k_mode0 = { - .anc_cfg_ff_l = { - // .total_gain = 440, - .total_gain =312, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FF_L, - - .iir_coef[0].coef_b={42465729, -84858529, 42392831}, - .iir_coef[0].coef_a={134217728, -268346271, 134128558}, - - .iir_coef[1].coef_b={136159949, -267039705, 130899919}, - .iir_coef[1].coef_a={134217728, -267039705, 132842140}, - - .iir_coef[2].coef_b={132746107, -263254540, 130599907}, - .iir_coef[2].coef_a={134217728, -263254540, 129128286}, - - .iir_coef[3].coef_b={131402980, -255575175, 125032243}, - .iir_coef[3].coef_a={ 134217728, -255575175, 122217496}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = +static const struct_anc_cfg POSSIBLY_UNUSED + AncFirCoef_44p1k_mode0 = { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, - .anc_cfg_ff_r = { - // .total_gain = 382, - .total_gain = 288, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FF_R, - - .iir_coef[0].coef_b={42465729, -84858529, 42392831}, - .iir_coef[0].coef_a={134217728, -268346271, 134128558}, - - .iir_coef[1].coef_b={136159949, -267039705, 130899919}, - .iir_coef[1].coef_a={134217728, -267039705, 132842140}, - - .iir_coef[2].coef_b={132746107, -263254540, 130599907}, - .iir_coef[2].coef_a={134217728, -263254540, 129128286}, - - .iir_coef[3].coef_b={131402980, -255575175, 125032243}, - .iir_coef[3].coef_a={ 134217728, -255575175, 122217496}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = - { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, + .anc_cfg_ff_l = + { + // .total_gain = 440, + .total_gain = 312, -/* + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FF_L, -Filter1_B=[ 26719020, -52852829, 26204379]; -Filter1_A=[ 134217728, -210410903, 76474119]; + .iir_coef[0].coef_b = {42465729, -84858529, 42392831}, + .iir_coef[0].coef_a = {134217728, -268346271, 134128558}, -Filter2_B=[ 138909433, -267471808, 128584365]; -Filter2_A=[ 134217728, -267471808, 133276071]; + .iir_coef[1].coef_b = {136159949, -267039705, 130899919}, + .iir_coef[1].coef_a = {134217728, -267039705, 132842140}, -Filter3_B=[ 134542733, -268138827, 133597115]; -Filter3_A=[ 134217728, -268138827, 133922120]; + .iir_coef[2].coef_b = {132746107, -263254540, 130599907}, + .iir_coef[2].coef_a = {134217728, -263254540, 129128286}, -Filter4_B=[ 133541379, -264235686, 130815458]; -Filter4_A=[ 134217728, -264235686, 130139109]; + .iir_coef[3].coef_b = {131402980, -255575175, 125032243}, + .iir_coef[3].coef_a = {134217728, -255575175, 122217496}, -*/ + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, - - .anc_cfg_fb_l = { - .total_gain = 511, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FB_L, - - .iir_coef[0].coef_b={26719020, -52852829, 26204379}, - .iir_coef[0].coef_a={134217728, -210410903, 76474119}, - - .iir_coef[1].coef_b={138909433, -267471808, 128584365}, - .iir_coef[1].coef_a={134217728, -267471808, 133276071}, - - .iir_coef[2].coef_b={134542733, -268138827, 133597115}, - .iir_coef[2].coef_a={134217728, -268138827, 133922120}, - - .iir_coef[3].coef_b={133541379, -264235686, 130815458}, - .iir_coef[3].coef_a={134217728, -264235686, 130139109}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = - { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, - .anc_cfg_fb_r = { - .total_gain = 511, - - .iir_bypass_flag=0, - .iir_counter=IIR_COUNTER_FB_R, - - .iir_coef[0].coef_b={26719020, -52852829, 26204379}, - .iir_coef[0].coef_a={134217728, -210410903, 76474119}, - - .iir_coef[1].coef_b={138909433, -267471808, 128584365}, - .iir_coef[1].coef_a={134217728, -267471808, 133276071}, - - .iir_coef[2].coef_b={134542733, -268138827, 133597115}, - .iir_coef[2].coef_a={134217728, -268138827, 133922120}, - - .iir_coef[3].coef_b={133541379, -264235686, 130815458}, - .iir_coef[3].coef_a={134217728, -264235686, 130139109}, - - .iir_coef[4].coef_b={0x8000000,0,0}, - .iir_coef[4].coef_a={0x8000000,0,0}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - - -/* .fir_bypass_flag=1, - .fir_len = AUD_COEF_LEN, - .fir_coef = - { - 32767, - }, -*/ - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + .anc_cfg_ff_r = + { + // .total_gain = 382, + .total_gain = 288, + + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FF_R, + + .iir_coef[0].coef_b = {42465729, -84858529, 42392831}, + .iir_coef[0].coef_a = {134217728, -268346271, 134128558}, + + .iir_coef[1].coef_b = {136159949, -267039705, 130899919}, + .iir_coef[1].coef_a = {134217728, -267039705, 132842140}, + + .iir_coef[2].coef_b = {132746107, -263254540, 130599907}, + .iir_coef[2].coef_a = {134217728, -263254540, 129128286}, + + .iir_coef[3].coef_b = {131402980, -255575175, 125032243}, + .iir_coef[3].coef_a = {134217728, -255575175, 122217496}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + + /* + + Filter1_B=[ 26719020, -52852829, 26204379]; + Filter1_A=[ 134217728, -210410903, 76474119]; + + Filter2_B=[ 138909433, -267471808, 128584365]; + Filter2_A=[ 134217728, -267471808, 133276071]; + + Filter3_B=[ 134542733, -268138827, 133597115]; + Filter3_A=[ 134217728, -268138827, 133922120]; + + Filter4_B=[ 133541379, -264235686, 130815458]; + Filter4_A=[ 134217728, -264235686, 130139109]; + + */ + + .anc_cfg_fb_l = + { + .total_gain = 511, + + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FB_L, + + .iir_coef[0].coef_b = {26719020, -52852829, 26204379}, + .iir_coef[0].coef_a = {134217728, -210410903, 76474119}, + + .iir_coef[1].coef_b = {138909433, -267471808, 128584365}, + .iir_coef[1].coef_a = {134217728, -267471808, 133276071}, + + .iir_coef[2].coef_b = {134542733, -268138827, 133597115}, + .iir_coef[2].coef_a = {134217728, -268138827, 133922120}, + + .iir_coef[3].coef_b = {133541379, -264235686, 130815458}, + .iir_coef[3].coef_a = {134217728, -264235686, 130139109}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + .anc_cfg_fb_r = + { + .total_gain = 511, + + .iir_bypass_flag = 0, + .iir_counter = IIR_COUNTER_FB_R, + + .iir_coef[0].coef_b = {26719020, -52852829, 26204379}, + .iir_coef[0].coef_a = {134217728, -210410903, 76474119}, + + .iir_coef[1].coef_b = {138909433, -267471808, 128584365}, + .iir_coef[1].coef_a = {134217728, -267471808, 133276071}, + + .iir_coef[2].coef_b = {134542733, -268138827, 133597115}, + .iir_coef[2].coef_a = {134217728, -268138827, 133922120}, + + .iir_coef[3].coef_b = {133541379, -264235686, 130815458}, + .iir_coef[3].coef_a = {134217728, -264235686, 130139109}, + + .iir_coef[4].coef_b = {0x8000000, 0, 0}, + .iir_coef[4].coef_a = {0x8000000, 0, 0}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + /* .fir_bypass_flag=1, + .fir_len = AUD_COEF_LEN, + .fir_coef = + { + 32767, + }, + */ + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, #if (AUD_SECTION_STRUCT_VERSION == 2) + /* + Filter1_B=[ 19847881, -39594823, 19747071]; + Filter1_A=[ 16777216, -33314517, 16538159]; -/* + Filter2_B=[ 9442890, -16603187, 7330251]; + Filter2_A=[ 16777216, -16603187, -4075]; -Filter1_B=[ 19847881, -39594823, 19747071]; -Filter1_A=[ 16777216, -33314517, 16538159]; + Filter3_B=[ 18107639, -32779315, 14701642]; + Filter3_A=[ 16777216, -32779315, 16032065]; -Filter2_B=[ 9442890, -16603187, 7330251]; -Filter2_A=[ 16777216, -16603187, -4075]; + Filter4_B=[ 12666347, -24058210, 11437046]; + Filter4_A=[ 16777216, -32089673, 15357640]; -Filter3_B=[ 18107639, -32779315, 14701642]; -Filter3_A=[ 16777216, -32779315, 16032065]; + Filter5_B=[ 16466312, -31915122, 15523589]; + Filter5_A=[ 16777216, -31915122, 15212684]; + */ -Filter4_B=[ 12666347, -24058210, 11437046]; -Filter4_A=[ 16777216, -32089673, 15357640]; + .anc_cfg_mc_l = + { + .total_gain = 1228, -Filter5_B=[ 16466312, -31915122, 15523589]; -Filter5_A=[ 16777216, -31915122, 15212684]; -*/ + .iir_bypass_flag = 0, + .iir_counter = 5, + .iir_coef[0].coef_b = {19847881, -39594823, 19747071}, + .iir_coef[0].coef_a = {16777216, -33314517, 16538159}, + .iir_coef[1].coef_b = {9442890, -16603187, 7330251}, + .iir_coef[1].coef_a = {16777216, -16603187, -4075}, + .iir_coef[2].coef_b = {18107639, -32779315, 14701642}, + .iir_coef[2].coef_a = {16777216, -32779315, 16032065}, - .anc_cfg_mc_l = { - .total_gain = 1228, - - .iir_bypass_flag=0, - .iir_counter=5, - - .iir_coef[0].coef_b={19847881, -39594823, 19747071}, - .iir_coef[0].coef_a={16777216, -33314517, 16538159}, - - .iir_coef[1].coef_b={9442890, -16603187, 7330251}, - .iir_coef[1].coef_a={16777216, -16603187, -4075}, - - .iir_coef[2].coef_b={18107639, -32779315, 14701642}, - .iir_coef[2].coef_a={16777216, -32779315, 16032065}, - - .iir_coef[3].coef_b={12666347, -24058210, 11437046}, - .iir_coef[3].coef_a={16777216, -32089673, 15357640}, - - .iir_coef[4].coef_b={16466312, -31915122, 15523589}, - .iir_coef[4].coef_a={16777216, -31915122, 15212684}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - + .iir_coef[3].coef_b = {12666347, -24058210, 11437046}, + .iir_coef[3].coef_a = {16777216, -32089673, 15357640}, - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, - .anc_cfg_mc_r = { - .total_gain = 1331, - - .iir_bypass_flag=0, - .iir_counter=5, - - .iir_coef[0].coef_b={19847881, -39594823, 19747071}, - .iir_coef[0].coef_a={16777216, -33314517, 16538159}, - - .iir_coef[1].coef_b={9442890, -16603187, 7330251}, - .iir_coef[1].coef_a={16777216, -16603187, -4075}, - - .iir_coef[2].coef_b={18107639, -32779315, 14701642}, - .iir_coef[2].coef_a={16777216, -32779315, 16032065}, - - .iir_coef[3].coef_b={12666347, -24058210, 11437046}, - .iir_coef[3].coef_a={16777216, -32089673, 15357640}, - - .iir_coef[4].coef_b={16466312, -31915122, 15523589}, - .iir_coef[4].coef_a={16777216, -31915122, 15212684}, - - .iir_coef[5].coef_b={0x8000000,0,0}, - .iir_coef[5].coef_a={0x8000000,0,0}, - + .iir_coef[4].coef_b = {16466312, -31915122, 15523589}, + .iir_coef[4].coef_a = {16777216, -31915122, 15212684}, - .dac_gain_offset=0, - .adc_gain_offset=(0)*4, - }, + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, + .anc_cfg_mc_r = + { + .total_gain = 1331, + + .iir_bypass_flag = 0, + .iir_counter = 5, + + .iir_coef[0].coef_b = {19847881, -39594823, 19747071}, + .iir_coef[0].coef_a = {16777216, -33314517, 16538159}, + + .iir_coef[1].coef_b = {9442890, -16603187, 7330251}, + .iir_coef[1].coef_a = {16777216, -16603187, -4075}, + + .iir_coef[2].coef_b = {18107639, -32779315, 14701642}, + .iir_coef[2].coef_a = {16777216, -32779315, 16032065}, + + .iir_coef[3].coef_b = {12666347, -24058210, 11437046}, + .iir_coef[3].coef_a = {16777216, -32089673, 15357640}, + + .iir_coef[4].coef_b = {16466312, -31915122, 15523589}, + .iir_coef[4].coef_a = {16777216, -31915122, 15212684}, + + .iir_coef[5].coef_b = {0x8000000, 0, 0}, + .iir_coef[5].coef_a = {0x8000000, 0, 0}, + + .dac_gain_offset = 0, + .adc_gain_offset = (0) * 4, + }, #endif }; -const struct_anc_cfg * anc_coef_list_50p7k[ANC_COEF_LIST_NUM] = { +const struct_anc_cfg *anc_coef_list_50p7k[ANC_COEF_LIST_NUM] = { &AncFirCoef_50p7k_mode0, #if (ANC_COEF_LIST_NUM == 2) &AncFirCoef_50p7k_mode0, #endif -#if(ANC_COEF_LIST_NUM == 3) - &AncFirCoef_50p7k_mode0, - &AncFirCoef_50p7k_mode0, +#if (ANC_COEF_LIST_NUM == 3) + &AncFirCoef_50p7k_mode0, &AncFirCoef_50p7k_mode0, #endif -#if(ANC_COEF_LIST_NUM == 4) - &AncFirCoef_50p7k_mode0, - &AncFirCoef_50p7k_mode0, - &AncFirCoef_50p7k_mode0, +#if (ANC_COEF_LIST_NUM == 4) + &AncFirCoef_50p7k_mode0, &AncFirCoef_50p7k_mode0, &AncFirCoef_50p7k_mode0, #endif }; -const struct_anc_cfg * anc_coef_list_48k[ANC_COEF_LIST_NUM] = { +const struct_anc_cfg *anc_coef_list_48k[ANC_COEF_LIST_NUM] = { &AncFirCoef_48k_mode0, #if (ANC_COEF_LIST_NUM == 2) &AncFirCoef_48k_mode0, #endif -#if(ANC_COEF_LIST_NUM == 3) - &AncFirCoef_48k_mode0, - &AncFirCoef_48k_mode0, +#if (ANC_COEF_LIST_NUM == 3) + &AncFirCoef_48k_mode0, &AncFirCoef_48k_mode0, #endif -#if(ANC_COEF_LIST_NUM == 4) - &AncFirCoef_48k_mode0, - &AncFirCoef_48k_mode0, - &AncFirCoef_48k_mode0, +#if (ANC_COEF_LIST_NUM == 4) + &AncFirCoef_48k_mode0, &AncFirCoef_48k_mode0, &AncFirCoef_48k_mode0, #endif }; -const struct_anc_cfg * anc_coef_list_44p1k[ANC_COEF_LIST_NUM] = { +const struct_anc_cfg *anc_coef_list_44p1k[ANC_COEF_LIST_NUM] = { &AncFirCoef_44p1k_mode0, #if (ANC_COEF_LIST_NUM == 2) &AncFirCoef_44p1k_mode0, #endif -#if(ANC_COEF_LIST_NUM == 3) - &AncFirCoef_44p1k_mode0, - &AncFirCoef_44p1k_mode0, +#if (ANC_COEF_LIST_NUM == 3) + &AncFirCoef_44p1k_mode0, &AncFirCoef_44p1k_mode0, #endif -#if(ANC_COEF_LIST_NUM == 4) - &AncFirCoef_44p1k_mode0, - &AncFirCoef_44p1k_mode0, - &AncFirCoef_44p1k_mode0, +#if (ANC_COEF_LIST_NUM == 4) + &AncFirCoef_44p1k_mode0, &AncFirCoef_44p1k_mode0, &AncFirCoef_44p1k_mode0, #endif }; -const IIR_CFG_T audio_eq_sw_iir_cfg = { - .gain0 = 0, - .gain1 = 0, - .num = 14, - .param = { - {IIR_TYPE_PEAK, -2.18, 10, 2}, - {IIR_TYPE_PEAK, 7.27, 21, 2}, - {IIR_TYPE_PEAK, 2.13, 42, 2}, - {IIR_TYPE_PEAK, -1.53, 83, 2}, - {IIR_TYPE_PEAK, -0.9, 120, 2}, - {IIR_TYPE_PEAK, -4.23, 166, 2}, - {IIR_TYPE_PEAK, -1.08, 333, 2}, - {IIR_TYPE_PEAK, -1.37, 577, 2}, - {IIR_TYPE_PEAK, 0.8, 1000, 2}, - {IIR_TYPE_PEAK, 5.35, 2000, 2}, - {IIR_TYPE_PEAK, 3.2, 4000, 2}, - {IIR_TYPE_PEAK, -4.96, 8000, 2}, - {IIR_TYPE_PEAK, 13.58, 16000, 2}, - {IIR_TYPE_PEAK, 8.89, 20000, 2}, - } -}; +const IIR_CFG_T audio_eq_sw_iir_cfg = {.gain0 = 0, + .gain1 = 0, + .num = 14, + .param = { + {IIR_TYPE_PEAK, -2.18, 10, 2}, + {IIR_TYPE_PEAK, 7.27, 21, 2}, + {IIR_TYPE_PEAK, 2.13, 42, 2}, + {IIR_TYPE_PEAK, -1.53, 83, 2}, + {IIR_TYPE_PEAK, -0.9, 120, 2}, + {IIR_TYPE_PEAK, -4.23, 166, 2}, + {IIR_TYPE_PEAK, -1.08, 333, 2}, + {IIR_TYPE_PEAK, -1.37, 577, 2}, + {IIR_TYPE_PEAK, 0.8, 1000, 2}, + {IIR_TYPE_PEAK, 5.35, 2000, 2}, + {IIR_TYPE_PEAK, 3.2, 4000, 2}, + {IIR_TYPE_PEAK, -4.96, 8000, 2}, + {IIR_TYPE_PEAK, 13.58, 16000, 2}, + {IIR_TYPE_PEAK, 8.89, 20000, 2}, + }}; -const IIR_CFG_T * const audio_eq_sw_iir_cfg_list[EQ_SW_IIR_LIST_NUM]={ +const IIR_CFG_T *const audio_eq_sw_iir_cfg_list[EQ_SW_IIR_LIST_NUM] = { &audio_eq_sw_iir_cfg, }; -const FIR_CFG_T audio_eq_hw_fir_cfg_44p1k = { - .gain = 0.0f, - .len = 384, - .coef = - { - (1<<23)-1, - } -}; +const FIR_CFG_T audio_eq_hw_fir_cfg_44p1k = {.gain = 0.0f, + .len = 384, + .coef = { + (1 << 23) - 1, + }}; -const FIR_CFG_T audio_eq_hw_fir_cfg_48k = { - .gain = 0.0f, - .len = 384, - .coef = - { - (1<<23)-1, - } -}; +const FIR_CFG_T audio_eq_hw_fir_cfg_48k = {.gain = 0.0f, + .len = 384, + .coef = { + (1 << 23) - 1, + }}; +const FIR_CFG_T audio_eq_hw_fir_cfg_96k = {.gain = 0.0f, + .len = 384, + .coef = { + (1 << 23) - 1, + }}; -const FIR_CFG_T audio_eq_hw_fir_cfg_96k = { - .gain = 0.0f, - .len = 384, - .coef = - { - (1<<23)-1, - } -}; - -const FIR_CFG_T * const audio_eq_hw_fir_cfg_list[EQ_HW_FIR_LIST_NUM]={ +const FIR_CFG_T *const audio_eq_hw_fir_cfg_list[EQ_HW_FIR_LIST_NUM] = { &audio_eq_hw_fir_cfg_44p1k, &audio_eq_hw_fir_cfg_48k, - &audio_eq_hw_fir_cfg_96k, + &audio_eq_hw_fir_cfg_96k, }; -//hardware dac iir eq +// hardware dac iir eq const IIR_CFG_T audio_eq_hw_dac_iir_cfg = audio_eq_sw_iir_cfg; -const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_dac_iir_cfg_list[EQ_HW_DAC_IIR_LIST_NUM]={ - &audio_eq_hw_dac_iir_cfg, +const IIR_CFG_T *const POSSIBLY_UNUSED + audio_eq_hw_dac_iir_cfg_list[EQ_HW_DAC_IIR_LIST_NUM] = { + &audio_eq_hw_dac_iir_cfg, }; -//hardware dac iir eq +// hardware dac iir eq const IIR_CFG_T audio_eq_hw_adc_iir_adc_cfg = audio_eq_sw_iir_cfg; -const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_adc_iir_cfg_list[EQ_HW_ADC_IIR_LIST_NUM]={ - &audio_eq_hw_adc_iir_adc_cfg, +const IIR_CFG_T *const POSSIBLY_UNUSED + audio_eq_hw_adc_iir_cfg_list[EQ_HW_ADC_IIR_LIST_NUM] = { + &audio_eq_hw_adc_iir_adc_cfg, }; -//hardware iir eq +// hardware iir eq const IIR_CFG_T audio_eq_hw_iir_cfg = audio_eq_sw_iir_cfg; -const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_iir_cfg_list[EQ_HW_IIR_LIST_NUM]={ - &audio_eq_hw_iir_cfg, +const IIR_CFG_T *const POSSIBLY_UNUSED + audio_eq_hw_iir_cfg_list[EQ_HW_IIR_LIST_NUM] = { + &audio_eq_hw_iir_cfg, }; -const DrcConfig audio_drc_cfg = { - .knee = 3, - .filter_type = {14, -1}, - .band_num = 2, - .look_ahead_time = 10, - .band_settings = { - {-20, 0, 2, 3, 3000, 1}, - {-20, 0, 2, 3, 3000, 1}, - } - }; +const DrcConfig audio_drc_cfg = {.knee = 3, + .filter_type = {14, -1}, + .band_num = 2, + .look_ahead_time = 10, + .band_settings = { + {-20, 0, 2, 3, 3000, 1}, + {-20, 0, 2, 3, 3000, 1}, + }}; const LimiterConfig audio_drc2_cfg = { .knee = 2, @@ -1091,4 +1104,3 @@ const SpectrumFixConfig audio_spectrum_cfg = { .freq_num = 9, .freq_list = {200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800}, }; - diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_abs_f32.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_abs_f32.c index 295939a..1265b89 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_abs_f32.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_abs_f32.c @@ -60,20 +60,15 @@ @return none */ -void arm_abs_f32( - const float32_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_abs_f32(const float32_t *pSrc, float32_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = |A| */ /* Calculate absolute and store result in destination buffer. */ @@ -99,8 +94,7 @@ void arm_abs_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = |A| */ /* Calculate absolute and store result in destination buffer. */ @@ -109,7 +103,6 @@ void arm_abs_f32( /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_abs_q15.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_abs_q15.c index eb944ce..ddaab19 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_abs_q15.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_abs_q15.c @@ -46,53 +46,50 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - The Q15 value -1 (0x8000) will be saturated to the maximum allowable positive value 0x7FFF. + The Q15 value -1 (0x8000) will be saturated to the maximum + allowable positive value 0x7FFF. */ -void arm_abs_q15( - const q15_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - q15_t in; /* Temporary input variable */ +void arm_abs_q15(const q15_t *pSrc, q15_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + q15_t in; /* Temporary input variable */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = |A| */ - /* Calculate absolute of input (if -1 then saturated to 0x7fff) and store result in destination buffer. */ + /* Calculate absolute of input (if -1 then saturated to 0x7fff) and store + * result in destination buffer. */ in = *pSrc++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = (in > 0) ? in : (q15_t)__QSUB16(0, in); #else - *pDst++ = (in > 0) ? in : ((in == (q15_t) 0x8000) ? 0x7fff : -in); + *pDst++ = (in > 0) ? in : ((in == (q15_t)0x8000) ? 0x7fff : -in); #endif in = *pSrc++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = (in > 0) ? in : (q15_t)__QSUB16(0, in); #else - *pDst++ = (in > 0) ? in : ((in == (q15_t) 0x8000) ? 0x7fff : -in); + *pDst++ = (in > 0) ? in : ((in == (q15_t)0x8000) ? 0x7fff : -in); #endif in = *pSrc++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = (in > 0) ? in : (q15_t)__QSUB16(0, in); #else - *pDst++ = (in > 0) ? in : ((in == (q15_t) 0x8000) ? 0x7fff : -in); + *pDst++ = (in > 0) ? in : ((in == (q15_t)0x8000) ? 0x7fff : -in); #endif in = *pSrc++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = (in > 0) ? in : (q15_t)__QSUB16(0, in); #else - *pDst++ = (in > 0) ? in : ((in == (q15_t) 0x8000) ? 0x7fff : -in); + *pDst++ = (in > 0) ? in : ((in == (q15_t)0x8000) ? 0x7fff : -in); #endif /* Decrement loop counter */ @@ -109,22 +106,21 @@ void arm_abs_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = |A| */ - /* Calculate absolute of input (if -1 then saturated to 0x7fff) and store result in destination buffer. */ + /* Calculate absolute of input (if -1 then saturated to 0x7fff) and store + * result in destination buffer. */ in = *pSrc++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = (in > 0) ? in : (q15_t)__QSUB16(0, in); #else - *pDst++ = (in > 0) ? in : ((in == (q15_t) 0x8000) ? 0x7fff : -in); + *pDst++ = (in > 0) ? in : ((in == (q15_t)0x8000) ? 0x7fff : -in); #endif /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_abs_q31.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_abs_q31.c index bf7608b..6363bfa 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_abs_q31.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_abs_q31.c @@ -46,50 +46,47 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - The Q31 value -1 (0x80000000) will be saturated to the maximum allowable positive value 0x7FFFFFFF. + The Q31 value -1 (0x80000000) will be saturated to the + maximum allowable positive value 0x7FFFFFFF. */ -void arm_abs_q31( - const q31_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - q31_t in; /* Temporary variable */ +void arm_abs_q31(const q31_t *pSrc, q31_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + q31_t in; /* Temporary variable */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = |A| */ - /* Calculate absolute of input (if -1 then saturated to 0x7fffffff) and store result in destination buffer. */ + /* Calculate absolute of input (if -1 then saturated to 0x7fffffff) and + * store result in destination buffer. */ in = *pSrc++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = (in > 0) ? in : (q31_t)__QSUB(0, in); #else *pDst++ = (in > 0) ? in : ((in == INT32_MIN) ? INT32_MAX : -in); #endif in = *pSrc++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = (in > 0) ? in : (q31_t)__QSUB(0, in); #else *pDst++ = (in > 0) ? in : ((in == INT32_MIN) ? INT32_MAX : -in); #endif in = *pSrc++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = (in > 0) ? in : (q31_t)__QSUB(0, in); #else *pDst++ = (in > 0) ? in : ((in == INT32_MIN) ? INT32_MAX : -in); #endif in = *pSrc++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = (in > 0) ? in : (q31_t)__QSUB(0, in); #else *pDst++ = (in > 0) ? in : ((in == INT32_MIN) ? INT32_MAX : -in); @@ -109,13 +106,13 @@ void arm_abs_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = |A| */ - /* Calculate absolute of input (if -1 then saturated to 0x7fffffff) and store result in destination buffer. */ + /* Calculate absolute of input (if -1 then saturated to 0x7fffffff) and + * store result in destination buffer. */ in = *pSrc++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = (in > 0) ? in : (q31_t)__QSUB(0, in); #else *pDst++ = (in > 0) ? in : ((in == INT32_MIN) ? INT32_MAX : -in); @@ -124,7 +121,6 @@ void arm_abs_q31( /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_abs_q7.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_abs_q7.c index a6c4a6c..3151520 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_abs_q7.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_abs_q7.c @@ -48,53 +48,50 @@ Input and output buffers should be aligned by 32-bit @par Scaling and Overflow Behavior The function uses saturating arithmetic. - The Q7 value -1 (0x80) will be saturated to the maximum allowable positive value 0x7F. + The Q7 value -1 (0x80) will be saturated to the maximum + allowable positive value 0x7F. */ -void arm_abs_q7( - const q7_t * pSrc, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - q7_t in; /* Temporary input variable */ +void arm_abs_q7(const q7_t *pSrc, q7_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + q7_t in; /* Temporary input variable */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = |A| */ - /* Calculate absolute of input (if -1 then saturated to 0x7f) and store result in destination buffer. */ + /* Calculate absolute of input (if -1 then saturated to 0x7f) and store + * result in destination buffer. */ in = *pSrc++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = (in > 0) ? in : (q7_t)__QSUB(0, in); #else - *pDst++ = (in > 0) ? in : ((in == (q7_t) 0x80) ? (q7_t) 0x7f : -in); + *pDst++ = (in > 0) ? in : ((in == (q7_t)0x80) ? (q7_t)0x7f : -in); #endif in = *pSrc++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = (in > 0) ? in : (q7_t)__QSUB(0, in); #else - *pDst++ = (in > 0) ? in : ((in == (q7_t) 0x80) ? (q7_t) 0x7f : -in); + *pDst++ = (in > 0) ? in : ((in == (q7_t)0x80) ? (q7_t)0x7f : -in); #endif in = *pSrc++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = (in > 0) ? in : (q7_t)__QSUB(0, in); #else - *pDst++ = (in > 0) ? in : ((in == (q7_t) 0x80) ? (q7_t) 0x7f : -in); + *pDst++ = (in > 0) ? in : ((in == (q7_t)0x80) ? (q7_t)0x7f : -in); #endif in = *pSrc++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = (in > 0) ? in : (q7_t)__QSUB(0, in); #else - *pDst++ = (in > 0) ? in : ((in == (q7_t) 0x80) ? (q7_t) 0x7f : -in); + *pDst++ = (in > 0) ? in : ((in == (q7_t)0x80) ? (q7_t)0x7f : -in); #endif /* Decrement loop counter */ @@ -111,22 +108,21 @@ void arm_abs_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = |A| */ - /* Calculate absolute of input (if -1 then saturated to 0x7f) and store result in destination buffer. */ + /* Calculate absolute of input (if -1 then saturated to 0x7f) and store + * result in destination buffer. */ in = *pSrc++; -#if defined (ARM_MATH_DSP) - *pDst++ = (in > 0) ? in : (q7_t) __QSUB(0, in); +#if defined(ARM_MATH_DSP) + *pDst++ = (in > 0) ? in : (q7_t)__QSUB(0, in); #else - *pDst++ = (in > 0) ? in : ((in == (q7_t) 0x80) ? (q7_t) 0x7f : -in); + *pDst++ = (in > 0) ? in : ((in == (q7_t)0x80) ? (q7_t)0x7f : -in); #endif /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_add_f32.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_add_f32.c index e48e1d5..17673f4 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_add_f32.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_add_f32.c @@ -58,21 +58,16 @@ @return none */ -void arm_add_f32( - const float32_t * pSrcA, - const float32_t * pSrcB, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_add_f32(const float32_t *pSrcA, const float32_t *pSrcB, + float32_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A + B */ /* Add and store result in destination buffer. */ @@ -95,8 +90,7 @@ void arm_add_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A + B */ /* Add and store result in destination buffer. */ @@ -105,7 +99,6 @@ void arm_add_f32( /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_add_q15.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_add_q15.c index bc62937..95eb565 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_add_q15.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_add_q15.c @@ -47,20 +47,17 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q15 range [0x8000 0x7FFF] are saturated. + Results outside of the allowable Q15 range [0x8000 0x7FFF] + are saturated. */ -void arm_add_q15( - const q15_t * pSrcA, - const q15_t * pSrcB, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_add_q15(const q15_t *pSrcA, const q15_t *pSrcB, q15_t *pDst, + uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) q31_t inA1, inA2; q31_t inB1, inB2; #endif @@ -68,26 +65,25 @@ void arm_add_q15( /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A + B */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* read 2 times 2 samples at a time from sourceA */ - inA1 = read_q15x2_ia ((q15_t **) &pSrcA); - inA2 = read_q15x2_ia ((q15_t **) &pSrcA); + inA1 = read_q15x2_ia((q15_t **)&pSrcA); + inA2 = read_q15x2_ia((q15_t **)&pSrcA); /* read 2 times 2 samples at a time from sourceB */ - inB1 = read_q15x2_ia ((q15_t **) &pSrcB); - inB2 = read_q15x2_ia ((q15_t **) &pSrcB); + inB1 = read_q15x2_ia((q15_t **)&pSrcB); + inB2 = read_q15x2_ia((q15_t **)&pSrcB); /* Add and store 2 times 2 samples at a time */ - write_q15x2_ia (&pDst, __QADD16(inA1, inB1)); - write_q15x2_ia (&pDst, __QADD16(inA2, inB2)); + write_q15x2_ia(&pDst, __QADD16(inA1, inB1)); + write_q15x2_ia(&pDst, __QADD16(inA2, inB2)); #else - *pDst++ = (q15_t) __SSAT(((q31_t) *pSrcA++ + *pSrcB++), 16); - *pDst++ = (q15_t) __SSAT(((q31_t) *pSrcA++ + *pSrcB++), 16); - *pDst++ = (q15_t) __SSAT(((q31_t) *pSrcA++ + *pSrcB++), 16); - *pDst++ = (q15_t) __SSAT(((q31_t) *pSrcA++ + *pSrcB++), 16); + *pDst++ = (q15_t)__SSAT(((q31_t)*pSrcA++ + *pSrcB++), 16); + *pDst++ = (q15_t)__SSAT(((q31_t)*pSrcA++ + *pSrcB++), 16); + *pDst++ = (q15_t)__SSAT(((q31_t)*pSrcA++ + *pSrcB++), 16); + *pDst++ = (q15_t)__SSAT(((q31_t)*pSrcA++ + *pSrcB++), 16); #endif /* Decrement loop counter */ @@ -104,21 +100,19 @@ void arm_add_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A + B */ /* Add and store result in destination buffer. */ -#if defined (ARM_MATH_DSP) - *pDst++ = (q15_t) __QADD16(*pSrcA++, *pSrcB++); +#if defined(ARM_MATH_DSP) + *pDst++ = (q15_t)__QADD16(*pSrcA++, *pSrcB++); #else - *pDst++ = (q15_t) __SSAT(((q31_t) *pSrcA++ + *pSrcB++), 16); + *pDst++ = (q15_t)__SSAT(((q31_t)*pSrcA++ + *pSrcB++), 16); #endif /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_add_q31.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_add_q31.c index 3c1cbc2..b882fb2 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_add_q31.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_add_q31.c @@ -47,24 +47,20 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q31 range [0x80000000 0x7FFFFFFF] are saturated. + Results outside of the allowable Q31 range [0x80000000 + 0x7FFFFFFF] are saturated. */ -void arm_add_q31( - const q31_t * pSrcA, - const q31_t * pSrcB, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_add_q31(const q31_t *pSrcA, const q31_t *pSrcB, q31_t *pDst, + uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A + B */ /* Add and store result in destination buffer. */ @@ -90,8 +86,7 @@ void arm_add_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A + B */ /* Add and store result in destination buffer. */ @@ -100,7 +95,6 @@ void arm_add_q31( /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_add_q7.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_add_q7.c index f9c4a95..e70b7d4 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_add_q7.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_add_q7.c @@ -47,34 +47,31 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q7 range [0x80 0x7F] are saturated. + Results outside of the allowable Q7 range [0x80 0x7F] are + saturated. */ -void arm_add_q7( - const q7_t * pSrcA, - const q7_t * pSrcB, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_add_q7(const q7_t *pSrcA, const q7_t *pSrcB, q7_t *pDst, + uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A + B */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* Add and store result in destination buffer (4 samples at a time). */ - write_q7x4_ia (&pDst, __QADD8 (read_q7x4_ia ((q7_t **) &pSrcA), read_q7x4_ia ((q7_t **) &pSrcB))); + write_q7x4_ia(&pDst, __QADD8(read_q7x4_ia((q7_t **)&pSrcA), + read_q7x4_ia((q7_t **)&pSrcB))); #else - *pDst++ = (q7_t) __SSAT ((q15_t) *pSrcA++ + *pSrcB++, 8); - *pDst++ = (q7_t) __SSAT ((q15_t) *pSrcA++ + *pSrcB++, 8); - *pDst++ = (q7_t) __SSAT ((q15_t) *pSrcA++ + *pSrcB++, 8); - *pDst++ = (q7_t) __SSAT ((q15_t) *pSrcA++ + *pSrcB++, 8); + *pDst++ = (q7_t)__SSAT((q15_t)*pSrcA++ + *pSrcB++, 8); + *pDst++ = (q7_t)__SSAT((q15_t)*pSrcA++ + *pSrcB++, 8); + *pDst++ = (q7_t)__SSAT((q15_t)*pSrcA++ + *pSrcB++, 8); + *pDst++ = (q7_t)__SSAT((q15_t)*pSrcA++ + *pSrcB++, 8); #endif /* Decrement loop counter */ @@ -91,17 +88,15 @@ void arm_add_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A + B */ /* Add and store result in destination buffer. */ - *pDst++ = (q7_t) __SSAT((q15_t) *pSrcA++ + *pSrcB++, 8); + *pDst++ = (q7_t)__SSAT((q15_t)*pSrcA++ + *pSrcB++, 8); /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_dot_prod_f32.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_dot_prod_f32.c index d7f2464..157b035 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_dot_prod_f32.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_dot_prod_f32.c @@ -39,7 +39,8 @@ The vectors are multiplied element-by-element and then summed.
-      sum = pSrcA[0]*pSrcB[0] + pSrcA[1]*pSrcB[1] + ... + pSrcA[blockSize-1]*pSrcB[blockSize-1]
+      sum = pSrcA[0]*pSrcB[0] + pSrcA[1]*pSrcB[1] + ... +
+  pSrcA[blockSize-1]*pSrcB[blockSize-1]
   
There are separate functions for floating-point, Q7, Q15, and Q31 data types. @@ -59,23 +60,19 @@ @return none */ -void arm_dot_prod_f32( - const float32_t * pSrcA, - const float32_t * pSrcB, - uint32_t blockSize, - float32_t * result) -{ - uint32_t blkCnt; /* Loop counter */ - float32_t sum = 0.0f; /* Temporary return variable */ +void arm_dot_prod_f32(const float32_t *pSrcA, const float32_t *pSrcB, + uint32_t blockSize, float32_t *result) { + uint32_t blkCnt; /* Loop counter */ + float32_t sum = 0.0f; /* Temporary return variable */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { - /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */ + while (blkCnt > 0U) { + /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* + * B[blockSize-1] */ /* Calculate dot product and store result in a temporary buffer. */ sum += (*pSrcA++) * (*pSrcB++); @@ -100,9 +97,9 @@ void arm_dot_prod_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { - /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */ + while (blkCnt > 0U) { + /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* + * B[blockSize-1] */ /* Calculate dot product and store result in a temporary buffer. */ sum += (*pSrcA++) * (*pSrcB++); diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_dot_prod_q15.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_dot_prod_q15.c index e303b09..84634fd 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_dot_prod_q15.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_dot_prod_q15.c @@ -46,40 +46,38 @@ @return none @par Scaling and Overflow Behavior - The intermediate multiplications are in 1.15 x 1.15 = 2.30 format and these - results are added to a 64-bit accumulator in 34.30 format. - Nonsaturating additions are used and given that there are 33 guard bits in the accumulator - there is no risk of overflow. - The return result is in 34.30 format. + The intermediate multiplications are in 1.15 x 1.15 = 2.30 + format and these results are added to a 64-bit accumulator in 34.30 format. + Nonsaturating additions are used and given that there are 33 + guard bits in the accumulator there is no risk of overflow. The return result + is in 34.30 format. */ -void arm_dot_prod_q15( - const q15_t * pSrcA, - const q15_t * pSrcB, - uint32_t blockSize, - q63_t * result) -{ - uint32_t blkCnt; /* Loop counter */ - q63_t sum = 0; /* Temporary return variable */ +void arm_dot_prod_q15(const q15_t *pSrcA, const q15_t *pSrcB, + uint32_t blockSize, q63_t *result) { + uint32_t blkCnt; /* Loop counter */ + q63_t sum = 0; /* Temporary return variable */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { - /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */ + while (blkCnt > 0U) { + /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* + * B[blockSize-1] */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* Calculate dot product and store result in a temporary buffer. */ - sum = __SMLALD(read_q15x2_ia ((q15_t **) &pSrcA), read_q15x2_ia ((q15_t **) &pSrcB), sum); - sum = __SMLALD(read_q15x2_ia ((q15_t **) &pSrcA), read_q15x2_ia ((q15_t **) &pSrcB), sum); + sum = __SMLALD(read_q15x2_ia((q15_t **)&pSrcA), + read_q15x2_ia((q15_t **)&pSrcB), sum); + sum = __SMLALD(read_q15x2_ia((q15_t **)&pSrcA), + read_q15x2_ia((q15_t **)&pSrcB), sum); #else - sum += (q63_t)((q31_t) *pSrcA++ * *pSrcB++); - sum += (q63_t)((q31_t) *pSrcA++ * *pSrcB++); - sum += (q63_t)((q31_t) *pSrcA++ * *pSrcB++); - sum += (q63_t)((q31_t) *pSrcA++ * *pSrcB++); + sum += (q63_t)((q31_t)*pSrcA++ * *pSrcB++); + sum += (q63_t)((q31_t)*pSrcA++ * *pSrcB++); + sum += (q63_t)((q31_t)*pSrcA++ * *pSrcB++); + sum += (q63_t)((q31_t)*pSrcA++ * *pSrcB++); #endif /* Decrement loop counter */ @@ -96,16 +94,16 @@ void arm_dot_prod_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { - /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */ + while (blkCnt > 0U) { + /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* + * B[blockSize-1] */ /* Calculate dot product and store result in a temporary buffer. */ -//#if defined (ARM_MATH_DSP) -// sum = __SMLALD(*pSrcA++, *pSrcB++, sum); -//#else - sum += (q63_t)((q31_t) *pSrcA++ * *pSrcB++); -//#endif + //#if defined (ARM_MATH_DSP) + // sum = __SMLALD(*pSrcA++, *pSrcB++, sum); + //#else + sum += (q63_t)((q31_t)*pSrcA++ * *pSrcB++); + //#endif /* Decrement loop counter */ blkCnt--; diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_dot_prod_q31.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_dot_prod_q31.c index 76cd577..f9523ac 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_dot_prod_q31.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_dot_prod_q31.c @@ -46,40 +46,36 @@ @return none @par Scaling and Overflow Behavior - The intermediate multiplications are in 1.31 x 1.31 = 2.62 format and these - are truncated to 2.48 format by discarding the lower 14 bits. - The 2.48 result is then added without saturation to a 64-bit accumulator in 16.48 format. - There are 15 guard bits in the accumulator and there is no risk of overflow as long as - the length of the vectors is less than 2^16 elements. - The return result is in 16.48 format. + The intermediate multiplications are in 1.31 x 1.31 = 2.62 + format and these are truncated to 2.48 format by discarding the lower 14 bits. + The 2.48 result is then added without saturation to a 64-bit + accumulator in 16.48 format. There are 15 guard bits in the accumulator and + there is no risk of overflow as long as the length of the vectors is less than + 2^16 elements. The return result is in 16.48 format. */ -void arm_dot_prod_q31( - const q31_t * pSrcA, - const q31_t * pSrcB, - uint32_t blockSize, - q63_t * result) -{ - uint32_t blkCnt; /* Loop counter */ - q63_t sum = 0; /* Temporary return variable */ +void arm_dot_prod_q31(const q31_t *pSrcA, const q31_t *pSrcB, + uint32_t blockSize, q63_t *result) { + uint32_t blkCnt; /* Loop counter */ + q63_t sum = 0; /* Temporary return variable */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { - /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */ + while (blkCnt > 0U) { + /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* + * B[blockSize-1] */ /* Calculate dot product and store result in a temporary buffer. */ - sum += ((q63_t) *pSrcA++ * *pSrcB++) >> 14U; + sum += ((q63_t)*pSrcA++ * *pSrcB++) >> 14U; - sum += ((q63_t) *pSrcA++ * *pSrcB++) >> 14U; + sum += ((q63_t)*pSrcA++ * *pSrcB++) >> 14U; - sum += ((q63_t) *pSrcA++ * *pSrcB++) >> 14U; + sum += ((q63_t)*pSrcA++ * *pSrcB++) >> 14U; - sum += ((q63_t) *pSrcA++ * *pSrcB++) >> 14U; + sum += ((q63_t)*pSrcA++ * *pSrcB++) >> 14U; /* Decrement loop counter */ blkCnt--; @@ -95,12 +91,12 @@ void arm_dot_prod_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { - /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */ + while (blkCnt > 0U) { + /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* + * B[blockSize-1] */ /* Calculate dot product and store result in a temporary buffer. */ - sum += ((q63_t) *pSrcA++ * *pSrcB++) >> 14U; + sum += ((q63_t)*pSrcA++ * *pSrcB++) >> 14U; /* Decrement loop counter */ blkCnt--; diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_dot_prod_q7.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_dot_prod_q7.c index 8e18a73..e75237e 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_dot_prod_q7.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_dot_prod_q7.c @@ -46,41 +46,37 @@ @return none @par Scaling and Overflow Behavior - The intermediate multiplications are in 1.7 x 1.7 = 2.14 format and these - results are added to an accumulator in 18.14 format. - Nonsaturating additions are used and there is no danger of wrap around as long as - the vectors are less than 2^18 elements long. - The return result is in 18.14 format. + The intermediate multiplications are in 1.7 x 1.7 = 2.14 + format and these results are added to an accumulator in 18.14 format. + Nonsaturating additions are used and there is no danger of + wrap around as long as the vectors are less than 2^18 elements long. The + return result is in 18.14 format. */ -void arm_dot_prod_q7( - const q7_t * pSrcA, - const q7_t * pSrcB, - uint32_t blockSize, - q31_t * result) -{ - uint32_t blkCnt; /* Loop counter */ - q31_t sum = 0; /* Temporary return variable */ +void arm_dot_prod_q7(const q7_t *pSrcA, const q7_t *pSrcB, uint32_t blockSize, + q31_t *result) { + uint32_t blkCnt; /* Loop counter */ + q31_t sum = 0; /* Temporary return variable */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) -#if defined (ARM_MATH_DSP) - q31_t input1, input2; /* Temporary variables */ - q31_t inA1, inA2, inB1, inB2; /* Temporary variables */ +#if defined(ARM_MATH_DSP) + q31_t input1, input2; /* Temporary variables */ + q31_t inA1, inA2, inB1, inB2; /* Temporary variables */ #endif /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { - /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */ + while (blkCnt > 0U) { + /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* + * B[blockSize-1] */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* read 4 samples at a time from sourceA */ - input1 = read_q7x4_ia ((q7_t **) &pSrcA); + input1 = read_q7x4_ia((q7_t **)&pSrcA); /* read 4 samples at a time from sourceB */ - input2 = read_q7x4_ia ((q7_t **) &pSrcB); + input2 = read_q7x4_ia((q7_t **)&pSrcB); /* extract two q7_t samples to q15_t samples */ inA1 = __SXTB16(__ROR(input1, 8)); @@ -95,10 +91,10 @@ void arm_dot_prod_q7( sum = __SMLAD(inA1, inB1, sum); sum = __SMLAD(inA2, inB2, sum); #else - sum += (q31_t) ((q15_t) *pSrcA++ * *pSrcB++); - sum += (q31_t) ((q15_t) *pSrcA++ * *pSrcB++); - sum += (q31_t) ((q15_t) *pSrcA++ * *pSrcB++); - sum += (q31_t) ((q15_t) *pSrcA++ * *pSrcB++); + sum += (q31_t)((q15_t)*pSrcA++ * *pSrcB++); + sum += (q31_t)((q15_t)*pSrcA++ * *pSrcB++); + sum += (q31_t)((q15_t)*pSrcA++ * *pSrcB++); + sum += (q31_t)((q15_t)*pSrcA++ * *pSrcB++); #endif /* Decrement loop counter */ @@ -115,16 +111,16 @@ void arm_dot_prod_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { - /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */ + while (blkCnt > 0U) { + /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* + * B[blockSize-1] */ /* Calculate dot product and store result in a temporary buffer. */ -//#if defined (ARM_MATH_DSP) -// sum = __SMLAD(*pSrcA++, *pSrcB++, sum); -//#else - sum += (q31_t) ((q15_t) *pSrcA++ * *pSrcB++); -//#endif + //#if defined (ARM_MATH_DSP) + // sum = __SMLAD(*pSrcA++, *pSrcB++, sum); + //#else + sum += (q31_t)((q15_t)*pSrcA++ * *pSrcB++); + //#endif /* Decrement loop counter */ blkCnt--; diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_mult_f32.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_mult_f32.c index 24f74f0..4c9d31e 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_mult_f32.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_mult_f32.c @@ -58,21 +58,16 @@ @return none */ -void arm_mult_f32( - const float32_t * pSrcA, - const float32_t * pSrcB, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_mult_f32(const float32_t *pSrcA, const float32_t *pSrcB, + float32_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A * B */ /* Multiply inputs and store result in destination buffer. */ @@ -98,8 +93,7 @@ void arm_mult_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A * B */ /* Multiply input and store result in destination buffer. */ @@ -108,7 +102,6 @@ void arm_mult_f32( /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_mult_q15.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_mult_q15.c index 37aa924..056d7e3 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_mult_q15.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_mult_q15.c @@ -47,68 +47,64 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q15 range [0x8000 0x7FFF] are saturated. + Results outside of the allowable Q15 range [0x8000 0x7FFF] + are saturated. */ -void arm_mult_q15( - const q15_t * pSrcA, - const q15_t * pSrcB, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_mult_q15(const q15_t *pSrcA, const q15_t *pSrcB, q15_t *pDst, + uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) -#if defined (ARM_MATH_DSP) - q31_t inA1, inA2, inB1, inB2; /* Temporary input variables */ - q15_t out1, out2, out3, out4; /* Temporary output variables */ - q31_t mul1, mul2, mul3, mul4; /* Temporary variables */ +#if defined(ARM_MATH_DSP) + q31_t inA1, inA2, inB1, inB2; /* Temporary input variables */ + q15_t out1, out2, out3, out4; /* Temporary output variables */ + q31_t mul1, mul2, mul3, mul4; /* Temporary variables */ #endif /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A * B */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* read 2 samples at a time from sourceA */ - inA1 = read_q15x2_ia ((q15_t **) &pSrcA); + inA1 = read_q15x2_ia((q15_t **)&pSrcA); /* read 2 samples at a time from sourceB */ - inB1 = read_q15x2_ia ((q15_t **) &pSrcB); + inB1 = read_q15x2_ia((q15_t **)&pSrcB); /* read 2 samples at a time from sourceA */ - inA2 = read_q15x2_ia ((q15_t **) &pSrcA); + inA2 = read_q15x2_ia((q15_t **)&pSrcA); /* read 2 samples at a time from sourceB */ - inB2 = read_q15x2_ia ((q15_t **) &pSrcB); + inB2 = read_q15x2_ia((q15_t **)&pSrcB); /* multiply mul = sourceA * sourceB */ - mul1 = (q31_t) ((q15_t) (inA1 >> 16) * (q15_t) (inB1 >> 16)); - mul2 = (q31_t) ((q15_t) (inA1 ) * (q15_t) (inB1 )); - mul3 = (q31_t) ((q15_t) (inA2 >> 16) * (q15_t) (inB2 >> 16)); - mul4 = (q31_t) ((q15_t) (inA2 ) * (q15_t) (inB2 )); + mul1 = (q31_t)((q15_t)(inA1 >> 16) * (q15_t)(inB1 >> 16)); + mul2 = (q31_t)((q15_t)(inA1) * (q15_t)(inB1)); + mul3 = (q31_t)((q15_t)(inA2 >> 16) * (q15_t)(inB2 >> 16)); + mul4 = (q31_t)((q15_t)(inA2) * (q15_t)(inB2)); /* saturate result to 16 bit */ - out1 = (q15_t) __SSAT(mul1 >> 15, 16); - out2 = (q15_t) __SSAT(mul2 >> 15, 16); - out3 = (q15_t) __SSAT(mul3 >> 15, 16); - out4 = (q15_t) __SSAT(mul4 >> 15, 16); + out1 = (q15_t)__SSAT(mul1 >> 15, 16); + out2 = (q15_t)__SSAT(mul2 >> 15, 16); + out3 = (q15_t)__SSAT(mul3 >> 15, 16); + out4 = (q15_t)__SSAT(mul4 >> 15, 16); /* store result to destination */ #ifndef ARM_MATH_BIG_ENDIAN - write_q15x2_ia (&pDst, __PKHBT(out2, out1, 16)); - write_q15x2_ia (&pDst, __PKHBT(out4, out3, 16)); + write_q15x2_ia(&pDst, __PKHBT(out2, out1, 16)); + write_q15x2_ia(&pDst, __PKHBT(out4, out3, 16)); #else - write_q15x2_ia (&pDst, __PKHBT(out1, out2, 16)); - write_q15x2_ia (&pDst, __PKHBT(out3, out4, 16)); + write_q15x2_ia(&pDst, __PKHBT(out1, out2, 16)); + write_q15x2_ia(&pDst, __PKHBT(out3, out4, 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ #else - *pDst++ = (q15_t) __SSAT((((q31_t) (*pSrcA++) * (*pSrcB++)) >> 15), 16); - *pDst++ = (q15_t) __SSAT((((q31_t) (*pSrcA++) * (*pSrcB++)) >> 15), 16); - *pDst++ = (q15_t) __SSAT((((q31_t) (*pSrcA++) * (*pSrcB++)) >> 15), 16); - *pDst++ = (q15_t) __SSAT((((q31_t) (*pSrcA++) * (*pSrcB++)) >> 15), 16); + *pDst++ = (q15_t)__SSAT((((q31_t)(*pSrcA++) * (*pSrcB++)) >> 15), 16); + *pDst++ = (q15_t)__SSAT((((q31_t)(*pSrcA++) * (*pSrcB++)) >> 15), 16); + *pDst++ = (q15_t)__SSAT((((q31_t)(*pSrcA++) * (*pSrcB++)) >> 15), 16); + *pDst++ = (q15_t)__SSAT((((q31_t)(*pSrcA++) * (*pSrcB++)) >> 15), 16); #endif /* Decrement loop counter */ @@ -125,17 +121,15 @@ void arm_mult_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A * B */ /* Multiply inputs and store result in destination buffer. */ - *pDst++ = (q15_t) __SSAT((((q31_t) (*pSrcA++) * (*pSrcB++)) >> 15), 16); + *pDst++ = (q15_t)__SSAT((((q31_t)(*pSrcA++) * (*pSrcB++)) >> 15), 16); /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_mult_q31.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_mult_q31.c index 9592684..16ea93a 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_mult_q31.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_mult_q31.c @@ -47,41 +47,37 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q31 range[0x80000000 0x7FFFFFFF] are saturated. + Results outside of the allowable Q31 range[0x80000000 + 0x7FFFFFFF] are saturated. */ -void arm_mult_q31( - const q31_t * pSrcA, - const q31_t * pSrcB, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - q31_t out; /* Temporary output variable */ +void arm_mult_q31(const q31_t *pSrcA, const q31_t *pSrcB, q31_t *pDst, + uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + q31_t out; /* Temporary output variable */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A * B */ /* Multiply inputs and store result in destination buffer. */ - out = ((q63_t) *pSrcA++ * *pSrcB++) >> 32; + out = ((q63_t)*pSrcA++ * *pSrcB++) >> 32; out = __SSAT(out, 31); *pDst++ = out << 1U; - out = ((q63_t) *pSrcA++ * *pSrcB++) >> 32; + out = ((q63_t)*pSrcA++ * *pSrcB++) >> 32; out = __SSAT(out, 31); *pDst++ = out << 1U; - out = ((q63_t) *pSrcA++ * *pSrcB++) >> 32; + out = ((q63_t)*pSrcA++ * *pSrcB++) >> 32; out = __SSAT(out, 31); *pDst++ = out << 1U; - out = ((q63_t) *pSrcA++ * *pSrcB++) >> 32; + out = ((q63_t)*pSrcA++ * *pSrcB++) >> 32; out = __SSAT(out, 31); *pDst++ = out << 1U; @@ -99,19 +95,17 @@ void arm_mult_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A * B */ /* Multiply inputs and store result in destination buffer. */ - out = ((q63_t) *pSrcA++ * *pSrcB++) >> 32; + out = ((q63_t)*pSrcA++ * *pSrcB++) >> 32; out = __SSAT(out, 31); *pDst++ = out << 1U; /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_mult_q7.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_mult_q7.c index 5587ce5..15fef7d 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_mult_q7.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_mult_q7.c @@ -47,44 +47,40 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q7 range [0x80 0x7F] are saturated. + Results outside of the allowable Q7 range [0x80 0x7F] are + saturated. */ -void arm_mult_q7( - const q7_t * pSrcA, - const q7_t * pSrcB, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_mult_q7(const q7_t *pSrcA, const q7_t *pSrcB, q7_t *pDst, + uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) -#if defined (ARM_MATH_DSP) - q7_t out1, out2, out3, out4; /* Temporary output variables */ +#if defined(ARM_MATH_DSP) + q7_t out1, out2, out3, out4; /* Temporary output variables */ #endif /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A * B */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* Multiply inputs and store results in temporary variables */ - out1 = (q7_t) __SSAT((((q15_t) (*pSrcA++) * (*pSrcB++)) >> 7), 8); - out2 = (q7_t) __SSAT((((q15_t) (*pSrcA++) * (*pSrcB++)) >> 7), 8); - out3 = (q7_t) __SSAT((((q15_t) (*pSrcA++) * (*pSrcB++)) >> 7), 8); - out4 = (q7_t) __SSAT((((q15_t) (*pSrcA++) * (*pSrcB++)) >> 7), 8); + out1 = (q7_t)__SSAT((((q15_t)(*pSrcA++) * (*pSrcB++)) >> 7), 8); + out2 = (q7_t)__SSAT((((q15_t)(*pSrcA++) * (*pSrcB++)) >> 7), 8); + out3 = (q7_t)__SSAT((((q15_t)(*pSrcA++) * (*pSrcB++)) >> 7), 8); + out4 = (q7_t)__SSAT((((q15_t)(*pSrcA++) * (*pSrcB++)) >> 7), 8); /* Pack and store result in destination buffer (in single write) */ - write_q7x4_ia (&pDst, __PACKq7(out1, out2, out3, out4)); + write_q7x4_ia(&pDst, __PACKq7(out1, out2, out3, out4)); #else - *pDst++ = (q7_t) __SSAT((((q15_t) (*pSrcA++) * (*pSrcB++)) >> 7), 8); - *pDst++ = (q7_t) __SSAT((((q15_t) (*pSrcA++) * (*pSrcB++)) >> 7), 8); - *pDst++ = (q7_t) __SSAT((((q15_t) (*pSrcA++) * (*pSrcB++)) >> 7), 8); - *pDst++ = (q7_t) __SSAT((((q15_t) (*pSrcA++) * (*pSrcB++)) >> 7), 8); + *pDst++ = (q7_t)__SSAT((((q15_t)(*pSrcA++) * (*pSrcB++)) >> 7), 8); + *pDst++ = (q7_t)__SSAT((((q15_t)(*pSrcA++) * (*pSrcB++)) >> 7), 8); + *pDst++ = (q7_t)__SSAT((((q15_t)(*pSrcA++) * (*pSrcB++)) >> 7), 8); + *pDst++ = (q7_t)__SSAT((((q15_t)(*pSrcA++) * (*pSrcB++)) >> 7), 8); #endif /* Decrement loop counter */ @@ -101,17 +97,15 @@ void arm_mult_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A * B */ /* Multiply input and store result in destination buffer. */ - *pDst++ = (q7_t) __SSAT((((q15_t) (*pSrcA++) * (*pSrcB++)) >> 7), 8); + *pDst++ = (q7_t)__SSAT((((q15_t)(*pSrcA++) * (*pSrcB++)) >> 7), 8); /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_negate_f32.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_negate_f32.c index fc020df..537da3a 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_negate_f32.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_negate_f32.c @@ -59,20 +59,16 @@ @return none */ -void arm_negate_f32( - const float32_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_negate_f32(const float32_t *pSrc, float32_t *pDst, + uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = -A */ /* Negate and store result in destination buffer. */ @@ -98,8 +94,7 @@ void arm_negate_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = -A */ /* Negate and store result in destination buffer. */ @@ -108,7 +103,6 @@ void arm_negate_f32( /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_negate_q15.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_negate_q15.c index 267e4cc..fb977fb 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_negate_q15.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_negate_q15.c @@ -48,49 +48,45 @@ Input and output buffers should be aligned by 32-bit @par Scaling and Overflow Behavior The function uses saturating arithmetic. - The Q15 value -1 (0x8000) is saturated to the maximum allowable positive value 0x7FFF. + The Q15 value -1 (0x8000) is saturated to the maximum + allowable positive value 0x7FFF. */ -void arm_negate_q15( - const q15_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - q15_t in; /* Temporary input variable */ +void arm_negate_q15(const q15_t *pSrc, q15_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + q15_t in; /* Temporary input variable */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) -#if defined (ARM_MATH_DSP) - q31_t in1; /* Temporary input variables */ +#if defined(ARM_MATH_DSP) + q31_t in1; /* Temporary input variables */ #endif /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = -A */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* Negate and store result in destination buffer (2 samples at a time). */ - in1 = read_q15x2_ia ((q15_t **) &pSrc); - write_q15x2_ia (&pDst, __QSUB16(0, in1)); + in1 = read_q15x2_ia((q15_t **)&pSrc); + write_q15x2_ia(&pDst, __QSUB16(0, in1)); - in1 = read_q15x2_ia ((q15_t **) &pSrc); - write_q15x2_ia (&pDst, __QSUB16(0, in1)); + in1 = read_q15x2_ia((q15_t **)&pSrc); + write_q15x2_ia(&pDst, __QSUB16(0, in1)); #else in = *pSrc++; - *pDst++ = (in == (q15_t) 0x8000) ? (q15_t) 0x7fff : -in; + *pDst++ = (in == (q15_t)0x8000) ? (q15_t)0x7fff : -in; in = *pSrc++; - *pDst++ = (in == (q15_t) 0x8000) ? (q15_t) 0x7fff : -in; + *pDst++ = (in == (q15_t)0x8000) ? (q15_t)0x7fff : -in; in = *pSrc++; - *pDst++ = (in == (q15_t) 0x8000) ? (q15_t) 0x7fff : -in; + *pDst++ = (in == (q15_t)0x8000) ? (q15_t)0x7fff : -in; in = *pSrc++; - *pDst++ = (in == (q15_t) 0x8000) ? (q15_t) 0x7fff : -in; + *pDst++ = (in == (q15_t)0x8000) ? (q15_t)0x7fff : -in; #endif /* Decrement loop counter */ @@ -107,18 +103,16 @@ void arm_negate_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = -A */ /* Negate and store result in destination buffer. */ in = *pSrc++; - *pDst++ = (in == (q15_t) 0x8000) ? (q15_t) 0x7fff : -in; + *pDst++ = (in == (q15_t)0x8000) ? (q15_t)0x7fff : -in; /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_negate_q31.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_negate_q31.c index 645fb0a..93f6473 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_negate_q31.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_negate_q31.c @@ -46,50 +46,46 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - The Q31 value -1 (0x80000000) is saturated to the maximum allowable positive value 0x7FFFFFFF. + The Q31 value -1 (0x80000000) is saturated to the maximum + allowable positive value 0x7FFFFFFF. */ -void arm_negate_q31( - const q31_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - q31_t in; /* Temporary input variable */ +void arm_negate_q31(const q31_t *pSrc, q31_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + q31_t in; /* Temporary input variable */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = -A */ /* Negate and store result in destination buffer. */ in = *pSrc++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = __QSUB(0, in); #else *pDst++ = (in == INT32_MIN) ? INT32_MAX : -in; #endif in = *pSrc++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = __QSUB(0, in); #else *pDst++ = (in == INT32_MIN) ? INT32_MAX : -in; #endif in = *pSrc++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = __QSUB(0, in); #else *pDst++ = (in == INT32_MIN) ? INT32_MAX : -in; #endif in = *pSrc++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = __QSUB(0, in); #else *pDst++ = (in == INT32_MIN) ? INT32_MAX : -in; @@ -109,13 +105,12 @@ void arm_negate_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = -A */ /* Negate and store result in destination buffer. */ in = *pSrc++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = __QSUB(0, in); #else *pDst++ = (in == INT32_MIN) ? INT32_MAX : -in; @@ -124,7 +119,6 @@ void arm_negate_q31( /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_negate_q7.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_negate_q7.c index 40a373e..4a4980a 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_negate_q7.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_negate_q7.c @@ -46,46 +46,42 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - The Q7 value -1 (0x80) is saturated to the maximum allowable positive value 0x7F. + The Q7 value -1 (0x80) is saturated to the maximum allowable + positive value 0x7F. */ -void arm_negate_q7( - const q7_t * pSrc, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - q7_t in; /* Temporary input variable */ +void arm_negate_q7(const q7_t *pSrc, q7_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + q7_t in; /* Temporary input variable */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) -#if defined (ARM_MATH_DSP) - q31_t in1; /* Temporary input variable */ +#if defined(ARM_MATH_DSP) + q31_t in1; /* Temporary input variable */ #endif /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = -A */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* Negate and store result in destination buffer (4 samples at a time). */ - in1 = read_q7x4_ia ((q7_t **) &pSrc); - write_q7x4_ia (&pDst, __QSUB8(0, in1)); + in1 = read_q7x4_ia((q7_t **)&pSrc); + write_q7x4_ia(&pDst, __QSUB8(0, in1)); #else in = *pSrc++; - *pDst++ = (in == (q7_t) 0x80) ? (q7_t) 0x7f : -in; + *pDst++ = (in == (q7_t)0x80) ? (q7_t)0x7f : -in; in = *pSrc++; - *pDst++ = (in == (q7_t) 0x80) ? (q7_t) 0x7f : -in; + *pDst++ = (in == (q7_t)0x80) ? (q7_t)0x7f : -in; in = *pSrc++; - *pDst++ = (in == (q7_t) 0x80) ? (q7_t) 0x7f : -in; + *pDst++ = (in == (q7_t)0x80) ? (q7_t)0x7f : -in; in = *pSrc++; - *pDst++ = (in == (q7_t) 0x80) ? (q7_t) 0x7f : -in; + *pDst++ = (in == (q7_t)0x80) ? (q7_t)0x7f : -in; #endif /* Decrement loop counter */ @@ -102,23 +98,21 @@ void arm_negate_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = -A */ /* Negate and store result in destination buffer. */ in = *pSrc++; -#if defined (ARM_MATH_DSP) - *pDst++ = (q7_t) __QSUB(0, in); +#if defined(ARM_MATH_DSP) + *pDst++ = (q7_t)__QSUB(0, in); #else - *pDst++ = (in == (q7_t) 0x80) ? (q7_t) 0x7f : -in; + *pDst++ = (in == (q7_t)0x80) ? (q7_t)0x7f : -in; #endif /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_offset_f32.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_offset_f32.c index 43c894f..20dd49d 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_offset_f32.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_offset_f32.c @@ -60,21 +60,16 @@ @return none */ -void arm_offset_f32( - const float32_t * pSrc, - float32_t offset, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_offset_f32(const float32_t *pSrc, float32_t offset, float32_t *pDst, + uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A + offset */ /* Add offset and store result in destination buffer. */ @@ -100,8 +95,7 @@ void arm_offset_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A + offset */ /* Add offset and store result in destination buffer. */ @@ -110,7 +104,6 @@ void arm_offset_f32( /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_offset_q15.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_offset_q15.c index cd2f22b..e0a9cfb 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_offset_q15.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_offset_q15.c @@ -47,21 +47,18 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q15 range [0x8000 0x7FFF] are saturated. + Results outside of the allowable Q15 range [0x8000 0x7FFF] + are saturated. */ -void arm_offset_q15( - const q15_t * pSrc, - q15_t offset, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_offset_q15(const q15_t *pSrc, q15_t offset, q15_t *pDst, + uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) -#if defined (ARM_MATH_DSP) - q31_t offset_packed; /* Offset packed to 32 bit */ +#if defined(ARM_MATH_DSP) + q31_t offset_packed; /* Offset packed to 32 bit */ /* Offset is packed to 32 bit in order to use SIMD32 for addition */ offset_packed = __PKHBT(offset, offset, 16); @@ -70,19 +67,21 @@ void arm_offset_q15( /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A + offset */ -#if defined (ARM_MATH_DSP) - /* Add offset and store result in destination buffer (2 samples at a time). */ - write_q15x2_ia (&pDst, __QADD16(read_q15x2_ia ((q15_t **) &pSrc), offset_packed)); - write_q15x2_ia (&pDst, __QADD16(read_q15x2_ia ((q15_t **) &pSrc), offset_packed)); +#if defined(ARM_MATH_DSP) + /* Add offset and store result in destination buffer (2 samples at a time). + */ + write_q15x2_ia(&pDst, + __QADD16(read_q15x2_ia((q15_t **)&pSrc), offset_packed)); + write_q15x2_ia(&pDst, + __QADD16(read_q15x2_ia((q15_t **)&pSrc), offset_packed)); #else - *pDst++ = (q15_t) __SSAT(((q31_t) *pSrc++ + offset), 16); - *pDst++ = (q15_t) __SSAT(((q31_t) *pSrc++ + offset), 16); - *pDst++ = (q15_t) __SSAT(((q31_t) *pSrc++ + offset), 16); - *pDst++ = (q15_t) __SSAT(((q31_t) *pSrc++ + offset), 16); + *pDst++ = (q15_t)__SSAT(((q31_t)*pSrc++ + offset), 16); + *pDst++ = (q15_t)__SSAT(((q31_t)*pSrc++ + offset), 16); + *pDst++ = (q15_t)__SSAT(((q31_t)*pSrc++ + offset), 16); + *pDst++ = (q15_t)__SSAT(((q31_t)*pSrc++ + offset), 16); #endif /* Decrement loop counter */ @@ -99,21 +98,19 @@ void arm_offset_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A + offset */ /* Add offset and store result in destination buffer. */ -#if defined (ARM_MATH_DSP) - *pDst++ = (q15_t) __QADD16(*pSrc++, offset); +#if defined(ARM_MATH_DSP) + *pDst++ = (q15_t)__QADD16(*pSrc++, offset); #else - *pDst++ = (q15_t) __SSAT(((q31_t) *pSrc++ + offset), 16); + *pDst++ = (q15_t)__SSAT(((q31_t)*pSrc++ + offset), 16); #endif /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_offset_q31.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_offset_q31.c index 5de36b4..825de23 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_offset_q31.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_offset_q31.c @@ -47,49 +47,45 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q31 range [0x80000000 0x7FFFFFFF] are saturated. + Results outside of the allowable Q31 range [0x80000000 + 0x7FFFFFFF] are saturated. */ -void arm_offset_q31( - const q31_t * pSrc, - q31_t offset, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_offset_q31(const q31_t *pSrc, q31_t offset, q31_t *pDst, + uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A + offset */ /* Add offset and store result in destination buffer. */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = __QADD(*pSrc++, offset); #else - *pDst++ = (q31_t) clip_q63_to_q31((q63_t) * pSrc++ + offset); + *pDst++ = (q31_t)clip_q63_to_q31((q63_t)*pSrc++ + offset); #endif -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = __QADD(*pSrc++, offset); #else - *pDst++ = (q31_t) clip_q63_to_q31((q63_t) * pSrc++ + offset); + *pDst++ = (q31_t)clip_q63_to_q31((q63_t)*pSrc++ + offset); #endif -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = __QADD(*pSrc++, offset); #else - *pDst++ = (q31_t) clip_q63_to_q31((q63_t) * pSrc++ + offset); + *pDst++ = (q31_t)clip_q63_to_q31((q63_t)*pSrc++ + offset); #endif -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = __QADD(*pSrc++, offset); #else - *pDst++ = (q31_t) clip_q63_to_q31((q63_t) * pSrc++ + offset); + *pDst++ = (q31_t)clip_q63_to_q31((q63_t)*pSrc++ + offset); #endif /* Decrement loop counter */ @@ -106,21 +102,19 @@ void arm_offset_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A + offset */ /* Add offset and store result in destination buffer. */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) *pDst++ = __QADD(*pSrc++, offset); #else - *pDst++ = (q31_t) clip_q63_to_q31((q63_t) * pSrc++ + offset); + *pDst++ = (q31_t)clip_q63_to_q31((q63_t)*pSrc++ + offset); #endif /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_offset_q7.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_offset_q7.c index f67db45..4b6b4d3 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_offset_q7.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_offset_q7.c @@ -47,21 +47,18 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q7 range [0x80 0x7F] are saturated. + Results outside of the allowable Q7 range [0x80 0x7F] are + saturated. */ -void arm_offset_q7( - const q7_t * pSrc, - q7_t offset, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_offset_q7(const q7_t *pSrc, q7_t offset, q7_t *pDst, + uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) -#if defined (ARM_MATH_DSP) - q31_t offset_packed; /* Offset packed to 32 bit */ +#if defined(ARM_MATH_DSP) + q31_t offset_packed; /* Offset packed to 32 bit */ /* Offset is packed to 32 bit in order to use SIMD32 for addition */ offset_packed = __PACKq7(offset, offset, offset, offset); @@ -70,18 +67,18 @@ void arm_offset_q7( /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A + offset */ -#if defined (ARM_MATH_DSP) - /* Add offset and store result in destination buffer (4 samples at a time). */ - write_q7x4_ia (&pDst, __QADD8(read_q7x4_ia ((q7_t **) &pSrc), offset_packed)); +#if defined(ARM_MATH_DSP) + /* Add offset and store result in destination buffer (4 samples at a time). + */ + write_q7x4_ia(&pDst, __QADD8(read_q7x4_ia((q7_t **)&pSrc), offset_packed)); #else - *pDst++ = (q7_t) __SSAT(*pSrc++ + offset, 8); - *pDst++ = (q7_t) __SSAT(*pSrc++ + offset, 8); - *pDst++ = (q7_t) __SSAT(*pSrc++ + offset, 8); - *pDst++ = (q7_t) __SSAT(*pSrc++ + offset, 8); + *pDst++ = (q7_t)__SSAT(*pSrc++ + offset, 8); + *pDst++ = (q7_t)__SSAT(*pSrc++ + offset, 8); + *pDst++ = (q7_t)__SSAT(*pSrc++ + offset, 8); + *pDst++ = (q7_t)__SSAT(*pSrc++ + offset, 8); #endif /* Decrement loop counter */ @@ -98,17 +95,15 @@ void arm_offset_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A + offset */ /* Add offset and store result in destination buffer. */ - *pDst++ = (q7_t) __SSAT((q15_t) *pSrc++ + offset, 8); + *pDst++ = (q7_t)__SSAT((q15_t)*pSrc++ + offset, 8); /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_scale_f32.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_scale_f32.c index 675f396..59cf041 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_scale_f32.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_scale_f32.c @@ -35,16 +35,17 @@ /** @defgroup BasicScale Vector Scale - Multiply a vector by a scalar value. For floating-point data, the algorithm used is: + Multiply a vector by a scalar value. For floating-point data, the algorithm + used is:
       pDst[n] = pSrc[n] * scale,   0 <= n < blockSize.
   
- In the fixed-point Q7, Q15, and Q31 functions, scale is represented by - a fractional multiplication scaleFract and an arithmetic shift shift. - The shift allows the gain of the scaling operation to exceed 1.0. - The algorithm used with fixed-point data is: + In the fixed-point Q7, Q15, and Q31 functions, scale is + represented by a fractional multiplication scaleFract and an + arithmetic shift shift. The shift allows the gain of the scaling + operation to exceed 1.0. The algorithm used with fixed-point data is:
       pDst[n] = (pSrc[n] * scaleFract) << shift,   0 <= n < blockSize.
@@ -73,21 +74,16 @@
   @return        none
  */
 
-void arm_scale_f32(
-  const float32_t *pSrc,
-        float32_t scale,
-        float32_t *pDst,
-        uint32_t blockSize)
-{
-        uint32_t blkCnt;                               /* Loop counter */
+void arm_scale_f32(const float32_t *pSrc, float32_t scale, float32_t *pDst,
+                   uint32_t blockSize) {
+  uint32_t blkCnt; /* Loop counter */
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
   /* Loop unrolling: Compute 4 outputs at a time */
   blkCnt = blockSize >> 2U;
 
-  while (blkCnt > 0U)
-  {
+  while (blkCnt > 0U) {
     /* C = A * scale */
 
     /* Scale input and store result in destination buffer. */
@@ -113,8 +109,7 @@ void arm_scale_f32(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-  while (blkCnt > 0U)
-  {
+  while (blkCnt > 0U) {
     /* C = A * scale */
 
     /* Scale input and store result in destination buffer. */
@@ -123,7 +118,6 @@ void arm_scale_f32(
     /* Decrement loop counter */
     blkCnt--;
   }
-
 }
 
 /**
diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_scale_q15.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_scale_q15.c
index 039b93d..d567109 100644
--- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_scale_q15.c
+++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_scale_q15.c
@@ -47,48 +47,43 @@
   @return        none
 
   @par           Scaling and Overflow Behavior
-                   The input data *pSrc and scaleFract are in 1.15 format.
-                   These are multiplied to yield a 2.30 intermediate result and this is shifted with saturation to 1.15 format.
+                   The input data *pSrc and scaleFract
+  are in 1.15 format. These are multiplied to yield a 2.30 intermediate result
+  and this is shifted with saturation to 1.15 format.
  */
 
-void arm_scale_q15(
-  const q15_t *pSrc,
-        q15_t scaleFract,
-        int8_t shift,
-        q15_t *pDst,
-        uint32_t blockSize)
-{
-        uint32_t blkCnt;                               /* Loop counter */
-        int8_t kShift = 15 - shift;                    /* Shift to apply after scaling */
+void arm_scale_q15(const q15_t *pSrc, q15_t scaleFract, int8_t shift,
+                   q15_t *pDst, uint32_t blockSize) {
+  uint32_t blkCnt;            /* Loop counter */
+  int8_t kShift = 15 - shift; /* Shift to apply after scaling */
 
-#if defined (ARM_MATH_LOOPUNROLL)
-#if defined (ARM_MATH_DSP)
+#if defined(ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_DSP)
   q31_t inA1, inA2;
-  q31_t out1, out2, out3, out4;                  /* Temporary output variables */
-  q15_t in1, in2, in3, in4;                      /* Temporary input variables */
+  q31_t out1, out2, out3, out4; /* Temporary output variables */
+  q15_t in1, in2, in3, in4;     /* Temporary input variables */
 #endif
 #endif
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
   /* Loop unrolling: Compute 4 outputs at a time */
   blkCnt = blockSize >> 2U;
 
-  while (blkCnt > 0U)
-  {
+  while (blkCnt > 0U) {
     /* C = A * scale */
 
-#if defined (ARM_MATH_DSP)
+#if defined(ARM_MATH_DSP)
     /* read 2 times 2 samples at a time from source */
-    inA1 = read_q15x2_ia ((q15_t **) &pSrc);
-    inA2 = read_q15x2_ia ((q15_t **) &pSrc);
+    inA1 = read_q15x2_ia((q15_t **)&pSrc);
+    inA2 = read_q15x2_ia((q15_t **)&pSrc);
 
     /* Scale inputs and store result in temporary variables
      * in single cycle by packing the outputs */
-    out1 = (q31_t) ((q15_t) (inA1 >> 16) * scaleFract);
-    out2 = (q31_t) ((q15_t) (inA1      ) * scaleFract);
-    out3 = (q31_t) ((q15_t) (inA2 >> 16) * scaleFract);
-    out4 = (q31_t) ((q15_t) (inA2      ) * scaleFract);
+    out1 = (q31_t)((q15_t)(inA1 >> 16) * scaleFract);
+    out2 = (q31_t)((q15_t)(inA1)*scaleFract);
+    out3 = (q31_t)((q15_t)(inA2 >> 16) * scaleFract);
+    out4 = (q31_t)((q15_t)(inA2)*scaleFract);
 
     /* apply shifting */
     out1 = out1 >> kShift;
@@ -97,19 +92,19 @@ void arm_scale_q15(
     out4 = out4 >> kShift;
 
     /* saturate the output */
-    in1 = (q15_t) (__SSAT(out1, 16));
-    in2 = (q15_t) (__SSAT(out2, 16));
-    in3 = (q15_t) (__SSAT(out3, 16));
-    in4 = (q15_t) (__SSAT(out4, 16));
+    in1 = (q15_t)(__SSAT(out1, 16));
+    in2 = (q15_t)(__SSAT(out2, 16));
+    in3 = (q15_t)(__SSAT(out3, 16));
+    in4 = (q15_t)(__SSAT(out4, 16));
 
     /* store result to destination */
-    write_q15x2_ia (&pDst, __PKHBT(in2, in1, 16));
-    write_q15x2_ia (&pDst, __PKHBT(in4, in3, 16));
+    write_q15x2_ia(&pDst, __PKHBT(in2, in1, 16));
+    write_q15x2_ia(&pDst, __PKHBT(in4, in3, 16));
 #else
-    *pDst++ = (q15_t) (__SSAT(((q31_t) *pSrc++ * scaleFract) >> kShift, 16));
-    *pDst++ = (q15_t) (__SSAT(((q31_t) *pSrc++ * scaleFract) >> kShift, 16));
-    *pDst++ = (q15_t) (__SSAT(((q31_t) *pSrc++ * scaleFract) >> kShift, 16));
-    *pDst++ = (q15_t) (__SSAT(((q31_t) *pSrc++ * scaleFract) >> kShift, 16));
+    *pDst++ = (q15_t)(__SSAT(((q31_t)*pSrc++ * scaleFract) >> kShift, 16));
+    *pDst++ = (q15_t)(__SSAT(((q31_t)*pSrc++ * scaleFract) >> kShift, 16));
+    *pDst++ = (q15_t)(__SSAT(((q31_t)*pSrc++ * scaleFract) >> kShift, 16));
+    *pDst++ = (q15_t)(__SSAT(((q31_t)*pSrc++ * scaleFract) >> kShift, 16));
 #endif
 
     /* Decrement loop counter */
@@ -126,17 +121,15 @@ void arm_scale_q15(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-  while (blkCnt > 0U)
-  {
+  while (blkCnt > 0U) {
     /* C = A * scale */
 
     /* Scale input and store result in destination buffer. */
-    *pDst++ = (q15_t) (__SSAT(((q31_t) *pSrc++ * scaleFract) >> kShift, 16));
+    *pDst++ = (q15_t)(__SSAT(((q31_t)*pSrc++ * scaleFract) >> kShift, 16));
 
     /* Decrement loop counter */
     blkCnt--;
   }
-
 }
 
 /**
diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_scale_q31.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_scale_q31.c
index d762ca7..a1f2469 100644
--- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_scale_q31.c
+++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_scale_q31.c
@@ -47,57 +47,52 @@
   @return        none
 
   @par           Scaling and Overflow Behavior
-                   The input data *pSrc and scaleFract are in 1.31 format.
-                   These are multiplied to yield a 2.62 intermediate result and this is shifted with saturation to 1.31 format.
+                   The input data *pSrc and scaleFract
+  are in 1.31 format. These are multiplied to yield a 2.62 intermediate result
+  and this is shifted with saturation to 1.31 format.
  */
 
-void arm_scale_q31(
-  const q31_t *pSrc,
-        q31_t scaleFract,
-        int8_t shift,
-        q31_t *pDst,
-        uint32_t blockSize)
-{
-        uint32_t blkCnt;                               /* Loop counter */
-        q31_t in, out;                                 /* Temporary variables */
-        int8_t kShift = shift + 1;                     /* Shift to apply after scaling */
-        int8_t sign = (kShift & 0x80);
+void arm_scale_q31(const q31_t *pSrc, q31_t scaleFract, int8_t shift,
+                   q31_t *pDst, uint32_t blockSize) {
+  uint32_t blkCnt;           /* Loop counter */
+  q31_t in, out;             /* Temporary variables */
+  int8_t kShift = shift + 1; /* Shift to apply after scaling */
+  int8_t sign = (kShift & 0x80);
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
   /* Loop unrolling: Compute 4 outputs at a time */
   blkCnt = blockSize >> 2U;
 
-  if (sign == 0U)
-  {
-    while (blkCnt > 0U)
-    {
+  if (sign == 0U) {
+    while (blkCnt > 0U) {
       /* C = A * scale */
 
       /* Scale input and store result in destination buffer. */
-      in = *pSrc++;                                /* read input from source */
-      in = ((q63_t) in * scaleFract) >> 32;        /* multiply input with scaler value */
-      out = in << kShift;                          /* apply shifting */
-      if (in != (out >> kShift))                   /* saturate the result */
+      in = *pSrc++; /* read input from source */
+      in =
+          ((q63_t)in * scaleFract) >> 32; /* multiply input with scaler value */
+      out = in << kShift;                 /* apply shifting */
+      if (in != (out >> kShift))          /* saturate the result */
         out = 0x7FFFFFFF ^ (in >> 31);
-      *pDst++ = out;                               /* Store result destination */
+      *pDst++ = out; /* Store result destination */
 
       in = *pSrc++;
-      in = ((q63_t) in * scaleFract) >> 32;
+      in = ((q63_t)in * scaleFract) >> 32;
       out = in << kShift;
       if (in != (out >> kShift))
         out = 0x7FFFFFFF ^ (in >> 31);
       *pDst++ = out;
 
       in = *pSrc++;
-      in = ((q63_t) in * scaleFract) >> 32;
+      in = ((q63_t)in * scaleFract) >> 32;
       out = in << kShift;
       if (in != (out >> kShift))
         out = 0x7FFFFFFF ^ (in >> 31);
       *pDst++ = out;
 
       in = *pSrc++;
-      in = ((q63_t) in * scaleFract) >> 32;
+      in = ((q63_t)in * scaleFract) >> 32;
       out = in << kShift;
       if (in != (out >> kShift))
         out = 0x7FFFFFFF ^ (in >> 31);
@@ -106,31 +101,29 @@ void arm_scale_q31(
       /* Decrement loop counter */
       blkCnt--;
     }
-  }
-  else
-  {
-    while (blkCnt > 0U)
-    {
+  } else {
+    while (blkCnt > 0U) {
       /* C = A * scale */
 
       /* Scale input and store result in destination buffer. */
-      in = *pSrc++;                                /* read four inputs from source */
-      in = ((q63_t) in * scaleFract) >> 32;        /* multiply input with scaler value */
-      out = in >> -kShift;                         /* apply shifting */
-      *pDst++ = out;                               /* Store result destination */
+      in = *pSrc++; /* read four inputs from source */
+      in =
+          ((q63_t)in * scaleFract) >> 32; /* multiply input with scaler value */
+      out = in >> -kShift;                /* apply shifting */
+      *pDst++ = out;                      /* Store result destination */
 
       in = *pSrc++;
-      in = ((q63_t) in * scaleFract) >> 32;
+      in = ((q63_t)in * scaleFract) >> 32;
       out = in >> -kShift;
       *pDst++ = out;
 
       in = *pSrc++;
-      in = ((q63_t) in * scaleFract) >> 32;
+      in = ((q63_t)in * scaleFract) >> 32;
       out = in >> -kShift;
       *pDst++ = out;
 
       in = *pSrc++;
-      in = ((q63_t) in * scaleFract) >> 32;
+      in = ((q63_t)in * scaleFract) >> 32;
       out = in >> -kShift;
       *pDst++ = out;
 
@@ -149,33 +142,28 @@ void arm_scale_q31(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-  if (sign == 0U)
-  {
-    while (blkCnt > 0U)
-    {
+  if (sign == 0U) {
+    while (blkCnt > 0U) {
       /* C = A * scale */
 
       /* Scale input and store result in destination buffer. */
       in = *pSrc++;
-      in = ((q63_t) in * scaleFract) >> 32;
+      in = ((q63_t)in * scaleFract) >> 32;
       out = in << kShift;
       if (in != (out >> kShift))
-          out = 0x7FFFFFFF ^ (in >> 31);
+        out = 0x7FFFFFFF ^ (in >> 31);
       *pDst++ = out;
 
       /* Decrement loop counter */
       blkCnt--;
     }
-  }
-  else
-  {
-    while (blkCnt > 0U)
-    {
+  } else {
+    while (blkCnt > 0U) {
       /* C = A * scale */
 
       /* Scale input and store result in destination buffer. */
       in = *pSrc++;
-      in = ((q63_t) in * scaleFract) >> 32;
+      in = ((q63_t)in * scaleFract) >> 32;
       out = in >> -kShift;
       *pDst++ = out;
 
@@ -183,7 +171,6 @@ void arm_scale_q31(
       blkCnt--;
     }
   }
-
 }
 
 /**
diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_scale_q7.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_scale_q7.c
index cb967d2..cafaba8 100644
--- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_scale_q7.c
+++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_scale_q7.c
@@ -47,35 +47,30 @@
   @return        none
 
   @par           Scaling and Overflow Behavior
-                   The input data *pSrc and scaleFract are in 1.7 format.
-                   These are multiplied to yield a 2.14 intermediate result and this is shifted with saturation to 1.7 format.
+                   The input data *pSrc and scaleFract
+  are in 1.7 format. These are multiplied to yield a 2.14 intermediate result
+  and this is shifted with saturation to 1.7 format.
  */
 
-void arm_scale_q7(
-  const q7_t * pSrc,
-        q7_t scaleFract,
-        int8_t shift,
-        q7_t * pDst,
-        uint32_t blockSize)
-{
-        uint32_t blkCnt;                               /* Loop counter */
-        int8_t kShift = 7 - shift;                     /* Shift to apply after scaling */
+void arm_scale_q7(const q7_t *pSrc, q7_t scaleFract, int8_t shift, q7_t *pDst,
+                  uint32_t blockSize) {
+  uint32_t blkCnt;           /* Loop counter */
+  int8_t kShift = 7 - shift; /* Shift to apply after scaling */
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
-#if defined (ARM_MATH_DSP)
-  q7_t in1,  in2,  in3,  in4;                    /* Temporary input variables */
-  q7_t out1, out2, out3, out4;                   /* Temporary output variables */
+#if defined(ARM_MATH_DSP)
+  q7_t in1, in2, in3, in4;     /* Temporary input variables */
+  q7_t out1, out2, out3, out4; /* Temporary output variables */
 #endif
 
   /* Loop unrolling: Compute 4 outputs at a time */
   blkCnt = blockSize >> 2U;
 
-  while (blkCnt > 0U)
-  {
+  while (blkCnt > 0U) {
     /* C = A * scale */
 
-#if defined (ARM_MATH_DSP)
+#if defined(ARM_MATH_DSP)
     /* Reading 4 inputs from memory */
     in1 = *pSrc++;
     in2 = *pSrc++;
@@ -83,18 +78,18 @@ void arm_scale_q7(
     in4 = *pSrc++;
 
     /* Scale inputs and store result in the temporary variable. */
-    out1 = (q7_t) (__SSAT(((in1) * scaleFract) >> kShift, 8));
-    out2 = (q7_t) (__SSAT(((in2) * scaleFract) >> kShift, 8));
-    out3 = (q7_t) (__SSAT(((in3) * scaleFract) >> kShift, 8));
-    out4 = (q7_t) (__SSAT(((in4) * scaleFract) >> kShift, 8));
+    out1 = (q7_t)(__SSAT(((in1)*scaleFract) >> kShift, 8));
+    out2 = (q7_t)(__SSAT(((in2)*scaleFract) >> kShift, 8));
+    out3 = (q7_t)(__SSAT(((in3)*scaleFract) >> kShift, 8));
+    out4 = (q7_t)(__SSAT(((in4)*scaleFract) >> kShift, 8));
 
     /* Pack and store result in destination buffer (in single write) */
-    write_q7x4_ia (&pDst, __PACKq7(out1, out2, out3, out4));
+    write_q7x4_ia(&pDst, __PACKq7(out1, out2, out3, out4));
 #else
-    *pDst++ = (q7_t) (__SSAT((((q15_t) *pSrc++ * scaleFract) >> kShift), 8));
-    *pDst++ = (q7_t) (__SSAT((((q15_t) *pSrc++ * scaleFract) >> kShift), 8));
-    *pDst++ = (q7_t) (__SSAT((((q15_t) *pSrc++ * scaleFract) >> kShift), 8));
-    *pDst++ = (q7_t) (__SSAT((((q15_t) *pSrc++ * scaleFract) >> kShift), 8));
+    *pDst++ = (q7_t)(__SSAT((((q15_t)*pSrc++ * scaleFract) >> kShift), 8));
+    *pDst++ = (q7_t)(__SSAT((((q15_t)*pSrc++ * scaleFract) >> kShift), 8));
+    *pDst++ = (q7_t)(__SSAT((((q15_t)*pSrc++ * scaleFract) >> kShift), 8));
+    *pDst++ = (q7_t)(__SSAT((((q15_t)*pSrc++ * scaleFract) >> kShift), 8));
 #endif
 
     /* Decrement loop counter */
@@ -111,17 +106,15 @@ void arm_scale_q7(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-  while (blkCnt > 0U)
-  {
+  while (blkCnt > 0U) {
     /* C = A * scale */
 
     /* Scale input and store result in destination buffer. */
-    *pDst++ = (q7_t) (__SSAT((((q15_t) *pSrc++ * scaleFract) >> kShift), 8));
+    *pDst++ = (q7_t)(__SSAT((((q15_t)*pSrc++ * scaleFract) >> kShift), 8));
 
     /* Decrement loop counter */
     blkCnt--;
   }
-
 }
 
 /**
diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_shift_q15.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_shift_q15.c
index 8a15155..e4bdaf6 100644
--- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_shift_q15.c
+++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_shift_q15.c
@@ -1,7 +1,8 @@
 /* ----------------------------------------------------------------------
  * Project:      CMSIS DSP Library
  * Title:        arm_shift_q15.c
- * Description:  Shifts the elements of a Q15 vector by a specified number of bits
+ * Description:  Shifts the elements of a Q15 vector by a specified number of
+ * bits
  *
  * $Date:        18. March 2019
  * $Revision:    V1.6.0
@@ -40,53 +41,50 @@
 /**
   @brief         Shifts the elements of a Q15 vector a specified number of bits
   @param[in]     pSrc       points to the input vector
-  @param[in]     shiftBits  number of bits to shift.  A positive value shifts left; a negative value shifts right.
+  @param[in]     shiftBits  number of bits to shift.  A positive value shifts
+  left; a negative value shifts right.
   @param[out]    pDst       points to the output vector
   @param[in]     blockSize  number of samples in each vector
   @return        none
 
   @par           Scaling and Overflow Behavior
                    The function uses saturating arithmetic.
-                   Results outside of the allowable Q15 range [0x8000 0x7FFF] are saturated.
+                   Results outside of the allowable Q15 range [0x8000 0x7FFF]
+  are saturated.
  */
 
-void arm_shift_q15(
-  const q15_t * pSrc,
-        int8_t shiftBits,
-        q15_t * pDst,
-        uint32_t blockSize)
-{
-        uint32_t blkCnt;                               /* Loop counter */
-        uint8_t sign = (shiftBits & 0x80);             /* Sign of shiftBits */
+void arm_shift_q15(const q15_t *pSrc, int8_t shiftBits, q15_t *pDst,
+                   uint32_t blockSize) {
+  uint32_t blkCnt;                   /* Loop counter */
+  uint8_t sign = (shiftBits & 0x80); /* Sign of shiftBits */
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
-#if defined (ARM_MATH_DSP)
-  q15_t in1, in2;                                /* Temporary input variables */
+#if defined(ARM_MATH_DSP)
+  q15_t in1, in2; /* Temporary input variables */
 #endif
 
   /* Loop unrolling: Compute 4 outputs at a time */
   blkCnt = blockSize >> 2U;
 
   /* If the shift value is positive then do right shift else left shift */
-  if (sign == 0U)
-  {
-    while (blkCnt > 0U)
-    {
+  if (sign == 0U) {
+    while (blkCnt > 0U) {
       /* C = A << shiftBits */
 
-#if defined (ARM_MATH_DSP)
+#if defined(ARM_MATH_DSP)
       /* read 2 samples from source */
       in1 = *pSrc++;
       in2 = *pSrc++;
 
-      /* Shift the inputs and then store the results in the destination buffer. */
+      /* Shift the inputs and then store the results in the destination buffer.
+       */
 #ifndef ARM_MATH_BIG_ENDIAN
-      write_q15x2_ia (&pDst, __PKHBT(__SSAT((in1 << shiftBits), 16),
-                                     __SSAT((in2 << shiftBits), 16), 16));
+      write_q15x2_ia(&pDst, __PKHBT(__SSAT((in1 << shiftBits), 16),
+                                    __SSAT((in2 << shiftBits), 16), 16));
 #else
-      write_q15x2_ia (&pDst, __PKHBT(__SSAT((in2 << shiftBits), 16),
-                                      __SSAT((in1 << shiftBits), 16), 16));
+      write_q15x2_ia(&pDst, __PKHBT(__SSAT((in2 << shiftBits), 16),
+                                    __SSAT((in1 << shiftBits), 16), 16));
 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
 
       /* read 2 samples from source */
@@ -94,42 +92,40 @@ void arm_shift_q15(
       in2 = *pSrc++;
 
 #ifndef ARM_MATH_BIG_ENDIAN
-      write_q15x2_ia (&pDst, __PKHBT(__SSAT((in1 << shiftBits), 16),
-                                     __SSAT((in2 << shiftBits), 16), 16));
+      write_q15x2_ia(&pDst, __PKHBT(__SSAT((in1 << shiftBits), 16),
+                                    __SSAT((in2 << shiftBits), 16), 16));
 #else
-      write_q15x2_ia (&pDst, __PKHBT(__SSAT((in2 << shiftBits), 16),
-                                     __SSAT((in1 << shiftBits), 16), 16));
+      write_q15x2_ia(&pDst, __PKHBT(__SSAT((in2 << shiftBits), 16),
+                                    __SSAT((in1 << shiftBits), 16), 16));
 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
 
 #else
-      *pDst++ = __SSAT(((q31_t) *pSrc++ << shiftBits), 16);
-      *pDst++ = __SSAT(((q31_t) *pSrc++ << shiftBits), 16);
-      *pDst++ = __SSAT(((q31_t) *pSrc++ << shiftBits), 16);
-      *pDst++ = __SSAT(((q31_t) *pSrc++ << shiftBits), 16);
+      *pDst++ = __SSAT(((q31_t)*pSrc++ << shiftBits), 16);
+      *pDst++ = __SSAT(((q31_t)*pSrc++ << shiftBits), 16);
+      *pDst++ = __SSAT(((q31_t)*pSrc++ << shiftBits), 16);
+      *pDst++ = __SSAT(((q31_t)*pSrc++ << shiftBits), 16);
 #endif
 
       /* Decrement loop counter */
       blkCnt--;
     }
-  }
-  else
-  {
-    while (blkCnt > 0U)
-    {
+  } else {
+    while (blkCnt > 0U) {
       /* C = A >> shiftBits */
 
-#if defined (ARM_MATH_DSP)
+#if defined(ARM_MATH_DSP)
       /* read 2 samples from source */
       in1 = *pSrc++;
       in2 = *pSrc++;
 
-      /* Shift the inputs and then store the results in the destination buffer. */
+      /* Shift the inputs and then store the results in the destination buffer.
+       */
 #ifndef ARM_MATH_BIG_ENDIAN
-      write_q15x2_ia (&pDst, __PKHBT((in1 >> -shiftBits),
-                                     (in2 >> -shiftBits), 16));
+      write_q15x2_ia(&pDst,
+                     __PKHBT((in1 >> -shiftBits), (in2 >> -shiftBits), 16));
 #else
-      write_q15x2_ia (&pDst, __PKHBT((in2 >> -shiftBits),
-                                     (in1 >> -shiftBits), 16));
+      write_q15x2_ia(&pDst,
+                     __PKHBT((in2 >> -shiftBits), (in1 >> -shiftBits), 16));
 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
 
       /* read 2 samples from source */
@@ -137,11 +133,11 @@ void arm_shift_q15(
       in2 = *pSrc++;
 
 #ifndef ARM_MATH_BIG_ENDIAN
-      write_q15x2_ia (&pDst, __PKHBT((in1 >> -shiftBits),
-                                     (in2 >> -shiftBits), 16));
+      write_q15x2_ia(&pDst,
+                     __PKHBT((in1 >> -shiftBits), (in2 >> -shiftBits), 16));
 #else
-      write_q15x2_ia (&pDst, __PKHBT((in2 >> -shiftBits),
-                                     (in1 >> -shiftBits), 16));
+      write_q15x2_ia(&pDst,
+                     __PKHBT((in2 >> -shiftBits), (in1 >> -shiftBits), 16));
 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
 
 #else
@@ -167,23 +163,18 @@ void arm_shift_q15(
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
   /* If the shift value is positive then do right shift else left shift */
-  if (sign == 0U)
-  {
-    while (blkCnt > 0U)
-    {
+  if (sign == 0U) {
+    while (blkCnt > 0U) {
       /* C = A << shiftBits */
 
       /* Shift input and store result in destination buffer. */
-      *pDst++ = __SSAT(((q31_t) *pSrc++ << shiftBits), 16);
+      *pDst++ = __SSAT(((q31_t)*pSrc++ << shiftBits), 16);
 
       /* Decrement loop counter */
       blkCnt--;
     }
-  }
-  else
-  {
-    while (blkCnt > 0U)
-    {
+  } else {
+    while (blkCnt > 0U) {
       /* C = A >> shiftBits */
 
       /* Shift input and store result in destination buffer. */
@@ -193,7 +184,6 @@ void arm_shift_q15(
       blkCnt--;
     }
   }
-
 }
 
 /**
diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_shift_q31.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_shift_q31.c
index db6060a..55a7d2e 100644
--- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_shift_q31.c
+++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_shift_q31.c
@@ -1,7 +1,8 @@
 /* ----------------------------------------------------------------------
  * Project:      CMSIS DSP Library
  * Title:        arm_shift_q31.c
- * Description:  Shifts the elements of a Q31 vector by a specified number of bits
+ * Description:  Shifts the elements of a Q31 vector by a specified number of
+ * bits
  *
  * $Date:        18. March 2019
  * $Revision:    V1.6.0
@@ -42,8 +43,9 @@
       pDst[n] = pSrc[n] << shift,   0 <= n < blockSize.
   
- If shift is positive then the elements of the vector are shifted to the left. - If shift is negative then the elements of the vector are shifted to the right. + If shift is positive then the elements of the vector are shifted + to the left. If shift is negative then the elements of the vector + are shifted to the right. The functions support in-place computation allowing the source and destination pointers to reference the same memory buffer. @@ -57,37 +59,33 @@ /** @brief Shifts the elements of a Q31 vector a specified number of bits. @param[in] pSrc points to the input vector - @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right. + @param[in] shiftBits number of bits to shift. A positive value shifts + left; a negative value shifts right. @param[out] pDst points to the output vector @param[in] blockSize number of samples in the vector @return none @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q31 range [0x80000000 0x7FFFFFFF] are saturated. + Results outside of the allowable Q31 range [0x80000000 + 0x7FFFFFFF] are saturated. */ -void arm_shift_q31( - const q31_t * pSrc, - int8_t shiftBits, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - uint8_t sign = (shiftBits & 0x80); /* Sign of shiftBits */ +void arm_shift_q31(const q31_t *pSrc, int8_t shiftBits, q31_t *pDst, + uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + uint8_t sign = (shiftBits & 0x80); /* Sign of shiftBits */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) - q31_t in, out; /* Temporary variables */ + q31_t in, out; /* Temporary variables */ /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; /* If the shift value is positive then do right shift else left shift */ - if (sign == 0U) - { - while (blkCnt > 0U) - { + if (sign == 0U) { + while (blkCnt > 0U) { /* C = A << shiftBits */ /* Shift input and store result in destination buffer. */ @@ -118,11 +116,8 @@ void arm_shift_q31( /* Decrement loop counter */ blkCnt--; } - } - else - { - while (blkCnt > 0U) - { + } else { + while (blkCnt > 0U) { /* C = A >> shiftBits */ /* Shift input and store results in destination buffer. */ @@ -147,23 +142,18 @@ void arm_shift_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* If the shift value is positive then do right shift else left shift */ - if (sign == 0U) - { - while (blkCnt > 0U) - { + if (sign == 0U) { + while (blkCnt > 0U) { /* C = A << shiftBits */ /* Shift input and store result in destination buffer. */ - *pDst++ = clip_q63_to_q31((q63_t) *pSrc++ << shiftBits); + *pDst++ = clip_q63_to_q31((q63_t)*pSrc++ << shiftBits); /* Decrement loop counter */ blkCnt--; } - } - else - { - while (blkCnt > 0U) - { + } else { + while (blkCnt > 0U) { /* C = A >> shiftBits */ /* Shift input and store result in destination buffer. */ @@ -173,7 +163,6 @@ void arm_shift_q31( blkCnt--; } } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_shift_q7.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_shift_q7.c index c4163fc..0f8e510 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_shift_q7.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_shift_q7.c @@ -40,7 +40,8 @@ /** @brief Shifts the elements of a Q7 vector a specified number of bits @param[in] pSrc points to the input vector - @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right. + @param[in] shiftBits number of bits to shift. A positive value shifts + left; a negative value shifts right. @param[out] pDst points to the output vector @param[in] blockSize number of samples in each vector @return none @@ -49,75 +50,65 @@ Input and output buffers should be aligned by 32-bit @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q7 range [0x80 0x7F] are saturated. + Results outside of the allowable Q7 range [0x80 0x7F] are + saturated. */ -void arm_shift_q7( - const q7_t * pSrc, - int8_t shiftBits, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - uint8_t sign = (shiftBits & 0x80); /* Sign of shiftBits */ +void arm_shift_q7(const q7_t *pSrc, int8_t shiftBits, q7_t *pDst, + uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + uint8_t sign = (shiftBits & 0x80); /* Sign of shiftBits */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) -#if defined (ARM_MATH_DSP) - q7_t in1, in2, in3, in4; /* Temporary input variables */ +#if defined(ARM_MATH_DSP) + q7_t in1, in2, in3, in4; /* Temporary input variables */ #endif /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; /* If the shift value is positive then do right shift else left shift */ - if (sign == 0U) - { - while (blkCnt > 0U) - { + if (sign == 0U) { + while (blkCnt > 0U) { /* C = A << shiftBits */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* Read 4 inputs */ in1 = *pSrc++; in2 = *pSrc++; in3 = *pSrc++; in4 = *pSrc++; - /* Pack and store result in destination buffer (in single write) */ - write_q7x4_ia (&pDst, __PACKq7(__SSAT((in1 << shiftBits), 8), - __SSAT((in2 << shiftBits), 8), - __SSAT((in3 << shiftBits), 8), - __SSAT((in4 << shiftBits), 8) )); + /* Pack and store result in destination buffer (in single write) */ + write_q7x4_ia(&pDst, __PACKq7(__SSAT((in1 << shiftBits), 8), + __SSAT((in2 << shiftBits), 8), + __SSAT((in3 << shiftBits), 8), + __SSAT((in4 << shiftBits), 8))); #else - *pDst++ = (q7_t) __SSAT(((q15_t) *pSrc++ << shiftBits), 8); - *pDst++ = (q7_t) __SSAT(((q15_t) *pSrc++ << shiftBits), 8); - *pDst++ = (q7_t) __SSAT(((q15_t) *pSrc++ << shiftBits), 8); - *pDst++ = (q7_t) __SSAT(((q15_t) *pSrc++ << shiftBits), 8); + *pDst++ = (q7_t)__SSAT(((q15_t)*pSrc++ << shiftBits), 8); + *pDst++ = (q7_t)__SSAT(((q15_t)*pSrc++ << shiftBits), 8); + *pDst++ = (q7_t)__SSAT(((q15_t)*pSrc++ << shiftBits), 8); + *pDst++ = (q7_t)__SSAT(((q15_t)*pSrc++ << shiftBits), 8); #endif /* Decrement loop counter */ blkCnt--; } - } - else - { - while (blkCnt > 0U) - { + } else { + while (blkCnt > 0U) { /* C = A >> shiftBits */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* Read 4 inputs */ in1 = *pSrc++; in2 = *pSrc++; in3 = *pSrc++; in4 = *pSrc++; - /* Pack and store result in destination buffer (in single write) */ - write_q7x4_ia (&pDst, __PACKq7((in1 >> -shiftBits), - (in2 >> -shiftBits), - (in3 >> -shiftBits), - (in4 >> -shiftBits) )); + /* Pack and store result in destination buffer (in single write) */ + write_q7x4_ia(&pDst, __PACKq7((in1 >> -shiftBits), (in2 >> -shiftBits), + (in3 >> -shiftBits), (in4 >> -shiftBits))); #else *pDst++ = (*pSrc++ >> -shiftBits); *pDst++ = (*pSrc++ >> -shiftBits); @@ -141,23 +132,18 @@ void arm_shift_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* If the shift value is positive then do right shift else left shift */ - if (sign == 0U) - { - while (blkCnt > 0U) - { + if (sign == 0U) { + while (blkCnt > 0U) { /* C = A << shiftBits */ /* Shift input and store result in destination buffer. */ - *pDst++ = (q7_t) __SSAT(((q15_t) *pSrc++ << shiftBits), 8); + *pDst++ = (q7_t)__SSAT(((q15_t)*pSrc++ << shiftBits), 8); /* Decrement loop counter */ blkCnt--; } - } - else - { - while (blkCnt > 0U) - { + } else { + while (blkCnt > 0U) { /* C = A >> shiftBits */ /* Shift input and store result in destination buffer. */ @@ -167,7 +153,6 @@ void arm_shift_q7( blkCnt--; } } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_sub_f32.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_sub_f32.c index 2ebacb9..118ec84 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_sub_f32.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_sub_f32.c @@ -58,21 +58,16 @@ @return none */ -void arm_sub_f32( - const float32_t * pSrcA, - const float32_t * pSrcB, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_sub_f32(const float32_t *pSrcA, const float32_t *pSrcB, + float32_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A - B */ /* Subtract and store result in destination buffer. */ @@ -98,8 +93,7 @@ void arm_sub_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A - B */ /* Subtract and store result in destination buffer. */ @@ -108,7 +102,6 @@ void arm_sub_f32( /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_sub_q15.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_sub_q15.c index 835917e..9673690 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_sub_q15.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_sub_q15.c @@ -47,20 +47,17 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q15 range [0x8000 0x7FFF] are saturated. + Results outside of the allowable Q15 range [0x8000 0x7FFF] + are saturated. */ -void arm_sub_q15( - const q15_t * pSrcA, - const q15_t * pSrcB, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_sub_q15(const q15_t *pSrcA, const q15_t *pSrcB, q15_t *pDst, + uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) q31_t inA1, inA2; q31_t inB1, inB2; #endif @@ -68,26 +65,25 @@ void arm_sub_q15( /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A - B */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* read 2 times 2 samples at a time from sourceA */ - inA1 = read_q15x2_ia ((q15_t **) &pSrcA); - inA2 = read_q15x2_ia ((q15_t **) &pSrcA); + inA1 = read_q15x2_ia((q15_t **)&pSrcA); + inA2 = read_q15x2_ia((q15_t **)&pSrcA); /* read 2 times 2 samples at a time from sourceB */ - inB1 = read_q15x2_ia ((q15_t **) &pSrcB); - inB2 = read_q15x2_ia ((q15_t **) &pSrcB); + inB1 = read_q15x2_ia((q15_t **)&pSrcB); + inB2 = read_q15x2_ia((q15_t **)&pSrcB); /* Subtract and store 2 times 2 samples at a time */ - write_q15x2_ia (&pDst, __QSUB16(inA1, inB1)); - write_q15x2_ia (&pDst, __QSUB16(inA2, inB2)); + write_q15x2_ia(&pDst, __QSUB16(inA1, inB1)); + write_q15x2_ia(&pDst, __QSUB16(inA2, inB2)); #else - *pDst++ = (q15_t) __SSAT(((q31_t) *pSrcA++ - *pSrcB++), 16); - *pDst++ = (q15_t) __SSAT(((q31_t) *pSrcA++ - *pSrcB++), 16); - *pDst++ = (q15_t) __SSAT(((q31_t) *pSrcA++ - *pSrcB++), 16); - *pDst++ = (q15_t) __SSAT(((q31_t) *pSrcA++ - *pSrcB++), 16); + *pDst++ = (q15_t)__SSAT(((q31_t)*pSrcA++ - *pSrcB++), 16); + *pDst++ = (q15_t)__SSAT(((q31_t)*pSrcA++ - *pSrcB++), 16); + *pDst++ = (q15_t)__SSAT(((q31_t)*pSrcA++ - *pSrcB++), 16); + *pDst++ = (q15_t)__SSAT(((q31_t)*pSrcA++ - *pSrcB++), 16); #endif /* Decrement loop counter */ @@ -104,21 +100,19 @@ void arm_sub_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A - B */ /* Subtract and store result in destination buffer. */ -#if defined (ARM_MATH_DSP) - *pDst++ = (q15_t) __QSUB16(*pSrcA++, *pSrcB++); +#if defined(ARM_MATH_DSP) + *pDst++ = (q15_t)__QSUB16(*pSrcA++, *pSrcB++); #else - *pDst++ = (q15_t) __SSAT(((q31_t) *pSrcA++ - *pSrcB++), 16); + *pDst++ = (q15_t)__SSAT(((q31_t)*pSrcA++ - *pSrcB++), 16); #endif /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_sub_q31.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_sub_q31.c index bac1927..49c1dd7 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_sub_q31.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_sub_q31.c @@ -47,24 +47,20 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q31 range [0x80000000 0x7FFFFFFF] are saturated. + Results outside of the allowable Q31 range [0x80000000 + 0x7FFFFFFF] are saturated. */ -void arm_sub_q31( - const q31_t * pSrcA, - const q31_t * pSrcB, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_sub_q31(const q31_t *pSrcA, const q31_t *pSrcB, q31_t *pDst, + uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A - B */ /* Subtract and store result in destination buffer. */ @@ -90,8 +86,7 @@ void arm_sub_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A - B */ /* Subtract and store result in destination buffer. */ @@ -100,7 +95,6 @@ void arm_sub_q31( /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_sub_q7.c b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_sub_q7.c index a55a8fd..27d29ae 100644 --- a/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_sub_q7.c +++ b/platform/cmsis/DSP_Lib/BasicMathFunctions/arm_sub_q7.c @@ -47,34 +47,31 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q7 range [0x80 0x7F] will be saturated. + Results outside of the allowable Q7 range [0x80 0x7F] will be + saturated. */ -void arm_sub_q7( - const q7_t * pSrcA, - const q7_t * pSrcB, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_sub_q7(const q7_t *pSrcA, const q7_t *pSrcB, q7_t *pDst, + uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A - B */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* Subtract and store result in destination buffer (4 samples at a time). */ - write_q7x4_ia (&pDst, __QSUB8(read_q7x4_ia ((q7_t **) &pSrcA), read_q7x4_ia ((q7_t **) &pSrcB))); + write_q7x4_ia(&pDst, __QSUB8(read_q7x4_ia((q7_t **)&pSrcA), + read_q7x4_ia((q7_t **)&pSrcB))); #else - *pDst++ = (q7_t) __SSAT((q15_t) *pSrcA++ - *pSrcB++, 8); - *pDst++ = (q7_t) __SSAT((q15_t) *pSrcA++ - *pSrcB++, 8); - *pDst++ = (q7_t) __SSAT((q15_t) *pSrcA++ - *pSrcB++, 8); - *pDst++ = (q7_t) __SSAT((q15_t) *pSrcA++ - *pSrcB++, 8); + *pDst++ = (q7_t)__SSAT((q15_t)*pSrcA++ - *pSrcB++, 8); + *pDst++ = (q7_t)__SSAT((q15_t)*pSrcA++ - *pSrcB++, 8); + *pDst++ = (q7_t)__SSAT((q15_t)*pSrcA++ - *pSrcB++, 8); + *pDst++ = (q7_t)__SSAT((q15_t)*pSrcA++ - *pSrcB++, 8); #endif /* Decrement loop counter */ @@ -91,17 +88,15 @@ void arm_sub_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A - B */ /* Subtract and store result in destination buffer. */ - *pDst++ = (q7_t) __SSAT((q15_t) *pSrcA++ - *pSrcB++, 8); + *pDst++ = (q7_t)__SSAT((q15_t)*pSrcA++ - *pSrcB++, 8); /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/CommonTables/CommonTables.c b/platform/cmsis/DSP_Lib/CommonTables/CommonTables.c index acda9f8..75e44c2 100644 --- a/platform/cmsis/DSP_Lib/CommonTables/CommonTables.c +++ b/platform/cmsis/DSP_Lib/CommonTables/CommonTables.c @@ -28,4 +28,3 @@ #include "arm_common_tables.c" #include "arm_const_structs.c" - diff --git a/platform/cmsis/DSP_Lib/CommonTables/arm_common_tables.c b/platform/cmsis/DSP_Lib/CommonTables/arm_common_tables.c index ea396a9..86c321d 100644 --- a/platform/cmsis/DSP_Lib/CommonTables/arm_common_tables.c +++ b/platform/cmsis/DSP_Lib/CommonTables/arm_common_tables.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_common_tables.c - * Description: common tables like fft twiddle factors, Bitreverse, reciprocal etc + * Description: common tables like fft twiddle factors, Bitreverse, reciprocal + * etc * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -26,8 +27,8 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @ingroup ComplexFFT @@ -65,111 +66,100 @@ @brief Table for bit reversal process */ const uint16_t armBitRevTable[1024] = { - 0x400, 0x200, 0x600, 0x100, 0x500, 0x300, 0x700, 0x080, 0x480, 0x280, - 0x680, 0x180, 0x580, 0x380, 0x780, 0x040, 0x440, 0x240, 0x640, 0x140, - 0x540, 0x340, 0x740, 0x0c0, 0x4c0, 0x2c0, 0x6c0, 0x1c0, 0x5c0, 0x3c0, - 0x7c0, 0x020, 0x420, 0x220, 0x620, 0x120, 0x520, 0x320, 0x720, 0x0a0, - 0x4a0, 0x2a0, 0x6a0, 0x1a0, 0x5a0, 0x3a0, 0x7a0, 0x060, 0x460, 0x260, - 0x660, 0x160, 0x560, 0x360, 0x760, 0x0e0, 0x4e0, 0x2e0, 0x6e0, 0x1e0, - 0x5e0, 0x3e0, 0x7e0, 0x010, 0x410, 0x210, 0x610, 0x110, 0x510, 0x310, - 0x710, 0x090, 0x490, 0x290, 0x690, 0x190, 0x590, 0x390, 0x790, 0x050, - 0x450, 0x250, 0x650, 0x150, 0x550, 0x350, 0x750, 0x0d0, 0x4d0, 0x2d0, - 0x6d0, 0x1d0, 0x5d0, 0x3d0, 0x7d0, 0x030, 0x430, 0x230, 0x630, 0x130, - 0x530, 0x330, 0x730, 0x0b0, 0x4b0, 0x2b0, 0x6b0, 0x1b0, 0x5b0, 0x3b0, - 0x7b0, 0x070, 0x470, 0x270, 0x670, 0x170, 0x570, 0x370, 0x770, 0x0f0, - 0x4f0, 0x2f0, 0x6f0, 0x1f0, 0x5f0, 0x3f0, 0x7f0, 0x008, 0x408, 0x208, - 0x608, 0x108, 0x508, 0x308, 0x708, 0x088, 0x488, 0x288, 0x688, 0x188, - 0x588, 0x388, 0x788, 0x048, 0x448, 0x248, 0x648, 0x148, 0x548, 0x348, - 0x748, 0x0c8, 0x4c8, 0x2c8, 0x6c8, 0x1c8, 0x5c8, 0x3c8, 0x7c8, 0x028, - 0x428, 0x228, 0x628, 0x128, 0x528, 0x328, 0x728, 0x0a8, 0x4a8, 0x2a8, - 0x6a8, 0x1a8, 0x5a8, 0x3a8, 0x7a8, 0x068, 0x468, 0x268, 0x668, 0x168, - 0x568, 0x368, 0x768, 0x0e8, 0x4e8, 0x2e8, 0x6e8, 0x1e8, 0x5e8, 0x3e8, - 0x7e8, 0x018, 0x418, 0x218, 0x618, 0x118, 0x518, 0x318, 0x718, 0x098, - 0x498, 0x298, 0x698, 0x198, 0x598, 0x398, 0x798, 0x058, 0x458, 0x258, - 0x658, 0x158, 0x558, 0x358, 0x758, 0x0d8, 0x4d8, 0x2d8, 0x6d8, 0x1d8, - 0x5d8, 0x3d8, 0x7d8, 0x038, 0x438, 0x238, 0x638, 0x138, 0x538, 0x338, - 0x738, 0x0b8, 0x4b8, 0x2b8, 0x6b8, 0x1b8, 0x5b8, 0x3b8, 0x7b8, 0x078, - 0x478, 0x278, 0x678, 0x178, 0x578, 0x378, 0x778, 0x0f8, 0x4f8, 0x2f8, - 0x6f8, 0x1f8, 0x5f8, 0x3f8, 0x7f8, 0x004, 0x404, 0x204, 0x604, 0x104, - 0x504, 0x304, 0x704, 0x084, 0x484, 0x284, 0x684, 0x184, 0x584, 0x384, - 0x784, 0x044, 0x444, 0x244, 0x644, 0x144, 0x544, 0x344, 0x744, 0x0c4, - 0x4c4, 0x2c4, 0x6c4, 0x1c4, 0x5c4, 0x3c4, 0x7c4, 0x024, 0x424, 0x224, - 0x624, 0x124, 0x524, 0x324, 0x724, 0x0a4, 0x4a4, 0x2a4, 0x6a4, 0x1a4, - 0x5a4, 0x3a4, 0x7a4, 0x064, 0x464, 0x264, 0x664, 0x164, 0x564, 0x364, - 0x764, 0x0e4, 0x4e4, 0x2e4, 0x6e4, 0x1e4, 0x5e4, 0x3e4, 0x7e4, 0x014, - 0x414, 0x214, 0x614, 0x114, 0x514, 0x314, 0x714, 0x094, 0x494, 0x294, - 0x694, 0x194, 0x594, 0x394, 0x794, 0x054, 0x454, 0x254, 0x654, 0x154, - 0x554, 0x354, 0x754, 0x0d4, 0x4d4, 0x2d4, 0x6d4, 0x1d4, 0x5d4, 0x3d4, - 0x7d4, 0x034, 0x434, 0x234, 0x634, 0x134, 0x534, 0x334, 0x734, 0x0b4, - 0x4b4, 0x2b4, 0x6b4, 0x1b4, 0x5b4, 0x3b4, 0x7b4, 0x074, 0x474, 0x274, - 0x674, 0x174, 0x574, 0x374, 0x774, 0x0f4, 0x4f4, 0x2f4, 0x6f4, 0x1f4, - 0x5f4, 0x3f4, 0x7f4, 0x00c, 0x40c, 0x20c, 0x60c, 0x10c, 0x50c, 0x30c, - 0x70c, 0x08c, 0x48c, 0x28c, 0x68c, 0x18c, 0x58c, 0x38c, 0x78c, 0x04c, - 0x44c, 0x24c, 0x64c, 0x14c, 0x54c, 0x34c, 0x74c, 0x0cc, 0x4cc, 0x2cc, - 0x6cc, 0x1cc, 0x5cc, 0x3cc, 0x7cc, 0x02c, 0x42c, 0x22c, 0x62c, 0x12c, - 0x52c, 0x32c, 0x72c, 0x0ac, 0x4ac, 0x2ac, 0x6ac, 0x1ac, 0x5ac, 0x3ac, - 0x7ac, 0x06c, 0x46c, 0x26c, 0x66c, 0x16c, 0x56c, 0x36c, 0x76c, 0x0ec, - 0x4ec, 0x2ec, 0x6ec, 0x1ec, 0x5ec, 0x3ec, 0x7ec, 0x01c, 0x41c, 0x21c, - 0x61c, 0x11c, 0x51c, 0x31c, 0x71c, 0x09c, 0x49c, 0x29c, 0x69c, 0x19c, - 0x59c, 0x39c, 0x79c, 0x05c, 0x45c, 0x25c, 0x65c, 0x15c, 0x55c, 0x35c, - 0x75c, 0x0dc, 0x4dc, 0x2dc, 0x6dc, 0x1dc, 0x5dc, 0x3dc, 0x7dc, 0x03c, - 0x43c, 0x23c, 0x63c, 0x13c, 0x53c, 0x33c, 0x73c, 0x0bc, 0x4bc, 0x2bc, - 0x6bc, 0x1bc, 0x5bc, 0x3bc, 0x7bc, 0x07c, 0x47c, 0x27c, 0x67c, 0x17c, - 0x57c, 0x37c, 0x77c, 0x0fc, 0x4fc, 0x2fc, 0x6fc, 0x1fc, 0x5fc, 0x3fc, - 0x7fc, 0x002, 0x402, 0x202, 0x602, 0x102, 0x502, 0x302, 0x702, 0x082, - 0x482, 0x282, 0x682, 0x182, 0x582, 0x382, 0x782, 0x042, 0x442, 0x242, - 0x642, 0x142, 0x542, 0x342, 0x742, 0x0c2, 0x4c2, 0x2c2, 0x6c2, 0x1c2, - 0x5c2, 0x3c2, 0x7c2, 0x022, 0x422, 0x222, 0x622, 0x122, 0x522, 0x322, - 0x722, 0x0a2, 0x4a2, 0x2a2, 0x6a2, 0x1a2, 0x5a2, 0x3a2, 0x7a2, 0x062, - 0x462, 0x262, 0x662, 0x162, 0x562, 0x362, 0x762, 0x0e2, 0x4e2, 0x2e2, - 0x6e2, 0x1e2, 0x5e2, 0x3e2, 0x7e2, 0x012, 0x412, 0x212, 0x612, 0x112, - 0x512, 0x312, 0x712, 0x092, 0x492, 0x292, 0x692, 0x192, 0x592, 0x392, - 0x792, 0x052, 0x452, 0x252, 0x652, 0x152, 0x552, 0x352, 0x752, 0x0d2, - 0x4d2, 0x2d2, 0x6d2, 0x1d2, 0x5d2, 0x3d2, 0x7d2, 0x032, 0x432, 0x232, - 0x632, 0x132, 0x532, 0x332, 0x732, 0x0b2, 0x4b2, 0x2b2, 0x6b2, 0x1b2, - 0x5b2, 0x3b2, 0x7b2, 0x072, 0x472, 0x272, 0x672, 0x172, 0x572, 0x372, - 0x772, 0x0f2, 0x4f2, 0x2f2, 0x6f2, 0x1f2, 0x5f2, 0x3f2, 0x7f2, 0x00a, - 0x40a, 0x20a, 0x60a, 0x10a, 0x50a, 0x30a, 0x70a, 0x08a, 0x48a, 0x28a, - 0x68a, 0x18a, 0x58a, 0x38a, 0x78a, 0x04a, 0x44a, 0x24a, 0x64a, 0x14a, - 0x54a, 0x34a, 0x74a, 0x0ca, 0x4ca, 0x2ca, 0x6ca, 0x1ca, 0x5ca, 0x3ca, - 0x7ca, 0x02a, 0x42a, 0x22a, 0x62a, 0x12a, 0x52a, 0x32a, 0x72a, 0x0aa, - 0x4aa, 0x2aa, 0x6aa, 0x1aa, 0x5aa, 0x3aa, 0x7aa, 0x06a, 0x46a, 0x26a, - 0x66a, 0x16a, 0x56a, 0x36a, 0x76a, 0x0ea, 0x4ea, 0x2ea, 0x6ea, 0x1ea, - 0x5ea, 0x3ea, 0x7ea, 0x01a, 0x41a, 0x21a, 0x61a, 0x11a, 0x51a, 0x31a, - 0x71a, 0x09a, 0x49a, 0x29a, 0x69a, 0x19a, 0x59a, 0x39a, 0x79a, 0x5a, - 0x45a, 0x25a, 0x65a, 0x15a, 0x55a, 0x35a, 0x75a, 0x0da, 0x4da, 0x2da, - 0x6da, 0x1da, 0x5da, 0x3da, 0x7da, 0x03a, 0x43a, 0x23a, 0x63a, 0x13a, - 0x53a, 0x33a, 0x73a, 0x0ba, 0x4ba, 0x2ba, 0x6ba, 0x1ba, 0x5ba, 0x3ba, - 0x7ba, 0x07a, 0x47a, 0x27a, 0x67a, 0x17a, 0x57a, 0x37a, 0x77a, 0x0fa, - 0x4fa, 0x2fa, 0x6fa, 0x1fa, 0x5fa, 0x3fa, 0x7fa, 0x006, 0x406, 0x206, - 0x606, 0x106, 0x506, 0x306, 0x706, 0x086, 0x486, 0x286, 0x686, 0x186, - 0x586, 0x386, 0x786, 0x046, 0x446, 0x246, 0x646, 0x146, 0x546, 0x346, - 0x746, 0x0c6, 0x4c6, 0x2c6, 0x6c6, 0x1c6, 0x5c6, 0x3c6, 0x7c6, 0x026, - 0x426, 0x226, 0x626, 0x126, 0x526, 0x326, 0x726, 0x0a6, 0x4a6, 0x2a6, - 0x6a6, 0x1a6, 0x5a6, 0x3a6, 0x7a6, 0x066, 0x466, 0x266, 0x666, 0x166, - 0x566, 0x366, 0x766, 0x0e6, 0x4e6, 0x2e6, 0x6e6, 0x1e6, 0x5e6, 0x3e6, - 0x7e6, 0x016, 0x416, 0x216, 0x616, 0x116, 0x516, 0x316, 0x716, 0x096, - 0x496, 0x296, 0x696, 0x196, 0x596, 0x396, 0x796, 0x056, 0x456, 0x256, - 0x656, 0x156, 0x556, 0x356, 0x756, 0x0d6, 0x4d6, 0x2d6, 0x6d6, 0x1d6, - 0x5d6, 0x3d6, 0x7d6, 0x036, 0x436, 0x236, 0x636, 0x136, 0x536, 0x336, - 0x736, 0x0b6, 0x4b6, 0x2b6, 0x6b6, 0x1b6, 0x5b6, 0x3b6, 0x7b6, 0x076, - 0x476, 0x276, 0x676, 0x176, 0x576, 0x376, 0x776, 0x0f6, 0x4f6, 0x2f6, - 0x6f6, 0x1f6, 0x5f6, 0x3f6, 0x7f6, 0x00e, 0x40e, 0x20e, 0x60e, 0x10e, - 0x50e, 0x30e, 0x70e, 0x08e, 0x48e, 0x28e, 0x68e, 0x18e, 0x58e, 0x38e, - 0x78e, 0x04e, 0x44e, 0x24e, 0x64e, 0x14e, 0x54e, 0x34e, 0x74e, 0x0ce, - 0x4ce, 0x2ce, 0x6ce, 0x1ce, 0x5ce, 0x3ce, 0x7ce, 0x02e, 0x42e, 0x22e, - 0x62e, 0x12e, 0x52e, 0x32e, 0x72e, 0x0ae, 0x4ae, 0x2ae, 0x6ae, 0x1ae, - 0x5ae, 0x3ae, 0x7ae, 0x06e, 0x46e, 0x26e, 0x66e, 0x16e, 0x56e, 0x36e, - 0x76e, 0x0ee, 0x4ee, 0x2ee, 0x6ee, 0x1ee, 0x5ee, 0x3ee, 0x7ee, 0x01e, - 0x41e, 0x21e, 0x61e, 0x11e, 0x51e, 0x31e, 0x71e, 0x09e, 0x49e, 0x29e, - 0x69e, 0x19e, 0x59e, 0x39e, 0x79e, 0x05e, 0x45e, 0x25e, 0x65e, 0x15e, - 0x55e, 0x35e, 0x75e, 0x0de, 0x4de, 0x2de, 0x6de, 0x1de, 0x5de, 0x3de, - 0x7de, 0x03e, 0x43e, 0x23e, 0x63e, 0x13e, 0x53e, 0x33e, 0x73e, 0x0be, - 0x4be, 0x2be, 0x6be, 0x1be, 0x5be, 0x3be, 0x7be, 0x07e, 0x47e, 0x27e, - 0x67e, 0x17e, 0x57e, 0x37e, 0x77e, 0x0fe, 0x4fe, 0x2fe, 0x6fe, 0x1fe, - 0x5fe, 0x3fe, 0x7fe, 0x001 -}; - + 0x400, 0x200, 0x600, 0x100, 0x500, 0x300, 0x700, 0x080, 0x480, 0x280, 0x680, + 0x180, 0x580, 0x380, 0x780, 0x040, 0x440, 0x240, 0x640, 0x140, 0x540, 0x340, + 0x740, 0x0c0, 0x4c0, 0x2c0, 0x6c0, 0x1c0, 0x5c0, 0x3c0, 0x7c0, 0x020, 0x420, + 0x220, 0x620, 0x120, 0x520, 0x320, 0x720, 0x0a0, 0x4a0, 0x2a0, 0x6a0, 0x1a0, + 0x5a0, 0x3a0, 0x7a0, 0x060, 0x460, 0x260, 0x660, 0x160, 0x560, 0x360, 0x760, + 0x0e0, 0x4e0, 0x2e0, 0x6e0, 0x1e0, 0x5e0, 0x3e0, 0x7e0, 0x010, 0x410, 0x210, + 0x610, 0x110, 0x510, 0x310, 0x710, 0x090, 0x490, 0x290, 0x690, 0x190, 0x590, + 0x390, 0x790, 0x050, 0x450, 0x250, 0x650, 0x150, 0x550, 0x350, 0x750, 0x0d0, + 0x4d0, 0x2d0, 0x6d0, 0x1d0, 0x5d0, 0x3d0, 0x7d0, 0x030, 0x430, 0x230, 0x630, + 0x130, 0x530, 0x330, 0x730, 0x0b0, 0x4b0, 0x2b0, 0x6b0, 0x1b0, 0x5b0, 0x3b0, + 0x7b0, 0x070, 0x470, 0x270, 0x670, 0x170, 0x570, 0x370, 0x770, 0x0f0, 0x4f0, + 0x2f0, 0x6f0, 0x1f0, 0x5f0, 0x3f0, 0x7f0, 0x008, 0x408, 0x208, 0x608, 0x108, + 0x508, 0x308, 0x708, 0x088, 0x488, 0x288, 0x688, 0x188, 0x588, 0x388, 0x788, + 0x048, 0x448, 0x248, 0x648, 0x148, 0x548, 0x348, 0x748, 0x0c8, 0x4c8, 0x2c8, + 0x6c8, 0x1c8, 0x5c8, 0x3c8, 0x7c8, 0x028, 0x428, 0x228, 0x628, 0x128, 0x528, + 0x328, 0x728, 0x0a8, 0x4a8, 0x2a8, 0x6a8, 0x1a8, 0x5a8, 0x3a8, 0x7a8, 0x068, + 0x468, 0x268, 0x668, 0x168, 0x568, 0x368, 0x768, 0x0e8, 0x4e8, 0x2e8, 0x6e8, + 0x1e8, 0x5e8, 0x3e8, 0x7e8, 0x018, 0x418, 0x218, 0x618, 0x118, 0x518, 0x318, + 0x718, 0x098, 0x498, 0x298, 0x698, 0x198, 0x598, 0x398, 0x798, 0x058, 0x458, + 0x258, 0x658, 0x158, 0x558, 0x358, 0x758, 0x0d8, 0x4d8, 0x2d8, 0x6d8, 0x1d8, + 0x5d8, 0x3d8, 0x7d8, 0x038, 0x438, 0x238, 0x638, 0x138, 0x538, 0x338, 0x738, + 0x0b8, 0x4b8, 0x2b8, 0x6b8, 0x1b8, 0x5b8, 0x3b8, 0x7b8, 0x078, 0x478, 0x278, + 0x678, 0x178, 0x578, 0x378, 0x778, 0x0f8, 0x4f8, 0x2f8, 0x6f8, 0x1f8, 0x5f8, + 0x3f8, 0x7f8, 0x004, 0x404, 0x204, 0x604, 0x104, 0x504, 0x304, 0x704, 0x084, + 0x484, 0x284, 0x684, 0x184, 0x584, 0x384, 0x784, 0x044, 0x444, 0x244, 0x644, + 0x144, 0x544, 0x344, 0x744, 0x0c4, 0x4c4, 0x2c4, 0x6c4, 0x1c4, 0x5c4, 0x3c4, + 0x7c4, 0x024, 0x424, 0x224, 0x624, 0x124, 0x524, 0x324, 0x724, 0x0a4, 0x4a4, + 0x2a4, 0x6a4, 0x1a4, 0x5a4, 0x3a4, 0x7a4, 0x064, 0x464, 0x264, 0x664, 0x164, + 0x564, 0x364, 0x764, 0x0e4, 0x4e4, 0x2e4, 0x6e4, 0x1e4, 0x5e4, 0x3e4, 0x7e4, + 0x014, 0x414, 0x214, 0x614, 0x114, 0x514, 0x314, 0x714, 0x094, 0x494, 0x294, + 0x694, 0x194, 0x594, 0x394, 0x794, 0x054, 0x454, 0x254, 0x654, 0x154, 0x554, + 0x354, 0x754, 0x0d4, 0x4d4, 0x2d4, 0x6d4, 0x1d4, 0x5d4, 0x3d4, 0x7d4, 0x034, + 0x434, 0x234, 0x634, 0x134, 0x534, 0x334, 0x734, 0x0b4, 0x4b4, 0x2b4, 0x6b4, + 0x1b4, 0x5b4, 0x3b4, 0x7b4, 0x074, 0x474, 0x274, 0x674, 0x174, 0x574, 0x374, + 0x774, 0x0f4, 0x4f4, 0x2f4, 0x6f4, 0x1f4, 0x5f4, 0x3f4, 0x7f4, 0x00c, 0x40c, + 0x20c, 0x60c, 0x10c, 0x50c, 0x30c, 0x70c, 0x08c, 0x48c, 0x28c, 0x68c, 0x18c, + 0x58c, 0x38c, 0x78c, 0x04c, 0x44c, 0x24c, 0x64c, 0x14c, 0x54c, 0x34c, 0x74c, + 0x0cc, 0x4cc, 0x2cc, 0x6cc, 0x1cc, 0x5cc, 0x3cc, 0x7cc, 0x02c, 0x42c, 0x22c, + 0x62c, 0x12c, 0x52c, 0x32c, 0x72c, 0x0ac, 0x4ac, 0x2ac, 0x6ac, 0x1ac, 0x5ac, + 0x3ac, 0x7ac, 0x06c, 0x46c, 0x26c, 0x66c, 0x16c, 0x56c, 0x36c, 0x76c, 0x0ec, + 0x4ec, 0x2ec, 0x6ec, 0x1ec, 0x5ec, 0x3ec, 0x7ec, 0x01c, 0x41c, 0x21c, 0x61c, + 0x11c, 0x51c, 0x31c, 0x71c, 0x09c, 0x49c, 0x29c, 0x69c, 0x19c, 0x59c, 0x39c, + 0x79c, 0x05c, 0x45c, 0x25c, 0x65c, 0x15c, 0x55c, 0x35c, 0x75c, 0x0dc, 0x4dc, + 0x2dc, 0x6dc, 0x1dc, 0x5dc, 0x3dc, 0x7dc, 0x03c, 0x43c, 0x23c, 0x63c, 0x13c, + 0x53c, 0x33c, 0x73c, 0x0bc, 0x4bc, 0x2bc, 0x6bc, 0x1bc, 0x5bc, 0x3bc, 0x7bc, + 0x07c, 0x47c, 0x27c, 0x67c, 0x17c, 0x57c, 0x37c, 0x77c, 0x0fc, 0x4fc, 0x2fc, + 0x6fc, 0x1fc, 0x5fc, 0x3fc, 0x7fc, 0x002, 0x402, 0x202, 0x602, 0x102, 0x502, + 0x302, 0x702, 0x082, 0x482, 0x282, 0x682, 0x182, 0x582, 0x382, 0x782, 0x042, + 0x442, 0x242, 0x642, 0x142, 0x542, 0x342, 0x742, 0x0c2, 0x4c2, 0x2c2, 0x6c2, + 0x1c2, 0x5c2, 0x3c2, 0x7c2, 0x022, 0x422, 0x222, 0x622, 0x122, 0x522, 0x322, + 0x722, 0x0a2, 0x4a2, 0x2a2, 0x6a2, 0x1a2, 0x5a2, 0x3a2, 0x7a2, 0x062, 0x462, + 0x262, 0x662, 0x162, 0x562, 0x362, 0x762, 0x0e2, 0x4e2, 0x2e2, 0x6e2, 0x1e2, + 0x5e2, 0x3e2, 0x7e2, 0x012, 0x412, 0x212, 0x612, 0x112, 0x512, 0x312, 0x712, + 0x092, 0x492, 0x292, 0x692, 0x192, 0x592, 0x392, 0x792, 0x052, 0x452, 0x252, + 0x652, 0x152, 0x552, 0x352, 0x752, 0x0d2, 0x4d2, 0x2d2, 0x6d2, 0x1d2, 0x5d2, + 0x3d2, 0x7d2, 0x032, 0x432, 0x232, 0x632, 0x132, 0x532, 0x332, 0x732, 0x0b2, + 0x4b2, 0x2b2, 0x6b2, 0x1b2, 0x5b2, 0x3b2, 0x7b2, 0x072, 0x472, 0x272, 0x672, + 0x172, 0x572, 0x372, 0x772, 0x0f2, 0x4f2, 0x2f2, 0x6f2, 0x1f2, 0x5f2, 0x3f2, + 0x7f2, 0x00a, 0x40a, 0x20a, 0x60a, 0x10a, 0x50a, 0x30a, 0x70a, 0x08a, 0x48a, + 0x28a, 0x68a, 0x18a, 0x58a, 0x38a, 0x78a, 0x04a, 0x44a, 0x24a, 0x64a, 0x14a, + 0x54a, 0x34a, 0x74a, 0x0ca, 0x4ca, 0x2ca, 0x6ca, 0x1ca, 0x5ca, 0x3ca, 0x7ca, + 0x02a, 0x42a, 0x22a, 0x62a, 0x12a, 0x52a, 0x32a, 0x72a, 0x0aa, 0x4aa, 0x2aa, + 0x6aa, 0x1aa, 0x5aa, 0x3aa, 0x7aa, 0x06a, 0x46a, 0x26a, 0x66a, 0x16a, 0x56a, + 0x36a, 0x76a, 0x0ea, 0x4ea, 0x2ea, 0x6ea, 0x1ea, 0x5ea, 0x3ea, 0x7ea, 0x01a, + 0x41a, 0x21a, 0x61a, 0x11a, 0x51a, 0x31a, 0x71a, 0x09a, 0x49a, 0x29a, 0x69a, + 0x19a, 0x59a, 0x39a, 0x79a, 0x5a, 0x45a, 0x25a, 0x65a, 0x15a, 0x55a, 0x35a, + 0x75a, 0x0da, 0x4da, 0x2da, 0x6da, 0x1da, 0x5da, 0x3da, 0x7da, 0x03a, 0x43a, + 0x23a, 0x63a, 0x13a, 0x53a, 0x33a, 0x73a, 0x0ba, 0x4ba, 0x2ba, 0x6ba, 0x1ba, + 0x5ba, 0x3ba, 0x7ba, 0x07a, 0x47a, 0x27a, 0x67a, 0x17a, 0x57a, 0x37a, 0x77a, + 0x0fa, 0x4fa, 0x2fa, 0x6fa, 0x1fa, 0x5fa, 0x3fa, 0x7fa, 0x006, 0x406, 0x206, + 0x606, 0x106, 0x506, 0x306, 0x706, 0x086, 0x486, 0x286, 0x686, 0x186, 0x586, + 0x386, 0x786, 0x046, 0x446, 0x246, 0x646, 0x146, 0x546, 0x346, 0x746, 0x0c6, + 0x4c6, 0x2c6, 0x6c6, 0x1c6, 0x5c6, 0x3c6, 0x7c6, 0x026, 0x426, 0x226, 0x626, + 0x126, 0x526, 0x326, 0x726, 0x0a6, 0x4a6, 0x2a6, 0x6a6, 0x1a6, 0x5a6, 0x3a6, + 0x7a6, 0x066, 0x466, 0x266, 0x666, 0x166, 0x566, 0x366, 0x766, 0x0e6, 0x4e6, + 0x2e6, 0x6e6, 0x1e6, 0x5e6, 0x3e6, 0x7e6, 0x016, 0x416, 0x216, 0x616, 0x116, + 0x516, 0x316, 0x716, 0x096, 0x496, 0x296, 0x696, 0x196, 0x596, 0x396, 0x796, + 0x056, 0x456, 0x256, 0x656, 0x156, 0x556, 0x356, 0x756, 0x0d6, 0x4d6, 0x2d6, + 0x6d6, 0x1d6, 0x5d6, 0x3d6, 0x7d6, 0x036, 0x436, 0x236, 0x636, 0x136, 0x536, + 0x336, 0x736, 0x0b6, 0x4b6, 0x2b6, 0x6b6, 0x1b6, 0x5b6, 0x3b6, 0x7b6, 0x076, + 0x476, 0x276, 0x676, 0x176, 0x576, 0x376, 0x776, 0x0f6, 0x4f6, 0x2f6, 0x6f6, + 0x1f6, 0x5f6, 0x3f6, 0x7f6, 0x00e, 0x40e, 0x20e, 0x60e, 0x10e, 0x50e, 0x30e, + 0x70e, 0x08e, 0x48e, 0x28e, 0x68e, 0x18e, 0x58e, 0x38e, 0x78e, 0x04e, 0x44e, + 0x24e, 0x64e, 0x14e, 0x54e, 0x34e, 0x74e, 0x0ce, 0x4ce, 0x2ce, 0x6ce, 0x1ce, + 0x5ce, 0x3ce, 0x7ce, 0x02e, 0x42e, 0x22e, 0x62e, 0x12e, 0x52e, 0x32e, 0x72e, + 0x0ae, 0x4ae, 0x2ae, 0x6ae, 0x1ae, 0x5ae, 0x3ae, 0x7ae, 0x06e, 0x46e, 0x26e, + 0x66e, 0x16e, 0x56e, 0x36e, 0x76e, 0x0ee, 0x4ee, 0x2ee, 0x6ee, 0x1ee, 0x5ee, + 0x3ee, 0x7ee, 0x01e, 0x41e, 0x21e, 0x61e, 0x11e, 0x51e, 0x31e, 0x71e, 0x09e, + 0x49e, 0x29e, 0x69e, 0x19e, 0x59e, 0x39e, 0x79e, 0x05e, 0x45e, 0x25e, 0x65e, + 0x15e, 0x55e, 0x35e, 0x75e, 0x0de, 0x4de, 0x2de, 0x6de, 0x1de, 0x5de, 0x3de, + 0x7de, 0x03e, 0x43e, 0x23e, 0x63e, 0x13e, 0x53e, 0x33e, 0x73e, 0x0be, 0x4be, + 0x2be, 0x6be, 0x1be, 0x5be, 0x3be, 0x7be, 0x07e, 0x47e, 0x27e, 0x67e, 0x17e, + 0x57e, 0x37e, 0x77e, 0x0fe, 0x4fe, 0x2fe, 0x6fe, 0x1fe, 0x5fe, 0x3fe, 0x7fe, + 0x001}; /** @brief Floating-point Twiddle factors Table Generation @@ -181,8 +171,8 @@ const uint16_t armBitRevTable[1024] = { @par
for (i = 0; i < N/; i++)
   {
- 	twiddleCoef[2*i]   = cos(i * 2*PI/(float)N);
- 	twiddleCoef[2*i+1] = sin(i * 2*PI/(float)N);
+        twiddleCoef[2*i]   = cos(i * 2*PI/(float)N);
+        twiddleCoef[2*i+1] = sin(i * 2*PI/(float)N);
   } 
@par where N = 16, PI = 3.14159265358979 @@ -190,23 +180,13 @@ const uint16_t armBitRevTable[1024] = { Cos and Sin values are in interleaved fashion */ const float32_t twiddleCoef_16[32] = { - 1.000000000f, 0.000000000f, - 0.923879533f, 0.382683432f, - 0.707106781f, 0.707106781f, - 0.382683432f, 0.923879533f, - 0.000000000f, 1.000000000f, - -0.382683432f, 0.923879533f, - -0.707106781f, 0.707106781f, - -0.923879533f, 0.382683432f, - -1.000000000f, 0.000000000f, - -0.923879533f, -0.382683432f, - -0.707106781f, -0.707106781f, - -0.382683432f, -0.923879533f, - -0.000000000f, -1.000000000f, - 0.382683432f, -0.923879533f, - 0.707106781f, -0.707106781f, - 0.923879533f, -0.382683432f -}; + 1.000000000f, 0.000000000f, 0.923879533f, 0.382683432f, 0.707106781f, + 0.707106781f, 0.382683432f, 0.923879533f, 0.000000000f, 1.000000000f, + -0.382683432f, 0.923879533f, -0.707106781f, 0.707106781f, -0.923879533f, + 0.382683432f, -1.000000000f, 0.000000000f, -0.923879533f, -0.382683432f, + -0.707106781f, -0.707106781f, -0.382683432f, -0.923879533f, -0.000000000f, + -1.000000000f, 0.382683432f, -0.923879533f, 0.707106781f, -0.707106781f, + 0.923879533f, -0.382683432f}; /** @par @@ -214,8 +194,8 @@ const float32_t twiddleCoef_16[32] = { @par
for (i = 0; i< N/; i++)
   {
- 	twiddleCoef[2*i]   = cos(i * 2*PI/(float)N);
- 	twiddleCoef[2*i+1] = sin(i * 2*PI/(float)N);
+        twiddleCoef[2*i]   = cos(i * 2*PI/(float)N);
+        twiddleCoef[2*i+1] = sin(i * 2*PI/(float)N);
   } 
@par where N = 32, PI = 3.14159265358979 @@ -223,39 +203,19 @@ const float32_t twiddleCoef_16[32] = { Cos and Sin values are in interleaved fashion */ const float32_t twiddleCoef_32[64] = { - 1.000000000f, 0.000000000f, - 0.980785280f, 0.195090322f, - 0.923879533f, 0.382683432f, - 0.831469612f, 0.555570233f, - 0.707106781f, 0.707106781f, - 0.555570233f, 0.831469612f, - 0.382683432f, 0.923879533f, - 0.195090322f, 0.980785280f, - 0.000000000f, 1.000000000f, - -0.195090322f, 0.980785280f, - -0.382683432f, 0.923879533f, - -0.555570233f, 0.831469612f, - -0.707106781f, 0.707106781f, - -0.831469612f, 0.555570233f, - -0.923879533f, 0.382683432f, - -0.980785280f, 0.195090322f, - -1.000000000f, 0.000000000f, - -0.980785280f, -0.195090322f, - -0.923879533f, -0.382683432f, - -0.831469612f, -0.555570233f, - -0.707106781f, -0.707106781f, - -0.555570233f, -0.831469612f, - -0.382683432f, -0.923879533f, - -0.195090322f, -0.980785280f, - -0.000000000f, -1.000000000f, - 0.195090322f, -0.980785280f, - 0.382683432f, -0.923879533f, - 0.555570233f, -0.831469612f, - 0.707106781f, -0.707106781f, - 0.831469612f, -0.555570233f, - 0.923879533f, -0.382683432f, - 0.980785280f, -0.195090322f -}; + 1.000000000f, 0.000000000f, 0.980785280f, 0.195090322f, 0.923879533f, + 0.382683432f, 0.831469612f, 0.555570233f, 0.707106781f, 0.707106781f, + 0.555570233f, 0.831469612f, 0.382683432f, 0.923879533f, 0.195090322f, + 0.980785280f, 0.000000000f, 1.000000000f, -0.195090322f, 0.980785280f, + -0.382683432f, 0.923879533f, -0.555570233f, 0.831469612f, -0.707106781f, + 0.707106781f, -0.831469612f, 0.555570233f, -0.923879533f, 0.382683432f, + -0.980785280f, 0.195090322f, -1.000000000f, 0.000000000f, -0.980785280f, + -0.195090322f, -0.923879533f, -0.382683432f, -0.831469612f, -0.555570233f, + -0.707106781f, -0.707106781f, -0.555570233f, -0.831469612f, -0.382683432f, + -0.923879533f, -0.195090322f, -0.980785280f, -0.000000000f, -1.000000000f, + 0.195090322f, -0.980785280f, 0.382683432f, -0.923879533f, 0.555570233f, + -0.831469612f, 0.707106781f, -0.707106781f, 0.831469612f, -0.555570233f, + 0.923879533f, -0.382683432f, 0.980785280f, -0.195090322f}; /** @par @@ -263,8 +223,8 @@ const float32_t twiddleCoef_32[64] = { @par
for(i = 0; i < N/; i++)
   {
- 	twiddleCoef[2*i]   = cos(i * 2*PI/(float)N);
- 	twiddleCoef[2*i+1] = sin(i * 2*PI/(float)N);
+        twiddleCoef[2*i]   = cos(i * 2*PI/(float)N);
+        twiddleCoef[2*i+1] = sin(i * 2*PI/(float)N);
   } 
@par where N = 64, PI = 3.14159265358979 @@ -272,71 +232,32 @@ const float32_t twiddleCoef_32[64] = { Cos and Sin values are in interleaved fashion */ const float32_t twiddleCoef_64[128] = { - 1.000000000f, 0.000000000f, - 0.995184727f, 0.098017140f, - 0.980785280f, 0.195090322f, - 0.956940336f, 0.290284677f, - 0.923879533f, 0.382683432f, - 0.881921264f, 0.471396737f, - 0.831469612f, 0.555570233f, - 0.773010453f, 0.634393284f, - 0.707106781f, 0.707106781f, - 0.634393284f, 0.773010453f, - 0.555570233f, 0.831469612f, - 0.471396737f, 0.881921264f, - 0.382683432f, 0.923879533f, - 0.290284677f, 0.956940336f, - 0.195090322f, 0.980785280f, - 0.098017140f, 0.995184727f, - 0.000000000f, 1.000000000f, - -0.098017140f, 0.995184727f, - -0.195090322f, 0.980785280f, - -0.290284677f, 0.956940336f, - -0.382683432f, 0.923879533f, - -0.471396737f, 0.881921264f, - -0.555570233f, 0.831469612f, - -0.634393284f, 0.773010453f, - -0.707106781f, 0.707106781f, - -0.773010453f, 0.634393284f, - -0.831469612f, 0.555570233f, - -0.881921264f, 0.471396737f, - -0.923879533f, 0.382683432f, - -0.956940336f, 0.290284677f, - -0.980785280f, 0.195090322f, - -0.995184727f, 0.098017140f, - -1.000000000f, 0.000000000f, - -0.995184727f, -0.098017140f, - -0.980785280f, -0.195090322f, - -0.956940336f, -0.290284677f, - -0.923879533f, -0.382683432f, - -0.881921264f, -0.471396737f, - -0.831469612f, -0.555570233f, - -0.773010453f, -0.634393284f, - -0.707106781f, -0.707106781f, - -0.634393284f, -0.773010453f, - -0.555570233f, -0.831469612f, - -0.471396737f, -0.881921264f, - -0.382683432f, -0.923879533f, - -0.290284677f, -0.956940336f, - -0.195090322f, -0.980785280f, - -0.098017140f, -0.995184727f, - -0.000000000f, -1.000000000f, - 0.098017140f, -0.995184727f, - 0.195090322f, -0.980785280f, - 0.290284677f, -0.956940336f, - 0.382683432f, -0.923879533f, - 0.471396737f, -0.881921264f, - 0.555570233f, -0.831469612f, - 0.634393284f, -0.773010453f, - 0.707106781f, -0.707106781f, - 0.773010453f, -0.634393284f, - 0.831469612f, -0.555570233f, - 0.881921264f, -0.471396737f, - 0.923879533f, -0.382683432f, - 0.956940336f, -0.290284677f, - 0.980785280f, -0.195090322f, - 0.995184727f, -0.098017140f -}; + 1.000000000f, 0.000000000f, 0.995184727f, 0.098017140f, 0.980785280f, + 0.195090322f, 0.956940336f, 0.290284677f, 0.923879533f, 0.382683432f, + 0.881921264f, 0.471396737f, 0.831469612f, 0.555570233f, 0.773010453f, + 0.634393284f, 0.707106781f, 0.707106781f, 0.634393284f, 0.773010453f, + 0.555570233f, 0.831469612f, 0.471396737f, 0.881921264f, 0.382683432f, + 0.923879533f, 0.290284677f, 0.956940336f, 0.195090322f, 0.980785280f, + 0.098017140f, 0.995184727f, 0.000000000f, 1.000000000f, -0.098017140f, + 0.995184727f, -0.195090322f, 0.980785280f, -0.290284677f, 0.956940336f, + -0.382683432f, 0.923879533f, -0.471396737f, 0.881921264f, -0.555570233f, + 0.831469612f, -0.634393284f, 0.773010453f, -0.707106781f, 0.707106781f, + -0.773010453f, 0.634393284f, -0.831469612f, 0.555570233f, -0.881921264f, + 0.471396737f, -0.923879533f, 0.382683432f, -0.956940336f, 0.290284677f, + -0.980785280f, 0.195090322f, -0.995184727f, 0.098017140f, -1.000000000f, + 0.000000000f, -0.995184727f, -0.098017140f, -0.980785280f, -0.195090322f, + -0.956940336f, -0.290284677f, -0.923879533f, -0.382683432f, -0.881921264f, + -0.471396737f, -0.831469612f, -0.555570233f, -0.773010453f, -0.634393284f, + -0.707106781f, -0.707106781f, -0.634393284f, -0.773010453f, -0.555570233f, + -0.831469612f, -0.471396737f, -0.881921264f, -0.382683432f, -0.923879533f, + -0.290284677f, -0.956940336f, -0.195090322f, -0.980785280f, -0.098017140f, + -0.995184727f, -0.000000000f, -1.000000000f, 0.098017140f, -0.995184727f, + 0.195090322f, -0.980785280f, 0.290284677f, -0.956940336f, 0.382683432f, + -0.923879533f, 0.471396737f, -0.881921264f, 0.555570233f, -0.831469612f, + 0.634393284f, -0.773010453f, 0.707106781f, -0.707106781f, 0.773010453f, + -0.634393284f, 0.831469612f, -0.555570233f, 0.881921264f, -0.471396737f, + 0.923879533f, -0.382683432f, 0.956940336f, -0.290284677f, 0.980785280f, + -0.195090322f, 0.995184727f, -0.098017140f}; /** @par @@ -344,8 +265,8 @@ const float32_t twiddleCoef_64[128] = { @par
for (i = 0; i< N/; i++)
   {
- 	twiddleCoef[2*i]   = cos(i * 2*PI/(float)N);
- 	twiddleCoef[2*i+1] = sin(i * 2*PI/(float)N);
+        twiddleCoef[2*i]   = cos(i * 2*PI/(float)N);
+        twiddleCoef[2*i+1] = sin(i * 2*PI/(float)N);
   } 
@par where N = 128, PI = 3.14159265358979 @@ -353,135 +274,58 @@ const float32_t twiddleCoef_64[128] = { Cos and Sin values are in interleaved fashion */ const float32_t twiddleCoef_128[256] = { - 1.000000000f, 0.000000000f, - 0.998795456f, 0.049067674f, - 0.995184727f, 0.098017140f, - 0.989176510f, 0.146730474f, - 0.980785280f, 0.195090322f, - 0.970031253f, 0.242980180f, - 0.956940336f, 0.290284677f, - 0.941544065f, 0.336889853f, - 0.923879533f, 0.382683432f, - 0.903989293f, 0.427555093f, - 0.881921264f, 0.471396737f, - 0.857728610f, 0.514102744f, - 0.831469612f, 0.555570233f, - 0.803207531f, 0.595699304f, - 0.773010453f, 0.634393284f, - 0.740951125f, 0.671558955f, - 0.707106781f, 0.707106781f, - 0.671558955f, 0.740951125f, - 0.634393284f, 0.773010453f, - 0.595699304f, 0.803207531f, - 0.555570233f, 0.831469612f, - 0.514102744f, 0.857728610f, - 0.471396737f, 0.881921264f, - 0.427555093f, 0.903989293f, - 0.382683432f, 0.923879533f, - 0.336889853f, 0.941544065f, - 0.290284677f, 0.956940336f, - 0.242980180f, 0.970031253f, - 0.195090322f, 0.980785280f, - 0.146730474f, 0.989176510f, - 0.098017140f, 0.995184727f, - 0.049067674f, 0.998795456f, - 0.000000000f, 1.000000000f, - -0.049067674f, 0.998795456f, - -0.098017140f, 0.995184727f, - -0.146730474f, 0.989176510f, - -0.195090322f, 0.980785280f, - -0.242980180f, 0.970031253f, - -0.290284677f, 0.956940336f, - -0.336889853f, 0.941544065f, - -0.382683432f, 0.923879533f, - -0.427555093f, 0.903989293f, - -0.471396737f, 0.881921264f, - -0.514102744f, 0.857728610f, - -0.555570233f, 0.831469612f, - -0.595699304f, 0.803207531f, - -0.634393284f, 0.773010453f, - -0.671558955f, 0.740951125f, - -0.707106781f, 0.707106781f, - -0.740951125f, 0.671558955f, - -0.773010453f, 0.634393284f, - -0.803207531f, 0.595699304f, - -0.831469612f, 0.555570233f, - -0.857728610f, 0.514102744f, - -0.881921264f, 0.471396737f, - -0.903989293f, 0.427555093f, - -0.923879533f, 0.382683432f, - -0.941544065f, 0.336889853f, - -0.956940336f, 0.290284677f, - -0.970031253f, 0.242980180f, - -0.980785280f, 0.195090322f, - -0.989176510f, 0.146730474f, - -0.995184727f, 0.098017140f, - -0.998795456f, 0.049067674f, - -1.000000000f, 0.000000000f, - -0.998795456f, -0.049067674f, - -0.995184727f, -0.098017140f, - -0.989176510f, -0.146730474f, - -0.980785280f, -0.195090322f, - -0.970031253f, -0.242980180f, - -0.956940336f, -0.290284677f, - -0.941544065f, -0.336889853f, - -0.923879533f, -0.382683432f, - -0.903989293f, -0.427555093f, - -0.881921264f, -0.471396737f, - -0.857728610f, -0.514102744f, - -0.831469612f, -0.555570233f, - -0.803207531f, -0.595699304f, - -0.773010453f, -0.634393284f, - -0.740951125f, -0.671558955f, - -0.707106781f, -0.707106781f, - -0.671558955f, -0.740951125f, - -0.634393284f, -0.773010453f, - -0.595699304f, -0.803207531f, - -0.555570233f, -0.831469612f, - -0.514102744f, -0.857728610f, - -0.471396737f, -0.881921264f, - -0.427555093f, -0.903989293f, - -0.382683432f, -0.923879533f, - -0.336889853f, -0.941544065f, - -0.290284677f, -0.956940336f, - -0.242980180f, -0.970031253f, - -0.195090322f, -0.980785280f, - -0.146730474f, -0.989176510f, - -0.098017140f, -0.995184727f, - -0.049067674f, -0.998795456f, - -0.000000000f, -1.000000000f, - 0.049067674f, -0.998795456f, - 0.098017140f, -0.995184727f, - 0.146730474f, -0.989176510f, - 0.195090322f, -0.980785280f, - 0.242980180f, -0.970031253f, - 0.290284677f, -0.956940336f, - 0.336889853f, -0.941544065f, - 0.382683432f, -0.923879533f, - 0.427555093f, -0.903989293f, - 0.471396737f, -0.881921264f, - 0.514102744f, -0.857728610f, - 0.555570233f, -0.831469612f, - 0.595699304f, -0.803207531f, - 0.634393284f, -0.773010453f, - 0.671558955f, -0.740951125f, - 0.707106781f, -0.707106781f, - 0.740951125f, -0.671558955f, - 0.773010453f, -0.634393284f, - 0.803207531f, -0.595699304f, - 0.831469612f, -0.555570233f, - 0.857728610f, -0.514102744f, - 0.881921264f, -0.471396737f, - 0.903989293f, -0.427555093f, - 0.923879533f, -0.382683432f, - 0.941544065f, -0.336889853f, - 0.956940336f, -0.290284677f, - 0.970031253f, -0.242980180f, - 0.980785280f, -0.195090322f, - 0.989176510f, -0.146730474f, - 0.995184727f, -0.098017140f, - 0.998795456f, -0.049067674f -}; + 1.000000000f, 0.000000000f, 0.998795456f, 0.049067674f, 0.995184727f, + 0.098017140f, 0.989176510f, 0.146730474f, 0.980785280f, 0.195090322f, + 0.970031253f, 0.242980180f, 0.956940336f, 0.290284677f, 0.941544065f, + 0.336889853f, 0.923879533f, 0.382683432f, 0.903989293f, 0.427555093f, + 0.881921264f, 0.471396737f, 0.857728610f, 0.514102744f, 0.831469612f, + 0.555570233f, 0.803207531f, 0.595699304f, 0.773010453f, 0.634393284f, + 0.740951125f, 0.671558955f, 0.707106781f, 0.707106781f, 0.671558955f, + 0.740951125f, 0.634393284f, 0.773010453f, 0.595699304f, 0.803207531f, + 0.555570233f, 0.831469612f, 0.514102744f, 0.857728610f, 0.471396737f, + 0.881921264f, 0.427555093f, 0.903989293f, 0.382683432f, 0.923879533f, + 0.336889853f, 0.941544065f, 0.290284677f, 0.956940336f, 0.242980180f, + 0.970031253f, 0.195090322f, 0.980785280f, 0.146730474f, 0.989176510f, + 0.098017140f, 0.995184727f, 0.049067674f, 0.998795456f, 0.000000000f, + 1.000000000f, -0.049067674f, 0.998795456f, -0.098017140f, 0.995184727f, + -0.146730474f, 0.989176510f, -0.195090322f, 0.980785280f, -0.242980180f, + 0.970031253f, -0.290284677f, 0.956940336f, -0.336889853f, 0.941544065f, + -0.382683432f, 0.923879533f, -0.427555093f, 0.903989293f, -0.471396737f, + 0.881921264f, -0.514102744f, 0.857728610f, -0.555570233f, 0.831469612f, + -0.595699304f, 0.803207531f, -0.634393284f, 0.773010453f, -0.671558955f, + 0.740951125f, -0.707106781f, 0.707106781f, -0.740951125f, 0.671558955f, + -0.773010453f, 0.634393284f, -0.803207531f, 0.595699304f, -0.831469612f, + 0.555570233f, -0.857728610f, 0.514102744f, -0.881921264f, 0.471396737f, + -0.903989293f, 0.427555093f, -0.923879533f, 0.382683432f, -0.941544065f, + 0.336889853f, -0.956940336f, 0.290284677f, -0.970031253f, 0.242980180f, + -0.980785280f, 0.195090322f, -0.989176510f, 0.146730474f, -0.995184727f, + 0.098017140f, -0.998795456f, 0.049067674f, -1.000000000f, 0.000000000f, + -0.998795456f, -0.049067674f, -0.995184727f, -0.098017140f, -0.989176510f, + -0.146730474f, -0.980785280f, -0.195090322f, -0.970031253f, -0.242980180f, + -0.956940336f, -0.290284677f, -0.941544065f, -0.336889853f, -0.923879533f, + -0.382683432f, -0.903989293f, -0.427555093f, -0.881921264f, -0.471396737f, + -0.857728610f, -0.514102744f, -0.831469612f, -0.555570233f, -0.803207531f, + -0.595699304f, -0.773010453f, -0.634393284f, -0.740951125f, -0.671558955f, + -0.707106781f, -0.707106781f, -0.671558955f, -0.740951125f, -0.634393284f, + -0.773010453f, -0.595699304f, -0.803207531f, -0.555570233f, -0.831469612f, + -0.514102744f, -0.857728610f, -0.471396737f, -0.881921264f, -0.427555093f, + -0.903989293f, -0.382683432f, -0.923879533f, -0.336889853f, -0.941544065f, + -0.290284677f, -0.956940336f, -0.242980180f, -0.970031253f, -0.195090322f, + -0.980785280f, -0.146730474f, -0.989176510f, -0.098017140f, -0.995184727f, + -0.049067674f, -0.998795456f, -0.000000000f, -1.000000000f, 0.049067674f, + -0.998795456f, 0.098017140f, -0.995184727f, 0.146730474f, -0.989176510f, + 0.195090322f, -0.980785280f, 0.242980180f, -0.970031253f, 0.290284677f, + -0.956940336f, 0.336889853f, -0.941544065f, 0.382683432f, -0.923879533f, + 0.427555093f, -0.903989293f, 0.471396737f, -0.881921264f, 0.514102744f, + -0.857728610f, 0.555570233f, -0.831469612f, 0.595699304f, -0.803207531f, + 0.634393284f, -0.773010453f, 0.671558955f, -0.740951125f, 0.707106781f, + -0.707106781f, 0.740951125f, -0.671558955f, 0.773010453f, -0.634393284f, + 0.803207531f, -0.595699304f, 0.831469612f, -0.555570233f, 0.857728610f, + -0.514102744f, 0.881921264f, -0.471396737f, 0.903989293f, -0.427555093f, + 0.923879533f, -0.382683432f, 0.941544065f, -0.336889853f, 0.956940336f, + -0.290284677f, 0.970031253f, -0.242980180f, 0.980785280f, -0.195090322f, + 0.989176510f, -0.146730474f, 0.995184727f, -0.098017140f, 0.998795456f, + -0.049067674f}; /** @par @@ -489,8 +333,8 @@ const float32_t twiddleCoef_128[256] = { @par
for(i = 0; i< N/; i++)
   {
- 	twiddleCoef[2*i]   = cos(i * 2*PI/(float)N);
- 	twiddleCoef[2*i+1] = sin(i * 2*PI/(float)N);
+        twiddleCoef[2*i]   = cos(i * 2*PI/(float)N);
+        twiddleCoef[2*i+1] = sin(i * 2*PI/(float)N);
   } 
@par where N = 256, PI = 3.14159265358979 @@ -498,263 +342,109 @@ const float32_t twiddleCoef_128[256] = { Cos and Sin values are in interleaved fashion */ const float32_t twiddleCoef_256[512] = { - 1.000000000f, 0.000000000f, - 0.999698819f, 0.024541229f, - 0.998795456f, 0.049067674f, - 0.997290457f, 0.073564564f, - 0.995184727f, 0.098017140f, - 0.992479535f, 0.122410675f, - 0.989176510f, 0.146730474f, - 0.985277642f, 0.170961889f, - 0.980785280f, 0.195090322f, - 0.975702130f, 0.219101240f, - 0.970031253f, 0.242980180f, - 0.963776066f, 0.266712757f, - 0.956940336f, 0.290284677f, - 0.949528181f, 0.313681740f, - 0.941544065f, 0.336889853f, - 0.932992799f, 0.359895037f, - 0.923879533f, 0.382683432f, - 0.914209756f, 0.405241314f, - 0.903989293f, 0.427555093f, - 0.893224301f, 0.449611330f, - 0.881921264f, 0.471396737f, - 0.870086991f, 0.492898192f, - 0.857728610f, 0.514102744f, - 0.844853565f, 0.534997620f, - 0.831469612f, 0.555570233f, - 0.817584813f, 0.575808191f, - 0.803207531f, 0.595699304f, - 0.788346428f, 0.615231591f, - 0.773010453f, 0.634393284f, - 0.757208847f, 0.653172843f, - 0.740951125f, 0.671558955f, - 0.724247083f, 0.689540545f, - 0.707106781f, 0.707106781f, - 0.689540545f, 0.724247083f, - 0.671558955f, 0.740951125f, - 0.653172843f, 0.757208847f, - 0.634393284f, 0.773010453f, - 0.615231591f, 0.788346428f, - 0.595699304f, 0.803207531f, - 0.575808191f, 0.817584813f, - 0.555570233f, 0.831469612f, - 0.534997620f, 0.844853565f, - 0.514102744f, 0.857728610f, - 0.492898192f, 0.870086991f, - 0.471396737f, 0.881921264f, - 0.449611330f, 0.893224301f, - 0.427555093f, 0.903989293f, - 0.405241314f, 0.914209756f, - 0.382683432f, 0.923879533f, - 0.359895037f, 0.932992799f, - 0.336889853f, 0.941544065f, - 0.313681740f, 0.949528181f, - 0.290284677f, 0.956940336f, - 0.266712757f, 0.963776066f, - 0.242980180f, 0.970031253f, - 0.219101240f, 0.975702130f, - 0.195090322f, 0.980785280f, - 0.170961889f, 0.985277642f, - 0.146730474f, 0.989176510f, - 0.122410675f, 0.992479535f, - 0.098017140f, 0.995184727f, - 0.073564564f, 0.997290457f, - 0.049067674f, 0.998795456f, - 0.024541229f, 0.999698819f, - 0.000000000f, 1.000000000f, - -0.024541229f, 0.999698819f, - -0.049067674f, 0.998795456f, - -0.073564564f, 0.997290457f, - -0.098017140f, 0.995184727f, - -0.122410675f, 0.992479535f, - -0.146730474f, 0.989176510f, - -0.170961889f, 0.985277642f, - -0.195090322f, 0.980785280f, - -0.219101240f, 0.975702130f, - -0.242980180f, 0.970031253f, - -0.266712757f, 0.963776066f, - -0.290284677f, 0.956940336f, - -0.313681740f, 0.949528181f, - -0.336889853f, 0.941544065f, - -0.359895037f, 0.932992799f, - -0.382683432f, 0.923879533f, - -0.405241314f, 0.914209756f, - -0.427555093f, 0.903989293f, - -0.449611330f, 0.893224301f, - -0.471396737f, 0.881921264f, - -0.492898192f, 0.870086991f, - -0.514102744f, 0.857728610f, - -0.534997620f, 0.844853565f, - -0.555570233f, 0.831469612f, - -0.575808191f, 0.817584813f, - -0.595699304f, 0.803207531f, - -0.615231591f, 0.788346428f, - -0.634393284f, 0.773010453f, - -0.653172843f, 0.757208847f, - -0.671558955f, 0.740951125f, - -0.689540545f, 0.724247083f, - -0.707106781f, 0.707106781f, - -0.724247083f, 0.689540545f, - -0.740951125f, 0.671558955f, - -0.757208847f, 0.653172843f, - -0.773010453f, 0.634393284f, - -0.788346428f, 0.615231591f, - -0.803207531f, 0.595699304f, - -0.817584813f, 0.575808191f, - -0.831469612f, 0.555570233f, - -0.844853565f, 0.534997620f, - -0.857728610f, 0.514102744f, - -0.870086991f, 0.492898192f, - -0.881921264f, 0.471396737f, - -0.893224301f, 0.449611330f, - -0.903989293f, 0.427555093f, - -0.914209756f, 0.405241314f, - -0.923879533f, 0.382683432f, - -0.932992799f, 0.359895037f, - -0.941544065f, 0.336889853f, - -0.949528181f, 0.313681740f, - -0.956940336f, 0.290284677f, - -0.963776066f, 0.266712757f, - -0.970031253f, 0.242980180f, - -0.975702130f, 0.219101240f, - -0.980785280f, 0.195090322f, - -0.985277642f, 0.170961889f, - -0.989176510f, 0.146730474f, - -0.992479535f, 0.122410675f, - -0.995184727f, 0.098017140f, - -0.997290457f, 0.073564564f, - -0.998795456f, 0.049067674f, - -0.999698819f, 0.024541229f, - -1.000000000f, 0.000000000f, - -0.999698819f, -0.024541229f, - -0.998795456f, -0.049067674f, - -0.997290457f, -0.073564564f, - -0.995184727f, -0.098017140f, - -0.992479535f, -0.122410675f, - -0.989176510f, -0.146730474f, - -0.985277642f, -0.170961889f, - -0.980785280f, -0.195090322f, - -0.975702130f, -0.219101240f, - -0.970031253f, -0.242980180f, - -0.963776066f, -0.266712757f, - -0.956940336f, -0.290284677f, - -0.949528181f, -0.313681740f, - -0.941544065f, -0.336889853f, - -0.932992799f, -0.359895037f, - -0.923879533f, -0.382683432f, - -0.914209756f, -0.405241314f, - -0.903989293f, -0.427555093f, - -0.893224301f, -0.449611330f, - -0.881921264f, -0.471396737f, - -0.870086991f, -0.492898192f, - -0.857728610f, -0.514102744f, - -0.844853565f, -0.534997620f, - -0.831469612f, -0.555570233f, - -0.817584813f, -0.575808191f, - -0.803207531f, -0.595699304f, - -0.788346428f, -0.615231591f, - -0.773010453f, -0.634393284f, - -0.757208847f, -0.653172843f, - -0.740951125f, -0.671558955f, - -0.724247083f, -0.689540545f, - -0.707106781f, -0.707106781f, - -0.689540545f, -0.724247083f, - -0.671558955f, -0.740951125f, - -0.653172843f, -0.757208847f, - -0.634393284f, -0.773010453f, - -0.615231591f, -0.788346428f, - -0.595699304f, -0.803207531f, - -0.575808191f, -0.817584813f, - -0.555570233f, -0.831469612f, - -0.534997620f, -0.844853565f, - -0.514102744f, -0.857728610f, - -0.492898192f, -0.870086991f, - -0.471396737f, -0.881921264f, - -0.449611330f, -0.893224301f, - -0.427555093f, -0.903989293f, - -0.405241314f, -0.914209756f, - -0.382683432f, -0.923879533f, - -0.359895037f, -0.932992799f, - -0.336889853f, -0.941544065f, - -0.313681740f, -0.949528181f, - -0.290284677f, -0.956940336f, - -0.266712757f, -0.963776066f, - -0.242980180f, -0.970031253f, - -0.219101240f, -0.975702130f, - -0.195090322f, -0.980785280f, - -0.170961889f, -0.985277642f, - -0.146730474f, -0.989176510f, - -0.122410675f, -0.992479535f, - -0.098017140f, -0.995184727f, - -0.073564564f, -0.997290457f, - -0.049067674f, -0.998795456f, - -0.024541229f, -0.999698819f, - -0.000000000f, -1.000000000f, - 0.024541229f, -0.999698819f, - 0.049067674f, -0.998795456f, - 0.073564564f, -0.997290457f, - 0.098017140f, -0.995184727f, - 0.122410675f, -0.992479535f, - 0.146730474f, -0.989176510f, - 0.170961889f, -0.985277642f, - 0.195090322f, -0.980785280f, - 0.219101240f, -0.975702130f, - 0.242980180f, -0.970031253f, - 0.266712757f, -0.963776066f, - 0.290284677f, -0.956940336f, - 0.313681740f, -0.949528181f, - 0.336889853f, -0.941544065f, - 0.359895037f, -0.932992799f, - 0.382683432f, -0.923879533f, - 0.405241314f, -0.914209756f, - 0.427555093f, -0.903989293f, - 0.449611330f, -0.893224301f, - 0.471396737f, -0.881921264f, - 0.492898192f, -0.870086991f, - 0.514102744f, -0.857728610f, - 0.534997620f, -0.844853565f, - 0.555570233f, -0.831469612f, - 0.575808191f, -0.817584813f, - 0.595699304f, -0.803207531f, - 0.615231591f, -0.788346428f, - 0.634393284f, -0.773010453f, - 0.653172843f, -0.757208847f, - 0.671558955f, -0.740951125f, - 0.689540545f, -0.724247083f, - 0.707106781f, -0.707106781f, - 0.724247083f, -0.689540545f, - 0.740951125f, -0.671558955f, - 0.757208847f, -0.653172843f, - 0.773010453f, -0.634393284f, - 0.788346428f, -0.615231591f, - 0.803207531f, -0.595699304f, - 0.817584813f, -0.575808191f, - 0.831469612f, -0.555570233f, - 0.844853565f, -0.534997620f, - 0.857728610f, -0.514102744f, - 0.870086991f, -0.492898192f, - 0.881921264f, -0.471396737f, - 0.893224301f, -0.449611330f, - 0.903989293f, -0.427555093f, - 0.914209756f, -0.405241314f, - 0.923879533f, -0.382683432f, - 0.932992799f, -0.359895037f, - 0.941544065f, -0.336889853f, - 0.949528181f, -0.313681740f, - 0.956940336f, -0.290284677f, - 0.963776066f, -0.266712757f, - 0.970031253f, -0.242980180f, - 0.975702130f, -0.219101240f, - 0.980785280f, -0.195090322f, - 0.985277642f, -0.170961889f, - 0.989176510f, -0.146730474f, - 0.992479535f, -0.122410675f, - 0.995184727f, -0.098017140f, - 0.997290457f, -0.073564564f, - 0.998795456f, -0.049067674f, - 0.999698819f, -0.024541229f -}; + 1.000000000f, 0.000000000f, 0.999698819f, 0.024541229f, 0.998795456f, + 0.049067674f, 0.997290457f, 0.073564564f, 0.995184727f, 0.098017140f, + 0.992479535f, 0.122410675f, 0.989176510f, 0.146730474f, 0.985277642f, + 0.170961889f, 0.980785280f, 0.195090322f, 0.975702130f, 0.219101240f, + 0.970031253f, 0.242980180f, 0.963776066f, 0.266712757f, 0.956940336f, + 0.290284677f, 0.949528181f, 0.313681740f, 0.941544065f, 0.336889853f, + 0.932992799f, 0.359895037f, 0.923879533f, 0.382683432f, 0.914209756f, + 0.405241314f, 0.903989293f, 0.427555093f, 0.893224301f, 0.449611330f, + 0.881921264f, 0.471396737f, 0.870086991f, 0.492898192f, 0.857728610f, + 0.514102744f, 0.844853565f, 0.534997620f, 0.831469612f, 0.555570233f, + 0.817584813f, 0.575808191f, 0.803207531f, 0.595699304f, 0.788346428f, + 0.615231591f, 0.773010453f, 0.634393284f, 0.757208847f, 0.653172843f, + 0.740951125f, 0.671558955f, 0.724247083f, 0.689540545f, 0.707106781f, + 0.707106781f, 0.689540545f, 0.724247083f, 0.671558955f, 0.740951125f, + 0.653172843f, 0.757208847f, 0.634393284f, 0.773010453f, 0.615231591f, + 0.788346428f, 0.595699304f, 0.803207531f, 0.575808191f, 0.817584813f, + 0.555570233f, 0.831469612f, 0.534997620f, 0.844853565f, 0.514102744f, + 0.857728610f, 0.492898192f, 0.870086991f, 0.471396737f, 0.881921264f, + 0.449611330f, 0.893224301f, 0.427555093f, 0.903989293f, 0.405241314f, + 0.914209756f, 0.382683432f, 0.923879533f, 0.359895037f, 0.932992799f, + 0.336889853f, 0.941544065f, 0.313681740f, 0.949528181f, 0.290284677f, + 0.956940336f, 0.266712757f, 0.963776066f, 0.242980180f, 0.970031253f, + 0.219101240f, 0.975702130f, 0.195090322f, 0.980785280f, 0.170961889f, + 0.985277642f, 0.146730474f, 0.989176510f, 0.122410675f, 0.992479535f, + 0.098017140f, 0.995184727f, 0.073564564f, 0.997290457f, 0.049067674f, + 0.998795456f, 0.024541229f, 0.999698819f, 0.000000000f, 1.000000000f, + -0.024541229f, 0.999698819f, -0.049067674f, 0.998795456f, -0.073564564f, + 0.997290457f, -0.098017140f, 0.995184727f, -0.122410675f, 0.992479535f, + -0.146730474f, 0.989176510f, -0.170961889f, 0.985277642f, -0.195090322f, + 0.980785280f, -0.219101240f, 0.975702130f, -0.242980180f, 0.970031253f, + -0.266712757f, 0.963776066f, -0.290284677f, 0.956940336f, -0.313681740f, + 0.949528181f, -0.336889853f, 0.941544065f, -0.359895037f, 0.932992799f, + -0.382683432f, 0.923879533f, -0.405241314f, 0.914209756f, -0.427555093f, + 0.903989293f, -0.449611330f, 0.893224301f, -0.471396737f, 0.881921264f, + -0.492898192f, 0.870086991f, -0.514102744f, 0.857728610f, -0.534997620f, + 0.844853565f, -0.555570233f, 0.831469612f, -0.575808191f, 0.817584813f, + -0.595699304f, 0.803207531f, -0.615231591f, 0.788346428f, -0.634393284f, + 0.773010453f, -0.653172843f, 0.757208847f, -0.671558955f, 0.740951125f, + -0.689540545f, 0.724247083f, -0.707106781f, 0.707106781f, -0.724247083f, + 0.689540545f, -0.740951125f, 0.671558955f, -0.757208847f, 0.653172843f, + -0.773010453f, 0.634393284f, -0.788346428f, 0.615231591f, -0.803207531f, + 0.595699304f, -0.817584813f, 0.575808191f, -0.831469612f, 0.555570233f, + -0.844853565f, 0.534997620f, -0.857728610f, 0.514102744f, -0.870086991f, + 0.492898192f, -0.881921264f, 0.471396737f, -0.893224301f, 0.449611330f, + -0.903989293f, 0.427555093f, -0.914209756f, 0.405241314f, -0.923879533f, + 0.382683432f, -0.932992799f, 0.359895037f, -0.941544065f, 0.336889853f, + -0.949528181f, 0.313681740f, -0.956940336f, 0.290284677f, -0.963776066f, + 0.266712757f, -0.970031253f, 0.242980180f, -0.975702130f, 0.219101240f, + -0.980785280f, 0.195090322f, -0.985277642f, 0.170961889f, -0.989176510f, + 0.146730474f, -0.992479535f, 0.122410675f, -0.995184727f, 0.098017140f, + -0.997290457f, 0.073564564f, -0.998795456f, 0.049067674f, -0.999698819f, + 0.024541229f, -1.000000000f, 0.000000000f, -0.999698819f, -0.024541229f, + -0.998795456f, -0.049067674f, -0.997290457f, -0.073564564f, -0.995184727f, + -0.098017140f, -0.992479535f, -0.122410675f, -0.989176510f, -0.146730474f, + -0.985277642f, -0.170961889f, -0.980785280f, -0.195090322f, -0.975702130f, + -0.219101240f, -0.970031253f, -0.242980180f, -0.963776066f, -0.266712757f, + -0.956940336f, -0.290284677f, -0.949528181f, -0.313681740f, -0.941544065f, + -0.336889853f, -0.932992799f, -0.359895037f, -0.923879533f, -0.382683432f, + -0.914209756f, -0.405241314f, -0.903989293f, -0.427555093f, -0.893224301f, + -0.449611330f, -0.881921264f, -0.471396737f, -0.870086991f, -0.492898192f, + -0.857728610f, -0.514102744f, -0.844853565f, -0.534997620f, -0.831469612f, + -0.555570233f, -0.817584813f, -0.575808191f, -0.803207531f, -0.595699304f, + -0.788346428f, -0.615231591f, -0.773010453f, -0.634393284f, -0.757208847f, + -0.653172843f, -0.740951125f, -0.671558955f, -0.724247083f, -0.689540545f, + -0.707106781f, -0.707106781f, -0.689540545f, -0.724247083f, -0.671558955f, + -0.740951125f, -0.653172843f, -0.757208847f, -0.634393284f, -0.773010453f, + -0.615231591f, -0.788346428f, -0.595699304f, -0.803207531f, -0.575808191f, + -0.817584813f, -0.555570233f, -0.831469612f, -0.534997620f, -0.844853565f, + -0.514102744f, -0.857728610f, -0.492898192f, -0.870086991f, -0.471396737f, + -0.881921264f, -0.449611330f, -0.893224301f, -0.427555093f, -0.903989293f, + -0.405241314f, -0.914209756f, -0.382683432f, -0.923879533f, -0.359895037f, + -0.932992799f, -0.336889853f, -0.941544065f, -0.313681740f, -0.949528181f, + -0.290284677f, -0.956940336f, -0.266712757f, -0.963776066f, -0.242980180f, + -0.970031253f, -0.219101240f, -0.975702130f, -0.195090322f, -0.980785280f, + -0.170961889f, -0.985277642f, -0.146730474f, -0.989176510f, -0.122410675f, + -0.992479535f, -0.098017140f, -0.995184727f, -0.073564564f, -0.997290457f, + -0.049067674f, -0.998795456f, -0.024541229f, -0.999698819f, -0.000000000f, + -1.000000000f, 0.024541229f, -0.999698819f, 0.049067674f, -0.998795456f, + 0.073564564f, -0.997290457f, 0.098017140f, -0.995184727f, 0.122410675f, + -0.992479535f, 0.146730474f, -0.989176510f, 0.170961889f, -0.985277642f, + 0.195090322f, -0.980785280f, 0.219101240f, -0.975702130f, 0.242980180f, + -0.970031253f, 0.266712757f, -0.963776066f, 0.290284677f, -0.956940336f, + 0.313681740f, -0.949528181f, 0.336889853f, -0.941544065f, 0.359895037f, + -0.932992799f, 0.382683432f, -0.923879533f, 0.405241314f, -0.914209756f, + 0.427555093f, -0.903989293f, 0.449611330f, -0.893224301f, 0.471396737f, + -0.881921264f, 0.492898192f, -0.870086991f, 0.514102744f, -0.857728610f, + 0.534997620f, -0.844853565f, 0.555570233f, -0.831469612f, 0.575808191f, + -0.817584813f, 0.595699304f, -0.803207531f, 0.615231591f, -0.788346428f, + 0.634393284f, -0.773010453f, 0.653172843f, -0.757208847f, 0.671558955f, + -0.740951125f, 0.689540545f, -0.724247083f, 0.707106781f, -0.707106781f, + 0.724247083f, -0.689540545f, 0.740951125f, -0.671558955f, 0.757208847f, + -0.653172843f, 0.773010453f, -0.634393284f, 0.788346428f, -0.615231591f, + 0.803207531f, -0.595699304f, 0.817584813f, -0.575808191f, 0.831469612f, + -0.555570233f, 0.844853565f, -0.534997620f, 0.857728610f, -0.514102744f, + 0.870086991f, -0.492898192f, 0.881921264f, -0.471396737f, 0.893224301f, + -0.449611330f, 0.903989293f, -0.427555093f, 0.914209756f, -0.405241314f, + 0.923879533f, -0.382683432f, 0.932992799f, -0.359895037f, 0.941544065f, + -0.336889853f, 0.949528181f, -0.313681740f, 0.956940336f, -0.290284677f, + 0.963776066f, -0.266712757f, 0.970031253f, -0.242980180f, 0.975702130f, + -0.219101240f, 0.980785280f, -0.195090322f, 0.985277642f, -0.170961889f, + 0.989176510f, -0.146730474f, 0.992479535f, -0.122410675f, 0.995184727f, + -0.098017140f, 0.997290457f, -0.073564564f, 0.998795456f, -0.049067674f, + 0.999698819f, -0.024541229f}; /** @par @@ -762,8 +452,8 @@ const float32_t twiddleCoef_256[512] = { @par
for (i = 0; i< N/; i++)
   {
- 	twiddleCoef[2*i]   = cos(i * 2*PI/(float)N);
- 	twiddleCoef[2*i+1] = sin(i * 2*PI/(float)N);
+        twiddleCoef[2*i]   = cos(i * 2*PI/(float)N);
+        twiddleCoef[2*i+1] = sin(i * 2*PI/(float)N);
   } 
@par where N = 512, PI = 3.14159265358979 @@ -771,527 +461,219 @@ const float32_t twiddleCoef_256[512] = { Cos and Sin values are in interleaved fashion */ const float32_t twiddleCoef_512[1024] = { - 1.000000000f, 0.000000000f, - 0.999924702f, 0.012271538f, - 0.999698819f, 0.024541229f, - 0.999322385f, 0.036807223f, - 0.998795456f, 0.049067674f, - 0.998118113f, 0.061320736f, - 0.997290457f, 0.073564564f, - 0.996312612f, 0.085797312f, - 0.995184727f, 0.098017140f, - 0.993906970f, 0.110222207f, - 0.992479535f, 0.122410675f, - 0.990902635f, 0.134580709f, - 0.989176510f, 0.146730474f, - 0.987301418f, 0.158858143f, - 0.985277642f, 0.170961889f, - 0.983105487f, 0.183039888f, - 0.980785280f, 0.195090322f, - 0.978317371f, 0.207111376f, - 0.975702130f, 0.219101240f, - 0.972939952f, 0.231058108f, - 0.970031253f, 0.242980180f, - 0.966976471f, 0.254865660f, - 0.963776066f, 0.266712757f, - 0.960430519f, 0.278519689f, - 0.956940336f, 0.290284677f, - 0.953306040f, 0.302005949f, - 0.949528181f, 0.313681740f, - 0.945607325f, 0.325310292f, - 0.941544065f, 0.336889853f, - 0.937339012f, 0.348418680f, - 0.932992799f, 0.359895037f, - 0.928506080f, 0.371317194f, - 0.923879533f, 0.382683432f, - 0.919113852f, 0.393992040f, - 0.914209756f, 0.405241314f, - 0.909167983f, 0.416429560f, - 0.903989293f, 0.427555093f, - 0.898674466f, 0.438616239f, - 0.893224301f, 0.449611330f, - 0.887639620f, 0.460538711f, - 0.881921264f, 0.471396737f, - 0.876070094f, 0.482183772f, - 0.870086991f, 0.492898192f, - 0.863972856f, 0.503538384f, - 0.857728610f, 0.514102744f, - 0.851355193f, 0.524589683f, - 0.844853565f, 0.534997620f, - 0.838224706f, 0.545324988f, - 0.831469612f, 0.555570233f, - 0.824589303f, 0.565731811f, - 0.817584813f, 0.575808191f, - 0.810457198f, 0.585797857f, - 0.803207531f, 0.595699304f, - 0.795836905f, 0.605511041f, - 0.788346428f, 0.615231591f, - 0.780737229f, 0.624859488f, - 0.773010453f, 0.634393284f, - 0.765167266f, 0.643831543f, - 0.757208847f, 0.653172843f, - 0.749136395f, 0.662415778f, - 0.740951125f, 0.671558955f, - 0.732654272f, 0.680600998f, - 0.724247083f, 0.689540545f, - 0.715730825f, 0.698376249f, - 0.707106781f, 0.707106781f, - 0.698376249f, 0.715730825f, - 0.689540545f, 0.724247083f, - 0.680600998f, 0.732654272f, - 0.671558955f, 0.740951125f, - 0.662415778f, 0.749136395f, - 0.653172843f, 0.757208847f, - 0.643831543f, 0.765167266f, - 0.634393284f, 0.773010453f, - 0.624859488f, 0.780737229f, - 0.615231591f, 0.788346428f, - 0.605511041f, 0.795836905f, - 0.595699304f, 0.803207531f, - 0.585797857f, 0.810457198f, - 0.575808191f, 0.817584813f, - 0.565731811f, 0.824589303f, - 0.555570233f, 0.831469612f, - 0.545324988f, 0.838224706f, - 0.534997620f, 0.844853565f, - 0.524589683f, 0.851355193f, - 0.514102744f, 0.857728610f, - 0.503538384f, 0.863972856f, - 0.492898192f, 0.870086991f, - 0.482183772f, 0.876070094f, - 0.471396737f, 0.881921264f, - 0.460538711f, 0.887639620f, - 0.449611330f, 0.893224301f, - 0.438616239f, 0.898674466f, - 0.427555093f, 0.903989293f, - 0.416429560f, 0.909167983f, - 0.405241314f, 0.914209756f, - 0.393992040f, 0.919113852f, - 0.382683432f, 0.923879533f, - 0.371317194f, 0.928506080f, - 0.359895037f, 0.932992799f, - 0.348418680f, 0.937339012f, - 0.336889853f, 0.941544065f, - 0.325310292f, 0.945607325f, - 0.313681740f, 0.949528181f, - 0.302005949f, 0.953306040f, - 0.290284677f, 0.956940336f, - 0.278519689f, 0.960430519f, - 0.266712757f, 0.963776066f, - 0.254865660f, 0.966976471f, - 0.242980180f, 0.970031253f, - 0.231058108f, 0.972939952f, - 0.219101240f, 0.975702130f, - 0.207111376f, 0.978317371f, - 0.195090322f, 0.980785280f, - 0.183039888f, 0.983105487f, - 0.170961889f, 0.985277642f, - 0.158858143f, 0.987301418f, - 0.146730474f, 0.989176510f, - 0.134580709f, 0.990902635f, - 0.122410675f, 0.992479535f, - 0.110222207f, 0.993906970f, - 0.098017140f, 0.995184727f, - 0.085797312f, 0.996312612f, - 0.073564564f, 0.997290457f, - 0.061320736f, 0.998118113f, - 0.049067674f, 0.998795456f, - 0.036807223f, 0.999322385f, - 0.024541229f, 0.999698819f, - 0.012271538f, 0.999924702f, - 0.000000000f, 1.000000000f, - -0.012271538f, 0.999924702f, - -0.024541229f, 0.999698819f, - -0.036807223f, 0.999322385f, - -0.049067674f, 0.998795456f, - -0.061320736f, 0.998118113f, - -0.073564564f, 0.997290457f, - -0.085797312f, 0.996312612f, - -0.098017140f, 0.995184727f, - -0.110222207f, 0.993906970f, - -0.122410675f, 0.992479535f, - -0.134580709f, 0.990902635f, - -0.146730474f, 0.989176510f, - -0.158858143f, 0.987301418f, - -0.170961889f, 0.985277642f, - -0.183039888f, 0.983105487f, - -0.195090322f, 0.980785280f, - -0.207111376f, 0.978317371f, - -0.219101240f, 0.975702130f, - -0.231058108f, 0.972939952f, - -0.242980180f, 0.970031253f, - -0.254865660f, 0.966976471f, - -0.266712757f, 0.963776066f, - -0.278519689f, 0.960430519f, - -0.290284677f, 0.956940336f, - -0.302005949f, 0.953306040f, - -0.313681740f, 0.949528181f, - -0.325310292f, 0.945607325f, - -0.336889853f, 0.941544065f, - -0.348418680f, 0.937339012f, - -0.359895037f, 0.932992799f, - -0.371317194f, 0.928506080f, - -0.382683432f, 0.923879533f, - -0.393992040f, 0.919113852f, - -0.405241314f, 0.914209756f, - -0.416429560f, 0.909167983f, - -0.427555093f, 0.903989293f, - -0.438616239f, 0.898674466f, - -0.449611330f, 0.893224301f, - -0.460538711f, 0.887639620f, - -0.471396737f, 0.881921264f, - -0.482183772f, 0.876070094f, - -0.492898192f, 0.870086991f, - -0.503538384f, 0.863972856f, - -0.514102744f, 0.857728610f, - -0.524589683f, 0.851355193f, - -0.534997620f, 0.844853565f, - -0.545324988f, 0.838224706f, - -0.555570233f, 0.831469612f, - -0.565731811f, 0.824589303f, - -0.575808191f, 0.817584813f, - -0.585797857f, 0.810457198f, - -0.595699304f, 0.803207531f, - -0.605511041f, 0.795836905f, - -0.615231591f, 0.788346428f, - -0.624859488f, 0.780737229f, - -0.634393284f, 0.773010453f, - -0.643831543f, 0.765167266f, - -0.653172843f, 0.757208847f, - -0.662415778f, 0.749136395f, - -0.671558955f, 0.740951125f, - -0.680600998f, 0.732654272f, - -0.689540545f, 0.724247083f, - -0.698376249f, 0.715730825f, - -0.707106781f, 0.707106781f, - -0.715730825f, 0.698376249f, - -0.724247083f, 0.689540545f, - -0.732654272f, 0.680600998f, - -0.740951125f, 0.671558955f, - -0.749136395f, 0.662415778f, - -0.757208847f, 0.653172843f, - -0.765167266f, 0.643831543f, - -0.773010453f, 0.634393284f, - -0.780737229f, 0.624859488f, - -0.788346428f, 0.615231591f, - -0.795836905f, 0.605511041f, - -0.803207531f, 0.595699304f, - -0.810457198f, 0.585797857f, - -0.817584813f, 0.575808191f, - -0.824589303f, 0.565731811f, - -0.831469612f, 0.555570233f, - -0.838224706f, 0.545324988f, - -0.844853565f, 0.534997620f, - -0.851355193f, 0.524589683f, - -0.857728610f, 0.514102744f, - -0.863972856f, 0.503538384f, - -0.870086991f, 0.492898192f, - -0.876070094f, 0.482183772f, - -0.881921264f, 0.471396737f, - -0.887639620f, 0.460538711f, - -0.893224301f, 0.449611330f, - -0.898674466f, 0.438616239f, - -0.903989293f, 0.427555093f, - -0.909167983f, 0.416429560f, - -0.914209756f, 0.405241314f, - -0.919113852f, 0.393992040f, - -0.923879533f, 0.382683432f, - -0.928506080f, 0.371317194f, - -0.932992799f, 0.359895037f, - -0.937339012f, 0.348418680f, - -0.941544065f, 0.336889853f, - -0.945607325f, 0.325310292f, - -0.949528181f, 0.313681740f, - -0.953306040f, 0.302005949f, - -0.956940336f, 0.290284677f, - -0.960430519f, 0.278519689f, - -0.963776066f, 0.266712757f, - -0.966976471f, 0.254865660f, - -0.970031253f, 0.242980180f, - -0.972939952f, 0.231058108f, - -0.975702130f, 0.219101240f, - -0.978317371f, 0.207111376f, - -0.980785280f, 0.195090322f, - -0.983105487f, 0.183039888f, - -0.985277642f, 0.170961889f, - -0.987301418f, 0.158858143f, - -0.989176510f, 0.146730474f, - -0.990902635f, 0.134580709f, - -0.992479535f, 0.122410675f, - -0.993906970f, 0.110222207f, - -0.995184727f, 0.098017140f, - -0.996312612f, 0.085797312f, - -0.997290457f, 0.073564564f, - -0.998118113f, 0.061320736f, - -0.998795456f, 0.049067674f, - -0.999322385f, 0.036807223f, - -0.999698819f, 0.024541229f, - -0.999924702f, 0.012271538f, - -1.000000000f, 0.000000000f, - -0.999924702f, -0.012271538f, - -0.999698819f, -0.024541229f, - -0.999322385f, -0.036807223f, - -0.998795456f, -0.049067674f, - -0.998118113f, -0.061320736f, - -0.997290457f, -0.073564564f, - -0.996312612f, -0.085797312f, - -0.995184727f, -0.098017140f, - -0.993906970f, -0.110222207f, - -0.992479535f, -0.122410675f, - -0.990902635f, -0.134580709f, - -0.989176510f, -0.146730474f, - -0.987301418f, -0.158858143f, - -0.985277642f, -0.170961889f, - -0.983105487f, -0.183039888f, - -0.980785280f, -0.195090322f, - -0.978317371f, -0.207111376f, - -0.975702130f, -0.219101240f, - -0.972939952f, -0.231058108f, - -0.970031253f, -0.242980180f, - -0.966976471f, -0.254865660f, - -0.963776066f, -0.266712757f, - -0.960430519f, -0.278519689f, - -0.956940336f, -0.290284677f, - -0.953306040f, -0.302005949f, - -0.949528181f, -0.313681740f, - -0.945607325f, -0.325310292f, - -0.941544065f, -0.336889853f, - -0.937339012f, -0.348418680f, - -0.932992799f, -0.359895037f, - -0.928506080f, -0.371317194f, - -0.923879533f, -0.382683432f, - -0.919113852f, -0.393992040f, - -0.914209756f, -0.405241314f, - -0.909167983f, -0.416429560f, - -0.903989293f, -0.427555093f, - -0.898674466f, -0.438616239f, - -0.893224301f, -0.449611330f, - -0.887639620f, -0.460538711f, - -0.881921264f, -0.471396737f, - -0.876070094f, -0.482183772f, - -0.870086991f, -0.492898192f, - -0.863972856f, -0.503538384f, - -0.857728610f, -0.514102744f, - -0.851355193f, -0.524589683f, - -0.844853565f, -0.534997620f, - -0.838224706f, -0.545324988f, - -0.831469612f, -0.555570233f, - -0.824589303f, -0.565731811f, - -0.817584813f, -0.575808191f, - -0.810457198f, -0.585797857f, - -0.803207531f, -0.595699304f, - -0.795836905f, -0.605511041f, - -0.788346428f, -0.615231591f, - -0.780737229f, -0.624859488f, - -0.773010453f, -0.634393284f, - -0.765167266f, -0.643831543f, - -0.757208847f, -0.653172843f, - -0.749136395f, -0.662415778f, - -0.740951125f, -0.671558955f, - -0.732654272f, -0.680600998f, - -0.724247083f, -0.689540545f, - -0.715730825f, -0.698376249f, - -0.707106781f, -0.707106781f, - -0.698376249f, -0.715730825f, - -0.689540545f, -0.724247083f, - -0.680600998f, -0.732654272f, - -0.671558955f, -0.740951125f, - -0.662415778f, -0.749136395f, - -0.653172843f, -0.757208847f, - -0.643831543f, -0.765167266f, - -0.634393284f, -0.773010453f, - -0.624859488f, -0.780737229f, - -0.615231591f, -0.788346428f, - -0.605511041f, -0.795836905f, - -0.595699304f, -0.803207531f, - -0.585797857f, -0.810457198f, - -0.575808191f, -0.817584813f, - -0.565731811f, -0.824589303f, - -0.555570233f, -0.831469612f, - -0.545324988f, -0.838224706f, - -0.534997620f, -0.844853565f, - -0.524589683f, -0.851355193f, - -0.514102744f, -0.857728610f, - -0.503538384f, -0.863972856f, - -0.492898192f, -0.870086991f, - -0.482183772f, -0.876070094f, - -0.471396737f, -0.881921264f, - -0.460538711f, -0.887639620f, - -0.449611330f, -0.893224301f, - -0.438616239f, -0.898674466f, - -0.427555093f, -0.903989293f, - -0.416429560f, -0.909167983f, - -0.405241314f, -0.914209756f, - -0.393992040f, -0.919113852f, - -0.382683432f, -0.923879533f, - -0.371317194f, -0.928506080f, - -0.359895037f, -0.932992799f, - -0.348418680f, -0.937339012f, - -0.336889853f, -0.941544065f, - -0.325310292f, -0.945607325f, - -0.313681740f, -0.949528181f, - -0.302005949f, -0.953306040f, - -0.290284677f, -0.956940336f, - -0.278519689f, -0.960430519f, - -0.266712757f, -0.963776066f, - -0.254865660f, -0.966976471f, - -0.242980180f, -0.970031253f, - -0.231058108f, -0.972939952f, - -0.219101240f, -0.975702130f, - -0.207111376f, -0.978317371f, - -0.195090322f, -0.980785280f, - -0.183039888f, -0.983105487f, - -0.170961889f, -0.985277642f, - -0.158858143f, -0.987301418f, - -0.146730474f, -0.989176510f, - -0.134580709f, -0.990902635f, - -0.122410675f, -0.992479535f, - -0.110222207f, -0.993906970f, - -0.098017140f, -0.995184727f, - -0.085797312f, -0.996312612f, - -0.073564564f, -0.997290457f, - -0.061320736f, -0.998118113f, - -0.049067674f, -0.998795456f, - -0.036807223f, -0.999322385f, - -0.024541229f, -0.999698819f, - -0.012271538f, -0.999924702f, - -0.000000000f, -1.000000000f, - 0.012271538f, -0.999924702f, - 0.024541229f, -0.999698819f, - 0.036807223f, -0.999322385f, - 0.049067674f, -0.998795456f, - 0.061320736f, -0.998118113f, - 0.073564564f, -0.997290457f, - 0.085797312f, -0.996312612f, - 0.098017140f, -0.995184727f, - 0.110222207f, -0.993906970f, - 0.122410675f, -0.992479535f, - 0.134580709f, -0.990902635f, - 0.146730474f, -0.989176510f, - 0.158858143f, -0.987301418f, - 0.170961889f, -0.985277642f, - 0.183039888f, -0.983105487f, - 0.195090322f, -0.980785280f, - 0.207111376f, -0.978317371f, - 0.219101240f, -0.975702130f, - 0.231058108f, -0.972939952f, - 0.242980180f, -0.970031253f, - 0.254865660f, -0.966976471f, - 0.266712757f, -0.963776066f, - 0.278519689f, -0.960430519f, - 0.290284677f, -0.956940336f, - 0.302005949f, -0.953306040f, - 0.313681740f, -0.949528181f, - 0.325310292f, -0.945607325f, - 0.336889853f, -0.941544065f, - 0.348418680f, -0.937339012f, - 0.359895037f, -0.932992799f, - 0.371317194f, -0.928506080f, - 0.382683432f, -0.923879533f, - 0.393992040f, -0.919113852f, - 0.405241314f, -0.914209756f, - 0.416429560f, -0.909167983f, - 0.427555093f, -0.903989293f, - 0.438616239f, -0.898674466f, - 0.449611330f, -0.893224301f, - 0.460538711f, -0.887639620f, - 0.471396737f, -0.881921264f, - 0.482183772f, -0.876070094f, - 0.492898192f, -0.870086991f, - 0.503538384f, -0.863972856f, - 0.514102744f, -0.857728610f, - 0.524589683f, -0.851355193f, - 0.534997620f, -0.844853565f, - 0.545324988f, -0.838224706f, - 0.555570233f, -0.831469612f, - 0.565731811f, -0.824589303f, - 0.575808191f, -0.817584813f, - 0.585797857f, -0.810457198f, - 0.595699304f, -0.803207531f, - 0.605511041f, -0.795836905f, - 0.615231591f, -0.788346428f, - 0.624859488f, -0.780737229f, - 0.634393284f, -0.773010453f, - 0.643831543f, -0.765167266f, - 0.653172843f, -0.757208847f, - 0.662415778f, -0.749136395f, - 0.671558955f, -0.740951125f, - 0.680600998f, -0.732654272f, - 0.689540545f, -0.724247083f, - 0.698376249f, -0.715730825f, - 0.707106781f, -0.707106781f, - 0.715730825f, -0.698376249f, - 0.724247083f, -0.689540545f, - 0.732654272f, -0.680600998f, - 0.740951125f, -0.671558955f, - 0.749136395f, -0.662415778f, - 0.757208847f, -0.653172843f, - 0.765167266f, -0.643831543f, - 0.773010453f, -0.634393284f, - 0.780737229f, -0.624859488f, - 0.788346428f, -0.615231591f, - 0.795836905f, -0.605511041f, - 0.803207531f, -0.595699304f, - 0.810457198f, -0.585797857f, - 0.817584813f, -0.575808191f, - 0.824589303f, -0.565731811f, - 0.831469612f, -0.555570233f, - 0.838224706f, -0.545324988f, - 0.844853565f, -0.534997620f, - 0.851355193f, -0.524589683f, - 0.857728610f, -0.514102744f, - 0.863972856f, -0.503538384f, - 0.870086991f, -0.492898192f, - 0.876070094f, -0.482183772f, - 0.881921264f, -0.471396737f, - 0.887639620f, -0.460538711f, - 0.893224301f, -0.449611330f, - 0.898674466f, -0.438616239f, - 0.903989293f, -0.427555093f, - 0.909167983f, -0.416429560f, - 0.914209756f, -0.405241314f, - 0.919113852f, -0.393992040f, - 0.923879533f, -0.382683432f, - 0.928506080f, -0.371317194f, - 0.932992799f, -0.359895037f, - 0.937339012f, -0.348418680f, - 0.941544065f, -0.336889853f, - 0.945607325f, -0.325310292f, - 0.949528181f, -0.313681740f, - 0.953306040f, -0.302005949f, - 0.956940336f, -0.290284677f, - 0.960430519f, -0.278519689f, - 0.963776066f, -0.266712757f, - 0.966976471f, -0.254865660f, - 0.970031253f, -0.242980180f, - 0.972939952f, -0.231058108f, - 0.975702130f, -0.219101240f, - 0.978317371f, -0.207111376f, - 0.980785280f, -0.195090322f, - 0.983105487f, -0.183039888f, - 0.985277642f, -0.170961889f, - 0.987301418f, -0.158858143f, - 0.989176510f, -0.146730474f, - 0.990902635f, -0.134580709f, - 0.992479535f, -0.122410675f, - 0.993906970f, -0.110222207f, - 0.995184727f, -0.098017140f, - 0.996312612f, -0.085797312f, - 0.997290457f, -0.073564564f, - 0.998118113f, -0.061320736f, - 0.998795456f, -0.049067674f, - 0.999322385f, -0.036807223f, - 0.999698819f, -0.024541229f, - 0.999924702f, -0.012271538f -}; + 1.000000000f, 0.000000000f, 0.999924702f, 0.012271538f, 0.999698819f, + 0.024541229f, 0.999322385f, 0.036807223f, 0.998795456f, 0.049067674f, + 0.998118113f, 0.061320736f, 0.997290457f, 0.073564564f, 0.996312612f, + 0.085797312f, 0.995184727f, 0.098017140f, 0.993906970f, 0.110222207f, + 0.992479535f, 0.122410675f, 0.990902635f, 0.134580709f, 0.989176510f, + 0.146730474f, 0.987301418f, 0.158858143f, 0.985277642f, 0.170961889f, + 0.983105487f, 0.183039888f, 0.980785280f, 0.195090322f, 0.978317371f, + 0.207111376f, 0.975702130f, 0.219101240f, 0.972939952f, 0.231058108f, + 0.970031253f, 0.242980180f, 0.966976471f, 0.254865660f, 0.963776066f, + 0.266712757f, 0.960430519f, 0.278519689f, 0.956940336f, 0.290284677f, + 0.953306040f, 0.302005949f, 0.949528181f, 0.313681740f, 0.945607325f, + 0.325310292f, 0.941544065f, 0.336889853f, 0.937339012f, 0.348418680f, + 0.932992799f, 0.359895037f, 0.928506080f, 0.371317194f, 0.923879533f, + 0.382683432f, 0.919113852f, 0.393992040f, 0.914209756f, 0.405241314f, + 0.909167983f, 0.416429560f, 0.903989293f, 0.427555093f, 0.898674466f, + 0.438616239f, 0.893224301f, 0.449611330f, 0.887639620f, 0.460538711f, + 0.881921264f, 0.471396737f, 0.876070094f, 0.482183772f, 0.870086991f, + 0.492898192f, 0.863972856f, 0.503538384f, 0.857728610f, 0.514102744f, + 0.851355193f, 0.524589683f, 0.844853565f, 0.534997620f, 0.838224706f, + 0.545324988f, 0.831469612f, 0.555570233f, 0.824589303f, 0.565731811f, + 0.817584813f, 0.575808191f, 0.810457198f, 0.585797857f, 0.803207531f, + 0.595699304f, 0.795836905f, 0.605511041f, 0.788346428f, 0.615231591f, + 0.780737229f, 0.624859488f, 0.773010453f, 0.634393284f, 0.765167266f, + 0.643831543f, 0.757208847f, 0.653172843f, 0.749136395f, 0.662415778f, + 0.740951125f, 0.671558955f, 0.732654272f, 0.680600998f, 0.724247083f, + 0.689540545f, 0.715730825f, 0.698376249f, 0.707106781f, 0.707106781f, + 0.698376249f, 0.715730825f, 0.689540545f, 0.724247083f, 0.680600998f, + 0.732654272f, 0.671558955f, 0.740951125f, 0.662415778f, 0.749136395f, + 0.653172843f, 0.757208847f, 0.643831543f, 0.765167266f, 0.634393284f, + 0.773010453f, 0.624859488f, 0.780737229f, 0.615231591f, 0.788346428f, + 0.605511041f, 0.795836905f, 0.595699304f, 0.803207531f, 0.585797857f, + 0.810457198f, 0.575808191f, 0.817584813f, 0.565731811f, 0.824589303f, + 0.555570233f, 0.831469612f, 0.545324988f, 0.838224706f, 0.534997620f, + 0.844853565f, 0.524589683f, 0.851355193f, 0.514102744f, 0.857728610f, + 0.503538384f, 0.863972856f, 0.492898192f, 0.870086991f, 0.482183772f, + 0.876070094f, 0.471396737f, 0.881921264f, 0.460538711f, 0.887639620f, + 0.449611330f, 0.893224301f, 0.438616239f, 0.898674466f, 0.427555093f, + 0.903989293f, 0.416429560f, 0.909167983f, 0.405241314f, 0.914209756f, + 0.393992040f, 0.919113852f, 0.382683432f, 0.923879533f, 0.371317194f, + 0.928506080f, 0.359895037f, 0.932992799f, 0.348418680f, 0.937339012f, + 0.336889853f, 0.941544065f, 0.325310292f, 0.945607325f, 0.313681740f, + 0.949528181f, 0.302005949f, 0.953306040f, 0.290284677f, 0.956940336f, + 0.278519689f, 0.960430519f, 0.266712757f, 0.963776066f, 0.254865660f, + 0.966976471f, 0.242980180f, 0.970031253f, 0.231058108f, 0.972939952f, + 0.219101240f, 0.975702130f, 0.207111376f, 0.978317371f, 0.195090322f, + 0.980785280f, 0.183039888f, 0.983105487f, 0.170961889f, 0.985277642f, + 0.158858143f, 0.987301418f, 0.146730474f, 0.989176510f, 0.134580709f, + 0.990902635f, 0.122410675f, 0.992479535f, 0.110222207f, 0.993906970f, + 0.098017140f, 0.995184727f, 0.085797312f, 0.996312612f, 0.073564564f, + 0.997290457f, 0.061320736f, 0.998118113f, 0.049067674f, 0.998795456f, + 0.036807223f, 0.999322385f, 0.024541229f, 0.999698819f, 0.012271538f, + 0.999924702f, 0.000000000f, 1.000000000f, -0.012271538f, 0.999924702f, + -0.024541229f, 0.999698819f, -0.036807223f, 0.999322385f, -0.049067674f, + 0.998795456f, -0.061320736f, 0.998118113f, -0.073564564f, 0.997290457f, + -0.085797312f, 0.996312612f, -0.098017140f, 0.995184727f, -0.110222207f, + 0.993906970f, -0.122410675f, 0.992479535f, -0.134580709f, 0.990902635f, + -0.146730474f, 0.989176510f, -0.158858143f, 0.987301418f, -0.170961889f, + 0.985277642f, -0.183039888f, 0.983105487f, -0.195090322f, 0.980785280f, + -0.207111376f, 0.978317371f, -0.219101240f, 0.975702130f, -0.231058108f, + 0.972939952f, -0.242980180f, 0.970031253f, -0.254865660f, 0.966976471f, + -0.266712757f, 0.963776066f, -0.278519689f, 0.960430519f, -0.290284677f, + 0.956940336f, -0.302005949f, 0.953306040f, -0.313681740f, 0.949528181f, + -0.325310292f, 0.945607325f, -0.336889853f, 0.941544065f, -0.348418680f, + 0.937339012f, -0.359895037f, 0.932992799f, -0.371317194f, 0.928506080f, + -0.382683432f, 0.923879533f, -0.393992040f, 0.919113852f, -0.405241314f, + 0.914209756f, -0.416429560f, 0.909167983f, -0.427555093f, 0.903989293f, + -0.438616239f, 0.898674466f, -0.449611330f, 0.893224301f, -0.460538711f, + 0.887639620f, -0.471396737f, 0.881921264f, -0.482183772f, 0.876070094f, + -0.492898192f, 0.870086991f, -0.503538384f, 0.863972856f, -0.514102744f, + 0.857728610f, -0.524589683f, 0.851355193f, -0.534997620f, 0.844853565f, + -0.545324988f, 0.838224706f, -0.555570233f, 0.831469612f, -0.565731811f, + 0.824589303f, -0.575808191f, 0.817584813f, -0.585797857f, 0.810457198f, + -0.595699304f, 0.803207531f, -0.605511041f, 0.795836905f, -0.615231591f, + 0.788346428f, -0.624859488f, 0.780737229f, -0.634393284f, 0.773010453f, + -0.643831543f, 0.765167266f, -0.653172843f, 0.757208847f, -0.662415778f, + 0.749136395f, -0.671558955f, 0.740951125f, -0.680600998f, 0.732654272f, + -0.689540545f, 0.724247083f, -0.698376249f, 0.715730825f, -0.707106781f, + 0.707106781f, -0.715730825f, 0.698376249f, -0.724247083f, 0.689540545f, + -0.732654272f, 0.680600998f, -0.740951125f, 0.671558955f, -0.749136395f, + 0.662415778f, -0.757208847f, 0.653172843f, -0.765167266f, 0.643831543f, + -0.773010453f, 0.634393284f, -0.780737229f, 0.624859488f, -0.788346428f, + 0.615231591f, -0.795836905f, 0.605511041f, -0.803207531f, 0.595699304f, + -0.810457198f, 0.585797857f, -0.817584813f, 0.575808191f, -0.824589303f, + 0.565731811f, -0.831469612f, 0.555570233f, -0.838224706f, 0.545324988f, + -0.844853565f, 0.534997620f, -0.851355193f, 0.524589683f, -0.857728610f, + 0.514102744f, -0.863972856f, 0.503538384f, -0.870086991f, 0.492898192f, + -0.876070094f, 0.482183772f, -0.881921264f, 0.471396737f, -0.887639620f, + 0.460538711f, -0.893224301f, 0.449611330f, -0.898674466f, 0.438616239f, + -0.903989293f, 0.427555093f, -0.909167983f, 0.416429560f, -0.914209756f, + 0.405241314f, -0.919113852f, 0.393992040f, -0.923879533f, 0.382683432f, + -0.928506080f, 0.371317194f, -0.932992799f, 0.359895037f, -0.937339012f, + 0.348418680f, -0.941544065f, 0.336889853f, -0.945607325f, 0.325310292f, + -0.949528181f, 0.313681740f, -0.953306040f, 0.302005949f, -0.956940336f, + 0.290284677f, -0.960430519f, 0.278519689f, -0.963776066f, 0.266712757f, + -0.966976471f, 0.254865660f, -0.970031253f, 0.242980180f, -0.972939952f, + 0.231058108f, -0.975702130f, 0.219101240f, -0.978317371f, 0.207111376f, + -0.980785280f, 0.195090322f, -0.983105487f, 0.183039888f, -0.985277642f, + 0.170961889f, -0.987301418f, 0.158858143f, -0.989176510f, 0.146730474f, + -0.990902635f, 0.134580709f, -0.992479535f, 0.122410675f, -0.993906970f, + 0.110222207f, -0.995184727f, 0.098017140f, -0.996312612f, 0.085797312f, + -0.997290457f, 0.073564564f, -0.998118113f, 0.061320736f, -0.998795456f, + 0.049067674f, -0.999322385f, 0.036807223f, -0.999698819f, 0.024541229f, + -0.999924702f, 0.012271538f, -1.000000000f, 0.000000000f, -0.999924702f, + -0.012271538f, -0.999698819f, -0.024541229f, -0.999322385f, -0.036807223f, + -0.998795456f, -0.049067674f, -0.998118113f, -0.061320736f, -0.997290457f, + -0.073564564f, -0.996312612f, -0.085797312f, -0.995184727f, -0.098017140f, + -0.993906970f, -0.110222207f, -0.992479535f, -0.122410675f, -0.990902635f, + -0.134580709f, -0.989176510f, -0.146730474f, -0.987301418f, -0.158858143f, + -0.985277642f, -0.170961889f, -0.983105487f, -0.183039888f, -0.980785280f, + -0.195090322f, -0.978317371f, -0.207111376f, -0.975702130f, -0.219101240f, + -0.972939952f, -0.231058108f, -0.970031253f, -0.242980180f, -0.966976471f, + -0.254865660f, -0.963776066f, -0.266712757f, -0.960430519f, -0.278519689f, + -0.956940336f, -0.290284677f, -0.953306040f, -0.302005949f, -0.949528181f, + -0.313681740f, -0.945607325f, -0.325310292f, -0.941544065f, -0.336889853f, + -0.937339012f, -0.348418680f, -0.932992799f, -0.359895037f, -0.928506080f, + -0.371317194f, -0.923879533f, -0.382683432f, -0.919113852f, -0.393992040f, + -0.914209756f, -0.405241314f, -0.909167983f, -0.416429560f, -0.903989293f, + -0.427555093f, -0.898674466f, -0.438616239f, -0.893224301f, -0.449611330f, + -0.887639620f, -0.460538711f, -0.881921264f, -0.471396737f, -0.876070094f, + -0.482183772f, -0.870086991f, -0.492898192f, -0.863972856f, -0.503538384f, + -0.857728610f, -0.514102744f, -0.851355193f, -0.524589683f, -0.844853565f, + -0.534997620f, -0.838224706f, -0.545324988f, -0.831469612f, -0.555570233f, + -0.824589303f, -0.565731811f, -0.817584813f, -0.575808191f, -0.810457198f, + -0.585797857f, -0.803207531f, -0.595699304f, -0.795836905f, -0.605511041f, + -0.788346428f, -0.615231591f, -0.780737229f, -0.624859488f, -0.773010453f, + -0.634393284f, -0.765167266f, -0.643831543f, -0.757208847f, -0.653172843f, + -0.749136395f, -0.662415778f, -0.740951125f, -0.671558955f, -0.732654272f, + -0.680600998f, -0.724247083f, -0.689540545f, -0.715730825f, -0.698376249f, + -0.707106781f, -0.707106781f, -0.698376249f, -0.715730825f, -0.689540545f, + -0.724247083f, -0.680600998f, -0.732654272f, -0.671558955f, -0.740951125f, + -0.662415778f, -0.749136395f, -0.653172843f, -0.757208847f, -0.643831543f, + -0.765167266f, -0.634393284f, -0.773010453f, -0.624859488f, -0.780737229f, + -0.615231591f, -0.788346428f, -0.605511041f, -0.795836905f, -0.595699304f, + -0.803207531f, -0.585797857f, -0.810457198f, -0.575808191f, -0.817584813f, + -0.565731811f, -0.824589303f, -0.555570233f, -0.831469612f, -0.545324988f, + -0.838224706f, -0.534997620f, -0.844853565f, -0.524589683f, -0.851355193f, + -0.514102744f, -0.857728610f, -0.503538384f, -0.863972856f, -0.492898192f, + -0.870086991f, -0.482183772f, -0.876070094f, -0.471396737f, -0.881921264f, + -0.460538711f, -0.887639620f, -0.449611330f, -0.893224301f, -0.438616239f, + -0.898674466f, -0.427555093f, -0.903989293f, -0.416429560f, -0.909167983f, + -0.405241314f, -0.914209756f, -0.393992040f, -0.919113852f, -0.382683432f, + -0.923879533f, -0.371317194f, -0.928506080f, -0.359895037f, -0.932992799f, + -0.348418680f, -0.937339012f, -0.336889853f, -0.941544065f, -0.325310292f, + -0.945607325f, -0.313681740f, -0.949528181f, -0.302005949f, -0.953306040f, + -0.290284677f, -0.956940336f, -0.278519689f, -0.960430519f, -0.266712757f, + -0.963776066f, -0.254865660f, -0.966976471f, -0.242980180f, -0.970031253f, + -0.231058108f, -0.972939952f, -0.219101240f, -0.975702130f, -0.207111376f, + -0.978317371f, -0.195090322f, -0.980785280f, -0.183039888f, -0.983105487f, + -0.170961889f, -0.985277642f, -0.158858143f, -0.987301418f, -0.146730474f, + -0.989176510f, -0.134580709f, -0.990902635f, -0.122410675f, -0.992479535f, + -0.110222207f, -0.993906970f, -0.098017140f, -0.995184727f, -0.085797312f, + -0.996312612f, -0.073564564f, -0.997290457f, -0.061320736f, -0.998118113f, + -0.049067674f, -0.998795456f, -0.036807223f, -0.999322385f, -0.024541229f, + -0.999698819f, -0.012271538f, -0.999924702f, -0.000000000f, -1.000000000f, + 0.012271538f, -0.999924702f, 0.024541229f, -0.999698819f, 0.036807223f, + -0.999322385f, 0.049067674f, -0.998795456f, 0.061320736f, -0.998118113f, + 0.073564564f, -0.997290457f, 0.085797312f, -0.996312612f, 0.098017140f, + -0.995184727f, 0.110222207f, -0.993906970f, 0.122410675f, -0.992479535f, + 0.134580709f, -0.990902635f, 0.146730474f, -0.989176510f, 0.158858143f, + -0.987301418f, 0.170961889f, -0.985277642f, 0.183039888f, -0.983105487f, + 0.195090322f, -0.980785280f, 0.207111376f, -0.978317371f, 0.219101240f, + -0.975702130f, 0.231058108f, -0.972939952f, 0.242980180f, -0.970031253f, + 0.254865660f, -0.966976471f, 0.266712757f, -0.963776066f, 0.278519689f, + -0.960430519f, 0.290284677f, -0.956940336f, 0.302005949f, -0.953306040f, + 0.313681740f, -0.949528181f, 0.325310292f, -0.945607325f, 0.336889853f, + -0.941544065f, 0.348418680f, -0.937339012f, 0.359895037f, -0.932992799f, + 0.371317194f, -0.928506080f, 0.382683432f, -0.923879533f, 0.393992040f, + -0.919113852f, 0.405241314f, -0.914209756f, 0.416429560f, -0.909167983f, + 0.427555093f, -0.903989293f, 0.438616239f, -0.898674466f, 0.449611330f, + -0.893224301f, 0.460538711f, -0.887639620f, 0.471396737f, -0.881921264f, + 0.482183772f, -0.876070094f, 0.492898192f, -0.870086991f, 0.503538384f, + -0.863972856f, 0.514102744f, -0.857728610f, 0.524589683f, -0.851355193f, + 0.534997620f, -0.844853565f, 0.545324988f, -0.838224706f, 0.555570233f, + -0.831469612f, 0.565731811f, -0.824589303f, 0.575808191f, -0.817584813f, + 0.585797857f, -0.810457198f, 0.595699304f, -0.803207531f, 0.605511041f, + -0.795836905f, 0.615231591f, -0.788346428f, 0.624859488f, -0.780737229f, + 0.634393284f, -0.773010453f, 0.643831543f, -0.765167266f, 0.653172843f, + -0.757208847f, 0.662415778f, -0.749136395f, 0.671558955f, -0.740951125f, + 0.680600998f, -0.732654272f, 0.689540545f, -0.724247083f, 0.698376249f, + -0.715730825f, 0.707106781f, -0.707106781f, 0.715730825f, -0.698376249f, + 0.724247083f, -0.689540545f, 0.732654272f, -0.680600998f, 0.740951125f, + -0.671558955f, 0.749136395f, -0.662415778f, 0.757208847f, -0.653172843f, + 0.765167266f, -0.643831543f, 0.773010453f, -0.634393284f, 0.780737229f, + -0.624859488f, 0.788346428f, -0.615231591f, 0.795836905f, -0.605511041f, + 0.803207531f, -0.595699304f, 0.810457198f, -0.585797857f, 0.817584813f, + -0.575808191f, 0.824589303f, -0.565731811f, 0.831469612f, -0.555570233f, + 0.838224706f, -0.545324988f, 0.844853565f, -0.534997620f, 0.851355193f, + -0.524589683f, 0.857728610f, -0.514102744f, 0.863972856f, -0.503538384f, + 0.870086991f, -0.492898192f, 0.876070094f, -0.482183772f, 0.881921264f, + -0.471396737f, 0.887639620f, -0.460538711f, 0.893224301f, -0.449611330f, + 0.898674466f, -0.438616239f, 0.903989293f, -0.427555093f, 0.909167983f, + -0.416429560f, 0.914209756f, -0.405241314f, 0.919113852f, -0.393992040f, + 0.923879533f, -0.382683432f, 0.928506080f, -0.371317194f, 0.932992799f, + -0.359895037f, 0.937339012f, -0.348418680f, 0.941544065f, -0.336889853f, + 0.945607325f, -0.325310292f, 0.949528181f, -0.313681740f, 0.953306040f, + -0.302005949f, 0.956940336f, -0.290284677f, 0.960430519f, -0.278519689f, + 0.963776066f, -0.266712757f, 0.966976471f, -0.254865660f, 0.970031253f, + -0.242980180f, 0.972939952f, -0.231058108f, 0.975702130f, -0.219101240f, + 0.978317371f, -0.207111376f, 0.980785280f, -0.195090322f, 0.983105487f, + -0.183039888f, 0.985277642f, -0.170961889f, 0.987301418f, -0.158858143f, + 0.989176510f, -0.146730474f, 0.990902635f, -0.134580709f, 0.992479535f, + -0.122410675f, 0.993906970f, -0.110222207f, 0.995184727f, -0.098017140f, + 0.996312612f, -0.085797312f, 0.997290457f, -0.073564564f, 0.998118113f, + -0.061320736f, 0.998795456f, -0.049067674f, 0.999322385f, -0.036807223f, + 0.999698819f, -0.024541229f, 0.999924702f, -0.012271538f}; /** @par Example code for Floating-point Twiddle factors Generation: @par
for (i = 0; i< N/; i++)
   {
- 	twiddleCoef[2*i]   = cos(i * 2*PI/(float)N);
- 	twiddleCoef[2*i+1] = sin(i * 2*PI/(float)N);
+        twiddleCoef[2*i]   = cos(i * 2*PI/(float)N);
+        twiddleCoef[2*i+1] = sin(i * 2*PI/(float)N);
   } 
@par where N = 1024, PI = 3.14159265358979 @@ -1299,1031 +681,416 @@ const float32_t twiddleCoef_512[1024] = { Cos and Sin values are in interleaved fashion */ const float32_t twiddleCoef_1024[2048] = { - 1.000000000f, 0.000000000f, - 0.999981175f, 0.006135885f, - 0.999924702f, 0.012271538f, - 0.999830582f, 0.018406730f, - 0.999698819f, 0.024541229f, - 0.999529418f, 0.030674803f, - 0.999322385f, 0.036807223f, - 0.999077728f, 0.042938257f, - 0.998795456f, 0.049067674f, - 0.998475581f, 0.055195244f, - 0.998118113f, 0.061320736f, - 0.997723067f, 0.067443920f, - 0.997290457f, 0.073564564f, - 0.996820299f, 0.079682438f, - 0.996312612f, 0.085797312f, - 0.995767414f, 0.091908956f, - 0.995184727f, 0.098017140f, - 0.994564571f, 0.104121634f, - 0.993906970f, 0.110222207f, - 0.993211949f, 0.116318631f, - 0.992479535f, 0.122410675f, - 0.991709754f, 0.128498111f, - 0.990902635f, 0.134580709f, - 0.990058210f, 0.140658239f, - 0.989176510f, 0.146730474f, - 0.988257568f, 0.152797185f, - 0.987301418f, 0.158858143f, - 0.986308097f, 0.164913120f, - 0.985277642f, 0.170961889f, - 0.984210092f, 0.177004220f, - 0.983105487f, 0.183039888f, - 0.981963869f, 0.189068664f, - 0.980785280f, 0.195090322f, - 0.979569766f, 0.201104635f, - 0.978317371f, 0.207111376f, - 0.977028143f, 0.213110320f, - 0.975702130f, 0.219101240f, - 0.974339383f, 0.225083911f, - 0.972939952f, 0.231058108f, - 0.971503891f, 0.237023606f, - 0.970031253f, 0.242980180f, - 0.968522094f, 0.248927606f, - 0.966976471f, 0.254865660f, - 0.965394442f, 0.260794118f, - 0.963776066f, 0.266712757f, - 0.962121404f, 0.272621355f, - 0.960430519f, 0.278519689f, - 0.958703475f, 0.284407537f, - 0.956940336f, 0.290284677f, - 0.955141168f, 0.296150888f, - 0.953306040f, 0.302005949f, - 0.951435021f, 0.307849640f, - 0.949528181f, 0.313681740f, - 0.947585591f, 0.319502031f, - 0.945607325f, 0.325310292f, - 0.943593458f, 0.331106306f, - 0.941544065f, 0.336889853f, - 0.939459224f, 0.342660717f, - 0.937339012f, 0.348418680f, - 0.935183510f, 0.354163525f, - 0.932992799f, 0.359895037f, - 0.930766961f, 0.365612998f, - 0.928506080f, 0.371317194f, - 0.926210242f, 0.377007410f, - 0.923879533f, 0.382683432f, - 0.921514039f, 0.388345047f, - 0.919113852f, 0.393992040f, - 0.916679060f, 0.399624200f, - 0.914209756f, 0.405241314f, - 0.911706032f, 0.410843171f, - 0.909167983f, 0.416429560f, - 0.906595705f, 0.422000271f, - 0.903989293f, 0.427555093f, - 0.901348847f, 0.433093819f, - 0.898674466f, 0.438616239f, - 0.895966250f, 0.444122145f, - 0.893224301f, 0.449611330f, - 0.890448723f, 0.455083587f, - 0.887639620f, 0.460538711f, - 0.884797098f, 0.465976496f, - 0.881921264f, 0.471396737f, - 0.879012226f, 0.476799230f, - 0.876070094f, 0.482183772f, - 0.873094978f, 0.487550160f, - 0.870086991f, 0.492898192f, - 0.867046246f, 0.498227667f, - 0.863972856f, 0.503538384f, - 0.860866939f, 0.508830143f, - 0.857728610f, 0.514102744f, - 0.854557988f, 0.519355990f, - 0.851355193f, 0.524589683f, - 0.848120345f, 0.529803625f, - 0.844853565f, 0.534997620f, - 0.841554977f, 0.540171473f, - 0.838224706f, 0.545324988f, - 0.834862875f, 0.550457973f, - 0.831469612f, 0.555570233f, - 0.828045045f, 0.560661576f, - 0.824589303f, 0.565731811f, - 0.821102515f, 0.570780746f, - 0.817584813f, 0.575808191f, - 0.814036330f, 0.580813958f, - 0.810457198f, 0.585797857f, - 0.806847554f, 0.590759702f, - 0.803207531f, 0.595699304f, - 0.799537269f, 0.600616479f, - 0.795836905f, 0.605511041f, - 0.792106577f, 0.610382806f, - 0.788346428f, 0.615231591f, - 0.784556597f, 0.620057212f, - 0.780737229f, 0.624859488f, - 0.776888466f, 0.629638239f, - 0.773010453f, 0.634393284f, - 0.769103338f, 0.639124445f, - 0.765167266f, 0.643831543f, - 0.761202385f, 0.648514401f, - 0.757208847f, 0.653172843f, - 0.753186799f, 0.657806693f, - 0.749136395f, 0.662415778f, - 0.745057785f, 0.666999922f, - 0.740951125f, 0.671558955f, - 0.736816569f, 0.676092704f, - 0.732654272f, 0.680600998f, - 0.728464390f, 0.685083668f, - 0.724247083f, 0.689540545f, - 0.720002508f, 0.693971461f, - 0.715730825f, 0.698376249f, - 0.711432196f, 0.702754744f, - 0.707106781f, 0.707106781f, - 0.702754744f, 0.711432196f, - 0.698376249f, 0.715730825f, - 0.693971461f, 0.720002508f, - 0.689540545f, 0.724247083f, - 0.685083668f, 0.728464390f, - 0.680600998f, 0.732654272f, - 0.676092704f, 0.736816569f, - 0.671558955f, 0.740951125f, - 0.666999922f, 0.745057785f, - 0.662415778f, 0.749136395f, - 0.657806693f, 0.753186799f, - 0.653172843f, 0.757208847f, - 0.648514401f, 0.761202385f, - 0.643831543f, 0.765167266f, - 0.639124445f, 0.769103338f, - 0.634393284f, 0.773010453f, - 0.629638239f, 0.776888466f, - 0.624859488f, 0.780737229f, - 0.620057212f, 0.784556597f, - 0.615231591f, 0.788346428f, - 0.610382806f, 0.792106577f, - 0.605511041f, 0.795836905f, - 0.600616479f, 0.799537269f, - 0.595699304f, 0.803207531f, - 0.590759702f, 0.806847554f, - 0.585797857f, 0.810457198f, - 0.580813958f, 0.814036330f, - 0.575808191f, 0.817584813f, - 0.570780746f, 0.821102515f, - 0.565731811f, 0.824589303f, - 0.560661576f, 0.828045045f, - 0.555570233f, 0.831469612f, - 0.550457973f, 0.834862875f, - 0.545324988f, 0.838224706f, - 0.540171473f, 0.841554977f, - 0.534997620f, 0.844853565f, - 0.529803625f, 0.848120345f, - 0.524589683f, 0.851355193f, - 0.519355990f, 0.854557988f, - 0.514102744f, 0.857728610f, - 0.508830143f, 0.860866939f, - 0.503538384f, 0.863972856f, - 0.498227667f, 0.867046246f, - 0.492898192f, 0.870086991f, - 0.487550160f, 0.873094978f, - 0.482183772f, 0.876070094f, - 0.476799230f, 0.879012226f, - 0.471396737f, 0.881921264f, - 0.465976496f, 0.884797098f, - 0.460538711f, 0.887639620f, - 0.455083587f, 0.890448723f, - 0.449611330f, 0.893224301f, - 0.444122145f, 0.895966250f, - 0.438616239f, 0.898674466f, - 0.433093819f, 0.901348847f, - 0.427555093f, 0.903989293f, - 0.422000271f, 0.906595705f, - 0.416429560f, 0.909167983f, - 0.410843171f, 0.911706032f, - 0.405241314f, 0.914209756f, - 0.399624200f, 0.916679060f, - 0.393992040f, 0.919113852f, - 0.388345047f, 0.921514039f, - 0.382683432f, 0.923879533f, - 0.377007410f, 0.926210242f, - 0.371317194f, 0.928506080f, - 0.365612998f, 0.930766961f, - 0.359895037f, 0.932992799f, - 0.354163525f, 0.935183510f, - 0.348418680f, 0.937339012f, - 0.342660717f, 0.939459224f, - 0.336889853f, 0.941544065f, - 0.331106306f, 0.943593458f, - 0.325310292f, 0.945607325f, - 0.319502031f, 0.947585591f, - 0.313681740f, 0.949528181f, - 0.307849640f, 0.951435021f, - 0.302005949f, 0.953306040f, - 0.296150888f, 0.955141168f, - 0.290284677f, 0.956940336f, - 0.284407537f, 0.958703475f, - 0.278519689f, 0.960430519f, - 0.272621355f, 0.962121404f, - 0.266712757f, 0.963776066f, - 0.260794118f, 0.965394442f, - 0.254865660f, 0.966976471f, - 0.248927606f, 0.968522094f, - 0.242980180f, 0.970031253f, - 0.237023606f, 0.971503891f, - 0.231058108f, 0.972939952f, - 0.225083911f, 0.974339383f, - 0.219101240f, 0.975702130f, - 0.213110320f, 0.977028143f, - 0.207111376f, 0.978317371f, - 0.201104635f, 0.979569766f, - 0.195090322f, 0.980785280f, - 0.189068664f, 0.981963869f, - 0.183039888f, 0.983105487f, - 0.177004220f, 0.984210092f, - 0.170961889f, 0.985277642f, - 0.164913120f, 0.986308097f, - 0.158858143f, 0.987301418f, - 0.152797185f, 0.988257568f, - 0.146730474f, 0.989176510f, - 0.140658239f, 0.990058210f, - 0.134580709f, 0.990902635f, - 0.128498111f, 0.991709754f, - 0.122410675f, 0.992479535f, - 0.116318631f, 0.993211949f, - 0.110222207f, 0.993906970f, - 0.104121634f, 0.994564571f, - 0.098017140f, 0.995184727f, - 0.091908956f, 0.995767414f, - 0.085797312f, 0.996312612f, - 0.079682438f, 0.996820299f, - 0.073564564f, 0.997290457f, - 0.067443920f, 0.997723067f, - 0.061320736f, 0.998118113f, - 0.055195244f, 0.998475581f, - 0.049067674f, 0.998795456f, - 0.042938257f, 0.999077728f, - 0.036807223f, 0.999322385f, - 0.030674803f, 0.999529418f, - 0.024541229f, 0.999698819f, - 0.018406730f, 0.999830582f, - 0.012271538f, 0.999924702f, - 0.006135885f, 0.999981175f, - 0.000000000f, 1.000000000f, - -0.006135885f, 0.999981175f, - -0.012271538f, 0.999924702f, - -0.018406730f, 0.999830582f, - -0.024541229f, 0.999698819f, - -0.030674803f, 0.999529418f, - -0.036807223f, 0.999322385f, - -0.042938257f, 0.999077728f, - -0.049067674f, 0.998795456f, - -0.055195244f, 0.998475581f, - -0.061320736f, 0.998118113f, - -0.067443920f, 0.997723067f, - -0.073564564f, 0.997290457f, - -0.079682438f, 0.996820299f, - -0.085797312f, 0.996312612f, - -0.091908956f, 0.995767414f, - -0.098017140f, 0.995184727f, - -0.104121634f, 0.994564571f, - -0.110222207f, 0.993906970f, - -0.116318631f, 0.993211949f, - -0.122410675f, 0.992479535f, - -0.128498111f, 0.991709754f, - -0.134580709f, 0.990902635f, - -0.140658239f, 0.990058210f, - -0.146730474f, 0.989176510f, - -0.152797185f, 0.988257568f, - -0.158858143f, 0.987301418f, - -0.164913120f, 0.986308097f, - -0.170961889f, 0.985277642f, - -0.177004220f, 0.984210092f, - -0.183039888f, 0.983105487f, - -0.189068664f, 0.981963869f, - -0.195090322f, 0.980785280f, - -0.201104635f, 0.979569766f, - -0.207111376f, 0.978317371f, - -0.213110320f, 0.977028143f, - -0.219101240f, 0.975702130f, - -0.225083911f, 0.974339383f, - -0.231058108f, 0.972939952f, - -0.237023606f, 0.971503891f, - -0.242980180f, 0.970031253f, - -0.248927606f, 0.968522094f, - -0.254865660f, 0.966976471f, - -0.260794118f, 0.965394442f, - -0.266712757f, 0.963776066f, - -0.272621355f, 0.962121404f, - -0.278519689f, 0.960430519f, - -0.284407537f, 0.958703475f, - -0.290284677f, 0.956940336f, - -0.296150888f, 0.955141168f, - -0.302005949f, 0.953306040f, - -0.307849640f, 0.951435021f, - -0.313681740f, 0.949528181f, - -0.319502031f, 0.947585591f, - -0.325310292f, 0.945607325f, - -0.331106306f, 0.943593458f, - -0.336889853f, 0.941544065f, - -0.342660717f, 0.939459224f, - -0.348418680f, 0.937339012f, - -0.354163525f, 0.935183510f, - -0.359895037f, 0.932992799f, - -0.365612998f, 0.930766961f, - -0.371317194f, 0.928506080f, - -0.377007410f, 0.926210242f, - -0.382683432f, 0.923879533f, - -0.388345047f, 0.921514039f, - -0.393992040f, 0.919113852f, - -0.399624200f, 0.916679060f, - -0.405241314f, 0.914209756f, - -0.410843171f, 0.911706032f, - -0.416429560f, 0.909167983f, - -0.422000271f, 0.906595705f, - -0.427555093f, 0.903989293f, - -0.433093819f, 0.901348847f, - -0.438616239f, 0.898674466f, - -0.444122145f, 0.895966250f, - -0.449611330f, 0.893224301f, - -0.455083587f, 0.890448723f, - -0.460538711f, 0.887639620f, - -0.465976496f, 0.884797098f, - -0.471396737f, 0.881921264f, - -0.476799230f, 0.879012226f, - -0.482183772f, 0.876070094f, - -0.487550160f, 0.873094978f, - -0.492898192f, 0.870086991f, - -0.498227667f, 0.867046246f, - -0.503538384f, 0.863972856f, - -0.508830143f, 0.860866939f, - -0.514102744f, 0.857728610f, - -0.519355990f, 0.854557988f, - -0.524589683f, 0.851355193f, - -0.529803625f, 0.848120345f, - -0.534997620f, 0.844853565f, - -0.540171473f, 0.841554977f, - -0.545324988f, 0.838224706f, - -0.550457973f, 0.834862875f, - -0.555570233f, 0.831469612f, - -0.560661576f, 0.828045045f, - -0.565731811f, 0.824589303f, - -0.570780746f, 0.821102515f, - -0.575808191f, 0.817584813f, - -0.580813958f, 0.814036330f, - -0.585797857f, 0.810457198f, - -0.590759702f, 0.806847554f, - -0.595699304f, 0.803207531f, - -0.600616479f, 0.799537269f, - -0.605511041f, 0.795836905f, - -0.610382806f, 0.792106577f, - -0.615231591f, 0.788346428f, - -0.620057212f, 0.784556597f, - -0.624859488f, 0.780737229f, - -0.629638239f, 0.776888466f, - -0.634393284f, 0.773010453f, - -0.639124445f, 0.769103338f, - -0.643831543f, 0.765167266f, - -0.648514401f, 0.761202385f, - -0.653172843f, 0.757208847f, - -0.657806693f, 0.753186799f, - -0.662415778f, 0.749136395f, - -0.666999922f, 0.745057785f, - -0.671558955f, 0.740951125f, - -0.676092704f, 0.736816569f, - -0.680600998f, 0.732654272f, - -0.685083668f, 0.728464390f, - -0.689540545f, 0.724247083f, - -0.693971461f, 0.720002508f, - -0.698376249f, 0.715730825f, - -0.702754744f, 0.711432196f, - -0.707106781f, 0.707106781f, - -0.711432196f, 0.702754744f, - -0.715730825f, 0.698376249f, - -0.720002508f, 0.693971461f, - -0.724247083f, 0.689540545f, - -0.728464390f, 0.685083668f, - -0.732654272f, 0.680600998f, - -0.736816569f, 0.676092704f, - -0.740951125f, 0.671558955f, - -0.745057785f, 0.666999922f, - -0.749136395f, 0.662415778f, - -0.753186799f, 0.657806693f, - -0.757208847f, 0.653172843f, - -0.761202385f, 0.648514401f, - -0.765167266f, 0.643831543f, - -0.769103338f, 0.639124445f, - -0.773010453f, 0.634393284f, - -0.776888466f, 0.629638239f, - -0.780737229f, 0.624859488f, - -0.784556597f, 0.620057212f, - -0.788346428f, 0.615231591f, - -0.792106577f, 0.610382806f, - -0.795836905f, 0.605511041f, - -0.799537269f, 0.600616479f, - -0.803207531f, 0.595699304f, - -0.806847554f, 0.590759702f, - -0.810457198f, 0.585797857f, - -0.814036330f, 0.580813958f, - -0.817584813f, 0.575808191f, - -0.821102515f, 0.570780746f, - -0.824589303f, 0.565731811f, - -0.828045045f, 0.560661576f, - -0.831469612f, 0.555570233f, - -0.834862875f, 0.550457973f, - -0.838224706f, 0.545324988f, - -0.841554977f, 0.540171473f, - -0.844853565f, 0.534997620f, - -0.848120345f, 0.529803625f, - -0.851355193f, 0.524589683f, - -0.854557988f, 0.519355990f, - -0.857728610f, 0.514102744f, - -0.860866939f, 0.508830143f, - -0.863972856f, 0.503538384f, - -0.867046246f, 0.498227667f, - -0.870086991f, 0.492898192f, - -0.873094978f, 0.487550160f, - -0.876070094f, 0.482183772f, - -0.879012226f, 0.476799230f, - -0.881921264f, 0.471396737f, - -0.884797098f, 0.465976496f, - -0.887639620f, 0.460538711f, - -0.890448723f, 0.455083587f, - -0.893224301f, 0.449611330f, - -0.895966250f, 0.444122145f, - -0.898674466f, 0.438616239f, - -0.901348847f, 0.433093819f, - -0.903989293f, 0.427555093f, - -0.906595705f, 0.422000271f, - -0.909167983f, 0.416429560f, - -0.911706032f, 0.410843171f, - -0.914209756f, 0.405241314f, - -0.916679060f, 0.399624200f, - -0.919113852f, 0.393992040f, - -0.921514039f, 0.388345047f, - -0.923879533f, 0.382683432f, - -0.926210242f, 0.377007410f, - -0.928506080f, 0.371317194f, - -0.930766961f, 0.365612998f, - -0.932992799f, 0.359895037f, - -0.935183510f, 0.354163525f, - -0.937339012f, 0.348418680f, - -0.939459224f, 0.342660717f, - -0.941544065f, 0.336889853f, - -0.943593458f, 0.331106306f, - -0.945607325f, 0.325310292f, - -0.947585591f, 0.319502031f, - -0.949528181f, 0.313681740f, - -0.951435021f, 0.307849640f, - -0.953306040f, 0.302005949f, - -0.955141168f, 0.296150888f, - -0.956940336f, 0.290284677f, - -0.958703475f, 0.284407537f, - -0.960430519f, 0.278519689f, - -0.962121404f, 0.272621355f, - -0.963776066f, 0.266712757f, - -0.965394442f, 0.260794118f, - -0.966976471f, 0.254865660f, - -0.968522094f, 0.248927606f, - -0.970031253f, 0.242980180f, - -0.971503891f, 0.237023606f, - -0.972939952f, 0.231058108f, - -0.974339383f, 0.225083911f, - -0.975702130f, 0.219101240f, - -0.977028143f, 0.213110320f, - -0.978317371f, 0.207111376f, - -0.979569766f, 0.201104635f, - -0.980785280f, 0.195090322f, - -0.981963869f, 0.189068664f, - -0.983105487f, 0.183039888f, - -0.984210092f, 0.177004220f, - -0.985277642f, 0.170961889f, - -0.986308097f, 0.164913120f, - -0.987301418f, 0.158858143f, - -0.988257568f, 0.152797185f, - -0.989176510f, 0.146730474f, - -0.990058210f, 0.140658239f, - -0.990902635f, 0.134580709f, - -0.991709754f, 0.128498111f, - -0.992479535f, 0.122410675f, - -0.993211949f, 0.116318631f, - -0.993906970f, 0.110222207f, - -0.994564571f, 0.104121634f, - -0.995184727f, 0.098017140f, - -0.995767414f, 0.091908956f, - -0.996312612f, 0.085797312f, - -0.996820299f, 0.079682438f, - -0.997290457f, 0.073564564f, - -0.997723067f, 0.067443920f, - -0.998118113f, 0.061320736f, - -0.998475581f, 0.055195244f, - -0.998795456f, 0.049067674f, - -0.999077728f, 0.042938257f, - -0.999322385f, 0.036807223f, - -0.999529418f, 0.030674803f, - -0.999698819f, 0.024541229f, - -0.999830582f, 0.018406730f, - -0.999924702f, 0.012271538f, - -0.999981175f, 0.006135885f, - -1.000000000f, 0.000000000f, - -0.999981175f, -0.006135885f, - -0.999924702f, -0.012271538f, - -0.999830582f, -0.018406730f, - -0.999698819f, -0.024541229f, - -0.999529418f, -0.030674803f, - -0.999322385f, -0.036807223f, - -0.999077728f, -0.042938257f, - -0.998795456f, -0.049067674f, - -0.998475581f, -0.055195244f, - -0.998118113f, -0.061320736f, - -0.997723067f, -0.067443920f, - -0.997290457f, -0.073564564f, - -0.996820299f, -0.079682438f, - -0.996312612f, -0.085797312f, - -0.995767414f, -0.091908956f, - -0.995184727f, -0.098017140f, - -0.994564571f, -0.104121634f, - -0.993906970f, -0.110222207f, - -0.993211949f, -0.116318631f, - -0.992479535f, -0.122410675f, - -0.991709754f, -0.128498111f, - -0.990902635f, -0.134580709f, - -0.990058210f, -0.140658239f, - -0.989176510f, -0.146730474f, - -0.988257568f, -0.152797185f, - -0.987301418f, -0.158858143f, - -0.986308097f, -0.164913120f, - -0.985277642f, -0.170961889f, - -0.984210092f, -0.177004220f, - -0.983105487f, -0.183039888f, - -0.981963869f, -0.189068664f, - -0.980785280f, -0.195090322f, - -0.979569766f, -0.201104635f, - -0.978317371f, -0.207111376f, - -0.977028143f, -0.213110320f, - -0.975702130f, -0.219101240f, - -0.974339383f, -0.225083911f, - -0.972939952f, -0.231058108f, - -0.971503891f, -0.237023606f, - -0.970031253f, -0.242980180f, - -0.968522094f, -0.248927606f, - -0.966976471f, -0.254865660f, - -0.965394442f, -0.260794118f, - -0.963776066f, -0.266712757f, - -0.962121404f, -0.272621355f, - -0.960430519f, -0.278519689f, - -0.958703475f, -0.284407537f, - -0.956940336f, -0.290284677f, - -0.955141168f, -0.296150888f, - -0.953306040f, -0.302005949f, - -0.951435021f, -0.307849640f, - -0.949528181f, -0.313681740f, - -0.947585591f, -0.319502031f, - -0.945607325f, -0.325310292f, - -0.943593458f, -0.331106306f, - -0.941544065f, -0.336889853f, - -0.939459224f, -0.342660717f, - -0.937339012f, -0.348418680f, - -0.935183510f, -0.354163525f, - -0.932992799f, -0.359895037f, - -0.930766961f, -0.365612998f, - -0.928506080f, -0.371317194f, - -0.926210242f, -0.377007410f, - -0.923879533f, -0.382683432f, - -0.921514039f, -0.388345047f, - -0.919113852f, -0.393992040f, - -0.916679060f, -0.399624200f, - -0.914209756f, -0.405241314f, - -0.911706032f, -0.410843171f, - -0.909167983f, -0.416429560f, - -0.906595705f, -0.422000271f, - -0.903989293f, -0.427555093f, - -0.901348847f, -0.433093819f, - -0.898674466f, -0.438616239f, - -0.895966250f, -0.444122145f, - -0.893224301f, -0.449611330f, - -0.890448723f, -0.455083587f, - -0.887639620f, -0.460538711f, - -0.884797098f, -0.465976496f, - -0.881921264f, -0.471396737f, - -0.879012226f, -0.476799230f, - -0.876070094f, -0.482183772f, - -0.873094978f, -0.487550160f, - -0.870086991f, -0.492898192f, - -0.867046246f, -0.498227667f, - -0.863972856f, -0.503538384f, - -0.860866939f, -0.508830143f, - -0.857728610f, -0.514102744f, - -0.854557988f, -0.519355990f, - -0.851355193f, -0.524589683f, - -0.848120345f, -0.529803625f, - -0.844853565f, -0.534997620f, - -0.841554977f, -0.540171473f, - -0.838224706f, -0.545324988f, - -0.834862875f, -0.550457973f, - -0.831469612f, -0.555570233f, - -0.828045045f, -0.560661576f, - -0.824589303f, -0.565731811f, - -0.821102515f, -0.570780746f, - -0.817584813f, -0.575808191f, - -0.814036330f, -0.580813958f, - -0.810457198f, -0.585797857f, - -0.806847554f, -0.590759702f, - -0.803207531f, -0.595699304f, - -0.799537269f, -0.600616479f, - -0.795836905f, -0.605511041f, - -0.792106577f, -0.610382806f, - -0.788346428f, -0.615231591f, - -0.784556597f, -0.620057212f, - -0.780737229f, -0.624859488f, - -0.776888466f, -0.629638239f, - -0.773010453f, -0.634393284f, - -0.769103338f, -0.639124445f, - -0.765167266f, -0.643831543f, - -0.761202385f, -0.648514401f, - -0.757208847f, -0.653172843f, - -0.753186799f, -0.657806693f, - -0.749136395f, -0.662415778f, - -0.745057785f, -0.666999922f, - -0.740951125f, -0.671558955f, - -0.736816569f, -0.676092704f, - -0.732654272f, -0.680600998f, - -0.728464390f, -0.685083668f, - -0.724247083f, -0.689540545f, - -0.720002508f, -0.693971461f, - -0.715730825f, -0.698376249f, - -0.711432196f, -0.702754744f, - -0.707106781f, -0.707106781f, - -0.702754744f, -0.711432196f, - -0.698376249f, -0.715730825f, - -0.693971461f, -0.720002508f, - -0.689540545f, -0.724247083f, - -0.685083668f, -0.728464390f, - -0.680600998f, -0.732654272f, - -0.676092704f, -0.736816569f, - -0.671558955f, -0.740951125f, - -0.666999922f, -0.745057785f, - -0.662415778f, -0.749136395f, - -0.657806693f, -0.753186799f, - -0.653172843f, -0.757208847f, - -0.648514401f, -0.761202385f, - -0.643831543f, -0.765167266f, - -0.639124445f, -0.769103338f, - -0.634393284f, -0.773010453f, - -0.629638239f, -0.776888466f, - -0.624859488f, -0.780737229f, - -0.620057212f, -0.784556597f, - -0.615231591f, -0.788346428f, - -0.610382806f, -0.792106577f, - -0.605511041f, -0.795836905f, - -0.600616479f, -0.799537269f, - -0.595699304f, -0.803207531f, - -0.590759702f, -0.806847554f, - -0.585797857f, -0.810457198f, - -0.580813958f, -0.814036330f, - -0.575808191f, -0.817584813f, - -0.570780746f, -0.821102515f, - -0.565731811f, -0.824589303f, - -0.560661576f, -0.828045045f, - -0.555570233f, -0.831469612f, - -0.550457973f, -0.834862875f, - -0.545324988f, -0.838224706f, - -0.540171473f, -0.841554977f, - -0.534997620f, -0.844853565f, - -0.529803625f, -0.848120345f, - -0.524589683f, -0.851355193f, - -0.519355990f, -0.854557988f, - -0.514102744f, -0.857728610f, - -0.508830143f, -0.860866939f, - -0.503538384f, -0.863972856f, - -0.498227667f, -0.867046246f, - -0.492898192f, -0.870086991f, - -0.487550160f, -0.873094978f, - -0.482183772f, -0.876070094f, - -0.476799230f, -0.879012226f, - -0.471396737f, -0.881921264f, - -0.465976496f, -0.884797098f, - -0.460538711f, -0.887639620f, - -0.455083587f, -0.890448723f, - -0.449611330f, -0.893224301f, - -0.444122145f, -0.895966250f, - -0.438616239f, -0.898674466f, - -0.433093819f, -0.901348847f, - -0.427555093f, -0.903989293f, - -0.422000271f, -0.906595705f, - -0.416429560f, -0.909167983f, - -0.410843171f, -0.911706032f, - -0.405241314f, -0.914209756f, - -0.399624200f, -0.916679060f, - -0.393992040f, -0.919113852f, - -0.388345047f, -0.921514039f, - -0.382683432f, -0.923879533f, - -0.377007410f, -0.926210242f, - -0.371317194f, -0.928506080f, - -0.365612998f, -0.930766961f, - -0.359895037f, -0.932992799f, - -0.354163525f, -0.935183510f, - -0.348418680f, -0.937339012f, - -0.342660717f, -0.939459224f, - -0.336889853f, -0.941544065f, - -0.331106306f, -0.943593458f, - -0.325310292f, -0.945607325f, - -0.319502031f, -0.947585591f, - -0.313681740f, -0.949528181f, - -0.307849640f, -0.951435021f, - -0.302005949f, -0.953306040f, - -0.296150888f, -0.955141168f, - -0.290284677f, -0.956940336f, - -0.284407537f, -0.958703475f, - -0.278519689f, -0.960430519f, - -0.272621355f, -0.962121404f, - -0.266712757f, -0.963776066f, - -0.260794118f, -0.965394442f, - -0.254865660f, -0.966976471f, - -0.248927606f, -0.968522094f, - -0.242980180f, -0.970031253f, - -0.237023606f, -0.971503891f, - -0.231058108f, -0.972939952f, - -0.225083911f, -0.974339383f, - -0.219101240f, -0.975702130f, - -0.213110320f, -0.977028143f, - -0.207111376f, -0.978317371f, - -0.201104635f, -0.979569766f, - -0.195090322f, -0.980785280f, - -0.189068664f, -0.981963869f, - -0.183039888f, -0.983105487f, - -0.177004220f, -0.984210092f, - -0.170961889f, -0.985277642f, - -0.164913120f, -0.986308097f, - -0.158858143f, -0.987301418f, - -0.152797185f, -0.988257568f, - -0.146730474f, -0.989176510f, - -0.140658239f, -0.990058210f, - -0.134580709f, -0.990902635f, - -0.128498111f, -0.991709754f, - -0.122410675f, -0.992479535f, - -0.116318631f, -0.993211949f, - -0.110222207f, -0.993906970f, - -0.104121634f, -0.994564571f, - -0.098017140f, -0.995184727f, - -0.091908956f, -0.995767414f, - -0.085797312f, -0.996312612f, - -0.079682438f, -0.996820299f, - -0.073564564f, -0.997290457f, - -0.067443920f, -0.997723067f, - -0.061320736f, -0.998118113f, - -0.055195244f, -0.998475581f, - -0.049067674f, -0.998795456f, - -0.042938257f, -0.999077728f, - -0.036807223f, -0.999322385f, - -0.030674803f, -0.999529418f, - -0.024541229f, -0.999698819f, - -0.018406730f, -0.999830582f, - -0.012271538f, -0.999924702f, - -0.006135885f, -0.999981175f, - -0.000000000f, -1.000000000f, - 0.006135885f, -0.999981175f, - 0.012271538f, -0.999924702f, - 0.018406730f, -0.999830582f, - 0.024541229f, -0.999698819f, - 0.030674803f, -0.999529418f, - 0.036807223f, -0.999322385f, - 0.042938257f, -0.999077728f, - 0.049067674f, -0.998795456f, - 0.055195244f, -0.998475581f, - 0.061320736f, -0.998118113f, - 0.067443920f, -0.997723067f, - 0.073564564f, -0.997290457f, - 0.079682438f, -0.996820299f, - 0.085797312f, -0.996312612f, - 0.091908956f, -0.995767414f, - 0.098017140f, -0.995184727f, - 0.104121634f, -0.994564571f, - 0.110222207f, -0.993906970f, - 0.116318631f, -0.993211949f, - 0.122410675f, -0.992479535f, - 0.128498111f, -0.991709754f, - 0.134580709f, -0.990902635f, - 0.140658239f, -0.990058210f, - 0.146730474f, -0.989176510f, - 0.152797185f, -0.988257568f, - 0.158858143f, -0.987301418f, - 0.164913120f, -0.986308097f, - 0.170961889f, -0.985277642f, - 0.177004220f, -0.984210092f, - 0.183039888f, -0.983105487f, - 0.189068664f, -0.981963869f, - 0.195090322f, -0.980785280f, - 0.201104635f, -0.979569766f, - 0.207111376f, -0.978317371f, - 0.213110320f, -0.977028143f, - 0.219101240f, -0.975702130f, - 0.225083911f, -0.974339383f, - 0.231058108f, -0.972939952f, - 0.237023606f, -0.971503891f, - 0.242980180f, -0.970031253f, - 0.248927606f, -0.968522094f, - 0.254865660f, -0.966976471f, - 0.260794118f, -0.965394442f, - 0.266712757f, -0.963776066f, - 0.272621355f, -0.962121404f, - 0.278519689f, -0.960430519f, - 0.284407537f, -0.958703475f, - 0.290284677f, -0.956940336f, - 0.296150888f, -0.955141168f, - 0.302005949f, -0.953306040f, - 0.307849640f, -0.951435021f, - 0.313681740f, -0.949528181f, - 0.319502031f, -0.947585591f, - 0.325310292f, -0.945607325f, - 0.331106306f, -0.943593458f, - 0.336889853f, -0.941544065f, - 0.342660717f, -0.939459224f, - 0.348418680f, -0.937339012f, - 0.354163525f, -0.935183510f, - 0.359895037f, -0.932992799f, - 0.365612998f, -0.930766961f, - 0.371317194f, -0.928506080f, - 0.377007410f, -0.926210242f, - 0.382683432f, -0.923879533f, - 0.388345047f, -0.921514039f, - 0.393992040f, -0.919113852f, - 0.399624200f, -0.916679060f, - 0.405241314f, -0.914209756f, - 0.410843171f, -0.911706032f, - 0.416429560f, -0.909167983f, - 0.422000271f, -0.906595705f, - 0.427555093f, -0.903989293f, - 0.433093819f, -0.901348847f, - 0.438616239f, -0.898674466f, - 0.444122145f, -0.895966250f, - 0.449611330f, -0.893224301f, - 0.455083587f, -0.890448723f, - 0.460538711f, -0.887639620f, - 0.465976496f, -0.884797098f, - 0.471396737f, -0.881921264f, - 0.476799230f, -0.879012226f, - 0.482183772f, -0.876070094f, - 0.487550160f, -0.873094978f, - 0.492898192f, -0.870086991f, - 0.498227667f, -0.867046246f, - 0.503538384f, -0.863972856f, - 0.508830143f, -0.860866939f, - 0.514102744f, -0.857728610f, - 0.519355990f, -0.854557988f, - 0.524589683f, -0.851355193f, - 0.529803625f, -0.848120345f, - 0.534997620f, -0.844853565f, - 0.540171473f, -0.841554977f, - 0.545324988f, -0.838224706f, - 0.550457973f, -0.834862875f, - 0.555570233f, -0.831469612f, - 0.560661576f, -0.828045045f, - 0.565731811f, -0.824589303f, - 0.570780746f, -0.821102515f, - 0.575808191f, -0.817584813f, - 0.580813958f, -0.814036330f, - 0.585797857f, -0.810457198f, - 0.590759702f, -0.806847554f, - 0.595699304f, -0.803207531f, - 0.600616479f, -0.799537269f, - 0.605511041f, -0.795836905f, - 0.610382806f, -0.792106577f, - 0.615231591f, -0.788346428f, - 0.620057212f, -0.784556597f, - 0.624859488f, -0.780737229f, - 0.629638239f, -0.776888466f, - 0.634393284f, -0.773010453f, - 0.639124445f, -0.769103338f, - 0.643831543f, -0.765167266f, - 0.648514401f, -0.761202385f, - 0.653172843f, -0.757208847f, - 0.657806693f, -0.753186799f, - 0.662415778f, -0.749136395f, - 0.666999922f, -0.745057785f, - 0.671558955f, -0.740951125f, - 0.676092704f, -0.736816569f, - 0.680600998f, -0.732654272f, - 0.685083668f, -0.728464390f, - 0.689540545f, -0.724247083f, - 0.693971461f, -0.720002508f, - 0.698376249f, -0.715730825f, - 0.702754744f, -0.711432196f, - 0.707106781f, -0.707106781f, - 0.711432196f, -0.702754744f, - 0.715730825f, -0.698376249f, - 0.720002508f, -0.693971461f, - 0.724247083f, -0.689540545f, - 0.728464390f, -0.685083668f, - 0.732654272f, -0.680600998f, - 0.736816569f, -0.676092704f, - 0.740951125f, -0.671558955f, - 0.745057785f, -0.666999922f, - 0.749136395f, -0.662415778f, - 0.753186799f, -0.657806693f, - 0.757208847f, -0.653172843f, - 0.761202385f, -0.648514401f, - 0.765167266f, -0.643831543f, - 0.769103338f, -0.639124445f, - 0.773010453f, -0.634393284f, - 0.776888466f, -0.629638239f, - 0.780737229f, -0.624859488f, - 0.784556597f, -0.620057212f, - 0.788346428f, -0.615231591f, - 0.792106577f, -0.610382806f, - 0.795836905f, -0.605511041f, - 0.799537269f, -0.600616479f, - 0.803207531f, -0.595699304f, - 0.806847554f, -0.590759702f, - 0.810457198f, -0.585797857f, - 0.814036330f, -0.580813958f, - 0.817584813f, -0.575808191f, - 0.821102515f, -0.570780746f, - 0.824589303f, -0.565731811f, - 0.828045045f, -0.560661576f, - 0.831469612f, -0.555570233f, - 0.834862875f, -0.550457973f, - 0.838224706f, -0.545324988f, - 0.841554977f, -0.540171473f, - 0.844853565f, -0.534997620f, - 0.848120345f, -0.529803625f, - 0.851355193f, -0.524589683f, - 0.854557988f, -0.519355990f, - 0.857728610f, -0.514102744f, - 0.860866939f, -0.508830143f, - 0.863972856f, -0.503538384f, - 0.867046246f, -0.498227667f, - 0.870086991f, -0.492898192f, - 0.873094978f, -0.487550160f, - 0.876070094f, -0.482183772f, - 0.879012226f, -0.476799230f, - 0.881921264f, -0.471396737f, - 0.884797098f, -0.465976496f, - 0.887639620f, -0.460538711f, - 0.890448723f, -0.455083587f, - 0.893224301f, -0.449611330f, - 0.895966250f, -0.444122145f, - 0.898674466f, -0.438616239f, - 0.901348847f, -0.433093819f, - 0.903989293f, -0.427555093f, - 0.906595705f, -0.422000271f, - 0.909167983f, -0.416429560f, - 0.911706032f, -0.410843171f, - 0.914209756f, -0.405241314f, - 0.916679060f, -0.399624200f, - 0.919113852f, -0.393992040f, - 0.921514039f, -0.388345047f, - 0.923879533f, -0.382683432f, - 0.926210242f, -0.377007410f, - 0.928506080f, -0.371317194f, - 0.930766961f, -0.365612998f, - 0.932992799f, -0.359895037f, - 0.935183510f, -0.354163525f, - 0.937339012f, -0.348418680f, - 0.939459224f, -0.342660717f, - 0.941544065f, -0.336889853f, - 0.943593458f, -0.331106306f, - 0.945607325f, -0.325310292f, - 0.947585591f, -0.319502031f, - 0.949528181f, -0.313681740f, - 0.951435021f, -0.307849640f, - 0.953306040f, -0.302005949f, - 0.955141168f, -0.296150888f, - 0.956940336f, -0.290284677f, - 0.958703475f, -0.284407537f, - 0.960430519f, -0.278519689f, - 0.962121404f, -0.272621355f, - 0.963776066f, -0.266712757f, - 0.965394442f, -0.260794118f, - 0.966976471f, -0.254865660f, - 0.968522094f, -0.248927606f, - 0.970031253f, -0.242980180f, - 0.971503891f, -0.237023606f, - 0.972939952f, -0.231058108f, - 0.974339383f, -0.225083911f, - 0.975702130f, -0.219101240f, - 0.977028143f, -0.213110320f, - 0.978317371f, -0.207111376f, - 0.979569766f, -0.201104635f, - 0.980785280f, -0.195090322f, - 0.981963869f, -0.189068664f, - 0.983105487f, -0.183039888f, - 0.984210092f, -0.177004220f, - 0.985277642f, -0.170961889f, - 0.986308097f, -0.164913120f, - 0.987301418f, -0.158858143f, - 0.988257568f, -0.152797185f, - 0.989176510f, -0.146730474f, - 0.990058210f, -0.140658239f, - 0.990902635f, -0.134580709f, - 0.991709754f, -0.128498111f, - 0.992479535f, -0.122410675f, - 0.993211949f, -0.116318631f, - 0.993906970f, -0.110222207f, - 0.994564571f, -0.104121634f, - 0.995184727f, -0.098017140f, - 0.995767414f, -0.091908956f, - 0.996312612f, -0.085797312f, - 0.996820299f, -0.079682438f, - 0.997290457f, -0.073564564f, - 0.997723067f, -0.067443920f, - 0.998118113f, -0.061320736f, - 0.998475581f, -0.055195244f, - 0.998795456f, -0.049067674f, - 0.999077728f, -0.042938257f, - 0.999322385f, -0.036807223f, - 0.999529418f, -0.030674803f, - 0.999698819f, -0.024541229f, - 0.999830582f, -0.018406730f, - 0.999924702f, -0.012271538f, - 0.999981175f, -0.006135885f -}; + 1.000000000f, 0.000000000f, 0.999981175f, 0.006135885f, 0.999924702f, + 0.012271538f, 0.999830582f, 0.018406730f, 0.999698819f, 0.024541229f, + 0.999529418f, 0.030674803f, 0.999322385f, 0.036807223f, 0.999077728f, + 0.042938257f, 0.998795456f, 0.049067674f, 0.998475581f, 0.055195244f, + 0.998118113f, 0.061320736f, 0.997723067f, 0.067443920f, 0.997290457f, + 0.073564564f, 0.996820299f, 0.079682438f, 0.996312612f, 0.085797312f, + 0.995767414f, 0.091908956f, 0.995184727f, 0.098017140f, 0.994564571f, + 0.104121634f, 0.993906970f, 0.110222207f, 0.993211949f, 0.116318631f, + 0.992479535f, 0.122410675f, 0.991709754f, 0.128498111f, 0.990902635f, + 0.134580709f, 0.990058210f, 0.140658239f, 0.989176510f, 0.146730474f, + 0.988257568f, 0.152797185f, 0.987301418f, 0.158858143f, 0.986308097f, + 0.164913120f, 0.985277642f, 0.170961889f, 0.984210092f, 0.177004220f, + 0.983105487f, 0.183039888f, 0.981963869f, 0.189068664f, 0.980785280f, + 0.195090322f, 0.979569766f, 0.201104635f, 0.978317371f, 0.207111376f, + 0.977028143f, 0.213110320f, 0.975702130f, 0.219101240f, 0.974339383f, + 0.225083911f, 0.972939952f, 0.231058108f, 0.971503891f, 0.237023606f, + 0.970031253f, 0.242980180f, 0.968522094f, 0.248927606f, 0.966976471f, + 0.254865660f, 0.965394442f, 0.260794118f, 0.963776066f, 0.266712757f, + 0.962121404f, 0.272621355f, 0.960430519f, 0.278519689f, 0.958703475f, + 0.284407537f, 0.956940336f, 0.290284677f, 0.955141168f, 0.296150888f, + 0.953306040f, 0.302005949f, 0.951435021f, 0.307849640f, 0.949528181f, + 0.313681740f, 0.947585591f, 0.319502031f, 0.945607325f, 0.325310292f, + 0.943593458f, 0.331106306f, 0.941544065f, 0.336889853f, 0.939459224f, + 0.342660717f, 0.937339012f, 0.348418680f, 0.935183510f, 0.354163525f, + 0.932992799f, 0.359895037f, 0.930766961f, 0.365612998f, 0.928506080f, + 0.371317194f, 0.926210242f, 0.377007410f, 0.923879533f, 0.382683432f, + 0.921514039f, 0.388345047f, 0.919113852f, 0.393992040f, 0.916679060f, + 0.399624200f, 0.914209756f, 0.405241314f, 0.911706032f, 0.410843171f, + 0.909167983f, 0.416429560f, 0.906595705f, 0.422000271f, 0.903989293f, + 0.427555093f, 0.901348847f, 0.433093819f, 0.898674466f, 0.438616239f, + 0.895966250f, 0.444122145f, 0.893224301f, 0.449611330f, 0.890448723f, + 0.455083587f, 0.887639620f, 0.460538711f, 0.884797098f, 0.465976496f, + 0.881921264f, 0.471396737f, 0.879012226f, 0.476799230f, 0.876070094f, + 0.482183772f, 0.873094978f, 0.487550160f, 0.870086991f, 0.492898192f, + 0.867046246f, 0.498227667f, 0.863972856f, 0.503538384f, 0.860866939f, + 0.508830143f, 0.857728610f, 0.514102744f, 0.854557988f, 0.519355990f, + 0.851355193f, 0.524589683f, 0.848120345f, 0.529803625f, 0.844853565f, + 0.534997620f, 0.841554977f, 0.540171473f, 0.838224706f, 0.545324988f, + 0.834862875f, 0.550457973f, 0.831469612f, 0.555570233f, 0.828045045f, + 0.560661576f, 0.824589303f, 0.565731811f, 0.821102515f, 0.570780746f, + 0.817584813f, 0.575808191f, 0.814036330f, 0.580813958f, 0.810457198f, + 0.585797857f, 0.806847554f, 0.590759702f, 0.803207531f, 0.595699304f, + 0.799537269f, 0.600616479f, 0.795836905f, 0.605511041f, 0.792106577f, + 0.610382806f, 0.788346428f, 0.615231591f, 0.784556597f, 0.620057212f, + 0.780737229f, 0.624859488f, 0.776888466f, 0.629638239f, 0.773010453f, + 0.634393284f, 0.769103338f, 0.639124445f, 0.765167266f, 0.643831543f, + 0.761202385f, 0.648514401f, 0.757208847f, 0.653172843f, 0.753186799f, + 0.657806693f, 0.749136395f, 0.662415778f, 0.745057785f, 0.666999922f, + 0.740951125f, 0.671558955f, 0.736816569f, 0.676092704f, 0.732654272f, + 0.680600998f, 0.728464390f, 0.685083668f, 0.724247083f, 0.689540545f, + 0.720002508f, 0.693971461f, 0.715730825f, 0.698376249f, 0.711432196f, + 0.702754744f, 0.707106781f, 0.707106781f, 0.702754744f, 0.711432196f, + 0.698376249f, 0.715730825f, 0.693971461f, 0.720002508f, 0.689540545f, + 0.724247083f, 0.685083668f, 0.728464390f, 0.680600998f, 0.732654272f, + 0.676092704f, 0.736816569f, 0.671558955f, 0.740951125f, 0.666999922f, + 0.745057785f, 0.662415778f, 0.749136395f, 0.657806693f, 0.753186799f, + 0.653172843f, 0.757208847f, 0.648514401f, 0.761202385f, 0.643831543f, + 0.765167266f, 0.639124445f, 0.769103338f, 0.634393284f, 0.773010453f, + 0.629638239f, 0.776888466f, 0.624859488f, 0.780737229f, 0.620057212f, + 0.784556597f, 0.615231591f, 0.788346428f, 0.610382806f, 0.792106577f, + 0.605511041f, 0.795836905f, 0.600616479f, 0.799537269f, 0.595699304f, + 0.803207531f, 0.590759702f, 0.806847554f, 0.585797857f, 0.810457198f, + 0.580813958f, 0.814036330f, 0.575808191f, 0.817584813f, 0.570780746f, + 0.821102515f, 0.565731811f, 0.824589303f, 0.560661576f, 0.828045045f, + 0.555570233f, 0.831469612f, 0.550457973f, 0.834862875f, 0.545324988f, + 0.838224706f, 0.540171473f, 0.841554977f, 0.534997620f, 0.844853565f, + 0.529803625f, 0.848120345f, 0.524589683f, 0.851355193f, 0.519355990f, + 0.854557988f, 0.514102744f, 0.857728610f, 0.508830143f, 0.860866939f, + 0.503538384f, 0.863972856f, 0.498227667f, 0.867046246f, 0.492898192f, + 0.870086991f, 0.487550160f, 0.873094978f, 0.482183772f, 0.876070094f, + 0.476799230f, 0.879012226f, 0.471396737f, 0.881921264f, 0.465976496f, + 0.884797098f, 0.460538711f, 0.887639620f, 0.455083587f, 0.890448723f, + 0.449611330f, 0.893224301f, 0.444122145f, 0.895966250f, 0.438616239f, + 0.898674466f, 0.433093819f, 0.901348847f, 0.427555093f, 0.903989293f, + 0.422000271f, 0.906595705f, 0.416429560f, 0.909167983f, 0.410843171f, + 0.911706032f, 0.405241314f, 0.914209756f, 0.399624200f, 0.916679060f, + 0.393992040f, 0.919113852f, 0.388345047f, 0.921514039f, 0.382683432f, + 0.923879533f, 0.377007410f, 0.926210242f, 0.371317194f, 0.928506080f, + 0.365612998f, 0.930766961f, 0.359895037f, 0.932992799f, 0.354163525f, + 0.935183510f, 0.348418680f, 0.937339012f, 0.342660717f, 0.939459224f, + 0.336889853f, 0.941544065f, 0.331106306f, 0.943593458f, 0.325310292f, + 0.945607325f, 0.319502031f, 0.947585591f, 0.313681740f, 0.949528181f, + 0.307849640f, 0.951435021f, 0.302005949f, 0.953306040f, 0.296150888f, + 0.955141168f, 0.290284677f, 0.956940336f, 0.284407537f, 0.958703475f, + 0.278519689f, 0.960430519f, 0.272621355f, 0.962121404f, 0.266712757f, + 0.963776066f, 0.260794118f, 0.965394442f, 0.254865660f, 0.966976471f, + 0.248927606f, 0.968522094f, 0.242980180f, 0.970031253f, 0.237023606f, + 0.971503891f, 0.231058108f, 0.972939952f, 0.225083911f, 0.974339383f, + 0.219101240f, 0.975702130f, 0.213110320f, 0.977028143f, 0.207111376f, + 0.978317371f, 0.201104635f, 0.979569766f, 0.195090322f, 0.980785280f, + 0.189068664f, 0.981963869f, 0.183039888f, 0.983105487f, 0.177004220f, + 0.984210092f, 0.170961889f, 0.985277642f, 0.164913120f, 0.986308097f, + 0.158858143f, 0.987301418f, 0.152797185f, 0.988257568f, 0.146730474f, + 0.989176510f, 0.140658239f, 0.990058210f, 0.134580709f, 0.990902635f, + 0.128498111f, 0.991709754f, 0.122410675f, 0.992479535f, 0.116318631f, + 0.993211949f, 0.110222207f, 0.993906970f, 0.104121634f, 0.994564571f, + 0.098017140f, 0.995184727f, 0.091908956f, 0.995767414f, 0.085797312f, + 0.996312612f, 0.079682438f, 0.996820299f, 0.073564564f, 0.997290457f, + 0.067443920f, 0.997723067f, 0.061320736f, 0.998118113f, 0.055195244f, + 0.998475581f, 0.049067674f, 0.998795456f, 0.042938257f, 0.999077728f, + 0.036807223f, 0.999322385f, 0.030674803f, 0.999529418f, 0.024541229f, + 0.999698819f, 0.018406730f, 0.999830582f, 0.012271538f, 0.999924702f, + 0.006135885f, 0.999981175f, 0.000000000f, 1.000000000f, -0.006135885f, + 0.999981175f, -0.012271538f, 0.999924702f, -0.018406730f, 0.999830582f, + -0.024541229f, 0.999698819f, -0.030674803f, 0.999529418f, -0.036807223f, + 0.999322385f, -0.042938257f, 0.999077728f, -0.049067674f, 0.998795456f, + -0.055195244f, 0.998475581f, -0.061320736f, 0.998118113f, -0.067443920f, + 0.997723067f, -0.073564564f, 0.997290457f, -0.079682438f, 0.996820299f, + -0.085797312f, 0.996312612f, -0.091908956f, 0.995767414f, -0.098017140f, + 0.995184727f, -0.104121634f, 0.994564571f, -0.110222207f, 0.993906970f, + -0.116318631f, 0.993211949f, -0.122410675f, 0.992479535f, -0.128498111f, + 0.991709754f, -0.134580709f, 0.990902635f, -0.140658239f, 0.990058210f, + -0.146730474f, 0.989176510f, -0.152797185f, 0.988257568f, -0.158858143f, + 0.987301418f, -0.164913120f, 0.986308097f, -0.170961889f, 0.985277642f, + -0.177004220f, 0.984210092f, -0.183039888f, 0.983105487f, -0.189068664f, + 0.981963869f, -0.195090322f, 0.980785280f, -0.201104635f, 0.979569766f, + -0.207111376f, 0.978317371f, -0.213110320f, 0.977028143f, -0.219101240f, + 0.975702130f, -0.225083911f, 0.974339383f, -0.231058108f, 0.972939952f, + -0.237023606f, 0.971503891f, -0.242980180f, 0.970031253f, -0.248927606f, + 0.968522094f, -0.254865660f, 0.966976471f, -0.260794118f, 0.965394442f, + -0.266712757f, 0.963776066f, -0.272621355f, 0.962121404f, -0.278519689f, + 0.960430519f, -0.284407537f, 0.958703475f, -0.290284677f, 0.956940336f, + -0.296150888f, 0.955141168f, -0.302005949f, 0.953306040f, -0.307849640f, + 0.951435021f, -0.313681740f, 0.949528181f, -0.319502031f, 0.947585591f, + -0.325310292f, 0.945607325f, -0.331106306f, 0.943593458f, -0.336889853f, + 0.941544065f, -0.342660717f, 0.939459224f, -0.348418680f, 0.937339012f, + -0.354163525f, 0.935183510f, -0.359895037f, 0.932992799f, -0.365612998f, + 0.930766961f, -0.371317194f, 0.928506080f, -0.377007410f, 0.926210242f, + -0.382683432f, 0.923879533f, -0.388345047f, 0.921514039f, -0.393992040f, + 0.919113852f, -0.399624200f, 0.916679060f, -0.405241314f, 0.914209756f, + -0.410843171f, 0.911706032f, -0.416429560f, 0.909167983f, -0.422000271f, + 0.906595705f, -0.427555093f, 0.903989293f, -0.433093819f, 0.901348847f, + -0.438616239f, 0.898674466f, -0.444122145f, 0.895966250f, -0.449611330f, + 0.893224301f, -0.455083587f, 0.890448723f, -0.460538711f, 0.887639620f, + -0.465976496f, 0.884797098f, -0.471396737f, 0.881921264f, -0.476799230f, + 0.879012226f, -0.482183772f, 0.876070094f, -0.487550160f, 0.873094978f, + -0.492898192f, 0.870086991f, -0.498227667f, 0.867046246f, -0.503538384f, + 0.863972856f, -0.508830143f, 0.860866939f, -0.514102744f, 0.857728610f, + -0.519355990f, 0.854557988f, -0.524589683f, 0.851355193f, -0.529803625f, + 0.848120345f, -0.534997620f, 0.844853565f, -0.540171473f, 0.841554977f, + -0.545324988f, 0.838224706f, -0.550457973f, 0.834862875f, -0.555570233f, + 0.831469612f, -0.560661576f, 0.828045045f, -0.565731811f, 0.824589303f, + -0.570780746f, 0.821102515f, -0.575808191f, 0.817584813f, -0.580813958f, + 0.814036330f, -0.585797857f, 0.810457198f, -0.590759702f, 0.806847554f, + -0.595699304f, 0.803207531f, -0.600616479f, 0.799537269f, -0.605511041f, + 0.795836905f, -0.610382806f, 0.792106577f, -0.615231591f, 0.788346428f, + -0.620057212f, 0.784556597f, -0.624859488f, 0.780737229f, -0.629638239f, + 0.776888466f, -0.634393284f, 0.773010453f, -0.639124445f, 0.769103338f, + -0.643831543f, 0.765167266f, -0.648514401f, 0.761202385f, -0.653172843f, + 0.757208847f, -0.657806693f, 0.753186799f, -0.662415778f, 0.749136395f, + -0.666999922f, 0.745057785f, -0.671558955f, 0.740951125f, -0.676092704f, + 0.736816569f, -0.680600998f, 0.732654272f, -0.685083668f, 0.728464390f, + -0.689540545f, 0.724247083f, -0.693971461f, 0.720002508f, -0.698376249f, + 0.715730825f, -0.702754744f, 0.711432196f, -0.707106781f, 0.707106781f, + -0.711432196f, 0.702754744f, -0.715730825f, 0.698376249f, -0.720002508f, + 0.693971461f, -0.724247083f, 0.689540545f, -0.728464390f, 0.685083668f, + -0.732654272f, 0.680600998f, -0.736816569f, 0.676092704f, -0.740951125f, + 0.671558955f, -0.745057785f, 0.666999922f, -0.749136395f, 0.662415778f, + -0.753186799f, 0.657806693f, -0.757208847f, 0.653172843f, -0.761202385f, + 0.648514401f, -0.765167266f, 0.643831543f, -0.769103338f, 0.639124445f, + -0.773010453f, 0.634393284f, -0.776888466f, 0.629638239f, -0.780737229f, + 0.624859488f, -0.784556597f, 0.620057212f, -0.788346428f, 0.615231591f, + -0.792106577f, 0.610382806f, -0.795836905f, 0.605511041f, -0.799537269f, + 0.600616479f, -0.803207531f, 0.595699304f, -0.806847554f, 0.590759702f, + -0.810457198f, 0.585797857f, -0.814036330f, 0.580813958f, -0.817584813f, + 0.575808191f, -0.821102515f, 0.570780746f, -0.824589303f, 0.565731811f, + -0.828045045f, 0.560661576f, -0.831469612f, 0.555570233f, -0.834862875f, + 0.550457973f, -0.838224706f, 0.545324988f, -0.841554977f, 0.540171473f, + -0.844853565f, 0.534997620f, -0.848120345f, 0.529803625f, -0.851355193f, + 0.524589683f, -0.854557988f, 0.519355990f, -0.857728610f, 0.514102744f, + -0.860866939f, 0.508830143f, -0.863972856f, 0.503538384f, -0.867046246f, + 0.498227667f, -0.870086991f, 0.492898192f, -0.873094978f, 0.487550160f, + -0.876070094f, 0.482183772f, -0.879012226f, 0.476799230f, -0.881921264f, + 0.471396737f, -0.884797098f, 0.465976496f, -0.887639620f, 0.460538711f, + -0.890448723f, 0.455083587f, -0.893224301f, 0.449611330f, -0.895966250f, + 0.444122145f, -0.898674466f, 0.438616239f, -0.901348847f, 0.433093819f, + -0.903989293f, 0.427555093f, -0.906595705f, 0.422000271f, -0.909167983f, + 0.416429560f, -0.911706032f, 0.410843171f, -0.914209756f, 0.405241314f, + -0.916679060f, 0.399624200f, -0.919113852f, 0.393992040f, -0.921514039f, + 0.388345047f, -0.923879533f, 0.382683432f, -0.926210242f, 0.377007410f, + -0.928506080f, 0.371317194f, -0.930766961f, 0.365612998f, -0.932992799f, + 0.359895037f, -0.935183510f, 0.354163525f, -0.937339012f, 0.348418680f, + -0.939459224f, 0.342660717f, -0.941544065f, 0.336889853f, -0.943593458f, + 0.331106306f, -0.945607325f, 0.325310292f, -0.947585591f, 0.319502031f, + -0.949528181f, 0.313681740f, -0.951435021f, 0.307849640f, -0.953306040f, + 0.302005949f, -0.955141168f, 0.296150888f, -0.956940336f, 0.290284677f, + -0.958703475f, 0.284407537f, -0.960430519f, 0.278519689f, -0.962121404f, + 0.272621355f, -0.963776066f, 0.266712757f, -0.965394442f, 0.260794118f, + -0.966976471f, 0.254865660f, -0.968522094f, 0.248927606f, -0.970031253f, + 0.242980180f, -0.971503891f, 0.237023606f, -0.972939952f, 0.231058108f, + -0.974339383f, 0.225083911f, -0.975702130f, 0.219101240f, -0.977028143f, + 0.213110320f, -0.978317371f, 0.207111376f, -0.979569766f, 0.201104635f, + -0.980785280f, 0.195090322f, -0.981963869f, 0.189068664f, -0.983105487f, + 0.183039888f, -0.984210092f, 0.177004220f, -0.985277642f, 0.170961889f, + -0.986308097f, 0.164913120f, -0.987301418f, 0.158858143f, -0.988257568f, + 0.152797185f, -0.989176510f, 0.146730474f, -0.990058210f, 0.140658239f, + -0.990902635f, 0.134580709f, -0.991709754f, 0.128498111f, -0.992479535f, + 0.122410675f, -0.993211949f, 0.116318631f, -0.993906970f, 0.110222207f, + -0.994564571f, 0.104121634f, -0.995184727f, 0.098017140f, -0.995767414f, + 0.091908956f, -0.996312612f, 0.085797312f, -0.996820299f, 0.079682438f, + -0.997290457f, 0.073564564f, -0.997723067f, 0.067443920f, -0.998118113f, + 0.061320736f, -0.998475581f, 0.055195244f, -0.998795456f, 0.049067674f, + -0.999077728f, 0.042938257f, -0.999322385f, 0.036807223f, -0.999529418f, + 0.030674803f, -0.999698819f, 0.024541229f, -0.999830582f, 0.018406730f, + -0.999924702f, 0.012271538f, -0.999981175f, 0.006135885f, -1.000000000f, + 0.000000000f, -0.999981175f, -0.006135885f, -0.999924702f, -0.012271538f, + -0.999830582f, -0.018406730f, -0.999698819f, -0.024541229f, -0.999529418f, + -0.030674803f, -0.999322385f, -0.036807223f, -0.999077728f, -0.042938257f, + -0.998795456f, -0.049067674f, -0.998475581f, -0.055195244f, -0.998118113f, + -0.061320736f, -0.997723067f, -0.067443920f, -0.997290457f, -0.073564564f, + -0.996820299f, -0.079682438f, -0.996312612f, -0.085797312f, -0.995767414f, + -0.091908956f, -0.995184727f, -0.098017140f, -0.994564571f, -0.104121634f, + -0.993906970f, -0.110222207f, -0.993211949f, -0.116318631f, -0.992479535f, + -0.122410675f, -0.991709754f, -0.128498111f, -0.990902635f, -0.134580709f, + -0.990058210f, -0.140658239f, -0.989176510f, -0.146730474f, -0.988257568f, + -0.152797185f, -0.987301418f, -0.158858143f, -0.986308097f, -0.164913120f, + -0.985277642f, -0.170961889f, -0.984210092f, -0.177004220f, -0.983105487f, + -0.183039888f, -0.981963869f, -0.189068664f, -0.980785280f, -0.195090322f, + -0.979569766f, -0.201104635f, -0.978317371f, -0.207111376f, -0.977028143f, + -0.213110320f, -0.975702130f, -0.219101240f, -0.974339383f, -0.225083911f, + -0.972939952f, -0.231058108f, -0.971503891f, -0.237023606f, -0.970031253f, + -0.242980180f, -0.968522094f, -0.248927606f, -0.966976471f, -0.254865660f, + -0.965394442f, -0.260794118f, -0.963776066f, -0.266712757f, -0.962121404f, + -0.272621355f, -0.960430519f, -0.278519689f, -0.958703475f, -0.284407537f, + -0.956940336f, -0.290284677f, -0.955141168f, -0.296150888f, -0.953306040f, + -0.302005949f, -0.951435021f, -0.307849640f, -0.949528181f, -0.313681740f, + -0.947585591f, -0.319502031f, -0.945607325f, -0.325310292f, -0.943593458f, + -0.331106306f, -0.941544065f, -0.336889853f, -0.939459224f, -0.342660717f, + -0.937339012f, -0.348418680f, -0.935183510f, -0.354163525f, -0.932992799f, + -0.359895037f, -0.930766961f, -0.365612998f, -0.928506080f, -0.371317194f, + -0.926210242f, -0.377007410f, -0.923879533f, -0.382683432f, -0.921514039f, + -0.388345047f, -0.919113852f, -0.393992040f, -0.916679060f, -0.399624200f, + -0.914209756f, -0.405241314f, -0.911706032f, -0.410843171f, -0.909167983f, + -0.416429560f, -0.906595705f, -0.422000271f, -0.903989293f, -0.427555093f, + -0.901348847f, -0.433093819f, -0.898674466f, -0.438616239f, -0.895966250f, + -0.444122145f, -0.893224301f, -0.449611330f, -0.890448723f, -0.455083587f, + -0.887639620f, -0.460538711f, -0.884797098f, -0.465976496f, -0.881921264f, + -0.471396737f, -0.879012226f, -0.476799230f, -0.876070094f, -0.482183772f, + -0.873094978f, -0.487550160f, -0.870086991f, -0.492898192f, -0.867046246f, + -0.498227667f, -0.863972856f, -0.503538384f, -0.860866939f, -0.508830143f, + -0.857728610f, -0.514102744f, -0.854557988f, -0.519355990f, -0.851355193f, + -0.524589683f, -0.848120345f, -0.529803625f, -0.844853565f, -0.534997620f, + -0.841554977f, -0.540171473f, -0.838224706f, -0.545324988f, -0.834862875f, + -0.550457973f, -0.831469612f, -0.555570233f, -0.828045045f, -0.560661576f, + -0.824589303f, -0.565731811f, -0.821102515f, -0.570780746f, -0.817584813f, + -0.575808191f, -0.814036330f, -0.580813958f, -0.810457198f, -0.585797857f, + -0.806847554f, -0.590759702f, -0.803207531f, -0.595699304f, -0.799537269f, + -0.600616479f, -0.795836905f, -0.605511041f, -0.792106577f, -0.610382806f, + -0.788346428f, -0.615231591f, -0.784556597f, -0.620057212f, -0.780737229f, + -0.624859488f, -0.776888466f, -0.629638239f, -0.773010453f, -0.634393284f, + -0.769103338f, -0.639124445f, -0.765167266f, -0.643831543f, -0.761202385f, + -0.648514401f, -0.757208847f, -0.653172843f, -0.753186799f, -0.657806693f, + -0.749136395f, -0.662415778f, -0.745057785f, -0.666999922f, -0.740951125f, + -0.671558955f, -0.736816569f, -0.676092704f, -0.732654272f, -0.680600998f, + -0.728464390f, -0.685083668f, -0.724247083f, -0.689540545f, -0.720002508f, + -0.693971461f, -0.715730825f, -0.698376249f, -0.711432196f, -0.702754744f, + -0.707106781f, -0.707106781f, -0.702754744f, -0.711432196f, -0.698376249f, + -0.715730825f, -0.693971461f, -0.720002508f, -0.689540545f, -0.724247083f, + -0.685083668f, -0.728464390f, -0.680600998f, -0.732654272f, -0.676092704f, + -0.736816569f, -0.671558955f, -0.740951125f, -0.666999922f, -0.745057785f, + -0.662415778f, -0.749136395f, -0.657806693f, -0.753186799f, -0.653172843f, + -0.757208847f, -0.648514401f, -0.761202385f, -0.643831543f, -0.765167266f, + -0.639124445f, -0.769103338f, -0.634393284f, -0.773010453f, -0.629638239f, + -0.776888466f, -0.624859488f, -0.780737229f, -0.620057212f, -0.784556597f, + -0.615231591f, -0.788346428f, -0.610382806f, -0.792106577f, -0.605511041f, + -0.795836905f, -0.600616479f, -0.799537269f, -0.595699304f, -0.803207531f, + -0.590759702f, -0.806847554f, -0.585797857f, -0.810457198f, -0.580813958f, + -0.814036330f, -0.575808191f, -0.817584813f, -0.570780746f, -0.821102515f, + -0.565731811f, -0.824589303f, -0.560661576f, -0.828045045f, -0.555570233f, + -0.831469612f, -0.550457973f, -0.834862875f, -0.545324988f, -0.838224706f, + -0.540171473f, -0.841554977f, -0.534997620f, -0.844853565f, -0.529803625f, + -0.848120345f, -0.524589683f, -0.851355193f, -0.519355990f, -0.854557988f, + -0.514102744f, -0.857728610f, -0.508830143f, -0.860866939f, -0.503538384f, + -0.863972856f, -0.498227667f, -0.867046246f, -0.492898192f, -0.870086991f, + -0.487550160f, -0.873094978f, -0.482183772f, -0.876070094f, -0.476799230f, + -0.879012226f, -0.471396737f, -0.881921264f, -0.465976496f, -0.884797098f, + -0.460538711f, -0.887639620f, -0.455083587f, -0.890448723f, -0.449611330f, + -0.893224301f, -0.444122145f, -0.895966250f, -0.438616239f, -0.898674466f, + -0.433093819f, -0.901348847f, -0.427555093f, -0.903989293f, -0.422000271f, + -0.906595705f, -0.416429560f, -0.909167983f, -0.410843171f, -0.911706032f, + -0.405241314f, -0.914209756f, -0.399624200f, -0.916679060f, -0.393992040f, + -0.919113852f, -0.388345047f, -0.921514039f, -0.382683432f, -0.923879533f, + -0.377007410f, -0.926210242f, -0.371317194f, -0.928506080f, -0.365612998f, + -0.930766961f, -0.359895037f, -0.932992799f, -0.354163525f, -0.935183510f, + -0.348418680f, -0.937339012f, -0.342660717f, -0.939459224f, -0.336889853f, + -0.941544065f, -0.331106306f, -0.943593458f, -0.325310292f, -0.945607325f, + -0.319502031f, -0.947585591f, -0.313681740f, -0.949528181f, -0.307849640f, + -0.951435021f, -0.302005949f, -0.953306040f, -0.296150888f, -0.955141168f, + -0.290284677f, -0.956940336f, -0.284407537f, -0.958703475f, -0.278519689f, + -0.960430519f, -0.272621355f, -0.962121404f, -0.266712757f, -0.963776066f, + -0.260794118f, -0.965394442f, -0.254865660f, -0.966976471f, -0.248927606f, + -0.968522094f, -0.242980180f, -0.970031253f, -0.237023606f, -0.971503891f, + -0.231058108f, -0.972939952f, -0.225083911f, -0.974339383f, -0.219101240f, + -0.975702130f, -0.213110320f, -0.977028143f, -0.207111376f, -0.978317371f, + -0.201104635f, -0.979569766f, -0.195090322f, -0.980785280f, -0.189068664f, + -0.981963869f, -0.183039888f, -0.983105487f, -0.177004220f, -0.984210092f, + -0.170961889f, -0.985277642f, -0.164913120f, -0.986308097f, -0.158858143f, + -0.987301418f, -0.152797185f, -0.988257568f, -0.146730474f, -0.989176510f, + -0.140658239f, -0.990058210f, -0.134580709f, -0.990902635f, -0.128498111f, + -0.991709754f, -0.122410675f, -0.992479535f, -0.116318631f, -0.993211949f, + -0.110222207f, -0.993906970f, -0.104121634f, -0.994564571f, -0.098017140f, + -0.995184727f, -0.091908956f, -0.995767414f, -0.085797312f, -0.996312612f, + -0.079682438f, -0.996820299f, -0.073564564f, -0.997290457f, -0.067443920f, + -0.997723067f, -0.061320736f, -0.998118113f, -0.055195244f, -0.998475581f, + -0.049067674f, -0.998795456f, -0.042938257f, -0.999077728f, -0.036807223f, + -0.999322385f, -0.030674803f, -0.999529418f, -0.024541229f, -0.999698819f, + -0.018406730f, -0.999830582f, -0.012271538f, -0.999924702f, -0.006135885f, + -0.999981175f, -0.000000000f, -1.000000000f, 0.006135885f, -0.999981175f, + 0.012271538f, -0.999924702f, 0.018406730f, -0.999830582f, 0.024541229f, + -0.999698819f, 0.030674803f, -0.999529418f, 0.036807223f, -0.999322385f, + 0.042938257f, -0.999077728f, 0.049067674f, -0.998795456f, 0.055195244f, + -0.998475581f, 0.061320736f, -0.998118113f, 0.067443920f, -0.997723067f, + 0.073564564f, -0.997290457f, 0.079682438f, -0.996820299f, 0.085797312f, + -0.996312612f, 0.091908956f, -0.995767414f, 0.098017140f, -0.995184727f, + 0.104121634f, -0.994564571f, 0.110222207f, -0.993906970f, 0.116318631f, + -0.993211949f, 0.122410675f, -0.992479535f, 0.128498111f, -0.991709754f, + 0.134580709f, -0.990902635f, 0.140658239f, -0.990058210f, 0.146730474f, + -0.989176510f, 0.152797185f, -0.988257568f, 0.158858143f, -0.987301418f, + 0.164913120f, -0.986308097f, 0.170961889f, -0.985277642f, 0.177004220f, + -0.984210092f, 0.183039888f, -0.983105487f, 0.189068664f, -0.981963869f, + 0.195090322f, -0.980785280f, 0.201104635f, -0.979569766f, 0.207111376f, + -0.978317371f, 0.213110320f, -0.977028143f, 0.219101240f, -0.975702130f, + 0.225083911f, -0.974339383f, 0.231058108f, -0.972939952f, 0.237023606f, + -0.971503891f, 0.242980180f, -0.970031253f, 0.248927606f, -0.968522094f, + 0.254865660f, -0.966976471f, 0.260794118f, -0.965394442f, 0.266712757f, + -0.963776066f, 0.272621355f, -0.962121404f, 0.278519689f, -0.960430519f, + 0.284407537f, -0.958703475f, 0.290284677f, -0.956940336f, 0.296150888f, + -0.955141168f, 0.302005949f, -0.953306040f, 0.307849640f, -0.951435021f, + 0.313681740f, -0.949528181f, 0.319502031f, -0.947585591f, 0.325310292f, + -0.945607325f, 0.331106306f, -0.943593458f, 0.336889853f, -0.941544065f, + 0.342660717f, -0.939459224f, 0.348418680f, -0.937339012f, 0.354163525f, + -0.935183510f, 0.359895037f, -0.932992799f, 0.365612998f, -0.930766961f, + 0.371317194f, -0.928506080f, 0.377007410f, -0.926210242f, 0.382683432f, + -0.923879533f, 0.388345047f, -0.921514039f, 0.393992040f, -0.919113852f, + 0.399624200f, -0.916679060f, 0.405241314f, -0.914209756f, 0.410843171f, + -0.911706032f, 0.416429560f, -0.909167983f, 0.422000271f, -0.906595705f, + 0.427555093f, -0.903989293f, 0.433093819f, -0.901348847f, 0.438616239f, + -0.898674466f, 0.444122145f, -0.895966250f, 0.449611330f, -0.893224301f, + 0.455083587f, -0.890448723f, 0.460538711f, -0.887639620f, 0.465976496f, + -0.884797098f, 0.471396737f, -0.881921264f, 0.476799230f, -0.879012226f, + 0.482183772f, -0.876070094f, 0.487550160f, -0.873094978f, 0.492898192f, + -0.870086991f, 0.498227667f, -0.867046246f, 0.503538384f, -0.863972856f, + 0.508830143f, -0.860866939f, 0.514102744f, -0.857728610f, 0.519355990f, + -0.854557988f, 0.524589683f, -0.851355193f, 0.529803625f, -0.848120345f, + 0.534997620f, -0.844853565f, 0.540171473f, -0.841554977f, 0.545324988f, + -0.838224706f, 0.550457973f, -0.834862875f, 0.555570233f, -0.831469612f, + 0.560661576f, -0.828045045f, 0.565731811f, -0.824589303f, 0.570780746f, + -0.821102515f, 0.575808191f, -0.817584813f, 0.580813958f, -0.814036330f, + 0.585797857f, -0.810457198f, 0.590759702f, -0.806847554f, 0.595699304f, + -0.803207531f, 0.600616479f, -0.799537269f, 0.605511041f, -0.795836905f, + 0.610382806f, -0.792106577f, 0.615231591f, -0.788346428f, 0.620057212f, + -0.784556597f, 0.624859488f, -0.780737229f, 0.629638239f, -0.776888466f, + 0.634393284f, -0.773010453f, 0.639124445f, -0.769103338f, 0.643831543f, + -0.765167266f, 0.648514401f, -0.761202385f, 0.653172843f, -0.757208847f, + 0.657806693f, -0.753186799f, 0.662415778f, -0.749136395f, 0.666999922f, + -0.745057785f, 0.671558955f, -0.740951125f, 0.676092704f, -0.736816569f, + 0.680600998f, -0.732654272f, 0.685083668f, -0.728464390f, 0.689540545f, + -0.724247083f, 0.693971461f, -0.720002508f, 0.698376249f, -0.715730825f, + 0.702754744f, -0.711432196f, 0.707106781f, -0.707106781f, 0.711432196f, + -0.702754744f, 0.715730825f, -0.698376249f, 0.720002508f, -0.693971461f, + 0.724247083f, -0.689540545f, 0.728464390f, -0.685083668f, 0.732654272f, + -0.680600998f, 0.736816569f, -0.676092704f, 0.740951125f, -0.671558955f, + 0.745057785f, -0.666999922f, 0.749136395f, -0.662415778f, 0.753186799f, + -0.657806693f, 0.757208847f, -0.653172843f, 0.761202385f, -0.648514401f, + 0.765167266f, -0.643831543f, 0.769103338f, -0.639124445f, 0.773010453f, + -0.634393284f, 0.776888466f, -0.629638239f, 0.780737229f, -0.624859488f, + 0.784556597f, -0.620057212f, 0.788346428f, -0.615231591f, 0.792106577f, + -0.610382806f, 0.795836905f, -0.605511041f, 0.799537269f, -0.600616479f, + 0.803207531f, -0.595699304f, 0.806847554f, -0.590759702f, 0.810457198f, + -0.585797857f, 0.814036330f, -0.580813958f, 0.817584813f, -0.575808191f, + 0.821102515f, -0.570780746f, 0.824589303f, -0.565731811f, 0.828045045f, + -0.560661576f, 0.831469612f, -0.555570233f, 0.834862875f, -0.550457973f, + 0.838224706f, -0.545324988f, 0.841554977f, -0.540171473f, 0.844853565f, + -0.534997620f, 0.848120345f, -0.529803625f, 0.851355193f, -0.524589683f, + 0.854557988f, -0.519355990f, 0.857728610f, -0.514102744f, 0.860866939f, + -0.508830143f, 0.863972856f, -0.503538384f, 0.867046246f, -0.498227667f, + 0.870086991f, -0.492898192f, 0.873094978f, -0.487550160f, 0.876070094f, + -0.482183772f, 0.879012226f, -0.476799230f, 0.881921264f, -0.471396737f, + 0.884797098f, -0.465976496f, 0.887639620f, -0.460538711f, 0.890448723f, + -0.455083587f, 0.893224301f, -0.449611330f, 0.895966250f, -0.444122145f, + 0.898674466f, -0.438616239f, 0.901348847f, -0.433093819f, 0.903989293f, + -0.427555093f, 0.906595705f, -0.422000271f, 0.909167983f, -0.416429560f, + 0.911706032f, -0.410843171f, 0.914209756f, -0.405241314f, 0.916679060f, + -0.399624200f, 0.919113852f, -0.393992040f, 0.921514039f, -0.388345047f, + 0.923879533f, -0.382683432f, 0.926210242f, -0.377007410f, 0.928506080f, + -0.371317194f, 0.930766961f, -0.365612998f, 0.932992799f, -0.359895037f, + 0.935183510f, -0.354163525f, 0.937339012f, -0.348418680f, 0.939459224f, + -0.342660717f, 0.941544065f, -0.336889853f, 0.943593458f, -0.331106306f, + 0.945607325f, -0.325310292f, 0.947585591f, -0.319502031f, 0.949528181f, + -0.313681740f, 0.951435021f, -0.307849640f, 0.953306040f, -0.302005949f, + 0.955141168f, -0.296150888f, 0.956940336f, -0.290284677f, 0.958703475f, + -0.284407537f, 0.960430519f, -0.278519689f, 0.962121404f, -0.272621355f, + 0.963776066f, -0.266712757f, 0.965394442f, -0.260794118f, 0.966976471f, + -0.254865660f, 0.968522094f, -0.248927606f, 0.970031253f, -0.242980180f, + 0.971503891f, -0.237023606f, 0.972939952f, -0.231058108f, 0.974339383f, + -0.225083911f, 0.975702130f, -0.219101240f, 0.977028143f, -0.213110320f, + 0.978317371f, -0.207111376f, 0.979569766f, -0.201104635f, 0.980785280f, + -0.195090322f, 0.981963869f, -0.189068664f, 0.983105487f, -0.183039888f, + 0.984210092f, -0.177004220f, 0.985277642f, -0.170961889f, 0.986308097f, + -0.164913120f, 0.987301418f, -0.158858143f, 0.988257568f, -0.152797185f, + 0.989176510f, -0.146730474f, 0.990058210f, -0.140658239f, 0.990902635f, + -0.134580709f, 0.991709754f, -0.128498111f, 0.992479535f, -0.122410675f, + 0.993211949f, -0.116318631f, 0.993906970f, -0.110222207f, 0.994564571f, + -0.104121634f, 0.995184727f, -0.098017140f, 0.995767414f, -0.091908956f, + 0.996312612f, -0.085797312f, 0.996820299f, -0.079682438f, 0.997290457f, + -0.073564564f, 0.997723067f, -0.067443920f, 0.998118113f, -0.061320736f, + 0.998475581f, -0.055195244f, 0.998795456f, -0.049067674f, 0.999077728f, + -0.042938257f, 0.999322385f, -0.036807223f, 0.999529418f, -0.030674803f, + 0.999698819f, -0.024541229f, 0.999830582f, -0.018406730f, 0.999924702f, + -0.012271538f, 0.999981175f, -0.006135885f}; /** @par @@ -2331,8 +1098,8 @@ const float32_t twiddleCoef_1024[2048] = { @par
for (i = 0; i< N/; i++)
   {
- 	twiddleCoef[2*i]   = cos(i * 2*PI/(float)N);
- 	twiddleCoef[2*i+1] = sin(i * 2*PI/(float)N);
+        twiddleCoef[2*i]   = cos(i * 2*PI/(float)N);
+        twiddleCoef[2*i+1] = sin(i * 2*PI/(float)N);
   } 
@par where N = 2048, PI = 3.14159265358979 @@ -2340,2055 +1107,826 @@ const float32_t twiddleCoef_1024[2048] = { Cos and Sin values are in interleaved fashion */ const float32_t twiddleCoef_2048[4096] = { - 1.000000000f, 0.000000000f, - 0.999995294f, 0.003067957f, - 0.999981175f, 0.006135885f, - 0.999957645f, 0.009203755f, - 0.999924702f, 0.012271538f, - 0.999882347f, 0.015339206f, - 0.999830582f, 0.018406730f, - 0.999769405f, 0.021474080f, - 0.999698819f, 0.024541229f, - 0.999618822f, 0.027608146f, - 0.999529418f, 0.030674803f, - 0.999430605f, 0.033741172f, - 0.999322385f, 0.036807223f, - 0.999204759f, 0.039872928f, - 0.999077728f, 0.042938257f, - 0.998941293f, 0.046003182f, - 0.998795456f, 0.049067674f, - 0.998640218f, 0.052131705f, - 0.998475581f, 0.055195244f, - 0.998301545f, 0.058258265f, - 0.998118113f, 0.061320736f, - 0.997925286f, 0.064382631f, - 0.997723067f, 0.067443920f, - 0.997511456f, 0.070504573f, - 0.997290457f, 0.073564564f, - 0.997060070f, 0.076623861f, - 0.996820299f, 0.079682438f, - 0.996571146f, 0.082740265f, - 0.996312612f, 0.085797312f, - 0.996044701f, 0.088853553f, - 0.995767414f, 0.091908956f, - 0.995480755f, 0.094963495f, - 0.995184727f, 0.098017140f, - 0.994879331f, 0.101069863f, - 0.994564571f, 0.104121634f, - 0.994240449f, 0.107172425f, - 0.993906970f, 0.110222207f, - 0.993564136f, 0.113270952f, - 0.993211949f, 0.116318631f, - 0.992850414f, 0.119365215f, - 0.992479535f, 0.122410675f, - 0.992099313f, 0.125454983f, - 0.991709754f, 0.128498111f, - 0.991310860f, 0.131540029f, - 0.990902635f, 0.134580709f, - 0.990485084f, 0.137620122f, - 0.990058210f, 0.140658239f, - 0.989622017f, 0.143695033f, - 0.989176510f, 0.146730474f, - 0.988721692f, 0.149764535f, - 0.988257568f, 0.152797185f, - 0.987784142f, 0.155828398f, - 0.987301418f, 0.158858143f, - 0.986809402f, 0.161886394f, - 0.986308097f, 0.164913120f, - 0.985797509f, 0.167938295f, - 0.985277642f, 0.170961889f, - 0.984748502f, 0.173983873f, - 0.984210092f, 0.177004220f, - 0.983662419f, 0.180022901f, - 0.983105487f, 0.183039888f, - 0.982539302f, 0.186055152f, - 0.981963869f, 0.189068664f, - 0.981379193f, 0.192080397f, - 0.980785280f, 0.195090322f, - 0.980182136f, 0.198098411f, - 0.979569766f, 0.201104635f, - 0.978948175f, 0.204108966f, - 0.978317371f, 0.207111376f, - 0.977677358f, 0.210111837f, - 0.977028143f, 0.213110320f, - 0.976369731f, 0.216106797f, - 0.975702130f, 0.219101240f, - 0.975025345f, 0.222093621f, - 0.974339383f, 0.225083911f, - 0.973644250f, 0.228072083f, - 0.972939952f, 0.231058108f, - 0.972226497f, 0.234041959f, - 0.971503891f, 0.237023606f, - 0.970772141f, 0.240003022f, - 0.970031253f, 0.242980180f, - 0.969281235f, 0.245955050f, - 0.968522094f, 0.248927606f, - 0.967753837f, 0.251897818f, - 0.966976471f, 0.254865660f, - 0.966190003f, 0.257831102f, - 0.965394442f, 0.260794118f, - 0.964589793f, 0.263754679f, - 0.963776066f, 0.266712757f, - 0.962953267f, 0.269668326f, - 0.962121404f, 0.272621355f, - 0.961280486f, 0.275571819f, - 0.960430519f, 0.278519689f, - 0.959571513f, 0.281464938f, - 0.958703475f, 0.284407537f, - 0.957826413f, 0.287347460f, - 0.956940336f, 0.290284677f, - 0.956045251f, 0.293219163f, - 0.955141168f, 0.296150888f, - 0.954228095f, 0.299079826f, - 0.953306040f, 0.302005949f, - 0.952375013f, 0.304929230f, - 0.951435021f, 0.307849640f, - 0.950486074f, 0.310767153f, - 0.949528181f, 0.313681740f, - 0.948561350f, 0.316593376f, - 0.947585591f, 0.319502031f, - 0.946600913f, 0.322407679f, - 0.945607325f, 0.325310292f, - 0.944604837f, 0.328209844f, - 0.943593458f, 0.331106306f, - 0.942573198f, 0.333999651f, - 0.941544065f, 0.336889853f, - 0.940506071f, 0.339776884f, - 0.939459224f, 0.342660717f, - 0.938403534f, 0.345541325f, - 0.937339012f, 0.348418680f, - 0.936265667f, 0.351292756f, - 0.935183510f, 0.354163525f, - 0.934092550f, 0.357030961f, - 0.932992799f, 0.359895037f, - 0.931884266f, 0.362755724f, - 0.930766961f, 0.365612998f, - 0.929640896f, 0.368466830f, - 0.928506080f, 0.371317194f, - 0.927362526f, 0.374164063f, - 0.926210242f, 0.377007410f, - 0.925049241f, 0.379847209f, - 0.923879533f, 0.382683432f, - 0.922701128f, 0.385516054f, - 0.921514039f, 0.388345047f, - 0.920318277f, 0.391170384f, - 0.919113852f, 0.393992040f, - 0.917900776f, 0.396809987f, - 0.916679060f, 0.399624200f, - 0.915448716f, 0.402434651f, - 0.914209756f, 0.405241314f, - 0.912962190f, 0.408044163f, - 0.911706032f, 0.410843171f, - 0.910441292f, 0.413638312f, - 0.909167983f, 0.416429560f, - 0.907886116f, 0.419216888f, - 0.906595705f, 0.422000271f, - 0.905296759f, 0.424779681f, - 0.903989293f, 0.427555093f, - 0.902673318f, 0.430326481f, - 0.901348847f, 0.433093819f, - 0.900015892f, 0.435857080f, - 0.898674466f, 0.438616239f, - 0.897324581f, 0.441371269f, - 0.895966250f, 0.444122145f, - 0.894599486f, 0.446868840f, - 0.893224301f, 0.449611330f, - 0.891840709f, 0.452349587f, - 0.890448723f, 0.455083587f, - 0.889048356f, 0.457813304f, - 0.887639620f, 0.460538711f, - 0.886222530f, 0.463259784f, - 0.884797098f, 0.465976496f, - 0.883363339f, 0.468688822f, - 0.881921264f, 0.471396737f, - 0.880470889f, 0.474100215f, - 0.879012226f, 0.476799230f, - 0.877545290f, 0.479493758f, - 0.876070094f, 0.482183772f, - 0.874586652f, 0.484869248f, - 0.873094978f, 0.487550160f, - 0.871595087f, 0.490226483f, - 0.870086991f, 0.492898192f, - 0.868570706f, 0.495565262f, - 0.867046246f, 0.498227667f, - 0.865513624f, 0.500885383f, - 0.863972856f, 0.503538384f, - 0.862423956f, 0.506186645f, - 0.860866939f, 0.508830143f, - 0.859301818f, 0.511468850f, - 0.857728610f, 0.514102744f, - 0.856147328f, 0.516731799f, - 0.854557988f, 0.519355990f, - 0.852960605f, 0.521975293f, - 0.851355193f, 0.524589683f, - 0.849741768f, 0.527199135f, - 0.848120345f, 0.529803625f, - 0.846490939f, 0.532403128f, - 0.844853565f, 0.534997620f, - 0.843208240f, 0.537587076f, - 0.841554977f, 0.540171473f, - 0.839893794f, 0.542750785f, - 0.838224706f, 0.545324988f, - 0.836547727f, 0.547894059f, - 0.834862875f, 0.550457973f, - 0.833170165f, 0.553016706f, - 0.831469612f, 0.555570233f, - 0.829761234f, 0.558118531f, - 0.828045045f, 0.560661576f, - 0.826321063f, 0.563199344f, - 0.824589303f, 0.565731811f, - 0.822849781f, 0.568258953f, - 0.821102515f, 0.570780746f, - 0.819347520f, 0.573297167f, - 0.817584813f, 0.575808191f, - 0.815814411f, 0.578313796f, - 0.814036330f, 0.580813958f, - 0.812250587f, 0.583308653f, - 0.810457198f, 0.585797857f, - 0.808656182f, 0.588281548f, - 0.806847554f, 0.590759702f, - 0.805031331f, 0.593232295f, - 0.803207531f, 0.595699304f, - 0.801376172f, 0.598160707f, - 0.799537269f, 0.600616479f, - 0.797690841f, 0.603066599f, - 0.795836905f, 0.605511041f, - 0.793975478f, 0.607949785f, - 0.792106577f, 0.610382806f, - 0.790230221f, 0.612810082f, - 0.788346428f, 0.615231591f, - 0.786455214f, 0.617647308f, - 0.784556597f, 0.620057212f, - 0.782650596f, 0.622461279f, - 0.780737229f, 0.624859488f, - 0.778816512f, 0.627251815f, - 0.776888466f, 0.629638239f, - 0.774953107f, 0.632018736f, - 0.773010453f, 0.634393284f, - 0.771060524f, 0.636761861f, - 0.769103338f, 0.639124445f, - 0.767138912f, 0.641481013f, - 0.765167266f, 0.643831543f, - 0.763188417f, 0.646176013f, - 0.761202385f, 0.648514401f, - 0.759209189f, 0.650846685f, - 0.757208847f, 0.653172843f, - 0.755201377f, 0.655492853f, - 0.753186799f, 0.657806693f, - 0.751165132f, 0.660114342f, - 0.749136395f, 0.662415778f, - 0.747100606f, 0.664710978f, - 0.745057785f, 0.666999922f, - 0.743007952f, 0.669282588f, - 0.740951125f, 0.671558955f, - 0.738887324f, 0.673829000f, - 0.736816569f, 0.676092704f, - 0.734738878f, 0.678350043f, - 0.732654272f, 0.680600998f, - 0.730562769f, 0.682845546f, - 0.728464390f, 0.685083668f, - 0.726359155f, 0.687315341f, - 0.724247083f, 0.689540545f, - 0.722128194f, 0.691759258f, - 0.720002508f, 0.693971461f, - 0.717870045f, 0.696177131f, - 0.715730825f, 0.698376249f, - 0.713584869f, 0.700568794f, - 0.711432196f, 0.702754744f, - 0.709272826f, 0.704934080f, - 0.707106781f, 0.707106781f, - 0.704934080f, 0.709272826f, - 0.702754744f, 0.711432196f, - 0.700568794f, 0.713584869f, - 0.698376249f, 0.715730825f, - 0.696177131f, 0.717870045f, - 0.693971461f, 0.720002508f, - 0.691759258f, 0.722128194f, - 0.689540545f, 0.724247083f, - 0.687315341f, 0.726359155f, - 0.685083668f, 0.728464390f, - 0.682845546f, 0.730562769f, - 0.680600998f, 0.732654272f, - 0.678350043f, 0.734738878f, - 0.676092704f, 0.736816569f, - 0.673829000f, 0.738887324f, - 0.671558955f, 0.740951125f, - 0.669282588f, 0.743007952f, - 0.666999922f, 0.745057785f, - 0.664710978f, 0.747100606f, - 0.662415778f, 0.749136395f, - 0.660114342f, 0.751165132f, - 0.657806693f, 0.753186799f, - 0.655492853f, 0.755201377f, - 0.653172843f, 0.757208847f, - 0.650846685f, 0.759209189f, - 0.648514401f, 0.761202385f, - 0.646176013f, 0.763188417f, - 0.643831543f, 0.765167266f, - 0.641481013f, 0.767138912f, - 0.639124445f, 0.769103338f, - 0.636761861f, 0.771060524f, - 0.634393284f, 0.773010453f, - 0.632018736f, 0.774953107f, - 0.629638239f, 0.776888466f, - 0.627251815f, 0.778816512f, - 0.624859488f, 0.780737229f, - 0.622461279f, 0.782650596f, - 0.620057212f, 0.784556597f, - 0.617647308f, 0.786455214f, - 0.615231591f, 0.788346428f, - 0.612810082f, 0.790230221f, - 0.610382806f, 0.792106577f, - 0.607949785f, 0.793975478f, - 0.605511041f, 0.795836905f, - 0.603066599f, 0.797690841f, - 0.600616479f, 0.799537269f, - 0.598160707f, 0.801376172f, - 0.595699304f, 0.803207531f, - 0.593232295f, 0.805031331f, - 0.590759702f, 0.806847554f, - 0.588281548f, 0.808656182f, - 0.585797857f, 0.810457198f, - 0.583308653f, 0.812250587f, - 0.580813958f, 0.814036330f, - 0.578313796f, 0.815814411f, - 0.575808191f, 0.817584813f, - 0.573297167f, 0.819347520f, - 0.570780746f, 0.821102515f, - 0.568258953f, 0.822849781f, - 0.565731811f, 0.824589303f, - 0.563199344f, 0.826321063f, - 0.560661576f, 0.828045045f, - 0.558118531f, 0.829761234f, - 0.555570233f, 0.831469612f, - 0.553016706f, 0.833170165f, - 0.550457973f, 0.834862875f, - 0.547894059f, 0.836547727f, - 0.545324988f, 0.838224706f, - 0.542750785f, 0.839893794f, - 0.540171473f, 0.841554977f, - 0.537587076f, 0.843208240f, - 0.534997620f, 0.844853565f, - 0.532403128f, 0.846490939f, - 0.529803625f, 0.848120345f, - 0.527199135f, 0.849741768f, - 0.524589683f, 0.851355193f, - 0.521975293f, 0.852960605f, - 0.519355990f, 0.854557988f, - 0.516731799f, 0.856147328f, - 0.514102744f, 0.857728610f, - 0.511468850f, 0.859301818f, - 0.508830143f, 0.860866939f, - 0.506186645f, 0.862423956f, - 0.503538384f, 0.863972856f, - 0.500885383f, 0.865513624f, - 0.498227667f, 0.867046246f, - 0.495565262f, 0.868570706f, - 0.492898192f, 0.870086991f, - 0.490226483f, 0.871595087f, - 0.487550160f, 0.873094978f, - 0.484869248f, 0.874586652f, - 0.482183772f, 0.876070094f, - 0.479493758f, 0.877545290f, - 0.476799230f, 0.879012226f, - 0.474100215f, 0.880470889f, - 0.471396737f, 0.881921264f, - 0.468688822f, 0.883363339f, - 0.465976496f, 0.884797098f, - 0.463259784f, 0.886222530f, - 0.460538711f, 0.887639620f, - 0.457813304f, 0.889048356f, - 0.455083587f, 0.890448723f, - 0.452349587f, 0.891840709f, - 0.449611330f, 0.893224301f, - 0.446868840f, 0.894599486f, - 0.444122145f, 0.895966250f, - 0.441371269f, 0.897324581f, - 0.438616239f, 0.898674466f, - 0.435857080f, 0.900015892f, - 0.433093819f, 0.901348847f, - 0.430326481f, 0.902673318f, - 0.427555093f, 0.903989293f, - 0.424779681f, 0.905296759f, - 0.422000271f, 0.906595705f, - 0.419216888f, 0.907886116f, - 0.416429560f, 0.909167983f, - 0.413638312f, 0.910441292f, - 0.410843171f, 0.911706032f, - 0.408044163f, 0.912962190f, - 0.405241314f, 0.914209756f, - 0.402434651f, 0.915448716f, - 0.399624200f, 0.916679060f, - 0.396809987f, 0.917900776f, - 0.393992040f, 0.919113852f, - 0.391170384f, 0.920318277f, - 0.388345047f, 0.921514039f, - 0.385516054f, 0.922701128f, - 0.382683432f, 0.923879533f, - 0.379847209f, 0.925049241f, - 0.377007410f, 0.926210242f, - 0.374164063f, 0.927362526f, - 0.371317194f, 0.928506080f, - 0.368466830f, 0.929640896f, - 0.365612998f, 0.930766961f, - 0.362755724f, 0.931884266f, - 0.359895037f, 0.932992799f, - 0.357030961f, 0.934092550f, - 0.354163525f, 0.935183510f, - 0.351292756f, 0.936265667f, - 0.348418680f, 0.937339012f, - 0.345541325f, 0.938403534f, - 0.342660717f, 0.939459224f, - 0.339776884f, 0.940506071f, - 0.336889853f, 0.941544065f, - 0.333999651f, 0.942573198f, - 0.331106306f, 0.943593458f, - 0.328209844f, 0.944604837f, - 0.325310292f, 0.945607325f, - 0.322407679f, 0.946600913f, - 0.319502031f, 0.947585591f, - 0.316593376f, 0.948561350f, - 0.313681740f, 0.949528181f, - 0.310767153f, 0.950486074f, - 0.307849640f, 0.951435021f, - 0.304929230f, 0.952375013f, - 0.302005949f, 0.953306040f, - 0.299079826f, 0.954228095f, - 0.296150888f, 0.955141168f, - 0.293219163f, 0.956045251f, - 0.290284677f, 0.956940336f, - 0.287347460f, 0.957826413f, - 0.284407537f, 0.958703475f, - 0.281464938f, 0.959571513f, - 0.278519689f, 0.960430519f, - 0.275571819f, 0.961280486f, - 0.272621355f, 0.962121404f, - 0.269668326f, 0.962953267f, - 0.266712757f, 0.963776066f, - 0.263754679f, 0.964589793f, - 0.260794118f, 0.965394442f, - 0.257831102f, 0.966190003f, - 0.254865660f, 0.966976471f, - 0.251897818f, 0.967753837f, - 0.248927606f, 0.968522094f, - 0.245955050f, 0.969281235f, - 0.242980180f, 0.970031253f, - 0.240003022f, 0.970772141f, - 0.237023606f, 0.971503891f, - 0.234041959f, 0.972226497f, - 0.231058108f, 0.972939952f, - 0.228072083f, 0.973644250f, - 0.225083911f, 0.974339383f, - 0.222093621f, 0.975025345f, - 0.219101240f, 0.975702130f, - 0.216106797f, 0.976369731f, - 0.213110320f, 0.977028143f, - 0.210111837f, 0.977677358f, - 0.207111376f, 0.978317371f, - 0.204108966f, 0.978948175f, - 0.201104635f, 0.979569766f, - 0.198098411f, 0.980182136f, - 0.195090322f, 0.980785280f, - 0.192080397f, 0.981379193f, - 0.189068664f, 0.981963869f, - 0.186055152f, 0.982539302f, - 0.183039888f, 0.983105487f, - 0.180022901f, 0.983662419f, - 0.177004220f, 0.984210092f, - 0.173983873f, 0.984748502f, - 0.170961889f, 0.985277642f, - 0.167938295f, 0.985797509f, - 0.164913120f, 0.986308097f, - 0.161886394f, 0.986809402f, - 0.158858143f, 0.987301418f, - 0.155828398f, 0.987784142f, - 0.152797185f, 0.988257568f, - 0.149764535f, 0.988721692f, - 0.146730474f, 0.989176510f, - 0.143695033f, 0.989622017f, - 0.140658239f, 0.990058210f, - 0.137620122f, 0.990485084f, - 0.134580709f, 0.990902635f, - 0.131540029f, 0.991310860f, - 0.128498111f, 0.991709754f, - 0.125454983f, 0.992099313f, - 0.122410675f, 0.992479535f, - 0.119365215f, 0.992850414f, - 0.116318631f, 0.993211949f, - 0.113270952f, 0.993564136f, - 0.110222207f, 0.993906970f, - 0.107172425f, 0.994240449f, - 0.104121634f, 0.994564571f, - 0.101069863f, 0.994879331f, - 0.098017140f, 0.995184727f, - 0.094963495f, 0.995480755f, - 0.091908956f, 0.995767414f, - 0.088853553f, 0.996044701f, - 0.085797312f, 0.996312612f, - 0.082740265f, 0.996571146f, - 0.079682438f, 0.996820299f, - 0.076623861f, 0.997060070f, - 0.073564564f, 0.997290457f, - 0.070504573f, 0.997511456f, - 0.067443920f, 0.997723067f, - 0.064382631f, 0.997925286f, - 0.061320736f, 0.998118113f, - 0.058258265f, 0.998301545f, - 0.055195244f, 0.998475581f, - 0.052131705f, 0.998640218f, - 0.049067674f, 0.998795456f, - 0.046003182f, 0.998941293f, - 0.042938257f, 0.999077728f, - 0.039872928f, 0.999204759f, - 0.036807223f, 0.999322385f, - 0.033741172f, 0.999430605f, - 0.030674803f, 0.999529418f, - 0.027608146f, 0.999618822f, - 0.024541229f, 0.999698819f, - 0.021474080f, 0.999769405f, - 0.018406730f, 0.999830582f, - 0.015339206f, 0.999882347f, - 0.012271538f, 0.999924702f, - 0.009203755f, 0.999957645f, - 0.006135885f, 0.999981175f, - 0.003067957f, 0.999995294f, - 0.000000000f, 1.000000000f, - -0.003067957f, 0.999995294f, - -0.006135885f, 0.999981175f, - -0.009203755f, 0.999957645f, - -0.012271538f, 0.999924702f, - -0.015339206f, 0.999882347f, - -0.018406730f, 0.999830582f, - -0.021474080f, 0.999769405f, - -0.024541229f, 0.999698819f, - -0.027608146f, 0.999618822f, - -0.030674803f, 0.999529418f, - -0.033741172f, 0.999430605f, - -0.036807223f, 0.999322385f, - -0.039872928f, 0.999204759f, - -0.042938257f, 0.999077728f, - -0.046003182f, 0.998941293f, - -0.049067674f, 0.998795456f, - -0.052131705f, 0.998640218f, - -0.055195244f, 0.998475581f, - -0.058258265f, 0.998301545f, - -0.061320736f, 0.998118113f, - -0.064382631f, 0.997925286f, - -0.067443920f, 0.997723067f, - -0.070504573f, 0.997511456f, - -0.073564564f, 0.997290457f, - -0.076623861f, 0.997060070f, - -0.079682438f, 0.996820299f, - -0.082740265f, 0.996571146f, - -0.085797312f, 0.996312612f, - -0.088853553f, 0.996044701f, - -0.091908956f, 0.995767414f, - -0.094963495f, 0.995480755f, - -0.098017140f, 0.995184727f, - -0.101069863f, 0.994879331f, - -0.104121634f, 0.994564571f, - -0.107172425f, 0.994240449f, - -0.110222207f, 0.993906970f, - -0.113270952f, 0.993564136f, - -0.116318631f, 0.993211949f, - -0.119365215f, 0.992850414f, - -0.122410675f, 0.992479535f, - -0.125454983f, 0.992099313f, - -0.128498111f, 0.991709754f, - -0.131540029f, 0.991310860f, - -0.134580709f, 0.990902635f, - -0.137620122f, 0.990485084f, - -0.140658239f, 0.990058210f, - -0.143695033f, 0.989622017f, - -0.146730474f, 0.989176510f, - -0.149764535f, 0.988721692f, - -0.152797185f, 0.988257568f, - -0.155828398f, 0.987784142f, - -0.158858143f, 0.987301418f, - -0.161886394f, 0.986809402f, - -0.164913120f, 0.986308097f, - -0.167938295f, 0.985797509f, - -0.170961889f, 0.985277642f, - -0.173983873f, 0.984748502f, - -0.177004220f, 0.984210092f, - -0.180022901f, 0.983662419f, - -0.183039888f, 0.983105487f, - -0.186055152f, 0.982539302f, - -0.189068664f, 0.981963869f, - -0.192080397f, 0.981379193f, - -0.195090322f, 0.980785280f, - -0.198098411f, 0.980182136f, - -0.201104635f, 0.979569766f, - -0.204108966f, 0.978948175f, - -0.207111376f, 0.978317371f, - -0.210111837f, 0.977677358f, - -0.213110320f, 0.977028143f, - -0.216106797f, 0.976369731f, - -0.219101240f, 0.975702130f, - -0.222093621f, 0.975025345f, - -0.225083911f, 0.974339383f, - -0.228072083f, 0.973644250f, - -0.231058108f, 0.972939952f, - -0.234041959f, 0.972226497f, - -0.237023606f, 0.971503891f, - -0.240003022f, 0.970772141f, - -0.242980180f, 0.970031253f, - -0.245955050f, 0.969281235f, - -0.248927606f, 0.968522094f, - -0.251897818f, 0.967753837f, - -0.254865660f, 0.966976471f, - -0.257831102f, 0.966190003f, - -0.260794118f, 0.965394442f, - -0.263754679f, 0.964589793f, - -0.266712757f, 0.963776066f, - -0.269668326f, 0.962953267f, - -0.272621355f, 0.962121404f, - -0.275571819f, 0.961280486f, - -0.278519689f, 0.960430519f, - -0.281464938f, 0.959571513f, - -0.284407537f, 0.958703475f, - -0.287347460f, 0.957826413f, - -0.290284677f, 0.956940336f, - -0.293219163f, 0.956045251f, - -0.296150888f, 0.955141168f, - -0.299079826f, 0.954228095f, - -0.302005949f, 0.953306040f, - -0.304929230f, 0.952375013f, - -0.307849640f, 0.951435021f, - -0.310767153f, 0.950486074f, - -0.313681740f, 0.949528181f, - -0.316593376f, 0.948561350f, - -0.319502031f, 0.947585591f, - -0.322407679f, 0.946600913f, - -0.325310292f, 0.945607325f, - -0.328209844f, 0.944604837f, - -0.331106306f, 0.943593458f, - -0.333999651f, 0.942573198f, - -0.336889853f, 0.941544065f, - -0.339776884f, 0.940506071f, - -0.342660717f, 0.939459224f, - -0.345541325f, 0.938403534f, - -0.348418680f, 0.937339012f, - -0.351292756f, 0.936265667f, - -0.354163525f, 0.935183510f, - -0.357030961f, 0.934092550f, - -0.359895037f, 0.932992799f, - -0.362755724f, 0.931884266f, - -0.365612998f, 0.930766961f, - -0.368466830f, 0.929640896f, - -0.371317194f, 0.928506080f, - -0.374164063f, 0.927362526f, - -0.377007410f, 0.926210242f, - -0.379847209f, 0.925049241f, - -0.382683432f, 0.923879533f, - -0.385516054f, 0.922701128f, - -0.388345047f, 0.921514039f, - -0.391170384f, 0.920318277f, - -0.393992040f, 0.919113852f, - -0.396809987f, 0.917900776f, - -0.399624200f, 0.916679060f, - -0.402434651f, 0.915448716f, - -0.405241314f, 0.914209756f, - -0.408044163f, 0.912962190f, - -0.410843171f, 0.911706032f, - -0.413638312f, 0.910441292f, - -0.416429560f, 0.909167983f, - -0.419216888f, 0.907886116f, - -0.422000271f, 0.906595705f, - -0.424779681f, 0.905296759f, - -0.427555093f, 0.903989293f, - -0.430326481f, 0.902673318f, - -0.433093819f, 0.901348847f, - -0.435857080f, 0.900015892f, - -0.438616239f, 0.898674466f, - -0.441371269f, 0.897324581f, - -0.444122145f, 0.895966250f, - -0.446868840f, 0.894599486f, - -0.449611330f, 0.893224301f, - -0.452349587f, 0.891840709f, - -0.455083587f, 0.890448723f, - -0.457813304f, 0.889048356f, - -0.460538711f, 0.887639620f, - -0.463259784f, 0.886222530f, - -0.465976496f, 0.884797098f, - -0.468688822f, 0.883363339f, - -0.471396737f, 0.881921264f, - -0.474100215f, 0.880470889f, - -0.476799230f, 0.879012226f, - -0.479493758f, 0.877545290f, - -0.482183772f, 0.876070094f, - -0.484869248f, 0.874586652f, - -0.487550160f, 0.873094978f, - -0.490226483f, 0.871595087f, - -0.492898192f, 0.870086991f, - -0.495565262f, 0.868570706f, - -0.498227667f, 0.867046246f, - -0.500885383f, 0.865513624f, - -0.503538384f, 0.863972856f, - -0.506186645f, 0.862423956f, - -0.508830143f, 0.860866939f, - -0.511468850f, 0.859301818f, - -0.514102744f, 0.857728610f, - -0.516731799f, 0.856147328f, - -0.519355990f, 0.854557988f, - -0.521975293f, 0.852960605f, - -0.524589683f, 0.851355193f, - -0.527199135f, 0.849741768f, - -0.529803625f, 0.848120345f, - -0.532403128f, 0.846490939f, - -0.534997620f, 0.844853565f, - -0.537587076f, 0.843208240f, - -0.540171473f, 0.841554977f, - -0.542750785f, 0.839893794f, - -0.545324988f, 0.838224706f, - -0.547894059f, 0.836547727f, - -0.550457973f, 0.834862875f, - -0.553016706f, 0.833170165f, - -0.555570233f, 0.831469612f, - -0.558118531f, 0.829761234f, - -0.560661576f, 0.828045045f, - -0.563199344f, 0.826321063f, - -0.565731811f, 0.824589303f, - -0.568258953f, 0.822849781f, - -0.570780746f, 0.821102515f, - -0.573297167f, 0.819347520f, - -0.575808191f, 0.817584813f, - -0.578313796f, 0.815814411f, - -0.580813958f, 0.814036330f, - -0.583308653f, 0.812250587f, - -0.585797857f, 0.810457198f, - -0.588281548f, 0.808656182f, - -0.590759702f, 0.806847554f, - -0.593232295f, 0.805031331f, - -0.595699304f, 0.803207531f, - -0.598160707f, 0.801376172f, - -0.600616479f, 0.799537269f, - -0.603066599f, 0.797690841f, - -0.605511041f, 0.795836905f, - -0.607949785f, 0.793975478f, - -0.610382806f, 0.792106577f, - -0.612810082f, 0.790230221f, - -0.615231591f, 0.788346428f, - -0.617647308f, 0.786455214f, - -0.620057212f, 0.784556597f, - -0.622461279f, 0.782650596f, - -0.624859488f, 0.780737229f, - -0.627251815f, 0.778816512f, - -0.629638239f, 0.776888466f, - -0.632018736f, 0.774953107f, - -0.634393284f, 0.773010453f, - -0.636761861f, 0.771060524f, - -0.639124445f, 0.769103338f, - -0.641481013f, 0.767138912f, - -0.643831543f, 0.765167266f, - -0.646176013f, 0.763188417f, - -0.648514401f, 0.761202385f, - -0.650846685f, 0.759209189f, - -0.653172843f, 0.757208847f, - -0.655492853f, 0.755201377f, - -0.657806693f, 0.753186799f, - -0.660114342f, 0.751165132f, - -0.662415778f, 0.749136395f, - -0.664710978f, 0.747100606f, - -0.666999922f, 0.745057785f, - -0.669282588f, 0.743007952f, - -0.671558955f, 0.740951125f, - -0.673829000f, 0.738887324f, - -0.676092704f, 0.736816569f, - -0.678350043f, 0.734738878f, - -0.680600998f, 0.732654272f, - -0.682845546f, 0.730562769f, - -0.685083668f, 0.728464390f, - -0.687315341f, 0.726359155f, - -0.689540545f, 0.724247083f, - -0.691759258f, 0.722128194f, - -0.693971461f, 0.720002508f, - -0.696177131f, 0.717870045f, - -0.698376249f, 0.715730825f, - -0.700568794f, 0.713584869f, - -0.702754744f, 0.711432196f, - -0.704934080f, 0.709272826f, - -0.707106781f, 0.707106781f, - -0.709272826f, 0.704934080f, - -0.711432196f, 0.702754744f, - -0.713584869f, 0.700568794f, - -0.715730825f, 0.698376249f, - -0.717870045f, 0.696177131f, - -0.720002508f, 0.693971461f, - -0.722128194f, 0.691759258f, - -0.724247083f, 0.689540545f, - -0.726359155f, 0.687315341f, - -0.728464390f, 0.685083668f, - -0.730562769f, 0.682845546f, - -0.732654272f, 0.680600998f, - -0.734738878f, 0.678350043f, - -0.736816569f, 0.676092704f, - -0.738887324f, 0.673829000f, - -0.740951125f, 0.671558955f, - -0.743007952f, 0.669282588f, - -0.745057785f, 0.666999922f, - -0.747100606f, 0.664710978f, - -0.749136395f, 0.662415778f, - -0.751165132f, 0.660114342f, - -0.753186799f, 0.657806693f, - -0.755201377f, 0.655492853f, - -0.757208847f, 0.653172843f, - -0.759209189f, 0.650846685f, - -0.761202385f, 0.648514401f, - -0.763188417f, 0.646176013f, - -0.765167266f, 0.643831543f, - -0.767138912f, 0.641481013f, - -0.769103338f, 0.639124445f, - -0.771060524f, 0.636761861f, - -0.773010453f, 0.634393284f, - -0.774953107f, 0.632018736f, - -0.776888466f, 0.629638239f, - -0.778816512f, 0.627251815f, - -0.780737229f, 0.624859488f, - -0.782650596f, 0.622461279f, - -0.784556597f, 0.620057212f, - -0.786455214f, 0.617647308f, - -0.788346428f, 0.615231591f, - -0.790230221f, 0.612810082f, - -0.792106577f, 0.610382806f, - -0.793975478f, 0.607949785f, - -0.795836905f, 0.605511041f, - -0.797690841f, 0.603066599f, - -0.799537269f, 0.600616479f, - -0.801376172f, 0.598160707f, - -0.803207531f, 0.595699304f, - -0.805031331f, 0.593232295f, - -0.806847554f, 0.590759702f, - -0.808656182f, 0.588281548f, - -0.810457198f, 0.585797857f, - -0.812250587f, 0.583308653f, - -0.814036330f, 0.580813958f, - -0.815814411f, 0.578313796f, - -0.817584813f, 0.575808191f, - -0.819347520f, 0.573297167f, - -0.821102515f, 0.570780746f, - -0.822849781f, 0.568258953f, - -0.824589303f, 0.565731811f, - -0.826321063f, 0.563199344f, - -0.828045045f, 0.560661576f, - -0.829761234f, 0.558118531f, - -0.831469612f, 0.555570233f, - -0.833170165f, 0.553016706f, - -0.834862875f, 0.550457973f, - -0.836547727f, 0.547894059f, - -0.838224706f, 0.545324988f, - -0.839893794f, 0.542750785f, - -0.841554977f, 0.540171473f, - -0.843208240f, 0.537587076f, - -0.844853565f, 0.534997620f, - -0.846490939f, 0.532403128f, - -0.848120345f, 0.529803625f, - -0.849741768f, 0.527199135f, - -0.851355193f, 0.524589683f, - -0.852960605f, 0.521975293f, - -0.854557988f, 0.519355990f, - -0.856147328f, 0.516731799f, - -0.857728610f, 0.514102744f, - -0.859301818f, 0.511468850f, - -0.860866939f, 0.508830143f, - -0.862423956f, 0.506186645f, - -0.863972856f, 0.503538384f, - -0.865513624f, 0.500885383f, - -0.867046246f, 0.498227667f, - -0.868570706f, 0.495565262f, - -0.870086991f, 0.492898192f, - -0.871595087f, 0.490226483f, - -0.873094978f, 0.487550160f, - -0.874586652f, 0.484869248f, - -0.876070094f, 0.482183772f, - -0.877545290f, 0.479493758f, - -0.879012226f, 0.476799230f, - -0.880470889f, 0.474100215f, - -0.881921264f, 0.471396737f, - -0.883363339f, 0.468688822f, - -0.884797098f, 0.465976496f, - -0.886222530f, 0.463259784f, - -0.887639620f, 0.460538711f, - -0.889048356f, 0.457813304f, - -0.890448723f, 0.455083587f, - -0.891840709f, 0.452349587f, - -0.893224301f, 0.449611330f, - -0.894599486f, 0.446868840f, - -0.895966250f, 0.444122145f, - -0.897324581f, 0.441371269f, - -0.898674466f, 0.438616239f, - -0.900015892f, 0.435857080f, - -0.901348847f, 0.433093819f, - -0.902673318f, 0.430326481f, - -0.903989293f, 0.427555093f, - -0.905296759f, 0.424779681f, - -0.906595705f, 0.422000271f, - -0.907886116f, 0.419216888f, - -0.909167983f, 0.416429560f, - -0.910441292f, 0.413638312f, - -0.911706032f, 0.410843171f, - -0.912962190f, 0.408044163f, - -0.914209756f, 0.405241314f, - -0.915448716f, 0.402434651f, - -0.916679060f, 0.399624200f, - -0.917900776f, 0.396809987f, - -0.919113852f, 0.393992040f, - -0.920318277f, 0.391170384f, - -0.921514039f, 0.388345047f, - -0.922701128f, 0.385516054f, - -0.923879533f, 0.382683432f, - -0.925049241f, 0.379847209f, - -0.926210242f, 0.377007410f, - -0.927362526f, 0.374164063f, - -0.928506080f, 0.371317194f, - -0.929640896f, 0.368466830f, - -0.930766961f, 0.365612998f, - -0.931884266f, 0.362755724f, - -0.932992799f, 0.359895037f, - -0.934092550f, 0.357030961f, - -0.935183510f, 0.354163525f, - -0.936265667f, 0.351292756f, - -0.937339012f, 0.348418680f, - -0.938403534f, 0.345541325f, - -0.939459224f, 0.342660717f, - -0.940506071f, 0.339776884f, - -0.941544065f, 0.336889853f, - -0.942573198f, 0.333999651f, - -0.943593458f, 0.331106306f, - -0.944604837f, 0.328209844f, - -0.945607325f, 0.325310292f, - -0.946600913f, 0.322407679f, - -0.947585591f, 0.319502031f, - -0.948561350f, 0.316593376f, - -0.949528181f, 0.313681740f, - -0.950486074f, 0.310767153f, - -0.951435021f, 0.307849640f, - -0.952375013f, 0.304929230f, - -0.953306040f, 0.302005949f, - -0.954228095f, 0.299079826f, - -0.955141168f, 0.296150888f, - -0.956045251f, 0.293219163f, - -0.956940336f, 0.290284677f, - -0.957826413f, 0.287347460f, - -0.958703475f, 0.284407537f, - -0.959571513f, 0.281464938f, - -0.960430519f, 0.278519689f, - -0.961280486f, 0.275571819f, - -0.962121404f, 0.272621355f, - -0.962953267f, 0.269668326f, - -0.963776066f, 0.266712757f, - -0.964589793f, 0.263754679f, - -0.965394442f, 0.260794118f, - -0.966190003f, 0.257831102f, - -0.966976471f, 0.254865660f, - -0.967753837f, 0.251897818f, - -0.968522094f, 0.248927606f, - -0.969281235f, 0.245955050f, - -0.970031253f, 0.242980180f, - -0.970772141f, 0.240003022f, - -0.971503891f, 0.237023606f, - -0.972226497f, 0.234041959f, - -0.972939952f, 0.231058108f, - -0.973644250f, 0.228072083f, - -0.974339383f, 0.225083911f, - -0.975025345f, 0.222093621f, - -0.975702130f, 0.219101240f, - -0.976369731f, 0.216106797f, - -0.977028143f, 0.213110320f, - -0.977677358f, 0.210111837f, - -0.978317371f, 0.207111376f, - -0.978948175f, 0.204108966f, - -0.979569766f, 0.201104635f, - -0.980182136f, 0.198098411f, - -0.980785280f, 0.195090322f, - -0.981379193f, 0.192080397f, - -0.981963869f, 0.189068664f, - -0.982539302f, 0.186055152f, - -0.983105487f, 0.183039888f, - -0.983662419f, 0.180022901f, - -0.984210092f, 0.177004220f, - -0.984748502f, 0.173983873f, - -0.985277642f, 0.170961889f, - -0.985797509f, 0.167938295f, - -0.986308097f, 0.164913120f, - -0.986809402f, 0.161886394f, - -0.987301418f, 0.158858143f, - -0.987784142f, 0.155828398f, - -0.988257568f, 0.152797185f, - -0.988721692f, 0.149764535f, - -0.989176510f, 0.146730474f, - -0.989622017f, 0.143695033f, - -0.990058210f, 0.140658239f, - -0.990485084f, 0.137620122f, - -0.990902635f, 0.134580709f, - -0.991310860f, 0.131540029f, - -0.991709754f, 0.128498111f, - -0.992099313f, 0.125454983f, - -0.992479535f, 0.122410675f, - -0.992850414f, 0.119365215f, - -0.993211949f, 0.116318631f, - -0.993564136f, 0.113270952f, - -0.993906970f, 0.110222207f, - -0.994240449f, 0.107172425f, - -0.994564571f, 0.104121634f, - -0.994879331f, 0.101069863f, - -0.995184727f, 0.098017140f, - -0.995480755f, 0.094963495f, - -0.995767414f, 0.091908956f, - -0.996044701f, 0.088853553f, - -0.996312612f, 0.085797312f, - -0.996571146f, 0.082740265f, - -0.996820299f, 0.079682438f, - -0.997060070f, 0.076623861f, - -0.997290457f, 0.073564564f, - -0.997511456f, 0.070504573f, - -0.997723067f, 0.067443920f, - -0.997925286f, 0.064382631f, - -0.998118113f, 0.061320736f, - -0.998301545f, 0.058258265f, - -0.998475581f, 0.055195244f, - -0.998640218f, 0.052131705f, - -0.998795456f, 0.049067674f, - -0.998941293f, 0.046003182f, - -0.999077728f, 0.042938257f, - -0.999204759f, 0.039872928f, - -0.999322385f, 0.036807223f, - -0.999430605f, 0.033741172f, - -0.999529418f, 0.030674803f, - -0.999618822f, 0.027608146f, - -0.999698819f, 0.024541229f, - -0.999769405f, 0.021474080f, - -0.999830582f, 0.018406730f, - -0.999882347f, 0.015339206f, - -0.999924702f, 0.012271538f, - -0.999957645f, 0.009203755f, - -0.999981175f, 0.006135885f, - -0.999995294f, 0.003067957f, - -1.000000000f, 0.000000000f, - -0.999995294f, -0.003067957f, - -0.999981175f, -0.006135885f, - -0.999957645f, -0.009203755f, - -0.999924702f, -0.012271538f, - -0.999882347f, -0.015339206f, - -0.999830582f, -0.018406730f, - -0.999769405f, -0.021474080f, - -0.999698819f, -0.024541229f, - -0.999618822f, -0.027608146f, - -0.999529418f, -0.030674803f, - -0.999430605f, -0.033741172f, - -0.999322385f, -0.036807223f, - -0.999204759f, -0.039872928f, - -0.999077728f, -0.042938257f, - -0.998941293f, -0.046003182f, - -0.998795456f, -0.049067674f, - -0.998640218f, -0.052131705f, - -0.998475581f, -0.055195244f, - -0.998301545f, -0.058258265f, - -0.998118113f, -0.061320736f, - -0.997925286f, -0.064382631f, - -0.997723067f, -0.067443920f, - -0.997511456f, -0.070504573f, - -0.997290457f, -0.073564564f, - -0.997060070f, -0.076623861f, - -0.996820299f, -0.079682438f, - -0.996571146f, -0.082740265f, - -0.996312612f, -0.085797312f, - -0.996044701f, -0.088853553f, - -0.995767414f, -0.091908956f, - -0.995480755f, -0.094963495f, - -0.995184727f, -0.098017140f, - -0.994879331f, -0.101069863f, - -0.994564571f, -0.104121634f, - -0.994240449f, -0.107172425f, - -0.993906970f, -0.110222207f, - -0.993564136f, -0.113270952f, - -0.993211949f, -0.116318631f, - -0.992850414f, -0.119365215f, - -0.992479535f, -0.122410675f, - -0.992099313f, -0.125454983f, - -0.991709754f, -0.128498111f, - -0.991310860f, -0.131540029f, - -0.990902635f, -0.134580709f, - -0.990485084f, -0.137620122f, - -0.990058210f, -0.140658239f, - -0.989622017f, -0.143695033f, - -0.989176510f, -0.146730474f, - -0.988721692f, -0.149764535f, - -0.988257568f, -0.152797185f, - -0.987784142f, -0.155828398f, - -0.987301418f, -0.158858143f, - -0.986809402f, -0.161886394f, - -0.986308097f, -0.164913120f, - -0.985797509f, -0.167938295f, - -0.985277642f, -0.170961889f, - -0.984748502f, -0.173983873f, - -0.984210092f, -0.177004220f, - -0.983662419f, -0.180022901f, - -0.983105487f, -0.183039888f, - -0.982539302f, -0.186055152f, - -0.981963869f, -0.189068664f, - -0.981379193f, -0.192080397f, - -0.980785280f, -0.195090322f, - -0.980182136f, -0.198098411f, - -0.979569766f, -0.201104635f, - -0.978948175f, -0.204108966f, - -0.978317371f, -0.207111376f, - -0.977677358f, -0.210111837f, - -0.977028143f, -0.213110320f, - -0.976369731f, -0.216106797f, - -0.975702130f, -0.219101240f, - -0.975025345f, -0.222093621f, - -0.974339383f, -0.225083911f, - -0.973644250f, -0.228072083f, - -0.972939952f, -0.231058108f, - -0.972226497f, -0.234041959f, - -0.971503891f, -0.237023606f, - -0.970772141f, -0.240003022f, - -0.970031253f, -0.242980180f, - -0.969281235f, -0.245955050f, - -0.968522094f, -0.248927606f, - -0.967753837f, -0.251897818f, - -0.966976471f, -0.254865660f, - -0.966190003f, -0.257831102f, - -0.965394442f, -0.260794118f, - -0.964589793f, -0.263754679f, - -0.963776066f, -0.266712757f, - -0.962953267f, -0.269668326f, - -0.962121404f, -0.272621355f, - -0.961280486f, -0.275571819f, - -0.960430519f, -0.278519689f, - -0.959571513f, -0.281464938f, - -0.958703475f, -0.284407537f, - -0.957826413f, -0.287347460f, - -0.956940336f, -0.290284677f, - -0.956045251f, -0.293219163f, - -0.955141168f, -0.296150888f, - -0.954228095f, -0.299079826f, - -0.953306040f, -0.302005949f, - -0.952375013f, -0.304929230f, - -0.951435021f, -0.307849640f, - -0.950486074f, -0.310767153f, - -0.949528181f, -0.313681740f, - -0.948561350f, -0.316593376f, - -0.947585591f, -0.319502031f, - -0.946600913f, -0.322407679f, - -0.945607325f, -0.325310292f, - -0.944604837f, -0.328209844f, - -0.943593458f, -0.331106306f, - -0.942573198f, -0.333999651f, - -0.941544065f, -0.336889853f, - -0.940506071f, -0.339776884f, - -0.939459224f, -0.342660717f, - -0.938403534f, -0.345541325f, - -0.937339012f, -0.348418680f, - -0.936265667f, -0.351292756f, - -0.935183510f, -0.354163525f, - -0.934092550f, -0.357030961f, - -0.932992799f, -0.359895037f, - -0.931884266f, -0.362755724f, - -0.930766961f, -0.365612998f, - -0.929640896f, -0.368466830f, - -0.928506080f, -0.371317194f, - -0.927362526f, -0.374164063f, - -0.926210242f, -0.377007410f, - -0.925049241f, -0.379847209f, - -0.923879533f, -0.382683432f, - -0.922701128f, -0.385516054f, - -0.921514039f, -0.388345047f, - -0.920318277f, -0.391170384f, - -0.919113852f, -0.393992040f, - -0.917900776f, -0.396809987f, - -0.916679060f, -0.399624200f, - -0.915448716f, -0.402434651f, - -0.914209756f, -0.405241314f, - -0.912962190f, -0.408044163f, - -0.911706032f, -0.410843171f, - -0.910441292f, -0.413638312f, - -0.909167983f, -0.416429560f, - -0.907886116f, -0.419216888f, - -0.906595705f, -0.422000271f, - -0.905296759f, -0.424779681f, - -0.903989293f, -0.427555093f, - -0.902673318f, -0.430326481f, - -0.901348847f, -0.433093819f, - -0.900015892f, -0.435857080f, - -0.898674466f, -0.438616239f, - -0.897324581f, -0.441371269f, - -0.895966250f, -0.444122145f, - -0.894599486f, -0.446868840f, - -0.893224301f, -0.449611330f, - -0.891840709f, -0.452349587f, - -0.890448723f, -0.455083587f, - -0.889048356f, -0.457813304f, - -0.887639620f, -0.460538711f, - -0.886222530f, -0.463259784f, - -0.884797098f, -0.465976496f, - -0.883363339f, -0.468688822f, - -0.881921264f, -0.471396737f, - -0.880470889f, -0.474100215f, - -0.879012226f, -0.476799230f, - -0.877545290f, -0.479493758f, - -0.876070094f, -0.482183772f, - -0.874586652f, -0.484869248f, - -0.873094978f, -0.487550160f, - -0.871595087f, -0.490226483f, - -0.870086991f, -0.492898192f, - -0.868570706f, -0.495565262f, - -0.867046246f, -0.498227667f, - -0.865513624f, -0.500885383f, - -0.863972856f, -0.503538384f, - -0.862423956f, -0.506186645f, - -0.860866939f, -0.508830143f, - -0.859301818f, -0.511468850f, - -0.857728610f, -0.514102744f, - -0.856147328f, -0.516731799f, - -0.854557988f, -0.519355990f, - -0.852960605f, -0.521975293f, - -0.851355193f, -0.524589683f, - -0.849741768f, -0.527199135f, - -0.848120345f, -0.529803625f, - -0.846490939f, -0.532403128f, - -0.844853565f, -0.534997620f, - -0.843208240f, -0.537587076f, - -0.841554977f, -0.540171473f, - -0.839893794f, -0.542750785f, - -0.838224706f, -0.545324988f, - -0.836547727f, -0.547894059f, - -0.834862875f, -0.550457973f, - -0.833170165f, -0.553016706f, - -0.831469612f, -0.555570233f, - -0.829761234f, -0.558118531f, - -0.828045045f, -0.560661576f, - -0.826321063f, -0.563199344f, - -0.824589303f, -0.565731811f, - -0.822849781f, -0.568258953f, - -0.821102515f, -0.570780746f, - -0.819347520f, -0.573297167f, - -0.817584813f, -0.575808191f, - -0.815814411f, -0.578313796f, - -0.814036330f, -0.580813958f, - -0.812250587f, -0.583308653f, - -0.810457198f, -0.585797857f, - -0.808656182f, -0.588281548f, - -0.806847554f, -0.590759702f, - -0.805031331f, -0.593232295f, - -0.803207531f, -0.595699304f, - -0.801376172f, -0.598160707f, - -0.799537269f, -0.600616479f, - -0.797690841f, -0.603066599f, - -0.795836905f, -0.605511041f, - -0.793975478f, -0.607949785f, - -0.792106577f, -0.610382806f, - -0.790230221f, -0.612810082f, - -0.788346428f, -0.615231591f, - -0.786455214f, -0.617647308f, - -0.784556597f, -0.620057212f, - -0.782650596f, -0.622461279f, - -0.780737229f, -0.624859488f, - -0.778816512f, -0.627251815f, - -0.776888466f, -0.629638239f, - -0.774953107f, -0.632018736f, - -0.773010453f, -0.634393284f, - -0.771060524f, -0.636761861f, - -0.769103338f, -0.639124445f, - -0.767138912f, -0.641481013f, - -0.765167266f, -0.643831543f, - -0.763188417f, -0.646176013f, - -0.761202385f, -0.648514401f, - -0.759209189f, -0.650846685f, - -0.757208847f, -0.653172843f, - -0.755201377f, -0.655492853f, - -0.753186799f, -0.657806693f, - -0.751165132f, -0.660114342f, - -0.749136395f, -0.662415778f, - -0.747100606f, -0.664710978f, - -0.745057785f, -0.666999922f, - -0.743007952f, -0.669282588f, - -0.740951125f, -0.671558955f, - -0.738887324f, -0.673829000f, - -0.736816569f, -0.676092704f, - -0.734738878f, -0.678350043f, - -0.732654272f, -0.680600998f, - -0.730562769f, -0.682845546f, - -0.728464390f, -0.685083668f, - -0.726359155f, -0.687315341f, - -0.724247083f, -0.689540545f, - -0.722128194f, -0.691759258f, - -0.720002508f, -0.693971461f, - -0.717870045f, -0.696177131f, - -0.715730825f, -0.698376249f, - -0.713584869f, -0.700568794f, - -0.711432196f, -0.702754744f, - -0.709272826f, -0.704934080f, - -0.707106781f, -0.707106781f, - -0.704934080f, -0.709272826f, - -0.702754744f, -0.711432196f, - -0.700568794f, -0.713584869f, - -0.698376249f, -0.715730825f, - -0.696177131f, -0.717870045f, - -0.693971461f, -0.720002508f, - -0.691759258f, -0.722128194f, - -0.689540545f, -0.724247083f, - -0.687315341f, -0.726359155f, - -0.685083668f, -0.728464390f, - -0.682845546f, -0.730562769f, - -0.680600998f, -0.732654272f, - -0.678350043f, -0.734738878f, - -0.676092704f, -0.736816569f, - -0.673829000f, -0.738887324f, - -0.671558955f, -0.740951125f, - -0.669282588f, -0.743007952f, - -0.666999922f, -0.745057785f, - -0.664710978f, -0.747100606f, - -0.662415778f, -0.749136395f, - -0.660114342f, -0.751165132f, - -0.657806693f, -0.753186799f, - -0.655492853f, -0.755201377f, - -0.653172843f, -0.757208847f, - -0.650846685f, -0.759209189f, - -0.648514401f, -0.761202385f, - -0.646176013f, -0.763188417f, - -0.643831543f, -0.765167266f, - -0.641481013f, -0.767138912f, - -0.639124445f, -0.769103338f, - -0.636761861f, -0.771060524f, - -0.634393284f, -0.773010453f, - -0.632018736f, -0.774953107f, - -0.629638239f, -0.776888466f, - -0.627251815f, -0.778816512f, - -0.624859488f, -0.780737229f, - -0.622461279f, -0.782650596f, - -0.620057212f, -0.784556597f, - -0.617647308f, -0.786455214f, - -0.615231591f, -0.788346428f, - -0.612810082f, -0.790230221f, - -0.610382806f, -0.792106577f, - -0.607949785f, -0.793975478f, - -0.605511041f, -0.795836905f, - -0.603066599f, -0.797690841f, - -0.600616479f, -0.799537269f, - -0.598160707f, -0.801376172f, - -0.595699304f, -0.803207531f, - -0.593232295f, -0.805031331f, - -0.590759702f, -0.806847554f, - -0.588281548f, -0.808656182f, - -0.585797857f, -0.810457198f, - -0.583308653f, -0.812250587f, - -0.580813958f, -0.814036330f, - -0.578313796f, -0.815814411f, - -0.575808191f, -0.817584813f, - -0.573297167f, -0.819347520f, - -0.570780746f, -0.821102515f, - -0.568258953f, -0.822849781f, - -0.565731811f, -0.824589303f, - -0.563199344f, -0.826321063f, - -0.560661576f, -0.828045045f, - -0.558118531f, -0.829761234f, - -0.555570233f, -0.831469612f, - -0.553016706f, -0.833170165f, - -0.550457973f, -0.834862875f, - -0.547894059f, -0.836547727f, - -0.545324988f, -0.838224706f, - -0.542750785f, -0.839893794f, - -0.540171473f, -0.841554977f, - -0.537587076f, -0.843208240f, - -0.534997620f, -0.844853565f, - -0.532403128f, -0.846490939f, - -0.529803625f, -0.848120345f, - -0.527199135f, -0.849741768f, - -0.524589683f, -0.851355193f, - -0.521975293f, -0.852960605f, - -0.519355990f, -0.854557988f, - -0.516731799f, -0.856147328f, - -0.514102744f, -0.857728610f, - -0.511468850f, -0.859301818f, - -0.508830143f, -0.860866939f, - -0.506186645f, -0.862423956f, - -0.503538384f, -0.863972856f, - -0.500885383f, -0.865513624f, - -0.498227667f, -0.867046246f, - -0.495565262f, -0.868570706f, - -0.492898192f, -0.870086991f, - -0.490226483f, -0.871595087f, - -0.487550160f, -0.873094978f, - -0.484869248f, -0.874586652f, - -0.482183772f, -0.876070094f, - -0.479493758f, -0.877545290f, - -0.476799230f, -0.879012226f, - -0.474100215f, -0.880470889f, - -0.471396737f, -0.881921264f, - -0.468688822f, -0.883363339f, - -0.465976496f, -0.884797098f, - -0.463259784f, -0.886222530f, - -0.460538711f, -0.887639620f, - -0.457813304f, -0.889048356f, - -0.455083587f, -0.890448723f, - -0.452349587f, -0.891840709f, - -0.449611330f, -0.893224301f, - -0.446868840f, -0.894599486f, - -0.444122145f, -0.895966250f, - -0.441371269f, -0.897324581f, - -0.438616239f, -0.898674466f, - -0.435857080f, -0.900015892f, - -0.433093819f, -0.901348847f, - -0.430326481f, -0.902673318f, - -0.427555093f, -0.903989293f, - -0.424779681f, -0.905296759f, - -0.422000271f, -0.906595705f, - -0.419216888f, -0.907886116f, - -0.416429560f, -0.909167983f, - -0.413638312f, -0.910441292f, - -0.410843171f, -0.911706032f, - -0.408044163f, -0.912962190f, - -0.405241314f, -0.914209756f, - -0.402434651f, -0.915448716f, - -0.399624200f, -0.916679060f, - -0.396809987f, -0.917900776f, - -0.393992040f, -0.919113852f, - -0.391170384f, -0.920318277f, - -0.388345047f, -0.921514039f, - -0.385516054f, -0.922701128f, - -0.382683432f, -0.923879533f, - -0.379847209f, -0.925049241f, - -0.377007410f, -0.926210242f, - -0.374164063f, -0.927362526f, - -0.371317194f, -0.928506080f, - -0.368466830f, -0.929640896f, - -0.365612998f, -0.930766961f, - -0.362755724f, -0.931884266f, - -0.359895037f, -0.932992799f, - -0.357030961f, -0.934092550f, - -0.354163525f, -0.935183510f, - -0.351292756f, -0.936265667f, - -0.348418680f, -0.937339012f, - -0.345541325f, -0.938403534f, - -0.342660717f, -0.939459224f, - -0.339776884f, -0.940506071f, - -0.336889853f, -0.941544065f, - -0.333999651f, -0.942573198f, - -0.331106306f, -0.943593458f, - -0.328209844f, -0.944604837f, - -0.325310292f, -0.945607325f, - -0.322407679f, -0.946600913f, - -0.319502031f, -0.947585591f, - -0.316593376f, -0.948561350f, - -0.313681740f, -0.949528181f, - -0.310767153f, -0.950486074f, - -0.307849640f, -0.951435021f, - -0.304929230f, -0.952375013f, - -0.302005949f, -0.953306040f, - -0.299079826f, -0.954228095f, - -0.296150888f, -0.955141168f, - -0.293219163f, -0.956045251f, - -0.290284677f, -0.956940336f, - -0.287347460f, -0.957826413f, - -0.284407537f, -0.958703475f, - -0.281464938f, -0.959571513f, - -0.278519689f, -0.960430519f, - -0.275571819f, -0.961280486f, - -0.272621355f, -0.962121404f, - -0.269668326f, -0.962953267f, - -0.266712757f, -0.963776066f, - -0.263754679f, -0.964589793f, - -0.260794118f, -0.965394442f, - -0.257831102f, -0.966190003f, - -0.254865660f, -0.966976471f, - -0.251897818f, -0.967753837f, - -0.248927606f, -0.968522094f, - -0.245955050f, -0.969281235f, - -0.242980180f, -0.970031253f, - -0.240003022f, -0.970772141f, - -0.237023606f, -0.971503891f, - -0.234041959f, -0.972226497f, - -0.231058108f, -0.972939952f, - -0.228072083f, -0.973644250f, - -0.225083911f, -0.974339383f, - -0.222093621f, -0.975025345f, - -0.219101240f, -0.975702130f, - -0.216106797f, -0.976369731f, - -0.213110320f, -0.977028143f, - -0.210111837f, -0.977677358f, - -0.207111376f, -0.978317371f, - -0.204108966f, -0.978948175f, - -0.201104635f, -0.979569766f, - -0.198098411f, -0.980182136f, - -0.195090322f, -0.980785280f, - -0.192080397f, -0.981379193f, - -0.189068664f, -0.981963869f, - -0.186055152f, -0.982539302f, - -0.183039888f, -0.983105487f, - -0.180022901f, -0.983662419f, - -0.177004220f, -0.984210092f, - -0.173983873f, -0.984748502f, - -0.170961889f, -0.985277642f, - -0.167938295f, -0.985797509f, - -0.164913120f, -0.986308097f, - -0.161886394f, -0.986809402f, - -0.158858143f, -0.987301418f, - -0.155828398f, -0.987784142f, - -0.152797185f, -0.988257568f, - -0.149764535f, -0.988721692f, - -0.146730474f, -0.989176510f, - -0.143695033f, -0.989622017f, - -0.140658239f, -0.990058210f, - -0.137620122f, -0.990485084f, - -0.134580709f, -0.990902635f, - -0.131540029f, -0.991310860f, - -0.128498111f, -0.991709754f, - -0.125454983f, -0.992099313f, - -0.122410675f, -0.992479535f, - -0.119365215f, -0.992850414f, - -0.116318631f, -0.993211949f, - -0.113270952f, -0.993564136f, - -0.110222207f, -0.993906970f, - -0.107172425f, -0.994240449f, - -0.104121634f, -0.994564571f, - -0.101069863f, -0.994879331f, - -0.098017140f, -0.995184727f, - -0.094963495f, -0.995480755f, - -0.091908956f, -0.995767414f, - -0.088853553f, -0.996044701f, - -0.085797312f, -0.996312612f, - -0.082740265f, -0.996571146f, - -0.079682438f, -0.996820299f, - -0.076623861f, -0.997060070f, - -0.073564564f, -0.997290457f, - -0.070504573f, -0.997511456f, - -0.067443920f, -0.997723067f, - -0.064382631f, -0.997925286f, - -0.061320736f, -0.998118113f, - -0.058258265f, -0.998301545f, - -0.055195244f, -0.998475581f, - -0.052131705f, -0.998640218f, - -0.049067674f, -0.998795456f, - -0.046003182f, -0.998941293f, - -0.042938257f, -0.999077728f, - -0.039872928f, -0.999204759f, - -0.036807223f, -0.999322385f, - -0.033741172f, -0.999430605f, - -0.030674803f, -0.999529418f, - -0.027608146f, -0.999618822f, - -0.024541229f, -0.999698819f, - -0.021474080f, -0.999769405f, - -0.018406730f, -0.999830582f, - -0.015339206f, -0.999882347f, - -0.012271538f, -0.999924702f, - -0.009203755f, -0.999957645f, - -0.006135885f, -0.999981175f, - -0.003067957f, -0.999995294f, - -0.000000000f, -1.000000000f, - 0.003067957f, -0.999995294f, - 0.006135885f, -0.999981175f, - 0.009203755f, -0.999957645f, - 0.012271538f, -0.999924702f, - 0.015339206f, -0.999882347f, - 0.018406730f, -0.999830582f, - 0.021474080f, -0.999769405f, - 0.024541229f, -0.999698819f, - 0.027608146f, -0.999618822f, - 0.030674803f, -0.999529418f, - 0.033741172f, -0.999430605f, - 0.036807223f, -0.999322385f, - 0.039872928f, -0.999204759f, - 0.042938257f, -0.999077728f, - 0.046003182f, -0.998941293f, - 0.049067674f, -0.998795456f, - 0.052131705f, -0.998640218f, - 0.055195244f, -0.998475581f, - 0.058258265f, -0.998301545f, - 0.061320736f, -0.998118113f, - 0.064382631f, -0.997925286f, - 0.067443920f, -0.997723067f, - 0.070504573f, -0.997511456f, - 0.073564564f, -0.997290457f, - 0.076623861f, -0.997060070f, - 0.079682438f, -0.996820299f, - 0.082740265f, -0.996571146f, - 0.085797312f, -0.996312612f, - 0.088853553f, -0.996044701f, - 0.091908956f, -0.995767414f, - 0.094963495f, -0.995480755f, - 0.098017140f, -0.995184727f, - 0.101069863f, -0.994879331f, - 0.104121634f, -0.994564571f, - 0.107172425f, -0.994240449f, - 0.110222207f, -0.993906970f, - 0.113270952f, -0.993564136f, - 0.116318631f, -0.993211949f, - 0.119365215f, -0.992850414f, - 0.122410675f, -0.992479535f, - 0.125454983f, -0.992099313f, - 0.128498111f, -0.991709754f, - 0.131540029f, -0.991310860f, - 0.134580709f, -0.990902635f, - 0.137620122f, -0.990485084f, - 0.140658239f, -0.990058210f, - 0.143695033f, -0.989622017f, - 0.146730474f, -0.989176510f, - 0.149764535f, -0.988721692f, - 0.152797185f, -0.988257568f, - 0.155828398f, -0.987784142f, - 0.158858143f, -0.987301418f, - 0.161886394f, -0.986809402f, - 0.164913120f, -0.986308097f, - 0.167938295f, -0.985797509f, - 0.170961889f, -0.985277642f, - 0.173983873f, -0.984748502f, - 0.177004220f, -0.984210092f, - 0.180022901f, -0.983662419f, - 0.183039888f, -0.983105487f, - 0.186055152f, -0.982539302f, - 0.189068664f, -0.981963869f, - 0.192080397f, -0.981379193f, - 0.195090322f, -0.980785280f, - 0.198098411f, -0.980182136f, - 0.201104635f, -0.979569766f, - 0.204108966f, -0.978948175f, - 0.207111376f, -0.978317371f, - 0.210111837f, -0.977677358f, - 0.213110320f, -0.977028143f, - 0.216106797f, -0.976369731f, - 0.219101240f, -0.975702130f, - 0.222093621f, -0.975025345f, - 0.225083911f, -0.974339383f, - 0.228072083f, -0.973644250f, - 0.231058108f, -0.972939952f, - 0.234041959f, -0.972226497f, - 0.237023606f, -0.971503891f, - 0.240003022f, -0.970772141f, - 0.242980180f, -0.970031253f, - 0.245955050f, -0.969281235f, - 0.248927606f, -0.968522094f, - 0.251897818f, -0.967753837f, - 0.254865660f, -0.966976471f, - 0.257831102f, -0.966190003f, - 0.260794118f, -0.965394442f, - 0.263754679f, -0.964589793f, - 0.266712757f, -0.963776066f, - 0.269668326f, -0.962953267f, - 0.272621355f, -0.962121404f, - 0.275571819f, -0.961280486f, - 0.278519689f, -0.960430519f, - 0.281464938f, -0.959571513f, - 0.284407537f, -0.958703475f, - 0.287347460f, -0.957826413f, - 0.290284677f, -0.956940336f, - 0.293219163f, -0.956045251f, - 0.296150888f, -0.955141168f, - 0.299079826f, -0.954228095f, - 0.302005949f, -0.953306040f, - 0.304929230f, -0.952375013f, - 0.307849640f, -0.951435021f, - 0.310767153f, -0.950486074f, - 0.313681740f, -0.949528181f, - 0.316593376f, -0.948561350f, - 0.319502031f, -0.947585591f, - 0.322407679f, -0.946600913f, - 0.325310292f, -0.945607325f, - 0.328209844f, -0.944604837f, - 0.331106306f, -0.943593458f, - 0.333999651f, -0.942573198f, - 0.336889853f, -0.941544065f, - 0.339776884f, -0.940506071f, - 0.342660717f, -0.939459224f, - 0.345541325f, -0.938403534f, - 0.348418680f, -0.937339012f, - 0.351292756f, -0.936265667f, - 0.354163525f, -0.935183510f, - 0.357030961f, -0.934092550f, - 0.359895037f, -0.932992799f, - 0.362755724f, -0.931884266f, - 0.365612998f, -0.930766961f, - 0.368466830f, -0.929640896f, - 0.371317194f, -0.928506080f, - 0.374164063f, -0.927362526f, - 0.377007410f, -0.926210242f, - 0.379847209f, -0.925049241f, - 0.382683432f, -0.923879533f, - 0.385516054f, -0.922701128f, - 0.388345047f, -0.921514039f, - 0.391170384f, -0.920318277f, - 0.393992040f, -0.919113852f, - 0.396809987f, -0.917900776f, - 0.399624200f, -0.916679060f, - 0.402434651f, -0.915448716f, - 0.405241314f, -0.914209756f, - 0.408044163f, -0.912962190f, - 0.410843171f, -0.911706032f, - 0.413638312f, -0.910441292f, - 0.416429560f, -0.909167983f, - 0.419216888f, -0.907886116f, - 0.422000271f, -0.906595705f, - 0.424779681f, -0.905296759f, - 0.427555093f, -0.903989293f, - 0.430326481f, -0.902673318f, - 0.433093819f, -0.901348847f, - 0.435857080f, -0.900015892f, - 0.438616239f, -0.898674466f, - 0.441371269f, -0.897324581f, - 0.444122145f, -0.895966250f, - 0.446868840f, -0.894599486f, - 0.449611330f, -0.893224301f, - 0.452349587f, -0.891840709f, - 0.455083587f, -0.890448723f, - 0.457813304f, -0.889048356f, - 0.460538711f, -0.887639620f, - 0.463259784f, -0.886222530f, - 0.465976496f, -0.884797098f, - 0.468688822f, -0.883363339f, - 0.471396737f, -0.881921264f, - 0.474100215f, -0.880470889f, - 0.476799230f, -0.879012226f, - 0.479493758f, -0.877545290f, - 0.482183772f, -0.876070094f, - 0.484869248f, -0.874586652f, - 0.487550160f, -0.873094978f, - 0.490226483f, -0.871595087f, - 0.492898192f, -0.870086991f, - 0.495565262f, -0.868570706f, - 0.498227667f, -0.867046246f, - 0.500885383f, -0.865513624f, - 0.503538384f, -0.863972856f, - 0.506186645f, -0.862423956f, - 0.508830143f, -0.860866939f, - 0.511468850f, -0.859301818f, - 0.514102744f, -0.857728610f, - 0.516731799f, -0.856147328f, - 0.519355990f, -0.854557988f, - 0.521975293f, -0.852960605f, - 0.524589683f, -0.851355193f, - 0.527199135f, -0.849741768f, - 0.529803625f, -0.848120345f, - 0.532403128f, -0.846490939f, - 0.534997620f, -0.844853565f, - 0.537587076f, -0.843208240f, - 0.540171473f, -0.841554977f, - 0.542750785f, -0.839893794f, - 0.545324988f, -0.838224706f, - 0.547894059f, -0.836547727f, - 0.550457973f, -0.834862875f, - 0.553016706f, -0.833170165f, - 0.555570233f, -0.831469612f, - 0.558118531f, -0.829761234f, - 0.560661576f, -0.828045045f, - 0.563199344f, -0.826321063f, - 0.565731811f, -0.824589303f, - 0.568258953f, -0.822849781f, - 0.570780746f, -0.821102515f, - 0.573297167f, -0.819347520f, - 0.575808191f, -0.817584813f, - 0.578313796f, -0.815814411f, - 0.580813958f, -0.814036330f, - 0.583308653f, -0.812250587f, - 0.585797857f, -0.810457198f, - 0.588281548f, -0.808656182f, - 0.590759702f, -0.806847554f, - 0.593232295f, -0.805031331f, - 0.595699304f, -0.803207531f, - 0.598160707f, -0.801376172f, - 0.600616479f, -0.799537269f, - 0.603066599f, -0.797690841f, - 0.605511041f, -0.795836905f, - 0.607949785f, -0.793975478f, - 0.610382806f, -0.792106577f, - 0.612810082f, -0.790230221f, - 0.615231591f, -0.788346428f, - 0.617647308f, -0.786455214f, - 0.620057212f, -0.784556597f, - 0.622461279f, -0.782650596f, - 0.624859488f, -0.780737229f, - 0.627251815f, -0.778816512f, - 0.629638239f, -0.776888466f, - 0.632018736f, -0.774953107f, - 0.634393284f, -0.773010453f, - 0.636761861f, -0.771060524f, - 0.639124445f, -0.769103338f, - 0.641481013f, -0.767138912f, - 0.643831543f, -0.765167266f, - 0.646176013f, -0.763188417f, - 0.648514401f, -0.761202385f, - 0.650846685f, -0.759209189f, - 0.653172843f, -0.757208847f, - 0.655492853f, -0.755201377f, - 0.657806693f, -0.753186799f, - 0.660114342f, -0.751165132f, - 0.662415778f, -0.749136395f, - 0.664710978f, -0.747100606f, - 0.666999922f, -0.745057785f, - 0.669282588f, -0.743007952f, - 0.671558955f, -0.740951125f, - 0.673829000f, -0.738887324f, - 0.676092704f, -0.736816569f, - 0.678350043f, -0.734738878f, - 0.680600998f, -0.732654272f, - 0.682845546f, -0.730562769f, - 0.685083668f, -0.728464390f, - 0.687315341f, -0.726359155f, - 0.689540545f, -0.724247083f, - 0.691759258f, -0.722128194f, - 0.693971461f, -0.720002508f, - 0.696177131f, -0.717870045f, - 0.698376249f, -0.715730825f, - 0.700568794f, -0.713584869f, - 0.702754744f, -0.711432196f, - 0.704934080f, -0.709272826f, - 0.707106781f, -0.707106781f, - 0.709272826f, -0.704934080f, - 0.711432196f, -0.702754744f, - 0.713584869f, -0.700568794f, - 0.715730825f, -0.698376249f, - 0.717870045f, -0.696177131f, - 0.720002508f, -0.693971461f, - 0.722128194f, -0.691759258f, - 0.724247083f, -0.689540545f, - 0.726359155f, -0.687315341f, - 0.728464390f, -0.685083668f, - 0.730562769f, -0.682845546f, - 0.732654272f, -0.680600998f, - 0.734738878f, -0.678350043f, - 0.736816569f, -0.676092704f, - 0.738887324f, -0.673829000f, - 0.740951125f, -0.671558955f, - 0.743007952f, -0.669282588f, - 0.745057785f, -0.666999922f, - 0.747100606f, -0.664710978f, - 0.749136395f, -0.662415778f, - 0.751165132f, -0.660114342f, - 0.753186799f, -0.657806693f, - 0.755201377f, -0.655492853f, - 0.757208847f, -0.653172843f, - 0.759209189f, -0.650846685f, - 0.761202385f, -0.648514401f, - 0.763188417f, -0.646176013f, - 0.765167266f, -0.643831543f, - 0.767138912f, -0.641481013f, - 0.769103338f, -0.639124445f, - 0.771060524f, -0.636761861f, - 0.773010453f, -0.634393284f, - 0.774953107f, -0.632018736f, - 0.776888466f, -0.629638239f, - 0.778816512f, -0.627251815f, - 0.780737229f, -0.624859488f, - 0.782650596f, -0.622461279f, - 0.784556597f, -0.620057212f, - 0.786455214f, -0.617647308f, - 0.788346428f, -0.615231591f, - 0.790230221f, -0.612810082f, - 0.792106577f, -0.610382806f, - 0.793975478f, -0.607949785f, - 0.795836905f, -0.605511041f, - 0.797690841f, -0.603066599f, - 0.799537269f, -0.600616479f, - 0.801376172f, -0.598160707f, - 0.803207531f, -0.595699304f, - 0.805031331f, -0.593232295f, - 0.806847554f, -0.590759702f, - 0.808656182f, -0.588281548f, - 0.810457198f, -0.585797857f, - 0.812250587f, -0.583308653f, - 0.814036330f, -0.580813958f, - 0.815814411f, -0.578313796f, - 0.817584813f, -0.575808191f, - 0.819347520f, -0.573297167f, - 0.821102515f, -0.570780746f, - 0.822849781f, -0.568258953f, - 0.824589303f, -0.565731811f, - 0.826321063f, -0.563199344f, - 0.828045045f, -0.560661576f, - 0.829761234f, -0.558118531f, - 0.831469612f, -0.555570233f, - 0.833170165f, -0.553016706f, - 0.834862875f, -0.550457973f, - 0.836547727f, -0.547894059f, - 0.838224706f, -0.545324988f, - 0.839893794f, -0.542750785f, - 0.841554977f, -0.540171473f, - 0.843208240f, -0.537587076f, - 0.844853565f, -0.534997620f, - 0.846490939f, -0.532403128f, - 0.848120345f, -0.529803625f, - 0.849741768f, -0.527199135f, - 0.851355193f, -0.524589683f, - 0.852960605f, -0.521975293f, - 0.854557988f, -0.519355990f, - 0.856147328f, -0.516731799f, - 0.857728610f, -0.514102744f, - 0.859301818f, -0.511468850f, - 0.860866939f, -0.508830143f, - 0.862423956f, -0.506186645f, - 0.863972856f, -0.503538384f, - 0.865513624f, -0.500885383f, - 0.867046246f, -0.498227667f, - 0.868570706f, -0.495565262f, - 0.870086991f, -0.492898192f, - 0.871595087f, -0.490226483f, - 0.873094978f, -0.487550160f, - 0.874586652f, -0.484869248f, - 0.876070094f, -0.482183772f, - 0.877545290f, -0.479493758f, - 0.879012226f, -0.476799230f, - 0.880470889f, -0.474100215f, - 0.881921264f, -0.471396737f, - 0.883363339f, -0.468688822f, - 0.884797098f, -0.465976496f, - 0.886222530f, -0.463259784f, - 0.887639620f, -0.460538711f, - 0.889048356f, -0.457813304f, - 0.890448723f, -0.455083587f, - 0.891840709f, -0.452349587f, - 0.893224301f, -0.449611330f, - 0.894599486f, -0.446868840f, - 0.895966250f, -0.444122145f, - 0.897324581f, -0.441371269f, - 0.898674466f, -0.438616239f, - 0.900015892f, -0.435857080f, - 0.901348847f, -0.433093819f, - 0.902673318f, -0.430326481f, - 0.903989293f, -0.427555093f, - 0.905296759f, -0.424779681f, - 0.906595705f, -0.422000271f, - 0.907886116f, -0.419216888f, - 0.909167983f, -0.416429560f, - 0.910441292f, -0.413638312f, - 0.911706032f, -0.410843171f, - 0.912962190f, -0.408044163f, - 0.914209756f, -0.405241314f, - 0.915448716f, -0.402434651f, - 0.916679060f, -0.399624200f, - 0.917900776f, -0.396809987f, - 0.919113852f, -0.393992040f, - 0.920318277f, -0.391170384f, - 0.921514039f, -0.388345047f, - 0.922701128f, -0.385516054f, - 0.923879533f, -0.382683432f, - 0.925049241f, -0.379847209f, - 0.926210242f, -0.377007410f, - 0.927362526f, -0.374164063f, - 0.928506080f, -0.371317194f, - 0.929640896f, -0.368466830f, - 0.930766961f, -0.365612998f, - 0.931884266f, -0.362755724f, - 0.932992799f, -0.359895037f, - 0.934092550f, -0.357030961f, - 0.935183510f, -0.354163525f, - 0.936265667f, -0.351292756f, - 0.937339012f, -0.348418680f, - 0.938403534f, -0.345541325f, - 0.939459224f, -0.342660717f, - 0.940506071f, -0.339776884f, - 0.941544065f, -0.336889853f, - 0.942573198f, -0.333999651f, - 0.943593458f, -0.331106306f, - 0.944604837f, -0.328209844f, - 0.945607325f, -0.325310292f, - 0.946600913f, -0.322407679f, - 0.947585591f, -0.319502031f, - 0.948561350f, -0.316593376f, - 0.949528181f, -0.313681740f, - 0.950486074f, -0.310767153f, - 0.951435021f, -0.307849640f, - 0.952375013f, -0.304929230f, - 0.953306040f, -0.302005949f, - 0.954228095f, -0.299079826f, - 0.955141168f, -0.296150888f, - 0.956045251f, -0.293219163f, - 0.956940336f, -0.290284677f, - 0.957826413f, -0.287347460f, - 0.958703475f, -0.284407537f, - 0.959571513f, -0.281464938f, - 0.960430519f, -0.278519689f, - 0.961280486f, -0.275571819f, - 0.962121404f, -0.272621355f, - 0.962953267f, -0.269668326f, - 0.963776066f, -0.266712757f, - 0.964589793f, -0.263754679f, - 0.965394442f, -0.260794118f, - 0.966190003f, -0.257831102f, - 0.966976471f, -0.254865660f, - 0.967753837f, -0.251897818f, - 0.968522094f, -0.248927606f, - 0.969281235f, -0.245955050f, - 0.970031253f, -0.242980180f, - 0.970772141f, -0.240003022f, - 0.971503891f, -0.237023606f, - 0.972226497f, -0.234041959f, - 0.972939952f, -0.231058108f, - 0.973644250f, -0.228072083f, - 0.974339383f, -0.225083911f, - 0.975025345f, -0.222093621f, - 0.975702130f, -0.219101240f, - 0.976369731f, -0.216106797f, - 0.977028143f, -0.213110320f, - 0.977677358f, -0.210111837f, - 0.978317371f, -0.207111376f, - 0.978948175f, -0.204108966f, - 0.979569766f, -0.201104635f, - 0.980182136f, -0.198098411f, - 0.980785280f, -0.195090322f, - 0.981379193f, -0.192080397f, - 0.981963869f, -0.189068664f, - 0.982539302f, -0.186055152f, - 0.983105487f, -0.183039888f, - 0.983662419f, -0.180022901f, - 0.984210092f, -0.177004220f, - 0.984748502f, -0.173983873f, - 0.985277642f, -0.170961889f, - 0.985797509f, -0.167938295f, - 0.986308097f, -0.164913120f, - 0.986809402f, -0.161886394f, - 0.987301418f, -0.158858143f, - 0.987784142f, -0.155828398f, - 0.988257568f, -0.152797185f, - 0.988721692f, -0.149764535f, - 0.989176510f, -0.146730474f, - 0.989622017f, -0.143695033f, - 0.990058210f, -0.140658239f, - 0.990485084f, -0.137620122f, - 0.990902635f, -0.134580709f, - 0.991310860f, -0.131540029f, - 0.991709754f, -0.128498111f, - 0.992099313f, -0.125454983f, - 0.992479535f, -0.122410675f, - 0.992850414f, -0.119365215f, - 0.993211949f, -0.116318631f, - 0.993564136f, -0.113270952f, - 0.993906970f, -0.110222207f, - 0.994240449f, -0.107172425f, - 0.994564571f, -0.104121634f, - 0.994879331f, -0.101069863f, - 0.995184727f, -0.098017140f, - 0.995480755f, -0.094963495f, - 0.995767414f, -0.091908956f, - 0.996044701f, -0.088853553f, - 0.996312612f, -0.085797312f, - 0.996571146f, -0.082740265f, - 0.996820299f, -0.079682438f, - 0.997060070f, -0.076623861f, - 0.997290457f, -0.073564564f, - 0.997511456f, -0.070504573f, - 0.997723067f, -0.067443920f, - 0.997925286f, -0.064382631f, - 0.998118113f, -0.061320736f, - 0.998301545f, -0.058258265f, - 0.998475581f, -0.055195244f, - 0.998640218f, -0.052131705f, - 0.998795456f, -0.049067674f, - 0.998941293f, -0.046003182f, - 0.999077728f, -0.042938257f, - 0.999204759f, -0.039872928f, - 0.999322385f, -0.036807223f, - 0.999430605f, -0.033741172f, - 0.999529418f, -0.030674803f, - 0.999618822f, -0.027608146f, - 0.999698819f, -0.024541229f, - 0.999769405f, -0.021474080f, - 0.999830582f, -0.018406730f, - 0.999882347f, -0.015339206f, - 0.999924702f, -0.012271538f, - 0.999957645f, -0.009203755f, - 0.999981175f, -0.006135885f, - 0.999995294f, -0.003067957f -}; + 1.000000000f, 0.000000000f, 0.999995294f, 0.003067957f, 0.999981175f, + 0.006135885f, 0.999957645f, 0.009203755f, 0.999924702f, 0.012271538f, + 0.999882347f, 0.015339206f, 0.999830582f, 0.018406730f, 0.999769405f, + 0.021474080f, 0.999698819f, 0.024541229f, 0.999618822f, 0.027608146f, + 0.999529418f, 0.030674803f, 0.999430605f, 0.033741172f, 0.999322385f, + 0.036807223f, 0.999204759f, 0.039872928f, 0.999077728f, 0.042938257f, + 0.998941293f, 0.046003182f, 0.998795456f, 0.049067674f, 0.998640218f, + 0.052131705f, 0.998475581f, 0.055195244f, 0.998301545f, 0.058258265f, + 0.998118113f, 0.061320736f, 0.997925286f, 0.064382631f, 0.997723067f, + 0.067443920f, 0.997511456f, 0.070504573f, 0.997290457f, 0.073564564f, + 0.997060070f, 0.076623861f, 0.996820299f, 0.079682438f, 0.996571146f, + 0.082740265f, 0.996312612f, 0.085797312f, 0.996044701f, 0.088853553f, + 0.995767414f, 0.091908956f, 0.995480755f, 0.094963495f, 0.995184727f, + 0.098017140f, 0.994879331f, 0.101069863f, 0.994564571f, 0.104121634f, + 0.994240449f, 0.107172425f, 0.993906970f, 0.110222207f, 0.993564136f, + 0.113270952f, 0.993211949f, 0.116318631f, 0.992850414f, 0.119365215f, + 0.992479535f, 0.122410675f, 0.992099313f, 0.125454983f, 0.991709754f, + 0.128498111f, 0.991310860f, 0.131540029f, 0.990902635f, 0.134580709f, + 0.990485084f, 0.137620122f, 0.990058210f, 0.140658239f, 0.989622017f, + 0.143695033f, 0.989176510f, 0.146730474f, 0.988721692f, 0.149764535f, + 0.988257568f, 0.152797185f, 0.987784142f, 0.155828398f, 0.987301418f, + 0.158858143f, 0.986809402f, 0.161886394f, 0.986308097f, 0.164913120f, + 0.985797509f, 0.167938295f, 0.985277642f, 0.170961889f, 0.984748502f, + 0.173983873f, 0.984210092f, 0.177004220f, 0.983662419f, 0.180022901f, + 0.983105487f, 0.183039888f, 0.982539302f, 0.186055152f, 0.981963869f, + 0.189068664f, 0.981379193f, 0.192080397f, 0.980785280f, 0.195090322f, + 0.980182136f, 0.198098411f, 0.979569766f, 0.201104635f, 0.978948175f, + 0.204108966f, 0.978317371f, 0.207111376f, 0.977677358f, 0.210111837f, + 0.977028143f, 0.213110320f, 0.976369731f, 0.216106797f, 0.975702130f, + 0.219101240f, 0.975025345f, 0.222093621f, 0.974339383f, 0.225083911f, + 0.973644250f, 0.228072083f, 0.972939952f, 0.231058108f, 0.972226497f, + 0.234041959f, 0.971503891f, 0.237023606f, 0.970772141f, 0.240003022f, + 0.970031253f, 0.242980180f, 0.969281235f, 0.245955050f, 0.968522094f, + 0.248927606f, 0.967753837f, 0.251897818f, 0.966976471f, 0.254865660f, + 0.966190003f, 0.257831102f, 0.965394442f, 0.260794118f, 0.964589793f, + 0.263754679f, 0.963776066f, 0.266712757f, 0.962953267f, 0.269668326f, + 0.962121404f, 0.272621355f, 0.961280486f, 0.275571819f, 0.960430519f, + 0.278519689f, 0.959571513f, 0.281464938f, 0.958703475f, 0.284407537f, + 0.957826413f, 0.287347460f, 0.956940336f, 0.290284677f, 0.956045251f, + 0.293219163f, 0.955141168f, 0.296150888f, 0.954228095f, 0.299079826f, + 0.953306040f, 0.302005949f, 0.952375013f, 0.304929230f, 0.951435021f, + 0.307849640f, 0.950486074f, 0.310767153f, 0.949528181f, 0.313681740f, + 0.948561350f, 0.316593376f, 0.947585591f, 0.319502031f, 0.946600913f, + 0.322407679f, 0.945607325f, 0.325310292f, 0.944604837f, 0.328209844f, + 0.943593458f, 0.331106306f, 0.942573198f, 0.333999651f, 0.941544065f, + 0.336889853f, 0.940506071f, 0.339776884f, 0.939459224f, 0.342660717f, + 0.938403534f, 0.345541325f, 0.937339012f, 0.348418680f, 0.936265667f, + 0.351292756f, 0.935183510f, 0.354163525f, 0.934092550f, 0.357030961f, + 0.932992799f, 0.359895037f, 0.931884266f, 0.362755724f, 0.930766961f, + 0.365612998f, 0.929640896f, 0.368466830f, 0.928506080f, 0.371317194f, + 0.927362526f, 0.374164063f, 0.926210242f, 0.377007410f, 0.925049241f, + 0.379847209f, 0.923879533f, 0.382683432f, 0.922701128f, 0.385516054f, + 0.921514039f, 0.388345047f, 0.920318277f, 0.391170384f, 0.919113852f, + 0.393992040f, 0.917900776f, 0.396809987f, 0.916679060f, 0.399624200f, + 0.915448716f, 0.402434651f, 0.914209756f, 0.405241314f, 0.912962190f, + 0.408044163f, 0.911706032f, 0.410843171f, 0.910441292f, 0.413638312f, + 0.909167983f, 0.416429560f, 0.907886116f, 0.419216888f, 0.906595705f, + 0.422000271f, 0.905296759f, 0.424779681f, 0.903989293f, 0.427555093f, + 0.902673318f, 0.430326481f, 0.901348847f, 0.433093819f, 0.900015892f, + 0.435857080f, 0.898674466f, 0.438616239f, 0.897324581f, 0.441371269f, + 0.895966250f, 0.444122145f, 0.894599486f, 0.446868840f, 0.893224301f, + 0.449611330f, 0.891840709f, 0.452349587f, 0.890448723f, 0.455083587f, + 0.889048356f, 0.457813304f, 0.887639620f, 0.460538711f, 0.886222530f, + 0.463259784f, 0.884797098f, 0.465976496f, 0.883363339f, 0.468688822f, + 0.881921264f, 0.471396737f, 0.880470889f, 0.474100215f, 0.879012226f, + 0.476799230f, 0.877545290f, 0.479493758f, 0.876070094f, 0.482183772f, + 0.874586652f, 0.484869248f, 0.873094978f, 0.487550160f, 0.871595087f, + 0.490226483f, 0.870086991f, 0.492898192f, 0.868570706f, 0.495565262f, + 0.867046246f, 0.498227667f, 0.865513624f, 0.500885383f, 0.863972856f, + 0.503538384f, 0.862423956f, 0.506186645f, 0.860866939f, 0.508830143f, + 0.859301818f, 0.511468850f, 0.857728610f, 0.514102744f, 0.856147328f, + 0.516731799f, 0.854557988f, 0.519355990f, 0.852960605f, 0.521975293f, + 0.851355193f, 0.524589683f, 0.849741768f, 0.527199135f, 0.848120345f, + 0.529803625f, 0.846490939f, 0.532403128f, 0.844853565f, 0.534997620f, + 0.843208240f, 0.537587076f, 0.841554977f, 0.540171473f, 0.839893794f, + 0.542750785f, 0.838224706f, 0.545324988f, 0.836547727f, 0.547894059f, + 0.834862875f, 0.550457973f, 0.833170165f, 0.553016706f, 0.831469612f, + 0.555570233f, 0.829761234f, 0.558118531f, 0.828045045f, 0.560661576f, + 0.826321063f, 0.563199344f, 0.824589303f, 0.565731811f, 0.822849781f, + 0.568258953f, 0.821102515f, 0.570780746f, 0.819347520f, 0.573297167f, + 0.817584813f, 0.575808191f, 0.815814411f, 0.578313796f, 0.814036330f, + 0.580813958f, 0.812250587f, 0.583308653f, 0.810457198f, 0.585797857f, + 0.808656182f, 0.588281548f, 0.806847554f, 0.590759702f, 0.805031331f, + 0.593232295f, 0.803207531f, 0.595699304f, 0.801376172f, 0.598160707f, + 0.799537269f, 0.600616479f, 0.797690841f, 0.603066599f, 0.795836905f, + 0.605511041f, 0.793975478f, 0.607949785f, 0.792106577f, 0.610382806f, + 0.790230221f, 0.612810082f, 0.788346428f, 0.615231591f, 0.786455214f, + 0.617647308f, 0.784556597f, 0.620057212f, 0.782650596f, 0.622461279f, + 0.780737229f, 0.624859488f, 0.778816512f, 0.627251815f, 0.776888466f, + 0.629638239f, 0.774953107f, 0.632018736f, 0.773010453f, 0.634393284f, + 0.771060524f, 0.636761861f, 0.769103338f, 0.639124445f, 0.767138912f, + 0.641481013f, 0.765167266f, 0.643831543f, 0.763188417f, 0.646176013f, + 0.761202385f, 0.648514401f, 0.759209189f, 0.650846685f, 0.757208847f, + 0.653172843f, 0.755201377f, 0.655492853f, 0.753186799f, 0.657806693f, + 0.751165132f, 0.660114342f, 0.749136395f, 0.662415778f, 0.747100606f, + 0.664710978f, 0.745057785f, 0.666999922f, 0.743007952f, 0.669282588f, + 0.740951125f, 0.671558955f, 0.738887324f, 0.673829000f, 0.736816569f, + 0.676092704f, 0.734738878f, 0.678350043f, 0.732654272f, 0.680600998f, + 0.730562769f, 0.682845546f, 0.728464390f, 0.685083668f, 0.726359155f, + 0.687315341f, 0.724247083f, 0.689540545f, 0.722128194f, 0.691759258f, + 0.720002508f, 0.693971461f, 0.717870045f, 0.696177131f, 0.715730825f, + 0.698376249f, 0.713584869f, 0.700568794f, 0.711432196f, 0.702754744f, + 0.709272826f, 0.704934080f, 0.707106781f, 0.707106781f, 0.704934080f, + 0.709272826f, 0.702754744f, 0.711432196f, 0.700568794f, 0.713584869f, + 0.698376249f, 0.715730825f, 0.696177131f, 0.717870045f, 0.693971461f, + 0.720002508f, 0.691759258f, 0.722128194f, 0.689540545f, 0.724247083f, + 0.687315341f, 0.726359155f, 0.685083668f, 0.728464390f, 0.682845546f, + 0.730562769f, 0.680600998f, 0.732654272f, 0.678350043f, 0.734738878f, + 0.676092704f, 0.736816569f, 0.673829000f, 0.738887324f, 0.671558955f, + 0.740951125f, 0.669282588f, 0.743007952f, 0.666999922f, 0.745057785f, + 0.664710978f, 0.747100606f, 0.662415778f, 0.749136395f, 0.660114342f, + 0.751165132f, 0.657806693f, 0.753186799f, 0.655492853f, 0.755201377f, + 0.653172843f, 0.757208847f, 0.650846685f, 0.759209189f, 0.648514401f, + 0.761202385f, 0.646176013f, 0.763188417f, 0.643831543f, 0.765167266f, + 0.641481013f, 0.767138912f, 0.639124445f, 0.769103338f, 0.636761861f, + 0.771060524f, 0.634393284f, 0.773010453f, 0.632018736f, 0.774953107f, + 0.629638239f, 0.776888466f, 0.627251815f, 0.778816512f, 0.624859488f, + 0.780737229f, 0.622461279f, 0.782650596f, 0.620057212f, 0.784556597f, + 0.617647308f, 0.786455214f, 0.615231591f, 0.788346428f, 0.612810082f, + 0.790230221f, 0.610382806f, 0.792106577f, 0.607949785f, 0.793975478f, + 0.605511041f, 0.795836905f, 0.603066599f, 0.797690841f, 0.600616479f, + 0.799537269f, 0.598160707f, 0.801376172f, 0.595699304f, 0.803207531f, + 0.593232295f, 0.805031331f, 0.590759702f, 0.806847554f, 0.588281548f, + 0.808656182f, 0.585797857f, 0.810457198f, 0.583308653f, 0.812250587f, + 0.580813958f, 0.814036330f, 0.578313796f, 0.815814411f, 0.575808191f, + 0.817584813f, 0.573297167f, 0.819347520f, 0.570780746f, 0.821102515f, + 0.568258953f, 0.822849781f, 0.565731811f, 0.824589303f, 0.563199344f, + 0.826321063f, 0.560661576f, 0.828045045f, 0.558118531f, 0.829761234f, + 0.555570233f, 0.831469612f, 0.553016706f, 0.833170165f, 0.550457973f, + 0.834862875f, 0.547894059f, 0.836547727f, 0.545324988f, 0.838224706f, + 0.542750785f, 0.839893794f, 0.540171473f, 0.841554977f, 0.537587076f, + 0.843208240f, 0.534997620f, 0.844853565f, 0.532403128f, 0.846490939f, + 0.529803625f, 0.848120345f, 0.527199135f, 0.849741768f, 0.524589683f, + 0.851355193f, 0.521975293f, 0.852960605f, 0.519355990f, 0.854557988f, + 0.516731799f, 0.856147328f, 0.514102744f, 0.857728610f, 0.511468850f, + 0.859301818f, 0.508830143f, 0.860866939f, 0.506186645f, 0.862423956f, + 0.503538384f, 0.863972856f, 0.500885383f, 0.865513624f, 0.498227667f, + 0.867046246f, 0.495565262f, 0.868570706f, 0.492898192f, 0.870086991f, + 0.490226483f, 0.871595087f, 0.487550160f, 0.873094978f, 0.484869248f, + 0.874586652f, 0.482183772f, 0.876070094f, 0.479493758f, 0.877545290f, + 0.476799230f, 0.879012226f, 0.474100215f, 0.880470889f, 0.471396737f, + 0.881921264f, 0.468688822f, 0.883363339f, 0.465976496f, 0.884797098f, + 0.463259784f, 0.886222530f, 0.460538711f, 0.887639620f, 0.457813304f, + 0.889048356f, 0.455083587f, 0.890448723f, 0.452349587f, 0.891840709f, + 0.449611330f, 0.893224301f, 0.446868840f, 0.894599486f, 0.444122145f, + 0.895966250f, 0.441371269f, 0.897324581f, 0.438616239f, 0.898674466f, + 0.435857080f, 0.900015892f, 0.433093819f, 0.901348847f, 0.430326481f, + 0.902673318f, 0.427555093f, 0.903989293f, 0.424779681f, 0.905296759f, + 0.422000271f, 0.906595705f, 0.419216888f, 0.907886116f, 0.416429560f, + 0.909167983f, 0.413638312f, 0.910441292f, 0.410843171f, 0.911706032f, + 0.408044163f, 0.912962190f, 0.405241314f, 0.914209756f, 0.402434651f, + 0.915448716f, 0.399624200f, 0.916679060f, 0.396809987f, 0.917900776f, + 0.393992040f, 0.919113852f, 0.391170384f, 0.920318277f, 0.388345047f, + 0.921514039f, 0.385516054f, 0.922701128f, 0.382683432f, 0.923879533f, + 0.379847209f, 0.925049241f, 0.377007410f, 0.926210242f, 0.374164063f, + 0.927362526f, 0.371317194f, 0.928506080f, 0.368466830f, 0.929640896f, + 0.365612998f, 0.930766961f, 0.362755724f, 0.931884266f, 0.359895037f, + 0.932992799f, 0.357030961f, 0.934092550f, 0.354163525f, 0.935183510f, + 0.351292756f, 0.936265667f, 0.348418680f, 0.937339012f, 0.345541325f, + 0.938403534f, 0.342660717f, 0.939459224f, 0.339776884f, 0.940506071f, + 0.336889853f, 0.941544065f, 0.333999651f, 0.942573198f, 0.331106306f, + 0.943593458f, 0.328209844f, 0.944604837f, 0.325310292f, 0.945607325f, + 0.322407679f, 0.946600913f, 0.319502031f, 0.947585591f, 0.316593376f, + 0.948561350f, 0.313681740f, 0.949528181f, 0.310767153f, 0.950486074f, + 0.307849640f, 0.951435021f, 0.304929230f, 0.952375013f, 0.302005949f, + 0.953306040f, 0.299079826f, 0.954228095f, 0.296150888f, 0.955141168f, + 0.293219163f, 0.956045251f, 0.290284677f, 0.956940336f, 0.287347460f, + 0.957826413f, 0.284407537f, 0.958703475f, 0.281464938f, 0.959571513f, + 0.278519689f, 0.960430519f, 0.275571819f, 0.961280486f, 0.272621355f, + 0.962121404f, 0.269668326f, 0.962953267f, 0.266712757f, 0.963776066f, + 0.263754679f, 0.964589793f, 0.260794118f, 0.965394442f, 0.257831102f, + 0.966190003f, 0.254865660f, 0.966976471f, 0.251897818f, 0.967753837f, + 0.248927606f, 0.968522094f, 0.245955050f, 0.969281235f, 0.242980180f, + 0.970031253f, 0.240003022f, 0.970772141f, 0.237023606f, 0.971503891f, + 0.234041959f, 0.972226497f, 0.231058108f, 0.972939952f, 0.228072083f, + 0.973644250f, 0.225083911f, 0.974339383f, 0.222093621f, 0.975025345f, + 0.219101240f, 0.975702130f, 0.216106797f, 0.976369731f, 0.213110320f, + 0.977028143f, 0.210111837f, 0.977677358f, 0.207111376f, 0.978317371f, + 0.204108966f, 0.978948175f, 0.201104635f, 0.979569766f, 0.198098411f, + 0.980182136f, 0.195090322f, 0.980785280f, 0.192080397f, 0.981379193f, + 0.189068664f, 0.981963869f, 0.186055152f, 0.982539302f, 0.183039888f, + 0.983105487f, 0.180022901f, 0.983662419f, 0.177004220f, 0.984210092f, + 0.173983873f, 0.984748502f, 0.170961889f, 0.985277642f, 0.167938295f, + 0.985797509f, 0.164913120f, 0.986308097f, 0.161886394f, 0.986809402f, + 0.158858143f, 0.987301418f, 0.155828398f, 0.987784142f, 0.152797185f, + 0.988257568f, 0.149764535f, 0.988721692f, 0.146730474f, 0.989176510f, + 0.143695033f, 0.989622017f, 0.140658239f, 0.990058210f, 0.137620122f, + 0.990485084f, 0.134580709f, 0.990902635f, 0.131540029f, 0.991310860f, + 0.128498111f, 0.991709754f, 0.125454983f, 0.992099313f, 0.122410675f, + 0.992479535f, 0.119365215f, 0.992850414f, 0.116318631f, 0.993211949f, + 0.113270952f, 0.993564136f, 0.110222207f, 0.993906970f, 0.107172425f, + 0.994240449f, 0.104121634f, 0.994564571f, 0.101069863f, 0.994879331f, + 0.098017140f, 0.995184727f, 0.094963495f, 0.995480755f, 0.091908956f, + 0.995767414f, 0.088853553f, 0.996044701f, 0.085797312f, 0.996312612f, + 0.082740265f, 0.996571146f, 0.079682438f, 0.996820299f, 0.076623861f, + 0.997060070f, 0.073564564f, 0.997290457f, 0.070504573f, 0.997511456f, + 0.067443920f, 0.997723067f, 0.064382631f, 0.997925286f, 0.061320736f, + 0.998118113f, 0.058258265f, 0.998301545f, 0.055195244f, 0.998475581f, + 0.052131705f, 0.998640218f, 0.049067674f, 0.998795456f, 0.046003182f, + 0.998941293f, 0.042938257f, 0.999077728f, 0.039872928f, 0.999204759f, + 0.036807223f, 0.999322385f, 0.033741172f, 0.999430605f, 0.030674803f, + 0.999529418f, 0.027608146f, 0.999618822f, 0.024541229f, 0.999698819f, + 0.021474080f, 0.999769405f, 0.018406730f, 0.999830582f, 0.015339206f, + 0.999882347f, 0.012271538f, 0.999924702f, 0.009203755f, 0.999957645f, + 0.006135885f, 0.999981175f, 0.003067957f, 0.999995294f, 0.000000000f, + 1.000000000f, -0.003067957f, 0.999995294f, -0.006135885f, 0.999981175f, + -0.009203755f, 0.999957645f, -0.012271538f, 0.999924702f, -0.015339206f, + 0.999882347f, -0.018406730f, 0.999830582f, -0.021474080f, 0.999769405f, + -0.024541229f, 0.999698819f, -0.027608146f, 0.999618822f, -0.030674803f, + 0.999529418f, -0.033741172f, 0.999430605f, -0.036807223f, 0.999322385f, + -0.039872928f, 0.999204759f, -0.042938257f, 0.999077728f, -0.046003182f, + 0.998941293f, -0.049067674f, 0.998795456f, -0.052131705f, 0.998640218f, + -0.055195244f, 0.998475581f, -0.058258265f, 0.998301545f, -0.061320736f, + 0.998118113f, -0.064382631f, 0.997925286f, -0.067443920f, 0.997723067f, + -0.070504573f, 0.997511456f, -0.073564564f, 0.997290457f, -0.076623861f, + 0.997060070f, -0.079682438f, 0.996820299f, -0.082740265f, 0.996571146f, + -0.085797312f, 0.996312612f, -0.088853553f, 0.996044701f, -0.091908956f, + 0.995767414f, -0.094963495f, 0.995480755f, -0.098017140f, 0.995184727f, + -0.101069863f, 0.994879331f, -0.104121634f, 0.994564571f, -0.107172425f, + 0.994240449f, -0.110222207f, 0.993906970f, -0.113270952f, 0.993564136f, + -0.116318631f, 0.993211949f, -0.119365215f, 0.992850414f, -0.122410675f, + 0.992479535f, -0.125454983f, 0.992099313f, -0.128498111f, 0.991709754f, + -0.131540029f, 0.991310860f, -0.134580709f, 0.990902635f, -0.137620122f, + 0.990485084f, -0.140658239f, 0.990058210f, -0.143695033f, 0.989622017f, + -0.146730474f, 0.989176510f, -0.149764535f, 0.988721692f, -0.152797185f, + 0.988257568f, -0.155828398f, 0.987784142f, -0.158858143f, 0.987301418f, + -0.161886394f, 0.986809402f, -0.164913120f, 0.986308097f, -0.167938295f, + 0.985797509f, -0.170961889f, 0.985277642f, -0.173983873f, 0.984748502f, + -0.177004220f, 0.984210092f, -0.180022901f, 0.983662419f, -0.183039888f, + 0.983105487f, -0.186055152f, 0.982539302f, -0.189068664f, 0.981963869f, + -0.192080397f, 0.981379193f, -0.195090322f, 0.980785280f, -0.198098411f, + 0.980182136f, -0.201104635f, 0.979569766f, -0.204108966f, 0.978948175f, + -0.207111376f, 0.978317371f, -0.210111837f, 0.977677358f, -0.213110320f, + 0.977028143f, -0.216106797f, 0.976369731f, -0.219101240f, 0.975702130f, + -0.222093621f, 0.975025345f, -0.225083911f, 0.974339383f, -0.228072083f, + 0.973644250f, -0.231058108f, 0.972939952f, -0.234041959f, 0.972226497f, + -0.237023606f, 0.971503891f, -0.240003022f, 0.970772141f, -0.242980180f, + 0.970031253f, -0.245955050f, 0.969281235f, -0.248927606f, 0.968522094f, + -0.251897818f, 0.967753837f, -0.254865660f, 0.966976471f, -0.257831102f, + 0.966190003f, -0.260794118f, 0.965394442f, -0.263754679f, 0.964589793f, + -0.266712757f, 0.963776066f, -0.269668326f, 0.962953267f, -0.272621355f, + 0.962121404f, -0.275571819f, 0.961280486f, -0.278519689f, 0.960430519f, + -0.281464938f, 0.959571513f, -0.284407537f, 0.958703475f, -0.287347460f, + 0.957826413f, -0.290284677f, 0.956940336f, -0.293219163f, 0.956045251f, + -0.296150888f, 0.955141168f, -0.299079826f, 0.954228095f, -0.302005949f, + 0.953306040f, -0.304929230f, 0.952375013f, -0.307849640f, 0.951435021f, + -0.310767153f, 0.950486074f, -0.313681740f, 0.949528181f, -0.316593376f, + 0.948561350f, -0.319502031f, 0.947585591f, -0.322407679f, 0.946600913f, + -0.325310292f, 0.945607325f, -0.328209844f, 0.944604837f, -0.331106306f, + 0.943593458f, -0.333999651f, 0.942573198f, -0.336889853f, 0.941544065f, + -0.339776884f, 0.940506071f, -0.342660717f, 0.939459224f, -0.345541325f, + 0.938403534f, -0.348418680f, 0.937339012f, -0.351292756f, 0.936265667f, + -0.354163525f, 0.935183510f, -0.357030961f, 0.934092550f, -0.359895037f, + 0.932992799f, -0.362755724f, 0.931884266f, -0.365612998f, 0.930766961f, + -0.368466830f, 0.929640896f, -0.371317194f, 0.928506080f, -0.374164063f, + 0.927362526f, -0.377007410f, 0.926210242f, -0.379847209f, 0.925049241f, + -0.382683432f, 0.923879533f, -0.385516054f, 0.922701128f, -0.388345047f, + 0.921514039f, -0.391170384f, 0.920318277f, -0.393992040f, 0.919113852f, + -0.396809987f, 0.917900776f, -0.399624200f, 0.916679060f, -0.402434651f, + 0.915448716f, -0.405241314f, 0.914209756f, -0.408044163f, 0.912962190f, + -0.410843171f, 0.911706032f, -0.413638312f, 0.910441292f, -0.416429560f, + 0.909167983f, -0.419216888f, 0.907886116f, -0.422000271f, 0.906595705f, + -0.424779681f, 0.905296759f, -0.427555093f, 0.903989293f, -0.430326481f, + 0.902673318f, -0.433093819f, 0.901348847f, -0.435857080f, 0.900015892f, + -0.438616239f, 0.898674466f, -0.441371269f, 0.897324581f, -0.444122145f, + 0.895966250f, -0.446868840f, 0.894599486f, -0.449611330f, 0.893224301f, + -0.452349587f, 0.891840709f, -0.455083587f, 0.890448723f, -0.457813304f, + 0.889048356f, -0.460538711f, 0.887639620f, -0.463259784f, 0.886222530f, + -0.465976496f, 0.884797098f, -0.468688822f, 0.883363339f, -0.471396737f, + 0.881921264f, -0.474100215f, 0.880470889f, -0.476799230f, 0.879012226f, + -0.479493758f, 0.877545290f, -0.482183772f, 0.876070094f, -0.484869248f, + 0.874586652f, -0.487550160f, 0.873094978f, -0.490226483f, 0.871595087f, + -0.492898192f, 0.870086991f, -0.495565262f, 0.868570706f, -0.498227667f, + 0.867046246f, -0.500885383f, 0.865513624f, -0.503538384f, 0.863972856f, + -0.506186645f, 0.862423956f, -0.508830143f, 0.860866939f, -0.511468850f, + 0.859301818f, -0.514102744f, 0.857728610f, -0.516731799f, 0.856147328f, + -0.519355990f, 0.854557988f, -0.521975293f, 0.852960605f, -0.524589683f, + 0.851355193f, -0.527199135f, 0.849741768f, -0.529803625f, 0.848120345f, + -0.532403128f, 0.846490939f, -0.534997620f, 0.844853565f, -0.537587076f, + 0.843208240f, -0.540171473f, 0.841554977f, -0.542750785f, 0.839893794f, + -0.545324988f, 0.838224706f, -0.547894059f, 0.836547727f, -0.550457973f, + 0.834862875f, -0.553016706f, 0.833170165f, -0.555570233f, 0.831469612f, + -0.558118531f, 0.829761234f, -0.560661576f, 0.828045045f, -0.563199344f, + 0.826321063f, -0.565731811f, 0.824589303f, -0.568258953f, 0.822849781f, + -0.570780746f, 0.821102515f, -0.573297167f, 0.819347520f, -0.575808191f, + 0.817584813f, -0.578313796f, 0.815814411f, -0.580813958f, 0.814036330f, + -0.583308653f, 0.812250587f, -0.585797857f, 0.810457198f, -0.588281548f, + 0.808656182f, -0.590759702f, 0.806847554f, -0.593232295f, 0.805031331f, + -0.595699304f, 0.803207531f, -0.598160707f, 0.801376172f, -0.600616479f, + 0.799537269f, -0.603066599f, 0.797690841f, -0.605511041f, 0.795836905f, + -0.607949785f, 0.793975478f, -0.610382806f, 0.792106577f, -0.612810082f, + 0.790230221f, -0.615231591f, 0.788346428f, -0.617647308f, 0.786455214f, + -0.620057212f, 0.784556597f, -0.622461279f, 0.782650596f, -0.624859488f, + 0.780737229f, -0.627251815f, 0.778816512f, -0.629638239f, 0.776888466f, + -0.632018736f, 0.774953107f, -0.634393284f, 0.773010453f, -0.636761861f, + 0.771060524f, -0.639124445f, 0.769103338f, -0.641481013f, 0.767138912f, + -0.643831543f, 0.765167266f, -0.646176013f, 0.763188417f, -0.648514401f, + 0.761202385f, -0.650846685f, 0.759209189f, -0.653172843f, 0.757208847f, + -0.655492853f, 0.755201377f, -0.657806693f, 0.753186799f, -0.660114342f, + 0.751165132f, -0.662415778f, 0.749136395f, -0.664710978f, 0.747100606f, + -0.666999922f, 0.745057785f, -0.669282588f, 0.743007952f, -0.671558955f, + 0.740951125f, -0.673829000f, 0.738887324f, -0.676092704f, 0.736816569f, + -0.678350043f, 0.734738878f, -0.680600998f, 0.732654272f, -0.682845546f, + 0.730562769f, -0.685083668f, 0.728464390f, -0.687315341f, 0.726359155f, + -0.689540545f, 0.724247083f, -0.691759258f, 0.722128194f, -0.693971461f, + 0.720002508f, -0.696177131f, 0.717870045f, -0.698376249f, 0.715730825f, + -0.700568794f, 0.713584869f, -0.702754744f, 0.711432196f, -0.704934080f, + 0.709272826f, -0.707106781f, 0.707106781f, -0.709272826f, 0.704934080f, + -0.711432196f, 0.702754744f, -0.713584869f, 0.700568794f, -0.715730825f, + 0.698376249f, -0.717870045f, 0.696177131f, -0.720002508f, 0.693971461f, + -0.722128194f, 0.691759258f, -0.724247083f, 0.689540545f, -0.726359155f, + 0.687315341f, -0.728464390f, 0.685083668f, -0.730562769f, 0.682845546f, + -0.732654272f, 0.680600998f, -0.734738878f, 0.678350043f, -0.736816569f, + 0.676092704f, -0.738887324f, 0.673829000f, -0.740951125f, 0.671558955f, + -0.743007952f, 0.669282588f, -0.745057785f, 0.666999922f, -0.747100606f, + 0.664710978f, -0.749136395f, 0.662415778f, -0.751165132f, 0.660114342f, + -0.753186799f, 0.657806693f, -0.755201377f, 0.655492853f, -0.757208847f, + 0.653172843f, -0.759209189f, 0.650846685f, -0.761202385f, 0.648514401f, + -0.763188417f, 0.646176013f, -0.765167266f, 0.643831543f, -0.767138912f, + 0.641481013f, -0.769103338f, 0.639124445f, -0.771060524f, 0.636761861f, + -0.773010453f, 0.634393284f, -0.774953107f, 0.632018736f, -0.776888466f, + 0.629638239f, -0.778816512f, 0.627251815f, -0.780737229f, 0.624859488f, + -0.782650596f, 0.622461279f, -0.784556597f, 0.620057212f, -0.786455214f, + 0.617647308f, -0.788346428f, 0.615231591f, -0.790230221f, 0.612810082f, + -0.792106577f, 0.610382806f, -0.793975478f, 0.607949785f, -0.795836905f, + 0.605511041f, -0.797690841f, 0.603066599f, -0.799537269f, 0.600616479f, + -0.801376172f, 0.598160707f, -0.803207531f, 0.595699304f, -0.805031331f, + 0.593232295f, -0.806847554f, 0.590759702f, -0.808656182f, 0.588281548f, + -0.810457198f, 0.585797857f, -0.812250587f, 0.583308653f, -0.814036330f, + 0.580813958f, -0.815814411f, 0.578313796f, -0.817584813f, 0.575808191f, + -0.819347520f, 0.573297167f, -0.821102515f, 0.570780746f, -0.822849781f, + 0.568258953f, -0.824589303f, 0.565731811f, -0.826321063f, 0.563199344f, + -0.828045045f, 0.560661576f, -0.829761234f, 0.558118531f, -0.831469612f, + 0.555570233f, -0.833170165f, 0.553016706f, -0.834862875f, 0.550457973f, + -0.836547727f, 0.547894059f, -0.838224706f, 0.545324988f, -0.839893794f, + 0.542750785f, -0.841554977f, 0.540171473f, -0.843208240f, 0.537587076f, + -0.844853565f, 0.534997620f, -0.846490939f, 0.532403128f, -0.848120345f, + 0.529803625f, -0.849741768f, 0.527199135f, -0.851355193f, 0.524589683f, + -0.852960605f, 0.521975293f, -0.854557988f, 0.519355990f, -0.856147328f, + 0.516731799f, -0.857728610f, 0.514102744f, -0.859301818f, 0.511468850f, + -0.860866939f, 0.508830143f, -0.862423956f, 0.506186645f, -0.863972856f, + 0.503538384f, -0.865513624f, 0.500885383f, -0.867046246f, 0.498227667f, + -0.868570706f, 0.495565262f, -0.870086991f, 0.492898192f, -0.871595087f, + 0.490226483f, -0.873094978f, 0.487550160f, -0.874586652f, 0.484869248f, + -0.876070094f, 0.482183772f, -0.877545290f, 0.479493758f, -0.879012226f, + 0.476799230f, -0.880470889f, 0.474100215f, -0.881921264f, 0.471396737f, + -0.883363339f, 0.468688822f, -0.884797098f, 0.465976496f, -0.886222530f, + 0.463259784f, -0.887639620f, 0.460538711f, -0.889048356f, 0.457813304f, + -0.890448723f, 0.455083587f, -0.891840709f, 0.452349587f, -0.893224301f, + 0.449611330f, -0.894599486f, 0.446868840f, -0.895966250f, 0.444122145f, + -0.897324581f, 0.441371269f, -0.898674466f, 0.438616239f, -0.900015892f, + 0.435857080f, -0.901348847f, 0.433093819f, -0.902673318f, 0.430326481f, + -0.903989293f, 0.427555093f, -0.905296759f, 0.424779681f, -0.906595705f, + 0.422000271f, -0.907886116f, 0.419216888f, -0.909167983f, 0.416429560f, + -0.910441292f, 0.413638312f, -0.911706032f, 0.410843171f, -0.912962190f, + 0.408044163f, -0.914209756f, 0.405241314f, -0.915448716f, 0.402434651f, + -0.916679060f, 0.399624200f, -0.917900776f, 0.396809987f, -0.919113852f, + 0.393992040f, -0.920318277f, 0.391170384f, -0.921514039f, 0.388345047f, + -0.922701128f, 0.385516054f, -0.923879533f, 0.382683432f, -0.925049241f, + 0.379847209f, -0.926210242f, 0.377007410f, -0.927362526f, 0.374164063f, + -0.928506080f, 0.371317194f, -0.929640896f, 0.368466830f, -0.930766961f, + 0.365612998f, -0.931884266f, 0.362755724f, -0.932992799f, 0.359895037f, + -0.934092550f, 0.357030961f, -0.935183510f, 0.354163525f, -0.936265667f, + 0.351292756f, -0.937339012f, 0.348418680f, -0.938403534f, 0.345541325f, + -0.939459224f, 0.342660717f, -0.940506071f, 0.339776884f, -0.941544065f, + 0.336889853f, -0.942573198f, 0.333999651f, -0.943593458f, 0.331106306f, + -0.944604837f, 0.328209844f, -0.945607325f, 0.325310292f, -0.946600913f, + 0.322407679f, -0.947585591f, 0.319502031f, -0.948561350f, 0.316593376f, + -0.949528181f, 0.313681740f, -0.950486074f, 0.310767153f, -0.951435021f, + 0.307849640f, -0.952375013f, 0.304929230f, -0.953306040f, 0.302005949f, + -0.954228095f, 0.299079826f, -0.955141168f, 0.296150888f, -0.956045251f, + 0.293219163f, -0.956940336f, 0.290284677f, -0.957826413f, 0.287347460f, + -0.958703475f, 0.284407537f, -0.959571513f, 0.281464938f, -0.960430519f, + 0.278519689f, -0.961280486f, 0.275571819f, -0.962121404f, 0.272621355f, + -0.962953267f, 0.269668326f, -0.963776066f, 0.266712757f, -0.964589793f, + 0.263754679f, -0.965394442f, 0.260794118f, -0.966190003f, 0.257831102f, + -0.966976471f, 0.254865660f, -0.967753837f, 0.251897818f, -0.968522094f, + 0.248927606f, -0.969281235f, 0.245955050f, -0.970031253f, 0.242980180f, + -0.970772141f, 0.240003022f, -0.971503891f, 0.237023606f, -0.972226497f, + 0.234041959f, -0.972939952f, 0.231058108f, -0.973644250f, 0.228072083f, + -0.974339383f, 0.225083911f, -0.975025345f, 0.222093621f, -0.975702130f, + 0.219101240f, -0.976369731f, 0.216106797f, -0.977028143f, 0.213110320f, + -0.977677358f, 0.210111837f, -0.978317371f, 0.207111376f, -0.978948175f, + 0.204108966f, -0.979569766f, 0.201104635f, -0.980182136f, 0.198098411f, + -0.980785280f, 0.195090322f, -0.981379193f, 0.192080397f, -0.981963869f, + 0.189068664f, -0.982539302f, 0.186055152f, -0.983105487f, 0.183039888f, + -0.983662419f, 0.180022901f, -0.984210092f, 0.177004220f, -0.984748502f, + 0.173983873f, -0.985277642f, 0.170961889f, -0.985797509f, 0.167938295f, + -0.986308097f, 0.164913120f, -0.986809402f, 0.161886394f, -0.987301418f, + 0.158858143f, -0.987784142f, 0.155828398f, -0.988257568f, 0.152797185f, + -0.988721692f, 0.149764535f, -0.989176510f, 0.146730474f, -0.989622017f, + 0.143695033f, -0.990058210f, 0.140658239f, -0.990485084f, 0.137620122f, + -0.990902635f, 0.134580709f, -0.991310860f, 0.131540029f, -0.991709754f, + 0.128498111f, -0.992099313f, 0.125454983f, -0.992479535f, 0.122410675f, + -0.992850414f, 0.119365215f, -0.993211949f, 0.116318631f, -0.993564136f, + 0.113270952f, -0.993906970f, 0.110222207f, -0.994240449f, 0.107172425f, + -0.994564571f, 0.104121634f, -0.994879331f, 0.101069863f, -0.995184727f, + 0.098017140f, -0.995480755f, 0.094963495f, -0.995767414f, 0.091908956f, + -0.996044701f, 0.088853553f, -0.996312612f, 0.085797312f, -0.996571146f, + 0.082740265f, -0.996820299f, 0.079682438f, -0.997060070f, 0.076623861f, + -0.997290457f, 0.073564564f, -0.997511456f, 0.070504573f, -0.997723067f, + 0.067443920f, -0.997925286f, 0.064382631f, -0.998118113f, 0.061320736f, + -0.998301545f, 0.058258265f, -0.998475581f, 0.055195244f, -0.998640218f, + 0.052131705f, -0.998795456f, 0.049067674f, -0.998941293f, 0.046003182f, + -0.999077728f, 0.042938257f, -0.999204759f, 0.039872928f, -0.999322385f, + 0.036807223f, -0.999430605f, 0.033741172f, -0.999529418f, 0.030674803f, + -0.999618822f, 0.027608146f, -0.999698819f, 0.024541229f, -0.999769405f, + 0.021474080f, -0.999830582f, 0.018406730f, -0.999882347f, 0.015339206f, + -0.999924702f, 0.012271538f, -0.999957645f, 0.009203755f, -0.999981175f, + 0.006135885f, -0.999995294f, 0.003067957f, -1.000000000f, 0.000000000f, + -0.999995294f, -0.003067957f, -0.999981175f, -0.006135885f, -0.999957645f, + -0.009203755f, -0.999924702f, -0.012271538f, -0.999882347f, -0.015339206f, + -0.999830582f, -0.018406730f, -0.999769405f, -0.021474080f, -0.999698819f, + -0.024541229f, -0.999618822f, -0.027608146f, -0.999529418f, -0.030674803f, + -0.999430605f, -0.033741172f, -0.999322385f, -0.036807223f, -0.999204759f, + -0.039872928f, -0.999077728f, -0.042938257f, -0.998941293f, -0.046003182f, + -0.998795456f, -0.049067674f, -0.998640218f, -0.052131705f, -0.998475581f, + -0.055195244f, -0.998301545f, -0.058258265f, -0.998118113f, -0.061320736f, + -0.997925286f, -0.064382631f, -0.997723067f, -0.067443920f, -0.997511456f, + -0.070504573f, -0.997290457f, -0.073564564f, -0.997060070f, -0.076623861f, + -0.996820299f, -0.079682438f, -0.996571146f, -0.082740265f, -0.996312612f, + -0.085797312f, -0.996044701f, -0.088853553f, -0.995767414f, -0.091908956f, + -0.995480755f, -0.094963495f, -0.995184727f, -0.098017140f, -0.994879331f, + -0.101069863f, -0.994564571f, -0.104121634f, -0.994240449f, -0.107172425f, + -0.993906970f, -0.110222207f, -0.993564136f, -0.113270952f, -0.993211949f, + -0.116318631f, -0.992850414f, -0.119365215f, -0.992479535f, -0.122410675f, + -0.992099313f, -0.125454983f, -0.991709754f, -0.128498111f, -0.991310860f, + -0.131540029f, -0.990902635f, -0.134580709f, -0.990485084f, -0.137620122f, + -0.990058210f, -0.140658239f, -0.989622017f, -0.143695033f, -0.989176510f, + -0.146730474f, -0.988721692f, -0.149764535f, -0.988257568f, -0.152797185f, + -0.987784142f, -0.155828398f, -0.987301418f, -0.158858143f, -0.986809402f, + -0.161886394f, -0.986308097f, -0.164913120f, -0.985797509f, -0.167938295f, + -0.985277642f, -0.170961889f, -0.984748502f, -0.173983873f, -0.984210092f, + -0.177004220f, -0.983662419f, -0.180022901f, -0.983105487f, -0.183039888f, + -0.982539302f, -0.186055152f, -0.981963869f, -0.189068664f, -0.981379193f, + -0.192080397f, -0.980785280f, -0.195090322f, -0.980182136f, -0.198098411f, + -0.979569766f, -0.201104635f, -0.978948175f, -0.204108966f, -0.978317371f, + -0.207111376f, -0.977677358f, -0.210111837f, -0.977028143f, -0.213110320f, + -0.976369731f, -0.216106797f, -0.975702130f, -0.219101240f, -0.975025345f, + -0.222093621f, -0.974339383f, -0.225083911f, -0.973644250f, -0.228072083f, + -0.972939952f, -0.231058108f, -0.972226497f, -0.234041959f, -0.971503891f, + -0.237023606f, -0.970772141f, -0.240003022f, -0.970031253f, -0.242980180f, + -0.969281235f, -0.245955050f, -0.968522094f, -0.248927606f, -0.967753837f, + -0.251897818f, -0.966976471f, -0.254865660f, -0.966190003f, -0.257831102f, + -0.965394442f, -0.260794118f, -0.964589793f, -0.263754679f, -0.963776066f, + -0.266712757f, -0.962953267f, -0.269668326f, -0.962121404f, -0.272621355f, + -0.961280486f, -0.275571819f, -0.960430519f, -0.278519689f, -0.959571513f, + -0.281464938f, -0.958703475f, -0.284407537f, -0.957826413f, -0.287347460f, + -0.956940336f, -0.290284677f, -0.956045251f, -0.293219163f, -0.955141168f, + -0.296150888f, -0.954228095f, -0.299079826f, -0.953306040f, -0.302005949f, + -0.952375013f, -0.304929230f, -0.951435021f, -0.307849640f, -0.950486074f, + -0.310767153f, -0.949528181f, -0.313681740f, -0.948561350f, -0.316593376f, + -0.947585591f, -0.319502031f, -0.946600913f, -0.322407679f, -0.945607325f, + -0.325310292f, -0.944604837f, -0.328209844f, -0.943593458f, -0.331106306f, + -0.942573198f, -0.333999651f, -0.941544065f, -0.336889853f, -0.940506071f, + -0.339776884f, -0.939459224f, -0.342660717f, -0.938403534f, -0.345541325f, + -0.937339012f, -0.348418680f, -0.936265667f, -0.351292756f, -0.935183510f, + -0.354163525f, -0.934092550f, -0.357030961f, -0.932992799f, -0.359895037f, + -0.931884266f, -0.362755724f, -0.930766961f, -0.365612998f, -0.929640896f, + -0.368466830f, -0.928506080f, -0.371317194f, -0.927362526f, -0.374164063f, + -0.926210242f, -0.377007410f, -0.925049241f, -0.379847209f, -0.923879533f, + -0.382683432f, -0.922701128f, -0.385516054f, -0.921514039f, -0.388345047f, + -0.920318277f, -0.391170384f, -0.919113852f, -0.393992040f, -0.917900776f, + -0.396809987f, -0.916679060f, -0.399624200f, -0.915448716f, -0.402434651f, + -0.914209756f, -0.405241314f, -0.912962190f, -0.408044163f, -0.911706032f, + -0.410843171f, -0.910441292f, -0.413638312f, -0.909167983f, -0.416429560f, + -0.907886116f, -0.419216888f, -0.906595705f, -0.422000271f, -0.905296759f, + -0.424779681f, -0.903989293f, -0.427555093f, -0.902673318f, -0.430326481f, + -0.901348847f, -0.433093819f, -0.900015892f, -0.435857080f, -0.898674466f, + -0.438616239f, -0.897324581f, -0.441371269f, -0.895966250f, -0.444122145f, + -0.894599486f, -0.446868840f, -0.893224301f, -0.449611330f, -0.891840709f, + -0.452349587f, -0.890448723f, -0.455083587f, -0.889048356f, -0.457813304f, + -0.887639620f, -0.460538711f, -0.886222530f, -0.463259784f, -0.884797098f, + -0.465976496f, -0.883363339f, -0.468688822f, -0.881921264f, -0.471396737f, + -0.880470889f, -0.474100215f, -0.879012226f, -0.476799230f, -0.877545290f, + -0.479493758f, -0.876070094f, -0.482183772f, -0.874586652f, -0.484869248f, + -0.873094978f, -0.487550160f, -0.871595087f, -0.490226483f, -0.870086991f, + -0.492898192f, -0.868570706f, -0.495565262f, -0.867046246f, -0.498227667f, + -0.865513624f, -0.500885383f, -0.863972856f, -0.503538384f, -0.862423956f, + -0.506186645f, -0.860866939f, -0.508830143f, -0.859301818f, -0.511468850f, + -0.857728610f, -0.514102744f, -0.856147328f, -0.516731799f, -0.854557988f, + -0.519355990f, -0.852960605f, -0.521975293f, -0.851355193f, -0.524589683f, + -0.849741768f, -0.527199135f, -0.848120345f, -0.529803625f, -0.846490939f, + -0.532403128f, -0.844853565f, -0.534997620f, -0.843208240f, -0.537587076f, + -0.841554977f, -0.540171473f, -0.839893794f, -0.542750785f, -0.838224706f, + -0.545324988f, -0.836547727f, -0.547894059f, -0.834862875f, -0.550457973f, + -0.833170165f, -0.553016706f, -0.831469612f, -0.555570233f, -0.829761234f, + -0.558118531f, -0.828045045f, -0.560661576f, -0.826321063f, -0.563199344f, + -0.824589303f, -0.565731811f, -0.822849781f, -0.568258953f, -0.821102515f, + -0.570780746f, -0.819347520f, -0.573297167f, -0.817584813f, -0.575808191f, + -0.815814411f, -0.578313796f, -0.814036330f, -0.580813958f, -0.812250587f, + -0.583308653f, -0.810457198f, -0.585797857f, -0.808656182f, -0.588281548f, + -0.806847554f, -0.590759702f, -0.805031331f, -0.593232295f, -0.803207531f, + -0.595699304f, -0.801376172f, -0.598160707f, -0.799537269f, -0.600616479f, + -0.797690841f, -0.603066599f, -0.795836905f, -0.605511041f, -0.793975478f, + -0.607949785f, -0.792106577f, -0.610382806f, -0.790230221f, -0.612810082f, + -0.788346428f, -0.615231591f, -0.786455214f, -0.617647308f, -0.784556597f, + -0.620057212f, -0.782650596f, -0.622461279f, -0.780737229f, -0.624859488f, + -0.778816512f, -0.627251815f, -0.776888466f, -0.629638239f, -0.774953107f, + -0.632018736f, -0.773010453f, -0.634393284f, -0.771060524f, -0.636761861f, + -0.769103338f, -0.639124445f, -0.767138912f, -0.641481013f, -0.765167266f, + -0.643831543f, -0.763188417f, -0.646176013f, -0.761202385f, -0.648514401f, + -0.759209189f, -0.650846685f, -0.757208847f, -0.653172843f, -0.755201377f, + -0.655492853f, -0.753186799f, -0.657806693f, -0.751165132f, -0.660114342f, + -0.749136395f, -0.662415778f, -0.747100606f, -0.664710978f, -0.745057785f, + -0.666999922f, -0.743007952f, -0.669282588f, -0.740951125f, -0.671558955f, + -0.738887324f, -0.673829000f, -0.736816569f, -0.676092704f, -0.734738878f, + -0.678350043f, -0.732654272f, -0.680600998f, -0.730562769f, -0.682845546f, + -0.728464390f, -0.685083668f, -0.726359155f, -0.687315341f, -0.724247083f, + -0.689540545f, -0.722128194f, -0.691759258f, -0.720002508f, -0.693971461f, + -0.717870045f, -0.696177131f, -0.715730825f, -0.698376249f, -0.713584869f, + -0.700568794f, -0.711432196f, -0.702754744f, -0.709272826f, -0.704934080f, + -0.707106781f, -0.707106781f, -0.704934080f, -0.709272826f, -0.702754744f, + -0.711432196f, -0.700568794f, -0.713584869f, -0.698376249f, -0.715730825f, + -0.696177131f, -0.717870045f, -0.693971461f, -0.720002508f, -0.691759258f, + -0.722128194f, -0.689540545f, -0.724247083f, -0.687315341f, -0.726359155f, + -0.685083668f, -0.728464390f, -0.682845546f, -0.730562769f, -0.680600998f, + -0.732654272f, -0.678350043f, -0.734738878f, -0.676092704f, -0.736816569f, + -0.673829000f, -0.738887324f, -0.671558955f, -0.740951125f, -0.669282588f, + -0.743007952f, -0.666999922f, -0.745057785f, -0.664710978f, -0.747100606f, + -0.662415778f, -0.749136395f, -0.660114342f, -0.751165132f, -0.657806693f, + -0.753186799f, -0.655492853f, -0.755201377f, -0.653172843f, -0.757208847f, + -0.650846685f, -0.759209189f, -0.648514401f, -0.761202385f, -0.646176013f, + -0.763188417f, -0.643831543f, -0.765167266f, -0.641481013f, -0.767138912f, + -0.639124445f, -0.769103338f, -0.636761861f, -0.771060524f, -0.634393284f, + -0.773010453f, -0.632018736f, -0.774953107f, -0.629638239f, -0.776888466f, + -0.627251815f, -0.778816512f, -0.624859488f, -0.780737229f, -0.622461279f, + -0.782650596f, -0.620057212f, -0.784556597f, -0.617647308f, -0.786455214f, + -0.615231591f, -0.788346428f, -0.612810082f, -0.790230221f, -0.610382806f, + -0.792106577f, -0.607949785f, -0.793975478f, -0.605511041f, -0.795836905f, + -0.603066599f, -0.797690841f, -0.600616479f, -0.799537269f, -0.598160707f, + -0.801376172f, -0.595699304f, -0.803207531f, -0.593232295f, -0.805031331f, + -0.590759702f, -0.806847554f, -0.588281548f, -0.808656182f, -0.585797857f, + -0.810457198f, -0.583308653f, -0.812250587f, -0.580813958f, -0.814036330f, + -0.578313796f, -0.815814411f, -0.575808191f, -0.817584813f, -0.573297167f, + -0.819347520f, -0.570780746f, -0.821102515f, -0.568258953f, -0.822849781f, + -0.565731811f, -0.824589303f, -0.563199344f, -0.826321063f, -0.560661576f, + -0.828045045f, -0.558118531f, -0.829761234f, -0.555570233f, -0.831469612f, + -0.553016706f, -0.833170165f, -0.550457973f, -0.834862875f, -0.547894059f, + -0.836547727f, -0.545324988f, -0.838224706f, -0.542750785f, -0.839893794f, + -0.540171473f, -0.841554977f, -0.537587076f, -0.843208240f, -0.534997620f, + -0.844853565f, -0.532403128f, -0.846490939f, -0.529803625f, -0.848120345f, + -0.527199135f, -0.849741768f, -0.524589683f, -0.851355193f, -0.521975293f, + -0.852960605f, -0.519355990f, -0.854557988f, -0.516731799f, -0.856147328f, + -0.514102744f, -0.857728610f, -0.511468850f, -0.859301818f, -0.508830143f, + -0.860866939f, -0.506186645f, -0.862423956f, -0.503538384f, -0.863972856f, + -0.500885383f, -0.865513624f, -0.498227667f, -0.867046246f, -0.495565262f, + -0.868570706f, -0.492898192f, -0.870086991f, -0.490226483f, -0.871595087f, + -0.487550160f, -0.873094978f, -0.484869248f, -0.874586652f, -0.482183772f, + -0.876070094f, -0.479493758f, -0.877545290f, -0.476799230f, -0.879012226f, + -0.474100215f, -0.880470889f, -0.471396737f, -0.881921264f, -0.468688822f, + -0.883363339f, -0.465976496f, -0.884797098f, -0.463259784f, -0.886222530f, + -0.460538711f, -0.887639620f, -0.457813304f, -0.889048356f, -0.455083587f, + -0.890448723f, -0.452349587f, -0.891840709f, -0.449611330f, -0.893224301f, + -0.446868840f, -0.894599486f, -0.444122145f, -0.895966250f, -0.441371269f, + -0.897324581f, -0.438616239f, -0.898674466f, -0.435857080f, -0.900015892f, + -0.433093819f, -0.901348847f, -0.430326481f, -0.902673318f, -0.427555093f, + -0.903989293f, -0.424779681f, -0.905296759f, -0.422000271f, -0.906595705f, + -0.419216888f, -0.907886116f, -0.416429560f, -0.909167983f, -0.413638312f, + -0.910441292f, -0.410843171f, -0.911706032f, -0.408044163f, -0.912962190f, + -0.405241314f, -0.914209756f, -0.402434651f, -0.915448716f, -0.399624200f, + -0.916679060f, -0.396809987f, -0.917900776f, -0.393992040f, -0.919113852f, + -0.391170384f, -0.920318277f, -0.388345047f, -0.921514039f, -0.385516054f, + -0.922701128f, -0.382683432f, -0.923879533f, -0.379847209f, -0.925049241f, + -0.377007410f, -0.926210242f, -0.374164063f, -0.927362526f, -0.371317194f, + -0.928506080f, -0.368466830f, -0.929640896f, -0.365612998f, -0.930766961f, + -0.362755724f, -0.931884266f, -0.359895037f, -0.932992799f, -0.357030961f, + -0.934092550f, -0.354163525f, -0.935183510f, -0.351292756f, -0.936265667f, + -0.348418680f, -0.937339012f, -0.345541325f, -0.938403534f, -0.342660717f, + -0.939459224f, -0.339776884f, -0.940506071f, -0.336889853f, -0.941544065f, + -0.333999651f, -0.942573198f, -0.331106306f, -0.943593458f, -0.328209844f, + -0.944604837f, -0.325310292f, -0.945607325f, -0.322407679f, -0.946600913f, + -0.319502031f, -0.947585591f, -0.316593376f, -0.948561350f, -0.313681740f, + -0.949528181f, -0.310767153f, -0.950486074f, -0.307849640f, -0.951435021f, + -0.304929230f, -0.952375013f, -0.302005949f, -0.953306040f, -0.299079826f, + -0.954228095f, -0.296150888f, -0.955141168f, -0.293219163f, -0.956045251f, + -0.290284677f, -0.956940336f, -0.287347460f, -0.957826413f, -0.284407537f, + -0.958703475f, -0.281464938f, -0.959571513f, -0.278519689f, -0.960430519f, + -0.275571819f, -0.961280486f, -0.272621355f, -0.962121404f, -0.269668326f, + -0.962953267f, -0.266712757f, -0.963776066f, -0.263754679f, -0.964589793f, + -0.260794118f, -0.965394442f, -0.257831102f, -0.966190003f, -0.254865660f, + -0.966976471f, -0.251897818f, -0.967753837f, -0.248927606f, -0.968522094f, + -0.245955050f, -0.969281235f, -0.242980180f, -0.970031253f, -0.240003022f, + -0.970772141f, -0.237023606f, -0.971503891f, -0.234041959f, -0.972226497f, + -0.231058108f, -0.972939952f, -0.228072083f, -0.973644250f, -0.225083911f, + -0.974339383f, -0.222093621f, -0.975025345f, -0.219101240f, -0.975702130f, + -0.216106797f, -0.976369731f, -0.213110320f, -0.977028143f, -0.210111837f, + -0.977677358f, -0.207111376f, -0.978317371f, -0.204108966f, -0.978948175f, + -0.201104635f, -0.979569766f, -0.198098411f, -0.980182136f, -0.195090322f, + -0.980785280f, -0.192080397f, -0.981379193f, -0.189068664f, -0.981963869f, + -0.186055152f, -0.982539302f, -0.183039888f, -0.983105487f, -0.180022901f, + -0.983662419f, -0.177004220f, -0.984210092f, -0.173983873f, -0.984748502f, + -0.170961889f, -0.985277642f, -0.167938295f, -0.985797509f, -0.164913120f, + -0.986308097f, -0.161886394f, -0.986809402f, -0.158858143f, -0.987301418f, + -0.155828398f, -0.987784142f, -0.152797185f, -0.988257568f, -0.149764535f, + -0.988721692f, -0.146730474f, -0.989176510f, -0.143695033f, -0.989622017f, + -0.140658239f, -0.990058210f, -0.137620122f, -0.990485084f, -0.134580709f, + -0.990902635f, -0.131540029f, -0.991310860f, -0.128498111f, -0.991709754f, + -0.125454983f, -0.992099313f, -0.122410675f, -0.992479535f, -0.119365215f, + -0.992850414f, -0.116318631f, -0.993211949f, -0.113270952f, -0.993564136f, + -0.110222207f, -0.993906970f, -0.107172425f, -0.994240449f, -0.104121634f, + -0.994564571f, -0.101069863f, -0.994879331f, -0.098017140f, -0.995184727f, + -0.094963495f, -0.995480755f, -0.091908956f, -0.995767414f, -0.088853553f, + -0.996044701f, -0.085797312f, -0.996312612f, -0.082740265f, -0.996571146f, + -0.079682438f, -0.996820299f, -0.076623861f, -0.997060070f, -0.073564564f, + -0.997290457f, -0.070504573f, -0.997511456f, -0.067443920f, -0.997723067f, + -0.064382631f, -0.997925286f, -0.061320736f, -0.998118113f, -0.058258265f, + -0.998301545f, -0.055195244f, -0.998475581f, -0.052131705f, -0.998640218f, + -0.049067674f, -0.998795456f, -0.046003182f, -0.998941293f, -0.042938257f, + -0.999077728f, -0.039872928f, -0.999204759f, -0.036807223f, -0.999322385f, + -0.033741172f, -0.999430605f, -0.030674803f, -0.999529418f, -0.027608146f, + -0.999618822f, -0.024541229f, -0.999698819f, -0.021474080f, -0.999769405f, + -0.018406730f, -0.999830582f, -0.015339206f, -0.999882347f, -0.012271538f, + -0.999924702f, -0.009203755f, -0.999957645f, -0.006135885f, -0.999981175f, + -0.003067957f, -0.999995294f, -0.000000000f, -1.000000000f, 0.003067957f, + -0.999995294f, 0.006135885f, -0.999981175f, 0.009203755f, -0.999957645f, + 0.012271538f, -0.999924702f, 0.015339206f, -0.999882347f, 0.018406730f, + -0.999830582f, 0.021474080f, -0.999769405f, 0.024541229f, -0.999698819f, + 0.027608146f, -0.999618822f, 0.030674803f, -0.999529418f, 0.033741172f, + -0.999430605f, 0.036807223f, -0.999322385f, 0.039872928f, -0.999204759f, + 0.042938257f, -0.999077728f, 0.046003182f, -0.998941293f, 0.049067674f, + -0.998795456f, 0.052131705f, -0.998640218f, 0.055195244f, -0.998475581f, + 0.058258265f, -0.998301545f, 0.061320736f, -0.998118113f, 0.064382631f, + -0.997925286f, 0.067443920f, -0.997723067f, 0.070504573f, -0.997511456f, + 0.073564564f, -0.997290457f, 0.076623861f, -0.997060070f, 0.079682438f, + -0.996820299f, 0.082740265f, -0.996571146f, 0.085797312f, -0.996312612f, + 0.088853553f, -0.996044701f, 0.091908956f, -0.995767414f, 0.094963495f, + -0.995480755f, 0.098017140f, -0.995184727f, 0.101069863f, -0.994879331f, + 0.104121634f, -0.994564571f, 0.107172425f, -0.994240449f, 0.110222207f, + -0.993906970f, 0.113270952f, -0.993564136f, 0.116318631f, -0.993211949f, + 0.119365215f, -0.992850414f, 0.122410675f, -0.992479535f, 0.125454983f, + -0.992099313f, 0.128498111f, -0.991709754f, 0.131540029f, -0.991310860f, + 0.134580709f, -0.990902635f, 0.137620122f, -0.990485084f, 0.140658239f, + -0.990058210f, 0.143695033f, -0.989622017f, 0.146730474f, -0.989176510f, + 0.149764535f, -0.988721692f, 0.152797185f, -0.988257568f, 0.155828398f, + -0.987784142f, 0.158858143f, -0.987301418f, 0.161886394f, -0.986809402f, + 0.164913120f, -0.986308097f, 0.167938295f, -0.985797509f, 0.170961889f, + -0.985277642f, 0.173983873f, -0.984748502f, 0.177004220f, -0.984210092f, + 0.180022901f, -0.983662419f, 0.183039888f, -0.983105487f, 0.186055152f, + -0.982539302f, 0.189068664f, -0.981963869f, 0.192080397f, -0.981379193f, + 0.195090322f, -0.980785280f, 0.198098411f, -0.980182136f, 0.201104635f, + -0.979569766f, 0.204108966f, -0.978948175f, 0.207111376f, -0.978317371f, + 0.210111837f, -0.977677358f, 0.213110320f, -0.977028143f, 0.216106797f, + -0.976369731f, 0.219101240f, -0.975702130f, 0.222093621f, -0.975025345f, + 0.225083911f, -0.974339383f, 0.228072083f, -0.973644250f, 0.231058108f, + -0.972939952f, 0.234041959f, -0.972226497f, 0.237023606f, -0.971503891f, + 0.240003022f, -0.970772141f, 0.242980180f, -0.970031253f, 0.245955050f, + -0.969281235f, 0.248927606f, -0.968522094f, 0.251897818f, -0.967753837f, + 0.254865660f, -0.966976471f, 0.257831102f, -0.966190003f, 0.260794118f, + -0.965394442f, 0.263754679f, -0.964589793f, 0.266712757f, -0.963776066f, + 0.269668326f, -0.962953267f, 0.272621355f, -0.962121404f, 0.275571819f, + -0.961280486f, 0.278519689f, -0.960430519f, 0.281464938f, -0.959571513f, + 0.284407537f, -0.958703475f, 0.287347460f, -0.957826413f, 0.290284677f, + -0.956940336f, 0.293219163f, -0.956045251f, 0.296150888f, -0.955141168f, + 0.299079826f, -0.954228095f, 0.302005949f, -0.953306040f, 0.304929230f, + -0.952375013f, 0.307849640f, -0.951435021f, 0.310767153f, -0.950486074f, + 0.313681740f, -0.949528181f, 0.316593376f, -0.948561350f, 0.319502031f, + -0.947585591f, 0.322407679f, -0.946600913f, 0.325310292f, -0.945607325f, + 0.328209844f, -0.944604837f, 0.331106306f, -0.943593458f, 0.333999651f, + -0.942573198f, 0.336889853f, -0.941544065f, 0.339776884f, -0.940506071f, + 0.342660717f, -0.939459224f, 0.345541325f, -0.938403534f, 0.348418680f, + -0.937339012f, 0.351292756f, -0.936265667f, 0.354163525f, -0.935183510f, + 0.357030961f, -0.934092550f, 0.359895037f, -0.932992799f, 0.362755724f, + -0.931884266f, 0.365612998f, -0.930766961f, 0.368466830f, -0.929640896f, + 0.371317194f, -0.928506080f, 0.374164063f, -0.927362526f, 0.377007410f, + -0.926210242f, 0.379847209f, -0.925049241f, 0.382683432f, -0.923879533f, + 0.385516054f, -0.922701128f, 0.388345047f, -0.921514039f, 0.391170384f, + -0.920318277f, 0.393992040f, -0.919113852f, 0.396809987f, -0.917900776f, + 0.399624200f, -0.916679060f, 0.402434651f, -0.915448716f, 0.405241314f, + -0.914209756f, 0.408044163f, -0.912962190f, 0.410843171f, -0.911706032f, + 0.413638312f, -0.910441292f, 0.416429560f, -0.909167983f, 0.419216888f, + -0.907886116f, 0.422000271f, -0.906595705f, 0.424779681f, -0.905296759f, + 0.427555093f, -0.903989293f, 0.430326481f, -0.902673318f, 0.433093819f, + -0.901348847f, 0.435857080f, -0.900015892f, 0.438616239f, -0.898674466f, + 0.441371269f, -0.897324581f, 0.444122145f, -0.895966250f, 0.446868840f, + -0.894599486f, 0.449611330f, -0.893224301f, 0.452349587f, -0.891840709f, + 0.455083587f, -0.890448723f, 0.457813304f, -0.889048356f, 0.460538711f, + -0.887639620f, 0.463259784f, -0.886222530f, 0.465976496f, -0.884797098f, + 0.468688822f, -0.883363339f, 0.471396737f, -0.881921264f, 0.474100215f, + -0.880470889f, 0.476799230f, -0.879012226f, 0.479493758f, -0.877545290f, + 0.482183772f, -0.876070094f, 0.484869248f, -0.874586652f, 0.487550160f, + -0.873094978f, 0.490226483f, -0.871595087f, 0.492898192f, -0.870086991f, + 0.495565262f, -0.868570706f, 0.498227667f, -0.867046246f, 0.500885383f, + -0.865513624f, 0.503538384f, -0.863972856f, 0.506186645f, -0.862423956f, + 0.508830143f, -0.860866939f, 0.511468850f, -0.859301818f, 0.514102744f, + -0.857728610f, 0.516731799f, -0.856147328f, 0.519355990f, -0.854557988f, + 0.521975293f, -0.852960605f, 0.524589683f, -0.851355193f, 0.527199135f, + -0.849741768f, 0.529803625f, -0.848120345f, 0.532403128f, -0.846490939f, + 0.534997620f, -0.844853565f, 0.537587076f, -0.843208240f, 0.540171473f, + -0.841554977f, 0.542750785f, -0.839893794f, 0.545324988f, -0.838224706f, + 0.547894059f, -0.836547727f, 0.550457973f, -0.834862875f, 0.553016706f, + -0.833170165f, 0.555570233f, -0.831469612f, 0.558118531f, -0.829761234f, + 0.560661576f, -0.828045045f, 0.563199344f, -0.826321063f, 0.565731811f, + -0.824589303f, 0.568258953f, -0.822849781f, 0.570780746f, -0.821102515f, + 0.573297167f, -0.819347520f, 0.575808191f, -0.817584813f, 0.578313796f, + -0.815814411f, 0.580813958f, -0.814036330f, 0.583308653f, -0.812250587f, + 0.585797857f, -0.810457198f, 0.588281548f, -0.808656182f, 0.590759702f, + -0.806847554f, 0.593232295f, -0.805031331f, 0.595699304f, -0.803207531f, + 0.598160707f, -0.801376172f, 0.600616479f, -0.799537269f, 0.603066599f, + -0.797690841f, 0.605511041f, -0.795836905f, 0.607949785f, -0.793975478f, + 0.610382806f, -0.792106577f, 0.612810082f, -0.790230221f, 0.615231591f, + -0.788346428f, 0.617647308f, -0.786455214f, 0.620057212f, -0.784556597f, + 0.622461279f, -0.782650596f, 0.624859488f, -0.780737229f, 0.627251815f, + -0.778816512f, 0.629638239f, -0.776888466f, 0.632018736f, -0.774953107f, + 0.634393284f, -0.773010453f, 0.636761861f, -0.771060524f, 0.639124445f, + -0.769103338f, 0.641481013f, -0.767138912f, 0.643831543f, -0.765167266f, + 0.646176013f, -0.763188417f, 0.648514401f, -0.761202385f, 0.650846685f, + -0.759209189f, 0.653172843f, -0.757208847f, 0.655492853f, -0.755201377f, + 0.657806693f, -0.753186799f, 0.660114342f, -0.751165132f, 0.662415778f, + -0.749136395f, 0.664710978f, -0.747100606f, 0.666999922f, -0.745057785f, + 0.669282588f, -0.743007952f, 0.671558955f, -0.740951125f, 0.673829000f, + -0.738887324f, 0.676092704f, -0.736816569f, 0.678350043f, -0.734738878f, + 0.680600998f, -0.732654272f, 0.682845546f, -0.730562769f, 0.685083668f, + -0.728464390f, 0.687315341f, -0.726359155f, 0.689540545f, -0.724247083f, + 0.691759258f, -0.722128194f, 0.693971461f, -0.720002508f, 0.696177131f, + -0.717870045f, 0.698376249f, -0.715730825f, 0.700568794f, -0.713584869f, + 0.702754744f, -0.711432196f, 0.704934080f, -0.709272826f, 0.707106781f, + -0.707106781f, 0.709272826f, -0.704934080f, 0.711432196f, -0.702754744f, + 0.713584869f, -0.700568794f, 0.715730825f, -0.698376249f, 0.717870045f, + -0.696177131f, 0.720002508f, -0.693971461f, 0.722128194f, -0.691759258f, + 0.724247083f, -0.689540545f, 0.726359155f, -0.687315341f, 0.728464390f, + -0.685083668f, 0.730562769f, -0.682845546f, 0.732654272f, -0.680600998f, + 0.734738878f, -0.678350043f, 0.736816569f, -0.676092704f, 0.738887324f, + -0.673829000f, 0.740951125f, -0.671558955f, 0.743007952f, -0.669282588f, + 0.745057785f, -0.666999922f, 0.747100606f, -0.664710978f, 0.749136395f, + -0.662415778f, 0.751165132f, -0.660114342f, 0.753186799f, -0.657806693f, + 0.755201377f, -0.655492853f, 0.757208847f, -0.653172843f, 0.759209189f, + -0.650846685f, 0.761202385f, -0.648514401f, 0.763188417f, -0.646176013f, + 0.765167266f, -0.643831543f, 0.767138912f, -0.641481013f, 0.769103338f, + -0.639124445f, 0.771060524f, -0.636761861f, 0.773010453f, -0.634393284f, + 0.774953107f, -0.632018736f, 0.776888466f, -0.629638239f, 0.778816512f, + -0.627251815f, 0.780737229f, -0.624859488f, 0.782650596f, -0.622461279f, + 0.784556597f, -0.620057212f, 0.786455214f, -0.617647308f, 0.788346428f, + -0.615231591f, 0.790230221f, -0.612810082f, 0.792106577f, -0.610382806f, + 0.793975478f, -0.607949785f, 0.795836905f, -0.605511041f, 0.797690841f, + -0.603066599f, 0.799537269f, -0.600616479f, 0.801376172f, -0.598160707f, + 0.803207531f, -0.595699304f, 0.805031331f, -0.593232295f, 0.806847554f, + -0.590759702f, 0.808656182f, -0.588281548f, 0.810457198f, -0.585797857f, + 0.812250587f, -0.583308653f, 0.814036330f, -0.580813958f, 0.815814411f, + -0.578313796f, 0.817584813f, -0.575808191f, 0.819347520f, -0.573297167f, + 0.821102515f, -0.570780746f, 0.822849781f, -0.568258953f, 0.824589303f, + -0.565731811f, 0.826321063f, -0.563199344f, 0.828045045f, -0.560661576f, + 0.829761234f, -0.558118531f, 0.831469612f, -0.555570233f, 0.833170165f, + -0.553016706f, 0.834862875f, -0.550457973f, 0.836547727f, -0.547894059f, + 0.838224706f, -0.545324988f, 0.839893794f, -0.542750785f, 0.841554977f, + -0.540171473f, 0.843208240f, -0.537587076f, 0.844853565f, -0.534997620f, + 0.846490939f, -0.532403128f, 0.848120345f, -0.529803625f, 0.849741768f, + -0.527199135f, 0.851355193f, -0.524589683f, 0.852960605f, -0.521975293f, + 0.854557988f, -0.519355990f, 0.856147328f, -0.516731799f, 0.857728610f, + -0.514102744f, 0.859301818f, -0.511468850f, 0.860866939f, -0.508830143f, + 0.862423956f, -0.506186645f, 0.863972856f, -0.503538384f, 0.865513624f, + -0.500885383f, 0.867046246f, -0.498227667f, 0.868570706f, -0.495565262f, + 0.870086991f, -0.492898192f, 0.871595087f, -0.490226483f, 0.873094978f, + -0.487550160f, 0.874586652f, -0.484869248f, 0.876070094f, -0.482183772f, + 0.877545290f, -0.479493758f, 0.879012226f, -0.476799230f, 0.880470889f, + -0.474100215f, 0.881921264f, -0.471396737f, 0.883363339f, -0.468688822f, + 0.884797098f, -0.465976496f, 0.886222530f, -0.463259784f, 0.887639620f, + -0.460538711f, 0.889048356f, -0.457813304f, 0.890448723f, -0.455083587f, + 0.891840709f, -0.452349587f, 0.893224301f, -0.449611330f, 0.894599486f, + -0.446868840f, 0.895966250f, -0.444122145f, 0.897324581f, -0.441371269f, + 0.898674466f, -0.438616239f, 0.900015892f, -0.435857080f, 0.901348847f, + -0.433093819f, 0.902673318f, -0.430326481f, 0.903989293f, -0.427555093f, + 0.905296759f, -0.424779681f, 0.906595705f, -0.422000271f, 0.907886116f, + -0.419216888f, 0.909167983f, -0.416429560f, 0.910441292f, -0.413638312f, + 0.911706032f, -0.410843171f, 0.912962190f, -0.408044163f, 0.914209756f, + -0.405241314f, 0.915448716f, -0.402434651f, 0.916679060f, -0.399624200f, + 0.917900776f, -0.396809987f, 0.919113852f, -0.393992040f, 0.920318277f, + -0.391170384f, 0.921514039f, -0.388345047f, 0.922701128f, -0.385516054f, + 0.923879533f, -0.382683432f, 0.925049241f, -0.379847209f, 0.926210242f, + -0.377007410f, 0.927362526f, -0.374164063f, 0.928506080f, -0.371317194f, + 0.929640896f, -0.368466830f, 0.930766961f, -0.365612998f, 0.931884266f, + -0.362755724f, 0.932992799f, -0.359895037f, 0.934092550f, -0.357030961f, + 0.935183510f, -0.354163525f, 0.936265667f, -0.351292756f, 0.937339012f, + -0.348418680f, 0.938403534f, -0.345541325f, 0.939459224f, -0.342660717f, + 0.940506071f, -0.339776884f, 0.941544065f, -0.336889853f, 0.942573198f, + -0.333999651f, 0.943593458f, -0.331106306f, 0.944604837f, -0.328209844f, + 0.945607325f, -0.325310292f, 0.946600913f, -0.322407679f, 0.947585591f, + -0.319502031f, 0.948561350f, -0.316593376f, 0.949528181f, -0.313681740f, + 0.950486074f, -0.310767153f, 0.951435021f, -0.307849640f, 0.952375013f, + -0.304929230f, 0.953306040f, -0.302005949f, 0.954228095f, -0.299079826f, + 0.955141168f, -0.296150888f, 0.956045251f, -0.293219163f, 0.956940336f, + -0.290284677f, 0.957826413f, -0.287347460f, 0.958703475f, -0.284407537f, + 0.959571513f, -0.281464938f, 0.960430519f, -0.278519689f, 0.961280486f, + -0.275571819f, 0.962121404f, -0.272621355f, 0.962953267f, -0.269668326f, + 0.963776066f, -0.266712757f, 0.964589793f, -0.263754679f, 0.965394442f, + -0.260794118f, 0.966190003f, -0.257831102f, 0.966976471f, -0.254865660f, + 0.967753837f, -0.251897818f, 0.968522094f, -0.248927606f, 0.969281235f, + -0.245955050f, 0.970031253f, -0.242980180f, 0.970772141f, -0.240003022f, + 0.971503891f, -0.237023606f, 0.972226497f, -0.234041959f, 0.972939952f, + -0.231058108f, 0.973644250f, -0.228072083f, 0.974339383f, -0.225083911f, + 0.975025345f, -0.222093621f, 0.975702130f, -0.219101240f, 0.976369731f, + -0.216106797f, 0.977028143f, -0.213110320f, 0.977677358f, -0.210111837f, + 0.978317371f, -0.207111376f, 0.978948175f, -0.204108966f, 0.979569766f, + -0.201104635f, 0.980182136f, -0.198098411f, 0.980785280f, -0.195090322f, + 0.981379193f, -0.192080397f, 0.981963869f, -0.189068664f, 0.982539302f, + -0.186055152f, 0.983105487f, -0.183039888f, 0.983662419f, -0.180022901f, + 0.984210092f, -0.177004220f, 0.984748502f, -0.173983873f, 0.985277642f, + -0.170961889f, 0.985797509f, -0.167938295f, 0.986308097f, -0.164913120f, + 0.986809402f, -0.161886394f, 0.987301418f, -0.158858143f, 0.987784142f, + -0.155828398f, 0.988257568f, -0.152797185f, 0.988721692f, -0.149764535f, + 0.989176510f, -0.146730474f, 0.989622017f, -0.143695033f, 0.990058210f, + -0.140658239f, 0.990485084f, -0.137620122f, 0.990902635f, -0.134580709f, + 0.991310860f, -0.131540029f, 0.991709754f, -0.128498111f, 0.992099313f, + -0.125454983f, 0.992479535f, -0.122410675f, 0.992850414f, -0.119365215f, + 0.993211949f, -0.116318631f, 0.993564136f, -0.113270952f, 0.993906970f, + -0.110222207f, 0.994240449f, -0.107172425f, 0.994564571f, -0.104121634f, + 0.994879331f, -0.101069863f, 0.995184727f, -0.098017140f, 0.995480755f, + -0.094963495f, 0.995767414f, -0.091908956f, 0.996044701f, -0.088853553f, + 0.996312612f, -0.085797312f, 0.996571146f, -0.082740265f, 0.996820299f, + -0.079682438f, 0.997060070f, -0.076623861f, 0.997290457f, -0.073564564f, + 0.997511456f, -0.070504573f, 0.997723067f, -0.067443920f, 0.997925286f, + -0.064382631f, 0.998118113f, -0.061320736f, 0.998301545f, -0.058258265f, + 0.998475581f, -0.055195244f, 0.998640218f, -0.052131705f, 0.998795456f, + -0.049067674f, 0.998941293f, -0.046003182f, 0.999077728f, -0.042938257f, + 0.999204759f, -0.039872928f, 0.999322385f, -0.036807223f, 0.999430605f, + -0.033741172f, 0.999529418f, -0.030674803f, 0.999618822f, -0.027608146f, + 0.999698819f, -0.024541229f, 0.999769405f, -0.021474080f, 0.999830582f, + -0.018406730f, 0.999882347f, -0.015339206f, 0.999924702f, -0.012271538f, + 0.999957645f, -0.009203755f, 0.999981175f, -0.006135885f, 0.999995294f, + -0.003067957f}; /** @par @@ -4396,8 +1934,8 @@ const float32_t twiddleCoef_2048[4096] = { @par
for (i = 0; i< N/; i++)
   {
- 	twiddleCoef[2*i]   = cos(i * 2*PI/(float)N);
- 	twiddleCoef[2*i+1] = sin(i * 2*PI/(float)N);
+        twiddleCoef[2*i]   = cos(i * 2*PI/(float)N);
+        twiddleCoef[2*i+1] = sin(i * 2*PI/(float)N);
   } 
@par where N = 4096, PI = 3.14159265358979 @@ -4405,4109 +1943,1650 @@ const float32_t twiddleCoef_2048[4096] = { Cos and Sin values are in interleaved fashion */ const float32_t twiddleCoef_4096[8192] = { - 1.000000000f, 0.000000000f, - 0.999998823f, 0.001533980f, - 0.999995294f, 0.003067957f, - 0.999989411f, 0.004601926f, - 0.999981175f, 0.006135885f, - 0.999970586f, 0.007669829f, - 0.999957645f, 0.009203755f, - 0.999942350f, 0.010737659f, - 0.999924702f, 0.012271538f, - 0.999904701f, 0.013805389f, - 0.999882347f, 0.015339206f, - 0.999857641f, 0.016872988f, - 0.999830582f, 0.018406730f, - 0.999801170f, 0.019940429f, - 0.999769405f, 0.021474080f, - 0.999735288f, 0.023007681f, - 0.999698819f, 0.024541229f, - 0.999659997f, 0.026074718f, - 0.999618822f, 0.027608146f, - 0.999575296f, 0.029141509f, - 0.999529418f, 0.030674803f, - 0.999481187f, 0.032208025f, - 0.999430605f, 0.033741172f, - 0.999377670f, 0.035274239f, - 0.999322385f, 0.036807223f, - 0.999264747f, 0.038340120f, - 0.999204759f, 0.039872928f, - 0.999142419f, 0.041405641f, - 0.999077728f, 0.042938257f, - 0.999010686f, 0.044470772f, - 0.998941293f, 0.046003182f, - 0.998869550f, 0.047535484f, - 0.998795456f, 0.049067674f, - 0.998719012f, 0.050599749f, - 0.998640218f, 0.052131705f, - 0.998559074f, 0.053663538f, - 0.998475581f, 0.055195244f, - 0.998389737f, 0.056726821f, - 0.998301545f, 0.058258265f, - 0.998211003f, 0.059789571f, - 0.998118113f, 0.061320736f, - 0.998022874f, 0.062851758f, - 0.997925286f, 0.064382631f, - 0.997825350f, 0.065913353f, - 0.997723067f, 0.067443920f, - 0.997618435f, 0.068974328f, - 0.997511456f, 0.070504573f, - 0.997402130f, 0.072034653f, - 0.997290457f, 0.073564564f, - 0.997176437f, 0.075094301f, - 0.997060070f, 0.076623861f, - 0.996941358f, 0.078153242f, - 0.996820299f, 0.079682438f, - 0.996696895f, 0.081211447f, - 0.996571146f, 0.082740265f, - 0.996443051f, 0.084268888f, - 0.996312612f, 0.085797312f, - 0.996179829f, 0.087325535f, - 0.996044701f, 0.088853553f, - 0.995907229f, 0.090381361f, - 0.995767414f, 0.091908956f, - 0.995625256f, 0.093436336f, - 0.995480755f, 0.094963495f, - 0.995333912f, 0.096490431f, - 0.995184727f, 0.098017140f, - 0.995033199f, 0.099543619f, - 0.994879331f, 0.101069863f, - 0.994723121f, 0.102595869f, - 0.994564571f, 0.104121634f, - 0.994403680f, 0.105647154f, - 0.994240449f, 0.107172425f, - 0.994074879f, 0.108697444f, - 0.993906970f, 0.110222207f, - 0.993736722f, 0.111746711f, - 0.993564136f, 0.113270952f, - 0.993389211f, 0.114794927f, - 0.993211949f, 0.116318631f, - 0.993032350f, 0.117842062f, - 0.992850414f, 0.119365215f, - 0.992666142f, 0.120888087f, - 0.992479535f, 0.122410675f, - 0.992290591f, 0.123932975f, - 0.992099313f, 0.125454983f, - 0.991905700f, 0.126976696f, - 0.991709754f, 0.128498111f, - 0.991511473f, 0.130019223f, - 0.991310860f, 0.131540029f, - 0.991107914f, 0.133060525f, - 0.990902635f, 0.134580709f, - 0.990695025f, 0.136100575f, - 0.990485084f, 0.137620122f, - 0.990272812f, 0.139139344f, - 0.990058210f, 0.140658239f, - 0.989841278f, 0.142176804f, - 0.989622017f, 0.143695033f, - 0.989400428f, 0.145212925f, - 0.989176510f, 0.146730474f, - 0.988950265f, 0.148247679f, - 0.988721692f, 0.149764535f, - 0.988490793f, 0.151281038f, - 0.988257568f, 0.152797185f, - 0.988022017f, 0.154312973f, - 0.987784142f, 0.155828398f, - 0.987543942f, 0.157343456f, - 0.987301418f, 0.158858143f, - 0.987056571f, 0.160372457f, - 0.986809402f, 0.161886394f, - 0.986559910f, 0.163399949f, - 0.986308097f, 0.164913120f, - 0.986053963f, 0.166425904f, - 0.985797509f, 0.167938295f, - 0.985538735f, 0.169450291f, - 0.985277642f, 0.170961889f, - 0.985014231f, 0.172473084f, - 0.984748502f, 0.173983873f, - 0.984480455f, 0.175494253f, - 0.984210092f, 0.177004220f, - 0.983937413f, 0.178513771f, - 0.983662419f, 0.180022901f, - 0.983385110f, 0.181531608f, - 0.983105487f, 0.183039888f, - 0.982823551f, 0.184547737f, - 0.982539302f, 0.186055152f, - 0.982252741f, 0.187562129f, - 0.981963869f, 0.189068664f, - 0.981672686f, 0.190574755f, - 0.981379193f, 0.192080397f, - 0.981083391f, 0.193585587f, - 0.980785280f, 0.195090322f, - 0.980484862f, 0.196594598f, - 0.980182136f, 0.198098411f, - 0.979877104f, 0.199601758f, - 0.979569766f, 0.201104635f, - 0.979260123f, 0.202607039f, - 0.978948175f, 0.204108966f, - 0.978633924f, 0.205610413f, - 0.978317371f, 0.207111376f, - 0.977998515f, 0.208611852f, - 0.977677358f, 0.210111837f, - 0.977353900f, 0.211611327f, - 0.977028143f, 0.213110320f, - 0.976700086f, 0.214608811f, - 0.976369731f, 0.216106797f, - 0.976037079f, 0.217604275f, - 0.975702130f, 0.219101240f, - 0.975364885f, 0.220597690f, - 0.975025345f, 0.222093621f, - 0.974683511f, 0.223589029f, - 0.974339383f, 0.225083911f, - 0.973992962f, 0.226578264f, - 0.973644250f, 0.228072083f, - 0.973293246f, 0.229565366f, - 0.972939952f, 0.231058108f, - 0.972584369f, 0.232550307f, - 0.972226497f, 0.234041959f, - 0.971866337f, 0.235533059f, - 0.971503891f, 0.237023606f, - 0.971139158f, 0.238513595f, - 0.970772141f, 0.240003022f, - 0.970402839f, 0.241491885f, - 0.970031253f, 0.242980180f, - 0.969657385f, 0.244467903f, - 0.969281235f, 0.245955050f, - 0.968902805f, 0.247441619f, - 0.968522094f, 0.248927606f, - 0.968139105f, 0.250413007f, - 0.967753837f, 0.251897818f, - 0.967366292f, 0.253382037f, - 0.966976471f, 0.254865660f, - 0.966584374f, 0.256348682f, - 0.966190003f, 0.257831102f, - 0.965793359f, 0.259312915f, - 0.965394442f, 0.260794118f, - 0.964993253f, 0.262274707f, - 0.964589793f, 0.263754679f, - 0.964184064f, 0.265234030f, - 0.963776066f, 0.266712757f, - 0.963365800f, 0.268190857f, - 0.962953267f, 0.269668326f, - 0.962538468f, 0.271145160f, - 0.962121404f, 0.272621355f, - 0.961702077f, 0.274096910f, - 0.961280486f, 0.275571819f, - 0.960856633f, 0.277046080f, - 0.960430519f, 0.278519689f, - 0.960002146f, 0.279992643f, - 0.959571513f, 0.281464938f, - 0.959138622f, 0.282936570f, - 0.958703475f, 0.284407537f, - 0.958266071f, 0.285877835f, - 0.957826413f, 0.287347460f, - 0.957384501f, 0.288816408f, - 0.956940336f, 0.290284677f, - 0.956493919f, 0.291752263f, - 0.956045251f, 0.293219163f, - 0.955594334f, 0.294685372f, - 0.955141168f, 0.296150888f, - 0.954685755f, 0.297615707f, - 0.954228095f, 0.299079826f, - 0.953768190f, 0.300543241f, - 0.953306040f, 0.302005949f, - 0.952841648f, 0.303467947f, - 0.952375013f, 0.304929230f, - 0.951906137f, 0.306389795f, - 0.951435021f, 0.307849640f, - 0.950961666f, 0.309308760f, - 0.950486074f, 0.310767153f, - 0.950008245f, 0.312224814f, - 0.949528181f, 0.313681740f, - 0.949045882f, 0.315137929f, - 0.948561350f, 0.316593376f, - 0.948074586f, 0.318048077f, - 0.947585591f, 0.319502031f, - 0.947094366f, 0.320955232f, - 0.946600913f, 0.322407679f, - 0.946105232f, 0.323859367f, - 0.945607325f, 0.325310292f, - 0.945107193f, 0.326760452f, - 0.944604837f, 0.328209844f, - 0.944100258f, 0.329658463f, - 0.943593458f, 0.331106306f, - 0.943084437f, 0.332553370f, - 0.942573198f, 0.333999651f, - 0.942059740f, 0.335445147f, - 0.941544065f, 0.336889853f, - 0.941026175f, 0.338333767f, - 0.940506071f, 0.339776884f, - 0.939983753f, 0.341219202f, - 0.939459224f, 0.342660717f, - 0.938932484f, 0.344101426f, - 0.938403534f, 0.345541325f, - 0.937872376f, 0.346980411f, - 0.937339012f, 0.348418680f, - 0.936803442f, 0.349856130f, - 0.936265667f, 0.351292756f, - 0.935725689f, 0.352728556f, - 0.935183510f, 0.354163525f, - 0.934639130f, 0.355597662f, - 0.934092550f, 0.357030961f, - 0.933543773f, 0.358463421f, - 0.932992799f, 0.359895037f, - 0.932439629f, 0.361325806f, - 0.931884266f, 0.362755724f, - 0.931326709f, 0.364184790f, - 0.930766961f, 0.365612998f, - 0.930205023f, 0.367040346f, - 0.929640896f, 0.368466830f, - 0.929074581f, 0.369892447f, - 0.928506080f, 0.371317194f, - 0.927935395f, 0.372741067f, - 0.927362526f, 0.374164063f, - 0.926787474f, 0.375586178f, - 0.926210242f, 0.377007410f, - 0.925630831f, 0.378427755f, - 0.925049241f, 0.379847209f, - 0.924465474f, 0.381265769f, - 0.923879533f, 0.382683432f, - 0.923291417f, 0.384100195f, - 0.922701128f, 0.385516054f, - 0.922108669f, 0.386931006f, - 0.921514039f, 0.388345047f, - 0.920917242f, 0.389758174f, - 0.920318277f, 0.391170384f, - 0.919717146f, 0.392581674f, - 0.919113852f, 0.393992040f, - 0.918508394f, 0.395401479f, - 0.917900776f, 0.396809987f, - 0.917290997f, 0.398217562f, - 0.916679060f, 0.399624200f, - 0.916064966f, 0.401029897f, - 0.915448716f, 0.402434651f, - 0.914830312f, 0.403838458f, - 0.914209756f, 0.405241314f, - 0.913587048f, 0.406643217f, - 0.912962190f, 0.408044163f, - 0.912335185f, 0.409444149f, - 0.911706032f, 0.410843171f, - 0.911074734f, 0.412241227f, - 0.910441292f, 0.413638312f, - 0.909805708f, 0.415034424f, - 0.909167983f, 0.416429560f, - 0.908528119f, 0.417823716f, - 0.907886116f, 0.419216888f, - 0.907241978f, 0.420609074f, - 0.906595705f, 0.422000271f, - 0.905947298f, 0.423390474f, - 0.905296759f, 0.424779681f, - 0.904644091f, 0.426167889f, - 0.903989293f, 0.427555093f, - 0.903332368f, 0.428941292f, - 0.902673318f, 0.430326481f, - 0.902012144f, 0.431710658f, - 0.901348847f, 0.433093819f, - 0.900683429f, 0.434475961f, - 0.900015892f, 0.435857080f, - 0.899346237f, 0.437237174f, - 0.898674466f, 0.438616239f, - 0.898000580f, 0.439994271f, - 0.897324581f, 0.441371269f, - 0.896646470f, 0.442747228f, - 0.895966250f, 0.444122145f, - 0.895283921f, 0.445496017f, - 0.894599486f, 0.446868840f, - 0.893912945f, 0.448240612f, - 0.893224301f, 0.449611330f, - 0.892533555f, 0.450980989f, - 0.891840709f, 0.452349587f, - 0.891145765f, 0.453717121f, - 0.890448723f, 0.455083587f, - 0.889749586f, 0.456448982f, - 0.889048356f, 0.457813304f, - 0.888345033f, 0.459176548f, - 0.887639620f, 0.460538711f, - 0.886932119f, 0.461899791f, - 0.886222530f, 0.463259784f, - 0.885510856f, 0.464618686f, - 0.884797098f, 0.465976496f, - 0.884081259f, 0.467333209f, - 0.883363339f, 0.468688822f, - 0.882643340f, 0.470043332f, - 0.881921264f, 0.471396737f, - 0.881197113f, 0.472749032f, - 0.880470889f, 0.474100215f, - 0.879742593f, 0.475450282f, - 0.879012226f, 0.476799230f, - 0.878279792f, 0.478147056f, - 0.877545290f, 0.479493758f, - 0.876808724f, 0.480839331f, - 0.876070094f, 0.482183772f, - 0.875329403f, 0.483527079f, - 0.874586652f, 0.484869248f, - 0.873841843f, 0.486210276f, - 0.873094978f, 0.487550160f, - 0.872346059f, 0.488888897f, - 0.871595087f, 0.490226483f, - 0.870842063f, 0.491562916f, - 0.870086991f, 0.492898192f, - 0.869329871f, 0.494232309f, - 0.868570706f, 0.495565262f, - 0.867809497f, 0.496897049f, - 0.867046246f, 0.498227667f, - 0.866280954f, 0.499557113f, - 0.865513624f, 0.500885383f, - 0.864744258f, 0.502212474f, - 0.863972856f, 0.503538384f, - 0.863199422f, 0.504863109f, - 0.862423956f, 0.506186645f, - 0.861646461f, 0.507508991f, - 0.860866939f, 0.508830143f, - 0.860085390f, 0.510150097f, - 0.859301818f, 0.511468850f, - 0.858516224f, 0.512786401f, - 0.857728610f, 0.514102744f, - 0.856938977f, 0.515417878f, - 0.856147328f, 0.516731799f, - 0.855353665f, 0.518044504f, - 0.854557988f, 0.519355990f, - 0.853760301f, 0.520666254f, - 0.852960605f, 0.521975293f, - 0.852158902f, 0.523283103f, - 0.851355193f, 0.524589683f, - 0.850549481f, 0.525895027f, - 0.849741768f, 0.527199135f, - 0.848932055f, 0.528502002f, - 0.848120345f, 0.529803625f, - 0.847306639f, 0.531104001f, - 0.846490939f, 0.532403128f, - 0.845673247f, 0.533701002f, - 0.844853565f, 0.534997620f, - 0.844031895f, 0.536292979f, - 0.843208240f, 0.537587076f, - 0.842382600f, 0.538879909f, - 0.841554977f, 0.540171473f, - 0.840725375f, 0.541461766f, - 0.839893794f, 0.542750785f, - 0.839060237f, 0.544038527f, - 0.838224706f, 0.545324988f, - 0.837387202f, 0.546610167f, - 0.836547727f, 0.547894059f, - 0.835706284f, 0.549176662f, - 0.834862875f, 0.550457973f, - 0.834017501f, 0.551737988f, - 0.833170165f, 0.553016706f, - 0.832320868f, 0.554294121f, - 0.831469612f, 0.555570233f, - 0.830616400f, 0.556845037f, - 0.829761234f, 0.558118531f, - 0.828904115f, 0.559390712f, - 0.828045045f, 0.560661576f, - 0.827184027f, 0.561931121f, - 0.826321063f, 0.563199344f, - 0.825456154f, 0.564466242f, - 0.824589303f, 0.565731811f, - 0.823720511f, 0.566996049f, - 0.822849781f, 0.568258953f, - 0.821977115f, 0.569520519f, - 0.821102515f, 0.570780746f, - 0.820225983f, 0.572039629f, - 0.819347520f, 0.573297167f, - 0.818467130f, 0.574553355f, - 0.817584813f, 0.575808191f, - 0.816700573f, 0.577061673f, - 0.815814411f, 0.578313796f, - 0.814926329f, 0.579564559f, - 0.814036330f, 0.580813958f, - 0.813144415f, 0.582061990f, - 0.812250587f, 0.583308653f, - 0.811354847f, 0.584553943f, - 0.810457198f, 0.585797857f, - 0.809557642f, 0.587040394f, - 0.808656182f, 0.588281548f, - 0.807752818f, 0.589521319f, - 0.806847554f, 0.590759702f, - 0.805940391f, 0.591996695f, - 0.805031331f, 0.593232295f, - 0.804120377f, 0.594466499f, - 0.803207531f, 0.595699304f, - 0.802292796f, 0.596930708f, - 0.801376172f, 0.598160707f, - 0.800457662f, 0.599389298f, - 0.799537269f, 0.600616479f, - 0.798614995f, 0.601842247f, - 0.797690841f, 0.603066599f, - 0.796764810f, 0.604289531f, - 0.795836905f, 0.605511041f, - 0.794907126f, 0.606731127f, - 0.793975478f, 0.607949785f, - 0.793041960f, 0.609167012f, - 0.792106577f, 0.610382806f, - 0.791169330f, 0.611597164f, - 0.790230221f, 0.612810082f, - 0.789289253f, 0.614021559f, - 0.788346428f, 0.615231591f, - 0.787401747f, 0.616440175f, - 0.786455214f, 0.617647308f, - 0.785506830f, 0.618852988f, - 0.784556597f, 0.620057212f, - 0.783604519f, 0.621259977f, - 0.782650596f, 0.622461279f, - 0.781694832f, 0.623661118f, - 0.780737229f, 0.624859488f, - 0.779777788f, 0.626056388f, - 0.778816512f, 0.627251815f, - 0.777853404f, 0.628445767f, - 0.776888466f, 0.629638239f, - 0.775921699f, 0.630829230f, - 0.774953107f, 0.632018736f, - 0.773982691f, 0.633206755f, - 0.773010453f, 0.634393284f, - 0.772036397f, 0.635578320f, - 0.771060524f, 0.636761861f, - 0.770082837f, 0.637943904f, - 0.769103338f, 0.639124445f, - 0.768122029f, 0.640303482f, - 0.767138912f, 0.641481013f, - 0.766153990f, 0.642657034f, - 0.765167266f, 0.643831543f, - 0.764178741f, 0.645004537f, - 0.763188417f, 0.646176013f, - 0.762196298f, 0.647345969f, - 0.761202385f, 0.648514401f, - 0.760206682f, 0.649681307f, - 0.759209189f, 0.650846685f, - 0.758209910f, 0.652010531f, - 0.757208847f, 0.653172843f, - 0.756206001f, 0.654333618f, - 0.755201377f, 0.655492853f, - 0.754194975f, 0.656650546f, - 0.753186799f, 0.657806693f, - 0.752176850f, 0.658961293f, - 0.751165132f, 0.660114342f, - 0.750151646f, 0.661265838f, - 0.749136395f, 0.662415778f, - 0.748119380f, 0.663564159f, - 0.747100606f, 0.664710978f, - 0.746080074f, 0.665856234f, - 0.745057785f, 0.666999922f, - 0.744033744f, 0.668142041f, - 0.743007952f, 0.669282588f, - 0.741980412f, 0.670421560f, - 0.740951125f, 0.671558955f, - 0.739920095f, 0.672694769f, - 0.738887324f, 0.673829000f, - 0.737852815f, 0.674961646f, - 0.736816569f, 0.676092704f, - 0.735778589f, 0.677222170f, - 0.734738878f, 0.678350043f, - 0.733697438f, 0.679476320f, - 0.732654272f, 0.680600998f, - 0.731609381f, 0.681724074f, - 0.730562769f, 0.682845546f, - 0.729514438f, 0.683965412f, - 0.728464390f, 0.685083668f, - 0.727412629f, 0.686200312f, - 0.726359155f, 0.687315341f, - 0.725303972f, 0.688428753f, - 0.724247083f, 0.689540545f, - 0.723188489f, 0.690650714f, - 0.722128194f, 0.691759258f, - 0.721066199f, 0.692866175f, - 0.720002508f, 0.693971461f, - 0.718937122f, 0.695075114f, - 0.717870045f, 0.696177131f, - 0.716801279f, 0.697277511f, - 0.715730825f, 0.698376249f, - 0.714658688f, 0.699473345f, - 0.713584869f, 0.700568794f, - 0.712509371f, 0.701662595f, - 0.711432196f, 0.702754744f, - 0.710353347f, 0.703845241f, - 0.709272826f, 0.704934080f, - 0.708190637f, 0.706021261f, - 0.707106781f, 0.707106781f, - 0.706021261f, 0.708190637f, - 0.704934080f, 0.709272826f, - 0.703845241f, 0.710353347f, - 0.702754744f, 0.711432196f, - 0.701662595f, 0.712509371f, - 0.700568794f, 0.713584869f, - 0.699473345f, 0.714658688f, - 0.698376249f, 0.715730825f, - 0.697277511f, 0.716801279f, - 0.696177131f, 0.717870045f, - 0.695075114f, 0.718937122f, - 0.693971461f, 0.720002508f, - 0.692866175f, 0.721066199f, - 0.691759258f, 0.722128194f, - 0.690650714f, 0.723188489f, - 0.689540545f, 0.724247083f, - 0.688428753f, 0.725303972f, - 0.687315341f, 0.726359155f, - 0.686200312f, 0.727412629f, - 0.685083668f, 0.728464390f, - 0.683965412f, 0.729514438f, - 0.682845546f, 0.730562769f, - 0.681724074f, 0.731609381f, - 0.680600998f, 0.732654272f, - 0.679476320f, 0.733697438f, - 0.678350043f, 0.734738878f, - 0.677222170f, 0.735778589f, - 0.676092704f, 0.736816569f, - 0.674961646f, 0.737852815f, - 0.673829000f, 0.738887324f, - 0.672694769f, 0.739920095f, - 0.671558955f, 0.740951125f, - 0.670421560f, 0.741980412f, - 0.669282588f, 0.743007952f, - 0.668142041f, 0.744033744f, - 0.666999922f, 0.745057785f, - 0.665856234f, 0.746080074f, - 0.664710978f, 0.747100606f, - 0.663564159f, 0.748119380f, - 0.662415778f, 0.749136395f, - 0.661265838f, 0.750151646f, - 0.660114342f, 0.751165132f, - 0.658961293f, 0.752176850f, - 0.657806693f, 0.753186799f, - 0.656650546f, 0.754194975f, - 0.655492853f, 0.755201377f, - 0.654333618f, 0.756206001f, - 0.653172843f, 0.757208847f, - 0.652010531f, 0.758209910f, - 0.650846685f, 0.759209189f, - 0.649681307f, 0.760206682f, - 0.648514401f, 0.761202385f, - 0.647345969f, 0.762196298f, - 0.646176013f, 0.763188417f, - 0.645004537f, 0.764178741f, - 0.643831543f, 0.765167266f, - 0.642657034f, 0.766153990f, - 0.641481013f, 0.767138912f, - 0.640303482f, 0.768122029f, - 0.639124445f, 0.769103338f, - 0.637943904f, 0.770082837f, - 0.636761861f, 0.771060524f, - 0.635578320f, 0.772036397f, - 0.634393284f, 0.773010453f, - 0.633206755f, 0.773982691f, - 0.632018736f, 0.774953107f, - 0.630829230f, 0.775921699f, - 0.629638239f, 0.776888466f, - 0.628445767f, 0.777853404f, - 0.627251815f, 0.778816512f, - 0.626056388f, 0.779777788f, - 0.624859488f, 0.780737229f, - 0.623661118f, 0.781694832f, - 0.622461279f, 0.782650596f, - 0.621259977f, 0.783604519f, - 0.620057212f, 0.784556597f, - 0.618852988f, 0.785506830f, - 0.617647308f, 0.786455214f, - 0.616440175f, 0.787401747f, - 0.615231591f, 0.788346428f, - 0.614021559f, 0.789289253f, - 0.612810082f, 0.790230221f, - 0.611597164f, 0.791169330f, - 0.610382806f, 0.792106577f, - 0.609167012f, 0.793041960f, - 0.607949785f, 0.793975478f, - 0.606731127f, 0.794907126f, - 0.605511041f, 0.795836905f, - 0.604289531f, 0.796764810f, - 0.603066599f, 0.797690841f, - 0.601842247f, 0.798614995f, - 0.600616479f, 0.799537269f, - 0.599389298f, 0.800457662f, - 0.598160707f, 0.801376172f, - 0.596930708f, 0.802292796f, - 0.595699304f, 0.803207531f, - 0.594466499f, 0.804120377f, - 0.593232295f, 0.805031331f, - 0.591996695f, 0.805940391f, - 0.590759702f, 0.806847554f, - 0.589521319f, 0.807752818f, - 0.588281548f, 0.808656182f, - 0.587040394f, 0.809557642f, - 0.585797857f, 0.810457198f, - 0.584553943f, 0.811354847f, - 0.583308653f, 0.812250587f, - 0.582061990f, 0.813144415f, - 0.580813958f, 0.814036330f, - 0.579564559f, 0.814926329f, - 0.578313796f, 0.815814411f, - 0.577061673f, 0.816700573f, - 0.575808191f, 0.817584813f, - 0.574553355f, 0.818467130f, - 0.573297167f, 0.819347520f, - 0.572039629f, 0.820225983f, - 0.570780746f, 0.821102515f, - 0.569520519f, 0.821977115f, - 0.568258953f, 0.822849781f, - 0.566996049f, 0.823720511f, - 0.565731811f, 0.824589303f, - 0.564466242f, 0.825456154f, - 0.563199344f, 0.826321063f, - 0.561931121f, 0.827184027f, - 0.560661576f, 0.828045045f, - 0.559390712f, 0.828904115f, - 0.558118531f, 0.829761234f, - 0.556845037f, 0.830616400f, - 0.555570233f, 0.831469612f, - 0.554294121f, 0.832320868f, - 0.553016706f, 0.833170165f, - 0.551737988f, 0.834017501f, - 0.550457973f, 0.834862875f, - 0.549176662f, 0.835706284f, - 0.547894059f, 0.836547727f, - 0.546610167f, 0.837387202f, - 0.545324988f, 0.838224706f, - 0.544038527f, 0.839060237f, - 0.542750785f, 0.839893794f, - 0.541461766f, 0.840725375f, - 0.540171473f, 0.841554977f, - 0.538879909f, 0.842382600f, - 0.537587076f, 0.843208240f, - 0.536292979f, 0.844031895f, - 0.534997620f, 0.844853565f, - 0.533701002f, 0.845673247f, - 0.532403128f, 0.846490939f, - 0.531104001f, 0.847306639f, - 0.529803625f, 0.848120345f, - 0.528502002f, 0.848932055f, - 0.527199135f, 0.849741768f, - 0.525895027f, 0.850549481f, - 0.524589683f, 0.851355193f, - 0.523283103f, 0.852158902f, - 0.521975293f, 0.852960605f, - 0.520666254f, 0.853760301f, - 0.519355990f, 0.854557988f, - 0.518044504f, 0.855353665f, - 0.516731799f, 0.856147328f, - 0.515417878f, 0.856938977f, - 0.514102744f, 0.857728610f, - 0.512786401f, 0.858516224f, - 0.511468850f, 0.859301818f, - 0.510150097f, 0.860085390f, - 0.508830143f, 0.860866939f, - 0.507508991f, 0.861646461f, - 0.506186645f, 0.862423956f, - 0.504863109f, 0.863199422f, - 0.503538384f, 0.863972856f, - 0.502212474f, 0.864744258f, - 0.500885383f, 0.865513624f, - 0.499557113f, 0.866280954f, - 0.498227667f, 0.867046246f, - 0.496897049f, 0.867809497f, - 0.495565262f, 0.868570706f, - 0.494232309f, 0.869329871f, - 0.492898192f, 0.870086991f, - 0.491562916f, 0.870842063f, - 0.490226483f, 0.871595087f, - 0.488888897f, 0.872346059f, - 0.487550160f, 0.873094978f, - 0.486210276f, 0.873841843f, - 0.484869248f, 0.874586652f, - 0.483527079f, 0.875329403f, - 0.482183772f, 0.876070094f, - 0.480839331f, 0.876808724f, - 0.479493758f, 0.877545290f, - 0.478147056f, 0.878279792f, - 0.476799230f, 0.879012226f, - 0.475450282f, 0.879742593f, - 0.474100215f, 0.880470889f, - 0.472749032f, 0.881197113f, - 0.471396737f, 0.881921264f, - 0.470043332f, 0.882643340f, - 0.468688822f, 0.883363339f, - 0.467333209f, 0.884081259f, - 0.465976496f, 0.884797098f, - 0.464618686f, 0.885510856f, - 0.463259784f, 0.886222530f, - 0.461899791f, 0.886932119f, - 0.460538711f, 0.887639620f, - 0.459176548f, 0.888345033f, - 0.457813304f, 0.889048356f, - 0.456448982f, 0.889749586f, - 0.455083587f, 0.890448723f, - 0.453717121f, 0.891145765f, - 0.452349587f, 0.891840709f, - 0.450980989f, 0.892533555f, - 0.449611330f, 0.893224301f, - 0.448240612f, 0.893912945f, - 0.446868840f, 0.894599486f, - 0.445496017f, 0.895283921f, - 0.444122145f, 0.895966250f, - 0.442747228f, 0.896646470f, - 0.441371269f, 0.897324581f, - 0.439994271f, 0.898000580f, - 0.438616239f, 0.898674466f, - 0.437237174f, 0.899346237f, - 0.435857080f, 0.900015892f, - 0.434475961f, 0.900683429f, - 0.433093819f, 0.901348847f, - 0.431710658f, 0.902012144f, - 0.430326481f, 0.902673318f, - 0.428941292f, 0.903332368f, - 0.427555093f, 0.903989293f, - 0.426167889f, 0.904644091f, - 0.424779681f, 0.905296759f, - 0.423390474f, 0.905947298f, - 0.422000271f, 0.906595705f, - 0.420609074f, 0.907241978f, - 0.419216888f, 0.907886116f, - 0.417823716f, 0.908528119f, - 0.416429560f, 0.909167983f, - 0.415034424f, 0.909805708f, - 0.413638312f, 0.910441292f, - 0.412241227f, 0.911074734f, - 0.410843171f, 0.911706032f, - 0.409444149f, 0.912335185f, - 0.408044163f, 0.912962190f, - 0.406643217f, 0.913587048f, - 0.405241314f, 0.914209756f, - 0.403838458f, 0.914830312f, - 0.402434651f, 0.915448716f, - 0.401029897f, 0.916064966f, - 0.399624200f, 0.916679060f, - 0.398217562f, 0.917290997f, - 0.396809987f, 0.917900776f, - 0.395401479f, 0.918508394f, - 0.393992040f, 0.919113852f, - 0.392581674f, 0.919717146f, - 0.391170384f, 0.920318277f, - 0.389758174f, 0.920917242f, - 0.388345047f, 0.921514039f, - 0.386931006f, 0.922108669f, - 0.385516054f, 0.922701128f, - 0.384100195f, 0.923291417f, - 0.382683432f, 0.923879533f, - 0.381265769f, 0.924465474f, - 0.379847209f, 0.925049241f, - 0.378427755f, 0.925630831f, - 0.377007410f, 0.926210242f, - 0.375586178f, 0.926787474f, - 0.374164063f, 0.927362526f, - 0.372741067f, 0.927935395f, - 0.371317194f, 0.928506080f, - 0.369892447f, 0.929074581f, - 0.368466830f, 0.929640896f, - 0.367040346f, 0.930205023f, - 0.365612998f, 0.930766961f, - 0.364184790f, 0.931326709f, - 0.362755724f, 0.931884266f, - 0.361325806f, 0.932439629f, - 0.359895037f, 0.932992799f, - 0.358463421f, 0.933543773f, - 0.357030961f, 0.934092550f, - 0.355597662f, 0.934639130f, - 0.354163525f, 0.935183510f, - 0.352728556f, 0.935725689f, - 0.351292756f, 0.936265667f, - 0.349856130f, 0.936803442f, - 0.348418680f, 0.937339012f, - 0.346980411f, 0.937872376f, - 0.345541325f, 0.938403534f, - 0.344101426f, 0.938932484f, - 0.342660717f, 0.939459224f, - 0.341219202f, 0.939983753f, - 0.339776884f, 0.940506071f, - 0.338333767f, 0.941026175f, - 0.336889853f, 0.941544065f, - 0.335445147f, 0.942059740f, - 0.333999651f, 0.942573198f, - 0.332553370f, 0.943084437f, - 0.331106306f, 0.943593458f, - 0.329658463f, 0.944100258f, - 0.328209844f, 0.944604837f, - 0.326760452f, 0.945107193f, - 0.325310292f, 0.945607325f, - 0.323859367f, 0.946105232f, - 0.322407679f, 0.946600913f, - 0.320955232f, 0.947094366f, - 0.319502031f, 0.947585591f, - 0.318048077f, 0.948074586f, - 0.316593376f, 0.948561350f, - 0.315137929f, 0.949045882f, - 0.313681740f, 0.949528181f, - 0.312224814f, 0.950008245f, - 0.310767153f, 0.950486074f, - 0.309308760f, 0.950961666f, - 0.307849640f, 0.951435021f, - 0.306389795f, 0.951906137f, - 0.304929230f, 0.952375013f, - 0.303467947f, 0.952841648f, - 0.302005949f, 0.953306040f, - 0.300543241f, 0.953768190f, - 0.299079826f, 0.954228095f, - 0.297615707f, 0.954685755f, - 0.296150888f, 0.955141168f, - 0.294685372f, 0.955594334f, - 0.293219163f, 0.956045251f, - 0.291752263f, 0.956493919f, - 0.290284677f, 0.956940336f, - 0.288816408f, 0.957384501f, - 0.287347460f, 0.957826413f, - 0.285877835f, 0.958266071f, - 0.284407537f, 0.958703475f, - 0.282936570f, 0.959138622f, - 0.281464938f, 0.959571513f, - 0.279992643f, 0.960002146f, - 0.278519689f, 0.960430519f, - 0.277046080f, 0.960856633f, - 0.275571819f, 0.961280486f, - 0.274096910f, 0.961702077f, - 0.272621355f, 0.962121404f, - 0.271145160f, 0.962538468f, - 0.269668326f, 0.962953267f, - 0.268190857f, 0.963365800f, - 0.266712757f, 0.963776066f, - 0.265234030f, 0.964184064f, - 0.263754679f, 0.964589793f, - 0.262274707f, 0.964993253f, - 0.260794118f, 0.965394442f, - 0.259312915f, 0.965793359f, - 0.257831102f, 0.966190003f, - 0.256348682f, 0.966584374f, - 0.254865660f, 0.966976471f, - 0.253382037f, 0.967366292f, - 0.251897818f, 0.967753837f, - 0.250413007f, 0.968139105f, - 0.248927606f, 0.968522094f, - 0.247441619f, 0.968902805f, - 0.245955050f, 0.969281235f, - 0.244467903f, 0.969657385f, - 0.242980180f, 0.970031253f, - 0.241491885f, 0.970402839f, - 0.240003022f, 0.970772141f, - 0.238513595f, 0.971139158f, - 0.237023606f, 0.971503891f, - 0.235533059f, 0.971866337f, - 0.234041959f, 0.972226497f, - 0.232550307f, 0.972584369f, - 0.231058108f, 0.972939952f, - 0.229565366f, 0.973293246f, - 0.228072083f, 0.973644250f, - 0.226578264f, 0.973992962f, - 0.225083911f, 0.974339383f, - 0.223589029f, 0.974683511f, - 0.222093621f, 0.975025345f, - 0.220597690f, 0.975364885f, - 0.219101240f, 0.975702130f, - 0.217604275f, 0.976037079f, - 0.216106797f, 0.976369731f, - 0.214608811f, 0.976700086f, - 0.213110320f, 0.977028143f, - 0.211611327f, 0.977353900f, - 0.210111837f, 0.977677358f, - 0.208611852f, 0.977998515f, - 0.207111376f, 0.978317371f, - 0.205610413f, 0.978633924f, - 0.204108966f, 0.978948175f, - 0.202607039f, 0.979260123f, - 0.201104635f, 0.979569766f, - 0.199601758f, 0.979877104f, - 0.198098411f, 0.980182136f, - 0.196594598f, 0.980484862f, - 0.195090322f, 0.980785280f, - 0.193585587f, 0.981083391f, - 0.192080397f, 0.981379193f, - 0.190574755f, 0.981672686f, - 0.189068664f, 0.981963869f, - 0.187562129f, 0.982252741f, - 0.186055152f, 0.982539302f, - 0.184547737f, 0.982823551f, - 0.183039888f, 0.983105487f, - 0.181531608f, 0.983385110f, - 0.180022901f, 0.983662419f, - 0.178513771f, 0.983937413f, - 0.177004220f, 0.984210092f, - 0.175494253f, 0.984480455f, - 0.173983873f, 0.984748502f, - 0.172473084f, 0.985014231f, - 0.170961889f, 0.985277642f, - 0.169450291f, 0.985538735f, - 0.167938295f, 0.985797509f, - 0.166425904f, 0.986053963f, - 0.164913120f, 0.986308097f, - 0.163399949f, 0.986559910f, - 0.161886394f, 0.986809402f, - 0.160372457f, 0.987056571f, - 0.158858143f, 0.987301418f, - 0.157343456f, 0.987543942f, - 0.155828398f, 0.987784142f, - 0.154312973f, 0.988022017f, - 0.152797185f, 0.988257568f, - 0.151281038f, 0.988490793f, - 0.149764535f, 0.988721692f, - 0.148247679f, 0.988950265f, - 0.146730474f, 0.989176510f, - 0.145212925f, 0.989400428f, - 0.143695033f, 0.989622017f, - 0.142176804f, 0.989841278f, - 0.140658239f, 0.990058210f, - 0.139139344f, 0.990272812f, - 0.137620122f, 0.990485084f, - 0.136100575f, 0.990695025f, - 0.134580709f, 0.990902635f, - 0.133060525f, 0.991107914f, - 0.131540029f, 0.991310860f, - 0.130019223f, 0.991511473f, - 0.128498111f, 0.991709754f, - 0.126976696f, 0.991905700f, - 0.125454983f, 0.992099313f, - 0.123932975f, 0.992290591f, - 0.122410675f, 0.992479535f, - 0.120888087f, 0.992666142f, - 0.119365215f, 0.992850414f, - 0.117842062f, 0.993032350f, - 0.116318631f, 0.993211949f, - 0.114794927f, 0.993389211f, - 0.113270952f, 0.993564136f, - 0.111746711f, 0.993736722f, - 0.110222207f, 0.993906970f, - 0.108697444f, 0.994074879f, - 0.107172425f, 0.994240449f, - 0.105647154f, 0.994403680f, - 0.104121634f, 0.994564571f, - 0.102595869f, 0.994723121f, - 0.101069863f, 0.994879331f, - 0.099543619f, 0.995033199f, - 0.098017140f, 0.995184727f, - 0.096490431f, 0.995333912f, - 0.094963495f, 0.995480755f, - 0.093436336f, 0.995625256f, - 0.091908956f, 0.995767414f, - 0.090381361f, 0.995907229f, - 0.088853553f, 0.996044701f, - 0.087325535f, 0.996179829f, - 0.085797312f, 0.996312612f, - 0.084268888f, 0.996443051f, - 0.082740265f, 0.996571146f, - 0.081211447f, 0.996696895f, - 0.079682438f, 0.996820299f, - 0.078153242f, 0.996941358f, - 0.076623861f, 0.997060070f, - 0.075094301f, 0.997176437f, - 0.073564564f, 0.997290457f, - 0.072034653f, 0.997402130f, - 0.070504573f, 0.997511456f, - 0.068974328f, 0.997618435f, - 0.067443920f, 0.997723067f, - 0.065913353f, 0.997825350f, - 0.064382631f, 0.997925286f, - 0.062851758f, 0.998022874f, - 0.061320736f, 0.998118113f, - 0.059789571f, 0.998211003f, - 0.058258265f, 0.998301545f, - 0.056726821f, 0.998389737f, - 0.055195244f, 0.998475581f, - 0.053663538f, 0.998559074f, - 0.052131705f, 0.998640218f, - 0.050599749f, 0.998719012f, - 0.049067674f, 0.998795456f, - 0.047535484f, 0.998869550f, - 0.046003182f, 0.998941293f, - 0.044470772f, 0.999010686f, - 0.042938257f, 0.999077728f, - 0.041405641f, 0.999142419f, - 0.039872928f, 0.999204759f, - 0.038340120f, 0.999264747f, - 0.036807223f, 0.999322385f, - 0.035274239f, 0.999377670f, - 0.033741172f, 0.999430605f, - 0.032208025f, 0.999481187f, - 0.030674803f, 0.999529418f, - 0.029141509f, 0.999575296f, - 0.027608146f, 0.999618822f, - 0.026074718f, 0.999659997f, - 0.024541229f, 0.999698819f, - 0.023007681f, 0.999735288f, - 0.021474080f, 0.999769405f, - 0.019940429f, 0.999801170f, - 0.018406730f, 0.999830582f, - 0.016872988f, 0.999857641f, - 0.015339206f, 0.999882347f, - 0.013805389f, 0.999904701f, - 0.012271538f, 0.999924702f, - 0.010737659f, 0.999942350f, - 0.009203755f, 0.999957645f, - 0.007669829f, 0.999970586f, - 0.006135885f, 0.999981175f, - 0.004601926f, 0.999989411f, - 0.003067957f, 0.999995294f, - 0.001533980f, 0.999998823f, - 0.000000000f, 1.000000000f, - -0.001533980f, 0.999998823f, - -0.003067957f, 0.999995294f, - -0.004601926f, 0.999989411f, - -0.006135885f, 0.999981175f, - -0.007669829f, 0.999970586f, - -0.009203755f, 0.999957645f, - -0.010737659f, 0.999942350f, - -0.012271538f, 0.999924702f, - -0.013805389f, 0.999904701f, - -0.015339206f, 0.999882347f, - -0.016872988f, 0.999857641f, - -0.018406730f, 0.999830582f, - -0.019940429f, 0.999801170f, - -0.021474080f, 0.999769405f, - -0.023007681f, 0.999735288f, - -0.024541229f, 0.999698819f, - -0.026074718f, 0.999659997f, - -0.027608146f, 0.999618822f, - -0.029141509f, 0.999575296f, - -0.030674803f, 0.999529418f, - -0.032208025f, 0.999481187f, - -0.033741172f, 0.999430605f, - -0.035274239f, 0.999377670f, - -0.036807223f, 0.999322385f, - -0.038340120f, 0.999264747f, - -0.039872928f, 0.999204759f, - -0.041405641f, 0.999142419f, - -0.042938257f, 0.999077728f, - -0.044470772f, 0.999010686f, - -0.046003182f, 0.998941293f, - -0.047535484f, 0.998869550f, - -0.049067674f, 0.998795456f, - -0.050599749f, 0.998719012f, - -0.052131705f, 0.998640218f, - -0.053663538f, 0.998559074f, - -0.055195244f, 0.998475581f, - -0.056726821f, 0.998389737f, - -0.058258265f, 0.998301545f, - -0.059789571f, 0.998211003f, - -0.061320736f, 0.998118113f, - -0.062851758f, 0.998022874f, - -0.064382631f, 0.997925286f, - -0.065913353f, 0.997825350f, - -0.067443920f, 0.997723067f, - -0.068974328f, 0.997618435f, - -0.070504573f, 0.997511456f, - -0.072034653f, 0.997402130f, - -0.073564564f, 0.997290457f, - -0.075094301f, 0.997176437f, - -0.076623861f, 0.997060070f, - -0.078153242f, 0.996941358f, - -0.079682438f, 0.996820299f, - -0.081211447f, 0.996696895f, - -0.082740265f, 0.996571146f, - -0.084268888f, 0.996443051f, - -0.085797312f, 0.996312612f, - -0.087325535f, 0.996179829f, - -0.088853553f, 0.996044701f, - -0.090381361f, 0.995907229f, - -0.091908956f, 0.995767414f, - -0.093436336f, 0.995625256f, - -0.094963495f, 0.995480755f, - -0.096490431f, 0.995333912f, - -0.098017140f, 0.995184727f, - -0.099543619f, 0.995033199f, - -0.101069863f, 0.994879331f, - -0.102595869f, 0.994723121f, - -0.104121634f, 0.994564571f, - -0.105647154f, 0.994403680f, - -0.107172425f, 0.994240449f, - -0.108697444f, 0.994074879f, - -0.110222207f, 0.993906970f, - -0.111746711f, 0.993736722f, - -0.113270952f, 0.993564136f, - -0.114794927f, 0.993389211f, - -0.116318631f, 0.993211949f, - -0.117842062f, 0.993032350f, - -0.119365215f, 0.992850414f, - -0.120888087f, 0.992666142f, - -0.122410675f, 0.992479535f, - -0.123932975f, 0.992290591f, - -0.125454983f, 0.992099313f, - -0.126976696f, 0.991905700f, - -0.128498111f, 0.991709754f, - -0.130019223f, 0.991511473f, - -0.131540029f, 0.991310860f, - -0.133060525f, 0.991107914f, - -0.134580709f, 0.990902635f, - -0.136100575f, 0.990695025f, - -0.137620122f, 0.990485084f, - -0.139139344f, 0.990272812f, - -0.140658239f, 0.990058210f, - -0.142176804f, 0.989841278f, - -0.143695033f, 0.989622017f, - -0.145212925f, 0.989400428f, - -0.146730474f, 0.989176510f, - -0.148247679f, 0.988950265f, - -0.149764535f, 0.988721692f, - -0.151281038f, 0.988490793f, - -0.152797185f, 0.988257568f, - -0.154312973f, 0.988022017f, - -0.155828398f, 0.987784142f, - -0.157343456f, 0.987543942f, - -0.158858143f, 0.987301418f, - -0.160372457f, 0.987056571f, - -0.161886394f, 0.986809402f, - -0.163399949f, 0.986559910f, - -0.164913120f, 0.986308097f, - -0.166425904f, 0.986053963f, - -0.167938295f, 0.985797509f, - -0.169450291f, 0.985538735f, - -0.170961889f, 0.985277642f, - -0.172473084f, 0.985014231f, - -0.173983873f, 0.984748502f, - -0.175494253f, 0.984480455f, - -0.177004220f, 0.984210092f, - -0.178513771f, 0.983937413f, - -0.180022901f, 0.983662419f, - -0.181531608f, 0.983385110f, - -0.183039888f, 0.983105487f, - -0.184547737f, 0.982823551f, - -0.186055152f, 0.982539302f, - -0.187562129f, 0.982252741f, - -0.189068664f, 0.981963869f, - -0.190574755f, 0.981672686f, - -0.192080397f, 0.981379193f, - -0.193585587f, 0.981083391f, - -0.195090322f, 0.980785280f, - -0.196594598f, 0.980484862f, - -0.198098411f, 0.980182136f, - -0.199601758f, 0.979877104f, - -0.201104635f, 0.979569766f, - -0.202607039f, 0.979260123f, - -0.204108966f, 0.978948175f, - -0.205610413f, 0.978633924f, - -0.207111376f, 0.978317371f, - -0.208611852f, 0.977998515f, - -0.210111837f, 0.977677358f, - -0.211611327f, 0.977353900f, - -0.213110320f, 0.977028143f, - -0.214608811f, 0.976700086f, - -0.216106797f, 0.976369731f, - -0.217604275f, 0.976037079f, - -0.219101240f, 0.975702130f, - -0.220597690f, 0.975364885f, - -0.222093621f, 0.975025345f, - -0.223589029f, 0.974683511f, - -0.225083911f, 0.974339383f, - -0.226578264f, 0.973992962f, - -0.228072083f, 0.973644250f, - -0.229565366f, 0.973293246f, - -0.231058108f, 0.972939952f, - -0.232550307f, 0.972584369f, - -0.234041959f, 0.972226497f, - -0.235533059f, 0.971866337f, - -0.237023606f, 0.971503891f, - -0.238513595f, 0.971139158f, - -0.240003022f, 0.970772141f, - -0.241491885f, 0.970402839f, - -0.242980180f, 0.970031253f, - -0.244467903f, 0.969657385f, - -0.245955050f, 0.969281235f, - -0.247441619f, 0.968902805f, - -0.248927606f, 0.968522094f, - -0.250413007f, 0.968139105f, - -0.251897818f, 0.967753837f, - -0.253382037f, 0.967366292f, - -0.254865660f, 0.966976471f, - -0.256348682f, 0.966584374f, - -0.257831102f, 0.966190003f, - -0.259312915f, 0.965793359f, - -0.260794118f, 0.965394442f, - -0.262274707f, 0.964993253f, - -0.263754679f, 0.964589793f, - -0.265234030f, 0.964184064f, - -0.266712757f, 0.963776066f, - -0.268190857f, 0.963365800f, - -0.269668326f, 0.962953267f, - -0.271145160f, 0.962538468f, - -0.272621355f, 0.962121404f, - -0.274096910f, 0.961702077f, - -0.275571819f, 0.961280486f, - -0.277046080f, 0.960856633f, - -0.278519689f, 0.960430519f, - -0.279992643f, 0.960002146f, - -0.281464938f, 0.959571513f, - -0.282936570f, 0.959138622f, - -0.284407537f, 0.958703475f, - -0.285877835f, 0.958266071f, - -0.287347460f, 0.957826413f, - -0.288816408f, 0.957384501f, - -0.290284677f, 0.956940336f, - -0.291752263f, 0.956493919f, - -0.293219163f, 0.956045251f, - -0.294685372f, 0.955594334f, - -0.296150888f, 0.955141168f, - -0.297615707f, 0.954685755f, - -0.299079826f, 0.954228095f, - -0.300543241f, 0.953768190f, - -0.302005949f, 0.953306040f, - -0.303467947f, 0.952841648f, - -0.304929230f, 0.952375013f, - -0.306389795f, 0.951906137f, - -0.307849640f, 0.951435021f, - -0.309308760f, 0.950961666f, - -0.310767153f, 0.950486074f, - -0.312224814f, 0.950008245f, - -0.313681740f, 0.949528181f, - -0.315137929f, 0.949045882f, - -0.316593376f, 0.948561350f, - -0.318048077f, 0.948074586f, - -0.319502031f, 0.947585591f, - -0.320955232f, 0.947094366f, - -0.322407679f, 0.946600913f, - -0.323859367f, 0.946105232f, - -0.325310292f, 0.945607325f, - -0.326760452f, 0.945107193f, - -0.328209844f, 0.944604837f, - -0.329658463f, 0.944100258f, - -0.331106306f, 0.943593458f, - -0.332553370f, 0.943084437f, - -0.333999651f, 0.942573198f, - -0.335445147f, 0.942059740f, - -0.336889853f, 0.941544065f, - -0.338333767f, 0.941026175f, - -0.339776884f, 0.940506071f, - -0.341219202f, 0.939983753f, - -0.342660717f, 0.939459224f, - -0.344101426f, 0.938932484f, - -0.345541325f, 0.938403534f, - -0.346980411f, 0.937872376f, - -0.348418680f, 0.937339012f, - -0.349856130f, 0.936803442f, - -0.351292756f, 0.936265667f, - -0.352728556f, 0.935725689f, - -0.354163525f, 0.935183510f, - -0.355597662f, 0.934639130f, - -0.357030961f, 0.934092550f, - -0.358463421f, 0.933543773f, - -0.359895037f, 0.932992799f, - -0.361325806f, 0.932439629f, - -0.362755724f, 0.931884266f, - -0.364184790f, 0.931326709f, - -0.365612998f, 0.930766961f, - -0.367040346f, 0.930205023f, - -0.368466830f, 0.929640896f, - -0.369892447f, 0.929074581f, - -0.371317194f, 0.928506080f, - -0.372741067f, 0.927935395f, - -0.374164063f, 0.927362526f, - -0.375586178f, 0.926787474f, - -0.377007410f, 0.926210242f, - -0.378427755f, 0.925630831f, - -0.379847209f, 0.925049241f, - -0.381265769f, 0.924465474f, - -0.382683432f, 0.923879533f, - -0.384100195f, 0.923291417f, - -0.385516054f, 0.922701128f, - -0.386931006f, 0.922108669f, - -0.388345047f, 0.921514039f, - -0.389758174f, 0.920917242f, - -0.391170384f, 0.920318277f, - -0.392581674f, 0.919717146f, - -0.393992040f, 0.919113852f, - -0.395401479f, 0.918508394f, - -0.396809987f, 0.917900776f, - -0.398217562f, 0.917290997f, - -0.399624200f, 0.916679060f, - -0.401029897f, 0.916064966f, - -0.402434651f, 0.915448716f, - -0.403838458f, 0.914830312f, - -0.405241314f, 0.914209756f, - -0.406643217f, 0.913587048f, - -0.408044163f, 0.912962190f, - -0.409444149f, 0.912335185f, - -0.410843171f, 0.911706032f, - -0.412241227f, 0.911074734f, - -0.413638312f, 0.910441292f, - -0.415034424f, 0.909805708f, - -0.416429560f, 0.909167983f, - -0.417823716f, 0.908528119f, - -0.419216888f, 0.907886116f, - -0.420609074f, 0.907241978f, - -0.422000271f, 0.906595705f, - -0.423390474f, 0.905947298f, - -0.424779681f, 0.905296759f, - -0.426167889f, 0.904644091f, - -0.427555093f, 0.903989293f, - -0.428941292f, 0.903332368f, - -0.430326481f, 0.902673318f, - -0.431710658f, 0.902012144f, - -0.433093819f, 0.901348847f, - -0.434475961f, 0.900683429f, - -0.435857080f, 0.900015892f, - -0.437237174f, 0.899346237f, - -0.438616239f, 0.898674466f, - -0.439994271f, 0.898000580f, - -0.441371269f, 0.897324581f, - -0.442747228f, 0.896646470f, - -0.444122145f, 0.895966250f, - -0.445496017f, 0.895283921f, - -0.446868840f, 0.894599486f, - -0.448240612f, 0.893912945f, - -0.449611330f, 0.893224301f, - -0.450980989f, 0.892533555f, - -0.452349587f, 0.891840709f, - -0.453717121f, 0.891145765f, - -0.455083587f, 0.890448723f, - -0.456448982f, 0.889749586f, - -0.457813304f, 0.889048356f, - -0.459176548f, 0.888345033f, - -0.460538711f, 0.887639620f, - -0.461899791f, 0.886932119f, - -0.463259784f, 0.886222530f, - -0.464618686f, 0.885510856f, - -0.465976496f, 0.884797098f, - -0.467333209f, 0.884081259f, - -0.468688822f, 0.883363339f, - -0.470043332f, 0.882643340f, - -0.471396737f, 0.881921264f, - -0.472749032f, 0.881197113f, - -0.474100215f, 0.880470889f, - -0.475450282f, 0.879742593f, - -0.476799230f, 0.879012226f, - -0.478147056f, 0.878279792f, - -0.479493758f, 0.877545290f, - -0.480839331f, 0.876808724f, - -0.482183772f, 0.876070094f, - -0.483527079f, 0.875329403f, - -0.484869248f, 0.874586652f, - -0.486210276f, 0.873841843f, - -0.487550160f, 0.873094978f, - -0.488888897f, 0.872346059f, - -0.490226483f, 0.871595087f, - -0.491562916f, 0.870842063f, - -0.492898192f, 0.870086991f, - -0.494232309f, 0.869329871f, - -0.495565262f, 0.868570706f, - -0.496897049f, 0.867809497f, - -0.498227667f, 0.867046246f, - -0.499557113f, 0.866280954f, - -0.500885383f, 0.865513624f, - -0.502212474f, 0.864744258f, - -0.503538384f, 0.863972856f, - -0.504863109f, 0.863199422f, - -0.506186645f, 0.862423956f, - -0.507508991f, 0.861646461f, - -0.508830143f, 0.860866939f, - -0.510150097f, 0.860085390f, - -0.511468850f, 0.859301818f, - -0.512786401f, 0.858516224f, - -0.514102744f, 0.857728610f, - -0.515417878f, 0.856938977f, - -0.516731799f, 0.856147328f, - -0.518044504f, 0.855353665f, - -0.519355990f, 0.854557988f, - -0.520666254f, 0.853760301f, - -0.521975293f, 0.852960605f, - -0.523283103f, 0.852158902f, - -0.524589683f, 0.851355193f, - -0.525895027f, 0.850549481f, - -0.527199135f, 0.849741768f, - -0.528502002f, 0.848932055f, - -0.529803625f, 0.848120345f, - -0.531104001f, 0.847306639f, - -0.532403128f, 0.846490939f, - -0.533701002f, 0.845673247f, - -0.534997620f, 0.844853565f, - -0.536292979f, 0.844031895f, - -0.537587076f, 0.843208240f, - -0.538879909f, 0.842382600f, - -0.540171473f, 0.841554977f, - -0.541461766f, 0.840725375f, - -0.542750785f, 0.839893794f, - -0.544038527f, 0.839060237f, - -0.545324988f, 0.838224706f, - -0.546610167f, 0.837387202f, - -0.547894059f, 0.836547727f, - -0.549176662f, 0.835706284f, - -0.550457973f, 0.834862875f, - -0.551737988f, 0.834017501f, - -0.553016706f, 0.833170165f, - -0.554294121f, 0.832320868f, - -0.555570233f, 0.831469612f, - -0.556845037f, 0.830616400f, - -0.558118531f, 0.829761234f, - -0.559390712f, 0.828904115f, - -0.560661576f, 0.828045045f, - -0.561931121f, 0.827184027f, - -0.563199344f, 0.826321063f, - -0.564466242f, 0.825456154f, - -0.565731811f, 0.824589303f, - -0.566996049f, 0.823720511f, - -0.568258953f, 0.822849781f, - -0.569520519f, 0.821977115f, - -0.570780746f, 0.821102515f, - -0.572039629f, 0.820225983f, - -0.573297167f, 0.819347520f, - -0.574553355f, 0.818467130f, - -0.575808191f, 0.817584813f, - -0.577061673f, 0.816700573f, - -0.578313796f, 0.815814411f, - -0.579564559f, 0.814926329f, - -0.580813958f, 0.814036330f, - -0.582061990f, 0.813144415f, - -0.583308653f, 0.812250587f, - -0.584553943f, 0.811354847f, - -0.585797857f, 0.810457198f, - -0.587040394f, 0.809557642f, - -0.588281548f, 0.808656182f, - -0.589521319f, 0.807752818f, - -0.590759702f, 0.806847554f, - -0.591996695f, 0.805940391f, - -0.593232295f, 0.805031331f, - -0.594466499f, 0.804120377f, - -0.595699304f, 0.803207531f, - -0.596930708f, 0.802292796f, - -0.598160707f, 0.801376172f, - -0.599389298f, 0.800457662f, - -0.600616479f, 0.799537269f, - -0.601842247f, 0.798614995f, - -0.603066599f, 0.797690841f, - -0.604289531f, 0.796764810f, - -0.605511041f, 0.795836905f, - -0.606731127f, 0.794907126f, - -0.607949785f, 0.793975478f, - -0.609167012f, 0.793041960f, - -0.610382806f, 0.792106577f, - -0.611597164f, 0.791169330f, - -0.612810082f, 0.790230221f, - -0.614021559f, 0.789289253f, - -0.615231591f, 0.788346428f, - -0.616440175f, 0.787401747f, - -0.617647308f, 0.786455214f, - -0.618852988f, 0.785506830f, - -0.620057212f, 0.784556597f, - -0.621259977f, 0.783604519f, - -0.622461279f, 0.782650596f, - -0.623661118f, 0.781694832f, - -0.624859488f, 0.780737229f, - -0.626056388f, 0.779777788f, - -0.627251815f, 0.778816512f, - -0.628445767f, 0.777853404f, - -0.629638239f, 0.776888466f, - -0.630829230f, 0.775921699f, - -0.632018736f, 0.774953107f, - -0.633206755f, 0.773982691f, - -0.634393284f, 0.773010453f, - -0.635578320f, 0.772036397f, - -0.636761861f, 0.771060524f, - -0.637943904f, 0.770082837f, - -0.639124445f, 0.769103338f, - -0.640303482f, 0.768122029f, - -0.641481013f, 0.767138912f, - -0.642657034f, 0.766153990f, - -0.643831543f, 0.765167266f, - -0.645004537f, 0.764178741f, - -0.646176013f, 0.763188417f, - -0.647345969f, 0.762196298f, - -0.648514401f, 0.761202385f, - -0.649681307f, 0.760206682f, - -0.650846685f, 0.759209189f, - -0.652010531f, 0.758209910f, - -0.653172843f, 0.757208847f, - -0.654333618f, 0.756206001f, - -0.655492853f, 0.755201377f, - -0.656650546f, 0.754194975f, - -0.657806693f, 0.753186799f, - -0.658961293f, 0.752176850f, - -0.660114342f, 0.751165132f, - -0.661265838f, 0.750151646f, - -0.662415778f, 0.749136395f, - -0.663564159f, 0.748119380f, - -0.664710978f, 0.747100606f, - -0.665856234f, 0.746080074f, - -0.666999922f, 0.745057785f, - -0.668142041f, 0.744033744f, - -0.669282588f, 0.743007952f, - -0.670421560f, 0.741980412f, - -0.671558955f, 0.740951125f, - -0.672694769f, 0.739920095f, - -0.673829000f, 0.738887324f, - -0.674961646f, 0.737852815f, - -0.676092704f, 0.736816569f, - -0.677222170f, 0.735778589f, - -0.678350043f, 0.734738878f, - -0.679476320f, 0.733697438f, - -0.680600998f, 0.732654272f, - -0.681724074f, 0.731609381f, - -0.682845546f, 0.730562769f, - -0.683965412f, 0.729514438f, - -0.685083668f, 0.728464390f, - -0.686200312f, 0.727412629f, - -0.687315341f, 0.726359155f, - -0.688428753f, 0.725303972f, - -0.689540545f, 0.724247083f, - -0.690650714f, 0.723188489f, - -0.691759258f, 0.722128194f, - -0.692866175f, 0.721066199f, - -0.693971461f, 0.720002508f, - -0.695075114f, 0.718937122f, - -0.696177131f, 0.717870045f, - -0.697277511f, 0.716801279f, - -0.698376249f, 0.715730825f, - -0.699473345f, 0.714658688f, - -0.700568794f, 0.713584869f, - -0.701662595f, 0.712509371f, - -0.702754744f, 0.711432196f, - -0.703845241f, 0.710353347f, - -0.704934080f, 0.709272826f, - -0.706021261f, 0.708190637f, - -0.707106781f, 0.707106781f, - -0.708190637f, 0.706021261f, - -0.709272826f, 0.704934080f, - -0.710353347f, 0.703845241f, - -0.711432196f, 0.702754744f, - -0.712509371f, 0.701662595f, - -0.713584869f, 0.700568794f, - -0.714658688f, 0.699473345f, - -0.715730825f, 0.698376249f, - -0.716801279f, 0.697277511f, - -0.717870045f, 0.696177131f, - -0.718937122f, 0.695075114f, - -0.720002508f, 0.693971461f, - -0.721066199f, 0.692866175f, - -0.722128194f, 0.691759258f, - -0.723188489f, 0.690650714f, - -0.724247083f, 0.689540545f, - -0.725303972f, 0.688428753f, - -0.726359155f, 0.687315341f, - -0.727412629f, 0.686200312f, - -0.728464390f, 0.685083668f, - -0.729514438f, 0.683965412f, - -0.730562769f, 0.682845546f, - -0.731609381f, 0.681724074f, - -0.732654272f, 0.680600998f, - -0.733697438f, 0.679476320f, - -0.734738878f, 0.678350043f, - -0.735778589f, 0.677222170f, - -0.736816569f, 0.676092704f, - -0.737852815f, 0.674961646f, - -0.738887324f, 0.673829000f, - -0.739920095f, 0.672694769f, - -0.740951125f, 0.671558955f, - -0.741980412f, 0.670421560f, - -0.743007952f, 0.669282588f, - -0.744033744f, 0.668142041f, - -0.745057785f, 0.666999922f, - -0.746080074f, 0.665856234f, - -0.747100606f, 0.664710978f, - -0.748119380f, 0.663564159f, - -0.749136395f, 0.662415778f, - -0.750151646f, 0.661265838f, - -0.751165132f, 0.660114342f, - -0.752176850f, 0.658961293f, - -0.753186799f, 0.657806693f, - -0.754194975f, 0.656650546f, - -0.755201377f, 0.655492853f, - -0.756206001f, 0.654333618f, - -0.757208847f, 0.653172843f, - -0.758209910f, 0.652010531f, - -0.759209189f, 0.650846685f, - -0.760206682f, 0.649681307f, - -0.761202385f, 0.648514401f, - -0.762196298f, 0.647345969f, - -0.763188417f, 0.646176013f, - -0.764178741f, 0.645004537f, - -0.765167266f, 0.643831543f, - -0.766153990f, 0.642657034f, - -0.767138912f, 0.641481013f, - -0.768122029f, 0.640303482f, - -0.769103338f, 0.639124445f, - -0.770082837f, 0.637943904f, - -0.771060524f, 0.636761861f, - -0.772036397f, 0.635578320f, - -0.773010453f, 0.634393284f, - -0.773982691f, 0.633206755f, - -0.774953107f, 0.632018736f, - -0.775921699f, 0.630829230f, - -0.776888466f, 0.629638239f, - -0.777853404f, 0.628445767f, - -0.778816512f, 0.627251815f, - -0.779777788f, 0.626056388f, - -0.780737229f, 0.624859488f, - -0.781694832f, 0.623661118f, - -0.782650596f, 0.622461279f, - -0.783604519f, 0.621259977f, - -0.784556597f, 0.620057212f, - -0.785506830f, 0.618852988f, - -0.786455214f, 0.617647308f, - -0.787401747f, 0.616440175f, - -0.788346428f, 0.615231591f, - -0.789289253f, 0.614021559f, - -0.790230221f, 0.612810082f, - -0.791169330f, 0.611597164f, - -0.792106577f, 0.610382806f, - -0.793041960f, 0.609167012f, - -0.793975478f, 0.607949785f, - -0.794907126f, 0.606731127f, - -0.795836905f, 0.605511041f, - -0.796764810f, 0.604289531f, - -0.797690841f, 0.603066599f, - -0.798614995f, 0.601842247f, - -0.799537269f, 0.600616479f, - -0.800457662f, 0.599389298f, - -0.801376172f, 0.598160707f, - -0.802292796f, 0.596930708f, - -0.803207531f, 0.595699304f, - -0.804120377f, 0.594466499f, - -0.805031331f, 0.593232295f, - -0.805940391f, 0.591996695f, - -0.806847554f, 0.590759702f, - -0.807752818f, 0.589521319f, - -0.808656182f, 0.588281548f, - -0.809557642f, 0.587040394f, - -0.810457198f, 0.585797857f, - -0.811354847f, 0.584553943f, - -0.812250587f, 0.583308653f, - -0.813144415f, 0.582061990f, - -0.814036330f, 0.580813958f, - -0.814926329f, 0.579564559f, - -0.815814411f, 0.578313796f, - -0.816700573f, 0.577061673f, - -0.817584813f, 0.575808191f, - -0.818467130f, 0.574553355f, - -0.819347520f, 0.573297167f, - -0.820225983f, 0.572039629f, - -0.821102515f, 0.570780746f, - -0.821977115f, 0.569520519f, - -0.822849781f, 0.568258953f, - -0.823720511f, 0.566996049f, - -0.824589303f, 0.565731811f, - -0.825456154f, 0.564466242f, - -0.826321063f, 0.563199344f, - -0.827184027f, 0.561931121f, - -0.828045045f, 0.560661576f, - -0.828904115f, 0.559390712f, - -0.829761234f, 0.558118531f, - -0.830616400f, 0.556845037f, - -0.831469612f, 0.555570233f, - -0.832320868f, 0.554294121f, - -0.833170165f, 0.553016706f, - -0.834017501f, 0.551737988f, - -0.834862875f, 0.550457973f, - -0.835706284f, 0.549176662f, - -0.836547727f, 0.547894059f, - -0.837387202f, 0.546610167f, - -0.838224706f, 0.545324988f, - -0.839060237f, 0.544038527f, - -0.839893794f, 0.542750785f, - -0.840725375f, 0.541461766f, - -0.841554977f, 0.540171473f, - -0.842382600f, 0.538879909f, - -0.843208240f, 0.537587076f, - -0.844031895f, 0.536292979f, - -0.844853565f, 0.534997620f, - -0.845673247f, 0.533701002f, - -0.846490939f, 0.532403128f, - -0.847306639f, 0.531104001f, - -0.848120345f, 0.529803625f, - -0.848932055f, 0.528502002f, - -0.849741768f, 0.527199135f, - -0.850549481f, 0.525895027f, - -0.851355193f, 0.524589683f, - -0.852158902f, 0.523283103f, - -0.852960605f, 0.521975293f, - -0.853760301f, 0.520666254f, - -0.854557988f, 0.519355990f, - -0.855353665f, 0.518044504f, - -0.856147328f, 0.516731799f, - -0.856938977f, 0.515417878f, - -0.857728610f, 0.514102744f, - -0.858516224f, 0.512786401f, - -0.859301818f, 0.511468850f, - -0.860085390f, 0.510150097f, - -0.860866939f, 0.508830143f, - -0.861646461f, 0.507508991f, - -0.862423956f, 0.506186645f, - -0.863199422f, 0.504863109f, - -0.863972856f, 0.503538384f, - -0.864744258f, 0.502212474f, - -0.865513624f, 0.500885383f, - -0.866280954f, 0.499557113f, - -0.867046246f, 0.498227667f, - -0.867809497f, 0.496897049f, - -0.868570706f, 0.495565262f, - -0.869329871f, 0.494232309f, - -0.870086991f, 0.492898192f, - -0.870842063f, 0.491562916f, - -0.871595087f, 0.490226483f, - -0.872346059f, 0.488888897f, - -0.873094978f, 0.487550160f, - -0.873841843f, 0.486210276f, - -0.874586652f, 0.484869248f, - -0.875329403f, 0.483527079f, - -0.876070094f, 0.482183772f, - -0.876808724f, 0.480839331f, - -0.877545290f, 0.479493758f, - -0.878279792f, 0.478147056f, - -0.879012226f, 0.476799230f, - -0.879742593f, 0.475450282f, - -0.880470889f, 0.474100215f, - -0.881197113f, 0.472749032f, - -0.881921264f, 0.471396737f, - -0.882643340f, 0.470043332f, - -0.883363339f, 0.468688822f, - -0.884081259f, 0.467333209f, - -0.884797098f, 0.465976496f, - -0.885510856f, 0.464618686f, - -0.886222530f, 0.463259784f, - -0.886932119f, 0.461899791f, - -0.887639620f, 0.460538711f, - -0.888345033f, 0.459176548f, - -0.889048356f, 0.457813304f, - -0.889749586f, 0.456448982f, - -0.890448723f, 0.455083587f, - -0.891145765f, 0.453717121f, - -0.891840709f, 0.452349587f, - -0.892533555f, 0.450980989f, - -0.893224301f, 0.449611330f, - -0.893912945f, 0.448240612f, - -0.894599486f, 0.446868840f, - -0.895283921f, 0.445496017f, - -0.895966250f, 0.444122145f, - -0.896646470f, 0.442747228f, - -0.897324581f, 0.441371269f, - -0.898000580f, 0.439994271f, - -0.898674466f, 0.438616239f, - -0.899346237f, 0.437237174f, - -0.900015892f, 0.435857080f, - -0.900683429f, 0.434475961f, - -0.901348847f, 0.433093819f, - -0.902012144f, 0.431710658f, - -0.902673318f, 0.430326481f, - -0.903332368f, 0.428941292f, - -0.903989293f, 0.427555093f, - -0.904644091f, 0.426167889f, - -0.905296759f, 0.424779681f, - -0.905947298f, 0.423390474f, - -0.906595705f, 0.422000271f, - -0.907241978f, 0.420609074f, - -0.907886116f, 0.419216888f, - -0.908528119f, 0.417823716f, - -0.909167983f, 0.416429560f, - -0.909805708f, 0.415034424f, - -0.910441292f, 0.413638312f, - -0.911074734f, 0.412241227f, - -0.911706032f, 0.410843171f, - -0.912335185f, 0.409444149f, - -0.912962190f, 0.408044163f, - -0.913587048f, 0.406643217f, - -0.914209756f, 0.405241314f, - -0.914830312f, 0.403838458f, - -0.915448716f, 0.402434651f, - -0.916064966f, 0.401029897f, - -0.916679060f, 0.399624200f, - -0.917290997f, 0.398217562f, - -0.917900776f, 0.396809987f, - -0.918508394f, 0.395401479f, - -0.919113852f, 0.393992040f, - -0.919717146f, 0.392581674f, - -0.920318277f, 0.391170384f, - -0.920917242f, 0.389758174f, - -0.921514039f, 0.388345047f, - -0.922108669f, 0.386931006f, - -0.922701128f, 0.385516054f, - -0.923291417f, 0.384100195f, - -0.923879533f, 0.382683432f, - -0.924465474f, 0.381265769f, - -0.925049241f, 0.379847209f, - -0.925630831f, 0.378427755f, - -0.926210242f, 0.377007410f, - -0.926787474f, 0.375586178f, - -0.927362526f, 0.374164063f, - -0.927935395f, 0.372741067f, - -0.928506080f, 0.371317194f, - -0.929074581f, 0.369892447f, - -0.929640896f, 0.368466830f, - -0.930205023f, 0.367040346f, - -0.930766961f, 0.365612998f, - -0.931326709f, 0.364184790f, - -0.931884266f, 0.362755724f, - -0.932439629f, 0.361325806f, - -0.932992799f, 0.359895037f, - -0.933543773f, 0.358463421f, - -0.934092550f, 0.357030961f, - -0.934639130f, 0.355597662f, - -0.935183510f, 0.354163525f, - -0.935725689f, 0.352728556f, - -0.936265667f, 0.351292756f, - -0.936803442f, 0.349856130f, - -0.937339012f, 0.348418680f, - -0.937872376f, 0.346980411f, - -0.938403534f, 0.345541325f, - -0.938932484f, 0.344101426f, - -0.939459224f, 0.342660717f, - -0.939983753f, 0.341219202f, - -0.940506071f, 0.339776884f, - -0.941026175f, 0.338333767f, - -0.941544065f, 0.336889853f, - -0.942059740f, 0.335445147f, - -0.942573198f, 0.333999651f, - -0.943084437f, 0.332553370f, - -0.943593458f, 0.331106306f, - -0.944100258f, 0.329658463f, - -0.944604837f, 0.328209844f, - -0.945107193f, 0.326760452f, - -0.945607325f, 0.325310292f, - -0.946105232f, 0.323859367f, - -0.946600913f, 0.322407679f, - -0.947094366f, 0.320955232f, - -0.947585591f, 0.319502031f, - -0.948074586f, 0.318048077f, - -0.948561350f, 0.316593376f, - -0.949045882f, 0.315137929f, - -0.949528181f, 0.313681740f, - -0.950008245f, 0.312224814f, - -0.950486074f, 0.310767153f, - -0.950961666f, 0.309308760f, - -0.951435021f, 0.307849640f, - -0.951906137f, 0.306389795f, - -0.952375013f, 0.304929230f, - -0.952841648f, 0.303467947f, - -0.953306040f, 0.302005949f, - -0.953768190f, 0.300543241f, - -0.954228095f, 0.299079826f, - -0.954685755f, 0.297615707f, - -0.955141168f, 0.296150888f, - -0.955594334f, 0.294685372f, - -0.956045251f, 0.293219163f, - -0.956493919f, 0.291752263f, - -0.956940336f, 0.290284677f, - -0.957384501f, 0.288816408f, - -0.957826413f, 0.287347460f, - -0.958266071f, 0.285877835f, - -0.958703475f, 0.284407537f, - -0.959138622f, 0.282936570f, - -0.959571513f, 0.281464938f, - -0.960002146f, 0.279992643f, - -0.960430519f, 0.278519689f, - -0.960856633f, 0.277046080f, - -0.961280486f, 0.275571819f, - -0.961702077f, 0.274096910f, - -0.962121404f, 0.272621355f, - -0.962538468f, 0.271145160f, - -0.962953267f, 0.269668326f, - -0.963365800f, 0.268190857f, - -0.963776066f, 0.266712757f, - -0.964184064f, 0.265234030f, - -0.964589793f, 0.263754679f, - -0.964993253f, 0.262274707f, - -0.965394442f, 0.260794118f, - -0.965793359f, 0.259312915f, - -0.966190003f, 0.257831102f, - -0.966584374f, 0.256348682f, - -0.966976471f, 0.254865660f, - -0.967366292f, 0.253382037f, - -0.967753837f, 0.251897818f, - -0.968139105f, 0.250413007f, - -0.968522094f, 0.248927606f, - -0.968902805f, 0.247441619f, - -0.969281235f, 0.245955050f, - -0.969657385f, 0.244467903f, - -0.970031253f, 0.242980180f, - -0.970402839f, 0.241491885f, - -0.970772141f, 0.240003022f, - -0.971139158f, 0.238513595f, - -0.971503891f, 0.237023606f, - -0.971866337f, 0.235533059f, - -0.972226497f, 0.234041959f, - -0.972584369f, 0.232550307f, - -0.972939952f, 0.231058108f, - -0.973293246f, 0.229565366f, - -0.973644250f, 0.228072083f, - -0.973992962f, 0.226578264f, - -0.974339383f, 0.225083911f, - -0.974683511f, 0.223589029f, - -0.975025345f, 0.222093621f, - -0.975364885f, 0.220597690f, - -0.975702130f, 0.219101240f, - -0.976037079f, 0.217604275f, - -0.976369731f, 0.216106797f, - -0.976700086f, 0.214608811f, - -0.977028143f, 0.213110320f, - -0.977353900f, 0.211611327f, - -0.977677358f, 0.210111837f, - -0.977998515f, 0.208611852f, - -0.978317371f, 0.207111376f, - -0.978633924f, 0.205610413f, - -0.978948175f, 0.204108966f, - -0.979260123f, 0.202607039f, - -0.979569766f, 0.201104635f, - -0.979877104f, 0.199601758f, - -0.980182136f, 0.198098411f, - -0.980484862f, 0.196594598f, - -0.980785280f, 0.195090322f, - -0.981083391f, 0.193585587f, - -0.981379193f, 0.192080397f, - -0.981672686f, 0.190574755f, - -0.981963869f, 0.189068664f, - -0.982252741f, 0.187562129f, - -0.982539302f, 0.186055152f, - -0.982823551f, 0.184547737f, - -0.983105487f, 0.183039888f, - -0.983385110f, 0.181531608f, - -0.983662419f, 0.180022901f, - -0.983937413f, 0.178513771f, - -0.984210092f, 0.177004220f, - -0.984480455f, 0.175494253f, - -0.984748502f, 0.173983873f, - -0.985014231f, 0.172473084f, - -0.985277642f, 0.170961889f, - -0.985538735f, 0.169450291f, - -0.985797509f, 0.167938295f, - -0.986053963f, 0.166425904f, - -0.986308097f, 0.164913120f, - -0.986559910f, 0.163399949f, - -0.986809402f, 0.161886394f, - -0.987056571f, 0.160372457f, - -0.987301418f, 0.158858143f, - -0.987543942f, 0.157343456f, - -0.987784142f, 0.155828398f, - -0.988022017f, 0.154312973f, - -0.988257568f, 0.152797185f, - -0.988490793f, 0.151281038f, - -0.988721692f, 0.149764535f, - -0.988950265f, 0.148247679f, - -0.989176510f, 0.146730474f, - -0.989400428f, 0.145212925f, - -0.989622017f, 0.143695033f, - -0.989841278f, 0.142176804f, - -0.990058210f, 0.140658239f, - -0.990272812f, 0.139139344f, - -0.990485084f, 0.137620122f, - -0.990695025f, 0.136100575f, - -0.990902635f, 0.134580709f, - -0.991107914f, 0.133060525f, - -0.991310860f, 0.131540029f, - -0.991511473f, 0.130019223f, - -0.991709754f, 0.128498111f, - -0.991905700f, 0.126976696f, - -0.992099313f, 0.125454983f, - -0.992290591f, 0.123932975f, - -0.992479535f, 0.122410675f, - -0.992666142f, 0.120888087f, - -0.992850414f, 0.119365215f, - -0.993032350f, 0.117842062f, - -0.993211949f, 0.116318631f, - -0.993389211f, 0.114794927f, - -0.993564136f, 0.113270952f, - -0.993736722f, 0.111746711f, - -0.993906970f, 0.110222207f, - -0.994074879f, 0.108697444f, - -0.994240449f, 0.107172425f, - -0.994403680f, 0.105647154f, - -0.994564571f, 0.104121634f, - -0.994723121f, 0.102595869f, - -0.994879331f, 0.101069863f, - -0.995033199f, 0.099543619f, - -0.995184727f, 0.098017140f, - -0.995333912f, 0.096490431f, - -0.995480755f, 0.094963495f, - -0.995625256f, 0.093436336f, - -0.995767414f, 0.091908956f, - -0.995907229f, 0.090381361f, - -0.996044701f, 0.088853553f, - -0.996179829f, 0.087325535f, - -0.996312612f, 0.085797312f, - -0.996443051f, 0.084268888f, - -0.996571146f, 0.082740265f, - -0.996696895f, 0.081211447f, - -0.996820299f, 0.079682438f, - -0.996941358f, 0.078153242f, - -0.997060070f, 0.076623861f, - -0.997176437f, 0.075094301f, - -0.997290457f, 0.073564564f, - -0.997402130f, 0.072034653f, - -0.997511456f, 0.070504573f, - -0.997618435f, 0.068974328f, - -0.997723067f, 0.067443920f, - -0.997825350f, 0.065913353f, - -0.997925286f, 0.064382631f, - -0.998022874f, 0.062851758f, - -0.998118113f, 0.061320736f, - -0.998211003f, 0.059789571f, - -0.998301545f, 0.058258265f, - -0.998389737f, 0.056726821f, - -0.998475581f, 0.055195244f, - -0.998559074f, 0.053663538f, - -0.998640218f, 0.052131705f, - -0.998719012f, 0.050599749f, - -0.998795456f, 0.049067674f, - -0.998869550f, 0.047535484f, - -0.998941293f, 0.046003182f, - -0.999010686f, 0.044470772f, - -0.999077728f, 0.042938257f, - -0.999142419f, 0.041405641f, - -0.999204759f, 0.039872928f, - -0.999264747f, 0.038340120f, - -0.999322385f, 0.036807223f, - -0.999377670f, 0.035274239f, - -0.999430605f, 0.033741172f, - -0.999481187f, 0.032208025f, - -0.999529418f, 0.030674803f, - -0.999575296f, 0.029141509f, - -0.999618822f, 0.027608146f, - -0.999659997f, 0.026074718f, - -0.999698819f, 0.024541229f, - -0.999735288f, 0.023007681f, - -0.999769405f, 0.021474080f, - -0.999801170f, 0.019940429f, - -0.999830582f, 0.018406730f, - -0.999857641f, 0.016872988f, - -0.999882347f, 0.015339206f, - -0.999904701f, 0.013805389f, - -0.999924702f, 0.012271538f, - -0.999942350f, 0.010737659f, - -0.999957645f, 0.009203755f, - -0.999970586f, 0.007669829f, - -0.999981175f, 0.006135885f, - -0.999989411f, 0.004601926f, - -0.999995294f, 0.003067957f, - -0.999998823f, 0.001533980f, - -1.000000000f, 0.000000000f, - -0.999998823f, -0.001533980f, - -0.999995294f, -0.003067957f, - -0.999989411f, -0.004601926f, - -0.999981175f, -0.006135885f, - -0.999970586f, -0.007669829f, - -0.999957645f, -0.009203755f, - -0.999942350f, -0.010737659f, - -0.999924702f, -0.012271538f, - -0.999904701f, -0.013805389f, - -0.999882347f, -0.015339206f, - -0.999857641f, -0.016872988f, - -0.999830582f, -0.018406730f, - -0.999801170f, -0.019940429f, - -0.999769405f, -0.021474080f, - -0.999735288f, -0.023007681f, - -0.999698819f, -0.024541229f, - -0.999659997f, -0.026074718f, - -0.999618822f, -0.027608146f, - -0.999575296f, -0.029141509f, - -0.999529418f, -0.030674803f, - -0.999481187f, -0.032208025f, - -0.999430605f, -0.033741172f, - -0.999377670f, -0.035274239f, - -0.999322385f, -0.036807223f, - -0.999264747f, -0.038340120f, - -0.999204759f, -0.039872928f, - -0.999142419f, -0.041405641f, - -0.999077728f, -0.042938257f, - -0.999010686f, -0.044470772f, - -0.998941293f, -0.046003182f, - -0.998869550f, -0.047535484f, - -0.998795456f, -0.049067674f, - -0.998719012f, -0.050599749f, - -0.998640218f, -0.052131705f, - -0.998559074f, -0.053663538f, - -0.998475581f, -0.055195244f, - -0.998389737f, -0.056726821f, - -0.998301545f, -0.058258265f, - -0.998211003f, -0.059789571f, - -0.998118113f, -0.061320736f, - -0.998022874f, -0.062851758f, - -0.997925286f, -0.064382631f, - -0.997825350f, -0.065913353f, - -0.997723067f, -0.067443920f, - -0.997618435f, -0.068974328f, - -0.997511456f, -0.070504573f, - -0.997402130f, -0.072034653f, - -0.997290457f, -0.073564564f, - -0.997176437f, -0.075094301f, - -0.997060070f, -0.076623861f, - -0.996941358f, -0.078153242f, - -0.996820299f, -0.079682438f, - -0.996696895f, -0.081211447f, - -0.996571146f, -0.082740265f, - -0.996443051f, -0.084268888f, - -0.996312612f, -0.085797312f, - -0.996179829f, -0.087325535f, - -0.996044701f, -0.088853553f, - -0.995907229f, -0.090381361f, - -0.995767414f, -0.091908956f, - -0.995625256f, -0.093436336f, - -0.995480755f, -0.094963495f, - -0.995333912f, -0.096490431f, - -0.995184727f, -0.098017140f, - -0.995033199f, -0.099543619f, - -0.994879331f, -0.101069863f, - -0.994723121f, -0.102595869f, - -0.994564571f, -0.104121634f, - -0.994403680f, -0.105647154f, - -0.994240449f, -0.107172425f, - -0.994074879f, -0.108697444f, - -0.993906970f, -0.110222207f, - -0.993736722f, -0.111746711f, - -0.993564136f, -0.113270952f, - -0.993389211f, -0.114794927f, - -0.993211949f, -0.116318631f, - -0.993032350f, -0.117842062f, - -0.992850414f, -0.119365215f, - -0.992666142f, -0.120888087f, - -0.992479535f, -0.122410675f, - -0.992290591f, -0.123932975f, - -0.992099313f, -0.125454983f, - -0.991905700f, -0.126976696f, - -0.991709754f, -0.128498111f, - -0.991511473f, -0.130019223f, - -0.991310860f, -0.131540029f, - -0.991107914f, -0.133060525f, - -0.990902635f, -0.134580709f, - -0.990695025f, -0.136100575f, - -0.990485084f, -0.137620122f, - -0.990272812f, -0.139139344f, - -0.990058210f, -0.140658239f, - -0.989841278f, -0.142176804f, - -0.989622017f, -0.143695033f, - -0.989400428f, -0.145212925f, - -0.989176510f, -0.146730474f, - -0.988950265f, -0.148247679f, - -0.988721692f, -0.149764535f, - -0.988490793f, -0.151281038f, - -0.988257568f, -0.152797185f, - -0.988022017f, -0.154312973f, - -0.987784142f, -0.155828398f, - -0.987543942f, -0.157343456f, - -0.987301418f, -0.158858143f, - -0.987056571f, -0.160372457f, - -0.986809402f, -0.161886394f, - -0.986559910f, -0.163399949f, - -0.986308097f, -0.164913120f, - -0.986053963f, -0.166425904f, - -0.985797509f, -0.167938295f, - -0.985538735f, -0.169450291f, - -0.985277642f, -0.170961889f, - -0.985014231f, -0.172473084f, - -0.984748502f, -0.173983873f, - -0.984480455f, -0.175494253f, - -0.984210092f, -0.177004220f, - -0.983937413f, -0.178513771f, - -0.983662419f, -0.180022901f, - -0.983385110f, -0.181531608f, - -0.983105487f, -0.183039888f, - -0.982823551f, -0.184547737f, - -0.982539302f, -0.186055152f, - -0.982252741f, -0.187562129f, - -0.981963869f, -0.189068664f, - -0.981672686f, -0.190574755f, - -0.981379193f, -0.192080397f, - -0.981083391f, -0.193585587f, - -0.980785280f, -0.195090322f, - -0.980484862f, -0.196594598f, - -0.980182136f, -0.198098411f, - -0.979877104f, -0.199601758f, - -0.979569766f, -0.201104635f, - -0.979260123f, -0.202607039f, - -0.978948175f, -0.204108966f, - -0.978633924f, -0.205610413f, - -0.978317371f, -0.207111376f, - -0.977998515f, -0.208611852f, - -0.977677358f, -0.210111837f, - -0.977353900f, -0.211611327f, - -0.977028143f, -0.213110320f, - -0.976700086f, -0.214608811f, - -0.976369731f, -0.216106797f, - -0.976037079f, -0.217604275f, - -0.975702130f, -0.219101240f, - -0.975364885f, -0.220597690f, - -0.975025345f, -0.222093621f, - -0.974683511f, -0.223589029f, - -0.974339383f, -0.225083911f, - -0.973992962f, -0.226578264f, - -0.973644250f, -0.228072083f, - -0.973293246f, -0.229565366f, - -0.972939952f, -0.231058108f, - -0.972584369f, -0.232550307f, - -0.972226497f, -0.234041959f, - -0.971866337f, -0.235533059f, - -0.971503891f, -0.237023606f, - -0.971139158f, -0.238513595f, - -0.970772141f, -0.240003022f, - -0.970402839f, -0.241491885f, - -0.970031253f, -0.242980180f, - -0.969657385f, -0.244467903f, - -0.969281235f, -0.245955050f, - -0.968902805f, -0.247441619f, - -0.968522094f, -0.248927606f, - -0.968139105f, -0.250413007f, - -0.967753837f, -0.251897818f, - -0.967366292f, -0.253382037f, - -0.966976471f, -0.254865660f, - -0.966584374f, -0.256348682f, - -0.966190003f, -0.257831102f, - -0.965793359f, -0.259312915f, - -0.965394442f, -0.260794118f, - -0.964993253f, -0.262274707f, - -0.964589793f, -0.263754679f, - -0.964184064f, -0.265234030f, - -0.963776066f, -0.266712757f, - -0.963365800f, -0.268190857f, - -0.962953267f, -0.269668326f, - -0.962538468f, -0.271145160f, - -0.962121404f, -0.272621355f, - -0.961702077f, -0.274096910f, - -0.961280486f, -0.275571819f, - -0.960856633f, -0.277046080f, - -0.960430519f, -0.278519689f, - -0.960002146f, -0.279992643f, - -0.959571513f, -0.281464938f, - -0.959138622f, -0.282936570f, - -0.958703475f, -0.284407537f, - -0.958266071f, -0.285877835f, - -0.957826413f, -0.287347460f, - -0.957384501f, -0.288816408f, - -0.956940336f, -0.290284677f, - -0.956493919f, -0.291752263f, - -0.956045251f, -0.293219163f, - -0.955594334f, -0.294685372f, - -0.955141168f, -0.296150888f, - -0.954685755f, -0.297615707f, - -0.954228095f, -0.299079826f, - -0.953768190f, -0.300543241f, - -0.953306040f, -0.302005949f, - -0.952841648f, -0.303467947f, - -0.952375013f, -0.304929230f, - -0.951906137f, -0.306389795f, - -0.951435021f, -0.307849640f, - -0.950961666f, -0.309308760f, - -0.950486074f, -0.310767153f, - -0.950008245f, -0.312224814f, - -0.949528181f, -0.313681740f, - -0.949045882f, -0.315137929f, - -0.948561350f, -0.316593376f, - -0.948074586f, -0.318048077f, - -0.947585591f, -0.319502031f, - -0.947094366f, -0.320955232f, - -0.946600913f, -0.322407679f, - -0.946105232f, -0.323859367f, - -0.945607325f, -0.325310292f, - -0.945107193f, -0.326760452f, - -0.944604837f, -0.328209844f, - -0.944100258f, -0.329658463f, - -0.943593458f, -0.331106306f, - -0.943084437f, -0.332553370f, - -0.942573198f, -0.333999651f, - -0.942059740f, -0.335445147f, - -0.941544065f, -0.336889853f, - -0.941026175f, -0.338333767f, - -0.940506071f, -0.339776884f, - -0.939983753f, -0.341219202f, - -0.939459224f, -0.342660717f, - -0.938932484f, -0.344101426f, - -0.938403534f, -0.345541325f, - -0.937872376f, -0.346980411f, - -0.937339012f, -0.348418680f, - -0.936803442f, -0.349856130f, - -0.936265667f, -0.351292756f, - -0.935725689f, -0.352728556f, - -0.935183510f, -0.354163525f, - -0.934639130f, -0.355597662f, - -0.934092550f, -0.357030961f, - -0.933543773f, -0.358463421f, - -0.932992799f, -0.359895037f, - -0.932439629f, -0.361325806f, - -0.931884266f, -0.362755724f, - -0.931326709f, -0.364184790f, - -0.930766961f, -0.365612998f, - -0.930205023f, -0.367040346f, - -0.929640896f, -0.368466830f, - -0.929074581f, -0.369892447f, - -0.928506080f, -0.371317194f, - -0.927935395f, -0.372741067f, - -0.927362526f, -0.374164063f, - -0.926787474f, -0.375586178f, - -0.926210242f, -0.377007410f, - -0.925630831f, -0.378427755f, - -0.925049241f, -0.379847209f, - -0.924465474f, -0.381265769f, - -0.923879533f, -0.382683432f, - -0.923291417f, -0.384100195f, - -0.922701128f, -0.385516054f, - -0.922108669f, -0.386931006f, - -0.921514039f, -0.388345047f, - -0.920917242f, -0.389758174f, - -0.920318277f, -0.391170384f, - -0.919717146f, -0.392581674f, - -0.919113852f, -0.393992040f, - -0.918508394f, -0.395401479f, - -0.917900776f, -0.396809987f, - -0.917290997f, -0.398217562f, - -0.916679060f, -0.399624200f, - -0.916064966f, -0.401029897f, - -0.915448716f, -0.402434651f, - -0.914830312f, -0.403838458f, - -0.914209756f, -0.405241314f, - -0.913587048f, -0.406643217f, - -0.912962190f, -0.408044163f, - -0.912335185f, -0.409444149f, - -0.911706032f, -0.410843171f, - -0.911074734f, -0.412241227f, - -0.910441292f, -0.413638312f, - -0.909805708f, -0.415034424f, - -0.909167983f, -0.416429560f, - -0.908528119f, -0.417823716f, - -0.907886116f, -0.419216888f, - -0.907241978f, -0.420609074f, - -0.906595705f, -0.422000271f, - -0.905947298f, -0.423390474f, - -0.905296759f, -0.424779681f, - -0.904644091f, -0.426167889f, - -0.903989293f, -0.427555093f, - -0.903332368f, -0.428941292f, - -0.902673318f, -0.430326481f, - -0.902012144f, -0.431710658f, - -0.901348847f, -0.433093819f, - -0.900683429f, -0.434475961f, - -0.900015892f, -0.435857080f, - -0.899346237f, -0.437237174f, - -0.898674466f, -0.438616239f, - -0.898000580f, -0.439994271f, - -0.897324581f, -0.441371269f, - -0.896646470f, -0.442747228f, - -0.895966250f, -0.444122145f, - -0.895283921f, -0.445496017f, - -0.894599486f, -0.446868840f, - -0.893912945f, -0.448240612f, - -0.893224301f, -0.449611330f, - -0.892533555f, -0.450980989f, - -0.891840709f, -0.452349587f, - -0.891145765f, -0.453717121f, - -0.890448723f, -0.455083587f, - -0.889749586f, -0.456448982f, - -0.889048356f, -0.457813304f, - -0.888345033f, -0.459176548f, - -0.887639620f, -0.460538711f, - -0.886932119f, -0.461899791f, - -0.886222530f, -0.463259784f, - -0.885510856f, -0.464618686f, - -0.884797098f, -0.465976496f, - -0.884081259f, -0.467333209f, - -0.883363339f, -0.468688822f, - -0.882643340f, -0.470043332f, - -0.881921264f, -0.471396737f, - -0.881197113f, -0.472749032f, - -0.880470889f, -0.474100215f, - -0.879742593f, -0.475450282f, - -0.879012226f, -0.476799230f, - -0.878279792f, -0.478147056f, - -0.877545290f, -0.479493758f, - -0.876808724f, -0.480839331f, - -0.876070094f, -0.482183772f, - -0.875329403f, -0.483527079f, - -0.874586652f, -0.484869248f, - -0.873841843f, -0.486210276f, - -0.873094978f, -0.487550160f, - -0.872346059f, -0.488888897f, - -0.871595087f, -0.490226483f, - -0.870842063f, -0.491562916f, - -0.870086991f, -0.492898192f, - -0.869329871f, -0.494232309f, - -0.868570706f, -0.495565262f, - -0.867809497f, -0.496897049f, - -0.867046246f, -0.498227667f, - -0.866280954f, -0.499557113f, - -0.865513624f, -0.500885383f, - -0.864744258f, -0.502212474f, - -0.863972856f, -0.503538384f, - -0.863199422f, -0.504863109f, - -0.862423956f, -0.506186645f, - -0.861646461f, -0.507508991f, - -0.860866939f, -0.508830143f, - -0.860085390f, -0.510150097f, - -0.859301818f, -0.511468850f, - -0.858516224f, -0.512786401f, - -0.857728610f, -0.514102744f, - -0.856938977f, -0.515417878f, - -0.856147328f, -0.516731799f, - -0.855353665f, -0.518044504f, - -0.854557988f, -0.519355990f, - -0.853760301f, -0.520666254f, - -0.852960605f, -0.521975293f, - -0.852158902f, -0.523283103f, - -0.851355193f, -0.524589683f, - -0.850549481f, -0.525895027f, - -0.849741768f, -0.527199135f, - -0.848932055f, -0.528502002f, - -0.848120345f, -0.529803625f, - -0.847306639f, -0.531104001f, - -0.846490939f, -0.532403128f, - -0.845673247f, -0.533701002f, - -0.844853565f, -0.534997620f, - -0.844031895f, -0.536292979f, - -0.843208240f, -0.537587076f, - -0.842382600f, -0.538879909f, - -0.841554977f, -0.540171473f, - -0.840725375f, -0.541461766f, - -0.839893794f, -0.542750785f, - -0.839060237f, -0.544038527f, - -0.838224706f, -0.545324988f, - -0.837387202f, -0.546610167f, - -0.836547727f, -0.547894059f, - -0.835706284f, -0.549176662f, - -0.834862875f, -0.550457973f, - -0.834017501f, -0.551737988f, - -0.833170165f, -0.553016706f, - -0.832320868f, -0.554294121f, - -0.831469612f, -0.555570233f, - -0.830616400f, -0.556845037f, - -0.829761234f, -0.558118531f, - -0.828904115f, -0.559390712f, - -0.828045045f, -0.560661576f, - -0.827184027f, -0.561931121f, - -0.826321063f, -0.563199344f, - -0.825456154f, -0.564466242f, - -0.824589303f, -0.565731811f, - -0.823720511f, -0.566996049f, - -0.822849781f, -0.568258953f, - -0.821977115f, -0.569520519f, - -0.821102515f, -0.570780746f, - -0.820225983f, -0.572039629f, - -0.819347520f, -0.573297167f, - -0.818467130f, -0.574553355f, - -0.817584813f, -0.575808191f, - -0.816700573f, -0.577061673f, - -0.815814411f, -0.578313796f, - -0.814926329f, -0.579564559f, - -0.814036330f, -0.580813958f, - -0.813144415f, -0.582061990f, - -0.812250587f, -0.583308653f, - -0.811354847f, -0.584553943f, - -0.810457198f, -0.585797857f, - -0.809557642f, -0.587040394f, - -0.808656182f, -0.588281548f, - -0.807752818f, -0.589521319f, - -0.806847554f, -0.590759702f, - -0.805940391f, -0.591996695f, - -0.805031331f, -0.593232295f, - -0.804120377f, -0.594466499f, - -0.803207531f, -0.595699304f, - -0.802292796f, -0.596930708f, - -0.801376172f, -0.598160707f, - -0.800457662f, -0.599389298f, - -0.799537269f, -0.600616479f, - -0.798614995f, -0.601842247f, - -0.797690841f, -0.603066599f, - -0.796764810f, -0.604289531f, - -0.795836905f, -0.605511041f, - -0.794907126f, -0.606731127f, - -0.793975478f, -0.607949785f, - -0.793041960f, -0.609167012f, - -0.792106577f, -0.610382806f, - -0.791169330f, -0.611597164f, - -0.790230221f, -0.612810082f, - -0.789289253f, -0.614021559f, - -0.788346428f, -0.615231591f, - -0.787401747f, -0.616440175f, - -0.786455214f, -0.617647308f, - -0.785506830f, -0.618852988f, - -0.784556597f, -0.620057212f, - -0.783604519f, -0.621259977f, - -0.782650596f, -0.622461279f, - -0.781694832f, -0.623661118f, - -0.780737229f, -0.624859488f, - -0.779777788f, -0.626056388f, - -0.778816512f, -0.627251815f, - -0.777853404f, -0.628445767f, - -0.776888466f, -0.629638239f, - -0.775921699f, -0.630829230f, - -0.774953107f, -0.632018736f, - -0.773982691f, -0.633206755f, - -0.773010453f, -0.634393284f, - -0.772036397f, -0.635578320f, - -0.771060524f, -0.636761861f, - -0.770082837f, -0.637943904f, - -0.769103338f, -0.639124445f, - -0.768122029f, -0.640303482f, - -0.767138912f, -0.641481013f, - -0.766153990f, -0.642657034f, - -0.765167266f, -0.643831543f, - -0.764178741f, -0.645004537f, - -0.763188417f, -0.646176013f, - -0.762196298f, -0.647345969f, - -0.761202385f, -0.648514401f, - -0.760206682f, -0.649681307f, - -0.759209189f, -0.650846685f, - -0.758209910f, -0.652010531f, - -0.757208847f, -0.653172843f, - -0.756206001f, -0.654333618f, - -0.755201377f, -0.655492853f, - -0.754194975f, -0.656650546f, - -0.753186799f, -0.657806693f, - -0.752176850f, -0.658961293f, - -0.751165132f, -0.660114342f, - -0.750151646f, -0.661265838f, - -0.749136395f, -0.662415778f, - -0.748119380f, -0.663564159f, - -0.747100606f, -0.664710978f, - -0.746080074f, -0.665856234f, - -0.745057785f, -0.666999922f, - -0.744033744f, -0.668142041f, - -0.743007952f, -0.669282588f, - -0.741980412f, -0.670421560f, - -0.740951125f, -0.671558955f, - -0.739920095f, -0.672694769f, - -0.738887324f, -0.673829000f, - -0.737852815f, -0.674961646f, - -0.736816569f, -0.676092704f, - -0.735778589f, -0.677222170f, - -0.734738878f, -0.678350043f, - -0.733697438f, -0.679476320f, - -0.732654272f, -0.680600998f, - -0.731609381f, -0.681724074f, - -0.730562769f, -0.682845546f, - -0.729514438f, -0.683965412f, - -0.728464390f, -0.685083668f, - -0.727412629f, -0.686200312f, - -0.726359155f, -0.687315341f, - -0.725303972f, -0.688428753f, - -0.724247083f, -0.689540545f, - -0.723188489f, -0.690650714f, - -0.722128194f, -0.691759258f, - -0.721066199f, -0.692866175f, - -0.720002508f, -0.693971461f, - -0.718937122f, -0.695075114f, - -0.717870045f, -0.696177131f, - -0.716801279f, -0.697277511f, - -0.715730825f, -0.698376249f, - -0.714658688f, -0.699473345f, - -0.713584869f, -0.700568794f, - -0.712509371f, -0.701662595f, - -0.711432196f, -0.702754744f, - -0.710353347f, -0.703845241f, - -0.709272826f, -0.704934080f, - -0.708190637f, -0.706021261f, - -0.707106781f, -0.707106781f, - -0.706021261f, -0.708190637f, - -0.704934080f, -0.709272826f, - -0.703845241f, -0.710353347f, - -0.702754744f, -0.711432196f, - -0.701662595f, -0.712509371f, - -0.700568794f, -0.713584869f, - -0.699473345f, -0.714658688f, - -0.698376249f, -0.715730825f, - -0.697277511f, -0.716801279f, - -0.696177131f, -0.717870045f, - -0.695075114f, -0.718937122f, - -0.693971461f, -0.720002508f, - -0.692866175f, -0.721066199f, - -0.691759258f, -0.722128194f, - -0.690650714f, -0.723188489f, - -0.689540545f, -0.724247083f, - -0.688428753f, -0.725303972f, - -0.687315341f, -0.726359155f, - -0.686200312f, -0.727412629f, - -0.685083668f, -0.728464390f, - -0.683965412f, -0.729514438f, - -0.682845546f, -0.730562769f, - -0.681724074f, -0.731609381f, - -0.680600998f, -0.732654272f, - -0.679476320f, -0.733697438f, - -0.678350043f, -0.734738878f, - -0.677222170f, -0.735778589f, - -0.676092704f, -0.736816569f, - -0.674961646f, -0.737852815f, - -0.673829000f, -0.738887324f, - -0.672694769f, -0.739920095f, - -0.671558955f, -0.740951125f, - -0.670421560f, -0.741980412f, - -0.669282588f, -0.743007952f, - -0.668142041f, -0.744033744f, - -0.666999922f, -0.745057785f, - -0.665856234f, -0.746080074f, - -0.664710978f, -0.747100606f, - -0.663564159f, -0.748119380f, - -0.662415778f, -0.749136395f, - -0.661265838f, -0.750151646f, - -0.660114342f, -0.751165132f, - -0.658961293f, -0.752176850f, - -0.657806693f, -0.753186799f, - -0.656650546f, -0.754194975f, - -0.655492853f, -0.755201377f, - -0.654333618f, -0.756206001f, - -0.653172843f, -0.757208847f, - -0.652010531f, -0.758209910f, - -0.650846685f, -0.759209189f, - -0.649681307f, -0.760206682f, - -0.648514401f, -0.761202385f, - -0.647345969f, -0.762196298f, - -0.646176013f, -0.763188417f, - -0.645004537f, -0.764178741f, - -0.643831543f, -0.765167266f, - -0.642657034f, -0.766153990f, - -0.641481013f, -0.767138912f, - -0.640303482f, -0.768122029f, - -0.639124445f, -0.769103338f, - -0.637943904f, -0.770082837f, - -0.636761861f, -0.771060524f, - -0.635578320f, -0.772036397f, - -0.634393284f, -0.773010453f, - -0.633206755f, -0.773982691f, - -0.632018736f, -0.774953107f, - -0.630829230f, -0.775921699f, - -0.629638239f, -0.776888466f, - -0.628445767f, -0.777853404f, - -0.627251815f, -0.778816512f, - -0.626056388f, -0.779777788f, - -0.624859488f, -0.780737229f, - -0.623661118f, -0.781694832f, - -0.622461279f, -0.782650596f, - -0.621259977f, -0.783604519f, - -0.620057212f, -0.784556597f, - -0.618852988f, -0.785506830f, - -0.617647308f, -0.786455214f, - -0.616440175f, -0.787401747f, - -0.615231591f, -0.788346428f, - -0.614021559f, -0.789289253f, - -0.612810082f, -0.790230221f, - -0.611597164f, -0.791169330f, - -0.610382806f, -0.792106577f, - -0.609167012f, -0.793041960f, - -0.607949785f, -0.793975478f, - -0.606731127f, -0.794907126f, - -0.605511041f, -0.795836905f, - -0.604289531f, -0.796764810f, - -0.603066599f, -0.797690841f, - -0.601842247f, -0.798614995f, - -0.600616479f, -0.799537269f, - -0.599389298f, -0.800457662f, - -0.598160707f, -0.801376172f, - -0.596930708f, -0.802292796f, - -0.595699304f, -0.803207531f, - -0.594466499f, -0.804120377f, - -0.593232295f, -0.805031331f, - -0.591996695f, -0.805940391f, - -0.590759702f, -0.806847554f, - -0.589521319f, -0.807752818f, - -0.588281548f, -0.808656182f, - -0.587040394f, -0.809557642f, - -0.585797857f, -0.810457198f, - -0.584553943f, -0.811354847f, - -0.583308653f, -0.812250587f, - -0.582061990f, -0.813144415f, - -0.580813958f, -0.814036330f, - -0.579564559f, -0.814926329f, - -0.578313796f, -0.815814411f, - -0.577061673f, -0.816700573f, - -0.575808191f, -0.817584813f, - -0.574553355f, -0.818467130f, - -0.573297167f, -0.819347520f, - -0.572039629f, -0.820225983f, - -0.570780746f, -0.821102515f, - -0.569520519f, -0.821977115f, - -0.568258953f, -0.822849781f, - -0.566996049f, -0.823720511f, - -0.565731811f, -0.824589303f, - -0.564466242f, -0.825456154f, - -0.563199344f, -0.826321063f, - -0.561931121f, -0.827184027f, - -0.560661576f, -0.828045045f, - -0.559390712f, -0.828904115f, - -0.558118531f, -0.829761234f, - -0.556845037f, -0.830616400f, - -0.555570233f, -0.831469612f, - -0.554294121f, -0.832320868f, - -0.553016706f, -0.833170165f, - -0.551737988f, -0.834017501f, - -0.550457973f, -0.834862875f, - -0.549176662f, -0.835706284f, - -0.547894059f, -0.836547727f, - -0.546610167f, -0.837387202f, - -0.545324988f, -0.838224706f, - -0.544038527f, -0.839060237f, - -0.542750785f, -0.839893794f, - -0.541461766f, -0.840725375f, - -0.540171473f, -0.841554977f, - -0.538879909f, -0.842382600f, - -0.537587076f, -0.843208240f, - -0.536292979f, -0.844031895f, - -0.534997620f, -0.844853565f, - -0.533701002f, -0.845673247f, - -0.532403128f, -0.846490939f, - -0.531104001f, -0.847306639f, - -0.529803625f, -0.848120345f, - -0.528502002f, -0.848932055f, - -0.527199135f, -0.849741768f, - -0.525895027f, -0.850549481f, - -0.524589683f, -0.851355193f, - -0.523283103f, -0.852158902f, - -0.521975293f, -0.852960605f, - -0.520666254f, -0.853760301f, - -0.519355990f, -0.854557988f, - -0.518044504f, -0.855353665f, - -0.516731799f, -0.856147328f, - -0.515417878f, -0.856938977f, - -0.514102744f, -0.857728610f, - -0.512786401f, -0.858516224f, - -0.511468850f, -0.859301818f, - -0.510150097f, -0.860085390f, - -0.508830143f, -0.860866939f, - -0.507508991f, -0.861646461f, - -0.506186645f, -0.862423956f, - -0.504863109f, -0.863199422f, - -0.503538384f, -0.863972856f, - -0.502212474f, -0.864744258f, - -0.500885383f, -0.865513624f, - -0.499557113f, -0.866280954f, - -0.498227667f, -0.867046246f, - -0.496897049f, -0.867809497f, - -0.495565262f, -0.868570706f, - -0.494232309f, -0.869329871f, - -0.492898192f, -0.870086991f, - -0.491562916f, -0.870842063f, - -0.490226483f, -0.871595087f, - -0.488888897f, -0.872346059f, - -0.487550160f, -0.873094978f, - -0.486210276f, -0.873841843f, - -0.484869248f, -0.874586652f, - -0.483527079f, -0.875329403f, - -0.482183772f, -0.876070094f, - -0.480839331f, -0.876808724f, - -0.479493758f, -0.877545290f, - -0.478147056f, -0.878279792f, - -0.476799230f, -0.879012226f, - -0.475450282f, -0.879742593f, - -0.474100215f, -0.880470889f, - -0.472749032f, -0.881197113f, - -0.471396737f, -0.881921264f, - -0.470043332f, -0.882643340f, - -0.468688822f, -0.883363339f, - -0.467333209f, -0.884081259f, - -0.465976496f, -0.884797098f, - -0.464618686f, -0.885510856f, - -0.463259784f, -0.886222530f, - -0.461899791f, -0.886932119f, - -0.460538711f, -0.887639620f, - -0.459176548f, -0.888345033f, - -0.457813304f, -0.889048356f, - -0.456448982f, -0.889749586f, - -0.455083587f, -0.890448723f, - -0.453717121f, -0.891145765f, - -0.452349587f, -0.891840709f, - -0.450980989f, -0.892533555f, - -0.449611330f, -0.893224301f, - -0.448240612f, -0.893912945f, - -0.446868840f, -0.894599486f, - -0.445496017f, -0.895283921f, - -0.444122145f, -0.895966250f, - -0.442747228f, -0.896646470f, - -0.441371269f, -0.897324581f, - -0.439994271f, -0.898000580f, - -0.438616239f, -0.898674466f, - -0.437237174f, -0.899346237f, - -0.435857080f, -0.900015892f, - -0.434475961f, -0.900683429f, - -0.433093819f, -0.901348847f, - -0.431710658f, -0.902012144f, - -0.430326481f, -0.902673318f, - -0.428941292f, -0.903332368f, - -0.427555093f, -0.903989293f, - -0.426167889f, -0.904644091f, - -0.424779681f, -0.905296759f, - -0.423390474f, -0.905947298f, - -0.422000271f, -0.906595705f, - -0.420609074f, -0.907241978f, - -0.419216888f, -0.907886116f, - -0.417823716f, -0.908528119f, - -0.416429560f, -0.909167983f, - -0.415034424f, -0.909805708f, - -0.413638312f, -0.910441292f, - -0.412241227f, -0.911074734f, - -0.410843171f, -0.911706032f, - -0.409444149f, -0.912335185f, - -0.408044163f, -0.912962190f, - -0.406643217f, -0.913587048f, - -0.405241314f, -0.914209756f, - -0.403838458f, -0.914830312f, - -0.402434651f, -0.915448716f, - -0.401029897f, -0.916064966f, - -0.399624200f, -0.916679060f, - -0.398217562f, -0.917290997f, - -0.396809987f, -0.917900776f, - -0.395401479f, -0.918508394f, - -0.393992040f, -0.919113852f, - -0.392581674f, -0.919717146f, - -0.391170384f, -0.920318277f, - -0.389758174f, -0.920917242f, - -0.388345047f, -0.921514039f, - -0.386931006f, -0.922108669f, - -0.385516054f, -0.922701128f, - -0.384100195f, -0.923291417f, - -0.382683432f, -0.923879533f, - -0.381265769f, -0.924465474f, - -0.379847209f, -0.925049241f, - -0.378427755f, -0.925630831f, - -0.377007410f, -0.926210242f, - -0.375586178f, -0.926787474f, - -0.374164063f, -0.927362526f, - -0.372741067f, -0.927935395f, - -0.371317194f, -0.928506080f, - -0.369892447f, -0.929074581f, - -0.368466830f, -0.929640896f, - -0.367040346f, -0.930205023f, - -0.365612998f, -0.930766961f, - -0.364184790f, -0.931326709f, - -0.362755724f, -0.931884266f, - -0.361325806f, -0.932439629f, - -0.359895037f, -0.932992799f, - -0.358463421f, -0.933543773f, - -0.357030961f, -0.934092550f, - -0.355597662f, -0.934639130f, - -0.354163525f, -0.935183510f, - -0.352728556f, -0.935725689f, - -0.351292756f, -0.936265667f, - -0.349856130f, -0.936803442f, - -0.348418680f, -0.937339012f, - -0.346980411f, -0.937872376f, - -0.345541325f, -0.938403534f, - -0.344101426f, -0.938932484f, - -0.342660717f, -0.939459224f, - -0.341219202f, -0.939983753f, - -0.339776884f, -0.940506071f, - -0.338333767f, -0.941026175f, - -0.336889853f, -0.941544065f, - -0.335445147f, -0.942059740f, - -0.333999651f, -0.942573198f, - -0.332553370f, -0.943084437f, - -0.331106306f, -0.943593458f, - -0.329658463f, -0.944100258f, - -0.328209844f, -0.944604837f, - -0.326760452f, -0.945107193f, - -0.325310292f, -0.945607325f, - -0.323859367f, -0.946105232f, - -0.322407679f, -0.946600913f, - -0.320955232f, -0.947094366f, - -0.319502031f, -0.947585591f, - -0.318048077f, -0.948074586f, - -0.316593376f, -0.948561350f, - -0.315137929f, -0.949045882f, - -0.313681740f, -0.949528181f, - -0.312224814f, -0.950008245f, - -0.310767153f, -0.950486074f, - -0.309308760f, -0.950961666f, - -0.307849640f, -0.951435021f, - -0.306389795f, -0.951906137f, - -0.304929230f, -0.952375013f, - -0.303467947f, -0.952841648f, - -0.302005949f, -0.953306040f, - -0.300543241f, -0.953768190f, - -0.299079826f, -0.954228095f, - -0.297615707f, -0.954685755f, - -0.296150888f, -0.955141168f, - -0.294685372f, -0.955594334f, - -0.293219163f, -0.956045251f, - -0.291752263f, -0.956493919f, - -0.290284677f, -0.956940336f, - -0.288816408f, -0.957384501f, - -0.287347460f, -0.957826413f, - -0.285877835f, -0.958266071f, - -0.284407537f, -0.958703475f, - -0.282936570f, -0.959138622f, - -0.281464938f, -0.959571513f, - -0.279992643f, -0.960002146f, - -0.278519689f, -0.960430519f, - -0.277046080f, -0.960856633f, - -0.275571819f, -0.961280486f, - -0.274096910f, -0.961702077f, - -0.272621355f, -0.962121404f, - -0.271145160f, -0.962538468f, - -0.269668326f, -0.962953267f, - -0.268190857f, -0.963365800f, - -0.266712757f, -0.963776066f, - -0.265234030f, -0.964184064f, - -0.263754679f, -0.964589793f, - -0.262274707f, -0.964993253f, - -0.260794118f, -0.965394442f, - -0.259312915f, -0.965793359f, - -0.257831102f, -0.966190003f, - -0.256348682f, -0.966584374f, - -0.254865660f, -0.966976471f, - -0.253382037f, -0.967366292f, - -0.251897818f, -0.967753837f, - -0.250413007f, -0.968139105f, - -0.248927606f, -0.968522094f, - -0.247441619f, -0.968902805f, - -0.245955050f, -0.969281235f, - -0.244467903f, -0.969657385f, - -0.242980180f, -0.970031253f, - -0.241491885f, -0.970402839f, - -0.240003022f, -0.970772141f, - -0.238513595f, -0.971139158f, - -0.237023606f, -0.971503891f, - -0.235533059f, -0.971866337f, - -0.234041959f, -0.972226497f, - -0.232550307f, -0.972584369f, - -0.231058108f, -0.972939952f, - -0.229565366f, -0.973293246f, - -0.228072083f, -0.973644250f, - -0.226578264f, -0.973992962f, - -0.225083911f, -0.974339383f, - -0.223589029f, -0.974683511f, - -0.222093621f, -0.975025345f, - -0.220597690f, -0.975364885f, - -0.219101240f, -0.975702130f, - -0.217604275f, -0.976037079f, - -0.216106797f, -0.976369731f, - -0.214608811f, -0.976700086f, - -0.213110320f, -0.977028143f, - -0.211611327f, -0.977353900f, - -0.210111837f, -0.977677358f, - -0.208611852f, -0.977998515f, - -0.207111376f, -0.978317371f, - -0.205610413f, -0.978633924f, - -0.204108966f, -0.978948175f, - -0.202607039f, -0.979260123f, - -0.201104635f, -0.979569766f, - -0.199601758f, -0.979877104f, - -0.198098411f, -0.980182136f, - -0.196594598f, -0.980484862f, - -0.195090322f, -0.980785280f, - -0.193585587f, -0.981083391f, - -0.192080397f, -0.981379193f, - -0.190574755f, -0.981672686f, - -0.189068664f, -0.981963869f, - -0.187562129f, -0.982252741f, - -0.186055152f, -0.982539302f, - -0.184547737f, -0.982823551f, - -0.183039888f, -0.983105487f, - -0.181531608f, -0.983385110f, - -0.180022901f, -0.983662419f, - -0.178513771f, -0.983937413f, - -0.177004220f, -0.984210092f, - -0.175494253f, -0.984480455f, - -0.173983873f, -0.984748502f, - -0.172473084f, -0.985014231f, - -0.170961889f, -0.985277642f, - -0.169450291f, -0.985538735f, - -0.167938295f, -0.985797509f, - -0.166425904f, -0.986053963f, - -0.164913120f, -0.986308097f, - -0.163399949f, -0.986559910f, - -0.161886394f, -0.986809402f, - -0.160372457f, -0.987056571f, - -0.158858143f, -0.987301418f, - -0.157343456f, -0.987543942f, - -0.155828398f, -0.987784142f, - -0.154312973f, -0.988022017f, - -0.152797185f, -0.988257568f, - -0.151281038f, -0.988490793f, - -0.149764535f, -0.988721692f, - -0.148247679f, -0.988950265f, - -0.146730474f, -0.989176510f, - -0.145212925f, -0.989400428f, - -0.143695033f, -0.989622017f, - -0.142176804f, -0.989841278f, - -0.140658239f, -0.990058210f, - -0.139139344f, -0.990272812f, - -0.137620122f, -0.990485084f, - -0.136100575f, -0.990695025f, - -0.134580709f, -0.990902635f, - -0.133060525f, -0.991107914f, - -0.131540029f, -0.991310860f, - -0.130019223f, -0.991511473f, - -0.128498111f, -0.991709754f, - -0.126976696f, -0.991905700f, - -0.125454983f, -0.992099313f, - -0.123932975f, -0.992290591f, - -0.122410675f, -0.992479535f, - -0.120888087f, -0.992666142f, - -0.119365215f, -0.992850414f, - -0.117842062f, -0.993032350f, - -0.116318631f, -0.993211949f, - -0.114794927f, -0.993389211f, - -0.113270952f, -0.993564136f, - -0.111746711f, -0.993736722f, - -0.110222207f, -0.993906970f, - -0.108697444f, -0.994074879f, - -0.107172425f, -0.994240449f, - -0.105647154f, -0.994403680f, - -0.104121634f, -0.994564571f, - -0.102595869f, -0.994723121f, - -0.101069863f, -0.994879331f, - -0.099543619f, -0.995033199f, - -0.098017140f, -0.995184727f, - -0.096490431f, -0.995333912f, - -0.094963495f, -0.995480755f, - -0.093436336f, -0.995625256f, - -0.091908956f, -0.995767414f, - -0.090381361f, -0.995907229f, - -0.088853553f, -0.996044701f, - -0.087325535f, -0.996179829f, - -0.085797312f, -0.996312612f, - -0.084268888f, -0.996443051f, - -0.082740265f, -0.996571146f, - -0.081211447f, -0.996696895f, - -0.079682438f, -0.996820299f, - -0.078153242f, -0.996941358f, - -0.076623861f, -0.997060070f, - -0.075094301f, -0.997176437f, - -0.073564564f, -0.997290457f, - -0.072034653f, -0.997402130f, - -0.070504573f, -0.997511456f, - -0.068974328f, -0.997618435f, - -0.067443920f, -0.997723067f, - -0.065913353f, -0.997825350f, - -0.064382631f, -0.997925286f, - -0.062851758f, -0.998022874f, - -0.061320736f, -0.998118113f, - -0.059789571f, -0.998211003f, - -0.058258265f, -0.998301545f, - -0.056726821f, -0.998389737f, - -0.055195244f, -0.998475581f, - -0.053663538f, -0.998559074f, - -0.052131705f, -0.998640218f, - -0.050599749f, -0.998719012f, - -0.049067674f, -0.998795456f, - -0.047535484f, -0.998869550f, - -0.046003182f, -0.998941293f, - -0.044470772f, -0.999010686f, - -0.042938257f, -0.999077728f, - -0.041405641f, -0.999142419f, - -0.039872928f, -0.999204759f, - -0.038340120f, -0.999264747f, - -0.036807223f, -0.999322385f, - -0.035274239f, -0.999377670f, - -0.033741172f, -0.999430605f, - -0.032208025f, -0.999481187f, - -0.030674803f, -0.999529418f, - -0.029141509f, -0.999575296f, - -0.027608146f, -0.999618822f, - -0.026074718f, -0.999659997f, - -0.024541229f, -0.999698819f, - -0.023007681f, -0.999735288f, - -0.021474080f, -0.999769405f, - -0.019940429f, -0.999801170f, - -0.018406730f, -0.999830582f, - -0.016872988f, -0.999857641f, - -0.015339206f, -0.999882347f, - -0.013805389f, -0.999904701f, - -0.012271538f, -0.999924702f, - -0.010737659f, -0.999942350f, - -0.009203755f, -0.999957645f, - -0.007669829f, -0.999970586f, - -0.006135885f, -0.999981175f, - -0.004601926f, -0.999989411f, - -0.003067957f, -0.999995294f, - -0.001533980f, -0.999998823f, - -0.000000000f, -1.000000000f, - 0.001533980f, -0.999998823f, - 0.003067957f, -0.999995294f, - 0.004601926f, -0.999989411f, - 0.006135885f, -0.999981175f, - 0.007669829f, -0.999970586f, - 0.009203755f, -0.999957645f, - 0.010737659f, -0.999942350f, - 0.012271538f, -0.999924702f, - 0.013805389f, -0.999904701f, - 0.015339206f, -0.999882347f, - 0.016872988f, -0.999857641f, - 0.018406730f, -0.999830582f, - 0.019940429f, -0.999801170f, - 0.021474080f, -0.999769405f, - 0.023007681f, -0.999735288f, - 0.024541229f, -0.999698819f, - 0.026074718f, -0.999659997f, - 0.027608146f, -0.999618822f, - 0.029141509f, -0.999575296f, - 0.030674803f, -0.999529418f, - 0.032208025f, -0.999481187f, - 0.033741172f, -0.999430605f, - 0.035274239f, -0.999377670f, - 0.036807223f, -0.999322385f, - 0.038340120f, -0.999264747f, - 0.039872928f, -0.999204759f, - 0.041405641f, -0.999142419f, - 0.042938257f, -0.999077728f, - 0.044470772f, -0.999010686f, - 0.046003182f, -0.998941293f, - 0.047535484f, -0.998869550f, - 0.049067674f, -0.998795456f, - 0.050599749f, -0.998719012f, - 0.052131705f, -0.998640218f, - 0.053663538f, -0.998559074f, - 0.055195244f, -0.998475581f, - 0.056726821f, -0.998389737f, - 0.058258265f, -0.998301545f, - 0.059789571f, -0.998211003f, - 0.061320736f, -0.998118113f, - 0.062851758f, -0.998022874f, - 0.064382631f, -0.997925286f, - 0.065913353f, -0.997825350f, - 0.067443920f, -0.997723067f, - 0.068974328f, -0.997618435f, - 0.070504573f, -0.997511456f, - 0.072034653f, -0.997402130f, - 0.073564564f, -0.997290457f, - 0.075094301f, -0.997176437f, - 0.076623861f, -0.997060070f, - 0.078153242f, -0.996941358f, - 0.079682438f, -0.996820299f, - 0.081211447f, -0.996696895f, - 0.082740265f, -0.996571146f, - 0.084268888f, -0.996443051f, - 0.085797312f, -0.996312612f, - 0.087325535f, -0.996179829f, - 0.088853553f, -0.996044701f, - 0.090381361f, -0.995907229f, - 0.091908956f, -0.995767414f, - 0.093436336f, -0.995625256f, - 0.094963495f, -0.995480755f, - 0.096490431f, -0.995333912f, - 0.098017140f, -0.995184727f, - 0.099543619f, -0.995033199f, - 0.101069863f, -0.994879331f, - 0.102595869f, -0.994723121f, - 0.104121634f, -0.994564571f, - 0.105647154f, -0.994403680f, - 0.107172425f, -0.994240449f, - 0.108697444f, -0.994074879f, - 0.110222207f, -0.993906970f, - 0.111746711f, -0.993736722f, - 0.113270952f, -0.993564136f, - 0.114794927f, -0.993389211f, - 0.116318631f, -0.993211949f, - 0.117842062f, -0.993032350f, - 0.119365215f, -0.992850414f, - 0.120888087f, -0.992666142f, - 0.122410675f, -0.992479535f, - 0.123932975f, -0.992290591f, - 0.125454983f, -0.992099313f, - 0.126976696f, -0.991905700f, - 0.128498111f, -0.991709754f, - 0.130019223f, -0.991511473f, - 0.131540029f, -0.991310860f, - 0.133060525f, -0.991107914f, - 0.134580709f, -0.990902635f, - 0.136100575f, -0.990695025f, - 0.137620122f, -0.990485084f, - 0.139139344f, -0.990272812f, - 0.140658239f, -0.990058210f, - 0.142176804f, -0.989841278f, - 0.143695033f, -0.989622017f, - 0.145212925f, -0.989400428f, - 0.146730474f, -0.989176510f, - 0.148247679f, -0.988950265f, - 0.149764535f, -0.988721692f, - 0.151281038f, -0.988490793f, - 0.152797185f, -0.988257568f, - 0.154312973f, -0.988022017f, - 0.155828398f, -0.987784142f, - 0.157343456f, -0.987543942f, - 0.158858143f, -0.987301418f, - 0.160372457f, -0.987056571f, - 0.161886394f, -0.986809402f, - 0.163399949f, -0.986559910f, - 0.164913120f, -0.986308097f, - 0.166425904f, -0.986053963f, - 0.167938295f, -0.985797509f, - 0.169450291f, -0.985538735f, - 0.170961889f, -0.985277642f, - 0.172473084f, -0.985014231f, - 0.173983873f, -0.984748502f, - 0.175494253f, -0.984480455f, - 0.177004220f, -0.984210092f, - 0.178513771f, -0.983937413f, - 0.180022901f, -0.983662419f, - 0.181531608f, -0.983385110f, - 0.183039888f, -0.983105487f, - 0.184547737f, -0.982823551f, - 0.186055152f, -0.982539302f, - 0.187562129f, -0.982252741f, - 0.189068664f, -0.981963869f, - 0.190574755f, -0.981672686f, - 0.192080397f, -0.981379193f, - 0.193585587f, -0.981083391f, - 0.195090322f, -0.980785280f, - 0.196594598f, -0.980484862f, - 0.198098411f, -0.980182136f, - 0.199601758f, -0.979877104f, - 0.201104635f, -0.979569766f, - 0.202607039f, -0.979260123f, - 0.204108966f, -0.978948175f, - 0.205610413f, -0.978633924f, - 0.207111376f, -0.978317371f, - 0.208611852f, -0.977998515f, - 0.210111837f, -0.977677358f, - 0.211611327f, -0.977353900f, - 0.213110320f, -0.977028143f, - 0.214608811f, -0.976700086f, - 0.216106797f, -0.976369731f, - 0.217604275f, -0.976037079f, - 0.219101240f, -0.975702130f, - 0.220597690f, -0.975364885f, - 0.222093621f, -0.975025345f, - 0.223589029f, -0.974683511f, - 0.225083911f, -0.974339383f, - 0.226578264f, -0.973992962f, - 0.228072083f, -0.973644250f, - 0.229565366f, -0.973293246f, - 0.231058108f, -0.972939952f, - 0.232550307f, -0.972584369f, - 0.234041959f, -0.972226497f, - 0.235533059f, -0.971866337f, - 0.237023606f, -0.971503891f, - 0.238513595f, -0.971139158f, - 0.240003022f, -0.970772141f, - 0.241491885f, -0.970402839f, - 0.242980180f, -0.970031253f, - 0.244467903f, -0.969657385f, - 0.245955050f, -0.969281235f, - 0.247441619f, -0.968902805f, - 0.248927606f, -0.968522094f, - 0.250413007f, -0.968139105f, - 0.251897818f, -0.967753837f, - 0.253382037f, -0.967366292f, - 0.254865660f, -0.966976471f, - 0.256348682f, -0.966584374f, - 0.257831102f, -0.966190003f, - 0.259312915f, -0.965793359f, - 0.260794118f, -0.965394442f, - 0.262274707f, -0.964993253f, - 0.263754679f, -0.964589793f, - 0.265234030f, -0.964184064f, - 0.266712757f, -0.963776066f, - 0.268190857f, -0.963365800f, - 0.269668326f, -0.962953267f, - 0.271145160f, -0.962538468f, - 0.272621355f, -0.962121404f, - 0.274096910f, -0.961702077f, - 0.275571819f, -0.961280486f, - 0.277046080f, -0.960856633f, - 0.278519689f, -0.960430519f, - 0.279992643f, -0.960002146f, - 0.281464938f, -0.959571513f, - 0.282936570f, -0.959138622f, - 0.284407537f, -0.958703475f, - 0.285877835f, -0.958266071f, - 0.287347460f, -0.957826413f, - 0.288816408f, -0.957384501f, - 0.290284677f, -0.956940336f, - 0.291752263f, -0.956493919f, - 0.293219163f, -0.956045251f, - 0.294685372f, -0.955594334f, - 0.296150888f, -0.955141168f, - 0.297615707f, -0.954685755f, - 0.299079826f, -0.954228095f, - 0.300543241f, -0.953768190f, - 0.302005949f, -0.953306040f, - 0.303467947f, -0.952841648f, - 0.304929230f, -0.952375013f, - 0.306389795f, -0.951906137f, - 0.307849640f, -0.951435021f, - 0.309308760f, -0.950961666f, - 0.310767153f, -0.950486074f, - 0.312224814f, -0.950008245f, - 0.313681740f, -0.949528181f, - 0.315137929f, -0.949045882f, - 0.316593376f, -0.948561350f, - 0.318048077f, -0.948074586f, - 0.319502031f, -0.947585591f, - 0.320955232f, -0.947094366f, - 0.322407679f, -0.946600913f, - 0.323859367f, -0.946105232f, - 0.325310292f, -0.945607325f, - 0.326760452f, -0.945107193f, - 0.328209844f, -0.944604837f, - 0.329658463f, -0.944100258f, - 0.331106306f, -0.943593458f, - 0.332553370f, -0.943084437f, - 0.333999651f, -0.942573198f, - 0.335445147f, -0.942059740f, - 0.336889853f, -0.941544065f, - 0.338333767f, -0.941026175f, - 0.339776884f, -0.940506071f, - 0.341219202f, -0.939983753f, - 0.342660717f, -0.939459224f, - 0.344101426f, -0.938932484f, - 0.345541325f, -0.938403534f, - 0.346980411f, -0.937872376f, - 0.348418680f, -0.937339012f, - 0.349856130f, -0.936803442f, - 0.351292756f, -0.936265667f, - 0.352728556f, -0.935725689f, - 0.354163525f, -0.935183510f, - 0.355597662f, -0.934639130f, - 0.357030961f, -0.934092550f, - 0.358463421f, -0.933543773f, - 0.359895037f, -0.932992799f, - 0.361325806f, -0.932439629f, - 0.362755724f, -0.931884266f, - 0.364184790f, -0.931326709f, - 0.365612998f, -0.930766961f, - 0.367040346f, -0.930205023f, - 0.368466830f, -0.929640896f, - 0.369892447f, -0.929074581f, - 0.371317194f, -0.928506080f, - 0.372741067f, -0.927935395f, - 0.374164063f, -0.927362526f, - 0.375586178f, -0.926787474f, - 0.377007410f, -0.926210242f, - 0.378427755f, -0.925630831f, - 0.379847209f, -0.925049241f, - 0.381265769f, -0.924465474f, - 0.382683432f, -0.923879533f, - 0.384100195f, -0.923291417f, - 0.385516054f, -0.922701128f, - 0.386931006f, -0.922108669f, - 0.388345047f, -0.921514039f, - 0.389758174f, -0.920917242f, - 0.391170384f, -0.920318277f, - 0.392581674f, -0.919717146f, - 0.393992040f, -0.919113852f, - 0.395401479f, -0.918508394f, - 0.396809987f, -0.917900776f, - 0.398217562f, -0.917290997f, - 0.399624200f, -0.916679060f, - 0.401029897f, -0.916064966f, - 0.402434651f, -0.915448716f, - 0.403838458f, -0.914830312f, - 0.405241314f, -0.914209756f, - 0.406643217f, -0.913587048f, - 0.408044163f, -0.912962190f, - 0.409444149f, -0.912335185f, - 0.410843171f, -0.911706032f, - 0.412241227f, -0.911074734f, - 0.413638312f, -0.910441292f, - 0.415034424f, -0.909805708f, - 0.416429560f, -0.909167983f, - 0.417823716f, -0.908528119f, - 0.419216888f, -0.907886116f, - 0.420609074f, -0.907241978f, - 0.422000271f, -0.906595705f, - 0.423390474f, -0.905947298f, - 0.424779681f, -0.905296759f, - 0.426167889f, -0.904644091f, - 0.427555093f, -0.903989293f, - 0.428941292f, -0.903332368f, - 0.430326481f, -0.902673318f, - 0.431710658f, -0.902012144f, - 0.433093819f, -0.901348847f, - 0.434475961f, -0.900683429f, - 0.435857080f, -0.900015892f, - 0.437237174f, -0.899346237f, - 0.438616239f, -0.898674466f, - 0.439994271f, -0.898000580f, - 0.441371269f, -0.897324581f, - 0.442747228f, -0.896646470f, - 0.444122145f, -0.895966250f, - 0.445496017f, -0.895283921f, - 0.446868840f, -0.894599486f, - 0.448240612f, -0.893912945f, - 0.449611330f, -0.893224301f, - 0.450980989f, -0.892533555f, - 0.452349587f, -0.891840709f, - 0.453717121f, -0.891145765f, - 0.455083587f, -0.890448723f, - 0.456448982f, -0.889749586f, - 0.457813304f, -0.889048356f, - 0.459176548f, -0.888345033f, - 0.460538711f, -0.887639620f, - 0.461899791f, -0.886932119f, - 0.463259784f, -0.886222530f, - 0.464618686f, -0.885510856f, - 0.465976496f, -0.884797098f, - 0.467333209f, -0.884081259f, - 0.468688822f, -0.883363339f, - 0.470043332f, -0.882643340f, - 0.471396737f, -0.881921264f, - 0.472749032f, -0.881197113f, - 0.474100215f, -0.880470889f, - 0.475450282f, -0.879742593f, - 0.476799230f, -0.879012226f, - 0.478147056f, -0.878279792f, - 0.479493758f, -0.877545290f, - 0.480839331f, -0.876808724f, - 0.482183772f, -0.876070094f, - 0.483527079f, -0.875329403f, - 0.484869248f, -0.874586652f, - 0.486210276f, -0.873841843f, - 0.487550160f, -0.873094978f, - 0.488888897f, -0.872346059f, - 0.490226483f, -0.871595087f, - 0.491562916f, -0.870842063f, - 0.492898192f, -0.870086991f, - 0.494232309f, -0.869329871f, - 0.495565262f, -0.868570706f, - 0.496897049f, -0.867809497f, - 0.498227667f, -0.867046246f, - 0.499557113f, -0.866280954f, - 0.500885383f, -0.865513624f, - 0.502212474f, -0.864744258f, - 0.503538384f, -0.863972856f, - 0.504863109f, -0.863199422f, - 0.506186645f, -0.862423956f, - 0.507508991f, -0.861646461f, - 0.508830143f, -0.860866939f, - 0.510150097f, -0.860085390f, - 0.511468850f, -0.859301818f, - 0.512786401f, -0.858516224f, - 0.514102744f, -0.857728610f, - 0.515417878f, -0.856938977f, - 0.516731799f, -0.856147328f, - 0.518044504f, -0.855353665f, - 0.519355990f, -0.854557988f, - 0.520666254f, -0.853760301f, - 0.521975293f, -0.852960605f, - 0.523283103f, -0.852158902f, - 0.524589683f, -0.851355193f, - 0.525895027f, -0.850549481f, - 0.527199135f, -0.849741768f, - 0.528502002f, -0.848932055f, - 0.529803625f, -0.848120345f, - 0.531104001f, -0.847306639f, - 0.532403128f, -0.846490939f, - 0.533701002f, -0.845673247f, - 0.534997620f, -0.844853565f, - 0.536292979f, -0.844031895f, - 0.537587076f, -0.843208240f, - 0.538879909f, -0.842382600f, - 0.540171473f, -0.841554977f, - 0.541461766f, -0.840725375f, - 0.542750785f, -0.839893794f, - 0.544038527f, -0.839060237f, - 0.545324988f, -0.838224706f, - 0.546610167f, -0.837387202f, - 0.547894059f, -0.836547727f, - 0.549176662f, -0.835706284f, - 0.550457973f, -0.834862875f, - 0.551737988f, -0.834017501f, - 0.553016706f, -0.833170165f, - 0.554294121f, -0.832320868f, - 0.555570233f, -0.831469612f, - 0.556845037f, -0.830616400f, - 0.558118531f, -0.829761234f, - 0.559390712f, -0.828904115f, - 0.560661576f, -0.828045045f, - 0.561931121f, -0.827184027f, - 0.563199344f, -0.826321063f, - 0.564466242f, -0.825456154f, - 0.565731811f, -0.824589303f, - 0.566996049f, -0.823720511f, - 0.568258953f, -0.822849781f, - 0.569520519f, -0.821977115f, - 0.570780746f, -0.821102515f, - 0.572039629f, -0.820225983f, - 0.573297167f, -0.819347520f, - 0.574553355f, -0.818467130f, - 0.575808191f, -0.817584813f, - 0.577061673f, -0.816700573f, - 0.578313796f, -0.815814411f, - 0.579564559f, -0.814926329f, - 0.580813958f, -0.814036330f, - 0.582061990f, -0.813144415f, - 0.583308653f, -0.812250587f, - 0.584553943f, -0.811354847f, - 0.585797857f, -0.810457198f, - 0.587040394f, -0.809557642f, - 0.588281548f, -0.808656182f, - 0.589521319f, -0.807752818f, - 0.590759702f, -0.806847554f, - 0.591996695f, -0.805940391f, - 0.593232295f, -0.805031331f, - 0.594466499f, -0.804120377f, - 0.595699304f, -0.803207531f, - 0.596930708f, -0.802292796f, - 0.598160707f, -0.801376172f, - 0.599389298f, -0.800457662f, - 0.600616479f, -0.799537269f, - 0.601842247f, -0.798614995f, - 0.603066599f, -0.797690841f, - 0.604289531f, -0.796764810f, - 0.605511041f, -0.795836905f, - 0.606731127f, -0.794907126f, - 0.607949785f, -0.793975478f, - 0.609167012f, -0.793041960f, - 0.610382806f, -0.792106577f, - 0.611597164f, -0.791169330f, - 0.612810082f, -0.790230221f, - 0.614021559f, -0.789289253f, - 0.615231591f, -0.788346428f, - 0.616440175f, -0.787401747f, - 0.617647308f, -0.786455214f, - 0.618852988f, -0.785506830f, - 0.620057212f, -0.784556597f, - 0.621259977f, -0.783604519f, - 0.622461279f, -0.782650596f, - 0.623661118f, -0.781694832f, - 0.624859488f, -0.780737229f, - 0.626056388f, -0.779777788f, - 0.627251815f, -0.778816512f, - 0.628445767f, -0.777853404f, - 0.629638239f, -0.776888466f, - 0.630829230f, -0.775921699f, - 0.632018736f, -0.774953107f, - 0.633206755f, -0.773982691f, - 0.634393284f, -0.773010453f, - 0.635578320f, -0.772036397f, - 0.636761861f, -0.771060524f, - 0.637943904f, -0.770082837f, - 0.639124445f, -0.769103338f, - 0.640303482f, -0.768122029f, - 0.641481013f, -0.767138912f, - 0.642657034f, -0.766153990f, - 0.643831543f, -0.765167266f, - 0.645004537f, -0.764178741f, - 0.646176013f, -0.763188417f, - 0.647345969f, -0.762196298f, - 0.648514401f, -0.761202385f, - 0.649681307f, -0.760206682f, - 0.650846685f, -0.759209189f, - 0.652010531f, -0.758209910f, - 0.653172843f, -0.757208847f, - 0.654333618f, -0.756206001f, - 0.655492853f, -0.755201377f, - 0.656650546f, -0.754194975f, - 0.657806693f, -0.753186799f, - 0.658961293f, -0.752176850f, - 0.660114342f, -0.751165132f, - 0.661265838f, -0.750151646f, - 0.662415778f, -0.749136395f, - 0.663564159f, -0.748119380f, - 0.664710978f, -0.747100606f, - 0.665856234f, -0.746080074f, - 0.666999922f, -0.745057785f, - 0.668142041f, -0.744033744f, - 0.669282588f, -0.743007952f, - 0.670421560f, -0.741980412f, - 0.671558955f, -0.740951125f, - 0.672694769f, -0.739920095f, - 0.673829000f, -0.738887324f, - 0.674961646f, -0.737852815f, - 0.676092704f, -0.736816569f, - 0.677222170f, -0.735778589f, - 0.678350043f, -0.734738878f, - 0.679476320f, -0.733697438f, - 0.680600998f, -0.732654272f, - 0.681724074f, -0.731609381f, - 0.682845546f, -0.730562769f, - 0.683965412f, -0.729514438f, - 0.685083668f, -0.728464390f, - 0.686200312f, -0.727412629f, - 0.687315341f, -0.726359155f, - 0.688428753f, -0.725303972f, - 0.689540545f, -0.724247083f, - 0.690650714f, -0.723188489f, - 0.691759258f, -0.722128194f, - 0.692866175f, -0.721066199f, - 0.693971461f, -0.720002508f, - 0.695075114f, -0.718937122f, - 0.696177131f, -0.717870045f, - 0.697277511f, -0.716801279f, - 0.698376249f, -0.715730825f, - 0.699473345f, -0.714658688f, - 0.700568794f, -0.713584869f, - 0.701662595f, -0.712509371f, - 0.702754744f, -0.711432196f, - 0.703845241f, -0.710353347f, - 0.704934080f, -0.709272826f, - 0.706021261f, -0.708190637f, - 0.707106781f, -0.707106781f, - 0.708190637f, -0.706021261f, - 0.709272826f, -0.704934080f, - 0.710353347f, -0.703845241f, - 0.711432196f, -0.702754744f, - 0.712509371f, -0.701662595f, - 0.713584869f, -0.700568794f, - 0.714658688f, -0.699473345f, - 0.715730825f, -0.698376249f, - 0.716801279f, -0.697277511f, - 0.717870045f, -0.696177131f, - 0.718937122f, -0.695075114f, - 0.720002508f, -0.693971461f, - 0.721066199f, -0.692866175f, - 0.722128194f, -0.691759258f, - 0.723188489f, -0.690650714f, - 0.724247083f, -0.689540545f, - 0.725303972f, -0.688428753f, - 0.726359155f, -0.687315341f, - 0.727412629f, -0.686200312f, - 0.728464390f, -0.685083668f, - 0.729514438f, -0.683965412f, - 0.730562769f, -0.682845546f, - 0.731609381f, -0.681724074f, - 0.732654272f, -0.680600998f, - 0.733697438f, -0.679476320f, - 0.734738878f, -0.678350043f, - 0.735778589f, -0.677222170f, - 0.736816569f, -0.676092704f, - 0.737852815f, -0.674961646f, - 0.738887324f, -0.673829000f, - 0.739920095f, -0.672694769f, - 0.740951125f, -0.671558955f, - 0.741980412f, -0.670421560f, - 0.743007952f, -0.669282588f, - 0.744033744f, -0.668142041f, - 0.745057785f, -0.666999922f, - 0.746080074f, -0.665856234f, - 0.747100606f, -0.664710978f, - 0.748119380f, -0.663564159f, - 0.749136395f, -0.662415778f, - 0.750151646f, -0.661265838f, - 0.751165132f, -0.660114342f, - 0.752176850f, -0.658961293f, - 0.753186799f, -0.657806693f, - 0.754194975f, -0.656650546f, - 0.755201377f, -0.655492853f, - 0.756206001f, -0.654333618f, - 0.757208847f, -0.653172843f, - 0.758209910f, -0.652010531f, - 0.759209189f, -0.650846685f, - 0.760206682f, -0.649681307f, - 0.761202385f, -0.648514401f, - 0.762196298f, -0.647345969f, - 0.763188417f, -0.646176013f, - 0.764178741f, -0.645004537f, - 0.765167266f, -0.643831543f, - 0.766153990f, -0.642657034f, - 0.767138912f, -0.641481013f, - 0.768122029f, -0.640303482f, - 0.769103338f, -0.639124445f, - 0.770082837f, -0.637943904f, - 0.771060524f, -0.636761861f, - 0.772036397f, -0.635578320f, - 0.773010453f, -0.634393284f, - 0.773982691f, -0.633206755f, - 0.774953107f, -0.632018736f, - 0.775921699f, -0.630829230f, - 0.776888466f, -0.629638239f, - 0.777853404f, -0.628445767f, - 0.778816512f, -0.627251815f, - 0.779777788f, -0.626056388f, - 0.780737229f, -0.624859488f, - 0.781694832f, -0.623661118f, - 0.782650596f, -0.622461279f, - 0.783604519f, -0.621259977f, - 0.784556597f, -0.620057212f, - 0.785506830f, -0.618852988f, - 0.786455214f, -0.617647308f, - 0.787401747f, -0.616440175f, - 0.788346428f, -0.615231591f, - 0.789289253f, -0.614021559f, - 0.790230221f, -0.612810082f, - 0.791169330f, -0.611597164f, - 0.792106577f, -0.610382806f, - 0.793041960f, -0.609167012f, - 0.793975478f, -0.607949785f, - 0.794907126f, -0.606731127f, - 0.795836905f, -0.605511041f, - 0.796764810f, -0.604289531f, - 0.797690841f, -0.603066599f, - 0.798614995f, -0.601842247f, - 0.799537269f, -0.600616479f, - 0.800457662f, -0.599389298f, - 0.801376172f, -0.598160707f, - 0.802292796f, -0.596930708f, - 0.803207531f, -0.595699304f, - 0.804120377f, -0.594466499f, - 0.805031331f, -0.593232295f, - 0.805940391f, -0.591996695f, - 0.806847554f, -0.590759702f, - 0.807752818f, -0.589521319f, - 0.808656182f, -0.588281548f, - 0.809557642f, -0.587040394f, - 0.810457198f, -0.585797857f, - 0.811354847f, -0.584553943f, - 0.812250587f, -0.583308653f, - 0.813144415f, -0.582061990f, - 0.814036330f, -0.580813958f, - 0.814926329f, -0.579564559f, - 0.815814411f, -0.578313796f, - 0.816700573f, -0.577061673f, - 0.817584813f, -0.575808191f, - 0.818467130f, -0.574553355f, - 0.819347520f, -0.573297167f, - 0.820225983f, -0.572039629f, - 0.821102515f, -0.570780746f, - 0.821977115f, -0.569520519f, - 0.822849781f, -0.568258953f, - 0.823720511f, -0.566996049f, - 0.824589303f, -0.565731811f, - 0.825456154f, -0.564466242f, - 0.826321063f, -0.563199344f, - 0.827184027f, -0.561931121f, - 0.828045045f, -0.560661576f, - 0.828904115f, -0.559390712f, - 0.829761234f, -0.558118531f, - 0.830616400f, -0.556845037f, - 0.831469612f, -0.555570233f, - 0.832320868f, -0.554294121f, - 0.833170165f, -0.553016706f, - 0.834017501f, -0.551737988f, - 0.834862875f, -0.550457973f, - 0.835706284f, -0.549176662f, - 0.836547727f, -0.547894059f, - 0.837387202f, -0.546610167f, - 0.838224706f, -0.545324988f, - 0.839060237f, -0.544038527f, - 0.839893794f, -0.542750785f, - 0.840725375f, -0.541461766f, - 0.841554977f, -0.540171473f, - 0.842382600f, -0.538879909f, - 0.843208240f, -0.537587076f, - 0.844031895f, -0.536292979f, - 0.844853565f, -0.534997620f, - 0.845673247f, -0.533701002f, - 0.846490939f, -0.532403128f, - 0.847306639f, -0.531104001f, - 0.848120345f, -0.529803625f, - 0.848932055f, -0.528502002f, - 0.849741768f, -0.527199135f, - 0.850549481f, -0.525895027f, - 0.851355193f, -0.524589683f, - 0.852158902f, -0.523283103f, - 0.852960605f, -0.521975293f, - 0.853760301f, -0.520666254f, - 0.854557988f, -0.519355990f, - 0.855353665f, -0.518044504f, - 0.856147328f, -0.516731799f, - 0.856938977f, -0.515417878f, - 0.857728610f, -0.514102744f, - 0.858516224f, -0.512786401f, - 0.859301818f, -0.511468850f, - 0.860085390f, -0.510150097f, - 0.860866939f, -0.508830143f, - 0.861646461f, -0.507508991f, - 0.862423956f, -0.506186645f, - 0.863199422f, -0.504863109f, - 0.863972856f, -0.503538384f, - 0.864744258f, -0.502212474f, - 0.865513624f, -0.500885383f, - 0.866280954f, -0.499557113f, - 0.867046246f, -0.498227667f, - 0.867809497f, -0.496897049f, - 0.868570706f, -0.495565262f, - 0.869329871f, -0.494232309f, - 0.870086991f, -0.492898192f, - 0.870842063f, -0.491562916f, - 0.871595087f, -0.490226483f, - 0.872346059f, -0.488888897f, - 0.873094978f, -0.487550160f, - 0.873841843f, -0.486210276f, - 0.874586652f, -0.484869248f, - 0.875329403f, -0.483527079f, - 0.876070094f, -0.482183772f, - 0.876808724f, -0.480839331f, - 0.877545290f, -0.479493758f, - 0.878279792f, -0.478147056f, - 0.879012226f, -0.476799230f, - 0.879742593f, -0.475450282f, - 0.880470889f, -0.474100215f, - 0.881197113f, -0.472749032f, - 0.881921264f, -0.471396737f, - 0.882643340f, -0.470043332f, - 0.883363339f, -0.468688822f, - 0.884081259f, -0.467333209f, - 0.884797098f, -0.465976496f, - 0.885510856f, -0.464618686f, - 0.886222530f, -0.463259784f, - 0.886932119f, -0.461899791f, - 0.887639620f, -0.460538711f, - 0.888345033f, -0.459176548f, - 0.889048356f, -0.457813304f, - 0.889749586f, -0.456448982f, - 0.890448723f, -0.455083587f, - 0.891145765f, -0.453717121f, - 0.891840709f, -0.452349587f, - 0.892533555f, -0.450980989f, - 0.893224301f, -0.449611330f, - 0.893912945f, -0.448240612f, - 0.894599486f, -0.446868840f, - 0.895283921f, -0.445496017f, - 0.895966250f, -0.444122145f, - 0.896646470f, -0.442747228f, - 0.897324581f, -0.441371269f, - 0.898000580f, -0.439994271f, - 0.898674466f, -0.438616239f, - 0.899346237f, -0.437237174f, - 0.900015892f, -0.435857080f, - 0.900683429f, -0.434475961f, - 0.901348847f, -0.433093819f, - 0.902012144f, -0.431710658f, - 0.902673318f, -0.430326481f, - 0.903332368f, -0.428941292f, - 0.903989293f, -0.427555093f, - 0.904644091f, -0.426167889f, - 0.905296759f, -0.424779681f, - 0.905947298f, -0.423390474f, - 0.906595705f, -0.422000271f, - 0.907241978f, -0.420609074f, - 0.907886116f, -0.419216888f, - 0.908528119f, -0.417823716f, - 0.909167983f, -0.416429560f, - 0.909805708f, -0.415034424f, - 0.910441292f, -0.413638312f, - 0.911074734f, -0.412241227f, - 0.911706032f, -0.410843171f, - 0.912335185f, -0.409444149f, - 0.912962190f, -0.408044163f, - 0.913587048f, -0.406643217f, - 0.914209756f, -0.405241314f, - 0.914830312f, -0.403838458f, - 0.915448716f, -0.402434651f, - 0.916064966f, -0.401029897f, - 0.916679060f, -0.399624200f, - 0.917290997f, -0.398217562f, - 0.917900776f, -0.396809987f, - 0.918508394f, -0.395401479f, - 0.919113852f, -0.393992040f, - 0.919717146f, -0.392581674f, - 0.920318277f, -0.391170384f, - 0.920917242f, -0.389758174f, - 0.921514039f, -0.388345047f, - 0.922108669f, -0.386931006f, - 0.922701128f, -0.385516054f, - 0.923291417f, -0.384100195f, - 0.923879533f, -0.382683432f, - 0.924465474f, -0.381265769f, - 0.925049241f, -0.379847209f, - 0.925630831f, -0.378427755f, - 0.926210242f, -0.377007410f, - 0.926787474f, -0.375586178f, - 0.927362526f, -0.374164063f, - 0.927935395f, -0.372741067f, - 0.928506080f, -0.371317194f, - 0.929074581f, -0.369892447f, - 0.929640896f, -0.368466830f, - 0.930205023f, -0.367040346f, - 0.930766961f, -0.365612998f, - 0.931326709f, -0.364184790f, - 0.931884266f, -0.362755724f, - 0.932439629f, -0.361325806f, - 0.932992799f, -0.359895037f, - 0.933543773f, -0.358463421f, - 0.934092550f, -0.357030961f, - 0.934639130f, -0.355597662f, - 0.935183510f, -0.354163525f, - 0.935725689f, -0.352728556f, - 0.936265667f, -0.351292756f, - 0.936803442f, -0.349856130f, - 0.937339012f, -0.348418680f, - 0.937872376f, -0.346980411f, - 0.938403534f, -0.345541325f, - 0.938932484f, -0.344101426f, - 0.939459224f, -0.342660717f, - 0.939983753f, -0.341219202f, - 0.940506071f, -0.339776884f, - 0.941026175f, -0.338333767f, - 0.941544065f, -0.336889853f, - 0.942059740f, -0.335445147f, - 0.942573198f, -0.333999651f, - 0.943084437f, -0.332553370f, - 0.943593458f, -0.331106306f, - 0.944100258f, -0.329658463f, - 0.944604837f, -0.328209844f, - 0.945107193f, -0.326760452f, - 0.945607325f, -0.325310292f, - 0.946105232f, -0.323859367f, - 0.946600913f, -0.322407679f, - 0.947094366f, -0.320955232f, - 0.947585591f, -0.319502031f, - 0.948074586f, -0.318048077f, - 0.948561350f, -0.316593376f, - 0.949045882f, -0.315137929f, - 0.949528181f, -0.313681740f, - 0.950008245f, -0.312224814f, - 0.950486074f, -0.310767153f, - 0.950961666f, -0.309308760f, - 0.951435021f, -0.307849640f, - 0.951906137f, -0.306389795f, - 0.952375013f, -0.304929230f, - 0.952841648f, -0.303467947f, - 0.953306040f, -0.302005949f, - 0.953768190f, -0.300543241f, - 0.954228095f, -0.299079826f, - 0.954685755f, -0.297615707f, - 0.955141168f, -0.296150888f, - 0.955594334f, -0.294685372f, - 0.956045251f, -0.293219163f, - 0.956493919f, -0.291752263f, - 0.956940336f, -0.290284677f, - 0.957384501f, -0.288816408f, - 0.957826413f, -0.287347460f, - 0.958266071f, -0.285877835f, - 0.958703475f, -0.284407537f, - 0.959138622f, -0.282936570f, - 0.959571513f, -0.281464938f, - 0.960002146f, -0.279992643f, - 0.960430519f, -0.278519689f, - 0.960856633f, -0.277046080f, - 0.961280486f, -0.275571819f, - 0.961702077f, -0.274096910f, - 0.962121404f, -0.272621355f, - 0.962538468f, -0.271145160f, - 0.962953267f, -0.269668326f, - 0.963365800f, -0.268190857f, - 0.963776066f, -0.266712757f, - 0.964184064f, -0.265234030f, - 0.964589793f, -0.263754679f, - 0.964993253f, -0.262274707f, - 0.965394442f, -0.260794118f, - 0.965793359f, -0.259312915f, - 0.966190003f, -0.257831102f, - 0.966584374f, -0.256348682f, - 0.966976471f, -0.254865660f, - 0.967366292f, -0.253382037f, - 0.967753837f, -0.251897818f, - 0.968139105f, -0.250413007f, - 0.968522094f, -0.248927606f, - 0.968902805f, -0.247441619f, - 0.969281235f, -0.245955050f, - 0.969657385f, -0.244467903f, - 0.970031253f, -0.242980180f, - 0.970402839f, -0.241491885f, - 0.970772141f, -0.240003022f, - 0.971139158f, -0.238513595f, - 0.971503891f, -0.237023606f, - 0.971866337f, -0.235533059f, - 0.972226497f, -0.234041959f, - 0.972584369f, -0.232550307f, - 0.972939952f, -0.231058108f, - 0.973293246f, -0.229565366f, - 0.973644250f, -0.228072083f, - 0.973992962f, -0.226578264f, - 0.974339383f, -0.225083911f, - 0.974683511f, -0.223589029f, - 0.975025345f, -0.222093621f, - 0.975364885f, -0.220597690f, - 0.975702130f, -0.219101240f, - 0.976037079f, -0.217604275f, - 0.976369731f, -0.216106797f, - 0.976700086f, -0.214608811f, - 0.977028143f, -0.213110320f, - 0.977353900f, -0.211611327f, - 0.977677358f, -0.210111837f, - 0.977998515f, -0.208611852f, - 0.978317371f, -0.207111376f, - 0.978633924f, -0.205610413f, - 0.978948175f, -0.204108966f, - 0.979260123f, -0.202607039f, - 0.979569766f, -0.201104635f, - 0.979877104f, -0.199601758f, - 0.980182136f, -0.198098411f, - 0.980484862f, -0.196594598f, - 0.980785280f, -0.195090322f, - 0.981083391f, -0.193585587f, - 0.981379193f, -0.192080397f, - 0.981672686f, -0.190574755f, - 0.981963869f, -0.189068664f, - 0.982252741f, -0.187562129f, - 0.982539302f, -0.186055152f, - 0.982823551f, -0.184547737f, - 0.983105487f, -0.183039888f, - 0.983385110f, -0.181531608f, - 0.983662419f, -0.180022901f, - 0.983937413f, -0.178513771f, - 0.984210092f, -0.177004220f, - 0.984480455f, -0.175494253f, - 0.984748502f, -0.173983873f, - 0.985014231f, -0.172473084f, - 0.985277642f, -0.170961889f, - 0.985538735f, -0.169450291f, - 0.985797509f, -0.167938295f, - 0.986053963f, -0.166425904f, - 0.986308097f, -0.164913120f, - 0.986559910f, -0.163399949f, - 0.986809402f, -0.161886394f, - 0.987056571f, -0.160372457f, - 0.987301418f, -0.158858143f, - 0.987543942f, -0.157343456f, - 0.987784142f, -0.155828398f, - 0.988022017f, -0.154312973f, - 0.988257568f, -0.152797185f, - 0.988490793f, -0.151281038f, - 0.988721692f, -0.149764535f, - 0.988950265f, -0.148247679f, - 0.989176510f, -0.146730474f, - 0.989400428f, -0.145212925f, - 0.989622017f, -0.143695033f, - 0.989841278f, -0.142176804f, - 0.990058210f, -0.140658239f, - 0.990272812f, -0.139139344f, - 0.990485084f, -0.137620122f, - 0.990695025f, -0.136100575f, - 0.990902635f, -0.134580709f, - 0.991107914f, -0.133060525f, - 0.991310860f, -0.131540029f, - 0.991511473f, -0.130019223f, - 0.991709754f, -0.128498111f, - 0.991905700f, -0.126976696f, - 0.992099313f, -0.125454983f, - 0.992290591f, -0.123932975f, - 0.992479535f, -0.122410675f, - 0.992666142f, -0.120888087f, - 0.992850414f, -0.119365215f, - 0.993032350f, -0.117842062f, - 0.993211949f, -0.116318631f, - 0.993389211f, -0.114794927f, - 0.993564136f, -0.113270952f, - 0.993736722f, -0.111746711f, - 0.993906970f, -0.110222207f, - 0.994074879f, -0.108697444f, - 0.994240449f, -0.107172425f, - 0.994403680f, -0.105647154f, - 0.994564571f, -0.104121634f, - 0.994723121f, -0.102595869f, - 0.994879331f, -0.101069863f, - 0.995033199f, -0.099543619f, - 0.995184727f, -0.098017140f, - 0.995333912f, -0.096490431f, - 0.995480755f, -0.094963495f, - 0.995625256f, -0.093436336f, - 0.995767414f, -0.091908956f, - 0.995907229f, -0.090381361f, - 0.996044701f, -0.088853553f, - 0.996179829f, -0.087325535f, - 0.996312612f, -0.085797312f, - 0.996443051f, -0.084268888f, - 0.996571146f, -0.082740265f, - 0.996696895f, -0.081211447f, - 0.996820299f, -0.079682438f, - 0.996941358f, -0.078153242f, - 0.997060070f, -0.076623861f, - 0.997176437f, -0.075094301f, - 0.997290457f, -0.073564564f, - 0.997402130f, -0.072034653f, - 0.997511456f, -0.070504573f, - 0.997618435f, -0.068974328f, - 0.997723067f, -0.067443920f, - 0.997825350f, -0.065913353f, - 0.997925286f, -0.064382631f, - 0.998022874f, -0.062851758f, - 0.998118113f, -0.061320736f, - 0.998211003f, -0.059789571f, - 0.998301545f, -0.058258265f, - 0.998389737f, -0.056726821f, - 0.998475581f, -0.055195244f, - 0.998559074f, -0.053663538f, - 0.998640218f, -0.052131705f, - 0.998719012f, -0.050599749f, - 0.998795456f, -0.049067674f, - 0.998869550f, -0.047535484f, - 0.998941293f, -0.046003182f, - 0.999010686f, -0.044470772f, - 0.999077728f, -0.042938257f, - 0.999142419f, -0.041405641f, - 0.999204759f, -0.039872928f, - 0.999264747f, -0.038340120f, - 0.999322385f, -0.036807223f, - 0.999377670f, -0.035274239f, - 0.999430605f, -0.033741172f, - 0.999481187f, -0.032208025f, - 0.999529418f, -0.030674803f, - 0.999575296f, -0.029141509f, - 0.999618822f, -0.027608146f, - 0.999659997f, -0.026074718f, - 0.999698819f, -0.024541229f, - 0.999735288f, -0.023007681f, - 0.999769405f, -0.021474080f, - 0.999801170f, -0.019940429f, - 0.999830582f, -0.018406730f, - 0.999857641f, -0.016872988f, - 0.999882347f, -0.015339206f, - 0.999904701f, -0.013805389f, - 0.999924702f, -0.012271538f, - 0.999942350f, -0.010737659f, - 0.999957645f, -0.009203755f, - 0.999970586f, -0.007669829f, - 0.999981175f, -0.006135885f, - 0.999989411f, -0.004601926f, - 0.999995294f, -0.003067957f, - 0.999998823f, -0.001533980f -}; + 1.000000000f, 0.000000000f, 0.999998823f, 0.001533980f, 0.999995294f, + 0.003067957f, 0.999989411f, 0.004601926f, 0.999981175f, 0.006135885f, + 0.999970586f, 0.007669829f, 0.999957645f, 0.009203755f, 0.999942350f, + 0.010737659f, 0.999924702f, 0.012271538f, 0.999904701f, 0.013805389f, + 0.999882347f, 0.015339206f, 0.999857641f, 0.016872988f, 0.999830582f, + 0.018406730f, 0.999801170f, 0.019940429f, 0.999769405f, 0.021474080f, + 0.999735288f, 0.023007681f, 0.999698819f, 0.024541229f, 0.999659997f, + 0.026074718f, 0.999618822f, 0.027608146f, 0.999575296f, 0.029141509f, + 0.999529418f, 0.030674803f, 0.999481187f, 0.032208025f, 0.999430605f, + 0.033741172f, 0.999377670f, 0.035274239f, 0.999322385f, 0.036807223f, + 0.999264747f, 0.038340120f, 0.999204759f, 0.039872928f, 0.999142419f, + 0.041405641f, 0.999077728f, 0.042938257f, 0.999010686f, 0.044470772f, + 0.998941293f, 0.046003182f, 0.998869550f, 0.047535484f, 0.998795456f, + 0.049067674f, 0.998719012f, 0.050599749f, 0.998640218f, 0.052131705f, + 0.998559074f, 0.053663538f, 0.998475581f, 0.055195244f, 0.998389737f, + 0.056726821f, 0.998301545f, 0.058258265f, 0.998211003f, 0.059789571f, + 0.998118113f, 0.061320736f, 0.998022874f, 0.062851758f, 0.997925286f, + 0.064382631f, 0.997825350f, 0.065913353f, 0.997723067f, 0.067443920f, + 0.997618435f, 0.068974328f, 0.997511456f, 0.070504573f, 0.997402130f, + 0.072034653f, 0.997290457f, 0.073564564f, 0.997176437f, 0.075094301f, + 0.997060070f, 0.076623861f, 0.996941358f, 0.078153242f, 0.996820299f, + 0.079682438f, 0.996696895f, 0.081211447f, 0.996571146f, 0.082740265f, + 0.996443051f, 0.084268888f, 0.996312612f, 0.085797312f, 0.996179829f, + 0.087325535f, 0.996044701f, 0.088853553f, 0.995907229f, 0.090381361f, + 0.995767414f, 0.091908956f, 0.995625256f, 0.093436336f, 0.995480755f, + 0.094963495f, 0.995333912f, 0.096490431f, 0.995184727f, 0.098017140f, + 0.995033199f, 0.099543619f, 0.994879331f, 0.101069863f, 0.994723121f, + 0.102595869f, 0.994564571f, 0.104121634f, 0.994403680f, 0.105647154f, + 0.994240449f, 0.107172425f, 0.994074879f, 0.108697444f, 0.993906970f, + 0.110222207f, 0.993736722f, 0.111746711f, 0.993564136f, 0.113270952f, + 0.993389211f, 0.114794927f, 0.993211949f, 0.116318631f, 0.993032350f, + 0.117842062f, 0.992850414f, 0.119365215f, 0.992666142f, 0.120888087f, + 0.992479535f, 0.122410675f, 0.992290591f, 0.123932975f, 0.992099313f, + 0.125454983f, 0.991905700f, 0.126976696f, 0.991709754f, 0.128498111f, + 0.991511473f, 0.130019223f, 0.991310860f, 0.131540029f, 0.991107914f, + 0.133060525f, 0.990902635f, 0.134580709f, 0.990695025f, 0.136100575f, + 0.990485084f, 0.137620122f, 0.990272812f, 0.139139344f, 0.990058210f, + 0.140658239f, 0.989841278f, 0.142176804f, 0.989622017f, 0.143695033f, + 0.989400428f, 0.145212925f, 0.989176510f, 0.146730474f, 0.988950265f, + 0.148247679f, 0.988721692f, 0.149764535f, 0.988490793f, 0.151281038f, + 0.988257568f, 0.152797185f, 0.988022017f, 0.154312973f, 0.987784142f, + 0.155828398f, 0.987543942f, 0.157343456f, 0.987301418f, 0.158858143f, + 0.987056571f, 0.160372457f, 0.986809402f, 0.161886394f, 0.986559910f, + 0.163399949f, 0.986308097f, 0.164913120f, 0.986053963f, 0.166425904f, + 0.985797509f, 0.167938295f, 0.985538735f, 0.169450291f, 0.985277642f, + 0.170961889f, 0.985014231f, 0.172473084f, 0.984748502f, 0.173983873f, + 0.984480455f, 0.175494253f, 0.984210092f, 0.177004220f, 0.983937413f, + 0.178513771f, 0.983662419f, 0.180022901f, 0.983385110f, 0.181531608f, + 0.983105487f, 0.183039888f, 0.982823551f, 0.184547737f, 0.982539302f, + 0.186055152f, 0.982252741f, 0.187562129f, 0.981963869f, 0.189068664f, + 0.981672686f, 0.190574755f, 0.981379193f, 0.192080397f, 0.981083391f, + 0.193585587f, 0.980785280f, 0.195090322f, 0.980484862f, 0.196594598f, + 0.980182136f, 0.198098411f, 0.979877104f, 0.199601758f, 0.979569766f, + 0.201104635f, 0.979260123f, 0.202607039f, 0.978948175f, 0.204108966f, + 0.978633924f, 0.205610413f, 0.978317371f, 0.207111376f, 0.977998515f, + 0.208611852f, 0.977677358f, 0.210111837f, 0.977353900f, 0.211611327f, + 0.977028143f, 0.213110320f, 0.976700086f, 0.214608811f, 0.976369731f, + 0.216106797f, 0.976037079f, 0.217604275f, 0.975702130f, 0.219101240f, + 0.975364885f, 0.220597690f, 0.975025345f, 0.222093621f, 0.974683511f, + 0.223589029f, 0.974339383f, 0.225083911f, 0.973992962f, 0.226578264f, + 0.973644250f, 0.228072083f, 0.973293246f, 0.229565366f, 0.972939952f, + 0.231058108f, 0.972584369f, 0.232550307f, 0.972226497f, 0.234041959f, + 0.971866337f, 0.235533059f, 0.971503891f, 0.237023606f, 0.971139158f, + 0.238513595f, 0.970772141f, 0.240003022f, 0.970402839f, 0.241491885f, + 0.970031253f, 0.242980180f, 0.969657385f, 0.244467903f, 0.969281235f, + 0.245955050f, 0.968902805f, 0.247441619f, 0.968522094f, 0.248927606f, + 0.968139105f, 0.250413007f, 0.967753837f, 0.251897818f, 0.967366292f, + 0.253382037f, 0.966976471f, 0.254865660f, 0.966584374f, 0.256348682f, + 0.966190003f, 0.257831102f, 0.965793359f, 0.259312915f, 0.965394442f, + 0.260794118f, 0.964993253f, 0.262274707f, 0.964589793f, 0.263754679f, + 0.964184064f, 0.265234030f, 0.963776066f, 0.266712757f, 0.963365800f, + 0.268190857f, 0.962953267f, 0.269668326f, 0.962538468f, 0.271145160f, + 0.962121404f, 0.272621355f, 0.961702077f, 0.274096910f, 0.961280486f, + 0.275571819f, 0.960856633f, 0.277046080f, 0.960430519f, 0.278519689f, + 0.960002146f, 0.279992643f, 0.959571513f, 0.281464938f, 0.959138622f, + 0.282936570f, 0.958703475f, 0.284407537f, 0.958266071f, 0.285877835f, + 0.957826413f, 0.287347460f, 0.957384501f, 0.288816408f, 0.956940336f, + 0.290284677f, 0.956493919f, 0.291752263f, 0.956045251f, 0.293219163f, + 0.955594334f, 0.294685372f, 0.955141168f, 0.296150888f, 0.954685755f, + 0.297615707f, 0.954228095f, 0.299079826f, 0.953768190f, 0.300543241f, + 0.953306040f, 0.302005949f, 0.952841648f, 0.303467947f, 0.952375013f, + 0.304929230f, 0.951906137f, 0.306389795f, 0.951435021f, 0.307849640f, + 0.950961666f, 0.309308760f, 0.950486074f, 0.310767153f, 0.950008245f, + 0.312224814f, 0.949528181f, 0.313681740f, 0.949045882f, 0.315137929f, + 0.948561350f, 0.316593376f, 0.948074586f, 0.318048077f, 0.947585591f, + 0.319502031f, 0.947094366f, 0.320955232f, 0.946600913f, 0.322407679f, + 0.946105232f, 0.323859367f, 0.945607325f, 0.325310292f, 0.945107193f, + 0.326760452f, 0.944604837f, 0.328209844f, 0.944100258f, 0.329658463f, + 0.943593458f, 0.331106306f, 0.943084437f, 0.332553370f, 0.942573198f, + 0.333999651f, 0.942059740f, 0.335445147f, 0.941544065f, 0.336889853f, + 0.941026175f, 0.338333767f, 0.940506071f, 0.339776884f, 0.939983753f, + 0.341219202f, 0.939459224f, 0.342660717f, 0.938932484f, 0.344101426f, + 0.938403534f, 0.345541325f, 0.937872376f, 0.346980411f, 0.937339012f, + 0.348418680f, 0.936803442f, 0.349856130f, 0.936265667f, 0.351292756f, + 0.935725689f, 0.352728556f, 0.935183510f, 0.354163525f, 0.934639130f, + 0.355597662f, 0.934092550f, 0.357030961f, 0.933543773f, 0.358463421f, + 0.932992799f, 0.359895037f, 0.932439629f, 0.361325806f, 0.931884266f, + 0.362755724f, 0.931326709f, 0.364184790f, 0.930766961f, 0.365612998f, + 0.930205023f, 0.367040346f, 0.929640896f, 0.368466830f, 0.929074581f, + 0.369892447f, 0.928506080f, 0.371317194f, 0.927935395f, 0.372741067f, + 0.927362526f, 0.374164063f, 0.926787474f, 0.375586178f, 0.926210242f, + 0.377007410f, 0.925630831f, 0.378427755f, 0.925049241f, 0.379847209f, + 0.924465474f, 0.381265769f, 0.923879533f, 0.382683432f, 0.923291417f, + 0.384100195f, 0.922701128f, 0.385516054f, 0.922108669f, 0.386931006f, + 0.921514039f, 0.388345047f, 0.920917242f, 0.389758174f, 0.920318277f, + 0.391170384f, 0.919717146f, 0.392581674f, 0.919113852f, 0.393992040f, + 0.918508394f, 0.395401479f, 0.917900776f, 0.396809987f, 0.917290997f, + 0.398217562f, 0.916679060f, 0.399624200f, 0.916064966f, 0.401029897f, + 0.915448716f, 0.402434651f, 0.914830312f, 0.403838458f, 0.914209756f, + 0.405241314f, 0.913587048f, 0.406643217f, 0.912962190f, 0.408044163f, + 0.912335185f, 0.409444149f, 0.911706032f, 0.410843171f, 0.911074734f, + 0.412241227f, 0.910441292f, 0.413638312f, 0.909805708f, 0.415034424f, + 0.909167983f, 0.416429560f, 0.908528119f, 0.417823716f, 0.907886116f, + 0.419216888f, 0.907241978f, 0.420609074f, 0.906595705f, 0.422000271f, + 0.905947298f, 0.423390474f, 0.905296759f, 0.424779681f, 0.904644091f, + 0.426167889f, 0.903989293f, 0.427555093f, 0.903332368f, 0.428941292f, + 0.902673318f, 0.430326481f, 0.902012144f, 0.431710658f, 0.901348847f, + 0.433093819f, 0.900683429f, 0.434475961f, 0.900015892f, 0.435857080f, + 0.899346237f, 0.437237174f, 0.898674466f, 0.438616239f, 0.898000580f, + 0.439994271f, 0.897324581f, 0.441371269f, 0.896646470f, 0.442747228f, + 0.895966250f, 0.444122145f, 0.895283921f, 0.445496017f, 0.894599486f, + 0.446868840f, 0.893912945f, 0.448240612f, 0.893224301f, 0.449611330f, + 0.892533555f, 0.450980989f, 0.891840709f, 0.452349587f, 0.891145765f, + 0.453717121f, 0.890448723f, 0.455083587f, 0.889749586f, 0.456448982f, + 0.889048356f, 0.457813304f, 0.888345033f, 0.459176548f, 0.887639620f, + 0.460538711f, 0.886932119f, 0.461899791f, 0.886222530f, 0.463259784f, + 0.885510856f, 0.464618686f, 0.884797098f, 0.465976496f, 0.884081259f, + 0.467333209f, 0.883363339f, 0.468688822f, 0.882643340f, 0.470043332f, + 0.881921264f, 0.471396737f, 0.881197113f, 0.472749032f, 0.880470889f, + 0.474100215f, 0.879742593f, 0.475450282f, 0.879012226f, 0.476799230f, + 0.878279792f, 0.478147056f, 0.877545290f, 0.479493758f, 0.876808724f, + 0.480839331f, 0.876070094f, 0.482183772f, 0.875329403f, 0.483527079f, + 0.874586652f, 0.484869248f, 0.873841843f, 0.486210276f, 0.873094978f, + 0.487550160f, 0.872346059f, 0.488888897f, 0.871595087f, 0.490226483f, + 0.870842063f, 0.491562916f, 0.870086991f, 0.492898192f, 0.869329871f, + 0.494232309f, 0.868570706f, 0.495565262f, 0.867809497f, 0.496897049f, + 0.867046246f, 0.498227667f, 0.866280954f, 0.499557113f, 0.865513624f, + 0.500885383f, 0.864744258f, 0.502212474f, 0.863972856f, 0.503538384f, + 0.863199422f, 0.504863109f, 0.862423956f, 0.506186645f, 0.861646461f, + 0.507508991f, 0.860866939f, 0.508830143f, 0.860085390f, 0.510150097f, + 0.859301818f, 0.511468850f, 0.858516224f, 0.512786401f, 0.857728610f, + 0.514102744f, 0.856938977f, 0.515417878f, 0.856147328f, 0.516731799f, + 0.855353665f, 0.518044504f, 0.854557988f, 0.519355990f, 0.853760301f, + 0.520666254f, 0.852960605f, 0.521975293f, 0.852158902f, 0.523283103f, + 0.851355193f, 0.524589683f, 0.850549481f, 0.525895027f, 0.849741768f, + 0.527199135f, 0.848932055f, 0.528502002f, 0.848120345f, 0.529803625f, + 0.847306639f, 0.531104001f, 0.846490939f, 0.532403128f, 0.845673247f, + 0.533701002f, 0.844853565f, 0.534997620f, 0.844031895f, 0.536292979f, + 0.843208240f, 0.537587076f, 0.842382600f, 0.538879909f, 0.841554977f, + 0.540171473f, 0.840725375f, 0.541461766f, 0.839893794f, 0.542750785f, + 0.839060237f, 0.544038527f, 0.838224706f, 0.545324988f, 0.837387202f, + 0.546610167f, 0.836547727f, 0.547894059f, 0.835706284f, 0.549176662f, + 0.834862875f, 0.550457973f, 0.834017501f, 0.551737988f, 0.833170165f, + 0.553016706f, 0.832320868f, 0.554294121f, 0.831469612f, 0.555570233f, + 0.830616400f, 0.556845037f, 0.829761234f, 0.558118531f, 0.828904115f, + 0.559390712f, 0.828045045f, 0.560661576f, 0.827184027f, 0.561931121f, + 0.826321063f, 0.563199344f, 0.825456154f, 0.564466242f, 0.824589303f, + 0.565731811f, 0.823720511f, 0.566996049f, 0.822849781f, 0.568258953f, + 0.821977115f, 0.569520519f, 0.821102515f, 0.570780746f, 0.820225983f, + 0.572039629f, 0.819347520f, 0.573297167f, 0.818467130f, 0.574553355f, + 0.817584813f, 0.575808191f, 0.816700573f, 0.577061673f, 0.815814411f, + 0.578313796f, 0.814926329f, 0.579564559f, 0.814036330f, 0.580813958f, + 0.813144415f, 0.582061990f, 0.812250587f, 0.583308653f, 0.811354847f, + 0.584553943f, 0.810457198f, 0.585797857f, 0.809557642f, 0.587040394f, + 0.808656182f, 0.588281548f, 0.807752818f, 0.589521319f, 0.806847554f, + 0.590759702f, 0.805940391f, 0.591996695f, 0.805031331f, 0.593232295f, + 0.804120377f, 0.594466499f, 0.803207531f, 0.595699304f, 0.802292796f, + 0.596930708f, 0.801376172f, 0.598160707f, 0.800457662f, 0.599389298f, + 0.799537269f, 0.600616479f, 0.798614995f, 0.601842247f, 0.797690841f, + 0.603066599f, 0.796764810f, 0.604289531f, 0.795836905f, 0.605511041f, + 0.794907126f, 0.606731127f, 0.793975478f, 0.607949785f, 0.793041960f, + 0.609167012f, 0.792106577f, 0.610382806f, 0.791169330f, 0.611597164f, + 0.790230221f, 0.612810082f, 0.789289253f, 0.614021559f, 0.788346428f, + 0.615231591f, 0.787401747f, 0.616440175f, 0.786455214f, 0.617647308f, + 0.785506830f, 0.618852988f, 0.784556597f, 0.620057212f, 0.783604519f, + 0.621259977f, 0.782650596f, 0.622461279f, 0.781694832f, 0.623661118f, + 0.780737229f, 0.624859488f, 0.779777788f, 0.626056388f, 0.778816512f, + 0.627251815f, 0.777853404f, 0.628445767f, 0.776888466f, 0.629638239f, + 0.775921699f, 0.630829230f, 0.774953107f, 0.632018736f, 0.773982691f, + 0.633206755f, 0.773010453f, 0.634393284f, 0.772036397f, 0.635578320f, + 0.771060524f, 0.636761861f, 0.770082837f, 0.637943904f, 0.769103338f, + 0.639124445f, 0.768122029f, 0.640303482f, 0.767138912f, 0.641481013f, + 0.766153990f, 0.642657034f, 0.765167266f, 0.643831543f, 0.764178741f, + 0.645004537f, 0.763188417f, 0.646176013f, 0.762196298f, 0.647345969f, + 0.761202385f, 0.648514401f, 0.760206682f, 0.649681307f, 0.759209189f, + 0.650846685f, 0.758209910f, 0.652010531f, 0.757208847f, 0.653172843f, + 0.756206001f, 0.654333618f, 0.755201377f, 0.655492853f, 0.754194975f, + 0.656650546f, 0.753186799f, 0.657806693f, 0.752176850f, 0.658961293f, + 0.751165132f, 0.660114342f, 0.750151646f, 0.661265838f, 0.749136395f, + 0.662415778f, 0.748119380f, 0.663564159f, 0.747100606f, 0.664710978f, + 0.746080074f, 0.665856234f, 0.745057785f, 0.666999922f, 0.744033744f, + 0.668142041f, 0.743007952f, 0.669282588f, 0.741980412f, 0.670421560f, + 0.740951125f, 0.671558955f, 0.739920095f, 0.672694769f, 0.738887324f, + 0.673829000f, 0.737852815f, 0.674961646f, 0.736816569f, 0.676092704f, + 0.735778589f, 0.677222170f, 0.734738878f, 0.678350043f, 0.733697438f, + 0.679476320f, 0.732654272f, 0.680600998f, 0.731609381f, 0.681724074f, + 0.730562769f, 0.682845546f, 0.729514438f, 0.683965412f, 0.728464390f, + 0.685083668f, 0.727412629f, 0.686200312f, 0.726359155f, 0.687315341f, + 0.725303972f, 0.688428753f, 0.724247083f, 0.689540545f, 0.723188489f, + 0.690650714f, 0.722128194f, 0.691759258f, 0.721066199f, 0.692866175f, + 0.720002508f, 0.693971461f, 0.718937122f, 0.695075114f, 0.717870045f, + 0.696177131f, 0.716801279f, 0.697277511f, 0.715730825f, 0.698376249f, + 0.714658688f, 0.699473345f, 0.713584869f, 0.700568794f, 0.712509371f, + 0.701662595f, 0.711432196f, 0.702754744f, 0.710353347f, 0.703845241f, + 0.709272826f, 0.704934080f, 0.708190637f, 0.706021261f, 0.707106781f, + 0.707106781f, 0.706021261f, 0.708190637f, 0.704934080f, 0.709272826f, + 0.703845241f, 0.710353347f, 0.702754744f, 0.711432196f, 0.701662595f, + 0.712509371f, 0.700568794f, 0.713584869f, 0.699473345f, 0.714658688f, + 0.698376249f, 0.715730825f, 0.697277511f, 0.716801279f, 0.696177131f, + 0.717870045f, 0.695075114f, 0.718937122f, 0.693971461f, 0.720002508f, + 0.692866175f, 0.721066199f, 0.691759258f, 0.722128194f, 0.690650714f, + 0.723188489f, 0.689540545f, 0.724247083f, 0.688428753f, 0.725303972f, + 0.687315341f, 0.726359155f, 0.686200312f, 0.727412629f, 0.685083668f, + 0.728464390f, 0.683965412f, 0.729514438f, 0.682845546f, 0.730562769f, + 0.681724074f, 0.731609381f, 0.680600998f, 0.732654272f, 0.679476320f, + 0.733697438f, 0.678350043f, 0.734738878f, 0.677222170f, 0.735778589f, + 0.676092704f, 0.736816569f, 0.674961646f, 0.737852815f, 0.673829000f, + 0.738887324f, 0.672694769f, 0.739920095f, 0.671558955f, 0.740951125f, + 0.670421560f, 0.741980412f, 0.669282588f, 0.743007952f, 0.668142041f, + 0.744033744f, 0.666999922f, 0.745057785f, 0.665856234f, 0.746080074f, + 0.664710978f, 0.747100606f, 0.663564159f, 0.748119380f, 0.662415778f, + 0.749136395f, 0.661265838f, 0.750151646f, 0.660114342f, 0.751165132f, + 0.658961293f, 0.752176850f, 0.657806693f, 0.753186799f, 0.656650546f, + 0.754194975f, 0.655492853f, 0.755201377f, 0.654333618f, 0.756206001f, + 0.653172843f, 0.757208847f, 0.652010531f, 0.758209910f, 0.650846685f, + 0.759209189f, 0.649681307f, 0.760206682f, 0.648514401f, 0.761202385f, + 0.647345969f, 0.762196298f, 0.646176013f, 0.763188417f, 0.645004537f, + 0.764178741f, 0.643831543f, 0.765167266f, 0.642657034f, 0.766153990f, + 0.641481013f, 0.767138912f, 0.640303482f, 0.768122029f, 0.639124445f, + 0.769103338f, 0.637943904f, 0.770082837f, 0.636761861f, 0.771060524f, + 0.635578320f, 0.772036397f, 0.634393284f, 0.773010453f, 0.633206755f, + 0.773982691f, 0.632018736f, 0.774953107f, 0.630829230f, 0.775921699f, + 0.629638239f, 0.776888466f, 0.628445767f, 0.777853404f, 0.627251815f, + 0.778816512f, 0.626056388f, 0.779777788f, 0.624859488f, 0.780737229f, + 0.623661118f, 0.781694832f, 0.622461279f, 0.782650596f, 0.621259977f, + 0.783604519f, 0.620057212f, 0.784556597f, 0.618852988f, 0.785506830f, + 0.617647308f, 0.786455214f, 0.616440175f, 0.787401747f, 0.615231591f, + 0.788346428f, 0.614021559f, 0.789289253f, 0.612810082f, 0.790230221f, + 0.611597164f, 0.791169330f, 0.610382806f, 0.792106577f, 0.609167012f, + 0.793041960f, 0.607949785f, 0.793975478f, 0.606731127f, 0.794907126f, + 0.605511041f, 0.795836905f, 0.604289531f, 0.796764810f, 0.603066599f, + 0.797690841f, 0.601842247f, 0.798614995f, 0.600616479f, 0.799537269f, + 0.599389298f, 0.800457662f, 0.598160707f, 0.801376172f, 0.596930708f, + 0.802292796f, 0.595699304f, 0.803207531f, 0.594466499f, 0.804120377f, + 0.593232295f, 0.805031331f, 0.591996695f, 0.805940391f, 0.590759702f, + 0.806847554f, 0.589521319f, 0.807752818f, 0.588281548f, 0.808656182f, + 0.587040394f, 0.809557642f, 0.585797857f, 0.810457198f, 0.584553943f, + 0.811354847f, 0.583308653f, 0.812250587f, 0.582061990f, 0.813144415f, + 0.580813958f, 0.814036330f, 0.579564559f, 0.814926329f, 0.578313796f, + 0.815814411f, 0.577061673f, 0.816700573f, 0.575808191f, 0.817584813f, + 0.574553355f, 0.818467130f, 0.573297167f, 0.819347520f, 0.572039629f, + 0.820225983f, 0.570780746f, 0.821102515f, 0.569520519f, 0.821977115f, + 0.568258953f, 0.822849781f, 0.566996049f, 0.823720511f, 0.565731811f, + 0.824589303f, 0.564466242f, 0.825456154f, 0.563199344f, 0.826321063f, + 0.561931121f, 0.827184027f, 0.560661576f, 0.828045045f, 0.559390712f, + 0.828904115f, 0.558118531f, 0.829761234f, 0.556845037f, 0.830616400f, + 0.555570233f, 0.831469612f, 0.554294121f, 0.832320868f, 0.553016706f, + 0.833170165f, 0.551737988f, 0.834017501f, 0.550457973f, 0.834862875f, + 0.549176662f, 0.835706284f, 0.547894059f, 0.836547727f, 0.546610167f, + 0.837387202f, 0.545324988f, 0.838224706f, 0.544038527f, 0.839060237f, + 0.542750785f, 0.839893794f, 0.541461766f, 0.840725375f, 0.540171473f, + 0.841554977f, 0.538879909f, 0.842382600f, 0.537587076f, 0.843208240f, + 0.536292979f, 0.844031895f, 0.534997620f, 0.844853565f, 0.533701002f, + 0.845673247f, 0.532403128f, 0.846490939f, 0.531104001f, 0.847306639f, + 0.529803625f, 0.848120345f, 0.528502002f, 0.848932055f, 0.527199135f, + 0.849741768f, 0.525895027f, 0.850549481f, 0.524589683f, 0.851355193f, + 0.523283103f, 0.852158902f, 0.521975293f, 0.852960605f, 0.520666254f, + 0.853760301f, 0.519355990f, 0.854557988f, 0.518044504f, 0.855353665f, + 0.516731799f, 0.856147328f, 0.515417878f, 0.856938977f, 0.514102744f, + 0.857728610f, 0.512786401f, 0.858516224f, 0.511468850f, 0.859301818f, + 0.510150097f, 0.860085390f, 0.508830143f, 0.860866939f, 0.507508991f, + 0.861646461f, 0.506186645f, 0.862423956f, 0.504863109f, 0.863199422f, + 0.503538384f, 0.863972856f, 0.502212474f, 0.864744258f, 0.500885383f, + 0.865513624f, 0.499557113f, 0.866280954f, 0.498227667f, 0.867046246f, + 0.496897049f, 0.867809497f, 0.495565262f, 0.868570706f, 0.494232309f, + 0.869329871f, 0.492898192f, 0.870086991f, 0.491562916f, 0.870842063f, + 0.490226483f, 0.871595087f, 0.488888897f, 0.872346059f, 0.487550160f, + 0.873094978f, 0.486210276f, 0.873841843f, 0.484869248f, 0.874586652f, + 0.483527079f, 0.875329403f, 0.482183772f, 0.876070094f, 0.480839331f, + 0.876808724f, 0.479493758f, 0.877545290f, 0.478147056f, 0.878279792f, + 0.476799230f, 0.879012226f, 0.475450282f, 0.879742593f, 0.474100215f, + 0.880470889f, 0.472749032f, 0.881197113f, 0.471396737f, 0.881921264f, + 0.470043332f, 0.882643340f, 0.468688822f, 0.883363339f, 0.467333209f, + 0.884081259f, 0.465976496f, 0.884797098f, 0.464618686f, 0.885510856f, + 0.463259784f, 0.886222530f, 0.461899791f, 0.886932119f, 0.460538711f, + 0.887639620f, 0.459176548f, 0.888345033f, 0.457813304f, 0.889048356f, + 0.456448982f, 0.889749586f, 0.455083587f, 0.890448723f, 0.453717121f, + 0.891145765f, 0.452349587f, 0.891840709f, 0.450980989f, 0.892533555f, + 0.449611330f, 0.893224301f, 0.448240612f, 0.893912945f, 0.446868840f, + 0.894599486f, 0.445496017f, 0.895283921f, 0.444122145f, 0.895966250f, + 0.442747228f, 0.896646470f, 0.441371269f, 0.897324581f, 0.439994271f, + 0.898000580f, 0.438616239f, 0.898674466f, 0.437237174f, 0.899346237f, + 0.435857080f, 0.900015892f, 0.434475961f, 0.900683429f, 0.433093819f, + 0.901348847f, 0.431710658f, 0.902012144f, 0.430326481f, 0.902673318f, + 0.428941292f, 0.903332368f, 0.427555093f, 0.903989293f, 0.426167889f, + 0.904644091f, 0.424779681f, 0.905296759f, 0.423390474f, 0.905947298f, + 0.422000271f, 0.906595705f, 0.420609074f, 0.907241978f, 0.419216888f, + 0.907886116f, 0.417823716f, 0.908528119f, 0.416429560f, 0.909167983f, + 0.415034424f, 0.909805708f, 0.413638312f, 0.910441292f, 0.412241227f, + 0.911074734f, 0.410843171f, 0.911706032f, 0.409444149f, 0.912335185f, + 0.408044163f, 0.912962190f, 0.406643217f, 0.913587048f, 0.405241314f, + 0.914209756f, 0.403838458f, 0.914830312f, 0.402434651f, 0.915448716f, + 0.401029897f, 0.916064966f, 0.399624200f, 0.916679060f, 0.398217562f, + 0.917290997f, 0.396809987f, 0.917900776f, 0.395401479f, 0.918508394f, + 0.393992040f, 0.919113852f, 0.392581674f, 0.919717146f, 0.391170384f, + 0.920318277f, 0.389758174f, 0.920917242f, 0.388345047f, 0.921514039f, + 0.386931006f, 0.922108669f, 0.385516054f, 0.922701128f, 0.384100195f, + 0.923291417f, 0.382683432f, 0.923879533f, 0.381265769f, 0.924465474f, + 0.379847209f, 0.925049241f, 0.378427755f, 0.925630831f, 0.377007410f, + 0.926210242f, 0.375586178f, 0.926787474f, 0.374164063f, 0.927362526f, + 0.372741067f, 0.927935395f, 0.371317194f, 0.928506080f, 0.369892447f, + 0.929074581f, 0.368466830f, 0.929640896f, 0.367040346f, 0.930205023f, + 0.365612998f, 0.930766961f, 0.364184790f, 0.931326709f, 0.362755724f, + 0.931884266f, 0.361325806f, 0.932439629f, 0.359895037f, 0.932992799f, + 0.358463421f, 0.933543773f, 0.357030961f, 0.934092550f, 0.355597662f, + 0.934639130f, 0.354163525f, 0.935183510f, 0.352728556f, 0.935725689f, + 0.351292756f, 0.936265667f, 0.349856130f, 0.936803442f, 0.348418680f, + 0.937339012f, 0.346980411f, 0.937872376f, 0.345541325f, 0.938403534f, + 0.344101426f, 0.938932484f, 0.342660717f, 0.939459224f, 0.341219202f, + 0.939983753f, 0.339776884f, 0.940506071f, 0.338333767f, 0.941026175f, + 0.336889853f, 0.941544065f, 0.335445147f, 0.942059740f, 0.333999651f, + 0.942573198f, 0.332553370f, 0.943084437f, 0.331106306f, 0.943593458f, + 0.329658463f, 0.944100258f, 0.328209844f, 0.944604837f, 0.326760452f, + 0.945107193f, 0.325310292f, 0.945607325f, 0.323859367f, 0.946105232f, + 0.322407679f, 0.946600913f, 0.320955232f, 0.947094366f, 0.319502031f, + 0.947585591f, 0.318048077f, 0.948074586f, 0.316593376f, 0.948561350f, + 0.315137929f, 0.949045882f, 0.313681740f, 0.949528181f, 0.312224814f, + 0.950008245f, 0.310767153f, 0.950486074f, 0.309308760f, 0.950961666f, + 0.307849640f, 0.951435021f, 0.306389795f, 0.951906137f, 0.304929230f, + 0.952375013f, 0.303467947f, 0.952841648f, 0.302005949f, 0.953306040f, + 0.300543241f, 0.953768190f, 0.299079826f, 0.954228095f, 0.297615707f, + 0.954685755f, 0.296150888f, 0.955141168f, 0.294685372f, 0.955594334f, + 0.293219163f, 0.956045251f, 0.291752263f, 0.956493919f, 0.290284677f, + 0.956940336f, 0.288816408f, 0.957384501f, 0.287347460f, 0.957826413f, + 0.285877835f, 0.958266071f, 0.284407537f, 0.958703475f, 0.282936570f, + 0.959138622f, 0.281464938f, 0.959571513f, 0.279992643f, 0.960002146f, + 0.278519689f, 0.960430519f, 0.277046080f, 0.960856633f, 0.275571819f, + 0.961280486f, 0.274096910f, 0.961702077f, 0.272621355f, 0.962121404f, + 0.271145160f, 0.962538468f, 0.269668326f, 0.962953267f, 0.268190857f, + 0.963365800f, 0.266712757f, 0.963776066f, 0.265234030f, 0.964184064f, + 0.263754679f, 0.964589793f, 0.262274707f, 0.964993253f, 0.260794118f, + 0.965394442f, 0.259312915f, 0.965793359f, 0.257831102f, 0.966190003f, + 0.256348682f, 0.966584374f, 0.254865660f, 0.966976471f, 0.253382037f, + 0.967366292f, 0.251897818f, 0.967753837f, 0.250413007f, 0.968139105f, + 0.248927606f, 0.968522094f, 0.247441619f, 0.968902805f, 0.245955050f, + 0.969281235f, 0.244467903f, 0.969657385f, 0.242980180f, 0.970031253f, + 0.241491885f, 0.970402839f, 0.240003022f, 0.970772141f, 0.238513595f, + 0.971139158f, 0.237023606f, 0.971503891f, 0.235533059f, 0.971866337f, + 0.234041959f, 0.972226497f, 0.232550307f, 0.972584369f, 0.231058108f, + 0.972939952f, 0.229565366f, 0.973293246f, 0.228072083f, 0.973644250f, + 0.226578264f, 0.973992962f, 0.225083911f, 0.974339383f, 0.223589029f, + 0.974683511f, 0.222093621f, 0.975025345f, 0.220597690f, 0.975364885f, + 0.219101240f, 0.975702130f, 0.217604275f, 0.976037079f, 0.216106797f, + 0.976369731f, 0.214608811f, 0.976700086f, 0.213110320f, 0.977028143f, + 0.211611327f, 0.977353900f, 0.210111837f, 0.977677358f, 0.208611852f, + 0.977998515f, 0.207111376f, 0.978317371f, 0.205610413f, 0.978633924f, + 0.204108966f, 0.978948175f, 0.202607039f, 0.979260123f, 0.201104635f, + 0.979569766f, 0.199601758f, 0.979877104f, 0.198098411f, 0.980182136f, + 0.196594598f, 0.980484862f, 0.195090322f, 0.980785280f, 0.193585587f, + 0.981083391f, 0.192080397f, 0.981379193f, 0.190574755f, 0.981672686f, + 0.189068664f, 0.981963869f, 0.187562129f, 0.982252741f, 0.186055152f, + 0.982539302f, 0.184547737f, 0.982823551f, 0.183039888f, 0.983105487f, + 0.181531608f, 0.983385110f, 0.180022901f, 0.983662419f, 0.178513771f, + 0.983937413f, 0.177004220f, 0.984210092f, 0.175494253f, 0.984480455f, + 0.173983873f, 0.984748502f, 0.172473084f, 0.985014231f, 0.170961889f, + 0.985277642f, 0.169450291f, 0.985538735f, 0.167938295f, 0.985797509f, + 0.166425904f, 0.986053963f, 0.164913120f, 0.986308097f, 0.163399949f, + 0.986559910f, 0.161886394f, 0.986809402f, 0.160372457f, 0.987056571f, + 0.158858143f, 0.987301418f, 0.157343456f, 0.987543942f, 0.155828398f, + 0.987784142f, 0.154312973f, 0.988022017f, 0.152797185f, 0.988257568f, + 0.151281038f, 0.988490793f, 0.149764535f, 0.988721692f, 0.148247679f, + 0.988950265f, 0.146730474f, 0.989176510f, 0.145212925f, 0.989400428f, + 0.143695033f, 0.989622017f, 0.142176804f, 0.989841278f, 0.140658239f, + 0.990058210f, 0.139139344f, 0.990272812f, 0.137620122f, 0.990485084f, + 0.136100575f, 0.990695025f, 0.134580709f, 0.990902635f, 0.133060525f, + 0.991107914f, 0.131540029f, 0.991310860f, 0.130019223f, 0.991511473f, + 0.128498111f, 0.991709754f, 0.126976696f, 0.991905700f, 0.125454983f, + 0.992099313f, 0.123932975f, 0.992290591f, 0.122410675f, 0.992479535f, + 0.120888087f, 0.992666142f, 0.119365215f, 0.992850414f, 0.117842062f, + 0.993032350f, 0.116318631f, 0.993211949f, 0.114794927f, 0.993389211f, + 0.113270952f, 0.993564136f, 0.111746711f, 0.993736722f, 0.110222207f, + 0.993906970f, 0.108697444f, 0.994074879f, 0.107172425f, 0.994240449f, + 0.105647154f, 0.994403680f, 0.104121634f, 0.994564571f, 0.102595869f, + 0.994723121f, 0.101069863f, 0.994879331f, 0.099543619f, 0.995033199f, + 0.098017140f, 0.995184727f, 0.096490431f, 0.995333912f, 0.094963495f, + 0.995480755f, 0.093436336f, 0.995625256f, 0.091908956f, 0.995767414f, + 0.090381361f, 0.995907229f, 0.088853553f, 0.996044701f, 0.087325535f, + 0.996179829f, 0.085797312f, 0.996312612f, 0.084268888f, 0.996443051f, + 0.082740265f, 0.996571146f, 0.081211447f, 0.996696895f, 0.079682438f, + 0.996820299f, 0.078153242f, 0.996941358f, 0.076623861f, 0.997060070f, + 0.075094301f, 0.997176437f, 0.073564564f, 0.997290457f, 0.072034653f, + 0.997402130f, 0.070504573f, 0.997511456f, 0.068974328f, 0.997618435f, + 0.067443920f, 0.997723067f, 0.065913353f, 0.997825350f, 0.064382631f, + 0.997925286f, 0.062851758f, 0.998022874f, 0.061320736f, 0.998118113f, + 0.059789571f, 0.998211003f, 0.058258265f, 0.998301545f, 0.056726821f, + 0.998389737f, 0.055195244f, 0.998475581f, 0.053663538f, 0.998559074f, + 0.052131705f, 0.998640218f, 0.050599749f, 0.998719012f, 0.049067674f, + 0.998795456f, 0.047535484f, 0.998869550f, 0.046003182f, 0.998941293f, + 0.044470772f, 0.999010686f, 0.042938257f, 0.999077728f, 0.041405641f, + 0.999142419f, 0.039872928f, 0.999204759f, 0.038340120f, 0.999264747f, + 0.036807223f, 0.999322385f, 0.035274239f, 0.999377670f, 0.033741172f, + 0.999430605f, 0.032208025f, 0.999481187f, 0.030674803f, 0.999529418f, + 0.029141509f, 0.999575296f, 0.027608146f, 0.999618822f, 0.026074718f, + 0.999659997f, 0.024541229f, 0.999698819f, 0.023007681f, 0.999735288f, + 0.021474080f, 0.999769405f, 0.019940429f, 0.999801170f, 0.018406730f, + 0.999830582f, 0.016872988f, 0.999857641f, 0.015339206f, 0.999882347f, + 0.013805389f, 0.999904701f, 0.012271538f, 0.999924702f, 0.010737659f, + 0.999942350f, 0.009203755f, 0.999957645f, 0.007669829f, 0.999970586f, + 0.006135885f, 0.999981175f, 0.004601926f, 0.999989411f, 0.003067957f, + 0.999995294f, 0.001533980f, 0.999998823f, 0.000000000f, 1.000000000f, + -0.001533980f, 0.999998823f, -0.003067957f, 0.999995294f, -0.004601926f, + 0.999989411f, -0.006135885f, 0.999981175f, -0.007669829f, 0.999970586f, + -0.009203755f, 0.999957645f, -0.010737659f, 0.999942350f, -0.012271538f, + 0.999924702f, -0.013805389f, 0.999904701f, -0.015339206f, 0.999882347f, + -0.016872988f, 0.999857641f, -0.018406730f, 0.999830582f, -0.019940429f, + 0.999801170f, -0.021474080f, 0.999769405f, -0.023007681f, 0.999735288f, + -0.024541229f, 0.999698819f, -0.026074718f, 0.999659997f, -0.027608146f, + 0.999618822f, -0.029141509f, 0.999575296f, -0.030674803f, 0.999529418f, + -0.032208025f, 0.999481187f, -0.033741172f, 0.999430605f, -0.035274239f, + 0.999377670f, -0.036807223f, 0.999322385f, -0.038340120f, 0.999264747f, + -0.039872928f, 0.999204759f, -0.041405641f, 0.999142419f, -0.042938257f, + 0.999077728f, -0.044470772f, 0.999010686f, -0.046003182f, 0.998941293f, + -0.047535484f, 0.998869550f, -0.049067674f, 0.998795456f, -0.050599749f, + 0.998719012f, -0.052131705f, 0.998640218f, -0.053663538f, 0.998559074f, + -0.055195244f, 0.998475581f, -0.056726821f, 0.998389737f, -0.058258265f, + 0.998301545f, -0.059789571f, 0.998211003f, -0.061320736f, 0.998118113f, + -0.062851758f, 0.998022874f, -0.064382631f, 0.997925286f, -0.065913353f, + 0.997825350f, -0.067443920f, 0.997723067f, -0.068974328f, 0.997618435f, + -0.070504573f, 0.997511456f, -0.072034653f, 0.997402130f, -0.073564564f, + 0.997290457f, -0.075094301f, 0.997176437f, -0.076623861f, 0.997060070f, + -0.078153242f, 0.996941358f, -0.079682438f, 0.996820299f, -0.081211447f, + 0.996696895f, -0.082740265f, 0.996571146f, -0.084268888f, 0.996443051f, + -0.085797312f, 0.996312612f, -0.087325535f, 0.996179829f, -0.088853553f, + 0.996044701f, -0.090381361f, 0.995907229f, -0.091908956f, 0.995767414f, + -0.093436336f, 0.995625256f, -0.094963495f, 0.995480755f, -0.096490431f, + 0.995333912f, -0.098017140f, 0.995184727f, -0.099543619f, 0.995033199f, + -0.101069863f, 0.994879331f, -0.102595869f, 0.994723121f, -0.104121634f, + 0.994564571f, -0.105647154f, 0.994403680f, -0.107172425f, 0.994240449f, + -0.108697444f, 0.994074879f, -0.110222207f, 0.993906970f, -0.111746711f, + 0.993736722f, -0.113270952f, 0.993564136f, -0.114794927f, 0.993389211f, + -0.116318631f, 0.993211949f, -0.117842062f, 0.993032350f, -0.119365215f, + 0.992850414f, -0.120888087f, 0.992666142f, -0.122410675f, 0.992479535f, + -0.123932975f, 0.992290591f, -0.125454983f, 0.992099313f, -0.126976696f, + 0.991905700f, -0.128498111f, 0.991709754f, -0.130019223f, 0.991511473f, + -0.131540029f, 0.991310860f, -0.133060525f, 0.991107914f, -0.134580709f, + 0.990902635f, -0.136100575f, 0.990695025f, -0.137620122f, 0.990485084f, + -0.139139344f, 0.990272812f, -0.140658239f, 0.990058210f, -0.142176804f, + 0.989841278f, -0.143695033f, 0.989622017f, -0.145212925f, 0.989400428f, + -0.146730474f, 0.989176510f, -0.148247679f, 0.988950265f, -0.149764535f, + 0.988721692f, -0.151281038f, 0.988490793f, -0.152797185f, 0.988257568f, + -0.154312973f, 0.988022017f, -0.155828398f, 0.987784142f, -0.157343456f, + 0.987543942f, -0.158858143f, 0.987301418f, -0.160372457f, 0.987056571f, + -0.161886394f, 0.986809402f, -0.163399949f, 0.986559910f, -0.164913120f, + 0.986308097f, -0.166425904f, 0.986053963f, -0.167938295f, 0.985797509f, + -0.169450291f, 0.985538735f, -0.170961889f, 0.985277642f, -0.172473084f, + 0.985014231f, -0.173983873f, 0.984748502f, -0.175494253f, 0.984480455f, + -0.177004220f, 0.984210092f, -0.178513771f, 0.983937413f, -0.180022901f, + 0.983662419f, -0.181531608f, 0.983385110f, -0.183039888f, 0.983105487f, + -0.184547737f, 0.982823551f, -0.186055152f, 0.982539302f, -0.187562129f, + 0.982252741f, -0.189068664f, 0.981963869f, -0.190574755f, 0.981672686f, + -0.192080397f, 0.981379193f, -0.193585587f, 0.981083391f, -0.195090322f, + 0.980785280f, -0.196594598f, 0.980484862f, -0.198098411f, 0.980182136f, + -0.199601758f, 0.979877104f, -0.201104635f, 0.979569766f, -0.202607039f, + 0.979260123f, -0.204108966f, 0.978948175f, -0.205610413f, 0.978633924f, + -0.207111376f, 0.978317371f, -0.208611852f, 0.977998515f, -0.210111837f, + 0.977677358f, -0.211611327f, 0.977353900f, -0.213110320f, 0.977028143f, + -0.214608811f, 0.976700086f, -0.216106797f, 0.976369731f, -0.217604275f, + 0.976037079f, -0.219101240f, 0.975702130f, -0.220597690f, 0.975364885f, + -0.222093621f, 0.975025345f, -0.223589029f, 0.974683511f, -0.225083911f, + 0.974339383f, -0.226578264f, 0.973992962f, -0.228072083f, 0.973644250f, + -0.229565366f, 0.973293246f, -0.231058108f, 0.972939952f, -0.232550307f, + 0.972584369f, -0.234041959f, 0.972226497f, -0.235533059f, 0.971866337f, + -0.237023606f, 0.971503891f, -0.238513595f, 0.971139158f, -0.240003022f, + 0.970772141f, -0.241491885f, 0.970402839f, -0.242980180f, 0.970031253f, + -0.244467903f, 0.969657385f, -0.245955050f, 0.969281235f, -0.247441619f, + 0.968902805f, -0.248927606f, 0.968522094f, -0.250413007f, 0.968139105f, + -0.251897818f, 0.967753837f, -0.253382037f, 0.967366292f, -0.254865660f, + 0.966976471f, -0.256348682f, 0.966584374f, -0.257831102f, 0.966190003f, + -0.259312915f, 0.965793359f, -0.260794118f, 0.965394442f, -0.262274707f, + 0.964993253f, -0.263754679f, 0.964589793f, -0.265234030f, 0.964184064f, + -0.266712757f, 0.963776066f, -0.268190857f, 0.963365800f, -0.269668326f, + 0.962953267f, -0.271145160f, 0.962538468f, -0.272621355f, 0.962121404f, + -0.274096910f, 0.961702077f, -0.275571819f, 0.961280486f, -0.277046080f, + 0.960856633f, -0.278519689f, 0.960430519f, -0.279992643f, 0.960002146f, + -0.281464938f, 0.959571513f, -0.282936570f, 0.959138622f, -0.284407537f, + 0.958703475f, -0.285877835f, 0.958266071f, -0.287347460f, 0.957826413f, + -0.288816408f, 0.957384501f, -0.290284677f, 0.956940336f, -0.291752263f, + 0.956493919f, -0.293219163f, 0.956045251f, -0.294685372f, 0.955594334f, + -0.296150888f, 0.955141168f, -0.297615707f, 0.954685755f, -0.299079826f, + 0.954228095f, -0.300543241f, 0.953768190f, -0.302005949f, 0.953306040f, + -0.303467947f, 0.952841648f, -0.304929230f, 0.952375013f, -0.306389795f, + 0.951906137f, -0.307849640f, 0.951435021f, -0.309308760f, 0.950961666f, + -0.310767153f, 0.950486074f, -0.312224814f, 0.950008245f, -0.313681740f, + 0.949528181f, -0.315137929f, 0.949045882f, -0.316593376f, 0.948561350f, + -0.318048077f, 0.948074586f, -0.319502031f, 0.947585591f, -0.320955232f, + 0.947094366f, -0.322407679f, 0.946600913f, -0.323859367f, 0.946105232f, + -0.325310292f, 0.945607325f, -0.326760452f, 0.945107193f, -0.328209844f, + 0.944604837f, -0.329658463f, 0.944100258f, -0.331106306f, 0.943593458f, + -0.332553370f, 0.943084437f, -0.333999651f, 0.942573198f, -0.335445147f, + 0.942059740f, -0.336889853f, 0.941544065f, -0.338333767f, 0.941026175f, + -0.339776884f, 0.940506071f, -0.341219202f, 0.939983753f, -0.342660717f, + 0.939459224f, -0.344101426f, 0.938932484f, -0.345541325f, 0.938403534f, + -0.346980411f, 0.937872376f, -0.348418680f, 0.937339012f, -0.349856130f, + 0.936803442f, -0.351292756f, 0.936265667f, -0.352728556f, 0.935725689f, + -0.354163525f, 0.935183510f, -0.355597662f, 0.934639130f, -0.357030961f, + 0.934092550f, -0.358463421f, 0.933543773f, -0.359895037f, 0.932992799f, + -0.361325806f, 0.932439629f, -0.362755724f, 0.931884266f, -0.364184790f, + 0.931326709f, -0.365612998f, 0.930766961f, -0.367040346f, 0.930205023f, + -0.368466830f, 0.929640896f, -0.369892447f, 0.929074581f, -0.371317194f, + 0.928506080f, -0.372741067f, 0.927935395f, -0.374164063f, 0.927362526f, + -0.375586178f, 0.926787474f, -0.377007410f, 0.926210242f, -0.378427755f, + 0.925630831f, -0.379847209f, 0.925049241f, -0.381265769f, 0.924465474f, + -0.382683432f, 0.923879533f, -0.384100195f, 0.923291417f, -0.385516054f, + 0.922701128f, -0.386931006f, 0.922108669f, -0.388345047f, 0.921514039f, + -0.389758174f, 0.920917242f, -0.391170384f, 0.920318277f, -0.392581674f, + 0.919717146f, -0.393992040f, 0.919113852f, -0.395401479f, 0.918508394f, + -0.396809987f, 0.917900776f, -0.398217562f, 0.917290997f, -0.399624200f, + 0.916679060f, -0.401029897f, 0.916064966f, -0.402434651f, 0.915448716f, + -0.403838458f, 0.914830312f, -0.405241314f, 0.914209756f, -0.406643217f, + 0.913587048f, -0.408044163f, 0.912962190f, -0.409444149f, 0.912335185f, + -0.410843171f, 0.911706032f, -0.412241227f, 0.911074734f, -0.413638312f, + 0.910441292f, -0.415034424f, 0.909805708f, -0.416429560f, 0.909167983f, + -0.417823716f, 0.908528119f, -0.419216888f, 0.907886116f, -0.420609074f, + 0.907241978f, -0.422000271f, 0.906595705f, -0.423390474f, 0.905947298f, + -0.424779681f, 0.905296759f, -0.426167889f, 0.904644091f, -0.427555093f, + 0.903989293f, -0.428941292f, 0.903332368f, -0.430326481f, 0.902673318f, + -0.431710658f, 0.902012144f, -0.433093819f, 0.901348847f, -0.434475961f, + 0.900683429f, -0.435857080f, 0.900015892f, -0.437237174f, 0.899346237f, + -0.438616239f, 0.898674466f, -0.439994271f, 0.898000580f, -0.441371269f, + 0.897324581f, -0.442747228f, 0.896646470f, -0.444122145f, 0.895966250f, + -0.445496017f, 0.895283921f, -0.446868840f, 0.894599486f, -0.448240612f, + 0.893912945f, -0.449611330f, 0.893224301f, -0.450980989f, 0.892533555f, + -0.452349587f, 0.891840709f, -0.453717121f, 0.891145765f, -0.455083587f, + 0.890448723f, -0.456448982f, 0.889749586f, -0.457813304f, 0.889048356f, + -0.459176548f, 0.888345033f, -0.460538711f, 0.887639620f, -0.461899791f, + 0.886932119f, -0.463259784f, 0.886222530f, -0.464618686f, 0.885510856f, + -0.465976496f, 0.884797098f, -0.467333209f, 0.884081259f, -0.468688822f, + 0.883363339f, -0.470043332f, 0.882643340f, -0.471396737f, 0.881921264f, + -0.472749032f, 0.881197113f, -0.474100215f, 0.880470889f, -0.475450282f, + 0.879742593f, -0.476799230f, 0.879012226f, -0.478147056f, 0.878279792f, + -0.479493758f, 0.877545290f, -0.480839331f, 0.876808724f, -0.482183772f, + 0.876070094f, -0.483527079f, 0.875329403f, -0.484869248f, 0.874586652f, + -0.486210276f, 0.873841843f, -0.487550160f, 0.873094978f, -0.488888897f, + 0.872346059f, -0.490226483f, 0.871595087f, -0.491562916f, 0.870842063f, + -0.492898192f, 0.870086991f, -0.494232309f, 0.869329871f, -0.495565262f, + 0.868570706f, -0.496897049f, 0.867809497f, -0.498227667f, 0.867046246f, + -0.499557113f, 0.866280954f, -0.500885383f, 0.865513624f, -0.502212474f, + 0.864744258f, -0.503538384f, 0.863972856f, -0.504863109f, 0.863199422f, + -0.506186645f, 0.862423956f, -0.507508991f, 0.861646461f, -0.508830143f, + 0.860866939f, -0.510150097f, 0.860085390f, -0.511468850f, 0.859301818f, + -0.512786401f, 0.858516224f, -0.514102744f, 0.857728610f, -0.515417878f, + 0.856938977f, -0.516731799f, 0.856147328f, -0.518044504f, 0.855353665f, + -0.519355990f, 0.854557988f, -0.520666254f, 0.853760301f, -0.521975293f, + 0.852960605f, -0.523283103f, 0.852158902f, -0.524589683f, 0.851355193f, + -0.525895027f, 0.850549481f, -0.527199135f, 0.849741768f, -0.528502002f, + 0.848932055f, -0.529803625f, 0.848120345f, -0.531104001f, 0.847306639f, + -0.532403128f, 0.846490939f, -0.533701002f, 0.845673247f, -0.534997620f, + 0.844853565f, -0.536292979f, 0.844031895f, -0.537587076f, 0.843208240f, + -0.538879909f, 0.842382600f, -0.540171473f, 0.841554977f, -0.541461766f, + 0.840725375f, -0.542750785f, 0.839893794f, -0.544038527f, 0.839060237f, + -0.545324988f, 0.838224706f, -0.546610167f, 0.837387202f, -0.547894059f, + 0.836547727f, -0.549176662f, 0.835706284f, -0.550457973f, 0.834862875f, + -0.551737988f, 0.834017501f, -0.553016706f, 0.833170165f, -0.554294121f, + 0.832320868f, -0.555570233f, 0.831469612f, -0.556845037f, 0.830616400f, + -0.558118531f, 0.829761234f, -0.559390712f, 0.828904115f, -0.560661576f, + 0.828045045f, -0.561931121f, 0.827184027f, -0.563199344f, 0.826321063f, + -0.564466242f, 0.825456154f, -0.565731811f, 0.824589303f, -0.566996049f, + 0.823720511f, -0.568258953f, 0.822849781f, -0.569520519f, 0.821977115f, + -0.570780746f, 0.821102515f, -0.572039629f, 0.820225983f, -0.573297167f, + 0.819347520f, -0.574553355f, 0.818467130f, -0.575808191f, 0.817584813f, + -0.577061673f, 0.816700573f, -0.578313796f, 0.815814411f, -0.579564559f, + 0.814926329f, -0.580813958f, 0.814036330f, -0.582061990f, 0.813144415f, + -0.583308653f, 0.812250587f, -0.584553943f, 0.811354847f, -0.585797857f, + 0.810457198f, -0.587040394f, 0.809557642f, -0.588281548f, 0.808656182f, + -0.589521319f, 0.807752818f, -0.590759702f, 0.806847554f, -0.591996695f, + 0.805940391f, -0.593232295f, 0.805031331f, -0.594466499f, 0.804120377f, + -0.595699304f, 0.803207531f, -0.596930708f, 0.802292796f, -0.598160707f, + 0.801376172f, -0.599389298f, 0.800457662f, -0.600616479f, 0.799537269f, + -0.601842247f, 0.798614995f, -0.603066599f, 0.797690841f, -0.604289531f, + 0.796764810f, -0.605511041f, 0.795836905f, -0.606731127f, 0.794907126f, + -0.607949785f, 0.793975478f, -0.609167012f, 0.793041960f, -0.610382806f, + 0.792106577f, -0.611597164f, 0.791169330f, -0.612810082f, 0.790230221f, + -0.614021559f, 0.789289253f, -0.615231591f, 0.788346428f, -0.616440175f, + 0.787401747f, -0.617647308f, 0.786455214f, -0.618852988f, 0.785506830f, + -0.620057212f, 0.784556597f, -0.621259977f, 0.783604519f, -0.622461279f, + 0.782650596f, -0.623661118f, 0.781694832f, -0.624859488f, 0.780737229f, + -0.626056388f, 0.779777788f, -0.627251815f, 0.778816512f, -0.628445767f, + 0.777853404f, -0.629638239f, 0.776888466f, -0.630829230f, 0.775921699f, + -0.632018736f, 0.774953107f, -0.633206755f, 0.773982691f, -0.634393284f, + 0.773010453f, -0.635578320f, 0.772036397f, -0.636761861f, 0.771060524f, + -0.637943904f, 0.770082837f, -0.639124445f, 0.769103338f, -0.640303482f, + 0.768122029f, -0.641481013f, 0.767138912f, -0.642657034f, 0.766153990f, + -0.643831543f, 0.765167266f, -0.645004537f, 0.764178741f, -0.646176013f, + 0.763188417f, -0.647345969f, 0.762196298f, -0.648514401f, 0.761202385f, + -0.649681307f, 0.760206682f, -0.650846685f, 0.759209189f, -0.652010531f, + 0.758209910f, -0.653172843f, 0.757208847f, -0.654333618f, 0.756206001f, + -0.655492853f, 0.755201377f, -0.656650546f, 0.754194975f, -0.657806693f, + 0.753186799f, -0.658961293f, 0.752176850f, -0.660114342f, 0.751165132f, + -0.661265838f, 0.750151646f, -0.662415778f, 0.749136395f, -0.663564159f, + 0.748119380f, -0.664710978f, 0.747100606f, -0.665856234f, 0.746080074f, + -0.666999922f, 0.745057785f, -0.668142041f, 0.744033744f, -0.669282588f, + 0.743007952f, -0.670421560f, 0.741980412f, -0.671558955f, 0.740951125f, + -0.672694769f, 0.739920095f, -0.673829000f, 0.738887324f, -0.674961646f, + 0.737852815f, -0.676092704f, 0.736816569f, -0.677222170f, 0.735778589f, + -0.678350043f, 0.734738878f, -0.679476320f, 0.733697438f, -0.680600998f, + 0.732654272f, -0.681724074f, 0.731609381f, -0.682845546f, 0.730562769f, + -0.683965412f, 0.729514438f, -0.685083668f, 0.728464390f, -0.686200312f, + 0.727412629f, -0.687315341f, 0.726359155f, -0.688428753f, 0.725303972f, + -0.689540545f, 0.724247083f, -0.690650714f, 0.723188489f, -0.691759258f, + 0.722128194f, -0.692866175f, 0.721066199f, -0.693971461f, 0.720002508f, + -0.695075114f, 0.718937122f, -0.696177131f, 0.717870045f, -0.697277511f, + 0.716801279f, -0.698376249f, 0.715730825f, -0.699473345f, 0.714658688f, + -0.700568794f, 0.713584869f, -0.701662595f, 0.712509371f, -0.702754744f, + 0.711432196f, -0.703845241f, 0.710353347f, -0.704934080f, 0.709272826f, + -0.706021261f, 0.708190637f, -0.707106781f, 0.707106781f, -0.708190637f, + 0.706021261f, -0.709272826f, 0.704934080f, -0.710353347f, 0.703845241f, + -0.711432196f, 0.702754744f, -0.712509371f, 0.701662595f, -0.713584869f, + 0.700568794f, -0.714658688f, 0.699473345f, -0.715730825f, 0.698376249f, + -0.716801279f, 0.697277511f, -0.717870045f, 0.696177131f, -0.718937122f, + 0.695075114f, -0.720002508f, 0.693971461f, -0.721066199f, 0.692866175f, + -0.722128194f, 0.691759258f, -0.723188489f, 0.690650714f, -0.724247083f, + 0.689540545f, -0.725303972f, 0.688428753f, -0.726359155f, 0.687315341f, + -0.727412629f, 0.686200312f, -0.728464390f, 0.685083668f, -0.729514438f, + 0.683965412f, -0.730562769f, 0.682845546f, -0.731609381f, 0.681724074f, + -0.732654272f, 0.680600998f, -0.733697438f, 0.679476320f, -0.734738878f, + 0.678350043f, -0.735778589f, 0.677222170f, -0.736816569f, 0.676092704f, + -0.737852815f, 0.674961646f, -0.738887324f, 0.673829000f, -0.739920095f, + 0.672694769f, -0.740951125f, 0.671558955f, -0.741980412f, 0.670421560f, + -0.743007952f, 0.669282588f, -0.744033744f, 0.668142041f, -0.745057785f, + 0.666999922f, -0.746080074f, 0.665856234f, -0.747100606f, 0.664710978f, + -0.748119380f, 0.663564159f, -0.749136395f, 0.662415778f, -0.750151646f, + 0.661265838f, -0.751165132f, 0.660114342f, -0.752176850f, 0.658961293f, + -0.753186799f, 0.657806693f, -0.754194975f, 0.656650546f, -0.755201377f, + 0.655492853f, -0.756206001f, 0.654333618f, -0.757208847f, 0.653172843f, + -0.758209910f, 0.652010531f, -0.759209189f, 0.650846685f, -0.760206682f, + 0.649681307f, -0.761202385f, 0.648514401f, -0.762196298f, 0.647345969f, + -0.763188417f, 0.646176013f, -0.764178741f, 0.645004537f, -0.765167266f, + 0.643831543f, -0.766153990f, 0.642657034f, -0.767138912f, 0.641481013f, + -0.768122029f, 0.640303482f, -0.769103338f, 0.639124445f, -0.770082837f, + 0.637943904f, -0.771060524f, 0.636761861f, -0.772036397f, 0.635578320f, + -0.773010453f, 0.634393284f, -0.773982691f, 0.633206755f, -0.774953107f, + 0.632018736f, -0.775921699f, 0.630829230f, -0.776888466f, 0.629638239f, + -0.777853404f, 0.628445767f, -0.778816512f, 0.627251815f, -0.779777788f, + 0.626056388f, -0.780737229f, 0.624859488f, -0.781694832f, 0.623661118f, + -0.782650596f, 0.622461279f, -0.783604519f, 0.621259977f, -0.784556597f, + 0.620057212f, -0.785506830f, 0.618852988f, -0.786455214f, 0.617647308f, + -0.787401747f, 0.616440175f, -0.788346428f, 0.615231591f, -0.789289253f, + 0.614021559f, -0.790230221f, 0.612810082f, -0.791169330f, 0.611597164f, + -0.792106577f, 0.610382806f, -0.793041960f, 0.609167012f, -0.793975478f, + 0.607949785f, -0.794907126f, 0.606731127f, -0.795836905f, 0.605511041f, + -0.796764810f, 0.604289531f, -0.797690841f, 0.603066599f, -0.798614995f, + 0.601842247f, -0.799537269f, 0.600616479f, -0.800457662f, 0.599389298f, + -0.801376172f, 0.598160707f, -0.802292796f, 0.596930708f, -0.803207531f, + 0.595699304f, -0.804120377f, 0.594466499f, -0.805031331f, 0.593232295f, + -0.805940391f, 0.591996695f, -0.806847554f, 0.590759702f, -0.807752818f, + 0.589521319f, -0.808656182f, 0.588281548f, -0.809557642f, 0.587040394f, + -0.810457198f, 0.585797857f, -0.811354847f, 0.584553943f, -0.812250587f, + 0.583308653f, -0.813144415f, 0.582061990f, -0.814036330f, 0.580813958f, + -0.814926329f, 0.579564559f, -0.815814411f, 0.578313796f, -0.816700573f, + 0.577061673f, -0.817584813f, 0.575808191f, -0.818467130f, 0.574553355f, + -0.819347520f, 0.573297167f, -0.820225983f, 0.572039629f, -0.821102515f, + 0.570780746f, -0.821977115f, 0.569520519f, -0.822849781f, 0.568258953f, + -0.823720511f, 0.566996049f, -0.824589303f, 0.565731811f, -0.825456154f, + 0.564466242f, -0.826321063f, 0.563199344f, -0.827184027f, 0.561931121f, + -0.828045045f, 0.560661576f, -0.828904115f, 0.559390712f, -0.829761234f, + 0.558118531f, -0.830616400f, 0.556845037f, -0.831469612f, 0.555570233f, + -0.832320868f, 0.554294121f, -0.833170165f, 0.553016706f, -0.834017501f, + 0.551737988f, -0.834862875f, 0.550457973f, -0.835706284f, 0.549176662f, + -0.836547727f, 0.547894059f, -0.837387202f, 0.546610167f, -0.838224706f, + 0.545324988f, -0.839060237f, 0.544038527f, -0.839893794f, 0.542750785f, + -0.840725375f, 0.541461766f, -0.841554977f, 0.540171473f, -0.842382600f, + 0.538879909f, -0.843208240f, 0.537587076f, -0.844031895f, 0.536292979f, + -0.844853565f, 0.534997620f, -0.845673247f, 0.533701002f, -0.846490939f, + 0.532403128f, -0.847306639f, 0.531104001f, -0.848120345f, 0.529803625f, + -0.848932055f, 0.528502002f, -0.849741768f, 0.527199135f, -0.850549481f, + 0.525895027f, -0.851355193f, 0.524589683f, -0.852158902f, 0.523283103f, + -0.852960605f, 0.521975293f, -0.853760301f, 0.520666254f, -0.854557988f, + 0.519355990f, -0.855353665f, 0.518044504f, -0.856147328f, 0.516731799f, + -0.856938977f, 0.515417878f, -0.857728610f, 0.514102744f, -0.858516224f, + 0.512786401f, -0.859301818f, 0.511468850f, -0.860085390f, 0.510150097f, + -0.860866939f, 0.508830143f, -0.861646461f, 0.507508991f, -0.862423956f, + 0.506186645f, -0.863199422f, 0.504863109f, -0.863972856f, 0.503538384f, + -0.864744258f, 0.502212474f, -0.865513624f, 0.500885383f, -0.866280954f, + 0.499557113f, -0.867046246f, 0.498227667f, -0.867809497f, 0.496897049f, + -0.868570706f, 0.495565262f, -0.869329871f, 0.494232309f, -0.870086991f, + 0.492898192f, -0.870842063f, 0.491562916f, -0.871595087f, 0.490226483f, + -0.872346059f, 0.488888897f, -0.873094978f, 0.487550160f, -0.873841843f, + 0.486210276f, -0.874586652f, 0.484869248f, -0.875329403f, 0.483527079f, + -0.876070094f, 0.482183772f, -0.876808724f, 0.480839331f, -0.877545290f, + 0.479493758f, -0.878279792f, 0.478147056f, -0.879012226f, 0.476799230f, + -0.879742593f, 0.475450282f, -0.880470889f, 0.474100215f, -0.881197113f, + 0.472749032f, -0.881921264f, 0.471396737f, -0.882643340f, 0.470043332f, + -0.883363339f, 0.468688822f, -0.884081259f, 0.467333209f, -0.884797098f, + 0.465976496f, -0.885510856f, 0.464618686f, -0.886222530f, 0.463259784f, + -0.886932119f, 0.461899791f, -0.887639620f, 0.460538711f, -0.888345033f, + 0.459176548f, -0.889048356f, 0.457813304f, -0.889749586f, 0.456448982f, + -0.890448723f, 0.455083587f, -0.891145765f, 0.453717121f, -0.891840709f, + 0.452349587f, -0.892533555f, 0.450980989f, -0.893224301f, 0.449611330f, + -0.893912945f, 0.448240612f, -0.894599486f, 0.446868840f, -0.895283921f, + 0.445496017f, -0.895966250f, 0.444122145f, -0.896646470f, 0.442747228f, + -0.897324581f, 0.441371269f, -0.898000580f, 0.439994271f, -0.898674466f, + 0.438616239f, -0.899346237f, 0.437237174f, -0.900015892f, 0.435857080f, + -0.900683429f, 0.434475961f, -0.901348847f, 0.433093819f, -0.902012144f, + 0.431710658f, -0.902673318f, 0.430326481f, -0.903332368f, 0.428941292f, + -0.903989293f, 0.427555093f, -0.904644091f, 0.426167889f, -0.905296759f, + 0.424779681f, -0.905947298f, 0.423390474f, -0.906595705f, 0.422000271f, + -0.907241978f, 0.420609074f, -0.907886116f, 0.419216888f, -0.908528119f, + 0.417823716f, -0.909167983f, 0.416429560f, -0.909805708f, 0.415034424f, + -0.910441292f, 0.413638312f, -0.911074734f, 0.412241227f, -0.911706032f, + 0.410843171f, -0.912335185f, 0.409444149f, -0.912962190f, 0.408044163f, + -0.913587048f, 0.406643217f, -0.914209756f, 0.405241314f, -0.914830312f, + 0.403838458f, -0.915448716f, 0.402434651f, -0.916064966f, 0.401029897f, + -0.916679060f, 0.399624200f, -0.917290997f, 0.398217562f, -0.917900776f, + 0.396809987f, -0.918508394f, 0.395401479f, -0.919113852f, 0.393992040f, + -0.919717146f, 0.392581674f, -0.920318277f, 0.391170384f, -0.920917242f, + 0.389758174f, -0.921514039f, 0.388345047f, -0.922108669f, 0.386931006f, + -0.922701128f, 0.385516054f, -0.923291417f, 0.384100195f, -0.923879533f, + 0.382683432f, -0.924465474f, 0.381265769f, -0.925049241f, 0.379847209f, + -0.925630831f, 0.378427755f, -0.926210242f, 0.377007410f, -0.926787474f, + 0.375586178f, -0.927362526f, 0.374164063f, -0.927935395f, 0.372741067f, + -0.928506080f, 0.371317194f, -0.929074581f, 0.369892447f, -0.929640896f, + 0.368466830f, -0.930205023f, 0.367040346f, -0.930766961f, 0.365612998f, + -0.931326709f, 0.364184790f, -0.931884266f, 0.362755724f, -0.932439629f, + 0.361325806f, -0.932992799f, 0.359895037f, -0.933543773f, 0.358463421f, + -0.934092550f, 0.357030961f, -0.934639130f, 0.355597662f, -0.935183510f, + 0.354163525f, -0.935725689f, 0.352728556f, -0.936265667f, 0.351292756f, + -0.936803442f, 0.349856130f, -0.937339012f, 0.348418680f, -0.937872376f, + 0.346980411f, -0.938403534f, 0.345541325f, -0.938932484f, 0.344101426f, + -0.939459224f, 0.342660717f, -0.939983753f, 0.341219202f, -0.940506071f, + 0.339776884f, -0.941026175f, 0.338333767f, -0.941544065f, 0.336889853f, + -0.942059740f, 0.335445147f, -0.942573198f, 0.333999651f, -0.943084437f, + 0.332553370f, -0.943593458f, 0.331106306f, -0.944100258f, 0.329658463f, + -0.944604837f, 0.328209844f, -0.945107193f, 0.326760452f, -0.945607325f, + 0.325310292f, -0.946105232f, 0.323859367f, -0.946600913f, 0.322407679f, + -0.947094366f, 0.320955232f, -0.947585591f, 0.319502031f, -0.948074586f, + 0.318048077f, -0.948561350f, 0.316593376f, -0.949045882f, 0.315137929f, + -0.949528181f, 0.313681740f, -0.950008245f, 0.312224814f, -0.950486074f, + 0.310767153f, -0.950961666f, 0.309308760f, -0.951435021f, 0.307849640f, + -0.951906137f, 0.306389795f, -0.952375013f, 0.304929230f, -0.952841648f, + 0.303467947f, -0.953306040f, 0.302005949f, -0.953768190f, 0.300543241f, + -0.954228095f, 0.299079826f, -0.954685755f, 0.297615707f, -0.955141168f, + 0.296150888f, -0.955594334f, 0.294685372f, -0.956045251f, 0.293219163f, + -0.956493919f, 0.291752263f, -0.956940336f, 0.290284677f, -0.957384501f, + 0.288816408f, -0.957826413f, 0.287347460f, -0.958266071f, 0.285877835f, + -0.958703475f, 0.284407537f, -0.959138622f, 0.282936570f, -0.959571513f, + 0.281464938f, -0.960002146f, 0.279992643f, -0.960430519f, 0.278519689f, + -0.960856633f, 0.277046080f, -0.961280486f, 0.275571819f, -0.961702077f, + 0.274096910f, -0.962121404f, 0.272621355f, -0.962538468f, 0.271145160f, + -0.962953267f, 0.269668326f, -0.963365800f, 0.268190857f, -0.963776066f, + 0.266712757f, -0.964184064f, 0.265234030f, -0.964589793f, 0.263754679f, + -0.964993253f, 0.262274707f, -0.965394442f, 0.260794118f, -0.965793359f, + 0.259312915f, -0.966190003f, 0.257831102f, -0.966584374f, 0.256348682f, + -0.966976471f, 0.254865660f, -0.967366292f, 0.253382037f, -0.967753837f, + 0.251897818f, -0.968139105f, 0.250413007f, -0.968522094f, 0.248927606f, + -0.968902805f, 0.247441619f, -0.969281235f, 0.245955050f, -0.969657385f, + 0.244467903f, -0.970031253f, 0.242980180f, -0.970402839f, 0.241491885f, + -0.970772141f, 0.240003022f, -0.971139158f, 0.238513595f, -0.971503891f, + 0.237023606f, -0.971866337f, 0.235533059f, -0.972226497f, 0.234041959f, + -0.972584369f, 0.232550307f, -0.972939952f, 0.231058108f, -0.973293246f, + 0.229565366f, -0.973644250f, 0.228072083f, -0.973992962f, 0.226578264f, + -0.974339383f, 0.225083911f, -0.974683511f, 0.223589029f, -0.975025345f, + 0.222093621f, -0.975364885f, 0.220597690f, -0.975702130f, 0.219101240f, + -0.976037079f, 0.217604275f, -0.976369731f, 0.216106797f, -0.976700086f, + 0.214608811f, -0.977028143f, 0.213110320f, -0.977353900f, 0.211611327f, + -0.977677358f, 0.210111837f, -0.977998515f, 0.208611852f, -0.978317371f, + 0.207111376f, -0.978633924f, 0.205610413f, -0.978948175f, 0.204108966f, + -0.979260123f, 0.202607039f, -0.979569766f, 0.201104635f, -0.979877104f, + 0.199601758f, -0.980182136f, 0.198098411f, -0.980484862f, 0.196594598f, + -0.980785280f, 0.195090322f, -0.981083391f, 0.193585587f, -0.981379193f, + 0.192080397f, -0.981672686f, 0.190574755f, -0.981963869f, 0.189068664f, + -0.982252741f, 0.187562129f, -0.982539302f, 0.186055152f, -0.982823551f, + 0.184547737f, -0.983105487f, 0.183039888f, -0.983385110f, 0.181531608f, + -0.983662419f, 0.180022901f, -0.983937413f, 0.178513771f, -0.984210092f, + 0.177004220f, -0.984480455f, 0.175494253f, -0.984748502f, 0.173983873f, + -0.985014231f, 0.172473084f, -0.985277642f, 0.170961889f, -0.985538735f, + 0.169450291f, -0.985797509f, 0.167938295f, -0.986053963f, 0.166425904f, + -0.986308097f, 0.164913120f, -0.986559910f, 0.163399949f, -0.986809402f, + 0.161886394f, -0.987056571f, 0.160372457f, -0.987301418f, 0.158858143f, + -0.987543942f, 0.157343456f, -0.987784142f, 0.155828398f, -0.988022017f, + 0.154312973f, -0.988257568f, 0.152797185f, -0.988490793f, 0.151281038f, + -0.988721692f, 0.149764535f, -0.988950265f, 0.148247679f, -0.989176510f, + 0.146730474f, -0.989400428f, 0.145212925f, -0.989622017f, 0.143695033f, + -0.989841278f, 0.142176804f, -0.990058210f, 0.140658239f, -0.990272812f, + 0.139139344f, -0.990485084f, 0.137620122f, -0.990695025f, 0.136100575f, + -0.990902635f, 0.134580709f, -0.991107914f, 0.133060525f, -0.991310860f, + 0.131540029f, -0.991511473f, 0.130019223f, -0.991709754f, 0.128498111f, + -0.991905700f, 0.126976696f, -0.992099313f, 0.125454983f, -0.992290591f, + 0.123932975f, -0.992479535f, 0.122410675f, -0.992666142f, 0.120888087f, + -0.992850414f, 0.119365215f, -0.993032350f, 0.117842062f, -0.993211949f, + 0.116318631f, -0.993389211f, 0.114794927f, -0.993564136f, 0.113270952f, + -0.993736722f, 0.111746711f, -0.993906970f, 0.110222207f, -0.994074879f, + 0.108697444f, -0.994240449f, 0.107172425f, -0.994403680f, 0.105647154f, + -0.994564571f, 0.104121634f, -0.994723121f, 0.102595869f, -0.994879331f, + 0.101069863f, -0.995033199f, 0.099543619f, -0.995184727f, 0.098017140f, + -0.995333912f, 0.096490431f, -0.995480755f, 0.094963495f, -0.995625256f, + 0.093436336f, -0.995767414f, 0.091908956f, -0.995907229f, 0.090381361f, + -0.996044701f, 0.088853553f, -0.996179829f, 0.087325535f, -0.996312612f, + 0.085797312f, -0.996443051f, 0.084268888f, -0.996571146f, 0.082740265f, + -0.996696895f, 0.081211447f, -0.996820299f, 0.079682438f, -0.996941358f, + 0.078153242f, -0.997060070f, 0.076623861f, -0.997176437f, 0.075094301f, + -0.997290457f, 0.073564564f, -0.997402130f, 0.072034653f, -0.997511456f, + 0.070504573f, -0.997618435f, 0.068974328f, -0.997723067f, 0.067443920f, + -0.997825350f, 0.065913353f, -0.997925286f, 0.064382631f, -0.998022874f, + 0.062851758f, -0.998118113f, 0.061320736f, -0.998211003f, 0.059789571f, + -0.998301545f, 0.058258265f, -0.998389737f, 0.056726821f, -0.998475581f, + 0.055195244f, -0.998559074f, 0.053663538f, -0.998640218f, 0.052131705f, + -0.998719012f, 0.050599749f, -0.998795456f, 0.049067674f, -0.998869550f, + 0.047535484f, -0.998941293f, 0.046003182f, -0.999010686f, 0.044470772f, + -0.999077728f, 0.042938257f, -0.999142419f, 0.041405641f, -0.999204759f, + 0.039872928f, -0.999264747f, 0.038340120f, -0.999322385f, 0.036807223f, + -0.999377670f, 0.035274239f, -0.999430605f, 0.033741172f, -0.999481187f, + 0.032208025f, -0.999529418f, 0.030674803f, -0.999575296f, 0.029141509f, + -0.999618822f, 0.027608146f, -0.999659997f, 0.026074718f, -0.999698819f, + 0.024541229f, -0.999735288f, 0.023007681f, -0.999769405f, 0.021474080f, + -0.999801170f, 0.019940429f, -0.999830582f, 0.018406730f, -0.999857641f, + 0.016872988f, -0.999882347f, 0.015339206f, -0.999904701f, 0.013805389f, + -0.999924702f, 0.012271538f, -0.999942350f, 0.010737659f, -0.999957645f, + 0.009203755f, -0.999970586f, 0.007669829f, -0.999981175f, 0.006135885f, + -0.999989411f, 0.004601926f, -0.999995294f, 0.003067957f, -0.999998823f, + 0.001533980f, -1.000000000f, 0.000000000f, -0.999998823f, -0.001533980f, + -0.999995294f, -0.003067957f, -0.999989411f, -0.004601926f, -0.999981175f, + -0.006135885f, -0.999970586f, -0.007669829f, -0.999957645f, -0.009203755f, + -0.999942350f, -0.010737659f, -0.999924702f, -0.012271538f, -0.999904701f, + -0.013805389f, -0.999882347f, -0.015339206f, -0.999857641f, -0.016872988f, + -0.999830582f, -0.018406730f, -0.999801170f, -0.019940429f, -0.999769405f, + -0.021474080f, -0.999735288f, -0.023007681f, -0.999698819f, -0.024541229f, + -0.999659997f, -0.026074718f, -0.999618822f, -0.027608146f, -0.999575296f, + -0.029141509f, -0.999529418f, -0.030674803f, -0.999481187f, -0.032208025f, + -0.999430605f, -0.033741172f, -0.999377670f, -0.035274239f, -0.999322385f, + -0.036807223f, -0.999264747f, -0.038340120f, -0.999204759f, -0.039872928f, + -0.999142419f, -0.041405641f, -0.999077728f, -0.042938257f, -0.999010686f, + -0.044470772f, -0.998941293f, -0.046003182f, -0.998869550f, -0.047535484f, + -0.998795456f, -0.049067674f, -0.998719012f, -0.050599749f, -0.998640218f, + -0.052131705f, -0.998559074f, -0.053663538f, -0.998475581f, -0.055195244f, + -0.998389737f, -0.056726821f, -0.998301545f, -0.058258265f, -0.998211003f, + -0.059789571f, -0.998118113f, -0.061320736f, -0.998022874f, -0.062851758f, + -0.997925286f, -0.064382631f, -0.997825350f, -0.065913353f, -0.997723067f, + -0.067443920f, -0.997618435f, -0.068974328f, -0.997511456f, -0.070504573f, + -0.997402130f, -0.072034653f, -0.997290457f, -0.073564564f, -0.997176437f, + -0.075094301f, -0.997060070f, -0.076623861f, -0.996941358f, -0.078153242f, + -0.996820299f, -0.079682438f, -0.996696895f, -0.081211447f, -0.996571146f, + -0.082740265f, -0.996443051f, -0.084268888f, -0.996312612f, -0.085797312f, + -0.996179829f, -0.087325535f, -0.996044701f, -0.088853553f, -0.995907229f, + -0.090381361f, -0.995767414f, -0.091908956f, -0.995625256f, -0.093436336f, + -0.995480755f, -0.094963495f, -0.995333912f, -0.096490431f, -0.995184727f, + -0.098017140f, -0.995033199f, -0.099543619f, -0.994879331f, -0.101069863f, + -0.994723121f, -0.102595869f, -0.994564571f, -0.104121634f, -0.994403680f, + -0.105647154f, -0.994240449f, -0.107172425f, -0.994074879f, -0.108697444f, + -0.993906970f, -0.110222207f, -0.993736722f, -0.111746711f, -0.993564136f, + -0.113270952f, -0.993389211f, -0.114794927f, -0.993211949f, -0.116318631f, + -0.993032350f, -0.117842062f, -0.992850414f, -0.119365215f, -0.992666142f, + -0.120888087f, -0.992479535f, -0.122410675f, -0.992290591f, -0.123932975f, + -0.992099313f, -0.125454983f, -0.991905700f, -0.126976696f, -0.991709754f, + -0.128498111f, -0.991511473f, -0.130019223f, -0.991310860f, -0.131540029f, + -0.991107914f, -0.133060525f, -0.990902635f, -0.134580709f, -0.990695025f, + -0.136100575f, -0.990485084f, -0.137620122f, -0.990272812f, -0.139139344f, + -0.990058210f, -0.140658239f, -0.989841278f, -0.142176804f, -0.989622017f, + -0.143695033f, -0.989400428f, -0.145212925f, -0.989176510f, -0.146730474f, + -0.988950265f, -0.148247679f, -0.988721692f, -0.149764535f, -0.988490793f, + -0.151281038f, -0.988257568f, -0.152797185f, -0.988022017f, -0.154312973f, + -0.987784142f, -0.155828398f, -0.987543942f, -0.157343456f, -0.987301418f, + -0.158858143f, -0.987056571f, -0.160372457f, -0.986809402f, -0.161886394f, + -0.986559910f, -0.163399949f, -0.986308097f, -0.164913120f, -0.986053963f, + -0.166425904f, -0.985797509f, -0.167938295f, -0.985538735f, -0.169450291f, + -0.985277642f, -0.170961889f, -0.985014231f, -0.172473084f, -0.984748502f, + -0.173983873f, -0.984480455f, -0.175494253f, -0.984210092f, -0.177004220f, + -0.983937413f, -0.178513771f, -0.983662419f, -0.180022901f, -0.983385110f, + -0.181531608f, -0.983105487f, -0.183039888f, -0.982823551f, -0.184547737f, + -0.982539302f, -0.186055152f, -0.982252741f, -0.187562129f, -0.981963869f, + -0.189068664f, -0.981672686f, -0.190574755f, -0.981379193f, -0.192080397f, + -0.981083391f, -0.193585587f, -0.980785280f, -0.195090322f, -0.980484862f, + -0.196594598f, -0.980182136f, -0.198098411f, -0.979877104f, -0.199601758f, + -0.979569766f, -0.201104635f, -0.979260123f, -0.202607039f, -0.978948175f, + -0.204108966f, -0.978633924f, -0.205610413f, -0.978317371f, -0.207111376f, + -0.977998515f, -0.208611852f, -0.977677358f, -0.210111837f, -0.977353900f, + -0.211611327f, -0.977028143f, -0.213110320f, -0.976700086f, -0.214608811f, + -0.976369731f, -0.216106797f, -0.976037079f, -0.217604275f, -0.975702130f, + -0.219101240f, -0.975364885f, -0.220597690f, -0.975025345f, -0.222093621f, + -0.974683511f, -0.223589029f, -0.974339383f, -0.225083911f, -0.973992962f, + -0.226578264f, -0.973644250f, -0.228072083f, -0.973293246f, -0.229565366f, + -0.972939952f, -0.231058108f, -0.972584369f, -0.232550307f, -0.972226497f, + -0.234041959f, -0.971866337f, -0.235533059f, -0.971503891f, -0.237023606f, + -0.971139158f, -0.238513595f, -0.970772141f, -0.240003022f, -0.970402839f, + -0.241491885f, -0.970031253f, -0.242980180f, -0.969657385f, -0.244467903f, + -0.969281235f, -0.245955050f, -0.968902805f, -0.247441619f, -0.968522094f, + -0.248927606f, -0.968139105f, -0.250413007f, -0.967753837f, -0.251897818f, + -0.967366292f, -0.253382037f, -0.966976471f, -0.254865660f, -0.966584374f, + -0.256348682f, -0.966190003f, -0.257831102f, -0.965793359f, -0.259312915f, + -0.965394442f, -0.260794118f, -0.964993253f, -0.262274707f, -0.964589793f, + -0.263754679f, -0.964184064f, -0.265234030f, -0.963776066f, -0.266712757f, + -0.963365800f, -0.268190857f, -0.962953267f, -0.269668326f, -0.962538468f, + -0.271145160f, -0.962121404f, -0.272621355f, -0.961702077f, -0.274096910f, + -0.961280486f, -0.275571819f, -0.960856633f, -0.277046080f, -0.960430519f, + -0.278519689f, -0.960002146f, -0.279992643f, -0.959571513f, -0.281464938f, + -0.959138622f, -0.282936570f, -0.958703475f, -0.284407537f, -0.958266071f, + -0.285877835f, -0.957826413f, -0.287347460f, -0.957384501f, -0.288816408f, + -0.956940336f, -0.290284677f, -0.956493919f, -0.291752263f, -0.956045251f, + -0.293219163f, -0.955594334f, -0.294685372f, -0.955141168f, -0.296150888f, + -0.954685755f, -0.297615707f, -0.954228095f, -0.299079826f, -0.953768190f, + -0.300543241f, -0.953306040f, -0.302005949f, -0.952841648f, -0.303467947f, + -0.952375013f, -0.304929230f, -0.951906137f, -0.306389795f, -0.951435021f, + -0.307849640f, -0.950961666f, -0.309308760f, -0.950486074f, -0.310767153f, + -0.950008245f, -0.312224814f, -0.949528181f, -0.313681740f, -0.949045882f, + -0.315137929f, -0.948561350f, -0.316593376f, -0.948074586f, -0.318048077f, + -0.947585591f, -0.319502031f, -0.947094366f, -0.320955232f, -0.946600913f, + -0.322407679f, -0.946105232f, -0.323859367f, -0.945607325f, -0.325310292f, + -0.945107193f, -0.326760452f, -0.944604837f, -0.328209844f, -0.944100258f, + -0.329658463f, -0.943593458f, -0.331106306f, -0.943084437f, -0.332553370f, + -0.942573198f, -0.333999651f, -0.942059740f, -0.335445147f, -0.941544065f, + -0.336889853f, -0.941026175f, -0.338333767f, -0.940506071f, -0.339776884f, + -0.939983753f, -0.341219202f, -0.939459224f, -0.342660717f, -0.938932484f, + -0.344101426f, -0.938403534f, -0.345541325f, -0.937872376f, -0.346980411f, + -0.937339012f, -0.348418680f, -0.936803442f, -0.349856130f, -0.936265667f, + -0.351292756f, -0.935725689f, -0.352728556f, -0.935183510f, -0.354163525f, + -0.934639130f, -0.355597662f, -0.934092550f, -0.357030961f, -0.933543773f, + -0.358463421f, -0.932992799f, -0.359895037f, -0.932439629f, -0.361325806f, + -0.931884266f, -0.362755724f, -0.931326709f, -0.364184790f, -0.930766961f, + -0.365612998f, -0.930205023f, -0.367040346f, -0.929640896f, -0.368466830f, + -0.929074581f, -0.369892447f, -0.928506080f, -0.371317194f, -0.927935395f, + -0.372741067f, -0.927362526f, -0.374164063f, -0.926787474f, -0.375586178f, + -0.926210242f, -0.377007410f, -0.925630831f, -0.378427755f, -0.925049241f, + -0.379847209f, -0.924465474f, -0.381265769f, -0.923879533f, -0.382683432f, + -0.923291417f, -0.384100195f, -0.922701128f, -0.385516054f, -0.922108669f, + -0.386931006f, -0.921514039f, -0.388345047f, -0.920917242f, -0.389758174f, + -0.920318277f, -0.391170384f, -0.919717146f, -0.392581674f, -0.919113852f, + -0.393992040f, -0.918508394f, -0.395401479f, -0.917900776f, -0.396809987f, + -0.917290997f, -0.398217562f, -0.916679060f, -0.399624200f, -0.916064966f, + -0.401029897f, -0.915448716f, -0.402434651f, -0.914830312f, -0.403838458f, + -0.914209756f, -0.405241314f, -0.913587048f, -0.406643217f, -0.912962190f, + -0.408044163f, -0.912335185f, -0.409444149f, -0.911706032f, -0.410843171f, + -0.911074734f, -0.412241227f, -0.910441292f, -0.413638312f, -0.909805708f, + -0.415034424f, -0.909167983f, -0.416429560f, -0.908528119f, -0.417823716f, + -0.907886116f, -0.419216888f, -0.907241978f, -0.420609074f, -0.906595705f, + -0.422000271f, -0.905947298f, -0.423390474f, -0.905296759f, -0.424779681f, + -0.904644091f, -0.426167889f, -0.903989293f, -0.427555093f, -0.903332368f, + -0.428941292f, -0.902673318f, -0.430326481f, -0.902012144f, -0.431710658f, + -0.901348847f, -0.433093819f, -0.900683429f, -0.434475961f, -0.900015892f, + -0.435857080f, -0.899346237f, -0.437237174f, -0.898674466f, -0.438616239f, + -0.898000580f, -0.439994271f, -0.897324581f, -0.441371269f, -0.896646470f, + -0.442747228f, -0.895966250f, -0.444122145f, -0.895283921f, -0.445496017f, + -0.894599486f, -0.446868840f, -0.893912945f, -0.448240612f, -0.893224301f, + -0.449611330f, -0.892533555f, -0.450980989f, -0.891840709f, -0.452349587f, + -0.891145765f, -0.453717121f, -0.890448723f, -0.455083587f, -0.889749586f, + -0.456448982f, -0.889048356f, -0.457813304f, -0.888345033f, -0.459176548f, + -0.887639620f, -0.460538711f, -0.886932119f, -0.461899791f, -0.886222530f, + -0.463259784f, -0.885510856f, -0.464618686f, -0.884797098f, -0.465976496f, + -0.884081259f, -0.467333209f, -0.883363339f, -0.468688822f, -0.882643340f, + -0.470043332f, -0.881921264f, -0.471396737f, -0.881197113f, -0.472749032f, + -0.880470889f, -0.474100215f, -0.879742593f, -0.475450282f, -0.879012226f, + -0.476799230f, -0.878279792f, -0.478147056f, -0.877545290f, -0.479493758f, + -0.876808724f, -0.480839331f, -0.876070094f, -0.482183772f, -0.875329403f, + -0.483527079f, -0.874586652f, -0.484869248f, -0.873841843f, -0.486210276f, + -0.873094978f, -0.487550160f, -0.872346059f, -0.488888897f, -0.871595087f, + -0.490226483f, -0.870842063f, -0.491562916f, -0.870086991f, -0.492898192f, + -0.869329871f, -0.494232309f, -0.868570706f, -0.495565262f, -0.867809497f, + -0.496897049f, -0.867046246f, -0.498227667f, -0.866280954f, -0.499557113f, + -0.865513624f, -0.500885383f, -0.864744258f, -0.502212474f, -0.863972856f, + -0.503538384f, -0.863199422f, -0.504863109f, -0.862423956f, -0.506186645f, + -0.861646461f, -0.507508991f, -0.860866939f, -0.508830143f, -0.860085390f, + -0.510150097f, -0.859301818f, -0.511468850f, -0.858516224f, -0.512786401f, + -0.857728610f, -0.514102744f, -0.856938977f, -0.515417878f, -0.856147328f, + -0.516731799f, -0.855353665f, -0.518044504f, -0.854557988f, -0.519355990f, + -0.853760301f, -0.520666254f, -0.852960605f, -0.521975293f, -0.852158902f, + -0.523283103f, -0.851355193f, -0.524589683f, -0.850549481f, -0.525895027f, + -0.849741768f, -0.527199135f, -0.848932055f, -0.528502002f, -0.848120345f, + -0.529803625f, -0.847306639f, -0.531104001f, -0.846490939f, -0.532403128f, + -0.845673247f, -0.533701002f, -0.844853565f, -0.534997620f, -0.844031895f, + -0.536292979f, -0.843208240f, -0.537587076f, -0.842382600f, -0.538879909f, + -0.841554977f, -0.540171473f, -0.840725375f, -0.541461766f, -0.839893794f, + -0.542750785f, -0.839060237f, -0.544038527f, -0.838224706f, -0.545324988f, + -0.837387202f, -0.546610167f, -0.836547727f, -0.547894059f, -0.835706284f, + -0.549176662f, -0.834862875f, -0.550457973f, -0.834017501f, -0.551737988f, + -0.833170165f, -0.553016706f, -0.832320868f, -0.554294121f, -0.831469612f, + -0.555570233f, -0.830616400f, -0.556845037f, -0.829761234f, -0.558118531f, + -0.828904115f, -0.559390712f, -0.828045045f, -0.560661576f, -0.827184027f, + -0.561931121f, -0.826321063f, -0.563199344f, -0.825456154f, -0.564466242f, + -0.824589303f, -0.565731811f, -0.823720511f, -0.566996049f, -0.822849781f, + -0.568258953f, -0.821977115f, -0.569520519f, -0.821102515f, -0.570780746f, + -0.820225983f, -0.572039629f, -0.819347520f, -0.573297167f, -0.818467130f, + -0.574553355f, -0.817584813f, -0.575808191f, -0.816700573f, -0.577061673f, + -0.815814411f, -0.578313796f, -0.814926329f, -0.579564559f, -0.814036330f, + -0.580813958f, -0.813144415f, -0.582061990f, -0.812250587f, -0.583308653f, + -0.811354847f, -0.584553943f, -0.810457198f, -0.585797857f, -0.809557642f, + -0.587040394f, -0.808656182f, -0.588281548f, -0.807752818f, -0.589521319f, + -0.806847554f, -0.590759702f, -0.805940391f, -0.591996695f, -0.805031331f, + -0.593232295f, -0.804120377f, -0.594466499f, -0.803207531f, -0.595699304f, + -0.802292796f, -0.596930708f, -0.801376172f, -0.598160707f, -0.800457662f, + -0.599389298f, -0.799537269f, -0.600616479f, -0.798614995f, -0.601842247f, + -0.797690841f, -0.603066599f, -0.796764810f, -0.604289531f, -0.795836905f, + -0.605511041f, -0.794907126f, -0.606731127f, -0.793975478f, -0.607949785f, + -0.793041960f, -0.609167012f, -0.792106577f, -0.610382806f, -0.791169330f, + -0.611597164f, -0.790230221f, -0.612810082f, -0.789289253f, -0.614021559f, + -0.788346428f, -0.615231591f, -0.787401747f, -0.616440175f, -0.786455214f, + -0.617647308f, -0.785506830f, -0.618852988f, -0.784556597f, -0.620057212f, + -0.783604519f, -0.621259977f, -0.782650596f, -0.622461279f, -0.781694832f, + -0.623661118f, -0.780737229f, -0.624859488f, -0.779777788f, -0.626056388f, + -0.778816512f, -0.627251815f, -0.777853404f, -0.628445767f, -0.776888466f, + -0.629638239f, -0.775921699f, -0.630829230f, -0.774953107f, -0.632018736f, + -0.773982691f, -0.633206755f, -0.773010453f, -0.634393284f, -0.772036397f, + -0.635578320f, -0.771060524f, -0.636761861f, -0.770082837f, -0.637943904f, + -0.769103338f, -0.639124445f, -0.768122029f, -0.640303482f, -0.767138912f, + -0.641481013f, -0.766153990f, -0.642657034f, -0.765167266f, -0.643831543f, + -0.764178741f, -0.645004537f, -0.763188417f, -0.646176013f, -0.762196298f, + -0.647345969f, -0.761202385f, -0.648514401f, -0.760206682f, -0.649681307f, + -0.759209189f, -0.650846685f, -0.758209910f, -0.652010531f, -0.757208847f, + -0.653172843f, -0.756206001f, -0.654333618f, -0.755201377f, -0.655492853f, + -0.754194975f, -0.656650546f, -0.753186799f, -0.657806693f, -0.752176850f, + -0.658961293f, -0.751165132f, -0.660114342f, -0.750151646f, -0.661265838f, + -0.749136395f, -0.662415778f, -0.748119380f, -0.663564159f, -0.747100606f, + -0.664710978f, -0.746080074f, -0.665856234f, -0.745057785f, -0.666999922f, + -0.744033744f, -0.668142041f, -0.743007952f, -0.669282588f, -0.741980412f, + -0.670421560f, -0.740951125f, -0.671558955f, -0.739920095f, -0.672694769f, + -0.738887324f, -0.673829000f, -0.737852815f, -0.674961646f, -0.736816569f, + -0.676092704f, -0.735778589f, -0.677222170f, -0.734738878f, -0.678350043f, + -0.733697438f, -0.679476320f, -0.732654272f, -0.680600998f, -0.731609381f, + -0.681724074f, -0.730562769f, -0.682845546f, -0.729514438f, -0.683965412f, + -0.728464390f, -0.685083668f, -0.727412629f, -0.686200312f, -0.726359155f, + -0.687315341f, -0.725303972f, -0.688428753f, -0.724247083f, -0.689540545f, + -0.723188489f, -0.690650714f, -0.722128194f, -0.691759258f, -0.721066199f, + -0.692866175f, -0.720002508f, -0.693971461f, -0.718937122f, -0.695075114f, + -0.717870045f, -0.696177131f, -0.716801279f, -0.697277511f, -0.715730825f, + -0.698376249f, -0.714658688f, -0.699473345f, -0.713584869f, -0.700568794f, + -0.712509371f, -0.701662595f, -0.711432196f, -0.702754744f, -0.710353347f, + -0.703845241f, -0.709272826f, -0.704934080f, -0.708190637f, -0.706021261f, + -0.707106781f, -0.707106781f, -0.706021261f, -0.708190637f, -0.704934080f, + -0.709272826f, -0.703845241f, -0.710353347f, -0.702754744f, -0.711432196f, + -0.701662595f, -0.712509371f, -0.700568794f, -0.713584869f, -0.699473345f, + -0.714658688f, -0.698376249f, -0.715730825f, -0.697277511f, -0.716801279f, + -0.696177131f, -0.717870045f, -0.695075114f, -0.718937122f, -0.693971461f, + -0.720002508f, -0.692866175f, -0.721066199f, -0.691759258f, -0.722128194f, + -0.690650714f, -0.723188489f, -0.689540545f, -0.724247083f, -0.688428753f, + -0.725303972f, -0.687315341f, -0.726359155f, -0.686200312f, -0.727412629f, + -0.685083668f, -0.728464390f, -0.683965412f, -0.729514438f, -0.682845546f, + -0.730562769f, -0.681724074f, -0.731609381f, -0.680600998f, -0.732654272f, + -0.679476320f, -0.733697438f, -0.678350043f, -0.734738878f, -0.677222170f, + -0.735778589f, -0.676092704f, -0.736816569f, -0.674961646f, -0.737852815f, + -0.673829000f, -0.738887324f, -0.672694769f, -0.739920095f, -0.671558955f, + -0.740951125f, -0.670421560f, -0.741980412f, -0.669282588f, -0.743007952f, + -0.668142041f, -0.744033744f, -0.666999922f, -0.745057785f, -0.665856234f, + -0.746080074f, -0.664710978f, -0.747100606f, -0.663564159f, -0.748119380f, + -0.662415778f, -0.749136395f, -0.661265838f, -0.750151646f, -0.660114342f, + -0.751165132f, -0.658961293f, -0.752176850f, -0.657806693f, -0.753186799f, + -0.656650546f, -0.754194975f, -0.655492853f, -0.755201377f, -0.654333618f, + -0.756206001f, -0.653172843f, -0.757208847f, -0.652010531f, -0.758209910f, + -0.650846685f, -0.759209189f, -0.649681307f, -0.760206682f, -0.648514401f, + -0.761202385f, -0.647345969f, -0.762196298f, -0.646176013f, -0.763188417f, + -0.645004537f, -0.764178741f, -0.643831543f, -0.765167266f, -0.642657034f, + -0.766153990f, -0.641481013f, -0.767138912f, -0.640303482f, -0.768122029f, + -0.639124445f, -0.769103338f, -0.637943904f, -0.770082837f, -0.636761861f, + -0.771060524f, -0.635578320f, -0.772036397f, -0.634393284f, -0.773010453f, + -0.633206755f, -0.773982691f, -0.632018736f, -0.774953107f, -0.630829230f, + -0.775921699f, -0.629638239f, -0.776888466f, -0.628445767f, -0.777853404f, + -0.627251815f, -0.778816512f, -0.626056388f, -0.779777788f, -0.624859488f, + -0.780737229f, -0.623661118f, -0.781694832f, -0.622461279f, -0.782650596f, + -0.621259977f, -0.783604519f, -0.620057212f, -0.784556597f, -0.618852988f, + -0.785506830f, -0.617647308f, -0.786455214f, -0.616440175f, -0.787401747f, + -0.615231591f, -0.788346428f, -0.614021559f, -0.789289253f, -0.612810082f, + -0.790230221f, -0.611597164f, -0.791169330f, -0.610382806f, -0.792106577f, + -0.609167012f, -0.793041960f, -0.607949785f, -0.793975478f, -0.606731127f, + -0.794907126f, -0.605511041f, -0.795836905f, -0.604289531f, -0.796764810f, + -0.603066599f, -0.797690841f, -0.601842247f, -0.798614995f, -0.600616479f, + -0.799537269f, -0.599389298f, -0.800457662f, -0.598160707f, -0.801376172f, + -0.596930708f, -0.802292796f, -0.595699304f, -0.803207531f, -0.594466499f, + -0.804120377f, -0.593232295f, -0.805031331f, -0.591996695f, -0.805940391f, + -0.590759702f, -0.806847554f, -0.589521319f, -0.807752818f, -0.588281548f, + -0.808656182f, -0.587040394f, -0.809557642f, -0.585797857f, -0.810457198f, + -0.584553943f, -0.811354847f, -0.583308653f, -0.812250587f, -0.582061990f, + -0.813144415f, -0.580813958f, -0.814036330f, -0.579564559f, -0.814926329f, + -0.578313796f, -0.815814411f, -0.577061673f, -0.816700573f, -0.575808191f, + -0.817584813f, -0.574553355f, -0.818467130f, -0.573297167f, -0.819347520f, + -0.572039629f, -0.820225983f, -0.570780746f, -0.821102515f, -0.569520519f, + -0.821977115f, -0.568258953f, -0.822849781f, -0.566996049f, -0.823720511f, + -0.565731811f, -0.824589303f, -0.564466242f, -0.825456154f, -0.563199344f, + -0.826321063f, -0.561931121f, -0.827184027f, -0.560661576f, -0.828045045f, + -0.559390712f, -0.828904115f, -0.558118531f, -0.829761234f, -0.556845037f, + -0.830616400f, -0.555570233f, -0.831469612f, -0.554294121f, -0.832320868f, + -0.553016706f, -0.833170165f, -0.551737988f, -0.834017501f, -0.550457973f, + -0.834862875f, -0.549176662f, -0.835706284f, -0.547894059f, -0.836547727f, + -0.546610167f, -0.837387202f, -0.545324988f, -0.838224706f, -0.544038527f, + -0.839060237f, -0.542750785f, -0.839893794f, -0.541461766f, -0.840725375f, + -0.540171473f, -0.841554977f, -0.538879909f, -0.842382600f, -0.537587076f, + -0.843208240f, -0.536292979f, -0.844031895f, -0.534997620f, -0.844853565f, + -0.533701002f, -0.845673247f, -0.532403128f, -0.846490939f, -0.531104001f, + -0.847306639f, -0.529803625f, -0.848120345f, -0.528502002f, -0.848932055f, + -0.527199135f, -0.849741768f, -0.525895027f, -0.850549481f, -0.524589683f, + -0.851355193f, -0.523283103f, -0.852158902f, -0.521975293f, -0.852960605f, + -0.520666254f, -0.853760301f, -0.519355990f, -0.854557988f, -0.518044504f, + -0.855353665f, -0.516731799f, -0.856147328f, -0.515417878f, -0.856938977f, + -0.514102744f, -0.857728610f, -0.512786401f, -0.858516224f, -0.511468850f, + -0.859301818f, -0.510150097f, -0.860085390f, -0.508830143f, -0.860866939f, + -0.507508991f, -0.861646461f, -0.506186645f, -0.862423956f, -0.504863109f, + -0.863199422f, -0.503538384f, -0.863972856f, -0.502212474f, -0.864744258f, + -0.500885383f, -0.865513624f, -0.499557113f, -0.866280954f, -0.498227667f, + -0.867046246f, -0.496897049f, -0.867809497f, -0.495565262f, -0.868570706f, + -0.494232309f, -0.869329871f, -0.492898192f, -0.870086991f, -0.491562916f, + -0.870842063f, -0.490226483f, -0.871595087f, -0.488888897f, -0.872346059f, + -0.487550160f, -0.873094978f, -0.486210276f, -0.873841843f, -0.484869248f, + -0.874586652f, -0.483527079f, -0.875329403f, -0.482183772f, -0.876070094f, + -0.480839331f, -0.876808724f, -0.479493758f, -0.877545290f, -0.478147056f, + -0.878279792f, -0.476799230f, -0.879012226f, -0.475450282f, -0.879742593f, + -0.474100215f, -0.880470889f, -0.472749032f, -0.881197113f, -0.471396737f, + -0.881921264f, -0.470043332f, -0.882643340f, -0.468688822f, -0.883363339f, + -0.467333209f, -0.884081259f, -0.465976496f, -0.884797098f, -0.464618686f, + -0.885510856f, -0.463259784f, -0.886222530f, -0.461899791f, -0.886932119f, + -0.460538711f, -0.887639620f, -0.459176548f, -0.888345033f, -0.457813304f, + -0.889048356f, -0.456448982f, -0.889749586f, -0.455083587f, -0.890448723f, + -0.453717121f, -0.891145765f, -0.452349587f, -0.891840709f, -0.450980989f, + -0.892533555f, -0.449611330f, -0.893224301f, -0.448240612f, -0.893912945f, + -0.446868840f, -0.894599486f, -0.445496017f, -0.895283921f, -0.444122145f, + -0.895966250f, -0.442747228f, -0.896646470f, -0.441371269f, -0.897324581f, + -0.439994271f, -0.898000580f, -0.438616239f, -0.898674466f, -0.437237174f, + -0.899346237f, -0.435857080f, -0.900015892f, -0.434475961f, -0.900683429f, + -0.433093819f, -0.901348847f, -0.431710658f, -0.902012144f, -0.430326481f, + -0.902673318f, -0.428941292f, -0.903332368f, -0.427555093f, -0.903989293f, + -0.426167889f, -0.904644091f, -0.424779681f, -0.905296759f, -0.423390474f, + -0.905947298f, -0.422000271f, -0.906595705f, -0.420609074f, -0.907241978f, + -0.419216888f, -0.907886116f, -0.417823716f, -0.908528119f, -0.416429560f, + -0.909167983f, -0.415034424f, -0.909805708f, -0.413638312f, -0.910441292f, + -0.412241227f, -0.911074734f, -0.410843171f, -0.911706032f, -0.409444149f, + -0.912335185f, -0.408044163f, -0.912962190f, -0.406643217f, -0.913587048f, + -0.405241314f, -0.914209756f, -0.403838458f, -0.914830312f, -0.402434651f, + -0.915448716f, -0.401029897f, -0.916064966f, -0.399624200f, -0.916679060f, + -0.398217562f, -0.917290997f, -0.396809987f, -0.917900776f, -0.395401479f, + -0.918508394f, -0.393992040f, -0.919113852f, -0.392581674f, -0.919717146f, + -0.391170384f, -0.920318277f, -0.389758174f, -0.920917242f, -0.388345047f, + -0.921514039f, -0.386931006f, -0.922108669f, -0.385516054f, -0.922701128f, + -0.384100195f, -0.923291417f, -0.382683432f, -0.923879533f, -0.381265769f, + -0.924465474f, -0.379847209f, -0.925049241f, -0.378427755f, -0.925630831f, + -0.377007410f, -0.926210242f, -0.375586178f, -0.926787474f, -0.374164063f, + -0.927362526f, -0.372741067f, -0.927935395f, -0.371317194f, -0.928506080f, + -0.369892447f, -0.929074581f, -0.368466830f, -0.929640896f, -0.367040346f, + -0.930205023f, -0.365612998f, -0.930766961f, -0.364184790f, -0.931326709f, + -0.362755724f, -0.931884266f, -0.361325806f, -0.932439629f, -0.359895037f, + -0.932992799f, -0.358463421f, -0.933543773f, -0.357030961f, -0.934092550f, + -0.355597662f, -0.934639130f, -0.354163525f, -0.935183510f, -0.352728556f, + -0.935725689f, -0.351292756f, -0.936265667f, -0.349856130f, -0.936803442f, + -0.348418680f, -0.937339012f, -0.346980411f, -0.937872376f, -0.345541325f, + -0.938403534f, -0.344101426f, -0.938932484f, -0.342660717f, -0.939459224f, + -0.341219202f, -0.939983753f, -0.339776884f, -0.940506071f, -0.338333767f, + -0.941026175f, -0.336889853f, -0.941544065f, -0.335445147f, -0.942059740f, + -0.333999651f, -0.942573198f, -0.332553370f, -0.943084437f, -0.331106306f, + -0.943593458f, -0.329658463f, -0.944100258f, -0.328209844f, -0.944604837f, + -0.326760452f, -0.945107193f, -0.325310292f, -0.945607325f, -0.323859367f, + -0.946105232f, -0.322407679f, -0.946600913f, -0.320955232f, -0.947094366f, + -0.319502031f, -0.947585591f, -0.318048077f, -0.948074586f, -0.316593376f, + -0.948561350f, -0.315137929f, -0.949045882f, -0.313681740f, -0.949528181f, + -0.312224814f, -0.950008245f, -0.310767153f, -0.950486074f, -0.309308760f, + -0.950961666f, -0.307849640f, -0.951435021f, -0.306389795f, -0.951906137f, + -0.304929230f, -0.952375013f, -0.303467947f, -0.952841648f, -0.302005949f, + -0.953306040f, -0.300543241f, -0.953768190f, -0.299079826f, -0.954228095f, + -0.297615707f, -0.954685755f, -0.296150888f, -0.955141168f, -0.294685372f, + -0.955594334f, -0.293219163f, -0.956045251f, -0.291752263f, -0.956493919f, + -0.290284677f, -0.956940336f, -0.288816408f, -0.957384501f, -0.287347460f, + -0.957826413f, -0.285877835f, -0.958266071f, -0.284407537f, -0.958703475f, + -0.282936570f, -0.959138622f, -0.281464938f, -0.959571513f, -0.279992643f, + -0.960002146f, -0.278519689f, -0.960430519f, -0.277046080f, -0.960856633f, + -0.275571819f, -0.961280486f, -0.274096910f, -0.961702077f, -0.272621355f, + -0.962121404f, -0.271145160f, -0.962538468f, -0.269668326f, -0.962953267f, + -0.268190857f, -0.963365800f, -0.266712757f, -0.963776066f, -0.265234030f, + -0.964184064f, -0.263754679f, -0.964589793f, -0.262274707f, -0.964993253f, + -0.260794118f, -0.965394442f, -0.259312915f, -0.965793359f, -0.257831102f, + -0.966190003f, -0.256348682f, -0.966584374f, -0.254865660f, -0.966976471f, + -0.253382037f, -0.967366292f, -0.251897818f, -0.967753837f, -0.250413007f, + -0.968139105f, -0.248927606f, -0.968522094f, -0.247441619f, -0.968902805f, + -0.245955050f, -0.969281235f, -0.244467903f, -0.969657385f, -0.242980180f, + -0.970031253f, -0.241491885f, -0.970402839f, -0.240003022f, -0.970772141f, + -0.238513595f, -0.971139158f, -0.237023606f, -0.971503891f, -0.235533059f, + -0.971866337f, -0.234041959f, -0.972226497f, -0.232550307f, -0.972584369f, + -0.231058108f, -0.972939952f, -0.229565366f, -0.973293246f, -0.228072083f, + -0.973644250f, -0.226578264f, -0.973992962f, -0.225083911f, -0.974339383f, + -0.223589029f, -0.974683511f, -0.222093621f, -0.975025345f, -0.220597690f, + -0.975364885f, -0.219101240f, -0.975702130f, -0.217604275f, -0.976037079f, + -0.216106797f, -0.976369731f, -0.214608811f, -0.976700086f, -0.213110320f, + -0.977028143f, -0.211611327f, -0.977353900f, -0.210111837f, -0.977677358f, + -0.208611852f, -0.977998515f, -0.207111376f, -0.978317371f, -0.205610413f, + -0.978633924f, -0.204108966f, -0.978948175f, -0.202607039f, -0.979260123f, + -0.201104635f, -0.979569766f, -0.199601758f, -0.979877104f, -0.198098411f, + -0.980182136f, -0.196594598f, -0.980484862f, -0.195090322f, -0.980785280f, + -0.193585587f, -0.981083391f, -0.192080397f, -0.981379193f, -0.190574755f, + -0.981672686f, -0.189068664f, -0.981963869f, -0.187562129f, -0.982252741f, + -0.186055152f, -0.982539302f, -0.184547737f, -0.982823551f, -0.183039888f, + -0.983105487f, -0.181531608f, -0.983385110f, -0.180022901f, -0.983662419f, + -0.178513771f, -0.983937413f, -0.177004220f, -0.984210092f, -0.175494253f, + -0.984480455f, -0.173983873f, -0.984748502f, -0.172473084f, -0.985014231f, + -0.170961889f, -0.985277642f, -0.169450291f, -0.985538735f, -0.167938295f, + -0.985797509f, -0.166425904f, -0.986053963f, -0.164913120f, -0.986308097f, + -0.163399949f, -0.986559910f, -0.161886394f, -0.986809402f, -0.160372457f, + -0.987056571f, -0.158858143f, -0.987301418f, -0.157343456f, -0.987543942f, + -0.155828398f, -0.987784142f, -0.154312973f, -0.988022017f, -0.152797185f, + -0.988257568f, -0.151281038f, -0.988490793f, -0.149764535f, -0.988721692f, + -0.148247679f, -0.988950265f, -0.146730474f, -0.989176510f, -0.145212925f, + -0.989400428f, -0.143695033f, -0.989622017f, -0.142176804f, -0.989841278f, + -0.140658239f, -0.990058210f, -0.139139344f, -0.990272812f, -0.137620122f, + -0.990485084f, -0.136100575f, -0.990695025f, -0.134580709f, -0.990902635f, + -0.133060525f, -0.991107914f, -0.131540029f, -0.991310860f, -0.130019223f, + -0.991511473f, -0.128498111f, -0.991709754f, -0.126976696f, -0.991905700f, + -0.125454983f, -0.992099313f, -0.123932975f, -0.992290591f, -0.122410675f, + -0.992479535f, -0.120888087f, -0.992666142f, -0.119365215f, -0.992850414f, + -0.117842062f, -0.993032350f, -0.116318631f, -0.993211949f, -0.114794927f, + -0.993389211f, -0.113270952f, -0.993564136f, -0.111746711f, -0.993736722f, + -0.110222207f, -0.993906970f, -0.108697444f, -0.994074879f, -0.107172425f, + -0.994240449f, -0.105647154f, -0.994403680f, -0.104121634f, -0.994564571f, + -0.102595869f, -0.994723121f, -0.101069863f, -0.994879331f, -0.099543619f, + -0.995033199f, -0.098017140f, -0.995184727f, -0.096490431f, -0.995333912f, + -0.094963495f, -0.995480755f, -0.093436336f, -0.995625256f, -0.091908956f, + -0.995767414f, -0.090381361f, -0.995907229f, -0.088853553f, -0.996044701f, + -0.087325535f, -0.996179829f, -0.085797312f, -0.996312612f, -0.084268888f, + -0.996443051f, -0.082740265f, -0.996571146f, -0.081211447f, -0.996696895f, + -0.079682438f, -0.996820299f, -0.078153242f, -0.996941358f, -0.076623861f, + -0.997060070f, -0.075094301f, -0.997176437f, -0.073564564f, -0.997290457f, + -0.072034653f, -0.997402130f, -0.070504573f, -0.997511456f, -0.068974328f, + -0.997618435f, -0.067443920f, -0.997723067f, -0.065913353f, -0.997825350f, + -0.064382631f, -0.997925286f, -0.062851758f, -0.998022874f, -0.061320736f, + -0.998118113f, -0.059789571f, -0.998211003f, -0.058258265f, -0.998301545f, + -0.056726821f, -0.998389737f, -0.055195244f, -0.998475581f, -0.053663538f, + -0.998559074f, -0.052131705f, -0.998640218f, -0.050599749f, -0.998719012f, + -0.049067674f, -0.998795456f, -0.047535484f, -0.998869550f, -0.046003182f, + -0.998941293f, -0.044470772f, -0.999010686f, -0.042938257f, -0.999077728f, + -0.041405641f, -0.999142419f, -0.039872928f, -0.999204759f, -0.038340120f, + -0.999264747f, -0.036807223f, -0.999322385f, -0.035274239f, -0.999377670f, + -0.033741172f, -0.999430605f, -0.032208025f, -0.999481187f, -0.030674803f, + -0.999529418f, -0.029141509f, -0.999575296f, -0.027608146f, -0.999618822f, + -0.026074718f, -0.999659997f, -0.024541229f, -0.999698819f, -0.023007681f, + -0.999735288f, -0.021474080f, -0.999769405f, -0.019940429f, -0.999801170f, + -0.018406730f, -0.999830582f, -0.016872988f, -0.999857641f, -0.015339206f, + -0.999882347f, -0.013805389f, -0.999904701f, -0.012271538f, -0.999924702f, + -0.010737659f, -0.999942350f, -0.009203755f, -0.999957645f, -0.007669829f, + -0.999970586f, -0.006135885f, -0.999981175f, -0.004601926f, -0.999989411f, + -0.003067957f, -0.999995294f, -0.001533980f, -0.999998823f, -0.000000000f, + -1.000000000f, 0.001533980f, -0.999998823f, 0.003067957f, -0.999995294f, + 0.004601926f, -0.999989411f, 0.006135885f, -0.999981175f, 0.007669829f, + -0.999970586f, 0.009203755f, -0.999957645f, 0.010737659f, -0.999942350f, + 0.012271538f, -0.999924702f, 0.013805389f, -0.999904701f, 0.015339206f, + -0.999882347f, 0.016872988f, -0.999857641f, 0.018406730f, -0.999830582f, + 0.019940429f, -0.999801170f, 0.021474080f, -0.999769405f, 0.023007681f, + -0.999735288f, 0.024541229f, -0.999698819f, 0.026074718f, -0.999659997f, + 0.027608146f, -0.999618822f, 0.029141509f, -0.999575296f, 0.030674803f, + -0.999529418f, 0.032208025f, -0.999481187f, 0.033741172f, -0.999430605f, + 0.035274239f, -0.999377670f, 0.036807223f, -0.999322385f, 0.038340120f, + -0.999264747f, 0.039872928f, -0.999204759f, 0.041405641f, -0.999142419f, + 0.042938257f, -0.999077728f, 0.044470772f, -0.999010686f, 0.046003182f, + -0.998941293f, 0.047535484f, -0.998869550f, 0.049067674f, -0.998795456f, + 0.050599749f, -0.998719012f, 0.052131705f, -0.998640218f, 0.053663538f, + -0.998559074f, 0.055195244f, -0.998475581f, 0.056726821f, -0.998389737f, + 0.058258265f, -0.998301545f, 0.059789571f, -0.998211003f, 0.061320736f, + -0.998118113f, 0.062851758f, -0.998022874f, 0.064382631f, -0.997925286f, + 0.065913353f, -0.997825350f, 0.067443920f, -0.997723067f, 0.068974328f, + -0.997618435f, 0.070504573f, -0.997511456f, 0.072034653f, -0.997402130f, + 0.073564564f, -0.997290457f, 0.075094301f, -0.997176437f, 0.076623861f, + -0.997060070f, 0.078153242f, -0.996941358f, 0.079682438f, -0.996820299f, + 0.081211447f, -0.996696895f, 0.082740265f, -0.996571146f, 0.084268888f, + -0.996443051f, 0.085797312f, -0.996312612f, 0.087325535f, -0.996179829f, + 0.088853553f, -0.996044701f, 0.090381361f, -0.995907229f, 0.091908956f, + -0.995767414f, 0.093436336f, -0.995625256f, 0.094963495f, -0.995480755f, + 0.096490431f, -0.995333912f, 0.098017140f, -0.995184727f, 0.099543619f, + -0.995033199f, 0.101069863f, -0.994879331f, 0.102595869f, -0.994723121f, + 0.104121634f, -0.994564571f, 0.105647154f, -0.994403680f, 0.107172425f, + -0.994240449f, 0.108697444f, -0.994074879f, 0.110222207f, -0.993906970f, + 0.111746711f, -0.993736722f, 0.113270952f, -0.993564136f, 0.114794927f, + -0.993389211f, 0.116318631f, -0.993211949f, 0.117842062f, -0.993032350f, + 0.119365215f, -0.992850414f, 0.120888087f, -0.992666142f, 0.122410675f, + -0.992479535f, 0.123932975f, -0.992290591f, 0.125454983f, -0.992099313f, + 0.126976696f, -0.991905700f, 0.128498111f, -0.991709754f, 0.130019223f, + -0.991511473f, 0.131540029f, -0.991310860f, 0.133060525f, -0.991107914f, + 0.134580709f, -0.990902635f, 0.136100575f, -0.990695025f, 0.137620122f, + -0.990485084f, 0.139139344f, -0.990272812f, 0.140658239f, -0.990058210f, + 0.142176804f, -0.989841278f, 0.143695033f, -0.989622017f, 0.145212925f, + -0.989400428f, 0.146730474f, -0.989176510f, 0.148247679f, -0.988950265f, + 0.149764535f, -0.988721692f, 0.151281038f, -0.988490793f, 0.152797185f, + -0.988257568f, 0.154312973f, -0.988022017f, 0.155828398f, -0.987784142f, + 0.157343456f, -0.987543942f, 0.158858143f, -0.987301418f, 0.160372457f, + -0.987056571f, 0.161886394f, -0.986809402f, 0.163399949f, -0.986559910f, + 0.164913120f, -0.986308097f, 0.166425904f, -0.986053963f, 0.167938295f, + -0.985797509f, 0.169450291f, -0.985538735f, 0.170961889f, -0.985277642f, + 0.172473084f, -0.985014231f, 0.173983873f, -0.984748502f, 0.175494253f, + -0.984480455f, 0.177004220f, -0.984210092f, 0.178513771f, -0.983937413f, + 0.180022901f, -0.983662419f, 0.181531608f, -0.983385110f, 0.183039888f, + -0.983105487f, 0.184547737f, -0.982823551f, 0.186055152f, -0.982539302f, + 0.187562129f, -0.982252741f, 0.189068664f, -0.981963869f, 0.190574755f, + -0.981672686f, 0.192080397f, -0.981379193f, 0.193585587f, -0.981083391f, + 0.195090322f, -0.980785280f, 0.196594598f, -0.980484862f, 0.198098411f, + -0.980182136f, 0.199601758f, -0.979877104f, 0.201104635f, -0.979569766f, + 0.202607039f, -0.979260123f, 0.204108966f, -0.978948175f, 0.205610413f, + -0.978633924f, 0.207111376f, -0.978317371f, 0.208611852f, -0.977998515f, + 0.210111837f, -0.977677358f, 0.211611327f, -0.977353900f, 0.213110320f, + -0.977028143f, 0.214608811f, -0.976700086f, 0.216106797f, -0.976369731f, + 0.217604275f, -0.976037079f, 0.219101240f, -0.975702130f, 0.220597690f, + -0.975364885f, 0.222093621f, -0.975025345f, 0.223589029f, -0.974683511f, + 0.225083911f, -0.974339383f, 0.226578264f, -0.973992962f, 0.228072083f, + -0.973644250f, 0.229565366f, -0.973293246f, 0.231058108f, -0.972939952f, + 0.232550307f, -0.972584369f, 0.234041959f, -0.972226497f, 0.235533059f, + -0.971866337f, 0.237023606f, -0.971503891f, 0.238513595f, -0.971139158f, + 0.240003022f, -0.970772141f, 0.241491885f, -0.970402839f, 0.242980180f, + -0.970031253f, 0.244467903f, -0.969657385f, 0.245955050f, -0.969281235f, + 0.247441619f, -0.968902805f, 0.248927606f, -0.968522094f, 0.250413007f, + -0.968139105f, 0.251897818f, -0.967753837f, 0.253382037f, -0.967366292f, + 0.254865660f, -0.966976471f, 0.256348682f, -0.966584374f, 0.257831102f, + -0.966190003f, 0.259312915f, -0.965793359f, 0.260794118f, -0.965394442f, + 0.262274707f, -0.964993253f, 0.263754679f, -0.964589793f, 0.265234030f, + -0.964184064f, 0.266712757f, -0.963776066f, 0.268190857f, -0.963365800f, + 0.269668326f, -0.962953267f, 0.271145160f, -0.962538468f, 0.272621355f, + -0.962121404f, 0.274096910f, -0.961702077f, 0.275571819f, -0.961280486f, + 0.277046080f, -0.960856633f, 0.278519689f, -0.960430519f, 0.279992643f, + -0.960002146f, 0.281464938f, -0.959571513f, 0.282936570f, -0.959138622f, + 0.284407537f, -0.958703475f, 0.285877835f, -0.958266071f, 0.287347460f, + -0.957826413f, 0.288816408f, -0.957384501f, 0.290284677f, -0.956940336f, + 0.291752263f, -0.956493919f, 0.293219163f, -0.956045251f, 0.294685372f, + -0.955594334f, 0.296150888f, -0.955141168f, 0.297615707f, -0.954685755f, + 0.299079826f, -0.954228095f, 0.300543241f, -0.953768190f, 0.302005949f, + -0.953306040f, 0.303467947f, -0.952841648f, 0.304929230f, -0.952375013f, + 0.306389795f, -0.951906137f, 0.307849640f, -0.951435021f, 0.309308760f, + -0.950961666f, 0.310767153f, -0.950486074f, 0.312224814f, -0.950008245f, + 0.313681740f, -0.949528181f, 0.315137929f, -0.949045882f, 0.316593376f, + -0.948561350f, 0.318048077f, -0.948074586f, 0.319502031f, -0.947585591f, + 0.320955232f, -0.947094366f, 0.322407679f, -0.946600913f, 0.323859367f, + -0.946105232f, 0.325310292f, -0.945607325f, 0.326760452f, -0.945107193f, + 0.328209844f, -0.944604837f, 0.329658463f, -0.944100258f, 0.331106306f, + -0.943593458f, 0.332553370f, -0.943084437f, 0.333999651f, -0.942573198f, + 0.335445147f, -0.942059740f, 0.336889853f, -0.941544065f, 0.338333767f, + -0.941026175f, 0.339776884f, -0.940506071f, 0.341219202f, -0.939983753f, + 0.342660717f, -0.939459224f, 0.344101426f, -0.938932484f, 0.345541325f, + -0.938403534f, 0.346980411f, -0.937872376f, 0.348418680f, -0.937339012f, + 0.349856130f, -0.936803442f, 0.351292756f, -0.936265667f, 0.352728556f, + -0.935725689f, 0.354163525f, -0.935183510f, 0.355597662f, -0.934639130f, + 0.357030961f, -0.934092550f, 0.358463421f, -0.933543773f, 0.359895037f, + -0.932992799f, 0.361325806f, -0.932439629f, 0.362755724f, -0.931884266f, + 0.364184790f, -0.931326709f, 0.365612998f, -0.930766961f, 0.367040346f, + -0.930205023f, 0.368466830f, -0.929640896f, 0.369892447f, -0.929074581f, + 0.371317194f, -0.928506080f, 0.372741067f, -0.927935395f, 0.374164063f, + -0.927362526f, 0.375586178f, -0.926787474f, 0.377007410f, -0.926210242f, + 0.378427755f, -0.925630831f, 0.379847209f, -0.925049241f, 0.381265769f, + -0.924465474f, 0.382683432f, -0.923879533f, 0.384100195f, -0.923291417f, + 0.385516054f, -0.922701128f, 0.386931006f, -0.922108669f, 0.388345047f, + -0.921514039f, 0.389758174f, -0.920917242f, 0.391170384f, -0.920318277f, + 0.392581674f, -0.919717146f, 0.393992040f, -0.919113852f, 0.395401479f, + -0.918508394f, 0.396809987f, -0.917900776f, 0.398217562f, -0.917290997f, + 0.399624200f, -0.916679060f, 0.401029897f, -0.916064966f, 0.402434651f, + -0.915448716f, 0.403838458f, -0.914830312f, 0.405241314f, -0.914209756f, + 0.406643217f, -0.913587048f, 0.408044163f, -0.912962190f, 0.409444149f, + -0.912335185f, 0.410843171f, -0.911706032f, 0.412241227f, -0.911074734f, + 0.413638312f, -0.910441292f, 0.415034424f, -0.909805708f, 0.416429560f, + -0.909167983f, 0.417823716f, -0.908528119f, 0.419216888f, -0.907886116f, + 0.420609074f, -0.907241978f, 0.422000271f, -0.906595705f, 0.423390474f, + -0.905947298f, 0.424779681f, -0.905296759f, 0.426167889f, -0.904644091f, + 0.427555093f, -0.903989293f, 0.428941292f, -0.903332368f, 0.430326481f, + -0.902673318f, 0.431710658f, -0.902012144f, 0.433093819f, -0.901348847f, + 0.434475961f, -0.900683429f, 0.435857080f, -0.900015892f, 0.437237174f, + -0.899346237f, 0.438616239f, -0.898674466f, 0.439994271f, -0.898000580f, + 0.441371269f, -0.897324581f, 0.442747228f, -0.896646470f, 0.444122145f, + -0.895966250f, 0.445496017f, -0.895283921f, 0.446868840f, -0.894599486f, + 0.448240612f, -0.893912945f, 0.449611330f, -0.893224301f, 0.450980989f, + -0.892533555f, 0.452349587f, -0.891840709f, 0.453717121f, -0.891145765f, + 0.455083587f, -0.890448723f, 0.456448982f, -0.889749586f, 0.457813304f, + -0.889048356f, 0.459176548f, -0.888345033f, 0.460538711f, -0.887639620f, + 0.461899791f, -0.886932119f, 0.463259784f, -0.886222530f, 0.464618686f, + -0.885510856f, 0.465976496f, -0.884797098f, 0.467333209f, -0.884081259f, + 0.468688822f, -0.883363339f, 0.470043332f, -0.882643340f, 0.471396737f, + -0.881921264f, 0.472749032f, -0.881197113f, 0.474100215f, -0.880470889f, + 0.475450282f, -0.879742593f, 0.476799230f, -0.879012226f, 0.478147056f, + -0.878279792f, 0.479493758f, -0.877545290f, 0.480839331f, -0.876808724f, + 0.482183772f, -0.876070094f, 0.483527079f, -0.875329403f, 0.484869248f, + -0.874586652f, 0.486210276f, -0.873841843f, 0.487550160f, -0.873094978f, + 0.488888897f, -0.872346059f, 0.490226483f, -0.871595087f, 0.491562916f, + -0.870842063f, 0.492898192f, -0.870086991f, 0.494232309f, -0.869329871f, + 0.495565262f, -0.868570706f, 0.496897049f, -0.867809497f, 0.498227667f, + -0.867046246f, 0.499557113f, -0.866280954f, 0.500885383f, -0.865513624f, + 0.502212474f, -0.864744258f, 0.503538384f, -0.863972856f, 0.504863109f, + -0.863199422f, 0.506186645f, -0.862423956f, 0.507508991f, -0.861646461f, + 0.508830143f, -0.860866939f, 0.510150097f, -0.860085390f, 0.511468850f, + -0.859301818f, 0.512786401f, -0.858516224f, 0.514102744f, -0.857728610f, + 0.515417878f, -0.856938977f, 0.516731799f, -0.856147328f, 0.518044504f, + -0.855353665f, 0.519355990f, -0.854557988f, 0.520666254f, -0.853760301f, + 0.521975293f, -0.852960605f, 0.523283103f, -0.852158902f, 0.524589683f, + -0.851355193f, 0.525895027f, -0.850549481f, 0.527199135f, -0.849741768f, + 0.528502002f, -0.848932055f, 0.529803625f, -0.848120345f, 0.531104001f, + -0.847306639f, 0.532403128f, -0.846490939f, 0.533701002f, -0.845673247f, + 0.534997620f, -0.844853565f, 0.536292979f, -0.844031895f, 0.537587076f, + -0.843208240f, 0.538879909f, -0.842382600f, 0.540171473f, -0.841554977f, + 0.541461766f, -0.840725375f, 0.542750785f, -0.839893794f, 0.544038527f, + -0.839060237f, 0.545324988f, -0.838224706f, 0.546610167f, -0.837387202f, + 0.547894059f, -0.836547727f, 0.549176662f, -0.835706284f, 0.550457973f, + -0.834862875f, 0.551737988f, -0.834017501f, 0.553016706f, -0.833170165f, + 0.554294121f, -0.832320868f, 0.555570233f, -0.831469612f, 0.556845037f, + -0.830616400f, 0.558118531f, -0.829761234f, 0.559390712f, -0.828904115f, + 0.560661576f, -0.828045045f, 0.561931121f, -0.827184027f, 0.563199344f, + -0.826321063f, 0.564466242f, -0.825456154f, 0.565731811f, -0.824589303f, + 0.566996049f, -0.823720511f, 0.568258953f, -0.822849781f, 0.569520519f, + -0.821977115f, 0.570780746f, -0.821102515f, 0.572039629f, -0.820225983f, + 0.573297167f, -0.819347520f, 0.574553355f, -0.818467130f, 0.575808191f, + -0.817584813f, 0.577061673f, -0.816700573f, 0.578313796f, -0.815814411f, + 0.579564559f, -0.814926329f, 0.580813958f, -0.814036330f, 0.582061990f, + -0.813144415f, 0.583308653f, -0.812250587f, 0.584553943f, -0.811354847f, + 0.585797857f, -0.810457198f, 0.587040394f, -0.809557642f, 0.588281548f, + -0.808656182f, 0.589521319f, -0.807752818f, 0.590759702f, -0.806847554f, + 0.591996695f, -0.805940391f, 0.593232295f, -0.805031331f, 0.594466499f, + -0.804120377f, 0.595699304f, -0.803207531f, 0.596930708f, -0.802292796f, + 0.598160707f, -0.801376172f, 0.599389298f, -0.800457662f, 0.600616479f, + -0.799537269f, 0.601842247f, -0.798614995f, 0.603066599f, -0.797690841f, + 0.604289531f, -0.796764810f, 0.605511041f, -0.795836905f, 0.606731127f, + -0.794907126f, 0.607949785f, -0.793975478f, 0.609167012f, -0.793041960f, + 0.610382806f, -0.792106577f, 0.611597164f, -0.791169330f, 0.612810082f, + -0.790230221f, 0.614021559f, -0.789289253f, 0.615231591f, -0.788346428f, + 0.616440175f, -0.787401747f, 0.617647308f, -0.786455214f, 0.618852988f, + -0.785506830f, 0.620057212f, -0.784556597f, 0.621259977f, -0.783604519f, + 0.622461279f, -0.782650596f, 0.623661118f, -0.781694832f, 0.624859488f, + -0.780737229f, 0.626056388f, -0.779777788f, 0.627251815f, -0.778816512f, + 0.628445767f, -0.777853404f, 0.629638239f, -0.776888466f, 0.630829230f, + -0.775921699f, 0.632018736f, -0.774953107f, 0.633206755f, -0.773982691f, + 0.634393284f, -0.773010453f, 0.635578320f, -0.772036397f, 0.636761861f, + -0.771060524f, 0.637943904f, -0.770082837f, 0.639124445f, -0.769103338f, + 0.640303482f, -0.768122029f, 0.641481013f, -0.767138912f, 0.642657034f, + -0.766153990f, 0.643831543f, -0.765167266f, 0.645004537f, -0.764178741f, + 0.646176013f, -0.763188417f, 0.647345969f, -0.762196298f, 0.648514401f, + -0.761202385f, 0.649681307f, -0.760206682f, 0.650846685f, -0.759209189f, + 0.652010531f, -0.758209910f, 0.653172843f, -0.757208847f, 0.654333618f, + -0.756206001f, 0.655492853f, -0.755201377f, 0.656650546f, -0.754194975f, + 0.657806693f, -0.753186799f, 0.658961293f, -0.752176850f, 0.660114342f, + -0.751165132f, 0.661265838f, -0.750151646f, 0.662415778f, -0.749136395f, + 0.663564159f, -0.748119380f, 0.664710978f, -0.747100606f, 0.665856234f, + -0.746080074f, 0.666999922f, -0.745057785f, 0.668142041f, -0.744033744f, + 0.669282588f, -0.743007952f, 0.670421560f, -0.741980412f, 0.671558955f, + -0.740951125f, 0.672694769f, -0.739920095f, 0.673829000f, -0.738887324f, + 0.674961646f, -0.737852815f, 0.676092704f, -0.736816569f, 0.677222170f, + -0.735778589f, 0.678350043f, -0.734738878f, 0.679476320f, -0.733697438f, + 0.680600998f, -0.732654272f, 0.681724074f, -0.731609381f, 0.682845546f, + -0.730562769f, 0.683965412f, -0.729514438f, 0.685083668f, -0.728464390f, + 0.686200312f, -0.727412629f, 0.687315341f, -0.726359155f, 0.688428753f, + -0.725303972f, 0.689540545f, -0.724247083f, 0.690650714f, -0.723188489f, + 0.691759258f, -0.722128194f, 0.692866175f, -0.721066199f, 0.693971461f, + -0.720002508f, 0.695075114f, -0.718937122f, 0.696177131f, -0.717870045f, + 0.697277511f, -0.716801279f, 0.698376249f, -0.715730825f, 0.699473345f, + -0.714658688f, 0.700568794f, -0.713584869f, 0.701662595f, -0.712509371f, + 0.702754744f, -0.711432196f, 0.703845241f, -0.710353347f, 0.704934080f, + -0.709272826f, 0.706021261f, -0.708190637f, 0.707106781f, -0.707106781f, + 0.708190637f, -0.706021261f, 0.709272826f, -0.704934080f, 0.710353347f, + -0.703845241f, 0.711432196f, -0.702754744f, 0.712509371f, -0.701662595f, + 0.713584869f, -0.700568794f, 0.714658688f, -0.699473345f, 0.715730825f, + -0.698376249f, 0.716801279f, -0.697277511f, 0.717870045f, -0.696177131f, + 0.718937122f, -0.695075114f, 0.720002508f, -0.693971461f, 0.721066199f, + -0.692866175f, 0.722128194f, -0.691759258f, 0.723188489f, -0.690650714f, + 0.724247083f, -0.689540545f, 0.725303972f, -0.688428753f, 0.726359155f, + -0.687315341f, 0.727412629f, -0.686200312f, 0.728464390f, -0.685083668f, + 0.729514438f, -0.683965412f, 0.730562769f, -0.682845546f, 0.731609381f, + -0.681724074f, 0.732654272f, -0.680600998f, 0.733697438f, -0.679476320f, + 0.734738878f, -0.678350043f, 0.735778589f, -0.677222170f, 0.736816569f, + -0.676092704f, 0.737852815f, -0.674961646f, 0.738887324f, -0.673829000f, + 0.739920095f, -0.672694769f, 0.740951125f, -0.671558955f, 0.741980412f, + -0.670421560f, 0.743007952f, -0.669282588f, 0.744033744f, -0.668142041f, + 0.745057785f, -0.666999922f, 0.746080074f, -0.665856234f, 0.747100606f, + -0.664710978f, 0.748119380f, -0.663564159f, 0.749136395f, -0.662415778f, + 0.750151646f, -0.661265838f, 0.751165132f, -0.660114342f, 0.752176850f, + -0.658961293f, 0.753186799f, -0.657806693f, 0.754194975f, -0.656650546f, + 0.755201377f, -0.655492853f, 0.756206001f, -0.654333618f, 0.757208847f, + -0.653172843f, 0.758209910f, -0.652010531f, 0.759209189f, -0.650846685f, + 0.760206682f, -0.649681307f, 0.761202385f, -0.648514401f, 0.762196298f, + -0.647345969f, 0.763188417f, -0.646176013f, 0.764178741f, -0.645004537f, + 0.765167266f, -0.643831543f, 0.766153990f, -0.642657034f, 0.767138912f, + -0.641481013f, 0.768122029f, -0.640303482f, 0.769103338f, -0.639124445f, + 0.770082837f, -0.637943904f, 0.771060524f, -0.636761861f, 0.772036397f, + -0.635578320f, 0.773010453f, -0.634393284f, 0.773982691f, -0.633206755f, + 0.774953107f, -0.632018736f, 0.775921699f, -0.630829230f, 0.776888466f, + -0.629638239f, 0.777853404f, -0.628445767f, 0.778816512f, -0.627251815f, + 0.779777788f, -0.626056388f, 0.780737229f, -0.624859488f, 0.781694832f, + -0.623661118f, 0.782650596f, -0.622461279f, 0.783604519f, -0.621259977f, + 0.784556597f, -0.620057212f, 0.785506830f, -0.618852988f, 0.786455214f, + -0.617647308f, 0.787401747f, -0.616440175f, 0.788346428f, -0.615231591f, + 0.789289253f, -0.614021559f, 0.790230221f, -0.612810082f, 0.791169330f, + -0.611597164f, 0.792106577f, -0.610382806f, 0.793041960f, -0.609167012f, + 0.793975478f, -0.607949785f, 0.794907126f, -0.606731127f, 0.795836905f, + -0.605511041f, 0.796764810f, -0.604289531f, 0.797690841f, -0.603066599f, + 0.798614995f, -0.601842247f, 0.799537269f, -0.600616479f, 0.800457662f, + -0.599389298f, 0.801376172f, -0.598160707f, 0.802292796f, -0.596930708f, + 0.803207531f, -0.595699304f, 0.804120377f, -0.594466499f, 0.805031331f, + -0.593232295f, 0.805940391f, -0.591996695f, 0.806847554f, -0.590759702f, + 0.807752818f, -0.589521319f, 0.808656182f, -0.588281548f, 0.809557642f, + -0.587040394f, 0.810457198f, -0.585797857f, 0.811354847f, -0.584553943f, + 0.812250587f, -0.583308653f, 0.813144415f, -0.582061990f, 0.814036330f, + -0.580813958f, 0.814926329f, -0.579564559f, 0.815814411f, -0.578313796f, + 0.816700573f, -0.577061673f, 0.817584813f, -0.575808191f, 0.818467130f, + -0.574553355f, 0.819347520f, -0.573297167f, 0.820225983f, -0.572039629f, + 0.821102515f, -0.570780746f, 0.821977115f, -0.569520519f, 0.822849781f, + -0.568258953f, 0.823720511f, -0.566996049f, 0.824589303f, -0.565731811f, + 0.825456154f, -0.564466242f, 0.826321063f, -0.563199344f, 0.827184027f, + -0.561931121f, 0.828045045f, -0.560661576f, 0.828904115f, -0.559390712f, + 0.829761234f, -0.558118531f, 0.830616400f, -0.556845037f, 0.831469612f, + -0.555570233f, 0.832320868f, -0.554294121f, 0.833170165f, -0.553016706f, + 0.834017501f, -0.551737988f, 0.834862875f, -0.550457973f, 0.835706284f, + -0.549176662f, 0.836547727f, -0.547894059f, 0.837387202f, -0.546610167f, + 0.838224706f, -0.545324988f, 0.839060237f, -0.544038527f, 0.839893794f, + -0.542750785f, 0.840725375f, -0.541461766f, 0.841554977f, -0.540171473f, + 0.842382600f, -0.538879909f, 0.843208240f, -0.537587076f, 0.844031895f, + -0.536292979f, 0.844853565f, -0.534997620f, 0.845673247f, -0.533701002f, + 0.846490939f, -0.532403128f, 0.847306639f, -0.531104001f, 0.848120345f, + -0.529803625f, 0.848932055f, -0.528502002f, 0.849741768f, -0.527199135f, + 0.850549481f, -0.525895027f, 0.851355193f, -0.524589683f, 0.852158902f, + -0.523283103f, 0.852960605f, -0.521975293f, 0.853760301f, -0.520666254f, + 0.854557988f, -0.519355990f, 0.855353665f, -0.518044504f, 0.856147328f, + -0.516731799f, 0.856938977f, -0.515417878f, 0.857728610f, -0.514102744f, + 0.858516224f, -0.512786401f, 0.859301818f, -0.511468850f, 0.860085390f, + -0.510150097f, 0.860866939f, -0.508830143f, 0.861646461f, -0.507508991f, + 0.862423956f, -0.506186645f, 0.863199422f, -0.504863109f, 0.863972856f, + -0.503538384f, 0.864744258f, -0.502212474f, 0.865513624f, -0.500885383f, + 0.866280954f, -0.499557113f, 0.867046246f, -0.498227667f, 0.867809497f, + -0.496897049f, 0.868570706f, -0.495565262f, 0.869329871f, -0.494232309f, + 0.870086991f, -0.492898192f, 0.870842063f, -0.491562916f, 0.871595087f, + -0.490226483f, 0.872346059f, -0.488888897f, 0.873094978f, -0.487550160f, + 0.873841843f, -0.486210276f, 0.874586652f, -0.484869248f, 0.875329403f, + -0.483527079f, 0.876070094f, -0.482183772f, 0.876808724f, -0.480839331f, + 0.877545290f, -0.479493758f, 0.878279792f, -0.478147056f, 0.879012226f, + -0.476799230f, 0.879742593f, -0.475450282f, 0.880470889f, -0.474100215f, + 0.881197113f, -0.472749032f, 0.881921264f, -0.471396737f, 0.882643340f, + -0.470043332f, 0.883363339f, -0.468688822f, 0.884081259f, -0.467333209f, + 0.884797098f, -0.465976496f, 0.885510856f, -0.464618686f, 0.886222530f, + -0.463259784f, 0.886932119f, -0.461899791f, 0.887639620f, -0.460538711f, + 0.888345033f, -0.459176548f, 0.889048356f, -0.457813304f, 0.889749586f, + -0.456448982f, 0.890448723f, -0.455083587f, 0.891145765f, -0.453717121f, + 0.891840709f, -0.452349587f, 0.892533555f, -0.450980989f, 0.893224301f, + -0.449611330f, 0.893912945f, -0.448240612f, 0.894599486f, -0.446868840f, + 0.895283921f, -0.445496017f, 0.895966250f, -0.444122145f, 0.896646470f, + -0.442747228f, 0.897324581f, -0.441371269f, 0.898000580f, -0.439994271f, + 0.898674466f, -0.438616239f, 0.899346237f, -0.437237174f, 0.900015892f, + -0.435857080f, 0.900683429f, -0.434475961f, 0.901348847f, -0.433093819f, + 0.902012144f, -0.431710658f, 0.902673318f, -0.430326481f, 0.903332368f, + -0.428941292f, 0.903989293f, -0.427555093f, 0.904644091f, -0.426167889f, + 0.905296759f, -0.424779681f, 0.905947298f, -0.423390474f, 0.906595705f, + -0.422000271f, 0.907241978f, -0.420609074f, 0.907886116f, -0.419216888f, + 0.908528119f, -0.417823716f, 0.909167983f, -0.416429560f, 0.909805708f, + -0.415034424f, 0.910441292f, -0.413638312f, 0.911074734f, -0.412241227f, + 0.911706032f, -0.410843171f, 0.912335185f, -0.409444149f, 0.912962190f, + -0.408044163f, 0.913587048f, -0.406643217f, 0.914209756f, -0.405241314f, + 0.914830312f, -0.403838458f, 0.915448716f, -0.402434651f, 0.916064966f, + -0.401029897f, 0.916679060f, -0.399624200f, 0.917290997f, -0.398217562f, + 0.917900776f, -0.396809987f, 0.918508394f, -0.395401479f, 0.919113852f, + -0.393992040f, 0.919717146f, -0.392581674f, 0.920318277f, -0.391170384f, + 0.920917242f, -0.389758174f, 0.921514039f, -0.388345047f, 0.922108669f, + -0.386931006f, 0.922701128f, -0.385516054f, 0.923291417f, -0.384100195f, + 0.923879533f, -0.382683432f, 0.924465474f, -0.381265769f, 0.925049241f, + -0.379847209f, 0.925630831f, -0.378427755f, 0.926210242f, -0.377007410f, + 0.926787474f, -0.375586178f, 0.927362526f, -0.374164063f, 0.927935395f, + -0.372741067f, 0.928506080f, -0.371317194f, 0.929074581f, -0.369892447f, + 0.929640896f, -0.368466830f, 0.930205023f, -0.367040346f, 0.930766961f, + -0.365612998f, 0.931326709f, -0.364184790f, 0.931884266f, -0.362755724f, + 0.932439629f, -0.361325806f, 0.932992799f, -0.359895037f, 0.933543773f, + -0.358463421f, 0.934092550f, -0.357030961f, 0.934639130f, -0.355597662f, + 0.935183510f, -0.354163525f, 0.935725689f, -0.352728556f, 0.936265667f, + -0.351292756f, 0.936803442f, -0.349856130f, 0.937339012f, -0.348418680f, + 0.937872376f, -0.346980411f, 0.938403534f, -0.345541325f, 0.938932484f, + -0.344101426f, 0.939459224f, -0.342660717f, 0.939983753f, -0.341219202f, + 0.940506071f, -0.339776884f, 0.941026175f, -0.338333767f, 0.941544065f, + -0.336889853f, 0.942059740f, -0.335445147f, 0.942573198f, -0.333999651f, + 0.943084437f, -0.332553370f, 0.943593458f, -0.331106306f, 0.944100258f, + -0.329658463f, 0.944604837f, -0.328209844f, 0.945107193f, -0.326760452f, + 0.945607325f, -0.325310292f, 0.946105232f, -0.323859367f, 0.946600913f, + -0.322407679f, 0.947094366f, -0.320955232f, 0.947585591f, -0.319502031f, + 0.948074586f, -0.318048077f, 0.948561350f, -0.316593376f, 0.949045882f, + -0.315137929f, 0.949528181f, -0.313681740f, 0.950008245f, -0.312224814f, + 0.950486074f, -0.310767153f, 0.950961666f, -0.309308760f, 0.951435021f, + -0.307849640f, 0.951906137f, -0.306389795f, 0.952375013f, -0.304929230f, + 0.952841648f, -0.303467947f, 0.953306040f, -0.302005949f, 0.953768190f, + -0.300543241f, 0.954228095f, -0.299079826f, 0.954685755f, -0.297615707f, + 0.955141168f, -0.296150888f, 0.955594334f, -0.294685372f, 0.956045251f, + -0.293219163f, 0.956493919f, -0.291752263f, 0.956940336f, -0.290284677f, + 0.957384501f, -0.288816408f, 0.957826413f, -0.287347460f, 0.958266071f, + -0.285877835f, 0.958703475f, -0.284407537f, 0.959138622f, -0.282936570f, + 0.959571513f, -0.281464938f, 0.960002146f, -0.279992643f, 0.960430519f, + -0.278519689f, 0.960856633f, -0.277046080f, 0.961280486f, -0.275571819f, + 0.961702077f, -0.274096910f, 0.962121404f, -0.272621355f, 0.962538468f, + -0.271145160f, 0.962953267f, -0.269668326f, 0.963365800f, -0.268190857f, + 0.963776066f, -0.266712757f, 0.964184064f, -0.265234030f, 0.964589793f, + -0.263754679f, 0.964993253f, -0.262274707f, 0.965394442f, -0.260794118f, + 0.965793359f, -0.259312915f, 0.966190003f, -0.257831102f, 0.966584374f, + -0.256348682f, 0.966976471f, -0.254865660f, 0.967366292f, -0.253382037f, + 0.967753837f, -0.251897818f, 0.968139105f, -0.250413007f, 0.968522094f, + -0.248927606f, 0.968902805f, -0.247441619f, 0.969281235f, -0.245955050f, + 0.969657385f, -0.244467903f, 0.970031253f, -0.242980180f, 0.970402839f, + -0.241491885f, 0.970772141f, -0.240003022f, 0.971139158f, -0.238513595f, + 0.971503891f, -0.237023606f, 0.971866337f, -0.235533059f, 0.972226497f, + -0.234041959f, 0.972584369f, -0.232550307f, 0.972939952f, -0.231058108f, + 0.973293246f, -0.229565366f, 0.973644250f, -0.228072083f, 0.973992962f, + -0.226578264f, 0.974339383f, -0.225083911f, 0.974683511f, -0.223589029f, + 0.975025345f, -0.222093621f, 0.975364885f, -0.220597690f, 0.975702130f, + -0.219101240f, 0.976037079f, -0.217604275f, 0.976369731f, -0.216106797f, + 0.976700086f, -0.214608811f, 0.977028143f, -0.213110320f, 0.977353900f, + -0.211611327f, 0.977677358f, -0.210111837f, 0.977998515f, -0.208611852f, + 0.978317371f, -0.207111376f, 0.978633924f, -0.205610413f, 0.978948175f, + -0.204108966f, 0.979260123f, -0.202607039f, 0.979569766f, -0.201104635f, + 0.979877104f, -0.199601758f, 0.980182136f, -0.198098411f, 0.980484862f, + -0.196594598f, 0.980785280f, -0.195090322f, 0.981083391f, -0.193585587f, + 0.981379193f, -0.192080397f, 0.981672686f, -0.190574755f, 0.981963869f, + -0.189068664f, 0.982252741f, -0.187562129f, 0.982539302f, -0.186055152f, + 0.982823551f, -0.184547737f, 0.983105487f, -0.183039888f, 0.983385110f, + -0.181531608f, 0.983662419f, -0.180022901f, 0.983937413f, -0.178513771f, + 0.984210092f, -0.177004220f, 0.984480455f, -0.175494253f, 0.984748502f, + -0.173983873f, 0.985014231f, -0.172473084f, 0.985277642f, -0.170961889f, + 0.985538735f, -0.169450291f, 0.985797509f, -0.167938295f, 0.986053963f, + -0.166425904f, 0.986308097f, -0.164913120f, 0.986559910f, -0.163399949f, + 0.986809402f, -0.161886394f, 0.987056571f, -0.160372457f, 0.987301418f, + -0.158858143f, 0.987543942f, -0.157343456f, 0.987784142f, -0.155828398f, + 0.988022017f, -0.154312973f, 0.988257568f, -0.152797185f, 0.988490793f, + -0.151281038f, 0.988721692f, -0.149764535f, 0.988950265f, -0.148247679f, + 0.989176510f, -0.146730474f, 0.989400428f, -0.145212925f, 0.989622017f, + -0.143695033f, 0.989841278f, -0.142176804f, 0.990058210f, -0.140658239f, + 0.990272812f, -0.139139344f, 0.990485084f, -0.137620122f, 0.990695025f, + -0.136100575f, 0.990902635f, -0.134580709f, 0.991107914f, -0.133060525f, + 0.991310860f, -0.131540029f, 0.991511473f, -0.130019223f, 0.991709754f, + -0.128498111f, 0.991905700f, -0.126976696f, 0.992099313f, -0.125454983f, + 0.992290591f, -0.123932975f, 0.992479535f, -0.122410675f, 0.992666142f, + -0.120888087f, 0.992850414f, -0.119365215f, 0.993032350f, -0.117842062f, + 0.993211949f, -0.116318631f, 0.993389211f, -0.114794927f, 0.993564136f, + -0.113270952f, 0.993736722f, -0.111746711f, 0.993906970f, -0.110222207f, + 0.994074879f, -0.108697444f, 0.994240449f, -0.107172425f, 0.994403680f, + -0.105647154f, 0.994564571f, -0.104121634f, 0.994723121f, -0.102595869f, + 0.994879331f, -0.101069863f, 0.995033199f, -0.099543619f, 0.995184727f, + -0.098017140f, 0.995333912f, -0.096490431f, 0.995480755f, -0.094963495f, + 0.995625256f, -0.093436336f, 0.995767414f, -0.091908956f, 0.995907229f, + -0.090381361f, 0.996044701f, -0.088853553f, 0.996179829f, -0.087325535f, + 0.996312612f, -0.085797312f, 0.996443051f, -0.084268888f, 0.996571146f, + -0.082740265f, 0.996696895f, -0.081211447f, 0.996820299f, -0.079682438f, + 0.996941358f, -0.078153242f, 0.997060070f, -0.076623861f, 0.997176437f, + -0.075094301f, 0.997290457f, -0.073564564f, 0.997402130f, -0.072034653f, + 0.997511456f, -0.070504573f, 0.997618435f, -0.068974328f, 0.997723067f, + -0.067443920f, 0.997825350f, -0.065913353f, 0.997925286f, -0.064382631f, + 0.998022874f, -0.062851758f, 0.998118113f, -0.061320736f, 0.998211003f, + -0.059789571f, 0.998301545f, -0.058258265f, 0.998389737f, -0.056726821f, + 0.998475581f, -0.055195244f, 0.998559074f, -0.053663538f, 0.998640218f, + -0.052131705f, 0.998719012f, -0.050599749f, 0.998795456f, -0.049067674f, + 0.998869550f, -0.047535484f, 0.998941293f, -0.046003182f, 0.999010686f, + -0.044470772f, 0.999077728f, -0.042938257f, 0.999142419f, -0.041405641f, + 0.999204759f, -0.039872928f, 0.999264747f, -0.038340120f, 0.999322385f, + -0.036807223f, 0.999377670f, -0.035274239f, 0.999430605f, -0.033741172f, + 0.999481187f, -0.032208025f, 0.999529418f, -0.030674803f, 0.999575296f, + -0.029141509f, 0.999618822f, -0.027608146f, 0.999659997f, -0.026074718f, + 0.999698819f, -0.024541229f, 0.999735288f, -0.023007681f, 0.999769405f, + -0.021474080f, 0.999801170f, -0.019940429f, 0.999830582f, -0.018406730f, + 0.999857641f, -0.016872988f, 0.999882347f, -0.015339206f, 0.999904701f, + -0.013805389f, 0.999924702f, -0.012271538f, 0.999942350f, -0.010737659f, + 0.999957645f, -0.009203755f, 0.999970586f, -0.007669829f, 0.999981175f, + -0.006135885f, 0.999989411f, -0.004601926f, 0.999995294f, -0.003067957f, + 0.999998823f, -0.001533980f}; /** @brief Q31 Twiddle factors Table */ - /** @par Example code for Q31 Twiddle factors Generation:: @@ -8523,22 +3602,15 @@ const float32_t twiddleCoef_4096[8192] = { Cos and Sin values are interleaved fashion @par Convert Floating point to Q31(Fixed point 1.31): - round(twiddleCoefQ31(i) * pow(2, 31)) + round(twiddleCoefQ31(i) * pow(2, 31)) */ const q31_t twiddleCoef_16_q31[24] = { - (q31_t)0x7FFFFFFF, (q31_t)0x00000000, - (q31_t)0x7641AF3C, (q31_t)0x30FBC54D, - (q31_t)0x5A82799A, (q31_t)0x5A82799A, - (q31_t)0x30FBC54D, (q31_t)0x7641AF3C, - (q31_t)0x00000000, (q31_t)0x7FFFFFFF, - (q31_t)0xCF043AB2, (q31_t)0x7641AF3C, - (q31_t)0xA57D8666, (q31_t)0x5A82799A, - (q31_t)0x89BE50C3, (q31_t)0x30FBC54D, - (q31_t)0x80000000, (q31_t)0x00000000, - (q31_t)0x89BE50C3, (q31_t)0xCF043AB2, - (q31_t)0xA57D8666, (q31_t)0xA57D8666, - (q31_t)0xCF043AB2, (q31_t)0x89BE50C3 -}; + (q31_t)0x7FFFFFFF, (q31_t)0x00000000, (q31_t)0x7641AF3C, (q31_t)0x30FBC54D, + (q31_t)0x5A82799A, (q31_t)0x5A82799A, (q31_t)0x30FBC54D, (q31_t)0x7641AF3C, + (q31_t)0x00000000, (q31_t)0x7FFFFFFF, (q31_t)0xCF043AB2, (q31_t)0x7641AF3C, + (q31_t)0xA57D8666, (q31_t)0x5A82799A, (q31_t)0x89BE50C3, (q31_t)0x30FBC54D, + (q31_t)0x80000000, (q31_t)0x00000000, (q31_t)0x89BE50C3, (q31_t)0xCF043AB2, + (q31_t)0xA57D8666, (q31_t)0xA57D8666, (q31_t)0xCF043AB2, (q31_t)0x89BE50C3}; /** @par @@ -8555,34 +3627,21 @@ const q31_t twiddleCoef_16_q31[24] = { Cos and Sin values are interleaved fashion @par Convert Floating point to Q31(Fixed point 1.31): - round(twiddleCoefQ31(i) * pow(2, 31)) + round(twiddleCoefQ31(i) * pow(2, 31)) */ const q31_t twiddleCoef_32_q31[48] = { - (q31_t)0x7FFFFFFF, (q31_t)0x00000000, - (q31_t)0x7D8A5F3F, (q31_t)0x18F8B83C, - (q31_t)0x7641AF3C, (q31_t)0x30FBC54D, - (q31_t)0x6A6D98A4, (q31_t)0x471CECE6, - (q31_t)0x5A82799A, (q31_t)0x5A82799A, - (q31_t)0x471CECE6, (q31_t)0x6A6D98A4, - (q31_t)0x30FBC54D, (q31_t)0x7641AF3C, - (q31_t)0x18F8B83C, (q31_t)0x7D8A5F3F, - (q31_t)0x00000000, (q31_t)0x7FFFFFFF, - (q31_t)0xE70747C3, (q31_t)0x7D8A5F3F, - (q31_t)0xCF043AB2, (q31_t)0x7641AF3C, - (q31_t)0xB8E31319, (q31_t)0x6A6D98A4, - (q31_t)0xA57D8666, (q31_t)0x5A82799A, - (q31_t)0x9592675B, (q31_t)0x471CECE6, - (q31_t)0x89BE50C3, (q31_t)0x30FBC54D, - (q31_t)0x8275A0C0, (q31_t)0x18F8B83C, - (q31_t)0x80000000, (q31_t)0x00000000, - (q31_t)0x8275A0C0, (q31_t)0xE70747C3, - (q31_t)0x89BE50C3, (q31_t)0xCF043AB2, - (q31_t)0x9592675B, (q31_t)0xB8E31319, - (q31_t)0xA57D8666, (q31_t)0xA57D8666, - (q31_t)0xB8E31319, (q31_t)0x9592675B, - (q31_t)0xCF043AB2, (q31_t)0x89BE50C3, - (q31_t)0xE70747C3, (q31_t)0x8275A0C0 -}; + (q31_t)0x7FFFFFFF, (q31_t)0x00000000, (q31_t)0x7D8A5F3F, (q31_t)0x18F8B83C, + (q31_t)0x7641AF3C, (q31_t)0x30FBC54D, (q31_t)0x6A6D98A4, (q31_t)0x471CECE6, + (q31_t)0x5A82799A, (q31_t)0x5A82799A, (q31_t)0x471CECE6, (q31_t)0x6A6D98A4, + (q31_t)0x30FBC54D, (q31_t)0x7641AF3C, (q31_t)0x18F8B83C, (q31_t)0x7D8A5F3F, + (q31_t)0x00000000, (q31_t)0x7FFFFFFF, (q31_t)0xE70747C3, (q31_t)0x7D8A5F3F, + (q31_t)0xCF043AB2, (q31_t)0x7641AF3C, (q31_t)0xB8E31319, (q31_t)0x6A6D98A4, + (q31_t)0xA57D8666, (q31_t)0x5A82799A, (q31_t)0x9592675B, (q31_t)0x471CECE6, + (q31_t)0x89BE50C3, (q31_t)0x30FBC54D, (q31_t)0x8275A0C0, (q31_t)0x18F8B83C, + (q31_t)0x80000000, (q31_t)0x00000000, (q31_t)0x8275A0C0, (q31_t)0xE70747C3, + (q31_t)0x89BE50C3, (q31_t)0xCF043AB2, (q31_t)0x9592675B, (q31_t)0xB8E31319, + (q31_t)0xA57D8666, (q31_t)0xA57D8666, (q31_t)0xB8E31319, (q31_t)0x9592675B, + (q31_t)0xCF043AB2, (q31_t)0x89BE50C3, (q31_t)0xE70747C3, (q31_t)0x8275A0C0}; /** @par @@ -8599,42 +3658,33 @@ const q31_t twiddleCoef_32_q31[48] = { Cos and Sin values are interleaved fashion @par Convert Floating point to Q31(Fixed point 1.31): - round(twiddleCoefQ31(i) * pow(2, 31)) + round(twiddleCoefQ31(i) * pow(2, 31)) */ const q31_t twiddleCoef_64_q31[96] = { - (q31_t)0x7FFFFFFF, (q31_t)0x00000000, (q31_t)0x7F62368F, - (q31_t)0x0C8BD35E, (q31_t)0x7D8A5F3F, (q31_t)0x18F8B83C, - (q31_t)0x7A7D055B, (q31_t)0x25280C5D, (q31_t)0x7641AF3C, - (q31_t)0x30FBC54D, (q31_t)0x70E2CBC6, (q31_t)0x3C56BA70, - (q31_t)0x6A6D98A4, (q31_t)0x471CECE6, (q31_t)0x62F201AC, - (q31_t)0x5133CC94, (q31_t)0x5A82799A, (q31_t)0x5A82799A, - (q31_t)0x5133CC94, (q31_t)0x62F201AC, (q31_t)0x471CECE6, - (q31_t)0x6A6D98A4, (q31_t)0x3C56BA70, (q31_t)0x70E2CBC6, - (q31_t)0x30FBC54D, (q31_t)0x7641AF3C, (q31_t)0x25280C5D, - (q31_t)0x7A7D055B, (q31_t)0x18F8B83C, (q31_t)0x7D8A5F3F, - (q31_t)0x0C8BD35E, (q31_t)0x7F62368F, (q31_t)0x00000000, - (q31_t)0x7FFFFFFF, (q31_t)0xF3742CA1, (q31_t)0x7F62368F, - (q31_t)0xE70747C3, (q31_t)0x7D8A5F3F, (q31_t)0xDAD7F3A2, - (q31_t)0x7A7D055B, (q31_t)0xCF043AB2, (q31_t)0x7641AF3C, - (q31_t)0xC3A9458F, (q31_t)0x70E2CBC6, (q31_t)0xB8E31319, - (q31_t)0x6A6D98A4, (q31_t)0xAECC336B, (q31_t)0x62F201AC, - (q31_t)0xA57D8666, (q31_t)0x5A82799A, (q31_t)0x9D0DFE53, - (q31_t)0x5133CC94, (q31_t)0x9592675B, (q31_t)0x471CECE6, - (q31_t)0x8F1D343A, (q31_t)0x3C56BA70, (q31_t)0x89BE50C3, - (q31_t)0x30FBC54D, (q31_t)0x8582FAA4, (q31_t)0x25280C5D, - (q31_t)0x8275A0C0, (q31_t)0x18F8B83C, (q31_t)0x809DC970, - (q31_t)0x0C8BD35E, (q31_t)0x80000000, (q31_t)0x00000000, - (q31_t)0x809DC970, (q31_t)0xF3742CA1, (q31_t)0x8275A0C0, - (q31_t)0xE70747C3, (q31_t)0x8582FAA4, (q31_t)0xDAD7F3A2, - (q31_t)0x89BE50C3, (q31_t)0xCF043AB2, (q31_t)0x8F1D343A, - (q31_t)0xC3A9458F, (q31_t)0x9592675B, (q31_t)0xB8E31319, - (q31_t)0x9D0DFE53, (q31_t)0xAECC336B, (q31_t)0xA57D8666, - (q31_t)0xA57D8666, (q31_t)0xAECC336B, (q31_t)0x9D0DFE53, - (q31_t)0xB8E31319, (q31_t)0x9592675B, (q31_t)0xC3A9458F, - (q31_t)0x8F1D343A, (q31_t)0xCF043AB2, (q31_t)0x89BE50C3, - (q31_t)0xDAD7F3A2, (q31_t)0x8582FAA4, (q31_t)0xE70747C3, - (q31_t)0x8275A0C0, (q31_t)0xF3742CA1, (q31_t)0x809DC970 -}; + (q31_t)0x7FFFFFFF, (q31_t)0x00000000, (q31_t)0x7F62368F, (q31_t)0x0C8BD35E, + (q31_t)0x7D8A5F3F, (q31_t)0x18F8B83C, (q31_t)0x7A7D055B, (q31_t)0x25280C5D, + (q31_t)0x7641AF3C, (q31_t)0x30FBC54D, (q31_t)0x70E2CBC6, (q31_t)0x3C56BA70, + (q31_t)0x6A6D98A4, (q31_t)0x471CECE6, (q31_t)0x62F201AC, (q31_t)0x5133CC94, + (q31_t)0x5A82799A, (q31_t)0x5A82799A, (q31_t)0x5133CC94, (q31_t)0x62F201AC, + (q31_t)0x471CECE6, (q31_t)0x6A6D98A4, (q31_t)0x3C56BA70, (q31_t)0x70E2CBC6, + (q31_t)0x30FBC54D, (q31_t)0x7641AF3C, (q31_t)0x25280C5D, (q31_t)0x7A7D055B, + (q31_t)0x18F8B83C, (q31_t)0x7D8A5F3F, (q31_t)0x0C8BD35E, (q31_t)0x7F62368F, + (q31_t)0x00000000, (q31_t)0x7FFFFFFF, (q31_t)0xF3742CA1, (q31_t)0x7F62368F, + (q31_t)0xE70747C3, (q31_t)0x7D8A5F3F, (q31_t)0xDAD7F3A2, (q31_t)0x7A7D055B, + (q31_t)0xCF043AB2, (q31_t)0x7641AF3C, (q31_t)0xC3A9458F, (q31_t)0x70E2CBC6, + (q31_t)0xB8E31319, (q31_t)0x6A6D98A4, (q31_t)0xAECC336B, (q31_t)0x62F201AC, + (q31_t)0xA57D8666, (q31_t)0x5A82799A, (q31_t)0x9D0DFE53, (q31_t)0x5133CC94, + (q31_t)0x9592675B, (q31_t)0x471CECE6, (q31_t)0x8F1D343A, (q31_t)0x3C56BA70, + (q31_t)0x89BE50C3, (q31_t)0x30FBC54D, (q31_t)0x8582FAA4, (q31_t)0x25280C5D, + (q31_t)0x8275A0C0, (q31_t)0x18F8B83C, (q31_t)0x809DC970, (q31_t)0x0C8BD35E, + (q31_t)0x80000000, (q31_t)0x00000000, (q31_t)0x809DC970, (q31_t)0xF3742CA1, + (q31_t)0x8275A0C0, (q31_t)0xE70747C3, (q31_t)0x8582FAA4, (q31_t)0xDAD7F3A2, + (q31_t)0x89BE50C3, (q31_t)0xCF043AB2, (q31_t)0x8F1D343A, (q31_t)0xC3A9458F, + (q31_t)0x9592675B, (q31_t)0xB8E31319, (q31_t)0x9D0DFE53, (q31_t)0xAECC336B, + (q31_t)0xA57D8666, (q31_t)0xA57D8666, (q31_t)0xAECC336B, (q31_t)0x9D0DFE53, + (q31_t)0xB8E31319, (q31_t)0x9592675B, (q31_t)0xC3A9458F, (q31_t)0x8F1D343A, + (q31_t)0xCF043AB2, (q31_t)0x89BE50C3, (q31_t)0xDAD7F3A2, (q31_t)0x8582FAA4, + (q31_t)0xE70747C3, (q31_t)0x8275A0C0, (q31_t)0xF3742CA1, (q31_t)0x809DC970}; /** @par @@ -8651,74 +3701,57 @@ const q31_t twiddleCoef_64_q31[96] = { Cos and Sin values are interleaved fashion @par Convert Floating point to Q31(Fixed point 1.31): - round(twiddleCoefQ31(i) * pow(2, 31)) + round(twiddleCoefQ31(i) * pow(2, 31)) */ const q31_t twiddleCoef_128_q31[192] = { - (q31_t)0x7FFFFFFF, (q31_t)0x00000000, (q31_t)0x7FD8878D, - (q31_t)0x0647D97C, (q31_t)0x7F62368F, (q31_t)0x0C8BD35E, - (q31_t)0x7E9D55FC, (q31_t)0x12C8106E, (q31_t)0x7D8A5F3F, - (q31_t)0x18F8B83C, (q31_t)0x7C29FBEE, (q31_t)0x1F19F97B, - (q31_t)0x7A7D055B, (q31_t)0x25280C5D, (q31_t)0x78848413, - (q31_t)0x2B1F34EB, (q31_t)0x7641AF3C, (q31_t)0x30FBC54D, - (q31_t)0x73B5EBD0, (q31_t)0x36BA2013, (q31_t)0x70E2CBC6, - (q31_t)0x3C56BA70, (q31_t)0x6DCA0D14, (q31_t)0x41CE1E64, - (q31_t)0x6A6D98A4, (q31_t)0x471CECE6, (q31_t)0x66CF811F, - (q31_t)0x4C3FDFF3, (q31_t)0x62F201AC, (q31_t)0x5133CC94, - (q31_t)0x5ED77C89, (q31_t)0x55F5A4D2, (q31_t)0x5A82799A, - (q31_t)0x5A82799A, (q31_t)0x55F5A4D2, (q31_t)0x5ED77C89, - (q31_t)0x5133CC94, (q31_t)0x62F201AC, (q31_t)0x4C3FDFF3, - (q31_t)0x66CF811F, (q31_t)0x471CECE6, (q31_t)0x6A6D98A4, - (q31_t)0x41CE1E64, (q31_t)0x6DCA0D14, (q31_t)0x3C56BA70, - (q31_t)0x70E2CBC6, (q31_t)0x36BA2013, (q31_t)0x73B5EBD0, - (q31_t)0x30FBC54D, (q31_t)0x7641AF3C, (q31_t)0x2B1F34EB, - (q31_t)0x78848413, (q31_t)0x25280C5D, (q31_t)0x7A7D055B, - (q31_t)0x1F19F97B, (q31_t)0x7C29FBEE, (q31_t)0x18F8B83C, - (q31_t)0x7D8A5F3F, (q31_t)0x12C8106E, (q31_t)0x7E9D55FC, - (q31_t)0x0C8BD35E, (q31_t)0x7F62368F, (q31_t)0x0647D97C, - (q31_t)0x7FD8878D, (q31_t)0x00000000, (q31_t)0x7FFFFFFF, - (q31_t)0xF9B82683, (q31_t)0x7FD8878D, (q31_t)0xF3742CA1, - (q31_t)0x7F62368F, (q31_t)0xED37EF91, (q31_t)0x7E9D55FC, - (q31_t)0xE70747C3, (q31_t)0x7D8A5F3F, (q31_t)0xE0E60684, - (q31_t)0x7C29FBEE, (q31_t)0xDAD7F3A2, (q31_t)0x7A7D055B, - (q31_t)0xD4E0CB14, (q31_t)0x78848413, (q31_t)0xCF043AB2, - (q31_t)0x7641AF3C, (q31_t)0xC945DFEC, (q31_t)0x73B5EBD0, - (q31_t)0xC3A9458F, (q31_t)0x70E2CBC6, (q31_t)0xBE31E19B, - (q31_t)0x6DCA0D14, (q31_t)0xB8E31319, (q31_t)0x6A6D98A4, - (q31_t)0xB3C0200C, (q31_t)0x66CF811F, (q31_t)0xAECC336B, - (q31_t)0x62F201AC, (q31_t)0xAA0A5B2D, (q31_t)0x5ED77C89, - (q31_t)0xA57D8666, (q31_t)0x5A82799A, (q31_t)0xA1288376, - (q31_t)0x55F5A4D2, (q31_t)0x9D0DFE53, (q31_t)0x5133CC94, - (q31_t)0x99307EE0, (q31_t)0x4C3FDFF3, (q31_t)0x9592675B, - (q31_t)0x471CECE6, (q31_t)0x9235F2EB, (q31_t)0x41CE1E64, - (q31_t)0x8F1D343A, (q31_t)0x3C56BA70, (q31_t)0x8C4A142F, - (q31_t)0x36BA2013, (q31_t)0x89BE50C3, (q31_t)0x30FBC54D, - (q31_t)0x877B7BEC, (q31_t)0x2B1F34EB, (q31_t)0x8582FAA4, - (q31_t)0x25280C5D, (q31_t)0x83D60411, (q31_t)0x1F19F97B, - (q31_t)0x8275A0C0, (q31_t)0x18F8B83C, (q31_t)0x8162AA03, - (q31_t)0x12C8106E, (q31_t)0x809DC970, (q31_t)0x0C8BD35E, - (q31_t)0x80277872, (q31_t)0x0647D97C, (q31_t)0x80000000, - (q31_t)0x00000000, (q31_t)0x80277872, (q31_t)0xF9B82683, - (q31_t)0x809DC970, (q31_t)0xF3742CA1, (q31_t)0x8162AA03, - (q31_t)0xED37EF91, (q31_t)0x8275A0C0, (q31_t)0xE70747C3, - (q31_t)0x83D60411, (q31_t)0xE0E60684, (q31_t)0x8582FAA4, - (q31_t)0xDAD7F3A2, (q31_t)0x877B7BEC, (q31_t)0xD4E0CB14, - (q31_t)0x89BE50C3, (q31_t)0xCF043AB2, (q31_t)0x8C4A142F, - (q31_t)0xC945DFEC, (q31_t)0x8F1D343A, (q31_t)0xC3A9458F, - (q31_t)0x9235F2EB, (q31_t)0xBE31E19B, (q31_t)0x9592675B, - (q31_t)0xB8E31319, (q31_t)0x99307EE0, (q31_t)0xB3C0200C, - (q31_t)0x9D0DFE53, (q31_t)0xAECC336B, (q31_t)0xA1288376, - (q31_t)0xAA0A5B2D, (q31_t)0xA57D8666, (q31_t)0xA57D8666, - (q31_t)0xAA0A5B2D, (q31_t)0xA1288376, (q31_t)0xAECC336B, - (q31_t)0x9D0DFE53, (q31_t)0xB3C0200C, (q31_t)0x99307EE0, - (q31_t)0xB8E31319, (q31_t)0x9592675B, (q31_t)0xBE31E19B, - (q31_t)0x9235F2EB, (q31_t)0xC3A9458F, (q31_t)0x8F1D343A, - (q31_t)0xC945DFEC, (q31_t)0x8C4A142F, (q31_t)0xCF043AB2, - (q31_t)0x89BE50C3, (q31_t)0xD4E0CB14, (q31_t)0x877B7BEC, - (q31_t)0xDAD7F3A2, (q31_t)0x8582FAA4, (q31_t)0xE0E60684, - (q31_t)0x83D60411, (q31_t)0xE70747C3, (q31_t)0x8275A0C0, - (q31_t)0xED37EF91, (q31_t)0x8162AA03, (q31_t)0xF3742CA1, - (q31_t)0x809DC970, (q31_t)0xF9B82683, (q31_t)0x80277872 -}; + (q31_t)0x7FFFFFFF, (q31_t)0x00000000, (q31_t)0x7FD8878D, (q31_t)0x0647D97C, + (q31_t)0x7F62368F, (q31_t)0x0C8BD35E, (q31_t)0x7E9D55FC, (q31_t)0x12C8106E, + (q31_t)0x7D8A5F3F, (q31_t)0x18F8B83C, (q31_t)0x7C29FBEE, (q31_t)0x1F19F97B, + (q31_t)0x7A7D055B, (q31_t)0x25280C5D, (q31_t)0x78848413, (q31_t)0x2B1F34EB, + (q31_t)0x7641AF3C, (q31_t)0x30FBC54D, (q31_t)0x73B5EBD0, (q31_t)0x36BA2013, + (q31_t)0x70E2CBC6, (q31_t)0x3C56BA70, (q31_t)0x6DCA0D14, (q31_t)0x41CE1E64, + (q31_t)0x6A6D98A4, (q31_t)0x471CECE6, (q31_t)0x66CF811F, (q31_t)0x4C3FDFF3, + (q31_t)0x62F201AC, (q31_t)0x5133CC94, (q31_t)0x5ED77C89, (q31_t)0x55F5A4D2, + (q31_t)0x5A82799A, (q31_t)0x5A82799A, (q31_t)0x55F5A4D2, (q31_t)0x5ED77C89, + (q31_t)0x5133CC94, (q31_t)0x62F201AC, (q31_t)0x4C3FDFF3, (q31_t)0x66CF811F, + (q31_t)0x471CECE6, (q31_t)0x6A6D98A4, (q31_t)0x41CE1E64, (q31_t)0x6DCA0D14, + (q31_t)0x3C56BA70, (q31_t)0x70E2CBC6, (q31_t)0x36BA2013, (q31_t)0x73B5EBD0, + (q31_t)0x30FBC54D, (q31_t)0x7641AF3C, (q31_t)0x2B1F34EB, (q31_t)0x78848413, + (q31_t)0x25280C5D, (q31_t)0x7A7D055B, (q31_t)0x1F19F97B, (q31_t)0x7C29FBEE, + (q31_t)0x18F8B83C, (q31_t)0x7D8A5F3F, (q31_t)0x12C8106E, (q31_t)0x7E9D55FC, + (q31_t)0x0C8BD35E, (q31_t)0x7F62368F, (q31_t)0x0647D97C, (q31_t)0x7FD8878D, + (q31_t)0x00000000, (q31_t)0x7FFFFFFF, (q31_t)0xF9B82683, (q31_t)0x7FD8878D, + (q31_t)0xF3742CA1, (q31_t)0x7F62368F, (q31_t)0xED37EF91, (q31_t)0x7E9D55FC, + (q31_t)0xE70747C3, (q31_t)0x7D8A5F3F, (q31_t)0xE0E60684, (q31_t)0x7C29FBEE, + (q31_t)0xDAD7F3A2, (q31_t)0x7A7D055B, (q31_t)0xD4E0CB14, (q31_t)0x78848413, + (q31_t)0xCF043AB2, (q31_t)0x7641AF3C, (q31_t)0xC945DFEC, (q31_t)0x73B5EBD0, + (q31_t)0xC3A9458F, (q31_t)0x70E2CBC6, (q31_t)0xBE31E19B, (q31_t)0x6DCA0D14, + (q31_t)0xB8E31319, (q31_t)0x6A6D98A4, (q31_t)0xB3C0200C, (q31_t)0x66CF811F, + (q31_t)0xAECC336B, (q31_t)0x62F201AC, (q31_t)0xAA0A5B2D, (q31_t)0x5ED77C89, + (q31_t)0xA57D8666, (q31_t)0x5A82799A, (q31_t)0xA1288376, (q31_t)0x55F5A4D2, + (q31_t)0x9D0DFE53, (q31_t)0x5133CC94, (q31_t)0x99307EE0, (q31_t)0x4C3FDFF3, + (q31_t)0x9592675B, (q31_t)0x471CECE6, (q31_t)0x9235F2EB, (q31_t)0x41CE1E64, + (q31_t)0x8F1D343A, (q31_t)0x3C56BA70, (q31_t)0x8C4A142F, (q31_t)0x36BA2013, + (q31_t)0x89BE50C3, (q31_t)0x30FBC54D, (q31_t)0x877B7BEC, (q31_t)0x2B1F34EB, + (q31_t)0x8582FAA4, (q31_t)0x25280C5D, (q31_t)0x83D60411, (q31_t)0x1F19F97B, + (q31_t)0x8275A0C0, (q31_t)0x18F8B83C, (q31_t)0x8162AA03, (q31_t)0x12C8106E, + (q31_t)0x809DC970, (q31_t)0x0C8BD35E, (q31_t)0x80277872, (q31_t)0x0647D97C, + (q31_t)0x80000000, (q31_t)0x00000000, (q31_t)0x80277872, (q31_t)0xF9B82683, + (q31_t)0x809DC970, (q31_t)0xF3742CA1, (q31_t)0x8162AA03, (q31_t)0xED37EF91, + (q31_t)0x8275A0C0, (q31_t)0xE70747C3, (q31_t)0x83D60411, (q31_t)0xE0E60684, + (q31_t)0x8582FAA4, (q31_t)0xDAD7F3A2, (q31_t)0x877B7BEC, (q31_t)0xD4E0CB14, + (q31_t)0x89BE50C3, (q31_t)0xCF043AB2, (q31_t)0x8C4A142F, (q31_t)0xC945DFEC, + (q31_t)0x8F1D343A, (q31_t)0xC3A9458F, (q31_t)0x9235F2EB, (q31_t)0xBE31E19B, + (q31_t)0x9592675B, (q31_t)0xB8E31319, (q31_t)0x99307EE0, (q31_t)0xB3C0200C, + (q31_t)0x9D0DFE53, (q31_t)0xAECC336B, (q31_t)0xA1288376, (q31_t)0xAA0A5B2D, + (q31_t)0xA57D8666, (q31_t)0xA57D8666, (q31_t)0xAA0A5B2D, (q31_t)0xA1288376, + (q31_t)0xAECC336B, (q31_t)0x9D0DFE53, (q31_t)0xB3C0200C, (q31_t)0x99307EE0, + (q31_t)0xB8E31319, (q31_t)0x9592675B, (q31_t)0xBE31E19B, (q31_t)0x9235F2EB, + (q31_t)0xC3A9458F, (q31_t)0x8F1D343A, (q31_t)0xC945DFEC, (q31_t)0x8C4A142F, + (q31_t)0xCF043AB2, (q31_t)0x89BE50C3, (q31_t)0xD4E0CB14, (q31_t)0x877B7BEC, + (q31_t)0xDAD7F3A2, (q31_t)0x8582FAA4, (q31_t)0xE0E60684, (q31_t)0x83D60411, + (q31_t)0xE70747C3, (q31_t)0x8275A0C0, (q31_t)0xED37EF91, (q31_t)0x8162AA03, + (q31_t)0xF3742CA1, (q31_t)0x809DC970, (q31_t)0xF9B82683, (q31_t)0x80277872}; /** @par @@ -8735,139 +3768,106 @@ const q31_t twiddleCoef_128_q31[192] = { Cos and Sin values are interleaved fashion @par Convert Floating point to Q31(Fixed point 1.31): - round(twiddleCoefQ31(i) * pow(2, 31)) - + round(twiddleCoefQ31(i) * pow(2, 31)) + */ const q31_t twiddleCoef_256_q31[384] = { - (q31_t)0x7FFFFFFF, (q31_t)0x00000000, (q31_t)0x7FF62182, - (q31_t)0x03242ABF, (q31_t)0x7FD8878D, (q31_t)0x0647D97C, - (q31_t)0x7FA736B4, (q31_t)0x096A9049, (q31_t)0x7F62368F, - (q31_t)0x0C8BD35E, (q31_t)0x7F0991C3, (q31_t)0x0FAB272B, - (q31_t)0x7E9D55FC, (q31_t)0x12C8106E, (q31_t)0x7E1D93E9, - (q31_t)0x15E21444, (q31_t)0x7D8A5F3F, (q31_t)0x18F8B83C, - (q31_t)0x7CE3CEB1, (q31_t)0x1C0B826A, (q31_t)0x7C29FBEE, - (q31_t)0x1F19F97B, (q31_t)0x7B5D039D, (q31_t)0x2223A4C5, - (q31_t)0x7A7D055B, (q31_t)0x25280C5D, (q31_t)0x798A23B1, - (q31_t)0x2826B928, (q31_t)0x78848413, (q31_t)0x2B1F34EB, - (q31_t)0x776C4EDB, (q31_t)0x2E110A62, (q31_t)0x7641AF3C, - (q31_t)0x30FBC54D, (q31_t)0x7504D345, (q31_t)0x33DEF287, - (q31_t)0x73B5EBD0, (q31_t)0x36BA2013, (q31_t)0x72552C84, - (q31_t)0x398CDD32, (q31_t)0x70E2CBC6, (q31_t)0x3C56BA70, - (q31_t)0x6F5F02B1, (q31_t)0x3F1749B7, (q31_t)0x6DCA0D14, - (q31_t)0x41CE1E64, (q31_t)0x6C242960, (q31_t)0x447ACD50, - (q31_t)0x6A6D98A4, (q31_t)0x471CECE6, (q31_t)0x68A69E81, - (q31_t)0x49B41533, (q31_t)0x66CF811F, (q31_t)0x4C3FDFF3, - (q31_t)0x64E88926, (q31_t)0x4EBFE8A4, (q31_t)0x62F201AC, - (q31_t)0x5133CC94, (q31_t)0x60EC3830, (q31_t)0x539B2AEF, - (q31_t)0x5ED77C89, (q31_t)0x55F5A4D2, (q31_t)0x5CB420DF, - (q31_t)0x5842DD54, (q31_t)0x5A82799A, (q31_t)0x5A82799A, - (q31_t)0x5842DD54, (q31_t)0x5CB420DF, (q31_t)0x55F5A4D2, - (q31_t)0x5ED77C89, (q31_t)0x539B2AEF, (q31_t)0x60EC3830, - (q31_t)0x5133CC94, (q31_t)0x62F201AC, (q31_t)0x4EBFE8A4, - (q31_t)0x64E88926, (q31_t)0x4C3FDFF3, (q31_t)0x66CF811F, - (q31_t)0x49B41533, (q31_t)0x68A69E81, (q31_t)0x471CECE6, - (q31_t)0x6A6D98A4, (q31_t)0x447ACD50, (q31_t)0x6C242960, - (q31_t)0x41CE1E64, (q31_t)0x6DCA0D14, (q31_t)0x3F1749B7, - (q31_t)0x6F5F02B1, (q31_t)0x3C56BA70, (q31_t)0x70E2CBC6, - (q31_t)0x398CDD32, (q31_t)0x72552C84, (q31_t)0x36BA2013, - (q31_t)0x73B5EBD0, (q31_t)0x33DEF287, (q31_t)0x7504D345, - (q31_t)0x30FBC54D, (q31_t)0x7641AF3C, (q31_t)0x2E110A62, - (q31_t)0x776C4EDB, (q31_t)0x2B1F34EB, (q31_t)0x78848413, - (q31_t)0x2826B928, (q31_t)0x798A23B1, (q31_t)0x25280C5D, - (q31_t)0x7A7D055B, (q31_t)0x2223A4C5, (q31_t)0x7B5D039D, - (q31_t)0x1F19F97B, (q31_t)0x7C29FBEE, (q31_t)0x1C0B826A, - (q31_t)0x7CE3CEB1, (q31_t)0x18F8B83C, (q31_t)0x7D8A5F3F, - (q31_t)0x15E21444, (q31_t)0x7E1D93E9, (q31_t)0x12C8106E, - (q31_t)0x7E9D55FC, (q31_t)0x0FAB272B, (q31_t)0x7F0991C3, - (q31_t)0x0C8BD35E, (q31_t)0x7F62368F, (q31_t)0x096A9049, - (q31_t)0x7FA736B4, (q31_t)0x0647D97C, (q31_t)0x7FD8878D, - (q31_t)0x03242ABF, (q31_t)0x7FF62182, (q31_t)0x00000000, - (q31_t)0x7FFFFFFF, (q31_t)0xFCDBD541, (q31_t)0x7FF62182, - (q31_t)0xF9B82683, (q31_t)0x7FD8878D, (q31_t)0xF6956FB6, - (q31_t)0x7FA736B4, (q31_t)0xF3742CA1, (q31_t)0x7F62368F, - (q31_t)0xF054D8D4, (q31_t)0x7F0991C3, (q31_t)0xED37EF91, - (q31_t)0x7E9D55FC, (q31_t)0xEA1DEBBB, (q31_t)0x7E1D93E9, - (q31_t)0xE70747C3, (q31_t)0x7D8A5F3F, (q31_t)0xE3F47D95, - (q31_t)0x7CE3CEB1, (q31_t)0xE0E60684, (q31_t)0x7C29FBEE, - (q31_t)0xDDDC5B3A, (q31_t)0x7B5D039D, (q31_t)0xDAD7F3A2, - (q31_t)0x7A7D055B, (q31_t)0xD7D946D7, (q31_t)0x798A23B1, - (q31_t)0xD4E0CB14, (q31_t)0x78848413, (q31_t)0xD1EEF59E, - (q31_t)0x776C4EDB, (q31_t)0xCF043AB2, (q31_t)0x7641AF3C, - (q31_t)0xCC210D78, (q31_t)0x7504D345, (q31_t)0xC945DFEC, - (q31_t)0x73B5EBD0, (q31_t)0xC67322CD, (q31_t)0x72552C84, - (q31_t)0xC3A9458F, (q31_t)0x70E2CBC6, (q31_t)0xC0E8B648, - (q31_t)0x6F5F02B1, (q31_t)0xBE31E19B, (q31_t)0x6DCA0D14, - (q31_t)0xBB8532AF, (q31_t)0x6C242960, (q31_t)0xB8E31319, - (q31_t)0x6A6D98A4, (q31_t)0xB64BEACC, (q31_t)0x68A69E81, - (q31_t)0xB3C0200C, (q31_t)0x66CF811F, (q31_t)0xB140175B, - (q31_t)0x64E88926, (q31_t)0xAECC336B, (q31_t)0x62F201AC, - (q31_t)0xAC64D510, (q31_t)0x60EC3830, (q31_t)0xAA0A5B2D, - (q31_t)0x5ED77C89, (q31_t)0xA7BD22AB, (q31_t)0x5CB420DF, - (q31_t)0xA57D8666, (q31_t)0x5A82799A, (q31_t)0xA34BDF20, - (q31_t)0x5842DD54, (q31_t)0xA1288376, (q31_t)0x55F5A4D2, - (q31_t)0x9F13C7D0, (q31_t)0x539B2AEF, (q31_t)0x9D0DFE53, - (q31_t)0x5133CC94, (q31_t)0x9B1776D9, (q31_t)0x4EBFE8A4, - (q31_t)0x99307EE0, (q31_t)0x4C3FDFF3, (q31_t)0x9759617E, - (q31_t)0x49B41533, (q31_t)0x9592675B, (q31_t)0x471CECE6, - (q31_t)0x93DBD69F, (q31_t)0x447ACD50, (q31_t)0x9235F2EB, - (q31_t)0x41CE1E64, (q31_t)0x90A0FD4E, (q31_t)0x3F1749B7, - (q31_t)0x8F1D343A, (q31_t)0x3C56BA70, (q31_t)0x8DAAD37B, - (q31_t)0x398CDD32, (q31_t)0x8C4A142F, (q31_t)0x36BA2013, - (q31_t)0x8AFB2CBA, (q31_t)0x33DEF287, (q31_t)0x89BE50C3, - (q31_t)0x30FBC54D, (q31_t)0x8893B124, (q31_t)0x2E110A62, - (q31_t)0x877B7BEC, (q31_t)0x2B1F34EB, (q31_t)0x8675DC4E, - (q31_t)0x2826B928, (q31_t)0x8582FAA4, (q31_t)0x25280C5D, - (q31_t)0x84A2FC62, (q31_t)0x2223A4C5, (q31_t)0x83D60411, - (q31_t)0x1F19F97B, (q31_t)0x831C314E, (q31_t)0x1C0B826A, - (q31_t)0x8275A0C0, (q31_t)0x18F8B83C, (q31_t)0x81E26C16, - (q31_t)0x15E21444, (q31_t)0x8162AA03, (q31_t)0x12C8106E, - (q31_t)0x80F66E3C, (q31_t)0x0FAB272B, (q31_t)0x809DC970, - (q31_t)0x0C8BD35E, (q31_t)0x8058C94C, (q31_t)0x096A9049, - (q31_t)0x80277872, (q31_t)0x0647D97C, (q31_t)0x8009DE7D, - (q31_t)0x03242ABF, (q31_t)0x80000000, (q31_t)0x00000000, - (q31_t)0x8009DE7D, (q31_t)0xFCDBD541, (q31_t)0x80277872, - (q31_t)0xF9B82683, (q31_t)0x8058C94C, (q31_t)0xF6956FB6, - (q31_t)0x809DC970, (q31_t)0xF3742CA1, (q31_t)0x80F66E3C, - (q31_t)0xF054D8D4, (q31_t)0x8162AA03, (q31_t)0xED37EF91, - (q31_t)0x81E26C16, (q31_t)0xEA1DEBBB, (q31_t)0x8275A0C0, - (q31_t)0xE70747C3, (q31_t)0x831C314E, (q31_t)0xE3F47D95, - (q31_t)0x83D60411, (q31_t)0xE0E60684, (q31_t)0x84A2FC62, - (q31_t)0xDDDC5B3A, (q31_t)0x8582FAA4, (q31_t)0xDAD7F3A2, - (q31_t)0x8675DC4E, (q31_t)0xD7D946D7, (q31_t)0x877B7BEC, - (q31_t)0xD4E0CB14, (q31_t)0x8893B124, (q31_t)0xD1EEF59E, - (q31_t)0x89BE50C3, (q31_t)0xCF043AB2, (q31_t)0x8AFB2CBA, - (q31_t)0xCC210D78, (q31_t)0x8C4A142F, (q31_t)0xC945DFEC, - (q31_t)0x8DAAD37B, (q31_t)0xC67322CD, (q31_t)0x8F1D343A, - (q31_t)0xC3A9458F, (q31_t)0x90A0FD4E, (q31_t)0xC0E8B648, - (q31_t)0x9235F2EB, (q31_t)0xBE31E19B, (q31_t)0x93DBD69F, - (q31_t)0xBB8532AF, (q31_t)0x9592675B, (q31_t)0xB8E31319, - (q31_t)0x9759617E, (q31_t)0xB64BEACC, (q31_t)0x99307EE0, - (q31_t)0xB3C0200C, (q31_t)0x9B1776D9, (q31_t)0xB140175B, - (q31_t)0x9D0DFE53, (q31_t)0xAECC336B, (q31_t)0x9F13C7D0, - (q31_t)0xAC64D510, (q31_t)0xA1288376, (q31_t)0xAA0A5B2D, - (q31_t)0xA34BDF20, (q31_t)0xA7BD22AB, (q31_t)0xA57D8666, - (q31_t)0xA57D8666, (q31_t)0xA7BD22AB, (q31_t)0xA34BDF20, - (q31_t)0xAA0A5B2D, (q31_t)0xA1288376, (q31_t)0xAC64D510, - (q31_t)0x9F13C7D0, (q31_t)0xAECC336B, (q31_t)0x9D0DFE53, - (q31_t)0xB140175B, (q31_t)0x9B1776D9, (q31_t)0xB3C0200C, - (q31_t)0x99307EE0, (q31_t)0xB64BEACC, (q31_t)0x9759617E, - (q31_t)0xB8E31319, (q31_t)0x9592675B, (q31_t)0xBB8532AF, - (q31_t)0x93DBD69F, (q31_t)0xBE31E19B, (q31_t)0x9235F2EB, - (q31_t)0xC0E8B648, (q31_t)0x90A0FD4E, (q31_t)0xC3A9458F, - (q31_t)0x8F1D343A, (q31_t)0xC67322CD, (q31_t)0x8DAAD37B, - (q31_t)0xC945DFEC, (q31_t)0x8C4A142F, (q31_t)0xCC210D78, - (q31_t)0x8AFB2CBA, (q31_t)0xCF043AB2, (q31_t)0x89BE50C3, - (q31_t)0xD1EEF59E, (q31_t)0x8893B124, (q31_t)0xD4E0CB14, - (q31_t)0x877B7BEC, (q31_t)0xD7D946D7, (q31_t)0x8675DC4E, - (q31_t)0xDAD7F3A2, (q31_t)0x8582FAA4, (q31_t)0xDDDC5B3A, - (q31_t)0x84A2FC62, (q31_t)0xE0E60684, (q31_t)0x83D60411, - (q31_t)0xE3F47D95, (q31_t)0x831C314E, (q31_t)0xE70747C3, - (q31_t)0x8275A0C0, (q31_t)0xEA1DEBBB, (q31_t)0x81E26C16, - (q31_t)0xED37EF91, (q31_t)0x8162AA03, (q31_t)0xF054D8D4, - (q31_t)0x80F66E3C, (q31_t)0xF3742CA1, (q31_t)0x809DC970, - (q31_t)0xF6956FB6, (q31_t)0x8058C94C, (q31_t)0xF9B82683, - (q31_t)0x80277872, (q31_t)0xFCDBD541, (q31_t)0x8009DE7D -}; + (q31_t)0x7FFFFFFF, (q31_t)0x00000000, (q31_t)0x7FF62182, (q31_t)0x03242ABF, + (q31_t)0x7FD8878D, (q31_t)0x0647D97C, (q31_t)0x7FA736B4, (q31_t)0x096A9049, + (q31_t)0x7F62368F, (q31_t)0x0C8BD35E, (q31_t)0x7F0991C3, (q31_t)0x0FAB272B, + (q31_t)0x7E9D55FC, (q31_t)0x12C8106E, (q31_t)0x7E1D93E9, (q31_t)0x15E21444, + (q31_t)0x7D8A5F3F, (q31_t)0x18F8B83C, (q31_t)0x7CE3CEB1, (q31_t)0x1C0B826A, + (q31_t)0x7C29FBEE, (q31_t)0x1F19F97B, (q31_t)0x7B5D039D, (q31_t)0x2223A4C5, + (q31_t)0x7A7D055B, (q31_t)0x25280C5D, (q31_t)0x798A23B1, (q31_t)0x2826B928, + (q31_t)0x78848413, (q31_t)0x2B1F34EB, (q31_t)0x776C4EDB, (q31_t)0x2E110A62, + (q31_t)0x7641AF3C, (q31_t)0x30FBC54D, (q31_t)0x7504D345, (q31_t)0x33DEF287, + (q31_t)0x73B5EBD0, (q31_t)0x36BA2013, (q31_t)0x72552C84, (q31_t)0x398CDD32, + (q31_t)0x70E2CBC6, (q31_t)0x3C56BA70, (q31_t)0x6F5F02B1, (q31_t)0x3F1749B7, + (q31_t)0x6DCA0D14, (q31_t)0x41CE1E64, (q31_t)0x6C242960, (q31_t)0x447ACD50, + (q31_t)0x6A6D98A4, (q31_t)0x471CECE6, (q31_t)0x68A69E81, (q31_t)0x49B41533, + (q31_t)0x66CF811F, (q31_t)0x4C3FDFF3, (q31_t)0x64E88926, (q31_t)0x4EBFE8A4, + (q31_t)0x62F201AC, (q31_t)0x5133CC94, (q31_t)0x60EC3830, (q31_t)0x539B2AEF, + (q31_t)0x5ED77C89, (q31_t)0x55F5A4D2, (q31_t)0x5CB420DF, (q31_t)0x5842DD54, + (q31_t)0x5A82799A, (q31_t)0x5A82799A, (q31_t)0x5842DD54, (q31_t)0x5CB420DF, + (q31_t)0x55F5A4D2, (q31_t)0x5ED77C89, (q31_t)0x539B2AEF, (q31_t)0x60EC3830, + (q31_t)0x5133CC94, (q31_t)0x62F201AC, (q31_t)0x4EBFE8A4, (q31_t)0x64E88926, + (q31_t)0x4C3FDFF3, (q31_t)0x66CF811F, (q31_t)0x49B41533, (q31_t)0x68A69E81, + (q31_t)0x471CECE6, (q31_t)0x6A6D98A4, (q31_t)0x447ACD50, (q31_t)0x6C242960, + (q31_t)0x41CE1E64, (q31_t)0x6DCA0D14, (q31_t)0x3F1749B7, (q31_t)0x6F5F02B1, + (q31_t)0x3C56BA70, (q31_t)0x70E2CBC6, (q31_t)0x398CDD32, (q31_t)0x72552C84, + (q31_t)0x36BA2013, (q31_t)0x73B5EBD0, (q31_t)0x33DEF287, (q31_t)0x7504D345, + (q31_t)0x30FBC54D, (q31_t)0x7641AF3C, (q31_t)0x2E110A62, (q31_t)0x776C4EDB, + (q31_t)0x2B1F34EB, (q31_t)0x78848413, (q31_t)0x2826B928, (q31_t)0x798A23B1, + (q31_t)0x25280C5D, (q31_t)0x7A7D055B, (q31_t)0x2223A4C5, (q31_t)0x7B5D039D, + (q31_t)0x1F19F97B, (q31_t)0x7C29FBEE, (q31_t)0x1C0B826A, (q31_t)0x7CE3CEB1, + (q31_t)0x18F8B83C, (q31_t)0x7D8A5F3F, (q31_t)0x15E21444, (q31_t)0x7E1D93E9, + (q31_t)0x12C8106E, (q31_t)0x7E9D55FC, (q31_t)0x0FAB272B, (q31_t)0x7F0991C3, + (q31_t)0x0C8BD35E, (q31_t)0x7F62368F, (q31_t)0x096A9049, (q31_t)0x7FA736B4, + (q31_t)0x0647D97C, (q31_t)0x7FD8878D, (q31_t)0x03242ABF, (q31_t)0x7FF62182, + (q31_t)0x00000000, (q31_t)0x7FFFFFFF, (q31_t)0xFCDBD541, (q31_t)0x7FF62182, + (q31_t)0xF9B82683, (q31_t)0x7FD8878D, (q31_t)0xF6956FB6, (q31_t)0x7FA736B4, + (q31_t)0xF3742CA1, (q31_t)0x7F62368F, (q31_t)0xF054D8D4, (q31_t)0x7F0991C3, + (q31_t)0xED37EF91, (q31_t)0x7E9D55FC, (q31_t)0xEA1DEBBB, (q31_t)0x7E1D93E9, + (q31_t)0xE70747C3, (q31_t)0x7D8A5F3F, (q31_t)0xE3F47D95, (q31_t)0x7CE3CEB1, + (q31_t)0xE0E60684, (q31_t)0x7C29FBEE, (q31_t)0xDDDC5B3A, (q31_t)0x7B5D039D, + (q31_t)0xDAD7F3A2, (q31_t)0x7A7D055B, (q31_t)0xD7D946D7, (q31_t)0x798A23B1, + (q31_t)0xD4E0CB14, (q31_t)0x78848413, (q31_t)0xD1EEF59E, (q31_t)0x776C4EDB, + (q31_t)0xCF043AB2, (q31_t)0x7641AF3C, (q31_t)0xCC210D78, (q31_t)0x7504D345, + (q31_t)0xC945DFEC, (q31_t)0x73B5EBD0, (q31_t)0xC67322CD, (q31_t)0x72552C84, + (q31_t)0xC3A9458F, (q31_t)0x70E2CBC6, (q31_t)0xC0E8B648, (q31_t)0x6F5F02B1, + (q31_t)0xBE31E19B, (q31_t)0x6DCA0D14, (q31_t)0xBB8532AF, (q31_t)0x6C242960, + (q31_t)0xB8E31319, (q31_t)0x6A6D98A4, (q31_t)0xB64BEACC, (q31_t)0x68A69E81, + (q31_t)0xB3C0200C, (q31_t)0x66CF811F, (q31_t)0xB140175B, (q31_t)0x64E88926, + (q31_t)0xAECC336B, (q31_t)0x62F201AC, (q31_t)0xAC64D510, (q31_t)0x60EC3830, + (q31_t)0xAA0A5B2D, (q31_t)0x5ED77C89, (q31_t)0xA7BD22AB, (q31_t)0x5CB420DF, + (q31_t)0xA57D8666, (q31_t)0x5A82799A, (q31_t)0xA34BDF20, (q31_t)0x5842DD54, + (q31_t)0xA1288376, (q31_t)0x55F5A4D2, (q31_t)0x9F13C7D0, (q31_t)0x539B2AEF, + (q31_t)0x9D0DFE53, (q31_t)0x5133CC94, (q31_t)0x9B1776D9, (q31_t)0x4EBFE8A4, + (q31_t)0x99307EE0, (q31_t)0x4C3FDFF3, (q31_t)0x9759617E, (q31_t)0x49B41533, + (q31_t)0x9592675B, (q31_t)0x471CECE6, (q31_t)0x93DBD69F, (q31_t)0x447ACD50, + (q31_t)0x9235F2EB, (q31_t)0x41CE1E64, (q31_t)0x90A0FD4E, (q31_t)0x3F1749B7, + (q31_t)0x8F1D343A, (q31_t)0x3C56BA70, (q31_t)0x8DAAD37B, (q31_t)0x398CDD32, + (q31_t)0x8C4A142F, (q31_t)0x36BA2013, (q31_t)0x8AFB2CBA, (q31_t)0x33DEF287, + (q31_t)0x89BE50C3, (q31_t)0x30FBC54D, (q31_t)0x8893B124, (q31_t)0x2E110A62, + (q31_t)0x877B7BEC, (q31_t)0x2B1F34EB, (q31_t)0x8675DC4E, (q31_t)0x2826B928, + (q31_t)0x8582FAA4, (q31_t)0x25280C5D, (q31_t)0x84A2FC62, (q31_t)0x2223A4C5, + (q31_t)0x83D60411, (q31_t)0x1F19F97B, (q31_t)0x831C314E, (q31_t)0x1C0B826A, + (q31_t)0x8275A0C0, (q31_t)0x18F8B83C, (q31_t)0x81E26C16, (q31_t)0x15E21444, + (q31_t)0x8162AA03, (q31_t)0x12C8106E, (q31_t)0x80F66E3C, (q31_t)0x0FAB272B, + (q31_t)0x809DC970, (q31_t)0x0C8BD35E, (q31_t)0x8058C94C, (q31_t)0x096A9049, + (q31_t)0x80277872, (q31_t)0x0647D97C, (q31_t)0x8009DE7D, (q31_t)0x03242ABF, + (q31_t)0x80000000, (q31_t)0x00000000, (q31_t)0x8009DE7D, (q31_t)0xFCDBD541, + (q31_t)0x80277872, (q31_t)0xF9B82683, (q31_t)0x8058C94C, (q31_t)0xF6956FB6, + (q31_t)0x809DC970, (q31_t)0xF3742CA1, (q31_t)0x80F66E3C, (q31_t)0xF054D8D4, + (q31_t)0x8162AA03, (q31_t)0xED37EF91, (q31_t)0x81E26C16, (q31_t)0xEA1DEBBB, + (q31_t)0x8275A0C0, (q31_t)0xE70747C3, (q31_t)0x831C314E, (q31_t)0xE3F47D95, + (q31_t)0x83D60411, (q31_t)0xE0E60684, (q31_t)0x84A2FC62, (q31_t)0xDDDC5B3A, + (q31_t)0x8582FAA4, (q31_t)0xDAD7F3A2, (q31_t)0x8675DC4E, (q31_t)0xD7D946D7, + (q31_t)0x877B7BEC, (q31_t)0xD4E0CB14, (q31_t)0x8893B124, (q31_t)0xD1EEF59E, + (q31_t)0x89BE50C3, (q31_t)0xCF043AB2, (q31_t)0x8AFB2CBA, (q31_t)0xCC210D78, + (q31_t)0x8C4A142F, (q31_t)0xC945DFEC, (q31_t)0x8DAAD37B, (q31_t)0xC67322CD, + (q31_t)0x8F1D343A, (q31_t)0xC3A9458F, (q31_t)0x90A0FD4E, (q31_t)0xC0E8B648, + (q31_t)0x9235F2EB, (q31_t)0xBE31E19B, (q31_t)0x93DBD69F, (q31_t)0xBB8532AF, + (q31_t)0x9592675B, (q31_t)0xB8E31319, (q31_t)0x9759617E, (q31_t)0xB64BEACC, + (q31_t)0x99307EE0, (q31_t)0xB3C0200C, (q31_t)0x9B1776D9, (q31_t)0xB140175B, + (q31_t)0x9D0DFE53, (q31_t)0xAECC336B, (q31_t)0x9F13C7D0, (q31_t)0xAC64D510, + (q31_t)0xA1288376, (q31_t)0xAA0A5B2D, (q31_t)0xA34BDF20, (q31_t)0xA7BD22AB, + (q31_t)0xA57D8666, (q31_t)0xA57D8666, (q31_t)0xA7BD22AB, (q31_t)0xA34BDF20, + (q31_t)0xAA0A5B2D, (q31_t)0xA1288376, (q31_t)0xAC64D510, (q31_t)0x9F13C7D0, + (q31_t)0xAECC336B, (q31_t)0x9D0DFE53, (q31_t)0xB140175B, (q31_t)0x9B1776D9, + (q31_t)0xB3C0200C, (q31_t)0x99307EE0, (q31_t)0xB64BEACC, (q31_t)0x9759617E, + (q31_t)0xB8E31319, (q31_t)0x9592675B, (q31_t)0xBB8532AF, (q31_t)0x93DBD69F, + (q31_t)0xBE31E19B, (q31_t)0x9235F2EB, (q31_t)0xC0E8B648, (q31_t)0x90A0FD4E, + (q31_t)0xC3A9458F, (q31_t)0x8F1D343A, (q31_t)0xC67322CD, (q31_t)0x8DAAD37B, + (q31_t)0xC945DFEC, (q31_t)0x8C4A142F, (q31_t)0xCC210D78, (q31_t)0x8AFB2CBA, + (q31_t)0xCF043AB2, (q31_t)0x89BE50C3, (q31_t)0xD1EEF59E, (q31_t)0x8893B124, + (q31_t)0xD4E0CB14, (q31_t)0x877B7BEC, (q31_t)0xD7D946D7, (q31_t)0x8675DC4E, + (q31_t)0xDAD7F3A2, (q31_t)0x8582FAA4, (q31_t)0xDDDC5B3A, (q31_t)0x84A2FC62, + (q31_t)0xE0E60684, (q31_t)0x83D60411, (q31_t)0xE3F47D95, (q31_t)0x831C314E, + (q31_t)0xE70747C3, (q31_t)0x8275A0C0, (q31_t)0xEA1DEBBB, (q31_t)0x81E26C16, + (q31_t)0xED37EF91, (q31_t)0x8162AA03, (q31_t)0xF054D8D4, (q31_t)0x80F66E3C, + (q31_t)0xF3742CA1, (q31_t)0x809DC970, (q31_t)0xF6956FB6, (q31_t)0x8058C94C, + (q31_t)0xF9B82683, (q31_t)0x80277872, (q31_t)0xFCDBD541, (q31_t)0x8009DE7D}; /** @par @@ -8884,267 +3884,202 @@ const q31_t twiddleCoef_256_q31[384] = { Cos and Sin values are interleaved fashion @par Convert Floating point to Q31(Fixed point 1.31): - round(twiddleCoefQ31(i) * pow(2, 31)) - + round(twiddleCoefQ31(i) * pow(2, 31)) + */ const q31_t twiddleCoef_512_q31[768] = { - (q31_t)0x7FFFFFFF, (q31_t)0x00000000, (q31_t)0x7FFD885A, - (q31_t)0x01921D1F, (q31_t)0x7FF62182, (q31_t)0x03242ABF, - (q31_t)0x7FE9CBC0, (q31_t)0x04B6195D, (q31_t)0x7FD8878D, - (q31_t)0x0647D97C, (q31_t)0x7FC25596, (q31_t)0x07D95B9E, - (q31_t)0x7FA736B4, (q31_t)0x096A9049, (q31_t)0x7F872BF3, - (q31_t)0x0AFB6805, (q31_t)0x7F62368F, (q31_t)0x0C8BD35E, - (q31_t)0x7F3857F5, (q31_t)0x0E1BC2E3, (q31_t)0x7F0991C3, - (q31_t)0x0FAB272B, (q31_t)0x7ED5E5C6, (q31_t)0x1139F0CE, - (q31_t)0x7E9D55FC, (q31_t)0x12C8106E, (q31_t)0x7E5FE493, - (q31_t)0x145576B1, (q31_t)0x7E1D93E9, (q31_t)0x15E21444, - (q31_t)0x7DD6668E, (q31_t)0x176DD9DE, (q31_t)0x7D8A5F3F, - (q31_t)0x18F8B83C, (q31_t)0x7D3980EC, (q31_t)0x1A82A025, - (q31_t)0x7CE3CEB1, (q31_t)0x1C0B826A, (q31_t)0x7C894BDD, - (q31_t)0x1D934FE5, (q31_t)0x7C29FBEE, (q31_t)0x1F19F97B, - (q31_t)0x7BC5E28F, (q31_t)0x209F701C, (q31_t)0x7B5D039D, - (q31_t)0x2223A4C5, (q31_t)0x7AEF6323, (q31_t)0x23A6887E, - (q31_t)0x7A7D055B, (q31_t)0x25280C5D, (q31_t)0x7A05EEAD, - (q31_t)0x26A82185, (q31_t)0x798A23B1, (q31_t)0x2826B928, - (q31_t)0x7909A92C, (q31_t)0x29A3C484, (q31_t)0x78848413, - (q31_t)0x2B1F34EB, (q31_t)0x77FAB988, (q31_t)0x2C98FBBA, - (q31_t)0x776C4EDB, (q31_t)0x2E110A62, (q31_t)0x76D94988, - (q31_t)0x2F875262, (q31_t)0x7641AF3C, (q31_t)0x30FBC54D, - (q31_t)0x75A585CF, (q31_t)0x326E54C7, (q31_t)0x7504D345, - (q31_t)0x33DEF287, (q31_t)0x745F9DD1, (q31_t)0x354D9056, - (q31_t)0x73B5EBD0, (q31_t)0x36BA2013, (q31_t)0x7307C3D0, - (q31_t)0x382493B0, (q31_t)0x72552C84, (q31_t)0x398CDD32, - (q31_t)0x719E2CD2, (q31_t)0x3AF2EEB7, (q31_t)0x70E2CBC6, - (q31_t)0x3C56BA70, (q31_t)0x70231099, (q31_t)0x3DB832A5, - (q31_t)0x6F5F02B1, (q31_t)0x3F1749B7, (q31_t)0x6E96A99C, - (q31_t)0x4073F21D, (q31_t)0x6DCA0D14, (q31_t)0x41CE1E64, - (q31_t)0x6CF934FB, (q31_t)0x4325C135, (q31_t)0x6C242960, - (q31_t)0x447ACD50, (q31_t)0x6B4AF278, (q31_t)0x45CD358F, - (q31_t)0x6A6D98A4, (q31_t)0x471CECE6, (q31_t)0x698C246C, - (q31_t)0x4869E664, (q31_t)0x68A69E81, (q31_t)0x49B41533, - (q31_t)0x67BD0FBC, (q31_t)0x4AFB6C97, (q31_t)0x66CF811F, - (q31_t)0x4C3FDFF3, (q31_t)0x65DDFBD3, (q31_t)0x4D8162C4, - (q31_t)0x64E88926, (q31_t)0x4EBFE8A4, (q31_t)0x63EF328F, - (q31_t)0x4FFB654D, (q31_t)0x62F201AC, (q31_t)0x5133CC94, - (q31_t)0x61F1003E, (q31_t)0x5269126E, (q31_t)0x60EC3830, - (q31_t)0x539B2AEF, (q31_t)0x5FE3B38D, (q31_t)0x54CA0A4A, - (q31_t)0x5ED77C89, (q31_t)0x55F5A4D2, (q31_t)0x5DC79D7C, - (q31_t)0x571DEEF9, (q31_t)0x5CB420DF, (q31_t)0x5842DD54, - (q31_t)0x5B9D1153, (q31_t)0x59646497, (q31_t)0x5A82799A, - (q31_t)0x5A82799A, (q31_t)0x59646497, (q31_t)0x5B9D1153, - (q31_t)0x5842DD54, (q31_t)0x5CB420DF, (q31_t)0x571DEEF9, - (q31_t)0x5DC79D7C, (q31_t)0x55F5A4D2, (q31_t)0x5ED77C89, - (q31_t)0x54CA0A4A, (q31_t)0x5FE3B38D, (q31_t)0x539B2AEF, - (q31_t)0x60EC3830, (q31_t)0x5269126E, (q31_t)0x61F1003E, - (q31_t)0x5133CC94, (q31_t)0x62F201AC, (q31_t)0x4FFB654D, - (q31_t)0x63EF328F, (q31_t)0x4EBFE8A4, (q31_t)0x64E88926, - (q31_t)0x4D8162C4, (q31_t)0x65DDFBD3, (q31_t)0x4C3FDFF3, - (q31_t)0x66CF811F, (q31_t)0x4AFB6C97, (q31_t)0x67BD0FBC, - (q31_t)0x49B41533, (q31_t)0x68A69E81, (q31_t)0x4869E664, - (q31_t)0x698C246C, (q31_t)0x471CECE6, (q31_t)0x6A6D98A4, - (q31_t)0x45CD358F, (q31_t)0x6B4AF278, (q31_t)0x447ACD50, - (q31_t)0x6C242960, (q31_t)0x4325C135, (q31_t)0x6CF934FB, - (q31_t)0x41CE1E64, (q31_t)0x6DCA0D14, (q31_t)0x4073F21D, - (q31_t)0x6E96A99C, (q31_t)0x3F1749B7, (q31_t)0x6F5F02B1, - (q31_t)0x3DB832A5, (q31_t)0x70231099, (q31_t)0x3C56BA70, - (q31_t)0x70E2CBC6, (q31_t)0x3AF2EEB7, (q31_t)0x719E2CD2, - (q31_t)0x398CDD32, (q31_t)0x72552C84, (q31_t)0x382493B0, - (q31_t)0x7307C3D0, (q31_t)0x36BA2013, (q31_t)0x73B5EBD0, - (q31_t)0x354D9056, (q31_t)0x745F9DD1, (q31_t)0x33DEF287, - (q31_t)0x7504D345, (q31_t)0x326E54C7, (q31_t)0x75A585CF, - (q31_t)0x30FBC54D, (q31_t)0x7641AF3C, (q31_t)0x2F875262, - (q31_t)0x76D94988, (q31_t)0x2E110A62, (q31_t)0x776C4EDB, - (q31_t)0x2C98FBBA, (q31_t)0x77FAB988, (q31_t)0x2B1F34EB, - (q31_t)0x78848413, (q31_t)0x29A3C484, (q31_t)0x7909A92C, - (q31_t)0x2826B928, (q31_t)0x798A23B1, (q31_t)0x26A82185, - (q31_t)0x7A05EEAD, (q31_t)0x25280C5D, (q31_t)0x7A7D055B, - (q31_t)0x23A6887E, (q31_t)0x7AEF6323, (q31_t)0x2223A4C5, - (q31_t)0x7B5D039D, (q31_t)0x209F701C, (q31_t)0x7BC5E28F, - (q31_t)0x1F19F97B, (q31_t)0x7C29FBEE, (q31_t)0x1D934FE5, - (q31_t)0x7C894BDD, (q31_t)0x1C0B826A, (q31_t)0x7CE3CEB1, - (q31_t)0x1A82A025, (q31_t)0x7D3980EC, (q31_t)0x18F8B83C, - (q31_t)0x7D8A5F3F, (q31_t)0x176DD9DE, (q31_t)0x7DD6668E, - (q31_t)0x15E21444, (q31_t)0x7E1D93E9, (q31_t)0x145576B1, - (q31_t)0x7E5FE493, (q31_t)0x12C8106E, (q31_t)0x7E9D55FC, - (q31_t)0x1139F0CE, (q31_t)0x7ED5E5C6, (q31_t)0x0FAB272B, - (q31_t)0x7F0991C3, (q31_t)0x0E1BC2E3, (q31_t)0x7F3857F5, - (q31_t)0x0C8BD35E, (q31_t)0x7F62368F, (q31_t)0x0AFB6805, - (q31_t)0x7F872BF3, (q31_t)0x096A9049, (q31_t)0x7FA736B4, - (q31_t)0x07D95B9E, (q31_t)0x7FC25596, (q31_t)0x0647D97C, - (q31_t)0x7FD8878D, (q31_t)0x04B6195D, (q31_t)0x7FE9CBC0, - (q31_t)0x03242ABF, (q31_t)0x7FF62182, (q31_t)0x01921D1F, - (q31_t)0x7FFD885A, (q31_t)0x00000000, (q31_t)0x7FFFFFFF, - (q31_t)0xFE6DE2E0, (q31_t)0x7FFD885A, (q31_t)0xFCDBD541, - (q31_t)0x7FF62182, (q31_t)0xFB49E6A2, (q31_t)0x7FE9CBC0, - (q31_t)0xF9B82683, (q31_t)0x7FD8878D, (q31_t)0xF826A461, - (q31_t)0x7FC25596, (q31_t)0xF6956FB6, (q31_t)0x7FA736B4, - (q31_t)0xF50497FA, (q31_t)0x7F872BF3, (q31_t)0xF3742CA1, - (q31_t)0x7F62368F, (q31_t)0xF1E43D1C, (q31_t)0x7F3857F5, - (q31_t)0xF054D8D4, (q31_t)0x7F0991C3, (q31_t)0xEEC60F31, - (q31_t)0x7ED5E5C6, (q31_t)0xED37EF91, (q31_t)0x7E9D55FC, - (q31_t)0xEBAA894E, (q31_t)0x7E5FE493, (q31_t)0xEA1DEBBB, - (q31_t)0x7E1D93E9, (q31_t)0xE8922621, (q31_t)0x7DD6668E, - (q31_t)0xE70747C3, (q31_t)0x7D8A5F3F, (q31_t)0xE57D5FDA, - (q31_t)0x7D3980EC, (q31_t)0xE3F47D95, (q31_t)0x7CE3CEB1, - (q31_t)0xE26CB01A, (q31_t)0x7C894BDD, (q31_t)0xE0E60684, - (q31_t)0x7C29FBEE, (q31_t)0xDF608FE3, (q31_t)0x7BC5E28F, - (q31_t)0xDDDC5B3A, (q31_t)0x7B5D039D, (q31_t)0xDC597781, - (q31_t)0x7AEF6323, (q31_t)0xDAD7F3A2, (q31_t)0x7A7D055B, - (q31_t)0xD957DE7A, (q31_t)0x7A05EEAD, (q31_t)0xD7D946D7, - (q31_t)0x798A23B1, (q31_t)0xD65C3B7B, (q31_t)0x7909A92C, - (q31_t)0xD4E0CB14, (q31_t)0x78848413, (q31_t)0xD3670445, - (q31_t)0x77FAB988, (q31_t)0xD1EEF59E, (q31_t)0x776C4EDB, - (q31_t)0xD078AD9D, (q31_t)0x76D94988, (q31_t)0xCF043AB2, - (q31_t)0x7641AF3C, (q31_t)0xCD91AB38, (q31_t)0x75A585CF, - (q31_t)0xCC210D78, (q31_t)0x7504D345, (q31_t)0xCAB26FA9, - (q31_t)0x745F9DD1, (q31_t)0xC945DFEC, (q31_t)0x73B5EBD0, - (q31_t)0xC7DB6C50, (q31_t)0x7307C3D0, (q31_t)0xC67322CD, - (q31_t)0x72552C84, (q31_t)0xC50D1148, (q31_t)0x719E2CD2, - (q31_t)0xC3A9458F, (q31_t)0x70E2CBC6, (q31_t)0xC247CD5A, - (q31_t)0x70231099, (q31_t)0xC0E8B648, (q31_t)0x6F5F02B1, - (q31_t)0xBF8C0DE2, (q31_t)0x6E96A99C, (q31_t)0xBE31E19B, - (q31_t)0x6DCA0D14, (q31_t)0xBCDA3ECA, (q31_t)0x6CF934FB, - (q31_t)0xBB8532AF, (q31_t)0x6C242960, (q31_t)0xBA32CA70, - (q31_t)0x6B4AF278, (q31_t)0xB8E31319, (q31_t)0x6A6D98A4, - (q31_t)0xB796199B, (q31_t)0x698C246C, (q31_t)0xB64BEACC, - (q31_t)0x68A69E81, (q31_t)0xB5049368, (q31_t)0x67BD0FBC, - (q31_t)0xB3C0200C, (q31_t)0x66CF811F, (q31_t)0xB27E9D3B, - (q31_t)0x65DDFBD3, (q31_t)0xB140175B, (q31_t)0x64E88926, - (q31_t)0xB0049AB2, (q31_t)0x63EF328F, (q31_t)0xAECC336B, - (q31_t)0x62F201AC, (q31_t)0xAD96ED91, (q31_t)0x61F1003E, - (q31_t)0xAC64D510, (q31_t)0x60EC3830, (q31_t)0xAB35F5B5, - (q31_t)0x5FE3B38D, (q31_t)0xAA0A5B2D, (q31_t)0x5ED77C89, - (q31_t)0xA8E21106, (q31_t)0x5DC79D7C, (q31_t)0xA7BD22AB, - (q31_t)0x5CB420DF, (q31_t)0xA69B9B68, (q31_t)0x5B9D1153, - (q31_t)0xA57D8666, (q31_t)0x5A82799A, (q31_t)0xA462EEAC, - (q31_t)0x59646497, (q31_t)0xA34BDF20, (q31_t)0x5842DD54, - (q31_t)0xA2386283, (q31_t)0x571DEEF9, (q31_t)0xA1288376, - (q31_t)0x55F5A4D2, (q31_t)0xA01C4C72, (q31_t)0x54CA0A4A, - (q31_t)0x9F13C7D0, (q31_t)0x539B2AEF, (q31_t)0x9E0EFFC1, - (q31_t)0x5269126E, (q31_t)0x9D0DFE53, (q31_t)0x5133CC94, - (q31_t)0x9C10CD70, (q31_t)0x4FFB654D, (q31_t)0x9B1776D9, - (q31_t)0x4EBFE8A4, (q31_t)0x9A22042C, (q31_t)0x4D8162C4, - (q31_t)0x99307EE0, (q31_t)0x4C3FDFF3, (q31_t)0x9842F043, - (q31_t)0x4AFB6C97, (q31_t)0x9759617E, (q31_t)0x49B41533, - (q31_t)0x9673DB94, (q31_t)0x4869E664, (q31_t)0x9592675B, - (q31_t)0x471CECE6, (q31_t)0x94B50D87, (q31_t)0x45CD358F, - (q31_t)0x93DBD69F, (q31_t)0x447ACD50, (q31_t)0x9306CB04, - (q31_t)0x4325C135, (q31_t)0x9235F2EB, (q31_t)0x41CE1E64, - (q31_t)0x91695663, (q31_t)0x4073F21D, (q31_t)0x90A0FD4E, - (q31_t)0x3F1749B7, (q31_t)0x8FDCEF66, (q31_t)0x3DB832A5, - (q31_t)0x8F1D343A, (q31_t)0x3C56BA70, (q31_t)0x8E61D32D, - (q31_t)0x3AF2EEB7, (q31_t)0x8DAAD37B, (q31_t)0x398CDD32, - (q31_t)0x8CF83C30, (q31_t)0x382493B0, (q31_t)0x8C4A142F, - (q31_t)0x36BA2013, (q31_t)0x8BA0622F, (q31_t)0x354D9056, - (q31_t)0x8AFB2CBA, (q31_t)0x33DEF287, (q31_t)0x8A5A7A30, - (q31_t)0x326E54C7, (q31_t)0x89BE50C3, (q31_t)0x30FBC54D, - (q31_t)0x8926B677, (q31_t)0x2F875262, (q31_t)0x8893B124, - (q31_t)0x2E110A62, (q31_t)0x88054677, (q31_t)0x2C98FBBA, - (q31_t)0x877B7BEC, (q31_t)0x2B1F34EB, (q31_t)0x86F656D3, - (q31_t)0x29A3C484, (q31_t)0x8675DC4E, (q31_t)0x2826B928, - (q31_t)0x85FA1152, (q31_t)0x26A82185, (q31_t)0x8582FAA4, - (q31_t)0x25280C5D, (q31_t)0x85109CDC, (q31_t)0x23A6887E, - (q31_t)0x84A2FC62, (q31_t)0x2223A4C5, (q31_t)0x843A1D70, - (q31_t)0x209F701C, (q31_t)0x83D60411, (q31_t)0x1F19F97B, - (q31_t)0x8376B422, (q31_t)0x1D934FE5, (q31_t)0x831C314E, - (q31_t)0x1C0B826A, (q31_t)0x82C67F13, (q31_t)0x1A82A025, - (q31_t)0x8275A0C0, (q31_t)0x18F8B83C, (q31_t)0x82299971, - (q31_t)0x176DD9DE, (q31_t)0x81E26C16, (q31_t)0x15E21444, - (q31_t)0x81A01B6C, (q31_t)0x145576B1, (q31_t)0x8162AA03, - (q31_t)0x12C8106E, (q31_t)0x812A1A39, (q31_t)0x1139F0CE, - (q31_t)0x80F66E3C, (q31_t)0x0FAB272B, (q31_t)0x80C7A80A, - (q31_t)0x0E1BC2E3, (q31_t)0x809DC970, (q31_t)0x0C8BD35E, - (q31_t)0x8078D40D, (q31_t)0x0AFB6805, (q31_t)0x8058C94C, - (q31_t)0x096A9049, (q31_t)0x803DAA69, (q31_t)0x07D95B9E, - (q31_t)0x80277872, (q31_t)0x0647D97C, (q31_t)0x80163440, - (q31_t)0x04B6195D, (q31_t)0x8009DE7D, (q31_t)0x03242ABF, - (q31_t)0x800277A5, (q31_t)0x01921D1F, (q31_t)0x80000000, - (q31_t)0x00000000, (q31_t)0x800277A5, (q31_t)0xFE6DE2E0, - (q31_t)0x8009DE7D, (q31_t)0xFCDBD541, (q31_t)0x80163440, - (q31_t)0xFB49E6A2, (q31_t)0x80277872, (q31_t)0xF9B82683, - (q31_t)0x803DAA69, (q31_t)0xF826A461, (q31_t)0x8058C94C, - (q31_t)0xF6956FB6, (q31_t)0x8078D40D, (q31_t)0xF50497FA, - (q31_t)0x809DC970, (q31_t)0xF3742CA1, (q31_t)0x80C7A80A, - (q31_t)0xF1E43D1C, (q31_t)0x80F66E3C, (q31_t)0xF054D8D4, - (q31_t)0x812A1A39, (q31_t)0xEEC60F31, (q31_t)0x8162AA03, - (q31_t)0xED37EF91, (q31_t)0x81A01B6C, (q31_t)0xEBAA894E, - (q31_t)0x81E26C16, (q31_t)0xEA1DEBBB, (q31_t)0x82299971, - (q31_t)0xE8922621, (q31_t)0x8275A0C0, (q31_t)0xE70747C3, - (q31_t)0x82C67F13, (q31_t)0xE57D5FDA, (q31_t)0x831C314E, - (q31_t)0xE3F47D95, (q31_t)0x8376B422, (q31_t)0xE26CB01A, - (q31_t)0x83D60411, (q31_t)0xE0E60684, (q31_t)0x843A1D70, - (q31_t)0xDF608FE3, (q31_t)0x84A2FC62, (q31_t)0xDDDC5B3A, - (q31_t)0x85109CDC, (q31_t)0xDC597781, (q31_t)0x8582FAA4, - (q31_t)0xDAD7F3A2, (q31_t)0x85FA1152, (q31_t)0xD957DE7A, - (q31_t)0x8675DC4E, (q31_t)0xD7D946D7, (q31_t)0x86F656D3, - (q31_t)0xD65C3B7B, (q31_t)0x877B7BEC, (q31_t)0xD4E0CB14, - (q31_t)0x88054677, (q31_t)0xD3670445, (q31_t)0x8893B124, - (q31_t)0xD1EEF59E, (q31_t)0x8926B677, (q31_t)0xD078AD9D, - (q31_t)0x89BE50C3, (q31_t)0xCF043AB2, (q31_t)0x8A5A7A30, - (q31_t)0xCD91AB38, (q31_t)0x8AFB2CBA, (q31_t)0xCC210D78, - (q31_t)0x8BA0622F, (q31_t)0xCAB26FA9, (q31_t)0x8C4A142F, - (q31_t)0xC945DFEC, (q31_t)0x8CF83C30, (q31_t)0xC7DB6C50, - (q31_t)0x8DAAD37B, (q31_t)0xC67322CD, (q31_t)0x8E61D32D, - (q31_t)0xC50D1148, (q31_t)0x8F1D343A, (q31_t)0xC3A9458F, - (q31_t)0x8FDCEF66, (q31_t)0xC247CD5A, (q31_t)0x90A0FD4E, - (q31_t)0xC0E8B648, (q31_t)0x91695663, (q31_t)0xBF8C0DE2, - (q31_t)0x9235F2EB, (q31_t)0xBE31E19B, (q31_t)0x9306CB04, - (q31_t)0xBCDA3ECA, (q31_t)0x93DBD69F, (q31_t)0xBB8532AF, - (q31_t)0x94B50D87, (q31_t)0xBA32CA70, (q31_t)0x9592675B, - (q31_t)0xB8E31319, (q31_t)0x9673DB94, (q31_t)0xB796199B, - (q31_t)0x9759617E, (q31_t)0xB64BEACC, (q31_t)0x9842F043, - (q31_t)0xB5049368, (q31_t)0x99307EE0, (q31_t)0xB3C0200C, - (q31_t)0x9A22042C, (q31_t)0xB27E9D3B, (q31_t)0x9B1776D9, - (q31_t)0xB140175B, (q31_t)0x9C10CD70, (q31_t)0xB0049AB2, - (q31_t)0x9D0DFE53, (q31_t)0xAECC336B, (q31_t)0x9E0EFFC1, - (q31_t)0xAD96ED91, (q31_t)0x9F13C7D0, (q31_t)0xAC64D510, - (q31_t)0xA01C4C72, (q31_t)0xAB35F5B5, (q31_t)0xA1288376, - (q31_t)0xAA0A5B2D, (q31_t)0xA2386283, (q31_t)0xA8E21106, - (q31_t)0xA34BDF20, (q31_t)0xA7BD22AB, (q31_t)0xA462EEAC, - (q31_t)0xA69B9B68, (q31_t)0xA57D8666, (q31_t)0xA57D8666, - (q31_t)0xA69B9B68, (q31_t)0xA462EEAC, (q31_t)0xA7BD22AB, - (q31_t)0xA34BDF20, (q31_t)0xA8E21106, (q31_t)0xA2386283, - (q31_t)0xAA0A5B2D, (q31_t)0xA1288376, (q31_t)0xAB35F5B5, - (q31_t)0xA01C4C72, (q31_t)0xAC64D510, (q31_t)0x9F13C7D0, - (q31_t)0xAD96ED91, (q31_t)0x9E0EFFC1, (q31_t)0xAECC336B, - (q31_t)0x9D0DFE53, (q31_t)0xB0049AB2, (q31_t)0x9C10CD70, - (q31_t)0xB140175B, (q31_t)0x9B1776D9, (q31_t)0xB27E9D3B, - (q31_t)0x9A22042C, (q31_t)0xB3C0200C, (q31_t)0x99307EE0, - (q31_t)0xB5049368, (q31_t)0x9842F043, (q31_t)0xB64BEACC, - (q31_t)0x9759617E, (q31_t)0xB796199B, (q31_t)0x9673DB94, - (q31_t)0xB8E31319, (q31_t)0x9592675B, (q31_t)0xBA32CA70, - (q31_t)0x94B50D87, (q31_t)0xBB8532AF, (q31_t)0x93DBD69F, - (q31_t)0xBCDA3ECA, (q31_t)0x9306CB04, (q31_t)0xBE31E19B, - (q31_t)0x9235F2EB, (q31_t)0xBF8C0DE2, (q31_t)0x91695663, - (q31_t)0xC0E8B648, (q31_t)0x90A0FD4E, (q31_t)0xC247CD5A, - (q31_t)0x8FDCEF66, (q31_t)0xC3A9458F, (q31_t)0x8F1D343A, - (q31_t)0xC50D1148, (q31_t)0x8E61D32D, (q31_t)0xC67322CD, - (q31_t)0x8DAAD37B, (q31_t)0xC7DB6C50, (q31_t)0x8CF83C30, - (q31_t)0xC945DFEC, (q31_t)0x8C4A142F, (q31_t)0xCAB26FA9, - (q31_t)0x8BA0622F, (q31_t)0xCC210D78, (q31_t)0x8AFB2CBA, - (q31_t)0xCD91AB38, (q31_t)0x8A5A7A30, (q31_t)0xCF043AB2, - (q31_t)0x89BE50C3, (q31_t)0xD078AD9D, (q31_t)0x8926B677, - (q31_t)0xD1EEF59E, (q31_t)0x8893B124, (q31_t)0xD3670445, - (q31_t)0x88054677, (q31_t)0xD4E0CB14, (q31_t)0x877B7BEC, - (q31_t)0xD65C3B7B, (q31_t)0x86F656D3, (q31_t)0xD7D946D7, - (q31_t)0x8675DC4E, (q31_t)0xD957DE7A, (q31_t)0x85FA1152, - (q31_t)0xDAD7F3A2, (q31_t)0x8582FAA4, (q31_t)0xDC597781, - (q31_t)0x85109CDC, (q31_t)0xDDDC5B3A, (q31_t)0x84A2FC62, - (q31_t)0xDF608FE3, (q31_t)0x843A1D70, (q31_t)0xE0E60684, - (q31_t)0x83D60411, (q31_t)0xE26CB01A, (q31_t)0x8376B422, - (q31_t)0xE3F47D95, (q31_t)0x831C314E, (q31_t)0xE57D5FDA, - (q31_t)0x82C67F13, (q31_t)0xE70747C3, (q31_t)0x8275A0C0, - (q31_t)0xE8922621, (q31_t)0x82299971, (q31_t)0xEA1DEBBB, - (q31_t)0x81E26C16, (q31_t)0xEBAA894E, (q31_t)0x81A01B6C, - (q31_t)0xED37EF91, (q31_t)0x8162AA03, (q31_t)0xEEC60F31, - (q31_t)0x812A1A39, (q31_t)0xF054D8D4, (q31_t)0x80F66E3C, - (q31_t)0xF1E43D1C, (q31_t)0x80C7A80A, (q31_t)0xF3742CA1, - (q31_t)0x809DC970, (q31_t)0xF50497FA, (q31_t)0x8078D40D, - (q31_t)0xF6956FB6, (q31_t)0x8058C94C, (q31_t)0xF826A461, - (q31_t)0x803DAA69, (q31_t)0xF9B82683, (q31_t)0x80277872, - (q31_t)0xFB49E6A2, (q31_t)0x80163440, (q31_t)0xFCDBD541, - (q31_t)0x8009DE7D, (q31_t)0xFE6DE2E0, (q31_t)0x800277A5 -}; + (q31_t)0x7FFFFFFF, (q31_t)0x00000000, (q31_t)0x7FFD885A, (q31_t)0x01921D1F, + (q31_t)0x7FF62182, (q31_t)0x03242ABF, (q31_t)0x7FE9CBC0, (q31_t)0x04B6195D, + (q31_t)0x7FD8878D, (q31_t)0x0647D97C, (q31_t)0x7FC25596, (q31_t)0x07D95B9E, + (q31_t)0x7FA736B4, (q31_t)0x096A9049, (q31_t)0x7F872BF3, (q31_t)0x0AFB6805, + (q31_t)0x7F62368F, (q31_t)0x0C8BD35E, (q31_t)0x7F3857F5, (q31_t)0x0E1BC2E3, + (q31_t)0x7F0991C3, (q31_t)0x0FAB272B, (q31_t)0x7ED5E5C6, (q31_t)0x1139F0CE, + (q31_t)0x7E9D55FC, (q31_t)0x12C8106E, (q31_t)0x7E5FE493, (q31_t)0x145576B1, + (q31_t)0x7E1D93E9, (q31_t)0x15E21444, (q31_t)0x7DD6668E, (q31_t)0x176DD9DE, + (q31_t)0x7D8A5F3F, (q31_t)0x18F8B83C, (q31_t)0x7D3980EC, (q31_t)0x1A82A025, + (q31_t)0x7CE3CEB1, (q31_t)0x1C0B826A, (q31_t)0x7C894BDD, (q31_t)0x1D934FE5, + (q31_t)0x7C29FBEE, (q31_t)0x1F19F97B, (q31_t)0x7BC5E28F, (q31_t)0x209F701C, + (q31_t)0x7B5D039D, (q31_t)0x2223A4C5, (q31_t)0x7AEF6323, (q31_t)0x23A6887E, + (q31_t)0x7A7D055B, (q31_t)0x25280C5D, (q31_t)0x7A05EEAD, (q31_t)0x26A82185, + (q31_t)0x798A23B1, (q31_t)0x2826B928, (q31_t)0x7909A92C, (q31_t)0x29A3C484, + (q31_t)0x78848413, (q31_t)0x2B1F34EB, (q31_t)0x77FAB988, (q31_t)0x2C98FBBA, + (q31_t)0x776C4EDB, (q31_t)0x2E110A62, (q31_t)0x76D94988, (q31_t)0x2F875262, + (q31_t)0x7641AF3C, (q31_t)0x30FBC54D, (q31_t)0x75A585CF, (q31_t)0x326E54C7, + (q31_t)0x7504D345, (q31_t)0x33DEF287, (q31_t)0x745F9DD1, (q31_t)0x354D9056, + (q31_t)0x73B5EBD0, (q31_t)0x36BA2013, (q31_t)0x7307C3D0, (q31_t)0x382493B0, + (q31_t)0x72552C84, (q31_t)0x398CDD32, (q31_t)0x719E2CD2, (q31_t)0x3AF2EEB7, + (q31_t)0x70E2CBC6, (q31_t)0x3C56BA70, (q31_t)0x70231099, (q31_t)0x3DB832A5, + (q31_t)0x6F5F02B1, (q31_t)0x3F1749B7, (q31_t)0x6E96A99C, (q31_t)0x4073F21D, + (q31_t)0x6DCA0D14, (q31_t)0x41CE1E64, (q31_t)0x6CF934FB, (q31_t)0x4325C135, + (q31_t)0x6C242960, (q31_t)0x447ACD50, (q31_t)0x6B4AF278, (q31_t)0x45CD358F, + (q31_t)0x6A6D98A4, (q31_t)0x471CECE6, (q31_t)0x698C246C, (q31_t)0x4869E664, + (q31_t)0x68A69E81, (q31_t)0x49B41533, (q31_t)0x67BD0FBC, (q31_t)0x4AFB6C97, + (q31_t)0x66CF811F, (q31_t)0x4C3FDFF3, (q31_t)0x65DDFBD3, (q31_t)0x4D8162C4, + (q31_t)0x64E88926, (q31_t)0x4EBFE8A4, (q31_t)0x63EF328F, (q31_t)0x4FFB654D, + (q31_t)0x62F201AC, (q31_t)0x5133CC94, (q31_t)0x61F1003E, (q31_t)0x5269126E, + (q31_t)0x60EC3830, (q31_t)0x539B2AEF, (q31_t)0x5FE3B38D, (q31_t)0x54CA0A4A, + (q31_t)0x5ED77C89, (q31_t)0x55F5A4D2, (q31_t)0x5DC79D7C, (q31_t)0x571DEEF9, + (q31_t)0x5CB420DF, (q31_t)0x5842DD54, (q31_t)0x5B9D1153, (q31_t)0x59646497, + (q31_t)0x5A82799A, (q31_t)0x5A82799A, (q31_t)0x59646497, (q31_t)0x5B9D1153, + (q31_t)0x5842DD54, (q31_t)0x5CB420DF, (q31_t)0x571DEEF9, (q31_t)0x5DC79D7C, + (q31_t)0x55F5A4D2, (q31_t)0x5ED77C89, (q31_t)0x54CA0A4A, (q31_t)0x5FE3B38D, + (q31_t)0x539B2AEF, (q31_t)0x60EC3830, (q31_t)0x5269126E, (q31_t)0x61F1003E, + (q31_t)0x5133CC94, (q31_t)0x62F201AC, (q31_t)0x4FFB654D, (q31_t)0x63EF328F, + (q31_t)0x4EBFE8A4, (q31_t)0x64E88926, (q31_t)0x4D8162C4, (q31_t)0x65DDFBD3, + (q31_t)0x4C3FDFF3, (q31_t)0x66CF811F, (q31_t)0x4AFB6C97, (q31_t)0x67BD0FBC, + (q31_t)0x49B41533, (q31_t)0x68A69E81, (q31_t)0x4869E664, (q31_t)0x698C246C, + (q31_t)0x471CECE6, (q31_t)0x6A6D98A4, (q31_t)0x45CD358F, (q31_t)0x6B4AF278, + (q31_t)0x447ACD50, (q31_t)0x6C242960, (q31_t)0x4325C135, (q31_t)0x6CF934FB, + (q31_t)0x41CE1E64, (q31_t)0x6DCA0D14, (q31_t)0x4073F21D, (q31_t)0x6E96A99C, + (q31_t)0x3F1749B7, (q31_t)0x6F5F02B1, (q31_t)0x3DB832A5, (q31_t)0x70231099, + (q31_t)0x3C56BA70, (q31_t)0x70E2CBC6, (q31_t)0x3AF2EEB7, (q31_t)0x719E2CD2, + (q31_t)0x398CDD32, (q31_t)0x72552C84, (q31_t)0x382493B0, (q31_t)0x7307C3D0, + (q31_t)0x36BA2013, (q31_t)0x73B5EBD0, (q31_t)0x354D9056, (q31_t)0x745F9DD1, + (q31_t)0x33DEF287, (q31_t)0x7504D345, (q31_t)0x326E54C7, (q31_t)0x75A585CF, + (q31_t)0x30FBC54D, (q31_t)0x7641AF3C, (q31_t)0x2F875262, (q31_t)0x76D94988, + (q31_t)0x2E110A62, (q31_t)0x776C4EDB, (q31_t)0x2C98FBBA, (q31_t)0x77FAB988, + (q31_t)0x2B1F34EB, (q31_t)0x78848413, (q31_t)0x29A3C484, (q31_t)0x7909A92C, + (q31_t)0x2826B928, (q31_t)0x798A23B1, (q31_t)0x26A82185, (q31_t)0x7A05EEAD, + (q31_t)0x25280C5D, (q31_t)0x7A7D055B, (q31_t)0x23A6887E, (q31_t)0x7AEF6323, + (q31_t)0x2223A4C5, (q31_t)0x7B5D039D, (q31_t)0x209F701C, (q31_t)0x7BC5E28F, + (q31_t)0x1F19F97B, (q31_t)0x7C29FBEE, (q31_t)0x1D934FE5, (q31_t)0x7C894BDD, + (q31_t)0x1C0B826A, (q31_t)0x7CE3CEB1, (q31_t)0x1A82A025, (q31_t)0x7D3980EC, + (q31_t)0x18F8B83C, (q31_t)0x7D8A5F3F, (q31_t)0x176DD9DE, (q31_t)0x7DD6668E, + (q31_t)0x15E21444, (q31_t)0x7E1D93E9, (q31_t)0x145576B1, (q31_t)0x7E5FE493, + (q31_t)0x12C8106E, (q31_t)0x7E9D55FC, (q31_t)0x1139F0CE, (q31_t)0x7ED5E5C6, + (q31_t)0x0FAB272B, (q31_t)0x7F0991C3, (q31_t)0x0E1BC2E3, (q31_t)0x7F3857F5, + (q31_t)0x0C8BD35E, (q31_t)0x7F62368F, (q31_t)0x0AFB6805, (q31_t)0x7F872BF3, + (q31_t)0x096A9049, (q31_t)0x7FA736B4, (q31_t)0x07D95B9E, (q31_t)0x7FC25596, + (q31_t)0x0647D97C, (q31_t)0x7FD8878D, (q31_t)0x04B6195D, (q31_t)0x7FE9CBC0, + (q31_t)0x03242ABF, (q31_t)0x7FF62182, (q31_t)0x01921D1F, (q31_t)0x7FFD885A, + (q31_t)0x00000000, (q31_t)0x7FFFFFFF, (q31_t)0xFE6DE2E0, (q31_t)0x7FFD885A, + (q31_t)0xFCDBD541, (q31_t)0x7FF62182, (q31_t)0xFB49E6A2, (q31_t)0x7FE9CBC0, + (q31_t)0xF9B82683, (q31_t)0x7FD8878D, (q31_t)0xF826A461, (q31_t)0x7FC25596, + (q31_t)0xF6956FB6, (q31_t)0x7FA736B4, (q31_t)0xF50497FA, (q31_t)0x7F872BF3, + (q31_t)0xF3742CA1, (q31_t)0x7F62368F, (q31_t)0xF1E43D1C, (q31_t)0x7F3857F5, + (q31_t)0xF054D8D4, (q31_t)0x7F0991C3, (q31_t)0xEEC60F31, (q31_t)0x7ED5E5C6, + (q31_t)0xED37EF91, (q31_t)0x7E9D55FC, (q31_t)0xEBAA894E, (q31_t)0x7E5FE493, + (q31_t)0xEA1DEBBB, (q31_t)0x7E1D93E9, (q31_t)0xE8922621, (q31_t)0x7DD6668E, + (q31_t)0xE70747C3, (q31_t)0x7D8A5F3F, (q31_t)0xE57D5FDA, (q31_t)0x7D3980EC, + (q31_t)0xE3F47D95, (q31_t)0x7CE3CEB1, (q31_t)0xE26CB01A, (q31_t)0x7C894BDD, + (q31_t)0xE0E60684, (q31_t)0x7C29FBEE, (q31_t)0xDF608FE3, (q31_t)0x7BC5E28F, + (q31_t)0xDDDC5B3A, (q31_t)0x7B5D039D, (q31_t)0xDC597781, (q31_t)0x7AEF6323, + (q31_t)0xDAD7F3A2, (q31_t)0x7A7D055B, (q31_t)0xD957DE7A, (q31_t)0x7A05EEAD, + (q31_t)0xD7D946D7, (q31_t)0x798A23B1, (q31_t)0xD65C3B7B, (q31_t)0x7909A92C, + (q31_t)0xD4E0CB14, (q31_t)0x78848413, (q31_t)0xD3670445, (q31_t)0x77FAB988, + (q31_t)0xD1EEF59E, (q31_t)0x776C4EDB, (q31_t)0xD078AD9D, (q31_t)0x76D94988, + (q31_t)0xCF043AB2, (q31_t)0x7641AF3C, (q31_t)0xCD91AB38, (q31_t)0x75A585CF, + (q31_t)0xCC210D78, (q31_t)0x7504D345, (q31_t)0xCAB26FA9, (q31_t)0x745F9DD1, + (q31_t)0xC945DFEC, (q31_t)0x73B5EBD0, (q31_t)0xC7DB6C50, (q31_t)0x7307C3D0, + (q31_t)0xC67322CD, (q31_t)0x72552C84, (q31_t)0xC50D1148, (q31_t)0x719E2CD2, + (q31_t)0xC3A9458F, (q31_t)0x70E2CBC6, (q31_t)0xC247CD5A, (q31_t)0x70231099, + (q31_t)0xC0E8B648, (q31_t)0x6F5F02B1, (q31_t)0xBF8C0DE2, (q31_t)0x6E96A99C, + (q31_t)0xBE31E19B, (q31_t)0x6DCA0D14, (q31_t)0xBCDA3ECA, (q31_t)0x6CF934FB, + (q31_t)0xBB8532AF, (q31_t)0x6C242960, (q31_t)0xBA32CA70, (q31_t)0x6B4AF278, + (q31_t)0xB8E31319, (q31_t)0x6A6D98A4, (q31_t)0xB796199B, (q31_t)0x698C246C, + (q31_t)0xB64BEACC, (q31_t)0x68A69E81, (q31_t)0xB5049368, (q31_t)0x67BD0FBC, + (q31_t)0xB3C0200C, (q31_t)0x66CF811F, (q31_t)0xB27E9D3B, (q31_t)0x65DDFBD3, + (q31_t)0xB140175B, (q31_t)0x64E88926, (q31_t)0xB0049AB2, (q31_t)0x63EF328F, + (q31_t)0xAECC336B, (q31_t)0x62F201AC, (q31_t)0xAD96ED91, (q31_t)0x61F1003E, + (q31_t)0xAC64D510, (q31_t)0x60EC3830, (q31_t)0xAB35F5B5, (q31_t)0x5FE3B38D, + (q31_t)0xAA0A5B2D, (q31_t)0x5ED77C89, (q31_t)0xA8E21106, (q31_t)0x5DC79D7C, + (q31_t)0xA7BD22AB, (q31_t)0x5CB420DF, (q31_t)0xA69B9B68, (q31_t)0x5B9D1153, + (q31_t)0xA57D8666, (q31_t)0x5A82799A, (q31_t)0xA462EEAC, (q31_t)0x59646497, + (q31_t)0xA34BDF20, (q31_t)0x5842DD54, (q31_t)0xA2386283, (q31_t)0x571DEEF9, + (q31_t)0xA1288376, (q31_t)0x55F5A4D2, (q31_t)0xA01C4C72, (q31_t)0x54CA0A4A, + (q31_t)0x9F13C7D0, (q31_t)0x539B2AEF, (q31_t)0x9E0EFFC1, (q31_t)0x5269126E, + (q31_t)0x9D0DFE53, (q31_t)0x5133CC94, (q31_t)0x9C10CD70, (q31_t)0x4FFB654D, + (q31_t)0x9B1776D9, (q31_t)0x4EBFE8A4, (q31_t)0x9A22042C, (q31_t)0x4D8162C4, + (q31_t)0x99307EE0, (q31_t)0x4C3FDFF3, (q31_t)0x9842F043, (q31_t)0x4AFB6C97, + (q31_t)0x9759617E, (q31_t)0x49B41533, (q31_t)0x9673DB94, (q31_t)0x4869E664, + (q31_t)0x9592675B, (q31_t)0x471CECE6, (q31_t)0x94B50D87, (q31_t)0x45CD358F, + (q31_t)0x93DBD69F, (q31_t)0x447ACD50, (q31_t)0x9306CB04, (q31_t)0x4325C135, + (q31_t)0x9235F2EB, (q31_t)0x41CE1E64, (q31_t)0x91695663, (q31_t)0x4073F21D, + (q31_t)0x90A0FD4E, (q31_t)0x3F1749B7, (q31_t)0x8FDCEF66, (q31_t)0x3DB832A5, + (q31_t)0x8F1D343A, (q31_t)0x3C56BA70, (q31_t)0x8E61D32D, (q31_t)0x3AF2EEB7, + (q31_t)0x8DAAD37B, (q31_t)0x398CDD32, (q31_t)0x8CF83C30, (q31_t)0x382493B0, + (q31_t)0x8C4A142F, (q31_t)0x36BA2013, (q31_t)0x8BA0622F, (q31_t)0x354D9056, + (q31_t)0x8AFB2CBA, (q31_t)0x33DEF287, (q31_t)0x8A5A7A30, (q31_t)0x326E54C7, + (q31_t)0x89BE50C3, (q31_t)0x30FBC54D, (q31_t)0x8926B677, (q31_t)0x2F875262, + (q31_t)0x8893B124, (q31_t)0x2E110A62, (q31_t)0x88054677, (q31_t)0x2C98FBBA, + (q31_t)0x877B7BEC, (q31_t)0x2B1F34EB, (q31_t)0x86F656D3, (q31_t)0x29A3C484, + (q31_t)0x8675DC4E, (q31_t)0x2826B928, (q31_t)0x85FA1152, (q31_t)0x26A82185, + (q31_t)0x8582FAA4, (q31_t)0x25280C5D, (q31_t)0x85109CDC, (q31_t)0x23A6887E, + (q31_t)0x84A2FC62, (q31_t)0x2223A4C5, (q31_t)0x843A1D70, (q31_t)0x209F701C, + (q31_t)0x83D60411, (q31_t)0x1F19F97B, (q31_t)0x8376B422, (q31_t)0x1D934FE5, + (q31_t)0x831C314E, (q31_t)0x1C0B826A, (q31_t)0x82C67F13, (q31_t)0x1A82A025, + (q31_t)0x8275A0C0, (q31_t)0x18F8B83C, (q31_t)0x82299971, (q31_t)0x176DD9DE, + (q31_t)0x81E26C16, (q31_t)0x15E21444, (q31_t)0x81A01B6C, (q31_t)0x145576B1, + (q31_t)0x8162AA03, (q31_t)0x12C8106E, (q31_t)0x812A1A39, (q31_t)0x1139F0CE, + (q31_t)0x80F66E3C, (q31_t)0x0FAB272B, (q31_t)0x80C7A80A, (q31_t)0x0E1BC2E3, + (q31_t)0x809DC970, (q31_t)0x0C8BD35E, (q31_t)0x8078D40D, (q31_t)0x0AFB6805, + (q31_t)0x8058C94C, (q31_t)0x096A9049, (q31_t)0x803DAA69, (q31_t)0x07D95B9E, + (q31_t)0x80277872, (q31_t)0x0647D97C, (q31_t)0x80163440, (q31_t)0x04B6195D, + (q31_t)0x8009DE7D, (q31_t)0x03242ABF, (q31_t)0x800277A5, (q31_t)0x01921D1F, + (q31_t)0x80000000, (q31_t)0x00000000, (q31_t)0x800277A5, (q31_t)0xFE6DE2E0, + (q31_t)0x8009DE7D, (q31_t)0xFCDBD541, (q31_t)0x80163440, (q31_t)0xFB49E6A2, + (q31_t)0x80277872, (q31_t)0xF9B82683, (q31_t)0x803DAA69, (q31_t)0xF826A461, + (q31_t)0x8058C94C, (q31_t)0xF6956FB6, (q31_t)0x8078D40D, (q31_t)0xF50497FA, + (q31_t)0x809DC970, (q31_t)0xF3742CA1, (q31_t)0x80C7A80A, (q31_t)0xF1E43D1C, + (q31_t)0x80F66E3C, (q31_t)0xF054D8D4, (q31_t)0x812A1A39, (q31_t)0xEEC60F31, + (q31_t)0x8162AA03, (q31_t)0xED37EF91, (q31_t)0x81A01B6C, (q31_t)0xEBAA894E, + (q31_t)0x81E26C16, (q31_t)0xEA1DEBBB, (q31_t)0x82299971, (q31_t)0xE8922621, + (q31_t)0x8275A0C0, (q31_t)0xE70747C3, (q31_t)0x82C67F13, (q31_t)0xE57D5FDA, + (q31_t)0x831C314E, (q31_t)0xE3F47D95, (q31_t)0x8376B422, (q31_t)0xE26CB01A, + (q31_t)0x83D60411, (q31_t)0xE0E60684, (q31_t)0x843A1D70, (q31_t)0xDF608FE3, + (q31_t)0x84A2FC62, (q31_t)0xDDDC5B3A, (q31_t)0x85109CDC, (q31_t)0xDC597781, + (q31_t)0x8582FAA4, (q31_t)0xDAD7F3A2, (q31_t)0x85FA1152, (q31_t)0xD957DE7A, + (q31_t)0x8675DC4E, (q31_t)0xD7D946D7, (q31_t)0x86F656D3, (q31_t)0xD65C3B7B, + (q31_t)0x877B7BEC, (q31_t)0xD4E0CB14, (q31_t)0x88054677, (q31_t)0xD3670445, + (q31_t)0x8893B124, (q31_t)0xD1EEF59E, (q31_t)0x8926B677, (q31_t)0xD078AD9D, + (q31_t)0x89BE50C3, (q31_t)0xCF043AB2, (q31_t)0x8A5A7A30, (q31_t)0xCD91AB38, + (q31_t)0x8AFB2CBA, (q31_t)0xCC210D78, (q31_t)0x8BA0622F, (q31_t)0xCAB26FA9, + (q31_t)0x8C4A142F, (q31_t)0xC945DFEC, (q31_t)0x8CF83C30, (q31_t)0xC7DB6C50, + (q31_t)0x8DAAD37B, (q31_t)0xC67322CD, (q31_t)0x8E61D32D, (q31_t)0xC50D1148, + (q31_t)0x8F1D343A, (q31_t)0xC3A9458F, (q31_t)0x8FDCEF66, (q31_t)0xC247CD5A, + (q31_t)0x90A0FD4E, (q31_t)0xC0E8B648, (q31_t)0x91695663, (q31_t)0xBF8C0DE2, + (q31_t)0x9235F2EB, (q31_t)0xBE31E19B, (q31_t)0x9306CB04, (q31_t)0xBCDA3ECA, + (q31_t)0x93DBD69F, (q31_t)0xBB8532AF, (q31_t)0x94B50D87, (q31_t)0xBA32CA70, + (q31_t)0x9592675B, (q31_t)0xB8E31319, (q31_t)0x9673DB94, (q31_t)0xB796199B, + (q31_t)0x9759617E, (q31_t)0xB64BEACC, (q31_t)0x9842F043, (q31_t)0xB5049368, + (q31_t)0x99307EE0, (q31_t)0xB3C0200C, (q31_t)0x9A22042C, (q31_t)0xB27E9D3B, + (q31_t)0x9B1776D9, (q31_t)0xB140175B, (q31_t)0x9C10CD70, (q31_t)0xB0049AB2, + (q31_t)0x9D0DFE53, (q31_t)0xAECC336B, (q31_t)0x9E0EFFC1, (q31_t)0xAD96ED91, + (q31_t)0x9F13C7D0, (q31_t)0xAC64D510, (q31_t)0xA01C4C72, (q31_t)0xAB35F5B5, + (q31_t)0xA1288376, (q31_t)0xAA0A5B2D, (q31_t)0xA2386283, (q31_t)0xA8E21106, + (q31_t)0xA34BDF20, (q31_t)0xA7BD22AB, (q31_t)0xA462EEAC, (q31_t)0xA69B9B68, + (q31_t)0xA57D8666, (q31_t)0xA57D8666, (q31_t)0xA69B9B68, (q31_t)0xA462EEAC, + (q31_t)0xA7BD22AB, (q31_t)0xA34BDF20, (q31_t)0xA8E21106, (q31_t)0xA2386283, + (q31_t)0xAA0A5B2D, (q31_t)0xA1288376, (q31_t)0xAB35F5B5, (q31_t)0xA01C4C72, + (q31_t)0xAC64D510, (q31_t)0x9F13C7D0, (q31_t)0xAD96ED91, (q31_t)0x9E0EFFC1, + (q31_t)0xAECC336B, (q31_t)0x9D0DFE53, (q31_t)0xB0049AB2, (q31_t)0x9C10CD70, + (q31_t)0xB140175B, (q31_t)0x9B1776D9, (q31_t)0xB27E9D3B, (q31_t)0x9A22042C, + (q31_t)0xB3C0200C, (q31_t)0x99307EE0, (q31_t)0xB5049368, (q31_t)0x9842F043, + (q31_t)0xB64BEACC, (q31_t)0x9759617E, (q31_t)0xB796199B, (q31_t)0x9673DB94, + (q31_t)0xB8E31319, (q31_t)0x9592675B, (q31_t)0xBA32CA70, (q31_t)0x94B50D87, + (q31_t)0xBB8532AF, (q31_t)0x93DBD69F, (q31_t)0xBCDA3ECA, (q31_t)0x9306CB04, + (q31_t)0xBE31E19B, (q31_t)0x9235F2EB, (q31_t)0xBF8C0DE2, (q31_t)0x91695663, + (q31_t)0xC0E8B648, (q31_t)0x90A0FD4E, (q31_t)0xC247CD5A, (q31_t)0x8FDCEF66, + (q31_t)0xC3A9458F, (q31_t)0x8F1D343A, (q31_t)0xC50D1148, (q31_t)0x8E61D32D, + (q31_t)0xC67322CD, (q31_t)0x8DAAD37B, (q31_t)0xC7DB6C50, (q31_t)0x8CF83C30, + (q31_t)0xC945DFEC, (q31_t)0x8C4A142F, (q31_t)0xCAB26FA9, (q31_t)0x8BA0622F, + (q31_t)0xCC210D78, (q31_t)0x8AFB2CBA, (q31_t)0xCD91AB38, (q31_t)0x8A5A7A30, + (q31_t)0xCF043AB2, (q31_t)0x89BE50C3, (q31_t)0xD078AD9D, (q31_t)0x8926B677, + (q31_t)0xD1EEF59E, (q31_t)0x8893B124, (q31_t)0xD3670445, (q31_t)0x88054677, + (q31_t)0xD4E0CB14, (q31_t)0x877B7BEC, (q31_t)0xD65C3B7B, (q31_t)0x86F656D3, + (q31_t)0xD7D946D7, (q31_t)0x8675DC4E, (q31_t)0xD957DE7A, (q31_t)0x85FA1152, + (q31_t)0xDAD7F3A2, (q31_t)0x8582FAA4, (q31_t)0xDC597781, (q31_t)0x85109CDC, + (q31_t)0xDDDC5B3A, (q31_t)0x84A2FC62, (q31_t)0xDF608FE3, (q31_t)0x843A1D70, + (q31_t)0xE0E60684, (q31_t)0x83D60411, (q31_t)0xE26CB01A, (q31_t)0x8376B422, + (q31_t)0xE3F47D95, (q31_t)0x831C314E, (q31_t)0xE57D5FDA, (q31_t)0x82C67F13, + (q31_t)0xE70747C3, (q31_t)0x8275A0C0, (q31_t)0xE8922621, (q31_t)0x82299971, + (q31_t)0xEA1DEBBB, (q31_t)0x81E26C16, (q31_t)0xEBAA894E, (q31_t)0x81A01B6C, + (q31_t)0xED37EF91, (q31_t)0x8162AA03, (q31_t)0xEEC60F31, (q31_t)0x812A1A39, + (q31_t)0xF054D8D4, (q31_t)0x80F66E3C, (q31_t)0xF1E43D1C, (q31_t)0x80C7A80A, + (q31_t)0xF3742CA1, (q31_t)0x809DC970, (q31_t)0xF50497FA, (q31_t)0x8078D40D, + (q31_t)0xF6956FB6, (q31_t)0x8058C94C, (q31_t)0xF826A461, (q31_t)0x803DAA69, + (q31_t)0xF9B82683, (q31_t)0x80277872, (q31_t)0xFB49E6A2, (q31_t)0x80163440, + (q31_t)0xFCDBD541, (q31_t)0x8009DE7D, (q31_t)0xFE6DE2E0, (q31_t)0x800277A5}; /** @par @@ -9161,523 +4096,394 @@ const q31_t twiddleCoef_512_q31[768] = { Cos and Sin values are interleaved fashion @par Convert Floating point to Q31(Fixed point 1.31): - round(twiddleCoefQ31(i) * pow(2, 31)) - + round(twiddleCoefQ31(i) * pow(2, 31)) + */ const q31_t twiddleCoef_1024_q31[1536] = { - (q31_t)0x7FFFFFFF, (q31_t)0x00000000, (q31_t)0x7FFF6216, - (q31_t)0x00C90F88, (q31_t)0x7FFD885A, (q31_t)0x01921D1F, - (q31_t)0x7FFA72D1, (q31_t)0x025B26D7, (q31_t)0x7FF62182, - (q31_t)0x03242ABF, (q31_t)0x7FF09477, (q31_t)0x03ED26E6, - (q31_t)0x7FE9CBC0, (q31_t)0x04B6195D, (q31_t)0x7FE1C76B, - (q31_t)0x057F0034, (q31_t)0x7FD8878D, (q31_t)0x0647D97C, - (q31_t)0x7FCE0C3E, (q31_t)0x0710A344, (q31_t)0x7FC25596, - (q31_t)0x07D95B9E, (q31_t)0x7FB563B2, (q31_t)0x08A2009A, - (q31_t)0x7FA736B4, (q31_t)0x096A9049, (q31_t)0x7F97CEBC, - (q31_t)0x0A3308BC, (q31_t)0x7F872BF3, (q31_t)0x0AFB6805, - (q31_t)0x7F754E7F, (q31_t)0x0BC3AC35, (q31_t)0x7F62368F, - (q31_t)0x0C8BD35E, (q31_t)0x7F4DE450, (q31_t)0x0D53DB92, - (q31_t)0x7F3857F5, (q31_t)0x0E1BC2E3, (q31_t)0x7F2191B4, - (q31_t)0x0EE38765, (q31_t)0x7F0991C3, (q31_t)0x0FAB272B, - (q31_t)0x7EF0585F, (q31_t)0x1072A047, (q31_t)0x7ED5E5C6, - (q31_t)0x1139F0CE, (q31_t)0x7EBA3A39, (q31_t)0x120116D4, - (q31_t)0x7E9D55FC, (q31_t)0x12C8106E, (q31_t)0x7E7F3956, - (q31_t)0x138EDBB0, (q31_t)0x7E5FE493, (q31_t)0x145576B1, - (q31_t)0x7E3F57FE, (q31_t)0x151BDF85, (q31_t)0x7E1D93E9, - (q31_t)0x15E21444, (q31_t)0x7DFA98A7, (q31_t)0x16A81305, - (q31_t)0x7DD6668E, (q31_t)0x176DD9DE, (q31_t)0x7DB0FDF7, - (q31_t)0x183366E8, (q31_t)0x7D8A5F3F, (q31_t)0x18F8B83C, - (q31_t)0x7D628AC5, (q31_t)0x19BDCBF2, (q31_t)0x7D3980EC, - (q31_t)0x1A82A025, (q31_t)0x7D0F4218, (q31_t)0x1B4732EF, - (q31_t)0x7CE3CEB1, (q31_t)0x1C0B826A, (q31_t)0x7CB72724, - (q31_t)0x1CCF8CB3, (q31_t)0x7C894BDD, (q31_t)0x1D934FE5, - (q31_t)0x7C5A3D4F, (q31_t)0x1E56CA1E, (q31_t)0x7C29FBEE, - (q31_t)0x1F19F97B, (q31_t)0x7BF88830, (q31_t)0x1FDCDC1A, - (q31_t)0x7BC5E28F, (q31_t)0x209F701C, (q31_t)0x7B920B89, - (q31_t)0x2161B39F, (q31_t)0x7B5D039D, (q31_t)0x2223A4C5, - (q31_t)0x7B26CB4F, (q31_t)0x22E541AE, (q31_t)0x7AEF6323, - (q31_t)0x23A6887E, (q31_t)0x7AB6CBA3, (q31_t)0x24677757, - (q31_t)0x7A7D055B, (q31_t)0x25280C5D, (q31_t)0x7A4210D8, - (q31_t)0x25E845B5, (q31_t)0x7A05EEAD, (q31_t)0x26A82185, - (q31_t)0x79C89F6D, (q31_t)0x27679DF4, (q31_t)0x798A23B1, - (q31_t)0x2826B928, (q31_t)0x794A7C11, (q31_t)0x28E5714A, - (q31_t)0x7909A92C, (q31_t)0x29A3C484, (q31_t)0x78C7ABA1, - (q31_t)0x2A61B101, (q31_t)0x78848413, (q31_t)0x2B1F34EB, - (q31_t)0x78403328, (q31_t)0x2BDC4E6F, (q31_t)0x77FAB988, - (q31_t)0x2C98FBBA, (q31_t)0x77B417DF, (q31_t)0x2D553AFB, - (q31_t)0x776C4EDB, (q31_t)0x2E110A62, (q31_t)0x77235F2D, - (q31_t)0x2ECC681E, (q31_t)0x76D94988, (q31_t)0x2F875262, - (q31_t)0x768E0EA5, (q31_t)0x3041C760, (q31_t)0x7641AF3C, - (q31_t)0x30FBC54D, (q31_t)0x75F42C0A, (q31_t)0x31B54A5D, - (q31_t)0x75A585CF, (q31_t)0x326E54C7, (q31_t)0x7555BD4B, - (q31_t)0x3326E2C2, (q31_t)0x7504D345, (q31_t)0x33DEF287, - (q31_t)0x74B2C883, (q31_t)0x3496824F, (q31_t)0x745F9DD1, - (q31_t)0x354D9056, (q31_t)0x740B53FA, (q31_t)0x36041AD9, - (q31_t)0x73B5EBD0, (q31_t)0x36BA2013, (q31_t)0x735F6626, - (q31_t)0x376F9E46, (q31_t)0x7307C3D0, (q31_t)0x382493B0, - (q31_t)0x72AF05A6, (q31_t)0x38D8FE93, (q31_t)0x72552C84, - (q31_t)0x398CDD32, (q31_t)0x71FA3948, (q31_t)0x3A402DD1, - (q31_t)0x719E2CD2, (q31_t)0x3AF2EEB7, (q31_t)0x71410804, - (q31_t)0x3BA51E29, (q31_t)0x70E2CBC6, (q31_t)0x3C56BA70, - (q31_t)0x708378FE, (q31_t)0x3D07C1D5, (q31_t)0x70231099, - (q31_t)0x3DB832A5, (q31_t)0x6FC19385, (q31_t)0x3E680B2C, - (q31_t)0x6F5F02B1, (q31_t)0x3F1749B7, (q31_t)0x6EFB5F12, - (q31_t)0x3FC5EC97, (q31_t)0x6E96A99C, (q31_t)0x4073F21D, - (q31_t)0x6E30E349, (q31_t)0x4121589A, (q31_t)0x6DCA0D14, - (q31_t)0x41CE1E64, (q31_t)0x6D6227FA, (q31_t)0x427A41D0, - (q31_t)0x6CF934FB, (q31_t)0x4325C135, (q31_t)0x6C8F351C, - (q31_t)0x43D09AEC, (q31_t)0x6C242960, (q31_t)0x447ACD50, - (q31_t)0x6BB812D0, (q31_t)0x452456BC, (q31_t)0x6B4AF278, - (q31_t)0x45CD358F, (q31_t)0x6ADCC964, (q31_t)0x46756827, - (q31_t)0x6A6D98A4, (q31_t)0x471CECE6, (q31_t)0x69FD614A, - (q31_t)0x47C3C22E, (q31_t)0x698C246C, (q31_t)0x4869E664, - (q31_t)0x6919E320, (q31_t)0x490F57EE, (q31_t)0x68A69E81, - (q31_t)0x49B41533, (q31_t)0x683257AA, (q31_t)0x4A581C9D, - (q31_t)0x67BD0FBC, (q31_t)0x4AFB6C97, (q31_t)0x6746C7D7, - (q31_t)0x4B9E038F, (q31_t)0x66CF811F, (q31_t)0x4C3FDFF3, - (q31_t)0x66573CBB, (q31_t)0x4CE10034, (q31_t)0x65DDFBD3, - (q31_t)0x4D8162C4, (q31_t)0x6563BF92, (q31_t)0x4E210617, - (q31_t)0x64E88926, (q31_t)0x4EBFE8A4, (q31_t)0x646C59BF, - (q31_t)0x4F5E08E3, (q31_t)0x63EF328F, (q31_t)0x4FFB654D, - (q31_t)0x637114CC, (q31_t)0x5097FC5E, (q31_t)0x62F201AC, - (q31_t)0x5133CC94, (q31_t)0x6271FA69, (q31_t)0x51CED46E, - (q31_t)0x61F1003E, (q31_t)0x5269126E, (q31_t)0x616F146B, - (q31_t)0x53028517, (q31_t)0x60EC3830, (q31_t)0x539B2AEF, - (q31_t)0x60686CCE, (q31_t)0x5433027D, (q31_t)0x5FE3B38D, - (q31_t)0x54CA0A4A, (q31_t)0x5F5E0DB3, (q31_t)0x556040E2, - (q31_t)0x5ED77C89, (q31_t)0x55F5A4D2, (q31_t)0x5E50015D, - (q31_t)0x568A34A9, (q31_t)0x5DC79D7C, (q31_t)0x571DEEF9, - (q31_t)0x5D3E5236, (q31_t)0x57B0D256, (q31_t)0x5CB420DF, - (q31_t)0x5842DD54, (q31_t)0x5C290ACC, (q31_t)0x58D40E8C, - (q31_t)0x5B9D1153, (q31_t)0x59646497, (q31_t)0x5B1035CF, - (q31_t)0x59F3DE12, (q31_t)0x5A82799A, (q31_t)0x5A82799A, - (q31_t)0x59F3DE12, (q31_t)0x5B1035CF, (q31_t)0x59646497, - (q31_t)0x5B9D1153, (q31_t)0x58D40E8C, (q31_t)0x5C290ACC, - (q31_t)0x5842DD54, (q31_t)0x5CB420DF, (q31_t)0x57B0D256, - (q31_t)0x5D3E5236, (q31_t)0x571DEEF9, (q31_t)0x5DC79D7C, - (q31_t)0x568A34A9, (q31_t)0x5E50015D, (q31_t)0x55F5A4D2, - (q31_t)0x5ED77C89, (q31_t)0x556040E2, (q31_t)0x5F5E0DB3, - (q31_t)0x54CA0A4A, (q31_t)0x5FE3B38D, (q31_t)0x5433027D, - (q31_t)0x60686CCE, (q31_t)0x539B2AEF, (q31_t)0x60EC3830, - (q31_t)0x53028517, (q31_t)0x616F146B, (q31_t)0x5269126E, - (q31_t)0x61F1003E, (q31_t)0x51CED46E, (q31_t)0x6271FA69, - (q31_t)0x5133CC94, (q31_t)0x62F201AC, (q31_t)0x5097FC5E, - (q31_t)0x637114CC, (q31_t)0x4FFB654D, (q31_t)0x63EF328F, - (q31_t)0x4F5E08E3, (q31_t)0x646C59BF, (q31_t)0x4EBFE8A4, - (q31_t)0x64E88926, (q31_t)0x4E210617, (q31_t)0x6563BF92, - (q31_t)0x4D8162C4, (q31_t)0x65DDFBD3, (q31_t)0x4CE10034, - (q31_t)0x66573CBB, (q31_t)0x4C3FDFF3, (q31_t)0x66CF811F, - (q31_t)0x4B9E038F, (q31_t)0x6746C7D7, (q31_t)0x4AFB6C97, - (q31_t)0x67BD0FBC, (q31_t)0x4A581C9D, (q31_t)0x683257AA, - (q31_t)0x49B41533, (q31_t)0x68A69E81, (q31_t)0x490F57EE, - (q31_t)0x6919E320, (q31_t)0x4869E664, (q31_t)0x698C246C, - (q31_t)0x47C3C22E, (q31_t)0x69FD614A, (q31_t)0x471CECE6, - (q31_t)0x6A6D98A4, (q31_t)0x46756827, (q31_t)0x6ADCC964, - (q31_t)0x45CD358F, (q31_t)0x6B4AF278, (q31_t)0x452456BC, - (q31_t)0x6BB812D0, (q31_t)0x447ACD50, (q31_t)0x6C242960, - (q31_t)0x43D09AEC, (q31_t)0x6C8F351C, (q31_t)0x4325C135, - (q31_t)0x6CF934FB, (q31_t)0x427A41D0, (q31_t)0x6D6227FA, - (q31_t)0x41CE1E64, (q31_t)0x6DCA0D14, (q31_t)0x4121589A, - (q31_t)0x6E30E349, (q31_t)0x4073F21D, (q31_t)0x6E96A99C, - (q31_t)0x3FC5EC97, (q31_t)0x6EFB5F12, (q31_t)0x3F1749B7, - (q31_t)0x6F5F02B1, (q31_t)0x3E680B2C, (q31_t)0x6FC19385, - (q31_t)0x3DB832A5, (q31_t)0x70231099, (q31_t)0x3D07C1D5, - (q31_t)0x708378FE, (q31_t)0x3C56BA70, (q31_t)0x70E2CBC6, - (q31_t)0x3BA51E29, (q31_t)0x71410804, (q31_t)0x3AF2EEB7, - (q31_t)0x719E2CD2, (q31_t)0x3A402DD1, (q31_t)0x71FA3948, - (q31_t)0x398CDD32, (q31_t)0x72552C84, (q31_t)0x38D8FE93, - (q31_t)0x72AF05A6, (q31_t)0x382493B0, (q31_t)0x7307C3D0, - (q31_t)0x376F9E46, (q31_t)0x735F6626, (q31_t)0x36BA2013, - (q31_t)0x73B5EBD0, (q31_t)0x36041AD9, (q31_t)0x740B53FA, - (q31_t)0x354D9056, (q31_t)0x745F9DD1, (q31_t)0x3496824F, - (q31_t)0x74B2C883, (q31_t)0x33DEF287, (q31_t)0x7504D345, - (q31_t)0x3326E2C2, (q31_t)0x7555BD4B, (q31_t)0x326E54C7, - (q31_t)0x75A585CF, (q31_t)0x31B54A5D, (q31_t)0x75F42C0A, - (q31_t)0x30FBC54D, (q31_t)0x7641AF3C, (q31_t)0x3041C760, - (q31_t)0x768E0EA5, (q31_t)0x2F875262, (q31_t)0x76D94988, - (q31_t)0x2ECC681E, (q31_t)0x77235F2D, (q31_t)0x2E110A62, - (q31_t)0x776C4EDB, (q31_t)0x2D553AFB, (q31_t)0x77B417DF, - (q31_t)0x2C98FBBA, (q31_t)0x77FAB988, (q31_t)0x2BDC4E6F, - (q31_t)0x78403328, (q31_t)0x2B1F34EB, (q31_t)0x78848413, - (q31_t)0x2A61B101, (q31_t)0x78C7ABA1, (q31_t)0x29A3C484, - (q31_t)0x7909A92C, (q31_t)0x28E5714A, (q31_t)0x794A7C11, - (q31_t)0x2826B928, (q31_t)0x798A23B1, (q31_t)0x27679DF4, - (q31_t)0x79C89F6D, (q31_t)0x26A82185, (q31_t)0x7A05EEAD, - (q31_t)0x25E845B5, (q31_t)0x7A4210D8, (q31_t)0x25280C5D, - (q31_t)0x7A7D055B, (q31_t)0x24677757, (q31_t)0x7AB6CBA3, - (q31_t)0x23A6887E, (q31_t)0x7AEF6323, (q31_t)0x22E541AE, - (q31_t)0x7B26CB4F, (q31_t)0x2223A4C5, (q31_t)0x7B5D039D, - (q31_t)0x2161B39F, (q31_t)0x7B920B89, (q31_t)0x209F701C, - (q31_t)0x7BC5E28F, (q31_t)0x1FDCDC1A, (q31_t)0x7BF88830, - (q31_t)0x1F19F97B, (q31_t)0x7C29FBEE, (q31_t)0x1E56CA1E, - (q31_t)0x7C5A3D4F, (q31_t)0x1D934FE5, (q31_t)0x7C894BDD, - (q31_t)0x1CCF8CB3, (q31_t)0x7CB72724, (q31_t)0x1C0B826A, - (q31_t)0x7CE3CEB1, (q31_t)0x1B4732EF, (q31_t)0x7D0F4218, - (q31_t)0x1A82A025, (q31_t)0x7D3980EC, (q31_t)0x19BDCBF2, - (q31_t)0x7D628AC5, (q31_t)0x18F8B83C, (q31_t)0x7D8A5F3F, - (q31_t)0x183366E8, (q31_t)0x7DB0FDF7, (q31_t)0x176DD9DE, - (q31_t)0x7DD6668E, (q31_t)0x16A81305, (q31_t)0x7DFA98A7, - (q31_t)0x15E21444, (q31_t)0x7E1D93E9, (q31_t)0x151BDF85, - (q31_t)0x7E3F57FE, (q31_t)0x145576B1, (q31_t)0x7E5FE493, - (q31_t)0x138EDBB0, (q31_t)0x7E7F3956, (q31_t)0x12C8106E, - (q31_t)0x7E9D55FC, (q31_t)0x120116D4, (q31_t)0x7EBA3A39, - (q31_t)0x1139F0CE, (q31_t)0x7ED5E5C6, (q31_t)0x1072A047, - (q31_t)0x7EF0585F, (q31_t)0x0FAB272B, (q31_t)0x7F0991C3, - (q31_t)0x0EE38765, (q31_t)0x7F2191B4, (q31_t)0x0E1BC2E3, - (q31_t)0x7F3857F5, (q31_t)0x0D53DB92, (q31_t)0x7F4DE450, - (q31_t)0x0C8BD35E, (q31_t)0x7F62368F, (q31_t)0x0BC3AC35, - (q31_t)0x7F754E7F, (q31_t)0x0AFB6805, (q31_t)0x7F872BF3, - (q31_t)0x0A3308BC, (q31_t)0x7F97CEBC, (q31_t)0x096A9049, - (q31_t)0x7FA736B4, (q31_t)0x08A2009A, (q31_t)0x7FB563B2, - (q31_t)0x07D95B9E, (q31_t)0x7FC25596, (q31_t)0x0710A344, - (q31_t)0x7FCE0C3E, (q31_t)0x0647D97C, (q31_t)0x7FD8878D, - (q31_t)0x057F0034, (q31_t)0x7FE1C76B, (q31_t)0x04B6195D, - (q31_t)0x7FE9CBC0, (q31_t)0x03ED26E6, (q31_t)0x7FF09477, - (q31_t)0x03242ABF, (q31_t)0x7FF62182, (q31_t)0x025B26D7, - (q31_t)0x7FFA72D1, (q31_t)0x01921D1F, (q31_t)0x7FFD885A, - (q31_t)0x00C90F88, (q31_t)0x7FFF6216, (q31_t)0x00000000, - (q31_t)0x7FFFFFFF, (q31_t)0xFF36F078, (q31_t)0x7FFF6216, - (q31_t)0xFE6DE2E0, (q31_t)0x7FFD885A, (q31_t)0xFDA4D928, - (q31_t)0x7FFA72D1, (q31_t)0xFCDBD541, (q31_t)0x7FF62182, - (q31_t)0xFC12D919, (q31_t)0x7FF09477, (q31_t)0xFB49E6A2, - (q31_t)0x7FE9CBC0, (q31_t)0xFA80FFCB, (q31_t)0x7FE1C76B, - (q31_t)0xF9B82683, (q31_t)0x7FD8878D, (q31_t)0xF8EF5CBB, - (q31_t)0x7FCE0C3E, (q31_t)0xF826A461, (q31_t)0x7FC25596, - (q31_t)0xF75DFF65, (q31_t)0x7FB563B2, (q31_t)0xF6956FB6, - (q31_t)0x7FA736B4, (q31_t)0xF5CCF743, (q31_t)0x7F97CEBC, - (q31_t)0xF50497FA, (q31_t)0x7F872BF3, (q31_t)0xF43C53CA, - (q31_t)0x7F754E7F, (q31_t)0xF3742CA1, (q31_t)0x7F62368F, - (q31_t)0xF2AC246D, (q31_t)0x7F4DE450, (q31_t)0xF1E43D1C, - (q31_t)0x7F3857F5, (q31_t)0xF11C789A, (q31_t)0x7F2191B4, - (q31_t)0xF054D8D4, (q31_t)0x7F0991C3, (q31_t)0xEF8D5FB8, - (q31_t)0x7EF0585F, (q31_t)0xEEC60F31, (q31_t)0x7ED5E5C6, - (q31_t)0xEDFEE92B, (q31_t)0x7EBA3A39, (q31_t)0xED37EF91, - (q31_t)0x7E9D55FC, (q31_t)0xEC71244F, (q31_t)0x7E7F3956, - (q31_t)0xEBAA894E, (q31_t)0x7E5FE493, (q31_t)0xEAE4207A, - (q31_t)0x7E3F57FE, (q31_t)0xEA1DEBBB, (q31_t)0x7E1D93E9, - (q31_t)0xE957ECFB, (q31_t)0x7DFA98A7, (q31_t)0xE8922621, - (q31_t)0x7DD6668E, (q31_t)0xE7CC9917, (q31_t)0x7DB0FDF7, - (q31_t)0xE70747C3, (q31_t)0x7D8A5F3F, (q31_t)0xE642340D, - (q31_t)0x7D628AC5, (q31_t)0xE57D5FDA, (q31_t)0x7D3980EC, - (q31_t)0xE4B8CD10, (q31_t)0x7D0F4218, (q31_t)0xE3F47D95, - (q31_t)0x7CE3CEB1, (q31_t)0xE330734C, (q31_t)0x7CB72724, - (q31_t)0xE26CB01A, (q31_t)0x7C894BDD, (q31_t)0xE1A935E1, - (q31_t)0x7C5A3D4F, (q31_t)0xE0E60684, (q31_t)0x7C29FBEE, - (q31_t)0xE02323E5, (q31_t)0x7BF88830, (q31_t)0xDF608FE3, - (q31_t)0x7BC5E28F, (q31_t)0xDE9E4C60, (q31_t)0x7B920B89, - (q31_t)0xDDDC5B3A, (q31_t)0x7B5D039D, (q31_t)0xDD1ABE51, - (q31_t)0x7B26CB4F, (q31_t)0xDC597781, (q31_t)0x7AEF6323, - (q31_t)0xDB9888A8, (q31_t)0x7AB6CBA3, (q31_t)0xDAD7F3A2, - (q31_t)0x7A7D055B, (q31_t)0xDA17BA4A, (q31_t)0x7A4210D8, - (q31_t)0xD957DE7A, (q31_t)0x7A05EEAD, (q31_t)0xD898620C, - (q31_t)0x79C89F6D, (q31_t)0xD7D946D7, (q31_t)0x798A23B1, - (q31_t)0xD71A8EB5, (q31_t)0x794A7C11, (q31_t)0xD65C3B7B, - (q31_t)0x7909A92C, (q31_t)0xD59E4EFE, (q31_t)0x78C7ABA1, - (q31_t)0xD4E0CB14, (q31_t)0x78848413, (q31_t)0xD423B190, - (q31_t)0x78403328, (q31_t)0xD3670445, (q31_t)0x77FAB988, - (q31_t)0xD2AAC504, (q31_t)0x77B417DF, (q31_t)0xD1EEF59E, - (q31_t)0x776C4EDB, (q31_t)0xD13397E1, (q31_t)0x77235F2D, - (q31_t)0xD078AD9D, (q31_t)0x76D94988, (q31_t)0xCFBE389F, - (q31_t)0x768E0EA5, (q31_t)0xCF043AB2, (q31_t)0x7641AF3C, - (q31_t)0xCE4AB5A2, (q31_t)0x75F42C0A, (q31_t)0xCD91AB38, - (q31_t)0x75A585CF, (q31_t)0xCCD91D3D, (q31_t)0x7555BD4B, - (q31_t)0xCC210D78, (q31_t)0x7504D345, (q31_t)0xCB697DB0, - (q31_t)0x74B2C883, (q31_t)0xCAB26FA9, (q31_t)0x745F9DD1, - (q31_t)0xC9FBE527, (q31_t)0x740B53FA, (q31_t)0xC945DFEC, - (q31_t)0x73B5EBD0, (q31_t)0xC89061BA, (q31_t)0x735F6626, - (q31_t)0xC7DB6C50, (q31_t)0x7307C3D0, (q31_t)0xC727016C, - (q31_t)0x72AF05A6, (q31_t)0xC67322CD, (q31_t)0x72552C84, - (q31_t)0xC5BFD22E, (q31_t)0x71FA3948, (q31_t)0xC50D1148, - (q31_t)0x719E2CD2, (q31_t)0xC45AE1D7, (q31_t)0x71410804, - (q31_t)0xC3A9458F, (q31_t)0x70E2CBC6, (q31_t)0xC2F83E2A, - (q31_t)0x708378FE, (q31_t)0xC247CD5A, (q31_t)0x70231099, - (q31_t)0xC197F4D3, (q31_t)0x6FC19385, (q31_t)0xC0E8B648, - (q31_t)0x6F5F02B1, (q31_t)0xC03A1368, (q31_t)0x6EFB5F12, - (q31_t)0xBF8C0DE2, (q31_t)0x6E96A99C, (q31_t)0xBEDEA765, - (q31_t)0x6E30E349, (q31_t)0xBE31E19B, (q31_t)0x6DCA0D14, - (q31_t)0xBD85BE2F, (q31_t)0x6D6227FA, (q31_t)0xBCDA3ECA, - (q31_t)0x6CF934FB, (q31_t)0xBC2F6513, (q31_t)0x6C8F351C, - (q31_t)0xBB8532AF, (q31_t)0x6C242960, (q31_t)0xBADBA943, - (q31_t)0x6BB812D0, (q31_t)0xBA32CA70, (q31_t)0x6B4AF278, - (q31_t)0xB98A97D8, (q31_t)0x6ADCC964, (q31_t)0xB8E31319, - (q31_t)0x6A6D98A4, (q31_t)0xB83C3DD1, (q31_t)0x69FD614A, - (q31_t)0xB796199B, (q31_t)0x698C246C, (q31_t)0xB6F0A811, - (q31_t)0x6919E320, (q31_t)0xB64BEACC, (q31_t)0x68A69E81, - (q31_t)0xB5A7E362, (q31_t)0x683257AA, (q31_t)0xB5049368, - (q31_t)0x67BD0FBC, (q31_t)0xB461FC70, (q31_t)0x6746C7D7, - (q31_t)0xB3C0200C, (q31_t)0x66CF811F, (q31_t)0xB31EFFCB, - (q31_t)0x66573CBB, (q31_t)0xB27E9D3B, (q31_t)0x65DDFBD3, - (q31_t)0xB1DEF9E8, (q31_t)0x6563BF92, (q31_t)0xB140175B, - (q31_t)0x64E88926, (q31_t)0xB0A1F71C, (q31_t)0x646C59BF, - (q31_t)0xB0049AB2, (q31_t)0x63EF328F, (q31_t)0xAF6803A1, - (q31_t)0x637114CC, (q31_t)0xAECC336B, (q31_t)0x62F201AC, - (q31_t)0xAE312B91, (q31_t)0x6271FA69, (q31_t)0xAD96ED91, - (q31_t)0x61F1003E, (q31_t)0xACFD7AE8, (q31_t)0x616F146B, - (q31_t)0xAC64D510, (q31_t)0x60EC3830, (q31_t)0xABCCFD82, - (q31_t)0x60686CCE, (q31_t)0xAB35F5B5, (q31_t)0x5FE3B38D, - (q31_t)0xAA9FBF1D, (q31_t)0x5F5E0DB3, (q31_t)0xAA0A5B2D, - (q31_t)0x5ED77C89, (q31_t)0xA975CB56, (q31_t)0x5E50015D, - (q31_t)0xA8E21106, (q31_t)0x5DC79D7C, (q31_t)0xA84F2DA9, - (q31_t)0x5D3E5236, (q31_t)0xA7BD22AB, (q31_t)0x5CB420DF, - (q31_t)0xA72BF173, (q31_t)0x5C290ACC, (q31_t)0xA69B9B68, - (q31_t)0x5B9D1153, (q31_t)0xA60C21ED, (q31_t)0x5B1035CF, - (q31_t)0xA57D8666, (q31_t)0x5A82799A, (q31_t)0xA4EFCA31, - (q31_t)0x59F3DE12, (q31_t)0xA462EEAC, (q31_t)0x59646497, - (q31_t)0xA3D6F533, (q31_t)0x58D40E8C, (q31_t)0xA34BDF20, - (q31_t)0x5842DD54, (q31_t)0xA2C1ADC9, (q31_t)0x57B0D256, - (q31_t)0xA2386283, (q31_t)0x571DEEF9, (q31_t)0xA1AFFEA2, - (q31_t)0x568A34A9, (q31_t)0xA1288376, (q31_t)0x55F5A4D2, - (q31_t)0xA0A1F24C, (q31_t)0x556040E2, (q31_t)0xA01C4C72, - (q31_t)0x54CA0A4A, (q31_t)0x9F979331, (q31_t)0x5433027D, - (q31_t)0x9F13C7D0, (q31_t)0x539B2AEF, (q31_t)0x9E90EB94, - (q31_t)0x53028517, (q31_t)0x9E0EFFC1, (q31_t)0x5269126E, - (q31_t)0x9D8E0596, (q31_t)0x51CED46E, (q31_t)0x9D0DFE53, - (q31_t)0x5133CC94, (q31_t)0x9C8EEB33, (q31_t)0x5097FC5E, - (q31_t)0x9C10CD70, (q31_t)0x4FFB654D, (q31_t)0x9B93A640, - (q31_t)0x4F5E08E3, (q31_t)0x9B1776D9, (q31_t)0x4EBFE8A4, - (q31_t)0x9A9C406D, (q31_t)0x4E210617, (q31_t)0x9A22042C, - (q31_t)0x4D8162C4, (q31_t)0x99A8C344, (q31_t)0x4CE10034, - (q31_t)0x99307EE0, (q31_t)0x4C3FDFF3, (q31_t)0x98B93828, - (q31_t)0x4B9E038F, (q31_t)0x9842F043, (q31_t)0x4AFB6C97, - (q31_t)0x97CDA855, (q31_t)0x4A581C9D, (q31_t)0x9759617E, - (q31_t)0x49B41533, (q31_t)0x96E61CDF, (q31_t)0x490F57EE, - (q31_t)0x9673DB94, (q31_t)0x4869E664, (q31_t)0x96029EB5, - (q31_t)0x47C3C22E, (q31_t)0x9592675B, (q31_t)0x471CECE6, - (q31_t)0x9523369B, (q31_t)0x46756827, (q31_t)0x94B50D87, - (q31_t)0x45CD358F, (q31_t)0x9447ED2F, (q31_t)0x452456BC, - (q31_t)0x93DBD69F, (q31_t)0x447ACD50, (q31_t)0x9370CAE4, - (q31_t)0x43D09AEC, (q31_t)0x9306CB04, (q31_t)0x4325C135, - (q31_t)0x929DD805, (q31_t)0x427A41D0, (q31_t)0x9235F2EB, - (q31_t)0x41CE1E64, (q31_t)0x91CF1CB6, (q31_t)0x4121589A, - (q31_t)0x91695663, (q31_t)0x4073F21D, (q31_t)0x9104A0ED, - (q31_t)0x3FC5EC97, (q31_t)0x90A0FD4E, (q31_t)0x3F1749B7, - (q31_t)0x903E6C7A, (q31_t)0x3E680B2C, (q31_t)0x8FDCEF66, - (q31_t)0x3DB832A5, (q31_t)0x8F7C8701, (q31_t)0x3D07C1D5, - (q31_t)0x8F1D343A, (q31_t)0x3C56BA70, (q31_t)0x8EBEF7FB, - (q31_t)0x3BA51E29, (q31_t)0x8E61D32D, (q31_t)0x3AF2EEB7, - (q31_t)0x8E05C6B7, (q31_t)0x3A402DD1, (q31_t)0x8DAAD37B, - (q31_t)0x398CDD32, (q31_t)0x8D50FA59, (q31_t)0x38D8FE93, - (q31_t)0x8CF83C30, (q31_t)0x382493B0, (q31_t)0x8CA099D9, - (q31_t)0x376F9E46, (q31_t)0x8C4A142F, (q31_t)0x36BA2013, - (q31_t)0x8BF4AC05, (q31_t)0x36041AD9, (q31_t)0x8BA0622F, - (q31_t)0x354D9056, (q31_t)0x8B4D377C, (q31_t)0x3496824F, - (q31_t)0x8AFB2CBA, (q31_t)0x33DEF287, (q31_t)0x8AAA42B4, - (q31_t)0x3326E2C2, (q31_t)0x8A5A7A30, (q31_t)0x326E54C7, - (q31_t)0x8A0BD3F5, (q31_t)0x31B54A5D, (q31_t)0x89BE50C3, - (q31_t)0x30FBC54D, (q31_t)0x8971F15A, (q31_t)0x3041C760, - (q31_t)0x8926B677, (q31_t)0x2F875262, (q31_t)0x88DCA0D3, - (q31_t)0x2ECC681E, (q31_t)0x8893B124, (q31_t)0x2E110A62, - (q31_t)0x884BE820, (q31_t)0x2D553AFB, (q31_t)0x88054677, - (q31_t)0x2C98FBBA, (q31_t)0x87BFCCD7, (q31_t)0x2BDC4E6F, - (q31_t)0x877B7BEC, (q31_t)0x2B1F34EB, (q31_t)0x8738545E, - (q31_t)0x2A61B101, (q31_t)0x86F656D3, (q31_t)0x29A3C484, - (q31_t)0x86B583EE, (q31_t)0x28E5714A, (q31_t)0x8675DC4E, - (q31_t)0x2826B928, (q31_t)0x86376092, (q31_t)0x27679DF4, - (q31_t)0x85FA1152, (q31_t)0x26A82185, (q31_t)0x85BDEF27, - (q31_t)0x25E845B5, (q31_t)0x8582FAA4, (q31_t)0x25280C5D, - (q31_t)0x8549345C, (q31_t)0x24677757, (q31_t)0x85109CDC, - (q31_t)0x23A6887E, (q31_t)0x84D934B0, (q31_t)0x22E541AE, - (q31_t)0x84A2FC62, (q31_t)0x2223A4C5, (q31_t)0x846DF476, - (q31_t)0x2161B39F, (q31_t)0x843A1D70, (q31_t)0x209F701C, - (q31_t)0x840777CF, (q31_t)0x1FDCDC1A, (q31_t)0x83D60411, - (q31_t)0x1F19F97B, (q31_t)0x83A5C2B0, (q31_t)0x1E56CA1E, - (q31_t)0x8376B422, (q31_t)0x1D934FE5, (q31_t)0x8348D8DB, - (q31_t)0x1CCF8CB3, (q31_t)0x831C314E, (q31_t)0x1C0B826A, - (q31_t)0x82F0BDE8, (q31_t)0x1B4732EF, (q31_t)0x82C67F13, - (q31_t)0x1A82A025, (q31_t)0x829D753A, (q31_t)0x19BDCBF2, - (q31_t)0x8275A0C0, (q31_t)0x18F8B83C, (q31_t)0x824F0208, - (q31_t)0x183366E8, (q31_t)0x82299971, (q31_t)0x176DD9DE, - (q31_t)0x82056758, (q31_t)0x16A81305, (q31_t)0x81E26C16, - (q31_t)0x15E21444, (q31_t)0x81C0A801, (q31_t)0x151BDF85, - (q31_t)0x81A01B6C, (q31_t)0x145576B1, (q31_t)0x8180C6A9, - (q31_t)0x138EDBB0, (q31_t)0x8162AA03, (q31_t)0x12C8106E, - (q31_t)0x8145C5C6, (q31_t)0x120116D4, (q31_t)0x812A1A39, - (q31_t)0x1139F0CE, (q31_t)0x810FA7A0, (q31_t)0x1072A047, - (q31_t)0x80F66E3C, (q31_t)0x0FAB272B, (q31_t)0x80DE6E4C, - (q31_t)0x0EE38765, (q31_t)0x80C7A80A, (q31_t)0x0E1BC2E3, - (q31_t)0x80B21BAF, (q31_t)0x0D53DB92, (q31_t)0x809DC970, - (q31_t)0x0C8BD35E, (q31_t)0x808AB180, (q31_t)0x0BC3AC35, - (q31_t)0x8078D40D, (q31_t)0x0AFB6805, (q31_t)0x80683143, - (q31_t)0x0A3308BC, (q31_t)0x8058C94C, (q31_t)0x096A9049, - (q31_t)0x804A9C4D, (q31_t)0x08A2009A, (q31_t)0x803DAA69, - (q31_t)0x07D95B9E, (q31_t)0x8031F3C1, (q31_t)0x0710A344, - (q31_t)0x80277872, (q31_t)0x0647D97C, (q31_t)0x801E3894, - (q31_t)0x057F0034, (q31_t)0x80163440, (q31_t)0x04B6195D, - (q31_t)0x800F6B88, (q31_t)0x03ED26E6, (q31_t)0x8009DE7D, - (q31_t)0x03242ABF, (q31_t)0x80058D2E, (q31_t)0x025B26D7, - (q31_t)0x800277A5, (q31_t)0x01921D1F, (q31_t)0x80009DE9, - (q31_t)0x00C90F88, (q31_t)0x80000000, (q31_t)0x00000000, - (q31_t)0x80009DE9, (q31_t)0xFF36F078, (q31_t)0x800277A5, - (q31_t)0xFE6DE2E0, (q31_t)0x80058D2E, (q31_t)0xFDA4D928, - (q31_t)0x8009DE7D, (q31_t)0xFCDBD541, (q31_t)0x800F6B88, - (q31_t)0xFC12D919, (q31_t)0x80163440, (q31_t)0xFB49E6A2, - (q31_t)0x801E3894, (q31_t)0xFA80FFCB, (q31_t)0x80277872, - (q31_t)0xF9B82683, (q31_t)0x8031F3C1, (q31_t)0xF8EF5CBB, - (q31_t)0x803DAA69, (q31_t)0xF826A461, (q31_t)0x804A9C4D, - (q31_t)0xF75DFF65, (q31_t)0x8058C94C, (q31_t)0xF6956FB6, - (q31_t)0x80683143, (q31_t)0xF5CCF743, (q31_t)0x8078D40D, - (q31_t)0xF50497FA, (q31_t)0x808AB180, (q31_t)0xF43C53CA, - (q31_t)0x809DC970, (q31_t)0xF3742CA1, (q31_t)0x80B21BAF, - (q31_t)0xF2AC246D, (q31_t)0x80C7A80A, (q31_t)0xF1E43D1C, - (q31_t)0x80DE6E4C, (q31_t)0xF11C789A, (q31_t)0x80F66E3C, - (q31_t)0xF054D8D4, (q31_t)0x810FA7A0, (q31_t)0xEF8D5FB8, - (q31_t)0x812A1A39, (q31_t)0xEEC60F31, (q31_t)0x8145C5C6, - (q31_t)0xEDFEE92B, (q31_t)0x8162AA03, (q31_t)0xED37EF91, - (q31_t)0x8180C6A9, (q31_t)0xEC71244F, (q31_t)0x81A01B6C, - (q31_t)0xEBAA894E, (q31_t)0x81C0A801, (q31_t)0xEAE4207A, - (q31_t)0x81E26C16, (q31_t)0xEA1DEBBB, (q31_t)0x82056758, - (q31_t)0xE957ECFB, (q31_t)0x82299971, (q31_t)0xE8922621, - (q31_t)0x824F0208, (q31_t)0xE7CC9917, (q31_t)0x8275A0C0, - (q31_t)0xE70747C3, (q31_t)0x829D753A, (q31_t)0xE642340D, - (q31_t)0x82C67F13, (q31_t)0xE57D5FDA, (q31_t)0x82F0BDE8, - (q31_t)0xE4B8CD10, (q31_t)0x831C314E, (q31_t)0xE3F47D95, - (q31_t)0x8348D8DB, (q31_t)0xE330734C, (q31_t)0x8376B422, - (q31_t)0xE26CB01A, (q31_t)0x83A5C2B0, (q31_t)0xE1A935E1, - (q31_t)0x83D60411, (q31_t)0xE0E60684, (q31_t)0x840777CF, - (q31_t)0xE02323E5, (q31_t)0x843A1D70, (q31_t)0xDF608FE3, - (q31_t)0x846DF476, (q31_t)0xDE9E4C60, (q31_t)0x84A2FC62, - (q31_t)0xDDDC5B3A, (q31_t)0x84D934B0, (q31_t)0xDD1ABE51, - (q31_t)0x85109CDC, (q31_t)0xDC597781, (q31_t)0x8549345C, - (q31_t)0xDB9888A8, (q31_t)0x8582FAA4, (q31_t)0xDAD7F3A2, - (q31_t)0x85BDEF27, (q31_t)0xDA17BA4A, (q31_t)0x85FA1152, - (q31_t)0xD957DE7A, (q31_t)0x86376092, (q31_t)0xD898620C, - (q31_t)0x8675DC4E, (q31_t)0xD7D946D7, (q31_t)0x86B583EE, - (q31_t)0xD71A8EB5, (q31_t)0x86F656D3, (q31_t)0xD65C3B7B, - (q31_t)0x8738545E, (q31_t)0xD59E4EFE, (q31_t)0x877B7BEC, - (q31_t)0xD4E0CB14, (q31_t)0x87BFCCD7, (q31_t)0xD423B190, - (q31_t)0x88054677, (q31_t)0xD3670445, (q31_t)0x884BE820, - (q31_t)0xD2AAC504, (q31_t)0x8893B124, (q31_t)0xD1EEF59E, - (q31_t)0x88DCA0D3, (q31_t)0xD13397E1, (q31_t)0x8926B677, - (q31_t)0xD078AD9D, (q31_t)0x8971F15A, (q31_t)0xCFBE389F, - (q31_t)0x89BE50C3, (q31_t)0xCF043AB2, (q31_t)0x8A0BD3F5, - (q31_t)0xCE4AB5A2, (q31_t)0x8A5A7A30, (q31_t)0xCD91AB38, - (q31_t)0x8AAA42B4, (q31_t)0xCCD91D3D, (q31_t)0x8AFB2CBA, - (q31_t)0xCC210D78, (q31_t)0x8B4D377C, (q31_t)0xCB697DB0, - (q31_t)0x8BA0622F, (q31_t)0xCAB26FA9, (q31_t)0x8BF4AC05, - (q31_t)0xC9FBE527, (q31_t)0x8C4A142F, (q31_t)0xC945DFEC, - (q31_t)0x8CA099D9, (q31_t)0xC89061BA, (q31_t)0x8CF83C30, - (q31_t)0xC7DB6C50, (q31_t)0x8D50FA59, (q31_t)0xC727016C, - (q31_t)0x8DAAD37B, (q31_t)0xC67322CD, (q31_t)0x8E05C6B7, - (q31_t)0xC5BFD22E, (q31_t)0x8E61D32D, (q31_t)0xC50D1148, - (q31_t)0x8EBEF7FB, (q31_t)0xC45AE1D7, (q31_t)0x8F1D343A, - (q31_t)0xC3A9458F, (q31_t)0x8F7C8701, (q31_t)0xC2F83E2A, - (q31_t)0x8FDCEF66, (q31_t)0xC247CD5A, (q31_t)0x903E6C7A, - (q31_t)0xC197F4D3, (q31_t)0x90A0FD4E, (q31_t)0xC0E8B648, - (q31_t)0x9104A0ED, (q31_t)0xC03A1368, (q31_t)0x91695663, - (q31_t)0xBF8C0DE2, (q31_t)0x91CF1CB6, (q31_t)0xBEDEA765, - (q31_t)0x9235F2EB, (q31_t)0xBE31E19B, (q31_t)0x929DD805, - (q31_t)0xBD85BE2F, (q31_t)0x9306CB04, (q31_t)0xBCDA3ECA, - (q31_t)0x9370CAE4, (q31_t)0xBC2F6513, (q31_t)0x93DBD69F, - (q31_t)0xBB8532AF, (q31_t)0x9447ED2F, (q31_t)0xBADBA943, - (q31_t)0x94B50D87, (q31_t)0xBA32CA70, (q31_t)0x9523369B, - (q31_t)0xB98A97D8, (q31_t)0x9592675B, (q31_t)0xB8E31319, - (q31_t)0x96029EB5, (q31_t)0xB83C3DD1, (q31_t)0x9673DB94, - (q31_t)0xB796199B, (q31_t)0x96E61CDF, (q31_t)0xB6F0A811, - (q31_t)0x9759617E, (q31_t)0xB64BEACC, (q31_t)0x97CDA855, - (q31_t)0xB5A7E362, (q31_t)0x9842F043, (q31_t)0xB5049368, - (q31_t)0x98B93828, (q31_t)0xB461FC70, (q31_t)0x99307EE0, - (q31_t)0xB3C0200C, (q31_t)0x99A8C344, (q31_t)0xB31EFFCB, - (q31_t)0x9A22042C, (q31_t)0xB27E9D3B, (q31_t)0x9A9C406D, - (q31_t)0xB1DEF9E8, (q31_t)0x9B1776D9, (q31_t)0xB140175B, - (q31_t)0x9B93A640, (q31_t)0xB0A1F71C, (q31_t)0x9C10CD70, - (q31_t)0xB0049AB2, (q31_t)0x9C8EEB33, (q31_t)0xAF6803A1, - (q31_t)0x9D0DFE53, (q31_t)0xAECC336B, (q31_t)0x9D8E0596, - (q31_t)0xAE312B91, (q31_t)0x9E0EFFC1, (q31_t)0xAD96ED91, - (q31_t)0x9E90EB94, (q31_t)0xACFD7AE8, (q31_t)0x9F13C7D0, - (q31_t)0xAC64D510, (q31_t)0x9F979331, (q31_t)0xABCCFD82, - (q31_t)0xA01C4C72, (q31_t)0xAB35F5B5, (q31_t)0xA0A1F24C, - (q31_t)0xAA9FBF1D, (q31_t)0xA1288376, (q31_t)0xAA0A5B2D, - (q31_t)0xA1AFFEA2, (q31_t)0xA975CB56, (q31_t)0xA2386283, - (q31_t)0xA8E21106, (q31_t)0xA2C1ADC9, (q31_t)0xA84F2DA9, - (q31_t)0xA34BDF20, (q31_t)0xA7BD22AB, (q31_t)0xA3D6F533, - (q31_t)0xA72BF173, (q31_t)0xA462EEAC, (q31_t)0xA69B9B68, - (q31_t)0xA4EFCA31, (q31_t)0xA60C21ED, (q31_t)0xA57D8666, - (q31_t)0xA57D8666, (q31_t)0xA60C21ED, (q31_t)0xA4EFCA31, - (q31_t)0xA69B9B68, (q31_t)0xA462EEAC, (q31_t)0xA72BF173, - (q31_t)0xA3D6F533, (q31_t)0xA7BD22AB, (q31_t)0xA34BDF20, - (q31_t)0xA84F2DA9, (q31_t)0xA2C1ADC9, (q31_t)0xA8E21106, - (q31_t)0xA2386283, (q31_t)0xA975CB56, (q31_t)0xA1AFFEA2, - (q31_t)0xAA0A5B2D, (q31_t)0xA1288376, (q31_t)0xAA9FBF1D, - (q31_t)0xA0A1F24C, (q31_t)0xAB35F5B5, (q31_t)0xA01C4C72, - (q31_t)0xABCCFD82, (q31_t)0x9F979331, (q31_t)0xAC64D510, - (q31_t)0x9F13C7D0, (q31_t)0xACFD7AE8, (q31_t)0x9E90EB94, - (q31_t)0xAD96ED91, (q31_t)0x9E0EFFC1, (q31_t)0xAE312B91, - (q31_t)0x9D8E0596, (q31_t)0xAECC336B, (q31_t)0x9D0DFE53, - (q31_t)0xAF6803A1, (q31_t)0x9C8EEB33, (q31_t)0xB0049AB2, - (q31_t)0x9C10CD70, (q31_t)0xB0A1F71C, (q31_t)0x9B93A640, - (q31_t)0xB140175B, (q31_t)0x9B1776D9, (q31_t)0xB1DEF9E8, - (q31_t)0x9A9C406D, (q31_t)0xB27E9D3B, (q31_t)0x9A22042C, - (q31_t)0xB31EFFCB, (q31_t)0x99A8C344, (q31_t)0xB3C0200C, - (q31_t)0x99307EE0, (q31_t)0xB461FC70, (q31_t)0x98B93828, - (q31_t)0xB5049368, (q31_t)0x9842F043, (q31_t)0xB5A7E362, - (q31_t)0x97CDA855, (q31_t)0xB64BEACC, (q31_t)0x9759617E, - (q31_t)0xB6F0A811, (q31_t)0x96E61CDF, (q31_t)0xB796199B, - (q31_t)0x9673DB94, (q31_t)0xB83C3DD1, (q31_t)0x96029EB5, - (q31_t)0xB8E31319, (q31_t)0x9592675B, (q31_t)0xB98A97D8, - (q31_t)0x9523369B, (q31_t)0xBA32CA70, (q31_t)0x94B50D87, - (q31_t)0xBADBA943, (q31_t)0x9447ED2F, (q31_t)0xBB8532AF, - (q31_t)0x93DBD69F, (q31_t)0xBC2F6513, (q31_t)0x9370CAE4, - (q31_t)0xBCDA3ECA, (q31_t)0x9306CB04, (q31_t)0xBD85BE2F, - (q31_t)0x929DD805, (q31_t)0xBE31E19B, (q31_t)0x9235F2EB, - (q31_t)0xBEDEA765, (q31_t)0x91CF1CB6, (q31_t)0xBF8C0DE2, - (q31_t)0x91695663, (q31_t)0xC03A1368, (q31_t)0x9104A0ED, - (q31_t)0xC0E8B648, (q31_t)0x90A0FD4E, (q31_t)0xC197F4D3, - (q31_t)0x903E6C7A, (q31_t)0xC247CD5A, (q31_t)0x8FDCEF66, - (q31_t)0xC2F83E2A, (q31_t)0x8F7C8701, (q31_t)0xC3A9458F, - (q31_t)0x8F1D343A, (q31_t)0xC45AE1D7, (q31_t)0x8EBEF7FB, - (q31_t)0xC50D1148, (q31_t)0x8E61D32D, (q31_t)0xC5BFD22E, - (q31_t)0x8E05C6B7, (q31_t)0xC67322CD, (q31_t)0x8DAAD37B, - (q31_t)0xC727016C, (q31_t)0x8D50FA59, (q31_t)0xC7DB6C50, - (q31_t)0x8CF83C30, (q31_t)0xC89061BA, (q31_t)0x8CA099D9, - (q31_t)0xC945DFEC, (q31_t)0x8C4A142F, (q31_t)0xC9FBE527, - (q31_t)0x8BF4AC05, (q31_t)0xCAB26FA9, (q31_t)0x8BA0622F, - (q31_t)0xCB697DB0, (q31_t)0x8B4D377C, (q31_t)0xCC210D78, - (q31_t)0x8AFB2CBA, (q31_t)0xCCD91D3D, (q31_t)0x8AAA42B4, - (q31_t)0xCD91AB38, (q31_t)0x8A5A7A30, (q31_t)0xCE4AB5A2, - (q31_t)0x8A0BD3F5, (q31_t)0xCF043AB2, (q31_t)0x89BE50C3, - (q31_t)0xCFBE389F, (q31_t)0x8971F15A, (q31_t)0xD078AD9D, - (q31_t)0x8926B677, (q31_t)0xD13397E1, (q31_t)0x88DCA0D3, - (q31_t)0xD1EEF59E, (q31_t)0x8893B124, (q31_t)0xD2AAC504, - (q31_t)0x884BE820, (q31_t)0xD3670445, (q31_t)0x88054677, - (q31_t)0xD423B190, (q31_t)0x87BFCCD7, (q31_t)0xD4E0CB14, - (q31_t)0x877B7BEC, (q31_t)0xD59E4EFE, (q31_t)0x8738545E, - (q31_t)0xD65C3B7B, (q31_t)0x86F656D3, (q31_t)0xD71A8EB5, - (q31_t)0x86B583EE, (q31_t)0xD7D946D7, (q31_t)0x8675DC4E, - (q31_t)0xD898620C, (q31_t)0x86376092, (q31_t)0xD957DE7A, - (q31_t)0x85FA1152, (q31_t)0xDA17BA4A, (q31_t)0x85BDEF27, - (q31_t)0xDAD7F3A2, (q31_t)0x8582FAA4, (q31_t)0xDB9888A8, - (q31_t)0x8549345C, (q31_t)0xDC597781, (q31_t)0x85109CDC, - (q31_t)0xDD1ABE51, (q31_t)0x84D934B0, (q31_t)0xDDDC5B3A, - (q31_t)0x84A2FC62, (q31_t)0xDE9E4C60, (q31_t)0x846DF476, - (q31_t)0xDF608FE3, (q31_t)0x843A1D70, (q31_t)0xE02323E5, - (q31_t)0x840777CF, (q31_t)0xE0E60684, (q31_t)0x83D60411, - (q31_t)0xE1A935E1, (q31_t)0x83A5C2B0, (q31_t)0xE26CB01A, - (q31_t)0x8376B422, (q31_t)0xE330734C, (q31_t)0x8348D8DB, - (q31_t)0xE3F47D95, (q31_t)0x831C314E, (q31_t)0xE4B8CD10, - (q31_t)0x82F0BDE8, (q31_t)0xE57D5FDA, (q31_t)0x82C67F13, - (q31_t)0xE642340D, (q31_t)0x829D753A, (q31_t)0xE70747C3, - (q31_t)0x8275A0C0, (q31_t)0xE7CC9917, (q31_t)0x824F0208, - (q31_t)0xE8922621, (q31_t)0x82299971, (q31_t)0xE957ECFB, - (q31_t)0x82056758, (q31_t)0xEA1DEBBB, (q31_t)0x81E26C16, - (q31_t)0xEAE4207A, (q31_t)0x81C0A801, (q31_t)0xEBAA894E, - (q31_t)0x81A01B6C, (q31_t)0xEC71244F, (q31_t)0x8180C6A9, - (q31_t)0xED37EF91, (q31_t)0x8162AA03, (q31_t)0xEDFEE92B, - (q31_t)0x8145C5C6, (q31_t)0xEEC60F31, (q31_t)0x812A1A39, - (q31_t)0xEF8D5FB8, (q31_t)0x810FA7A0, (q31_t)0xF054D8D4, - (q31_t)0x80F66E3C, (q31_t)0xF11C789A, (q31_t)0x80DE6E4C, - (q31_t)0xF1E43D1C, (q31_t)0x80C7A80A, (q31_t)0xF2AC246D, - (q31_t)0x80B21BAF, (q31_t)0xF3742CA1, (q31_t)0x809DC970, - (q31_t)0xF43C53CA, (q31_t)0x808AB180, (q31_t)0xF50497FA, - (q31_t)0x8078D40D, (q31_t)0xF5CCF743, (q31_t)0x80683143, - (q31_t)0xF6956FB6, (q31_t)0x8058C94C, (q31_t)0xF75DFF65, - (q31_t)0x804A9C4D, (q31_t)0xF826A461, (q31_t)0x803DAA69, - (q31_t)0xF8EF5CBB, (q31_t)0x8031F3C1, (q31_t)0xF9B82683, - (q31_t)0x80277872, (q31_t)0xFA80FFCB, (q31_t)0x801E3894, - (q31_t)0xFB49E6A2, (q31_t)0x80163440, (q31_t)0xFC12D919, - (q31_t)0x800F6B88, (q31_t)0xFCDBD541, (q31_t)0x8009DE7D, - (q31_t)0xFDA4D928, (q31_t)0x80058D2E, (q31_t)0xFE6DE2E0, - (q31_t)0x800277A5, (q31_t)0xFF36F078, (q31_t)0x80009DE9 -}; + (q31_t)0x7FFFFFFF, (q31_t)0x00000000, (q31_t)0x7FFF6216, (q31_t)0x00C90F88, + (q31_t)0x7FFD885A, (q31_t)0x01921D1F, (q31_t)0x7FFA72D1, (q31_t)0x025B26D7, + (q31_t)0x7FF62182, (q31_t)0x03242ABF, (q31_t)0x7FF09477, (q31_t)0x03ED26E6, + (q31_t)0x7FE9CBC0, (q31_t)0x04B6195D, (q31_t)0x7FE1C76B, (q31_t)0x057F0034, + (q31_t)0x7FD8878D, (q31_t)0x0647D97C, (q31_t)0x7FCE0C3E, (q31_t)0x0710A344, + (q31_t)0x7FC25596, (q31_t)0x07D95B9E, (q31_t)0x7FB563B2, (q31_t)0x08A2009A, + (q31_t)0x7FA736B4, (q31_t)0x096A9049, (q31_t)0x7F97CEBC, (q31_t)0x0A3308BC, + (q31_t)0x7F872BF3, (q31_t)0x0AFB6805, (q31_t)0x7F754E7F, (q31_t)0x0BC3AC35, + (q31_t)0x7F62368F, (q31_t)0x0C8BD35E, (q31_t)0x7F4DE450, (q31_t)0x0D53DB92, + (q31_t)0x7F3857F5, (q31_t)0x0E1BC2E3, (q31_t)0x7F2191B4, (q31_t)0x0EE38765, + (q31_t)0x7F0991C3, (q31_t)0x0FAB272B, (q31_t)0x7EF0585F, (q31_t)0x1072A047, + (q31_t)0x7ED5E5C6, (q31_t)0x1139F0CE, (q31_t)0x7EBA3A39, (q31_t)0x120116D4, + (q31_t)0x7E9D55FC, (q31_t)0x12C8106E, (q31_t)0x7E7F3956, (q31_t)0x138EDBB0, + (q31_t)0x7E5FE493, (q31_t)0x145576B1, (q31_t)0x7E3F57FE, (q31_t)0x151BDF85, + (q31_t)0x7E1D93E9, (q31_t)0x15E21444, (q31_t)0x7DFA98A7, (q31_t)0x16A81305, + (q31_t)0x7DD6668E, (q31_t)0x176DD9DE, (q31_t)0x7DB0FDF7, (q31_t)0x183366E8, + (q31_t)0x7D8A5F3F, (q31_t)0x18F8B83C, (q31_t)0x7D628AC5, (q31_t)0x19BDCBF2, + (q31_t)0x7D3980EC, (q31_t)0x1A82A025, (q31_t)0x7D0F4218, (q31_t)0x1B4732EF, + (q31_t)0x7CE3CEB1, (q31_t)0x1C0B826A, (q31_t)0x7CB72724, (q31_t)0x1CCF8CB3, + (q31_t)0x7C894BDD, (q31_t)0x1D934FE5, (q31_t)0x7C5A3D4F, (q31_t)0x1E56CA1E, + (q31_t)0x7C29FBEE, (q31_t)0x1F19F97B, (q31_t)0x7BF88830, (q31_t)0x1FDCDC1A, + (q31_t)0x7BC5E28F, (q31_t)0x209F701C, (q31_t)0x7B920B89, (q31_t)0x2161B39F, + (q31_t)0x7B5D039D, (q31_t)0x2223A4C5, (q31_t)0x7B26CB4F, (q31_t)0x22E541AE, + (q31_t)0x7AEF6323, (q31_t)0x23A6887E, (q31_t)0x7AB6CBA3, (q31_t)0x24677757, + (q31_t)0x7A7D055B, (q31_t)0x25280C5D, (q31_t)0x7A4210D8, (q31_t)0x25E845B5, + (q31_t)0x7A05EEAD, (q31_t)0x26A82185, (q31_t)0x79C89F6D, (q31_t)0x27679DF4, + (q31_t)0x798A23B1, (q31_t)0x2826B928, (q31_t)0x794A7C11, (q31_t)0x28E5714A, + (q31_t)0x7909A92C, (q31_t)0x29A3C484, (q31_t)0x78C7ABA1, (q31_t)0x2A61B101, + (q31_t)0x78848413, (q31_t)0x2B1F34EB, (q31_t)0x78403328, (q31_t)0x2BDC4E6F, + (q31_t)0x77FAB988, (q31_t)0x2C98FBBA, (q31_t)0x77B417DF, (q31_t)0x2D553AFB, + (q31_t)0x776C4EDB, (q31_t)0x2E110A62, (q31_t)0x77235F2D, (q31_t)0x2ECC681E, + (q31_t)0x76D94988, (q31_t)0x2F875262, (q31_t)0x768E0EA5, (q31_t)0x3041C760, + (q31_t)0x7641AF3C, (q31_t)0x30FBC54D, (q31_t)0x75F42C0A, (q31_t)0x31B54A5D, + (q31_t)0x75A585CF, (q31_t)0x326E54C7, (q31_t)0x7555BD4B, (q31_t)0x3326E2C2, + (q31_t)0x7504D345, (q31_t)0x33DEF287, (q31_t)0x74B2C883, (q31_t)0x3496824F, + (q31_t)0x745F9DD1, (q31_t)0x354D9056, (q31_t)0x740B53FA, (q31_t)0x36041AD9, + (q31_t)0x73B5EBD0, (q31_t)0x36BA2013, (q31_t)0x735F6626, (q31_t)0x376F9E46, + (q31_t)0x7307C3D0, (q31_t)0x382493B0, (q31_t)0x72AF05A6, (q31_t)0x38D8FE93, + (q31_t)0x72552C84, (q31_t)0x398CDD32, (q31_t)0x71FA3948, (q31_t)0x3A402DD1, + (q31_t)0x719E2CD2, (q31_t)0x3AF2EEB7, (q31_t)0x71410804, (q31_t)0x3BA51E29, + (q31_t)0x70E2CBC6, (q31_t)0x3C56BA70, (q31_t)0x708378FE, (q31_t)0x3D07C1D5, + (q31_t)0x70231099, (q31_t)0x3DB832A5, (q31_t)0x6FC19385, (q31_t)0x3E680B2C, + (q31_t)0x6F5F02B1, (q31_t)0x3F1749B7, (q31_t)0x6EFB5F12, (q31_t)0x3FC5EC97, + (q31_t)0x6E96A99C, (q31_t)0x4073F21D, (q31_t)0x6E30E349, (q31_t)0x4121589A, + (q31_t)0x6DCA0D14, (q31_t)0x41CE1E64, (q31_t)0x6D6227FA, (q31_t)0x427A41D0, + (q31_t)0x6CF934FB, (q31_t)0x4325C135, (q31_t)0x6C8F351C, (q31_t)0x43D09AEC, + (q31_t)0x6C242960, (q31_t)0x447ACD50, (q31_t)0x6BB812D0, (q31_t)0x452456BC, + (q31_t)0x6B4AF278, (q31_t)0x45CD358F, (q31_t)0x6ADCC964, (q31_t)0x46756827, + (q31_t)0x6A6D98A4, (q31_t)0x471CECE6, (q31_t)0x69FD614A, (q31_t)0x47C3C22E, + (q31_t)0x698C246C, (q31_t)0x4869E664, (q31_t)0x6919E320, (q31_t)0x490F57EE, + (q31_t)0x68A69E81, (q31_t)0x49B41533, (q31_t)0x683257AA, (q31_t)0x4A581C9D, + (q31_t)0x67BD0FBC, (q31_t)0x4AFB6C97, (q31_t)0x6746C7D7, (q31_t)0x4B9E038F, + (q31_t)0x66CF811F, (q31_t)0x4C3FDFF3, (q31_t)0x66573CBB, (q31_t)0x4CE10034, + (q31_t)0x65DDFBD3, (q31_t)0x4D8162C4, (q31_t)0x6563BF92, (q31_t)0x4E210617, + (q31_t)0x64E88926, (q31_t)0x4EBFE8A4, (q31_t)0x646C59BF, (q31_t)0x4F5E08E3, + (q31_t)0x63EF328F, (q31_t)0x4FFB654D, (q31_t)0x637114CC, (q31_t)0x5097FC5E, + (q31_t)0x62F201AC, (q31_t)0x5133CC94, (q31_t)0x6271FA69, (q31_t)0x51CED46E, + (q31_t)0x61F1003E, (q31_t)0x5269126E, (q31_t)0x616F146B, (q31_t)0x53028517, + (q31_t)0x60EC3830, (q31_t)0x539B2AEF, (q31_t)0x60686CCE, (q31_t)0x5433027D, + (q31_t)0x5FE3B38D, (q31_t)0x54CA0A4A, (q31_t)0x5F5E0DB3, (q31_t)0x556040E2, + (q31_t)0x5ED77C89, (q31_t)0x55F5A4D2, (q31_t)0x5E50015D, (q31_t)0x568A34A9, + (q31_t)0x5DC79D7C, (q31_t)0x571DEEF9, (q31_t)0x5D3E5236, (q31_t)0x57B0D256, + (q31_t)0x5CB420DF, (q31_t)0x5842DD54, (q31_t)0x5C290ACC, (q31_t)0x58D40E8C, + (q31_t)0x5B9D1153, (q31_t)0x59646497, (q31_t)0x5B1035CF, (q31_t)0x59F3DE12, + (q31_t)0x5A82799A, (q31_t)0x5A82799A, (q31_t)0x59F3DE12, (q31_t)0x5B1035CF, + (q31_t)0x59646497, (q31_t)0x5B9D1153, (q31_t)0x58D40E8C, (q31_t)0x5C290ACC, + (q31_t)0x5842DD54, (q31_t)0x5CB420DF, (q31_t)0x57B0D256, (q31_t)0x5D3E5236, + (q31_t)0x571DEEF9, (q31_t)0x5DC79D7C, (q31_t)0x568A34A9, (q31_t)0x5E50015D, + (q31_t)0x55F5A4D2, (q31_t)0x5ED77C89, (q31_t)0x556040E2, (q31_t)0x5F5E0DB3, + (q31_t)0x54CA0A4A, (q31_t)0x5FE3B38D, (q31_t)0x5433027D, (q31_t)0x60686CCE, + (q31_t)0x539B2AEF, (q31_t)0x60EC3830, (q31_t)0x53028517, (q31_t)0x616F146B, + (q31_t)0x5269126E, (q31_t)0x61F1003E, (q31_t)0x51CED46E, (q31_t)0x6271FA69, + (q31_t)0x5133CC94, (q31_t)0x62F201AC, (q31_t)0x5097FC5E, (q31_t)0x637114CC, + (q31_t)0x4FFB654D, (q31_t)0x63EF328F, (q31_t)0x4F5E08E3, (q31_t)0x646C59BF, + (q31_t)0x4EBFE8A4, (q31_t)0x64E88926, (q31_t)0x4E210617, (q31_t)0x6563BF92, + (q31_t)0x4D8162C4, (q31_t)0x65DDFBD3, (q31_t)0x4CE10034, (q31_t)0x66573CBB, + (q31_t)0x4C3FDFF3, (q31_t)0x66CF811F, (q31_t)0x4B9E038F, (q31_t)0x6746C7D7, + (q31_t)0x4AFB6C97, (q31_t)0x67BD0FBC, (q31_t)0x4A581C9D, (q31_t)0x683257AA, + (q31_t)0x49B41533, (q31_t)0x68A69E81, (q31_t)0x490F57EE, (q31_t)0x6919E320, + (q31_t)0x4869E664, (q31_t)0x698C246C, (q31_t)0x47C3C22E, (q31_t)0x69FD614A, + (q31_t)0x471CECE6, (q31_t)0x6A6D98A4, (q31_t)0x46756827, (q31_t)0x6ADCC964, + (q31_t)0x45CD358F, (q31_t)0x6B4AF278, (q31_t)0x452456BC, (q31_t)0x6BB812D0, + (q31_t)0x447ACD50, (q31_t)0x6C242960, (q31_t)0x43D09AEC, (q31_t)0x6C8F351C, + (q31_t)0x4325C135, (q31_t)0x6CF934FB, (q31_t)0x427A41D0, (q31_t)0x6D6227FA, + (q31_t)0x41CE1E64, (q31_t)0x6DCA0D14, (q31_t)0x4121589A, (q31_t)0x6E30E349, + (q31_t)0x4073F21D, (q31_t)0x6E96A99C, (q31_t)0x3FC5EC97, (q31_t)0x6EFB5F12, + (q31_t)0x3F1749B7, (q31_t)0x6F5F02B1, (q31_t)0x3E680B2C, (q31_t)0x6FC19385, + (q31_t)0x3DB832A5, (q31_t)0x70231099, (q31_t)0x3D07C1D5, (q31_t)0x708378FE, + (q31_t)0x3C56BA70, (q31_t)0x70E2CBC6, (q31_t)0x3BA51E29, (q31_t)0x71410804, + (q31_t)0x3AF2EEB7, (q31_t)0x719E2CD2, (q31_t)0x3A402DD1, (q31_t)0x71FA3948, + (q31_t)0x398CDD32, (q31_t)0x72552C84, (q31_t)0x38D8FE93, (q31_t)0x72AF05A6, + (q31_t)0x382493B0, (q31_t)0x7307C3D0, (q31_t)0x376F9E46, (q31_t)0x735F6626, + (q31_t)0x36BA2013, (q31_t)0x73B5EBD0, (q31_t)0x36041AD9, (q31_t)0x740B53FA, + (q31_t)0x354D9056, (q31_t)0x745F9DD1, (q31_t)0x3496824F, (q31_t)0x74B2C883, + (q31_t)0x33DEF287, (q31_t)0x7504D345, (q31_t)0x3326E2C2, (q31_t)0x7555BD4B, + (q31_t)0x326E54C7, (q31_t)0x75A585CF, (q31_t)0x31B54A5D, (q31_t)0x75F42C0A, + (q31_t)0x30FBC54D, (q31_t)0x7641AF3C, (q31_t)0x3041C760, (q31_t)0x768E0EA5, + (q31_t)0x2F875262, (q31_t)0x76D94988, (q31_t)0x2ECC681E, (q31_t)0x77235F2D, + (q31_t)0x2E110A62, (q31_t)0x776C4EDB, (q31_t)0x2D553AFB, (q31_t)0x77B417DF, + (q31_t)0x2C98FBBA, (q31_t)0x77FAB988, (q31_t)0x2BDC4E6F, (q31_t)0x78403328, + (q31_t)0x2B1F34EB, (q31_t)0x78848413, (q31_t)0x2A61B101, (q31_t)0x78C7ABA1, + (q31_t)0x29A3C484, (q31_t)0x7909A92C, (q31_t)0x28E5714A, (q31_t)0x794A7C11, + (q31_t)0x2826B928, (q31_t)0x798A23B1, (q31_t)0x27679DF4, (q31_t)0x79C89F6D, + (q31_t)0x26A82185, (q31_t)0x7A05EEAD, (q31_t)0x25E845B5, (q31_t)0x7A4210D8, + (q31_t)0x25280C5D, (q31_t)0x7A7D055B, (q31_t)0x24677757, (q31_t)0x7AB6CBA3, + (q31_t)0x23A6887E, (q31_t)0x7AEF6323, (q31_t)0x22E541AE, (q31_t)0x7B26CB4F, + (q31_t)0x2223A4C5, (q31_t)0x7B5D039D, (q31_t)0x2161B39F, (q31_t)0x7B920B89, + (q31_t)0x209F701C, (q31_t)0x7BC5E28F, (q31_t)0x1FDCDC1A, (q31_t)0x7BF88830, + (q31_t)0x1F19F97B, (q31_t)0x7C29FBEE, (q31_t)0x1E56CA1E, (q31_t)0x7C5A3D4F, + (q31_t)0x1D934FE5, (q31_t)0x7C894BDD, (q31_t)0x1CCF8CB3, (q31_t)0x7CB72724, + (q31_t)0x1C0B826A, (q31_t)0x7CE3CEB1, (q31_t)0x1B4732EF, (q31_t)0x7D0F4218, + (q31_t)0x1A82A025, (q31_t)0x7D3980EC, (q31_t)0x19BDCBF2, (q31_t)0x7D628AC5, + (q31_t)0x18F8B83C, (q31_t)0x7D8A5F3F, (q31_t)0x183366E8, (q31_t)0x7DB0FDF7, + (q31_t)0x176DD9DE, (q31_t)0x7DD6668E, (q31_t)0x16A81305, (q31_t)0x7DFA98A7, + (q31_t)0x15E21444, (q31_t)0x7E1D93E9, (q31_t)0x151BDF85, (q31_t)0x7E3F57FE, + (q31_t)0x145576B1, (q31_t)0x7E5FE493, (q31_t)0x138EDBB0, (q31_t)0x7E7F3956, + (q31_t)0x12C8106E, (q31_t)0x7E9D55FC, (q31_t)0x120116D4, (q31_t)0x7EBA3A39, + (q31_t)0x1139F0CE, (q31_t)0x7ED5E5C6, (q31_t)0x1072A047, (q31_t)0x7EF0585F, + (q31_t)0x0FAB272B, (q31_t)0x7F0991C3, (q31_t)0x0EE38765, (q31_t)0x7F2191B4, + (q31_t)0x0E1BC2E3, (q31_t)0x7F3857F5, (q31_t)0x0D53DB92, (q31_t)0x7F4DE450, + (q31_t)0x0C8BD35E, (q31_t)0x7F62368F, (q31_t)0x0BC3AC35, (q31_t)0x7F754E7F, + (q31_t)0x0AFB6805, (q31_t)0x7F872BF3, (q31_t)0x0A3308BC, (q31_t)0x7F97CEBC, + (q31_t)0x096A9049, (q31_t)0x7FA736B4, (q31_t)0x08A2009A, (q31_t)0x7FB563B2, + (q31_t)0x07D95B9E, (q31_t)0x7FC25596, (q31_t)0x0710A344, (q31_t)0x7FCE0C3E, + (q31_t)0x0647D97C, (q31_t)0x7FD8878D, (q31_t)0x057F0034, (q31_t)0x7FE1C76B, + (q31_t)0x04B6195D, (q31_t)0x7FE9CBC0, (q31_t)0x03ED26E6, (q31_t)0x7FF09477, + (q31_t)0x03242ABF, (q31_t)0x7FF62182, (q31_t)0x025B26D7, (q31_t)0x7FFA72D1, + (q31_t)0x01921D1F, (q31_t)0x7FFD885A, (q31_t)0x00C90F88, (q31_t)0x7FFF6216, + (q31_t)0x00000000, (q31_t)0x7FFFFFFF, (q31_t)0xFF36F078, (q31_t)0x7FFF6216, + (q31_t)0xFE6DE2E0, (q31_t)0x7FFD885A, (q31_t)0xFDA4D928, (q31_t)0x7FFA72D1, + (q31_t)0xFCDBD541, (q31_t)0x7FF62182, (q31_t)0xFC12D919, (q31_t)0x7FF09477, + (q31_t)0xFB49E6A2, (q31_t)0x7FE9CBC0, (q31_t)0xFA80FFCB, (q31_t)0x7FE1C76B, + (q31_t)0xF9B82683, (q31_t)0x7FD8878D, (q31_t)0xF8EF5CBB, (q31_t)0x7FCE0C3E, + (q31_t)0xF826A461, (q31_t)0x7FC25596, (q31_t)0xF75DFF65, (q31_t)0x7FB563B2, + (q31_t)0xF6956FB6, (q31_t)0x7FA736B4, (q31_t)0xF5CCF743, (q31_t)0x7F97CEBC, + (q31_t)0xF50497FA, (q31_t)0x7F872BF3, (q31_t)0xF43C53CA, (q31_t)0x7F754E7F, + (q31_t)0xF3742CA1, (q31_t)0x7F62368F, (q31_t)0xF2AC246D, (q31_t)0x7F4DE450, + (q31_t)0xF1E43D1C, (q31_t)0x7F3857F5, (q31_t)0xF11C789A, (q31_t)0x7F2191B4, + (q31_t)0xF054D8D4, (q31_t)0x7F0991C3, (q31_t)0xEF8D5FB8, (q31_t)0x7EF0585F, + (q31_t)0xEEC60F31, (q31_t)0x7ED5E5C6, (q31_t)0xEDFEE92B, (q31_t)0x7EBA3A39, + (q31_t)0xED37EF91, (q31_t)0x7E9D55FC, (q31_t)0xEC71244F, (q31_t)0x7E7F3956, + (q31_t)0xEBAA894E, (q31_t)0x7E5FE493, (q31_t)0xEAE4207A, (q31_t)0x7E3F57FE, + (q31_t)0xEA1DEBBB, (q31_t)0x7E1D93E9, (q31_t)0xE957ECFB, (q31_t)0x7DFA98A7, + (q31_t)0xE8922621, (q31_t)0x7DD6668E, (q31_t)0xE7CC9917, (q31_t)0x7DB0FDF7, + (q31_t)0xE70747C3, (q31_t)0x7D8A5F3F, (q31_t)0xE642340D, (q31_t)0x7D628AC5, + (q31_t)0xE57D5FDA, (q31_t)0x7D3980EC, (q31_t)0xE4B8CD10, (q31_t)0x7D0F4218, + (q31_t)0xE3F47D95, (q31_t)0x7CE3CEB1, (q31_t)0xE330734C, (q31_t)0x7CB72724, + (q31_t)0xE26CB01A, (q31_t)0x7C894BDD, (q31_t)0xE1A935E1, (q31_t)0x7C5A3D4F, + (q31_t)0xE0E60684, (q31_t)0x7C29FBEE, (q31_t)0xE02323E5, (q31_t)0x7BF88830, + (q31_t)0xDF608FE3, (q31_t)0x7BC5E28F, (q31_t)0xDE9E4C60, (q31_t)0x7B920B89, + (q31_t)0xDDDC5B3A, (q31_t)0x7B5D039D, (q31_t)0xDD1ABE51, (q31_t)0x7B26CB4F, + (q31_t)0xDC597781, (q31_t)0x7AEF6323, (q31_t)0xDB9888A8, (q31_t)0x7AB6CBA3, + (q31_t)0xDAD7F3A2, (q31_t)0x7A7D055B, (q31_t)0xDA17BA4A, (q31_t)0x7A4210D8, + (q31_t)0xD957DE7A, (q31_t)0x7A05EEAD, (q31_t)0xD898620C, (q31_t)0x79C89F6D, + (q31_t)0xD7D946D7, (q31_t)0x798A23B1, (q31_t)0xD71A8EB5, (q31_t)0x794A7C11, + (q31_t)0xD65C3B7B, (q31_t)0x7909A92C, (q31_t)0xD59E4EFE, (q31_t)0x78C7ABA1, + (q31_t)0xD4E0CB14, (q31_t)0x78848413, (q31_t)0xD423B190, (q31_t)0x78403328, + (q31_t)0xD3670445, (q31_t)0x77FAB988, (q31_t)0xD2AAC504, (q31_t)0x77B417DF, + (q31_t)0xD1EEF59E, (q31_t)0x776C4EDB, (q31_t)0xD13397E1, (q31_t)0x77235F2D, + (q31_t)0xD078AD9D, (q31_t)0x76D94988, (q31_t)0xCFBE389F, (q31_t)0x768E0EA5, + (q31_t)0xCF043AB2, (q31_t)0x7641AF3C, (q31_t)0xCE4AB5A2, (q31_t)0x75F42C0A, + (q31_t)0xCD91AB38, (q31_t)0x75A585CF, (q31_t)0xCCD91D3D, (q31_t)0x7555BD4B, + (q31_t)0xCC210D78, (q31_t)0x7504D345, (q31_t)0xCB697DB0, (q31_t)0x74B2C883, + (q31_t)0xCAB26FA9, (q31_t)0x745F9DD1, (q31_t)0xC9FBE527, (q31_t)0x740B53FA, + (q31_t)0xC945DFEC, (q31_t)0x73B5EBD0, (q31_t)0xC89061BA, (q31_t)0x735F6626, + (q31_t)0xC7DB6C50, (q31_t)0x7307C3D0, (q31_t)0xC727016C, (q31_t)0x72AF05A6, + (q31_t)0xC67322CD, (q31_t)0x72552C84, (q31_t)0xC5BFD22E, (q31_t)0x71FA3948, + (q31_t)0xC50D1148, (q31_t)0x719E2CD2, (q31_t)0xC45AE1D7, (q31_t)0x71410804, + (q31_t)0xC3A9458F, (q31_t)0x70E2CBC6, (q31_t)0xC2F83E2A, (q31_t)0x708378FE, + (q31_t)0xC247CD5A, (q31_t)0x70231099, (q31_t)0xC197F4D3, (q31_t)0x6FC19385, + (q31_t)0xC0E8B648, (q31_t)0x6F5F02B1, (q31_t)0xC03A1368, (q31_t)0x6EFB5F12, + (q31_t)0xBF8C0DE2, (q31_t)0x6E96A99C, (q31_t)0xBEDEA765, (q31_t)0x6E30E349, + (q31_t)0xBE31E19B, (q31_t)0x6DCA0D14, (q31_t)0xBD85BE2F, (q31_t)0x6D6227FA, + (q31_t)0xBCDA3ECA, (q31_t)0x6CF934FB, (q31_t)0xBC2F6513, (q31_t)0x6C8F351C, + (q31_t)0xBB8532AF, (q31_t)0x6C242960, (q31_t)0xBADBA943, (q31_t)0x6BB812D0, + (q31_t)0xBA32CA70, (q31_t)0x6B4AF278, (q31_t)0xB98A97D8, (q31_t)0x6ADCC964, + (q31_t)0xB8E31319, (q31_t)0x6A6D98A4, (q31_t)0xB83C3DD1, (q31_t)0x69FD614A, + (q31_t)0xB796199B, (q31_t)0x698C246C, (q31_t)0xB6F0A811, (q31_t)0x6919E320, + (q31_t)0xB64BEACC, (q31_t)0x68A69E81, (q31_t)0xB5A7E362, (q31_t)0x683257AA, + (q31_t)0xB5049368, (q31_t)0x67BD0FBC, (q31_t)0xB461FC70, (q31_t)0x6746C7D7, + (q31_t)0xB3C0200C, (q31_t)0x66CF811F, (q31_t)0xB31EFFCB, (q31_t)0x66573CBB, + (q31_t)0xB27E9D3B, (q31_t)0x65DDFBD3, (q31_t)0xB1DEF9E8, (q31_t)0x6563BF92, + (q31_t)0xB140175B, (q31_t)0x64E88926, (q31_t)0xB0A1F71C, (q31_t)0x646C59BF, + (q31_t)0xB0049AB2, (q31_t)0x63EF328F, (q31_t)0xAF6803A1, (q31_t)0x637114CC, + (q31_t)0xAECC336B, (q31_t)0x62F201AC, (q31_t)0xAE312B91, (q31_t)0x6271FA69, + (q31_t)0xAD96ED91, (q31_t)0x61F1003E, (q31_t)0xACFD7AE8, (q31_t)0x616F146B, + (q31_t)0xAC64D510, (q31_t)0x60EC3830, (q31_t)0xABCCFD82, (q31_t)0x60686CCE, + (q31_t)0xAB35F5B5, (q31_t)0x5FE3B38D, (q31_t)0xAA9FBF1D, (q31_t)0x5F5E0DB3, + (q31_t)0xAA0A5B2D, (q31_t)0x5ED77C89, (q31_t)0xA975CB56, (q31_t)0x5E50015D, + (q31_t)0xA8E21106, (q31_t)0x5DC79D7C, (q31_t)0xA84F2DA9, (q31_t)0x5D3E5236, + (q31_t)0xA7BD22AB, (q31_t)0x5CB420DF, (q31_t)0xA72BF173, (q31_t)0x5C290ACC, + (q31_t)0xA69B9B68, (q31_t)0x5B9D1153, (q31_t)0xA60C21ED, (q31_t)0x5B1035CF, + (q31_t)0xA57D8666, (q31_t)0x5A82799A, (q31_t)0xA4EFCA31, (q31_t)0x59F3DE12, + (q31_t)0xA462EEAC, (q31_t)0x59646497, (q31_t)0xA3D6F533, (q31_t)0x58D40E8C, + (q31_t)0xA34BDF20, (q31_t)0x5842DD54, (q31_t)0xA2C1ADC9, (q31_t)0x57B0D256, + (q31_t)0xA2386283, (q31_t)0x571DEEF9, (q31_t)0xA1AFFEA2, (q31_t)0x568A34A9, + (q31_t)0xA1288376, (q31_t)0x55F5A4D2, (q31_t)0xA0A1F24C, (q31_t)0x556040E2, + (q31_t)0xA01C4C72, (q31_t)0x54CA0A4A, (q31_t)0x9F979331, (q31_t)0x5433027D, + (q31_t)0x9F13C7D0, (q31_t)0x539B2AEF, (q31_t)0x9E90EB94, (q31_t)0x53028517, + (q31_t)0x9E0EFFC1, (q31_t)0x5269126E, (q31_t)0x9D8E0596, (q31_t)0x51CED46E, + (q31_t)0x9D0DFE53, (q31_t)0x5133CC94, (q31_t)0x9C8EEB33, (q31_t)0x5097FC5E, + (q31_t)0x9C10CD70, (q31_t)0x4FFB654D, (q31_t)0x9B93A640, (q31_t)0x4F5E08E3, + (q31_t)0x9B1776D9, (q31_t)0x4EBFE8A4, (q31_t)0x9A9C406D, (q31_t)0x4E210617, + (q31_t)0x9A22042C, (q31_t)0x4D8162C4, (q31_t)0x99A8C344, (q31_t)0x4CE10034, + (q31_t)0x99307EE0, (q31_t)0x4C3FDFF3, (q31_t)0x98B93828, (q31_t)0x4B9E038F, + (q31_t)0x9842F043, (q31_t)0x4AFB6C97, (q31_t)0x97CDA855, (q31_t)0x4A581C9D, + (q31_t)0x9759617E, (q31_t)0x49B41533, (q31_t)0x96E61CDF, (q31_t)0x490F57EE, + (q31_t)0x9673DB94, (q31_t)0x4869E664, (q31_t)0x96029EB5, (q31_t)0x47C3C22E, + (q31_t)0x9592675B, (q31_t)0x471CECE6, (q31_t)0x9523369B, (q31_t)0x46756827, + (q31_t)0x94B50D87, (q31_t)0x45CD358F, (q31_t)0x9447ED2F, (q31_t)0x452456BC, + (q31_t)0x93DBD69F, (q31_t)0x447ACD50, (q31_t)0x9370CAE4, (q31_t)0x43D09AEC, + (q31_t)0x9306CB04, (q31_t)0x4325C135, (q31_t)0x929DD805, (q31_t)0x427A41D0, + (q31_t)0x9235F2EB, (q31_t)0x41CE1E64, (q31_t)0x91CF1CB6, (q31_t)0x4121589A, + (q31_t)0x91695663, (q31_t)0x4073F21D, (q31_t)0x9104A0ED, (q31_t)0x3FC5EC97, + (q31_t)0x90A0FD4E, (q31_t)0x3F1749B7, (q31_t)0x903E6C7A, (q31_t)0x3E680B2C, + (q31_t)0x8FDCEF66, (q31_t)0x3DB832A5, (q31_t)0x8F7C8701, (q31_t)0x3D07C1D5, + (q31_t)0x8F1D343A, (q31_t)0x3C56BA70, (q31_t)0x8EBEF7FB, (q31_t)0x3BA51E29, + (q31_t)0x8E61D32D, (q31_t)0x3AF2EEB7, (q31_t)0x8E05C6B7, (q31_t)0x3A402DD1, + (q31_t)0x8DAAD37B, (q31_t)0x398CDD32, (q31_t)0x8D50FA59, (q31_t)0x38D8FE93, + (q31_t)0x8CF83C30, (q31_t)0x382493B0, (q31_t)0x8CA099D9, (q31_t)0x376F9E46, + (q31_t)0x8C4A142F, (q31_t)0x36BA2013, (q31_t)0x8BF4AC05, (q31_t)0x36041AD9, + (q31_t)0x8BA0622F, (q31_t)0x354D9056, (q31_t)0x8B4D377C, (q31_t)0x3496824F, + (q31_t)0x8AFB2CBA, (q31_t)0x33DEF287, (q31_t)0x8AAA42B4, (q31_t)0x3326E2C2, + (q31_t)0x8A5A7A30, (q31_t)0x326E54C7, (q31_t)0x8A0BD3F5, (q31_t)0x31B54A5D, + (q31_t)0x89BE50C3, (q31_t)0x30FBC54D, (q31_t)0x8971F15A, (q31_t)0x3041C760, + (q31_t)0x8926B677, (q31_t)0x2F875262, (q31_t)0x88DCA0D3, (q31_t)0x2ECC681E, + (q31_t)0x8893B124, (q31_t)0x2E110A62, (q31_t)0x884BE820, (q31_t)0x2D553AFB, + (q31_t)0x88054677, (q31_t)0x2C98FBBA, (q31_t)0x87BFCCD7, (q31_t)0x2BDC4E6F, + (q31_t)0x877B7BEC, (q31_t)0x2B1F34EB, (q31_t)0x8738545E, (q31_t)0x2A61B101, + (q31_t)0x86F656D3, (q31_t)0x29A3C484, (q31_t)0x86B583EE, (q31_t)0x28E5714A, + (q31_t)0x8675DC4E, (q31_t)0x2826B928, (q31_t)0x86376092, (q31_t)0x27679DF4, + (q31_t)0x85FA1152, (q31_t)0x26A82185, (q31_t)0x85BDEF27, (q31_t)0x25E845B5, + (q31_t)0x8582FAA4, (q31_t)0x25280C5D, (q31_t)0x8549345C, (q31_t)0x24677757, + (q31_t)0x85109CDC, (q31_t)0x23A6887E, (q31_t)0x84D934B0, (q31_t)0x22E541AE, + (q31_t)0x84A2FC62, (q31_t)0x2223A4C5, (q31_t)0x846DF476, (q31_t)0x2161B39F, + (q31_t)0x843A1D70, (q31_t)0x209F701C, (q31_t)0x840777CF, (q31_t)0x1FDCDC1A, + (q31_t)0x83D60411, (q31_t)0x1F19F97B, (q31_t)0x83A5C2B0, (q31_t)0x1E56CA1E, + (q31_t)0x8376B422, (q31_t)0x1D934FE5, (q31_t)0x8348D8DB, (q31_t)0x1CCF8CB3, + (q31_t)0x831C314E, (q31_t)0x1C0B826A, (q31_t)0x82F0BDE8, (q31_t)0x1B4732EF, + (q31_t)0x82C67F13, (q31_t)0x1A82A025, (q31_t)0x829D753A, (q31_t)0x19BDCBF2, + (q31_t)0x8275A0C0, (q31_t)0x18F8B83C, (q31_t)0x824F0208, (q31_t)0x183366E8, + (q31_t)0x82299971, (q31_t)0x176DD9DE, (q31_t)0x82056758, (q31_t)0x16A81305, + (q31_t)0x81E26C16, (q31_t)0x15E21444, (q31_t)0x81C0A801, (q31_t)0x151BDF85, + (q31_t)0x81A01B6C, (q31_t)0x145576B1, (q31_t)0x8180C6A9, (q31_t)0x138EDBB0, + (q31_t)0x8162AA03, (q31_t)0x12C8106E, (q31_t)0x8145C5C6, (q31_t)0x120116D4, + (q31_t)0x812A1A39, (q31_t)0x1139F0CE, (q31_t)0x810FA7A0, (q31_t)0x1072A047, + (q31_t)0x80F66E3C, (q31_t)0x0FAB272B, (q31_t)0x80DE6E4C, (q31_t)0x0EE38765, + (q31_t)0x80C7A80A, (q31_t)0x0E1BC2E3, (q31_t)0x80B21BAF, (q31_t)0x0D53DB92, + (q31_t)0x809DC970, (q31_t)0x0C8BD35E, (q31_t)0x808AB180, (q31_t)0x0BC3AC35, + (q31_t)0x8078D40D, (q31_t)0x0AFB6805, (q31_t)0x80683143, (q31_t)0x0A3308BC, + (q31_t)0x8058C94C, (q31_t)0x096A9049, (q31_t)0x804A9C4D, (q31_t)0x08A2009A, + (q31_t)0x803DAA69, (q31_t)0x07D95B9E, (q31_t)0x8031F3C1, (q31_t)0x0710A344, + (q31_t)0x80277872, (q31_t)0x0647D97C, (q31_t)0x801E3894, (q31_t)0x057F0034, + (q31_t)0x80163440, (q31_t)0x04B6195D, (q31_t)0x800F6B88, (q31_t)0x03ED26E6, + (q31_t)0x8009DE7D, (q31_t)0x03242ABF, (q31_t)0x80058D2E, (q31_t)0x025B26D7, + (q31_t)0x800277A5, (q31_t)0x01921D1F, (q31_t)0x80009DE9, (q31_t)0x00C90F88, + (q31_t)0x80000000, (q31_t)0x00000000, (q31_t)0x80009DE9, (q31_t)0xFF36F078, + (q31_t)0x800277A5, (q31_t)0xFE6DE2E0, (q31_t)0x80058D2E, (q31_t)0xFDA4D928, + (q31_t)0x8009DE7D, (q31_t)0xFCDBD541, (q31_t)0x800F6B88, (q31_t)0xFC12D919, + (q31_t)0x80163440, (q31_t)0xFB49E6A2, (q31_t)0x801E3894, (q31_t)0xFA80FFCB, + (q31_t)0x80277872, (q31_t)0xF9B82683, (q31_t)0x8031F3C1, (q31_t)0xF8EF5CBB, + (q31_t)0x803DAA69, (q31_t)0xF826A461, (q31_t)0x804A9C4D, (q31_t)0xF75DFF65, + (q31_t)0x8058C94C, (q31_t)0xF6956FB6, (q31_t)0x80683143, (q31_t)0xF5CCF743, + (q31_t)0x8078D40D, (q31_t)0xF50497FA, (q31_t)0x808AB180, (q31_t)0xF43C53CA, + (q31_t)0x809DC970, (q31_t)0xF3742CA1, (q31_t)0x80B21BAF, (q31_t)0xF2AC246D, + (q31_t)0x80C7A80A, (q31_t)0xF1E43D1C, (q31_t)0x80DE6E4C, (q31_t)0xF11C789A, + (q31_t)0x80F66E3C, (q31_t)0xF054D8D4, (q31_t)0x810FA7A0, (q31_t)0xEF8D5FB8, + (q31_t)0x812A1A39, (q31_t)0xEEC60F31, (q31_t)0x8145C5C6, (q31_t)0xEDFEE92B, + (q31_t)0x8162AA03, (q31_t)0xED37EF91, (q31_t)0x8180C6A9, (q31_t)0xEC71244F, + (q31_t)0x81A01B6C, (q31_t)0xEBAA894E, (q31_t)0x81C0A801, (q31_t)0xEAE4207A, + (q31_t)0x81E26C16, (q31_t)0xEA1DEBBB, (q31_t)0x82056758, (q31_t)0xE957ECFB, + (q31_t)0x82299971, (q31_t)0xE8922621, (q31_t)0x824F0208, (q31_t)0xE7CC9917, + (q31_t)0x8275A0C0, (q31_t)0xE70747C3, (q31_t)0x829D753A, (q31_t)0xE642340D, + (q31_t)0x82C67F13, (q31_t)0xE57D5FDA, (q31_t)0x82F0BDE8, (q31_t)0xE4B8CD10, + (q31_t)0x831C314E, (q31_t)0xE3F47D95, (q31_t)0x8348D8DB, (q31_t)0xE330734C, + (q31_t)0x8376B422, (q31_t)0xE26CB01A, (q31_t)0x83A5C2B0, (q31_t)0xE1A935E1, + (q31_t)0x83D60411, (q31_t)0xE0E60684, (q31_t)0x840777CF, (q31_t)0xE02323E5, + (q31_t)0x843A1D70, (q31_t)0xDF608FE3, (q31_t)0x846DF476, (q31_t)0xDE9E4C60, + (q31_t)0x84A2FC62, (q31_t)0xDDDC5B3A, (q31_t)0x84D934B0, (q31_t)0xDD1ABE51, + (q31_t)0x85109CDC, (q31_t)0xDC597781, (q31_t)0x8549345C, (q31_t)0xDB9888A8, + (q31_t)0x8582FAA4, (q31_t)0xDAD7F3A2, (q31_t)0x85BDEF27, (q31_t)0xDA17BA4A, + (q31_t)0x85FA1152, (q31_t)0xD957DE7A, (q31_t)0x86376092, (q31_t)0xD898620C, + (q31_t)0x8675DC4E, (q31_t)0xD7D946D7, (q31_t)0x86B583EE, (q31_t)0xD71A8EB5, + (q31_t)0x86F656D3, (q31_t)0xD65C3B7B, (q31_t)0x8738545E, (q31_t)0xD59E4EFE, + (q31_t)0x877B7BEC, (q31_t)0xD4E0CB14, (q31_t)0x87BFCCD7, (q31_t)0xD423B190, + (q31_t)0x88054677, (q31_t)0xD3670445, (q31_t)0x884BE820, (q31_t)0xD2AAC504, + (q31_t)0x8893B124, (q31_t)0xD1EEF59E, (q31_t)0x88DCA0D3, (q31_t)0xD13397E1, + (q31_t)0x8926B677, (q31_t)0xD078AD9D, (q31_t)0x8971F15A, (q31_t)0xCFBE389F, + (q31_t)0x89BE50C3, (q31_t)0xCF043AB2, (q31_t)0x8A0BD3F5, (q31_t)0xCE4AB5A2, + (q31_t)0x8A5A7A30, (q31_t)0xCD91AB38, (q31_t)0x8AAA42B4, (q31_t)0xCCD91D3D, + (q31_t)0x8AFB2CBA, (q31_t)0xCC210D78, (q31_t)0x8B4D377C, (q31_t)0xCB697DB0, + (q31_t)0x8BA0622F, (q31_t)0xCAB26FA9, (q31_t)0x8BF4AC05, (q31_t)0xC9FBE527, + (q31_t)0x8C4A142F, (q31_t)0xC945DFEC, (q31_t)0x8CA099D9, (q31_t)0xC89061BA, + (q31_t)0x8CF83C30, (q31_t)0xC7DB6C50, (q31_t)0x8D50FA59, (q31_t)0xC727016C, + (q31_t)0x8DAAD37B, (q31_t)0xC67322CD, (q31_t)0x8E05C6B7, (q31_t)0xC5BFD22E, + (q31_t)0x8E61D32D, (q31_t)0xC50D1148, (q31_t)0x8EBEF7FB, (q31_t)0xC45AE1D7, + (q31_t)0x8F1D343A, (q31_t)0xC3A9458F, (q31_t)0x8F7C8701, (q31_t)0xC2F83E2A, + (q31_t)0x8FDCEF66, (q31_t)0xC247CD5A, (q31_t)0x903E6C7A, (q31_t)0xC197F4D3, + (q31_t)0x90A0FD4E, (q31_t)0xC0E8B648, (q31_t)0x9104A0ED, (q31_t)0xC03A1368, + (q31_t)0x91695663, (q31_t)0xBF8C0DE2, (q31_t)0x91CF1CB6, (q31_t)0xBEDEA765, + (q31_t)0x9235F2EB, (q31_t)0xBE31E19B, (q31_t)0x929DD805, (q31_t)0xBD85BE2F, + (q31_t)0x9306CB04, (q31_t)0xBCDA3ECA, (q31_t)0x9370CAE4, (q31_t)0xBC2F6513, + (q31_t)0x93DBD69F, (q31_t)0xBB8532AF, (q31_t)0x9447ED2F, (q31_t)0xBADBA943, + (q31_t)0x94B50D87, (q31_t)0xBA32CA70, (q31_t)0x9523369B, (q31_t)0xB98A97D8, + (q31_t)0x9592675B, (q31_t)0xB8E31319, (q31_t)0x96029EB5, (q31_t)0xB83C3DD1, + (q31_t)0x9673DB94, (q31_t)0xB796199B, (q31_t)0x96E61CDF, (q31_t)0xB6F0A811, + (q31_t)0x9759617E, (q31_t)0xB64BEACC, (q31_t)0x97CDA855, (q31_t)0xB5A7E362, + (q31_t)0x9842F043, (q31_t)0xB5049368, (q31_t)0x98B93828, (q31_t)0xB461FC70, + (q31_t)0x99307EE0, (q31_t)0xB3C0200C, (q31_t)0x99A8C344, (q31_t)0xB31EFFCB, + (q31_t)0x9A22042C, (q31_t)0xB27E9D3B, (q31_t)0x9A9C406D, (q31_t)0xB1DEF9E8, + (q31_t)0x9B1776D9, (q31_t)0xB140175B, (q31_t)0x9B93A640, (q31_t)0xB0A1F71C, + (q31_t)0x9C10CD70, (q31_t)0xB0049AB2, (q31_t)0x9C8EEB33, (q31_t)0xAF6803A1, + (q31_t)0x9D0DFE53, (q31_t)0xAECC336B, (q31_t)0x9D8E0596, (q31_t)0xAE312B91, + (q31_t)0x9E0EFFC1, (q31_t)0xAD96ED91, (q31_t)0x9E90EB94, (q31_t)0xACFD7AE8, + (q31_t)0x9F13C7D0, (q31_t)0xAC64D510, (q31_t)0x9F979331, (q31_t)0xABCCFD82, + (q31_t)0xA01C4C72, (q31_t)0xAB35F5B5, (q31_t)0xA0A1F24C, (q31_t)0xAA9FBF1D, + (q31_t)0xA1288376, (q31_t)0xAA0A5B2D, (q31_t)0xA1AFFEA2, (q31_t)0xA975CB56, + (q31_t)0xA2386283, (q31_t)0xA8E21106, (q31_t)0xA2C1ADC9, (q31_t)0xA84F2DA9, + (q31_t)0xA34BDF20, (q31_t)0xA7BD22AB, (q31_t)0xA3D6F533, (q31_t)0xA72BF173, + (q31_t)0xA462EEAC, (q31_t)0xA69B9B68, (q31_t)0xA4EFCA31, (q31_t)0xA60C21ED, + (q31_t)0xA57D8666, (q31_t)0xA57D8666, (q31_t)0xA60C21ED, (q31_t)0xA4EFCA31, + (q31_t)0xA69B9B68, (q31_t)0xA462EEAC, (q31_t)0xA72BF173, (q31_t)0xA3D6F533, + (q31_t)0xA7BD22AB, (q31_t)0xA34BDF20, (q31_t)0xA84F2DA9, (q31_t)0xA2C1ADC9, + (q31_t)0xA8E21106, (q31_t)0xA2386283, (q31_t)0xA975CB56, (q31_t)0xA1AFFEA2, + (q31_t)0xAA0A5B2D, (q31_t)0xA1288376, (q31_t)0xAA9FBF1D, (q31_t)0xA0A1F24C, + (q31_t)0xAB35F5B5, (q31_t)0xA01C4C72, (q31_t)0xABCCFD82, (q31_t)0x9F979331, + (q31_t)0xAC64D510, (q31_t)0x9F13C7D0, (q31_t)0xACFD7AE8, (q31_t)0x9E90EB94, + (q31_t)0xAD96ED91, (q31_t)0x9E0EFFC1, (q31_t)0xAE312B91, (q31_t)0x9D8E0596, + (q31_t)0xAECC336B, (q31_t)0x9D0DFE53, (q31_t)0xAF6803A1, (q31_t)0x9C8EEB33, + (q31_t)0xB0049AB2, (q31_t)0x9C10CD70, (q31_t)0xB0A1F71C, (q31_t)0x9B93A640, + (q31_t)0xB140175B, (q31_t)0x9B1776D9, (q31_t)0xB1DEF9E8, (q31_t)0x9A9C406D, + (q31_t)0xB27E9D3B, (q31_t)0x9A22042C, (q31_t)0xB31EFFCB, (q31_t)0x99A8C344, + (q31_t)0xB3C0200C, (q31_t)0x99307EE0, (q31_t)0xB461FC70, (q31_t)0x98B93828, + (q31_t)0xB5049368, (q31_t)0x9842F043, (q31_t)0xB5A7E362, (q31_t)0x97CDA855, + (q31_t)0xB64BEACC, (q31_t)0x9759617E, (q31_t)0xB6F0A811, (q31_t)0x96E61CDF, + (q31_t)0xB796199B, (q31_t)0x9673DB94, (q31_t)0xB83C3DD1, (q31_t)0x96029EB5, + (q31_t)0xB8E31319, (q31_t)0x9592675B, (q31_t)0xB98A97D8, (q31_t)0x9523369B, + (q31_t)0xBA32CA70, (q31_t)0x94B50D87, (q31_t)0xBADBA943, (q31_t)0x9447ED2F, + (q31_t)0xBB8532AF, (q31_t)0x93DBD69F, (q31_t)0xBC2F6513, (q31_t)0x9370CAE4, + (q31_t)0xBCDA3ECA, (q31_t)0x9306CB04, (q31_t)0xBD85BE2F, (q31_t)0x929DD805, + (q31_t)0xBE31E19B, (q31_t)0x9235F2EB, (q31_t)0xBEDEA765, (q31_t)0x91CF1CB6, + (q31_t)0xBF8C0DE2, (q31_t)0x91695663, (q31_t)0xC03A1368, (q31_t)0x9104A0ED, + (q31_t)0xC0E8B648, (q31_t)0x90A0FD4E, (q31_t)0xC197F4D3, (q31_t)0x903E6C7A, + (q31_t)0xC247CD5A, (q31_t)0x8FDCEF66, (q31_t)0xC2F83E2A, (q31_t)0x8F7C8701, + (q31_t)0xC3A9458F, (q31_t)0x8F1D343A, (q31_t)0xC45AE1D7, (q31_t)0x8EBEF7FB, + (q31_t)0xC50D1148, (q31_t)0x8E61D32D, (q31_t)0xC5BFD22E, (q31_t)0x8E05C6B7, + (q31_t)0xC67322CD, (q31_t)0x8DAAD37B, (q31_t)0xC727016C, (q31_t)0x8D50FA59, + (q31_t)0xC7DB6C50, (q31_t)0x8CF83C30, (q31_t)0xC89061BA, (q31_t)0x8CA099D9, + (q31_t)0xC945DFEC, (q31_t)0x8C4A142F, (q31_t)0xC9FBE527, (q31_t)0x8BF4AC05, + (q31_t)0xCAB26FA9, (q31_t)0x8BA0622F, (q31_t)0xCB697DB0, (q31_t)0x8B4D377C, + (q31_t)0xCC210D78, (q31_t)0x8AFB2CBA, (q31_t)0xCCD91D3D, (q31_t)0x8AAA42B4, + (q31_t)0xCD91AB38, (q31_t)0x8A5A7A30, (q31_t)0xCE4AB5A2, (q31_t)0x8A0BD3F5, + (q31_t)0xCF043AB2, (q31_t)0x89BE50C3, (q31_t)0xCFBE389F, (q31_t)0x8971F15A, + (q31_t)0xD078AD9D, (q31_t)0x8926B677, (q31_t)0xD13397E1, (q31_t)0x88DCA0D3, + (q31_t)0xD1EEF59E, (q31_t)0x8893B124, (q31_t)0xD2AAC504, (q31_t)0x884BE820, + (q31_t)0xD3670445, (q31_t)0x88054677, (q31_t)0xD423B190, (q31_t)0x87BFCCD7, + (q31_t)0xD4E0CB14, (q31_t)0x877B7BEC, (q31_t)0xD59E4EFE, (q31_t)0x8738545E, + (q31_t)0xD65C3B7B, (q31_t)0x86F656D3, (q31_t)0xD71A8EB5, (q31_t)0x86B583EE, + (q31_t)0xD7D946D7, (q31_t)0x8675DC4E, (q31_t)0xD898620C, (q31_t)0x86376092, + (q31_t)0xD957DE7A, (q31_t)0x85FA1152, (q31_t)0xDA17BA4A, (q31_t)0x85BDEF27, + (q31_t)0xDAD7F3A2, (q31_t)0x8582FAA4, (q31_t)0xDB9888A8, (q31_t)0x8549345C, + (q31_t)0xDC597781, (q31_t)0x85109CDC, (q31_t)0xDD1ABE51, (q31_t)0x84D934B0, + (q31_t)0xDDDC5B3A, (q31_t)0x84A2FC62, (q31_t)0xDE9E4C60, (q31_t)0x846DF476, + (q31_t)0xDF608FE3, (q31_t)0x843A1D70, (q31_t)0xE02323E5, (q31_t)0x840777CF, + (q31_t)0xE0E60684, (q31_t)0x83D60411, (q31_t)0xE1A935E1, (q31_t)0x83A5C2B0, + (q31_t)0xE26CB01A, (q31_t)0x8376B422, (q31_t)0xE330734C, (q31_t)0x8348D8DB, + (q31_t)0xE3F47D95, (q31_t)0x831C314E, (q31_t)0xE4B8CD10, (q31_t)0x82F0BDE8, + (q31_t)0xE57D5FDA, (q31_t)0x82C67F13, (q31_t)0xE642340D, (q31_t)0x829D753A, + (q31_t)0xE70747C3, (q31_t)0x8275A0C0, (q31_t)0xE7CC9917, (q31_t)0x824F0208, + (q31_t)0xE8922621, (q31_t)0x82299971, (q31_t)0xE957ECFB, (q31_t)0x82056758, + (q31_t)0xEA1DEBBB, (q31_t)0x81E26C16, (q31_t)0xEAE4207A, (q31_t)0x81C0A801, + (q31_t)0xEBAA894E, (q31_t)0x81A01B6C, (q31_t)0xEC71244F, (q31_t)0x8180C6A9, + (q31_t)0xED37EF91, (q31_t)0x8162AA03, (q31_t)0xEDFEE92B, (q31_t)0x8145C5C6, + (q31_t)0xEEC60F31, (q31_t)0x812A1A39, (q31_t)0xEF8D5FB8, (q31_t)0x810FA7A0, + (q31_t)0xF054D8D4, (q31_t)0x80F66E3C, (q31_t)0xF11C789A, (q31_t)0x80DE6E4C, + (q31_t)0xF1E43D1C, (q31_t)0x80C7A80A, (q31_t)0xF2AC246D, (q31_t)0x80B21BAF, + (q31_t)0xF3742CA1, (q31_t)0x809DC970, (q31_t)0xF43C53CA, (q31_t)0x808AB180, + (q31_t)0xF50497FA, (q31_t)0x8078D40D, (q31_t)0xF5CCF743, (q31_t)0x80683143, + (q31_t)0xF6956FB6, (q31_t)0x8058C94C, (q31_t)0xF75DFF65, (q31_t)0x804A9C4D, + (q31_t)0xF826A461, (q31_t)0x803DAA69, (q31_t)0xF8EF5CBB, (q31_t)0x8031F3C1, + (q31_t)0xF9B82683, (q31_t)0x80277872, (q31_t)0xFA80FFCB, (q31_t)0x801E3894, + (q31_t)0xFB49E6A2, (q31_t)0x80163440, (q31_t)0xFC12D919, (q31_t)0x800F6B88, + (q31_t)0xFCDBD541, (q31_t)0x8009DE7D, (q31_t)0xFDA4D928, (q31_t)0x80058D2E, + (q31_t)0xFE6DE2E0, (q31_t)0x800277A5, (q31_t)0xFF36F078, (q31_t)0x80009DE9}; /** @par @@ -9694,1034 +4500,777 @@ const q31_t twiddleCoef_1024_q31[1536] = { Cos and Sin values are interleaved fashion @par Convert Floating point to Q31(Fixed point 1.31): - round(twiddleCoefQ31(i) * pow(2, 31)) + round(twiddleCoefQ31(i) * pow(2, 31)) */ const q31_t twiddleCoef_2048_q31[3072] = { - (q31_t)0x7FFFFFFF, (q31_t)0x00000000, (q31_t)0x7FFFD885, - (q31_t)0x006487E3, (q31_t)0x7FFF6216, (q31_t)0x00C90F88, - (q31_t)0x7FFE9CB2, (q31_t)0x012D96B0, (q31_t)0x7FFD885A, - (q31_t)0x01921D1F, (q31_t)0x7FFC250F, (q31_t)0x01F6A296, - (q31_t)0x7FFA72D1, (q31_t)0x025B26D7, (q31_t)0x7FF871A1, - (q31_t)0x02BFA9A4, (q31_t)0x7FF62182, (q31_t)0x03242ABF, - (q31_t)0x7FF38273, (q31_t)0x0388A9E9, (q31_t)0x7FF09477, - (q31_t)0x03ED26E6, (q31_t)0x7FED5790, (q31_t)0x0451A176, - (q31_t)0x7FE9CBC0, (q31_t)0x04B6195D, (q31_t)0x7FE5F108, - (q31_t)0x051A8E5C, (q31_t)0x7FE1C76B, (q31_t)0x057F0034, - (q31_t)0x7FDD4EEC, (q31_t)0x05E36EA9, (q31_t)0x7FD8878D, - (q31_t)0x0647D97C, (q31_t)0x7FD37152, (q31_t)0x06AC406F, - (q31_t)0x7FCE0C3E, (q31_t)0x0710A344, (q31_t)0x7FC85853, - (q31_t)0x077501BE, (q31_t)0x7FC25596, (q31_t)0x07D95B9E, - (q31_t)0x7FBC040A, (q31_t)0x083DB0A7, (q31_t)0x7FB563B2, - (q31_t)0x08A2009A, (q31_t)0x7FAE7494, (q31_t)0x09064B3A, - (q31_t)0x7FA736B4, (q31_t)0x096A9049, (q31_t)0x7F9FAA15, - (q31_t)0x09CECF89, (q31_t)0x7F97CEBC, (q31_t)0x0A3308BC, - (q31_t)0x7F8FA4AF, (q31_t)0x0A973BA5, (q31_t)0x7F872BF3, - (q31_t)0x0AFB6805, (q31_t)0x7F7E648B, (q31_t)0x0B5F8D9F, - (q31_t)0x7F754E7F, (q31_t)0x0BC3AC35, (q31_t)0x7F6BE9D4, - (q31_t)0x0C27C389, (q31_t)0x7F62368F, (q31_t)0x0C8BD35E, - (q31_t)0x7F5834B6, (q31_t)0x0CEFDB75, (q31_t)0x7F4DE450, - (q31_t)0x0D53DB92, (q31_t)0x7F434563, (q31_t)0x0DB7D376, - (q31_t)0x7F3857F5, (q31_t)0x0E1BC2E3, (q31_t)0x7F2D1C0E, - (q31_t)0x0E7FA99D, (q31_t)0x7F2191B4, (q31_t)0x0EE38765, - (q31_t)0x7F15B8EE, (q31_t)0x0F475BFE, (q31_t)0x7F0991C3, - (q31_t)0x0FAB272B, (q31_t)0x7EFD1C3C, (q31_t)0x100EE8AD, - (q31_t)0x7EF0585F, (q31_t)0x1072A047, (q31_t)0x7EE34635, - (q31_t)0x10D64DBC, (q31_t)0x7ED5E5C6, (q31_t)0x1139F0CE, - (q31_t)0x7EC8371A, (q31_t)0x119D8940, (q31_t)0x7EBA3A39, - (q31_t)0x120116D4, (q31_t)0x7EABEF2C, (q31_t)0x1264994E, - (q31_t)0x7E9D55FC, (q31_t)0x12C8106E, (q31_t)0x7E8E6EB1, - (q31_t)0x132B7BF9, (q31_t)0x7E7F3956, (q31_t)0x138EDBB0, - (q31_t)0x7E6FB5F3, (q31_t)0x13F22F57, (q31_t)0x7E5FE493, - (q31_t)0x145576B1, (q31_t)0x7E4FC53E, (q31_t)0x14B8B17F, - (q31_t)0x7E3F57FE, (q31_t)0x151BDF85, (q31_t)0x7E2E9CDF, - (q31_t)0x157F0086, (q31_t)0x7E1D93E9, (q31_t)0x15E21444, - (q31_t)0x7E0C3D29, (q31_t)0x16451A83, (q31_t)0x7DFA98A7, - (q31_t)0x16A81305, (q31_t)0x7DE8A670, (q31_t)0x170AFD8D, - (q31_t)0x7DD6668E, (q31_t)0x176DD9DE, (q31_t)0x7DC3D90D, - (q31_t)0x17D0A7BB, (q31_t)0x7DB0FDF7, (q31_t)0x183366E8, - (q31_t)0x7D9DD55A, (q31_t)0x18961727, (q31_t)0x7D8A5F3F, - (q31_t)0x18F8B83C, (q31_t)0x7D769BB5, (q31_t)0x195B49E9, - (q31_t)0x7D628AC5, (q31_t)0x19BDCBF2, (q31_t)0x7D4E2C7E, - (q31_t)0x1A203E1B, (q31_t)0x7D3980EC, (q31_t)0x1A82A025, - (q31_t)0x7D24881A, (q31_t)0x1AE4F1D6, (q31_t)0x7D0F4218, - (q31_t)0x1B4732EF, (q31_t)0x7CF9AEF0, (q31_t)0x1BA96334, - (q31_t)0x7CE3CEB1, (q31_t)0x1C0B826A, (q31_t)0x7CCDA168, - (q31_t)0x1C6D9053, (q31_t)0x7CB72724, (q31_t)0x1CCF8CB3, - (q31_t)0x7CA05FF1, (q31_t)0x1D31774D, (q31_t)0x7C894BDD, - (q31_t)0x1D934FE5, (q31_t)0x7C71EAF8, (q31_t)0x1DF5163F, - (q31_t)0x7C5A3D4F, (q31_t)0x1E56CA1E, (q31_t)0x7C4242F2, - (q31_t)0x1EB86B46, (q31_t)0x7C29FBEE, (q31_t)0x1F19F97B, - (q31_t)0x7C116853, (q31_t)0x1F7B7480, (q31_t)0x7BF88830, - (q31_t)0x1FDCDC1A, (q31_t)0x7BDF5B94, (q31_t)0x203E300D, - (q31_t)0x7BC5E28F, (q31_t)0x209F701C, (q31_t)0x7BAC1D31, - (q31_t)0x21009C0B, (q31_t)0x7B920B89, (q31_t)0x2161B39F, - (q31_t)0x7B77ADA8, (q31_t)0x21C2B69C, (q31_t)0x7B5D039D, - (q31_t)0x2223A4C5, (q31_t)0x7B420D7A, (q31_t)0x22847DDF, - (q31_t)0x7B26CB4F, (q31_t)0x22E541AE, (q31_t)0x7B0B3D2C, - (q31_t)0x2345EFF7, (q31_t)0x7AEF6323, (q31_t)0x23A6887E, - (q31_t)0x7AD33D45, (q31_t)0x24070B07, (q31_t)0x7AB6CBA3, - (q31_t)0x24677757, (q31_t)0x7A9A0E4F, (q31_t)0x24C7CD32, - (q31_t)0x7A7D055B, (q31_t)0x25280C5D, (q31_t)0x7A5FB0D8, - (q31_t)0x2588349D, (q31_t)0x7A4210D8, (q31_t)0x25E845B5, - (q31_t)0x7A24256E, (q31_t)0x26483F6C, (q31_t)0x7A05EEAD, - (q31_t)0x26A82185, (q31_t)0x79E76CA6, (q31_t)0x2707EBC6, - (q31_t)0x79C89F6D, (q31_t)0x27679DF4, (q31_t)0x79A98715, - (q31_t)0x27C737D2, (q31_t)0x798A23B1, (q31_t)0x2826B928, - (q31_t)0x796A7554, (q31_t)0x288621B9, (q31_t)0x794A7C11, - (q31_t)0x28E5714A, (q31_t)0x792A37FE, (q31_t)0x2944A7A2, - (q31_t)0x7909A92C, (q31_t)0x29A3C484, (q31_t)0x78E8CFB1, - (q31_t)0x2A02C7B8, (q31_t)0x78C7ABA1, (q31_t)0x2A61B101, - (q31_t)0x78A63D10, (q31_t)0x2AC08025, (q31_t)0x78848413, - (q31_t)0x2B1F34EB, (q31_t)0x786280BF, (q31_t)0x2B7DCF17, - (q31_t)0x78403328, (q31_t)0x2BDC4E6F, (q31_t)0x781D9B64, - (q31_t)0x2C3AB2B9, (q31_t)0x77FAB988, (q31_t)0x2C98FBBA, - (q31_t)0x77D78DAA, (q31_t)0x2CF72939, (q31_t)0x77B417DF, - (q31_t)0x2D553AFB, (q31_t)0x7790583D, (q31_t)0x2DB330C7, - (q31_t)0x776C4EDB, (q31_t)0x2E110A62, (q31_t)0x7747FBCE, - (q31_t)0x2E6EC792, (q31_t)0x77235F2D, (q31_t)0x2ECC681E, - (q31_t)0x76FE790E, (q31_t)0x2F29EBCC, (q31_t)0x76D94988, - (q31_t)0x2F875262, (q31_t)0x76B3D0B3, (q31_t)0x2FE49BA6, - (q31_t)0x768E0EA5, (q31_t)0x3041C760, (q31_t)0x76680376, - (q31_t)0x309ED555, (q31_t)0x7641AF3C, (q31_t)0x30FBC54D, - (q31_t)0x761B1211, (q31_t)0x3158970D, (q31_t)0x75F42C0A, - (q31_t)0x31B54A5D, (q31_t)0x75CCFD42, (q31_t)0x3211DF03, - (q31_t)0x75A585CF, (q31_t)0x326E54C7, (q31_t)0x757DC5CA, - (q31_t)0x32CAAB6F, (q31_t)0x7555BD4B, (q31_t)0x3326E2C2, - (q31_t)0x752D6C6C, (q31_t)0x3382FA88, (q31_t)0x7504D345, - (q31_t)0x33DEF287, (q31_t)0x74DBF1EF, (q31_t)0x343ACA87, - (q31_t)0x74B2C883, (q31_t)0x3496824F, (q31_t)0x7489571B, - (q31_t)0x34F219A7, (q31_t)0x745F9DD1, (q31_t)0x354D9056, - (q31_t)0x74359CBD, (q31_t)0x35A8E624, (q31_t)0x740B53FA, - (q31_t)0x36041AD9, (q31_t)0x73E0C3A3, (q31_t)0x365F2E3B, - (q31_t)0x73B5EBD0, (q31_t)0x36BA2013, (q31_t)0x738ACC9E, - (q31_t)0x3714F02A, (q31_t)0x735F6626, (q31_t)0x376F9E46, - (q31_t)0x7333B883, (q31_t)0x37CA2A30, (q31_t)0x7307C3D0, - (q31_t)0x382493B0, (q31_t)0x72DB8828, (q31_t)0x387EDA8E, - (q31_t)0x72AF05A6, (q31_t)0x38D8FE93, (q31_t)0x72823C66, - (q31_t)0x3932FF87, (q31_t)0x72552C84, (q31_t)0x398CDD32, - (q31_t)0x7227D61C, (q31_t)0x39E6975D, (q31_t)0x71FA3948, - (q31_t)0x3A402DD1, (q31_t)0x71CC5626, (q31_t)0x3A99A057, - (q31_t)0x719E2CD2, (q31_t)0x3AF2EEB7, (q31_t)0x716FBD68, - (q31_t)0x3B4C18BA, (q31_t)0x71410804, (q31_t)0x3BA51E29, - (q31_t)0x71120CC5, (q31_t)0x3BFDFECD, (q31_t)0x70E2CBC6, - (q31_t)0x3C56BA70, (q31_t)0x70B34524, (q31_t)0x3CAF50DA, - (q31_t)0x708378FE, (q31_t)0x3D07C1D5, (q31_t)0x70536771, - (q31_t)0x3D600D2B, (q31_t)0x70231099, (q31_t)0x3DB832A5, - (q31_t)0x6FF27496, (q31_t)0x3E10320D, (q31_t)0x6FC19385, - (q31_t)0x3E680B2C, (q31_t)0x6F906D84, (q31_t)0x3EBFBDCC, - (q31_t)0x6F5F02B1, (q31_t)0x3F1749B7, (q31_t)0x6F2D532C, - (q31_t)0x3F6EAEB8, (q31_t)0x6EFB5F12, (q31_t)0x3FC5EC97, - (q31_t)0x6EC92682, (q31_t)0x401D0320, (q31_t)0x6E96A99C, - (q31_t)0x4073F21D, (q31_t)0x6E63E87F, (q31_t)0x40CAB957, - (q31_t)0x6E30E349, (q31_t)0x4121589A, (q31_t)0x6DFD9A1B, - (q31_t)0x4177CFB0, (q31_t)0x6DCA0D14, (q31_t)0x41CE1E64, - (q31_t)0x6D963C54, (q31_t)0x42244480, (q31_t)0x6D6227FA, - (q31_t)0x427A41D0, (q31_t)0x6D2DD027, (q31_t)0x42D0161E, - (q31_t)0x6CF934FB, (q31_t)0x4325C135, (q31_t)0x6CC45697, - (q31_t)0x437B42E1, (q31_t)0x6C8F351C, (q31_t)0x43D09AEC, - (q31_t)0x6C59D0A9, (q31_t)0x4425C923, (q31_t)0x6C242960, - (q31_t)0x447ACD50, (q31_t)0x6BEE3F62, (q31_t)0x44CFA73F, - (q31_t)0x6BB812D0, (q31_t)0x452456BC, (q31_t)0x6B81A3CD, - (q31_t)0x4578DB93, (q31_t)0x6B4AF278, (q31_t)0x45CD358F, - (q31_t)0x6B13FEF5, (q31_t)0x4621647C, (q31_t)0x6ADCC964, - (q31_t)0x46756827, (q31_t)0x6AA551E8, (q31_t)0x46C9405C, - (q31_t)0x6A6D98A4, (q31_t)0x471CECE6, (q31_t)0x6A359DB9, - (q31_t)0x47706D93, (q31_t)0x69FD614A, (q31_t)0x47C3C22E, - (q31_t)0x69C4E37A, (q31_t)0x4816EA85, (q31_t)0x698C246C, - (q31_t)0x4869E664, (q31_t)0x69532442, (q31_t)0x48BCB598, - (q31_t)0x6919E320, (q31_t)0x490F57EE, (q31_t)0x68E06129, - (q31_t)0x4961CD32, (q31_t)0x68A69E81, (q31_t)0x49B41533, - (q31_t)0x686C9B4B, (q31_t)0x4A062FBD, (q31_t)0x683257AA, - (q31_t)0x4A581C9D, (q31_t)0x67F7D3C4, (q31_t)0x4AA9DBA1, - (q31_t)0x67BD0FBC, (q31_t)0x4AFB6C97, (q31_t)0x67820BB6, - (q31_t)0x4B4CCF4D, (q31_t)0x6746C7D7, (q31_t)0x4B9E038F, - (q31_t)0x670B4443, (q31_t)0x4BEF092D, (q31_t)0x66CF811F, - (q31_t)0x4C3FDFF3, (q31_t)0x66937E90, (q31_t)0x4C9087B1, - (q31_t)0x66573CBB, (q31_t)0x4CE10034, (q31_t)0x661ABBC5, - (q31_t)0x4D31494B, (q31_t)0x65DDFBD3, (q31_t)0x4D8162C4, - (q31_t)0x65A0FD0B, (q31_t)0x4DD14C6E, (q31_t)0x6563BF92, - (q31_t)0x4E210617, (q31_t)0x6526438E, (q31_t)0x4E708F8F, - (q31_t)0x64E88926, (q31_t)0x4EBFE8A4, (q31_t)0x64AA907F, - (q31_t)0x4F0F1126, (q31_t)0x646C59BF, (q31_t)0x4F5E08E3, - (q31_t)0x642DE50D, (q31_t)0x4FACCFAB, (q31_t)0x63EF328F, - (q31_t)0x4FFB654D, (q31_t)0x63B0426D, (q31_t)0x5049C999, - (q31_t)0x637114CC, (q31_t)0x5097FC5E, (q31_t)0x6331A9D4, - (q31_t)0x50E5FD6C, (q31_t)0x62F201AC, (q31_t)0x5133CC94, - (q31_t)0x62B21C7B, (q31_t)0x518169A4, (q31_t)0x6271FA69, - (q31_t)0x51CED46E, (q31_t)0x62319B9D, (q31_t)0x521C0CC1, - (q31_t)0x61F1003E, (q31_t)0x5269126E, (q31_t)0x61B02876, - (q31_t)0x52B5E545, (q31_t)0x616F146B, (q31_t)0x53028517, - (q31_t)0x612DC446, (q31_t)0x534EF1B5, (q31_t)0x60EC3830, - (q31_t)0x539B2AEF, (q31_t)0x60AA704F, (q31_t)0x53E73097, - (q31_t)0x60686CCE, (q31_t)0x5433027D, (q31_t)0x60262DD5, - (q31_t)0x547EA073, (q31_t)0x5FE3B38D, (q31_t)0x54CA0A4A, - (q31_t)0x5FA0FE1E, (q31_t)0x55153FD4, (q31_t)0x5F5E0DB3, - (q31_t)0x556040E2, (q31_t)0x5F1AE273, (q31_t)0x55AB0D46, - (q31_t)0x5ED77C89, (q31_t)0x55F5A4D2, (q31_t)0x5E93DC1F, - (q31_t)0x56400757, (q31_t)0x5E50015D, (q31_t)0x568A34A9, - (q31_t)0x5E0BEC6E, (q31_t)0x56D42C99, (q31_t)0x5DC79D7C, - (q31_t)0x571DEEF9, (q31_t)0x5D8314B0, (q31_t)0x57677B9D, - (q31_t)0x5D3E5236, (q31_t)0x57B0D256, (q31_t)0x5CF95638, - (q31_t)0x57F9F2F7, (q31_t)0x5CB420DF, (q31_t)0x5842DD54, - (q31_t)0x5C6EB258, (q31_t)0x588B913F, (q31_t)0x5C290ACC, - (q31_t)0x58D40E8C, (q31_t)0x5BE32A67, (q31_t)0x591C550E, - (q31_t)0x5B9D1153, (q31_t)0x59646497, (q31_t)0x5B56BFBD, - (q31_t)0x59AC3CFD, (q31_t)0x5B1035CF, (q31_t)0x59F3DE12, - (q31_t)0x5AC973B4, (q31_t)0x5A3B47AA, (q31_t)0x5A82799A, - (q31_t)0x5A82799A, (q31_t)0x5A3B47AA, (q31_t)0x5AC973B4, - (q31_t)0x59F3DE12, (q31_t)0x5B1035CF, (q31_t)0x59AC3CFD, - (q31_t)0x5B56BFBD, (q31_t)0x59646497, (q31_t)0x5B9D1153, - (q31_t)0x591C550E, (q31_t)0x5BE32A67, (q31_t)0x58D40E8C, - (q31_t)0x5C290ACC, (q31_t)0x588B913F, (q31_t)0x5C6EB258, - (q31_t)0x5842DD54, (q31_t)0x5CB420DF, (q31_t)0x57F9F2F7, - (q31_t)0x5CF95638, (q31_t)0x57B0D256, (q31_t)0x5D3E5236, - (q31_t)0x57677B9D, (q31_t)0x5D8314B0, (q31_t)0x571DEEF9, - (q31_t)0x5DC79D7C, (q31_t)0x56D42C99, (q31_t)0x5E0BEC6E, - (q31_t)0x568A34A9, (q31_t)0x5E50015D, (q31_t)0x56400757, - (q31_t)0x5E93DC1F, (q31_t)0x55F5A4D2, (q31_t)0x5ED77C89, - (q31_t)0x55AB0D46, (q31_t)0x5F1AE273, (q31_t)0x556040E2, - (q31_t)0x5F5E0DB3, (q31_t)0x55153FD4, (q31_t)0x5FA0FE1E, - (q31_t)0x54CA0A4A, (q31_t)0x5FE3B38D, (q31_t)0x547EA073, - (q31_t)0x60262DD5, (q31_t)0x5433027D, (q31_t)0x60686CCE, - (q31_t)0x53E73097, (q31_t)0x60AA704F, (q31_t)0x539B2AEF, - (q31_t)0x60EC3830, (q31_t)0x534EF1B5, (q31_t)0x612DC446, - (q31_t)0x53028517, (q31_t)0x616F146B, (q31_t)0x52B5E545, - (q31_t)0x61B02876, (q31_t)0x5269126E, (q31_t)0x61F1003E, - (q31_t)0x521C0CC1, (q31_t)0x62319B9D, (q31_t)0x51CED46E, - (q31_t)0x6271FA69, (q31_t)0x518169A4, (q31_t)0x62B21C7B, - (q31_t)0x5133CC94, (q31_t)0x62F201AC, (q31_t)0x50E5FD6C, - (q31_t)0x6331A9D4, (q31_t)0x5097FC5E, (q31_t)0x637114CC, - (q31_t)0x5049C999, (q31_t)0x63B0426D, (q31_t)0x4FFB654D, - (q31_t)0x63EF328F, (q31_t)0x4FACCFAB, (q31_t)0x642DE50D, - (q31_t)0x4F5E08E3, (q31_t)0x646C59BF, (q31_t)0x4F0F1126, - (q31_t)0x64AA907F, (q31_t)0x4EBFE8A4, (q31_t)0x64E88926, - (q31_t)0x4E708F8F, (q31_t)0x6526438E, (q31_t)0x4E210617, - (q31_t)0x6563BF92, (q31_t)0x4DD14C6E, (q31_t)0x65A0FD0B, - (q31_t)0x4D8162C4, (q31_t)0x65DDFBD3, (q31_t)0x4D31494B, - (q31_t)0x661ABBC5, (q31_t)0x4CE10034, (q31_t)0x66573CBB, - (q31_t)0x4C9087B1, (q31_t)0x66937E90, (q31_t)0x4C3FDFF3, - (q31_t)0x66CF811F, (q31_t)0x4BEF092D, (q31_t)0x670B4443, - (q31_t)0x4B9E038F, (q31_t)0x6746C7D7, (q31_t)0x4B4CCF4D, - (q31_t)0x67820BB6, (q31_t)0x4AFB6C97, (q31_t)0x67BD0FBC, - (q31_t)0x4AA9DBA1, (q31_t)0x67F7D3C4, (q31_t)0x4A581C9D, - (q31_t)0x683257AA, (q31_t)0x4A062FBD, (q31_t)0x686C9B4B, - (q31_t)0x49B41533, (q31_t)0x68A69E81, (q31_t)0x4961CD32, - (q31_t)0x68E06129, (q31_t)0x490F57EE, (q31_t)0x6919E320, - (q31_t)0x48BCB598, (q31_t)0x69532442, (q31_t)0x4869E664, - (q31_t)0x698C246C, (q31_t)0x4816EA85, (q31_t)0x69C4E37A, - (q31_t)0x47C3C22E, (q31_t)0x69FD614A, (q31_t)0x47706D93, - (q31_t)0x6A359DB9, (q31_t)0x471CECE6, (q31_t)0x6A6D98A4, - (q31_t)0x46C9405C, (q31_t)0x6AA551E8, (q31_t)0x46756827, - (q31_t)0x6ADCC964, (q31_t)0x4621647C, (q31_t)0x6B13FEF5, - (q31_t)0x45CD358F, (q31_t)0x6B4AF278, (q31_t)0x4578DB93, - (q31_t)0x6B81A3CD, (q31_t)0x452456BC, (q31_t)0x6BB812D0, - (q31_t)0x44CFA73F, (q31_t)0x6BEE3F62, (q31_t)0x447ACD50, - (q31_t)0x6C242960, (q31_t)0x4425C923, (q31_t)0x6C59D0A9, - (q31_t)0x43D09AEC, (q31_t)0x6C8F351C, (q31_t)0x437B42E1, - (q31_t)0x6CC45697, (q31_t)0x4325C135, (q31_t)0x6CF934FB, - (q31_t)0x42D0161E, (q31_t)0x6D2DD027, (q31_t)0x427A41D0, - (q31_t)0x6D6227FA, (q31_t)0x42244480, (q31_t)0x6D963C54, - (q31_t)0x41CE1E64, (q31_t)0x6DCA0D14, (q31_t)0x4177CFB0, - (q31_t)0x6DFD9A1B, (q31_t)0x4121589A, (q31_t)0x6E30E349, - (q31_t)0x40CAB957, (q31_t)0x6E63E87F, (q31_t)0x4073F21D, - (q31_t)0x6E96A99C, (q31_t)0x401D0320, (q31_t)0x6EC92682, - (q31_t)0x3FC5EC97, (q31_t)0x6EFB5F12, (q31_t)0x3F6EAEB8, - (q31_t)0x6F2D532C, (q31_t)0x3F1749B7, (q31_t)0x6F5F02B1, - (q31_t)0x3EBFBDCC, (q31_t)0x6F906D84, (q31_t)0x3E680B2C, - (q31_t)0x6FC19385, (q31_t)0x3E10320D, (q31_t)0x6FF27496, - (q31_t)0x3DB832A5, (q31_t)0x70231099, (q31_t)0x3D600D2B, - (q31_t)0x70536771, (q31_t)0x3D07C1D5, (q31_t)0x708378FE, - (q31_t)0x3CAF50DA, (q31_t)0x70B34524, (q31_t)0x3C56BA70, - (q31_t)0x70E2CBC6, (q31_t)0x3BFDFECD, (q31_t)0x71120CC5, - (q31_t)0x3BA51E29, (q31_t)0x71410804, (q31_t)0x3B4C18BA, - (q31_t)0x716FBD68, (q31_t)0x3AF2EEB7, (q31_t)0x719E2CD2, - (q31_t)0x3A99A057, (q31_t)0x71CC5626, (q31_t)0x3A402DD1, - (q31_t)0x71FA3948, (q31_t)0x39E6975D, (q31_t)0x7227D61C, - (q31_t)0x398CDD32, (q31_t)0x72552C84, (q31_t)0x3932FF87, - (q31_t)0x72823C66, (q31_t)0x38D8FE93, (q31_t)0x72AF05A6, - (q31_t)0x387EDA8E, (q31_t)0x72DB8828, (q31_t)0x382493B0, - (q31_t)0x7307C3D0, (q31_t)0x37CA2A30, (q31_t)0x7333B883, - (q31_t)0x376F9E46, (q31_t)0x735F6626, (q31_t)0x3714F02A, - (q31_t)0x738ACC9E, (q31_t)0x36BA2013, (q31_t)0x73B5EBD0, - (q31_t)0x365F2E3B, (q31_t)0x73E0C3A3, (q31_t)0x36041AD9, - (q31_t)0x740B53FA, (q31_t)0x35A8E624, (q31_t)0x74359CBD, - (q31_t)0x354D9056, (q31_t)0x745F9DD1, (q31_t)0x34F219A7, - (q31_t)0x7489571B, (q31_t)0x3496824F, (q31_t)0x74B2C883, - (q31_t)0x343ACA87, (q31_t)0x74DBF1EF, (q31_t)0x33DEF287, - (q31_t)0x7504D345, (q31_t)0x3382FA88, (q31_t)0x752D6C6C, - (q31_t)0x3326E2C2, (q31_t)0x7555BD4B, (q31_t)0x32CAAB6F, - (q31_t)0x757DC5CA, (q31_t)0x326E54C7, (q31_t)0x75A585CF, - (q31_t)0x3211DF03, (q31_t)0x75CCFD42, (q31_t)0x31B54A5D, - (q31_t)0x75F42C0A, (q31_t)0x3158970D, (q31_t)0x761B1211, - (q31_t)0x30FBC54D, (q31_t)0x7641AF3C, (q31_t)0x309ED555, - (q31_t)0x76680376, (q31_t)0x3041C760, (q31_t)0x768E0EA5, - (q31_t)0x2FE49BA6, (q31_t)0x76B3D0B3, (q31_t)0x2F875262, - (q31_t)0x76D94988, (q31_t)0x2F29EBCC, (q31_t)0x76FE790E, - (q31_t)0x2ECC681E, (q31_t)0x77235F2D, (q31_t)0x2E6EC792, - (q31_t)0x7747FBCE, (q31_t)0x2E110A62, (q31_t)0x776C4EDB, - (q31_t)0x2DB330C7, (q31_t)0x7790583D, (q31_t)0x2D553AFB, - (q31_t)0x77B417DF, (q31_t)0x2CF72939, (q31_t)0x77D78DAA, - (q31_t)0x2C98FBBA, (q31_t)0x77FAB988, (q31_t)0x2C3AB2B9, - (q31_t)0x781D9B64, (q31_t)0x2BDC4E6F, (q31_t)0x78403328, - (q31_t)0x2B7DCF17, (q31_t)0x786280BF, (q31_t)0x2B1F34EB, - (q31_t)0x78848413, (q31_t)0x2AC08025, (q31_t)0x78A63D10, - (q31_t)0x2A61B101, (q31_t)0x78C7ABA1, (q31_t)0x2A02C7B8, - (q31_t)0x78E8CFB1, (q31_t)0x29A3C484, (q31_t)0x7909A92C, - (q31_t)0x2944A7A2, (q31_t)0x792A37FE, (q31_t)0x28E5714A, - (q31_t)0x794A7C11, (q31_t)0x288621B9, (q31_t)0x796A7554, - (q31_t)0x2826B928, (q31_t)0x798A23B1, (q31_t)0x27C737D2, - (q31_t)0x79A98715, (q31_t)0x27679DF4, (q31_t)0x79C89F6D, - (q31_t)0x2707EBC6, (q31_t)0x79E76CA6, (q31_t)0x26A82185, - (q31_t)0x7A05EEAD, (q31_t)0x26483F6C, (q31_t)0x7A24256E, - (q31_t)0x25E845B5, (q31_t)0x7A4210D8, (q31_t)0x2588349D, - (q31_t)0x7A5FB0D8, (q31_t)0x25280C5D, (q31_t)0x7A7D055B, - (q31_t)0x24C7CD32, (q31_t)0x7A9A0E4F, (q31_t)0x24677757, - (q31_t)0x7AB6CBA3, (q31_t)0x24070B07, (q31_t)0x7AD33D45, - (q31_t)0x23A6887E, (q31_t)0x7AEF6323, (q31_t)0x2345EFF7, - (q31_t)0x7B0B3D2C, (q31_t)0x22E541AE, (q31_t)0x7B26CB4F, - (q31_t)0x22847DDF, (q31_t)0x7B420D7A, (q31_t)0x2223A4C5, - (q31_t)0x7B5D039D, (q31_t)0x21C2B69C, (q31_t)0x7B77ADA8, - (q31_t)0x2161B39F, (q31_t)0x7B920B89, (q31_t)0x21009C0B, - (q31_t)0x7BAC1D31, (q31_t)0x209F701C, (q31_t)0x7BC5E28F, - (q31_t)0x203E300D, (q31_t)0x7BDF5B94, (q31_t)0x1FDCDC1A, - (q31_t)0x7BF88830, (q31_t)0x1F7B7480, (q31_t)0x7C116853, - (q31_t)0x1F19F97B, (q31_t)0x7C29FBEE, (q31_t)0x1EB86B46, - (q31_t)0x7C4242F2, (q31_t)0x1E56CA1E, (q31_t)0x7C5A3D4F, - (q31_t)0x1DF5163F, (q31_t)0x7C71EAF8, (q31_t)0x1D934FE5, - (q31_t)0x7C894BDD, (q31_t)0x1D31774D, (q31_t)0x7CA05FF1, - (q31_t)0x1CCF8CB3, (q31_t)0x7CB72724, (q31_t)0x1C6D9053, - (q31_t)0x7CCDA168, (q31_t)0x1C0B826A, (q31_t)0x7CE3CEB1, - (q31_t)0x1BA96334, (q31_t)0x7CF9AEF0, (q31_t)0x1B4732EF, - (q31_t)0x7D0F4218, (q31_t)0x1AE4F1D6, (q31_t)0x7D24881A, - (q31_t)0x1A82A025, (q31_t)0x7D3980EC, (q31_t)0x1A203E1B, - (q31_t)0x7D4E2C7E, (q31_t)0x19BDCBF2, (q31_t)0x7D628AC5, - (q31_t)0x195B49E9, (q31_t)0x7D769BB5, (q31_t)0x18F8B83C, - (q31_t)0x7D8A5F3F, (q31_t)0x18961727, (q31_t)0x7D9DD55A, - (q31_t)0x183366E8, (q31_t)0x7DB0FDF7, (q31_t)0x17D0A7BB, - (q31_t)0x7DC3D90D, (q31_t)0x176DD9DE, (q31_t)0x7DD6668E, - (q31_t)0x170AFD8D, (q31_t)0x7DE8A670, (q31_t)0x16A81305, - (q31_t)0x7DFA98A7, (q31_t)0x16451A83, (q31_t)0x7E0C3D29, - (q31_t)0x15E21444, (q31_t)0x7E1D93E9, (q31_t)0x157F0086, - (q31_t)0x7E2E9CDF, (q31_t)0x151BDF85, (q31_t)0x7E3F57FE, - (q31_t)0x14B8B17F, (q31_t)0x7E4FC53E, (q31_t)0x145576B1, - (q31_t)0x7E5FE493, (q31_t)0x13F22F57, (q31_t)0x7E6FB5F3, - (q31_t)0x138EDBB0, (q31_t)0x7E7F3956, (q31_t)0x132B7BF9, - (q31_t)0x7E8E6EB1, (q31_t)0x12C8106E, (q31_t)0x7E9D55FC, - (q31_t)0x1264994E, (q31_t)0x7EABEF2C, (q31_t)0x120116D4, - (q31_t)0x7EBA3A39, (q31_t)0x119D8940, (q31_t)0x7EC8371A, - (q31_t)0x1139F0CE, (q31_t)0x7ED5E5C6, (q31_t)0x10D64DBC, - (q31_t)0x7EE34635, (q31_t)0x1072A047, (q31_t)0x7EF0585F, - (q31_t)0x100EE8AD, (q31_t)0x7EFD1C3C, (q31_t)0x0FAB272B, - (q31_t)0x7F0991C3, (q31_t)0x0F475BFE, (q31_t)0x7F15B8EE, - (q31_t)0x0EE38765, (q31_t)0x7F2191B4, (q31_t)0x0E7FA99D, - (q31_t)0x7F2D1C0E, (q31_t)0x0E1BC2E3, (q31_t)0x7F3857F5, - (q31_t)0x0DB7D376, (q31_t)0x7F434563, (q31_t)0x0D53DB92, - (q31_t)0x7F4DE450, (q31_t)0x0CEFDB75, (q31_t)0x7F5834B6, - (q31_t)0x0C8BD35E, (q31_t)0x7F62368F, (q31_t)0x0C27C389, - (q31_t)0x7F6BE9D4, (q31_t)0x0BC3AC35, (q31_t)0x7F754E7F, - (q31_t)0x0B5F8D9F, (q31_t)0x7F7E648B, (q31_t)0x0AFB6805, - (q31_t)0x7F872BF3, (q31_t)0x0A973BA5, (q31_t)0x7F8FA4AF, - (q31_t)0x0A3308BC, (q31_t)0x7F97CEBC, (q31_t)0x09CECF89, - (q31_t)0x7F9FAA15, (q31_t)0x096A9049, (q31_t)0x7FA736B4, - (q31_t)0x09064B3A, (q31_t)0x7FAE7494, (q31_t)0x08A2009A, - (q31_t)0x7FB563B2, (q31_t)0x083DB0A7, (q31_t)0x7FBC040A, - (q31_t)0x07D95B9E, (q31_t)0x7FC25596, (q31_t)0x077501BE, - (q31_t)0x7FC85853, (q31_t)0x0710A344, (q31_t)0x7FCE0C3E, - (q31_t)0x06AC406F, (q31_t)0x7FD37152, (q31_t)0x0647D97C, - (q31_t)0x7FD8878D, (q31_t)0x05E36EA9, (q31_t)0x7FDD4EEC, - (q31_t)0x057F0034, (q31_t)0x7FE1C76B, (q31_t)0x051A8E5C, - (q31_t)0x7FE5F108, (q31_t)0x04B6195D, (q31_t)0x7FE9CBC0, - (q31_t)0x0451A176, (q31_t)0x7FED5790, (q31_t)0x03ED26E6, - (q31_t)0x7FF09477, (q31_t)0x0388A9E9, (q31_t)0x7FF38273, - (q31_t)0x03242ABF, (q31_t)0x7FF62182, (q31_t)0x02BFA9A4, - (q31_t)0x7FF871A1, (q31_t)0x025B26D7, (q31_t)0x7FFA72D1, - (q31_t)0x01F6A296, (q31_t)0x7FFC250F, (q31_t)0x01921D1F, - (q31_t)0x7FFD885A, (q31_t)0x012D96B0, (q31_t)0x7FFE9CB2, - (q31_t)0x00C90F88, (q31_t)0x7FFF6216, (q31_t)0x006487E3, - (q31_t)0x7FFFD885, (q31_t)0x00000000, (q31_t)0x7FFFFFFF, - (q31_t)0xFF9B781D, (q31_t)0x7FFFD885, (q31_t)0xFF36F078, - (q31_t)0x7FFF6216, (q31_t)0xFED2694F, (q31_t)0x7FFE9CB2, - (q31_t)0xFE6DE2E0, (q31_t)0x7FFD885A, (q31_t)0xFE095D69, - (q31_t)0x7FFC250F, (q31_t)0xFDA4D928, (q31_t)0x7FFA72D1, - (q31_t)0xFD40565B, (q31_t)0x7FF871A1, (q31_t)0xFCDBD541, - (q31_t)0x7FF62182, (q31_t)0xFC775616, (q31_t)0x7FF38273, - (q31_t)0xFC12D919, (q31_t)0x7FF09477, (q31_t)0xFBAE5E89, - (q31_t)0x7FED5790, (q31_t)0xFB49E6A2, (q31_t)0x7FE9CBC0, - (q31_t)0xFAE571A4, (q31_t)0x7FE5F108, (q31_t)0xFA80FFCB, - (q31_t)0x7FE1C76B, (q31_t)0xFA1C9156, (q31_t)0x7FDD4EEC, - (q31_t)0xF9B82683, (q31_t)0x7FD8878D, (q31_t)0xF953BF90, - (q31_t)0x7FD37152, (q31_t)0xF8EF5CBB, (q31_t)0x7FCE0C3E, - (q31_t)0xF88AFE41, (q31_t)0x7FC85853, (q31_t)0xF826A461, - (q31_t)0x7FC25596, (q31_t)0xF7C24F58, (q31_t)0x7FBC040A, - (q31_t)0xF75DFF65, (q31_t)0x7FB563B2, (q31_t)0xF6F9B4C5, - (q31_t)0x7FAE7494, (q31_t)0xF6956FB6, (q31_t)0x7FA736B4, - (q31_t)0xF6313076, (q31_t)0x7F9FAA15, (q31_t)0xF5CCF743, - (q31_t)0x7F97CEBC, (q31_t)0xF568C45A, (q31_t)0x7F8FA4AF, - (q31_t)0xF50497FA, (q31_t)0x7F872BF3, (q31_t)0xF4A07260, - (q31_t)0x7F7E648B, (q31_t)0xF43C53CA, (q31_t)0x7F754E7F, - (q31_t)0xF3D83C76, (q31_t)0x7F6BE9D4, (q31_t)0xF3742CA1, - (q31_t)0x7F62368F, (q31_t)0xF310248A, (q31_t)0x7F5834B6, - (q31_t)0xF2AC246D, (q31_t)0x7F4DE450, (q31_t)0xF2482C89, - (q31_t)0x7F434563, (q31_t)0xF1E43D1C, (q31_t)0x7F3857F5, - (q31_t)0xF1805662, (q31_t)0x7F2D1C0E, (q31_t)0xF11C789A, - (q31_t)0x7F2191B4, (q31_t)0xF0B8A401, (q31_t)0x7F15B8EE, - (q31_t)0xF054D8D4, (q31_t)0x7F0991C3, (q31_t)0xEFF11752, - (q31_t)0x7EFD1C3C, (q31_t)0xEF8D5FB8, (q31_t)0x7EF0585F, - (q31_t)0xEF29B243, (q31_t)0x7EE34635, (q31_t)0xEEC60F31, - (q31_t)0x7ED5E5C6, (q31_t)0xEE6276BF, (q31_t)0x7EC8371A, - (q31_t)0xEDFEE92B, (q31_t)0x7EBA3A39, (q31_t)0xED9B66B2, - (q31_t)0x7EABEF2C, (q31_t)0xED37EF91, (q31_t)0x7E9D55FC, - (q31_t)0xECD48406, (q31_t)0x7E8E6EB1, (q31_t)0xEC71244F, - (q31_t)0x7E7F3956, (q31_t)0xEC0DD0A8, (q31_t)0x7E6FB5F3, - (q31_t)0xEBAA894E, (q31_t)0x7E5FE493, (q31_t)0xEB474E80, - (q31_t)0x7E4FC53E, (q31_t)0xEAE4207A, (q31_t)0x7E3F57FE, - (q31_t)0xEA80FF79, (q31_t)0x7E2E9CDF, (q31_t)0xEA1DEBBB, - (q31_t)0x7E1D93E9, (q31_t)0xE9BAE57C, (q31_t)0x7E0C3D29, - (q31_t)0xE957ECFB, (q31_t)0x7DFA98A7, (q31_t)0xE8F50273, - (q31_t)0x7DE8A670, (q31_t)0xE8922621, (q31_t)0x7DD6668E, - (q31_t)0xE82F5844, (q31_t)0x7DC3D90D, (q31_t)0xE7CC9917, - (q31_t)0x7DB0FDF7, (q31_t)0xE769E8D8, (q31_t)0x7D9DD55A, - (q31_t)0xE70747C3, (q31_t)0x7D8A5F3F, (q31_t)0xE6A4B616, - (q31_t)0x7D769BB5, (q31_t)0xE642340D, (q31_t)0x7D628AC5, - (q31_t)0xE5DFC1E4, (q31_t)0x7D4E2C7E, (q31_t)0xE57D5FDA, - (q31_t)0x7D3980EC, (q31_t)0xE51B0E2A, (q31_t)0x7D24881A, - (q31_t)0xE4B8CD10, (q31_t)0x7D0F4218, (q31_t)0xE4569CCB, - (q31_t)0x7CF9AEF0, (q31_t)0xE3F47D95, (q31_t)0x7CE3CEB1, - (q31_t)0xE3926FAC, (q31_t)0x7CCDA168, (q31_t)0xE330734C, - (q31_t)0x7CB72724, (q31_t)0xE2CE88B2, (q31_t)0x7CA05FF1, - (q31_t)0xE26CB01A, (q31_t)0x7C894BDD, (q31_t)0xE20AE9C1, - (q31_t)0x7C71EAF8, (q31_t)0xE1A935E1, (q31_t)0x7C5A3D4F, - (q31_t)0xE14794B9, (q31_t)0x7C4242F2, (q31_t)0xE0E60684, - (q31_t)0x7C29FBEE, (q31_t)0xE0848B7F, (q31_t)0x7C116853, - (q31_t)0xE02323E5, (q31_t)0x7BF88830, (q31_t)0xDFC1CFF2, - (q31_t)0x7BDF5B94, (q31_t)0xDF608FE3, (q31_t)0x7BC5E28F, - (q31_t)0xDEFF63F4, (q31_t)0x7BAC1D31, (q31_t)0xDE9E4C60, - (q31_t)0x7B920B89, (q31_t)0xDE3D4963, (q31_t)0x7B77ADA8, - (q31_t)0xDDDC5B3A, (q31_t)0x7B5D039D, (q31_t)0xDD7B8220, - (q31_t)0x7B420D7A, (q31_t)0xDD1ABE51, (q31_t)0x7B26CB4F, - (q31_t)0xDCBA1008, (q31_t)0x7B0B3D2C, (q31_t)0xDC597781, - (q31_t)0x7AEF6323, (q31_t)0xDBF8F4F8, (q31_t)0x7AD33D45, - (q31_t)0xDB9888A8, (q31_t)0x7AB6CBA3, (q31_t)0xDB3832CD, - (q31_t)0x7A9A0E4F, (q31_t)0xDAD7F3A2, (q31_t)0x7A7D055B, - (q31_t)0xDA77CB62, (q31_t)0x7A5FB0D8, (q31_t)0xDA17BA4A, - (q31_t)0x7A4210D8, (q31_t)0xD9B7C093, (q31_t)0x7A24256E, - (q31_t)0xD957DE7A, (q31_t)0x7A05EEAD, (q31_t)0xD8F81439, - (q31_t)0x79E76CA6, (q31_t)0xD898620C, (q31_t)0x79C89F6D, - (q31_t)0xD838C82D, (q31_t)0x79A98715, (q31_t)0xD7D946D7, - (q31_t)0x798A23B1, (q31_t)0xD779DE46, (q31_t)0x796A7554, - (q31_t)0xD71A8EB5, (q31_t)0x794A7C11, (q31_t)0xD6BB585D, - (q31_t)0x792A37FE, (q31_t)0xD65C3B7B, (q31_t)0x7909A92C, - (q31_t)0xD5FD3847, (q31_t)0x78E8CFB1, (q31_t)0xD59E4EFE, - (q31_t)0x78C7ABA1, (q31_t)0xD53F7FDA, (q31_t)0x78A63D10, - (q31_t)0xD4E0CB14, (q31_t)0x78848413, (q31_t)0xD48230E8, - (q31_t)0x786280BF, (q31_t)0xD423B190, (q31_t)0x78403328, - (q31_t)0xD3C54D46, (q31_t)0x781D9B64, (q31_t)0xD3670445, - (q31_t)0x77FAB988, (q31_t)0xD308D6C6, (q31_t)0x77D78DAA, - (q31_t)0xD2AAC504, (q31_t)0x77B417DF, (q31_t)0xD24CCF38, - (q31_t)0x7790583D, (q31_t)0xD1EEF59E, (q31_t)0x776C4EDB, - (q31_t)0xD191386D, (q31_t)0x7747FBCE, (q31_t)0xD13397E1, - (q31_t)0x77235F2D, (q31_t)0xD0D61433, (q31_t)0x76FE790E, - (q31_t)0xD078AD9D, (q31_t)0x76D94988, (q31_t)0xD01B6459, - (q31_t)0x76B3D0B3, (q31_t)0xCFBE389F, (q31_t)0x768E0EA5, - (q31_t)0xCF612AAA, (q31_t)0x76680376, (q31_t)0xCF043AB2, - (q31_t)0x7641AF3C, (q31_t)0xCEA768F2, (q31_t)0x761B1211, - (q31_t)0xCE4AB5A2, (q31_t)0x75F42C0A, (q31_t)0xCDEE20FC, - (q31_t)0x75CCFD42, (q31_t)0xCD91AB38, (q31_t)0x75A585CF, - (q31_t)0xCD355490, (q31_t)0x757DC5CA, (q31_t)0xCCD91D3D, - (q31_t)0x7555BD4B, (q31_t)0xCC7D0577, (q31_t)0x752D6C6C, - (q31_t)0xCC210D78, (q31_t)0x7504D345, (q31_t)0xCBC53578, - (q31_t)0x74DBF1EF, (q31_t)0xCB697DB0, (q31_t)0x74B2C883, - (q31_t)0xCB0DE658, (q31_t)0x7489571B, (q31_t)0xCAB26FA9, - (q31_t)0x745F9DD1, (q31_t)0xCA5719DB, (q31_t)0x74359CBD, - (q31_t)0xC9FBE527, (q31_t)0x740B53FA, (q31_t)0xC9A0D1C4, - (q31_t)0x73E0C3A3, (q31_t)0xC945DFEC, (q31_t)0x73B5EBD0, - (q31_t)0xC8EB0FD6, (q31_t)0x738ACC9E, (q31_t)0xC89061BA, - (q31_t)0x735F6626, (q31_t)0xC835D5D0, (q31_t)0x7333B883, - (q31_t)0xC7DB6C50, (q31_t)0x7307C3D0, (q31_t)0xC7812571, - (q31_t)0x72DB8828, (q31_t)0xC727016C, (q31_t)0x72AF05A6, - (q31_t)0xC6CD0079, (q31_t)0x72823C66, (q31_t)0xC67322CD, - (q31_t)0x72552C84, (q31_t)0xC61968A2, (q31_t)0x7227D61C, - (q31_t)0xC5BFD22E, (q31_t)0x71FA3948, (q31_t)0xC5665FA8, - (q31_t)0x71CC5626, (q31_t)0xC50D1148, (q31_t)0x719E2CD2, - (q31_t)0xC4B3E746, (q31_t)0x716FBD68, (q31_t)0xC45AE1D7, - (q31_t)0x71410804, (q31_t)0xC4020132, (q31_t)0x71120CC5, - (q31_t)0xC3A9458F, (q31_t)0x70E2CBC6, (q31_t)0xC350AF25, - (q31_t)0x70B34524, (q31_t)0xC2F83E2A, (q31_t)0x708378FE, - (q31_t)0xC29FF2D4, (q31_t)0x70536771, (q31_t)0xC247CD5A, - (q31_t)0x70231099, (q31_t)0xC1EFCDF2, (q31_t)0x6FF27496, - (q31_t)0xC197F4D3, (q31_t)0x6FC19385, (q31_t)0xC1404233, - (q31_t)0x6F906D84, (q31_t)0xC0E8B648, (q31_t)0x6F5F02B1, - (q31_t)0xC0915147, (q31_t)0x6F2D532C, (q31_t)0xC03A1368, - (q31_t)0x6EFB5F12, (q31_t)0xBFE2FCDF, (q31_t)0x6EC92682, - (q31_t)0xBF8C0DE2, (q31_t)0x6E96A99C, (q31_t)0xBF3546A8, - (q31_t)0x6E63E87F, (q31_t)0xBEDEA765, (q31_t)0x6E30E349, - (q31_t)0xBE88304F, (q31_t)0x6DFD9A1B, (q31_t)0xBE31E19B, - (q31_t)0x6DCA0D14, (q31_t)0xBDDBBB7F, (q31_t)0x6D963C54, - (q31_t)0xBD85BE2F, (q31_t)0x6D6227FA, (q31_t)0xBD2FE9E1, - (q31_t)0x6D2DD027, (q31_t)0xBCDA3ECA, (q31_t)0x6CF934FB, - (q31_t)0xBC84BD1E, (q31_t)0x6CC45697, (q31_t)0xBC2F6513, - (q31_t)0x6C8F351C, (q31_t)0xBBDA36DC, (q31_t)0x6C59D0A9, - (q31_t)0xBB8532AF, (q31_t)0x6C242960, (q31_t)0xBB3058C0, - (q31_t)0x6BEE3F62, (q31_t)0xBADBA943, (q31_t)0x6BB812D0, - (q31_t)0xBA87246C, (q31_t)0x6B81A3CD, (q31_t)0xBA32CA70, - (q31_t)0x6B4AF278, (q31_t)0xB9DE9B83, (q31_t)0x6B13FEF5, - (q31_t)0xB98A97D8, (q31_t)0x6ADCC964, (q31_t)0xB936BFA3, - (q31_t)0x6AA551E8, (q31_t)0xB8E31319, (q31_t)0x6A6D98A4, - (q31_t)0xB88F926C, (q31_t)0x6A359DB9, (q31_t)0xB83C3DD1, - (q31_t)0x69FD614A, (q31_t)0xB7E9157A, (q31_t)0x69C4E37A, - (q31_t)0xB796199B, (q31_t)0x698C246C, (q31_t)0xB7434A67, - (q31_t)0x69532442, (q31_t)0xB6F0A811, (q31_t)0x6919E320, - (q31_t)0xB69E32CD, (q31_t)0x68E06129, (q31_t)0xB64BEACC, - (q31_t)0x68A69E81, (q31_t)0xB5F9D042, (q31_t)0x686C9B4B, - (q31_t)0xB5A7E362, (q31_t)0x683257AA, (q31_t)0xB556245E, - (q31_t)0x67F7D3C4, (q31_t)0xB5049368, (q31_t)0x67BD0FBC, - (q31_t)0xB4B330B2, (q31_t)0x67820BB6, (q31_t)0xB461FC70, - (q31_t)0x6746C7D7, (q31_t)0xB410F6D2, (q31_t)0x670B4443, - (q31_t)0xB3C0200C, (q31_t)0x66CF811F, (q31_t)0xB36F784E, - (q31_t)0x66937E90, (q31_t)0xB31EFFCB, (q31_t)0x66573CBB, - (q31_t)0xB2CEB6B5, (q31_t)0x661ABBC5, (q31_t)0xB27E9D3B, - (q31_t)0x65DDFBD3, (q31_t)0xB22EB392, (q31_t)0x65A0FD0B, - (q31_t)0xB1DEF9E8, (q31_t)0x6563BF92, (q31_t)0xB18F7070, - (q31_t)0x6526438E, (q31_t)0xB140175B, (q31_t)0x64E88926, - (q31_t)0xB0F0EEDA, (q31_t)0x64AA907F, (q31_t)0xB0A1F71C, - (q31_t)0x646C59BF, (q31_t)0xB0533055, (q31_t)0x642DE50D, - (q31_t)0xB0049AB2, (q31_t)0x63EF328F, (q31_t)0xAFB63667, - (q31_t)0x63B0426D, (q31_t)0xAF6803A1, (q31_t)0x637114CC, - (q31_t)0xAF1A0293, (q31_t)0x6331A9D4, (q31_t)0xAECC336B, - (q31_t)0x62F201AC, (q31_t)0xAE7E965B, (q31_t)0x62B21C7B, - (q31_t)0xAE312B91, (q31_t)0x6271FA69, (q31_t)0xADE3F33E, - (q31_t)0x62319B9D, (q31_t)0xAD96ED91, (q31_t)0x61F1003E, - (q31_t)0xAD4A1ABA, (q31_t)0x61B02876, (q31_t)0xACFD7AE8, - (q31_t)0x616F146B, (q31_t)0xACB10E4A, (q31_t)0x612DC446, - (q31_t)0xAC64D510, (q31_t)0x60EC3830, (q31_t)0xAC18CF68, - (q31_t)0x60AA704F, (q31_t)0xABCCFD82, (q31_t)0x60686CCE, - (q31_t)0xAB815F8C, (q31_t)0x60262DD5, (q31_t)0xAB35F5B5, - (q31_t)0x5FE3B38D, (q31_t)0xAAEAC02B, (q31_t)0x5FA0FE1E, - (q31_t)0xAA9FBF1D, (q31_t)0x5F5E0DB3, (q31_t)0xAA54F2B9, - (q31_t)0x5F1AE273, (q31_t)0xAA0A5B2D, (q31_t)0x5ED77C89, - (q31_t)0xA9BFF8A8, (q31_t)0x5E93DC1F, (q31_t)0xA975CB56, - (q31_t)0x5E50015D, (q31_t)0xA92BD366, (q31_t)0x5E0BEC6E, - (q31_t)0xA8E21106, (q31_t)0x5DC79D7C, (q31_t)0xA8988463, - (q31_t)0x5D8314B0, (q31_t)0xA84F2DA9, (q31_t)0x5D3E5236, - (q31_t)0xA8060D08, (q31_t)0x5CF95638, (q31_t)0xA7BD22AB, - (q31_t)0x5CB420DF, (q31_t)0xA7746EC0, (q31_t)0x5C6EB258, - (q31_t)0xA72BF173, (q31_t)0x5C290ACC, (q31_t)0xA6E3AAF2, - (q31_t)0x5BE32A67, (q31_t)0xA69B9B68, (q31_t)0x5B9D1153, - (q31_t)0xA653C302, (q31_t)0x5B56BFBD, (q31_t)0xA60C21ED, - (q31_t)0x5B1035CF, (q31_t)0xA5C4B855, (q31_t)0x5AC973B4, - (q31_t)0xA57D8666, (q31_t)0x5A82799A, (q31_t)0xA5368C4B, - (q31_t)0x5A3B47AA, (q31_t)0xA4EFCA31, (q31_t)0x59F3DE12, - (q31_t)0xA4A94042, (q31_t)0x59AC3CFD, (q31_t)0xA462EEAC, - (q31_t)0x59646497, (q31_t)0xA41CD598, (q31_t)0x591C550E, - (q31_t)0xA3D6F533, (q31_t)0x58D40E8C, (q31_t)0xA3914DA7, - (q31_t)0x588B913F, (q31_t)0xA34BDF20, (q31_t)0x5842DD54, - (q31_t)0xA306A9C7, (q31_t)0x57F9F2F7, (q31_t)0xA2C1ADC9, - (q31_t)0x57B0D256, (q31_t)0xA27CEB4F, (q31_t)0x57677B9D, - (q31_t)0xA2386283, (q31_t)0x571DEEF9, (q31_t)0xA1F41391, - (q31_t)0x56D42C99, (q31_t)0xA1AFFEA2, (q31_t)0x568A34A9, - (q31_t)0xA16C23E1, (q31_t)0x56400757, (q31_t)0xA1288376, - (q31_t)0x55F5A4D2, (q31_t)0xA0E51D8C, (q31_t)0x55AB0D46, - (q31_t)0xA0A1F24C, (q31_t)0x556040E2, (q31_t)0xA05F01E1, - (q31_t)0x55153FD4, (q31_t)0xA01C4C72, (q31_t)0x54CA0A4A, - (q31_t)0x9FD9D22A, (q31_t)0x547EA073, (q31_t)0x9F979331, - (q31_t)0x5433027D, (q31_t)0x9F558FB0, (q31_t)0x53E73097, - (q31_t)0x9F13C7D0, (q31_t)0x539B2AEF, (q31_t)0x9ED23BB9, - (q31_t)0x534EF1B5, (q31_t)0x9E90EB94, (q31_t)0x53028517, - (q31_t)0x9E4FD789, (q31_t)0x52B5E545, (q31_t)0x9E0EFFC1, - (q31_t)0x5269126E, (q31_t)0x9DCE6462, (q31_t)0x521C0CC1, - (q31_t)0x9D8E0596, (q31_t)0x51CED46E, (q31_t)0x9D4DE384, - (q31_t)0x518169A4, (q31_t)0x9D0DFE53, (q31_t)0x5133CC94, - (q31_t)0x9CCE562B, (q31_t)0x50E5FD6C, (q31_t)0x9C8EEB33, - (q31_t)0x5097FC5E, (q31_t)0x9C4FBD92, (q31_t)0x5049C999, - (q31_t)0x9C10CD70, (q31_t)0x4FFB654D, (q31_t)0x9BD21AF2, - (q31_t)0x4FACCFAB, (q31_t)0x9B93A640, (q31_t)0x4F5E08E3, - (q31_t)0x9B556F80, (q31_t)0x4F0F1126, (q31_t)0x9B1776D9, - (q31_t)0x4EBFE8A4, (q31_t)0x9AD9BC71, (q31_t)0x4E708F8F, - (q31_t)0x9A9C406D, (q31_t)0x4E210617, (q31_t)0x9A5F02F5, - (q31_t)0x4DD14C6E, (q31_t)0x9A22042C, (q31_t)0x4D8162C4, - (q31_t)0x99E5443A, (q31_t)0x4D31494B, (q31_t)0x99A8C344, - (q31_t)0x4CE10034, (q31_t)0x996C816F, (q31_t)0x4C9087B1, - (q31_t)0x99307EE0, (q31_t)0x4C3FDFF3, (q31_t)0x98F4BBBC, - (q31_t)0x4BEF092D, (q31_t)0x98B93828, (q31_t)0x4B9E038F, - (q31_t)0x987DF449, (q31_t)0x4B4CCF4D, (q31_t)0x9842F043, - (q31_t)0x4AFB6C97, (q31_t)0x98082C3B, (q31_t)0x4AA9DBA1, - (q31_t)0x97CDA855, (q31_t)0x4A581C9D, (q31_t)0x979364B5, - (q31_t)0x4A062FBD, (q31_t)0x9759617E, (q31_t)0x49B41533, - (q31_t)0x971F9ED6, (q31_t)0x4961CD32, (q31_t)0x96E61CDF, - (q31_t)0x490F57EE, (q31_t)0x96ACDBBD, (q31_t)0x48BCB598, - (q31_t)0x9673DB94, (q31_t)0x4869E664, (q31_t)0x963B1C85, - (q31_t)0x4816EA85, (q31_t)0x96029EB5, (q31_t)0x47C3C22E, - (q31_t)0x95CA6246, (q31_t)0x47706D93, (q31_t)0x9592675B, - (q31_t)0x471CECE6, (q31_t)0x955AAE17, (q31_t)0x46C9405C, - (q31_t)0x9523369B, (q31_t)0x46756827, (q31_t)0x94EC010B, - (q31_t)0x4621647C, (q31_t)0x94B50D87, (q31_t)0x45CD358F, - (q31_t)0x947E5C32, (q31_t)0x4578DB93, (q31_t)0x9447ED2F, - (q31_t)0x452456BC, (q31_t)0x9411C09D, (q31_t)0x44CFA73F, - (q31_t)0x93DBD69F, (q31_t)0x447ACD50, (q31_t)0x93A62F56, - (q31_t)0x4425C923, (q31_t)0x9370CAE4, (q31_t)0x43D09AEC, - (q31_t)0x933BA968, (q31_t)0x437B42E1, (q31_t)0x9306CB04, - (q31_t)0x4325C135, (q31_t)0x92D22FD8, (q31_t)0x42D0161E, - (q31_t)0x929DD805, (q31_t)0x427A41D0, (q31_t)0x9269C3AC, - (q31_t)0x42244480, (q31_t)0x9235F2EB, (q31_t)0x41CE1E64, - (q31_t)0x920265E4, (q31_t)0x4177CFB0, (q31_t)0x91CF1CB6, - (q31_t)0x4121589A, (q31_t)0x919C1780, (q31_t)0x40CAB957, - (q31_t)0x91695663, (q31_t)0x4073F21D, (q31_t)0x9136D97D, - (q31_t)0x401D0320, (q31_t)0x9104A0ED, (q31_t)0x3FC5EC97, - (q31_t)0x90D2ACD3, (q31_t)0x3F6EAEB8, (q31_t)0x90A0FD4E, - (q31_t)0x3F1749B7, (q31_t)0x906F927B, (q31_t)0x3EBFBDCC, - (q31_t)0x903E6C7A, (q31_t)0x3E680B2C, (q31_t)0x900D8B69, - (q31_t)0x3E10320D, (q31_t)0x8FDCEF66, (q31_t)0x3DB832A5, - (q31_t)0x8FAC988E, (q31_t)0x3D600D2B, (q31_t)0x8F7C8701, - (q31_t)0x3D07C1D5, (q31_t)0x8F4CBADB, (q31_t)0x3CAF50DA, - (q31_t)0x8F1D343A, (q31_t)0x3C56BA70, (q31_t)0x8EEDF33B, - (q31_t)0x3BFDFECD, (q31_t)0x8EBEF7FB, (q31_t)0x3BA51E29, - (q31_t)0x8E904298, (q31_t)0x3B4C18BA, (q31_t)0x8E61D32D, - (q31_t)0x3AF2EEB7, (q31_t)0x8E33A9D9, (q31_t)0x3A99A057, - (q31_t)0x8E05C6B7, (q31_t)0x3A402DD1, (q31_t)0x8DD829E4, - (q31_t)0x39E6975D, (q31_t)0x8DAAD37B, (q31_t)0x398CDD32, - (q31_t)0x8D7DC399, (q31_t)0x3932FF87, (q31_t)0x8D50FA59, - (q31_t)0x38D8FE93, (q31_t)0x8D2477D8, (q31_t)0x387EDA8E, - (q31_t)0x8CF83C30, (q31_t)0x382493B0, (q31_t)0x8CCC477D, - (q31_t)0x37CA2A30, (q31_t)0x8CA099D9, (q31_t)0x376F9E46, - (q31_t)0x8C753361, (q31_t)0x3714F02A, (q31_t)0x8C4A142F, - (q31_t)0x36BA2013, (q31_t)0x8C1F3C5C, (q31_t)0x365F2E3B, - (q31_t)0x8BF4AC05, (q31_t)0x36041AD9, (q31_t)0x8BCA6342, - (q31_t)0x35A8E624, (q31_t)0x8BA0622F, (q31_t)0x354D9056, - (q31_t)0x8B76A8E4, (q31_t)0x34F219A7, (q31_t)0x8B4D377C, - (q31_t)0x3496824F, (q31_t)0x8B240E10, (q31_t)0x343ACA87, - (q31_t)0x8AFB2CBA, (q31_t)0x33DEF287, (q31_t)0x8AD29393, - (q31_t)0x3382FA88, (q31_t)0x8AAA42B4, (q31_t)0x3326E2C2, - (q31_t)0x8A823A35, (q31_t)0x32CAAB6F, (q31_t)0x8A5A7A30, - (q31_t)0x326E54C7, (q31_t)0x8A3302BD, (q31_t)0x3211DF03, - (q31_t)0x8A0BD3F5, (q31_t)0x31B54A5D, (q31_t)0x89E4EDEE, - (q31_t)0x3158970D, (q31_t)0x89BE50C3, (q31_t)0x30FBC54D, - (q31_t)0x8997FC89, (q31_t)0x309ED555, (q31_t)0x8971F15A, - (q31_t)0x3041C760, (q31_t)0x894C2F4C, (q31_t)0x2FE49BA6, - (q31_t)0x8926B677, (q31_t)0x2F875262, (q31_t)0x890186F1, - (q31_t)0x2F29EBCC, (q31_t)0x88DCA0D3, (q31_t)0x2ECC681E, - (q31_t)0x88B80431, (q31_t)0x2E6EC792, (q31_t)0x8893B124, - (q31_t)0x2E110A62, (q31_t)0x886FA7C2, (q31_t)0x2DB330C7, - (q31_t)0x884BE820, (q31_t)0x2D553AFB, (q31_t)0x88287255, - (q31_t)0x2CF72939, (q31_t)0x88054677, (q31_t)0x2C98FBBA, - (q31_t)0x87E2649B, (q31_t)0x2C3AB2B9, (q31_t)0x87BFCCD7, - (q31_t)0x2BDC4E6F, (q31_t)0x879D7F40, (q31_t)0x2B7DCF17, - (q31_t)0x877B7BEC, (q31_t)0x2B1F34EB, (q31_t)0x8759C2EF, - (q31_t)0x2AC08025, (q31_t)0x8738545E, (q31_t)0x2A61B101, - (q31_t)0x8717304E, (q31_t)0x2A02C7B8, (q31_t)0x86F656D3, - (q31_t)0x29A3C484, (q31_t)0x86D5C802, (q31_t)0x2944A7A2, - (q31_t)0x86B583EE, (q31_t)0x28E5714A, (q31_t)0x86958AAB, - (q31_t)0x288621B9, (q31_t)0x8675DC4E, (q31_t)0x2826B928, - (q31_t)0x865678EA, (q31_t)0x27C737D2, (q31_t)0x86376092, - (q31_t)0x27679DF4, (q31_t)0x86189359, (q31_t)0x2707EBC6, - (q31_t)0x85FA1152, (q31_t)0x26A82185, (q31_t)0x85DBDA91, - (q31_t)0x26483F6C, (q31_t)0x85BDEF27, (q31_t)0x25E845B5, - (q31_t)0x85A04F28, (q31_t)0x2588349D, (q31_t)0x8582FAA4, - (q31_t)0x25280C5D, (q31_t)0x8565F1B0, (q31_t)0x24C7CD32, - (q31_t)0x8549345C, (q31_t)0x24677757, (q31_t)0x852CC2BA, - (q31_t)0x24070B07, (q31_t)0x85109CDC, (q31_t)0x23A6887E, - (q31_t)0x84F4C2D3, (q31_t)0x2345EFF7, (q31_t)0x84D934B0, - (q31_t)0x22E541AE, (q31_t)0x84BDF285, (q31_t)0x22847DDF, - (q31_t)0x84A2FC62, (q31_t)0x2223A4C5, (q31_t)0x84885257, - (q31_t)0x21C2B69C, (q31_t)0x846DF476, (q31_t)0x2161B39F, - (q31_t)0x8453E2CE, (q31_t)0x21009C0B, (q31_t)0x843A1D70, - (q31_t)0x209F701C, (q31_t)0x8420A46B, (q31_t)0x203E300D, - (q31_t)0x840777CF, (q31_t)0x1FDCDC1A, (q31_t)0x83EE97AC, - (q31_t)0x1F7B7480, (q31_t)0x83D60411, (q31_t)0x1F19F97B, - (q31_t)0x83BDBD0D, (q31_t)0x1EB86B46, (q31_t)0x83A5C2B0, - (q31_t)0x1E56CA1E, (q31_t)0x838E1507, (q31_t)0x1DF5163F, - (q31_t)0x8376B422, (q31_t)0x1D934FE5, (q31_t)0x835FA00E, - (q31_t)0x1D31774D, (q31_t)0x8348D8DB, (q31_t)0x1CCF8CB3, - (q31_t)0x83325E97, (q31_t)0x1C6D9053, (q31_t)0x831C314E, - (q31_t)0x1C0B826A, (q31_t)0x8306510F, (q31_t)0x1BA96334, - (q31_t)0x82F0BDE8, (q31_t)0x1B4732EF, (q31_t)0x82DB77E5, - (q31_t)0x1AE4F1D6, (q31_t)0x82C67F13, (q31_t)0x1A82A025, - (q31_t)0x82B1D381, (q31_t)0x1A203E1B, (q31_t)0x829D753A, - (q31_t)0x19BDCBF2, (q31_t)0x8289644A, (q31_t)0x195B49E9, - (q31_t)0x8275A0C0, (q31_t)0x18F8B83C, (q31_t)0x82622AA5, - (q31_t)0x18961727, (q31_t)0x824F0208, (q31_t)0x183366E8, - (q31_t)0x823C26F2, (q31_t)0x17D0A7BB, (q31_t)0x82299971, - (q31_t)0x176DD9DE, (q31_t)0x8217598F, (q31_t)0x170AFD8D, - (q31_t)0x82056758, (q31_t)0x16A81305, (q31_t)0x81F3C2D7, - (q31_t)0x16451A83, (q31_t)0x81E26C16, (q31_t)0x15E21444, - (q31_t)0x81D16320, (q31_t)0x157F0086, (q31_t)0x81C0A801, - (q31_t)0x151BDF85, (q31_t)0x81B03AC1, (q31_t)0x14B8B17F, - (q31_t)0x81A01B6C, (q31_t)0x145576B1, (q31_t)0x81904A0C, - (q31_t)0x13F22F57, (q31_t)0x8180C6A9, (q31_t)0x138EDBB0, - (q31_t)0x8171914E, (q31_t)0x132B7BF9, (q31_t)0x8162AA03, - (q31_t)0x12C8106E, (q31_t)0x815410D3, (q31_t)0x1264994E, - (q31_t)0x8145C5C6, (q31_t)0x120116D4, (q31_t)0x8137C8E6, - (q31_t)0x119D8940, (q31_t)0x812A1A39, (q31_t)0x1139F0CE, - (q31_t)0x811CB9CA, (q31_t)0x10D64DBC, (q31_t)0x810FA7A0, - (q31_t)0x1072A047, (q31_t)0x8102E3C3, (q31_t)0x100EE8AD, - (q31_t)0x80F66E3C, (q31_t)0x0FAB272B, (q31_t)0x80EA4712, - (q31_t)0x0F475BFE, (q31_t)0x80DE6E4C, (q31_t)0x0EE38765, - (q31_t)0x80D2E3F1, (q31_t)0x0E7FA99D, (q31_t)0x80C7A80A, - (q31_t)0x0E1BC2E3, (q31_t)0x80BCBA9C, (q31_t)0x0DB7D376, - (q31_t)0x80B21BAF, (q31_t)0x0D53DB92, (q31_t)0x80A7CB49, - (q31_t)0x0CEFDB75, (q31_t)0x809DC970, (q31_t)0x0C8BD35E, - (q31_t)0x8094162B, (q31_t)0x0C27C389, (q31_t)0x808AB180, - (q31_t)0x0BC3AC35, (q31_t)0x80819B74, (q31_t)0x0B5F8D9F, - (q31_t)0x8078D40D, (q31_t)0x0AFB6805, (q31_t)0x80705B50, - (q31_t)0x0A973BA5, (q31_t)0x80683143, (q31_t)0x0A3308BC, - (q31_t)0x806055EA, (q31_t)0x09CECF89, (q31_t)0x8058C94C, - (q31_t)0x096A9049, (q31_t)0x80518B6B, (q31_t)0x09064B3A, - (q31_t)0x804A9C4D, (q31_t)0x08A2009A, (q31_t)0x8043FBF6, - (q31_t)0x083DB0A7, (q31_t)0x803DAA69, (q31_t)0x07D95B9E, - (q31_t)0x8037A7AC, (q31_t)0x077501BE, (q31_t)0x8031F3C1, - (q31_t)0x0710A344, (q31_t)0x802C8EAD, (q31_t)0x06AC406F, - (q31_t)0x80277872, (q31_t)0x0647D97C, (q31_t)0x8022B113, - (q31_t)0x05E36EA9, (q31_t)0x801E3894, (q31_t)0x057F0034, - (q31_t)0x801A0EF7, (q31_t)0x051A8E5C, (q31_t)0x80163440, - (q31_t)0x04B6195D, (q31_t)0x8012A86F, (q31_t)0x0451A176, - (q31_t)0x800F6B88, (q31_t)0x03ED26E6, (q31_t)0x800C7D8C, - (q31_t)0x0388A9E9, (q31_t)0x8009DE7D, (q31_t)0x03242ABF, - (q31_t)0x80078E5E, (q31_t)0x02BFA9A4, (q31_t)0x80058D2E, - (q31_t)0x025B26D7, (q31_t)0x8003DAF0, (q31_t)0x01F6A296, - (q31_t)0x800277A5, (q31_t)0x01921D1F, (q31_t)0x8001634D, - (q31_t)0x012D96B0, (q31_t)0x80009DE9, (q31_t)0x00C90F88, - (q31_t)0x8000277A, (q31_t)0x006487E3, (q31_t)0x80000000, - (q31_t)0x00000000, (q31_t)0x8000277A, (q31_t)0xFF9B781D, - (q31_t)0x80009DE9, (q31_t)0xFF36F078, (q31_t)0x8001634D, - (q31_t)0xFED2694F, (q31_t)0x800277A5, (q31_t)0xFE6DE2E0, - (q31_t)0x8003DAF0, (q31_t)0xFE095D69, (q31_t)0x80058D2E, - (q31_t)0xFDA4D928, (q31_t)0x80078E5E, (q31_t)0xFD40565B, - (q31_t)0x8009DE7D, (q31_t)0xFCDBD541, (q31_t)0x800C7D8C, - (q31_t)0xFC775616, (q31_t)0x800F6B88, (q31_t)0xFC12D919, - (q31_t)0x8012A86F, (q31_t)0xFBAE5E89, (q31_t)0x80163440, - (q31_t)0xFB49E6A2, (q31_t)0x801A0EF7, (q31_t)0xFAE571A4, - (q31_t)0x801E3894, (q31_t)0xFA80FFCB, (q31_t)0x8022B113, - (q31_t)0xFA1C9156, (q31_t)0x80277872, (q31_t)0xF9B82683, - (q31_t)0x802C8EAD, (q31_t)0xF953BF90, (q31_t)0x8031F3C1, - (q31_t)0xF8EF5CBB, (q31_t)0x8037A7AC, (q31_t)0xF88AFE41, - (q31_t)0x803DAA69, (q31_t)0xF826A461, (q31_t)0x8043FBF6, - (q31_t)0xF7C24F58, (q31_t)0x804A9C4D, (q31_t)0xF75DFF65, - (q31_t)0x80518B6B, (q31_t)0xF6F9B4C5, (q31_t)0x8058C94C, - (q31_t)0xF6956FB6, (q31_t)0x806055EA, (q31_t)0xF6313076, - (q31_t)0x80683143, (q31_t)0xF5CCF743, (q31_t)0x80705B50, - (q31_t)0xF568C45A, (q31_t)0x8078D40D, (q31_t)0xF50497FA, - (q31_t)0x80819B74, (q31_t)0xF4A07260, (q31_t)0x808AB180, - (q31_t)0xF43C53CA, (q31_t)0x8094162B, (q31_t)0xF3D83C76, - (q31_t)0x809DC970, (q31_t)0xF3742CA1, (q31_t)0x80A7CB49, - (q31_t)0xF310248A, (q31_t)0x80B21BAF, (q31_t)0xF2AC246D, - (q31_t)0x80BCBA9C, (q31_t)0xF2482C89, (q31_t)0x80C7A80A, - (q31_t)0xF1E43D1C, (q31_t)0x80D2E3F1, (q31_t)0xF1805662, - (q31_t)0x80DE6E4C, (q31_t)0xF11C789A, (q31_t)0x80EA4712, - (q31_t)0xF0B8A401, (q31_t)0x80F66E3C, (q31_t)0xF054D8D4, - (q31_t)0x8102E3C3, (q31_t)0xEFF11752, (q31_t)0x810FA7A0, - (q31_t)0xEF8D5FB8, (q31_t)0x811CB9CA, (q31_t)0xEF29B243, - (q31_t)0x812A1A39, (q31_t)0xEEC60F31, (q31_t)0x8137C8E6, - (q31_t)0xEE6276BF, (q31_t)0x8145C5C6, (q31_t)0xEDFEE92B, - (q31_t)0x815410D3, (q31_t)0xED9B66B2, (q31_t)0x8162AA03, - (q31_t)0xED37EF91, (q31_t)0x8171914E, (q31_t)0xECD48406, - (q31_t)0x8180C6A9, (q31_t)0xEC71244F, (q31_t)0x81904A0C, - (q31_t)0xEC0DD0A8, (q31_t)0x81A01B6C, (q31_t)0xEBAA894E, - (q31_t)0x81B03AC1, (q31_t)0xEB474E80, (q31_t)0x81C0A801, - (q31_t)0xEAE4207A, (q31_t)0x81D16320, (q31_t)0xEA80FF79, - (q31_t)0x81E26C16, (q31_t)0xEA1DEBBB, (q31_t)0x81F3C2D7, - (q31_t)0xE9BAE57C, (q31_t)0x82056758, (q31_t)0xE957ECFB, - (q31_t)0x8217598F, (q31_t)0xE8F50273, (q31_t)0x82299971, - (q31_t)0xE8922621, (q31_t)0x823C26F2, (q31_t)0xE82F5844, - (q31_t)0x824F0208, (q31_t)0xE7CC9917, (q31_t)0x82622AA5, - (q31_t)0xE769E8D8, (q31_t)0x8275A0C0, (q31_t)0xE70747C3, - (q31_t)0x8289644A, (q31_t)0xE6A4B616, (q31_t)0x829D753A, - (q31_t)0xE642340D, (q31_t)0x82B1D381, (q31_t)0xE5DFC1E4, - (q31_t)0x82C67F13, (q31_t)0xE57D5FDA, (q31_t)0x82DB77E5, - (q31_t)0xE51B0E2A, (q31_t)0x82F0BDE8, (q31_t)0xE4B8CD10, - (q31_t)0x8306510F, (q31_t)0xE4569CCB, (q31_t)0x831C314E, - (q31_t)0xE3F47D95, (q31_t)0x83325E97, (q31_t)0xE3926FAC, - (q31_t)0x8348D8DB, (q31_t)0xE330734C, (q31_t)0x835FA00E, - (q31_t)0xE2CE88B2, (q31_t)0x8376B422, (q31_t)0xE26CB01A, - (q31_t)0x838E1507, (q31_t)0xE20AE9C1, (q31_t)0x83A5C2B0, - (q31_t)0xE1A935E1, (q31_t)0x83BDBD0D, (q31_t)0xE14794B9, - (q31_t)0x83D60411, (q31_t)0xE0E60684, (q31_t)0x83EE97AC, - (q31_t)0xE0848B7F, (q31_t)0x840777CF, (q31_t)0xE02323E5, - (q31_t)0x8420A46B, (q31_t)0xDFC1CFF2, (q31_t)0x843A1D70, - (q31_t)0xDF608FE3, (q31_t)0x8453E2CE, (q31_t)0xDEFF63F4, - (q31_t)0x846DF476, (q31_t)0xDE9E4C60, (q31_t)0x84885257, - (q31_t)0xDE3D4963, (q31_t)0x84A2FC62, (q31_t)0xDDDC5B3A, - (q31_t)0x84BDF285, (q31_t)0xDD7B8220, (q31_t)0x84D934B0, - (q31_t)0xDD1ABE51, (q31_t)0x84F4C2D3, (q31_t)0xDCBA1008, - (q31_t)0x85109CDC, (q31_t)0xDC597781, (q31_t)0x852CC2BA, - (q31_t)0xDBF8F4F8, (q31_t)0x8549345C, (q31_t)0xDB9888A8, - (q31_t)0x8565F1B0, (q31_t)0xDB3832CD, (q31_t)0x8582FAA4, - (q31_t)0xDAD7F3A2, (q31_t)0x85A04F28, (q31_t)0xDA77CB62, - (q31_t)0x85BDEF27, (q31_t)0xDA17BA4A, (q31_t)0x85DBDA91, - (q31_t)0xD9B7C093, (q31_t)0x85FA1152, (q31_t)0xD957DE7A, - (q31_t)0x86189359, (q31_t)0xD8F81439, (q31_t)0x86376092, - (q31_t)0xD898620C, (q31_t)0x865678EA, (q31_t)0xD838C82D, - (q31_t)0x8675DC4E, (q31_t)0xD7D946D7, (q31_t)0x86958AAB, - (q31_t)0xD779DE46, (q31_t)0x86B583EE, (q31_t)0xD71A8EB5, - (q31_t)0x86D5C802, (q31_t)0xD6BB585D, (q31_t)0x86F656D3, - (q31_t)0xD65C3B7B, (q31_t)0x8717304E, (q31_t)0xD5FD3847, - (q31_t)0x8738545E, (q31_t)0xD59E4EFE, (q31_t)0x8759C2EF, - (q31_t)0xD53F7FDA, (q31_t)0x877B7BEC, (q31_t)0xD4E0CB14, - (q31_t)0x879D7F40, (q31_t)0xD48230E8, (q31_t)0x87BFCCD7, - (q31_t)0xD423B190, (q31_t)0x87E2649B, (q31_t)0xD3C54D46, - (q31_t)0x88054677, (q31_t)0xD3670445, (q31_t)0x88287255, - (q31_t)0xD308D6C6, (q31_t)0x884BE820, (q31_t)0xD2AAC504, - (q31_t)0x886FA7C2, (q31_t)0xD24CCF38, (q31_t)0x8893B124, - (q31_t)0xD1EEF59E, (q31_t)0x88B80431, (q31_t)0xD191386D, - (q31_t)0x88DCA0D3, (q31_t)0xD13397E1, (q31_t)0x890186F1, - (q31_t)0xD0D61433, (q31_t)0x8926B677, (q31_t)0xD078AD9D, - (q31_t)0x894C2F4C, (q31_t)0xD01B6459, (q31_t)0x8971F15A, - (q31_t)0xCFBE389F, (q31_t)0x8997FC89, (q31_t)0xCF612AAA, - (q31_t)0x89BE50C3, (q31_t)0xCF043AB2, (q31_t)0x89E4EDEE, - (q31_t)0xCEA768F2, (q31_t)0x8A0BD3F5, (q31_t)0xCE4AB5A2, - (q31_t)0x8A3302BD, (q31_t)0xCDEE20FC, (q31_t)0x8A5A7A30, - (q31_t)0xCD91AB38, (q31_t)0x8A823A35, (q31_t)0xCD355490, - (q31_t)0x8AAA42B4, (q31_t)0xCCD91D3D, (q31_t)0x8AD29393, - (q31_t)0xCC7D0577, (q31_t)0x8AFB2CBA, (q31_t)0xCC210D78, - (q31_t)0x8B240E10, (q31_t)0xCBC53578, (q31_t)0x8B4D377C, - (q31_t)0xCB697DB0, (q31_t)0x8B76A8E4, (q31_t)0xCB0DE658, - (q31_t)0x8BA0622F, (q31_t)0xCAB26FA9, (q31_t)0x8BCA6342, - (q31_t)0xCA5719DB, (q31_t)0x8BF4AC05, (q31_t)0xC9FBE527, - (q31_t)0x8C1F3C5C, (q31_t)0xC9A0D1C4, (q31_t)0x8C4A142F, - (q31_t)0xC945DFEC, (q31_t)0x8C753361, (q31_t)0xC8EB0FD6, - (q31_t)0x8CA099D9, (q31_t)0xC89061BA, (q31_t)0x8CCC477D, - (q31_t)0xC835D5D0, (q31_t)0x8CF83C30, (q31_t)0xC7DB6C50, - (q31_t)0x8D2477D8, (q31_t)0xC7812571, (q31_t)0x8D50FA59, - (q31_t)0xC727016C, (q31_t)0x8D7DC399, (q31_t)0xC6CD0079, - (q31_t)0x8DAAD37B, (q31_t)0xC67322CD, (q31_t)0x8DD829E4, - (q31_t)0xC61968A2, (q31_t)0x8E05C6B7, (q31_t)0xC5BFD22E, - (q31_t)0x8E33A9D9, (q31_t)0xC5665FA8, (q31_t)0x8E61D32D, - (q31_t)0xC50D1148, (q31_t)0x8E904298, (q31_t)0xC4B3E746, - (q31_t)0x8EBEF7FB, (q31_t)0xC45AE1D7, (q31_t)0x8EEDF33B, - (q31_t)0xC4020132, (q31_t)0x8F1D343A, (q31_t)0xC3A9458F, - (q31_t)0x8F4CBADB, (q31_t)0xC350AF25, (q31_t)0x8F7C8701, - (q31_t)0xC2F83E2A, (q31_t)0x8FAC988E, (q31_t)0xC29FF2D4, - (q31_t)0x8FDCEF66, (q31_t)0xC247CD5A, (q31_t)0x900D8B69, - (q31_t)0xC1EFCDF2, (q31_t)0x903E6C7A, (q31_t)0xC197F4D3, - (q31_t)0x906F927B, (q31_t)0xC1404233, (q31_t)0x90A0FD4E, - (q31_t)0xC0E8B648, (q31_t)0x90D2ACD3, (q31_t)0xC0915147, - (q31_t)0x9104A0ED, (q31_t)0xC03A1368, (q31_t)0x9136D97D, - (q31_t)0xBFE2FCDF, (q31_t)0x91695663, (q31_t)0xBF8C0DE2, - (q31_t)0x919C1780, (q31_t)0xBF3546A8, (q31_t)0x91CF1CB6, - (q31_t)0xBEDEA765, (q31_t)0x920265E4, (q31_t)0xBE88304F, - (q31_t)0x9235F2EB, (q31_t)0xBE31E19B, (q31_t)0x9269C3AC, - (q31_t)0xBDDBBB7F, (q31_t)0x929DD805, (q31_t)0xBD85BE2F, - (q31_t)0x92D22FD8, (q31_t)0xBD2FE9E1, (q31_t)0x9306CB04, - (q31_t)0xBCDA3ECA, (q31_t)0x933BA968, (q31_t)0xBC84BD1E, - (q31_t)0x9370CAE4, (q31_t)0xBC2F6513, (q31_t)0x93A62F56, - (q31_t)0xBBDA36DC, (q31_t)0x93DBD69F, (q31_t)0xBB8532AF, - (q31_t)0x9411C09D, (q31_t)0xBB3058C0, (q31_t)0x9447ED2F, - (q31_t)0xBADBA943, (q31_t)0x947E5C32, (q31_t)0xBA87246C, - (q31_t)0x94B50D87, (q31_t)0xBA32CA70, (q31_t)0x94EC010B, - (q31_t)0xB9DE9B83, (q31_t)0x9523369B, (q31_t)0xB98A97D8, - (q31_t)0x955AAE17, (q31_t)0xB936BFA3, (q31_t)0x9592675B, - (q31_t)0xB8E31319, (q31_t)0x95CA6246, (q31_t)0xB88F926C, - (q31_t)0x96029EB5, (q31_t)0xB83C3DD1, (q31_t)0x963B1C85, - (q31_t)0xB7E9157A, (q31_t)0x9673DB94, (q31_t)0xB796199B, - (q31_t)0x96ACDBBD, (q31_t)0xB7434A67, (q31_t)0x96E61CDF, - (q31_t)0xB6F0A811, (q31_t)0x971F9ED6, (q31_t)0xB69E32CD, - (q31_t)0x9759617E, (q31_t)0xB64BEACC, (q31_t)0x979364B5, - (q31_t)0xB5F9D042, (q31_t)0x97CDA855, (q31_t)0xB5A7E362, - (q31_t)0x98082C3B, (q31_t)0xB556245E, (q31_t)0x9842F043, - (q31_t)0xB5049368, (q31_t)0x987DF449, (q31_t)0xB4B330B2, - (q31_t)0x98B93828, (q31_t)0xB461FC70, (q31_t)0x98F4BBBC, - (q31_t)0xB410F6D2, (q31_t)0x99307EE0, (q31_t)0xB3C0200C, - (q31_t)0x996C816F, (q31_t)0xB36F784E, (q31_t)0x99A8C344, - (q31_t)0xB31EFFCB, (q31_t)0x99E5443A, (q31_t)0xB2CEB6B5, - (q31_t)0x9A22042C, (q31_t)0xB27E9D3B, (q31_t)0x9A5F02F5, - (q31_t)0xB22EB392, (q31_t)0x9A9C406D, (q31_t)0xB1DEF9E8, - (q31_t)0x9AD9BC71, (q31_t)0xB18F7070, (q31_t)0x9B1776D9, - (q31_t)0xB140175B, (q31_t)0x9B556F80, (q31_t)0xB0F0EEDA, - (q31_t)0x9B93A640, (q31_t)0xB0A1F71C, (q31_t)0x9BD21AF2, - (q31_t)0xB0533055, (q31_t)0x9C10CD70, (q31_t)0xB0049AB2, - (q31_t)0x9C4FBD92, (q31_t)0xAFB63667, (q31_t)0x9C8EEB33, - (q31_t)0xAF6803A1, (q31_t)0x9CCE562B, (q31_t)0xAF1A0293, - (q31_t)0x9D0DFE53, (q31_t)0xAECC336B, (q31_t)0x9D4DE384, - (q31_t)0xAE7E965B, (q31_t)0x9D8E0596, (q31_t)0xAE312B91, - (q31_t)0x9DCE6462, (q31_t)0xADE3F33E, (q31_t)0x9E0EFFC1, - (q31_t)0xAD96ED91, (q31_t)0x9E4FD789, (q31_t)0xAD4A1ABA, - (q31_t)0x9E90EB94, (q31_t)0xACFD7AE8, (q31_t)0x9ED23BB9, - (q31_t)0xACB10E4A, (q31_t)0x9F13C7D0, (q31_t)0xAC64D510, - (q31_t)0x9F558FB0, (q31_t)0xAC18CF68, (q31_t)0x9F979331, - (q31_t)0xABCCFD82, (q31_t)0x9FD9D22A, (q31_t)0xAB815F8C, - (q31_t)0xA01C4C72, (q31_t)0xAB35F5B5, (q31_t)0xA05F01E1, - (q31_t)0xAAEAC02B, (q31_t)0xA0A1F24C, (q31_t)0xAA9FBF1D, - (q31_t)0xA0E51D8C, (q31_t)0xAA54F2B9, (q31_t)0xA1288376, - (q31_t)0xAA0A5B2D, (q31_t)0xA16C23E1, (q31_t)0xA9BFF8A8, - (q31_t)0xA1AFFEA2, (q31_t)0xA975CB56, (q31_t)0xA1F41391, - (q31_t)0xA92BD366, (q31_t)0xA2386283, (q31_t)0xA8E21106, - (q31_t)0xA27CEB4F, (q31_t)0xA8988463, (q31_t)0xA2C1ADC9, - (q31_t)0xA84F2DA9, (q31_t)0xA306A9C7, (q31_t)0xA8060D08, - (q31_t)0xA34BDF20, (q31_t)0xA7BD22AB, (q31_t)0xA3914DA7, - (q31_t)0xA7746EC0, (q31_t)0xA3D6F533, (q31_t)0xA72BF173, - (q31_t)0xA41CD598, (q31_t)0xA6E3AAF2, (q31_t)0xA462EEAC, - (q31_t)0xA69B9B68, (q31_t)0xA4A94042, (q31_t)0xA653C302, - (q31_t)0xA4EFCA31, (q31_t)0xA60C21ED, (q31_t)0xA5368C4B, - (q31_t)0xA5C4B855, (q31_t)0xA57D8666, (q31_t)0xA57D8666, - (q31_t)0xA5C4B855, (q31_t)0xA5368C4B, (q31_t)0xA60C21ED, - (q31_t)0xA4EFCA31, (q31_t)0xA653C302, (q31_t)0xA4A94042, - (q31_t)0xA69B9B68, (q31_t)0xA462EEAC, (q31_t)0xA6E3AAF2, - (q31_t)0xA41CD598, (q31_t)0xA72BF173, (q31_t)0xA3D6F533, - (q31_t)0xA7746EC0, (q31_t)0xA3914DA7, (q31_t)0xA7BD22AB, - (q31_t)0xA34BDF20, (q31_t)0xA8060D08, (q31_t)0xA306A9C7, - (q31_t)0xA84F2DA9, (q31_t)0xA2C1ADC9, (q31_t)0xA8988463, - (q31_t)0xA27CEB4F, (q31_t)0xA8E21106, (q31_t)0xA2386283, - (q31_t)0xA92BD366, (q31_t)0xA1F41391, (q31_t)0xA975CB56, - (q31_t)0xA1AFFEA2, (q31_t)0xA9BFF8A8, (q31_t)0xA16C23E1, - (q31_t)0xAA0A5B2D, (q31_t)0xA1288376, (q31_t)0xAA54F2B9, - (q31_t)0xA0E51D8C, (q31_t)0xAA9FBF1D, (q31_t)0xA0A1F24C, - (q31_t)0xAAEAC02B, (q31_t)0xA05F01E1, (q31_t)0xAB35F5B5, - (q31_t)0xA01C4C72, (q31_t)0xAB815F8C, (q31_t)0x9FD9D22A, - (q31_t)0xABCCFD82, (q31_t)0x9F979331, (q31_t)0xAC18CF68, - (q31_t)0x9F558FB0, (q31_t)0xAC64D510, (q31_t)0x9F13C7D0, - (q31_t)0xACB10E4A, (q31_t)0x9ED23BB9, (q31_t)0xACFD7AE8, - (q31_t)0x9E90EB94, (q31_t)0xAD4A1ABA, (q31_t)0x9E4FD789, - (q31_t)0xAD96ED91, (q31_t)0x9E0EFFC1, (q31_t)0xADE3F33E, - (q31_t)0x9DCE6462, (q31_t)0xAE312B91, (q31_t)0x9D8E0596, - (q31_t)0xAE7E965B, (q31_t)0x9D4DE384, (q31_t)0xAECC336B, - (q31_t)0x9D0DFE53, (q31_t)0xAF1A0293, (q31_t)0x9CCE562B, - (q31_t)0xAF6803A1, (q31_t)0x9C8EEB33, (q31_t)0xAFB63667, - (q31_t)0x9C4FBD92, (q31_t)0xB0049AB2, (q31_t)0x9C10CD70, - (q31_t)0xB0533055, (q31_t)0x9BD21AF2, (q31_t)0xB0A1F71C, - (q31_t)0x9B93A640, (q31_t)0xB0F0EEDA, (q31_t)0x9B556F80, - (q31_t)0xB140175B, (q31_t)0x9B1776D9, (q31_t)0xB18F7070, - (q31_t)0x9AD9BC71, (q31_t)0xB1DEF9E8, (q31_t)0x9A9C406D, - (q31_t)0xB22EB392, (q31_t)0x9A5F02F5, (q31_t)0xB27E9D3B, - (q31_t)0x9A22042C, (q31_t)0xB2CEB6B5, (q31_t)0x99E5443A, - (q31_t)0xB31EFFCB, (q31_t)0x99A8C344, (q31_t)0xB36F784E, - (q31_t)0x996C816F, (q31_t)0xB3C0200C, (q31_t)0x99307EE0, - (q31_t)0xB410F6D2, (q31_t)0x98F4BBBC, (q31_t)0xB461FC70, - (q31_t)0x98B93828, (q31_t)0xB4B330B2, (q31_t)0x987DF449, - (q31_t)0xB5049368, (q31_t)0x9842F043, (q31_t)0xB556245E, - (q31_t)0x98082C3B, (q31_t)0xB5A7E362, (q31_t)0x97CDA855, - (q31_t)0xB5F9D042, (q31_t)0x979364B5, (q31_t)0xB64BEACC, - (q31_t)0x9759617E, (q31_t)0xB69E32CD, (q31_t)0x971F9ED6, - (q31_t)0xB6F0A811, (q31_t)0x96E61CDF, (q31_t)0xB7434A67, - (q31_t)0x96ACDBBD, (q31_t)0xB796199B, (q31_t)0x9673DB94, - (q31_t)0xB7E9157A, (q31_t)0x963B1C85, (q31_t)0xB83C3DD1, - (q31_t)0x96029EB5, (q31_t)0xB88F926C, (q31_t)0x95CA6246, - (q31_t)0xB8E31319, (q31_t)0x9592675B, (q31_t)0xB936BFA3, - (q31_t)0x955AAE17, (q31_t)0xB98A97D8, (q31_t)0x9523369B, - (q31_t)0xB9DE9B83, (q31_t)0x94EC010B, (q31_t)0xBA32CA70, - (q31_t)0x94B50D87, (q31_t)0xBA87246C, (q31_t)0x947E5C32, - (q31_t)0xBADBA943, (q31_t)0x9447ED2F, (q31_t)0xBB3058C0, - (q31_t)0x9411C09D, (q31_t)0xBB8532AF, (q31_t)0x93DBD69F, - (q31_t)0xBBDA36DC, (q31_t)0x93A62F56, (q31_t)0xBC2F6513, - (q31_t)0x9370CAE4, (q31_t)0xBC84BD1E, (q31_t)0x933BA968, - (q31_t)0xBCDA3ECA, (q31_t)0x9306CB04, (q31_t)0xBD2FE9E1, - (q31_t)0x92D22FD8, (q31_t)0xBD85BE2F, (q31_t)0x929DD805, - (q31_t)0xBDDBBB7F, (q31_t)0x9269C3AC, (q31_t)0xBE31E19B, - (q31_t)0x9235F2EB, (q31_t)0xBE88304F, (q31_t)0x920265E4, - (q31_t)0xBEDEA765, (q31_t)0x91CF1CB6, (q31_t)0xBF3546A8, - (q31_t)0x919C1780, (q31_t)0xBF8C0DE2, (q31_t)0x91695663, - (q31_t)0xBFE2FCDF, (q31_t)0x9136D97D, (q31_t)0xC03A1368, - (q31_t)0x9104A0ED, (q31_t)0xC0915147, (q31_t)0x90D2ACD3, - (q31_t)0xC0E8B648, (q31_t)0x90A0FD4E, (q31_t)0xC1404233, - (q31_t)0x906F927B, (q31_t)0xC197F4D3, (q31_t)0x903E6C7A, - (q31_t)0xC1EFCDF2, (q31_t)0x900D8B69, (q31_t)0xC247CD5A, - (q31_t)0x8FDCEF66, (q31_t)0xC29FF2D4, (q31_t)0x8FAC988E, - (q31_t)0xC2F83E2A, (q31_t)0x8F7C8701, (q31_t)0xC350AF25, - (q31_t)0x8F4CBADB, (q31_t)0xC3A9458F, (q31_t)0x8F1D343A, - (q31_t)0xC4020132, (q31_t)0x8EEDF33B, (q31_t)0xC45AE1D7, - (q31_t)0x8EBEF7FB, (q31_t)0xC4B3E746, (q31_t)0x8E904298, - (q31_t)0xC50D1148, (q31_t)0x8E61D32D, (q31_t)0xC5665FA8, - (q31_t)0x8E33A9D9, (q31_t)0xC5BFD22E, (q31_t)0x8E05C6B7, - (q31_t)0xC61968A2, (q31_t)0x8DD829E4, (q31_t)0xC67322CD, - (q31_t)0x8DAAD37B, (q31_t)0xC6CD0079, (q31_t)0x8D7DC399, - (q31_t)0xC727016C, (q31_t)0x8D50FA59, (q31_t)0xC7812571, - (q31_t)0x8D2477D8, (q31_t)0xC7DB6C50, (q31_t)0x8CF83C30, - (q31_t)0xC835D5D0, (q31_t)0x8CCC477D, (q31_t)0xC89061BA, - (q31_t)0x8CA099D9, (q31_t)0xC8EB0FD6, (q31_t)0x8C753361, - (q31_t)0xC945DFEC, (q31_t)0x8C4A142F, (q31_t)0xC9A0D1C4, - (q31_t)0x8C1F3C5C, (q31_t)0xC9FBE527, (q31_t)0x8BF4AC05, - (q31_t)0xCA5719DB, (q31_t)0x8BCA6342, (q31_t)0xCAB26FA9, - (q31_t)0x8BA0622F, (q31_t)0xCB0DE658, (q31_t)0x8B76A8E4, - (q31_t)0xCB697DB0, (q31_t)0x8B4D377C, (q31_t)0xCBC53578, - (q31_t)0x8B240E10, (q31_t)0xCC210D78, (q31_t)0x8AFB2CBA, - (q31_t)0xCC7D0577, (q31_t)0x8AD29393, (q31_t)0xCCD91D3D, - (q31_t)0x8AAA42B4, (q31_t)0xCD355490, (q31_t)0x8A823A35, - (q31_t)0xCD91AB38, (q31_t)0x8A5A7A30, (q31_t)0xCDEE20FC, - (q31_t)0x8A3302BD, (q31_t)0xCE4AB5A2, (q31_t)0x8A0BD3F5, - (q31_t)0xCEA768F2, (q31_t)0x89E4EDEE, (q31_t)0xCF043AB2, - (q31_t)0x89BE50C3, (q31_t)0xCF612AAA, (q31_t)0x8997FC89, - (q31_t)0xCFBE389F, (q31_t)0x8971F15A, (q31_t)0xD01B6459, - (q31_t)0x894C2F4C, (q31_t)0xD078AD9D, (q31_t)0x8926B677, - (q31_t)0xD0D61433, (q31_t)0x890186F1, (q31_t)0xD13397E1, - (q31_t)0x88DCA0D3, (q31_t)0xD191386D, (q31_t)0x88B80431, - (q31_t)0xD1EEF59E, (q31_t)0x8893B124, (q31_t)0xD24CCF38, - (q31_t)0x886FA7C2, (q31_t)0xD2AAC504, (q31_t)0x884BE820, - (q31_t)0xD308D6C6, (q31_t)0x88287255, (q31_t)0xD3670445, - (q31_t)0x88054677, (q31_t)0xD3C54D46, (q31_t)0x87E2649B, - (q31_t)0xD423B190, (q31_t)0x87BFCCD7, (q31_t)0xD48230E8, - (q31_t)0x879D7F40, (q31_t)0xD4E0CB14, (q31_t)0x877B7BEC, - (q31_t)0xD53F7FDA, (q31_t)0x8759C2EF, (q31_t)0xD59E4EFE, - (q31_t)0x8738545E, (q31_t)0xD5FD3847, (q31_t)0x8717304E, - (q31_t)0xD65C3B7B, (q31_t)0x86F656D3, (q31_t)0xD6BB585D, - (q31_t)0x86D5C802, (q31_t)0xD71A8EB5, (q31_t)0x86B583EE, - (q31_t)0xD779DE46, (q31_t)0x86958AAB, (q31_t)0xD7D946D7, - (q31_t)0x8675DC4E, (q31_t)0xD838C82D, (q31_t)0x865678EA, - (q31_t)0xD898620C, (q31_t)0x86376092, (q31_t)0xD8F81439, - (q31_t)0x86189359, (q31_t)0xD957DE7A, (q31_t)0x85FA1152, - (q31_t)0xD9B7C093, (q31_t)0x85DBDA91, (q31_t)0xDA17BA4A, - (q31_t)0x85BDEF27, (q31_t)0xDA77CB62, (q31_t)0x85A04F28, - (q31_t)0xDAD7F3A2, (q31_t)0x8582FAA4, (q31_t)0xDB3832CD, - (q31_t)0x8565F1B0, (q31_t)0xDB9888A8, (q31_t)0x8549345C, - (q31_t)0xDBF8F4F8, (q31_t)0x852CC2BA, (q31_t)0xDC597781, - (q31_t)0x85109CDC, (q31_t)0xDCBA1008, (q31_t)0x84F4C2D3, - (q31_t)0xDD1ABE51, (q31_t)0x84D934B0, (q31_t)0xDD7B8220, - (q31_t)0x84BDF285, (q31_t)0xDDDC5B3A, (q31_t)0x84A2FC62, - (q31_t)0xDE3D4963, (q31_t)0x84885257, (q31_t)0xDE9E4C60, - (q31_t)0x846DF476, (q31_t)0xDEFF63F4, (q31_t)0x8453E2CE, - (q31_t)0xDF608FE3, (q31_t)0x843A1D70, (q31_t)0xDFC1CFF2, - (q31_t)0x8420A46B, (q31_t)0xE02323E5, (q31_t)0x840777CF, - (q31_t)0xE0848B7F, (q31_t)0x83EE97AC, (q31_t)0xE0E60684, - (q31_t)0x83D60411, (q31_t)0xE14794B9, (q31_t)0x83BDBD0D, - (q31_t)0xE1A935E1, (q31_t)0x83A5C2B0, (q31_t)0xE20AE9C1, - (q31_t)0x838E1507, (q31_t)0xE26CB01A, (q31_t)0x8376B422, - (q31_t)0xE2CE88B2, (q31_t)0x835FA00E, (q31_t)0xE330734C, - (q31_t)0x8348D8DB, (q31_t)0xE3926FAC, (q31_t)0x83325E97, - (q31_t)0xE3F47D95, (q31_t)0x831C314E, (q31_t)0xE4569CCB, - (q31_t)0x8306510F, (q31_t)0xE4B8CD10, (q31_t)0x82F0BDE8, - (q31_t)0xE51B0E2A, (q31_t)0x82DB77E5, (q31_t)0xE57D5FDA, - (q31_t)0x82C67F13, (q31_t)0xE5DFC1E4, (q31_t)0x82B1D381, - (q31_t)0xE642340D, (q31_t)0x829D753A, (q31_t)0xE6A4B616, - (q31_t)0x8289644A, (q31_t)0xE70747C3, (q31_t)0x8275A0C0, - (q31_t)0xE769E8D8, (q31_t)0x82622AA5, (q31_t)0xE7CC9917, - (q31_t)0x824F0208, (q31_t)0xE82F5844, (q31_t)0x823C26F2, - (q31_t)0xE8922621, (q31_t)0x82299971, (q31_t)0xE8F50273, - (q31_t)0x8217598F, (q31_t)0xE957ECFB, (q31_t)0x82056758, - (q31_t)0xE9BAE57C, (q31_t)0x81F3C2D7, (q31_t)0xEA1DEBBB, - (q31_t)0x81E26C16, (q31_t)0xEA80FF79, (q31_t)0x81D16320, - (q31_t)0xEAE4207A, (q31_t)0x81C0A801, (q31_t)0xEB474E80, - (q31_t)0x81B03AC1, (q31_t)0xEBAA894E, (q31_t)0x81A01B6C, - (q31_t)0xEC0DD0A8, (q31_t)0x81904A0C, (q31_t)0xEC71244F, - (q31_t)0x8180C6A9, (q31_t)0xECD48406, (q31_t)0x8171914E, - (q31_t)0xED37EF91, (q31_t)0x8162AA03, (q31_t)0xED9B66B2, - (q31_t)0x815410D3, (q31_t)0xEDFEE92B, (q31_t)0x8145C5C6, - (q31_t)0xEE6276BF, (q31_t)0x8137C8E6, (q31_t)0xEEC60F31, - (q31_t)0x812A1A39, (q31_t)0xEF29B243, (q31_t)0x811CB9CA, - (q31_t)0xEF8D5FB8, (q31_t)0x810FA7A0, (q31_t)0xEFF11752, - (q31_t)0x8102E3C3, (q31_t)0xF054D8D4, (q31_t)0x80F66E3C, - (q31_t)0xF0B8A401, (q31_t)0x80EA4712, (q31_t)0xF11C789A, - (q31_t)0x80DE6E4C, (q31_t)0xF1805662, (q31_t)0x80D2E3F1, - (q31_t)0xF1E43D1C, (q31_t)0x80C7A80A, (q31_t)0xF2482C89, - (q31_t)0x80BCBA9C, (q31_t)0xF2AC246D, (q31_t)0x80B21BAF, - (q31_t)0xF310248A, (q31_t)0x80A7CB49, (q31_t)0xF3742CA1, - (q31_t)0x809DC970, (q31_t)0xF3D83C76, (q31_t)0x8094162B, - (q31_t)0xF43C53CA, (q31_t)0x808AB180, (q31_t)0xF4A07260, - (q31_t)0x80819B74, (q31_t)0xF50497FA, (q31_t)0x8078D40D, - (q31_t)0xF568C45A, (q31_t)0x80705B50, (q31_t)0xF5CCF743, - (q31_t)0x80683143, (q31_t)0xF6313076, (q31_t)0x806055EA, - (q31_t)0xF6956FB6, (q31_t)0x8058C94C, (q31_t)0xF6F9B4C5, - (q31_t)0x80518B6B, (q31_t)0xF75DFF65, (q31_t)0x804A9C4D, - (q31_t)0xF7C24F58, (q31_t)0x8043FBF6, (q31_t)0xF826A461, - (q31_t)0x803DAA69, (q31_t)0xF88AFE41, (q31_t)0x8037A7AC, - (q31_t)0xF8EF5CBB, (q31_t)0x8031F3C1, (q31_t)0xF953BF90, - (q31_t)0x802C8EAD, (q31_t)0xF9B82683, (q31_t)0x80277872, - (q31_t)0xFA1C9156, (q31_t)0x8022B113, (q31_t)0xFA80FFCB, - (q31_t)0x801E3894, (q31_t)0xFAE571A4, (q31_t)0x801A0EF7, - (q31_t)0xFB49E6A2, (q31_t)0x80163440, (q31_t)0xFBAE5E89, - (q31_t)0x8012A86F, (q31_t)0xFC12D919, (q31_t)0x800F6B88, - (q31_t)0xFC775616, (q31_t)0x800C7D8C, (q31_t)0xFCDBD541, - (q31_t)0x8009DE7D, (q31_t)0xFD40565B, (q31_t)0x80078E5E, - (q31_t)0xFDA4D928, (q31_t)0x80058D2E, (q31_t)0xFE095D69, - (q31_t)0x8003DAF0, (q31_t)0xFE6DE2E0, (q31_t)0x800277A5, - (q31_t)0xFED2694F, (q31_t)0x8001634D, (q31_t)0xFF36F078, - (q31_t)0x80009DE9, (q31_t)0xFF9B781D, (q31_t)0x8000277A -}; + (q31_t)0x7FFFFFFF, (q31_t)0x00000000, (q31_t)0x7FFFD885, (q31_t)0x006487E3, + (q31_t)0x7FFF6216, (q31_t)0x00C90F88, (q31_t)0x7FFE9CB2, (q31_t)0x012D96B0, + (q31_t)0x7FFD885A, (q31_t)0x01921D1F, (q31_t)0x7FFC250F, (q31_t)0x01F6A296, + (q31_t)0x7FFA72D1, (q31_t)0x025B26D7, (q31_t)0x7FF871A1, (q31_t)0x02BFA9A4, + (q31_t)0x7FF62182, (q31_t)0x03242ABF, (q31_t)0x7FF38273, (q31_t)0x0388A9E9, + (q31_t)0x7FF09477, (q31_t)0x03ED26E6, (q31_t)0x7FED5790, (q31_t)0x0451A176, + (q31_t)0x7FE9CBC0, (q31_t)0x04B6195D, (q31_t)0x7FE5F108, (q31_t)0x051A8E5C, + (q31_t)0x7FE1C76B, (q31_t)0x057F0034, (q31_t)0x7FDD4EEC, (q31_t)0x05E36EA9, + (q31_t)0x7FD8878D, (q31_t)0x0647D97C, (q31_t)0x7FD37152, (q31_t)0x06AC406F, + (q31_t)0x7FCE0C3E, (q31_t)0x0710A344, (q31_t)0x7FC85853, (q31_t)0x077501BE, + (q31_t)0x7FC25596, (q31_t)0x07D95B9E, (q31_t)0x7FBC040A, (q31_t)0x083DB0A7, + (q31_t)0x7FB563B2, (q31_t)0x08A2009A, (q31_t)0x7FAE7494, (q31_t)0x09064B3A, + (q31_t)0x7FA736B4, (q31_t)0x096A9049, (q31_t)0x7F9FAA15, (q31_t)0x09CECF89, + (q31_t)0x7F97CEBC, (q31_t)0x0A3308BC, (q31_t)0x7F8FA4AF, (q31_t)0x0A973BA5, + (q31_t)0x7F872BF3, (q31_t)0x0AFB6805, (q31_t)0x7F7E648B, (q31_t)0x0B5F8D9F, + (q31_t)0x7F754E7F, (q31_t)0x0BC3AC35, (q31_t)0x7F6BE9D4, (q31_t)0x0C27C389, + (q31_t)0x7F62368F, (q31_t)0x0C8BD35E, (q31_t)0x7F5834B6, (q31_t)0x0CEFDB75, + (q31_t)0x7F4DE450, (q31_t)0x0D53DB92, (q31_t)0x7F434563, (q31_t)0x0DB7D376, + (q31_t)0x7F3857F5, (q31_t)0x0E1BC2E3, (q31_t)0x7F2D1C0E, (q31_t)0x0E7FA99D, + (q31_t)0x7F2191B4, (q31_t)0x0EE38765, (q31_t)0x7F15B8EE, (q31_t)0x0F475BFE, + (q31_t)0x7F0991C3, (q31_t)0x0FAB272B, (q31_t)0x7EFD1C3C, (q31_t)0x100EE8AD, + (q31_t)0x7EF0585F, (q31_t)0x1072A047, (q31_t)0x7EE34635, (q31_t)0x10D64DBC, + (q31_t)0x7ED5E5C6, (q31_t)0x1139F0CE, (q31_t)0x7EC8371A, (q31_t)0x119D8940, + (q31_t)0x7EBA3A39, (q31_t)0x120116D4, (q31_t)0x7EABEF2C, (q31_t)0x1264994E, + (q31_t)0x7E9D55FC, (q31_t)0x12C8106E, (q31_t)0x7E8E6EB1, (q31_t)0x132B7BF9, + (q31_t)0x7E7F3956, (q31_t)0x138EDBB0, (q31_t)0x7E6FB5F3, (q31_t)0x13F22F57, + (q31_t)0x7E5FE493, (q31_t)0x145576B1, (q31_t)0x7E4FC53E, (q31_t)0x14B8B17F, + (q31_t)0x7E3F57FE, (q31_t)0x151BDF85, (q31_t)0x7E2E9CDF, (q31_t)0x157F0086, + (q31_t)0x7E1D93E9, (q31_t)0x15E21444, (q31_t)0x7E0C3D29, (q31_t)0x16451A83, + (q31_t)0x7DFA98A7, (q31_t)0x16A81305, (q31_t)0x7DE8A670, (q31_t)0x170AFD8D, + (q31_t)0x7DD6668E, (q31_t)0x176DD9DE, (q31_t)0x7DC3D90D, (q31_t)0x17D0A7BB, + (q31_t)0x7DB0FDF7, (q31_t)0x183366E8, (q31_t)0x7D9DD55A, (q31_t)0x18961727, + (q31_t)0x7D8A5F3F, (q31_t)0x18F8B83C, (q31_t)0x7D769BB5, (q31_t)0x195B49E9, + (q31_t)0x7D628AC5, (q31_t)0x19BDCBF2, (q31_t)0x7D4E2C7E, (q31_t)0x1A203E1B, + (q31_t)0x7D3980EC, (q31_t)0x1A82A025, (q31_t)0x7D24881A, (q31_t)0x1AE4F1D6, + (q31_t)0x7D0F4218, (q31_t)0x1B4732EF, (q31_t)0x7CF9AEF0, (q31_t)0x1BA96334, + (q31_t)0x7CE3CEB1, (q31_t)0x1C0B826A, (q31_t)0x7CCDA168, (q31_t)0x1C6D9053, + (q31_t)0x7CB72724, (q31_t)0x1CCF8CB3, (q31_t)0x7CA05FF1, (q31_t)0x1D31774D, + (q31_t)0x7C894BDD, (q31_t)0x1D934FE5, (q31_t)0x7C71EAF8, (q31_t)0x1DF5163F, + (q31_t)0x7C5A3D4F, (q31_t)0x1E56CA1E, (q31_t)0x7C4242F2, (q31_t)0x1EB86B46, + (q31_t)0x7C29FBEE, (q31_t)0x1F19F97B, (q31_t)0x7C116853, (q31_t)0x1F7B7480, + (q31_t)0x7BF88830, (q31_t)0x1FDCDC1A, (q31_t)0x7BDF5B94, (q31_t)0x203E300D, + (q31_t)0x7BC5E28F, (q31_t)0x209F701C, (q31_t)0x7BAC1D31, (q31_t)0x21009C0B, + (q31_t)0x7B920B89, (q31_t)0x2161B39F, (q31_t)0x7B77ADA8, (q31_t)0x21C2B69C, + (q31_t)0x7B5D039D, (q31_t)0x2223A4C5, (q31_t)0x7B420D7A, (q31_t)0x22847DDF, + (q31_t)0x7B26CB4F, (q31_t)0x22E541AE, (q31_t)0x7B0B3D2C, (q31_t)0x2345EFF7, + (q31_t)0x7AEF6323, (q31_t)0x23A6887E, (q31_t)0x7AD33D45, (q31_t)0x24070B07, + (q31_t)0x7AB6CBA3, (q31_t)0x24677757, (q31_t)0x7A9A0E4F, (q31_t)0x24C7CD32, + (q31_t)0x7A7D055B, (q31_t)0x25280C5D, (q31_t)0x7A5FB0D8, (q31_t)0x2588349D, + (q31_t)0x7A4210D8, (q31_t)0x25E845B5, (q31_t)0x7A24256E, (q31_t)0x26483F6C, + (q31_t)0x7A05EEAD, (q31_t)0x26A82185, (q31_t)0x79E76CA6, (q31_t)0x2707EBC6, + (q31_t)0x79C89F6D, (q31_t)0x27679DF4, (q31_t)0x79A98715, (q31_t)0x27C737D2, + (q31_t)0x798A23B1, (q31_t)0x2826B928, (q31_t)0x796A7554, (q31_t)0x288621B9, + (q31_t)0x794A7C11, (q31_t)0x28E5714A, (q31_t)0x792A37FE, (q31_t)0x2944A7A2, + (q31_t)0x7909A92C, (q31_t)0x29A3C484, (q31_t)0x78E8CFB1, (q31_t)0x2A02C7B8, + (q31_t)0x78C7ABA1, (q31_t)0x2A61B101, (q31_t)0x78A63D10, (q31_t)0x2AC08025, + (q31_t)0x78848413, (q31_t)0x2B1F34EB, (q31_t)0x786280BF, (q31_t)0x2B7DCF17, + (q31_t)0x78403328, (q31_t)0x2BDC4E6F, (q31_t)0x781D9B64, (q31_t)0x2C3AB2B9, + (q31_t)0x77FAB988, (q31_t)0x2C98FBBA, (q31_t)0x77D78DAA, (q31_t)0x2CF72939, + (q31_t)0x77B417DF, (q31_t)0x2D553AFB, (q31_t)0x7790583D, (q31_t)0x2DB330C7, + (q31_t)0x776C4EDB, (q31_t)0x2E110A62, (q31_t)0x7747FBCE, (q31_t)0x2E6EC792, + (q31_t)0x77235F2D, (q31_t)0x2ECC681E, (q31_t)0x76FE790E, (q31_t)0x2F29EBCC, + (q31_t)0x76D94988, (q31_t)0x2F875262, (q31_t)0x76B3D0B3, (q31_t)0x2FE49BA6, + (q31_t)0x768E0EA5, (q31_t)0x3041C760, (q31_t)0x76680376, (q31_t)0x309ED555, + (q31_t)0x7641AF3C, (q31_t)0x30FBC54D, (q31_t)0x761B1211, (q31_t)0x3158970D, + (q31_t)0x75F42C0A, (q31_t)0x31B54A5D, (q31_t)0x75CCFD42, (q31_t)0x3211DF03, + (q31_t)0x75A585CF, (q31_t)0x326E54C7, (q31_t)0x757DC5CA, (q31_t)0x32CAAB6F, + (q31_t)0x7555BD4B, (q31_t)0x3326E2C2, (q31_t)0x752D6C6C, (q31_t)0x3382FA88, + (q31_t)0x7504D345, (q31_t)0x33DEF287, (q31_t)0x74DBF1EF, (q31_t)0x343ACA87, + (q31_t)0x74B2C883, (q31_t)0x3496824F, (q31_t)0x7489571B, (q31_t)0x34F219A7, + (q31_t)0x745F9DD1, (q31_t)0x354D9056, (q31_t)0x74359CBD, (q31_t)0x35A8E624, + (q31_t)0x740B53FA, (q31_t)0x36041AD9, (q31_t)0x73E0C3A3, (q31_t)0x365F2E3B, + (q31_t)0x73B5EBD0, (q31_t)0x36BA2013, (q31_t)0x738ACC9E, (q31_t)0x3714F02A, + (q31_t)0x735F6626, (q31_t)0x376F9E46, (q31_t)0x7333B883, (q31_t)0x37CA2A30, + (q31_t)0x7307C3D0, (q31_t)0x382493B0, (q31_t)0x72DB8828, (q31_t)0x387EDA8E, + (q31_t)0x72AF05A6, (q31_t)0x38D8FE93, (q31_t)0x72823C66, (q31_t)0x3932FF87, + (q31_t)0x72552C84, (q31_t)0x398CDD32, (q31_t)0x7227D61C, (q31_t)0x39E6975D, + (q31_t)0x71FA3948, (q31_t)0x3A402DD1, (q31_t)0x71CC5626, (q31_t)0x3A99A057, + (q31_t)0x719E2CD2, (q31_t)0x3AF2EEB7, (q31_t)0x716FBD68, (q31_t)0x3B4C18BA, + (q31_t)0x71410804, (q31_t)0x3BA51E29, (q31_t)0x71120CC5, (q31_t)0x3BFDFECD, + (q31_t)0x70E2CBC6, (q31_t)0x3C56BA70, (q31_t)0x70B34524, (q31_t)0x3CAF50DA, + (q31_t)0x708378FE, (q31_t)0x3D07C1D5, (q31_t)0x70536771, (q31_t)0x3D600D2B, + (q31_t)0x70231099, (q31_t)0x3DB832A5, (q31_t)0x6FF27496, (q31_t)0x3E10320D, + (q31_t)0x6FC19385, (q31_t)0x3E680B2C, (q31_t)0x6F906D84, (q31_t)0x3EBFBDCC, + (q31_t)0x6F5F02B1, (q31_t)0x3F1749B7, (q31_t)0x6F2D532C, (q31_t)0x3F6EAEB8, + (q31_t)0x6EFB5F12, (q31_t)0x3FC5EC97, (q31_t)0x6EC92682, (q31_t)0x401D0320, + (q31_t)0x6E96A99C, (q31_t)0x4073F21D, (q31_t)0x6E63E87F, (q31_t)0x40CAB957, + (q31_t)0x6E30E349, (q31_t)0x4121589A, (q31_t)0x6DFD9A1B, (q31_t)0x4177CFB0, + (q31_t)0x6DCA0D14, (q31_t)0x41CE1E64, (q31_t)0x6D963C54, (q31_t)0x42244480, + (q31_t)0x6D6227FA, (q31_t)0x427A41D0, (q31_t)0x6D2DD027, (q31_t)0x42D0161E, + (q31_t)0x6CF934FB, (q31_t)0x4325C135, (q31_t)0x6CC45697, (q31_t)0x437B42E1, + (q31_t)0x6C8F351C, (q31_t)0x43D09AEC, (q31_t)0x6C59D0A9, (q31_t)0x4425C923, + (q31_t)0x6C242960, (q31_t)0x447ACD50, (q31_t)0x6BEE3F62, (q31_t)0x44CFA73F, + (q31_t)0x6BB812D0, (q31_t)0x452456BC, (q31_t)0x6B81A3CD, (q31_t)0x4578DB93, + (q31_t)0x6B4AF278, (q31_t)0x45CD358F, (q31_t)0x6B13FEF5, (q31_t)0x4621647C, + (q31_t)0x6ADCC964, (q31_t)0x46756827, (q31_t)0x6AA551E8, (q31_t)0x46C9405C, + (q31_t)0x6A6D98A4, (q31_t)0x471CECE6, (q31_t)0x6A359DB9, (q31_t)0x47706D93, + (q31_t)0x69FD614A, (q31_t)0x47C3C22E, (q31_t)0x69C4E37A, (q31_t)0x4816EA85, + (q31_t)0x698C246C, (q31_t)0x4869E664, (q31_t)0x69532442, (q31_t)0x48BCB598, + (q31_t)0x6919E320, (q31_t)0x490F57EE, (q31_t)0x68E06129, (q31_t)0x4961CD32, + (q31_t)0x68A69E81, (q31_t)0x49B41533, (q31_t)0x686C9B4B, (q31_t)0x4A062FBD, + (q31_t)0x683257AA, (q31_t)0x4A581C9D, (q31_t)0x67F7D3C4, (q31_t)0x4AA9DBA1, + (q31_t)0x67BD0FBC, (q31_t)0x4AFB6C97, (q31_t)0x67820BB6, (q31_t)0x4B4CCF4D, + (q31_t)0x6746C7D7, (q31_t)0x4B9E038F, (q31_t)0x670B4443, (q31_t)0x4BEF092D, + (q31_t)0x66CF811F, (q31_t)0x4C3FDFF3, (q31_t)0x66937E90, (q31_t)0x4C9087B1, + (q31_t)0x66573CBB, (q31_t)0x4CE10034, (q31_t)0x661ABBC5, (q31_t)0x4D31494B, + (q31_t)0x65DDFBD3, (q31_t)0x4D8162C4, (q31_t)0x65A0FD0B, (q31_t)0x4DD14C6E, + (q31_t)0x6563BF92, (q31_t)0x4E210617, (q31_t)0x6526438E, (q31_t)0x4E708F8F, + (q31_t)0x64E88926, (q31_t)0x4EBFE8A4, (q31_t)0x64AA907F, (q31_t)0x4F0F1126, + (q31_t)0x646C59BF, (q31_t)0x4F5E08E3, (q31_t)0x642DE50D, (q31_t)0x4FACCFAB, + (q31_t)0x63EF328F, (q31_t)0x4FFB654D, (q31_t)0x63B0426D, (q31_t)0x5049C999, + (q31_t)0x637114CC, (q31_t)0x5097FC5E, (q31_t)0x6331A9D4, (q31_t)0x50E5FD6C, + (q31_t)0x62F201AC, (q31_t)0x5133CC94, (q31_t)0x62B21C7B, (q31_t)0x518169A4, + (q31_t)0x6271FA69, (q31_t)0x51CED46E, (q31_t)0x62319B9D, (q31_t)0x521C0CC1, + (q31_t)0x61F1003E, (q31_t)0x5269126E, (q31_t)0x61B02876, (q31_t)0x52B5E545, + (q31_t)0x616F146B, (q31_t)0x53028517, (q31_t)0x612DC446, (q31_t)0x534EF1B5, + (q31_t)0x60EC3830, (q31_t)0x539B2AEF, (q31_t)0x60AA704F, (q31_t)0x53E73097, + (q31_t)0x60686CCE, (q31_t)0x5433027D, (q31_t)0x60262DD5, (q31_t)0x547EA073, + (q31_t)0x5FE3B38D, (q31_t)0x54CA0A4A, (q31_t)0x5FA0FE1E, (q31_t)0x55153FD4, + (q31_t)0x5F5E0DB3, (q31_t)0x556040E2, (q31_t)0x5F1AE273, (q31_t)0x55AB0D46, + (q31_t)0x5ED77C89, (q31_t)0x55F5A4D2, (q31_t)0x5E93DC1F, (q31_t)0x56400757, + (q31_t)0x5E50015D, (q31_t)0x568A34A9, (q31_t)0x5E0BEC6E, (q31_t)0x56D42C99, + (q31_t)0x5DC79D7C, (q31_t)0x571DEEF9, (q31_t)0x5D8314B0, (q31_t)0x57677B9D, + (q31_t)0x5D3E5236, (q31_t)0x57B0D256, (q31_t)0x5CF95638, (q31_t)0x57F9F2F7, + (q31_t)0x5CB420DF, (q31_t)0x5842DD54, (q31_t)0x5C6EB258, (q31_t)0x588B913F, + (q31_t)0x5C290ACC, (q31_t)0x58D40E8C, (q31_t)0x5BE32A67, (q31_t)0x591C550E, + (q31_t)0x5B9D1153, (q31_t)0x59646497, (q31_t)0x5B56BFBD, (q31_t)0x59AC3CFD, + (q31_t)0x5B1035CF, (q31_t)0x59F3DE12, (q31_t)0x5AC973B4, (q31_t)0x5A3B47AA, + (q31_t)0x5A82799A, (q31_t)0x5A82799A, (q31_t)0x5A3B47AA, (q31_t)0x5AC973B4, + (q31_t)0x59F3DE12, (q31_t)0x5B1035CF, (q31_t)0x59AC3CFD, (q31_t)0x5B56BFBD, + (q31_t)0x59646497, (q31_t)0x5B9D1153, (q31_t)0x591C550E, (q31_t)0x5BE32A67, + (q31_t)0x58D40E8C, (q31_t)0x5C290ACC, (q31_t)0x588B913F, (q31_t)0x5C6EB258, + (q31_t)0x5842DD54, (q31_t)0x5CB420DF, (q31_t)0x57F9F2F7, (q31_t)0x5CF95638, + (q31_t)0x57B0D256, (q31_t)0x5D3E5236, (q31_t)0x57677B9D, (q31_t)0x5D8314B0, + (q31_t)0x571DEEF9, (q31_t)0x5DC79D7C, (q31_t)0x56D42C99, (q31_t)0x5E0BEC6E, + (q31_t)0x568A34A9, (q31_t)0x5E50015D, (q31_t)0x56400757, (q31_t)0x5E93DC1F, + (q31_t)0x55F5A4D2, (q31_t)0x5ED77C89, (q31_t)0x55AB0D46, (q31_t)0x5F1AE273, + (q31_t)0x556040E2, (q31_t)0x5F5E0DB3, (q31_t)0x55153FD4, (q31_t)0x5FA0FE1E, + (q31_t)0x54CA0A4A, (q31_t)0x5FE3B38D, (q31_t)0x547EA073, (q31_t)0x60262DD5, + (q31_t)0x5433027D, (q31_t)0x60686CCE, (q31_t)0x53E73097, (q31_t)0x60AA704F, + (q31_t)0x539B2AEF, (q31_t)0x60EC3830, (q31_t)0x534EF1B5, (q31_t)0x612DC446, + (q31_t)0x53028517, (q31_t)0x616F146B, (q31_t)0x52B5E545, (q31_t)0x61B02876, + (q31_t)0x5269126E, (q31_t)0x61F1003E, (q31_t)0x521C0CC1, (q31_t)0x62319B9D, + (q31_t)0x51CED46E, (q31_t)0x6271FA69, (q31_t)0x518169A4, (q31_t)0x62B21C7B, + (q31_t)0x5133CC94, (q31_t)0x62F201AC, (q31_t)0x50E5FD6C, (q31_t)0x6331A9D4, + (q31_t)0x5097FC5E, (q31_t)0x637114CC, (q31_t)0x5049C999, (q31_t)0x63B0426D, + (q31_t)0x4FFB654D, (q31_t)0x63EF328F, (q31_t)0x4FACCFAB, (q31_t)0x642DE50D, + (q31_t)0x4F5E08E3, (q31_t)0x646C59BF, (q31_t)0x4F0F1126, (q31_t)0x64AA907F, + (q31_t)0x4EBFE8A4, (q31_t)0x64E88926, (q31_t)0x4E708F8F, (q31_t)0x6526438E, + (q31_t)0x4E210617, (q31_t)0x6563BF92, (q31_t)0x4DD14C6E, (q31_t)0x65A0FD0B, + (q31_t)0x4D8162C4, (q31_t)0x65DDFBD3, (q31_t)0x4D31494B, (q31_t)0x661ABBC5, + (q31_t)0x4CE10034, (q31_t)0x66573CBB, (q31_t)0x4C9087B1, (q31_t)0x66937E90, + (q31_t)0x4C3FDFF3, (q31_t)0x66CF811F, (q31_t)0x4BEF092D, (q31_t)0x670B4443, + (q31_t)0x4B9E038F, (q31_t)0x6746C7D7, (q31_t)0x4B4CCF4D, (q31_t)0x67820BB6, + (q31_t)0x4AFB6C97, (q31_t)0x67BD0FBC, (q31_t)0x4AA9DBA1, (q31_t)0x67F7D3C4, + (q31_t)0x4A581C9D, (q31_t)0x683257AA, (q31_t)0x4A062FBD, (q31_t)0x686C9B4B, + (q31_t)0x49B41533, (q31_t)0x68A69E81, (q31_t)0x4961CD32, (q31_t)0x68E06129, + (q31_t)0x490F57EE, (q31_t)0x6919E320, (q31_t)0x48BCB598, (q31_t)0x69532442, + (q31_t)0x4869E664, (q31_t)0x698C246C, (q31_t)0x4816EA85, (q31_t)0x69C4E37A, + (q31_t)0x47C3C22E, (q31_t)0x69FD614A, (q31_t)0x47706D93, (q31_t)0x6A359DB9, + (q31_t)0x471CECE6, (q31_t)0x6A6D98A4, (q31_t)0x46C9405C, (q31_t)0x6AA551E8, + (q31_t)0x46756827, (q31_t)0x6ADCC964, (q31_t)0x4621647C, (q31_t)0x6B13FEF5, + (q31_t)0x45CD358F, (q31_t)0x6B4AF278, (q31_t)0x4578DB93, (q31_t)0x6B81A3CD, + (q31_t)0x452456BC, (q31_t)0x6BB812D0, (q31_t)0x44CFA73F, (q31_t)0x6BEE3F62, + (q31_t)0x447ACD50, (q31_t)0x6C242960, (q31_t)0x4425C923, (q31_t)0x6C59D0A9, + (q31_t)0x43D09AEC, (q31_t)0x6C8F351C, (q31_t)0x437B42E1, (q31_t)0x6CC45697, + (q31_t)0x4325C135, (q31_t)0x6CF934FB, (q31_t)0x42D0161E, (q31_t)0x6D2DD027, + (q31_t)0x427A41D0, (q31_t)0x6D6227FA, (q31_t)0x42244480, (q31_t)0x6D963C54, + (q31_t)0x41CE1E64, (q31_t)0x6DCA0D14, (q31_t)0x4177CFB0, (q31_t)0x6DFD9A1B, + (q31_t)0x4121589A, (q31_t)0x6E30E349, (q31_t)0x40CAB957, (q31_t)0x6E63E87F, + (q31_t)0x4073F21D, (q31_t)0x6E96A99C, (q31_t)0x401D0320, (q31_t)0x6EC92682, + (q31_t)0x3FC5EC97, (q31_t)0x6EFB5F12, (q31_t)0x3F6EAEB8, (q31_t)0x6F2D532C, + (q31_t)0x3F1749B7, (q31_t)0x6F5F02B1, (q31_t)0x3EBFBDCC, (q31_t)0x6F906D84, + (q31_t)0x3E680B2C, (q31_t)0x6FC19385, (q31_t)0x3E10320D, (q31_t)0x6FF27496, + (q31_t)0x3DB832A5, (q31_t)0x70231099, (q31_t)0x3D600D2B, (q31_t)0x70536771, + (q31_t)0x3D07C1D5, (q31_t)0x708378FE, (q31_t)0x3CAF50DA, (q31_t)0x70B34524, + (q31_t)0x3C56BA70, (q31_t)0x70E2CBC6, (q31_t)0x3BFDFECD, (q31_t)0x71120CC5, + (q31_t)0x3BA51E29, (q31_t)0x71410804, (q31_t)0x3B4C18BA, (q31_t)0x716FBD68, + (q31_t)0x3AF2EEB7, (q31_t)0x719E2CD2, (q31_t)0x3A99A057, (q31_t)0x71CC5626, + (q31_t)0x3A402DD1, (q31_t)0x71FA3948, (q31_t)0x39E6975D, (q31_t)0x7227D61C, + (q31_t)0x398CDD32, (q31_t)0x72552C84, (q31_t)0x3932FF87, (q31_t)0x72823C66, + (q31_t)0x38D8FE93, (q31_t)0x72AF05A6, (q31_t)0x387EDA8E, (q31_t)0x72DB8828, + (q31_t)0x382493B0, (q31_t)0x7307C3D0, (q31_t)0x37CA2A30, (q31_t)0x7333B883, + (q31_t)0x376F9E46, (q31_t)0x735F6626, (q31_t)0x3714F02A, (q31_t)0x738ACC9E, + (q31_t)0x36BA2013, (q31_t)0x73B5EBD0, (q31_t)0x365F2E3B, (q31_t)0x73E0C3A3, + (q31_t)0x36041AD9, (q31_t)0x740B53FA, (q31_t)0x35A8E624, (q31_t)0x74359CBD, + (q31_t)0x354D9056, (q31_t)0x745F9DD1, (q31_t)0x34F219A7, (q31_t)0x7489571B, + (q31_t)0x3496824F, (q31_t)0x74B2C883, (q31_t)0x343ACA87, (q31_t)0x74DBF1EF, + (q31_t)0x33DEF287, (q31_t)0x7504D345, (q31_t)0x3382FA88, (q31_t)0x752D6C6C, + (q31_t)0x3326E2C2, (q31_t)0x7555BD4B, (q31_t)0x32CAAB6F, (q31_t)0x757DC5CA, + (q31_t)0x326E54C7, (q31_t)0x75A585CF, (q31_t)0x3211DF03, (q31_t)0x75CCFD42, + (q31_t)0x31B54A5D, (q31_t)0x75F42C0A, (q31_t)0x3158970D, (q31_t)0x761B1211, + (q31_t)0x30FBC54D, (q31_t)0x7641AF3C, (q31_t)0x309ED555, (q31_t)0x76680376, + (q31_t)0x3041C760, (q31_t)0x768E0EA5, (q31_t)0x2FE49BA6, (q31_t)0x76B3D0B3, + (q31_t)0x2F875262, (q31_t)0x76D94988, (q31_t)0x2F29EBCC, (q31_t)0x76FE790E, + (q31_t)0x2ECC681E, (q31_t)0x77235F2D, (q31_t)0x2E6EC792, (q31_t)0x7747FBCE, + (q31_t)0x2E110A62, (q31_t)0x776C4EDB, (q31_t)0x2DB330C7, (q31_t)0x7790583D, + (q31_t)0x2D553AFB, (q31_t)0x77B417DF, (q31_t)0x2CF72939, (q31_t)0x77D78DAA, + (q31_t)0x2C98FBBA, (q31_t)0x77FAB988, (q31_t)0x2C3AB2B9, (q31_t)0x781D9B64, + (q31_t)0x2BDC4E6F, (q31_t)0x78403328, (q31_t)0x2B7DCF17, (q31_t)0x786280BF, + (q31_t)0x2B1F34EB, (q31_t)0x78848413, (q31_t)0x2AC08025, (q31_t)0x78A63D10, + (q31_t)0x2A61B101, (q31_t)0x78C7ABA1, (q31_t)0x2A02C7B8, (q31_t)0x78E8CFB1, + (q31_t)0x29A3C484, (q31_t)0x7909A92C, (q31_t)0x2944A7A2, (q31_t)0x792A37FE, + (q31_t)0x28E5714A, (q31_t)0x794A7C11, (q31_t)0x288621B9, (q31_t)0x796A7554, + (q31_t)0x2826B928, (q31_t)0x798A23B1, (q31_t)0x27C737D2, (q31_t)0x79A98715, + (q31_t)0x27679DF4, (q31_t)0x79C89F6D, (q31_t)0x2707EBC6, (q31_t)0x79E76CA6, + (q31_t)0x26A82185, (q31_t)0x7A05EEAD, (q31_t)0x26483F6C, (q31_t)0x7A24256E, + (q31_t)0x25E845B5, (q31_t)0x7A4210D8, (q31_t)0x2588349D, (q31_t)0x7A5FB0D8, + (q31_t)0x25280C5D, (q31_t)0x7A7D055B, (q31_t)0x24C7CD32, (q31_t)0x7A9A0E4F, + (q31_t)0x24677757, (q31_t)0x7AB6CBA3, (q31_t)0x24070B07, (q31_t)0x7AD33D45, + (q31_t)0x23A6887E, (q31_t)0x7AEF6323, (q31_t)0x2345EFF7, (q31_t)0x7B0B3D2C, + (q31_t)0x22E541AE, (q31_t)0x7B26CB4F, (q31_t)0x22847DDF, (q31_t)0x7B420D7A, + (q31_t)0x2223A4C5, (q31_t)0x7B5D039D, (q31_t)0x21C2B69C, (q31_t)0x7B77ADA8, + (q31_t)0x2161B39F, (q31_t)0x7B920B89, (q31_t)0x21009C0B, (q31_t)0x7BAC1D31, + (q31_t)0x209F701C, (q31_t)0x7BC5E28F, (q31_t)0x203E300D, (q31_t)0x7BDF5B94, + (q31_t)0x1FDCDC1A, (q31_t)0x7BF88830, (q31_t)0x1F7B7480, (q31_t)0x7C116853, + (q31_t)0x1F19F97B, (q31_t)0x7C29FBEE, (q31_t)0x1EB86B46, (q31_t)0x7C4242F2, + (q31_t)0x1E56CA1E, (q31_t)0x7C5A3D4F, (q31_t)0x1DF5163F, (q31_t)0x7C71EAF8, + (q31_t)0x1D934FE5, (q31_t)0x7C894BDD, (q31_t)0x1D31774D, (q31_t)0x7CA05FF1, + (q31_t)0x1CCF8CB3, (q31_t)0x7CB72724, (q31_t)0x1C6D9053, (q31_t)0x7CCDA168, + (q31_t)0x1C0B826A, (q31_t)0x7CE3CEB1, (q31_t)0x1BA96334, (q31_t)0x7CF9AEF0, + (q31_t)0x1B4732EF, (q31_t)0x7D0F4218, (q31_t)0x1AE4F1D6, (q31_t)0x7D24881A, + (q31_t)0x1A82A025, (q31_t)0x7D3980EC, (q31_t)0x1A203E1B, (q31_t)0x7D4E2C7E, + (q31_t)0x19BDCBF2, (q31_t)0x7D628AC5, (q31_t)0x195B49E9, (q31_t)0x7D769BB5, + (q31_t)0x18F8B83C, (q31_t)0x7D8A5F3F, (q31_t)0x18961727, (q31_t)0x7D9DD55A, + (q31_t)0x183366E8, (q31_t)0x7DB0FDF7, (q31_t)0x17D0A7BB, (q31_t)0x7DC3D90D, + (q31_t)0x176DD9DE, (q31_t)0x7DD6668E, (q31_t)0x170AFD8D, (q31_t)0x7DE8A670, + (q31_t)0x16A81305, (q31_t)0x7DFA98A7, (q31_t)0x16451A83, (q31_t)0x7E0C3D29, + (q31_t)0x15E21444, (q31_t)0x7E1D93E9, (q31_t)0x157F0086, (q31_t)0x7E2E9CDF, + (q31_t)0x151BDF85, (q31_t)0x7E3F57FE, (q31_t)0x14B8B17F, (q31_t)0x7E4FC53E, + (q31_t)0x145576B1, (q31_t)0x7E5FE493, (q31_t)0x13F22F57, (q31_t)0x7E6FB5F3, + (q31_t)0x138EDBB0, (q31_t)0x7E7F3956, (q31_t)0x132B7BF9, (q31_t)0x7E8E6EB1, + (q31_t)0x12C8106E, (q31_t)0x7E9D55FC, (q31_t)0x1264994E, (q31_t)0x7EABEF2C, + (q31_t)0x120116D4, (q31_t)0x7EBA3A39, (q31_t)0x119D8940, (q31_t)0x7EC8371A, + (q31_t)0x1139F0CE, (q31_t)0x7ED5E5C6, (q31_t)0x10D64DBC, (q31_t)0x7EE34635, + (q31_t)0x1072A047, (q31_t)0x7EF0585F, (q31_t)0x100EE8AD, (q31_t)0x7EFD1C3C, + (q31_t)0x0FAB272B, (q31_t)0x7F0991C3, (q31_t)0x0F475BFE, (q31_t)0x7F15B8EE, + (q31_t)0x0EE38765, (q31_t)0x7F2191B4, (q31_t)0x0E7FA99D, (q31_t)0x7F2D1C0E, + (q31_t)0x0E1BC2E3, (q31_t)0x7F3857F5, (q31_t)0x0DB7D376, (q31_t)0x7F434563, + (q31_t)0x0D53DB92, (q31_t)0x7F4DE450, (q31_t)0x0CEFDB75, (q31_t)0x7F5834B6, + (q31_t)0x0C8BD35E, (q31_t)0x7F62368F, (q31_t)0x0C27C389, (q31_t)0x7F6BE9D4, + (q31_t)0x0BC3AC35, (q31_t)0x7F754E7F, (q31_t)0x0B5F8D9F, (q31_t)0x7F7E648B, + (q31_t)0x0AFB6805, (q31_t)0x7F872BF3, (q31_t)0x0A973BA5, (q31_t)0x7F8FA4AF, + (q31_t)0x0A3308BC, (q31_t)0x7F97CEBC, (q31_t)0x09CECF89, (q31_t)0x7F9FAA15, + (q31_t)0x096A9049, (q31_t)0x7FA736B4, (q31_t)0x09064B3A, (q31_t)0x7FAE7494, + (q31_t)0x08A2009A, (q31_t)0x7FB563B2, (q31_t)0x083DB0A7, (q31_t)0x7FBC040A, + (q31_t)0x07D95B9E, (q31_t)0x7FC25596, (q31_t)0x077501BE, (q31_t)0x7FC85853, + (q31_t)0x0710A344, (q31_t)0x7FCE0C3E, (q31_t)0x06AC406F, (q31_t)0x7FD37152, + (q31_t)0x0647D97C, (q31_t)0x7FD8878D, (q31_t)0x05E36EA9, (q31_t)0x7FDD4EEC, + (q31_t)0x057F0034, (q31_t)0x7FE1C76B, (q31_t)0x051A8E5C, (q31_t)0x7FE5F108, + (q31_t)0x04B6195D, (q31_t)0x7FE9CBC0, (q31_t)0x0451A176, (q31_t)0x7FED5790, + (q31_t)0x03ED26E6, (q31_t)0x7FF09477, (q31_t)0x0388A9E9, (q31_t)0x7FF38273, + (q31_t)0x03242ABF, (q31_t)0x7FF62182, (q31_t)0x02BFA9A4, (q31_t)0x7FF871A1, + (q31_t)0x025B26D7, (q31_t)0x7FFA72D1, (q31_t)0x01F6A296, (q31_t)0x7FFC250F, + (q31_t)0x01921D1F, (q31_t)0x7FFD885A, (q31_t)0x012D96B0, (q31_t)0x7FFE9CB2, + (q31_t)0x00C90F88, (q31_t)0x7FFF6216, (q31_t)0x006487E3, (q31_t)0x7FFFD885, + (q31_t)0x00000000, (q31_t)0x7FFFFFFF, (q31_t)0xFF9B781D, (q31_t)0x7FFFD885, + (q31_t)0xFF36F078, (q31_t)0x7FFF6216, (q31_t)0xFED2694F, (q31_t)0x7FFE9CB2, + (q31_t)0xFE6DE2E0, (q31_t)0x7FFD885A, (q31_t)0xFE095D69, (q31_t)0x7FFC250F, + (q31_t)0xFDA4D928, (q31_t)0x7FFA72D1, (q31_t)0xFD40565B, (q31_t)0x7FF871A1, + (q31_t)0xFCDBD541, (q31_t)0x7FF62182, (q31_t)0xFC775616, (q31_t)0x7FF38273, + (q31_t)0xFC12D919, (q31_t)0x7FF09477, (q31_t)0xFBAE5E89, (q31_t)0x7FED5790, + (q31_t)0xFB49E6A2, (q31_t)0x7FE9CBC0, (q31_t)0xFAE571A4, (q31_t)0x7FE5F108, + (q31_t)0xFA80FFCB, (q31_t)0x7FE1C76B, (q31_t)0xFA1C9156, (q31_t)0x7FDD4EEC, + (q31_t)0xF9B82683, (q31_t)0x7FD8878D, (q31_t)0xF953BF90, (q31_t)0x7FD37152, + (q31_t)0xF8EF5CBB, (q31_t)0x7FCE0C3E, (q31_t)0xF88AFE41, (q31_t)0x7FC85853, + (q31_t)0xF826A461, (q31_t)0x7FC25596, (q31_t)0xF7C24F58, (q31_t)0x7FBC040A, + (q31_t)0xF75DFF65, (q31_t)0x7FB563B2, (q31_t)0xF6F9B4C5, (q31_t)0x7FAE7494, + (q31_t)0xF6956FB6, (q31_t)0x7FA736B4, (q31_t)0xF6313076, (q31_t)0x7F9FAA15, + (q31_t)0xF5CCF743, (q31_t)0x7F97CEBC, (q31_t)0xF568C45A, (q31_t)0x7F8FA4AF, + (q31_t)0xF50497FA, (q31_t)0x7F872BF3, (q31_t)0xF4A07260, (q31_t)0x7F7E648B, + (q31_t)0xF43C53CA, (q31_t)0x7F754E7F, (q31_t)0xF3D83C76, (q31_t)0x7F6BE9D4, + (q31_t)0xF3742CA1, (q31_t)0x7F62368F, (q31_t)0xF310248A, (q31_t)0x7F5834B6, + (q31_t)0xF2AC246D, (q31_t)0x7F4DE450, (q31_t)0xF2482C89, (q31_t)0x7F434563, + (q31_t)0xF1E43D1C, (q31_t)0x7F3857F5, (q31_t)0xF1805662, (q31_t)0x7F2D1C0E, + (q31_t)0xF11C789A, (q31_t)0x7F2191B4, (q31_t)0xF0B8A401, (q31_t)0x7F15B8EE, + (q31_t)0xF054D8D4, (q31_t)0x7F0991C3, (q31_t)0xEFF11752, (q31_t)0x7EFD1C3C, + (q31_t)0xEF8D5FB8, (q31_t)0x7EF0585F, (q31_t)0xEF29B243, (q31_t)0x7EE34635, + (q31_t)0xEEC60F31, (q31_t)0x7ED5E5C6, (q31_t)0xEE6276BF, (q31_t)0x7EC8371A, + (q31_t)0xEDFEE92B, (q31_t)0x7EBA3A39, (q31_t)0xED9B66B2, (q31_t)0x7EABEF2C, + (q31_t)0xED37EF91, (q31_t)0x7E9D55FC, (q31_t)0xECD48406, (q31_t)0x7E8E6EB1, + (q31_t)0xEC71244F, (q31_t)0x7E7F3956, (q31_t)0xEC0DD0A8, (q31_t)0x7E6FB5F3, + (q31_t)0xEBAA894E, (q31_t)0x7E5FE493, (q31_t)0xEB474E80, (q31_t)0x7E4FC53E, + (q31_t)0xEAE4207A, (q31_t)0x7E3F57FE, (q31_t)0xEA80FF79, (q31_t)0x7E2E9CDF, + (q31_t)0xEA1DEBBB, (q31_t)0x7E1D93E9, (q31_t)0xE9BAE57C, (q31_t)0x7E0C3D29, + (q31_t)0xE957ECFB, (q31_t)0x7DFA98A7, (q31_t)0xE8F50273, (q31_t)0x7DE8A670, + (q31_t)0xE8922621, (q31_t)0x7DD6668E, (q31_t)0xE82F5844, (q31_t)0x7DC3D90D, + (q31_t)0xE7CC9917, (q31_t)0x7DB0FDF7, (q31_t)0xE769E8D8, (q31_t)0x7D9DD55A, + (q31_t)0xE70747C3, (q31_t)0x7D8A5F3F, (q31_t)0xE6A4B616, (q31_t)0x7D769BB5, + (q31_t)0xE642340D, (q31_t)0x7D628AC5, (q31_t)0xE5DFC1E4, (q31_t)0x7D4E2C7E, + (q31_t)0xE57D5FDA, (q31_t)0x7D3980EC, (q31_t)0xE51B0E2A, (q31_t)0x7D24881A, + (q31_t)0xE4B8CD10, (q31_t)0x7D0F4218, (q31_t)0xE4569CCB, (q31_t)0x7CF9AEF0, + (q31_t)0xE3F47D95, (q31_t)0x7CE3CEB1, (q31_t)0xE3926FAC, (q31_t)0x7CCDA168, + (q31_t)0xE330734C, (q31_t)0x7CB72724, (q31_t)0xE2CE88B2, (q31_t)0x7CA05FF1, + (q31_t)0xE26CB01A, (q31_t)0x7C894BDD, (q31_t)0xE20AE9C1, (q31_t)0x7C71EAF8, + (q31_t)0xE1A935E1, (q31_t)0x7C5A3D4F, (q31_t)0xE14794B9, (q31_t)0x7C4242F2, + (q31_t)0xE0E60684, (q31_t)0x7C29FBEE, (q31_t)0xE0848B7F, (q31_t)0x7C116853, + (q31_t)0xE02323E5, (q31_t)0x7BF88830, (q31_t)0xDFC1CFF2, (q31_t)0x7BDF5B94, + (q31_t)0xDF608FE3, (q31_t)0x7BC5E28F, (q31_t)0xDEFF63F4, (q31_t)0x7BAC1D31, + (q31_t)0xDE9E4C60, (q31_t)0x7B920B89, (q31_t)0xDE3D4963, (q31_t)0x7B77ADA8, + (q31_t)0xDDDC5B3A, (q31_t)0x7B5D039D, (q31_t)0xDD7B8220, (q31_t)0x7B420D7A, + (q31_t)0xDD1ABE51, (q31_t)0x7B26CB4F, (q31_t)0xDCBA1008, (q31_t)0x7B0B3D2C, + (q31_t)0xDC597781, (q31_t)0x7AEF6323, (q31_t)0xDBF8F4F8, (q31_t)0x7AD33D45, + (q31_t)0xDB9888A8, (q31_t)0x7AB6CBA3, (q31_t)0xDB3832CD, (q31_t)0x7A9A0E4F, + (q31_t)0xDAD7F3A2, (q31_t)0x7A7D055B, (q31_t)0xDA77CB62, (q31_t)0x7A5FB0D8, + (q31_t)0xDA17BA4A, (q31_t)0x7A4210D8, (q31_t)0xD9B7C093, (q31_t)0x7A24256E, + (q31_t)0xD957DE7A, (q31_t)0x7A05EEAD, (q31_t)0xD8F81439, (q31_t)0x79E76CA6, + (q31_t)0xD898620C, (q31_t)0x79C89F6D, (q31_t)0xD838C82D, (q31_t)0x79A98715, + (q31_t)0xD7D946D7, (q31_t)0x798A23B1, (q31_t)0xD779DE46, (q31_t)0x796A7554, + (q31_t)0xD71A8EB5, (q31_t)0x794A7C11, (q31_t)0xD6BB585D, (q31_t)0x792A37FE, + (q31_t)0xD65C3B7B, (q31_t)0x7909A92C, (q31_t)0xD5FD3847, (q31_t)0x78E8CFB1, + (q31_t)0xD59E4EFE, (q31_t)0x78C7ABA1, (q31_t)0xD53F7FDA, (q31_t)0x78A63D10, + (q31_t)0xD4E0CB14, (q31_t)0x78848413, (q31_t)0xD48230E8, (q31_t)0x786280BF, + (q31_t)0xD423B190, (q31_t)0x78403328, (q31_t)0xD3C54D46, (q31_t)0x781D9B64, + (q31_t)0xD3670445, (q31_t)0x77FAB988, (q31_t)0xD308D6C6, (q31_t)0x77D78DAA, + (q31_t)0xD2AAC504, (q31_t)0x77B417DF, (q31_t)0xD24CCF38, (q31_t)0x7790583D, + (q31_t)0xD1EEF59E, (q31_t)0x776C4EDB, (q31_t)0xD191386D, (q31_t)0x7747FBCE, + (q31_t)0xD13397E1, (q31_t)0x77235F2D, (q31_t)0xD0D61433, (q31_t)0x76FE790E, + (q31_t)0xD078AD9D, (q31_t)0x76D94988, (q31_t)0xD01B6459, (q31_t)0x76B3D0B3, + (q31_t)0xCFBE389F, (q31_t)0x768E0EA5, (q31_t)0xCF612AAA, (q31_t)0x76680376, + (q31_t)0xCF043AB2, (q31_t)0x7641AF3C, (q31_t)0xCEA768F2, (q31_t)0x761B1211, + (q31_t)0xCE4AB5A2, (q31_t)0x75F42C0A, (q31_t)0xCDEE20FC, (q31_t)0x75CCFD42, + (q31_t)0xCD91AB38, (q31_t)0x75A585CF, (q31_t)0xCD355490, (q31_t)0x757DC5CA, + (q31_t)0xCCD91D3D, (q31_t)0x7555BD4B, (q31_t)0xCC7D0577, (q31_t)0x752D6C6C, + (q31_t)0xCC210D78, (q31_t)0x7504D345, (q31_t)0xCBC53578, (q31_t)0x74DBF1EF, + (q31_t)0xCB697DB0, (q31_t)0x74B2C883, (q31_t)0xCB0DE658, (q31_t)0x7489571B, + (q31_t)0xCAB26FA9, (q31_t)0x745F9DD1, (q31_t)0xCA5719DB, (q31_t)0x74359CBD, + (q31_t)0xC9FBE527, (q31_t)0x740B53FA, (q31_t)0xC9A0D1C4, (q31_t)0x73E0C3A3, + (q31_t)0xC945DFEC, (q31_t)0x73B5EBD0, (q31_t)0xC8EB0FD6, (q31_t)0x738ACC9E, + (q31_t)0xC89061BA, (q31_t)0x735F6626, (q31_t)0xC835D5D0, (q31_t)0x7333B883, + (q31_t)0xC7DB6C50, (q31_t)0x7307C3D0, (q31_t)0xC7812571, (q31_t)0x72DB8828, + (q31_t)0xC727016C, (q31_t)0x72AF05A6, (q31_t)0xC6CD0079, (q31_t)0x72823C66, + (q31_t)0xC67322CD, (q31_t)0x72552C84, (q31_t)0xC61968A2, (q31_t)0x7227D61C, + (q31_t)0xC5BFD22E, (q31_t)0x71FA3948, (q31_t)0xC5665FA8, (q31_t)0x71CC5626, + (q31_t)0xC50D1148, (q31_t)0x719E2CD2, (q31_t)0xC4B3E746, (q31_t)0x716FBD68, + (q31_t)0xC45AE1D7, (q31_t)0x71410804, (q31_t)0xC4020132, (q31_t)0x71120CC5, + (q31_t)0xC3A9458F, (q31_t)0x70E2CBC6, (q31_t)0xC350AF25, (q31_t)0x70B34524, + (q31_t)0xC2F83E2A, (q31_t)0x708378FE, (q31_t)0xC29FF2D4, (q31_t)0x70536771, + (q31_t)0xC247CD5A, (q31_t)0x70231099, (q31_t)0xC1EFCDF2, (q31_t)0x6FF27496, + (q31_t)0xC197F4D3, (q31_t)0x6FC19385, (q31_t)0xC1404233, (q31_t)0x6F906D84, + (q31_t)0xC0E8B648, (q31_t)0x6F5F02B1, (q31_t)0xC0915147, (q31_t)0x6F2D532C, + (q31_t)0xC03A1368, (q31_t)0x6EFB5F12, (q31_t)0xBFE2FCDF, (q31_t)0x6EC92682, + (q31_t)0xBF8C0DE2, (q31_t)0x6E96A99C, (q31_t)0xBF3546A8, (q31_t)0x6E63E87F, + (q31_t)0xBEDEA765, (q31_t)0x6E30E349, (q31_t)0xBE88304F, (q31_t)0x6DFD9A1B, + (q31_t)0xBE31E19B, (q31_t)0x6DCA0D14, (q31_t)0xBDDBBB7F, (q31_t)0x6D963C54, + (q31_t)0xBD85BE2F, (q31_t)0x6D6227FA, (q31_t)0xBD2FE9E1, (q31_t)0x6D2DD027, + (q31_t)0xBCDA3ECA, (q31_t)0x6CF934FB, (q31_t)0xBC84BD1E, (q31_t)0x6CC45697, + (q31_t)0xBC2F6513, (q31_t)0x6C8F351C, (q31_t)0xBBDA36DC, (q31_t)0x6C59D0A9, + (q31_t)0xBB8532AF, (q31_t)0x6C242960, (q31_t)0xBB3058C0, (q31_t)0x6BEE3F62, + (q31_t)0xBADBA943, (q31_t)0x6BB812D0, (q31_t)0xBA87246C, (q31_t)0x6B81A3CD, + (q31_t)0xBA32CA70, (q31_t)0x6B4AF278, (q31_t)0xB9DE9B83, (q31_t)0x6B13FEF5, + (q31_t)0xB98A97D8, (q31_t)0x6ADCC964, (q31_t)0xB936BFA3, (q31_t)0x6AA551E8, + (q31_t)0xB8E31319, (q31_t)0x6A6D98A4, (q31_t)0xB88F926C, (q31_t)0x6A359DB9, + (q31_t)0xB83C3DD1, (q31_t)0x69FD614A, (q31_t)0xB7E9157A, (q31_t)0x69C4E37A, + (q31_t)0xB796199B, (q31_t)0x698C246C, (q31_t)0xB7434A67, (q31_t)0x69532442, + (q31_t)0xB6F0A811, (q31_t)0x6919E320, (q31_t)0xB69E32CD, (q31_t)0x68E06129, + (q31_t)0xB64BEACC, (q31_t)0x68A69E81, (q31_t)0xB5F9D042, (q31_t)0x686C9B4B, + (q31_t)0xB5A7E362, (q31_t)0x683257AA, (q31_t)0xB556245E, (q31_t)0x67F7D3C4, + (q31_t)0xB5049368, (q31_t)0x67BD0FBC, (q31_t)0xB4B330B2, (q31_t)0x67820BB6, + (q31_t)0xB461FC70, (q31_t)0x6746C7D7, (q31_t)0xB410F6D2, (q31_t)0x670B4443, + (q31_t)0xB3C0200C, (q31_t)0x66CF811F, (q31_t)0xB36F784E, (q31_t)0x66937E90, + (q31_t)0xB31EFFCB, (q31_t)0x66573CBB, (q31_t)0xB2CEB6B5, (q31_t)0x661ABBC5, + (q31_t)0xB27E9D3B, (q31_t)0x65DDFBD3, (q31_t)0xB22EB392, (q31_t)0x65A0FD0B, + (q31_t)0xB1DEF9E8, (q31_t)0x6563BF92, (q31_t)0xB18F7070, (q31_t)0x6526438E, + (q31_t)0xB140175B, (q31_t)0x64E88926, (q31_t)0xB0F0EEDA, (q31_t)0x64AA907F, + (q31_t)0xB0A1F71C, (q31_t)0x646C59BF, (q31_t)0xB0533055, (q31_t)0x642DE50D, + (q31_t)0xB0049AB2, (q31_t)0x63EF328F, (q31_t)0xAFB63667, (q31_t)0x63B0426D, + (q31_t)0xAF6803A1, (q31_t)0x637114CC, (q31_t)0xAF1A0293, (q31_t)0x6331A9D4, + (q31_t)0xAECC336B, (q31_t)0x62F201AC, (q31_t)0xAE7E965B, (q31_t)0x62B21C7B, + (q31_t)0xAE312B91, (q31_t)0x6271FA69, (q31_t)0xADE3F33E, (q31_t)0x62319B9D, + (q31_t)0xAD96ED91, (q31_t)0x61F1003E, (q31_t)0xAD4A1ABA, (q31_t)0x61B02876, + (q31_t)0xACFD7AE8, (q31_t)0x616F146B, (q31_t)0xACB10E4A, (q31_t)0x612DC446, + (q31_t)0xAC64D510, (q31_t)0x60EC3830, (q31_t)0xAC18CF68, (q31_t)0x60AA704F, + (q31_t)0xABCCFD82, (q31_t)0x60686CCE, (q31_t)0xAB815F8C, (q31_t)0x60262DD5, + (q31_t)0xAB35F5B5, (q31_t)0x5FE3B38D, (q31_t)0xAAEAC02B, (q31_t)0x5FA0FE1E, + (q31_t)0xAA9FBF1D, (q31_t)0x5F5E0DB3, (q31_t)0xAA54F2B9, (q31_t)0x5F1AE273, + (q31_t)0xAA0A5B2D, (q31_t)0x5ED77C89, (q31_t)0xA9BFF8A8, (q31_t)0x5E93DC1F, + (q31_t)0xA975CB56, (q31_t)0x5E50015D, (q31_t)0xA92BD366, (q31_t)0x5E0BEC6E, + (q31_t)0xA8E21106, (q31_t)0x5DC79D7C, (q31_t)0xA8988463, (q31_t)0x5D8314B0, + (q31_t)0xA84F2DA9, (q31_t)0x5D3E5236, (q31_t)0xA8060D08, (q31_t)0x5CF95638, + (q31_t)0xA7BD22AB, (q31_t)0x5CB420DF, (q31_t)0xA7746EC0, (q31_t)0x5C6EB258, + (q31_t)0xA72BF173, (q31_t)0x5C290ACC, (q31_t)0xA6E3AAF2, (q31_t)0x5BE32A67, + (q31_t)0xA69B9B68, (q31_t)0x5B9D1153, (q31_t)0xA653C302, (q31_t)0x5B56BFBD, + (q31_t)0xA60C21ED, (q31_t)0x5B1035CF, (q31_t)0xA5C4B855, (q31_t)0x5AC973B4, + (q31_t)0xA57D8666, (q31_t)0x5A82799A, (q31_t)0xA5368C4B, (q31_t)0x5A3B47AA, + (q31_t)0xA4EFCA31, (q31_t)0x59F3DE12, (q31_t)0xA4A94042, (q31_t)0x59AC3CFD, + (q31_t)0xA462EEAC, (q31_t)0x59646497, (q31_t)0xA41CD598, (q31_t)0x591C550E, + (q31_t)0xA3D6F533, (q31_t)0x58D40E8C, (q31_t)0xA3914DA7, (q31_t)0x588B913F, + (q31_t)0xA34BDF20, (q31_t)0x5842DD54, (q31_t)0xA306A9C7, (q31_t)0x57F9F2F7, + (q31_t)0xA2C1ADC9, (q31_t)0x57B0D256, (q31_t)0xA27CEB4F, (q31_t)0x57677B9D, + (q31_t)0xA2386283, (q31_t)0x571DEEF9, (q31_t)0xA1F41391, (q31_t)0x56D42C99, + (q31_t)0xA1AFFEA2, (q31_t)0x568A34A9, (q31_t)0xA16C23E1, (q31_t)0x56400757, + (q31_t)0xA1288376, (q31_t)0x55F5A4D2, (q31_t)0xA0E51D8C, (q31_t)0x55AB0D46, + (q31_t)0xA0A1F24C, (q31_t)0x556040E2, (q31_t)0xA05F01E1, (q31_t)0x55153FD4, + (q31_t)0xA01C4C72, (q31_t)0x54CA0A4A, (q31_t)0x9FD9D22A, (q31_t)0x547EA073, + (q31_t)0x9F979331, (q31_t)0x5433027D, (q31_t)0x9F558FB0, (q31_t)0x53E73097, + (q31_t)0x9F13C7D0, (q31_t)0x539B2AEF, (q31_t)0x9ED23BB9, (q31_t)0x534EF1B5, + (q31_t)0x9E90EB94, (q31_t)0x53028517, (q31_t)0x9E4FD789, (q31_t)0x52B5E545, + (q31_t)0x9E0EFFC1, (q31_t)0x5269126E, (q31_t)0x9DCE6462, (q31_t)0x521C0CC1, + (q31_t)0x9D8E0596, (q31_t)0x51CED46E, (q31_t)0x9D4DE384, (q31_t)0x518169A4, + (q31_t)0x9D0DFE53, (q31_t)0x5133CC94, (q31_t)0x9CCE562B, (q31_t)0x50E5FD6C, + (q31_t)0x9C8EEB33, (q31_t)0x5097FC5E, (q31_t)0x9C4FBD92, (q31_t)0x5049C999, + (q31_t)0x9C10CD70, (q31_t)0x4FFB654D, (q31_t)0x9BD21AF2, (q31_t)0x4FACCFAB, + (q31_t)0x9B93A640, (q31_t)0x4F5E08E3, (q31_t)0x9B556F80, (q31_t)0x4F0F1126, + (q31_t)0x9B1776D9, (q31_t)0x4EBFE8A4, (q31_t)0x9AD9BC71, (q31_t)0x4E708F8F, + (q31_t)0x9A9C406D, (q31_t)0x4E210617, (q31_t)0x9A5F02F5, (q31_t)0x4DD14C6E, + (q31_t)0x9A22042C, (q31_t)0x4D8162C4, (q31_t)0x99E5443A, (q31_t)0x4D31494B, + (q31_t)0x99A8C344, (q31_t)0x4CE10034, (q31_t)0x996C816F, (q31_t)0x4C9087B1, + (q31_t)0x99307EE0, (q31_t)0x4C3FDFF3, (q31_t)0x98F4BBBC, (q31_t)0x4BEF092D, + (q31_t)0x98B93828, (q31_t)0x4B9E038F, (q31_t)0x987DF449, (q31_t)0x4B4CCF4D, + (q31_t)0x9842F043, (q31_t)0x4AFB6C97, (q31_t)0x98082C3B, (q31_t)0x4AA9DBA1, + (q31_t)0x97CDA855, (q31_t)0x4A581C9D, (q31_t)0x979364B5, (q31_t)0x4A062FBD, + (q31_t)0x9759617E, (q31_t)0x49B41533, (q31_t)0x971F9ED6, (q31_t)0x4961CD32, + (q31_t)0x96E61CDF, (q31_t)0x490F57EE, (q31_t)0x96ACDBBD, (q31_t)0x48BCB598, + (q31_t)0x9673DB94, (q31_t)0x4869E664, (q31_t)0x963B1C85, (q31_t)0x4816EA85, + (q31_t)0x96029EB5, (q31_t)0x47C3C22E, (q31_t)0x95CA6246, (q31_t)0x47706D93, + (q31_t)0x9592675B, (q31_t)0x471CECE6, (q31_t)0x955AAE17, (q31_t)0x46C9405C, + (q31_t)0x9523369B, (q31_t)0x46756827, (q31_t)0x94EC010B, (q31_t)0x4621647C, + (q31_t)0x94B50D87, (q31_t)0x45CD358F, (q31_t)0x947E5C32, (q31_t)0x4578DB93, + (q31_t)0x9447ED2F, (q31_t)0x452456BC, (q31_t)0x9411C09D, (q31_t)0x44CFA73F, + (q31_t)0x93DBD69F, (q31_t)0x447ACD50, (q31_t)0x93A62F56, (q31_t)0x4425C923, + (q31_t)0x9370CAE4, (q31_t)0x43D09AEC, (q31_t)0x933BA968, (q31_t)0x437B42E1, + (q31_t)0x9306CB04, (q31_t)0x4325C135, (q31_t)0x92D22FD8, (q31_t)0x42D0161E, + (q31_t)0x929DD805, (q31_t)0x427A41D0, (q31_t)0x9269C3AC, (q31_t)0x42244480, + (q31_t)0x9235F2EB, (q31_t)0x41CE1E64, (q31_t)0x920265E4, (q31_t)0x4177CFB0, + (q31_t)0x91CF1CB6, (q31_t)0x4121589A, (q31_t)0x919C1780, (q31_t)0x40CAB957, + (q31_t)0x91695663, (q31_t)0x4073F21D, (q31_t)0x9136D97D, (q31_t)0x401D0320, + (q31_t)0x9104A0ED, (q31_t)0x3FC5EC97, (q31_t)0x90D2ACD3, (q31_t)0x3F6EAEB8, + (q31_t)0x90A0FD4E, (q31_t)0x3F1749B7, (q31_t)0x906F927B, (q31_t)0x3EBFBDCC, + (q31_t)0x903E6C7A, (q31_t)0x3E680B2C, (q31_t)0x900D8B69, (q31_t)0x3E10320D, + (q31_t)0x8FDCEF66, (q31_t)0x3DB832A5, (q31_t)0x8FAC988E, (q31_t)0x3D600D2B, + (q31_t)0x8F7C8701, (q31_t)0x3D07C1D5, (q31_t)0x8F4CBADB, (q31_t)0x3CAF50DA, + (q31_t)0x8F1D343A, (q31_t)0x3C56BA70, (q31_t)0x8EEDF33B, (q31_t)0x3BFDFECD, + (q31_t)0x8EBEF7FB, (q31_t)0x3BA51E29, (q31_t)0x8E904298, (q31_t)0x3B4C18BA, + (q31_t)0x8E61D32D, (q31_t)0x3AF2EEB7, (q31_t)0x8E33A9D9, (q31_t)0x3A99A057, + (q31_t)0x8E05C6B7, (q31_t)0x3A402DD1, (q31_t)0x8DD829E4, (q31_t)0x39E6975D, + (q31_t)0x8DAAD37B, (q31_t)0x398CDD32, (q31_t)0x8D7DC399, (q31_t)0x3932FF87, + (q31_t)0x8D50FA59, (q31_t)0x38D8FE93, (q31_t)0x8D2477D8, (q31_t)0x387EDA8E, + (q31_t)0x8CF83C30, (q31_t)0x382493B0, (q31_t)0x8CCC477D, (q31_t)0x37CA2A30, + (q31_t)0x8CA099D9, (q31_t)0x376F9E46, (q31_t)0x8C753361, (q31_t)0x3714F02A, + (q31_t)0x8C4A142F, (q31_t)0x36BA2013, (q31_t)0x8C1F3C5C, (q31_t)0x365F2E3B, + (q31_t)0x8BF4AC05, (q31_t)0x36041AD9, (q31_t)0x8BCA6342, (q31_t)0x35A8E624, + (q31_t)0x8BA0622F, (q31_t)0x354D9056, (q31_t)0x8B76A8E4, (q31_t)0x34F219A7, + (q31_t)0x8B4D377C, (q31_t)0x3496824F, (q31_t)0x8B240E10, (q31_t)0x343ACA87, + (q31_t)0x8AFB2CBA, (q31_t)0x33DEF287, (q31_t)0x8AD29393, (q31_t)0x3382FA88, + (q31_t)0x8AAA42B4, (q31_t)0x3326E2C2, (q31_t)0x8A823A35, (q31_t)0x32CAAB6F, + (q31_t)0x8A5A7A30, (q31_t)0x326E54C7, (q31_t)0x8A3302BD, (q31_t)0x3211DF03, + (q31_t)0x8A0BD3F5, (q31_t)0x31B54A5D, (q31_t)0x89E4EDEE, (q31_t)0x3158970D, + (q31_t)0x89BE50C3, (q31_t)0x30FBC54D, (q31_t)0x8997FC89, (q31_t)0x309ED555, + (q31_t)0x8971F15A, (q31_t)0x3041C760, (q31_t)0x894C2F4C, (q31_t)0x2FE49BA6, + (q31_t)0x8926B677, (q31_t)0x2F875262, (q31_t)0x890186F1, (q31_t)0x2F29EBCC, + (q31_t)0x88DCA0D3, (q31_t)0x2ECC681E, (q31_t)0x88B80431, (q31_t)0x2E6EC792, + (q31_t)0x8893B124, (q31_t)0x2E110A62, (q31_t)0x886FA7C2, (q31_t)0x2DB330C7, + (q31_t)0x884BE820, (q31_t)0x2D553AFB, (q31_t)0x88287255, (q31_t)0x2CF72939, + (q31_t)0x88054677, (q31_t)0x2C98FBBA, (q31_t)0x87E2649B, (q31_t)0x2C3AB2B9, + (q31_t)0x87BFCCD7, (q31_t)0x2BDC4E6F, (q31_t)0x879D7F40, (q31_t)0x2B7DCF17, + (q31_t)0x877B7BEC, (q31_t)0x2B1F34EB, (q31_t)0x8759C2EF, (q31_t)0x2AC08025, + (q31_t)0x8738545E, (q31_t)0x2A61B101, (q31_t)0x8717304E, (q31_t)0x2A02C7B8, + (q31_t)0x86F656D3, (q31_t)0x29A3C484, (q31_t)0x86D5C802, (q31_t)0x2944A7A2, + (q31_t)0x86B583EE, (q31_t)0x28E5714A, (q31_t)0x86958AAB, (q31_t)0x288621B9, + (q31_t)0x8675DC4E, (q31_t)0x2826B928, (q31_t)0x865678EA, (q31_t)0x27C737D2, + (q31_t)0x86376092, (q31_t)0x27679DF4, (q31_t)0x86189359, (q31_t)0x2707EBC6, + (q31_t)0x85FA1152, (q31_t)0x26A82185, (q31_t)0x85DBDA91, (q31_t)0x26483F6C, + (q31_t)0x85BDEF27, (q31_t)0x25E845B5, (q31_t)0x85A04F28, (q31_t)0x2588349D, + (q31_t)0x8582FAA4, (q31_t)0x25280C5D, (q31_t)0x8565F1B0, (q31_t)0x24C7CD32, + (q31_t)0x8549345C, (q31_t)0x24677757, (q31_t)0x852CC2BA, (q31_t)0x24070B07, + (q31_t)0x85109CDC, (q31_t)0x23A6887E, (q31_t)0x84F4C2D3, (q31_t)0x2345EFF7, + (q31_t)0x84D934B0, (q31_t)0x22E541AE, (q31_t)0x84BDF285, (q31_t)0x22847DDF, + (q31_t)0x84A2FC62, (q31_t)0x2223A4C5, (q31_t)0x84885257, (q31_t)0x21C2B69C, + (q31_t)0x846DF476, (q31_t)0x2161B39F, (q31_t)0x8453E2CE, (q31_t)0x21009C0B, + (q31_t)0x843A1D70, (q31_t)0x209F701C, (q31_t)0x8420A46B, (q31_t)0x203E300D, + (q31_t)0x840777CF, (q31_t)0x1FDCDC1A, (q31_t)0x83EE97AC, (q31_t)0x1F7B7480, + (q31_t)0x83D60411, (q31_t)0x1F19F97B, (q31_t)0x83BDBD0D, (q31_t)0x1EB86B46, + (q31_t)0x83A5C2B0, (q31_t)0x1E56CA1E, (q31_t)0x838E1507, (q31_t)0x1DF5163F, + (q31_t)0x8376B422, (q31_t)0x1D934FE5, (q31_t)0x835FA00E, (q31_t)0x1D31774D, + (q31_t)0x8348D8DB, (q31_t)0x1CCF8CB3, (q31_t)0x83325E97, (q31_t)0x1C6D9053, + (q31_t)0x831C314E, (q31_t)0x1C0B826A, (q31_t)0x8306510F, (q31_t)0x1BA96334, + (q31_t)0x82F0BDE8, (q31_t)0x1B4732EF, (q31_t)0x82DB77E5, (q31_t)0x1AE4F1D6, + (q31_t)0x82C67F13, (q31_t)0x1A82A025, (q31_t)0x82B1D381, (q31_t)0x1A203E1B, + (q31_t)0x829D753A, (q31_t)0x19BDCBF2, (q31_t)0x8289644A, (q31_t)0x195B49E9, + (q31_t)0x8275A0C0, (q31_t)0x18F8B83C, (q31_t)0x82622AA5, (q31_t)0x18961727, + (q31_t)0x824F0208, (q31_t)0x183366E8, (q31_t)0x823C26F2, (q31_t)0x17D0A7BB, + (q31_t)0x82299971, (q31_t)0x176DD9DE, (q31_t)0x8217598F, (q31_t)0x170AFD8D, + (q31_t)0x82056758, (q31_t)0x16A81305, (q31_t)0x81F3C2D7, (q31_t)0x16451A83, + (q31_t)0x81E26C16, (q31_t)0x15E21444, (q31_t)0x81D16320, (q31_t)0x157F0086, + (q31_t)0x81C0A801, (q31_t)0x151BDF85, (q31_t)0x81B03AC1, (q31_t)0x14B8B17F, + (q31_t)0x81A01B6C, (q31_t)0x145576B1, (q31_t)0x81904A0C, (q31_t)0x13F22F57, + (q31_t)0x8180C6A9, (q31_t)0x138EDBB0, (q31_t)0x8171914E, (q31_t)0x132B7BF9, + (q31_t)0x8162AA03, (q31_t)0x12C8106E, (q31_t)0x815410D3, (q31_t)0x1264994E, + (q31_t)0x8145C5C6, (q31_t)0x120116D4, (q31_t)0x8137C8E6, (q31_t)0x119D8940, + (q31_t)0x812A1A39, (q31_t)0x1139F0CE, (q31_t)0x811CB9CA, (q31_t)0x10D64DBC, + (q31_t)0x810FA7A0, (q31_t)0x1072A047, (q31_t)0x8102E3C3, (q31_t)0x100EE8AD, + (q31_t)0x80F66E3C, (q31_t)0x0FAB272B, (q31_t)0x80EA4712, (q31_t)0x0F475BFE, + (q31_t)0x80DE6E4C, (q31_t)0x0EE38765, (q31_t)0x80D2E3F1, (q31_t)0x0E7FA99D, + (q31_t)0x80C7A80A, (q31_t)0x0E1BC2E3, (q31_t)0x80BCBA9C, (q31_t)0x0DB7D376, + (q31_t)0x80B21BAF, (q31_t)0x0D53DB92, (q31_t)0x80A7CB49, (q31_t)0x0CEFDB75, + (q31_t)0x809DC970, (q31_t)0x0C8BD35E, (q31_t)0x8094162B, (q31_t)0x0C27C389, + (q31_t)0x808AB180, (q31_t)0x0BC3AC35, (q31_t)0x80819B74, (q31_t)0x0B5F8D9F, + (q31_t)0x8078D40D, (q31_t)0x0AFB6805, (q31_t)0x80705B50, (q31_t)0x0A973BA5, + (q31_t)0x80683143, (q31_t)0x0A3308BC, (q31_t)0x806055EA, (q31_t)0x09CECF89, + (q31_t)0x8058C94C, (q31_t)0x096A9049, (q31_t)0x80518B6B, (q31_t)0x09064B3A, + (q31_t)0x804A9C4D, (q31_t)0x08A2009A, (q31_t)0x8043FBF6, (q31_t)0x083DB0A7, + (q31_t)0x803DAA69, (q31_t)0x07D95B9E, (q31_t)0x8037A7AC, (q31_t)0x077501BE, + (q31_t)0x8031F3C1, (q31_t)0x0710A344, (q31_t)0x802C8EAD, (q31_t)0x06AC406F, + (q31_t)0x80277872, (q31_t)0x0647D97C, (q31_t)0x8022B113, (q31_t)0x05E36EA9, + (q31_t)0x801E3894, (q31_t)0x057F0034, (q31_t)0x801A0EF7, (q31_t)0x051A8E5C, + (q31_t)0x80163440, (q31_t)0x04B6195D, (q31_t)0x8012A86F, (q31_t)0x0451A176, + (q31_t)0x800F6B88, (q31_t)0x03ED26E6, (q31_t)0x800C7D8C, (q31_t)0x0388A9E9, + (q31_t)0x8009DE7D, (q31_t)0x03242ABF, (q31_t)0x80078E5E, (q31_t)0x02BFA9A4, + (q31_t)0x80058D2E, (q31_t)0x025B26D7, (q31_t)0x8003DAF0, (q31_t)0x01F6A296, + (q31_t)0x800277A5, (q31_t)0x01921D1F, (q31_t)0x8001634D, (q31_t)0x012D96B0, + (q31_t)0x80009DE9, (q31_t)0x00C90F88, (q31_t)0x8000277A, (q31_t)0x006487E3, + (q31_t)0x80000000, (q31_t)0x00000000, (q31_t)0x8000277A, (q31_t)0xFF9B781D, + (q31_t)0x80009DE9, (q31_t)0xFF36F078, (q31_t)0x8001634D, (q31_t)0xFED2694F, + (q31_t)0x800277A5, (q31_t)0xFE6DE2E0, (q31_t)0x8003DAF0, (q31_t)0xFE095D69, + (q31_t)0x80058D2E, (q31_t)0xFDA4D928, (q31_t)0x80078E5E, (q31_t)0xFD40565B, + (q31_t)0x8009DE7D, (q31_t)0xFCDBD541, (q31_t)0x800C7D8C, (q31_t)0xFC775616, + (q31_t)0x800F6B88, (q31_t)0xFC12D919, (q31_t)0x8012A86F, (q31_t)0xFBAE5E89, + (q31_t)0x80163440, (q31_t)0xFB49E6A2, (q31_t)0x801A0EF7, (q31_t)0xFAE571A4, + (q31_t)0x801E3894, (q31_t)0xFA80FFCB, (q31_t)0x8022B113, (q31_t)0xFA1C9156, + (q31_t)0x80277872, (q31_t)0xF9B82683, (q31_t)0x802C8EAD, (q31_t)0xF953BF90, + (q31_t)0x8031F3C1, (q31_t)0xF8EF5CBB, (q31_t)0x8037A7AC, (q31_t)0xF88AFE41, + (q31_t)0x803DAA69, (q31_t)0xF826A461, (q31_t)0x8043FBF6, (q31_t)0xF7C24F58, + (q31_t)0x804A9C4D, (q31_t)0xF75DFF65, (q31_t)0x80518B6B, (q31_t)0xF6F9B4C5, + (q31_t)0x8058C94C, (q31_t)0xF6956FB6, (q31_t)0x806055EA, (q31_t)0xF6313076, + (q31_t)0x80683143, (q31_t)0xF5CCF743, (q31_t)0x80705B50, (q31_t)0xF568C45A, + (q31_t)0x8078D40D, (q31_t)0xF50497FA, (q31_t)0x80819B74, (q31_t)0xF4A07260, + (q31_t)0x808AB180, (q31_t)0xF43C53CA, (q31_t)0x8094162B, (q31_t)0xF3D83C76, + (q31_t)0x809DC970, (q31_t)0xF3742CA1, (q31_t)0x80A7CB49, (q31_t)0xF310248A, + (q31_t)0x80B21BAF, (q31_t)0xF2AC246D, (q31_t)0x80BCBA9C, (q31_t)0xF2482C89, + (q31_t)0x80C7A80A, (q31_t)0xF1E43D1C, (q31_t)0x80D2E3F1, (q31_t)0xF1805662, + (q31_t)0x80DE6E4C, (q31_t)0xF11C789A, (q31_t)0x80EA4712, (q31_t)0xF0B8A401, + (q31_t)0x80F66E3C, (q31_t)0xF054D8D4, (q31_t)0x8102E3C3, (q31_t)0xEFF11752, + (q31_t)0x810FA7A0, (q31_t)0xEF8D5FB8, (q31_t)0x811CB9CA, (q31_t)0xEF29B243, + (q31_t)0x812A1A39, (q31_t)0xEEC60F31, (q31_t)0x8137C8E6, (q31_t)0xEE6276BF, + (q31_t)0x8145C5C6, (q31_t)0xEDFEE92B, (q31_t)0x815410D3, (q31_t)0xED9B66B2, + (q31_t)0x8162AA03, (q31_t)0xED37EF91, (q31_t)0x8171914E, (q31_t)0xECD48406, + (q31_t)0x8180C6A9, (q31_t)0xEC71244F, (q31_t)0x81904A0C, (q31_t)0xEC0DD0A8, + (q31_t)0x81A01B6C, (q31_t)0xEBAA894E, (q31_t)0x81B03AC1, (q31_t)0xEB474E80, + (q31_t)0x81C0A801, (q31_t)0xEAE4207A, (q31_t)0x81D16320, (q31_t)0xEA80FF79, + (q31_t)0x81E26C16, (q31_t)0xEA1DEBBB, (q31_t)0x81F3C2D7, (q31_t)0xE9BAE57C, + (q31_t)0x82056758, (q31_t)0xE957ECFB, (q31_t)0x8217598F, (q31_t)0xE8F50273, + (q31_t)0x82299971, (q31_t)0xE8922621, (q31_t)0x823C26F2, (q31_t)0xE82F5844, + (q31_t)0x824F0208, (q31_t)0xE7CC9917, (q31_t)0x82622AA5, (q31_t)0xE769E8D8, + (q31_t)0x8275A0C0, (q31_t)0xE70747C3, (q31_t)0x8289644A, (q31_t)0xE6A4B616, + (q31_t)0x829D753A, (q31_t)0xE642340D, (q31_t)0x82B1D381, (q31_t)0xE5DFC1E4, + (q31_t)0x82C67F13, (q31_t)0xE57D5FDA, (q31_t)0x82DB77E5, (q31_t)0xE51B0E2A, + (q31_t)0x82F0BDE8, (q31_t)0xE4B8CD10, (q31_t)0x8306510F, (q31_t)0xE4569CCB, + (q31_t)0x831C314E, (q31_t)0xE3F47D95, (q31_t)0x83325E97, (q31_t)0xE3926FAC, + (q31_t)0x8348D8DB, (q31_t)0xE330734C, (q31_t)0x835FA00E, (q31_t)0xE2CE88B2, + (q31_t)0x8376B422, (q31_t)0xE26CB01A, (q31_t)0x838E1507, (q31_t)0xE20AE9C1, + (q31_t)0x83A5C2B0, (q31_t)0xE1A935E1, (q31_t)0x83BDBD0D, (q31_t)0xE14794B9, + (q31_t)0x83D60411, (q31_t)0xE0E60684, (q31_t)0x83EE97AC, (q31_t)0xE0848B7F, + (q31_t)0x840777CF, (q31_t)0xE02323E5, (q31_t)0x8420A46B, (q31_t)0xDFC1CFF2, + (q31_t)0x843A1D70, (q31_t)0xDF608FE3, (q31_t)0x8453E2CE, (q31_t)0xDEFF63F4, + (q31_t)0x846DF476, (q31_t)0xDE9E4C60, (q31_t)0x84885257, (q31_t)0xDE3D4963, + (q31_t)0x84A2FC62, (q31_t)0xDDDC5B3A, (q31_t)0x84BDF285, (q31_t)0xDD7B8220, + (q31_t)0x84D934B0, (q31_t)0xDD1ABE51, (q31_t)0x84F4C2D3, (q31_t)0xDCBA1008, + (q31_t)0x85109CDC, (q31_t)0xDC597781, (q31_t)0x852CC2BA, (q31_t)0xDBF8F4F8, + (q31_t)0x8549345C, (q31_t)0xDB9888A8, (q31_t)0x8565F1B0, (q31_t)0xDB3832CD, + (q31_t)0x8582FAA4, (q31_t)0xDAD7F3A2, (q31_t)0x85A04F28, (q31_t)0xDA77CB62, + (q31_t)0x85BDEF27, (q31_t)0xDA17BA4A, (q31_t)0x85DBDA91, (q31_t)0xD9B7C093, + (q31_t)0x85FA1152, (q31_t)0xD957DE7A, (q31_t)0x86189359, (q31_t)0xD8F81439, + (q31_t)0x86376092, (q31_t)0xD898620C, (q31_t)0x865678EA, (q31_t)0xD838C82D, + (q31_t)0x8675DC4E, (q31_t)0xD7D946D7, (q31_t)0x86958AAB, (q31_t)0xD779DE46, + (q31_t)0x86B583EE, (q31_t)0xD71A8EB5, (q31_t)0x86D5C802, (q31_t)0xD6BB585D, + (q31_t)0x86F656D3, (q31_t)0xD65C3B7B, (q31_t)0x8717304E, (q31_t)0xD5FD3847, + (q31_t)0x8738545E, (q31_t)0xD59E4EFE, (q31_t)0x8759C2EF, (q31_t)0xD53F7FDA, + (q31_t)0x877B7BEC, (q31_t)0xD4E0CB14, (q31_t)0x879D7F40, (q31_t)0xD48230E8, + (q31_t)0x87BFCCD7, (q31_t)0xD423B190, (q31_t)0x87E2649B, (q31_t)0xD3C54D46, + (q31_t)0x88054677, (q31_t)0xD3670445, (q31_t)0x88287255, (q31_t)0xD308D6C6, + (q31_t)0x884BE820, (q31_t)0xD2AAC504, (q31_t)0x886FA7C2, (q31_t)0xD24CCF38, + (q31_t)0x8893B124, (q31_t)0xD1EEF59E, (q31_t)0x88B80431, (q31_t)0xD191386D, + (q31_t)0x88DCA0D3, (q31_t)0xD13397E1, (q31_t)0x890186F1, (q31_t)0xD0D61433, + (q31_t)0x8926B677, (q31_t)0xD078AD9D, (q31_t)0x894C2F4C, (q31_t)0xD01B6459, + (q31_t)0x8971F15A, (q31_t)0xCFBE389F, (q31_t)0x8997FC89, (q31_t)0xCF612AAA, + (q31_t)0x89BE50C3, (q31_t)0xCF043AB2, (q31_t)0x89E4EDEE, (q31_t)0xCEA768F2, + (q31_t)0x8A0BD3F5, (q31_t)0xCE4AB5A2, (q31_t)0x8A3302BD, (q31_t)0xCDEE20FC, + (q31_t)0x8A5A7A30, (q31_t)0xCD91AB38, (q31_t)0x8A823A35, (q31_t)0xCD355490, + (q31_t)0x8AAA42B4, (q31_t)0xCCD91D3D, (q31_t)0x8AD29393, (q31_t)0xCC7D0577, + (q31_t)0x8AFB2CBA, (q31_t)0xCC210D78, (q31_t)0x8B240E10, (q31_t)0xCBC53578, + (q31_t)0x8B4D377C, (q31_t)0xCB697DB0, (q31_t)0x8B76A8E4, (q31_t)0xCB0DE658, + (q31_t)0x8BA0622F, (q31_t)0xCAB26FA9, (q31_t)0x8BCA6342, (q31_t)0xCA5719DB, + (q31_t)0x8BF4AC05, (q31_t)0xC9FBE527, (q31_t)0x8C1F3C5C, (q31_t)0xC9A0D1C4, + (q31_t)0x8C4A142F, (q31_t)0xC945DFEC, (q31_t)0x8C753361, (q31_t)0xC8EB0FD6, + (q31_t)0x8CA099D9, (q31_t)0xC89061BA, (q31_t)0x8CCC477D, (q31_t)0xC835D5D0, + (q31_t)0x8CF83C30, (q31_t)0xC7DB6C50, (q31_t)0x8D2477D8, (q31_t)0xC7812571, + (q31_t)0x8D50FA59, (q31_t)0xC727016C, (q31_t)0x8D7DC399, (q31_t)0xC6CD0079, + (q31_t)0x8DAAD37B, (q31_t)0xC67322CD, (q31_t)0x8DD829E4, (q31_t)0xC61968A2, + (q31_t)0x8E05C6B7, (q31_t)0xC5BFD22E, (q31_t)0x8E33A9D9, (q31_t)0xC5665FA8, + (q31_t)0x8E61D32D, (q31_t)0xC50D1148, (q31_t)0x8E904298, (q31_t)0xC4B3E746, + (q31_t)0x8EBEF7FB, (q31_t)0xC45AE1D7, (q31_t)0x8EEDF33B, (q31_t)0xC4020132, + (q31_t)0x8F1D343A, (q31_t)0xC3A9458F, (q31_t)0x8F4CBADB, (q31_t)0xC350AF25, + (q31_t)0x8F7C8701, (q31_t)0xC2F83E2A, (q31_t)0x8FAC988E, (q31_t)0xC29FF2D4, + (q31_t)0x8FDCEF66, (q31_t)0xC247CD5A, (q31_t)0x900D8B69, (q31_t)0xC1EFCDF2, + (q31_t)0x903E6C7A, (q31_t)0xC197F4D3, (q31_t)0x906F927B, (q31_t)0xC1404233, + (q31_t)0x90A0FD4E, (q31_t)0xC0E8B648, (q31_t)0x90D2ACD3, (q31_t)0xC0915147, + (q31_t)0x9104A0ED, (q31_t)0xC03A1368, (q31_t)0x9136D97D, (q31_t)0xBFE2FCDF, + (q31_t)0x91695663, (q31_t)0xBF8C0DE2, (q31_t)0x919C1780, (q31_t)0xBF3546A8, + (q31_t)0x91CF1CB6, (q31_t)0xBEDEA765, (q31_t)0x920265E4, (q31_t)0xBE88304F, + (q31_t)0x9235F2EB, (q31_t)0xBE31E19B, (q31_t)0x9269C3AC, (q31_t)0xBDDBBB7F, + (q31_t)0x929DD805, (q31_t)0xBD85BE2F, (q31_t)0x92D22FD8, (q31_t)0xBD2FE9E1, + (q31_t)0x9306CB04, (q31_t)0xBCDA3ECA, (q31_t)0x933BA968, (q31_t)0xBC84BD1E, + (q31_t)0x9370CAE4, (q31_t)0xBC2F6513, (q31_t)0x93A62F56, (q31_t)0xBBDA36DC, + (q31_t)0x93DBD69F, (q31_t)0xBB8532AF, (q31_t)0x9411C09D, (q31_t)0xBB3058C0, + (q31_t)0x9447ED2F, (q31_t)0xBADBA943, (q31_t)0x947E5C32, (q31_t)0xBA87246C, + (q31_t)0x94B50D87, (q31_t)0xBA32CA70, (q31_t)0x94EC010B, (q31_t)0xB9DE9B83, + (q31_t)0x9523369B, (q31_t)0xB98A97D8, (q31_t)0x955AAE17, (q31_t)0xB936BFA3, + (q31_t)0x9592675B, (q31_t)0xB8E31319, (q31_t)0x95CA6246, (q31_t)0xB88F926C, + (q31_t)0x96029EB5, (q31_t)0xB83C3DD1, (q31_t)0x963B1C85, (q31_t)0xB7E9157A, + (q31_t)0x9673DB94, (q31_t)0xB796199B, (q31_t)0x96ACDBBD, (q31_t)0xB7434A67, + (q31_t)0x96E61CDF, (q31_t)0xB6F0A811, (q31_t)0x971F9ED6, (q31_t)0xB69E32CD, + (q31_t)0x9759617E, (q31_t)0xB64BEACC, (q31_t)0x979364B5, (q31_t)0xB5F9D042, + (q31_t)0x97CDA855, (q31_t)0xB5A7E362, (q31_t)0x98082C3B, (q31_t)0xB556245E, + (q31_t)0x9842F043, (q31_t)0xB5049368, (q31_t)0x987DF449, (q31_t)0xB4B330B2, + (q31_t)0x98B93828, (q31_t)0xB461FC70, (q31_t)0x98F4BBBC, (q31_t)0xB410F6D2, + (q31_t)0x99307EE0, (q31_t)0xB3C0200C, (q31_t)0x996C816F, (q31_t)0xB36F784E, + (q31_t)0x99A8C344, (q31_t)0xB31EFFCB, (q31_t)0x99E5443A, (q31_t)0xB2CEB6B5, + (q31_t)0x9A22042C, (q31_t)0xB27E9D3B, (q31_t)0x9A5F02F5, (q31_t)0xB22EB392, + (q31_t)0x9A9C406D, (q31_t)0xB1DEF9E8, (q31_t)0x9AD9BC71, (q31_t)0xB18F7070, + (q31_t)0x9B1776D9, (q31_t)0xB140175B, (q31_t)0x9B556F80, (q31_t)0xB0F0EEDA, + (q31_t)0x9B93A640, (q31_t)0xB0A1F71C, (q31_t)0x9BD21AF2, (q31_t)0xB0533055, + (q31_t)0x9C10CD70, (q31_t)0xB0049AB2, (q31_t)0x9C4FBD92, (q31_t)0xAFB63667, + (q31_t)0x9C8EEB33, (q31_t)0xAF6803A1, (q31_t)0x9CCE562B, (q31_t)0xAF1A0293, + (q31_t)0x9D0DFE53, (q31_t)0xAECC336B, (q31_t)0x9D4DE384, (q31_t)0xAE7E965B, + (q31_t)0x9D8E0596, (q31_t)0xAE312B91, (q31_t)0x9DCE6462, (q31_t)0xADE3F33E, + (q31_t)0x9E0EFFC1, (q31_t)0xAD96ED91, (q31_t)0x9E4FD789, (q31_t)0xAD4A1ABA, + (q31_t)0x9E90EB94, (q31_t)0xACFD7AE8, (q31_t)0x9ED23BB9, (q31_t)0xACB10E4A, + (q31_t)0x9F13C7D0, (q31_t)0xAC64D510, (q31_t)0x9F558FB0, (q31_t)0xAC18CF68, + (q31_t)0x9F979331, (q31_t)0xABCCFD82, (q31_t)0x9FD9D22A, (q31_t)0xAB815F8C, + (q31_t)0xA01C4C72, (q31_t)0xAB35F5B5, (q31_t)0xA05F01E1, (q31_t)0xAAEAC02B, + (q31_t)0xA0A1F24C, (q31_t)0xAA9FBF1D, (q31_t)0xA0E51D8C, (q31_t)0xAA54F2B9, + (q31_t)0xA1288376, (q31_t)0xAA0A5B2D, (q31_t)0xA16C23E1, (q31_t)0xA9BFF8A8, + (q31_t)0xA1AFFEA2, (q31_t)0xA975CB56, (q31_t)0xA1F41391, (q31_t)0xA92BD366, + (q31_t)0xA2386283, (q31_t)0xA8E21106, (q31_t)0xA27CEB4F, (q31_t)0xA8988463, + (q31_t)0xA2C1ADC9, (q31_t)0xA84F2DA9, (q31_t)0xA306A9C7, (q31_t)0xA8060D08, + (q31_t)0xA34BDF20, (q31_t)0xA7BD22AB, (q31_t)0xA3914DA7, (q31_t)0xA7746EC0, + (q31_t)0xA3D6F533, (q31_t)0xA72BF173, (q31_t)0xA41CD598, (q31_t)0xA6E3AAF2, + (q31_t)0xA462EEAC, (q31_t)0xA69B9B68, (q31_t)0xA4A94042, (q31_t)0xA653C302, + (q31_t)0xA4EFCA31, (q31_t)0xA60C21ED, (q31_t)0xA5368C4B, (q31_t)0xA5C4B855, + (q31_t)0xA57D8666, (q31_t)0xA57D8666, (q31_t)0xA5C4B855, (q31_t)0xA5368C4B, + (q31_t)0xA60C21ED, (q31_t)0xA4EFCA31, (q31_t)0xA653C302, (q31_t)0xA4A94042, + (q31_t)0xA69B9B68, (q31_t)0xA462EEAC, (q31_t)0xA6E3AAF2, (q31_t)0xA41CD598, + (q31_t)0xA72BF173, (q31_t)0xA3D6F533, (q31_t)0xA7746EC0, (q31_t)0xA3914DA7, + (q31_t)0xA7BD22AB, (q31_t)0xA34BDF20, (q31_t)0xA8060D08, (q31_t)0xA306A9C7, + (q31_t)0xA84F2DA9, (q31_t)0xA2C1ADC9, (q31_t)0xA8988463, (q31_t)0xA27CEB4F, + (q31_t)0xA8E21106, (q31_t)0xA2386283, (q31_t)0xA92BD366, (q31_t)0xA1F41391, + (q31_t)0xA975CB56, (q31_t)0xA1AFFEA2, (q31_t)0xA9BFF8A8, (q31_t)0xA16C23E1, + (q31_t)0xAA0A5B2D, (q31_t)0xA1288376, (q31_t)0xAA54F2B9, (q31_t)0xA0E51D8C, + (q31_t)0xAA9FBF1D, (q31_t)0xA0A1F24C, (q31_t)0xAAEAC02B, (q31_t)0xA05F01E1, + (q31_t)0xAB35F5B5, (q31_t)0xA01C4C72, (q31_t)0xAB815F8C, (q31_t)0x9FD9D22A, + (q31_t)0xABCCFD82, (q31_t)0x9F979331, (q31_t)0xAC18CF68, (q31_t)0x9F558FB0, + (q31_t)0xAC64D510, (q31_t)0x9F13C7D0, (q31_t)0xACB10E4A, (q31_t)0x9ED23BB9, + (q31_t)0xACFD7AE8, (q31_t)0x9E90EB94, (q31_t)0xAD4A1ABA, (q31_t)0x9E4FD789, + (q31_t)0xAD96ED91, (q31_t)0x9E0EFFC1, (q31_t)0xADE3F33E, (q31_t)0x9DCE6462, + (q31_t)0xAE312B91, (q31_t)0x9D8E0596, (q31_t)0xAE7E965B, (q31_t)0x9D4DE384, + (q31_t)0xAECC336B, (q31_t)0x9D0DFE53, (q31_t)0xAF1A0293, (q31_t)0x9CCE562B, + (q31_t)0xAF6803A1, (q31_t)0x9C8EEB33, (q31_t)0xAFB63667, (q31_t)0x9C4FBD92, + (q31_t)0xB0049AB2, (q31_t)0x9C10CD70, (q31_t)0xB0533055, (q31_t)0x9BD21AF2, + (q31_t)0xB0A1F71C, (q31_t)0x9B93A640, (q31_t)0xB0F0EEDA, (q31_t)0x9B556F80, + (q31_t)0xB140175B, (q31_t)0x9B1776D9, (q31_t)0xB18F7070, (q31_t)0x9AD9BC71, + (q31_t)0xB1DEF9E8, (q31_t)0x9A9C406D, (q31_t)0xB22EB392, (q31_t)0x9A5F02F5, + (q31_t)0xB27E9D3B, (q31_t)0x9A22042C, (q31_t)0xB2CEB6B5, (q31_t)0x99E5443A, + (q31_t)0xB31EFFCB, (q31_t)0x99A8C344, (q31_t)0xB36F784E, (q31_t)0x996C816F, + (q31_t)0xB3C0200C, (q31_t)0x99307EE0, (q31_t)0xB410F6D2, (q31_t)0x98F4BBBC, + (q31_t)0xB461FC70, (q31_t)0x98B93828, (q31_t)0xB4B330B2, (q31_t)0x987DF449, + (q31_t)0xB5049368, (q31_t)0x9842F043, (q31_t)0xB556245E, (q31_t)0x98082C3B, + (q31_t)0xB5A7E362, (q31_t)0x97CDA855, (q31_t)0xB5F9D042, (q31_t)0x979364B5, + (q31_t)0xB64BEACC, (q31_t)0x9759617E, (q31_t)0xB69E32CD, (q31_t)0x971F9ED6, + (q31_t)0xB6F0A811, (q31_t)0x96E61CDF, (q31_t)0xB7434A67, (q31_t)0x96ACDBBD, + (q31_t)0xB796199B, (q31_t)0x9673DB94, (q31_t)0xB7E9157A, (q31_t)0x963B1C85, + (q31_t)0xB83C3DD1, (q31_t)0x96029EB5, (q31_t)0xB88F926C, (q31_t)0x95CA6246, + (q31_t)0xB8E31319, (q31_t)0x9592675B, (q31_t)0xB936BFA3, (q31_t)0x955AAE17, + (q31_t)0xB98A97D8, (q31_t)0x9523369B, (q31_t)0xB9DE9B83, (q31_t)0x94EC010B, + (q31_t)0xBA32CA70, (q31_t)0x94B50D87, (q31_t)0xBA87246C, (q31_t)0x947E5C32, + (q31_t)0xBADBA943, (q31_t)0x9447ED2F, (q31_t)0xBB3058C0, (q31_t)0x9411C09D, + (q31_t)0xBB8532AF, (q31_t)0x93DBD69F, (q31_t)0xBBDA36DC, (q31_t)0x93A62F56, + (q31_t)0xBC2F6513, (q31_t)0x9370CAE4, (q31_t)0xBC84BD1E, (q31_t)0x933BA968, + (q31_t)0xBCDA3ECA, (q31_t)0x9306CB04, (q31_t)0xBD2FE9E1, (q31_t)0x92D22FD8, + (q31_t)0xBD85BE2F, (q31_t)0x929DD805, (q31_t)0xBDDBBB7F, (q31_t)0x9269C3AC, + (q31_t)0xBE31E19B, (q31_t)0x9235F2EB, (q31_t)0xBE88304F, (q31_t)0x920265E4, + (q31_t)0xBEDEA765, (q31_t)0x91CF1CB6, (q31_t)0xBF3546A8, (q31_t)0x919C1780, + (q31_t)0xBF8C0DE2, (q31_t)0x91695663, (q31_t)0xBFE2FCDF, (q31_t)0x9136D97D, + (q31_t)0xC03A1368, (q31_t)0x9104A0ED, (q31_t)0xC0915147, (q31_t)0x90D2ACD3, + (q31_t)0xC0E8B648, (q31_t)0x90A0FD4E, (q31_t)0xC1404233, (q31_t)0x906F927B, + (q31_t)0xC197F4D3, (q31_t)0x903E6C7A, (q31_t)0xC1EFCDF2, (q31_t)0x900D8B69, + (q31_t)0xC247CD5A, (q31_t)0x8FDCEF66, (q31_t)0xC29FF2D4, (q31_t)0x8FAC988E, + (q31_t)0xC2F83E2A, (q31_t)0x8F7C8701, (q31_t)0xC350AF25, (q31_t)0x8F4CBADB, + (q31_t)0xC3A9458F, (q31_t)0x8F1D343A, (q31_t)0xC4020132, (q31_t)0x8EEDF33B, + (q31_t)0xC45AE1D7, (q31_t)0x8EBEF7FB, (q31_t)0xC4B3E746, (q31_t)0x8E904298, + (q31_t)0xC50D1148, (q31_t)0x8E61D32D, (q31_t)0xC5665FA8, (q31_t)0x8E33A9D9, + (q31_t)0xC5BFD22E, (q31_t)0x8E05C6B7, (q31_t)0xC61968A2, (q31_t)0x8DD829E4, + (q31_t)0xC67322CD, (q31_t)0x8DAAD37B, (q31_t)0xC6CD0079, (q31_t)0x8D7DC399, + (q31_t)0xC727016C, (q31_t)0x8D50FA59, (q31_t)0xC7812571, (q31_t)0x8D2477D8, + (q31_t)0xC7DB6C50, (q31_t)0x8CF83C30, (q31_t)0xC835D5D0, (q31_t)0x8CCC477D, + (q31_t)0xC89061BA, (q31_t)0x8CA099D9, (q31_t)0xC8EB0FD6, (q31_t)0x8C753361, + (q31_t)0xC945DFEC, (q31_t)0x8C4A142F, (q31_t)0xC9A0D1C4, (q31_t)0x8C1F3C5C, + (q31_t)0xC9FBE527, (q31_t)0x8BF4AC05, (q31_t)0xCA5719DB, (q31_t)0x8BCA6342, + (q31_t)0xCAB26FA9, (q31_t)0x8BA0622F, (q31_t)0xCB0DE658, (q31_t)0x8B76A8E4, + (q31_t)0xCB697DB0, (q31_t)0x8B4D377C, (q31_t)0xCBC53578, (q31_t)0x8B240E10, + (q31_t)0xCC210D78, (q31_t)0x8AFB2CBA, (q31_t)0xCC7D0577, (q31_t)0x8AD29393, + (q31_t)0xCCD91D3D, (q31_t)0x8AAA42B4, (q31_t)0xCD355490, (q31_t)0x8A823A35, + (q31_t)0xCD91AB38, (q31_t)0x8A5A7A30, (q31_t)0xCDEE20FC, (q31_t)0x8A3302BD, + (q31_t)0xCE4AB5A2, (q31_t)0x8A0BD3F5, (q31_t)0xCEA768F2, (q31_t)0x89E4EDEE, + (q31_t)0xCF043AB2, (q31_t)0x89BE50C3, (q31_t)0xCF612AAA, (q31_t)0x8997FC89, + (q31_t)0xCFBE389F, (q31_t)0x8971F15A, (q31_t)0xD01B6459, (q31_t)0x894C2F4C, + (q31_t)0xD078AD9D, (q31_t)0x8926B677, (q31_t)0xD0D61433, (q31_t)0x890186F1, + (q31_t)0xD13397E1, (q31_t)0x88DCA0D3, (q31_t)0xD191386D, (q31_t)0x88B80431, + (q31_t)0xD1EEF59E, (q31_t)0x8893B124, (q31_t)0xD24CCF38, (q31_t)0x886FA7C2, + (q31_t)0xD2AAC504, (q31_t)0x884BE820, (q31_t)0xD308D6C6, (q31_t)0x88287255, + (q31_t)0xD3670445, (q31_t)0x88054677, (q31_t)0xD3C54D46, (q31_t)0x87E2649B, + (q31_t)0xD423B190, (q31_t)0x87BFCCD7, (q31_t)0xD48230E8, (q31_t)0x879D7F40, + (q31_t)0xD4E0CB14, (q31_t)0x877B7BEC, (q31_t)0xD53F7FDA, (q31_t)0x8759C2EF, + (q31_t)0xD59E4EFE, (q31_t)0x8738545E, (q31_t)0xD5FD3847, (q31_t)0x8717304E, + (q31_t)0xD65C3B7B, (q31_t)0x86F656D3, (q31_t)0xD6BB585D, (q31_t)0x86D5C802, + (q31_t)0xD71A8EB5, (q31_t)0x86B583EE, (q31_t)0xD779DE46, (q31_t)0x86958AAB, + (q31_t)0xD7D946D7, (q31_t)0x8675DC4E, (q31_t)0xD838C82D, (q31_t)0x865678EA, + (q31_t)0xD898620C, (q31_t)0x86376092, (q31_t)0xD8F81439, (q31_t)0x86189359, + (q31_t)0xD957DE7A, (q31_t)0x85FA1152, (q31_t)0xD9B7C093, (q31_t)0x85DBDA91, + (q31_t)0xDA17BA4A, (q31_t)0x85BDEF27, (q31_t)0xDA77CB62, (q31_t)0x85A04F28, + (q31_t)0xDAD7F3A2, (q31_t)0x8582FAA4, (q31_t)0xDB3832CD, (q31_t)0x8565F1B0, + (q31_t)0xDB9888A8, (q31_t)0x8549345C, (q31_t)0xDBF8F4F8, (q31_t)0x852CC2BA, + (q31_t)0xDC597781, (q31_t)0x85109CDC, (q31_t)0xDCBA1008, (q31_t)0x84F4C2D3, + (q31_t)0xDD1ABE51, (q31_t)0x84D934B0, (q31_t)0xDD7B8220, (q31_t)0x84BDF285, + (q31_t)0xDDDC5B3A, (q31_t)0x84A2FC62, (q31_t)0xDE3D4963, (q31_t)0x84885257, + (q31_t)0xDE9E4C60, (q31_t)0x846DF476, (q31_t)0xDEFF63F4, (q31_t)0x8453E2CE, + (q31_t)0xDF608FE3, (q31_t)0x843A1D70, (q31_t)0xDFC1CFF2, (q31_t)0x8420A46B, + (q31_t)0xE02323E5, (q31_t)0x840777CF, (q31_t)0xE0848B7F, (q31_t)0x83EE97AC, + (q31_t)0xE0E60684, (q31_t)0x83D60411, (q31_t)0xE14794B9, (q31_t)0x83BDBD0D, + (q31_t)0xE1A935E1, (q31_t)0x83A5C2B0, (q31_t)0xE20AE9C1, (q31_t)0x838E1507, + (q31_t)0xE26CB01A, (q31_t)0x8376B422, (q31_t)0xE2CE88B2, (q31_t)0x835FA00E, + (q31_t)0xE330734C, (q31_t)0x8348D8DB, (q31_t)0xE3926FAC, (q31_t)0x83325E97, + (q31_t)0xE3F47D95, (q31_t)0x831C314E, (q31_t)0xE4569CCB, (q31_t)0x8306510F, + (q31_t)0xE4B8CD10, (q31_t)0x82F0BDE8, (q31_t)0xE51B0E2A, (q31_t)0x82DB77E5, + (q31_t)0xE57D5FDA, (q31_t)0x82C67F13, (q31_t)0xE5DFC1E4, (q31_t)0x82B1D381, + (q31_t)0xE642340D, (q31_t)0x829D753A, (q31_t)0xE6A4B616, (q31_t)0x8289644A, + (q31_t)0xE70747C3, (q31_t)0x8275A0C0, (q31_t)0xE769E8D8, (q31_t)0x82622AA5, + (q31_t)0xE7CC9917, (q31_t)0x824F0208, (q31_t)0xE82F5844, (q31_t)0x823C26F2, + (q31_t)0xE8922621, (q31_t)0x82299971, (q31_t)0xE8F50273, (q31_t)0x8217598F, + (q31_t)0xE957ECFB, (q31_t)0x82056758, (q31_t)0xE9BAE57C, (q31_t)0x81F3C2D7, + (q31_t)0xEA1DEBBB, (q31_t)0x81E26C16, (q31_t)0xEA80FF79, (q31_t)0x81D16320, + (q31_t)0xEAE4207A, (q31_t)0x81C0A801, (q31_t)0xEB474E80, (q31_t)0x81B03AC1, + (q31_t)0xEBAA894E, (q31_t)0x81A01B6C, (q31_t)0xEC0DD0A8, (q31_t)0x81904A0C, + (q31_t)0xEC71244F, (q31_t)0x8180C6A9, (q31_t)0xECD48406, (q31_t)0x8171914E, + (q31_t)0xED37EF91, (q31_t)0x8162AA03, (q31_t)0xED9B66B2, (q31_t)0x815410D3, + (q31_t)0xEDFEE92B, (q31_t)0x8145C5C6, (q31_t)0xEE6276BF, (q31_t)0x8137C8E6, + (q31_t)0xEEC60F31, (q31_t)0x812A1A39, (q31_t)0xEF29B243, (q31_t)0x811CB9CA, + (q31_t)0xEF8D5FB8, (q31_t)0x810FA7A0, (q31_t)0xEFF11752, (q31_t)0x8102E3C3, + (q31_t)0xF054D8D4, (q31_t)0x80F66E3C, (q31_t)0xF0B8A401, (q31_t)0x80EA4712, + (q31_t)0xF11C789A, (q31_t)0x80DE6E4C, (q31_t)0xF1805662, (q31_t)0x80D2E3F1, + (q31_t)0xF1E43D1C, (q31_t)0x80C7A80A, (q31_t)0xF2482C89, (q31_t)0x80BCBA9C, + (q31_t)0xF2AC246D, (q31_t)0x80B21BAF, (q31_t)0xF310248A, (q31_t)0x80A7CB49, + (q31_t)0xF3742CA1, (q31_t)0x809DC970, (q31_t)0xF3D83C76, (q31_t)0x8094162B, + (q31_t)0xF43C53CA, (q31_t)0x808AB180, (q31_t)0xF4A07260, (q31_t)0x80819B74, + (q31_t)0xF50497FA, (q31_t)0x8078D40D, (q31_t)0xF568C45A, (q31_t)0x80705B50, + (q31_t)0xF5CCF743, (q31_t)0x80683143, (q31_t)0xF6313076, (q31_t)0x806055EA, + (q31_t)0xF6956FB6, (q31_t)0x8058C94C, (q31_t)0xF6F9B4C5, (q31_t)0x80518B6B, + (q31_t)0xF75DFF65, (q31_t)0x804A9C4D, (q31_t)0xF7C24F58, (q31_t)0x8043FBF6, + (q31_t)0xF826A461, (q31_t)0x803DAA69, (q31_t)0xF88AFE41, (q31_t)0x8037A7AC, + (q31_t)0xF8EF5CBB, (q31_t)0x8031F3C1, (q31_t)0xF953BF90, (q31_t)0x802C8EAD, + (q31_t)0xF9B82683, (q31_t)0x80277872, (q31_t)0xFA1C9156, (q31_t)0x8022B113, + (q31_t)0xFA80FFCB, (q31_t)0x801E3894, (q31_t)0xFAE571A4, (q31_t)0x801A0EF7, + (q31_t)0xFB49E6A2, (q31_t)0x80163440, (q31_t)0xFBAE5E89, (q31_t)0x8012A86F, + (q31_t)0xFC12D919, (q31_t)0x800F6B88, (q31_t)0xFC775616, (q31_t)0x800C7D8C, + (q31_t)0xFCDBD541, (q31_t)0x8009DE7D, (q31_t)0xFD40565B, (q31_t)0x80078E5E, + (q31_t)0xFDA4D928, (q31_t)0x80058D2E, (q31_t)0xFE095D69, (q31_t)0x8003DAF0, + (q31_t)0xFE6DE2E0, (q31_t)0x800277A5, (q31_t)0xFED2694F, (q31_t)0x8001634D, + (q31_t)0xFF36F078, (q31_t)0x80009DE9, (q31_t)0xFF9B781D, (q31_t)0x8000277A}; /** @par @@ -10738,2067 +5287,1550 @@ const q31_t twiddleCoef_2048_q31[3072] = { Cos and Sin values are interleaved fashion @par Convert Floating point to Q31(Fixed point 1.31): - round(twiddleCoefQ31(i) * pow(2, 31)) + round(twiddleCoefQ31(i) * pow(2, 31)) */ -const q31_t twiddleCoef_4096_q31[6144] = -{ - (q31_t)0x7FFFFFFF, (q31_t)0x00000000, (q31_t)0x7FFFF621, - (q31_t)0x003243F5, (q31_t)0x7FFFD885, (q31_t)0x006487E3, - (q31_t)0x7FFFA72C, (q31_t)0x0096CBC1, (q31_t)0x7FFF6216, - (q31_t)0x00C90F88, (q31_t)0x7FFF0942, (q31_t)0x00FB532F, - (q31_t)0x7FFE9CB2, (q31_t)0x012D96B0, (q31_t)0x7FFE1C64, - (q31_t)0x015FDA03, (q31_t)0x7FFD885A, (q31_t)0x01921D1F, - (q31_t)0x7FFCE093, (q31_t)0x01C45FFE, (q31_t)0x7FFC250F, - (q31_t)0x01F6A296, (q31_t)0x7FFB55CE, (q31_t)0x0228E4E1, - (q31_t)0x7FFA72D1, (q31_t)0x025B26D7, (q31_t)0x7FF97C17, - (q31_t)0x028D6870, (q31_t)0x7FF871A1, (q31_t)0x02BFA9A4, - (q31_t)0x7FF7536F, (q31_t)0x02F1EA6B, (q31_t)0x7FF62182, - (q31_t)0x03242ABF, (q31_t)0x7FF4DBD8, (q31_t)0x03566A96, - (q31_t)0x7FF38273, (q31_t)0x0388A9E9, (q31_t)0x7FF21553, - (q31_t)0x03BAE8B1, (q31_t)0x7FF09477, (q31_t)0x03ED26E6, - (q31_t)0x7FEEFFE1, (q31_t)0x041F647F, (q31_t)0x7FED5790, - (q31_t)0x0451A176, (q31_t)0x7FEB9B85, (q31_t)0x0483DDC3, - (q31_t)0x7FE9CBC0, (q31_t)0x04B6195D, (q31_t)0x7FE7E840, - (q31_t)0x04E8543D, (q31_t)0x7FE5F108, (q31_t)0x051A8E5C, - (q31_t)0x7FE3E616, (q31_t)0x054CC7B0, (q31_t)0x7FE1C76B, - (q31_t)0x057F0034, (q31_t)0x7FDF9508, (q31_t)0x05B137DF, - (q31_t)0x7FDD4EEC, (q31_t)0x05E36EA9, (q31_t)0x7FDAF518, - (q31_t)0x0615A48A, (q31_t)0x7FD8878D, (q31_t)0x0647D97C, - (q31_t)0x7FD6064B, (q31_t)0x067A0D75, (q31_t)0x7FD37152, - (q31_t)0x06AC406F, (q31_t)0x7FD0C8A3, (q31_t)0x06DE7261, - (q31_t)0x7FCE0C3E, (q31_t)0x0710A344, (q31_t)0x7FCB3C23, - (q31_t)0x0742D310, (q31_t)0x7FC85853, (q31_t)0x077501BE, - (q31_t)0x7FC560CF, (q31_t)0x07A72F45, (q31_t)0x7FC25596, - (q31_t)0x07D95B9E, (q31_t)0x7FBF36A9, (q31_t)0x080B86C1, - (q31_t)0x7FBC040A, (q31_t)0x083DB0A7, (q31_t)0x7FB8BDB7, - (q31_t)0x086FD947, (q31_t)0x7FB563B2, (q31_t)0x08A2009A, - (q31_t)0x7FB1F5FC, (q31_t)0x08D42698, (q31_t)0x7FAE7494, - (q31_t)0x09064B3A, (q31_t)0x7FAADF7C, (q31_t)0x09386E77, - (q31_t)0x7FA736B4, (q31_t)0x096A9049, (q31_t)0x7FA37A3C, - (q31_t)0x099CB0A7, (q31_t)0x7F9FAA15, (q31_t)0x09CECF89, - (q31_t)0x7F9BC63F, (q31_t)0x0A00ECE8, (q31_t)0x7F97CEBC, - (q31_t)0x0A3308BC, (q31_t)0x7F93C38C, (q31_t)0x0A6522FE, - (q31_t)0x7F8FA4AF, (q31_t)0x0A973BA5, (q31_t)0x7F8B7226, - (q31_t)0x0AC952AA, (q31_t)0x7F872BF3, (q31_t)0x0AFB6805, - (q31_t)0x7F82D214, (q31_t)0x0B2D7BAE, (q31_t)0x7F7E648B, - (q31_t)0x0B5F8D9F, (q31_t)0x7F79E35A, (q31_t)0x0B919DCE, - (q31_t)0x7F754E7F, (q31_t)0x0BC3AC35, (q31_t)0x7F70A5FD, - (q31_t)0x0BF5B8CB, (q31_t)0x7F6BE9D4, (q31_t)0x0C27C389, - (q31_t)0x7F671A04, (q31_t)0x0C59CC67, (q31_t)0x7F62368F, - (q31_t)0x0C8BD35E, (q31_t)0x7F5D3F75, (q31_t)0x0CBDD865, - (q31_t)0x7F5834B6, (q31_t)0x0CEFDB75, (q31_t)0x7F531654, - (q31_t)0x0D21DC87, (q31_t)0x7F4DE450, (q31_t)0x0D53DB92, - (q31_t)0x7F489EAA, (q31_t)0x0D85D88F, (q31_t)0x7F434563, - (q31_t)0x0DB7D376, (q31_t)0x7F3DD87C, (q31_t)0x0DE9CC3F, - (q31_t)0x7F3857F5, (q31_t)0x0E1BC2E3, (q31_t)0x7F32C3D0, - (q31_t)0x0E4DB75B, (q31_t)0x7F2D1C0E, (q31_t)0x0E7FA99D, - (q31_t)0x7F2760AF, (q31_t)0x0EB199A3, (q31_t)0x7F2191B4, - (q31_t)0x0EE38765, (q31_t)0x7F1BAF1E, (q31_t)0x0F1572DC, - (q31_t)0x7F15B8EE, (q31_t)0x0F475BFE, (q31_t)0x7F0FAF24, - (q31_t)0x0F7942C6, (q31_t)0x7F0991C3, (q31_t)0x0FAB272B, - (q31_t)0x7F0360CB, (q31_t)0x0FDD0925, (q31_t)0x7EFD1C3C, - (q31_t)0x100EE8AD, (q31_t)0x7EF6C418, (q31_t)0x1040C5BB, - (q31_t)0x7EF0585F, (q31_t)0x1072A047, (q31_t)0x7EE9D913, - (q31_t)0x10A4784A, (q31_t)0x7EE34635, (q31_t)0x10D64DBC, - (q31_t)0x7EDC9FC6, (q31_t)0x11082096, (q31_t)0x7ED5E5C6, - (q31_t)0x1139F0CE, (q31_t)0x7ECF1837, (q31_t)0x116BBE5F, - (q31_t)0x7EC8371A, (q31_t)0x119D8940, (q31_t)0x7EC1426F, - (q31_t)0x11CF516A, (q31_t)0x7EBA3A39, (q31_t)0x120116D4, - (q31_t)0x7EB31E77, (q31_t)0x1232D978, (q31_t)0x7EABEF2C, - (q31_t)0x1264994E, (q31_t)0x7EA4AC58, (q31_t)0x1296564D, - (q31_t)0x7E9D55FC, (q31_t)0x12C8106E, (q31_t)0x7E95EC19, - (q31_t)0x12F9C7AA, (q31_t)0x7E8E6EB1, (q31_t)0x132B7BF9, - (q31_t)0x7E86DDC5, (q31_t)0x135D2D53, (q31_t)0x7E7F3956, - (q31_t)0x138EDBB0, (q31_t)0x7E778165, (q31_t)0x13C0870A, - (q31_t)0x7E6FB5F3, (q31_t)0x13F22F57, (q31_t)0x7E67D702, - (q31_t)0x1423D492, (q31_t)0x7E5FE493, (q31_t)0x145576B1, - (q31_t)0x7E57DEA6, (q31_t)0x148715AD, (q31_t)0x7E4FC53E, - (q31_t)0x14B8B17F, (q31_t)0x7E47985B, (q31_t)0x14EA4A1F, - (q31_t)0x7E3F57FE, (q31_t)0x151BDF85, (q31_t)0x7E37042A, - (q31_t)0x154D71AA, (q31_t)0x7E2E9CDF, (q31_t)0x157F0086, - (q31_t)0x7E26221E, (q31_t)0x15B08C11, (q31_t)0x7E1D93E9, - (q31_t)0x15E21444, (q31_t)0x7E14F242, (q31_t)0x16139917, - (q31_t)0x7E0C3D29, (q31_t)0x16451A83, (q31_t)0x7E03749F, - (q31_t)0x1676987F, (q31_t)0x7DFA98A7, (q31_t)0x16A81305, - (q31_t)0x7DF1A942, (q31_t)0x16D98A0C, (q31_t)0x7DE8A670, - (q31_t)0x170AFD8D, (q31_t)0x7DDF9034, (q31_t)0x173C6D80, - (q31_t)0x7DD6668E, (q31_t)0x176DD9DE, (q31_t)0x7DCD2981, - (q31_t)0x179F429F, (q31_t)0x7DC3D90D, (q31_t)0x17D0A7BB, - (q31_t)0x7DBA7534, (q31_t)0x1802092C, (q31_t)0x7DB0FDF7, - (q31_t)0x183366E8, (q31_t)0x7DA77359, (q31_t)0x1864C0E9, - (q31_t)0x7D9DD55A, (q31_t)0x18961727, (q31_t)0x7D9423FB, - (q31_t)0x18C7699B, (q31_t)0x7D8A5F3F, (q31_t)0x18F8B83C, - (q31_t)0x7D808727, (q31_t)0x192A0303, (q31_t)0x7D769BB5, - (q31_t)0x195B49E9, (q31_t)0x7D6C9CE9, (q31_t)0x198C8CE6, - (q31_t)0x7D628AC5, (q31_t)0x19BDCBF2, (q31_t)0x7D58654C, - (q31_t)0x19EF0706, (q31_t)0x7D4E2C7E, (q31_t)0x1A203E1B, - (q31_t)0x7D43E05E, (q31_t)0x1A517127, (q31_t)0x7D3980EC, - (q31_t)0x1A82A025, (q31_t)0x7D2F0E2A, (q31_t)0x1AB3CB0C, - (q31_t)0x7D24881A, (q31_t)0x1AE4F1D6, (q31_t)0x7D19EEBE, - (q31_t)0x1B161479, (q31_t)0x7D0F4218, (q31_t)0x1B4732EF, - (q31_t)0x7D048228, (q31_t)0x1B784D30, (q31_t)0x7CF9AEF0, - (q31_t)0x1BA96334, (q31_t)0x7CEEC873, (q31_t)0x1BDA74F5, - (q31_t)0x7CE3CEB1, (q31_t)0x1C0B826A, (q31_t)0x7CD8C1AD, - (q31_t)0x1C3C8B8C, (q31_t)0x7CCDA168, (q31_t)0x1C6D9053, - (q31_t)0x7CC26DE5, (q31_t)0x1C9E90B8, (q31_t)0x7CB72724, - (q31_t)0x1CCF8CB3, (q31_t)0x7CABCD27, (q31_t)0x1D00843C, - (q31_t)0x7CA05FF1, (q31_t)0x1D31774D, (q31_t)0x7C94DF82, - (q31_t)0x1D6265DD, (q31_t)0x7C894BDD, (q31_t)0x1D934FE5, - (q31_t)0x7C7DA504, (q31_t)0x1DC4355D, (q31_t)0x7C71EAF8, - (q31_t)0x1DF5163F, (q31_t)0x7C661DBB, (q31_t)0x1E25F281, - (q31_t)0x7C5A3D4F, (q31_t)0x1E56CA1E, (q31_t)0x7C4E49B6, - (q31_t)0x1E879D0C, (q31_t)0x7C4242F2, (q31_t)0x1EB86B46, - (q31_t)0x7C362904, (q31_t)0x1EE934C2, (q31_t)0x7C29FBEE, - (q31_t)0x1F19F97B, (q31_t)0x7C1DBBB2, (q31_t)0x1F4AB967, - (q31_t)0x7C116853, (q31_t)0x1F7B7480, (q31_t)0x7C0501D1, - (q31_t)0x1FAC2ABF, (q31_t)0x7BF88830, (q31_t)0x1FDCDC1A, - (q31_t)0x7BEBFB70, (q31_t)0x200D888C, (q31_t)0x7BDF5B94, - (q31_t)0x203E300D, (q31_t)0x7BD2A89E, (q31_t)0x206ED295, - (q31_t)0x7BC5E28F, (q31_t)0x209F701C, (q31_t)0x7BB9096A, - (q31_t)0x20D0089B, (q31_t)0x7BAC1D31, (q31_t)0x21009C0B, - (q31_t)0x7B9F1DE5, (q31_t)0x21312A65, (q31_t)0x7B920B89, - (q31_t)0x2161B39F, (q31_t)0x7B84E61E, (q31_t)0x219237B4, - (q31_t)0x7B77ADA8, (q31_t)0x21C2B69C, (q31_t)0x7B6A6227, - (q31_t)0x21F3304E, (q31_t)0x7B5D039D, (q31_t)0x2223A4C5, - (q31_t)0x7B4F920E, (q31_t)0x225413F8, (q31_t)0x7B420D7A, - (q31_t)0x22847DDF, (q31_t)0x7B3475E4, (q31_t)0x22B4E274, - (q31_t)0x7B26CB4F, (q31_t)0x22E541AE, (q31_t)0x7B190DBB, - (q31_t)0x23159B87, (q31_t)0x7B0B3D2C, (q31_t)0x2345EFF7, - (q31_t)0x7AFD59A3, (q31_t)0x23763EF7, (q31_t)0x7AEF6323, - (q31_t)0x23A6887E, (q31_t)0x7AE159AE, (q31_t)0x23D6CC86, - (q31_t)0x7AD33D45, (q31_t)0x24070B07, (q31_t)0x7AC50DEB, - (q31_t)0x243743FA, (q31_t)0x7AB6CBA3, (q31_t)0x24677757, - (q31_t)0x7AA8766E, (q31_t)0x2497A517, (q31_t)0x7A9A0E4F, - (q31_t)0x24C7CD32, (q31_t)0x7A8B9348, (q31_t)0x24F7EFA1, - (q31_t)0x7A7D055B, (q31_t)0x25280C5D, (q31_t)0x7A6E648A, - (q31_t)0x2558235E, (q31_t)0x7A5FB0D8, (q31_t)0x2588349D, - (q31_t)0x7A50EA46, (q31_t)0x25B84012, (q31_t)0x7A4210D8, - (q31_t)0x25E845B5, (q31_t)0x7A33248F, (q31_t)0x26184581, - (q31_t)0x7A24256E, (q31_t)0x26483F6C, (q31_t)0x7A151377, - (q31_t)0x26783370, (q31_t)0x7A05EEAD, (q31_t)0x26A82185, - (q31_t)0x79F6B711, (q31_t)0x26D809A5, (q31_t)0x79E76CA6, - (q31_t)0x2707EBC6, (q31_t)0x79D80F6F, (q31_t)0x2737C7E3, - (q31_t)0x79C89F6D, (q31_t)0x27679DF4, (q31_t)0x79B91CA4, - (q31_t)0x27976DF1, (q31_t)0x79A98715, (q31_t)0x27C737D2, - (q31_t)0x7999DEC3, (q31_t)0x27F6FB92, (q31_t)0x798A23B1, - (q31_t)0x2826B928, (q31_t)0x797A55E0, (q31_t)0x2856708C, - (q31_t)0x796A7554, (q31_t)0x288621B9, (q31_t)0x795A820E, - (q31_t)0x28B5CCA5, (q31_t)0x794A7C11, (q31_t)0x28E5714A, - (q31_t)0x793A6360, (q31_t)0x29150FA1, (q31_t)0x792A37FE, - (q31_t)0x2944A7A2, (q31_t)0x7919F9EB, (q31_t)0x29743945, - (q31_t)0x7909A92C, (q31_t)0x29A3C484, (q31_t)0x78F945C3, - (q31_t)0x29D34958, (q31_t)0x78E8CFB1, (q31_t)0x2A02C7B8, - (q31_t)0x78D846FB, (q31_t)0x2A323F9D, (q31_t)0x78C7ABA1, - (q31_t)0x2A61B101, (q31_t)0x78B6FDA8, (q31_t)0x2A911BDB, - (q31_t)0x78A63D10, (q31_t)0x2AC08025, (q31_t)0x789569DE, - (q31_t)0x2AEFDDD8, (q31_t)0x78848413, (q31_t)0x2B1F34EB, - (q31_t)0x78738BB3, (q31_t)0x2B4E8558, (q31_t)0x786280BF, - (q31_t)0x2B7DCF17, (q31_t)0x7851633B, (q31_t)0x2BAD1221, - (q31_t)0x78403328, (q31_t)0x2BDC4E6F, (q31_t)0x782EF08B, - (q31_t)0x2C0B83F9, (q31_t)0x781D9B64, (q31_t)0x2C3AB2B9, - (q31_t)0x780C33B8, (q31_t)0x2C69DAA6, (q31_t)0x77FAB988, - (q31_t)0x2C98FBBA, (q31_t)0x77E92CD8, (q31_t)0x2CC815ED, - (q31_t)0x77D78DAA, (q31_t)0x2CF72939, (q31_t)0x77C5DC01, - (q31_t)0x2D263595, (q31_t)0x77B417DF, (q31_t)0x2D553AFB, - (q31_t)0x77A24148, (q31_t)0x2D843963, (q31_t)0x7790583D, - (q31_t)0x2DB330C7, (q31_t)0x777E5CC3, (q31_t)0x2DE2211E, - (q31_t)0x776C4EDB, (q31_t)0x2E110A62, (q31_t)0x775A2E88, - (q31_t)0x2E3FEC8B, (q31_t)0x7747FBCE, (q31_t)0x2E6EC792, - (q31_t)0x7735B6AE, (q31_t)0x2E9D9B70, (q31_t)0x77235F2D, - (q31_t)0x2ECC681E, (q31_t)0x7710F54B, (q31_t)0x2EFB2D94, - (q31_t)0x76FE790E, (q31_t)0x2F29EBCC, (q31_t)0x76EBEA77, - (q31_t)0x2F58A2BD, (q31_t)0x76D94988, (q31_t)0x2F875262, - (q31_t)0x76C69646, (q31_t)0x2FB5FAB2, (q31_t)0x76B3D0B3, - (q31_t)0x2FE49BA6, (q31_t)0x76A0F8D2, (q31_t)0x30133538, - (q31_t)0x768E0EA5, (q31_t)0x3041C760, (q31_t)0x767B1230, - (q31_t)0x30705217, (q31_t)0x76680376, (q31_t)0x309ED555, - (q31_t)0x7654E279, (q31_t)0x30CD5114, (q31_t)0x7641AF3C, - (q31_t)0x30FBC54D, (q31_t)0x762E69C3, (q31_t)0x312A31F8, - (q31_t)0x761B1211, (q31_t)0x3158970D, (q31_t)0x7607A827, - (q31_t)0x3186F487, (q31_t)0x75F42C0A, (q31_t)0x31B54A5D, - (q31_t)0x75E09DBD, (q31_t)0x31E39889, (q31_t)0x75CCFD42, - (q31_t)0x3211DF03, (q31_t)0x75B94A9C, (q31_t)0x32401DC5, - (q31_t)0x75A585CF, (q31_t)0x326E54C7, (q31_t)0x7591AEDD, - (q31_t)0x329C8402, (q31_t)0x757DC5CA, (q31_t)0x32CAAB6F, - (q31_t)0x7569CA98, (q31_t)0x32F8CB07, (q31_t)0x7555BD4B, - (q31_t)0x3326E2C2, (q31_t)0x75419DE6, (q31_t)0x3354F29A, - (q31_t)0x752D6C6C, (q31_t)0x3382FA88, (q31_t)0x751928E0, - (q31_t)0x33B0FA84, (q31_t)0x7504D345, (q31_t)0x33DEF287, - (q31_t)0x74F06B9E, (q31_t)0x340CE28A, (q31_t)0x74DBF1EF, - (q31_t)0x343ACA87, (q31_t)0x74C7663A, (q31_t)0x3468AA76, - (q31_t)0x74B2C883, (q31_t)0x3496824F, (q31_t)0x749E18CD, - (q31_t)0x34C4520D, (q31_t)0x7489571B, (q31_t)0x34F219A7, - (q31_t)0x74748371, (q31_t)0x351FD917, (q31_t)0x745F9DD1, - (q31_t)0x354D9056, (q31_t)0x744AA63E, (q31_t)0x357B3F5D, - (q31_t)0x74359CBD, (q31_t)0x35A8E624, (q31_t)0x74208150, - (q31_t)0x35D684A5, (q31_t)0x740B53FA, (q31_t)0x36041AD9, - (q31_t)0x73F614C0, (q31_t)0x3631A8B7, (q31_t)0x73E0C3A3, - (q31_t)0x365F2E3B, (q31_t)0x73CB60A7, (q31_t)0x368CAB5C, - (q31_t)0x73B5EBD0, (q31_t)0x36BA2013, (q31_t)0x73A06522, - (q31_t)0x36E78C5A, (q31_t)0x738ACC9E, (q31_t)0x3714F02A, - (q31_t)0x73752249, (q31_t)0x37424B7A, (q31_t)0x735F6626, - (q31_t)0x376F9E46, (q31_t)0x73499838, (q31_t)0x379CE884, - (q31_t)0x7333B883, (q31_t)0x37CA2A30, (q31_t)0x731DC709, - (q31_t)0x37F76340, (q31_t)0x7307C3D0, (q31_t)0x382493B0, - (q31_t)0x72F1AED8, (q31_t)0x3851BB76, (q31_t)0x72DB8828, - (q31_t)0x387EDA8E, (q31_t)0x72C54FC0, (q31_t)0x38ABF0EF, - (q31_t)0x72AF05A6, (q31_t)0x38D8FE93, (q31_t)0x7298A9DC, - (q31_t)0x39060372, (q31_t)0x72823C66, (q31_t)0x3932FF87, - (q31_t)0x726BBD48, (q31_t)0x395FF2C9, (q31_t)0x72552C84, - (q31_t)0x398CDD32, (q31_t)0x723E8A1F, (q31_t)0x39B9BEBB, - (q31_t)0x7227D61C, (q31_t)0x39E6975D, (q31_t)0x7211107D, - (q31_t)0x3A136712, (q31_t)0x71FA3948, (q31_t)0x3A402DD1, - (q31_t)0x71E3507F, (q31_t)0x3A6CEB95, (q31_t)0x71CC5626, - (q31_t)0x3A99A057, (q31_t)0x71B54A40, (q31_t)0x3AC64C0F, - (q31_t)0x719E2CD2, (q31_t)0x3AF2EEB7, (q31_t)0x7186FDDE, - (q31_t)0x3B1F8847, (q31_t)0x716FBD68, (q31_t)0x3B4C18BA, - (q31_t)0x71586B73, (q31_t)0x3B78A007, (q31_t)0x71410804, - (q31_t)0x3BA51E29, (q31_t)0x7129931E, (q31_t)0x3BD19317, - (q31_t)0x71120CC5, (q31_t)0x3BFDFECD, (q31_t)0x70FA74FB, - (q31_t)0x3C2A6142, (q31_t)0x70E2CBC6, (q31_t)0x3C56BA70, - (q31_t)0x70CB1127, (q31_t)0x3C830A4F, (q31_t)0x70B34524, - (q31_t)0x3CAF50DA, (q31_t)0x709B67C0, (q31_t)0x3CDB8E09, - (q31_t)0x708378FE, (q31_t)0x3D07C1D5, (q31_t)0x706B78E3, - (q31_t)0x3D33EC39, (q31_t)0x70536771, (q31_t)0x3D600D2B, - (q31_t)0x703B44AC, (q31_t)0x3D8C24A7, (q31_t)0x70231099, - (q31_t)0x3DB832A5, (q31_t)0x700ACB3B, (q31_t)0x3DE4371F, - (q31_t)0x6FF27496, (q31_t)0x3E10320D, (q31_t)0x6FDA0CAD, - (q31_t)0x3E3C2369, (q31_t)0x6FC19385, (q31_t)0x3E680B2C, - (q31_t)0x6FA90920, (q31_t)0x3E93E94F, (q31_t)0x6F906D84, - (q31_t)0x3EBFBDCC, (q31_t)0x6F77C0B3, (q31_t)0x3EEB889C, - (q31_t)0x6F5F02B1, (q31_t)0x3F1749B7, (q31_t)0x6F463383, - (q31_t)0x3F430118, (q31_t)0x6F2D532C, (q31_t)0x3F6EAEB8, - (q31_t)0x6F1461AF, (q31_t)0x3F9A528F, (q31_t)0x6EFB5F12, - (q31_t)0x3FC5EC97, (q31_t)0x6EE24B57, (q31_t)0x3FF17CCA, - (q31_t)0x6EC92682, (q31_t)0x401D0320, (q31_t)0x6EAFF098, - (q31_t)0x40487F93, (q31_t)0x6E96A99C, (q31_t)0x4073F21D, - (q31_t)0x6E7D5193, (q31_t)0x409F5AB6, (q31_t)0x6E63E87F, - (q31_t)0x40CAB957, (q31_t)0x6E4A6E65, (q31_t)0x40F60DFB, - (q31_t)0x6E30E349, (q31_t)0x4121589A, (q31_t)0x6E17472F, - (q31_t)0x414C992E, (q31_t)0x6DFD9A1B, (q31_t)0x4177CFB0, - (q31_t)0x6DE3DC11, (q31_t)0x41A2FC1A, (q31_t)0x6DCA0D14, - (q31_t)0x41CE1E64, (q31_t)0x6DB02D29, (q31_t)0x41F93688, - (q31_t)0x6D963C54, (q31_t)0x42244480, (q31_t)0x6D7C3A98, - (q31_t)0x424F4845, (q31_t)0x6D6227FA, (q31_t)0x427A41D0, - (q31_t)0x6D48047E, (q31_t)0x42A5311A, (q31_t)0x6D2DD027, - (q31_t)0x42D0161E, (q31_t)0x6D138AFA, (q31_t)0x42FAF0D4, - (q31_t)0x6CF934FB, (q31_t)0x4325C135, (q31_t)0x6CDECE2E, - (q31_t)0x4350873C, (q31_t)0x6CC45697, (q31_t)0x437B42E1, - (q31_t)0x6CA9CE3A, (q31_t)0x43A5F41E, (q31_t)0x6C8F351C, - (q31_t)0x43D09AEC, (q31_t)0x6C748B3F, (q31_t)0x43FB3745, - (q31_t)0x6C59D0A9, (q31_t)0x4425C923, (q31_t)0x6C3F055D, - (q31_t)0x4450507E, (q31_t)0x6C242960, (q31_t)0x447ACD50, - (q31_t)0x6C093CB6, (q31_t)0x44A53F93, (q31_t)0x6BEE3F62, - (q31_t)0x44CFA73F, (q31_t)0x6BD3316A, (q31_t)0x44FA044F, - (q31_t)0x6BB812D0, (q31_t)0x452456BC, (q31_t)0x6B9CE39B, - (q31_t)0x454E9E80, (q31_t)0x6B81A3CD, (q31_t)0x4578DB93, - (q31_t)0x6B66536A, (q31_t)0x45A30DF0, (q31_t)0x6B4AF278, - (q31_t)0x45CD358F, (q31_t)0x6B2F80FA, (q31_t)0x45F7526B, - (q31_t)0x6B13FEF5, (q31_t)0x4621647C, (q31_t)0x6AF86C6C, - (q31_t)0x464B6BBD, (q31_t)0x6ADCC964, (q31_t)0x46756827, - (q31_t)0x6AC115E1, (q31_t)0x469F59B4, (q31_t)0x6AA551E8, - (q31_t)0x46C9405C, (q31_t)0x6A897D7D, (q31_t)0x46F31C1A, - (q31_t)0x6A6D98A4, (q31_t)0x471CECE6, (q31_t)0x6A51A361, - (q31_t)0x4746B2BC, (q31_t)0x6A359DB9, (q31_t)0x47706D93, - (q31_t)0x6A1987B0, (q31_t)0x479A1D66, (q31_t)0x69FD614A, - (q31_t)0x47C3C22E, (q31_t)0x69E12A8C, (q31_t)0x47ED5BE6, - (q31_t)0x69C4E37A, (q31_t)0x4816EA85, (q31_t)0x69A88C18, - (q31_t)0x48406E07, (q31_t)0x698C246C, (q31_t)0x4869E664, - (q31_t)0x696FAC78, (q31_t)0x48935397, (q31_t)0x69532442, - (q31_t)0x48BCB598, (q31_t)0x69368BCE, (q31_t)0x48E60C62, - (q31_t)0x6919E320, (q31_t)0x490F57EE, (q31_t)0x68FD2A3D, - (q31_t)0x49389836, (q31_t)0x68E06129, (q31_t)0x4961CD32, - (q31_t)0x68C387E9, (q31_t)0x498AF6DE, (q31_t)0x68A69E81, - (q31_t)0x49B41533, (q31_t)0x6889A4F5, (q31_t)0x49DD282A, - (q31_t)0x686C9B4B, (q31_t)0x4A062FBD, (q31_t)0x684F8186, - (q31_t)0x4A2F2BE5, (q31_t)0x683257AA, (q31_t)0x4A581C9D, - (q31_t)0x68151DBE, (q31_t)0x4A8101DE, (q31_t)0x67F7D3C4, - (q31_t)0x4AA9DBA1, (q31_t)0x67DA79C2, (q31_t)0x4AD2A9E1, - (q31_t)0x67BD0FBC, (q31_t)0x4AFB6C97, (q31_t)0x679F95B7, - (q31_t)0x4B2423BD, (q31_t)0x67820BB6, (q31_t)0x4B4CCF4D, - (q31_t)0x676471C0, (q31_t)0x4B756F3F, (q31_t)0x6746C7D7, - (q31_t)0x4B9E038F, (q31_t)0x67290E02, (q31_t)0x4BC68C36, - (q31_t)0x670B4443, (q31_t)0x4BEF092D, (q31_t)0x66ED6AA1, - (q31_t)0x4C177A6E, (q31_t)0x66CF811F, (q31_t)0x4C3FDFF3, - (q31_t)0x66B187C3, (q31_t)0x4C6839B6, (q31_t)0x66937E90, - (q31_t)0x4C9087B1, (q31_t)0x6675658C, (q31_t)0x4CB8C9DD, - (q31_t)0x66573CBB, (q31_t)0x4CE10034, (q31_t)0x66390422, - (q31_t)0x4D092AB0, (q31_t)0x661ABBC5, (q31_t)0x4D31494B, - (q31_t)0x65FC63A9, (q31_t)0x4D595BFE, (q31_t)0x65DDFBD3, - (q31_t)0x4D8162C4, (q31_t)0x65BF8447, (q31_t)0x4DA95D96, - (q31_t)0x65A0FD0B, (q31_t)0x4DD14C6E, (q31_t)0x65826622, - (q31_t)0x4DF92F45, (q31_t)0x6563BF92, (q31_t)0x4E210617, - (q31_t)0x6545095F, (q31_t)0x4E48D0DC, (q31_t)0x6526438E, - (q31_t)0x4E708F8F, (q31_t)0x65076E24, (q31_t)0x4E984229, - (q31_t)0x64E88926, (q31_t)0x4EBFE8A4, (q31_t)0x64C99498, - (q31_t)0x4EE782FA, (q31_t)0x64AA907F, (q31_t)0x4F0F1126, - (q31_t)0x648B7CDF, (q31_t)0x4F369320, (q31_t)0x646C59BF, - (q31_t)0x4F5E08E3, (q31_t)0x644D2722, (q31_t)0x4F857268, - (q31_t)0x642DE50D, (q31_t)0x4FACCFAB, (q31_t)0x640E9385, - (q31_t)0x4FD420A3, (q31_t)0x63EF328F, (q31_t)0x4FFB654D, - (q31_t)0x63CFC230, (q31_t)0x50229DA0, (q31_t)0x63B0426D, - (q31_t)0x5049C999, (q31_t)0x6390B34A, (q31_t)0x5070E92F, - (q31_t)0x637114CC, (q31_t)0x5097FC5E, (q31_t)0x635166F8, - (q31_t)0x50BF031F, (q31_t)0x6331A9D4, (q31_t)0x50E5FD6C, - (q31_t)0x6311DD63, (q31_t)0x510CEB40, (q31_t)0x62F201AC, - (q31_t)0x5133CC94, (q31_t)0x62D216B2, (q31_t)0x515AA162, - (q31_t)0x62B21C7B, (q31_t)0x518169A4, (q31_t)0x6292130C, - (q31_t)0x51A82555, (q31_t)0x6271FA69, (q31_t)0x51CED46E, - (q31_t)0x6251D297, (q31_t)0x51F576E9, (q31_t)0x62319B9D, - (q31_t)0x521C0CC1, (q31_t)0x6211557D, (q31_t)0x524295EF, - (q31_t)0x61F1003E, (q31_t)0x5269126E, (q31_t)0x61D09BE5, - (q31_t)0x528F8237, (q31_t)0x61B02876, (q31_t)0x52B5E545, - (q31_t)0x618FA5F6, (q31_t)0x52DC3B92, (q31_t)0x616F146B, - (q31_t)0x53028517, (q31_t)0x614E73D9, (q31_t)0x5328C1D0, - (q31_t)0x612DC446, (q31_t)0x534EF1B5, (q31_t)0x610D05B7, - (q31_t)0x537514C1, (q31_t)0x60EC3830, (q31_t)0x539B2AEF, - (q31_t)0x60CB5BB6, (q31_t)0x53C13438, (q31_t)0x60AA704F, - (q31_t)0x53E73097, (q31_t)0x60897600, (q31_t)0x540D2005, - (q31_t)0x60686CCE, (q31_t)0x5433027D, (q31_t)0x604754BE, - (q31_t)0x5458D7F9, (q31_t)0x60262DD5, (q31_t)0x547EA073, - (q31_t)0x6004F818, (q31_t)0x54A45BE5, (q31_t)0x5FE3B38D, - (q31_t)0x54CA0A4A, (q31_t)0x5FC26038, (q31_t)0x54EFAB9C, - (q31_t)0x5FA0FE1E, (q31_t)0x55153FD4, (q31_t)0x5F7F8D46, - (q31_t)0x553AC6ED, (q31_t)0x5F5E0DB3, (q31_t)0x556040E2, - (q31_t)0x5F3C7F6B, (q31_t)0x5585ADAC, (q31_t)0x5F1AE273, - (q31_t)0x55AB0D46, (q31_t)0x5EF936D1, (q31_t)0x55D05FAA, - (q31_t)0x5ED77C89, (q31_t)0x55F5A4D2, (q31_t)0x5EB5B3A1, - (q31_t)0x561ADCB8, (q31_t)0x5E93DC1F, (q31_t)0x56400757, - (q31_t)0x5E71F606, (q31_t)0x566524AA, (q31_t)0x5E50015D, - (q31_t)0x568A34A9, (q31_t)0x5E2DFE28, (q31_t)0x56AF3750, - (q31_t)0x5E0BEC6E, (q31_t)0x56D42C99, (q31_t)0x5DE9CC32, - (q31_t)0x56F9147E, (q31_t)0x5DC79D7C, (q31_t)0x571DEEF9, - (q31_t)0x5DA5604E, (q31_t)0x5742BC05, (q31_t)0x5D8314B0, - (q31_t)0x57677B9D, (q31_t)0x5D60BAA6, (q31_t)0x578C2DB9, - (q31_t)0x5D3E5236, (q31_t)0x57B0D256, (q31_t)0x5D1BDB65, - (q31_t)0x57D5696C, (q31_t)0x5CF95638, (q31_t)0x57F9F2F7, - (q31_t)0x5CD6C2B4, (q31_t)0x581E6EF1, (q31_t)0x5CB420DF, - (q31_t)0x5842DD54, (q31_t)0x5C9170BF, (q31_t)0x58673E1B, - (q31_t)0x5C6EB258, (q31_t)0x588B913F, (q31_t)0x5C4BE5B0, - (q31_t)0x58AFD6BC, (q31_t)0x5C290ACC, (q31_t)0x58D40E8C, - (q31_t)0x5C0621B2, (q31_t)0x58F838A9, (q31_t)0x5BE32A67, - (q31_t)0x591C550E, (q31_t)0x5BC024F0, (q31_t)0x594063B4, - (q31_t)0x5B9D1153, (q31_t)0x59646497, (q31_t)0x5B79EF96, - (q31_t)0x598857B1, (q31_t)0x5B56BFBD, (q31_t)0x59AC3CFD, - (q31_t)0x5B3381CE, (q31_t)0x59D01474, (q31_t)0x5B1035CF, - (q31_t)0x59F3DE12, (q31_t)0x5AECDBC4, (q31_t)0x5A1799D0, - (q31_t)0x5AC973B4, (q31_t)0x5A3B47AA, (q31_t)0x5AA5FDA4, - (q31_t)0x5A5EE79A, (q31_t)0x5A82799A, (q31_t)0x5A82799A, - (q31_t)0x5A5EE79A, (q31_t)0x5AA5FDA4, (q31_t)0x5A3B47AA, - (q31_t)0x5AC973B4, (q31_t)0x5A1799D0, (q31_t)0x5AECDBC4, - (q31_t)0x59F3DE12, (q31_t)0x5B1035CF, (q31_t)0x59D01474, - (q31_t)0x5B3381CE, (q31_t)0x59AC3CFD, (q31_t)0x5B56BFBD, - (q31_t)0x598857B1, (q31_t)0x5B79EF96, (q31_t)0x59646497, - (q31_t)0x5B9D1153, (q31_t)0x594063B4, (q31_t)0x5BC024F0, - (q31_t)0x591C550E, (q31_t)0x5BE32A67, (q31_t)0x58F838A9, - (q31_t)0x5C0621B2, (q31_t)0x58D40E8C, (q31_t)0x5C290ACC, - (q31_t)0x58AFD6BC, (q31_t)0x5C4BE5B0, (q31_t)0x588B913F, - (q31_t)0x5C6EB258, (q31_t)0x58673E1B, (q31_t)0x5C9170BF, - (q31_t)0x5842DD54, (q31_t)0x5CB420DF, (q31_t)0x581E6EF1, - (q31_t)0x5CD6C2B4, (q31_t)0x57F9F2F7, (q31_t)0x5CF95638, - (q31_t)0x57D5696C, (q31_t)0x5D1BDB65, (q31_t)0x57B0D256, - (q31_t)0x5D3E5236, (q31_t)0x578C2DB9, (q31_t)0x5D60BAA6, - (q31_t)0x57677B9D, (q31_t)0x5D8314B0, (q31_t)0x5742BC05, - (q31_t)0x5DA5604E, (q31_t)0x571DEEF9, (q31_t)0x5DC79D7C, - (q31_t)0x56F9147E, (q31_t)0x5DE9CC32, (q31_t)0x56D42C99, - (q31_t)0x5E0BEC6E, (q31_t)0x56AF3750, (q31_t)0x5E2DFE28, - (q31_t)0x568A34A9, (q31_t)0x5E50015D, (q31_t)0x566524AA, - (q31_t)0x5E71F606, (q31_t)0x56400757, (q31_t)0x5E93DC1F, - (q31_t)0x561ADCB8, (q31_t)0x5EB5B3A1, (q31_t)0x55F5A4D2, - (q31_t)0x5ED77C89, (q31_t)0x55D05FAA, (q31_t)0x5EF936D1, - (q31_t)0x55AB0D46, (q31_t)0x5F1AE273, (q31_t)0x5585ADAC, - (q31_t)0x5F3C7F6B, (q31_t)0x556040E2, (q31_t)0x5F5E0DB3, - (q31_t)0x553AC6ED, (q31_t)0x5F7F8D46, (q31_t)0x55153FD4, - (q31_t)0x5FA0FE1E, (q31_t)0x54EFAB9C, (q31_t)0x5FC26038, - (q31_t)0x54CA0A4A, (q31_t)0x5FE3B38D, (q31_t)0x54A45BE5, - (q31_t)0x6004F818, (q31_t)0x547EA073, (q31_t)0x60262DD5, - (q31_t)0x5458D7F9, (q31_t)0x604754BE, (q31_t)0x5433027D, - (q31_t)0x60686CCE, (q31_t)0x540D2005, (q31_t)0x60897600, - (q31_t)0x53E73097, (q31_t)0x60AA704F, (q31_t)0x53C13438, - (q31_t)0x60CB5BB6, (q31_t)0x539B2AEF, (q31_t)0x60EC3830, - (q31_t)0x537514C1, (q31_t)0x610D05B7, (q31_t)0x534EF1B5, - (q31_t)0x612DC446, (q31_t)0x5328C1D0, (q31_t)0x614E73D9, - (q31_t)0x53028517, (q31_t)0x616F146B, (q31_t)0x52DC3B92, - (q31_t)0x618FA5F6, (q31_t)0x52B5E545, (q31_t)0x61B02876, - (q31_t)0x528F8237, (q31_t)0x61D09BE5, (q31_t)0x5269126E, - (q31_t)0x61F1003E, (q31_t)0x524295EF, (q31_t)0x6211557D, - (q31_t)0x521C0CC1, (q31_t)0x62319B9D, (q31_t)0x51F576E9, - (q31_t)0x6251D297, (q31_t)0x51CED46E, (q31_t)0x6271FA69, - (q31_t)0x51A82555, (q31_t)0x6292130C, (q31_t)0x518169A4, - (q31_t)0x62B21C7B, (q31_t)0x515AA162, (q31_t)0x62D216B2, - (q31_t)0x5133CC94, (q31_t)0x62F201AC, (q31_t)0x510CEB40, - (q31_t)0x6311DD63, (q31_t)0x50E5FD6C, (q31_t)0x6331A9D4, - (q31_t)0x50BF031F, (q31_t)0x635166F8, (q31_t)0x5097FC5E, - (q31_t)0x637114CC, (q31_t)0x5070E92F, (q31_t)0x6390B34A, - (q31_t)0x5049C999, (q31_t)0x63B0426D, (q31_t)0x50229DA0, - (q31_t)0x63CFC230, (q31_t)0x4FFB654D, (q31_t)0x63EF328F, - (q31_t)0x4FD420A3, (q31_t)0x640E9385, (q31_t)0x4FACCFAB, - (q31_t)0x642DE50D, (q31_t)0x4F857268, (q31_t)0x644D2722, - (q31_t)0x4F5E08E3, (q31_t)0x646C59BF, (q31_t)0x4F369320, - (q31_t)0x648B7CDF, (q31_t)0x4F0F1126, (q31_t)0x64AA907F, - (q31_t)0x4EE782FA, (q31_t)0x64C99498, (q31_t)0x4EBFE8A4, - (q31_t)0x64E88926, (q31_t)0x4E984229, (q31_t)0x65076E24, - (q31_t)0x4E708F8F, (q31_t)0x6526438E, (q31_t)0x4E48D0DC, - (q31_t)0x6545095F, (q31_t)0x4E210617, (q31_t)0x6563BF92, - (q31_t)0x4DF92F45, (q31_t)0x65826622, (q31_t)0x4DD14C6E, - (q31_t)0x65A0FD0B, (q31_t)0x4DA95D96, (q31_t)0x65BF8447, - (q31_t)0x4D8162C4, (q31_t)0x65DDFBD3, (q31_t)0x4D595BFE, - (q31_t)0x65FC63A9, (q31_t)0x4D31494B, (q31_t)0x661ABBC5, - (q31_t)0x4D092AB0, (q31_t)0x66390422, (q31_t)0x4CE10034, - (q31_t)0x66573CBB, (q31_t)0x4CB8C9DD, (q31_t)0x6675658C, - (q31_t)0x4C9087B1, (q31_t)0x66937E90, (q31_t)0x4C6839B6, - (q31_t)0x66B187C3, (q31_t)0x4C3FDFF3, (q31_t)0x66CF811F, - (q31_t)0x4C177A6E, (q31_t)0x66ED6AA1, (q31_t)0x4BEF092D, - (q31_t)0x670B4443, (q31_t)0x4BC68C36, (q31_t)0x67290E02, - (q31_t)0x4B9E038F, (q31_t)0x6746C7D7, (q31_t)0x4B756F3F, - (q31_t)0x676471C0, (q31_t)0x4B4CCF4D, (q31_t)0x67820BB6, - (q31_t)0x4B2423BD, (q31_t)0x679F95B7, (q31_t)0x4AFB6C97, - (q31_t)0x67BD0FBC, (q31_t)0x4AD2A9E1, (q31_t)0x67DA79C2, - (q31_t)0x4AA9DBA1, (q31_t)0x67F7D3C4, (q31_t)0x4A8101DE, - (q31_t)0x68151DBE, (q31_t)0x4A581C9D, (q31_t)0x683257AA, - (q31_t)0x4A2F2BE5, (q31_t)0x684F8186, (q31_t)0x4A062FBD, - (q31_t)0x686C9B4B, (q31_t)0x49DD282A, (q31_t)0x6889A4F5, - (q31_t)0x49B41533, (q31_t)0x68A69E81, (q31_t)0x498AF6DE, - (q31_t)0x68C387E9, (q31_t)0x4961CD32, (q31_t)0x68E06129, - (q31_t)0x49389836, (q31_t)0x68FD2A3D, (q31_t)0x490F57EE, - (q31_t)0x6919E320, (q31_t)0x48E60C62, (q31_t)0x69368BCE, - (q31_t)0x48BCB598, (q31_t)0x69532442, (q31_t)0x48935397, - (q31_t)0x696FAC78, (q31_t)0x4869E664, (q31_t)0x698C246C, - (q31_t)0x48406E07, (q31_t)0x69A88C18, (q31_t)0x4816EA85, - (q31_t)0x69C4E37A, (q31_t)0x47ED5BE6, (q31_t)0x69E12A8C, - (q31_t)0x47C3C22E, (q31_t)0x69FD614A, (q31_t)0x479A1D66, - (q31_t)0x6A1987B0, (q31_t)0x47706D93, (q31_t)0x6A359DB9, - (q31_t)0x4746B2BC, (q31_t)0x6A51A361, (q31_t)0x471CECE6, - (q31_t)0x6A6D98A4, (q31_t)0x46F31C1A, (q31_t)0x6A897D7D, - (q31_t)0x46C9405C, (q31_t)0x6AA551E8, (q31_t)0x469F59B4, - (q31_t)0x6AC115E1, (q31_t)0x46756827, (q31_t)0x6ADCC964, - (q31_t)0x464B6BBD, (q31_t)0x6AF86C6C, (q31_t)0x4621647C, - (q31_t)0x6B13FEF5, (q31_t)0x45F7526B, (q31_t)0x6B2F80FA, - (q31_t)0x45CD358F, (q31_t)0x6B4AF278, (q31_t)0x45A30DF0, - (q31_t)0x6B66536A, (q31_t)0x4578DB93, (q31_t)0x6B81A3CD, - (q31_t)0x454E9E80, (q31_t)0x6B9CE39B, (q31_t)0x452456BC, - (q31_t)0x6BB812D0, (q31_t)0x44FA044F, (q31_t)0x6BD3316A, - (q31_t)0x44CFA73F, (q31_t)0x6BEE3F62, (q31_t)0x44A53F93, - (q31_t)0x6C093CB6, (q31_t)0x447ACD50, (q31_t)0x6C242960, - (q31_t)0x4450507E, (q31_t)0x6C3F055D, (q31_t)0x4425C923, - (q31_t)0x6C59D0A9, (q31_t)0x43FB3745, (q31_t)0x6C748B3F, - (q31_t)0x43D09AEC, (q31_t)0x6C8F351C, (q31_t)0x43A5F41E, - (q31_t)0x6CA9CE3A, (q31_t)0x437B42E1, (q31_t)0x6CC45697, - (q31_t)0x4350873C, (q31_t)0x6CDECE2E, (q31_t)0x4325C135, - (q31_t)0x6CF934FB, (q31_t)0x42FAF0D4, (q31_t)0x6D138AFA, - (q31_t)0x42D0161E, (q31_t)0x6D2DD027, (q31_t)0x42A5311A, - (q31_t)0x6D48047E, (q31_t)0x427A41D0, (q31_t)0x6D6227FA, - (q31_t)0x424F4845, (q31_t)0x6D7C3A98, (q31_t)0x42244480, - (q31_t)0x6D963C54, (q31_t)0x41F93688, (q31_t)0x6DB02D29, - (q31_t)0x41CE1E64, (q31_t)0x6DCA0D14, (q31_t)0x41A2FC1A, - (q31_t)0x6DE3DC11, (q31_t)0x4177CFB0, (q31_t)0x6DFD9A1B, - (q31_t)0x414C992E, (q31_t)0x6E17472F, (q31_t)0x4121589A, - (q31_t)0x6E30E349, (q31_t)0x40F60DFB, (q31_t)0x6E4A6E65, - (q31_t)0x40CAB957, (q31_t)0x6E63E87F, (q31_t)0x409F5AB6, - (q31_t)0x6E7D5193, (q31_t)0x4073F21D, (q31_t)0x6E96A99C, - (q31_t)0x40487F93, (q31_t)0x6EAFF098, (q31_t)0x401D0320, - (q31_t)0x6EC92682, (q31_t)0x3FF17CCA, (q31_t)0x6EE24B57, - (q31_t)0x3FC5EC97, (q31_t)0x6EFB5F12, (q31_t)0x3F9A528F, - (q31_t)0x6F1461AF, (q31_t)0x3F6EAEB8, (q31_t)0x6F2D532C, - (q31_t)0x3F430118, (q31_t)0x6F463383, (q31_t)0x3F1749B7, - (q31_t)0x6F5F02B1, (q31_t)0x3EEB889C, (q31_t)0x6F77C0B3, - (q31_t)0x3EBFBDCC, (q31_t)0x6F906D84, (q31_t)0x3E93E94F, - (q31_t)0x6FA90920, (q31_t)0x3E680B2C, (q31_t)0x6FC19385, - (q31_t)0x3E3C2369, (q31_t)0x6FDA0CAD, (q31_t)0x3E10320D, - (q31_t)0x6FF27496, (q31_t)0x3DE4371F, (q31_t)0x700ACB3B, - (q31_t)0x3DB832A5, (q31_t)0x70231099, (q31_t)0x3D8C24A7, - (q31_t)0x703B44AC, (q31_t)0x3D600D2B, (q31_t)0x70536771, - (q31_t)0x3D33EC39, (q31_t)0x706B78E3, (q31_t)0x3D07C1D5, - (q31_t)0x708378FE, (q31_t)0x3CDB8E09, (q31_t)0x709B67C0, - (q31_t)0x3CAF50DA, (q31_t)0x70B34524, (q31_t)0x3C830A4F, - (q31_t)0x70CB1127, (q31_t)0x3C56BA70, (q31_t)0x70E2CBC6, - (q31_t)0x3C2A6142, (q31_t)0x70FA74FB, (q31_t)0x3BFDFECD, - (q31_t)0x71120CC5, (q31_t)0x3BD19317, (q31_t)0x7129931E, - (q31_t)0x3BA51E29, (q31_t)0x71410804, (q31_t)0x3B78A007, - (q31_t)0x71586B73, (q31_t)0x3B4C18BA, (q31_t)0x716FBD68, - (q31_t)0x3B1F8847, (q31_t)0x7186FDDE, (q31_t)0x3AF2EEB7, - (q31_t)0x719E2CD2, (q31_t)0x3AC64C0F, (q31_t)0x71B54A40, - (q31_t)0x3A99A057, (q31_t)0x71CC5626, (q31_t)0x3A6CEB95, - (q31_t)0x71E3507F, (q31_t)0x3A402DD1, (q31_t)0x71FA3948, - (q31_t)0x3A136712, (q31_t)0x7211107D, (q31_t)0x39E6975D, - (q31_t)0x7227D61C, (q31_t)0x39B9BEBB, (q31_t)0x723E8A1F, - (q31_t)0x398CDD32, (q31_t)0x72552C84, (q31_t)0x395FF2C9, - (q31_t)0x726BBD48, (q31_t)0x3932FF87, (q31_t)0x72823C66, - (q31_t)0x39060372, (q31_t)0x7298A9DC, (q31_t)0x38D8FE93, - (q31_t)0x72AF05A6, (q31_t)0x38ABF0EF, (q31_t)0x72C54FC0, - (q31_t)0x387EDA8E, (q31_t)0x72DB8828, (q31_t)0x3851BB76, - (q31_t)0x72F1AED8, (q31_t)0x382493B0, (q31_t)0x7307C3D0, - (q31_t)0x37F76340, (q31_t)0x731DC709, (q31_t)0x37CA2A30, - (q31_t)0x7333B883, (q31_t)0x379CE884, (q31_t)0x73499838, - (q31_t)0x376F9E46, (q31_t)0x735F6626, (q31_t)0x37424B7A, - (q31_t)0x73752249, (q31_t)0x3714F02A, (q31_t)0x738ACC9E, - (q31_t)0x36E78C5A, (q31_t)0x73A06522, (q31_t)0x36BA2013, - (q31_t)0x73B5EBD0, (q31_t)0x368CAB5C, (q31_t)0x73CB60A7, - (q31_t)0x365F2E3B, (q31_t)0x73E0C3A3, (q31_t)0x3631A8B7, - (q31_t)0x73F614C0, (q31_t)0x36041AD9, (q31_t)0x740B53FA, - (q31_t)0x35D684A5, (q31_t)0x74208150, (q31_t)0x35A8E624, - (q31_t)0x74359CBD, (q31_t)0x357B3F5D, (q31_t)0x744AA63E, - (q31_t)0x354D9056, (q31_t)0x745F9DD1, (q31_t)0x351FD917, - (q31_t)0x74748371, (q31_t)0x34F219A7, (q31_t)0x7489571B, - (q31_t)0x34C4520D, (q31_t)0x749E18CD, (q31_t)0x3496824F, - (q31_t)0x74B2C883, (q31_t)0x3468AA76, (q31_t)0x74C7663A, - (q31_t)0x343ACA87, (q31_t)0x74DBF1EF, (q31_t)0x340CE28A, - (q31_t)0x74F06B9E, (q31_t)0x33DEF287, (q31_t)0x7504D345, - (q31_t)0x33B0FA84, (q31_t)0x751928E0, (q31_t)0x3382FA88, - (q31_t)0x752D6C6C, (q31_t)0x3354F29A, (q31_t)0x75419DE6, - (q31_t)0x3326E2C2, (q31_t)0x7555BD4B, (q31_t)0x32F8CB07, - (q31_t)0x7569CA98, (q31_t)0x32CAAB6F, (q31_t)0x757DC5CA, - (q31_t)0x329C8402, (q31_t)0x7591AEDD, (q31_t)0x326E54C7, - (q31_t)0x75A585CF, (q31_t)0x32401DC5, (q31_t)0x75B94A9C, - (q31_t)0x3211DF03, (q31_t)0x75CCFD42, (q31_t)0x31E39889, - (q31_t)0x75E09DBD, (q31_t)0x31B54A5D, (q31_t)0x75F42C0A, - (q31_t)0x3186F487, (q31_t)0x7607A827, (q31_t)0x3158970D, - (q31_t)0x761B1211, (q31_t)0x312A31F8, (q31_t)0x762E69C3, - (q31_t)0x30FBC54D, (q31_t)0x7641AF3C, (q31_t)0x30CD5114, - (q31_t)0x7654E279, (q31_t)0x309ED555, (q31_t)0x76680376, - (q31_t)0x30705217, (q31_t)0x767B1230, (q31_t)0x3041C760, - (q31_t)0x768E0EA5, (q31_t)0x30133538, (q31_t)0x76A0F8D2, - (q31_t)0x2FE49BA6, (q31_t)0x76B3D0B3, (q31_t)0x2FB5FAB2, - (q31_t)0x76C69646, (q31_t)0x2F875262, (q31_t)0x76D94988, - (q31_t)0x2F58A2BD, (q31_t)0x76EBEA77, (q31_t)0x2F29EBCC, - (q31_t)0x76FE790E, (q31_t)0x2EFB2D94, (q31_t)0x7710F54B, - (q31_t)0x2ECC681E, (q31_t)0x77235F2D, (q31_t)0x2E9D9B70, - (q31_t)0x7735B6AE, (q31_t)0x2E6EC792, (q31_t)0x7747FBCE, - (q31_t)0x2E3FEC8B, (q31_t)0x775A2E88, (q31_t)0x2E110A62, - (q31_t)0x776C4EDB, (q31_t)0x2DE2211E, (q31_t)0x777E5CC3, - (q31_t)0x2DB330C7, (q31_t)0x7790583D, (q31_t)0x2D843963, - (q31_t)0x77A24148, (q31_t)0x2D553AFB, (q31_t)0x77B417DF, - (q31_t)0x2D263595, (q31_t)0x77C5DC01, (q31_t)0x2CF72939, - (q31_t)0x77D78DAA, (q31_t)0x2CC815ED, (q31_t)0x77E92CD8, - (q31_t)0x2C98FBBA, (q31_t)0x77FAB988, (q31_t)0x2C69DAA6, - (q31_t)0x780C33B8, (q31_t)0x2C3AB2B9, (q31_t)0x781D9B64, - (q31_t)0x2C0B83F9, (q31_t)0x782EF08B, (q31_t)0x2BDC4E6F, - (q31_t)0x78403328, (q31_t)0x2BAD1221, (q31_t)0x7851633B, - (q31_t)0x2B7DCF17, (q31_t)0x786280BF, (q31_t)0x2B4E8558, - (q31_t)0x78738BB3, (q31_t)0x2B1F34EB, (q31_t)0x78848413, - (q31_t)0x2AEFDDD8, (q31_t)0x789569DE, (q31_t)0x2AC08025, - (q31_t)0x78A63D10, (q31_t)0x2A911BDB, (q31_t)0x78B6FDA8, - (q31_t)0x2A61B101, (q31_t)0x78C7ABA1, (q31_t)0x2A323F9D, - (q31_t)0x78D846FB, (q31_t)0x2A02C7B8, (q31_t)0x78E8CFB1, - (q31_t)0x29D34958, (q31_t)0x78F945C3, (q31_t)0x29A3C484, - (q31_t)0x7909A92C, (q31_t)0x29743945, (q31_t)0x7919F9EB, - (q31_t)0x2944A7A2, (q31_t)0x792A37FE, (q31_t)0x29150FA1, - (q31_t)0x793A6360, (q31_t)0x28E5714A, (q31_t)0x794A7C11, - (q31_t)0x28B5CCA5, (q31_t)0x795A820E, (q31_t)0x288621B9, - (q31_t)0x796A7554, (q31_t)0x2856708C, (q31_t)0x797A55E0, - (q31_t)0x2826B928, (q31_t)0x798A23B1, (q31_t)0x27F6FB92, - (q31_t)0x7999DEC3, (q31_t)0x27C737D2, (q31_t)0x79A98715, - (q31_t)0x27976DF1, (q31_t)0x79B91CA4, (q31_t)0x27679DF4, - (q31_t)0x79C89F6D, (q31_t)0x2737C7E3, (q31_t)0x79D80F6F, - (q31_t)0x2707EBC6, (q31_t)0x79E76CA6, (q31_t)0x26D809A5, - (q31_t)0x79F6B711, (q31_t)0x26A82185, (q31_t)0x7A05EEAD, - (q31_t)0x26783370, (q31_t)0x7A151377, (q31_t)0x26483F6C, - (q31_t)0x7A24256E, (q31_t)0x26184581, (q31_t)0x7A33248F, - (q31_t)0x25E845B5, (q31_t)0x7A4210D8, (q31_t)0x25B84012, - (q31_t)0x7A50EA46, (q31_t)0x2588349D, (q31_t)0x7A5FB0D8, - (q31_t)0x2558235E, (q31_t)0x7A6E648A, (q31_t)0x25280C5D, - (q31_t)0x7A7D055B, (q31_t)0x24F7EFA1, (q31_t)0x7A8B9348, - (q31_t)0x24C7CD32, (q31_t)0x7A9A0E4F, (q31_t)0x2497A517, - (q31_t)0x7AA8766E, (q31_t)0x24677757, (q31_t)0x7AB6CBA3, - (q31_t)0x243743FA, (q31_t)0x7AC50DEB, (q31_t)0x24070B07, - (q31_t)0x7AD33D45, (q31_t)0x23D6CC86, (q31_t)0x7AE159AE, - (q31_t)0x23A6887E, (q31_t)0x7AEF6323, (q31_t)0x23763EF7, - (q31_t)0x7AFD59A3, (q31_t)0x2345EFF7, (q31_t)0x7B0B3D2C, - (q31_t)0x23159B87, (q31_t)0x7B190DBB, (q31_t)0x22E541AE, - (q31_t)0x7B26CB4F, (q31_t)0x22B4E274, (q31_t)0x7B3475E4, - (q31_t)0x22847DDF, (q31_t)0x7B420D7A, (q31_t)0x225413F8, - (q31_t)0x7B4F920E, (q31_t)0x2223A4C5, (q31_t)0x7B5D039D, - (q31_t)0x21F3304E, (q31_t)0x7B6A6227, (q31_t)0x21C2B69C, - (q31_t)0x7B77ADA8, (q31_t)0x219237B4, (q31_t)0x7B84E61E, - (q31_t)0x2161B39F, (q31_t)0x7B920B89, (q31_t)0x21312A65, - (q31_t)0x7B9F1DE5, (q31_t)0x21009C0B, (q31_t)0x7BAC1D31, - (q31_t)0x20D0089B, (q31_t)0x7BB9096A, (q31_t)0x209F701C, - (q31_t)0x7BC5E28F, (q31_t)0x206ED295, (q31_t)0x7BD2A89E, - (q31_t)0x203E300D, (q31_t)0x7BDF5B94, (q31_t)0x200D888C, - (q31_t)0x7BEBFB70, (q31_t)0x1FDCDC1A, (q31_t)0x7BF88830, - (q31_t)0x1FAC2ABF, (q31_t)0x7C0501D1, (q31_t)0x1F7B7480, - (q31_t)0x7C116853, (q31_t)0x1F4AB967, (q31_t)0x7C1DBBB2, - (q31_t)0x1F19F97B, (q31_t)0x7C29FBEE, (q31_t)0x1EE934C2, - (q31_t)0x7C362904, (q31_t)0x1EB86B46, (q31_t)0x7C4242F2, - (q31_t)0x1E879D0C, (q31_t)0x7C4E49B6, (q31_t)0x1E56CA1E, - (q31_t)0x7C5A3D4F, (q31_t)0x1E25F281, (q31_t)0x7C661DBB, - (q31_t)0x1DF5163F, (q31_t)0x7C71EAF8, (q31_t)0x1DC4355D, - (q31_t)0x7C7DA504, (q31_t)0x1D934FE5, (q31_t)0x7C894BDD, - (q31_t)0x1D6265DD, (q31_t)0x7C94DF82, (q31_t)0x1D31774D, - (q31_t)0x7CA05FF1, (q31_t)0x1D00843C, (q31_t)0x7CABCD27, - (q31_t)0x1CCF8CB3, (q31_t)0x7CB72724, (q31_t)0x1C9E90B8, - (q31_t)0x7CC26DE5, (q31_t)0x1C6D9053, (q31_t)0x7CCDA168, - (q31_t)0x1C3C8B8C, (q31_t)0x7CD8C1AD, (q31_t)0x1C0B826A, - (q31_t)0x7CE3CEB1, (q31_t)0x1BDA74F5, (q31_t)0x7CEEC873, - (q31_t)0x1BA96334, (q31_t)0x7CF9AEF0, (q31_t)0x1B784D30, - (q31_t)0x7D048228, (q31_t)0x1B4732EF, (q31_t)0x7D0F4218, - (q31_t)0x1B161479, (q31_t)0x7D19EEBE, (q31_t)0x1AE4F1D6, - (q31_t)0x7D24881A, (q31_t)0x1AB3CB0C, (q31_t)0x7D2F0E2A, - (q31_t)0x1A82A025, (q31_t)0x7D3980EC, (q31_t)0x1A517127, - (q31_t)0x7D43E05E, (q31_t)0x1A203E1B, (q31_t)0x7D4E2C7E, - (q31_t)0x19EF0706, (q31_t)0x7D58654C, (q31_t)0x19BDCBF2, - (q31_t)0x7D628AC5, (q31_t)0x198C8CE6, (q31_t)0x7D6C9CE9, - (q31_t)0x195B49E9, (q31_t)0x7D769BB5, (q31_t)0x192A0303, - (q31_t)0x7D808727, (q31_t)0x18F8B83C, (q31_t)0x7D8A5F3F, - (q31_t)0x18C7699B, (q31_t)0x7D9423FB, (q31_t)0x18961727, - (q31_t)0x7D9DD55A, (q31_t)0x1864C0E9, (q31_t)0x7DA77359, - (q31_t)0x183366E8, (q31_t)0x7DB0FDF7, (q31_t)0x1802092C, - (q31_t)0x7DBA7534, (q31_t)0x17D0A7BB, (q31_t)0x7DC3D90D, - (q31_t)0x179F429F, (q31_t)0x7DCD2981, (q31_t)0x176DD9DE, - (q31_t)0x7DD6668E, (q31_t)0x173C6D80, (q31_t)0x7DDF9034, - (q31_t)0x170AFD8D, (q31_t)0x7DE8A670, (q31_t)0x16D98A0C, - (q31_t)0x7DF1A942, (q31_t)0x16A81305, (q31_t)0x7DFA98A7, - (q31_t)0x1676987F, (q31_t)0x7E03749F, (q31_t)0x16451A83, - (q31_t)0x7E0C3D29, (q31_t)0x16139917, (q31_t)0x7E14F242, - (q31_t)0x15E21444, (q31_t)0x7E1D93E9, (q31_t)0x15B08C11, - (q31_t)0x7E26221E, (q31_t)0x157F0086, (q31_t)0x7E2E9CDF, - (q31_t)0x154D71AA, (q31_t)0x7E37042A, (q31_t)0x151BDF85, - (q31_t)0x7E3F57FE, (q31_t)0x14EA4A1F, (q31_t)0x7E47985B, - (q31_t)0x14B8B17F, (q31_t)0x7E4FC53E, (q31_t)0x148715AD, - (q31_t)0x7E57DEA6, (q31_t)0x145576B1, (q31_t)0x7E5FE493, - (q31_t)0x1423D492, (q31_t)0x7E67D702, (q31_t)0x13F22F57, - (q31_t)0x7E6FB5F3, (q31_t)0x13C0870A, (q31_t)0x7E778165, - (q31_t)0x138EDBB0, (q31_t)0x7E7F3956, (q31_t)0x135D2D53, - (q31_t)0x7E86DDC5, (q31_t)0x132B7BF9, (q31_t)0x7E8E6EB1, - (q31_t)0x12F9C7AA, (q31_t)0x7E95EC19, (q31_t)0x12C8106E, - (q31_t)0x7E9D55FC, (q31_t)0x1296564D, (q31_t)0x7EA4AC58, - (q31_t)0x1264994E, (q31_t)0x7EABEF2C, (q31_t)0x1232D978, - (q31_t)0x7EB31E77, (q31_t)0x120116D4, (q31_t)0x7EBA3A39, - (q31_t)0x11CF516A, (q31_t)0x7EC1426F, (q31_t)0x119D8940, - (q31_t)0x7EC8371A, (q31_t)0x116BBE5F, (q31_t)0x7ECF1837, - (q31_t)0x1139F0CE, (q31_t)0x7ED5E5C6, (q31_t)0x11082096, - (q31_t)0x7EDC9FC6, (q31_t)0x10D64DBC, (q31_t)0x7EE34635, - (q31_t)0x10A4784A, (q31_t)0x7EE9D913, (q31_t)0x1072A047, - (q31_t)0x7EF0585F, (q31_t)0x1040C5BB, (q31_t)0x7EF6C418, - (q31_t)0x100EE8AD, (q31_t)0x7EFD1C3C, (q31_t)0x0FDD0925, - (q31_t)0x7F0360CB, (q31_t)0x0FAB272B, (q31_t)0x7F0991C3, - (q31_t)0x0F7942C6, (q31_t)0x7F0FAF24, (q31_t)0x0F475BFE, - (q31_t)0x7F15B8EE, (q31_t)0x0F1572DC, (q31_t)0x7F1BAF1E, - (q31_t)0x0EE38765, (q31_t)0x7F2191B4, (q31_t)0x0EB199A3, - (q31_t)0x7F2760AF, (q31_t)0x0E7FA99D, (q31_t)0x7F2D1C0E, - (q31_t)0x0E4DB75B, (q31_t)0x7F32C3D0, (q31_t)0x0E1BC2E3, - (q31_t)0x7F3857F5, (q31_t)0x0DE9CC3F, (q31_t)0x7F3DD87C, - (q31_t)0x0DB7D376, (q31_t)0x7F434563, (q31_t)0x0D85D88F, - (q31_t)0x7F489EAA, (q31_t)0x0D53DB92, (q31_t)0x7F4DE450, - (q31_t)0x0D21DC87, (q31_t)0x7F531654, (q31_t)0x0CEFDB75, - (q31_t)0x7F5834B6, (q31_t)0x0CBDD865, (q31_t)0x7F5D3F75, - (q31_t)0x0C8BD35E, (q31_t)0x7F62368F, (q31_t)0x0C59CC67, - (q31_t)0x7F671A04, (q31_t)0x0C27C389, (q31_t)0x7F6BE9D4, - (q31_t)0x0BF5B8CB, (q31_t)0x7F70A5FD, (q31_t)0x0BC3AC35, - (q31_t)0x7F754E7F, (q31_t)0x0B919DCE, (q31_t)0x7F79E35A, - (q31_t)0x0B5F8D9F, (q31_t)0x7F7E648B, (q31_t)0x0B2D7BAE, - (q31_t)0x7F82D214, (q31_t)0x0AFB6805, (q31_t)0x7F872BF3, - (q31_t)0x0AC952AA, (q31_t)0x7F8B7226, (q31_t)0x0A973BA5, - (q31_t)0x7F8FA4AF, (q31_t)0x0A6522FE, (q31_t)0x7F93C38C, - (q31_t)0x0A3308BC, (q31_t)0x7F97CEBC, (q31_t)0x0A00ECE8, - (q31_t)0x7F9BC63F, (q31_t)0x09CECF89, (q31_t)0x7F9FAA15, - (q31_t)0x099CB0A7, (q31_t)0x7FA37A3C, (q31_t)0x096A9049, - (q31_t)0x7FA736B4, (q31_t)0x09386E77, (q31_t)0x7FAADF7C, - (q31_t)0x09064B3A, (q31_t)0x7FAE7494, (q31_t)0x08D42698, - (q31_t)0x7FB1F5FC, (q31_t)0x08A2009A, (q31_t)0x7FB563B2, - (q31_t)0x086FD947, (q31_t)0x7FB8BDB7, (q31_t)0x083DB0A7, - (q31_t)0x7FBC040A, (q31_t)0x080B86C1, (q31_t)0x7FBF36A9, - (q31_t)0x07D95B9E, (q31_t)0x7FC25596, (q31_t)0x07A72F45, - (q31_t)0x7FC560CF, (q31_t)0x077501BE, (q31_t)0x7FC85853, - (q31_t)0x0742D310, (q31_t)0x7FCB3C23, (q31_t)0x0710A344, - (q31_t)0x7FCE0C3E, (q31_t)0x06DE7261, (q31_t)0x7FD0C8A3, - (q31_t)0x06AC406F, (q31_t)0x7FD37152, (q31_t)0x067A0D75, - (q31_t)0x7FD6064B, (q31_t)0x0647D97C, (q31_t)0x7FD8878D, - (q31_t)0x0615A48A, (q31_t)0x7FDAF518, (q31_t)0x05E36EA9, - (q31_t)0x7FDD4EEC, (q31_t)0x05B137DF, (q31_t)0x7FDF9508, - (q31_t)0x057F0034, (q31_t)0x7FE1C76B, (q31_t)0x054CC7B0, - (q31_t)0x7FE3E616, (q31_t)0x051A8E5C, (q31_t)0x7FE5F108, - (q31_t)0x04E8543D, (q31_t)0x7FE7E840, (q31_t)0x04B6195D, - (q31_t)0x7FE9CBC0, (q31_t)0x0483DDC3, (q31_t)0x7FEB9B85, - (q31_t)0x0451A176, (q31_t)0x7FED5790, (q31_t)0x041F647F, - (q31_t)0x7FEEFFE1, (q31_t)0x03ED26E6, (q31_t)0x7FF09477, - (q31_t)0x03BAE8B1, (q31_t)0x7FF21553, (q31_t)0x0388A9E9, - (q31_t)0x7FF38273, (q31_t)0x03566A96, (q31_t)0x7FF4DBD8, - (q31_t)0x03242ABF, (q31_t)0x7FF62182, (q31_t)0x02F1EA6B, - (q31_t)0x7FF7536F, (q31_t)0x02BFA9A4, (q31_t)0x7FF871A1, - (q31_t)0x028D6870, (q31_t)0x7FF97C17, (q31_t)0x025B26D7, - (q31_t)0x7FFA72D1, (q31_t)0x0228E4E1, (q31_t)0x7FFB55CE, - (q31_t)0x01F6A296, (q31_t)0x7FFC250F, (q31_t)0x01C45FFE, - (q31_t)0x7FFCE093, (q31_t)0x01921D1F, (q31_t)0x7FFD885A, - (q31_t)0x015FDA03, (q31_t)0x7FFE1C64, (q31_t)0x012D96B0, - (q31_t)0x7FFE9CB2, (q31_t)0x00FB532F, (q31_t)0x7FFF0942, - (q31_t)0x00C90F88, (q31_t)0x7FFF6216, (q31_t)0x0096CBC1, - (q31_t)0x7FFFA72C, (q31_t)0x006487E3, (q31_t)0x7FFFD885, - (q31_t)0x003243F5, (q31_t)0x7FFFF621, (q31_t)0x00000000, - (q31_t)0x7FFFFFFF, (q31_t)0xFFCDBC0A, (q31_t)0x7FFFF621, - (q31_t)0xFF9B781D, (q31_t)0x7FFFD885, (q31_t)0xFF69343E, - (q31_t)0x7FFFA72C, (q31_t)0xFF36F078, (q31_t)0x7FFF6216, - (q31_t)0xFF04ACD0, (q31_t)0x7FFF0942, (q31_t)0xFED2694F, - (q31_t)0x7FFE9CB2, (q31_t)0xFEA025FC, (q31_t)0x7FFE1C64, - (q31_t)0xFE6DE2E0, (q31_t)0x7FFD885A, (q31_t)0xFE3BA001, - (q31_t)0x7FFCE093, (q31_t)0xFE095D69, (q31_t)0x7FFC250F, - (q31_t)0xFDD71B1E, (q31_t)0x7FFB55CE, (q31_t)0xFDA4D928, - (q31_t)0x7FFA72D1, (q31_t)0xFD72978F, (q31_t)0x7FF97C17, - (q31_t)0xFD40565B, (q31_t)0x7FF871A1, (q31_t)0xFD0E1594, - (q31_t)0x7FF7536F, (q31_t)0xFCDBD541, (q31_t)0x7FF62182, - (q31_t)0xFCA99569, (q31_t)0x7FF4DBD8, (q31_t)0xFC775616, - (q31_t)0x7FF38273, (q31_t)0xFC45174E, (q31_t)0x7FF21553, - (q31_t)0xFC12D919, (q31_t)0x7FF09477, (q31_t)0xFBE09B80, - (q31_t)0x7FEEFFE1, (q31_t)0xFBAE5E89, (q31_t)0x7FED5790, - (q31_t)0xFB7C223C, (q31_t)0x7FEB9B85, (q31_t)0xFB49E6A2, - (q31_t)0x7FE9CBC0, (q31_t)0xFB17ABC2, (q31_t)0x7FE7E840, - (q31_t)0xFAE571A4, (q31_t)0x7FE5F108, (q31_t)0xFAB3384F, - (q31_t)0x7FE3E616, (q31_t)0xFA80FFCB, (q31_t)0x7FE1C76B, - (q31_t)0xFA4EC820, (q31_t)0x7FDF9508, (q31_t)0xFA1C9156, - (q31_t)0x7FDD4EEC, (q31_t)0xF9EA5B75, (q31_t)0x7FDAF518, - (q31_t)0xF9B82683, (q31_t)0x7FD8878D, (q31_t)0xF985F28A, - (q31_t)0x7FD6064B, (q31_t)0xF953BF90, (q31_t)0x7FD37152, - (q31_t)0xF9218D9E, (q31_t)0x7FD0C8A3, (q31_t)0xF8EF5CBB, - (q31_t)0x7FCE0C3E, (q31_t)0xF8BD2CEF, (q31_t)0x7FCB3C23, - (q31_t)0xF88AFE41, (q31_t)0x7FC85853, (q31_t)0xF858D0BA, - (q31_t)0x7FC560CF, (q31_t)0xF826A461, (q31_t)0x7FC25596, - (q31_t)0xF7F4793E, (q31_t)0x7FBF36A9, (q31_t)0xF7C24F58, - (q31_t)0x7FBC040A, (q31_t)0xF79026B8, (q31_t)0x7FB8BDB7, - (q31_t)0xF75DFF65, (q31_t)0x7FB563B2, (q31_t)0xF72BD967, - (q31_t)0x7FB1F5FC, (q31_t)0xF6F9B4C5, (q31_t)0x7FAE7494, - (q31_t)0xF6C79188, (q31_t)0x7FAADF7C, (q31_t)0xF6956FB6, - (q31_t)0x7FA736B4, (q31_t)0xF6634F58, (q31_t)0x7FA37A3C, - (q31_t)0xF6313076, (q31_t)0x7F9FAA15, (q31_t)0xF5FF1317, - (q31_t)0x7F9BC63F, (q31_t)0xF5CCF743, (q31_t)0x7F97CEBC, - (q31_t)0xF59ADD01, (q31_t)0x7F93C38C, (q31_t)0xF568C45A, - (q31_t)0x7F8FA4AF, (q31_t)0xF536AD55, (q31_t)0x7F8B7226, - (q31_t)0xF50497FA, (q31_t)0x7F872BF3, (q31_t)0xF4D28451, - (q31_t)0x7F82D214, (q31_t)0xF4A07260, (q31_t)0x7F7E648B, - (q31_t)0xF46E6231, (q31_t)0x7F79E35A, (q31_t)0xF43C53CA, - (q31_t)0x7F754E7F, (q31_t)0xF40A4734, (q31_t)0x7F70A5FD, - (q31_t)0xF3D83C76, (q31_t)0x7F6BE9D4, (q31_t)0xF3A63398, - (q31_t)0x7F671A04, (q31_t)0xF3742CA1, (q31_t)0x7F62368F, - (q31_t)0xF342279A, (q31_t)0x7F5D3F75, (q31_t)0xF310248A, - (q31_t)0x7F5834B6, (q31_t)0xF2DE2378, (q31_t)0x7F531654, - (q31_t)0xF2AC246D, (q31_t)0x7F4DE450, (q31_t)0xF27A2770, - (q31_t)0x7F489EAA, (q31_t)0xF2482C89, (q31_t)0x7F434563, - (q31_t)0xF21633C0, (q31_t)0x7F3DD87C, (q31_t)0xF1E43D1C, - (q31_t)0x7F3857F5, (q31_t)0xF1B248A5, (q31_t)0x7F32C3D0, - (q31_t)0xF1805662, (q31_t)0x7F2D1C0E, (q31_t)0xF14E665C, - (q31_t)0x7F2760AF, (q31_t)0xF11C789A, (q31_t)0x7F2191B4, - (q31_t)0xF0EA8D23, (q31_t)0x7F1BAF1E, (q31_t)0xF0B8A401, - (q31_t)0x7F15B8EE, (q31_t)0xF086BD39, (q31_t)0x7F0FAF24, - (q31_t)0xF054D8D4, (q31_t)0x7F0991C3, (q31_t)0xF022F6DA, - (q31_t)0x7F0360CB, (q31_t)0xEFF11752, (q31_t)0x7EFD1C3C, - (q31_t)0xEFBF3A44, (q31_t)0x7EF6C418, (q31_t)0xEF8D5FB8, - (q31_t)0x7EF0585F, (q31_t)0xEF5B87B5, (q31_t)0x7EE9D913, - (q31_t)0xEF29B243, (q31_t)0x7EE34635, (q31_t)0xEEF7DF6A, - (q31_t)0x7EDC9FC6, (q31_t)0xEEC60F31, (q31_t)0x7ED5E5C6, - (q31_t)0xEE9441A0, (q31_t)0x7ECF1837, (q31_t)0xEE6276BF, - (q31_t)0x7EC8371A, (q31_t)0xEE30AE95, (q31_t)0x7EC1426F, - (q31_t)0xEDFEE92B, (q31_t)0x7EBA3A39, (q31_t)0xEDCD2687, - (q31_t)0x7EB31E77, (q31_t)0xED9B66B2, (q31_t)0x7EABEF2C, - (q31_t)0xED69A9B2, (q31_t)0x7EA4AC58, (q31_t)0xED37EF91, - (q31_t)0x7E9D55FC, (q31_t)0xED063855, (q31_t)0x7E95EC19, - (q31_t)0xECD48406, (q31_t)0x7E8E6EB1, (q31_t)0xECA2D2AC, - (q31_t)0x7E86DDC5, (q31_t)0xEC71244F, (q31_t)0x7E7F3956, - (q31_t)0xEC3F78F5, (q31_t)0x7E778165, (q31_t)0xEC0DD0A8, - (q31_t)0x7E6FB5F3, (q31_t)0xEBDC2B6D, (q31_t)0x7E67D702, - (q31_t)0xEBAA894E, (q31_t)0x7E5FE493, (q31_t)0xEB78EA52, - (q31_t)0x7E57DEA6, (q31_t)0xEB474E80, (q31_t)0x7E4FC53E, - (q31_t)0xEB15B5E0, (q31_t)0x7E47985B, (q31_t)0xEAE4207A, - (q31_t)0x7E3F57FE, (q31_t)0xEAB28E55, (q31_t)0x7E37042A, - (q31_t)0xEA80FF79, (q31_t)0x7E2E9CDF, (q31_t)0xEA4F73EE, - (q31_t)0x7E26221E, (q31_t)0xEA1DEBBB, (q31_t)0x7E1D93E9, - (q31_t)0xE9EC66E8, (q31_t)0x7E14F242, (q31_t)0xE9BAE57C, - (q31_t)0x7E0C3D29, (q31_t)0xE9896780, (q31_t)0x7E03749F, - (q31_t)0xE957ECFB, (q31_t)0x7DFA98A7, (q31_t)0xE92675F4, - (q31_t)0x7DF1A942, (q31_t)0xE8F50273, (q31_t)0x7DE8A670, - (q31_t)0xE8C3927F, (q31_t)0x7DDF9034, (q31_t)0xE8922621, - (q31_t)0x7DD6668E, (q31_t)0xE860BD60, (q31_t)0x7DCD2981, - (q31_t)0xE82F5844, (q31_t)0x7DC3D90D, (q31_t)0xE7FDF6D3, - (q31_t)0x7DBA7534, (q31_t)0xE7CC9917, (q31_t)0x7DB0FDF7, - (q31_t)0xE79B3F16, (q31_t)0x7DA77359, (q31_t)0xE769E8D8, - (q31_t)0x7D9DD55A, (q31_t)0xE7389664, (q31_t)0x7D9423FB, - (q31_t)0xE70747C3, (q31_t)0x7D8A5F3F, (q31_t)0xE6D5FCFC, - (q31_t)0x7D808727, (q31_t)0xE6A4B616, (q31_t)0x7D769BB5, - (q31_t)0xE6737319, (q31_t)0x7D6C9CE9, (q31_t)0xE642340D, - (q31_t)0x7D628AC5, (q31_t)0xE610F8F9, (q31_t)0x7D58654C, - (q31_t)0xE5DFC1E4, (q31_t)0x7D4E2C7E, (q31_t)0xE5AE8ED8, - (q31_t)0x7D43E05E, (q31_t)0xE57D5FDA, (q31_t)0x7D3980EC, - (q31_t)0xE54C34F3, (q31_t)0x7D2F0E2A, (q31_t)0xE51B0E2A, - (q31_t)0x7D24881A, (q31_t)0xE4E9EB86, (q31_t)0x7D19EEBE, - (q31_t)0xE4B8CD10, (q31_t)0x7D0F4218, (q31_t)0xE487B2CF, - (q31_t)0x7D048228, (q31_t)0xE4569CCB, (q31_t)0x7CF9AEF0, - (q31_t)0xE4258B0A, (q31_t)0x7CEEC873, (q31_t)0xE3F47D95, - (q31_t)0x7CE3CEB1, (q31_t)0xE3C37473, (q31_t)0x7CD8C1AD, - (q31_t)0xE3926FAC, (q31_t)0x7CCDA168, (q31_t)0xE3616F47, - (q31_t)0x7CC26DE5, (q31_t)0xE330734C, (q31_t)0x7CB72724, - (q31_t)0xE2FF7BC3, (q31_t)0x7CABCD27, (q31_t)0xE2CE88B2, - (q31_t)0x7CA05FF1, (q31_t)0xE29D9A22, (q31_t)0x7C94DF82, - (q31_t)0xE26CB01A, (q31_t)0x7C894BDD, (q31_t)0xE23BCAA2, - (q31_t)0x7C7DA504, (q31_t)0xE20AE9C1, (q31_t)0x7C71EAF8, - (q31_t)0xE1DA0D7E, (q31_t)0x7C661DBB, (q31_t)0xE1A935E1, - (q31_t)0x7C5A3D4F, (q31_t)0xE17862F3, (q31_t)0x7C4E49B6, - (q31_t)0xE14794B9, (q31_t)0x7C4242F2, (q31_t)0xE116CB3D, - (q31_t)0x7C362904, (q31_t)0xE0E60684, (q31_t)0x7C29FBEE, - (q31_t)0xE0B54698, (q31_t)0x7C1DBBB2, (q31_t)0xE0848B7F, - (q31_t)0x7C116853, (q31_t)0xE053D541, (q31_t)0x7C0501D1, - (q31_t)0xE02323E5, (q31_t)0x7BF88830, (q31_t)0xDFF27773, - (q31_t)0x7BEBFB70, (q31_t)0xDFC1CFF2, (q31_t)0x7BDF5B94, - (q31_t)0xDF912D6A, (q31_t)0x7BD2A89E, (q31_t)0xDF608FE3, - (q31_t)0x7BC5E28F, (q31_t)0xDF2FF764, (q31_t)0x7BB9096A, - (q31_t)0xDEFF63F4, (q31_t)0x7BAC1D31, (q31_t)0xDECED59B, - (q31_t)0x7B9F1DE5, (q31_t)0xDE9E4C60, (q31_t)0x7B920B89, - (q31_t)0xDE6DC84B, (q31_t)0x7B84E61E, (q31_t)0xDE3D4963, - (q31_t)0x7B77ADA8, (q31_t)0xDE0CCFB1, (q31_t)0x7B6A6227, - (q31_t)0xDDDC5B3A, (q31_t)0x7B5D039D, (q31_t)0xDDABEC07, - (q31_t)0x7B4F920E, (q31_t)0xDD7B8220, (q31_t)0x7B420D7A, - (q31_t)0xDD4B1D8B, (q31_t)0x7B3475E4, (q31_t)0xDD1ABE51, - (q31_t)0x7B26CB4F, (q31_t)0xDCEA6478, (q31_t)0x7B190DBB, - (q31_t)0xDCBA1008, (q31_t)0x7B0B3D2C, (q31_t)0xDC89C108, - (q31_t)0x7AFD59A3, (q31_t)0xDC597781, (q31_t)0x7AEF6323, - (q31_t)0xDC293379, (q31_t)0x7AE159AE, (q31_t)0xDBF8F4F8, - (q31_t)0x7AD33D45, (q31_t)0xDBC8BC05, (q31_t)0x7AC50DEB, - (q31_t)0xDB9888A8, (q31_t)0x7AB6CBA3, (q31_t)0xDB685AE8, - (q31_t)0x7AA8766E, (q31_t)0xDB3832CD, (q31_t)0x7A9A0E4F, - (q31_t)0xDB08105E, (q31_t)0x7A8B9348, (q31_t)0xDAD7F3A2, - (q31_t)0x7A7D055B, (q31_t)0xDAA7DCA1, (q31_t)0x7A6E648A, - (q31_t)0xDA77CB62, (q31_t)0x7A5FB0D8, (q31_t)0xDA47BFED, - (q31_t)0x7A50EA46, (q31_t)0xDA17BA4A, (q31_t)0x7A4210D8, - (q31_t)0xD9E7BA7E, (q31_t)0x7A33248F, (q31_t)0xD9B7C093, - (q31_t)0x7A24256E, (q31_t)0xD987CC8F, (q31_t)0x7A151377, - (q31_t)0xD957DE7A, (q31_t)0x7A05EEAD, (q31_t)0xD927F65B, - (q31_t)0x79F6B711, (q31_t)0xD8F81439, (q31_t)0x79E76CA6, - (q31_t)0xD8C8381C, (q31_t)0x79D80F6F, (q31_t)0xD898620C, - (q31_t)0x79C89F6D, (q31_t)0xD868920F, (q31_t)0x79B91CA4, - (q31_t)0xD838C82D, (q31_t)0x79A98715, (q31_t)0xD809046D, - (q31_t)0x7999DEC3, (q31_t)0xD7D946D7, (q31_t)0x798A23B1, - (q31_t)0xD7A98F73, (q31_t)0x797A55E0, (q31_t)0xD779DE46, - (q31_t)0x796A7554, (q31_t)0xD74A335A, (q31_t)0x795A820E, - (q31_t)0xD71A8EB5, (q31_t)0x794A7C11, (q31_t)0xD6EAF05E, - (q31_t)0x793A6360, (q31_t)0xD6BB585D, (q31_t)0x792A37FE, - (q31_t)0xD68BC6BA, (q31_t)0x7919F9EB, (q31_t)0xD65C3B7B, - (q31_t)0x7909A92C, (q31_t)0xD62CB6A7, (q31_t)0x78F945C3, - (q31_t)0xD5FD3847, (q31_t)0x78E8CFB1, (q31_t)0xD5CDC062, - (q31_t)0x78D846FB, (q31_t)0xD59E4EFE, (q31_t)0x78C7ABA1, - (q31_t)0xD56EE424, (q31_t)0x78B6FDA8, (q31_t)0xD53F7FDA, - (q31_t)0x78A63D10, (q31_t)0xD5102227, (q31_t)0x789569DE, - (q31_t)0xD4E0CB14, (q31_t)0x78848413, (q31_t)0xD4B17AA7, - (q31_t)0x78738BB3, (q31_t)0xD48230E8, (q31_t)0x786280BF, - (q31_t)0xD452EDDE, (q31_t)0x7851633B, (q31_t)0xD423B190, - (q31_t)0x78403328, (q31_t)0xD3F47C06, (q31_t)0x782EF08B, - (q31_t)0xD3C54D46, (q31_t)0x781D9B64, (q31_t)0xD3962559, - (q31_t)0x780C33B8, (q31_t)0xD3670445, (q31_t)0x77FAB988, - (q31_t)0xD337EA12, (q31_t)0x77E92CD8, (q31_t)0xD308D6C6, - (q31_t)0x77D78DAA, (q31_t)0xD2D9CA6A, (q31_t)0x77C5DC01, - (q31_t)0xD2AAC504, (q31_t)0x77B417DF, (q31_t)0xD27BC69C, - (q31_t)0x77A24148, (q31_t)0xD24CCF38, (q31_t)0x7790583D, - (q31_t)0xD21DDEE1, (q31_t)0x777E5CC3, (q31_t)0xD1EEF59E, - (q31_t)0x776C4EDB, (q31_t)0xD1C01374, (q31_t)0x775A2E88, - (q31_t)0xD191386D, (q31_t)0x7747FBCE, (q31_t)0xD162648F, - (q31_t)0x7735B6AE, (q31_t)0xD13397E1, (q31_t)0x77235F2D, - (q31_t)0xD104D26B, (q31_t)0x7710F54B, (q31_t)0xD0D61433, - (q31_t)0x76FE790E, (q31_t)0xD0A75D42, (q31_t)0x76EBEA77, - (q31_t)0xD078AD9D, (q31_t)0x76D94988, (q31_t)0xD04A054D, - (q31_t)0x76C69646, (q31_t)0xD01B6459, (q31_t)0x76B3D0B3, - (q31_t)0xCFECCAC7, (q31_t)0x76A0F8D2, (q31_t)0xCFBE389F, - (q31_t)0x768E0EA5, (q31_t)0xCF8FADE8, (q31_t)0x767B1230, - (q31_t)0xCF612AAA, (q31_t)0x76680376, (q31_t)0xCF32AEEB, - (q31_t)0x7654E279, (q31_t)0xCF043AB2, (q31_t)0x7641AF3C, - (q31_t)0xCED5CE08, (q31_t)0x762E69C3, (q31_t)0xCEA768F2, - (q31_t)0x761B1211, (q31_t)0xCE790B78, (q31_t)0x7607A827, - (q31_t)0xCE4AB5A2, (q31_t)0x75F42C0A, (q31_t)0xCE1C6776, - (q31_t)0x75E09DBD, (q31_t)0xCDEE20FC, (q31_t)0x75CCFD42, - (q31_t)0xCDBFE23A, (q31_t)0x75B94A9C, (q31_t)0xCD91AB38, - (q31_t)0x75A585CF, (q31_t)0xCD637BFD, (q31_t)0x7591AEDD, - (q31_t)0xCD355490, (q31_t)0x757DC5CA, (q31_t)0xCD0734F8, - (q31_t)0x7569CA98, (q31_t)0xCCD91D3D, (q31_t)0x7555BD4B, - (q31_t)0xCCAB0D65, (q31_t)0x75419DE6, (q31_t)0xCC7D0577, - (q31_t)0x752D6C6C, (q31_t)0xCC4F057B, (q31_t)0x751928E0, - (q31_t)0xCC210D78, (q31_t)0x7504D345, (q31_t)0xCBF31D75, - (q31_t)0x74F06B9E, (q31_t)0xCBC53578, (q31_t)0x74DBF1EF, - (q31_t)0xCB975589, (q31_t)0x74C7663A, (q31_t)0xCB697DB0, - (q31_t)0x74B2C883, (q31_t)0xCB3BADF2, (q31_t)0x749E18CD, - (q31_t)0xCB0DE658, (q31_t)0x7489571B, (q31_t)0xCAE026E8, - (q31_t)0x74748371, (q31_t)0xCAB26FA9, (q31_t)0x745F9DD1, - (q31_t)0xCA84C0A2, (q31_t)0x744AA63E, (q31_t)0xCA5719DB, - (q31_t)0x74359CBD, (q31_t)0xCA297B5A, (q31_t)0x74208150, - (q31_t)0xC9FBE527, (q31_t)0x740B53FA, (q31_t)0xC9CE5748, - (q31_t)0x73F614C0, (q31_t)0xC9A0D1C4, (q31_t)0x73E0C3A3, - (q31_t)0xC97354A3, (q31_t)0x73CB60A7, (q31_t)0xC945DFEC, - (q31_t)0x73B5EBD0, (q31_t)0xC91873A5, (q31_t)0x73A06522, - (q31_t)0xC8EB0FD6, (q31_t)0x738ACC9E, (q31_t)0xC8BDB485, - (q31_t)0x73752249, (q31_t)0xC89061BA, (q31_t)0x735F6626, - (q31_t)0xC863177B, (q31_t)0x73499838, (q31_t)0xC835D5D0, - (q31_t)0x7333B883, (q31_t)0xC8089CBF, (q31_t)0x731DC709, - (q31_t)0xC7DB6C50, (q31_t)0x7307C3D0, (q31_t)0xC7AE4489, - (q31_t)0x72F1AED8, (q31_t)0xC7812571, (q31_t)0x72DB8828, - (q31_t)0xC7540F10, (q31_t)0x72C54FC0, (q31_t)0xC727016C, - (q31_t)0x72AF05A6, (q31_t)0xC6F9FC8D, (q31_t)0x7298A9DC, - (q31_t)0xC6CD0079, (q31_t)0x72823C66, (q31_t)0xC6A00D36, - (q31_t)0x726BBD48, (q31_t)0xC67322CD, (q31_t)0x72552C84, - (q31_t)0xC6464144, (q31_t)0x723E8A1F, (q31_t)0xC61968A2, - (q31_t)0x7227D61C, (q31_t)0xC5EC98ED, (q31_t)0x7211107D, - (q31_t)0xC5BFD22E, (q31_t)0x71FA3948, (q31_t)0xC593146A, - (q31_t)0x71E3507F, (q31_t)0xC5665FA8, (q31_t)0x71CC5626, - (q31_t)0xC539B3F0, (q31_t)0x71B54A40, (q31_t)0xC50D1148, - (q31_t)0x719E2CD2, (q31_t)0xC4E077B8, (q31_t)0x7186FDDE, - (q31_t)0xC4B3E746, (q31_t)0x716FBD68, (q31_t)0xC4875FF8, - (q31_t)0x71586B73, (q31_t)0xC45AE1D7, (q31_t)0x71410804, - (q31_t)0xC42E6CE8, (q31_t)0x7129931E, (q31_t)0xC4020132, - (q31_t)0x71120CC5, (q31_t)0xC3D59EBD, (q31_t)0x70FA74FB, - (q31_t)0xC3A9458F, (q31_t)0x70E2CBC6, (q31_t)0xC37CF5B0, - (q31_t)0x70CB1127, (q31_t)0xC350AF25, (q31_t)0x70B34524, - (q31_t)0xC32471F6, (q31_t)0x709B67C0, (q31_t)0xC2F83E2A, - (q31_t)0x708378FE, (q31_t)0xC2CC13C7, (q31_t)0x706B78E3, - (q31_t)0xC29FF2D4, (q31_t)0x70536771, (q31_t)0xC273DB58, - (q31_t)0x703B44AC, (q31_t)0xC247CD5A, (q31_t)0x70231099, - (q31_t)0xC21BC8E0, (q31_t)0x700ACB3B, (q31_t)0xC1EFCDF2, - (q31_t)0x6FF27496, (q31_t)0xC1C3DC96, (q31_t)0x6FDA0CAD, - (q31_t)0xC197F4D3, (q31_t)0x6FC19385, (q31_t)0xC16C16B0, - (q31_t)0x6FA90920, (q31_t)0xC1404233, (q31_t)0x6F906D84, - (q31_t)0xC1147763, (q31_t)0x6F77C0B3, (q31_t)0xC0E8B648, - (q31_t)0x6F5F02B1, (q31_t)0xC0BCFEE7, (q31_t)0x6F463383, - (q31_t)0xC0915147, (q31_t)0x6F2D532C, (q31_t)0xC065AD70, - (q31_t)0x6F1461AF, (q31_t)0xC03A1368, (q31_t)0x6EFB5F12, - (q31_t)0xC00E8335, (q31_t)0x6EE24B57, (q31_t)0xBFE2FCDF, - (q31_t)0x6EC92682, (q31_t)0xBFB7806C, (q31_t)0x6EAFF098, - (q31_t)0xBF8C0DE2, (q31_t)0x6E96A99C, (q31_t)0xBF60A54A, - (q31_t)0x6E7D5193, (q31_t)0xBF3546A8, (q31_t)0x6E63E87F, - (q31_t)0xBF09F204, (q31_t)0x6E4A6E65, (q31_t)0xBEDEA765, - (q31_t)0x6E30E349, (q31_t)0xBEB366D1, (q31_t)0x6E17472F, - (q31_t)0xBE88304F, (q31_t)0x6DFD9A1B, (q31_t)0xBE5D03E5, - (q31_t)0x6DE3DC11, (q31_t)0xBE31E19B, (q31_t)0x6DCA0D14, - (q31_t)0xBE06C977, (q31_t)0x6DB02D29, (q31_t)0xBDDBBB7F, - (q31_t)0x6D963C54, (q31_t)0xBDB0B7BA, (q31_t)0x6D7C3A98, - (q31_t)0xBD85BE2F, (q31_t)0x6D6227FA, (q31_t)0xBD5ACEE5, - (q31_t)0x6D48047E, (q31_t)0xBD2FE9E1, (q31_t)0x6D2DD027, - (q31_t)0xBD050F2C, (q31_t)0x6D138AFA, (q31_t)0xBCDA3ECA, - (q31_t)0x6CF934FB, (q31_t)0xBCAF78C3, (q31_t)0x6CDECE2E, - (q31_t)0xBC84BD1E, (q31_t)0x6CC45697, (q31_t)0xBC5A0BE1, - (q31_t)0x6CA9CE3A, (q31_t)0xBC2F6513, (q31_t)0x6C8F351C, - (q31_t)0xBC04C8BA, (q31_t)0x6C748B3F, (q31_t)0xBBDA36DC, - (q31_t)0x6C59D0A9, (q31_t)0xBBAFAF81, (q31_t)0x6C3F055D, - (q31_t)0xBB8532AF, (q31_t)0x6C242960, (q31_t)0xBB5AC06C, - (q31_t)0x6C093CB6, (q31_t)0xBB3058C0, (q31_t)0x6BEE3F62, - (q31_t)0xBB05FBB0, (q31_t)0x6BD3316A, (q31_t)0xBADBA943, - (q31_t)0x6BB812D0, (q31_t)0xBAB1617F, (q31_t)0x6B9CE39B, - (q31_t)0xBA87246C, (q31_t)0x6B81A3CD, (q31_t)0xBA5CF210, - (q31_t)0x6B66536A, (q31_t)0xBA32CA70, (q31_t)0x6B4AF278, - (q31_t)0xBA08AD94, (q31_t)0x6B2F80FA, (q31_t)0xB9DE9B83, - (q31_t)0x6B13FEF5, (q31_t)0xB9B49442, (q31_t)0x6AF86C6C, - (q31_t)0xB98A97D8, (q31_t)0x6ADCC964, (q31_t)0xB960A64B, - (q31_t)0x6AC115E1, (q31_t)0xB936BFA3, (q31_t)0x6AA551E8, - (q31_t)0xB90CE3E6, (q31_t)0x6A897D7D, (q31_t)0xB8E31319, - (q31_t)0x6A6D98A4, (q31_t)0xB8B94D44, (q31_t)0x6A51A361, - (q31_t)0xB88F926C, (q31_t)0x6A359DB9, (q31_t)0xB865E299, - (q31_t)0x6A1987B0, (q31_t)0xB83C3DD1, (q31_t)0x69FD614A, - (q31_t)0xB812A419, (q31_t)0x69E12A8C, (q31_t)0xB7E9157A, - (q31_t)0x69C4E37A, (q31_t)0xB7BF91F8, (q31_t)0x69A88C18, - (q31_t)0xB796199B, (q31_t)0x698C246C, (q31_t)0xB76CAC68, - (q31_t)0x696FAC78, (q31_t)0xB7434A67, (q31_t)0x69532442, - (q31_t)0xB719F39D, (q31_t)0x69368BCE, (q31_t)0xB6F0A811, - (q31_t)0x6919E320, (q31_t)0xB6C767CA, (q31_t)0x68FD2A3D, - (q31_t)0xB69E32CD, (q31_t)0x68E06129, (q31_t)0xB6750921, - (q31_t)0x68C387E9, (q31_t)0xB64BEACC, (q31_t)0x68A69E81, - (q31_t)0xB622D7D5, (q31_t)0x6889A4F5, (q31_t)0xB5F9D042, - (q31_t)0x686C9B4B, (q31_t)0xB5D0D41A, (q31_t)0x684F8186, - (q31_t)0xB5A7E362, (q31_t)0x683257AA, (q31_t)0xB57EFE21, - (q31_t)0x68151DBE, (q31_t)0xB556245E, (q31_t)0x67F7D3C4, - (q31_t)0xB52D561E, (q31_t)0x67DA79C2, (q31_t)0xB5049368, - (q31_t)0x67BD0FBC, (q31_t)0xB4DBDC42, (q31_t)0x679F95B7, - (q31_t)0xB4B330B2, (q31_t)0x67820BB6, (q31_t)0xB48A90C0, - (q31_t)0x676471C0, (q31_t)0xB461FC70, (q31_t)0x6746C7D7, - (q31_t)0xB43973C9, (q31_t)0x67290E02, (q31_t)0xB410F6D2, - (q31_t)0x670B4443, (q31_t)0xB3E88591, (q31_t)0x66ED6AA1, - (q31_t)0xB3C0200C, (q31_t)0x66CF811F, (q31_t)0xB397C649, - (q31_t)0x66B187C3, (q31_t)0xB36F784E, (q31_t)0x66937E90, - (q31_t)0xB3473622, (q31_t)0x6675658C, (q31_t)0xB31EFFCB, - (q31_t)0x66573CBB, (q31_t)0xB2F6D54F, (q31_t)0x66390422, - (q31_t)0xB2CEB6B5, (q31_t)0x661ABBC5, (q31_t)0xB2A6A401, - (q31_t)0x65FC63A9, (q31_t)0xB27E9D3B, (q31_t)0x65DDFBD3, - (q31_t)0xB256A26A, (q31_t)0x65BF8447, (q31_t)0xB22EB392, - (q31_t)0x65A0FD0B, (q31_t)0xB206D0BA, (q31_t)0x65826622, - (q31_t)0xB1DEF9E8, (q31_t)0x6563BF92, (q31_t)0xB1B72F23, - (q31_t)0x6545095F, (q31_t)0xB18F7070, (q31_t)0x6526438E, - (q31_t)0xB167BDD6, (q31_t)0x65076E24, (q31_t)0xB140175B, - (q31_t)0x64E88926, (q31_t)0xB1187D05, (q31_t)0x64C99498, - (q31_t)0xB0F0EEDA, (q31_t)0x64AA907F, (q31_t)0xB0C96CDF, - (q31_t)0x648B7CDF, (q31_t)0xB0A1F71C, (q31_t)0x646C59BF, - (q31_t)0xB07A8D97, (q31_t)0x644D2722, (q31_t)0xB0533055, - (q31_t)0x642DE50D, (q31_t)0xB02BDF5C, (q31_t)0x640E9385, - (q31_t)0xB0049AB2, (q31_t)0x63EF328F, (q31_t)0xAFDD625F, - (q31_t)0x63CFC230, (q31_t)0xAFB63667, (q31_t)0x63B0426D, - (q31_t)0xAF8F16D0, (q31_t)0x6390B34A, (q31_t)0xAF6803A1, - (q31_t)0x637114CC, (q31_t)0xAF40FCE0, (q31_t)0x635166F8, - (q31_t)0xAF1A0293, (q31_t)0x6331A9D4, (q31_t)0xAEF314BF, - (q31_t)0x6311DD63, (q31_t)0xAECC336B, (q31_t)0x62F201AC, - (q31_t)0xAEA55E9D, (q31_t)0x62D216B2, (q31_t)0xAE7E965B, - (q31_t)0x62B21C7B, (q31_t)0xAE57DAAA, (q31_t)0x6292130C, - (q31_t)0xAE312B91, (q31_t)0x6271FA69, (q31_t)0xAE0A8916, - (q31_t)0x6251D297, (q31_t)0xADE3F33E, (q31_t)0x62319B9D, - (q31_t)0xADBD6A10, (q31_t)0x6211557D, (q31_t)0xAD96ED91, - (q31_t)0x61F1003E, (q31_t)0xAD707DC8, (q31_t)0x61D09BE5, - (q31_t)0xAD4A1ABA, (q31_t)0x61B02876, (q31_t)0xAD23C46D, - (q31_t)0x618FA5F6, (q31_t)0xACFD7AE8, (q31_t)0x616F146B, - (q31_t)0xACD73E30, (q31_t)0x614E73D9, (q31_t)0xACB10E4A, - (q31_t)0x612DC446, (q31_t)0xAC8AEB3E, (q31_t)0x610D05B7, - (q31_t)0xAC64D510, (q31_t)0x60EC3830, (q31_t)0xAC3ECBC7, - (q31_t)0x60CB5BB6, (q31_t)0xAC18CF68, (q31_t)0x60AA704F, - (q31_t)0xABF2DFFA, (q31_t)0x60897600, (q31_t)0xABCCFD82, - (q31_t)0x60686CCE, (q31_t)0xABA72806, (q31_t)0x604754BE, - (q31_t)0xAB815F8C, (q31_t)0x60262DD5, (q31_t)0xAB5BA41A, - (q31_t)0x6004F818, (q31_t)0xAB35F5B5, (q31_t)0x5FE3B38D, - (q31_t)0xAB105464, (q31_t)0x5FC26038, (q31_t)0xAAEAC02B, - (q31_t)0x5FA0FE1E, (q31_t)0xAAC53912, (q31_t)0x5F7F8D46, - (q31_t)0xAA9FBF1D, (q31_t)0x5F5E0DB3, (q31_t)0xAA7A5253, - (q31_t)0x5F3C7F6B, (q31_t)0xAA54F2B9, (q31_t)0x5F1AE273, - (q31_t)0xAA2FA055, (q31_t)0x5EF936D1, (q31_t)0xAA0A5B2D, - (q31_t)0x5ED77C89, (q31_t)0xA9E52347, (q31_t)0x5EB5B3A1, - (q31_t)0xA9BFF8A8, (q31_t)0x5E93DC1F, (q31_t)0xA99ADB56, - (q31_t)0x5E71F606, (q31_t)0xA975CB56, (q31_t)0x5E50015D, - (q31_t)0xA950C8AF, (q31_t)0x5E2DFE28, (q31_t)0xA92BD366, - (q31_t)0x5E0BEC6E, (q31_t)0xA906EB81, (q31_t)0x5DE9CC32, - (q31_t)0xA8E21106, (q31_t)0x5DC79D7C, (q31_t)0xA8BD43FA, - (q31_t)0x5DA5604E, (q31_t)0xA8988463, (q31_t)0x5D8314B0, - (q31_t)0xA873D246, (q31_t)0x5D60BAA6, (q31_t)0xA84F2DA9, - (q31_t)0x5D3E5236, (q31_t)0xA82A9693, (q31_t)0x5D1BDB65, - (q31_t)0xA8060D08, (q31_t)0x5CF95638, (q31_t)0xA7E1910E, - (q31_t)0x5CD6C2B4, (q31_t)0xA7BD22AB, (q31_t)0x5CB420DF, - (q31_t)0xA798C1E4, (q31_t)0x5C9170BF, (q31_t)0xA7746EC0, - (q31_t)0x5C6EB258, (q31_t)0xA7502943, (q31_t)0x5C4BE5B0, - (q31_t)0xA72BF173, (q31_t)0x5C290ACC, (q31_t)0xA707C756, - (q31_t)0x5C0621B2, (q31_t)0xA6E3AAF2, (q31_t)0x5BE32A67, - (q31_t)0xA6BF9C4B, (q31_t)0x5BC024F0, (q31_t)0xA69B9B68, - (q31_t)0x5B9D1153, (q31_t)0xA677A84E, (q31_t)0x5B79EF96, - (q31_t)0xA653C302, (q31_t)0x5B56BFBD, (q31_t)0xA62FEB8B, - (q31_t)0x5B3381CE, (q31_t)0xA60C21ED, (q31_t)0x5B1035CF, - (q31_t)0xA5E8662F, (q31_t)0x5AECDBC4, (q31_t)0xA5C4B855, - (q31_t)0x5AC973B4, (q31_t)0xA5A11865, (q31_t)0x5AA5FDA4, - (q31_t)0xA57D8666, (q31_t)0x5A82799A, (q31_t)0xA55A025B, - (q31_t)0x5A5EE79A, (q31_t)0xA5368C4B, (q31_t)0x5A3B47AA, - (q31_t)0xA513243B, (q31_t)0x5A1799D0, (q31_t)0xA4EFCA31, - (q31_t)0x59F3DE12, (q31_t)0xA4CC7E31, (q31_t)0x59D01474, - (q31_t)0xA4A94042, (q31_t)0x59AC3CFD, (q31_t)0xA4861069, - (q31_t)0x598857B1, (q31_t)0xA462EEAC, (q31_t)0x59646497, - (q31_t)0xA43FDB0F, (q31_t)0x594063B4, (q31_t)0xA41CD598, - (q31_t)0x591C550E, (q31_t)0xA3F9DE4D, (q31_t)0x58F838A9, - (q31_t)0xA3D6F533, (q31_t)0x58D40E8C, (q31_t)0xA3B41A4F, - (q31_t)0x58AFD6BC, (q31_t)0xA3914DA7, (q31_t)0x588B913F, - (q31_t)0xA36E8F40, (q31_t)0x58673E1B, (q31_t)0xA34BDF20, - (q31_t)0x5842DD54, (q31_t)0xA3293D4B, (q31_t)0x581E6EF1, - (q31_t)0xA306A9C7, (q31_t)0x57F9F2F7, (q31_t)0xA2E4249A, - (q31_t)0x57D5696C, (q31_t)0xA2C1ADC9, (q31_t)0x57B0D256, - (q31_t)0xA29F4559, (q31_t)0x578C2DB9, (q31_t)0xA27CEB4F, - (q31_t)0x57677B9D, (q31_t)0xA25A9FB1, (q31_t)0x5742BC05, - (q31_t)0xA2386283, (q31_t)0x571DEEF9, (q31_t)0xA21633CD, - (q31_t)0x56F9147E, (q31_t)0xA1F41391, (q31_t)0x56D42C99, - (q31_t)0xA1D201D7, (q31_t)0x56AF3750, (q31_t)0xA1AFFEA2, - (q31_t)0x568A34A9, (q31_t)0xA18E09F9, (q31_t)0x566524AA, - (q31_t)0xA16C23E1, (q31_t)0x56400757, (q31_t)0xA14A4C5E, - (q31_t)0x561ADCB8, (q31_t)0xA1288376, (q31_t)0x55F5A4D2, - (q31_t)0xA106C92E, (q31_t)0x55D05FAA, (q31_t)0xA0E51D8C, - (q31_t)0x55AB0D46, (q31_t)0xA0C38094, (q31_t)0x5585ADAC, - (q31_t)0xA0A1F24C, (q31_t)0x556040E2, (q31_t)0xA08072BA, - (q31_t)0x553AC6ED, (q31_t)0xA05F01E1, (q31_t)0x55153FD4, - (q31_t)0xA03D9FC7, (q31_t)0x54EFAB9C, (q31_t)0xA01C4C72, - (q31_t)0x54CA0A4A, (q31_t)0x9FFB07E7, (q31_t)0x54A45BE5, - (q31_t)0x9FD9D22A, (q31_t)0x547EA073, (q31_t)0x9FB8AB41, - (q31_t)0x5458D7F9, (q31_t)0x9F979331, (q31_t)0x5433027D, - (q31_t)0x9F7689FF, (q31_t)0x540D2005, (q31_t)0x9F558FB0, - (q31_t)0x53E73097, (q31_t)0x9F34A449, (q31_t)0x53C13438, - (q31_t)0x9F13C7D0, (q31_t)0x539B2AEF, (q31_t)0x9EF2FA48, - (q31_t)0x537514C1, (q31_t)0x9ED23BB9, (q31_t)0x534EF1B5, - (q31_t)0x9EB18C26, (q31_t)0x5328C1D0, (q31_t)0x9E90EB94, - (q31_t)0x53028517, (q31_t)0x9E705A09, (q31_t)0x52DC3B92, - (q31_t)0x9E4FD789, (q31_t)0x52B5E545, (q31_t)0x9E2F641A, - (q31_t)0x528F8237, (q31_t)0x9E0EFFC1, (q31_t)0x5269126E, - (q31_t)0x9DEEAA82, (q31_t)0x524295EF, (q31_t)0x9DCE6462, - (q31_t)0x521C0CC1, (q31_t)0x9DAE2D68, (q31_t)0x51F576E9, - (q31_t)0x9D8E0596, (q31_t)0x51CED46E, (q31_t)0x9D6DECF4, - (q31_t)0x51A82555, (q31_t)0x9D4DE384, (q31_t)0x518169A4, - (q31_t)0x9D2DE94D, (q31_t)0x515AA162, (q31_t)0x9D0DFE53, - (q31_t)0x5133CC94, (q31_t)0x9CEE229C, (q31_t)0x510CEB40, - (q31_t)0x9CCE562B, (q31_t)0x50E5FD6C, (q31_t)0x9CAE9907, - (q31_t)0x50BF031F, (q31_t)0x9C8EEB33, (q31_t)0x5097FC5E, - (q31_t)0x9C6F4CB5, (q31_t)0x5070E92F, (q31_t)0x9C4FBD92, - (q31_t)0x5049C999, (q31_t)0x9C303DCF, (q31_t)0x50229DA0, - (q31_t)0x9C10CD70, (q31_t)0x4FFB654D, (q31_t)0x9BF16C7A, - (q31_t)0x4FD420A3, (q31_t)0x9BD21AF2, (q31_t)0x4FACCFAB, - (q31_t)0x9BB2D8DD, (q31_t)0x4F857268, (q31_t)0x9B93A640, - (q31_t)0x4F5E08E3, (q31_t)0x9B748320, (q31_t)0x4F369320, - (q31_t)0x9B556F80, (q31_t)0x4F0F1126, (q31_t)0x9B366B67, - (q31_t)0x4EE782FA, (q31_t)0x9B1776D9, (q31_t)0x4EBFE8A4, - (q31_t)0x9AF891DB, (q31_t)0x4E984229, (q31_t)0x9AD9BC71, - (q31_t)0x4E708F8F, (q31_t)0x9ABAF6A0, (q31_t)0x4E48D0DC, - (q31_t)0x9A9C406D, (q31_t)0x4E210617, (q31_t)0x9A7D99DD, - (q31_t)0x4DF92F45, (q31_t)0x9A5F02F5, (q31_t)0x4DD14C6E, - (q31_t)0x9A407BB8, (q31_t)0x4DA95D96, (q31_t)0x9A22042C, - (q31_t)0x4D8162C4, (q31_t)0x9A039C56, (q31_t)0x4D595BFE, - (q31_t)0x99E5443A, (q31_t)0x4D31494B, (q31_t)0x99C6FBDE, - (q31_t)0x4D092AB0, (q31_t)0x99A8C344, (q31_t)0x4CE10034, - (q31_t)0x998A9A73, (q31_t)0x4CB8C9DD, (q31_t)0x996C816F, - (q31_t)0x4C9087B1, (q31_t)0x994E783C, (q31_t)0x4C6839B6, - (q31_t)0x99307EE0, (q31_t)0x4C3FDFF3, (q31_t)0x9912955E, - (q31_t)0x4C177A6E, (q31_t)0x98F4BBBC, (q31_t)0x4BEF092D, - (q31_t)0x98D6F1FE, (q31_t)0x4BC68C36, (q31_t)0x98B93828, - (q31_t)0x4B9E038F, (q31_t)0x989B8E3F, (q31_t)0x4B756F3F, - (q31_t)0x987DF449, (q31_t)0x4B4CCF4D, (q31_t)0x98606A48, - (q31_t)0x4B2423BD, (q31_t)0x9842F043, (q31_t)0x4AFB6C97, - (q31_t)0x9825863D, (q31_t)0x4AD2A9E1, (q31_t)0x98082C3B, - (q31_t)0x4AA9DBA1, (q31_t)0x97EAE241, (q31_t)0x4A8101DE, - (q31_t)0x97CDA855, (q31_t)0x4A581C9D, (q31_t)0x97B07E7A, - (q31_t)0x4A2F2BE5, (q31_t)0x979364B5, (q31_t)0x4A062FBD, - (q31_t)0x97765B0A, (q31_t)0x49DD282A, (q31_t)0x9759617E, - (q31_t)0x49B41533, (q31_t)0x973C7816, (q31_t)0x498AF6DE, - (q31_t)0x971F9ED6, (q31_t)0x4961CD32, (q31_t)0x9702D5C2, - (q31_t)0x49389836, (q31_t)0x96E61CDF, (q31_t)0x490F57EE, - (q31_t)0x96C97431, (q31_t)0x48E60C62, (q31_t)0x96ACDBBD, - (q31_t)0x48BCB598, (q31_t)0x96905387, (q31_t)0x48935397, - (q31_t)0x9673DB94, (q31_t)0x4869E664, (q31_t)0x965773E7, - (q31_t)0x48406E07, (q31_t)0x963B1C85, (q31_t)0x4816EA85, - (q31_t)0x961ED573, (q31_t)0x47ED5BE6, (q31_t)0x96029EB5, - (q31_t)0x47C3C22E, (q31_t)0x95E6784F, (q31_t)0x479A1D66, - (q31_t)0x95CA6246, (q31_t)0x47706D93, (q31_t)0x95AE5C9E, - (q31_t)0x4746B2BC, (q31_t)0x9592675B, (q31_t)0x471CECE6, - (q31_t)0x95768282, (q31_t)0x46F31C1A, (q31_t)0x955AAE17, - (q31_t)0x46C9405C, (q31_t)0x953EEA1E, (q31_t)0x469F59B4, - (q31_t)0x9523369B, (q31_t)0x46756827, (q31_t)0x95079393, - (q31_t)0x464B6BBD, (q31_t)0x94EC010B, (q31_t)0x4621647C, - (q31_t)0x94D07F05, (q31_t)0x45F7526B, (q31_t)0x94B50D87, - (q31_t)0x45CD358F, (q31_t)0x9499AC95, (q31_t)0x45A30DF0, - (q31_t)0x947E5C32, (q31_t)0x4578DB93, (q31_t)0x94631C64, - (q31_t)0x454E9E80, (q31_t)0x9447ED2F, (q31_t)0x452456BC, - (q31_t)0x942CCE95, (q31_t)0x44FA044F, (q31_t)0x9411C09D, - (q31_t)0x44CFA73F, (q31_t)0x93F6C34A, (q31_t)0x44A53F93, - (q31_t)0x93DBD69F, (q31_t)0x447ACD50, (q31_t)0x93C0FAA2, - (q31_t)0x4450507E, (q31_t)0x93A62F56, (q31_t)0x4425C923, - (q31_t)0x938B74C0, (q31_t)0x43FB3745, (q31_t)0x9370CAE4, - (q31_t)0x43D09AEC, (q31_t)0x935631C5, (q31_t)0x43A5F41E, - (q31_t)0x933BA968, (q31_t)0x437B42E1, (q31_t)0x932131D1, - (q31_t)0x4350873C, (q31_t)0x9306CB04, (q31_t)0x4325C135, - (q31_t)0x92EC7505, (q31_t)0x42FAF0D4, (q31_t)0x92D22FD8, - (q31_t)0x42D0161E, (q31_t)0x92B7FB82, (q31_t)0x42A5311A, - (q31_t)0x929DD805, (q31_t)0x427A41D0, (q31_t)0x9283C567, - (q31_t)0x424F4845, (q31_t)0x9269C3AC, (q31_t)0x42244480, - (q31_t)0x924FD2D6, (q31_t)0x41F93688, (q31_t)0x9235F2EB, - (q31_t)0x41CE1E64, (q31_t)0x921C23EE, (q31_t)0x41A2FC1A, - (q31_t)0x920265E4, (q31_t)0x4177CFB0, (q31_t)0x91E8B8D0, - (q31_t)0x414C992E, (q31_t)0x91CF1CB6, (q31_t)0x4121589A, - (q31_t)0x91B5919A, (q31_t)0x40F60DFB, (q31_t)0x919C1780, - (q31_t)0x40CAB957, (q31_t)0x9182AE6C, (q31_t)0x409F5AB6, - (q31_t)0x91695663, (q31_t)0x4073F21D, (q31_t)0x91500F67, - (q31_t)0x40487F93, (q31_t)0x9136D97D, (q31_t)0x401D0320, - (q31_t)0x911DB4A8, (q31_t)0x3FF17CCA, (q31_t)0x9104A0ED, - (q31_t)0x3FC5EC97, (q31_t)0x90EB9E50, (q31_t)0x3F9A528F, - (q31_t)0x90D2ACD3, (q31_t)0x3F6EAEB8, (q31_t)0x90B9CC7C, - (q31_t)0x3F430118, (q31_t)0x90A0FD4E, (q31_t)0x3F1749B7, - (q31_t)0x90883F4C, (q31_t)0x3EEB889C, (q31_t)0x906F927B, - (q31_t)0x3EBFBDCC, (q31_t)0x9056F6DF, (q31_t)0x3E93E94F, - (q31_t)0x903E6C7A, (q31_t)0x3E680B2C, (q31_t)0x9025F352, - (q31_t)0x3E3C2369, (q31_t)0x900D8B69, (q31_t)0x3E10320D, - (q31_t)0x8FF534C4, (q31_t)0x3DE4371F, (q31_t)0x8FDCEF66, - (q31_t)0x3DB832A5, (q31_t)0x8FC4BB53, (q31_t)0x3D8C24A7, - (q31_t)0x8FAC988E, (q31_t)0x3D600D2B, (q31_t)0x8F94871D, - (q31_t)0x3D33EC39, (q31_t)0x8F7C8701, (q31_t)0x3D07C1D5, - (q31_t)0x8F64983F, (q31_t)0x3CDB8E09, (q31_t)0x8F4CBADB, - (q31_t)0x3CAF50DA, (q31_t)0x8F34EED8, (q31_t)0x3C830A4F, - (q31_t)0x8F1D343A, (q31_t)0x3C56BA70, (q31_t)0x8F058B04, - (q31_t)0x3C2A6142, (q31_t)0x8EEDF33B, (q31_t)0x3BFDFECD, - (q31_t)0x8ED66CE1, (q31_t)0x3BD19317, (q31_t)0x8EBEF7FB, - (q31_t)0x3BA51E29, (q31_t)0x8EA7948C, (q31_t)0x3B78A007, - (q31_t)0x8E904298, (q31_t)0x3B4C18BA, (q31_t)0x8E790222, - (q31_t)0x3B1F8847, (q31_t)0x8E61D32D, (q31_t)0x3AF2EEB7, - (q31_t)0x8E4AB5BF, (q31_t)0x3AC64C0F, (q31_t)0x8E33A9D9, - (q31_t)0x3A99A057, (q31_t)0x8E1CAF80, (q31_t)0x3A6CEB95, - (q31_t)0x8E05C6B7, (q31_t)0x3A402DD1, (q31_t)0x8DEEEF82, - (q31_t)0x3A136712, (q31_t)0x8DD829E4, (q31_t)0x39E6975D, - (q31_t)0x8DC175E0, (q31_t)0x39B9BEBB, (q31_t)0x8DAAD37B, - (q31_t)0x398CDD32, (q31_t)0x8D9442B7, (q31_t)0x395FF2C9, - (q31_t)0x8D7DC399, (q31_t)0x3932FF87, (q31_t)0x8D675623, - (q31_t)0x39060372, (q31_t)0x8D50FA59, (q31_t)0x38D8FE93, - (q31_t)0x8D3AB03F, (q31_t)0x38ABF0EF, (q31_t)0x8D2477D8, - (q31_t)0x387EDA8E, (q31_t)0x8D0E5127, (q31_t)0x3851BB76, - (q31_t)0x8CF83C30, (q31_t)0x382493B0, (q31_t)0x8CE238F6, - (q31_t)0x37F76340, (q31_t)0x8CCC477D, (q31_t)0x37CA2A30, - (q31_t)0x8CB667C7, (q31_t)0x379CE884, (q31_t)0x8CA099D9, - (q31_t)0x376F9E46, (q31_t)0x8C8ADDB6, (q31_t)0x37424B7A, - (q31_t)0x8C753361, (q31_t)0x3714F02A, (q31_t)0x8C5F9ADD, - (q31_t)0x36E78C5A, (q31_t)0x8C4A142F, (q31_t)0x36BA2013, - (q31_t)0x8C349F58, (q31_t)0x368CAB5C, (q31_t)0x8C1F3C5C, - (q31_t)0x365F2E3B, (q31_t)0x8C09EB40, (q31_t)0x3631A8B7, - (q31_t)0x8BF4AC05, (q31_t)0x36041AD9, (q31_t)0x8BDF7EAF, - (q31_t)0x35D684A5, (q31_t)0x8BCA6342, (q31_t)0x35A8E624, - (q31_t)0x8BB559C1, (q31_t)0x357B3F5D, (q31_t)0x8BA0622F, - (q31_t)0x354D9056, (q31_t)0x8B8B7C8F, (q31_t)0x351FD917, - (q31_t)0x8B76A8E4, (q31_t)0x34F219A7, (q31_t)0x8B61E732, - (q31_t)0x34C4520D, (q31_t)0x8B4D377C, (q31_t)0x3496824F, - (q31_t)0x8B3899C5, (q31_t)0x3468AA76, (q31_t)0x8B240E10, - (q31_t)0x343ACA87, (q31_t)0x8B0F9461, (q31_t)0x340CE28A, - (q31_t)0x8AFB2CBA, (q31_t)0x33DEF287, (q31_t)0x8AE6D71F, - (q31_t)0x33B0FA84, (q31_t)0x8AD29393, (q31_t)0x3382FA88, - (q31_t)0x8ABE6219, (q31_t)0x3354F29A, (q31_t)0x8AAA42B4, - (q31_t)0x3326E2C2, (q31_t)0x8A963567, (q31_t)0x32F8CB07, - (q31_t)0x8A823A35, (q31_t)0x32CAAB6F, (q31_t)0x8A6E5122, - (q31_t)0x329C8402, (q31_t)0x8A5A7A30, (q31_t)0x326E54C7, - (q31_t)0x8A46B563, (q31_t)0x32401DC5, (q31_t)0x8A3302BD, - (q31_t)0x3211DF03, (q31_t)0x8A1F6242, (q31_t)0x31E39889, - (q31_t)0x8A0BD3F5, (q31_t)0x31B54A5D, (q31_t)0x89F857D8, - (q31_t)0x3186F487, (q31_t)0x89E4EDEE, (q31_t)0x3158970D, - (q31_t)0x89D1963C, (q31_t)0x312A31F8, (q31_t)0x89BE50C3, - (q31_t)0x30FBC54D, (q31_t)0x89AB1D86, (q31_t)0x30CD5114, - (q31_t)0x8997FC89, (q31_t)0x309ED555, (q31_t)0x8984EDCF, - (q31_t)0x30705217, (q31_t)0x8971F15A, (q31_t)0x3041C760, - (q31_t)0x895F072D, (q31_t)0x30133538, (q31_t)0x894C2F4C, - (q31_t)0x2FE49BA6, (q31_t)0x893969B9, (q31_t)0x2FB5FAB2, - (q31_t)0x8926B677, (q31_t)0x2F875262, (q31_t)0x89141589, - (q31_t)0x2F58A2BD, (q31_t)0x890186F1, (q31_t)0x2F29EBCC, - (q31_t)0x88EF0AB4, (q31_t)0x2EFB2D94, (q31_t)0x88DCA0D3, - (q31_t)0x2ECC681E, (q31_t)0x88CA4951, (q31_t)0x2E9D9B70, - (q31_t)0x88B80431, (q31_t)0x2E6EC792, (q31_t)0x88A5D177, - (q31_t)0x2E3FEC8B, (q31_t)0x8893B124, (q31_t)0x2E110A62, - (q31_t)0x8881A33C, (q31_t)0x2DE2211E, (q31_t)0x886FA7C2, - (q31_t)0x2DB330C7, (q31_t)0x885DBEB7, (q31_t)0x2D843963, - (q31_t)0x884BE820, (q31_t)0x2D553AFB, (q31_t)0x883A23FE, - (q31_t)0x2D263595, (q31_t)0x88287255, (q31_t)0x2CF72939, - (q31_t)0x8816D327, (q31_t)0x2CC815ED, (q31_t)0x88054677, - (q31_t)0x2C98FBBA, (q31_t)0x87F3CC47, (q31_t)0x2C69DAA6, - (q31_t)0x87E2649B, (q31_t)0x2C3AB2B9, (q31_t)0x87D10F75, - (q31_t)0x2C0B83F9, (q31_t)0x87BFCCD7, (q31_t)0x2BDC4E6F, - (q31_t)0x87AE9CC5, (q31_t)0x2BAD1221, (q31_t)0x879D7F40, - (q31_t)0x2B7DCF17, (q31_t)0x878C744C, (q31_t)0x2B4E8558, - (q31_t)0x877B7BEC, (q31_t)0x2B1F34EB, (q31_t)0x876A9621, - (q31_t)0x2AEFDDD8, (q31_t)0x8759C2EF, (q31_t)0x2AC08025, - (q31_t)0x87490257, (q31_t)0x2A911BDB, (q31_t)0x8738545E, - (q31_t)0x2A61B101, (q31_t)0x8727B904, (q31_t)0x2A323F9D, - (q31_t)0x8717304E, (q31_t)0x2A02C7B8, (q31_t)0x8706BA3C, - (q31_t)0x29D34958, (q31_t)0x86F656D3, (q31_t)0x29A3C484, - (q31_t)0x86E60614, (q31_t)0x29743945, (q31_t)0x86D5C802, - (q31_t)0x2944A7A2, (q31_t)0x86C59C9F, (q31_t)0x29150FA1, - (q31_t)0x86B583EE, (q31_t)0x28E5714A, (q31_t)0x86A57DF1, - (q31_t)0x28B5CCA5, (q31_t)0x86958AAB, (q31_t)0x288621B9, - (q31_t)0x8685AA1F, (q31_t)0x2856708C, (q31_t)0x8675DC4E, - (q31_t)0x2826B928, (q31_t)0x8666213C, (q31_t)0x27F6FB92, - (q31_t)0x865678EA, (q31_t)0x27C737D2, (q31_t)0x8646E35B, - (q31_t)0x27976DF1, (q31_t)0x86376092, (q31_t)0x27679DF4, - (q31_t)0x8627F090, (q31_t)0x2737C7E3, (q31_t)0x86189359, - (q31_t)0x2707EBC6, (q31_t)0x860948EE, (q31_t)0x26D809A5, - (q31_t)0x85FA1152, (q31_t)0x26A82185, (q31_t)0x85EAEC88, - (q31_t)0x26783370, (q31_t)0x85DBDA91, (q31_t)0x26483F6C, - (q31_t)0x85CCDB70, (q31_t)0x26184581, (q31_t)0x85BDEF27, - (q31_t)0x25E845B5, (q31_t)0x85AF15B9, (q31_t)0x25B84012, - (q31_t)0x85A04F28, (q31_t)0x2588349D, (q31_t)0x85919B75, - (q31_t)0x2558235E, (q31_t)0x8582FAA4, (q31_t)0x25280C5D, - (q31_t)0x85746CB7, (q31_t)0x24F7EFA1, (q31_t)0x8565F1B0, - (q31_t)0x24C7CD32, (q31_t)0x85578991, (q31_t)0x2497A517, - (q31_t)0x8549345C, (q31_t)0x24677757, (q31_t)0x853AF214, - (q31_t)0x243743FA, (q31_t)0x852CC2BA, (q31_t)0x24070B07, - (q31_t)0x851EA652, (q31_t)0x23D6CC86, (q31_t)0x85109CDC, - (q31_t)0x23A6887E, (q31_t)0x8502A65C, (q31_t)0x23763EF7, - (q31_t)0x84F4C2D3, (q31_t)0x2345EFF7, (q31_t)0x84E6F244, - (q31_t)0x23159B87, (q31_t)0x84D934B0, (q31_t)0x22E541AE, - (q31_t)0x84CB8A1B, (q31_t)0x22B4E274, (q31_t)0x84BDF285, - (q31_t)0x22847DDF, (q31_t)0x84B06DF1, (q31_t)0x225413F8, - (q31_t)0x84A2FC62, (q31_t)0x2223A4C5, (q31_t)0x84959DD9, - (q31_t)0x21F3304E, (q31_t)0x84885257, (q31_t)0x21C2B69C, - (q31_t)0x847B19E1, (q31_t)0x219237B4, (q31_t)0x846DF476, - (q31_t)0x2161B39F, (q31_t)0x8460E21A, (q31_t)0x21312A65, - (q31_t)0x8453E2CE, (q31_t)0x21009C0B, (q31_t)0x8446F695, - (q31_t)0x20D0089B, (q31_t)0x843A1D70, (q31_t)0x209F701C, - (q31_t)0x842D5761, (q31_t)0x206ED295, (q31_t)0x8420A46B, - (q31_t)0x203E300D, (q31_t)0x8414048F, (q31_t)0x200D888C, - (q31_t)0x840777CF, (q31_t)0x1FDCDC1A, (q31_t)0x83FAFE2E, - (q31_t)0x1FAC2ABF, (q31_t)0x83EE97AC, (q31_t)0x1F7B7480, - (q31_t)0x83E2444D, (q31_t)0x1F4AB967, (q31_t)0x83D60411, - (q31_t)0x1F19F97B, (q31_t)0x83C9D6FB, (q31_t)0x1EE934C2, - (q31_t)0x83BDBD0D, (q31_t)0x1EB86B46, (q31_t)0x83B1B649, - (q31_t)0x1E879D0C, (q31_t)0x83A5C2B0, (q31_t)0x1E56CA1E, - (q31_t)0x8399E244, (q31_t)0x1E25F281, (q31_t)0x838E1507, - (q31_t)0x1DF5163F, (q31_t)0x83825AFB, (q31_t)0x1DC4355D, - (q31_t)0x8376B422, (q31_t)0x1D934FE5, (q31_t)0x836B207D, - (q31_t)0x1D6265DD, (q31_t)0x835FA00E, (q31_t)0x1D31774D, - (q31_t)0x835432D8, (q31_t)0x1D00843C, (q31_t)0x8348D8DB, - (q31_t)0x1CCF8CB3, (q31_t)0x833D921A, (q31_t)0x1C9E90B8, - (q31_t)0x83325E97, (q31_t)0x1C6D9053, (q31_t)0x83273E52, - (q31_t)0x1C3C8B8C, (q31_t)0x831C314E, (q31_t)0x1C0B826A, - (q31_t)0x8311378C, (q31_t)0x1BDA74F5, (q31_t)0x8306510F, - (q31_t)0x1BA96334, (q31_t)0x82FB7DD8, (q31_t)0x1B784D30, - (q31_t)0x82F0BDE8, (q31_t)0x1B4732EF, (q31_t)0x82E61141, - (q31_t)0x1B161479, (q31_t)0x82DB77E5, (q31_t)0x1AE4F1D6, - (q31_t)0x82D0F1D5, (q31_t)0x1AB3CB0C, (q31_t)0x82C67F13, - (q31_t)0x1A82A025, (q31_t)0x82BC1FA1, (q31_t)0x1A517127, - (q31_t)0x82B1D381, (q31_t)0x1A203E1B, (q31_t)0x82A79AB3, - (q31_t)0x19EF0706, (q31_t)0x829D753A, (q31_t)0x19BDCBF2, - (q31_t)0x82936316, (q31_t)0x198C8CE6, (q31_t)0x8289644A, - (q31_t)0x195B49E9, (q31_t)0x827F78D8, (q31_t)0x192A0303, - (q31_t)0x8275A0C0, (q31_t)0x18F8B83C, (q31_t)0x826BDC04, - (q31_t)0x18C7699B, (q31_t)0x82622AA5, (q31_t)0x18961727, - (q31_t)0x82588CA6, (q31_t)0x1864C0E9, (q31_t)0x824F0208, - (q31_t)0x183366E8, (q31_t)0x82458ACB, (q31_t)0x1802092C, - (q31_t)0x823C26F2, (q31_t)0x17D0A7BB, (q31_t)0x8232D67E, - (q31_t)0x179F429F, (q31_t)0x82299971, (q31_t)0x176DD9DE, - (q31_t)0x82206FCB, (q31_t)0x173C6D80, (q31_t)0x8217598F, - (q31_t)0x170AFD8D, (q31_t)0x820E56BE, (q31_t)0x16D98A0C, - (q31_t)0x82056758, (q31_t)0x16A81305, (q31_t)0x81FC8B60, - (q31_t)0x1676987F, (q31_t)0x81F3C2D7, (q31_t)0x16451A83, - (q31_t)0x81EB0DBD, (q31_t)0x16139917, (q31_t)0x81E26C16, - (q31_t)0x15E21444, (q31_t)0x81D9DDE1, (q31_t)0x15B08C11, - (q31_t)0x81D16320, (q31_t)0x157F0086, (q31_t)0x81C8FBD5, - (q31_t)0x154D71AA, (q31_t)0x81C0A801, (q31_t)0x151BDF85, - (q31_t)0x81B867A4, (q31_t)0x14EA4A1F, (q31_t)0x81B03AC1, - (q31_t)0x14B8B17F, (q31_t)0x81A82159, (q31_t)0x148715AD, - (q31_t)0x81A01B6C, (q31_t)0x145576B1, (q31_t)0x819828FD, - (q31_t)0x1423D492, (q31_t)0x81904A0C, (q31_t)0x13F22F57, - (q31_t)0x81887E9A, (q31_t)0x13C0870A, (q31_t)0x8180C6A9, - (q31_t)0x138EDBB0, (q31_t)0x8179223A, (q31_t)0x135D2D53, - (q31_t)0x8171914E, (q31_t)0x132B7BF9, (q31_t)0x816A13E6, - (q31_t)0x12F9C7AA, (q31_t)0x8162AA03, (q31_t)0x12C8106E, - (q31_t)0x815B53A8, (q31_t)0x1296564D, (q31_t)0x815410D3, - (q31_t)0x1264994E, (q31_t)0x814CE188, (q31_t)0x1232D978, - (q31_t)0x8145C5C6, (q31_t)0x120116D4, (q31_t)0x813EBD90, - (q31_t)0x11CF516A, (q31_t)0x8137C8E6, (q31_t)0x119D8940, - (q31_t)0x8130E7C8, (q31_t)0x116BBE5F, (q31_t)0x812A1A39, - (q31_t)0x1139F0CE, (q31_t)0x81236039, (q31_t)0x11082096, - (q31_t)0x811CB9CA, (q31_t)0x10D64DBC, (q31_t)0x811626EC, - (q31_t)0x10A4784A, (q31_t)0x810FA7A0, (q31_t)0x1072A047, - (q31_t)0x81093BE8, (q31_t)0x1040C5BB, (q31_t)0x8102E3C3, - (q31_t)0x100EE8AD, (q31_t)0x80FC9F35, (q31_t)0x0FDD0925, - (q31_t)0x80F66E3C, (q31_t)0x0FAB272B, (q31_t)0x80F050DB, - (q31_t)0x0F7942C6, (q31_t)0x80EA4712, (q31_t)0x0F475BFE, - (q31_t)0x80E450E2, (q31_t)0x0F1572DC, (q31_t)0x80DE6E4C, - (q31_t)0x0EE38765, (q31_t)0x80D89F51, (q31_t)0x0EB199A3, - (q31_t)0x80D2E3F1, (q31_t)0x0E7FA99D, (q31_t)0x80CD3C2F, - (q31_t)0x0E4DB75B, (q31_t)0x80C7A80A, (q31_t)0x0E1BC2E3, - (q31_t)0x80C22783, (q31_t)0x0DE9CC3F, (q31_t)0x80BCBA9C, - (q31_t)0x0DB7D376, (q31_t)0x80B76155, (q31_t)0x0D85D88F, - (q31_t)0x80B21BAF, (q31_t)0x0D53DB92, (q31_t)0x80ACE9AB, - (q31_t)0x0D21DC87, (q31_t)0x80A7CB49, (q31_t)0x0CEFDB75, - (q31_t)0x80A2C08B, (q31_t)0x0CBDD865, (q31_t)0x809DC970, - (q31_t)0x0C8BD35E, (q31_t)0x8098E5FB, (q31_t)0x0C59CC67, - (q31_t)0x8094162B, (q31_t)0x0C27C389, (q31_t)0x808F5A02, - (q31_t)0x0BF5B8CB, (q31_t)0x808AB180, (q31_t)0x0BC3AC35, - (q31_t)0x80861CA5, (q31_t)0x0B919DCE, (q31_t)0x80819B74, - (q31_t)0x0B5F8D9F, (q31_t)0x807D2DEB, (q31_t)0x0B2D7BAE, - (q31_t)0x8078D40D, (q31_t)0x0AFB6805, (q31_t)0x80748DD9, - (q31_t)0x0AC952AA, (q31_t)0x80705B50, (q31_t)0x0A973BA5, - (q31_t)0x806C3C73, (q31_t)0x0A6522FE, (q31_t)0x80683143, - (q31_t)0x0A3308BC, (q31_t)0x806439C0, (q31_t)0x0A00ECE8, - (q31_t)0x806055EA, (q31_t)0x09CECF89, (q31_t)0x805C85C3, - (q31_t)0x099CB0A7, (q31_t)0x8058C94C, (q31_t)0x096A9049, - (q31_t)0x80552083, (q31_t)0x09386E77, (q31_t)0x80518B6B, - (q31_t)0x09064B3A, (q31_t)0x804E0A03, (q31_t)0x08D42698, - (q31_t)0x804A9C4D, (q31_t)0x08A2009A, (q31_t)0x80474248, - (q31_t)0x086FD947, (q31_t)0x8043FBF6, (q31_t)0x083DB0A7, - (q31_t)0x8040C956, (q31_t)0x080B86C1, (q31_t)0x803DAA69, - (q31_t)0x07D95B9E, (q31_t)0x803A9F31, (q31_t)0x07A72F45, - (q31_t)0x8037A7AC, (q31_t)0x077501BE, (q31_t)0x8034C3DC, - (q31_t)0x0742D310, (q31_t)0x8031F3C1, (q31_t)0x0710A344, - (q31_t)0x802F375C, (q31_t)0x06DE7261, (q31_t)0x802C8EAD, - (q31_t)0x06AC406F, (q31_t)0x8029F9B4, (q31_t)0x067A0D75, - (q31_t)0x80277872, (q31_t)0x0647D97C, (q31_t)0x80250AE7, - (q31_t)0x0615A48A, (q31_t)0x8022B113, (q31_t)0x05E36EA9, - (q31_t)0x80206AF8, (q31_t)0x05B137DF, (q31_t)0x801E3894, - (q31_t)0x057F0034, (q31_t)0x801C19E9, (q31_t)0x054CC7B0, - (q31_t)0x801A0EF7, (q31_t)0x051A8E5C, (q31_t)0x801817BF, - (q31_t)0x04E8543D, (q31_t)0x80163440, (q31_t)0x04B6195D, - (q31_t)0x8014647A, (q31_t)0x0483DDC3, (q31_t)0x8012A86F, - (q31_t)0x0451A176, (q31_t)0x8011001E, (q31_t)0x041F647F, - (q31_t)0x800F6B88, (q31_t)0x03ED26E6, (q31_t)0x800DEAAC, - (q31_t)0x03BAE8B1, (q31_t)0x800C7D8C, (q31_t)0x0388A9E9, - (q31_t)0x800B2427, (q31_t)0x03566A96, (q31_t)0x8009DE7D, - (q31_t)0x03242ABF, (q31_t)0x8008AC90, (q31_t)0x02F1EA6B, - (q31_t)0x80078E5E, (q31_t)0x02BFA9A4, (q31_t)0x800683E8, - (q31_t)0x028D6870, (q31_t)0x80058D2E, (q31_t)0x025B26D7, - (q31_t)0x8004AA31, (q31_t)0x0228E4E1, (q31_t)0x8003DAF0, - (q31_t)0x01F6A296, (q31_t)0x80031F6C, (q31_t)0x01C45FFE, - (q31_t)0x800277A5, (q31_t)0x01921D1F, (q31_t)0x8001E39B, - (q31_t)0x015FDA03, (q31_t)0x8001634D, (q31_t)0x012D96B0, - (q31_t)0x8000F6BD, (q31_t)0x00FB532F, (q31_t)0x80009DE9, - (q31_t)0x00C90F88, (q31_t)0x800058D3, (q31_t)0x0096CBC1, - (q31_t)0x8000277A, (q31_t)0x006487E3, (q31_t)0x800009DE, - (q31_t)0x003243F5, (q31_t)0x80000000, (q31_t)0x00000000, - (q31_t)0x800009DE, (q31_t)0xFFCDBC0A, (q31_t)0x8000277A, - (q31_t)0xFF9B781D, (q31_t)0x800058D3, (q31_t)0xFF69343E, - (q31_t)0x80009DE9, (q31_t)0xFF36F078, (q31_t)0x8000F6BD, - (q31_t)0xFF04ACD0, (q31_t)0x8001634D, (q31_t)0xFED2694F, - (q31_t)0x8001E39B, (q31_t)0xFEA025FC, (q31_t)0x800277A5, - (q31_t)0xFE6DE2E0, (q31_t)0x80031F6C, (q31_t)0xFE3BA001, - (q31_t)0x8003DAF0, (q31_t)0xFE095D69, (q31_t)0x8004AA31, - (q31_t)0xFDD71B1E, (q31_t)0x80058D2E, (q31_t)0xFDA4D928, - (q31_t)0x800683E8, (q31_t)0xFD72978F, (q31_t)0x80078E5E, - (q31_t)0xFD40565B, (q31_t)0x8008AC90, (q31_t)0xFD0E1594, - (q31_t)0x8009DE7D, (q31_t)0xFCDBD541, (q31_t)0x800B2427, - (q31_t)0xFCA99569, (q31_t)0x800C7D8C, (q31_t)0xFC775616, - (q31_t)0x800DEAAC, (q31_t)0xFC45174E, (q31_t)0x800F6B88, - (q31_t)0xFC12D919, (q31_t)0x8011001E, (q31_t)0xFBE09B80, - (q31_t)0x8012A86F, (q31_t)0xFBAE5E89, (q31_t)0x8014647A, - (q31_t)0xFB7C223C, (q31_t)0x80163440, (q31_t)0xFB49E6A2, - (q31_t)0x801817BF, (q31_t)0xFB17ABC2, (q31_t)0x801A0EF7, - (q31_t)0xFAE571A4, (q31_t)0x801C19E9, (q31_t)0xFAB3384F, - (q31_t)0x801E3894, (q31_t)0xFA80FFCB, (q31_t)0x80206AF8, - (q31_t)0xFA4EC820, (q31_t)0x8022B113, (q31_t)0xFA1C9156, - (q31_t)0x80250AE7, (q31_t)0xF9EA5B75, (q31_t)0x80277872, - (q31_t)0xF9B82683, (q31_t)0x8029F9B4, (q31_t)0xF985F28A, - (q31_t)0x802C8EAD, (q31_t)0xF953BF90, (q31_t)0x802F375C, - (q31_t)0xF9218D9E, (q31_t)0x8031F3C1, (q31_t)0xF8EF5CBB, - (q31_t)0x8034C3DC, (q31_t)0xF8BD2CEF, (q31_t)0x8037A7AC, - (q31_t)0xF88AFE41, (q31_t)0x803A9F31, (q31_t)0xF858D0BA, - (q31_t)0x803DAA69, (q31_t)0xF826A461, (q31_t)0x8040C956, - (q31_t)0xF7F4793E, (q31_t)0x8043FBF6, (q31_t)0xF7C24F58, - (q31_t)0x80474248, (q31_t)0xF79026B8, (q31_t)0x804A9C4D, - (q31_t)0xF75DFF65, (q31_t)0x804E0A03, (q31_t)0xF72BD967, - (q31_t)0x80518B6B, (q31_t)0xF6F9B4C5, (q31_t)0x80552083, - (q31_t)0xF6C79188, (q31_t)0x8058C94C, (q31_t)0xF6956FB6, - (q31_t)0x805C85C3, (q31_t)0xF6634F58, (q31_t)0x806055EA, - (q31_t)0xF6313076, (q31_t)0x806439C0, (q31_t)0xF5FF1317, - (q31_t)0x80683143, (q31_t)0xF5CCF743, (q31_t)0x806C3C73, - (q31_t)0xF59ADD01, (q31_t)0x80705B50, (q31_t)0xF568C45A, - (q31_t)0x80748DD9, (q31_t)0xF536AD55, (q31_t)0x8078D40D, - (q31_t)0xF50497FA, (q31_t)0x807D2DEB, (q31_t)0xF4D28451, - (q31_t)0x80819B74, (q31_t)0xF4A07260, (q31_t)0x80861CA5, - (q31_t)0xF46E6231, (q31_t)0x808AB180, (q31_t)0xF43C53CA, - (q31_t)0x808F5A02, (q31_t)0xF40A4734, (q31_t)0x8094162B, - (q31_t)0xF3D83C76, (q31_t)0x8098E5FB, (q31_t)0xF3A63398, - (q31_t)0x809DC970, (q31_t)0xF3742CA1, (q31_t)0x80A2C08B, - (q31_t)0xF342279A, (q31_t)0x80A7CB49, (q31_t)0xF310248A, - (q31_t)0x80ACE9AB, (q31_t)0xF2DE2378, (q31_t)0x80B21BAF, - (q31_t)0xF2AC246D, (q31_t)0x80B76155, (q31_t)0xF27A2770, - (q31_t)0x80BCBA9C, (q31_t)0xF2482C89, (q31_t)0x80C22783, - (q31_t)0xF21633C0, (q31_t)0x80C7A80A, (q31_t)0xF1E43D1C, - (q31_t)0x80CD3C2F, (q31_t)0xF1B248A5, (q31_t)0x80D2E3F1, - (q31_t)0xF1805662, (q31_t)0x80D89F51, (q31_t)0xF14E665C, - (q31_t)0x80DE6E4C, (q31_t)0xF11C789A, (q31_t)0x80E450E2, - (q31_t)0xF0EA8D23, (q31_t)0x80EA4712, (q31_t)0xF0B8A401, - (q31_t)0x80F050DB, (q31_t)0xF086BD39, (q31_t)0x80F66E3C, - (q31_t)0xF054D8D4, (q31_t)0x80FC9F35, (q31_t)0xF022F6DA, - (q31_t)0x8102E3C3, (q31_t)0xEFF11752, (q31_t)0x81093BE8, - (q31_t)0xEFBF3A44, (q31_t)0x810FA7A0, (q31_t)0xEF8D5FB8, - (q31_t)0x811626EC, (q31_t)0xEF5B87B5, (q31_t)0x811CB9CA, - (q31_t)0xEF29B243, (q31_t)0x81236039, (q31_t)0xEEF7DF6A, - (q31_t)0x812A1A39, (q31_t)0xEEC60F31, (q31_t)0x8130E7C8, - (q31_t)0xEE9441A0, (q31_t)0x8137C8E6, (q31_t)0xEE6276BF, - (q31_t)0x813EBD90, (q31_t)0xEE30AE95, (q31_t)0x8145C5C6, - (q31_t)0xEDFEE92B, (q31_t)0x814CE188, (q31_t)0xEDCD2687, - (q31_t)0x815410D3, (q31_t)0xED9B66B2, (q31_t)0x815B53A8, - (q31_t)0xED69A9B2, (q31_t)0x8162AA03, (q31_t)0xED37EF91, - (q31_t)0x816A13E6, (q31_t)0xED063855, (q31_t)0x8171914E, - (q31_t)0xECD48406, (q31_t)0x8179223A, (q31_t)0xECA2D2AC, - (q31_t)0x8180C6A9, (q31_t)0xEC71244F, (q31_t)0x81887E9A, - (q31_t)0xEC3F78F5, (q31_t)0x81904A0C, (q31_t)0xEC0DD0A8, - (q31_t)0x819828FD, (q31_t)0xEBDC2B6D, (q31_t)0x81A01B6C, - (q31_t)0xEBAA894E, (q31_t)0x81A82159, (q31_t)0xEB78EA52, - (q31_t)0x81B03AC1, (q31_t)0xEB474E80, (q31_t)0x81B867A4, - (q31_t)0xEB15B5E0, (q31_t)0x81C0A801, (q31_t)0xEAE4207A, - (q31_t)0x81C8FBD5, (q31_t)0xEAB28E55, (q31_t)0x81D16320, - (q31_t)0xEA80FF79, (q31_t)0x81D9DDE1, (q31_t)0xEA4F73EE, - (q31_t)0x81E26C16, (q31_t)0xEA1DEBBB, (q31_t)0x81EB0DBD, - (q31_t)0xE9EC66E8, (q31_t)0x81F3C2D7, (q31_t)0xE9BAE57C, - (q31_t)0x81FC8B60, (q31_t)0xE9896780, (q31_t)0x82056758, - (q31_t)0xE957ECFB, (q31_t)0x820E56BE, (q31_t)0xE92675F4, - (q31_t)0x8217598F, (q31_t)0xE8F50273, (q31_t)0x82206FCB, - (q31_t)0xE8C3927F, (q31_t)0x82299971, (q31_t)0xE8922621, - (q31_t)0x8232D67E, (q31_t)0xE860BD60, (q31_t)0x823C26F2, - (q31_t)0xE82F5844, (q31_t)0x82458ACB, (q31_t)0xE7FDF6D3, - (q31_t)0x824F0208, (q31_t)0xE7CC9917, (q31_t)0x82588CA6, - (q31_t)0xE79B3F16, (q31_t)0x82622AA5, (q31_t)0xE769E8D8, - (q31_t)0x826BDC04, (q31_t)0xE7389664, (q31_t)0x8275A0C0, - (q31_t)0xE70747C3, (q31_t)0x827F78D8, (q31_t)0xE6D5FCFC, - (q31_t)0x8289644A, (q31_t)0xE6A4B616, (q31_t)0x82936316, - (q31_t)0xE6737319, (q31_t)0x829D753A, (q31_t)0xE642340D, - (q31_t)0x82A79AB3, (q31_t)0xE610F8F9, (q31_t)0x82B1D381, - (q31_t)0xE5DFC1E4, (q31_t)0x82BC1FA1, (q31_t)0xE5AE8ED8, - (q31_t)0x82C67F13, (q31_t)0xE57D5FDA, (q31_t)0x82D0F1D5, - (q31_t)0xE54C34F3, (q31_t)0x82DB77E5, (q31_t)0xE51B0E2A, - (q31_t)0x82E61141, (q31_t)0xE4E9EB86, (q31_t)0x82F0BDE8, - (q31_t)0xE4B8CD10, (q31_t)0x82FB7DD8, (q31_t)0xE487B2CF, - (q31_t)0x8306510F, (q31_t)0xE4569CCB, (q31_t)0x8311378C, - (q31_t)0xE4258B0A, (q31_t)0x831C314E, (q31_t)0xE3F47D95, - (q31_t)0x83273E52, (q31_t)0xE3C37473, (q31_t)0x83325E97, - (q31_t)0xE3926FAC, (q31_t)0x833D921A, (q31_t)0xE3616F47, - (q31_t)0x8348D8DB, (q31_t)0xE330734C, (q31_t)0x835432D8, - (q31_t)0xE2FF7BC3, (q31_t)0x835FA00E, (q31_t)0xE2CE88B2, - (q31_t)0x836B207D, (q31_t)0xE29D9A22, (q31_t)0x8376B422, - (q31_t)0xE26CB01A, (q31_t)0x83825AFB, (q31_t)0xE23BCAA2, - (q31_t)0x838E1507, (q31_t)0xE20AE9C1, (q31_t)0x8399E244, - (q31_t)0xE1DA0D7E, (q31_t)0x83A5C2B0, (q31_t)0xE1A935E1, - (q31_t)0x83B1B649, (q31_t)0xE17862F3, (q31_t)0x83BDBD0D, - (q31_t)0xE14794B9, (q31_t)0x83C9D6FB, (q31_t)0xE116CB3D, - (q31_t)0x83D60411, (q31_t)0xE0E60684, (q31_t)0x83E2444D, - (q31_t)0xE0B54698, (q31_t)0x83EE97AC, (q31_t)0xE0848B7F, - (q31_t)0x83FAFE2E, (q31_t)0xE053D541, (q31_t)0x840777CF, - (q31_t)0xE02323E5, (q31_t)0x8414048F, (q31_t)0xDFF27773, - (q31_t)0x8420A46B, (q31_t)0xDFC1CFF2, (q31_t)0x842D5761, - (q31_t)0xDF912D6A, (q31_t)0x843A1D70, (q31_t)0xDF608FE3, - (q31_t)0x8446F695, (q31_t)0xDF2FF764, (q31_t)0x8453E2CE, - (q31_t)0xDEFF63F4, (q31_t)0x8460E21A, (q31_t)0xDECED59B, - (q31_t)0x846DF476, (q31_t)0xDE9E4C60, (q31_t)0x847B19E1, - (q31_t)0xDE6DC84B, (q31_t)0x84885257, (q31_t)0xDE3D4963, - (q31_t)0x84959DD9, (q31_t)0xDE0CCFB1, (q31_t)0x84A2FC62, - (q31_t)0xDDDC5B3A, (q31_t)0x84B06DF1, (q31_t)0xDDABEC07, - (q31_t)0x84BDF285, (q31_t)0xDD7B8220, (q31_t)0x84CB8A1B, - (q31_t)0xDD4B1D8B, (q31_t)0x84D934B0, (q31_t)0xDD1ABE51, - (q31_t)0x84E6F244, (q31_t)0xDCEA6478, (q31_t)0x84F4C2D3, - (q31_t)0xDCBA1008, (q31_t)0x8502A65C, (q31_t)0xDC89C108, - (q31_t)0x85109CDC, (q31_t)0xDC597781, (q31_t)0x851EA652, - (q31_t)0xDC293379, (q31_t)0x852CC2BA, (q31_t)0xDBF8F4F8, - (q31_t)0x853AF214, (q31_t)0xDBC8BC05, (q31_t)0x8549345C, - (q31_t)0xDB9888A8, (q31_t)0x85578991, (q31_t)0xDB685AE8, - (q31_t)0x8565F1B0, (q31_t)0xDB3832CD, (q31_t)0x85746CB7, - (q31_t)0xDB08105E, (q31_t)0x8582FAA4, (q31_t)0xDAD7F3A2, - (q31_t)0x85919B75, (q31_t)0xDAA7DCA1, (q31_t)0x85A04F28, - (q31_t)0xDA77CB62, (q31_t)0x85AF15B9, (q31_t)0xDA47BFED, - (q31_t)0x85BDEF27, (q31_t)0xDA17BA4A, (q31_t)0x85CCDB70, - (q31_t)0xD9E7BA7E, (q31_t)0x85DBDA91, (q31_t)0xD9B7C093, - (q31_t)0x85EAEC88, (q31_t)0xD987CC8F, (q31_t)0x85FA1152, - (q31_t)0xD957DE7A, (q31_t)0x860948EE, (q31_t)0xD927F65B, - (q31_t)0x86189359, (q31_t)0xD8F81439, (q31_t)0x8627F090, - (q31_t)0xD8C8381C, (q31_t)0x86376092, (q31_t)0xD898620C, - (q31_t)0x8646E35B, (q31_t)0xD868920F, (q31_t)0x865678EA, - (q31_t)0xD838C82D, (q31_t)0x8666213C, (q31_t)0xD809046D, - (q31_t)0x8675DC4E, (q31_t)0xD7D946D7, (q31_t)0x8685AA1F, - (q31_t)0xD7A98F73, (q31_t)0x86958AAB, (q31_t)0xD779DE46, - (q31_t)0x86A57DF1, (q31_t)0xD74A335A, (q31_t)0x86B583EE, - (q31_t)0xD71A8EB5, (q31_t)0x86C59C9F, (q31_t)0xD6EAF05E, - (q31_t)0x86D5C802, (q31_t)0xD6BB585D, (q31_t)0x86E60614, - (q31_t)0xD68BC6BA, (q31_t)0x86F656D3, (q31_t)0xD65C3B7B, - (q31_t)0x8706BA3C, (q31_t)0xD62CB6A7, (q31_t)0x8717304E, - (q31_t)0xD5FD3847, (q31_t)0x8727B904, (q31_t)0xD5CDC062, - (q31_t)0x8738545E, (q31_t)0xD59E4EFE, (q31_t)0x87490257, - (q31_t)0xD56EE424, (q31_t)0x8759C2EF, (q31_t)0xD53F7FDA, - (q31_t)0x876A9621, (q31_t)0xD5102227, (q31_t)0x877B7BEC, - (q31_t)0xD4E0CB14, (q31_t)0x878C744C, (q31_t)0xD4B17AA7, - (q31_t)0x879D7F40, (q31_t)0xD48230E8, (q31_t)0x87AE9CC5, - (q31_t)0xD452EDDE, (q31_t)0x87BFCCD7, (q31_t)0xD423B190, - (q31_t)0x87D10F75, (q31_t)0xD3F47C06, (q31_t)0x87E2649B, - (q31_t)0xD3C54D46, (q31_t)0x87F3CC47, (q31_t)0xD3962559, - (q31_t)0x88054677, (q31_t)0xD3670445, (q31_t)0x8816D327, - (q31_t)0xD337EA12, (q31_t)0x88287255, (q31_t)0xD308D6C6, - (q31_t)0x883A23FE, (q31_t)0xD2D9CA6A, (q31_t)0x884BE820, - (q31_t)0xD2AAC504, (q31_t)0x885DBEB7, (q31_t)0xD27BC69C, - (q31_t)0x886FA7C2, (q31_t)0xD24CCF38, (q31_t)0x8881A33C, - (q31_t)0xD21DDEE1, (q31_t)0x8893B124, (q31_t)0xD1EEF59E, - (q31_t)0x88A5D177, (q31_t)0xD1C01374, (q31_t)0x88B80431, - (q31_t)0xD191386D, (q31_t)0x88CA4951, (q31_t)0xD162648F, - (q31_t)0x88DCA0D3, (q31_t)0xD13397E1, (q31_t)0x88EF0AB4, - (q31_t)0xD104D26B, (q31_t)0x890186F1, (q31_t)0xD0D61433, - (q31_t)0x89141589, (q31_t)0xD0A75D42, (q31_t)0x8926B677, - (q31_t)0xD078AD9D, (q31_t)0x893969B9, (q31_t)0xD04A054D, - (q31_t)0x894C2F4C, (q31_t)0xD01B6459, (q31_t)0x895F072D, - (q31_t)0xCFECCAC7, (q31_t)0x8971F15A, (q31_t)0xCFBE389F, - (q31_t)0x8984EDCF, (q31_t)0xCF8FADE8, (q31_t)0x8997FC89, - (q31_t)0xCF612AAA, (q31_t)0x89AB1D86, (q31_t)0xCF32AEEB, - (q31_t)0x89BE50C3, (q31_t)0xCF043AB2, (q31_t)0x89D1963C, - (q31_t)0xCED5CE08, (q31_t)0x89E4EDEE, (q31_t)0xCEA768F2, - (q31_t)0x89F857D8, (q31_t)0xCE790B78, (q31_t)0x8A0BD3F5, - (q31_t)0xCE4AB5A2, (q31_t)0x8A1F6242, (q31_t)0xCE1C6776, - (q31_t)0x8A3302BD, (q31_t)0xCDEE20FC, (q31_t)0x8A46B563, - (q31_t)0xCDBFE23A, (q31_t)0x8A5A7A30, (q31_t)0xCD91AB38, - (q31_t)0x8A6E5122, (q31_t)0xCD637BFD, (q31_t)0x8A823A35, - (q31_t)0xCD355490, (q31_t)0x8A963567, (q31_t)0xCD0734F8, - (q31_t)0x8AAA42B4, (q31_t)0xCCD91D3D, (q31_t)0x8ABE6219, - (q31_t)0xCCAB0D65, (q31_t)0x8AD29393, (q31_t)0xCC7D0577, - (q31_t)0x8AE6D71F, (q31_t)0xCC4F057B, (q31_t)0x8AFB2CBA, - (q31_t)0xCC210D78, (q31_t)0x8B0F9461, (q31_t)0xCBF31D75, - (q31_t)0x8B240E10, (q31_t)0xCBC53578, (q31_t)0x8B3899C5, - (q31_t)0xCB975589, (q31_t)0x8B4D377C, (q31_t)0xCB697DB0, - (q31_t)0x8B61E732, (q31_t)0xCB3BADF2, (q31_t)0x8B76A8E4, - (q31_t)0xCB0DE658, (q31_t)0x8B8B7C8F, (q31_t)0xCAE026E8, - (q31_t)0x8BA0622F, (q31_t)0xCAB26FA9, (q31_t)0x8BB559C1, - (q31_t)0xCA84C0A2, (q31_t)0x8BCA6342, (q31_t)0xCA5719DB, - (q31_t)0x8BDF7EAF, (q31_t)0xCA297B5A, (q31_t)0x8BF4AC05, - (q31_t)0xC9FBE527, (q31_t)0x8C09EB40, (q31_t)0xC9CE5748, - (q31_t)0x8C1F3C5C, (q31_t)0xC9A0D1C4, (q31_t)0x8C349F58, - (q31_t)0xC97354A3, (q31_t)0x8C4A142F, (q31_t)0xC945DFEC, - (q31_t)0x8C5F9ADD, (q31_t)0xC91873A5, (q31_t)0x8C753361, - (q31_t)0xC8EB0FD6, (q31_t)0x8C8ADDB6, (q31_t)0xC8BDB485, - (q31_t)0x8CA099D9, (q31_t)0xC89061BA, (q31_t)0x8CB667C7, - (q31_t)0xC863177B, (q31_t)0x8CCC477D, (q31_t)0xC835D5D0, - (q31_t)0x8CE238F6, (q31_t)0xC8089CBF, (q31_t)0x8CF83C30, - (q31_t)0xC7DB6C50, (q31_t)0x8D0E5127, (q31_t)0xC7AE4489, - (q31_t)0x8D2477D8, (q31_t)0xC7812571, (q31_t)0x8D3AB03F, - (q31_t)0xC7540F10, (q31_t)0x8D50FA59, (q31_t)0xC727016C, - (q31_t)0x8D675623, (q31_t)0xC6F9FC8D, (q31_t)0x8D7DC399, - (q31_t)0xC6CD0079, (q31_t)0x8D9442B7, (q31_t)0xC6A00D36, - (q31_t)0x8DAAD37B, (q31_t)0xC67322CD, (q31_t)0x8DC175E0, - (q31_t)0xC6464144, (q31_t)0x8DD829E4, (q31_t)0xC61968A2, - (q31_t)0x8DEEEF82, (q31_t)0xC5EC98ED, (q31_t)0x8E05C6B7, - (q31_t)0xC5BFD22E, (q31_t)0x8E1CAF80, (q31_t)0xC593146A, - (q31_t)0x8E33A9D9, (q31_t)0xC5665FA8, (q31_t)0x8E4AB5BF, - (q31_t)0xC539B3F0, (q31_t)0x8E61D32D, (q31_t)0xC50D1148, - (q31_t)0x8E790222, (q31_t)0xC4E077B8, (q31_t)0x8E904298, - (q31_t)0xC4B3E746, (q31_t)0x8EA7948C, (q31_t)0xC4875FF8, - (q31_t)0x8EBEF7FB, (q31_t)0xC45AE1D7, (q31_t)0x8ED66CE1, - (q31_t)0xC42E6CE8, (q31_t)0x8EEDF33B, (q31_t)0xC4020132, - (q31_t)0x8F058B04, (q31_t)0xC3D59EBD, (q31_t)0x8F1D343A, - (q31_t)0xC3A9458F, (q31_t)0x8F34EED8, (q31_t)0xC37CF5B0, - (q31_t)0x8F4CBADB, (q31_t)0xC350AF25, (q31_t)0x8F64983F, - (q31_t)0xC32471F6, (q31_t)0x8F7C8701, (q31_t)0xC2F83E2A, - (q31_t)0x8F94871D, (q31_t)0xC2CC13C7, (q31_t)0x8FAC988E, - (q31_t)0xC29FF2D4, (q31_t)0x8FC4BB53, (q31_t)0xC273DB58, - (q31_t)0x8FDCEF66, (q31_t)0xC247CD5A, (q31_t)0x8FF534C4, - (q31_t)0xC21BC8E0, (q31_t)0x900D8B69, (q31_t)0xC1EFCDF2, - (q31_t)0x9025F352, (q31_t)0xC1C3DC96, (q31_t)0x903E6C7A, - (q31_t)0xC197F4D3, (q31_t)0x9056F6DF, (q31_t)0xC16C16B0, - (q31_t)0x906F927B, (q31_t)0xC1404233, (q31_t)0x90883F4C, - (q31_t)0xC1147763, (q31_t)0x90A0FD4E, (q31_t)0xC0E8B648, - (q31_t)0x90B9CC7C, (q31_t)0xC0BCFEE7, (q31_t)0x90D2ACD3, - (q31_t)0xC0915147, (q31_t)0x90EB9E50, (q31_t)0xC065AD70, - (q31_t)0x9104A0ED, (q31_t)0xC03A1368, (q31_t)0x911DB4A8, - (q31_t)0xC00E8335, (q31_t)0x9136D97D, (q31_t)0xBFE2FCDF, - (q31_t)0x91500F67, (q31_t)0xBFB7806C, (q31_t)0x91695663, - (q31_t)0xBF8C0DE2, (q31_t)0x9182AE6C, (q31_t)0xBF60A54A, - (q31_t)0x919C1780, (q31_t)0xBF3546A8, (q31_t)0x91B5919A, - (q31_t)0xBF09F204, (q31_t)0x91CF1CB6, (q31_t)0xBEDEA765, - (q31_t)0x91E8B8D0, (q31_t)0xBEB366D1, (q31_t)0x920265E4, - (q31_t)0xBE88304F, (q31_t)0x921C23EE, (q31_t)0xBE5D03E5, - (q31_t)0x9235F2EB, (q31_t)0xBE31E19B, (q31_t)0x924FD2D6, - (q31_t)0xBE06C977, (q31_t)0x9269C3AC, (q31_t)0xBDDBBB7F, - (q31_t)0x9283C567, (q31_t)0xBDB0B7BA, (q31_t)0x929DD805, - (q31_t)0xBD85BE2F, (q31_t)0x92B7FB82, (q31_t)0xBD5ACEE5, - (q31_t)0x92D22FD8, (q31_t)0xBD2FE9E1, (q31_t)0x92EC7505, - (q31_t)0xBD050F2C, (q31_t)0x9306CB04, (q31_t)0xBCDA3ECA, - (q31_t)0x932131D1, (q31_t)0xBCAF78C3, (q31_t)0x933BA968, - (q31_t)0xBC84BD1E, (q31_t)0x935631C5, (q31_t)0xBC5A0BE1, - (q31_t)0x9370CAE4, (q31_t)0xBC2F6513, (q31_t)0x938B74C0, - (q31_t)0xBC04C8BA, (q31_t)0x93A62F56, (q31_t)0xBBDA36DC, - (q31_t)0x93C0FAA2, (q31_t)0xBBAFAF81, (q31_t)0x93DBD69F, - (q31_t)0xBB8532AF, (q31_t)0x93F6C34A, (q31_t)0xBB5AC06C, - (q31_t)0x9411C09D, (q31_t)0xBB3058C0, (q31_t)0x942CCE95, - (q31_t)0xBB05FBB0, (q31_t)0x9447ED2F, (q31_t)0xBADBA943, - (q31_t)0x94631C64, (q31_t)0xBAB1617F, (q31_t)0x947E5C32, - (q31_t)0xBA87246C, (q31_t)0x9499AC95, (q31_t)0xBA5CF210, - (q31_t)0x94B50D87, (q31_t)0xBA32CA70, (q31_t)0x94D07F05, - (q31_t)0xBA08AD94, (q31_t)0x94EC010B, (q31_t)0xB9DE9B83, - (q31_t)0x95079393, (q31_t)0xB9B49442, (q31_t)0x9523369B, - (q31_t)0xB98A97D8, (q31_t)0x953EEA1E, (q31_t)0xB960A64B, - (q31_t)0x955AAE17, (q31_t)0xB936BFA3, (q31_t)0x95768282, - (q31_t)0xB90CE3E6, (q31_t)0x9592675B, (q31_t)0xB8E31319, - (q31_t)0x95AE5C9E, (q31_t)0xB8B94D44, (q31_t)0x95CA6246, - (q31_t)0xB88F926C, (q31_t)0x95E6784F, (q31_t)0xB865E299, - (q31_t)0x96029EB5, (q31_t)0xB83C3DD1, (q31_t)0x961ED573, - (q31_t)0xB812A419, (q31_t)0x963B1C85, (q31_t)0xB7E9157A, - (q31_t)0x965773E7, (q31_t)0xB7BF91F8, (q31_t)0x9673DB94, - (q31_t)0xB796199B, (q31_t)0x96905387, (q31_t)0xB76CAC68, - (q31_t)0x96ACDBBD, (q31_t)0xB7434A67, (q31_t)0x96C97431, - (q31_t)0xB719F39D, (q31_t)0x96E61CDF, (q31_t)0xB6F0A811, - (q31_t)0x9702D5C2, (q31_t)0xB6C767CA, (q31_t)0x971F9ED6, - (q31_t)0xB69E32CD, (q31_t)0x973C7816, (q31_t)0xB6750921, - (q31_t)0x9759617E, (q31_t)0xB64BEACC, (q31_t)0x97765B0A, - (q31_t)0xB622D7D5, (q31_t)0x979364B5, (q31_t)0xB5F9D042, - (q31_t)0x97B07E7A, (q31_t)0xB5D0D41A, (q31_t)0x97CDA855, - (q31_t)0xB5A7E362, (q31_t)0x97EAE241, (q31_t)0xB57EFE21, - (q31_t)0x98082C3B, (q31_t)0xB556245E, (q31_t)0x9825863D, - (q31_t)0xB52D561E, (q31_t)0x9842F043, (q31_t)0xB5049368, - (q31_t)0x98606A48, (q31_t)0xB4DBDC42, (q31_t)0x987DF449, - (q31_t)0xB4B330B2, (q31_t)0x989B8E3F, (q31_t)0xB48A90C0, - (q31_t)0x98B93828, (q31_t)0xB461FC70, (q31_t)0x98D6F1FE, - (q31_t)0xB43973C9, (q31_t)0x98F4BBBC, (q31_t)0xB410F6D2, - (q31_t)0x9912955E, (q31_t)0xB3E88591, (q31_t)0x99307EE0, - (q31_t)0xB3C0200C, (q31_t)0x994E783C, (q31_t)0xB397C649, - (q31_t)0x996C816F, (q31_t)0xB36F784E, (q31_t)0x998A9A73, - (q31_t)0xB3473622, (q31_t)0x99A8C344, (q31_t)0xB31EFFCB, - (q31_t)0x99C6FBDE, (q31_t)0xB2F6D54F, (q31_t)0x99E5443A, - (q31_t)0xB2CEB6B5, (q31_t)0x9A039C56, (q31_t)0xB2A6A401, - (q31_t)0x9A22042C, (q31_t)0xB27E9D3B, (q31_t)0x9A407BB8, - (q31_t)0xB256A26A, (q31_t)0x9A5F02F5, (q31_t)0xB22EB392, - (q31_t)0x9A7D99DD, (q31_t)0xB206D0BA, (q31_t)0x9A9C406D, - (q31_t)0xB1DEF9E8, (q31_t)0x9ABAF6A0, (q31_t)0xB1B72F23, - (q31_t)0x9AD9BC71, (q31_t)0xB18F7070, (q31_t)0x9AF891DB, - (q31_t)0xB167BDD6, (q31_t)0x9B1776D9, (q31_t)0xB140175B, - (q31_t)0x9B366B67, (q31_t)0xB1187D05, (q31_t)0x9B556F80, - (q31_t)0xB0F0EEDA, (q31_t)0x9B748320, (q31_t)0xB0C96CDF, - (q31_t)0x9B93A640, (q31_t)0xB0A1F71C, (q31_t)0x9BB2D8DD, - (q31_t)0xB07A8D97, (q31_t)0x9BD21AF2, (q31_t)0xB0533055, - (q31_t)0x9BF16C7A, (q31_t)0xB02BDF5C, (q31_t)0x9C10CD70, - (q31_t)0xB0049AB2, (q31_t)0x9C303DCF, (q31_t)0xAFDD625F, - (q31_t)0x9C4FBD92, (q31_t)0xAFB63667, (q31_t)0x9C6F4CB5, - (q31_t)0xAF8F16D0, (q31_t)0x9C8EEB33, (q31_t)0xAF6803A1, - (q31_t)0x9CAE9907, (q31_t)0xAF40FCE0, (q31_t)0x9CCE562B, - (q31_t)0xAF1A0293, (q31_t)0x9CEE229C, (q31_t)0xAEF314BF, - (q31_t)0x9D0DFE53, (q31_t)0xAECC336B, (q31_t)0x9D2DE94D, - (q31_t)0xAEA55E9D, (q31_t)0x9D4DE384, (q31_t)0xAE7E965B, - (q31_t)0x9D6DECF4, (q31_t)0xAE57DAAA, (q31_t)0x9D8E0596, - (q31_t)0xAE312B91, (q31_t)0x9DAE2D68, (q31_t)0xAE0A8916, - (q31_t)0x9DCE6462, (q31_t)0xADE3F33E, (q31_t)0x9DEEAA82, - (q31_t)0xADBD6A10, (q31_t)0x9E0EFFC1, (q31_t)0xAD96ED91, - (q31_t)0x9E2F641A, (q31_t)0xAD707DC8, (q31_t)0x9E4FD789, - (q31_t)0xAD4A1ABA, (q31_t)0x9E705A09, (q31_t)0xAD23C46D, - (q31_t)0x9E90EB94, (q31_t)0xACFD7AE8, (q31_t)0x9EB18C26, - (q31_t)0xACD73E30, (q31_t)0x9ED23BB9, (q31_t)0xACB10E4A, - (q31_t)0x9EF2FA48, (q31_t)0xAC8AEB3E, (q31_t)0x9F13C7D0, - (q31_t)0xAC64D510, (q31_t)0x9F34A449, (q31_t)0xAC3ECBC7, - (q31_t)0x9F558FB0, (q31_t)0xAC18CF68, (q31_t)0x9F7689FF, - (q31_t)0xABF2DFFA, (q31_t)0x9F979331, (q31_t)0xABCCFD82, - (q31_t)0x9FB8AB41, (q31_t)0xABA72806, (q31_t)0x9FD9D22A, - (q31_t)0xAB815F8C, (q31_t)0x9FFB07E7, (q31_t)0xAB5BA41A, - (q31_t)0xA01C4C72, (q31_t)0xAB35F5B5, (q31_t)0xA03D9FC7, - (q31_t)0xAB105464, (q31_t)0xA05F01E1, (q31_t)0xAAEAC02B, - (q31_t)0xA08072BA, (q31_t)0xAAC53912, (q31_t)0xA0A1F24C, - (q31_t)0xAA9FBF1D, (q31_t)0xA0C38094, (q31_t)0xAA7A5253, - (q31_t)0xA0E51D8C, (q31_t)0xAA54F2B9, (q31_t)0xA106C92E, - (q31_t)0xAA2FA055, (q31_t)0xA1288376, (q31_t)0xAA0A5B2D, - (q31_t)0xA14A4C5E, (q31_t)0xA9E52347, (q31_t)0xA16C23E1, - (q31_t)0xA9BFF8A8, (q31_t)0xA18E09F9, (q31_t)0xA99ADB56, - (q31_t)0xA1AFFEA2, (q31_t)0xA975CB56, (q31_t)0xA1D201D7, - (q31_t)0xA950C8AF, (q31_t)0xA1F41391, (q31_t)0xA92BD366, - (q31_t)0xA21633CD, (q31_t)0xA906EB81, (q31_t)0xA2386283, - (q31_t)0xA8E21106, (q31_t)0xA25A9FB1, (q31_t)0xA8BD43FA, - (q31_t)0xA27CEB4F, (q31_t)0xA8988463, (q31_t)0xA29F4559, - (q31_t)0xA873D246, (q31_t)0xA2C1ADC9, (q31_t)0xA84F2DA9, - (q31_t)0xA2E4249A, (q31_t)0xA82A9693, (q31_t)0xA306A9C7, - (q31_t)0xA8060D08, (q31_t)0xA3293D4B, (q31_t)0xA7E1910E, - (q31_t)0xA34BDF20, (q31_t)0xA7BD22AB, (q31_t)0xA36E8F40, - (q31_t)0xA798C1E4, (q31_t)0xA3914DA7, (q31_t)0xA7746EC0, - (q31_t)0xA3B41A4F, (q31_t)0xA7502943, (q31_t)0xA3D6F533, - (q31_t)0xA72BF173, (q31_t)0xA3F9DE4D, (q31_t)0xA707C756, - (q31_t)0xA41CD598, (q31_t)0xA6E3AAF2, (q31_t)0xA43FDB0F, - (q31_t)0xA6BF9C4B, (q31_t)0xA462EEAC, (q31_t)0xA69B9B68, - (q31_t)0xA4861069, (q31_t)0xA677A84E, (q31_t)0xA4A94042, - (q31_t)0xA653C302, (q31_t)0xA4CC7E31, (q31_t)0xA62FEB8B, - (q31_t)0xA4EFCA31, (q31_t)0xA60C21ED, (q31_t)0xA513243B, - (q31_t)0xA5E8662F, (q31_t)0xA5368C4B, (q31_t)0xA5C4B855, - (q31_t)0xA55A025B, (q31_t)0xA5A11865, (q31_t)0xA57D8666, - (q31_t)0xA57D8666, (q31_t)0xA5A11865, (q31_t)0xA55A025B, - (q31_t)0xA5C4B855, (q31_t)0xA5368C4B, (q31_t)0xA5E8662F, - (q31_t)0xA513243B, (q31_t)0xA60C21ED, (q31_t)0xA4EFCA31, - (q31_t)0xA62FEB8B, (q31_t)0xA4CC7E31, (q31_t)0xA653C302, - (q31_t)0xA4A94042, (q31_t)0xA677A84E, (q31_t)0xA4861069, - (q31_t)0xA69B9B68, (q31_t)0xA462EEAC, (q31_t)0xA6BF9C4B, - (q31_t)0xA43FDB0F, (q31_t)0xA6E3AAF2, (q31_t)0xA41CD598, - (q31_t)0xA707C756, (q31_t)0xA3F9DE4D, (q31_t)0xA72BF173, - (q31_t)0xA3D6F533, (q31_t)0xA7502943, (q31_t)0xA3B41A4F, - (q31_t)0xA7746EC0, (q31_t)0xA3914DA7, (q31_t)0xA798C1E4, - (q31_t)0xA36E8F40, (q31_t)0xA7BD22AB, (q31_t)0xA34BDF20, - (q31_t)0xA7E1910E, (q31_t)0xA3293D4B, (q31_t)0xA8060D08, - (q31_t)0xA306A9C7, (q31_t)0xA82A9693, (q31_t)0xA2E4249A, - (q31_t)0xA84F2DA9, (q31_t)0xA2C1ADC9, (q31_t)0xA873D246, - (q31_t)0xA29F4559, (q31_t)0xA8988463, (q31_t)0xA27CEB4F, - (q31_t)0xA8BD43FA, (q31_t)0xA25A9FB1, (q31_t)0xA8E21106, - (q31_t)0xA2386283, (q31_t)0xA906EB81, (q31_t)0xA21633CD, - (q31_t)0xA92BD366, (q31_t)0xA1F41391, (q31_t)0xA950C8AF, - (q31_t)0xA1D201D7, (q31_t)0xA975CB56, (q31_t)0xA1AFFEA2, - (q31_t)0xA99ADB56, (q31_t)0xA18E09F9, (q31_t)0xA9BFF8A8, - (q31_t)0xA16C23E1, (q31_t)0xA9E52347, (q31_t)0xA14A4C5E, - (q31_t)0xAA0A5B2D, (q31_t)0xA1288376, (q31_t)0xAA2FA055, - (q31_t)0xA106C92E, (q31_t)0xAA54F2B9, (q31_t)0xA0E51D8C, - (q31_t)0xAA7A5253, (q31_t)0xA0C38094, (q31_t)0xAA9FBF1D, - (q31_t)0xA0A1F24C, (q31_t)0xAAC53912, (q31_t)0xA08072BA, - (q31_t)0xAAEAC02B, (q31_t)0xA05F01E1, (q31_t)0xAB105464, - (q31_t)0xA03D9FC7, (q31_t)0xAB35F5B5, (q31_t)0xA01C4C72, - (q31_t)0xAB5BA41A, (q31_t)0x9FFB07E7, (q31_t)0xAB815F8C, - (q31_t)0x9FD9D22A, (q31_t)0xABA72806, (q31_t)0x9FB8AB41, - (q31_t)0xABCCFD82, (q31_t)0x9F979331, (q31_t)0xABF2DFFA, - (q31_t)0x9F7689FF, (q31_t)0xAC18CF68, (q31_t)0x9F558FB0, - (q31_t)0xAC3ECBC7, (q31_t)0x9F34A449, (q31_t)0xAC64D510, - (q31_t)0x9F13C7D0, (q31_t)0xAC8AEB3E, (q31_t)0x9EF2FA48, - (q31_t)0xACB10E4A, (q31_t)0x9ED23BB9, (q31_t)0xACD73E30, - (q31_t)0x9EB18C26, (q31_t)0xACFD7AE8, (q31_t)0x9E90EB94, - (q31_t)0xAD23C46D, (q31_t)0x9E705A09, (q31_t)0xAD4A1ABA, - (q31_t)0x9E4FD789, (q31_t)0xAD707DC8, (q31_t)0x9E2F641A, - (q31_t)0xAD96ED91, (q31_t)0x9E0EFFC1, (q31_t)0xADBD6A10, - (q31_t)0x9DEEAA82, (q31_t)0xADE3F33E, (q31_t)0x9DCE6462, - (q31_t)0xAE0A8916, (q31_t)0x9DAE2D68, (q31_t)0xAE312B91, - (q31_t)0x9D8E0596, (q31_t)0xAE57DAAA, (q31_t)0x9D6DECF4, - (q31_t)0xAE7E965B, (q31_t)0x9D4DE384, (q31_t)0xAEA55E9D, - (q31_t)0x9D2DE94D, (q31_t)0xAECC336B, (q31_t)0x9D0DFE53, - (q31_t)0xAEF314BF, (q31_t)0x9CEE229C, (q31_t)0xAF1A0293, - (q31_t)0x9CCE562B, (q31_t)0xAF40FCE0, (q31_t)0x9CAE9907, - (q31_t)0xAF6803A1, (q31_t)0x9C8EEB33, (q31_t)0xAF8F16D0, - (q31_t)0x9C6F4CB5, (q31_t)0xAFB63667, (q31_t)0x9C4FBD92, - (q31_t)0xAFDD625F, (q31_t)0x9C303DCF, (q31_t)0xB0049AB2, - (q31_t)0x9C10CD70, (q31_t)0xB02BDF5C, (q31_t)0x9BF16C7A, - (q31_t)0xB0533055, (q31_t)0x9BD21AF2, (q31_t)0xB07A8D97, - (q31_t)0x9BB2D8DD, (q31_t)0xB0A1F71C, (q31_t)0x9B93A640, - (q31_t)0xB0C96CDF, (q31_t)0x9B748320, (q31_t)0xB0F0EEDA, - (q31_t)0x9B556F80, (q31_t)0xB1187D05, (q31_t)0x9B366B67, - (q31_t)0xB140175B, (q31_t)0x9B1776D9, (q31_t)0xB167BDD6, - (q31_t)0x9AF891DB, (q31_t)0xB18F7070, (q31_t)0x9AD9BC71, - (q31_t)0xB1B72F23, (q31_t)0x9ABAF6A0, (q31_t)0xB1DEF9E8, - (q31_t)0x9A9C406D, (q31_t)0xB206D0BA, (q31_t)0x9A7D99DD, - (q31_t)0xB22EB392, (q31_t)0x9A5F02F5, (q31_t)0xB256A26A, - (q31_t)0x9A407BB8, (q31_t)0xB27E9D3B, (q31_t)0x9A22042C, - (q31_t)0xB2A6A401, (q31_t)0x9A039C56, (q31_t)0xB2CEB6B5, - (q31_t)0x99E5443A, (q31_t)0xB2F6D54F, (q31_t)0x99C6FBDE, - (q31_t)0xB31EFFCB, (q31_t)0x99A8C344, (q31_t)0xB3473622, - (q31_t)0x998A9A73, (q31_t)0xB36F784E, (q31_t)0x996C816F, - (q31_t)0xB397C649, (q31_t)0x994E783C, (q31_t)0xB3C0200C, - (q31_t)0x99307EE0, (q31_t)0xB3E88591, (q31_t)0x9912955E, - (q31_t)0xB410F6D2, (q31_t)0x98F4BBBC, (q31_t)0xB43973C9, - (q31_t)0x98D6F1FE, (q31_t)0xB461FC70, (q31_t)0x98B93828, - (q31_t)0xB48A90C0, (q31_t)0x989B8E3F, (q31_t)0xB4B330B2, - (q31_t)0x987DF449, (q31_t)0xB4DBDC42, (q31_t)0x98606A48, - (q31_t)0xB5049368, (q31_t)0x9842F043, (q31_t)0xB52D561E, - (q31_t)0x9825863D, (q31_t)0xB556245E, (q31_t)0x98082C3B, - (q31_t)0xB57EFE21, (q31_t)0x97EAE241, (q31_t)0xB5A7E362, - (q31_t)0x97CDA855, (q31_t)0xB5D0D41A, (q31_t)0x97B07E7A, - (q31_t)0xB5F9D042, (q31_t)0x979364B5, (q31_t)0xB622D7D5, - (q31_t)0x97765B0A, (q31_t)0xB64BEACC, (q31_t)0x9759617E, - (q31_t)0xB6750921, (q31_t)0x973C7816, (q31_t)0xB69E32CD, - (q31_t)0x971F9ED6, (q31_t)0xB6C767CA, (q31_t)0x9702D5C2, - (q31_t)0xB6F0A811, (q31_t)0x96E61CDF, (q31_t)0xB719F39D, - (q31_t)0x96C97431, (q31_t)0xB7434A67, (q31_t)0x96ACDBBD, - (q31_t)0xB76CAC68, (q31_t)0x96905387, (q31_t)0xB796199B, - (q31_t)0x9673DB94, (q31_t)0xB7BF91F8, (q31_t)0x965773E7, - (q31_t)0xB7E9157A, (q31_t)0x963B1C85, (q31_t)0xB812A419, - (q31_t)0x961ED573, (q31_t)0xB83C3DD1, (q31_t)0x96029EB5, - (q31_t)0xB865E299, (q31_t)0x95E6784F, (q31_t)0xB88F926C, - (q31_t)0x95CA6246, (q31_t)0xB8B94D44, (q31_t)0x95AE5C9E, - (q31_t)0xB8E31319, (q31_t)0x9592675B, (q31_t)0xB90CE3E6, - (q31_t)0x95768282, (q31_t)0xB936BFA3, (q31_t)0x955AAE17, - (q31_t)0xB960A64B, (q31_t)0x953EEA1E, (q31_t)0xB98A97D8, - (q31_t)0x9523369B, (q31_t)0xB9B49442, (q31_t)0x95079393, - (q31_t)0xB9DE9B83, (q31_t)0x94EC010B, (q31_t)0xBA08AD94, - (q31_t)0x94D07F05, (q31_t)0xBA32CA70, (q31_t)0x94B50D87, - (q31_t)0xBA5CF210, (q31_t)0x9499AC95, (q31_t)0xBA87246C, - (q31_t)0x947E5C32, (q31_t)0xBAB1617F, (q31_t)0x94631C64, - (q31_t)0xBADBA943, (q31_t)0x9447ED2F, (q31_t)0xBB05FBB0, - (q31_t)0x942CCE95, (q31_t)0xBB3058C0, (q31_t)0x9411C09D, - (q31_t)0xBB5AC06C, (q31_t)0x93F6C34A, (q31_t)0xBB8532AF, - (q31_t)0x93DBD69F, (q31_t)0xBBAFAF81, (q31_t)0x93C0FAA2, - (q31_t)0xBBDA36DC, (q31_t)0x93A62F56, (q31_t)0xBC04C8BA, - (q31_t)0x938B74C0, (q31_t)0xBC2F6513, (q31_t)0x9370CAE4, - (q31_t)0xBC5A0BE1, (q31_t)0x935631C5, (q31_t)0xBC84BD1E, - (q31_t)0x933BA968, (q31_t)0xBCAF78C3, (q31_t)0x932131D1, - (q31_t)0xBCDA3ECA, (q31_t)0x9306CB04, (q31_t)0xBD050F2C, - (q31_t)0x92EC7505, (q31_t)0xBD2FE9E1, (q31_t)0x92D22FD8, - (q31_t)0xBD5ACEE5, (q31_t)0x92B7FB82, (q31_t)0xBD85BE2F, - (q31_t)0x929DD805, (q31_t)0xBDB0B7BA, (q31_t)0x9283C567, - (q31_t)0xBDDBBB7F, (q31_t)0x9269C3AC, (q31_t)0xBE06C977, - (q31_t)0x924FD2D6, (q31_t)0xBE31E19B, (q31_t)0x9235F2EB, - (q31_t)0xBE5D03E5, (q31_t)0x921C23EE, (q31_t)0xBE88304F, - (q31_t)0x920265E4, (q31_t)0xBEB366D1, (q31_t)0x91E8B8D0, - (q31_t)0xBEDEA765, (q31_t)0x91CF1CB6, (q31_t)0xBF09F204, - (q31_t)0x91B5919A, (q31_t)0xBF3546A8, (q31_t)0x919C1780, - (q31_t)0xBF60A54A, (q31_t)0x9182AE6C, (q31_t)0xBF8C0DE2, - (q31_t)0x91695663, (q31_t)0xBFB7806C, (q31_t)0x91500F67, - (q31_t)0xBFE2FCDF, (q31_t)0x9136D97D, (q31_t)0xC00E8335, - (q31_t)0x911DB4A8, (q31_t)0xC03A1368, (q31_t)0x9104A0ED, - (q31_t)0xC065AD70, (q31_t)0x90EB9E50, (q31_t)0xC0915147, - (q31_t)0x90D2ACD3, (q31_t)0xC0BCFEE7, (q31_t)0x90B9CC7C, - (q31_t)0xC0E8B648, (q31_t)0x90A0FD4E, (q31_t)0xC1147763, - (q31_t)0x90883F4C, (q31_t)0xC1404233, (q31_t)0x906F927B, - (q31_t)0xC16C16B0, (q31_t)0x9056F6DF, (q31_t)0xC197F4D3, - (q31_t)0x903E6C7A, (q31_t)0xC1C3DC96, (q31_t)0x9025F352, - (q31_t)0xC1EFCDF2, (q31_t)0x900D8B69, (q31_t)0xC21BC8E0, - (q31_t)0x8FF534C4, (q31_t)0xC247CD5A, (q31_t)0x8FDCEF66, - (q31_t)0xC273DB58, (q31_t)0x8FC4BB53, (q31_t)0xC29FF2D4, - (q31_t)0x8FAC988E, (q31_t)0xC2CC13C7, (q31_t)0x8F94871D, - (q31_t)0xC2F83E2A, (q31_t)0x8F7C8701, (q31_t)0xC32471F6, - (q31_t)0x8F64983F, (q31_t)0xC350AF25, (q31_t)0x8F4CBADB, - (q31_t)0xC37CF5B0, (q31_t)0x8F34EED8, (q31_t)0xC3A9458F, - (q31_t)0x8F1D343A, (q31_t)0xC3D59EBD, (q31_t)0x8F058B04, - (q31_t)0xC4020132, (q31_t)0x8EEDF33B, (q31_t)0xC42E6CE8, - (q31_t)0x8ED66CE1, (q31_t)0xC45AE1D7, (q31_t)0x8EBEF7FB, - (q31_t)0xC4875FF8, (q31_t)0x8EA7948C, (q31_t)0xC4B3E746, - (q31_t)0x8E904298, (q31_t)0xC4E077B8, (q31_t)0x8E790222, - (q31_t)0xC50D1148, (q31_t)0x8E61D32D, (q31_t)0xC539B3F0, - (q31_t)0x8E4AB5BF, (q31_t)0xC5665FA8, (q31_t)0x8E33A9D9, - (q31_t)0xC593146A, (q31_t)0x8E1CAF80, (q31_t)0xC5BFD22E, - (q31_t)0x8E05C6B7, (q31_t)0xC5EC98ED, (q31_t)0x8DEEEF82, - (q31_t)0xC61968A2, (q31_t)0x8DD829E4, (q31_t)0xC6464144, - (q31_t)0x8DC175E0, (q31_t)0xC67322CD, (q31_t)0x8DAAD37B, - (q31_t)0xC6A00D36, (q31_t)0x8D9442B7, (q31_t)0xC6CD0079, - (q31_t)0x8D7DC399, (q31_t)0xC6F9FC8D, (q31_t)0x8D675623, - (q31_t)0xC727016C, (q31_t)0x8D50FA59, (q31_t)0xC7540F10, - (q31_t)0x8D3AB03F, (q31_t)0xC7812571, (q31_t)0x8D2477D8, - (q31_t)0xC7AE4489, (q31_t)0x8D0E5127, (q31_t)0xC7DB6C50, - (q31_t)0x8CF83C30, (q31_t)0xC8089CBF, (q31_t)0x8CE238F6, - (q31_t)0xC835D5D0, (q31_t)0x8CCC477D, (q31_t)0xC863177B, - (q31_t)0x8CB667C7, (q31_t)0xC89061BA, (q31_t)0x8CA099D9, - (q31_t)0xC8BDB485, (q31_t)0x8C8ADDB6, (q31_t)0xC8EB0FD6, - (q31_t)0x8C753361, (q31_t)0xC91873A5, (q31_t)0x8C5F9ADD, - (q31_t)0xC945DFEC, (q31_t)0x8C4A142F, (q31_t)0xC97354A3, - (q31_t)0x8C349F58, (q31_t)0xC9A0D1C4, (q31_t)0x8C1F3C5C, - (q31_t)0xC9CE5748, (q31_t)0x8C09EB40, (q31_t)0xC9FBE527, - (q31_t)0x8BF4AC05, (q31_t)0xCA297B5A, (q31_t)0x8BDF7EAF, - (q31_t)0xCA5719DB, (q31_t)0x8BCA6342, (q31_t)0xCA84C0A2, - (q31_t)0x8BB559C1, (q31_t)0xCAB26FA9, (q31_t)0x8BA0622F, - (q31_t)0xCAE026E8, (q31_t)0x8B8B7C8F, (q31_t)0xCB0DE658, - (q31_t)0x8B76A8E4, (q31_t)0xCB3BADF2, (q31_t)0x8B61E732, - (q31_t)0xCB697DB0, (q31_t)0x8B4D377C, (q31_t)0xCB975589, - (q31_t)0x8B3899C5, (q31_t)0xCBC53578, (q31_t)0x8B240E10, - (q31_t)0xCBF31D75, (q31_t)0x8B0F9461, (q31_t)0xCC210D78, - (q31_t)0x8AFB2CBA, (q31_t)0xCC4F057B, (q31_t)0x8AE6D71F, - (q31_t)0xCC7D0577, (q31_t)0x8AD29393, (q31_t)0xCCAB0D65, - (q31_t)0x8ABE6219, (q31_t)0xCCD91D3D, (q31_t)0x8AAA42B4, - (q31_t)0xCD0734F8, (q31_t)0x8A963567, (q31_t)0xCD355490, - (q31_t)0x8A823A35, (q31_t)0xCD637BFD, (q31_t)0x8A6E5122, - (q31_t)0xCD91AB38, (q31_t)0x8A5A7A30, (q31_t)0xCDBFE23A, - (q31_t)0x8A46B563, (q31_t)0xCDEE20FC, (q31_t)0x8A3302BD, - (q31_t)0xCE1C6776, (q31_t)0x8A1F6242, (q31_t)0xCE4AB5A2, - (q31_t)0x8A0BD3F5, (q31_t)0xCE790B78, (q31_t)0x89F857D8, - (q31_t)0xCEA768F2, (q31_t)0x89E4EDEE, (q31_t)0xCED5CE08, - (q31_t)0x89D1963C, (q31_t)0xCF043AB2, (q31_t)0x89BE50C3, - (q31_t)0xCF32AEEB, (q31_t)0x89AB1D86, (q31_t)0xCF612AAA, - (q31_t)0x8997FC89, (q31_t)0xCF8FADE8, (q31_t)0x8984EDCF, - (q31_t)0xCFBE389F, (q31_t)0x8971F15A, (q31_t)0xCFECCAC7, - (q31_t)0x895F072D, (q31_t)0xD01B6459, (q31_t)0x894C2F4C, - (q31_t)0xD04A054D, (q31_t)0x893969B9, (q31_t)0xD078AD9D, - (q31_t)0x8926B677, (q31_t)0xD0A75D42, (q31_t)0x89141589, - (q31_t)0xD0D61433, (q31_t)0x890186F1, (q31_t)0xD104D26B, - (q31_t)0x88EF0AB4, (q31_t)0xD13397E1, (q31_t)0x88DCA0D3, - (q31_t)0xD162648F, (q31_t)0x88CA4951, (q31_t)0xD191386D, - (q31_t)0x88B80431, (q31_t)0xD1C01374, (q31_t)0x88A5D177, - (q31_t)0xD1EEF59E, (q31_t)0x8893B124, (q31_t)0xD21DDEE1, - (q31_t)0x8881A33C, (q31_t)0xD24CCF38, (q31_t)0x886FA7C2, - (q31_t)0xD27BC69C, (q31_t)0x885DBEB7, (q31_t)0xD2AAC504, - (q31_t)0x884BE820, (q31_t)0xD2D9CA6A, (q31_t)0x883A23FE, - (q31_t)0xD308D6C6, (q31_t)0x88287255, (q31_t)0xD337EA12, - (q31_t)0x8816D327, (q31_t)0xD3670445, (q31_t)0x88054677, - (q31_t)0xD3962559, (q31_t)0x87F3CC47, (q31_t)0xD3C54D46, - (q31_t)0x87E2649B, (q31_t)0xD3F47C06, (q31_t)0x87D10F75, - (q31_t)0xD423B190, (q31_t)0x87BFCCD7, (q31_t)0xD452EDDE, - (q31_t)0x87AE9CC5, (q31_t)0xD48230E8, (q31_t)0x879D7F40, - (q31_t)0xD4B17AA7, (q31_t)0x878C744C, (q31_t)0xD4E0CB14, - (q31_t)0x877B7BEC, (q31_t)0xD5102227, (q31_t)0x876A9621, - (q31_t)0xD53F7FDA, (q31_t)0x8759C2EF, (q31_t)0xD56EE424, - (q31_t)0x87490257, (q31_t)0xD59E4EFE, (q31_t)0x8738545E, - (q31_t)0xD5CDC062, (q31_t)0x8727B904, (q31_t)0xD5FD3847, - (q31_t)0x8717304E, (q31_t)0xD62CB6A7, (q31_t)0x8706BA3C, - (q31_t)0xD65C3B7B, (q31_t)0x86F656D3, (q31_t)0xD68BC6BA, - (q31_t)0x86E60614, (q31_t)0xD6BB585D, (q31_t)0x86D5C802, - (q31_t)0xD6EAF05E, (q31_t)0x86C59C9F, (q31_t)0xD71A8EB5, - (q31_t)0x86B583EE, (q31_t)0xD74A335A, (q31_t)0x86A57DF1, - (q31_t)0xD779DE46, (q31_t)0x86958AAB, (q31_t)0xD7A98F73, - (q31_t)0x8685AA1F, (q31_t)0xD7D946D7, (q31_t)0x8675DC4E, - (q31_t)0xD809046D, (q31_t)0x8666213C, (q31_t)0xD838C82D, - (q31_t)0x865678EA, (q31_t)0xD868920F, (q31_t)0x8646E35B, - (q31_t)0xD898620C, (q31_t)0x86376092, (q31_t)0xD8C8381C, - (q31_t)0x8627F090, (q31_t)0xD8F81439, (q31_t)0x86189359, - (q31_t)0xD927F65B, (q31_t)0x860948EE, (q31_t)0xD957DE7A, - (q31_t)0x85FA1152, (q31_t)0xD987CC8F, (q31_t)0x85EAEC88, - (q31_t)0xD9B7C093, (q31_t)0x85DBDA91, (q31_t)0xD9E7BA7E, - (q31_t)0x85CCDB70, (q31_t)0xDA17BA4A, (q31_t)0x85BDEF27, - (q31_t)0xDA47BFED, (q31_t)0x85AF15B9, (q31_t)0xDA77CB62, - (q31_t)0x85A04F28, (q31_t)0xDAA7DCA1, (q31_t)0x85919B75, - (q31_t)0xDAD7F3A2, (q31_t)0x8582FAA4, (q31_t)0xDB08105E, - (q31_t)0x85746CB7, (q31_t)0xDB3832CD, (q31_t)0x8565F1B0, - (q31_t)0xDB685AE8, (q31_t)0x85578991, (q31_t)0xDB9888A8, - (q31_t)0x8549345C, (q31_t)0xDBC8BC05, (q31_t)0x853AF214, - (q31_t)0xDBF8F4F8, (q31_t)0x852CC2BA, (q31_t)0xDC293379, - (q31_t)0x851EA652, (q31_t)0xDC597781, (q31_t)0x85109CDC, - (q31_t)0xDC89C108, (q31_t)0x8502A65C, (q31_t)0xDCBA1008, - (q31_t)0x84F4C2D3, (q31_t)0xDCEA6478, (q31_t)0x84E6F244, - (q31_t)0xDD1ABE51, (q31_t)0x84D934B0, (q31_t)0xDD4B1D8B, - (q31_t)0x84CB8A1B, (q31_t)0xDD7B8220, (q31_t)0x84BDF285, - (q31_t)0xDDABEC07, (q31_t)0x84B06DF1, (q31_t)0xDDDC5B3A, - (q31_t)0x84A2FC62, (q31_t)0xDE0CCFB1, (q31_t)0x84959DD9, - (q31_t)0xDE3D4963, (q31_t)0x84885257, (q31_t)0xDE6DC84B, - (q31_t)0x847B19E1, (q31_t)0xDE9E4C60, (q31_t)0x846DF476, - (q31_t)0xDECED59B, (q31_t)0x8460E21A, (q31_t)0xDEFF63F4, - (q31_t)0x8453E2CE, (q31_t)0xDF2FF764, (q31_t)0x8446F695, - (q31_t)0xDF608FE3, (q31_t)0x843A1D70, (q31_t)0xDF912D6A, - (q31_t)0x842D5761, (q31_t)0xDFC1CFF2, (q31_t)0x8420A46B, - (q31_t)0xDFF27773, (q31_t)0x8414048F, (q31_t)0xE02323E5, - (q31_t)0x840777CF, (q31_t)0xE053D541, (q31_t)0x83FAFE2E, - (q31_t)0xE0848B7F, (q31_t)0x83EE97AC, (q31_t)0xE0B54698, - (q31_t)0x83E2444D, (q31_t)0xE0E60684, (q31_t)0x83D60411, - (q31_t)0xE116CB3D, (q31_t)0x83C9D6FB, (q31_t)0xE14794B9, - (q31_t)0x83BDBD0D, (q31_t)0xE17862F3, (q31_t)0x83B1B649, - (q31_t)0xE1A935E1, (q31_t)0x83A5C2B0, (q31_t)0xE1DA0D7E, - (q31_t)0x8399E244, (q31_t)0xE20AE9C1, (q31_t)0x838E1507, - (q31_t)0xE23BCAA2, (q31_t)0x83825AFB, (q31_t)0xE26CB01A, - (q31_t)0x8376B422, (q31_t)0xE29D9A22, (q31_t)0x836B207D, - (q31_t)0xE2CE88B2, (q31_t)0x835FA00E, (q31_t)0xE2FF7BC3, - (q31_t)0x835432D8, (q31_t)0xE330734C, (q31_t)0x8348D8DB, - (q31_t)0xE3616F47, (q31_t)0x833D921A, (q31_t)0xE3926FAC, - (q31_t)0x83325E97, (q31_t)0xE3C37473, (q31_t)0x83273E52, - (q31_t)0xE3F47D95, (q31_t)0x831C314E, (q31_t)0xE4258B0A, - (q31_t)0x8311378C, (q31_t)0xE4569CCB, (q31_t)0x8306510F, - (q31_t)0xE487B2CF, (q31_t)0x82FB7DD8, (q31_t)0xE4B8CD10, - (q31_t)0x82F0BDE8, (q31_t)0xE4E9EB86, (q31_t)0x82E61141, - (q31_t)0xE51B0E2A, (q31_t)0x82DB77E5, (q31_t)0xE54C34F3, - (q31_t)0x82D0F1D5, (q31_t)0xE57D5FDA, (q31_t)0x82C67F13, - (q31_t)0xE5AE8ED8, (q31_t)0x82BC1FA1, (q31_t)0xE5DFC1E4, - (q31_t)0x82B1D381, (q31_t)0xE610F8F9, (q31_t)0x82A79AB3, - (q31_t)0xE642340D, (q31_t)0x829D753A, (q31_t)0xE6737319, - (q31_t)0x82936316, (q31_t)0xE6A4B616, (q31_t)0x8289644A, - (q31_t)0xE6D5FCFC, (q31_t)0x827F78D8, (q31_t)0xE70747C3, - (q31_t)0x8275A0C0, (q31_t)0xE7389664, (q31_t)0x826BDC04, - (q31_t)0xE769E8D8, (q31_t)0x82622AA5, (q31_t)0xE79B3F16, - (q31_t)0x82588CA6, (q31_t)0xE7CC9917, (q31_t)0x824F0208, - (q31_t)0xE7FDF6D3, (q31_t)0x82458ACB, (q31_t)0xE82F5844, - (q31_t)0x823C26F2, (q31_t)0xE860BD60, (q31_t)0x8232D67E, - (q31_t)0xE8922621, (q31_t)0x82299971, (q31_t)0xE8C3927F, - (q31_t)0x82206FCB, (q31_t)0xE8F50273, (q31_t)0x8217598F, - (q31_t)0xE92675F4, (q31_t)0x820E56BE, (q31_t)0xE957ECFB, - (q31_t)0x82056758, (q31_t)0xE9896780, (q31_t)0x81FC8B60, - (q31_t)0xE9BAE57C, (q31_t)0x81F3C2D7, (q31_t)0xE9EC66E8, - (q31_t)0x81EB0DBD, (q31_t)0xEA1DEBBB, (q31_t)0x81E26C16, - (q31_t)0xEA4F73EE, (q31_t)0x81D9DDE1, (q31_t)0xEA80FF79, - (q31_t)0x81D16320, (q31_t)0xEAB28E55, (q31_t)0x81C8FBD5, - (q31_t)0xEAE4207A, (q31_t)0x81C0A801, (q31_t)0xEB15B5E0, - (q31_t)0x81B867A4, (q31_t)0xEB474E80, (q31_t)0x81B03AC1, - (q31_t)0xEB78EA52, (q31_t)0x81A82159, (q31_t)0xEBAA894E, - (q31_t)0x81A01B6C, (q31_t)0xEBDC2B6D, (q31_t)0x819828FD, - (q31_t)0xEC0DD0A8, (q31_t)0x81904A0C, (q31_t)0xEC3F78F5, - (q31_t)0x81887E9A, (q31_t)0xEC71244F, (q31_t)0x8180C6A9, - (q31_t)0xECA2D2AC, (q31_t)0x8179223A, (q31_t)0xECD48406, - (q31_t)0x8171914E, (q31_t)0xED063855, (q31_t)0x816A13E6, - (q31_t)0xED37EF91, (q31_t)0x8162AA03, (q31_t)0xED69A9B2, - (q31_t)0x815B53A8, (q31_t)0xED9B66B2, (q31_t)0x815410D3, - (q31_t)0xEDCD2687, (q31_t)0x814CE188, (q31_t)0xEDFEE92B, - (q31_t)0x8145C5C6, (q31_t)0xEE30AE95, (q31_t)0x813EBD90, - (q31_t)0xEE6276BF, (q31_t)0x8137C8E6, (q31_t)0xEE9441A0, - (q31_t)0x8130E7C8, (q31_t)0xEEC60F31, (q31_t)0x812A1A39, - (q31_t)0xEEF7DF6A, (q31_t)0x81236039, (q31_t)0xEF29B243, - (q31_t)0x811CB9CA, (q31_t)0xEF5B87B5, (q31_t)0x811626EC, - (q31_t)0xEF8D5FB8, (q31_t)0x810FA7A0, (q31_t)0xEFBF3A44, - (q31_t)0x81093BE8, (q31_t)0xEFF11752, (q31_t)0x8102E3C3, - (q31_t)0xF022F6DA, (q31_t)0x80FC9F35, (q31_t)0xF054D8D4, - (q31_t)0x80F66E3C, (q31_t)0xF086BD39, (q31_t)0x80F050DB, - (q31_t)0xF0B8A401, (q31_t)0x80EA4712, (q31_t)0xF0EA8D23, - (q31_t)0x80E450E2, (q31_t)0xF11C789A, (q31_t)0x80DE6E4C, - (q31_t)0xF14E665C, (q31_t)0x80D89F51, (q31_t)0xF1805662, - (q31_t)0x80D2E3F1, (q31_t)0xF1B248A5, (q31_t)0x80CD3C2F, - (q31_t)0xF1E43D1C, (q31_t)0x80C7A80A, (q31_t)0xF21633C0, - (q31_t)0x80C22783, (q31_t)0xF2482C89, (q31_t)0x80BCBA9C, - (q31_t)0xF27A2770, (q31_t)0x80B76155, (q31_t)0xF2AC246D, - (q31_t)0x80B21BAF, (q31_t)0xF2DE2378, (q31_t)0x80ACE9AB, - (q31_t)0xF310248A, (q31_t)0x80A7CB49, (q31_t)0xF342279A, - (q31_t)0x80A2C08B, (q31_t)0xF3742CA1, (q31_t)0x809DC970, - (q31_t)0xF3A63398, (q31_t)0x8098E5FB, (q31_t)0xF3D83C76, - (q31_t)0x8094162B, (q31_t)0xF40A4734, (q31_t)0x808F5A02, - (q31_t)0xF43C53CA, (q31_t)0x808AB180, (q31_t)0xF46E6231, - (q31_t)0x80861CA5, (q31_t)0xF4A07260, (q31_t)0x80819B74, - (q31_t)0xF4D28451, (q31_t)0x807D2DEB, (q31_t)0xF50497FA, - (q31_t)0x8078D40D, (q31_t)0xF536AD55, (q31_t)0x80748DD9, - (q31_t)0xF568C45A, (q31_t)0x80705B50, (q31_t)0xF59ADD01, - (q31_t)0x806C3C73, (q31_t)0xF5CCF743, (q31_t)0x80683143, - (q31_t)0xF5FF1317, (q31_t)0x806439C0, (q31_t)0xF6313076, - (q31_t)0x806055EA, (q31_t)0xF6634F58, (q31_t)0x805C85C3, - (q31_t)0xF6956FB6, (q31_t)0x8058C94C, (q31_t)0xF6C79188, - (q31_t)0x80552083, (q31_t)0xF6F9B4C5, (q31_t)0x80518B6B, - (q31_t)0xF72BD967, (q31_t)0x804E0A03, (q31_t)0xF75DFF65, - (q31_t)0x804A9C4D, (q31_t)0xF79026B8, (q31_t)0x80474248, - (q31_t)0xF7C24F58, (q31_t)0x8043FBF6, (q31_t)0xF7F4793E, - (q31_t)0x8040C956, (q31_t)0xF826A461, (q31_t)0x803DAA69, - (q31_t)0xF858D0BA, (q31_t)0x803A9F31, (q31_t)0xF88AFE41, - (q31_t)0x8037A7AC, (q31_t)0xF8BD2CEF, (q31_t)0x8034C3DC, - (q31_t)0xF8EF5CBB, (q31_t)0x8031F3C1, (q31_t)0xF9218D9E, - (q31_t)0x802F375C, (q31_t)0xF953BF90, (q31_t)0x802C8EAD, - (q31_t)0xF985F28A, (q31_t)0x8029F9B4, (q31_t)0xF9B82683, - (q31_t)0x80277872, (q31_t)0xF9EA5B75, (q31_t)0x80250AE7, - (q31_t)0xFA1C9156, (q31_t)0x8022B113, (q31_t)0xFA4EC820, - (q31_t)0x80206AF8, (q31_t)0xFA80FFCB, (q31_t)0x801E3894, - (q31_t)0xFAB3384F, (q31_t)0x801C19E9, (q31_t)0xFAE571A4, - (q31_t)0x801A0EF7, (q31_t)0xFB17ABC2, (q31_t)0x801817BF, - (q31_t)0xFB49E6A2, (q31_t)0x80163440, (q31_t)0xFB7C223C, - (q31_t)0x8014647A, (q31_t)0xFBAE5E89, (q31_t)0x8012A86F, - (q31_t)0xFBE09B80, (q31_t)0x8011001E, (q31_t)0xFC12D919, - (q31_t)0x800F6B88, (q31_t)0xFC45174E, (q31_t)0x800DEAAC, - (q31_t)0xFC775616, (q31_t)0x800C7D8C, (q31_t)0xFCA99569, - (q31_t)0x800B2427, (q31_t)0xFCDBD541, (q31_t)0x8009DE7D, - (q31_t)0xFD0E1594, (q31_t)0x8008AC90, (q31_t)0xFD40565B, - (q31_t)0x80078E5E, (q31_t)0xFD72978F, (q31_t)0x800683E8, - (q31_t)0xFDA4D928, (q31_t)0x80058D2E, (q31_t)0xFDD71B1E, - (q31_t)0x8004AA31, (q31_t)0xFE095D69, (q31_t)0x8003DAF0, - (q31_t)0xFE3BA001, (q31_t)0x80031F6C, (q31_t)0xFE6DE2E0, - (q31_t)0x800277A5, (q31_t)0xFEA025FC, (q31_t)0x8001E39B, - (q31_t)0xFED2694F, (q31_t)0x8001634D, (q31_t)0xFF04ACD0, - (q31_t)0x8000F6BD, (q31_t)0xFF36F078, (q31_t)0x80009DE9, - (q31_t)0xFF69343E, (q31_t)0x800058D3, (q31_t)0xFF9B781D, - (q31_t)0x8000277A, (q31_t)0xFFCDBC0A, (q31_t)0x800009DE -}; - - +const q31_t twiddleCoef_4096_q31[6144] = { + (q31_t)0x7FFFFFFF, (q31_t)0x00000000, (q31_t)0x7FFFF621, (q31_t)0x003243F5, + (q31_t)0x7FFFD885, (q31_t)0x006487E3, (q31_t)0x7FFFA72C, (q31_t)0x0096CBC1, + (q31_t)0x7FFF6216, (q31_t)0x00C90F88, (q31_t)0x7FFF0942, (q31_t)0x00FB532F, + (q31_t)0x7FFE9CB2, (q31_t)0x012D96B0, (q31_t)0x7FFE1C64, (q31_t)0x015FDA03, + (q31_t)0x7FFD885A, (q31_t)0x01921D1F, (q31_t)0x7FFCE093, (q31_t)0x01C45FFE, + (q31_t)0x7FFC250F, (q31_t)0x01F6A296, (q31_t)0x7FFB55CE, (q31_t)0x0228E4E1, + (q31_t)0x7FFA72D1, (q31_t)0x025B26D7, (q31_t)0x7FF97C17, (q31_t)0x028D6870, + (q31_t)0x7FF871A1, (q31_t)0x02BFA9A4, (q31_t)0x7FF7536F, (q31_t)0x02F1EA6B, + (q31_t)0x7FF62182, (q31_t)0x03242ABF, (q31_t)0x7FF4DBD8, (q31_t)0x03566A96, + (q31_t)0x7FF38273, (q31_t)0x0388A9E9, (q31_t)0x7FF21553, (q31_t)0x03BAE8B1, + (q31_t)0x7FF09477, (q31_t)0x03ED26E6, (q31_t)0x7FEEFFE1, (q31_t)0x041F647F, + (q31_t)0x7FED5790, (q31_t)0x0451A176, (q31_t)0x7FEB9B85, (q31_t)0x0483DDC3, + (q31_t)0x7FE9CBC0, (q31_t)0x04B6195D, (q31_t)0x7FE7E840, (q31_t)0x04E8543D, + (q31_t)0x7FE5F108, (q31_t)0x051A8E5C, (q31_t)0x7FE3E616, (q31_t)0x054CC7B0, + (q31_t)0x7FE1C76B, (q31_t)0x057F0034, (q31_t)0x7FDF9508, (q31_t)0x05B137DF, + (q31_t)0x7FDD4EEC, (q31_t)0x05E36EA9, (q31_t)0x7FDAF518, (q31_t)0x0615A48A, + (q31_t)0x7FD8878D, (q31_t)0x0647D97C, (q31_t)0x7FD6064B, (q31_t)0x067A0D75, + (q31_t)0x7FD37152, (q31_t)0x06AC406F, (q31_t)0x7FD0C8A3, (q31_t)0x06DE7261, + (q31_t)0x7FCE0C3E, (q31_t)0x0710A344, (q31_t)0x7FCB3C23, (q31_t)0x0742D310, + (q31_t)0x7FC85853, (q31_t)0x077501BE, (q31_t)0x7FC560CF, (q31_t)0x07A72F45, + (q31_t)0x7FC25596, (q31_t)0x07D95B9E, (q31_t)0x7FBF36A9, (q31_t)0x080B86C1, + (q31_t)0x7FBC040A, (q31_t)0x083DB0A7, (q31_t)0x7FB8BDB7, (q31_t)0x086FD947, + (q31_t)0x7FB563B2, (q31_t)0x08A2009A, (q31_t)0x7FB1F5FC, (q31_t)0x08D42698, + (q31_t)0x7FAE7494, (q31_t)0x09064B3A, (q31_t)0x7FAADF7C, (q31_t)0x09386E77, + (q31_t)0x7FA736B4, (q31_t)0x096A9049, (q31_t)0x7FA37A3C, (q31_t)0x099CB0A7, + (q31_t)0x7F9FAA15, (q31_t)0x09CECF89, (q31_t)0x7F9BC63F, (q31_t)0x0A00ECE8, + (q31_t)0x7F97CEBC, (q31_t)0x0A3308BC, (q31_t)0x7F93C38C, (q31_t)0x0A6522FE, + (q31_t)0x7F8FA4AF, (q31_t)0x0A973BA5, (q31_t)0x7F8B7226, (q31_t)0x0AC952AA, + (q31_t)0x7F872BF3, (q31_t)0x0AFB6805, (q31_t)0x7F82D214, (q31_t)0x0B2D7BAE, + (q31_t)0x7F7E648B, (q31_t)0x0B5F8D9F, (q31_t)0x7F79E35A, (q31_t)0x0B919DCE, + (q31_t)0x7F754E7F, (q31_t)0x0BC3AC35, (q31_t)0x7F70A5FD, (q31_t)0x0BF5B8CB, + (q31_t)0x7F6BE9D4, (q31_t)0x0C27C389, (q31_t)0x7F671A04, (q31_t)0x0C59CC67, + (q31_t)0x7F62368F, (q31_t)0x0C8BD35E, (q31_t)0x7F5D3F75, (q31_t)0x0CBDD865, + (q31_t)0x7F5834B6, (q31_t)0x0CEFDB75, (q31_t)0x7F531654, (q31_t)0x0D21DC87, + (q31_t)0x7F4DE450, (q31_t)0x0D53DB92, (q31_t)0x7F489EAA, (q31_t)0x0D85D88F, + (q31_t)0x7F434563, (q31_t)0x0DB7D376, (q31_t)0x7F3DD87C, (q31_t)0x0DE9CC3F, + (q31_t)0x7F3857F5, (q31_t)0x0E1BC2E3, (q31_t)0x7F32C3D0, (q31_t)0x0E4DB75B, + (q31_t)0x7F2D1C0E, (q31_t)0x0E7FA99D, (q31_t)0x7F2760AF, (q31_t)0x0EB199A3, + (q31_t)0x7F2191B4, (q31_t)0x0EE38765, (q31_t)0x7F1BAF1E, (q31_t)0x0F1572DC, + (q31_t)0x7F15B8EE, (q31_t)0x0F475BFE, (q31_t)0x7F0FAF24, (q31_t)0x0F7942C6, + (q31_t)0x7F0991C3, (q31_t)0x0FAB272B, (q31_t)0x7F0360CB, (q31_t)0x0FDD0925, + (q31_t)0x7EFD1C3C, (q31_t)0x100EE8AD, (q31_t)0x7EF6C418, (q31_t)0x1040C5BB, + (q31_t)0x7EF0585F, (q31_t)0x1072A047, (q31_t)0x7EE9D913, (q31_t)0x10A4784A, + (q31_t)0x7EE34635, (q31_t)0x10D64DBC, (q31_t)0x7EDC9FC6, (q31_t)0x11082096, + (q31_t)0x7ED5E5C6, (q31_t)0x1139F0CE, (q31_t)0x7ECF1837, (q31_t)0x116BBE5F, + (q31_t)0x7EC8371A, (q31_t)0x119D8940, (q31_t)0x7EC1426F, (q31_t)0x11CF516A, + (q31_t)0x7EBA3A39, (q31_t)0x120116D4, (q31_t)0x7EB31E77, (q31_t)0x1232D978, + (q31_t)0x7EABEF2C, (q31_t)0x1264994E, (q31_t)0x7EA4AC58, (q31_t)0x1296564D, + (q31_t)0x7E9D55FC, (q31_t)0x12C8106E, (q31_t)0x7E95EC19, (q31_t)0x12F9C7AA, + (q31_t)0x7E8E6EB1, (q31_t)0x132B7BF9, (q31_t)0x7E86DDC5, (q31_t)0x135D2D53, + (q31_t)0x7E7F3956, (q31_t)0x138EDBB0, (q31_t)0x7E778165, (q31_t)0x13C0870A, + (q31_t)0x7E6FB5F3, (q31_t)0x13F22F57, (q31_t)0x7E67D702, (q31_t)0x1423D492, + (q31_t)0x7E5FE493, (q31_t)0x145576B1, (q31_t)0x7E57DEA6, (q31_t)0x148715AD, + (q31_t)0x7E4FC53E, (q31_t)0x14B8B17F, (q31_t)0x7E47985B, (q31_t)0x14EA4A1F, + (q31_t)0x7E3F57FE, (q31_t)0x151BDF85, (q31_t)0x7E37042A, (q31_t)0x154D71AA, + (q31_t)0x7E2E9CDF, (q31_t)0x157F0086, (q31_t)0x7E26221E, (q31_t)0x15B08C11, + (q31_t)0x7E1D93E9, (q31_t)0x15E21444, (q31_t)0x7E14F242, (q31_t)0x16139917, + (q31_t)0x7E0C3D29, (q31_t)0x16451A83, (q31_t)0x7E03749F, (q31_t)0x1676987F, + (q31_t)0x7DFA98A7, (q31_t)0x16A81305, (q31_t)0x7DF1A942, (q31_t)0x16D98A0C, + (q31_t)0x7DE8A670, (q31_t)0x170AFD8D, (q31_t)0x7DDF9034, (q31_t)0x173C6D80, + (q31_t)0x7DD6668E, (q31_t)0x176DD9DE, (q31_t)0x7DCD2981, (q31_t)0x179F429F, + (q31_t)0x7DC3D90D, (q31_t)0x17D0A7BB, (q31_t)0x7DBA7534, (q31_t)0x1802092C, + (q31_t)0x7DB0FDF7, (q31_t)0x183366E8, (q31_t)0x7DA77359, (q31_t)0x1864C0E9, + (q31_t)0x7D9DD55A, (q31_t)0x18961727, (q31_t)0x7D9423FB, (q31_t)0x18C7699B, + (q31_t)0x7D8A5F3F, (q31_t)0x18F8B83C, (q31_t)0x7D808727, (q31_t)0x192A0303, + (q31_t)0x7D769BB5, (q31_t)0x195B49E9, (q31_t)0x7D6C9CE9, (q31_t)0x198C8CE6, + (q31_t)0x7D628AC5, (q31_t)0x19BDCBF2, (q31_t)0x7D58654C, (q31_t)0x19EF0706, + (q31_t)0x7D4E2C7E, (q31_t)0x1A203E1B, (q31_t)0x7D43E05E, (q31_t)0x1A517127, + (q31_t)0x7D3980EC, (q31_t)0x1A82A025, (q31_t)0x7D2F0E2A, (q31_t)0x1AB3CB0C, + (q31_t)0x7D24881A, (q31_t)0x1AE4F1D6, (q31_t)0x7D19EEBE, (q31_t)0x1B161479, + (q31_t)0x7D0F4218, (q31_t)0x1B4732EF, (q31_t)0x7D048228, (q31_t)0x1B784D30, + (q31_t)0x7CF9AEF0, (q31_t)0x1BA96334, (q31_t)0x7CEEC873, (q31_t)0x1BDA74F5, + (q31_t)0x7CE3CEB1, (q31_t)0x1C0B826A, (q31_t)0x7CD8C1AD, (q31_t)0x1C3C8B8C, + (q31_t)0x7CCDA168, (q31_t)0x1C6D9053, (q31_t)0x7CC26DE5, (q31_t)0x1C9E90B8, + (q31_t)0x7CB72724, (q31_t)0x1CCF8CB3, (q31_t)0x7CABCD27, (q31_t)0x1D00843C, + (q31_t)0x7CA05FF1, (q31_t)0x1D31774D, (q31_t)0x7C94DF82, (q31_t)0x1D6265DD, + (q31_t)0x7C894BDD, (q31_t)0x1D934FE5, (q31_t)0x7C7DA504, (q31_t)0x1DC4355D, + (q31_t)0x7C71EAF8, (q31_t)0x1DF5163F, (q31_t)0x7C661DBB, (q31_t)0x1E25F281, + (q31_t)0x7C5A3D4F, (q31_t)0x1E56CA1E, (q31_t)0x7C4E49B6, (q31_t)0x1E879D0C, + (q31_t)0x7C4242F2, (q31_t)0x1EB86B46, (q31_t)0x7C362904, (q31_t)0x1EE934C2, + (q31_t)0x7C29FBEE, (q31_t)0x1F19F97B, (q31_t)0x7C1DBBB2, (q31_t)0x1F4AB967, + (q31_t)0x7C116853, (q31_t)0x1F7B7480, (q31_t)0x7C0501D1, (q31_t)0x1FAC2ABF, + (q31_t)0x7BF88830, (q31_t)0x1FDCDC1A, (q31_t)0x7BEBFB70, (q31_t)0x200D888C, + (q31_t)0x7BDF5B94, (q31_t)0x203E300D, (q31_t)0x7BD2A89E, (q31_t)0x206ED295, + (q31_t)0x7BC5E28F, (q31_t)0x209F701C, (q31_t)0x7BB9096A, (q31_t)0x20D0089B, + (q31_t)0x7BAC1D31, (q31_t)0x21009C0B, (q31_t)0x7B9F1DE5, (q31_t)0x21312A65, + (q31_t)0x7B920B89, (q31_t)0x2161B39F, (q31_t)0x7B84E61E, (q31_t)0x219237B4, + (q31_t)0x7B77ADA8, (q31_t)0x21C2B69C, (q31_t)0x7B6A6227, (q31_t)0x21F3304E, + (q31_t)0x7B5D039D, (q31_t)0x2223A4C5, (q31_t)0x7B4F920E, (q31_t)0x225413F8, + (q31_t)0x7B420D7A, (q31_t)0x22847DDF, (q31_t)0x7B3475E4, (q31_t)0x22B4E274, + (q31_t)0x7B26CB4F, (q31_t)0x22E541AE, (q31_t)0x7B190DBB, (q31_t)0x23159B87, + (q31_t)0x7B0B3D2C, (q31_t)0x2345EFF7, (q31_t)0x7AFD59A3, (q31_t)0x23763EF7, + (q31_t)0x7AEF6323, (q31_t)0x23A6887E, (q31_t)0x7AE159AE, (q31_t)0x23D6CC86, + (q31_t)0x7AD33D45, (q31_t)0x24070B07, (q31_t)0x7AC50DEB, (q31_t)0x243743FA, + (q31_t)0x7AB6CBA3, (q31_t)0x24677757, (q31_t)0x7AA8766E, (q31_t)0x2497A517, + (q31_t)0x7A9A0E4F, (q31_t)0x24C7CD32, (q31_t)0x7A8B9348, (q31_t)0x24F7EFA1, + (q31_t)0x7A7D055B, (q31_t)0x25280C5D, (q31_t)0x7A6E648A, (q31_t)0x2558235E, + (q31_t)0x7A5FB0D8, (q31_t)0x2588349D, (q31_t)0x7A50EA46, (q31_t)0x25B84012, + (q31_t)0x7A4210D8, (q31_t)0x25E845B5, (q31_t)0x7A33248F, (q31_t)0x26184581, + (q31_t)0x7A24256E, (q31_t)0x26483F6C, (q31_t)0x7A151377, (q31_t)0x26783370, + (q31_t)0x7A05EEAD, (q31_t)0x26A82185, (q31_t)0x79F6B711, (q31_t)0x26D809A5, + (q31_t)0x79E76CA6, (q31_t)0x2707EBC6, (q31_t)0x79D80F6F, (q31_t)0x2737C7E3, + (q31_t)0x79C89F6D, (q31_t)0x27679DF4, (q31_t)0x79B91CA4, (q31_t)0x27976DF1, + (q31_t)0x79A98715, (q31_t)0x27C737D2, (q31_t)0x7999DEC3, (q31_t)0x27F6FB92, + (q31_t)0x798A23B1, (q31_t)0x2826B928, (q31_t)0x797A55E0, (q31_t)0x2856708C, + (q31_t)0x796A7554, (q31_t)0x288621B9, (q31_t)0x795A820E, (q31_t)0x28B5CCA5, + (q31_t)0x794A7C11, (q31_t)0x28E5714A, (q31_t)0x793A6360, (q31_t)0x29150FA1, + (q31_t)0x792A37FE, (q31_t)0x2944A7A2, (q31_t)0x7919F9EB, (q31_t)0x29743945, + (q31_t)0x7909A92C, (q31_t)0x29A3C484, (q31_t)0x78F945C3, (q31_t)0x29D34958, + (q31_t)0x78E8CFB1, (q31_t)0x2A02C7B8, (q31_t)0x78D846FB, (q31_t)0x2A323F9D, + (q31_t)0x78C7ABA1, (q31_t)0x2A61B101, (q31_t)0x78B6FDA8, (q31_t)0x2A911BDB, + (q31_t)0x78A63D10, (q31_t)0x2AC08025, (q31_t)0x789569DE, (q31_t)0x2AEFDDD8, + (q31_t)0x78848413, (q31_t)0x2B1F34EB, (q31_t)0x78738BB3, (q31_t)0x2B4E8558, + (q31_t)0x786280BF, (q31_t)0x2B7DCF17, (q31_t)0x7851633B, (q31_t)0x2BAD1221, + (q31_t)0x78403328, (q31_t)0x2BDC4E6F, (q31_t)0x782EF08B, (q31_t)0x2C0B83F9, + (q31_t)0x781D9B64, (q31_t)0x2C3AB2B9, (q31_t)0x780C33B8, (q31_t)0x2C69DAA6, + (q31_t)0x77FAB988, (q31_t)0x2C98FBBA, (q31_t)0x77E92CD8, (q31_t)0x2CC815ED, + (q31_t)0x77D78DAA, (q31_t)0x2CF72939, (q31_t)0x77C5DC01, (q31_t)0x2D263595, + (q31_t)0x77B417DF, (q31_t)0x2D553AFB, (q31_t)0x77A24148, (q31_t)0x2D843963, + (q31_t)0x7790583D, (q31_t)0x2DB330C7, (q31_t)0x777E5CC3, (q31_t)0x2DE2211E, + (q31_t)0x776C4EDB, (q31_t)0x2E110A62, (q31_t)0x775A2E88, (q31_t)0x2E3FEC8B, + (q31_t)0x7747FBCE, (q31_t)0x2E6EC792, (q31_t)0x7735B6AE, (q31_t)0x2E9D9B70, + (q31_t)0x77235F2D, (q31_t)0x2ECC681E, (q31_t)0x7710F54B, (q31_t)0x2EFB2D94, + (q31_t)0x76FE790E, (q31_t)0x2F29EBCC, (q31_t)0x76EBEA77, (q31_t)0x2F58A2BD, + (q31_t)0x76D94988, (q31_t)0x2F875262, (q31_t)0x76C69646, (q31_t)0x2FB5FAB2, + (q31_t)0x76B3D0B3, (q31_t)0x2FE49BA6, (q31_t)0x76A0F8D2, (q31_t)0x30133538, + (q31_t)0x768E0EA5, (q31_t)0x3041C760, (q31_t)0x767B1230, (q31_t)0x30705217, + (q31_t)0x76680376, (q31_t)0x309ED555, (q31_t)0x7654E279, (q31_t)0x30CD5114, + (q31_t)0x7641AF3C, (q31_t)0x30FBC54D, (q31_t)0x762E69C3, (q31_t)0x312A31F8, + (q31_t)0x761B1211, (q31_t)0x3158970D, (q31_t)0x7607A827, (q31_t)0x3186F487, + (q31_t)0x75F42C0A, (q31_t)0x31B54A5D, (q31_t)0x75E09DBD, (q31_t)0x31E39889, + (q31_t)0x75CCFD42, (q31_t)0x3211DF03, (q31_t)0x75B94A9C, (q31_t)0x32401DC5, + (q31_t)0x75A585CF, (q31_t)0x326E54C7, (q31_t)0x7591AEDD, (q31_t)0x329C8402, + (q31_t)0x757DC5CA, (q31_t)0x32CAAB6F, (q31_t)0x7569CA98, (q31_t)0x32F8CB07, + (q31_t)0x7555BD4B, (q31_t)0x3326E2C2, (q31_t)0x75419DE6, (q31_t)0x3354F29A, + (q31_t)0x752D6C6C, (q31_t)0x3382FA88, (q31_t)0x751928E0, (q31_t)0x33B0FA84, + (q31_t)0x7504D345, (q31_t)0x33DEF287, (q31_t)0x74F06B9E, (q31_t)0x340CE28A, + (q31_t)0x74DBF1EF, (q31_t)0x343ACA87, (q31_t)0x74C7663A, (q31_t)0x3468AA76, + (q31_t)0x74B2C883, (q31_t)0x3496824F, (q31_t)0x749E18CD, (q31_t)0x34C4520D, + (q31_t)0x7489571B, (q31_t)0x34F219A7, (q31_t)0x74748371, (q31_t)0x351FD917, + (q31_t)0x745F9DD1, (q31_t)0x354D9056, (q31_t)0x744AA63E, (q31_t)0x357B3F5D, + (q31_t)0x74359CBD, (q31_t)0x35A8E624, (q31_t)0x74208150, (q31_t)0x35D684A5, + (q31_t)0x740B53FA, (q31_t)0x36041AD9, (q31_t)0x73F614C0, (q31_t)0x3631A8B7, + (q31_t)0x73E0C3A3, (q31_t)0x365F2E3B, (q31_t)0x73CB60A7, (q31_t)0x368CAB5C, + (q31_t)0x73B5EBD0, (q31_t)0x36BA2013, (q31_t)0x73A06522, (q31_t)0x36E78C5A, + (q31_t)0x738ACC9E, (q31_t)0x3714F02A, (q31_t)0x73752249, (q31_t)0x37424B7A, + (q31_t)0x735F6626, (q31_t)0x376F9E46, (q31_t)0x73499838, (q31_t)0x379CE884, + (q31_t)0x7333B883, (q31_t)0x37CA2A30, (q31_t)0x731DC709, (q31_t)0x37F76340, + (q31_t)0x7307C3D0, (q31_t)0x382493B0, (q31_t)0x72F1AED8, (q31_t)0x3851BB76, + (q31_t)0x72DB8828, (q31_t)0x387EDA8E, (q31_t)0x72C54FC0, (q31_t)0x38ABF0EF, + (q31_t)0x72AF05A6, (q31_t)0x38D8FE93, (q31_t)0x7298A9DC, (q31_t)0x39060372, + (q31_t)0x72823C66, (q31_t)0x3932FF87, (q31_t)0x726BBD48, (q31_t)0x395FF2C9, + (q31_t)0x72552C84, (q31_t)0x398CDD32, (q31_t)0x723E8A1F, (q31_t)0x39B9BEBB, + (q31_t)0x7227D61C, (q31_t)0x39E6975D, (q31_t)0x7211107D, (q31_t)0x3A136712, + (q31_t)0x71FA3948, (q31_t)0x3A402DD1, (q31_t)0x71E3507F, (q31_t)0x3A6CEB95, + (q31_t)0x71CC5626, (q31_t)0x3A99A057, (q31_t)0x71B54A40, (q31_t)0x3AC64C0F, + (q31_t)0x719E2CD2, (q31_t)0x3AF2EEB7, (q31_t)0x7186FDDE, (q31_t)0x3B1F8847, + (q31_t)0x716FBD68, (q31_t)0x3B4C18BA, (q31_t)0x71586B73, (q31_t)0x3B78A007, + (q31_t)0x71410804, (q31_t)0x3BA51E29, (q31_t)0x7129931E, (q31_t)0x3BD19317, + (q31_t)0x71120CC5, (q31_t)0x3BFDFECD, (q31_t)0x70FA74FB, (q31_t)0x3C2A6142, + (q31_t)0x70E2CBC6, (q31_t)0x3C56BA70, (q31_t)0x70CB1127, (q31_t)0x3C830A4F, + (q31_t)0x70B34524, (q31_t)0x3CAF50DA, (q31_t)0x709B67C0, (q31_t)0x3CDB8E09, + (q31_t)0x708378FE, (q31_t)0x3D07C1D5, (q31_t)0x706B78E3, (q31_t)0x3D33EC39, + (q31_t)0x70536771, (q31_t)0x3D600D2B, (q31_t)0x703B44AC, (q31_t)0x3D8C24A7, + (q31_t)0x70231099, (q31_t)0x3DB832A5, (q31_t)0x700ACB3B, (q31_t)0x3DE4371F, + (q31_t)0x6FF27496, (q31_t)0x3E10320D, (q31_t)0x6FDA0CAD, (q31_t)0x3E3C2369, + (q31_t)0x6FC19385, (q31_t)0x3E680B2C, (q31_t)0x6FA90920, (q31_t)0x3E93E94F, + (q31_t)0x6F906D84, (q31_t)0x3EBFBDCC, (q31_t)0x6F77C0B3, (q31_t)0x3EEB889C, + (q31_t)0x6F5F02B1, (q31_t)0x3F1749B7, (q31_t)0x6F463383, (q31_t)0x3F430118, + (q31_t)0x6F2D532C, (q31_t)0x3F6EAEB8, (q31_t)0x6F1461AF, (q31_t)0x3F9A528F, + (q31_t)0x6EFB5F12, (q31_t)0x3FC5EC97, (q31_t)0x6EE24B57, (q31_t)0x3FF17CCA, + (q31_t)0x6EC92682, (q31_t)0x401D0320, (q31_t)0x6EAFF098, (q31_t)0x40487F93, + (q31_t)0x6E96A99C, (q31_t)0x4073F21D, (q31_t)0x6E7D5193, (q31_t)0x409F5AB6, + (q31_t)0x6E63E87F, (q31_t)0x40CAB957, (q31_t)0x6E4A6E65, (q31_t)0x40F60DFB, + (q31_t)0x6E30E349, (q31_t)0x4121589A, (q31_t)0x6E17472F, (q31_t)0x414C992E, + (q31_t)0x6DFD9A1B, (q31_t)0x4177CFB0, (q31_t)0x6DE3DC11, (q31_t)0x41A2FC1A, + (q31_t)0x6DCA0D14, (q31_t)0x41CE1E64, (q31_t)0x6DB02D29, (q31_t)0x41F93688, + (q31_t)0x6D963C54, (q31_t)0x42244480, (q31_t)0x6D7C3A98, (q31_t)0x424F4845, + (q31_t)0x6D6227FA, (q31_t)0x427A41D0, (q31_t)0x6D48047E, (q31_t)0x42A5311A, + (q31_t)0x6D2DD027, (q31_t)0x42D0161E, (q31_t)0x6D138AFA, (q31_t)0x42FAF0D4, + (q31_t)0x6CF934FB, (q31_t)0x4325C135, (q31_t)0x6CDECE2E, (q31_t)0x4350873C, + (q31_t)0x6CC45697, (q31_t)0x437B42E1, (q31_t)0x6CA9CE3A, (q31_t)0x43A5F41E, + (q31_t)0x6C8F351C, (q31_t)0x43D09AEC, (q31_t)0x6C748B3F, (q31_t)0x43FB3745, + (q31_t)0x6C59D0A9, (q31_t)0x4425C923, (q31_t)0x6C3F055D, (q31_t)0x4450507E, + (q31_t)0x6C242960, (q31_t)0x447ACD50, (q31_t)0x6C093CB6, (q31_t)0x44A53F93, + (q31_t)0x6BEE3F62, (q31_t)0x44CFA73F, (q31_t)0x6BD3316A, (q31_t)0x44FA044F, + (q31_t)0x6BB812D0, (q31_t)0x452456BC, (q31_t)0x6B9CE39B, (q31_t)0x454E9E80, + (q31_t)0x6B81A3CD, (q31_t)0x4578DB93, (q31_t)0x6B66536A, (q31_t)0x45A30DF0, + (q31_t)0x6B4AF278, (q31_t)0x45CD358F, (q31_t)0x6B2F80FA, (q31_t)0x45F7526B, + (q31_t)0x6B13FEF5, (q31_t)0x4621647C, (q31_t)0x6AF86C6C, (q31_t)0x464B6BBD, + (q31_t)0x6ADCC964, (q31_t)0x46756827, (q31_t)0x6AC115E1, (q31_t)0x469F59B4, + (q31_t)0x6AA551E8, (q31_t)0x46C9405C, (q31_t)0x6A897D7D, (q31_t)0x46F31C1A, + (q31_t)0x6A6D98A4, (q31_t)0x471CECE6, (q31_t)0x6A51A361, (q31_t)0x4746B2BC, + (q31_t)0x6A359DB9, (q31_t)0x47706D93, (q31_t)0x6A1987B0, (q31_t)0x479A1D66, + (q31_t)0x69FD614A, (q31_t)0x47C3C22E, (q31_t)0x69E12A8C, (q31_t)0x47ED5BE6, + (q31_t)0x69C4E37A, (q31_t)0x4816EA85, (q31_t)0x69A88C18, (q31_t)0x48406E07, + (q31_t)0x698C246C, (q31_t)0x4869E664, (q31_t)0x696FAC78, (q31_t)0x48935397, + (q31_t)0x69532442, (q31_t)0x48BCB598, (q31_t)0x69368BCE, (q31_t)0x48E60C62, + (q31_t)0x6919E320, (q31_t)0x490F57EE, (q31_t)0x68FD2A3D, (q31_t)0x49389836, + (q31_t)0x68E06129, (q31_t)0x4961CD32, (q31_t)0x68C387E9, (q31_t)0x498AF6DE, + (q31_t)0x68A69E81, (q31_t)0x49B41533, (q31_t)0x6889A4F5, (q31_t)0x49DD282A, + (q31_t)0x686C9B4B, (q31_t)0x4A062FBD, (q31_t)0x684F8186, (q31_t)0x4A2F2BE5, + (q31_t)0x683257AA, (q31_t)0x4A581C9D, (q31_t)0x68151DBE, (q31_t)0x4A8101DE, + (q31_t)0x67F7D3C4, (q31_t)0x4AA9DBA1, (q31_t)0x67DA79C2, (q31_t)0x4AD2A9E1, + (q31_t)0x67BD0FBC, (q31_t)0x4AFB6C97, (q31_t)0x679F95B7, (q31_t)0x4B2423BD, + (q31_t)0x67820BB6, (q31_t)0x4B4CCF4D, (q31_t)0x676471C0, (q31_t)0x4B756F3F, + (q31_t)0x6746C7D7, (q31_t)0x4B9E038F, (q31_t)0x67290E02, (q31_t)0x4BC68C36, + (q31_t)0x670B4443, (q31_t)0x4BEF092D, (q31_t)0x66ED6AA1, (q31_t)0x4C177A6E, + (q31_t)0x66CF811F, (q31_t)0x4C3FDFF3, (q31_t)0x66B187C3, (q31_t)0x4C6839B6, + (q31_t)0x66937E90, (q31_t)0x4C9087B1, (q31_t)0x6675658C, (q31_t)0x4CB8C9DD, + (q31_t)0x66573CBB, (q31_t)0x4CE10034, (q31_t)0x66390422, (q31_t)0x4D092AB0, + (q31_t)0x661ABBC5, (q31_t)0x4D31494B, (q31_t)0x65FC63A9, (q31_t)0x4D595BFE, + (q31_t)0x65DDFBD3, (q31_t)0x4D8162C4, (q31_t)0x65BF8447, (q31_t)0x4DA95D96, + (q31_t)0x65A0FD0B, (q31_t)0x4DD14C6E, (q31_t)0x65826622, (q31_t)0x4DF92F45, + (q31_t)0x6563BF92, (q31_t)0x4E210617, (q31_t)0x6545095F, (q31_t)0x4E48D0DC, + (q31_t)0x6526438E, (q31_t)0x4E708F8F, (q31_t)0x65076E24, (q31_t)0x4E984229, + (q31_t)0x64E88926, (q31_t)0x4EBFE8A4, (q31_t)0x64C99498, (q31_t)0x4EE782FA, + (q31_t)0x64AA907F, (q31_t)0x4F0F1126, (q31_t)0x648B7CDF, (q31_t)0x4F369320, + (q31_t)0x646C59BF, (q31_t)0x4F5E08E3, (q31_t)0x644D2722, (q31_t)0x4F857268, + (q31_t)0x642DE50D, (q31_t)0x4FACCFAB, (q31_t)0x640E9385, (q31_t)0x4FD420A3, + (q31_t)0x63EF328F, (q31_t)0x4FFB654D, (q31_t)0x63CFC230, (q31_t)0x50229DA0, + (q31_t)0x63B0426D, (q31_t)0x5049C999, (q31_t)0x6390B34A, (q31_t)0x5070E92F, + (q31_t)0x637114CC, (q31_t)0x5097FC5E, (q31_t)0x635166F8, (q31_t)0x50BF031F, + (q31_t)0x6331A9D4, (q31_t)0x50E5FD6C, (q31_t)0x6311DD63, (q31_t)0x510CEB40, + (q31_t)0x62F201AC, (q31_t)0x5133CC94, (q31_t)0x62D216B2, (q31_t)0x515AA162, + (q31_t)0x62B21C7B, (q31_t)0x518169A4, (q31_t)0x6292130C, (q31_t)0x51A82555, + (q31_t)0x6271FA69, (q31_t)0x51CED46E, (q31_t)0x6251D297, (q31_t)0x51F576E9, + (q31_t)0x62319B9D, (q31_t)0x521C0CC1, (q31_t)0x6211557D, (q31_t)0x524295EF, + (q31_t)0x61F1003E, (q31_t)0x5269126E, (q31_t)0x61D09BE5, (q31_t)0x528F8237, + (q31_t)0x61B02876, (q31_t)0x52B5E545, (q31_t)0x618FA5F6, (q31_t)0x52DC3B92, + (q31_t)0x616F146B, (q31_t)0x53028517, (q31_t)0x614E73D9, (q31_t)0x5328C1D0, + (q31_t)0x612DC446, (q31_t)0x534EF1B5, (q31_t)0x610D05B7, (q31_t)0x537514C1, + (q31_t)0x60EC3830, (q31_t)0x539B2AEF, (q31_t)0x60CB5BB6, (q31_t)0x53C13438, + (q31_t)0x60AA704F, (q31_t)0x53E73097, (q31_t)0x60897600, (q31_t)0x540D2005, + (q31_t)0x60686CCE, (q31_t)0x5433027D, (q31_t)0x604754BE, (q31_t)0x5458D7F9, + (q31_t)0x60262DD5, (q31_t)0x547EA073, (q31_t)0x6004F818, (q31_t)0x54A45BE5, + (q31_t)0x5FE3B38D, (q31_t)0x54CA0A4A, (q31_t)0x5FC26038, (q31_t)0x54EFAB9C, + (q31_t)0x5FA0FE1E, (q31_t)0x55153FD4, (q31_t)0x5F7F8D46, (q31_t)0x553AC6ED, + (q31_t)0x5F5E0DB3, (q31_t)0x556040E2, (q31_t)0x5F3C7F6B, (q31_t)0x5585ADAC, + (q31_t)0x5F1AE273, (q31_t)0x55AB0D46, (q31_t)0x5EF936D1, (q31_t)0x55D05FAA, + (q31_t)0x5ED77C89, (q31_t)0x55F5A4D2, (q31_t)0x5EB5B3A1, (q31_t)0x561ADCB8, + (q31_t)0x5E93DC1F, (q31_t)0x56400757, (q31_t)0x5E71F606, (q31_t)0x566524AA, + (q31_t)0x5E50015D, (q31_t)0x568A34A9, (q31_t)0x5E2DFE28, (q31_t)0x56AF3750, + (q31_t)0x5E0BEC6E, (q31_t)0x56D42C99, (q31_t)0x5DE9CC32, (q31_t)0x56F9147E, + (q31_t)0x5DC79D7C, (q31_t)0x571DEEF9, (q31_t)0x5DA5604E, (q31_t)0x5742BC05, + (q31_t)0x5D8314B0, (q31_t)0x57677B9D, (q31_t)0x5D60BAA6, (q31_t)0x578C2DB9, + (q31_t)0x5D3E5236, (q31_t)0x57B0D256, (q31_t)0x5D1BDB65, (q31_t)0x57D5696C, + (q31_t)0x5CF95638, (q31_t)0x57F9F2F7, (q31_t)0x5CD6C2B4, (q31_t)0x581E6EF1, + (q31_t)0x5CB420DF, (q31_t)0x5842DD54, (q31_t)0x5C9170BF, (q31_t)0x58673E1B, + (q31_t)0x5C6EB258, (q31_t)0x588B913F, (q31_t)0x5C4BE5B0, (q31_t)0x58AFD6BC, + (q31_t)0x5C290ACC, (q31_t)0x58D40E8C, (q31_t)0x5C0621B2, (q31_t)0x58F838A9, + (q31_t)0x5BE32A67, (q31_t)0x591C550E, (q31_t)0x5BC024F0, (q31_t)0x594063B4, + (q31_t)0x5B9D1153, (q31_t)0x59646497, (q31_t)0x5B79EF96, (q31_t)0x598857B1, + (q31_t)0x5B56BFBD, (q31_t)0x59AC3CFD, (q31_t)0x5B3381CE, (q31_t)0x59D01474, + (q31_t)0x5B1035CF, (q31_t)0x59F3DE12, (q31_t)0x5AECDBC4, (q31_t)0x5A1799D0, + (q31_t)0x5AC973B4, (q31_t)0x5A3B47AA, (q31_t)0x5AA5FDA4, (q31_t)0x5A5EE79A, + (q31_t)0x5A82799A, (q31_t)0x5A82799A, (q31_t)0x5A5EE79A, (q31_t)0x5AA5FDA4, + (q31_t)0x5A3B47AA, (q31_t)0x5AC973B4, (q31_t)0x5A1799D0, (q31_t)0x5AECDBC4, + (q31_t)0x59F3DE12, (q31_t)0x5B1035CF, (q31_t)0x59D01474, (q31_t)0x5B3381CE, + (q31_t)0x59AC3CFD, (q31_t)0x5B56BFBD, (q31_t)0x598857B1, (q31_t)0x5B79EF96, + (q31_t)0x59646497, (q31_t)0x5B9D1153, (q31_t)0x594063B4, (q31_t)0x5BC024F0, + (q31_t)0x591C550E, (q31_t)0x5BE32A67, (q31_t)0x58F838A9, (q31_t)0x5C0621B2, + (q31_t)0x58D40E8C, (q31_t)0x5C290ACC, (q31_t)0x58AFD6BC, (q31_t)0x5C4BE5B0, + (q31_t)0x588B913F, (q31_t)0x5C6EB258, (q31_t)0x58673E1B, (q31_t)0x5C9170BF, + (q31_t)0x5842DD54, (q31_t)0x5CB420DF, (q31_t)0x581E6EF1, (q31_t)0x5CD6C2B4, + (q31_t)0x57F9F2F7, (q31_t)0x5CF95638, (q31_t)0x57D5696C, (q31_t)0x5D1BDB65, + (q31_t)0x57B0D256, (q31_t)0x5D3E5236, (q31_t)0x578C2DB9, (q31_t)0x5D60BAA6, + (q31_t)0x57677B9D, (q31_t)0x5D8314B0, (q31_t)0x5742BC05, (q31_t)0x5DA5604E, + (q31_t)0x571DEEF9, (q31_t)0x5DC79D7C, (q31_t)0x56F9147E, (q31_t)0x5DE9CC32, + (q31_t)0x56D42C99, (q31_t)0x5E0BEC6E, (q31_t)0x56AF3750, (q31_t)0x5E2DFE28, + (q31_t)0x568A34A9, (q31_t)0x5E50015D, (q31_t)0x566524AA, (q31_t)0x5E71F606, + (q31_t)0x56400757, (q31_t)0x5E93DC1F, (q31_t)0x561ADCB8, (q31_t)0x5EB5B3A1, + (q31_t)0x55F5A4D2, (q31_t)0x5ED77C89, (q31_t)0x55D05FAA, (q31_t)0x5EF936D1, + (q31_t)0x55AB0D46, (q31_t)0x5F1AE273, (q31_t)0x5585ADAC, (q31_t)0x5F3C7F6B, + (q31_t)0x556040E2, (q31_t)0x5F5E0DB3, (q31_t)0x553AC6ED, (q31_t)0x5F7F8D46, + (q31_t)0x55153FD4, (q31_t)0x5FA0FE1E, (q31_t)0x54EFAB9C, (q31_t)0x5FC26038, + (q31_t)0x54CA0A4A, (q31_t)0x5FE3B38D, (q31_t)0x54A45BE5, (q31_t)0x6004F818, + (q31_t)0x547EA073, (q31_t)0x60262DD5, (q31_t)0x5458D7F9, (q31_t)0x604754BE, + (q31_t)0x5433027D, (q31_t)0x60686CCE, (q31_t)0x540D2005, (q31_t)0x60897600, + (q31_t)0x53E73097, (q31_t)0x60AA704F, (q31_t)0x53C13438, (q31_t)0x60CB5BB6, + (q31_t)0x539B2AEF, (q31_t)0x60EC3830, (q31_t)0x537514C1, (q31_t)0x610D05B7, + (q31_t)0x534EF1B5, (q31_t)0x612DC446, (q31_t)0x5328C1D0, (q31_t)0x614E73D9, + (q31_t)0x53028517, (q31_t)0x616F146B, (q31_t)0x52DC3B92, (q31_t)0x618FA5F6, + (q31_t)0x52B5E545, (q31_t)0x61B02876, (q31_t)0x528F8237, (q31_t)0x61D09BE5, + (q31_t)0x5269126E, (q31_t)0x61F1003E, (q31_t)0x524295EF, (q31_t)0x6211557D, + (q31_t)0x521C0CC1, (q31_t)0x62319B9D, (q31_t)0x51F576E9, (q31_t)0x6251D297, + (q31_t)0x51CED46E, (q31_t)0x6271FA69, (q31_t)0x51A82555, (q31_t)0x6292130C, + (q31_t)0x518169A4, (q31_t)0x62B21C7B, (q31_t)0x515AA162, (q31_t)0x62D216B2, + (q31_t)0x5133CC94, (q31_t)0x62F201AC, (q31_t)0x510CEB40, (q31_t)0x6311DD63, + (q31_t)0x50E5FD6C, (q31_t)0x6331A9D4, (q31_t)0x50BF031F, (q31_t)0x635166F8, + (q31_t)0x5097FC5E, (q31_t)0x637114CC, (q31_t)0x5070E92F, (q31_t)0x6390B34A, + (q31_t)0x5049C999, (q31_t)0x63B0426D, (q31_t)0x50229DA0, (q31_t)0x63CFC230, + (q31_t)0x4FFB654D, (q31_t)0x63EF328F, (q31_t)0x4FD420A3, (q31_t)0x640E9385, + (q31_t)0x4FACCFAB, (q31_t)0x642DE50D, (q31_t)0x4F857268, (q31_t)0x644D2722, + (q31_t)0x4F5E08E3, (q31_t)0x646C59BF, (q31_t)0x4F369320, (q31_t)0x648B7CDF, + (q31_t)0x4F0F1126, (q31_t)0x64AA907F, (q31_t)0x4EE782FA, (q31_t)0x64C99498, + (q31_t)0x4EBFE8A4, (q31_t)0x64E88926, (q31_t)0x4E984229, (q31_t)0x65076E24, + (q31_t)0x4E708F8F, (q31_t)0x6526438E, (q31_t)0x4E48D0DC, (q31_t)0x6545095F, + (q31_t)0x4E210617, (q31_t)0x6563BF92, (q31_t)0x4DF92F45, (q31_t)0x65826622, + (q31_t)0x4DD14C6E, (q31_t)0x65A0FD0B, (q31_t)0x4DA95D96, (q31_t)0x65BF8447, + (q31_t)0x4D8162C4, (q31_t)0x65DDFBD3, (q31_t)0x4D595BFE, (q31_t)0x65FC63A9, + (q31_t)0x4D31494B, (q31_t)0x661ABBC5, (q31_t)0x4D092AB0, (q31_t)0x66390422, + (q31_t)0x4CE10034, (q31_t)0x66573CBB, (q31_t)0x4CB8C9DD, (q31_t)0x6675658C, + (q31_t)0x4C9087B1, (q31_t)0x66937E90, (q31_t)0x4C6839B6, (q31_t)0x66B187C3, + (q31_t)0x4C3FDFF3, (q31_t)0x66CF811F, (q31_t)0x4C177A6E, (q31_t)0x66ED6AA1, + (q31_t)0x4BEF092D, (q31_t)0x670B4443, (q31_t)0x4BC68C36, (q31_t)0x67290E02, + (q31_t)0x4B9E038F, (q31_t)0x6746C7D7, (q31_t)0x4B756F3F, (q31_t)0x676471C0, + (q31_t)0x4B4CCF4D, (q31_t)0x67820BB6, (q31_t)0x4B2423BD, (q31_t)0x679F95B7, + (q31_t)0x4AFB6C97, (q31_t)0x67BD0FBC, (q31_t)0x4AD2A9E1, (q31_t)0x67DA79C2, + (q31_t)0x4AA9DBA1, (q31_t)0x67F7D3C4, (q31_t)0x4A8101DE, (q31_t)0x68151DBE, + (q31_t)0x4A581C9D, (q31_t)0x683257AA, (q31_t)0x4A2F2BE5, (q31_t)0x684F8186, + (q31_t)0x4A062FBD, (q31_t)0x686C9B4B, (q31_t)0x49DD282A, (q31_t)0x6889A4F5, + (q31_t)0x49B41533, (q31_t)0x68A69E81, (q31_t)0x498AF6DE, (q31_t)0x68C387E9, + (q31_t)0x4961CD32, (q31_t)0x68E06129, (q31_t)0x49389836, (q31_t)0x68FD2A3D, + (q31_t)0x490F57EE, (q31_t)0x6919E320, (q31_t)0x48E60C62, (q31_t)0x69368BCE, + (q31_t)0x48BCB598, (q31_t)0x69532442, (q31_t)0x48935397, (q31_t)0x696FAC78, + (q31_t)0x4869E664, (q31_t)0x698C246C, (q31_t)0x48406E07, (q31_t)0x69A88C18, + (q31_t)0x4816EA85, (q31_t)0x69C4E37A, (q31_t)0x47ED5BE6, (q31_t)0x69E12A8C, + (q31_t)0x47C3C22E, (q31_t)0x69FD614A, (q31_t)0x479A1D66, (q31_t)0x6A1987B0, + (q31_t)0x47706D93, (q31_t)0x6A359DB9, (q31_t)0x4746B2BC, (q31_t)0x6A51A361, + (q31_t)0x471CECE6, (q31_t)0x6A6D98A4, (q31_t)0x46F31C1A, (q31_t)0x6A897D7D, + (q31_t)0x46C9405C, (q31_t)0x6AA551E8, (q31_t)0x469F59B4, (q31_t)0x6AC115E1, + (q31_t)0x46756827, (q31_t)0x6ADCC964, (q31_t)0x464B6BBD, (q31_t)0x6AF86C6C, + (q31_t)0x4621647C, (q31_t)0x6B13FEF5, (q31_t)0x45F7526B, (q31_t)0x6B2F80FA, + (q31_t)0x45CD358F, (q31_t)0x6B4AF278, (q31_t)0x45A30DF0, (q31_t)0x6B66536A, + (q31_t)0x4578DB93, (q31_t)0x6B81A3CD, (q31_t)0x454E9E80, (q31_t)0x6B9CE39B, + (q31_t)0x452456BC, (q31_t)0x6BB812D0, (q31_t)0x44FA044F, (q31_t)0x6BD3316A, + (q31_t)0x44CFA73F, (q31_t)0x6BEE3F62, (q31_t)0x44A53F93, (q31_t)0x6C093CB6, + (q31_t)0x447ACD50, (q31_t)0x6C242960, (q31_t)0x4450507E, (q31_t)0x6C3F055D, + (q31_t)0x4425C923, (q31_t)0x6C59D0A9, (q31_t)0x43FB3745, (q31_t)0x6C748B3F, + (q31_t)0x43D09AEC, (q31_t)0x6C8F351C, (q31_t)0x43A5F41E, (q31_t)0x6CA9CE3A, + (q31_t)0x437B42E1, (q31_t)0x6CC45697, (q31_t)0x4350873C, (q31_t)0x6CDECE2E, + (q31_t)0x4325C135, (q31_t)0x6CF934FB, (q31_t)0x42FAF0D4, (q31_t)0x6D138AFA, + (q31_t)0x42D0161E, (q31_t)0x6D2DD027, (q31_t)0x42A5311A, (q31_t)0x6D48047E, + (q31_t)0x427A41D0, (q31_t)0x6D6227FA, (q31_t)0x424F4845, (q31_t)0x6D7C3A98, + (q31_t)0x42244480, (q31_t)0x6D963C54, (q31_t)0x41F93688, (q31_t)0x6DB02D29, + (q31_t)0x41CE1E64, (q31_t)0x6DCA0D14, (q31_t)0x41A2FC1A, (q31_t)0x6DE3DC11, + (q31_t)0x4177CFB0, (q31_t)0x6DFD9A1B, (q31_t)0x414C992E, (q31_t)0x6E17472F, + (q31_t)0x4121589A, (q31_t)0x6E30E349, (q31_t)0x40F60DFB, (q31_t)0x6E4A6E65, + (q31_t)0x40CAB957, (q31_t)0x6E63E87F, (q31_t)0x409F5AB6, (q31_t)0x6E7D5193, + (q31_t)0x4073F21D, (q31_t)0x6E96A99C, (q31_t)0x40487F93, (q31_t)0x6EAFF098, + (q31_t)0x401D0320, (q31_t)0x6EC92682, (q31_t)0x3FF17CCA, (q31_t)0x6EE24B57, + (q31_t)0x3FC5EC97, (q31_t)0x6EFB5F12, (q31_t)0x3F9A528F, (q31_t)0x6F1461AF, + (q31_t)0x3F6EAEB8, (q31_t)0x6F2D532C, (q31_t)0x3F430118, (q31_t)0x6F463383, + (q31_t)0x3F1749B7, (q31_t)0x6F5F02B1, (q31_t)0x3EEB889C, (q31_t)0x6F77C0B3, + (q31_t)0x3EBFBDCC, (q31_t)0x6F906D84, (q31_t)0x3E93E94F, (q31_t)0x6FA90920, + (q31_t)0x3E680B2C, (q31_t)0x6FC19385, (q31_t)0x3E3C2369, (q31_t)0x6FDA0CAD, + (q31_t)0x3E10320D, (q31_t)0x6FF27496, (q31_t)0x3DE4371F, (q31_t)0x700ACB3B, + (q31_t)0x3DB832A5, (q31_t)0x70231099, (q31_t)0x3D8C24A7, (q31_t)0x703B44AC, + (q31_t)0x3D600D2B, (q31_t)0x70536771, (q31_t)0x3D33EC39, (q31_t)0x706B78E3, + (q31_t)0x3D07C1D5, (q31_t)0x708378FE, (q31_t)0x3CDB8E09, (q31_t)0x709B67C0, + (q31_t)0x3CAF50DA, (q31_t)0x70B34524, (q31_t)0x3C830A4F, (q31_t)0x70CB1127, + (q31_t)0x3C56BA70, (q31_t)0x70E2CBC6, (q31_t)0x3C2A6142, (q31_t)0x70FA74FB, + (q31_t)0x3BFDFECD, (q31_t)0x71120CC5, (q31_t)0x3BD19317, (q31_t)0x7129931E, + (q31_t)0x3BA51E29, (q31_t)0x71410804, (q31_t)0x3B78A007, (q31_t)0x71586B73, + (q31_t)0x3B4C18BA, (q31_t)0x716FBD68, (q31_t)0x3B1F8847, (q31_t)0x7186FDDE, + (q31_t)0x3AF2EEB7, (q31_t)0x719E2CD2, (q31_t)0x3AC64C0F, (q31_t)0x71B54A40, + (q31_t)0x3A99A057, (q31_t)0x71CC5626, (q31_t)0x3A6CEB95, (q31_t)0x71E3507F, + (q31_t)0x3A402DD1, (q31_t)0x71FA3948, (q31_t)0x3A136712, (q31_t)0x7211107D, + (q31_t)0x39E6975D, (q31_t)0x7227D61C, (q31_t)0x39B9BEBB, (q31_t)0x723E8A1F, + (q31_t)0x398CDD32, (q31_t)0x72552C84, (q31_t)0x395FF2C9, (q31_t)0x726BBD48, + (q31_t)0x3932FF87, (q31_t)0x72823C66, (q31_t)0x39060372, (q31_t)0x7298A9DC, + (q31_t)0x38D8FE93, (q31_t)0x72AF05A6, (q31_t)0x38ABF0EF, (q31_t)0x72C54FC0, + (q31_t)0x387EDA8E, (q31_t)0x72DB8828, (q31_t)0x3851BB76, (q31_t)0x72F1AED8, + (q31_t)0x382493B0, (q31_t)0x7307C3D0, (q31_t)0x37F76340, (q31_t)0x731DC709, + (q31_t)0x37CA2A30, (q31_t)0x7333B883, (q31_t)0x379CE884, (q31_t)0x73499838, + (q31_t)0x376F9E46, (q31_t)0x735F6626, (q31_t)0x37424B7A, (q31_t)0x73752249, + (q31_t)0x3714F02A, (q31_t)0x738ACC9E, (q31_t)0x36E78C5A, (q31_t)0x73A06522, + (q31_t)0x36BA2013, (q31_t)0x73B5EBD0, (q31_t)0x368CAB5C, (q31_t)0x73CB60A7, + (q31_t)0x365F2E3B, (q31_t)0x73E0C3A3, (q31_t)0x3631A8B7, (q31_t)0x73F614C0, + (q31_t)0x36041AD9, (q31_t)0x740B53FA, (q31_t)0x35D684A5, (q31_t)0x74208150, + (q31_t)0x35A8E624, (q31_t)0x74359CBD, (q31_t)0x357B3F5D, (q31_t)0x744AA63E, + (q31_t)0x354D9056, (q31_t)0x745F9DD1, (q31_t)0x351FD917, (q31_t)0x74748371, + (q31_t)0x34F219A7, (q31_t)0x7489571B, (q31_t)0x34C4520D, (q31_t)0x749E18CD, + (q31_t)0x3496824F, (q31_t)0x74B2C883, (q31_t)0x3468AA76, (q31_t)0x74C7663A, + (q31_t)0x343ACA87, (q31_t)0x74DBF1EF, (q31_t)0x340CE28A, (q31_t)0x74F06B9E, + (q31_t)0x33DEF287, (q31_t)0x7504D345, (q31_t)0x33B0FA84, (q31_t)0x751928E0, + (q31_t)0x3382FA88, (q31_t)0x752D6C6C, (q31_t)0x3354F29A, (q31_t)0x75419DE6, + (q31_t)0x3326E2C2, (q31_t)0x7555BD4B, (q31_t)0x32F8CB07, (q31_t)0x7569CA98, + (q31_t)0x32CAAB6F, (q31_t)0x757DC5CA, (q31_t)0x329C8402, (q31_t)0x7591AEDD, + (q31_t)0x326E54C7, (q31_t)0x75A585CF, (q31_t)0x32401DC5, (q31_t)0x75B94A9C, + (q31_t)0x3211DF03, (q31_t)0x75CCFD42, (q31_t)0x31E39889, (q31_t)0x75E09DBD, + (q31_t)0x31B54A5D, (q31_t)0x75F42C0A, (q31_t)0x3186F487, (q31_t)0x7607A827, + (q31_t)0x3158970D, (q31_t)0x761B1211, (q31_t)0x312A31F8, (q31_t)0x762E69C3, + (q31_t)0x30FBC54D, (q31_t)0x7641AF3C, (q31_t)0x30CD5114, (q31_t)0x7654E279, + (q31_t)0x309ED555, (q31_t)0x76680376, (q31_t)0x30705217, (q31_t)0x767B1230, + (q31_t)0x3041C760, (q31_t)0x768E0EA5, (q31_t)0x30133538, (q31_t)0x76A0F8D2, + (q31_t)0x2FE49BA6, (q31_t)0x76B3D0B3, (q31_t)0x2FB5FAB2, (q31_t)0x76C69646, + (q31_t)0x2F875262, (q31_t)0x76D94988, (q31_t)0x2F58A2BD, (q31_t)0x76EBEA77, + (q31_t)0x2F29EBCC, (q31_t)0x76FE790E, (q31_t)0x2EFB2D94, (q31_t)0x7710F54B, + (q31_t)0x2ECC681E, (q31_t)0x77235F2D, (q31_t)0x2E9D9B70, (q31_t)0x7735B6AE, + (q31_t)0x2E6EC792, (q31_t)0x7747FBCE, (q31_t)0x2E3FEC8B, (q31_t)0x775A2E88, + (q31_t)0x2E110A62, (q31_t)0x776C4EDB, (q31_t)0x2DE2211E, (q31_t)0x777E5CC3, + (q31_t)0x2DB330C7, (q31_t)0x7790583D, (q31_t)0x2D843963, (q31_t)0x77A24148, + (q31_t)0x2D553AFB, (q31_t)0x77B417DF, (q31_t)0x2D263595, (q31_t)0x77C5DC01, + (q31_t)0x2CF72939, (q31_t)0x77D78DAA, (q31_t)0x2CC815ED, (q31_t)0x77E92CD8, + (q31_t)0x2C98FBBA, (q31_t)0x77FAB988, (q31_t)0x2C69DAA6, (q31_t)0x780C33B8, + (q31_t)0x2C3AB2B9, (q31_t)0x781D9B64, (q31_t)0x2C0B83F9, (q31_t)0x782EF08B, + (q31_t)0x2BDC4E6F, (q31_t)0x78403328, (q31_t)0x2BAD1221, (q31_t)0x7851633B, + (q31_t)0x2B7DCF17, (q31_t)0x786280BF, (q31_t)0x2B4E8558, (q31_t)0x78738BB3, + (q31_t)0x2B1F34EB, (q31_t)0x78848413, (q31_t)0x2AEFDDD8, (q31_t)0x789569DE, + (q31_t)0x2AC08025, (q31_t)0x78A63D10, (q31_t)0x2A911BDB, (q31_t)0x78B6FDA8, + (q31_t)0x2A61B101, (q31_t)0x78C7ABA1, (q31_t)0x2A323F9D, (q31_t)0x78D846FB, + (q31_t)0x2A02C7B8, (q31_t)0x78E8CFB1, (q31_t)0x29D34958, (q31_t)0x78F945C3, + (q31_t)0x29A3C484, (q31_t)0x7909A92C, (q31_t)0x29743945, (q31_t)0x7919F9EB, + (q31_t)0x2944A7A2, (q31_t)0x792A37FE, (q31_t)0x29150FA1, (q31_t)0x793A6360, + (q31_t)0x28E5714A, (q31_t)0x794A7C11, (q31_t)0x28B5CCA5, (q31_t)0x795A820E, + (q31_t)0x288621B9, (q31_t)0x796A7554, (q31_t)0x2856708C, (q31_t)0x797A55E0, + (q31_t)0x2826B928, (q31_t)0x798A23B1, (q31_t)0x27F6FB92, (q31_t)0x7999DEC3, + (q31_t)0x27C737D2, (q31_t)0x79A98715, (q31_t)0x27976DF1, (q31_t)0x79B91CA4, + (q31_t)0x27679DF4, (q31_t)0x79C89F6D, (q31_t)0x2737C7E3, (q31_t)0x79D80F6F, + (q31_t)0x2707EBC6, (q31_t)0x79E76CA6, (q31_t)0x26D809A5, (q31_t)0x79F6B711, + (q31_t)0x26A82185, (q31_t)0x7A05EEAD, (q31_t)0x26783370, (q31_t)0x7A151377, + (q31_t)0x26483F6C, (q31_t)0x7A24256E, (q31_t)0x26184581, (q31_t)0x7A33248F, + (q31_t)0x25E845B5, (q31_t)0x7A4210D8, (q31_t)0x25B84012, (q31_t)0x7A50EA46, + (q31_t)0x2588349D, (q31_t)0x7A5FB0D8, (q31_t)0x2558235E, (q31_t)0x7A6E648A, + (q31_t)0x25280C5D, (q31_t)0x7A7D055B, (q31_t)0x24F7EFA1, (q31_t)0x7A8B9348, + (q31_t)0x24C7CD32, (q31_t)0x7A9A0E4F, (q31_t)0x2497A517, (q31_t)0x7AA8766E, + (q31_t)0x24677757, (q31_t)0x7AB6CBA3, (q31_t)0x243743FA, (q31_t)0x7AC50DEB, + (q31_t)0x24070B07, (q31_t)0x7AD33D45, (q31_t)0x23D6CC86, (q31_t)0x7AE159AE, + (q31_t)0x23A6887E, (q31_t)0x7AEF6323, (q31_t)0x23763EF7, (q31_t)0x7AFD59A3, + (q31_t)0x2345EFF7, (q31_t)0x7B0B3D2C, (q31_t)0x23159B87, (q31_t)0x7B190DBB, + (q31_t)0x22E541AE, (q31_t)0x7B26CB4F, (q31_t)0x22B4E274, (q31_t)0x7B3475E4, + (q31_t)0x22847DDF, (q31_t)0x7B420D7A, (q31_t)0x225413F8, (q31_t)0x7B4F920E, + (q31_t)0x2223A4C5, (q31_t)0x7B5D039D, (q31_t)0x21F3304E, (q31_t)0x7B6A6227, + (q31_t)0x21C2B69C, (q31_t)0x7B77ADA8, (q31_t)0x219237B4, (q31_t)0x7B84E61E, + (q31_t)0x2161B39F, (q31_t)0x7B920B89, (q31_t)0x21312A65, (q31_t)0x7B9F1DE5, + (q31_t)0x21009C0B, (q31_t)0x7BAC1D31, (q31_t)0x20D0089B, (q31_t)0x7BB9096A, + (q31_t)0x209F701C, (q31_t)0x7BC5E28F, (q31_t)0x206ED295, (q31_t)0x7BD2A89E, + (q31_t)0x203E300D, (q31_t)0x7BDF5B94, (q31_t)0x200D888C, (q31_t)0x7BEBFB70, + (q31_t)0x1FDCDC1A, (q31_t)0x7BF88830, (q31_t)0x1FAC2ABF, (q31_t)0x7C0501D1, + (q31_t)0x1F7B7480, (q31_t)0x7C116853, (q31_t)0x1F4AB967, (q31_t)0x7C1DBBB2, + (q31_t)0x1F19F97B, (q31_t)0x7C29FBEE, (q31_t)0x1EE934C2, (q31_t)0x7C362904, + (q31_t)0x1EB86B46, (q31_t)0x7C4242F2, (q31_t)0x1E879D0C, (q31_t)0x7C4E49B6, + (q31_t)0x1E56CA1E, (q31_t)0x7C5A3D4F, (q31_t)0x1E25F281, (q31_t)0x7C661DBB, + (q31_t)0x1DF5163F, (q31_t)0x7C71EAF8, (q31_t)0x1DC4355D, (q31_t)0x7C7DA504, + (q31_t)0x1D934FE5, (q31_t)0x7C894BDD, (q31_t)0x1D6265DD, (q31_t)0x7C94DF82, + (q31_t)0x1D31774D, (q31_t)0x7CA05FF1, (q31_t)0x1D00843C, (q31_t)0x7CABCD27, + (q31_t)0x1CCF8CB3, (q31_t)0x7CB72724, (q31_t)0x1C9E90B8, (q31_t)0x7CC26DE5, + (q31_t)0x1C6D9053, (q31_t)0x7CCDA168, (q31_t)0x1C3C8B8C, (q31_t)0x7CD8C1AD, + (q31_t)0x1C0B826A, (q31_t)0x7CE3CEB1, (q31_t)0x1BDA74F5, (q31_t)0x7CEEC873, + (q31_t)0x1BA96334, (q31_t)0x7CF9AEF0, (q31_t)0x1B784D30, (q31_t)0x7D048228, + (q31_t)0x1B4732EF, (q31_t)0x7D0F4218, (q31_t)0x1B161479, (q31_t)0x7D19EEBE, + (q31_t)0x1AE4F1D6, (q31_t)0x7D24881A, (q31_t)0x1AB3CB0C, (q31_t)0x7D2F0E2A, + (q31_t)0x1A82A025, (q31_t)0x7D3980EC, (q31_t)0x1A517127, (q31_t)0x7D43E05E, + (q31_t)0x1A203E1B, (q31_t)0x7D4E2C7E, (q31_t)0x19EF0706, (q31_t)0x7D58654C, + (q31_t)0x19BDCBF2, (q31_t)0x7D628AC5, (q31_t)0x198C8CE6, (q31_t)0x7D6C9CE9, + (q31_t)0x195B49E9, (q31_t)0x7D769BB5, (q31_t)0x192A0303, (q31_t)0x7D808727, + (q31_t)0x18F8B83C, (q31_t)0x7D8A5F3F, (q31_t)0x18C7699B, (q31_t)0x7D9423FB, + (q31_t)0x18961727, (q31_t)0x7D9DD55A, (q31_t)0x1864C0E9, (q31_t)0x7DA77359, + (q31_t)0x183366E8, (q31_t)0x7DB0FDF7, (q31_t)0x1802092C, (q31_t)0x7DBA7534, + (q31_t)0x17D0A7BB, (q31_t)0x7DC3D90D, (q31_t)0x179F429F, (q31_t)0x7DCD2981, + (q31_t)0x176DD9DE, (q31_t)0x7DD6668E, (q31_t)0x173C6D80, (q31_t)0x7DDF9034, + (q31_t)0x170AFD8D, (q31_t)0x7DE8A670, (q31_t)0x16D98A0C, (q31_t)0x7DF1A942, + (q31_t)0x16A81305, (q31_t)0x7DFA98A7, (q31_t)0x1676987F, (q31_t)0x7E03749F, + (q31_t)0x16451A83, (q31_t)0x7E0C3D29, (q31_t)0x16139917, (q31_t)0x7E14F242, + (q31_t)0x15E21444, (q31_t)0x7E1D93E9, (q31_t)0x15B08C11, (q31_t)0x7E26221E, + (q31_t)0x157F0086, (q31_t)0x7E2E9CDF, (q31_t)0x154D71AA, (q31_t)0x7E37042A, + (q31_t)0x151BDF85, (q31_t)0x7E3F57FE, (q31_t)0x14EA4A1F, (q31_t)0x7E47985B, + (q31_t)0x14B8B17F, (q31_t)0x7E4FC53E, (q31_t)0x148715AD, (q31_t)0x7E57DEA6, + (q31_t)0x145576B1, (q31_t)0x7E5FE493, (q31_t)0x1423D492, (q31_t)0x7E67D702, + (q31_t)0x13F22F57, (q31_t)0x7E6FB5F3, (q31_t)0x13C0870A, (q31_t)0x7E778165, + (q31_t)0x138EDBB0, (q31_t)0x7E7F3956, (q31_t)0x135D2D53, (q31_t)0x7E86DDC5, + (q31_t)0x132B7BF9, (q31_t)0x7E8E6EB1, (q31_t)0x12F9C7AA, (q31_t)0x7E95EC19, + (q31_t)0x12C8106E, (q31_t)0x7E9D55FC, (q31_t)0x1296564D, (q31_t)0x7EA4AC58, + (q31_t)0x1264994E, (q31_t)0x7EABEF2C, (q31_t)0x1232D978, (q31_t)0x7EB31E77, + (q31_t)0x120116D4, (q31_t)0x7EBA3A39, (q31_t)0x11CF516A, (q31_t)0x7EC1426F, + (q31_t)0x119D8940, (q31_t)0x7EC8371A, (q31_t)0x116BBE5F, (q31_t)0x7ECF1837, + (q31_t)0x1139F0CE, (q31_t)0x7ED5E5C6, (q31_t)0x11082096, (q31_t)0x7EDC9FC6, + (q31_t)0x10D64DBC, (q31_t)0x7EE34635, (q31_t)0x10A4784A, (q31_t)0x7EE9D913, + (q31_t)0x1072A047, (q31_t)0x7EF0585F, (q31_t)0x1040C5BB, (q31_t)0x7EF6C418, + (q31_t)0x100EE8AD, (q31_t)0x7EFD1C3C, (q31_t)0x0FDD0925, (q31_t)0x7F0360CB, + (q31_t)0x0FAB272B, (q31_t)0x7F0991C3, (q31_t)0x0F7942C6, (q31_t)0x7F0FAF24, + (q31_t)0x0F475BFE, (q31_t)0x7F15B8EE, (q31_t)0x0F1572DC, (q31_t)0x7F1BAF1E, + (q31_t)0x0EE38765, (q31_t)0x7F2191B4, (q31_t)0x0EB199A3, (q31_t)0x7F2760AF, + (q31_t)0x0E7FA99D, (q31_t)0x7F2D1C0E, (q31_t)0x0E4DB75B, (q31_t)0x7F32C3D0, + (q31_t)0x0E1BC2E3, (q31_t)0x7F3857F5, (q31_t)0x0DE9CC3F, (q31_t)0x7F3DD87C, + (q31_t)0x0DB7D376, (q31_t)0x7F434563, (q31_t)0x0D85D88F, (q31_t)0x7F489EAA, + (q31_t)0x0D53DB92, (q31_t)0x7F4DE450, (q31_t)0x0D21DC87, (q31_t)0x7F531654, + (q31_t)0x0CEFDB75, (q31_t)0x7F5834B6, (q31_t)0x0CBDD865, (q31_t)0x7F5D3F75, + (q31_t)0x0C8BD35E, (q31_t)0x7F62368F, (q31_t)0x0C59CC67, (q31_t)0x7F671A04, + (q31_t)0x0C27C389, (q31_t)0x7F6BE9D4, (q31_t)0x0BF5B8CB, (q31_t)0x7F70A5FD, + (q31_t)0x0BC3AC35, (q31_t)0x7F754E7F, (q31_t)0x0B919DCE, (q31_t)0x7F79E35A, + (q31_t)0x0B5F8D9F, (q31_t)0x7F7E648B, (q31_t)0x0B2D7BAE, (q31_t)0x7F82D214, + (q31_t)0x0AFB6805, (q31_t)0x7F872BF3, (q31_t)0x0AC952AA, (q31_t)0x7F8B7226, + (q31_t)0x0A973BA5, (q31_t)0x7F8FA4AF, (q31_t)0x0A6522FE, (q31_t)0x7F93C38C, + (q31_t)0x0A3308BC, (q31_t)0x7F97CEBC, (q31_t)0x0A00ECE8, (q31_t)0x7F9BC63F, + (q31_t)0x09CECF89, (q31_t)0x7F9FAA15, (q31_t)0x099CB0A7, (q31_t)0x7FA37A3C, + (q31_t)0x096A9049, (q31_t)0x7FA736B4, (q31_t)0x09386E77, (q31_t)0x7FAADF7C, + (q31_t)0x09064B3A, (q31_t)0x7FAE7494, (q31_t)0x08D42698, (q31_t)0x7FB1F5FC, + (q31_t)0x08A2009A, (q31_t)0x7FB563B2, (q31_t)0x086FD947, (q31_t)0x7FB8BDB7, + (q31_t)0x083DB0A7, (q31_t)0x7FBC040A, (q31_t)0x080B86C1, (q31_t)0x7FBF36A9, + (q31_t)0x07D95B9E, (q31_t)0x7FC25596, (q31_t)0x07A72F45, (q31_t)0x7FC560CF, + (q31_t)0x077501BE, (q31_t)0x7FC85853, (q31_t)0x0742D310, (q31_t)0x7FCB3C23, + (q31_t)0x0710A344, (q31_t)0x7FCE0C3E, (q31_t)0x06DE7261, (q31_t)0x7FD0C8A3, + (q31_t)0x06AC406F, (q31_t)0x7FD37152, (q31_t)0x067A0D75, (q31_t)0x7FD6064B, + (q31_t)0x0647D97C, (q31_t)0x7FD8878D, (q31_t)0x0615A48A, (q31_t)0x7FDAF518, + (q31_t)0x05E36EA9, (q31_t)0x7FDD4EEC, (q31_t)0x05B137DF, (q31_t)0x7FDF9508, + (q31_t)0x057F0034, (q31_t)0x7FE1C76B, (q31_t)0x054CC7B0, (q31_t)0x7FE3E616, + (q31_t)0x051A8E5C, (q31_t)0x7FE5F108, (q31_t)0x04E8543D, (q31_t)0x7FE7E840, + (q31_t)0x04B6195D, (q31_t)0x7FE9CBC0, (q31_t)0x0483DDC3, (q31_t)0x7FEB9B85, + (q31_t)0x0451A176, (q31_t)0x7FED5790, (q31_t)0x041F647F, (q31_t)0x7FEEFFE1, + (q31_t)0x03ED26E6, (q31_t)0x7FF09477, (q31_t)0x03BAE8B1, (q31_t)0x7FF21553, + (q31_t)0x0388A9E9, (q31_t)0x7FF38273, (q31_t)0x03566A96, (q31_t)0x7FF4DBD8, + (q31_t)0x03242ABF, (q31_t)0x7FF62182, (q31_t)0x02F1EA6B, (q31_t)0x7FF7536F, + (q31_t)0x02BFA9A4, (q31_t)0x7FF871A1, (q31_t)0x028D6870, (q31_t)0x7FF97C17, + (q31_t)0x025B26D7, (q31_t)0x7FFA72D1, (q31_t)0x0228E4E1, (q31_t)0x7FFB55CE, + (q31_t)0x01F6A296, (q31_t)0x7FFC250F, (q31_t)0x01C45FFE, (q31_t)0x7FFCE093, + (q31_t)0x01921D1F, (q31_t)0x7FFD885A, (q31_t)0x015FDA03, (q31_t)0x7FFE1C64, + (q31_t)0x012D96B0, (q31_t)0x7FFE9CB2, (q31_t)0x00FB532F, (q31_t)0x7FFF0942, + (q31_t)0x00C90F88, (q31_t)0x7FFF6216, (q31_t)0x0096CBC1, (q31_t)0x7FFFA72C, + (q31_t)0x006487E3, (q31_t)0x7FFFD885, (q31_t)0x003243F5, (q31_t)0x7FFFF621, + (q31_t)0x00000000, (q31_t)0x7FFFFFFF, (q31_t)0xFFCDBC0A, (q31_t)0x7FFFF621, + (q31_t)0xFF9B781D, (q31_t)0x7FFFD885, (q31_t)0xFF69343E, (q31_t)0x7FFFA72C, + (q31_t)0xFF36F078, (q31_t)0x7FFF6216, (q31_t)0xFF04ACD0, (q31_t)0x7FFF0942, + (q31_t)0xFED2694F, (q31_t)0x7FFE9CB2, (q31_t)0xFEA025FC, (q31_t)0x7FFE1C64, + (q31_t)0xFE6DE2E0, (q31_t)0x7FFD885A, (q31_t)0xFE3BA001, (q31_t)0x7FFCE093, + (q31_t)0xFE095D69, (q31_t)0x7FFC250F, (q31_t)0xFDD71B1E, (q31_t)0x7FFB55CE, + (q31_t)0xFDA4D928, (q31_t)0x7FFA72D1, (q31_t)0xFD72978F, (q31_t)0x7FF97C17, + (q31_t)0xFD40565B, (q31_t)0x7FF871A1, (q31_t)0xFD0E1594, (q31_t)0x7FF7536F, + (q31_t)0xFCDBD541, (q31_t)0x7FF62182, (q31_t)0xFCA99569, (q31_t)0x7FF4DBD8, + (q31_t)0xFC775616, (q31_t)0x7FF38273, (q31_t)0xFC45174E, (q31_t)0x7FF21553, + (q31_t)0xFC12D919, (q31_t)0x7FF09477, (q31_t)0xFBE09B80, (q31_t)0x7FEEFFE1, + (q31_t)0xFBAE5E89, (q31_t)0x7FED5790, (q31_t)0xFB7C223C, (q31_t)0x7FEB9B85, + (q31_t)0xFB49E6A2, (q31_t)0x7FE9CBC0, (q31_t)0xFB17ABC2, (q31_t)0x7FE7E840, + (q31_t)0xFAE571A4, (q31_t)0x7FE5F108, (q31_t)0xFAB3384F, (q31_t)0x7FE3E616, + (q31_t)0xFA80FFCB, (q31_t)0x7FE1C76B, (q31_t)0xFA4EC820, (q31_t)0x7FDF9508, + (q31_t)0xFA1C9156, (q31_t)0x7FDD4EEC, (q31_t)0xF9EA5B75, (q31_t)0x7FDAF518, + (q31_t)0xF9B82683, (q31_t)0x7FD8878D, (q31_t)0xF985F28A, (q31_t)0x7FD6064B, + (q31_t)0xF953BF90, (q31_t)0x7FD37152, (q31_t)0xF9218D9E, (q31_t)0x7FD0C8A3, + (q31_t)0xF8EF5CBB, (q31_t)0x7FCE0C3E, (q31_t)0xF8BD2CEF, (q31_t)0x7FCB3C23, + (q31_t)0xF88AFE41, (q31_t)0x7FC85853, (q31_t)0xF858D0BA, (q31_t)0x7FC560CF, + (q31_t)0xF826A461, (q31_t)0x7FC25596, (q31_t)0xF7F4793E, (q31_t)0x7FBF36A9, + (q31_t)0xF7C24F58, (q31_t)0x7FBC040A, (q31_t)0xF79026B8, (q31_t)0x7FB8BDB7, + (q31_t)0xF75DFF65, (q31_t)0x7FB563B2, (q31_t)0xF72BD967, (q31_t)0x7FB1F5FC, + (q31_t)0xF6F9B4C5, (q31_t)0x7FAE7494, (q31_t)0xF6C79188, (q31_t)0x7FAADF7C, + (q31_t)0xF6956FB6, (q31_t)0x7FA736B4, (q31_t)0xF6634F58, (q31_t)0x7FA37A3C, + (q31_t)0xF6313076, (q31_t)0x7F9FAA15, (q31_t)0xF5FF1317, (q31_t)0x7F9BC63F, + (q31_t)0xF5CCF743, (q31_t)0x7F97CEBC, (q31_t)0xF59ADD01, (q31_t)0x7F93C38C, + (q31_t)0xF568C45A, (q31_t)0x7F8FA4AF, (q31_t)0xF536AD55, (q31_t)0x7F8B7226, + (q31_t)0xF50497FA, (q31_t)0x7F872BF3, (q31_t)0xF4D28451, (q31_t)0x7F82D214, + (q31_t)0xF4A07260, (q31_t)0x7F7E648B, (q31_t)0xF46E6231, (q31_t)0x7F79E35A, + (q31_t)0xF43C53CA, (q31_t)0x7F754E7F, (q31_t)0xF40A4734, (q31_t)0x7F70A5FD, + (q31_t)0xF3D83C76, (q31_t)0x7F6BE9D4, (q31_t)0xF3A63398, (q31_t)0x7F671A04, + (q31_t)0xF3742CA1, (q31_t)0x7F62368F, (q31_t)0xF342279A, (q31_t)0x7F5D3F75, + (q31_t)0xF310248A, (q31_t)0x7F5834B6, (q31_t)0xF2DE2378, (q31_t)0x7F531654, + (q31_t)0xF2AC246D, (q31_t)0x7F4DE450, (q31_t)0xF27A2770, (q31_t)0x7F489EAA, + (q31_t)0xF2482C89, (q31_t)0x7F434563, (q31_t)0xF21633C0, (q31_t)0x7F3DD87C, + (q31_t)0xF1E43D1C, (q31_t)0x7F3857F5, (q31_t)0xF1B248A5, (q31_t)0x7F32C3D0, + (q31_t)0xF1805662, (q31_t)0x7F2D1C0E, (q31_t)0xF14E665C, (q31_t)0x7F2760AF, + (q31_t)0xF11C789A, (q31_t)0x7F2191B4, (q31_t)0xF0EA8D23, (q31_t)0x7F1BAF1E, + (q31_t)0xF0B8A401, (q31_t)0x7F15B8EE, (q31_t)0xF086BD39, (q31_t)0x7F0FAF24, + (q31_t)0xF054D8D4, (q31_t)0x7F0991C3, (q31_t)0xF022F6DA, (q31_t)0x7F0360CB, + (q31_t)0xEFF11752, (q31_t)0x7EFD1C3C, (q31_t)0xEFBF3A44, (q31_t)0x7EF6C418, + (q31_t)0xEF8D5FB8, (q31_t)0x7EF0585F, (q31_t)0xEF5B87B5, (q31_t)0x7EE9D913, + (q31_t)0xEF29B243, (q31_t)0x7EE34635, (q31_t)0xEEF7DF6A, (q31_t)0x7EDC9FC6, + (q31_t)0xEEC60F31, (q31_t)0x7ED5E5C6, (q31_t)0xEE9441A0, (q31_t)0x7ECF1837, + (q31_t)0xEE6276BF, (q31_t)0x7EC8371A, (q31_t)0xEE30AE95, (q31_t)0x7EC1426F, + (q31_t)0xEDFEE92B, (q31_t)0x7EBA3A39, (q31_t)0xEDCD2687, (q31_t)0x7EB31E77, + (q31_t)0xED9B66B2, (q31_t)0x7EABEF2C, (q31_t)0xED69A9B2, (q31_t)0x7EA4AC58, + (q31_t)0xED37EF91, (q31_t)0x7E9D55FC, (q31_t)0xED063855, (q31_t)0x7E95EC19, + (q31_t)0xECD48406, (q31_t)0x7E8E6EB1, (q31_t)0xECA2D2AC, (q31_t)0x7E86DDC5, + (q31_t)0xEC71244F, (q31_t)0x7E7F3956, (q31_t)0xEC3F78F5, (q31_t)0x7E778165, + (q31_t)0xEC0DD0A8, (q31_t)0x7E6FB5F3, (q31_t)0xEBDC2B6D, (q31_t)0x7E67D702, + (q31_t)0xEBAA894E, (q31_t)0x7E5FE493, (q31_t)0xEB78EA52, (q31_t)0x7E57DEA6, + (q31_t)0xEB474E80, (q31_t)0x7E4FC53E, (q31_t)0xEB15B5E0, (q31_t)0x7E47985B, + (q31_t)0xEAE4207A, (q31_t)0x7E3F57FE, (q31_t)0xEAB28E55, (q31_t)0x7E37042A, + (q31_t)0xEA80FF79, (q31_t)0x7E2E9CDF, (q31_t)0xEA4F73EE, (q31_t)0x7E26221E, + (q31_t)0xEA1DEBBB, (q31_t)0x7E1D93E9, (q31_t)0xE9EC66E8, (q31_t)0x7E14F242, + (q31_t)0xE9BAE57C, (q31_t)0x7E0C3D29, (q31_t)0xE9896780, (q31_t)0x7E03749F, + (q31_t)0xE957ECFB, (q31_t)0x7DFA98A7, (q31_t)0xE92675F4, (q31_t)0x7DF1A942, + (q31_t)0xE8F50273, (q31_t)0x7DE8A670, (q31_t)0xE8C3927F, (q31_t)0x7DDF9034, + (q31_t)0xE8922621, (q31_t)0x7DD6668E, (q31_t)0xE860BD60, (q31_t)0x7DCD2981, + (q31_t)0xE82F5844, (q31_t)0x7DC3D90D, (q31_t)0xE7FDF6D3, (q31_t)0x7DBA7534, + (q31_t)0xE7CC9917, (q31_t)0x7DB0FDF7, (q31_t)0xE79B3F16, (q31_t)0x7DA77359, + (q31_t)0xE769E8D8, (q31_t)0x7D9DD55A, (q31_t)0xE7389664, (q31_t)0x7D9423FB, + (q31_t)0xE70747C3, (q31_t)0x7D8A5F3F, (q31_t)0xE6D5FCFC, (q31_t)0x7D808727, + (q31_t)0xE6A4B616, (q31_t)0x7D769BB5, (q31_t)0xE6737319, (q31_t)0x7D6C9CE9, + (q31_t)0xE642340D, (q31_t)0x7D628AC5, (q31_t)0xE610F8F9, (q31_t)0x7D58654C, + (q31_t)0xE5DFC1E4, (q31_t)0x7D4E2C7E, (q31_t)0xE5AE8ED8, (q31_t)0x7D43E05E, + (q31_t)0xE57D5FDA, (q31_t)0x7D3980EC, (q31_t)0xE54C34F3, (q31_t)0x7D2F0E2A, + (q31_t)0xE51B0E2A, (q31_t)0x7D24881A, (q31_t)0xE4E9EB86, (q31_t)0x7D19EEBE, + (q31_t)0xE4B8CD10, (q31_t)0x7D0F4218, (q31_t)0xE487B2CF, (q31_t)0x7D048228, + (q31_t)0xE4569CCB, (q31_t)0x7CF9AEF0, (q31_t)0xE4258B0A, (q31_t)0x7CEEC873, + (q31_t)0xE3F47D95, (q31_t)0x7CE3CEB1, (q31_t)0xE3C37473, (q31_t)0x7CD8C1AD, + (q31_t)0xE3926FAC, (q31_t)0x7CCDA168, (q31_t)0xE3616F47, (q31_t)0x7CC26DE5, + (q31_t)0xE330734C, (q31_t)0x7CB72724, (q31_t)0xE2FF7BC3, (q31_t)0x7CABCD27, + (q31_t)0xE2CE88B2, (q31_t)0x7CA05FF1, (q31_t)0xE29D9A22, (q31_t)0x7C94DF82, + (q31_t)0xE26CB01A, (q31_t)0x7C894BDD, (q31_t)0xE23BCAA2, (q31_t)0x7C7DA504, + (q31_t)0xE20AE9C1, (q31_t)0x7C71EAF8, (q31_t)0xE1DA0D7E, (q31_t)0x7C661DBB, + (q31_t)0xE1A935E1, (q31_t)0x7C5A3D4F, (q31_t)0xE17862F3, (q31_t)0x7C4E49B6, + (q31_t)0xE14794B9, (q31_t)0x7C4242F2, (q31_t)0xE116CB3D, (q31_t)0x7C362904, + (q31_t)0xE0E60684, (q31_t)0x7C29FBEE, (q31_t)0xE0B54698, (q31_t)0x7C1DBBB2, + (q31_t)0xE0848B7F, (q31_t)0x7C116853, (q31_t)0xE053D541, (q31_t)0x7C0501D1, + (q31_t)0xE02323E5, (q31_t)0x7BF88830, (q31_t)0xDFF27773, (q31_t)0x7BEBFB70, + (q31_t)0xDFC1CFF2, (q31_t)0x7BDF5B94, (q31_t)0xDF912D6A, (q31_t)0x7BD2A89E, + (q31_t)0xDF608FE3, (q31_t)0x7BC5E28F, (q31_t)0xDF2FF764, (q31_t)0x7BB9096A, + (q31_t)0xDEFF63F4, (q31_t)0x7BAC1D31, (q31_t)0xDECED59B, (q31_t)0x7B9F1DE5, + (q31_t)0xDE9E4C60, (q31_t)0x7B920B89, (q31_t)0xDE6DC84B, (q31_t)0x7B84E61E, + (q31_t)0xDE3D4963, (q31_t)0x7B77ADA8, (q31_t)0xDE0CCFB1, (q31_t)0x7B6A6227, + (q31_t)0xDDDC5B3A, (q31_t)0x7B5D039D, (q31_t)0xDDABEC07, (q31_t)0x7B4F920E, + (q31_t)0xDD7B8220, (q31_t)0x7B420D7A, (q31_t)0xDD4B1D8B, (q31_t)0x7B3475E4, + (q31_t)0xDD1ABE51, (q31_t)0x7B26CB4F, (q31_t)0xDCEA6478, (q31_t)0x7B190DBB, + (q31_t)0xDCBA1008, (q31_t)0x7B0B3D2C, (q31_t)0xDC89C108, (q31_t)0x7AFD59A3, + (q31_t)0xDC597781, (q31_t)0x7AEF6323, (q31_t)0xDC293379, (q31_t)0x7AE159AE, + (q31_t)0xDBF8F4F8, (q31_t)0x7AD33D45, (q31_t)0xDBC8BC05, (q31_t)0x7AC50DEB, + (q31_t)0xDB9888A8, (q31_t)0x7AB6CBA3, (q31_t)0xDB685AE8, (q31_t)0x7AA8766E, + (q31_t)0xDB3832CD, (q31_t)0x7A9A0E4F, (q31_t)0xDB08105E, (q31_t)0x7A8B9348, + (q31_t)0xDAD7F3A2, (q31_t)0x7A7D055B, (q31_t)0xDAA7DCA1, (q31_t)0x7A6E648A, + (q31_t)0xDA77CB62, (q31_t)0x7A5FB0D8, (q31_t)0xDA47BFED, (q31_t)0x7A50EA46, + (q31_t)0xDA17BA4A, (q31_t)0x7A4210D8, (q31_t)0xD9E7BA7E, (q31_t)0x7A33248F, + (q31_t)0xD9B7C093, (q31_t)0x7A24256E, (q31_t)0xD987CC8F, (q31_t)0x7A151377, + (q31_t)0xD957DE7A, (q31_t)0x7A05EEAD, (q31_t)0xD927F65B, (q31_t)0x79F6B711, + (q31_t)0xD8F81439, (q31_t)0x79E76CA6, (q31_t)0xD8C8381C, (q31_t)0x79D80F6F, + (q31_t)0xD898620C, (q31_t)0x79C89F6D, (q31_t)0xD868920F, (q31_t)0x79B91CA4, + (q31_t)0xD838C82D, (q31_t)0x79A98715, (q31_t)0xD809046D, (q31_t)0x7999DEC3, + (q31_t)0xD7D946D7, (q31_t)0x798A23B1, (q31_t)0xD7A98F73, (q31_t)0x797A55E0, + (q31_t)0xD779DE46, (q31_t)0x796A7554, (q31_t)0xD74A335A, (q31_t)0x795A820E, + (q31_t)0xD71A8EB5, (q31_t)0x794A7C11, (q31_t)0xD6EAF05E, (q31_t)0x793A6360, + (q31_t)0xD6BB585D, (q31_t)0x792A37FE, (q31_t)0xD68BC6BA, (q31_t)0x7919F9EB, + (q31_t)0xD65C3B7B, (q31_t)0x7909A92C, (q31_t)0xD62CB6A7, (q31_t)0x78F945C3, + (q31_t)0xD5FD3847, (q31_t)0x78E8CFB1, (q31_t)0xD5CDC062, (q31_t)0x78D846FB, + (q31_t)0xD59E4EFE, (q31_t)0x78C7ABA1, (q31_t)0xD56EE424, (q31_t)0x78B6FDA8, + (q31_t)0xD53F7FDA, (q31_t)0x78A63D10, (q31_t)0xD5102227, (q31_t)0x789569DE, + (q31_t)0xD4E0CB14, (q31_t)0x78848413, (q31_t)0xD4B17AA7, (q31_t)0x78738BB3, + (q31_t)0xD48230E8, (q31_t)0x786280BF, (q31_t)0xD452EDDE, (q31_t)0x7851633B, + (q31_t)0xD423B190, (q31_t)0x78403328, (q31_t)0xD3F47C06, (q31_t)0x782EF08B, + (q31_t)0xD3C54D46, (q31_t)0x781D9B64, (q31_t)0xD3962559, (q31_t)0x780C33B8, + (q31_t)0xD3670445, (q31_t)0x77FAB988, (q31_t)0xD337EA12, (q31_t)0x77E92CD8, + (q31_t)0xD308D6C6, (q31_t)0x77D78DAA, (q31_t)0xD2D9CA6A, (q31_t)0x77C5DC01, + (q31_t)0xD2AAC504, (q31_t)0x77B417DF, (q31_t)0xD27BC69C, (q31_t)0x77A24148, + (q31_t)0xD24CCF38, (q31_t)0x7790583D, (q31_t)0xD21DDEE1, (q31_t)0x777E5CC3, + (q31_t)0xD1EEF59E, (q31_t)0x776C4EDB, (q31_t)0xD1C01374, (q31_t)0x775A2E88, + (q31_t)0xD191386D, (q31_t)0x7747FBCE, (q31_t)0xD162648F, (q31_t)0x7735B6AE, + (q31_t)0xD13397E1, (q31_t)0x77235F2D, (q31_t)0xD104D26B, (q31_t)0x7710F54B, + (q31_t)0xD0D61433, (q31_t)0x76FE790E, (q31_t)0xD0A75D42, (q31_t)0x76EBEA77, + (q31_t)0xD078AD9D, (q31_t)0x76D94988, (q31_t)0xD04A054D, (q31_t)0x76C69646, + (q31_t)0xD01B6459, (q31_t)0x76B3D0B3, (q31_t)0xCFECCAC7, (q31_t)0x76A0F8D2, + (q31_t)0xCFBE389F, (q31_t)0x768E0EA5, (q31_t)0xCF8FADE8, (q31_t)0x767B1230, + (q31_t)0xCF612AAA, (q31_t)0x76680376, (q31_t)0xCF32AEEB, (q31_t)0x7654E279, + (q31_t)0xCF043AB2, (q31_t)0x7641AF3C, (q31_t)0xCED5CE08, (q31_t)0x762E69C3, + (q31_t)0xCEA768F2, (q31_t)0x761B1211, (q31_t)0xCE790B78, (q31_t)0x7607A827, + (q31_t)0xCE4AB5A2, (q31_t)0x75F42C0A, (q31_t)0xCE1C6776, (q31_t)0x75E09DBD, + (q31_t)0xCDEE20FC, (q31_t)0x75CCFD42, (q31_t)0xCDBFE23A, (q31_t)0x75B94A9C, + (q31_t)0xCD91AB38, (q31_t)0x75A585CF, (q31_t)0xCD637BFD, (q31_t)0x7591AEDD, + (q31_t)0xCD355490, (q31_t)0x757DC5CA, (q31_t)0xCD0734F8, (q31_t)0x7569CA98, + (q31_t)0xCCD91D3D, (q31_t)0x7555BD4B, (q31_t)0xCCAB0D65, (q31_t)0x75419DE6, + (q31_t)0xCC7D0577, (q31_t)0x752D6C6C, (q31_t)0xCC4F057B, (q31_t)0x751928E0, + (q31_t)0xCC210D78, (q31_t)0x7504D345, (q31_t)0xCBF31D75, (q31_t)0x74F06B9E, + (q31_t)0xCBC53578, (q31_t)0x74DBF1EF, (q31_t)0xCB975589, (q31_t)0x74C7663A, + (q31_t)0xCB697DB0, (q31_t)0x74B2C883, (q31_t)0xCB3BADF2, (q31_t)0x749E18CD, + (q31_t)0xCB0DE658, (q31_t)0x7489571B, (q31_t)0xCAE026E8, (q31_t)0x74748371, + (q31_t)0xCAB26FA9, (q31_t)0x745F9DD1, (q31_t)0xCA84C0A2, (q31_t)0x744AA63E, + (q31_t)0xCA5719DB, (q31_t)0x74359CBD, (q31_t)0xCA297B5A, (q31_t)0x74208150, + (q31_t)0xC9FBE527, (q31_t)0x740B53FA, (q31_t)0xC9CE5748, (q31_t)0x73F614C0, + (q31_t)0xC9A0D1C4, (q31_t)0x73E0C3A3, (q31_t)0xC97354A3, (q31_t)0x73CB60A7, + (q31_t)0xC945DFEC, (q31_t)0x73B5EBD0, (q31_t)0xC91873A5, (q31_t)0x73A06522, + (q31_t)0xC8EB0FD6, (q31_t)0x738ACC9E, (q31_t)0xC8BDB485, (q31_t)0x73752249, + (q31_t)0xC89061BA, (q31_t)0x735F6626, (q31_t)0xC863177B, (q31_t)0x73499838, + (q31_t)0xC835D5D0, (q31_t)0x7333B883, (q31_t)0xC8089CBF, (q31_t)0x731DC709, + (q31_t)0xC7DB6C50, (q31_t)0x7307C3D0, (q31_t)0xC7AE4489, (q31_t)0x72F1AED8, + (q31_t)0xC7812571, (q31_t)0x72DB8828, (q31_t)0xC7540F10, (q31_t)0x72C54FC0, + (q31_t)0xC727016C, (q31_t)0x72AF05A6, (q31_t)0xC6F9FC8D, (q31_t)0x7298A9DC, + (q31_t)0xC6CD0079, (q31_t)0x72823C66, (q31_t)0xC6A00D36, (q31_t)0x726BBD48, + (q31_t)0xC67322CD, (q31_t)0x72552C84, (q31_t)0xC6464144, (q31_t)0x723E8A1F, + (q31_t)0xC61968A2, (q31_t)0x7227D61C, (q31_t)0xC5EC98ED, (q31_t)0x7211107D, + (q31_t)0xC5BFD22E, (q31_t)0x71FA3948, (q31_t)0xC593146A, (q31_t)0x71E3507F, + (q31_t)0xC5665FA8, (q31_t)0x71CC5626, (q31_t)0xC539B3F0, (q31_t)0x71B54A40, + (q31_t)0xC50D1148, (q31_t)0x719E2CD2, (q31_t)0xC4E077B8, (q31_t)0x7186FDDE, + (q31_t)0xC4B3E746, (q31_t)0x716FBD68, (q31_t)0xC4875FF8, (q31_t)0x71586B73, + (q31_t)0xC45AE1D7, (q31_t)0x71410804, (q31_t)0xC42E6CE8, (q31_t)0x7129931E, + (q31_t)0xC4020132, (q31_t)0x71120CC5, (q31_t)0xC3D59EBD, (q31_t)0x70FA74FB, + (q31_t)0xC3A9458F, (q31_t)0x70E2CBC6, (q31_t)0xC37CF5B0, (q31_t)0x70CB1127, + (q31_t)0xC350AF25, (q31_t)0x70B34524, (q31_t)0xC32471F6, (q31_t)0x709B67C0, + (q31_t)0xC2F83E2A, (q31_t)0x708378FE, (q31_t)0xC2CC13C7, (q31_t)0x706B78E3, + (q31_t)0xC29FF2D4, (q31_t)0x70536771, (q31_t)0xC273DB58, (q31_t)0x703B44AC, + (q31_t)0xC247CD5A, (q31_t)0x70231099, (q31_t)0xC21BC8E0, (q31_t)0x700ACB3B, + (q31_t)0xC1EFCDF2, (q31_t)0x6FF27496, (q31_t)0xC1C3DC96, (q31_t)0x6FDA0CAD, + (q31_t)0xC197F4D3, (q31_t)0x6FC19385, (q31_t)0xC16C16B0, (q31_t)0x6FA90920, + (q31_t)0xC1404233, (q31_t)0x6F906D84, (q31_t)0xC1147763, (q31_t)0x6F77C0B3, + (q31_t)0xC0E8B648, (q31_t)0x6F5F02B1, (q31_t)0xC0BCFEE7, (q31_t)0x6F463383, + (q31_t)0xC0915147, (q31_t)0x6F2D532C, (q31_t)0xC065AD70, (q31_t)0x6F1461AF, + (q31_t)0xC03A1368, (q31_t)0x6EFB5F12, (q31_t)0xC00E8335, (q31_t)0x6EE24B57, + (q31_t)0xBFE2FCDF, (q31_t)0x6EC92682, (q31_t)0xBFB7806C, (q31_t)0x6EAFF098, + (q31_t)0xBF8C0DE2, (q31_t)0x6E96A99C, (q31_t)0xBF60A54A, (q31_t)0x6E7D5193, + (q31_t)0xBF3546A8, (q31_t)0x6E63E87F, (q31_t)0xBF09F204, (q31_t)0x6E4A6E65, + (q31_t)0xBEDEA765, (q31_t)0x6E30E349, (q31_t)0xBEB366D1, (q31_t)0x6E17472F, + (q31_t)0xBE88304F, (q31_t)0x6DFD9A1B, (q31_t)0xBE5D03E5, (q31_t)0x6DE3DC11, + (q31_t)0xBE31E19B, (q31_t)0x6DCA0D14, (q31_t)0xBE06C977, (q31_t)0x6DB02D29, + (q31_t)0xBDDBBB7F, (q31_t)0x6D963C54, (q31_t)0xBDB0B7BA, (q31_t)0x6D7C3A98, + (q31_t)0xBD85BE2F, (q31_t)0x6D6227FA, (q31_t)0xBD5ACEE5, (q31_t)0x6D48047E, + (q31_t)0xBD2FE9E1, (q31_t)0x6D2DD027, (q31_t)0xBD050F2C, (q31_t)0x6D138AFA, + (q31_t)0xBCDA3ECA, (q31_t)0x6CF934FB, (q31_t)0xBCAF78C3, (q31_t)0x6CDECE2E, + (q31_t)0xBC84BD1E, (q31_t)0x6CC45697, (q31_t)0xBC5A0BE1, (q31_t)0x6CA9CE3A, + (q31_t)0xBC2F6513, (q31_t)0x6C8F351C, (q31_t)0xBC04C8BA, (q31_t)0x6C748B3F, + (q31_t)0xBBDA36DC, (q31_t)0x6C59D0A9, (q31_t)0xBBAFAF81, (q31_t)0x6C3F055D, + (q31_t)0xBB8532AF, (q31_t)0x6C242960, (q31_t)0xBB5AC06C, (q31_t)0x6C093CB6, + (q31_t)0xBB3058C0, (q31_t)0x6BEE3F62, (q31_t)0xBB05FBB0, (q31_t)0x6BD3316A, + (q31_t)0xBADBA943, (q31_t)0x6BB812D0, (q31_t)0xBAB1617F, (q31_t)0x6B9CE39B, + (q31_t)0xBA87246C, (q31_t)0x6B81A3CD, (q31_t)0xBA5CF210, (q31_t)0x6B66536A, + (q31_t)0xBA32CA70, (q31_t)0x6B4AF278, (q31_t)0xBA08AD94, (q31_t)0x6B2F80FA, + (q31_t)0xB9DE9B83, (q31_t)0x6B13FEF5, (q31_t)0xB9B49442, (q31_t)0x6AF86C6C, + (q31_t)0xB98A97D8, (q31_t)0x6ADCC964, (q31_t)0xB960A64B, (q31_t)0x6AC115E1, + (q31_t)0xB936BFA3, (q31_t)0x6AA551E8, (q31_t)0xB90CE3E6, (q31_t)0x6A897D7D, + (q31_t)0xB8E31319, (q31_t)0x6A6D98A4, (q31_t)0xB8B94D44, (q31_t)0x6A51A361, + (q31_t)0xB88F926C, (q31_t)0x6A359DB9, (q31_t)0xB865E299, (q31_t)0x6A1987B0, + (q31_t)0xB83C3DD1, (q31_t)0x69FD614A, (q31_t)0xB812A419, (q31_t)0x69E12A8C, + (q31_t)0xB7E9157A, (q31_t)0x69C4E37A, (q31_t)0xB7BF91F8, (q31_t)0x69A88C18, + (q31_t)0xB796199B, (q31_t)0x698C246C, (q31_t)0xB76CAC68, (q31_t)0x696FAC78, + (q31_t)0xB7434A67, (q31_t)0x69532442, (q31_t)0xB719F39D, (q31_t)0x69368BCE, + (q31_t)0xB6F0A811, (q31_t)0x6919E320, (q31_t)0xB6C767CA, (q31_t)0x68FD2A3D, + (q31_t)0xB69E32CD, (q31_t)0x68E06129, (q31_t)0xB6750921, (q31_t)0x68C387E9, + (q31_t)0xB64BEACC, (q31_t)0x68A69E81, (q31_t)0xB622D7D5, (q31_t)0x6889A4F5, + (q31_t)0xB5F9D042, (q31_t)0x686C9B4B, (q31_t)0xB5D0D41A, (q31_t)0x684F8186, + (q31_t)0xB5A7E362, (q31_t)0x683257AA, (q31_t)0xB57EFE21, (q31_t)0x68151DBE, + (q31_t)0xB556245E, (q31_t)0x67F7D3C4, (q31_t)0xB52D561E, (q31_t)0x67DA79C2, + (q31_t)0xB5049368, (q31_t)0x67BD0FBC, (q31_t)0xB4DBDC42, (q31_t)0x679F95B7, + (q31_t)0xB4B330B2, (q31_t)0x67820BB6, (q31_t)0xB48A90C0, (q31_t)0x676471C0, + (q31_t)0xB461FC70, (q31_t)0x6746C7D7, (q31_t)0xB43973C9, (q31_t)0x67290E02, + (q31_t)0xB410F6D2, (q31_t)0x670B4443, (q31_t)0xB3E88591, (q31_t)0x66ED6AA1, + (q31_t)0xB3C0200C, (q31_t)0x66CF811F, (q31_t)0xB397C649, (q31_t)0x66B187C3, + (q31_t)0xB36F784E, (q31_t)0x66937E90, (q31_t)0xB3473622, (q31_t)0x6675658C, + (q31_t)0xB31EFFCB, (q31_t)0x66573CBB, (q31_t)0xB2F6D54F, (q31_t)0x66390422, + (q31_t)0xB2CEB6B5, (q31_t)0x661ABBC5, (q31_t)0xB2A6A401, (q31_t)0x65FC63A9, + (q31_t)0xB27E9D3B, (q31_t)0x65DDFBD3, (q31_t)0xB256A26A, (q31_t)0x65BF8447, + (q31_t)0xB22EB392, (q31_t)0x65A0FD0B, (q31_t)0xB206D0BA, (q31_t)0x65826622, + (q31_t)0xB1DEF9E8, (q31_t)0x6563BF92, (q31_t)0xB1B72F23, (q31_t)0x6545095F, + (q31_t)0xB18F7070, (q31_t)0x6526438E, (q31_t)0xB167BDD6, (q31_t)0x65076E24, + (q31_t)0xB140175B, (q31_t)0x64E88926, (q31_t)0xB1187D05, (q31_t)0x64C99498, + (q31_t)0xB0F0EEDA, (q31_t)0x64AA907F, (q31_t)0xB0C96CDF, (q31_t)0x648B7CDF, + (q31_t)0xB0A1F71C, (q31_t)0x646C59BF, (q31_t)0xB07A8D97, (q31_t)0x644D2722, + (q31_t)0xB0533055, (q31_t)0x642DE50D, (q31_t)0xB02BDF5C, (q31_t)0x640E9385, + (q31_t)0xB0049AB2, (q31_t)0x63EF328F, (q31_t)0xAFDD625F, (q31_t)0x63CFC230, + (q31_t)0xAFB63667, (q31_t)0x63B0426D, (q31_t)0xAF8F16D0, (q31_t)0x6390B34A, + (q31_t)0xAF6803A1, (q31_t)0x637114CC, (q31_t)0xAF40FCE0, (q31_t)0x635166F8, + (q31_t)0xAF1A0293, (q31_t)0x6331A9D4, (q31_t)0xAEF314BF, (q31_t)0x6311DD63, + (q31_t)0xAECC336B, (q31_t)0x62F201AC, (q31_t)0xAEA55E9D, (q31_t)0x62D216B2, + (q31_t)0xAE7E965B, (q31_t)0x62B21C7B, (q31_t)0xAE57DAAA, (q31_t)0x6292130C, + (q31_t)0xAE312B91, (q31_t)0x6271FA69, (q31_t)0xAE0A8916, (q31_t)0x6251D297, + (q31_t)0xADE3F33E, (q31_t)0x62319B9D, (q31_t)0xADBD6A10, (q31_t)0x6211557D, + (q31_t)0xAD96ED91, (q31_t)0x61F1003E, (q31_t)0xAD707DC8, (q31_t)0x61D09BE5, + (q31_t)0xAD4A1ABA, (q31_t)0x61B02876, (q31_t)0xAD23C46D, (q31_t)0x618FA5F6, + (q31_t)0xACFD7AE8, (q31_t)0x616F146B, (q31_t)0xACD73E30, (q31_t)0x614E73D9, + (q31_t)0xACB10E4A, (q31_t)0x612DC446, (q31_t)0xAC8AEB3E, (q31_t)0x610D05B7, + (q31_t)0xAC64D510, (q31_t)0x60EC3830, (q31_t)0xAC3ECBC7, (q31_t)0x60CB5BB6, + (q31_t)0xAC18CF68, (q31_t)0x60AA704F, (q31_t)0xABF2DFFA, (q31_t)0x60897600, + (q31_t)0xABCCFD82, (q31_t)0x60686CCE, (q31_t)0xABA72806, (q31_t)0x604754BE, + (q31_t)0xAB815F8C, (q31_t)0x60262DD5, (q31_t)0xAB5BA41A, (q31_t)0x6004F818, + (q31_t)0xAB35F5B5, (q31_t)0x5FE3B38D, (q31_t)0xAB105464, (q31_t)0x5FC26038, + (q31_t)0xAAEAC02B, (q31_t)0x5FA0FE1E, (q31_t)0xAAC53912, (q31_t)0x5F7F8D46, + (q31_t)0xAA9FBF1D, (q31_t)0x5F5E0DB3, (q31_t)0xAA7A5253, (q31_t)0x5F3C7F6B, + (q31_t)0xAA54F2B9, (q31_t)0x5F1AE273, (q31_t)0xAA2FA055, (q31_t)0x5EF936D1, + (q31_t)0xAA0A5B2D, (q31_t)0x5ED77C89, (q31_t)0xA9E52347, (q31_t)0x5EB5B3A1, + (q31_t)0xA9BFF8A8, (q31_t)0x5E93DC1F, (q31_t)0xA99ADB56, (q31_t)0x5E71F606, + (q31_t)0xA975CB56, (q31_t)0x5E50015D, (q31_t)0xA950C8AF, (q31_t)0x5E2DFE28, + (q31_t)0xA92BD366, (q31_t)0x5E0BEC6E, (q31_t)0xA906EB81, (q31_t)0x5DE9CC32, + (q31_t)0xA8E21106, (q31_t)0x5DC79D7C, (q31_t)0xA8BD43FA, (q31_t)0x5DA5604E, + (q31_t)0xA8988463, (q31_t)0x5D8314B0, (q31_t)0xA873D246, (q31_t)0x5D60BAA6, + (q31_t)0xA84F2DA9, (q31_t)0x5D3E5236, (q31_t)0xA82A9693, (q31_t)0x5D1BDB65, + (q31_t)0xA8060D08, (q31_t)0x5CF95638, (q31_t)0xA7E1910E, (q31_t)0x5CD6C2B4, + (q31_t)0xA7BD22AB, (q31_t)0x5CB420DF, (q31_t)0xA798C1E4, (q31_t)0x5C9170BF, + (q31_t)0xA7746EC0, (q31_t)0x5C6EB258, (q31_t)0xA7502943, (q31_t)0x5C4BE5B0, + (q31_t)0xA72BF173, (q31_t)0x5C290ACC, (q31_t)0xA707C756, (q31_t)0x5C0621B2, + (q31_t)0xA6E3AAF2, (q31_t)0x5BE32A67, (q31_t)0xA6BF9C4B, (q31_t)0x5BC024F0, + (q31_t)0xA69B9B68, (q31_t)0x5B9D1153, (q31_t)0xA677A84E, (q31_t)0x5B79EF96, + (q31_t)0xA653C302, (q31_t)0x5B56BFBD, (q31_t)0xA62FEB8B, (q31_t)0x5B3381CE, + (q31_t)0xA60C21ED, (q31_t)0x5B1035CF, (q31_t)0xA5E8662F, (q31_t)0x5AECDBC4, + (q31_t)0xA5C4B855, (q31_t)0x5AC973B4, (q31_t)0xA5A11865, (q31_t)0x5AA5FDA4, + (q31_t)0xA57D8666, (q31_t)0x5A82799A, (q31_t)0xA55A025B, (q31_t)0x5A5EE79A, + (q31_t)0xA5368C4B, (q31_t)0x5A3B47AA, (q31_t)0xA513243B, (q31_t)0x5A1799D0, + (q31_t)0xA4EFCA31, (q31_t)0x59F3DE12, (q31_t)0xA4CC7E31, (q31_t)0x59D01474, + (q31_t)0xA4A94042, (q31_t)0x59AC3CFD, (q31_t)0xA4861069, (q31_t)0x598857B1, + (q31_t)0xA462EEAC, (q31_t)0x59646497, (q31_t)0xA43FDB0F, (q31_t)0x594063B4, + (q31_t)0xA41CD598, (q31_t)0x591C550E, (q31_t)0xA3F9DE4D, (q31_t)0x58F838A9, + (q31_t)0xA3D6F533, (q31_t)0x58D40E8C, (q31_t)0xA3B41A4F, (q31_t)0x58AFD6BC, + (q31_t)0xA3914DA7, (q31_t)0x588B913F, (q31_t)0xA36E8F40, (q31_t)0x58673E1B, + (q31_t)0xA34BDF20, (q31_t)0x5842DD54, (q31_t)0xA3293D4B, (q31_t)0x581E6EF1, + (q31_t)0xA306A9C7, (q31_t)0x57F9F2F7, (q31_t)0xA2E4249A, (q31_t)0x57D5696C, + (q31_t)0xA2C1ADC9, (q31_t)0x57B0D256, (q31_t)0xA29F4559, (q31_t)0x578C2DB9, + (q31_t)0xA27CEB4F, (q31_t)0x57677B9D, (q31_t)0xA25A9FB1, (q31_t)0x5742BC05, + (q31_t)0xA2386283, (q31_t)0x571DEEF9, (q31_t)0xA21633CD, (q31_t)0x56F9147E, + (q31_t)0xA1F41391, (q31_t)0x56D42C99, (q31_t)0xA1D201D7, (q31_t)0x56AF3750, + (q31_t)0xA1AFFEA2, (q31_t)0x568A34A9, (q31_t)0xA18E09F9, (q31_t)0x566524AA, + (q31_t)0xA16C23E1, (q31_t)0x56400757, (q31_t)0xA14A4C5E, (q31_t)0x561ADCB8, + (q31_t)0xA1288376, (q31_t)0x55F5A4D2, (q31_t)0xA106C92E, (q31_t)0x55D05FAA, + (q31_t)0xA0E51D8C, (q31_t)0x55AB0D46, (q31_t)0xA0C38094, (q31_t)0x5585ADAC, + (q31_t)0xA0A1F24C, (q31_t)0x556040E2, (q31_t)0xA08072BA, (q31_t)0x553AC6ED, + (q31_t)0xA05F01E1, (q31_t)0x55153FD4, (q31_t)0xA03D9FC7, (q31_t)0x54EFAB9C, + (q31_t)0xA01C4C72, (q31_t)0x54CA0A4A, (q31_t)0x9FFB07E7, (q31_t)0x54A45BE5, + (q31_t)0x9FD9D22A, (q31_t)0x547EA073, (q31_t)0x9FB8AB41, (q31_t)0x5458D7F9, + (q31_t)0x9F979331, (q31_t)0x5433027D, (q31_t)0x9F7689FF, (q31_t)0x540D2005, + (q31_t)0x9F558FB0, (q31_t)0x53E73097, (q31_t)0x9F34A449, (q31_t)0x53C13438, + (q31_t)0x9F13C7D0, (q31_t)0x539B2AEF, (q31_t)0x9EF2FA48, (q31_t)0x537514C1, + (q31_t)0x9ED23BB9, (q31_t)0x534EF1B5, (q31_t)0x9EB18C26, (q31_t)0x5328C1D0, + (q31_t)0x9E90EB94, (q31_t)0x53028517, (q31_t)0x9E705A09, (q31_t)0x52DC3B92, + (q31_t)0x9E4FD789, (q31_t)0x52B5E545, (q31_t)0x9E2F641A, (q31_t)0x528F8237, + (q31_t)0x9E0EFFC1, (q31_t)0x5269126E, (q31_t)0x9DEEAA82, (q31_t)0x524295EF, + (q31_t)0x9DCE6462, (q31_t)0x521C0CC1, (q31_t)0x9DAE2D68, (q31_t)0x51F576E9, + (q31_t)0x9D8E0596, (q31_t)0x51CED46E, (q31_t)0x9D6DECF4, (q31_t)0x51A82555, + (q31_t)0x9D4DE384, (q31_t)0x518169A4, (q31_t)0x9D2DE94D, (q31_t)0x515AA162, + (q31_t)0x9D0DFE53, (q31_t)0x5133CC94, (q31_t)0x9CEE229C, (q31_t)0x510CEB40, + (q31_t)0x9CCE562B, (q31_t)0x50E5FD6C, (q31_t)0x9CAE9907, (q31_t)0x50BF031F, + (q31_t)0x9C8EEB33, (q31_t)0x5097FC5E, (q31_t)0x9C6F4CB5, (q31_t)0x5070E92F, + (q31_t)0x9C4FBD92, (q31_t)0x5049C999, (q31_t)0x9C303DCF, (q31_t)0x50229DA0, + (q31_t)0x9C10CD70, (q31_t)0x4FFB654D, (q31_t)0x9BF16C7A, (q31_t)0x4FD420A3, + (q31_t)0x9BD21AF2, (q31_t)0x4FACCFAB, (q31_t)0x9BB2D8DD, (q31_t)0x4F857268, + (q31_t)0x9B93A640, (q31_t)0x4F5E08E3, (q31_t)0x9B748320, (q31_t)0x4F369320, + (q31_t)0x9B556F80, (q31_t)0x4F0F1126, (q31_t)0x9B366B67, (q31_t)0x4EE782FA, + (q31_t)0x9B1776D9, (q31_t)0x4EBFE8A4, (q31_t)0x9AF891DB, (q31_t)0x4E984229, + (q31_t)0x9AD9BC71, (q31_t)0x4E708F8F, (q31_t)0x9ABAF6A0, (q31_t)0x4E48D0DC, + (q31_t)0x9A9C406D, (q31_t)0x4E210617, (q31_t)0x9A7D99DD, (q31_t)0x4DF92F45, + (q31_t)0x9A5F02F5, (q31_t)0x4DD14C6E, (q31_t)0x9A407BB8, (q31_t)0x4DA95D96, + (q31_t)0x9A22042C, (q31_t)0x4D8162C4, (q31_t)0x9A039C56, (q31_t)0x4D595BFE, + (q31_t)0x99E5443A, (q31_t)0x4D31494B, (q31_t)0x99C6FBDE, (q31_t)0x4D092AB0, + (q31_t)0x99A8C344, (q31_t)0x4CE10034, (q31_t)0x998A9A73, (q31_t)0x4CB8C9DD, + (q31_t)0x996C816F, (q31_t)0x4C9087B1, (q31_t)0x994E783C, (q31_t)0x4C6839B6, + (q31_t)0x99307EE0, (q31_t)0x4C3FDFF3, (q31_t)0x9912955E, (q31_t)0x4C177A6E, + (q31_t)0x98F4BBBC, (q31_t)0x4BEF092D, (q31_t)0x98D6F1FE, (q31_t)0x4BC68C36, + (q31_t)0x98B93828, (q31_t)0x4B9E038F, (q31_t)0x989B8E3F, (q31_t)0x4B756F3F, + (q31_t)0x987DF449, (q31_t)0x4B4CCF4D, (q31_t)0x98606A48, (q31_t)0x4B2423BD, + (q31_t)0x9842F043, (q31_t)0x4AFB6C97, (q31_t)0x9825863D, (q31_t)0x4AD2A9E1, + (q31_t)0x98082C3B, (q31_t)0x4AA9DBA1, (q31_t)0x97EAE241, (q31_t)0x4A8101DE, + (q31_t)0x97CDA855, (q31_t)0x4A581C9D, (q31_t)0x97B07E7A, (q31_t)0x4A2F2BE5, + (q31_t)0x979364B5, (q31_t)0x4A062FBD, (q31_t)0x97765B0A, (q31_t)0x49DD282A, + (q31_t)0x9759617E, (q31_t)0x49B41533, (q31_t)0x973C7816, (q31_t)0x498AF6DE, + (q31_t)0x971F9ED6, (q31_t)0x4961CD32, (q31_t)0x9702D5C2, (q31_t)0x49389836, + (q31_t)0x96E61CDF, (q31_t)0x490F57EE, (q31_t)0x96C97431, (q31_t)0x48E60C62, + (q31_t)0x96ACDBBD, (q31_t)0x48BCB598, (q31_t)0x96905387, (q31_t)0x48935397, + (q31_t)0x9673DB94, (q31_t)0x4869E664, (q31_t)0x965773E7, (q31_t)0x48406E07, + (q31_t)0x963B1C85, (q31_t)0x4816EA85, (q31_t)0x961ED573, (q31_t)0x47ED5BE6, + (q31_t)0x96029EB5, (q31_t)0x47C3C22E, (q31_t)0x95E6784F, (q31_t)0x479A1D66, + (q31_t)0x95CA6246, (q31_t)0x47706D93, (q31_t)0x95AE5C9E, (q31_t)0x4746B2BC, + (q31_t)0x9592675B, (q31_t)0x471CECE6, (q31_t)0x95768282, (q31_t)0x46F31C1A, + (q31_t)0x955AAE17, (q31_t)0x46C9405C, (q31_t)0x953EEA1E, (q31_t)0x469F59B4, + (q31_t)0x9523369B, (q31_t)0x46756827, (q31_t)0x95079393, (q31_t)0x464B6BBD, + (q31_t)0x94EC010B, (q31_t)0x4621647C, (q31_t)0x94D07F05, (q31_t)0x45F7526B, + (q31_t)0x94B50D87, (q31_t)0x45CD358F, (q31_t)0x9499AC95, (q31_t)0x45A30DF0, + (q31_t)0x947E5C32, (q31_t)0x4578DB93, (q31_t)0x94631C64, (q31_t)0x454E9E80, + (q31_t)0x9447ED2F, (q31_t)0x452456BC, (q31_t)0x942CCE95, (q31_t)0x44FA044F, + (q31_t)0x9411C09D, (q31_t)0x44CFA73F, (q31_t)0x93F6C34A, (q31_t)0x44A53F93, + (q31_t)0x93DBD69F, (q31_t)0x447ACD50, (q31_t)0x93C0FAA2, (q31_t)0x4450507E, + (q31_t)0x93A62F56, (q31_t)0x4425C923, (q31_t)0x938B74C0, (q31_t)0x43FB3745, + (q31_t)0x9370CAE4, (q31_t)0x43D09AEC, (q31_t)0x935631C5, (q31_t)0x43A5F41E, + (q31_t)0x933BA968, (q31_t)0x437B42E1, (q31_t)0x932131D1, (q31_t)0x4350873C, + (q31_t)0x9306CB04, (q31_t)0x4325C135, (q31_t)0x92EC7505, (q31_t)0x42FAF0D4, + (q31_t)0x92D22FD8, (q31_t)0x42D0161E, (q31_t)0x92B7FB82, (q31_t)0x42A5311A, + (q31_t)0x929DD805, (q31_t)0x427A41D0, (q31_t)0x9283C567, (q31_t)0x424F4845, + (q31_t)0x9269C3AC, (q31_t)0x42244480, (q31_t)0x924FD2D6, (q31_t)0x41F93688, + (q31_t)0x9235F2EB, (q31_t)0x41CE1E64, (q31_t)0x921C23EE, (q31_t)0x41A2FC1A, + (q31_t)0x920265E4, (q31_t)0x4177CFB0, (q31_t)0x91E8B8D0, (q31_t)0x414C992E, + (q31_t)0x91CF1CB6, (q31_t)0x4121589A, (q31_t)0x91B5919A, (q31_t)0x40F60DFB, + (q31_t)0x919C1780, (q31_t)0x40CAB957, (q31_t)0x9182AE6C, (q31_t)0x409F5AB6, + (q31_t)0x91695663, (q31_t)0x4073F21D, (q31_t)0x91500F67, (q31_t)0x40487F93, + (q31_t)0x9136D97D, (q31_t)0x401D0320, (q31_t)0x911DB4A8, (q31_t)0x3FF17CCA, + (q31_t)0x9104A0ED, (q31_t)0x3FC5EC97, (q31_t)0x90EB9E50, (q31_t)0x3F9A528F, + (q31_t)0x90D2ACD3, (q31_t)0x3F6EAEB8, (q31_t)0x90B9CC7C, (q31_t)0x3F430118, + (q31_t)0x90A0FD4E, (q31_t)0x3F1749B7, (q31_t)0x90883F4C, (q31_t)0x3EEB889C, + (q31_t)0x906F927B, (q31_t)0x3EBFBDCC, (q31_t)0x9056F6DF, (q31_t)0x3E93E94F, + (q31_t)0x903E6C7A, (q31_t)0x3E680B2C, (q31_t)0x9025F352, (q31_t)0x3E3C2369, + (q31_t)0x900D8B69, (q31_t)0x3E10320D, (q31_t)0x8FF534C4, (q31_t)0x3DE4371F, + (q31_t)0x8FDCEF66, (q31_t)0x3DB832A5, (q31_t)0x8FC4BB53, (q31_t)0x3D8C24A7, + (q31_t)0x8FAC988E, (q31_t)0x3D600D2B, (q31_t)0x8F94871D, (q31_t)0x3D33EC39, + (q31_t)0x8F7C8701, (q31_t)0x3D07C1D5, (q31_t)0x8F64983F, (q31_t)0x3CDB8E09, + (q31_t)0x8F4CBADB, (q31_t)0x3CAF50DA, (q31_t)0x8F34EED8, (q31_t)0x3C830A4F, + (q31_t)0x8F1D343A, (q31_t)0x3C56BA70, (q31_t)0x8F058B04, (q31_t)0x3C2A6142, + (q31_t)0x8EEDF33B, (q31_t)0x3BFDFECD, (q31_t)0x8ED66CE1, (q31_t)0x3BD19317, + (q31_t)0x8EBEF7FB, (q31_t)0x3BA51E29, (q31_t)0x8EA7948C, (q31_t)0x3B78A007, + (q31_t)0x8E904298, (q31_t)0x3B4C18BA, (q31_t)0x8E790222, (q31_t)0x3B1F8847, + (q31_t)0x8E61D32D, (q31_t)0x3AF2EEB7, (q31_t)0x8E4AB5BF, (q31_t)0x3AC64C0F, + (q31_t)0x8E33A9D9, (q31_t)0x3A99A057, (q31_t)0x8E1CAF80, (q31_t)0x3A6CEB95, + (q31_t)0x8E05C6B7, (q31_t)0x3A402DD1, (q31_t)0x8DEEEF82, (q31_t)0x3A136712, + (q31_t)0x8DD829E4, (q31_t)0x39E6975D, (q31_t)0x8DC175E0, (q31_t)0x39B9BEBB, + (q31_t)0x8DAAD37B, (q31_t)0x398CDD32, (q31_t)0x8D9442B7, (q31_t)0x395FF2C9, + (q31_t)0x8D7DC399, (q31_t)0x3932FF87, (q31_t)0x8D675623, (q31_t)0x39060372, + (q31_t)0x8D50FA59, (q31_t)0x38D8FE93, (q31_t)0x8D3AB03F, (q31_t)0x38ABF0EF, + (q31_t)0x8D2477D8, (q31_t)0x387EDA8E, (q31_t)0x8D0E5127, (q31_t)0x3851BB76, + (q31_t)0x8CF83C30, (q31_t)0x382493B0, (q31_t)0x8CE238F6, (q31_t)0x37F76340, + (q31_t)0x8CCC477D, (q31_t)0x37CA2A30, (q31_t)0x8CB667C7, (q31_t)0x379CE884, + (q31_t)0x8CA099D9, (q31_t)0x376F9E46, (q31_t)0x8C8ADDB6, (q31_t)0x37424B7A, + (q31_t)0x8C753361, (q31_t)0x3714F02A, (q31_t)0x8C5F9ADD, (q31_t)0x36E78C5A, + (q31_t)0x8C4A142F, (q31_t)0x36BA2013, (q31_t)0x8C349F58, (q31_t)0x368CAB5C, + (q31_t)0x8C1F3C5C, (q31_t)0x365F2E3B, (q31_t)0x8C09EB40, (q31_t)0x3631A8B7, + (q31_t)0x8BF4AC05, (q31_t)0x36041AD9, (q31_t)0x8BDF7EAF, (q31_t)0x35D684A5, + (q31_t)0x8BCA6342, (q31_t)0x35A8E624, (q31_t)0x8BB559C1, (q31_t)0x357B3F5D, + (q31_t)0x8BA0622F, (q31_t)0x354D9056, (q31_t)0x8B8B7C8F, (q31_t)0x351FD917, + (q31_t)0x8B76A8E4, (q31_t)0x34F219A7, (q31_t)0x8B61E732, (q31_t)0x34C4520D, + (q31_t)0x8B4D377C, (q31_t)0x3496824F, (q31_t)0x8B3899C5, (q31_t)0x3468AA76, + (q31_t)0x8B240E10, (q31_t)0x343ACA87, (q31_t)0x8B0F9461, (q31_t)0x340CE28A, + (q31_t)0x8AFB2CBA, (q31_t)0x33DEF287, (q31_t)0x8AE6D71F, (q31_t)0x33B0FA84, + (q31_t)0x8AD29393, (q31_t)0x3382FA88, (q31_t)0x8ABE6219, (q31_t)0x3354F29A, + (q31_t)0x8AAA42B4, (q31_t)0x3326E2C2, (q31_t)0x8A963567, (q31_t)0x32F8CB07, + (q31_t)0x8A823A35, (q31_t)0x32CAAB6F, (q31_t)0x8A6E5122, (q31_t)0x329C8402, + (q31_t)0x8A5A7A30, (q31_t)0x326E54C7, (q31_t)0x8A46B563, (q31_t)0x32401DC5, + (q31_t)0x8A3302BD, (q31_t)0x3211DF03, (q31_t)0x8A1F6242, (q31_t)0x31E39889, + (q31_t)0x8A0BD3F5, (q31_t)0x31B54A5D, (q31_t)0x89F857D8, (q31_t)0x3186F487, + (q31_t)0x89E4EDEE, (q31_t)0x3158970D, (q31_t)0x89D1963C, (q31_t)0x312A31F8, + (q31_t)0x89BE50C3, (q31_t)0x30FBC54D, (q31_t)0x89AB1D86, (q31_t)0x30CD5114, + (q31_t)0x8997FC89, (q31_t)0x309ED555, (q31_t)0x8984EDCF, (q31_t)0x30705217, + (q31_t)0x8971F15A, (q31_t)0x3041C760, (q31_t)0x895F072D, (q31_t)0x30133538, + (q31_t)0x894C2F4C, (q31_t)0x2FE49BA6, (q31_t)0x893969B9, (q31_t)0x2FB5FAB2, + (q31_t)0x8926B677, (q31_t)0x2F875262, (q31_t)0x89141589, (q31_t)0x2F58A2BD, + (q31_t)0x890186F1, (q31_t)0x2F29EBCC, (q31_t)0x88EF0AB4, (q31_t)0x2EFB2D94, + (q31_t)0x88DCA0D3, (q31_t)0x2ECC681E, (q31_t)0x88CA4951, (q31_t)0x2E9D9B70, + (q31_t)0x88B80431, (q31_t)0x2E6EC792, (q31_t)0x88A5D177, (q31_t)0x2E3FEC8B, + (q31_t)0x8893B124, (q31_t)0x2E110A62, (q31_t)0x8881A33C, (q31_t)0x2DE2211E, + (q31_t)0x886FA7C2, (q31_t)0x2DB330C7, (q31_t)0x885DBEB7, (q31_t)0x2D843963, + (q31_t)0x884BE820, (q31_t)0x2D553AFB, (q31_t)0x883A23FE, (q31_t)0x2D263595, + (q31_t)0x88287255, (q31_t)0x2CF72939, (q31_t)0x8816D327, (q31_t)0x2CC815ED, + (q31_t)0x88054677, (q31_t)0x2C98FBBA, (q31_t)0x87F3CC47, (q31_t)0x2C69DAA6, + (q31_t)0x87E2649B, (q31_t)0x2C3AB2B9, (q31_t)0x87D10F75, (q31_t)0x2C0B83F9, + (q31_t)0x87BFCCD7, (q31_t)0x2BDC4E6F, (q31_t)0x87AE9CC5, (q31_t)0x2BAD1221, + (q31_t)0x879D7F40, (q31_t)0x2B7DCF17, (q31_t)0x878C744C, (q31_t)0x2B4E8558, + (q31_t)0x877B7BEC, (q31_t)0x2B1F34EB, (q31_t)0x876A9621, (q31_t)0x2AEFDDD8, + (q31_t)0x8759C2EF, (q31_t)0x2AC08025, (q31_t)0x87490257, (q31_t)0x2A911BDB, + (q31_t)0x8738545E, (q31_t)0x2A61B101, (q31_t)0x8727B904, (q31_t)0x2A323F9D, + (q31_t)0x8717304E, (q31_t)0x2A02C7B8, (q31_t)0x8706BA3C, (q31_t)0x29D34958, + (q31_t)0x86F656D3, (q31_t)0x29A3C484, (q31_t)0x86E60614, (q31_t)0x29743945, + (q31_t)0x86D5C802, (q31_t)0x2944A7A2, (q31_t)0x86C59C9F, (q31_t)0x29150FA1, + (q31_t)0x86B583EE, (q31_t)0x28E5714A, (q31_t)0x86A57DF1, (q31_t)0x28B5CCA5, + (q31_t)0x86958AAB, (q31_t)0x288621B9, (q31_t)0x8685AA1F, (q31_t)0x2856708C, + (q31_t)0x8675DC4E, (q31_t)0x2826B928, (q31_t)0x8666213C, (q31_t)0x27F6FB92, + (q31_t)0x865678EA, (q31_t)0x27C737D2, (q31_t)0x8646E35B, (q31_t)0x27976DF1, + (q31_t)0x86376092, (q31_t)0x27679DF4, (q31_t)0x8627F090, (q31_t)0x2737C7E3, + (q31_t)0x86189359, (q31_t)0x2707EBC6, (q31_t)0x860948EE, (q31_t)0x26D809A5, + (q31_t)0x85FA1152, (q31_t)0x26A82185, (q31_t)0x85EAEC88, (q31_t)0x26783370, + (q31_t)0x85DBDA91, (q31_t)0x26483F6C, (q31_t)0x85CCDB70, (q31_t)0x26184581, + (q31_t)0x85BDEF27, (q31_t)0x25E845B5, (q31_t)0x85AF15B9, (q31_t)0x25B84012, + (q31_t)0x85A04F28, (q31_t)0x2588349D, (q31_t)0x85919B75, (q31_t)0x2558235E, + (q31_t)0x8582FAA4, (q31_t)0x25280C5D, (q31_t)0x85746CB7, (q31_t)0x24F7EFA1, + (q31_t)0x8565F1B0, (q31_t)0x24C7CD32, (q31_t)0x85578991, (q31_t)0x2497A517, + (q31_t)0x8549345C, (q31_t)0x24677757, (q31_t)0x853AF214, (q31_t)0x243743FA, + (q31_t)0x852CC2BA, (q31_t)0x24070B07, (q31_t)0x851EA652, (q31_t)0x23D6CC86, + (q31_t)0x85109CDC, (q31_t)0x23A6887E, (q31_t)0x8502A65C, (q31_t)0x23763EF7, + (q31_t)0x84F4C2D3, (q31_t)0x2345EFF7, (q31_t)0x84E6F244, (q31_t)0x23159B87, + (q31_t)0x84D934B0, (q31_t)0x22E541AE, (q31_t)0x84CB8A1B, (q31_t)0x22B4E274, + (q31_t)0x84BDF285, (q31_t)0x22847DDF, (q31_t)0x84B06DF1, (q31_t)0x225413F8, + (q31_t)0x84A2FC62, (q31_t)0x2223A4C5, (q31_t)0x84959DD9, (q31_t)0x21F3304E, + (q31_t)0x84885257, (q31_t)0x21C2B69C, (q31_t)0x847B19E1, (q31_t)0x219237B4, + (q31_t)0x846DF476, (q31_t)0x2161B39F, (q31_t)0x8460E21A, (q31_t)0x21312A65, + (q31_t)0x8453E2CE, (q31_t)0x21009C0B, (q31_t)0x8446F695, (q31_t)0x20D0089B, + (q31_t)0x843A1D70, (q31_t)0x209F701C, (q31_t)0x842D5761, (q31_t)0x206ED295, + (q31_t)0x8420A46B, (q31_t)0x203E300D, (q31_t)0x8414048F, (q31_t)0x200D888C, + (q31_t)0x840777CF, (q31_t)0x1FDCDC1A, (q31_t)0x83FAFE2E, (q31_t)0x1FAC2ABF, + (q31_t)0x83EE97AC, (q31_t)0x1F7B7480, (q31_t)0x83E2444D, (q31_t)0x1F4AB967, + (q31_t)0x83D60411, (q31_t)0x1F19F97B, (q31_t)0x83C9D6FB, (q31_t)0x1EE934C2, + (q31_t)0x83BDBD0D, (q31_t)0x1EB86B46, (q31_t)0x83B1B649, (q31_t)0x1E879D0C, + (q31_t)0x83A5C2B0, (q31_t)0x1E56CA1E, (q31_t)0x8399E244, (q31_t)0x1E25F281, + (q31_t)0x838E1507, (q31_t)0x1DF5163F, (q31_t)0x83825AFB, (q31_t)0x1DC4355D, + (q31_t)0x8376B422, (q31_t)0x1D934FE5, (q31_t)0x836B207D, (q31_t)0x1D6265DD, + (q31_t)0x835FA00E, (q31_t)0x1D31774D, (q31_t)0x835432D8, (q31_t)0x1D00843C, + (q31_t)0x8348D8DB, (q31_t)0x1CCF8CB3, (q31_t)0x833D921A, (q31_t)0x1C9E90B8, + (q31_t)0x83325E97, (q31_t)0x1C6D9053, (q31_t)0x83273E52, (q31_t)0x1C3C8B8C, + (q31_t)0x831C314E, (q31_t)0x1C0B826A, (q31_t)0x8311378C, (q31_t)0x1BDA74F5, + (q31_t)0x8306510F, (q31_t)0x1BA96334, (q31_t)0x82FB7DD8, (q31_t)0x1B784D30, + (q31_t)0x82F0BDE8, (q31_t)0x1B4732EF, (q31_t)0x82E61141, (q31_t)0x1B161479, + (q31_t)0x82DB77E5, (q31_t)0x1AE4F1D6, (q31_t)0x82D0F1D5, (q31_t)0x1AB3CB0C, + (q31_t)0x82C67F13, (q31_t)0x1A82A025, (q31_t)0x82BC1FA1, (q31_t)0x1A517127, + (q31_t)0x82B1D381, (q31_t)0x1A203E1B, (q31_t)0x82A79AB3, (q31_t)0x19EF0706, + (q31_t)0x829D753A, (q31_t)0x19BDCBF2, (q31_t)0x82936316, (q31_t)0x198C8CE6, + (q31_t)0x8289644A, (q31_t)0x195B49E9, (q31_t)0x827F78D8, (q31_t)0x192A0303, + (q31_t)0x8275A0C0, (q31_t)0x18F8B83C, (q31_t)0x826BDC04, (q31_t)0x18C7699B, + (q31_t)0x82622AA5, (q31_t)0x18961727, (q31_t)0x82588CA6, (q31_t)0x1864C0E9, + (q31_t)0x824F0208, (q31_t)0x183366E8, (q31_t)0x82458ACB, (q31_t)0x1802092C, + (q31_t)0x823C26F2, (q31_t)0x17D0A7BB, (q31_t)0x8232D67E, (q31_t)0x179F429F, + (q31_t)0x82299971, (q31_t)0x176DD9DE, (q31_t)0x82206FCB, (q31_t)0x173C6D80, + (q31_t)0x8217598F, (q31_t)0x170AFD8D, (q31_t)0x820E56BE, (q31_t)0x16D98A0C, + (q31_t)0x82056758, (q31_t)0x16A81305, (q31_t)0x81FC8B60, (q31_t)0x1676987F, + (q31_t)0x81F3C2D7, (q31_t)0x16451A83, (q31_t)0x81EB0DBD, (q31_t)0x16139917, + (q31_t)0x81E26C16, (q31_t)0x15E21444, (q31_t)0x81D9DDE1, (q31_t)0x15B08C11, + (q31_t)0x81D16320, (q31_t)0x157F0086, (q31_t)0x81C8FBD5, (q31_t)0x154D71AA, + (q31_t)0x81C0A801, (q31_t)0x151BDF85, (q31_t)0x81B867A4, (q31_t)0x14EA4A1F, + (q31_t)0x81B03AC1, (q31_t)0x14B8B17F, (q31_t)0x81A82159, (q31_t)0x148715AD, + (q31_t)0x81A01B6C, (q31_t)0x145576B1, (q31_t)0x819828FD, (q31_t)0x1423D492, + (q31_t)0x81904A0C, (q31_t)0x13F22F57, (q31_t)0x81887E9A, (q31_t)0x13C0870A, + (q31_t)0x8180C6A9, (q31_t)0x138EDBB0, (q31_t)0x8179223A, (q31_t)0x135D2D53, + (q31_t)0x8171914E, (q31_t)0x132B7BF9, (q31_t)0x816A13E6, (q31_t)0x12F9C7AA, + (q31_t)0x8162AA03, (q31_t)0x12C8106E, (q31_t)0x815B53A8, (q31_t)0x1296564D, + (q31_t)0x815410D3, (q31_t)0x1264994E, (q31_t)0x814CE188, (q31_t)0x1232D978, + (q31_t)0x8145C5C6, (q31_t)0x120116D4, (q31_t)0x813EBD90, (q31_t)0x11CF516A, + (q31_t)0x8137C8E6, (q31_t)0x119D8940, (q31_t)0x8130E7C8, (q31_t)0x116BBE5F, + (q31_t)0x812A1A39, (q31_t)0x1139F0CE, (q31_t)0x81236039, (q31_t)0x11082096, + (q31_t)0x811CB9CA, (q31_t)0x10D64DBC, (q31_t)0x811626EC, (q31_t)0x10A4784A, + (q31_t)0x810FA7A0, (q31_t)0x1072A047, (q31_t)0x81093BE8, (q31_t)0x1040C5BB, + (q31_t)0x8102E3C3, (q31_t)0x100EE8AD, (q31_t)0x80FC9F35, (q31_t)0x0FDD0925, + (q31_t)0x80F66E3C, (q31_t)0x0FAB272B, (q31_t)0x80F050DB, (q31_t)0x0F7942C6, + (q31_t)0x80EA4712, (q31_t)0x0F475BFE, (q31_t)0x80E450E2, (q31_t)0x0F1572DC, + (q31_t)0x80DE6E4C, (q31_t)0x0EE38765, (q31_t)0x80D89F51, (q31_t)0x0EB199A3, + (q31_t)0x80D2E3F1, (q31_t)0x0E7FA99D, (q31_t)0x80CD3C2F, (q31_t)0x0E4DB75B, + (q31_t)0x80C7A80A, (q31_t)0x0E1BC2E3, (q31_t)0x80C22783, (q31_t)0x0DE9CC3F, + (q31_t)0x80BCBA9C, (q31_t)0x0DB7D376, (q31_t)0x80B76155, (q31_t)0x0D85D88F, + (q31_t)0x80B21BAF, (q31_t)0x0D53DB92, (q31_t)0x80ACE9AB, (q31_t)0x0D21DC87, + (q31_t)0x80A7CB49, (q31_t)0x0CEFDB75, (q31_t)0x80A2C08B, (q31_t)0x0CBDD865, + (q31_t)0x809DC970, (q31_t)0x0C8BD35E, (q31_t)0x8098E5FB, (q31_t)0x0C59CC67, + (q31_t)0x8094162B, (q31_t)0x0C27C389, (q31_t)0x808F5A02, (q31_t)0x0BF5B8CB, + (q31_t)0x808AB180, (q31_t)0x0BC3AC35, (q31_t)0x80861CA5, (q31_t)0x0B919DCE, + (q31_t)0x80819B74, (q31_t)0x0B5F8D9F, (q31_t)0x807D2DEB, (q31_t)0x0B2D7BAE, + (q31_t)0x8078D40D, (q31_t)0x0AFB6805, (q31_t)0x80748DD9, (q31_t)0x0AC952AA, + (q31_t)0x80705B50, (q31_t)0x0A973BA5, (q31_t)0x806C3C73, (q31_t)0x0A6522FE, + (q31_t)0x80683143, (q31_t)0x0A3308BC, (q31_t)0x806439C0, (q31_t)0x0A00ECE8, + (q31_t)0x806055EA, (q31_t)0x09CECF89, (q31_t)0x805C85C3, (q31_t)0x099CB0A7, + (q31_t)0x8058C94C, (q31_t)0x096A9049, (q31_t)0x80552083, (q31_t)0x09386E77, + (q31_t)0x80518B6B, (q31_t)0x09064B3A, (q31_t)0x804E0A03, (q31_t)0x08D42698, + (q31_t)0x804A9C4D, (q31_t)0x08A2009A, (q31_t)0x80474248, (q31_t)0x086FD947, + (q31_t)0x8043FBF6, (q31_t)0x083DB0A7, (q31_t)0x8040C956, (q31_t)0x080B86C1, + (q31_t)0x803DAA69, (q31_t)0x07D95B9E, (q31_t)0x803A9F31, (q31_t)0x07A72F45, + (q31_t)0x8037A7AC, (q31_t)0x077501BE, (q31_t)0x8034C3DC, (q31_t)0x0742D310, + (q31_t)0x8031F3C1, (q31_t)0x0710A344, (q31_t)0x802F375C, (q31_t)0x06DE7261, + (q31_t)0x802C8EAD, (q31_t)0x06AC406F, (q31_t)0x8029F9B4, (q31_t)0x067A0D75, + (q31_t)0x80277872, (q31_t)0x0647D97C, (q31_t)0x80250AE7, (q31_t)0x0615A48A, + (q31_t)0x8022B113, (q31_t)0x05E36EA9, (q31_t)0x80206AF8, (q31_t)0x05B137DF, + (q31_t)0x801E3894, (q31_t)0x057F0034, (q31_t)0x801C19E9, (q31_t)0x054CC7B0, + (q31_t)0x801A0EF7, (q31_t)0x051A8E5C, (q31_t)0x801817BF, (q31_t)0x04E8543D, + (q31_t)0x80163440, (q31_t)0x04B6195D, (q31_t)0x8014647A, (q31_t)0x0483DDC3, + (q31_t)0x8012A86F, (q31_t)0x0451A176, (q31_t)0x8011001E, (q31_t)0x041F647F, + (q31_t)0x800F6B88, (q31_t)0x03ED26E6, (q31_t)0x800DEAAC, (q31_t)0x03BAE8B1, + (q31_t)0x800C7D8C, (q31_t)0x0388A9E9, (q31_t)0x800B2427, (q31_t)0x03566A96, + (q31_t)0x8009DE7D, (q31_t)0x03242ABF, (q31_t)0x8008AC90, (q31_t)0x02F1EA6B, + (q31_t)0x80078E5E, (q31_t)0x02BFA9A4, (q31_t)0x800683E8, (q31_t)0x028D6870, + (q31_t)0x80058D2E, (q31_t)0x025B26D7, (q31_t)0x8004AA31, (q31_t)0x0228E4E1, + (q31_t)0x8003DAF0, (q31_t)0x01F6A296, (q31_t)0x80031F6C, (q31_t)0x01C45FFE, + (q31_t)0x800277A5, (q31_t)0x01921D1F, (q31_t)0x8001E39B, (q31_t)0x015FDA03, + (q31_t)0x8001634D, (q31_t)0x012D96B0, (q31_t)0x8000F6BD, (q31_t)0x00FB532F, + (q31_t)0x80009DE9, (q31_t)0x00C90F88, (q31_t)0x800058D3, (q31_t)0x0096CBC1, + (q31_t)0x8000277A, (q31_t)0x006487E3, (q31_t)0x800009DE, (q31_t)0x003243F5, + (q31_t)0x80000000, (q31_t)0x00000000, (q31_t)0x800009DE, (q31_t)0xFFCDBC0A, + (q31_t)0x8000277A, (q31_t)0xFF9B781D, (q31_t)0x800058D3, (q31_t)0xFF69343E, + (q31_t)0x80009DE9, (q31_t)0xFF36F078, (q31_t)0x8000F6BD, (q31_t)0xFF04ACD0, + (q31_t)0x8001634D, (q31_t)0xFED2694F, (q31_t)0x8001E39B, (q31_t)0xFEA025FC, + (q31_t)0x800277A5, (q31_t)0xFE6DE2E0, (q31_t)0x80031F6C, (q31_t)0xFE3BA001, + (q31_t)0x8003DAF0, (q31_t)0xFE095D69, (q31_t)0x8004AA31, (q31_t)0xFDD71B1E, + (q31_t)0x80058D2E, (q31_t)0xFDA4D928, (q31_t)0x800683E8, (q31_t)0xFD72978F, + (q31_t)0x80078E5E, (q31_t)0xFD40565B, (q31_t)0x8008AC90, (q31_t)0xFD0E1594, + (q31_t)0x8009DE7D, (q31_t)0xFCDBD541, (q31_t)0x800B2427, (q31_t)0xFCA99569, + (q31_t)0x800C7D8C, (q31_t)0xFC775616, (q31_t)0x800DEAAC, (q31_t)0xFC45174E, + (q31_t)0x800F6B88, (q31_t)0xFC12D919, (q31_t)0x8011001E, (q31_t)0xFBE09B80, + (q31_t)0x8012A86F, (q31_t)0xFBAE5E89, (q31_t)0x8014647A, (q31_t)0xFB7C223C, + (q31_t)0x80163440, (q31_t)0xFB49E6A2, (q31_t)0x801817BF, (q31_t)0xFB17ABC2, + (q31_t)0x801A0EF7, (q31_t)0xFAE571A4, (q31_t)0x801C19E9, (q31_t)0xFAB3384F, + (q31_t)0x801E3894, (q31_t)0xFA80FFCB, (q31_t)0x80206AF8, (q31_t)0xFA4EC820, + (q31_t)0x8022B113, (q31_t)0xFA1C9156, (q31_t)0x80250AE7, (q31_t)0xF9EA5B75, + (q31_t)0x80277872, (q31_t)0xF9B82683, (q31_t)0x8029F9B4, (q31_t)0xF985F28A, + (q31_t)0x802C8EAD, (q31_t)0xF953BF90, (q31_t)0x802F375C, (q31_t)0xF9218D9E, + (q31_t)0x8031F3C1, (q31_t)0xF8EF5CBB, (q31_t)0x8034C3DC, (q31_t)0xF8BD2CEF, + (q31_t)0x8037A7AC, (q31_t)0xF88AFE41, (q31_t)0x803A9F31, (q31_t)0xF858D0BA, + (q31_t)0x803DAA69, (q31_t)0xF826A461, (q31_t)0x8040C956, (q31_t)0xF7F4793E, + (q31_t)0x8043FBF6, (q31_t)0xF7C24F58, (q31_t)0x80474248, (q31_t)0xF79026B8, + (q31_t)0x804A9C4D, (q31_t)0xF75DFF65, (q31_t)0x804E0A03, (q31_t)0xF72BD967, + (q31_t)0x80518B6B, (q31_t)0xF6F9B4C5, (q31_t)0x80552083, (q31_t)0xF6C79188, + (q31_t)0x8058C94C, (q31_t)0xF6956FB6, (q31_t)0x805C85C3, (q31_t)0xF6634F58, + (q31_t)0x806055EA, (q31_t)0xF6313076, (q31_t)0x806439C0, (q31_t)0xF5FF1317, + (q31_t)0x80683143, (q31_t)0xF5CCF743, (q31_t)0x806C3C73, (q31_t)0xF59ADD01, + (q31_t)0x80705B50, (q31_t)0xF568C45A, (q31_t)0x80748DD9, (q31_t)0xF536AD55, + (q31_t)0x8078D40D, (q31_t)0xF50497FA, (q31_t)0x807D2DEB, (q31_t)0xF4D28451, + (q31_t)0x80819B74, (q31_t)0xF4A07260, (q31_t)0x80861CA5, (q31_t)0xF46E6231, + (q31_t)0x808AB180, (q31_t)0xF43C53CA, (q31_t)0x808F5A02, (q31_t)0xF40A4734, + (q31_t)0x8094162B, (q31_t)0xF3D83C76, (q31_t)0x8098E5FB, (q31_t)0xF3A63398, + (q31_t)0x809DC970, (q31_t)0xF3742CA1, (q31_t)0x80A2C08B, (q31_t)0xF342279A, + (q31_t)0x80A7CB49, (q31_t)0xF310248A, (q31_t)0x80ACE9AB, (q31_t)0xF2DE2378, + (q31_t)0x80B21BAF, (q31_t)0xF2AC246D, (q31_t)0x80B76155, (q31_t)0xF27A2770, + (q31_t)0x80BCBA9C, (q31_t)0xF2482C89, (q31_t)0x80C22783, (q31_t)0xF21633C0, + (q31_t)0x80C7A80A, (q31_t)0xF1E43D1C, (q31_t)0x80CD3C2F, (q31_t)0xF1B248A5, + (q31_t)0x80D2E3F1, (q31_t)0xF1805662, (q31_t)0x80D89F51, (q31_t)0xF14E665C, + (q31_t)0x80DE6E4C, (q31_t)0xF11C789A, (q31_t)0x80E450E2, (q31_t)0xF0EA8D23, + (q31_t)0x80EA4712, (q31_t)0xF0B8A401, (q31_t)0x80F050DB, (q31_t)0xF086BD39, + (q31_t)0x80F66E3C, (q31_t)0xF054D8D4, (q31_t)0x80FC9F35, (q31_t)0xF022F6DA, + (q31_t)0x8102E3C3, (q31_t)0xEFF11752, (q31_t)0x81093BE8, (q31_t)0xEFBF3A44, + (q31_t)0x810FA7A0, (q31_t)0xEF8D5FB8, (q31_t)0x811626EC, (q31_t)0xEF5B87B5, + (q31_t)0x811CB9CA, (q31_t)0xEF29B243, (q31_t)0x81236039, (q31_t)0xEEF7DF6A, + (q31_t)0x812A1A39, (q31_t)0xEEC60F31, (q31_t)0x8130E7C8, (q31_t)0xEE9441A0, + (q31_t)0x8137C8E6, (q31_t)0xEE6276BF, (q31_t)0x813EBD90, (q31_t)0xEE30AE95, + (q31_t)0x8145C5C6, (q31_t)0xEDFEE92B, (q31_t)0x814CE188, (q31_t)0xEDCD2687, + (q31_t)0x815410D3, (q31_t)0xED9B66B2, (q31_t)0x815B53A8, (q31_t)0xED69A9B2, + (q31_t)0x8162AA03, (q31_t)0xED37EF91, (q31_t)0x816A13E6, (q31_t)0xED063855, + (q31_t)0x8171914E, (q31_t)0xECD48406, (q31_t)0x8179223A, (q31_t)0xECA2D2AC, + (q31_t)0x8180C6A9, (q31_t)0xEC71244F, (q31_t)0x81887E9A, (q31_t)0xEC3F78F5, + (q31_t)0x81904A0C, (q31_t)0xEC0DD0A8, (q31_t)0x819828FD, (q31_t)0xEBDC2B6D, + (q31_t)0x81A01B6C, (q31_t)0xEBAA894E, (q31_t)0x81A82159, (q31_t)0xEB78EA52, + (q31_t)0x81B03AC1, (q31_t)0xEB474E80, (q31_t)0x81B867A4, (q31_t)0xEB15B5E0, + (q31_t)0x81C0A801, (q31_t)0xEAE4207A, (q31_t)0x81C8FBD5, (q31_t)0xEAB28E55, + (q31_t)0x81D16320, (q31_t)0xEA80FF79, (q31_t)0x81D9DDE1, (q31_t)0xEA4F73EE, + (q31_t)0x81E26C16, (q31_t)0xEA1DEBBB, (q31_t)0x81EB0DBD, (q31_t)0xE9EC66E8, + (q31_t)0x81F3C2D7, (q31_t)0xE9BAE57C, (q31_t)0x81FC8B60, (q31_t)0xE9896780, + (q31_t)0x82056758, (q31_t)0xE957ECFB, (q31_t)0x820E56BE, (q31_t)0xE92675F4, + (q31_t)0x8217598F, (q31_t)0xE8F50273, (q31_t)0x82206FCB, (q31_t)0xE8C3927F, + (q31_t)0x82299971, (q31_t)0xE8922621, (q31_t)0x8232D67E, (q31_t)0xE860BD60, + (q31_t)0x823C26F2, (q31_t)0xE82F5844, (q31_t)0x82458ACB, (q31_t)0xE7FDF6D3, + (q31_t)0x824F0208, (q31_t)0xE7CC9917, (q31_t)0x82588CA6, (q31_t)0xE79B3F16, + (q31_t)0x82622AA5, (q31_t)0xE769E8D8, (q31_t)0x826BDC04, (q31_t)0xE7389664, + (q31_t)0x8275A0C0, (q31_t)0xE70747C3, (q31_t)0x827F78D8, (q31_t)0xE6D5FCFC, + (q31_t)0x8289644A, (q31_t)0xE6A4B616, (q31_t)0x82936316, (q31_t)0xE6737319, + (q31_t)0x829D753A, (q31_t)0xE642340D, (q31_t)0x82A79AB3, (q31_t)0xE610F8F9, + (q31_t)0x82B1D381, (q31_t)0xE5DFC1E4, (q31_t)0x82BC1FA1, (q31_t)0xE5AE8ED8, + (q31_t)0x82C67F13, (q31_t)0xE57D5FDA, (q31_t)0x82D0F1D5, (q31_t)0xE54C34F3, + (q31_t)0x82DB77E5, (q31_t)0xE51B0E2A, (q31_t)0x82E61141, (q31_t)0xE4E9EB86, + (q31_t)0x82F0BDE8, (q31_t)0xE4B8CD10, (q31_t)0x82FB7DD8, (q31_t)0xE487B2CF, + (q31_t)0x8306510F, (q31_t)0xE4569CCB, (q31_t)0x8311378C, (q31_t)0xE4258B0A, + (q31_t)0x831C314E, (q31_t)0xE3F47D95, (q31_t)0x83273E52, (q31_t)0xE3C37473, + (q31_t)0x83325E97, (q31_t)0xE3926FAC, (q31_t)0x833D921A, (q31_t)0xE3616F47, + (q31_t)0x8348D8DB, (q31_t)0xE330734C, (q31_t)0x835432D8, (q31_t)0xE2FF7BC3, + (q31_t)0x835FA00E, (q31_t)0xE2CE88B2, (q31_t)0x836B207D, (q31_t)0xE29D9A22, + (q31_t)0x8376B422, (q31_t)0xE26CB01A, (q31_t)0x83825AFB, (q31_t)0xE23BCAA2, + (q31_t)0x838E1507, (q31_t)0xE20AE9C1, (q31_t)0x8399E244, (q31_t)0xE1DA0D7E, + (q31_t)0x83A5C2B0, (q31_t)0xE1A935E1, (q31_t)0x83B1B649, (q31_t)0xE17862F3, + (q31_t)0x83BDBD0D, (q31_t)0xE14794B9, (q31_t)0x83C9D6FB, (q31_t)0xE116CB3D, + (q31_t)0x83D60411, (q31_t)0xE0E60684, (q31_t)0x83E2444D, (q31_t)0xE0B54698, + (q31_t)0x83EE97AC, (q31_t)0xE0848B7F, (q31_t)0x83FAFE2E, (q31_t)0xE053D541, + (q31_t)0x840777CF, (q31_t)0xE02323E5, (q31_t)0x8414048F, (q31_t)0xDFF27773, + (q31_t)0x8420A46B, (q31_t)0xDFC1CFF2, (q31_t)0x842D5761, (q31_t)0xDF912D6A, + (q31_t)0x843A1D70, (q31_t)0xDF608FE3, (q31_t)0x8446F695, (q31_t)0xDF2FF764, + (q31_t)0x8453E2CE, (q31_t)0xDEFF63F4, (q31_t)0x8460E21A, (q31_t)0xDECED59B, + (q31_t)0x846DF476, (q31_t)0xDE9E4C60, (q31_t)0x847B19E1, (q31_t)0xDE6DC84B, + (q31_t)0x84885257, (q31_t)0xDE3D4963, (q31_t)0x84959DD9, (q31_t)0xDE0CCFB1, + (q31_t)0x84A2FC62, (q31_t)0xDDDC5B3A, (q31_t)0x84B06DF1, (q31_t)0xDDABEC07, + (q31_t)0x84BDF285, (q31_t)0xDD7B8220, (q31_t)0x84CB8A1B, (q31_t)0xDD4B1D8B, + (q31_t)0x84D934B0, (q31_t)0xDD1ABE51, (q31_t)0x84E6F244, (q31_t)0xDCEA6478, + (q31_t)0x84F4C2D3, (q31_t)0xDCBA1008, (q31_t)0x8502A65C, (q31_t)0xDC89C108, + (q31_t)0x85109CDC, (q31_t)0xDC597781, (q31_t)0x851EA652, (q31_t)0xDC293379, + (q31_t)0x852CC2BA, (q31_t)0xDBF8F4F8, (q31_t)0x853AF214, (q31_t)0xDBC8BC05, + (q31_t)0x8549345C, (q31_t)0xDB9888A8, (q31_t)0x85578991, (q31_t)0xDB685AE8, + (q31_t)0x8565F1B0, (q31_t)0xDB3832CD, (q31_t)0x85746CB7, (q31_t)0xDB08105E, + (q31_t)0x8582FAA4, (q31_t)0xDAD7F3A2, (q31_t)0x85919B75, (q31_t)0xDAA7DCA1, + (q31_t)0x85A04F28, (q31_t)0xDA77CB62, (q31_t)0x85AF15B9, (q31_t)0xDA47BFED, + (q31_t)0x85BDEF27, (q31_t)0xDA17BA4A, (q31_t)0x85CCDB70, (q31_t)0xD9E7BA7E, + (q31_t)0x85DBDA91, (q31_t)0xD9B7C093, (q31_t)0x85EAEC88, (q31_t)0xD987CC8F, + (q31_t)0x85FA1152, (q31_t)0xD957DE7A, (q31_t)0x860948EE, (q31_t)0xD927F65B, + (q31_t)0x86189359, (q31_t)0xD8F81439, (q31_t)0x8627F090, (q31_t)0xD8C8381C, + (q31_t)0x86376092, (q31_t)0xD898620C, (q31_t)0x8646E35B, (q31_t)0xD868920F, + (q31_t)0x865678EA, (q31_t)0xD838C82D, (q31_t)0x8666213C, (q31_t)0xD809046D, + (q31_t)0x8675DC4E, (q31_t)0xD7D946D7, (q31_t)0x8685AA1F, (q31_t)0xD7A98F73, + (q31_t)0x86958AAB, (q31_t)0xD779DE46, (q31_t)0x86A57DF1, (q31_t)0xD74A335A, + (q31_t)0x86B583EE, (q31_t)0xD71A8EB5, (q31_t)0x86C59C9F, (q31_t)0xD6EAF05E, + (q31_t)0x86D5C802, (q31_t)0xD6BB585D, (q31_t)0x86E60614, (q31_t)0xD68BC6BA, + (q31_t)0x86F656D3, (q31_t)0xD65C3B7B, (q31_t)0x8706BA3C, (q31_t)0xD62CB6A7, + (q31_t)0x8717304E, (q31_t)0xD5FD3847, (q31_t)0x8727B904, (q31_t)0xD5CDC062, + (q31_t)0x8738545E, (q31_t)0xD59E4EFE, (q31_t)0x87490257, (q31_t)0xD56EE424, + (q31_t)0x8759C2EF, (q31_t)0xD53F7FDA, (q31_t)0x876A9621, (q31_t)0xD5102227, + (q31_t)0x877B7BEC, (q31_t)0xD4E0CB14, (q31_t)0x878C744C, (q31_t)0xD4B17AA7, + (q31_t)0x879D7F40, (q31_t)0xD48230E8, (q31_t)0x87AE9CC5, (q31_t)0xD452EDDE, + (q31_t)0x87BFCCD7, (q31_t)0xD423B190, (q31_t)0x87D10F75, (q31_t)0xD3F47C06, + (q31_t)0x87E2649B, (q31_t)0xD3C54D46, (q31_t)0x87F3CC47, (q31_t)0xD3962559, + (q31_t)0x88054677, (q31_t)0xD3670445, (q31_t)0x8816D327, (q31_t)0xD337EA12, + (q31_t)0x88287255, (q31_t)0xD308D6C6, (q31_t)0x883A23FE, (q31_t)0xD2D9CA6A, + (q31_t)0x884BE820, (q31_t)0xD2AAC504, (q31_t)0x885DBEB7, (q31_t)0xD27BC69C, + (q31_t)0x886FA7C2, (q31_t)0xD24CCF38, (q31_t)0x8881A33C, (q31_t)0xD21DDEE1, + (q31_t)0x8893B124, (q31_t)0xD1EEF59E, (q31_t)0x88A5D177, (q31_t)0xD1C01374, + (q31_t)0x88B80431, (q31_t)0xD191386D, (q31_t)0x88CA4951, (q31_t)0xD162648F, + (q31_t)0x88DCA0D3, (q31_t)0xD13397E1, (q31_t)0x88EF0AB4, (q31_t)0xD104D26B, + (q31_t)0x890186F1, (q31_t)0xD0D61433, (q31_t)0x89141589, (q31_t)0xD0A75D42, + (q31_t)0x8926B677, (q31_t)0xD078AD9D, (q31_t)0x893969B9, (q31_t)0xD04A054D, + (q31_t)0x894C2F4C, (q31_t)0xD01B6459, (q31_t)0x895F072D, (q31_t)0xCFECCAC7, + (q31_t)0x8971F15A, (q31_t)0xCFBE389F, (q31_t)0x8984EDCF, (q31_t)0xCF8FADE8, + (q31_t)0x8997FC89, (q31_t)0xCF612AAA, (q31_t)0x89AB1D86, (q31_t)0xCF32AEEB, + (q31_t)0x89BE50C3, (q31_t)0xCF043AB2, (q31_t)0x89D1963C, (q31_t)0xCED5CE08, + (q31_t)0x89E4EDEE, (q31_t)0xCEA768F2, (q31_t)0x89F857D8, (q31_t)0xCE790B78, + (q31_t)0x8A0BD3F5, (q31_t)0xCE4AB5A2, (q31_t)0x8A1F6242, (q31_t)0xCE1C6776, + (q31_t)0x8A3302BD, (q31_t)0xCDEE20FC, (q31_t)0x8A46B563, (q31_t)0xCDBFE23A, + (q31_t)0x8A5A7A30, (q31_t)0xCD91AB38, (q31_t)0x8A6E5122, (q31_t)0xCD637BFD, + (q31_t)0x8A823A35, (q31_t)0xCD355490, (q31_t)0x8A963567, (q31_t)0xCD0734F8, + (q31_t)0x8AAA42B4, (q31_t)0xCCD91D3D, (q31_t)0x8ABE6219, (q31_t)0xCCAB0D65, + (q31_t)0x8AD29393, (q31_t)0xCC7D0577, (q31_t)0x8AE6D71F, (q31_t)0xCC4F057B, + (q31_t)0x8AFB2CBA, (q31_t)0xCC210D78, (q31_t)0x8B0F9461, (q31_t)0xCBF31D75, + (q31_t)0x8B240E10, (q31_t)0xCBC53578, (q31_t)0x8B3899C5, (q31_t)0xCB975589, + (q31_t)0x8B4D377C, (q31_t)0xCB697DB0, (q31_t)0x8B61E732, (q31_t)0xCB3BADF2, + (q31_t)0x8B76A8E4, (q31_t)0xCB0DE658, (q31_t)0x8B8B7C8F, (q31_t)0xCAE026E8, + (q31_t)0x8BA0622F, (q31_t)0xCAB26FA9, (q31_t)0x8BB559C1, (q31_t)0xCA84C0A2, + (q31_t)0x8BCA6342, (q31_t)0xCA5719DB, (q31_t)0x8BDF7EAF, (q31_t)0xCA297B5A, + (q31_t)0x8BF4AC05, (q31_t)0xC9FBE527, (q31_t)0x8C09EB40, (q31_t)0xC9CE5748, + (q31_t)0x8C1F3C5C, (q31_t)0xC9A0D1C4, (q31_t)0x8C349F58, (q31_t)0xC97354A3, + (q31_t)0x8C4A142F, (q31_t)0xC945DFEC, (q31_t)0x8C5F9ADD, (q31_t)0xC91873A5, + (q31_t)0x8C753361, (q31_t)0xC8EB0FD6, (q31_t)0x8C8ADDB6, (q31_t)0xC8BDB485, + (q31_t)0x8CA099D9, (q31_t)0xC89061BA, (q31_t)0x8CB667C7, (q31_t)0xC863177B, + (q31_t)0x8CCC477D, (q31_t)0xC835D5D0, (q31_t)0x8CE238F6, (q31_t)0xC8089CBF, + (q31_t)0x8CF83C30, (q31_t)0xC7DB6C50, (q31_t)0x8D0E5127, (q31_t)0xC7AE4489, + (q31_t)0x8D2477D8, (q31_t)0xC7812571, (q31_t)0x8D3AB03F, (q31_t)0xC7540F10, + (q31_t)0x8D50FA59, (q31_t)0xC727016C, (q31_t)0x8D675623, (q31_t)0xC6F9FC8D, + (q31_t)0x8D7DC399, (q31_t)0xC6CD0079, (q31_t)0x8D9442B7, (q31_t)0xC6A00D36, + (q31_t)0x8DAAD37B, (q31_t)0xC67322CD, (q31_t)0x8DC175E0, (q31_t)0xC6464144, + (q31_t)0x8DD829E4, (q31_t)0xC61968A2, (q31_t)0x8DEEEF82, (q31_t)0xC5EC98ED, + (q31_t)0x8E05C6B7, (q31_t)0xC5BFD22E, (q31_t)0x8E1CAF80, (q31_t)0xC593146A, + (q31_t)0x8E33A9D9, (q31_t)0xC5665FA8, (q31_t)0x8E4AB5BF, (q31_t)0xC539B3F0, + (q31_t)0x8E61D32D, (q31_t)0xC50D1148, (q31_t)0x8E790222, (q31_t)0xC4E077B8, + (q31_t)0x8E904298, (q31_t)0xC4B3E746, (q31_t)0x8EA7948C, (q31_t)0xC4875FF8, + (q31_t)0x8EBEF7FB, (q31_t)0xC45AE1D7, (q31_t)0x8ED66CE1, (q31_t)0xC42E6CE8, + (q31_t)0x8EEDF33B, (q31_t)0xC4020132, (q31_t)0x8F058B04, (q31_t)0xC3D59EBD, + (q31_t)0x8F1D343A, (q31_t)0xC3A9458F, (q31_t)0x8F34EED8, (q31_t)0xC37CF5B0, + (q31_t)0x8F4CBADB, (q31_t)0xC350AF25, (q31_t)0x8F64983F, (q31_t)0xC32471F6, + (q31_t)0x8F7C8701, (q31_t)0xC2F83E2A, (q31_t)0x8F94871D, (q31_t)0xC2CC13C7, + (q31_t)0x8FAC988E, (q31_t)0xC29FF2D4, (q31_t)0x8FC4BB53, (q31_t)0xC273DB58, + (q31_t)0x8FDCEF66, (q31_t)0xC247CD5A, (q31_t)0x8FF534C4, (q31_t)0xC21BC8E0, + (q31_t)0x900D8B69, (q31_t)0xC1EFCDF2, (q31_t)0x9025F352, (q31_t)0xC1C3DC96, + (q31_t)0x903E6C7A, (q31_t)0xC197F4D3, (q31_t)0x9056F6DF, (q31_t)0xC16C16B0, + (q31_t)0x906F927B, (q31_t)0xC1404233, (q31_t)0x90883F4C, (q31_t)0xC1147763, + (q31_t)0x90A0FD4E, (q31_t)0xC0E8B648, (q31_t)0x90B9CC7C, (q31_t)0xC0BCFEE7, + (q31_t)0x90D2ACD3, (q31_t)0xC0915147, (q31_t)0x90EB9E50, (q31_t)0xC065AD70, + (q31_t)0x9104A0ED, (q31_t)0xC03A1368, (q31_t)0x911DB4A8, (q31_t)0xC00E8335, + (q31_t)0x9136D97D, (q31_t)0xBFE2FCDF, (q31_t)0x91500F67, (q31_t)0xBFB7806C, + (q31_t)0x91695663, (q31_t)0xBF8C0DE2, (q31_t)0x9182AE6C, (q31_t)0xBF60A54A, + (q31_t)0x919C1780, (q31_t)0xBF3546A8, (q31_t)0x91B5919A, (q31_t)0xBF09F204, + (q31_t)0x91CF1CB6, (q31_t)0xBEDEA765, (q31_t)0x91E8B8D0, (q31_t)0xBEB366D1, + (q31_t)0x920265E4, (q31_t)0xBE88304F, (q31_t)0x921C23EE, (q31_t)0xBE5D03E5, + (q31_t)0x9235F2EB, (q31_t)0xBE31E19B, (q31_t)0x924FD2D6, (q31_t)0xBE06C977, + (q31_t)0x9269C3AC, (q31_t)0xBDDBBB7F, (q31_t)0x9283C567, (q31_t)0xBDB0B7BA, + (q31_t)0x929DD805, (q31_t)0xBD85BE2F, (q31_t)0x92B7FB82, (q31_t)0xBD5ACEE5, + (q31_t)0x92D22FD8, (q31_t)0xBD2FE9E1, (q31_t)0x92EC7505, (q31_t)0xBD050F2C, + (q31_t)0x9306CB04, (q31_t)0xBCDA3ECA, (q31_t)0x932131D1, (q31_t)0xBCAF78C3, + (q31_t)0x933BA968, (q31_t)0xBC84BD1E, (q31_t)0x935631C5, (q31_t)0xBC5A0BE1, + (q31_t)0x9370CAE4, (q31_t)0xBC2F6513, (q31_t)0x938B74C0, (q31_t)0xBC04C8BA, + (q31_t)0x93A62F56, (q31_t)0xBBDA36DC, (q31_t)0x93C0FAA2, (q31_t)0xBBAFAF81, + (q31_t)0x93DBD69F, (q31_t)0xBB8532AF, (q31_t)0x93F6C34A, (q31_t)0xBB5AC06C, + (q31_t)0x9411C09D, (q31_t)0xBB3058C0, (q31_t)0x942CCE95, (q31_t)0xBB05FBB0, + (q31_t)0x9447ED2F, (q31_t)0xBADBA943, (q31_t)0x94631C64, (q31_t)0xBAB1617F, + (q31_t)0x947E5C32, (q31_t)0xBA87246C, (q31_t)0x9499AC95, (q31_t)0xBA5CF210, + (q31_t)0x94B50D87, (q31_t)0xBA32CA70, (q31_t)0x94D07F05, (q31_t)0xBA08AD94, + (q31_t)0x94EC010B, (q31_t)0xB9DE9B83, (q31_t)0x95079393, (q31_t)0xB9B49442, + (q31_t)0x9523369B, (q31_t)0xB98A97D8, (q31_t)0x953EEA1E, (q31_t)0xB960A64B, + (q31_t)0x955AAE17, (q31_t)0xB936BFA3, (q31_t)0x95768282, (q31_t)0xB90CE3E6, + (q31_t)0x9592675B, (q31_t)0xB8E31319, (q31_t)0x95AE5C9E, (q31_t)0xB8B94D44, + (q31_t)0x95CA6246, (q31_t)0xB88F926C, (q31_t)0x95E6784F, (q31_t)0xB865E299, + (q31_t)0x96029EB5, (q31_t)0xB83C3DD1, (q31_t)0x961ED573, (q31_t)0xB812A419, + (q31_t)0x963B1C85, (q31_t)0xB7E9157A, (q31_t)0x965773E7, (q31_t)0xB7BF91F8, + (q31_t)0x9673DB94, (q31_t)0xB796199B, (q31_t)0x96905387, (q31_t)0xB76CAC68, + (q31_t)0x96ACDBBD, (q31_t)0xB7434A67, (q31_t)0x96C97431, (q31_t)0xB719F39D, + (q31_t)0x96E61CDF, (q31_t)0xB6F0A811, (q31_t)0x9702D5C2, (q31_t)0xB6C767CA, + (q31_t)0x971F9ED6, (q31_t)0xB69E32CD, (q31_t)0x973C7816, (q31_t)0xB6750921, + (q31_t)0x9759617E, (q31_t)0xB64BEACC, (q31_t)0x97765B0A, (q31_t)0xB622D7D5, + (q31_t)0x979364B5, (q31_t)0xB5F9D042, (q31_t)0x97B07E7A, (q31_t)0xB5D0D41A, + (q31_t)0x97CDA855, (q31_t)0xB5A7E362, (q31_t)0x97EAE241, (q31_t)0xB57EFE21, + (q31_t)0x98082C3B, (q31_t)0xB556245E, (q31_t)0x9825863D, (q31_t)0xB52D561E, + (q31_t)0x9842F043, (q31_t)0xB5049368, (q31_t)0x98606A48, (q31_t)0xB4DBDC42, + (q31_t)0x987DF449, (q31_t)0xB4B330B2, (q31_t)0x989B8E3F, (q31_t)0xB48A90C0, + (q31_t)0x98B93828, (q31_t)0xB461FC70, (q31_t)0x98D6F1FE, (q31_t)0xB43973C9, + (q31_t)0x98F4BBBC, (q31_t)0xB410F6D2, (q31_t)0x9912955E, (q31_t)0xB3E88591, + (q31_t)0x99307EE0, (q31_t)0xB3C0200C, (q31_t)0x994E783C, (q31_t)0xB397C649, + (q31_t)0x996C816F, (q31_t)0xB36F784E, (q31_t)0x998A9A73, (q31_t)0xB3473622, + (q31_t)0x99A8C344, (q31_t)0xB31EFFCB, (q31_t)0x99C6FBDE, (q31_t)0xB2F6D54F, + (q31_t)0x99E5443A, (q31_t)0xB2CEB6B5, (q31_t)0x9A039C56, (q31_t)0xB2A6A401, + (q31_t)0x9A22042C, (q31_t)0xB27E9D3B, (q31_t)0x9A407BB8, (q31_t)0xB256A26A, + (q31_t)0x9A5F02F5, (q31_t)0xB22EB392, (q31_t)0x9A7D99DD, (q31_t)0xB206D0BA, + (q31_t)0x9A9C406D, (q31_t)0xB1DEF9E8, (q31_t)0x9ABAF6A0, (q31_t)0xB1B72F23, + (q31_t)0x9AD9BC71, (q31_t)0xB18F7070, (q31_t)0x9AF891DB, (q31_t)0xB167BDD6, + (q31_t)0x9B1776D9, (q31_t)0xB140175B, (q31_t)0x9B366B67, (q31_t)0xB1187D05, + (q31_t)0x9B556F80, (q31_t)0xB0F0EEDA, (q31_t)0x9B748320, (q31_t)0xB0C96CDF, + (q31_t)0x9B93A640, (q31_t)0xB0A1F71C, (q31_t)0x9BB2D8DD, (q31_t)0xB07A8D97, + (q31_t)0x9BD21AF2, (q31_t)0xB0533055, (q31_t)0x9BF16C7A, (q31_t)0xB02BDF5C, + (q31_t)0x9C10CD70, (q31_t)0xB0049AB2, (q31_t)0x9C303DCF, (q31_t)0xAFDD625F, + (q31_t)0x9C4FBD92, (q31_t)0xAFB63667, (q31_t)0x9C6F4CB5, (q31_t)0xAF8F16D0, + (q31_t)0x9C8EEB33, (q31_t)0xAF6803A1, (q31_t)0x9CAE9907, (q31_t)0xAF40FCE0, + (q31_t)0x9CCE562B, (q31_t)0xAF1A0293, (q31_t)0x9CEE229C, (q31_t)0xAEF314BF, + (q31_t)0x9D0DFE53, (q31_t)0xAECC336B, (q31_t)0x9D2DE94D, (q31_t)0xAEA55E9D, + (q31_t)0x9D4DE384, (q31_t)0xAE7E965B, (q31_t)0x9D6DECF4, (q31_t)0xAE57DAAA, + (q31_t)0x9D8E0596, (q31_t)0xAE312B91, (q31_t)0x9DAE2D68, (q31_t)0xAE0A8916, + (q31_t)0x9DCE6462, (q31_t)0xADE3F33E, (q31_t)0x9DEEAA82, (q31_t)0xADBD6A10, + (q31_t)0x9E0EFFC1, (q31_t)0xAD96ED91, (q31_t)0x9E2F641A, (q31_t)0xAD707DC8, + (q31_t)0x9E4FD789, (q31_t)0xAD4A1ABA, (q31_t)0x9E705A09, (q31_t)0xAD23C46D, + (q31_t)0x9E90EB94, (q31_t)0xACFD7AE8, (q31_t)0x9EB18C26, (q31_t)0xACD73E30, + (q31_t)0x9ED23BB9, (q31_t)0xACB10E4A, (q31_t)0x9EF2FA48, (q31_t)0xAC8AEB3E, + (q31_t)0x9F13C7D0, (q31_t)0xAC64D510, (q31_t)0x9F34A449, (q31_t)0xAC3ECBC7, + (q31_t)0x9F558FB0, (q31_t)0xAC18CF68, (q31_t)0x9F7689FF, (q31_t)0xABF2DFFA, + (q31_t)0x9F979331, (q31_t)0xABCCFD82, (q31_t)0x9FB8AB41, (q31_t)0xABA72806, + (q31_t)0x9FD9D22A, (q31_t)0xAB815F8C, (q31_t)0x9FFB07E7, (q31_t)0xAB5BA41A, + (q31_t)0xA01C4C72, (q31_t)0xAB35F5B5, (q31_t)0xA03D9FC7, (q31_t)0xAB105464, + (q31_t)0xA05F01E1, (q31_t)0xAAEAC02B, (q31_t)0xA08072BA, (q31_t)0xAAC53912, + (q31_t)0xA0A1F24C, (q31_t)0xAA9FBF1D, (q31_t)0xA0C38094, (q31_t)0xAA7A5253, + (q31_t)0xA0E51D8C, (q31_t)0xAA54F2B9, (q31_t)0xA106C92E, (q31_t)0xAA2FA055, + (q31_t)0xA1288376, (q31_t)0xAA0A5B2D, (q31_t)0xA14A4C5E, (q31_t)0xA9E52347, + (q31_t)0xA16C23E1, (q31_t)0xA9BFF8A8, (q31_t)0xA18E09F9, (q31_t)0xA99ADB56, + (q31_t)0xA1AFFEA2, (q31_t)0xA975CB56, (q31_t)0xA1D201D7, (q31_t)0xA950C8AF, + (q31_t)0xA1F41391, (q31_t)0xA92BD366, (q31_t)0xA21633CD, (q31_t)0xA906EB81, + (q31_t)0xA2386283, (q31_t)0xA8E21106, (q31_t)0xA25A9FB1, (q31_t)0xA8BD43FA, + (q31_t)0xA27CEB4F, (q31_t)0xA8988463, (q31_t)0xA29F4559, (q31_t)0xA873D246, + (q31_t)0xA2C1ADC9, (q31_t)0xA84F2DA9, (q31_t)0xA2E4249A, (q31_t)0xA82A9693, + (q31_t)0xA306A9C7, (q31_t)0xA8060D08, (q31_t)0xA3293D4B, (q31_t)0xA7E1910E, + (q31_t)0xA34BDF20, (q31_t)0xA7BD22AB, (q31_t)0xA36E8F40, (q31_t)0xA798C1E4, + (q31_t)0xA3914DA7, (q31_t)0xA7746EC0, (q31_t)0xA3B41A4F, (q31_t)0xA7502943, + (q31_t)0xA3D6F533, (q31_t)0xA72BF173, (q31_t)0xA3F9DE4D, (q31_t)0xA707C756, + (q31_t)0xA41CD598, (q31_t)0xA6E3AAF2, (q31_t)0xA43FDB0F, (q31_t)0xA6BF9C4B, + (q31_t)0xA462EEAC, (q31_t)0xA69B9B68, (q31_t)0xA4861069, (q31_t)0xA677A84E, + (q31_t)0xA4A94042, (q31_t)0xA653C302, (q31_t)0xA4CC7E31, (q31_t)0xA62FEB8B, + (q31_t)0xA4EFCA31, (q31_t)0xA60C21ED, (q31_t)0xA513243B, (q31_t)0xA5E8662F, + (q31_t)0xA5368C4B, (q31_t)0xA5C4B855, (q31_t)0xA55A025B, (q31_t)0xA5A11865, + (q31_t)0xA57D8666, (q31_t)0xA57D8666, (q31_t)0xA5A11865, (q31_t)0xA55A025B, + (q31_t)0xA5C4B855, (q31_t)0xA5368C4B, (q31_t)0xA5E8662F, (q31_t)0xA513243B, + (q31_t)0xA60C21ED, (q31_t)0xA4EFCA31, (q31_t)0xA62FEB8B, (q31_t)0xA4CC7E31, + (q31_t)0xA653C302, (q31_t)0xA4A94042, (q31_t)0xA677A84E, (q31_t)0xA4861069, + (q31_t)0xA69B9B68, (q31_t)0xA462EEAC, (q31_t)0xA6BF9C4B, (q31_t)0xA43FDB0F, + (q31_t)0xA6E3AAF2, (q31_t)0xA41CD598, (q31_t)0xA707C756, (q31_t)0xA3F9DE4D, + (q31_t)0xA72BF173, (q31_t)0xA3D6F533, (q31_t)0xA7502943, (q31_t)0xA3B41A4F, + (q31_t)0xA7746EC0, (q31_t)0xA3914DA7, (q31_t)0xA798C1E4, (q31_t)0xA36E8F40, + (q31_t)0xA7BD22AB, (q31_t)0xA34BDF20, (q31_t)0xA7E1910E, (q31_t)0xA3293D4B, + (q31_t)0xA8060D08, (q31_t)0xA306A9C7, (q31_t)0xA82A9693, (q31_t)0xA2E4249A, + (q31_t)0xA84F2DA9, (q31_t)0xA2C1ADC9, (q31_t)0xA873D246, (q31_t)0xA29F4559, + (q31_t)0xA8988463, (q31_t)0xA27CEB4F, (q31_t)0xA8BD43FA, (q31_t)0xA25A9FB1, + (q31_t)0xA8E21106, (q31_t)0xA2386283, (q31_t)0xA906EB81, (q31_t)0xA21633CD, + (q31_t)0xA92BD366, (q31_t)0xA1F41391, (q31_t)0xA950C8AF, (q31_t)0xA1D201D7, + (q31_t)0xA975CB56, (q31_t)0xA1AFFEA2, (q31_t)0xA99ADB56, (q31_t)0xA18E09F9, + (q31_t)0xA9BFF8A8, (q31_t)0xA16C23E1, (q31_t)0xA9E52347, (q31_t)0xA14A4C5E, + (q31_t)0xAA0A5B2D, (q31_t)0xA1288376, (q31_t)0xAA2FA055, (q31_t)0xA106C92E, + (q31_t)0xAA54F2B9, (q31_t)0xA0E51D8C, (q31_t)0xAA7A5253, (q31_t)0xA0C38094, + (q31_t)0xAA9FBF1D, (q31_t)0xA0A1F24C, (q31_t)0xAAC53912, (q31_t)0xA08072BA, + (q31_t)0xAAEAC02B, (q31_t)0xA05F01E1, (q31_t)0xAB105464, (q31_t)0xA03D9FC7, + (q31_t)0xAB35F5B5, (q31_t)0xA01C4C72, (q31_t)0xAB5BA41A, (q31_t)0x9FFB07E7, + (q31_t)0xAB815F8C, (q31_t)0x9FD9D22A, (q31_t)0xABA72806, (q31_t)0x9FB8AB41, + (q31_t)0xABCCFD82, (q31_t)0x9F979331, (q31_t)0xABF2DFFA, (q31_t)0x9F7689FF, + (q31_t)0xAC18CF68, (q31_t)0x9F558FB0, (q31_t)0xAC3ECBC7, (q31_t)0x9F34A449, + (q31_t)0xAC64D510, (q31_t)0x9F13C7D0, (q31_t)0xAC8AEB3E, (q31_t)0x9EF2FA48, + (q31_t)0xACB10E4A, (q31_t)0x9ED23BB9, (q31_t)0xACD73E30, (q31_t)0x9EB18C26, + (q31_t)0xACFD7AE8, (q31_t)0x9E90EB94, (q31_t)0xAD23C46D, (q31_t)0x9E705A09, + (q31_t)0xAD4A1ABA, (q31_t)0x9E4FD789, (q31_t)0xAD707DC8, (q31_t)0x9E2F641A, + (q31_t)0xAD96ED91, (q31_t)0x9E0EFFC1, (q31_t)0xADBD6A10, (q31_t)0x9DEEAA82, + (q31_t)0xADE3F33E, (q31_t)0x9DCE6462, (q31_t)0xAE0A8916, (q31_t)0x9DAE2D68, + (q31_t)0xAE312B91, (q31_t)0x9D8E0596, (q31_t)0xAE57DAAA, (q31_t)0x9D6DECF4, + (q31_t)0xAE7E965B, (q31_t)0x9D4DE384, (q31_t)0xAEA55E9D, (q31_t)0x9D2DE94D, + (q31_t)0xAECC336B, (q31_t)0x9D0DFE53, (q31_t)0xAEF314BF, (q31_t)0x9CEE229C, + (q31_t)0xAF1A0293, (q31_t)0x9CCE562B, (q31_t)0xAF40FCE0, (q31_t)0x9CAE9907, + (q31_t)0xAF6803A1, (q31_t)0x9C8EEB33, (q31_t)0xAF8F16D0, (q31_t)0x9C6F4CB5, + (q31_t)0xAFB63667, (q31_t)0x9C4FBD92, (q31_t)0xAFDD625F, (q31_t)0x9C303DCF, + (q31_t)0xB0049AB2, (q31_t)0x9C10CD70, (q31_t)0xB02BDF5C, (q31_t)0x9BF16C7A, + (q31_t)0xB0533055, (q31_t)0x9BD21AF2, (q31_t)0xB07A8D97, (q31_t)0x9BB2D8DD, + (q31_t)0xB0A1F71C, (q31_t)0x9B93A640, (q31_t)0xB0C96CDF, (q31_t)0x9B748320, + (q31_t)0xB0F0EEDA, (q31_t)0x9B556F80, (q31_t)0xB1187D05, (q31_t)0x9B366B67, + (q31_t)0xB140175B, (q31_t)0x9B1776D9, (q31_t)0xB167BDD6, (q31_t)0x9AF891DB, + (q31_t)0xB18F7070, (q31_t)0x9AD9BC71, (q31_t)0xB1B72F23, (q31_t)0x9ABAF6A0, + (q31_t)0xB1DEF9E8, (q31_t)0x9A9C406D, (q31_t)0xB206D0BA, (q31_t)0x9A7D99DD, + (q31_t)0xB22EB392, (q31_t)0x9A5F02F5, (q31_t)0xB256A26A, (q31_t)0x9A407BB8, + (q31_t)0xB27E9D3B, (q31_t)0x9A22042C, (q31_t)0xB2A6A401, (q31_t)0x9A039C56, + (q31_t)0xB2CEB6B5, (q31_t)0x99E5443A, (q31_t)0xB2F6D54F, (q31_t)0x99C6FBDE, + (q31_t)0xB31EFFCB, (q31_t)0x99A8C344, (q31_t)0xB3473622, (q31_t)0x998A9A73, + (q31_t)0xB36F784E, (q31_t)0x996C816F, (q31_t)0xB397C649, (q31_t)0x994E783C, + (q31_t)0xB3C0200C, (q31_t)0x99307EE0, (q31_t)0xB3E88591, (q31_t)0x9912955E, + (q31_t)0xB410F6D2, (q31_t)0x98F4BBBC, (q31_t)0xB43973C9, (q31_t)0x98D6F1FE, + (q31_t)0xB461FC70, (q31_t)0x98B93828, (q31_t)0xB48A90C0, (q31_t)0x989B8E3F, + (q31_t)0xB4B330B2, (q31_t)0x987DF449, (q31_t)0xB4DBDC42, (q31_t)0x98606A48, + (q31_t)0xB5049368, (q31_t)0x9842F043, (q31_t)0xB52D561E, (q31_t)0x9825863D, + (q31_t)0xB556245E, (q31_t)0x98082C3B, (q31_t)0xB57EFE21, (q31_t)0x97EAE241, + (q31_t)0xB5A7E362, (q31_t)0x97CDA855, (q31_t)0xB5D0D41A, (q31_t)0x97B07E7A, + (q31_t)0xB5F9D042, (q31_t)0x979364B5, (q31_t)0xB622D7D5, (q31_t)0x97765B0A, + (q31_t)0xB64BEACC, (q31_t)0x9759617E, (q31_t)0xB6750921, (q31_t)0x973C7816, + (q31_t)0xB69E32CD, (q31_t)0x971F9ED6, (q31_t)0xB6C767CA, (q31_t)0x9702D5C2, + (q31_t)0xB6F0A811, (q31_t)0x96E61CDF, (q31_t)0xB719F39D, (q31_t)0x96C97431, + (q31_t)0xB7434A67, (q31_t)0x96ACDBBD, (q31_t)0xB76CAC68, (q31_t)0x96905387, + (q31_t)0xB796199B, (q31_t)0x9673DB94, (q31_t)0xB7BF91F8, (q31_t)0x965773E7, + (q31_t)0xB7E9157A, (q31_t)0x963B1C85, (q31_t)0xB812A419, (q31_t)0x961ED573, + (q31_t)0xB83C3DD1, (q31_t)0x96029EB5, (q31_t)0xB865E299, (q31_t)0x95E6784F, + (q31_t)0xB88F926C, (q31_t)0x95CA6246, (q31_t)0xB8B94D44, (q31_t)0x95AE5C9E, + (q31_t)0xB8E31319, (q31_t)0x9592675B, (q31_t)0xB90CE3E6, (q31_t)0x95768282, + (q31_t)0xB936BFA3, (q31_t)0x955AAE17, (q31_t)0xB960A64B, (q31_t)0x953EEA1E, + (q31_t)0xB98A97D8, (q31_t)0x9523369B, (q31_t)0xB9B49442, (q31_t)0x95079393, + (q31_t)0xB9DE9B83, (q31_t)0x94EC010B, (q31_t)0xBA08AD94, (q31_t)0x94D07F05, + (q31_t)0xBA32CA70, (q31_t)0x94B50D87, (q31_t)0xBA5CF210, (q31_t)0x9499AC95, + (q31_t)0xBA87246C, (q31_t)0x947E5C32, (q31_t)0xBAB1617F, (q31_t)0x94631C64, + (q31_t)0xBADBA943, (q31_t)0x9447ED2F, (q31_t)0xBB05FBB0, (q31_t)0x942CCE95, + (q31_t)0xBB3058C0, (q31_t)0x9411C09D, (q31_t)0xBB5AC06C, (q31_t)0x93F6C34A, + (q31_t)0xBB8532AF, (q31_t)0x93DBD69F, (q31_t)0xBBAFAF81, (q31_t)0x93C0FAA2, + (q31_t)0xBBDA36DC, (q31_t)0x93A62F56, (q31_t)0xBC04C8BA, (q31_t)0x938B74C0, + (q31_t)0xBC2F6513, (q31_t)0x9370CAE4, (q31_t)0xBC5A0BE1, (q31_t)0x935631C5, + (q31_t)0xBC84BD1E, (q31_t)0x933BA968, (q31_t)0xBCAF78C3, (q31_t)0x932131D1, + (q31_t)0xBCDA3ECA, (q31_t)0x9306CB04, (q31_t)0xBD050F2C, (q31_t)0x92EC7505, + (q31_t)0xBD2FE9E1, (q31_t)0x92D22FD8, (q31_t)0xBD5ACEE5, (q31_t)0x92B7FB82, + (q31_t)0xBD85BE2F, (q31_t)0x929DD805, (q31_t)0xBDB0B7BA, (q31_t)0x9283C567, + (q31_t)0xBDDBBB7F, (q31_t)0x9269C3AC, (q31_t)0xBE06C977, (q31_t)0x924FD2D6, + (q31_t)0xBE31E19B, (q31_t)0x9235F2EB, (q31_t)0xBE5D03E5, (q31_t)0x921C23EE, + (q31_t)0xBE88304F, (q31_t)0x920265E4, (q31_t)0xBEB366D1, (q31_t)0x91E8B8D0, + (q31_t)0xBEDEA765, (q31_t)0x91CF1CB6, (q31_t)0xBF09F204, (q31_t)0x91B5919A, + (q31_t)0xBF3546A8, (q31_t)0x919C1780, (q31_t)0xBF60A54A, (q31_t)0x9182AE6C, + (q31_t)0xBF8C0DE2, (q31_t)0x91695663, (q31_t)0xBFB7806C, (q31_t)0x91500F67, + (q31_t)0xBFE2FCDF, (q31_t)0x9136D97D, (q31_t)0xC00E8335, (q31_t)0x911DB4A8, + (q31_t)0xC03A1368, (q31_t)0x9104A0ED, (q31_t)0xC065AD70, (q31_t)0x90EB9E50, + (q31_t)0xC0915147, (q31_t)0x90D2ACD3, (q31_t)0xC0BCFEE7, (q31_t)0x90B9CC7C, + (q31_t)0xC0E8B648, (q31_t)0x90A0FD4E, (q31_t)0xC1147763, (q31_t)0x90883F4C, + (q31_t)0xC1404233, (q31_t)0x906F927B, (q31_t)0xC16C16B0, (q31_t)0x9056F6DF, + (q31_t)0xC197F4D3, (q31_t)0x903E6C7A, (q31_t)0xC1C3DC96, (q31_t)0x9025F352, + (q31_t)0xC1EFCDF2, (q31_t)0x900D8B69, (q31_t)0xC21BC8E0, (q31_t)0x8FF534C4, + (q31_t)0xC247CD5A, (q31_t)0x8FDCEF66, (q31_t)0xC273DB58, (q31_t)0x8FC4BB53, + (q31_t)0xC29FF2D4, (q31_t)0x8FAC988E, (q31_t)0xC2CC13C7, (q31_t)0x8F94871D, + (q31_t)0xC2F83E2A, (q31_t)0x8F7C8701, (q31_t)0xC32471F6, (q31_t)0x8F64983F, + (q31_t)0xC350AF25, (q31_t)0x8F4CBADB, (q31_t)0xC37CF5B0, (q31_t)0x8F34EED8, + (q31_t)0xC3A9458F, (q31_t)0x8F1D343A, (q31_t)0xC3D59EBD, (q31_t)0x8F058B04, + (q31_t)0xC4020132, (q31_t)0x8EEDF33B, (q31_t)0xC42E6CE8, (q31_t)0x8ED66CE1, + (q31_t)0xC45AE1D7, (q31_t)0x8EBEF7FB, (q31_t)0xC4875FF8, (q31_t)0x8EA7948C, + (q31_t)0xC4B3E746, (q31_t)0x8E904298, (q31_t)0xC4E077B8, (q31_t)0x8E790222, + (q31_t)0xC50D1148, (q31_t)0x8E61D32D, (q31_t)0xC539B3F0, (q31_t)0x8E4AB5BF, + (q31_t)0xC5665FA8, (q31_t)0x8E33A9D9, (q31_t)0xC593146A, (q31_t)0x8E1CAF80, + (q31_t)0xC5BFD22E, (q31_t)0x8E05C6B7, (q31_t)0xC5EC98ED, (q31_t)0x8DEEEF82, + (q31_t)0xC61968A2, (q31_t)0x8DD829E4, (q31_t)0xC6464144, (q31_t)0x8DC175E0, + (q31_t)0xC67322CD, (q31_t)0x8DAAD37B, (q31_t)0xC6A00D36, (q31_t)0x8D9442B7, + (q31_t)0xC6CD0079, (q31_t)0x8D7DC399, (q31_t)0xC6F9FC8D, (q31_t)0x8D675623, + (q31_t)0xC727016C, (q31_t)0x8D50FA59, (q31_t)0xC7540F10, (q31_t)0x8D3AB03F, + (q31_t)0xC7812571, (q31_t)0x8D2477D8, (q31_t)0xC7AE4489, (q31_t)0x8D0E5127, + (q31_t)0xC7DB6C50, (q31_t)0x8CF83C30, (q31_t)0xC8089CBF, (q31_t)0x8CE238F6, + (q31_t)0xC835D5D0, (q31_t)0x8CCC477D, (q31_t)0xC863177B, (q31_t)0x8CB667C7, + (q31_t)0xC89061BA, (q31_t)0x8CA099D9, (q31_t)0xC8BDB485, (q31_t)0x8C8ADDB6, + (q31_t)0xC8EB0FD6, (q31_t)0x8C753361, (q31_t)0xC91873A5, (q31_t)0x8C5F9ADD, + (q31_t)0xC945DFEC, (q31_t)0x8C4A142F, (q31_t)0xC97354A3, (q31_t)0x8C349F58, + (q31_t)0xC9A0D1C4, (q31_t)0x8C1F3C5C, (q31_t)0xC9CE5748, (q31_t)0x8C09EB40, + (q31_t)0xC9FBE527, (q31_t)0x8BF4AC05, (q31_t)0xCA297B5A, (q31_t)0x8BDF7EAF, + (q31_t)0xCA5719DB, (q31_t)0x8BCA6342, (q31_t)0xCA84C0A2, (q31_t)0x8BB559C1, + (q31_t)0xCAB26FA9, (q31_t)0x8BA0622F, (q31_t)0xCAE026E8, (q31_t)0x8B8B7C8F, + (q31_t)0xCB0DE658, (q31_t)0x8B76A8E4, (q31_t)0xCB3BADF2, (q31_t)0x8B61E732, + (q31_t)0xCB697DB0, (q31_t)0x8B4D377C, (q31_t)0xCB975589, (q31_t)0x8B3899C5, + (q31_t)0xCBC53578, (q31_t)0x8B240E10, (q31_t)0xCBF31D75, (q31_t)0x8B0F9461, + (q31_t)0xCC210D78, (q31_t)0x8AFB2CBA, (q31_t)0xCC4F057B, (q31_t)0x8AE6D71F, + (q31_t)0xCC7D0577, (q31_t)0x8AD29393, (q31_t)0xCCAB0D65, (q31_t)0x8ABE6219, + (q31_t)0xCCD91D3D, (q31_t)0x8AAA42B4, (q31_t)0xCD0734F8, (q31_t)0x8A963567, + (q31_t)0xCD355490, (q31_t)0x8A823A35, (q31_t)0xCD637BFD, (q31_t)0x8A6E5122, + (q31_t)0xCD91AB38, (q31_t)0x8A5A7A30, (q31_t)0xCDBFE23A, (q31_t)0x8A46B563, + (q31_t)0xCDEE20FC, (q31_t)0x8A3302BD, (q31_t)0xCE1C6776, (q31_t)0x8A1F6242, + (q31_t)0xCE4AB5A2, (q31_t)0x8A0BD3F5, (q31_t)0xCE790B78, (q31_t)0x89F857D8, + (q31_t)0xCEA768F2, (q31_t)0x89E4EDEE, (q31_t)0xCED5CE08, (q31_t)0x89D1963C, + (q31_t)0xCF043AB2, (q31_t)0x89BE50C3, (q31_t)0xCF32AEEB, (q31_t)0x89AB1D86, + (q31_t)0xCF612AAA, (q31_t)0x8997FC89, (q31_t)0xCF8FADE8, (q31_t)0x8984EDCF, + (q31_t)0xCFBE389F, (q31_t)0x8971F15A, (q31_t)0xCFECCAC7, (q31_t)0x895F072D, + (q31_t)0xD01B6459, (q31_t)0x894C2F4C, (q31_t)0xD04A054D, (q31_t)0x893969B9, + (q31_t)0xD078AD9D, (q31_t)0x8926B677, (q31_t)0xD0A75D42, (q31_t)0x89141589, + (q31_t)0xD0D61433, (q31_t)0x890186F1, (q31_t)0xD104D26B, (q31_t)0x88EF0AB4, + (q31_t)0xD13397E1, (q31_t)0x88DCA0D3, (q31_t)0xD162648F, (q31_t)0x88CA4951, + (q31_t)0xD191386D, (q31_t)0x88B80431, (q31_t)0xD1C01374, (q31_t)0x88A5D177, + (q31_t)0xD1EEF59E, (q31_t)0x8893B124, (q31_t)0xD21DDEE1, (q31_t)0x8881A33C, + (q31_t)0xD24CCF38, (q31_t)0x886FA7C2, (q31_t)0xD27BC69C, (q31_t)0x885DBEB7, + (q31_t)0xD2AAC504, (q31_t)0x884BE820, (q31_t)0xD2D9CA6A, (q31_t)0x883A23FE, + (q31_t)0xD308D6C6, (q31_t)0x88287255, (q31_t)0xD337EA12, (q31_t)0x8816D327, + (q31_t)0xD3670445, (q31_t)0x88054677, (q31_t)0xD3962559, (q31_t)0x87F3CC47, + (q31_t)0xD3C54D46, (q31_t)0x87E2649B, (q31_t)0xD3F47C06, (q31_t)0x87D10F75, + (q31_t)0xD423B190, (q31_t)0x87BFCCD7, (q31_t)0xD452EDDE, (q31_t)0x87AE9CC5, + (q31_t)0xD48230E8, (q31_t)0x879D7F40, (q31_t)0xD4B17AA7, (q31_t)0x878C744C, + (q31_t)0xD4E0CB14, (q31_t)0x877B7BEC, (q31_t)0xD5102227, (q31_t)0x876A9621, + (q31_t)0xD53F7FDA, (q31_t)0x8759C2EF, (q31_t)0xD56EE424, (q31_t)0x87490257, + (q31_t)0xD59E4EFE, (q31_t)0x8738545E, (q31_t)0xD5CDC062, (q31_t)0x8727B904, + (q31_t)0xD5FD3847, (q31_t)0x8717304E, (q31_t)0xD62CB6A7, (q31_t)0x8706BA3C, + (q31_t)0xD65C3B7B, (q31_t)0x86F656D3, (q31_t)0xD68BC6BA, (q31_t)0x86E60614, + (q31_t)0xD6BB585D, (q31_t)0x86D5C802, (q31_t)0xD6EAF05E, (q31_t)0x86C59C9F, + (q31_t)0xD71A8EB5, (q31_t)0x86B583EE, (q31_t)0xD74A335A, (q31_t)0x86A57DF1, + (q31_t)0xD779DE46, (q31_t)0x86958AAB, (q31_t)0xD7A98F73, (q31_t)0x8685AA1F, + (q31_t)0xD7D946D7, (q31_t)0x8675DC4E, (q31_t)0xD809046D, (q31_t)0x8666213C, + (q31_t)0xD838C82D, (q31_t)0x865678EA, (q31_t)0xD868920F, (q31_t)0x8646E35B, + (q31_t)0xD898620C, (q31_t)0x86376092, (q31_t)0xD8C8381C, (q31_t)0x8627F090, + (q31_t)0xD8F81439, (q31_t)0x86189359, (q31_t)0xD927F65B, (q31_t)0x860948EE, + (q31_t)0xD957DE7A, (q31_t)0x85FA1152, (q31_t)0xD987CC8F, (q31_t)0x85EAEC88, + (q31_t)0xD9B7C093, (q31_t)0x85DBDA91, (q31_t)0xD9E7BA7E, (q31_t)0x85CCDB70, + (q31_t)0xDA17BA4A, (q31_t)0x85BDEF27, (q31_t)0xDA47BFED, (q31_t)0x85AF15B9, + (q31_t)0xDA77CB62, (q31_t)0x85A04F28, (q31_t)0xDAA7DCA1, (q31_t)0x85919B75, + (q31_t)0xDAD7F3A2, (q31_t)0x8582FAA4, (q31_t)0xDB08105E, (q31_t)0x85746CB7, + (q31_t)0xDB3832CD, (q31_t)0x8565F1B0, (q31_t)0xDB685AE8, (q31_t)0x85578991, + (q31_t)0xDB9888A8, (q31_t)0x8549345C, (q31_t)0xDBC8BC05, (q31_t)0x853AF214, + (q31_t)0xDBF8F4F8, (q31_t)0x852CC2BA, (q31_t)0xDC293379, (q31_t)0x851EA652, + (q31_t)0xDC597781, (q31_t)0x85109CDC, (q31_t)0xDC89C108, (q31_t)0x8502A65C, + (q31_t)0xDCBA1008, (q31_t)0x84F4C2D3, (q31_t)0xDCEA6478, (q31_t)0x84E6F244, + (q31_t)0xDD1ABE51, (q31_t)0x84D934B0, (q31_t)0xDD4B1D8B, (q31_t)0x84CB8A1B, + (q31_t)0xDD7B8220, (q31_t)0x84BDF285, (q31_t)0xDDABEC07, (q31_t)0x84B06DF1, + (q31_t)0xDDDC5B3A, (q31_t)0x84A2FC62, (q31_t)0xDE0CCFB1, (q31_t)0x84959DD9, + (q31_t)0xDE3D4963, (q31_t)0x84885257, (q31_t)0xDE6DC84B, (q31_t)0x847B19E1, + (q31_t)0xDE9E4C60, (q31_t)0x846DF476, (q31_t)0xDECED59B, (q31_t)0x8460E21A, + (q31_t)0xDEFF63F4, (q31_t)0x8453E2CE, (q31_t)0xDF2FF764, (q31_t)0x8446F695, + (q31_t)0xDF608FE3, (q31_t)0x843A1D70, (q31_t)0xDF912D6A, (q31_t)0x842D5761, + (q31_t)0xDFC1CFF2, (q31_t)0x8420A46B, (q31_t)0xDFF27773, (q31_t)0x8414048F, + (q31_t)0xE02323E5, (q31_t)0x840777CF, (q31_t)0xE053D541, (q31_t)0x83FAFE2E, + (q31_t)0xE0848B7F, (q31_t)0x83EE97AC, (q31_t)0xE0B54698, (q31_t)0x83E2444D, + (q31_t)0xE0E60684, (q31_t)0x83D60411, (q31_t)0xE116CB3D, (q31_t)0x83C9D6FB, + (q31_t)0xE14794B9, (q31_t)0x83BDBD0D, (q31_t)0xE17862F3, (q31_t)0x83B1B649, + (q31_t)0xE1A935E1, (q31_t)0x83A5C2B0, (q31_t)0xE1DA0D7E, (q31_t)0x8399E244, + (q31_t)0xE20AE9C1, (q31_t)0x838E1507, (q31_t)0xE23BCAA2, (q31_t)0x83825AFB, + (q31_t)0xE26CB01A, (q31_t)0x8376B422, (q31_t)0xE29D9A22, (q31_t)0x836B207D, + (q31_t)0xE2CE88B2, (q31_t)0x835FA00E, (q31_t)0xE2FF7BC3, (q31_t)0x835432D8, + (q31_t)0xE330734C, (q31_t)0x8348D8DB, (q31_t)0xE3616F47, (q31_t)0x833D921A, + (q31_t)0xE3926FAC, (q31_t)0x83325E97, (q31_t)0xE3C37473, (q31_t)0x83273E52, + (q31_t)0xE3F47D95, (q31_t)0x831C314E, (q31_t)0xE4258B0A, (q31_t)0x8311378C, + (q31_t)0xE4569CCB, (q31_t)0x8306510F, (q31_t)0xE487B2CF, (q31_t)0x82FB7DD8, + (q31_t)0xE4B8CD10, (q31_t)0x82F0BDE8, (q31_t)0xE4E9EB86, (q31_t)0x82E61141, + (q31_t)0xE51B0E2A, (q31_t)0x82DB77E5, (q31_t)0xE54C34F3, (q31_t)0x82D0F1D5, + (q31_t)0xE57D5FDA, (q31_t)0x82C67F13, (q31_t)0xE5AE8ED8, (q31_t)0x82BC1FA1, + (q31_t)0xE5DFC1E4, (q31_t)0x82B1D381, (q31_t)0xE610F8F9, (q31_t)0x82A79AB3, + (q31_t)0xE642340D, (q31_t)0x829D753A, (q31_t)0xE6737319, (q31_t)0x82936316, + (q31_t)0xE6A4B616, (q31_t)0x8289644A, (q31_t)0xE6D5FCFC, (q31_t)0x827F78D8, + (q31_t)0xE70747C3, (q31_t)0x8275A0C0, (q31_t)0xE7389664, (q31_t)0x826BDC04, + (q31_t)0xE769E8D8, (q31_t)0x82622AA5, (q31_t)0xE79B3F16, (q31_t)0x82588CA6, + (q31_t)0xE7CC9917, (q31_t)0x824F0208, (q31_t)0xE7FDF6D3, (q31_t)0x82458ACB, + (q31_t)0xE82F5844, (q31_t)0x823C26F2, (q31_t)0xE860BD60, (q31_t)0x8232D67E, + (q31_t)0xE8922621, (q31_t)0x82299971, (q31_t)0xE8C3927F, (q31_t)0x82206FCB, + (q31_t)0xE8F50273, (q31_t)0x8217598F, (q31_t)0xE92675F4, (q31_t)0x820E56BE, + (q31_t)0xE957ECFB, (q31_t)0x82056758, (q31_t)0xE9896780, (q31_t)0x81FC8B60, + (q31_t)0xE9BAE57C, (q31_t)0x81F3C2D7, (q31_t)0xE9EC66E8, (q31_t)0x81EB0DBD, + (q31_t)0xEA1DEBBB, (q31_t)0x81E26C16, (q31_t)0xEA4F73EE, (q31_t)0x81D9DDE1, + (q31_t)0xEA80FF79, (q31_t)0x81D16320, (q31_t)0xEAB28E55, (q31_t)0x81C8FBD5, + (q31_t)0xEAE4207A, (q31_t)0x81C0A801, (q31_t)0xEB15B5E0, (q31_t)0x81B867A4, + (q31_t)0xEB474E80, (q31_t)0x81B03AC1, (q31_t)0xEB78EA52, (q31_t)0x81A82159, + (q31_t)0xEBAA894E, (q31_t)0x81A01B6C, (q31_t)0xEBDC2B6D, (q31_t)0x819828FD, + (q31_t)0xEC0DD0A8, (q31_t)0x81904A0C, (q31_t)0xEC3F78F5, (q31_t)0x81887E9A, + (q31_t)0xEC71244F, (q31_t)0x8180C6A9, (q31_t)0xECA2D2AC, (q31_t)0x8179223A, + (q31_t)0xECD48406, (q31_t)0x8171914E, (q31_t)0xED063855, (q31_t)0x816A13E6, + (q31_t)0xED37EF91, (q31_t)0x8162AA03, (q31_t)0xED69A9B2, (q31_t)0x815B53A8, + (q31_t)0xED9B66B2, (q31_t)0x815410D3, (q31_t)0xEDCD2687, (q31_t)0x814CE188, + (q31_t)0xEDFEE92B, (q31_t)0x8145C5C6, (q31_t)0xEE30AE95, (q31_t)0x813EBD90, + (q31_t)0xEE6276BF, (q31_t)0x8137C8E6, (q31_t)0xEE9441A0, (q31_t)0x8130E7C8, + (q31_t)0xEEC60F31, (q31_t)0x812A1A39, (q31_t)0xEEF7DF6A, (q31_t)0x81236039, + (q31_t)0xEF29B243, (q31_t)0x811CB9CA, (q31_t)0xEF5B87B5, (q31_t)0x811626EC, + (q31_t)0xEF8D5FB8, (q31_t)0x810FA7A0, (q31_t)0xEFBF3A44, (q31_t)0x81093BE8, + (q31_t)0xEFF11752, (q31_t)0x8102E3C3, (q31_t)0xF022F6DA, (q31_t)0x80FC9F35, + (q31_t)0xF054D8D4, (q31_t)0x80F66E3C, (q31_t)0xF086BD39, (q31_t)0x80F050DB, + (q31_t)0xF0B8A401, (q31_t)0x80EA4712, (q31_t)0xF0EA8D23, (q31_t)0x80E450E2, + (q31_t)0xF11C789A, (q31_t)0x80DE6E4C, (q31_t)0xF14E665C, (q31_t)0x80D89F51, + (q31_t)0xF1805662, (q31_t)0x80D2E3F1, (q31_t)0xF1B248A5, (q31_t)0x80CD3C2F, + (q31_t)0xF1E43D1C, (q31_t)0x80C7A80A, (q31_t)0xF21633C0, (q31_t)0x80C22783, + (q31_t)0xF2482C89, (q31_t)0x80BCBA9C, (q31_t)0xF27A2770, (q31_t)0x80B76155, + (q31_t)0xF2AC246D, (q31_t)0x80B21BAF, (q31_t)0xF2DE2378, (q31_t)0x80ACE9AB, + (q31_t)0xF310248A, (q31_t)0x80A7CB49, (q31_t)0xF342279A, (q31_t)0x80A2C08B, + (q31_t)0xF3742CA1, (q31_t)0x809DC970, (q31_t)0xF3A63398, (q31_t)0x8098E5FB, + (q31_t)0xF3D83C76, (q31_t)0x8094162B, (q31_t)0xF40A4734, (q31_t)0x808F5A02, + (q31_t)0xF43C53CA, (q31_t)0x808AB180, (q31_t)0xF46E6231, (q31_t)0x80861CA5, + (q31_t)0xF4A07260, (q31_t)0x80819B74, (q31_t)0xF4D28451, (q31_t)0x807D2DEB, + (q31_t)0xF50497FA, (q31_t)0x8078D40D, (q31_t)0xF536AD55, (q31_t)0x80748DD9, + (q31_t)0xF568C45A, (q31_t)0x80705B50, (q31_t)0xF59ADD01, (q31_t)0x806C3C73, + (q31_t)0xF5CCF743, (q31_t)0x80683143, (q31_t)0xF5FF1317, (q31_t)0x806439C0, + (q31_t)0xF6313076, (q31_t)0x806055EA, (q31_t)0xF6634F58, (q31_t)0x805C85C3, + (q31_t)0xF6956FB6, (q31_t)0x8058C94C, (q31_t)0xF6C79188, (q31_t)0x80552083, + (q31_t)0xF6F9B4C5, (q31_t)0x80518B6B, (q31_t)0xF72BD967, (q31_t)0x804E0A03, + (q31_t)0xF75DFF65, (q31_t)0x804A9C4D, (q31_t)0xF79026B8, (q31_t)0x80474248, + (q31_t)0xF7C24F58, (q31_t)0x8043FBF6, (q31_t)0xF7F4793E, (q31_t)0x8040C956, + (q31_t)0xF826A461, (q31_t)0x803DAA69, (q31_t)0xF858D0BA, (q31_t)0x803A9F31, + (q31_t)0xF88AFE41, (q31_t)0x8037A7AC, (q31_t)0xF8BD2CEF, (q31_t)0x8034C3DC, + (q31_t)0xF8EF5CBB, (q31_t)0x8031F3C1, (q31_t)0xF9218D9E, (q31_t)0x802F375C, + (q31_t)0xF953BF90, (q31_t)0x802C8EAD, (q31_t)0xF985F28A, (q31_t)0x8029F9B4, + (q31_t)0xF9B82683, (q31_t)0x80277872, (q31_t)0xF9EA5B75, (q31_t)0x80250AE7, + (q31_t)0xFA1C9156, (q31_t)0x8022B113, (q31_t)0xFA4EC820, (q31_t)0x80206AF8, + (q31_t)0xFA80FFCB, (q31_t)0x801E3894, (q31_t)0xFAB3384F, (q31_t)0x801C19E9, + (q31_t)0xFAE571A4, (q31_t)0x801A0EF7, (q31_t)0xFB17ABC2, (q31_t)0x801817BF, + (q31_t)0xFB49E6A2, (q31_t)0x80163440, (q31_t)0xFB7C223C, (q31_t)0x8014647A, + (q31_t)0xFBAE5E89, (q31_t)0x8012A86F, (q31_t)0xFBE09B80, (q31_t)0x8011001E, + (q31_t)0xFC12D919, (q31_t)0x800F6B88, (q31_t)0xFC45174E, (q31_t)0x800DEAAC, + (q31_t)0xFC775616, (q31_t)0x800C7D8C, (q31_t)0xFCA99569, (q31_t)0x800B2427, + (q31_t)0xFCDBD541, (q31_t)0x8009DE7D, (q31_t)0xFD0E1594, (q31_t)0x8008AC90, + (q31_t)0xFD40565B, (q31_t)0x80078E5E, (q31_t)0xFD72978F, (q31_t)0x800683E8, + (q31_t)0xFDA4D928, (q31_t)0x80058D2E, (q31_t)0xFDD71B1E, (q31_t)0x8004AA31, + (q31_t)0xFE095D69, (q31_t)0x8003DAF0, (q31_t)0xFE3BA001, (q31_t)0x80031F6C, + (q31_t)0xFE6DE2E0, (q31_t)0x800277A5, (q31_t)0xFEA025FC, (q31_t)0x8001E39B, + (q31_t)0xFED2694F, (q31_t)0x8001634D, (q31_t)0xFF04ACD0, (q31_t)0x8000F6BD, + (q31_t)0xFF36F078, (q31_t)0x80009DE9, (q31_t)0xFF69343E, (q31_t)0x800058D3, + (q31_t)0xFF9B781D, (q31_t)0x8000277A, (q31_t)0xFFCDBC0A, (q31_t)0x800009DE}; /** @brief q15 Twiddle factors Table */ - /** @par Example code for q15 Twiddle factors Generation:: @@ -12814,22 +6846,14 @@ const q31_t twiddleCoef_4096_q31[6144] = Cos and Sin values are interleaved fashion @par Convert Floating point to q15(Fixed point 1.15): - round(twiddleCoefq15(i) * pow(2, 15)) + round(twiddleCoefq15(i) * pow(2, 15)) */ const q15_t twiddleCoef_16_q15[24] = { - (q15_t)0x7FFF, (q15_t)0x0000, - (q15_t)0x7641, (q15_t)0x30FB, - (q15_t)0x5A82, (q15_t)0x5A82, - (q15_t)0x30FB, (q15_t)0x7641, - (q15_t)0x0000, (q15_t)0x7FFF, - (q15_t)0xCF04, (q15_t)0x7641, - (q15_t)0xA57D, (q15_t)0x5A82, - (q15_t)0x89BE, (q15_t)0x30FB, - (q15_t)0x8000, (q15_t)0x0000, - (q15_t)0x89BE, (q15_t)0xCF04, - (q15_t)0xA57D, (q15_t)0xA57D, - (q15_t)0xCF04, (q15_t)0x89BE -}; + (q15_t)0x7FFF, (q15_t)0x0000, (q15_t)0x7641, (q15_t)0x30FB, (q15_t)0x5A82, + (q15_t)0x5A82, (q15_t)0x30FB, (q15_t)0x7641, (q15_t)0x0000, (q15_t)0x7FFF, + (q15_t)0xCF04, (q15_t)0x7641, (q15_t)0xA57D, (q15_t)0x5A82, (q15_t)0x89BE, + (q15_t)0x30FB, (q15_t)0x8000, (q15_t)0x0000, (q15_t)0x89BE, (q15_t)0xCF04, + (q15_t)0xA57D, (q15_t)0xA57D, (q15_t)0xCF04, (q15_t)0x89BE}; /** @par @@ -12846,34 +6870,19 @@ const q15_t twiddleCoef_16_q15[24] = { Cos and Sin values are interleaved fashion @par Convert Floating point to q15(Fixed point 1.15): - round(twiddleCoefq15(i) * pow(2, 15)) + round(twiddleCoefq15(i) * pow(2, 15)) */ const q15_t twiddleCoef_32_q15[48] = { - (q15_t)0x7FFF, (q15_t)0x0000, - (q15_t)0x7D8A, (q15_t)0x18F8, - (q15_t)0x7641, (q15_t)0x30FB, - (q15_t)0x6A6D, (q15_t)0x471C, - (q15_t)0x5A82, (q15_t)0x5A82, - (q15_t)0x471C, (q15_t)0x6A6D, - (q15_t)0x30FB, (q15_t)0x7641, - (q15_t)0x18F8, (q15_t)0x7D8A, - (q15_t)0x0000, (q15_t)0x7FFF, - (q15_t)0xE707, (q15_t)0x7D8A, - (q15_t)0xCF04, (q15_t)0x7641, - (q15_t)0xB8E3, (q15_t)0x6A6D, - (q15_t)0xA57D, (q15_t)0x5A82, - (q15_t)0x9592, (q15_t)0x471C, - (q15_t)0x89BE, (q15_t)0x30FB, - (q15_t)0x8275, (q15_t)0x18F8, - (q15_t)0x8000, (q15_t)0x0000, - (q15_t)0x8275, (q15_t)0xE707, - (q15_t)0x89BE, (q15_t)0xCF04, - (q15_t)0x9592, (q15_t)0xB8E3, - (q15_t)0xA57D, (q15_t)0xA57D, - (q15_t)0xB8E3, (q15_t)0x9592, - (q15_t)0xCF04, (q15_t)0x89BE, - (q15_t)0xE707, (q15_t)0x8275 -}; + (q15_t)0x7FFF, (q15_t)0x0000, (q15_t)0x7D8A, (q15_t)0x18F8, (q15_t)0x7641, + (q15_t)0x30FB, (q15_t)0x6A6D, (q15_t)0x471C, (q15_t)0x5A82, (q15_t)0x5A82, + (q15_t)0x471C, (q15_t)0x6A6D, (q15_t)0x30FB, (q15_t)0x7641, (q15_t)0x18F8, + (q15_t)0x7D8A, (q15_t)0x0000, (q15_t)0x7FFF, (q15_t)0xE707, (q15_t)0x7D8A, + (q15_t)0xCF04, (q15_t)0x7641, (q15_t)0xB8E3, (q15_t)0x6A6D, (q15_t)0xA57D, + (q15_t)0x5A82, (q15_t)0x9592, (q15_t)0x471C, (q15_t)0x89BE, (q15_t)0x30FB, + (q15_t)0x8275, (q15_t)0x18F8, (q15_t)0x8000, (q15_t)0x0000, (q15_t)0x8275, + (q15_t)0xE707, (q15_t)0x89BE, (q15_t)0xCF04, (q15_t)0x9592, (q15_t)0xB8E3, + (q15_t)0xA57D, (q15_t)0xA57D, (q15_t)0xB8E3, (q15_t)0x9592, (q15_t)0xCF04, + (q15_t)0x89BE, (q15_t)0xE707, (q15_t)0x8275}; /** @par @@ -12890,34 +6899,29 @@ const q15_t twiddleCoef_32_q15[48] = { Cos and Sin values are interleaved fashion @par Convert Floating point to q15(Fixed point 1.15): - round(twiddleCoefq15(i) * pow(2, 15)) + round(twiddleCoefq15(i) * pow(2, 15)) */ const q15_t twiddleCoef_64_q15[96] = { - (q15_t)0x7FFF, (q15_t)0x0000, (q15_t)0x7F62, (q15_t)0x0C8B, - (q15_t)0x7D8A, (q15_t)0x18F8, (q15_t)0x7A7D, (q15_t)0x2528, - (q15_t)0x7641, (q15_t)0x30FB, (q15_t)0x70E2, (q15_t)0x3C56, - (q15_t)0x6A6D, (q15_t)0x471C, (q15_t)0x62F2, (q15_t)0x5133, - (q15_t)0x5A82, (q15_t)0x5A82, (q15_t)0x5133, (q15_t)0x62F2, - (q15_t)0x471C, (q15_t)0x6A6D, (q15_t)0x3C56, (q15_t)0x70E2, - (q15_t)0x30FB, (q15_t)0x7641, (q15_t)0x2528, (q15_t)0x7A7D, - (q15_t)0x18F8, (q15_t)0x7D8A, (q15_t)0x0C8B, (q15_t)0x7F62, - (q15_t)0x0000, (q15_t)0x7FFF, (q15_t)0xF374, (q15_t)0x7F62, - (q15_t)0xE707, (q15_t)0x7D8A, (q15_t)0xDAD7, (q15_t)0x7A7D, - (q15_t)0xCF04, (q15_t)0x7641, (q15_t)0xC3A9, (q15_t)0x70E2, - (q15_t)0xB8E3, (q15_t)0x6A6D, (q15_t)0xAECC, (q15_t)0x62F2, - (q15_t)0xA57D, (q15_t)0x5A82, (q15_t)0x9D0D, (q15_t)0x5133, - (q15_t)0x9592, (q15_t)0x471C, (q15_t)0x8F1D, (q15_t)0x3C56, - (q15_t)0x89BE, (q15_t)0x30FB, (q15_t)0x8582, (q15_t)0x2528, - (q15_t)0x8275, (q15_t)0x18F8, (q15_t)0x809D, (q15_t)0x0C8B, - (q15_t)0x8000, (q15_t)0x0000, (q15_t)0x809D, (q15_t)0xF374, - (q15_t)0x8275, (q15_t)0xE707, (q15_t)0x8582, (q15_t)0xDAD7, - (q15_t)0x89BE, (q15_t)0xCF04, (q15_t)0x8F1D, (q15_t)0xC3A9, - (q15_t)0x9592, (q15_t)0xB8E3, (q15_t)0x9D0D, (q15_t)0xAECC, - (q15_t)0xA57D, (q15_t)0xA57D, (q15_t)0xAECC, (q15_t)0x9D0D, - (q15_t)0xB8E3, (q15_t)0x9592, (q15_t)0xC3A9, (q15_t)0x8F1D, - (q15_t)0xCF04, (q15_t)0x89BE, (q15_t)0xDAD7, (q15_t)0x8582, - (q15_t)0xE707, (q15_t)0x8275, (q15_t)0xF374, (q15_t)0x809D -}; + (q15_t)0x7FFF, (q15_t)0x0000, (q15_t)0x7F62, (q15_t)0x0C8B, (q15_t)0x7D8A, + (q15_t)0x18F8, (q15_t)0x7A7D, (q15_t)0x2528, (q15_t)0x7641, (q15_t)0x30FB, + (q15_t)0x70E2, (q15_t)0x3C56, (q15_t)0x6A6D, (q15_t)0x471C, (q15_t)0x62F2, + (q15_t)0x5133, (q15_t)0x5A82, (q15_t)0x5A82, (q15_t)0x5133, (q15_t)0x62F2, + (q15_t)0x471C, (q15_t)0x6A6D, (q15_t)0x3C56, (q15_t)0x70E2, (q15_t)0x30FB, + (q15_t)0x7641, (q15_t)0x2528, (q15_t)0x7A7D, (q15_t)0x18F8, (q15_t)0x7D8A, + (q15_t)0x0C8B, (q15_t)0x7F62, (q15_t)0x0000, (q15_t)0x7FFF, (q15_t)0xF374, + (q15_t)0x7F62, (q15_t)0xE707, (q15_t)0x7D8A, (q15_t)0xDAD7, (q15_t)0x7A7D, + (q15_t)0xCF04, (q15_t)0x7641, (q15_t)0xC3A9, (q15_t)0x70E2, (q15_t)0xB8E3, + (q15_t)0x6A6D, (q15_t)0xAECC, (q15_t)0x62F2, (q15_t)0xA57D, (q15_t)0x5A82, + (q15_t)0x9D0D, (q15_t)0x5133, (q15_t)0x9592, (q15_t)0x471C, (q15_t)0x8F1D, + (q15_t)0x3C56, (q15_t)0x89BE, (q15_t)0x30FB, (q15_t)0x8582, (q15_t)0x2528, + (q15_t)0x8275, (q15_t)0x18F8, (q15_t)0x809D, (q15_t)0x0C8B, (q15_t)0x8000, + (q15_t)0x0000, (q15_t)0x809D, (q15_t)0xF374, (q15_t)0x8275, (q15_t)0xE707, + (q15_t)0x8582, (q15_t)0xDAD7, (q15_t)0x89BE, (q15_t)0xCF04, (q15_t)0x8F1D, + (q15_t)0xC3A9, (q15_t)0x9592, (q15_t)0xB8E3, (q15_t)0x9D0D, (q15_t)0xAECC, + (q15_t)0xA57D, (q15_t)0xA57D, (q15_t)0xAECC, (q15_t)0x9D0D, (q15_t)0xB8E3, + (q15_t)0x9592, (q15_t)0xC3A9, (q15_t)0x8F1D, (q15_t)0xCF04, (q15_t)0x89BE, + (q15_t)0xDAD7, (q15_t)0x8582, (q15_t)0xE707, (q15_t)0x8275, (q15_t)0xF374, + (q15_t)0x809D}; /** @par @@ -12934,58 +6938,48 @@ const q15_t twiddleCoef_64_q15[96] = { Cos and Sin values are interleaved fashion @par Convert Floating point to q15(Fixed point 1.15): - round(twiddleCoefq15(i) * pow(2, 15)) + round(twiddleCoefq15(i) * pow(2, 15)) */ const q15_t twiddleCoef_128_q15[192] = { - (q15_t)0x7FFF, (q15_t)0x0000, (q15_t)0x7FD8, (q15_t)0x0647, - (q15_t)0x7F62, (q15_t)0x0C8B, (q15_t)0x7E9D, (q15_t)0x12C8, - (q15_t)0x7D8A, (q15_t)0x18F8, (q15_t)0x7C29, (q15_t)0x1F19, - (q15_t)0x7A7D, (q15_t)0x2528, (q15_t)0x7884, (q15_t)0x2B1F, - (q15_t)0x7641, (q15_t)0x30FB, (q15_t)0x73B5, (q15_t)0x36BA, - (q15_t)0x70E2, (q15_t)0x3C56, (q15_t)0x6DCA, (q15_t)0x41CE, - (q15_t)0x6A6D, (q15_t)0x471C, (q15_t)0x66CF, (q15_t)0x4C3F, - (q15_t)0x62F2, (q15_t)0x5133, (q15_t)0x5ED7, (q15_t)0x55F5, - (q15_t)0x5A82, (q15_t)0x5A82, (q15_t)0x55F5, (q15_t)0x5ED7, - (q15_t)0x5133, (q15_t)0x62F2, (q15_t)0x4C3F, (q15_t)0x66CF, - (q15_t)0x471C, (q15_t)0x6A6D, (q15_t)0x41CE, (q15_t)0x6DCA, - (q15_t)0x3C56, (q15_t)0x70E2, (q15_t)0x36BA, (q15_t)0x73B5, - (q15_t)0x30FB, (q15_t)0x7641, (q15_t)0x2B1F, (q15_t)0x7884, - (q15_t)0x2528, (q15_t)0x7A7D, (q15_t)0x1F19, (q15_t)0x7C29, - (q15_t)0x18F8, (q15_t)0x7D8A, (q15_t)0x12C8, (q15_t)0x7E9D, - (q15_t)0x0C8B, (q15_t)0x7F62, (q15_t)0x0647, (q15_t)0x7FD8, - (q15_t)0x0000, (q15_t)0x7FFF, (q15_t)0xF9B8, (q15_t)0x7FD8, - (q15_t)0xF374, (q15_t)0x7F62, (q15_t)0xED37, (q15_t)0x7E9D, - (q15_t)0xE707, (q15_t)0x7D8A, (q15_t)0xE0E6, (q15_t)0x7C29, - (q15_t)0xDAD7, (q15_t)0x7A7D, (q15_t)0xD4E0, (q15_t)0x7884, - (q15_t)0xCF04, (q15_t)0x7641, (q15_t)0xC945, (q15_t)0x73B5, - (q15_t)0xC3A9, (q15_t)0x70E2, (q15_t)0xBE31, (q15_t)0x6DCA, - (q15_t)0xB8E3, (q15_t)0x6A6D, (q15_t)0xB3C0, (q15_t)0x66CF, - (q15_t)0xAECC, (q15_t)0x62F2, (q15_t)0xAA0A, (q15_t)0x5ED7, - (q15_t)0xA57D, (q15_t)0x5A82, (q15_t)0xA128, (q15_t)0x55F5, - (q15_t)0x9D0D, (q15_t)0x5133, (q15_t)0x9930, (q15_t)0x4C3F, - (q15_t)0x9592, (q15_t)0x471C, (q15_t)0x9235, (q15_t)0x41CE, - (q15_t)0x8F1D, (q15_t)0x3C56, (q15_t)0x8C4A, (q15_t)0x36BA, - (q15_t)0x89BE, (q15_t)0x30FB, (q15_t)0x877B, (q15_t)0x2B1F, - (q15_t)0x8582, (q15_t)0x2528, (q15_t)0x83D6, (q15_t)0x1F19, - (q15_t)0x8275, (q15_t)0x18F8, (q15_t)0x8162, (q15_t)0x12C8, - (q15_t)0x809D, (q15_t)0x0C8B, (q15_t)0x8027, (q15_t)0x0647, - (q15_t)0x8000, (q15_t)0x0000, (q15_t)0x8027, (q15_t)0xF9B8, - (q15_t)0x809D, (q15_t)0xF374, (q15_t)0x8162, (q15_t)0xED37, - (q15_t)0x8275, (q15_t)0xE707, (q15_t)0x83D6, (q15_t)0xE0E6, - (q15_t)0x8582, (q15_t)0xDAD7, (q15_t)0x877B, (q15_t)0xD4E0, - (q15_t)0x89BE, (q15_t)0xCF04, (q15_t)0x8C4A, (q15_t)0xC945, - (q15_t)0x8F1D, (q15_t)0xC3A9, (q15_t)0x9235, (q15_t)0xBE31, - (q15_t)0x9592, (q15_t)0xB8E3, (q15_t)0x9930, (q15_t)0xB3C0, - (q15_t)0x9D0D, (q15_t)0xAECC, (q15_t)0xA128, (q15_t)0xAA0A, - (q15_t)0xA57D, (q15_t)0xA57D, (q15_t)0xAA0A, (q15_t)0xA128, - (q15_t)0xAECC, (q15_t)0x9D0D, (q15_t)0xB3C0, (q15_t)0x9930, - (q15_t)0xB8E3, (q15_t)0x9592, (q15_t)0xBE31, (q15_t)0x9235, - (q15_t)0xC3A9, (q15_t)0x8F1D, (q15_t)0xC945, (q15_t)0x8C4A, - (q15_t)0xCF04, (q15_t)0x89BE, (q15_t)0xD4E0, (q15_t)0x877B, - (q15_t)0xDAD7, (q15_t)0x8582, (q15_t)0xE0E6, (q15_t)0x83D6, - (q15_t)0xE707, (q15_t)0x8275, (q15_t)0xED37, (q15_t)0x8162, - (q15_t)0xF374, (q15_t)0x809D, (q15_t)0xF9B8, (q15_t)0x8027 -}; + (q15_t)0x7FFF, (q15_t)0x0000, (q15_t)0x7FD8, (q15_t)0x0647, (q15_t)0x7F62, + (q15_t)0x0C8B, (q15_t)0x7E9D, (q15_t)0x12C8, (q15_t)0x7D8A, (q15_t)0x18F8, + (q15_t)0x7C29, (q15_t)0x1F19, (q15_t)0x7A7D, (q15_t)0x2528, (q15_t)0x7884, + (q15_t)0x2B1F, (q15_t)0x7641, (q15_t)0x30FB, (q15_t)0x73B5, (q15_t)0x36BA, + (q15_t)0x70E2, (q15_t)0x3C56, (q15_t)0x6DCA, (q15_t)0x41CE, (q15_t)0x6A6D, + (q15_t)0x471C, (q15_t)0x66CF, (q15_t)0x4C3F, (q15_t)0x62F2, (q15_t)0x5133, + (q15_t)0x5ED7, (q15_t)0x55F5, (q15_t)0x5A82, (q15_t)0x5A82, (q15_t)0x55F5, + (q15_t)0x5ED7, (q15_t)0x5133, (q15_t)0x62F2, (q15_t)0x4C3F, (q15_t)0x66CF, + (q15_t)0x471C, (q15_t)0x6A6D, (q15_t)0x41CE, (q15_t)0x6DCA, (q15_t)0x3C56, + (q15_t)0x70E2, (q15_t)0x36BA, (q15_t)0x73B5, (q15_t)0x30FB, (q15_t)0x7641, + (q15_t)0x2B1F, (q15_t)0x7884, (q15_t)0x2528, (q15_t)0x7A7D, (q15_t)0x1F19, + (q15_t)0x7C29, (q15_t)0x18F8, (q15_t)0x7D8A, (q15_t)0x12C8, (q15_t)0x7E9D, + (q15_t)0x0C8B, (q15_t)0x7F62, (q15_t)0x0647, (q15_t)0x7FD8, (q15_t)0x0000, + (q15_t)0x7FFF, (q15_t)0xF9B8, (q15_t)0x7FD8, (q15_t)0xF374, (q15_t)0x7F62, + (q15_t)0xED37, (q15_t)0x7E9D, (q15_t)0xE707, (q15_t)0x7D8A, (q15_t)0xE0E6, + (q15_t)0x7C29, (q15_t)0xDAD7, (q15_t)0x7A7D, (q15_t)0xD4E0, (q15_t)0x7884, + (q15_t)0xCF04, (q15_t)0x7641, (q15_t)0xC945, (q15_t)0x73B5, (q15_t)0xC3A9, + (q15_t)0x70E2, (q15_t)0xBE31, (q15_t)0x6DCA, (q15_t)0xB8E3, (q15_t)0x6A6D, + (q15_t)0xB3C0, (q15_t)0x66CF, (q15_t)0xAECC, (q15_t)0x62F2, (q15_t)0xAA0A, + (q15_t)0x5ED7, (q15_t)0xA57D, (q15_t)0x5A82, (q15_t)0xA128, (q15_t)0x55F5, + (q15_t)0x9D0D, (q15_t)0x5133, (q15_t)0x9930, (q15_t)0x4C3F, (q15_t)0x9592, + (q15_t)0x471C, (q15_t)0x9235, (q15_t)0x41CE, (q15_t)0x8F1D, (q15_t)0x3C56, + (q15_t)0x8C4A, (q15_t)0x36BA, (q15_t)0x89BE, (q15_t)0x30FB, (q15_t)0x877B, + (q15_t)0x2B1F, (q15_t)0x8582, (q15_t)0x2528, (q15_t)0x83D6, (q15_t)0x1F19, + (q15_t)0x8275, (q15_t)0x18F8, (q15_t)0x8162, (q15_t)0x12C8, (q15_t)0x809D, + (q15_t)0x0C8B, (q15_t)0x8027, (q15_t)0x0647, (q15_t)0x8000, (q15_t)0x0000, + (q15_t)0x8027, (q15_t)0xF9B8, (q15_t)0x809D, (q15_t)0xF374, (q15_t)0x8162, + (q15_t)0xED37, (q15_t)0x8275, (q15_t)0xE707, (q15_t)0x83D6, (q15_t)0xE0E6, + (q15_t)0x8582, (q15_t)0xDAD7, (q15_t)0x877B, (q15_t)0xD4E0, (q15_t)0x89BE, + (q15_t)0xCF04, (q15_t)0x8C4A, (q15_t)0xC945, (q15_t)0x8F1D, (q15_t)0xC3A9, + (q15_t)0x9235, (q15_t)0xBE31, (q15_t)0x9592, (q15_t)0xB8E3, (q15_t)0x9930, + (q15_t)0xB3C0, (q15_t)0x9D0D, (q15_t)0xAECC, (q15_t)0xA128, (q15_t)0xAA0A, + (q15_t)0xA57D, (q15_t)0xA57D, (q15_t)0xAA0A, (q15_t)0xA128, (q15_t)0xAECC, + (q15_t)0x9D0D, (q15_t)0xB3C0, (q15_t)0x9930, (q15_t)0xB8E3, (q15_t)0x9592, + (q15_t)0xBE31, (q15_t)0x9235, (q15_t)0xC3A9, (q15_t)0x8F1D, (q15_t)0xC945, + (q15_t)0x8C4A, (q15_t)0xCF04, (q15_t)0x89BE, (q15_t)0xD4E0, (q15_t)0x877B, + (q15_t)0xDAD7, (q15_t)0x8582, (q15_t)0xE0E6, (q15_t)0x83D6, (q15_t)0xE707, + (q15_t)0x8275, (q15_t)0xED37, (q15_t)0x8162, (q15_t)0xF374, (q15_t)0x809D, + (q15_t)0xF9B8, (q15_t)0x8027}; /** @par @@ -13002,106 +6996,86 @@ const q15_t twiddleCoef_128_q15[192] = { Cos and Sin values are interleaved fashion @par Convert Floating point to q15(Fixed point 1.15): - round(twiddleCoefq15(i) * pow(2, 15)) + round(twiddleCoefq15(i) * pow(2, 15)) */ const q15_t twiddleCoef_256_q15[384] = { - (q15_t)0x7FFF, (q15_t)0x0000, (q15_t)0x7FF6, (q15_t)0x0324, - (q15_t)0x7FD8, (q15_t)0x0647, (q15_t)0x7FA7, (q15_t)0x096A, - (q15_t)0x7F62, (q15_t)0x0C8B, (q15_t)0x7F09, (q15_t)0x0FAB, - (q15_t)0x7E9D, (q15_t)0x12C8, (q15_t)0x7E1D, (q15_t)0x15E2, - (q15_t)0x7D8A, (q15_t)0x18F8, (q15_t)0x7CE3, (q15_t)0x1C0B, - (q15_t)0x7C29, (q15_t)0x1F19, (q15_t)0x7B5D, (q15_t)0x2223, - (q15_t)0x7A7D, (q15_t)0x2528, (q15_t)0x798A, (q15_t)0x2826, - (q15_t)0x7884, (q15_t)0x2B1F, (q15_t)0x776C, (q15_t)0x2E11, - (q15_t)0x7641, (q15_t)0x30FB, (q15_t)0x7504, (q15_t)0x33DE, - (q15_t)0x73B5, (q15_t)0x36BA, (q15_t)0x7255, (q15_t)0x398C, - (q15_t)0x70E2, (q15_t)0x3C56, (q15_t)0x6F5F, (q15_t)0x3F17, - (q15_t)0x6DCA, (q15_t)0x41CE, (q15_t)0x6C24, (q15_t)0x447A, - (q15_t)0x6A6D, (q15_t)0x471C, (q15_t)0x68A6, (q15_t)0x49B4, - (q15_t)0x66CF, (q15_t)0x4C3F, (q15_t)0x64E8, (q15_t)0x4EBF, - (q15_t)0x62F2, (q15_t)0x5133, (q15_t)0x60EC, (q15_t)0x539B, - (q15_t)0x5ED7, (q15_t)0x55F5, (q15_t)0x5CB4, (q15_t)0x5842, - (q15_t)0x5A82, (q15_t)0x5A82, (q15_t)0x5842, (q15_t)0x5CB4, - (q15_t)0x55F5, (q15_t)0x5ED7, (q15_t)0x539B, (q15_t)0x60EC, - (q15_t)0x5133, (q15_t)0x62F2, (q15_t)0x4EBF, (q15_t)0x64E8, - (q15_t)0x4C3F, (q15_t)0x66CF, (q15_t)0x49B4, (q15_t)0x68A6, - (q15_t)0x471C, (q15_t)0x6A6D, (q15_t)0x447A, (q15_t)0x6C24, - (q15_t)0x41CE, (q15_t)0x6DCA, (q15_t)0x3F17, (q15_t)0x6F5F, - (q15_t)0x3C56, (q15_t)0x70E2, (q15_t)0x398C, (q15_t)0x7255, - (q15_t)0x36BA, (q15_t)0x73B5, (q15_t)0x33DE, (q15_t)0x7504, - (q15_t)0x30FB, (q15_t)0x7641, (q15_t)0x2E11, (q15_t)0x776C, - (q15_t)0x2B1F, (q15_t)0x7884, (q15_t)0x2826, (q15_t)0x798A, - (q15_t)0x2528, (q15_t)0x7A7D, (q15_t)0x2223, (q15_t)0x7B5D, - (q15_t)0x1F19, (q15_t)0x7C29, (q15_t)0x1C0B, (q15_t)0x7CE3, - (q15_t)0x18F8, (q15_t)0x7D8A, (q15_t)0x15E2, (q15_t)0x7E1D, - (q15_t)0x12C8, (q15_t)0x7E9D, (q15_t)0x0FAB, (q15_t)0x7F09, - (q15_t)0x0C8B, (q15_t)0x7F62, (q15_t)0x096A, (q15_t)0x7FA7, - (q15_t)0x0647, (q15_t)0x7FD8, (q15_t)0x0324, (q15_t)0x7FF6, - (q15_t)0x0000, (q15_t)0x7FFF, (q15_t)0xFCDB, (q15_t)0x7FF6, - (q15_t)0xF9B8, (q15_t)0x7FD8, (q15_t)0xF695, (q15_t)0x7FA7, - (q15_t)0xF374, (q15_t)0x7F62, (q15_t)0xF054, (q15_t)0x7F09, - (q15_t)0xED37, (q15_t)0x7E9D, (q15_t)0xEA1D, (q15_t)0x7E1D, - (q15_t)0xE707, (q15_t)0x7D8A, (q15_t)0xE3F4, (q15_t)0x7CE3, - (q15_t)0xE0E6, (q15_t)0x7C29, (q15_t)0xDDDC, (q15_t)0x7B5D, - (q15_t)0xDAD7, (q15_t)0x7A7D, (q15_t)0xD7D9, (q15_t)0x798A, - (q15_t)0xD4E0, (q15_t)0x7884, (q15_t)0xD1EE, (q15_t)0x776C, - (q15_t)0xCF04, (q15_t)0x7641, (q15_t)0xCC21, (q15_t)0x7504, - (q15_t)0xC945, (q15_t)0x73B5, (q15_t)0xC673, (q15_t)0x7255, - (q15_t)0xC3A9, (q15_t)0x70E2, (q15_t)0xC0E8, (q15_t)0x6F5F, - (q15_t)0xBE31, (q15_t)0x6DCA, (q15_t)0xBB85, (q15_t)0x6C24, - (q15_t)0xB8E3, (q15_t)0x6A6D, (q15_t)0xB64B, (q15_t)0x68A6, - (q15_t)0xB3C0, (q15_t)0x66CF, (q15_t)0xB140, (q15_t)0x64E8, - (q15_t)0xAECC, (q15_t)0x62F2, (q15_t)0xAC64, (q15_t)0x60EC, - (q15_t)0xAA0A, (q15_t)0x5ED7, (q15_t)0xA7BD, (q15_t)0x5CB4, - (q15_t)0xA57D, (q15_t)0x5A82, (q15_t)0xA34B, (q15_t)0x5842, - (q15_t)0xA128, (q15_t)0x55F5, (q15_t)0x9F13, (q15_t)0x539B, - (q15_t)0x9D0D, (q15_t)0x5133, (q15_t)0x9B17, (q15_t)0x4EBF, - (q15_t)0x9930, (q15_t)0x4C3F, (q15_t)0x9759, (q15_t)0x49B4, - (q15_t)0x9592, (q15_t)0x471C, (q15_t)0x93DB, (q15_t)0x447A, - (q15_t)0x9235, (q15_t)0x41CE, (q15_t)0x90A0, (q15_t)0x3F17, - (q15_t)0x8F1D, (q15_t)0x3C56, (q15_t)0x8DAA, (q15_t)0x398C, - (q15_t)0x8C4A, (q15_t)0x36BA, (q15_t)0x8AFB, (q15_t)0x33DE, - (q15_t)0x89BE, (q15_t)0x30FB, (q15_t)0x8893, (q15_t)0x2E11, - (q15_t)0x877B, (q15_t)0x2B1F, (q15_t)0x8675, (q15_t)0x2826, - (q15_t)0x8582, (q15_t)0x2528, (q15_t)0x84A2, (q15_t)0x2223, - (q15_t)0x83D6, (q15_t)0x1F19, (q15_t)0x831C, (q15_t)0x1C0B, - (q15_t)0x8275, (q15_t)0x18F8, (q15_t)0x81E2, (q15_t)0x15E2, - (q15_t)0x8162, (q15_t)0x12C8, (q15_t)0x80F6, (q15_t)0x0FAB, - (q15_t)0x809D, (q15_t)0x0C8B, (q15_t)0x8058, (q15_t)0x096A, - (q15_t)0x8027, (q15_t)0x0647, (q15_t)0x8009, (q15_t)0x0324, - (q15_t)0x8000, (q15_t)0x0000, (q15_t)0x8009, (q15_t)0xFCDB, - (q15_t)0x8027, (q15_t)0xF9B8, (q15_t)0x8058, (q15_t)0xF695, - (q15_t)0x809D, (q15_t)0xF374, (q15_t)0x80F6, (q15_t)0xF054, - (q15_t)0x8162, (q15_t)0xED37, (q15_t)0x81E2, (q15_t)0xEA1D, - (q15_t)0x8275, (q15_t)0xE707, (q15_t)0x831C, (q15_t)0xE3F4, - (q15_t)0x83D6, (q15_t)0xE0E6, (q15_t)0x84A2, (q15_t)0xDDDC, - (q15_t)0x8582, (q15_t)0xDAD7, (q15_t)0x8675, (q15_t)0xD7D9, - (q15_t)0x877B, (q15_t)0xD4E0, (q15_t)0x8893, (q15_t)0xD1EE, - (q15_t)0x89BE, (q15_t)0xCF04, (q15_t)0x8AFB, (q15_t)0xCC21, - (q15_t)0x8C4A, (q15_t)0xC945, (q15_t)0x8DAA, (q15_t)0xC673, - (q15_t)0x8F1D, (q15_t)0xC3A9, (q15_t)0x90A0, (q15_t)0xC0E8, - (q15_t)0x9235, (q15_t)0xBE31, (q15_t)0x93DB, (q15_t)0xBB85, - (q15_t)0x9592, (q15_t)0xB8E3, (q15_t)0x9759, (q15_t)0xB64B, - (q15_t)0x9930, (q15_t)0xB3C0, (q15_t)0x9B17, (q15_t)0xB140, - (q15_t)0x9D0D, (q15_t)0xAECC, (q15_t)0x9F13, (q15_t)0xAC64, - (q15_t)0xA128, (q15_t)0xAA0A, (q15_t)0xA34B, (q15_t)0xA7BD, - (q15_t)0xA57D, (q15_t)0xA57D, (q15_t)0xA7BD, (q15_t)0xA34B, - (q15_t)0xAA0A, (q15_t)0xA128, (q15_t)0xAC64, (q15_t)0x9F13, - (q15_t)0xAECC, (q15_t)0x9D0D, (q15_t)0xB140, (q15_t)0x9B17, - (q15_t)0xB3C0, (q15_t)0x9930, (q15_t)0xB64B, (q15_t)0x9759, - (q15_t)0xB8E3, (q15_t)0x9592, (q15_t)0xBB85, (q15_t)0x93DB, - (q15_t)0xBE31, (q15_t)0x9235, (q15_t)0xC0E8, (q15_t)0x90A0, - (q15_t)0xC3A9, (q15_t)0x8F1D, (q15_t)0xC673, (q15_t)0x8DAA, - (q15_t)0xC945, (q15_t)0x8C4A, (q15_t)0xCC21, (q15_t)0x8AFB, - (q15_t)0xCF04, (q15_t)0x89BE, (q15_t)0xD1EE, (q15_t)0x8893, - (q15_t)0xD4E0, (q15_t)0x877B, (q15_t)0xD7D9, (q15_t)0x8675, - (q15_t)0xDAD7, (q15_t)0x8582, (q15_t)0xDDDC, (q15_t)0x84A2, - (q15_t)0xE0E6, (q15_t)0x83D6, (q15_t)0xE3F4, (q15_t)0x831C, - (q15_t)0xE707, (q15_t)0x8275, (q15_t)0xEA1D, (q15_t)0x81E2, - (q15_t)0xED37, (q15_t)0x8162, (q15_t)0xF054, (q15_t)0x80F6, - (q15_t)0xF374, (q15_t)0x809D, (q15_t)0xF695, (q15_t)0x8058, - (q15_t)0xF9B8, (q15_t)0x8027, (q15_t)0xFCDB, (q15_t)0x8009 -}; + (q15_t)0x7FFF, (q15_t)0x0000, (q15_t)0x7FF6, (q15_t)0x0324, (q15_t)0x7FD8, + (q15_t)0x0647, (q15_t)0x7FA7, (q15_t)0x096A, (q15_t)0x7F62, (q15_t)0x0C8B, + (q15_t)0x7F09, (q15_t)0x0FAB, (q15_t)0x7E9D, (q15_t)0x12C8, (q15_t)0x7E1D, + (q15_t)0x15E2, (q15_t)0x7D8A, (q15_t)0x18F8, (q15_t)0x7CE3, (q15_t)0x1C0B, + (q15_t)0x7C29, (q15_t)0x1F19, (q15_t)0x7B5D, (q15_t)0x2223, (q15_t)0x7A7D, + (q15_t)0x2528, (q15_t)0x798A, (q15_t)0x2826, (q15_t)0x7884, (q15_t)0x2B1F, + (q15_t)0x776C, (q15_t)0x2E11, (q15_t)0x7641, (q15_t)0x30FB, (q15_t)0x7504, + (q15_t)0x33DE, (q15_t)0x73B5, (q15_t)0x36BA, (q15_t)0x7255, (q15_t)0x398C, + (q15_t)0x70E2, (q15_t)0x3C56, (q15_t)0x6F5F, (q15_t)0x3F17, (q15_t)0x6DCA, + (q15_t)0x41CE, (q15_t)0x6C24, (q15_t)0x447A, (q15_t)0x6A6D, (q15_t)0x471C, + (q15_t)0x68A6, (q15_t)0x49B4, (q15_t)0x66CF, (q15_t)0x4C3F, (q15_t)0x64E8, + (q15_t)0x4EBF, (q15_t)0x62F2, (q15_t)0x5133, (q15_t)0x60EC, (q15_t)0x539B, + (q15_t)0x5ED7, (q15_t)0x55F5, (q15_t)0x5CB4, (q15_t)0x5842, (q15_t)0x5A82, + (q15_t)0x5A82, (q15_t)0x5842, (q15_t)0x5CB4, (q15_t)0x55F5, (q15_t)0x5ED7, + (q15_t)0x539B, (q15_t)0x60EC, (q15_t)0x5133, (q15_t)0x62F2, (q15_t)0x4EBF, + (q15_t)0x64E8, (q15_t)0x4C3F, (q15_t)0x66CF, (q15_t)0x49B4, (q15_t)0x68A6, + (q15_t)0x471C, (q15_t)0x6A6D, (q15_t)0x447A, (q15_t)0x6C24, (q15_t)0x41CE, + (q15_t)0x6DCA, (q15_t)0x3F17, (q15_t)0x6F5F, (q15_t)0x3C56, (q15_t)0x70E2, + (q15_t)0x398C, (q15_t)0x7255, (q15_t)0x36BA, (q15_t)0x73B5, (q15_t)0x33DE, + (q15_t)0x7504, (q15_t)0x30FB, (q15_t)0x7641, (q15_t)0x2E11, (q15_t)0x776C, + (q15_t)0x2B1F, (q15_t)0x7884, (q15_t)0x2826, (q15_t)0x798A, (q15_t)0x2528, + (q15_t)0x7A7D, (q15_t)0x2223, (q15_t)0x7B5D, (q15_t)0x1F19, (q15_t)0x7C29, + (q15_t)0x1C0B, (q15_t)0x7CE3, (q15_t)0x18F8, (q15_t)0x7D8A, (q15_t)0x15E2, + (q15_t)0x7E1D, (q15_t)0x12C8, (q15_t)0x7E9D, (q15_t)0x0FAB, (q15_t)0x7F09, + (q15_t)0x0C8B, (q15_t)0x7F62, (q15_t)0x096A, (q15_t)0x7FA7, (q15_t)0x0647, + (q15_t)0x7FD8, (q15_t)0x0324, (q15_t)0x7FF6, (q15_t)0x0000, (q15_t)0x7FFF, + (q15_t)0xFCDB, (q15_t)0x7FF6, (q15_t)0xF9B8, (q15_t)0x7FD8, (q15_t)0xF695, + (q15_t)0x7FA7, (q15_t)0xF374, (q15_t)0x7F62, (q15_t)0xF054, (q15_t)0x7F09, + (q15_t)0xED37, (q15_t)0x7E9D, (q15_t)0xEA1D, (q15_t)0x7E1D, (q15_t)0xE707, + (q15_t)0x7D8A, (q15_t)0xE3F4, (q15_t)0x7CE3, (q15_t)0xE0E6, (q15_t)0x7C29, + (q15_t)0xDDDC, (q15_t)0x7B5D, (q15_t)0xDAD7, (q15_t)0x7A7D, (q15_t)0xD7D9, + (q15_t)0x798A, (q15_t)0xD4E0, (q15_t)0x7884, (q15_t)0xD1EE, (q15_t)0x776C, + (q15_t)0xCF04, (q15_t)0x7641, (q15_t)0xCC21, (q15_t)0x7504, (q15_t)0xC945, + (q15_t)0x73B5, (q15_t)0xC673, (q15_t)0x7255, (q15_t)0xC3A9, (q15_t)0x70E2, + (q15_t)0xC0E8, (q15_t)0x6F5F, (q15_t)0xBE31, (q15_t)0x6DCA, (q15_t)0xBB85, + (q15_t)0x6C24, (q15_t)0xB8E3, (q15_t)0x6A6D, (q15_t)0xB64B, (q15_t)0x68A6, + (q15_t)0xB3C0, (q15_t)0x66CF, (q15_t)0xB140, (q15_t)0x64E8, (q15_t)0xAECC, + (q15_t)0x62F2, (q15_t)0xAC64, (q15_t)0x60EC, (q15_t)0xAA0A, (q15_t)0x5ED7, + (q15_t)0xA7BD, (q15_t)0x5CB4, (q15_t)0xA57D, (q15_t)0x5A82, (q15_t)0xA34B, + (q15_t)0x5842, (q15_t)0xA128, (q15_t)0x55F5, (q15_t)0x9F13, (q15_t)0x539B, + (q15_t)0x9D0D, (q15_t)0x5133, (q15_t)0x9B17, (q15_t)0x4EBF, (q15_t)0x9930, + (q15_t)0x4C3F, (q15_t)0x9759, (q15_t)0x49B4, (q15_t)0x9592, (q15_t)0x471C, + (q15_t)0x93DB, (q15_t)0x447A, (q15_t)0x9235, (q15_t)0x41CE, (q15_t)0x90A0, + (q15_t)0x3F17, (q15_t)0x8F1D, (q15_t)0x3C56, (q15_t)0x8DAA, (q15_t)0x398C, + (q15_t)0x8C4A, (q15_t)0x36BA, (q15_t)0x8AFB, (q15_t)0x33DE, (q15_t)0x89BE, + (q15_t)0x30FB, (q15_t)0x8893, (q15_t)0x2E11, (q15_t)0x877B, (q15_t)0x2B1F, + (q15_t)0x8675, (q15_t)0x2826, (q15_t)0x8582, (q15_t)0x2528, (q15_t)0x84A2, + (q15_t)0x2223, (q15_t)0x83D6, (q15_t)0x1F19, (q15_t)0x831C, (q15_t)0x1C0B, + (q15_t)0x8275, (q15_t)0x18F8, (q15_t)0x81E2, (q15_t)0x15E2, (q15_t)0x8162, + (q15_t)0x12C8, (q15_t)0x80F6, (q15_t)0x0FAB, (q15_t)0x809D, (q15_t)0x0C8B, + (q15_t)0x8058, (q15_t)0x096A, (q15_t)0x8027, (q15_t)0x0647, (q15_t)0x8009, + (q15_t)0x0324, (q15_t)0x8000, (q15_t)0x0000, (q15_t)0x8009, (q15_t)0xFCDB, + (q15_t)0x8027, (q15_t)0xF9B8, (q15_t)0x8058, (q15_t)0xF695, (q15_t)0x809D, + (q15_t)0xF374, (q15_t)0x80F6, (q15_t)0xF054, (q15_t)0x8162, (q15_t)0xED37, + (q15_t)0x81E2, (q15_t)0xEA1D, (q15_t)0x8275, (q15_t)0xE707, (q15_t)0x831C, + (q15_t)0xE3F4, (q15_t)0x83D6, (q15_t)0xE0E6, (q15_t)0x84A2, (q15_t)0xDDDC, + (q15_t)0x8582, (q15_t)0xDAD7, (q15_t)0x8675, (q15_t)0xD7D9, (q15_t)0x877B, + (q15_t)0xD4E0, (q15_t)0x8893, (q15_t)0xD1EE, (q15_t)0x89BE, (q15_t)0xCF04, + (q15_t)0x8AFB, (q15_t)0xCC21, (q15_t)0x8C4A, (q15_t)0xC945, (q15_t)0x8DAA, + (q15_t)0xC673, (q15_t)0x8F1D, (q15_t)0xC3A9, (q15_t)0x90A0, (q15_t)0xC0E8, + (q15_t)0x9235, (q15_t)0xBE31, (q15_t)0x93DB, (q15_t)0xBB85, (q15_t)0x9592, + (q15_t)0xB8E3, (q15_t)0x9759, (q15_t)0xB64B, (q15_t)0x9930, (q15_t)0xB3C0, + (q15_t)0x9B17, (q15_t)0xB140, (q15_t)0x9D0D, (q15_t)0xAECC, (q15_t)0x9F13, + (q15_t)0xAC64, (q15_t)0xA128, (q15_t)0xAA0A, (q15_t)0xA34B, (q15_t)0xA7BD, + (q15_t)0xA57D, (q15_t)0xA57D, (q15_t)0xA7BD, (q15_t)0xA34B, (q15_t)0xAA0A, + (q15_t)0xA128, (q15_t)0xAC64, (q15_t)0x9F13, (q15_t)0xAECC, (q15_t)0x9D0D, + (q15_t)0xB140, (q15_t)0x9B17, (q15_t)0xB3C0, (q15_t)0x9930, (q15_t)0xB64B, + (q15_t)0x9759, (q15_t)0xB8E3, (q15_t)0x9592, (q15_t)0xBB85, (q15_t)0x93DB, + (q15_t)0xBE31, (q15_t)0x9235, (q15_t)0xC0E8, (q15_t)0x90A0, (q15_t)0xC3A9, + (q15_t)0x8F1D, (q15_t)0xC673, (q15_t)0x8DAA, (q15_t)0xC945, (q15_t)0x8C4A, + (q15_t)0xCC21, (q15_t)0x8AFB, (q15_t)0xCF04, (q15_t)0x89BE, (q15_t)0xD1EE, + (q15_t)0x8893, (q15_t)0xD4E0, (q15_t)0x877B, (q15_t)0xD7D9, (q15_t)0x8675, + (q15_t)0xDAD7, (q15_t)0x8582, (q15_t)0xDDDC, (q15_t)0x84A2, (q15_t)0xE0E6, + (q15_t)0x83D6, (q15_t)0xE3F4, (q15_t)0x831C, (q15_t)0xE707, (q15_t)0x8275, + (q15_t)0xEA1D, (q15_t)0x81E2, (q15_t)0xED37, (q15_t)0x8162, (q15_t)0xF054, + (q15_t)0x80F6, (q15_t)0xF374, (q15_t)0x809D, (q15_t)0xF695, (q15_t)0x8058, + (q15_t)0xF9B8, (q15_t)0x8027, (q15_t)0xFCDB, (q15_t)0x8009}; /** @par @@ -13118,202 +7092,163 @@ const q15_t twiddleCoef_256_q15[384] = { Cos and Sin values are interleaved fashion @par Convert Floating point to q15(Fixed point 1.15): - round(twiddleCoefq15(i) * pow(2, 15)) + round(twiddleCoefq15(i) * pow(2, 15)) */ const q15_t twiddleCoef_512_q15[768] = { - (q15_t)0x7FFF, (q15_t)0x0000, (q15_t)0x7FFD, (q15_t)0x0192, - (q15_t)0x7FF6, (q15_t)0x0324, (q15_t)0x7FE9, (q15_t)0x04B6, - (q15_t)0x7FD8, (q15_t)0x0647, (q15_t)0x7FC2, (q15_t)0x07D9, - (q15_t)0x7FA7, (q15_t)0x096A, (q15_t)0x7F87, (q15_t)0x0AFB, - (q15_t)0x7F62, (q15_t)0x0C8B, (q15_t)0x7F38, (q15_t)0x0E1B, - (q15_t)0x7F09, (q15_t)0x0FAB, (q15_t)0x7ED5, (q15_t)0x1139, - (q15_t)0x7E9D, (q15_t)0x12C8, (q15_t)0x7E5F, (q15_t)0x1455, - (q15_t)0x7E1D, (q15_t)0x15E2, (q15_t)0x7DD6, (q15_t)0x176D, - (q15_t)0x7D8A, (q15_t)0x18F8, (q15_t)0x7D39, (q15_t)0x1A82, - (q15_t)0x7CE3, (q15_t)0x1C0B, (q15_t)0x7C89, (q15_t)0x1D93, - (q15_t)0x7C29, (q15_t)0x1F19, (q15_t)0x7BC5, (q15_t)0x209F, - (q15_t)0x7B5D, (q15_t)0x2223, (q15_t)0x7AEF, (q15_t)0x23A6, - (q15_t)0x7A7D, (q15_t)0x2528, (q15_t)0x7A05, (q15_t)0x26A8, - (q15_t)0x798A, (q15_t)0x2826, (q15_t)0x7909, (q15_t)0x29A3, - (q15_t)0x7884, (q15_t)0x2B1F, (q15_t)0x77FA, (q15_t)0x2C98, - (q15_t)0x776C, (q15_t)0x2E11, (q15_t)0x76D9, (q15_t)0x2F87, - (q15_t)0x7641, (q15_t)0x30FB, (q15_t)0x75A5, (q15_t)0x326E, - (q15_t)0x7504, (q15_t)0x33DE, (q15_t)0x745F, (q15_t)0x354D, - (q15_t)0x73B5, (q15_t)0x36BA, (q15_t)0x7307, (q15_t)0x3824, - (q15_t)0x7255, (q15_t)0x398C, (q15_t)0x719E, (q15_t)0x3AF2, - (q15_t)0x70E2, (q15_t)0x3C56, (q15_t)0x7023, (q15_t)0x3DB8, - (q15_t)0x6F5F, (q15_t)0x3F17, (q15_t)0x6E96, (q15_t)0x4073, - (q15_t)0x6DCA, (q15_t)0x41CE, (q15_t)0x6CF9, (q15_t)0x4325, - (q15_t)0x6C24, (q15_t)0x447A, (q15_t)0x6B4A, (q15_t)0x45CD, - (q15_t)0x6A6D, (q15_t)0x471C, (q15_t)0x698C, (q15_t)0x4869, - (q15_t)0x68A6, (q15_t)0x49B4, (q15_t)0x67BD, (q15_t)0x4AFB, - (q15_t)0x66CF, (q15_t)0x4C3F, (q15_t)0x65DD, (q15_t)0x4D81, - (q15_t)0x64E8, (q15_t)0x4EBF, (q15_t)0x63EF, (q15_t)0x4FFB, - (q15_t)0x62F2, (q15_t)0x5133, (q15_t)0x61F1, (q15_t)0x5269, - (q15_t)0x60EC, (q15_t)0x539B, (q15_t)0x5FE3, (q15_t)0x54CA, - (q15_t)0x5ED7, (q15_t)0x55F5, (q15_t)0x5DC7, (q15_t)0x571D, - (q15_t)0x5CB4, (q15_t)0x5842, (q15_t)0x5B9D, (q15_t)0x5964, - (q15_t)0x5A82, (q15_t)0x5A82, (q15_t)0x5964, (q15_t)0x5B9D, - (q15_t)0x5842, (q15_t)0x5CB4, (q15_t)0x571D, (q15_t)0x5DC7, - (q15_t)0x55F5, (q15_t)0x5ED7, (q15_t)0x54CA, (q15_t)0x5FE3, - (q15_t)0x539B, (q15_t)0x60EC, (q15_t)0x5269, (q15_t)0x61F1, - (q15_t)0x5133, (q15_t)0x62F2, (q15_t)0x4FFB, (q15_t)0x63EF, - (q15_t)0x4EBF, (q15_t)0x64E8, (q15_t)0x4D81, (q15_t)0x65DD, - (q15_t)0x4C3F, (q15_t)0x66CF, (q15_t)0x4AFB, (q15_t)0x67BD, - (q15_t)0x49B4, (q15_t)0x68A6, (q15_t)0x4869, (q15_t)0x698C, - (q15_t)0x471C, (q15_t)0x6A6D, (q15_t)0x45CD, (q15_t)0x6B4A, - (q15_t)0x447A, (q15_t)0x6C24, (q15_t)0x4325, (q15_t)0x6CF9, - (q15_t)0x41CE, (q15_t)0x6DCA, (q15_t)0x4073, (q15_t)0x6E96, - (q15_t)0x3F17, (q15_t)0x6F5F, (q15_t)0x3DB8, (q15_t)0x7023, - (q15_t)0x3C56, (q15_t)0x70E2, (q15_t)0x3AF2, (q15_t)0x719E, - (q15_t)0x398C, (q15_t)0x7255, (q15_t)0x3824, (q15_t)0x7307, - (q15_t)0x36BA, (q15_t)0x73B5, (q15_t)0x354D, (q15_t)0x745F, - (q15_t)0x33DE, (q15_t)0x7504, (q15_t)0x326E, (q15_t)0x75A5, - (q15_t)0x30FB, (q15_t)0x7641, (q15_t)0x2F87, (q15_t)0x76D9, - (q15_t)0x2E11, (q15_t)0x776C, (q15_t)0x2C98, (q15_t)0x77FA, - (q15_t)0x2B1F, (q15_t)0x7884, (q15_t)0x29A3, (q15_t)0x7909, - (q15_t)0x2826, (q15_t)0x798A, (q15_t)0x26A8, (q15_t)0x7A05, - (q15_t)0x2528, (q15_t)0x7A7D, (q15_t)0x23A6, (q15_t)0x7AEF, - (q15_t)0x2223, (q15_t)0x7B5D, (q15_t)0x209F, (q15_t)0x7BC5, - (q15_t)0x1F19, (q15_t)0x7C29, (q15_t)0x1D93, (q15_t)0x7C89, - (q15_t)0x1C0B, (q15_t)0x7CE3, (q15_t)0x1A82, (q15_t)0x7D39, - (q15_t)0x18F8, (q15_t)0x7D8A, (q15_t)0x176D, (q15_t)0x7DD6, - (q15_t)0x15E2, (q15_t)0x7E1D, (q15_t)0x1455, (q15_t)0x7E5F, - (q15_t)0x12C8, (q15_t)0x7E9D, (q15_t)0x1139, (q15_t)0x7ED5, - (q15_t)0x0FAB, (q15_t)0x7F09, (q15_t)0x0E1B, (q15_t)0x7F38, - (q15_t)0x0C8B, (q15_t)0x7F62, (q15_t)0x0AFB, (q15_t)0x7F87, - (q15_t)0x096A, (q15_t)0x7FA7, (q15_t)0x07D9, (q15_t)0x7FC2, - (q15_t)0x0647, (q15_t)0x7FD8, (q15_t)0x04B6, (q15_t)0x7FE9, - (q15_t)0x0324, (q15_t)0x7FF6, (q15_t)0x0192, (q15_t)0x7FFD, - (q15_t)0x0000, (q15_t)0x7FFF, (q15_t)0xFE6D, (q15_t)0x7FFD, - (q15_t)0xFCDB, (q15_t)0x7FF6, (q15_t)0xFB49, (q15_t)0x7FE9, - (q15_t)0xF9B8, (q15_t)0x7FD8, (q15_t)0xF826, (q15_t)0x7FC2, - (q15_t)0xF695, (q15_t)0x7FA7, (q15_t)0xF504, (q15_t)0x7F87, - (q15_t)0xF374, (q15_t)0x7F62, (q15_t)0xF1E4, (q15_t)0x7F38, - (q15_t)0xF054, (q15_t)0x7F09, (q15_t)0xEEC6, (q15_t)0x7ED5, - (q15_t)0xED37, (q15_t)0x7E9D, (q15_t)0xEBAA, (q15_t)0x7E5F, - (q15_t)0xEA1D, (q15_t)0x7E1D, (q15_t)0xE892, (q15_t)0x7DD6, - (q15_t)0xE707, (q15_t)0x7D8A, (q15_t)0xE57D, (q15_t)0x7D39, - (q15_t)0xE3F4, (q15_t)0x7CE3, (q15_t)0xE26C, (q15_t)0x7C89, - (q15_t)0xE0E6, (q15_t)0x7C29, (q15_t)0xDF60, (q15_t)0x7BC5, - (q15_t)0xDDDC, (q15_t)0x7B5D, (q15_t)0xDC59, (q15_t)0x7AEF, - (q15_t)0xDAD7, (q15_t)0x7A7D, (q15_t)0xD957, (q15_t)0x7A05, - (q15_t)0xD7D9, (q15_t)0x798A, (q15_t)0xD65C, (q15_t)0x7909, - (q15_t)0xD4E0, (q15_t)0x7884, (q15_t)0xD367, (q15_t)0x77FA, - (q15_t)0xD1EE, (q15_t)0x776C, (q15_t)0xD078, (q15_t)0x76D9, - (q15_t)0xCF04, (q15_t)0x7641, (q15_t)0xCD91, (q15_t)0x75A5, - (q15_t)0xCC21, (q15_t)0x7504, (q15_t)0xCAB2, (q15_t)0x745F, - (q15_t)0xC945, (q15_t)0x73B5, (q15_t)0xC7DB, (q15_t)0x7307, - (q15_t)0xC673, (q15_t)0x7255, (q15_t)0xC50D, (q15_t)0x719E, - (q15_t)0xC3A9, (q15_t)0x70E2, (q15_t)0xC247, (q15_t)0x7023, - (q15_t)0xC0E8, (q15_t)0x6F5F, (q15_t)0xBF8C, (q15_t)0x6E96, - (q15_t)0xBE31, (q15_t)0x6DCA, (q15_t)0xBCDA, (q15_t)0x6CF9, - (q15_t)0xBB85, (q15_t)0x6C24, (q15_t)0xBA32, (q15_t)0x6B4A, - (q15_t)0xB8E3, (q15_t)0x6A6D, (q15_t)0xB796, (q15_t)0x698C, - (q15_t)0xB64B, (q15_t)0x68A6, (q15_t)0xB504, (q15_t)0x67BD, - (q15_t)0xB3C0, (q15_t)0x66CF, (q15_t)0xB27E, (q15_t)0x65DD, - (q15_t)0xB140, (q15_t)0x64E8, (q15_t)0xB004, (q15_t)0x63EF, - (q15_t)0xAECC, (q15_t)0x62F2, (q15_t)0xAD96, (q15_t)0x61F1, - (q15_t)0xAC64, (q15_t)0x60EC, (q15_t)0xAB35, (q15_t)0x5FE3, - (q15_t)0xAA0A, (q15_t)0x5ED7, (q15_t)0xA8E2, (q15_t)0x5DC7, - (q15_t)0xA7BD, (q15_t)0x5CB4, (q15_t)0xA69B, (q15_t)0x5B9D, - (q15_t)0xA57D, (q15_t)0x5A82, (q15_t)0xA462, (q15_t)0x5964, - (q15_t)0xA34B, (q15_t)0x5842, (q15_t)0xA238, (q15_t)0x571D, - (q15_t)0xA128, (q15_t)0x55F5, (q15_t)0xA01C, (q15_t)0x54CA, - (q15_t)0x9F13, (q15_t)0x539B, (q15_t)0x9E0E, (q15_t)0x5269, - (q15_t)0x9D0D, (q15_t)0x5133, (q15_t)0x9C10, (q15_t)0x4FFB, - (q15_t)0x9B17, (q15_t)0x4EBF, (q15_t)0x9A22, (q15_t)0x4D81, - (q15_t)0x9930, (q15_t)0x4C3F, (q15_t)0x9842, (q15_t)0x4AFB, - (q15_t)0x9759, (q15_t)0x49B4, (q15_t)0x9673, (q15_t)0x4869, - (q15_t)0x9592, (q15_t)0x471C, (q15_t)0x94B5, (q15_t)0x45CD, - (q15_t)0x93DB, (q15_t)0x447A, (q15_t)0x9306, (q15_t)0x4325, - (q15_t)0x9235, (q15_t)0x41CE, (q15_t)0x9169, (q15_t)0x4073, - (q15_t)0x90A0, (q15_t)0x3F17, (q15_t)0x8FDC, (q15_t)0x3DB8, - (q15_t)0x8F1D, (q15_t)0x3C56, (q15_t)0x8E61, (q15_t)0x3AF2, - (q15_t)0x8DAA, (q15_t)0x398C, (q15_t)0x8CF8, (q15_t)0x3824, - (q15_t)0x8C4A, (q15_t)0x36BA, (q15_t)0x8BA0, (q15_t)0x354D, - (q15_t)0x8AFB, (q15_t)0x33DE, (q15_t)0x8A5A, (q15_t)0x326E, - (q15_t)0x89BE, (q15_t)0x30FB, (q15_t)0x8926, (q15_t)0x2F87, - (q15_t)0x8893, (q15_t)0x2E11, (q15_t)0x8805, (q15_t)0x2C98, - (q15_t)0x877B, (q15_t)0x2B1F, (q15_t)0x86F6, (q15_t)0x29A3, - (q15_t)0x8675, (q15_t)0x2826, (q15_t)0x85FA, (q15_t)0x26A8, - (q15_t)0x8582, (q15_t)0x2528, (q15_t)0x8510, (q15_t)0x23A6, - (q15_t)0x84A2, (q15_t)0x2223, (q15_t)0x843A, (q15_t)0x209F, - (q15_t)0x83D6, (q15_t)0x1F19, (q15_t)0x8376, (q15_t)0x1D93, - (q15_t)0x831C, (q15_t)0x1C0B, (q15_t)0x82C6, (q15_t)0x1A82, - (q15_t)0x8275, (q15_t)0x18F8, (q15_t)0x8229, (q15_t)0x176D, - (q15_t)0x81E2, (q15_t)0x15E2, (q15_t)0x81A0, (q15_t)0x1455, - (q15_t)0x8162, (q15_t)0x12C8, (q15_t)0x812A, (q15_t)0x1139, - (q15_t)0x80F6, (q15_t)0x0FAB, (q15_t)0x80C7, (q15_t)0x0E1B, - (q15_t)0x809D, (q15_t)0x0C8B, (q15_t)0x8078, (q15_t)0x0AFB, - (q15_t)0x8058, (q15_t)0x096A, (q15_t)0x803D, (q15_t)0x07D9, - (q15_t)0x8027, (q15_t)0x0647, (q15_t)0x8016, (q15_t)0x04B6, - (q15_t)0x8009, (q15_t)0x0324, (q15_t)0x8002, (q15_t)0x0192, - (q15_t)0x8000, (q15_t)0x0000, (q15_t)0x8002, (q15_t)0xFE6D, - (q15_t)0x8009, (q15_t)0xFCDB, (q15_t)0x8016, (q15_t)0xFB49, - (q15_t)0x8027, (q15_t)0xF9B8, (q15_t)0x803D, (q15_t)0xF826, - (q15_t)0x8058, (q15_t)0xF695, (q15_t)0x8078, (q15_t)0xF504, - (q15_t)0x809D, (q15_t)0xF374, (q15_t)0x80C7, (q15_t)0xF1E4, - (q15_t)0x80F6, (q15_t)0xF054, (q15_t)0x812A, (q15_t)0xEEC6, - (q15_t)0x8162, (q15_t)0xED37, (q15_t)0x81A0, (q15_t)0xEBAA, - (q15_t)0x81E2, (q15_t)0xEA1D, (q15_t)0x8229, (q15_t)0xE892, - (q15_t)0x8275, (q15_t)0xE707, (q15_t)0x82C6, (q15_t)0xE57D, - (q15_t)0x831C, (q15_t)0xE3F4, (q15_t)0x8376, (q15_t)0xE26C, - (q15_t)0x83D6, (q15_t)0xE0E6, (q15_t)0x843A, (q15_t)0xDF60, - (q15_t)0x84A2, (q15_t)0xDDDC, (q15_t)0x8510, (q15_t)0xDC59, - (q15_t)0x8582, (q15_t)0xDAD7, (q15_t)0x85FA, (q15_t)0xD957, - (q15_t)0x8675, (q15_t)0xD7D9, (q15_t)0x86F6, (q15_t)0xD65C, - (q15_t)0x877B, (q15_t)0xD4E0, (q15_t)0x8805, (q15_t)0xD367, - (q15_t)0x8893, (q15_t)0xD1EE, (q15_t)0x8926, (q15_t)0xD078, - (q15_t)0x89BE, (q15_t)0xCF04, (q15_t)0x8A5A, (q15_t)0xCD91, - (q15_t)0x8AFB, (q15_t)0xCC21, (q15_t)0x8BA0, (q15_t)0xCAB2, - (q15_t)0x8C4A, (q15_t)0xC945, (q15_t)0x8CF8, (q15_t)0xC7DB, - (q15_t)0x8DAA, (q15_t)0xC673, (q15_t)0x8E61, (q15_t)0xC50D, - (q15_t)0x8F1D, (q15_t)0xC3A9, (q15_t)0x8FDC, (q15_t)0xC247, - (q15_t)0x90A0, (q15_t)0xC0E8, (q15_t)0x9169, (q15_t)0xBF8C, - (q15_t)0x9235, (q15_t)0xBE31, (q15_t)0x9306, (q15_t)0xBCDA, - (q15_t)0x93DB, (q15_t)0xBB85, (q15_t)0x94B5, (q15_t)0xBA32, - (q15_t)0x9592, (q15_t)0xB8E3, (q15_t)0x9673, (q15_t)0xB796, - (q15_t)0x9759, (q15_t)0xB64B, (q15_t)0x9842, (q15_t)0xB504, - (q15_t)0x9930, (q15_t)0xB3C0, (q15_t)0x9A22, (q15_t)0xB27E, - (q15_t)0x9B17, (q15_t)0xB140, (q15_t)0x9C10, (q15_t)0xB004, - (q15_t)0x9D0D, (q15_t)0xAECC, (q15_t)0x9E0E, (q15_t)0xAD96, - (q15_t)0x9F13, (q15_t)0xAC64, (q15_t)0xA01C, (q15_t)0xAB35, - (q15_t)0xA128, (q15_t)0xAA0A, (q15_t)0xA238, (q15_t)0xA8E2, - (q15_t)0xA34B, (q15_t)0xA7BD, (q15_t)0xA462, (q15_t)0xA69B, - (q15_t)0xA57D, (q15_t)0xA57D, (q15_t)0xA69B, (q15_t)0xA462, - (q15_t)0xA7BD, (q15_t)0xA34B, (q15_t)0xA8E2, (q15_t)0xA238, - (q15_t)0xAA0A, (q15_t)0xA128, (q15_t)0xAB35, (q15_t)0xA01C, - (q15_t)0xAC64, (q15_t)0x9F13, (q15_t)0xAD96, (q15_t)0x9E0E, - (q15_t)0xAECC, (q15_t)0x9D0D, (q15_t)0xB004, (q15_t)0x9C10, - (q15_t)0xB140, (q15_t)0x9B17, (q15_t)0xB27E, (q15_t)0x9A22, - (q15_t)0xB3C0, (q15_t)0x9930, (q15_t)0xB504, (q15_t)0x9842, - (q15_t)0xB64B, (q15_t)0x9759, (q15_t)0xB796, (q15_t)0x9673, - (q15_t)0xB8E3, (q15_t)0x9592, (q15_t)0xBA32, (q15_t)0x94B5, - (q15_t)0xBB85, (q15_t)0x93DB, (q15_t)0xBCDA, (q15_t)0x9306, - (q15_t)0xBE31, (q15_t)0x9235, (q15_t)0xBF8C, (q15_t)0x9169, - (q15_t)0xC0E8, (q15_t)0x90A0, (q15_t)0xC247, (q15_t)0x8FDC, - (q15_t)0xC3A9, (q15_t)0x8F1D, (q15_t)0xC50D, (q15_t)0x8E61, - (q15_t)0xC673, (q15_t)0x8DAA, (q15_t)0xC7DB, (q15_t)0x8CF8, - (q15_t)0xC945, (q15_t)0x8C4A, (q15_t)0xCAB2, (q15_t)0x8BA0, - (q15_t)0xCC21, (q15_t)0x8AFB, (q15_t)0xCD91, (q15_t)0x8A5A, - (q15_t)0xCF04, (q15_t)0x89BE, (q15_t)0xD078, (q15_t)0x8926, - (q15_t)0xD1EE, (q15_t)0x8893, (q15_t)0xD367, (q15_t)0x8805, - (q15_t)0xD4E0, (q15_t)0x877B, (q15_t)0xD65C, (q15_t)0x86F6, - (q15_t)0xD7D9, (q15_t)0x8675, (q15_t)0xD957, (q15_t)0x85FA, - (q15_t)0xDAD7, (q15_t)0x8582, (q15_t)0xDC59, (q15_t)0x8510, - (q15_t)0xDDDC, (q15_t)0x84A2, (q15_t)0xDF60, (q15_t)0x843A, - (q15_t)0xE0E6, (q15_t)0x83D6, (q15_t)0xE26C, (q15_t)0x8376, - (q15_t)0xE3F4, (q15_t)0x831C, (q15_t)0xE57D, (q15_t)0x82C6, - (q15_t)0xE707, (q15_t)0x8275, (q15_t)0xE892, (q15_t)0x8229, - (q15_t)0xEA1D, (q15_t)0x81E2, (q15_t)0xEBAA, (q15_t)0x81A0, - (q15_t)0xED37, (q15_t)0x8162, (q15_t)0xEEC6, (q15_t)0x812A, - (q15_t)0xF054, (q15_t)0x80F6, (q15_t)0xF1E4, (q15_t)0x80C7, - (q15_t)0xF374, (q15_t)0x809D, (q15_t)0xF504, (q15_t)0x8078, - (q15_t)0xF695, (q15_t)0x8058, (q15_t)0xF826, (q15_t)0x803D, - (q15_t)0xF9B8, (q15_t)0x8027, (q15_t)0xFB49, (q15_t)0x8016, - (q15_t)0xFCDB, (q15_t)0x8009, (q15_t)0xFE6D, (q15_t)0x8002 -}; + (q15_t)0x7FFF, (q15_t)0x0000, (q15_t)0x7FFD, (q15_t)0x0192, (q15_t)0x7FF6, + (q15_t)0x0324, (q15_t)0x7FE9, (q15_t)0x04B6, (q15_t)0x7FD8, (q15_t)0x0647, + (q15_t)0x7FC2, (q15_t)0x07D9, (q15_t)0x7FA7, (q15_t)0x096A, (q15_t)0x7F87, + (q15_t)0x0AFB, (q15_t)0x7F62, (q15_t)0x0C8B, (q15_t)0x7F38, (q15_t)0x0E1B, + (q15_t)0x7F09, (q15_t)0x0FAB, (q15_t)0x7ED5, (q15_t)0x1139, (q15_t)0x7E9D, + (q15_t)0x12C8, (q15_t)0x7E5F, (q15_t)0x1455, (q15_t)0x7E1D, (q15_t)0x15E2, + (q15_t)0x7DD6, (q15_t)0x176D, (q15_t)0x7D8A, (q15_t)0x18F8, (q15_t)0x7D39, + (q15_t)0x1A82, (q15_t)0x7CE3, (q15_t)0x1C0B, (q15_t)0x7C89, (q15_t)0x1D93, + (q15_t)0x7C29, (q15_t)0x1F19, (q15_t)0x7BC5, (q15_t)0x209F, (q15_t)0x7B5D, + (q15_t)0x2223, (q15_t)0x7AEF, (q15_t)0x23A6, (q15_t)0x7A7D, (q15_t)0x2528, + (q15_t)0x7A05, (q15_t)0x26A8, (q15_t)0x798A, (q15_t)0x2826, (q15_t)0x7909, + (q15_t)0x29A3, (q15_t)0x7884, (q15_t)0x2B1F, (q15_t)0x77FA, (q15_t)0x2C98, + (q15_t)0x776C, (q15_t)0x2E11, (q15_t)0x76D9, (q15_t)0x2F87, (q15_t)0x7641, + (q15_t)0x30FB, (q15_t)0x75A5, (q15_t)0x326E, (q15_t)0x7504, (q15_t)0x33DE, + (q15_t)0x745F, (q15_t)0x354D, (q15_t)0x73B5, (q15_t)0x36BA, (q15_t)0x7307, + (q15_t)0x3824, (q15_t)0x7255, (q15_t)0x398C, (q15_t)0x719E, (q15_t)0x3AF2, + (q15_t)0x70E2, (q15_t)0x3C56, (q15_t)0x7023, (q15_t)0x3DB8, (q15_t)0x6F5F, + (q15_t)0x3F17, (q15_t)0x6E96, (q15_t)0x4073, (q15_t)0x6DCA, (q15_t)0x41CE, + (q15_t)0x6CF9, (q15_t)0x4325, (q15_t)0x6C24, (q15_t)0x447A, (q15_t)0x6B4A, + (q15_t)0x45CD, (q15_t)0x6A6D, (q15_t)0x471C, (q15_t)0x698C, (q15_t)0x4869, + (q15_t)0x68A6, (q15_t)0x49B4, (q15_t)0x67BD, (q15_t)0x4AFB, (q15_t)0x66CF, + (q15_t)0x4C3F, (q15_t)0x65DD, (q15_t)0x4D81, (q15_t)0x64E8, (q15_t)0x4EBF, + (q15_t)0x63EF, (q15_t)0x4FFB, (q15_t)0x62F2, (q15_t)0x5133, (q15_t)0x61F1, + (q15_t)0x5269, (q15_t)0x60EC, (q15_t)0x539B, (q15_t)0x5FE3, (q15_t)0x54CA, + (q15_t)0x5ED7, (q15_t)0x55F5, (q15_t)0x5DC7, (q15_t)0x571D, (q15_t)0x5CB4, + (q15_t)0x5842, (q15_t)0x5B9D, (q15_t)0x5964, (q15_t)0x5A82, (q15_t)0x5A82, + (q15_t)0x5964, (q15_t)0x5B9D, (q15_t)0x5842, (q15_t)0x5CB4, (q15_t)0x571D, + (q15_t)0x5DC7, (q15_t)0x55F5, (q15_t)0x5ED7, (q15_t)0x54CA, (q15_t)0x5FE3, + (q15_t)0x539B, (q15_t)0x60EC, (q15_t)0x5269, (q15_t)0x61F1, (q15_t)0x5133, + (q15_t)0x62F2, (q15_t)0x4FFB, (q15_t)0x63EF, (q15_t)0x4EBF, (q15_t)0x64E8, + (q15_t)0x4D81, (q15_t)0x65DD, (q15_t)0x4C3F, (q15_t)0x66CF, (q15_t)0x4AFB, + (q15_t)0x67BD, (q15_t)0x49B4, (q15_t)0x68A6, (q15_t)0x4869, (q15_t)0x698C, + (q15_t)0x471C, (q15_t)0x6A6D, (q15_t)0x45CD, (q15_t)0x6B4A, (q15_t)0x447A, + (q15_t)0x6C24, (q15_t)0x4325, (q15_t)0x6CF9, (q15_t)0x41CE, (q15_t)0x6DCA, + (q15_t)0x4073, (q15_t)0x6E96, (q15_t)0x3F17, (q15_t)0x6F5F, (q15_t)0x3DB8, + (q15_t)0x7023, (q15_t)0x3C56, (q15_t)0x70E2, (q15_t)0x3AF2, (q15_t)0x719E, + (q15_t)0x398C, (q15_t)0x7255, (q15_t)0x3824, (q15_t)0x7307, (q15_t)0x36BA, + (q15_t)0x73B5, (q15_t)0x354D, (q15_t)0x745F, (q15_t)0x33DE, (q15_t)0x7504, + (q15_t)0x326E, (q15_t)0x75A5, (q15_t)0x30FB, (q15_t)0x7641, (q15_t)0x2F87, + (q15_t)0x76D9, (q15_t)0x2E11, (q15_t)0x776C, (q15_t)0x2C98, (q15_t)0x77FA, + (q15_t)0x2B1F, (q15_t)0x7884, (q15_t)0x29A3, (q15_t)0x7909, (q15_t)0x2826, + (q15_t)0x798A, (q15_t)0x26A8, (q15_t)0x7A05, (q15_t)0x2528, (q15_t)0x7A7D, + (q15_t)0x23A6, (q15_t)0x7AEF, (q15_t)0x2223, (q15_t)0x7B5D, (q15_t)0x209F, + (q15_t)0x7BC5, (q15_t)0x1F19, (q15_t)0x7C29, (q15_t)0x1D93, (q15_t)0x7C89, + (q15_t)0x1C0B, (q15_t)0x7CE3, (q15_t)0x1A82, (q15_t)0x7D39, (q15_t)0x18F8, + (q15_t)0x7D8A, (q15_t)0x176D, (q15_t)0x7DD6, (q15_t)0x15E2, (q15_t)0x7E1D, + (q15_t)0x1455, (q15_t)0x7E5F, (q15_t)0x12C8, (q15_t)0x7E9D, (q15_t)0x1139, + (q15_t)0x7ED5, (q15_t)0x0FAB, (q15_t)0x7F09, (q15_t)0x0E1B, (q15_t)0x7F38, + (q15_t)0x0C8B, (q15_t)0x7F62, (q15_t)0x0AFB, (q15_t)0x7F87, (q15_t)0x096A, + (q15_t)0x7FA7, (q15_t)0x07D9, (q15_t)0x7FC2, (q15_t)0x0647, (q15_t)0x7FD8, + (q15_t)0x04B6, (q15_t)0x7FE9, (q15_t)0x0324, (q15_t)0x7FF6, (q15_t)0x0192, + (q15_t)0x7FFD, (q15_t)0x0000, (q15_t)0x7FFF, (q15_t)0xFE6D, (q15_t)0x7FFD, + (q15_t)0xFCDB, (q15_t)0x7FF6, (q15_t)0xFB49, (q15_t)0x7FE9, (q15_t)0xF9B8, + (q15_t)0x7FD8, (q15_t)0xF826, (q15_t)0x7FC2, (q15_t)0xF695, (q15_t)0x7FA7, + (q15_t)0xF504, (q15_t)0x7F87, (q15_t)0xF374, (q15_t)0x7F62, (q15_t)0xF1E4, + (q15_t)0x7F38, (q15_t)0xF054, (q15_t)0x7F09, (q15_t)0xEEC6, (q15_t)0x7ED5, + (q15_t)0xED37, (q15_t)0x7E9D, (q15_t)0xEBAA, (q15_t)0x7E5F, (q15_t)0xEA1D, + (q15_t)0x7E1D, (q15_t)0xE892, (q15_t)0x7DD6, (q15_t)0xE707, (q15_t)0x7D8A, + (q15_t)0xE57D, (q15_t)0x7D39, (q15_t)0xE3F4, (q15_t)0x7CE3, (q15_t)0xE26C, + (q15_t)0x7C89, (q15_t)0xE0E6, (q15_t)0x7C29, (q15_t)0xDF60, (q15_t)0x7BC5, + (q15_t)0xDDDC, (q15_t)0x7B5D, (q15_t)0xDC59, (q15_t)0x7AEF, (q15_t)0xDAD7, + (q15_t)0x7A7D, (q15_t)0xD957, (q15_t)0x7A05, (q15_t)0xD7D9, (q15_t)0x798A, + (q15_t)0xD65C, (q15_t)0x7909, (q15_t)0xD4E0, (q15_t)0x7884, (q15_t)0xD367, + (q15_t)0x77FA, (q15_t)0xD1EE, (q15_t)0x776C, (q15_t)0xD078, (q15_t)0x76D9, + (q15_t)0xCF04, (q15_t)0x7641, (q15_t)0xCD91, (q15_t)0x75A5, (q15_t)0xCC21, + (q15_t)0x7504, (q15_t)0xCAB2, (q15_t)0x745F, (q15_t)0xC945, (q15_t)0x73B5, + (q15_t)0xC7DB, (q15_t)0x7307, (q15_t)0xC673, (q15_t)0x7255, (q15_t)0xC50D, + (q15_t)0x719E, (q15_t)0xC3A9, (q15_t)0x70E2, (q15_t)0xC247, (q15_t)0x7023, + (q15_t)0xC0E8, (q15_t)0x6F5F, (q15_t)0xBF8C, (q15_t)0x6E96, (q15_t)0xBE31, + (q15_t)0x6DCA, (q15_t)0xBCDA, (q15_t)0x6CF9, (q15_t)0xBB85, (q15_t)0x6C24, + (q15_t)0xBA32, (q15_t)0x6B4A, (q15_t)0xB8E3, (q15_t)0x6A6D, (q15_t)0xB796, + (q15_t)0x698C, (q15_t)0xB64B, (q15_t)0x68A6, (q15_t)0xB504, (q15_t)0x67BD, + (q15_t)0xB3C0, (q15_t)0x66CF, (q15_t)0xB27E, (q15_t)0x65DD, (q15_t)0xB140, + (q15_t)0x64E8, (q15_t)0xB004, (q15_t)0x63EF, (q15_t)0xAECC, (q15_t)0x62F2, + (q15_t)0xAD96, (q15_t)0x61F1, (q15_t)0xAC64, (q15_t)0x60EC, (q15_t)0xAB35, + (q15_t)0x5FE3, (q15_t)0xAA0A, (q15_t)0x5ED7, (q15_t)0xA8E2, (q15_t)0x5DC7, + (q15_t)0xA7BD, (q15_t)0x5CB4, (q15_t)0xA69B, (q15_t)0x5B9D, (q15_t)0xA57D, + (q15_t)0x5A82, (q15_t)0xA462, (q15_t)0x5964, (q15_t)0xA34B, (q15_t)0x5842, + (q15_t)0xA238, (q15_t)0x571D, (q15_t)0xA128, (q15_t)0x55F5, (q15_t)0xA01C, + (q15_t)0x54CA, (q15_t)0x9F13, (q15_t)0x539B, (q15_t)0x9E0E, (q15_t)0x5269, + (q15_t)0x9D0D, (q15_t)0x5133, (q15_t)0x9C10, (q15_t)0x4FFB, (q15_t)0x9B17, + (q15_t)0x4EBF, (q15_t)0x9A22, (q15_t)0x4D81, (q15_t)0x9930, (q15_t)0x4C3F, + (q15_t)0x9842, (q15_t)0x4AFB, (q15_t)0x9759, (q15_t)0x49B4, (q15_t)0x9673, + (q15_t)0x4869, (q15_t)0x9592, (q15_t)0x471C, (q15_t)0x94B5, (q15_t)0x45CD, + (q15_t)0x93DB, (q15_t)0x447A, (q15_t)0x9306, (q15_t)0x4325, (q15_t)0x9235, + (q15_t)0x41CE, (q15_t)0x9169, (q15_t)0x4073, (q15_t)0x90A0, (q15_t)0x3F17, + (q15_t)0x8FDC, (q15_t)0x3DB8, (q15_t)0x8F1D, (q15_t)0x3C56, (q15_t)0x8E61, + (q15_t)0x3AF2, (q15_t)0x8DAA, (q15_t)0x398C, (q15_t)0x8CF8, (q15_t)0x3824, + (q15_t)0x8C4A, (q15_t)0x36BA, (q15_t)0x8BA0, (q15_t)0x354D, (q15_t)0x8AFB, + (q15_t)0x33DE, (q15_t)0x8A5A, (q15_t)0x326E, (q15_t)0x89BE, (q15_t)0x30FB, + (q15_t)0x8926, (q15_t)0x2F87, (q15_t)0x8893, (q15_t)0x2E11, (q15_t)0x8805, + (q15_t)0x2C98, (q15_t)0x877B, (q15_t)0x2B1F, (q15_t)0x86F6, (q15_t)0x29A3, + (q15_t)0x8675, (q15_t)0x2826, (q15_t)0x85FA, (q15_t)0x26A8, (q15_t)0x8582, + (q15_t)0x2528, (q15_t)0x8510, (q15_t)0x23A6, (q15_t)0x84A2, (q15_t)0x2223, + (q15_t)0x843A, (q15_t)0x209F, (q15_t)0x83D6, (q15_t)0x1F19, (q15_t)0x8376, + (q15_t)0x1D93, (q15_t)0x831C, (q15_t)0x1C0B, (q15_t)0x82C6, (q15_t)0x1A82, + (q15_t)0x8275, (q15_t)0x18F8, (q15_t)0x8229, (q15_t)0x176D, (q15_t)0x81E2, + (q15_t)0x15E2, (q15_t)0x81A0, (q15_t)0x1455, (q15_t)0x8162, (q15_t)0x12C8, + (q15_t)0x812A, (q15_t)0x1139, (q15_t)0x80F6, (q15_t)0x0FAB, (q15_t)0x80C7, + (q15_t)0x0E1B, (q15_t)0x809D, (q15_t)0x0C8B, (q15_t)0x8078, (q15_t)0x0AFB, + (q15_t)0x8058, (q15_t)0x096A, (q15_t)0x803D, (q15_t)0x07D9, (q15_t)0x8027, + (q15_t)0x0647, (q15_t)0x8016, (q15_t)0x04B6, (q15_t)0x8009, (q15_t)0x0324, + (q15_t)0x8002, (q15_t)0x0192, (q15_t)0x8000, (q15_t)0x0000, (q15_t)0x8002, + (q15_t)0xFE6D, (q15_t)0x8009, (q15_t)0xFCDB, (q15_t)0x8016, (q15_t)0xFB49, + (q15_t)0x8027, (q15_t)0xF9B8, (q15_t)0x803D, (q15_t)0xF826, (q15_t)0x8058, + (q15_t)0xF695, (q15_t)0x8078, (q15_t)0xF504, (q15_t)0x809D, (q15_t)0xF374, + (q15_t)0x80C7, (q15_t)0xF1E4, (q15_t)0x80F6, (q15_t)0xF054, (q15_t)0x812A, + (q15_t)0xEEC6, (q15_t)0x8162, (q15_t)0xED37, (q15_t)0x81A0, (q15_t)0xEBAA, + (q15_t)0x81E2, (q15_t)0xEA1D, (q15_t)0x8229, (q15_t)0xE892, (q15_t)0x8275, + (q15_t)0xE707, (q15_t)0x82C6, (q15_t)0xE57D, (q15_t)0x831C, (q15_t)0xE3F4, + (q15_t)0x8376, (q15_t)0xE26C, (q15_t)0x83D6, (q15_t)0xE0E6, (q15_t)0x843A, + (q15_t)0xDF60, (q15_t)0x84A2, (q15_t)0xDDDC, (q15_t)0x8510, (q15_t)0xDC59, + (q15_t)0x8582, (q15_t)0xDAD7, (q15_t)0x85FA, (q15_t)0xD957, (q15_t)0x8675, + (q15_t)0xD7D9, (q15_t)0x86F6, (q15_t)0xD65C, (q15_t)0x877B, (q15_t)0xD4E0, + (q15_t)0x8805, (q15_t)0xD367, (q15_t)0x8893, (q15_t)0xD1EE, (q15_t)0x8926, + (q15_t)0xD078, (q15_t)0x89BE, (q15_t)0xCF04, (q15_t)0x8A5A, (q15_t)0xCD91, + (q15_t)0x8AFB, (q15_t)0xCC21, (q15_t)0x8BA0, (q15_t)0xCAB2, (q15_t)0x8C4A, + (q15_t)0xC945, (q15_t)0x8CF8, (q15_t)0xC7DB, (q15_t)0x8DAA, (q15_t)0xC673, + (q15_t)0x8E61, (q15_t)0xC50D, (q15_t)0x8F1D, (q15_t)0xC3A9, (q15_t)0x8FDC, + (q15_t)0xC247, (q15_t)0x90A0, (q15_t)0xC0E8, (q15_t)0x9169, (q15_t)0xBF8C, + (q15_t)0x9235, (q15_t)0xBE31, (q15_t)0x9306, (q15_t)0xBCDA, (q15_t)0x93DB, + (q15_t)0xBB85, (q15_t)0x94B5, (q15_t)0xBA32, (q15_t)0x9592, (q15_t)0xB8E3, + (q15_t)0x9673, (q15_t)0xB796, (q15_t)0x9759, (q15_t)0xB64B, (q15_t)0x9842, + (q15_t)0xB504, (q15_t)0x9930, (q15_t)0xB3C0, (q15_t)0x9A22, (q15_t)0xB27E, + (q15_t)0x9B17, (q15_t)0xB140, (q15_t)0x9C10, (q15_t)0xB004, (q15_t)0x9D0D, + (q15_t)0xAECC, (q15_t)0x9E0E, (q15_t)0xAD96, (q15_t)0x9F13, (q15_t)0xAC64, + (q15_t)0xA01C, (q15_t)0xAB35, (q15_t)0xA128, (q15_t)0xAA0A, (q15_t)0xA238, + (q15_t)0xA8E2, (q15_t)0xA34B, (q15_t)0xA7BD, (q15_t)0xA462, (q15_t)0xA69B, + (q15_t)0xA57D, (q15_t)0xA57D, (q15_t)0xA69B, (q15_t)0xA462, (q15_t)0xA7BD, + (q15_t)0xA34B, (q15_t)0xA8E2, (q15_t)0xA238, (q15_t)0xAA0A, (q15_t)0xA128, + (q15_t)0xAB35, (q15_t)0xA01C, (q15_t)0xAC64, (q15_t)0x9F13, (q15_t)0xAD96, + (q15_t)0x9E0E, (q15_t)0xAECC, (q15_t)0x9D0D, (q15_t)0xB004, (q15_t)0x9C10, + (q15_t)0xB140, (q15_t)0x9B17, (q15_t)0xB27E, (q15_t)0x9A22, (q15_t)0xB3C0, + (q15_t)0x9930, (q15_t)0xB504, (q15_t)0x9842, (q15_t)0xB64B, (q15_t)0x9759, + (q15_t)0xB796, (q15_t)0x9673, (q15_t)0xB8E3, (q15_t)0x9592, (q15_t)0xBA32, + (q15_t)0x94B5, (q15_t)0xBB85, (q15_t)0x93DB, (q15_t)0xBCDA, (q15_t)0x9306, + (q15_t)0xBE31, (q15_t)0x9235, (q15_t)0xBF8C, (q15_t)0x9169, (q15_t)0xC0E8, + (q15_t)0x90A0, (q15_t)0xC247, (q15_t)0x8FDC, (q15_t)0xC3A9, (q15_t)0x8F1D, + (q15_t)0xC50D, (q15_t)0x8E61, (q15_t)0xC673, (q15_t)0x8DAA, (q15_t)0xC7DB, + (q15_t)0x8CF8, (q15_t)0xC945, (q15_t)0x8C4A, (q15_t)0xCAB2, (q15_t)0x8BA0, + (q15_t)0xCC21, (q15_t)0x8AFB, (q15_t)0xCD91, (q15_t)0x8A5A, (q15_t)0xCF04, + (q15_t)0x89BE, (q15_t)0xD078, (q15_t)0x8926, (q15_t)0xD1EE, (q15_t)0x8893, + (q15_t)0xD367, (q15_t)0x8805, (q15_t)0xD4E0, (q15_t)0x877B, (q15_t)0xD65C, + (q15_t)0x86F6, (q15_t)0xD7D9, (q15_t)0x8675, (q15_t)0xD957, (q15_t)0x85FA, + (q15_t)0xDAD7, (q15_t)0x8582, (q15_t)0xDC59, (q15_t)0x8510, (q15_t)0xDDDC, + (q15_t)0x84A2, (q15_t)0xDF60, (q15_t)0x843A, (q15_t)0xE0E6, (q15_t)0x83D6, + (q15_t)0xE26C, (q15_t)0x8376, (q15_t)0xE3F4, (q15_t)0x831C, (q15_t)0xE57D, + (q15_t)0x82C6, (q15_t)0xE707, (q15_t)0x8275, (q15_t)0xE892, (q15_t)0x8229, + (q15_t)0xEA1D, (q15_t)0x81E2, (q15_t)0xEBAA, (q15_t)0x81A0, (q15_t)0xED37, + (q15_t)0x8162, (q15_t)0xEEC6, (q15_t)0x812A, (q15_t)0xF054, (q15_t)0x80F6, + (q15_t)0xF1E4, (q15_t)0x80C7, (q15_t)0xF374, (q15_t)0x809D, (q15_t)0xF504, + (q15_t)0x8078, (q15_t)0xF695, (q15_t)0x8058, (q15_t)0xF826, (q15_t)0x803D, + (q15_t)0xF9B8, (q15_t)0x8027, (q15_t)0xFB49, (q15_t)0x8016, (q15_t)0xFCDB, + (q15_t)0x8009, (q15_t)0xFE6D, (q15_t)0x8002}; /** @par @@ -13330,395 +7265,318 @@ const q15_t twiddleCoef_512_q15[768] = { Cos and Sin values are interleaved fashion @par Convert Floating point to q15(Fixed point 1.15): - round(twiddleCoefq15(i) * pow(2, 15)) - + round(twiddleCoefq15(i) * pow(2, 15)) + */ const q15_t twiddleCoef_1024_q15[1536] = { - (q15_t)0x7FFF, (q15_t)0x0000, (q15_t)0x7FFF, (q15_t)0x00C9, - (q15_t)0x7FFD, (q15_t)0x0192, (q15_t)0x7FFA, (q15_t)0x025B, - (q15_t)0x7FF6, (q15_t)0x0324, (q15_t)0x7FF0, (q15_t)0x03ED, - (q15_t)0x7FE9, (q15_t)0x04B6, (q15_t)0x7FE1, (q15_t)0x057F, - (q15_t)0x7FD8, (q15_t)0x0647, (q15_t)0x7FCE, (q15_t)0x0710, - (q15_t)0x7FC2, (q15_t)0x07D9, (q15_t)0x7FB5, (q15_t)0x08A2, - (q15_t)0x7FA7, (q15_t)0x096A, (q15_t)0x7F97, (q15_t)0x0A33, - (q15_t)0x7F87, (q15_t)0x0AFB, (q15_t)0x7F75, (q15_t)0x0BC3, - (q15_t)0x7F62, (q15_t)0x0C8B, (q15_t)0x7F4D, (q15_t)0x0D53, - (q15_t)0x7F38, (q15_t)0x0E1B, (q15_t)0x7F21, (q15_t)0x0EE3, - (q15_t)0x7F09, (q15_t)0x0FAB, (q15_t)0x7EF0, (q15_t)0x1072, - (q15_t)0x7ED5, (q15_t)0x1139, (q15_t)0x7EBA, (q15_t)0x1201, - (q15_t)0x7E9D, (q15_t)0x12C8, (q15_t)0x7E7F, (q15_t)0x138E, - (q15_t)0x7E5F, (q15_t)0x1455, (q15_t)0x7E3F, (q15_t)0x151B, - (q15_t)0x7E1D, (q15_t)0x15E2, (q15_t)0x7DFA, (q15_t)0x16A8, - (q15_t)0x7DD6, (q15_t)0x176D, (q15_t)0x7DB0, (q15_t)0x1833, - (q15_t)0x7D8A, (q15_t)0x18F8, (q15_t)0x7D62, (q15_t)0x19BD, - (q15_t)0x7D39, (q15_t)0x1A82, (q15_t)0x7D0F, (q15_t)0x1B47, - (q15_t)0x7CE3, (q15_t)0x1C0B, (q15_t)0x7CB7, (q15_t)0x1CCF, - (q15_t)0x7C89, (q15_t)0x1D93, (q15_t)0x7C5A, (q15_t)0x1E56, - (q15_t)0x7C29, (q15_t)0x1F19, (q15_t)0x7BF8, (q15_t)0x1FDC, - (q15_t)0x7BC5, (q15_t)0x209F, (q15_t)0x7B92, (q15_t)0x2161, - (q15_t)0x7B5D, (q15_t)0x2223, (q15_t)0x7B26, (q15_t)0x22E5, - (q15_t)0x7AEF, (q15_t)0x23A6, (q15_t)0x7AB6, (q15_t)0x2467, - (q15_t)0x7A7D, (q15_t)0x2528, (q15_t)0x7A42, (q15_t)0x25E8, - (q15_t)0x7A05, (q15_t)0x26A8, (q15_t)0x79C8, (q15_t)0x2767, - (q15_t)0x798A, (q15_t)0x2826, (q15_t)0x794A, (q15_t)0x28E5, - (q15_t)0x7909, (q15_t)0x29A3, (q15_t)0x78C7, (q15_t)0x2A61, - (q15_t)0x7884, (q15_t)0x2B1F, (q15_t)0x7840, (q15_t)0x2BDC, - (q15_t)0x77FA, (q15_t)0x2C98, (q15_t)0x77B4, (q15_t)0x2D55, - (q15_t)0x776C, (q15_t)0x2E11, (q15_t)0x7723, (q15_t)0x2ECC, - (q15_t)0x76D9, (q15_t)0x2F87, (q15_t)0x768E, (q15_t)0x3041, - (q15_t)0x7641, (q15_t)0x30FB, (q15_t)0x75F4, (q15_t)0x31B5, - (q15_t)0x75A5, (q15_t)0x326E, (q15_t)0x7555, (q15_t)0x3326, - (q15_t)0x7504, (q15_t)0x33DE, (q15_t)0x74B2, (q15_t)0x3496, - (q15_t)0x745F, (q15_t)0x354D, (q15_t)0x740B, (q15_t)0x3604, - (q15_t)0x73B5, (q15_t)0x36BA, (q15_t)0x735F, (q15_t)0x376F, - (q15_t)0x7307, (q15_t)0x3824, (q15_t)0x72AF, (q15_t)0x38D8, - (q15_t)0x7255, (q15_t)0x398C, (q15_t)0x71FA, (q15_t)0x3A40, - (q15_t)0x719E, (q15_t)0x3AF2, (q15_t)0x7141, (q15_t)0x3BA5, - (q15_t)0x70E2, (q15_t)0x3C56, (q15_t)0x7083, (q15_t)0x3D07, - (q15_t)0x7023, (q15_t)0x3DB8, (q15_t)0x6FC1, (q15_t)0x3E68, - (q15_t)0x6F5F, (q15_t)0x3F17, (q15_t)0x6EFB, (q15_t)0x3FC5, - (q15_t)0x6E96, (q15_t)0x4073, (q15_t)0x6E30, (q15_t)0x4121, - (q15_t)0x6DCA, (q15_t)0x41CE, (q15_t)0x6D62, (q15_t)0x427A, - (q15_t)0x6CF9, (q15_t)0x4325, (q15_t)0x6C8F, (q15_t)0x43D0, - (q15_t)0x6C24, (q15_t)0x447A, (q15_t)0x6BB8, (q15_t)0x4524, - (q15_t)0x6B4A, (q15_t)0x45CD, (q15_t)0x6ADC, (q15_t)0x4675, - (q15_t)0x6A6D, (q15_t)0x471C, (q15_t)0x69FD, (q15_t)0x47C3, - (q15_t)0x698C, (q15_t)0x4869, (q15_t)0x6919, (q15_t)0x490F, - (q15_t)0x68A6, (q15_t)0x49B4, (q15_t)0x6832, (q15_t)0x4A58, - (q15_t)0x67BD, (q15_t)0x4AFB, (q15_t)0x6746, (q15_t)0x4B9E, - (q15_t)0x66CF, (q15_t)0x4C3F, (q15_t)0x6657, (q15_t)0x4CE1, - (q15_t)0x65DD, (q15_t)0x4D81, (q15_t)0x6563, (q15_t)0x4E21, - (q15_t)0x64E8, (q15_t)0x4EBF, (q15_t)0x646C, (q15_t)0x4F5E, - (q15_t)0x63EF, (q15_t)0x4FFB, (q15_t)0x6371, (q15_t)0x5097, - (q15_t)0x62F2, (q15_t)0x5133, (q15_t)0x6271, (q15_t)0x51CE, - (q15_t)0x61F1, (q15_t)0x5269, (q15_t)0x616F, (q15_t)0x5302, - (q15_t)0x60EC, (q15_t)0x539B, (q15_t)0x6068, (q15_t)0x5433, - (q15_t)0x5FE3, (q15_t)0x54CA, (q15_t)0x5F5E, (q15_t)0x5560, - (q15_t)0x5ED7, (q15_t)0x55F5, (q15_t)0x5E50, (q15_t)0x568A, - (q15_t)0x5DC7, (q15_t)0x571D, (q15_t)0x5D3E, (q15_t)0x57B0, - (q15_t)0x5CB4, (q15_t)0x5842, (q15_t)0x5C29, (q15_t)0x58D4, - (q15_t)0x5B9D, (q15_t)0x5964, (q15_t)0x5B10, (q15_t)0x59F3, - (q15_t)0x5A82, (q15_t)0x5A82, (q15_t)0x59F3, (q15_t)0x5B10, - (q15_t)0x5964, (q15_t)0x5B9D, (q15_t)0x58D4, (q15_t)0x5C29, - (q15_t)0x5842, (q15_t)0x5CB4, (q15_t)0x57B0, (q15_t)0x5D3E, - (q15_t)0x571D, (q15_t)0x5DC7, (q15_t)0x568A, (q15_t)0x5E50, - (q15_t)0x55F5, (q15_t)0x5ED7, (q15_t)0x5560, (q15_t)0x5F5E, - (q15_t)0x54CA, (q15_t)0x5FE3, (q15_t)0x5433, (q15_t)0x6068, - (q15_t)0x539B, (q15_t)0x60EC, (q15_t)0x5302, (q15_t)0x616F, - (q15_t)0x5269, (q15_t)0x61F1, (q15_t)0x51CE, (q15_t)0x6271, - (q15_t)0x5133, (q15_t)0x62F2, (q15_t)0x5097, (q15_t)0x6371, - (q15_t)0x4FFB, (q15_t)0x63EF, (q15_t)0x4F5E, (q15_t)0x646C, - (q15_t)0x4EBF, (q15_t)0x64E8, (q15_t)0x4E21, (q15_t)0x6563, - (q15_t)0x4D81, (q15_t)0x65DD, (q15_t)0x4CE1, (q15_t)0x6657, - (q15_t)0x4C3F, (q15_t)0x66CF, (q15_t)0x4B9E, (q15_t)0x6746, - (q15_t)0x4AFB, (q15_t)0x67BD, (q15_t)0x4A58, (q15_t)0x6832, - (q15_t)0x49B4, (q15_t)0x68A6, (q15_t)0x490F, (q15_t)0x6919, - (q15_t)0x4869, (q15_t)0x698C, (q15_t)0x47C3, (q15_t)0x69FD, - (q15_t)0x471C, (q15_t)0x6A6D, (q15_t)0x4675, (q15_t)0x6ADC, - (q15_t)0x45CD, (q15_t)0x6B4A, (q15_t)0x4524, (q15_t)0x6BB8, - (q15_t)0x447A, (q15_t)0x6C24, (q15_t)0x43D0, (q15_t)0x6C8F, - (q15_t)0x4325, (q15_t)0x6CF9, (q15_t)0x427A, (q15_t)0x6D62, - (q15_t)0x41CE, (q15_t)0x6DCA, (q15_t)0x4121, (q15_t)0x6E30, - (q15_t)0x4073, (q15_t)0x6E96, (q15_t)0x3FC5, (q15_t)0x6EFB, - (q15_t)0x3F17, (q15_t)0x6F5F, (q15_t)0x3E68, (q15_t)0x6FC1, - (q15_t)0x3DB8, (q15_t)0x7023, (q15_t)0x3D07, (q15_t)0x7083, - (q15_t)0x3C56, (q15_t)0x70E2, (q15_t)0x3BA5, (q15_t)0x7141, - (q15_t)0x3AF2, (q15_t)0x719E, (q15_t)0x3A40, (q15_t)0x71FA, - (q15_t)0x398C, (q15_t)0x7255, (q15_t)0x38D8, (q15_t)0x72AF, - (q15_t)0x3824, (q15_t)0x7307, (q15_t)0x376F, (q15_t)0x735F, - (q15_t)0x36BA, (q15_t)0x73B5, (q15_t)0x3604, (q15_t)0x740B, - (q15_t)0x354D, (q15_t)0x745F, (q15_t)0x3496, (q15_t)0x74B2, - (q15_t)0x33DE, (q15_t)0x7504, (q15_t)0x3326, (q15_t)0x7555, - (q15_t)0x326E, (q15_t)0x75A5, (q15_t)0x31B5, (q15_t)0x75F4, - (q15_t)0x30FB, (q15_t)0x7641, (q15_t)0x3041, (q15_t)0x768E, - (q15_t)0x2F87, (q15_t)0x76D9, (q15_t)0x2ECC, (q15_t)0x7723, - (q15_t)0x2E11, (q15_t)0x776C, (q15_t)0x2D55, (q15_t)0x77B4, - (q15_t)0x2C98, (q15_t)0x77FA, (q15_t)0x2BDC, (q15_t)0x7840, - (q15_t)0x2B1F, (q15_t)0x7884, (q15_t)0x2A61, (q15_t)0x78C7, - (q15_t)0x29A3, (q15_t)0x7909, (q15_t)0x28E5, (q15_t)0x794A, - (q15_t)0x2826, (q15_t)0x798A, (q15_t)0x2767, (q15_t)0x79C8, - (q15_t)0x26A8, (q15_t)0x7A05, (q15_t)0x25E8, (q15_t)0x7A42, - (q15_t)0x2528, (q15_t)0x7A7D, (q15_t)0x2467, (q15_t)0x7AB6, - (q15_t)0x23A6, (q15_t)0x7AEF, (q15_t)0x22E5, (q15_t)0x7B26, - (q15_t)0x2223, (q15_t)0x7B5D, (q15_t)0x2161, (q15_t)0x7B92, - (q15_t)0x209F, (q15_t)0x7BC5, (q15_t)0x1FDC, (q15_t)0x7BF8, - (q15_t)0x1F19, (q15_t)0x7C29, (q15_t)0x1E56, (q15_t)0x7C5A, - (q15_t)0x1D93, (q15_t)0x7C89, (q15_t)0x1CCF, (q15_t)0x7CB7, - (q15_t)0x1C0B, (q15_t)0x7CE3, (q15_t)0x1B47, (q15_t)0x7D0F, - (q15_t)0x1A82, (q15_t)0x7D39, (q15_t)0x19BD, (q15_t)0x7D62, - (q15_t)0x18F8, (q15_t)0x7D8A, (q15_t)0x1833, (q15_t)0x7DB0, - (q15_t)0x176D, (q15_t)0x7DD6, (q15_t)0x16A8, (q15_t)0x7DFA, - (q15_t)0x15E2, (q15_t)0x7E1D, (q15_t)0x151B, (q15_t)0x7E3F, - (q15_t)0x1455, (q15_t)0x7E5F, (q15_t)0x138E, (q15_t)0x7E7F, - (q15_t)0x12C8, (q15_t)0x7E9D, (q15_t)0x1201, (q15_t)0x7EBA, - (q15_t)0x1139, (q15_t)0x7ED5, (q15_t)0x1072, (q15_t)0x7EF0, - (q15_t)0x0FAB, (q15_t)0x7F09, (q15_t)0x0EE3, (q15_t)0x7F21, - (q15_t)0x0E1B, (q15_t)0x7F38, (q15_t)0x0D53, (q15_t)0x7F4D, - (q15_t)0x0C8B, (q15_t)0x7F62, (q15_t)0x0BC3, (q15_t)0x7F75, - (q15_t)0x0AFB, (q15_t)0x7F87, (q15_t)0x0A33, (q15_t)0x7F97, - (q15_t)0x096A, (q15_t)0x7FA7, (q15_t)0x08A2, (q15_t)0x7FB5, - (q15_t)0x07D9, (q15_t)0x7FC2, (q15_t)0x0710, (q15_t)0x7FCE, - (q15_t)0x0647, (q15_t)0x7FD8, (q15_t)0x057F, (q15_t)0x7FE1, - (q15_t)0x04B6, (q15_t)0x7FE9, (q15_t)0x03ED, (q15_t)0x7FF0, - (q15_t)0x0324, (q15_t)0x7FF6, (q15_t)0x025B, (q15_t)0x7FFA, - (q15_t)0x0192, (q15_t)0x7FFD, (q15_t)0x00C9, (q15_t)0x7FFF, - (q15_t)0x0000, (q15_t)0x7FFF, (q15_t)0xFF36, (q15_t)0x7FFF, - (q15_t)0xFE6D, (q15_t)0x7FFD, (q15_t)0xFDA4, (q15_t)0x7FFA, - (q15_t)0xFCDB, (q15_t)0x7FF6, (q15_t)0xFC12, (q15_t)0x7FF0, - (q15_t)0xFB49, (q15_t)0x7FE9, (q15_t)0xFA80, (q15_t)0x7FE1, - (q15_t)0xF9B8, (q15_t)0x7FD8, (q15_t)0xF8EF, (q15_t)0x7FCE, - (q15_t)0xF826, (q15_t)0x7FC2, (q15_t)0xF75D, (q15_t)0x7FB5, - (q15_t)0xF695, (q15_t)0x7FA7, (q15_t)0xF5CC, (q15_t)0x7F97, - (q15_t)0xF504, (q15_t)0x7F87, (q15_t)0xF43C, (q15_t)0x7F75, - (q15_t)0xF374, (q15_t)0x7F62, (q15_t)0xF2AC, (q15_t)0x7F4D, - (q15_t)0xF1E4, (q15_t)0x7F38, (q15_t)0xF11C, (q15_t)0x7F21, - (q15_t)0xF054, (q15_t)0x7F09, (q15_t)0xEF8D, (q15_t)0x7EF0, - (q15_t)0xEEC6, (q15_t)0x7ED5, (q15_t)0xEDFE, (q15_t)0x7EBA, - (q15_t)0xED37, (q15_t)0x7E9D, (q15_t)0xEC71, (q15_t)0x7E7F, - (q15_t)0xEBAA, (q15_t)0x7E5F, (q15_t)0xEAE4, (q15_t)0x7E3F, - (q15_t)0xEA1D, (q15_t)0x7E1D, (q15_t)0xE957, (q15_t)0x7DFA, - (q15_t)0xE892, (q15_t)0x7DD6, (q15_t)0xE7CC, (q15_t)0x7DB0, - (q15_t)0xE707, (q15_t)0x7D8A, (q15_t)0xE642, (q15_t)0x7D62, - (q15_t)0xE57D, (q15_t)0x7D39, (q15_t)0xE4B8, (q15_t)0x7D0F, - (q15_t)0xE3F4, (q15_t)0x7CE3, (q15_t)0xE330, (q15_t)0x7CB7, - (q15_t)0xE26C, (q15_t)0x7C89, (q15_t)0xE1A9, (q15_t)0x7C5A, - (q15_t)0xE0E6, (q15_t)0x7C29, (q15_t)0xE023, (q15_t)0x7BF8, - (q15_t)0xDF60, (q15_t)0x7BC5, (q15_t)0xDE9E, (q15_t)0x7B92, - (q15_t)0xDDDC, (q15_t)0x7B5D, (q15_t)0xDD1A, (q15_t)0x7B26, - (q15_t)0xDC59, (q15_t)0x7AEF, (q15_t)0xDB98, (q15_t)0x7AB6, - (q15_t)0xDAD7, (q15_t)0x7A7D, (q15_t)0xDA17, (q15_t)0x7A42, - (q15_t)0xD957, (q15_t)0x7A05, (q15_t)0xD898, (q15_t)0x79C8, - (q15_t)0xD7D9, (q15_t)0x798A, (q15_t)0xD71A, (q15_t)0x794A, - (q15_t)0xD65C, (q15_t)0x7909, (q15_t)0xD59E, (q15_t)0x78C7, - (q15_t)0xD4E0, (q15_t)0x7884, (q15_t)0xD423, (q15_t)0x7840, - (q15_t)0xD367, (q15_t)0x77FA, (q15_t)0xD2AA, (q15_t)0x77B4, - (q15_t)0xD1EE, (q15_t)0x776C, (q15_t)0xD133, (q15_t)0x7723, - (q15_t)0xD078, (q15_t)0x76D9, (q15_t)0xCFBE, (q15_t)0x768E, - (q15_t)0xCF04, (q15_t)0x7641, (q15_t)0xCE4A, (q15_t)0x75F4, - (q15_t)0xCD91, (q15_t)0x75A5, (q15_t)0xCCD9, (q15_t)0x7555, - (q15_t)0xCC21, (q15_t)0x7504, (q15_t)0xCB69, (q15_t)0x74B2, - (q15_t)0xCAB2, (q15_t)0x745F, (q15_t)0xC9FB, (q15_t)0x740B, - (q15_t)0xC945, (q15_t)0x73B5, (q15_t)0xC890, (q15_t)0x735F, - (q15_t)0xC7DB, (q15_t)0x7307, (q15_t)0xC727, (q15_t)0x72AF, - (q15_t)0xC673, (q15_t)0x7255, (q15_t)0xC5BF, (q15_t)0x71FA, - (q15_t)0xC50D, (q15_t)0x719E, (q15_t)0xC45A, (q15_t)0x7141, - (q15_t)0xC3A9, (q15_t)0x70E2, (q15_t)0xC2F8, (q15_t)0x7083, - (q15_t)0xC247, (q15_t)0x7023, (q15_t)0xC197, (q15_t)0x6FC1, - (q15_t)0xC0E8, (q15_t)0x6F5F, (q15_t)0xC03A, (q15_t)0x6EFB, - (q15_t)0xBF8C, (q15_t)0x6E96, (q15_t)0xBEDE, (q15_t)0x6E30, - (q15_t)0xBE31, (q15_t)0x6DCA, (q15_t)0xBD85, (q15_t)0x6D62, - (q15_t)0xBCDA, (q15_t)0x6CF9, (q15_t)0xBC2F, (q15_t)0x6C8F, - (q15_t)0xBB85, (q15_t)0x6C24, (q15_t)0xBADB, (q15_t)0x6BB8, - (q15_t)0xBA32, (q15_t)0x6B4A, (q15_t)0xB98A, (q15_t)0x6ADC, - (q15_t)0xB8E3, (q15_t)0x6A6D, (q15_t)0xB83C, (q15_t)0x69FD, - (q15_t)0xB796, (q15_t)0x698C, (q15_t)0xB6F0, (q15_t)0x6919, - (q15_t)0xB64B, (q15_t)0x68A6, (q15_t)0xB5A7, (q15_t)0x6832, - (q15_t)0xB504, (q15_t)0x67BD, (q15_t)0xB461, (q15_t)0x6746, - (q15_t)0xB3C0, (q15_t)0x66CF, (q15_t)0xB31E, (q15_t)0x6657, - (q15_t)0xB27E, (q15_t)0x65DD, (q15_t)0xB1DE, (q15_t)0x6563, - (q15_t)0xB140, (q15_t)0x64E8, (q15_t)0xB0A1, (q15_t)0x646C, - (q15_t)0xB004, (q15_t)0x63EF, (q15_t)0xAF68, (q15_t)0x6371, - (q15_t)0xAECC, (q15_t)0x62F2, (q15_t)0xAE31, (q15_t)0x6271, - (q15_t)0xAD96, (q15_t)0x61F1, (q15_t)0xACFD, (q15_t)0x616F, - (q15_t)0xAC64, (q15_t)0x60EC, (q15_t)0xABCC, (q15_t)0x6068, - (q15_t)0xAB35, (q15_t)0x5FE3, (q15_t)0xAA9F, (q15_t)0x5F5E, - (q15_t)0xAA0A, (q15_t)0x5ED7, (q15_t)0xA975, (q15_t)0x5E50, - (q15_t)0xA8E2, (q15_t)0x5DC7, (q15_t)0xA84F, (q15_t)0x5D3E, - (q15_t)0xA7BD, (q15_t)0x5CB4, (q15_t)0xA72B, (q15_t)0x5C29, - (q15_t)0xA69B, (q15_t)0x5B9D, (q15_t)0xA60C, (q15_t)0x5B10, - (q15_t)0xA57D, (q15_t)0x5A82, (q15_t)0xA4EF, (q15_t)0x59F3, - (q15_t)0xA462, (q15_t)0x5964, (q15_t)0xA3D6, (q15_t)0x58D4, - (q15_t)0xA34B, (q15_t)0x5842, (q15_t)0xA2C1, (q15_t)0x57B0, - (q15_t)0xA238, (q15_t)0x571D, (q15_t)0xA1AF, (q15_t)0x568A, - (q15_t)0xA128, (q15_t)0x55F5, (q15_t)0xA0A1, (q15_t)0x5560, - (q15_t)0xA01C, (q15_t)0x54CA, (q15_t)0x9F97, (q15_t)0x5433, - (q15_t)0x9F13, (q15_t)0x539B, (q15_t)0x9E90, (q15_t)0x5302, - (q15_t)0x9E0E, (q15_t)0x5269, (q15_t)0x9D8E, (q15_t)0x51CE, - (q15_t)0x9D0D, (q15_t)0x5133, (q15_t)0x9C8E, (q15_t)0x5097, - (q15_t)0x9C10, (q15_t)0x4FFB, (q15_t)0x9B93, (q15_t)0x4F5E, - (q15_t)0x9B17, (q15_t)0x4EBF, (q15_t)0x9A9C, (q15_t)0x4E21, - (q15_t)0x9A22, (q15_t)0x4D81, (q15_t)0x99A8, (q15_t)0x4CE1, - (q15_t)0x9930, (q15_t)0x4C3F, (q15_t)0x98B9, (q15_t)0x4B9E, - (q15_t)0x9842, (q15_t)0x4AFB, (q15_t)0x97CD, (q15_t)0x4A58, - (q15_t)0x9759, (q15_t)0x49B4, (q15_t)0x96E6, (q15_t)0x490F, - (q15_t)0x9673, (q15_t)0x4869, (q15_t)0x9602, (q15_t)0x47C3, - (q15_t)0x9592, (q15_t)0x471C, (q15_t)0x9523, (q15_t)0x4675, - (q15_t)0x94B5, (q15_t)0x45CD, (q15_t)0x9447, (q15_t)0x4524, - (q15_t)0x93DB, (q15_t)0x447A, (q15_t)0x9370, (q15_t)0x43D0, - (q15_t)0x9306, (q15_t)0x4325, (q15_t)0x929D, (q15_t)0x427A, - (q15_t)0x9235, (q15_t)0x41CE, (q15_t)0x91CF, (q15_t)0x4121, - (q15_t)0x9169, (q15_t)0x4073, (q15_t)0x9104, (q15_t)0x3FC5, - (q15_t)0x90A0, (q15_t)0x3F17, (q15_t)0x903E, (q15_t)0x3E68, - (q15_t)0x8FDC, (q15_t)0x3DB8, (q15_t)0x8F7C, (q15_t)0x3D07, - (q15_t)0x8F1D, (q15_t)0x3C56, (q15_t)0x8EBE, (q15_t)0x3BA5, - (q15_t)0x8E61, (q15_t)0x3AF2, (q15_t)0x8E05, (q15_t)0x3A40, - (q15_t)0x8DAA, (q15_t)0x398C, (q15_t)0x8D50, (q15_t)0x38D8, - (q15_t)0x8CF8, (q15_t)0x3824, (q15_t)0x8CA0, (q15_t)0x376F, - (q15_t)0x8C4A, (q15_t)0x36BA, (q15_t)0x8BF4, (q15_t)0x3604, - (q15_t)0x8BA0, (q15_t)0x354D, (q15_t)0x8B4D, (q15_t)0x3496, - (q15_t)0x8AFB, (q15_t)0x33DE, (q15_t)0x8AAA, (q15_t)0x3326, - (q15_t)0x8A5A, (q15_t)0x326E, (q15_t)0x8A0B, (q15_t)0x31B5, - (q15_t)0x89BE, (q15_t)0x30FB, (q15_t)0x8971, (q15_t)0x3041, - (q15_t)0x8926, (q15_t)0x2F87, (q15_t)0x88DC, (q15_t)0x2ECC, - (q15_t)0x8893, (q15_t)0x2E11, (q15_t)0x884B, (q15_t)0x2D55, - (q15_t)0x8805, (q15_t)0x2C98, (q15_t)0x87BF, (q15_t)0x2BDC, - (q15_t)0x877B, (q15_t)0x2B1F, (q15_t)0x8738, (q15_t)0x2A61, - (q15_t)0x86F6, (q15_t)0x29A3, (q15_t)0x86B5, (q15_t)0x28E5, - (q15_t)0x8675, (q15_t)0x2826, (q15_t)0x8637, (q15_t)0x2767, - (q15_t)0x85FA, (q15_t)0x26A8, (q15_t)0x85BD, (q15_t)0x25E8, - (q15_t)0x8582, (q15_t)0x2528, (q15_t)0x8549, (q15_t)0x2467, - (q15_t)0x8510, (q15_t)0x23A6, (q15_t)0x84D9, (q15_t)0x22E5, - (q15_t)0x84A2, (q15_t)0x2223, (q15_t)0x846D, (q15_t)0x2161, - (q15_t)0x843A, (q15_t)0x209F, (q15_t)0x8407, (q15_t)0x1FDC, - (q15_t)0x83D6, (q15_t)0x1F19, (q15_t)0x83A5, (q15_t)0x1E56, - (q15_t)0x8376, (q15_t)0x1D93, (q15_t)0x8348, (q15_t)0x1CCF, - (q15_t)0x831C, (q15_t)0x1C0B, (q15_t)0x82F0, (q15_t)0x1B47, - (q15_t)0x82C6, (q15_t)0x1A82, (q15_t)0x829D, (q15_t)0x19BD, - (q15_t)0x8275, (q15_t)0x18F8, (q15_t)0x824F, (q15_t)0x1833, - (q15_t)0x8229, (q15_t)0x176D, (q15_t)0x8205, (q15_t)0x16A8, - (q15_t)0x81E2, (q15_t)0x15E2, (q15_t)0x81C0, (q15_t)0x151B, - (q15_t)0x81A0, (q15_t)0x1455, (q15_t)0x8180, (q15_t)0x138E, - (q15_t)0x8162, (q15_t)0x12C8, (q15_t)0x8145, (q15_t)0x1201, - (q15_t)0x812A, (q15_t)0x1139, (q15_t)0x810F, (q15_t)0x1072, - (q15_t)0x80F6, (q15_t)0x0FAB, (q15_t)0x80DE, (q15_t)0x0EE3, - (q15_t)0x80C7, (q15_t)0x0E1B, (q15_t)0x80B2, (q15_t)0x0D53, - (q15_t)0x809D, (q15_t)0x0C8B, (q15_t)0x808A, (q15_t)0x0BC3, - (q15_t)0x8078, (q15_t)0x0AFB, (q15_t)0x8068, (q15_t)0x0A33, - (q15_t)0x8058, (q15_t)0x096A, (q15_t)0x804A, (q15_t)0x08A2, - (q15_t)0x803D, (q15_t)0x07D9, (q15_t)0x8031, (q15_t)0x0710, - (q15_t)0x8027, (q15_t)0x0647, (q15_t)0x801E, (q15_t)0x057F, - (q15_t)0x8016, (q15_t)0x04B6, (q15_t)0x800F, (q15_t)0x03ED, - (q15_t)0x8009, (q15_t)0x0324, (q15_t)0x8005, (q15_t)0x025B, - (q15_t)0x8002, (q15_t)0x0192, (q15_t)0x8000, (q15_t)0x00C9, - (q15_t)0x8000, (q15_t)0x0000, (q15_t)0x8000, (q15_t)0xFF36, - (q15_t)0x8002, (q15_t)0xFE6D, (q15_t)0x8005, (q15_t)0xFDA4, - (q15_t)0x8009, (q15_t)0xFCDB, (q15_t)0x800F, (q15_t)0xFC12, - (q15_t)0x8016, (q15_t)0xFB49, (q15_t)0x801E, (q15_t)0xFA80, - (q15_t)0x8027, (q15_t)0xF9B8, (q15_t)0x8031, (q15_t)0xF8EF, - (q15_t)0x803D, (q15_t)0xF826, (q15_t)0x804A, (q15_t)0xF75D, - (q15_t)0x8058, (q15_t)0xF695, (q15_t)0x8068, (q15_t)0xF5CC, - (q15_t)0x8078, (q15_t)0xF504, (q15_t)0x808A, (q15_t)0xF43C, - (q15_t)0x809D, (q15_t)0xF374, (q15_t)0x80B2, (q15_t)0xF2AC, - (q15_t)0x80C7, (q15_t)0xF1E4, (q15_t)0x80DE, (q15_t)0xF11C, - (q15_t)0x80F6, (q15_t)0xF054, (q15_t)0x810F, (q15_t)0xEF8D, - (q15_t)0x812A, (q15_t)0xEEC6, (q15_t)0x8145, (q15_t)0xEDFE, - (q15_t)0x8162, (q15_t)0xED37, (q15_t)0x8180, (q15_t)0xEC71, - (q15_t)0x81A0, (q15_t)0xEBAA, (q15_t)0x81C0, (q15_t)0xEAE4, - (q15_t)0x81E2, (q15_t)0xEA1D, (q15_t)0x8205, (q15_t)0xE957, - (q15_t)0x8229, (q15_t)0xE892, (q15_t)0x824F, (q15_t)0xE7CC, - (q15_t)0x8275, (q15_t)0xE707, (q15_t)0x829D, (q15_t)0xE642, - (q15_t)0x82C6, (q15_t)0xE57D, (q15_t)0x82F0, (q15_t)0xE4B8, - (q15_t)0x831C, (q15_t)0xE3F4, (q15_t)0x8348, (q15_t)0xE330, - (q15_t)0x8376, (q15_t)0xE26C, (q15_t)0x83A5, (q15_t)0xE1A9, - (q15_t)0x83D6, (q15_t)0xE0E6, (q15_t)0x8407, (q15_t)0xE023, - (q15_t)0x843A, (q15_t)0xDF60, (q15_t)0x846D, (q15_t)0xDE9E, - (q15_t)0x84A2, (q15_t)0xDDDC, (q15_t)0x84D9, (q15_t)0xDD1A, - (q15_t)0x8510, (q15_t)0xDC59, (q15_t)0x8549, (q15_t)0xDB98, - (q15_t)0x8582, (q15_t)0xDAD7, (q15_t)0x85BD, (q15_t)0xDA17, - (q15_t)0x85FA, (q15_t)0xD957, (q15_t)0x8637, (q15_t)0xD898, - (q15_t)0x8675, (q15_t)0xD7D9, (q15_t)0x86B5, (q15_t)0xD71A, - (q15_t)0x86F6, (q15_t)0xD65C, (q15_t)0x8738, (q15_t)0xD59E, - (q15_t)0x877B, (q15_t)0xD4E0, (q15_t)0x87BF, (q15_t)0xD423, - (q15_t)0x8805, (q15_t)0xD367, (q15_t)0x884B, (q15_t)0xD2AA, - (q15_t)0x8893, (q15_t)0xD1EE, (q15_t)0x88DC, (q15_t)0xD133, - (q15_t)0x8926, (q15_t)0xD078, (q15_t)0x8971, (q15_t)0xCFBE, - (q15_t)0x89BE, (q15_t)0xCF04, (q15_t)0x8A0B, (q15_t)0xCE4A, - (q15_t)0x8A5A, (q15_t)0xCD91, (q15_t)0x8AAA, (q15_t)0xCCD9, - (q15_t)0x8AFB, (q15_t)0xCC21, (q15_t)0x8B4D, (q15_t)0xCB69, - (q15_t)0x8BA0, (q15_t)0xCAB2, (q15_t)0x8BF4, (q15_t)0xC9FB, - (q15_t)0x8C4A, (q15_t)0xC945, (q15_t)0x8CA0, (q15_t)0xC890, - (q15_t)0x8CF8, (q15_t)0xC7DB, (q15_t)0x8D50, (q15_t)0xC727, - (q15_t)0x8DAA, (q15_t)0xC673, (q15_t)0x8E05, (q15_t)0xC5BF, - (q15_t)0x8E61, (q15_t)0xC50D, (q15_t)0x8EBE, (q15_t)0xC45A, - (q15_t)0x8F1D, (q15_t)0xC3A9, (q15_t)0x8F7C, (q15_t)0xC2F8, - (q15_t)0x8FDC, (q15_t)0xC247, (q15_t)0x903E, (q15_t)0xC197, - (q15_t)0x90A0, (q15_t)0xC0E8, (q15_t)0x9104, (q15_t)0xC03A, - (q15_t)0x9169, (q15_t)0xBF8C, (q15_t)0x91CF, (q15_t)0xBEDE, - (q15_t)0x9235, (q15_t)0xBE31, (q15_t)0x929D, (q15_t)0xBD85, - (q15_t)0x9306, (q15_t)0xBCDA, (q15_t)0x9370, (q15_t)0xBC2F, - (q15_t)0x93DB, (q15_t)0xBB85, (q15_t)0x9447, (q15_t)0xBADB, - (q15_t)0x94B5, (q15_t)0xBA32, (q15_t)0x9523, (q15_t)0xB98A, - (q15_t)0x9592, (q15_t)0xB8E3, (q15_t)0x9602, (q15_t)0xB83C, - (q15_t)0x9673, (q15_t)0xB796, (q15_t)0x96E6, (q15_t)0xB6F0, - (q15_t)0x9759, (q15_t)0xB64B, (q15_t)0x97CD, (q15_t)0xB5A7, - (q15_t)0x9842, (q15_t)0xB504, (q15_t)0x98B9, (q15_t)0xB461, - (q15_t)0x9930, (q15_t)0xB3C0, (q15_t)0x99A8, (q15_t)0xB31E, - (q15_t)0x9A22, (q15_t)0xB27E, (q15_t)0x9A9C, (q15_t)0xB1DE, - (q15_t)0x9B17, (q15_t)0xB140, (q15_t)0x9B93, (q15_t)0xB0A1, - (q15_t)0x9C10, (q15_t)0xB004, (q15_t)0x9C8E, (q15_t)0xAF68, - (q15_t)0x9D0D, (q15_t)0xAECC, (q15_t)0x9D8E, (q15_t)0xAE31, - (q15_t)0x9E0E, (q15_t)0xAD96, (q15_t)0x9E90, (q15_t)0xACFD, - (q15_t)0x9F13, (q15_t)0xAC64, (q15_t)0x9F97, (q15_t)0xABCC, - (q15_t)0xA01C, (q15_t)0xAB35, (q15_t)0xA0A1, (q15_t)0xAA9F, - (q15_t)0xA128, (q15_t)0xAA0A, (q15_t)0xA1AF, (q15_t)0xA975, - (q15_t)0xA238, (q15_t)0xA8E2, (q15_t)0xA2C1, (q15_t)0xA84F, - (q15_t)0xA34B, (q15_t)0xA7BD, (q15_t)0xA3D6, (q15_t)0xA72B, - (q15_t)0xA462, (q15_t)0xA69B, (q15_t)0xA4EF, (q15_t)0xA60C, - (q15_t)0xA57D, (q15_t)0xA57D, (q15_t)0xA60C, (q15_t)0xA4EF, - (q15_t)0xA69B, (q15_t)0xA462, (q15_t)0xA72B, (q15_t)0xA3D6, - (q15_t)0xA7BD, (q15_t)0xA34B, (q15_t)0xA84F, (q15_t)0xA2C1, - (q15_t)0xA8E2, (q15_t)0xA238, (q15_t)0xA975, (q15_t)0xA1AF, - (q15_t)0xAA0A, (q15_t)0xA128, (q15_t)0xAA9F, (q15_t)0xA0A1, - (q15_t)0xAB35, (q15_t)0xA01C, (q15_t)0xABCC, (q15_t)0x9F97, - (q15_t)0xAC64, (q15_t)0x9F13, (q15_t)0xACFD, (q15_t)0x9E90, - (q15_t)0xAD96, (q15_t)0x9E0E, (q15_t)0xAE31, (q15_t)0x9D8E, - (q15_t)0xAECC, (q15_t)0x9D0D, (q15_t)0xAF68, (q15_t)0x9C8E, - (q15_t)0xB004, (q15_t)0x9C10, (q15_t)0xB0A1, (q15_t)0x9B93, - (q15_t)0xB140, (q15_t)0x9B17, (q15_t)0xB1DE, (q15_t)0x9A9C, - (q15_t)0xB27E, (q15_t)0x9A22, (q15_t)0xB31E, (q15_t)0x99A8, - (q15_t)0xB3C0, (q15_t)0x9930, (q15_t)0xB461, (q15_t)0x98B9, - (q15_t)0xB504, (q15_t)0x9842, (q15_t)0xB5A7, (q15_t)0x97CD, - (q15_t)0xB64B, (q15_t)0x9759, (q15_t)0xB6F0, (q15_t)0x96E6, - (q15_t)0xB796, (q15_t)0x9673, (q15_t)0xB83C, (q15_t)0x9602, - (q15_t)0xB8E3, (q15_t)0x9592, (q15_t)0xB98A, (q15_t)0x9523, - (q15_t)0xBA32, (q15_t)0x94B5, (q15_t)0xBADB, (q15_t)0x9447, - (q15_t)0xBB85, (q15_t)0x93DB, (q15_t)0xBC2F, (q15_t)0x9370, - (q15_t)0xBCDA, (q15_t)0x9306, (q15_t)0xBD85, (q15_t)0x929D, - (q15_t)0xBE31, (q15_t)0x9235, (q15_t)0xBEDE, (q15_t)0x91CF, - (q15_t)0xBF8C, (q15_t)0x9169, (q15_t)0xC03A, (q15_t)0x9104, - (q15_t)0xC0E8, (q15_t)0x90A0, (q15_t)0xC197, (q15_t)0x903E, - (q15_t)0xC247, (q15_t)0x8FDC, (q15_t)0xC2F8, (q15_t)0x8F7C, - (q15_t)0xC3A9, (q15_t)0x8F1D, (q15_t)0xC45A, (q15_t)0x8EBE, - (q15_t)0xC50D, (q15_t)0x8E61, (q15_t)0xC5BF, (q15_t)0x8E05, - (q15_t)0xC673, (q15_t)0x8DAA, (q15_t)0xC727, (q15_t)0x8D50, - (q15_t)0xC7DB, (q15_t)0x8CF8, (q15_t)0xC890, (q15_t)0x8CA0, - (q15_t)0xC945, (q15_t)0x8C4A, (q15_t)0xC9FB, (q15_t)0x8BF4, - (q15_t)0xCAB2, (q15_t)0x8BA0, (q15_t)0xCB69, (q15_t)0x8B4D, - (q15_t)0xCC21, (q15_t)0x8AFB, (q15_t)0xCCD9, (q15_t)0x8AAA, - (q15_t)0xCD91, (q15_t)0x8A5A, (q15_t)0xCE4A, (q15_t)0x8A0B, - (q15_t)0xCF04, (q15_t)0x89BE, (q15_t)0xCFBE, (q15_t)0x8971, - (q15_t)0xD078, (q15_t)0x8926, (q15_t)0xD133, (q15_t)0x88DC, - (q15_t)0xD1EE, (q15_t)0x8893, (q15_t)0xD2AA, (q15_t)0x884B, - (q15_t)0xD367, (q15_t)0x8805, (q15_t)0xD423, (q15_t)0x87BF, - (q15_t)0xD4E0, (q15_t)0x877B, (q15_t)0xD59E, (q15_t)0x8738, - (q15_t)0xD65C, (q15_t)0x86F6, (q15_t)0xD71A, (q15_t)0x86B5, - (q15_t)0xD7D9, (q15_t)0x8675, (q15_t)0xD898, (q15_t)0x8637, - (q15_t)0xD957, (q15_t)0x85FA, (q15_t)0xDA17, (q15_t)0x85BD, - (q15_t)0xDAD7, (q15_t)0x8582, (q15_t)0xDB98, (q15_t)0x8549, - (q15_t)0xDC59, (q15_t)0x8510, (q15_t)0xDD1A, (q15_t)0x84D9, - (q15_t)0xDDDC, (q15_t)0x84A2, (q15_t)0xDE9E, (q15_t)0x846D, - (q15_t)0xDF60, (q15_t)0x843A, (q15_t)0xE023, (q15_t)0x8407, - (q15_t)0xE0E6, (q15_t)0x83D6, (q15_t)0xE1A9, (q15_t)0x83A5, - (q15_t)0xE26C, (q15_t)0x8376, (q15_t)0xE330, (q15_t)0x8348, - (q15_t)0xE3F4, (q15_t)0x831C, (q15_t)0xE4B8, (q15_t)0x82F0, - (q15_t)0xE57D, (q15_t)0x82C6, (q15_t)0xE642, (q15_t)0x829D, - (q15_t)0xE707, (q15_t)0x8275, (q15_t)0xE7CC, (q15_t)0x824F, - (q15_t)0xE892, (q15_t)0x8229, (q15_t)0xE957, (q15_t)0x8205, - (q15_t)0xEA1D, (q15_t)0x81E2, (q15_t)0xEAE4, (q15_t)0x81C0, - (q15_t)0xEBAA, (q15_t)0x81A0, (q15_t)0xEC71, (q15_t)0x8180, - (q15_t)0xED37, (q15_t)0x8162, (q15_t)0xEDFE, (q15_t)0x8145, - (q15_t)0xEEC6, (q15_t)0x812A, (q15_t)0xEF8D, (q15_t)0x810F, - (q15_t)0xF054, (q15_t)0x80F6, (q15_t)0xF11C, (q15_t)0x80DE, - (q15_t)0xF1E4, (q15_t)0x80C7, (q15_t)0xF2AC, (q15_t)0x80B2, - (q15_t)0xF374, (q15_t)0x809D, (q15_t)0xF43C, (q15_t)0x808A, - (q15_t)0xF504, (q15_t)0x8078, (q15_t)0xF5CC, (q15_t)0x8068, - (q15_t)0xF695, (q15_t)0x8058, (q15_t)0xF75D, (q15_t)0x804A, - (q15_t)0xF826, (q15_t)0x803D, (q15_t)0xF8EF, (q15_t)0x8031, - (q15_t)0xF9B8, (q15_t)0x8027, (q15_t)0xFA80, (q15_t)0x801E, - (q15_t)0xFB49, (q15_t)0x8016, (q15_t)0xFC12, (q15_t)0x800F, - (q15_t)0xFCDB, (q15_t)0x8009, (q15_t)0xFDA4, (q15_t)0x8005, - (q15_t)0xFE6D, (q15_t)0x8002, (q15_t)0xFF36, (q15_t)0x8000 -}; + (q15_t)0x7FFF, (q15_t)0x0000, (q15_t)0x7FFF, (q15_t)0x00C9, (q15_t)0x7FFD, + (q15_t)0x0192, (q15_t)0x7FFA, (q15_t)0x025B, (q15_t)0x7FF6, (q15_t)0x0324, + (q15_t)0x7FF0, (q15_t)0x03ED, (q15_t)0x7FE9, (q15_t)0x04B6, (q15_t)0x7FE1, + (q15_t)0x057F, (q15_t)0x7FD8, (q15_t)0x0647, (q15_t)0x7FCE, (q15_t)0x0710, + (q15_t)0x7FC2, (q15_t)0x07D9, (q15_t)0x7FB5, (q15_t)0x08A2, (q15_t)0x7FA7, + (q15_t)0x096A, (q15_t)0x7F97, (q15_t)0x0A33, (q15_t)0x7F87, (q15_t)0x0AFB, + (q15_t)0x7F75, (q15_t)0x0BC3, (q15_t)0x7F62, (q15_t)0x0C8B, (q15_t)0x7F4D, + (q15_t)0x0D53, (q15_t)0x7F38, (q15_t)0x0E1B, (q15_t)0x7F21, (q15_t)0x0EE3, + (q15_t)0x7F09, (q15_t)0x0FAB, (q15_t)0x7EF0, (q15_t)0x1072, (q15_t)0x7ED5, + (q15_t)0x1139, (q15_t)0x7EBA, (q15_t)0x1201, (q15_t)0x7E9D, (q15_t)0x12C8, + (q15_t)0x7E7F, (q15_t)0x138E, (q15_t)0x7E5F, (q15_t)0x1455, (q15_t)0x7E3F, + (q15_t)0x151B, (q15_t)0x7E1D, (q15_t)0x15E2, (q15_t)0x7DFA, (q15_t)0x16A8, + (q15_t)0x7DD6, (q15_t)0x176D, (q15_t)0x7DB0, (q15_t)0x1833, (q15_t)0x7D8A, + (q15_t)0x18F8, (q15_t)0x7D62, (q15_t)0x19BD, (q15_t)0x7D39, (q15_t)0x1A82, + (q15_t)0x7D0F, (q15_t)0x1B47, (q15_t)0x7CE3, (q15_t)0x1C0B, (q15_t)0x7CB7, + (q15_t)0x1CCF, (q15_t)0x7C89, (q15_t)0x1D93, (q15_t)0x7C5A, (q15_t)0x1E56, + (q15_t)0x7C29, (q15_t)0x1F19, (q15_t)0x7BF8, (q15_t)0x1FDC, (q15_t)0x7BC5, + (q15_t)0x209F, (q15_t)0x7B92, (q15_t)0x2161, (q15_t)0x7B5D, (q15_t)0x2223, + (q15_t)0x7B26, (q15_t)0x22E5, (q15_t)0x7AEF, (q15_t)0x23A6, (q15_t)0x7AB6, + (q15_t)0x2467, (q15_t)0x7A7D, (q15_t)0x2528, (q15_t)0x7A42, (q15_t)0x25E8, + (q15_t)0x7A05, (q15_t)0x26A8, (q15_t)0x79C8, (q15_t)0x2767, (q15_t)0x798A, + (q15_t)0x2826, (q15_t)0x794A, (q15_t)0x28E5, (q15_t)0x7909, (q15_t)0x29A3, + (q15_t)0x78C7, (q15_t)0x2A61, (q15_t)0x7884, (q15_t)0x2B1F, (q15_t)0x7840, + (q15_t)0x2BDC, (q15_t)0x77FA, (q15_t)0x2C98, (q15_t)0x77B4, (q15_t)0x2D55, + (q15_t)0x776C, (q15_t)0x2E11, (q15_t)0x7723, (q15_t)0x2ECC, (q15_t)0x76D9, + (q15_t)0x2F87, (q15_t)0x768E, (q15_t)0x3041, (q15_t)0x7641, (q15_t)0x30FB, + (q15_t)0x75F4, (q15_t)0x31B5, (q15_t)0x75A5, (q15_t)0x326E, (q15_t)0x7555, + (q15_t)0x3326, (q15_t)0x7504, (q15_t)0x33DE, (q15_t)0x74B2, (q15_t)0x3496, + (q15_t)0x745F, (q15_t)0x354D, (q15_t)0x740B, (q15_t)0x3604, (q15_t)0x73B5, + (q15_t)0x36BA, (q15_t)0x735F, (q15_t)0x376F, (q15_t)0x7307, (q15_t)0x3824, + (q15_t)0x72AF, (q15_t)0x38D8, (q15_t)0x7255, (q15_t)0x398C, (q15_t)0x71FA, + (q15_t)0x3A40, (q15_t)0x719E, (q15_t)0x3AF2, (q15_t)0x7141, (q15_t)0x3BA5, + (q15_t)0x70E2, (q15_t)0x3C56, (q15_t)0x7083, (q15_t)0x3D07, (q15_t)0x7023, + (q15_t)0x3DB8, (q15_t)0x6FC1, (q15_t)0x3E68, (q15_t)0x6F5F, (q15_t)0x3F17, + (q15_t)0x6EFB, (q15_t)0x3FC5, (q15_t)0x6E96, (q15_t)0x4073, (q15_t)0x6E30, + (q15_t)0x4121, (q15_t)0x6DCA, (q15_t)0x41CE, (q15_t)0x6D62, (q15_t)0x427A, + (q15_t)0x6CF9, (q15_t)0x4325, (q15_t)0x6C8F, (q15_t)0x43D0, (q15_t)0x6C24, + (q15_t)0x447A, (q15_t)0x6BB8, (q15_t)0x4524, (q15_t)0x6B4A, (q15_t)0x45CD, + (q15_t)0x6ADC, (q15_t)0x4675, (q15_t)0x6A6D, (q15_t)0x471C, (q15_t)0x69FD, + (q15_t)0x47C3, (q15_t)0x698C, (q15_t)0x4869, (q15_t)0x6919, (q15_t)0x490F, + (q15_t)0x68A6, (q15_t)0x49B4, (q15_t)0x6832, (q15_t)0x4A58, (q15_t)0x67BD, + (q15_t)0x4AFB, (q15_t)0x6746, (q15_t)0x4B9E, (q15_t)0x66CF, (q15_t)0x4C3F, + (q15_t)0x6657, (q15_t)0x4CE1, (q15_t)0x65DD, (q15_t)0x4D81, (q15_t)0x6563, + (q15_t)0x4E21, (q15_t)0x64E8, (q15_t)0x4EBF, (q15_t)0x646C, (q15_t)0x4F5E, + (q15_t)0x63EF, (q15_t)0x4FFB, (q15_t)0x6371, (q15_t)0x5097, (q15_t)0x62F2, + (q15_t)0x5133, (q15_t)0x6271, (q15_t)0x51CE, (q15_t)0x61F1, (q15_t)0x5269, + (q15_t)0x616F, (q15_t)0x5302, (q15_t)0x60EC, (q15_t)0x539B, (q15_t)0x6068, + (q15_t)0x5433, (q15_t)0x5FE3, (q15_t)0x54CA, (q15_t)0x5F5E, (q15_t)0x5560, + (q15_t)0x5ED7, (q15_t)0x55F5, (q15_t)0x5E50, (q15_t)0x568A, (q15_t)0x5DC7, + (q15_t)0x571D, (q15_t)0x5D3E, (q15_t)0x57B0, (q15_t)0x5CB4, (q15_t)0x5842, + (q15_t)0x5C29, (q15_t)0x58D4, (q15_t)0x5B9D, (q15_t)0x5964, (q15_t)0x5B10, + (q15_t)0x59F3, (q15_t)0x5A82, (q15_t)0x5A82, (q15_t)0x59F3, (q15_t)0x5B10, + (q15_t)0x5964, (q15_t)0x5B9D, (q15_t)0x58D4, (q15_t)0x5C29, (q15_t)0x5842, + (q15_t)0x5CB4, (q15_t)0x57B0, (q15_t)0x5D3E, (q15_t)0x571D, (q15_t)0x5DC7, + (q15_t)0x568A, (q15_t)0x5E50, (q15_t)0x55F5, (q15_t)0x5ED7, (q15_t)0x5560, + (q15_t)0x5F5E, (q15_t)0x54CA, (q15_t)0x5FE3, (q15_t)0x5433, (q15_t)0x6068, + (q15_t)0x539B, (q15_t)0x60EC, (q15_t)0x5302, (q15_t)0x616F, (q15_t)0x5269, + (q15_t)0x61F1, (q15_t)0x51CE, (q15_t)0x6271, (q15_t)0x5133, (q15_t)0x62F2, + (q15_t)0x5097, (q15_t)0x6371, (q15_t)0x4FFB, (q15_t)0x63EF, (q15_t)0x4F5E, + (q15_t)0x646C, (q15_t)0x4EBF, (q15_t)0x64E8, (q15_t)0x4E21, (q15_t)0x6563, + (q15_t)0x4D81, (q15_t)0x65DD, (q15_t)0x4CE1, (q15_t)0x6657, (q15_t)0x4C3F, + (q15_t)0x66CF, (q15_t)0x4B9E, (q15_t)0x6746, (q15_t)0x4AFB, (q15_t)0x67BD, + (q15_t)0x4A58, (q15_t)0x6832, (q15_t)0x49B4, (q15_t)0x68A6, (q15_t)0x490F, + (q15_t)0x6919, (q15_t)0x4869, (q15_t)0x698C, (q15_t)0x47C3, (q15_t)0x69FD, + (q15_t)0x471C, (q15_t)0x6A6D, (q15_t)0x4675, (q15_t)0x6ADC, (q15_t)0x45CD, + (q15_t)0x6B4A, (q15_t)0x4524, (q15_t)0x6BB8, (q15_t)0x447A, (q15_t)0x6C24, + (q15_t)0x43D0, (q15_t)0x6C8F, (q15_t)0x4325, (q15_t)0x6CF9, (q15_t)0x427A, + (q15_t)0x6D62, (q15_t)0x41CE, (q15_t)0x6DCA, (q15_t)0x4121, (q15_t)0x6E30, + (q15_t)0x4073, (q15_t)0x6E96, (q15_t)0x3FC5, (q15_t)0x6EFB, (q15_t)0x3F17, + (q15_t)0x6F5F, (q15_t)0x3E68, (q15_t)0x6FC1, (q15_t)0x3DB8, (q15_t)0x7023, + (q15_t)0x3D07, (q15_t)0x7083, (q15_t)0x3C56, (q15_t)0x70E2, (q15_t)0x3BA5, + (q15_t)0x7141, (q15_t)0x3AF2, (q15_t)0x719E, (q15_t)0x3A40, (q15_t)0x71FA, + (q15_t)0x398C, (q15_t)0x7255, (q15_t)0x38D8, (q15_t)0x72AF, (q15_t)0x3824, + (q15_t)0x7307, (q15_t)0x376F, (q15_t)0x735F, (q15_t)0x36BA, (q15_t)0x73B5, + (q15_t)0x3604, (q15_t)0x740B, (q15_t)0x354D, (q15_t)0x745F, (q15_t)0x3496, + (q15_t)0x74B2, (q15_t)0x33DE, (q15_t)0x7504, (q15_t)0x3326, (q15_t)0x7555, + (q15_t)0x326E, (q15_t)0x75A5, (q15_t)0x31B5, (q15_t)0x75F4, (q15_t)0x30FB, + (q15_t)0x7641, (q15_t)0x3041, (q15_t)0x768E, (q15_t)0x2F87, (q15_t)0x76D9, + (q15_t)0x2ECC, (q15_t)0x7723, (q15_t)0x2E11, (q15_t)0x776C, (q15_t)0x2D55, + (q15_t)0x77B4, (q15_t)0x2C98, (q15_t)0x77FA, (q15_t)0x2BDC, (q15_t)0x7840, + (q15_t)0x2B1F, (q15_t)0x7884, (q15_t)0x2A61, (q15_t)0x78C7, (q15_t)0x29A3, + (q15_t)0x7909, (q15_t)0x28E5, (q15_t)0x794A, (q15_t)0x2826, (q15_t)0x798A, + (q15_t)0x2767, (q15_t)0x79C8, (q15_t)0x26A8, (q15_t)0x7A05, (q15_t)0x25E8, + (q15_t)0x7A42, (q15_t)0x2528, (q15_t)0x7A7D, (q15_t)0x2467, (q15_t)0x7AB6, + (q15_t)0x23A6, (q15_t)0x7AEF, (q15_t)0x22E5, (q15_t)0x7B26, (q15_t)0x2223, + (q15_t)0x7B5D, (q15_t)0x2161, (q15_t)0x7B92, (q15_t)0x209F, (q15_t)0x7BC5, + (q15_t)0x1FDC, (q15_t)0x7BF8, (q15_t)0x1F19, (q15_t)0x7C29, (q15_t)0x1E56, + (q15_t)0x7C5A, (q15_t)0x1D93, (q15_t)0x7C89, (q15_t)0x1CCF, (q15_t)0x7CB7, + (q15_t)0x1C0B, (q15_t)0x7CE3, (q15_t)0x1B47, (q15_t)0x7D0F, (q15_t)0x1A82, + (q15_t)0x7D39, (q15_t)0x19BD, (q15_t)0x7D62, (q15_t)0x18F8, (q15_t)0x7D8A, + (q15_t)0x1833, (q15_t)0x7DB0, (q15_t)0x176D, (q15_t)0x7DD6, (q15_t)0x16A8, + (q15_t)0x7DFA, (q15_t)0x15E2, (q15_t)0x7E1D, (q15_t)0x151B, (q15_t)0x7E3F, + (q15_t)0x1455, (q15_t)0x7E5F, (q15_t)0x138E, (q15_t)0x7E7F, (q15_t)0x12C8, + (q15_t)0x7E9D, (q15_t)0x1201, (q15_t)0x7EBA, (q15_t)0x1139, (q15_t)0x7ED5, + (q15_t)0x1072, (q15_t)0x7EF0, (q15_t)0x0FAB, (q15_t)0x7F09, (q15_t)0x0EE3, + (q15_t)0x7F21, (q15_t)0x0E1B, (q15_t)0x7F38, (q15_t)0x0D53, (q15_t)0x7F4D, + (q15_t)0x0C8B, (q15_t)0x7F62, (q15_t)0x0BC3, (q15_t)0x7F75, (q15_t)0x0AFB, + (q15_t)0x7F87, (q15_t)0x0A33, (q15_t)0x7F97, (q15_t)0x096A, (q15_t)0x7FA7, + (q15_t)0x08A2, (q15_t)0x7FB5, (q15_t)0x07D9, (q15_t)0x7FC2, (q15_t)0x0710, + (q15_t)0x7FCE, (q15_t)0x0647, (q15_t)0x7FD8, (q15_t)0x057F, (q15_t)0x7FE1, + (q15_t)0x04B6, (q15_t)0x7FE9, (q15_t)0x03ED, (q15_t)0x7FF0, (q15_t)0x0324, + (q15_t)0x7FF6, (q15_t)0x025B, (q15_t)0x7FFA, (q15_t)0x0192, (q15_t)0x7FFD, + (q15_t)0x00C9, (q15_t)0x7FFF, (q15_t)0x0000, (q15_t)0x7FFF, (q15_t)0xFF36, + (q15_t)0x7FFF, (q15_t)0xFE6D, (q15_t)0x7FFD, (q15_t)0xFDA4, (q15_t)0x7FFA, + (q15_t)0xFCDB, (q15_t)0x7FF6, (q15_t)0xFC12, (q15_t)0x7FF0, (q15_t)0xFB49, + (q15_t)0x7FE9, (q15_t)0xFA80, (q15_t)0x7FE1, (q15_t)0xF9B8, (q15_t)0x7FD8, + (q15_t)0xF8EF, (q15_t)0x7FCE, (q15_t)0xF826, (q15_t)0x7FC2, (q15_t)0xF75D, + (q15_t)0x7FB5, (q15_t)0xF695, (q15_t)0x7FA7, (q15_t)0xF5CC, (q15_t)0x7F97, + (q15_t)0xF504, (q15_t)0x7F87, (q15_t)0xF43C, (q15_t)0x7F75, (q15_t)0xF374, + (q15_t)0x7F62, (q15_t)0xF2AC, (q15_t)0x7F4D, (q15_t)0xF1E4, (q15_t)0x7F38, + (q15_t)0xF11C, (q15_t)0x7F21, (q15_t)0xF054, (q15_t)0x7F09, (q15_t)0xEF8D, + (q15_t)0x7EF0, (q15_t)0xEEC6, (q15_t)0x7ED5, (q15_t)0xEDFE, (q15_t)0x7EBA, + (q15_t)0xED37, (q15_t)0x7E9D, (q15_t)0xEC71, (q15_t)0x7E7F, (q15_t)0xEBAA, + (q15_t)0x7E5F, (q15_t)0xEAE4, (q15_t)0x7E3F, (q15_t)0xEA1D, (q15_t)0x7E1D, + (q15_t)0xE957, (q15_t)0x7DFA, (q15_t)0xE892, (q15_t)0x7DD6, (q15_t)0xE7CC, + (q15_t)0x7DB0, (q15_t)0xE707, (q15_t)0x7D8A, (q15_t)0xE642, (q15_t)0x7D62, + (q15_t)0xE57D, (q15_t)0x7D39, (q15_t)0xE4B8, (q15_t)0x7D0F, (q15_t)0xE3F4, + (q15_t)0x7CE3, (q15_t)0xE330, (q15_t)0x7CB7, (q15_t)0xE26C, (q15_t)0x7C89, + (q15_t)0xE1A9, (q15_t)0x7C5A, (q15_t)0xE0E6, (q15_t)0x7C29, (q15_t)0xE023, + (q15_t)0x7BF8, (q15_t)0xDF60, (q15_t)0x7BC5, (q15_t)0xDE9E, (q15_t)0x7B92, + (q15_t)0xDDDC, (q15_t)0x7B5D, (q15_t)0xDD1A, (q15_t)0x7B26, (q15_t)0xDC59, + (q15_t)0x7AEF, (q15_t)0xDB98, (q15_t)0x7AB6, (q15_t)0xDAD7, (q15_t)0x7A7D, + (q15_t)0xDA17, (q15_t)0x7A42, (q15_t)0xD957, (q15_t)0x7A05, (q15_t)0xD898, + (q15_t)0x79C8, (q15_t)0xD7D9, (q15_t)0x798A, (q15_t)0xD71A, (q15_t)0x794A, + (q15_t)0xD65C, (q15_t)0x7909, (q15_t)0xD59E, (q15_t)0x78C7, (q15_t)0xD4E0, + (q15_t)0x7884, (q15_t)0xD423, (q15_t)0x7840, (q15_t)0xD367, (q15_t)0x77FA, + (q15_t)0xD2AA, (q15_t)0x77B4, (q15_t)0xD1EE, (q15_t)0x776C, (q15_t)0xD133, + (q15_t)0x7723, (q15_t)0xD078, (q15_t)0x76D9, (q15_t)0xCFBE, (q15_t)0x768E, + (q15_t)0xCF04, (q15_t)0x7641, (q15_t)0xCE4A, (q15_t)0x75F4, (q15_t)0xCD91, + (q15_t)0x75A5, (q15_t)0xCCD9, (q15_t)0x7555, (q15_t)0xCC21, (q15_t)0x7504, + (q15_t)0xCB69, (q15_t)0x74B2, (q15_t)0xCAB2, (q15_t)0x745F, (q15_t)0xC9FB, + (q15_t)0x740B, (q15_t)0xC945, (q15_t)0x73B5, (q15_t)0xC890, (q15_t)0x735F, + (q15_t)0xC7DB, (q15_t)0x7307, (q15_t)0xC727, (q15_t)0x72AF, (q15_t)0xC673, + (q15_t)0x7255, (q15_t)0xC5BF, (q15_t)0x71FA, (q15_t)0xC50D, (q15_t)0x719E, + (q15_t)0xC45A, (q15_t)0x7141, (q15_t)0xC3A9, (q15_t)0x70E2, (q15_t)0xC2F8, + (q15_t)0x7083, (q15_t)0xC247, (q15_t)0x7023, (q15_t)0xC197, (q15_t)0x6FC1, + (q15_t)0xC0E8, (q15_t)0x6F5F, (q15_t)0xC03A, (q15_t)0x6EFB, (q15_t)0xBF8C, + (q15_t)0x6E96, (q15_t)0xBEDE, (q15_t)0x6E30, (q15_t)0xBE31, (q15_t)0x6DCA, + (q15_t)0xBD85, (q15_t)0x6D62, (q15_t)0xBCDA, (q15_t)0x6CF9, (q15_t)0xBC2F, + (q15_t)0x6C8F, (q15_t)0xBB85, (q15_t)0x6C24, (q15_t)0xBADB, (q15_t)0x6BB8, + (q15_t)0xBA32, (q15_t)0x6B4A, (q15_t)0xB98A, (q15_t)0x6ADC, (q15_t)0xB8E3, + (q15_t)0x6A6D, (q15_t)0xB83C, (q15_t)0x69FD, (q15_t)0xB796, (q15_t)0x698C, + (q15_t)0xB6F0, (q15_t)0x6919, (q15_t)0xB64B, (q15_t)0x68A6, (q15_t)0xB5A7, + (q15_t)0x6832, (q15_t)0xB504, (q15_t)0x67BD, (q15_t)0xB461, (q15_t)0x6746, + (q15_t)0xB3C0, (q15_t)0x66CF, (q15_t)0xB31E, (q15_t)0x6657, (q15_t)0xB27E, + (q15_t)0x65DD, (q15_t)0xB1DE, (q15_t)0x6563, (q15_t)0xB140, (q15_t)0x64E8, + (q15_t)0xB0A1, (q15_t)0x646C, (q15_t)0xB004, (q15_t)0x63EF, (q15_t)0xAF68, + (q15_t)0x6371, (q15_t)0xAECC, (q15_t)0x62F2, (q15_t)0xAE31, (q15_t)0x6271, + (q15_t)0xAD96, (q15_t)0x61F1, (q15_t)0xACFD, (q15_t)0x616F, (q15_t)0xAC64, + (q15_t)0x60EC, (q15_t)0xABCC, (q15_t)0x6068, (q15_t)0xAB35, (q15_t)0x5FE3, + (q15_t)0xAA9F, (q15_t)0x5F5E, (q15_t)0xAA0A, (q15_t)0x5ED7, (q15_t)0xA975, + (q15_t)0x5E50, (q15_t)0xA8E2, (q15_t)0x5DC7, (q15_t)0xA84F, (q15_t)0x5D3E, + (q15_t)0xA7BD, (q15_t)0x5CB4, (q15_t)0xA72B, (q15_t)0x5C29, (q15_t)0xA69B, + (q15_t)0x5B9D, (q15_t)0xA60C, (q15_t)0x5B10, (q15_t)0xA57D, (q15_t)0x5A82, + (q15_t)0xA4EF, (q15_t)0x59F3, (q15_t)0xA462, (q15_t)0x5964, (q15_t)0xA3D6, + (q15_t)0x58D4, (q15_t)0xA34B, (q15_t)0x5842, (q15_t)0xA2C1, (q15_t)0x57B0, + (q15_t)0xA238, (q15_t)0x571D, (q15_t)0xA1AF, (q15_t)0x568A, (q15_t)0xA128, + (q15_t)0x55F5, (q15_t)0xA0A1, (q15_t)0x5560, (q15_t)0xA01C, (q15_t)0x54CA, + (q15_t)0x9F97, (q15_t)0x5433, (q15_t)0x9F13, (q15_t)0x539B, (q15_t)0x9E90, + (q15_t)0x5302, (q15_t)0x9E0E, (q15_t)0x5269, (q15_t)0x9D8E, (q15_t)0x51CE, + (q15_t)0x9D0D, (q15_t)0x5133, (q15_t)0x9C8E, (q15_t)0x5097, (q15_t)0x9C10, + (q15_t)0x4FFB, (q15_t)0x9B93, (q15_t)0x4F5E, (q15_t)0x9B17, (q15_t)0x4EBF, + (q15_t)0x9A9C, (q15_t)0x4E21, (q15_t)0x9A22, (q15_t)0x4D81, (q15_t)0x99A8, + (q15_t)0x4CE1, (q15_t)0x9930, (q15_t)0x4C3F, (q15_t)0x98B9, (q15_t)0x4B9E, + (q15_t)0x9842, (q15_t)0x4AFB, (q15_t)0x97CD, (q15_t)0x4A58, (q15_t)0x9759, + (q15_t)0x49B4, (q15_t)0x96E6, (q15_t)0x490F, (q15_t)0x9673, (q15_t)0x4869, + (q15_t)0x9602, (q15_t)0x47C3, (q15_t)0x9592, (q15_t)0x471C, (q15_t)0x9523, + (q15_t)0x4675, (q15_t)0x94B5, (q15_t)0x45CD, (q15_t)0x9447, (q15_t)0x4524, + (q15_t)0x93DB, (q15_t)0x447A, (q15_t)0x9370, (q15_t)0x43D0, (q15_t)0x9306, + (q15_t)0x4325, (q15_t)0x929D, (q15_t)0x427A, (q15_t)0x9235, (q15_t)0x41CE, + (q15_t)0x91CF, (q15_t)0x4121, (q15_t)0x9169, (q15_t)0x4073, (q15_t)0x9104, + (q15_t)0x3FC5, (q15_t)0x90A0, (q15_t)0x3F17, (q15_t)0x903E, (q15_t)0x3E68, + (q15_t)0x8FDC, (q15_t)0x3DB8, (q15_t)0x8F7C, (q15_t)0x3D07, (q15_t)0x8F1D, + (q15_t)0x3C56, (q15_t)0x8EBE, (q15_t)0x3BA5, (q15_t)0x8E61, (q15_t)0x3AF2, + (q15_t)0x8E05, (q15_t)0x3A40, (q15_t)0x8DAA, (q15_t)0x398C, (q15_t)0x8D50, + (q15_t)0x38D8, (q15_t)0x8CF8, (q15_t)0x3824, (q15_t)0x8CA0, (q15_t)0x376F, + (q15_t)0x8C4A, (q15_t)0x36BA, (q15_t)0x8BF4, (q15_t)0x3604, (q15_t)0x8BA0, + (q15_t)0x354D, (q15_t)0x8B4D, (q15_t)0x3496, (q15_t)0x8AFB, (q15_t)0x33DE, + (q15_t)0x8AAA, (q15_t)0x3326, (q15_t)0x8A5A, (q15_t)0x326E, (q15_t)0x8A0B, + (q15_t)0x31B5, (q15_t)0x89BE, (q15_t)0x30FB, (q15_t)0x8971, (q15_t)0x3041, + (q15_t)0x8926, (q15_t)0x2F87, (q15_t)0x88DC, (q15_t)0x2ECC, (q15_t)0x8893, + (q15_t)0x2E11, (q15_t)0x884B, (q15_t)0x2D55, (q15_t)0x8805, (q15_t)0x2C98, + (q15_t)0x87BF, (q15_t)0x2BDC, (q15_t)0x877B, (q15_t)0x2B1F, (q15_t)0x8738, + (q15_t)0x2A61, (q15_t)0x86F6, (q15_t)0x29A3, (q15_t)0x86B5, (q15_t)0x28E5, + (q15_t)0x8675, (q15_t)0x2826, (q15_t)0x8637, (q15_t)0x2767, (q15_t)0x85FA, + (q15_t)0x26A8, (q15_t)0x85BD, (q15_t)0x25E8, (q15_t)0x8582, (q15_t)0x2528, + (q15_t)0x8549, (q15_t)0x2467, (q15_t)0x8510, (q15_t)0x23A6, (q15_t)0x84D9, + (q15_t)0x22E5, (q15_t)0x84A2, (q15_t)0x2223, (q15_t)0x846D, (q15_t)0x2161, + (q15_t)0x843A, (q15_t)0x209F, (q15_t)0x8407, (q15_t)0x1FDC, (q15_t)0x83D6, + (q15_t)0x1F19, (q15_t)0x83A5, (q15_t)0x1E56, (q15_t)0x8376, (q15_t)0x1D93, + (q15_t)0x8348, (q15_t)0x1CCF, (q15_t)0x831C, (q15_t)0x1C0B, (q15_t)0x82F0, + (q15_t)0x1B47, (q15_t)0x82C6, (q15_t)0x1A82, (q15_t)0x829D, (q15_t)0x19BD, + (q15_t)0x8275, (q15_t)0x18F8, (q15_t)0x824F, (q15_t)0x1833, (q15_t)0x8229, + (q15_t)0x176D, (q15_t)0x8205, (q15_t)0x16A8, (q15_t)0x81E2, (q15_t)0x15E2, + (q15_t)0x81C0, (q15_t)0x151B, (q15_t)0x81A0, (q15_t)0x1455, (q15_t)0x8180, + (q15_t)0x138E, (q15_t)0x8162, (q15_t)0x12C8, (q15_t)0x8145, (q15_t)0x1201, + (q15_t)0x812A, (q15_t)0x1139, (q15_t)0x810F, (q15_t)0x1072, (q15_t)0x80F6, + (q15_t)0x0FAB, (q15_t)0x80DE, (q15_t)0x0EE3, (q15_t)0x80C7, (q15_t)0x0E1B, + (q15_t)0x80B2, (q15_t)0x0D53, (q15_t)0x809D, (q15_t)0x0C8B, (q15_t)0x808A, + (q15_t)0x0BC3, (q15_t)0x8078, (q15_t)0x0AFB, (q15_t)0x8068, (q15_t)0x0A33, + (q15_t)0x8058, (q15_t)0x096A, (q15_t)0x804A, (q15_t)0x08A2, (q15_t)0x803D, + (q15_t)0x07D9, (q15_t)0x8031, (q15_t)0x0710, (q15_t)0x8027, (q15_t)0x0647, + (q15_t)0x801E, (q15_t)0x057F, (q15_t)0x8016, (q15_t)0x04B6, (q15_t)0x800F, + (q15_t)0x03ED, (q15_t)0x8009, (q15_t)0x0324, (q15_t)0x8005, (q15_t)0x025B, + (q15_t)0x8002, (q15_t)0x0192, (q15_t)0x8000, (q15_t)0x00C9, (q15_t)0x8000, + (q15_t)0x0000, (q15_t)0x8000, (q15_t)0xFF36, (q15_t)0x8002, (q15_t)0xFE6D, + (q15_t)0x8005, (q15_t)0xFDA4, (q15_t)0x8009, (q15_t)0xFCDB, (q15_t)0x800F, + (q15_t)0xFC12, (q15_t)0x8016, (q15_t)0xFB49, (q15_t)0x801E, (q15_t)0xFA80, + (q15_t)0x8027, (q15_t)0xF9B8, (q15_t)0x8031, (q15_t)0xF8EF, (q15_t)0x803D, + (q15_t)0xF826, (q15_t)0x804A, (q15_t)0xF75D, (q15_t)0x8058, (q15_t)0xF695, + (q15_t)0x8068, (q15_t)0xF5CC, (q15_t)0x8078, (q15_t)0xF504, (q15_t)0x808A, + (q15_t)0xF43C, (q15_t)0x809D, (q15_t)0xF374, (q15_t)0x80B2, (q15_t)0xF2AC, + (q15_t)0x80C7, (q15_t)0xF1E4, (q15_t)0x80DE, (q15_t)0xF11C, (q15_t)0x80F6, + (q15_t)0xF054, (q15_t)0x810F, (q15_t)0xEF8D, (q15_t)0x812A, (q15_t)0xEEC6, + (q15_t)0x8145, (q15_t)0xEDFE, (q15_t)0x8162, (q15_t)0xED37, (q15_t)0x8180, + (q15_t)0xEC71, (q15_t)0x81A0, (q15_t)0xEBAA, (q15_t)0x81C0, (q15_t)0xEAE4, + (q15_t)0x81E2, (q15_t)0xEA1D, (q15_t)0x8205, (q15_t)0xE957, (q15_t)0x8229, + (q15_t)0xE892, (q15_t)0x824F, (q15_t)0xE7CC, (q15_t)0x8275, (q15_t)0xE707, + (q15_t)0x829D, (q15_t)0xE642, (q15_t)0x82C6, (q15_t)0xE57D, (q15_t)0x82F0, + (q15_t)0xE4B8, (q15_t)0x831C, (q15_t)0xE3F4, (q15_t)0x8348, (q15_t)0xE330, + (q15_t)0x8376, (q15_t)0xE26C, (q15_t)0x83A5, (q15_t)0xE1A9, (q15_t)0x83D6, + (q15_t)0xE0E6, (q15_t)0x8407, (q15_t)0xE023, (q15_t)0x843A, (q15_t)0xDF60, + (q15_t)0x846D, (q15_t)0xDE9E, (q15_t)0x84A2, (q15_t)0xDDDC, (q15_t)0x84D9, + (q15_t)0xDD1A, (q15_t)0x8510, (q15_t)0xDC59, (q15_t)0x8549, (q15_t)0xDB98, + (q15_t)0x8582, (q15_t)0xDAD7, (q15_t)0x85BD, (q15_t)0xDA17, (q15_t)0x85FA, + (q15_t)0xD957, (q15_t)0x8637, (q15_t)0xD898, (q15_t)0x8675, (q15_t)0xD7D9, + (q15_t)0x86B5, (q15_t)0xD71A, (q15_t)0x86F6, (q15_t)0xD65C, (q15_t)0x8738, + (q15_t)0xD59E, (q15_t)0x877B, (q15_t)0xD4E0, (q15_t)0x87BF, (q15_t)0xD423, + (q15_t)0x8805, (q15_t)0xD367, (q15_t)0x884B, (q15_t)0xD2AA, (q15_t)0x8893, + (q15_t)0xD1EE, (q15_t)0x88DC, (q15_t)0xD133, (q15_t)0x8926, (q15_t)0xD078, + (q15_t)0x8971, (q15_t)0xCFBE, (q15_t)0x89BE, (q15_t)0xCF04, (q15_t)0x8A0B, + (q15_t)0xCE4A, (q15_t)0x8A5A, (q15_t)0xCD91, (q15_t)0x8AAA, (q15_t)0xCCD9, + (q15_t)0x8AFB, (q15_t)0xCC21, (q15_t)0x8B4D, (q15_t)0xCB69, (q15_t)0x8BA0, + (q15_t)0xCAB2, (q15_t)0x8BF4, (q15_t)0xC9FB, (q15_t)0x8C4A, (q15_t)0xC945, + (q15_t)0x8CA0, (q15_t)0xC890, (q15_t)0x8CF8, (q15_t)0xC7DB, (q15_t)0x8D50, + (q15_t)0xC727, (q15_t)0x8DAA, (q15_t)0xC673, (q15_t)0x8E05, (q15_t)0xC5BF, + (q15_t)0x8E61, (q15_t)0xC50D, (q15_t)0x8EBE, (q15_t)0xC45A, (q15_t)0x8F1D, + (q15_t)0xC3A9, (q15_t)0x8F7C, (q15_t)0xC2F8, (q15_t)0x8FDC, (q15_t)0xC247, + (q15_t)0x903E, (q15_t)0xC197, (q15_t)0x90A0, (q15_t)0xC0E8, (q15_t)0x9104, + (q15_t)0xC03A, (q15_t)0x9169, (q15_t)0xBF8C, (q15_t)0x91CF, (q15_t)0xBEDE, + (q15_t)0x9235, (q15_t)0xBE31, (q15_t)0x929D, (q15_t)0xBD85, (q15_t)0x9306, + (q15_t)0xBCDA, (q15_t)0x9370, (q15_t)0xBC2F, (q15_t)0x93DB, (q15_t)0xBB85, + (q15_t)0x9447, (q15_t)0xBADB, (q15_t)0x94B5, (q15_t)0xBA32, (q15_t)0x9523, + (q15_t)0xB98A, (q15_t)0x9592, (q15_t)0xB8E3, (q15_t)0x9602, (q15_t)0xB83C, + (q15_t)0x9673, (q15_t)0xB796, (q15_t)0x96E6, (q15_t)0xB6F0, (q15_t)0x9759, + (q15_t)0xB64B, (q15_t)0x97CD, (q15_t)0xB5A7, (q15_t)0x9842, (q15_t)0xB504, + (q15_t)0x98B9, (q15_t)0xB461, (q15_t)0x9930, (q15_t)0xB3C0, (q15_t)0x99A8, + (q15_t)0xB31E, (q15_t)0x9A22, (q15_t)0xB27E, (q15_t)0x9A9C, (q15_t)0xB1DE, + (q15_t)0x9B17, (q15_t)0xB140, (q15_t)0x9B93, (q15_t)0xB0A1, (q15_t)0x9C10, + (q15_t)0xB004, (q15_t)0x9C8E, (q15_t)0xAF68, (q15_t)0x9D0D, (q15_t)0xAECC, + (q15_t)0x9D8E, (q15_t)0xAE31, (q15_t)0x9E0E, (q15_t)0xAD96, (q15_t)0x9E90, + (q15_t)0xACFD, (q15_t)0x9F13, (q15_t)0xAC64, (q15_t)0x9F97, (q15_t)0xABCC, + (q15_t)0xA01C, (q15_t)0xAB35, (q15_t)0xA0A1, (q15_t)0xAA9F, (q15_t)0xA128, + (q15_t)0xAA0A, (q15_t)0xA1AF, (q15_t)0xA975, (q15_t)0xA238, (q15_t)0xA8E2, + (q15_t)0xA2C1, (q15_t)0xA84F, (q15_t)0xA34B, (q15_t)0xA7BD, (q15_t)0xA3D6, + (q15_t)0xA72B, (q15_t)0xA462, (q15_t)0xA69B, (q15_t)0xA4EF, (q15_t)0xA60C, + (q15_t)0xA57D, (q15_t)0xA57D, (q15_t)0xA60C, (q15_t)0xA4EF, (q15_t)0xA69B, + (q15_t)0xA462, (q15_t)0xA72B, (q15_t)0xA3D6, (q15_t)0xA7BD, (q15_t)0xA34B, + (q15_t)0xA84F, (q15_t)0xA2C1, (q15_t)0xA8E2, (q15_t)0xA238, (q15_t)0xA975, + (q15_t)0xA1AF, (q15_t)0xAA0A, (q15_t)0xA128, (q15_t)0xAA9F, (q15_t)0xA0A1, + (q15_t)0xAB35, (q15_t)0xA01C, (q15_t)0xABCC, (q15_t)0x9F97, (q15_t)0xAC64, + (q15_t)0x9F13, (q15_t)0xACFD, (q15_t)0x9E90, (q15_t)0xAD96, (q15_t)0x9E0E, + (q15_t)0xAE31, (q15_t)0x9D8E, (q15_t)0xAECC, (q15_t)0x9D0D, (q15_t)0xAF68, + (q15_t)0x9C8E, (q15_t)0xB004, (q15_t)0x9C10, (q15_t)0xB0A1, (q15_t)0x9B93, + (q15_t)0xB140, (q15_t)0x9B17, (q15_t)0xB1DE, (q15_t)0x9A9C, (q15_t)0xB27E, + (q15_t)0x9A22, (q15_t)0xB31E, (q15_t)0x99A8, (q15_t)0xB3C0, (q15_t)0x9930, + (q15_t)0xB461, (q15_t)0x98B9, (q15_t)0xB504, (q15_t)0x9842, (q15_t)0xB5A7, + (q15_t)0x97CD, (q15_t)0xB64B, (q15_t)0x9759, (q15_t)0xB6F0, (q15_t)0x96E6, + (q15_t)0xB796, (q15_t)0x9673, (q15_t)0xB83C, (q15_t)0x9602, (q15_t)0xB8E3, + (q15_t)0x9592, (q15_t)0xB98A, (q15_t)0x9523, (q15_t)0xBA32, (q15_t)0x94B5, + (q15_t)0xBADB, (q15_t)0x9447, (q15_t)0xBB85, (q15_t)0x93DB, (q15_t)0xBC2F, + (q15_t)0x9370, (q15_t)0xBCDA, (q15_t)0x9306, (q15_t)0xBD85, (q15_t)0x929D, + (q15_t)0xBE31, (q15_t)0x9235, (q15_t)0xBEDE, (q15_t)0x91CF, (q15_t)0xBF8C, + (q15_t)0x9169, (q15_t)0xC03A, (q15_t)0x9104, (q15_t)0xC0E8, (q15_t)0x90A0, + (q15_t)0xC197, (q15_t)0x903E, (q15_t)0xC247, (q15_t)0x8FDC, (q15_t)0xC2F8, + (q15_t)0x8F7C, (q15_t)0xC3A9, (q15_t)0x8F1D, (q15_t)0xC45A, (q15_t)0x8EBE, + (q15_t)0xC50D, (q15_t)0x8E61, (q15_t)0xC5BF, (q15_t)0x8E05, (q15_t)0xC673, + (q15_t)0x8DAA, (q15_t)0xC727, (q15_t)0x8D50, (q15_t)0xC7DB, (q15_t)0x8CF8, + (q15_t)0xC890, (q15_t)0x8CA0, (q15_t)0xC945, (q15_t)0x8C4A, (q15_t)0xC9FB, + (q15_t)0x8BF4, (q15_t)0xCAB2, (q15_t)0x8BA0, (q15_t)0xCB69, (q15_t)0x8B4D, + (q15_t)0xCC21, (q15_t)0x8AFB, (q15_t)0xCCD9, (q15_t)0x8AAA, (q15_t)0xCD91, + (q15_t)0x8A5A, (q15_t)0xCE4A, (q15_t)0x8A0B, (q15_t)0xCF04, (q15_t)0x89BE, + (q15_t)0xCFBE, (q15_t)0x8971, (q15_t)0xD078, (q15_t)0x8926, (q15_t)0xD133, + (q15_t)0x88DC, (q15_t)0xD1EE, (q15_t)0x8893, (q15_t)0xD2AA, (q15_t)0x884B, + (q15_t)0xD367, (q15_t)0x8805, (q15_t)0xD423, (q15_t)0x87BF, (q15_t)0xD4E0, + (q15_t)0x877B, (q15_t)0xD59E, (q15_t)0x8738, (q15_t)0xD65C, (q15_t)0x86F6, + (q15_t)0xD71A, (q15_t)0x86B5, (q15_t)0xD7D9, (q15_t)0x8675, (q15_t)0xD898, + (q15_t)0x8637, (q15_t)0xD957, (q15_t)0x85FA, (q15_t)0xDA17, (q15_t)0x85BD, + (q15_t)0xDAD7, (q15_t)0x8582, (q15_t)0xDB98, (q15_t)0x8549, (q15_t)0xDC59, + (q15_t)0x8510, (q15_t)0xDD1A, (q15_t)0x84D9, (q15_t)0xDDDC, (q15_t)0x84A2, + (q15_t)0xDE9E, (q15_t)0x846D, (q15_t)0xDF60, (q15_t)0x843A, (q15_t)0xE023, + (q15_t)0x8407, (q15_t)0xE0E6, (q15_t)0x83D6, (q15_t)0xE1A9, (q15_t)0x83A5, + (q15_t)0xE26C, (q15_t)0x8376, (q15_t)0xE330, (q15_t)0x8348, (q15_t)0xE3F4, + (q15_t)0x831C, (q15_t)0xE4B8, (q15_t)0x82F0, (q15_t)0xE57D, (q15_t)0x82C6, + (q15_t)0xE642, (q15_t)0x829D, (q15_t)0xE707, (q15_t)0x8275, (q15_t)0xE7CC, + (q15_t)0x824F, (q15_t)0xE892, (q15_t)0x8229, (q15_t)0xE957, (q15_t)0x8205, + (q15_t)0xEA1D, (q15_t)0x81E2, (q15_t)0xEAE4, (q15_t)0x81C0, (q15_t)0xEBAA, + (q15_t)0x81A0, (q15_t)0xEC71, (q15_t)0x8180, (q15_t)0xED37, (q15_t)0x8162, + (q15_t)0xEDFE, (q15_t)0x8145, (q15_t)0xEEC6, (q15_t)0x812A, (q15_t)0xEF8D, + (q15_t)0x810F, (q15_t)0xF054, (q15_t)0x80F6, (q15_t)0xF11C, (q15_t)0x80DE, + (q15_t)0xF1E4, (q15_t)0x80C7, (q15_t)0xF2AC, (q15_t)0x80B2, (q15_t)0xF374, + (q15_t)0x809D, (q15_t)0xF43C, (q15_t)0x808A, (q15_t)0xF504, (q15_t)0x8078, + (q15_t)0xF5CC, (q15_t)0x8068, (q15_t)0xF695, (q15_t)0x8058, (q15_t)0xF75D, + (q15_t)0x804A, (q15_t)0xF826, (q15_t)0x803D, (q15_t)0xF8EF, (q15_t)0x8031, + (q15_t)0xF9B8, (q15_t)0x8027, (q15_t)0xFA80, (q15_t)0x801E, (q15_t)0xFB49, + (q15_t)0x8016, (q15_t)0xFC12, (q15_t)0x800F, (q15_t)0xFCDB, (q15_t)0x8009, + (q15_t)0xFDA4, (q15_t)0x8005, (q15_t)0xFE6D, (q15_t)0x8002, (q15_t)0xFF36, + (q15_t)0x8000}; /** @par @@ -13735,778 +7593,624 @@ const q15_t twiddleCoef_1024_q15[1536] = { Cos and Sin values are interleaved fashion @par Convert Floating point to q15(Fixed point 1.15): - round(twiddleCoefq15(i) * pow(2, 15)) + round(twiddleCoefq15(i) * pow(2, 15)) */ const q15_t twiddleCoef_2048_q15[3072] = { - (q15_t)0x7FFF, (q15_t)0x0000, (q15_t)0x7FFF, (q15_t)0x0064, - (q15_t)0x7FFF, (q15_t)0x00C9, (q15_t)0x7FFE, (q15_t)0x012D, - (q15_t)0x7FFD, (q15_t)0x0192, (q15_t)0x7FFC, (q15_t)0x01F6, - (q15_t)0x7FFA, (q15_t)0x025B, (q15_t)0x7FF8, (q15_t)0x02BF, - (q15_t)0x7FF6, (q15_t)0x0324, (q15_t)0x7FF3, (q15_t)0x0388, - (q15_t)0x7FF0, (q15_t)0x03ED, (q15_t)0x7FED, (q15_t)0x0451, - (q15_t)0x7FE9, (q15_t)0x04B6, (q15_t)0x7FE5, (q15_t)0x051A, - (q15_t)0x7FE1, (q15_t)0x057F, (q15_t)0x7FDD, (q15_t)0x05E3, - (q15_t)0x7FD8, (q15_t)0x0647, (q15_t)0x7FD3, (q15_t)0x06AC, - (q15_t)0x7FCE, (q15_t)0x0710, (q15_t)0x7FC8, (q15_t)0x0775, - (q15_t)0x7FC2, (q15_t)0x07D9, (q15_t)0x7FBC, (q15_t)0x083D, - (q15_t)0x7FB5, (q15_t)0x08A2, (q15_t)0x7FAE, (q15_t)0x0906, - (q15_t)0x7FA7, (q15_t)0x096A, (q15_t)0x7F9F, (q15_t)0x09CE, - (q15_t)0x7F97, (q15_t)0x0A33, (q15_t)0x7F8F, (q15_t)0x0A97, - (q15_t)0x7F87, (q15_t)0x0AFB, (q15_t)0x7F7E, (q15_t)0x0B5F, - (q15_t)0x7F75, (q15_t)0x0BC3, (q15_t)0x7F6B, (q15_t)0x0C27, - (q15_t)0x7F62, (q15_t)0x0C8B, (q15_t)0x7F58, (q15_t)0x0CEF, - (q15_t)0x7F4D, (q15_t)0x0D53, (q15_t)0x7F43, (q15_t)0x0DB7, - (q15_t)0x7F38, (q15_t)0x0E1B, (q15_t)0x7F2D, (q15_t)0x0E7F, - (q15_t)0x7F21, (q15_t)0x0EE3, (q15_t)0x7F15, (q15_t)0x0F47, - (q15_t)0x7F09, (q15_t)0x0FAB, (q15_t)0x7EFD, (q15_t)0x100E, - (q15_t)0x7EF0, (q15_t)0x1072, (q15_t)0x7EE3, (q15_t)0x10D6, - (q15_t)0x7ED5, (q15_t)0x1139, (q15_t)0x7EC8, (q15_t)0x119D, - (q15_t)0x7EBA, (q15_t)0x1201, (q15_t)0x7EAB, (q15_t)0x1264, - (q15_t)0x7E9D, (q15_t)0x12C8, (q15_t)0x7E8E, (q15_t)0x132B, - (q15_t)0x7E7F, (q15_t)0x138E, (q15_t)0x7E6F, (q15_t)0x13F2, - (q15_t)0x7E5F, (q15_t)0x1455, (q15_t)0x7E4F, (q15_t)0x14B8, - (q15_t)0x7E3F, (q15_t)0x151B, (q15_t)0x7E2E, (q15_t)0x157F, - (q15_t)0x7E1D, (q15_t)0x15E2, (q15_t)0x7E0C, (q15_t)0x1645, - (q15_t)0x7DFA, (q15_t)0x16A8, (q15_t)0x7DE8, (q15_t)0x170A, - (q15_t)0x7DD6, (q15_t)0x176D, (q15_t)0x7DC3, (q15_t)0x17D0, - (q15_t)0x7DB0, (q15_t)0x1833, (q15_t)0x7D9D, (q15_t)0x1896, - (q15_t)0x7D8A, (q15_t)0x18F8, (q15_t)0x7D76, (q15_t)0x195B, - (q15_t)0x7D62, (q15_t)0x19BD, (q15_t)0x7D4E, (q15_t)0x1A20, - (q15_t)0x7D39, (q15_t)0x1A82, (q15_t)0x7D24, (q15_t)0x1AE4, - (q15_t)0x7D0F, (q15_t)0x1B47, (q15_t)0x7CF9, (q15_t)0x1BA9, - (q15_t)0x7CE3, (q15_t)0x1C0B, (q15_t)0x7CCD, (q15_t)0x1C6D, - (q15_t)0x7CB7, (q15_t)0x1CCF, (q15_t)0x7CA0, (q15_t)0x1D31, - (q15_t)0x7C89, (q15_t)0x1D93, (q15_t)0x7C71, (q15_t)0x1DF5, - (q15_t)0x7C5A, (q15_t)0x1E56, (q15_t)0x7C42, (q15_t)0x1EB8, - (q15_t)0x7C29, (q15_t)0x1F19, (q15_t)0x7C11, (q15_t)0x1F7B, - (q15_t)0x7BF8, (q15_t)0x1FDC, (q15_t)0x7BDF, (q15_t)0x203E, - (q15_t)0x7BC5, (q15_t)0x209F, (q15_t)0x7BAC, (q15_t)0x2100, - (q15_t)0x7B92, (q15_t)0x2161, (q15_t)0x7B77, (q15_t)0x21C2, - (q15_t)0x7B5D, (q15_t)0x2223, (q15_t)0x7B42, (q15_t)0x2284, - (q15_t)0x7B26, (q15_t)0x22E5, (q15_t)0x7B0B, (q15_t)0x2345, - (q15_t)0x7AEF, (q15_t)0x23A6, (q15_t)0x7AD3, (q15_t)0x2407, - (q15_t)0x7AB6, (q15_t)0x2467, (q15_t)0x7A9A, (q15_t)0x24C7, - (q15_t)0x7A7D, (q15_t)0x2528, (q15_t)0x7A5F, (q15_t)0x2588, - (q15_t)0x7A42, (q15_t)0x25E8, (q15_t)0x7A24, (q15_t)0x2648, - (q15_t)0x7A05, (q15_t)0x26A8, (q15_t)0x79E7, (q15_t)0x2707, - (q15_t)0x79C8, (q15_t)0x2767, (q15_t)0x79A9, (q15_t)0x27C7, - (q15_t)0x798A, (q15_t)0x2826, (q15_t)0x796A, (q15_t)0x2886, - (q15_t)0x794A, (q15_t)0x28E5, (q15_t)0x792A, (q15_t)0x2944, - (q15_t)0x7909, (q15_t)0x29A3, (q15_t)0x78E8, (q15_t)0x2A02, - (q15_t)0x78C7, (q15_t)0x2A61, (q15_t)0x78A6, (q15_t)0x2AC0, - (q15_t)0x7884, (q15_t)0x2B1F, (q15_t)0x7862, (q15_t)0x2B7D, - (q15_t)0x7840, (q15_t)0x2BDC, (q15_t)0x781D, (q15_t)0x2C3A, - (q15_t)0x77FA, (q15_t)0x2C98, (q15_t)0x77D7, (q15_t)0x2CF7, - (q15_t)0x77B4, (q15_t)0x2D55, (q15_t)0x7790, (q15_t)0x2DB3, - (q15_t)0x776C, (q15_t)0x2E11, (q15_t)0x7747, (q15_t)0x2E6E, - (q15_t)0x7723, (q15_t)0x2ECC, (q15_t)0x76FE, (q15_t)0x2F29, - (q15_t)0x76D9, (q15_t)0x2F87, (q15_t)0x76B3, (q15_t)0x2FE4, - (q15_t)0x768E, (q15_t)0x3041, (q15_t)0x7668, (q15_t)0x309E, - (q15_t)0x7641, (q15_t)0x30FB, (q15_t)0x761B, (q15_t)0x3158, - (q15_t)0x75F4, (q15_t)0x31B5, (q15_t)0x75CC, (q15_t)0x3211, - (q15_t)0x75A5, (q15_t)0x326E, (q15_t)0x757D, (q15_t)0x32CA, - (q15_t)0x7555, (q15_t)0x3326, (q15_t)0x752D, (q15_t)0x3382, - (q15_t)0x7504, (q15_t)0x33DE, (q15_t)0x74DB, (q15_t)0x343A, - (q15_t)0x74B2, (q15_t)0x3496, (q15_t)0x7489, (q15_t)0x34F2, - (q15_t)0x745F, (q15_t)0x354D, (q15_t)0x7435, (q15_t)0x35A8, - (q15_t)0x740B, (q15_t)0x3604, (q15_t)0x73E0, (q15_t)0x365F, - (q15_t)0x73B5, (q15_t)0x36BA, (q15_t)0x738A, (q15_t)0x3714, - (q15_t)0x735F, (q15_t)0x376F, (q15_t)0x7333, (q15_t)0x37CA, - (q15_t)0x7307, (q15_t)0x3824, (q15_t)0x72DB, (q15_t)0x387E, - (q15_t)0x72AF, (q15_t)0x38D8, (q15_t)0x7282, (q15_t)0x3932, - (q15_t)0x7255, (q15_t)0x398C, (q15_t)0x7227, (q15_t)0x39E6, - (q15_t)0x71FA, (q15_t)0x3A40, (q15_t)0x71CC, (q15_t)0x3A99, - (q15_t)0x719E, (q15_t)0x3AF2, (q15_t)0x716F, (q15_t)0x3B4C, - (q15_t)0x7141, (q15_t)0x3BA5, (q15_t)0x7112, (q15_t)0x3BFD, - (q15_t)0x70E2, (q15_t)0x3C56, (q15_t)0x70B3, (q15_t)0x3CAF, - (q15_t)0x7083, (q15_t)0x3D07, (q15_t)0x7053, (q15_t)0x3D60, - (q15_t)0x7023, (q15_t)0x3DB8, (q15_t)0x6FF2, (q15_t)0x3E10, - (q15_t)0x6FC1, (q15_t)0x3E68, (q15_t)0x6F90, (q15_t)0x3EBF, - (q15_t)0x6F5F, (q15_t)0x3F17, (q15_t)0x6F2D, (q15_t)0x3F6E, - (q15_t)0x6EFB, (q15_t)0x3FC5, (q15_t)0x6EC9, (q15_t)0x401D, - (q15_t)0x6E96, (q15_t)0x4073, (q15_t)0x6E63, (q15_t)0x40CA, - (q15_t)0x6E30, (q15_t)0x4121, (q15_t)0x6DFD, (q15_t)0x4177, - (q15_t)0x6DCA, (q15_t)0x41CE, (q15_t)0x6D96, (q15_t)0x4224, - (q15_t)0x6D62, (q15_t)0x427A, (q15_t)0x6D2D, (q15_t)0x42D0, - (q15_t)0x6CF9, (q15_t)0x4325, (q15_t)0x6CC4, (q15_t)0x437B, - (q15_t)0x6C8F, (q15_t)0x43D0, (q15_t)0x6C59, (q15_t)0x4425, - (q15_t)0x6C24, (q15_t)0x447A, (q15_t)0x6BEE, (q15_t)0x44CF, - (q15_t)0x6BB8, (q15_t)0x4524, (q15_t)0x6B81, (q15_t)0x4578, - (q15_t)0x6B4A, (q15_t)0x45CD, (q15_t)0x6B13, (q15_t)0x4621, - (q15_t)0x6ADC, (q15_t)0x4675, (q15_t)0x6AA5, (q15_t)0x46C9, - (q15_t)0x6A6D, (q15_t)0x471C, (q15_t)0x6A35, (q15_t)0x4770, - (q15_t)0x69FD, (q15_t)0x47C3, (q15_t)0x69C4, (q15_t)0x4816, - (q15_t)0x698C, (q15_t)0x4869, (q15_t)0x6953, (q15_t)0x48BC, - (q15_t)0x6919, (q15_t)0x490F, (q15_t)0x68E0, (q15_t)0x4961, - (q15_t)0x68A6, (q15_t)0x49B4, (q15_t)0x686C, (q15_t)0x4A06, - (q15_t)0x6832, (q15_t)0x4A58, (q15_t)0x67F7, (q15_t)0x4AA9, - (q15_t)0x67BD, (q15_t)0x4AFB, (q15_t)0x6782, (q15_t)0x4B4C, - (q15_t)0x6746, (q15_t)0x4B9E, (q15_t)0x670B, (q15_t)0x4BEF, - (q15_t)0x66CF, (q15_t)0x4C3F, (q15_t)0x6693, (q15_t)0x4C90, - (q15_t)0x6657, (q15_t)0x4CE1, (q15_t)0x661A, (q15_t)0x4D31, - (q15_t)0x65DD, (q15_t)0x4D81, (q15_t)0x65A0, (q15_t)0x4DD1, - (q15_t)0x6563, (q15_t)0x4E21, (q15_t)0x6526, (q15_t)0x4E70, - (q15_t)0x64E8, (q15_t)0x4EBF, (q15_t)0x64AA, (q15_t)0x4F0F, - (q15_t)0x646C, (q15_t)0x4F5E, (q15_t)0x642D, (q15_t)0x4FAC, - (q15_t)0x63EF, (q15_t)0x4FFB, (q15_t)0x63B0, (q15_t)0x5049, - (q15_t)0x6371, (q15_t)0x5097, (q15_t)0x6331, (q15_t)0x50E5, - (q15_t)0x62F2, (q15_t)0x5133, (q15_t)0x62B2, (q15_t)0x5181, - (q15_t)0x6271, (q15_t)0x51CE, (q15_t)0x6231, (q15_t)0x521C, - (q15_t)0x61F1, (q15_t)0x5269, (q15_t)0x61B0, (q15_t)0x52B5, - (q15_t)0x616F, (q15_t)0x5302, (q15_t)0x612D, (q15_t)0x534E, - (q15_t)0x60EC, (q15_t)0x539B, (q15_t)0x60AA, (q15_t)0x53E7, - (q15_t)0x6068, (q15_t)0x5433, (q15_t)0x6026, (q15_t)0x547E, - (q15_t)0x5FE3, (q15_t)0x54CA, (q15_t)0x5FA0, (q15_t)0x5515, - (q15_t)0x5F5E, (q15_t)0x5560, (q15_t)0x5F1A, (q15_t)0x55AB, - (q15_t)0x5ED7, (q15_t)0x55F5, (q15_t)0x5E93, (q15_t)0x5640, - (q15_t)0x5E50, (q15_t)0x568A, (q15_t)0x5E0B, (q15_t)0x56D4, - (q15_t)0x5DC7, (q15_t)0x571D, (q15_t)0x5D83, (q15_t)0x5767, - (q15_t)0x5D3E, (q15_t)0x57B0, (q15_t)0x5CF9, (q15_t)0x57F9, - (q15_t)0x5CB4, (q15_t)0x5842, (q15_t)0x5C6E, (q15_t)0x588B, - (q15_t)0x5C29, (q15_t)0x58D4, (q15_t)0x5BE3, (q15_t)0x591C, - (q15_t)0x5B9D, (q15_t)0x5964, (q15_t)0x5B56, (q15_t)0x59AC, - (q15_t)0x5B10, (q15_t)0x59F3, (q15_t)0x5AC9, (q15_t)0x5A3B, - (q15_t)0x5A82, (q15_t)0x5A82, (q15_t)0x5A3B, (q15_t)0x5AC9, - (q15_t)0x59F3, (q15_t)0x5B10, (q15_t)0x59AC, (q15_t)0x5B56, - (q15_t)0x5964, (q15_t)0x5B9D, (q15_t)0x591C, (q15_t)0x5BE3, - (q15_t)0x58D4, (q15_t)0x5C29, (q15_t)0x588B, (q15_t)0x5C6E, - (q15_t)0x5842, (q15_t)0x5CB4, (q15_t)0x57F9, (q15_t)0x5CF9, - (q15_t)0x57B0, (q15_t)0x5D3E, (q15_t)0x5767, (q15_t)0x5D83, - (q15_t)0x571D, (q15_t)0x5DC7, (q15_t)0x56D4, (q15_t)0x5E0B, - (q15_t)0x568A, (q15_t)0x5E50, (q15_t)0x5640, (q15_t)0x5E93, - (q15_t)0x55F5, (q15_t)0x5ED7, (q15_t)0x55AB, (q15_t)0x5F1A, - (q15_t)0x5560, (q15_t)0x5F5E, (q15_t)0x5515, (q15_t)0x5FA0, - (q15_t)0x54CA, (q15_t)0x5FE3, (q15_t)0x547E, (q15_t)0x6026, - (q15_t)0x5433, (q15_t)0x6068, (q15_t)0x53E7, (q15_t)0x60AA, - (q15_t)0x539B, (q15_t)0x60EC, (q15_t)0x534E, (q15_t)0x612D, - (q15_t)0x5302, (q15_t)0x616F, (q15_t)0x52B5, (q15_t)0x61B0, - (q15_t)0x5269, (q15_t)0x61F1, (q15_t)0x521C, (q15_t)0x6231, - (q15_t)0x51CE, (q15_t)0x6271, (q15_t)0x5181, (q15_t)0x62B2, - (q15_t)0x5133, (q15_t)0x62F2, (q15_t)0x50E5, (q15_t)0x6331, - (q15_t)0x5097, (q15_t)0x6371, (q15_t)0x5049, (q15_t)0x63B0, - (q15_t)0x4FFB, (q15_t)0x63EF, (q15_t)0x4FAC, (q15_t)0x642D, - (q15_t)0x4F5E, (q15_t)0x646C, (q15_t)0x4F0F, (q15_t)0x64AA, - (q15_t)0x4EBF, (q15_t)0x64E8, (q15_t)0x4E70, (q15_t)0x6526, - (q15_t)0x4E21, (q15_t)0x6563, (q15_t)0x4DD1, (q15_t)0x65A0, - (q15_t)0x4D81, (q15_t)0x65DD, (q15_t)0x4D31, (q15_t)0x661A, - (q15_t)0x4CE1, (q15_t)0x6657, (q15_t)0x4C90, (q15_t)0x6693, - (q15_t)0x4C3F, (q15_t)0x66CF, (q15_t)0x4BEF, (q15_t)0x670B, - (q15_t)0x4B9E, (q15_t)0x6746, (q15_t)0x4B4C, (q15_t)0x6782, - (q15_t)0x4AFB, (q15_t)0x67BD, (q15_t)0x4AA9, (q15_t)0x67F7, - (q15_t)0x4A58, (q15_t)0x6832, (q15_t)0x4A06, (q15_t)0x686C, - (q15_t)0x49B4, (q15_t)0x68A6, (q15_t)0x4961, (q15_t)0x68E0, - (q15_t)0x490F, (q15_t)0x6919, (q15_t)0x48BC, (q15_t)0x6953, - (q15_t)0x4869, (q15_t)0x698C, (q15_t)0x4816, (q15_t)0x69C4, - (q15_t)0x47C3, (q15_t)0x69FD, (q15_t)0x4770, (q15_t)0x6A35, - (q15_t)0x471C, (q15_t)0x6A6D, (q15_t)0x46C9, (q15_t)0x6AA5, - (q15_t)0x4675, (q15_t)0x6ADC, (q15_t)0x4621, (q15_t)0x6B13, - (q15_t)0x45CD, (q15_t)0x6B4A, (q15_t)0x4578, (q15_t)0x6B81, - (q15_t)0x4524, (q15_t)0x6BB8, (q15_t)0x44CF, (q15_t)0x6BEE, - (q15_t)0x447A, (q15_t)0x6C24, (q15_t)0x4425, (q15_t)0x6C59, - (q15_t)0x43D0, (q15_t)0x6C8F, (q15_t)0x437B, (q15_t)0x6CC4, - (q15_t)0x4325, (q15_t)0x6CF9, (q15_t)0x42D0, (q15_t)0x6D2D, - (q15_t)0x427A, (q15_t)0x6D62, (q15_t)0x4224, (q15_t)0x6D96, - (q15_t)0x41CE, (q15_t)0x6DCA, (q15_t)0x4177, (q15_t)0x6DFD, - (q15_t)0x4121, (q15_t)0x6E30, (q15_t)0x40CA, (q15_t)0x6E63, - (q15_t)0x4073, (q15_t)0x6E96, (q15_t)0x401D, (q15_t)0x6EC9, - (q15_t)0x3FC5, (q15_t)0x6EFB, (q15_t)0x3F6E, (q15_t)0x6F2D, - (q15_t)0x3F17, (q15_t)0x6F5F, (q15_t)0x3EBF, (q15_t)0x6F90, - (q15_t)0x3E68, (q15_t)0x6FC1, (q15_t)0x3E10, (q15_t)0x6FF2, - (q15_t)0x3DB8, (q15_t)0x7023, (q15_t)0x3D60, (q15_t)0x7053, - (q15_t)0x3D07, (q15_t)0x7083, (q15_t)0x3CAF, (q15_t)0x70B3, - (q15_t)0x3C56, (q15_t)0x70E2, (q15_t)0x3BFD, (q15_t)0x7112, - (q15_t)0x3BA5, (q15_t)0x7141, (q15_t)0x3B4C, (q15_t)0x716F, - (q15_t)0x3AF2, (q15_t)0x719E, (q15_t)0x3A99, (q15_t)0x71CC, - (q15_t)0x3A40, (q15_t)0x71FA, (q15_t)0x39E6, (q15_t)0x7227, - (q15_t)0x398C, (q15_t)0x7255, (q15_t)0x3932, (q15_t)0x7282, - (q15_t)0x38D8, (q15_t)0x72AF, (q15_t)0x387E, (q15_t)0x72DB, - (q15_t)0x3824, (q15_t)0x7307, (q15_t)0x37CA, (q15_t)0x7333, - (q15_t)0x376F, (q15_t)0x735F, (q15_t)0x3714, (q15_t)0x738A, - (q15_t)0x36BA, (q15_t)0x73B5, (q15_t)0x365F, (q15_t)0x73E0, - (q15_t)0x3604, (q15_t)0x740B, (q15_t)0x35A8, (q15_t)0x7435, - (q15_t)0x354D, (q15_t)0x745F, (q15_t)0x34F2, (q15_t)0x7489, - (q15_t)0x3496, (q15_t)0x74B2, (q15_t)0x343A, (q15_t)0x74DB, - (q15_t)0x33DE, (q15_t)0x7504, (q15_t)0x3382, (q15_t)0x752D, - (q15_t)0x3326, (q15_t)0x7555, (q15_t)0x32CA, (q15_t)0x757D, - (q15_t)0x326E, (q15_t)0x75A5, (q15_t)0x3211, (q15_t)0x75CC, - (q15_t)0x31B5, (q15_t)0x75F4, (q15_t)0x3158, (q15_t)0x761B, - (q15_t)0x30FB, (q15_t)0x7641, (q15_t)0x309E, (q15_t)0x7668, - (q15_t)0x3041, (q15_t)0x768E, (q15_t)0x2FE4, (q15_t)0x76B3, - (q15_t)0x2F87, (q15_t)0x76D9, (q15_t)0x2F29, (q15_t)0x76FE, - (q15_t)0x2ECC, (q15_t)0x7723, (q15_t)0x2E6E, (q15_t)0x7747, - (q15_t)0x2E11, (q15_t)0x776C, (q15_t)0x2DB3, (q15_t)0x7790, - (q15_t)0x2D55, (q15_t)0x77B4, (q15_t)0x2CF7, (q15_t)0x77D7, - (q15_t)0x2C98, (q15_t)0x77FA, (q15_t)0x2C3A, (q15_t)0x781D, - (q15_t)0x2BDC, (q15_t)0x7840, (q15_t)0x2B7D, (q15_t)0x7862, - (q15_t)0x2B1F, (q15_t)0x7884, (q15_t)0x2AC0, (q15_t)0x78A6, - (q15_t)0x2A61, (q15_t)0x78C7, (q15_t)0x2A02, (q15_t)0x78E8, - (q15_t)0x29A3, (q15_t)0x7909, (q15_t)0x2944, (q15_t)0x792A, - (q15_t)0x28E5, (q15_t)0x794A, (q15_t)0x2886, (q15_t)0x796A, - (q15_t)0x2826, (q15_t)0x798A, (q15_t)0x27C7, (q15_t)0x79A9, - (q15_t)0x2767, (q15_t)0x79C8, (q15_t)0x2707, (q15_t)0x79E7, - (q15_t)0x26A8, (q15_t)0x7A05, (q15_t)0x2648, (q15_t)0x7A24, - (q15_t)0x25E8, (q15_t)0x7A42, (q15_t)0x2588, (q15_t)0x7A5F, - (q15_t)0x2528, (q15_t)0x7A7D, (q15_t)0x24C7, (q15_t)0x7A9A, - (q15_t)0x2467, (q15_t)0x7AB6, (q15_t)0x2407, (q15_t)0x7AD3, - (q15_t)0x23A6, (q15_t)0x7AEF, (q15_t)0x2345, (q15_t)0x7B0B, - (q15_t)0x22E5, (q15_t)0x7B26, (q15_t)0x2284, (q15_t)0x7B42, - (q15_t)0x2223, (q15_t)0x7B5D, (q15_t)0x21C2, (q15_t)0x7B77, - (q15_t)0x2161, (q15_t)0x7B92, (q15_t)0x2100, (q15_t)0x7BAC, - (q15_t)0x209F, (q15_t)0x7BC5, (q15_t)0x203E, (q15_t)0x7BDF, - (q15_t)0x1FDC, (q15_t)0x7BF8, (q15_t)0x1F7B, (q15_t)0x7C11, - (q15_t)0x1F19, (q15_t)0x7C29, (q15_t)0x1EB8, (q15_t)0x7C42, - (q15_t)0x1E56, (q15_t)0x7C5A, (q15_t)0x1DF5, (q15_t)0x7C71, - (q15_t)0x1D93, (q15_t)0x7C89, (q15_t)0x1D31, (q15_t)0x7CA0, - (q15_t)0x1CCF, (q15_t)0x7CB7, (q15_t)0x1C6D, (q15_t)0x7CCD, - (q15_t)0x1C0B, (q15_t)0x7CE3, (q15_t)0x1BA9, (q15_t)0x7CF9, - (q15_t)0x1B47, (q15_t)0x7D0F, (q15_t)0x1AE4, (q15_t)0x7D24, - (q15_t)0x1A82, (q15_t)0x7D39, (q15_t)0x1A20, (q15_t)0x7D4E, - (q15_t)0x19BD, (q15_t)0x7D62, (q15_t)0x195B, (q15_t)0x7D76, - (q15_t)0x18F8, (q15_t)0x7D8A, (q15_t)0x1896, (q15_t)0x7D9D, - (q15_t)0x1833, (q15_t)0x7DB0, (q15_t)0x17D0, (q15_t)0x7DC3, - (q15_t)0x176D, (q15_t)0x7DD6, (q15_t)0x170A, (q15_t)0x7DE8, - (q15_t)0x16A8, (q15_t)0x7DFA, (q15_t)0x1645, (q15_t)0x7E0C, - (q15_t)0x15E2, (q15_t)0x7E1D, (q15_t)0x157F, (q15_t)0x7E2E, - (q15_t)0x151B, (q15_t)0x7E3F, (q15_t)0x14B8, (q15_t)0x7E4F, - (q15_t)0x1455, (q15_t)0x7E5F, (q15_t)0x13F2, (q15_t)0x7E6F, - (q15_t)0x138E, (q15_t)0x7E7F, (q15_t)0x132B, (q15_t)0x7E8E, - (q15_t)0x12C8, (q15_t)0x7E9D, (q15_t)0x1264, (q15_t)0x7EAB, - (q15_t)0x1201, (q15_t)0x7EBA, (q15_t)0x119D, (q15_t)0x7EC8, - (q15_t)0x1139, (q15_t)0x7ED5, (q15_t)0x10D6, (q15_t)0x7EE3, - (q15_t)0x1072, (q15_t)0x7EF0, (q15_t)0x100E, (q15_t)0x7EFD, - (q15_t)0x0FAB, (q15_t)0x7F09, (q15_t)0x0F47, (q15_t)0x7F15, - (q15_t)0x0EE3, (q15_t)0x7F21, (q15_t)0x0E7F, (q15_t)0x7F2D, - (q15_t)0x0E1B, (q15_t)0x7F38, (q15_t)0x0DB7, (q15_t)0x7F43, - (q15_t)0x0D53, (q15_t)0x7F4D, (q15_t)0x0CEF, (q15_t)0x7F58, - (q15_t)0x0C8B, (q15_t)0x7F62, (q15_t)0x0C27, (q15_t)0x7F6B, - (q15_t)0x0BC3, (q15_t)0x7F75, (q15_t)0x0B5F, (q15_t)0x7F7E, - (q15_t)0x0AFB, (q15_t)0x7F87, (q15_t)0x0A97, (q15_t)0x7F8F, - (q15_t)0x0A33, (q15_t)0x7F97, (q15_t)0x09CE, (q15_t)0x7F9F, - (q15_t)0x096A, (q15_t)0x7FA7, (q15_t)0x0906, (q15_t)0x7FAE, - (q15_t)0x08A2, (q15_t)0x7FB5, (q15_t)0x083D, (q15_t)0x7FBC, - (q15_t)0x07D9, (q15_t)0x7FC2, (q15_t)0x0775, (q15_t)0x7FC8, - (q15_t)0x0710, (q15_t)0x7FCE, (q15_t)0x06AC, (q15_t)0x7FD3, - (q15_t)0x0647, (q15_t)0x7FD8, (q15_t)0x05E3, (q15_t)0x7FDD, - (q15_t)0x057F, (q15_t)0x7FE1, (q15_t)0x051A, (q15_t)0x7FE5, - (q15_t)0x04B6, (q15_t)0x7FE9, (q15_t)0x0451, (q15_t)0x7FED, - (q15_t)0x03ED, (q15_t)0x7FF0, (q15_t)0x0388, (q15_t)0x7FF3, - (q15_t)0x0324, (q15_t)0x7FF6, (q15_t)0x02BF, (q15_t)0x7FF8, - (q15_t)0x025B, (q15_t)0x7FFA, (q15_t)0x01F6, (q15_t)0x7FFC, - (q15_t)0x0192, (q15_t)0x7FFD, (q15_t)0x012D, (q15_t)0x7FFE, - (q15_t)0x00C9, (q15_t)0x7FFF, (q15_t)0x0064, (q15_t)0x7FFF, - (q15_t)0x0000, (q15_t)0x7FFF, (q15_t)0xFF9B, (q15_t)0x7FFF, - (q15_t)0xFF36, (q15_t)0x7FFF, (q15_t)0xFED2, (q15_t)0x7FFE, - (q15_t)0xFE6D, (q15_t)0x7FFD, (q15_t)0xFE09, (q15_t)0x7FFC, - (q15_t)0xFDA4, (q15_t)0x7FFA, (q15_t)0xFD40, (q15_t)0x7FF8, - (q15_t)0xFCDB, (q15_t)0x7FF6, (q15_t)0xFC77, (q15_t)0x7FF3, - (q15_t)0xFC12, (q15_t)0x7FF0, (q15_t)0xFBAE, (q15_t)0x7FED, - (q15_t)0xFB49, (q15_t)0x7FE9, (q15_t)0xFAE5, (q15_t)0x7FE5, - (q15_t)0xFA80, (q15_t)0x7FE1, (q15_t)0xFA1C, (q15_t)0x7FDD, - (q15_t)0xF9B8, (q15_t)0x7FD8, (q15_t)0xF953, (q15_t)0x7FD3, - (q15_t)0xF8EF, (q15_t)0x7FCE, (q15_t)0xF88A, (q15_t)0x7FC8, - (q15_t)0xF826, (q15_t)0x7FC2, (q15_t)0xF7C2, (q15_t)0x7FBC, - (q15_t)0xF75D, (q15_t)0x7FB5, (q15_t)0xF6F9, (q15_t)0x7FAE, - (q15_t)0xF695, (q15_t)0x7FA7, (q15_t)0xF631, (q15_t)0x7F9F, - (q15_t)0xF5CC, (q15_t)0x7F97, (q15_t)0xF568, (q15_t)0x7F8F, - (q15_t)0xF504, (q15_t)0x7F87, (q15_t)0xF4A0, (q15_t)0x7F7E, - (q15_t)0xF43C, (q15_t)0x7F75, (q15_t)0xF3D8, (q15_t)0x7F6B, - (q15_t)0xF374, (q15_t)0x7F62, (q15_t)0xF310, (q15_t)0x7F58, - (q15_t)0xF2AC, (q15_t)0x7F4D, (q15_t)0xF248, (q15_t)0x7F43, - (q15_t)0xF1E4, (q15_t)0x7F38, (q15_t)0xF180, (q15_t)0x7F2D, - (q15_t)0xF11C, (q15_t)0x7F21, (q15_t)0xF0B8, (q15_t)0x7F15, - (q15_t)0xF054, (q15_t)0x7F09, (q15_t)0xEFF1, (q15_t)0x7EFD, - (q15_t)0xEF8D, (q15_t)0x7EF0, (q15_t)0xEF29, (q15_t)0x7EE3, - (q15_t)0xEEC6, (q15_t)0x7ED5, (q15_t)0xEE62, (q15_t)0x7EC8, - (q15_t)0xEDFE, (q15_t)0x7EBA, (q15_t)0xED9B, (q15_t)0x7EAB, - (q15_t)0xED37, (q15_t)0x7E9D, (q15_t)0xECD4, (q15_t)0x7E8E, - (q15_t)0xEC71, (q15_t)0x7E7F, (q15_t)0xEC0D, (q15_t)0x7E6F, - (q15_t)0xEBAA, (q15_t)0x7E5F, (q15_t)0xEB47, (q15_t)0x7E4F, - (q15_t)0xEAE4, (q15_t)0x7E3F, (q15_t)0xEA80, (q15_t)0x7E2E, - (q15_t)0xEA1D, (q15_t)0x7E1D, (q15_t)0xE9BA, (q15_t)0x7E0C, - (q15_t)0xE957, (q15_t)0x7DFA, (q15_t)0xE8F5, (q15_t)0x7DE8, - (q15_t)0xE892, (q15_t)0x7DD6, (q15_t)0xE82F, (q15_t)0x7DC3, - (q15_t)0xE7CC, (q15_t)0x7DB0, (q15_t)0xE769, (q15_t)0x7D9D, - (q15_t)0xE707, (q15_t)0x7D8A, (q15_t)0xE6A4, (q15_t)0x7D76, - (q15_t)0xE642, (q15_t)0x7D62, (q15_t)0xE5DF, (q15_t)0x7D4E, - (q15_t)0xE57D, (q15_t)0x7D39, (q15_t)0xE51B, (q15_t)0x7D24, - (q15_t)0xE4B8, (q15_t)0x7D0F, (q15_t)0xE456, (q15_t)0x7CF9, - (q15_t)0xE3F4, (q15_t)0x7CE3, (q15_t)0xE392, (q15_t)0x7CCD, - (q15_t)0xE330, (q15_t)0x7CB7, (q15_t)0xE2CE, (q15_t)0x7CA0, - (q15_t)0xE26C, (q15_t)0x7C89, (q15_t)0xE20A, (q15_t)0x7C71, - (q15_t)0xE1A9, (q15_t)0x7C5A, (q15_t)0xE147, (q15_t)0x7C42, - (q15_t)0xE0E6, (q15_t)0x7C29, (q15_t)0xE084, (q15_t)0x7C11, - (q15_t)0xE023, (q15_t)0x7BF8, (q15_t)0xDFC1, (q15_t)0x7BDF, - (q15_t)0xDF60, (q15_t)0x7BC5, (q15_t)0xDEFF, (q15_t)0x7BAC, - (q15_t)0xDE9E, (q15_t)0x7B92, (q15_t)0xDE3D, (q15_t)0x7B77, - (q15_t)0xDDDC, (q15_t)0x7B5D, (q15_t)0xDD7B, (q15_t)0x7B42, - (q15_t)0xDD1A, (q15_t)0x7B26, (q15_t)0xDCBA, (q15_t)0x7B0B, - (q15_t)0xDC59, (q15_t)0x7AEF, (q15_t)0xDBF8, (q15_t)0x7AD3, - (q15_t)0xDB98, (q15_t)0x7AB6, (q15_t)0xDB38, (q15_t)0x7A9A, - (q15_t)0xDAD7, (q15_t)0x7A7D, (q15_t)0xDA77, (q15_t)0x7A5F, - (q15_t)0xDA17, (q15_t)0x7A42, (q15_t)0xD9B7, (q15_t)0x7A24, - (q15_t)0xD957, (q15_t)0x7A05, (q15_t)0xD8F8, (q15_t)0x79E7, - (q15_t)0xD898, (q15_t)0x79C8, (q15_t)0xD838, (q15_t)0x79A9, - (q15_t)0xD7D9, (q15_t)0x798A, (q15_t)0xD779, (q15_t)0x796A, - (q15_t)0xD71A, (q15_t)0x794A, (q15_t)0xD6BB, (q15_t)0x792A, - (q15_t)0xD65C, (q15_t)0x7909, (q15_t)0xD5FD, (q15_t)0x78E8, - (q15_t)0xD59E, (q15_t)0x78C7, (q15_t)0xD53F, (q15_t)0x78A6, - (q15_t)0xD4E0, (q15_t)0x7884, (q15_t)0xD482, (q15_t)0x7862, - (q15_t)0xD423, (q15_t)0x7840, (q15_t)0xD3C5, (q15_t)0x781D, - (q15_t)0xD367, (q15_t)0x77FA, (q15_t)0xD308, (q15_t)0x77D7, - (q15_t)0xD2AA, (q15_t)0x77B4, (q15_t)0xD24C, (q15_t)0x7790, - (q15_t)0xD1EE, (q15_t)0x776C, (q15_t)0xD191, (q15_t)0x7747, - (q15_t)0xD133, (q15_t)0x7723, (q15_t)0xD0D6, (q15_t)0x76FE, - (q15_t)0xD078, (q15_t)0x76D9, (q15_t)0xD01B, (q15_t)0x76B3, - (q15_t)0xCFBE, (q15_t)0x768E, (q15_t)0xCF61, (q15_t)0x7668, - (q15_t)0xCF04, (q15_t)0x7641, (q15_t)0xCEA7, (q15_t)0x761B, - (q15_t)0xCE4A, (q15_t)0x75F4, (q15_t)0xCDEE, (q15_t)0x75CC, - (q15_t)0xCD91, (q15_t)0x75A5, (q15_t)0xCD35, (q15_t)0x757D, - (q15_t)0xCCD9, (q15_t)0x7555, (q15_t)0xCC7D, (q15_t)0x752D, - (q15_t)0xCC21, (q15_t)0x7504, (q15_t)0xCBC5, (q15_t)0x74DB, - (q15_t)0xCB69, (q15_t)0x74B2, (q15_t)0xCB0D, (q15_t)0x7489, - (q15_t)0xCAB2, (q15_t)0x745F, (q15_t)0xCA57, (q15_t)0x7435, - (q15_t)0xC9FB, (q15_t)0x740B, (q15_t)0xC9A0, (q15_t)0x73E0, - (q15_t)0xC945, (q15_t)0x73B5, (q15_t)0xC8EB, (q15_t)0x738A, - (q15_t)0xC890, (q15_t)0x735F, (q15_t)0xC835, (q15_t)0x7333, - (q15_t)0xC7DB, (q15_t)0x7307, (q15_t)0xC781, (q15_t)0x72DB, - (q15_t)0xC727, (q15_t)0x72AF, (q15_t)0xC6CD, (q15_t)0x7282, - (q15_t)0xC673, (q15_t)0x7255, (q15_t)0xC619, (q15_t)0x7227, - (q15_t)0xC5BF, (q15_t)0x71FA, (q15_t)0xC566, (q15_t)0x71CC, - (q15_t)0xC50D, (q15_t)0x719E, (q15_t)0xC4B3, (q15_t)0x716F, - (q15_t)0xC45A, (q15_t)0x7141, (q15_t)0xC402, (q15_t)0x7112, - (q15_t)0xC3A9, (q15_t)0x70E2, (q15_t)0xC350, (q15_t)0x70B3, - (q15_t)0xC2F8, (q15_t)0x7083, (q15_t)0xC29F, (q15_t)0x7053, - (q15_t)0xC247, (q15_t)0x7023, (q15_t)0xC1EF, (q15_t)0x6FF2, - (q15_t)0xC197, (q15_t)0x6FC1, (q15_t)0xC140, (q15_t)0x6F90, - (q15_t)0xC0E8, (q15_t)0x6F5F, (q15_t)0xC091, (q15_t)0x6F2D, - (q15_t)0xC03A, (q15_t)0x6EFB, (q15_t)0xBFE2, (q15_t)0x6EC9, - (q15_t)0xBF8C, (q15_t)0x6E96, (q15_t)0xBF35, (q15_t)0x6E63, - (q15_t)0xBEDE, (q15_t)0x6E30, (q15_t)0xBE88, (q15_t)0x6DFD, - (q15_t)0xBE31, (q15_t)0x6DCA, (q15_t)0xBDDB, (q15_t)0x6D96, - (q15_t)0xBD85, (q15_t)0x6D62, (q15_t)0xBD2F, (q15_t)0x6D2D, - (q15_t)0xBCDA, (q15_t)0x6CF9, (q15_t)0xBC84, (q15_t)0x6CC4, - (q15_t)0xBC2F, (q15_t)0x6C8F, (q15_t)0xBBDA, (q15_t)0x6C59, - (q15_t)0xBB85, (q15_t)0x6C24, (q15_t)0xBB30, (q15_t)0x6BEE, - (q15_t)0xBADB, (q15_t)0x6BB8, (q15_t)0xBA87, (q15_t)0x6B81, - (q15_t)0xBA32, (q15_t)0x6B4A, (q15_t)0xB9DE, (q15_t)0x6B13, - (q15_t)0xB98A, (q15_t)0x6ADC, (q15_t)0xB936, (q15_t)0x6AA5, - (q15_t)0xB8E3, (q15_t)0x6A6D, (q15_t)0xB88F, (q15_t)0x6A35, - (q15_t)0xB83C, (q15_t)0x69FD, (q15_t)0xB7E9, (q15_t)0x69C4, - (q15_t)0xB796, (q15_t)0x698C, (q15_t)0xB743, (q15_t)0x6953, - (q15_t)0xB6F0, (q15_t)0x6919, (q15_t)0xB69E, (q15_t)0x68E0, - (q15_t)0xB64B, (q15_t)0x68A6, (q15_t)0xB5F9, (q15_t)0x686C, - (q15_t)0xB5A7, (q15_t)0x6832, (q15_t)0xB556, (q15_t)0x67F7, - (q15_t)0xB504, (q15_t)0x67BD, (q15_t)0xB4B3, (q15_t)0x6782, - (q15_t)0xB461, (q15_t)0x6746, (q15_t)0xB410, (q15_t)0x670B, - (q15_t)0xB3C0, (q15_t)0x66CF, (q15_t)0xB36F, (q15_t)0x6693, - (q15_t)0xB31E, (q15_t)0x6657, (q15_t)0xB2CE, (q15_t)0x661A, - (q15_t)0xB27E, (q15_t)0x65DD, (q15_t)0xB22E, (q15_t)0x65A0, - (q15_t)0xB1DE, (q15_t)0x6563, (q15_t)0xB18F, (q15_t)0x6526, - (q15_t)0xB140, (q15_t)0x64E8, (q15_t)0xB0F0, (q15_t)0x64AA, - (q15_t)0xB0A1, (q15_t)0x646C, (q15_t)0xB053, (q15_t)0x642D, - (q15_t)0xB004, (q15_t)0x63EF, (q15_t)0xAFB6, (q15_t)0x63B0, - (q15_t)0xAF68, (q15_t)0x6371, (q15_t)0xAF1A, (q15_t)0x6331, - (q15_t)0xAECC, (q15_t)0x62F2, (q15_t)0xAE7E, (q15_t)0x62B2, - (q15_t)0xAE31, (q15_t)0x6271, (q15_t)0xADE3, (q15_t)0x6231, - (q15_t)0xAD96, (q15_t)0x61F1, (q15_t)0xAD4A, (q15_t)0x61B0, - (q15_t)0xACFD, (q15_t)0x616F, (q15_t)0xACB1, (q15_t)0x612D, - (q15_t)0xAC64, (q15_t)0x60EC, (q15_t)0xAC18, (q15_t)0x60AA, - (q15_t)0xABCC, (q15_t)0x6068, (q15_t)0xAB81, (q15_t)0x6026, - (q15_t)0xAB35, (q15_t)0x5FE3, (q15_t)0xAAEA, (q15_t)0x5FA0, - (q15_t)0xAA9F, (q15_t)0x5F5E, (q15_t)0xAA54, (q15_t)0x5F1A, - (q15_t)0xAA0A, (q15_t)0x5ED7, (q15_t)0xA9BF, (q15_t)0x5E93, - (q15_t)0xA975, (q15_t)0x5E50, (q15_t)0xA92B, (q15_t)0x5E0B, - (q15_t)0xA8E2, (q15_t)0x5DC7, (q15_t)0xA898, (q15_t)0x5D83, - (q15_t)0xA84F, (q15_t)0x5D3E, (q15_t)0xA806, (q15_t)0x5CF9, - (q15_t)0xA7BD, (q15_t)0x5CB4, (q15_t)0xA774, (q15_t)0x5C6E, - (q15_t)0xA72B, (q15_t)0x5C29, (q15_t)0xA6E3, (q15_t)0x5BE3, - (q15_t)0xA69B, (q15_t)0x5B9D, (q15_t)0xA653, (q15_t)0x5B56, - (q15_t)0xA60C, (q15_t)0x5B10, (q15_t)0xA5C4, (q15_t)0x5AC9, - (q15_t)0xA57D, (q15_t)0x5A82, (q15_t)0xA536, (q15_t)0x5A3B, - (q15_t)0xA4EF, (q15_t)0x59F3, (q15_t)0xA4A9, (q15_t)0x59AC, - (q15_t)0xA462, (q15_t)0x5964, (q15_t)0xA41C, (q15_t)0x591C, - (q15_t)0xA3D6, (q15_t)0x58D4, (q15_t)0xA391, (q15_t)0x588B, - (q15_t)0xA34B, (q15_t)0x5842, (q15_t)0xA306, (q15_t)0x57F9, - (q15_t)0xA2C1, (q15_t)0x57B0, (q15_t)0xA27C, (q15_t)0x5767, - (q15_t)0xA238, (q15_t)0x571D, (q15_t)0xA1F4, (q15_t)0x56D4, - (q15_t)0xA1AF, (q15_t)0x568A, (q15_t)0xA16C, (q15_t)0x5640, - (q15_t)0xA128, (q15_t)0x55F5, (q15_t)0xA0E5, (q15_t)0x55AB, - (q15_t)0xA0A1, (q15_t)0x5560, (q15_t)0xA05F, (q15_t)0x5515, - (q15_t)0xA01C, (q15_t)0x54CA, (q15_t)0x9FD9, (q15_t)0x547E, - (q15_t)0x9F97, (q15_t)0x5433, (q15_t)0x9F55, (q15_t)0x53E7, - (q15_t)0x9F13, (q15_t)0x539B, (q15_t)0x9ED2, (q15_t)0x534E, - (q15_t)0x9E90, (q15_t)0x5302, (q15_t)0x9E4F, (q15_t)0x52B5, - (q15_t)0x9E0E, (q15_t)0x5269, (q15_t)0x9DCE, (q15_t)0x521C, - (q15_t)0x9D8E, (q15_t)0x51CE, (q15_t)0x9D4D, (q15_t)0x5181, - (q15_t)0x9D0D, (q15_t)0x5133, (q15_t)0x9CCE, (q15_t)0x50E5, - (q15_t)0x9C8E, (q15_t)0x5097, (q15_t)0x9C4F, (q15_t)0x5049, - (q15_t)0x9C10, (q15_t)0x4FFB, (q15_t)0x9BD2, (q15_t)0x4FAC, - (q15_t)0x9B93, (q15_t)0x4F5E, (q15_t)0x9B55, (q15_t)0x4F0F, - (q15_t)0x9B17, (q15_t)0x4EBF, (q15_t)0x9AD9, (q15_t)0x4E70, - (q15_t)0x9A9C, (q15_t)0x4E21, (q15_t)0x9A5F, (q15_t)0x4DD1, - (q15_t)0x9A22, (q15_t)0x4D81, (q15_t)0x99E5, (q15_t)0x4D31, - (q15_t)0x99A8, (q15_t)0x4CE1, (q15_t)0x996C, (q15_t)0x4C90, - (q15_t)0x9930, (q15_t)0x4C3F, (q15_t)0x98F4, (q15_t)0x4BEF, - (q15_t)0x98B9, (q15_t)0x4B9E, (q15_t)0x987D, (q15_t)0x4B4C, - (q15_t)0x9842, (q15_t)0x4AFB, (q15_t)0x9808, (q15_t)0x4AA9, - (q15_t)0x97CD, (q15_t)0x4A58, (q15_t)0x9793, (q15_t)0x4A06, - (q15_t)0x9759, (q15_t)0x49B4, (q15_t)0x971F, (q15_t)0x4961, - (q15_t)0x96E6, (q15_t)0x490F, (q15_t)0x96AC, (q15_t)0x48BC, - (q15_t)0x9673, (q15_t)0x4869, (q15_t)0x963B, (q15_t)0x4816, - (q15_t)0x9602, (q15_t)0x47C3, (q15_t)0x95CA, (q15_t)0x4770, - (q15_t)0x9592, (q15_t)0x471C, (q15_t)0x955A, (q15_t)0x46C9, - (q15_t)0x9523, (q15_t)0x4675, (q15_t)0x94EC, (q15_t)0x4621, - (q15_t)0x94B5, (q15_t)0x45CD, (q15_t)0x947E, (q15_t)0x4578, - (q15_t)0x9447, (q15_t)0x4524, (q15_t)0x9411, (q15_t)0x44CF, - (q15_t)0x93DB, (q15_t)0x447A, (q15_t)0x93A6, (q15_t)0x4425, - (q15_t)0x9370, (q15_t)0x43D0, (q15_t)0x933B, (q15_t)0x437B, - (q15_t)0x9306, (q15_t)0x4325, (q15_t)0x92D2, (q15_t)0x42D0, - (q15_t)0x929D, (q15_t)0x427A, (q15_t)0x9269, (q15_t)0x4224, - (q15_t)0x9235, (q15_t)0x41CE, (q15_t)0x9202, (q15_t)0x4177, - (q15_t)0x91CF, (q15_t)0x4121, (q15_t)0x919C, (q15_t)0x40CA, - (q15_t)0x9169, (q15_t)0x4073, (q15_t)0x9136, (q15_t)0x401D, - (q15_t)0x9104, (q15_t)0x3FC5, (q15_t)0x90D2, (q15_t)0x3F6E, - (q15_t)0x90A0, (q15_t)0x3F17, (q15_t)0x906F, (q15_t)0x3EBF, - (q15_t)0x903E, (q15_t)0x3E68, (q15_t)0x900D, (q15_t)0x3E10, - (q15_t)0x8FDC, (q15_t)0x3DB8, (q15_t)0x8FAC, (q15_t)0x3D60, - (q15_t)0x8F7C, (q15_t)0x3D07, (q15_t)0x8F4C, (q15_t)0x3CAF, - (q15_t)0x8F1D, (q15_t)0x3C56, (q15_t)0x8EED, (q15_t)0x3BFD, - (q15_t)0x8EBE, (q15_t)0x3BA5, (q15_t)0x8E90, (q15_t)0x3B4C, - (q15_t)0x8E61, (q15_t)0x3AF2, (q15_t)0x8E33, (q15_t)0x3A99, - (q15_t)0x8E05, (q15_t)0x3A40, (q15_t)0x8DD8, (q15_t)0x39E6, - (q15_t)0x8DAA, (q15_t)0x398C, (q15_t)0x8D7D, (q15_t)0x3932, - (q15_t)0x8D50, (q15_t)0x38D8, (q15_t)0x8D24, (q15_t)0x387E, - (q15_t)0x8CF8, (q15_t)0x3824, (q15_t)0x8CCC, (q15_t)0x37CA, - (q15_t)0x8CA0, (q15_t)0x376F, (q15_t)0x8C75, (q15_t)0x3714, - (q15_t)0x8C4A, (q15_t)0x36BA, (q15_t)0x8C1F, (q15_t)0x365F, - (q15_t)0x8BF4, (q15_t)0x3604, (q15_t)0x8BCA, (q15_t)0x35A8, - (q15_t)0x8BA0, (q15_t)0x354D, (q15_t)0x8B76, (q15_t)0x34F2, - (q15_t)0x8B4D, (q15_t)0x3496, (q15_t)0x8B24, (q15_t)0x343A, - (q15_t)0x8AFB, (q15_t)0x33DE, (q15_t)0x8AD2, (q15_t)0x3382, - (q15_t)0x8AAA, (q15_t)0x3326, (q15_t)0x8A82, (q15_t)0x32CA, - (q15_t)0x8A5A, (q15_t)0x326E, (q15_t)0x8A33, (q15_t)0x3211, - (q15_t)0x8A0B, (q15_t)0x31B5, (q15_t)0x89E4, (q15_t)0x3158, - (q15_t)0x89BE, (q15_t)0x30FB, (q15_t)0x8997, (q15_t)0x309E, - (q15_t)0x8971, (q15_t)0x3041, (q15_t)0x894C, (q15_t)0x2FE4, - (q15_t)0x8926, (q15_t)0x2F87, (q15_t)0x8901, (q15_t)0x2F29, - (q15_t)0x88DC, (q15_t)0x2ECC, (q15_t)0x88B8, (q15_t)0x2E6E, - (q15_t)0x8893, (q15_t)0x2E11, (q15_t)0x886F, (q15_t)0x2DB3, - (q15_t)0x884B, (q15_t)0x2D55, (q15_t)0x8828, (q15_t)0x2CF7, - (q15_t)0x8805, (q15_t)0x2C98, (q15_t)0x87E2, (q15_t)0x2C3A, - (q15_t)0x87BF, (q15_t)0x2BDC, (q15_t)0x879D, (q15_t)0x2B7D, - (q15_t)0x877B, (q15_t)0x2B1F, (q15_t)0x8759, (q15_t)0x2AC0, - (q15_t)0x8738, (q15_t)0x2A61, (q15_t)0x8717, (q15_t)0x2A02, - (q15_t)0x86F6, (q15_t)0x29A3, (q15_t)0x86D5, (q15_t)0x2944, - (q15_t)0x86B5, (q15_t)0x28E5, (q15_t)0x8695, (q15_t)0x2886, - (q15_t)0x8675, (q15_t)0x2826, (q15_t)0x8656, (q15_t)0x27C7, - (q15_t)0x8637, (q15_t)0x2767, (q15_t)0x8618, (q15_t)0x2707, - (q15_t)0x85FA, (q15_t)0x26A8, (q15_t)0x85DB, (q15_t)0x2648, - (q15_t)0x85BD, (q15_t)0x25E8, (q15_t)0x85A0, (q15_t)0x2588, - (q15_t)0x8582, (q15_t)0x2528, (q15_t)0x8565, (q15_t)0x24C7, - (q15_t)0x8549, (q15_t)0x2467, (q15_t)0x852C, (q15_t)0x2407, - (q15_t)0x8510, (q15_t)0x23A6, (q15_t)0x84F4, (q15_t)0x2345, - (q15_t)0x84D9, (q15_t)0x22E5, (q15_t)0x84BD, (q15_t)0x2284, - (q15_t)0x84A2, (q15_t)0x2223, (q15_t)0x8488, (q15_t)0x21C2, - (q15_t)0x846D, (q15_t)0x2161, (q15_t)0x8453, (q15_t)0x2100, - (q15_t)0x843A, (q15_t)0x209F, (q15_t)0x8420, (q15_t)0x203E, - (q15_t)0x8407, (q15_t)0x1FDC, (q15_t)0x83EE, (q15_t)0x1F7B, - (q15_t)0x83D6, (q15_t)0x1F19, (q15_t)0x83BD, (q15_t)0x1EB8, - (q15_t)0x83A5, (q15_t)0x1E56, (q15_t)0x838E, (q15_t)0x1DF5, - (q15_t)0x8376, (q15_t)0x1D93, (q15_t)0x835F, (q15_t)0x1D31, - (q15_t)0x8348, (q15_t)0x1CCF, (q15_t)0x8332, (q15_t)0x1C6D, - (q15_t)0x831C, (q15_t)0x1C0B, (q15_t)0x8306, (q15_t)0x1BA9, - (q15_t)0x82F0, (q15_t)0x1B47, (q15_t)0x82DB, (q15_t)0x1AE4, - (q15_t)0x82C6, (q15_t)0x1A82, (q15_t)0x82B1, (q15_t)0x1A20, - (q15_t)0x829D, (q15_t)0x19BD, (q15_t)0x8289, (q15_t)0x195B, - (q15_t)0x8275, (q15_t)0x18F8, (q15_t)0x8262, (q15_t)0x1896, - (q15_t)0x824F, (q15_t)0x1833, (q15_t)0x823C, (q15_t)0x17D0, - (q15_t)0x8229, (q15_t)0x176D, (q15_t)0x8217, (q15_t)0x170A, - (q15_t)0x8205, (q15_t)0x16A8, (q15_t)0x81F3, (q15_t)0x1645, - (q15_t)0x81E2, (q15_t)0x15E2, (q15_t)0x81D1, (q15_t)0x157F, - (q15_t)0x81C0, (q15_t)0x151B, (q15_t)0x81B0, (q15_t)0x14B8, - (q15_t)0x81A0, (q15_t)0x1455, (q15_t)0x8190, (q15_t)0x13F2, - (q15_t)0x8180, (q15_t)0x138E, (q15_t)0x8171, (q15_t)0x132B, - (q15_t)0x8162, (q15_t)0x12C8, (q15_t)0x8154, (q15_t)0x1264, - (q15_t)0x8145, (q15_t)0x1201, (q15_t)0x8137, (q15_t)0x119D, - (q15_t)0x812A, (q15_t)0x1139, (q15_t)0x811C, (q15_t)0x10D6, - (q15_t)0x810F, (q15_t)0x1072, (q15_t)0x8102, (q15_t)0x100E, - (q15_t)0x80F6, (q15_t)0x0FAB, (q15_t)0x80EA, (q15_t)0x0F47, - (q15_t)0x80DE, (q15_t)0x0EE3, (q15_t)0x80D2, (q15_t)0x0E7F, - (q15_t)0x80C7, (q15_t)0x0E1B, (q15_t)0x80BC, (q15_t)0x0DB7, - (q15_t)0x80B2, (q15_t)0x0D53, (q15_t)0x80A7, (q15_t)0x0CEF, - (q15_t)0x809D, (q15_t)0x0C8B, (q15_t)0x8094, (q15_t)0x0C27, - (q15_t)0x808A, (q15_t)0x0BC3, (q15_t)0x8081, (q15_t)0x0B5F, - (q15_t)0x8078, (q15_t)0x0AFB, (q15_t)0x8070, (q15_t)0x0A97, - (q15_t)0x8068, (q15_t)0x0A33, (q15_t)0x8060, (q15_t)0x09CE, - (q15_t)0x8058, (q15_t)0x096A, (q15_t)0x8051, (q15_t)0x0906, - (q15_t)0x804A, (q15_t)0x08A2, (q15_t)0x8043, (q15_t)0x083D, - (q15_t)0x803D, (q15_t)0x07D9, (q15_t)0x8037, (q15_t)0x0775, - (q15_t)0x8031, (q15_t)0x0710, (q15_t)0x802C, (q15_t)0x06AC, - (q15_t)0x8027, (q15_t)0x0647, (q15_t)0x8022, (q15_t)0x05E3, - (q15_t)0x801E, (q15_t)0x057F, (q15_t)0x801A, (q15_t)0x051A, - (q15_t)0x8016, (q15_t)0x04B6, (q15_t)0x8012, (q15_t)0x0451, - (q15_t)0x800F, (q15_t)0x03ED, (q15_t)0x800C, (q15_t)0x0388, - (q15_t)0x8009, (q15_t)0x0324, (q15_t)0x8007, (q15_t)0x02BF, - (q15_t)0x8005, (q15_t)0x025B, (q15_t)0x8003, (q15_t)0x01F6, - (q15_t)0x8002, (q15_t)0x0192, (q15_t)0x8001, (q15_t)0x012D, - (q15_t)0x8000, (q15_t)0x00C9, (q15_t)0x8000, (q15_t)0x0064, - (q15_t)0x8000, (q15_t)0x0000, (q15_t)0x8000, (q15_t)0xFF9B, - (q15_t)0x8000, (q15_t)0xFF36, (q15_t)0x8001, (q15_t)0xFED2, - (q15_t)0x8002, (q15_t)0xFE6D, (q15_t)0x8003, (q15_t)0xFE09, - (q15_t)0x8005, (q15_t)0xFDA4, (q15_t)0x8007, (q15_t)0xFD40, - (q15_t)0x8009, (q15_t)0xFCDB, (q15_t)0x800C, (q15_t)0xFC77, - (q15_t)0x800F, (q15_t)0xFC12, (q15_t)0x8012, (q15_t)0xFBAE, - (q15_t)0x8016, (q15_t)0xFB49, (q15_t)0x801A, (q15_t)0xFAE5, - (q15_t)0x801E, (q15_t)0xFA80, (q15_t)0x8022, (q15_t)0xFA1C, - (q15_t)0x8027, (q15_t)0xF9B8, (q15_t)0x802C, (q15_t)0xF953, - (q15_t)0x8031, (q15_t)0xF8EF, (q15_t)0x8037, (q15_t)0xF88A, - (q15_t)0x803D, (q15_t)0xF826, (q15_t)0x8043, (q15_t)0xF7C2, - (q15_t)0x804A, (q15_t)0xF75D, (q15_t)0x8051, (q15_t)0xF6F9, - (q15_t)0x8058, (q15_t)0xF695, (q15_t)0x8060, (q15_t)0xF631, - (q15_t)0x8068, (q15_t)0xF5CC, (q15_t)0x8070, (q15_t)0xF568, - (q15_t)0x8078, (q15_t)0xF504, (q15_t)0x8081, (q15_t)0xF4A0, - (q15_t)0x808A, (q15_t)0xF43C, (q15_t)0x8094, (q15_t)0xF3D8, - (q15_t)0x809D, (q15_t)0xF374, (q15_t)0x80A7, (q15_t)0xF310, - (q15_t)0x80B2, (q15_t)0xF2AC, (q15_t)0x80BC, (q15_t)0xF248, - (q15_t)0x80C7, (q15_t)0xF1E4, (q15_t)0x80D2, (q15_t)0xF180, - (q15_t)0x80DE, (q15_t)0xF11C, (q15_t)0x80EA, (q15_t)0xF0B8, - (q15_t)0x80F6, (q15_t)0xF054, (q15_t)0x8102, (q15_t)0xEFF1, - (q15_t)0x810F, (q15_t)0xEF8D, (q15_t)0x811C, (q15_t)0xEF29, - (q15_t)0x812A, (q15_t)0xEEC6, (q15_t)0x8137, (q15_t)0xEE62, - (q15_t)0x8145, (q15_t)0xEDFE, (q15_t)0x8154, (q15_t)0xED9B, - (q15_t)0x8162, (q15_t)0xED37, (q15_t)0x8171, (q15_t)0xECD4, - (q15_t)0x8180, (q15_t)0xEC71, (q15_t)0x8190, (q15_t)0xEC0D, - (q15_t)0x81A0, (q15_t)0xEBAA, (q15_t)0x81B0, (q15_t)0xEB47, - (q15_t)0x81C0, (q15_t)0xEAE4, (q15_t)0x81D1, (q15_t)0xEA80, - (q15_t)0x81E2, (q15_t)0xEA1D, (q15_t)0x81F3, (q15_t)0xE9BA, - (q15_t)0x8205, (q15_t)0xE957, (q15_t)0x8217, (q15_t)0xE8F5, - (q15_t)0x8229, (q15_t)0xE892, (q15_t)0x823C, (q15_t)0xE82F, - (q15_t)0x824F, (q15_t)0xE7CC, (q15_t)0x8262, (q15_t)0xE769, - (q15_t)0x8275, (q15_t)0xE707, (q15_t)0x8289, (q15_t)0xE6A4, - (q15_t)0x829D, (q15_t)0xE642, (q15_t)0x82B1, (q15_t)0xE5DF, - (q15_t)0x82C6, (q15_t)0xE57D, (q15_t)0x82DB, (q15_t)0xE51B, - (q15_t)0x82F0, (q15_t)0xE4B8, (q15_t)0x8306, (q15_t)0xE456, - (q15_t)0x831C, (q15_t)0xE3F4, (q15_t)0x8332, (q15_t)0xE392, - (q15_t)0x8348, (q15_t)0xE330, (q15_t)0x835F, (q15_t)0xE2CE, - (q15_t)0x8376, (q15_t)0xE26C, (q15_t)0x838E, (q15_t)0xE20A, - (q15_t)0x83A5, (q15_t)0xE1A9, (q15_t)0x83BD, (q15_t)0xE147, - (q15_t)0x83D6, (q15_t)0xE0E6, (q15_t)0x83EE, (q15_t)0xE084, - (q15_t)0x8407, (q15_t)0xE023, (q15_t)0x8420, (q15_t)0xDFC1, - (q15_t)0x843A, (q15_t)0xDF60, (q15_t)0x8453, (q15_t)0xDEFF, - (q15_t)0x846D, (q15_t)0xDE9E, (q15_t)0x8488, (q15_t)0xDE3D, - (q15_t)0x84A2, (q15_t)0xDDDC, (q15_t)0x84BD, (q15_t)0xDD7B, - (q15_t)0x84D9, (q15_t)0xDD1A, (q15_t)0x84F4, (q15_t)0xDCBA, - (q15_t)0x8510, (q15_t)0xDC59, (q15_t)0x852C, (q15_t)0xDBF8, - (q15_t)0x8549, (q15_t)0xDB98, (q15_t)0x8565, (q15_t)0xDB38, - (q15_t)0x8582, (q15_t)0xDAD7, (q15_t)0x85A0, (q15_t)0xDA77, - (q15_t)0x85BD, (q15_t)0xDA17, (q15_t)0x85DB, (q15_t)0xD9B7, - (q15_t)0x85FA, (q15_t)0xD957, (q15_t)0x8618, (q15_t)0xD8F8, - (q15_t)0x8637, (q15_t)0xD898, (q15_t)0x8656, (q15_t)0xD838, - (q15_t)0x8675, (q15_t)0xD7D9, (q15_t)0x8695, (q15_t)0xD779, - (q15_t)0x86B5, (q15_t)0xD71A, (q15_t)0x86D5, (q15_t)0xD6BB, - (q15_t)0x86F6, (q15_t)0xD65C, (q15_t)0x8717, (q15_t)0xD5FD, - (q15_t)0x8738, (q15_t)0xD59E, (q15_t)0x8759, (q15_t)0xD53F, - (q15_t)0x877B, (q15_t)0xD4E0, (q15_t)0x879D, (q15_t)0xD482, - (q15_t)0x87BF, (q15_t)0xD423, (q15_t)0x87E2, (q15_t)0xD3C5, - (q15_t)0x8805, (q15_t)0xD367, (q15_t)0x8828, (q15_t)0xD308, - (q15_t)0x884B, (q15_t)0xD2AA, (q15_t)0x886F, (q15_t)0xD24C, - (q15_t)0x8893, (q15_t)0xD1EE, (q15_t)0x88B8, (q15_t)0xD191, - (q15_t)0x88DC, (q15_t)0xD133, (q15_t)0x8901, (q15_t)0xD0D6, - (q15_t)0x8926, (q15_t)0xD078, (q15_t)0x894C, (q15_t)0xD01B, - (q15_t)0x8971, (q15_t)0xCFBE, (q15_t)0x8997, (q15_t)0xCF61, - (q15_t)0x89BE, (q15_t)0xCF04, (q15_t)0x89E4, (q15_t)0xCEA7, - (q15_t)0x8A0B, (q15_t)0xCE4A, (q15_t)0x8A33, (q15_t)0xCDEE, - (q15_t)0x8A5A, (q15_t)0xCD91, (q15_t)0x8A82, (q15_t)0xCD35, - (q15_t)0x8AAA, (q15_t)0xCCD9, (q15_t)0x8AD2, (q15_t)0xCC7D, - (q15_t)0x8AFB, (q15_t)0xCC21, (q15_t)0x8B24, (q15_t)0xCBC5, - (q15_t)0x8B4D, (q15_t)0xCB69, (q15_t)0x8B76, (q15_t)0xCB0D, - (q15_t)0x8BA0, (q15_t)0xCAB2, (q15_t)0x8BCA, (q15_t)0xCA57, - (q15_t)0x8BF4, (q15_t)0xC9FB, (q15_t)0x8C1F, (q15_t)0xC9A0, - (q15_t)0x8C4A, (q15_t)0xC945, (q15_t)0x8C75, (q15_t)0xC8EB, - (q15_t)0x8CA0, (q15_t)0xC890, (q15_t)0x8CCC, (q15_t)0xC835, - (q15_t)0x8CF8, (q15_t)0xC7DB, (q15_t)0x8D24, (q15_t)0xC781, - (q15_t)0x8D50, (q15_t)0xC727, (q15_t)0x8D7D, (q15_t)0xC6CD, - (q15_t)0x8DAA, (q15_t)0xC673, (q15_t)0x8DD8, (q15_t)0xC619, - (q15_t)0x8E05, (q15_t)0xC5BF, (q15_t)0x8E33, (q15_t)0xC566, - (q15_t)0x8E61, (q15_t)0xC50D, (q15_t)0x8E90, (q15_t)0xC4B3, - (q15_t)0x8EBE, (q15_t)0xC45A, (q15_t)0x8EED, (q15_t)0xC402, - (q15_t)0x8F1D, (q15_t)0xC3A9, (q15_t)0x8F4C, (q15_t)0xC350, - (q15_t)0x8F7C, (q15_t)0xC2F8, (q15_t)0x8FAC, (q15_t)0xC29F, - (q15_t)0x8FDC, (q15_t)0xC247, (q15_t)0x900D, (q15_t)0xC1EF, - (q15_t)0x903E, (q15_t)0xC197, (q15_t)0x906F, (q15_t)0xC140, - (q15_t)0x90A0, (q15_t)0xC0E8, (q15_t)0x90D2, (q15_t)0xC091, - (q15_t)0x9104, (q15_t)0xC03A, (q15_t)0x9136, (q15_t)0xBFE2, - (q15_t)0x9169, (q15_t)0xBF8C, (q15_t)0x919C, (q15_t)0xBF35, - (q15_t)0x91CF, (q15_t)0xBEDE, (q15_t)0x9202, (q15_t)0xBE88, - (q15_t)0x9235, (q15_t)0xBE31, (q15_t)0x9269, (q15_t)0xBDDB, - (q15_t)0x929D, (q15_t)0xBD85, (q15_t)0x92D2, (q15_t)0xBD2F, - (q15_t)0x9306, (q15_t)0xBCDA, (q15_t)0x933B, (q15_t)0xBC84, - (q15_t)0x9370, (q15_t)0xBC2F, (q15_t)0x93A6, (q15_t)0xBBDA, - (q15_t)0x93DB, (q15_t)0xBB85, (q15_t)0x9411, (q15_t)0xBB30, - (q15_t)0x9447, (q15_t)0xBADB, (q15_t)0x947E, (q15_t)0xBA87, - (q15_t)0x94B5, (q15_t)0xBA32, (q15_t)0x94EC, (q15_t)0xB9DE, - (q15_t)0x9523, (q15_t)0xB98A, (q15_t)0x955A, (q15_t)0xB936, - (q15_t)0x9592, (q15_t)0xB8E3, (q15_t)0x95CA, (q15_t)0xB88F, - (q15_t)0x9602, (q15_t)0xB83C, (q15_t)0x963B, (q15_t)0xB7E9, - (q15_t)0x9673, (q15_t)0xB796, (q15_t)0x96AC, (q15_t)0xB743, - (q15_t)0x96E6, (q15_t)0xB6F0, (q15_t)0x971F, (q15_t)0xB69E, - (q15_t)0x9759, (q15_t)0xB64B, (q15_t)0x9793, (q15_t)0xB5F9, - (q15_t)0x97CD, (q15_t)0xB5A7, (q15_t)0x9808, (q15_t)0xB556, - (q15_t)0x9842, (q15_t)0xB504, (q15_t)0x987D, (q15_t)0xB4B3, - (q15_t)0x98B9, (q15_t)0xB461, (q15_t)0x98F4, (q15_t)0xB410, - (q15_t)0x9930, (q15_t)0xB3C0, (q15_t)0x996C, (q15_t)0xB36F, - (q15_t)0x99A8, (q15_t)0xB31E, (q15_t)0x99E5, (q15_t)0xB2CE, - (q15_t)0x9A22, (q15_t)0xB27E, (q15_t)0x9A5F, (q15_t)0xB22E, - (q15_t)0x9A9C, (q15_t)0xB1DE, (q15_t)0x9AD9, (q15_t)0xB18F, - (q15_t)0x9B17, (q15_t)0xB140, (q15_t)0x9B55, (q15_t)0xB0F0, - (q15_t)0x9B93, (q15_t)0xB0A1, (q15_t)0x9BD2, (q15_t)0xB053, - (q15_t)0x9C10, (q15_t)0xB004, (q15_t)0x9C4F, (q15_t)0xAFB6, - (q15_t)0x9C8E, (q15_t)0xAF68, (q15_t)0x9CCE, (q15_t)0xAF1A, - (q15_t)0x9D0D, (q15_t)0xAECC, (q15_t)0x9D4D, (q15_t)0xAE7E, - (q15_t)0x9D8E, (q15_t)0xAE31, (q15_t)0x9DCE, (q15_t)0xADE3, - (q15_t)0x9E0E, (q15_t)0xAD96, (q15_t)0x9E4F, (q15_t)0xAD4A, - (q15_t)0x9E90, (q15_t)0xACFD, (q15_t)0x9ED2, (q15_t)0xACB1, - (q15_t)0x9F13, (q15_t)0xAC64, (q15_t)0x9F55, (q15_t)0xAC18, - (q15_t)0x9F97, (q15_t)0xABCC, (q15_t)0x9FD9, (q15_t)0xAB81, - (q15_t)0xA01C, (q15_t)0xAB35, (q15_t)0xA05F, (q15_t)0xAAEA, - (q15_t)0xA0A1, (q15_t)0xAA9F, (q15_t)0xA0E5, (q15_t)0xAA54, - (q15_t)0xA128, (q15_t)0xAA0A, (q15_t)0xA16C, (q15_t)0xA9BF, - (q15_t)0xA1AF, (q15_t)0xA975, (q15_t)0xA1F4, (q15_t)0xA92B, - (q15_t)0xA238, (q15_t)0xA8E2, (q15_t)0xA27C, (q15_t)0xA898, - (q15_t)0xA2C1, (q15_t)0xA84F, (q15_t)0xA306, (q15_t)0xA806, - (q15_t)0xA34B, (q15_t)0xA7BD, (q15_t)0xA391, (q15_t)0xA774, - (q15_t)0xA3D6, (q15_t)0xA72B, (q15_t)0xA41C, (q15_t)0xA6E3, - (q15_t)0xA462, (q15_t)0xA69B, (q15_t)0xA4A9, (q15_t)0xA653, - (q15_t)0xA4EF, (q15_t)0xA60C, (q15_t)0xA536, (q15_t)0xA5C4, - (q15_t)0xA57D, (q15_t)0xA57D, (q15_t)0xA5C4, (q15_t)0xA536, - (q15_t)0xA60C, (q15_t)0xA4EF, (q15_t)0xA653, (q15_t)0xA4A9, - (q15_t)0xA69B, (q15_t)0xA462, (q15_t)0xA6E3, (q15_t)0xA41C, - (q15_t)0xA72B, (q15_t)0xA3D6, (q15_t)0xA774, (q15_t)0xA391, - (q15_t)0xA7BD, (q15_t)0xA34B, (q15_t)0xA806, (q15_t)0xA306, - (q15_t)0xA84F, (q15_t)0xA2C1, (q15_t)0xA898, (q15_t)0xA27C, - (q15_t)0xA8E2, (q15_t)0xA238, (q15_t)0xA92B, (q15_t)0xA1F4, - (q15_t)0xA975, (q15_t)0xA1AF, (q15_t)0xA9BF, (q15_t)0xA16C, - (q15_t)0xAA0A, (q15_t)0xA128, (q15_t)0xAA54, (q15_t)0xA0E5, - (q15_t)0xAA9F, (q15_t)0xA0A1, (q15_t)0xAAEA, (q15_t)0xA05F, - (q15_t)0xAB35, (q15_t)0xA01C, (q15_t)0xAB81, (q15_t)0x9FD9, - (q15_t)0xABCC, (q15_t)0x9F97, (q15_t)0xAC18, (q15_t)0x9F55, - (q15_t)0xAC64, (q15_t)0x9F13, (q15_t)0xACB1, (q15_t)0x9ED2, - (q15_t)0xACFD, (q15_t)0x9E90, (q15_t)0xAD4A, (q15_t)0x9E4F, - (q15_t)0xAD96, (q15_t)0x9E0E, (q15_t)0xADE3, (q15_t)0x9DCE, - (q15_t)0xAE31, (q15_t)0x9D8E, (q15_t)0xAE7E, (q15_t)0x9D4D, - (q15_t)0xAECC, (q15_t)0x9D0D, (q15_t)0xAF1A, (q15_t)0x9CCE, - (q15_t)0xAF68, (q15_t)0x9C8E, (q15_t)0xAFB6, (q15_t)0x9C4F, - (q15_t)0xB004, (q15_t)0x9C10, (q15_t)0xB053, (q15_t)0x9BD2, - (q15_t)0xB0A1, (q15_t)0x9B93, (q15_t)0xB0F0, (q15_t)0x9B55, - (q15_t)0xB140, (q15_t)0x9B17, (q15_t)0xB18F, (q15_t)0x9AD9, - (q15_t)0xB1DE, (q15_t)0x9A9C, (q15_t)0xB22E, (q15_t)0x9A5F, - (q15_t)0xB27E, (q15_t)0x9A22, (q15_t)0xB2CE, (q15_t)0x99E5, - (q15_t)0xB31E, (q15_t)0x99A8, (q15_t)0xB36F, (q15_t)0x996C, - (q15_t)0xB3C0, (q15_t)0x9930, (q15_t)0xB410, (q15_t)0x98F4, - (q15_t)0xB461, (q15_t)0x98B9, (q15_t)0xB4B3, (q15_t)0x987D, - (q15_t)0xB504, (q15_t)0x9842, (q15_t)0xB556, (q15_t)0x9808, - (q15_t)0xB5A7, (q15_t)0x97CD, (q15_t)0xB5F9, (q15_t)0x9793, - (q15_t)0xB64B, (q15_t)0x9759, (q15_t)0xB69E, (q15_t)0x971F, - (q15_t)0xB6F0, (q15_t)0x96E6, (q15_t)0xB743, (q15_t)0x96AC, - (q15_t)0xB796, (q15_t)0x9673, (q15_t)0xB7E9, (q15_t)0x963B, - (q15_t)0xB83C, (q15_t)0x9602, (q15_t)0xB88F, (q15_t)0x95CA, - (q15_t)0xB8E3, (q15_t)0x9592, (q15_t)0xB936, (q15_t)0x955A, - (q15_t)0xB98A, (q15_t)0x9523, (q15_t)0xB9DE, (q15_t)0x94EC, - (q15_t)0xBA32, (q15_t)0x94B5, (q15_t)0xBA87, (q15_t)0x947E, - (q15_t)0xBADB, (q15_t)0x9447, (q15_t)0xBB30, (q15_t)0x9411, - (q15_t)0xBB85, (q15_t)0x93DB, (q15_t)0xBBDA, (q15_t)0x93A6, - (q15_t)0xBC2F, (q15_t)0x9370, (q15_t)0xBC84, (q15_t)0x933B, - (q15_t)0xBCDA, (q15_t)0x9306, (q15_t)0xBD2F, (q15_t)0x92D2, - (q15_t)0xBD85, (q15_t)0x929D, (q15_t)0xBDDB, (q15_t)0x9269, - (q15_t)0xBE31, (q15_t)0x9235, (q15_t)0xBE88, (q15_t)0x9202, - (q15_t)0xBEDE, (q15_t)0x91CF, (q15_t)0xBF35, (q15_t)0x919C, - (q15_t)0xBF8C, (q15_t)0x9169, (q15_t)0xBFE2, (q15_t)0x9136, - (q15_t)0xC03A, (q15_t)0x9104, (q15_t)0xC091, (q15_t)0x90D2, - (q15_t)0xC0E8, (q15_t)0x90A0, (q15_t)0xC140, (q15_t)0x906F, - (q15_t)0xC197, (q15_t)0x903E, (q15_t)0xC1EF, (q15_t)0x900D, - (q15_t)0xC247, (q15_t)0x8FDC, (q15_t)0xC29F, (q15_t)0x8FAC, - (q15_t)0xC2F8, (q15_t)0x8F7C, (q15_t)0xC350, (q15_t)0x8F4C, - (q15_t)0xC3A9, (q15_t)0x8F1D, (q15_t)0xC402, (q15_t)0x8EED, - (q15_t)0xC45A, (q15_t)0x8EBE, (q15_t)0xC4B3, (q15_t)0x8E90, - (q15_t)0xC50D, (q15_t)0x8E61, (q15_t)0xC566, (q15_t)0x8E33, - (q15_t)0xC5BF, (q15_t)0x8E05, (q15_t)0xC619, (q15_t)0x8DD8, - (q15_t)0xC673, (q15_t)0x8DAA, (q15_t)0xC6CD, (q15_t)0x8D7D, - (q15_t)0xC727, (q15_t)0x8D50, (q15_t)0xC781, (q15_t)0x8D24, - (q15_t)0xC7DB, (q15_t)0x8CF8, (q15_t)0xC835, (q15_t)0x8CCC, - (q15_t)0xC890, (q15_t)0x8CA0, (q15_t)0xC8EB, (q15_t)0x8C75, - (q15_t)0xC945, (q15_t)0x8C4A, (q15_t)0xC9A0, (q15_t)0x8C1F, - (q15_t)0xC9FB, (q15_t)0x8BF4, (q15_t)0xCA57, (q15_t)0x8BCA, - (q15_t)0xCAB2, (q15_t)0x8BA0, (q15_t)0xCB0D, (q15_t)0x8B76, - (q15_t)0xCB69, (q15_t)0x8B4D, (q15_t)0xCBC5, (q15_t)0x8B24, - (q15_t)0xCC21, (q15_t)0x8AFB, (q15_t)0xCC7D, (q15_t)0x8AD2, - (q15_t)0xCCD9, (q15_t)0x8AAA, (q15_t)0xCD35, (q15_t)0x8A82, - (q15_t)0xCD91, (q15_t)0x8A5A, (q15_t)0xCDEE, (q15_t)0x8A33, - (q15_t)0xCE4A, (q15_t)0x8A0B, (q15_t)0xCEA7, (q15_t)0x89E4, - (q15_t)0xCF04, (q15_t)0x89BE, (q15_t)0xCF61, (q15_t)0x8997, - (q15_t)0xCFBE, (q15_t)0x8971, (q15_t)0xD01B, (q15_t)0x894C, - (q15_t)0xD078, (q15_t)0x8926, (q15_t)0xD0D6, (q15_t)0x8901, - (q15_t)0xD133, (q15_t)0x88DC, (q15_t)0xD191, (q15_t)0x88B8, - (q15_t)0xD1EE, (q15_t)0x8893, (q15_t)0xD24C, (q15_t)0x886F, - (q15_t)0xD2AA, (q15_t)0x884B, (q15_t)0xD308, (q15_t)0x8828, - (q15_t)0xD367, (q15_t)0x8805, (q15_t)0xD3C5, (q15_t)0x87E2, - (q15_t)0xD423, (q15_t)0x87BF, (q15_t)0xD482, (q15_t)0x879D, - (q15_t)0xD4E0, (q15_t)0x877B, (q15_t)0xD53F, (q15_t)0x8759, - (q15_t)0xD59E, (q15_t)0x8738, (q15_t)0xD5FD, (q15_t)0x8717, - (q15_t)0xD65C, (q15_t)0x86F6, (q15_t)0xD6BB, (q15_t)0x86D5, - (q15_t)0xD71A, (q15_t)0x86B5, (q15_t)0xD779, (q15_t)0x8695, - (q15_t)0xD7D9, (q15_t)0x8675, (q15_t)0xD838, (q15_t)0x8656, - (q15_t)0xD898, (q15_t)0x8637, (q15_t)0xD8F8, (q15_t)0x8618, - (q15_t)0xD957, (q15_t)0x85FA, (q15_t)0xD9B7, (q15_t)0x85DB, - (q15_t)0xDA17, (q15_t)0x85BD, (q15_t)0xDA77, (q15_t)0x85A0, - (q15_t)0xDAD7, (q15_t)0x8582, (q15_t)0xDB38, (q15_t)0x8565, - (q15_t)0xDB98, (q15_t)0x8549, (q15_t)0xDBF8, (q15_t)0x852C, - (q15_t)0xDC59, (q15_t)0x8510, (q15_t)0xDCBA, (q15_t)0x84F4, - (q15_t)0xDD1A, (q15_t)0x84D9, (q15_t)0xDD7B, (q15_t)0x84BD, - (q15_t)0xDDDC, (q15_t)0x84A2, (q15_t)0xDE3D, (q15_t)0x8488, - (q15_t)0xDE9E, (q15_t)0x846D, (q15_t)0xDEFF, (q15_t)0x8453, - (q15_t)0xDF60, (q15_t)0x843A, (q15_t)0xDFC1, (q15_t)0x8420, - (q15_t)0xE023, (q15_t)0x8407, (q15_t)0xE084, (q15_t)0x83EE, - (q15_t)0xE0E6, (q15_t)0x83D6, (q15_t)0xE147, (q15_t)0x83BD, - (q15_t)0xE1A9, (q15_t)0x83A5, (q15_t)0xE20A, (q15_t)0x838E, - (q15_t)0xE26C, (q15_t)0x8376, (q15_t)0xE2CE, (q15_t)0x835F, - (q15_t)0xE330, (q15_t)0x8348, (q15_t)0xE392, (q15_t)0x8332, - (q15_t)0xE3F4, (q15_t)0x831C, (q15_t)0xE456, (q15_t)0x8306, - (q15_t)0xE4B8, (q15_t)0x82F0, (q15_t)0xE51B, (q15_t)0x82DB, - (q15_t)0xE57D, (q15_t)0x82C6, (q15_t)0xE5DF, (q15_t)0x82B1, - (q15_t)0xE642, (q15_t)0x829D, (q15_t)0xE6A4, (q15_t)0x8289, - (q15_t)0xE707, (q15_t)0x8275, (q15_t)0xE769, (q15_t)0x8262, - (q15_t)0xE7CC, (q15_t)0x824F, (q15_t)0xE82F, (q15_t)0x823C, - (q15_t)0xE892, (q15_t)0x8229, (q15_t)0xE8F5, (q15_t)0x8217, - (q15_t)0xE957, (q15_t)0x8205, (q15_t)0xE9BA, (q15_t)0x81F3, - (q15_t)0xEA1D, (q15_t)0x81E2, (q15_t)0xEA80, (q15_t)0x81D1, - (q15_t)0xEAE4, (q15_t)0x81C0, (q15_t)0xEB47, (q15_t)0x81B0, - (q15_t)0xEBAA, (q15_t)0x81A0, (q15_t)0xEC0D, (q15_t)0x8190, - (q15_t)0xEC71, (q15_t)0x8180, (q15_t)0xECD4, (q15_t)0x8171, - (q15_t)0xED37, (q15_t)0x8162, (q15_t)0xED9B, (q15_t)0x8154, - (q15_t)0xEDFE, (q15_t)0x8145, (q15_t)0xEE62, (q15_t)0x8137, - (q15_t)0xEEC6, (q15_t)0x812A, (q15_t)0xEF29, (q15_t)0x811C, - (q15_t)0xEF8D, (q15_t)0x810F, (q15_t)0xEFF1, (q15_t)0x8102, - (q15_t)0xF054, (q15_t)0x80F6, (q15_t)0xF0B8, (q15_t)0x80EA, - (q15_t)0xF11C, (q15_t)0x80DE, (q15_t)0xF180, (q15_t)0x80D2, - (q15_t)0xF1E4, (q15_t)0x80C7, (q15_t)0xF248, (q15_t)0x80BC, - (q15_t)0xF2AC, (q15_t)0x80B2, (q15_t)0xF310, (q15_t)0x80A7, - (q15_t)0xF374, (q15_t)0x809D, (q15_t)0xF3D8, (q15_t)0x8094, - (q15_t)0xF43C, (q15_t)0x808A, (q15_t)0xF4A0, (q15_t)0x8081, - (q15_t)0xF504, (q15_t)0x8078, (q15_t)0xF568, (q15_t)0x8070, - (q15_t)0xF5CC, (q15_t)0x8068, (q15_t)0xF631, (q15_t)0x8060, - (q15_t)0xF695, (q15_t)0x8058, (q15_t)0xF6F9, (q15_t)0x8051, - (q15_t)0xF75D, (q15_t)0x804A, (q15_t)0xF7C2, (q15_t)0x8043, - (q15_t)0xF826, (q15_t)0x803D, (q15_t)0xF88A, (q15_t)0x8037, - (q15_t)0xF8EF, (q15_t)0x8031, (q15_t)0xF953, (q15_t)0x802C, - (q15_t)0xF9B8, (q15_t)0x8027, (q15_t)0xFA1C, (q15_t)0x8022, - (q15_t)0xFA80, (q15_t)0x801E, (q15_t)0xFAE5, (q15_t)0x801A, - (q15_t)0xFB49, (q15_t)0x8016, (q15_t)0xFBAE, (q15_t)0x8012, - (q15_t)0xFC12, (q15_t)0x800F, (q15_t)0xFC77, (q15_t)0x800C, - (q15_t)0xFCDB, (q15_t)0x8009, (q15_t)0xFD40, (q15_t)0x8007, - (q15_t)0xFDA4, (q15_t)0x8005, (q15_t)0xFE09, (q15_t)0x8003, - (q15_t)0xFE6D, (q15_t)0x8002, (q15_t)0xFED2, (q15_t)0x8001, - (q15_t)0xFF36, (q15_t)0x8000, (q15_t)0xFF9B, (q15_t)0x8000 -}; + (q15_t)0x7FFF, (q15_t)0x0000, (q15_t)0x7FFF, (q15_t)0x0064, (q15_t)0x7FFF, + (q15_t)0x00C9, (q15_t)0x7FFE, (q15_t)0x012D, (q15_t)0x7FFD, (q15_t)0x0192, + (q15_t)0x7FFC, (q15_t)0x01F6, (q15_t)0x7FFA, (q15_t)0x025B, (q15_t)0x7FF8, + (q15_t)0x02BF, (q15_t)0x7FF6, (q15_t)0x0324, (q15_t)0x7FF3, (q15_t)0x0388, + (q15_t)0x7FF0, (q15_t)0x03ED, (q15_t)0x7FED, (q15_t)0x0451, (q15_t)0x7FE9, + (q15_t)0x04B6, (q15_t)0x7FE5, (q15_t)0x051A, (q15_t)0x7FE1, (q15_t)0x057F, + (q15_t)0x7FDD, (q15_t)0x05E3, (q15_t)0x7FD8, (q15_t)0x0647, (q15_t)0x7FD3, + (q15_t)0x06AC, (q15_t)0x7FCE, (q15_t)0x0710, (q15_t)0x7FC8, (q15_t)0x0775, + (q15_t)0x7FC2, (q15_t)0x07D9, (q15_t)0x7FBC, (q15_t)0x083D, (q15_t)0x7FB5, + (q15_t)0x08A2, (q15_t)0x7FAE, (q15_t)0x0906, (q15_t)0x7FA7, (q15_t)0x096A, + (q15_t)0x7F9F, (q15_t)0x09CE, (q15_t)0x7F97, (q15_t)0x0A33, (q15_t)0x7F8F, + (q15_t)0x0A97, (q15_t)0x7F87, (q15_t)0x0AFB, (q15_t)0x7F7E, (q15_t)0x0B5F, + (q15_t)0x7F75, (q15_t)0x0BC3, (q15_t)0x7F6B, (q15_t)0x0C27, (q15_t)0x7F62, + (q15_t)0x0C8B, (q15_t)0x7F58, (q15_t)0x0CEF, (q15_t)0x7F4D, (q15_t)0x0D53, + (q15_t)0x7F43, (q15_t)0x0DB7, (q15_t)0x7F38, (q15_t)0x0E1B, (q15_t)0x7F2D, + (q15_t)0x0E7F, (q15_t)0x7F21, (q15_t)0x0EE3, (q15_t)0x7F15, (q15_t)0x0F47, + (q15_t)0x7F09, (q15_t)0x0FAB, (q15_t)0x7EFD, (q15_t)0x100E, (q15_t)0x7EF0, + (q15_t)0x1072, (q15_t)0x7EE3, (q15_t)0x10D6, (q15_t)0x7ED5, (q15_t)0x1139, + (q15_t)0x7EC8, (q15_t)0x119D, (q15_t)0x7EBA, (q15_t)0x1201, (q15_t)0x7EAB, + (q15_t)0x1264, (q15_t)0x7E9D, (q15_t)0x12C8, (q15_t)0x7E8E, (q15_t)0x132B, + (q15_t)0x7E7F, (q15_t)0x138E, (q15_t)0x7E6F, (q15_t)0x13F2, (q15_t)0x7E5F, + (q15_t)0x1455, (q15_t)0x7E4F, (q15_t)0x14B8, (q15_t)0x7E3F, (q15_t)0x151B, + (q15_t)0x7E2E, (q15_t)0x157F, (q15_t)0x7E1D, (q15_t)0x15E2, (q15_t)0x7E0C, + (q15_t)0x1645, (q15_t)0x7DFA, (q15_t)0x16A8, (q15_t)0x7DE8, (q15_t)0x170A, + (q15_t)0x7DD6, (q15_t)0x176D, (q15_t)0x7DC3, (q15_t)0x17D0, (q15_t)0x7DB0, + (q15_t)0x1833, (q15_t)0x7D9D, (q15_t)0x1896, (q15_t)0x7D8A, (q15_t)0x18F8, + (q15_t)0x7D76, (q15_t)0x195B, (q15_t)0x7D62, (q15_t)0x19BD, (q15_t)0x7D4E, + (q15_t)0x1A20, (q15_t)0x7D39, (q15_t)0x1A82, (q15_t)0x7D24, (q15_t)0x1AE4, + (q15_t)0x7D0F, (q15_t)0x1B47, (q15_t)0x7CF9, (q15_t)0x1BA9, (q15_t)0x7CE3, + (q15_t)0x1C0B, (q15_t)0x7CCD, (q15_t)0x1C6D, (q15_t)0x7CB7, (q15_t)0x1CCF, + (q15_t)0x7CA0, (q15_t)0x1D31, (q15_t)0x7C89, (q15_t)0x1D93, (q15_t)0x7C71, + (q15_t)0x1DF5, (q15_t)0x7C5A, (q15_t)0x1E56, (q15_t)0x7C42, (q15_t)0x1EB8, + (q15_t)0x7C29, (q15_t)0x1F19, (q15_t)0x7C11, (q15_t)0x1F7B, (q15_t)0x7BF8, + (q15_t)0x1FDC, (q15_t)0x7BDF, (q15_t)0x203E, (q15_t)0x7BC5, (q15_t)0x209F, + (q15_t)0x7BAC, (q15_t)0x2100, (q15_t)0x7B92, (q15_t)0x2161, (q15_t)0x7B77, + (q15_t)0x21C2, (q15_t)0x7B5D, (q15_t)0x2223, (q15_t)0x7B42, (q15_t)0x2284, + (q15_t)0x7B26, (q15_t)0x22E5, (q15_t)0x7B0B, (q15_t)0x2345, (q15_t)0x7AEF, + (q15_t)0x23A6, (q15_t)0x7AD3, (q15_t)0x2407, (q15_t)0x7AB6, (q15_t)0x2467, + (q15_t)0x7A9A, (q15_t)0x24C7, (q15_t)0x7A7D, (q15_t)0x2528, (q15_t)0x7A5F, + (q15_t)0x2588, (q15_t)0x7A42, (q15_t)0x25E8, (q15_t)0x7A24, (q15_t)0x2648, + (q15_t)0x7A05, (q15_t)0x26A8, (q15_t)0x79E7, (q15_t)0x2707, (q15_t)0x79C8, + (q15_t)0x2767, (q15_t)0x79A9, (q15_t)0x27C7, (q15_t)0x798A, (q15_t)0x2826, + (q15_t)0x796A, (q15_t)0x2886, (q15_t)0x794A, (q15_t)0x28E5, (q15_t)0x792A, + (q15_t)0x2944, (q15_t)0x7909, (q15_t)0x29A3, (q15_t)0x78E8, (q15_t)0x2A02, + (q15_t)0x78C7, (q15_t)0x2A61, (q15_t)0x78A6, (q15_t)0x2AC0, (q15_t)0x7884, + (q15_t)0x2B1F, (q15_t)0x7862, (q15_t)0x2B7D, (q15_t)0x7840, (q15_t)0x2BDC, + (q15_t)0x781D, (q15_t)0x2C3A, (q15_t)0x77FA, (q15_t)0x2C98, (q15_t)0x77D7, + (q15_t)0x2CF7, (q15_t)0x77B4, (q15_t)0x2D55, (q15_t)0x7790, (q15_t)0x2DB3, + (q15_t)0x776C, (q15_t)0x2E11, (q15_t)0x7747, (q15_t)0x2E6E, (q15_t)0x7723, + (q15_t)0x2ECC, (q15_t)0x76FE, (q15_t)0x2F29, (q15_t)0x76D9, (q15_t)0x2F87, + (q15_t)0x76B3, (q15_t)0x2FE4, (q15_t)0x768E, (q15_t)0x3041, (q15_t)0x7668, + (q15_t)0x309E, (q15_t)0x7641, (q15_t)0x30FB, (q15_t)0x761B, (q15_t)0x3158, + (q15_t)0x75F4, (q15_t)0x31B5, (q15_t)0x75CC, (q15_t)0x3211, (q15_t)0x75A5, + (q15_t)0x326E, (q15_t)0x757D, (q15_t)0x32CA, (q15_t)0x7555, (q15_t)0x3326, + (q15_t)0x752D, (q15_t)0x3382, (q15_t)0x7504, (q15_t)0x33DE, (q15_t)0x74DB, + (q15_t)0x343A, (q15_t)0x74B2, (q15_t)0x3496, (q15_t)0x7489, (q15_t)0x34F2, + (q15_t)0x745F, (q15_t)0x354D, (q15_t)0x7435, (q15_t)0x35A8, (q15_t)0x740B, + (q15_t)0x3604, (q15_t)0x73E0, (q15_t)0x365F, (q15_t)0x73B5, (q15_t)0x36BA, + (q15_t)0x738A, (q15_t)0x3714, (q15_t)0x735F, (q15_t)0x376F, (q15_t)0x7333, + (q15_t)0x37CA, (q15_t)0x7307, (q15_t)0x3824, (q15_t)0x72DB, (q15_t)0x387E, + (q15_t)0x72AF, (q15_t)0x38D8, (q15_t)0x7282, (q15_t)0x3932, (q15_t)0x7255, + (q15_t)0x398C, (q15_t)0x7227, (q15_t)0x39E6, (q15_t)0x71FA, (q15_t)0x3A40, + (q15_t)0x71CC, (q15_t)0x3A99, (q15_t)0x719E, (q15_t)0x3AF2, (q15_t)0x716F, + (q15_t)0x3B4C, (q15_t)0x7141, (q15_t)0x3BA5, (q15_t)0x7112, (q15_t)0x3BFD, + (q15_t)0x70E2, (q15_t)0x3C56, (q15_t)0x70B3, (q15_t)0x3CAF, (q15_t)0x7083, + (q15_t)0x3D07, (q15_t)0x7053, (q15_t)0x3D60, (q15_t)0x7023, (q15_t)0x3DB8, + (q15_t)0x6FF2, (q15_t)0x3E10, (q15_t)0x6FC1, (q15_t)0x3E68, (q15_t)0x6F90, + (q15_t)0x3EBF, (q15_t)0x6F5F, (q15_t)0x3F17, (q15_t)0x6F2D, (q15_t)0x3F6E, + (q15_t)0x6EFB, (q15_t)0x3FC5, (q15_t)0x6EC9, (q15_t)0x401D, (q15_t)0x6E96, + (q15_t)0x4073, (q15_t)0x6E63, (q15_t)0x40CA, (q15_t)0x6E30, (q15_t)0x4121, + (q15_t)0x6DFD, (q15_t)0x4177, (q15_t)0x6DCA, (q15_t)0x41CE, (q15_t)0x6D96, + (q15_t)0x4224, (q15_t)0x6D62, (q15_t)0x427A, (q15_t)0x6D2D, (q15_t)0x42D0, + (q15_t)0x6CF9, (q15_t)0x4325, (q15_t)0x6CC4, (q15_t)0x437B, (q15_t)0x6C8F, + (q15_t)0x43D0, (q15_t)0x6C59, (q15_t)0x4425, (q15_t)0x6C24, (q15_t)0x447A, + (q15_t)0x6BEE, (q15_t)0x44CF, (q15_t)0x6BB8, (q15_t)0x4524, (q15_t)0x6B81, + (q15_t)0x4578, (q15_t)0x6B4A, (q15_t)0x45CD, (q15_t)0x6B13, (q15_t)0x4621, + (q15_t)0x6ADC, (q15_t)0x4675, (q15_t)0x6AA5, (q15_t)0x46C9, (q15_t)0x6A6D, + (q15_t)0x471C, (q15_t)0x6A35, (q15_t)0x4770, (q15_t)0x69FD, (q15_t)0x47C3, + (q15_t)0x69C4, (q15_t)0x4816, (q15_t)0x698C, (q15_t)0x4869, (q15_t)0x6953, + (q15_t)0x48BC, (q15_t)0x6919, (q15_t)0x490F, (q15_t)0x68E0, (q15_t)0x4961, + (q15_t)0x68A6, (q15_t)0x49B4, (q15_t)0x686C, (q15_t)0x4A06, (q15_t)0x6832, + (q15_t)0x4A58, (q15_t)0x67F7, (q15_t)0x4AA9, (q15_t)0x67BD, (q15_t)0x4AFB, + (q15_t)0x6782, (q15_t)0x4B4C, (q15_t)0x6746, (q15_t)0x4B9E, (q15_t)0x670B, + (q15_t)0x4BEF, (q15_t)0x66CF, (q15_t)0x4C3F, (q15_t)0x6693, (q15_t)0x4C90, + (q15_t)0x6657, (q15_t)0x4CE1, (q15_t)0x661A, (q15_t)0x4D31, (q15_t)0x65DD, + (q15_t)0x4D81, (q15_t)0x65A0, (q15_t)0x4DD1, (q15_t)0x6563, (q15_t)0x4E21, + (q15_t)0x6526, (q15_t)0x4E70, (q15_t)0x64E8, (q15_t)0x4EBF, (q15_t)0x64AA, + (q15_t)0x4F0F, (q15_t)0x646C, (q15_t)0x4F5E, (q15_t)0x642D, (q15_t)0x4FAC, + (q15_t)0x63EF, (q15_t)0x4FFB, (q15_t)0x63B0, (q15_t)0x5049, (q15_t)0x6371, + (q15_t)0x5097, (q15_t)0x6331, (q15_t)0x50E5, (q15_t)0x62F2, (q15_t)0x5133, + (q15_t)0x62B2, (q15_t)0x5181, (q15_t)0x6271, (q15_t)0x51CE, (q15_t)0x6231, + (q15_t)0x521C, (q15_t)0x61F1, (q15_t)0x5269, (q15_t)0x61B0, (q15_t)0x52B5, + (q15_t)0x616F, (q15_t)0x5302, (q15_t)0x612D, (q15_t)0x534E, (q15_t)0x60EC, + (q15_t)0x539B, (q15_t)0x60AA, (q15_t)0x53E7, (q15_t)0x6068, (q15_t)0x5433, + (q15_t)0x6026, (q15_t)0x547E, (q15_t)0x5FE3, (q15_t)0x54CA, (q15_t)0x5FA0, + (q15_t)0x5515, (q15_t)0x5F5E, (q15_t)0x5560, (q15_t)0x5F1A, (q15_t)0x55AB, + (q15_t)0x5ED7, (q15_t)0x55F5, (q15_t)0x5E93, (q15_t)0x5640, (q15_t)0x5E50, + (q15_t)0x568A, (q15_t)0x5E0B, (q15_t)0x56D4, (q15_t)0x5DC7, (q15_t)0x571D, + (q15_t)0x5D83, (q15_t)0x5767, (q15_t)0x5D3E, (q15_t)0x57B0, (q15_t)0x5CF9, + (q15_t)0x57F9, (q15_t)0x5CB4, (q15_t)0x5842, (q15_t)0x5C6E, (q15_t)0x588B, + (q15_t)0x5C29, (q15_t)0x58D4, (q15_t)0x5BE3, (q15_t)0x591C, (q15_t)0x5B9D, + (q15_t)0x5964, (q15_t)0x5B56, (q15_t)0x59AC, (q15_t)0x5B10, (q15_t)0x59F3, + (q15_t)0x5AC9, (q15_t)0x5A3B, (q15_t)0x5A82, (q15_t)0x5A82, (q15_t)0x5A3B, + (q15_t)0x5AC9, (q15_t)0x59F3, (q15_t)0x5B10, (q15_t)0x59AC, (q15_t)0x5B56, + (q15_t)0x5964, (q15_t)0x5B9D, (q15_t)0x591C, (q15_t)0x5BE3, (q15_t)0x58D4, + (q15_t)0x5C29, (q15_t)0x588B, (q15_t)0x5C6E, (q15_t)0x5842, (q15_t)0x5CB4, + (q15_t)0x57F9, (q15_t)0x5CF9, (q15_t)0x57B0, (q15_t)0x5D3E, (q15_t)0x5767, + (q15_t)0x5D83, (q15_t)0x571D, (q15_t)0x5DC7, (q15_t)0x56D4, (q15_t)0x5E0B, + (q15_t)0x568A, (q15_t)0x5E50, (q15_t)0x5640, (q15_t)0x5E93, (q15_t)0x55F5, + (q15_t)0x5ED7, (q15_t)0x55AB, (q15_t)0x5F1A, (q15_t)0x5560, (q15_t)0x5F5E, + (q15_t)0x5515, (q15_t)0x5FA0, (q15_t)0x54CA, (q15_t)0x5FE3, (q15_t)0x547E, + (q15_t)0x6026, (q15_t)0x5433, (q15_t)0x6068, (q15_t)0x53E7, (q15_t)0x60AA, + (q15_t)0x539B, (q15_t)0x60EC, (q15_t)0x534E, (q15_t)0x612D, (q15_t)0x5302, + (q15_t)0x616F, (q15_t)0x52B5, (q15_t)0x61B0, (q15_t)0x5269, (q15_t)0x61F1, + (q15_t)0x521C, (q15_t)0x6231, (q15_t)0x51CE, (q15_t)0x6271, (q15_t)0x5181, + (q15_t)0x62B2, (q15_t)0x5133, (q15_t)0x62F2, (q15_t)0x50E5, (q15_t)0x6331, + (q15_t)0x5097, (q15_t)0x6371, (q15_t)0x5049, (q15_t)0x63B0, (q15_t)0x4FFB, + (q15_t)0x63EF, (q15_t)0x4FAC, (q15_t)0x642D, (q15_t)0x4F5E, (q15_t)0x646C, + (q15_t)0x4F0F, (q15_t)0x64AA, (q15_t)0x4EBF, (q15_t)0x64E8, (q15_t)0x4E70, + (q15_t)0x6526, (q15_t)0x4E21, (q15_t)0x6563, (q15_t)0x4DD1, (q15_t)0x65A0, + (q15_t)0x4D81, (q15_t)0x65DD, (q15_t)0x4D31, (q15_t)0x661A, (q15_t)0x4CE1, + (q15_t)0x6657, (q15_t)0x4C90, (q15_t)0x6693, (q15_t)0x4C3F, (q15_t)0x66CF, + (q15_t)0x4BEF, (q15_t)0x670B, (q15_t)0x4B9E, (q15_t)0x6746, (q15_t)0x4B4C, + (q15_t)0x6782, (q15_t)0x4AFB, (q15_t)0x67BD, (q15_t)0x4AA9, (q15_t)0x67F7, + (q15_t)0x4A58, (q15_t)0x6832, (q15_t)0x4A06, (q15_t)0x686C, (q15_t)0x49B4, + (q15_t)0x68A6, (q15_t)0x4961, (q15_t)0x68E0, (q15_t)0x490F, (q15_t)0x6919, + (q15_t)0x48BC, (q15_t)0x6953, (q15_t)0x4869, (q15_t)0x698C, (q15_t)0x4816, + (q15_t)0x69C4, (q15_t)0x47C3, (q15_t)0x69FD, (q15_t)0x4770, (q15_t)0x6A35, + (q15_t)0x471C, (q15_t)0x6A6D, (q15_t)0x46C9, (q15_t)0x6AA5, (q15_t)0x4675, + (q15_t)0x6ADC, (q15_t)0x4621, (q15_t)0x6B13, (q15_t)0x45CD, (q15_t)0x6B4A, + (q15_t)0x4578, (q15_t)0x6B81, (q15_t)0x4524, (q15_t)0x6BB8, (q15_t)0x44CF, + (q15_t)0x6BEE, (q15_t)0x447A, (q15_t)0x6C24, (q15_t)0x4425, (q15_t)0x6C59, + (q15_t)0x43D0, (q15_t)0x6C8F, (q15_t)0x437B, (q15_t)0x6CC4, (q15_t)0x4325, + (q15_t)0x6CF9, (q15_t)0x42D0, (q15_t)0x6D2D, (q15_t)0x427A, (q15_t)0x6D62, + (q15_t)0x4224, (q15_t)0x6D96, (q15_t)0x41CE, (q15_t)0x6DCA, (q15_t)0x4177, + (q15_t)0x6DFD, (q15_t)0x4121, (q15_t)0x6E30, (q15_t)0x40CA, (q15_t)0x6E63, + (q15_t)0x4073, (q15_t)0x6E96, (q15_t)0x401D, (q15_t)0x6EC9, (q15_t)0x3FC5, + (q15_t)0x6EFB, (q15_t)0x3F6E, (q15_t)0x6F2D, (q15_t)0x3F17, (q15_t)0x6F5F, + (q15_t)0x3EBF, (q15_t)0x6F90, (q15_t)0x3E68, (q15_t)0x6FC1, (q15_t)0x3E10, + (q15_t)0x6FF2, (q15_t)0x3DB8, (q15_t)0x7023, (q15_t)0x3D60, (q15_t)0x7053, + (q15_t)0x3D07, (q15_t)0x7083, (q15_t)0x3CAF, (q15_t)0x70B3, (q15_t)0x3C56, + (q15_t)0x70E2, (q15_t)0x3BFD, (q15_t)0x7112, (q15_t)0x3BA5, (q15_t)0x7141, + (q15_t)0x3B4C, (q15_t)0x716F, (q15_t)0x3AF2, (q15_t)0x719E, (q15_t)0x3A99, + (q15_t)0x71CC, (q15_t)0x3A40, (q15_t)0x71FA, (q15_t)0x39E6, (q15_t)0x7227, + (q15_t)0x398C, (q15_t)0x7255, (q15_t)0x3932, (q15_t)0x7282, (q15_t)0x38D8, + (q15_t)0x72AF, (q15_t)0x387E, (q15_t)0x72DB, (q15_t)0x3824, (q15_t)0x7307, + (q15_t)0x37CA, (q15_t)0x7333, (q15_t)0x376F, (q15_t)0x735F, (q15_t)0x3714, + (q15_t)0x738A, (q15_t)0x36BA, (q15_t)0x73B5, (q15_t)0x365F, (q15_t)0x73E0, + (q15_t)0x3604, (q15_t)0x740B, (q15_t)0x35A8, (q15_t)0x7435, (q15_t)0x354D, + (q15_t)0x745F, (q15_t)0x34F2, (q15_t)0x7489, (q15_t)0x3496, (q15_t)0x74B2, + (q15_t)0x343A, (q15_t)0x74DB, (q15_t)0x33DE, (q15_t)0x7504, (q15_t)0x3382, + (q15_t)0x752D, (q15_t)0x3326, (q15_t)0x7555, (q15_t)0x32CA, (q15_t)0x757D, + (q15_t)0x326E, (q15_t)0x75A5, (q15_t)0x3211, (q15_t)0x75CC, (q15_t)0x31B5, + (q15_t)0x75F4, (q15_t)0x3158, (q15_t)0x761B, (q15_t)0x30FB, (q15_t)0x7641, + (q15_t)0x309E, (q15_t)0x7668, (q15_t)0x3041, (q15_t)0x768E, (q15_t)0x2FE4, + (q15_t)0x76B3, (q15_t)0x2F87, (q15_t)0x76D9, (q15_t)0x2F29, (q15_t)0x76FE, + (q15_t)0x2ECC, (q15_t)0x7723, (q15_t)0x2E6E, (q15_t)0x7747, (q15_t)0x2E11, + (q15_t)0x776C, (q15_t)0x2DB3, (q15_t)0x7790, (q15_t)0x2D55, (q15_t)0x77B4, + (q15_t)0x2CF7, (q15_t)0x77D7, (q15_t)0x2C98, (q15_t)0x77FA, (q15_t)0x2C3A, + (q15_t)0x781D, (q15_t)0x2BDC, (q15_t)0x7840, (q15_t)0x2B7D, (q15_t)0x7862, + (q15_t)0x2B1F, (q15_t)0x7884, (q15_t)0x2AC0, (q15_t)0x78A6, (q15_t)0x2A61, + (q15_t)0x78C7, (q15_t)0x2A02, (q15_t)0x78E8, (q15_t)0x29A3, (q15_t)0x7909, + (q15_t)0x2944, (q15_t)0x792A, (q15_t)0x28E5, (q15_t)0x794A, (q15_t)0x2886, + (q15_t)0x796A, (q15_t)0x2826, (q15_t)0x798A, (q15_t)0x27C7, (q15_t)0x79A9, + (q15_t)0x2767, (q15_t)0x79C8, (q15_t)0x2707, (q15_t)0x79E7, (q15_t)0x26A8, + (q15_t)0x7A05, (q15_t)0x2648, (q15_t)0x7A24, (q15_t)0x25E8, (q15_t)0x7A42, + (q15_t)0x2588, (q15_t)0x7A5F, (q15_t)0x2528, (q15_t)0x7A7D, (q15_t)0x24C7, + (q15_t)0x7A9A, (q15_t)0x2467, (q15_t)0x7AB6, (q15_t)0x2407, (q15_t)0x7AD3, + (q15_t)0x23A6, (q15_t)0x7AEF, (q15_t)0x2345, (q15_t)0x7B0B, (q15_t)0x22E5, + (q15_t)0x7B26, (q15_t)0x2284, (q15_t)0x7B42, (q15_t)0x2223, (q15_t)0x7B5D, + (q15_t)0x21C2, (q15_t)0x7B77, (q15_t)0x2161, (q15_t)0x7B92, (q15_t)0x2100, + (q15_t)0x7BAC, (q15_t)0x209F, (q15_t)0x7BC5, (q15_t)0x203E, (q15_t)0x7BDF, + (q15_t)0x1FDC, (q15_t)0x7BF8, (q15_t)0x1F7B, (q15_t)0x7C11, (q15_t)0x1F19, + (q15_t)0x7C29, (q15_t)0x1EB8, (q15_t)0x7C42, (q15_t)0x1E56, (q15_t)0x7C5A, + (q15_t)0x1DF5, (q15_t)0x7C71, (q15_t)0x1D93, (q15_t)0x7C89, (q15_t)0x1D31, + (q15_t)0x7CA0, (q15_t)0x1CCF, (q15_t)0x7CB7, (q15_t)0x1C6D, (q15_t)0x7CCD, + (q15_t)0x1C0B, (q15_t)0x7CE3, (q15_t)0x1BA9, (q15_t)0x7CF9, (q15_t)0x1B47, + (q15_t)0x7D0F, (q15_t)0x1AE4, (q15_t)0x7D24, (q15_t)0x1A82, (q15_t)0x7D39, + (q15_t)0x1A20, (q15_t)0x7D4E, (q15_t)0x19BD, (q15_t)0x7D62, (q15_t)0x195B, + (q15_t)0x7D76, (q15_t)0x18F8, (q15_t)0x7D8A, (q15_t)0x1896, (q15_t)0x7D9D, + (q15_t)0x1833, (q15_t)0x7DB0, (q15_t)0x17D0, (q15_t)0x7DC3, (q15_t)0x176D, + (q15_t)0x7DD6, (q15_t)0x170A, (q15_t)0x7DE8, (q15_t)0x16A8, (q15_t)0x7DFA, + (q15_t)0x1645, (q15_t)0x7E0C, (q15_t)0x15E2, (q15_t)0x7E1D, (q15_t)0x157F, + (q15_t)0x7E2E, (q15_t)0x151B, (q15_t)0x7E3F, (q15_t)0x14B8, (q15_t)0x7E4F, + (q15_t)0x1455, (q15_t)0x7E5F, (q15_t)0x13F2, (q15_t)0x7E6F, (q15_t)0x138E, + (q15_t)0x7E7F, (q15_t)0x132B, (q15_t)0x7E8E, (q15_t)0x12C8, (q15_t)0x7E9D, + (q15_t)0x1264, (q15_t)0x7EAB, (q15_t)0x1201, (q15_t)0x7EBA, (q15_t)0x119D, + (q15_t)0x7EC8, (q15_t)0x1139, (q15_t)0x7ED5, (q15_t)0x10D6, (q15_t)0x7EE3, + (q15_t)0x1072, (q15_t)0x7EF0, (q15_t)0x100E, (q15_t)0x7EFD, (q15_t)0x0FAB, + (q15_t)0x7F09, (q15_t)0x0F47, (q15_t)0x7F15, (q15_t)0x0EE3, (q15_t)0x7F21, + (q15_t)0x0E7F, (q15_t)0x7F2D, (q15_t)0x0E1B, (q15_t)0x7F38, (q15_t)0x0DB7, + (q15_t)0x7F43, (q15_t)0x0D53, (q15_t)0x7F4D, (q15_t)0x0CEF, (q15_t)0x7F58, + (q15_t)0x0C8B, (q15_t)0x7F62, (q15_t)0x0C27, (q15_t)0x7F6B, (q15_t)0x0BC3, + (q15_t)0x7F75, (q15_t)0x0B5F, (q15_t)0x7F7E, (q15_t)0x0AFB, (q15_t)0x7F87, + (q15_t)0x0A97, (q15_t)0x7F8F, (q15_t)0x0A33, (q15_t)0x7F97, (q15_t)0x09CE, + (q15_t)0x7F9F, (q15_t)0x096A, (q15_t)0x7FA7, (q15_t)0x0906, (q15_t)0x7FAE, + (q15_t)0x08A2, (q15_t)0x7FB5, (q15_t)0x083D, (q15_t)0x7FBC, (q15_t)0x07D9, + (q15_t)0x7FC2, (q15_t)0x0775, (q15_t)0x7FC8, (q15_t)0x0710, (q15_t)0x7FCE, + (q15_t)0x06AC, (q15_t)0x7FD3, (q15_t)0x0647, (q15_t)0x7FD8, (q15_t)0x05E3, + (q15_t)0x7FDD, (q15_t)0x057F, (q15_t)0x7FE1, (q15_t)0x051A, (q15_t)0x7FE5, + (q15_t)0x04B6, (q15_t)0x7FE9, (q15_t)0x0451, (q15_t)0x7FED, (q15_t)0x03ED, + (q15_t)0x7FF0, (q15_t)0x0388, (q15_t)0x7FF3, (q15_t)0x0324, (q15_t)0x7FF6, + (q15_t)0x02BF, (q15_t)0x7FF8, (q15_t)0x025B, (q15_t)0x7FFA, (q15_t)0x01F6, + (q15_t)0x7FFC, (q15_t)0x0192, (q15_t)0x7FFD, (q15_t)0x012D, (q15_t)0x7FFE, + (q15_t)0x00C9, (q15_t)0x7FFF, (q15_t)0x0064, (q15_t)0x7FFF, (q15_t)0x0000, + (q15_t)0x7FFF, (q15_t)0xFF9B, (q15_t)0x7FFF, (q15_t)0xFF36, (q15_t)0x7FFF, + (q15_t)0xFED2, (q15_t)0x7FFE, (q15_t)0xFE6D, (q15_t)0x7FFD, (q15_t)0xFE09, + (q15_t)0x7FFC, (q15_t)0xFDA4, (q15_t)0x7FFA, (q15_t)0xFD40, (q15_t)0x7FF8, + (q15_t)0xFCDB, (q15_t)0x7FF6, (q15_t)0xFC77, (q15_t)0x7FF3, (q15_t)0xFC12, + (q15_t)0x7FF0, (q15_t)0xFBAE, (q15_t)0x7FED, (q15_t)0xFB49, (q15_t)0x7FE9, + (q15_t)0xFAE5, (q15_t)0x7FE5, (q15_t)0xFA80, (q15_t)0x7FE1, (q15_t)0xFA1C, + (q15_t)0x7FDD, (q15_t)0xF9B8, (q15_t)0x7FD8, (q15_t)0xF953, (q15_t)0x7FD3, + (q15_t)0xF8EF, (q15_t)0x7FCE, (q15_t)0xF88A, (q15_t)0x7FC8, (q15_t)0xF826, + (q15_t)0x7FC2, (q15_t)0xF7C2, (q15_t)0x7FBC, (q15_t)0xF75D, (q15_t)0x7FB5, + (q15_t)0xF6F9, (q15_t)0x7FAE, (q15_t)0xF695, (q15_t)0x7FA7, (q15_t)0xF631, + (q15_t)0x7F9F, (q15_t)0xF5CC, (q15_t)0x7F97, (q15_t)0xF568, (q15_t)0x7F8F, + (q15_t)0xF504, (q15_t)0x7F87, (q15_t)0xF4A0, (q15_t)0x7F7E, (q15_t)0xF43C, + (q15_t)0x7F75, (q15_t)0xF3D8, (q15_t)0x7F6B, (q15_t)0xF374, (q15_t)0x7F62, + (q15_t)0xF310, (q15_t)0x7F58, (q15_t)0xF2AC, (q15_t)0x7F4D, (q15_t)0xF248, + (q15_t)0x7F43, (q15_t)0xF1E4, (q15_t)0x7F38, (q15_t)0xF180, (q15_t)0x7F2D, + (q15_t)0xF11C, (q15_t)0x7F21, (q15_t)0xF0B8, (q15_t)0x7F15, (q15_t)0xF054, + (q15_t)0x7F09, (q15_t)0xEFF1, (q15_t)0x7EFD, (q15_t)0xEF8D, (q15_t)0x7EF0, + (q15_t)0xEF29, (q15_t)0x7EE3, (q15_t)0xEEC6, (q15_t)0x7ED5, (q15_t)0xEE62, + (q15_t)0x7EC8, (q15_t)0xEDFE, (q15_t)0x7EBA, (q15_t)0xED9B, (q15_t)0x7EAB, + (q15_t)0xED37, (q15_t)0x7E9D, (q15_t)0xECD4, (q15_t)0x7E8E, (q15_t)0xEC71, + (q15_t)0x7E7F, (q15_t)0xEC0D, (q15_t)0x7E6F, (q15_t)0xEBAA, (q15_t)0x7E5F, + (q15_t)0xEB47, (q15_t)0x7E4F, (q15_t)0xEAE4, (q15_t)0x7E3F, (q15_t)0xEA80, + (q15_t)0x7E2E, (q15_t)0xEA1D, (q15_t)0x7E1D, (q15_t)0xE9BA, (q15_t)0x7E0C, + (q15_t)0xE957, (q15_t)0x7DFA, (q15_t)0xE8F5, (q15_t)0x7DE8, (q15_t)0xE892, + (q15_t)0x7DD6, (q15_t)0xE82F, (q15_t)0x7DC3, (q15_t)0xE7CC, (q15_t)0x7DB0, + (q15_t)0xE769, (q15_t)0x7D9D, (q15_t)0xE707, (q15_t)0x7D8A, (q15_t)0xE6A4, + (q15_t)0x7D76, (q15_t)0xE642, (q15_t)0x7D62, (q15_t)0xE5DF, (q15_t)0x7D4E, + (q15_t)0xE57D, (q15_t)0x7D39, (q15_t)0xE51B, (q15_t)0x7D24, (q15_t)0xE4B8, + (q15_t)0x7D0F, (q15_t)0xE456, (q15_t)0x7CF9, (q15_t)0xE3F4, (q15_t)0x7CE3, + (q15_t)0xE392, (q15_t)0x7CCD, (q15_t)0xE330, (q15_t)0x7CB7, (q15_t)0xE2CE, + (q15_t)0x7CA0, (q15_t)0xE26C, (q15_t)0x7C89, (q15_t)0xE20A, (q15_t)0x7C71, + (q15_t)0xE1A9, (q15_t)0x7C5A, (q15_t)0xE147, (q15_t)0x7C42, (q15_t)0xE0E6, + (q15_t)0x7C29, (q15_t)0xE084, (q15_t)0x7C11, (q15_t)0xE023, (q15_t)0x7BF8, + (q15_t)0xDFC1, (q15_t)0x7BDF, (q15_t)0xDF60, (q15_t)0x7BC5, (q15_t)0xDEFF, + (q15_t)0x7BAC, (q15_t)0xDE9E, (q15_t)0x7B92, (q15_t)0xDE3D, (q15_t)0x7B77, + (q15_t)0xDDDC, (q15_t)0x7B5D, (q15_t)0xDD7B, (q15_t)0x7B42, (q15_t)0xDD1A, + (q15_t)0x7B26, (q15_t)0xDCBA, (q15_t)0x7B0B, (q15_t)0xDC59, (q15_t)0x7AEF, + (q15_t)0xDBF8, (q15_t)0x7AD3, (q15_t)0xDB98, (q15_t)0x7AB6, (q15_t)0xDB38, + (q15_t)0x7A9A, (q15_t)0xDAD7, (q15_t)0x7A7D, (q15_t)0xDA77, (q15_t)0x7A5F, + (q15_t)0xDA17, (q15_t)0x7A42, (q15_t)0xD9B7, (q15_t)0x7A24, (q15_t)0xD957, + (q15_t)0x7A05, (q15_t)0xD8F8, (q15_t)0x79E7, (q15_t)0xD898, (q15_t)0x79C8, + (q15_t)0xD838, (q15_t)0x79A9, (q15_t)0xD7D9, (q15_t)0x798A, (q15_t)0xD779, + (q15_t)0x796A, (q15_t)0xD71A, (q15_t)0x794A, (q15_t)0xD6BB, (q15_t)0x792A, + (q15_t)0xD65C, (q15_t)0x7909, (q15_t)0xD5FD, (q15_t)0x78E8, (q15_t)0xD59E, + (q15_t)0x78C7, (q15_t)0xD53F, (q15_t)0x78A6, (q15_t)0xD4E0, (q15_t)0x7884, + (q15_t)0xD482, (q15_t)0x7862, (q15_t)0xD423, (q15_t)0x7840, (q15_t)0xD3C5, + (q15_t)0x781D, (q15_t)0xD367, (q15_t)0x77FA, (q15_t)0xD308, (q15_t)0x77D7, + (q15_t)0xD2AA, (q15_t)0x77B4, (q15_t)0xD24C, (q15_t)0x7790, (q15_t)0xD1EE, + (q15_t)0x776C, (q15_t)0xD191, (q15_t)0x7747, (q15_t)0xD133, (q15_t)0x7723, + (q15_t)0xD0D6, (q15_t)0x76FE, (q15_t)0xD078, (q15_t)0x76D9, (q15_t)0xD01B, + (q15_t)0x76B3, (q15_t)0xCFBE, (q15_t)0x768E, (q15_t)0xCF61, (q15_t)0x7668, + (q15_t)0xCF04, (q15_t)0x7641, (q15_t)0xCEA7, (q15_t)0x761B, (q15_t)0xCE4A, + (q15_t)0x75F4, (q15_t)0xCDEE, (q15_t)0x75CC, (q15_t)0xCD91, (q15_t)0x75A5, + (q15_t)0xCD35, (q15_t)0x757D, (q15_t)0xCCD9, (q15_t)0x7555, (q15_t)0xCC7D, + (q15_t)0x752D, (q15_t)0xCC21, (q15_t)0x7504, (q15_t)0xCBC5, (q15_t)0x74DB, + (q15_t)0xCB69, (q15_t)0x74B2, (q15_t)0xCB0D, (q15_t)0x7489, (q15_t)0xCAB2, + (q15_t)0x745F, (q15_t)0xCA57, (q15_t)0x7435, (q15_t)0xC9FB, (q15_t)0x740B, + (q15_t)0xC9A0, (q15_t)0x73E0, (q15_t)0xC945, (q15_t)0x73B5, (q15_t)0xC8EB, + (q15_t)0x738A, (q15_t)0xC890, (q15_t)0x735F, (q15_t)0xC835, (q15_t)0x7333, + (q15_t)0xC7DB, (q15_t)0x7307, (q15_t)0xC781, (q15_t)0x72DB, (q15_t)0xC727, + (q15_t)0x72AF, (q15_t)0xC6CD, (q15_t)0x7282, (q15_t)0xC673, (q15_t)0x7255, + (q15_t)0xC619, (q15_t)0x7227, (q15_t)0xC5BF, (q15_t)0x71FA, (q15_t)0xC566, + (q15_t)0x71CC, (q15_t)0xC50D, (q15_t)0x719E, (q15_t)0xC4B3, (q15_t)0x716F, + (q15_t)0xC45A, (q15_t)0x7141, (q15_t)0xC402, (q15_t)0x7112, (q15_t)0xC3A9, + (q15_t)0x70E2, (q15_t)0xC350, (q15_t)0x70B3, (q15_t)0xC2F8, (q15_t)0x7083, + (q15_t)0xC29F, (q15_t)0x7053, (q15_t)0xC247, (q15_t)0x7023, (q15_t)0xC1EF, + (q15_t)0x6FF2, (q15_t)0xC197, (q15_t)0x6FC1, (q15_t)0xC140, (q15_t)0x6F90, + (q15_t)0xC0E8, (q15_t)0x6F5F, (q15_t)0xC091, (q15_t)0x6F2D, (q15_t)0xC03A, + (q15_t)0x6EFB, (q15_t)0xBFE2, (q15_t)0x6EC9, (q15_t)0xBF8C, (q15_t)0x6E96, + (q15_t)0xBF35, (q15_t)0x6E63, (q15_t)0xBEDE, (q15_t)0x6E30, (q15_t)0xBE88, + (q15_t)0x6DFD, (q15_t)0xBE31, (q15_t)0x6DCA, (q15_t)0xBDDB, (q15_t)0x6D96, + (q15_t)0xBD85, (q15_t)0x6D62, (q15_t)0xBD2F, (q15_t)0x6D2D, (q15_t)0xBCDA, + (q15_t)0x6CF9, (q15_t)0xBC84, (q15_t)0x6CC4, (q15_t)0xBC2F, (q15_t)0x6C8F, + (q15_t)0xBBDA, (q15_t)0x6C59, (q15_t)0xBB85, (q15_t)0x6C24, (q15_t)0xBB30, + (q15_t)0x6BEE, (q15_t)0xBADB, (q15_t)0x6BB8, (q15_t)0xBA87, (q15_t)0x6B81, + (q15_t)0xBA32, (q15_t)0x6B4A, (q15_t)0xB9DE, (q15_t)0x6B13, (q15_t)0xB98A, + (q15_t)0x6ADC, (q15_t)0xB936, (q15_t)0x6AA5, (q15_t)0xB8E3, (q15_t)0x6A6D, + (q15_t)0xB88F, (q15_t)0x6A35, (q15_t)0xB83C, (q15_t)0x69FD, (q15_t)0xB7E9, + (q15_t)0x69C4, (q15_t)0xB796, (q15_t)0x698C, (q15_t)0xB743, (q15_t)0x6953, + (q15_t)0xB6F0, (q15_t)0x6919, (q15_t)0xB69E, (q15_t)0x68E0, (q15_t)0xB64B, + (q15_t)0x68A6, (q15_t)0xB5F9, (q15_t)0x686C, (q15_t)0xB5A7, (q15_t)0x6832, + (q15_t)0xB556, (q15_t)0x67F7, (q15_t)0xB504, (q15_t)0x67BD, (q15_t)0xB4B3, + (q15_t)0x6782, (q15_t)0xB461, (q15_t)0x6746, (q15_t)0xB410, (q15_t)0x670B, + (q15_t)0xB3C0, (q15_t)0x66CF, (q15_t)0xB36F, (q15_t)0x6693, (q15_t)0xB31E, + (q15_t)0x6657, (q15_t)0xB2CE, (q15_t)0x661A, (q15_t)0xB27E, (q15_t)0x65DD, + (q15_t)0xB22E, (q15_t)0x65A0, (q15_t)0xB1DE, (q15_t)0x6563, (q15_t)0xB18F, + (q15_t)0x6526, (q15_t)0xB140, (q15_t)0x64E8, (q15_t)0xB0F0, (q15_t)0x64AA, + (q15_t)0xB0A1, (q15_t)0x646C, (q15_t)0xB053, (q15_t)0x642D, (q15_t)0xB004, + (q15_t)0x63EF, (q15_t)0xAFB6, (q15_t)0x63B0, (q15_t)0xAF68, (q15_t)0x6371, + (q15_t)0xAF1A, (q15_t)0x6331, (q15_t)0xAECC, (q15_t)0x62F2, (q15_t)0xAE7E, + (q15_t)0x62B2, (q15_t)0xAE31, (q15_t)0x6271, (q15_t)0xADE3, (q15_t)0x6231, + (q15_t)0xAD96, (q15_t)0x61F1, (q15_t)0xAD4A, (q15_t)0x61B0, (q15_t)0xACFD, + (q15_t)0x616F, (q15_t)0xACB1, (q15_t)0x612D, (q15_t)0xAC64, (q15_t)0x60EC, + (q15_t)0xAC18, (q15_t)0x60AA, (q15_t)0xABCC, (q15_t)0x6068, (q15_t)0xAB81, + (q15_t)0x6026, (q15_t)0xAB35, (q15_t)0x5FE3, (q15_t)0xAAEA, (q15_t)0x5FA0, + (q15_t)0xAA9F, (q15_t)0x5F5E, (q15_t)0xAA54, (q15_t)0x5F1A, (q15_t)0xAA0A, + (q15_t)0x5ED7, (q15_t)0xA9BF, (q15_t)0x5E93, (q15_t)0xA975, (q15_t)0x5E50, + (q15_t)0xA92B, (q15_t)0x5E0B, (q15_t)0xA8E2, (q15_t)0x5DC7, (q15_t)0xA898, + (q15_t)0x5D83, (q15_t)0xA84F, (q15_t)0x5D3E, (q15_t)0xA806, (q15_t)0x5CF9, + (q15_t)0xA7BD, (q15_t)0x5CB4, (q15_t)0xA774, (q15_t)0x5C6E, (q15_t)0xA72B, + (q15_t)0x5C29, (q15_t)0xA6E3, (q15_t)0x5BE3, (q15_t)0xA69B, (q15_t)0x5B9D, + (q15_t)0xA653, (q15_t)0x5B56, (q15_t)0xA60C, (q15_t)0x5B10, (q15_t)0xA5C4, + (q15_t)0x5AC9, (q15_t)0xA57D, (q15_t)0x5A82, (q15_t)0xA536, (q15_t)0x5A3B, + (q15_t)0xA4EF, (q15_t)0x59F3, (q15_t)0xA4A9, (q15_t)0x59AC, (q15_t)0xA462, + (q15_t)0x5964, (q15_t)0xA41C, (q15_t)0x591C, (q15_t)0xA3D6, (q15_t)0x58D4, + (q15_t)0xA391, (q15_t)0x588B, (q15_t)0xA34B, (q15_t)0x5842, (q15_t)0xA306, + (q15_t)0x57F9, (q15_t)0xA2C1, (q15_t)0x57B0, (q15_t)0xA27C, (q15_t)0x5767, + (q15_t)0xA238, (q15_t)0x571D, (q15_t)0xA1F4, (q15_t)0x56D4, (q15_t)0xA1AF, + (q15_t)0x568A, (q15_t)0xA16C, (q15_t)0x5640, (q15_t)0xA128, (q15_t)0x55F5, + (q15_t)0xA0E5, (q15_t)0x55AB, (q15_t)0xA0A1, (q15_t)0x5560, (q15_t)0xA05F, + (q15_t)0x5515, (q15_t)0xA01C, (q15_t)0x54CA, (q15_t)0x9FD9, (q15_t)0x547E, + (q15_t)0x9F97, (q15_t)0x5433, (q15_t)0x9F55, (q15_t)0x53E7, (q15_t)0x9F13, + (q15_t)0x539B, (q15_t)0x9ED2, (q15_t)0x534E, (q15_t)0x9E90, (q15_t)0x5302, + (q15_t)0x9E4F, (q15_t)0x52B5, (q15_t)0x9E0E, (q15_t)0x5269, (q15_t)0x9DCE, + (q15_t)0x521C, (q15_t)0x9D8E, (q15_t)0x51CE, (q15_t)0x9D4D, (q15_t)0x5181, + (q15_t)0x9D0D, (q15_t)0x5133, (q15_t)0x9CCE, (q15_t)0x50E5, (q15_t)0x9C8E, + (q15_t)0x5097, (q15_t)0x9C4F, (q15_t)0x5049, (q15_t)0x9C10, (q15_t)0x4FFB, + (q15_t)0x9BD2, (q15_t)0x4FAC, (q15_t)0x9B93, (q15_t)0x4F5E, (q15_t)0x9B55, + (q15_t)0x4F0F, (q15_t)0x9B17, (q15_t)0x4EBF, (q15_t)0x9AD9, (q15_t)0x4E70, + (q15_t)0x9A9C, (q15_t)0x4E21, (q15_t)0x9A5F, (q15_t)0x4DD1, (q15_t)0x9A22, + (q15_t)0x4D81, (q15_t)0x99E5, (q15_t)0x4D31, (q15_t)0x99A8, (q15_t)0x4CE1, + (q15_t)0x996C, (q15_t)0x4C90, (q15_t)0x9930, (q15_t)0x4C3F, (q15_t)0x98F4, + (q15_t)0x4BEF, (q15_t)0x98B9, (q15_t)0x4B9E, (q15_t)0x987D, (q15_t)0x4B4C, + (q15_t)0x9842, (q15_t)0x4AFB, (q15_t)0x9808, (q15_t)0x4AA9, (q15_t)0x97CD, + (q15_t)0x4A58, (q15_t)0x9793, (q15_t)0x4A06, (q15_t)0x9759, (q15_t)0x49B4, + (q15_t)0x971F, (q15_t)0x4961, (q15_t)0x96E6, (q15_t)0x490F, (q15_t)0x96AC, + (q15_t)0x48BC, (q15_t)0x9673, (q15_t)0x4869, (q15_t)0x963B, (q15_t)0x4816, + (q15_t)0x9602, (q15_t)0x47C3, (q15_t)0x95CA, (q15_t)0x4770, (q15_t)0x9592, + (q15_t)0x471C, (q15_t)0x955A, (q15_t)0x46C9, (q15_t)0x9523, (q15_t)0x4675, + (q15_t)0x94EC, (q15_t)0x4621, (q15_t)0x94B5, (q15_t)0x45CD, (q15_t)0x947E, + (q15_t)0x4578, (q15_t)0x9447, (q15_t)0x4524, (q15_t)0x9411, (q15_t)0x44CF, + (q15_t)0x93DB, (q15_t)0x447A, (q15_t)0x93A6, (q15_t)0x4425, (q15_t)0x9370, + (q15_t)0x43D0, (q15_t)0x933B, (q15_t)0x437B, (q15_t)0x9306, (q15_t)0x4325, + (q15_t)0x92D2, (q15_t)0x42D0, (q15_t)0x929D, (q15_t)0x427A, (q15_t)0x9269, + (q15_t)0x4224, (q15_t)0x9235, (q15_t)0x41CE, (q15_t)0x9202, (q15_t)0x4177, + (q15_t)0x91CF, (q15_t)0x4121, (q15_t)0x919C, (q15_t)0x40CA, (q15_t)0x9169, + (q15_t)0x4073, (q15_t)0x9136, (q15_t)0x401D, (q15_t)0x9104, (q15_t)0x3FC5, + (q15_t)0x90D2, (q15_t)0x3F6E, (q15_t)0x90A0, (q15_t)0x3F17, (q15_t)0x906F, + (q15_t)0x3EBF, (q15_t)0x903E, (q15_t)0x3E68, (q15_t)0x900D, (q15_t)0x3E10, + (q15_t)0x8FDC, (q15_t)0x3DB8, (q15_t)0x8FAC, (q15_t)0x3D60, (q15_t)0x8F7C, + (q15_t)0x3D07, (q15_t)0x8F4C, (q15_t)0x3CAF, (q15_t)0x8F1D, (q15_t)0x3C56, + (q15_t)0x8EED, (q15_t)0x3BFD, (q15_t)0x8EBE, (q15_t)0x3BA5, (q15_t)0x8E90, + (q15_t)0x3B4C, (q15_t)0x8E61, (q15_t)0x3AF2, (q15_t)0x8E33, (q15_t)0x3A99, + (q15_t)0x8E05, (q15_t)0x3A40, (q15_t)0x8DD8, (q15_t)0x39E6, (q15_t)0x8DAA, + (q15_t)0x398C, (q15_t)0x8D7D, (q15_t)0x3932, (q15_t)0x8D50, (q15_t)0x38D8, + (q15_t)0x8D24, (q15_t)0x387E, (q15_t)0x8CF8, (q15_t)0x3824, (q15_t)0x8CCC, + (q15_t)0x37CA, (q15_t)0x8CA0, (q15_t)0x376F, (q15_t)0x8C75, (q15_t)0x3714, + (q15_t)0x8C4A, (q15_t)0x36BA, (q15_t)0x8C1F, (q15_t)0x365F, (q15_t)0x8BF4, + (q15_t)0x3604, (q15_t)0x8BCA, (q15_t)0x35A8, (q15_t)0x8BA0, (q15_t)0x354D, + (q15_t)0x8B76, (q15_t)0x34F2, (q15_t)0x8B4D, (q15_t)0x3496, (q15_t)0x8B24, + (q15_t)0x343A, (q15_t)0x8AFB, (q15_t)0x33DE, (q15_t)0x8AD2, (q15_t)0x3382, + (q15_t)0x8AAA, (q15_t)0x3326, (q15_t)0x8A82, (q15_t)0x32CA, (q15_t)0x8A5A, + (q15_t)0x326E, (q15_t)0x8A33, (q15_t)0x3211, (q15_t)0x8A0B, (q15_t)0x31B5, + (q15_t)0x89E4, (q15_t)0x3158, (q15_t)0x89BE, (q15_t)0x30FB, (q15_t)0x8997, + (q15_t)0x309E, (q15_t)0x8971, (q15_t)0x3041, (q15_t)0x894C, (q15_t)0x2FE4, + (q15_t)0x8926, (q15_t)0x2F87, (q15_t)0x8901, (q15_t)0x2F29, (q15_t)0x88DC, + (q15_t)0x2ECC, (q15_t)0x88B8, (q15_t)0x2E6E, (q15_t)0x8893, (q15_t)0x2E11, + (q15_t)0x886F, (q15_t)0x2DB3, (q15_t)0x884B, (q15_t)0x2D55, (q15_t)0x8828, + (q15_t)0x2CF7, (q15_t)0x8805, (q15_t)0x2C98, (q15_t)0x87E2, (q15_t)0x2C3A, + (q15_t)0x87BF, (q15_t)0x2BDC, (q15_t)0x879D, (q15_t)0x2B7D, (q15_t)0x877B, + (q15_t)0x2B1F, (q15_t)0x8759, (q15_t)0x2AC0, (q15_t)0x8738, (q15_t)0x2A61, + (q15_t)0x8717, (q15_t)0x2A02, (q15_t)0x86F6, (q15_t)0x29A3, (q15_t)0x86D5, + (q15_t)0x2944, (q15_t)0x86B5, (q15_t)0x28E5, (q15_t)0x8695, (q15_t)0x2886, + (q15_t)0x8675, (q15_t)0x2826, (q15_t)0x8656, (q15_t)0x27C7, (q15_t)0x8637, + (q15_t)0x2767, (q15_t)0x8618, (q15_t)0x2707, (q15_t)0x85FA, (q15_t)0x26A8, + (q15_t)0x85DB, (q15_t)0x2648, (q15_t)0x85BD, (q15_t)0x25E8, (q15_t)0x85A0, + (q15_t)0x2588, (q15_t)0x8582, (q15_t)0x2528, (q15_t)0x8565, (q15_t)0x24C7, + (q15_t)0x8549, (q15_t)0x2467, (q15_t)0x852C, (q15_t)0x2407, (q15_t)0x8510, + (q15_t)0x23A6, (q15_t)0x84F4, (q15_t)0x2345, (q15_t)0x84D9, (q15_t)0x22E5, + (q15_t)0x84BD, (q15_t)0x2284, (q15_t)0x84A2, (q15_t)0x2223, (q15_t)0x8488, + (q15_t)0x21C2, (q15_t)0x846D, (q15_t)0x2161, (q15_t)0x8453, (q15_t)0x2100, + (q15_t)0x843A, (q15_t)0x209F, (q15_t)0x8420, (q15_t)0x203E, (q15_t)0x8407, + (q15_t)0x1FDC, (q15_t)0x83EE, (q15_t)0x1F7B, (q15_t)0x83D6, (q15_t)0x1F19, + (q15_t)0x83BD, (q15_t)0x1EB8, (q15_t)0x83A5, (q15_t)0x1E56, (q15_t)0x838E, + (q15_t)0x1DF5, (q15_t)0x8376, (q15_t)0x1D93, (q15_t)0x835F, (q15_t)0x1D31, + (q15_t)0x8348, (q15_t)0x1CCF, (q15_t)0x8332, (q15_t)0x1C6D, (q15_t)0x831C, + (q15_t)0x1C0B, (q15_t)0x8306, (q15_t)0x1BA9, (q15_t)0x82F0, (q15_t)0x1B47, + (q15_t)0x82DB, (q15_t)0x1AE4, (q15_t)0x82C6, (q15_t)0x1A82, (q15_t)0x82B1, + (q15_t)0x1A20, (q15_t)0x829D, (q15_t)0x19BD, (q15_t)0x8289, (q15_t)0x195B, + (q15_t)0x8275, (q15_t)0x18F8, (q15_t)0x8262, (q15_t)0x1896, (q15_t)0x824F, + (q15_t)0x1833, (q15_t)0x823C, (q15_t)0x17D0, (q15_t)0x8229, (q15_t)0x176D, + (q15_t)0x8217, (q15_t)0x170A, (q15_t)0x8205, (q15_t)0x16A8, (q15_t)0x81F3, + (q15_t)0x1645, (q15_t)0x81E2, (q15_t)0x15E2, (q15_t)0x81D1, (q15_t)0x157F, + (q15_t)0x81C0, (q15_t)0x151B, (q15_t)0x81B0, (q15_t)0x14B8, (q15_t)0x81A0, + (q15_t)0x1455, (q15_t)0x8190, (q15_t)0x13F2, (q15_t)0x8180, (q15_t)0x138E, + (q15_t)0x8171, (q15_t)0x132B, (q15_t)0x8162, (q15_t)0x12C8, (q15_t)0x8154, + (q15_t)0x1264, (q15_t)0x8145, (q15_t)0x1201, (q15_t)0x8137, (q15_t)0x119D, + (q15_t)0x812A, (q15_t)0x1139, (q15_t)0x811C, (q15_t)0x10D6, (q15_t)0x810F, + (q15_t)0x1072, (q15_t)0x8102, (q15_t)0x100E, (q15_t)0x80F6, (q15_t)0x0FAB, + (q15_t)0x80EA, (q15_t)0x0F47, (q15_t)0x80DE, (q15_t)0x0EE3, (q15_t)0x80D2, + (q15_t)0x0E7F, (q15_t)0x80C7, (q15_t)0x0E1B, (q15_t)0x80BC, (q15_t)0x0DB7, + (q15_t)0x80B2, (q15_t)0x0D53, (q15_t)0x80A7, (q15_t)0x0CEF, (q15_t)0x809D, + (q15_t)0x0C8B, (q15_t)0x8094, (q15_t)0x0C27, (q15_t)0x808A, (q15_t)0x0BC3, + (q15_t)0x8081, (q15_t)0x0B5F, (q15_t)0x8078, (q15_t)0x0AFB, (q15_t)0x8070, + (q15_t)0x0A97, (q15_t)0x8068, (q15_t)0x0A33, (q15_t)0x8060, (q15_t)0x09CE, + (q15_t)0x8058, (q15_t)0x096A, (q15_t)0x8051, (q15_t)0x0906, (q15_t)0x804A, + (q15_t)0x08A2, (q15_t)0x8043, (q15_t)0x083D, (q15_t)0x803D, (q15_t)0x07D9, + (q15_t)0x8037, (q15_t)0x0775, (q15_t)0x8031, (q15_t)0x0710, (q15_t)0x802C, + (q15_t)0x06AC, (q15_t)0x8027, (q15_t)0x0647, (q15_t)0x8022, (q15_t)0x05E3, + (q15_t)0x801E, (q15_t)0x057F, (q15_t)0x801A, (q15_t)0x051A, (q15_t)0x8016, + (q15_t)0x04B6, (q15_t)0x8012, (q15_t)0x0451, (q15_t)0x800F, (q15_t)0x03ED, + (q15_t)0x800C, (q15_t)0x0388, (q15_t)0x8009, (q15_t)0x0324, (q15_t)0x8007, + (q15_t)0x02BF, (q15_t)0x8005, (q15_t)0x025B, (q15_t)0x8003, (q15_t)0x01F6, + (q15_t)0x8002, (q15_t)0x0192, (q15_t)0x8001, (q15_t)0x012D, (q15_t)0x8000, + (q15_t)0x00C9, (q15_t)0x8000, (q15_t)0x0064, (q15_t)0x8000, (q15_t)0x0000, + (q15_t)0x8000, (q15_t)0xFF9B, (q15_t)0x8000, (q15_t)0xFF36, (q15_t)0x8001, + (q15_t)0xFED2, (q15_t)0x8002, (q15_t)0xFE6D, (q15_t)0x8003, (q15_t)0xFE09, + (q15_t)0x8005, (q15_t)0xFDA4, (q15_t)0x8007, (q15_t)0xFD40, (q15_t)0x8009, + (q15_t)0xFCDB, (q15_t)0x800C, (q15_t)0xFC77, (q15_t)0x800F, (q15_t)0xFC12, + (q15_t)0x8012, (q15_t)0xFBAE, (q15_t)0x8016, (q15_t)0xFB49, (q15_t)0x801A, + (q15_t)0xFAE5, (q15_t)0x801E, (q15_t)0xFA80, (q15_t)0x8022, (q15_t)0xFA1C, + (q15_t)0x8027, (q15_t)0xF9B8, (q15_t)0x802C, (q15_t)0xF953, (q15_t)0x8031, + (q15_t)0xF8EF, (q15_t)0x8037, (q15_t)0xF88A, (q15_t)0x803D, (q15_t)0xF826, + (q15_t)0x8043, (q15_t)0xF7C2, (q15_t)0x804A, (q15_t)0xF75D, (q15_t)0x8051, + (q15_t)0xF6F9, (q15_t)0x8058, (q15_t)0xF695, (q15_t)0x8060, (q15_t)0xF631, + (q15_t)0x8068, (q15_t)0xF5CC, (q15_t)0x8070, (q15_t)0xF568, (q15_t)0x8078, + (q15_t)0xF504, (q15_t)0x8081, (q15_t)0xF4A0, (q15_t)0x808A, (q15_t)0xF43C, + (q15_t)0x8094, (q15_t)0xF3D8, (q15_t)0x809D, (q15_t)0xF374, (q15_t)0x80A7, + (q15_t)0xF310, (q15_t)0x80B2, (q15_t)0xF2AC, (q15_t)0x80BC, (q15_t)0xF248, + (q15_t)0x80C7, (q15_t)0xF1E4, (q15_t)0x80D2, (q15_t)0xF180, (q15_t)0x80DE, + (q15_t)0xF11C, (q15_t)0x80EA, (q15_t)0xF0B8, (q15_t)0x80F6, (q15_t)0xF054, + (q15_t)0x8102, (q15_t)0xEFF1, (q15_t)0x810F, (q15_t)0xEF8D, (q15_t)0x811C, + (q15_t)0xEF29, (q15_t)0x812A, (q15_t)0xEEC6, (q15_t)0x8137, (q15_t)0xEE62, + (q15_t)0x8145, (q15_t)0xEDFE, (q15_t)0x8154, (q15_t)0xED9B, (q15_t)0x8162, + (q15_t)0xED37, (q15_t)0x8171, (q15_t)0xECD4, (q15_t)0x8180, (q15_t)0xEC71, + (q15_t)0x8190, (q15_t)0xEC0D, (q15_t)0x81A0, (q15_t)0xEBAA, (q15_t)0x81B0, + (q15_t)0xEB47, (q15_t)0x81C0, (q15_t)0xEAE4, (q15_t)0x81D1, (q15_t)0xEA80, + (q15_t)0x81E2, (q15_t)0xEA1D, (q15_t)0x81F3, (q15_t)0xE9BA, (q15_t)0x8205, + (q15_t)0xE957, (q15_t)0x8217, (q15_t)0xE8F5, (q15_t)0x8229, (q15_t)0xE892, + (q15_t)0x823C, (q15_t)0xE82F, (q15_t)0x824F, (q15_t)0xE7CC, (q15_t)0x8262, + (q15_t)0xE769, (q15_t)0x8275, (q15_t)0xE707, (q15_t)0x8289, (q15_t)0xE6A4, + (q15_t)0x829D, (q15_t)0xE642, (q15_t)0x82B1, (q15_t)0xE5DF, (q15_t)0x82C6, + (q15_t)0xE57D, (q15_t)0x82DB, (q15_t)0xE51B, (q15_t)0x82F0, (q15_t)0xE4B8, + (q15_t)0x8306, (q15_t)0xE456, (q15_t)0x831C, (q15_t)0xE3F4, (q15_t)0x8332, + (q15_t)0xE392, (q15_t)0x8348, (q15_t)0xE330, (q15_t)0x835F, (q15_t)0xE2CE, + (q15_t)0x8376, (q15_t)0xE26C, (q15_t)0x838E, (q15_t)0xE20A, (q15_t)0x83A5, + (q15_t)0xE1A9, (q15_t)0x83BD, (q15_t)0xE147, (q15_t)0x83D6, (q15_t)0xE0E6, + (q15_t)0x83EE, (q15_t)0xE084, (q15_t)0x8407, (q15_t)0xE023, (q15_t)0x8420, + (q15_t)0xDFC1, (q15_t)0x843A, (q15_t)0xDF60, (q15_t)0x8453, (q15_t)0xDEFF, + (q15_t)0x846D, (q15_t)0xDE9E, (q15_t)0x8488, (q15_t)0xDE3D, (q15_t)0x84A2, + (q15_t)0xDDDC, (q15_t)0x84BD, (q15_t)0xDD7B, (q15_t)0x84D9, (q15_t)0xDD1A, + (q15_t)0x84F4, (q15_t)0xDCBA, (q15_t)0x8510, (q15_t)0xDC59, (q15_t)0x852C, + (q15_t)0xDBF8, (q15_t)0x8549, (q15_t)0xDB98, (q15_t)0x8565, (q15_t)0xDB38, + (q15_t)0x8582, (q15_t)0xDAD7, (q15_t)0x85A0, (q15_t)0xDA77, (q15_t)0x85BD, + (q15_t)0xDA17, (q15_t)0x85DB, (q15_t)0xD9B7, (q15_t)0x85FA, (q15_t)0xD957, + (q15_t)0x8618, (q15_t)0xD8F8, (q15_t)0x8637, (q15_t)0xD898, (q15_t)0x8656, + (q15_t)0xD838, (q15_t)0x8675, (q15_t)0xD7D9, (q15_t)0x8695, (q15_t)0xD779, + (q15_t)0x86B5, (q15_t)0xD71A, (q15_t)0x86D5, (q15_t)0xD6BB, (q15_t)0x86F6, + (q15_t)0xD65C, (q15_t)0x8717, (q15_t)0xD5FD, (q15_t)0x8738, (q15_t)0xD59E, + (q15_t)0x8759, (q15_t)0xD53F, (q15_t)0x877B, (q15_t)0xD4E0, (q15_t)0x879D, + (q15_t)0xD482, (q15_t)0x87BF, (q15_t)0xD423, (q15_t)0x87E2, (q15_t)0xD3C5, + (q15_t)0x8805, (q15_t)0xD367, (q15_t)0x8828, (q15_t)0xD308, (q15_t)0x884B, + (q15_t)0xD2AA, (q15_t)0x886F, (q15_t)0xD24C, (q15_t)0x8893, (q15_t)0xD1EE, + (q15_t)0x88B8, (q15_t)0xD191, (q15_t)0x88DC, (q15_t)0xD133, (q15_t)0x8901, + (q15_t)0xD0D6, (q15_t)0x8926, (q15_t)0xD078, (q15_t)0x894C, (q15_t)0xD01B, + (q15_t)0x8971, (q15_t)0xCFBE, (q15_t)0x8997, (q15_t)0xCF61, (q15_t)0x89BE, + (q15_t)0xCF04, (q15_t)0x89E4, (q15_t)0xCEA7, (q15_t)0x8A0B, (q15_t)0xCE4A, + (q15_t)0x8A33, (q15_t)0xCDEE, (q15_t)0x8A5A, (q15_t)0xCD91, (q15_t)0x8A82, + (q15_t)0xCD35, (q15_t)0x8AAA, (q15_t)0xCCD9, (q15_t)0x8AD2, (q15_t)0xCC7D, + (q15_t)0x8AFB, (q15_t)0xCC21, (q15_t)0x8B24, (q15_t)0xCBC5, (q15_t)0x8B4D, + (q15_t)0xCB69, (q15_t)0x8B76, (q15_t)0xCB0D, (q15_t)0x8BA0, (q15_t)0xCAB2, + (q15_t)0x8BCA, (q15_t)0xCA57, (q15_t)0x8BF4, (q15_t)0xC9FB, (q15_t)0x8C1F, + (q15_t)0xC9A0, (q15_t)0x8C4A, (q15_t)0xC945, (q15_t)0x8C75, (q15_t)0xC8EB, + (q15_t)0x8CA0, (q15_t)0xC890, (q15_t)0x8CCC, (q15_t)0xC835, (q15_t)0x8CF8, + (q15_t)0xC7DB, (q15_t)0x8D24, (q15_t)0xC781, (q15_t)0x8D50, (q15_t)0xC727, + (q15_t)0x8D7D, (q15_t)0xC6CD, (q15_t)0x8DAA, (q15_t)0xC673, (q15_t)0x8DD8, + (q15_t)0xC619, (q15_t)0x8E05, (q15_t)0xC5BF, (q15_t)0x8E33, (q15_t)0xC566, + (q15_t)0x8E61, (q15_t)0xC50D, (q15_t)0x8E90, (q15_t)0xC4B3, (q15_t)0x8EBE, + (q15_t)0xC45A, (q15_t)0x8EED, (q15_t)0xC402, (q15_t)0x8F1D, (q15_t)0xC3A9, + (q15_t)0x8F4C, (q15_t)0xC350, (q15_t)0x8F7C, (q15_t)0xC2F8, (q15_t)0x8FAC, + (q15_t)0xC29F, (q15_t)0x8FDC, (q15_t)0xC247, (q15_t)0x900D, (q15_t)0xC1EF, + (q15_t)0x903E, (q15_t)0xC197, (q15_t)0x906F, (q15_t)0xC140, (q15_t)0x90A0, + (q15_t)0xC0E8, (q15_t)0x90D2, (q15_t)0xC091, (q15_t)0x9104, (q15_t)0xC03A, + (q15_t)0x9136, (q15_t)0xBFE2, (q15_t)0x9169, (q15_t)0xBF8C, (q15_t)0x919C, + (q15_t)0xBF35, (q15_t)0x91CF, (q15_t)0xBEDE, (q15_t)0x9202, (q15_t)0xBE88, + (q15_t)0x9235, (q15_t)0xBE31, (q15_t)0x9269, (q15_t)0xBDDB, (q15_t)0x929D, + (q15_t)0xBD85, (q15_t)0x92D2, (q15_t)0xBD2F, (q15_t)0x9306, (q15_t)0xBCDA, + (q15_t)0x933B, (q15_t)0xBC84, (q15_t)0x9370, (q15_t)0xBC2F, (q15_t)0x93A6, + (q15_t)0xBBDA, (q15_t)0x93DB, (q15_t)0xBB85, (q15_t)0x9411, (q15_t)0xBB30, + (q15_t)0x9447, (q15_t)0xBADB, (q15_t)0x947E, (q15_t)0xBA87, (q15_t)0x94B5, + (q15_t)0xBA32, (q15_t)0x94EC, (q15_t)0xB9DE, (q15_t)0x9523, (q15_t)0xB98A, + (q15_t)0x955A, (q15_t)0xB936, (q15_t)0x9592, (q15_t)0xB8E3, (q15_t)0x95CA, + (q15_t)0xB88F, (q15_t)0x9602, (q15_t)0xB83C, (q15_t)0x963B, (q15_t)0xB7E9, + (q15_t)0x9673, (q15_t)0xB796, (q15_t)0x96AC, (q15_t)0xB743, (q15_t)0x96E6, + (q15_t)0xB6F0, (q15_t)0x971F, (q15_t)0xB69E, (q15_t)0x9759, (q15_t)0xB64B, + (q15_t)0x9793, (q15_t)0xB5F9, (q15_t)0x97CD, (q15_t)0xB5A7, (q15_t)0x9808, + (q15_t)0xB556, (q15_t)0x9842, (q15_t)0xB504, (q15_t)0x987D, (q15_t)0xB4B3, + (q15_t)0x98B9, (q15_t)0xB461, (q15_t)0x98F4, (q15_t)0xB410, (q15_t)0x9930, + (q15_t)0xB3C0, (q15_t)0x996C, (q15_t)0xB36F, (q15_t)0x99A8, (q15_t)0xB31E, + (q15_t)0x99E5, (q15_t)0xB2CE, (q15_t)0x9A22, (q15_t)0xB27E, (q15_t)0x9A5F, + (q15_t)0xB22E, (q15_t)0x9A9C, (q15_t)0xB1DE, (q15_t)0x9AD9, (q15_t)0xB18F, + (q15_t)0x9B17, (q15_t)0xB140, (q15_t)0x9B55, (q15_t)0xB0F0, (q15_t)0x9B93, + (q15_t)0xB0A1, (q15_t)0x9BD2, (q15_t)0xB053, (q15_t)0x9C10, (q15_t)0xB004, + (q15_t)0x9C4F, (q15_t)0xAFB6, (q15_t)0x9C8E, (q15_t)0xAF68, (q15_t)0x9CCE, + (q15_t)0xAF1A, (q15_t)0x9D0D, (q15_t)0xAECC, (q15_t)0x9D4D, (q15_t)0xAE7E, + (q15_t)0x9D8E, (q15_t)0xAE31, (q15_t)0x9DCE, (q15_t)0xADE3, (q15_t)0x9E0E, + (q15_t)0xAD96, (q15_t)0x9E4F, (q15_t)0xAD4A, (q15_t)0x9E90, (q15_t)0xACFD, + (q15_t)0x9ED2, (q15_t)0xACB1, (q15_t)0x9F13, (q15_t)0xAC64, (q15_t)0x9F55, + (q15_t)0xAC18, (q15_t)0x9F97, (q15_t)0xABCC, (q15_t)0x9FD9, (q15_t)0xAB81, + (q15_t)0xA01C, (q15_t)0xAB35, (q15_t)0xA05F, (q15_t)0xAAEA, (q15_t)0xA0A1, + (q15_t)0xAA9F, (q15_t)0xA0E5, (q15_t)0xAA54, (q15_t)0xA128, (q15_t)0xAA0A, + (q15_t)0xA16C, (q15_t)0xA9BF, (q15_t)0xA1AF, (q15_t)0xA975, (q15_t)0xA1F4, + (q15_t)0xA92B, (q15_t)0xA238, (q15_t)0xA8E2, (q15_t)0xA27C, (q15_t)0xA898, + (q15_t)0xA2C1, (q15_t)0xA84F, (q15_t)0xA306, (q15_t)0xA806, (q15_t)0xA34B, + (q15_t)0xA7BD, (q15_t)0xA391, (q15_t)0xA774, (q15_t)0xA3D6, (q15_t)0xA72B, + (q15_t)0xA41C, (q15_t)0xA6E3, (q15_t)0xA462, (q15_t)0xA69B, (q15_t)0xA4A9, + (q15_t)0xA653, (q15_t)0xA4EF, (q15_t)0xA60C, (q15_t)0xA536, (q15_t)0xA5C4, + (q15_t)0xA57D, (q15_t)0xA57D, (q15_t)0xA5C4, (q15_t)0xA536, (q15_t)0xA60C, + (q15_t)0xA4EF, (q15_t)0xA653, (q15_t)0xA4A9, (q15_t)0xA69B, (q15_t)0xA462, + (q15_t)0xA6E3, (q15_t)0xA41C, (q15_t)0xA72B, (q15_t)0xA3D6, (q15_t)0xA774, + (q15_t)0xA391, (q15_t)0xA7BD, (q15_t)0xA34B, (q15_t)0xA806, (q15_t)0xA306, + (q15_t)0xA84F, (q15_t)0xA2C1, (q15_t)0xA898, (q15_t)0xA27C, (q15_t)0xA8E2, + (q15_t)0xA238, (q15_t)0xA92B, (q15_t)0xA1F4, (q15_t)0xA975, (q15_t)0xA1AF, + (q15_t)0xA9BF, (q15_t)0xA16C, (q15_t)0xAA0A, (q15_t)0xA128, (q15_t)0xAA54, + (q15_t)0xA0E5, (q15_t)0xAA9F, (q15_t)0xA0A1, (q15_t)0xAAEA, (q15_t)0xA05F, + (q15_t)0xAB35, (q15_t)0xA01C, (q15_t)0xAB81, (q15_t)0x9FD9, (q15_t)0xABCC, + (q15_t)0x9F97, (q15_t)0xAC18, (q15_t)0x9F55, (q15_t)0xAC64, (q15_t)0x9F13, + (q15_t)0xACB1, (q15_t)0x9ED2, (q15_t)0xACFD, (q15_t)0x9E90, (q15_t)0xAD4A, + (q15_t)0x9E4F, (q15_t)0xAD96, (q15_t)0x9E0E, (q15_t)0xADE3, (q15_t)0x9DCE, + (q15_t)0xAE31, (q15_t)0x9D8E, (q15_t)0xAE7E, (q15_t)0x9D4D, (q15_t)0xAECC, + (q15_t)0x9D0D, (q15_t)0xAF1A, (q15_t)0x9CCE, (q15_t)0xAF68, (q15_t)0x9C8E, + (q15_t)0xAFB6, (q15_t)0x9C4F, (q15_t)0xB004, (q15_t)0x9C10, (q15_t)0xB053, + (q15_t)0x9BD2, (q15_t)0xB0A1, (q15_t)0x9B93, (q15_t)0xB0F0, (q15_t)0x9B55, + (q15_t)0xB140, (q15_t)0x9B17, (q15_t)0xB18F, (q15_t)0x9AD9, (q15_t)0xB1DE, + (q15_t)0x9A9C, (q15_t)0xB22E, (q15_t)0x9A5F, (q15_t)0xB27E, (q15_t)0x9A22, + (q15_t)0xB2CE, (q15_t)0x99E5, (q15_t)0xB31E, (q15_t)0x99A8, (q15_t)0xB36F, + (q15_t)0x996C, (q15_t)0xB3C0, (q15_t)0x9930, (q15_t)0xB410, (q15_t)0x98F4, + (q15_t)0xB461, (q15_t)0x98B9, (q15_t)0xB4B3, (q15_t)0x987D, (q15_t)0xB504, + (q15_t)0x9842, (q15_t)0xB556, (q15_t)0x9808, (q15_t)0xB5A7, (q15_t)0x97CD, + (q15_t)0xB5F9, (q15_t)0x9793, (q15_t)0xB64B, (q15_t)0x9759, (q15_t)0xB69E, + (q15_t)0x971F, (q15_t)0xB6F0, (q15_t)0x96E6, (q15_t)0xB743, (q15_t)0x96AC, + (q15_t)0xB796, (q15_t)0x9673, (q15_t)0xB7E9, (q15_t)0x963B, (q15_t)0xB83C, + (q15_t)0x9602, (q15_t)0xB88F, (q15_t)0x95CA, (q15_t)0xB8E3, (q15_t)0x9592, + (q15_t)0xB936, (q15_t)0x955A, (q15_t)0xB98A, (q15_t)0x9523, (q15_t)0xB9DE, + (q15_t)0x94EC, (q15_t)0xBA32, (q15_t)0x94B5, (q15_t)0xBA87, (q15_t)0x947E, + (q15_t)0xBADB, (q15_t)0x9447, (q15_t)0xBB30, (q15_t)0x9411, (q15_t)0xBB85, + (q15_t)0x93DB, (q15_t)0xBBDA, (q15_t)0x93A6, (q15_t)0xBC2F, (q15_t)0x9370, + (q15_t)0xBC84, (q15_t)0x933B, (q15_t)0xBCDA, (q15_t)0x9306, (q15_t)0xBD2F, + (q15_t)0x92D2, (q15_t)0xBD85, (q15_t)0x929D, (q15_t)0xBDDB, (q15_t)0x9269, + (q15_t)0xBE31, (q15_t)0x9235, (q15_t)0xBE88, (q15_t)0x9202, (q15_t)0xBEDE, + (q15_t)0x91CF, (q15_t)0xBF35, (q15_t)0x919C, (q15_t)0xBF8C, (q15_t)0x9169, + (q15_t)0xBFE2, (q15_t)0x9136, (q15_t)0xC03A, (q15_t)0x9104, (q15_t)0xC091, + (q15_t)0x90D2, (q15_t)0xC0E8, (q15_t)0x90A0, (q15_t)0xC140, (q15_t)0x906F, + (q15_t)0xC197, (q15_t)0x903E, (q15_t)0xC1EF, (q15_t)0x900D, (q15_t)0xC247, + (q15_t)0x8FDC, (q15_t)0xC29F, (q15_t)0x8FAC, (q15_t)0xC2F8, (q15_t)0x8F7C, + (q15_t)0xC350, (q15_t)0x8F4C, (q15_t)0xC3A9, (q15_t)0x8F1D, (q15_t)0xC402, + (q15_t)0x8EED, (q15_t)0xC45A, (q15_t)0x8EBE, (q15_t)0xC4B3, (q15_t)0x8E90, + (q15_t)0xC50D, (q15_t)0x8E61, (q15_t)0xC566, (q15_t)0x8E33, (q15_t)0xC5BF, + (q15_t)0x8E05, (q15_t)0xC619, (q15_t)0x8DD8, (q15_t)0xC673, (q15_t)0x8DAA, + (q15_t)0xC6CD, (q15_t)0x8D7D, (q15_t)0xC727, (q15_t)0x8D50, (q15_t)0xC781, + (q15_t)0x8D24, (q15_t)0xC7DB, (q15_t)0x8CF8, (q15_t)0xC835, (q15_t)0x8CCC, + (q15_t)0xC890, (q15_t)0x8CA0, (q15_t)0xC8EB, (q15_t)0x8C75, (q15_t)0xC945, + (q15_t)0x8C4A, (q15_t)0xC9A0, (q15_t)0x8C1F, (q15_t)0xC9FB, (q15_t)0x8BF4, + (q15_t)0xCA57, (q15_t)0x8BCA, (q15_t)0xCAB2, (q15_t)0x8BA0, (q15_t)0xCB0D, + (q15_t)0x8B76, (q15_t)0xCB69, (q15_t)0x8B4D, (q15_t)0xCBC5, (q15_t)0x8B24, + (q15_t)0xCC21, (q15_t)0x8AFB, (q15_t)0xCC7D, (q15_t)0x8AD2, (q15_t)0xCCD9, + (q15_t)0x8AAA, (q15_t)0xCD35, (q15_t)0x8A82, (q15_t)0xCD91, (q15_t)0x8A5A, + (q15_t)0xCDEE, (q15_t)0x8A33, (q15_t)0xCE4A, (q15_t)0x8A0B, (q15_t)0xCEA7, + (q15_t)0x89E4, (q15_t)0xCF04, (q15_t)0x89BE, (q15_t)0xCF61, (q15_t)0x8997, + (q15_t)0xCFBE, (q15_t)0x8971, (q15_t)0xD01B, (q15_t)0x894C, (q15_t)0xD078, + (q15_t)0x8926, (q15_t)0xD0D6, (q15_t)0x8901, (q15_t)0xD133, (q15_t)0x88DC, + (q15_t)0xD191, (q15_t)0x88B8, (q15_t)0xD1EE, (q15_t)0x8893, (q15_t)0xD24C, + (q15_t)0x886F, (q15_t)0xD2AA, (q15_t)0x884B, (q15_t)0xD308, (q15_t)0x8828, + (q15_t)0xD367, (q15_t)0x8805, (q15_t)0xD3C5, (q15_t)0x87E2, (q15_t)0xD423, + (q15_t)0x87BF, (q15_t)0xD482, (q15_t)0x879D, (q15_t)0xD4E0, (q15_t)0x877B, + (q15_t)0xD53F, (q15_t)0x8759, (q15_t)0xD59E, (q15_t)0x8738, (q15_t)0xD5FD, + (q15_t)0x8717, (q15_t)0xD65C, (q15_t)0x86F6, (q15_t)0xD6BB, (q15_t)0x86D5, + (q15_t)0xD71A, (q15_t)0x86B5, (q15_t)0xD779, (q15_t)0x8695, (q15_t)0xD7D9, + (q15_t)0x8675, (q15_t)0xD838, (q15_t)0x8656, (q15_t)0xD898, (q15_t)0x8637, + (q15_t)0xD8F8, (q15_t)0x8618, (q15_t)0xD957, (q15_t)0x85FA, (q15_t)0xD9B7, + (q15_t)0x85DB, (q15_t)0xDA17, (q15_t)0x85BD, (q15_t)0xDA77, (q15_t)0x85A0, + (q15_t)0xDAD7, (q15_t)0x8582, (q15_t)0xDB38, (q15_t)0x8565, (q15_t)0xDB98, + (q15_t)0x8549, (q15_t)0xDBF8, (q15_t)0x852C, (q15_t)0xDC59, (q15_t)0x8510, + (q15_t)0xDCBA, (q15_t)0x84F4, (q15_t)0xDD1A, (q15_t)0x84D9, (q15_t)0xDD7B, + (q15_t)0x84BD, (q15_t)0xDDDC, (q15_t)0x84A2, (q15_t)0xDE3D, (q15_t)0x8488, + (q15_t)0xDE9E, (q15_t)0x846D, (q15_t)0xDEFF, (q15_t)0x8453, (q15_t)0xDF60, + (q15_t)0x843A, (q15_t)0xDFC1, (q15_t)0x8420, (q15_t)0xE023, (q15_t)0x8407, + (q15_t)0xE084, (q15_t)0x83EE, (q15_t)0xE0E6, (q15_t)0x83D6, (q15_t)0xE147, + (q15_t)0x83BD, (q15_t)0xE1A9, (q15_t)0x83A5, (q15_t)0xE20A, (q15_t)0x838E, + (q15_t)0xE26C, (q15_t)0x8376, (q15_t)0xE2CE, (q15_t)0x835F, (q15_t)0xE330, + (q15_t)0x8348, (q15_t)0xE392, (q15_t)0x8332, (q15_t)0xE3F4, (q15_t)0x831C, + (q15_t)0xE456, (q15_t)0x8306, (q15_t)0xE4B8, (q15_t)0x82F0, (q15_t)0xE51B, + (q15_t)0x82DB, (q15_t)0xE57D, (q15_t)0x82C6, (q15_t)0xE5DF, (q15_t)0x82B1, + (q15_t)0xE642, (q15_t)0x829D, (q15_t)0xE6A4, (q15_t)0x8289, (q15_t)0xE707, + (q15_t)0x8275, (q15_t)0xE769, (q15_t)0x8262, (q15_t)0xE7CC, (q15_t)0x824F, + (q15_t)0xE82F, (q15_t)0x823C, (q15_t)0xE892, (q15_t)0x8229, (q15_t)0xE8F5, + (q15_t)0x8217, (q15_t)0xE957, (q15_t)0x8205, (q15_t)0xE9BA, (q15_t)0x81F3, + (q15_t)0xEA1D, (q15_t)0x81E2, (q15_t)0xEA80, (q15_t)0x81D1, (q15_t)0xEAE4, + (q15_t)0x81C0, (q15_t)0xEB47, (q15_t)0x81B0, (q15_t)0xEBAA, (q15_t)0x81A0, + (q15_t)0xEC0D, (q15_t)0x8190, (q15_t)0xEC71, (q15_t)0x8180, (q15_t)0xECD4, + (q15_t)0x8171, (q15_t)0xED37, (q15_t)0x8162, (q15_t)0xED9B, (q15_t)0x8154, + (q15_t)0xEDFE, (q15_t)0x8145, (q15_t)0xEE62, (q15_t)0x8137, (q15_t)0xEEC6, + (q15_t)0x812A, (q15_t)0xEF29, (q15_t)0x811C, (q15_t)0xEF8D, (q15_t)0x810F, + (q15_t)0xEFF1, (q15_t)0x8102, (q15_t)0xF054, (q15_t)0x80F6, (q15_t)0xF0B8, + (q15_t)0x80EA, (q15_t)0xF11C, (q15_t)0x80DE, (q15_t)0xF180, (q15_t)0x80D2, + (q15_t)0xF1E4, (q15_t)0x80C7, (q15_t)0xF248, (q15_t)0x80BC, (q15_t)0xF2AC, + (q15_t)0x80B2, (q15_t)0xF310, (q15_t)0x80A7, (q15_t)0xF374, (q15_t)0x809D, + (q15_t)0xF3D8, (q15_t)0x8094, (q15_t)0xF43C, (q15_t)0x808A, (q15_t)0xF4A0, + (q15_t)0x8081, (q15_t)0xF504, (q15_t)0x8078, (q15_t)0xF568, (q15_t)0x8070, + (q15_t)0xF5CC, (q15_t)0x8068, (q15_t)0xF631, (q15_t)0x8060, (q15_t)0xF695, + (q15_t)0x8058, (q15_t)0xF6F9, (q15_t)0x8051, (q15_t)0xF75D, (q15_t)0x804A, + (q15_t)0xF7C2, (q15_t)0x8043, (q15_t)0xF826, (q15_t)0x803D, (q15_t)0xF88A, + (q15_t)0x8037, (q15_t)0xF8EF, (q15_t)0x8031, (q15_t)0xF953, (q15_t)0x802C, + (q15_t)0xF9B8, (q15_t)0x8027, (q15_t)0xFA1C, (q15_t)0x8022, (q15_t)0xFA80, + (q15_t)0x801E, (q15_t)0xFAE5, (q15_t)0x801A, (q15_t)0xFB49, (q15_t)0x8016, + (q15_t)0xFBAE, (q15_t)0x8012, (q15_t)0xFC12, (q15_t)0x800F, (q15_t)0xFC77, + (q15_t)0x800C, (q15_t)0xFCDB, (q15_t)0x8009, (q15_t)0xFD40, (q15_t)0x8007, + (q15_t)0xFDA4, (q15_t)0x8005, (q15_t)0xFE09, (q15_t)0x8003, (q15_t)0xFE6D, + (q15_t)0x8002, (q15_t)0xFED2, (q15_t)0x8001, (q15_t)0xFF36, (q15_t)0x8000, + (q15_t)0xFF9B, (q15_t)0x8000}; /** @par @@ -14523,1548 +8227,1238 @@ const q15_t twiddleCoef_2048_q15[3072] = { Cos and Sin values are interleaved fashion @par Convert Floating point to q15(Fixed point 1.15): - round(twiddleCoefq15(i) * pow(2, 15)) + round(twiddleCoefq15(i) * pow(2, 15)) */ -const q15_t twiddleCoef_4096_q15[6144] = -{ - (q15_t)0x7FFF, (q15_t)0x0000, (q15_t)0x7FFF, (q15_t)0x0032, - (q15_t)0x7FFF, (q15_t)0x0064, (q15_t)0x7FFF, (q15_t)0x0096, - (q15_t)0x7FFF, (q15_t)0x00C9, (q15_t)0x7FFF, (q15_t)0x00FB, - (q15_t)0x7FFE, (q15_t)0x012D, (q15_t)0x7FFE, (q15_t)0x015F, - (q15_t)0x7FFD, (q15_t)0x0192, (q15_t)0x7FFC, (q15_t)0x01C4, - (q15_t)0x7FFC, (q15_t)0x01F6, (q15_t)0x7FFB, (q15_t)0x0228, - (q15_t)0x7FFA, (q15_t)0x025B, (q15_t)0x7FF9, (q15_t)0x028D, - (q15_t)0x7FF8, (q15_t)0x02BF, (q15_t)0x7FF7, (q15_t)0x02F1, - (q15_t)0x7FF6, (q15_t)0x0324, (q15_t)0x7FF4, (q15_t)0x0356, - (q15_t)0x7FF3, (q15_t)0x0388, (q15_t)0x7FF2, (q15_t)0x03BA, - (q15_t)0x7FF0, (q15_t)0x03ED, (q15_t)0x7FEE, (q15_t)0x041F, - (q15_t)0x7FED, (q15_t)0x0451, (q15_t)0x7FEB, (q15_t)0x0483, - (q15_t)0x7FE9, (q15_t)0x04B6, (q15_t)0x7FE7, (q15_t)0x04E8, - (q15_t)0x7FE5, (q15_t)0x051A, (q15_t)0x7FE3, (q15_t)0x054C, - (q15_t)0x7FE1, (q15_t)0x057F, (q15_t)0x7FDF, (q15_t)0x05B1, - (q15_t)0x7FDD, (q15_t)0x05E3, (q15_t)0x7FDA, (q15_t)0x0615, - (q15_t)0x7FD8, (q15_t)0x0647, (q15_t)0x7FD6, (q15_t)0x067A, - (q15_t)0x7FD3, (q15_t)0x06AC, (q15_t)0x7FD0, (q15_t)0x06DE, - (q15_t)0x7FCE, (q15_t)0x0710, (q15_t)0x7FCB, (q15_t)0x0742, - (q15_t)0x7FC8, (q15_t)0x0775, (q15_t)0x7FC5, (q15_t)0x07A7, - (q15_t)0x7FC2, (q15_t)0x07D9, (q15_t)0x7FBF, (q15_t)0x080B, - (q15_t)0x7FBC, (q15_t)0x083D, (q15_t)0x7FB8, (q15_t)0x086F, - (q15_t)0x7FB5, (q15_t)0x08A2, (q15_t)0x7FB1, (q15_t)0x08D4, - (q15_t)0x7FAE, (q15_t)0x0906, (q15_t)0x7FAA, (q15_t)0x0938, - (q15_t)0x7FA7, (q15_t)0x096A, (q15_t)0x7FA3, (q15_t)0x099C, - (q15_t)0x7F9F, (q15_t)0x09CE, (q15_t)0x7F9B, (q15_t)0x0A00, - (q15_t)0x7F97, (q15_t)0x0A33, (q15_t)0x7F93, (q15_t)0x0A65, - (q15_t)0x7F8F, (q15_t)0x0A97, (q15_t)0x7F8B, (q15_t)0x0AC9, - (q15_t)0x7F87, (q15_t)0x0AFB, (q15_t)0x7F82, (q15_t)0x0B2D, - (q15_t)0x7F7E, (q15_t)0x0B5F, (q15_t)0x7F79, (q15_t)0x0B91, - (q15_t)0x7F75, (q15_t)0x0BC3, (q15_t)0x7F70, (q15_t)0x0BF5, - (q15_t)0x7F6B, (q15_t)0x0C27, (q15_t)0x7F67, (q15_t)0x0C59, - (q15_t)0x7F62, (q15_t)0x0C8B, (q15_t)0x7F5D, (q15_t)0x0CBD, - (q15_t)0x7F58, (q15_t)0x0CEF, (q15_t)0x7F53, (q15_t)0x0D21, - (q15_t)0x7F4D, (q15_t)0x0D53, (q15_t)0x7F48, (q15_t)0x0D85, - (q15_t)0x7F43, (q15_t)0x0DB7, (q15_t)0x7F3D, (q15_t)0x0DE9, - (q15_t)0x7F38, (q15_t)0x0E1B, (q15_t)0x7F32, (q15_t)0x0E4D, - (q15_t)0x7F2D, (q15_t)0x0E7F, (q15_t)0x7F27, (q15_t)0x0EB1, - (q15_t)0x7F21, (q15_t)0x0EE3, (q15_t)0x7F1B, (q15_t)0x0F15, - (q15_t)0x7F15, (q15_t)0x0F47, (q15_t)0x7F0F, (q15_t)0x0F79, - (q15_t)0x7F09, (q15_t)0x0FAB, (q15_t)0x7F03, (q15_t)0x0FDD, - (q15_t)0x7EFD, (q15_t)0x100E, (q15_t)0x7EF6, (q15_t)0x1040, - (q15_t)0x7EF0, (q15_t)0x1072, (q15_t)0x7EE9, (q15_t)0x10A4, - (q15_t)0x7EE3, (q15_t)0x10D6, (q15_t)0x7EDC, (q15_t)0x1108, - (q15_t)0x7ED5, (q15_t)0x1139, (q15_t)0x7ECF, (q15_t)0x116B, - (q15_t)0x7EC8, (q15_t)0x119D, (q15_t)0x7EC1, (q15_t)0x11CF, - (q15_t)0x7EBA, (q15_t)0x1201, (q15_t)0x7EB3, (q15_t)0x1232, - (q15_t)0x7EAB, (q15_t)0x1264, (q15_t)0x7EA4, (q15_t)0x1296, - (q15_t)0x7E9D, (q15_t)0x12C8, (q15_t)0x7E95, (q15_t)0x12F9, - (q15_t)0x7E8E, (q15_t)0x132B, (q15_t)0x7E86, (q15_t)0x135D, - (q15_t)0x7E7F, (q15_t)0x138E, (q15_t)0x7E77, (q15_t)0x13C0, - (q15_t)0x7E6F, (q15_t)0x13F2, (q15_t)0x7E67, (q15_t)0x1423, - (q15_t)0x7E5F, (q15_t)0x1455, (q15_t)0x7E57, (q15_t)0x1487, - (q15_t)0x7E4F, (q15_t)0x14B8, (q15_t)0x7E47, (q15_t)0x14EA, - (q15_t)0x7E3F, (q15_t)0x151B, (q15_t)0x7E37, (q15_t)0x154D, - (q15_t)0x7E2E, (q15_t)0x157F, (q15_t)0x7E26, (q15_t)0x15B0, - (q15_t)0x7E1D, (q15_t)0x15E2, (q15_t)0x7E14, (q15_t)0x1613, - (q15_t)0x7E0C, (q15_t)0x1645, (q15_t)0x7E03, (q15_t)0x1676, - (q15_t)0x7DFA, (q15_t)0x16A8, (q15_t)0x7DF1, (q15_t)0x16D9, - (q15_t)0x7DE8, (q15_t)0x170A, (q15_t)0x7DDF, (q15_t)0x173C, - (q15_t)0x7DD6, (q15_t)0x176D, (q15_t)0x7DCD, (q15_t)0x179F, - (q15_t)0x7DC3, (q15_t)0x17D0, (q15_t)0x7DBA, (q15_t)0x1802, - (q15_t)0x7DB0, (q15_t)0x1833, (q15_t)0x7DA7, (q15_t)0x1864, - (q15_t)0x7D9D, (q15_t)0x1896, (q15_t)0x7D94, (q15_t)0x18C7, - (q15_t)0x7D8A, (q15_t)0x18F8, (q15_t)0x7D80, (q15_t)0x192A, - (q15_t)0x7D76, (q15_t)0x195B, (q15_t)0x7D6C, (q15_t)0x198C, - (q15_t)0x7D62, (q15_t)0x19BD, (q15_t)0x7D58, (q15_t)0x19EF, - (q15_t)0x7D4E, (q15_t)0x1A20, (q15_t)0x7D43, (q15_t)0x1A51, - (q15_t)0x7D39, (q15_t)0x1A82, (q15_t)0x7D2F, (q15_t)0x1AB3, - (q15_t)0x7D24, (q15_t)0x1AE4, (q15_t)0x7D19, (q15_t)0x1B16, - (q15_t)0x7D0F, (q15_t)0x1B47, (q15_t)0x7D04, (q15_t)0x1B78, - (q15_t)0x7CF9, (q15_t)0x1BA9, (q15_t)0x7CEE, (q15_t)0x1BDA, - (q15_t)0x7CE3, (q15_t)0x1C0B, (q15_t)0x7CD8, (q15_t)0x1C3C, - (q15_t)0x7CCD, (q15_t)0x1C6D, (q15_t)0x7CC2, (q15_t)0x1C9E, - (q15_t)0x7CB7, (q15_t)0x1CCF, (q15_t)0x7CAB, (q15_t)0x1D00, - (q15_t)0x7CA0, (q15_t)0x1D31, (q15_t)0x7C94, (q15_t)0x1D62, - (q15_t)0x7C89, (q15_t)0x1D93, (q15_t)0x7C7D, (q15_t)0x1DC4, - (q15_t)0x7C71, (q15_t)0x1DF5, (q15_t)0x7C66, (q15_t)0x1E25, - (q15_t)0x7C5A, (q15_t)0x1E56, (q15_t)0x7C4E, (q15_t)0x1E87, - (q15_t)0x7C42, (q15_t)0x1EB8, (q15_t)0x7C36, (q15_t)0x1EE9, - (q15_t)0x7C29, (q15_t)0x1F19, (q15_t)0x7C1D, (q15_t)0x1F4A, - (q15_t)0x7C11, (q15_t)0x1F7B, (q15_t)0x7C05, (q15_t)0x1FAC, - (q15_t)0x7BF8, (q15_t)0x1FDC, (q15_t)0x7BEB, (q15_t)0x200D, - (q15_t)0x7BDF, (q15_t)0x203E, (q15_t)0x7BD2, (q15_t)0x206E, - (q15_t)0x7BC5, (q15_t)0x209F, (q15_t)0x7BB9, (q15_t)0x20D0, - (q15_t)0x7BAC, (q15_t)0x2100, (q15_t)0x7B9F, (q15_t)0x2131, - (q15_t)0x7B92, (q15_t)0x2161, (q15_t)0x7B84, (q15_t)0x2192, - (q15_t)0x7B77, (q15_t)0x21C2, (q15_t)0x7B6A, (q15_t)0x21F3, - (q15_t)0x7B5D, (q15_t)0x2223, (q15_t)0x7B4F, (q15_t)0x2254, - (q15_t)0x7B42, (q15_t)0x2284, (q15_t)0x7B34, (q15_t)0x22B4, - (q15_t)0x7B26, (q15_t)0x22E5, (q15_t)0x7B19, (q15_t)0x2315, - (q15_t)0x7B0B, (q15_t)0x2345, (q15_t)0x7AFD, (q15_t)0x2376, - (q15_t)0x7AEF, (q15_t)0x23A6, (q15_t)0x7AE1, (q15_t)0x23D6, - (q15_t)0x7AD3, (q15_t)0x2407, (q15_t)0x7AC5, (q15_t)0x2437, - (q15_t)0x7AB6, (q15_t)0x2467, (q15_t)0x7AA8, (q15_t)0x2497, - (q15_t)0x7A9A, (q15_t)0x24C7, (q15_t)0x7A8B, (q15_t)0x24F7, - (q15_t)0x7A7D, (q15_t)0x2528, (q15_t)0x7A6E, (q15_t)0x2558, - (q15_t)0x7A5F, (q15_t)0x2588, (q15_t)0x7A50, (q15_t)0x25B8, - (q15_t)0x7A42, (q15_t)0x25E8, (q15_t)0x7A33, (q15_t)0x2618, - (q15_t)0x7A24, (q15_t)0x2648, (q15_t)0x7A15, (q15_t)0x2678, - (q15_t)0x7A05, (q15_t)0x26A8, (q15_t)0x79F6, (q15_t)0x26D8, - (q15_t)0x79E7, (q15_t)0x2707, (q15_t)0x79D8, (q15_t)0x2737, - (q15_t)0x79C8, (q15_t)0x2767, (q15_t)0x79B9, (q15_t)0x2797, - (q15_t)0x79A9, (q15_t)0x27C7, (q15_t)0x7999, (q15_t)0x27F6, - (q15_t)0x798A, (q15_t)0x2826, (q15_t)0x797A, (q15_t)0x2856, - (q15_t)0x796A, (q15_t)0x2886, (q15_t)0x795A, (q15_t)0x28B5, - (q15_t)0x794A, (q15_t)0x28E5, (q15_t)0x793A, (q15_t)0x2915, - (q15_t)0x792A, (q15_t)0x2944, (q15_t)0x7919, (q15_t)0x2974, - (q15_t)0x7909, (q15_t)0x29A3, (q15_t)0x78F9, (q15_t)0x29D3, - (q15_t)0x78E8, (q15_t)0x2A02, (q15_t)0x78D8, (q15_t)0x2A32, - (q15_t)0x78C7, (q15_t)0x2A61, (q15_t)0x78B6, (q15_t)0x2A91, - (q15_t)0x78A6, (q15_t)0x2AC0, (q15_t)0x7895, (q15_t)0x2AEF, - (q15_t)0x7884, (q15_t)0x2B1F, (q15_t)0x7873, (q15_t)0x2B4E, - (q15_t)0x7862, (q15_t)0x2B7D, (q15_t)0x7851, (q15_t)0x2BAD, - (q15_t)0x7840, (q15_t)0x2BDC, (q15_t)0x782E, (q15_t)0x2C0B, - (q15_t)0x781D, (q15_t)0x2C3A, (q15_t)0x780C, (q15_t)0x2C69, - (q15_t)0x77FA, (q15_t)0x2C98, (q15_t)0x77E9, (q15_t)0x2CC8, - (q15_t)0x77D7, (q15_t)0x2CF7, (q15_t)0x77C5, (q15_t)0x2D26, - (q15_t)0x77B4, (q15_t)0x2D55, (q15_t)0x77A2, (q15_t)0x2D84, - (q15_t)0x7790, (q15_t)0x2DB3, (q15_t)0x777E, (q15_t)0x2DE2, - (q15_t)0x776C, (q15_t)0x2E11, (q15_t)0x775A, (q15_t)0x2E3F, - (q15_t)0x7747, (q15_t)0x2E6E, (q15_t)0x7735, (q15_t)0x2E9D, - (q15_t)0x7723, (q15_t)0x2ECC, (q15_t)0x7710, (q15_t)0x2EFB, - (q15_t)0x76FE, (q15_t)0x2F29, (q15_t)0x76EB, (q15_t)0x2F58, - (q15_t)0x76D9, (q15_t)0x2F87, (q15_t)0x76C6, (q15_t)0x2FB5, - (q15_t)0x76B3, (q15_t)0x2FE4, (q15_t)0x76A0, (q15_t)0x3013, - (q15_t)0x768E, (q15_t)0x3041, (q15_t)0x767B, (q15_t)0x3070, - (q15_t)0x7668, (q15_t)0x309E, (q15_t)0x7654, (q15_t)0x30CD, - (q15_t)0x7641, (q15_t)0x30FB, (q15_t)0x762E, (q15_t)0x312A, - (q15_t)0x761B, (q15_t)0x3158, (q15_t)0x7607, (q15_t)0x3186, - (q15_t)0x75F4, (q15_t)0x31B5, (q15_t)0x75E0, (q15_t)0x31E3, - (q15_t)0x75CC, (q15_t)0x3211, (q15_t)0x75B9, (q15_t)0x3240, - (q15_t)0x75A5, (q15_t)0x326E, (q15_t)0x7591, (q15_t)0x329C, - (q15_t)0x757D, (q15_t)0x32CA, (q15_t)0x7569, (q15_t)0x32F8, - (q15_t)0x7555, (q15_t)0x3326, (q15_t)0x7541, (q15_t)0x3354, - (q15_t)0x752D, (q15_t)0x3382, (q15_t)0x7519, (q15_t)0x33B0, - (q15_t)0x7504, (q15_t)0x33DE, (q15_t)0x74F0, (q15_t)0x340C, - (q15_t)0x74DB, (q15_t)0x343A, (q15_t)0x74C7, (q15_t)0x3468, - (q15_t)0x74B2, (q15_t)0x3496, (q15_t)0x749E, (q15_t)0x34C4, - (q15_t)0x7489, (q15_t)0x34F2, (q15_t)0x7474, (q15_t)0x351F, - (q15_t)0x745F, (q15_t)0x354D, (q15_t)0x744A, (q15_t)0x357B, - (q15_t)0x7435, (q15_t)0x35A8, (q15_t)0x7420, (q15_t)0x35D6, - (q15_t)0x740B, (q15_t)0x3604, (q15_t)0x73F6, (q15_t)0x3631, - (q15_t)0x73E0, (q15_t)0x365F, (q15_t)0x73CB, (q15_t)0x368C, - (q15_t)0x73B5, (q15_t)0x36BA, (q15_t)0x73A0, (q15_t)0x36E7, - (q15_t)0x738A, (q15_t)0x3714, (q15_t)0x7375, (q15_t)0x3742, - (q15_t)0x735F, (q15_t)0x376F, (q15_t)0x7349, (q15_t)0x379C, - (q15_t)0x7333, (q15_t)0x37CA, (q15_t)0x731D, (q15_t)0x37F7, - (q15_t)0x7307, (q15_t)0x3824, (q15_t)0x72F1, (q15_t)0x3851, - (q15_t)0x72DB, (q15_t)0x387E, (q15_t)0x72C5, (q15_t)0x38AB, - (q15_t)0x72AF, (q15_t)0x38D8, (q15_t)0x7298, (q15_t)0x3906, - (q15_t)0x7282, (q15_t)0x3932, (q15_t)0x726B, (q15_t)0x395F, - (q15_t)0x7255, (q15_t)0x398C, (q15_t)0x723E, (q15_t)0x39B9, - (q15_t)0x7227, (q15_t)0x39E6, (q15_t)0x7211, (q15_t)0x3A13, - (q15_t)0x71FA, (q15_t)0x3A40, (q15_t)0x71E3, (q15_t)0x3A6C, - (q15_t)0x71CC, (q15_t)0x3A99, (q15_t)0x71B5, (q15_t)0x3AC6, - (q15_t)0x719E, (q15_t)0x3AF2, (q15_t)0x7186, (q15_t)0x3B1F, - (q15_t)0x716F, (q15_t)0x3B4C, (q15_t)0x7158, (q15_t)0x3B78, - (q15_t)0x7141, (q15_t)0x3BA5, (q15_t)0x7129, (q15_t)0x3BD1, - (q15_t)0x7112, (q15_t)0x3BFD, (q15_t)0x70FA, (q15_t)0x3C2A, - (q15_t)0x70E2, (q15_t)0x3C56, (q15_t)0x70CB, (q15_t)0x3C83, - (q15_t)0x70B3, (q15_t)0x3CAF, (q15_t)0x709B, (q15_t)0x3CDB, - (q15_t)0x7083, (q15_t)0x3D07, (q15_t)0x706B, (q15_t)0x3D33, - (q15_t)0x7053, (q15_t)0x3D60, (q15_t)0x703B, (q15_t)0x3D8C, - (q15_t)0x7023, (q15_t)0x3DB8, (q15_t)0x700A, (q15_t)0x3DE4, - (q15_t)0x6FF2, (q15_t)0x3E10, (q15_t)0x6FDA, (q15_t)0x3E3C, - (q15_t)0x6FC1, (q15_t)0x3E68, (q15_t)0x6FA9, (q15_t)0x3E93, - (q15_t)0x6F90, (q15_t)0x3EBF, (q15_t)0x6F77, (q15_t)0x3EEB, - (q15_t)0x6F5F, (q15_t)0x3F17, (q15_t)0x6F46, (q15_t)0x3F43, - (q15_t)0x6F2D, (q15_t)0x3F6E, (q15_t)0x6F14, (q15_t)0x3F9A, - (q15_t)0x6EFB, (q15_t)0x3FC5, (q15_t)0x6EE2, (q15_t)0x3FF1, - (q15_t)0x6EC9, (q15_t)0x401D, (q15_t)0x6EAF, (q15_t)0x4048, - (q15_t)0x6E96, (q15_t)0x4073, (q15_t)0x6E7D, (q15_t)0x409F, - (q15_t)0x6E63, (q15_t)0x40CA, (q15_t)0x6E4A, (q15_t)0x40F6, - (q15_t)0x6E30, (q15_t)0x4121, (q15_t)0x6E17, (q15_t)0x414C, - (q15_t)0x6DFD, (q15_t)0x4177, (q15_t)0x6DE3, (q15_t)0x41A2, - (q15_t)0x6DCA, (q15_t)0x41CE, (q15_t)0x6DB0, (q15_t)0x41F9, - (q15_t)0x6D96, (q15_t)0x4224, (q15_t)0x6D7C, (q15_t)0x424F, - (q15_t)0x6D62, (q15_t)0x427A, (q15_t)0x6D48, (q15_t)0x42A5, - (q15_t)0x6D2D, (q15_t)0x42D0, (q15_t)0x6D13, (q15_t)0x42FA, - (q15_t)0x6CF9, (q15_t)0x4325, (q15_t)0x6CDE, (q15_t)0x4350, - (q15_t)0x6CC4, (q15_t)0x437B, (q15_t)0x6CA9, (q15_t)0x43A5, - (q15_t)0x6C8F, (q15_t)0x43D0, (q15_t)0x6C74, (q15_t)0x43FB, - (q15_t)0x6C59, (q15_t)0x4425, (q15_t)0x6C3F, (q15_t)0x4450, - (q15_t)0x6C24, (q15_t)0x447A, (q15_t)0x6C09, (q15_t)0x44A5, - (q15_t)0x6BEE, (q15_t)0x44CF, (q15_t)0x6BD3, (q15_t)0x44FA, - (q15_t)0x6BB8, (q15_t)0x4524, (q15_t)0x6B9C, (q15_t)0x454E, - (q15_t)0x6B81, (q15_t)0x4578, (q15_t)0x6B66, (q15_t)0x45A3, - (q15_t)0x6B4A, (q15_t)0x45CD, (q15_t)0x6B2F, (q15_t)0x45F7, - (q15_t)0x6B13, (q15_t)0x4621, (q15_t)0x6AF8, (q15_t)0x464B, - (q15_t)0x6ADC, (q15_t)0x4675, (q15_t)0x6AC1, (q15_t)0x469F, - (q15_t)0x6AA5, (q15_t)0x46C9, (q15_t)0x6A89, (q15_t)0x46F3, - (q15_t)0x6A6D, (q15_t)0x471C, (q15_t)0x6A51, (q15_t)0x4746, - (q15_t)0x6A35, (q15_t)0x4770, (q15_t)0x6A19, (q15_t)0x479A, - (q15_t)0x69FD, (q15_t)0x47C3, (q15_t)0x69E1, (q15_t)0x47ED, - (q15_t)0x69C4, (q15_t)0x4816, (q15_t)0x69A8, (q15_t)0x4840, - (q15_t)0x698C, (q15_t)0x4869, (q15_t)0x696F, (q15_t)0x4893, - (q15_t)0x6953, (q15_t)0x48BC, (q15_t)0x6936, (q15_t)0x48E6, - (q15_t)0x6919, (q15_t)0x490F, (q15_t)0x68FD, (q15_t)0x4938, - (q15_t)0x68E0, (q15_t)0x4961, (q15_t)0x68C3, (q15_t)0x498A, - (q15_t)0x68A6, (q15_t)0x49B4, (q15_t)0x6889, (q15_t)0x49DD, - (q15_t)0x686C, (q15_t)0x4A06, (q15_t)0x684F, (q15_t)0x4A2F, - (q15_t)0x6832, (q15_t)0x4A58, (q15_t)0x6815, (q15_t)0x4A81, - (q15_t)0x67F7, (q15_t)0x4AA9, (q15_t)0x67DA, (q15_t)0x4AD2, - (q15_t)0x67BD, (q15_t)0x4AFB, (q15_t)0x679F, (q15_t)0x4B24, - (q15_t)0x6782, (q15_t)0x4B4C, (q15_t)0x6764, (q15_t)0x4B75, - (q15_t)0x6746, (q15_t)0x4B9E, (q15_t)0x6729, (q15_t)0x4BC6, - (q15_t)0x670B, (q15_t)0x4BEF, (q15_t)0x66ED, (q15_t)0x4C17, - (q15_t)0x66CF, (q15_t)0x4C3F, (q15_t)0x66B1, (q15_t)0x4C68, - (q15_t)0x6693, (q15_t)0x4C90, (q15_t)0x6675, (q15_t)0x4CB8, - (q15_t)0x6657, (q15_t)0x4CE1, (q15_t)0x6639, (q15_t)0x4D09, - (q15_t)0x661A, (q15_t)0x4D31, (q15_t)0x65FC, (q15_t)0x4D59, - (q15_t)0x65DD, (q15_t)0x4D81, (q15_t)0x65BF, (q15_t)0x4DA9, - (q15_t)0x65A0, (q15_t)0x4DD1, (q15_t)0x6582, (q15_t)0x4DF9, - (q15_t)0x6563, (q15_t)0x4E21, (q15_t)0x6545, (q15_t)0x4E48, - (q15_t)0x6526, (q15_t)0x4E70, (q15_t)0x6507, (q15_t)0x4E98, - (q15_t)0x64E8, (q15_t)0x4EBF, (q15_t)0x64C9, (q15_t)0x4EE7, - (q15_t)0x64AA, (q15_t)0x4F0F, (q15_t)0x648B, (q15_t)0x4F36, - (q15_t)0x646C, (q15_t)0x4F5E, (q15_t)0x644D, (q15_t)0x4F85, - (q15_t)0x642D, (q15_t)0x4FAC, (q15_t)0x640E, (q15_t)0x4FD4, - (q15_t)0x63EF, (q15_t)0x4FFB, (q15_t)0x63CF, (q15_t)0x5022, - (q15_t)0x63B0, (q15_t)0x5049, (q15_t)0x6390, (q15_t)0x5070, - (q15_t)0x6371, (q15_t)0x5097, (q15_t)0x6351, (q15_t)0x50BF, - (q15_t)0x6331, (q15_t)0x50E5, (q15_t)0x6311, (q15_t)0x510C, - (q15_t)0x62F2, (q15_t)0x5133, (q15_t)0x62D2, (q15_t)0x515A, - (q15_t)0x62B2, (q15_t)0x5181, (q15_t)0x6292, (q15_t)0x51A8, - (q15_t)0x6271, (q15_t)0x51CE, (q15_t)0x6251, (q15_t)0x51F5, - (q15_t)0x6231, (q15_t)0x521C, (q15_t)0x6211, (q15_t)0x5242, - (q15_t)0x61F1, (q15_t)0x5269, (q15_t)0x61D0, (q15_t)0x528F, - (q15_t)0x61B0, (q15_t)0x52B5, (q15_t)0x618F, (q15_t)0x52DC, - (q15_t)0x616F, (q15_t)0x5302, (q15_t)0x614E, (q15_t)0x5328, - (q15_t)0x612D, (q15_t)0x534E, (q15_t)0x610D, (q15_t)0x5375, - (q15_t)0x60EC, (q15_t)0x539B, (q15_t)0x60CB, (q15_t)0x53C1, - (q15_t)0x60AA, (q15_t)0x53E7, (q15_t)0x6089, (q15_t)0x540D, - (q15_t)0x6068, (q15_t)0x5433, (q15_t)0x6047, (q15_t)0x5458, - (q15_t)0x6026, (q15_t)0x547E, (q15_t)0x6004, (q15_t)0x54A4, - (q15_t)0x5FE3, (q15_t)0x54CA, (q15_t)0x5FC2, (q15_t)0x54EF, - (q15_t)0x5FA0, (q15_t)0x5515, (q15_t)0x5F7F, (q15_t)0x553A, - (q15_t)0x5F5E, (q15_t)0x5560, (q15_t)0x5F3C, (q15_t)0x5585, - (q15_t)0x5F1A, (q15_t)0x55AB, (q15_t)0x5EF9, (q15_t)0x55D0, - (q15_t)0x5ED7, (q15_t)0x55F5, (q15_t)0x5EB5, (q15_t)0x561A, - (q15_t)0x5E93, (q15_t)0x5640, (q15_t)0x5E71, (q15_t)0x5665, - (q15_t)0x5E50, (q15_t)0x568A, (q15_t)0x5E2D, (q15_t)0x56AF, - (q15_t)0x5E0B, (q15_t)0x56D4, (q15_t)0x5DE9, (q15_t)0x56F9, - (q15_t)0x5DC7, (q15_t)0x571D, (q15_t)0x5DA5, (q15_t)0x5742, - (q15_t)0x5D83, (q15_t)0x5767, (q15_t)0x5D60, (q15_t)0x578C, - (q15_t)0x5D3E, (q15_t)0x57B0, (q15_t)0x5D1B, (q15_t)0x57D5, - (q15_t)0x5CF9, (q15_t)0x57F9, (q15_t)0x5CD6, (q15_t)0x581E, - (q15_t)0x5CB4, (q15_t)0x5842, (q15_t)0x5C91, (q15_t)0x5867, - (q15_t)0x5C6E, (q15_t)0x588B, (q15_t)0x5C4B, (q15_t)0x58AF, - (q15_t)0x5C29, (q15_t)0x58D4, (q15_t)0x5C06, (q15_t)0x58F8, - (q15_t)0x5BE3, (q15_t)0x591C, (q15_t)0x5BC0, (q15_t)0x5940, - (q15_t)0x5B9D, (q15_t)0x5964, (q15_t)0x5B79, (q15_t)0x5988, - (q15_t)0x5B56, (q15_t)0x59AC, (q15_t)0x5B33, (q15_t)0x59D0, - (q15_t)0x5B10, (q15_t)0x59F3, (q15_t)0x5AEC, (q15_t)0x5A17, - (q15_t)0x5AC9, (q15_t)0x5A3B, (q15_t)0x5AA5, (q15_t)0x5A5E, - (q15_t)0x5A82, (q15_t)0x5A82, (q15_t)0x5A5E, (q15_t)0x5AA5, - (q15_t)0x5A3B, (q15_t)0x5AC9, (q15_t)0x5A17, (q15_t)0x5AEC, - (q15_t)0x59F3, (q15_t)0x5B10, (q15_t)0x59D0, (q15_t)0x5B33, - (q15_t)0x59AC, (q15_t)0x5B56, (q15_t)0x5988, (q15_t)0x5B79, - (q15_t)0x5964, (q15_t)0x5B9D, (q15_t)0x5940, (q15_t)0x5BC0, - (q15_t)0x591C, (q15_t)0x5BE3, (q15_t)0x58F8, (q15_t)0x5C06, - (q15_t)0x58D4, (q15_t)0x5C29, (q15_t)0x58AF, (q15_t)0x5C4B, - (q15_t)0x588B, (q15_t)0x5C6E, (q15_t)0x5867, (q15_t)0x5C91, - (q15_t)0x5842, (q15_t)0x5CB4, (q15_t)0x581E, (q15_t)0x5CD6, - (q15_t)0x57F9, (q15_t)0x5CF9, (q15_t)0x57D5, (q15_t)0x5D1B, - (q15_t)0x57B0, (q15_t)0x5D3E, (q15_t)0x578C, (q15_t)0x5D60, - (q15_t)0x5767, (q15_t)0x5D83, (q15_t)0x5742, (q15_t)0x5DA5, - (q15_t)0x571D, (q15_t)0x5DC7, (q15_t)0x56F9, (q15_t)0x5DE9, - (q15_t)0x56D4, (q15_t)0x5E0B, (q15_t)0x56AF, (q15_t)0x5E2D, - (q15_t)0x568A, (q15_t)0x5E50, (q15_t)0x5665, (q15_t)0x5E71, - (q15_t)0x5640, (q15_t)0x5E93, (q15_t)0x561A, (q15_t)0x5EB5, - (q15_t)0x55F5, (q15_t)0x5ED7, (q15_t)0x55D0, (q15_t)0x5EF9, - (q15_t)0x55AB, (q15_t)0x5F1A, (q15_t)0x5585, (q15_t)0x5F3C, - (q15_t)0x5560, (q15_t)0x5F5E, (q15_t)0x553A, (q15_t)0x5F7F, - (q15_t)0x5515, (q15_t)0x5FA0, (q15_t)0x54EF, (q15_t)0x5FC2, - (q15_t)0x54CA, (q15_t)0x5FE3, (q15_t)0x54A4, (q15_t)0x6004, - (q15_t)0x547E, (q15_t)0x6026, (q15_t)0x5458, (q15_t)0x6047, - (q15_t)0x5433, (q15_t)0x6068, (q15_t)0x540D, (q15_t)0x6089, - (q15_t)0x53E7, (q15_t)0x60AA, (q15_t)0x53C1, (q15_t)0x60CB, - (q15_t)0x539B, (q15_t)0x60EC, (q15_t)0x5375, (q15_t)0x610D, - (q15_t)0x534E, (q15_t)0x612D, (q15_t)0x5328, (q15_t)0x614E, - (q15_t)0x5302, (q15_t)0x616F, (q15_t)0x52DC, (q15_t)0x618F, - (q15_t)0x52B5, (q15_t)0x61B0, (q15_t)0x528F, (q15_t)0x61D0, - (q15_t)0x5269, (q15_t)0x61F1, (q15_t)0x5242, (q15_t)0x6211, - (q15_t)0x521C, (q15_t)0x6231, (q15_t)0x51F5, (q15_t)0x6251, - (q15_t)0x51CE, (q15_t)0x6271, (q15_t)0x51A8, (q15_t)0x6292, - (q15_t)0x5181, (q15_t)0x62B2, (q15_t)0x515A, (q15_t)0x62D2, - (q15_t)0x5133, (q15_t)0x62F2, (q15_t)0x510C, (q15_t)0x6311, - (q15_t)0x50E5, (q15_t)0x6331, (q15_t)0x50BF, (q15_t)0x6351, - (q15_t)0x5097, (q15_t)0x6371, (q15_t)0x5070, (q15_t)0x6390, - (q15_t)0x5049, (q15_t)0x63B0, (q15_t)0x5022, (q15_t)0x63CF, - (q15_t)0x4FFB, (q15_t)0x63EF, (q15_t)0x4FD4, (q15_t)0x640E, - (q15_t)0x4FAC, (q15_t)0x642D, (q15_t)0x4F85, (q15_t)0x644D, - (q15_t)0x4F5E, (q15_t)0x646C, (q15_t)0x4F36, (q15_t)0x648B, - (q15_t)0x4F0F, (q15_t)0x64AA, (q15_t)0x4EE7, (q15_t)0x64C9, - (q15_t)0x4EBF, (q15_t)0x64E8, (q15_t)0x4E98, (q15_t)0x6507, - (q15_t)0x4E70, (q15_t)0x6526, (q15_t)0x4E48, (q15_t)0x6545, - (q15_t)0x4E21, (q15_t)0x6563, (q15_t)0x4DF9, (q15_t)0x6582, - (q15_t)0x4DD1, (q15_t)0x65A0, (q15_t)0x4DA9, (q15_t)0x65BF, - (q15_t)0x4D81, (q15_t)0x65DD, (q15_t)0x4D59, (q15_t)0x65FC, - (q15_t)0x4D31, (q15_t)0x661A, (q15_t)0x4D09, (q15_t)0x6639, - (q15_t)0x4CE1, (q15_t)0x6657, (q15_t)0x4CB8, (q15_t)0x6675, - (q15_t)0x4C90, (q15_t)0x6693, (q15_t)0x4C68, (q15_t)0x66B1, - (q15_t)0x4C3F, (q15_t)0x66CF, (q15_t)0x4C17, (q15_t)0x66ED, - (q15_t)0x4BEF, (q15_t)0x670B, (q15_t)0x4BC6, (q15_t)0x6729, - (q15_t)0x4B9E, (q15_t)0x6746, (q15_t)0x4B75, (q15_t)0x6764, - (q15_t)0x4B4C, (q15_t)0x6782, (q15_t)0x4B24, (q15_t)0x679F, - (q15_t)0x4AFB, (q15_t)0x67BD, (q15_t)0x4AD2, (q15_t)0x67DA, - (q15_t)0x4AA9, (q15_t)0x67F7, (q15_t)0x4A81, (q15_t)0x6815, - (q15_t)0x4A58, (q15_t)0x6832, (q15_t)0x4A2F, (q15_t)0x684F, - (q15_t)0x4A06, (q15_t)0x686C, (q15_t)0x49DD, (q15_t)0x6889, - (q15_t)0x49B4, (q15_t)0x68A6, (q15_t)0x498A, (q15_t)0x68C3, - (q15_t)0x4961, (q15_t)0x68E0, (q15_t)0x4938, (q15_t)0x68FD, - (q15_t)0x490F, (q15_t)0x6919, (q15_t)0x48E6, (q15_t)0x6936, - (q15_t)0x48BC, (q15_t)0x6953, (q15_t)0x4893, (q15_t)0x696F, - (q15_t)0x4869, (q15_t)0x698C, (q15_t)0x4840, (q15_t)0x69A8, - (q15_t)0x4816, (q15_t)0x69C4, (q15_t)0x47ED, (q15_t)0x69E1, - (q15_t)0x47C3, (q15_t)0x69FD, (q15_t)0x479A, (q15_t)0x6A19, - (q15_t)0x4770, (q15_t)0x6A35, (q15_t)0x4746, (q15_t)0x6A51, - (q15_t)0x471C, (q15_t)0x6A6D, (q15_t)0x46F3, (q15_t)0x6A89, - (q15_t)0x46C9, (q15_t)0x6AA5, (q15_t)0x469F, (q15_t)0x6AC1, - (q15_t)0x4675, (q15_t)0x6ADC, (q15_t)0x464B, (q15_t)0x6AF8, - (q15_t)0x4621, (q15_t)0x6B13, (q15_t)0x45F7, (q15_t)0x6B2F, - (q15_t)0x45CD, (q15_t)0x6B4A, (q15_t)0x45A3, (q15_t)0x6B66, - (q15_t)0x4578, (q15_t)0x6B81, (q15_t)0x454E, (q15_t)0x6B9C, - (q15_t)0x4524, (q15_t)0x6BB8, (q15_t)0x44FA, (q15_t)0x6BD3, - (q15_t)0x44CF, (q15_t)0x6BEE, (q15_t)0x44A5, (q15_t)0x6C09, - (q15_t)0x447A, (q15_t)0x6C24, (q15_t)0x4450, (q15_t)0x6C3F, - (q15_t)0x4425, (q15_t)0x6C59, (q15_t)0x43FB, (q15_t)0x6C74, - (q15_t)0x43D0, (q15_t)0x6C8F, (q15_t)0x43A5, (q15_t)0x6CA9, - (q15_t)0x437B, (q15_t)0x6CC4, (q15_t)0x4350, (q15_t)0x6CDE, - (q15_t)0x4325, (q15_t)0x6CF9, (q15_t)0x42FA, (q15_t)0x6D13, - (q15_t)0x42D0, (q15_t)0x6D2D, (q15_t)0x42A5, (q15_t)0x6D48, - (q15_t)0x427A, (q15_t)0x6D62, (q15_t)0x424F, (q15_t)0x6D7C, - (q15_t)0x4224, (q15_t)0x6D96, (q15_t)0x41F9, (q15_t)0x6DB0, - (q15_t)0x41CE, (q15_t)0x6DCA, (q15_t)0x41A2, (q15_t)0x6DE3, - (q15_t)0x4177, (q15_t)0x6DFD, (q15_t)0x414C, (q15_t)0x6E17, - (q15_t)0x4121, (q15_t)0x6E30, (q15_t)0x40F6, (q15_t)0x6E4A, - (q15_t)0x40CA, (q15_t)0x6E63, (q15_t)0x409F, (q15_t)0x6E7D, - (q15_t)0x4073, (q15_t)0x6E96, (q15_t)0x4048, (q15_t)0x6EAF, - (q15_t)0x401D, (q15_t)0x6EC9, (q15_t)0x3FF1, (q15_t)0x6EE2, - (q15_t)0x3FC5, (q15_t)0x6EFB, (q15_t)0x3F9A, (q15_t)0x6F14, - (q15_t)0x3F6E, (q15_t)0x6F2D, (q15_t)0x3F43, (q15_t)0x6F46, - (q15_t)0x3F17, (q15_t)0x6F5F, (q15_t)0x3EEB, (q15_t)0x6F77, - (q15_t)0x3EBF, (q15_t)0x6F90, (q15_t)0x3E93, (q15_t)0x6FA9, - (q15_t)0x3E68, (q15_t)0x6FC1, (q15_t)0x3E3C, (q15_t)0x6FDA, - (q15_t)0x3E10, (q15_t)0x6FF2, (q15_t)0x3DE4, (q15_t)0x700A, - (q15_t)0x3DB8, (q15_t)0x7023, (q15_t)0x3D8C, (q15_t)0x703B, - (q15_t)0x3D60, (q15_t)0x7053, (q15_t)0x3D33, (q15_t)0x706B, - (q15_t)0x3D07, (q15_t)0x7083, (q15_t)0x3CDB, (q15_t)0x709B, - (q15_t)0x3CAF, (q15_t)0x70B3, (q15_t)0x3C83, (q15_t)0x70CB, - (q15_t)0x3C56, (q15_t)0x70E2, (q15_t)0x3C2A, (q15_t)0x70FA, - (q15_t)0x3BFD, (q15_t)0x7112, (q15_t)0x3BD1, (q15_t)0x7129, - (q15_t)0x3BA5, (q15_t)0x7141, (q15_t)0x3B78, (q15_t)0x7158, - (q15_t)0x3B4C, (q15_t)0x716F, (q15_t)0x3B1F, (q15_t)0x7186, - (q15_t)0x3AF2, (q15_t)0x719E, (q15_t)0x3AC6, (q15_t)0x71B5, - (q15_t)0x3A99, (q15_t)0x71CC, (q15_t)0x3A6C, (q15_t)0x71E3, - (q15_t)0x3A40, (q15_t)0x71FA, (q15_t)0x3A13, (q15_t)0x7211, - (q15_t)0x39E6, (q15_t)0x7227, (q15_t)0x39B9, (q15_t)0x723E, - (q15_t)0x398C, (q15_t)0x7255, (q15_t)0x395F, (q15_t)0x726B, - (q15_t)0x3932, (q15_t)0x7282, (q15_t)0x3906, (q15_t)0x7298, - (q15_t)0x38D8, (q15_t)0x72AF, (q15_t)0x38AB, (q15_t)0x72C5, - (q15_t)0x387E, (q15_t)0x72DB, (q15_t)0x3851, (q15_t)0x72F1, - (q15_t)0x3824, (q15_t)0x7307, (q15_t)0x37F7, (q15_t)0x731D, - (q15_t)0x37CA, (q15_t)0x7333, (q15_t)0x379C, (q15_t)0x7349, - (q15_t)0x376F, (q15_t)0x735F, (q15_t)0x3742, (q15_t)0x7375, - (q15_t)0x3714, (q15_t)0x738A, (q15_t)0x36E7, (q15_t)0x73A0, - (q15_t)0x36BA, (q15_t)0x73B5, (q15_t)0x368C, (q15_t)0x73CB, - (q15_t)0x365F, (q15_t)0x73E0, (q15_t)0x3631, (q15_t)0x73F6, - (q15_t)0x3604, (q15_t)0x740B, (q15_t)0x35D6, (q15_t)0x7420, - (q15_t)0x35A8, (q15_t)0x7435, (q15_t)0x357B, (q15_t)0x744A, - (q15_t)0x354D, (q15_t)0x745F, (q15_t)0x351F, (q15_t)0x7474, - (q15_t)0x34F2, (q15_t)0x7489, (q15_t)0x34C4, (q15_t)0x749E, - (q15_t)0x3496, (q15_t)0x74B2, (q15_t)0x3468, (q15_t)0x74C7, - (q15_t)0x343A, (q15_t)0x74DB, (q15_t)0x340C, (q15_t)0x74F0, - (q15_t)0x33DE, (q15_t)0x7504, (q15_t)0x33B0, (q15_t)0x7519, - (q15_t)0x3382, (q15_t)0x752D, (q15_t)0x3354, (q15_t)0x7541, - (q15_t)0x3326, (q15_t)0x7555, (q15_t)0x32F8, (q15_t)0x7569, - (q15_t)0x32CA, (q15_t)0x757D, (q15_t)0x329C, (q15_t)0x7591, - (q15_t)0x326E, (q15_t)0x75A5, (q15_t)0x3240, (q15_t)0x75B9, - (q15_t)0x3211, (q15_t)0x75CC, (q15_t)0x31E3, (q15_t)0x75E0, - (q15_t)0x31B5, (q15_t)0x75F4, (q15_t)0x3186, (q15_t)0x7607, - (q15_t)0x3158, (q15_t)0x761B, (q15_t)0x312A, (q15_t)0x762E, - (q15_t)0x30FB, (q15_t)0x7641, (q15_t)0x30CD, (q15_t)0x7654, - (q15_t)0x309E, (q15_t)0x7668, (q15_t)0x3070, (q15_t)0x767B, - (q15_t)0x3041, (q15_t)0x768E, (q15_t)0x3013, (q15_t)0x76A0, - (q15_t)0x2FE4, (q15_t)0x76B3, (q15_t)0x2FB5, (q15_t)0x76C6, - (q15_t)0x2F87, (q15_t)0x76D9, (q15_t)0x2F58, (q15_t)0x76EB, - (q15_t)0x2F29, (q15_t)0x76FE, (q15_t)0x2EFB, (q15_t)0x7710, - (q15_t)0x2ECC, (q15_t)0x7723, (q15_t)0x2E9D, (q15_t)0x7735, - (q15_t)0x2E6E, (q15_t)0x7747, (q15_t)0x2E3F, (q15_t)0x775A, - (q15_t)0x2E11, (q15_t)0x776C, (q15_t)0x2DE2, (q15_t)0x777E, - (q15_t)0x2DB3, (q15_t)0x7790, (q15_t)0x2D84, (q15_t)0x77A2, - (q15_t)0x2D55, (q15_t)0x77B4, (q15_t)0x2D26, (q15_t)0x77C5, - (q15_t)0x2CF7, (q15_t)0x77D7, (q15_t)0x2CC8, (q15_t)0x77E9, - (q15_t)0x2C98, (q15_t)0x77FA, (q15_t)0x2C69, (q15_t)0x780C, - (q15_t)0x2C3A, (q15_t)0x781D, (q15_t)0x2C0B, (q15_t)0x782E, - (q15_t)0x2BDC, (q15_t)0x7840, (q15_t)0x2BAD, (q15_t)0x7851, - (q15_t)0x2B7D, (q15_t)0x7862, (q15_t)0x2B4E, (q15_t)0x7873, - (q15_t)0x2B1F, (q15_t)0x7884, (q15_t)0x2AEF, (q15_t)0x7895, - (q15_t)0x2AC0, (q15_t)0x78A6, (q15_t)0x2A91, (q15_t)0x78B6, - (q15_t)0x2A61, (q15_t)0x78C7, (q15_t)0x2A32, (q15_t)0x78D8, - (q15_t)0x2A02, (q15_t)0x78E8, (q15_t)0x29D3, (q15_t)0x78F9, - (q15_t)0x29A3, (q15_t)0x7909, (q15_t)0x2974, (q15_t)0x7919, - (q15_t)0x2944, (q15_t)0x792A, (q15_t)0x2915, (q15_t)0x793A, - (q15_t)0x28E5, (q15_t)0x794A, (q15_t)0x28B5, (q15_t)0x795A, - (q15_t)0x2886, (q15_t)0x796A, (q15_t)0x2856, (q15_t)0x797A, - (q15_t)0x2826, (q15_t)0x798A, (q15_t)0x27F6, (q15_t)0x7999, - (q15_t)0x27C7, (q15_t)0x79A9, (q15_t)0x2797, (q15_t)0x79B9, - (q15_t)0x2767, (q15_t)0x79C8, (q15_t)0x2737, (q15_t)0x79D8, - (q15_t)0x2707, (q15_t)0x79E7, (q15_t)0x26D8, (q15_t)0x79F6, - (q15_t)0x26A8, (q15_t)0x7A05, (q15_t)0x2678, (q15_t)0x7A15, - (q15_t)0x2648, (q15_t)0x7A24, (q15_t)0x2618, (q15_t)0x7A33, - (q15_t)0x25E8, (q15_t)0x7A42, (q15_t)0x25B8, (q15_t)0x7A50, - (q15_t)0x2588, (q15_t)0x7A5F, (q15_t)0x2558, (q15_t)0x7A6E, - (q15_t)0x2528, (q15_t)0x7A7D, (q15_t)0x24F7, (q15_t)0x7A8B, - (q15_t)0x24C7, (q15_t)0x7A9A, (q15_t)0x2497, (q15_t)0x7AA8, - (q15_t)0x2467, (q15_t)0x7AB6, (q15_t)0x2437, (q15_t)0x7AC5, - (q15_t)0x2407, (q15_t)0x7AD3, (q15_t)0x23D6, (q15_t)0x7AE1, - (q15_t)0x23A6, (q15_t)0x7AEF, (q15_t)0x2376, (q15_t)0x7AFD, - (q15_t)0x2345, (q15_t)0x7B0B, (q15_t)0x2315, (q15_t)0x7B19, - (q15_t)0x22E5, (q15_t)0x7B26, (q15_t)0x22B4, (q15_t)0x7B34, - (q15_t)0x2284, (q15_t)0x7B42, (q15_t)0x2254, (q15_t)0x7B4F, - (q15_t)0x2223, (q15_t)0x7B5D, (q15_t)0x21F3, (q15_t)0x7B6A, - (q15_t)0x21C2, (q15_t)0x7B77, (q15_t)0x2192, (q15_t)0x7B84, - (q15_t)0x2161, (q15_t)0x7B92, (q15_t)0x2131, (q15_t)0x7B9F, - (q15_t)0x2100, (q15_t)0x7BAC, (q15_t)0x20D0, (q15_t)0x7BB9, - (q15_t)0x209F, (q15_t)0x7BC5, (q15_t)0x206E, (q15_t)0x7BD2, - (q15_t)0x203E, (q15_t)0x7BDF, (q15_t)0x200D, (q15_t)0x7BEB, - (q15_t)0x1FDC, (q15_t)0x7BF8, (q15_t)0x1FAC, (q15_t)0x7C05, - (q15_t)0x1F7B, (q15_t)0x7C11, (q15_t)0x1F4A, (q15_t)0x7C1D, - (q15_t)0x1F19, (q15_t)0x7C29, (q15_t)0x1EE9, (q15_t)0x7C36, - (q15_t)0x1EB8, (q15_t)0x7C42, (q15_t)0x1E87, (q15_t)0x7C4E, - (q15_t)0x1E56, (q15_t)0x7C5A, (q15_t)0x1E25, (q15_t)0x7C66, - (q15_t)0x1DF5, (q15_t)0x7C71, (q15_t)0x1DC4, (q15_t)0x7C7D, - (q15_t)0x1D93, (q15_t)0x7C89, (q15_t)0x1D62, (q15_t)0x7C94, - (q15_t)0x1D31, (q15_t)0x7CA0, (q15_t)0x1D00, (q15_t)0x7CAB, - (q15_t)0x1CCF, (q15_t)0x7CB7, (q15_t)0x1C9E, (q15_t)0x7CC2, - (q15_t)0x1C6D, (q15_t)0x7CCD, (q15_t)0x1C3C, (q15_t)0x7CD8, - (q15_t)0x1C0B, (q15_t)0x7CE3, (q15_t)0x1BDA, (q15_t)0x7CEE, - (q15_t)0x1BA9, (q15_t)0x7CF9, (q15_t)0x1B78, (q15_t)0x7D04, - (q15_t)0x1B47, (q15_t)0x7D0F, (q15_t)0x1B16, (q15_t)0x7D19, - (q15_t)0x1AE4, (q15_t)0x7D24, (q15_t)0x1AB3, (q15_t)0x7D2F, - (q15_t)0x1A82, (q15_t)0x7D39, (q15_t)0x1A51, (q15_t)0x7D43, - (q15_t)0x1A20, (q15_t)0x7D4E, (q15_t)0x19EF, (q15_t)0x7D58, - (q15_t)0x19BD, (q15_t)0x7D62, (q15_t)0x198C, (q15_t)0x7D6C, - (q15_t)0x195B, (q15_t)0x7D76, (q15_t)0x192A, (q15_t)0x7D80, - (q15_t)0x18F8, (q15_t)0x7D8A, (q15_t)0x18C7, (q15_t)0x7D94, - (q15_t)0x1896, (q15_t)0x7D9D, (q15_t)0x1864, (q15_t)0x7DA7, - (q15_t)0x1833, (q15_t)0x7DB0, (q15_t)0x1802, (q15_t)0x7DBA, - (q15_t)0x17D0, (q15_t)0x7DC3, (q15_t)0x179F, (q15_t)0x7DCD, - (q15_t)0x176D, (q15_t)0x7DD6, (q15_t)0x173C, (q15_t)0x7DDF, - (q15_t)0x170A, (q15_t)0x7DE8, (q15_t)0x16D9, (q15_t)0x7DF1, - (q15_t)0x16A8, (q15_t)0x7DFA, (q15_t)0x1676, (q15_t)0x7E03, - (q15_t)0x1645, (q15_t)0x7E0C, (q15_t)0x1613, (q15_t)0x7E14, - (q15_t)0x15E2, (q15_t)0x7E1D, (q15_t)0x15B0, (q15_t)0x7E26, - (q15_t)0x157F, (q15_t)0x7E2E, (q15_t)0x154D, (q15_t)0x7E37, - (q15_t)0x151B, (q15_t)0x7E3F, (q15_t)0x14EA, (q15_t)0x7E47, - (q15_t)0x14B8, (q15_t)0x7E4F, (q15_t)0x1487, (q15_t)0x7E57, - (q15_t)0x1455, (q15_t)0x7E5F, (q15_t)0x1423, (q15_t)0x7E67, - (q15_t)0x13F2, (q15_t)0x7E6F, (q15_t)0x13C0, (q15_t)0x7E77, - (q15_t)0x138E, (q15_t)0x7E7F, (q15_t)0x135D, (q15_t)0x7E86, - (q15_t)0x132B, (q15_t)0x7E8E, (q15_t)0x12F9, (q15_t)0x7E95, - (q15_t)0x12C8, (q15_t)0x7E9D, (q15_t)0x1296, (q15_t)0x7EA4, - (q15_t)0x1264, (q15_t)0x7EAB, (q15_t)0x1232, (q15_t)0x7EB3, - (q15_t)0x1201, (q15_t)0x7EBA, (q15_t)0x11CF, (q15_t)0x7EC1, - (q15_t)0x119D, (q15_t)0x7EC8, (q15_t)0x116B, (q15_t)0x7ECF, - (q15_t)0x1139, (q15_t)0x7ED5, (q15_t)0x1108, (q15_t)0x7EDC, - (q15_t)0x10D6, (q15_t)0x7EE3, (q15_t)0x10A4, (q15_t)0x7EE9, - (q15_t)0x1072, (q15_t)0x7EF0, (q15_t)0x1040, (q15_t)0x7EF6, - (q15_t)0x100E, (q15_t)0x7EFD, (q15_t)0x0FDD, (q15_t)0x7F03, - (q15_t)0x0FAB, (q15_t)0x7F09, (q15_t)0x0F79, (q15_t)0x7F0F, - (q15_t)0x0F47, (q15_t)0x7F15, (q15_t)0x0F15, (q15_t)0x7F1B, - (q15_t)0x0EE3, (q15_t)0x7F21, (q15_t)0x0EB1, (q15_t)0x7F27, - (q15_t)0x0E7F, (q15_t)0x7F2D, (q15_t)0x0E4D, (q15_t)0x7F32, - (q15_t)0x0E1B, (q15_t)0x7F38, (q15_t)0x0DE9, (q15_t)0x7F3D, - (q15_t)0x0DB7, (q15_t)0x7F43, (q15_t)0x0D85, (q15_t)0x7F48, - (q15_t)0x0D53, (q15_t)0x7F4D, (q15_t)0x0D21, (q15_t)0x7F53, - (q15_t)0x0CEF, (q15_t)0x7F58, (q15_t)0x0CBD, (q15_t)0x7F5D, - (q15_t)0x0C8B, (q15_t)0x7F62, (q15_t)0x0C59, (q15_t)0x7F67, - (q15_t)0x0C27, (q15_t)0x7F6B, (q15_t)0x0BF5, (q15_t)0x7F70, - (q15_t)0x0BC3, (q15_t)0x7F75, (q15_t)0x0B91, (q15_t)0x7F79, - (q15_t)0x0B5F, (q15_t)0x7F7E, (q15_t)0x0B2D, (q15_t)0x7F82, - (q15_t)0x0AFB, (q15_t)0x7F87, (q15_t)0x0AC9, (q15_t)0x7F8B, - (q15_t)0x0A97, (q15_t)0x7F8F, (q15_t)0x0A65, (q15_t)0x7F93, - (q15_t)0x0A33, (q15_t)0x7F97, (q15_t)0x0A00, (q15_t)0x7F9B, - (q15_t)0x09CE, (q15_t)0x7F9F, (q15_t)0x099C, (q15_t)0x7FA3, - (q15_t)0x096A, (q15_t)0x7FA7, (q15_t)0x0938, (q15_t)0x7FAA, - (q15_t)0x0906, (q15_t)0x7FAE, (q15_t)0x08D4, (q15_t)0x7FB1, - (q15_t)0x08A2, (q15_t)0x7FB5, (q15_t)0x086F, (q15_t)0x7FB8, - (q15_t)0x083D, (q15_t)0x7FBC, (q15_t)0x080B, (q15_t)0x7FBF, - (q15_t)0x07D9, (q15_t)0x7FC2, (q15_t)0x07A7, (q15_t)0x7FC5, - (q15_t)0x0775, (q15_t)0x7FC8, (q15_t)0x0742, (q15_t)0x7FCB, - (q15_t)0x0710, (q15_t)0x7FCE, (q15_t)0x06DE, (q15_t)0x7FD0, - (q15_t)0x06AC, (q15_t)0x7FD3, (q15_t)0x067A, (q15_t)0x7FD6, - (q15_t)0x0647, (q15_t)0x7FD8, (q15_t)0x0615, (q15_t)0x7FDA, - (q15_t)0x05E3, (q15_t)0x7FDD, (q15_t)0x05B1, (q15_t)0x7FDF, - (q15_t)0x057F, (q15_t)0x7FE1, (q15_t)0x054C, (q15_t)0x7FE3, - (q15_t)0x051A, (q15_t)0x7FE5, (q15_t)0x04E8, (q15_t)0x7FE7, - (q15_t)0x04B6, (q15_t)0x7FE9, (q15_t)0x0483, (q15_t)0x7FEB, - (q15_t)0x0451, (q15_t)0x7FED, (q15_t)0x041F, (q15_t)0x7FEE, - (q15_t)0x03ED, (q15_t)0x7FF0, (q15_t)0x03BA, (q15_t)0x7FF2, - (q15_t)0x0388, (q15_t)0x7FF3, (q15_t)0x0356, (q15_t)0x7FF4, - (q15_t)0x0324, (q15_t)0x7FF6, (q15_t)0x02F1, (q15_t)0x7FF7, - (q15_t)0x02BF, (q15_t)0x7FF8, (q15_t)0x028D, (q15_t)0x7FF9, - (q15_t)0x025B, (q15_t)0x7FFA, (q15_t)0x0228, (q15_t)0x7FFB, - (q15_t)0x01F6, (q15_t)0x7FFC, (q15_t)0x01C4, (q15_t)0x7FFC, - (q15_t)0x0192, (q15_t)0x7FFD, (q15_t)0x015F, (q15_t)0x7FFE, - (q15_t)0x012D, (q15_t)0x7FFE, (q15_t)0x00FB, (q15_t)0x7FFF, - (q15_t)0x00C9, (q15_t)0x7FFF, (q15_t)0x0096, (q15_t)0x7FFF, - (q15_t)0x0064, (q15_t)0x7FFF, (q15_t)0x0032, (q15_t)0x7FFF, - (q15_t)0x0000, (q15_t)0x7FFF, (q15_t)0xFFCD, (q15_t)0x7FFF, - (q15_t)0xFF9B, (q15_t)0x7FFF, (q15_t)0xFF69, (q15_t)0x7FFF, - (q15_t)0xFF36, (q15_t)0x7FFF, (q15_t)0xFF04, (q15_t)0x7FFF, - (q15_t)0xFED2, (q15_t)0x7FFE, (q15_t)0xFEA0, (q15_t)0x7FFE, - (q15_t)0xFE6D, (q15_t)0x7FFD, (q15_t)0xFE3B, (q15_t)0x7FFC, - (q15_t)0xFE09, (q15_t)0x7FFC, (q15_t)0xFDD7, (q15_t)0x7FFB, - (q15_t)0xFDA4, (q15_t)0x7FFA, (q15_t)0xFD72, (q15_t)0x7FF9, - (q15_t)0xFD40, (q15_t)0x7FF8, (q15_t)0xFD0E, (q15_t)0x7FF7, - (q15_t)0xFCDB, (q15_t)0x7FF6, (q15_t)0xFCA9, (q15_t)0x7FF4, - (q15_t)0xFC77, (q15_t)0x7FF3, (q15_t)0xFC45, (q15_t)0x7FF2, - (q15_t)0xFC12, (q15_t)0x7FF0, (q15_t)0xFBE0, (q15_t)0x7FEE, - (q15_t)0xFBAE, (q15_t)0x7FED, (q15_t)0xFB7C, (q15_t)0x7FEB, - (q15_t)0xFB49, (q15_t)0x7FE9, (q15_t)0xFB17, (q15_t)0x7FE7, - (q15_t)0xFAE5, (q15_t)0x7FE5, (q15_t)0xFAB3, (q15_t)0x7FE3, - (q15_t)0xFA80, (q15_t)0x7FE1, (q15_t)0xFA4E, (q15_t)0x7FDF, - (q15_t)0xFA1C, (q15_t)0x7FDD, (q15_t)0xF9EA, (q15_t)0x7FDA, - (q15_t)0xF9B8, (q15_t)0x7FD8, (q15_t)0xF985, (q15_t)0x7FD6, - (q15_t)0xF953, (q15_t)0x7FD3, (q15_t)0xF921, (q15_t)0x7FD0, - (q15_t)0xF8EF, (q15_t)0x7FCE, (q15_t)0xF8BD, (q15_t)0x7FCB, - (q15_t)0xF88A, (q15_t)0x7FC8, (q15_t)0xF858, (q15_t)0x7FC5, - (q15_t)0xF826, (q15_t)0x7FC2, (q15_t)0xF7F4, (q15_t)0x7FBF, - (q15_t)0xF7C2, (q15_t)0x7FBC, (q15_t)0xF790, (q15_t)0x7FB8, - (q15_t)0xF75D, (q15_t)0x7FB5, (q15_t)0xF72B, (q15_t)0x7FB1, - (q15_t)0xF6F9, (q15_t)0x7FAE, (q15_t)0xF6C7, (q15_t)0x7FAA, - (q15_t)0xF695, (q15_t)0x7FA7, (q15_t)0xF663, (q15_t)0x7FA3, - (q15_t)0xF631, (q15_t)0x7F9F, (q15_t)0xF5FF, (q15_t)0x7F9B, - (q15_t)0xF5CC, (q15_t)0x7F97, (q15_t)0xF59A, (q15_t)0x7F93, - (q15_t)0xF568, (q15_t)0x7F8F, (q15_t)0xF536, (q15_t)0x7F8B, - (q15_t)0xF504, (q15_t)0x7F87, (q15_t)0xF4D2, (q15_t)0x7F82, - (q15_t)0xF4A0, (q15_t)0x7F7E, (q15_t)0xF46E, (q15_t)0x7F79, - (q15_t)0xF43C, (q15_t)0x7F75, (q15_t)0xF40A, (q15_t)0x7F70, - (q15_t)0xF3D8, (q15_t)0x7F6B, (q15_t)0xF3A6, (q15_t)0x7F67, - (q15_t)0xF374, (q15_t)0x7F62, (q15_t)0xF342, (q15_t)0x7F5D, - (q15_t)0xF310, (q15_t)0x7F58, (q15_t)0xF2DE, (q15_t)0x7F53, - (q15_t)0xF2AC, (q15_t)0x7F4D, (q15_t)0xF27A, (q15_t)0x7F48, - (q15_t)0xF248, (q15_t)0x7F43, (q15_t)0xF216, (q15_t)0x7F3D, - (q15_t)0xF1E4, (q15_t)0x7F38, (q15_t)0xF1B2, (q15_t)0x7F32, - (q15_t)0xF180, (q15_t)0x7F2D, (q15_t)0xF14E, (q15_t)0x7F27, - (q15_t)0xF11C, (q15_t)0x7F21, (q15_t)0xF0EA, (q15_t)0x7F1B, - (q15_t)0xF0B8, (q15_t)0x7F15, (q15_t)0xF086, (q15_t)0x7F0F, - (q15_t)0xF054, (q15_t)0x7F09, (q15_t)0xF022, (q15_t)0x7F03, - (q15_t)0xEFF1, (q15_t)0x7EFD, (q15_t)0xEFBF, (q15_t)0x7EF6, - (q15_t)0xEF8D, (q15_t)0x7EF0, (q15_t)0xEF5B, (q15_t)0x7EE9, - (q15_t)0xEF29, (q15_t)0x7EE3, (q15_t)0xEEF7, (q15_t)0x7EDC, - (q15_t)0xEEC6, (q15_t)0x7ED5, (q15_t)0xEE94, (q15_t)0x7ECF, - (q15_t)0xEE62, (q15_t)0x7EC8, (q15_t)0xEE30, (q15_t)0x7EC1, - (q15_t)0xEDFE, (q15_t)0x7EBA, (q15_t)0xEDCD, (q15_t)0x7EB3, - (q15_t)0xED9B, (q15_t)0x7EAB, (q15_t)0xED69, (q15_t)0x7EA4, - (q15_t)0xED37, (q15_t)0x7E9D, (q15_t)0xED06, (q15_t)0x7E95, - (q15_t)0xECD4, (q15_t)0x7E8E, (q15_t)0xECA2, (q15_t)0x7E86, - (q15_t)0xEC71, (q15_t)0x7E7F, (q15_t)0xEC3F, (q15_t)0x7E77, - (q15_t)0xEC0D, (q15_t)0x7E6F, (q15_t)0xEBDC, (q15_t)0x7E67, - (q15_t)0xEBAA, (q15_t)0x7E5F, (q15_t)0xEB78, (q15_t)0x7E57, - (q15_t)0xEB47, (q15_t)0x7E4F, (q15_t)0xEB15, (q15_t)0x7E47, - (q15_t)0xEAE4, (q15_t)0x7E3F, (q15_t)0xEAB2, (q15_t)0x7E37, - (q15_t)0xEA80, (q15_t)0x7E2E, (q15_t)0xEA4F, (q15_t)0x7E26, - (q15_t)0xEA1D, (q15_t)0x7E1D, (q15_t)0xE9EC, (q15_t)0x7E14, - (q15_t)0xE9BA, (q15_t)0x7E0C, (q15_t)0xE989, (q15_t)0x7E03, - (q15_t)0xE957, (q15_t)0x7DFA, (q15_t)0xE926, (q15_t)0x7DF1, - (q15_t)0xE8F5, (q15_t)0x7DE8, (q15_t)0xE8C3, (q15_t)0x7DDF, - (q15_t)0xE892, (q15_t)0x7DD6, (q15_t)0xE860, (q15_t)0x7DCD, - (q15_t)0xE82F, (q15_t)0x7DC3, (q15_t)0xE7FD, (q15_t)0x7DBA, - (q15_t)0xE7CC, (q15_t)0x7DB0, (q15_t)0xE79B, (q15_t)0x7DA7, - (q15_t)0xE769, (q15_t)0x7D9D, (q15_t)0xE738, (q15_t)0x7D94, - (q15_t)0xE707, (q15_t)0x7D8A, (q15_t)0xE6D5, (q15_t)0x7D80, - (q15_t)0xE6A4, (q15_t)0x7D76, (q15_t)0xE673, (q15_t)0x7D6C, - (q15_t)0xE642, (q15_t)0x7D62, (q15_t)0xE610, (q15_t)0x7D58, - (q15_t)0xE5DF, (q15_t)0x7D4E, (q15_t)0xE5AE, (q15_t)0x7D43, - (q15_t)0xE57D, (q15_t)0x7D39, (q15_t)0xE54C, (q15_t)0x7D2F, - (q15_t)0xE51B, (q15_t)0x7D24, (q15_t)0xE4E9, (q15_t)0x7D19, - (q15_t)0xE4B8, (q15_t)0x7D0F, (q15_t)0xE487, (q15_t)0x7D04, - (q15_t)0xE456, (q15_t)0x7CF9, (q15_t)0xE425, (q15_t)0x7CEE, - (q15_t)0xE3F4, (q15_t)0x7CE3, (q15_t)0xE3C3, (q15_t)0x7CD8, - (q15_t)0xE392, (q15_t)0x7CCD, (q15_t)0xE361, (q15_t)0x7CC2, - (q15_t)0xE330, (q15_t)0x7CB7, (q15_t)0xE2FF, (q15_t)0x7CAB, - (q15_t)0xE2CE, (q15_t)0x7CA0, (q15_t)0xE29D, (q15_t)0x7C94, - (q15_t)0xE26C, (q15_t)0x7C89, (q15_t)0xE23B, (q15_t)0x7C7D, - (q15_t)0xE20A, (q15_t)0x7C71, (q15_t)0xE1DA, (q15_t)0x7C66, - (q15_t)0xE1A9, (q15_t)0x7C5A, (q15_t)0xE178, (q15_t)0x7C4E, - (q15_t)0xE147, (q15_t)0x7C42, (q15_t)0xE116, (q15_t)0x7C36, - (q15_t)0xE0E6, (q15_t)0x7C29, (q15_t)0xE0B5, (q15_t)0x7C1D, - (q15_t)0xE084, (q15_t)0x7C11, (q15_t)0xE053, (q15_t)0x7C05, - (q15_t)0xE023, (q15_t)0x7BF8, (q15_t)0xDFF2, (q15_t)0x7BEB, - (q15_t)0xDFC1, (q15_t)0x7BDF, (q15_t)0xDF91, (q15_t)0x7BD2, - (q15_t)0xDF60, (q15_t)0x7BC5, (q15_t)0xDF2F, (q15_t)0x7BB9, - (q15_t)0xDEFF, (q15_t)0x7BAC, (q15_t)0xDECE, (q15_t)0x7B9F, - (q15_t)0xDE9E, (q15_t)0x7B92, (q15_t)0xDE6D, (q15_t)0x7B84, - (q15_t)0xDE3D, (q15_t)0x7B77, (q15_t)0xDE0C, (q15_t)0x7B6A, - (q15_t)0xDDDC, (q15_t)0x7B5D, (q15_t)0xDDAB, (q15_t)0x7B4F, - (q15_t)0xDD7B, (q15_t)0x7B42, (q15_t)0xDD4B, (q15_t)0x7B34, - (q15_t)0xDD1A, (q15_t)0x7B26, (q15_t)0xDCEA, (q15_t)0x7B19, - (q15_t)0xDCBA, (q15_t)0x7B0B, (q15_t)0xDC89, (q15_t)0x7AFD, - (q15_t)0xDC59, (q15_t)0x7AEF, (q15_t)0xDC29, (q15_t)0x7AE1, - (q15_t)0xDBF8, (q15_t)0x7AD3, (q15_t)0xDBC8, (q15_t)0x7AC5, - (q15_t)0xDB98, (q15_t)0x7AB6, (q15_t)0xDB68, (q15_t)0x7AA8, - (q15_t)0xDB38, (q15_t)0x7A9A, (q15_t)0xDB08, (q15_t)0x7A8B, - (q15_t)0xDAD7, (q15_t)0x7A7D, (q15_t)0xDAA7, (q15_t)0x7A6E, - (q15_t)0xDA77, (q15_t)0x7A5F, (q15_t)0xDA47, (q15_t)0x7A50, - (q15_t)0xDA17, (q15_t)0x7A42, (q15_t)0xD9E7, (q15_t)0x7A33, - (q15_t)0xD9B7, (q15_t)0x7A24, (q15_t)0xD987, (q15_t)0x7A15, - (q15_t)0xD957, (q15_t)0x7A05, (q15_t)0xD927, (q15_t)0x79F6, - (q15_t)0xD8F8, (q15_t)0x79E7, (q15_t)0xD8C8, (q15_t)0x79D8, - (q15_t)0xD898, (q15_t)0x79C8, (q15_t)0xD868, (q15_t)0x79B9, - (q15_t)0xD838, (q15_t)0x79A9, (q15_t)0xD809, (q15_t)0x7999, - (q15_t)0xD7D9, (q15_t)0x798A, (q15_t)0xD7A9, (q15_t)0x797A, - (q15_t)0xD779, (q15_t)0x796A, (q15_t)0xD74A, (q15_t)0x795A, - (q15_t)0xD71A, (q15_t)0x794A, (q15_t)0xD6EA, (q15_t)0x793A, - (q15_t)0xD6BB, (q15_t)0x792A, (q15_t)0xD68B, (q15_t)0x7919, - (q15_t)0xD65C, (q15_t)0x7909, (q15_t)0xD62C, (q15_t)0x78F9, - (q15_t)0xD5FD, (q15_t)0x78E8, (q15_t)0xD5CD, (q15_t)0x78D8, - (q15_t)0xD59E, (q15_t)0x78C7, (q15_t)0xD56E, (q15_t)0x78B6, - (q15_t)0xD53F, (q15_t)0x78A6, (q15_t)0xD510, (q15_t)0x7895, - (q15_t)0xD4E0, (q15_t)0x7884, (q15_t)0xD4B1, (q15_t)0x7873, - (q15_t)0xD482, (q15_t)0x7862, (q15_t)0xD452, (q15_t)0x7851, - (q15_t)0xD423, (q15_t)0x7840, (q15_t)0xD3F4, (q15_t)0x782E, - (q15_t)0xD3C5, (q15_t)0x781D, (q15_t)0xD396, (q15_t)0x780C, - (q15_t)0xD367, (q15_t)0x77FA, (q15_t)0xD337, (q15_t)0x77E9, - (q15_t)0xD308, (q15_t)0x77D7, (q15_t)0xD2D9, (q15_t)0x77C5, - (q15_t)0xD2AA, (q15_t)0x77B4, (q15_t)0xD27B, (q15_t)0x77A2, - (q15_t)0xD24C, (q15_t)0x7790, (q15_t)0xD21D, (q15_t)0x777E, - (q15_t)0xD1EE, (q15_t)0x776C, (q15_t)0xD1C0, (q15_t)0x775A, - (q15_t)0xD191, (q15_t)0x7747, (q15_t)0xD162, (q15_t)0x7735, - (q15_t)0xD133, (q15_t)0x7723, (q15_t)0xD104, (q15_t)0x7710, - (q15_t)0xD0D6, (q15_t)0x76FE, (q15_t)0xD0A7, (q15_t)0x76EB, - (q15_t)0xD078, (q15_t)0x76D9, (q15_t)0xD04A, (q15_t)0x76C6, - (q15_t)0xD01B, (q15_t)0x76B3, (q15_t)0xCFEC, (q15_t)0x76A0, - (q15_t)0xCFBE, (q15_t)0x768E, (q15_t)0xCF8F, (q15_t)0x767B, - (q15_t)0xCF61, (q15_t)0x7668, (q15_t)0xCF32, (q15_t)0x7654, - (q15_t)0xCF04, (q15_t)0x7641, (q15_t)0xCED5, (q15_t)0x762E, - (q15_t)0xCEA7, (q15_t)0x761B, (q15_t)0xCE79, (q15_t)0x7607, - (q15_t)0xCE4A, (q15_t)0x75F4, (q15_t)0xCE1C, (q15_t)0x75E0, - (q15_t)0xCDEE, (q15_t)0x75CC, (q15_t)0xCDBF, (q15_t)0x75B9, - (q15_t)0xCD91, (q15_t)0x75A5, (q15_t)0xCD63, (q15_t)0x7591, - (q15_t)0xCD35, (q15_t)0x757D, (q15_t)0xCD07, (q15_t)0x7569, - (q15_t)0xCCD9, (q15_t)0x7555, (q15_t)0xCCAB, (q15_t)0x7541, - (q15_t)0xCC7D, (q15_t)0x752D, (q15_t)0xCC4F, (q15_t)0x7519, - (q15_t)0xCC21, (q15_t)0x7504, (q15_t)0xCBF3, (q15_t)0x74F0, - (q15_t)0xCBC5, (q15_t)0x74DB, (q15_t)0xCB97, (q15_t)0x74C7, - (q15_t)0xCB69, (q15_t)0x74B2, (q15_t)0xCB3B, (q15_t)0x749E, - (q15_t)0xCB0D, (q15_t)0x7489, (q15_t)0xCAE0, (q15_t)0x7474, - (q15_t)0xCAB2, (q15_t)0x745F, (q15_t)0xCA84, (q15_t)0x744A, - (q15_t)0xCA57, (q15_t)0x7435, (q15_t)0xCA29, (q15_t)0x7420, - (q15_t)0xC9FB, (q15_t)0x740B, (q15_t)0xC9CE, (q15_t)0x73F6, - (q15_t)0xC9A0, (q15_t)0x73E0, (q15_t)0xC973, (q15_t)0x73CB, - (q15_t)0xC945, (q15_t)0x73B5, (q15_t)0xC918, (q15_t)0x73A0, - (q15_t)0xC8EB, (q15_t)0x738A, (q15_t)0xC8BD, (q15_t)0x7375, - (q15_t)0xC890, (q15_t)0x735F, (q15_t)0xC863, (q15_t)0x7349, - (q15_t)0xC835, (q15_t)0x7333, (q15_t)0xC808, (q15_t)0x731D, - (q15_t)0xC7DB, (q15_t)0x7307, (q15_t)0xC7AE, (q15_t)0x72F1, - (q15_t)0xC781, (q15_t)0x72DB, (q15_t)0xC754, (q15_t)0x72C5, - (q15_t)0xC727, (q15_t)0x72AF, (q15_t)0xC6F9, (q15_t)0x7298, - (q15_t)0xC6CD, (q15_t)0x7282, (q15_t)0xC6A0, (q15_t)0x726B, - (q15_t)0xC673, (q15_t)0x7255, (q15_t)0xC646, (q15_t)0x723E, - (q15_t)0xC619, (q15_t)0x7227, (q15_t)0xC5EC, (q15_t)0x7211, - (q15_t)0xC5BF, (q15_t)0x71FA, (q15_t)0xC593, (q15_t)0x71E3, - (q15_t)0xC566, (q15_t)0x71CC, (q15_t)0xC539, (q15_t)0x71B5, - (q15_t)0xC50D, (q15_t)0x719E, (q15_t)0xC4E0, (q15_t)0x7186, - (q15_t)0xC4B3, (q15_t)0x716F, (q15_t)0xC487, (q15_t)0x7158, - (q15_t)0xC45A, (q15_t)0x7141, (q15_t)0xC42E, (q15_t)0x7129, - (q15_t)0xC402, (q15_t)0x7112, (q15_t)0xC3D5, (q15_t)0x70FA, - (q15_t)0xC3A9, (q15_t)0x70E2, (q15_t)0xC37C, (q15_t)0x70CB, - (q15_t)0xC350, (q15_t)0x70B3, (q15_t)0xC324, (q15_t)0x709B, - (q15_t)0xC2F8, (q15_t)0x7083, (q15_t)0xC2CC, (q15_t)0x706B, - (q15_t)0xC29F, (q15_t)0x7053, (q15_t)0xC273, (q15_t)0x703B, - (q15_t)0xC247, (q15_t)0x7023, (q15_t)0xC21B, (q15_t)0x700A, - (q15_t)0xC1EF, (q15_t)0x6FF2, (q15_t)0xC1C3, (q15_t)0x6FDA, - (q15_t)0xC197, (q15_t)0x6FC1, (q15_t)0xC16C, (q15_t)0x6FA9, - (q15_t)0xC140, (q15_t)0x6F90, (q15_t)0xC114, (q15_t)0x6F77, - (q15_t)0xC0E8, (q15_t)0x6F5F, (q15_t)0xC0BC, (q15_t)0x6F46, - (q15_t)0xC091, (q15_t)0x6F2D, (q15_t)0xC065, (q15_t)0x6F14, - (q15_t)0xC03A, (q15_t)0x6EFB, (q15_t)0xC00E, (q15_t)0x6EE2, - (q15_t)0xBFE2, (q15_t)0x6EC9, (q15_t)0xBFB7, (q15_t)0x6EAF, - (q15_t)0xBF8C, (q15_t)0x6E96, (q15_t)0xBF60, (q15_t)0x6E7D, - (q15_t)0xBF35, (q15_t)0x6E63, (q15_t)0xBF09, (q15_t)0x6E4A, - (q15_t)0xBEDE, (q15_t)0x6E30, (q15_t)0xBEB3, (q15_t)0x6E17, - (q15_t)0xBE88, (q15_t)0x6DFD, (q15_t)0xBE5D, (q15_t)0x6DE3, - (q15_t)0xBE31, (q15_t)0x6DCA, (q15_t)0xBE06, (q15_t)0x6DB0, - (q15_t)0xBDDB, (q15_t)0x6D96, (q15_t)0xBDB0, (q15_t)0x6D7C, - (q15_t)0xBD85, (q15_t)0x6D62, (q15_t)0xBD5A, (q15_t)0x6D48, - (q15_t)0xBD2F, (q15_t)0x6D2D, (q15_t)0xBD05, (q15_t)0x6D13, - (q15_t)0xBCDA, (q15_t)0x6CF9, (q15_t)0xBCAF, (q15_t)0x6CDE, - (q15_t)0xBC84, (q15_t)0x6CC4, (q15_t)0xBC5A, (q15_t)0x6CA9, - (q15_t)0xBC2F, (q15_t)0x6C8F, (q15_t)0xBC04, (q15_t)0x6C74, - (q15_t)0xBBDA, (q15_t)0x6C59, (q15_t)0xBBAF, (q15_t)0x6C3F, - (q15_t)0xBB85, (q15_t)0x6C24, (q15_t)0xBB5A, (q15_t)0x6C09, - (q15_t)0xBB30, (q15_t)0x6BEE, (q15_t)0xBB05, (q15_t)0x6BD3, - (q15_t)0xBADB, (q15_t)0x6BB8, (q15_t)0xBAB1, (q15_t)0x6B9C, - (q15_t)0xBA87, (q15_t)0x6B81, (q15_t)0xBA5C, (q15_t)0x6B66, - (q15_t)0xBA32, (q15_t)0x6B4A, (q15_t)0xBA08, (q15_t)0x6B2F, - (q15_t)0xB9DE, (q15_t)0x6B13, (q15_t)0xB9B4, (q15_t)0x6AF8, - (q15_t)0xB98A, (q15_t)0x6ADC, (q15_t)0xB960, (q15_t)0x6AC1, - (q15_t)0xB936, (q15_t)0x6AA5, (q15_t)0xB90C, (q15_t)0x6A89, - (q15_t)0xB8E3, (q15_t)0x6A6D, (q15_t)0xB8B9, (q15_t)0x6A51, - (q15_t)0xB88F, (q15_t)0x6A35, (q15_t)0xB865, (q15_t)0x6A19, - (q15_t)0xB83C, (q15_t)0x69FD, (q15_t)0xB812, (q15_t)0x69E1, - (q15_t)0xB7E9, (q15_t)0x69C4, (q15_t)0xB7BF, (q15_t)0x69A8, - (q15_t)0xB796, (q15_t)0x698C, (q15_t)0xB76C, (q15_t)0x696F, - (q15_t)0xB743, (q15_t)0x6953, (q15_t)0xB719, (q15_t)0x6936, - (q15_t)0xB6F0, (q15_t)0x6919, (q15_t)0xB6C7, (q15_t)0x68FD, - (q15_t)0xB69E, (q15_t)0x68E0, (q15_t)0xB675, (q15_t)0x68C3, - (q15_t)0xB64B, (q15_t)0x68A6, (q15_t)0xB622, (q15_t)0x6889, - (q15_t)0xB5F9, (q15_t)0x686C, (q15_t)0xB5D0, (q15_t)0x684F, - (q15_t)0xB5A7, (q15_t)0x6832, (q15_t)0xB57E, (q15_t)0x6815, - (q15_t)0xB556, (q15_t)0x67F7, (q15_t)0xB52D, (q15_t)0x67DA, - (q15_t)0xB504, (q15_t)0x67BD, (q15_t)0xB4DB, (q15_t)0x679F, - (q15_t)0xB4B3, (q15_t)0x6782, (q15_t)0xB48A, (q15_t)0x6764, - (q15_t)0xB461, (q15_t)0x6746, (q15_t)0xB439, (q15_t)0x6729, - (q15_t)0xB410, (q15_t)0x670B, (q15_t)0xB3E8, (q15_t)0x66ED, - (q15_t)0xB3C0, (q15_t)0x66CF, (q15_t)0xB397, (q15_t)0x66B1, - (q15_t)0xB36F, (q15_t)0x6693, (q15_t)0xB347, (q15_t)0x6675, - (q15_t)0xB31E, (q15_t)0x6657, (q15_t)0xB2F6, (q15_t)0x6639, - (q15_t)0xB2CE, (q15_t)0x661A, (q15_t)0xB2A6, (q15_t)0x65FC, - (q15_t)0xB27E, (q15_t)0x65DD, (q15_t)0xB256, (q15_t)0x65BF, - (q15_t)0xB22E, (q15_t)0x65A0, (q15_t)0xB206, (q15_t)0x6582, - (q15_t)0xB1DE, (q15_t)0x6563, (q15_t)0xB1B7, (q15_t)0x6545, - (q15_t)0xB18F, (q15_t)0x6526, (q15_t)0xB167, (q15_t)0x6507, - (q15_t)0xB140, (q15_t)0x64E8, (q15_t)0xB118, (q15_t)0x64C9, - (q15_t)0xB0F0, (q15_t)0x64AA, (q15_t)0xB0C9, (q15_t)0x648B, - (q15_t)0xB0A1, (q15_t)0x646C, (q15_t)0xB07A, (q15_t)0x644D, - (q15_t)0xB053, (q15_t)0x642D, (q15_t)0xB02B, (q15_t)0x640E, - (q15_t)0xB004, (q15_t)0x63EF, (q15_t)0xAFDD, (q15_t)0x63CF, - (q15_t)0xAFB6, (q15_t)0x63B0, (q15_t)0xAF8F, (q15_t)0x6390, - (q15_t)0xAF68, (q15_t)0x6371, (q15_t)0xAF40, (q15_t)0x6351, - (q15_t)0xAF1A, (q15_t)0x6331, (q15_t)0xAEF3, (q15_t)0x6311, - (q15_t)0xAECC, (q15_t)0x62F2, (q15_t)0xAEA5, (q15_t)0x62D2, - (q15_t)0xAE7E, (q15_t)0x62B2, (q15_t)0xAE57, (q15_t)0x6292, - (q15_t)0xAE31, (q15_t)0x6271, (q15_t)0xAE0A, (q15_t)0x6251, - (q15_t)0xADE3, (q15_t)0x6231, (q15_t)0xADBD, (q15_t)0x6211, - (q15_t)0xAD96, (q15_t)0x61F1, (q15_t)0xAD70, (q15_t)0x61D0, - (q15_t)0xAD4A, (q15_t)0x61B0, (q15_t)0xAD23, (q15_t)0x618F, - (q15_t)0xACFD, (q15_t)0x616F, (q15_t)0xACD7, (q15_t)0x614E, - (q15_t)0xACB1, (q15_t)0x612D, (q15_t)0xAC8A, (q15_t)0x610D, - (q15_t)0xAC64, (q15_t)0x60EC, (q15_t)0xAC3E, (q15_t)0x60CB, - (q15_t)0xAC18, (q15_t)0x60AA, (q15_t)0xABF2, (q15_t)0x6089, - (q15_t)0xABCC, (q15_t)0x6068, (q15_t)0xABA7, (q15_t)0x6047, - (q15_t)0xAB81, (q15_t)0x6026, (q15_t)0xAB5B, (q15_t)0x6004, - (q15_t)0xAB35, (q15_t)0x5FE3, (q15_t)0xAB10, (q15_t)0x5FC2, - (q15_t)0xAAEA, (q15_t)0x5FA0, (q15_t)0xAAC5, (q15_t)0x5F7F, - (q15_t)0xAA9F, (q15_t)0x5F5E, (q15_t)0xAA7A, (q15_t)0x5F3C, - (q15_t)0xAA54, (q15_t)0x5F1A, (q15_t)0xAA2F, (q15_t)0x5EF9, - (q15_t)0xAA0A, (q15_t)0x5ED7, (q15_t)0xA9E5, (q15_t)0x5EB5, - (q15_t)0xA9BF, (q15_t)0x5E93, (q15_t)0xA99A, (q15_t)0x5E71, - (q15_t)0xA975, (q15_t)0x5E50, (q15_t)0xA950, (q15_t)0x5E2D, - (q15_t)0xA92B, (q15_t)0x5E0B, (q15_t)0xA906, (q15_t)0x5DE9, - (q15_t)0xA8E2, (q15_t)0x5DC7, (q15_t)0xA8BD, (q15_t)0x5DA5, - (q15_t)0xA898, (q15_t)0x5D83, (q15_t)0xA873, (q15_t)0x5D60, - (q15_t)0xA84F, (q15_t)0x5D3E, (q15_t)0xA82A, (q15_t)0x5D1B, - (q15_t)0xA806, (q15_t)0x5CF9, (q15_t)0xA7E1, (q15_t)0x5CD6, - (q15_t)0xA7BD, (q15_t)0x5CB4, (q15_t)0xA798, (q15_t)0x5C91, - (q15_t)0xA774, (q15_t)0x5C6E, (q15_t)0xA750, (q15_t)0x5C4B, - (q15_t)0xA72B, (q15_t)0x5C29, (q15_t)0xA707, (q15_t)0x5C06, - (q15_t)0xA6E3, (q15_t)0x5BE3, (q15_t)0xA6BF, (q15_t)0x5BC0, - (q15_t)0xA69B, (q15_t)0x5B9D, (q15_t)0xA677, (q15_t)0x5B79, - (q15_t)0xA653, (q15_t)0x5B56, (q15_t)0xA62F, (q15_t)0x5B33, - (q15_t)0xA60C, (q15_t)0x5B10, (q15_t)0xA5E8, (q15_t)0x5AEC, - (q15_t)0xA5C4, (q15_t)0x5AC9, (q15_t)0xA5A1, (q15_t)0x5AA5, - (q15_t)0xA57D, (q15_t)0x5A82, (q15_t)0xA55A, (q15_t)0x5A5E, - (q15_t)0xA536, (q15_t)0x5A3B, (q15_t)0xA513, (q15_t)0x5A17, - (q15_t)0xA4EF, (q15_t)0x59F3, (q15_t)0xA4CC, (q15_t)0x59D0, - (q15_t)0xA4A9, (q15_t)0x59AC, (q15_t)0xA486, (q15_t)0x5988, - (q15_t)0xA462, (q15_t)0x5964, (q15_t)0xA43F, (q15_t)0x5940, - (q15_t)0xA41C, (q15_t)0x591C, (q15_t)0xA3F9, (q15_t)0x58F8, - (q15_t)0xA3D6, (q15_t)0x58D4, (q15_t)0xA3B4, (q15_t)0x58AF, - (q15_t)0xA391, (q15_t)0x588B, (q15_t)0xA36E, (q15_t)0x5867, - (q15_t)0xA34B, (q15_t)0x5842, (q15_t)0xA329, (q15_t)0x581E, - (q15_t)0xA306, (q15_t)0x57F9, (q15_t)0xA2E4, (q15_t)0x57D5, - (q15_t)0xA2C1, (q15_t)0x57B0, (q15_t)0xA29F, (q15_t)0x578C, - (q15_t)0xA27C, (q15_t)0x5767, (q15_t)0xA25A, (q15_t)0x5742, - (q15_t)0xA238, (q15_t)0x571D, (q15_t)0xA216, (q15_t)0x56F9, - (q15_t)0xA1F4, (q15_t)0x56D4, (q15_t)0xA1D2, (q15_t)0x56AF, - (q15_t)0xA1AF, (q15_t)0x568A, (q15_t)0xA18E, (q15_t)0x5665, - (q15_t)0xA16C, (q15_t)0x5640, (q15_t)0xA14A, (q15_t)0x561A, - (q15_t)0xA128, (q15_t)0x55F5, (q15_t)0xA106, (q15_t)0x55D0, - (q15_t)0xA0E5, (q15_t)0x55AB, (q15_t)0xA0C3, (q15_t)0x5585, - (q15_t)0xA0A1, (q15_t)0x5560, (q15_t)0xA080, (q15_t)0x553A, - (q15_t)0xA05F, (q15_t)0x5515, (q15_t)0xA03D, (q15_t)0x54EF, - (q15_t)0xA01C, (q15_t)0x54CA, (q15_t)0x9FFB, (q15_t)0x54A4, - (q15_t)0x9FD9, (q15_t)0x547E, (q15_t)0x9FB8, (q15_t)0x5458, - (q15_t)0x9F97, (q15_t)0x5433, (q15_t)0x9F76, (q15_t)0x540D, - (q15_t)0x9F55, (q15_t)0x53E7, (q15_t)0x9F34, (q15_t)0x53C1, - (q15_t)0x9F13, (q15_t)0x539B, (q15_t)0x9EF2, (q15_t)0x5375, - (q15_t)0x9ED2, (q15_t)0x534E, (q15_t)0x9EB1, (q15_t)0x5328, - (q15_t)0x9E90, (q15_t)0x5302, (q15_t)0x9E70, (q15_t)0x52DC, - (q15_t)0x9E4F, (q15_t)0x52B5, (q15_t)0x9E2F, (q15_t)0x528F, - (q15_t)0x9E0E, (q15_t)0x5269, (q15_t)0x9DEE, (q15_t)0x5242, - (q15_t)0x9DCE, (q15_t)0x521C, (q15_t)0x9DAE, (q15_t)0x51F5, - (q15_t)0x9D8E, (q15_t)0x51CE, (q15_t)0x9D6D, (q15_t)0x51A8, - (q15_t)0x9D4D, (q15_t)0x5181, (q15_t)0x9D2D, (q15_t)0x515A, - (q15_t)0x9D0D, (q15_t)0x5133, (q15_t)0x9CEE, (q15_t)0x510C, - (q15_t)0x9CCE, (q15_t)0x50E5, (q15_t)0x9CAE, (q15_t)0x50BF, - (q15_t)0x9C8E, (q15_t)0x5097, (q15_t)0x9C6F, (q15_t)0x5070, - (q15_t)0x9C4F, (q15_t)0x5049, (q15_t)0x9C30, (q15_t)0x5022, - (q15_t)0x9C10, (q15_t)0x4FFB, (q15_t)0x9BF1, (q15_t)0x4FD4, - (q15_t)0x9BD2, (q15_t)0x4FAC, (q15_t)0x9BB2, (q15_t)0x4F85, - (q15_t)0x9B93, (q15_t)0x4F5E, (q15_t)0x9B74, (q15_t)0x4F36, - (q15_t)0x9B55, (q15_t)0x4F0F, (q15_t)0x9B36, (q15_t)0x4EE7, - (q15_t)0x9B17, (q15_t)0x4EBF, (q15_t)0x9AF8, (q15_t)0x4E98, - (q15_t)0x9AD9, (q15_t)0x4E70, (q15_t)0x9ABA, (q15_t)0x4E48, - (q15_t)0x9A9C, (q15_t)0x4E21, (q15_t)0x9A7D, (q15_t)0x4DF9, - (q15_t)0x9A5F, (q15_t)0x4DD1, (q15_t)0x9A40, (q15_t)0x4DA9, - (q15_t)0x9A22, (q15_t)0x4D81, (q15_t)0x9A03, (q15_t)0x4D59, - (q15_t)0x99E5, (q15_t)0x4D31, (q15_t)0x99C6, (q15_t)0x4D09, - (q15_t)0x99A8, (q15_t)0x4CE1, (q15_t)0x998A, (q15_t)0x4CB8, - (q15_t)0x996C, (q15_t)0x4C90, (q15_t)0x994E, (q15_t)0x4C68, - (q15_t)0x9930, (q15_t)0x4C3F, (q15_t)0x9912, (q15_t)0x4C17, - (q15_t)0x98F4, (q15_t)0x4BEF, (q15_t)0x98D6, (q15_t)0x4BC6, - (q15_t)0x98B9, (q15_t)0x4B9E, (q15_t)0x989B, (q15_t)0x4B75, - (q15_t)0x987D, (q15_t)0x4B4C, (q15_t)0x9860, (q15_t)0x4B24, - (q15_t)0x9842, (q15_t)0x4AFB, (q15_t)0x9825, (q15_t)0x4AD2, - (q15_t)0x9808, (q15_t)0x4AA9, (q15_t)0x97EA, (q15_t)0x4A81, - (q15_t)0x97CD, (q15_t)0x4A58, (q15_t)0x97B0, (q15_t)0x4A2F, - (q15_t)0x9793, (q15_t)0x4A06, (q15_t)0x9776, (q15_t)0x49DD, - (q15_t)0x9759, (q15_t)0x49B4, (q15_t)0x973C, (q15_t)0x498A, - (q15_t)0x971F, (q15_t)0x4961, (q15_t)0x9702, (q15_t)0x4938, - (q15_t)0x96E6, (q15_t)0x490F, (q15_t)0x96C9, (q15_t)0x48E6, - (q15_t)0x96AC, (q15_t)0x48BC, (q15_t)0x9690, (q15_t)0x4893, - (q15_t)0x9673, (q15_t)0x4869, (q15_t)0x9657, (q15_t)0x4840, - (q15_t)0x963B, (q15_t)0x4816, (q15_t)0x961E, (q15_t)0x47ED, - (q15_t)0x9602, (q15_t)0x47C3, (q15_t)0x95E6, (q15_t)0x479A, - (q15_t)0x95CA, (q15_t)0x4770, (q15_t)0x95AE, (q15_t)0x4746, - (q15_t)0x9592, (q15_t)0x471C, (q15_t)0x9576, (q15_t)0x46F3, - (q15_t)0x955A, (q15_t)0x46C9, (q15_t)0x953E, (q15_t)0x469F, - (q15_t)0x9523, (q15_t)0x4675, (q15_t)0x9507, (q15_t)0x464B, - (q15_t)0x94EC, (q15_t)0x4621, (q15_t)0x94D0, (q15_t)0x45F7, - (q15_t)0x94B5, (q15_t)0x45CD, (q15_t)0x9499, (q15_t)0x45A3, - (q15_t)0x947E, (q15_t)0x4578, (q15_t)0x9463, (q15_t)0x454E, - (q15_t)0x9447, (q15_t)0x4524, (q15_t)0x942C, (q15_t)0x44FA, - (q15_t)0x9411, (q15_t)0x44CF, (q15_t)0x93F6, (q15_t)0x44A5, - (q15_t)0x93DB, (q15_t)0x447A, (q15_t)0x93C0, (q15_t)0x4450, - (q15_t)0x93A6, (q15_t)0x4425, (q15_t)0x938B, (q15_t)0x43FB, - (q15_t)0x9370, (q15_t)0x43D0, (q15_t)0x9356, (q15_t)0x43A5, - (q15_t)0x933B, (q15_t)0x437B, (q15_t)0x9321, (q15_t)0x4350, - (q15_t)0x9306, (q15_t)0x4325, (q15_t)0x92EC, (q15_t)0x42FA, - (q15_t)0x92D2, (q15_t)0x42D0, (q15_t)0x92B7, (q15_t)0x42A5, - (q15_t)0x929D, (q15_t)0x427A, (q15_t)0x9283, (q15_t)0x424F, - (q15_t)0x9269, (q15_t)0x4224, (q15_t)0x924F, (q15_t)0x41F9, - (q15_t)0x9235, (q15_t)0x41CE, (q15_t)0x921C, (q15_t)0x41A2, - (q15_t)0x9202, (q15_t)0x4177, (q15_t)0x91E8, (q15_t)0x414C, - (q15_t)0x91CF, (q15_t)0x4121, (q15_t)0x91B5, (q15_t)0x40F6, - (q15_t)0x919C, (q15_t)0x40CA, (q15_t)0x9182, (q15_t)0x409F, - (q15_t)0x9169, (q15_t)0x4073, (q15_t)0x9150, (q15_t)0x4048, - (q15_t)0x9136, (q15_t)0x401D, (q15_t)0x911D, (q15_t)0x3FF1, - (q15_t)0x9104, (q15_t)0x3FC5, (q15_t)0x90EB, (q15_t)0x3F9A, - (q15_t)0x90D2, (q15_t)0x3F6E, (q15_t)0x90B9, (q15_t)0x3F43, - (q15_t)0x90A0, (q15_t)0x3F17, (q15_t)0x9088, (q15_t)0x3EEB, - (q15_t)0x906F, (q15_t)0x3EBF, (q15_t)0x9056, (q15_t)0x3E93, - (q15_t)0x903E, (q15_t)0x3E68, (q15_t)0x9025, (q15_t)0x3E3C, - (q15_t)0x900D, (q15_t)0x3E10, (q15_t)0x8FF5, (q15_t)0x3DE4, - (q15_t)0x8FDC, (q15_t)0x3DB8, (q15_t)0x8FC4, (q15_t)0x3D8C, - (q15_t)0x8FAC, (q15_t)0x3D60, (q15_t)0x8F94, (q15_t)0x3D33, - (q15_t)0x8F7C, (q15_t)0x3D07, (q15_t)0x8F64, (q15_t)0x3CDB, - (q15_t)0x8F4C, (q15_t)0x3CAF, (q15_t)0x8F34, (q15_t)0x3C83, - (q15_t)0x8F1D, (q15_t)0x3C56, (q15_t)0x8F05, (q15_t)0x3C2A, - (q15_t)0x8EED, (q15_t)0x3BFD, (q15_t)0x8ED6, (q15_t)0x3BD1, - (q15_t)0x8EBE, (q15_t)0x3BA5, (q15_t)0x8EA7, (q15_t)0x3B78, - (q15_t)0x8E90, (q15_t)0x3B4C, (q15_t)0x8E79, (q15_t)0x3B1F, - (q15_t)0x8E61, (q15_t)0x3AF2, (q15_t)0x8E4A, (q15_t)0x3AC6, - (q15_t)0x8E33, (q15_t)0x3A99, (q15_t)0x8E1C, (q15_t)0x3A6C, - (q15_t)0x8E05, (q15_t)0x3A40, (q15_t)0x8DEE, (q15_t)0x3A13, - (q15_t)0x8DD8, (q15_t)0x39E6, (q15_t)0x8DC1, (q15_t)0x39B9, - (q15_t)0x8DAA, (q15_t)0x398C, (q15_t)0x8D94, (q15_t)0x395F, - (q15_t)0x8D7D, (q15_t)0x3932, (q15_t)0x8D67, (q15_t)0x3906, - (q15_t)0x8D50, (q15_t)0x38D8, (q15_t)0x8D3A, (q15_t)0x38AB, - (q15_t)0x8D24, (q15_t)0x387E, (q15_t)0x8D0E, (q15_t)0x3851, - (q15_t)0x8CF8, (q15_t)0x3824, (q15_t)0x8CE2, (q15_t)0x37F7, - (q15_t)0x8CCC, (q15_t)0x37CA, (q15_t)0x8CB6, (q15_t)0x379C, - (q15_t)0x8CA0, (q15_t)0x376F, (q15_t)0x8C8A, (q15_t)0x3742, - (q15_t)0x8C75, (q15_t)0x3714, (q15_t)0x8C5F, (q15_t)0x36E7, - (q15_t)0x8C4A, (q15_t)0x36BA, (q15_t)0x8C34, (q15_t)0x368C, - (q15_t)0x8C1F, (q15_t)0x365F, (q15_t)0x8C09, (q15_t)0x3631, - (q15_t)0x8BF4, (q15_t)0x3604, (q15_t)0x8BDF, (q15_t)0x35D6, - (q15_t)0x8BCA, (q15_t)0x35A8, (q15_t)0x8BB5, (q15_t)0x357B, - (q15_t)0x8BA0, (q15_t)0x354D, (q15_t)0x8B8B, (q15_t)0x351F, - (q15_t)0x8B76, (q15_t)0x34F2, (q15_t)0x8B61, (q15_t)0x34C4, - (q15_t)0x8B4D, (q15_t)0x3496, (q15_t)0x8B38, (q15_t)0x3468, - (q15_t)0x8B24, (q15_t)0x343A, (q15_t)0x8B0F, (q15_t)0x340C, - (q15_t)0x8AFB, (q15_t)0x33DE, (q15_t)0x8AE6, (q15_t)0x33B0, - (q15_t)0x8AD2, (q15_t)0x3382, (q15_t)0x8ABE, (q15_t)0x3354, - (q15_t)0x8AAA, (q15_t)0x3326, (q15_t)0x8A96, (q15_t)0x32F8, - (q15_t)0x8A82, (q15_t)0x32CA, (q15_t)0x8A6E, (q15_t)0x329C, - (q15_t)0x8A5A, (q15_t)0x326E, (q15_t)0x8A46, (q15_t)0x3240, - (q15_t)0x8A33, (q15_t)0x3211, (q15_t)0x8A1F, (q15_t)0x31E3, - (q15_t)0x8A0B, (q15_t)0x31B5, (q15_t)0x89F8, (q15_t)0x3186, - (q15_t)0x89E4, (q15_t)0x3158, (q15_t)0x89D1, (q15_t)0x312A, - (q15_t)0x89BE, (q15_t)0x30FB, (q15_t)0x89AB, (q15_t)0x30CD, - (q15_t)0x8997, (q15_t)0x309E, (q15_t)0x8984, (q15_t)0x3070, - (q15_t)0x8971, (q15_t)0x3041, (q15_t)0x895F, (q15_t)0x3013, - (q15_t)0x894C, (q15_t)0x2FE4, (q15_t)0x8939, (q15_t)0x2FB5, - (q15_t)0x8926, (q15_t)0x2F87, (q15_t)0x8914, (q15_t)0x2F58, - (q15_t)0x8901, (q15_t)0x2F29, (q15_t)0x88EF, (q15_t)0x2EFB, - (q15_t)0x88DC, (q15_t)0x2ECC, (q15_t)0x88CA, (q15_t)0x2E9D, - (q15_t)0x88B8, (q15_t)0x2E6E, (q15_t)0x88A5, (q15_t)0x2E3F, - (q15_t)0x8893, (q15_t)0x2E11, (q15_t)0x8881, (q15_t)0x2DE2, - (q15_t)0x886F, (q15_t)0x2DB3, (q15_t)0x885D, (q15_t)0x2D84, - (q15_t)0x884B, (q15_t)0x2D55, (q15_t)0x883A, (q15_t)0x2D26, - (q15_t)0x8828, (q15_t)0x2CF7, (q15_t)0x8816, (q15_t)0x2CC8, - (q15_t)0x8805, (q15_t)0x2C98, (q15_t)0x87F3, (q15_t)0x2C69, - (q15_t)0x87E2, (q15_t)0x2C3A, (q15_t)0x87D1, (q15_t)0x2C0B, - (q15_t)0x87BF, (q15_t)0x2BDC, (q15_t)0x87AE, (q15_t)0x2BAD, - (q15_t)0x879D, (q15_t)0x2B7D, (q15_t)0x878C, (q15_t)0x2B4E, - (q15_t)0x877B, (q15_t)0x2B1F, (q15_t)0x876A, (q15_t)0x2AEF, - (q15_t)0x8759, (q15_t)0x2AC0, (q15_t)0x8749, (q15_t)0x2A91, - (q15_t)0x8738, (q15_t)0x2A61, (q15_t)0x8727, (q15_t)0x2A32, - (q15_t)0x8717, (q15_t)0x2A02, (q15_t)0x8706, (q15_t)0x29D3, - (q15_t)0x86F6, (q15_t)0x29A3, (q15_t)0x86E6, (q15_t)0x2974, - (q15_t)0x86D5, (q15_t)0x2944, (q15_t)0x86C5, (q15_t)0x2915, - (q15_t)0x86B5, (q15_t)0x28E5, (q15_t)0x86A5, (q15_t)0x28B5, - (q15_t)0x8695, (q15_t)0x2886, (q15_t)0x8685, (q15_t)0x2856, - (q15_t)0x8675, (q15_t)0x2826, (q15_t)0x8666, (q15_t)0x27F6, - (q15_t)0x8656, (q15_t)0x27C7, (q15_t)0x8646, (q15_t)0x2797, - (q15_t)0x8637, (q15_t)0x2767, (q15_t)0x8627, (q15_t)0x2737, - (q15_t)0x8618, (q15_t)0x2707, (q15_t)0x8609, (q15_t)0x26D8, - (q15_t)0x85FA, (q15_t)0x26A8, (q15_t)0x85EA, (q15_t)0x2678, - (q15_t)0x85DB, (q15_t)0x2648, (q15_t)0x85CC, (q15_t)0x2618, - (q15_t)0x85BD, (q15_t)0x25E8, (q15_t)0x85AF, (q15_t)0x25B8, - (q15_t)0x85A0, (q15_t)0x2588, (q15_t)0x8591, (q15_t)0x2558, - (q15_t)0x8582, (q15_t)0x2528, (q15_t)0x8574, (q15_t)0x24F7, - (q15_t)0x8565, (q15_t)0x24C7, (q15_t)0x8557, (q15_t)0x2497, - (q15_t)0x8549, (q15_t)0x2467, (q15_t)0x853A, (q15_t)0x2437, - (q15_t)0x852C, (q15_t)0x2407, (q15_t)0x851E, (q15_t)0x23D6, - (q15_t)0x8510, (q15_t)0x23A6, (q15_t)0x8502, (q15_t)0x2376, - (q15_t)0x84F4, (q15_t)0x2345, (q15_t)0x84E6, (q15_t)0x2315, - (q15_t)0x84D9, (q15_t)0x22E5, (q15_t)0x84CB, (q15_t)0x22B4, - (q15_t)0x84BD, (q15_t)0x2284, (q15_t)0x84B0, (q15_t)0x2254, - (q15_t)0x84A2, (q15_t)0x2223, (q15_t)0x8495, (q15_t)0x21F3, - (q15_t)0x8488, (q15_t)0x21C2, (q15_t)0x847B, (q15_t)0x2192, - (q15_t)0x846D, (q15_t)0x2161, (q15_t)0x8460, (q15_t)0x2131, - (q15_t)0x8453, (q15_t)0x2100, (q15_t)0x8446, (q15_t)0x20D0, - (q15_t)0x843A, (q15_t)0x209F, (q15_t)0x842D, (q15_t)0x206E, - (q15_t)0x8420, (q15_t)0x203E, (q15_t)0x8414, (q15_t)0x200D, - (q15_t)0x8407, (q15_t)0x1FDC, (q15_t)0x83FA, (q15_t)0x1FAC, - (q15_t)0x83EE, (q15_t)0x1F7B, (q15_t)0x83E2, (q15_t)0x1F4A, - (q15_t)0x83D6, (q15_t)0x1F19, (q15_t)0x83C9, (q15_t)0x1EE9, - (q15_t)0x83BD, (q15_t)0x1EB8, (q15_t)0x83B1, (q15_t)0x1E87, - (q15_t)0x83A5, (q15_t)0x1E56, (q15_t)0x8399, (q15_t)0x1E25, - (q15_t)0x838E, (q15_t)0x1DF5, (q15_t)0x8382, (q15_t)0x1DC4, - (q15_t)0x8376, (q15_t)0x1D93, (q15_t)0x836B, (q15_t)0x1D62, - (q15_t)0x835F, (q15_t)0x1D31, (q15_t)0x8354, (q15_t)0x1D00, - (q15_t)0x8348, (q15_t)0x1CCF, (q15_t)0x833D, (q15_t)0x1C9E, - (q15_t)0x8332, (q15_t)0x1C6D, (q15_t)0x8327, (q15_t)0x1C3C, - (q15_t)0x831C, (q15_t)0x1C0B, (q15_t)0x8311, (q15_t)0x1BDA, - (q15_t)0x8306, (q15_t)0x1BA9, (q15_t)0x82FB, (q15_t)0x1B78, - (q15_t)0x82F0, (q15_t)0x1B47, (q15_t)0x82E6, (q15_t)0x1B16, - (q15_t)0x82DB, (q15_t)0x1AE4, (q15_t)0x82D0, (q15_t)0x1AB3, - (q15_t)0x82C6, (q15_t)0x1A82, (q15_t)0x82BC, (q15_t)0x1A51, - (q15_t)0x82B1, (q15_t)0x1A20, (q15_t)0x82A7, (q15_t)0x19EF, - (q15_t)0x829D, (q15_t)0x19BD, (q15_t)0x8293, (q15_t)0x198C, - (q15_t)0x8289, (q15_t)0x195B, (q15_t)0x827F, (q15_t)0x192A, - (q15_t)0x8275, (q15_t)0x18F8, (q15_t)0x826B, (q15_t)0x18C7, - (q15_t)0x8262, (q15_t)0x1896, (q15_t)0x8258, (q15_t)0x1864, - (q15_t)0x824F, (q15_t)0x1833, (q15_t)0x8245, (q15_t)0x1802, - (q15_t)0x823C, (q15_t)0x17D0, (q15_t)0x8232, (q15_t)0x179F, - (q15_t)0x8229, (q15_t)0x176D, (q15_t)0x8220, (q15_t)0x173C, - (q15_t)0x8217, (q15_t)0x170A, (q15_t)0x820E, (q15_t)0x16D9, - (q15_t)0x8205, (q15_t)0x16A8, (q15_t)0x81FC, (q15_t)0x1676, - (q15_t)0x81F3, (q15_t)0x1645, (q15_t)0x81EB, (q15_t)0x1613, - (q15_t)0x81E2, (q15_t)0x15E2, (q15_t)0x81D9, (q15_t)0x15B0, - (q15_t)0x81D1, (q15_t)0x157F, (q15_t)0x81C8, (q15_t)0x154D, - (q15_t)0x81C0, (q15_t)0x151B, (q15_t)0x81B8, (q15_t)0x14EA, - (q15_t)0x81B0, (q15_t)0x14B8, (q15_t)0x81A8, (q15_t)0x1487, - (q15_t)0x81A0, (q15_t)0x1455, (q15_t)0x8198, (q15_t)0x1423, - (q15_t)0x8190, (q15_t)0x13F2, (q15_t)0x8188, (q15_t)0x13C0, - (q15_t)0x8180, (q15_t)0x138E, (q15_t)0x8179, (q15_t)0x135D, - (q15_t)0x8171, (q15_t)0x132B, (q15_t)0x816A, (q15_t)0x12F9, - (q15_t)0x8162, (q15_t)0x12C8, (q15_t)0x815B, (q15_t)0x1296, - (q15_t)0x8154, (q15_t)0x1264, (q15_t)0x814C, (q15_t)0x1232, - (q15_t)0x8145, (q15_t)0x1201, (q15_t)0x813E, (q15_t)0x11CF, - (q15_t)0x8137, (q15_t)0x119D, (q15_t)0x8130, (q15_t)0x116B, - (q15_t)0x812A, (q15_t)0x1139, (q15_t)0x8123, (q15_t)0x1108, - (q15_t)0x811C, (q15_t)0x10D6, (q15_t)0x8116, (q15_t)0x10A4, - (q15_t)0x810F, (q15_t)0x1072, (q15_t)0x8109, (q15_t)0x1040, - (q15_t)0x8102, (q15_t)0x100E, (q15_t)0x80FC, (q15_t)0x0FDD, - (q15_t)0x80F6, (q15_t)0x0FAB, (q15_t)0x80F0, (q15_t)0x0F79, - (q15_t)0x80EA, (q15_t)0x0F47, (q15_t)0x80E4, (q15_t)0x0F15, - (q15_t)0x80DE, (q15_t)0x0EE3, (q15_t)0x80D8, (q15_t)0x0EB1, - (q15_t)0x80D2, (q15_t)0x0E7F, (q15_t)0x80CD, (q15_t)0x0E4D, - (q15_t)0x80C7, (q15_t)0x0E1B, (q15_t)0x80C2, (q15_t)0x0DE9, - (q15_t)0x80BC, (q15_t)0x0DB7, (q15_t)0x80B7, (q15_t)0x0D85, - (q15_t)0x80B2, (q15_t)0x0D53, (q15_t)0x80AC, (q15_t)0x0D21, - (q15_t)0x80A7, (q15_t)0x0CEF, (q15_t)0x80A2, (q15_t)0x0CBD, - (q15_t)0x809D, (q15_t)0x0C8B, (q15_t)0x8098, (q15_t)0x0C59, - (q15_t)0x8094, (q15_t)0x0C27, (q15_t)0x808F, (q15_t)0x0BF5, - (q15_t)0x808A, (q15_t)0x0BC3, (q15_t)0x8086, (q15_t)0x0B91, - (q15_t)0x8081, (q15_t)0x0B5F, (q15_t)0x807D, (q15_t)0x0B2D, - (q15_t)0x8078, (q15_t)0x0AFB, (q15_t)0x8074, (q15_t)0x0AC9, - (q15_t)0x8070, (q15_t)0x0A97, (q15_t)0x806C, (q15_t)0x0A65, - (q15_t)0x8068, (q15_t)0x0A33, (q15_t)0x8064, (q15_t)0x0A00, - (q15_t)0x8060, (q15_t)0x09CE, (q15_t)0x805C, (q15_t)0x099C, - (q15_t)0x8058, (q15_t)0x096A, (q15_t)0x8055, (q15_t)0x0938, - (q15_t)0x8051, (q15_t)0x0906, (q15_t)0x804E, (q15_t)0x08D4, - (q15_t)0x804A, (q15_t)0x08A2, (q15_t)0x8047, (q15_t)0x086F, - (q15_t)0x8043, (q15_t)0x083D, (q15_t)0x8040, (q15_t)0x080B, - (q15_t)0x803D, (q15_t)0x07D9, (q15_t)0x803A, (q15_t)0x07A7, - (q15_t)0x8037, (q15_t)0x0775, (q15_t)0x8034, (q15_t)0x0742, - (q15_t)0x8031, (q15_t)0x0710, (q15_t)0x802F, (q15_t)0x06DE, - (q15_t)0x802C, (q15_t)0x06AC, (q15_t)0x8029, (q15_t)0x067A, - (q15_t)0x8027, (q15_t)0x0647, (q15_t)0x8025, (q15_t)0x0615, - (q15_t)0x8022, (q15_t)0x05E3, (q15_t)0x8020, (q15_t)0x05B1, - (q15_t)0x801E, (q15_t)0x057F, (q15_t)0x801C, (q15_t)0x054C, - (q15_t)0x801A, (q15_t)0x051A, (q15_t)0x8018, (q15_t)0x04E8, - (q15_t)0x8016, (q15_t)0x04B6, (q15_t)0x8014, (q15_t)0x0483, - (q15_t)0x8012, (q15_t)0x0451, (q15_t)0x8011, (q15_t)0x041F, - (q15_t)0x800F, (q15_t)0x03ED, (q15_t)0x800D, (q15_t)0x03BA, - (q15_t)0x800C, (q15_t)0x0388, (q15_t)0x800B, (q15_t)0x0356, - (q15_t)0x8009, (q15_t)0x0324, (q15_t)0x8008, (q15_t)0x02F1, - (q15_t)0x8007, (q15_t)0x02BF, (q15_t)0x8006, (q15_t)0x028D, - (q15_t)0x8005, (q15_t)0x025B, (q15_t)0x8004, (q15_t)0x0228, - (q15_t)0x8003, (q15_t)0x01F6, (q15_t)0x8003, (q15_t)0x01C4, - (q15_t)0x8002, (q15_t)0x0192, (q15_t)0x8001, (q15_t)0x015F, - (q15_t)0x8001, (q15_t)0x012D, (q15_t)0x8000, (q15_t)0x00FB, - (q15_t)0x8000, (q15_t)0x00C9, (q15_t)0x8000, (q15_t)0x0096, - (q15_t)0x8000, (q15_t)0x0064, (q15_t)0x8000, (q15_t)0x0032, - (q15_t)0x8000, (q15_t)0x0000, (q15_t)0x8000, (q15_t)0xFFCD, - (q15_t)0x8000, (q15_t)0xFF9B, (q15_t)0x8000, (q15_t)0xFF69, - (q15_t)0x8000, (q15_t)0xFF36, (q15_t)0x8000, (q15_t)0xFF04, - (q15_t)0x8001, (q15_t)0xFED2, (q15_t)0x8001, (q15_t)0xFEA0, - (q15_t)0x8002, (q15_t)0xFE6D, (q15_t)0x8003, (q15_t)0xFE3B, - (q15_t)0x8003, (q15_t)0xFE09, (q15_t)0x8004, (q15_t)0xFDD7, - (q15_t)0x8005, (q15_t)0xFDA4, (q15_t)0x8006, (q15_t)0xFD72, - (q15_t)0x8007, (q15_t)0xFD40, (q15_t)0x8008, (q15_t)0xFD0E, - (q15_t)0x8009, (q15_t)0xFCDB, (q15_t)0x800B, (q15_t)0xFCA9, - (q15_t)0x800C, (q15_t)0xFC77, (q15_t)0x800D, (q15_t)0xFC45, - (q15_t)0x800F, (q15_t)0xFC12, (q15_t)0x8011, (q15_t)0xFBE0, - (q15_t)0x8012, (q15_t)0xFBAE, (q15_t)0x8014, (q15_t)0xFB7C, - (q15_t)0x8016, (q15_t)0xFB49, (q15_t)0x8018, (q15_t)0xFB17, - (q15_t)0x801A, (q15_t)0xFAE5, (q15_t)0x801C, (q15_t)0xFAB3, - (q15_t)0x801E, (q15_t)0xFA80, (q15_t)0x8020, (q15_t)0xFA4E, - (q15_t)0x8022, (q15_t)0xFA1C, (q15_t)0x8025, (q15_t)0xF9EA, - (q15_t)0x8027, (q15_t)0xF9B8, (q15_t)0x8029, (q15_t)0xF985, - (q15_t)0x802C, (q15_t)0xF953, (q15_t)0x802F, (q15_t)0xF921, - (q15_t)0x8031, (q15_t)0xF8EF, (q15_t)0x8034, (q15_t)0xF8BD, - (q15_t)0x8037, (q15_t)0xF88A, (q15_t)0x803A, (q15_t)0xF858, - (q15_t)0x803D, (q15_t)0xF826, (q15_t)0x8040, (q15_t)0xF7F4, - (q15_t)0x8043, (q15_t)0xF7C2, (q15_t)0x8047, (q15_t)0xF790, - (q15_t)0x804A, (q15_t)0xF75D, (q15_t)0x804E, (q15_t)0xF72B, - (q15_t)0x8051, (q15_t)0xF6F9, (q15_t)0x8055, (q15_t)0xF6C7, - (q15_t)0x8058, (q15_t)0xF695, (q15_t)0x805C, (q15_t)0xF663, - (q15_t)0x8060, (q15_t)0xF631, (q15_t)0x8064, (q15_t)0xF5FF, - (q15_t)0x8068, (q15_t)0xF5CC, (q15_t)0x806C, (q15_t)0xF59A, - (q15_t)0x8070, (q15_t)0xF568, (q15_t)0x8074, (q15_t)0xF536, - (q15_t)0x8078, (q15_t)0xF504, (q15_t)0x807D, (q15_t)0xF4D2, - (q15_t)0x8081, (q15_t)0xF4A0, (q15_t)0x8086, (q15_t)0xF46E, - (q15_t)0x808A, (q15_t)0xF43C, (q15_t)0x808F, (q15_t)0xF40A, - (q15_t)0x8094, (q15_t)0xF3D8, (q15_t)0x8098, (q15_t)0xF3A6, - (q15_t)0x809D, (q15_t)0xF374, (q15_t)0x80A2, (q15_t)0xF342, - (q15_t)0x80A7, (q15_t)0xF310, (q15_t)0x80AC, (q15_t)0xF2DE, - (q15_t)0x80B2, (q15_t)0xF2AC, (q15_t)0x80B7, (q15_t)0xF27A, - (q15_t)0x80BC, (q15_t)0xF248, (q15_t)0x80C2, (q15_t)0xF216, - (q15_t)0x80C7, (q15_t)0xF1E4, (q15_t)0x80CD, (q15_t)0xF1B2, - (q15_t)0x80D2, (q15_t)0xF180, (q15_t)0x80D8, (q15_t)0xF14E, - (q15_t)0x80DE, (q15_t)0xF11C, (q15_t)0x80E4, (q15_t)0xF0EA, - (q15_t)0x80EA, (q15_t)0xF0B8, (q15_t)0x80F0, (q15_t)0xF086, - (q15_t)0x80F6, (q15_t)0xF054, (q15_t)0x80FC, (q15_t)0xF022, - (q15_t)0x8102, (q15_t)0xEFF1, (q15_t)0x8109, (q15_t)0xEFBF, - (q15_t)0x810F, (q15_t)0xEF8D, (q15_t)0x8116, (q15_t)0xEF5B, - (q15_t)0x811C, (q15_t)0xEF29, (q15_t)0x8123, (q15_t)0xEEF7, - (q15_t)0x812A, (q15_t)0xEEC6, (q15_t)0x8130, (q15_t)0xEE94, - (q15_t)0x8137, (q15_t)0xEE62, (q15_t)0x813E, (q15_t)0xEE30, - (q15_t)0x8145, (q15_t)0xEDFE, (q15_t)0x814C, (q15_t)0xEDCD, - (q15_t)0x8154, (q15_t)0xED9B, (q15_t)0x815B, (q15_t)0xED69, - (q15_t)0x8162, (q15_t)0xED37, (q15_t)0x816A, (q15_t)0xED06, - (q15_t)0x8171, (q15_t)0xECD4, (q15_t)0x8179, (q15_t)0xECA2, - (q15_t)0x8180, (q15_t)0xEC71, (q15_t)0x8188, (q15_t)0xEC3F, - (q15_t)0x8190, (q15_t)0xEC0D, (q15_t)0x8198, (q15_t)0xEBDC, - (q15_t)0x81A0, (q15_t)0xEBAA, (q15_t)0x81A8, (q15_t)0xEB78, - (q15_t)0x81B0, (q15_t)0xEB47, (q15_t)0x81B8, (q15_t)0xEB15, - (q15_t)0x81C0, (q15_t)0xEAE4, (q15_t)0x81C8, (q15_t)0xEAB2, - (q15_t)0x81D1, (q15_t)0xEA80, (q15_t)0x81D9, (q15_t)0xEA4F, - (q15_t)0x81E2, (q15_t)0xEA1D, (q15_t)0x81EB, (q15_t)0xE9EC, - (q15_t)0x81F3, (q15_t)0xE9BA, (q15_t)0x81FC, (q15_t)0xE989, - (q15_t)0x8205, (q15_t)0xE957, (q15_t)0x820E, (q15_t)0xE926, - (q15_t)0x8217, (q15_t)0xE8F5, (q15_t)0x8220, (q15_t)0xE8C3, - (q15_t)0x8229, (q15_t)0xE892, (q15_t)0x8232, (q15_t)0xE860, - (q15_t)0x823C, (q15_t)0xE82F, (q15_t)0x8245, (q15_t)0xE7FD, - (q15_t)0x824F, (q15_t)0xE7CC, (q15_t)0x8258, (q15_t)0xE79B, - (q15_t)0x8262, (q15_t)0xE769, (q15_t)0x826B, (q15_t)0xE738, - (q15_t)0x8275, (q15_t)0xE707, (q15_t)0x827F, (q15_t)0xE6D5, - (q15_t)0x8289, (q15_t)0xE6A4, (q15_t)0x8293, (q15_t)0xE673, - (q15_t)0x829D, (q15_t)0xE642, (q15_t)0x82A7, (q15_t)0xE610, - (q15_t)0x82B1, (q15_t)0xE5DF, (q15_t)0x82BC, (q15_t)0xE5AE, - (q15_t)0x82C6, (q15_t)0xE57D, (q15_t)0x82D0, (q15_t)0xE54C, - (q15_t)0x82DB, (q15_t)0xE51B, (q15_t)0x82E6, (q15_t)0xE4E9, - (q15_t)0x82F0, (q15_t)0xE4B8, (q15_t)0x82FB, (q15_t)0xE487, - (q15_t)0x8306, (q15_t)0xE456, (q15_t)0x8311, (q15_t)0xE425, - (q15_t)0x831C, (q15_t)0xE3F4, (q15_t)0x8327, (q15_t)0xE3C3, - (q15_t)0x8332, (q15_t)0xE392, (q15_t)0x833D, (q15_t)0xE361, - (q15_t)0x8348, (q15_t)0xE330, (q15_t)0x8354, (q15_t)0xE2FF, - (q15_t)0x835F, (q15_t)0xE2CE, (q15_t)0x836B, (q15_t)0xE29D, - (q15_t)0x8376, (q15_t)0xE26C, (q15_t)0x8382, (q15_t)0xE23B, - (q15_t)0x838E, (q15_t)0xE20A, (q15_t)0x8399, (q15_t)0xE1DA, - (q15_t)0x83A5, (q15_t)0xE1A9, (q15_t)0x83B1, (q15_t)0xE178, - (q15_t)0x83BD, (q15_t)0xE147, (q15_t)0x83C9, (q15_t)0xE116, - (q15_t)0x83D6, (q15_t)0xE0E6, (q15_t)0x83E2, (q15_t)0xE0B5, - (q15_t)0x83EE, (q15_t)0xE084, (q15_t)0x83FA, (q15_t)0xE053, - (q15_t)0x8407, (q15_t)0xE023, (q15_t)0x8414, (q15_t)0xDFF2, - (q15_t)0x8420, (q15_t)0xDFC1, (q15_t)0x842D, (q15_t)0xDF91, - (q15_t)0x843A, (q15_t)0xDF60, (q15_t)0x8446, (q15_t)0xDF2F, - (q15_t)0x8453, (q15_t)0xDEFF, (q15_t)0x8460, (q15_t)0xDECE, - (q15_t)0x846D, (q15_t)0xDE9E, (q15_t)0x847B, (q15_t)0xDE6D, - (q15_t)0x8488, (q15_t)0xDE3D, (q15_t)0x8495, (q15_t)0xDE0C, - (q15_t)0x84A2, (q15_t)0xDDDC, (q15_t)0x84B0, (q15_t)0xDDAB, - (q15_t)0x84BD, (q15_t)0xDD7B, (q15_t)0x84CB, (q15_t)0xDD4B, - (q15_t)0x84D9, (q15_t)0xDD1A, (q15_t)0x84E6, (q15_t)0xDCEA, - (q15_t)0x84F4, (q15_t)0xDCBA, (q15_t)0x8502, (q15_t)0xDC89, - (q15_t)0x8510, (q15_t)0xDC59, (q15_t)0x851E, (q15_t)0xDC29, - (q15_t)0x852C, (q15_t)0xDBF8, (q15_t)0x853A, (q15_t)0xDBC8, - (q15_t)0x8549, (q15_t)0xDB98, (q15_t)0x8557, (q15_t)0xDB68, - (q15_t)0x8565, (q15_t)0xDB38, (q15_t)0x8574, (q15_t)0xDB08, - (q15_t)0x8582, (q15_t)0xDAD7, (q15_t)0x8591, (q15_t)0xDAA7, - (q15_t)0x85A0, (q15_t)0xDA77, (q15_t)0x85AF, (q15_t)0xDA47, - (q15_t)0x85BD, (q15_t)0xDA17, (q15_t)0x85CC, (q15_t)0xD9E7, - (q15_t)0x85DB, (q15_t)0xD9B7, (q15_t)0x85EA, (q15_t)0xD987, - (q15_t)0x85FA, (q15_t)0xD957, (q15_t)0x8609, (q15_t)0xD927, - (q15_t)0x8618, (q15_t)0xD8F8, (q15_t)0x8627, (q15_t)0xD8C8, - (q15_t)0x8637, (q15_t)0xD898, (q15_t)0x8646, (q15_t)0xD868, - (q15_t)0x8656, (q15_t)0xD838, (q15_t)0x8666, (q15_t)0xD809, - (q15_t)0x8675, (q15_t)0xD7D9, (q15_t)0x8685, (q15_t)0xD7A9, - (q15_t)0x8695, (q15_t)0xD779, (q15_t)0x86A5, (q15_t)0xD74A, - (q15_t)0x86B5, (q15_t)0xD71A, (q15_t)0x86C5, (q15_t)0xD6EA, - (q15_t)0x86D5, (q15_t)0xD6BB, (q15_t)0x86E6, (q15_t)0xD68B, - (q15_t)0x86F6, (q15_t)0xD65C, (q15_t)0x8706, (q15_t)0xD62C, - (q15_t)0x8717, (q15_t)0xD5FD, (q15_t)0x8727, (q15_t)0xD5CD, - (q15_t)0x8738, (q15_t)0xD59E, (q15_t)0x8749, (q15_t)0xD56E, - (q15_t)0x8759, (q15_t)0xD53F, (q15_t)0x876A, (q15_t)0xD510, - (q15_t)0x877B, (q15_t)0xD4E0, (q15_t)0x878C, (q15_t)0xD4B1, - (q15_t)0x879D, (q15_t)0xD482, (q15_t)0x87AE, (q15_t)0xD452, - (q15_t)0x87BF, (q15_t)0xD423, (q15_t)0x87D1, (q15_t)0xD3F4, - (q15_t)0x87E2, (q15_t)0xD3C5, (q15_t)0x87F3, (q15_t)0xD396, - (q15_t)0x8805, (q15_t)0xD367, (q15_t)0x8816, (q15_t)0xD337, - (q15_t)0x8828, (q15_t)0xD308, (q15_t)0x883A, (q15_t)0xD2D9, - (q15_t)0x884B, (q15_t)0xD2AA, (q15_t)0x885D, (q15_t)0xD27B, - (q15_t)0x886F, (q15_t)0xD24C, (q15_t)0x8881, (q15_t)0xD21D, - (q15_t)0x8893, (q15_t)0xD1EE, (q15_t)0x88A5, (q15_t)0xD1C0, - (q15_t)0x88B8, (q15_t)0xD191, (q15_t)0x88CA, (q15_t)0xD162, - (q15_t)0x88DC, (q15_t)0xD133, (q15_t)0x88EF, (q15_t)0xD104, - (q15_t)0x8901, (q15_t)0xD0D6, (q15_t)0x8914, (q15_t)0xD0A7, - (q15_t)0x8926, (q15_t)0xD078, (q15_t)0x8939, (q15_t)0xD04A, - (q15_t)0x894C, (q15_t)0xD01B, (q15_t)0x895F, (q15_t)0xCFEC, - (q15_t)0x8971, (q15_t)0xCFBE, (q15_t)0x8984, (q15_t)0xCF8F, - (q15_t)0x8997, (q15_t)0xCF61, (q15_t)0x89AB, (q15_t)0xCF32, - (q15_t)0x89BE, (q15_t)0xCF04, (q15_t)0x89D1, (q15_t)0xCED5, - (q15_t)0x89E4, (q15_t)0xCEA7, (q15_t)0x89F8, (q15_t)0xCE79, - (q15_t)0x8A0B, (q15_t)0xCE4A, (q15_t)0x8A1F, (q15_t)0xCE1C, - (q15_t)0x8A33, (q15_t)0xCDEE, (q15_t)0x8A46, (q15_t)0xCDBF, - (q15_t)0x8A5A, (q15_t)0xCD91, (q15_t)0x8A6E, (q15_t)0xCD63, - (q15_t)0x8A82, (q15_t)0xCD35, (q15_t)0x8A96, (q15_t)0xCD07, - (q15_t)0x8AAA, (q15_t)0xCCD9, (q15_t)0x8ABE, (q15_t)0xCCAB, - (q15_t)0x8AD2, (q15_t)0xCC7D, (q15_t)0x8AE6, (q15_t)0xCC4F, - (q15_t)0x8AFB, (q15_t)0xCC21, (q15_t)0x8B0F, (q15_t)0xCBF3, - (q15_t)0x8B24, (q15_t)0xCBC5, (q15_t)0x8B38, (q15_t)0xCB97, - (q15_t)0x8B4D, (q15_t)0xCB69, (q15_t)0x8B61, (q15_t)0xCB3B, - (q15_t)0x8B76, (q15_t)0xCB0D, (q15_t)0x8B8B, (q15_t)0xCAE0, - (q15_t)0x8BA0, (q15_t)0xCAB2, (q15_t)0x8BB5, (q15_t)0xCA84, - (q15_t)0x8BCA, (q15_t)0xCA57, (q15_t)0x8BDF, (q15_t)0xCA29, - (q15_t)0x8BF4, (q15_t)0xC9FB, (q15_t)0x8C09, (q15_t)0xC9CE, - (q15_t)0x8C1F, (q15_t)0xC9A0, (q15_t)0x8C34, (q15_t)0xC973, - (q15_t)0x8C4A, (q15_t)0xC945, (q15_t)0x8C5F, (q15_t)0xC918, - (q15_t)0x8C75, (q15_t)0xC8EB, (q15_t)0x8C8A, (q15_t)0xC8BD, - (q15_t)0x8CA0, (q15_t)0xC890, (q15_t)0x8CB6, (q15_t)0xC863, - (q15_t)0x8CCC, (q15_t)0xC835, (q15_t)0x8CE2, (q15_t)0xC808, - (q15_t)0x8CF8, (q15_t)0xC7DB, (q15_t)0x8D0E, (q15_t)0xC7AE, - (q15_t)0x8D24, (q15_t)0xC781, (q15_t)0x8D3A, (q15_t)0xC754, - (q15_t)0x8D50, (q15_t)0xC727, (q15_t)0x8D67, (q15_t)0xC6F9, - (q15_t)0x8D7D, (q15_t)0xC6CD, (q15_t)0x8D94, (q15_t)0xC6A0, - (q15_t)0x8DAA, (q15_t)0xC673, (q15_t)0x8DC1, (q15_t)0xC646, - (q15_t)0x8DD8, (q15_t)0xC619, (q15_t)0x8DEE, (q15_t)0xC5EC, - (q15_t)0x8E05, (q15_t)0xC5BF, (q15_t)0x8E1C, (q15_t)0xC593, - (q15_t)0x8E33, (q15_t)0xC566, (q15_t)0x8E4A, (q15_t)0xC539, - (q15_t)0x8E61, (q15_t)0xC50D, (q15_t)0x8E79, (q15_t)0xC4E0, - (q15_t)0x8E90, (q15_t)0xC4B3, (q15_t)0x8EA7, (q15_t)0xC487, - (q15_t)0x8EBE, (q15_t)0xC45A, (q15_t)0x8ED6, (q15_t)0xC42E, - (q15_t)0x8EED, (q15_t)0xC402, (q15_t)0x8F05, (q15_t)0xC3D5, - (q15_t)0x8F1D, (q15_t)0xC3A9, (q15_t)0x8F34, (q15_t)0xC37C, - (q15_t)0x8F4C, (q15_t)0xC350, (q15_t)0x8F64, (q15_t)0xC324, - (q15_t)0x8F7C, (q15_t)0xC2F8, (q15_t)0x8F94, (q15_t)0xC2CC, - (q15_t)0x8FAC, (q15_t)0xC29F, (q15_t)0x8FC4, (q15_t)0xC273, - (q15_t)0x8FDC, (q15_t)0xC247, (q15_t)0x8FF5, (q15_t)0xC21B, - (q15_t)0x900D, (q15_t)0xC1EF, (q15_t)0x9025, (q15_t)0xC1C3, - (q15_t)0x903E, (q15_t)0xC197, (q15_t)0x9056, (q15_t)0xC16C, - (q15_t)0x906F, (q15_t)0xC140, (q15_t)0x9088, (q15_t)0xC114, - (q15_t)0x90A0, (q15_t)0xC0E8, (q15_t)0x90B9, (q15_t)0xC0BC, - (q15_t)0x90D2, (q15_t)0xC091, (q15_t)0x90EB, (q15_t)0xC065, - (q15_t)0x9104, (q15_t)0xC03A, (q15_t)0x911D, (q15_t)0xC00E, - (q15_t)0x9136, (q15_t)0xBFE2, (q15_t)0x9150, (q15_t)0xBFB7, - (q15_t)0x9169, (q15_t)0xBF8C, (q15_t)0x9182, (q15_t)0xBF60, - (q15_t)0x919C, (q15_t)0xBF35, (q15_t)0x91B5, (q15_t)0xBF09, - (q15_t)0x91CF, (q15_t)0xBEDE, (q15_t)0x91E8, (q15_t)0xBEB3, - (q15_t)0x9202, (q15_t)0xBE88, (q15_t)0x921C, (q15_t)0xBE5D, - (q15_t)0x9235, (q15_t)0xBE31, (q15_t)0x924F, (q15_t)0xBE06, - (q15_t)0x9269, (q15_t)0xBDDB, (q15_t)0x9283, (q15_t)0xBDB0, - (q15_t)0x929D, (q15_t)0xBD85, (q15_t)0x92B7, (q15_t)0xBD5A, - (q15_t)0x92D2, (q15_t)0xBD2F, (q15_t)0x92EC, (q15_t)0xBD05, - (q15_t)0x9306, (q15_t)0xBCDA, (q15_t)0x9321, (q15_t)0xBCAF, - (q15_t)0x933B, (q15_t)0xBC84, (q15_t)0x9356, (q15_t)0xBC5A, - (q15_t)0x9370, (q15_t)0xBC2F, (q15_t)0x938B, (q15_t)0xBC04, - (q15_t)0x93A6, (q15_t)0xBBDA, (q15_t)0x93C0, (q15_t)0xBBAF, - (q15_t)0x93DB, (q15_t)0xBB85, (q15_t)0x93F6, (q15_t)0xBB5A, - (q15_t)0x9411, (q15_t)0xBB30, (q15_t)0x942C, (q15_t)0xBB05, - (q15_t)0x9447, (q15_t)0xBADB, (q15_t)0x9463, (q15_t)0xBAB1, - (q15_t)0x947E, (q15_t)0xBA87, (q15_t)0x9499, (q15_t)0xBA5C, - (q15_t)0x94B5, (q15_t)0xBA32, (q15_t)0x94D0, (q15_t)0xBA08, - (q15_t)0x94EC, (q15_t)0xB9DE, (q15_t)0x9507, (q15_t)0xB9B4, - (q15_t)0x9523, (q15_t)0xB98A, (q15_t)0x953E, (q15_t)0xB960, - (q15_t)0x955A, (q15_t)0xB936, (q15_t)0x9576, (q15_t)0xB90C, - (q15_t)0x9592, (q15_t)0xB8E3, (q15_t)0x95AE, (q15_t)0xB8B9, - (q15_t)0x95CA, (q15_t)0xB88F, (q15_t)0x95E6, (q15_t)0xB865, - (q15_t)0x9602, (q15_t)0xB83C, (q15_t)0x961E, (q15_t)0xB812, - (q15_t)0x963B, (q15_t)0xB7E9, (q15_t)0x9657, (q15_t)0xB7BF, - (q15_t)0x9673, (q15_t)0xB796, (q15_t)0x9690, (q15_t)0xB76C, - (q15_t)0x96AC, (q15_t)0xB743, (q15_t)0x96C9, (q15_t)0xB719, - (q15_t)0x96E6, (q15_t)0xB6F0, (q15_t)0x9702, (q15_t)0xB6C7, - (q15_t)0x971F, (q15_t)0xB69E, (q15_t)0x973C, (q15_t)0xB675, - (q15_t)0x9759, (q15_t)0xB64B, (q15_t)0x9776, (q15_t)0xB622, - (q15_t)0x9793, (q15_t)0xB5F9, (q15_t)0x97B0, (q15_t)0xB5D0, - (q15_t)0x97CD, (q15_t)0xB5A7, (q15_t)0x97EA, (q15_t)0xB57E, - (q15_t)0x9808, (q15_t)0xB556, (q15_t)0x9825, (q15_t)0xB52D, - (q15_t)0x9842, (q15_t)0xB504, (q15_t)0x9860, (q15_t)0xB4DB, - (q15_t)0x987D, (q15_t)0xB4B3, (q15_t)0x989B, (q15_t)0xB48A, - (q15_t)0x98B9, (q15_t)0xB461, (q15_t)0x98D6, (q15_t)0xB439, - (q15_t)0x98F4, (q15_t)0xB410, (q15_t)0x9912, (q15_t)0xB3E8, - (q15_t)0x9930, (q15_t)0xB3C0, (q15_t)0x994E, (q15_t)0xB397, - (q15_t)0x996C, (q15_t)0xB36F, (q15_t)0x998A, (q15_t)0xB347, - (q15_t)0x99A8, (q15_t)0xB31E, (q15_t)0x99C6, (q15_t)0xB2F6, - (q15_t)0x99E5, (q15_t)0xB2CE, (q15_t)0x9A03, (q15_t)0xB2A6, - (q15_t)0x9A22, (q15_t)0xB27E, (q15_t)0x9A40, (q15_t)0xB256, - (q15_t)0x9A5F, (q15_t)0xB22E, (q15_t)0x9A7D, (q15_t)0xB206, - (q15_t)0x9A9C, (q15_t)0xB1DE, (q15_t)0x9ABA, (q15_t)0xB1B7, - (q15_t)0x9AD9, (q15_t)0xB18F, (q15_t)0x9AF8, (q15_t)0xB167, - (q15_t)0x9B17, (q15_t)0xB140, (q15_t)0x9B36, (q15_t)0xB118, - (q15_t)0x9B55, (q15_t)0xB0F0, (q15_t)0x9B74, (q15_t)0xB0C9, - (q15_t)0x9B93, (q15_t)0xB0A1, (q15_t)0x9BB2, (q15_t)0xB07A, - (q15_t)0x9BD2, (q15_t)0xB053, (q15_t)0x9BF1, (q15_t)0xB02B, - (q15_t)0x9C10, (q15_t)0xB004, (q15_t)0x9C30, (q15_t)0xAFDD, - (q15_t)0x9C4F, (q15_t)0xAFB6, (q15_t)0x9C6F, (q15_t)0xAF8F, - (q15_t)0x9C8E, (q15_t)0xAF68, (q15_t)0x9CAE, (q15_t)0xAF40, - (q15_t)0x9CCE, (q15_t)0xAF1A, (q15_t)0x9CEE, (q15_t)0xAEF3, - (q15_t)0x9D0D, (q15_t)0xAECC, (q15_t)0x9D2D, (q15_t)0xAEA5, - (q15_t)0x9D4D, (q15_t)0xAE7E, (q15_t)0x9D6D, (q15_t)0xAE57, - (q15_t)0x9D8E, (q15_t)0xAE31, (q15_t)0x9DAE, (q15_t)0xAE0A, - (q15_t)0x9DCE, (q15_t)0xADE3, (q15_t)0x9DEE, (q15_t)0xADBD, - (q15_t)0x9E0E, (q15_t)0xAD96, (q15_t)0x9E2F, (q15_t)0xAD70, - (q15_t)0x9E4F, (q15_t)0xAD4A, (q15_t)0x9E70, (q15_t)0xAD23, - (q15_t)0x9E90, (q15_t)0xACFD, (q15_t)0x9EB1, (q15_t)0xACD7, - (q15_t)0x9ED2, (q15_t)0xACB1, (q15_t)0x9EF2, (q15_t)0xAC8A, - (q15_t)0x9F13, (q15_t)0xAC64, (q15_t)0x9F34, (q15_t)0xAC3E, - (q15_t)0x9F55, (q15_t)0xAC18, (q15_t)0x9F76, (q15_t)0xABF2, - (q15_t)0x9F97, (q15_t)0xABCC, (q15_t)0x9FB8, (q15_t)0xABA7, - (q15_t)0x9FD9, (q15_t)0xAB81, (q15_t)0x9FFB, (q15_t)0xAB5B, - (q15_t)0xA01C, (q15_t)0xAB35, (q15_t)0xA03D, (q15_t)0xAB10, - (q15_t)0xA05F, (q15_t)0xAAEA, (q15_t)0xA080, (q15_t)0xAAC5, - (q15_t)0xA0A1, (q15_t)0xAA9F, (q15_t)0xA0C3, (q15_t)0xAA7A, - (q15_t)0xA0E5, (q15_t)0xAA54, (q15_t)0xA106, (q15_t)0xAA2F, - (q15_t)0xA128, (q15_t)0xAA0A, (q15_t)0xA14A, (q15_t)0xA9E5, - (q15_t)0xA16C, (q15_t)0xA9BF, (q15_t)0xA18E, (q15_t)0xA99A, - (q15_t)0xA1AF, (q15_t)0xA975, (q15_t)0xA1D2, (q15_t)0xA950, - (q15_t)0xA1F4, (q15_t)0xA92B, (q15_t)0xA216, (q15_t)0xA906, - (q15_t)0xA238, (q15_t)0xA8E2, (q15_t)0xA25A, (q15_t)0xA8BD, - (q15_t)0xA27C, (q15_t)0xA898, (q15_t)0xA29F, (q15_t)0xA873, - (q15_t)0xA2C1, (q15_t)0xA84F, (q15_t)0xA2E4, (q15_t)0xA82A, - (q15_t)0xA306, (q15_t)0xA806, (q15_t)0xA329, (q15_t)0xA7E1, - (q15_t)0xA34B, (q15_t)0xA7BD, (q15_t)0xA36E, (q15_t)0xA798, - (q15_t)0xA391, (q15_t)0xA774, (q15_t)0xA3B4, (q15_t)0xA750, - (q15_t)0xA3D6, (q15_t)0xA72B, (q15_t)0xA3F9, (q15_t)0xA707, - (q15_t)0xA41C, (q15_t)0xA6E3, (q15_t)0xA43F, (q15_t)0xA6BF, - (q15_t)0xA462, (q15_t)0xA69B, (q15_t)0xA486, (q15_t)0xA677, - (q15_t)0xA4A9, (q15_t)0xA653, (q15_t)0xA4CC, (q15_t)0xA62F, - (q15_t)0xA4EF, (q15_t)0xA60C, (q15_t)0xA513, (q15_t)0xA5E8, - (q15_t)0xA536, (q15_t)0xA5C4, (q15_t)0xA55A, (q15_t)0xA5A1, - (q15_t)0xA57D, (q15_t)0xA57D, (q15_t)0xA5A1, (q15_t)0xA55A, - (q15_t)0xA5C4, (q15_t)0xA536, (q15_t)0xA5E8, (q15_t)0xA513, - (q15_t)0xA60C, (q15_t)0xA4EF, (q15_t)0xA62F, (q15_t)0xA4CC, - (q15_t)0xA653, (q15_t)0xA4A9, (q15_t)0xA677, (q15_t)0xA486, - (q15_t)0xA69B, (q15_t)0xA462, (q15_t)0xA6BF, (q15_t)0xA43F, - (q15_t)0xA6E3, (q15_t)0xA41C, (q15_t)0xA707, (q15_t)0xA3F9, - (q15_t)0xA72B, (q15_t)0xA3D6, (q15_t)0xA750, (q15_t)0xA3B4, - (q15_t)0xA774, (q15_t)0xA391, (q15_t)0xA798, (q15_t)0xA36E, - (q15_t)0xA7BD, (q15_t)0xA34B, (q15_t)0xA7E1, (q15_t)0xA329, - (q15_t)0xA806, (q15_t)0xA306, (q15_t)0xA82A, (q15_t)0xA2E4, - (q15_t)0xA84F, (q15_t)0xA2C1, (q15_t)0xA873, (q15_t)0xA29F, - (q15_t)0xA898, (q15_t)0xA27C, (q15_t)0xA8BD, (q15_t)0xA25A, - (q15_t)0xA8E2, (q15_t)0xA238, (q15_t)0xA906, (q15_t)0xA216, - (q15_t)0xA92B, (q15_t)0xA1F4, (q15_t)0xA950, (q15_t)0xA1D2, - (q15_t)0xA975, (q15_t)0xA1AF, (q15_t)0xA99A, (q15_t)0xA18E, - (q15_t)0xA9BF, (q15_t)0xA16C, (q15_t)0xA9E5, (q15_t)0xA14A, - (q15_t)0xAA0A, (q15_t)0xA128, (q15_t)0xAA2F, (q15_t)0xA106, - (q15_t)0xAA54, (q15_t)0xA0E5, (q15_t)0xAA7A, (q15_t)0xA0C3, - (q15_t)0xAA9F, (q15_t)0xA0A1, (q15_t)0xAAC5, (q15_t)0xA080, - (q15_t)0xAAEA, (q15_t)0xA05F, (q15_t)0xAB10, (q15_t)0xA03D, - (q15_t)0xAB35, (q15_t)0xA01C, (q15_t)0xAB5B, (q15_t)0x9FFB, - (q15_t)0xAB81, (q15_t)0x9FD9, (q15_t)0xABA7, (q15_t)0x9FB8, - (q15_t)0xABCC, (q15_t)0x9F97, (q15_t)0xABF2, (q15_t)0x9F76, - (q15_t)0xAC18, (q15_t)0x9F55, (q15_t)0xAC3E, (q15_t)0x9F34, - (q15_t)0xAC64, (q15_t)0x9F13, (q15_t)0xAC8A, (q15_t)0x9EF2, - (q15_t)0xACB1, (q15_t)0x9ED2, (q15_t)0xACD7, (q15_t)0x9EB1, - (q15_t)0xACFD, (q15_t)0x9E90, (q15_t)0xAD23, (q15_t)0x9E70, - (q15_t)0xAD4A, (q15_t)0x9E4F, (q15_t)0xAD70, (q15_t)0x9E2F, - (q15_t)0xAD96, (q15_t)0x9E0E, (q15_t)0xADBD, (q15_t)0x9DEE, - (q15_t)0xADE3, (q15_t)0x9DCE, (q15_t)0xAE0A, (q15_t)0x9DAE, - (q15_t)0xAE31, (q15_t)0x9D8E, (q15_t)0xAE57, (q15_t)0x9D6D, - (q15_t)0xAE7E, (q15_t)0x9D4D, (q15_t)0xAEA5, (q15_t)0x9D2D, - (q15_t)0xAECC, (q15_t)0x9D0D, (q15_t)0xAEF3, (q15_t)0x9CEE, - (q15_t)0xAF1A, (q15_t)0x9CCE, (q15_t)0xAF40, (q15_t)0x9CAE, - (q15_t)0xAF68, (q15_t)0x9C8E, (q15_t)0xAF8F, (q15_t)0x9C6F, - (q15_t)0xAFB6, (q15_t)0x9C4F, (q15_t)0xAFDD, (q15_t)0x9C30, - (q15_t)0xB004, (q15_t)0x9C10, (q15_t)0xB02B, (q15_t)0x9BF1, - (q15_t)0xB053, (q15_t)0x9BD2, (q15_t)0xB07A, (q15_t)0x9BB2, - (q15_t)0xB0A1, (q15_t)0x9B93, (q15_t)0xB0C9, (q15_t)0x9B74, - (q15_t)0xB0F0, (q15_t)0x9B55, (q15_t)0xB118, (q15_t)0x9B36, - (q15_t)0xB140, (q15_t)0x9B17, (q15_t)0xB167, (q15_t)0x9AF8, - (q15_t)0xB18F, (q15_t)0x9AD9, (q15_t)0xB1B7, (q15_t)0x9ABA, - (q15_t)0xB1DE, (q15_t)0x9A9C, (q15_t)0xB206, (q15_t)0x9A7D, - (q15_t)0xB22E, (q15_t)0x9A5F, (q15_t)0xB256, (q15_t)0x9A40, - (q15_t)0xB27E, (q15_t)0x9A22, (q15_t)0xB2A6, (q15_t)0x9A03, - (q15_t)0xB2CE, (q15_t)0x99E5, (q15_t)0xB2F6, (q15_t)0x99C6, - (q15_t)0xB31E, (q15_t)0x99A8, (q15_t)0xB347, (q15_t)0x998A, - (q15_t)0xB36F, (q15_t)0x996C, (q15_t)0xB397, (q15_t)0x994E, - (q15_t)0xB3C0, (q15_t)0x9930, (q15_t)0xB3E8, (q15_t)0x9912, - (q15_t)0xB410, (q15_t)0x98F4, (q15_t)0xB439, (q15_t)0x98D6, - (q15_t)0xB461, (q15_t)0x98B9, (q15_t)0xB48A, (q15_t)0x989B, - (q15_t)0xB4B3, (q15_t)0x987D, (q15_t)0xB4DB, (q15_t)0x9860, - (q15_t)0xB504, (q15_t)0x9842, (q15_t)0xB52D, (q15_t)0x9825, - (q15_t)0xB556, (q15_t)0x9808, (q15_t)0xB57E, (q15_t)0x97EA, - (q15_t)0xB5A7, (q15_t)0x97CD, (q15_t)0xB5D0, (q15_t)0x97B0, - (q15_t)0xB5F9, (q15_t)0x9793, (q15_t)0xB622, (q15_t)0x9776, - (q15_t)0xB64B, (q15_t)0x9759, (q15_t)0xB675, (q15_t)0x973C, - (q15_t)0xB69E, (q15_t)0x971F, (q15_t)0xB6C7, (q15_t)0x9702, - (q15_t)0xB6F0, (q15_t)0x96E6, (q15_t)0xB719, (q15_t)0x96C9, - (q15_t)0xB743, (q15_t)0x96AC, (q15_t)0xB76C, (q15_t)0x9690, - (q15_t)0xB796, (q15_t)0x9673, (q15_t)0xB7BF, (q15_t)0x9657, - (q15_t)0xB7E9, (q15_t)0x963B, (q15_t)0xB812, (q15_t)0x961E, - (q15_t)0xB83C, (q15_t)0x9602, (q15_t)0xB865, (q15_t)0x95E6, - (q15_t)0xB88F, (q15_t)0x95CA, (q15_t)0xB8B9, (q15_t)0x95AE, - (q15_t)0xB8E3, (q15_t)0x9592, (q15_t)0xB90C, (q15_t)0x9576, - (q15_t)0xB936, (q15_t)0x955A, (q15_t)0xB960, (q15_t)0x953E, - (q15_t)0xB98A, (q15_t)0x9523, (q15_t)0xB9B4, (q15_t)0x9507, - (q15_t)0xB9DE, (q15_t)0x94EC, (q15_t)0xBA08, (q15_t)0x94D0, - (q15_t)0xBA32, (q15_t)0x94B5, (q15_t)0xBA5C, (q15_t)0x9499, - (q15_t)0xBA87, (q15_t)0x947E, (q15_t)0xBAB1, (q15_t)0x9463, - (q15_t)0xBADB, (q15_t)0x9447, (q15_t)0xBB05, (q15_t)0x942C, - (q15_t)0xBB30, (q15_t)0x9411, (q15_t)0xBB5A, (q15_t)0x93F6, - (q15_t)0xBB85, (q15_t)0x93DB, (q15_t)0xBBAF, (q15_t)0x93C0, - (q15_t)0xBBDA, (q15_t)0x93A6, (q15_t)0xBC04, (q15_t)0x938B, - (q15_t)0xBC2F, (q15_t)0x9370, (q15_t)0xBC5A, (q15_t)0x9356, - (q15_t)0xBC84, (q15_t)0x933B, (q15_t)0xBCAF, (q15_t)0x9321, - (q15_t)0xBCDA, (q15_t)0x9306, (q15_t)0xBD05, (q15_t)0x92EC, - (q15_t)0xBD2F, (q15_t)0x92D2, (q15_t)0xBD5A, (q15_t)0x92B7, - (q15_t)0xBD85, (q15_t)0x929D, (q15_t)0xBDB0, (q15_t)0x9283, - (q15_t)0xBDDB, (q15_t)0x9269, (q15_t)0xBE06, (q15_t)0x924F, - (q15_t)0xBE31, (q15_t)0x9235, (q15_t)0xBE5D, (q15_t)0x921C, - (q15_t)0xBE88, (q15_t)0x9202, (q15_t)0xBEB3, (q15_t)0x91E8, - (q15_t)0xBEDE, (q15_t)0x91CF, (q15_t)0xBF09, (q15_t)0x91B5, - (q15_t)0xBF35, (q15_t)0x919C, (q15_t)0xBF60, (q15_t)0x9182, - (q15_t)0xBF8C, (q15_t)0x9169, (q15_t)0xBFB7, (q15_t)0x9150, - (q15_t)0xBFE2, (q15_t)0x9136, (q15_t)0xC00E, (q15_t)0x911D, - (q15_t)0xC03A, (q15_t)0x9104, (q15_t)0xC065, (q15_t)0x90EB, - (q15_t)0xC091, (q15_t)0x90D2, (q15_t)0xC0BC, (q15_t)0x90B9, - (q15_t)0xC0E8, (q15_t)0x90A0, (q15_t)0xC114, (q15_t)0x9088, - (q15_t)0xC140, (q15_t)0x906F, (q15_t)0xC16C, (q15_t)0x9056, - (q15_t)0xC197, (q15_t)0x903E, (q15_t)0xC1C3, (q15_t)0x9025, - (q15_t)0xC1EF, (q15_t)0x900D, (q15_t)0xC21B, (q15_t)0x8FF5, - (q15_t)0xC247, (q15_t)0x8FDC, (q15_t)0xC273, (q15_t)0x8FC4, - (q15_t)0xC29F, (q15_t)0x8FAC, (q15_t)0xC2CC, (q15_t)0x8F94, - (q15_t)0xC2F8, (q15_t)0x8F7C, (q15_t)0xC324, (q15_t)0x8F64, - (q15_t)0xC350, (q15_t)0x8F4C, (q15_t)0xC37C, (q15_t)0x8F34, - (q15_t)0xC3A9, (q15_t)0x8F1D, (q15_t)0xC3D5, (q15_t)0x8F05, - (q15_t)0xC402, (q15_t)0x8EED, (q15_t)0xC42E, (q15_t)0x8ED6, - (q15_t)0xC45A, (q15_t)0x8EBE, (q15_t)0xC487, (q15_t)0x8EA7, - (q15_t)0xC4B3, (q15_t)0x8E90, (q15_t)0xC4E0, (q15_t)0x8E79, - (q15_t)0xC50D, (q15_t)0x8E61, (q15_t)0xC539, (q15_t)0x8E4A, - (q15_t)0xC566, (q15_t)0x8E33, (q15_t)0xC593, (q15_t)0x8E1C, - (q15_t)0xC5BF, (q15_t)0x8E05, (q15_t)0xC5EC, (q15_t)0x8DEE, - (q15_t)0xC619, (q15_t)0x8DD8, (q15_t)0xC646, (q15_t)0x8DC1, - (q15_t)0xC673, (q15_t)0x8DAA, (q15_t)0xC6A0, (q15_t)0x8D94, - (q15_t)0xC6CD, (q15_t)0x8D7D, (q15_t)0xC6F9, (q15_t)0x8D67, - (q15_t)0xC727, (q15_t)0x8D50, (q15_t)0xC754, (q15_t)0x8D3A, - (q15_t)0xC781, (q15_t)0x8D24, (q15_t)0xC7AE, (q15_t)0x8D0E, - (q15_t)0xC7DB, (q15_t)0x8CF8, (q15_t)0xC808, (q15_t)0x8CE2, - (q15_t)0xC835, (q15_t)0x8CCC, (q15_t)0xC863, (q15_t)0x8CB6, - (q15_t)0xC890, (q15_t)0x8CA0, (q15_t)0xC8BD, (q15_t)0x8C8A, - (q15_t)0xC8EB, (q15_t)0x8C75, (q15_t)0xC918, (q15_t)0x8C5F, - (q15_t)0xC945, (q15_t)0x8C4A, (q15_t)0xC973, (q15_t)0x8C34, - (q15_t)0xC9A0, (q15_t)0x8C1F, (q15_t)0xC9CE, (q15_t)0x8C09, - (q15_t)0xC9FB, (q15_t)0x8BF4, (q15_t)0xCA29, (q15_t)0x8BDF, - (q15_t)0xCA57, (q15_t)0x8BCA, (q15_t)0xCA84, (q15_t)0x8BB5, - (q15_t)0xCAB2, (q15_t)0x8BA0, (q15_t)0xCAE0, (q15_t)0x8B8B, - (q15_t)0xCB0D, (q15_t)0x8B76, (q15_t)0xCB3B, (q15_t)0x8B61, - (q15_t)0xCB69, (q15_t)0x8B4D, (q15_t)0xCB97, (q15_t)0x8B38, - (q15_t)0xCBC5, (q15_t)0x8B24, (q15_t)0xCBF3, (q15_t)0x8B0F, - (q15_t)0xCC21, (q15_t)0x8AFB, (q15_t)0xCC4F, (q15_t)0x8AE6, - (q15_t)0xCC7D, (q15_t)0x8AD2, (q15_t)0xCCAB, (q15_t)0x8ABE, - (q15_t)0xCCD9, (q15_t)0x8AAA, (q15_t)0xCD07, (q15_t)0x8A96, - (q15_t)0xCD35, (q15_t)0x8A82, (q15_t)0xCD63, (q15_t)0x8A6E, - (q15_t)0xCD91, (q15_t)0x8A5A, (q15_t)0xCDBF, (q15_t)0x8A46, - (q15_t)0xCDEE, (q15_t)0x8A33, (q15_t)0xCE1C, (q15_t)0x8A1F, - (q15_t)0xCE4A, (q15_t)0x8A0B, (q15_t)0xCE79, (q15_t)0x89F8, - (q15_t)0xCEA7, (q15_t)0x89E4, (q15_t)0xCED5, (q15_t)0x89D1, - (q15_t)0xCF04, (q15_t)0x89BE, (q15_t)0xCF32, (q15_t)0x89AB, - (q15_t)0xCF61, (q15_t)0x8997, (q15_t)0xCF8F, (q15_t)0x8984, - (q15_t)0xCFBE, (q15_t)0x8971, (q15_t)0xCFEC, (q15_t)0x895F, - (q15_t)0xD01B, (q15_t)0x894C, (q15_t)0xD04A, (q15_t)0x8939, - (q15_t)0xD078, (q15_t)0x8926, (q15_t)0xD0A7, (q15_t)0x8914, - (q15_t)0xD0D6, (q15_t)0x8901, (q15_t)0xD104, (q15_t)0x88EF, - (q15_t)0xD133, (q15_t)0x88DC, (q15_t)0xD162, (q15_t)0x88CA, - (q15_t)0xD191, (q15_t)0x88B8, (q15_t)0xD1C0, (q15_t)0x88A5, - (q15_t)0xD1EE, (q15_t)0x8893, (q15_t)0xD21D, (q15_t)0x8881, - (q15_t)0xD24C, (q15_t)0x886F, (q15_t)0xD27B, (q15_t)0x885D, - (q15_t)0xD2AA, (q15_t)0x884B, (q15_t)0xD2D9, (q15_t)0x883A, - (q15_t)0xD308, (q15_t)0x8828, (q15_t)0xD337, (q15_t)0x8816, - (q15_t)0xD367, (q15_t)0x8805, (q15_t)0xD396, (q15_t)0x87F3, - (q15_t)0xD3C5, (q15_t)0x87E2, (q15_t)0xD3F4, (q15_t)0x87D1, - (q15_t)0xD423, (q15_t)0x87BF, (q15_t)0xD452, (q15_t)0x87AE, - (q15_t)0xD482, (q15_t)0x879D, (q15_t)0xD4B1, (q15_t)0x878C, - (q15_t)0xD4E0, (q15_t)0x877B, (q15_t)0xD510, (q15_t)0x876A, - (q15_t)0xD53F, (q15_t)0x8759, (q15_t)0xD56E, (q15_t)0x8749, - (q15_t)0xD59E, (q15_t)0x8738, (q15_t)0xD5CD, (q15_t)0x8727, - (q15_t)0xD5FD, (q15_t)0x8717, (q15_t)0xD62C, (q15_t)0x8706, - (q15_t)0xD65C, (q15_t)0x86F6, (q15_t)0xD68B, (q15_t)0x86E6, - (q15_t)0xD6BB, (q15_t)0x86D5, (q15_t)0xD6EA, (q15_t)0x86C5, - (q15_t)0xD71A, (q15_t)0x86B5, (q15_t)0xD74A, (q15_t)0x86A5, - (q15_t)0xD779, (q15_t)0x8695, (q15_t)0xD7A9, (q15_t)0x8685, - (q15_t)0xD7D9, (q15_t)0x8675, (q15_t)0xD809, (q15_t)0x8666, - (q15_t)0xD838, (q15_t)0x8656, (q15_t)0xD868, (q15_t)0x8646, - (q15_t)0xD898, (q15_t)0x8637, (q15_t)0xD8C8, (q15_t)0x8627, - (q15_t)0xD8F8, (q15_t)0x8618, (q15_t)0xD927, (q15_t)0x8609, - (q15_t)0xD957, (q15_t)0x85FA, (q15_t)0xD987, (q15_t)0x85EA, - (q15_t)0xD9B7, (q15_t)0x85DB, (q15_t)0xD9E7, (q15_t)0x85CC, - (q15_t)0xDA17, (q15_t)0x85BD, (q15_t)0xDA47, (q15_t)0x85AF, - (q15_t)0xDA77, (q15_t)0x85A0, (q15_t)0xDAA7, (q15_t)0x8591, - (q15_t)0xDAD7, (q15_t)0x8582, (q15_t)0xDB08, (q15_t)0x8574, - (q15_t)0xDB38, (q15_t)0x8565, (q15_t)0xDB68, (q15_t)0x8557, - (q15_t)0xDB98, (q15_t)0x8549, (q15_t)0xDBC8, (q15_t)0x853A, - (q15_t)0xDBF8, (q15_t)0x852C, (q15_t)0xDC29, (q15_t)0x851E, - (q15_t)0xDC59, (q15_t)0x8510, (q15_t)0xDC89, (q15_t)0x8502, - (q15_t)0xDCBA, (q15_t)0x84F4, (q15_t)0xDCEA, (q15_t)0x84E6, - (q15_t)0xDD1A, (q15_t)0x84D9, (q15_t)0xDD4B, (q15_t)0x84CB, - (q15_t)0xDD7B, (q15_t)0x84BD, (q15_t)0xDDAB, (q15_t)0x84B0, - (q15_t)0xDDDC, (q15_t)0x84A2, (q15_t)0xDE0C, (q15_t)0x8495, - (q15_t)0xDE3D, (q15_t)0x8488, (q15_t)0xDE6D, (q15_t)0x847B, - (q15_t)0xDE9E, (q15_t)0x846D, (q15_t)0xDECE, (q15_t)0x8460, - (q15_t)0xDEFF, (q15_t)0x8453, (q15_t)0xDF2F, (q15_t)0x8446, - (q15_t)0xDF60, (q15_t)0x843A, (q15_t)0xDF91, (q15_t)0x842D, - (q15_t)0xDFC1, (q15_t)0x8420, (q15_t)0xDFF2, (q15_t)0x8414, - (q15_t)0xE023, (q15_t)0x8407, (q15_t)0xE053, (q15_t)0x83FA, - (q15_t)0xE084, (q15_t)0x83EE, (q15_t)0xE0B5, (q15_t)0x83E2, - (q15_t)0xE0E6, (q15_t)0x83D6, (q15_t)0xE116, (q15_t)0x83C9, - (q15_t)0xE147, (q15_t)0x83BD, (q15_t)0xE178, (q15_t)0x83B1, - (q15_t)0xE1A9, (q15_t)0x83A5, (q15_t)0xE1DA, (q15_t)0x8399, - (q15_t)0xE20A, (q15_t)0x838E, (q15_t)0xE23B, (q15_t)0x8382, - (q15_t)0xE26C, (q15_t)0x8376, (q15_t)0xE29D, (q15_t)0x836B, - (q15_t)0xE2CE, (q15_t)0x835F, (q15_t)0xE2FF, (q15_t)0x8354, - (q15_t)0xE330, (q15_t)0x8348, (q15_t)0xE361, (q15_t)0x833D, - (q15_t)0xE392, (q15_t)0x8332, (q15_t)0xE3C3, (q15_t)0x8327, - (q15_t)0xE3F4, (q15_t)0x831C, (q15_t)0xE425, (q15_t)0x8311, - (q15_t)0xE456, (q15_t)0x8306, (q15_t)0xE487, (q15_t)0x82FB, - (q15_t)0xE4B8, (q15_t)0x82F0, (q15_t)0xE4E9, (q15_t)0x82E6, - (q15_t)0xE51B, (q15_t)0x82DB, (q15_t)0xE54C, (q15_t)0x82D0, - (q15_t)0xE57D, (q15_t)0x82C6, (q15_t)0xE5AE, (q15_t)0x82BC, - (q15_t)0xE5DF, (q15_t)0x82B1, (q15_t)0xE610, (q15_t)0x82A7, - (q15_t)0xE642, (q15_t)0x829D, (q15_t)0xE673, (q15_t)0x8293, - (q15_t)0xE6A4, (q15_t)0x8289, (q15_t)0xE6D5, (q15_t)0x827F, - (q15_t)0xE707, (q15_t)0x8275, (q15_t)0xE738, (q15_t)0x826B, - (q15_t)0xE769, (q15_t)0x8262, (q15_t)0xE79B, (q15_t)0x8258, - (q15_t)0xE7CC, (q15_t)0x824F, (q15_t)0xE7FD, (q15_t)0x8245, - (q15_t)0xE82F, (q15_t)0x823C, (q15_t)0xE860, (q15_t)0x8232, - (q15_t)0xE892, (q15_t)0x8229, (q15_t)0xE8C3, (q15_t)0x8220, - (q15_t)0xE8F5, (q15_t)0x8217, (q15_t)0xE926, (q15_t)0x820E, - (q15_t)0xE957, (q15_t)0x8205, (q15_t)0xE989, (q15_t)0x81FC, - (q15_t)0xE9BA, (q15_t)0x81F3, (q15_t)0xE9EC, (q15_t)0x81EB, - (q15_t)0xEA1D, (q15_t)0x81E2, (q15_t)0xEA4F, (q15_t)0x81D9, - (q15_t)0xEA80, (q15_t)0x81D1, (q15_t)0xEAB2, (q15_t)0x81C8, - (q15_t)0xEAE4, (q15_t)0x81C0, (q15_t)0xEB15, (q15_t)0x81B8, - (q15_t)0xEB47, (q15_t)0x81B0, (q15_t)0xEB78, (q15_t)0x81A8, - (q15_t)0xEBAA, (q15_t)0x81A0, (q15_t)0xEBDC, (q15_t)0x8198, - (q15_t)0xEC0D, (q15_t)0x8190, (q15_t)0xEC3F, (q15_t)0x8188, - (q15_t)0xEC71, (q15_t)0x8180, (q15_t)0xECA2, (q15_t)0x8179, - (q15_t)0xECD4, (q15_t)0x8171, (q15_t)0xED06, (q15_t)0x816A, - (q15_t)0xED37, (q15_t)0x8162, (q15_t)0xED69, (q15_t)0x815B, - (q15_t)0xED9B, (q15_t)0x8154, (q15_t)0xEDCD, (q15_t)0x814C, - (q15_t)0xEDFE, (q15_t)0x8145, (q15_t)0xEE30, (q15_t)0x813E, - (q15_t)0xEE62, (q15_t)0x8137, (q15_t)0xEE94, (q15_t)0x8130, - (q15_t)0xEEC6, (q15_t)0x812A, (q15_t)0xEEF7, (q15_t)0x8123, - (q15_t)0xEF29, (q15_t)0x811C, (q15_t)0xEF5B, (q15_t)0x8116, - (q15_t)0xEF8D, (q15_t)0x810F, (q15_t)0xEFBF, (q15_t)0x8109, - (q15_t)0xEFF1, (q15_t)0x8102, (q15_t)0xF022, (q15_t)0x80FC, - (q15_t)0xF054, (q15_t)0x80F6, (q15_t)0xF086, (q15_t)0x80F0, - (q15_t)0xF0B8, (q15_t)0x80EA, (q15_t)0xF0EA, (q15_t)0x80E4, - (q15_t)0xF11C, (q15_t)0x80DE, (q15_t)0xF14E, (q15_t)0x80D8, - (q15_t)0xF180, (q15_t)0x80D2, (q15_t)0xF1B2, (q15_t)0x80CD, - (q15_t)0xF1E4, (q15_t)0x80C7, (q15_t)0xF216, (q15_t)0x80C2, - (q15_t)0xF248, (q15_t)0x80BC, (q15_t)0xF27A, (q15_t)0x80B7, - (q15_t)0xF2AC, (q15_t)0x80B2, (q15_t)0xF2DE, (q15_t)0x80AC, - (q15_t)0xF310, (q15_t)0x80A7, (q15_t)0xF342, (q15_t)0x80A2, - (q15_t)0xF374, (q15_t)0x809D, (q15_t)0xF3A6, (q15_t)0x8098, - (q15_t)0xF3D8, (q15_t)0x8094, (q15_t)0xF40A, (q15_t)0x808F, - (q15_t)0xF43C, (q15_t)0x808A, (q15_t)0xF46E, (q15_t)0x8086, - (q15_t)0xF4A0, (q15_t)0x8081, (q15_t)0xF4D2, (q15_t)0x807D, - (q15_t)0xF504, (q15_t)0x8078, (q15_t)0xF536, (q15_t)0x8074, - (q15_t)0xF568, (q15_t)0x8070, (q15_t)0xF59A, (q15_t)0x806C, - (q15_t)0xF5CC, (q15_t)0x8068, (q15_t)0xF5FF, (q15_t)0x8064, - (q15_t)0xF631, (q15_t)0x8060, (q15_t)0xF663, (q15_t)0x805C, - (q15_t)0xF695, (q15_t)0x8058, (q15_t)0xF6C7, (q15_t)0x8055, - (q15_t)0xF6F9, (q15_t)0x8051, (q15_t)0xF72B, (q15_t)0x804E, - (q15_t)0xF75D, (q15_t)0x804A, (q15_t)0xF790, (q15_t)0x8047, - (q15_t)0xF7C2, (q15_t)0x8043, (q15_t)0xF7F4, (q15_t)0x8040, - (q15_t)0xF826, (q15_t)0x803D, (q15_t)0xF858, (q15_t)0x803A, - (q15_t)0xF88A, (q15_t)0x8037, (q15_t)0xF8BD, (q15_t)0x8034, - (q15_t)0xF8EF, (q15_t)0x8031, (q15_t)0xF921, (q15_t)0x802F, - (q15_t)0xF953, (q15_t)0x802C, (q15_t)0xF985, (q15_t)0x8029, - (q15_t)0xF9B8, (q15_t)0x8027, (q15_t)0xF9EA, (q15_t)0x8025, - (q15_t)0xFA1C, (q15_t)0x8022, (q15_t)0xFA4E, (q15_t)0x8020, - (q15_t)0xFA80, (q15_t)0x801E, (q15_t)0xFAB3, (q15_t)0x801C, - (q15_t)0xFAE5, (q15_t)0x801A, (q15_t)0xFB17, (q15_t)0x8018, - (q15_t)0xFB49, (q15_t)0x8016, (q15_t)0xFB7C, (q15_t)0x8014, - (q15_t)0xFBAE, (q15_t)0x8012, (q15_t)0xFBE0, (q15_t)0x8011, - (q15_t)0xFC12, (q15_t)0x800F, (q15_t)0xFC45, (q15_t)0x800D, - (q15_t)0xFC77, (q15_t)0x800C, (q15_t)0xFCA9, (q15_t)0x800B, - (q15_t)0xFCDB, (q15_t)0x8009, (q15_t)0xFD0E, (q15_t)0x8008, - (q15_t)0xFD40, (q15_t)0x8007, (q15_t)0xFD72, (q15_t)0x8006, - (q15_t)0xFDA4, (q15_t)0x8005, (q15_t)0xFDD7, (q15_t)0x8004, - (q15_t)0xFE09, (q15_t)0x8003, (q15_t)0xFE3B, (q15_t)0x8003, - (q15_t)0xFE6D, (q15_t)0x8002, (q15_t)0xFEA0, (q15_t)0x8001, - (q15_t)0xFED2, (q15_t)0x8001, (q15_t)0xFF04, (q15_t)0x8000, - (q15_t)0xFF36, (q15_t)0x8000, (q15_t)0xFF69, (q15_t)0x8000, - (q15_t)0xFF9B, (q15_t)0x8000, (q15_t)0xFFCD, (q15_t)0x8000 -}; - +const q15_t twiddleCoef_4096_q15[6144] = { + (q15_t)0x7FFF, (q15_t)0x0000, (q15_t)0x7FFF, (q15_t)0x0032, (q15_t)0x7FFF, + (q15_t)0x0064, (q15_t)0x7FFF, (q15_t)0x0096, (q15_t)0x7FFF, (q15_t)0x00C9, + (q15_t)0x7FFF, (q15_t)0x00FB, (q15_t)0x7FFE, (q15_t)0x012D, (q15_t)0x7FFE, + (q15_t)0x015F, (q15_t)0x7FFD, (q15_t)0x0192, (q15_t)0x7FFC, (q15_t)0x01C4, + (q15_t)0x7FFC, (q15_t)0x01F6, (q15_t)0x7FFB, (q15_t)0x0228, (q15_t)0x7FFA, + (q15_t)0x025B, (q15_t)0x7FF9, (q15_t)0x028D, (q15_t)0x7FF8, (q15_t)0x02BF, + (q15_t)0x7FF7, (q15_t)0x02F1, (q15_t)0x7FF6, (q15_t)0x0324, (q15_t)0x7FF4, + (q15_t)0x0356, (q15_t)0x7FF3, (q15_t)0x0388, (q15_t)0x7FF2, (q15_t)0x03BA, + (q15_t)0x7FF0, (q15_t)0x03ED, (q15_t)0x7FEE, (q15_t)0x041F, (q15_t)0x7FED, + (q15_t)0x0451, (q15_t)0x7FEB, (q15_t)0x0483, (q15_t)0x7FE9, (q15_t)0x04B6, + (q15_t)0x7FE7, (q15_t)0x04E8, (q15_t)0x7FE5, (q15_t)0x051A, (q15_t)0x7FE3, + (q15_t)0x054C, (q15_t)0x7FE1, (q15_t)0x057F, (q15_t)0x7FDF, (q15_t)0x05B1, + (q15_t)0x7FDD, (q15_t)0x05E3, (q15_t)0x7FDA, (q15_t)0x0615, (q15_t)0x7FD8, + (q15_t)0x0647, (q15_t)0x7FD6, (q15_t)0x067A, (q15_t)0x7FD3, (q15_t)0x06AC, + (q15_t)0x7FD0, (q15_t)0x06DE, (q15_t)0x7FCE, (q15_t)0x0710, (q15_t)0x7FCB, + (q15_t)0x0742, (q15_t)0x7FC8, (q15_t)0x0775, (q15_t)0x7FC5, (q15_t)0x07A7, + (q15_t)0x7FC2, (q15_t)0x07D9, (q15_t)0x7FBF, (q15_t)0x080B, (q15_t)0x7FBC, + (q15_t)0x083D, (q15_t)0x7FB8, (q15_t)0x086F, (q15_t)0x7FB5, (q15_t)0x08A2, + (q15_t)0x7FB1, (q15_t)0x08D4, (q15_t)0x7FAE, (q15_t)0x0906, (q15_t)0x7FAA, + (q15_t)0x0938, (q15_t)0x7FA7, (q15_t)0x096A, (q15_t)0x7FA3, (q15_t)0x099C, + (q15_t)0x7F9F, (q15_t)0x09CE, (q15_t)0x7F9B, (q15_t)0x0A00, (q15_t)0x7F97, + (q15_t)0x0A33, (q15_t)0x7F93, (q15_t)0x0A65, (q15_t)0x7F8F, (q15_t)0x0A97, + (q15_t)0x7F8B, (q15_t)0x0AC9, (q15_t)0x7F87, (q15_t)0x0AFB, (q15_t)0x7F82, + (q15_t)0x0B2D, (q15_t)0x7F7E, (q15_t)0x0B5F, (q15_t)0x7F79, (q15_t)0x0B91, + (q15_t)0x7F75, (q15_t)0x0BC3, (q15_t)0x7F70, (q15_t)0x0BF5, (q15_t)0x7F6B, + (q15_t)0x0C27, (q15_t)0x7F67, (q15_t)0x0C59, (q15_t)0x7F62, (q15_t)0x0C8B, + (q15_t)0x7F5D, (q15_t)0x0CBD, (q15_t)0x7F58, (q15_t)0x0CEF, (q15_t)0x7F53, + (q15_t)0x0D21, (q15_t)0x7F4D, (q15_t)0x0D53, (q15_t)0x7F48, (q15_t)0x0D85, + (q15_t)0x7F43, (q15_t)0x0DB7, (q15_t)0x7F3D, (q15_t)0x0DE9, (q15_t)0x7F38, + (q15_t)0x0E1B, (q15_t)0x7F32, (q15_t)0x0E4D, (q15_t)0x7F2D, (q15_t)0x0E7F, + (q15_t)0x7F27, (q15_t)0x0EB1, (q15_t)0x7F21, (q15_t)0x0EE3, (q15_t)0x7F1B, + (q15_t)0x0F15, (q15_t)0x7F15, (q15_t)0x0F47, (q15_t)0x7F0F, (q15_t)0x0F79, + (q15_t)0x7F09, (q15_t)0x0FAB, (q15_t)0x7F03, (q15_t)0x0FDD, (q15_t)0x7EFD, + (q15_t)0x100E, (q15_t)0x7EF6, (q15_t)0x1040, (q15_t)0x7EF0, (q15_t)0x1072, + (q15_t)0x7EE9, (q15_t)0x10A4, (q15_t)0x7EE3, (q15_t)0x10D6, (q15_t)0x7EDC, + (q15_t)0x1108, (q15_t)0x7ED5, (q15_t)0x1139, (q15_t)0x7ECF, (q15_t)0x116B, + (q15_t)0x7EC8, (q15_t)0x119D, (q15_t)0x7EC1, (q15_t)0x11CF, (q15_t)0x7EBA, + (q15_t)0x1201, (q15_t)0x7EB3, (q15_t)0x1232, (q15_t)0x7EAB, (q15_t)0x1264, + (q15_t)0x7EA4, (q15_t)0x1296, (q15_t)0x7E9D, (q15_t)0x12C8, (q15_t)0x7E95, + (q15_t)0x12F9, (q15_t)0x7E8E, (q15_t)0x132B, (q15_t)0x7E86, (q15_t)0x135D, + (q15_t)0x7E7F, (q15_t)0x138E, (q15_t)0x7E77, (q15_t)0x13C0, (q15_t)0x7E6F, + (q15_t)0x13F2, (q15_t)0x7E67, (q15_t)0x1423, (q15_t)0x7E5F, (q15_t)0x1455, + (q15_t)0x7E57, (q15_t)0x1487, (q15_t)0x7E4F, (q15_t)0x14B8, (q15_t)0x7E47, + (q15_t)0x14EA, (q15_t)0x7E3F, (q15_t)0x151B, (q15_t)0x7E37, (q15_t)0x154D, + (q15_t)0x7E2E, (q15_t)0x157F, (q15_t)0x7E26, (q15_t)0x15B0, (q15_t)0x7E1D, + (q15_t)0x15E2, (q15_t)0x7E14, (q15_t)0x1613, (q15_t)0x7E0C, (q15_t)0x1645, + (q15_t)0x7E03, (q15_t)0x1676, (q15_t)0x7DFA, (q15_t)0x16A8, (q15_t)0x7DF1, + (q15_t)0x16D9, (q15_t)0x7DE8, (q15_t)0x170A, (q15_t)0x7DDF, (q15_t)0x173C, + (q15_t)0x7DD6, (q15_t)0x176D, (q15_t)0x7DCD, (q15_t)0x179F, (q15_t)0x7DC3, + (q15_t)0x17D0, (q15_t)0x7DBA, (q15_t)0x1802, (q15_t)0x7DB0, (q15_t)0x1833, + (q15_t)0x7DA7, (q15_t)0x1864, (q15_t)0x7D9D, (q15_t)0x1896, (q15_t)0x7D94, + (q15_t)0x18C7, (q15_t)0x7D8A, (q15_t)0x18F8, (q15_t)0x7D80, (q15_t)0x192A, + (q15_t)0x7D76, (q15_t)0x195B, (q15_t)0x7D6C, (q15_t)0x198C, (q15_t)0x7D62, + (q15_t)0x19BD, (q15_t)0x7D58, (q15_t)0x19EF, (q15_t)0x7D4E, (q15_t)0x1A20, + (q15_t)0x7D43, (q15_t)0x1A51, (q15_t)0x7D39, (q15_t)0x1A82, (q15_t)0x7D2F, + (q15_t)0x1AB3, (q15_t)0x7D24, (q15_t)0x1AE4, (q15_t)0x7D19, (q15_t)0x1B16, + (q15_t)0x7D0F, (q15_t)0x1B47, (q15_t)0x7D04, (q15_t)0x1B78, (q15_t)0x7CF9, + (q15_t)0x1BA9, (q15_t)0x7CEE, (q15_t)0x1BDA, (q15_t)0x7CE3, (q15_t)0x1C0B, + (q15_t)0x7CD8, (q15_t)0x1C3C, (q15_t)0x7CCD, (q15_t)0x1C6D, (q15_t)0x7CC2, + (q15_t)0x1C9E, (q15_t)0x7CB7, (q15_t)0x1CCF, (q15_t)0x7CAB, (q15_t)0x1D00, + (q15_t)0x7CA0, (q15_t)0x1D31, (q15_t)0x7C94, (q15_t)0x1D62, (q15_t)0x7C89, + (q15_t)0x1D93, (q15_t)0x7C7D, (q15_t)0x1DC4, (q15_t)0x7C71, (q15_t)0x1DF5, + (q15_t)0x7C66, (q15_t)0x1E25, (q15_t)0x7C5A, (q15_t)0x1E56, (q15_t)0x7C4E, + (q15_t)0x1E87, (q15_t)0x7C42, (q15_t)0x1EB8, (q15_t)0x7C36, (q15_t)0x1EE9, + (q15_t)0x7C29, (q15_t)0x1F19, (q15_t)0x7C1D, (q15_t)0x1F4A, (q15_t)0x7C11, + (q15_t)0x1F7B, (q15_t)0x7C05, (q15_t)0x1FAC, (q15_t)0x7BF8, (q15_t)0x1FDC, + (q15_t)0x7BEB, (q15_t)0x200D, (q15_t)0x7BDF, (q15_t)0x203E, (q15_t)0x7BD2, + (q15_t)0x206E, (q15_t)0x7BC5, (q15_t)0x209F, (q15_t)0x7BB9, (q15_t)0x20D0, + (q15_t)0x7BAC, (q15_t)0x2100, (q15_t)0x7B9F, (q15_t)0x2131, (q15_t)0x7B92, + (q15_t)0x2161, (q15_t)0x7B84, (q15_t)0x2192, (q15_t)0x7B77, (q15_t)0x21C2, + (q15_t)0x7B6A, (q15_t)0x21F3, (q15_t)0x7B5D, (q15_t)0x2223, (q15_t)0x7B4F, + (q15_t)0x2254, (q15_t)0x7B42, (q15_t)0x2284, (q15_t)0x7B34, (q15_t)0x22B4, + (q15_t)0x7B26, (q15_t)0x22E5, (q15_t)0x7B19, (q15_t)0x2315, (q15_t)0x7B0B, + (q15_t)0x2345, (q15_t)0x7AFD, (q15_t)0x2376, (q15_t)0x7AEF, (q15_t)0x23A6, + (q15_t)0x7AE1, (q15_t)0x23D6, (q15_t)0x7AD3, (q15_t)0x2407, (q15_t)0x7AC5, + (q15_t)0x2437, (q15_t)0x7AB6, (q15_t)0x2467, (q15_t)0x7AA8, (q15_t)0x2497, + (q15_t)0x7A9A, (q15_t)0x24C7, (q15_t)0x7A8B, (q15_t)0x24F7, (q15_t)0x7A7D, + (q15_t)0x2528, (q15_t)0x7A6E, (q15_t)0x2558, (q15_t)0x7A5F, (q15_t)0x2588, + (q15_t)0x7A50, (q15_t)0x25B8, (q15_t)0x7A42, (q15_t)0x25E8, (q15_t)0x7A33, + (q15_t)0x2618, (q15_t)0x7A24, (q15_t)0x2648, (q15_t)0x7A15, (q15_t)0x2678, + (q15_t)0x7A05, (q15_t)0x26A8, (q15_t)0x79F6, (q15_t)0x26D8, (q15_t)0x79E7, + (q15_t)0x2707, (q15_t)0x79D8, (q15_t)0x2737, (q15_t)0x79C8, (q15_t)0x2767, + (q15_t)0x79B9, (q15_t)0x2797, (q15_t)0x79A9, (q15_t)0x27C7, (q15_t)0x7999, + (q15_t)0x27F6, (q15_t)0x798A, (q15_t)0x2826, (q15_t)0x797A, (q15_t)0x2856, + (q15_t)0x796A, (q15_t)0x2886, (q15_t)0x795A, (q15_t)0x28B5, (q15_t)0x794A, + (q15_t)0x28E5, (q15_t)0x793A, (q15_t)0x2915, (q15_t)0x792A, (q15_t)0x2944, + (q15_t)0x7919, (q15_t)0x2974, (q15_t)0x7909, (q15_t)0x29A3, (q15_t)0x78F9, + (q15_t)0x29D3, (q15_t)0x78E8, (q15_t)0x2A02, (q15_t)0x78D8, (q15_t)0x2A32, + (q15_t)0x78C7, (q15_t)0x2A61, (q15_t)0x78B6, (q15_t)0x2A91, (q15_t)0x78A6, + (q15_t)0x2AC0, (q15_t)0x7895, (q15_t)0x2AEF, (q15_t)0x7884, (q15_t)0x2B1F, + (q15_t)0x7873, (q15_t)0x2B4E, (q15_t)0x7862, (q15_t)0x2B7D, (q15_t)0x7851, + (q15_t)0x2BAD, (q15_t)0x7840, (q15_t)0x2BDC, (q15_t)0x782E, (q15_t)0x2C0B, + (q15_t)0x781D, (q15_t)0x2C3A, (q15_t)0x780C, (q15_t)0x2C69, (q15_t)0x77FA, + (q15_t)0x2C98, (q15_t)0x77E9, (q15_t)0x2CC8, (q15_t)0x77D7, (q15_t)0x2CF7, + (q15_t)0x77C5, (q15_t)0x2D26, (q15_t)0x77B4, (q15_t)0x2D55, (q15_t)0x77A2, + (q15_t)0x2D84, (q15_t)0x7790, (q15_t)0x2DB3, (q15_t)0x777E, (q15_t)0x2DE2, + (q15_t)0x776C, (q15_t)0x2E11, (q15_t)0x775A, (q15_t)0x2E3F, (q15_t)0x7747, + (q15_t)0x2E6E, (q15_t)0x7735, (q15_t)0x2E9D, (q15_t)0x7723, (q15_t)0x2ECC, + (q15_t)0x7710, (q15_t)0x2EFB, (q15_t)0x76FE, (q15_t)0x2F29, (q15_t)0x76EB, + (q15_t)0x2F58, (q15_t)0x76D9, (q15_t)0x2F87, (q15_t)0x76C6, (q15_t)0x2FB5, + (q15_t)0x76B3, (q15_t)0x2FE4, (q15_t)0x76A0, (q15_t)0x3013, (q15_t)0x768E, + (q15_t)0x3041, (q15_t)0x767B, (q15_t)0x3070, (q15_t)0x7668, (q15_t)0x309E, + (q15_t)0x7654, (q15_t)0x30CD, (q15_t)0x7641, (q15_t)0x30FB, (q15_t)0x762E, + (q15_t)0x312A, (q15_t)0x761B, (q15_t)0x3158, (q15_t)0x7607, (q15_t)0x3186, + (q15_t)0x75F4, (q15_t)0x31B5, (q15_t)0x75E0, (q15_t)0x31E3, (q15_t)0x75CC, + (q15_t)0x3211, (q15_t)0x75B9, (q15_t)0x3240, (q15_t)0x75A5, (q15_t)0x326E, + (q15_t)0x7591, (q15_t)0x329C, (q15_t)0x757D, (q15_t)0x32CA, (q15_t)0x7569, + (q15_t)0x32F8, (q15_t)0x7555, (q15_t)0x3326, (q15_t)0x7541, (q15_t)0x3354, + (q15_t)0x752D, (q15_t)0x3382, (q15_t)0x7519, (q15_t)0x33B0, (q15_t)0x7504, + (q15_t)0x33DE, (q15_t)0x74F0, (q15_t)0x340C, (q15_t)0x74DB, (q15_t)0x343A, + (q15_t)0x74C7, (q15_t)0x3468, (q15_t)0x74B2, (q15_t)0x3496, (q15_t)0x749E, + (q15_t)0x34C4, (q15_t)0x7489, (q15_t)0x34F2, (q15_t)0x7474, (q15_t)0x351F, + (q15_t)0x745F, (q15_t)0x354D, (q15_t)0x744A, (q15_t)0x357B, (q15_t)0x7435, + (q15_t)0x35A8, (q15_t)0x7420, (q15_t)0x35D6, (q15_t)0x740B, (q15_t)0x3604, + (q15_t)0x73F6, (q15_t)0x3631, (q15_t)0x73E0, (q15_t)0x365F, (q15_t)0x73CB, + (q15_t)0x368C, (q15_t)0x73B5, (q15_t)0x36BA, (q15_t)0x73A0, (q15_t)0x36E7, + (q15_t)0x738A, (q15_t)0x3714, (q15_t)0x7375, (q15_t)0x3742, (q15_t)0x735F, + (q15_t)0x376F, (q15_t)0x7349, (q15_t)0x379C, (q15_t)0x7333, (q15_t)0x37CA, + (q15_t)0x731D, (q15_t)0x37F7, (q15_t)0x7307, (q15_t)0x3824, (q15_t)0x72F1, + (q15_t)0x3851, (q15_t)0x72DB, (q15_t)0x387E, (q15_t)0x72C5, (q15_t)0x38AB, + (q15_t)0x72AF, (q15_t)0x38D8, (q15_t)0x7298, (q15_t)0x3906, (q15_t)0x7282, + (q15_t)0x3932, (q15_t)0x726B, (q15_t)0x395F, (q15_t)0x7255, (q15_t)0x398C, + (q15_t)0x723E, (q15_t)0x39B9, (q15_t)0x7227, (q15_t)0x39E6, (q15_t)0x7211, + (q15_t)0x3A13, (q15_t)0x71FA, (q15_t)0x3A40, (q15_t)0x71E3, (q15_t)0x3A6C, + (q15_t)0x71CC, (q15_t)0x3A99, (q15_t)0x71B5, (q15_t)0x3AC6, (q15_t)0x719E, + (q15_t)0x3AF2, (q15_t)0x7186, (q15_t)0x3B1F, (q15_t)0x716F, (q15_t)0x3B4C, + (q15_t)0x7158, (q15_t)0x3B78, (q15_t)0x7141, (q15_t)0x3BA5, (q15_t)0x7129, + (q15_t)0x3BD1, (q15_t)0x7112, (q15_t)0x3BFD, (q15_t)0x70FA, (q15_t)0x3C2A, + (q15_t)0x70E2, (q15_t)0x3C56, (q15_t)0x70CB, (q15_t)0x3C83, (q15_t)0x70B3, + (q15_t)0x3CAF, (q15_t)0x709B, (q15_t)0x3CDB, (q15_t)0x7083, (q15_t)0x3D07, + (q15_t)0x706B, (q15_t)0x3D33, (q15_t)0x7053, (q15_t)0x3D60, (q15_t)0x703B, + (q15_t)0x3D8C, (q15_t)0x7023, (q15_t)0x3DB8, (q15_t)0x700A, (q15_t)0x3DE4, + (q15_t)0x6FF2, (q15_t)0x3E10, (q15_t)0x6FDA, (q15_t)0x3E3C, (q15_t)0x6FC1, + (q15_t)0x3E68, (q15_t)0x6FA9, (q15_t)0x3E93, (q15_t)0x6F90, (q15_t)0x3EBF, + (q15_t)0x6F77, (q15_t)0x3EEB, (q15_t)0x6F5F, (q15_t)0x3F17, (q15_t)0x6F46, + (q15_t)0x3F43, (q15_t)0x6F2D, (q15_t)0x3F6E, (q15_t)0x6F14, (q15_t)0x3F9A, + (q15_t)0x6EFB, (q15_t)0x3FC5, (q15_t)0x6EE2, (q15_t)0x3FF1, (q15_t)0x6EC9, + (q15_t)0x401D, (q15_t)0x6EAF, (q15_t)0x4048, (q15_t)0x6E96, (q15_t)0x4073, + (q15_t)0x6E7D, (q15_t)0x409F, (q15_t)0x6E63, (q15_t)0x40CA, (q15_t)0x6E4A, + (q15_t)0x40F6, (q15_t)0x6E30, (q15_t)0x4121, (q15_t)0x6E17, (q15_t)0x414C, + (q15_t)0x6DFD, (q15_t)0x4177, (q15_t)0x6DE3, (q15_t)0x41A2, (q15_t)0x6DCA, + (q15_t)0x41CE, (q15_t)0x6DB0, (q15_t)0x41F9, (q15_t)0x6D96, (q15_t)0x4224, + (q15_t)0x6D7C, (q15_t)0x424F, (q15_t)0x6D62, (q15_t)0x427A, (q15_t)0x6D48, + (q15_t)0x42A5, (q15_t)0x6D2D, (q15_t)0x42D0, (q15_t)0x6D13, (q15_t)0x42FA, + (q15_t)0x6CF9, (q15_t)0x4325, (q15_t)0x6CDE, (q15_t)0x4350, (q15_t)0x6CC4, + (q15_t)0x437B, (q15_t)0x6CA9, (q15_t)0x43A5, (q15_t)0x6C8F, (q15_t)0x43D0, + (q15_t)0x6C74, (q15_t)0x43FB, (q15_t)0x6C59, (q15_t)0x4425, (q15_t)0x6C3F, + (q15_t)0x4450, (q15_t)0x6C24, (q15_t)0x447A, (q15_t)0x6C09, (q15_t)0x44A5, + (q15_t)0x6BEE, (q15_t)0x44CF, (q15_t)0x6BD3, (q15_t)0x44FA, (q15_t)0x6BB8, + (q15_t)0x4524, (q15_t)0x6B9C, (q15_t)0x454E, (q15_t)0x6B81, (q15_t)0x4578, + (q15_t)0x6B66, (q15_t)0x45A3, (q15_t)0x6B4A, (q15_t)0x45CD, (q15_t)0x6B2F, + (q15_t)0x45F7, (q15_t)0x6B13, (q15_t)0x4621, (q15_t)0x6AF8, (q15_t)0x464B, + (q15_t)0x6ADC, (q15_t)0x4675, (q15_t)0x6AC1, (q15_t)0x469F, (q15_t)0x6AA5, + (q15_t)0x46C9, (q15_t)0x6A89, (q15_t)0x46F3, (q15_t)0x6A6D, (q15_t)0x471C, + (q15_t)0x6A51, (q15_t)0x4746, (q15_t)0x6A35, (q15_t)0x4770, (q15_t)0x6A19, + (q15_t)0x479A, (q15_t)0x69FD, (q15_t)0x47C3, (q15_t)0x69E1, (q15_t)0x47ED, + (q15_t)0x69C4, (q15_t)0x4816, (q15_t)0x69A8, (q15_t)0x4840, (q15_t)0x698C, + (q15_t)0x4869, (q15_t)0x696F, (q15_t)0x4893, (q15_t)0x6953, (q15_t)0x48BC, + (q15_t)0x6936, (q15_t)0x48E6, (q15_t)0x6919, (q15_t)0x490F, (q15_t)0x68FD, + (q15_t)0x4938, (q15_t)0x68E0, (q15_t)0x4961, (q15_t)0x68C3, (q15_t)0x498A, + (q15_t)0x68A6, (q15_t)0x49B4, (q15_t)0x6889, (q15_t)0x49DD, (q15_t)0x686C, + (q15_t)0x4A06, (q15_t)0x684F, (q15_t)0x4A2F, (q15_t)0x6832, (q15_t)0x4A58, + (q15_t)0x6815, (q15_t)0x4A81, (q15_t)0x67F7, (q15_t)0x4AA9, (q15_t)0x67DA, + (q15_t)0x4AD2, (q15_t)0x67BD, (q15_t)0x4AFB, (q15_t)0x679F, (q15_t)0x4B24, + (q15_t)0x6782, (q15_t)0x4B4C, (q15_t)0x6764, (q15_t)0x4B75, (q15_t)0x6746, + (q15_t)0x4B9E, (q15_t)0x6729, (q15_t)0x4BC6, (q15_t)0x670B, (q15_t)0x4BEF, + (q15_t)0x66ED, (q15_t)0x4C17, (q15_t)0x66CF, (q15_t)0x4C3F, (q15_t)0x66B1, + (q15_t)0x4C68, (q15_t)0x6693, (q15_t)0x4C90, (q15_t)0x6675, (q15_t)0x4CB8, + (q15_t)0x6657, (q15_t)0x4CE1, (q15_t)0x6639, (q15_t)0x4D09, (q15_t)0x661A, + (q15_t)0x4D31, (q15_t)0x65FC, (q15_t)0x4D59, (q15_t)0x65DD, (q15_t)0x4D81, + (q15_t)0x65BF, (q15_t)0x4DA9, (q15_t)0x65A0, (q15_t)0x4DD1, (q15_t)0x6582, + (q15_t)0x4DF9, (q15_t)0x6563, (q15_t)0x4E21, (q15_t)0x6545, (q15_t)0x4E48, + (q15_t)0x6526, (q15_t)0x4E70, (q15_t)0x6507, (q15_t)0x4E98, (q15_t)0x64E8, + (q15_t)0x4EBF, (q15_t)0x64C9, (q15_t)0x4EE7, (q15_t)0x64AA, (q15_t)0x4F0F, + (q15_t)0x648B, (q15_t)0x4F36, (q15_t)0x646C, (q15_t)0x4F5E, (q15_t)0x644D, + (q15_t)0x4F85, (q15_t)0x642D, (q15_t)0x4FAC, (q15_t)0x640E, (q15_t)0x4FD4, + (q15_t)0x63EF, (q15_t)0x4FFB, (q15_t)0x63CF, (q15_t)0x5022, (q15_t)0x63B0, + (q15_t)0x5049, (q15_t)0x6390, (q15_t)0x5070, (q15_t)0x6371, (q15_t)0x5097, + (q15_t)0x6351, (q15_t)0x50BF, (q15_t)0x6331, (q15_t)0x50E5, (q15_t)0x6311, + (q15_t)0x510C, (q15_t)0x62F2, (q15_t)0x5133, (q15_t)0x62D2, (q15_t)0x515A, + (q15_t)0x62B2, (q15_t)0x5181, (q15_t)0x6292, (q15_t)0x51A8, (q15_t)0x6271, + (q15_t)0x51CE, (q15_t)0x6251, (q15_t)0x51F5, (q15_t)0x6231, (q15_t)0x521C, + (q15_t)0x6211, (q15_t)0x5242, (q15_t)0x61F1, (q15_t)0x5269, (q15_t)0x61D0, + (q15_t)0x528F, (q15_t)0x61B0, (q15_t)0x52B5, (q15_t)0x618F, (q15_t)0x52DC, + (q15_t)0x616F, (q15_t)0x5302, (q15_t)0x614E, (q15_t)0x5328, (q15_t)0x612D, + (q15_t)0x534E, (q15_t)0x610D, (q15_t)0x5375, (q15_t)0x60EC, (q15_t)0x539B, + (q15_t)0x60CB, (q15_t)0x53C1, (q15_t)0x60AA, (q15_t)0x53E7, (q15_t)0x6089, + (q15_t)0x540D, (q15_t)0x6068, (q15_t)0x5433, (q15_t)0x6047, (q15_t)0x5458, + (q15_t)0x6026, (q15_t)0x547E, (q15_t)0x6004, (q15_t)0x54A4, (q15_t)0x5FE3, + (q15_t)0x54CA, (q15_t)0x5FC2, (q15_t)0x54EF, (q15_t)0x5FA0, (q15_t)0x5515, + (q15_t)0x5F7F, (q15_t)0x553A, (q15_t)0x5F5E, (q15_t)0x5560, (q15_t)0x5F3C, + (q15_t)0x5585, (q15_t)0x5F1A, (q15_t)0x55AB, (q15_t)0x5EF9, (q15_t)0x55D0, + (q15_t)0x5ED7, (q15_t)0x55F5, (q15_t)0x5EB5, (q15_t)0x561A, (q15_t)0x5E93, + (q15_t)0x5640, (q15_t)0x5E71, (q15_t)0x5665, (q15_t)0x5E50, (q15_t)0x568A, + (q15_t)0x5E2D, (q15_t)0x56AF, (q15_t)0x5E0B, (q15_t)0x56D4, (q15_t)0x5DE9, + (q15_t)0x56F9, (q15_t)0x5DC7, (q15_t)0x571D, (q15_t)0x5DA5, (q15_t)0x5742, + (q15_t)0x5D83, (q15_t)0x5767, (q15_t)0x5D60, (q15_t)0x578C, (q15_t)0x5D3E, + (q15_t)0x57B0, (q15_t)0x5D1B, (q15_t)0x57D5, (q15_t)0x5CF9, (q15_t)0x57F9, + (q15_t)0x5CD6, (q15_t)0x581E, (q15_t)0x5CB4, (q15_t)0x5842, (q15_t)0x5C91, + (q15_t)0x5867, (q15_t)0x5C6E, (q15_t)0x588B, (q15_t)0x5C4B, (q15_t)0x58AF, + (q15_t)0x5C29, (q15_t)0x58D4, (q15_t)0x5C06, (q15_t)0x58F8, (q15_t)0x5BE3, + (q15_t)0x591C, (q15_t)0x5BC0, (q15_t)0x5940, (q15_t)0x5B9D, (q15_t)0x5964, + (q15_t)0x5B79, (q15_t)0x5988, (q15_t)0x5B56, (q15_t)0x59AC, (q15_t)0x5B33, + (q15_t)0x59D0, (q15_t)0x5B10, (q15_t)0x59F3, (q15_t)0x5AEC, (q15_t)0x5A17, + (q15_t)0x5AC9, (q15_t)0x5A3B, (q15_t)0x5AA5, (q15_t)0x5A5E, (q15_t)0x5A82, + (q15_t)0x5A82, (q15_t)0x5A5E, (q15_t)0x5AA5, (q15_t)0x5A3B, (q15_t)0x5AC9, + (q15_t)0x5A17, (q15_t)0x5AEC, (q15_t)0x59F3, (q15_t)0x5B10, (q15_t)0x59D0, + (q15_t)0x5B33, (q15_t)0x59AC, (q15_t)0x5B56, (q15_t)0x5988, (q15_t)0x5B79, + (q15_t)0x5964, (q15_t)0x5B9D, (q15_t)0x5940, (q15_t)0x5BC0, (q15_t)0x591C, + (q15_t)0x5BE3, (q15_t)0x58F8, (q15_t)0x5C06, (q15_t)0x58D4, (q15_t)0x5C29, + (q15_t)0x58AF, (q15_t)0x5C4B, (q15_t)0x588B, (q15_t)0x5C6E, (q15_t)0x5867, + (q15_t)0x5C91, (q15_t)0x5842, (q15_t)0x5CB4, (q15_t)0x581E, (q15_t)0x5CD6, + (q15_t)0x57F9, (q15_t)0x5CF9, (q15_t)0x57D5, (q15_t)0x5D1B, (q15_t)0x57B0, + (q15_t)0x5D3E, (q15_t)0x578C, (q15_t)0x5D60, (q15_t)0x5767, (q15_t)0x5D83, + (q15_t)0x5742, (q15_t)0x5DA5, (q15_t)0x571D, (q15_t)0x5DC7, (q15_t)0x56F9, + (q15_t)0x5DE9, (q15_t)0x56D4, (q15_t)0x5E0B, (q15_t)0x56AF, (q15_t)0x5E2D, + (q15_t)0x568A, (q15_t)0x5E50, (q15_t)0x5665, (q15_t)0x5E71, (q15_t)0x5640, + (q15_t)0x5E93, (q15_t)0x561A, (q15_t)0x5EB5, (q15_t)0x55F5, (q15_t)0x5ED7, + (q15_t)0x55D0, (q15_t)0x5EF9, (q15_t)0x55AB, (q15_t)0x5F1A, (q15_t)0x5585, + (q15_t)0x5F3C, (q15_t)0x5560, (q15_t)0x5F5E, (q15_t)0x553A, (q15_t)0x5F7F, + (q15_t)0x5515, (q15_t)0x5FA0, (q15_t)0x54EF, (q15_t)0x5FC2, (q15_t)0x54CA, + (q15_t)0x5FE3, (q15_t)0x54A4, (q15_t)0x6004, (q15_t)0x547E, (q15_t)0x6026, + (q15_t)0x5458, (q15_t)0x6047, (q15_t)0x5433, (q15_t)0x6068, (q15_t)0x540D, + (q15_t)0x6089, (q15_t)0x53E7, (q15_t)0x60AA, (q15_t)0x53C1, (q15_t)0x60CB, + (q15_t)0x539B, (q15_t)0x60EC, (q15_t)0x5375, (q15_t)0x610D, (q15_t)0x534E, + (q15_t)0x612D, (q15_t)0x5328, (q15_t)0x614E, (q15_t)0x5302, (q15_t)0x616F, + (q15_t)0x52DC, (q15_t)0x618F, (q15_t)0x52B5, (q15_t)0x61B0, (q15_t)0x528F, + (q15_t)0x61D0, (q15_t)0x5269, (q15_t)0x61F1, (q15_t)0x5242, (q15_t)0x6211, + (q15_t)0x521C, (q15_t)0x6231, (q15_t)0x51F5, (q15_t)0x6251, (q15_t)0x51CE, + (q15_t)0x6271, (q15_t)0x51A8, (q15_t)0x6292, (q15_t)0x5181, (q15_t)0x62B2, + (q15_t)0x515A, (q15_t)0x62D2, (q15_t)0x5133, (q15_t)0x62F2, (q15_t)0x510C, + (q15_t)0x6311, (q15_t)0x50E5, (q15_t)0x6331, (q15_t)0x50BF, (q15_t)0x6351, + (q15_t)0x5097, (q15_t)0x6371, (q15_t)0x5070, (q15_t)0x6390, (q15_t)0x5049, + (q15_t)0x63B0, (q15_t)0x5022, (q15_t)0x63CF, (q15_t)0x4FFB, (q15_t)0x63EF, + (q15_t)0x4FD4, (q15_t)0x640E, (q15_t)0x4FAC, (q15_t)0x642D, (q15_t)0x4F85, + (q15_t)0x644D, (q15_t)0x4F5E, (q15_t)0x646C, (q15_t)0x4F36, (q15_t)0x648B, + (q15_t)0x4F0F, (q15_t)0x64AA, (q15_t)0x4EE7, (q15_t)0x64C9, (q15_t)0x4EBF, + (q15_t)0x64E8, (q15_t)0x4E98, (q15_t)0x6507, (q15_t)0x4E70, (q15_t)0x6526, + (q15_t)0x4E48, (q15_t)0x6545, (q15_t)0x4E21, (q15_t)0x6563, (q15_t)0x4DF9, + (q15_t)0x6582, (q15_t)0x4DD1, (q15_t)0x65A0, (q15_t)0x4DA9, (q15_t)0x65BF, + (q15_t)0x4D81, (q15_t)0x65DD, (q15_t)0x4D59, (q15_t)0x65FC, (q15_t)0x4D31, + (q15_t)0x661A, (q15_t)0x4D09, (q15_t)0x6639, (q15_t)0x4CE1, (q15_t)0x6657, + (q15_t)0x4CB8, (q15_t)0x6675, (q15_t)0x4C90, (q15_t)0x6693, (q15_t)0x4C68, + (q15_t)0x66B1, (q15_t)0x4C3F, (q15_t)0x66CF, (q15_t)0x4C17, (q15_t)0x66ED, + (q15_t)0x4BEF, (q15_t)0x670B, (q15_t)0x4BC6, (q15_t)0x6729, (q15_t)0x4B9E, + (q15_t)0x6746, (q15_t)0x4B75, (q15_t)0x6764, (q15_t)0x4B4C, (q15_t)0x6782, + (q15_t)0x4B24, (q15_t)0x679F, (q15_t)0x4AFB, (q15_t)0x67BD, (q15_t)0x4AD2, + (q15_t)0x67DA, (q15_t)0x4AA9, (q15_t)0x67F7, (q15_t)0x4A81, (q15_t)0x6815, + (q15_t)0x4A58, (q15_t)0x6832, (q15_t)0x4A2F, (q15_t)0x684F, (q15_t)0x4A06, + (q15_t)0x686C, (q15_t)0x49DD, (q15_t)0x6889, (q15_t)0x49B4, (q15_t)0x68A6, + (q15_t)0x498A, (q15_t)0x68C3, (q15_t)0x4961, (q15_t)0x68E0, (q15_t)0x4938, + (q15_t)0x68FD, (q15_t)0x490F, (q15_t)0x6919, (q15_t)0x48E6, (q15_t)0x6936, + (q15_t)0x48BC, (q15_t)0x6953, (q15_t)0x4893, (q15_t)0x696F, (q15_t)0x4869, + (q15_t)0x698C, (q15_t)0x4840, (q15_t)0x69A8, (q15_t)0x4816, (q15_t)0x69C4, + (q15_t)0x47ED, (q15_t)0x69E1, (q15_t)0x47C3, (q15_t)0x69FD, (q15_t)0x479A, + (q15_t)0x6A19, (q15_t)0x4770, (q15_t)0x6A35, (q15_t)0x4746, (q15_t)0x6A51, + (q15_t)0x471C, (q15_t)0x6A6D, (q15_t)0x46F3, (q15_t)0x6A89, (q15_t)0x46C9, + (q15_t)0x6AA5, (q15_t)0x469F, (q15_t)0x6AC1, (q15_t)0x4675, (q15_t)0x6ADC, + (q15_t)0x464B, (q15_t)0x6AF8, (q15_t)0x4621, (q15_t)0x6B13, (q15_t)0x45F7, + (q15_t)0x6B2F, (q15_t)0x45CD, (q15_t)0x6B4A, (q15_t)0x45A3, (q15_t)0x6B66, + (q15_t)0x4578, (q15_t)0x6B81, (q15_t)0x454E, (q15_t)0x6B9C, (q15_t)0x4524, + (q15_t)0x6BB8, (q15_t)0x44FA, (q15_t)0x6BD3, (q15_t)0x44CF, (q15_t)0x6BEE, + (q15_t)0x44A5, (q15_t)0x6C09, (q15_t)0x447A, (q15_t)0x6C24, (q15_t)0x4450, + (q15_t)0x6C3F, (q15_t)0x4425, (q15_t)0x6C59, (q15_t)0x43FB, (q15_t)0x6C74, + (q15_t)0x43D0, (q15_t)0x6C8F, (q15_t)0x43A5, (q15_t)0x6CA9, (q15_t)0x437B, + (q15_t)0x6CC4, (q15_t)0x4350, (q15_t)0x6CDE, (q15_t)0x4325, (q15_t)0x6CF9, + (q15_t)0x42FA, (q15_t)0x6D13, (q15_t)0x42D0, (q15_t)0x6D2D, (q15_t)0x42A5, + (q15_t)0x6D48, (q15_t)0x427A, (q15_t)0x6D62, (q15_t)0x424F, (q15_t)0x6D7C, + (q15_t)0x4224, (q15_t)0x6D96, (q15_t)0x41F9, (q15_t)0x6DB0, (q15_t)0x41CE, + (q15_t)0x6DCA, (q15_t)0x41A2, (q15_t)0x6DE3, (q15_t)0x4177, (q15_t)0x6DFD, + (q15_t)0x414C, (q15_t)0x6E17, (q15_t)0x4121, (q15_t)0x6E30, (q15_t)0x40F6, + (q15_t)0x6E4A, (q15_t)0x40CA, (q15_t)0x6E63, (q15_t)0x409F, (q15_t)0x6E7D, + (q15_t)0x4073, (q15_t)0x6E96, (q15_t)0x4048, (q15_t)0x6EAF, (q15_t)0x401D, + (q15_t)0x6EC9, (q15_t)0x3FF1, (q15_t)0x6EE2, (q15_t)0x3FC5, (q15_t)0x6EFB, + (q15_t)0x3F9A, (q15_t)0x6F14, (q15_t)0x3F6E, (q15_t)0x6F2D, (q15_t)0x3F43, + (q15_t)0x6F46, (q15_t)0x3F17, (q15_t)0x6F5F, (q15_t)0x3EEB, (q15_t)0x6F77, + (q15_t)0x3EBF, (q15_t)0x6F90, (q15_t)0x3E93, (q15_t)0x6FA9, (q15_t)0x3E68, + (q15_t)0x6FC1, (q15_t)0x3E3C, (q15_t)0x6FDA, (q15_t)0x3E10, (q15_t)0x6FF2, + (q15_t)0x3DE4, (q15_t)0x700A, (q15_t)0x3DB8, (q15_t)0x7023, (q15_t)0x3D8C, + (q15_t)0x703B, (q15_t)0x3D60, (q15_t)0x7053, (q15_t)0x3D33, (q15_t)0x706B, + (q15_t)0x3D07, (q15_t)0x7083, (q15_t)0x3CDB, (q15_t)0x709B, (q15_t)0x3CAF, + (q15_t)0x70B3, (q15_t)0x3C83, (q15_t)0x70CB, (q15_t)0x3C56, (q15_t)0x70E2, + (q15_t)0x3C2A, (q15_t)0x70FA, (q15_t)0x3BFD, (q15_t)0x7112, (q15_t)0x3BD1, + (q15_t)0x7129, (q15_t)0x3BA5, (q15_t)0x7141, (q15_t)0x3B78, (q15_t)0x7158, + (q15_t)0x3B4C, (q15_t)0x716F, (q15_t)0x3B1F, (q15_t)0x7186, (q15_t)0x3AF2, + (q15_t)0x719E, (q15_t)0x3AC6, (q15_t)0x71B5, (q15_t)0x3A99, (q15_t)0x71CC, + (q15_t)0x3A6C, (q15_t)0x71E3, (q15_t)0x3A40, (q15_t)0x71FA, (q15_t)0x3A13, + (q15_t)0x7211, (q15_t)0x39E6, (q15_t)0x7227, (q15_t)0x39B9, (q15_t)0x723E, + (q15_t)0x398C, (q15_t)0x7255, (q15_t)0x395F, (q15_t)0x726B, (q15_t)0x3932, + (q15_t)0x7282, (q15_t)0x3906, (q15_t)0x7298, (q15_t)0x38D8, (q15_t)0x72AF, + (q15_t)0x38AB, (q15_t)0x72C5, (q15_t)0x387E, (q15_t)0x72DB, (q15_t)0x3851, + (q15_t)0x72F1, (q15_t)0x3824, (q15_t)0x7307, (q15_t)0x37F7, (q15_t)0x731D, + (q15_t)0x37CA, (q15_t)0x7333, (q15_t)0x379C, (q15_t)0x7349, (q15_t)0x376F, + (q15_t)0x735F, (q15_t)0x3742, (q15_t)0x7375, (q15_t)0x3714, (q15_t)0x738A, + (q15_t)0x36E7, (q15_t)0x73A0, (q15_t)0x36BA, (q15_t)0x73B5, (q15_t)0x368C, + (q15_t)0x73CB, (q15_t)0x365F, (q15_t)0x73E0, (q15_t)0x3631, (q15_t)0x73F6, + (q15_t)0x3604, (q15_t)0x740B, (q15_t)0x35D6, (q15_t)0x7420, (q15_t)0x35A8, + (q15_t)0x7435, (q15_t)0x357B, (q15_t)0x744A, (q15_t)0x354D, (q15_t)0x745F, + (q15_t)0x351F, (q15_t)0x7474, (q15_t)0x34F2, (q15_t)0x7489, (q15_t)0x34C4, + (q15_t)0x749E, (q15_t)0x3496, (q15_t)0x74B2, (q15_t)0x3468, (q15_t)0x74C7, + (q15_t)0x343A, (q15_t)0x74DB, (q15_t)0x340C, (q15_t)0x74F0, (q15_t)0x33DE, + (q15_t)0x7504, (q15_t)0x33B0, (q15_t)0x7519, (q15_t)0x3382, (q15_t)0x752D, + (q15_t)0x3354, (q15_t)0x7541, (q15_t)0x3326, (q15_t)0x7555, (q15_t)0x32F8, + (q15_t)0x7569, (q15_t)0x32CA, (q15_t)0x757D, (q15_t)0x329C, (q15_t)0x7591, + (q15_t)0x326E, (q15_t)0x75A5, (q15_t)0x3240, (q15_t)0x75B9, (q15_t)0x3211, + (q15_t)0x75CC, (q15_t)0x31E3, (q15_t)0x75E0, (q15_t)0x31B5, (q15_t)0x75F4, + (q15_t)0x3186, (q15_t)0x7607, (q15_t)0x3158, (q15_t)0x761B, (q15_t)0x312A, + (q15_t)0x762E, (q15_t)0x30FB, (q15_t)0x7641, (q15_t)0x30CD, (q15_t)0x7654, + (q15_t)0x309E, (q15_t)0x7668, (q15_t)0x3070, (q15_t)0x767B, (q15_t)0x3041, + (q15_t)0x768E, (q15_t)0x3013, (q15_t)0x76A0, (q15_t)0x2FE4, (q15_t)0x76B3, + (q15_t)0x2FB5, (q15_t)0x76C6, (q15_t)0x2F87, (q15_t)0x76D9, (q15_t)0x2F58, + (q15_t)0x76EB, (q15_t)0x2F29, (q15_t)0x76FE, (q15_t)0x2EFB, (q15_t)0x7710, + (q15_t)0x2ECC, (q15_t)0x7723, (q15_t)0x2E9D, (q15_t)0x7735, (q15_t)0x2E6E, + (q15_t)0x7747, (q15_t)0x2E3F, (q15_t)0x775A, (q15_t)0x2E11, (q15_t)0x776C, + (q15_t)0x2DE2, (q15_t)0x777E, (q15_t)0x2DB3, (q15_t)0x7790, (q15_t)0x2D84, + (q15_t)0x77A2, (q15_t)0x2D55, (q15_t)0x77B4, (q15_t)0x2D26, (q15_t)0x77C5, + (q15_t)0x2CF7, (q15_t)0x77D7, (q15_t)0x2CC8, (q15_t)0x77E9, (q15_t)0x2C98, + (q15_t)0x77FA, (q15_t)0x2C69, (q15_t)0x780C, (q15_t)0x2C3A, (q15_t)0x781D, + (q15_t)0x2C0B, (q15_t)0x782E, (q15_t)0x2BDC, (q15_t)0x7840, (q15_t)0x2BAD, + (q15_t)0x7851, (q15_t)0x2B7D, (q15_t)0x7862, (q15_t)0x2B4E, (q15_t)0x7873, + (q15_t)0x2B1F, (q15_t)0x7884, (q15_t)0x2AEF, (q15_t)0x7895, (q15_t)0x2AC0, + (q15_t)0x78A6, (q15_t)0x2A91, (q15_t)0x78B6, (q15_t)0x2A61, (q15_t)0x78C7, + (q15_t)0x2A32, (q15_t)0x78D8, (q15_t)0x2A02, (q15_t)0x78E8, (q15_t)0x29D3, + (q15_t)0x78F9, (q15_t)0x29A3, (q15_t)0x7909, (q15_t)0x2974, (q15_t)0x7919, + (q15_t)0x2944, (q15_t)0x792A, (q15_t)0x2915, (q15_t)0x793A, (q15_t)0x28E5, + (q15_t)0x794A, (q15_t)0x28B5, (q15_t)0x795A, (q15_t)0x2886, (q15_t)0x796A, + (q15_t)0x2856, (q15_t)0x797A, (q15_t)0x2826, (q15_t)0x798A, (q15_t)0x27F6, + (q15_t)0x7999, (q15_t)0x27C7, (q15_t)0x79A9, (q15_t)0x2797, (q15_t)0x79B9, + (q15_t)0x2767, (q15_t)0x79C8, (q15_t)0x2737, (q15_t)0x79D8, (q15_t)0x2707, + (q15_t)0x79E7, (q15_t)0x26D8, (q15_t)0x79F6, (q15_t)0x26A8, (q15_t)0x7A05, + (q15_t)0x2678, (q15_t)0x7A15, (q15_t)0x2648, (q15_t)0x7A24, (q15_t)0x2618, + (q15_t)0x7A33, (q15_t)0x25E8, (q15_t)0x7A42, (q15_t)0x25B8, (q15_t)0x7A50, + (q15_t)0x2588, (q15_t)0x7A5F, (q15_t)0x2558, (q15_t)0x7A6E, (q15_t)0x2528, + (q15_t)0x7A7D, (q15_t)0x24F7, (q15_t)0x7A8B, (q15_t)0x24C7, (q15_t)0x7A9A, + (q15_t)0x2497, (q15_t)0x7AA8, (q15_t)0x2467, (q15_t)0x7AB6, (q15_t)0x2437, + (q15_t)0x7AC5, (q15_t)0x2407, (q15_t)0x7AD3, (q15_t)0x23D6, (q15_t)0x7AE1, + (q15_t)0x23A6, (q15_t)0x7AEF, (q15_t)0x2376, (q15_t)0x7AFD, (q15_t)0x2345, + (q15_t)0x7B0B, (q15_t)0x2315, (q15_t)0x7B19, (q15_t)0x22E5, (q15_t)0x7B26, + (q15_t)0x22B4, (q15_t)0x7B34, (q15_t)0x2284, (q15_t)0x7B42, (q15_t)0x2254, + (q15_t)0x7B4F, (q15_t)0x2223, (q15_t)0x7B5D, (q15_t)0x21F3, (q15_t)0x7B6A, + (q15_t)0x21C2, (q15_t)0x7B77, (q15_t)0x2192, (q15_t)0x7B84, (q15_t)0x2161, + (q15_t)0x7B92, (q15_t)0x2131, (q15_t)0x7B9F, (q15_t)0x2100, (q15_t)0x7BAC, + (q15_t)0x20D0, (q15_t)0x7BB9, (q15_t)0x209F, (q15_t)0x7BC5, (q15_t)0x206E, + (q15_t)0x7BD2, (q15_t)0x203E, (q15_t)0x7BDF, (q15_t)0x200D, (q15_t)0x7BEB, + (q15_t)0x1FDC, (q15_t)0x7BF8, (q15_t)0x1FAC, (q15_t)0x7C05, (q15_t)0x1F7B, + (q15_t)0x7C11, (q15_t)0x1F4A, (q15_t)0x7C1D, (q15_t)0x1F19, (q15_t)0x7C29, + (q15_t)0x1EE9, (q15_t)0x7C36, (q15_t)0x1EB8, (q15_t)0x7C42, (q15_t)0x1E87, + (q15_t)0x7C4E, (q15_t)0x1E56, (q15_t)0x7C5A, (q15_t)0x1E25, (q15_t)0x7C66, + (q15_t)0x1DF5, (q15_t)0x7C71, (q15_t)0x1DC4, (q15_t)0x7C7D, (q15_t)0x1D93, + (q15_t)0x7C89, (q15_t)0x1D62, (q15_t)0x7C94, (q15_t)0x1D31, (q15_t)0x7CA0, + (q15_t)0x1D00, (q15_t)0x7CAB, (q15_t)0x1CCF, (q15_t)0x7CB7, (q15_t)0x1C9E, + (q15_t)0x7CC2, (q15_t)0x1C6D, (q15_t)0x7CCD, (q15_t)0x1C3C, (q15_t)0x7CD8, + (q15_t)0x1C0B, (q15_t)0x7CE3, (q15_t)0x1BDA, (q15_t)0x7CEE, (q15_t)0x1BA9, + (q15_t)0x7CF9, (q15_t)0x1B78, (q15_t)0x7D04, (q15_t)0x1B47, (q15_t)0x7D0F, + (q15_t)0x1B16, (q15_t)0x7D19, (q15_t)0x1AE4, (q15_t)0x7D24, (q15_t)0x1AB3, + (q15_t)0x7D2F, (q15_t)0x1A82, (q15_t)0x7D39, (q15_t)0x1A51, (q15_t)0x7D43, + (q15_t)0x1A20, (q15_t)0x7D4E, (q15_t)0x19EF, (q15_t)0x7D58, (q15_t)0x19BD, + (q15_t)0x7D62, (q15_t)0x198C, (q15_t)0x7D6C, (q15_t)0x195B, (q15_t)0x7D76, + (q15_t)0x192A, (q15_t)0x7D80, (q15_t)0x18F8, (q15_t)0x7D8A, (q15_t)0x18C7, + (q15_t)0x7D94, (q15_t)0x1896, (q15_t)0x7D9D, (q15_t)0x1864, (q15_t)0x7DA7, + (q15_t)0x1833, (q15_t)0x7DB0, (q15_t)0x1802, (q15_t)0x7DBA, (q15_t)0x17D0, + (q15_t)0x7DC3, (q15_t)0x179F, (q15_t)0x7DCD, (q15_t)0x176D, (q15_t)0x7DD6, + (q15_t)0x173C, (q15_t)0x7DDF, (q15_t)0x170A, (q15_t)0x7DE8, (q15_t)0x16D9, + (q15_t)0x7DF1, (q15_t)0x16A8, (q15_t)0x7DFA, (q15_t)0x1676, (q15_t)0x7E03, + (q15_t)0x1645, (q15_t)0x7E0C, (q15_t)0x1613, (q15_t)0x7E14, (q15_t)0x15E2, + (q15_t)0x7E1D, (q15_t)0x15B0, (q15_t)0x7E26, (q15_t)0x157F, (q15_t)0x7E2E, + (q15_t)0x154D, (q15_t)0x7E37, (q15_t)0x151B, (q15_t)0x7E3F, (q15_t)0x14EA, + (q15_t)0x7E47, (q15_t)0x14B8, (q15_t)0x7E4F, (q15_t)0x1487, (q15_t)0x7E57, + (q15_t)0x1455, (q15_t)0x7E5F, (q15_t)0x1423, (q15_t)0x7E67, (q15_t)0x13F2, + (q15_t)0x7E6F, (q15_t)0x13C0, (q15_t)0x7E77, (q15_t)0x138E, (q15_t)0x7E7F, + (q15_t)0x135D, (q15_t)0x7E86, (q15_t)0x132B, (q15_t)0x7E8E, (q15_t)0x12F9, + (q15_t)0x7E95, (q15_t)0x12C8, (q15_t)0x7E9D, (q15_t)0x1296, (q15_t)0x7EA4, + (q15_t)0x1264, (q15_t)0x7EAB, (q15_t)0x1232, (q15_t)0x7EB3, (q15_t)0x1201, + (q15_t)0x7EBA, (q15_t)0x11CF, (q15_t)0x7EC1, (q15_t)0x119D, (q15_t)0x7EC8, + (q15_t)0x116B, (q15_t)0x7ECF, (q15_t)0x1139, (q15_t)0x7ED5, (q15_t)0x1108, + (q15_t)0x7EDC, (q15_t)0x10D6, (q15_t)0x7EE3, (q15_t)0x10A4, (q15_t)0x7EE9, + (q15_t)0x1072, (q15_t)0x7EF0, (q15_t)0x1040, (q15_t)0x7EF6, (q15_t)0x100E, + (q15_t)0x7EFD, (q15_t)0x0FDD, (q15_t)0x7F03, (q15_t)0x0FAB, (q15_t)0x7F09, + (q15_t)0x0F79, (q15_t)0x7F0F, (q15_t)0x0F47, (q15_t)0x7F15, (q15_t)0x0F15, + (q15_t)0x7F1B, (q15_t)0x0EE3, (q15_t)0x7F21, (q15_t)0x0EB1, (q15_t)0x7F27, + (q15_t)0x0E7F, (q15_t)0x7F2D, (q15_t)0x0E4D, (q15_t)0x7F32, (q15_t)0x0E1B, + (q15_t)0x7F38, (q15_t)0x0DE9, (q15_t)0x7F3D, (q15_t)0x0DB7, (q15_t)0x7F43, + (q15_t)0x0D85, (q15_t)0x7F48, (q15_t)0x0D53, (q15_t)0x7F4D, (q15_t)0x0D21, + (q15_t)0x7F53, (q15_t)0x0CEF, (q15_t)0x7F58, (q15_t)0x0CBD, (q15_t)0x7F5D, + (q15_t)0x0C8B, (q15_t)0x7F62, (q15_t)0x0C59, (q15_t)0x7F67, (q15_t)0x0C27, + (q15_t)0x7F6B, (q15_t)0x0BF5, (q15_t)0x7F70, (q15_t)0x0BC3, (q15_t)0x7F75, + (q15_t)0x0B91, (q15_t)0x7F79, (q15_t)0x0B5F, (q15_t)0x7F7E, (q15_t)0x0B2D, + (q15_t)0x7F82, (q15_t)0x0AFB, (q15_t)0x7F87, (q15_t)0x0AC9, (q15_t)0x7F8B, + (q15_t)0x0A97, (q15_t)0x7F8F, (q15_t)0x0A65, (q15_t)0x7F93, (q15_t)0x0A33, + (q15_t)0x7F97, (q15_t)0x0A00, (q15_t)0x7F9B, (q15_t)0x09CE, (q15_t)0x7F9F, + (q15_t)0x099C, (q15_t)0x7FA3, (q15_t)0x096A, (q15_t)0x7FA7, (q15_t)0x0938, + (q15_t)0x7FAA, (q15_t)0x0906, (q15_t)0x7FAE, (q15_t)0x08D4, (q15_t)0x7FB1, + (q15_t)0x08A2, (q15_t)0x7FB5, (q15_t)0x086F, (q15_t)0x7FB8, (q15_t)0x083D, + (q15_t)0x7FBC, (q15_t)0x080B, (q15_t)0x7FBF, (q15_t)0x07D9, (q15_t)0x7FC2, + (q15_t)0x07A7, (q15_t)0x7FC5, (q15_t)0x0775, (q15_t)0x7FC8, (q15_t)0x0742, + (q15_t)0x7FCB, (q15_t)0x0710, (q15_t)0x7FCE, (q15_t)0x06DE, (q15_t)0x7FD0, + (q15_t)0x06AC, (q15_t)0x7FD3, (q15_t)0x067A, (q15_t)0x7FD6, (q15_t)0x0647, + (q15_t)0x7FD8, (q15_t)0x0615, (q15_t)0x7FDA, (q15_t)0x05E3, (q15_t)0x7FDD, + (q15_t)0x05B1, (q15_t)0x7FDF, (q15_t)0x057F, (q15_t)0x7FE1, (q15_t)0x054C, + (q15_t)0x7FE3, (q15_t)0x051A, (q15_t)0x7FE5, (q15_t)0x04E8, (q15_t)0x7FE7, + (q15_t)0x04B6, (q15_t)0x7FE9, (q15_t)0x0483, (q15_t)0x7FEB, (q15_t)0x0451, + (q15_t)0x7FED, (q15_t)0x041F, (q15_t)0x7FEE, (q15_t)0x03ED, (q15_t)0x7FF0, + (q15_t)0x03BA, (q15_t)0x7FF2, (q15_t)0x0388, (q15_t)0x7FF3, (q15_t)0x0356, + (q15_t)0x7FF4, (q15_t)0x0324, (q15_t)0x7FF6, (q15_t)0x02F1, (q15_t)0x7FF7, + (q15_t)0x02BF, (q15_t)0x7FF8, (q15_t)0x028D, (q15_t)0x7FF9, (q15_t)0x025B, + (q15_t)0x7FFA, (q15_t)0x0228, (q15_t)0x7FFB, (q15_t)0x01F6, (q15_t)0x7FFC, + (q15_t)0x01C4, (q15_t)0x7FFC, (q15_t)0x0192, (q15_t)0x7FFD, (q15_t)0x015F, + (q15_t)0x7FFE, (q15_t)0x012D, (q15_t)0x7FFE, (q15_t)0x00FB, (q15_t)0x7FFF, + (q15_t)0x00C9, (q15_t)0x7FFF, (q15_t)0x0096, (q15_t)0x7FFF, (q15_t)0x0064, + (q15_t)0x7FFF, (q15_t)0x0032, (q15_t)0x7FFF, (q15_t)0x0000, (q15_t)0x7FFF, + (q15_t)0xFFCD, (q15_t)0x7FFF, (q15_t)0xFF9B, (q15_t)0x7FFF, (q15_t)0xFF69, + (q15_t)0x7FFF, (q15_t)0xFF36, (q15_t)0x7FFF, (q15_t)0xFF04, (q15_t)0x7FFF, + (q15_t)0xFED2, (q15_t)0x7FFE, (q15_t)0xFEA0, (q15_t)0x7FFE, (q15_t)0xFE6D, + (q15_t)0x7FFD, (q15_t)0xFE3B, (q15_t)0x7FFC, (q15_t)0xFE09, (q15_t)0x7FFC, + (q15_t)0xFDD7, (q15_t)0x7FFB, (q15_t)0xFDA4, (q15_t)0x7FFA, (q15_t)0xFD72, + (q15_t)0x7FF9, (q15_t)0xFD40, (q15_t)0x7FF8, (q15_t)0xFD0E, (q15_t)0x7FF7, + (q15_t)0xFCDB, (q15_t)0x7FF6, (q15_t)0xFCA9, (q15_t)0x7FF4, (q15_t)0xFC77, + (q15_t)0x7FF3, (q15_t)0xFC45, (q15_t)0x7FF2, (q15_t)0xFC12, (q15_t)0x7FF0, + (q15_t)0xFBE0, (q15_t)0x7FEE, (q15_t)0xFBAE, (q15_t)0x7FED, (q15_t)0xFB7C, + (q15_t)0x7FEB, (q15_t)0xFB49, (q15_t)0x7FE9, (q15_t)0xFB17, (q15_t)0x7FE7, + (q15_t)0xFAE5, (q15_t)0x7FE5, (q15_t)0xFAB3, (q15_t)0x7FE3, (q15_t)0xFA80, + (q15_t)0x7FE1, (q15_t)0xFA4E, (q15_t)0x7FDF, (q15_t)0xFA1C, (q15_t)0x7FDD, + (q15_t)0xF9EA, (q15_t)0x7FDA, (q15_t)0xF9B8, (q15_t)0x7FD8, (q15_t)0xF985, + (q15_t)0x7FD6, (q15_t)0xF953, (q15_t)0x7FD3, (q15_t)0xF921, (q15_t)0x7FD0, + (q15_t)0xF8EF, (q15_t)0x7FCE, (q15_t)0xF8BD, (q15_t)0x7FCB, (q15_t)0xF88A, + (q15_t)0x7FC8, (q15_t)0xF858, (q15_t)0x7FC5, (q15_t)0xF826, (q15_t)0x7FC2, + (q15_t)0xF7F4, (q15_t)0x7FBF, (q15_t)0xF7C2, (q15_t)0x7FBC, (q15_t)0xF790, + (q15_t)0x7FB8, (q15_t)0xF75D, (q15_t)0x7FB5, (q15_t)0xF72B, (q15_t)0x7FB1, + (q15_t)0xF6F9, (q15_t)0x7FAE, (q15_t)0xF6C7, (q15_t)0x7FAA, (q15_t)0xF695, + (q15_t)0x7FA7, (q15_t)0xF663, (q15_t)0x7FA3, (q15_t)0xF631, (q15_t)0x7F9F, + (q15_t)0xF5FF, (q15_t)0x7F9B, (q15_t)0xF5CC, (q15_t)0x7F97, (q15_t)0xF59A, + (q15_t)0x7F93, (q15_t)0xF568, (q15_t)0x7F8F, (q15_t)0xF536, (q15_t)0x7F8B, + (q15_t)0xF504, (q15_t)0x7F87, (q15_t)0xF4D2, (q15_t)0x7F82, (q15_t)0xF4A0, + (q15_t)0x7F7E, (q15_t)0xF46E, (q15_t)0x7F79, (q15_t)0xF43C, (q15_t)0x7F75, + (q15_t)0xF40A, (q15_t)0x7F70, (q15_t)0xF3D8, (q15_t)0x7F6B, (q15_t)0xF3A6, + (q15_t)0x7F67, (q15_t)0xF374, (q15_t)0x7F62, (q15_t)0xF342, (q15_t)0x7F5D, + (q15_t)0xF310, (q15_t)0x7F58, (q15_t)0xF2DE, (q15_t)0x7F53, (q15_t)0xF2AC, + (q15_t)0x7F4D, (q15_t)0xF27A, (q15_t)0x7F48, (q15_t)0xF248, (q15_t)0x7F43, + (q15_t)0xF216, (q15_t)0x7F3D, (q15_t)0xF1E4, (q15_t)0x7F38, (q15_t)0xF1B2, + (q15_t)0x7F32, (q15_t)0xF180, (q15_t)0x7F2D, (q15_t)0xF14E, (q15_t)0x7F27, + (q15_t)0xF11C, (q15_t)0x7F21, (q15_t)0xF0EA, (q15_t)0x7F1B, (q15_t)0xF0B8, + (q15_t)0x7F15, (q15_t)0xF086, (q15_t)0x7F0F, (q15_t)0xF054, (q15_t)0x7F09, + (q15_t)0xF022, (q15_t)0x7F03, (q15_t)0xEFF1, (q15_t)0x7EFD, (q15_t)0xEFBF, + (q15_t)0x7EF6, (q15_t)0xEF8D, (q15_t)0x7EF0, (q15_t)0xEF5B, (q15_t)0x7EE9, + (q15_t)0xEF29, (q15_t)0x7EE3, (q15_t)0xEEF7, (q15_t)0x7EDC, (q15_t)0xEEC6, + (q15_t)0x7ED5, (q15_t)0xEE94, (q15_t)0x7ECF, (q15_t)0xEE62, (q15_t)0x7EC8, + (q15_t)0xEE30, (q15_t)0x7EC1, (q15_t)0xEDFE, (q15_t)0x7EBA, (q15_t)0xEDCD, + (q15_t)0x7EB3, (q15_t)0xED9B, (q15_t)0x7EAB, (q15_t)0xED69, (q15_t)0x7EA4, + (q15_t)0xED37, (q15_t)0x7E9D, (q15_t)0xED06, (q15_t)0x7E95, (q15_t)0xECD4, + (q15_t)0x7E8E, (q15_t)0xECA2, (q15_t)0x7E86, (q15_t)0xEC71, (q15_t)0x7E7F, + (q15_t)0xEC3F, (q15_t)0x7E77, (q15_t)0xEC0D, (q15_t)0x7E6F, (q15_t)0xEBDC, + (q15_t)0x7E67, (q15_t)0xEBAA, (q15_t)0x7E5F, (q15_t)0xEB78, (q15_t)0x7E57, + (q15_t)0xEB47, (q15_t)0x7E4F, (q15_t)0xEB15, (q15_t)0x7E47, (q15_t)0xEAE4, + (q15_t)0x7E3F, (q15_t)0xEAB2, (q15_t)0x7E37, (q15_t)0xEA80, (q15_t)0x7E2E, + (q15_t)0xEA4F, (q15_t)0x7E26, (q15_t)0xEA1D, (q15_t)0x7E1D, (q15_t)0xE9EC, + (q15_t)0x7E14, (q15_t)0xE9BA, (q15_t)0x7E0C, (q15_t)0xE989, (q15_t)0x7E03, + (q15_t)0xE957, (q15_t)0x7DFA, (q15_t)0xE926, (q15_t)0x7DF1, (q15_t)0xE8F5, + (q15_t)0x7DE8, (q15_t)0xE8C3, (q15_t)0x7DDF, (q15_t)0xE892, (q15_t)0x7DD6, + (q15_t)0xE860, (q15_t)0x7DCD, (q15_t)0xE82F, (q15_t)0x7DC3, (q15_t)0xE7FD, + (q15_t)0x7DBA, (q15_t)0xE7CC, (q15_t)0x7DB0, (q15_t)0xE79B, (q15_t)0x7DA7, + (q15_t)0xE769, (q15_t)0x7D9D, (q15_t)0xE738, (q15_t)0x7D94, (q15_t)0xE707, + (q15_t)0x7D8A, (q15_t)0xE6D5, (q15_t)0x7D80, (q15_t)0xE6A4, (q15_t)0x7D76, + (q15_t)0xE673, (q15_t)0x7D6C, (q15_t)0xE642, (q15_t)0x7D62, (q15_t)0xE610, + (q15_t)0x7D58, (q15_t)0xE5DF, (q15_t)0x7D4E, (q15_t)0xE5AE, (q15_t)0x7D43, + (q15_t)0xE57D, (q15_t)0x7D39, (q15_t)0xE54C, (q15_t)0x7D2F, (q15_t)0xE51B, + (q15_t)0x7D24, (q15_t)0xE4E9, (q15_t)0x7D19, (q15_t)0xE4B8, (q15_t)0x7D0F, + (q15_t)0xE487, (q15_t)0x7D04, (q15_t)0xE456, (q15_t)0x7CF9, (q15_t)0xE425, + (q15_t)0x7CEE, (q15_t)0xE3F4, (q15_t)0x7CE3, (q15_t)0xE3C3, (q15_t)0x7CD8, + (q15_t)0xE392, (q15_t)0x7CCD, (q15_t)0xE361, (q15_t)0x7CC2, (q15_t)0xE330, + (q15_t)0x7CB7, (q15_t)0xE2FF, (q15_t)0x7CAB, (q15_t)0xE2CE, (q15_t)0x7CA0, + (q15_t)0xE29D, (q15_t)0x7C94, (q15_t)0xE26C, (q15_t)0x7C89, (q15_t)0xE23B, + (q15_t)0x7C7D, (q15_t)0xE20A, (q15_t)0x7C71, (q15_t)0xE1DA, (q15_t)0x7C66, + (q15_t)0xE1A9, (q15_t)0x7C5A, (q15_t)0xE178, (q15_t)0x7C4E, (q15_t)0xE147, + (q15_t)0x7C42, (q15_t)0xE116, (q15_t)0x7C36, (q15_t)0xE0E6, (q15_t)0x7C29, + (q15_t)0xE0B5, (q15_t)0x7C1D, (q15_t)0xE084, (q15_t)0x7C11, (q15_t)0xE053, + (q15_t)0x7C05, (q15_t)0xE023, (q15_t)0x7BF8, (q15_t)0xDFF2, (q15_t)0x7BEB, + (q15_t)0xDFC1, (q15_t)0x7BDF, (q15_t)0xDF91, (q15_t)0x7BD2, (q15_t)0xDF60, + (q15_t)0x7BC5, (q15_t)0xDF2F, (q15_t)0x7BB9, (q15_t)0xDEFF, (q15_t)0x7BAC, + (q15_t)0xDECE, (q15_t)0x7B9F, (q15_t)0xDE9E, (q15_t)0x7B92, (q15_t)0xDE6D, + (q15_t)0x7B84, (q15_t)0xDE3D, (q15_t)0x7B77, (q15_t)0xDE0C, (q15_t)0x7B6A, + (q15_t)0xDDDC, (q15_t)0x7B5D, (q15_t)0xDDAB, (q15_t)0x7B4F, (q15_t)0xDD7B, + (q15_t)0x7B42, (q15_t)0xDD4B, (q15_t)0x7B34, (q15_t)0xDD1A, (q15_t)0x7B26, + (q15_t)0xDCEA, (q15_t)0x7B19, (q15_t)0xDCBA, (q15_t)0x7B0B, (q15_t)0xDC89, + (q15_t)0x7AFD, (q15_t)0xDC59, (q15_t)0x7AEF, (q15_t)0xDC29, (q15_t)0x7AE1, + (q15_t)0xDBF8, (q15_t)0x7AD3, (q15_t)0xDBC8, (q15_t)0x7AC5, (q15_t)0xDB98, + (q15_t)0x7AB6, (q15_t)0xDB68, (q15_t)0x7AA8, (q15_t)0xDB38, (q15_t)0x7A9A, + (q15_t)0xDB08, (q15_t)0x7A8B, (q15_t)0xDAD7, (q15_t)0x7A7D, (q15_t)0xDAA7, + (q15_t)0x7A6E, (q15_t)0xDA77, (q15_t)0x7A5F, (q15_t)0xDA47, (q15_t)0x7A50, + (q15_t)0xDA17, (q15_t)0x7A42, (q15_t)0xD9E7, (q15_t)0x7A33, (q15_t)0xD9B7, + (q15_t)0x7A24, (q15_t)0xD987, (q15_t)0x7A15, (q15_t)0xD957, (q15_t)0x7A05, + (q15_t)0xD927, (q15_t)0x79F6, (q15_t)0xD8F8, (q15_t)0x79E7, (q15_t)0xD8C8, + (q15_t)0x79D8, (q15_t)0xD898, (q15_t)0x79C8, (q15_t)0xD868, (q15_t)0x79B9, + (q15_t)0xD838, (q15_t)0x79A9, (q15_t)0xD809, (q15_t)0x7999, (q15_t)0xD7D9, + (q15_t)0x798A, (q15_t)0xD7A9, (q15_t)0x797A, (q15_t)0xD779, (q15_t)0x796A, + (q15_t)0xD74A, (q15_t)0x795A, (q15_t)0xD71A, (q15_t)0x794A, (q15_t)0xD6EA, + (q15_t)0x793A, (q15_t)0xD6BB, (q15_t)0x792A, (q15_t)0xD68B, (q15_t)0x7919, + (q15_t)0xD65C, (q15_t)0x7909, (q15_t)0xD62C, (q15_t)0x78F9, (q15_t)0xD5FD, + (q15_t)0x78E8, (q15_t)0xD5CD, (q15_t)0x78D8, (q15_t)0xD59E, (q15_t)0x78C7, + (q15_t)0xD56E, (q15_t)0x78B6, (q15_t)0xD53F, (q15_t)0x78A6, (q15_t)0xD510, + (q15_t)0x7895, (q15_t)0xD4E0, (q15_t)0x7884, (q15_t)0xD4B1, (q15_t)0x7873, + (q15_t)0xD482, (q15_t)0x7862, (q15_t)0xD452, (q15_t)0x7851, (q15_t)0xD423, + (q15_t)0x7840, (q15_t)0xD3F4, (q15_t)0x782E, (q15_t)0xD3C5, (q15_t)0x781D, + (q15_t)0xD396, (q15_t)0x780C, (q15_t)0xD367, (q15_t)0x77FA, (q15_t)0xD337, + (q15_t)0x77E9, (q15_t)0xD308, (q15_t)0x77D7, (q15_t)0xD2D9, (q15_t)0x77C5, + (q15_t)0xD2AA, (q15_t)0x77B4, (q15_t)0xD27B, (q15_t)0x77A2, (q15_t)0xD24C, + (q15_t)0x7790, (q15_t)0xD21D, (q15_t)0x777E, (q15_t)0xD1EE, (q15_t)0x776C, + (q15_t)0xD1C0, (q15_t)0x775A, (q15_t)0xD191, (q15_t)0x7747, (q15_t)0xD162, + (q15_t)0x7735, (q15_t)0xD133, (q15_t)0x7723, (q15_t)0xD104, (q15_t)0x7710, + (q15_t)0xD0D6, (q15_t)0x76FE, (q15_t)0xD0A7, (q15_t)0x76EB, (q15_t)0xD078, + (q15_t)0x76D9, (q15_t)0xD04A, (q15_t)0x76C6, (q15_t)0xD01B, (q15_t)0x76B3, + (q15_t)0xCFEC, (q15_t)0x76A0, (q15_t)0xCFBE, (q15_t)0x768E, (q15_t)0xCF8F, + (q15_t)0x767B, (q15_t)0xCF61, (q15_t)0x7668, (q15_t)0xCF32, (q15_t)0x7654, + (q15_t)0xCF04, (q15_t)0x7641, (q15_t)0xCED5, (q15_t)0x762E, (q15_t)0xCEA7, + (q15_t)0x761B, (q15_t)0xCE79, (q15_t)0x7607, (q15_t)0xCE4A, (q15_t)0x75F4, + (q15_t)0xCE1C, (q15_t)0x75E0, (q15_t)0xCDEE, (q15_t)0x75CC, (q15_t)0xCDBF, + (q15_t)0x75B9, (q15_t)0xCD91, (q15_t)0x75A5, (q15_t)0xCD63, (q15_t)0x7591, + (q15_t)0xCD35, (q15_t)0x757D, (q15_t)0xCD07, (q15_t)0x7569, (q15_t)0xCCD9, + (q15_t)0x7555, (q15_t)0xCCAB, (q15_t)0x7541, (q15_t)0xCC7D, (q15_t)0x752D, + (q15_t)0xCC4F, (q15_t)0x7519, (q15_t)0xCC21, (q15_t)0x7504, (q15_t)0xCBF3, + (q15_t)0x74F0, (q15_t)0xCBC5, (q15_t)0x74DB, (q15_t)0xCB97, (q15_t)0x74C7, + (q15_t)0xCB69, (q15_t)0x74B2, (q15_t)0xCB3B, (q15_t)0x749E, (q15_t)0xCB0D, + (q15_t)0x7489, (q15_t)0xCAE0, (q15_t)0x7474, (q15_t)0xCAB2, (q15_t)0x745F, + (q15_t)0xCA84, (q15_t)0x744A, (q15_t)0xCA57, (q15_t)0x7435, (q15_t)0xCA29, + (q15_t)0x7420, (q15_t)0xC9FB, (q15_t)0x740B, (q15_t)0xC9CE, (q15_t)0x73F6, + (q15_t)0xC9A0, (q15_t)0x73E0, (q15_t)0xC973, (q15_t)0x73CB, (q15_t)0xC945, + (q15_t)0x73B5, (q15_t)0xC918, (q15_t)0x73A0, (q15_t)0xC8EB, (q15_t)0x738A, + (q15_t)0xC8BD, (q15_t)0x7375, (q15_t)0xC890, (q15_t)0x735F, (q15_t)0xC863, + (q15_t)0x7349, (q15_t)0xC835, (q15_t)0x7333, (q15_t)0xC808, (q15_t)0x731D, + (q15_t)0xC7DB, (q15_t)0x7307, (q15_t)0xC7AE, (q15_t)0x72F1, (q15_t)0xC781, + (q15_t)0x72DB, (q15_t)0xC754, (q15_t)0x72C5, (q15_t)0xC727, (q15_t)0x72AF, + (q15_t)0xC6F9, (q15_t)0x7298, (q15_t)0xC6CD, (q15_t)0x7282, (q15_t)0xC6A0, + (q15_t)0x726B, (q15_t)0xC673, (q15_t)0x7255, (q15_t)0xC646, (q15_t)0x723E, + (q15_t)0xC619, (q15_t)0x7227, (q15_t)0xC5EC, (q15_t)0x7211, (q15_t)0xC5BF, + (q15_t)0x71FA, (q15_t)0xC593, (q15_t)0x71E3, (q15_t)0xC566, (q15_t)0x71CC, + (q15_t)0xC539, (q15_t)0x71B5, (q15_t)0xC50D, (q15_t)0x719E, (q15_t)0xC4E0, + (q15_t)0x7186, (q15_t)0xC4B3, (q15_t)0x716F, (q15_t)0xC487, (q15_t)0x7158, + (q15_t)0xC45A, (q15_t)0x7141, (q15_t)0xC42E, (q15_t)0x7129, (q15_t)0xC402, + (q15_t)0x7112, (q15_t)0xC3D5, (q15_t)0x70FA, (q15_t)0xC3A9, (q15_t)0x70E2, + (q15_t)0xC37C, (q15_t)0x70CB, (q15_t)0xC350, (q15_t)0x70B3, (q15_t)0xC324, + (q15_t)0x709B, (q15_t)0xC2F8, (q15_t)0x7083, (q15_t)0xC2CC, (q15_t)0x706B, + (q15_t)0xC29F, (q15_t)0x7053, (q15_t)0xC273, (q15_t)0x703B, (q15_t)0xC247, + (q15_t)0x7023, (q15_t)0xC21B, (q15_t)0x700A, (q15_t)0xC1EF, (q15_t)0x6FF2, + (q15_t)0xC1C3, (q15_t)0x6FDA, (q15_t)0xC197, (q15_t)0x6FC1, (q15_t)0xC16C, + (q15_t)0x6FA9, (q15_t)0xC140, (q15_t)0x6F90, (q15_t)0xC114, (q15_t)0x6F77, + (q15_t)0xC0E8, (q15_t)0x6F5F, (q15_t)0xC0BC, (q15_t)0x6F46, (q15_t)0xC091, + (q15_t)0x6F2D, (q15_t)0xC065, (q15_t)0x6F14, (q15_t)0xC03A, (q15_t)0x6EFB, + (q15_t)0xC00E, (q15_t)0x6EE2, (q15_t)0xBFE2, (q15_t)0x6EC9, (q15_t)0xBFB7, + (q15_t)0x6EAF, (q15_t)0xBF8C, (q15_t)0x6E96, (q15_t)0xBF60, (q15_t)0x6E7D, + (q15_t)0xBF35, (q15_t)0x6E63, (q15_t)0xBF09, (q15_t)0x6E4A, (q15_t)0xBEDE, + (q15_t)0x6E30, (q15_t)0xBEB3, (q15_t)0x6E17, (q15_t)0xBE88, (q15_t)0x6DFD, + (q15_t)0xBE5D, (q15_t)0x6DE3, (q15_t)0xBE31, (q15_t)0x6DCA, (q15_t)0xBE06, + (q15_t)0x6DB0, (q15_t)0xBDDB, (q15_t)0x6D96, (q15_t)0xBDB0, (q15_t)0x6D7C, + (q15_t)0xBD85, (q15_t)0x6D62, (q15_t)0xBD5A, (q15_t)0x6D48, (q15_t)0xBD2F, + (q15_t)0x6D2D, (q15_t)0xBD05, (q15_t)0x6D13, (q15_t)0xBCDA, (q15_t)0x6CF9, + (q15_t)0xBCAF, (q15_t)0x6CDE, (q15_t)0xBC84, (q15_t)0x6CC4, (q15_t)0xBC5A, + (q15_t)0x6CA9, (q15_t)0xBC2F, (q15_t)0x6C8F, (q15_t)0xBC04, (q15_t)0x6C74, + (q15_t)0xBBDA, (q15_t)0x6C59, (q15_t)0xBBAF, (q15_t)0x6C3F, (q15_t)0xBB85, + (q15_t)0x6C24, (q15_t)0xBB5A, (q15_t)0x6C09, (q15_t)0xBB30, (q15_t)0x6BEE, + (q15_t)0xBB05, (q15_t)0x6BD3, (q15_t)0xBADB, (q15_t)0x6BB8, (q15_t)0xBAB1, + (q15_t)0x6B9C, (q15_t)0xBA87, (q15_t)0x6B81, (q15_t)0xBA5C, (q15_t)0x6B66, + (q15_t)0xBA32, (q15_t)0x6B4A, (q15_t)0xBA08, (q15_t)0x6B2F, (q15_t)0xB9DE, + (q15_t)0x6B13, (q15_t)0xB9B4, (q15_t)0x6AF8, (q15_t)0xB98A, (q15_t)0x6ADC, + (q15_t)0xB960, (q15_t)0x6AC1, (q15_t)0xB936, (q15_t)0x6AA5, (q15_t)0xB90C, + (q15_t)0x6A89, (q15_t)0xB8E3, (q15_t)0x6A6D, (q15_t)0xB8B9, (q15_t)0x6A51, + (q15_t)0xB88F, (q15_t)0x6A35, (q15_t)0xB865, (q15_t)0x6A19, (q15_t)0xB83C, + (q15_t)0x69FD, (q15_t)0xB812, (q15_t)0x69E1, (q15_t)0xB7E9, (q15_t)0x69C4, + (q15_t)0xB7BF, (q15_t)0x69A8, (q15_t)0xB796, (q15_t)0x698C, (q15_t)0xB76C, + (q15_t)0x696F, (q15_t)0xB743, (q15_t)0x6953, (q15_t)0xB719, (q15_t)0x6936, + (q15_t)0xB6F0, (q15_t)0x6919, (q15_t)0xB6C7, (q15_t)0x68FD, (q15_t)0xB69E, + (q15_t)0x68E0, (q15_t)0xB675, (q15_t)0x68C3, (q15_t)0xB64B, (q15_t)0x68A6, + (q15_t)0xB622, (q15_t)0x6889, (q15_t)0xB5F9, (q15_t)0x686C, (q15_t)0xB5D0, + (q15_t)0x684F, (q15_t)0xB5A7, (q15_t)0x6832, (q15_t)0xB57E, (q15_t)0x6815, + (q15_t)0xB556, (q15_t)0x67F7, (q15_t)0xB52D, (q15_t)0x67DA, (q15_t)0xB504, + (q15_t)0x67BD, (q15_t)0xB4DB, (q15_t)0x679F, (q15_t)0xB4B3, (q15_t)0x6782, + (q15_t)0xB48A, (q15_t)0x6764, (q15_t)0xB461, (q15_t)0x6746, (q15_t)0xB439, + (q15_t)0x6729, (q15_t)0xB410, (q15_t)0x670B, (q15_t)0xB3E8, (q15_t)0x66ED, + (q15_t)0xB3C0, (q15_t)0x66CF, (q15_t)0xB397, (q15_t)0x66B1, (q15_t)0xB36F, + (q15_t)0x6693, (q15_t)0xB347, (q15_t)0x6675, (q15_t)0xB31E, (q15_t)0x6657, + (q15_t)0xB2F6, (q15_t)0x6639, (q15_t)0xB2CE, (q15_t)0x661A, (q15_t)0xB2A6, + (q15_t)0x65FC, (q15_t)0xB27E, (q15_t)0x65DD, (q15_t)0xB256, (q15_t)0x65BF, + (q15_t)0xB22E, (q15_t)0x65A0, (q15_t)0xB206, (q15_t)0x6582, (q15_t)0xB1DE, + (q15_t)0x6563, (q15_t)0xB1B7, (q15_t)0x6545, (q15_t)0xB18F, (q15_t)0x6526, + (q15_t)0xB167, (q15_t)0x6507, (q15_t)0xB140, (q15_t)0x64E8, (q15_t)0xB118, + (q15_t)0x64C9, (q15_t)0xB0F0, (q15_t)0x64AA, (q15_t)0xB0C9, (q15_t)0x648B, + (q15_t)0xB0A1, (q15_t)0x646C, (q15_t)0xB07A, (q15_t)0x644D, (q15_t)0xB053, + (q15_t)0x642D, (q15_t)0xB02B, (q15_t)0x640E, (q15_t)0xB004, (q15_t)0x63EF, + (q15_t)0xAFDD, (q15_t)0x63CF, (q15_t)0xAFB6, (q15_t)0x63B0, (q15_t)0xAF8F, + (q15_t)0x6390, (q15_t)0xAF68, (q15_t)0x6371, (q15_t)0xAF40, (q15_t)0x6351, + (q15_t)0xAF1A, (q15_t)0x6331, (q15_t)0xAEF3, (q15_t)0x6311, (q15_t)0xAECC, + (q15_t)0x62F2, (q15_t)0xAEA5, (q15_t)0x62D2, (q15_t)0xAE7E, (q15_t)0x62B2, + (q15_t)0xAE57, (q15_t)0x6292, (q15_t)0xAE31, (q15_t)0x6271, (q15_t)0xAE0A, + (q15_t)0x6251, (q15_t)0xADE3, (q15_t)0x6231, (q15_t)0xADBD, (q15_t)0x6211, + (q15_t)0xAD96, (q15_t)0x61F1, (q15_t)0xAD70, (q15_t)0x61D0, (q15_t)0xAD4A, + (q15_t)0x61B0, (q15_t)0xAD23, (q15_t)0x618F, (q15_t)0xACFD, (q15_t)0x616F, + (q15_t)0xACD7, (q15_t)0x614E, (q15_t)0xACB1, (q15_t)0x612D, (q15_t)0xAC8A, + (q15_t)0x610D, (q15_t)0xAC64, (q15_t)0x60EC, (q15_t)0xAC3E, (q15_t)0x60CB, + (q15_t)0xAC18, (q15_t)0x60AA, (q15_t)0xABF2, (q15_t)0x6089, (q15_t)0xABCC, + (q15_t)0x6068, (q15_t)0xABA7, (q15_t)0x6047, (q15_t)0xAB81, (q15_t)0x6026, + (q15_t)0xAB5B, (q15_t)0x6004, (q15_t)0xAB35, (q15_t)0x5FE3, (q15_t)0xAB10, + (q15_t)0x5FC2, (q15_t)0xAAEA, (q15_t)0x5FA0, (q15_t)0xAAC5, (q15_t)0x5F7F, + (q15_t)0xAA9F, (q15_t)0x5F5E, (q15_t)0xAA7A, (q15_t)0x5F3C, (q15_t)0xAA54, + (q15_t)0x5F1A, (q15_t)0xAA2F, (q15_t)0x5EF9, (q15_t)0xAA0A, (q15_t)0x5ED7, + (q15_t)0xA9E5, (q15_t)0x5EB5, (q15_t)0xA9BF, (q15_t)0x5E93, (q15_t)0xA99A, + (q15_t)0x5E71, (q15_t)0xA975, (q15_t)0x5E50, (q15_t)0xA950, (q15_t)0x5E2D, + (q15_t)0xA92B, (q15_t)0x5E0B, (q15_t)0xA906, (q15_t)0x5DE9, (q15_t)0xA8E2, + (q15_t)0x5DC7, (q15_t)0xA8BD, (q15_t)0x5DA5, (q15_t)0xA898, (q15_t)0x5D83, + (q15_t)0xA873, (q15_t)0x5D60, (q15_t)0xA84F, (q15_t)0x5D3E, (q15_t)0xA82A, + (q15_t)0x5D1B, (q15_t)0xA806, (q15_t)0x5CF9, (q15_t)0xA7E1, (q15_t)0x5CD6, + (q15_t)0xA7BD, (q15_t)0x5CB4, (q15_t)0xA798, (q15_t)0x5C91, (q15_t)0xA774, + (q15_t)0x5C6E, (q15_t)0xA750, (q15_t)0x5C4B, (q15_t)0xA72B, (q15_t)0x5C29, + (q15_t)0xA707, (q15_t)0x5C06, (q15_t)0xA6E3, (q15_t)0x5BE3, (q15_t)0xA6BF, + (q15_t)0x5BC0, (q15_t)0xA69B, (q15_t)0x5B9D, (q15_t)0xA677, (q15_t)0x5B79, + (q15_t)0xA653, (q15_t)0x5B56, (q15_t)0xA62F, (q15_t)0x5B33, (q15_t)0xA60C, + (q15_t)0x5B10, (q15_t)0xA5E8, (q15_t)0x5AEC, (q15_t)0xA5C4, (q15_t)0x5AC9, + (q15_t)0xA5A1, (q15_t)0x5AA5, (q15_t)0xA57D, (q15_t)0x5A82, (q15_t)0xA55A, + (q15_t)0x5A5E, (q15_t)0xA536, (q15_t)0x5A3B, (q15_t)0xA513, (q15_t)0x5A17, + (q15_t)0xA4EF, (q15_t)0x59F3, (q15_t)0xA4CC, (q15_t)0x59D0, (q15_t)0xA4A9, + (q15_t)0x59AC, (q15_t)0xA486, (q15_t)0x5988, (q15_t)0xA462, (q15_t)0x5964, + (q15_t)0xA43F, (q15_t)0x5940, (q15_t)0xA41C, (q15_t)0x591C, (q15_t)0xA3F9, + (q15_t)0x58F8, (q15_t)0xA3D6, (q15_t)0x58D4, (q15_t)0xA3B4, (q15_t)0x58AF, + (q15_t)0xA391, (q15_t)0x588B, (q15_t)0xA36E, (q15_t)0x5867, (q15_t)0xA34B, + (q15_t)0x5842, (q15_t)0xA329, (q15_t)0x581E, (q15_t)0xA306, (q15_t)0x57F9, + (q15_t)0xA2E4, (q15_t)0x57D5, (q15_t)0xA2C1, (q15_t)0x57B0, (q15_t)0xA29F, + (q15_t)0x578C, (q15_t)0xA27C, (q15_t)0x5767, (q15_t)0xA25A, (q15_t)0x5742, + (q15_t)0xA238, (q15_t)0x571D, (q15_t)0xA216, (q15_t)0x56F9, (q15_t)0xA1F4, + (q15_t)0x56D4, (q15_t)0xA1D2, (q15_t)0x56AF, (q15_t)0xA1AF, (q15_t)0x568A, + (q15_t)0xA18E, (q15_t)0x5665, (q15_t)0xA16C, (q15_t)0x5640, (q15_t)0xA14A, + (q15_t)0x561A, (q15_t)0xA128, (q15_t)0x55F5, (q15_t)0xA106, (q15_t)0x55D0, + (q15_t)0xA0E5, (q15_t)0x55AB, (q15_t)0xA0C3, (q15_t)0x5585, (q15_t)0xA0A1, + (q15_t)0x5560, (q15_t)0xA080, (q15_t)0x553A, (q15_t)0xA05F, (q15_t)0x5515, + (q15_t)0xA03D, (q15_t)0x54EF, (q15_t)0xA01C, (q15_t)0x54CA, (q15_t)0x9FFB, + (q15_t)0x54A4, (q15_t)0x9FD9, (q15_t)0x547E, (q15_t)0x9FB8, (q15_t)0x5458, + (q15_t)0x9F97, (q15_t)0x5433, (q15_t)0x9F76, (q15_t)0x540D, (q15_t)0x9F55, + (q15_t)0x53E7, (q15_t)0x9F34, (q15_t)0x53C1, (q15_t)0x9F13, (q15_t)0x539B, + (q15_t)0x9EF2, (q15_t)0x5375, (q15_t)0x9ED2, (q15_t)0x534E, (q15_t)0x9EB1, + (q15_t)0x5328, (q15_t)0x9E90, (q15_t)0x5302, (q15_t)0x9E70, (q15_t)0x52DC, + (q15_t)0x9E4F, (q15_t)0x52B5, (q15_t)0x9E2F, (q15_t)0x528F, (q15_t)0x9E0E, + (q15_t)0x5269, (q15_t)0x9DEE, (q15_t)0x5242, (q15_t)0x9DCE, (q15_t)0x521C, + (q15_t)0x9DAE, (q15_t)0x51F5, (q15_t)0x9D8E, (q15_t)0x51CE, (q15_t)0x9D6D, + (q15_t)0x51A8, (q15_t)0x9D4D, (q15_t)0x5181, (q15_t)0x9D2D, (q15_t)0x515A, + (q15_t)0x9D0D, (q15_t)0x5133, (q15_t)0x9CEE, (q15_t)0x510C, (q15_t)0x9CCE, + (q15_t)0x50E5, (q15_t)0x9CAE, (q15_t)0x50BF, (q15_t)0x9C8E, (q15_t)0x5097, + (q15_t)0x9C6F, (q15_t)0x5070, (q15_t)0x9C4F, (q15_t)0x5049, (q15_t)0x9C30, + (q15_t)0x5022, (q15_t)0x9C10, (q15_t)0x4FFB, (q15_t)0x9BF1, (q15_t)0x4FD4, + (q15_t)0x9BD2, (q15_t)0x4FAC, (q15_t)0x9BB2, (q15_t)0x4F85, (q15_t)0x9B93, + (q15_t)0x4F5E, (q15_t)0x9B74, (q15_t)0x4F36, (q15_t)0x9B55, (q15_t)0x4F0F, + (q15_t)0x9B36, (q15_t)0x4EE7, (q15_t)0x9B17, (q15_t)0x4EBF, (q15_t)0x9AF8, + (q15_t)0x4E98, (q15_t)0x9AD9, (q15_t)0x4E70, (q15_t)0x9ABA, (q15_t)0x4E48, + (q15_t)0x9A9C, (q15_t)0x4E21, (q15_t)0x9A7D, (q15_t)0x4DF9, (q15_t)0x9A5F, + (q15_t)0x4DD1, (q15_t)0x9A40, (q15_t)0x4DA9, (q15_t)0x9A22, (q15_t)0x4D81, + (q15_t)0x9A03, (q15_t)0x4D59, (q15_t)0x99E5, (q15_t)0x4D31, (q15_t)0x99C6, + (q15_t)0x4D09, (q15_t)0x99A8, (q15_t)0x4CE1, (q15_t)0x998A, (q15_t)0x4CB8, + (q15_t)0x996C, (q15_t)0x4C90, (q15_t)0x994E, (q15_t)0x4C68, (q15_t)0x9930, + (q15_t)0x4C3F, (q15_t)0x9912, (q15_t)0x4C17, (q15_t)0x98F4, (q15_t)0x4BEF, + (q15_t)0x98D6, (q15_t)0x4BC6, (q15_t)0x98B9, (q15_t)0x4B9E, (q15_t)0x989B, + (q15_t)0x4B75, (q15_t)0x987D, (q15_t)0x4B4C, (q15_t)0x9860, (q15_t)0x4B24, + (q15_t)0x9842, (q15_t)0x4AFB, (q15_t)0x9825, (q15_t)0x4AD2, (q15_t)0x9808, + (q15_t)0x4AA9, (q15_t)0x97EA, (q15_t)0x4A81, (q15_t)0x97CD, (q15_t)0x4A58, + (q15_t)0x97B0, (q15_t)0x4A2F, (q15_t)0x9793, (q15_t)0x4A06, (q15_t)0x9776, + (q15_t)0x49DD, (q15_t)0x9759, (q15_t)0x49B4, (q15_t)0x973C, (q15_t)0x498A, + (q15_t)0x971F, (q15_t)0x4961, (q15_t)0x9702, (q15_t)0x4938, (q15_t)0x96E6, + (q15_t)0x490F, (q15_t)0x96C9, (q15_t)0x48E6, (q15_t)0x96AC, (q15_t)0x48BC, + (q15_t)0x9690, (q15_t)0x4893, (q15_t)0x9673, (q15_t)0x4869, (q15_t)0x9657, + (q15_t)0x4840, (q15_t)0x963B, (q15_t)0x4816, (q15_t)0x961E, (q15_t)0x47ED, + (q15_t)0x9602, (q15_t)0x47C3, (q15_t)0x95E6, (q15_t)0x479A, (q15_t)0x95CA, + (q15_t)0x4770, (q15_t)0x95AE, (q15_t)0x4746, (q15_t)0x9592, (q15_t)0x471C, + (q15_t)0x9576, (q15_t)0x46F3, (q15_t)0x955A, (q15_t)0x46C9, (q15_t)0x953E, + (q15_t)0x469F, (q15_t)0x9523, (q15_t)0x4675, (q15_t)0x9507, (q15_t)0x464B, + (q15_t)0x94EC, (q15_t)0x4621, (q15_t)0x94D0, (q15_t)0x45F7, (q15_t)0x94B5, + (q15_t)0x45CD, (q15_t)0x9499, (q15_t)0x45A3, (q15_t)0x947E, (q15_t)0x4578, + (q15_t)0x9463, (q15_t)0x454E, (q15_t)0x9447, (q15_t)0x4524, (q15_t)0x942C, + (q15_t)0x44FA, (q15_t)0x9411, (q15_t)0x44CF, (q15_t)0x93F6, (q15_t)0x44A5, + (q15_t)0x93DB, (q15_t)0x447A, (q15_t)0x93C0, (q15_t)0x4450, (q15_t)0x93A6, + (q15_t)0x4425, (q15_t)0x938B, (q15_t)0x43FB, (q15_t)0x9370, (q15_t)0x43D0, + (q15_t)0x9356, (q15_t)0x43A5, (q15_t)0x933B, (q15_t)0x437B, (q15_t)0x9321, + (q15_t)0x4350, (q15_t)0x9306, (q15_t)0x4325, (q15_t)0x92EC, (q15_t)0x42FA, + (q15_t)0x92D2, (q15_t)0x42D0, (q15_t)0x92B7, (q15_t)0x42A5, (q15_t)0x929D, + (q15_t)0x427A, (q15_t)0x9283, (q15_t)0x424F, (q15_t)0x9269, (q15_t)0x4224, + (q15_t)0x924F, (q15_t)0x41F9, (q15_t)0x9235, (q15_t)0x41CE, (q15_t)0x921C, + (q15_t)0x41A2, (q15_t)0x9202, (q15_t)0x4177, (q15_t)0x91E8, (q15_t)0x414C, + (q15_t)0x91CF, (q15_t)0x4121, (q15_t)0x91B5, (q15_t)0x40F6, (q15_t)0x919C, + (q15_t)0x40CA, (q15_t)0x9182, (q15_t)0x409F, (q15_t)0x9169, (q15_t)0x4073, + (q15_t)0x9150, (q15_t)0x4048, (q15_t)0x9136, (q15_t)0x401D, (q15_t)0x911D, + (q15_t)0x3FF1, (q15_t)0x9104, (q15_t)0x3FC5, (q15_t)0x90EB, (q15_t)0x3F9A, + (q15_t)0x90D2, (q15_t)0x3F6E, (q15_t)0x90B9, (q15_t)0x3F43, (q15_t)0x90A0, + (q15_t)0x3F17, (q15_t)0x9088, (q15_t)0x3EEB, (q15_t)0x906F, (q15_t)0x3EBF, + (q15_t)0x9056, (q15_t)0x3E93, (q15_t)0x903E, (q15_t)0x3E68, (q15_t)0x9025, + (q15_t)0x3E3C, (q15_t)0x900D, (q15_t)0x3E10, (q15_t)0x8FF5, (q15_t)0x3DE4, + (q15_t)0x8FDC, (q15_t)0x3DB8, (q15_t)0x8FC4, (q15_t)0x3D8C, (q15_t)0x8FAC, + (q15_t)0x3D60, (q15_t)0x8F94, (q15_t)0x3D33, (q15_t)0x8F7C, (q15_t)0x3D07, + (q15_t)0x8F64, (q15_t)0x3CDB, (q15_t)0x8F4C, (q15_t)0x3CAF, (q15_t)0x8F34, + (q15_t)0x3C83, (q15_t)0x8F1D, (q15_t)0x3C56, (q15_t)0x8F05, (q15_t)0x3C2A, + (q15_t)0x8EED, (q15_t)0x3BFD, (q15_t)0x8ED6, (q15_t)0x3BD1, (q15_t)0x8EBE, + (q15_t)0x3BA5, (q15_t)0x8EA7, (q15_t)0x3B78, (q15_t)0x8E90, (q15_t)0x3B4C, + (q15_t)0x8E79, (q15_t)0x3B1F, (q15_t)0x8E61, (q15_t)0x3AF2, (q15_t)0x8E4A, + (q15_t)0x3AC6, (q15_t)0x8E33, (q15_t)0x3A99, (q15_t)0x8E1C, (q15_t)0x3A6C, + (q15_t)0x8E05, (q15_t)0x3A40, (q15_t)0x8DEE, (q15_t)0x3A13, (q15_t)0x8DD8, + (q15_t)0x39E6, (q15_t)0x8DC1, (q15_t)0x39B9, (q15_t)0x8DAA, (q15_t)0x398C, + (q15_t)0x8D94, (q15_t)0x395F, (q15_t)0x8D7D, (q15_t)0x3932, (q15_t)0x8D67, + (q15_t)0x3906, (q15_t)0x8D50, (q15_t)0x38D8, (q15_t)0x8D3A, (q15_t)0x38AB, + (q15_t)0x8D24, (q15_t)0x387E, (q15_t)0x8D0E, (q15_t)0x3851, (q15_t)0x8CF8, + (q15_t)0x3824, (q15_t)0x8CE2, (q15_t)0x37F7, (q15_t)0x8CCC, (q15_t)0x37CA, + (q15_t)0x8CB6, (q15_t)0x379C, (q15_t)0x8CA0, (q15_t)0x376F, (q15_t)0x8C8A, + (q15_t)0x3742, (q15_t)0x8C75, (q15_t)0x3714, (q15_t)0x8C5F, (q15_t)0x36E7, + (q15_t)0x8C4A, (q15_t)0x36BA, (q15_t)0x8C34, (q15_t)0x368C, (q15_t)0x8C1F, + (q15_t)0x365F, (q15_t)0x8C09, (q15_t)0x3631, (q15_t)0x8BF4, (q15_t)0x3604, + (q15_t)0x8BDF, (q15_t)0x35D6, (q15_t)0x8BCA, (q15_t)0x35A8, (q15_t)0x8BB5, + (q15_t)0x357B, (q15_t)0x8BA0, (q15_t)0x354D, (q15_t)0x8B8B, (q15_t)0x351F, + (q15_t)0x8B76, (q15_t)0x34F2, (q15_t)0x8B61, (q15_t)0x34C4, (q15_t)0x8B4D, + (q15_t)0x3496, (q15_t)0x8B38, (q15_t)0x3468, (q15_t)0x8B24, (q15_t)0x343A, + (q15_t)0x8B0F, (q15_t)0x340C, (q15_t)0x8AFB, (q15_t)0x33DE, (q15_t)0x8AE6, + (q15_t)0x33B0, (q15_t)0x8AD2, (q15_t)0x3382, (q15_t)0x8ABE, (q15_t)0x3354, + (q15_t)0x8AAA, (q15_t)0x3326, (q15_t)0x8A96, (q15_t)0x32F8, (q15_t)0x8A82, + (q15_t)0x32CA, (q15_t)0x8A6E, (q15_t)0x329C, (q15_t)0x8A5A, (q15_t)0x326E, + (q15_t)0x8A46, (q15_t)0x3240, (q15_t)0x8A33, (q15_t)0x3211, (q15_t)0x8A1F, + (q15_t)0x31E3, (q15_t)0x8A0B, (q15_t)0x31B5, (q15_t)0x89F8, (q15_t)0x3186, + (q15_t)0x89E4, (q15_t)0x3158, (q15_t)0x89D1, (q15_t)0x312A, (q15_t)0x89BE, + (q15_t)0x30FB, (q15_t)0x89AB, (q15_t)0x30CD, (q15_t)0x8997, (q15_t)0x309E, + (q15_t)0x8984, (q15_t)0x3070, (q15_t)0x8971, (q15_t)0x3041, (q15_t)0x895F, + (q15_t)0x3013, (q15_t)0x894C, (q15_t)0x2FE4, (q15_t)0x8939, (q15_t)0x2FB5, + (q15_t)0x8926, (q15_t)0x2F87, (q15_t)0x8914, (q15_t)0x2F58, (q15_t)0x8901, + (q15_t)0x2F29, (q15_t)0x88EF, (q15_t)0x2EFB, (q15_t)0x88DC, (q15_t)0x2ECC, + (q15_t)0x88CA, (q15_t)0x2E9D, (q15_t)0x88B8, (q15_t)0x2E6E, (q15_t)0x88A5, + (q15_t)0x2E3F, (q15_t)0x8893, (q15_t)0x2E11, (q15_t)0x8881, (q15_t)0x2DE2, + (q15_t)0x886F, (q15_t)0x2DB3, (q15_t)0x885D, (q15_t)0x2D84, (q15_t)0x884B, + (q15_t)0x2D55, (q15_t)0x883A, (q15_t)0x2D26, (q15_t)0x8828, (q15_t)0x2CF7, + (q15_t)0x8816, (q15_t)0x2CC8, (q15_t)0x8805, (q15_t)0x2C98, (q15_t)0x87F3, + (q15_t)0x2C69, (q15_t)0x87E2, (q15_t)0x2C3A, (q15_t)0x87D1, (q15_t)0x2C0B, + (q15_t)0x87BF, (q15_t)0x2BDC, (q15_t)0x87AE, (q15_t)0x2BAD, (q15_t)0x879D, + (q15_t)0x2B7D, (q15_t)0x878C, (q15_t)0x2B4E, (q15_t)0x877B, (q15_t)0x2B1F, + (q15_t)0x876A, (q15_t)0x2AEF, (q15_t)0x8759, (q15_t)0x2AC0, (q15_t)0x8749, + (q15_t)0x2A91, (q15_t)0x8738, (q15_t)0x2A61, (q15_t)0x8727, (q15_t)0x2A32, + (q15_t)0x8717, (q15_t)0x2A02, (q15_t)0x8706, (q15_t)0x29D3, (q15_t)0x86F6, + (q15_t)0x29A3, (q15_t)0x86E6, (q15_t)0x2974, (q15_t)0x86D5, (q15_t)0x2944, + (q15_t)0x86C5, (q15_t)0x2915, (q15_t)0x86B5, (q15_t)0x28E5, (q15_t)0x86A5, + (q15_t)0x28B5, (q15_t)0x8695, (q15_t)0x2886, (q15_t)0x8685, (q15_t)0x2856, + (q15_t)0x8675, (q15_t)0x2826, (q15_t)0x8666, (q15_t)0x27F6, (q15_t)0x8656, + (q15_t)0x27C7, (q15_t)0x8646, (q15_t)0x2797, (q15_t)0x8637, (q15_t)0x2767, + (q15_t)0x8627, (q15_t)0x2737, (q15_t)0x8618, (q15_t)0x2707, (q15_t)0x8609, + (q15_t)0x26D8, (q15_t)0x85FA, (q15_t)0x26A8, (q15_t)0x85EA, (q15_t)0x2678, + (q15_t)0x85DB, (q15_t)0x2648, (q15_t)0x85CC, (q15_t)0x2618, (q15_t)0x85BD, + (q15_t)0x25E8, (q15_t)0x85AF, (q15_t)0x25B8, (q15_t)0x85A0, (q15_t)0x2588, + (q15_t)0x8591, (q15_t)0x2558, (q15_t)0x8582, (q15_t)0x2528, (q15_t)0x8574, + (q15_t)0x24F7, (q15_t)0x8565, (q15_t)0x24C7, (q15_t)0x8557, (q15_t)0x2497, + (q15_t)0x8549, (q15_t)0x2467, (q15_t)0x853A, (q15_t)0x2437, (q15_t)0x852C, + (q15_t)0x2407, (q15_t)0x851E, (q15_t)0x23D6, (q15_t)0x8510, (q15_t)0x23A6, + (q15_t)0x8502, (q15_t)0x2376, (q15_t)0x84F4, (q15_t)0x2345, (q15_t)0x84E6, + (q15_t)0x2315, (q15_t)0x84D9, (q15_t)0x22E5, (q15_t)0x84CB, (q15_t)0x22B4, + (q15_t)0x84BD, (q15_t)0x2284, (q15_t)0x84B0, (q15_t)0x2254, (q15_t)0x84A2, + (q15_t)0x2223, (q15_t)0x8495, (q15_t)0x21F3, (q15_t)0x8488, (q15_t)0x21C2, + (q15_t)0x847B, (q15_t)0x2192, (q15_t)0x846D, (q15_t)0x2161, (q15_t)0x8460, + (q15_t)0x2131, (q15_t)0x8453, (q15_t)0x2100, (q15_t)0x8446, (q15_t)0x20D0, + (q15_t)0x843A, (q15_t)0x209F, (q15_t)0x842D, (q15_t)0x206E, (q15_t)0x8420, + (q15_t)0x203E, (q15_t)0x8414, (q15_t)0x200D, (q15_t)0x8407, (q15_t)0x1FDC, + (q15_t)0x83FA, (q15_t)0x1FAC, (q15_t)0x83EE, (q15_t)0x1F7B, (q15_t)0x83E2, + (q15_t)0x1F4A, (q15_t)0x83D6, (q15_t)0x1F19, (q15_t)0x83C9, (q15_t)0x1EE9, + (q15_t)0x83BD, (q15_t)0x1EB8, (q15_t)0x83B1, (q15_t)0x1E87, (q15_t)0x83A5, + (q15_t)0x1E56, (q15_t)0x8399, (q15_t)0x1E25, (q15_t)0x838E, (q15_t)0x1DF5, + (q15_t)0x8382, (q15_t)0x1DC4, (q15_t)0x8376, (q15_t)0x1D93, (q15_t)0x836B, + (q15_t)0x1D62, (q15_t)0x835F, (q15_t)0x1D31, (q15_t)0x8354, (q15_t)0x1D00, + (q15_t)0x8348, (q15_t)0x1CCF, (q15_t)0x833D, (q15_t)0x1C9E, (q15_t)0x8332, + (q15_t)0x1C6D, (q15_t)0x8327, (q15_t)0x1C3C, (q15_t)0x831C, (q15_t)0x1C0B, + (q15_t)0x8311, (q15_t)0x1BDA, (q15_t)0x8306, (q15_t)0x1BA9, (q15_t)0x82FB, + (q15_t)0x1B78, (q15_t)0x82F0, (q15_t)0x1B47, (q15_t)0x82E6, (q15_t)0x1B16, + (q15_t)0x82DB, (q15_t)0x1AE4, (q15_t)0x82D0, (q15_t)0x1AB3, (q15_t)0x82C6, + (q15_t)0x1A82, (q15_t)0x82BC, (q15_t)0x1A51, (q15_t)0x82B1, (q15_t)0x1A20, + (q15_t)0x82A7, (q15_t)0x19EF, (q15_t)0x829D, (q15_t)0x19BD, (q15_t)0x8293, + (q15_t)0x198C, (q15_t)0x8289, (q15_t)0x195B, (q15_t)0x827F, (q15_t)0x192A, + (q15_t)0x8275, (q15_t)0x18F8, (q15_t)0x826B, (q15_t)0x18C7, (q15_t)0x8262, + (q15_t)0x1896, (q15_t)0x8258, (q15_t)0x1864, (q15_t)0x824F, (q15_t)0x1833, + (q15_t)0x8245, (q15_t)0x1802, (q15_t)0x823C, (q15_t)0x17D0, (q15_t)0x8232, + (q15_t)0x179F, (q15_t)0x8229, (q15_t)0x176D, (q15_t)0x8220, (q15_t)0x173C, + (q15_t)0x8217, (q15_t)0x170A, (q15_t)0x820E, (q15_t)0x16D9, (q15_t)0x8205, + (q15_t)0x16A8, (q15_t)0x81FC, (q15_t)0x1676, (q15_t)0x81F3, (q15_t)0x1645, + (q15_t)0x81EB, (q15_t)0x1613, (q15_t)0x81E2, (q15_t)0x15E2, (q15_t)0x81D9, + (q15_t)0x15B0, (q15_t)0x81D1, (q15_t)0x157F, (q15_t)0x81C8, (q15_t)0x154D, + (q15_t)0x81C0, (q15_t)0x151B, (q15_t)0x81B8, (q15_t)0x14EA, (q15_t)0x81B0, + (q15_t)0x14B8, (q15_t)0x81A8, (q15_t)0x1487, (q15_t)0x81A0, (q15_t)0x1455, + (q15_t)0x8198, (q15_t)0x1423, (q15_t)0x8190, (q15_t)0x13F2, (q15_t)0x8188, + (q15_t)0x13C0, (q15_t)0x8180, (q15_t)0x138E, (q15_t)0x8179, (q15_t)0x135D, + (q15_t)0x8171, (q15_t)0x132B, (q15_t)0x816A, (q15_t)0x12F9, (q15_t)0x8162, + (q15_t)0x12C8, (q15_t)0x815B, (q15_t)0x1296, (q15_t)0x8154, (q15_t)0x1264, + (q15_t)0x814C, (q15_t)0x1232, (q15_t)0x8145, (q15_t)0x1201, (q15_t)0x813E, + (q15_t)0x11CF, (q15_t)0x8137, (q15_t)0x119D, (q15_t)0x8130, (q15_t)0x116B, + (q15_t)0x812A, (q15_t)0x1139, (q15_t)0x8123, (q15_t)0x1108, (q15_t)0x811C, + (q15_t)0x10D6, (q15_t)0x8116, (q15_t)0x10A4, (q15_t)0x810F, (q15_t)0x1072, + (q15_t)0x8109, (q15_t)0x1040, (q15_t)0x8102, (q15_t)0x100E, (q15_t)0x80FC, + (q15_t)0x0FDD, (q15_t)0x80F6, (q15_t)0x0FAB, (q15_t)0x80F0, (q15_t)0x0F79, + (q15_t)0x80EA, (q15_t)0x0F47, (q15_t)0x80E4, (q15_t)0x0F15, (q15_t)0x80DE, + (q15_t)0x0EE3, (q15_t)0x80D8, (q15_t)0x0EB1, (q15_t)0x80D2, (q15_t)0x0E7F, + (q15_t)0x80CD, (q15_t)0x0E4D, (q15_t)0x80C7, (q15_t)0x0E1B, (q15_t)0x80C2, + (q15_t)0x0DE9, (q15_t)0x80BC, (q15_t)0x0DB7, (q15_t)0x80B7, (q15_t)0x0D85, + (q15_t)0x80B2, (q15_t)0x0D53, (q15_t)0x80AC, (q15_t)0x0D21, (q15_t)0x80A7, + (q15_t)0x0CEF, (q15_t)0x80A2, (q15_t)0x0CBD, (q15_t)0x809D, (q15_t)0x0C8B, + (q15_t)0x8098, (q15_t)0x0C59, (q15_t)0x8094, (q15_t)0x0C27, (q15_t)0x808F, + (q15_t)0x0BF5, (q15_t)0x808A, (q15_t)0x0BC3, (q15_t)0x8086, (q15_t)0x0B91, + (q15_t)0x8081, (q15_t)0x0B5F, (q15_t)0x807D, (q15_t)0x0B2D, (q15_t)0x8078, + (q15_t)0x0AFB, (q15_t)0x8074, (q15_t)0x0AC9, (q15_t)0x8070, (q15_t)0x0A97, + (q15_t)0x806C, (q15_t)0x0A65, (q15_t)0x8068, (q15_t)0x0A33, (q15_t)0x8064, + (q15_t)0x0A00, (q15_t)0x8060, (q15_t)0x09CE, (q15_t)0x805C, (q15_t)0x099C, + (q15_t)0x8058, (q15_t)0x096A, (q15_t)0x8055, (q15_t)0x0938, (q15_t)0x8051, + (q15_t)0x0906, (q15_t)0x804E, (q15_t)0x08D4, (q15_t)0x804A, (q15_t)0x08A2, + (q15_t)0x8047, (q15_t)0x086F, (q15_t)0x8043, (q15_t)0x083D, (q15_t)0x8040, + (q15_t)0x080B, (q15_t)0x803D, (q15_t)0x07D9, (q15_t)0x803A, (q15_t)0x07A7, + (q15_t)0x8037, (q15_t)0x0775, (q15_t)0x8034, (q15_t)0x0742, (q15_t)0x8031, + (q15_t)0x0710, (q15_t)0x802F, (q15_t)0x06DE, (q15_t)0x802C, (q15_t)0x06AC, + (q15_t)0x8029, (q15_t)0x067A, (q15_t)0x8027, (q15_t)0x0647, (q15_t)0x8025, + (q15_t)0x0615, (q15_t)0x8022, (q15_t)0x05E3, (q15_t)0x8020, (q15_t)0x05B1, + (q15_t)0x801E, (q15_t)0x057F, (q15_t)0x801C, (q15_t)0x054C, (q15_t)0x801A, + (q15_t)0x051A, (q15_t)0x8018, (q15_t)0x04E8, (q15_t)0x8016, (q15_t)0x04B6, + (q15_t)0x8014, (q15_t)0x0483, (q15_t)0x8012, (q15_t)0x0451, (q15_t)0x8011, + (q15_t)0x041F, (q15_t)0x800F, (q15_t)0x03ED, (q15_t)0x800D, (q15_t)0x03BA, + (q15_t)0x800C, (q15_t)0x0388, (q15_t)0x800B, (q15_t)0x0356, (q15_t)0x8009, + (q15_t)0x0324, (q15_t)0x8008, (q15_t)0x02F1, (q15_t)0x8007, (q15_t)0x02BF, + (q15_t)0x8006, (q15_t)0x028D, (q15_t)0x8005, (q15_t)0x025B, (q15_t)0x8004, + (q15_t)0x0228, (q15_t)0x8003, (q15_t)0x01F6, (q15_t)0x8003, (q15_t)0x01C4, + (q15_t)0x8002, (q15_t)0x0192, (q15_t)0x8001, (q15_t)0x015F, (q15_t)0x8001, + (q15_t)0x012D, (q15_t)0x8000, (q15_t)0x00FB, (q15_t)0x8000, (q15_t)0x00C9, + (q15_t)0x8000, (q15_t)0x0096, (q15_t)0x8000, (q15_t)0x0064, (q15_t)0x8000, + (q15_t)0x0032, (q15_t)0x8000, (q15_t)0x0000, (q15_t)0x8000, (q15_t)0xFFCD, + (q15_t)0x8000, (q15_t)0xFF9B, (q15_t)0x8000, (q15_t)0xFF69, (q15_t)0x8000, + (q15_t)0xFF36, (q15_t)0x8000, (q15_t)0xFF04, (q15_t)0x8001, (q15_t)0xFED2, + (q15_t)0x8001, (q15_t)0xFEA0, (q15_t)0x8002, (q15_t)0xFE6D, (q15_t)0x8003, + (q15_t)0xFE3B, (q15_t)0x8003, (q15_t)0xFE09, (q15_t)0x8004, (q15_t)0xFDD7, + (q15_t)0x8005, (q15_t)0xFDA4, (q15_t)0x8006, (q15_t)0xFD72, (q15_t)0x8007, + (q15_t)0xFD40, (q15_t)0x8008, (q15_t)0xFD0E, (q15_t)0x8009, (q15_t)0xFCDB, + (q15_t)0x800B, (q15_t)0xFCA9, (q15_t)0x800C, (q15_t)0xFC77, (q15_t)0x800D, + (q15_t)0xFC45, (q15_t)0x800F, (q15_t)0xFC12, (q15_t)0x8011, (q15_t)0xFBE0, + (q15_t)0x8012, (q15_t)0xFBAE, (q15_t)0x8014, (q15_t)0xFB7C, (q15_t)0x8016, + (q15_t)0xFB49, (q15_t)0x8018, (q15_t)0xFB17, (q15_t)0x801A, (q15_t)0xFAE5, + (q15_t)0x801C, (q15_t)0xFAB3, (q15_t)0x801E, (q15_t)0xFA80, (q15_t)0x8020, + (q15_t)0xFA4E, (q15_t)0x8022, (q15_t)0xFA1C, (q15_t)0x8025, (q15_t)0xF9EA, + (q15_t)0x8027, (q15_t)0xF9B8, (q15_t)0x8029, (q15_t)0xF985, (q15_t)0x802C, + (q15_t)0xF953, (q15_t)0x802F, (q15_t)0xF921, (q15_t)0x8031, (q15_t)0xF8EF, + (q15_t)0x8034, (q15_t)0xF8BD, (q15_t)0x8037, (q15_t)0xF88A, (q15_t)0x803A, + (q15_t)0xF858, (q15_t)0x803D, (q15_t)0xF826, (q15_t)0x8040, (q15_t)0xF7F4, + (q15_t)0x8043, (q15_t)0xF7C2, (q15_t)0x8047, (q15_t)0xF790, (q15_t)0x804A, + (q15_t)0xF75D, (q15_t)0x804E, (q15_t)0xF72B, (q15_t)0x8051, (q15_t)0xF6F9, + (q15_t)0x8055, (q15_t)0xF6C7, (q15_t)0x8058, (q15_t)0xF695, (q15_t)0x805C, + (q15_t)0xF663, (q15_t)0x8060, (q15_t)0xF631, (q15_t)0x8064, (q15_t)0xF5FF, + (q15_t)0x8068, (q15_t)0xF5CC, (q15_t)0x806C, (q15_t)0xF59A, (q15_t)0x8070, + (q15_t)0xF568, (q15_t)0x8074, (q15_t)0xF536, (q15_t)0x8078, (q15_t)0xF504, + (q15_t)0x807D, (q15_t)0xF4D2, (q15_t)0x8081, (q15_t)0xF4A0, (q15_t)0x8086, + (q15_t)0xF46E, (q15_t)0x808A, (q15_t)0xF43C, (q15_t)0x808F, (q15_t)0xF40A, + (q15_t)0x8094, (q15_t)0xF3D8, (q15_t)0x8098, (q15_t)0xF3A6, (q15_t)0x809D, + (q15_t)0xF374, (q15_t)0x80A2, (q15_t)0xF342, (q15_t)0x80A7, (q15_t)0xF310, + (q15_t)0x80AC, (q15_t)0xF2DE, (q15_t)0x80B2, (q15_t)0xF2AC, (q15_t)0x80B7, + (q15_t)0xF27A, (q15_t)0x80BC, (q15_t)0xF248, (q15_t)0x80C2, (q15_t)0xF216, + (q15_t)0x80C7, (q15_t)0xF1E4, (q15_t)0x80CD, (q15_t)0xF1B2, (q15_t)0x80D2, + (q15_t)0xF180, (q15_t)0x80D8, (q15_t)0xF14E, (q15_t)0x80DE, (q15_t)0xF11C, + (q15_t)0x80E4, (q15_t)0xF0EA, (q15_t)0x80EA, (q15_t)0xF0B8, (q15_t)0x80F0, + (q15_t)0xF086, (q15_t)0x80F6, (q15_t)0xF054, (q15_t)0x80FC, (q15_t)0xF022, + (q15_t)0x8102, (q15_t)0xEFF1, (q15_t)0x8109, (q15_t)0xEFBF, (q15_t)0x810F, + (q15_t)0xEF8D, (q15_t)0x8116, (q15_t)0xEF5B, (q15_t)0x811C, (q15_t)0xEF29, + (q15_t)0x8123, (q15_t)0xEEF7, (q15_t)0x812A, (q15_t)0xEEC6, (q15_t)0x8130, + (q15_t)0xEE94, (q15_t)0x8137, (q15_t)0xEE62, (q15_t)0x813E, (q15_t)0xEE30, + (q15_t)0x8145, (q15_t)0xEDFE, (q15_t)0x814C, (q15_t)0xEDCD, (q15_t)0x8154, + (q15_t)0xED9B, (q15_t)0x815B, (q15_t)0xED69, (q15_t)0x8162, (q15_t)0xED37, + (q15_t)0x816A, (q15_t)0xED06, (q15_t)0x8171, (q15_t)0xECD4, (q15_t)0x8179, + (q15_t)0xECA2, (q15_t)0x8180, (q15_t)0xEC71, (q15_t)0x8188, (q15_t)0xEC3F, + (q15_t)0x8190, (q15_t)0xEC0D, (q15_t)0x8198, (q15_t)0xEBDC, (q15_t)0x81A0, + (q15_t)0xEBAA, (q15_t)0x81A8, (q15_t)0xEB78, (q15_t)0x81B0, (q15_t)0xEB47, + (q15_t)0x81B8, (q15_t)0xEB15, (q15_t)0x81C0, (q15_t)0xEAE4, (q15_t)0x81C8, + (q15_t)0xEAB2, (q15_t)0x81D1, (q15_t)0xEA80, (q15_t)0x81D9, (q15_t)0xEA4F, + (q15_t)0x81E2, (q15_t)0xEA1D, (q15_t)0x81EB, (q15_t)0xE9EC, (q15_t)0x81F3, + (q15_t)0xE9BA, (q15_t)0x81FC, (q15_t)0xE989, (q15_t)0x8205, (q15_t)0xE957, + (q15_t)0x820E, (q15_t)0xE926, (q15_t)0x8217, (q15_t)0xE8F5, (q15_t)0x8220, + (q15_t)0xE8C3, (q15_t)0x8229, (q15_t)0xE892, (q15_t)0x8232, (q15_t)0xE860, + (q15_t)0x823C, (q15_t)0xE82F, (q15_t)0x8245, (q15_t)0xE7FD, (q15_t)0x824F, + (q15_t)0xE7CC, (q15_t)0x8258, (q15_t)0xE79B, (q15_t)0x8262, (q15_t)0xE769, + (q15_t)0x826B, (q15_t)0xE738, (q15_t)0x8275, (q15_t)0xE707, (q15_t)0x827F, + (q15_t)0xE6D5, (q15_t)0x8289, (q15_t)0xE6A4, (q15_t)0x8293, (q15_t)0xE673, + (q15_t)0x829D, (q15_t)0xE642, (q15_t)0x82A7, (q15_t)0xE610, (q15_t)0x82B1, + (q15_t)0xE5DF, (q15_t)0x82BC, (q15_t)0xE5AE, (q15_t)0x82C6, (q15_t)0xE57D, + (q15_t)0x82D0, (q15_t)0xE54C, (q15_t)0x82DB, (q15_t)0xE51B, (q15_t)0x82E6, + (q15_t)0xE4E9, (q15_t)0x82F0, (q15_t)0xE4B8, (q15_t)0x82FB, (q15_t)0xE487, + (q15_t)0x8306, (q15_t)0xE456, (q15_t)0x8311, (q15_t)0xE425, (q15_t)0x831C, + (q15_t)0xE3F4, (q15_t)0x8327, (q15_t)0xE3C3, (q15_t)0x8332, (q15_t)0xE392, + (q15_t)0x833D, (q15_t)0xE361, (q15_t)0x8348, (q15_t)0xE330, (q15_t)0x8354, + (q15_t)0xE2FF, (q15_t)0x835F, (q15_t)0xE2CE, (q15_t)0x836B, (q15_t)0xE29D, + (q15_t)0x8376, (q15_t)0xE26C, (q15_t)0x8382, (q15_t)0xE23B, (q15_t)0x838E, + (q15_t)0xE20A, (q15_t)0x8399, (q15_t)0xE1DA, (q15_t)0x83A5, (q15_t)0xE1A9, + (q15_t)0x83B1, (q15_t)0xE178, (q15_t)0x83BD, (q15_t)0xE147, (q15_t)0x83C9, + (q15_t)0xE116, (q15_t)0x83D6, (q15_t)0xE0E6, (q15_t)0x83E2, (q15_t)0xE0B5, + (q15_t)0x83EE, (q15_t)0xE084, (q15_t)0x83FA, (q15_t)0xE053, (q15_t)0x8407, + (q15_t)0xE023, (q15_t)0x8414, (q15_t)0xDFF2, (q15_t)0x8420, (q15_t)0xDFC1, + (q15_t)0x842D, (q15_t)0xDF91, (q15_t)0x843A, (q15_t)0xDF60, (q15_t)0x8446, + (q15_t)0xDF2F, (q15_t)0x8453, (q15_t)0xDEFF, (q15_t)0x8460, (q15_t)0xDECE, + (q15_t)0x846D, (q15_t)0xDE9E, (q15_t)0x847B, (q15_t)0xDE6D, (q15_t)0x8488, + (q15_t)0xDE3D, (q15_t)0x8495, (q15_t)0xDE0C, (q15_t)0x84A2, (q15_t)0xDDDC, + (q15_t)0x84B0, (q15_t)0xDDAB, (q15_t)0x84BD, (q15_t)0xDD7B, (q15_t)0x84CB, + (q15_t)0xDD4B, (q15_t)0x84D9, (q15_t)0xDD1A, (q15_t)0x84E6, (q15_t)0xDCEA, + (q15_t)0x84F4, (q15_t)0xDCBA, (q15_t)0x8502, (q15_t)0xDC89, (q15_t)0x8510, + (q15_t)0xDC59, (q15_t)0x851E, (q15_t)0xDC29, (q15_t)0x852C, (q15_t)0xDBF8, + (q15_t)0x853A, (q15_t)0xDBC8, (q15_t)0x8549, (q15_t)0xDB98, (q15_t)0x8557, + (q15_t)0xDB68, (q15_t)0x8565, (q15_t)0xDB38, (q15_t)0x8574, (q15_t)0xDB08, + (q15_t)0x8582, (q15_t)0xDAD7, (q15_t)0x8591, (q15_t)0xDAA7, (q15_t)0x85A0, + (q15_t)0xDA77, (q15_t)0x85AF, (q15_t)0xDA47, (q15_t)0x85BD, (q15_t)0xDA17, + (q15_t)0x85CC, (q15_t)0xD9E7, (q15_t)0x85DB, (q15_t)0xD9B7, (q15_t)0x85EA, + (q15_t)0xD987, (q15_t)0x85FA, (q15_t)0xD957, (q15_t)0x8609, (q15_t)0xD927, + (q15_t)0x8618, (q15_t)0xD8F8, (q15_t)0x8627, (q15_t)0xD8C8, (q15_t)0x8637, + (q15_t)0xD898, (q15_t)0x8646, (q15_t)0xD868, (q15_t)0x8656, (q15_t)0xD838, + (q15_t)0x8666, (q15_t)0xD809, (q15_t)0x8675, (q15_t)0xD7D9, (q15_t)0x8685, + (q15_t)0xD7A9, (q15_t)0x8695, (q15_t)0xD779, (q15_t)0x86A5, (q15_t)0xD74A, + (q15_t)0x86B5, (q15_t)0xD71A, (q15_t)0x86C5, (q15_t)0xD6EA, (q15_t)0x86D5, + (q15_t)0xD6BB, (q15_t)0x86E6, (q15_t)0xD68B, (q15_t)0x86F6, (q15_t)0xD65C, + (q15_t)0x8706, (q15_t)0xD62C, (q15_t)0x8717, (q15_t)0xD5FD, (q15_t)0x8727, + (q15_t)0xD5CD, (q15_t)0x8738, (q15_t)0xD59E, (q15_t)0x8749, (q15_t)0xD56E, + (q15_t)0x8759, (q15_t)0xD53F, (q15_t)0x876A, (q15_t)0xD510, (q15_t)0x877B, + (q15_t)0xD4E0, (q15_t)0x878C, (q15_t)0xD4B1, (q15_t)0x879D, (q15_t)0xD482, + (q15_t)0x87AE, (q15_t)0xD452, (q15_t)0x87BF, (q15_t)0xD423, (q15_t)0x87D1, + (q15_t)0xD3F4, (q15_t)0x87E2, (q15_t)0xD3C5, (q15_t)0x87F3, (q15_t)0xD396, + (q15_t)0x8805, (q15_t)0xD367, (q15_t)0x8816, (q15_t)0xD337, (q15_t)0x8828, + (q15_t)0xD308, (q15_t)0x883A, (q15_t)0xD2D9, (q15_t)0x884B, (q15_t)0xD2AA, + (q15_t)0x885D, (q15_t)0xD27B, (q15_t)0x886F, (q15_t)0xD24C, (q15_t)0x8881, + (q15_t)0xD21D, (q15_t)0x8893, (q15_t)0xD1EE, (q15_t)0x88A5, (q15_t)0xD1C0, + (q15_t)0x88B8, (q15_t)0xD191, (q15_t)0x88CA, (q15_t)0xD162, (q15_t)0x88DC, + (q15_t)0xD133, (q15_t)0x88EF, (q15_t)0xD104, (q15_t)0x8901, (q15_t)0xD0D6, + (q15_t)0x8914, (q15_t)0xD0A7, (q15_t)0x8926, (q15_t)0xD078, (q15_t)0x8939, + (q15_t)0xD04A, (q15_t)0x894C, (q15_t)0xD01B, (q15_t)0x895F, (q15_t)0xCFEC, + (q15_t)0x8971, (q15_t)0xCFBE, (q15_t)0x8984, (q15_t)0xCF8F, (q15_t)0x8997, + (q15_t)0xCF61, (q15_t)0x89AB, (q15_t)0xCF32, (q15_t)0x89BE, (q15_t)0xCF04, + (q15_t)0x89D1, (q15_t)0xCED5, (q15_t)0x89E4, (q15_t)0xCEA7, (q15_t)0x89F8, + (q15_t)0xCE79, (q15_t)0x8A0B, (q15_t)0xCE4A, (q15_t)0x8A1F, (q15_t)0xCE1C, + (q15_t)0x8A33, (q15_t)0xCDEE, (q15_t)0x8A46, (q15_t)0xCDBF, (q15_t)0x8A5A, + (q15_t)0xCD91, (q15_t)0x8A6E, (q15_t)0xCD63, (q15_t)0x8A82, (q15_t)0xCD35, + (q15_t)0x8A96, (q15_t)0xCD07, (q15_t)0x8AAA, (q15_t)0xCCD9, (q15_t)0x8ABE, + (q15_t)0xCCAB, (q15_t)0x8AD2, (q15_t)0xCC7D, (q15_t)0x8AE6, (q15_t)0xCC4F, + (q15_t)0x8AFB, (q15_t)0xCC21, (q15_t)0x8B0F, (q15_t)0xCBF3, (q15_t)0x8B24, + (q15_t)0xCBC5, (q15_t)0x8B38, (q15_t)0xCB97, (q15_t)0x8B4D, (q15_t)0xCB69, + (q15_t)0x8B61, (q15_t)0xCB3B, (q15_t)0x8B76, (q15_t)0xCB0D, (q15_t)0x8B8B, + (q15_t)0xCAE0, (q15_t)0x8BA0, (q15_t)0xCAB2, (q15_t)0x8BB5, (q15_t)0xCA84, + (q15_t)0x8BCA, (q15_t)0xCA57, (q15_t)0x8BDF, (q15_t)0xCA29, (q15_t)0x8BF4, + (q15_t)0xC9FB, (q15_t)0x8C09, (q15_t)0xC9CE, (q15_t)0x8C1F, (q15_t)0xC9A0, + (q15_t)0x8C34, (q15_t)0xC973, (q15_t)0x8C4A, (q15_t)0xC945, (q15_t)0x8C5F, + (q15_t)0xC918, (q15_t)0x8C75, (q15_t)0xC8EB, (q15_t)0x8C8A, (q15_t)0xC8BD, + (q15_t)0x8CA0, (q15_t)0xC890, (q15_t)0x8CB6, (q15_t)0xC863, (q15_t)0x8CCC, + (q15_t)0xC835, (q15_t)0x8CE2, (q15_t)0xC808, (q15_t)0x8CF8, (q15_t)0xC7DB, + (q15_t)0x8D0E, (q15_t)0xC7AE, (q15_t)0x8D24, (q15_t)0xC781, (q15_t)0x8D3A, + (q15_t)0xC754, (q15_t)0x8D50, (q15_t)0xC727, (q15_t)0x8D67, (q15_t)0xC6F9, + (q15_t)0x8D7D, (q15_t)0xC6CD, (q15_t)0x8D94, (q15_t)0xC6A0, (q15_t)0x8DAA, + (q15_t)0xC673, (q15_t)0x8DC1, (q15_t)0xC646, (q15_t)0x8DD8, (q15_t)0xC619, + (q15_t)0x8DEE, (q15_t)0xC5EC, (q15_t)0x8E05, (q15_t)0xC5BF, (q15_t)0x8E1C, + (q15_t)0xC593, (q15_t)0x8E33, (q15_t)0xC566, (q15_t)0x8E4A, (q15_t)0xC539, + (q15_t)0x8E61, (q15_t)0xC50D, (q15_t)0x8E79, (q15_t)0xC4E0, (q15_t)0x8E90, + (q15_t)0xC4B3, (q15_t)0x8EA7, (q15_t)0xC487, (q15_t)0x8EBE, (q15_t)0xC45A, + (q15_t)0x8ED6, (q15_t)0xC42E, (q15_t)0x8EED, (q15_t)0xC402, (q15_t)0x8F05, + (q15_t)0xC3D5, (q15_t)0x8F1D, (q15_t)0xC3A9, (q15_t)0x8F34, (q15_t)0xC37C, + (q15_t)0x8F4C, (q15_t)0xC350, (q15_t)0x8F64, (q15_t)0xC324, (q15_t)0x8F7C, + (q15_t)0xC2F8, (q15_t)0x8F94, (q15_t)0xC2CC, (q15_t)0x8FAC, (q15_t)0xC29F, + (q15_t)0x8FC4, (q15_t)0xC273, (q15_t)0x8FDC, (q15_t)0xC247, (q15_t)0x8FF5, + (q15_t)0xC21B, (q15_t)0x900D, (q15_t)0xC1EF, (q15_t)0x9025, (q15_t)0xC1C3, + (q15_t)0x903E, (q15_t)0xC197, (q15_t)0x9056, (q15_t)0xC16C, (q15_t)0x906F, + (q15_t)0xC140, (q15_t)0x9088, (q15_t)0xC114, (q15_t)0x90A0, (q15_t)0xC0E8, + (q15_t)0x90B9, (q15_t)0xC0BC, (q15_t)0x90D2, (q15_t)0xC091, (q15_t)0x90EB, + (q15_t)0xC065, (q15_t)0x9104, (q15_t)0xC03A, (q15_t)0x911D, (q15_t)0xC00E, + (q15_t)0x9136, (q15_t)0xBFE2, (q15_t)0x9150, (q15_t)0xBFB7, (q15_t)0x9169, + (q15_t)0xBF8C, (q15_t)0x9182, (q15_t)0xBF60, (q15_t)0x919C, (q15_t)0xBF35, + (q15_t)0x91B5, (q15_t)0xBF09, (q15_t)0x91CF, (q15_t)0xBEDE, (q15_t)0x91E8, + (q15_t)0xBEB3, (q15_t)0x9202, (q15_t)0xBE88, (q15_t)0x921C, (q15_t)0xBE5D, + (q15_t)0x9235, (q15_t)0xBE31, (q15_t)0x924F, (q15_t)0xBE06, (q15_t)0x9269, + (q15_t)0xBDDB, (q15_t)0x9283, (q15_t)0xBDB0, (q15_t)0x929D, (q15_t)0xBD85, + (q15_t)0x92B7, (q15_t)0xBD5A, (q15_t)0x92D2, (q15_t)0xBD2F, (q15_t)0x92EC, + (q15_t)0xBD05, (q15_t)0x9306, (q15_t)0xBCDA, (q15_t)0x9321, (q15_t)0xBCAF, + (q15_t)0x933B, (q15_t)0xBC84, (q15_t)0x9356, (q15_t)0xBC5A, (q15_t)0x9370, + (q15_t)0xBC2F, (q15_t)0x938B, (q15_t)0xBC04, (q15_t)0x93A6, (q15_t)0xBBDA, + (q15_t)0x93C0, (q15_t)0xBBAF, (q15_t)0x93DB, (q15_t)0xBB85, (q15_t)0x93F6, + (q15_t)0xBB5A, (q15_t)0x9411, (q15_t)0xBB30, (q15_t)0x942C, (q15_t)0xBB05, + (q15_t)0x9447, (q15_t)0xBADB, (q15_t)0x9463, (q15_t)0xBAB1, (q15_t)0x947E, + (q15_t)0xBA87, (q15_t)0x9499, (q15_t)0xBA5C, (q15_t)0x94B5, (q15_t)0xBA32, + (q15_t)0x94D0, (q15_t)0xBA08, (q15_t)0x94EC, (q15_t)0xB9DE, (q15_t)0x9507, + (q15_t)0xB9B4, (q15_t)0x9523, (q15_t)0xB98A, (q15_t)0x953E, (q15_t)0xB960, + (q15_t)0x955A, (q15_t)0xB936, (q15_t)0x9576, (q15_t)0xB90C, (q15_t)0x9592, + (q15_t)0xB8E3, (q15_t)0x95AE, (q15_t)0xB8B9, (q15_t)0x95CA, (q15_t)0xB88F, + (q15_t)0x95E6, (q15_t)0xB865, (q15_t)0x9602, (q15_t)0xB83C, (q15_t)0x961E, + (q15_t)0xB812, (q15_t)0x963B, (q15_t)0xB7E9, (q15_t)0x9657, (q15_t)0xB7BF, + (q15_t)0x9673, (q15_t)0xB796, (q15_t)0x9690, (q15_t)0xB76C, (q15_t)0x96AC, + (q15_t)0xB743, (q15_t)0x96C9, (q15_t)0xB719, (q15_t)0x96E6, (q15_t)0xB6F0, + (q15_t)0x9702, (q15_t)0xB6C7, (q15_t)0x971F, (q15_t)0xB69E, (q15_t)0x973C, + (q15_t)0xB675, (q15_t)0x9759, (q15_t)0xB64B, (q15_t)0x9776, (q15_t)0xB622, + (q15_t)0x9793, (q15_t)0xB5F9, (q15_t)0x97B0, (q15_t)0xB5D0, (q15_t)0x97CD, + (q15_t)0xB5A7, (q15_t)0x97EA, (q15_t)0xB57E, (q15_t)0x9808, (q15_t)0xB556, + (q15_t)0x9825, (q15_t)0xB52D, (q15_t)0x9842, (q15_t)0xB504, (q15_t)0x9860, + (q15_t)0xB4DB, (q15_t)0x987D, (q15_t)0xB4B3, (q15_t)0x989B, (q15_t)0xB48A, + (q15_t)0x98B9, (q15_t)0xB461, (q15_t)0x98D6, (q15_t)0xB439, (q15_t)0x98F4, + (q15_t)0xB410, (q15_t)0x9912, (q15_t)0xB3E8, (q15_t)0x9930, (q15_t)0xB3C0, + (q15_t)0x994E, (q15_t)0xB397, (q15_t)0x996C, (q15_t)0xB36F, (q15_t)0x998A, + (q15_t)0xB347, (q15_t)0x99A8, (q15_t)0xB31E, (q15_t)0x99C6, (q15_t)0xB2F6, + (q15_t)0x99E5, (q15_t)0xB2CE, (q15_t)0x9A03, (q15_t)0xB2A6, (q15_t)0x9A22, + (q15_t)0xB27E, (q15_t)0x9A40, (q15_t)0xB256, (q15_t)0x9A5F, (q15_t)0xB22E, + (q15_t)0x9A7D, (q15_t)0xB206, (q15_t)0x9A9C, (q15_t)0xB1DE, (q15_t)0x9ABA, + (q15_t)0xB1B7, (q15_t)0x9AD9, (q15_t)0xB18F, (q15_t)0x9AF8, (q15_t)0xB167, + (q15_t)0x9B17, (q15_t)0xB140, (q15_t)0x9B36, (q15_t)0xB118, (q15_t)0x9B55, + (q15_t)0xB0F0, (q15_t)0x9B74, (q15_t)0xB0C9, (q15_t)0x9B93, (q15_t)0xB0A1, + (q15_t)0x9BB2, (q15_t)0xB07A, (q15_t)0x9BD2, (q15_t)0xB053, (q15_t)0x9BF1, + (q15_t)0xB02B, (q15_t)0x9C10, (q15_t)0xB004, (q15_t)0x9C30, (q15_t)0xAFDD, + (q15_t)0x9C4F, (q15_t)0xAFB6, (q15_t)0x9C6F, (q15_t)0xAF8F, (q15_t)0x9C8E, + (q15_t)0xAF68, (q15_t)0x9CAE, (q15_t)0xAF40, (q15_t)0x9CCE, (q15_t)0xAF1A, + (q15_t)0x9CEE, (q15_t)0xAEF3, (q15_t)0x9D0D, (q15_t)0xAECC, (q15_t)0x9D2D, + (q15_t)0xAEA5, (q15_t)0x9D4D, (q15_t)0xAE7E, (q15_t)0x9D6D, (q15_t)0xAE57, + (q15_t)0x9D8E, (q15_t)0xAE31, (q15_t)0x9DAE, (q15_t)0xAE0A, (q15_t)0x9DCE, + (q15_t)0xADE3, (q15_t)0x9DEE, (q15_t)0xADBD, (q15_t)0x9E0E, (q15_t)0xAD96, + (q15_t)0x9E2F, (q15_t)0xAD70, (q15_t)0x9E4F, (q15_t)0xAD4A, (q15_t)0x9E70, + (q15_t)0xAD23, (q15_t)0x9E90, (q15_t)0xACFD, (q15_t)0x9EB1, (q15_t)0xACD7, + (q15_t)0x9ED2, (q15_t)0xACB1, (q15_t)0x9EF2, (q15_t)0xAC8A, (q15_t)0x9F13, + (q15_t)0xAC64, (q15_t)0x9F34, (q15_t)0xAC3E, (q15_t)0x9F55, (q15_t)0xAC18, + (q15_t)0x9F76, (q15_t)0xABF2, (q15_t)0x9F97, (q15_t)0xABCC, (q15_t)0x9FB8, + (q15_t)0xABA7, (q15_t)0x9FD9, (q15_t)0xAB81, (q15_t)0x9FFB, (q15_t)0xAB5B, + (q15_t)0xA01C, (q15_t)0xAB35, (q15_t)0xA03D, (q15_t)0xAB10, (q15_t)0xA05F, + (q15_t)0xAAEA, (q15_t)0xA080, (q15_t)0xAAC5, (q15_t)0xA0A1, (q15_t)0xAA9F, + (q15_t)0xA0C3, (q15_t)0xAA7A, (q15_t)0xA0E5, (q15_t)0xAA54, (q15_t)0xA106, + (q15_t)0xAA2F, (q15_t)0xA128, (q15_t)0xAA0A, (q15_t)0xA14A, (q15_t)0xA9E5, + (q15_t)0xA16C, (q15_t)0xA9BF, (q15_t)0xA18E, (q15_t)0xA99A, (q15_t)0xA1AF, + (q15_t)0xA975, (q15_t)0xA1D2, (q15_t)0xA950, (q15_t)0xA1F4, (q15_t)0xA92B, + (q15_t)0xA216, (q15_t)0xA906, (q15_t)0xA238, (q15_t)0xA8E2, (q15_t)0xA25A, + (q15_t)0xA8BD, (q15_t)0xA27C, (q15_t)0xA898, (q15_t)0xA29F, (q15_t)0xA873, + (q15_t)0xA2C1, (q15_t)0xA84F, (q15_t)0xA2E4, (q15_t)0xA82A, (q15_t)0xA306, + (q15_t)0xA806, (q15_t)0xA329, (q15_t)0xA7E1, (q15_t)0xA34B, (q15_t)0xA7BD, + (q15_t)0xA36E, (q15_t)0xA798, (q15_t)0xA391, (q15_t)0xA774, (q15_t)0xA3B4, + (q15_t)0xA750, (q15_t)0xA3D6, (q15_t)0xA72B, (q15_t)0xA3F9, (q15_t)0xA707, + (q15_t)0xA41C, (q15_t)0xA6E3, (q15_t)0xA43F, (q15_t)0xA6BF, (q15_t)0xA462, + (q15_t)0xA69B, (q15_t)0xA486, (q15_t)0xA677, (q15_t)0xA4A9, (q15_t)0xA653, + (q15_t)0xA4CC, (q15_t)0xA62F, (q15_t)0xA4EF, (q15_t)0xA60C, (q15_t)0xA513, + (q15_t)0xA5E8, (q15_t)0xA536, (q15_t)0xA5C4, (q15_t)0xA55A, (q15_t)0xA5A1, + (q15_t)0xA57D, (q15_t)0xA57D, (q15_t)0xA5A1, (q15_t)0xA55A, (q15_t)0xA5C4, + (q15_t)0xA536, (q15_t)0xA5E8, (q15_t)0xA513, (q15_t)0xA60C, (q15_t)0xA4EF, + (q15_t)0xA62F, (q15_t)0xA4CC, (q15_t)0xA653, (q15_t)0xA4A9, (q15_t)0xA677, + (q15_t)0xA486, (q15_t)0xA69B, (q15_t)0xA462, (q15_t)0xA6BF, (q15_t)0xA43F, + (q15_t)0xA6E3, (q15_t)0xA41C, (q15_t)0xA707, (q15_t)0xA3F9, (q15_t)0xA72B, + (q15_t)0xA3D6, (q15_t)0xA750, (q15_t)0xA3B4, (q15_t)0xA774, (q15_t)0xA391, + (q15_t)0xA798, (q15_t)0xA36E, (q15_t)0xA7BD, (q15_t)0xA34B, (q15_t)0xA7E1, + (q15_t)0xA329, (q15_t)0xA806, (q15_t)0xA306, (q15_t)0xA82A, (q15_t)0xA2E4, + (q15_t)0xA84F, (q15_t)0xA2C1, (q15_t)0xA873, (q15_t)0xA29F, (q15_t)0xA898, + (q15_t)0xA27C, (q15_t)0xA8BD, (q15_t)0xA25A, (q15_t)0xA8E2, (q15_t)0xA238, + (q15_t)0xA906, (q15_t)0xA216, (q15_t)0xA92B, (q15_t)0xA1F4, (q15_t)0xA950, + (q15_t)0xA1D2, (q15_t)0xA975, (q15_t)0xA1AF, (q15_t)0xA99A, (q15_t)0xA18E, + (q15_t)0xA9BF, (q15_t)0xA16C, (q15_t)0xA9E5, (q15_t)0xA14A, (q15_t)0xAA0A, + (q15_t)0xA128, (q15_t)0xAA2F, (q15_t)0xA106, (q15_t)0xAA54, (q15_t)0xA0E5, + (q15_t)0xAA7A, (q15_t)0xA0C3, (q15_t)0xAA9F, (q15_t)0xA0A1, (q15_t)0xAAC5, + (q15_t)0xA080, (q15_t)0xAAEA, (q15_t)0xA05F, (q15_t)0xAB10, (q15_t)0xA03D, + (q15_t)0xAB35, (q15_t)0xA01C, (q15_t)0xAB5B, (q15_t)0x9FFB, (q15_t)0xAB81, + (q15_t)0x9FD9, (q15_t)0xABA7, (q15_t)0x9FB8, (q15_t)0xABCC, (q15_t)0x9F97, + (q15_t)0xABF2, (q15_t)0x9F76, (q15_t)0xAC18, (q15_t)0x9F55, (q15_t)0xAC3E, + (q15_t)0x9F34, (q15_t)0xAC64, (q15_t)0x9F13, (q15_t)0xAC8A, (q15_t)0x9EF2, + (q15_t)0xACB1, (q15_t)0x9ED2, (q15_t)0xACD7, (q15_t)0x9EB1, (q15_t)0xACFD, + (q15_t)0x9E90, (q15_t)0xAD23, (q15_t)0x9E70, (q15_t)0xAD4A, (q15_t)0x9E4F, + (q15_t)0xAD70, (q15_t)0x9E2F, (q15_t)0xAD96, (q15_t)0x9E0E, (q15_t)0xADBD, + (q15_t)0x9DEE, (q15_t)0xADE3, (q15_t)0x9DCE, (q15_t)0xAE0A, (q15_t)0x9DAE, + (q15_t)0xAE31, (q15_t)0x9D8E, (q15_t)0xAE57, (q15_t)0x9D6D, (q15_t)0xAE7E, + (q15_t)0x9D4D, (q15_t)0xAEA5, (q15_t)0x9D2D, (q15_t)0xAECC, (q15_t)0x9D0D, + (q15_t)0xAEF3, (q15_t)0x9CEE, (q15_t)0xAF1A, (q15_t)0x9CCE, (q15_t)0xAF40, + (q15_t)0x9CAE, (q15_t)0xAF68, (q15_t)0x9C8E, (q15_t)0xAF8F, (q15_t)0x9C6F, + (q15_t)0xAFB6, (q15_t)0x9C4F, (q15_t)0xAFDD, (q15_t)0x9C30, (q15_t)0xB004, + (q15_t)0x9C10, (q15_t)0xB02B, (q15_t)0x9BF1, (q15_t)0xB053, (q15_t)0x9BD2, + (q15_t)0xB07A, (q15_t)0x9BB2, (q15_t)0xB0A1, (q15_t)0x9B93, (q15_t)0xB0C9, + (q15_t)0x9B74, (q15_t)0xB0F0, (q15_t)0x9B55, (q15_t)0xB118, (q15_t)0x9B36, + (q15_t)0xB140, (q15_t)0x9B17, (q15_t)0xB167, (q15_t)0x9AF8, (q15_t)0xB18F, + (q15_t)0x9AD9, (q15_t)0xB1B7, (q15_t)0x9ABA, (q15_t)0xB1DE, (q15_t)0x9A9C, + (q15_t)0xB206, (q15_t)0x9A7D, (q15_t)0xB22E, (q15_t)0x9A5F, (q15_t)0xB256, + (q15_t)0x9A40, (q15_t)0xB27E, (q15_t)0x9A22, (q15_t)0xB2A6, (q15_t)0x9A03, + (q15_t)0xB2CE, (q15_t)0x99E5, (q15_t)0xB2F6, (q15_t)0x99C6, (q15_t)0xB31E, + (q15_t)0x99A8, (q15_t)0xB347, (q15_t)0x998A, (q15_t)0xB36F, (q15_t)0x996C, + (q15_t)0xB397, (q15_t)0x994E, (q15_t)0xB3C0, (q15_t)0x9930, (q15_t)0xB3E8, + (q15_t)0x9912, (q15_t)0xB410, (q15_t)0x98F4, (q15_t)0xB439, (q15_t)0x98D6, + (q15_t)0xB461, (q15_t)0x98B9, (q15_t)0xB48A, (q15_t)0x989B, (q15_t)0xB4B3, + (q15_t)0x987D, (q15_t)0xB4DB, (q15_t)0x9860, (q15_t)0xB504, (q15_t)0x9842, + (q15_t)0xB52D, (q15_t)0x9825, (q15_t)0xB556, (q15_t)0x9808, (q15_t)0xB57E, + (q15_t)0x97EA, (q15_t)0xB5A7, (q15_t)0x97CD, (q15_t)0xB5D0, (q15_t)0x97B0, + (q15_t)0xB5F9, (q15_t)0x9793, (q15_t)0xB622, (q15_t)0x9776, (q15_t)0xB64B, + (q15_t)0x9759, (q15_t)0xB675, (q15_t)0x973C, (q15_t)0xB69E, (q15_t)0x971F, + (q15_t)0xB6C7, (q15_t)0x9702, (q15_t)0xB6F0, (q15_t)0x96E6, (q15_t)0xB719, + (q15_t)0x96C9, (q15_t)0xB743, (q15_t)0x96AC, (q15_t)0xB76C, (q15_t)0x9690, + (q15_t)0xB796, (q15_t)0x9673, (q15_t)0xB7BF, (q15_t)0x9657, (q15_t)0xB7E9, + (q15_t)0x963B, (q15_t)0xB812, (q15_t)0x961E, (q15_t)0xB83C, (q15_t)0x9602, + (q15_t)0xB865, (q15_t)0x95E6, (q15_t)0xB88F, (q15_t)0x95CA, (q15_t)0xB8B9, + (q15_t)0x95AE, (q15_t)0xB8E3, (q15_t)0x9592, (q15_t)0xB90C, (q15_t)0x9576, + (q15_t)0xB936, (q15_t)0x955A, (q15_t)0xB960, (q15_t)0x953E, (q15_t)0xB98A, + (q15_t)0x9523, (q15_t)0xB9B4, (q15_t)0x9507, (q15_t)0xB9DE, (q15_t)0x94EC, + (q15_t)0xBA08, (q15_t)0x94D0, (q15_t)0xBA32, (q15_t)0x94B5, (q15_t)0xBA5C, + (q15_t)0x9499, (q15_t)0xBA87, (q15_t)0x947E, (q15_t)0xBAB1, (q15_t)0x9463, + (q15_t)0xBADB, (q15_t)0x9447, (q15_t)0xBB05, (q15_t)0x942C, (q15_t)0xBB30, + (q15_t)0x9411, (q15_t)0xBB5A, (q15_t)0x93F6, (q15_t)0xBB85, (q15_t)0x93DB, + (q15_t)0xBBAF, (q15_t)0x93C0, (q15_t)0xBBDA, (q15_t)0x93A6, (q15_t)0xBC04, + (q15_t)0x938B, (q15_t)0xBC2F, (q15_t)0x9370, (q15_t)0xBC5A, (q15_t)0x9356, + (q15_t)0xBC84, (q15_t)0x933B, (q15_t)0xBCAF, (q15_t)0x9321, (q15_t)0xBCDA, + (q15_t)0x9306, (q15_t)0xBD05, (q15_t)0x92EC, (q15_t)0xBD2F, (q15_t)0x92D2, + (q15_t)0xBD5A, (q15_t)0x92B7, (q15_t)0xBD85, (q15_t)0x929D, (q15_t)0xBDB0, + (q15_t)0x9283, (q15_t)0xBDDB, (q15_t)0x9269, (q15_t)0xBE06, (q15_t)0x924F, + (q15_t)0xBE31, (q15_t)0x9235, (q15_t)0xBE5D, (q15_t)0x921C, (q15_t)0xBE88, + (q15_t)0x9202, (q15_t)0xBEB3, (q15_t)0x91E8, (q15_t)0xBEDE, (q15_t)0x91CF, + (q15_t)0xBF09, (q15_t)0x91B5, (q15_t)0xBF35, (q15_t)0x919C, (q15_t)0xBF60, + (q15_t)0x9182, (q15_t)0xBF8C, (q15_t)0x9169, (q15_t)0xBFB7, (q15_t)0x9150, + (q15_t)0xBFE2, (q15_t)0x9136, (q15_t)0xC00E, (q15_t)0x911D, (q15_t)0xC03A, + (q15_t)0x9104, (q15_t)0xC065, (q15_t)0x90EB, (q15_t)0xC091, (q15_t)0x90D2, + (q15_t)0xC0BC, (q15_t)0x90B9, (q15_t)0xC0E8, (q15_t)0x90A0, (q15_t)0xC114, + (q15_t)0x9088, (q15_t)0xC140, (q15_t)0x906F, (q15_t)0xC16C, (q15_t)0x9056, + (q15_t)0xC197, (q15_t)0x903E, (q15_t)0xC1C3, (q15_t)0x9025, (q15_t)0xC1EF, + (q15_t)0x900D, (q15_t)0xC21B, (q15_t)0x8FF5, (q15_t)0xC247, (q15_t)0x8FDC, + (q15_t)0xC273, (q15_t)0x8FC4, (q15_t)0xC29F, (q15_t)0x8FAC, (q15_t)0xC2CC, + (q15_t)0x8F94, (q15_t)0xC2F8, (q15_t)0x8F7C, (q15_t)0xC324, (q15_t)0x8F64, + (q15_t)0xC350, (q15_t)0x8F4C, (q15_t)0xC37C, (q15_t)0x8F34, (q15_t)0xC3A9, + (q15_t)0x8F1D, (q15_t)0xC3D5, (q15_t)0x8F05, (q15_t)0xC402, (q15_t)0x8EED, + (q15_t)0xC42E, (q15_t)0x8ED6, (q15_t)0xC45A, (q15_t)0x8EBE, (q15_t)0xC487, + (q15_t)0x8EA7, (q15_t)0xC4B3, (q15_t)0x8E90, (q15_t)0xC4E0, (q15_t)0x8E79, + (q15_t)0xC50D, (q15_t)0x8E61, (q15_t)0xC539, (q15_t)0x8E4A, (q15_t)0xC566, + (q15_t)0x8E33, (q15_t)0xC593, (q15_t)0x8E1C, (q15_t)0xC5BF, (q15_t)0x8E05, + (q15_t)0xC5EC, (q15_t)0x8DEE, (q15_t)0xC619, (q15_t)0x8DD8, (q15_t)0xC646, + (q15_t)0x8DC1, (q15_t)0xC673, (q15_t)0x8DAA, (q15_t)0xC6A0, (q15_t)0x8D94, + (q15_t)0xC6CD, (q15_t)0x8D7D, (q15_t)0xC6F9, (q15_t)0x8D67, (q15_t)0xC727, + (q15_t)0x8D50, (q15_t)0xC754, (q15_t)0x8D3A, (q15_t)0xC781, (q15_t)0x8D24, + (q15_t)0xC7AE, (q15_t)0x8D0E, (q15_t)0xC7DB, (q15_t)0x8CF8, (q15_t)0xC808, + (q15_t)0x8CE2, (q15_t)0xC835, (q15_t)0x8CCC, (q15_t)0xC863, (q15_t)0x8CB6, + (q15_t)0xC890, (q15_t)0x8CA0, (q15_t)0xC8BD, (q15_t)0x8C8A, (q15_t)0xC8EB, + (q15_t)0x8C75, (q15_t)0xC918, (q15_t)0x8C5F, (q15_t)0xC945, (q15_t)0x8C4A, + (q15_t)0xC973, (q15_t)0x8C34, (q15_t)0xC9A0, (q15_t)0x8C1F, (q15_t)0xC9CE, + (q15_t)0x8C09, (q15_t)0xC9FB, (q15_t)0x8BF4, (q15_t)0xCA29, (q15_t)0x8BDF, + (q15_t)0xCA57, (q15_t)0x8BCA, (q15_t)0xCA84, (q15_t)0x8BB5, (q15_t)0xCAB2, + (q15_t)0x8BA0, (q15_t)0xCAE0, (q15_t)0x8B8B, (q15_t)0xCB0D, (q15_t)0x8B76, + (q15_t)0xCB3B, (q15_t)0x8B61, (q15_t)0xCB69, (q15_t)0x8B4D, (q15_t)0xCB97, + (q15_t)0x8B38, (q15_t)0xCBC5, (q15_t)0x8B24, (q15_t)0xCBF3, (q15_t)0x8B0F, + (q15_t)0xCC21, (q15_t)0x8AFB, (q15_t)0xCC4F, (q15_t)0x8AE6, (q15_t)0xCC7D, + (q15_t)0x8AD2, (q15_t)0xCCAB, (q15_t)0x8ABE, (q15_t)0xCCD9, (q15_t)0x8AAA, + (q15_t)0xCD07, (q15_t)0x8A96, (q15_t)0xCD35, (q15_t)0x8A82, (q15_t)0xCD63, + (q15_t)0x8A6E, (q15_t)0xCD91, (q15_t)0x8A5A, (q15_t)0xCDBF, (q15_t)0x8A46, + (q15_t)0xCDEE, (q15_t)0x8A33, (q15_t)0xCE1C, (q15_t)0x8A1F, (q15_t)0xCE4A, + (q15_t)0x8A0B, (q15_t)0xCE79, (q15_t)0x89F8, (q15_t)0xCEA7, (q15_t)0x89E4, + (q15_t)0xCED5, (q15_t)0x89D1, (q15_t)0xCF04, (q15_t)0x89BE, (q15_t)0xCF32, + (q15_t)0x89AB, (q15_t)0xCF61, (q15_t)0x8997, (q15_t)0xCF8F, (q15_t)0x8984, + (q15_t)0xCFBE, (q15_t)0x8971, (q15_t)0xCFEC, (q15_t)0x895F, (q15_t)0xD01B, + (q15_t)0x894C, (q15_t)0xD04A, (q15_t)0x8939, (q15_t)0xD078, (q15_t)0x8926, + (q15_t)0xD0A7, (q15_t)0x8914, (q15_t)0xD0D6, (q15_t)0x8901, (q15_t)0xD104, + (q15_t)0x88EF, (q15_t)0xD133, (q15_t)0x88DC, (q15_t)0xD162, (q15_t)0x88CA, + (q15_t)0xD191, (q15_t)0x88B8, (q15_t)0xD1C0, (q15_t)0x88A5, (q15_t)0xD1EE, + (q15_t)0x8893, (q15_t)0xD21D, (q15_t)0x8881, (q15_t)0xD24C, (q15_t)0x886F, + (q15_t)0xD27B, (q15_t)0x885D, (q15_t)0xD2AA, (q15_t)0x884B, (q15_t)0xD2D9, + (q15_t)0x883A, (q15_t)0xD308, (q15_t)0x8828, (q15_t)0xD337, (q15_t)0x8816, + (q15_t)0xD367, (q15_t)0x8805, (q15_t)0xD396, (q15_t)0x87F3, (q15_t)0xD3C5, + (q15_t)0x87E2, (q15_t)0xD3F4, (q15_t)0x87D1, (q15_t)0xD423, (q15_t)0x87BF, + (q15_t)0xD452, (q15_t)0x87AE, (q15_t)0xD482, (q15_t)0x879D, (q15_t)0xD4B1, + (q15_t)0x878C, (q15_t)0xD4E0, (q15_t)0x877B, (q15_t)0xD510, (q15_t)0x876A, + (q15_t)0xD53F, (q15_t)0x8759, (q15_t)0xD56E, (q15_t)0x8749, (q15_t)0xD59E, + (q15_t)0x8738, (q15_t)0xD5CD, (q15_t)0x8727, (q15_t)0xD5FD, (q15_t)0x8717, + (q15_t)0xD62C, (q15_t)0x8706, (q15_t)0xD65C, (q15_t)0x86F6, (q15_t)0xD68B, + (q15_t)0x86E6, (q15_t)0xD6BB, (q15_t)0x86D5, (q15_t)0xD6EA, (q15_t)0x86C5, + (q15_t)0xD71A, (q15_t)0x86B5, (q15_t)0xD74A, (q15_t)0x86A5, (q15_t)0xD779, + (q15_t)0x8695, (q15_t)0xD7A9, (q15_t)0x8685, (q15_t)0xD7D9, (q15_t)0x8675, + (q15_t)0xD809, (q15_t)0x8666, (q15_t)0xD838, (q15_t)0x8656, (q15_t)0xD868, + (q15_t)0x8646, (q15_t)0xD898, (q15_t)0x8637, (q15_t)0xD8C8, (q15_t)0x8627, + (q15_t)0xD8F8, (q15_t)0x8618, (q15_t)0xD927, (q15_t)0x8609, (q15_t)0xD957, + (q15_t)0x85FA, (q15_t)0xD987, (q15_t)0x85EA, (q15_t)0xD9B7, (q15_t)0x85DB, + (q15_t)0xD9E7, (q15_t)0x85CC, (q15_t)0xDA17, (q15_t)0x85BD, (q15_t)0xDA47, + (q15_t)0x85AF, (q15_t)0xDA77, (q15_t)0x85A0, (q15_t)0xDAA7, (q15_t)0x8591, + (q15_t)0xDAD7, (q15_t)0x8582, (q15_t)0xDB08, (q15_t)0x8574, (q15_t)0xDB38, + (q15_t)0x8565, (q15_t)0xDB68, (q15_t)0x8557, (q15_t)0xDB98, (q15_t)0x8549, + (q15_t)0xDBC8, (q15_t)0x853A, (q15_t)0xDBF8, (q15_t)0x852C, (q15_t)0xDC29, + (q15_t)0x851E, (q15_t)0xDC59, (q15_t)0x8510, (q15_t)0xDC89, (q15_t)0x8502, + (q15_t)0xDCBA, (q15_t)0x84F4, (q15_t)0xDCEA, (q15_t)0x84E6, (q15_t)0xDD1A, + (q15_t)0x84D9, (q15_t)0xDD4B, (q15_t)0x84CB, (q15_t)0xDD7B, (q15_t)0x84BD, + (q15_t)0xDDAB, (q15_t)0x84B0, (q15_t)0xDDDC, (q15_t)0x84A2, (q15_t)0xDE0C, + (q15_t)0x8495, (q15_t)0xDE3D, (q15_t)0x8488, (q15_t)0xDE6D, (q15_t)0x847B, + (q15_t)0xDE9E, (q15_t)0x846D, (q15_t)0xDECE, (q15_t)0x8460, (q15_t)0xDEFF, + (q15_t)0x8453, (q15_t)0xDF2F, (q15_t)0x8446, (q15_t)0xDF60, (q15_t)0x843A, + (q15_t)0xDF91, (q15_t)0x842D, (q15_t)0xDFC1, (q15_t)0x8420, (q15_t)0xDFF2, + (q15_t)0x8414, (q15_t)0xE023, (q15_t)0x8407, (q15_t)0xE053, (q15_t)0x83FA, + (q15_t)0xE084, (q15_t)0x83EE, (q15_t)0xE0B5, (q15_t)0x83E2, (q15_t)0xE0E6, + (q15_t)0x83D6, (q15_t)0xE116, (q15_t)0x83C9, (q15_t)0xE147, (q15_t)0x83BD, + (q15_t)0xE178, (q15_t)0x83B1, (q15_t)0xE1A9, (q15_t)0x83A5, (q15_t)0xE1DA, + (q15_t)0x8399, (q15_t)0xE20A, (q15_t)0x838E, (q15_t)0xE23B, (q15_t)0x8382, + (q15_t)0xE26C, (q15_t)0x8376, (q15_t)0xE29D, (q15_t)0x836B, (q15_t)0xE2CE, + (q15_t)0x835F, (q15_t)0xE2FF, (q15_t)0x8354, (q15_t)0xE330, (q15_t)0x8348, + (q15_t)0xE361, (q15_t)0x833D, (q15_t)0xE392, (q15_t)0x8332, (q15_t)0xE3C3, + (q15_t)0x8327, (q15_t)0xE3F4, (q15_t)0x831C, (q15_t)0xE425, (q15_t)0x8311, + (q15_t)0xE456, (q15_t)0x8306, (q15_t)0xE487, (q15_t)0x82FB, (q15_t)0xE4B8, + (q15_t)0x82F0, (q15_t)0xE4E9, (q15_t)0x82E6, (q15_t)0xE51B, (q15_t)0x82DB, + (q15_t)0xE54C, (q15_t)0x82D0, (q15_t)0xE57D, (q15_t)0x82C6, (q15_t)0xE5AE, + (q15_t)0x82BC, (q15_t)0xE5DF, (q15_t)0x82B1, (q15_t)0xE610, (q15_t)0x82A7, + (q15_t)0xE642, (q15_t)0x829D, (q15_t)0xE673, (q15_t)0x8293, (q15_t)0xE6A4, + (q15_t)0x8289, (q15_t)0xE6D5, (q15_t)0x827F, (q15_t)0xE707, (q15_t)0x8275, + (q15_t)0xE738, (q15_t)0x826B, (q15_t)0xE769, (q15_t)0x8262, (q15_t)0xE79B, + (q15_t)0x8258, (q15_t)0xE7CC, (q15_t)0x824F, (q15_t)0xE7FD, (q15_t)0x8245, + (q15_t)0xE82F, (q15_t)0x823C, (q15_t)0xE860, (q15_t)0x8232, (q15_t)0xE892, + (q15_t)0x8229, (q15_t)0xE8C3, (q15_t)0x8220, (q15_t)0xE8F5, (q15_t)0x8217, + (q15_t)0xE926, (q15_t)0x820E, (q15_t)0xE957, (q15_t)0x8205, (q15_t)0xE989, + (q15_t)0x81FC, (q15_t)0xE9BA, (q15_t)0x81F3, (q15_t)0xE9EC, (q15_t)0x81EB, + (q15_t)0xEA1D, (q15_t)0x81E2, (q15_t)0xEA4F, (q15_t)0x81D9, (q15_t)0xEA80, + (q15_t)0x81D1, (q15_t)0xEAB2, (q15_t)0x81C8, (q15_t)0xEAE4, (q15_t)0x81C0, + (q15_t)0xEB15, (q15_t)0x81B8, (q15_t)0xEB47, (q15_t)0x81B0, (q15_t)0xEB78, + (q15_t)0x81A8, (q15_t)0xEBAA, (q15_t)0x81A0, (q15_t)0xEBDC, (q15_t)0x8198, + (q15_t)0xEC0D, (q15_t)0x8190, (q15_t)0xEC3F, (q15_t)0x8188, (q15_t)0xEC71, + (q15_t)0x8180, (q15_t)0xECA2, (q15_t)0x8179, (q15_t)0xECD4, (q15_t)0x8171, + (q15_t)0xED06, (q15_t)0x816A, (q15_t)0xED37, (q15_t)0x8162, (q15_t)0xED69, + (q15_t)0x815B, (q15_t)0xED9B, (q15_t)0x8154, (q15_t)0xEDCD, (q15_t)0x814C, + (q15_t)0xEDFE, (q15_t)0x8145, (q15_t)0xEE30, (q15_t)0x813E, (q15_t)0xEE62, + (q15_t)0x8137, (q15_t)0xEE94, (q15_t)0x8130, (q15_t)0xEEC6, (q15_t)0x812A, + (q15_t)0xEEF7, (q15_t)0x8123, (q15_t)0xEF29, (q15_t)0x811C, (q15_t)0xEF5B, + (q15_t)0x8116, (q15_t)0xEF8D, (q15_t)0x810F, (q15_t)0xEFBF, (q15_t)0x8109, + (q15_t)0xEFF1, (q15_t)0x8102, (q15_t)0xF022, (q15_t)0x80FC, (q15_t)0xF054, + (q15_t)0x80F6, (q15_t)0xF086, (q15_t)0x80F0, (q15_t)0xF0B8, (q15_t)0x80EA, + (q15_t)0xF0EA, (q15_t)0x80E4, (q15_t)0xF11C, (q15_t)0x80DE, (q15_t)0xF14E, + (q15_t)0x80D8, (q15_t)0xF180, (q15_t)0x80D2, (q15_t)0xF1B2, (q15_t)0x80CD, + (q15_t)0xF1E4, (q15_t)0x80C7, (q15_t)0xF216, (q15_t)0x80C2, (q15_t)0xF248, + (q15_t)0x80BC, (q15_t)0xF27A, (q15_t)0x80B7, (q15_t)0xF2AC, (q15_t)0x80B2, + (q15_t)0xF2DE, (q15_t)0x80AC, (q15_t)0xF310, (q15_t)0x80A7, (q15_t)0xF342, + (q15_t)0x80A2, (q15_t)0xF374, (q15_t)0x809D, (q15_t)0xF3A6, (q15_t)0x8098, + (q15_t)0xF3D8, (q15_t)0x8094, (q15_t)0xF40A, (q15_t)0x808F, (q15_t)0xF43C, + (q15_t)0x808A, (q15_t)0xF46E, (q15_t)0x8086, (q15_t)0xF4A0, (q15_t)0x8081, + (q15_t)0xF4D2, (q15_t)0x807D, (q15_t)0xF504, (q15_t)0x8078, (q15_t)0xF536, + (q15_t)0x8074, (q15_t)0xF568, (q15_t)0x8070, (q15_t)0xF59A, (q15_t)0x806C, + (q15_t)0xF5CC, (q15_t)0x8068, (q15_t)0xF5FF, (q15_t)0x8064, (q15_t)0xF631, + (q15_t)0x8060, (q15_t)0xF663, (q15_t)0x805C, (q15_t)0xF695, (q15_t)0x8058, + (q15_t)0xF6C7, (q15_t)0x8055, (q15_t)0xF6F9, (q15_t)0x8051, (q15_t)0xF72B, + (q15_t)0x804E, (q15_t)0xF75D, (q15_t)0x804A, (q15_t)0xF790, (q15_t)0x8047, + (q15_t)0xF7C2, (q15_t)0x8043, (q15_t)0xF7F4, (q15_t)0x8040, (q15_t)0xF826, + (q15_t)0x803D, (q15_t)0xF858, (q15_t)0x803A, (q15_t)0xF88A, (q15_t)0x8037, + (q15_t)0xF8BD, (q15_t)0x8034, (q15_t)0xF8EF, (q15_t)0x8031, (q15_t)0xF921, + (q15_t)0x802F, (q15_t)0xF953, (q15_t)0x802C, (q15_t)0xF985, (q15_t)0x8029, + (q15_t)0xF9B8, (q15_t)0x8027, (q15_t)0xF9EA, (q15_t)0x8025, (q15_t)0xFA1C, + (q15_t)0x8022, (q15_t)0xFA4E, (q15_t)0x8020, (q15_t)0xFA80, (q15_t)0x801E, + (q15_t)0xFAB3, (q15_t)0x801C, (q15_t)0xFAE5, (q15_t)0x801A, (q15_t)0xFB17, + (q15_t)0x8018, (q15_t)0xFB49, (q15_t)0x8016, (q15_t)0xFB7C, (q15_t)0x8014, + (q15_t)0xFBAE, (q15_t)0x8012, (q15_t)0xFBE0, (q15_t)0x8011, (q15_t)0xFC12, + (q15_t)0x800F, (q15_t)0xFC45, (q15_t)0x800D, (q15_t)0xFC77, (q15_t)0x800C, + (q15_t)0xFCA9, (q15_t)0x800B, (q15_t)0xFCDB, (q15_t)0x8009, (q15_t)0xFD0E, + (q15_t)0x8008, (q15_t)0xFD40, (q15_t)0x8007, (q15_t)0xFD72, (q15_t)0x8006, + (q15_t)0xFDA4, (q15_t)0x8005, (q15_t)0xFDD7, (q15_t)0x8004, (q15_t)0xFE09, + (q15_t)0x8003, (q15_t)0xFE3B, (q15_t)0x8003, (q15_t)0xFE6D, (q15_t)0x8002, + (q15_t)0xFEA0, (q15_t)0x8001, (q15_t)0xFED2, (q15_t)0x8001, (q15_t)0xFF04, + (q15_t)0x8000, (q15_t)0xFF36, (q15_t)0x8000, (q15_t)0xFF69, (q15_t)0x8000, + (q15_t)0xFF9B, (q15_t)0x8000, (q15_t)0xFFCD, (q15_t)0x8000}; /** @} end of CFFT_CIFFT group @@ -16074,1673 +9468,1896 @@ const q15_t twiddleCoef_4096_q15[6144] = @brief Q15 table for reciprocal */ const q15_t __ALIGNED(4) armRecipTableQ15[64] = { - 0x7F03, 0x7D13, 0x7B31, 0x795E, 0x7798, 0x75E0, - 0x7434, 0x7294, 0x70FF, 0x6F76, 0x6DF6, 0x6C82, - 0x6B16, 0x69B5, 0x685C, 0x670C, 0x65C4, 0x6484, - 0x634C, 0x621C, 0x60F3, 0x5FD0, 0x5EB5, 0x5DA0, - 0x5C91, 0x5B88, 0x5A85, 0x5988, 0x5890, 0x579E, - 0x56B0, 0x55C8, 0x54E4, 0x5405, 0x532B, 0x5255, - 0x5183, 0x50B6, 0x4FEC, 0x4F26, 0x4E64, 0x4DA6, - 0x4CEC, 0x4C34, 0x4B81, 0x4AD0, 0x4A23, 0x4978, - 0x48D1, 0x482D, 0x478C, 0x46ED, 0x4651, 0x45B8, - 0x4521, 0x448D, 0x43FC, 0x436C, 0x42DF, 0x4255, - 0x41CC, 0x4146, 0x40C2, 0x4040 -}; + 0x7F03, 0x7D13, 0x7B31, 0x795E, 0x7798, 0x75E0, 0x7434, 0x7294, + 0x70FF, 0x6F76, 0x6DF6, 0x6C82, 0x6B16, 0x69B5, 0x685C, 0x670C, + 0x65C4, 0x6484, 0x634C, 0x621C, 0x60F3, 0x5FD0, 0x5EB5, 0x5DA0, + 0x5C91, 0x5B88, 0x5A85, 0x5988, 0x5890, 0x579E, 0x56B0, 0x55C8, + 0x54E4, 0x5405, 0x532B, 0x5255, 0x5183, 0x50B6, 0x4FEC, 0x4F26, + 0x4E64, 0x4DA6, 0x4CEC, 0x4C34, 0x4B81, 0x4AD0, 0x4A23, 0x4978, + 0x48D1, 0x482D, 0x478C, 0x46ED, 0x4651, 0x45B8, 0x4521, 0x448D, + 0x43FC, 0x436C, 0x42DF, 0x4255, 0x41CC, 0x4146, 0x40C2, 0x4040}; /** @brief Q31 table for reciprocal */ const q31_t armRecipTableQ31[64] = { - 0x7F03F03F, 0x7D137420, 0x7B31E739, 0x795E9F94, 0x7798FD29, 0x75E06928, - 0x7434554D, 0x72943B4B, 0x70FF9C40, 0x6F760031, 0x6DF6F593, 0x6C8210E3, - 0x6B16EC3A, 0x69B526F6, 0x685C655F, 0x670C505D, 0x65C4952D, 0x6484E519, - 0x634CF53E, 0x621C7E4F, 0x60F33C61, 0x5FD0EEB3, 0x5EB55785, 0x5DA03BEB, - 0x5C9163A1, 0x5B8898E6, 0x5A85A85A, 0x598860DF, 0x58909373, 0x579E1318, - 0x56B0B4B8, 0x55C84F0B, 0x54E4BA80, 0x5405D124, 0x532B6E8F, 0x52556FD0, - 0x5183B35A, 0x50B618F3, 0x4FEC81A2, 0x4F26CFA2, 0x4E64E64E, 0x4DA6AA1D, - 0x4CEC008B, 0x4C34D010, 0x4B810016, 0x4AD078EF, 0x4A2323C4, 0x4978EA96, - 0x48D1B827, 0x482D77FE, 0x478C1657, 0x46ED801D, 0x4651A2E5, 0x45B86CE2, - 0x4521CCE1, 0x448DB244, 0x43FC0CFA, 0x436CCD78, 0x42DFE4B4, 0x42554426, - 0x41CCDDB6, 0x4146A3C6, 0x40C28923, 0x40408102 -}; + 0x7F03F03F, 0x7D137420, 0x7B31E739, 0x795E9F94, 0x7798FD29, 0x75E06928, + 0x7434554D, 0x72943B4B, 0x70FF9C40, 0x6F760031, 0x6DF6F593, 0x6C8210E3, + 0x6B16EC3A, 0x69B526F6, 0x685C655F, 0x670C505D, 0x65C4952D, 0x6484E519, + 0x634CF53E, 0x621C7E4F, 0x60F33C61, 0x5FD0EEB3, 0x5EB55785, 0x5DA03BEB, + 0x5C9163A1, 0x5B8898E6, 0x5A85A85A, 0x598860DF, 0x58909373, 0x579E1318, + 0x56B0B4B8, 0x55C84F0B, 0x54E4BA80, 0x5405D124, 0x532B6E8F, 0x52556FD0, + 0x5183B35A, 0x50B618F3, 0x4FEC81A2, 0x4F26CFA2, 0x4E64E64E, 0x4DA6AA1D, + 0x4CEC008B, 0x4C34D010, 0x4B810016, 0x4AD078EF, 0x4A2323C4, 0x4978EA96, + 0x48D1B827, 0x482D77FE, 0x478C1657, 0x46ED801D, 0x4651A2E5, 0x45B86CE2, + 0x4521CCE1, 0x448DB244, 0x43FC0CFA, 0x436CCD78, 0x42DFE4B4, 0x42554426, + 0x41CCDDB6, 0x4146A3C6, 0x40C28923, 0x40408102}; -const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE_16_TABLE_LENGTH] = -{ - /* 8x2, size 20 */ - 8,64, 24,72, 16,64, 40,80, 32,64, 56,88, 48,72, 88,104, 72,96, 104,112 -}; +const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE_16_TABLE_LENGTH] = { + /* 8x2, size 20 */ + 8, 64, 24, 72, 16, 64, 40, 80, 32, 64, + 56, 88, 48, 72, 88, 104, 72, 96, 104, 112}; -const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE_32_TABLE_LENGTH] = -{ - /* 8x4, size 48 */ - 8,64, 16,128, 24,192, 32,64, 40,72, 48,136, 56,200, 64,128, 72,80, 88,208, - 80,144, 96,192, 104,208, 112,152, 120,216, 136,192, 144,160, 168,208, - 152,224, 176,208, 184,232, 216,240, 200,224, 232,240 -}; +const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE_32_TABLE_LENGTH] = { + /* 8x4, size 48 */ + 8, 64, 16, 128, 24, 192, 32, 64, 40, 72, 48, 136, + 56, 200, 64, 128, 72, 80, 88, 208, 80, 144, 96, 192, + 104, 208, 112, 152, 120, 216, 136, 192, 144, 160, 168, 208, + 152, 224, 176, 208, 184, 232, 216, 240, 200, 224, 232, 240}; -const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE_64_TABLE_LENGTH] = -{ - /* radix 8, size 56 */ - 8,64, 16,128, 24,192, 32,256, 40,320, 48,384, 56,448, 80,136, 88,200, - 96,264, 104,328, 112,392, 120,456, 152,208, 160,272, 168,336, 176,400, - 184,464, 224,280, 232,344, 240,408, 248,472, 296,352, 304,416, 312,480, - 368,424, 376,488, 440,496 -}; +const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE_64_TABLE_LENGTH] = { + /* radix 8, size 56 */ + 8, 64, 16, 128, 24, 192, 32, 256, 40, 320, 48, 384, 56, 448, + 80, 136, 88, 200, 96, 264, 104, 328, 112, 392, 120, 456, 152, 208, + 160, 272, 168, 336, 176, 400, 184, 464, 224, 280, 232, 344, 240, 408, + 248, 472, 296, 352, 304, 416, 312, 480, 368, 424, 376, 488, 440, 496}; -const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH] = -{ - /* 8x2, size 208 */ - 8,512, 16,64, 24,576, 32,128, 40,640, 48,192, 56,704, 64,256, 72,768, - 80,320, 88,832, 96,384, 104,896, 112,448, 120,960, 128,512, 136,520, - 144,768, 152,584, 160,520, 168,648, 176,200, 184,712, 192,264, 200,776, - 208,328, 216,840, 224,392, 232,904, 240,456, 248,968, 264,528, 272,320, - 280,592, 288,768, 296,656, 304,328, 312,720, 328,784, 344,848, 352,400, - 360,912, 368,464, 376,976, 384,576, 392,536, 400,832, 408,600, 416,584, - 424,664, 432,840, 440,728, 448,592, 456,792, 464,848, 472,856, 480,600, - 488,920, 496,856, 504,984, 520,544, 528,576, 536,608, 552,672, 560,608, - 568,736, 576,768, 584,800, 592,832, 600,864, 608,800, 616,928, 624,864, - 632,992, 648,672, 656,896, 664,928, 688,904, 696,744, 704,896, 712,808, - 720,912, 728,872, 736,928, 744,936, 752,920, 760,1000, 776,800, 784,832, - 792,864, 808,904, 816,864, 824,920, 840,864, 856,880, 872,944, 888,1008, - 904,928, 912,960, 920,992, 944,968, 952,1000, 968,992, 984,1008 -}; +const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH] = { + /* 8x2, size 208 */ + 8, 512, 16, 64, 24, 576, 32, 128, 40, 640, 48, 192, 56, 704, 64, + 256, 72, 768, 80, 320, 88, 832, 96, 384, 104, 896, 112, 448, 120, 960, + 128, 512, 136, 520, 144, 768, 152, 584, 160, 520, 168, 648, 176, 200, 184, + 712, 192, 264, 200, 776, 208, 328, 216, 840, 224, 392, 232, 904, 240, 456, + 248, 968, 264, 528, 272, 320, 280, 592, 288, 768, 296, 656, 304, 328, 312, + 720, 328, 784, 344, 848, 352, 400, 360, 912, 368, 464, 376, 976, 384, 576, + 392, 536, 400, 832, 408, 600, 416, 584, 424, 664, 432, 840, 440, 728, 448, + 592, 456, 792, 464, 848, 472, 856, 480, 600, 488, 920, 496, 856, 504, 984, + 520, 544, 528, 576, 536, 608, 552, 672, 560, 608, 568, 736, 576, 768, 584, + 800, 592, 832, 600, 864, 608, 800, 616, 928, 624, 864, 632, 992, 648, 672, + 656, 896, 664, 928, 688, 904, 696, 744, 704, 896, 712, 808, 720, 912, 728, + 872, 736, 928, 744, 936, 752, 920, 760, 1000, 776, 800, 784, 832, 792, 864, + 808, 904, 816, 864, 824, 920, 840, 864, 856, 880, 872, 944, 888, 1008, 904, + 928, 912, 960, 920, 992, 944, 968, 952, 1000, 968, 992, 984, 1008}; -const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH] = -{ - /* 8x4, size 440 */ - 8,512, 16,1024, 24,1536, 32,64, 40,576, 48,1088, 56,1600, 64,128, 72,640, - 80,1152, 88,1664, 96,192, 104,704, 112,1216, 120,1728, 128,256, 136,768, - 144,1280, 152,1792, 160,320, 168,832, 176,1344, 184,1856, 192,384, - 200,896, 208,1408, 216,1920, 224,448, 232,960, 240,1472, 248,1984, - 256,512, 264,520, 272,1032, 280,1544, 288,640, 296,584, 304,1096, 312,1608, - 320,768, 328,648, 336,1160, 344,1672, 352,896, 360,712, 368,1224, 376,1736, - 384,520, 392,776, 400,1288, 408,1800, 416,648, 424,840, 432,1352, 440,1864, - 448,776, 456,904, 464,1416, 472,1928, 480,904, 488,968, 496,1480, 504,1992, - 520,528, 512,1024, 528,1040, 536,1552, 544,1152, 552,592, 560,1104, - 568,1616, 576,1280, 584,656, 592,1168, 600,1680, 608,1408, 616,720, - 624,1232, 632,1744, 640,1032, 648,784, 656,1296, 664,1808, 672,1160, - 680,848, 688,1360, 696,1872, 704,1288, 712,912, 720,1424, 728,1936, - 736,1416, 744,976, 752,1488, 760,2000, 768,1536, 776,1552, 784,1048, - 792,1560, 800,1664, 808,1680, 816,1112, 824,1624, 832,1792, 840,1808, - 848,1176, 856,1688, 864,1920, 872,1936, 880,1240, 888,1752, 896,1544, - 904,1560, 912,1304, 920,1816, 928,1672, 936,1688, 944,1368, 952,1880, - 960,1800, 968,1816, 976,1432, 984,1944, 992,1928, 1000,1944, 1008,1496, - 1016,2008, 1032,1152, 1040,1056, 1048,1568, 1064,1408, 1072,1120, - 1080,1632, 1088,1536, 1096,1160, 1104,1184, 1112,1696, 1120,1552, - 1128,1416, 1136,1248, 1144,1760, 1160,1664, 1168,1312, 1176,1824, - 1184,1544, 1192,1920, 1200,1376, 1208,1888, 1216,1568, 1224,1672, - 1232,1440, 1240,1952, 1248,1560, 1256,1928, 1264,1504, 1272,2016, - 1288,1312, 1296,1408, 1304,1576, 1320,1424, 1328,1416, 1336,1640, - 1344,1792, 1352,1824, 1360,1920, 1368,1704, 1376,1800, 1384,1432, - 1392,1928, 1400,1768, 1416,1680, 1432,1832, 1440,1576, 1448,1936, - 1456,1832, 1464,1896, 1472,1808, 1480,1688, 1488,1936, 1496,1960, - 1504,1816, 1512,1944, 1520,1944, 1528,2024, 1560,1584, 1592,1648, - 1600,1792, 1608,1920, 1616,1800, 1624,1712, 1632,1808, 1640,1936, - 1648,1816, 1656,1776, 1672,1696, 1688,1840, 1704,1952, 1712,1928, - 1720,1904, 1728,1824, 1736,1952, 1744,1832, 1752,1968, 1760,1840, - 1768,1960, 1776,1944, 1784,2032, 1864,1872, 1848,1944, 1872,1888, - 1880,1904, 1888,1984, 1896,2000, 1912,2032, 1904,2016, 1976,2032, - 1960,1968, 2008,2032, 1992,2016, 2024,2032 -}; +const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH] = { + /* 8x4, size 440 */ + 8, 512, 16, 1024, 24, 1536, 32, 64, 40, 576, 48, 1088, + 56, 1600, 64, 128, 72, 640, 80, 1152, 88, 1664, 96, 192, + 104, 704, 112, 1216, 120, 1728, 128, 256, 136, 768, 144, 1280, + 152, 1792, 160, 320, 168, 832, 176, 1344, 184, 1856, 192, 384, + 200, 896, 208, 1408, 216, 1920, 224, 448, 232, 960, 240, 1472, + 248, 1984, 256, 512, 264, 520, 272, 1032, 280, 1544, 288, 640, + 296, 584, 304, 1096, 312, 1608, 320, 768, 328, 648, 336, 1160, + 344, 1672, 352, 896, 360, 712, 368, 1224, 376, 1736, 384, 520, + 392, 776, 400, 1288, 408, 1800, 416, 648, 424, 840, 432, 1352, + 440, 1864, 448, 776, 456, 904, 464, 1416, 472, 1928, 480, 904, + 488, 968, 496, 1480, 504, 1992, 520, 528, 512, 1024, 528, 1040, + 536, 1552, 544, 1152, 552, 592, 560, 1104, 568, 1616, 576, 1280, + 584, 656, 592, 1168, 600, 1680, 608, 1408, 616, 720, 624, 1232, + 632, 1744, 640, 1032, 648, 784, 656, 1296, 664, 1808, 672, 1160, + 680, 848, 688, 1360, 696, 1872, 704, 1288, 712, 912, 720, 1424, + 728, 1936, 736, 1416, 744, 976, 752, 1488, 760, 2000, 768, 1536, + 776, 1552, 784, 1048, 792, 1560, 800, 1664, 808, 1680, 816, 1112, + 824, 1624, 832, 1792, 840, 1808, 848, 1176, 856, 1688, 864, 1920, + 872, 1936, 880, 1240, 888, 1752, 896, 1544, 904, 1560, 912, 1304, + 920, 1816, 928, 1672, 936, 1688, 944, 1368, 952, 1880, 960, 1800, + 968, 1816, 976, 1432, 984, 1944, 992, 1928, 1000, 1944, 1008, 1496, + 1016, 2008, 1032, 1152, 1040, 1056, 1048, 1568, 1064, 1408, 1072, 1120, + 1080, 1632, 1088, 1536, 1096, 1160, 1104, 1184, 1112, 1696, 1120, 1552, + 1128, 1416, 1136, 1248, 1144, 1760, 1160, 1664, 1168, 1312, 1176, 1824, + 1184, 1544, 1192, 1920, 1200, 1376, 1208, 1888, 1216, 1568, 1224, 1672, + 1232, 1440, 1240, 1952, 1248, 1560, 1256, 1928, 1264, 1504, 1272, 2016, + 1288, 1312, 1296, 1408, 1304, 1576, 1320, 1424, 1328, 1416, 1336, 1640, + 1344, 1792, 1352, 1824, 1360, 1920, 1368, 1704, 1376, 1800, 1384, 1432, + 1392, 1928, 1400, 1768, 1416, 1680, 1432, 1832, 1440, 1576, 1448, 1936, + 1456, 1832, 1464, 1896, 1472, 1808, 1480, 1688, 1488, 1936, 1496, 1960, + 1504, 1816, 1512, 1944, 1520, 1944, 1528, 2024, 1560, 1584, 1592, 1648, + 1600, 1792, 1608, 1920, 1616, 1800, 1624, 1712, 1632, 1808, 1640, 1936, + 1648, 1816, 1656, 1776, 1672, 1696, 1688, 1840, 1704, 1952, 1712, 1928, + 1720, 1904, 1728, 1824, 1736, 1952, 1744, 1832, 1752, 1968, 1760, 1840, + 1768, 1960, 1776, 1944, 1784, 2032, 1864, 1872, 1848, 1944, 1872, 1888, + 1880, 1904, 1888, 1984, 1896, 2000, 1912, 2032, 1904, 2016, 1976, 2032, + 1960, 1968, 2008, 2032, 1992, 2016, 2024, 2032}; -const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH] = -{ - /* radix 8, size 448 */ - 8,512, 16,1024, 24,1536, 32,2048, 40,2560, 48,3072, 56,3584, 72,576, - 80,1088, 88,1600, 96,2112, 104,2624, 112,3136, 120,3648, 136,640, 144,1152, - 152,1664, 160,2176, 168,2688, 176,3200, 184,3712, 200,704, 208,1216, - 216,1728, 224,2240, 232,2752, 240,3264, 248,3776, 264,768, 272,1280, - 280,1792, 288,2304, 296,2816, 304,3328, 312,3840, 328,832, 336,1344, - 344,1856, 352,2368, 360,2880, 368,3392, 376,3904, 392,896, 400,1408, - 408,1920, 416,2432, 424,2944, 432,3456, 440,3968, 456,960, 464,1472, - 472,1984, 480,2496, 488,3008, 496,3520, 504,4032, 528,1032, 536,1544, - 544,2056, 552,2568, 560,3080, 568,3592, 592,1096, 600,1608, 608,2120, - 616,2632, 624,3144, 632,3656, 656,1160, 664,1672, 672,2184, 680,2696, - 688,3208, 696,3720, 720,1224, 728,1736, 736,2248, 744,2760, 752,3272, - 760,3784, 784,1288, 792,1800, 800,2312, 808,2824, 816,3336, 824,3848, - 848,1352, 856,1864, 864,2376, 872,2888, 880,3400, 888,3912, 912,1416, - 920,1928, 928,2440, 936,2952, 944,3464, 952,3976, 976,1480, 984,1992, - 992,2504, 1000,3016, 1008,3528, 1016,4040, 1048,1552, 1056,2064, 1064,2576, - 1072,3088, 1080,3600, 1112,1616, 1120,2128, 1128,2640, 1136,3152, - 1144,3664, 1176,1680, 1184,2192, 1192,2704, 1200,3216, 1208,3728, - 1240,1744, 1248,2256, 1256,2768, 1264,3280, 1272,3792, 1304,1808, - 1312,2320, 1320,2832, 1328,3344, 1336,3856, 1368,1872, 1376,2384, - 1384,2896, 1392,3408, 1400,3920, 1432,1936, 1440,2448, 1448,2960, - 1456,3472, 1464,3984, 1496,2000, 1504,2512, 1512,3024, 1520,3536, - 1528,4048, 1568,2072, 1576,2584, 1584,3096, 1592,3608, 1632,2136, - 1640,2648, 1648,3160, 1656,3672, 1696,2200, 1704,2712, 1712,3224, - 1720,3736, 1760,2264, 1768,2776, 1776,3288, 1784,3800, 1824,2328, - 1832,2840, 1840,3352, 1848,3864, 1888,2392, 1896,2904, 1904,3416, - 1912,3928, 1952,2456, 1960,2968, 1968,3480, 1976,3992, 2016,2520, - 2024,3032, 2032,3544, 2040,4056, 2088,2592, 2096,3104, 2104,3616, - 2152,2656, 2160,3168, 2168,3680, 2216,2720, 2224,3232, 2232,3744, - 2280,2784, 2288,3296, 2296,3808, 2344,2848, 2352,3360, 2360,3872, - 2408,2912, 2416,3424, 2424,3936, 2472,2976, 2480,3488, 2488,4000, - 2536,3040, 2544,3552, 2552,4064, 2608,3112, 2616,3624, 2672,3176, - 2680,3688, 2736,3240, 2744,3752, 2800,3304, 2808,3816, 2864,3368, - 2872,3880, 2928,3432, 2936,3944, 2992,3496, 3000,4008, 3056,3560, - 3064,4072, 3128,3632, 3192,3696, 3256,3760, 3320,3824, 3384,3888, - 3448,3952, 3512,4016, 3576,4080 -}; +const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH] = { + /* radix 8, size 448 */ + 8, 512, 16, 1024, 24, 1536, 32, 2048, 40, 2560, 48, 3072, + 56, 3584, 72, 576, 80, 1088, 88, 1600, 96, 2112, 104, 2624, + 112, 3136, 120, 3648, 136, 640, 144, 1152, 152, 1664, 160, 2176, + 168, 2688, 176, 3200, 184, 3712, 200, 704, 208, 1216, 216, 1728, + 224, 2240, 232, 2752, 240, 3264, 248, 3776, 264, 768, 272, 1280, + 280, 1792, 288, 2304, 296, 2816, 304, 3328, 312, 3840, 328, 832, + 336, 1344, 344, 1856, 352, 2368, 360, 2880, 368, 3392, 376, 3904, + 392, 896, 400, 1408, 408, 1920, 416, 2432, 424, 2944, 432, 3456, + 440, 3968, 456, 960, 464, 1472, 472, 1984, 480, 2496, 488, 3008, + 496, 3520, 504, 4032, 528, 1032, 536, 1544, 544, 2056, 552, 2568, + 560, 3080, 568, 3592, 592, 1096, 600, 1608, 608, 2120, 616, 2632, + 624, 3144, 632, 3656, 656, 1160, 664, 1672, 672, 2184, 680, 2696, + 688, 3208, 696, 3720, 720, 1224, 728, 1736, 736, 2248, 744, 2760, + 752, 3272, 760, 3784, 784, 1288, 792, 1800, 800, 2312, 808, 2824, + 816, 3336, 824, 3848, 848, 1352, 856, 1864, 864, 2376, 872, 2888, + 880, 3400, 888, 3912, 912, 1416, 920, 1928, 928, 2440, 936, 2952, + 944, 3464, 952, 3976, 976, 1480, 984, 1992, 992, 2504, 1000, 3016, + 1008, 3528, 1016, 4040, 1048, 1552, 1056, 2064, 1064, 2576, 1072, 3088, + 1080, 3600, 1112, 1616, 1120, 2128, 1128, 2640, 1136, 3152, 1144, 3664, + 1176, 1680, 1184, 2192, 1192, 2704, 1200, 3216, 1208, 3728, 1240, 1744, + 1248, 2256, 1256, 2768, 1264, 3280, 1272, 3792, 1304, 1808, 1312, 2320, + 1320, 2832, 1328, 3344, 1336, 3856, 1368, 1872, 1376, 2384, 1384, 2896, + 1392, 3408, 1400, 3920, 1432, 1936, 1440, 2448, 1448, 2960, 1456, 3472, + 1464, 3984, 1496, 2000, 1504, 2512, 1512, 3024, 1520, 3536, 1528, 4048, + 1568, 2072, 1576, 2584, 1584, 3096, 1592, 3608, 1632, 2136, 1640, 2648, + 1648, 3160, 1656, 3672, 1696, 2200, 1704, 2712, 1712, 3224, 1720, 3736, + 1760, 2264, 1768, 2776, 1776, 3288, 1784, 3800, 1824, 2328, 1832, 2840, + 1840, 3352, 1848, 3864, 1888, 2392, 1896, 2904, 1904, 3416, 1912, 3928, + 1952, 2456, 1960, 2968, 1968, 3480, 1976, 3992, 2016, 2520, 2024, 3032, + 2032, 3544, 2040, 4056, 2088, 2592, 2096, 3104, 2104, 3616, 2152, 2656, + 2160, 3168, 2168, 3680, 2216, 2720, 2224, 3232, 2232, 3744, 2280, 2784, + 2288, 3296, 2296, 3808, 2344, 2848, 2352, 3360, 2360, 3872, 2408, 2912, + 2416, 3424, 2424, 3936, 2472, 2976, 2480, 3488, 2488, 4000, 2536, 3040, + 2544, 3552, 2552, 4064, 2608, 3112, 2616, 3624, 2672, 3176, 2680, 3688, + 2736, 3240, 2744, 3752, 2800, 3304, 2808, 3816, 2864, 3368, 2872, 3880, + 2928, 3432, 2936, 3944, 2992, 3496, 3000, 4008, 3056, 3560, 3064, 4072, + 3128, 3632, 3192, 3696, 3256, 3760, 3320, 3824, 3384, 3888, 3448, 3952, + 3512, 4016, 3576, 4080}; const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE_1024_TABLE_LENGTH] = -{ - /* 8x2, size 1800 */ - 8,4096, 16,512, 24,4608, 32,1024, 40,5120, 48,1536, 56,5632, 64,2048, - 72,6144, 80,2560, 88,6656, 96,3072, 104,7168, 112,3584, 120,7680, 128,2048, - 136,4160, 144,576, 152,4672, 160,1088, 168,5184, 176,1600, 184,5696, - 192,2112, 200,6208, 208,2624, 216,6720, 224,3136, 232,7232, 240,3648, - 248,7744, 256,2048, 264,4224, 272,640, 280,4736, 288,1152, 296,5248, - 304,1664, 312,5760, 320,2176, 328,6272, 336,2688, 344,6784, 352,3200, - 360,7296, 368,3712, 376,7808, 384,2112, 392,4288, 400,704, 408,4800, - 416,1216, 424,5312, 432,1728, 440,5824, 448,2240, 456,6336, 464,2752, - 472,6848, 480,3264, 488,7360, 496,3776, 504,7872, 512,2048, 520,4352, - 528,768, 536,4864, 544,1280, 552,5376, 560,1792, 568,5888, 576,2304, - 584,6400, 592,2816, 600,6912, 608,3328, 616,7424, 624,3840, 632,7936, - 640,2176, 648,4416, 656,832, 664,4928, 672,1344, 680,5440, 688,1856, - 696,5952, 704,2368, 712,6464, 720,2880, 728,6976, 736,3392, 744,7488, - 752,3904, 760,8000, 768,2112, 776,4480, 784,896, 792,4992, 800,1408, - 808,5504, 816,1920, 824,6016, 832,2432, 840,6528, 848,2944, 856,7040, - 864,3456, 872,7552, 880,3968, 888,8064, 896,2240, 904,4544, 912,960, - 920,5056, 928,1472, 936,5568, 944,1984, 952,6080, 960,2496, 968,6592, - 976,3008, 984,7104, 992,3520, 1000,7616, 1008,4032, 1016,8128, 1024,4096, - 1032,4104, 1040,4352, 1048,4616, 1056,4104, 1064,5128, 1072,1544, - 1080,5640, 1088,2056, 1096,6152, 1104,2568, 1112,6664, 1120,3080, - 1128,7176, 1136,3592, 1144,7688, 1152,6144, 1160,4168, 1168,6400, - 1176,4680, 1184,6152, 1192,5192, 1200,1608, 1208,5704, 1216,2120, - 1224,6216, 1232,2632, 1240,6728, 1248,3144, 1256,7240, 1264,3656, - 1272,7752, 1280,4160, 1288,4232, 1296,4416, 1304,4744, 1312,4168, - 1320,5256, 1328,1672, 1336,5768, 1344,2184, 1352,6280, 1360,2696, - 1368,6792, 1376,3208, 1384,7304, 1392,3720, 1400,7816, 1408,6208, - 1416,4296, 1424,6464, 1432,4808, 1440,6216, 1448,5320, 1456,1736, - 1464,5832, 1472,2248, 1480,6344, 1488,2760, 1496,6856, 1504,3272, - 1512,7368, 1520,3784, 1528,7880, 1536,4224, 1544,4360, 1552,4480, - 1560,4872, 1568,4232, 1576,5384, 1584,1800, 1592,5896, 1600,2312, - 1608,6408, 1616,2824, 1624,6920, 1632,3336, 1640,7432, 1648,3848, - 1656,7944, 1664,6272, 1672,4424, 1680,6528, 1688,4936, 1696,6280, - 1704,5448, 1712,1864, 1720,5960, 1728,2376, 1736,6472, 1744,2888, - 1752,6984, 1760,3400, 1768,7496, 1776,3912, 1784,8008, 1792,4288, - 1800,4488, 1808,4544, 1816,5000, 1824,4296, 1832,5512, 1840,1928, - 1848,6024, 1856,2440, 1864,6536, 1872,2952, 1880,7048, 1888,3464, - 1896,7560, 1904,3976, 1912,8072, 1920,6336, 1928,4552, 1936,6592, - 1944,5064, 1952,6344, 1960,5576, 1968,1992, 1976,6088, 1984,2504, - 1992,6600, 2000,3016, 2008,7112, 2016,3528, 2024,7624, 2032,4040, - 2040,8136, 2056,4112, 2064,2112, 2072,4624, 2080,4352, 2088,5136, - 2096,4480, 2104,5648, 2120,6160, 2128,2576, 2136,6672, 2144,3088, - 2152,7184, 2160,3600, 2168,7696, 2176,2560, 2184,4176, 2192,2816, - 2200,4688, 2208,2568, 2216,5200, 2224,2824, 2232,5712, 2240,2576, - 2248,6224, 2256,2640, 2264,6736, 2272,3152, 2280,7248, 2288,3664, - 2296,7760, 2312,4240, 2320,2432, 2328,4752, 2336,6400, 2344,5264, - 2352,6528, 2360,5776, 2368,2816, 2376,6288, 2384,2704, 2392,6800, - 2400,3216, 2408,7312, 2416,3728, 2424,7824, 2432,2624, 2440,4304, - 2448,2880, 2456,4816, 2464,2632, 2472,5328, 2480,2888, 2488,5840, - 2496,2640, 2504,6352, 2512,2768, 2520,6864, 2528,3280, 2536,7376, - 2544,3792, 2552,7888, 2568,4368, 2584,4880, 2592,4416, 2600,5392, - 2608,4544, 2616,5904, 2632,6416, 2640,2832, 2648,6928, 2656,3344, - 2664,7440, 2672,3856, 2680,7952, 2696,4432, 2704,2944, 2712,4944, - 2720,4432, 2728,5456, 2736,2952, 2744,5968, 2752,2944, 2760,6480, - 2768,2896, 2776,6992, 2784,3408, 2792,7504, 2800,3920, 2808,8016, - 2824,4496, 2840,5008, 2848,6464, 2856,5520, 2864,6592, 2872,6032, - 2888,6544, 2896,2960, 2904,7056, 2912,3472, 2920,7568, 2928,3984, - 2936,8080, 2952,4560, 2960,3008, 2968,5072, 2976,6480, 2984,5584, - 2992,3016, 3000,6096, 3016,6608, 3032,7120, 3040,3536, 3048,7632, - 3056,4048, 3064,8144, 3072,4608, 3080,4120, 3088,4864, 3096,4632, - 3104,4616, 3112,5144, 3120,4872, 3128,5656, 3136,4624, 3144,6168, - 3152,4880, 3160,6680, 3168,4632, 3176,7192, 3184,3608, 3192,7704, - 3200,6656, 3208,4184, 3216,6912, 3224,4696, 3232,6664, 3240,5208, - 3248,6920, 3256,5720, 3264,6672, 3272,6232, 3280,6928, 3288,6744, - 3296,6680, 3304,7256, 3312,3672, 3320,7768, 3328,4672, 3336,4248, - 3344,4928, 3352,4760, 3360,4680, 3368,5272, 3376,4936, 3384,5784, - 3392,4688, 3400,6296, 3408,4944, 3416,6808, 3424,4696, 3432,7320, - 3440,3736, 3448,7832, 3456,6720, 3464,4312, 3472,6976, 3480,4824, - 3488,6728, 3496,5336, 3504,6984, 3512,5848, 3520,6736, 3528,6360, - 3536,6992, 3544,6872, 3552,6744, 3560,7384, 3568,3800, 3576,7896, - 3584,4736, 3592,4376, 3600,4992, 3608,4888, 3616,4744, 3624,5400, - 3632,5000, 3640,5912, 3648,4752, 3656,6424, 3664,5008, 3672,6936, - 3680,4760, 3688,7448, 3696,3864, 3704,7960, 3712,6784, 3720,4440, - 3728,7040, 3736,4952, 3744,6792, 3752,5464, 3760,7048, 3768,5976, - 3776,6800, 3784,6488, 3792,7056, 3800,7000, 3808,6808, 3816,7512, - 3824,3928, 3832,8024, 3840,4800, 3848,4504, 3856,5056, 3864,5016, - 3872,4808, 3880,5528, 3888,5064, 3896,6040, 3904,4816, 3912,6552, - 3920,5072, 3928,7064, 3936,4824, 3944,7576, 3952,3992, 3960,8088, - 3968,6848, 3976,4568, 3984,7104, 3992,5080, 4000,6856, 4008,5592, - 4016,7112, 4024,6104, 4032,6864, 4040,6616, 4048,7120, 4056,7128, - 4064,6872, 4072,7640, 4080,7128, 4088,8152, 4104,4128, 4112,4160, - 4120,4640, 4136,5152, 4144,4232, 4152,5664, 4160,4352, 4168,6176, - 4176,4416, 4184,6688, 4192,4616, 4200,7200, 4208,4744, 4216,7712, - 4224,4608, 4232,4616, 4240,4672, 4248,4704, 4256,4640, 4264,5216, - 4272,4704, 4280,5728, 4288,4864, 4296,6240, 4304,4928, 4312,6752, - 4320,4632, 4328,7264, 4336,4760, 4344,7776, 4360,4640, 4368,4416, - 4376,4768, 4384,6152, 4392,5280, 4400,6280, 4408,5792, 4424,6304, - 4440,6816, 4448,6664, 4456,7328, 4464,6792, 4472,7840, 4480,4624, - 4488,4632, 4496,4688, 4504,4832, 4512,6168, 4520,5344, 4528,6296, - 4536,5856, 4544,4880, 4552,6368, 4560,4944, 4568,6880, 4576,6680, - 4584,7392, 4592,6808, 4600,7904, 4608,6144, 4616,6152, 4624,6208, - 4632,4896, 4640,6176, 4648,5408, 4656,6240, 4664,5920, 4672,6400, - 4680,6432, 4688,6464, 4696,6944, 4704,6432, 4712,7456, 4720,4808, - 4728,7968, 4736,6656, 4744,6664, 4752,6720, 4760,4960, 4768,6688, - 4776,5472, 4784,6752, 4792,5984, 4800,6912, 4808,6496, 4816,6976, - 4824,7008, 4832,6944, 4840,7520, 4848,7008, 4856,8032, 4864,6160, - 4872,6168, 4880,6224, 4888,5024, 4896,6216, 4904,5536, 4912,6344, - 4920,6048, 4928,6416, 4936,6560, 4944,6480, 4952,7072, 4960,6728, - 4968,7584, 4976,6856, 4984,8096, 4992,6672, 5000,6680, 5008,6736, - 5016,5088, 5024,6232, 5032,5600, 5040,6360, 5048,6112, 5056,6928, - 5064,6624, 5072,6992, 5080,7136, 5088,6744, 5096,7648, 5104,6872, - 5112,8160, 5128,5152, 5136,5376, 5144,5408, 5168,5384, 5176,5672, - 5184,5376, 5192,6184, 5200,5392, 5208,6696, 5216,5408, 5224,7208, - 5232,5400, 5240,7720, 5248,7168, 5256,7200, 5264,7424, 5272,7456, - 5280,7176, 5288,7208, 5296,7432, 5304,5736, 5312,7184, 5320,6248, - 5328,7440, 5336,6760, 5344,7192, 5352,7272, 5360,7448, 5368,7784, - 5384,5408, 5392,5440, 5400,5472, 5408,6184, 5416,7208, 5424,5448, - 5432,5800, 5448,6312, 5464,6824, 5472,6696, 5480,7336, 5488,6824, - 5496,7848, 5504,7232, 5512,7264, 5520,7488, 5528,7520, 5536,7240, - 5544,7272, 5552,7496, 5560,5864, 5568,7248, 5576,6376, 5584,7504, - 5592,6888, 5600,7256, 5608,7400, 5616,7512, 5624,7912, 5632,7168, - 5640,7176, 5648,7232, 5656,7240, 5664,7200, 5672,7208, 5680,7264, - 5688,5928, 5696,7424, 5704,6440, 5712,7488, 5720,6952, 5728,7456, - 5736,7464, 5744,7520, 5752,7976, 5760,7296, 5768,7328, 5776,7552, - 5784,7584, 5792,7304, 5800,7336, 5808,7560, 5816,5992, 5824,7312, - 5832,6504, 5840,7568, 5848,7016, 5856,7320, 5864,7528, 5872,7576, - 5880,8040, 5888,7184, 5896,7192, 5904,7248, 5912,7256, 5920,6248, - 5928,7272, 5936,6376, 5944,6056, 5952,7440, 5960,6568, 5968,7504, - 5976,7080, 5984,6760, 5992,7592, 6000,6888, 6008,8104, 6016,7360, - 6024,7392, 6032,7616, 6040,7648, 6048,7368, 6056,7400, 6064,7624, - 6072,6120, 6080,7376, 6088,6632, 6096,7632, 6104,7144, 6112,7384, - 6120,7656, 6128,7640, 6136,8168, 6168,6240, 6192,6216, 6200,7264, - 6232,6704, 6248,7216, 6256,6680, 6264,7728, 6272,6656, 6280,6664, - 6288,6912, 6296,6496, 6304,6688, 6312,6696, 6320,6944, 6328,7520, - 6336,6672, 6344,6680, 6352,6928, 6360,6768, 6368,6704, 6376,7280, - 6384,6744, 6392,7792, 6408,6432, 6424,6752, 6440,7432, 6448,6536, - 6456,7560, 6472,6944, 6488,6832, 6496,6920, 6504,7344, 6512,7048, - 6520,7856, 6528,6720, 6536,6728, 6544,6976, 6552,7008, 6560,6752, - 6568,7448, 6576,7008, 6584,7576, 6592,6736, 6600,6744, 6608,6992, - 6616,6896, 6624,6936, 6632,7408, 6640,7064, 6648,7920, 6712,7280, - 6744,6960, 6760,7472, 6768,6936, 6776,7984, 6800,6848, 6808,6856, - 6832,6880, 6840,6888, 6848,7040, 6856,7048, 6864,7104, 6872,7024, - 6880,7072, 6888,7536, 6896,7136, 6904,8048, 6952,7496, 6968,7624, - 6984,7008, 7000,7088, 7016,7600, 7024,7112, 7032,8112, 7056,7104, - 7064,7112, 7080,7512, 7088,7136, 7096,7640, 7128,7152, 7144,7664, - 7160,8176, 7176,7200, 7192,7216, 7224,7272, 7240,7264, 7256,7280, - 7288,7736, 7296,7680, 7304,7712, 7312,7936, 7320,7968, 7328,7688, - 7336,7720, 7344,7944, 7352,7976, 7360,7696, 7368,7728, 7376,7952, - 7384,7984, 7392,7704, 7400,7736, 7408,7960, 7416,7800, 7432,7456, - 7448,7472, 7480,7592, 7496,7520, 7512,7536, 7528,7976, 7544,7864, - 7552,7744, 7560,7776, 7568,8000, 7576,8032, 7584,7752, 7592,7784, - 7600,8008, 7608,8040, 7616,7760, 7624,7792, 7632,8016, 7640,8048, - 7648,7768, 7656,7800, 7664,8024, 7672,7928, 7688,7712, 7704,7728, - 7752,7776, 7768,7792, 7800,7992, 7816,7840, 7824,8064, 7832,8096, - 7856,8072, 7864,8104, 7872,8064, 7880,8072, 7888,8080, 7896,8112, - 7904,8096, 7912,8104, 7920,8088, 7928,8056, 7944,7968, 7960,7984, - 8008,8032, 8024,8048, 8056,8120, 8072,8096, 8080,8128, 8088,8160, - 8112,8136, 8120,8168, 8136,8160, 8152,8176 -}; + { + /* 8x2, size 1800 */ + 8, 4096, 16, 512, 24, 4608, 32, 1024, 40, 5120, 48, 1536, + 56, 5632, 64, 2048, 72, 6144, 80, 2560, 88, 6656, 96, 3072, + 104, 7168, 112, 3584, 120, 7680, 128, 2048, 136, 4160, 144, 576, + 152, 4672, 160, 1088, 168, 5184, 176, 1600, 184, 5696, 192, 2112, + 200, 6208, 208, 2624, 216, 6720, 224, 3136, 232, 7232, 240, 3648, + 248, 7744, 256, 2048, 264, 4224, 272, 640, 280, 4736, 288, 1152, + 296, 5248, 304, 1664, 312, 5760, 320, 2176, 328, 6272, 336, 2688, + 344, 6784, 352, 3200, 360, 7296, 368, 3712, 376, 7808, 384, 2112, + 392, 4288, 400, 704, 408, 4800, 416, 1216, 424, 5312, 432, 1728, + 440, 5824, 448, 2240, 456, 6336, 464, 2752, 472, 6848, 480, 3264, + 488, 7360, 496, 3776, 504, 7872, 512, 2048, 520, 4352, 528, 768, + 536, 4864, 544, 1280, 552, 5376, 560, 1792, 568, 5888, 576, 2304, + 584, 6400, 592, 2816, 600, 6912, 608, 3328, 616, 7424, 624, 3840, + 632, 7936, 640, 2176, 648, 4416, 656, 832, 664, 4928, 672, 1344, + 680, 5440, 688, 1856, 696, 5952, 704, 2368, 712, 6464, 720, 2880, + 728, 6976, 736, 3392, 744, 7488, 752, 3904, 760, 8000, 768, 2112, + 776, 4480, 784, 896, 792, 4992, 800, 1408, 808, 5504, 816, 1920, + 824, 6016, 832, 2432, 840, 6528, 848, 2944, 856, 7040, 864, 3456, + 872, 7552, 880, 3968, 888, 8064, 896, 2240, 904, 4544, 912, 960, + 920, 5056, 928, 1472, 936, 5568, 944, 1984, 952, 6080, 960, 2496, + 968, 6592, 976, 3008, 984, 7104, 992, 3520, 1000, 7616, 1008, 4032, + 1016, 8128, 1024, 4096, 1032, 4104, 1040, 4352, 1048, 4616, 1056, 4104, + 1064, 5128, 1072, 1544, 1080, 5640, 1088, 2056, 1096, 6152, 1104, 2568, + 1112, 6664, 1120, 3080, 1128, 7176, 1136, 3592, 1144, 7688, 1152, 6144, + 1160, 4168, 1168, 6400, 1176, 4680, 1184, 6152, 1192, 5192, 1200, 1608, + 1208, 5704, 1216, 2120, 1224, 6216, 1232, 2632, 1240, 6728, 1248, 3144, + 1256, 7240, 1264, 3656, 1272, 7752, 1280, 4160, 1288, 4232, 1296, 4416, + 1304, 4744, 1312, 4168, 1320, 5256, 1328, 1672, 1336, 5768, 1344, 2184, + 1352, 6280, 1360, 2696, 1368, 6792, 1376, 3208, 1384, 7304, 1392, 3720, + 1400, 7816, 1408, 6208, 1416, 4296, 1424, 6464, 1432, 4808, 1440, 6216, + 1448, 5320, 1456, 1736, 1464, 5832, 1472, 2248, 1480, 6344, 1488, 2760, + 1496, 6856, 1504, 3272, 1512, 7368, 1520, 3784, 1528, 7880, 1536, 4224, + 1544, 4360, 1552, 4480, 1560, 4872, 1568, 4232, 1576, 5384, 1584, 1800, + 1592, 5896, 1600, 2312, 1608, 6408, 1616, 2824, 1624, 6920, 1632, 3336, + 1640, 7432, 1648, 3848, 1656, 7944, 1664, 6272, 1672, 4424, 1680, 6528, + 1688, 4936, 1696, 6280, 1704, 5448, 1712, 1864, 1720, 5960, 1728, 2376, + 1736, 6472, 1744, 2888, 1752, 6984, 1760, 3400, 1768, 7496, 1776, 3912, + 1784, 8008, 1792, 4288, 1800, 4488, 1808, 4544, 1816, 5000, 1824, 4296, + 1832, 5512, 1840, 1928, 1848, 6024, 1856, 2440, 1864, 6536, 1872, 2952, + 1880, 7048, 1888, 3464, 1896, 7560, 1904, 3976, 1912, 8072, 1920, 6336, + 1928, 4552, 1936, 6592, 1944, 5064, 1952, 6344, 1960, 5576, 1968, 1992, + 1976, 6088, 1984, 2504, 1992, 6600, 2000, 3016, 2008, 7112, 2016, 3528, + 2024, 7624, 2032, 4040, 2040, 8136, 2056, 4112, 2064, 2112, 2072, 4624, + 2080, 4352, 2088, 5136, 2096, 4480, 2104, 5648, 2120, 6160, 2128, 2576, + 2136, 6672, 2144, 3088, 2152, 7184, 2160, 3600, 2168, 7696, 2176, 2560, + 2184, 4176, 2192, 2816, 2200, 4688, 2208, 2568, 2216, 5200, 2224, 2824, + 2232, 5712, 2240, 2576, 2248, 6224, 2256, 2640, 2264, 6736, 2272, 3152, + 2280, 7248, 2288, 3664, 2296, 7760, 2312, 4240, 2320, 2432, 2328, 4752, + 2336, 6400, 2344, 5264, 2352, 6528, 2360, 5776, 2368, 2816, 2376, 6288, + 2384, 2704, 2392, 6800, 2400, 3216, 2408, 7312, 2416, 3728, 2424, 7824, + 2432, 2624, 2440, 4304, 2448, 2880, 2456, 4816, 2464, 2632, 2472, 5328, + 2480, 2888, 2488, 5840, 2496, 2640, 2504, 6352, 2512, 2768, 2520, 6864, + 2528, 3280, 2536, 7376, 2544, 3792, 2552, 7888, 2568, 4368, 2584, 4880, + 2592, 4416, 2600, 5392, 2608, 4544, 2616, 5904, 2632, 6416, 2640, 2832, + 2648, 6928, 2656, 3344, 2664, 7440, 2672, 3856, 2680, 7952, 2696, 4432, + 2704, 2944, 2712, 4944, 2720, 4432, 2728, 5456, 2736, 2952, 2744, 5968, + 2752, 2944, 2760, 6480, 2768, 2896, 2776, 6992, 2784, 3408, 2792, 7504, + 2800, 3920, 2808, 8016, 2824, 4496, 2840, 5008, 2848, 6464, 2856, 5520, + 2864, 6592, 2872, 6032, 2888, 6544, 2896, 2960, 2904, 7056, 2912, 3472, + 2920, 7568, 2928, 3984, 2936, 8080, 2952, 4560, 2960, 3008, 2968, 5072, + 2976, 6480, 2984, 5584, 2992, 3016, 3000, 6096, 3016, 6608, 3032, 7120, + 3040, 3536, 3048, 7632, 3056, 4048, 3064, 8144, 3072, 4608, 3080, 4120, + 3088, 4864, 3096, 4632, 3104, 4616, 3112, 5144, 3120, 4872, 3128, 5656, + 3136, 4624, 3144, 6168, 3152, 4880, 3160, 6680, 3168, 4632, 3176, 7192, + 3184, 3608, 3192, 7704, 3200, 6656, 3208, 4184, 3216, 6912, 3224, 4696, + 3232, 6664, 3240, 5208, 3248, 6920, 3256, 5720, 3264, 6672, 3272, 6232, + 3280, 6928, 3288, 6744, 3296, 6680, 3304, 7256, 3312, 3672, 3320, 7768, + 3328, 4672, 3336, 4248, 3344, 4928, 3352, 4760, 3360, 4680, 3368, 5272, + 3376, 4936, 3384, 5784, 3392, 4688, 3400, 6296, 3408, 4944, 3416, 6808, + 3424, 4696, 3432, 7320, 3440, 3736, 3448, 7832, 3456, 6720, 3464, 4312, + 3472, 6976, 3480, 4824, 3488, 6728, 3496, 5336, 3504, 6984, 3512, 5848, + 3520, 6736, 3528, 6360, 3536, 6992, 3544, 6872, 3552, 6744, 3560, 7384, + 3568, 3800, 3576, 7896, 3584, 4736, 3592, 4376, 3600, 4992, 3608, 4888, + 3616, 4744, 3624, 5400, 3632, 5000, 3640, 5912, 3648, 4752, 3656, 6424, + 3664, 5008, 3672, 6936, 3680, 4760, 3688, 7448, 3696, 3864, 3704, 7960, + 3712, 6784, 3720, 4440, 3728, 7040, 3736, 4952, 3744, 6792, 3752, 5464, + 3760, 7048, 3768, 5976, 3776, 6800, 3784, 6488, 3792, 7056, 3800, 7000, + 3808, 6808, 3816, 7512, 3824, 3928, 3832, 8024, 3840, 4800, 3848, 4504, + 3856, 5056, 3864, 5016, 3872, 4808, 3880, 5528, 3888, 5064, 3896, 6040, + 3904, 4816, 3912, 6552, 3920, 5072, 3928, 7064, 3936, 4824, 3944, 7576, + 3952, 3992, 3960, 8088, 3968, 6848, 3976, 4568, 3984, 7104, 3992, 5080, + 4000, 6856, 4008, 5592, 4016, 7112, 4024, 6104, 4032, 6864, 4040, 6616, + 4048, 7120, 4056, 7128, 4064, 6872, 4072, 7640, 4080, 7128, 4088, 8152, + 4104, 4128, 4112, 4160, 4120, 4640, 4136, 5152, 4144, 4232, 4152, 5664, + 4160, 4352, 4168, 6176, 4176, 4416, 4184, 6688, 4192, 4616, 4200, 7200, + 4208, 4744, 4216, 7712, 4224, 4608, 4232, 4616, 4240, 4672, 4248, 4704, + 4256, 4640, 4264, 5216, 4272, 4704, 4280, 5728, 4288, 4864, 4296, 6240, + 4304, 4928, 4312, 6752, 4320, 4632, 4328, 7264, 4336, 4760, 4344, 7776, + 4360, 4640, 4368, 4416, 4376, 4768, 4384, 6152, 4392, 5280, 4400, 6280, + 4408, 5792, 4424, 6304, 4440, 6816, 4448, 6664, 4456, 7328, 4464, 6792, + 4472, 7840, 4480, 4624, 4488, 4632, 4496, 4688, 4504, 4832, 4512, 6168, + 4520, 5344, 4528, 6296, 4536, 5856, 4544, 4880, 4552, 6368, 4560, 4944, + 4568, 6880, 4576, 6680, 4584, 7392, 4592, 6808, 4600, 7904, 4608, 6144, + 4616, 6152, 4624, 6208, 4632, 4896, 4640, 6176, 4648, 5408, 4656, 6240, + 4664, 5920, 4672, 6400, 4680, 6432, 4688, 6464, 4696, 6944, 4704, 6432, + 4712, 7456, 4720, 4808, 4728, 7968, 4736, 6656, 4744, 6664, 4752, 6720, + 4760, 4960, 4768, 6688, 4776, 5472, 4784, 6752, 4792, 5984, 4800, 6912, + 4808, 6496, 4816, 6976, 4824, 7008, 4832, 6944, 4840, 7520, 4848, 7008, + 4856, 8032, 4864, 6160, 4872, 6168, 4880, 6224, 4888, 5024, 4896, 6216, + 4904, 5536, 4912, 6344, 4920, 6048, 4928, 6416, 4936, 6560, 4944, 6480, + 4952, 7072, 4960, 6728, 4968, 7584, 4976, 6856, 4984, 8096, 4992, 6672, + 5000, 6680, 5008, 6736, 5016, 5088, 5024, 6232, 5032, 5600, 5040, 6360, + 5048, 6112, 5056, 6928, 5064, 6624, 5072, 6992, 5080, 7136, 5088, 6744, + 5096, 7648, 5104, 6872, 5112, 8160, 5128, 5152, 5136, 5376, 5144, 5408, + 5168, 5384, 5176, 5672, 5184, 5376, 5192, 6184, 5200, 5392, 5208, 6696, + 5216, 5408, 5224, 7208, 5232, 5400, 5240, 7720, 5248, 7168, 5256, 7200, + 5264, 7424, 5272, 7456, 5280, 7176, 5288, 7208, 5296, 7432, 5304, 5736, + 5312, 7184, 5320, 6248, 5328, 7440, 5336, 6760, 5344, 7192, 5352, 7272, + 5360, 7448, 5368, 7784, 5384, 5408, 5392, 5440, 5400, 5472, 5408, 6184, + 5416, 7208, 5424, 5448, 5432, 5800, 5448, 6312, 5464, 6824, 5472, 6696, + 5480, 7336, 5488, 6824, 5496, 7848, 5504, 7232, 5512, 7264, 5520, 7488, + 5528, 7520, 5536, 7240, 5544, 7272, 5552, 7496, 5560, 5864, 5568, 7248, + 5576, 6376, 5584, 7504, 5592, 6888, 5600, 7256, 5608, 7400, 5616, 7512, + 5624, 7912, 5632, 7168, 5640, 7176, 5648, 7232, 5656, 7240, 5664, 7200, + 5672, 7208, 5680, 7264, 5688, 5928, 5696, 7424, 5704, 6440, 5712, 7488, + 5720, 6952, 5728, 7456, 5736, 7464, 5744, 7520, 5752, 7976, 5760, 7296, + 5768, 7328, 5776, 7552, 5784, 7584, 5792, 7304, 5800, 7336, 5808, 7560, + 5816, 5992, 5824, 7312, 5832, 6504, 5840, 7568, 5848, 7016, 5856, 7320, + 5864, 7528, 5872, 7576, 5880, 8040, 5888, 7184, 5896, 7192, 5904, 7248, + 5912, 7256, 5920, 6248, 5928, 7272, 5936, 6376, 5944, 6056, 5952, 7440, + 5960, 6568, 5968, 7504, 5976, 7080, 5984, 6760, 5992, 7592, 6000, 6888, + 6008, 8104, 6016, 7360, 6024, 7392, 6032, 7616, 6040, 7648, 6048, 7368, + 6056, 7400, 6064, 7624, 6072, 6120, 6080, 7376, 6088, 6632, 6096, 7632, + 6104, 7144, 6112, 7384, 6120, 7656, 6128, 7640, 6136, 8168, 6168, 6240, + 6192, 6216, 6200, 7264, 6232, 6704, 6248, 7216, 6256, 6680, 6264, 7728, + 6272, 6656, 6280, 6664, 6288, 6912, 6296, 6496, 6304, 6688, 6312, 6696, + 6320, 6944, 6328, 7520, 6336, 6672, 6344, 6680, 6352, 6928, 6360, 6768, + 6368, 6704, 6376, 7280, 6384, 6744, 6392, 7792, 6408, 6432, 6424, 6752, + 6440, 7432, 6448, 6536, 6456, 7560, 6472, 6944, 6488, 6832, 6496, 6920, + 6504, 7344, 6512, 7048, 6520, 7856, 6528, 6720, 6536, 6728, 6544, 6976, + 6552, 7008, 6560, 6752, 6568, 7448, 6576, 7008, 6584, 7576, 6592, 6736, + 6600, 6744, 6608, 6992, 6616, 6896, 6624, 6936, 6632, 7408, 6640, 7064, + 6648, 7920, 6712, 7280, 6744, 6960, 6760, 7472, 6768, 6936, 6776, 7984, + 6800, 6848, 6808, 6856, 6832, 6880, 6840, 6888, 6848, 7040, 6856, 7048, + 6864, 7104, 6872, 7024, 6880, 7072, 6888, 7536, 6896, 7136, 6904, 8048, + 6952, 7496, 6968, 7624, 6984, 7008, 7000, 7088, 7016, 7600, 7024, 7112, + 7032, 8112, 7056, 7104, 7064, 7112, 7080, 7512, 7088, 7136, 7096, 7640, + 7128, 7152, 7144, 7664, 7160, 8176, 7176, 7200, 7192, 7216, 7224, 7272, + 7240, 7264, 7256, 7280, 7288, 7736, 7296, 7680, 7304, 7712, 7312, 7936, + 7320, 7968, 7328, 7688, 7336, 7720, 7344, 7944, 7352, 7976, 7360, 7696, + 7368, 7728, 7376, 7952, 7384, 7984, 7392, 7704, 7400, 7736, 7408, 7960, + 7416, 7800, 7432, 7456, 7448, 7472, 7480, 7592, 7496, 7520, 7512, 7536, + 7528, 7976, 7544, 7864, 7552, 7744, 7560, 7776, 7568, 8000, 7576, 8032, + 7584, 7752, 7592, 7784, 7600, 8008, 7608, 8040, 7616, 7760, 7624, 7792, + 7632, 8016, 7640, 8048, 7648, 7768, 7656, 7800, 7664, 8024, 7672, 7928, + 7688, 7712, 7704, 7728, 7752, 7776, 7768, 7792, 7800, 7992, 7816, 7840, + 7824, 8064, 7832, 8096, 7856, 8072, 7864, 8104, 7872, 8064, 7880, 8072, + 7888, 8080, 7896, 8112, 7904, 8096, 7912, 8104, 7920, 8088, 7928, 8056, + 7944, 7968, 7960, 7984, 8008, 8032, 8024, 8048, 8056, 8120, 8072, 8096, + 8080, 8128, 8088, 8160, 8112, 8136, 8120, 8168, 8136, 8160, 8152, 8176}; const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE_2048_TABLE_LENGTH] = -{ - /* 8x2, size 3808 */ - 8,4096, 16,8192, 24,12288, 32,512, 40,4608, 48,8704, 56,12800, 64,1024, - 72,5120, 80,9216, 88,13312, 96,1536, 104,5632, 112,9728, 120,13824, - 128,2048, 136,6144, 144,10240, 152,14336, 160,2560, 168,6656, 176,10752, - 184,14848, 192,3072, 200,7168, 208,11264, 216,15360, 224,3584, 232,7680, - 240,11776, 248,15872, 256,1024, 264,4160, 272,8256, 280,12352, 288,576, - 296,4672, 304,8768, 312,12864, 320,1088, 328,5184, 336,9280, 344,13376, - 352,1600, 360,5696, 368,9792, 376,13888, 384,2112, 392,6208, 400,10304, - 408,14400, 416,2624, 424,6720, 432,10816, 440,14912, 448,3136, 456,7232, - 464,11328, 472,15424, 480,3648, 488,7744, 496,11840, 504,15936, 512,2048, - 520,4224, 528,8320, 536,12416, 544,640, 552,4736, 560,8832, 568,12928, - 576,1152, 584,5248, 592,9344, 600,13440, 608,1664, 616,5760, 624,9856, - 632,13952, 640,2176, 648,6272, 656,10368, 664,14464, 672,2688, 680,6784, - 688,10880, 696,14976, 704,3200, 712,7296, 720,11392, 728,15488, 736,3712, - 744,7808, 752,11904, 760,16000, 768,3072, 776,4288, 784,8384, 792,12480, - 800,3200, 808,4800, 816,8896, 824,12992, 832,1216, 840,5312, 848,9408, - 856,13504, 864,1728, 872,5824, 880,9920, 888,14016, 896,2240, 904,6336, - 912,10432, 920,14528, 928,2752, 936,6848, 944,10944, 952,15040, 960,3264, - 968,7360, 976,11456, 984,15552, 992,3776, 1000,7872, 1008,11968, 1016,16064, - 1032,4352, 1040,8448, 1048,12544, 1056,3072, 1064,4864, 1072,8960, - 1080,13056, 1088,1280, 1096,5376, 1104,9472, 1112,13568, 1120,1792, - 1128,5888, 1136,9984, 1144,14080, 1152,2304, 1160,6400, 1168,10496, - 1176,14592, 1184,2816, 1192,6912, 1200,11008, 1208,15104, 1216,3328, - 1224,7424, 1232,11520, 1240,15616, 1248,3840, 1256,7936, 1264,12032, - 1272,16128, 1288,4416, 1296,8512, 1304,12608, 1312,3328, 1320,4928, - 1328,9024, 1336,13120, 1352,5440, 1360,9536, 1368,13632, 1376,1856, - 1384,5952, 1392,10048, 1400,14144, 1408,2368, 1416,6464, 1424,10560, - 1432,14656, 1440,2880, 1448,6976, 1456,11072, 1464,15168, 1472,3392, - 1480,7488, 1488,11584, 1496,15680, 1504,3904, 1512,8000, 1520,12096, - 1528,16192, 1536,2112, 1544,4480, 1552,8576, 1560,12672, 1568,2240, - 1576,4992, 1584,9088, 1592,13184, 1600,2368, 1608,5504, 1616,9600, - 1624,13696, 1632,1920, 1640,6016, 1648,10112, 1656,14208, 1664,2432, - 1672,6528, 1680,10624, 1688,14720, 1696,2944, 1704,7040, 1712,11136, - 1720,15232, 1728,3456, 1736,7552, 1744,11648, 1752,15744, 1760,3968, - 1768,8064, 1776,12160, 1784,16256, 1792,3136, 1800,4544, 1808,8640, - 1816,12736, 1824,3264, 1832,5056, 1840,9152, 1848,13248, 1856,3392, - 1864,5568, 1872,9664, 1880,13760, 1888,1984, 1896,6080, 1904,10176, - 1912,14272, 1920,2496, 1928,6592, 1936,10688, 1944,14784, 1952,3008, - 1960,7104, 1968,11200, 1976,15296, 1984,3520, 1992,7616, 2000,11712, - 2008,15808, 2016,4032, 2024,8128, 2032,12224, 2040,16320, 2048,4096, - 2056,4104, 2064,8200, 2072,12296, 2080,4224, 2088,4616, 2096,8712, - 2104,12808, 2112,4352, 2120,5128, 2128,9224, 2136,13320, 2144,4480, - 2152,5640, 2160,9736, 2168,13832, 2176,4104, 2184,6152, 2192,10248, - 2200,14344, 2208,2568, 2216,6664, 2224,10760, 2232,14856, 2240,3080, - 2248,7176, 2256,11272, 2264,15368, 2272,3592, 2280,7688, 2288,11784, - 2296,15880, 2304,5120, 2312,4168, 2320,8264, 2328,12360, 2336,5248, - 2344,4680, 2352,8776, 2360,12872, 2368,5376, 2376,5192, 2384,9288, - 2392,13384, 2400,5504, 2408,5704, 2416,9800, 2424,13896, 2432,5128, - 2440,6216, 2448,10312, 2456,14408, 2464,2632, 2472,6728, 2480,10824, - 2488,14920, 2496,3144, 2504,7240, 2512,11336, 2520,15432, 2528,3656, - 2536,7752, 2544,11848, 2552,15944, 2560,6144, 2568,4232, 2576,8328, - 2584,12424, 2592,6272, 2600,4744, 2608,8840, 2616,12936, 2624,6400, - 2632,5256, 2640,9352, 2648,13448, 2656,6528, 2664,5768, 2672,9864, - 2680,13960, 2688,6152, 2696,6280, 2704,10376, 2712,14472, 2720,6280, - 2728,6792, 2736,10888, 2744,14984, 2752,3208, 2760,7304, 2768,11400, - 2776,15496, 2784,3720, 2792,7816, 2800,11912, 2808,16008, 2816,7168, - 2824,4296, 2832,8392, 2840,12488, 2848,7296, 2856,4808, 2864,8904, - 2872,13000, 2880,7424, 2888,5320, 2896,9416, 2904,13512, 2912,7552, - 2920,5832, 2928,9928, 2936,14024, 2944,7176, 2952,6344, 2960,10440, - 2968,14536, 2976,7304, 2984,6856, 2992,10952, 3000,15048, 3008,3272, - 3016,7368, 3024,11464, 3032,15560, 3040,3784, 3048,7880, 3056,11976, - 3064,16072, 3072,4160, 3080,4360, 3088,8456, 3096,12552, 3104,4288, - 3112,4872, 3120,8968, 3128,13064, 3136,4416, 3144,5384, 3152,9480, - 3160,13576, 3168,4544, 3176,5896, 3184,9992, 3192,14088, 3200,4168, - 3208,6408, 3216,10504, 3224,14600, 3232,4296, 3240,6920, 3248,11016, - 3256,15112, 3264,3336, 3272,7432, 3280,11528, 3288,15624, 3296,3848, - 3304,7944, 3312,12040, 3320,16136, 3328,5184, 3336,4424, 3344,8520, - 3352,12616, 3360,5312, 3368,4936, 3376,9032, 3384,13128, 3392,5440, - 3400,5448, 3408,9544, 3416,13640, 3424,5568, 3432,5960, 3440,10056, - 3448,14152, 3456,5192, 3464,6472, 3472,10568, 3480,14664, 3488,5320, - 3496,6984, 3504,11080, 3512,15176, 3520,5448, 3528,7496, 3536,11592, - 3544,15688, 3552,3912, 3560,8008, 3568,12104, 3576,16200, 3584,6208, - 3592,4488, 3600,8584, 3608,12680, 3616,6336, 3624,5000, 3632,9096, - 3640,13192, 3648,6464, 3656,5512, 3664,9608, 3672,13704, 3680,6592, - 3688,6024, 3696,10120, 3704,14216, 3712,6216, 3720,6536, 3728,10632, - 3736,14728, 3744,6344, 3752,7048, 3760,11144, 3768,15240, 3776,6472, - 3784,7560, 3792,11656, 3800,15752, 3808,3976, 3816,8072, 3824,12168, - 3832,16264, 3840,7232, 3848,4552, 3856,8648, 3864,12744, 3872,7360, - 3880,5064, 3888,9160, 3896,13256, 3904,7488, 3912,5576, 3920,9672, - 3928,13768, 3936,7616, 3944,6088, 3952,10184, 3960,14280, 3968,7240, - 3976,6600, 3984,10696, 3992,14792, 4000,7368, 4008,7112, 4016,11208, - 4024,15304, 4032,7496, 4040,7624, 4048,11720, 4056,15816, 4064,7624, - 4072,8136, 4080,12232, 4088,16328, 4096,8192, 4104,4112, 4112,8208, - 4120,12304, 4128,8320, 4136,4624, 4144,8720, 4152,12816, 4160,8448, - 4168,5136, 4176,9232, 4184,13328, 4192,8576, 4200,5648, 4208,9744, - 4216,13840, 4224,8200, 4232,6160, 4240,10256, 4248,14352, 4256,8328, - 4264,6672, 4272,10768, 4280,14864, 4288,8456, 4296,7184, 4304,11280, - 4312,15376, 4320,8584, 4328,7696, 4336,11792, 4344,15888, 4352,9216, - 4360,9232, 4368,8272, 4376,12368, 4384,9344, 4392,4688, 4400,8784, - 4408,12880, 4416,9472, 4424,5200, 4432,9296, 4440,13392, 4448,9600, - 4456,5712, 4464,9808, 4472,13904, 4480,9224, 4488,6224, 4496,10320, - 4504,14416, 4512,9352, 4520,6736, 4528,10832, 4536,14928, 4544,9480, - 4552,7248, 4560,11344, 4568,15440, 4576,9608, 4584,7760, 4592,11856, - 4600,15952, 4608,10240, 4616,10256, 4624,8336, 4632,12432, 4640,10368, - 4648,4752, 4656,8848, 4664,12944, 4672,10496, 4680,5264, 4688,9360, - 4696,13456, 4704,10624, 4712,5776, 4720,9872, 4728,13968, 4736,10248, - 4744,6288, 4752,10384, 4760,14480, 4768,10376, 4776,6800, 4784,10896, - 4792,14992, 4800,10504, 4808,7312, 4816,11408, 4824,15504, 4832,10632, - 4840,7824, 4848,11920, 4856,16016, 4864,11264, 4872,11280, 4880,8400, - 4888,12496, 4896,11392, 4904,11408, 4912,8912, 4920,13008, 4928,11520, - 4936,5328, 4944,9424, 4952,13520, 4960,11648, 4968,5840, 4976,9936, - 4984,14032, 4992,11272, 5000,6352, 5008,10448, 5016,14544, 5024,11400, - 5032,6864, 5040,10960, 5048,15056, 5056,11528, 5064,7376, 5072,11472, - 5080,15568, 5088,11656, 5096,7888, 5104,11984, 5112,16080, 5120,8256, - 5128,8272, 5136,8464, 5144,12560, 5152,8384, 5160,8400, 5168,8976, - 5176,13072, 5184,8512, 5192,5392, 5200,9488, 5208,13584, 5216,8640, - 5224,5904, 5232,10000, 5240,14096, 5248,8264, 5256,6416, 5264,10512, - 5272,14608, 5280,8392, 5288,6928, 5296,11024, 5304,15120, 5312,8520, - 5320,7440, 5328,11536, 5336,15632, 5344,8648, 5352,7952, 5360,12048, - 5368,16144, 5376,9280, 5384,9296, 5392,8528, 5400,12624, 5408,9408, - 5416,9424, 5424,9040, 5432,13136, 5440,9536, 5448,5456, 5456,9552, - 5464,13648, 5472,9664, 5480,5968, 5488,10064, 5496,14160, 5504,9288, - 5512,6480, 5520,10576, 5528,14672, 5536,9416, 5544,6992, 5552,11088, - 5560,15184, 5568,9544, 5576,7504, 5584,11600, 5592,15696, 5600,9672, - 5608,8016, 5616,12112, 5624,16208, 5632,10304, 5640,10320, 5648,8592, - 5656,12688, 5664,10432, 5672,10448, 5680,9104, 5688,13200, 5696,10560, - 5704,10576, 5712,9616, 5720,13712, 5728,10688, 5736,6032, 5744,10128, - 5752,14224, 5760,10312, 5768,6544, 5776,10640, 5784,14736, 5792,10440, - 5800,7056, 5808,11152, 5816,15248, 5824,10568, 5832,7568, 5840,11664, - 5848,15760, 5856,10696, 5864,8080, 5872,12176, 5880,16272, 5888,11328, - 5896,11344, 5904,8656, 5912,12752, 5920,11456, 5928,11472, 5936,9168, - 5944,13264, 5952,11584, 5960,11600, 5968,9680, 5976,13776, 5984,11712, - 5992,6096, 6000,10192, 6008,14288, 6016,11336, 6024,6608, 6032,10704, - 6040,14800, 6048,11464, 6056,7120, 6064,11216, 6072,15312, 6080,11592, - 6088,7632, 6096,11728, 6104,15824, 6112,11720, 6120,8144, 6128,12240, - 6136,16336, 6144,12288, 6152,12304, 6160,8216, 6168,12312, 6176,12416, - 6184,12432, 6192,8728, 6200,12824, 6208,12544, 6216,12560, 6224,9240, - 6232,13336, 6240,12672, 6248,12688, 6256,9752, 6264,13848, 6272,12296, - 6280,12312, 6288,10264, 6296,14360, 6304,12424, 6312,6680, 6320,10776, - 6328,14872, 6336,12552, 6344,7192, 6352,11288, 6360,15384, 6368,12680, - 6376,7704, 6384,11800, 6392,15896, 6400,13312, 6408,13328, 6416,8280, - 6424,12376, 6432,13440, 6440,13456, 6448,8792, 6456,12888, 6464,13568, - 6472,13584, 6480,9304, 6488,13400, 6496,13696, 6504,13712, 6512,9816, - 6520,13912, 6528,13320, 6536,13336, 6544,10328, 6552,14424, 6560,13448, - 6568,6744, 6576,10840, 6584,14936, 6592,13576, 6600,7256, 6608,11352, - 6616,15448, 6624,13704, 6632,7768, 6640,11864, 6648,15960, 6656,14336, - 6664,14352, 6672,8344, 6680,12440, 6688,14464, 6696,14480, 6704,8856, - 6712,12952, 6720,14592, 6728,14608, 6736,9368, 6744,13464, 6752,14720, - 6760,14736, 6768,9880, 6776,13976, 6784,14344, 6792,14360, 6800,10392, - 6808,14488, 6816,14472, 6824,14488, 6832,10904, 6840,15000, 6848,14600, - 6856,7320, 6864,11416, 6872,15512, 6880,14728, 6888,7832, 6896,11928, - 6904,16024, 6912,15360, 6920,15376, 6928,8408, 6936,12504, 6944,15488, - 6952,15504, 6960,8920, 6968,13016, 6976,15616, 6984,15632, 6992,9432, - 7000,13528, 7008,15744, 7016,15760, 7024,9944, 7032,14040, 7040,15368, - 7048,15384, 7056,10456, 7064,14552, 7072,15496, 7080,15512, 7088,10968, - 7096,15064, 7104,15624, 7112,7384, 7120,11480, 7128,15576, 7136,15752, - 7144,7896, 7152,11992, 7160,16088, 7168,12352, 7176,12368, 7184,8472, - 7192,12568, 7200,12480, 7208,12496, 7216,8984, 7224,13080, 7232,12608, - 7240,12624, 7248,9496, 7256,13592, 7264,12736, 7272,12752, 7280,10008, - 7288,14104, 7296,12360, 7304,12376, 7312,10520, 7320,14616, 7328,12488, - 7336,12504, 7344,11032, 7352,15128, 7360,12616, 7368,7448, 7376,11544, - 7384,15640, 7392,12744, 7400,7960, 7408,12056, 7416,16152, 7424,13376, - 7432,13392, 7440,8536, 7448,12632, 7456,13504, 7464,13520, 7472,9048, - 7480,13144, 7488,13632, 7496,13648, 7504,9560, 7512,13656, 7520,13760, - 7528,13776, 7536,10072, 7544,14168, 7552,13384, 7560,13400, 7568,10584, - 7576,14680, 7584,13512, 7592,13528, 7600,11096, 7608,15192, 7616,13640, - 7624,13656, 7632,11608, 7640,15704, 7648,13768, 7656,8024, 7664,12120, - 7672,16216, 7680,14400, 7688,14416, 7696,8600, 7704,12696, 7712,14528, - 7720,14544, 7728,9112, 7736,13208, 7744,14656, 7752,14672, 7760,9624, - 7768,13720, 7776,14784, 7784,14800, 7792,10136, 7800,14232, 7808,14408, - 7816,14424, 7824,10648, 7832,14744, 7840,14536, 7848,14552, 7856,11160, - 7864,15256, 7872,14664, 7880,14680, 7888,11672, 7896,15768, 7904,14792, - 7912,8088, 7920,12184, 7928,16280, 7936,15424, 7944,15440, 7952,8664, - 7960,12760, 7968,15552, 7976,15568, 7984,9176, 7992,13272, 8000,15680, - 8008,15696, 8016,9688, 8024,13784, 8032,15808, 8040,15824, 8048,10200, - 8056,14296, 8064,15432, 8072,15448, 8080,10712, 8088,14808, 8096,15560, - 8104,15576, 8112,11224, 8120,15320, 8128,15688, 8136,15704, 8144,11736, - 8152,15832, 8160,15816, 8168,15832, 8176,12248, 8184,16344, 8200,8320, - 8208,8224, 8216,12320, 8232,10368, 8240,8736, 8248,12832, 8256,8448, - 8264,8384, 8272,9248, 8280,13344, 8288,9232, 8296,10432, 8304,9760, - 8312,13856, 8328,12416, 8336,10272, 8344,14368, 8352,12296, 8360,14464, - 8368,10784, 8376,14880, 8384,8456, 8392,12480, 8400,11296, 8408,15392, - 8416,12552, 8424,14528, 8432,11808, 8440,15904, 8448,9216, 8456,8576, - 8464,9232, 8472,12384, 8480,9248, 8488,10624, 8496,8800, 8504,12896, - 8512,9472, 8520,8640, 8528,9312, 8536,13408, 8544,9296, 8552,10688, - 8560,9824, 8568,13920, 8576,9224, 8584,12672, 8592,10336, 8600,14432, - 8608,13320, 8616,14720, 8624,10848, 8632,14944, 8640,9480, 8648,12736, - 8656,11360, 8664,15456, 8672,13576, 8680,14784, 8688,11872, 8696,15968, - 8704,12288, 8712,12416, 8720,12296, 8728,12448, 8736,12304, 8744,10376, - 8752,8864, 8760,12960, 8768,12352, 8776,12480, 8784,9376, 8792,13472, - 8800,12368, 8808,10440, 8816,9888, 8824,13984, 8832,12320, 8840,12424, - 8848,10400, 8856,14496, 8864,12312, 8872,14472, 8880,10912, 8888,15008, - 8896,12384, 8904,12488, 8912,11424, 8920,15520, 8928,12568, 8936,14536, - 8944,11936, 8952,16032, 8960,12544, 8968,12672, 8976,12552, 8984,12512, - 8992,12560, 9000,10632, 9008,12568, 9016,13024, 9024,12608, 9032,12736, - 9040,9440, 9048,13536, 9056,12624, 9064,10696, 9072,9952, 9080,14048, - 9088,9240, 9096,12680, 9104,10464, 9112,14560, 9120,13336, 9128,14728, - 9136,10976, 9144,15072, 9152,9496, 9160,12744, 9168,11488, 9176,15584, - 9184,13592, 9192,14792, 9200,12000, 9208,16096, 9224,9344, 9232,9248, - 9240,12576, 9256,11392, 9264,12560, 9272,13088, 9280,9472, 9288,9408, - 9296,9504, 9304,13600, 9312,9488, 9320,11456, 9328,10016, 9336,14112, - 9352,13440, 9360,10528, 9368,14624, 9376,12360, 9384,15488, 9392,11040, - 9400,15136, 9408,9480, 9416,13504, 9424,11552, 9432,15648, 9440,12616, - 9448,15552, 9456,12064, 9464,16160, 9480,9600, 9488,9504, 9496,12640, - 9512,11648, 9520,12624, 9528,13152, 9544,9664, 9552,9568, 9560,13664, - 9576,11712, 9584,10080, 9592,14176, 9608,13696, 9616,10592, 9624,14688, - 9632,13384, 9640,15744, 9648,11104, 9656,15200, 9672,13760, 9680,11616, - 9688,15712, 9696,13640, 9704,15808, 9712,12128, 9720,16224, 9728,13312, - 9736,13440, 9744,13320, 9752,12704, 9760,13328, 9768,11400, 9776,13336, - 9784,13216, 9792,13376, 9800,13504, 9808,13384, 9816,13728, 9824,13392, - 9832,11464, 9840,10144, 9848,14240, 9856,13344, 9864,13448, 9872,10656, - 9880,14752, 9888,12376, 9896,15496, 9904,11168, 9912,15264, 9920,13408, - 9928,13512, 9936,11680, 9944,15776, 9952,12632, 9960,15560, 9968,12192, - 9976,16288, 9984,13568, 9992,13696, 10000,13576, 10008,12768, 10016,13584, - 10024,11656, 10032,13592, 10040,13280, 10048,13632, 10056,13760, - 10064,13640, 10072,13792, 10080,13648, 10088,11720, 10096,10208, - 10104,14304, 10112,13600, 10120,13704, 10128,10720, 10136,14816, - 10144,13400, 10152,15752, 10160,11232, 10168,15328, 10176,13664, - 10184,13768, 10192,11744, 10200,15840, 10208,13656, 10216,15816, - 10224,12256, 10232,16352, 10248,10272, 10256,10368, 10264,12328, - 10280,10384, 10288,10376, 10296,12840, 10304,11264, 10312,11296, - 10320,11392, 10328,13352, 10336,11272, 10344,10448, 10352,11400, - 10360,13864, 10376,12432, 10392,14376, 10400,12328, 10408,14480, - 10416,10792, 10424,14888, 10432,11280, 10440,12496, 10448,11304, - 10456,15400, 10464,11288, 10472,14544, 10480,11816, 10488,15912, - 10496,11264, 10504,11272, 10512,11280, 10520,12392, 10528,11296, - 10536,10640, 10544,12496, 10552,12904, 10560,11328, 10568,11360, - 10576,11456, 10584,13416, 10592,11336, 10600,10704, 10608,11464, - 10616,13928, 10624,11392, 10632,12688, 10640,11304, 10648,14440, - 10656,13352, 10664,14736, 10672,10856, 10680,14952, 10688,11344, - 10696,12752, 10704,11368, 10712,15464, 10720,11352, 10728,14800, - 10736,11880, 10744,15976, 10752,14336, 10760,14368, 10768,14464, - 10776,12456, 10784,14344, 10792,14376, 10800,14472, 10808,12968, - 10816,15360, 10824,15392, 10832,15488, 10840,13480, 10848,15368, - 10856,15400, 10864,15496, 10872,13992, 10880,14352, 10888,12440, - 10896,14480, 10904,14504, 10912,14360, 10920,14488, 10928,14488, - 10936,15016, 10944,15376, 10952,12504, 10960,11432, 10968,15528, - 10976,15384, 10984,14552, 10992,11944, 11000,16040, 11008,14400, - 11016,14432, 11024,14528, 11032,12520, 11040,14408, 11048,14440, - 11056,14536, 11064,13032, 11072,15424, 11080,15456, 11088,15552, - 11096,13544, 11104,15432, 11112,15464, 11120,15560, 11128,14056, - 11136,14416, 11144,12696, 11152,14544, 11160,14568, 11168,14424, - 11176,14744, 11184,14552, 11192,15080, 11200,15440, 11208,12760, - 11216,11496, 11224,15592, 11232,15448, 11240,14808, 11248,12008, - 11256,16104, 11272,11296, 11280,11392, 11288,12584, 11304,11408, - 11312,12688, 11320,13096, 11328,11520, 11336,11552, 11344,11648, - 11352,13608, 11360,11528, 11368,11472, 11376,11656, 11384,14120, - 11400,13456, 11416,14632, 11424,12392, 11432,15504, 11440,14440, - 11448,15144, 11456,11536, 11464,13520, 11472,11560, 11480,15656, - 11488,11544, 11496,15568, 11504,12072, 11512,16168, 11528,11552, - 11536,11648, 11544,12648, 11560,11664, 11568,12752, 11576,13160, - 11592,11616, 11600,11712, 11608,13672, 11624,11728, 11632,11720, - 11640,14184, 11656,13712, 11672,14696, 11680,13416, 11688,15760, - 11696,15464, 11704,15208, 11720,13776, 11736,15720, 11744,13672, - 11752,15824, 11760,12136, 11768,16232, 11776,14592, 11784,14624, - 11792,14720, 11800,12712, 11808,14600, 11816,14632, 11824,14728, - 11832,13224, 11840,15616, 11848,15648, 11856,15744, 11864,13736, - 11872,15624, 11880,15656, 11888,15752, 11896,14248, 11904,14608, - 11912,13464, 11920,14736, 11928,14760, 11936,14616, 11944,15512, - 11952,14744, 11960,15272, 11968,15632, 11976,13528, 11984,15760, - 11992,15784, 12000,15640, 12008,15576, 12016,12200, 12024,16296, - 12032,14656, 12040,14688, 12048,14784, 12056,12776, 12064,14664, - 12072,14696, 12080,14792, 12088,13288, 12096,15680, 12104,15712, - 12112,15808, 12120,13800, 12128,15688, 12136,15720, 12144,15816, - 12152,14312, 12160,14672, 12168,13720, 12176,14800, 12184,14824, - 12192,14680, 12200,15768, 12208,14808, 12216,15336, 12224,15696, - 12232,13784, 12240,15824, 12248,15848, 12256,15704, 12264,15832, - 12272,15832, 12280,16360, 12312,12336, 12344,12848, 12352,12544, - 12360,12552, 12368,12560, 12376,13360, 12384,12576, 12392,12584, - 12400,13336, 12408,13872, 12424,12448, 12440,14384, 12456,14496, - 12464,14472, 12472,14896, 12480,12672, 12488,12512, 12496,12688, - 12504,15408, 12512,12680, 12520,14560, 12528,14728, 12536,15920, - 12544,13312, 12552,13320, 12560,13328, 12568,13336, 12576,13344, - 12584,13352, 12592,13360, 12600,12912, 12608,13568, 12616,13576, - 12624,13584, 12632,13424, 12640,13600, 12648,13608, 12656,13400, - 12664,13936, 12672,13440, 12680,12704, 12688,13456, 12696,14448, - 12704,13448, 12712,14752, 12720,15496, 12728,14960, 12736,13696, - 12744,12768, 12752,13712, 12760,15472, 12768,13704, 12776,14816, - 12784,15752, 12792,15984, 12800,14336, 12808,14464, 12816,14344, - 12824,14472, 12832,14352, 12840,14480, 12848,14360, 12856,12976, - 12864,14400, 12872,14528, 12880,14408, 12888,13488, 12896,14416, - 12904,14544, 12912,14424, 12920,14000, 12928,14368, 12936,14496, - 12944,14376, 12952,14512, 12960,14384, 12968,14504, 12976,14488, - 12984,15024, 12992,14432, 13000,14560, 13008,14440, 13016,15536, - 13024,14448, 13032,14568, 13040,14744, 13048,16048, 13056,14592, - 13064,14720, 13072,14600, 13080,14728, 13088,14608, 13096,14736, - 13104,14616, 13112,14744, 13120,14656, 13128,14784, 13136,14664, - 13144,13552, 13152,14672, 13160,14800, 13168,14680, 13176,14064, - 13184,14624, 13192,14752, 13200,14632, 13208,14576, 13216,13464, - 13224,14760, 13232,15512, 13240,15088, 13248,14688, 13256,14816, - 13264,14696, 13272,15600, 13280,13720, 13288,14824, 13296,15768, - 13304,16112, 13336,13360, 13368,14616, 13376,13568, 13384,13576, - 13392,13584, 13400,13616, 13408,13600, 13416,13608, 13424,13592, - 13432,14128, 13448,13472, 13464,14640, 13480,15520, 13488,14536, - 13496,15152, 13504,13696, 13512,13536, 13520,13712, 13528,15664, - 13536,13704, 13544,15584, 13552,14792, 13560,16176, 13592,13616, - 13624,14680, 13656,13680, 13688,14192, 13704,13728, 13720,14704, - 13736,15776, 13744,15560, 13752,15216, 13768,13792, 13784,15728, - 13800,15840, 13808,15816, 13816,16240, 13824,15360, 13832,15488, - 13840,15368, 13848,15496, 13856,15376, 13864,15504, 13872,15384, - 13880,15512, 13888,15424, 13896,15552, 13904,15432, 13912,15560, - 13920,15440, 13928,15568, 13936,15448, 13944,14256, 13952,15392, - 13960,15520, 13968,15400, 13976,14768, 13984,15408, 13992,15528, - 14000,14552, 14008,15280, 14016,15456, 14024,15584, 14032,15464, - 14040,15792, 14048,15472, 14056,15592, 14064,14808, 14072,16304, - 14080,15616, 14088,15744, 14096,15624, 14104,15752, 14112,15632, - 14120,15760, 14128,15640, 14136,15768, 14144,15680, 14152,15808, - 14160,15688, 14168,15816, 14176,15696, 14184,15824, 14192,15704, - 14200,14320, 14208,15648, 14216,15776, 14224,15656, 14232,14832, - 14240,15664, 14248,15784, 14256,15576, 14264,15344, 14272,15712, - 14280,15840, 14288,15720, 14296,15856, 14304,15728, 14312,15848, - 14320,15832, 14328,16368, 14392,14488, 14400,14592, 14408,14600, - 14416,14608, 14424,14616, 14432,14624, 14440,14632, 14448,14640, - 14456,15512, 14504,14512, 14520,14904, 14528,14720, 14536,14728, - 14544,14736, 14552,15416, 14560,14752, 14568,14576, 14584,15928, - 14576,14760, 14592,15360, 14600,15368, 14608,15376, 14616,15384, - 14624,15392, 14632,15400, 14640,15408, 14648,15416, 14656,15616, - 14664,15624, 14672,15632, 14680,15640, 14688,15648, 14696,15656, - 14704,15664, 14712,15576, 14720,15488, 14728,15496, 14736,15504, - 14744,15512, 14752,15520, 14760,14768, 14776,14968, 14768,15528, - 14784,15744, 14792,15752, 14800,15760, 14808,15480, 14816,15776, - 14824,14832, 14840,15992, 14832,15784, 14856,14864, 14864,14880, - 14872,14896, 14880,14976, 14888,14992, 14896,15008, 14904,15024, - 14912,15104, 14920,15120, 14928,15136, 14936,15152, 14944,15232, - 14952,15248, 14960,15264, 14968,15280, 14984,15008, 15000,15024, - 15016,15024, 15040,15112, 15048,15128, 15056,15144, 15064,15544, - 15072,15240, 15080,15256, 15088,15272, 15096,16056, 15104,15872, - 15112,15888, 15120,15904, 15128,15920, 15136,16000, 15144,16016, - 15152,16032, 15160,16048, 15168,16128, 15176,16144, 15184,16160, - 15192,16176, 15200,16256, 15208,16272, 15216,16288, 15224,16304, - 15232,15880, 15240,15896, 15248,15912, 15256,15928, 15264,16008, - 15272,16024, 15280,16040, 15288,16056, 15296,16136, 15304,16152, - 15312,16168, 15320,15608, 15328,16264, 15336,16280, 15344,16296, - 15352,16120, 15416,15512, 15424,15616, 15432,15624, 15440,15632, - 15448,15640, 15456,15648, 15464,15656, 15472,15664, 15480,15768, - 15528,15536, 15544,16048, 15552,15744, 15560,15752, 15568,15760, - 15576,15672, 15584,15776, 15592,15600, 15600,15784, 15608,16184, - 15672,15768, 15736,15832, 15784,15792, 15800,16304, 15848,15856, - 15880,16000, 15864,16248, 15888,16000, 15896,16008, 15904,16000, - 15912,16016, 15920,16008, 15928,16024, 15936,16128, 15944,16160, - 15952,16256, 15960,16288, 15968,16136, 15976,16168, 15984,16264, - 15992,16296, 16008,16032, 16024,16040, 16064,16144, 16040,16048, - 16072,16176, 16080,16272, 16088,16304, 16096,16152, 16104,16184, - 16112,16280, 16136,16256, 16120,16312, 16144,16256, 16152,16264, - 16160,16256, 16168,16272, 16176,16264, 16184,16280, 16200,16208, - 16208,16224, 16216,16240, 16224,16320, 16232,16336, 16240,16352, - 16248,16368, 16264,16288, 16280,16296, 16296,16304, 16344,16368, - 16328,16352, 16360,16368 -}; + { + /* 8x2, size 3808 */ + 8, 4096, 16, 8192, 24, 12288, 32, 512, 40, 4608, + 48, 8704, 56, 12800, 64, 1024, 72, 5120, 80, 9216, + 88, 13312, 96, 1536, 104, 5632, 112, 9728, 120, 13824, + 128, 2048, 136, 6144, 144, 10240, 152, 14336, 160, 2560, + 168, 6656, 176, 10752, 184, 14848, 192, 3072, 200, 7168, + 208, 11264, 216, 15360, 224, 3584, 232, 7680, 240, 11776, + 248, 15872, 256, 1024, 264, 4160, 272, 8256, 280, 12352, + 288, 576, 296, 4672, 304, 8768, 312, 12864, 320, 1088, + 328, 5184, 336, 9280, 344, 13376, 352, 1600, 360, 5696, + 368, 9792, 376, 13888, 384, 2112, 392, 6208, 400, 10304, + 408, 14400, 416, 2624, 424, 6720, 432, 10816, 440, 14912, + 448, 3136, 456, 7232, 464, 11328, 472, 15424, 480, 3648, + 488, 7744, 496, 11840, 504, 15936, 512, 2048, 520, 4224, + 528, 8320, 536, 12416, 544, 640, 552, 4736, 560, 8832, + 568, 12928, 576, 1152, 584, 5248, 592, 9344, 600, 13440, + 608, 1664, 616, 5760, 624, 9856, 632, 13952, 640, 2176, + 648, 6272, 656, 10368, 664, 14464, 672, 2688, 680, 6784, + 688, 10880, 696, 14976, 704, 3200, 712, 7296, 720, 11392, + 728, 15488, 736, 3712, 744, 7808, 752, 11904, 760, 16000, + 768, 3072, 776, 4288, 784, 8384, 792, 12480, 800, 3200, + 808, 4800, 816, 8896, 824, 12992, 832, 1216, 840, 5312, + 848, 9408, 856, 13504, 864, 1728, 872, 5824, 880, 9920, + 888, 14016, 896, 2240, 904, 6336, 912, 10432, 920, 14528, + 928, 2752, 936, 6848, 944, 10944, 952, 15040, 960, 3264, + 968, 7360, 976, 11456, 984, 15552, 992, 3776, 1000, 7872, + 1008, 11968, 1016, 16064, 1032, 4352, 1040, 8448, 1048, 12544, + 1056, 3072, 1064, 4864, 1072, 8960, 1080, 13056, 1088, 1280, + 1096, 5376, 1104, 9472, 1112, 13568, 1120, 1792, 1128, 5888, + 1136, 9984, 1144, 14080, 1152, 2304, 1160, 6400, 1168, 10496, + 1176, 14592, 1184, 2816, 1192, 6912, 1200, 11008, 1208, 15104, + 1216, 3328, 1224, 7424, 1232, 11520, 1240, 15616, 1248, 3840, + 1256, 7936, 1264, 12032, 1272, 16128, 1288, 4416, 1296, 8512, + 1304, 12608, 1312, 3328, 1320, 4928, 1328, 9024, 1336, 13120, + 1352, 5440, 1360, 9536, 1368, 13632, 1376, 1856, 1384, 5952, + 1392, 10048, 1400, 14144, 1408, 2368, 1416, 6464, 1424, 10560, + 1432, 14656, 1440, 2880, 1448, 6976, 1456, 11072, 1464, 15168, + 1472, 3392, 1480, 7488, 1488, 11584, 1496, 15680, 1504, 3904, + 1512, 8000, 1520, 12096, 1528, 16192, 1536, 2112, 1544, 4480, + 1552, 8576, 1560, 12672, 1568, 2240, 1576, 4992, 1584, 9088, + 1592, 13184, 1600, 2368, 1608, 5504, 1616, 9600, 1624, 13696, + 1632, 1920, 1640, 6016, 1648, 10112, 1656, 14208, 1664, 2432, + 1672, 6528, 1680, 10624, 1688, 14720, 1696, 2944, 1704, 7040, + 1712, 11136, 1720, 15232, 1728, 3456, 1736, 7552, 1744, 11648, + 1752, 15744, 1760, 3968, 1768, 8064, 1776, 12160, 1784, 16256, + 1792, 3136, 1800, 4544, 1808, 8640, 1816, 12736, 1824, 3264, + 1832, 5056, 1840, 9152, 1848, 13248, 1856, 3392, 1864, 5568, + 1872, 9664, 1880, 13760, 1888, 1984, 1896, 6080, 1904, 10176, + 1912, 14272, 1920, 2496, 1928, 6592, 1936, 10688, 1944, 14784, + 1952, 3008, 1960, 7104, 1968, 11200, 1976, 15296, 1984, 3520, + 1992, 7616, 2000, 11712, 2008, 15808, 2016, 4032, 2024, 8128, + 2032, 12224, 2040, 16320, 2048, 4096, 2056, 4104, 2064, 8200, + 2072, 12296, 2080, 4224, 2088, 4616, 2096, 8712, 2104, 12808, + 2112, 4352, 2120, 5128, 2128, 9224, 2136, 13320, 2144, 4480, + 2152, 5640, 2160, 9736, 2168, 13832, 2176, 4104, 2184, 6152, + 2192, 10248, 2200, 14344, 2208, 2568, 2216, 6664, 2224, 10760, + 2232, 14856, 2240, 3080, 2248, 7176, 2256, 11272, 2264, 15368, + 2272, 3592, 2280, 7688, 2288, 11784, 2296, 15880, 2304, 5120, + 2312, 4168, 2320, 8264, 2328, 12360, 2336, 5248, 2344, 4680, + 2352, 8776, 2360, 12872, 2368, 5376, 2376, 5192, 2384, 9288, + 2392, 13384, 2400, 5504, 2408, 5704, 2416, 9800, 2424, 13896, + 2432, 5128, 2440, 6216, 2448, 10312, 2456, 14408, 2464, 2632, + 2472, 6728, 2480, 10824, 2488, 14920, 2496, 3144, 2504, 7240, + 2512, 11336, 2520, 15432, 2528, 3656, 2536, 7752, 2544, 11848, + 2552, 15944, 2560, 6144, 2568, 4232, 2576, 8328, 2584, 12424, + 2592, 6272, 2600, 4744, 2608, 8840, 2616, 12936, 2624, 6400, + 2632, 5256, 2640, 9352, 2648, 13448, 2656, 6528, 2664, 5768, + 2672, 9864, 2680, 13960, 2688, 6152, 2696, 6280, 2704, 10376, + 2712, 14472, 2720, 6280, 2728, 6792, 2736, 10888, 2744, 14984, + 2752, 3208, 2760, 7304, 2768, 11400, 2776, 15496, 2784, 3720, + 2792, 7816, 2800, 11912, 2808, 16008, 2816, 7168, 2824, 4296, + 2832, 8392, 2840, 12488, 2848, 7296, 2856, 4808, 2864, 8904, + 2872, 13000, 2880, 7424, 2888, 5320, 2896, 9416, 2904, 13512, + 2912, 7552, 2920, 5832, 2928, 9928, 2936, 14024, 2944, 7176, + 2952, 6344, 2960, 10440, 2968, 14536, 2976, 7304, 2984, 6856, + 2992, 10952, 3000, 15048, 3008, 3272, 3016, 7368, 3024, 11464, + 3032, 15560, 3040, 3784, 3048, 7880, 3056, 11976, 3064, 16072, + 3072, 4160, 3080, 4360, 3088, 8456, 3096, 12552, 3104, 4288, + 3112, 4872, 3120, 8968, 3128, 13064, 3136, 4416, 3144, 5384, + 3152, 9480, 3160, 13576, 3168, 4544, 3176, 5896, 3184, 9992, + 3192, 14088, 3200, 4168, 3208, 6408, 3216, 10504, 3224, 14600, + 3232, 4296, 3240, 6920, 3248, 11016, 3256, 15112, 3264, 3336, + 3272, 7432, 3280, 11528, 3288, 15624, 3296, 3848, 3304, 7944, + 3312, 12040, 3320, 16136, 3328, 5184, 3336, 4424, 3344, 8520, + 3352, 12616, 3360, 5312, 3368, 4936, 3376, 9032, 3384, 13128, + 3392, 5440, 3400, 5448, 3408, 9544, 3416, 13640, 3424, 5568, + 3432, 5960, 3440, 10056, 3448, 14152, 3456, 5192, 3464, 6472, + 3472, 10568, 3480, 14664, 3488, 5320, 3496, 6984, 3504, 11080, + 3512, 15176, 3520, 5448, 3528, 7496, 3536, 11592, 3544, 15688, + 3552, 3912, 3560, 8008, 3568, 12104, 3576, 16200, 3584, 6208, + 3592, 4488, 3600, 8584, 3608, 12680, 3616, 6336, 3624, 5000, + 3632, 9096, 3640, 13192, 3648, 6464, 3656, 5512, 3664, 9608, + 3672, 13704, 3680, 6592, 3688, 6024, 3696, 10120, 3704, 14216, + 3712, 6216, 3720, 6536, 3728, 10632, 3736, 14728, 3744, 6344, + 3752, 7048, 3760, 11144, 3768, 15240, 3776, 6472, 3784, 7560, + 3792, 11656, 3800, 15752, 3808, 3976, 3816, 8072, 3824, 12168, + 3832, 16264, 3840, 7232, 3848, 4552, 3856, 8648, 3864, 12744, + 3872, 7360, 3880, 5064, 3888, 9160, 3896, 13256, 3904, 7488, + 3912, 5576, 3920, 9672, 3928, 13768, 3936, 7616, 3944, 6088, + 3952, 10184, 3960, 14280, 3968, 7240, 3976, 6600, 3984, 10696, + 3992, 14792, 4000, 7368, 4008, 7112, 4016, 11208, 4024, 15304, + 4032, 7496, 4040, 7624, 4048, 11720, 4056, 15816, 4064, 7624, + 4072, 8136, 4080, 12232, 4088, 16328, 4096, 8192, 4104, 4112, + 4112, 8208, 4120, 12304, 4128, 8320, 4136, 4624, 4144, 8720, + 4152, 12816, 4160, 8448, 4168, 5136, 4176, 9232, 4184, 13328, + 4192, 8576, 4200, 5648, 4208, 9744, 4216, 13840, 4224, 8200, + 4232, 6160, 4240, 10256, 4248, 14352, 4256, 8328, 4264, 6672, + 4272, 10768, 4280, 14864, 4288, 8456, 4296, 7184, 4304, 11280, + 4312, 15376, 4320, 8584, 4328, 7696, 4336, 11792, 4344, 15888, + 4352, 9216, 4360, 9232, 4368, 8272, 4376, 12368, 4384, 9344, + 4392, 4688, 4400, 8784, 4408, 12880, 4416, 9472, 4424, 5200, + 4432, 9296, 4440, 13392, 4448, 9600, 4456, 5712, 4464, 9808, + 4472, 13904, 4480, 9224, 4488, 6224, 4496, 10320, 4504, 14416, + 4512, 9352, 4520, 6736, 4528, 10832, 4536, 14928, 4544, 9480, + 4552, 7248, 4560, 11344, 4568, 15440, 4576, 9608, 4584, 7760, + 4592, 11856, 4600, 15952, 4608, 10240, 4616, 10256, 4624, 8336, + 4632, 12432, 4640, 10368, 4648, 4752, 4656, 8848, 4664, 12944, + 4672, 10496, 4680, 5264, 4688, 9360, 4696, 13456, 4704, 10624, + 4712, 5776, 4720, 9872, 4728, 13968, 4736, 10248, 4744, 6288, + 4752, 10384, 4760, 14480, 4768, 10376, 4776, 6800, 4784, 10896, + 4792, 14992, 4800, 10504, 4808, 7312, 4816, 11408, 4824, 15504, + 4832, 10632, 4840, 7824, 4848, 11920, 4856, 16016, 4864, 11264, + 4872, 11280, 4880, 8400, 4888, 12496, 4896, 11392, 4904, 11408, + 4912, 8912, 4920, 13008, 4928, 11520, 4936, 5328, 4944, 9424, + 4952, 13520, 4960, 11648, 4968, 5840, 4976, 9936, 4984, 14032, + 4992, 11272, 5000, 6352, 5008, 10448, 5016, 14544, 5024, 11400, + 5032, 6864, 5040, 10960, 5048, 15056, 5056, 11528, 5064, 7376, + 5072, 11472, 5080, 15568, 5088, 11656, 5096, 7888, 5104, 11984, + 5112, 16080, 5120, 8256, 5128, 8272, 5136, 8464, 5144, 12560, + 5152, 8384, 5160, 8400, 5168, 8976, 5176, 13072, 5184, 8512, + 5192, 5392, 5200, 9488, 5208, 13584, 5216, 8640, 5224, 5904, + 5232, 10000, 5240, 14096, 5248, 8264, 5256, 6416, 5264, 10512, + 5272, 14608, 5280, 8392, 5288, 6928, 5296, 11024, 5304, 15120, + 5312, 8520, 5320, 7440, 5328, 11536, 5336, 15632, 5344, 8648, + 5352, 7952, 5360, 12048, 5368, 16144, 5376, 9280, 5384, 9296, + 5392, 8528, 5400, 12624, 5408, 9408, 5416, 9424, 5424, 9040, + 5432, 13136, 5440, 9536, 5448, 5456, 5456, 9552, 5464, 13648, + 5472, 9664, 5480, 5968, 5488, 10064, 5496, 14160, 5504, 9288, + 5512, 6480, 5520, 10576, 5528, 14672, 5536, 9416, 5544, 6992, + 5552, 11088, 5560, 15184, 5568, 9544, 5576, 7504, 5584, 11600, + 5592, 15696, 5600, 9672, 5608, 8016, 5616, 12112, 5624, 16208, + 5632, 10304, 5640, 10320, 5648, 8592, 5656, 12688, 5664, 10432, + 5672, 10448, 5680, 9104, 5688, 13200, 5696, 10560, 5704, 10576, + 5712, 9616, 5720, 13712, 5728, 10688, 5736, 6032, 5744, 10128, + 5752, 14224, 5760, 10312, 5768, 6544, 5776, 10640, 5784, 14736, + 5792, 10440, 5800, 7056, 5808, 11152, 5816, 15248, 5824, 10568, + 5832, 7568, 5840, 11664, 5848, 15760, 5856, 10696, 5864, 8080, + 5872, 12176, 5880, 16272, 5888, 11328, 5896, 11344, 5904, 8656, + 5912, 12752, 5920, 11456, 5928, 11472, 5936, 9168, 5944, 13264, + 5952, 11584, 5960, 11600, 5968, 9680, 5976, 13776, 5984, 11712, + 5992, 6096, 6000, 10192, 6008, 14288, 6016, 11336, 6024, 6608, + 6032, 10704, 6040, 14800, 6048, 11464, 6056, 7120, 6064, 11216, + 6072, 15312, 6080, 11592, 6088, 7632, 6096, 11728, 6104, 15824, + 6112, 11720, 6120, 8144, 6128, 12240, 6136, 16336, 6144, 12288, + 6152, 12304, 6160, 8216, 6168, 12312, 6176, 12416, 6184, 12432, + 6192, 8728, 6200, 12824, 6208, 12544, 6216, 12560, 6224, 9240, + 6232, 13336, 6240, 12672, 6248, 12688, 6256, 9752, 6264, 13848, + 6272, 12296, 6280, 12312, 6288, 10264, 6296, 14360, 6304, 12424, + 6312, 6680, 6320, 10776, 6328, 14872, 6336, 12552, 6344, 7192, + 6352, 11288, 6360, 15384, 6368, 12680, 6376, 7704, 6384, 11800, + 6392, 15896, 6400, 13312, 6408, 13328, 6416, 8280, 6424, 12376, + 6432, 13440, 6440, 13456, 6448, 8792, 6456, 12888, 6464, 13568, + 6472, 13584, 6480, 9304, 6488, 13400, 6496, 13696, 6504, 13712, + 6512, 9816, 6520, 13912, 6528, 13320, 6536, 13336, 6544, 10328, + 6552, 14424, 6560, 13448, 6568, 6744, 6576, 10840, 6584, 14936, + 6592, 13576, 6600, 7256, 6608, 11352, 6616, 15448, 6624, 13704, + 6632, 7768, 6640, 11864, 6648, 15960, 6656, 14336, 6664, 14352, + 6672, 8344, 6680, 12440, 6688, 14464, 6696, 14480, 6704, 8856, + 6712, 12952, 6720, 14592, 6728, 14608, 6736, 9368, 6744, 13464, + 6752, 14720, 6760, 14736, 6768, 9880, 6776, 13976, 6784, 14344, + 6792, 14360, 6800, 10392, 6808, 14488, 6816, 14472, 6824, 14488, + 6832, 10904, 6840, 15000, 6848, 14600, 6856, 7320, 6864, 11416, + 6872, 15512, 6880, 14728, 6888, 7832, 6896, 11928, 6904, 16024, + 6912, 15360, 6920, 15376, 6928, 8408, 6936, 12504, 6944, 15488, + 6952, 15504, 6960, 8920, 6968, 13016, 6976, 15616, 6984, 15632, + 6992, 9432, 7000, 13528, 7008, 15744, 7016, 15760, 7024, 9944, + 7032, 14040, 7040, 15368, 7048, 15384, 7056, 10456, 7064, 14552, + 7072, 15496, 7080, 15512, 7088, 10968, 7096, 15064, 7104, 15624, + 7112, 7384, 7120, 11480, 7128, 15576, 7136, 15752, 7144, 7896, + 7152, 11992, 7160, 16088, 7168, 12352, 7176, 12368, 7184, 8472, + 7192, 12568, 7200, 12480, 7208, 12496, 7216, 8984, 7224, 13080, + 7232, 12608, 7240, 12624, 7248, 9496, 7256, 13592, 7264, 12736, + 7272, 12752, 7280, 10008, 7288, 14104, 7296, 12360, 7304, 12376, + 7312, 10520, 7320, 14616, 7328, 12488, 7336, 12504, 7344, 11032, + 7352, 15128, 7360, 12616, 7368, 7448, 7376, 11544, 7384, 15640, + 7392, 12744, 7400, 7960, 7408, 12056, 7416, 16152, 7424, 13376, + 7432, 13392, 7440, 8536, 7448, 12632, 7456, 13504, 7464, 13520, + 7472, 9048, 7480, 13144, 7488, 13632, 7496, 13648, 7504, 9560, + 7512, 13656, 7520, 13760, 7528, 13776, 7536, 10072, 7544, 14168, + 7552, 13384, 7560, 13400, 7568, 10584, 7576, 14680, 7584, 13512, + 7592, 13528, 7600, 11096, 7608, 15192, 7616, 13640, 7624, 13656, + 7632, 11608, 7640, 15704, 7648, 13768, 7656, 8024, 7664, 12120, + 7672, 16216, 7680, 14400, 7688, 14416, 7696, 8600, 7704, 12696, + 7712, 14528, 7720, 14544, 7728, 9112, 7736, 13208, 7744, 14656, + 7752, 14672, 7760, 9624, 7768, 13720, 7776, 14784, 7784, 14800, + 7792, 10136, 7800, 14232, 7808, 14408, 7816, 14424, 7824, 10648, + 7832, 14744, 7840, 14536, 7848, 14552, 7856, 11160, 7864, 15256, + 7872, 14664, 7880, 14680, 7888, 11672, 7896, 15768, 7904, 14792, + 7912, 8088, 7920, 12184, 7928, 16280, 7936, 15424, 7944, 15440, + 7952, 8664, 7960, 12760, 7968, 15552, 7976, 15568, 7984, 9176, + 7992, 13272, 8000, 15680, 8008, 15696, 8016, 9688, 8024, 13784, + 8032, 15808, 8040, 15824, 8048, 10200, 8056, 14296, 8064, 15432, + 8072, 15448, 8080, 10712, 8088, 14808, 8096, 15560, 8104, 15576, + 8112, 11224, 8120, 15320, 8128, 15688, 8136, 15704, 8144, 11736, + 8152, 15832, 8160, 15816, 8168, 15832, 8176, 12248, 8184, 16344, + 8200, 8320, 8208, 8224, 8216, 12320, 8232, 10368, 8240, 8736, + 8248, 12832, 8256, 8448, 8264, 8384, 8272, 9248, 8280, 13344, + 8288, 9232, 8296, 10432, 8304, 9760, 8312, 13856, 8328, 12416, + 8336, 10272, 8344, 14368, 8352, 12296, 8360, 14464, 8368, 10784, + 8376, 14880, 8384, 8456, 8392, 12480, 8400, 11296, 8408, 15392, + 8416, 12552, 8424, 14528, 8432, 11808, 8440, 15904, 8448, 9216, + 8456, 8576, 8464, 9232, 8472, 12384, 8480, 9248, 8488, 10624, + 8496, 8800, 8504, 12896, 8512, 9472, 8520, 8640, 8528, 9312, + 8536, 13408, 8544, 9296, 8552, 10688, 8560, 9824, 8568, 13920, + 8576, 9224, 8584, 12672, 8592, 10336, 8600, 14432, 8608, 13320, + 8616, 14720, 8624, 10848, 8632, 14944, 8640, 9480, 8648, 12736, + 8656, 11360, 8664, 15456, 8672, 13576, 8680, 14784, 8688, 11872, + 8696, 15968, 8704, 12288, 8712, 12416, 8720, 12296, 8728, 12448, + 8736, 12304, 8744, 10376, 8752, 8864, 8760, 12960, 8768, 12352, + 8776, 12480, 8784, 9376, 8792, 13472, 8800, 12368, 8808, 10440, + 8816, 9888, 8824, 13984, 8832, 12320, 8840, 12424, 8848, 10400, + 8856, 14496, 8864, 12312, 8872, 14472, 8880, 10912, 8888, 15008, + 8896, 12384, 8904, 12488, 8912, 11424, 8920, 15520, 8928, 12568, + 8936, 14536, 8944, 11936, 8952, 16032, 8960, 12544, 8968, 12672, + 8976, 12552, 8984, 12512, 8992, 12560, 9000, 10632, 9008, 12568, + 9016, 13024, 9024, 12608, 9032, 12736, 9040, 9440, 9048, 13536, + 9056, 12624, 9064, 10696, 9072, 9952, 9080, 14048, 9088, 9240, + 9096, 12680, 9104, 10464, 9112, 14560, 9120, 13336, 9128, 14728, + 9136, 10976, 9144, 15072, 9152, 9496, 9160, 12744, 9168, 11488, + 9176, 15584, 9184, 13592, 9192, 14792, 9200, 12000, 9208, 16096, + 9224, 9344, 9232, 9248, 9240, 12576, 9256, 11392, 9264, 12560, + 9272, 13088, 9280, 9472, 9288, 9408, 9296, 9504, 9304, 13600, + 9312, 9488, 9320, 11456, 9328, 10016, 9336, 14112, 9352, 13440, + 9360, 10528, 9368, 14624, 9376, 12360, 9384, 15488, 9392, 11040, + 9400, 15136, 9408, 9480, 9416, 13504, 9424, 11552, 9432, 15648, + 9440, 12616, 9448, 15552, 9456, 12064, 9464, 16160, 9480, 9600, + 9488, 9504, 9496, 12640, 9512, 11648, 9520, 12624, 9528, 13152, + 9544, 9664, 9552, 9568, 9560, 13664, 9576, 11712, 9584, 10080, + 9592, 14176, 9608, 13696, 9616, 10592, 9624, 14688, 9632, 13384, + 9640, 15744, 9648, 11104, 9656, 15200, 9672, 13760, 9680, 11616, + 9688, 15712, 9696, 13640, 9704, 15808, 9712, 12128, 9720, 16224, + 9728, 13312, 9736, 13440, 9744, 13320, 9752, 12704, 9760, 13328, + 9768, 11400, 9776, 13336, 9784, 13216, 9792, 13376, 9800, 13504, + 9808, 13384, 9816, 13728, 9824, 13392, 9832, 11464, 9840, 10144, + 9848, 14240, 9856, 13344, 9864, 13448, 9872, 10656, 9880, 14752, + 9888, 12376, 9896, 15496, 9904, 11168, 9912, 15264, 9920, 13408, + 9928, 13512, 9936, 11680, 9944, 15776, 9952, 12632, 9960, 15560, + 9968, 12192, 9976, 16288, 9984, 13568, 9992, 13696, 10000, 13576, + 10008, 12768, 10016, 13584, 10024, 11656, 10032, 13592, 10040, 13280, + 10048, 13632, 10056, 13760, 10064, 13640, 10072, 13792, 10080, 13648, + 10088, 11720, 10096, 10208, 10104, 14304, 10112, 13600, 10120, 13704, + 10128, 10720, 10136, 14816, 10144, 13400, 10152, 15752, 10160, 11232, + 10168, 15328, 10176, 13664, 10184, 13768, 10192, 11744, 10200, 15840, + 10208, 13656, 10216, 15816, 10224, 12256, 10232, 16352, 10248, 10272, + 10256, 10368, 10264, 12328, 10280, 10384, 10288, 10376, 10296, 12840, + 10304, 11264, 10312, 11296, 10320, 11392, 10328, 13352, 10336, 11272, + 10344, 10448, 10352, 11400, 10360, 13864, 10376, 12432, 10392, 14376, + 10400, 12328, 10408, 14480, 10416, 10792, 10424, 14888, 10432, 11280, + 10440, 12496, 10448, 11304, 10456, 15400, 10464, 11288, 10472, 14544, + 10480, 11816, 10488, 15912, 10496, 11264, 10504, 11272, 10512, 11280, + 10520, 12392, 10528, 11296, 10536, 10640, 10544, 12496, 10552, 12904, + 10560, 11328, 10568, 11360, 10576, 11456, 10584, 13416, 10592, 11336, + 10600, 10704, 10608, 11464, 10616, 13928, 10624, 11392, 10632, 12688, + 10640, 11304, 10648, 14440, 10656, 13352, 10664, 14736, 10672, 10856, + 10680, 14952, 10688, 11344, 10696, 12752, 10704, 11368, 10712, 15464, + 10720, 11352, 10728, 14800, 10736, 11880, 10744, 15976, 10752, 14336, + 10760, 14368, 10768, 14464, 10776, 12456, 10784, 14344, 10792, 14376, + 10800, 14472, 10808, 12968, 10816, 15360, 10824, 15392, 10832, 15488, + 10840, 13480, 10848, 15368, 10856, 15400, 10864, 15496, 10872, 13992, + 10880, 14352, 10888, 12440, 10896, 14480, 10904, 14504, 10912, 14360, + 10920, 14488, 10928, 14488, 10936, 15016, 10944, 15376, 10952, 12504, + 10960, 11432, 10968, 15528, 10976, 15384, 10984, 14552, 10992, 11944, + 11000, 16040, 11008, 14400, 11016, 14432, 11024, 14528, 11032, 12520, + 11040, 14408, 11048, 14440, 11056, 14536, 11064, 13032, 11072, 15424, + 11080, 15456, 11088, 15552, 11096, 13544, 11104, 15432, 11112, 15464, + 11120, 15560, 11128, 14056, 11136, 14416, 11144, 12696, 11152, 14544, + 11160, 14568, 11168, 14424, 11176, 14744, 11184, 14552, 11192, 15080, + 11200, 15440, 11208, 12760, 11216, 11496, 11224, 15592, 11232, 15448, + 11240, 14808, 11248, 12008, 11256, 16104, 11272, 11296, 11280, 11392, + 11288, 12584, 11304, 11408, 11312, 12688, 11320, 13096, 11328, 11520, + 11336, 11552, 11344, 11648, 11352, 13608, 11360, 11528, 11368, 11472, + 11376, 11656, 11384, 14120, 11400, 13456, 11416, 14632, 11424, 12392, + 11432, 15504, 11440, 14440, 11448, 15144, 11456, 11536, 11464, 13520, + 11472, 11560, 11480, 15656, 11488, 11544, 11496, 15568, 11504, 12072, + 11512, 16168, 11528, 11552, 11536, 11648, 11544, 12648, 11560, 11664, + 11568, 12752, 11576, 13160, 11592, 11616, 11600, 11712, 11608, 13672, + 11624, 11728, 11632, 11720, 11640, 14184, 11656, 13712, 11672, 14696, + 11680, 13416, 11688, 15760, 11696, 15464, 11704, 15208, 11720, 13776, + 11736, 15720, 11744, 13672, 11752, 15824, 11760, 12136, 11768, 16232, + 11776, 14592, 11784, 14624, 11792, 14720, 11800, 12712, 11808, 14600, + 11816, 14632, 11824, 14728, 11832, 13224, 11840, 15616, 11848, 15648, + 11856, 15744, 11864, 13736, 11872, 15624, 11880, 15656, 11888, 15752, + 11896, 14248, 11904, 14608, 11912, 13464, 11920, 14736, 11928, 14760, + 11936, 14616, 11944, 15512, 11952, 14744, 11960, 15272, 11968, 15632, + 11976, 13528, 11984, 15760, 11992, 15784, 12000, 15640, 12008, 15576, + 12016, 12200, 12024, 16296, 12032, 14656, 12040, 14688, 12048, 14784, + 12056, 12776, 12064, 14664, 12072, 14696, 12080, 14792, 12088, 13288, + 12096, 15680, 12104, 15712, 12112, 15808, 12120, 13800, 12128, 15688, + 12136, 15720, 12144, 15816, 12152, 14312, 12160, 14672, 12168, 13720, + 12176, 14800, 12184, 14824, 12192, 14680, 12200, 15768, 12208, 14808, + 12216, 15336, 12224, 15696, 12232, 13784, 12240, 15824, 12248, 15848, + 12256, 15704, 12264, 15832, 12272, 15832, 12280, 16360, 12312, 12336, + 12344, 12848, 12352, 12544, 12360, 12552, 12368, 12560, 12376, 13360, + 12384, 12576, 12392, 12584, 12400, 13336, 12408, 13872, 12424, 12448, + 12440, 14384, 12456, 14496, 12464, 14472, 12472, 14896, 12480, 12672, + 12488, 12512, 12496, 12688, 12504, 15408, 12512, 12680, 12520, 14560, + 12528, 14728, 12536, 15920, 12544, 13312, 12552, 13320, 12560, 13328, + 12568, 13336, 12576, 13344, 12584, 13352, 12592, 13360, 12600, 12912, + 12608, 13568, 12616, 13576, 12624, 13584, 12632, 13424, 12640, 13600, + 12648, 13608, 12656, 13400, 12664, 13936, 12672, 13440, 12680, 12704, + 12688, 13456, 12696, 14448, 12704, 13448, 12712, 14752, 12720, 15496, + 12728, 14960, 12736, 13696, 12744, 12768, 12752, 13712, 12760, 15472, + 12768, 13704, 12776, 14816, 12784, 15752, 12792, 15984, 12800, 14336, + 12808, 14464, 12816, 14344, 12824, 14472, 12832, 14352, 12840, 14480, + 12848, 14360, 12856, 12976, 12864, 14400, 12872, 14528, 12880, 14408, + 12888, 13488, 12896, 14416, 12904, 14544, 12912, 14424, 12920, 14000, + 12928, 14368, 12936, 14496, 12944, 14376, 12952, 14512, 12960, 14384, + 12968, 14504, 12976, 14488, 12984, 15024, 12992, 14432, 13000, 14560, + 13008, 14440, 13016, 15536, 13024, 14448, 13032, 14568, 13040, 14744, + 13048, 16048, 13056, 14592, 13064, 14720, 13072, 14600, 13080, 14728, + 13088, 14608, 13096, 14736, 13104, 14616, 13112, 14744, 13120, 14656, + 13128, 14784, 13136, 14664, 13144, 13552, 13152, 14672, 13160, 14800, + 13168, 14680, 13176, 14064, 13184, 14624, 13192, 14752, 13200, 14632, + 13208, 14576, 13216, 13464, 13224, 14760, 13232, 15512, 13240, 15088, + 13248, 14688, 13256, 14816, 13264, 14696, 13272, 15600, 13280, 13720, + 13288, 14824, 13296, 15768, 13304, 16112, 13336, 13360, 13368, 14616, + 13376, 13568, 13384, 13576, 13392, 13584, 13400, 13616, 13408, 13600, + 13416, 13608, 13424, 13592, 13432, 14128, 13448, 13472, 13464, 14640, + 13480, 15520, 13488, 14536, 13496, 15152, 13504, 13696, 13512, 13536, + 13520, 13712, 13528, 15664, 13536, 13704, 13544, 15584, 13552, 14792, + 13560, 16176, 13592, 13616, 13624, 14680, 13656, 13680, 13688, 14192, + 13704, 13728, 13720, 14704, 13736, 15776, 13744, 15560, 13752, 15216, + 13768, 13792, 13784, 15728, 13800, 15840, 13808, 15816, 13816, 16240, + 13824, 15360, 13832, 15488, 13840, 15368, 13848, 15496, 13856, 15376, + 13864, 15504, 13872, 15384, 13880, 15512, 13888, 15424, 13896, 15552, + 13904, 15432, 13912, 15560, 13920, 15440, 13928, 15568, 13936, 15448, + 13944, 14256, 13952, 15392, 13960, 15520, 13968, 15400, 13976, 14768, + 13984, 15408, 13992, 15528, 14000, 14552, 14008, 15280, 14016, 15456, + 14024, 15584, 14032, 15464, 14040, 15792, 14048, 15472, 14056, 15592, + 14064, 14808, 14072, 16304, 14080, 15616, 14088, 15744, 14096, 15624, + 14104, 15752, 14112, 15632, 14120, 15760, 14128, 15640, 14136, 15768, + 14144, 15680, 14152, 15808, 14160, 15688, 14168, 15816, 14176, 15696, + 14184, 15824, 14192, 15704, 14200, 14320, 14208, 15648, 14216, 15776, + 14224, 15656, 14232, 14832, 14240, 15664, 14248, 15784, 14256, 15576, + 14264, 15344, 14272, 15712, 14280, 15840, 14288, 15720, 14296, 15856, + 14304, 15728, 14312, 15848, 14320, 15832, 14328, 16368, 14392, 14488, + 14400, 14592, 14408, 14600, 14416, 14608, 14424, 14616, 14432, 14624, + 14440, 14632, 14448, 14640, 14456, 15512, 14504, 14512, 14520, 14904, + 14528, 14720, 14536, 14728, 14544, 14736, 14552, 15416, 14560, 14752, + 14568, 14576, 14584, 15928, 14576, 14760, 14592, 15360, 14600, 15368, + 14608, 15376, 14616, 15384, 14624, 15392, 14632, 15400, 14640, 15408, + 14648, 15416, 14656, 15616, 14664, 15624, 14672, 15632, 14680, 15640, + 14688, 15648, 14696, 15656, 14704, 15664, 14712, 15576, 14720, 15488, + 14728, 15496, 14736, 15504, 14744, 15512, 14752, 15520, 14760, 14768, + 14776, 14968, 14768, 15528, 14784, 15744, 14792, 15752, 14800, 15760, + 14808, 15480, 14816, 15776, 14824, 14832, 14840, 15992, 14832, 15784, + 14856, 14864, 14864, 14880, 14872, 14896, 14880, 14976, 14888, 14992, + 14896, 15008, 14904, 15024, 14912, 15104, 14920, 15120, 14928, 15136, + 14936, 15152, 14944, 15232, 14952, 15248, 14960, 15264, 14968, 15280, + 14984, 15008, 15000, 15024, 15016, 15024, 15040, 15112, 15048, 15128, + 15056, 15144, 15064, 15544, 15072, 15240, 15080, 15256, 15088, 15272, + 15096, 16056, 15104, 15872, 15112, 15888, 15120, 15904, 15128, 15920, + 15136, 16000, 15144, 16016, 15152, 16032, 15160, 16048, 15168, 16128, + 15176, 16144, 15184, 16160, 15192, 16176, 15200, 16256, 15208, 16272, + 15216, 16288, 15224, 16304, 15232, 15880, 15240, 15896, 15248, 15912, + 15256, 15928, 15264, 16008, 15272, 16024, 15280, 16040, 15288, 16056, + 15296, 16136, 15304, 16152, 15312, 16168, 15320, 15608, 15328, 16264, + 15336, 16280, 15344, 16296, 15352, 16120, 15416, 15512, 15424, 15616, + 15432, 15624, 15440, 15632, 15448, 15640, 15456, 15648, 15464, 15656, + 15472, 15664, 15480, 15768, 15528, 15536, 15544, 16048, 15552, 15744, + 15560, 15752, 15568, 15760, 15576, 15672, 15584, 15776, 15592, 15600, + 15600, 15784, 15608, 16184, 15672, 15768, 15736, 15832, 15784, 15792, + 15800, 16304, 15848, 15856, 15880, 16000, 15864, 16248, 15888, 16000, + 15896, 16008, 15904, 16000, 15912, 16016, 15920, 16008, 15928, 16024, + 15936, 16128, 15944, 16160, 15952, 16256, 15960, 16288, 15968, 16136, + 15976, 16168, 15984, 16264, 15992, 16296, 16008, 16032, 16024, 16040, + 16064, 16144, 16040, 16048, 16072, 16176, 16080, 16272, 16088, 16304, + 16096, 16152, 16104, 16184, 16112, 16280, 16136, 16256, 16120, 16312, + 16144, 16256, 16152, 16264, 16160, 16256, 16168, 16272, 16176, 16264, + 16184, 16280, 16200, 16208, 16208, 16224, 16216, 16240, 16224, 16320, + 16232, 16336, 16240, 16352, 16248, 16368, 16264, 16288, 16280, 16296, + 16296, 16304, 16344, 16368, 16328, 16352, 16360, 16368}; const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE_4096_TABLE_LENGTH] = -{ - /* radix 8, size 4032 */ - 8,4096, 16,8192, 24,12288, 32,16384, 40,20480, 48,24576, 56,28672, 64,512, - 72,4608, 80,8704, 88,12800, 96,16896, 104,20992, 112,25088, 120,29184, - 128,1024, 136,5120, 144,9216, 152,13312, 160,17408, 168,21504, 176,25600, - 184,29696, 192,1536, 200,5632, 208,9728, 216,13824, 224,17920, 232,22016, - 240,26112, 248,30208, 256,2048, 264,6144, 272,10240, 280,14336, 288,18432, - 296,22528, 304,26624, 312,30720, 320,2560, 328,6656, 336,10752, 344,14848, - 352,18944, 360,23040, 368,27136, 376,31232, 384,3072, 392,7168, 400,11264, - 408,15360, 416,19456, 424,23552, 432,27648, 440,31744, 448,3584, 456,7680, - 464,11776, 472,15872, 480,19968, 488,24064, 496,28160, 504,32256, 520,4160, - 528,8256, 536,12352, 544,16448, 552,20544, 560,24640, 568,28736, 584,4672, - 592,8768, 600,12864, 608,16960, 616,21056, 624,25152, 632,29248, 640,1088, - 648,5184, 656,9280, 664,13376, 672,17472, 680,21568, 688,25664, 696,29760, - 704,1600, 712,5696, 720,9792, 728,13888, 736,17984, 744,22080, 752,26176, - 760,30272, 768,2112, 776,6208, 784,10304, 792,14400, 800,18496, 808,22592, - 816,26688, 824,30784, 832,2624, 840,6720, 848,10816, 856,14912, 864,19008, - 872,23104, 880,27200, 888,31296, 896,3136, 904,7232, 912,11328, 920,15424, - 928,19520, 936,23616, 944,27712, 952,31808, 960,3648, 968,7744, 976,11840, - 984,15936, 992,20032, 1000,24128, 1008,28224, 1016,32320, 1032,4224, - 1040,8320, 1048,12416, 1056,16512, 1064,20608, 1072,24704, 1080,28800, - 1096,4736, 1104,8832, 1112,12928, 1120,17024, 1128,21120, 1136,25216, - 1144,29312, 1160,5248, 1168,9344, 1176,13440, 1184,17536, 1192,21632, - 1200,25728, 1208,29824, 1216,1664, 1224,5760, 1232,9856, 1240,13952, - 1248,18048, 1256,22144, 1264,26240, 1272,30336, 1280,2176, 1288,6272, - 1296,10368, 1304,14464, 1312,18560, 1320,22656, 1328,26752, 1336,30848, - 1344,2688, 1352,6784, 1360,10880, 1368,14976, 1376,19072, 1384,23168, - 1392,27264, 1400,31360, 1408,3200, 1416,7296, 1424,11392, 1432,15488, - 1440,19584, 1448,23680, 1456,27776, 1464,31872, 1472,3712, 1480,7808, - 1488,11904, 1496,16000, 1504,20096, 1512,24192, 1520,28288, 1528,32384, - 1544,4288, 1552,8384, 1560,12480, 1568,16576, 1576,20672, 1584,24768, - 1592,28864, 1608,4800, 1616,8896, 1624,12992, 1632,17088, 1640,21184, - 1648,25280, 1656,29376, 1672,5312, 1680,9408, 1688,13504, 1696,17600, - 1704,21696, 1712,25792, 1720,29888, 1736,5824, 1744,9920, 1752,14016, - 1760,18112, 1768,22208, 1776,26304, 1784,30400, 1792,2240, 1800,6336, - 1808,10432, 1816,14528, 1824,18624, 1832,22720, 1840,26816, 1848,30912, - 1856,2752, 1864,6848, 1872,10944, 1880,15040, 1888,19136, 1896,23232, - 1904,27328, 1912,31424, 1920,3264, 1928,7360, 1936,11456, 1944,15552, - 1952,19648, 1960,23744, 1968,27840, 1976,31936, 1984,3776, 1992,7872, - 2000,11968, 2008,16064, 2016,20160, 2024,24256, 2032,28352, 2040,32448, - 2056,4352, 2064,8448, 2072,12544, 2080,16640, 2088,20736, 2096,24832, - 2104,28928, 2120,4864, 2128,8960, 2136,13056, 2144,17152, 2152,21248, - 2160,25344, 2168,29440, 2184,5376, 2192,9472, 2200,13568, 2208,17664, - 2216,21760, 2224,25856, 2232,29952, 2248,5888, 2256,9984, 2264,14080, - 2272,18176, 2280,22272, 2288,26368, 2296,30464, 2312,6400, 2320,10496, - 2328,14592, 2336,18688, 2344,22784, 2352,26880, 2360,30976, 2368,2816, - 2376,6912, 2384,11008, 2392,15104, 2400,19200, 2408,23296, 2416,27392, - 2424,31488, 2432,3328, 2440,7424, 2448,11520, 2456,15616, 2464,19712, - 2472,23808, 2480,27904, 2488,32000, 2496,3840, 2504,7936, 2512,12032, - 2520,16128, 2528,20224, 2536,24320, 2544,28416, 2552,32512, 2568,4416, - 2576,8512, 2584,12608, 2592,16704, 2600,20800, 2608,24896, 2616,28992, - 2632,4928, 2640,9024, 2648,13120, 2656,17216, 2664,21312, 2672,25408, - 2680,29504, 2696,5440, 2704,9536, 2712,13632, 2720,17728, 2728,21824, - 2736,25920, 2744,30016, 2760,5952, 2768,10048, 2776,14144, 2784,18240, - 2792,22336, 2800,26432, 2808,30528, 2824,6464, 2832,10560, 2840,14656, - 2848,18752, 2856,22848, 2864,26944, 2872,31040, 2888,6976, 2896,11072, - 2904,15168, 2912,19264, 2920,23360, 2928,27456, 2936,31552, 2944,3392, - 2952,7488, 2960,11584, 2968,15680, 2976,19776, 2984,23872, 2992,27968, - 3000,32064, 3008,3904, 3016,8000, 3024,12096, 3032,16192, 3040,20288, - 3048,24384, 3056,28480, 3064,32576, 3080,4480, 3088,8576, 3096,12672, - 3104,16768, 3112,20864, 3120,24960, 3128,29056, 3144,4992, 3152,9088, - 3160,13184, 3168,17280, 3176,21376, 3184,25472, 3192,29568, 3208,5504, - 3216,9600, 3224,13696, 3232,17792, 3240,21888, 3248,25984, 3256,30080, - 3272,6016, 3280,10112, 3288,14208, 3296,18304, 3304,22400, 3312,26496, - 3320,30592, 3336,6528, 3344,10624, 3352,14720, 3360,18816, 3368,22912, - 3376,27008, 3384,31104, 3400,7040, 3408,11136, 3416,15232, 3424,19328, - 3432,23424, 3440,27520, 3448,31616, 3464,7552, 3472,11648, 3480,15744, - 3488,19840, 3496,23936, 3504,28032, 3512,32128, 3520,3968, 3528,8064, - 3536,12160, 3544,16256, 3552,20352, 3560,24448, 3568,28544, 3576,32640, - 3592,4544, 3600,8640, 3608,12736, 3616,16832, 3624,20928, 3632,25024, - 3640,29120, 3656,5056, 3664,9152, 3672,13248, 3680,17344, 3688,21440, - 3696,25536, 3704,29632, 3720,5568, 3728,9664, 3736,13760, 3744,17856, - 3752,21952, 3760,26048, 3768,30144, 3784,6080, 3792,10176, 3800,14272, - 3808,18368, 3816,22464, 3824,26560, 3832,30656, 3848,6592, 3856,10688, - 3864,14784, 3872,18880, 3880,22976, 3888,27072, 3896,31168, 3912,7104, - 3920,11200, 3928,15296, 3936,19392, 3944,23488, 3952,27584, 3960,31680, - 3976,7616, 3984,11712, 3992,15808, 4000,19904, 4008,24000, 4016,28096, - 4024,32192, 4040,8128, 4048,12224, 4056,16320, 4064,20416, 4072,24512, - 4080,28608, 4088,32704, 4112,8200, 4120,12296, 4128,16392, 4136,20488, - 4144,24584, 4152,28680, 4168,4616, 4176,8712, 4184,12808, 4192,16904, - 4200,21000, 4208,25096, 4216,29192, 4232,5128, 4240,9224, 4248,13320, - 4256,17416, 4264,21512, 4272,25608, 4280,29704, 4296,5640, 4304,9736, - 4312,13832, 4320,17928, 4328,22024, 4336,26120, 4344,30216, 4360,6152, - 4368,10248, 4376,14344, 4384,18440, 4392,22536, 4400,26632, 4408,30728, - 4424,6664, 4432,10760, 4440,14856, 4448,18952, 4456,23048, 4464,27144, - 4472,31240, 4488,7176, 4496,11272, 4504,15368, 4512,19464, 4520,23560, - 4528,27656, 4536,31752, 4552,7688, 4560,11784, 4568,15880, 4576,19976, - 4584,24072, 4592,28168, 4600,32264, 4624,8264, 4632,12360, 4640,16456, - 4648,20552, 4656,24648, 4664,28744, 4688,8776, 4696,12872, 4704,16968, - 4712,21064, 4720,25160, 4728,29256, 4744,5192, 4752,9288, 4760,13384, - 4768,17480, 4776,21576, 4784,25672, 4792,29768, 4808,5704, 4816,9800, - 4824,13896, 4832,17992, 4840,22088, 4848,26184, 4856,30280, 4872,6216, - 4880,10312, 4888,14408, 4896,18504, 4904,22600, 4912,26696, 4920,30792, - 4936,6728, 4944,10824, 4952,14920, 4960,19016, 4968,23112, 4976,27208, - 4984,31304, 5000,7240, 5008,11336, 5016,15432, 5024,19528, 5032,23624, - 5040,27720, 5048,31816, 5064,7752, 5072,11848, 5080,15944, 5088,20040, - 5096,24136, 5104,28232, 5112,32328, 5136,8328, 5144,12424, 5152,16520, - 5160,20616, 5168,24712, 5176,28808, 5200,8840, 5208,12936, 5216,17032, - 5224,21128, 5232,25224, 5240,29320, 5264,9352, 5272,13448, 5280,17544, - 5288,21640, 5296,25736, 5304,29832, 5320,5768, 5328,9864, 5336,13960, - 5344,18056, 5352,22152, 5360,26248, 5368,30344, 5384,6280, 5392,10376, - 5400,14472, 5408,18568, 5416,22664, 5424,26760, 5432,30856, 5448,6792, - 5456,10888, 5464,14984, 5472,19080, 5480,23176, 5488,27272, 5496,31368, - 5512,7304, 5520,11400, 5528,15496, 5536,19592, 5544,23688, 5552,27784, - 5560,31880, 5576,7816, 5584,11912, 5592,16008, 5600,20104, 5608,24200, - 5616,28296, 5624,32392, 5648,8392, 5656,12488, 5664,16584, 5672,20680, - 5680,24776, 5688,28872, 5712,8904, 5720,13000, 5728,17096, 5736,21192, - 5744,25288, 5752,29384, 5776,9416, 5784,13512, 5792,17608, 5800,21704, - 5808,25800, 5816,29896, 5840,9928, 5848,14024, 5856,18120, 5864,22216, - 5872,26312, 5880,30408, 5896,6344, 5904,10440, 5912,14536, 5920,18632, - 5928,22728, 5936,26824, 5944,30920, 5960,6856, 5968,10952, 5976,15048, - 5984,19144, 5992,23240, 6000,27336, 6008,31432, 6024,7368, 6032,11464, - 6040,15560, 6048,19656, 6056,23752, 6064,27848, 6072,31944, 6088,7880, - 6096,11976, 6104,16072, 6112,20168, 6120,24264, 6128,28360, 6136,32456, - 6160,8456, 6168,12552, 6176,16648, 6184,20744, 6192,24840, 6200,28936, - 6224,8968, 6232,13064, 6240,17160, 6248,21256, 6256,25352, 6264,29448, - 6288,9480, 6296,13576, 6304,17672, 6312,21768, 6320,25864, 6328,29960, - 6352,9992, 6360,14088, 6368,18184, 6376,22280, 6384,26376, 6392,30472, - 6416,10504, 6424,14600, 6432,18696, 6440,22792, 6448,26888, 6456,30984, - 6472,6920, 6480,11016, 6488,15112, 6496,19208, 6504,23304, 6512,27400, - 6520,31496, 6536,7432, 6544,11528, 6552,15624, 6560,19720, 6568,23816, - 6576,27912, 6584,32008, 6600,7944, 6608,12040, 6616,16136, 6624,20232, - 6632,24328, 6640,28424, 6648,32520, 6672,8520, 6680,12616, 6688,16712, - 6696,20808, 6704,24904, 6712,29000, 6736,9032, 6744,13128, 6752,17224, - 6760,21320, 6768,25416, 6776,29512, 6800,9544, 6808,13640, 6816,17736, - 6824,21832, 6832,25928, 6840,30024, 6864,10056, 6872,14152, 6880,18248, - 6888,22344, 6896,26440, 6904,30536, 6928,10568, 6936,14664, 6944,18760, - 6952,22856, 6960,26952, 6968,31048, 6992,11080, 7000,15176, 7008,19272, - 7016,23368, 7024,27464, 7032,31560, 7048,7496, 7056,11592, 7064,15688, - 7072,19784, 7080,23880, 7088,27976, 7096,32072, 7112,8008, 7120,12104, - 7128,16200, 7136,20296, 7144,24392, 7152,28488, 7160,32584, 7184,8584, - 7192,12680, 7200,16776, 7208,20872, 7216,24968, 7224,29064, 7248,9096, - 7256,13192, 7264,17288, 7272,21384, 7280,25480, 7288,29576, 7312,9608, - 7320,13704, 7328,17800, 7336,21896, 7344,25992, 7352,30088, 7376,10120, - 7384,14216, 7392,18312, 7400,22408, 7408,26504, 7416,30600, 7440,10632, - 7448,14728, 7456,18824, 7464,22920, 7472,27016, 7480,31112, 7504,11144, - 7512,15240, 7520,19336, 7528,23432, 7536,27528, 7544,31624, 7568,11656, - 7576,15752, 7584,19848, 7592,23944, 7600,28040, 7608,32136, 7624,8072, - 7632,12168, 7640,16264, 7648,20360, 7656,24456, 7664,28552, 7672,32648, - 7696,8648, 7704,12744, 7712,16840, 7720,20936, 7728,25032, 7736,29128, - 7760,9160, 7768,13256, 7776,17352, 7784,21448, 7792,25544, 7800,29640, - 7824,9672, 7832,13768, 7840,17864, 7848,21960, 7856,26056, 7864,30152, - 7888,10184, 7896,14280, 7904,18376, 7912,22472, 7920,26568, 7928,30664, - 7952,10696, 7960,14792, 7968,18888, 7976,22984, 7984,27080, 7992,31176, - 8016,11208, 8024,15304, 8032,19400, 8040,23496, 8048,27592, 8056,31688, - 8080,11720, 8088,15816, 8096,19912, 8104,24008, 8112,28104, 8120,32200, - 8144,12232, 8152,16328, 8160,20424, 8168,24520, 8176,28616, 8184,32712, - 8216,12304, 8224,16400, 8232,20496, 8240,24592, 8248,28688, 8272,8720, - 8280,12816, 8288,16912, 8296,21008, 8304,25104, 8312,29200, 8336,9232, - 8344,13328, 8352,17424, 8360,21520, 8368,25616, 8376,29712, 8400,9744, - 8408,13840, 8416,17936, 8424,22032, 8432,26128, 8440,30224, 8464,10256, - 8472,14352, 8480,18448, 8488,22544, 8496,26640, 8504,30736, 8528,10768, - 8536,14864, 8544,18960, 8552,23056, 8560,27152, 8568,31248, 8592,11280, - 8600,15376, 8608,19472, 8616,23568, 8624,27664, 8632,31760, 8656,11792, - 8664,15888, 8672,19984, 8680,24080, 8688,28176, 8696,32272, 8728,12368, - 8736,16464, 8744,20560, 8752,24656, 8760,28752, 8792,12880, 8800,16976, - 8808,21072, 8816,25168, 8824,29264, 8848,9296, 8856,13392, 8864,17488, - 8872,21584, 8880,25680, 8888,29776, 8912,9808, 8920,13904, 8928,18000, - 8936,22096, 8944,26192, 8952,30288, 8976,10320, 8984,14416, 8992,18512, - 9000,22608, 9008,26704, 9016,30800, 9040,10832, 9048,14928, 9056,19024, - 9064,23120, 9072,27216, 9080,31312, 9104,11344, 9112,15440, 9120,19536, - 9128,23632, 9136,27728, 9144,31824, 9168,11856, 9176,15952, 9184,20048, - 9192,24144, 9200,28240, 9208,32336, 9240,12432, 9248,16528, 9256,20624, - 9264,24720, 9272,28816, 9304,12944, 9312,17040, 9320,21136, 9328,25232, - 9336,29328, 9368,13456, 9376,17552, 9384,21648, 9392,25744, 9400,29840, - 9424,9872, 9432,13968, 9440,18064, 9448,22160, 9456,26256, 9464,30352, - 9488,10384, 9496,14480, 9504,18576, 9512,22672, 9520,26768, 9528,30864, - 9552,10896, 9560,14992, 9568,19088, 9576,23184, 9584,27280, 9592,31376, - 9616,11408, 9624,15504, 9632,19600, 9640,23696, 9648,27792, 9656,31888, - 9680,11920, 9688,16016, 9696,20112, 9704,24208, 9712,28304, 9720,32400, - 9752,12496, 9760,16592, 9768,20688, 9776,24784, 9784,28880, 9816,13008, - 9824,17104, 9832,21200, 9840,25296, 9848,29392, 9880,13520, 9888,17616, - 9896,21712, 9904,25808, 9912,29904, 9944,14032, 9952,18128, 9960,22224, - 9968,26320, 9976,30416, 10000,10448, 10008,14544, 10016,18640, 10024,22736, - 10032,26832, 10040,30928, 10064,10960, 10072,15056, 10080,19152, - 10088,23248, 10096,27344, 10104,31440, 10128,11472, 10136,15568, - 10144,19664, 10152,23760, 10160,27856, 10168,31952, 10192,11984, - 10200,16080, 10208,20176, 10216,24272, 10224,28368, 10232,32464, - 10264,12560, 10272,16656, 10280,20752, 10288,24848, 10296,28944, - 10328,13072, 10336,17168, 10344,21264, 10352,25360, 10360,29456, - 10392,13584, 10400,17680, 10408,21776, 10416,25872, 10424,29968, - 10456,14096, 10464,18192, 10472,22288, 10480,26384, 10488,30480, - 10520,14608, 10528,18704, 10536,22800, 10544,26896, 10552,30992, - 10576,11024, 10584,15120, 10592,19216, 10600,23312, 10608,27408, - 10616,31504, 10640,11536, 10648,15632, 10656,19728, 10664,23824, - 10672,27920, 10680,32016, 10704,12048, 10712,16144, 10720,20240, - 10728,24336, 10736,28432, 10744,32528, 10776,12624, 10784,16720, - 10792,20816, 10800,24912, 10808,29008, 10840,13136, 10848,17232, - 10856,21328, 10864,25424, 10872,29520, 10904,13648, 10912,17744, - 10920,21840, 10928,25936, 10936,30032, 10968,14160, 10976,18256, - 10984,22352, 10992,26448, 11000,30544, 11032,14672, 11040,18768, - 11048,22864, 11056,26960, 11064,31056, 11096,15184, 11104,19280, - 11112,23376, 11120,27472, 11128,31568, 11152,11600, 11160,15696, - 11168,19792, 11176,23888, 11184,27984, 11192,32080, 11216,12112, - 11224,16208, 11232,20304, 11240,24400, 11248,28496, 11256,32592, - 11288,12688, 11296,16784, 11304,20880, 11312,24976, 11320,29072, - 11352,13200, 11360,17296, 11368,21392, 11376,25488, 11384,29584, - 11416,13712, 11424,17808, 11432,21904, 11440,26000, 11448,30096, - 11480,14224, 11488,18320, 11496,22416, 11504,26512, 11512,30608, - 11544,14736, 11552,18832, 11560,22928, 11568,27024, 11576,31120, - 11608,15248, 11616,19344, 11624,23440, 11632,27536, 11640,31632, - 11672,15760, 11680,19856, 11688,23952, 11696,28048, 11704,32144, - 11728,12176, 11736,16272, 11744,20368, 11752,24464, 11760,28560, - 11768,32656, 11800,12752, 11808,16848, 11816,20944, 11824,25040, - 11832,29136, 11864,13264, 11872,17360, 11880,21456, 11888,25552, - 11896,29648, 11928,13776, 11936,17872, 11944,21968, 11952,26064, - 11960,30160, 11992,14288, 12000,18384, 12008,22480, 12016,26576, - 12024,30672, 12056,14800, 12064,18896, 12072,22992, 12080,27088, - 12088,31184, 12120,15312, 12128,19408, 12136,23504, 12144,27600, - 12152,31696, 12184,15824, 12192,19920, 12200,24016, 12208,28112, - 12216,32208, 12248,16336, 12256,20432, 12264,24528, 12272,28624, - 12280,32720, 12320,16408, 12328,20504, 12336,24600, 12344,28696, - 12376,12824, 12384,16920, 12392,21016, 12400,25112, 12408,29208, - 12440,13336, 12448,17432, 12456,21528, 12464,25624, 12472,29720, - 12504,13848, 12512,17944, 12520,22040, 12528,26136, 12536,30232, - 12568,14360, 12576,18456, 12584,22552, 12592,26648, 12600,30744, - 12632,14872, 12640,18968, 12648,23064, 12656,27160, 12664,31256, - 12696,15384, 12704,19480, 12712,23576, 12720,27672, 12728,31768, - 12760,15896, 12768,19992, 12776,24088, 12784,28184, 12792,32280, - 12832,16472, 12840,20568, 12848,24664, 12856,28760, 12896,16984, - 12904,21080, 12912,25176, 12920,29272, 12952,13400, 12960,17496, - 12968,21592, 12976,25688, 12984,29784, 13016,13912, 13024,18008, - 13032,22104, 13040,26200, 13048,30296, 13080,14424, 13088,18520, - 13096,22616, 13104,26712, 13112,30808, 13144,14936, 13152,19032, - 13160,23128, 13168,27224, 13176,31320, 13208,15448, 13216,19544, - 13224,23640, 13232,27736, 13240,31832, 13272,15960, 13280,20056, - 13288,24152, 13296,28248, 13304,32344, 13344,16536, 13352,20632, - 13360,24728, 13368,28824, 13408,17048, 13416,21144, 13424,25240, - 13432,29336, 13472,17560, 13480,21656, 13488,25752, 13496,29848, - 13528,13976, 13536,18072, 13544,22168, 13552,26264, 13560,30360, - 13592,14488, 13600,18584, 13608,22680, 13616,26776, 13624,30872, - 13656,15000, 13664,19096, 13672,23192, 13680,27288, 13688,31384, - 13720,15512, 13728,19608, 13736,23704, 13744,27800, 13752,31896, - 13784,16024, 13792,20120, 13800,24216, 13808,28312, 13816,32408, - 13856,16600, 13864,20696, 13872,24792, 13880,28888, 13920,17112, - 13928,21208, 13936,25304, 13944,29400, 13984,17624, 13992,21720, - 14000,25816, 14008,29912, 14048,18136, 14056,22232, 14064,26328, - 14072,30424, 14104,14552, 14112,18648, 14120,22744, 14128,26840, - 14136,30936, 14168,15064, 14176,19160, 14184,23256, 14192,27352, - 14200,31448, 14232,15576, 14240,19672, 14248,23768, 14256,27864, - 14264,31960, 14296,16088, 14304,20184, 14312,24280, 14320,28376, - 14328,32472, 14368,16664, 14376,20760, 14384,24856, 14392,28952, - 14432,17176, 14440,21272, 14448,25368, 14456,29464, 14496,17688, - 14504,21784, 14512,25880, 14520,29976, 14560,18200, 14568,22296, - 14576,26392, 14584,30488, 14624,18712, 14632,22808, 14640,26904, - 14648,31000, 14680,15128, 14688,19224, 14696,23320, 14704,27416, - 14712,31512, 14744,15640, 14752,19736, 14760,23832, 14768,27928, - 14776,32024, 14808,16152, 14816,20248, 14824,24344, 14832,28440, - 14840,32536, 14880,16728, 14888,20824, 14896,24920, 14904,29016, - 14944,17240, 14952,21336, 14960,25432, 14968,29528, 15008,17752, - 15016,21848, 15024,25944, 15032,30040, 15072,18264, 15080,22360, - 15088,26456, 15096,30552, 15136,18776, 15144,22872, 15152,26968, - 15160,31064, 15200,19288, 15208,23384, 15216,27480, 15224,31576, - 15256,15704, 15264,19800, 15272,23896, 15280,27992, 15288,32088, - 15320,16216, 15328,20312, 15336,24408, 15344,28504, 15352,32600, - 15392,16792, 15400,20888, 15408,24984, 15416,29080, 15456,17304, - 15464,21400, 15472,25496, 15480,29592, 15520,17816, 15528,21912, - 15536,26008, 15544,30104, 15584,18328, 15592,22424, 15600,26520, - 15608,30616, 15648,18840, 15656,22936, 15664,27032, 15672,31128, - 15712,19352, 15720,23448, 15728,27544, 15736,31640, 15776,19864, - 15784,23960, 15792,28056, 15800,32152, 15832,16280, 15840,20376, - 15848,24472, 15856,28568, 15864,32664, 15904,16856, 15912,20952, - 15920,25048, 15928,29144, 15968,17368, 15976,21464, 15984,25560, - 15992,29656, 16032,17880, 16040,21976, 16048,26072, 16056,30168, - 16096,18392, 16104,22488, 16112,26584, 16120,30680, 16160,18904, - 16168,23000, 16176,27096, 16184,31192, 16224,19416, 16232,23512, - 16240,27608, 16248,31704, 16288,19928, 16296,24024, 16304,28120, - 16312,32216, 16352,20440, 16360,24536, 16368,28632, 16376,32728, - 16424,20512, 16432,24608, 16440,28704, 16480,16928, 16488,21024, - 16496,25120, 16504,29216, 16544,17440, 16552,21536, 16560,25632, - 16568,29728, 16608,17952, 16616,22048, 16624,26144, 16632,30240, - 16672,18464, 16680,22560, 16688,26656, 16696,30752, 16736,18976, - 16744,23072, 16752,27168, 16760,31264, 16800,19488, 16808,23584, - 16816,27680, 16824,31776, 16864,20000, 16872,24096, 16880,28192, - 16888,32288, 16936,20576, 16944,24672, 16952,28768, 17000,21088, - 17008,25184, 17016,29280, 17056,17504, 17064,21600, 17072,25696, - 17080,29792, 17120,18016, 17128,22112, 17136,26208, 17144,30304, - 17184,18528, 17192,22624, 17200,26720, 17208,30816, 17248,19040, - 17256,23136, 17264,27232, 17272,31328, 17312,19552, 17320,23648, - 17328,27744, 17336,31840, 17376,20064, 17384,24160, 17392,28256, - 17400,32352, 17448,20640, 17456,24736, 17464,28832, 17512,21152, - 17520,25248, 17528,29344, 17576,21664, 17584,25760, 17592,29856, - 17632,18080, 17640,22176, 17648,26272, 17656,30368, 17696,18592, - 17704,22688, 17712,26784, 17720,30880, 17760,19104, 17768,23200, - 17776,27296, 17784,31392, 17824,19616, 17832,23712, 17840,27808, - 17848,31904, 17888,20128, 17896,24224, 17904,28320, 17912,32416, - 17960,20704, 17968,24800, 17976,28896, 18024,21216, 18032,25312, - 18040,29408, 18088,21728, 18096,25824, 18104,29920, 18152,22240, - 18160,26336, 18168,30432, 18208,18656, 18216,22752, 18224,26848, - 18232,30944, 18272,19168, 18280,23264, 18288,27360, 18296,31456, - 18336,19680, 18344,23776, 18352,27872, 18360,31968, 18400,20192, - 18408,24288, 18416,28384, 18424,32480, 18472,20768, 18480,24864, - 18488,28960, 18536,21280, 18544,25376, 18552,29472, 18600,21792, - 18608,25888, 18616,29984, 18664,22304, 18672,26400, 18680,30496, - 18728,22816, 18736,26912, 18744,31008, 18784,19232, 18792,23328, - 18800,27424, 18808,31520, 18848,19744, 18856,23840, 18864,27936, - 18872,32032, 18912,20256, 18920,24352, 18928,28448, 18936,32544, - 18984,20832, 18992,24928, 19000,29024, 19048,21344, 19056,25440, - 19064,29536, 19112,21856, 19120,25952, 19128,30048, 19176,22368, - 19184,26464, 19192,30560, 19240,22880, 19248,26976, 19256,31072, - 19304,23392, 19312,27488, 19320,31584, 19360,19808, 19368,23904, - 19376,28000, 19384,32096, 19424,20320, 19432,24416, 19440,28512, - 19448,32608, 19496,20896, 19504,24992, 19512,29088, 19560,21408, - 19568,25504, 19576,29600, 19624,21920, 19632,26016, 19640,30112, - 19688,22432, 19696,26528, 19704,30624, 19752,22944, 19760,27040, - 19768,31136, 19816,23456, 19824,27552, 19832,31648, 19880,23968, - 19888,28064, 19896,32160, 19936,20384, 19944,24480, 19952,28576, - 19960,32672, 20008,20960, 20016,25056, 20024,29152, 20072,21472, - 20080,25568, 20088,29664, 20136,21984, 20144,26080, 20152,30176, - 20200,22496, 20208,26592, 20216,30688, 20264,23008, 20272,27104, - 20280,31200, 20328,23520, 20336,27616, 20344,31712, 20392,24032, - 20400,28128, 20408,32224, 20456,24544, 20464,28640, 20472,32736, - 20528,24616, 20536,28712, 20584,21032, 20592,25128, 20600,29224, - 20648,21544, 20656,25640, 20664,29736, 20712,22056, 20720,26152, - 20728,30248, 20776,22568, 20784,26664, 20792,30760, 20840,23080, - 20848,27176, 20856,31272, 20904,23592, 20912,27688, 20920,31784, - 20968,24104, 20976,28200, 20984,32296, 21040,24680, 21048,28776, - 21104,25192, 21112,29288, 21160,21608, 21168,25704, 21176,29800, - 21224,22120, 21232,26216, 21240,30312, 21288,22632, 21296,26728, - 21304,30824, 21352,23144, 21360,27240, 21368,31336, 21416,23656, - 21424,27752, 21432,31848, 21480,24168, 21488,28264, 21496,32360, - 21552,24744, 21560,28840, 21616,25256, 21624,29352, 21680,25768, - 21688,29864, 21736,22184, 21744,26280, 21752,30376, 21800,22696, - 21808,26792, 21816,30888, 21864,23208, 21872,27304, 21880,31400, - 21928,23720, 21936,27816, 21944,31912, 21992,24232, 22000,28328, - 22008,32424, 22064,24808, 22072,28904, 22128,25320, 22136,29416, - 22192,25832, 22200,29928, 22256,26344, 22264,30440, 22312,22760, - 22320,26856, 22328,30952, 22376,23272, 22384,27368, 22392,31464, - 22440,23784, 22448,27880, 22456,31976, 22504,24296, 22512,28392, - 22520,32488, 22576,24872, 22584,28968, 22640,25384, 22648,29480, - 22704,25896, 22712,29992, 22768,26408, 22776,30504, 22832,26920, - 22840,31016, 22888,23336, 22896,27432, 22904,31528, 22952,23848, - 22960,27944, 22968,32040, 23016,24360, 23024,28456, 23032,32552, - 23088,24936, 23096,29032, 23152,25448, 23160,29544, 23216,25960, - 23224,30056, 23280,26472, 23288,30568, 23344,26984, 23352,31080, - 23408,27496, 23416,31592, 23464,23912, 23472,28008, 23480,32104, - 23528,24424, 23536,28520, 23544,32616, 23600,25000, 23608,29096, - 23664,25512, 23672,29608, 23728,26024, 23736,30120, 23792,26536, - 23800,30632, 23856,27048, 23864,31144, 23920,27560, 23928,31656, - 23984,28072, 23992,32168, 24040,24488, 24048,28584, 24056,32680, - 24112,25064, 24120,29160, 24176,25576, 24184,29672, 24240,26088, - 24248,30184, 24304,26600, 24312,30696, 24368,27112, 24376,31208, - 24432,27624, 24440,31720, 24496,28136, 24504,32232, 24560,28648, - 24568,32744, 24632,28720, 24688,25136, 24696,29232, 24752,25648, - 24760,29744, 24816,26160, 24824,30256, 24880,26672, 24888,30768, - 24944,27184, 24952,31280, 25008,27696, 25016,31792, 25072,28208, - 25080,32304, 25144,28784, 25208,29296, 25264,25712, 25272,29808, - 25328,26224, 25336,30320, 25392,26736, 25400,30832, 25456,27248, - 25464,31344, 25520,27760, 25528,31856, 25584,28272, 25592,32368, - 25656,28848, 25720,29360, 25784,29872, 25840,26288, 25848,30384, - 25904,26800, 25912,30896, 25968,27312, 25976,31408, 26032,27824, - 26040,31920, 26096,28336, 26104,32432, 26168,28912, 26232,29424, - 26296,29936, 26360,30448, 26416,26864, 26424,30960, 26480,27376, - 26488,31472, 26544,27888, 26552,31984, 26608,28400, 26616,32496, - 26680,28976, 26744,29488, 26808,30000, 26872,30512, 26936,31024, - 26992,27440, 27000,31536, 27056,27952, 27064,32048, 27120,28464, - 27128,32560, 27192,29040, 27256,29552, 27320,30064, 27384,30576, - 27448,31088, 27512,31600, 27568,28016, 27576,32112, 27632,28528, - 27640,32624, 27704,29104, 27768,29616, 27832,30128, 27896,30640, - 27960,31152, 28024,31664, 28088,32176, 28144,28592, 28152,32688, - 28216,29168, 28280,29680, 28344,30192, 28408,30704, 28472,31216, - 28536,31728, 28600,32240, 28664,32752, 28792,29240, 28856,29752, - 28920,30264, 28984,30776, 29048,31288, 29112,31800, 29176,32312, - 29368,29816, 29432,30328, 29496,30840, 29560,31352, 29624,31864, - 29688,32376, 29944,30392, 30008,30904, 30072,31416, 30136,31928, - 30200,32440, 30520,30968, 30584,31480, 30648,31992, 30712,32504, - 31096,31544, 31160,32056, 31224,32568, 31672,32120, 31736,32632, - 32248,32696 -}; + { + /* radix 8, size 4032 */ + 8, 4096, 16, 8192, 24, 12288, 32, 16384, 40, 20480, + 48, 24576, 56, 28672, 64, 512, 72, 4608, 80, 8704, + 88, 12800, 96, 16896, 104, 20992, 112, 25088, 120, 29184, + 128, 1024, 136, 5120, 144, 9216, 152, 13312, 160, 17408, + 168, 21504, 176, 25600, 184, 29696, 192, 1536, 200, 5632, + 208, 9728, 216, 13824, 224, 17920, 232, 22016, 240, 26112, + 248, 30208, 256, 2048, 264, 6144, 272, 10240, 280, 14336, + 288, 18432, 296, 22528, 304, 26624, 312, 30720, 320, 2560, + 328, 6656, 336, 10752, 344, 14848, 352, 18944, 360, 23040, + 368, 27136, 376, 31232, 384, 3072, 392, 7168, 400, 11264, + 408, 15360, 416, 19456, 424, 23552, 432, 27648, 440, 31744, + 448, 3584, 456, 7680, 464, 11776, 472, 15872, 480, 19968, + 488, 24064, 496, 28160, 504, 32256, 520, 4160, 528, 8256, + 536, 12352, 544, 16448, 552, 20544, 560, 24640, 568, 28736, + 584, 4672, 592, 8768, 600, 12864, 608, 16960, 616, 21056, + 624, 25152, 632, 29248, 640, 1088, 648, 5184, 656, 9280, + 664, 13376, 672, 17472, 680, 21568, 688, 25664, 696, 29760, + 704, 1600, 712, 5696, 720, 9792, 728, 13888, 736, 17984, + 744, 22080, 752, 26176, 760, 30272, 768, 2112, 776, 6208, + 784, 10304, 792, 14400, 800, 18496, 808, 22592, 816, 26688, + 824, 30784, 832, 2624, 840, 6720, 848, 10816, 856, 14912, + 864, 19008, 872, 23104, 880, 27200, 888, 31296, 896, 3136, + 904, 7232, 912, 11328, 920, 15424, 928, 19520, 936, 23616, + 944, 27712, 952, 31808, 960, 3648, 968, 7744, 976, 11840, + 984, 15936, 992, 20032, 1000, 24128, 1008, 28224, 1016, 32320, + 1032, 4224, 1040, 8320, 1048, 12416, 1056, 16512, 1064, 20608, + 1072, 24704, 1080, 28800, 1096, 4736, 1104, 8832, 1112, 12928, + 1120, 17024, 1128, 21120, 1136, 25216, 1144, 29312, 1160, 5248, + 1168, 9344, 1176, 13440, 1184, 17536, 1192, 21632, 1200, 25728, + 1208, 29824, 1216, 1664, 1224, 5760, 1232, 9856, 1240, 13952, + 1248, 18048, 1256, 22144, 1264, 26240, 1272, 30336, 1280, 2176, + 1288, 6272, 1296, 10368, 1304, 14464, 1312, 18560, 1320, 22656, + 1328, 26752, 1336, 30848, 1344, 2688, 1352, 6784, 1360, 10880, + 1368, 14976, 1376, 19072, 1384, 23168, 1392, 27264, 1400, 31360, + 1408, 3200, 1416, 7296, 1424, 11392, 1432, 15488, 1440, 19584, + 1448, 23680, 1456, 27776, 1464, 31872, 1472, 3712, 1480, 7808, + 1488, 11904, 1496, 16000, 1504, 20096, 1512, 24192, 1520, 28288, + 1528, 32384, 1544, 4288, 1552, 8384, 1560, 12480, 1568, 16576, + 1576, 20672, 1584, 24768, 1592, 28864, 1608, 4800, 1616, 8896, + 1624, 12992, 1632, 17088, 1640, 21184, 1648, 25280, 1656, 29376, + 1672, 5312, 1680, 9408, 1688, 13504, 1696, 17600, 1704, 21696, + 1712, 25792, 1720, 29888, 1736, 5824, 1744, 9920, 1752, 14016, + 1760, 18112, 1768, 22208, 1776, 26304, 1784, 30400, 1792, 2240, + 1800, 6336, 1808, 10432, 1816, 14528, 1824, 18624, 1832, 22720, + 1840, 26816, 1848, 30912, 1856, 2752, 1864, 6848, 1872, 10944, + 1880, 15040, 1888, 19136, 1896, 23232, 1904, 27328, 1912, 31424, + 1920, 3264, 1928, 7360, 1936, 11456, 1944, 15552, 1952, 19648, + 1960, 23744, 1968, 27840, 1976, 31936, 1984, 3776, 1992, 7872, + 2000, 11968, 2008, 16064, 2016, 20160, 2024, 24256, 2032, 28352, + 2040, 32448, 2056, 4352, 2064, 8448, 2072, 12544, 2080, 16640, + 2088, 20736, 2096, 24832, 2104, 28928, 2120, 4864, 2128, 8960, + 2136, 13056, 2144, 17152, 2152, 21248, 2160, 25344, 2168, 29440, + 2184, 5376, 2192, 9472, 2200, 13568, 2208, 17664, 2216, 21760, + 2224, 25856, 2232, 29952, 2248, 5888, 2256, 9984, 2264, 14080, + 2272, 18176, 2280, 22272, 2288, 26368, 2296, 30464, 2312, 6400, + 2320, 10496, 2328, 14592, 2336, 18688, 2344, 22784, 2352, 26880, + 2360, 30976, 2368, 2816, 2376, 6912, 2384, 11008, 2392, 15104, + 2400, 19200, 2408, 23296, 2416, 27392, 2424, 31488, 2432, 3328, + 2440, 7424, 2448, 11520, 2456, 15616, 2464, 19712, 2472, 23808, + 2480, 27904, 2488, 32000, 2496, 3840, 2504, 7936, 2512, 12032, + 2520, 16128, 2528, 20224, 2536, 24320, 2544, 28416, 2552, 32512, + 2568, 4416, 2576, 8512, 2584, 12608, 2592, 16704, 2600, 20800, + 2608, 24896, 2616, 28992, 2632, 4928, 2640, 9024, 2648, 13120, + 2656, 17216, 2664, 21312, 2672, 25408, 2680, 29504, 2696, 5440, + 2704, 9536, 2712, 13632, 2720, 17728, 2728, 21824, 2736, 25920, + 2744, 30016, 2760, 5952, 2768, 10048, 2776, 14144, 2784, 18240, + 2792, 22336, 2800, 26432, 2808, 30528, 2824, 6464, 2832, 10560, + 2840, 14656, 2848, 18752, 2856, 22848, 2864, 26944, 2872, 31040, + 2888, 6976, 2896, 11072, 2904, 15168, 2912, 19264, 2920, 23360, + 2928, 27456, 2936, 31552, 2944, 3392, 2952, 7488, 2960, 11584, + 2968, 15680, 2976, 19776, 2984, 23872, 2992, 27968, 3000, 32064, + 3008, 3904, 3016, 8000, 3024, 12096, 3032, 16192, 3040, 20288, + 3048, 24384, 3056, 28480, 3064, 32576, 3080, 4480, 3088, 8576, + 3096, 12672, 3104, 16768, 3112, 20864, 3120, 24960, 3128, 29056, + 3144, 4992, 3152, 9088, 3160, 13184, 3168, 17280, 3176, 21376, + 3184, 25472, 3192, 29568, 3208, 5504, 3216, 9600, 3224, 13696, + 3232, 17792, 3240, 21888, 3248, 25984, 3256, 30080, 3272, 6016, + 3280, 10112, 3288, 14208, 3296, 18304, 3304, 22400, 3312, 26496, + 3320, 30592, 3336, 6528, 3344, 10624, 3352, 14720, 3360, 18816, + 3368, 22912, 3376, 27008, 3384, 31104, 3400, 7040, 3408, 11136, + 3416, 15232, 3424, 19328, 3432, 23424, 3440, 27520, 3448, 31616, + 3464, 7552, 3472, 11648, 3480, 15744, 3488, 19840, 3496, 23936, + 3504, 28032, 3512, 32128, 3520, 3968, 3528, 8064, 3536, 12160, + 3544, 16256, 3552, 20352, 3560, 24448, 3568, 28544, 3576, 32640, + 3592, 4544, 3600, 8640, 3608, 12736, 3616, 16832, 3624, 20928, + 3632, 25024, 3640, 29120, 3656, 5056, 3664, 9152, 3672, 13248, + 3680, 17344, 3688, 21440, 3696, 25536, 3704, 29632, 3720, 5568, + 3728, 9664, 3736, 13760, 3744, 17856, 3752, 21952, 3760, 26048, + 3768, 30144, 3784, 6080, 3792, 10176, 3800, 14272, 3808, 18368, + 3816, 22464, 3824, 26560, 3832, 30656, 3848, 6592, 3856, 10688, + 3864, 14784, 3872, 18880, 3880, 22976, 3888, 27072, 3896, 31168, + 3912, 7104, 3920, 11200, 3928, 15296, 3936, 19392, 3944, 23488, + 3952, 27584, 3960, 31680, 3976, 7616, 3984, 11712, 3992, 15808, + 4000, 19904, 4008, 24000, 4016, 28096, 4024, 32192, 4040, 8128, + 4048, 12224, 4056, 16320, 4064, 20416, 4072, 24512, 4080, 28608, + 4088, 32704, 4112, 8200, 4120, 12296, 4128, 16392, 4136, 20488, + 4144, 24584, 4152, 28680, 4168, 4616, 4176, 8712, 4184, 12808, + 4192, 16904, 4200, 21000, 4208, 25096, 4216, 29192, 4232, 5128, + 4240, 9224, 4248, 13320, 4256, 17416, 4264, 21512, 4272, 25608, + 4280, 29704, 4296, 5640, 4304, 9736, 4312, 13832, 4320, 17928, + 4328, 22024, 4336, 26120, 4344, 30216, 4360, 6152, 4368, 10248, + 4376, 14344, 4384, 18440, 4392, 22536, 4400, 26632, 4408, 30728, + 4424, 6664, 4432, 10760, 4440, 14856, 4448, 18952, 4456, 23048, + 4464, 27144, 4472, 31240, 4488, 7176, 4496, 11272, 4504, 15368, + 4512, 19464, 4520, 23560, 4528, 27656, 4536, 31752, 4552, 7688, + 4560, 11784, 4568, 15880, 4576, 19976, 4584, 24072, 4592, 28168, + 4600, 32264, 4624, 8264, 4632, 12360, 4640, 16456, 4648, 20552, + 4656, 24648, 4664, 28744, 4688, 8776, 4696, 12872, 4704, 16968, + 4712, 21064, 4720, 25160, 4728, 29256, 4744, 5192, 4752, 9288, + 4760, 13384, 4768, 17480, 4776, 21576, 4784, 25672, 4792, 29768, + 4808, 5704, 4816, 9800, 4824, 13896, 4832, 17992, 4840, 22088, + 4848, 26184, 4856, 30280, 4872, 6216, 4880, 10312, 4888, 14408, + 4896, 18504, 4904, 22600, 4912, 26696, 4920, 30792, 4936, 6728, + 4944, 10824, 4952, 14920, 4960, 19016, 4968, 23112, 4976, 27208, + 4984, 31304, 5000, 7240, 5008, 11336, 5016, 15432, 5024, 19528, + 5032, 23624, 5040, 27720, 5048, 31816, 5064, 7752, 5072, 11848, + 5080, 15944, 5088, 20040, 5096, 24136, 5104, 28232, 5112, 32328, + 5136, 8328, 5144, 12424, 5152, 16520, 5160, 20616, 5168, 24712, + 5176, 28808, 5200, 8840, 5208, 12936, 5216, 17032, 5224, 21128, + 5232, 25224, 5240, 29320, 5264, 9352, 5272, 13448, 5280, 17544, + 5288, 21640, 5296, 25736, 5304, 29832, 5320, 5768, 5328, 9864, + 5336, 13960, 5344, 18056, 5352, 22152, 5360, 26248, 5368, 30344, + 5384, 6280, 5392, 10376, 5400, 14472, 5408, 18568, 5416, 22664, + 5424, 26760, 5432, 30856, 5448, 6792, 5456, 10888, 5464, 14984, + 5472, 19080, 5480, 23176, 5488, 27272, 5496, 31368, 5512, 7304, + 5520, 11400, 5528, 15496, 5536, 19592, 5544, 23688, 5552, 27784, + 5560, 31880, 5576, 7816, 5584, 11912, 5592, 16008, 5600, 20104, + 5608, 24200, 5616, 28296, 5624, 32392, 5648, 8392, 5656, 12488, + 5664, 16584, 5672, 20680, 5680, 24776, 5688, 28872, 5712, 8904, + 5720, 13000, 5728, 17096, 5736, 21192, 5744, 25288, 5752, 29384, + 5776, 9416, 5784, 13512, 5792, 17608, 5800, 21704, 5808, 25800, + 5816, 29896, 5840, 9928, 5848, 14024, 5856, 18120, 5864, 22216, + 5872, 26312, 5880, 30408, 5896, 6344, 5904, 10440, 5912, 14536, + 5920, 18632, 5928, 22728, 5936, 26824, 5944, 30920, 5960, 6856, + 5968, 10952, 5976, 15048, 5984, 19144, 5992, 23240, 6000, 27336, + 6008, 31432, 6024, 7368, 6032, 11464, 6040, 15560, 6048, 19656, + 6056, 23752, 6064, 27848, 6072, 31944, 6088, 7880, 6096, 11976, + 6104, 16072, 6112, 20168, 6120, 24264, 6128, 28360, 6136, 32456, + 6160, 8456, 6168, 12552, 6176, 16648, 6184, 20744, 6192, 24840, + 6200, 28936, 6224, 8968, 6232, 13064, 6240, 17160, 6248, 21256, + 6256, 25352, 6264, 29448, 6288, 9480, 6296, 13576, 6304, 17672, + 6312, 21768, 6320, 25864, 6328, 29960, 6352, 9992, 6360, 14088, + 6368, 18184, 6376, 22280, 6384, 26376, 6392, 30472, 6416, 10504, + 6424, 14600, 6432, 18696, 6440, 22792, 6448, 26888, 6456, 30984, + 6472, 6920, 6480, 11016, 6488, 15112, 6496, 19208, 6504, 23304, + 6512, 27400, 6520, 31496, 6536, 7432, 6544, 11528, 6552, 15624, + 6560, 19720, 6568, 23816, 6576, 27912, 6584, 32008, 6600, 7944, + 6608, 12040, 6616, 16136, 6624, 20232, 6632, 24328, 6640, 28424, + 6648, 32520, 6672, 8520, 6680, 12616, 6688, 16712, 6696, 20808, + 6704, 24904, 6712, 29000, 6736, 9032, 6744, 13128, 6752, 17224, + 6760, 21320, 6768, 25416, 6776, 29512, 6800, 9544, 6808, 13640, + 6816, 17736, 6824, 21832, 6832, 25928, 6840, 30024, 6864, 10056, + 6872, 14152, 6880, 18248, 6888, 22344, 6896, 26440, 6904, 30536, + 6928, 10568, 6936, 14664, 6944, 18760, 6952, 22856, 6960, 26952, + 6968, 31048, 6992, 11080, 7000, 15176, 7008, 19272, 7016, 23368, + 7024, 27464, 7032, 31560, 7048, 7496, 7056, 11592, 7064, 15688, + 7072, 19784, 7080, 23880, 7088, 27976, 7096, 32072, 7112, 8008, + 7120, 12104, 7128, 16200, 7136, 20296, 7144, 24392, 7152, 28488, + 7160, 32584, 7184, 8584, 7192, 12680, 7200, 16776, 7208, 20872, + 7216, 24968, 7224, 29064, 7248, 9096, 7256, 13192, 7264, 17288, + 7272, 21384, 7280, 25480, 7288, 29576, 7312, 9608, 7320, 13704, + 7328, 17800, 7336, 21896, 7344, 25992, 7352, 30088, 7376, 10120, + 7384, 14216, 7392, 18312, 7400, 22408, 7408, 26504, 7416, 30600, + 7440, 10632, 7448, 14728, 7456, 18824, 7464, 22920, 7472, 27016, + 7480, 31112, 7504, 11144, 7512, 15240, 7520, 19336, 7528, 23432, + 7536, 27528, 7544, 31624, 7568, 11656, 7576, 15752, 7584, 19848, + 7592, 23944, 7600, 28040, 7608, 32136, 7624, 8072, 7632, 12168, + 7640, 16264, 7648, 20360, 7656, 24456, 7664, 28552, 7672, 32648, + 7696, 8648, 7704, 12744, 7712, 16840, 7720, 20936, 7728, 25032, + 7736, 29128, 7760, 9160, 7768, 13256, 7776, 17352, 7784, 21448, + 7792, 25544, 7800, 29640, 7824, 9672, 7832, 13768, 7840, 17864, + 7848, 21960, 7856, 26056, 7864, 30152, 7888, 10184, 7896, 14280, + 7904, 18376, 7912, 22472, 7920, 26568, 7928, 30664, 7952, 10696, + 7960, 14792, 7968, 18888, 7976, 22984, 7984, 27080, 7992, 31176, + 8016, 11208, 8024, 15304, 8032, 19400, 8040, 23496, 8048, 27592, + 8056, 31688, 8080, 11720, 8088, 15816, 8096, 19912, 8104, 24008, + 8112, 28104, 8120, 32200, 8144, 12232, 8152, 16328, 8160, 20424, + 8168, 24520, 8176, 28616, 8184, 32712, 8216, 12304, 8224, 16400, + 8232, 20496, 8240, 24592, 8248, 28688, 8272, 8720, 8280, 12816, + 8288, 16912, 8296, 21008, 8304, 25104, 8312, 29200, 8336, 9232, + 8344, 13328, 8352, 17424, 8360, 21520, 8368, 25616, 8376, 29712, + 8400, 9744, 8408, 13840, 8416, 17936, 8424, 22032, 8432, 26128, + 8440, 30224, 8464, 10256, 8472, 14352, 8480, 18448, 8488, 22544, + 8496, 26640, 8504, 30736, 8528, 10768, 8536, 14864, 8544, 18960, + 8552, 23056, 8560, 27152, 8568, 31248, 8592, 11280, 8600, 15376, + 8608, 19472, 8616, 23568, 8624, 27664, 8632, 31760, 8656, 11792, + 8664, 15888, 8672, 19984, 8680, 24080, 8688, 28176, 8696, 32272, + 8728, 12368, 8736, 16464, 8744, 20560, 8752, 24656, 8760, 28752, + 8792, 12880, 8800, 16976, 8808, 21072, 8816, 25168, 8824, 29264, + 8848, 9296, 8856, 13392, 8864, 17488, 8872, 21584, 8880, 25680, + 8888, 29776, 8912, 9808, 8920, 13904, 8928, 18000, 8936, 22096, + 8944, 26192, 8952, 30288, 8976, 10320, 8984, 14416, 8992, 18512, + 9000, 22608, 9008, 26704, 9016, 30800, 9040, 10832, 9048, 14928, + 9056, 19024, 9064, 23120, 9072, 27216, 9080, 31312, 9104, 11344, + 9112, 15440, 9120, 19536, 9128, 23632, 9136, 27728, 9144, 31824, + 9168, 11856, 9176, 15952, 9184, 20048, 9192, 24144, 9200, 28240, + 9208, 32336, 9240, 12432, 9248, 16528, 9256, 20624, 9264, 24720, + 9272, 28816, 9304, 12944, 9312, 17040, 9320, 21136, 9328, 25232, + 9336, 29328, 9368, 13456, 9376, 17552, 9384, 21648, 9392, 25744, + 9400, 29840, 9424, 9872, 9432, 13968, 9440, 18064, 9448, 22160, + 9456, 26256, 9464, 30352, 9488, 10384, 9496, 14480, 9504, 18576, + 9512, 22672, 9520, 26768, 9528, 30864, 9552, 10896, 9560, 14992, + 9568, 19088, 9576, 23184, 9584, 27280, 9592, 31376, 9616, 11408, + 9624, 15504, 9632, 19600, 9640, 23696, 9648, 27792, 9656, 31888, + 9680, 11920, 9688, 16016, 9696, 20112, 9704, 24208, 9712, 28304, + 9720, 32400, 9752, 12496, 9760, 16592, 9768, 20688, 9776, 24784, + 9784, 28880, 9816, 13008, 9824, 17104, 9832, 21200, 9840, 25296, + 9848, 29392, 9880, 13520, 9888, 17616, 9896, 21712, 9904, 25808, + 9912, 29904, 9944, 14032, 9952, 18128, 9960, 22224, 9968, 26320, + 9976, 30416, 10000, 10448, 10008, 14544, 10016, 18640, 10024, 22736, + 10032, 26832, 10040, 30928, 10064, 10960, 10072, 15056, 10080, 19152, + 10088, 23248, 10096, 27344, 10104, 31440, 10128, 11472, 10136, 15568, + 10144, 19664, 10152, 23760, 10160, 27856, 10168, 31952, 10192, 11984, + 10200, 16080, 10208, 20176, 10216, 24272, 10224, 28368, 10232, 32464, + 10264, 12560, 10272, 16656, 10280, 20752, 10288, 24848, 10296, 28944, + 10328, 13072, 10336, 17168, 10344, 21264, 10352, 25360, 10360, 29456, + 10392, 13584, 10400, 17680, 10408, 21776, 10416, 25872, 10424, 29968, + 10456, 14096, 10464, 18192, 10472, 22288, 10480, 26384, 10488, 30480, + 10520, 14608, 10528, 18704, 10536, 22800, 10544, 26896, 10552, 30992, + 10576, 11024, 10584, 15120, 10592, 19216, 10600, 23312, 10608, 27408, + 10616, 31504, 10640, 11536, 10648, 15632, 10656, 19728, 10664, 23824, + 10672, 27920, 10680, 32016, 10704, 12048, 10712, 16144, 10720, 20240, + 10728, 24336, 10736, 28432, 10744, 32528, 10776, 12624, 10784, 16720, + 10792, 20816, 10800, 24912, 10808, 29008, 10840, 13136, 10848, 17232, + 10856, 21328, 10864, 25424, 10872, 29520, 10904, 13648, 10912, 17744, + 10920, 21840, 10928, 25936, 10936, 30032, 10968, 14160, 10976, 18256, + 10984, 22352, 10992, 26448, 11000, 30544, 11032, 14672, 11040, 18768, + 11048, 22864, 11056, 26960, 11064, 31056, 11096, 15184, 11104, 19280, + 11112, 23376, 11120, 27472, 11128, 31568, 11152, 11600, 11160, 15696, + 11168, 19792, 11176, 23888, 11184, 27984, 11192, 32080, 11216, 12112, + 11224, 16208, 11232, 20304, 11240, 24400, 11248, 28496, 11256, 32592, + 11288, 12688, 11296, 16784, 11304, 20880, 11312, 24976, 11320, 29072, + 11352, 13200, 11360, 17296, 11368, 21392, 11376, 25488, 11384, 29584, + 11416, 13712, 11424, 17808, 11432, 21904, 11440, 26000, 11448, 30096, + 11480, 14224, 11488, 18320, 11496, 22416, 11504, 26512, 11512, 30608, + 11544, 14736, 11552, 18832, 11560, 22928, 11568, 27024, 11576, 31120, + 11608, 15248, 11616, 19344, 11624, 23440, 11632, 27536, 11640, 31632, + 11672, 15760, 11680, 19856, 11688, 23952, 11696, 28048, 11704, 32144, + 11728, 12176, 11736, 16272, 11744, 20368, 11752, 24464, 11760, 28560, + 11768, 32656, 11800, 12752, 11808, 16848, 11816, 20944, 11824, 25040, + 11832, 29136, 11864, 13264, 11872, 17360, 11880, 21456, 11888, 25552, + 11896, 29648, 11928, 13776, 11936, 17872, 11944, 21968, 11952, 26064, + 11960, 30160, 11992, 14288, 12000, 18384, 12008, 22480, 12016, 26576, + 12024, 30672, 12056, 14800, 12064, 18896, 12072, 22992, 12080, 27088, + 12088, 31184, 12120, 15312, 12128, 19408, 12136, 23504, 12144, 27600, + 12152, 31696, 12184, 15824, 12192, 19920, 12200, 24016, 12208, 28112, + 12216, 32208, 12248, 16336, 12256, 20432, 12264, 24528, 12272, 28624, + 12280, 32720, 12320, 16408, 12328, 20504, 12336, 24600, 12344, 28696, + 12376, 12824, 12384, 16920, 12392, 21016, 12400, 25112, 12408, 29208, + 12440, 13336, 12448, 17432, 12456, 21528, 12464, 25624, 12472, 29720, + 12504, 13848, 12512, 17944, 12520, 22040, 12528, 26136, 12536, 30232, + 12568, 14360, 12576, 18456, 12584, 22552, 12592, 26648, 12600, 30744, + 12632, 14872, 12640, 18968, 12648, 23064, 12656, 27160, 12664, 31256, + 12696, 15384, 12704, 19480, 12712, 23576, 12720, 27672, 12728, 31768, + 12760, 15896, 12768, 19992, 12776, 24088, 12784, 28184, 12792, 32280, + 12832, 16472, 12840, 20568, 12848, 24664, 12856, 28760, 12896, 16984, + 12904, 21080, 12912, 25176, 12920, 29272, 12952, 13400, 12960, 17496, + 12968, 21592, 12976, 25688, 12984, 29784, 13016, 13912, 13024, 18008, + 13032, 22104, 13040, 26200, 13048, 30296, 13080, 14424, 13088, 18520, + 13096, 22616, 13104, 26712, 13112, 30808, 13144, 14936, 13152, 19032, + 13160, 23128, 13168, 27224, 13176, 31320, 13208, 15448, 13216, 19544, + 13224, 23640, 13232, 27736, 13240, 31832, 13272, 15960, 13280, 20056, + 13288, 24152, 13296, 28248, 13304, 32344, 13344, 16536, 13352, 20632, + 13360, 24728, 13368, 28824, 13408, 17048, 13416, 21144, 13424, 25240, + 13432, 29336, 13472, 17560, 13480, 21656, 13488, 25752, 13496, 29848, + 13528, 13976, 13536, 18072, 13544, 22168, 13552, 26264, 13560, 30360, + 13592, 14488, 13600, 18584, 13608, 22680, 13616, 26776, 13624, 30872, + 13656, 15000, 13664, 19096, 13672, 23192, 13680, 27288, 13688, 31384, + 13720, 15512, 13728, 19608, 13736, 23704, 13744, 27800, 13752, 31896, + 13784, 16024, 13792, 20120, 13800, 24216, 13808, 28312, 13816, 32408, + 13856, 16600, 13864, 20696, 13872, 24792, 13880, 28888, 13920, 17112, + 13928, 21208, 13936, 25304, 13944, 29400, 13984, 17624, 13992, 21720, + 14000, 25816, 14008, 29912, 14048, 18136, 14056, 22232, 14064, 26328, + 14072, 30424, 14104, 14552, 14112, 18648, 14120, 22744, 14128, 26840, + 14136, 30936, 14168, 15064, 14176, 19160, 14184, 23256, 14192, 27352, + 14200, 31448, 14232, 15576, 14240, 19672, 14248, 23768, 14256, 27864, + 14264, 31960, 14296, 16088, 14304, 20184, 14312, 24280, 14320, 28376, + 14328, 32472, 14368, 16664, 14376, 20760, 14384, 24856, 14392, 28952, + 14432, 17176, 14440, 21272, 14448, 25368, 14456, 29464, 14496, 17688, + 14504, 21784, 14512, 25880, 14520, 29976, 14560, 18200, 14568, 22296, + 14576, 26392, 14584, 30488, 14624, 18712, 14632, 22808, 14640, 26904, + 14648, 31000, 14680, 15128, 14688, 19224, 14696, 23320, 14704, 27416, + 14712, 31512, 14744, 15640, 14752, 19736, 14760, 23832, 14768, 27928, + 14776, 32024, 14808, 16152, 14816, 20248, 14824, 24344, 14832, 28440, + 14840, 32536, 14880, 16728, 14888, 20824, 14896, 24920, 14904, 29016, + 14944, 17240, 14952, 21336, 14960, 25432, 14968, 29528, 15008, 17752, + 15016, 21848, 15024, 25944, 15032, 30040, 15072, 18264, 15080, 22360, + 15088, 26456, 15096, 30552, 15136, 18776, 15144, 22872, 15152, 26968, + 15160, 31064, 15200, 19288, 15208, 23384, 15216, 27480, 15224, 31576, + 15256, 15704, 15264, 19800, 15272, 23896, 15280, 27992, 15288, 32088, + 15320, 16216, 15328, 20312, 15336, 24408, 15344, 28504, 15352, 32600, + 15392, 16792, 15400, 20888, 15408, 24984, 15416, 29080, 15456, 17304, + 15464, 21400, 15472, 25496, 15480, 29592, 15520, 17816, 15528, 21912, + 15536, 26008, 15544, 30104, 15584, 18328, 15592, 22424, 15600, 26520, + 15608, 30616, 15648, 18840, 15656, 22936, 15664, 27032, 15672, 31128, + 15712, 19352, 15720, 23448, 15728, 27544, 15736, 31640, 15776, 19864, + 15784, 23960, 15792, 28056, 15800, 32152, 15832, 16280, 15840, 20376, + 15848, 24472, 15856, 28568, 15864, 32664, 15904, 16856, 15912, 20952, + 15920, 25048, 15928, 29144, 15968, 17368, 15976, 21464, 15984, 25560, + 15992, 29656, 16032, 17880, 16040, 21976, 16048, 26072, 16056, 30168, + 16096, 18392, 16104, 22488, 16112, 26584, 16120, 30680, 16160, 18904, + 16168, 23000, 16176, 27096, 16184, 31192, 16224, 19416, 16232, 23512, + 16240, 27608, 16248, 31704, 16288, 19928, 16296, 24024, 16304, 28120, + 16312, 32216, 16352, 20440, 16360, 24536, 16368, 28632, 16376, 32728, + 16424, 20512, 16432, 24608, 16440, 28704, 16480, 16928, 16488, 21024, + 16496, 25120, 16504, 29216, 16544, 17440, 16552, 21536, 16560, 25632, + 16568, 29728, 16608, 17952, 16616, 22048, 16624, 26144, 16632, 30240, + 16672, 18464, 16680, 22560, 16688, 26656, 16696, 30752, 16736, 18976, + 16744, 23072, 16752, 27168, 16760, 31264, 16800, 19488, 16808, 23584, + 16816, 27680, 16824, 31776, 16864, 20000, 16872, 24096, 16880, 28192, + 16888, 32288, 16936, 20576, 16944, 24672, 16952, 28768, 17000, 21088, + 17008, 25184, 17016, 29280, 17056, 17504, 17064, 21600, 17072, 25696, + 17080, 29792, 17120, 18016, 17128, 22112, 17136, 26208, 17144, 30304, + 17184, 18528, 17192, 22624, 17200, 26720, 17208, 30816, 17248, 19040, + 17256, 23136, 17264, 27232, 17272, 31328, 17312, 19552, 17320, 23648, + 17328, 27744, 17336, 31840, 17376, 20064, 17384, 24160, 17392, 28256, + 17400, 32352, 17448, 20640, 17456, 24736, 17464, 28832, 17512, 21152, + 17520, 25248, 17528, 29344, 17576, 21664, 17584, 25760, 17592, 29856, + 17632, 18080, 17640, 22176, 17648, 26272, 17656, 30368, 17696, 18592, + 17704, 22688, 17712, 26784, 17720, 30880, 17760, 19104, 17768, 23200, + 17776, 27296, 17784, 31392, 17824, 19616, 17832, 23712, 17840, 27808, + 17848, 31904, 17888, 20128, 17896, 24224, 17904, 28320, 17912, 32416, + 17960, 20704, 17968, 24800, 17976, 28896, 18024, 21216, 18032, 25312, + 18040, 29408, 18088, 21728, 18096, 25824, 18104, 29920, 18152, 22240, + 18160, 26336, 18168, 30432, 18208, 18656, 18216, 22752, 18224, 26848, + 18232, 30944, 18272, 19168, 18280, 23264, 18288, 27360, 18296, 31456, + 18336, 19680, 18344, 23776, 18352, 27872, 18360, 31968, 18400, 20192, + 18408, 24288, 18416, 28384, 18424, 32480, 18472, 20768, 18480, 24864, + 18488, 28960, 18536, 21280, 18544, 25376, 18552, 29472, 18600, 21792, + 18608, 25888, 18616, 29984, 18664, 22304, 18672, 26400, 18680, 30496, + 18728, 22816, 18736, 26912, 18744, 31008, 18784, 19232, 18792, 23328, + 18800, 27424, 18808, 31520, 18848, 19744, 18856, 23840, 18864, 27936, + 18872, 32032, 18912, 20256, 18920, 24352, 18928, 28448, 18936, 32544, + 18984, 20832, 18992, 24928, 19000, 29024, 19048, 21344, 19056, 25440, + 19064, 29536, 19112, 21856, 19120, 25952, 19128, 30048, 19176, 22368, + 19184, 26464, 19192, 30560, 19240, 22880, 19248, 26976, 19256, 31072, + 19304, 23392, 19312, 27488, 19320, 31584, 19360, 19808, 19368, 23904, + 19376, 28000, 19384, 32096, 19424, 20320, 19432, 24416, 19440, 28512, + 19448, 32608, 19496, 20896, 19504, 24992, 19512, 29088, 19560, 21408, + 19568, 25504, 19576, 29600, 19624, 21920, 19632, 26016, 19640, 30112, + 19688, 22432, 19696, 26528, 19704, 30624, 19752, 22944, 19760, 27040, + 19768, 31136, 19816, 23456, 19824, 27552, 19832, 31648, 19880, 23968, + 19888, 28064, 19896, 32160, 19936, 20384, 19944, 24480, 19952, 28576, + 19960, 32672, 20008, 20960, 20016, 25056, 20024, 29152, 20072, 21472, + 20080, 25568, 20088, 29664, 20136, 21984, 20144, 26080, 20152, 30176, + 20200, 22496, 20208, 26592, 20216, 30688, 20264, 23008, 20272, 27104, + 20280, 31200, 20328, 23520, 20336, 27616, 20344, 31712, 20392, 24032, + 20400, 28128, 20408, 32224, 20456, 24544, 20464, 28640, 20472, 32736, + 20528, 24616, 20536, 28712, 20584, 21032, 20592, 25128, 20600, 29224, + 20648, 21544, 20656, 25640, 20664, 29736, 20712, 22056, 20720, 26152, + 20728, 30248, 20776, 22568, 20784, 26664, 20792, 30760, 20840, 23080, + 20848, 27176, 20856, 31272, 20904, 23592, 20912, 27688, 20920, 31784, + 20968, 24104, 20976, 28200, 20984, 32296, 21040, 24680, 21048, 28776, + 21104, 25192, 21112, 29288, 21160, 21608, 21168, 25704, 21176, 29800, + 21224, 22120, 21232, 26216, 21240, 30312, 21288, 22632, 21296, 26728, + 21304, 30824, 21352, 23144, 21360, 27240, 21368, 31336, 21416, 23656, + 21424, 27752, 21432, 31848, 21480, 24168, 21488, 28264, 21496, 32360, + 21552, 24744, 21560, 28840, 21616, 25256, 21624, 29352, 21680, 25768, + 21688, 29864, 21736, 22184, 21744, 26280, 21752, 30376, 21800, 22696, + 21808, 26792, 21816, 30888, 21864, 23208, 21872, 27304, 21880, 31400, + 21928, 23720, 21936, 27816, 21944, 31912, 21992, 24232, 22000, 28328, + 22008, 32424, 22064, 24808, 22072, 28904, 22128, 25320, 22136, 29416, + 22192, 25832, 22200, 29928, 22256, 26344, 22264, 30440, 22312, 22760, + 22320, 26856, 22328, 30952, 22376, 23272, 22384, 27368, 22392, 31464, + 22440, 23784, 22448, 27880, 22456, 31976, 22504, 24296, 22512, 28392, + 22520, 32488, 22576, 24872, 22584, 28968, 22640, 25384, 22648, 29480, + 22704, 25896, 22712, 29992, 22768, 26408, 22776, 30504, 22832, 26920, + 22840, 31016, 22888, 23336, 22896, 27432, 22904, 31528, 22952, 23848, + 22960, 27944, 22968, 32040, 23016, 24360, 23024, 28456, 23032, 32552, + 23088, 24936, 23096, 29032, 23152, 25448, 23160, 29544, 23216, 25960, + 23224, 30056, 23280, 26472, 23288, 30568, 23344, 26984, 23352, 31080, + 23408, 27496, 23416, 31592, 23464, 23912, 23472, 28008, 23480, 32104, + 23528, 24424, 23536, 28520, 23544, 32616, 23600, 25000, 23608, 29096, + 23664, 25512, 23672, 29608, 23728, 26024, 23736, 30120, 23792, 26536, + 23800, 30632, 23856, 27048, 23864, 31144, 23920, 27560, 23928, 31656, + 23984, 28072, 23992, 32168, 24040, 24488, 24048, 28584, 24056, 32680, + 24112, 25064, 24120, 29160, 24176, 25576, 24184, 29672, 24240, 26088, + 24248, 30184, 24304, 26600, 24312, 30696, 24368, 27112, 24376, 31208, + 24432, 27624, 24440, 31720, 24496, 28136, 24504, 32232, 24560, 28648, + 24568, 32744, 24632, 28720, 24688, 25136, 24696, 29232, 24752, 25648, + 24760, 29744, 24816, 26160, 24824, 30256, 24880, 26672, 24888, 30768, + 24944, 27184, 24952, 31280, 25008, 27696, 25016, 31792, 25072, 28208, + 25080, 32304, 25144, 28784, 25208, 29296, 25264, 25712, 25272, 29808, + 25328, 26224, 25336, 30320, 25392, 26736, 25400, 30832, 25456, 27248, + 25464, 31344, 25520, 27760, 25528, 31856, 25584, 28272, 25592, 32368, + 25656, 28848, 25720, 29360, 25784, 29872, 25840, 26288, 25848, 30384, + 25904, 26800, 25912, 30896, 25968, 27312, 25976, 31408, 26032, 27824, + 26040, 31920, 26096, 28336, 26104, 32432, 26168, 28912, 26232, 29424, + 26296, 29936, 26360, 30448, 26416, 26864, 26424, 30960, 26480, 27376, + 26488, 31472, 26544, 27888, 26552, 31984, 26608, 28400, 26616, 32496, + 26680, 28976, 26744, 29488, 26808, 30000, 26872, 30512, 26936, 31024, + 26992, 27440, 27000, 31536, 27056, 27952, 27064, 32048, 27120, 28464, + 27128, 32560, 27192, 29040, 27256, 29552, 27320, 30064, 27384, 30576, + 27448, 31088, 27512, 31600, 27568, 28016, 27576, 32112, 27632, 28528, + 27640, 32624, 27704, 29104, 27768, 29616, 27832, 30128, 27896, 30640, + 27960, 31152, 28024, 31664, 28088, 32176, 28144, 28592, 28152, 32688, + 28216, 29168, 28280, 29680, 28344, 30192, 28408, 30704, 28472, 31216, + 28536, 31728, 28600, 32240, 28664, 32752, 28792, 29240, 28856, 29752, + 28920, 30264, 28984, 30776, 29048, 31288, 29112, 31800, 29176, 32312, + 29368, 29816, 29432, 30328, 29496, 30840, 29560, 31352, 29624, 31864, + 29688, 32376, 29944, 30392, 30008, 30904, 30072, 31416, 30136, 31928, + 30200, 32440, 30520, 30968, 30584, 31480, 30648, 31992, 30712, 32504, + 31096, 31544, 31160, 32056, 31224, 32568, 31672, 32120, 31736, 32632, + 32248, 32696}; +const uint16_t + armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED_16_TABLE_LENGTH] = { + /* radix 4, size 12 */ + 8, 64, 16, 32, 24, 96, 40, 80, 56, 112, 88, 104}; -const uint16_t armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED_16_TABLE_LENGTH] = -{ - /* radix 4, size 12 */ - 8,64, 16,32, 24,96, 40,80, 56,112, 88,104 -}; +const uint16_t + armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED_32_TABLE_LENGTH] = { + /* 4x2, size 24 */ + 8, 128, 16, 64, 24, 192, 40, 160, 48, 96, 56, 224, + 72, 144, 88, 208, 104, 176, 120, 240, 152, 200, 184, 232}; -const uint16_t armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED_32_TABLE_LENGTH] = -{ - /* 4x2, size 24 */ - 8,128, 16,64, 24,192, 40,160, 48,96, 56,224, 72,144, - 88,208, 104,176, 120,240, 152,200, 184,232 -}; +const uint16_t + armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED_64_TABLE_LENGTH] = { + /* radix 4, size 56 */ + 8, 256, 16, 128, 24, 384, 32, 64, 40, 320, 48, 192, 56, 448, + 72, 288, 80, 160, 88, 416, 104, 352, 112, 224, 120, 480, 136, 272, + 152, 400, 168, 336, 176, 208, 184, 464, 200, 304, 216, 432, 232, 368, + 248, 496, 280, 392, 296, 328, 312, 456, 344, 424, 376, 488, 440, 472}; -const uint16_t armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED_64_TABLE_LENGTH] = -{ - /* radix 4, size 56 */ - 8,256, 16,128, 24,384, 32,64, 40,320, 48,192, 56,448, 72,288, 80,160, 88,416, 104,352, - 112,224, 120,480, 136,272, 152,400, 168,336, 176,208, 184,464, 200,304, 216,432, - 232,368, 248,496, 280,392, 296,328, 312,456, 344,424, 376,488, 440,472 -}; +const uint16_t + armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED_128_TABLE_LENGTH] = + { + /* 4x2, size 112 */ + 8, 512, 16, 256, 24, 768, 32, 128, 40, 640, 48, 384, 56, + 896, 72, 576, 80, 320, 88, 832, 96, 192, 104, 704, 112, 448, + 120, 960, 136, 544, 144, 288, 152, 800, 168, 672, 176, 416, 184, + 928, 200, 608, 208, 352, 216, 864, 232, 736, 240, 480, 248, 992, + 264, 528, 280, 784, 296, 656, 304, 400, 312, 912, 328, 592, 344, + 848, 360, 720, 368, 464, 376, 976, 392, 560, 408, 816, 424, 688, + 440, 944, 456, 624, 472, 880, 488, 752, 504, 1008, 536, 776, 552, + 648, 568, 904, 600, 840, 616, 712, 632, 968, 664, 808, 696, 936, + 728, 872, 760, 1000, 824, 920, 888, 984}; -const uint16_t armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED_128_TABLE_LENGTH] = -{ - /* 4x2, size 112 */ - 8,512, 16,256, 24,768, 32,128, 40,640, 48,384, 56,896, 72,576, 80,320, 88,832, 96,192, - 104,704, 112,448, 120,960, 136,544, 144,288, 152,800, 168,672, 176,416, 184,928, 200,608, - 208,352, 216,864, 232,736, 240,480, 248,992, 264,528, 280,784, 296,656, 304,400, 312,912, - 328,592, 344,848, 360,720, 368,464, 376,976, 392,560, 408,816, 424,688, 440,944, 456,624, - 472,880, 488,752, 504,1008, 536,776, 552,648, 568,904, 600,840, 616,712, 632,968, - 664,808, 696,936, 728,872, 760,1000, 824,920, 888,984 -}; +const uint16_t + armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED_256_TABLE_LENGTH] = + { + /* radix 4, size 240 */ + 8, 1024, 16, 512, 24, 1536, 32, 256, 40, 1280, 48, + 768, 56, 1792, 64, 128, 72, 1152, 80, 640, 88, 1664, + 96, 384, 104, 1408, 112, 896, 120, 1920, 136, 1088, 144, + 576, 152, 1600, 160, 320, 168, 1344, 176, 832, 184, 1856, + 200, 1216, 208, 704, 216, 1728, 224, 448, 232, 1472, 240, + 960, 248, 1984, 264, 1056, 272, 544, 280, 1568, 296, 1312, + 304, 800, 312, 1824, 328, 1184, 336, 672, 344, 1696, 352, + 416, 360, 1440, 368, 928, 376, 1952, 392, 1120, 400, 608, + 408, 1632, 424, 1376, 432, 864, 440, 1888, 456, 1248, 464, + 736, 472, 1760, 488, 1504, 496, 992, 504, 2016, 520, 1040, + 536, 1552, 552, 1296, 560, 784, 568, 1808, 584, 1168, 592, + 656, 600, 1680, 616, 1424, 624, 912, 632, 1936, 648, 1104, + 664, 1616, 680, 1360, 688, 848, 696, 1872, 712, 1232, 728, + 1744, 744, 1488, 752, 976, 760, 2000, 776, 1072, 792, 1584, + 808, 1328, 824, 1840, 840, 1200, 856, 1712, 872, 1456, 880, + 944, 888, 1968, 904, 1136, 920, 1648, 936, 1392, 952, 1904, + 968, 1264, 984, 1776, 1000, 1520, 1016, 2032, 1048, 1544, 1064, + 1288, 1080, 1800, 1096, 1160, 1112, 1672, 1128, 1416, 1144, 1928, + 1176, 1608, 1192, 1352, 1208, 1864, 1240, 1736, 1256, 1480, 1272, + 1992, 1304, 1576, 1336, 1832, 1368, 1704, 1384, 1448, 1400, 1960, + 1432, 1640, 1464, 1896, 1496, 1768, 1528, 2024, 1592, 1816, 1624, + 1688, 1656, 1944, 1720, 1880, 1784, 2008, 1912, 1976}; -const uint16_t armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED_256_TABLE_LENGTH] = -{ - /* radix 4, size 240 */ - 8,1024, 16,512, 24,1536, 32,256, 40,1280, 48,768, 56,1792, 64,128, 72,1152, 80,640, - 88,1664, 96,384, 104,1408, 112,896, 120,1920, 136,1088, 144,576, 152,1600, 160,320, - 168,1344, 176,832, 184,1856, 200,1216, 208,704, 216,1728, 224,448, 232,1472, 240,960, - 248,1984, 264,1056, 272,544, 280,1568, 296,1312, 304,800, 312,1824, 328,1184, 336,672, - 344,1696, 352,416, 360,1440, 368,928, 376,1952, 392,1120, 400,608, 408,1632, 424,1376, - 432,864, 440,1888, 456,1248, 464,736, 472,1760, 488,1504, 496,992, 504,2016, 520,1040, - 536,1552, 552,1296, 560,784, 568,1808, 584,1168, 592,656, 600,1680, 616,1424, 624,912, - 632,1936, 648,1104, 664,1616, 680,1360, 688,848, 696,1872, 712,1232, 728,1744, 744,1488, - 752,976, 760,2000, 776,1072, 792,1584, 808,1328, 824,1840, 840,1200, 856,1712, 872,1456, - 880,944, 888,1968, 904,1136, 920,1648, 936,1392, 952,1904, 968,1264, 984,1776, 1000,1520, - 1016,2032, 1048,1544, 1064,1288, 1080,1800, 1096,1160, 1112,1672, 1128,1416, 1144,1928, - 1176,1608, 1192,1352, 1208,1864, 1240,1736, 1256,1480, 1272,1992, 1304,1576, 1336,1832, - 1368,1704, 1384,1448, 1400,1960, 1432,1640, 1464,1896, 1496,1768, 1528,2024, 1592,1816, - 1624,1688, 1656,1944, 1720,1880, 1784,2008, 1912,1976 -}; +const uint16_t armBitRevIndexTable_fixed_512 + [ARMBITREVINDEXTABLE_FIXED_512_TABLE_LENGTH] = { + /* 4x2, size 480 */ + 8, 2048, 16, 1024, 24, 3072, 32, 512, 40, 2560, 48, 1536, + 56, 3584, 64, 256, 72, 2304, 80, 1280, 88, 3328, 96, 768, + 104, 2816, 112, 1792, 120, 3840, 136, 2176, 144, 1152, 152, 3200, + 160, 640, 168, 2688, 176, 1664, 184, 3712, 192, 384, 200, 2432, + 208, 1408, 216, 3456, 224, 896, 232, 2944, 240, 1920, 248, 3968, + 264, 2112, 272, 1088, 280, 3136, 288, 576, 296, 2624, 304, 1600, + 312, 3648, 328, 2368, 336, 1344, 344, 3392, 352, 832, 360, 2880, + 368, 1856, 376, 3904, 392, 2240, 400, 1216, 408, 3264, 416, 704, + 424, 2752, 432, 1728, 440, 3776, 456, 2496, 464, 1472, 472, 3520, + 480, 960, 488, 3008, 496, 1984, 504, 4032, 520, 2080, 528, 1056, + 536, 3104, 552, 2592, 560, 1568, 568, 3616, 584, 2336, 592, 1312, + 600, 3360, 608, 800, 616, 2848, 624, 1824, 632, 3872, 648, 2208, + 656, 1184, 664, 3232, 680, 2720, 688, 1696, 696, 3744, 712, 2464, + 720, 1440, 728, 3488, 736, 928, 744, 2976, 752, 1952, 760, 4000, + 776, 2144, 784, 1120, 792, 3168, 808, 2656, 816, 1632, 824, 3680, + 840, 2400, 848, 1376, 856, 3424, 872, 2912, 880, 1888, 888, 3936, + 904, 2272, 912, 1248, 920, 3296, 936, 2784, 944, 1760, 952, 3808, + 968, 2528, 976, 1504, 984, 3552, 1000, 3040, 1008, 2016, 1016, 4064, + 1032, 2064, 1048, 3088, 1064, 2576, 1072, 1552, 1080, 3600, 1096, 2320, + 1104, 1296, 1112, 3344, 1128, 2832, 1136, 1808, 1144, 3856, 1160, 2192, + 1176, 3216, 1192, 2704, 1200, 1680, 1208, 3728, 1224, 2448, 1232, 1424, + 1240, 3472, 1256, 2960, 1264, 1936, 1272, 3984, 1288, 2128, 1304, 3152, + 1320, 2640, 1328, 1616, 1336, 3664, 1352, 2384, 1368, 3408, 1384, 2896, + 1392, 1872, 1400, 3920, 1416, 2256, 1432, 3280, 1448, 2768, 1456, 1744, + 1464, 3792, 1480, 2512, 1496, 3536, 1512, 3024, 1520, 2000, 1528, 4048, + 1544, 2096, 1560, 3120, 1576, 2608, 1592, 3632, 1608, 2352, 1624, 3376, + 1640, 2864, 1648, 1840, 1656, 3888, 1672, 2224, 1688, 3248, 1704, 2736, + 1720, 3760, 1736, 2480, 1752, 3504, 1768, 2992, 1776, 1968, 1784, 4016, + 1800, 2160, 1816, 3184, 1832, 2672, 1848, 3696, 1864, 2416, 1880, 3440, + 1896, 2928, 1912, 3952, 1928, 2288, 1944, 3312, 1960, 2800, 1976, 3824, + 1992, 2544, 2008, 3568, 2024, 3056, 2040, 4080, 2072, 3080, 2088, 2568, + 2104, 3592, 2120, 2312, 2136, 3336, 2152, 2824, 2168, 3848, 2200, 3208, + 2216, 2696, 2232, 3720, 2248, 2440, 2264, 3464, 2280, 2952, 2296, 3976, + 2328, 3144, 2344, 2632, 2360, 3656, 2392, 3400, 2408, 2888, 2424, 3912, + 2456, 3272, 2472, 2760, 2488, 3784, 2520, 3528, 2536, 3016, 2552, 4040, + 2584, 3112, 2616, 3624, 2648, 3368, 2664, 2856, 2680, 3880, 2712, 3240, + 2744, 3752, 2776, 3496, 2792, 2984, 2808, 4008, 2840, 3176, 2872, 3688, + 2904, 3432, 2936, 3944, 2968, 3304, 3000, 3816, 3032, 3560, 3064, 4072, + 3128, 3608, 3160, 3352, 3192, 3864, 3256, 3736, 3288, 3480, 3320, 3992, + 3384, 3672, 3448, 3928, 3512, 3800, 3576, 4056, 3704, 3896, 3832, 4024}; -const uint16_t armBitRevIndexTable_fixed_512[ARMBITREVINDEXTABLE_FIXED_512_TABLE_LENGTH] = -{ - /* 4x2, size 480 */ - 8,2048, 16,1024, 24,3072, 32,512, 40,2560, 48,1536, 56,3584, 64,256, 72,2304, 80,1280, - 88,3328, 96,768, 104,2816, 112,1792, 120,3840, 136,2176, 144,1152, 152,3200, 160,640, - 168,2688, 176,1664, 184,3712, 192,384, 200,2432, 208,1408, 216,3456, 224,896, 232,2944, - 240,1920, 248,3968, 264,2112, 272,1088, 280,3136, 288,576, 296,2624, 304,1600, 312,3648, - 328,2368, 336,1344, 344,3392, 352,832, 360,2880, 368,1856, 376,3904, 392,2240, 400,1216, - 408,3264, 416,704, 424,2752, 432,1728, 440,3776, 456,2496, 464,1472, 472,3520, 480,960, - 488,3008, 496,1984, 504,4032, 520,2080, 528,1056, 536,3104, 552,2592, 560,1568, 568,3616, - 584,2336, 592,1312, 600,3360, 608,800, 616,2848, 624,1824, 632,3872, 648,2208, 656,1184, - 664,3232, 680,2720, 688,1696, 696,3744, 712,2464, 720,1440, 728,3488, 736,928, 744,2976, - 752,1952, 760,4000, 776,2144, 784,1120, 792,3168, 808,2656, 816,1632, 824,3680, 840,2400, - 848,1376, 856,3424, 872,2912, 880,1888, 888,3936, 904,2272, 912,1248, 920,3296, 936,2784, - 944,1760, 952,3808, 968,2528, 976,1504, 984,3552, 1000,3040, 1008,2016, 1016,4064, - 1032,2064, 1048,3088, 1064,2576, 1072,1552, 1080,3600, 1096,2320, 1104,1296, 1112,3344, - 1128,2832, 1136,1808, 1144,3856, 1160,2192, 1176,3216, 1192,2704, 1200,1680, 1208,3728, - 1224,2448, 1232,1424, 1240,3472, 1256,2960, 1264,1936, 1272,3984, 1288,2128, 1304,3152, - 1320,2640, 1328,1616, 1336,3664, 1352,2384, 1368,3408, 1384,2896, 1392,1872, 1400,3920, - 1416,2256, 1432,3280, 1448,2768, 1456,1744, 1464,3792, 1480,2512, 1496,3536, 1512,3024, - 1520,2000, 1528,4048, 1544,2096, 1560,3120, 1576,2608, 1592,3632, 1608,2352, 1624,3376, - 1640,2864, 1648,1840, 1656,3888, 1672,2224, 1688,3248, 1704,2736, 1720,3760, 1736,2480, - 1752,3504, 1768,2992, 1776,1968, 1784,4016, 1800,2160, 1816,3184, 1832,2672, 1848,3696, - 1864,2416, 1880,3440, 1896,2928, 1912,3952, 1928,2288, 1944,3312, 1960,2800, 1976,3824, - 1992,2544, 2008,3568, 2024,3056, 2040,4080, 2072,3080, 2088,2568, 2104,3592, 2120,2312, - 2136,3336, 2152,2824, 2168,3848, 2200,3208, 2216,2696, 2232,3720, 2248,2440, 2264,3464, - 2280,2952, 2296,3976, 2328,3144, 2344,2632, 2360,3656, 2392,3400, 2408,2888, 2424,3912, - 2456,3272, 2472,2760, 2488,3784, 2520,3528, 2536,3016, 2552,4040, 2584,3112, 2616,3624, - 2648,3368, 2664,2856, 2680,3880, 2712,3240, 2744,3752, 2776,3496, 2792,2984, 2808,4008, - 2840,3176, 2872,3688, 2904,3432, 2936,3944, 2968,3304, 3000,3816, 3032,3560, 3064,4072, - 3128,3608, 3160,3352, 3192,3864, 3256,3736, 3288,3480, 3320,3992, 3384,3672, 3448,3928, - 3512,3800, 3576,4056, 3704,3896, 3832,4024 -}; +const uint16_t armBitRevIndexTable_fixed_1024 + [ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH] = { + /* radix 4, size 992 */ + 8, 4096, 16, 2048, 24, 6144, 32, 1024, 40, 5120, 48, 3072, + 56, 7168, 64, 512, 72, 4608, 80, 2560, 88, 6656, 96, 1536, + 104, 5632, 112, 3584, 120, 7680, 128, 256, 136, 4352, 144, 2304, + 152, 6400, 160, 1280, 168, 5376, 176, 3328, 184, 7424, 192, 768, + 200, 4864, 208, 2816, 216, 6912, 224, 1792, 232, 5888, 240, 3840, + 248, 7936, 264, 4224, 272, 2176, 280, 6272, 288, 1152, 296, 5248, + 304, 3200, 312, 7296, 320, 640, 328, 4736, 336, 2688, 344, 6784, + 352, 1664, 360, 5760, 368, 3712, 376, 7808, 392, 4480, 400, 2432, + 408, 6528, 416, 1408, 424, 5504, 432, 3456, 440, 7552, 448, 896, + 456, 4992, 464, 2944, 472, 7040, 480, 1920, 488, 6016, 496, 3968, + 504, 8064, 520, 4160, 528, 2112, 536, 6208, 544, 1088, 552, 5184, + 560, 3136, 568, 7232, 584, 4672, 592, 2624, 600, 6720, 608, 1600, + 616, 5696, 624, 3648, 632, 7744, 648, 4416, 656, 2368, 664, 6464, + 672, 1344, 680, 5440, 688, 3392, 696, 7488, 704, 832, 712, 4928, + 720, 2880, 728, 6976, 736, 1856, 744, 5952, 752, 3904, 760, 8000, + 776, 4288, 784, 2240, 792, 6336, 800, 1216, 808, 5312, 816, 3264, + 824, 7360, 840, 4800, 848, 2752, 856, 6848, 864, 1728, 872, 5824, + 880, 3776, 888, 7872, 904, 4544, 912, 2496, 920, 6592, 928, 1472, + 936, 5568, 944, 3520, 952, 7616, 968, 5056, 976, 3008, 984, 7104, + 992, 1984, 1000, 6080, 1008, 4032, 1016, 8128, 1032, 4128, 1040, 2080, + 1048, 6176, 1064, 5152, 1072, 3104, 1080, 7200, 1096, 4640, 1104, 2592, + 1112, 6688, 1120, 1568, 1128, 5664, 1136, 3616, 1144, 7712, 1160, 4384, + 1168, 2336, 1176, 6432, 1184, 1312, 1192, 5408, 1200, 3360, 1208, 7456, + 1224, 4896, 1232, 2848, 1240, 6944, 1248, 1824, 1256, 5920, 1264, 3872, + 1272, 7968, 1288, 4256, 1296, 2208, 1304, 6304, 1320, 5280, 1328, 3232, + 1336, 7328, 1352, 4768, 1360, 2720, 1368, 6816, 1376, 1696, 1384, 5792, + 1392, 3744, 1400, 7840, 1416, 4512, 1424, 2464, 1432, 6560, 1448, 5536, + 1456, 3488, 1464, 7584, 1480, 5024, 1488, 2976, 1496, 7072, 1504, 1952, + 1512, 6048, 1520, 4000, 1528, 8096, 1544, 4192, 1552, 2144, 1560, 6240, + 1576, 5216, 1584, 3168, 1592, 7264, 1608, 4704, 1616, 2656, 1624, 6752, + 1640, 5728, 1648, 3680, 1656, 7776, 1672, 4448, 1680, 2400, 1688, 6496, + 1704, 5472, 1712, 3424, 1720, 7520, 1736, 4960, 1744, 2912, 1752, 7008, + 1760, 1888, 1768, 5984, 1776, 3936, 1784, 8032, 1800, 4320, 1808, 2272, + 1816, 6368, 1832, 5344, 1840, 3296, 1848, 7392, 1864, 4832, 1872, 2784, + 1880, 6880, 1896, 5856, 1904, 3808, 1912, 7904, 1928, 4576, 1936, 2528, + 1944, 6624, 1960, 5600, 1968, 3552, 1976, 7648, 1992, 5088, 2000, 3040, + 2008, 7136, 2024, 6112, 2032, 4064, 2040, 8160, 2056, 4112, 2072, 6160, + 2088, 5136, 2096, 3088, 2104, 7184, 2120, 4624, 2128, 2576, 2136, 6672, + 2152, 5648, 2160, 3600, 2168, 7696, 2184, 4368, 2192, 2320, 2200, 6416, + 2216, 5392, 2224, 3344, 2232, 7440, 2248, 4880, 2256, 2832, 2264, 6928, + 2280, 5904, 2288, 3856, 2296, 7952, 2312, 4240, 2328, 6288, 2344, 5264, + 2352, 3216, 2360, 7312, 2376, 4752, 2384, 2704, 2392, 6800, 2408, 5776, + 2416, 3728, 2424, 7824, 2440, 4496, 2456, 6544, 2472, 5520, 2480, 3472, + 2488, 7568, 2504, 5008, 2512, 2960, 2520, 7056, 2536, 6032, 2544, 3984, + 2552, 8080, 2568, 4176, 2584, 6224, 2600, 5200, 2608, 3152, 2616, 7248, + 2632, 4688, 2648, 6736, 2664, 5712, 2672, 3664, 2680, 7760, 2696, 4432, + 2712, 6480, 2728, 5456, 2736, 3408, 2744, 7504, 2760, 4944, 2768, 2896, + 2776, 6992, 2792, 5968, 2800, 3920, 2808, 8016, 2824, 4304, 2840, 6352, + 2856, 5328, 2864, 3280, 2872, 7376, 2888, 4816, 2904, 6864, 2920, 5840, + 2928, 3792, 2936, 7888, 2952, 4560, 2968, 6608, 2984, 5584, 2992, 3536, + 3000, 7632, 3016, 5072, 3032, 7120, 3048, 6096, 3056, 4048, 3064, 8144, + 3080, 4144, 3096, 6192, 3112, 5168, 3128, 7216, 3144, 4656, 3160, 6704, + 3176, 5680, 3184, 3632, 3192, 7728, 3208, 4400, 3224, 6448, 3240, 5424, + 3248, 3376, 3256, 7472, 3272, 4912, 3288, 6960, 3304, 5936, 3312, 3888, + 3320, 7984, 3336, 4272, 3352, 6320, 3368, 5296, 3384, 7344, 3400, 4784, + 3416, 6832, 3432, 5808, 3440, 3760, 3448, 7856, 3464, 4528, 3480, 6576, + 3496, 5552, 3512, 7600, 3528, 5040, 3544, 7088, 3560, 6064, 3568, 4016, + 3576, 8112, 3592, 4208, 3608, 6256, 3624, 5232, 3640, 7280, 3656, 4720, + 3672, 6768, 3688, 5744, 3704, 7792, 3720, 4464, 3736, 6512, 3752, 5488, + 3768, 7536, 3784, 4976, 3800, 7024, 3816, 6000, 3824, 3952, 3832, 8048, + 3848, 4336, 3864, 6384, 3880, 5360, 3896, 7408, 3912, 4848, 3928, 6896, + 3944, 5872, 3960, 7920, 3976, 4592, 3992, 6640, 4008, 5616, 4024, 7664, + 4040, 5104, 4056, 7152, 4072, 6128, 4088, 8176, 4120, 6152, 4136, 5128, + 4152, 7176, 4168, 4616, 4184, 6664, 4200, 5640, 4216, 7688, 4232, 4360, + 4248, 6408, 4264, 5384, 4280, 7432, 4296, 4872, 4312, 6920, 4328, 5896, + 4344, 7944, 4376, 6280, 4392, 5256, 4408, 7304, 4424, 4744, 4440, 6792, + 4456, 5768, 4472, 7816, 4504, 6536, 4520, 5512, 4536, 7560, 4552, 5000, + 4568, 7048, 4584, 6024, 4600, 8072, 4632, 6216, 4648, 5192, 4664, 7240, + 4696, 6728, 4712, 5704, 4728, 7752, 4760, 6472, 4776, 5448, 4792, 7496, + 4808, 4936, 4824, 6984, 4840, 5960, 4856, 8008, 4888, 6344, 4904, 5320, + 4920, 7368, 4952, 6856, 4968, 5832, 4984, 7880, 5016, 6600, 5032, 5576, + 5048, 7624, 5080, 7112, 5096, 6088, 5112, 8136, 5144, 6184, 5176, 7208, + 5208, 6696, 5224, 5672, 5240, 7720, 5272, 6440, 5288, 5416, 5304, 7464, + 5336, 6952, 5352, 5928, 5368, 7976, 5400, 6312, 5432, 7336, 5464, 6824, + 5480, 5800, 5496, 7848, 5528, 6568, 5560, 7592, 5592, 7080, 5608, 6056, + 5624, 8104, 5656, 6248, 5688, 7272, 5720, 6760, 5752, 7784, 5784, 6504, + 5816, 7528, 5848, 7016, 5864, 5992, 5880, 8040, 5912, 6376, 5944, 7400, + 5976, 6888, 6008, 7912, 6040, 6632, 6072, 7656, 6104, 7144, 6136, 8168, + 6200, 7192, 6232, 6680, 6264, 7704, 6296, 6424, 6328, 7448, 6360, 6936, + 6392, 7960, 6456, 7320, 6488, 6808, 6520, 7832, 6584, 7576, 6616, 7064, + 6648, 8088, 6712, 7256, 6776, 7768, 6840, 7512, 6872, 7000, 6904, 8024, + 6968, 7384, 7032, 7896, 7096, 7640, 7160, 8152, 7288, 7736, 7352, 7480, + 7416, 7992, 7544, 7864, 7672, 8120, 7928, 8056}; -const uint16_t armBitRevIndexTable_fixed_1024[ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH] = -{ - /* radix 4, size 992 */ - 8,4096, 16,2048, 24,6144, 32,1024, 40,5120, 48,3072, 56,7168, 64,512, 72,4608, - 80,2560, 88,6656, 96,1536, 104,5632, 112,3584, 120,7680, 128,256, 136,4352, - 144,2304, 152,6400, 160,1280, 168,5376, 176,3328, 184,7424, 192,768, 200,4864, - 208,2816, 216,6912, 224,1792, 232,5888, 240,3840, 248,7936, 264,4224, 272,2176, - 280,6272, 288,1152, 296,5248, 304,3200, 312,7296, 320,640, 328,4736, 336,2688, - 344,6784, 352,1664, 360,5760, 368,3712, 376,7808, 392,4480, 400,2432, 408,6528, - 416,1408, 424,5504, 432,3456, 440,7552, 448,896, 456,4992, 464,2944, 472,7040, - 480,1920, 488,6016, 496,3968, 504,8064, 520,4160, 528,2112, 536,6208, 544,1088, - 552,5184, 560,3136, 568,7232, 584,4672, 592,2624, 600,6720, 608,1600, 616,5696, - 624,3648, 632,7744, 648,4416, 656,2368, 664,6464, 672,1344, 680,5440, 688,3392, - 696,7488, 704,832, 712,4928, 720,2880, 728,6976, 736,1856, 744,5952, 752,3904, - 760,8000, 776,4288, 784,2240, 792,6336, 800,1216, 808,5312, 816,3264, 824,7360, - 840,4800, 848,2752, 856,6848, 864,1728, 872,5824, 880,3776, 888,7872, 904,4544, - 912,2496, 920,6592, 928,1472, 936,5568, 944,3520, 952,7616, 968,5056, 976,3008, - 984,7104, 992,1984, 1000,6080, 1008,4032, 1016,8128, 1032,4128, 1040,2080, - 1048,6176, 1064,5152, 1072,3104, 1080,7200, 1096,4640, 1104,2592, 1112,6688, - 1120,1568, 1128,5664, 1136,3616, 1144,7712, 1160,4384, 1168,2336, 1176,6432, - 1184,1312, 1192,5408, 1200,3360, 1208,7456, 1224,4896, 1232,2848, 1240,6944, - 1248,1824, 1256,5920, 1264,3872, 1272,7968, 1288,4256, 1296,2208, 1304,6304, - 1320,5280, 1328,3232, 1336,7328, 1352,4768, 1360,2720, 1368,6816, 1376,1696, - 1384,5792, 1392,3744, 1400,7840, 1416,4512, 1424,2464, 1432,6560, 1448,5536, - 1456,3488, 1464,7584, 1480,5024, 1488,2976, 1496,7072, 1504,1952, 1512,6048, - 1520,4000, 1528,8096, 1544,4192, 1552,2144, 1560,6240, 1576,5216, 1584,3168, - 1592,7264, 1608,4704, 1616,2656, 1624,6752, 1640,5728, 1648,3680, 1656,7776, - 1672,4448, 1680,2400, 1688,6496, 1704,5472, 1712,3424, 1720,7520, 1736,4960, - 1744,2912, 1752,7008, 1760,1888, 1768,5984, 1776,3936, 1784,8032, 1800,4320, - 1808,2272, 1816,6368, 1832,5344, 1840,3296, 1848,7392, 1864,4832, 1872,2784, - 1880,6880, 1896,5856, 1904,3808, 1912,7904, 1928,4576, 1936,2528, 1944,6624, - 1960,5600, 1968,3552, 1976,7648, 1992,5088, 2000,3040, 2008,7136, 2024,6112, - 2032,4064, 2040,8160, 2056,4112, 2072,6160, 2088,5136, 2096,3088, 2104,7184, - 2120,4624, 2128,2576, 2136,6672, 2152,5648, 2160,3600, 2168,7696, 2184,4368, - 2192,2320, 2200,6416, 2216,5392, 2224,3344, 2232,7440, 2248,4880, 2256,2832, - 2264,6928, 2280,5904, 2288,3856, 2296,7952, 2312,4240, 2328,6288, 2344,5264, - 2352,3216, 2360,7312, 2376,4752, 2384,2704, 2392,6800, 2408,5776, 2416,3728, - 2424,7824, 2440,4496, 2456,6544, 2472,5520, 2480,3472, 2488,7568, 2504,5008, - 2512,2960, 2520,7056, 2536,6032, 2544,3984, 2552,8080, 2568,4176, 2584,6224, - 2600,5200, 2608,3152, 2616,7248, 2632,4688, 2648,6736, 2664,5712, 2672,3664, - 2680,7760, 2696,4432, 2712,6480, 2728,5456, 2736,3408, 2744,7504, 2760,4944, - 2768,2896, 2776,6992, 2792,5968, 2800,3920, 2808,8016, 2824,4304, 2840,6352, - 2856,5328, 2864,3280, 2872,7376, 2888,4816, 2904,6864, 2920,5840, 2928,3792, - 2936,7888, 2952,4560, 2968,6608, 2984,5584, 2992,3536, 3000,7632, 3016,5072, - 3032,7120, 3048,6096, 3056,4048, 3064,8144, 3080,4144, 3096,6192, 3112,5168, - 3128,7216, 3144,4656, 3160,6704, 3176,5680, 3184,3632, 3192,7728, 3208,4400, - 3224,6448, 3240,5424, 3248,3376, 3256,7472, 3272,4912, 3288,6960, 3304,5936, - 3312,3888, 3320,7984, 3336,4272, 3352,6320, 3368,5296, 3384,7344, 3400,4784, - 3416,6832, 3432,5808, 3440,3760, 3448,7856, 3464,4528, 3480,6576, 3496,5552, - 3512,7600, 3528,5040, 3544,7088, 3560,6064, 3568,4016, 3576,8112, 3592,4208, - 3608,6256, 3624,5232, 3640,7280, 3656,4720, 3672,6768, 3688,5744, 3704,7792, - 3720,4464, 3736,6512, 3752,5488, 3768,7536, 3784,4976, 3800,7024, 3816,6000, - 3824,3952, 3832,8048, 3848,4336, 3864,6384, 3880,5360, 3896,7408, 3912,4848, - 3928,6896, 3944,5872, 3960,7920, 3976,4592, 3992,6640, 4008,5616, 4024,7664, - 4040,5104, 4056,7152, 4072,6128, 4088,8176, 4120,6152, 4136,5128, 4152,7176, - 4168,4616, 4184,6664, 4200,5640, 4216,7688, 4232,4360, 4248,6408, 4264,5384, - 4280,7432, 4296,4872, 4312,6920, 4328,5896, 4344,7944, 4376,6280, 4392,5256, - 4408,7304, 4424,4744, 4440,6792, 4456,5768, 4472,7816, 4504,6536, 4520,5512, - 4536,7560, 4552,5000, 4568,7048, 4584,6024, 4600,8072, 4632,6216, 4648,5192, - 4664,7240, 4696,6728, 4712,5704, 4728,7752, 4760,6472, 4776,5448, 4792,7496, - 4808,4936, 4824,6984, 4840,5960, 4856,8008, 4888,6344, 4904,5320, 4920,7368, - 4952,6856, 4968,5832, 4984,7880, 5016,6600, 5032,5576, 5048,7624, 5080,7112, - 5096,6088, 5112,8136, 5144,6184, 5176,7208, 5208,6696, 5224,5672, 5240,7720, - 5272,6440, 5288,5416, 5304,7464, 5336,6952, 5352,5928, 5368,7976, 5400,6312, - 5432,7336, 5464,6824, 5480,5800, 5496,7848, 5528,6568, 5560,7592, 5592,7080, - 5608,6056, 5624,8104, 5656,6248, 5688,7272, 5720,6760, 5752,7784, 5784,6504, - 5816,7528, 5848,7016, 5864,5992, 5880,8040, 5912,6376, 5944,7400, 5976,6888, - 6008,7912, 6040,6632, 6072,7656, 6104,7144, 6136,8168, 6200,7192, 6232,6680, - 6264,7704, 6296,6424, 6328,7448, 6360,6936, 6392,7960, 6456,7320, 6488,6808, - 6520,7832, 6584,7576, 6616,7064, 6648,8088, 6712,7256, 6776,7768, 6840,7512, - 6872,7000, 6904,8024, 6968,7384, 7032,7896, 7096,7640, 7160,8152, 7288,7736, - 7352,7480, 7416,7992, 7544,7864, 7672,8120, 7928,8056 -}; +const uint16_t armBitRevIndexTable_fixed_2048 + [ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH] = { + /* 4x2, size 1984 */ + 8, 8192, 16, 4096, 24, 12288, 32, 2048, 40, 10240, + 48, 6144, 56, 14336, 64, 1024, 72, 9216, 80, 5120, + 88, 13312, 96, 3072, 104, 11264, 112, 7168, 120, 15360, + 128, 512, 136, 8704, 144, 4608, 152, 12800, 160, 2560, + 168, 10752, 176, 6656, 184, 14848, 192, 1536, 200, 9728, + 208, 5632, 216, 13824, 224, 3584, 232, 11776, 240, 7680, + 248, 15872, 264, 8448, 272, 4352, 280, 12544, 288, 2304, + 296, 10496, 304, 6400, 312, 14592, 320, 1280, 328, 9472, + 336, 5376, 344, 13568, 352, 3328, 360, 11520, 368, 7424, + 376, 15616, 384, 768, 392, 8960, 400, 4864, 408, 13056, + 416, 2816, 424, 11008, 432, 6912, 440, 15104, 448, 1792, + 456, 9984, 464, 5888, 472, 14080, 480, 3840, 488, 12032, + 496, 7936, 504, 16128, 520, 8320, 528, 4224, 536, 12416, + 544, 2176, 552, 10368, 560, 6272, 568, 14464, 576, 1152, + 584, 9344, 592, 5248, 600, 13440, 608, 3200, 616, 11392, + 624, 7296, 632, 15488, 648, 8832, 656, 4736, 664, 12928, + 672, 2688, 680, 10880, 688, 6784, 696, 14976, 704, 1664, + 712, 9856, 720, 5760, 728, 13952, 736, 3712, 744, 11904, + 752, 7808, 760, 16000, 776, 8576, 784, 4480, 792, 12672, + 800, 2432, 808, 10624, 816, 6528, 824, 14720, 832, 1408, + 840, 9600, 848, 5504, 856, 13696, 864, 3456, 872, 11648, + 880, 7552, 888, 15744, 904, 9088, 912, 4992, 920, 13184, + 928, 2944, 936, 11136, 944, 7040, 952, 15232, 960, 1920, + 968, 10112, 976, 6016, 984, 14208, 992, 3968, 1000, 12160, + 1008, 8064, 1016, 16256, 1032, 8256, 1040, 4160, 1048, 12352, + 1056, 2112, 1064, 10304, 1072, 6208, 1080, 14400, 1096, 9280, + 1104, 5184, 1112, 13376, 1120, 3136, 1128, 11328, 1136, 7232, + 1144, 15424, 1160, 8768, 1168, 4672, 1176, 12864, 1184, 2624, + 1192, 10816, 1200, 6720, 1208, 14912, 1216, 1600, 1224, 9792, + 1232, 5696, 1240, 13888, 1248, 3648, 1256, 11840, 1264, 7744, + 1272, 15936, 1288, 8512, 1296, 4416, 1304, 12608, 1312, 2368, + 1320, 10560, 1328, 6464, 1336, 14656, 1352, 9536, 1360, 5440, + 1368, 13632, 1376, 3392, 1384, 11584, 1392, 7488, 1400, 15680, + 1416, 9024, 1424, 4928, 1432, 13120, 1440, 2880, 1448, 11072, + 1456, 6976, 1464, 15168, 1472, 1856, 1480, 10048, 1488, 5952, + 1496, 14144, 1504, 3904, 1512, 12096, 1520, 8000, 1528, 16192, + 1544, 8384, 1552, 4288, 1560, 12480, 1568, 2240, 1576, 10432, + 1584, 6336, 1592, 14528, 1608, 9408, 1616, 5312, 1624, 13504, + 1632, 3264, 1640, 11456, 1648, 7360, 1656, 15552, 1672, 8896, + 1680, 4800, 1688, 12992, 1696, 2752, 1704, 10944, 1712, 6848, + 1720, 15040, 1736, 9920, 1744, 5824, 1752, 14016, 1760, 3776, + 1768, 11968, 1776, 7872, 1784, 16064, 1800, 8640, 1808, 4544, + 1816, 12736, 1824, 2496, 1832, 10688, 1840, 6592, 1848, 14784, + 1864, 9664, 1872, 5568, 1880, 13760, 1888, 3520, 1896, 11712, + 1904, 7616, 1912, 15808, 1928, 9152, 1936, 5056, 1944, 13248, + 1952, 3008, 1960, 11200, 1968, 7104, 1976, 15296, 1992, 10176, + 2000, 6080, 2008, 14272, 2016, 4032, 2024, 12224, 2032, 8128, + 2040, 16320, 2056, 8224, 2064, 4128, 2072, 12320, 2088, 10272, + 2096, 6176, 2104, 14368, 2120, 9248, 2128, 5152, 2136, 13344, + 2144, 3104, 2152, 11296, 2160, 7200, 2168, 15392, 2184, 8736, + 2192, 4640, 2200, 12832, 2208, 2592, 2216, 10784, 2224, 6688, + 2232, 14880, 2248, 9760, 2256, 5664, 2264, 13856, 2272, 3616, + 2280, 11808, 2288, 7712, 2296, 15904, 2312, 8480, 2320, 4384, + 2328, 12576, 2344, 10528, 2352, 6432, 2360, 14624, 2376, 9504, + 2384, 5408, 2392, 13600, 2400, 3360, 2408, 11552, 2416, 7456, + 2424, 15648, 2440, 8992, 2448, 4896, 2456, 13088, 2464, 2848, + 2472, 11040, 2480, 6944, 2488, 15136, 2504, 10016, 2512, 5920, + 2520, 14112, 2528, 3872, 2536, 12064, 2544, 7968, 2552, 16160, + 2568, 8352, 2576, 4256, 2584, 12448, 2600, 10400, 2608, 6304, + 2616, 14496, 2632, 9376, 2640, 5280, 2648, 13472, 2656, 3232, + 2664, 11424, 2672, 7328, 2680, 15520, 2696, 8864, 2704, 4768, + 2712, 12960, 2728, 10912, 2736, 6816, 2744, 15008, 2760, 9888, + 2768, 5792, 2776, 13984, 2784, 3744, 2792, 11936, 2800, 7840, + 2808, 16032, 2824, 8608, 2832, 4512, 2840, 12704, 2856, 10656, + 2864, 6560, 2872, 14752, 2888, 9632, 2896, 5536, 2904, 13728, + 2912, 3488, 2920, 11680, 2928, 7584, 2936, 15776, 2952, 9120, + 2960, 5024, 2968, 13216, 2984, 11168, 2992, 7072, 3000, 15264, + 3016, 10144, 3024, 6048, 3032, 14240, 3040, 4000, 3048, 12192, + 3056, 8096, 3064, 16288, 3080, 8288, 3088, 4192, 3096, 12384, + 3112, 10336, 3120, 6240, 3128, 14432, 3144, 9312, 3152, 5216, + 3160, 13408, 3176, 11360, 3184, 7264, 3192, 15456, 3208, 8800, + 3216, 4704, 3224, 12896, 3240, 10848, 3248, 6752, 3256, 14944, + 3272, 9824, 3280, 5728, 3288, 13920, 3296, 3680, 3304, 11872, + 3312, 7776, 3320, 15968, 3336, 8544, 3344, 4448, 3352, 12640, + 3368, 10592, 3376, 6496, 3384, 14688, 3400, 9568, 3408, 5472, + 3416, 13664, 3432, 11616, 3440, 7520, 3448, 15712, 3464, 9056, + 3472, 4960, 3480, 13152, 3496, 11104, 3504, 7008, 3512, 15200, + 3528, 10080, 3536, 5984, 3544, 14176, 3552, 3936, 3560, 12128, + 3568, 8032, 3576, 16224, 3592, 8416, 3600, 4320, 3608, 12512, + 3624, 10464, 3632, 6368, 3640, 14560, 3656, 9440, 3664, 5344, + 3672, 13536, 3688, 11488, 3696, 7392, 3704, 15584, 3720, 8928, + 3728, 4832, 3736, 13024, 3752, 10976, 3760, 6880, 3768, 15072, + 3784, 9952, 3792, 5856, 3800, 14048, 3816, 12000, 3824, 7904, + 3832, 16096, 3848, 8672, 3856, 4576, 3864, 12768, 3880, 10720, + 3888, 6624, 3896, 14816, 3912, 9696, 3920, 5600, 3928, 13792, + 3944, 11744, 3952, 7648, 3960, 15840, 3976, 9184, 3984, 5088, + 3992, 13280, 4008, 11232, 4016, 7136, 4024, 15328, 4040, 10208, + 4048, 6112, 4056, 14304, 4072, 12256, 4080, 8160, 4088, 16352, + 4104, 8208, 4120, 12304, 4136, 10256, 4144, 6160, 4152, 14352, + 4168, 9232, 4176, 5136, 4184, 13328, 4200, 11280, 4208, 7184, + 4216, 15376, 4232, 8720, 4240, 4624, 4248, 12816, 4264, 10768, + 4272, 6672, 4280, 14864, 4296, 9744, 4304, 5648, 4312, 13840, + 4328, 11792, 4336, 7696, 4344, 15888, 4360, 8464, 4376, 12560, + 4392, 10512, 4400, 6416, 4408, 14608, 4424, 9488, 4432, 5392, + 4440, 13584, 4456, 11536, 4464, 7440, 4472, 15632, 4488, 8976, + 4496, 4880, 4504, 13072, 4520, 11024, 4528, 6928, 4536, 15120, + 4552, 10000, 4560, 5904, 4568, 14096, 4584, 12048, 4592, 7952, + 4600, 16144, 4616, 8336, 4632, 12432, 4648, 10384, 4656, 6288, + 4664, 14480, 4680, 9360, 4688, 5264, 4696, 13456, 4712, 11408, + 4720, 7312, 4728, 15504, 4744, 8848, 4760, 12944, 4776, 10896, + 4784, 6800, 4792, 14992, 4808, 9872, 4816, 5776, 4824, 13968, + 4840, 11920, 4848, 7824, 4856, 16016, 4872, 8592, 4888, 12688, + 4904, 10640, 4912, 6544, 4920, 14736, 4936, 9616, 4944, 5520, + 4952, 13712, 4968, 11664, 4976, 7568, 4984, 15760, 5000, 9104, + 5016, 13200, 5032, 11152, 5040, 7056, 5048, 15248, 5064, 10128, + 5072, 6032, 5080, 14224, 5096, 12176, 5104, 8080, 5112, 16272, + 5128, 8272, 5144, 12368, 5160, 10320, 5168, 6224, 5176, 14416, + 5192, 9296, 5208, 13392, 5224, 11344, 5232, 7248, 5240, 15440, + 5256, 8784, 5272, 12880, 5288, 10832, 5296, 6736, 5304, 14928, + 5320, 9808, 5328, 5712, 5336, 13904, 5352, 11856, 5360, 7760, + 5368, 15952, 5384, 8528, 5400, 12624, 5416, 10576, 5424, 6480, + 5432, 14672, 5448, 9552, 5464, 13648, 5480, 11600, 5488, 7504, + 5496, 15696, 5512, 9040, 5528, 13136, 5544, 11088, 5552, 6992, + 5560, 15184, 5576, 10064, 5584, 5968, 5592, 14160, 5608, 12112, + 5616, 8016, 5624, 16208, 5640, 8400, 5656, 12496, 5672, 10448, + 5680, 6352, 5688, 14544, 5704, 9424, 5720, 13520, 5736, 11472, + 5744, 7376, 5752, 15568, 5768, 8912, 5784, 13008, 5800, 10960, + 5808, 6864, 5816, 15056, 5832, 9936, 5848, 14032, 5864, 11984, + 5872, 7888, 5880, 16080, 5896, 8656, 5912, 12752, 5928, 10704, + 5936, 6608, 5944, 14800, 5960, 9680, 5976, 13776, 5992, 11728, + 6000, 7632, 6008, 15824, 6024, 9168, 6040, 13264, 6056, 11216, + 6064, 7120, 6072, 15312, 6088, 10192, 6104, 14288, 6120, 12240, + 6128, 8144, 6136, 16336, 6152, 8240, 6168, 12336, 6184, 10288, + 6200, 14384, 6216, 9264, 6232, 13360, 6248, 11312, 6256, 7216, + 6264, 15408, 6280, 8752, 6296, 12848, 6312, 10800, 6320, 6704, + 6328, 14896, 6344, 9776, 6360, 13872, 6376, 11824, 6384, 7728, + 6392, 15920, 6408, 8496, 6424, 12592, 6440, 10544, 6456, 14640, + 6472, 9520, 6488, 13616, 6504, 11568, 6512, 7472, 6520, 15664, + 6536, 9008, 6552, 13104, 6568, 11056, 6576, 6960, 6584, 15152, + 6600, 10032, 6616, 14128, 6632, 12080, 6640, 7984, 6648, 16176, + 6664, 8368, 6680, 12464, 6696, 10416, 6712, 14512, 6728, 9392, + 6744, 13488, 6760, 11440, 6768, 7344, 6776, 15536, 6792, 8880, + 6808, 12976, 6824, 10928, 6840, 15024, 6856, 9904, 6872, 14000, + 6888, 11952, 6896, 7856, 6904, 16048, 6920, 8624, 6936, 12720, + 6952, 10672, 6968, 14768, 6984, 9648, 7000, 13744, 7016, 11696, + 7024, 7600, 7032, 15792, 7048, 9136, 7064, 13232, 7080, 11184, + 7096, 15280, 7112, 10160, 7128, 14256, 7144, 12208, 7152, 8112, + 7160, 16304, 7176, 8304, 7192, 12400, 7208, 10352, 7224, 14448, + 7240, 9328, 7256, 13424, 7272, 11376, 7288, 15472, 7304, 8816, + 7320, 12912, 7336, 10864, 7352, 14960, 7368, 9840, 7384, 13936, + 7400, 11888, 7408, 7792, 7416, 15984, 7432, 8560, 7448, 12656, + 7464, 10608, 7480, 14704, 7496, 9584, 7512, 13680, 7528, 11632, + 7544, 15728, 7560, 9072, 7576, 13168, 7592, 11120, 7608, 15216, + 7624, 10096, 7640, 14192, 7656, 12144, 7664, 8048, 7672, 16240, + 7688, 8432, 7704, 12528, 7720, 10480, 7736, 14576, 7752, 9456, + 7768, 13552, 7784, 11504, 7800, 15600, 7816, 8944, 7832, 13040, + 7848, 10992, 7864, 15088, 7880, 9968, 7896, 14064, 7912, 12016, + 7928, 16112, 7944, 8688, 7960, 12784, 7976, 10736, 7992, 14832, + 8008, 9712, 8024, 13808, 8040, 11760, 8056, 15856, 8072, 9200, + 8088, 13296, 8104, 11248, 8120, 15344, 8136, 10224, 8152, 14320, + 8168, 12272, 8184, 16368, 8216, 12296, 8232, 10248, 8248, 14344, + 8264, 9224, 8280, 13320, 8296, 11272, 8312, 15368, 8328, 8712, + 8344, 12808, 8360, 10760, 8376, 14856, 8392, 9736, 8408, 13832, + 8424, 11784, 8440, 15880, 8472, 12552, 8488, 10504, 8504, 14600, + 8520, 9480, 8536, 13576, 8552, 11528, 8568, 15624, 8584, 8968, + 8600, 13064, 8616, 11016, 8632, 15112, 8648, 9992, 8664, 14088, + 8680, 12040, 8696, 16136, 8728, 12424, 8744, 10376, 8760, 14472, + 8776, 9352, 8792, 13448, 8808, 11400, 8824, 15496, 8856, 12936, + 8872, 10888, 8888, 14984, 8904, 9864, 8920, 13960, 8936, 11912, + 8952, 16008, 8984, 12680, 9000, 10632, 9016, 14728, 9032, 9608, + 9048, 13704, 9064, 11656, 9080, 15752, 9112, 13192, 9128, 11144, + 9144, 15240, 9160, 10120, 9176, 14216, 9192, 12168, 9208, 16264, + 9240, 12360, 9256, 10312, 9272, 14408, 9304, 13384, 9320, 11336, + 9336, 15432, 9368, 12872, 9384, 10824, 9400, 14920, 9416, 9800, + 9432, 13896, 9448, 11848, 9464, 15944, 9496, 12616, 9512, 10568, + 9528, 14664, 9560, 13640, 9576, 11592, 9592, 15688, 9624, 13128, + 9640, 11080, 9656, 15176, 9672, 10056, 9688, 14152, 9704, 12104, + 9720, 16200, 9752, 12488, 9768, 10440, 9784, 14536, 9816, 13512, + 9832, 11464, 9848, 15560, 9880, 13000, 9896, 10952, 9912, 15048, + 9944, 14024, 9960, 11976, 9976, 16072, 10008, 12744, 10024, 10696, + 10040, 14792, 10072, 13768, 10088, 11720, 10104, 15816, 10136, 13256, + 10152, 11208, 10168, 15304, 10200, 14280, 10216, 12232, 10232, 16328, + 10264, 12328, 10296, 14376, 10328, 13352, 10344, 11304, 10360, 15400, + 10392, 12840, 10408, 10792, 10424, 14888, 10456, 13864, 10472, 11816, + 10488, 15912, 10520, 12584, 10552, 14632, 10584, 13608, 10600, 11560, + 10616, 15656, 10648, 13096, 10664, 11048, 10680, 15144, 10712, 14120, + 10728, 12072, 10744, 16168, 10776, 12456, 10808, 14504, 10840, 13480, + 10856, 11432, 10872, 15528, 10904, 12968, 10936, 15016, 10968, 13992, + 10984, 11944, 11000, 16040, 11032, 12712, 11064, 14760, 11096, 13736, + 11112, 11688, 11128, 15784, 11160, 13224, 11192, 15272, 11224, 14248, + 11240, 12200, 11256, 16296, 11288, 12392, 11320, 14440, 11352, 13416, + 11384, 15464, 11416, 12904, 11448, 14952, 11480, 13928, 11496, 11880, + 11512, 15976, 11544, 12648, 11576, 14696, 11608, 13672, 11640, 15720, + 11672, 13160, 11704, 15208, 11736, 14184, 11752, 12136, 11768, 16232, + 11800, 12520, 11832, 14568, 11864, 13544, 11896, 15592, 11928, 13032, + 11960, 15080, 11992, 14056, 12024, 16104, 12056, 12776, 12088, 14824, + 12120, 13800, 12152, 15848, 12184, 13288, 12216, 15336, 12248, 14312, + 12280, 16360, 12344, 14360, 12376, 13336, 12408, 15384, 12440, 12824, + 12472, 14872, 12504, 13848, 12536, 15896, 12600, 14616, 12632, 13592, + 12664, 15640, 12696, 13080, 12728, 15128, 12760, 14104, 12792, 16152, + 12856, 14488, 12888, 13464, 12920, 15512, 12984, 15000, 13016, 13976, + 13048, 16024, 13112, 14744, 13144, 13720, 13176, 15768, 13240, 15256, + 13272, 14232, 13304, 16280, 13368, 14424, 13432, 15448, 13496, 14936, + 13528, 13912, 13560, 15960, 13624, 14680, 13688, 15704, 13752, 15192, + 13784, 14168, 13816, 16216, 13880, 14552, 13944, 15576, 14008, 15064, + 14072, 16088, 14136, 14808, 14200, 15832, 14264, 15320, 14328, 16344, + 14456, 15416, 14520, 14904, 14584, 15928, 14712, 15672, 14776, 15160, + 14840, 16184, 14968, 15544, 15096, 16056, 15224, 15800, 15352, 16312, + 15608, 15992, 15864, 16248}; -const uint16_t armBitRevIndexTable_fixed_2048[ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH] = -{ - /* 4x2, size 1984 */ - 8,8192, 16,4096, 24,12288, 32,2048, 40,10240, 48,6144, 56,14336, 64,1024, - 72,9216, 80,5120, 88,13312, 96,3072, 104,11264, 112,7168, 120,15360, 128,512, - 136,8704, 144,4608, 152,12800, 160,2560, 168,10752, 176,6656, 184,14848, - 192,1536, 200,9728, 208,5632, 216,13824, 224,3584, 232,11776, 240,7680, - 248,15872, 264,8448, 272,4352, 280,12544, 288,2304, 296,10496, 304,6400, - 312,14592, 320,1280, 328,9472, 336,5376, 344,13568, 352,3328, 360,11520, - 368,7424, 376,15616, 384,768, 392,8960, 400,4864, 408,13056, 416,2816, - 424,11008, 432,6912, 440,15104, 448,1792, 456,9984, 464,5888, 472,14080, - 480,3840, 488,12032, 496,7936, 504,16128, 520,8320, 528,4224, 536,12416, - 544,2176, 552,10368, 560,6272, 568,14464, 576,1152, 584,9344, 592,5248, - 600,13440, 608,3200, 616,11392, 624,7296, 632,15488, 648,8832, 656,4736, - 664,12928, 672,2688, 680,10880, 688,6784, 696,14976, 704,1664, 712,9856, - 720,5760, 728,13952, 736,3712, 744,11904, 752,7808, 760,16000, 776,8576, - 784,4480, 792,12672, 800,2432, 808,10624, 816,6528, 824,14720, 832,1408, - 840,9600, 848,5504, 856,13696, 864,3456, 872,11648, 880,7552, 888,15744, - 904,9088, 912,4992, 920,13184, 928,2944, 936,11136, 944,7040, 952,15232, - 960,1920, 968,10112, 976,6016, 984,14208, 992,3968, 1000,12160, 1008,8064, - 1016,16256, 1032,8256, 1040,4160, 1048,12352, 1056,2112, 1064,10304, 1072,6208, - 1080,14400, 1096,9280, 1104,5184, 1112,13376, 1120,3136, 1128,11328, 1136,7232, - 1144,15424, 1160,8768, 1168,4672, 1176,12864, 1184,2624, 1192,10816, 1200,6720, - 1208,14912, 1216,1600, 1224,9792, 1232,5696, 1240,13888, 1248,3648, 1256,11840, - 1264,7744, 1272,15936, 1288,8512, 1296,4416, 1304,12608, 1312,2368, 1320,10560, - 1328,6464, 1336,14656, 1352,9536, 1360,5440, 1368,13632, 1376,3392, 1384,11584, - 1392,7488, 1400,15680, 1416,9024, 1424,4928, 1432,13120, 1440,2880, 1448,11072, - 1456,6976, 1464,15168, 1472,1856, 1480,10048, 1488,5952, 1496,14144, 1504,3904, - 1512,12096, 1520,8000, 1528,16192, 1544,8384, 1552,4288, 1560,12480, 1568,2240, - 1576,10432, 1584,6336, 1592,14528, 1608,9408, 1616,5312, 1624,13504, 1632,3264, - 1640,11456, 1648,7360, 1656,15552, 1672,8896, 1680,4800, 1688,12992, 1696,2752, - 1704,10944, 1712,6848, 1720,15040, 1736,9920, 1744,5824, 1752,14016, 1760,3776, - 1768,11968, 1776,7872, 1784,16064, 1800,8640, 1808,4544, 1816,12736, 1824,2496, - 1832,10688, 1840,6592, 1848,14784, 1864,9664, 1872,5568, 1880,13760, 1888,3520, - 1896,11712, 1904,7616, 1912,15808, 1928,9152, 1936,5056, 1944,13248, 1952,3008, - 1960,11200, 1968,7104, 1976,15296, 1992,10176, 2000,6080, 2008,14272, 2016,4032, - 2024,12224, 2032,8128, 2040,16320, 2056,8224, 2064,4128, 2072,12320, 2088,10272, - 2096,6176, 2104,14368, 2120,9248, 2128,5152, 2136,13344, 2144,3104, 2152,11296, - 2160,7200, 2168,15392, 2184,8736, 2192,4640, 2200,12832, 2208,2592, 2216,10784, - 2224,6688, 2232,14880, 2248,9760, 2256,5664, 2264,13856, 2272,3616, 2280,11808, - 2288,7712, 2296,15904, 2312,8480, 2320,4384, 2328,12576, 2344,10528, 2352,6432, - 2360,14624, 2376,9504, 2384,5408, 2392,13600, 2400,3360, 2408,11552, 2416,7456, - 2424,15648, 2440,8992, 2448,4896, 2456,13088, 2464,2848, 2472,11040, 2480,6944, - 2488,15136, 2504,10016, 2512,5920, 2520,14112, 2528,3872, 2536,12064, 2544,7968, - 2552,16160, 2568,8352, 2576,4256, 2584,12448, 2600,10400, 2608,6304, 2616,14496, - 2632,9376, 2640,5280, 2648,13472, 2656,3232, 2664,11424, 2672,7328, 2680,15520, - 2696,8864, 2704,4768, 2712,12960, 2728,10912, 2736,6816, 2744,15008, 2760,9888, - 2768,5792, 2776,13984, 2784,3744, 2792,11936, 2800,7840, 2808,16032, 2824,8608, - 2832,4512, 2840,12704, 2856,10656, 2864,6560, 2872,14752, 2888,9632, 2896,5536, - 2904,13728, 2912,3488, 2920,11680, 2928,7584, 2936,15776, 2952,9120, 2960,5024, - 2968,13216, 2984,11168, 2992,7072, 3000,15264, 3016,10144, 3024,6048, - 3032,14240, 3040,4000, 3048,12192, 3056,8096, 3064,16288, 3080,8288, 3088,4192, - 3096,12384, 3112,10336, 3120,6240, 3128,14432, 3144,9312, 3152,5216, 3160,13408, - 3176,11360, 3184,7264, 3192,15456, 3208,8800, 3216,4704, 3224,12896, 3240,10848, - 3248,6752, 3256,14944, 3272,9824, 3280,5728, 3288,13920, 3296,3680, 3304,11872, - 3312,7776, 3320,15968, 3336,8544, 3344,4448, 3352,12640, 3368,10592, 3376,6496, - 3384,14688, 3400,9568, 3408,5472, 3416,13664, 3432,11616, 3440,7520, 3448,15712, - 3464,9056, 3472,4960, 3480,13152, 3496,11104, 3504,7008, 3512,15200, 3528,10080, - 3536,5984, 3544,14176, 3552,3936, 3560,12128, 3568,8032, 3576,16224, 3592,8416, - 3600,4320, 3608,12512, 3624,10464, 3632,6368, 3640,14560, 3656,9440, 3664,5344, - 3672,13536, 3688,11488, 3696,7392, 3704,15584, 3720,8928, 3728,4832, 3736,13024, - 3752,10976, 3760,6880, 3768,15072, 3784,9952, 3792,5856, 3800,14048, 3816,12000, - 3824,7904, 3832,16096, 3848,8672, 3856,4576, 3864,12768, 3880,10720, 3888,6624, - 3896,14816, 3912,9696, 3920,5600, 3928,13792, 3944,11744, 3952,7648, 3960,15840, - 3976,9184, 3984,5088, 3992,13280, 4008,11232, 4016,7136, 4024,15328, 4040,10208, - 4048,6112, 4056,14304, 4072,12256, 4080,8160, 4088,16352, 4104,8208, 4120,12304, - 4136,10256, 4144,6160, 4152,14352, 4168,9232, 4176,5136, 4184,13328, 4200,11280, - 4208,7184, 4216,15376, 4232,8720, 4240,4624, 4248,12816, 4264,10768, 4272,6672, - 4280,14864, 4296,9744, 4304,5648, 4312,13840, 4328,11792, 4336,7696, 4344,15888, - 4360,8464, 4376,12560, 4392,10512, 4400,6416, 4408,14608, 4424,9488, 4432,5392, - 4440,13584, 4456,11536, 4464,7440, 4472,15632, 4488,8976, 4496,4880, 4504,13072, - 4520,11024, 4528,6928, 4536,15120, 4552,10000, 4560,5904, 4568,14096, - 4584,12048, 4592,7952, 4600,16144, 4616,8336, 4632,12432, 4648,10384, 4656,6288, - 4664,14480, 4680,9360, 4688,5264, 4696,13456, 4712,11408, 4720,7312, 4728,15504, - 4744,8848, 4760,12944, 4776,10896, 4784,6800, 4792,14992, 4808,9872, 4816,5776, - 4824,13968, 4840,11920, 4848,7824, 4856,16016, 4872,8592, 4888,12688, - 4904,10640, 4912,6544, 4920,14736, 4936,9616, 4944,5520, 4952,13712, 4968,11664, - 4976,7568, 4984,15760, 5000,9104, 5016,13200, 5032,11152, 5040,7056, 5048,15248, - 5064,10128, 5072,6032, 5080,14224, 5096,12176, 5104,8080, 5112,16272, 5128,8272, - 5144,12368, 5160,10320, 5168,6224, 5176,14416, 5192,9296, 5208,13392, - 5224,11344, 5232,7248, 5240,15440, 5256,8784, 5272,12880, 5288,10832, 5296,6736, - 5304,14928, 5320,9808, 5328,5712, 5336,13904, 5352,11856, 5360,7760, 5368,15952, - 5384,8528, 5400,12624, 5416,10576, 5424,6480, 5432,14672, 5448,9552, 5464,13648, - 5480,11600, 5488,7504, 5496,15696, 5512,9040, 5528,13136, 5544,11088, 5552,6992, - 5560,15184, 5576,10064, 5584,5968, 5592,14160, 5608,12112, 5616,8016, - 5624,16208, 5640,8400, 5656,12496, 5672,10448, 5680,6352, 5688,14544, 5704,9424, - 5720,13520, 5736,11472, 5744,7376, 5752,15568, 5768,8912, 5784,13008, - 5800,10960, 5808,6864, 5816,15056, 5832,9936, 5848,14032, 5864,11984, 5872,7888, - 5880,16080, 5896,8656, 5912,12752, 5928,10704, 5936,6608, 5944,14800, 5960,9680, - 5976,13776, 5992,11728, 6000,7632, 6008,15824, 6024,9168, 6040,13264, - 6056,11216, 6064,7120, 6072,15312, 6088,10192, 6104,14288, 6120,12240, - 6128,8144, 6136,16336, 6152,8240, 6168,12336, 6184,10288, 6200,14384, 6216,9264, - 6232,13360, 6248,11312, 6256,7216, 6264,15408, 6280,8752, 6296,12848, - 6312,10800, 6320,6704, 6328,14896, 6344,9776, 6360,13872, 6376,11824, 6384,7728, - 6392,15920, 6408,8496, 6424,12592, 6440,10544, 6456,14640, 6472,9520, - 6488,13616, 6504,11568, 6512,7472, 6520,15664, 6536,9008, 6552,13104, - 6568,11056, 6576,6960, 6584,15152, 6600,10032, 6616,14128, 6632,12080, - 6640,7984, 6648,16176, 6664,8368, 6680,12464, 6696,10416, 6712,14512, 6728,9392, - 6744,13488, 6760,11440, 6768,7344, 6776,15536, 6792,8880, 6808,12976, - 6824,10928, 6840,15024, 6856,9904, 6872,14000, 6888,11952, 6896,7856, - 6904,16048, 6920,8624, 6936,12720, 6952,10672, 6968,14768, 6984,9648, - 7000,13744, 7016,11696, 7024,7600, 7032,15792, 7048,9136, 7064,13232, - 7080,11184, 7096,15280, 7112,10160, 7128,14256, 7144,12208, 7152,8112, - 7160,16304, 7176,8304, 7192,12400, 7208,10352, 7224,14448, 7240,9328, - 7256,13424, 7272,11376, 7288,15472, 7304,8816, 7320,12912, 7336,10864, - 7352,14960, 7368,9840, 7384,13936, 7400,11888, 7408,7792, 7416,15984, 7432,8560, - 7448,12656, 7464,10608, 7480,14704, 7496,9584, 7512,13680, 7528,11632, - 7544,15728, 7560,9072, 7576,13168, 7592,11120, 7608,15216, 7624,10096, - 7640,14192, 7656,12144, 7664,8048, 7672,16240, 7688,8432, 7704,12528, - 7720,10480, 7736,14576, 7752,9456, 7768,13552, 7784,11504, 7800,15600, - 7816,8944, 7832,13040, 7848,10992, 7864,15088, 7880,9968, 7896,14064, - 7912,12016, 7928,16112, 7944,8688, 7960,12784, 7976,10736, 7992,14832, - 8008,9712, 8024,13808, 8040,11760, 8056,15856, 8072,9200, 8088,13296, - 8104,11248, 8120,15344, 8136,10224, 8152,14320, 8168,12272, 8184,16368, - 8216,12296, 8232,10248, 8248,14344, 8264,9224, 8280,13320, 8296,11272, - 8312,15368, 8328,8712, 8344,12808, 8360,10760, 8376,14856, 8392,9736, - 8408,13832, 8424,11784, 8440,15880, 8472,12552, 8488,10504, 8504,14600, - 8520,9480, 8536,13576, 8552,11528, 8568,15624, 8584,8968, 8600,13064, - 8616,11016, 8632,15112, 8648,9992, 8664,14088, 8680,12040, 8696,16136, - 8728,12424, 8744,10376, 8760,14472, 8776,9352, 8792,13448, 8808,11400, - 8824,15496, 8856,12936, 8872,10888, 8888,14984, 8904,9864, 8920,13960, - 8936,11912, 8952,16008, 8984,12680, 9000,10632, 9016,14728, 9032,9608, - 9048,13704, 9064,11656, 9080,15752, 9112,13192, 9128,11144, 9144,15240, - 9160,10120, 9176,14216, 9192,12168, 9208,16264, 9240,12360, 9256,10312, - 9272,14408, 9304,13384, 9320,11336, 9336,15432, 9368,12872, 9384,10824, - 9400,14920, 9416,9800, 9432,13896, 9448,11848, 9464,15944, 9496,12616, - 9512,10568, 9528,14664, 9560,13640, 9576,11592, 9592,15688, 9624,13128, - 9640,11080, 9656,15176, 9672,10056, 9688,14152, 9704,12104, 9720,16200, - 9752,12488, 9768,10440, 9784,14536, 9816,13512, 9832,11464, 9848,15560, - 9880,13000, 9896,10952, 9912,15048, 9944,14024, 9960,11976, 9976,16072, - 10008,12744, 10024,10696, 10040,14792, 10072,13768, 10088,11720, 10104,15816, - 10136,13256, 10152,11208, 10168,15304, 10200,14280, 10216,12232, 10232,16328, - 10264,12328, 10296,14376, 10328,13352, 10344,11304, 10360,15400, 10392,12840, - 10408,10792, 10424,14888, 10456,13864, 10472,11816, 10488,15912, 10520,12584, - 10552,14632, 10584,13608, 10600,11560, 10616,15656, 10648,13096, 10664,11048, - 10680,15144, 10712,14120, 10728,12072, 10744,16168, 10776,12456, 10808,14504, - 10840,13480, 10856,11432, 10872,15528, 10904,12968, 10936,15016, 10968,13992, - 10984,11944, 11000,16040, 11032,12712, 11064,14760, 11096,13736, 11112,11688, - 11128,15784, 11160,13224, 11192,15272, 11224,14248, 11240,12200, 11256,16296, - 11288,12392, 11320,14440, 11352,13416, 11384,15464, 11416,12904, 11448,14952, - 11480,13928, 11496,11880, 11512,15976, 11544,12648, 11576,14696, 11608,13672, - 11640,15720, 11672,13160, 11704,15208, 11736,14184, 11752,12136, 11768,16232, - 11800,12520, 11832,14568, 11864,13544, 11896,15592, 11928,13032, 11960,15080, - 11992,14056, 12024,16104, 12056,12776, 12088,14824, 12120,13800, 12152,15848, - 12184,13288, 12216,15336, 12248,14312, 12280,16360, 12344,14360, 12376,13336, - 12408,15384, 12440,12824, 12472,14872, 12504,13848, 12536,15896, 12600,14616, - 12632,13592, 12664,15640, 12696,13080, 12728,15128, 12760,14104, 12792,16152, - 12856,14488, 12888,13464, 12920,15512, 12984,15000, 13016,13976, 13048,16024, - 13112,14744, 13144,13720, 13176,15768, 13240,15256, 13272,14232, 13304,16280, - 13368,14424, 13432,15448, 13496,14936, 13528,13912, 13560,15960, 13624,14680, - 13688,15704, 13752,15192, 13784,14168, 13816,16216, 13880,14552, 13944,15576, - 14008,15064, 14072,16088, 14136,14808, 14200,15832, 14264,15320, 14328,16344, - 14456,15416, 14520,14904, 14584,15928, 14712,15672, 14776,15160, 14840,16184, - 14968,15544, 15096,16056, 15224,15800, 15352,16312, 15608,15992, 15864,16248 -}; - -const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH] = -{ - /* radix 4, size 4032 */ - 8,16384, 16,8192, 24,24576, 32,4096, 40,20480, 48,12288, 56,28672, 64,2048, - 72,18432, 80,10240, 88,26624, 96,6144, 104,22528, 112,14336, 120,30720, - 128,1024, 136,17408, 144,9216, 152,25600, 160,5120, 168,21504, 176,13312, - 184,29696, 192,3072, 200,19456, 208,11264, 216,27648, 224,7168, 232,23552, - 240,15360, 248,31744, 256,512, 264,16896, 272,8704, 280,25088, 288,4608, - 296,20992, 304,12800, 312,29184, 320,2560, 328,18944, 336,10752, 344,27136, - 352,6656, 360,23040, 368,14848, 376,31232, 384,1536, 392,17920, 400,9728, - 408,26112, 416,5632, 424,22016, 432,13824, 440,30208, 448,3584, 456,19968, - 464,11776, 472,28160, 480,7680, 488,24064, 496,15872, 504,32256, 520,16640, - 528,8448, 536,24832, 544,4352, 552,20736, 560,12544, 568,28928, 576,2304, - 584,18688, 592,10496, 600,26880, 608,6400, 616,22784, 624,14592, 632,30976, - 640,1280, 648,17664, 656,9472, 664,25856, 672,5376, 680,21760, 688,13568, - 696,29952, 704,3328, 712,19712, 720,11520, 728,27904, 736,7424, 744,23808, - 752,15616, 760,32000, 776,17152, 784,8960, 792,25344, 800,4864, 808,21248, - 816,13056, 824,29440, 832,2816, 840,19200, 848,11008, 856,27392, 864,6912, - 872,23296, 880,15104, 888,31488, 896,1792, 904,18176, 912,9984, 920,26368, - 928,5888, 936,22272, 944,14080, 952,30464, 960,3840, 968,20224, 976,12032, - 984,28416, 992,7936, 1000,24320, 1008,16128, 1016,32512, 1032,16512, 1040,8320, - 1048,24704, 1056,4224, 1064,20608, 1072,12416, 1080,28800, 1088,2176, - 1096,18560, 1104,10368, 1112,26752, 1120,6272, 1128,22656, 1136,14464, - 1144,30848, 1160,17536, 1168,9344, 1176,25728, 1184,5248, 1192,21632, - 1200,13440, 1208,29824, 1216,3200, 1224,19584, 1232,11392, 1240,27776, - 1248,7296, 1256,23680, 1264,15488, 1272,31872, 1288,17024, 1296,8832, - 1304,25216, 1312,4736, 1320,21120, 1328,12928, 1336,29312, 1344,2688, - 1352,19072, 1360,10880, 1368,27264, 1376,6784, 1384,23168, 1392,14976, - 1400,31360, 1408,1664, 1416,18048, 1424,9856, 1432,26240, 1440,5760, 1448,22144, - 1456,13952, 1464,30336, 1472,3712, 1480,20096, 1488,11904, 1496,28288, - 1504,7808, 1512,24192, 1520,16000, 1528,32384, 1544,16768, 1552,8576, - 1560,24960, 1568,4480, 1576,20864, 1584,12672, 1592,29056, 1600,2432, - 1608,18816, 1616,10624, 1624,27008, 1632,6528, 1640,22912, 1648,14720, - 1656,31104, 1672,17792, 1680,9600, 1688,25984, 1696,5504, 1704,21888, - 1712,13696, 1720,30080, 1728,3456, 1736,19840, 1744,11648, 1752,28032, - 1760,7552, 1768,23936, 1776,15744, 1784,32128, 1800,17280, 1808,9088, - 1816,25472, 1824,4992, 1832,21376, 1840,13184, 1848,29568, 1856,2944, - 1864,19328, 1872,11136, 1880,27520, 1888,7040, 1896,23424, 1904,15232, - 1912,31616, 1928,18304, 1936,10112, 1944,26496, 1952,6016, 1960,22400, - 1968,14208, 1976,30592, 1984,3968, 1992,20352, 2000,12160, 2008,28544, - 2016,8064, 2024,24448, 2032,16256, 2040,32640, 2056,16448, 2064,8256, - 2072,24640, 2080,4160, 2088,20544, 2096,12352, 2104,28736, 2120,18496, - 2128,10304, 2136,26688, 2144,6208, 2152,22592, 2160,14400, 2168,30784, - 2184,17472, 2192,9280, 2200,25664, 2208,5184, 2216,21568, 2224,13376, - 2232,29760, 2240,3136, 2248,19520, 2256,11328, 2264,27712, 2272,7232, - 2280,23616, 2288,15424, 2296,31808, 2312,16960, 2320,8768, 2328,25152, - 2336,4672, 2344,21056, 2352,12864, 2360,29248, 2368,2624, 2376,19008, - 2384,10816, 2392,27200, 2400,6720, 2408,23104, 2416,14912, 2424,31296, - 2440,17984, 2448,9792, 2456,26176, 2464,5696, 2472,22080, 2480,13888, - 2488,30272, 2496,3648, 2504,20032, 2512,11840, 2520,28224, 2528,7744, - 2536,24128, 2544,15936, 2552,32320, 2568,16704, 2576,8512, 2584,24896, - 2592,4416, 2600,20800, 2608,12608, 2616,28992, 2632,18752, 2640,10560, - 2648,26944, 2656,6464, 2664,22848, 2672,14656, 2680,31040, 2696,17728, - 2704,9536, 2712,25920, 2720,5440, 2728,21824, 2736,13632, 2744,30016, 2752,3392, - 2760,19776, 2768,11584, 2776,27968, 2784,7488, 2792,23872, 2800,15680, - 2808,32064, 2824,17216, 2832,9024, 2840,25408, 2848,4928, 2856,21312, - 2864,13120, 2872,29504, 2888,19264, 2896,11072, 2904,27456, 2912,6976, - 2920,23360, 2928,15168, 2936,31552, 2952,18240, 2960,10048, 2968,26432, - 2976,5952, 2984,22336, 2992,14144, 3000,30528, 3008,3904, 3016,20288, - 3024,12096, 3032,28480, 3040,8000, 3048,24384, 3056,16192, 3064,32576, - 3080,16576, 3088,8384, 3096,24768, 3104,4288, 3112,20672, 3120,12480, - 3128,28864, 3144,18624, 3152,10432, 3160,26816, 3168,6336, 3176,22720, - 3184,14528, 3192,30912, 3208,17600, 3216,9408, 3224,25792, 3232,5312, - 3240,21696, 3248,13504, 3256,29888, 3272,19648, 3280,11456, 3288,27840, - 3296,7360, 3304,23744, 3312,15552, 3320,31936, 3336,17088, 3344,8896, - 3352,25280, 3360,4800, 3368,21184, 3376,12992, 3384,29376, 3400,19136, - 3408,10944, 3416,27328, 3424,6848, 3432,23232, 3440,15040, 3448,31424, - 3464,18112, 3472,9920, 3480,26304, 3488,5824, 3496,22208, 3504,14016, - 3512,30400, 3520,3776, 3528,20160, 3536,11968, 3544,28352, 3552,7872, - 3560,24256, 3568,16064, 3576,32448, 3592,16832, 3600,8640, 3608,25024, - 3616,4544, 3624,20928, 3632,12736, 3640,29120, 3656,18880, 3664,10688, - 3672,27072, 3680,6592, 3688,22976, 3696,14784, 3704,31168, 3720,17856, - 3728,9664, 3736,26048, 3744,5568, 3752,21952, 3760,13760, 3768,30144, - 3784,19904, 3792,11712, 3800,28096, 3808,7616, 3816,24000, 3824,15808, - 3832,32192, 3848,17344, 3856,9152, 3864,25536, 3872,5056, 3880,21440, - 3888,13248, 3896,29632, 3912,19392, 3920,11200, 3928,27584, 3936,7104, - 3944,23488, 3952,15296, 3960,31680, 3976,18368, 3984,10176, 3992,26560, - 4000,6080, 4008,22464, 4016,14272, 4024,30656, 4040,20416, 4048,12224, - 4056,28608, 4064,8128, 4072,24512, 4080,16320, 4088,32704, 4104,16416, - 4112,8224, 4120,24608, 4136,20512, 4144,12320, 4152,28704, 4168,18464, - 4176,10272, 4184,26656, 4192,6176, 4200,22560, 4208,14368, 4216,30752, - 4232,17440, 4240,9248, 4248,25632, 4256,5152, 4264,21536, 4272,13344, - 4280,29728, 4296,19488, 4304,11296, 4312,27680, 4320,7200, 4328,23584, - 4336,15392, 4344,31776, 4360,16928, 4368,8736, 4376,25120, 4384,4640, - 4392,21024, 4400,12832, 4408,29216, 4424,18976, 4432,10784, 4440,27168, - 4448,6688, 4456,23072, 4464,14880, 4472,31264, 4488,17952, 4496,9760, - 4504,26144, 4512,5664, 4520,22048, 4528,13856, 4536,30240, 4552,20000, - 4560,11808, 4568,28192, 4576,7712, 4584,24096, 4592,15904, 4600,32288, - 4616,16672, 4624,8480, 4632,24864, 4648,20768, 4656,12576, 4664,28960, - 4680,18720, 4688,10528, 4696,26912, 4704,6432, 4712,22816, 4720,14624, - 4728,31008, 4744,17696, 4752,9504, 4760,25888, 4768,5408, 4776,21792, - 4784,13600, 4792,29984, 4808,19744, 4816,11552, 4824,27936, 4832,7456, - 4840,23840, 4848,15648, 4856,32032, 4872,17184, 4880,8992, 4888,25376, - 4904,21280, 4912,13088, 4920,29472, 4936,19232, 4944,11040, 4952,27424, - 4960,6944, 4968,23328, 4976,15136, 4984,31520, 5000,18208, 5008,10016, - 5016,26400, 5024,5920, 5032,22304, 5040,14112, 5048,30496, 5064,20256, - 5072,12064, 5080,28448, 5088,7968, 5096,24352, 5104,16160, 5112,32544, - 5128,16544, 5136,8352, 5144,24736, 5160,20640, 5168,12448, 5176,28832, - 5192,18592, 5200,10400, 5208,26784, 5216,6304, 5224,22688, 5232,14496, - 5240,30880, 5256,17568, 5264,9376, 5272,25760, 5288,21664, 5296,13472, - 5304,29856, 5320,19616, 5328,11424, 5336,27808, 5344,7328, 5352,23712, - 5360,15520, 5368,31904, 5384,17056, 5392,8864, 5400,25248, 5416,21152, - 5424,12960, 5432,29344, 5448,19104, 5456,10912, 5464,27296, 5472,6816, - 5480,23200, 5488,15008, 5496,31392, 5512,18080, 5520,9888, 5528,26272, - 5536,5792, 5544,22176, 5552,13984, 5560,30368, 5576,20128, 5584,11936, - 5592,28320, 5600,7840, 5608,24224, 5616,16032, 5624,32416, 5640,16800, - 5648,8608, 5656,24992, 5672,20896, 5680,12704, 5688,29088, 5704,18848, - 5712,10656, 5720,27040, 5728,6560, 5736,22944, 5744,14752, 5752,31136, - 5768,17824, 5776,9632, 5784,26016, 5800,21920, 5808,13728, 5816,30112, - 5832,19872, 5840,11680, 5848,28064, 5856,7584, 5864,23968, 5872,15776, - 5880,32160, 5896,17312, 5904,9120, 5912,25504, 5928,21408, 5936,13216, - 5944,29600, 5960,19360, 5968,11168, 5976,27552, 5984,7072, 5992,23456, - 6000,15264, 6008,31648, 6024,18336, 6032,10144, 6040,26528, 6056,22432, - 6064,14240, 6072,30624, 6088,20384, 6096,12192, 6104,28576, 6112,8096, - 6120,24480, 6128,16288, 6136,32672, 6152,16480, 6160,8288, 6168,24672, - 6184,20576, 6192,12384, 6200,28768, 6216,18528, 6224,10336, 6232,26720, - 6248,22624, 6256,14432, 6264,30816, 6280,17504, 6288,9312, 6296,25696, - 6312,21600, 6320,13408, 6328,29792, 6344,19552, 6352,11360, 6360,27744, - 6368,7264, 6376,23648, 6384,15456, 6392,31840, 6408,16992, 6416,8800, - 6424,25184, 6440,21088, 6448,12896, 6456,29280, 6472,19040, 6480,10848, - 6488,27232, 6496,6752, 6504,23136, 6512,14944, 6520,31328, 6536,18016, - 6544,9824, 6552,26208, 6568,22112, 6576,13920, 6584,30304, 6600,20064, - 6608,11872, 6616,28256, 6624,7776, 6632,24160, 6640,15968, 6648,32352, - 6664,16736, 6672,8544, 6680,24928, 6696,20832, 6704,12640, 6712,29024, - 6728,18784, 6736,10592, 6744,26976, 6760,22880, 6768,14688, 6776,31072, - 6792,17760, 6800,9568, 6808,25952, 6824,21856, 6832,13664, 6840,30048, - 6856,19808, 6864,11616, 6872,28000, 6880,7520, 6888,23904, 6896,15712, - 6904,32096, 6920,17248, 6928,9056, 6936,25440, 6952,21344, 6960,13152, - 6968,29536, 6984,19296, 6992,11104, 7000,27488, 7016,23392, 7024,15200, - 7032,31584, 7048,18272, 7056,10080, 7064,26464, 7080,22368, 7088,14176, - 7096,30560, 7112,20320, 7120,12128, 7128,28512, 7136,8032, 7144,24416, - 7152,16224, 7160,32608, 7176,16608, 7184,8416, 7192,24800, 7208,20704, - 7216,12512, 7224,28896, 7240,18656, 7248,10464, 7256,26848, 7272,22752, - 7280,14560, 7288,30944, 7304,17632, 7312,9440, 7320,25824, 7336,21728, - 7344,13536, 7352,29920, 7368,19680, 7376,11488, 7384,27872, 7400,23776, - 7408,15584, 7416,31968, 7432,17120, 7440,8928, 7448,25312, 7464,21216, - 7472,13024, 7480,29408, 7496,19168, 7504,10976, 7512,27360, 7528,23264, - 7536,15072, 7544,31456, 7560,18144, 7568,9952, 7576,26336, 7592,22240, - 7600,14048, 7608,30432, 7624,20192, 7632,12000, 7640,28384, 7648,7904, - 7656,24288, 7664,16096, 7672,32480, 7688,16864, 7696,8672, 7704,25056, - 7720,20960, 7728,12768, 7736,29152, 7752,18912, 7760,10720, 7768,27104, - 7784,23008, 7792,14816, 7800,31200, 7816,17888, 7824,9696, 7832,26080, - 7848,21984, 7856,13792, 7864,30176, 7880,19936, 7888,11744, 7896,28128, - 7912,24032, 7920,15840, 7928,32224, 7944,17376, 7952,9184, 7960,25568, - 7976,21472, 7984,13280, 7992,29664, 8008,19424, 8016,11232, 8024,27616, - 8040,23520, 8048,15328, 8056,31712, 8072,18400, 8080,10208, 8088,26592, - 8104,22496, 8112,14304, 8120,30688, 8136,20448, 8144,12256, 8152,28640, - 8168,24544, 8176,16352, 8184,32736, 8200,16400, 8216,24592, 8232,20496, - 8240,12304, 8248,28688, 8264,18448, 8272,10256, 8280,26640, 8296,22544, - 8304,14352, 8312,30736, 8328,17424, 8336,9232, 8344,25616, 8360,21520, - 8368,13328, 8376,29712, 8392,19472, 8400,11280, 8408,27664, 8424,23568, - 8432,15376, 8440,31760, 8456,16912, 8464,8720, 8472,25104, 8488,21008, - 8496,12816, 8504,29200, 8520,18960, 8528,10768, 8536,27152, 8552,23056, - 8560,14864, 8568,31248, 8584,17936, 8592,9744, 8600,26128, 8616,22032, - 8624,13840, 8632,30224, 8648,19984, 8656,11792, 8664,28176, 8680,24080, - 8688,15888, 8696,32272, 8712,16656, 8728,24848, 8744,20752, 8752,12560, - 8760,28944, 8776,18704, 8784,10512, 8792,26896, 8808,22800, 8816,14608, - 8824,30992, 8840,17680, 8848,9488, 8856,25872, 8872,21776, 8880,13584, - 8888,29968, 8904,19728, 8912,11536, 8920,27920, 8936,23824, 8944,15632, - 8952,32016, 8968,17168, 8984,25360, 9000,21264, 9008,13072, 9016,29456, - 9032,19216, 9040,11024, 9048,27408, 9064,23312, 9072,15120, 9080,31504, - 9096,18192, 9104,10000, 9112,26384, 9128,22288, 9136,14096, 9144,30480, - 9160,20240, 9168,12048, 9176,28432, 9192,24336, 9200,16144, 9208,32528, - 9224,16528, 9240,24720, 9256,20624, 9264,12432, 9272,28816, 9288,18576, - 9296,10384, 9304,26768, 9320,22672, 9328,14480, 9336,30864, 9352,17552, - 9368,25744, 9384,21648, 9392,13456, 9400,29840, 9416,19600, 9424,11408, - 9432,27792, 9448,23696, 9456,15504, 9464,31888, 9480,17040, 9496,25232, - 9512,21136, 9520,12944, 9528,29328, 9544,19088, 9552,10896, 9560,27280, - 9576,23184, 9584,14992, 9592,31376, 9608,18064, 9616,9872, 9624,26256, - 9640,22160, 9648,13968, 9656,30352, 9672,20112, 9680,11920, 9688,28304, - 9704,24208, 9712,16016, 9720,32400, 9736,16784, 9752,24976, 9768,20880, - 9776,12688, 9784,29072, 9800,18832, 9808,10640, 9816,27024, 9832,22928, - 9840,14736, 9848,31120, 9864,17808, 9880,26000, 9896,21904, 9904,13712, - 9912,30096, 9928,19856, 9936,11664, 9944,28048, 9960,23952, 9968,15760, - 9976,32144, 9992,17296, 10008,25488, 10024,21392, 10032,13200, 10040,29584, - 10056,19344, 10064,11152, 10072,27536, 10088,23440, 10096,15248, 10104,31632, - 10120,18320, 10136,26512, 10152,22416, 10160,14224, 10168,30608, 10184,20368, - 10192,12176, 10200,28560, 10216,24464, 10224,16272, 10232,32656, 10248,16464, - 10264,24656, 10280,20560, 10288,12368, 10296,28752, 10312,18512, 10328,26704, - 10344,22608, 10352,14416, 10360,30800, 10376,17488, 10392,25680, 10408,21584, - 10416,13392, 10424,29776, 10440,19536, 10448,11344, 10456,27728, 10472,23632, - 10480,15440, 10488,31824, 10504,16976, 10520,25168, 10536,21072, 10544,12880, - 10552,29264, 10568,19024, 10576,10832, 10584,27216, 10600,23120, 10608,14928, - 10616,31312, 10632,18000, 10648,26192, 10664,22096, 10672,13904, 10680,30288, - 10696,20048, 10704,11856, 10712,28240, 10728,24144, 10736,15952, 10744,32336, - 10760,16720, 10776,24912, 10792,20816, 10800,12624, 10808,29008, 10824,18768, - 10840,26960, 10856,22864, 10864,14672, 10872,31056, 10888,17744, 10904,25936, - 10920,21840, 10928,13648, 10936,30032, 10952,19792, 10960,11600, 10968,27984, - 10984,23888, 10992,15696, 11000,32080, 11016,17232, 11032,25424, 11048,21328, - 11056,13136, 11064,29520, 11080,19280, 11096,27472, 11112,23376, 11120,15184, - 11128,31568, 11144,18256, 11160,26448, 11176,22352, 11184,14160, 11192,30544, - 11208,20304, 11216,12112, 11224,28496, 11240,24400, 11248,16208, 11256,32592, - 11272,16592, 11288,24784, 11304,20688, 11312,12496, 11320,28880, 11336,18640, - 11352,26832, 11368,22736, 11376,14544, 11384,30928, 11400,17616, 11416,25808, - 11432,21712, 11440,13520, 11448,29904, 11464,19664, 11480,27856, 11496,23760, - 11504,15568, 11512,31952, 11528,17104, 11544,25296, 11560,21200, 11568,13008, - 11576,29392, 11592,19152, 11608,27344, 11624,23248, 11632,15056, 11640,31440, - 11656,18128, 11672,26320, 11688,22224, 11696,14032, 11704,30416, 11720,20176, - 11728,11984, 11736,28368, 11752,24272, 11760,16080, 11768,32464, 11784,16848, - 11800,25040, 11816,20944, 11824,12752, 11832,29136, 11848,18896, 11864,27088, - 11880,22992, 11888,14800, 11896,31184, 11912,17872, 11928,26064, 11944,21968, - 11952,13776, 11960,30160, 11976,19920, 11992,28112, 12008,24016, 12016,15824, - 12024,32208, 12040,17360, 12056,25552, 12072,21456, 12080,13264, 12088,29648, - 12104,19408, 12120,27600, 12136,23504, 12144,15312, 12152,31696, 12168,18384, - 12184,26576, 12200,22480, 12208,14288, 12216,30672, 12232,20432, 12248,28624, - 12264,24528, 12272,16336, 12280,32720, 12296,16432, 12312,24624, 12328,20528, - 12344,28720, 12360,18480, 12376,26672, 12392,22576, 12400,14384, 12408,30768, - 12424,17456, 12440,25648, 12456,21552, 12464,13360, 12472,29744, 12488,19504, - 12504,27696, 12520,23600, 12528,15408, 12536,31792, 12552,16944, 12568,25136, - 12584,21040, 12592,12848, 12600,29232, 12616,18992, 12632,27184, 12648,23088, - 12656,14896, 12664,31280, 12680,17968, 12696,26160, 12712,22064, 12720,13872, - 12728,30256, 12744,20016, 12760,28208, 12776,24112, 12784,15920, 12792,32304, - 12808,16688, 12824,24880, 12840,20784, 12856,28976, 12872,18736, 12888,26928, - 12904,22832, 12912,14640, 12920,31024, 12936,17712, 12952,25904, 12968,21808, - 12976,13616, 12984,30000, 13000,19760, 13016,27952, 13032,23856, 13040,15664, - 13048,32048, 13064,17200, 13080,25392, 13096,21296, 13112,29488, 13128,19248, - 13144,27440, 13160,23344, 13168,15152, 13176,31536, 13192,18224, 13208,26416, - 13224,22320, 13232,14128, 13240,30512, 13256,20272, 13272,28464, 13288,24368, - 13296,16176, 13304,32560, 13320,16560, 13336,24752, 13352,20656, 13368,28848, - 13384,18608, 13400,26800, 13416,22704, 13424,14512, 13432,30896, 13448,17584, - 13464,25776, 13480,21680, 13496,29872, 13512,19632, 13528,27824, 13544,23728, - 13552,15536, 13560,31920, 13576,17072, 13592,25264, 13608,21168, 13624,29360, - 13640,19120, 13656,27312, 13672,23216, 13680,15024, 13688,31408, 13704,18096, - 13720,26288, 13736,22192, 13744,14000, 13752,30384, 13768,20144, 13784,28336, - 13800,24240, 13808,16048, 13816,32432, 13832,16816, 13848,25008, 13864,20912, - 13880,29104, 13896,18864, 13912,27056, 13928,22960, 13936,14768, 13944,31152, - 13960,17840, 13976,26032, 13992,21936, 14008,30128, 14024,19888, 14040,28080, - 14056,23984, 14064,15792, 14072,32176, 14088,17328, 14104,25520, 14120,21424, - 14136,29616, 14152,19376, 14168,27568, 14184,23472, 14192,15280, 14200,31664, - 14216,18352, 14232,26544, 14248,22448, 14264,30640, 14280,20400, 14296,28592, - 14312,24496, 14320,16304, 14328,32688, 14344,16496, 14360,24688, 14376,20592, - 14392,28784, 14408,18544, 14424,26736, 14440,22640, 14456,30832, 14472,17520, - 14488,25712, 14504,21616, 14520,29808, 14536,19568, 14552,27760, 14568,23664, - 14576,15472, 14584,31856, 14600,17008, 14616,25200, 14632,21104, 14648,29296, - 14664,19056, 14680,27248, 14696,23152, 14704,14960, 14712,31344, 14728,18032, - 14744,26224, 14760,22128, 14776,30320, 14792,20080, 14808,28272, 14824,24176, - 14832,15984, 14840,32368, 14856,16752, 14872,24944, 14888,20848, 14904,29040, - 14920,18800, 14936,26992, 14952,22896, 14968,31088, 14984,17776, 15000,25968, - 15016,21872, 15032,30064, 15048,19824, 15064,28016, 15080,23920, 15088,15728, - 15096,32112, 15112,17264, 15128,25456, 15144,21360, 15160,29552, 15176,19312, - 15192,27504, 15208,23408, 15224,31600, 15240,18288, 15256,26480, 15272,22384, - 15288,30576, 15304,20336, 15320,28528, 15336,24432, 15344,16240, 15352,32624, - 15368,16624, 15384,24816, 15400,20720, 15416,28912, 15432,18672, 15448,26864, - 15464,22768, 15480,30960, 15496,17648, 15512,25840, 15528,21744, 15544,29936, - 15560,19696, 15576,27888, 15592,23792, 15608,31984, 15624,17136, 15640,25328, - 15656,21232, 15672,29424, 15688,19184, 15704,27376, 15720,23280, 15736,31472, - 15752,18160, 15768,26352, 15784,22256, 15800,30448, 15816,20208, 15832,28400, - 15848,24304, 15856,16112, 15864,32496, 15880,16880, 15896,25072, 15912,20976, - 15928,29168, 15944,18928, 15960,27120, 15976,23024, 15992,31216, 16008,17904, - 16024,26096, 16040,22000, 16056,30192, 16072,19952, 16088,28144, 16104,24048, - 16120,32240, 16136,17392, 16152,25584, 16168,21488, 16184,29680, 16200,19440, - 16216,27632, 16232,23536, 16248,31728, 16264,18416, 16280,26608, 16296,22512, - 16312,30704, 16328,20464, 16344,28656, 16360,24560, 16376,32752, 16408,24584, - 16424,20488, 16440,28680, 16456,18440, 16472,26632, 16488,22536, 16504,30728, - 16520,17416, 16536,25608, 16552,21512, 16568,29704, 16584,19464, 16600,27656, - 16616,23560, 16632,31752, 16648,16904, 16664,25096, 16680,21000, 16696,29192, - 16712,18952, 16728,27144, 16744,23048, 16760,31240, 16776,17928, 16792,26120, - 16808,22024, 16824,30216, 16840,19976, 16856,28168, 16872,24072, 16888,32264, - 16920,24840, 16936,20744, 16952,28936, 16968,18696, 16984,26888, 17000,22792, - 17016,30984, 17032,17672, 17048,25864, 17064,21768, 17080,29960, 17096,19720, - 17112,27912, 17128,23816, 17144,32008, 17176,25352, 17192,21256, 17208,29448, - 17224,19208, 17240,27400, 17256,23304, 17272,31496, 17288,18184, 17304,26376, - 17320,22280, 17336,30472, 17352,20232, 17368,28424, 17384,24328, 17400,32520, - 17432,24712, 17448,20616, 17464,28808, 17480,18568, 17496,26760, 17512,22664, - 17528,30856, 17560,25736, 17576,21640, 17592,29832, 17608,19592, 17624,27784, - 17640,23688, 17656,31880, 17688,25224, 17704,21128, 17720,29320, 17736,19080, - 17752,27272, 17768,23176, 17784,31368, 17800,18056, 17816,26248, 17832,22152, - 17848,30344, 17864,20104, 17880,28296, 17896,24200, 17912,32392, 17944,24968, - 17960,20872, 17976,29064, 17992,18824, 18008,27016, 18024,22920, 18040,31112, - 18072,25992, 18088,21896, 18104,30088, 18120,19848, 18136,28040, 18152,23944, - 18168,32136, 18200,25480, 18216,21384, 18232,29576, 18248,19336, 18264,27528, - 18280,23432, 18296,31624, 18328,26504, 18344,22408, 18360,30600, 18376,20360, - 18392,28552, 18408,24456, 18424,32648, 18456,24648, 18472,20552, 18488,28744, - 18520,26696, 18536,22600, 18552,30792, 18584,25672, 18600,21576, 18616,29768, - 18632,19528, 18648,27720, 18664,23624, 18680,31816, 18712,25160, 18728,21064, - 18744,29256, 18760,19016, 18776,27208, 18792,23112, 18808,31304, 18840,26184, - 18856,22088, 18872,30280, 18888,20040, 18904,28232, 18920,24136, 18936,32328, - 18968,24904, 18984,20808, 19000,29000, 19032,26952, 19048,22856, 19064,31048, - 19096,25928, 19112,21832, 19128,30024, 19144,19784, 19160,27976, 19176,23880, - 19192,32072, 19224,25416, 19240,21320, 19256,29512, 19288,27464, 19304,23368, - 19320,31560, 19352,26440, 19368,22344, 19384,30536, 19400,20296, 19416,28488, - 19432,24392, 19448,32584, 19480,24776, 19496,20680, 19512,28872, 19544,26824, - 19560,22728, 19576,30920, 19608,25800, 19624,21704, 19640,29896, 19672,27848, - 19688,23752, 19704,31944, 19736,25288, 19752,21192, 19768,29384, 19800,27336, - 19816,23240, 19832,31432, 19864,26312, 19880,22216, 19896,30408, 19912,20168, - 19928,28360, 19944,24264, 19960,32456, 19992,25032, 20008,20936, 20024,29128, - 20056,27080, 20072,22984, 20088,31176, 20120,26056, 20136,21960, 20152,30152, - 20184,28104, 20200,24008, 20216,32200, 20248,25544, 20264,21448, 20280,29640, - 20312,27592, 20328,23496, 20344,31688, 20376,26568, 20392,22472, 20408,30664, - 20440,28616, 20456,24520, 20472,32712, 20504,24616, 20536,28712, 20568,26664, - 20584,22568, 20600,30760, 20632,25640, 20648,21544, 20664,29736, 20696,27688, - 20712,23592, 20728,31784, 20760,25128, 20776,21032, 20792,29224, 20824,27176, - 20840,23080, 20856,31272, 20888,26152, 20904,22056, 20920,30248, 20952,28200, - 20968,24104, 20984,32296, 21016,24872, 21048,28968, 21080,26920, 21096,22824, - 21112,31016, 21144,25896, 21160,21800, 21176,29992, 21208,27944, 21224,23848, - 21240,32040, 21272,25384, 21304,29480, 21336,27432, 21352,23336, 21368,31528, - 21400,26408, 21416,22312, 21432,30504, 21464,28456, 21480,24360, 21496,32552, - 21528,24744, 21560,28840, 21592,26792, 21608,22696, 21624,30888, 21656,25768, - 21688,29864, 21720,27816, 21736,23720, 21752,31912, 21784,25256, 21816,29352, - 21848,27304, 21864,23208, 21880,31400, 21912,26280, 21928,22184, 21944,30376, - 21976,28328, 21992,24232, 22008,32424, 22040,25000, 22072,29096, 22104,27048, - 22120,22952, 22136,31144, 22168,26024, 22200,30120, 22232,28072, 22248,23976, - 22264,32168, 22296,25512, 22328,29608, 22360,27560, 22376,23464, 22392,31656, - 22424,26536, 22456,30632, 22488,28584, 22504,24488, 22520,32680, 22552,24680, - 22584,28776, 22616,26728, 22648,30824, 22680,25704, 22712,29800, 22744,27752, - 22760,23656, 22776,31848, 22808,25192, 22840,29288, 22872,27240, 22888,23144, - 22904,31336, 22936,26216, 22968,30312, 23000,28264, 23016,24168, 23032,32360, - 23064,24936, 23096,29032, 23128,26984, 23160,31080, 23192,25960, 23224,30056, - 23256,28008, 23272,23912, 23288,32104, 23320,25448, 23352,29544, 23384,27496, - 23416,31592, 23448,26472, 23480,30568, 23512,28520, 23528,24424, 23544,32616, - 23576,24808, 23608,28904, 23640,26856, 23672,30952, 23704,25832, 23736,29928, - 23768,27880, 23800,31976, 23832,25320, 23864,29416, 23896,27368, 23928,31464, - 23960,26344, 23992,30440, 24024,28392, 24040,24296, 24056,32488, 24088,25064, - 24120,29160, 24152,27112, 24184,31208, 24216,26088, 24248,30184, 24280,28136, - 24312,32232, 24344,25576, 24376,29672, 24408,27624, 24440,31720, 24472,26600, - 24504,30696, 24536,28648, 24568,32744, 24632,28696, 24664,26648, 24696,30744, - 24728,25624, 24760,29720, 24792,27672, 24824,31768, 24856,25112, 24888,29208, - 24920,27160, 24952,31256, 24984,26136, 25016,30232, 25048,28184, 25080,32280, - 25144,28952, 25176,26904, 25208,31000, 25240,25880, 25272,29976, 25304,27928, - 25336,32024, 25400,29464, 25432,27416, 25464,31512, 25496,26392, 25528,30488, - 25560,28440, 25592,32536, 25656,28824, 25688,26776, 25720,30872, 25784,29848, - 25816,27800, 25848,31896, 25912,29336, 25944,27288, 25976,31384, 26008,26264, - 26040,30360, 26072,28312, 26104,32408, 26168,29080, 26200,27032, 26232,31128, - 26296,30104, 26328,28056, 26360,32152, 26424,29592, 26456,27544, 26488,31640, - 26552,30616, 26584,28568, 26616,32664, 26680,28760, 26744,30808, 26808,29784, - 26840,27736, 26872,31832, 26936,29272, 26968,27224, 27000,31320, 27064,30296, - 27096,28248, 27128,32344, 27192,29016, 27256,31064, 27320,30040, 27352,27992, - 27384,32088, 27448,29528, 27512,31576, 27576,30552, 27608,28504, 27640,32600, - 27704,28888, 27768,30936, 27832,29912, 27896,31960, 27960,29400, 28024,31448, - 28088,30424, 28120,28376, 28152,32472, 28216,29144, 28280,31192, 28344,30168, - 28408,32216, 28472,29656, 28536,31704, 28600,30680, 28664,32728, 28792,30776, - 28856,29752, 28920,31800, 28984,29240, 29048,31288, 29112,30264, 29176,32312, - 29304,31032, 29368,30008, 29432,32056, 29560,31544, 29624,30520, 29688,32568, - 29816,30904, 29944,31928, 30072,31416, 30136,30392, 30200,32440, 30328,31160, - 30456,32184, 30584,31672, 30712,32696, 30968,31864, 31096,31352, 31224,32376, - 31480,32120, 31736,32632, 32248,32504 -}; +const uint16_t armBitRevIndexTable_fixed_4096 + [ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH] = { + /* radix 4, size 4032 */ + 8, 16384, 16, 8192, 24, 24576, 32, 4096, 40, 20480, + 48, 12288, 56, 28672, 64, 2048, 72, 18432, 80, 10240, + 88, 26624, 96, 6144, 104, 22528, 112, 14336, 120, 30720, + 128, 1024, 136, 17408, 144, 9216, 152, 25600, 160, 5120, + 168, 21504, 176, 13312, 184, 29696, 192, 3072, 200, 19456, + 208, 11264, 216, 27648, 224, 7168, 232, 23552, 240, 15360, + 248, 31744, 256, 512, 264, 16896, 272, 8704, 280, 25088, + 288, 4608, 296, 20992, 304, 12800, 312, 29184, 320, 2560, + 328, 18944, 336, 10752, 344, 27136, 352, 6656, 360, 23040, + 368, 14848, 376, 31232, 384, 1536, 392, 17920, 400, 9728, + 408, 26112, 416, 5632, 424, 22016, 432, 13824, 440, 30208, + 448, 3584, 456, 19968, 464, 11776, 472, 28160, 480, 7680, + 488, 24064, 496, 15872, 504, 32256, 520, 16640, 528, 8448, + 536, 24832, 544, 4352, 552, 20736, 560, 12544, 568, 28928, + 576, 2304, 584, 18688, 592, 10496, 600, 26880, 608, 6400, + 616, 22784, 624, 14592, 632, 30976, 640, 1280, 648, 17664, + 656, 9472, 664, 25856, 672, 5376, 680, 21760, 688, 13568, + 696, 29952, 704, 3328, 712, 19712, 720, 11520, 728, 27904, + 736, 7424, 744, 23808, 752, 15616, 760, 32000, 776, 17152, + 784, 8960, 792, 25344, 800, 4864, 808, 21248, 816, 13056, + 824, 29440, 832, 2816, 840, 19200, 848, 11008, 856, 27392, + 864, 6912, 872, 23296, 880, 15104, 888, 31488, 896, 1792, + 904, 18176, 912, 9984, 920, 26368, 928, 5888, 936, 22272, + 944, 14080, 952, 30464, 960, 3840, 968, 20224, 976, 12032, + 984, 28416, 992, 7936, 1000, 24320, 1008, 16128, 1016, 32512, + 1032, 16512, 1040, 8320, 1048, 24704, 1056, 4224, 1064, 20608, + 1072, 12416, 1080, 28800, 1088, 2176, 1096, 18560, 1104, 10368, + 1112, 26752, 1120, 6272, 1128, 22656, 1136, 14464, 1144, 30848, + 1160, 17536, 1168, 9344, 1176, 25728, 1184, 5248, 1192, 21632, + 1200, 13440, 1208, 29824, 1216, 3200, 1224, 19584, 1232, 11392, + 1240, 27776, 1248, 7296, 1256, 23680, 1264, 15488, 1272, 31872, + 1288, 17024, 1296, 8832, 1304, 25216, 1312, 4736, 1320, 21120, + 1328, 12928, 1336, 29312, 1344, 2688, 1352, 19072, 1360, 10880, + 1368, 27264, 1376, 6784, 1384, 23168, 1392, 14976, 1400, 31360, + 1408, 1664, 1416, 18048, 1424, 9856, 1432, 26240, 1440, 5760, + 1448, 22144, 1456, 13952, 1464, 30336, 1472, 3712, 1480, 20096, + 1488, 11904, 1496, 28288, 1504, 7808, 1512, 24192, 1520, 16000, + 1528, 32384, 1544, 16768, 1552, 8576, 1560, 24960, 1568, 4480, + 1576, 20864, 1584, 12672, 1592, 29056, 1600, 2432, 1608, 18816, + 1616, 10624, 1624, 27008, 1632, 6528, 1640, 22912, 1648, 14720, + 1656, 31104, 1672, 17792, 1680, 9600, 1688, 25984, 1696, 5504, + 1704, 21888, 1712, 13696, 1720, 30080, 1728, 3456, 1736, 19840, + 1744, 11648, 1752, 28032, 1760, 7552, 1768, 23936, 1776, 15744, + 1784, 32128, 1800, 17280, 1808, 9088, 1816, 25472, 1824, 4992, + 1832, 21376, 1840, 13184, 1848, 29568, 1856, 2944, 1864, 19328, + 1872, 11136, 1880, 27520, 1888, 7040, 1896, 23424, 1904, 15232, + 1912, 31616, 1928, 18304, 1936, 10112, 1944, 26496, 1952, 6016, + 1960, 22400, 1968, 14208, 1976, 30592, 1984, 3968, 1992, 20352, + 2000, 12160, 2008, 28544, 2016, 8064, 2024, 24448, 2032, 16256, + 2040, 32640, 2056, 16448, 2064, 8256, 2072, 24640, 2080, 4160, + 2088, 20544, 2096, 12352, 2104, 28736, 2120, 18496, 2128, 10304, + 2136, 26688, 2144, 6208, 2152, 22592, 2160, 14400, 2168, 30784, + 2184, 17472, 2192, 9280, 2200, 25664, 2208, 5184, 2216, 21568, + 2224, 13376, 2232, 29760, 2240, 3136, 2248, 19520, 2256, 11328, + 2264, 27712, 2272, 7232, 2280, 23616, 2288, 15424, 2296, 31808, + 2312, 16960, 2320, 8768, 2328, 25152, 2336, 4672, 2344, 21056, + 2352, 12864, 2360, 29248, 2368, 2624, 2376, 19008, 2384, 10816, + 2392, 27200, 2400, 6720, 2408, 23104, 2416, 14912, 2424, 31296, + 2440, 17984, 2448, 9792, 2456, 26176, 2464, 5696, 2472, 22080, + 2480, 13888, 2488, 30272, 2496, 3648, 2504, 20032, 2512, 11840, + 2520, 28224, 2528, 7744, 2536, 24128, 2544, 15936, 2552, 32320, + 2568, 16704, 2576, 8512, 2584, 24896, 2592, 4416, 2600, 20800, + 2608, 12608, 2616, 28992, 2632, 18752, 2640, 10560, 2648, 26944, + 2656, 6464, 2664, 22848, 2672, 14656, 2680, 31040, 2696, 17728, + 2704, 9536, 2712, 25920, 2720, 5440, 2728, 21824, 2736, 13632, + 2744, 30016, 2752, 3392, 2760, 19776, 2768, 11584, 2776, 27968, + 2784, 7488, 2792, 23872, 2800, 15680, 2808, 32064, 2824, 17216, + 2832, 9024, 2840, 25408, 2848, 4928, 2856, 21312, 2864, 13120, + 2872, 29504, 2888, 19264, 2896, 11072, 2904, 27456, 2912, 6976, + 2920, 23360, 2928, 15168, 2936, 31552, 2952, 18240, 2960, 10048, + 2968, 26432, 2976, 5952, 2984, 22336, 2992, 14144, 3000, 30528, + 3008, 3904, 3016, 20288, 3024, 12096, 3032, 28480, 3040, 8000, + 3048, 24384, 3056, 16192, 3064, 32576, 3080, 16576, 3088, 8384, + 3096, 24768, 3104, 4288, 3112, 20672, 3120, 12480, 3128, 28864, + 3144, 18624, 3152, 10432, 3160, 26816, 3168, 6336, 3176, 22720, + 3184, 14528, 3192, 30912, 3208, 17600, 3216, 9408, 3224, 25792, + 3232, 5312, 3240, 21696, 3248, 13504, 3256, 29888, 3272, 19648, + 3280, 11456, 3288, 27840, 3296, 7360, 3304, 23744, 3312, 15552, + 3320, 31936, 3336, 17088, 3344, 8896, 3352, 25280, 3360, 4800, + 3368, 21184, 3376, 12992, 3384, 29376, 3400, 19136, 3408, 10944, + 3416, 27328, 3424, 6848, 3432, 23232, 3440, 15040, 3448, 31424, + 3464, 18112, 3472, 9920, 3480, 26304, 3488, 5824, 3496, 22208, + 3504, 14016, 3512, 30400, 3520, 3776, 3528, 20160, 3536, 11968, + 3544, 28352, 3552, 7872, 3560, 24256, 3568, 16064, 3576, 32448, + 3592, 16832, 3600, 8640, 3608, 25024, 3616, 4544, 3624, 20928, + 3632, 12736, 3640, 29120, 3656, 18880, 3664, 10688, 3672, 27072, + 3680, 6592, 3688, 22976, 3696, 14784, 3704, 31168, 3720, 17856, + 3728, 9664, 3736, 26048, 3744, 5568, 3752, 21952, 3760, 13760, + 3768, 30144, 3784, 19904, 3792, 11712, 3800, 28096, 3808, 7616, + 3816, 24000, 3824, 15808, 3832, 32192, 3848, 17344, 3856, 9152, + 3864, 25536, 3872, 5056, 3880, 21440, 3888, 13248, 3896, 29632, + 3912, 19392, 3920, 11200, 3928, 27584, 3936, 7104, 3944, 23488, + 3952, 15296, 3960, 31680, 3976, 18368, 3984, 10176, 3992, 26560, + 4000, 6080, 4008, 22464, 4016, 14272, 4024, 30656, 4040, 20416, + 4048, 12224, 4056, 28608, 4064, 8128, 4072, 24512, 4080, 16320, + 4088, 32704, 4104, 16416, 4112, 8224, 4120, 24608, 4136, 20512, + 4144, 12320, 4152, 28704, 4168, 18464, 4176, 10272, 4184, 26656, + 4192, 6176, 4200, 22560, 4208, 14368, 4216, 30752, 4232, 17440, + 4240, 9248, 4248, 25632, 4256, 5152, 4264, 21536, 4272, 13344, + 4280, 29728, 4296, 19488, 4304, 11296, 4312, 27680, 4320, 7200, + 4328, 23584, 4336, 15392, 4344, 31776, 4360, 16928, 4368, 8736, + 4376, 25120, 4384, 4640, 4392, 21024, 4400, 12832, 4408, 29216, + 4424, 18976, 4432, 10784, 4440, 27168, 4448, 6688, 4456, 23072, + 4464, 14880, 4472, 31264, 4488, 17952, 4496, 9760, 4504, 26144, + 4512, 5664, 4520, 22048, 4528, 13856, 4536, 30240, 4552, 20000, + 4560, 11808, 4568, 28192, 4576, 7712, 4584, 24096, 4592, 15904, + 4600, 32288, 4616, 16672, 4624, 8480, 4632, 24864, 4648, 20768, + 4656, 12576, 4664, 28960, 4680, 18720, 4688, 10528, 4696, 26912, + 4704, 6432, 4712, 22816, 4720, 14624, 4728, 31008, 4744, 17696, + 4752, 9504, 4760, 25888, 4768, 5408, 4776, 21792, 4784, 13600, + 4792, 29984, 4808, 19744, 4816, 11552, 4824, 27936, 4832, 7456, + 4840, 23840, 4848, 15648, 4856, 32032, 4872, 17184, 4880, 8992, + 4888, 25376, 4904, 21280, 4912, 13088, 4920, 29472, 4936, 19232, + 4944, 11040, 4952, 27424, 4960, 6944, 4968, 23328, 4976, 15136, + 4984, 31520, 5000, 18208, 5008, 10016, 5016, 26400, 5024, 5920, + 5032, 22304, 5040, 14112, 5048, 30496, 5064, 20256, 5072, 12064, + 5080, 28448, 5088, 7968, 5096, 24352, 5104, 16160, 5112, 32544, + 5128, 16544, 5136, 8352, 5144, 24736, 5160, 20640, 5168, 12448, + 5176, 28832, 5192, 18592, 5200, 10400, 5208, 26784, 5216, 6304, + 5224, 22688, 5232, 14496, 5240, 30880, 5256, 17568, 5264, 9376, + 5272, 25760, 5288, 21664, 5296, 13472, 5304, 29856, 5320, 19616, + 5328, 11424, 5336, 27808, 5344, 7328, 5352, 23712, 5360, 15520, + 5368, 31904, 5384, 17056, 5392, 8864, 5400, 25248, 5416, 21152, + 5424, 12960, 5432, 29344, 5448, 19104, 5456, 10912, 5464, 27296, + 5472, 6816, 5480, 23200, 5488, 15008, 5496, 31392, 5512, 18080, + 5520, 9888, 5528, 26272, 5536, 5792, 5544, 22176, 5552, 13984, + 5560, 30368, 5576, 20128, 5584, 11936, 5592, 28320, 5600, 7840, + 5608, 24224, 5616, 16032, 5624, 32416, 5640, 16800, 5648, 8608, + 5656, 24992, 5672, 20896, 5680, 12704, 5688, 29088, 5704, 18848, + 5712, 10656, 5720, 27040, 5728, 6560, 5736, 22944, 5744, 14752, + 5752, 31136, 5768, 17824, 5776, 9632, 5784, 26016, 5800, 21920, + 5808, 13728, 5816, 30112, 5832, 19872, 5840, 11680, 5848, 28064, + 5856, 7584, 5864, 23968, 5872, 15776, 5880, 32160, 5896, 17312, + 5904, 9120, 5912, 25504, 5928, 21408, 5936, 13216, 5944, 29600, + 5960, 19360, 5968, 11168, 5976, 27552, 5984, 7072, 5992, 23456, + 6000, 15264, 6008, 31648, 6024, 18336, 6032, 10144, 6040, 26528, + 6056, 22432, 6064, 14240, 6072, 30624, 6088, 20384, 6096, 12192, + 6104, 28576, 6112, 8096, 6120, 24480, 6128, 16288, 6136, 32672, + 6152, 16480, 6160, 8288, 6168, 24672, 6184, 20576, 6192, 12384, + 6200, 28768, 6216, 18528, 6224, 10336, 6232, 26720, 6248, 22624, + 6256, 14432, 6264, 30816, 6280, 17504, 6288, 9312, 6296, 25696, + 6312, 21600, 6320, 13408, 6328, 29792, 6344, 19552, 6352, 11360, + 6360, 27744, 6368, 7264, 6376, 23648, 6384, 15456, 6392, 31840, + 6408, 16992, 6416, 8800, 6424, 25184, 6440, 21088, 6448, 12896, + 6456, 29280, 6472, 19040, 6480, 10848, 6488, 27232, 6496, 6752, + 6504, 23136, 6512, 14944, 6520, 31328, 6536, 18016, 6544, 9824, + 6552, 26208, 6568, 22112, 6576, 13920, 6584, 30304, 6600, 20064, + 6608, 11872, 6616, 28256, 6624, 7776, 6632, 24160, 6640, 15968, + 6648, 32352, 6664, 16736, 6672, 8544, 6680, 24928, 6696, 20832, + 6704, 12640, 6712, 29024, 6728, 18784, 6736, 10592, 6744, 26976, + 6760, 22880, 6768, 14688, 6776, 31072, 6792, 17760, 6800, 9568, + 6808, 25952, 6824, 21856, 6832, 13664, 6840, 30048, 6856, 19808, + 6864, 11616, 6872, 28000, 6880, 7520, 6888, 23904, 6896, 15712, + 6904, 32096, 6920, 17248, 6928, 9056, 6936, 25440, 6952, 21344, + 6960, 13152, 6968, 29536, 6984, 19296, 6992, 11104, 7000, 27488, + 7016, 23392, 7024, 15200, 7032, 31584, 7048, 18272, 7056, 10080, + 7064, 26464, 7080, 22368, 7088, 14176, 7096, 30560, 7112, 20320, + 7120, 12128, 7128, 28512, 7136, 8032, 7144, 24416, 7152, 16224, + 7160, 32608, 7176, 16608, 7184, 8416, 7192, 24800, 7208, 20704, + 7216, 12512, 7224, 28896, 7240, 18656, 7248, 10464, 7256, 26848, + 7272, 22752, 7280, 14560, 7288, 30944, 7304, 17632, 7312, 9440, + 7320, 25824, 7336, 21728, 7344, 13536, 7352, 29920, 7368, 19680, + 7376, 11488, 7384, 27872, 7400, 23776, 7408, 15584, 7416, 31968, + 7432, 17120, 7440, 8928, 7448, 25312, 7464, 21216, 7472, 13024, + 7480, 29408, 7496, 19168, 7504, 10976, 7512, 27360, 7528, 23264, + 7536, 15072, 7544, 31456, 7560, 18144, 7568, 9952, 7576, 26336, + 7592, 22240, 7600, 14048, 7608, 30432, 7624, 20192, 7632, 12000, + 7640, 28384, 7648, 7904, 7656, 24288, 7664, 16096, 7672, 32480, + 7688, 16864, 7696, 8672, 7704, 25056, 7720, 20960, 7728, 12768, + 7736, 29152, 7752, 18912, 7760, 10720, 7768, 27104, 7784, 23008, + 7792, 14816, 7800, 31200, 7816, 17888, 7824, 9696, 7832, 26080, + 7848, 21984, 7856, 13792, 7864, 30176, 7880, 19936, 7888, 11744, + 7896, 28128, 7912, 24032, 7920, 15840, 7928, 32224, 7944, 17376, + 7952, 9184, 7960, 25568, 7976, 21472, 7984, 13280, 7992, 29664, + 8008, 19424, 8016, 11232, 8024, 27616, 8040, 23520, 8048, 15328, + 8056, 31712, 8072, 18400, 8080, 10208, 8088, 26592, 8104, 22496, + 8112, 14304, 8120, 30688, 8136, 20448, 8144, 12256, 8152, 28640, + 8168, 24544, 8176, 16352, 8184, 32736, 8200, 16400, 8216, 24592, + 8232, 20496, 8240, 12304, 8248, 28688, 8264, 18448, 8272, 10256, + 8280, 26640, 8296, 22544, 8304, 14352, 8312, 30736, 8328, 17424, + 8336, 9232, 8344, 25616, 8360, 21520, 8368, 13328, 8376, 29712, + 8392, 19472, 8400, 11280, 8408, 27664, 8424, 23568, 8432, 15376, + 8440, 31760, 8456, 16912, 8464, 8720, 8472, 25104, 8488, 21008, + 8496, 12816, 8504, 29200, 8520, 18960, 8528, 10768, 8536, 27152, + 8552, 23056, 8560, 14864, 8568, 31248, 8584, 17936, 8592, 9744, + 8600, 26128, 8616, 22032, 8624, 13840, 8632, 30224, 8648, 19984, + 8656, 11792, 8664, 28176, 8680, 24080, 8688, 15888, 8696, 32272, + 8712, 16656, 8728, 24848, 8744, 20752, 8752, 12560, 8760, 28944, + 8776, 18704, 8784, 10512, 8792, 26896, 8808, 22800, 8816, 14608, + 8824, 30992, 8840, 17680, 8848, 9488, 8856, 25872, 8872, 21776, + 8880, 13584, 8888, 29968, 8904, 19728, 8912, 11536, 8920, 27920, + 8936, 23824, 8944, 15632, 8952, 32016, 8968, 17168, 8984, 25360, + 9000, 21264, 9008, 13072, 9016, 29456, 9032, 19216, 9040, 11024, + 9048, 27408, 9064, 23312, 9072, 15120, 9080, 31504, 9096, 18192, + 9104, 10000, 9112, 26384, 9128, 22288, 9136, 14096, 9144, 30480, + 9160, 20240, 9168, 12048, 9176, 28432, 9192, 24336, 9200, 16144, + 9208, 32528, 9224, 16528, 9240, 24720, 9256, 20624, 9264, 12432, + 9272, 28816, 9288, 18576, 9296, 10384, 9304, 26768, 9320, 22672, + 9328, 14480, 9336, 30864, 9352, 17552, 9368, 25744, 9384, 21648, + 9392, 13456, 9400, 29840, 9416, 19600, 9424, 11408, 9432, 27792, + 9448, 23696, 9456, 15504, 9464, 31888, 9480, 17040, 9496, 25232, + 9512, 21136, 9520, 12944, 9528, 29328, 9544, 19088, 9552, 10896, + 9560, 27280, 9576, 23184, 9584, 14992, 9592, 31376, 9608, 18064, + 9616, 9872, 9624, 26256, 9640, 22160, 9648, 13968, 9656, 30352, + 9672, 20112, 9680, 11920, 9688, 28304, 9704, 24208, 9712, 16016, + 9720, 32400, 9736, 16784, 9752, 24976, 9768, 20880, 9776, 12688, + 9784, 29072, 9800, 18832, 9808, 10640, 9816, 27024, 9832, 22928, + 9840, 14736, 9848, 31120, 9864, 17808, 9880, 26000, 9896, 21904, + 9904, 13712, 9912, 30096, 9928, 19856, 9936, 11664, 9944, 28048, + 9960, 23952, 9968, 15760, 9976, 32144, 9992, 17296, 10008, 25488, + 10024, 21392, 10032, 13200, 10040, 29584, 10056, 19344, 10064, 11152, + 10072, 27536, 10088, 23440, 10096, 15248, 10104, 31632, 10120, 18320, + 10136, 26512, 10152, 22416, 10160, 14224, 10168, 30608, 10184, 20368, + 10192, 12176, 10200, 28560, 10216, 24464, 10224, 16272, 10232, 32656, + 10248, 16464, 10264, 24656, 10280, 20560, 10288, 12368, 10296, 28752, + 10312, 18512, 10328, 26704, 10344, 22608, 10352, 14416, 10360, 30800, + 10376, 17488, 10392, 25680, 10408, 21584, 10416, 13392, 10424, 29776, + 10440, 19536, 10448, 11344, 10456, 27728, 10472, 23632, 10480, 15440, + 10488, 31824, 10504, 16976, 10520, 25168, 10536, 21072, 10544, 12880, + 10552, 29264, 10568, 19024, 10576, 10832, 10584, 27216, 10600, 23120, + 10608, 14928, 10616, 31312, 10632, 18000, 10648, 26192, 10664, 22096, + 10672, 13904, 10680, 30288, 10696, 20048, 10704, 11856, 10712, 28240, + 10728, 24144, 10736, 15952, 10744, 32336, 10760, 16720, 10776, 24912, + 10792, 20816, 10800, 12624, 10808, 29008, 10824, 18768, 10840, 26960, + 10856, 22864, 10864, 14672, 10872, 31056, 10888, 17744, 10904, 25936, + 10920, 21840, 10928, 13648, 10936, 30032, 10952, 19792, 10960, 11600, + 10968, 27984, 10984, 23888, 10992, 15696, 11000, 32080, 11016, 17232, + 11032, 25424, 11048, 21328, 11056, 13136, 11064, 29520, 11080, 19280, + 11096, 27472, 11112, 23376, 11120, 15184, 11128, 31568, 11144, 18256, + 11160, 26448, 11176, 22352, 11184, 14160, 11192, 30544, 11208, 20304, + 11216, 12112, 11224, 28496, 11240, 24400, 11248, 16208, 11256, 32592, + 11272, 16592, 11288, 24784, 11304, 20688, 11312, 12496, 11320, 28880, + 11336, 18640, 11352, 26832, 11368, 22736, 11376, 14544, 11384, 30928, + 11400, 17616, 11416, 25808, 11432, 21712, 11440, 13520, 11448, 29904, + 11464, 19664, 11480, 27856, 11496, 23760, 11504, 15568, 11512, 31952, + 11528, 17104, 11544, 25296, 11560, 21200, 11568, 13008, 11576, 29392, + 11592, 19152, 11608, 27344, 11624, 23248, 11632, 15056, 11640, 31440, + 11656, 18128, 11672, 26320, 11688, 22224, 11696, 14032, 11704, 30416, + 11720, 20176, 11728, 11984, 11736, 28368, 11752, 24272, 11760, 16080, + 11768, 32464, 11784, 16848, 11800, 25040, 11816, 20944, 11824, 12752, + 11832, 29136, 11848, 18896, 11864, 27088, 11880, 22992, 11888, 14800, + 11896, 31184, 11912, 17872, 11928, 26064, 11944, 21968, 11952, 13776, + 11960, 30160, 11976, 19920, 11992, 28112, 12008, 24016, 12016, 15824, + 12024, 32208, 12040, 17360, 12056, 25552, 12072, 21456, 12080, 13264, + 12088, 29648, 12104, 19408, 12120, 27600, 12136, 23504, 12144, 15312, + 12152, 31696, 12168, 18384, 12184, 26576, 12200, 22480, 12208, 14288, + 12216, 30672, 12232, 20432, 12248, 28624, 12264, 24528, 12272, 16336, + 12280, 32720, 12296, 16432, 12312, 24624, 12328, 20528, 12344, 28720, + 12360, 18480, 12376, 26672, 12392, 22576, 12400, 14384, 12408, 30768, + 12424, 17456, 12440, 25648, 12456, 21552, 12464, 13360, 12472, 29744, + 12488, 19504, 12504, 27696, 12520, 23600, 12528, 15408, 12536, 31792, + 12552, 16944, 12568, 25136, 12584, 21040, 12592, 12848, 12600, 29232, + 12616, 18992, 12632, 27184, 12648, 23088, 12656, 14896, 12664, 31280, + 12680, 17968, 12696, 26160, 12712, 22064, 12720, 13872, 12728, 30256, + 12744, 20016, 12760, 28208, 12776, 24112, 12784, 15920, 12792, 32304, + 12808, 16688, 12824, 24880, 12840, 20784, 12856, 28976, 12872, 18736, + 12888, 26928, 12904, 22832, 12912, 14640, 12920, 31024, 12936, 17712, + 12952, 25904, 12968, 21808, 12976, 13616, 12984, 30000, 13000, 19760, + 13016, 27952, 13032, 23856, 13040, 15664, 13048, 32048, 13064, 17200, + 13080, 25392, 13096, 21296, 13112, 29488, 13128, 19248, 13144, 27440, + 13160, 23344, 13168, 15152, 13176, 31536, 13192, 18224, 13208, 26416, + 13224, 22320, 13232, 14128, 13240, 30512, 13256, 20272, 13272, 28464, + 13288, 24368, 13296, 16176, 13304, 32560, 13320, 16560, 13336, 24752, + 13352, 20656, 13368, 28848, 13384, 18608, 13400, 26800, 13416, 22704, + 13424, 14512, 13432, 30896, 13448, 17584, 13464, 25776, 13480, 21680, + 13496, 29872, 13512, 19632, 13528, 27824, 13544, 23728, 13552, 15536, + 13560, 31920, 13576, 17072, 13592, 25264, 13608, 21168, 13624, 29360, + 13640, 19120, 13656, 27312, 13672, 23216, 13680, 15024, 13688, 31408, + 13704, 18096, 13720, 26288, 13736, 22192, 13744, 14000, 13752, 30384, + 13768, 20144, 13784, 28336, 13800, 24240, 13808, 16048, 13816, 32432, + 13832, 16816, 13848, 25008, 13864, 20912, 13880, 29104, 13896, 18864, + 13912, 27056, 13928, 22960, 13936, 14768, 13944, 31152, 13960, 17840, + 13976, 26032, 13992, 21936, 14008, 30128, 14024, 19888, 14040, 28080, + 14056, 23984, 14064, 15792, 14072, 32176, 14088, 17328, 14104, 25520, + 14120, 21424, 14136, 29616, 14152, 19376, 14168, 27568, 14184, 23472, + 14192, 15280, 14200, 31664, 14216, 18352, 14232, 26544, 14248, 22448, + 14264, 30640, 14280, 20400, 14296, 28592, 14312, 24496, 14320, 16304, + 14328, 32688, 14344, 16496, 14360, 24688, 14376, 20592, 14392, 28784, + 14408, 18544, 14424, 26736, 14440, 22640, 14456, 30832, 14472, 17520, + 14488, 25712, 14504, 21616, 14520, 29808, 14536, 19568, 14552, 27760, + 14568, 23664, 14576, 15472, 14584, 31856, 14600, 17008, 14616, 25200, + 14632, 21104, 14648, 29296, 14664, 19056, 14680, 27248, 14696, 23152, + 14704, 14960, 14712, 31344, 14728, 18032, 14744, 26224, 14760, 22128, + 14776, 30320, 14792, 20080, 14808, 28272, 14824, 24176, 14832, 15984, + 14840, 32368, 14856, 16752, 14872, 24944, 14888, 20848, 14904, 29040, + 14920, 18800, 14936, 26992, 14952, 22896, 14968, 31088, 14984, 17776, + 15000, 25968, 15016, 21872, 15032, 30064, 15048, 19824, 15064, 28016, + 15080, 23920, 15088, 15728, 15096, 32112, 15112, 17264, 15128, 25456, + 15144, 21360, 15160, 29552, 15176, 19312, 15192, 27504, 15208, 23408, + 15224, 31600, 15240, 18288, 15256, 26480, 15272, 22384, 15288, 30576, + 15304, 20336, 15320, 28528, 15336, 24432, 15344, 16240, 15352, 32624, + 15368, 16624, 15384, 24816, 15400, 20720, 15416, 28912, 15432, 18672, + 15448, 26864, 15464, 22768, 15480, 30960, 15496, 17648, 15512, 25840, + 15528, 21744, 15544, 29936, 15560, 19696, 15576, 27888, 15592, 23792, + 15608, 31984, 15624, 17136, 15640, 25328, 15656, 21232, 15672, 29424, + 15688, 19184, 15704, 27376, 15720, 23280, 15736, 31472, 15752, 18160, + 15768, 26352, 15784, 22256, 15800, 30448, 15816, 20208, 15832, 28400, + 15848, 24304, 15856, 16112, 15864, 32496, 15880, 16880, 15896, 25072, + 15912, 20976, 15928, 29168, 15944, 18928, 15960, 27120, 15976, 23024, + 15992, 31216, 16008, 17904, 16024, 26096, 16040, 22000, 16056, 30192, + 16072, 19952, 16088, 28144, 16104, 24048, 16120, 32240, 16136, 17392, + 16152, 25584, 16168, 21488, 16184, 29680, 16200, 19440, 16216, 27632, + 16232, 23536, 16248, 31728, 16264, 18416, 16280, 26608, 16296, 22512, + 16312, 30704, 16328, 20464, 16344, 28656, 16360, 24560, 16376, 32752, + 16408, 24584, 16424, 20488, 16440, 28680, 16456, 18440, 16472, 26632, + 16488, 22536, 16504, 30728, 16520, 17416, 16536, 25608, 16552, 21512, + 16568, 29704, 16584, 19464, 16600, 27656, 16616, 23560, 16632, 31752, + 16648, 16904, 16664, 25096, 16680, 21000, 16696, 29192, 16712, 18952, + 16728, 27144, 16744, 23048, 16760, 31240, 16776, 17928, 16792, 26120, + 16808, 22024, 16824, 30216, 16840, 19976, 16856, 28168, 16872, 24072, + 16888, 32264, 16920, 24840, 16936, 20744, 16952, 28936, 16968, 18696, + 16984, 26888, 17000, 22792, 17016, 30984, 17032, 17672, 17048, 25864, + 17064, 21768, 17080, 29960, 17096, 19720, 17112, 27912, 17128, 23816, + 17144, 32008, 17176, 25352, 17192, 21256, 17208, 29448, 17224, 19208, + 17240, 27400, 17256, 23304, 17272, 31496, 17288, 18184, 17304, 26376, + 17320, 22280, 17336, 30472, 17352, 20232, 17368, 28424, 17384, 24328, + 17400, 32520, 17432, 24712, 17448, 20616, 17464, 28808, 17480, 18568, + 17496, 26760, 17512, 22664, 17528, 30856, 17560, 25736, 17576, 21640, + 17592, 29832, 17608, 19592, 17624, 27784, 17640, 23688, 17656, 31880, + 17688, 25224, 17704, 21128, 17720, 29320, 17736, 19080, 17752, 27272, + 17768, 23176, 17784, 31368, 17800, 18056, 17816, 26248, 17832, 22152, + 17848, 30344, 17864, 20104, 17880, 28296, 17896, 24200, 17912, 32392, + 17944, 24968, 17960, 20872, 17976, 29064, 17992, 18824, 18008, 27016, + 18024, 22920, 18040, 31112, 18072, 25992, 18088, 21896, 18104, 30088, + 18120, 19848, 18136, 28040, 18152, 23944, 18168, 32136, 18200, 25480, + 18216, 21384, 18232, 29576, 18248, 19336, 18264, 27528, 18280, 23432, + 18296, 31624, 18328, 26504, 18344, 22408, 18360, 30600, 18376, 20360, + 18392, 28552, 18408, 24456, 18424, 32648, 18456, 24648, 18472, 20552, + 18488, 28744, 18520, 26696, 18536, 22600, 18552, 30792, 18584, 25672, + 18600, 21576, 18616, 29768, 18632, 19528, 18648, 27720, 18664, 23624, + 18680, 31816, 18712, 25160, 18728, 21064, 18744, 29256, 18760, 19016, + 18776, 27208, 18792, 23112, 18808, 31304, 18840, 26184, 18856, 22088, + 18872, 30280, 18888, 20040, 18904, 28232, 18920, 24136, 18936, 32328, + 18968, 24904, 18984, 20808, 19000, 29000, 19032, 26952, 19048, 22856, + 19064, 31048, 19096, 25928, 19112, 21832, 19128, 30024, 19144, 19784, + 19160, 27976, 19176, 23880, 19192, 32072, 19224, 25416, 19240, 21320, + 19256, 29512, 19288, 27464, 19304, 23368, 19320, 31560, 19352, 26440, + 19368, 22344, 19384, 30536, 19400, 20296, 19416, 28488, 19432, 24392, + 19448, 32584, 19480, 24776, 19496, 20680, 19512, 28872, 19544, 26824, + 19560, 22728, 19576, 30920, 19608, 25800, 19624, 21704, 19640, 29896, + 19672, 27848, 19688, 23752, 19704, 31944, 19736, 25288, 19752, 21192, + 19768, 29384, 19800, 27336, 19816, 23240, 19832, 31432, 19864, 26312, + 19880, 22216, 19896, 30408, 19912, 20168, 19928, 28360, 19944, 24264, + 19960, 32456, 19992, 25032, 20008, 20936, 20024, 29128, 20056, 27080, + 20072, 22984, 20088, 31176, 20120, 26056, 20136, 21960, 20152, 30152, + 20184, 28104, 20200, 24008, 20216, 32200, 20248, 25544, 20264, 21448, + 20280, 29640, 20312, 27592, 20328, 23496, 20344, 31688, 20376, 26568, + 20392, 22472, 20408, 30664, 20440, 28616, 20456, 24520, 20472, 32712, + 20504, 24616, 20536, 28712, 20568, 26664, 20584, 22568, 20600, 30760, + 20632, 25640, 20648, 21544, 20664, 29736, 20696, 27688, 20712, 23592, + 20728, 31784, 20760, 25128, 20776, 21032, 20792, 29224, 20824, 27176, + 20840, 23080, 20856, 31272, 20888, 26152, 20904, 22056, 20920, 30248, + 20952, 28200, 20968, 24104, 20984, 32296, 21016, 24872, 21048, 28968, + 21080, 26920, 21096, 22824, 21112, 31016, 21144, 25896, 21160, 21800, + 21176, 29992, 21208, 27944, 21224, 23848, 21240, 32040, 21272, 25384, + 21304, 29480, 21336, 27432, 21352, 23336, 21368, 31528, 21400, 26408, + 21416, 22312, 21432, 30504, 21464, 28456, 21480, 24360, 21496, 32552, + 21528, 24744, 21560, 28840, 21592, 26792, 21608, 22696, 21624, 30888, + 21656, 25768, 21688, 29864, 21720, 27816, 21736, 23720, 21752, 31912, + 21784, 25256, 21816, 29352, 21848, 27304, 21864, 23208, 21880, 31400, + 21912, 26280, 21928, 22184, 21944, 30376, 21976, 28328, 21992, 24232, + 22008, 32424, 22040, 25000, 22072, 29096, 22104, 27048, 22120, 22952, + 22136, 31144, 22168, 26024, 22200, 30120, 22232, 28072, 22248, 23976, + 22264, 32168, 22296, 25512, 22328, 29608, 22360, 27560, 22376, 23464, + 22392, 31656, 22424, 26536, 22456, 30632, 22488, 28584, 22504, 24488, + 22520, 32680, 22552, 24680, 22584, 28776, 22616, 26728, 22648, 30824, + 22680, 25704, 22712, 29800, 22744, 27752, 22760, 23656, 22776, 31848, + 22808, 25192, 22840, 29288, 22872, 27240, 22888, 23144, 22904, 31336, + 22936, 26216, 22968, 30312, 23000, 28264, 23016, 24168, 23032, 32360, + 23064, 24936, 23096, 29032, 23128, 26984, 23160, 31080, 23192, 25960, + 23224, 30056, 23256, 28008, 23272, 23912, 23288, 32104, 23320, 25448, + 23352, 29544, 23384, 27496, 23416, 31592, 23448, 26472, 23480, 30568, + 23512, 28520, 23528, 24424, 23544, 32616, 23576, 24808, 23608, 28904, + 23640, 26856, 23672, 30952, 23704, 25832, 23736, 29928, 23768, 27880, + 23800, 31976, 23832, 25320, 23864, 29416, 23896, 27368, 23928, 31464, + 23960, 26344, 23992, 30440, 24024, 28392, 24040, 24296, 24056, 32488, + 24088, 25064, 24120, 29160, 24152, 27112, 24184, 31208, 24216, 26088, + 24248, 30184, 24280, 28136, 24312, 32232, 24344, 25576, 24376, 29672, + 24408, 27624, 24440, 31720, 24472, 26600, 24504, 30696, 24536, 28648, + 24568, 32744, 24632, 28696, 24664, 26648, 24696, 30744, 24728, 25624, + 24760, 29720, 24792, 27672, 24824, 31768, 24856, 25112, 24888, 29208, + 24920, 27160, 24952, 31256, 24984, 26136, 25016, 30232, 25048, 28184, + 25080, 32280, 25144, 28952, 25176, 26904, 25208, 31000, 25240, 25880, + 25272, 29976, 25304, 27928, 25336, 32024, 25400, 29464, 25432, 27416, + 25464, 31512, 25496, 26392, 25528, 30488, 25560, 28440, 25592, 32536, + 25656, 28824, 25688, 26776, 25720, 30872, 25784, 29848, 25816, 27800, + 25848, 31896, 25912, 29336, 25944, 27288, 25976, 31384, 26008, 26264, + 26040, 30360, 26072, 28312, 26104, 32408, 26168, 29080, 26200, 27032, + 26232, 31128, 26296, 30104, 26328, 28056, 26360, 32152, 26424, 29592, + 26456, 27544, 26488, 31640, 26552, 30616, 26584, 28568, 26616, 32664, + 26680, 28760, 26744, 30808, 26808, 29784, 26840, 27736, 26872, 31832, + 26936, 29272, 26968, 27224, 27000, 31320, 27064, 30296, 27096, 28248, + 27128, 32344, 27192, 29016, 27256, 31064, 27320, 30040, 27352, 27992, + 27384, 32088, 27448, 29528, 27512, 31576, 27576, 30552, 27608, 28504, + 27640, 32600, 27704, 28888, 27768, 30936, 27832, 29912, 27896, 31960, + 27960, 29400, 28024, 31448, 28088, 30424, 28120, 28376, 28152, 32472, + 28216, 29144, 28280, 31192, 28344, 30168, 28408, 32216, 28472, 29656, + 28536, 31704, 28600, 30680, 28664, 32728, 28792, 30776, 28856, 29752, + 28920, 31800, 28984, 29240, 29048, 31288, 29112, 30264, 29176, 32312, + 29304, 31032, 29368, 30008, 29432, 32056, 29560, 31544, 29624, 30520, + 29688, 32568, 29816, 30904, 29944, 31928, 30072, 31416, 30136, 30392, + 30200, 32440, 30328, 31160, 30456, 32184, 30584, 31672, 30712, 32696, + 30968, 31864, 31096, 31352, 31224, 32376, 31480, 32120, 31736, 32632, + 32248, 32504}; /** @par @@ -17751,4109 +11368,1665 @@ const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TAB Real and Imag values are in interleaved fashion */ const float32_t twiddleCoef_rfft_32[32] = { - 0.000000000f, 1.000000000f, - 0.195090322f, 0.980785280f, - 0.382683432f, 0.923879533f, - 0.555570233f, 0.831469612f, - 0.707106781f, 0.707106781f, - 0.831469612f, 0.555570233f, - 0.923879533f, 0.382683432f, - 0.980785280f, 0.195090322f, - 1.000000000f, 0.000000000f, - 0.980785280f, -0.195090322f, - 0.923879533f, -0.382683432f, - 0.831469612f, -0.555570233f, - 0.707106781f, -0.707106781f, - 0.555570233f, -0.831469612f, - 0.382683432f, -0.923879533f, - 0.195090322f, -0.980785280f -}; + 0.000000000f, 1.000000000f, 0.195090322f, 0.980785280f, 0.382683432f, + 0.923879533f, 0.555570233f, 0.831469612f, 0.707106781f, 0.707106781f, + 0.831469612f, 0.555570233f, 0.923879533f, 0.382683432f, 0.980785280f, + 0.195090322f, 1.000000000f, 0.000000000f, 0.980785280f, -0.195090322f, + 0.923879533f, -0.382683432f, 0.831469612f, -0.555570233f, 0.707106781f, + -0.707106781f, 0.555570233f, -0.831469612f, 0.382683432f, -0.923879533f, + 0.195090322f, -0.980785280f}; const float32_t twiddleCoef_rfft_64[64] = { - 0.000000000000000f, 1.000000000000000f, - 0.098017140329561f, 0.995184726672197f, - 0.195090322016128f, 0.980785280403230f, - 0.290284677254462f, 0.956940335732209f, - 0.382683432365090f, 0.923879532511287f, - 0.471396736825998f, 0.881921264348355f, - 0.555570233019602f, 0.831469612302545f, - 0.634393284163645f, 0.773010453362737f, - 0.707106781186547f, 0.707106781186548f, - 0.773010453362737f, 0.634393284163645f, - 0.831469612302545f, 0.555570233019602f, - 0.881921264348355f, 0.471396736825998f, - 0.923879532511287f, 0.382683432365090f, - 0.956940335732209f, 0.290284677254462f, - 0.980785280403230f, 0.195090322016128f, - 0.995184726672197f, 0.098017140329561f, - 1.000000000000000f, 0.000000000000000f, - 0.995184726672197f, -0.098017140329561f, - 0.980785280403230f, -0.195090322016128f, - 0.956940335732209f, -0.290284677254462f, - 0.923879532511287f, -0.382683432365090f, - 0.881921264348355f, -0.471396736825998f, - 0.831469612302545f, -0.555570233019602f, - 0.773010453362737f, -0.634393284163645f, - 0.707106781186548f, -0.707106781186547f, - 0.634393284163645f, -0.773010453362737f, - 0.555570233019602f, -0.831469612302545f, - 0.471396736825998f, -0.881921264348355f, - 0.382683432365090f, -0.923879532511287f, - 0.290284677254462f, -0.956940335732209f, - 0.195090322016129f, -0.980785280403230f, - 0.098017140329561f, -0.995184726672197f -}; + 0.000000000000000f, 1.000000000000000f, 0.098017140329561f, + 0.995184726672197f, 0.195090322016128f, 0.980785280403230f, + 0.290284677254462f, 0.956940335732209f, 0.382683432365090f, + 0.923879532511287f, 0.471396736825998f, 0.881921264348355f, + 0.555570233019602f, 0.831469612302545f, 0.634393284163645f, + 0.773010453362737f, 0.707106781186547f, 0.707106781186548f, + 0.773010453362737f, 0.634393284163645f, 0.831469612302545f, + 0.555570233019602f, 0.881921264348355f, 0.471396736825998f, + 0.923879532511287f, 0.382683432365090f, 0.956940335732209f, + 0.290284677254462f, 0.980785280403230f, 0.195090322016128f, + 0.995184726672197f, 0.098017140329561f, 1.000000000000000f, + 0.000000000000000f, 0.995184726672197f, -0.098017140329561f, + 0.980785280403230f, -0.195090322016128f, 0.956940335732209f, + -0.290284677254462f, 0.923879532511287f, -0.382683432365090f, + 0.881921264348355f, -0.471396736825998f, 0.831469612302545f, + -0.555570233019602f, 0.773010453362737f, -0.634393284163645f, + 0.707106781186548f, -0.707106781186547f, 0.634393284163645f, + -0.773010453362737f, 0.555570233019602f, -0.831469612302545f, + 0.471396736825998f, -0.881921264348355f, 0.382683432365090f, + -0.923879532511287f, 0.290284677254462f, -0.956940335732209f, + 0.195090322016129f, -0.980785280403230f, 0.098017140329561f, + -0.995184726672197f}; const float32_t twiddleCoef_rfft_128[128] = { - 0.000000000f, 1.000000000f, - 0.049067674f, 0.998795456f, - 0.098017140f, 0.995184727f, - 0.146730474f, 0.989176510f, - 0.195090322f, 0.980785280f, - 0.242980180f, 0.970031253f, - 0.290284677f, 0.956940336f, - 0.336889853f, 0.941544065f, - 0.382683432f, 0.923879533f, - 0.427555093f, 0.903989293f, - 0.471396737f, 0.881921264f, - 0.514102744f, 0.857728610f, - 0.555570233f, 0.831469612f, - 0.595699304f, 0.803207531f, - 0.634393284f, 0.773010453f, - 0.671558955f, 0.740951125f, - 0.707106781f, 0.707106781f, - 0.740951125f, 0.671558955f, - 0.773010453f, 0.634393284f, - 0.803207531f, 0.595699304f, - 0.831469612f, 0.555570233f, - 0.857728610f, 0.514102744f, - 0.881921264f, 0.471396737f, - 0.903989293f, 0.427555093f, - 0.923879533f, 0.382683432f, - 0.941544065f, 0.336889853f, - 0.956940336f, 0.290284677f, - 0.970031253f, 0.242980180f, - 0.980785280f, 0.195090322f, - 0.989176510f, 0.146730474f, - 0.995184727f, 0.098017140f, - 0.998795456f, 0.049067674f, - 1.000000000f, 0.000000000f, - 0.998795456f, -0.049067674f, - 0.995184727f, -0.098017140f, - 0.989176510f, -0.146730474f, - 0.980785280f, -0.195090322f, - 0.970031253f, -0.242980180f, - 0.956940336f, -0.290284677f, - 0.941544065f, -0.336889853f, - 0.923879533f, -0.382683432f, - 0.903989293f, -0.427555093f, - 0.881921264f, -0.471396737f, - 0.857728610f, -0.514102744f, - 0.831469612f, -0.555570233f, - 0.803207531f, -0.595699304f, - 0.773010453f, -0.634393284f, - 0.740951125f, -0.671558955f, - 0.707106781f, -0.707106781f, - 0.671558955f, -0.740951125f, - 0.634393284f, -0.773010453f, - 0.595699304f, -0.803207531f, - 0.555570233f, -0.831469612f, - 0.514102744f, -0.857728610f, - 0.471396737f, -0.881921264f, - 0.427555093f, -0.903989293f, - 0.382683432f, -0.923879533f, - 0.336889853f, -0.941544065f, - 0.290284677f, -0.956940336f, - 0.242980180f, -0.970031253f, - 0.195090322f, -0.980785280f, - 0.146730474f, -0.989176510f, - 0.098017140f, -0.995184727f, - 0.049067674f, -0.998795456f -}; + 0.000000000f, 1.000000000f, 0.049067674f, 0.998795456f, 0.098017140f, + 0.995184727f, 0.146730474f, 0.989176510f, 0.195090322f, 0.980785280f, + 0.242980180f, 0.970031253f, 0.290284677f, 0.956940336f, 0.336889853f, + 0.941544065f, 0.382683432f, 0.923879533f, 0.427555093f, 0.903989293f, + 0.471396737f, 0.881921264f, 0.514102744f, 0.857728610f, 0.555570233f, + 0.831469612f, 0.595699304f, 0.803207531f, 0.634393284f, 0.773010453f, + 0.671558955f, 0.740951125f, 0.707106781f, 0.707106781f, 0.740951125f, + 0.671558955f, 0.773010453f, 0.634393284f, 0.803207531f, 0.595699304f, + 0.831469612f, 0.555570233f, 0.857728610f, 0.514102744f, 0.881921264f, + 0.471396737f, 0.903989293f, 0.427555093f, 0.923879533f, 0.382683432f, + 0.941544065f, 0.336889853f, 0.956940336f, 0.290284677f, 0.970031253f, + 0.242980180f, 0.980785280f, 0.195090322f, 0.989176510f, 0.146730474f, + 0.995184727f, 0.098017140f, 0.998795456f, 0.049067674f, 1.000000000f, + 0.000000000f, 0.998795456f, -0.049067674f, 0.995184727f, -0.098017140f, + 0.989176510f, -0.146730474f, 0.980785280f, -0.195090322f, 0.970031253f, + -0.242980180f, 0.956940336f, -0.290284677f, 0.941544065f, -0.336889853f, + 0.923879533f, -0.382683432f, 0.903989293f, -0.427555093f, 0.881921264f, + -0.471396737f, 0.857728610f, -0.514102744f, 0.831469612f, -0.555570233f, + 0.803207531f, -0.595699304f, 0.773010453f, -0.634393284f, 0.740951125f, + -0.671558955f, 0.707106781f, -0.707106781f, 0.671558955f, -0.740951125f, + 0.634393284f, -0.773010453f, 0.595699304f, -0.803207531f, 0.555570233f, + -0.831469612f, 0.514102744f, -0.857728610f, 0.471396737f, -0.881921264f, + 0.427555093f, -0.903989293f, 0.382683432f, -0.923879533f, 0.336889853f, + -0.941544065f, 0.290284677f, -0.956940336f, 0.242980180f, -0.970031253f, + 0.195090322f, -0.980785280f, 0.146730474f, -0.989176510f, 0.098017140f, + -0.995184727f, 0.049067674f, -0.998795456f}; const float32_t twiddleCoef_rfft_256[256] = { - 0.000000000f, 1.000000000f, - 0.024541229f, 0.999698819f, - 0.049067674f, 0.998795456f, - 0.073564564f, 0.997290457f, - 0.098017140f, 0.995184727f, - 0.122410675f, 0.992479535f, - 0.146730474f, 0.989176510f, - 0.170961889f, 0.985277642f, - 0.195090322f, 0.980785280f, - 0.219101240f, 0.975702130f, - 0.242980180f, 0.970031253f, - 0.266712757f, 0.963776066f, - 0.290284677f, 0.956940336f, - 0.313681740f, 0.949528181f, - 0.336889853f, 0.941544065f, - 0.359895037f, 0.932992799f, - 0.382683432f, 0.923879533f, - 0.405241314f, 0.914209756f, - 0.427555093f, 0.903989293f, - 0.449611330f, 0.893224301f, - 0.471396737f, 0.881921264f, - 0.492898192f, 0.870086991f, - 0.514102744f, 0.857728610f, - 0.534997620f, 0.844853565f, - 0.555570233f, 0.831469612f, - 0.575808191f, 0.817584813f, - 0.595699304f, 0.803207531f, - 0.615231591f, 0.788346428f, - 0.634393284f, 0.773010453f, - 0.653172843f, 0.757208847f, - 0.671558955f, 0.740951125f, - 0.689540545f, 0.724247083f, - 0.707106781f, 0.707106781f, - 0.724247083f, 0.689540545f, - 0.740951125f, 0.671558955f, - 0.757208847f, 0.653172843f, - 0.773010453f, 0.634393284f, - 0.788346428f, 0.615231591f, - 0.803207531f, 0.595699304f, - 0.817584813f, 0.575808191f, - 0.831469612f, 0.555570233f, - 0.844853565f, 0.534997620f, - 0.857728610f, 0.514102744f, - 0.870086991f, 0.492898192f, - 0.881921264f, 0.471396737f, - 0.893224301f, 0.449611330f, - 0.903989293f, 0.427555093f, - 0.914209756f, 0.405241314f, - 0.923879533f, 0.382683432f, - 0.932992799f, 0.359895037f, - 0.941544065f, 0.336889853f, - 0.949528181f, 0.313681740f, - 0.956940336f, 0.290284677f, - 0.963776066f, 0.266712757f, - 0.970031253f, 0.242980180f, - 0.975702130f, 0.219101240f, - 0.980785280f, 0.195090322f, - 0.985277642f, 0.170961889f, - 0.989176510f, 0.146730474f, - 0.992479535f, 0.122410675f, - 0.995184727f, 0.098017140f, - 0.997290457f, 0.073564564f, - 0.998795456f, 0.049067674f, - 0.999698819f, 0.024541229f, - 1.000000000f, 0.000000000f, - 0.999698819f, -0.024541229f, - 0.998795456f, -0.049067674f, - 0.997290457f, -0.073564564f, - 0.995184727f, -0.098017140f, - 0.992479535f, -0.122410675f, - 0.989176510f, -0.146730474f, - 0.985277642f, -0.170961889f, - 0.980785280f, -0.195090322f, - 0.975702130f, -0.219101240f, - 0.970031253f, -0.242980180f, - 0.963776066f, -0.266712757f, - 0.956940336f, -0.290284677f, - 0.949528181f, -0.313681740f, - 0.941544065f, -0.336889853f, - 0.932992799f, -0.359895037f, - 0.923879533f, -0.382683432f, - 0.914209756f, -0.405241314f, - 0.903989293f, -0.427555093f, - 0.893224301f, -0.449611330f, - 0.881921264f, -0.471396737f, - 0.870086991f, -0.492898192f, - 0.857728610f, -0.514102744f, - 0.844853565f, -0.534997620f, - 0.831469612f, -0.555570233f, - 0.817584813f, -0.575808191f, - 0.803207531f, -0.595699304f, - 0.788346428f, -0.615231591f, - 0.773010453f, -0.634393284f, - 0.757208847f, -0.653172843f, - 0.740951125f, -0.671558955f, - 0.724247083f, -0.689540545f, - 0.707106781f, -0.707106781f, - 0.689540545f, -0.724247083f, - 0.671558955f, -0.740951125f, - 0.653172843f, -0.757208847f, - 0.634393284f, -0.773010453f, - 0.615231591f, -0.788346428f, - 0.595699304f, -0.803207531f, - 0.575808191f, -0.817584813f, - 0.555570233f, -0.831469612f, - 0.534997620f, -0.844853565f, - 0.514102744f, -0.857728610f, - 0.492898192f, -0.870086991f, - 0.471396737f, -0.881921264f, - 0.449611330f, -0.893224301f, - 0.427555093f, -0.903989293f, - 0.405241314f, -0.914209756f, - 0.382683432f, -0.923879533f, - 0.359895037f, -0.932992799f, - 0.336889853f, -0.941544065f, - 0.313681740f, -0.949528181f, - 0.290284677f, -0.956940336f, - 0.266712757f, -0.963776066f, - 0.242980180f, -0.970031253f, - 0.219101240f, -0.975702130f, - 0.195090322f, -0.980785280f, - 0.170961889f, -0.985277642f, - 0.146730474f, -0.989176510f, - 0.122410675f, -0.992479535f, - 0.098017140f, -0.995184727f, - 0.073564564f, -0.997290457f, - 0.049067674f, -0.998795456f, - 0.024541229f, -0.999698819f -}; + 0.000000000f, 1.000000000f, 0.024541229f, 0.999698819f, 0.049067674f, + 0.998795456f, 0.073564564f, 0.997290457f, 0.098017140f, 0.995184727f, + 0.122410675f, 0.992479535f, 0.146730474f, 0.989176510f, 0.170961889f, + 0.985277642f, 0.195090322f, 0.980785280f, 0.219101240f, 0.975702130f, + 0.242980180f, 0.970031253f, 0.266712757f, 0.963776066f, 0.290284677f, + 0.956940336f, 0.313681740f, 0.949528181f, 0.336889853f, 0.941544065f, + 0.359895037f, 0.932992799f, 0.382683432f, 0.923879533f, 0.405241314f, + 0.914209756f, 0.427555093f, 0.903989293f, 0.449611330f, 0.893224301f, + 0.471396737f, 0.881921264f, 0.492898192f, 0.870086991f, 0.514102744f, + 0.857728610f, 0.534997620f, 0.844853565f, 0.555570233f, 0.831469612f, + 0.575808191f, 0.817584813f, 0.595699304f, 0.803207531f, 0.615231591f, + 0.788346428f, 0.634393284f, 0.773010453f, 0.653172843f, 0.757208847f, + 0.671558955f, 0.740951125f, 0.689540545f, 0.724247083f, 0.707106781f, + 0.707106781f, 0.724247083f, 0.689540545f, 0.740951125f, 0.671558955f, + 0.757208847f, 0.653172843f, 0.773010453f, 0.634393284f, 0.788346428f, + 0.615231591f, 0.803207531f, 0.595699304f, 0.817584813f, 0.575808191f, + 0.831469612f, 0.555570233f, 0.844853565f, 0.534997620f, 0.857728610f, + 0.514102744f, 0.870086991f, 0.492898192f, 0.881921264f, 0.471396737f, + 0.893224301f, 0.449611330f, 0.903989293f, 0.427555093f, 0.914209756f, + 0.405241314f, 0.923879533f, 0.382683432f, 0.932992799f, 0.359895037f, + 0.941544065f, 0.336889853f, 0.949528181f, 0.313681740f, 0.956940336f, + 0.290284677f, 0.963776066f, 0.266712757f, 0.970031253f, 0.242980180f, + 0.975702130f, 0.219101240f, 0.980785280f, 0.195090322f, 0.985277642f, + 0.170961889f, 0.989176510f, 0.146730474f, 0.992479535f, 0.122410675f, + 0.995184727f, 0.098017140f, 0.997290457f, 0.073564564f, 0.998795456f, + 0.049067674f, 0.999698819f, 0.024541229f, 1.000000000f, 0.000000000f, + 0.999698819f, -0.024541229f, 0.998795456f, -0.049067674f, 0.997290457f, + -0.073564564f, 0.995184727f, -0.098017140f, 0.992479535f, -0.122410675f, + 0.989176510f, -0.146730474f, 0.985277642f, -0.170961889f, 0.980785280f, + -0.195090322f, 0.975702130f, -0.219101240f, 0.970031253f, -0.242980180f, + 0.963776066f, -0.266712757f, 0.956940336f, -0.290284677f, 0.949528181f, + -0.313681740f, 0.941544065f, -0.336889853f, 0.932992799f, -0.359895037f, + 0.923879533f, -0.382683432f, 0.914209756f, -0.405241314f, 0.903989293f, + -0.427555093f, 0.893224301f, -0.449611330f, 0.881921264f, -0.471396737f, + 0.870086991f, -0.492898192f, 0.857728610f, -0.514102744f, 0.844853565f, + -0.534997620f, 0.831469612f, -0.555570233f, 0.817584813f, -0.575808191f, + 0.803207531f, -0.595699304f, 0.788346428f, -0.615231591f, 0.773010453f, + -0.634393284f, 0.757208847f, -0.653172843f, 0.740951125f, -0.671558955f, + 0.724247083f, -0.689540545f, 0.707106781f, -0.707106781f, 0.689540545f, + -0.724247083f, 0.671558955f, -0.740951125f, 0.653172843f, -0.757208847f, + 0.634393284f, -0.773010453f, 0.615231591f, -0.788346428f, 0.595699304f, + -0.803207531f, 0.575808191f, -0.817584813f, 0.555570233f, -0.831469612f, + 0.534997620f, -0.844853565f, 0.514102744f, -0.857728610f, 0.492898192f, + -0.870086991f, 0.471396737f, -0.881921264f, 0.449611330f, -0.893224301f, + 0.427555093f, -0.903989293f, 0.405241314f, -0.914209756f, 0.382683432f, + -0.923879533f, 0.359895037f, -0.932992799f, 0.336889853f, -0.941544065f, + 0.313681740f, -0.949528181f, 0.290284677f, -0.956940336f, 0.266712757f, + -0.963776066f, 0.242980180f, -0.970031253f, 0.219101240f, -0.975702130f, + 0.195090322f, -0.980785280f, 0.170961889f, -0.985277642f, 0.146730474f, + -0.989176510f, 0.122410675f, -0.992479535f, 0.098017140f, -0.995184727f, + 0.073564564f, -0.997290457f, 0.049067674f, -0.998795456f, 0.024541229f, + -0.999698819f}; const float32_t twiddleCoef_rfft_512[512] = { - 0.000000000f, 1.000000000f, - 0.012271538f, 0.999924702f, - 0.024541229f, 0.999698819f, - 0.036807223f, 0.999322385f, - 0.049067674f, 0.998795456f, - 0.061320736f, 0.998118113f, - 0.073564564f, 0.997290457f, - 0.085797312f, 0.996312612f, - 0.098017140f, 0.995184727f, - 0.110222207f, 0.993906970f, - 0.122410675f, 0.992479535f, - 0.134580709f, 0.990902635f, - 0.146730474f, 0.989176510f, - 0.158858143f, 0.987301418f, - 0.170961889f, 0.985277642f, - 0.183039888f, 0.983105487f, - 0.195090322f, 0.980785280f, - 0.207111376f, 0.978317371f, - 0.219101240f, 0.975702130f, - 0.231058108f, 0.972939952f, - 0.242980180f, 0.970031253f, - 0.254865660f, 0.966976471f, - 0.266712757f, 0.963776066f, - 0.278519689f, 0.960430519f, - 0.290284677f, 0.956940336f, - 0.302005949f, 0.953306040f, - 0.313681740f, 0.949528181f, - 0.325310292f, 0.945607325f, - 0.336889853f, 0.941544065f, - 0.348418680f, 0.937339012f, - 0.359895037f, 0.932992799f, - 0.371317194f, 0.928506080f, - 0.382683432f, 0.923879533f, - 0.393992040f, 0.919113852f, - 0.405241314f, 0.914209756f, - 0.416429560f, 0.909167983f, - 0.427555093f, 0.903989293f, - 0.438616239f, 0.898674466f, - 0.449611330f, 0.893224301f, - 0.460538711f, 0.887639620f, - 0.471396737f, 0.881921264f, - 0.482183772f, 0.876070094f, - 0.492898192f, 0.870086991f, - 0.503538384f, 0.863972856f, - 0.514102744f, 0.857728610f, - 0.524589683f, 0.851355193f, - 0.534997620f, 0.844853565f, - 0.545324988f, 0.838224706f, - 0.555570233f, 0.831469612f, - 0.565731811f, 0.824589303f, - 0.575808191f, 0.817584813f, - 0.585797857f, 0.810457198f, - 0.595699304f, 0.803207531f, - 0.605511041f, 0.795836905f, - 0.615231591f, 0.788346428f, - 0.624859488f, 0.780737229f, - 0.634393284f, 0.773010453f, - 0.643831543f, 0.765167266f, - 0.653172843f, 0.757208847f, - 0.662415778f, 0.749136395f, - 0.671558955f, 0.740951125f, - 0.680600998f, 0.732654272f, - 0.689540545f, 0.724247083f, - 0.698376249f, 0.715730825f, - 0.707106781f, 0.707106781f, - 0.715730825f, 0.698376249f, - 0.724247083f, 0.689540545f, - 0.732654272f, 0.680600998f, - 0.740951125f, 0.671558955f, - 0.749136395f, 0.662415778f, - 0.757208847f, 0.653172843f, - 0.765167266f, 0.643831543f, - 0.773010453f, 0.634393284f, - 0.780737229f, 0.624859488f, - 0.788346428f, 0.615231591f, - 0.795836905f, 0.605511041f, - 0.803207531f, 0.595699304f, - 0.810457198f, 0.585797857f, - 0.817584813f, 0.575808191f, - 0.824589303f, 0.565731811f, - 0.831469612f, 0.555570233f, - 0.838224706f, 0.545324988f, - 0.844853565f, 0.534997620f, - 0.851355193f, 0.524589683f, - 0.857728610f, 0.514102744f, - 0.863972856f, 0.503538384f, - 0.870086991f, 0.492898192f, - 0.876070094f, 0.482183772f, - 0.881921264f, 0.471396737f, - 0.887639620f, 0.460538711f, - 0.893224301f, 0.449611330f, - 0.898674466f, 0.438616239f, - 0.903989293f, 0.427555093f, - 0.909167983f, 0.416429560f, - 0.914209756f, 0.405241314f, - 0.919113852f, 0.393992040f, - 0.923879533f, 0.382683432f, - 0.928506080f, 0.371317194f, - 0.932992799f, 0.359895037f, - 0.937339012f, 0.348418680f, - 0.941544065f, 0.336889853f, - 0.945607325f, 0.325310292f, - 0.949528181f, 0.313681740f, - 0.953306040f, 0.302005949f, - 0.956940336f, 0.290284677f, - 0.960430519f, 0.278519689f, - 0.963776066f, 0.266712757f, - 0.966976471f, 0.254865660f, - 0.970031253f, 0.242980180f, - 0.972939952f, 0.231058108f, - 0.975702130f, 0.219101240f, - 0.978317371f, 0.207111376f, - 0.980785280f, 0.195090322f, - 0.983105487f, 0.183039888f, - 0.985277642f, 0.170961889f, - 0.987301418f, 0.158858143f, - 0.989176510f, 0.146730474f, - 0.990902635f, 0.134580709f, - 0.992479535f, 0.122410675f, - 0.993906970f, 0.110222207f, - 0.995184727f, 0.098017140f, - 0.996312612f, 0.085797312f, - 0.997290457f, 0.073564564f, - 0.998118113f, 0.061320736f, - 0.998795456f, 0.049067674f, - 0.999322385f, 0.036807223f, - 0.999698819f, 0.024541229f, - 0.999924702f, 0.012271538f, - 1.000000000f, 0.000000000f, - 0.999924702f, -0.012271538f, - 0.999698819f, -0.024541229f, - 0.999322385f, -0.036807223f, - 0.998795456f, -0.049067674f, - 0.998118113f, -0.061320736f, - 0.997290457f, -0.073564564f, - 0.996312612f, -0.085797312f, - 0.995184727f, -0.098017140f, - 0.993906970f, -0.110222207f, - 0.992479535f, -0.122410675f, - 0.990902635f, -0.134580709f, - 0.989176510f, -0.146730474f, - 0.987301418f, -0.158858143f, - 0.985277642f, -0.170961889f, - 0.983105487f, -0.183039888f, - 0.980785280f, -0.195090322f, - 0.978317371f, -0.207111376f, - 0.975702130f, -0.219101240f, - 0.972939952f, -0.231058108f, - 0.970031253f, -0.242980180f, - 0.966976471f, -0.254865660f, - 0.963776066f, -0.266712757f, - 0.960430519f, -0.278519689f, - 0.956940336f, -0.290284677f, - 0.953306040f, -0.302005949f, - 0.949528181f, -0.313681740f, - 0.945607325f, -0.325310292f, - 0.941544065f, -0.336889853f, - 0.937339012f, -0.348418680f, - 0.932992799f, -0.359895037f, - 0.928506080f, -0.371317194f, - 0.923879533f, -0.382683432f, - 0.919113852f, -0.393992040f, - 0.914209756f, -0.405241314f, - 0.909167983f, -0.416429560f, - 0.903989293f, -0.427555093f, - 0.898674466f, -0.438616239f, - 0.893224301f, -0.449611330f, - 0.887639620f, -0.460538711f, - 0.881921264f, -0.471396737f, - 0.876070094f, -0.482183772f, - 0.870086991f, -0.492898192f, - 0.863972856f, -0.503538384f, - 0.857728610f, -0.514102744f, - 0.851355193f, -0.524589683f, - 0.844853565f, -0.534997620f, - 0.838224706f, -0.545324988f, - 0.831469612f, -0.555570233f, - 0.824589303f, -0.565731811f, - 0.817584813f, -0.575808191f, - 0.810457198f, -0.585797857f, - 0.803207531f, -0.595699304f, - 0.795836905f, -0.605511041f, - 0.788346428f, -0.615231591f, - 0.780737229f, -0.624859488f, - 0.773010453f, -0.634393284f, - 0.765167266f, -0.643831543f, - 0.757208847f, -0.653172843f, - 0.749136395f, -0.662415778f, - 0.740951125f, -0.671558955f, - 0.732654272f, -0.680600998f, - 0.724247083f, -0.689540545f, - 0.715730825f, -0.698376249f, - 0.707106781f, -0.707106781f, - 0.698376249f, -0.715730825f, - 0.689540545f, -0.724247083f, - 0.680600998f, -0.732654272f, - 0.671558955f, -0.740951125f, - 0.662415778f, -0.749136395f, - 0.653172843f, -0.757208847f, - 0.643831543f, -0.765167266f, - 0.634393284f, -0.773010453f, - 0.624859488f, -0.780737229f, - 0.615231591f, -0.788346428f, - 0.605511041f, -0.795836905f, - 0.595699304f, -0.803207531f, - 0.585797857f, -0.810457198f, - 0.575808191f, -0.817584813f, - 0.565731811f, -0.824589303f, - 0.555570233f, -0.831469612f, - 0.545324988f, -0.838224706f, - 0.534997620f, -0.844853565f, - 0.524589683f, -0.851355193f, - 0.514102744f, -0.857728610f, - 0.503538384f, -0.863972856f, - 0.492898192f, -0.870086991f, - 0.482183772f, -0.876070094f, - 0.471396737f, -0.881921264f, - 0.460538711f, -0.887639620f, - 0.449611330f, -0.893224301f, - 0.438616239f, -0.898674466f, - 0.427555093f, -0.903989293f, - 0.416429560f, -0.909167983f, - 0.405241314f, -0.914209756f, - 0.393992040f, -0.919113852f, - 0.382683432f, -0.923879533f, - 0.371317194f, -0.928506080f, - 0.359895037f, -0.932992799f, - 0.348418680f, -0.937339012f, - 0.336889853f, -0.941544065f, - 0.325310292f, -0.945607325f, - 0.313681740f, -0.949528181f, - 0.302005949f, -0.953306040f, - 0.290284677f, -0.956940336f, - 0.278519689f, -0.960430519f, - 0.266712757f, -0.963776066f, - 0.254865660f, -0.966976471f, - 0.242980180f, -0.970031253f, - 0.231058108f, -0.972939952f, - 0.219101240f, -0.975702130f, - 0.207111376f, -0.978317371f, - 0.195090322f, -0.980785280f, - 0.183039888f, -0.983105487f, - 0.170961889f, -0.985277642f, - 0.158858143f, -0.987301418f, - 0.146730474f, -0.989176510f, - 0.134580709f, -0.990902635f, - 0.122410675f, -0.992479535f, - 0.110222207f, -0.993906970f, - 0.098017140f, -0.995184727f, - 0.085797312f, -0.996312612f, - 0.073564564f, -0.997290457f, - 0.061320736f, -0.998118113f, - 0.049067674f, -0.998795456f, - 0.036807223f, -0.999322385f, - 0.024541229f, -0.999698819f, - 0.012271538f, -0.999924702f -}; + 0.000000000f, 1.000000000f, 0.012271538f, 0.999924702f, 0.024541229f, + 0.999698819f, 0.036807223f, 0.999322385f, 0.049067674f, 0.998795456f, + 0.061320736f, 0.998118113f, 0.073564564f, 0.997290457f, 0.085797312f, + 0.996312612f, 0.098017140f, 0.995184727f, 0.110222207f, 0.993906970f, + 0.122410675f, 0.992479535f, 0.134580709f, 0.990902635f, 0.146730474f, + 0.989176510f, 0.158858143f, 0.987301418f, 0.170961889f, 0.985277642f, + 0.183039888f, 0.983105487f, 0.195090322f, 0.980785280f, 0.207111376f, + 0.978317371f, 0.219101240f, 0.975702130f, 0.231058108f, 0.972939952f, + 0.242980180f, 0.970031253f, 0.254865660f, 0.966976471f, 0.266712757f, + 0.963776066f, 0.278519689f, 0.960430519f, 0.290284677f, 0.956940336f, + 0.302005949f, 0.953306040f, 0.313681740f, 0.949528181f, 0.325310292f, + 0.945607325f, 0.336889853f, 0.941544065f, 0.348418680f, 0.937339012f, + 0.359895037f, 0.932992799f, 0.371317194f, 0.928506080f, 0.382683432f, + 0.923879533f, 0.393992040f, 0.919113852f, 0.405241314f, 0.914209756f, + 0.416429560f, 0.909167983f, 0.427555093f, 0.903989293f, 0.438616239f, + 0.898674466f, 0.449611330f, 0.893224301f, 0.460538711f, 0.887639620f, + 0.471396737f, 0.881921264f, 0.482183772f, 0.876070094f, 0.492898192f, + 0.870086991f, 0.503538384f, 0.863972856f, 0.514102744f, 0.857728610f, + 0.524589683f, 0.851355193f, 0.534997620f, 0.844853565f, 0.545324988f, + 0.838224706f, 0.555570233f, 0.831469612f, 0.565731811f, 0.824589303f, + 0.575808191f, 0.817584813f, 0.585797857f, 0.810457198f, 0.595699304f, + 0.803207531f, 0.605511041f, 0.795836905f, 0.615231591f, 0.788346428f, + 0.624859488f, 0.780737229f, 0.634393284f, 0.773010453f, 0.643831543f, + 0.765167266f, 0.653172843f, 0.757208847f, 0.662415778f, 0.749136395f, + 0.671558955f, 0.740951125f, 0.680600998f, 0.732654272f, 0.689540545f, + 0.724247083f, 0.698376249f, 0.715730825f, 0.707106781f, 0.707106781f, + 0.715730825f, 0.698376249f, 0.724247083f, 0.689540545f, 0.732654272f, + 0.680600998f, 0.740951125f, 0.671558955f, 0.749136395f, 0.662415778f, + 0.757208847f, 0.653172843f, 0.765167266f, 0.643831543f, 0.773010453f, + 0.634393284f, 0.780737229f, 0.624859488f, 0.788346428f, 0.615231591f, + 0.795836905f, 0.605511041f, 0.803207531f, 0.595699304f, 0.810457198f, + 0.585797857f, 0.817584813f, 0.575808191f, 0.824589303f, 0.565731811f, + 0.831469612f, 0.555570233f, 0.838224706f, 0.545324988f, 0.844853565f, + 0.534997620f, 0.851355193f, 0.524589683f, 0.857728610f, 0.514102744f, + 0.863972856f, 0.503538384f, 0.870086991f, 0.492898192f, 0.876070094f, + 0.482183772f, 0.881921264f, 0.471396737f, 0.887639620f, 0.460538711f, + 0.893224301f, 0.449611330f, 0.898674466f, 0.438616239f, 0.903989293f, + 0.427555093f, 0.909167983f, 0.416429560f, 0.914209756f, 0.405241314f, + 0.919113852f, 0.393992040f, 0.923879533f, 0.382683432f, 0.928506080f, + 0.371317194f, 0.932992799f, 0.359895037f, 0.937339012f, 0.348418680f, + 0.941544065f, 0.336889853f, 0.945607325f, 0.325310292f, 0.949528181f, + 0.313681740f, 0.953306040f, 0.302005949f, 0.956940336f, 0.290284677f, + 0.960430519f, 0.278519689f, 0.963776066f, 0.266712757f, 0.966976471f, + 0.254865660f, 0.970031253f, 0.242980180f, 0.972939952f, 0.231058108f, + 0.975702130f, 0.219101240f, 0.978317371f, 0.207111376f, 0.980785280f, + 0.195090322f, 0.983105487f, 0.183039888f, 0.985277642f, 0.170961889f, + 0.987301418f, 0.158858143f, 0.989176510f, 0.146730474f, 0.990902635f, + 0.134580709f, 0.992479535f, 0.122410675f, 0.993906970f, 0.110222207f, + 0.995184727f, 0.098017140f, 0.996312612f, 0.085797312f, 0.997290457f, + 0.073564564f, 0.998118113f, 0.061320736f, 0.998795456f, 0.049067674f, + 0.999322385f, 0.036807223f, 0.999698819f, 0.024541229f, 0.999924702f, + 0.012271538f, 1.000000000f, 0.000000000f, 0.999924702f, -0.012271538f, + 0.999698819f, -0.024541229f, 0.999322385f, -0.036807223f, 0.998795456f, + -0.049067674f, 0.998118113f, -0.061320736f, 0.997290457f, -0.073564564f, + 0.996312612f, -0.085797312f, 0.995184727f, -0.098017140f, 0.993906970f, + -0.110222207f, 0.992479535f, -0.122410675f, 0.990902635f, -0.134580709f, + 0.989176510f, -0.146730474f, 0.987301418f, -0.158858143f, 0.985277642f, + -0.170961889f, 0.983105487f, -0.183039888f, 0.980785280f, -0.195090322f, + 0.978317371f, -0.207111376f, 0.975702130f, -0.219101240f, 0.972939952f, + -0.231058108f, 0.970031253f, -0.242980180f, 0.966976471f, -0.254865660f, + 0.963776066f, -0.266712757f, 0.960430519f, -0.278519689f, 0.956940336f, + -0.290284677f, 0.953306040f, -0.302005949f, 0.949528181f, -0.313681740f, + 0.945607325f, -0.325310292f, 0.941544065f, -0.336889853f, 0.937339012f, + -0.348418680f, 0.932992799f, -0.359895037f, 0.928506080f, -0.371317194f, + 0.923879533f, -0.382683432f, 0.919113852f, -0.393992040f, 0.914209756f, + -0.405241314f, 0.909167983f, -0.416429560f, 0.903989293f, -0.427555093f, + 0.898674466f, -0.438616239f, 0.893224301f, -0.449611330f, 0.887639620f, + -0.460538711f, 0.881921264f, -0.471396737f, 0.876070094f, -0.482183772f, + 0.870086991f, -0.492898192f, 0.863972856f, -0.503538384f, 0.857728610f, + -0.514102744f, 0.851355193f, -0.524589683f, 0.844853565f, -0.534997620f, + 0.838224706f, -0.545324988f, 0.831469612f, -0.555570233f, 0.824589303f, + -0.565731811f, 0.817584813f, -0.575808191f, 0.810457198f, -0.585797857f, + 0.803207531f, -0.595699304f, 0.795836905f, -0.605511041f, 0.788346428f, + -0.615231591f, 0.780737229f, -0.624859488f, 0.773010453f, -0.634393284f, + 0.765167266f, -0.643831543f, 0.757208847f, -0.653172843f, 0.749136395f, + -0.662415778f, 0.740951125f, -0.671558955f, 0.732654272f, -0.680600998f, + 0.724247083f, -0.689540545f, 0.715730825f, -0.698376249f, 0.707106781f, + -0.707106781f, 0.698376249f, -0.715730825f, 0.689540545f, -0.724247083f, + 0.680600998f, -0.732654272f, 0.671558955f, -0.740951125f, 0.662415778f, + -0.749136395f, 0.653172843f, -0.757208847f, 0.643831543f, -0.765167266f, + 0.634393284f, -0.773010453f, 0.624859488f, -0.780737229f, 0.615231591f, + -0.788346428f, 0.605511041f, -0.795836905f, 0.595699304f, -0.803207531f, + 0.585797857f, -0.810457198f, 0.575808191f, -0.817584813f, 0.565731811f, + -0.824589303f, 0.555570233f, -0.831469612f, 0.545324988f, -0.838224706f, + 0.534997620f, -0.844853565f, 0.524589683f, -0.851355193f, 0.514102744f, + -0.857728610f, 0.503538384f, -0.863972856f, 0.492898192f, -0.870086991f, + 0.482183772f, -0.876070094f, 0.471396737f, -0.881921264f, 0.460538711f, + -0.887639620f, 0.449611330f, -0.893224301f, 0.438616239f, -0.898674466f, + 0.427555093f, -0.903989293f, 0.416429560f, -0.909167983f, 0.405241314f, + -0.914209756f, 0.393992040f, -0.919113852f, 0.382683432f, -0.923879533f, + 0.371317194f, -0.928506080f, 0.359895037f, -0.932992799f, 0.348418680f, + -0.937339012f, 0.336889853f, -0.941544065f, 0.325310292f, -0.945607325f, + 0.313681740f, -0.949528181f, 0.302005949f, -0.953306040f, 0.290284677f, + -0.956940336f, 0.278519689f, -0.960430519f, 0.266712757f, -0.963776066f, + 0.254865660f, -0.966976471f, 0.242980180f, -0.970031253f, 0.231058108f, + -0.972939952f, 0.219101240f, -0.975702130f, 0.207111376f, -0.978317371f, + 0.195090322f, -0.980785280f, 0.183039888f, -0.983105487f, 0.170961889f, + -0.985277642f, 0.158858143f, -0.987301418f, 0.146730474f, -0.989176510f, + 0.134580709f, -0.990902635f, 0.122410675f, -0.992479535f, 0.110222207f, + -0.993906970f, 0.098017140f, -0.995184727f, 0.085797312f, -0.996312612f, + 0.073564564f, -0.997290457f, 0.061320736f, -0.998118113f, 0.049067674f, + -0.998795456f, 0.036807223f, -0.999322385f, 0.024541229f, -0.999698819f, + 0.012271538f, -0.999924702f}; const float32_t twiddleCoef_rfft_1024[1024] = { - 0.000000000f, 1.000000000f, - 0.006135885f, 0.999981175f, - 0.012271538f, 0.999924702f, - 0.018406730f, 0.999830582f, - 0.024541229f, 0.999698819f, - 0.030674803f, 0.999529418f, - 0.036807223f, 0.999322385f, - 0.042938257f, 0.999077728f, - 0.049067674f, 0.998795456f, - 0.055195244f, 0.998475581f, - 0.061320736f, 0.998118113f, - 0.067443920f, 0.997723067f, - 0.073564564f, 0.997290457f, - 0.079682438f, 0.996820299f, - 0.085797312f, 0.996312612f, - 0.091908956f, 0.995767414f, - 0.098017140f, 0.995184727f, - 0.104121634f, 0.994564571f, - 0.110222207f, 0.993906970f, - 0.116318631f, 0.993211949f, - 0.122410675f, 0.992479535f, - 0.128498111f, 0.991709754f, - 0.134580709f, 0.990902635f, - 0.140658239f, 0.990058210f, - 0.146730474f, 0.989176510f, - 0.152797185f, 0.988257568f, - 0.158858143f, 0.987301418f, - 0.164913120f, 0.986308097f, - 0.170961889f, 0.985277642f, - 0.177004220f, 0.984210092f, - 0.183039888f, 0.983105487f, - 0.189068664f, 0.981963869f, - 0.195090322f, 0.980785280f, - 0.201104635f, 0.979569766f, - 0.207111376f, 0.978317371f, - 0.213110320f, 0.977028143f, - 0.219101240f, 0.975702130f, - 0.225083911f, 0.974339383f, - 0.231058108f, 0.972939952f, - 0.237023606f, 0.971503891f, - 0.242980180f, 0.970031253f, - 0.248927606f, 0.968522094f, - 0.254865660f, 0.966976471f, - 0.260794118f, 0.965394442f, - 0.266712757f, 0.963776066f, - 0.272621355f, 0.962121404f, - 0.278519689f, 0.960430519f, - 0.284407537f, 0.958703475f, - 0.290284677f, 0.956940336f, - 0.296150888f, 0.955141168f, - 0.302005949f, 0.953306040f, - 0.307849640f, 0.951435021f, - 0.313681740f, 0.949528181f, - 0.319502031f, 0.947585591f, - 0.325310292f, 0.945607325f, - 0.331106306f, 0.943593458f, - 0.336889853f, 0.941544065f, - 0.342660717f, 0.939459224f, - 0.348418680f, 0.937339012f, - 0.354163525f, 0.935183510f, - 0.359895037f, 0.932992799f, - 0.365612998f, 0.930766961f, - 0.371317194f, 0.928506080f, - 0.377007410f, 0.926210242f, - 0.382683432f, 0.923879533f, - 0.388345047f, 0.921514039f, - 0.393992040f, 0.919113852f, - 0.399624200f, 0.916679060f, - 0.405241314f, 0.914209756f, - 0.410843171f, 0.911706032f, - 0.416429560f, 0.909167983f, - 0.422000271f, 0.906595705f, - 0.427555093f, 0.903989293f, - 0.433093819f, 0.901348847f, - 0.438616239f, 0.898674466f, - 0.444122145f, 0.895966250f, - 0.449611330f, 0.893224301f, - 0.455083587f, 0.890448723f, - 0.460538711f, 0.887639620f, - 0.465976496f, 0.884797098f, - 0.471396737f, 0.881921264f, - 0.476799230f, 0.879012226f, - 0.482183772f, 0.876070094f, - 0.487550160f, 0.873094978f, - 0.492898192f, 0.870086991f, - 0.498227667f, 0.867046246f, - 0.503538384f, 0.863972856f, - 0.508830143f, 0.860866939f, - 0.514102744f, 0.857728610f, - 0.519355990f, 0.854557988f, - 0.524589683f, 0.851355193f, - 0.529803625f, 0.848120345f, - 0.534997620f, 0.844853565f, - 0.540171473f, 0.841554977f, - 0.545324988f, 0.838224706f, - 0.550457973f, 0.834862875f, - 0.555570233f, 0.831469612f, - 0.560661576f, 0.828045045f, - 0.565731811f, 0.824589303f, - 0.570780746f, 0.821102515f, - 0.575808191f, 0.817584813f, - 0.580813958f, 0.814036330f, - 0.585797857f, 0.810457198f, - 0.590759702f, 0.806847554f, - 0.595699304f, 0.803207531f, - 0.600616479f, 0.799537269f, - 0.605511041f, 0.795836905f, - 0.610382806f, 0.792106577f, - 0.615231591f, 0.788346428f, - 0.620057212f, 0.784556597f, - 0.624859488f, 0.780737229f, - 0.629638239f, 0.776888466f, - 0.634393284f, 0.773010453f, - 0.639124445f, 0.769103338f, - 0.643831543f, 0.765167266f, - 0.648514401f, 0.761202385f, - 0.653172843f, 0.757208847f, - 0.657806693f, 0.753186799f, - 0.662415778f, 0.749136395f, - 0.666999922f, 0.745057785f, - 0.671558955f, 0.740951125f, - 0.676092704f, 0.736816569f, - 0.680600998f, 0.732654272f, - 0.685083668f, 0.728464390f, - 0.689540545f, 0.724247083f, - 0.693971461f, 0.720002508f, - 0.698376249f, 0.715730825f, - 0.702754744f, 0.711432196f, - 0.707106781f, 0.707106781f, - 0.711432196f, 0.702754744f, - 0.715730825f, 0.698376249f, - 0.720002508f, 0.693971461f, - 0.724247083f, 0.689540545f, - 0.728464390f, 0.685083668f, - 0.732654272f, 0.680600998f, - 0.736816569f, 0.676092704f, - 0.740951125f, 0.671558955f, - 0.745057785f, 0.666999922f, - 0.749136395f, 0.662415778f, - 0.753186799f, 0.657806693f, - 0.757208847f, 0.653172843f, - 0.761202385f, 0.648514401f, - 0.765167266f, 0.643831543f, - 0.769103338f, 0.639124445f, - 0.773010453f, 0.634393284f, - 0.776888466f, 0.629638239f, - 0.780737229f, 0.624859488f, - 0.784556597f, 0.620057212f, - 0.788346428f, 0.615231591f, - 0.792106577f, 0.610382806f, - 0.795836905f, 0.605511041f, - 0.799537269f, 0.600616479f, - 0.803207531f, 0.595699304f, - 0.806847554f, 0.590759702f, - 0.810457198f, 0.585797857f, - 0.814036330f, 0.580813958f, - 0.817584813f, 0.575808191f, - 0.821102515f, 0.570780746f, - 0.824589303f, 0.565731811f, - 0.828045045f, 0.560661576f, - 0.831469612f, 0.555570233f, - 0.834862875f, 0.550457973f, - 0.838224706f, 0.545324988f, - 0.841554977f, 0.540171473f, - 0.844853565f, 0.534997620f, - 0.848120345f, 0.529803625f, - 0.851355193f, 0.524589683f, - 0.854557988f, 0.519355990f, - 0.857728610f, 0.514102744f, - 0.860866939f, 0.508830143f, - 0.863972856f, 0.503538384f, - 0.867046246f, 0.498227667f, - 0.870086991f, 0.492898192f, - 0.873094978f, 0.487550160f, - 0.876070094f, 0.482183772f, - 0.879012226f, 0.476799230f, - 0.881921264f, 0.471396737f, - 0.884797098f, 0.465976496f, - 0.887639620f, 0.460538711f, - 0.890448723f, 0.455083587f, - 0.893224301f, 0.449611330f, - 0.895966250f, 0.444122145f, - 0.898674466f, 0.438616239f, - 0.901348847f, 0.433093819f, - 0.903989293f, 0.427555093f, - 0.906595705f, 0.422000271f, - 0.909167983f, 0.416429560f, - 0.911706032f, 0.410843171f, - 0.914209756f, 0.405241314f, - 0.916679060f, 0.399624200f, - 0.919113852f, 0.393992040f, - 0.921514039f, 0.388345047f, - 0.923879533f, 0.382683432f, - 0.926210242f, 0.377007410f, - 0.928506080f, 0.371317194f, - 0.930766961f, 0.365612998f, - 0.932992799f, 0.359895037f, - 0.935183510f, 0.354163525f, - 0.937339012f, 0.348418680f, - 0.939459224f, 0.342660717f, - 0.941544065f, 0.336889853f, - 0.943593458f, 0.331106306f, - 0.945607325f, 0.325310292f, - 0.947585591f, 0.319502031f, - 0.949528181f, 0.313681740f, - 0.951435021f, 0.307849640f, - 0.953306040f, 0.302005949f, - 0.955141168f, 0.296150888f, - 0.956940336f, 0.290284677f, - 0.958703475f, 0.284407537f, - 0.960430519f, 0.278519689f, - 0.962121404f, 0.272621355f, - 0.963776066f, 0.266712757f, - 0.965394442f, 0.260794118f, - 0.966976471f, 0.254865660f, - 0.968522094f, 0.248927606f, - 0.970031253f, 0.242980180f, - 0.971503891f, 0.237023606f, - 0.972939952f, 0.231058108f, - 0.974339383f, 0.225083911f, - 0.975702130f, 0.219101240f, - 0.977028143f, 0.213110320f, - 0.978317371f, 0.207111376f, - 0.979569766f, 0.201104635f, - 0.980785280f, 0.195090322f, - 0.981963869f, 0.189068664f, - 0.983105487f, 0.183039888f, - 0.984210092f, 0.177004220f, - 0.985277642f, 0.170961889f, - 0.986308097f, 0.164913120f, - 0.987301418f, 0.158858143f, - 0.988257568f, 0.152797185f, - 0.989176510f, 0.146730474f, - 0.990058210f, 0.140658239f, - 0.990902635f, 0.134580709f, - 0.991709754f, 0.128498111f, - 0.992479535f, 0.122410675f, - 0.993211949f, 0.116318631f, - 0.993906970f, 0.110222207f, - 0.994564571f, 0.104121634f, - 0.995184727f, 0.098017140f, - 0.995767414f, 0.091908956f, - 0.996312612f, 0.085797312f, - 0.996820299f, 0.079682438f, - 0.997290457f, 0.073564564f, - 0.997723067f, 0.067443920f, - 0.998118113f, 0.061320736f, - 0.998475581f, 0.055195244f, - 0.998795456f, 0.049067674f, - 0.999077728f, 0.042938257f, - 0.999322385f, 0.036807223f, - 0.999529418f, 0.030674803f, - 0.999698819f, 0.024541229f, - 0.999830582f, 0.018406730f, - 0.999924702f, 0.012271538f, - 0.999981175f, 0.006135885f, - 1.000000000f, 0.000000000f, - 0.999981175f, -0.006135885f, - 0.999924702f, -0.012271538f, - 0.999830582f, -0.018406730f, - 0.999698819f, -0.024541229f, - 0.999529418f, -0.030674803f, - 0.999322385f, -0.036807223f, - 0.999077728f, -0.042938257f, - 0.998795456f, -0.049067674f, - 0.998475581f, -0.055195244f, - 0.998118113f, -0.061320736f, - 0.997723067f, -0.067443920f, - 0.997290457f, -0.073564564f, - 0.996820299f, -0.079682438f, - 0.996312612f, -0.085797312f, - 0.995767414f, -0.091908956f, - 0.995184727f, -0.098017140f, - 0.994564571f, -0.104121634f, - 0.993906970f, -0.110222207f, - 0.993211949f, -0.116318631f, - 0.992479535f, -0.122410675f, - 0.991709754f, -0.128498111f, - 0.990902635f, -0.134580709f, - 0.990058210f, -0.140658239f, - 0.989176510f, -0.146730474f, - 0.988257568f, -0.152797185f, - 0.987301418f, -0.158858143f, - 0.986308097f, -0.164913120f, - 0.985277642f, -0.170961889f, - 0.984210092f, -0.177004220f, - 0.983105487f, -0.183039888f, - 0.981963869f, -0.189068664f, - 0.980785280f, -0.195090322f, - 0.979569766f, -0.201104635f, - 0.978317371f, -0.207111376f, - 0.977028143f, -0.213110320f, - 0.975702130f, -0.219101240f, - 0.974339383f, -0.225083911f, - 0.972939952f, -0.231058108f, - 0.971503891f, -0.237023606f, - 0.970031253f, -0.242980180f, - 0.968522094f, -0.248927606f, - 0.966976471f, -0.254865660f, - 0.965394442f, -0.260794118f, - 0.963776066f, -0.266712757f, - 0.962121404f, -0.272621355f, - 0.960430519f, -0.278519689f, - 0.958703475f, -0.284407537f, - 0.956940336f, -0.290284677f, - 0.955141168f, -0.296150888f, - 0.953306040f, -0.302005949f, - 0.951435021f, -0.307849640f, - 0.949528181f, -0.313681740f, - 0.947585591f, -0.319502031f, - 0.945607325f, -0.325310292f, - 0.943593458f, -0.331106306f, - 0.941544065f, -0.336889853f, - 0.939459224f, -0.342660717f, - 0.937339012f, -0.348418680f, - 0.935183510f, -0.354163525f, - 0.932992799f, -0.359895037f, - 0.930766961f, -0.365612998f, - 0.928506080f, -0.371317194f, - 0.926210242f, -0.377007410f, - 0.923879533f, -0.382683432f, - 0.921514039f, -0.388345047f, - 0.919113852f, -0.393992040f, - 0.916679060f, -0.399624200f, - 0.914209756f, -0.405241314f, - 0.911706032f, -0.410843171f, - 0.909167983f, -0.416429560f, - 0.906595705f, -0.422000271f, - 0.903989293f, -0.427555093f, - 0.901348847f, -0.433093819f, - 0.898674466f, -0.438616239f, - 0.895966250f, -0.444122145f, - 0.893224301f, -0.449611330f, - 0.890448723f, -0.455083587f, - 0.887639620f, -0.460538711f, - 0.884797098f, -0.465976496f, - 0.881921264f, -0.471396737f, - 0.879012226f, -0.476799230f, - 0.876070094f, -0.482183772f, - 0.873094978f, -0.487550160f, - 0.870086991f, -0.492898192f, - 0.867046246f, -0.498227667f, - 0.863972856f, -0.503538384f, - 0.860866939f, -0.508830143f, - 0.857728610f, -0.514102744f, - 0.854557988f, -0.519355990f, - 0.851355193f, -0.524589683f, - 0.848120345f, -0.529803625f, - 0.844853565f, -0.534997620f, - 0.841554977f, -0.540171473f, - 0.838224706f, -0.545324988f, - 0.834862875f, -0.550457973f, - 0.831469612f, -0.555570233f, - 0.828045045f, -0.560661576f, - 0.824589303f, -0.565731811f, - 0.821102515f, -0.570780746f, - 0.817584813f, -0.575808191f, - 0.814036330f, -0.580813958f, - 0.810457198f, -0.585797857f, - 0.806847554f, -0.590759702f, - 0.803207531f, -0.595699304f, - 0.799537269f, -0.600616479f, - 0.795836905f, -0.605511041f, - 0.792106577f, -0.610382806f, - 0.788346428f, -0.615231591f, - 0.784556597f, -0.620057212f, - 0.780737229f, -0.624859488f, - 0.776888466f, -0.629638239f, - 0.773010453f, -0.634393284f, - 0.769103338f, -0.639124445f, - 0.765167266f, -0.643831543f, - 0.761202385f, -0.648514401f, - 0.757208847f, -0.653172843f, - 0.753186799f, -0.657806693f, - 0.749136395f, -0.662415778f, - 0.745057785f, -0.666999922f, - 0.740951125f, -0.671558955f, - 0.736816569f, -0.676092704f, - 0.732654272f, -0.680600998f, - 0.728464390f, -0.685083668f, - 0.724247083f, -0.689540545f, - 0.720002508f, -0.693971461f, - 0.715730825f, -0.698376249f, - 0.711432196f, -0.702754744f, - 0.707106781f, -0.707106781f, - 0.702754744f, -0.711432196f, - 0.698376249f, -0.715730825f, - 0.693971461f, -0.720002508f, - 0.689540545f, -0.724247083f, - 0.685083668f, -0.728464390f, - 0.680600998f, -0.732654272f, - 0.676092704f, -0.736816569f, - 0.671558955f, -0.740951125f, - 0.666999922f, -0.745057785f, - 0.662415778f, -0.749136395f, - 0.657806693f, -0.753186799f, - 0.653172843f, -0.757208847f, - 0.648514401f, -0.761202385f, - 0.643831543f, -0.765167266f, - 0.639124445f, -0.769103338f, - 0.634393284f, -0.773010453f, - 0.629638239f, -0.776888466f, - 0.624859488f, -0.780737229f, - 0.620057212f, -0.784556597f, - 0.615231591f, -0.788346428f, - 0.610382806f, -0.792106577f, - 0.605511041f, -0.795836905f, - 0.600616479f, -0.799537269f, - 0.595699304f, -0.803207531f, - 0.590759702f, -0.806847554f, - 0.585797857f, -0.810457198f, - 0.580813958f, -0.814036330f, - 0.575808191f, -0.817584813f, - 0.570780746f, -0.821102515f, - 0.565731811f, -0.824589303f, - 0.560661576f, -0.828045045f, - 0.555570233f, -0.831469612f, - 0.550457973f, -0.834862875f, - 0.545324988f, -0.838224706f, - 0.540171473f, -0.841554977f, - 0.534997620f, -0.844853565f, - 0.529803625f, -0.848120345f, - 0.524589683f, -0.851355193f, - 0.519355990f, -0.854557988f, - 0.514102744f, -0.857728610f, - 0.508830143f, -0.860866939f, - 0.503538384f, -0.863972856f, - 0.498227667f, -0.867046246f, - 0.492898192f, -0.870086991f, - 0.487550160f, -0.873094978f, - 0.482183772f, -0.876070094f, - 0.476799230f, -0.879012226f, - 0.471396737f, -0.881921264f, - 0.465976496f, -0.884797098f, - 0.460538711f, -0.887639620f, - 0.455083587f, -0.890448723f, - 0.449611330f, -0.893224301f, - 0.444122145f, -0.895966250f, - 0.438616239f, -0.898674466f, - 0.433093819f, -0.901348847f, - 0.427555093f, -0.903989293f, - 0.422000271f, -0.906595705f, - 0.416429560f, -0.909167983f, - 0.410843171f, -0.911706032f, - 0.405241314f, -0.914209756f, - 0.399624200f, -0.916679060f, - 0.393992040f, -0.919113852f, - 0.388345047f, -0.921514039f, - 0.382683432f, -0.923879533f, - 0.377007410f, -0.926210242f, - 0.371317194f, -0.928506080f, - 0.365612998f, -0.930766961f, - 0.359895037f, -0.932992799f, - 0.354163525f, -0.935183510f, - 0.348418680f, -0.937339012f, - 0.342660717f, -0.939459224f, - 0.336889853f, -0.941544065f, - 0.331106306f, -0.943593458f, - 0.325310292f, -0.945607325f, - 0.319502031f, -0.947585591f, - 0.313681740f, -0.949528181f, - 0.307849640f, -0.951435021f, - 0.302005949f, -0.953306040f, - 0.296150888f, -0.955141168f, - 0.290284677f, -0.956940336f, - 0.284407537f, -0.958703475f, - 0.278519689f, -0.960430519f, - 0.272621355f, -0.962121404f, - 0.266712757f, -0.963776066f, - 0.260794118f, -0.965394442f, - 0.254865660f, -0.966976471f, - 0.248927606f, -0.968522094f, - 0.242980180f, -0.970031253f, - 0.237023606f, -0.971503891f, - 0.231058108f, -0.972939952f, - 0.225083911f, -0.974339383f, - 0.219101240f, -0.975702130f, - 0.213110320f, -0.977028143f, - 0.207111376f, -0.978317371f, - 0.201104635f, -0.979569766f, - 0.195090322f, -0.980785280f, - 0.189068664f, -0.981963869f, - 0.183039888f, -0.983105487f, - 0.177004220f, -0.984210092f, - 0.170961889f, -0.985277642f, - 0.164913120f, -0.986308097f, - 0.158858143f, -0.987301418f, - 0.152797185f, -0.988257568f, - 0.146730474f, -0.989176510f, - 0.140658239f, -0.990058210f, - 0.134580709f, -0.990902635f, - 0.128498111f, -0.991709754f, - 0.122410675f, -0.992479535f, - 0.116318631f, -0.993211949f, - 0.110222207f, -0.993906970f, - 0.104121634f, -0.994564571f, - 0.098017140f, -0.995184727f, - 0.091908956f, -0.995767414f, - 0.085797312f, -0.996312612f, - 0.079682438f, -0.996820299f, - 0.073564564f, -0.997290457f, - 0.067443920f, -0.997723067f, - 0.061320736f, -0.998118113f, - 0.055195244f, -0.998475581f, - 0.049067674f, -0.998795456f, - 0.042938257f, -0.999077728f, - 0.036807223f, -0.999322385f, - 0.030674803f, -0.999529418f, - 0.024541229f, -0.999698819f, - 0.018406730f, -0.999830582f, - 0.012271538f, -0.999924702f, - 0.006135885f, -0.999981175f -}; + 0.000000000f, 1.000000000f, 0.006135885f, 0.999981175f, 0.012271538f, + 0.999924702f, 0.018406730f, 0.999830582f, 0.024541229f, 0.999698819f, + 0.030674803f, 0.999529418f, 0.036807223f, 0.999322385f, 0.042938257f, + 0.999077728f, 0.049067674f, 0.998795456f, 0.055195244f, 0.998475581f, + 0.061320736f, 0.998118113f, 0.067443920f, 0.997723067f, 0.073564564f, + 0.997290457f, 0.079682438f, 0.996820299f, 0.085797312f, 0.996312612f, + 0.091908956f, 0.995767414f, 0.098017140f, 0.995184727f, 0.104121634f, + 0.994564571f, 0.110222207f, 0.993906970f, 0.116318631f, 0.993211949f, + 0.122410675f, 0.992479535f, 0.128498111f, 0.991709754f, 0.134580709f, + 0.990902635f, 0.140658239f, 0.990058210f, 0.146730474f, 0.989176510f, + 0.152797185f, 0.988257568f, 0.158858143f, 0.987301418f, 0.164913120f, + 0.986308097f, 0.170961889f, 0.985277642f, 0.177004220f, 0.984210092f, + 0.183039888f, 0.983105487f, 0.189068664f, 0.981963869f, 0.195090322f, + 0.980785280f, 0.201104635f, 0.979569766f, 0.207111376f, 0.978317371f, + 0.213110320f, 0.977028143f, 0.219101240f, 0.975702130f, 0.225083911f, + 0.974339383f, 0.231058108f, 0.972939952f, 0.237023606f, 0.971503891f, + 0.242980180f, 0.970031253f, 0.248927606f, 0.968522094f, 0.254865660f, + 0.966976471f, 0.260794118f, 0.965394442f, 0.266712757f, 0.963776066f, + 0.272621355f, 0.962121404f, 0.278519689f, 0.960430519f, 0.284407537f, + 0.958703475f, 0.290284677f, 0.956940336f, 0.296150888f, 0.955141168f, + 0.302005949f, 0.953306040f, 0.307849640f, 0.951435021f, 0.313681740f, + 0.949528181f, 0.319502031f, 0.947585591f, 0.325310292f, 0.945607325f, + 0.331106306f, 0.943593458f, 0.336889853f, 0.941544065f, 0.342660717f, + 0.939459224f, 0.348418680f, 0.937339012f, 0.354163525f, 0.935183510f, + 0.359895037f, 0.932992799f, 0.365612998f, 0.930766961f, 0.371317194f, + 0.928506080f, 0.377007410f, 0.926210242f, 0.382683432f, 0.923879533f, + 0.388345047f, 0.921514039f, 0.393992040f, 0.919113852f, 0.399624200f, + 0.916679060f, 0.405241314f, 0.914209756f, 0.410843171f, 0.911706032f, + 0.416429560f, 0.909167983f, 0.422000271f, 0.906595705f, 0.427555093f, + 0.903989293f, 0.433093819f, 0.901348847f, 0.438616239f, 0.898674466f, + 0.444122145f, 0.895966250f, 0.449611330f, 0.893224301f, 0.455083587f, + 0.890448723f, 0.460538711f, 0.887639620f, 0.465976496f, 0.884797098f, + 0.471396737f, 0.881921264f, 0.476799230f, 0.879012226f, 0.482183772f, + 0.876070094f, 0.487550160f, 0.873094978f, 0.492898192f, 0.870086991f, + 0.498227667f, 0.867046246f, 0.503538384f, 0.863972856f, 0.508830143f, + 0.860866939f, 0.514102744f, 0.857728610f, 0.519355990f, 0.854557988f, + 0.524589683f, 0.851355193f, 0.529803625f, 0.848120345f, 0.534997620f, + 0.844853565f, 0.540171473f, 0.841554977f, 0.545324988f, 0.838224706f, + 0.550457973f, 0.834862875f, 0.555570233f, 0.831469612f, 0.560661576f, + 0.828045045f, 0.565731811f, 0.824589303f, 0.570780746f, 0.821102515f, + 0.575808191f, 0.817584813f, 0.580813958f, 0.814036330f, 0.585797857f, + 0.810457198f, 0.590759702f, 0.806847554f, 0.595699304f, 0.803207531f, + 0.600616479f, 0.799537269f, 0.605511041f, 0.795836905f, 0.610382806f, + 0.792106577f, 0.615231591f, 0.788346428f, 0.620057212f, 0.784556597f, + 0.624859488f, 0.780737229f, 0.629638239f, 0.776888466f, 0.634393284f, + 0.773010453f, 0.639124445f, 0.769103338f, 0.643831543f, 0.765167266f, + 0.648514401f, 0.761202385f, 0.653172843f, 0.757208847f, 0.657806693f, + 0.753186799f, 0.662415778f, 0.749136395f, 0.666999922f, 0.745057785f, + 0.671558955f, 0.740951125f, 0.676092704f, 0.736816569f, 0.680600998f, + 0.732654272f, 0.685083668f, 0.728464390f, 0.689540545f, 0.724247083f, + 0.693971461f, 0.720002508f, 0.698376249f, 0.715730825f, 0.702754744f, + 0.711432196f, 0.707106781f, 0.707106781f, 0.711432196f, 0.702754744f, + 0.715730825f, 0.698376249f, 0.720002508f, 0.693971461f, 0.724247083f, + 0.689540545f, 0.728464390f, 0.685083668f, 0.732654272f, 0.680600998f, + 0.736816569f, 0.676092704f, 0.740951125f, 0.671558955f, 0.745057785f, + 0.666999922f, 0.749136395f, 0.662415778f, 0.753186799f, 0.657806693f, + 0.757208847f, 0.653172843f, 0.761202385f, 0.648514401f, 0.765167266f, + 0.643831543f, 0.769103338f, 0.639124445f, 0.773010453f, 0.634393284f, + 0.776888466f, 0.629638239f, 0.780737229f, 0.624859488f, 0.784556597f, + 0.620057212f, 0.788346428f, 0.615231591f, 0.792106577f, 0.610382806f, + 0.795836905f, 0.605511041f, 0.799537269f, 0.600616479f, 0.803207531f, + 0.595699304f, 0.806847554f, 0.590759702f, 0.810457198f, 0.585797857f, + 0.814036330f, 0.580813958f, 0.817584813f, 0.575808191f, 0.821102515f, + 0.570780746f, 0.824589303f, 0.565731811f, 0.828045045f, 0.560661576f, + 0.831469612f, 0.555570233f, 0.834862875f, 0.550457973f, 0.838224706f, + 0.545324988f, 0.841554977f, 0.540171473f, 0.844853565f, 0.534997620f, + 0.848120345f, 0.529803625f, 0.851355193f, 0.524589683f, 0.854557988f, + 0.519355990f, 0.857728610f, 0.514102744f, 0.860866939f, 0.508830143f, + 0.863972856f, 0.503538384f, 0.867046246f, 0.498227667f, 0.870086991f, + 0.492898192f, 0.873094978f, 0.487550160f, 0.876070094f, 0.482183772f, + 0.879012226f, 0.476799230f, 0.881921264f, 0.471396737f, 0.884797098f, + 0.465976496f, 0.887639620f, 0.460538711f, 0.890448723f, 0.455083587f, + 0.893224301f, 0.449611330f, 0.895966250f, 0.444122145f, 0.898674466f, + 0.438616239f, 0.901348847f, 0.433093819f, 0.903989293f, 0.427555093f, + 0.906595705f, 0.422000271f, 0.909167983f, 0.416429560f, 0.911706032f, + 0.410843171f, 0.914209756f, 0.405241314f, 0.916679060f, 0.399624200f, + 0.919113852f, 0.393992040f, 0.921514039f, 0.388345047f, 0.923879533f, + 0.382683432f, 0.926210242f, 0.377007410f, 0.928506080f, 0.371317194f, + 0.930766961f, 0.365612998f, 0.932992799f, 0.359895037f, 0.935183510f, + 0.354163525f, 0.937339012f, 0.348418680f, 0.939459224f, 0.342660717f, + 0.941544065f, 0.336889853f, 0.943593458f, 0.331106306f, 0.945607325f, + 0.325310292f, 0.947585591f, 0.319502031f, 0.949528181f, 0.313681740f, + 0.951435021f, 0.307849640f, 0.953306040f, 0.302005949f, 0.955141168f, + 0.296150888f, 0.956940336f, 0.290284677f, 0.958703475f, 0.284407537f, + 0.960430519f, 0.278519689f, 0.962121404f, 0.272621355f, 0.963776066f, + 0.266712757f, 0.965394442f, 0.260794118f, 0.966976471f, 0.254865660f, + 0.968522094f, 0.248927606f, 0.970031253f, 0.242980180f, 0.971503891f, + 0.237023606f, 0.972939952f, 0.231058108f, 0.974339383f, 0.225083911f, + 0.975702130f, 0.219101240f, 0.977028143f, 0.213110320f, 0.978317371f, + 0.207111376f, 0.979569766f, 0.201104635f, 0.980785280f, 0.195090322f, + 0.981963869f, 0.189068664f, 0.983105487f, 0.183039888f, 0.984210092f, + 0.177004220f, 0.985277642f, 0.170961889f, 0.986308097f, 0.164913120f, + 0.987301418f, 0.158858143f, 0.988257568f, 0.152797185f, 0.989176510f, + 0.146730474f, 0.990058210f, 0.140658239f, 0.990902635f, 0.134580709f, + 0.991709754f, 0.128498111f, 0.992479535f, 0.122410675f, 0.993211949f, + 0.116318631f, 0.993906970f, 0.110222207f, 0.994564571f, 0.104121634f, + 0.995184727f, 0.098017140f, 0.995767414f, 0.091908956f, 0.996312612f, + 0.085797312f, 0.996820299f, 0.079682438f, 0.997290457f, 0.073564564f, + 0.997723067f, 0.067443920f, 0.998118113f, 0.061320736f, 0.998475581f, + 0.055195244f, 0.998795456f, 0.049067674f, 0.999077728f, 0.042938257f, + 0.999322385f, 0.036807223f, 0.999529418f, 0.030674803f, 0.999698819f, + 0.024541229f, 0.999830582f, 0.018406730f, 0.999924702f, 0.012271538f, + 0.999981175f, 0.006135885f, 1.000000000f, 0.000000000f, 0.999981175f, + -0.006135885f, 0.999924702f, -0.012271538f, 0.999830582f, -0.018406730f, + 0.999698819f, -0.024541229f, 0.999529418f, -0.030674803f, 0.999322385f, + -0.036807223f, 0.999077728f, -0.042938257f, 0.998795456f, -0.049067674f, + 0.998475581f, -0.055195244f, 0.998118113f, -0.061320736f, 0.997723067f, + -0.067443920f, 0.997290457f, -0.073564564f, 0.996820299f, -0.079682438f, + 0.996312612f, -0.085797312f, 0.995767414f, -0.091908956f, 0.995184727f, + -0.098017140f, 0.994564571f, -0.104121634f, 0.993906970f, -0.110222207f, + 0.993211949f, -0.116318631f, 0.992479535f, -0.122410675f, 0.991709754f, + -0.128498111f, 0.990902635f, -0.134580709f, 0.990058210f, -0.140658239f, + 0.989176510f, -0.146730474f, 0.988257568f, -0.152797185f, 0.987301418f, + -0.158858143f, 0.986308097f, -0.164913120f, 0.985277642f, -0.170961889f, + 0.984210092f, -0.177004220f, 0.983105487f, -0.183039888f, 0.981963869f, + -0.189068664f, 0.980785280f, -0.195090322f, 0.979569766f, -0.201104635f, + 0.978317371f, -0.207111376f, 0.977028143f, -0.213110320f, 0.975702130f, + -0.219101240f, 0.974339383f, -0.225083911f, 0.972939952f, -0.231058108f, + 0.971503891f, -0.237023606f, 0.970031253f, -0.242980180f, 0.968522094f, + -0.248927606f, 0.966976471f, -0.254865660f, 0.965394442f, -0.260794118f, + 0.963776066f, -0.266712757f, 0.962121404f, -0.272621355f, 0.960430519f, + -0.278519689f, 0.958703475f, -0.284407537f, 0.956940336f, -0.290284677f, + 0.955141168f, -0.296150888f, 0.953306040f, -0.302005949f, 0.951435021f, + -0.307849640f, 0.949528181f, -0.313681740f, 0.947585591f, -0.319502031f, + 0.945607325f, -0.325310292f, 0.943593458f, -0.331106306f, 0.941544065f, + -0.336889853f, 0.939459224f, -0.342660717f, 0.937339012f, -0.348418680f, + 0.935183510f, -0.354163525f, 0.932992799f, -0.359895037f, 0.930766961f, + -0.365612998f, 0.928506080f, -0.371317194f, 0.926210242f, -0.377007410f, + 0.923879533f, -0.382683432f, 0.921514039f, -0.388345047f, 0.919113852f, + -0.393992040f, 0.916679060f, -0.399624200f, 0.914209756f, -0.405241314f, + 0.911706032f, -0.410843171f, 0.909167983f, -0.416429560f, 0.906595705f, + -0.422000271f, 0.903989293f, -0.427555093f, 0.901348847f, -0.433093819f, + 0.898674466f, -0.438616239f, 0.895966250f, -0.444122145f, 0.893224301f, + -0.449611330f, 0.890448723f, -0.455083587f, 0.887639620f, -0.460538711f, + 0.884797098f, -0.465976496f, 0.881921264f, -0.471396737f, 0.879012226f, + -0.476799230f, 0.876070094f, -0.482183772f, 0.873094978f, -0.487550160f, + 0.870086991f, -0.492898192f, 0.867046246f, -0.498227667f, 0.863972856f, + -0.503538384f, 0.860866939f, -0.508830143f, 0.857728610f, -0.514102744f, + 0.854557988f, -0.519355990f, 0.851355193f, -0.524589683f, 0.848120345f, + -0.529803625f, 0.844853565f, -0.534997620f, 0.841554977f, -0.540171473f, + 0.838224706f, -0.545324988f, 0.834862875f, -0.550457973f, 0.831469612f, + -0.555570233f, 0.828045045f, -0.560661576f, 0.824589303f, -0.565731811f, + 0.821102515f, -0.570780746f, 0.817584813f, -0.575808191f, 0.814036330f, + -0.580813958f, 0.810457198f, -0.585797857f, 0.806847554f, -0.590759702f, + 0.803207531f, -0.595699304f, 0.799537269f, -0.600616479f, 0.795836905f, + -0.605511041f, 0.792106577f, -0.610382806f, 0.788346428f, -0.615231591f, + 0.784556597f, -0.620057212f, 0.780737229f, -0.624859488f, 0.776888466f, + -0.629638239f, 0.773010453f, -0.634393284f, 0.769103338f, -0.639124445f, + 0.765167266f, -0.643831543f, 0.761202385f, -0.648514401f, 0.757208847f, + -0.653172843f, 0.753186799f, -0.657806693f, 0.749136395f, -0.662415778f, + 0.745057785f, -0.666999922f, 0.740951125f, -0.671558955f, 0.736816569f, + -0.676092704f, 0.732654272f, -0.680600998f, 0.728464390f, -0.685083668f, + 0.724247083f, -0.689540545f, 0.720002508f, -0.693971461f, 0.715730825f, + -0.698376249f, 0.711432196f, -0.702754744f, 0.707106781f, -0.707106781f, + 0.702754744f, -0.711432196f, 0.698376249f, -0.715730825f, 0.693971461f, + -0.720002508f, 0.689540545f, -0.724247083f, 0.685083668f, -0.728464390f, + 0.680600998f, -0.732654272f, 0.676092704f, -0.736816569f, 0.671558955f, + -0.740951125f, 0.666999922f, -0.745057785f, 0.662415778f, -0.749136395f, + 0.657806693f, -0.753186799f, 0.653172843f, -0.757208847f, 0.648514401f, + -0.761202385f, 0.643831543f, -0.765167266f, 0.639124445f, -0.769103338f, + 0.634393284f, -0.773010453f, 0.629638239f, -0.776888466f, 0.624859488f, + -0.780737229f, 0.620057212f, -0.784556597f, 0.615231591f, -0.788346428f, + 0.610382806f, -0.792106577f, 0.605511041f, -0.795836905f, 0.600616479f, + -0.799537269f, 0.595699304f, -0.803207531f, 0.590759702f, -0.806847554f, + 0.585797857f, -0.810457198f, 0.580813958f, -0.814036330f, 0.575808191f, + -0.817584813f, 0.570780746f, -0.821102515f, 0.565731811f, -0.824589303f, + 0.560661576f, -0.828045045f, 0.555570233f, -0.831469612f, 0.550457973f, + -0.834862875f, 0.545324988f, -0.838224706f, 0.540171473f, -0.841554977f, + 0.534997620f, -0.844853565f, 0.529803625f, -0.848120345f, 0.524589683f, + -0.851355193f, 0.519355990f, -0.854557988f, 0.514102744f, -0.857728610f, + 0.508830143f, -0.860866939f, 0.503538384f, -0.863972856f, 0.498227667f, + -0.867046246f, 0.492898192f, -0.870086991f, 0.487550160f, -0.873094978f, + 0.482183772f, -0.876070094f, 0.476799230f, -0.879012226f, 0.471396737f, + -0.881921264f, 0.465976496f, -0.884797098f, 0.460538711f, -0.887639620f, + 0.455083587f, -0.890448723f, 0.449611330f, -0.893224301f, 0.444122145f, + -0.895966250f, 0.438616239f, -0.898674466f, 0.433093819f, -0.901348847f, + 0.427555093f, -0.903989293f, 0.422000271f, -0.906595705f, 0.416429560f, + -0.909167983f, 0.410843171f, -0.911706032f, 0.405241314f, -0.914209756f, + 0.399624200f, -0.916679060f, 0.393992040f, -0.919113852f, 0.388345047f, + -0.921514039f, 0.382683432f, -0.923879533f, 0.377007410f, -0.926210242f, + 0.371317194f, -0.928506080f, 0.365612998f, -0.930766961f, 0.359895037f, + -0.932992799f, 0.354163525f, -0.935183510f, 0.348418680f, -0.937339012f, + 0.342660717f, -0.939459224f, 0.336889853f, -0.941544065f, 0.331106306f, + -0.943593458f, 0.325310292f, -0.945607325f, 0.319502031f, -0.947585591f, + 0.313681740f, -0.949528181f, 0.307849640f, -0.951435021f, 0.302005949f, + -0.953306040f, 0.296150888f, -0.955141168f, 0.290284677f, -0.956940336f, + 0.284407537f, -0.958703475f, 0.278519689f, -0.960430519f, 0.272621355f, + -0.962121404f, 0.266712757f, -0.963776066f, 0.260794118f, -0.965394442f, + 0.254865660f, -0.966976471f, 0.248927606f, -0.968522094f, 0.242980180f, + -0.970031253f, 0.237023606f, -0.971503891f, 0.231058108f, -0.972939952f, + 0.225083911f, -0.974339383f, 0.219101240f, -0.975702130f, 0.213110320f, + -0.977028143f, 0.207111376f, -0.978317371f, 0.201104635f, -0.979569766f, + 0.195090322f, -0.980785280f, 0.189068664f, -0.981963869f, 0.183039888f, + -0.983105487f, 0.177004220f, -0.984210092f, 0.170961889f, -0.985277642f, + 0.164913120f, -0.986308097f, 0.158858143f, -0.987301418f, 0.152797185f, + -0.988257568f, 0.146730474f, -0.989176510f, 0.140658239f, -0.990058210f, + 0.134580709f, -0.990902635f, 0.128498111f, -0.991709754f, 0.122410675f, + -0.992479535f, 0.116318631f, -0.993211949f, 0.110222207f, -0.993906970f, + 0.104121634f, -0.994564571f, 0.098017140f, -0.995184727f, 0.091908956f, + -0.995767414f, 0.085797312f, -0.996312612f, 0.079682438f, -0.996820299f, + 0.073564564f, -0.997290457f, 0.067443920f, -0.997723067f, 0.061320736f, + -0.998118113f, 0.055195244f, -0.998475581f, 0.049067674f, -0.998795456f, + 0.042938257f, -0.999077728f, 0.036807223f, -0.999322385f, 0.030674803f, + -0.999529418f, 0.024541229f, -0.999698819f, 0.018406730f, -0.999830582f, + 0.012271538f, -0.999924702f, 0.006135885f, -0.999981175f}; const float32_t twiddleCoef_rfft_2048[2048] = { - 0.000000000f, 1.000000000f, - 0.003067957f, 0.999995294f, - 0.006135885f, 0.999981175f, - 0.009203755f, 0.999957645f, - 0.012271538f, 0.999924702f, - 0.015339206f, 0.999882347f, - 0.018406730f, 0.999830582f, - 0.021474080f, 0.999769405f, - 0.024541229f, 0.999698819f, - 0.027608146f, 0.999618822f, - 0.030674803f, 0.999529418f, - 0.033741172f, 0.999430605f, - 0.036807223f, 0.999322385f, - 0.039872928f, 0.999204759f, - 0.042938257f, 0.999077728f, - 0.046003182f, 0.998941293f, - 0.049067674f, 0.998795456f, - 0.052131705f, 0.998640218f, - 0.055195244f, 0.998475581f, - 0.058258265f, 0.998301545f, - 0.061320736f, 0.998118113f, - 0.064382631f, 0.997925286f, - 0.067443920f, 0.997723067f, - 0.070504573f, 0.997511456f, - 0.073564564f, 0.997290457f, - 0.076623861f, 0.997060070f, - 0.079682438f, 0.996820299f, - 0.082740265f, 0.996571146f, - 0.085797312f, 0.996312612f, - 0.088853553f, 0.996044701f, - 0.091908956f, 0.995767414f, - 0.094963495f, 0.995480755f, - 0.098017140f, 0.995184727f, - 0.101069863f, 0.994879331f, - 0.104121634f, 0.994564571f, - 0.107172425f, 0.994240449f, - 0.110222207f, 0.993906970f, - 0.113270952f, 0.993564136f, - 0.116318631f, 0.993211949f, - 0.119365215f, 0.992850414f, - 0.122410675f, 0.992479535f, - 0.125454983f, 0.992099313f, - 0.128498111f, 0.991709754f, - 0.131540029f, 0.991310860f, - 0.134580709f, 0.990902635f, - 0.137620122f, 0.990485084f, - 0.140658239f, 0.990058210f, - 0.143695033f, 0.989622017f, - 0.146730474f, 0.989176510f, - 0.149764535f, 0.988721692f, - 0.152797185f, 0.988257568f, - 0.155828398f, 0.987784142f, - 0.158858143f, 0.987301418f, - 0.161886394f, 0.986809402f, - 0.164913120f, 0.986308097f, - 0.167938295f, 0.985797509f, - 0.170961889f, 0.985277642f, - 0.173983873f, 0.984748502f, - 0.177004220f, 0.984210092f, - 0.180022901f, 0.983662419f, - 0.183039888f, 0.983105487f, - 0.186055152f, 0.982539302f, - 0.189068664f, 0.981963869f, - 0.192080397f, 0.981379193f, - 0.195090322f, 0.980785280f, - 0.198098411f, 0.980182136f, - 0.201104635f, 0.979569766f, - 0.204108966f, 0.978948175f, - 0.207111376f, 0.978317371f, - 0.210111837f, 0.977677358f, - 0.213110320f, 0.977028143f, - 0.216106797f, 0.976369731f, - 0.219101240f, 0.975702130f, - 0.222093621f, 0.975025345f, - 0.225083911f, 0.974339383f, - 0.228072083f, 0.973644250f, - 0.231058108f, 0.972939952f, - 0.234041959f, 0.972226497f, - 0.237023606f, 0.971503891f, - 0.240003022f, 0.970772141f, - 0.242980180f, 0.970031253f, - 0.245955050f, 0.969281235f, - 0.248927606f, 0.968522094f, - 0.251897818f, 0.967753837f, - 0.254865660f, 0.966976471f, - 0.257831102f, 0.966190003f, - 0.260794118f, 0.965394442f, - 0.263754679f, 0.964589793f, - 0.266712757f, 0.963776066f, - 0.269668326f, 0.962953267f, - 0.272621355f, 0.962121404f, - 0.275571819f, 0.961280486f, - 0.278519689f, 0.960430519f, - 0.281464938f, 0.959571513f, - 0.284407537f, 0.958703475f, - 0.287347460f, 0.957826413f, - 0.290284677f, 0.956940336f, - 0.293219163f, 0.956045251f, - 0.296150888f, 0.955141168f, - 0.299079826f, 0.954228095f, - 0.302005949f, 0.953306040f, - 0.304929230f, 0.952375013f, - 0.307849640f, 0.951435021f, - 0.310767153f, 0.950486074f, - 0.313681740f, 0.949528181f, - 0.316593376f, 0.948561350f, - 0.319502031f, 0.947585591f, - 0.322407679f, 0.946600913f, - 0.325310292f, 0.945607325f, - 0.328209844f, 0.944604837f, - 0.331106306f, 0.943593458f, - 0.333999651f, 0.942573198f, - 0.336889853f, 0.941544065f, - 0.339776884f, 0.940506071f, - 0.342660717f, 0.939459224f, - 0.345541325f, 0.938403534f, - 0.348418680f, 0.937339012f, - 0.351292756f, 0.936265667f, - 0.354163525f, 0.935183510f, - 0.357030961f, 0.934092550f, - 0.359895037f, 0.932992799f, - 0.362755724f, 0.931884266f, - 0.365612998f, 0.930766961f, - 0.368466830f, 0.929640896f, - 0.371317194f, 0.928506080f, - 0.374164063f, 0.927362526f, - 0.377007410f, 0.926210242f, - 0.379847209f, 0.925049241f, - 0.382683432f, 0.923879533f, - 0.385516054f, 0.922701128f, - 0.388345047f, 0.921514039f, - 0.391170384f, 0.920318277f, - 0.393992040f, 0.919113852f, - 0.396809987f, 0.917900776f, - 0.399624200f, 0.916679060f, - 0.402434651f, 0.915448716f, - 0.405241314f, 0.914209756f, - 0.408044163f, 0.912962190f, - 0.410843171f, 0.911706032f, - 0.413638312f, 0.910441292f, - 0.416429560f, 0.909167983f, - 0.419216888f, 0.907886116f, - 0.422000271f, 0.906595705f, - 0.424779681f, 0.905296759f, - 0.427555093f, 0.903989293f, - 0.430326481f, 0.902673318f, - 0.433093819f, 0.901348847f, - 0.435857080f, 0.900015892f, - 0.438616239f, 0.898674466f, - 0.441371269f, 0.897324581f, - 0.444122145f, 0.895966250f, - 0.446868840f, 0.894599486f, - 0.449611330f, 0.893224301f, - 0.452349587f, 0.891840709f, - 0.455083587f, 0.890448723f, - 0.457813304f, 0.889048356f, - 0.460538711f, 0.887639620f, - 0.463259784f, 0.886222530f, - 0.465976496f, 0.884797098f, - 0.468688822f, 0.883363339f, - 0.471396737f, 0.881921264f, - 0.474100215f, 0.880470889f, - 0.476799230f, 0.879012226f, - 0.479493758f, 0.877545290f, - 0.482183772f, 0.876070094f, - 0.484869248f, 0.874586652f, - 0.487550160f, 0.873094978f, - 0.490226483f, 0.871595087f, - 0.492898192f, 0.870086991f, - 0.495565262f, 0.868570706f, - 0.498227667f, 0.867046246f, - 0.500885383f, 0.865513624f, - 0.503538384f, 0.863972856f, - 0.506186645f, 0.862423956f, - 0.508830143f, 0.860866939f, - 0.511468850f, 0.859301818f, - 0.514102744f, 0.857728610f, - 0.516731799f, 0.856147328f, - 0.519355990f, 0.854557988f, - 0.521975293f, 0.852960605f, - 0.524589683f, 0.851355193f, - 0.527199135f, 0.849741768f, - 0.529803625f, 0.848120345f, - 0.532403128f, 0.846490939f, - 0.534997620f, 0.844853565f, - 0.537587076f, 0.843208240f, - 0.540171473f, 0.841554977f, - 0.542750785f, 0.839893794f, - 0.545324988f, 0.838224706f, - 0.547894059f, 0.836547727f, - 0.550457973f, 0.834862875f, - 0.553016706f, 0.833170165f, - 0.555570233f, 0.831469612f, - 0.558118531f, 0.829761234f, - 0.560661576f, 0.828045045f, - 0.563199344f, 0.826321063f, - 0.565731811f, 0.824589303f, - 0.568258953f, 0.822849781f, - 0.570780746f, 0.821102515f, - 0.573297167f, 0.819347520f, - 0.575808191f, 0.817584813f, - 0.578313796f, 0.815814411f, - 0.580813958f, 0.814036330f, - 0.583308653f, 0.812250587f, - 0.585797857f, 0.810457198f, - 0.588281548f, 0.808656182f, - 0.590759702f, 0.806847554f, - 0.593232295f, 0.805031331f, - 0.595699304f, 0.803207531f, - 0.598160707f, 0.801376172f, - 0.600616479f, 0.799537269f, - 0.603066599f, 0.797690841f, - 0.605511041f, 0.795836905f, - 0.607949785f, 0.793975478f, - 0.610382806f, 0.792106577f, - 0.612810082f, 0.790230221f, - 0.615231591f, 0.788346428f, - 0.617647308f, 0.786455214f, - 0.620057212f, 0.784556597f, - 0.622461279f, 0.782650596f, - 0.624859488f, 0.780737229f, - 0.627251815f, 0.778816512f, - 0.629638239f, 0.776888466f, - 0.632018736f, 0.774953107f, - 0.634393284f, 0.773010453f, - 0.636761861f, 0.771060524f, - 0.639124445f, 0.769103338f, - 0.641481013f, 0.767138912f, - 0.643831543f, 0.765167266f, - 0.646176013f, 0.763188417f, - 0.648514401f, 0.761202385f, - 0.650846685f, 0.759209189f, - 0.653172843f, 0.757208847f, - 0.655492853f, 0.755201377f, - 0.657806693f, 0.753186799f, - 0.660114342f, 0.751165132f, - 0.662415778f, 0.749136395f, - 0.664710978f, 0.747100606f, - 0.666999922f, 0.745057785f, - 0.669282588f, 0.743007952f, - 0.671558955f, 0.740951125f, - 0.673829000f, 0.738887324f, - 0.676092704f, 0.736816569f, - 0.678350043f, 0.734738878f, - 0.680600998f, 0.732654272f, - 0.682845546f, 0.730562769f, - 0.685083668f, 0.728464390f, - 0.687315341f, 0.726359155f, - 0.689540545f, 0.724247083f, - 0.691759258f, 0.722128194f, - 0.693971461f, 0.720002508f, - 0.696177131f, 0.717870045f, - 0.698376249f, 0.715730825f, - 0.700568794f, 0.713584869f, - 0.702754744f, 0.711432196f, - 0.704934080f, 0.709272826f, - 0.707106781f, 0.707106781f, - 0.709272826f, 0.704934080f, - 0.711432196f, 0.702754744f, - 0.713584869f, 0.700568794f, - 0.715730825f, 0.698376249f, - 0.717870045f, 0.696177131f, - 0.720002508f, 0.693971461f, - 0.722128194f, 0.691759258f, - 0.724247083f, 0.689540545f, - 0.726359155f, 0.687315341f, - 0.728464390f, 0.685083668f, - 0.730562769f, 0.682845546f, - 0.732654272f, 0.680600998f, - 0.734738878f, 0.678350043f, - 0.736816569f, 0.676092704f, - 0.738887324f, 0.673829000f, - 0.740951125f, 0.671558955f, - 0.743007952f, 0.669282588f, - 0.745057785f, 0.666999922f, - 0.747100606f, 0.664710978f, - 0.749136395f, 0.662415778f, - 0.751165132f, 0.660114342f, - 0.753186799f, 0.657806693f, - 0.755201377f, 0.655492853f, - 0.757208847f, 0.653172843f, - 0.759209189f, 0.650846685f, - 0.761202385f, 0.648514401f, - 0.763188417f, 0.646176013f, - 0.765167266f, 0.643831543f, - 0.767138912f, 0.641481013f, - 0.769103338f, 0.639124445f, - 0.771060524f, 0.636761861f, - 0.773010453f, 0.634393284f, - 0.774953107f, 0.632018736f, - 0.776888466f, 0.629638239f, - 0.778816512f, 0.627251815f, - 0.780737229f, 0.624859488f, - 0.782650596f, 0.622461279f, - 0.784556597f, 0.620057212f, - 0.786455214f, 0.617647308f, - 0.788346428f, 0.615231591f, - 0.790230221f, 0.612810082f, - 0.792106577f, 0.610382806f, - 0.793975478f, 0.607949785f, - 0.795836905f, 0.605511041f, - 0.797690841f, 0.603066599f, - 0.799537269f, 0.600616479f, - 0.801376172f, 0.598160707f, - 0.803207531f, 0.595699304f, - 0.805031331f, 0.593232295f, - 0.806847554f, 0.590759702f, - 0.808656182f, 0.588281548f, - 0.810457198f, 0.585797857f, - 0.812250587f, 0.583308653f, - 0.814036330f, 0.580813958f, - 0.815814411f, 0.578313796f, - 0.817584813f, 0.575808191f, - 0.819347520f, 0.573297167f, - 0.821102515f, 0.570780746f, - 0.822849781f, 0.568258953f, - 0.824589303f, 0.565731811f, - 0.826321063f, 0.563199344f, - 0.828045045f, 0.560661576f, - 0.829761234f, 0.558118531f, - 0.831469612f, 0.555570233f, - 0.833170165f, 0.553016706f, - 0.834862875f, 0.550457973f, - 0.836547727f, 0.547894059f, - 0.838224706f, 0.545324988f, - 0.839893794f, 0.542750785f, - 0.841554977f, 0.540171473f, - 0.843208240f, 0.537587076f, - 0.844853565f, 0.534997620f, - 0.846490939f, 0.532403128f, - 0.848120345f, 0.529803625f, - 0.849741768f, 0.527199135f, - 0.851355193f, 0.524589683f, - 0.852960605f, 0.521975293f, - 0.854557988f, 0.519355990f, - 0.856147328f, 0.516731799f, - 0.857728610f, 0.514102744f, - 0.859301818f, 0.511468850f, - 0.860866939f, 0.508830143f, - 0.862423956f, 0.506186645f, - 0.863972856f, 0.503538384f, - 0.865513624f, 0.500885383f, - 0.867046246f, 0.498227667f, - 0.868570706f, 0.495565262f, - 0.870086991f, 0.492898192f, - 0.871595087f, 0.490226483f, - 0.873094978f, 0.487550160f, - 0.874586652f, 0.484869248f, - 0.876070094f, 0.482183772f, - 0.877545290f, 0.479493758f, - 0.879012226f, 0.476799230f, - 0.880470889f, 0.474100215f, - 0.881921264f, 0.471396737f, - 0.883363339f, 0.468688822f, - 0.884797098f, 0.465976496f, - 0.886222530f, 0.463259784f, - 0.887639620f, 0.460538711f, - 0.889048356f, 0.457813304f, - 0.890448723f, 0.455083587f, - 0.891840709f, 0.452349587f, - 0.893224301f, 0.449611330f, - 0.894599486f, 0.446868840f, - 0.895966250f, 0.444122145f, - 0.897324581f, 0.441371269f, - 0.898674466f, 0.438616239f, - 0.900015892f, 0.435857080f, - 0.901348847f, 0.433093819f, - 0.902673318f, 0.430326481f, - 0.903989293f, 0.427555093f, - 0.905296759f, 0.424779681f, - 0.906595705f, 0.422000271f, - 0.907886116f, 0.419216888f, - 0.909167983f, 0.416429560f, - 0.910441292f, 0.413638312f, - 0.911706032f, 0.410843171f, - 0.912962190f, 0.408044163f, - 0.914209756f, 0.405241314f, - 0.915448716f, 0.402434651f, - 0.916679060f, 0.399624200f, - 0.917900776f, 0.396809987f, - 0.919113852f, 0.393992040f, - 0.920318277f, 0.391170384f, - 0.921514039f, 0.388345047f, - 0.922701128f, 0.385516054f, - 0.923879533f, 0.382683432f, - 0.925049241f, 0.379847209f, - 0.926210242f, 0.377007410f, - 0.927362526f, 0.374164063f, - 0.928506080f, 0.371317194f, - 0.929640896f, 0.368466830f, - 0.930766961f, 0.365612998f, - 0.931884266f, 0.362755724f, - 0.932992799f, 0.359895037f, - 0.934092550f, 0.357030961f, - 0.935183510f, 0.354163525f, - 0.936265667f, 0.351292756f, - 0.937339012f, 0.348418680f, - 0.938403534f, 0.345541325f, - 0.939459224f, 0.342660717f, - 0.940506071f, 0.339776884f, - 0.941544065f, 0.336889853f, - 0.942573198f, 0.333999651f, - 0.943593458f, 0.331106306f, - 0.944604837f, 0.328209844f, - 0.945607325f, 0.325310292f, - 0.946600913f, 0.322407679f, - 0.947585591f, 0.319502031f, - 0.948561350f, 0.316593376f, - 0.949528181f, 0.313681740f, - 0.950486074f, 0.310767153f, - 0.951435021f, 0.307849640f, - 0.952375013f, 0.304929230f, - 0.953306040f, 0.302005949f, - 0.954228095f, 0.299079826f, - 0.955141168f, 0.296150888f, - 0.956045251f, 0.293219163f, - 0.956940336f, 0.290284677f, - 0.957826413f, 0.287347460f, - 0.958703475f, 0.284407537f, - 0.959571513f, 0.281464938f, - 0.960430519f, 0.278519689f, - 0.961280486f, 0.275571819f, - 0.962121404f, 0.272621355f, - 0.962953267f, 0.269668326f, - 0.963776066f, 0.266712757f, - 0.964589793f, 0.263754679f, - 0.965394442f, 0.260794118f, - 0.966190003f, 0.257831102f, - 0.966976471f, 0.254865660f, - 0.967753837f, 0.251897818f, - 0.968522094f, 0.248927606f, - 0.969281235f, 0.245955050f, - 0.970031253f, 0.242980180f, - 0.970772141f, 0.240003022f, - 0.971503891f, 0.237023606f, - 0.972226497f, 0.234041959f, - 0.972939952f, 0.231058108f, - 0.973644250f, 0.228072083f, - 0.974339383f, 0.225083911f, - 0.975025345f, 0.222093621f, - 0.975702130f, 0.219101240f, - 0.976369731f, 0.216106797f, - 0.977028143f, 0.213110320f, - 0.977677358f, 0.210111837f, - 0.978317371f, 0.207111376f, - 0.978948175f, 0.204108966f, - 0.979569766f, 0.201104635f, - 0.980182136f, 0.198098411f, - 0.980785280f, 0.195090322f, - 0.981379193f, 0.192080397f, - 0.981963869f, 0.189068664f, - 0.982539302f, 0.186055152f, - 0.983105487f, 0.183039888f, - 0.983662419f, 0.180022901f, - 0.984210092f, 0.177004220f, - 0.984748502f, 0.173983873f, - 0.985277642f, 0.170961889f, - 0.985797509f, 0.167938295f, - 0.986308097f, 0.164913120f, - 0.986809402f, 0.161886394f, - 0.987301418f, 0.158858143f, - 0.987784142f, 0.155828398f, - 0.988257568f, 0.152797185f, - 0.988721692f, 0.149764535f, - 0.989176510f, 0.146730474f, - 0.989622017f, 0.143695033f, - 0.990058210f, 0.140658239f, - 0.990485084f, 0.137620122f, - 0.990902635f, 0.134580709f, - 0.991310860f, 0.131540029f, - 0.991709754f, 0.128498111f, - 0.992099313f, 0.125454983f, - 0.992479535f, 0.122410675f, - 0.992850414f, 0.119365215f, - 0.993211949f, 0.116318631f, - 0.993564136f, 0.113270952f, - 0.993906970f, 0.110222207f, - 0.994240449f, 0.107172425f, - 0.994564571f, 0.104121634f, - 0.994879331f, 0.101069863f, - 0.995184727f, 0.098017140f, - 0.995480755f, 0.094963495f, - 0.995767414f, 0.091908956f, - 0.996044701f, 0.088853553f, - 0.996312612f, 0.085797312f, - 0.996571146f, 0.082740265f, - 0.996820299f, 0.079682438f, - 0.997060070f, 0.076623861f, - 0.997290457f, 0.073564564f, - 0.997511456f, 0.070504573f, - 0.997723067f, 0.067443920f, - 0.997925286f, 0.064382631f, - 0.998118113f, 0.061320736f, - 0.998301545f, 0.058258265f, - 0.998475581f, 0.055195244f, - 0.998640218f, 0.052131705f, - 0.998795456f, 0.049067674f, - 0.998941293f, 0.046003182f, - 0.999077728f, 0.042938257f, - 0.999204759f, 0.039872928f, - 0.999322385f, 0.036807223f, - 0.999430605f, 0.033741172f, - 0.999529418f, 0.030674803f, - 0.999618822f, 0.027608146f, - 0.999698819f, 0.024541229f, - 0.999769405f, 0.021474080f, - 0.999830582f, 0.018406730f, - 0.999882347f, 0.015339206f, - 0.999924702f, 0.012271538f, - 0.999957645f, 0.009203755f, - 0.999981175f, 0.006135885f, - 0.999995294f, 0.003067957f, - 1.000000000f, 0.000000000f, - 0.999995294f, -0.003067957f, - 0.999981175f, -0.006135885f, - 0.999957645f, -0.009203755f, - 0.999924702f, -0.012271538f, - 0.999882347f, -0.015339206f, - 0.999830582f, -0.018406730f, - 0.999769405f, -0.021474080f, - 0.999698819f, -0.024541229f, - 0.999618822f, -0.027608146f, - 0.999529418f, -0.030674803f, - 0.999430605f, -0.033741172f, - 0.999322385f, -0.036807223f, - 0.999204759f, -0.039872928f, - 0.999077728f, -0.042938257f, - 0.998941293f, -0.046003182f, - 0.998795456f, -0.049067674f, - 0.998640218f, -0.052131705f, - 0.998475581f, -0.055195244f, - 0.998301545f, -0.058258265f, - 0.998118113f, -0.061320736f, - 0.997925286f, -0.064382631f, - 0.997723067f, -0.067443920f, - 0.997511456f, -0.070504573f, - 0.997290457f, -0.073564564f, - 0.997060070f, -0.076623861f, - 0.996820299f, -0.079682438f, - 0.996571146f, -0.082740265f, - 0.996312612f, -0.085797312f, - 0.996044701f, -0.088853553f, - 0.995767414f, -0.091908956f, - 0.995480755f, -0.094963495f, - 0.995184727f, -0.098017140f, - 0.994879331f, -0.101069863f, - 0.994564571f, -0.104121634f, - 0.994240449f, -0.107172425f, - 0.993906970f, -0.110222207f, - 0.993564136f, -0.113270952f, - 0.993211949f, -0.116318631f, - 0.992850414f, -0.119365215f, - 0.992479535f, -0.122410675f, - 0.992099313f, -0.125454983f, - 0.991709754f, -0.128498111f, - 0.991310860f, -0.131540029f, - 0.990902635f, -0.134580709f, - 0.990485084f, -0.137620122f, - 0.990058210f, -0.140658239f, - 0.989622017f, -0.143695033f, - 0.989176510f, -0.146730474f, - 0.988721692f, -0.149764535f, - 0.988257568f, -0.152797185f, - 0.987784142f, -0.155828398f, - 0.987301418f, -0.158858143f, - 0.986809402f, -0.161886394f, - 0.986308097f, -0.164913120f, - 0.985797509f, -0.167938295f, - 0.985277642f, -0.170961889f, - 0.984748502f, -0.173983873f, - 0.984210092f, -0.177004220f, - 0.983662419f, -0.180022901f, - 0.983105487f, -0.183039888f, - 0.982539302f, -0.186055152f, - 0.981963869f, -0.189068664f, - 0.981379193f, -0.192080397f, - 0.980785280f, -0.195090322f, - 0.980182136f, -0.198098411f, - 0.979569766f, -0.201104635f, - 0.978948175f, -0.204108966f, - 0.978317371f, -0.207111376f, - 0.977677358f, -0.210111837f, - 0.977028143f, -0.213110320f, - 0.976369731f, -0.216106797f, - 0.975702130f, -0.219101240f, - 0.975025345f, -0.222093621f, - 0.974339383f, -0.225083911f, - 0.973644250f, -0.228072083f, - 0.972939952f, -0.231058108f, - 0.972226497f, -0.234041959f, - 0.971503891f, -0.237023606f, - 0.970772141f, -0.240003022f, - 0.970031253f, -0.242980180f, - 0.969281235f, -0.245955050f, - 0.968522094f, -0.248927606f, - 0.967753837f, -0.251897818f, - 0.966976471f, -0.254865660f, - 0.966190003f, -0.257831102f, - 0.965394442f, -0.260794118f, - 0.964589793f, -0.263754679f, - 0.963776066f, -0.266712757f, - 0.962953267f, -0.269668326f, - 0.962121404f, -0.272621355f, - 0.961280486f, -0.275571819f, - 0.960430519f, -0.278519689f, - 0.959571513f, -0.281464938f, - 0.958703475f, -0.284407537f, - 0.957826413f, -0.287347460f, - 0.956940336f, -0.290284677f, - 0.956045251f, -0.293219163f, - 0.955141168f, -0.296150888f, - 0.954228095f, -0.299079826f, - 0.953306040f, -0.302005949f, - 0.952375013f, -0.304929230f, - 0.951435021f, -0.307849640f, - 0.950486074f, -0.310767153f, - 0.949528181f, -0.313681740f, - 0.948561350f, -0.316593376f, - 0.947585591f, -0.319502031f, - 0.946600913f, -0.322407679f, - 0.945607325f, -0.325310292f, - 0.944604837f, -0.328209844f, - 0.943593458f, -0.331106306f, - 0.942573198f, -0.333999651f, - 0.941544065f, -0.336889853f, - 0.940506071f, -0.339776884f, - 0.939459224f, -0.342660717f, - 0.938403534f, -0.345541325f, - 0.937339012f, -0.348418680f, - 0.936265667f, -0.351292756f, - 0.935183510f, -0.354163525f, - 0.934092550f, -0.357030961f, - 0.932992799f, -0.359895037f, - 0.931884266f, -0.362755724f, - 0.930766961f, -0.365612998f, - 0.929640896f, -0.368466830f, - 0.928506080f, -0.371317194f, - 0.927362526f, -0.374164063f, - 0.926210242f, -0.377007410f, - 0.925049241f, -0.379847209f, - 0.923879533f, -0.382683432f, - 0.922701128f, -0.385516054f, - 0.921514039f, -0.388345047f, - 0.920318277f, -0.391170384f, - 0.919113852f, -0.393992040f, - 0.917900776f, -0.396809987f, - 0.916679060f, -0.399624200f, - 0.915448716f, -0.402434651f, - 0.914209756f, -0.405241314f, - 0.912962190f, -0.408044163f, - 0.911706032f, -0.410843171f, - 0.910441292f, -0.413638312f, - 0.909167983f, -0.416429560f, - 0.907886116f, -0.419216888f, - 0.906595705f, -0.422000271f, - 0.905296759f, -0.424779681f, - 0.903989293f, -0.427555093f, - 0.902673318f, -0.430326481f, - 0.901348847f, -0.433093819f, - 0.900015892f, -0.435857080f, - 0.898674466f, -0.438616239f, - 0.897324581f, -0.441371269f, - 0.895966250f, -0.444122145f, - 0.894599486f, -0.446868840f, - 0.893224301f, -0.449611330f, - 0.891840709f, -0.452349587f, - 0.890448723f, -0.455083587f, - 0.889048356f, -0.457813304f, - 0.887639620f, -0.460538711f, - 0.886222530f, -0.463259784f, - 0.884797098f, -0.465976496f, - 0.883363339f, -0.468688822f, - 0.881921264f, -0.471396737f, - 0.880470889f, -0.474100215f, - 0.879012226f, -0.476799230f, - 0.877545290f, -0.479493758f, - 0.876070094f, -0.482183772f, - 0.874586652f, -0.484869248f, - 0.873094978f, -0.487550160f, - 0.871595087f, -0.490226483f, - 0.870086991f, -0.492898192f, - 0.868570706f, -0.495565262f, - 0.867046246f, -0.498227667f, - 0.865513624f, -0.500885383f, - 0.863972856f, -0.503538384f, - 0.862423956f, -0.506186645f, - 0.860866939f, -0.508830143f, - 0.859301818f, -0.511468850f, - 0.857728610f, -0.514102744f, - 0.856147328f, -0.516731799f, - 0.854557988f, -0.519355990f, - 0.852960605f, -0.521975293f, - 0.851355193f, -0.524589683f, - 0.849741768f, -0.527199135f, - 0.848120345f, -0.529803625f, - 0.846490939f, -0.532403128f, - 0.844853565f, -0.534997620f, - 0.843208240f, -0.537587076f, - 0.841554977f, -0.540171473f, - 0.839893794f, -0.542750785f, - 0.838224706f, -0.545324988f, - 0.836547727f, -0.547894059f, - 0.834862875f, -0.550457973f, - 0.833170165f, -0.553016706f, - 0.831469612f, -0.555570233f, - 0.829761234f, -0.558118531f, - 0.828045045f, -0.560661576f, - 0.826321063f, -0.563199344f, - 0.824589303f, -0.565731811f, - 0.822849781f, -0.568258953f, - 0.821102515f, -0.570780746f, - 0.819347520f, -0.573297167f, - 0.817584813f, -0.575808191f, - 0.815814411f, -0.578313796f, - 0.814036330f, -0.580813958f, - 0.812250587f, -0.583308653f, - 0.810457198f, -0.585797857f, - 0.808656182f, -0.588281548f, - 0.806847554f, -0.590759702f, - 0.805031331f, -0.593232295f, - 0.803207531f, -0.595699304f, - 0.801376172f, -0.598160707f, - 0.799537269f, -0.600616479f, - 0.797690841f, -0.603066599f, - 0.795836905f, -0.605511041f, - 0.793975478f, -0.607949785f, - 0.792106577f, -0.610382806f, - 0.790230221f, -0.612810082f, - 0.788346428f, -0.615231591f, - 0.786455214f, -0.617647308f, - 0.784556597f, -0.620057212f, - 0.782650596f, -0.622461279f, - 0.780737229f, -0.624859488f, - 0.778816512f, -0.627251815f, - 0.776888466f, -0.629638239f, - 0.774953107f, -0.632018736f, - 0.773010453f, -0.634393284f, - 0.771060524f, -0.636761861f, - 0.769103338f, -0.639124445f, - 0.767138912f, -0.641481013f, - 0.765167266f, -0.643831543f, - 0.763188417f, -0.646176013f, - 0.761202385f, -0.648514401f, - 0.759209189f, -0.650846685f, - 0.757208847f, -0.653172843f, - 0.755201377f, -0.655492853f, - 0.753186799f, -0.657806693f, - 0.751165132f, -0.660114342f, - 0.749136395f, -0.662415778f, - 0.747100606f, -0.664710978f, - 0.745057785f, -0.666999922f, - 0.743007952f, -0.669282588f, - 0.740951125f, -0.671558955f, - 0.738887324f, -0.673829000f, - 0.736816569f, -0.676092704f, - 0.734738878f, -0.678350043f, - 0.732654272f, -0.680600998f, - 0.730562769f, -0.682845546f, - 0.728464390f, -0.685083668f, - 0.726359155f, -0.687315341f, - 0.724247083f, -0.689540545f, - 0.722128194f, -0.691759258f, - 0.720002508f, -0.693971461f, - 0.717870045f, -0.696177131f, - 0.715730825f, -0.698376249f, - 0.713584869f, -0.700568794f, - 0.711432196f, -0.702754744f, - 0.709272826f, -0.704934080f, - 0.707106781f, -0.707106781f, - 0.704934080f, -0.709272826f, - 0.702754744f, -0.711432196f, - 0.700568794f, -0.713584869f, - 0.698376249f, -0.715730825f, - 0.696177131f, -0.717870045f, - 0.693971461f, -0.720002508f, - 0.691759258f, -0.722128194f, - 0.689540545f, -0.724247083f, - 0.687315341f, -0.726359155f, - 0.685083668f, -0.728464390f, - 0.682845546f, -0.730562769f, - 0.680600998f, -0.732654272f, - 0.678350043f, -0.734738878f, - 0.676092704f, -0.736816569f, - 0.673829000f, -0.738887324f, - 0.671558955f, -0.740951125f, - 0.669282588f, -0.743007952f, - 0.666999922f, -0.745057785f, - 0.664710978f, -0.747100606f, - 0.662415778f, -0.749136395f, - 0.660114342f, -0.751165132f, - 0.657806693f, -0.753186799f, - 0.655492853f, -0.755201377f, - 0.653172843f, -0.757208847f, - 0.650846685f, -0.759209189f, - 0.648514401f, -0.761202385f, - 0.646176013f, -0.763188417f, - 0.643831543f, -0.765167266f, - 0.641481013f, -0.767138912f, - 0.639124445f, -0.769103338f, - 0.636761861f, -0.771060524f, - 0.634393284f, -0.773010453f, - 0.632018736f, -0.774953107f, - 0.629638239f, -0.776888466f, - 0.627251815f, -0.778816512f, - 0.624859488f, -0.780737229f, - 0.622461279f, -0.782650596f, - 0.620057212f, -0.784556597f, - 0.617647308f, -0.786455214f, - 0.615231591f, -0.788346428f, - 0.612810082f, -0.790230221f, - 0.610382806f, -0.792106577f, - 0.607949785f, -0.793975478f, - 0.605511041f, -0.795836905f, - 0.603066599f, -0.797690841f, - 0.600616479f, -0.799537269f, - 0.598160707f, -0.801376172f, - 0.595699304f, -0.803207531f, - 0.593232295f, -0.805031331f, - 0.590759702f, -0.806847554f, - 0.588281548f, -0.808656182f, - 0.585797857f, -0.810457198f, - 0.583308653f, -0.812250587f, - 0.580813958f, -0.814036330f, - 0.578313796f, -0.815814411f, - 0.575808191f, -0.817584813f, - 0.573297167f, -0.819347520f, - 0.570780746f, -0.821102515f, - 0.568258953f, -0.822849781f, - 0.565731811f, -0.824589303f, - 0.563199344f, -0.826321063f, - 0.560661576f, -0.828045045f, - 0.558118531f, -0.829761234f, - 0.555570233f, -0.831469612f, - 0.553016706f, -0.833170165f, - 0.550457973f, -0.834862875f, - 0.547894059f, -0.836547727f, - 0.545324988f, -0.838224706f, - 0.542750785f, -0.839893794f, - 0.540171473f, -0.841554977f, - 0.537587076f, -0.843208240f, - 0.534997620f, -0.844853565f, - 0.532403128f, -0.846490939f, - 0.529803625f, -0.848120345f, - 0.527199135f, -0.849741768f, - 0.524589683f, -0.851355193f, - 0.521975293f, -0.852960605f, - 0.519355990f, -0.854557988f, - 0.516731799f, -0.856147328f, - 0.514102744f, -0.857728610f, - 0.511468850f, -0.859301818f, - 0.508830143f, -0.860866939f, - 0.506186645f, -0.862423956f, - 0.503538384f, -0.863972856f, - 0.500885383f, -0.865513624f, - 0.498227667f, -0.867046246f, - 0.495565262f, -0.868570706f, - 0.492898192f, -0.870086991f, - 0.490226483f, -0.871595087f, - 0.487550160f, -0.873094978f, - 0.484869248f, -0.874586652f, - 0.482183772f, -0.876070094f, - 0.479493758f, -0.877545290f, - 0.476799230f, -0.879012226f, - 0.474100215f, -0.880470889f, - 0.471396737f, -0.881921264f, - 0.468688822f, -0.883363339f, - 0.465976496f, -0.884797098f, - 0.463259784f, -0.886222530f, - 0.460538711f, -0.887639620f, - 0.457813304f, -0.889048356f, - 0.455083587f, -0.890448723f, - 0.452349587f, -0.891840709f, - 0.449611330f, -0.893224301f, - 0.446868840f, -0.894599486f, - 0.444122145f, -0.895966250f, - 0.441371269f, -0.897324581f, - 0.438616239f, -0.898674466f, - 0.435857080f, -0.900015892f, - 0.433093819f, -0.901348847f, - 0.430326481f, -0.902673318f, - 0.427555093f, -0.903989293f, - 0.424779681f, -0.905296759f, - 0.422000271f, -0.906595705f, - 0.419216888f, -0.907886116f, - 0.416429560f, -0.909167983f, - 0.413638312f, -0.910441292f, - 0.410843171f, -0.911706032f, - 0.408044163f, -0.912962190f, - 0.405241314f, -0.914209756f, - 0.402434651f, -0.915448716f, - 0.399624200f, -0.916679060f, - 0.396809987f, -0.917900776f, - 0.393992040f, -0.919113852f, - 0.391170384f, -0.920318277f, - 0.388345047f, -0.921514039f, - 0.385516054f, -0.922701128f, - 0.382683432f, -0.923879533f, - 0.379847209f, -0.925049241f, - 0.377007410f, -0.926210242f, - 0.374164063f, -0.927362526f, - 0.371317194f, -0.928506080f, - 0.368466830f, -0.929640896f, - 0.365612998f, -0.930766961f, - 0.362755724f, -0.931884266f, - 0.359895037f, -0.932992799f, - 0.357030961f, -0.934092550f, - 0.354163525f, -0.935183510f, - 0.351292756f, -0.936265667f, - 0.348418680f, -0.937339012f, - 0.345541325f, -0.938403534f, - 0.342660717f, -0.939459224f, - 0.339776884f, -0.940506071f, - 0.336889853f, -0.941544065f, - 0.333999651f, -0.942573198f, - 0.331106306f, -0.943593458f, - 0.328209844f, -0.944604837f, - 0.325310292f, -0.945607325f, - 0.322407679f, -0.946600913f, - 0.319502031f, -0.947585591f, - 0.316593376f, -0.948561350f, - 0.313681740f, -0.949528181f, - 0.310767153f, -0.950486074f, - 0.307849640f, -0.951435021f, - 0.304929230f, -0.952375013f, - 0.302005949f, -0.953306040f, - 0.299079826f, -0.954228095f, - 0.296150888f, -0.955141168f, - 0.293219163f, -0.956045251f, - 0.290284677f, -0.956940336f, - 0.287347460f, -0.957826413f, - 0.284407537f, -0.958703475f, - 0.281464938f, -0.959571513f, - 0.278519689f, -0.960430519f, - 0.275571819f, -0.961280486f, - 0.272621355f, -0.962121404f, - 0.269668326f, -0.962953267f, - 0.266712757f, -0.963776066f, - 0.263754679f, -0.964589793f, - 0.260794118f, -0.965394442f, - 0.257831102f, -0.966190003f, - 0.254865660f, -0.966976471f, - 0.251897818f, -0.967753837f, - 0.248927606f, -0.968522094f, - 0.245955050f, -0.969281235f, - 0.242980180f, -0.970031253f, - 0.240003022f, -0.970772141f, - 0.237023606f, -0.971503891f, - 0.234041959f, -0.972226497f, - 0.231058108f, -0.972939952f, - 0.228072083f, -0.973644250f, - 0.225083911f, -0.974339383f, - 0.222093621f, -0.975025345f, - 0.219101240f, -0.975702130f, - 0.216106797f, -0.976369731f, - 0.213110320f, -0.977028143f, - 0.210111837f, -0.977677358f, - 0.207111376f, -0.978317371f, - 0.204108966f, -0.978948175f, - 0.201104635f, -0.979569766f, - 0.198098411f, -0.980182136f, - 0.195090322f, -0.980785280f, - 0.192080397f, -0.981379193f, - 0.189068664f, -0.981963869f, - 0.186055152f, -0.982539302f, - 0.183039888f, -0.983105487f, - 0.180022901f, -0.983662419f, - 0.177004220f, -0.984210092f, - 0.173983873f, -0.984748502f, - 0.170961889f, -0.985277642f, - 0.167938295f, -0.985797509f, - 0.164913120f, -0.986308097f, - 0.161886394f, -0.986809402f, - 0.158858143f, -0.987301418f, - 0.155828398f, -0.987784142f, - 0.152797185f, -0.988257568f, - 0.149764535f, -0.988721692f, - 0.146730474f, -0.989176510f, - 0.143695033f, -0.989622017f, - 0.140658239f, -0.990058210f, - 0.137620122f, -0.990485084f, - 0.134580709f, -0.990902635f, - 0.131540029f, -0.991310860f, - 0.128498111f, -0.991709754f, - 0.125454983f, -0.992099313f, - 0.122410675f, -0.992479535f, - 0.119365215f, -0.992850414f, - 0.116318631f, -0.993211949f, - 0.113270952f, -0.993564136f, - 0.110222207f, -0.993906970f, - 0.107172425f, -0.994240449f, - 0.104121634f, -0.994564571f, - 0.101069863f, -0.994879331f, - 0.098017140f, -0.995184727f, - 0.094963495f, -0.995480755f, - 0.091908956f, -0.995767414f, - 0.088853553f, -0.996044701f, - 0.085797312f, -0.996312612f, - 0.082740265f, -0.996571146f, - 0.079682438f, -0.996820299f, - 0.076623861f, -0.997060070f, - 0.073564564f, -0.997290457f, - 0.070504573f, -0.997511456f, - 0.067443920f, -0.997723067f, - 0.064382631f, -0.997925286f, - 0.061320736f, -0.998118113f, - 0.058258265f, -0.998301545f, - 0.055195244f, -0.998475581f, - 0.052131705f, -0.998640218f, - 0.049067674f, -0.998795456f, - 0.046003182f, -0.998941293f, - 0.042938257f, -0.999077728f, - 0.039872928f, -0.999204759f, - 0.036807223f, -0.999322385f, - 0.033741172f, -0.999430605f, - 0.030674803f, -0.999529418f, - 0.027608146f, -0.999618822f, - 0.024541229f, -0.999698819f, - 0.021474080f, -0.999769405f, - 0.018406730f, -0.999830582f, - 0.015339206f, -0.999882347f, - 0.012271538f, -0.999924702f, - 0.009203755f, -0.999957645f, - 0.006135885f, -0.999981175f, - 0.003067957f, -0.999995294f -}; + 0.000000000f, 1.000000000f, 0.003067957f, 0.999995294f, 0.006135885f, + 0.999981175f, 0.009203755f, 0.999957645f, 0.012271538f, 0.999924702f, + 0.015339206f, 0.999882347f, 0.018406730f, 0.999830582f, 0.021474080f, + 0.999769405f, 0.024541229f, 0.999698819f, 0.027608146f, 0.999618822f, + 0.030674803f, 0.999529418f, 0.033741172f, 0.999430605f, 0.036807223f, + 0.999322385f, 0.039872928f, 0.999204759f, 0.042938257f, 0.999077728f, + 0.046003182f, 0.998941293f, 0.049067674f, 0.998795456f, 0.052131705f, + 0.998640218f, 0.055195244f, 0.998475581f, 0.058258265f, 0.998301545f, + 0.061320736f, 0.998118113f, 0.064382631f, 0.997925286f, 0.067443920f, + 0.997723067f, 0.070504573f, 0.997511456f, 0.073564564f, 0.997290457f, + 0.076623861f, 0.997060070f, 0.079682438f, 0.996820299f, 0.082740265f, + 0.996571146f, 0.085797312f, 0.996312612f, 0.088853553f, 0.996044701f, + 0.091908956f, 0.995767414f, 0.094963495f, 0.995480755f, 0.098017140f, + 0.995184727f, 0.101069863f, 0.994879331f, 0.104121634f, 0.994564571f, + 0.107172425f, 0.994240449f, 0.110222207f, 0.993906970f, 0.113270952f, + 0.993564136f, 0.116318631f, 0.993211949f, 0.119365215f, 0.992850414f, + 0.122410675f, 0.992479535f, 0.125454983f, 0.992099313f, 0.128498111f, + 0.991709754f, 0.131540029f, 0.991310860f, 0.134580709f, 0.990902635f, + 0.137620122f, 0.990485084f, 0.140658239f, 0.990058210f, 0.143695033f, + 0.989622017f, 0.146730474f, 0.989176510f, 0.149764535f, 0.988721692f, + 0.152797185f, 0.988257568f, 0.155828398f, 0.987784142f, 0.158858143f, + 0.987301418f, 0.161886394f, 0.986809402f, 0.164913120f, 0.986308097f, + 0.167938295f, 0.985797509f, 0.170961889f, 0.985277642f, 0.173983873f, + 0.984748502f, 0.177004220f, 0.984210092f, 0.180022901f, 0.983662419f, + 0.183039888f, 0.983105487f, 0.186055152f, 0.982539302f, 0.189068664f, + 0.981963869f, 0.192080397f, 0.981379193f, 0.195090322f, 0.980785280f, + 0.198098411f, 0.980182136f, 0.201104635f, 0.979569766f, 0.204108966f, + 0.978948175f, 0.207111376f, 0.978317371f, 0.210111837f, 0.977677358f, + 0.213110320f, 0.977028143f, 0.216106797f, 0.976369731f, 0.219101240f, + 0.975702130f, 0.222093621f, 0.975025345f, 0.225083911f, 0.974339383f, + 0.228072083f, 0.973644250f, 0.231058108f, 0.972939952f, 0.234041959f, + 0.972226497f, 0.237023606f, 0.971503891f, 0.240003022f, 0.970772141f, + 0.242980180f, 0.970031253f, 0.245955050f, 0.969281235f, 0.248927606f, + 0.968522094f, 0.251897818f, 0.967753837f, 0.254865660f, 0.966976471f, + 0.257831102f, 0.966190003f, 0.260794118f, 0.965394442f, 0.263754679f, + 0.964589793f, 0.266712757f, 0.963776066f, 0.269668326f, 0.962953267f, + 0.272621355f, 0.962121404f, 0.275571819f, 0.961280486f, 0.278519689f, + 0.960430519f, 0.281464938f, 0.959571513f, 0.284407537f, 0.958703475f, + 0.287347460f, 0.957826413f, 0.290284677f, 0.956940336f, 0.293219163f, + 0.956045251f, 0.296150888f, 0.955141168f, 0.299079826f, 0.954228095f, + 0.302005949f, 0.953306040f, 0.304929230f, 0.952375013f, 0.307849640f, + 0.951435021f, 0.310767153f, 0.950486074f, 0.313681740f, 0.949528181f, + 0.316593376f, 0.948561350f, 0.319502031f, 0.947585591f, 0.322407679f, + 0.946600913f, 0.325310292f, 0.945607325f, 0.328209844f, 0.944604837f, + 0.331106306f, 0.943593458f, 0.333999651f, 0.942573198f, 0.336889853f, + 0.941544065f, 0.339776884f, 0.940506071f, 0.342660717f, 0.939459224f, + 0.345541325f, 0.938403534f, 0.348418680f, 0.937339012f, 0.351292756f, + 0.936265667f, 0.354163525f, 0.935183510f, 0.357030961f, 0.934092550f, + 0.359895037f, 0.932992799f, 0.362755724f, 0.931884266f, 0.365612998f, + 0.930766961f, 0.368466830f, 0.929640896f, 0.371317194f, 0.928506080f, + 0.374164063f, 0.927362526f, 0.377007410f, 0.926210242f, 0.379847209f, + 0.925049241f, 0.382683432f, 0.923879533f, 0.385516054f, 0.922701128f, + 0.388345047f, 0.921514039f, 0.391170384f, 0.920318277f, 0.393992040f, + 0.919113852f, 0.396809987f, 0.917900776f, 0.399624200f, 0.916679060f, + 0.402434651f, 0.915448716f, 0.405241314f, 0.914209756f, 0.408044163f, + 0.912962190f, 0.410843171f, 0.911706032f, 0.413638312f, 0.910441292f, + 0.416429560f, 0.909167983f, 0.419216888f, 0.907886116f, 0.422000271f, + 0.906595705f, 0.424779681f, 0.905296759f, 0.427555093f, 0.903989293f, + 0.430326481f, 0.902673318f, 0.433093819f, 0.901348847f, 0.435857080f, + 0.900015892f, 0.438616239f, 0.898674466f, 0.441371269f, 0.897324581f, + 0.444122145f, 0.895966250f, 0.446868840f, 0.894599486f, 0.449611330f, + 0.893224301f, 0.452349587f, 0.891840709f, 0.455083587f, 0.890448723f, + 0.457813304f, 0.889048356f, 0.460538711f, 0.887639620f, 0.463259784f, + 0.886222530f, 0.465976496f, 0.884797098f, 0.468688822f, 0.883363339f, + 0.471396737f, 0.881921264f, 0.474100215f, 0.880470889f, 0.476799230f, + 0.879012226f, 0.479493758f, 0.877545290f, 0.482183772f, 0.876070094f, + 0.484869248f, 0.874586652f, 0.487550160f, 0.873094978f, 0.490226483f, + 0.871595087f, 0.492898192f, 0.870086991f, 0.495565262f, 0.868570706f, + 0.498227667f, 0.867046246f, 0.500885383f, 0.865513624f, 0.503538384f, + 0.863972856f, 0.506186645f, 0.862423956f, 0.508830143f, 0.860866939f, + 0.511468850f, 0.859301818f, 0.514102744f, 0.857728610f, 0.516731799f, + 0.856147328f, 0.519355990f, 0.854557988f, 0.521975293f, 0.852960605f, + 0.524589683f, 0.851355193f, 0.527199135f, 0.849741768f, 0.529803625f, + 0.848120345f, 0.532403128f, 0.846490939f, 0.534997620f, 0.844853565f, + 0.537587076f, 0.843208240f, 0.540171473f, 0.841554977f, 0.542750785f, + 0.839893794f, 0.545324988f, 0.838224706f, 0.547894059f, 0.836547727f, + 0.550457973f, 0.834862875f, 0.553016706f, 0.833170165f, 0.555570233f, + 0.831469612f, 0.558118531f, 0.829761234f, 0.560661576f, 0.828045045f, + 0.563199344f, 0.826321063f, 0.565731811f, 0.824589303f, 0.568258953f, + 0.822849781f, 0.570780746f, 0.821102515f, 0.573297167f, 0.819347520f, + 0.575808191f, 0.817584813f, 0.578313796f, 0.815814411f, 0.580813958f, + 0.814036330f, 0.583308653f, 0.812250587f, 0.585797857f, 0.810457198f, + 0.588281548f, 0.808656182f, 0.590759702f, 0.806847554f, 0.593232295f, + 0.805031331f, 0.595699304f, 0.803207531f, 0.598160707f, 0.801376172f, + 0.600616479f, 0.799537269f, 0.603066599f, 0.797690841f, 0.605511041f, + 0.795836905f, 0.607949785f, 0.793975478f, 0.610382806f, 0.792106577f, + 0.612810082f, 0.790230221f, 0.615231591f, 0.788346428f, 0.617647308f, + 0.786455214f, 0.620057212f, 0.784556597f, 0.622461279f, 0.782650596f, + 0.624859488f, 0.780737229f, 0.627251815f, 0.778816512f, 0.629638239f, + 0.776888466f, 0.632018736f, 0.774953107f, 0.634393284f, 0.773010453f, + 0.636761861f, 0.771060524f, 0.639124445f, 0.769103338f, 0.641481013f, + 0.767138912f, 0.643831543f, 0.765167266f, 0.646176013f, 0.763188417f, + 0.648514401f, 0.761202385f, 0.650846685f, 0.759209189f, 0.653172843f, + 0.757208847f, 0.655492853f, 0.755201377f, 0.657806693f, 0.753186799f, + 0.660114342f, 0.751165132f, 0.662415778f, 0.749136395f, 0.664710978f, + 0.747100606f, 0.666999922f, 0.745057785f, 0.669282588f, 0.743007952f, + 0.671558955f, 0.740951125f, 0.673829000f, 0.738887324f, 0.676092704f, + 0.736816569f, 0.678350043f, 0.734738878f, 0.680600998f, 0.732654272f, + 0.682845546f, 0.730562769f, 0.685083668f, 0.728464390f, 0.687315341f, + 0.726359155f, 0.689540545f, 0.724247083f, 0.691759258f, 0.722128194f, + 0.693971461f, 0.720002508f, 0.696177131f, 0.717870045f, 0.698376249f, + 0.715730825f, 0.700568794f, 0.713584869f, 0.702754744f, 0.711432196f, + 0.704934080f, 0.709272826f, 0.707106781f, 0.707106781f, 0.709272826f, + 0.704934080f, 0.711432196f, 0.702754744f, 0.713584869f, 0.700568794f, + 0.715730825f, 0.698376249f, 0.717870045f, 0.696177131f, 0.720002508f, + 0.693971461f, 0.722128194f, 0.691759258f, 0.724247083f, 0.689540545f, + 0.726359155f, 0.687315341f, 0.728464390f, 0.685083668f, 0.730562769f, + 0.682845546f, 0.732654272f, 0.680600998f, 0.734738878f, 0.678350043f, + 0.736816569f, 0.676092704f, 0.738887324f, 0.673829000f, 0.740951125f, + 0.671558955f, 0.743007952f, 0.669282588f, 0.745057785f, 0.666999922f, + 0.747100606f, 0.664710978f, 0.749136395f, 0.662415778f, 0.751165132f, + 0.660114342f, 0.753186799f, 0.657806693f, 0.755201377f, 0.655492853f, + 0.757208847f, 0.653172843f, 0.759209189f, 0.650846685f, 0.761202385f, + 0.648514401f, 0.763188417f, 0.646176013f, 0.765167266f, 0.643831543f, + 0.767138912f, 0.641481013f, 0.769103338f, 0.639124445f, 0.771060524f, + 0.636761861f, 0.773010453f, 0.634393284f, 0.774953107f, 0.632018736f, + 0.776888466f, 0.629638239f, 0.778816512f, 0.627251815f, 0.780737229f, + 0.624859488f, 0.782650596f, 0.622461279f, 0.784556597f, 0.620057212f, + 0.786455214f, 0.617647308f, 0.788346428f, 0.615231591f, 0.790230221f, + 0.612810082f, 0.792106577f, 0.610382806f, 0.793975478f, 0.607949785f, + 0.795836905f, 0.605511041f, 0.797690841f, 0.603066599f, 0.799537269f, + 0.600616479f, 0.801376172f, 0.598160707f, 0.803207531f, 0.595699304f, + 0.805031331f, 0.593232295f, 0.806847554f, 0.590759702f, 0.808656182f, + 0.588281548f, 0.810457198f, 0.585797857f, 0.812250587f, 0.583308653f, + 0.814036330f, 0.580813958f, 0.815814411f, 0.578313796f, 0.817584813f, + 0.575808191f, 0.819347520f, 0.573297167f, 0.821102515f, 0.570780746f, + 0.822849781f, 0.568258953f, 0.824589303f, 0.565731811f, 0.826321063f, + 0.563199344f, 0.828045045f, 0.560661576f, 0.829761234f, 0.558118531f, + 0.831469612f, 0.555570233f, 0.833170165f, 0.553016706f, 0.834862875f, + 0.550457973f, 0.836547727f, 0.547894059f, 0.838224706f, 0.545324988f, + 0.839893794f, 0.542750785f, 0.841554977f, 0.540171473f, 0.843208240f, + 0.537587076f, 0.844853565f, 0.534997620f, 0.846490939f, 0.532403128f, + 0.848120345f, 0.529803625f, 0.849741768f, 0.527199135f, 0.851355193f, + 0.524589683f, 0.852960605f, 0.521975293f, 0.854557988f, 0.519355990f, + 0.856147328f, 0.516731799f, 0.857728610f, 0.514102744f, 0.859301818f, + 0.511468850f, 0.860866939f, 0.508830143f, 0.862423956f, 0.506186645f, + 0.863972856f, 0.503538384f, 0.865513624f, 0.500885383f, 0.867046246f, + 0.498227667f, 0.868570706f, 0.495565262f, 0.870086991f, 0.492898192f, + 0.871595087f, 0.490226483f, 0.873094978f, 0.487550160f, 0.874586652f, + 0.484869248f, 0.876070094f, 0.482183772f, 0.877545290f, 0.479493758f, + 0.879012226f, 0.476799230f, 0.880470889f, 0.474100215f, 0.881921264f, + 0.471396737f, 0.883363339f, 0.468688822f, 0.884797098f, 0.465976496f, + 0.886222530f, 0.463259784f, 0.887639620f, 0.460538711f, 0.889048356f, + 0.457813304f, 0.890448723f, 0.455083587f, 0.891840709f, 0.452349587f, + 0.893224301f, 0.449611330f, 0.894599486f, 0.446868840f, 0.895966250f, + 0.444122145f, 0.897324581f, 0.441371269f, 0.898674466f, 0.438616239f, + 0.900015892f, 0.435857080f, 0.901348847f, 0.433093819f, 0.902673318f, + 0.430326481f, 0.903989293f, 0.427555093f, 0.905296759f, 0.424779681f, + 0.906595705f, 0.422000271f, 0.907886116f, 0.419216888f, 0.909167983f, + 0.416429560f, 0.910441292f, 0.413638312f, 0.911706032f, 0.410843171f, + 0.912962190f, 0.408044163f, 0.914209756f, 0.405241314f, 0.915448716f, + 0.402434651f, 0.916679060f, 0.399624200f, 0.917900776f, 0.396809987f, + 0.919113852f, 0.393992040f, 0.920318277f, 0.391170384f, 0.921514039f, + 0.388345047f, 0.922701128f, 0.385516054f, 0.923879533f, 0.382683432f, + 0.925049241f, 0.379847209f, 0.926210242f, 0.377007410f, 0.927362526f, + 0.374164063f, 0.928506080f, 0.371317194f, 0.929640896f, 0.368466830f, + 0.930766961f, 0.365612998f, 0.931884266f, 0.362755724f, 0.932992799f, + 0.359895037f, 0.934092550f, 0.357030961f, 0.935183510f, 0.354163525f, + 0.936265667f, 0.351292756f, 0.937339012f, 0.348418680f, 0.938403534f, + 0.345541325f, 0.939459224f, 0.342660717f, 0.940506071f, 0.339776884f, + 0.941544065f, 0.336889853f, 0.942573198f, 0.333999651f, 0.943593458f, + 0.331106306f, 0.944604837f, 0.328209844f, 0.945607325f, 0.325310292f, + 0.946600913f, 0.322407679f, 0.947585591f, 0.319502031f, 0.948561350f, + 0.316593376f, 0.949528181f, 0.313681740f, 0.950486074f, 0.310767153f, + 0.951435021f, 0.307849640f, 0.952375013f, 0.304929230f, 0.953306040f, + 0.302005949f, 0.954228095f, 0.299079826f, 0.955141168f, 0.296150888f, + 0.956045251f, 0.293219163f, 0.956940336f, 0.290284677f, 0.957826413f, + 0.287347460f, 0.958703475f, 0.284407537f, 0.959571513f, 0.281464938f, + 0.960430519f, 0.278519689f, 0.961280486f, 0.275571819f, 0.962121404f, + 0.272621355f, 0.962953267f, 0.269668326f, 0.963776066f, 0.266712757f, + 0.964589793f, 0.263754679f, 0.965394442f, 0.260794118f, 0.966190003f, + 0.257831102f, 0.966976471f, 0.254865660f, 0.967753837f, 0.251897818f, + 0.968522094f, 0.248927606f, 0.969281235f, 0.245955050f, 0.970031253f, + 0.242980180f, 0.970772141f, 0.240003022f, 0.971503891f, 0.237023606f, + 0.972226497f, 0.234041959f, 0.972939952f, 0.231058108f, 0.973644250f, + 0.228072083f, 0.974339383f, 0.225083911f, 0.975025345f, 0.222093621f, + 0.975702130f, 0.219101240f, 0.976369731f, 0.216106797f, 0.977028143f, + 0.213110320f, 0.977677358f, 0.210111837f, 0.978317371f, 0.207111376f, + 0.978948175f, 0.204108966f, 0.979569766f, 0.201104635f, 0.980182136f, + 0.198098411f, 0.980785280f, 0.195090322f, 0.981379193f, 0.192080397f, + 0.981963869f, 0.189068664f, 0.982539302f, 0.186055152f, 0.983105487f, + 0.183039888f, 0.983662419f, 0.180022901f, 0.984210092f, 0.177004220f, + 0.984748502f, 0.173983873f, 0.985277642f, 0.170961889f, 0.985797509f, + 0.167938295f, 0.986308097f, 0.164913120f, 0.986809402f, 0.161886394f, + 0.987301418f, 0.158858143f, 0.987784142f, 0.155828398f, 0.988257568f, + 0.152797185f, 0.988721692f, 0.149764535f, 0.989176510f, 0.146730474f, + 0.989622017f, 0.143695033f, 0.990058210f, 0.140658239f, 0.990485084f, + 0.137620122f, 0.990902635f, 0.134580709f, 0.991310860f, 0.131540029f, + 0.991709754f, 0.128498111f, 0.992099313f, 0.125454983f, 0.992479535f, + 0.122410675f, 0.992850414f, 0.119365215f, 0.993211949f, 0.116318631f, + 0.993564136f, 0.113270952f, 0.993906970f, 0.110222207f, 0.994240449f, + 0.107172425f, 0.994564571f, 0.104121634f, 0.994879331f, 0.101069863f, + 0.995184727f, 0.098017140f, 0.995480755f, 0.094963495f, 0.995767414f, + 0.091908956f, 0.996044701f, 0.088853553f, 0.996312612f, 0.085797312f, + 0.996571146f, 0.082740265f, 0.996820299f, 0.079682438f, 0.997060070f, + 0.076623861f, 0.997290457f, 0.073564564f, 0.997511456f, 0.070504573f, + 0.997723067f, 0.067443920f, 0.997925286f, 0.064382631f, 0.998118113f, + 0.061320736f, 0.998301545f, 0.058258265f, 0.998475581f, 0.055195244f, + 0.998640218f, 0.052131705f, 0.998795456f, 0.049067674f, 0.998941293f, + 0.046003182f, 0.999077728f, 0.042938257f, 0.999204759f, 0.039872928f, + 0.999322385f, 0.036807223f, 0.999430605f, 0.033741172f, 0.999529418f, + 0.030674803f, 0.999618822f, 0.027608146f, 0.999698819f, 0.024541229f, + 0.999769405f, 0.021474080f, 0.999830582f, 0.018406730f, 0.999882347f, + 0.015339206f, 0.999924702f, 0.012271538f, 0.999957645f, 0.009203755f, + 0.999981175f, 0.006135885f, 0.999995294f, 0.003067957f, 1.000000000f, + 0.000000000f, 0.999995294f, -0.003067957f, 0.999981175f, -0.006135885f, + 0.999957645f, -0.009203755f, 0.999924702f, -0.012271538f, 0.999882347f, + -0.015339206f, 0.999830582f, -0.018406730f, 0.999769405f, -0.021474080f, + 0.999698819f, -0.024541229f, 0.999618822f, -0.027608146f, 0.999529418f, + -0.030674803f, 0.999430605f, -0.033741172f, 0.999322385f, -0.036807223f, + 0.999204759f, -0.039872928f, 0.999077728f, -0.042938257f, 0.998941293f, + -0.046003182f, 0.998795456f, -0.049067674f, 0.998640218f, -0.052131705f, + 0.998475581f, -0.055195244f, 0.998301545f, -0.058258265f, 0.998118113f, + -0.061320736f, 0.997925286f, -0.064382631f, 0.997723067f, -0.067443920f, + 0.997511456f, -0.070504573f, 0.997290457f, -0.073564564f, 0.997060070f, + -0.076623861f, 0.996820299f, -0.079682438f, 0.996571146f, -0.082740265f, + 0.996312612f, -0.085797312f, 0.996044701f, -0.088853553f, 0.995767414f, + -0.091908956f, 0.995480755f, -0.094963495f, 0.995184727f, -0.098017140f, + 0.994879331f, -0.101069863f, 0.994564571f, -0.104121634f, 0.994240449f, + -0.107172425f, 0.993906970f, -0.110222207f, 0.993564136f, -0.113270952f, + 0.993211949f, -0.116318631f, 0.992850414f, -0.119365215f, 0.992479535f, + -0.122410675f, 0.992099313f, -0.125454983f, 0.991709754f, -0.128498111f, + 0.991310860f, -0.131540029f, 0.990902635f, -0.134580709f, 0.990485084f, + -0.137620122f, 0.990058210f, -0.140658239f, 0.989622017f, -0.143695033f, + 0.989176510f, -0.146730474f, 0.988721692f, -0.149764535f, 0.988257568f, + -0.152797185f, 0.987784142f, -0.155828398f, 0.987301418f, -0.158858143f, + 0.986809402f, -0.161886394f, 0.986308097f, -0.164913120f, 0.985797509f, + -0.167938295f, 0.985277642f, -0.170961889f, 0.984748502f, -0.173983873f, + 0.984210092f, -0.177004220f, 0.983662419f, -0.180022901f, 0.983105487f, + -0.183039888f, 0.982539302f, -0.186055152f, 0.981963869f, -0.189068664f, + 0.981379193f, -0.192080397f, 0.980785280f, -0.195090322f, 0.980182136f, + -0.198098411f, 0.979569766f, -0.201104635f, 0.978948175f, -0.204108966f, + 0.978317371f, -0.207111376f, 0.977677358f, -0.210111837f, 0.977028143f, + -0.213110320f, 0.976369731f, -0.216106797f, 0.975702130f, -0.219101240f, + 0.975025345f, -0.222093621f, 0.974339383f, -0.225083911f, 0.973644250f, + -0.228072083f, 0.972939952f, -0.231058108f, 0.972226497f, -0.234041959f, + 0.971503891f, -0.237023606f, 0.970772141f, -0.240003022f, 0.970031253f, + -0.242980180f, 0.969281235f, -0.245955050f, 0.968522094f, -0.248927606f, + 0.967753837f, -0.251897818f, 0.966976471f, -0.254865660f, 0.966190003f, + -0.257831102f, 0.965394442f, -0.260794118f, 0.964589793f, -0.263754679f, + 0.963776066f, -0.266712757f, 0.962953267f, -0.269668326f, 0.962121404f, + -0.272621355f, 0.961280486f, -0.275571819f, 0.960430519f, -0.278519689f, + 0.959571513f, -0.281464938f, 0.958703475f, -0.284407537f, 0.957826413f, + -0.287347460f, 0.956940336f, -0.290284677f, 0.956045251f, -0.293219163f, + 0.955141168f, -0.296150888f, 0.954228095f, -0.299079826f, 0.953306040f, + -0.302005949f, 0.952375013f, -0.304929230f, 0.951435021f, -0.307849640f, + 0.950486074f, -0.310767153f, 0.949528181f, -0.313681740f, 0.948561350f, + -0.316593376f, 0.947585591f, -0.319502031f, 0.946600913f, -0.322407679f, + 0.945607325f, -0.325310292f, 0.944604837f, -0.328209844f, 0.943593458f, + -0.331106306f, 0.942573198f, -0.333999651f, 0.941544065f, -0.336889853f, + 0.940506071f, -0.339776884f, 0.939459224f, -0.342660717f, 0.938403534f, + -0.345541325f, 0.937339012f, -0.348418680f, 0.936265667f, -0.351292756f, + 0.935183510f, -0.354163525f, 0.934092550f, -0.357030961f, 0.932992799f, + -0.359895037f, 0.931884266f, -0.362755724f, 0.930766961f, -0.365612998f, + 0.929640896f, -0.368466830f, 0.928506080f, -0.371317194f, 0.927362526f, + -0.374164063f, 0.926210242f, -0.377007410f, 0.925049241f, -0.379847209f, + 0.923879533f, -0.382683432f, 0.922701128f, -0.385516054f, 0.921514039f, + -0.388345047f, 0.920318277f, -0.391170384f, 0.919113852f, -0.393992040f, + 0.917900776f, -0.396809987f, 0.916679060f, -0.399624200f, 0.915448716f, + -0.402434651f, 0.914209756f, -0.405241314f, 0.912962190f, -0.408044163f, + 0.911706032f, -0.410843171f, 0.910441292f, -0.413638312f, 0.909167983f, + -0.416429560f, 0.907886116f, -0.419216888f, 0.906595705f, -0.422000271f, + 0.905296759f, -0.424779681f, 0.903989293f, -0.427555093f, 0.902673318f, + -0.430326481f, 0.901348847f, -0.433093819f, 0.900015892f, -0.435857080f, + 0.898674466f, -0.438616239f, 0.897324581f, -0.441371269f, 0.895966250f, + -0.444122145f, 0.894599486f, -0.446868840f, 0.893224301f, -0.449611330f, + 0.891840709f, -0.452349587f, 0.890448723f, -0.455083587f, 0.889048356f, + -0.457813304f, 0.887639620f, -0.460538711f, 0.886222530f, -0.463259784f, + 0.884797098f, -0.465976496f, 0.883363339f, -0.468688822f, 0.881921264f, + -0.471396737f, 0.880470889f, -0.474100215f, 0.879012226f, -0.476799230f, + 0.877545290f, -0.479493758f, 0.876070094f, -0.482183772f, 0.874586652f, + -0.484869248f, 0.873094978f, -0.487550160f, 0.871595087f, -0.490226483f, + 0.870086991f, -0.492898192f, 0.868570706f, -0.495565262f, 0.867046246f, + -0.498227667f, 0.865513624f, -0.500885383f, 0.863972856f, -0.503538384f, + 0.862423956f, -0.506186645f, 0.860866939f, -0.508830143f, 0.859301818f, + -0.511468850f, 0.857728610f, -0.514102744f, 0.856147328f, -0.516731799f, + 0.854557988f, -0.519355990f, 0.852960605f, -0.521975293f, 0.851355193f, + -0.524589683f, 0.849741768f, -0.527199135f, 0.848120345f, -0.529803625f, + 0.846490939f, -0.532403128f, 0.844853565f, -0.534997620f, 0.843208240f, + -0.537587076f, 0.841554977f, -0.540171473f, 0.839893794f, -0.542750785f, + 0.838224706f, -0.545324988f, 0.836547727f, -0.547894059f, 0.834862875f, + -0.550457973f, 0.833170165f, -0.553016706f, 0.831469612f, -0.555570233f, + 0.829761234f, -0.558118531f, 0.828045045f, -0.560661576f, 0.826321063f, + -0.563199344f, 0.824589303f, -0.565731811f, 0.822849781f, -0.568258953f, + 0.821102515f, -0.570780746f, 0.819347520f, -0.573297167f, 0.817584813f, + -0.575808191f, 0.815814411f, -0.578313796f, 0.814036330f, -0.580813958f, + 0.812250587f, -0.583308653f, 0.810457198f, -0.585797857f, 0.808656182f, + -0.588281548f, 0.806847554f, -0.590759702f, 0.805031331f, -0.593232295f, + 0.803207531f, -0.595699304f, 0.801376172f, -0.598160707f, 0.799537269f, + -0.600616479f, 0.797690841f, -0.603066599f, 0.795836905f, -0.605511041f, + 0.793975478f, -0.607949785f, 0.792106577f, -0.610382806f, 0.790230221f, + -0.612810082f, 0.788346428f, -0.615231591f, 0.786455214f, -0.617647308f, + 0.784556597f, -0.620057212f, 0.782650596f, -0.622461279f, 0.780737229f, + -0.624859488f, 0.778816512f, -0.627251815f, 0.776888466f, -0.629638239f, + 0.774953107f, -0.632018736f, 0.773010453f, -0.634393284f, 0.771060524f, + -0.636761861f, 0.769103338f, -0.639124445f, 0.767138912f, -0.641481013f, + 0.765167266f, -0.643831543f, 0.763188417f, -0.646176013f, 0.761202385f, + -0.648514401f, 0.759209189f, -0.650846685f, 0.757208847f, -0.653172843f, + 0.755201377f, -0.655492853f, 0.753186799f, -0.657806693f, 0.751165132f, + -0.660114342f, 0.749136395f, -0.662415778f, 0.747100606f, -0.664710978f, + 0.745057785f, -0.666999922f, 0.743007952f, -0.669282588f, 0.740951125f, + -0.671558955f, 0.738887324f, -0.673829000f, 0.736816569f, -0.676092704f, + 0.734738878f, -0.678350043f, 0.732654272f, -0.680600998f, 0.730562769f, + -0.682845546f, 0.728464390f, -0.685083668f, 0.726359155f, -0.687315341f, + 0.724247083f, -0.689540545f, 0.722128194f, -0.691759258f, 0.720002508f, + -0.693971461f, 0.717870045f, -0.696177131f, 0.715730825f, -0.698376249f, + 0.713584869f, -0.700568794f, 0.711432196f, -0.702754744f, 0.709272826f, + -0.704934080f, 0.707106781f, -0.707106781f, 0.704934080f, -0.709272826f, + 0.702754744f, -0.711432196f, 0.700568794f, -0.713584869f, 0.698376249f, + -0.715730825f, 0.696177131f, -0.717870045f, 0.693971461f, -0.720002508f, + 0.691759258f, -0.722128194f, 0.689540545f, -0.724247083f, 0.687315341f, + -0.726359155f, 0.685083668f, -0.728464390f, 0.682845546f, -0.730562769f, + 0.680600998f, -0.732654272f, 0.678350043f, -0.734738878f, 0.676092704f, + -0.736816569f, 0.673829000f, -0.738887324f, 0.671558955f, -0.740951125f, + 0.669282588f, -0.743007952f, 0.666999922f, -0.745057785f, 0.664710978f, + -0.747100606f, 0.662415778f, -0.749136395f, 0.660114342f, -0.751165132f, + 0.657806693f, -0.753186799f, 0.655492853f, -0.755201377f, 0.653172843f, + -0.757208847f, 0.650846685f, -0.759209189f, 0.648514401f, -0.761202385f, + 0.646176013f, -0.763188417f, 0.643831543f, -0.765167266f, 0.641481013f, + -0.767138912f, 0.639124445f, -0.769103338f, 0.636761861f, -0.771060524f, + 0.634393284f, -0.773010453f, 0.632018736f, -0.774953107f, 0.629638239f, + -0.776888466f, 0.627251815f, -0.778816512f, 0.624859488f, -0.780737229f, + 0.622461279f, -0.782650596f, 0.620057212f, -0.784556597f, 0.617647308f, + -0.786455214f, 0.615231591f, -0.788346428f, 0.612810082f, -0.790230221f, + 0.610382806f, -0.792106577f, 0.607949785f, -0.793975478f, 0.605511041f, + -0.795836905f, 0.603066599f, -0.797690841f, 0.600616479f, -0.799537269f, + 0.598160707f, -0.801376172f, 0.595699304f, -0.803207531f, 0.593232295f, + -0.805031331f, 0.590759702f, -0.806847554f, 0.588281548f, -0.808656182f, + 0.585797857f, -0.810457198f, 0.583308653f, -0.812250587f, 0.580813958f, + -0.814036330f, 0.578313796f, -0.815814411f, 0.575808191f, -0.817584813f, + 0.573297167f, -0.819347520f, 0.570780746f, -0.821102515f, 0.568258953f, + -0.822849781f, 0.565731811f, -0.824589303f, 0.563199344f, -0.826321063f, + 0.560661576f, -0.828045045f, 0.558118531f, -0.829761234f, 0.555570233f, + -0.831469612f, 0.553016706f, -0.833170165f, 0.550457973f, -0.834862875f, + 0.547894059f, -0.836547727f, 0.545324988f, -0.838224706f, 0.542750785f, + -0.839893794f, 0.540171473f, -0.841554977f, 0.537587076f, -0.843208240f, + 0.534997620f, -0.844853565f, 0.532403128f, -0.846490939f, 0.529803625f, + -0.848120345f, 0.527199135f, -0.849741768f, 0.524589683f, -0.851355193f, + 0.521975293f, -0.852960605f, 0.519355990f, -0.854557988f, 0.516731799f, + -0.856147328f, 0.514102744f, -0.857728610f, 0.511468850f, -0.859301818f, + 0.508830143f, -0.860866939f, 0.506186645f, -0.862423956f, 0.503538384f, + -0.863972856f, 0.500885383f, -0.865513624f, 0.498227667f, -0.867046246f, + 0.495565262f, -0.868570706f, 0.492898192f, -0.870086991f, 0.490226483f, + -0.871595087f, 0.487550160f, -0.873094978f, 0.484869248f, -0.874586652f, + 0.482183772f, -0.876070094f, 0.479493758f, -0.877545290f, 0.476799230f, + -0.879012226f, 0.474100215f, -0.880470889f, 0.471396737f, -0.881921264f, + 0.468688822f, -0.883363339f, 0.465976496f, -0.884797098f, 0.463259784f, + -0.886222530f, 0.460538711f, -0.887639620f, 0.457813304f, -0.889048356f, + 0.455083587f, -0.890448723f, 0.452349587f, -0.891840709f, 0.449611330f, + -0.893224301f, 0.446868840f, -0.894599486f, 0.444122145f, -0.895966250f, + 0.441371269f, -0.897324581f, 0.438616239f, -0.898674466f, 0.435857080f, + -0.900015892f, 0.433093819f, -0.901348847f, 0.430326481f, -0.902673318f, + 0.427555093f, -0.903989293f, 0.424779681f, -0.905296759f, 0.422000271f, + -0.906595705f, 0.419216888f, -0.907886116f, 0.416429560f, -0.909167983f, + 0.413638312f, -0.910441292f, 0.410843171f, -0.911706032f, 0.408044163f, + -0.912962190f, 0.405241314f, -0.914209756f, 0.402434651f, -0.915448716f, + 0.399624200f, -0.916679060f, 0.396809987f, -0.917900776f, 0.393992040f, + -0.919113852f, 0.391170384f, -0.920318277f, 0.388345047f, -0.921514039f, + 0.385516054f, -0.922701128f, 0.382683432f, -0.923879533f, 0.379847209f, + -0.925049241f, 0.377007410f, -0.926210242f, 0.374164063f, -0.927362526f, + 0.371317194f, -0.928506080f, 0.368466830f, -0.929640896f, 0.365612998f, + -0.930766961f, 0.362755724f, -0.931884266f, 0.359895037f, -0.932992799f, + 0.357030961f, -0.934092550f, 0.354163525f, -0.935183510f, 0.351292756f, + -0.936265667f, 0.348418680f, -0.937339012f, 0.345541325f, -0.938403534f, + 0.342660717f, -0.939459224f, 0.339776884f, -0.940506071f, 0.336889853f, + -0.941544065f, 0.333999651f, -0.942573198f, 0.331106306f, -0.943593458f, + 0.328209844f, -0.944604837f, 0.325310292f, -0.945607325f, 0.322407679f, + -0.946600913f, 0.319502031f, -0.947585591f, 0.316593376f, -0.948561350f, + 0.313681740f, -0.949528181f, 0.310767153f, -0.950486074f, 0.307849640f, + -0.951435021f, 0.304929230f, -0.952375013f, 0.302005949f, -0.953306040f, + 0.299079826f, -0.954228095f, 0.296150888f, -0.955141168f, 0.293219163f, + -0.956045251f, 0.290284677f, -0.956940336f, 0.287347460f, -0.957826413f, + 0.284407537f, -0.958703475f, 0.281464938f, -0.959571513f, 0.278519689f, + -0.960430519f, 0.275571819f, -0.961280486f, 0.272621355f, -0.962121404f, + 0.269668326f, -0.962953267f, 0.266712757f, -0.963776066f, 0.263754679f, + -0.964589793f, 0.260794118f, -0.965394442f, 0.257831102f, -0.966190003f, + 0.254865660f, -0.966976471f, 0.251897818f, -0.967753837f, 0.248927606f, + -0.968522094f, 0.245955050f, -0.969281235f, 0.242980180f, -0.970031253f, + 0.240003022f, -0.970772141f, 0.237023606f, -0.971503891f, 0.234041959f, + -0.972226497f, 0.231058108f, -0.972939952f, 0.228072083f, -0.973644250f, + 0.225083911f, -0.974339383f, 0.222093621f, -0.975025345f, 0.219101240f, + -0.975702130f, 0.216106797f, -0.976369731f, 0.213110320f, -0.977028143f, + 0.210111837f, -0.977677358f, 0.207111376f, -0.978317371f, 0.204108966f, + -0.978948175f, 0.201104635f, -0.979569766f, 0.198098411f, -0.980182136f, + 0.195090322f, -0.980785280f, 0.192080397f, -0.981379193f, 0.189068664f, + -0.981963869f, 0.186055152f, -0.982539302f, 0.183039888f, -0.983105487f, + 0.180022901f, -0.983662419f, 0.177004220f, -0.984210092f, 0.173983873f, + -0.984748502f, 0.170961889f, -0.985277642f, 0.167938295f, -0.985797509f, + 0.164913120f, -0.986308097f, 0.161886394f, -0.986809402f, 0.158858143f, + -0.987301418f, 0.155828398f, -0.987784142f, 0.152797185f, -0.988257568f, + 0.149764535f, -0.988721692f, 0.146730474f, -0.989176510f, 0.143695033f, + -0.989622017f, 0.140658239f, -0.990058210f, 0.137620122f, -0.990485084f, + 0.134580709f, -0.990902635f, 0.131540029f, -0.991310860f, 0.128498111f, + -0.991709754f, 0.125454983f, -0.992099313f, 0.122410675f, -0.992479535f, + 0.119365215f, -0.992850414f, 0.116318631f, -0.993211949f, 0.113270952f, + -0.993564136f, 0.110222207f, -0.993906970f, 0.107172425f, -0.994240449f, + 0.104121634f, -0.994564571f, 0.101069863f, -0.994879331f, 0.098017140f, + -0.995184727f, 0.094963495f, -0.995480755f, 0.091908956f, -0.995767414f, + 0.088853553f, -0.996044701f, 0.085797312f, -0.996312612f, 0.082740265f, + -0.996571146f, 0.079682438f, -0.996820299f, 0.076623861f, -0.997060070f, + 0.073564564f, -0.997290457f, 0.070504573f, -0.997511456f, 0.067443920f, + -0.997723067f, 0.064382631f, -0.997925286f, 0.061320736f, -0.998118113f, + 0.058258265f, -0.998301545f, 0.055195244f, -0.998475581f, 0.052131705f, + -0.998640218f, 0.049067674f, -0.998795456f, 0.046003182f, -0.998941293f, + 0.042938257f, -0.999077728f, 0.039872928f, -0.999204759f, 0.036807223f, + -0.999322385f, 0.033741172f, -0.999430605f, 0.030674803f, -0.999529418f, + 0.027608146f, -0.999618822f, 0.024541229f, -0.999698819f, 0.021474080f, + -0.999769405f, 0.018406730f, -0.999830582f, 0.015339206f, -0.999882347f, + 0.012271538f, -0.999924702f, 0.009203755f, -0.999957645f, 0.006135885f, + -0.999981175f, 0.003067957f, -0.999995294f}; const float32_t twiddleCoef_rfft_4096[4096] = { - 0.000000000f, 1.000000000f, - 0.001533980f, 0.999998823f, - 0.003067957f, 0.999995294f, - 0.004601926f, 0.999989411f, - 0.006135885f, 0.999981175f, - 0.007669829f, 0.999970586f, - 0.009203755f, 0.999957645f, - 0.010737659f, 0.999942350f, - 0.012271538f, 0.999924702f, - 0.013805389f, 0.999904701f, - 0.015339206f, 0.999882347f, - 0.016872988f, 0.999857641f, - 0.018406730f, 0.999830582f, - 0.019940429f, 0.999801170f, - 0.021474080f, 0.999769405f, - 0.023007681f, 0.999735288f, - 0.024541229f, 0.999698819f, - 0.026074718f, 0.999659997f, - 0.027608146f, 0.999618822f, - 0.029141509f, 0.999575296f, - 0.030674803f, 0.999529418f, - 0.032208025f, 0.999481187f, - 0.033741172f, 0.999430605f, - 0.035274239f, 0.999377670f, - 0.036807223f, 0.999322385f, - 0.038340120f, 0.999264747f, - 0.039872928f, 0.999204759f, - 0.041405641f, 0.999142419f, - 0.042938257f, 0.999077728f, - 0.044470772f, 0.999010686f, - 0.046003182f, 0.998941293f, - 0.047535484f, 0.998869550f, - 0.049067674f, 0.998795456f, - 0.050599749f, 0.998719012f, - 0.052131705f, 0.998640218f, - 0.053663538f, 0.998559074f, - 0.055195244f, 0.998475581f, - 0.056726821f, 0.998389737f, - 0.058258265f, 0.998301545f, - 0.059789571f, 0.998211003f, - 0.061320736f, 0.998118113f, - 0.062851758f, 0.998022874f, - 0.064382631f, 0.997925286f, - 0.065913353f, 0.997825350f, - 0.067443920f, 0.997723067f, - 0.068974328f, 0.997618435f, - 0.070504573f, 0.997511456f, - 0.072034653f, 0.997402130f, - 0.073564564f, 0.997290457f, - 0.075094301f, 0.997176437f, - 0.076623861f, 0.997060070f, - 0.078153242f, 0.996941358f, - 0.079682438f, 0.996820299f, - 0.081211447f, 0.996696895f, - 0.082740265f, 0.996571146f, - 0.084268888f, 0.996443051f, - 0.085797312f, 0.996312612f, - 0.087325535f, 0.996179829f, - 0.088853553f, 0.996044701f, - 0.090381361f, 0.995907229f, - 0.091908956f, 0.995767414f, - 0.093436336f, 0.995625256f, - 0.094963495f, 0.995480755f, - 0.096490431f, 0.995333912f, - 0.098017140f, 0.995184727f, - 0.099543619f, 0.995033199f, - 0.101069863f, 0.994879331f, - 0.102595869f, 0.994723121f, - 0.104121634f, 0.994564571f, - 0.105647154f, 0.994403680f, - 0.107172425f, 0.994240449f, - 0.108697444f, 0.994074879f, - 0.110222207f, 0.993906970f, - 0.111746711f, 0.993736722f, - 0.113270952f, 0.993564136f, - 0.114794927f, 0.993389211f, - 0.116318631f, 0.993211949f, - 0.117842062f, 0.993032350f, - 0.119365215f, 0.992850414f, - 0.120888087f, 0.992666142f, - 0.122410675f, 0.992479535f, - 0.123932975f, 0.992290591f, - 0.125454983f, 0.992099313f, - 0.126976696f, 0.991905700f, - 0.128498111f, 0.991709754f, - 0.130019223f, 0.991511473f, - 0.131540029f, 0.991310860f, - 0.133060525f, 0.991107914f, - 0.134580709f, 0.990902635f, - 0.136100575f, 0.990695025f, - 0.137620122f, 0.990485084f, - 0.139139344f, 0.990272812f, - 0.140658239f, 0.990058210f, - 0.142176804f, 0.989841278f, - 0.143695033f, 0.989622017f, - 0.145212925f, 0.989400428f, - 0.146730474f, 0.989176510f, - 0.148247679f, 0.988950265f, - 0.149764535f, 0.988721692f, - 0.151281038f, 0.988490793f, - 0.152797185f, 0.988257568f, - 0.154312973f, 0.988022017f, - 0.155828398f, 0.987784142f, - 0.157343456f, 0.987543942f, - 0.158858143f, 0.987301418f, - 0.160372457f, 0.987056571f, - 0.161886394f, 0.986809402f, - 0.163399949f, 0.986559910f, - 0.164913120f, 0.986308097f, - 0.166425904f, 0.986053963f, - 0.167938295f, 0.985797509f, - 0.169450291f, 0.985538735f, - 0.170961889f, 0.985277642f, - 0.172473084f, 0.985014231f, - 0.173983873f, 0.984748502f, - 0.175494253f, 0.984480455f, - 0.177004220f, 0.984210092f, - 0.178513771f, 0.983937413f, - 0.180022901f, 0.983662419f, - 0.181531608f, 0.983385110f, - 0.183039888f, 0.983105487f, - 0.184547737f, 0.982823551f, - 0.186055152f, 0.982539302f, - 0.187562129f, 0.982252741f, - 0.189068664f, 0.981963869f, - 0.190574755f, 0.981672686f, - 0.192080397f, 0.981379193f, - 0.193585587f, 0.981083391f, - 0.195090322f, 0.980785280f, - 0.196594598f, 0.980484862f, - 0.198098411f, 0.980182136f, - 0.199601758f, 0.979877104f, - 0.201104635f, 0.979569766f, - 0.202607039f, 0.979260123f, - 0.204108966f, 0.978948175f, - 0.205610413f, 0.978633924f, - 0.207111376f, 0.978317371f, - 0.208611852f, 0.977998515f, - 0.210111837f, 0.977677358f, - 0.211611327f, 0.977353900f, - 0.213110320f, 0.977028143f, - 0.214608811f, 0.976700086f, - 0.216106797f, 0.976369731f, - 0.217604275f, 0.976037079f, - 0.219101240f, 0.975702130f, - 0.220597690f, 0.975364885f, - 0.222093621f, 0.975025345f, - 0.223589029f, 0.974683511f, - 0.225083911f, 0.974339383f, - 0.226578264f, 0.973992962f, - 0.228072083f, 0.973644250f, - 0.229565366f, 0.973293246f, - 0.231058108f, 0.972939952f, - 0.232550307f, 0.972584369f, - 0.234041959f, 0.972226497f, - 0.235533059f, 0.971866337f, - 0.237023606f, 0.971503891f, - 0.238513595f, 0.971139158f, - 0.240003022f, 0.970772141f, - 0.241491885f, 0.970402839f, - 0.242980180f, 0.970031253f, - 0.244467903f, 0.969657385f, - 0.245955050f, 0.969281235f, - 0.247441619f, 0.968902805f, - 0.248927606f, 0.968522094f, - 0.250413007f, 0.968139105f, - 0.251897818f, 0.967753837f, - 0.253382037f, 0.967366292f, - 0.254865660f, 0.966976471f, - 0.256348682f, 0.966584374f, - 0.257831102f, 0.966190003f, - 0.259312915f, 0.965793359f, - 0.260794118f, 0.965394442f, - 0.262274707f, 0.964993253f, - 0.263754679f, 0.964589793f, - 0.265234030f, 0.964184064f, - 0.266712757f, 0.963776066f, - 0.268190857f, 0.963365800f, - 0.269668326f, 0.962953267f, - 0.271145160f, 0.962538468f, - 0.272621355f, 0.962121404f, - 0.274096910f, 0.961702077f, - 0.275571819f, 0.961280486f, - 0.277046080f, 0.960856633f, - 0.278519689f, 0.960430519f, - 0.279992643f, 0.960002146f, - 0.281464938f, 0.959571513f, - 0.282936570f, 0.959138622f, - 0.284407537f, 0.958703475f, - 0.285877835f, 0.958266071f, - 0.287347460f, 0.957826413f, - 0.288816408f, 0.957384501f, - 0.290284677f, 0.956940336f, - 0.291752263f, 0.956493919f, - 0.293219163f, 0.956045251f, - 0.294685372f, 0.955594334f, - 0.296150888f, 0.955141168f, - 0.297615707f, 0.954685755f, - 0.299079826f, 0.954228095f, - 0.300543241f, 0.953768190f, - 0.302005949f, 0.953306040f, - 0.303467947f, 0.952841648f, - 0.304929230f, 0.952375013f, - 0.306389795f, 0.951906137f, - 0.307849640f, 0.951435021f, - 0.309308760f, 0.950961666f, - 0.310767153f, 0.950486074f, - 0.312224814f, 0.950008245f, - 0.313681740f, 0.949528181f, - 0.315137929f, 0.949045882f, - 0.316593376f, 0.948561350f, - 0.318048077f, 0.948074586f, - 0.319502031f, 0.947585591f, - 0.320955232f, 0.947094366f, - 0.322407679f, 0.946600913f, - 0.323859367f, 0.946105232f, - 0.325310292f, 0.945607325f, - 0.326760452f, 0.945107193f, - 0.328209844f, 0.944604837f, - 0.329658463f, 0.944100258f, - 0.331106306f, 0.943593458f, - 0.332553370f, 0.943084437f, - 0.333999651f, 0.942573198f, - 0.335445147f, 0.942059740f, - 0.336889853f, 0.941544065f, - 0.338333767f, 0.941026175f, - 0.339776884f, 0.940506071f, - 0.341219202f, 0.939983753f, - 0.342660717f, 0.939459224f, - 0.344101426f, 0.938932484f, - 0.345541325f, 0.938403534f, - 0.346980411f, 0.937872376f, - 0.348418680f, 0.937339012f, - 0.349856130f, 0.936803442f, - 0.351292756f, 0.936265667f, - 0.352728556f, 0.935725689f, - 0.354163525f, 0.935183510f, - 0.355597662f, 0.934639130f, - 0.357030961f, 0.934092550f, - 0.358463421f, 0.933543773f, - 0.359895037f, 0.932992799f, - 0.361325806f, 0.932439629f, - 0.362755724f, 0.931884266f, - 0.364184790f, 0.931326709f, - 0.365612998f, 0.930766961f, - 0.367040346f, 0.930205023f, - 0.368466830f, 0.929640896f, - 0.369892447f, 0.929074581f, - 0.371317194f, 0.928506080f, - 0.372741067f, 0.927935395f, - 0.374164063f, 0.927362526f, - 0.375586178f, 0.926787474f, - 0.377007410f, 0.926210242f, - 0.378427755f, 0.925630831f, - 0.379847209f, 0.925049241f, - 0.381265769f, 0.924465474f, - 0.382683432f, 0.923879533f, - 0.384100195f, 0.923291417f, - 0.385516054f, 0.922701128f, - 0.386931006f, 0.922108669f, - 0.388345047f, 0.921514039f, - 0.389758174f, 0.920917242f, - 0.391170384f, 0.920318277f, - 0.392581674f, 0.919717146f, - 0.393992040f, 0.919113852f, - 0.395401479f, 0.918508394f, - 0.396809987f, 0.917900776f, - 0.398217562f, 0.917290997f, - 0.399624200f, 0.916679060f, - 0.401029897f, 0.916064966f, - 0.402434651f, 0.915448716f, - 0.403838458f, 0.914830312f, - 0.405241314f, 0.914209756f, - 0.406643217f, 0.913587048f, - 0.408044163f, 0.912962190f, - 0.409444149f, 0.912335185f, - 0.410843171f, 0.911706032f, - 0.412241227f, 0.911074734f, - 0.413638312f, 0.910441292f, - 0.415034424f, 0.909805708f, - 0.416429560f, 0.909167983f, - 0.417823716f, 0.908528119f, - 0.419216888f, 0.907886116f, - 0.420609074f, 0.907241978f, - 0.422000271f, 0.906595705f, - 0.423390474f, 0.905947298f, - 0.424779681f, 0.905296759f, - 0.426167889f, 0.904644091f, - 0.427555093f, 0.903989293f, - 0.428941292f, 0.903332368f, - 0.430326481f, 0.902673318f, - 0.431710658f, 0.902012144f, - 0.433093819f, 0.901348847f, - 0.434475961f, 0.900683429f, - 0.435857080f, 0.900015892f, - 0.437237174f, 0.899346237f, - 0.438616239f, 0.898674466f, - 0.439994271f, 0.898000580f, - 0.441371269f, 0.897324581f, - 0.442747228f, 0.896646470f, - 0.444122145f, 0.895966250f, - 0.445496017f, 0.895283921f, - 0.446868840f, 0.894599486f, - 0.448240612f, 0.893912945f, - 0.449611330f, 0.893224301f, - 0.450980989f, 0.892533555f, - 0.452349587f, 0.891840709f, - 0.453717121f, 0.891145765f, - 0.455083587f, 0.890448723f, - 0.456448982f, 0.889749586f, - 0.457813304f, 0.889048356f, - 0.459176548f, 0.888345033f, - 0.460538711f, 0.887639620f, - 0.461899791f, 0.886932119f, - 0.463259784f, 0.886222530f, - 0.464618686f, 0.885510856f, - 0.465976496f, 0.884797098f, - 0.467333209f, 0.884081259f, - 0.468688822f, 0.883363339f, - 0.470043332f, 0.882643340f, - 0.471396737f, 0.881921264f, - 0.472749032f, 0.881197113f, - 0.474100215f, 0.880470889f, - 0.475450282f, 0.879742593f, - 0.476799230f, 0.879012226f, - 0.478147056f, 0.878279792f, - 0.479493758f, 0.877545290f, - 0.480839331f, 0.876808724f, - 0.482183772f, 0.876070094f, - 0.483527079f, 0.875329403f, - 0.484869248f, 0.874586652f, - 0.486210276f, 0.873841843f, - 0.487550160f, 0.873094978f, - 0.488888897f, 0.872346059f, - 0.490226483f, 0.871595087f, - 0.491562916f, 0.870842063f, - 0.492898192f, 0.870086991f, - 0.494232309f, 0.869329871f, - 0.495565262f, 0.868570706f, - 0.496897049f, 0.867809497f, - 0.498227667f, 0.867046246f, - 0.499557113f, 0.866280954f, - 0.500885383f, 0.865513624f, - 0.502212474f, 0.864744258f, - 0.503538384f, 0.863972856f, - 0.504863109f, 0.863199422f, - 0.506186645f, 0.862423956f, - 0.507508991f, 0.861646461f, - 0.508830143f, 0.860866939f, - 0.510150097f, 0.860085390f, - 0.511468850f, 0.859301818f, - 0.512786401f, 0.858516224f, - 0.514102744f, 0.857728610f, - 0.515417878f, 0.856938977f, - 0.516731799f, 0.856147328f, - 0.518044504f, 0.855353665f, - 0.519355990f, 0.854557988f, - 0.520666254f, 0.853760301f, - 0.521975293f, 0.852960605f, - 0.523283103f, 0.852158902f, - 0.524589683f, 0.851355193f, - 0.525895027f, 0.850549481f, - 0.527199135f, 0.849741768f, - 0.528502002f, 0.848932055f, - 0.529803625f, 0.848120345f, - 0.531104001f, 0.847306639f, - 0.532403128f, 0.846490939f, - 0.533701002f, 0.845673247f, - 0.534997620f, 0.844853565f, - 0.536292979f, 0.844031895f, - 0.537587076f, 0.843208240f, - 0.538879909f, 0.842382600f, - 0.540171473f, 0.841554977f, - 0.541461766f, 0.840725375f, - 0.542750785f, 0.839893794f, - 0.544038527f, 0.839060237f, - 0.545324988f, 0.838224706f, - 0.546610167f, 0.837387202f, - 0.547894059f, 0.836547727f, - 0.549176662f, 0.835706284f, - 0.550457973f, 0.834862875f, - 0.551737988f, 0.834017501f, - 0.553016706f, 0.833170165f, - 0.554294121f, 0.832320868f, - 0.555570233f, 0.831469612f, - 0.556845037f, 0.830616400f, - 0.558118531f, 0.829761234f, - 0.559390712f, 0.828904115f, - 0.560661576f, 0.828045045f, - 0.561931121f, 0.827184027f, - 0.563199344f, 0.826321063f, - 0.564466242f, 0.825456154f, - 0.565731811f, 0.824589303f, - 0.566996049f, 0.823720511f, - 0.568258953f, 0.822849781f, - 0.569520519f, 0.821977115f, - 0.570780746f, 0.821102515f, - 0.572039629f, 0.820225983f, - 0.573297167f, 0.819347520f, - 0.574553355f, 0.818467130f, - 0.575808191f, 0.817584813f, - 0.577061673f, 0.816700573f, - 0.578313796f, 0.815814411f, - 0.579564559f, 0.814926329f, - 0.580813958f, 0.814036330f, - 0.582061990f, 0.813144415f, - 0.583308653f, 0.812250587f, - 0.584553943f, 0.811354847f, - 0.585797857f, 0.810457198f, - 0.587040394f, 0.809557642f, - 0.588281548f, 0.808656182f, - 0.589521319f, 0.807752818f, - 0.590759702f, 0.806847554f, - 0.591996695f, 0.805940391f, - 0.593232295f, 0.805031331f, - 0.594466499f, 0.804120377f, - 0.595699304f, 0.803207531f, - 0.596930708f, 0.802292796f, - 0.598160707f, 0.801376172f, - 0.599389298f, 0.800457662f, - 0.600616479f, 0.799537269f, - 0.601842247f, 0.798614995f, - 0.603066599f, 0.797690841f, - 0.604289531f, 0.796764810f, - 0.605511041f, 0.795836905f, - 0.606731127f, 0.794907126f, - 0.607949785f, 0.793975478f, - 0.609167012f, 0.793041960f, - 0.610382806f, 0.792106577f, - 0.611597164f, 0.791169330f, - 0.612810082f, 0.790230221f, - 0.614021559f, 0.789289253f, - 0.615231591f, 0.788346428f, - 0.616440175f, 0.787401747f, - 0.617647308f, 0.786455214f, - 0.618852988f, 0.785506830f, - 0.620057212f, 0.784556597f, - 0.621259977f, 0.783604519f, - 0.622461279f, 0.782650596f, - 0.623661118f, 0.781694832f, - 0.624859488f, 0.780737229f, - 0.626056388f, 0.779777788f, - 0.627251815f, 0.778816512f, - 0.628445767f, 0.777853404f, - 0.629638239f, 0.776888466f, - 0.630829230f, 0.775921699f, - 0.632018736f, 0.774953107f, - 0.633206755f, 0.773982691f, - 0.634393284f, 0.773010453f, - 0.635578320f, 0.772036397f, - 0.636761861f, 0.771060524f, - 0.637943904f, 0.770082837f, - 0.639124445f, 0.769103338f, - 0.640303482f, 0.768122029f, - 0.641481013f, 0.767138912f, - 0.642657034f, 0.766153990f, - 0.643831543f, 0.765167266f, - 0.645004537f, 0.764178741f, - 0.646176013f, 0.763188417f, - 0.647345969f, 0.762196298f, - 0.648514401f, 0.761202385f, - 0.649681307f, 0.760206682f, - 0.650846685f, 0.759209189f, - 0.652010531f, 0.758209910f, - 0.653172843f, 0.757208847f, - 0.654333618f, 0.756206001f, - 0.655492853f, 0.755201377f, - 0.656650546f, 0.754194975f, - 0.657806693f, 0.753186799f, - 0.658961293f, 0.752176850f, - 0.660114342f, 0.751165132f, - 0.661265838f, 0.750151646f, - 0.662415778f, 0.749136395f, - 0.663564159f, 0.748119380f, - 0.664710978f, 0.747100606f, - 0.665856234f, 0.746080074f, - 0.666999922f, 0.745057785f, - 0.668142041f, 0.744033744f, - 0.669282588f, 0.743007952f, - 0.670421560f, 0.741980412f, - 0.671558955f, 0.740951125f, - 0.672694769f, 0.739920095f, - 0.673829000f, 0.738887324f, - 0.674961646f, 0.737852815f, - 0.676092704f, 0.736816569f, - 0.677222170f, 0.735778589f, - 0.678350043f, 0.734738878f, - 0.679476320f, 0.733697438f, - 0.680600998f, 0.732654272f, - 0.681724074f, 0.731609381f, - 0.682845546f, 0.730562769f, - 0.683965412f, 0.729514438f, - 0.685083668f, 0.728464390f, - 0.686200312f, 0.727412629f, - 0.687315341f, 0.726359155f, - 0.688428753f, 0.725303972f, - 0.689540545f, 0.724247083f, - 0.690650714f, 0.723188489f, - 0.691759258f, 0.722128194f, - 0.692866175f, 0.721066199f, - 0.693971461f, 0.720002508f, - 0.695075114f, 0.718937122f, - 0.696177131f, 0.717870045f, - 0.697277511f, 0.716801279f, - 0.698376249f, 0.715730825f, - 0.699473345f, 0.714658688f, - 0.700568794f, 0.713584869f, - 0.701662595f, 0.712509371f, - 0.702754744f, 0.711432196f, - 0.703845241f, 0.710353347f, - 0.704934080f, 0.709272826f, - 0.706021261f, 0.708190637f, - 0.707106781f, 0.707106781f, - 0.708190637f, 0.706021261f, - 0.709272826f, 0.704934080f, - 0.710353347f, 0.703845241f, - 0.711432196f, 0.702754744f, - 0.712509371f, 0.701662595f, - 0.713584869f, 0.700568794f, - 0.714658688f, 0.699473345f, - 0.715730825f, 0.698376249f, - 0.716801279f, 0.697277511f, - 0.717870045f, 0.696177131f, - 0.718937122f, 0.695075114f, - 0.720002508f, 0.693971461f, - 0.721066199f, 0.692866175f, - 0.722128194f, 0.691759258f, - 0.723188489f, 0.690650714f, - 0.724247083f, 0.689540545f, - 0.725303972f, 0.688428753f, - 0.726359155f, 0.687315341f, - 0.727412629f, 0.686200312f, - 0.728464390f, 0.685083668f, - 0.729514438f, 0.683965412f, - 0.730562769f, 0.682845546f, - 0.731609381f, 0.681724074f, - 0.732654272f, 0.680600998f, - 0.733697438f, 0.679476320f, - 0.734738878f, 0.678350043f, - 0.735778589f, 0.677222170f, - 0.736816569f, 0.676092704f, - 0.737852815f, 0.674961646f, - 0.738887324f, 0.673829000f, - 0.739920095f, 0.672694769f, - 0.740951125f, 0.671558955f, - 0.741980412f, 0.670421560f, - 0.743007952f, 0.669282588f, - 0.744033744f, 0.668142041f, - 0.745057785f, 0.666999922f, - 0.746080074f, 0.665856234f, - 0.747100606f, 0.664710978f, - 0.748119380f, 0.663564159f, - 0.749136395f, 0.662415778f, - 0.750151646f, 0.661265838f, - 0.751165132f, 0.660114342f, - 0.752176850f, 0.658961293f, - 0.753186799f, 0.657806693f, - 0.754194975f, 0.656650546f, - 0.755201377f, 0.655492853f, - 0.756206001f, 0.654333618f, - 0.757208847f, 0.653172843f, - 0.758209910f, 0.652010531f, - 0.759209189f, 0.650846685f, - 0.760206682f, 0.649681307f, - 0.761202385f, 0.648514401f, - 0.762196298f, 0.647345969f, - 0.763188417f, 0.646176013f, - 0.764178741f, 0.645004537f, - 0.765167266f, 0.643831543f, - 0.766153990f, 0.642657034f, - 0.767138912f, 0.641481013f, - 0.768122029f, 0.640303482f, - 0.769103338f, 0.639124445f, - 0.770082837f, 0.637943904f, - 0.771060524f, 0.636761861f, - 0.772036397f, 0.635578320f, - 0.773010453f, 0.634393284f, - 0.773982691f, 0.633206755f, - 0.774953107f, 0.632018736f, - 0.775921699f, 0.630829230f, - 0.776888466f, 0.629638239f, - 0.777853404f, 0.628445767f, - 0.778816512f, 0.627251815f, - 0.779777788f, 0.626056388f, - 0.780737229f, 0.624859488f, - 0.781694832f, 0.623661118f, - 0.782650596f, 0.622461279f, - 0.783604519f, 0.621259977f, - 0.784556597f, 0.620057212f, - 0.785506830f, 0.618852988f, - 0.786455214f, 0.617647308f, - 0.787401747f, 0.616440175f, - 0.788346428f, 0.615231591f, - 0.789289253f, 0.614021559f, - 0.790230221f, 0.612810082f, - 0.791169330f, 0.611597164f, - 0.792106577f, 0.610382806f, - 0.793041960f, 0.609167012f, - 0.793975478f, 0.607949785f, - 0.794907126f, 0.606731127f, - 0.795836905f, 0.605511041f, - 0.796764810f, 0.604289531f, - 0.797690841f, 0.603066599f, - 0.798614995f, 0.601842247f, - 0.799537269f, 0.600616479f, - 0.800457662f, 0.599389298f, - 0.801376172f, 0.598160707f, - 0.802292796f, 0.596930708f, - 0.803207531f, 0.595699304f, - 0.804120377f, 0.594466499f, - 0.805031331f, 0.593232295f, - 0.805940391f, 0.591996695f, - 0.806847554f, 0.590759702f, - 0.807752818f, 0.589521319f, - 0.808656182f, 0.588281548f, - 0.809557642f, 0.587040394f, - 0.810457198f, 0.585797857f, - 0.811354847f, 0.584553943f, - 0.812250587f, 0.583308653f, - 0.813144415f, 0.582061990f, - 0.814036330f, 0.580813958f, - 0.814926329f, 0.579564559f, - 0.815814411f, 0.578313796f, - 0.816700573f, 0.577061673f, - 0.817584813f, 0.575808191f, - 0.818467130f, 0.574553355f, - 0.819347520f, 0.573297167f, - 0.820225983f, 0.572039629f, - 0.821102515f, 0.570780746f, - 0.821977115f, 0.569520519f, - 0.822849781f, 0.568258953f, - 0.823720511f, 0.566996049f, - 0.824589303f, 0.565731811f, - 0.825456154f, 0.564466242f, - 0.826321063f, 0.563199344f, - 0.827184027f, 0.561931121f, - 0.828045045f, 0.560661576f, - 0.828904115f, 0.559390712f, - 0.829761234f, 0.558118531f, - 0.830616400f, 0.556845037f, - 0.831469612f, 0.555570233f, - 0.832320868f, 0.554294121f, - 0.833170165f, 0.553016706f, - 0.834017501f, 0.551737988f, - 0.834862875f, 0.550457973f, - 0.835706284f, 0.549176662f, - 0.836547727f, 0.547894059f, - 0.837387202f, 0.546610167f, - 0.838224706f, 0.545324988f, - 0.839060237f, 0.544038527f, - 0.839893794f, 0.542750785f, - 0.840725375f, 0.541461766f, - 0.841554977f, 0.540171473f, - 0.842382600f, 0.538879909f, - 0.843208240f, 0.537587076f, - 0.844031895f, 0.536292979f, - 0.844853565f, 0.534997620f, - 0.845673247f, 0.533701002f, - 0.846490939f, 0.532403128f, - 0.847306639f, 0.531104001f, - 0.848120345f, 0.529803625f, - 0.848932055f, 0.528502002f, - 0.849741768f, 0.527199135f, - 0.850549481f, 0.525895027f, - 0.851355193f, 0.524589683f, - 0.852158902f, 0.523283103f, - 0.852960605f, 0.521975293f, - 0.853760301f, 0.520666254f, - 0.854557988f, 0.519355990f, - 0.855353665f, 0.518044504f, - 0.856147328f, 0.516731799f, - 0.856938977f, 0.515417878f, - 0.857728610f, 0.514102744f, - 0.858516224f, 0.512786401f, - 0.859301818f, 0.511468850f, - 0.860085390f, 0.510150097f, - 0.860866939f, 0.508830143f, - 0.861646461f, 0.507508991f, - 0.862423956f, 0.506186645f, - 0.863199422f, 0.504863109f, - 0.863972856f, 0.503538384f, - 0.864744258f, 0.502212474f, - 0.865513624f, 0.500885383f, - 0.866280954f, 0.499557113f, - 0.867046246f, 0.498227667f, - 0.867809497f, 0.496897049f, - 0.868570706f, 0.495565262f, - 0.869329871f, 0.494232309f, - 0.870086991f, 0.492898192f, - 0.870842063f, 0.491562916f, - 0.871595087f, 0.490226483f, - 0.872346059f, 0.488888897f, - 0.873094978f, 0.487550160f, - 0.873841843f, 0.486210276f, - 0.874586652f, 0.484869248f, - 0.875329403f, 0.483527079f, - 0.876070094f, 0.482183772f, - 0.876808724f, 0.480839331f, - 0.877545290f, 0.479493758f, - 0.878279792f, 0.478147056f, - 0.879012226f, 0.476799230f, - 0.879742593f, 0.475450282f, - 0.880470889f, 0.474100215f, - 0.881197113f, 0.472749032f, - 0.881921264f, 0.471396737f, - 0.882643340f, 0.470043332f, - 0.883363339f, 0.468688822f, - 0.884081259f, 0.467333209f, - 0.884797098f, 0.465976496f, - 0.885510856f, 0.464618686f, - 0.886222530f, 0.463259784f, - 0.886932119f, 0.461899791f, - 0.887639620f, 0.460538711f, - 0.888345033f, 0.459176548f, - 0.889048356f, 0.457813304f, - 0.889749586f, 0.456448982f, - 0.890448723f, 0.455083587f, - 0.891145765f, 0.453717121f, - 0.891840709f, 0.452349587f, - 0.892533555f, 0.450980989f, - 0.893224301f, 0.449611330f, - 0.893912945f, 0.448240612f, - 0.894599486f, 0.446868840f, - 0.895283921f, 0.445496017f, - 0.895966250f, 0.444122145f, - 0.896646470f, 0.442747228f, - 0.897324581f, 0.441371269f, - 0.898000580f, 0.439994271f, - 0.898674466f, 0.438616239f, - 0.899346237f, 0.437237174f, - 0.900015892f, 0.435857080f, - 0.900683429f, 0.434475961f, - 0.901348847f, 0.433093819f, - 0.902012144f, 0.431710658f, - 0.902673318f, 0.430326481f, - 0.903332368f, 0.428941292f, - 0.903989293f, 0.427555093f, - 0.904644091f, 0.426167889f, - 0.905296759f, 0.424779681f, - 0.905947298f, 0.423390474f, - 0.906595705f, 0.422000271f, - 0.907241978f, 0.420609074f, - 0.907886116f, 0.419216888f, - 0.908528119f, 0.417823716f, - 0.909167983f, 0.416429560f, - 0.909805708f, 0.415034424f, - 0.910441292f, 0.413638312f, - 0.911074734f, 0.412241227f, - 0.911706032f, 0.410843171f, - 0.912335185f, 0.409444149f, - 0.912962190f, 0.408044163f, - 0.913587048f, 0.406643217f, - 0.914209756f, 0.405241314f, - 0.914830312f, 0.403838458f, - 0.915448716f, 0.402434651f, - 0.916064966f, 0.401029897f, - 0.916679060f, 0.399624200f, - 0.917290997f, 0.398217562f, - 0.917900776f, 0.396809987f, - 0.918508394f, 0.395401479f, - 0.919113852f, 0.393992040f, - 0.919717146f, 0.392581674f, - 0.920318277f, 0.391170384f, - 0.920917242f, 0.389758174f, - 0.921514039f, 0.388345047f, - 0.922108669f, 0.386931006f, - 0.922701128f, 0.385516054f, - 0.923291417f, 0.384100195f, - 0.923879533f, 0.382683432f, - 0.924465474f, 0.381265769f, - 0.925049241f, 0.379847209f, - 0.925630831f, 0.378427755f, - 0.926210242f, 0.377007410f, - 0.926787474f, 0.375586178f, - 0.927362526f, 0.374164063f, - 0.927935395f, 0.372741067f, - 0.928506080f, 0.371317194f, - 0.929074581f, 0.369892447f, - 0.929640896f, 0.368466830f, - 0.930205023f, 0.367040346f, - 0.930766961f, 0.365612998f, - 0.931326709f, 0.364184790f, - 0.931884266f, 0.362755724f, - 0.932439629f, 0.361325806f, - 0.932992799f, 0.359895037f, - 0.933543773f, 0.358463421f, - 0.934092550f, 0.357030961f, - 0.934639130f, 0.355597662f, - 0.935183510f, 0.354163525f, - 0.935725689f, 0.352728556f, - 0.936265667f, 0.351292756f, - 0.936803442f, 0.349856130f, - 0.937339012f, 0.348418680f, - 0.937872376f, 0.346980411f, - 0.938403534f, 0.345541325f, - 0.938932484f, 0.344101426f, - 0.939459224f, 0.342660717f, - 0.939983753f, 0.341219202f, - 0.940506071f, 0.339776884f, - 0.941026175f, 0.338333767f, - 0.941544065f, 0.336889853f, - 0.942059740f, 0.335445147f, - 0.942573198f, 0.333999651f, - 0.943084437f, 0.332553370f, - 0.943593458f, 0.331106306f, - 0.944100258f, 0.329658463f, - 0.944604837f, 0.328209844f, - 0.945107193f, 0.326760452f, - 0.945607325f, 0.325310292f, - 0.946105232f, 0.323859367f, - 0.946600913f, 0.322407679f, - 0.947094366f, 0.320955232f, - 0.947585591f, 0.319502031f, - 0.948074586f, 0.318048077f, - 0.948561350f, 0.316593376f, - 0.949045882f, 0.315137929f, - 0.949528181f, 0.313681740f, - 0.950008245f, 0.312224814f, - 0.950486074f, 0.310767153f, - 0.950961666f, 0.309308760f, - 0.951435021f, 0.307849640f, - 0.951906137f, 0.306389795f, - 0.952375013f, 0.304929230f, - 0.952841648f, 0.303467947f, - 0.953306040f, 0.302005949f, - 0.953768190f, 0.300543241f, - 0.954228095f, 0.299079826f, - 0.954685755f, 0.297615707f, - 0.955141168f, 0.296150888f, - 0.955594334f, 0.294685372f, - 0.956045251f, 0.293219163f, - 0.956493919f, 0.291752263f, - 0.956940336f, 0.290284677f, - 0.957384501f, 0.288816408f, - 0.957826413f, 0.287347460f, - 0.958266071f, 0.285877835f, - 0.958703475f, 0.284407537f, - 0.959138622f, 0.282936570f, - 0.959571513f, 0.281464938f, - 0.960002146f, 0.279992643f, - 0.960430519f, 0.278519689f, - 0.960856633f, 0.277046080f, - 0.961280486f, 0.275571819f, - 0.961702077f, 0.274096910f, - 0.962121404f, 0.272621355f, - 0.962538468f, 0.271145160f, - 0.962953267f, 0.269668326f, - 0.963365800f, 0.268190857f, - 0.963776066f, 0.266712757f, - 0.964184064f, 0.265234030f, - 0.964589793f, 0.263754679f, - 0.964993253f, 0.262274707f, - 0.965394442f, 0.260794118f, - 0.965793359f, 0.259312915f, - 0.966190003f, 0.257831102f, - 0.966584374f, 0.256348682f, - 0.966976471f, 0.254865660f, - 0.967366292f, 0.253382037f, - 0.967753837f, 0.251897818f, - 0.968139105f, 0.250413007f, - 0.968522094f, 0.248927606f, - 0.968902805f, 0.247441619f, - 0.969281235f, 0.245955050f, - 0.969657385f, 0.244467903f, - 0.970031253f, 0.242980180f, - 0.970402839f, 0.241491885f, - 0.970772141f, 0.240003022f, - 0.971139158f, 0.238513595f, - 0.971503891f, 0.237023606f, - 0.971866337f, 0.235533059f, - 0.972226497f, 0.234041959f, - 0.972584369f, 0.232550307f, - 0.972939952f, 0.231058108f, - 0.973293246f, 0.229565366f, - 0.973644250f, 0.228072083f, - 0.973992962f, 0.226578264f, - 0.974339383f, 0.225083911f, - 0.974683511f, 0.223589029f, - 0.975025345f, 0.222093621f, - 0.975364885f, 0.220597690f, - 0.975702130f, 0.219101240f, - 0.976037079f, 0.217604275f, - 0.976369731f, 0.216106797f, - 0.976700086f, 0.214608811f, - 0.977028143f, 0.213110320f, - 0.977353900f, 0.211611327f, - 0.977677358f, 0.210111837f, - 0.977998515f, 0.208611852f, - 0.978317371f, 0.207111376f, - 0.978633924f, 0.205610413f, - 0.978948175f, 0.204108966f, - 0.979260123f, 0.202607039f, - 0.979569766f, 0.201104635f, - 0.979877104f, 0.199601758f, - 0.980182136f, 0.198098411f, - 0.980484862f, 0.196594598f, - 0.980785280f, 0.195090322f, - 0.981083391f, 0.193585587f, - 0.981379193f, 0.192080397f, - 0.981672686f, 0.190574755f, - 0.981963869f, 0.189068664f, - 0.982252741f, 0.187562129f, - 0.982539302f, 0.186055152f, - 0.982823551f, 0.184547737f, - 0.983105487f, 0.183039888f, - 0.983385110f, 0.181531608f, - 0.983662419f, 0.180022901f, - 0.983937413f, 0.178513771f, - 0.984210092f, 0.177004220f, - 0.984480455f, 0.175494253f, - 0.984748502f, 0.173983873f, - 0.985014231f, 0.172473084f, - 0.985277642f, 0.170961889f, - 0.985538735f, 0.169450291f, - 0.985797509f, 0.167938295f, - 0.986053963f, 0.166425904f, - 0.986308097f, 0.164913120f, - 0.986559910f, 0.163399949f, - 0.986809402f, 0.161886394f, - 0.987056571f, 0.160372457f, - 0.987301418f, 0.158858143f, - 0.987543942f, 0.157343456f, - 0.987784142f, 0.155828398f, - 0.988022017f, 0.154312973f, - 0.988257568f, 0.152797185f, - 0.988490793f, 0.151281038f, - 0.988721692f, 0.149764535f, - 0.988950265f, 0.148247679f, - 0.989176510f, 0.146730474f, - 0.989400428f, 0.145212925f, - 0.989622017f, 0.143695033f, - 0.989841278f, 0.142176804f, - 0.990058210f, 0.140658239f, - 0.990272812f, 0.139139344f, - 0.990485084f, 0.137620122f, - 0.990695025f, 0.136100575f, - 0.990902635f, 0.134580709f, - 0.991107914f, 0.133060525f, - 0.991310860f, 0.131540029f, - 0.991511473f, 0.130019223f, - 0.991709754f, 0.128498111f, - 0.991905700f, 0.126976696f, - 0.992099313f, 0.125454983f, - 0.992290591f, 0.123932975f, - 0.992479535f, 0.122410675f, - 0.992666142f, 0.120888087f, - 0.992850414f, 0.119365215f, - 0.993032350f, 0.117842062f, - 0.993211949f, 0.116318631f, - 0.993389211f, 0.114794927f, - 0.993564136f, 0.113270952f, - 0.993736722f, 0.111746711f, - 0.993906970f, 0.110222207f, - 0.994074879f, 0.108697444f, - 0.994240449f, 0.107172425f, - 0.994403680f, 0.105647154f, - 0.994564571f, 0.104121634f, - 0.994723121f, 0.102595869f, - 0.994879331f, 0.101069863f, - 0.995033199f, 0.099543619f, - 0.995184727f, 0.098017140f, - 0.995333912f, 0.096490431f, - 0.995480755f, 0.094963495f, - 0.995625256f, 0.093436336f, - 0.995767414f, 0.091908956f, - 0.995907229f, 0.090381361f, - 0.996044701f, 0.088853553f, - 0.996179829f, 0.087325535f, - 0.996312612f, 0.085797312f, - 0.996443051f, 0.084268888f, - 0.996571146f, 0.082740265f, - 0.996696895f, 0.081211447f, - 0.996820299f, 0.079682438f, - 0.996941358f, 0.078153242f, - 0.997060070f, 0.076623861f, - 0.997176437f, 0.075094301f, - 0.997290457f, 0.073564564f, - 0.997402130f, 0.072034653f, - 0.997511456f, 0.070504573f, - 0.997618435f, 0.068974328f, - 0.997723067f, 0.067443920f, - 0.997825350f, 0.065913353f, - 0.997925286f, 0.064382631f, - 0.998022874f, 0.062851758f, - 0.998118113f, 0.061320736f, - 0.998211003f, 0.059789571f, - 0.998301545f, 0.058258265f, - 0.998389737f, 0.056726821f, - 0.998475581f, 0.055195244f, - 0.998559074f, 0.053663538f, - 0.998640218f, 0.052131705f, - 0.998719012f, 0.050599749f, - 0.998795456f, 0.049067674f, - 0.998869550f, 0.047535484f, - 0.998941293f, 0.046003182f, - 0.999010686f, 0.044470772f, - 0.999077728f, 0.042938257f, - 0.999142419f, 0.041405641f, - 0.999204759f, 0.039872928f, - 0.999264747f, 0.038340120f, - 0.999322385f, 0.036807223f, - 0.999377670f, 0.035274239f, - 0.999430605f, 0.033741172f, - 0.999481187f, 0.032208025f, - 0.999529418f, 0.030674803f, - 0.999575296f, 0.029141509f, - 0.999618822f, 0.027608146f, - 0.999659997f, 0.026074718f, - 0.999698819f, 0.024541229f, - 0.999735288f, 0.023007681f, - 0.999769405f, 0.021474080f, - 0.999801170f, 0.019940429f, - 0.999830582f, 0.018406730f, - 0.999857641f, 0.016872988f, - 0.999882347f, 0.015339206f, - 0.999904701f, 0.013805389f, - 0.999924702f, 0.012271538f, - 0.999942350f, 0.010737659f, - 0.999957645f, 0.009203755f, - 0.999970586f, 0.007669829f, - 0.999981175f, 0.006135885f, - 0.999989411f, 0.004601926f, - 0.999995294f, 0.003067957f, - 0.999998823f, 0.001533980f, - 1.000000000f, 0.000000000f, - 0.999998823f, -0.001533980f, - 0.999995294f, -0.003067957f, - 0.999989411f, -0.004601926f, - 0.999981175f, -0.006135885f, - 0.999970586f, -0.007669829f, - 0.999957645f, -0.009203755f, - 0.999942350f, -0.010737659f, - 0.999924702f, -0.012271538f, - 0.999904701f, -0.013805389f, - 0.999882347f, -0.015339206f, - 0.999857641f, -0.016872988f, - 0.999830582f, -0.018406730f, - 0.999801170f, -0.019940429f, - 0.999769405f, -0.021474080f, - 0.999735288f, -0.023007681f, - 0.999698819f, -0.024541229f, - 0.999659997f, -0.026074718f, - 0.999618822f, -0.027608146f, - 0.999575296f, -0.029141509f, - 0.999529418f, -0.030674803f, - 0.999481187f, -0.032208025f, - 0.999430605f, -0.033741172f, - 0.999377670f, -0.035274239f, - 0.999322385f, -0.036807223f, - 0.999264747f, -0.038340120f, - 0.999204759f, -0.039872928f, - 0.999142419f, -0.041405641f, - 0.999077728f, -0.042938257f, - 0.999010686f, -0.044470772f, - 0.998941293f, -0.046003182f, - 0.998869550f, -0.047535484f, - 0.998795456f, -0.049067674f, - 0.998719012f, -0.050599749f, - 0.998640218f, -0.052131705f, - 0.998559074f, -0.053663538f, - 0.998475581f, -0.055195244f, - 0.998389737f, -0.056726821f, - 0.998301545f, -0.058258265f, - 0.998211003f, -0.059789571f, - 0.998118113f, -0.061320736f, - 0.998022874f, -0.062851758f, - 0.997925286f, -0.064382631f, - 0.997825350f, -0.065913353f, - 0.997723067f, -0.067443920f, - 0.997618435f, -0.068974328f, - 0.997511456f, -0.070504573f, - 0.997402130f, -0.072034653f, - 0.997290457f, -0.073564564f, - 0.997176437f, -0.075094301f, - 0.997060070f, -0.076623861f, - 0.996941358f, -0.078153242f, - 0.996820299f, -0.079682438f, - 0.996696895f, -0.081211447f, - 0.996571146f, -0.082740265f, - 0.996443051f, -0.084268888f, - 0.996312612f, -0.085797312f, - 0.996179829f, -0.087325535f, - 0.996044701f, -0.088853553f, - 0.995907229f, -0.090381361f, - 0.995767414f, -0.091908956f, - 0.995625256f, -0.093436336f, - 0.995480755f, -0.094963495f, - 0.995333912f, -0.096490431f, - 0.995184727f, -0.098017140f, - 0.995033199f, -0.099543619f, - 0.994879331f, -0.101069863f, - 0.994723121f, -0.102595869f, - 0.994564571f, -0.104121634f, - 0.994403680f, -0.105647154f, - 0.994240449f, -0.107172425f, - 0.994074879f, -0.108697444f, - 0.993906970f, -0.110222207f, - 0.993736722f, -0.111746711f, - 0.993564136f, -0.113270952f, - 0.993389211f, -0.114794927f, - 0.993211949f, -0.116318631f, - 0.993032350f, -0.117842062f, - 0.992850414f, -0.119365215f, - 0.992666142f, -0.120888087f, - 0.992479535f, -0.122410675f, - 0.992290591f, -0.123932975f, - 0.992099313f, -0.125454983f, - 0.991905700f, -0.126976696f, - 0.991709754f, -0.128498111f, - 0.991511473f, -0.130019223f, - 0.991310860f, -0.131540029f, - 0.991107914f, -0.133060525f, - 0.990902635f, -0.134580709f, - 0.990695025f, -0.136100575f, - 0.990485084f, -0.137620122f, - 0.990272812f, -0.139139344f, - 0.990058210f, -0.140658239f, - 0.989841278f, -0.142176804f, - 0.989622017f, -0.143695033f, - 0.989400428f, -0.145212925f, - 0.989176510f, -0.146730474f, - 0.988950265f, -0.148247679f, - 0.988721692f, -0.149764535f, - 0.988490793f, -0.151281038f, - 0.988257568f, -0.152797185f, - 0.988022017f, -0.154312973f, - 0.987784142f, -0.155828398f, - 0.987543942f, -0.157343456f, - 0.987301418f, -0.158858143f, - 0.987056571f, -0.160372457f, - 0.986809402f, -0.161886394f, - 0.986559910f, -0.163399949f, - 0.986308097f, -0.164913120f, - 0.986053963f, -0.166425904f, - 0.985797509f, -0.167938295f, - 0.985538735f, -0.169450291f, - 0.985277642f, -0.170961889f, - 0.985014231f, -0.172473084f, - 0.984748502f, -0.173983873f, - 0.984480455f, -0.175494253f, - 0.984210092f, -0.177004220f, - 0.983937413f, -0.178513771f, - 0.983662419f, -0.180022901f, - 0.983385110f, -0.181531608f, - 0.983105487f, -0.183039888f, - 0.982823551f, -0.184547737f, - 0.982539302f, -0.186055152f, - 0.982252741f, -0.187562129f, - 0.981963869f, -0.189068664f, - 0.981672686f, -0.190574755f, - 0.981379193f, -0.192080397f, - 0.981083391f, -0.193585587f, - 0.980785280f, -0.195090322f, - 0.980484862f, -0.196594598f, - 0.980182136f, -0.198098411f, - 0.979877104f, -0.199601758f, - 0.979569766f, -0.201104635f, - 0.979260123f, -0.202607039f, - 0.978948175f, -0.204108966f, - 0.978633924f, -0.205610413f, - 0.978317371f, -0.207111376f, - 0.977998515f, -0.208611852f, - 0.977677358f, -0.210111837f, - 0.977353900f, -0.211611327f, - 0.977028143f, -0.213110320f, - 0.976700086f, -0.214608811f, - 0.976369731f, -0.216106797f, - 0.976037079f, -0.217604275f, - 0.975702130f, -0.219101240f, - 0.975364885f, -0.220597690f, - 0.975025345f, -0.222093621f, - 0.974683511f, -0.223589029f, - 0.974339383f, -0.225083911f, - 0.973992962f, -0.226578264f, - 0.973644250f, -0.228072083f, - 0.973293246f, -0.229565366f, - 0.972939952f, -0.231058108f, - 0.972584369f, -0.232550307f, - 0.972226497f, -0.234041959f, - 0.971866337f, -0.235533059f, - 0.971503891f, -0.237023606f, - 0.971139158f, -0.238513595f, - 0.970772141f, -0.240003022f, - 0.970402839f, -0.241491885f, - 0.970031253f, -0.242980180f, - 0.969657385f, -0.244467903f, - 0.969281235f, -0.245955050f, - 0.968902805f, -0.247441619f, - 0.968522094f, -0.248927606f, - 0.968139105f, -0.250413007f, - 0.967753837f, -0.251897818f, - 0.967366292f, -0.253382037f, - 0.966976471f, -0.254865660f, - 0.966584374f, -0.256348682f, - 0.966190003f, -0.257831102f, - 0.965793359f, -0.259312915f, - 0.965394442f, -0.260794118f, - 0.964993253f, -0.262274707f, - 0.964589793f, -0.263754679f, - 0.964184064f, -0.265234030f, - 0.963776066f, -0.266712757f, - 0.963365800f, -0.268190857f, - 0.962953267f, -0.269668326f, - 0.962538468f, -0.271145160f, - 0.962121404f, -0.272621355f, - 0.961702077f, -0.274096910f, - 0.961280486f, -0.275571819f, - 0.960856633f, -0.277046080f, - 0.960430519f, -0.278519689f, - 0.960002146f, -0.279992643f, - 0.959571513f, -0.281464938f, - 0.959138622f, -0.282936570f, - 0.958703475f, -0.284407537f, - 0.958266071f, -0.285877835f, - 0.957826413f, -0.287347460f, - 0.957384501f, -0.288816408f, - 0.956940336f, -0.290284677f, - 0.956493919f, -0.291752263f, - 0.956045251f, -0.293219163f, - 0.955594334f, -0.294685372f, - 0.955141168f, -0.296150888f, - 0.954685755f, -0.297615707f, - 0.954228095f, -0.299079826f, - 0.953768190f, -0.300543241f, - 0.953306040f, -0.302005949f, - 0.952841648f, -0.303467947f, - 0.952375013f, -0.304929230f, - 0.951906137f, -0.306389795f, - 0.951435021f, -0.307849640f, - 0.950961666f, -0.309308760f, - 0.950486074f, -0.310767153f, - 0.950008245f, -0.312224814f, - 0.949528181f, -0.313681740f, - 0.949045882f, -0.315137929f, - 0.948561350f, -0.316593376f, - 0.948074586f, -0.318048077f, - 0.947585591f, -0.319502031f, - 0.947094366f, -0.320955232f, - 0.946600913f, -0.322407679f, - 0.946105232f, -0.323859367f, - 0.945607325f, -0.325310292f, - 0.945107193f, -0.326760452f, - 0.944604837f, -0.328209844f, - 0.944100258f, -0.329658463f, - 0.943593458f, -0.331106306f, - 0.943084437f, -0.332553370f, - 0.942573198f, -0.333999651f, - 0.942059740f, -0.335445147f, - 0.941544065f, -0.336889853f, - 0.941026175f, -0.338333767f, - 0.940506071f, -0.339776884f, - 0.939983753f, -0.341219202f, - 0.939459224f, -0.342660717f, - 0.938932484f, -0.344101426f, - 0.938403534f, -0.345541325f, - 0.937872376f, -0.346980411f, - 0.937339012f, -0.348418680f, - 0.936803442f, -0.349856130f, - 0.936265667f, -0.351292756f, - 0.935725689f, -0.352728556f, - 0.935183510f, -0.354163525f, - 0.934639130f, -0.355597662f, - 0.934092550f, -0.357030961f, - 0.933543773f, -0.358463421f, - 0.932992799f, -0.359895037f, - 0.932439629f, -0.361325806f, - 0.931884266f, -0.362755724f, - 0.931326709f, -0.364184790f, - 0.930766961f, -0.365612998f, - 0.930205023f, -0.367040346f, - 0.929640896f, -0.368466830f, - 0.929074581f, -0.369892447f, - 0.928506080f, -0.371317194f, - 0.927935395f, -0.372741067f, - 0.927362526f, -0.374164063f, - 0.926787474f, -0.375586178f, - 0.926210242f, -0.377007410f, - 0.925630831f, -0.378427755f, - 0.925049241f, -0.379847209f, - 0.924465474f, -0.381265769f, - 0.923879533f, -0.382683432f, - 0.923291417f, -0.384100195f, - 0.922701128f, -0.385516054f, - 0.922108669f, -0.386931006f, - 0.921514039f, -0.388345047f, - 0.920917242f, -0.389758174f, - 0.920318277f, -0.391170384f, - 0.919717146f, -0.392581674f, - 0.919113852f, -0.393992040f, - 0.918508394f, -0.395401479f, - 0.917900776f, -0.396809987f, - 0.917290997f, -0.398217562f, - 0.916679060f, -0.399624200f, - 0.916064966f, -0.401029897f, - 0.915448716f, -0.402434651f, - 0.914830312f, -0.403838458f, - 0.914209756f, -0.405241314f, - 0.913587048f, -0.406643217f, - 0.912962190f, -0.408044163f, - 0.912335185f, -0.409444149f, - 0.911706032f, -0.410843171f, - 0.911074734f, -0.412241227f, - 0.910441292f, -0.413638312f, - 0.909805708f, -0.415034424f, - 0.909167983f, -0.416429560f, - 0.908528119f, -0.417823716f, - 0.907886116f, -0.419216888f, - 0.907241978f, -0.420609074f, - 0.906595705f, -0.422000271f, - 0.905947298f, -0.423390474f, - 0.905296759f, -0.424779681f, - 0.904644091f, -0.426167889f, - 0.903989293f, -0.427555093f, - 0.903332368f, -0.428941292f, - 0.902673318f, -0.430326481f, - 0.902012144f, -0.431710658f, - 0.901348847f, -0.433093819f, - 0.900683429f, -0.434475961f, - 0.900015892f, -0.435857080f, - 0.899346237f, -0.437237174f, - 0.898674466f, -0.438616239f, - 0.898000580f, -0.439994271f, - 0.897324581f, -0.441371269f, - 0.896646470f, -0.442747228f, - 0.895966250f, -0.444122145f, - 0.895283921f, -0.445496017f, - 0.894599486f, -0.446868840f, - 0.893912945f, -0.448240612f, - 0.893224301f, -0.449611330f, - 0.892533555f, -0.450980989f, - 0.891840709f, -0.452349587f, - 0.891145765f, -0.453717121f, - 0.890448723f, -0.455083587f, - 0.889749586f, -0.456448982f, - 0.889048356f, -0.457813304f, - 0.888345033f, -0.459176548f, - 0.887639620f, -0.460538711f, - 0.886932119f, -0.461899791f, - 0.886222530f, -0.463259784f, - 0.885510856f, -0.464618686f, - 0.884797098f, -0.465976496f, - 0.884081259f, -0.467333209f, - 0.883363339f, -0.468688822f, - 0.882643340f, -0.470043332f, - 0.881921264f, -0.471396737f, - 0.881197113f, -0.472749032f, - 0.880470889f, -0.474100215f, - 0.879742593f, -0.475450282f, - 0.879012226f, -0.476799230f, - 0.878279792f, -0.478147056f, - 0.877545290f, -0.479493758f, - 0.876808724f, -0.480839331f, - 0.876070094f, -0.482183772f, - 0.875329403f, -0.483527079f, - 0.874586652f, -0.484869248f, - 0.873841843f, -0.486210276f, - 0.873094978f, -0.487550160f, - 0.872346059f, -0.488888897f, - 0.871595087f, -0.490226483f, - 0.870842063f, -0.491562916f, - 0.870086991f, -0.492898192f, - 0.869329871f, -0.494232309f, - 0.868570706f, -0.495565262f, - 0.867809497f, -0.496897049f, - 0.867046246f, -0.498227667f, - 0.866280954f, -0.499557113f, - 0.865513624f, -0.500885383f, - 0.864744258f, -0.502212474f, - 0.863972856f, -0.503538384f, - 0.863199422f, -0.504863109f, - 0.862423956f, -0.506186645f, - 0.861646461f, -0.507508991f, - 0.860866939f, -0.508830143f, - 0.860085390f, -0.510150097f, - 0.859301818f, -0.511468850f, - 0.858516224f, -0.512786401f, - 0.857728610f, -0.514102744f, - 0.856938977f, -0.515417878f, - 0.856147328f, -0.516731799f, - 0.855353665f, -0.518044504f, - 0.854557988f, -0.519355990f, - 0.853760301f, -0.520666254f, - 0.852960605f, -0.521975293f, - 0.852158902f, -0.523283103f, - 0.851355193f, -0.524589683f, - 0.850549481f, -0.525895027f, - 0.849741768f, -0.527199135f, - 0.848932055f, -0.528502002f, - 0.848120345f, -0.529803625f, - 0.847306639f, -0.531104001f, - 0.846490939f, -0.532403128f, - 0.845673247f, -0.533701002f, - 0.844853565f, -0.534997620f, - 0.844031895f, -0.536292979f, - 0.843208240f, -0.537587076f, - 0.842382600f, -0.538879909f, - 0.841554977f, -0.540171473f, - 0.840725375f, -0.541461766f, - 0.839893794f, -0.542750785f, - 0.839060237f, -0.544038527f, - 0.838224706f, -0.545324988f, - 0.837387202f, -0.546610167f, - 0.836547727f, -0.547894059f, - 0.835706284f, -0.549176662f, - 0.834862875f, -0.550457973f, - 0.834017501f, -0.551737988f, - 0.833170165f, -0.553016706f, - 0.832320868f, -0.554294121f, - 0.831469612f, -0.555570233f, - 0.830616400f, -0.556845037f, - 0.829761234f, -0.558118531f, - 0.828904115f, -0.559390712f, - 0.828045045f, -0.560661576f, - 0.827184027f, -0.561931121f, - 0.826321063f, -0.563199344f, - 0.825456154f, -0.564466242f, - 0.824589303f, -0.565731811f, - 0.823720511f, -0.566996049f, - 0.822849781f, -0.568258953f, - 0.821977115f, -0.569520519f, - 0.821102515f, -0.570780746f, - 0.820225983f, -0.572039629f, - 0.819347520f, -0.573297167f, - 0.818467130f, -0.574553355f, - 0.817584813f, -0.575808191f, - 0.816700573f, -0.577061673f, - 0.815814411f, -0.578313796f, - 0.814926329f, -0.579564559f, - 0.814036330f, -0.580813958f, - 0.813144415f, -0.582061990f, - 0.812250587f, -0.583308653f, - 0.811354847f, -0.584553943f, - 0.810457198f, -0.585797857f, - 0.809557642f, -0.587040394f, - 0.808656182f, -0.588281548f, - 0.807752818f, -0.589521319f, - 0.806847554f, -0.590759702f, - 0.805940391f, -0.591996695f, - 0.805031331f, -0.593232295f, - 0.804120377f, -0.594466499f, - 0.803207531f, -0.595699304f, - 0.802292796f, -0.596930708f, - 0.801376172f, -0.598160707f, - 0.800457662f, -0.599389298f, - 0.799537269f, -0.600616479f, - 0.798614995f, -0.601842247f, - 0.797690841f, -0.603066599f, - 0.796764810f, -0.604289531f, - 0.795836905f, -0.605511041f, - 0.794907126f, -0.606731127f, - 0.793975478f, -0.607949785f, - 0.793041960f, -0.609167012f, - 0.792106577f, -0.610382806f, - 0.791169330f, -0.611597164f, - 0.790230221f, -0.612810082f, - 0.789289253f, -0.614021559f, - 0.788346428f, -0.615231591f, - 0.787401747f, -0.616440175f, - 0.786455214f, -0.617647308f, - 0.785506830f, -0.618852988f, - 0.784556597f, -0.620057212f, - 0.783604519f, -0.621259977f, - 0.782650596f, -0.622461279f, - 0.781694832f, -0.623661118f, - 0.780737229f, -0.624859488f, - 0.779777788f, -0.626056388f, - 0.778816512f, -0.627251815f, - 0.777853404f, -0.628445767f, - 0.776888466f, -0.629638239f, - 0.775921699f, -0.630829230f, - 0.774953107f, -0.632018736f, - 0.773982691f, -0.633206755f, - 0.773010453f, -0.634393284f, - 0.772036397f, -0.635578320f, - 0.771060524f, -0.636761861f, - 0.770082837f, -0.637943904f, - 0.769103338f, -0.639124445f, - 0.768122029f, -0.640303482f, - 0.767138912f, -0.641481013f, - 0.766153990f, -0.642657034f, - 0.765167266f, -0.643831543f, - 0.764178741f, -0.645004537f, - 0.763188417f, -0.646176013f, - 0.762196298f, -0.647345969f, - 0.761202385f, -0.648514401f, - 0.760206682f, -0.649681307f, - 0.759209189f, -0.650846685f, - 0.758209910f, -0.652010531f, - 0.757208847f, -0.653172843f, - 0.756206001f, -0.654333618f, - 0.755201377f, -0.655492853f, - 0.754194975f, -0.656650546f, - 0.753186799f, -0.657806693f, - 0.752176850f, -0.658961293f, - 0.751165132f, -0.660114342f, - 0.750151646f, -0.661265838f, - 0.749136395f, -0.662415778f, - 0.748119380f, -0.663564159f, - 0.747100606f, -0.664710978f, - 0.746080074f, -0.665856234f, - 0.745057785f, -0.666999922f, - 0.744033744f, -0.668142041f, - 0.743007952f, -0.669282588f, - 0.741980412f, -0.670421560f, - 0.740951125f, -0.671558955f, - 0.739920095f, -0.672694769f, - 0.738887324f, -0.673829000f, - 0.737852815f, -0.674961646f, - 0.736816569f, -0.676092704f, - 0.735778589f, -0.677222170f, - 0.734738878f, -0.678350043f, - 0.733697438f, -0.679476320f, - 0.732654272f, -0.680600998f, - 0.731609381f, -0.681724074f, - 0.730562769f, -0.682845546f, - 0.729514438f, -0.683965412f, - 0.728464390f, -0.685083668f, - 0.727412629f, -0.686200312f, - 0.726359155f, -0.687315341f, - 0.725303972f, -0.688428753f, - 0.724247083f, -0.689540545f, - 0.723188489f, -0.690650714f, - 0.722128194f, -0.691759258f, - 0.721066199f, -0.692866175f, - 0.720002508f, -0.693971461f, - 0.718937122f, -0.695075114f, - 0.717870045f, -0.696177131f, - 0.716801279f, -0.697277511f, - 0.715730825f, -0.698376249f, - 0.714658688f, -0.699473345f, - 0.713584869f, -0.700568794f, - 0.712509371f, -0.701662595f, - 0.711432196f, -0.702754744f, - 0.710353347f, -0.703845241f, - 0.709272826f, -0.704934080f, - 0.708190637f, -0.706021261f, - 0.707106781f, -0.707106781f, - 0.706021261f, -0.708190637f, - 0.704934080f, -0.709272826f, - 0.703845241f, -0.710353347f, - 0.702754744f, -0.711432196f, - 0.701662595f, -0.712509371f, - 0.700568794f, -0.713584869f, - 0.699473345f, -0.714658688f, - 0.698376249f, -0.715730825f, - 0.697277511f, -0.716801279f, - 0.696177131f, -0.717870045f, - 0.695075114f, -0.718937122f, - 0.693971461f, -0.720002508f, - 0.692866175f, -0.721066199f, - 0.691759258f, -0.722128194f, - 0.690650714f, -0.723188489f, - 0.689540545f, -0.724247083f, - 0.688428753f, -0.725303972f, - 0.687315341f, -0.726359155f, - 0.686200312f, -0.727412629f, - 0.685083668f, -0.728464390f, - 0.683965412f, -0.729514438f, - 0.682845546f, -0.730562769f, - 0.681724074f, -0.731609381f, - 0.680600998f, -0.732654272f, - 0.679476320f, -0.733697438f, - 0.678350043f, -0.734738878f, - 0.677222170f, -0.735778589f, - 0.676092704f, -0.736816569f, - 0.674961646f, -0.737852815f, - 0.673829000f, -0.738887324f, - 0.672694769f, -0.739920095f, - 0.671558955f, -0.740951125f, - 0.670421560f, -0.741980412f, - 0.669282588f, -0.743007952f, - 0.668142041f, -0.744033744f, - 0.666999922f, -0.745057785f, - 0.665856234f, -0.746080074f, - 0.664710978f, -0.747100606f, - 0.663564159f, -0.748119380f, - 0.662415778f, -0.749136395f, - 0.661265838f, -0.750151646f, - 0.660114342f, -0.751165132f, - 0.658961293f, -0.752176850f, - 0.657806693f, -0.753186799f, - 0.656650546f, -0.754194975f, - 0.655492853f, -0.755201377f, - 0.654333618f, -0.756206001f, - 0.653172843f, -0.757208847f, - 0.652010531f, -0.758209910f, - 0.650846685f, -0.759209189f, - 0.649681307f, -0.760206682f, - 0.648514401f, -0.761202385f, - 0.647345969f, -0.762196298f, - 0.646176013f, -0.763188417f, - 0.645004537f, -0.764178741f, - 0.643831543f, -0.765167266f, - 0.642657034f, -0.766153990f, - 0.641481013f, -0.767138912f, - 0.640303482f, -0.768122029f, - 0.639124445f, -0.769103338f, - 0.637943904f, -0.770082837f, - 0.636761861f, -0.771060524f, - 0.635578320f, -0.772036397f, - 0.634393284f, -0.773010453f, - 0.633206755f, -0.773982691f, - 0.632018736f, -0.774953107f, - 0.630829230f, -0.775921699f, - 0.629638239f, -0.776888466f, - 0.628445767f, -0.777853404f, - 0.627251815f, -0.778816512f, - 0.626056388f, -0.779777788f, - 0.624859488f, -0.780737229f, - 0.623661118f, -0.781694832f, - 0.622461279f, -0.782650596f, - 0.621259977f, -0.783604519f, - 0.620057212f, -0.784556597f, - 0.618852988f, -0.785506830f, - 0.617647308f, -0.786455214f, - 0.616440175f, -0.787401747f, - 0.615231591f, -0.788346428f, - 0.614021559f, -0.789289253f, - 0.612810082f, -0.790230221f, - 0.611597164f, -0.791169330f, - 0.610382806f, -0.792106577f, - 0.609167012f, -0.793041960f, - 0.607949785f, -0.793975478f, - 0.606731127f, -0.794907126f, - 0.605511041f, -0.795836905f, - 0.604289531f, -0.796764810f, - 0.603066599f, -0.797690841f, - 0.601842247f, -0.798614995f, - 0.600616479f, -0.799537269f, - 0.599389298f, -0.800457662f, - 0.598160707f, -0.801376172f, - 0.596930708f, -0.802292796f, - 0.595699304f, -0.803207531f, - 0.594466499f, -0.804120377f, - 0.593232295f, -0.805031331f, - 0.591996695f, -0.805940391f, - 0.590759702f, -0.806847554f, - 0.589521319f, -0.807752818f, - 0.588281548f, -0.808656182f, - 0.587040394f, -0.809557642f, - 0.585797857f, -0.810457198f, - 0.584553943f, -0.811354847f, - 0.583308653f, -0.812250587f, - 0.582061990f, -0.813144415f, - 0.580813958f, -0.814036330f, - 0.579564559f, -0.814926329f, - 0.578313796f, -0.815814411f, - 0.577061673f, -0.816700573f, - 0.575808191f, -0.817584813f, - 0.574553355f, -0.818467130f, - 0.573297167f, -0.819347520f, - 0.572039629f, -0.820225983f, - 0.570780746f, -0.821102515f, - 0.569520519f, -0.821977115f, - 0.568258953f, -0.822849781f, - 0.566996049f, -0.823720511f, - 0.565731811f, -0.824589303f, - 0.564466242f, -0.825456154f, - 0.563199344f, -0.826321063f, - 0.561931121f, -0.827184027f, - 0.560661576f, -0.828045045f, - 0.559390712f, -0.828904115f, - 0.558118531f, -0.829761234f, - 0.556845037f, -0.830616400f, - 0.555570233f, -0.831469612f, - 0.554294121f, -0.832320868f, - 0.553016706f, -0.833170165f, - 0.551737988f, -0.834017501f, - 0.550457973f, -0.834862875f, - 0.549176662f, -0.835706284f, - 0.547894059f, -0.836547727f, - 0.546610167f, -0.837387202f, - 0.545324988f, -0.838224706f, - 0.544038527f, -0.839060237f, - 0.542750785f, -0.839893794f, - 0.541461766f, -0.840725375f, - 0.540171473f, -0.841554977f, - 0.538879909f, -0.842382600f, - 0.537587076f, -0.843208240f, - 0.536292979f, -0.844031895f, - 0.534997620f, -0.844853565f, - 0.533701002f, -0.845673247f, - 0.532403128f, -0.846490939f, - 0.531104001f, -0.847306639f, - 0.529803625f, -0.848120345f, - 0.528502002f, -0.848932055f, - 0.527199135f, -0.849741768f, - 0.525895027f, -0.850549481f, - 0.524589683f, -0.851355193f, - 0.523283103f, -0.852158902f, - 0.521975293f, -0.852960605f, - 0.520666254f, -0.853760301f, - 0.519355990f, -0.854557988f, - 0.518044504f, -0.855353665f, - 0.516731799f, -0.856147328f, - 0.515417878f, -0.856938977f, - 0.514102744f, -0.857728610f, - 0.512786401f, -0.858516224f, - 0.511468850f, -0.859301818f, - 0.510150097f, -0.860085390f, - 0.508830143f, -0.860866939f, - 0.507508991f, -0.861646461f, - 0.506186645f, -0.862423956f, - 0.504863109f, -0.863199422f, - 0.503538384f, -0.863972856f, - 0.502212474f, -0.864744258f, - 0.500885383f, -0.865513624f, - 0.499557113f, -0.866280954f, - 0.498227667f, -0.867046246f, - 0.496897049f, -0.867809497f, - 0.495565262f, -0.868570706f, - 0.494232309f, -0.869329871f, - 0.492898192f, -0.870086991f, - 0.491562916f, -0.870842063f, - 0.490226483f, -0.871595087f, - 0.488888897f, -0.872346059f, - 0.487550160f, -0.873094978f, - 0.486210276f, -0.873841843f, - 0.484869248f, -0.874586652f, - 0.483527079f, -0.875329403f, - 0.482183772f, -0.876070094f, - 0.480839331f, -0.876808724f, - 0.479493758f, -0.877545290f, - 0.478147056f, -0.878279792f, - 0.476799230f, -0.879012226f, - 0.475450282f, -0.879742593f, - 0.474100215f, -0.880470889f, - 0.472749032f, -0.881197113f, - 0.471396737f, -0.881921264f, - 0.470043332f, -0.882643340f, - 0.468688822f, -0.883363339f, - 0.467333209f, -0.884081259f, - 0.465976496f, -0.884797098f, - 0.464618686f, -0.885510856f, - 0.463259784f, -0.886222530f, - 0.461899791f, -0.886932119f, - 0.460538711f, -0.887639620f, - 0.459176548f, -0.888345033f, - 0.457813304f, -0.889048356f, - 0.456448982f, -0.889749586f, - 0.455083587f, -0.890448723f, - 0.453717121f, -0.891145765f, - 0.452349587f, -0.891840709f, - 0.450980989f, -0.892533555f, - 0.449611330f, -0.893224301f, - 0.448240612f, -0.893912945f, - 0.446868840f, -0.894599486f, - 0.445496017f, -0.895283921f, - 0.444122145f, -0.895966250f, - 0.442747228f, -0.896646470f, - 0.441371269f, -0.897324581f, - 0.439994271f, -0.898000580f, - 0.438616239f, -0.898674466f, - 0.437237174f, -0.899346237f, - 0.435857080f, -0.900015892f, - 0.434475961f, -0.900683429f, - 0.433093819f, -0.901348847f, - 0.431710658f, -0.902012144f, - 0.430326481f, -0.902673318f, - 0.428941292f, -0.903332368f, - 0.427555093f, -0.903989293f, - 0.426167889f, -0.904644091f, - 0.424779681f, -0.905296759f, - 0.423390474f, -0.905947298f, - 0.422000271f, -0.906595705f, - 0.420609074f, -0.907241978f, - 0.419216888f, -0.907886116f, - 0.417823716f, -0.908528119f, - 0.416429560f, -0.909167983f, - 0.415034424f, -0.909805708f, - 0.413638312f, -0.910441292f, - 0.412241227f, -0.911074734f, - 0.410843171f, -0.911706032f, - 0.409444149f, -0.912335185f, - 0.408044163f, -0.912962190f, - 0.406643217f, -0.913587048f, - 0.405241314f, -0.914209756f, - 0.403838458f, -0.914830312f, - 0.402434651f, -0.915448716f, - 0.401029897f, -0.916064966f, - 0.399624200f, -0.916679060f, - 0.398217562f, -0.917290997f, - 0.396809987f, -0.917900776f, - 0.395401479f, -0.918508394f, - 0.393992040f, -0.919113852f, - 0.392581674f, -0.919717146f, - 0.391170384f, -0.920318277f, - 0.389758174f, -0.920917242f, - 0.388345047f, -0.921514039f, - 0.386931006f, -0.922108669f, - 0.385516054f, -0.922701128f, - 0.384100195f, -0.923291417f, - 0.382683432f, -0.923879533f, - 0.381265769f, -0.924465474f, - 0.379847209f, -0.925049241f, - 0.378427755f, -0.925630831f, - 0.377007410f, -0.926210242f, - 0.375586178f, -0.926787474f, - 0.374164063f, -0.927362526f, - 0.372741067f, -0.927935395f, - 0.371317194f, -0.928506080f, - 0.369892447f, -0.929074581f, - 0.368466830f, -0.929640896f, - 0.367040346f, -0.930205023f, - 0.365612998f, -0.930766961f, - 0.364184790f, -0.931326709f, - 0.362755724f, -0.931884266f, - 0.361325806f, -0.932439629f, - 0.359895037f, -0.932992799f, - 0.358463421f, -0.933543773f, - 0.357030961f, -0.934092550f, - 0.355597662f, -0.934639130f, - 0.354163525f, -0.935183510f, - 0.352728556f, -0.935725689f, - 0.351292756f, -0.936265667f, - 0.349856130f, -0.936803442f, - 0.348418680f, -0.937339012f, - 0.346980411f, -0.937872376f, - 0.345541325f, -0.938403534f, - 0.344101426f, -0.938932484f, - 0.342660717f, -0.939459224f, - 0.341219202f, -0.939983753f, - 0.339776884f, -0.940506071f, - 0.338333767f, -0.941026175f, - 0.336889853f, -0.941544065f, - 0.335445147f, -0.942059740f, - 0.333999651f, -0.942573198f, - 0.332553370f, -0.943084437f, - 0.331106306f, -0.943593458f, - 0.329658463f, -0.944100258f, - 0.328209844f, -0.944604837f, - 0.326760452f, -0.945107193f, - 0.325310292f, -0.945607325f, - 0.323859367f, -0.946105232f, - 0.322407679f, -0.946600913f, - 0.320955232f, -0.947094366f, - 0.319502031f, -0.947585591f, - 0.318048077f, -0.948074586f, - 0.316593376f, -0.948561350f, - 0.315137929f, -0.949045882f, - 0.313681740f, -0.949528181f, - 0.312224814f, -0.950008245f, - 0.310767153f, -0.950486074f, - 0.309308760f, -0.950961666f, - 0.307849640f, -0.951435021f, - 0.306389795f, -0.951906137f, - 0.304929230f, -0.952375013f, - 0.303467947f, -0.952841648f, - 0.302005949f, -0.953306040f, - 0.300543241f, -0.953768190f, - 0.299079826f, -0.954228095f, - 0.297615707f, -0.954685755f, - 0.296150888f, -0.955141168f, - 0.294685372f, -0.955594334f, - 0.293219163f, -0.956045251f, - 0.291752263f, -0.956493919f, - 0.290284677f, -0.956940336f, - 0.288816408f, -0.957384501f, - 0.287347460f, -0.957826413f, - 0.285877835f, -0.958266071f, - 0.284407537f, -0.958703475f, - 0.282936570f, -0.959138622f, - 0.281464938f, -0.959571513f, - 0.279992643f, -0.960002146f, - 0.278519689f, -0.960430519f, - 0.277046080f, -0.960856633f, - 0.275571819f, -0.961280486f, - 0.274096910f, -0.961702077f, - 0.272621355f, -0.962121404f, - 0.271145160f, -0.962538468f, - 0.269668326f, -0.962953267f, - 0.268190857f, -0.963365800f, - 0.266712757f, -0.963776066f, - 0.265234030f, -0.964184064f, - 0.263754679f, -0.964589793f, - 0.262274707f, -0.964993253f, - 0.260794118f, -0.965394442f, - 0.259312915f, -0.965793359f, - 0.257831102f, -0.966190003f, - 0.256348682f, -0.966584374f, - 0.254865660f, -0.966976471f, - 0.253382037f, -0.967366292f, - 0.251897818f, -0.967753837f, - 0.250413007f, -0.968139105f, - 0.248927606f, -0.968522094f, - 0.247441619f, -0.968902805f, - 0.245955050f, -0.969281235f, - 0.244467903f, -0.969657385f, - 0.242980180f, -0.970031253f, - 0.241491885f, -0.970402839f, - 0.240003022f, -0.970772141f, - 0.238513595f, -0.971139158f, - 0.237023606f, -0.971503891f, - 0.235533059f, -0.971866337f, - 0.234041959f, -0.972226497f, - 0.232550307f, -0.972584369f, - 0.231058108f, -0.972939952f, - 0.229565366f, -0.973293246f, - 0.228072083f, -0.973644250f, - 0.226578264f, -0.973992962f, - 0.225083911f, -0.974339383f, - 0.223589029f, -0.974683511f, - 0.222093621f, -0.975025345f, - 0.220597690f, -0.975364885f, - 0.219101240f, -0.975702130f, - 0.217604275f, -0.976037079f, - 0.216106797f, -0.976369731f, - 0.214608811f, -0.976700086f, - 0.213110320f, -0.977028143f, - 0.211611327f, -0.977353900f, - 0.210111837f, -0.977677358f, - 0.208611852f, -0.977998515f, - 0.207111376f, -0.978317371f, - 0.205610413f, -0.978633924f, - 0.204108966f, -0.978948175f, - 0.202607039f, -0.979260123f, - 0.201104635f, -0.979569766f, - 0.199601758f, -0.979877104f, - 0.198098411f, -0.980182136f, - 0.196594598f, -0.980484862f, - 0.195090322f, -0.980785280f, - 0.193585587f, -0.981083391f, - 0.192080397f, -0.981379193f, - 0.190574755f, -0.981672686f, - 0.189068664f, -0.981963869f, - 0.187562129f, -0.982252741f, - 0.186055152f, -0.982539302f, - 0.184547737f, -0.982823551f, - 0.183039888f, -0.983105487f, - 0.181531608f, -0.983385110f, - 0.180022901f, -0.983662419f, - 0.178513771f, -0.983937413f, - 0.177004220f, -0.984210092f, - 0.175494253f, -0.984480455f, - 0.173983873f, -0.984748502f, - 0.172473084f, -0.985014231f, - 0.170961889f, -0.985277642f, - 0.169450291f, -0.985538735f, - 0.167938295f, -0.985797509f, - 0.166425904f, -0.986053963f, - 0.164913120f, -0.986308097f, - 0.163399949f, -0.986559910f, - 0.161886394f, -0.986809402f, - 0.160372457f, -0.987056571f, - 0.158858143f, -0.987301418f, - 0.157343456f, -0.987543942f, - 0.155828398f, -0.987784142f, - 0.154312973f, -0.988022017f, - 0.152797185f, -0.988257568f, - 0.151281038f, -0.988490793f, - 0.149764535f, -0.988721692f, - 0.148247679f, -0.988950265f, - 0.146730474f, -0.989176510f, - 0.145212925f, -0.989400428f, - 0.143695033f, -0.989622017f, - 0.142176804f, -0.989841278f, - 0.140658239f, -0.990058210f, - 0.139139344f, -0.990272812f, - 0.137620122f, -0.990485084f, - 0.136100575f, -0.990695025f, - 0.134580709f, -0.990902635f, - 0.133060525f, -0.991107914f, - 0.131540029f, -0.991310860f, - 0.130019223f, -0.991511473f, - 0.128498111f, -0.991709754f, - 0.126976696f, -0.991905700f, - 0.125454983f, -0.992099313f, - 0.123932975f, -0.992290591f, - 0.122410675f, -0.992479535f, - 0.120888087f, -0.992666142f, - 0.119365215f, -0.992850414f, - 0.117842062f, -0.993032350f, - 0.116318631f, -0.993211949f, - 0.114794927f, -0.993389211f, - 0.113270952f, -0.993564136f, - 0.111746711f, -0.993736722f, - 0.110222207f, -0.993906970f, - 0.108697444f, -0.994074879f, - 0.107172425f, -0.994240449f, - 0.105647154f, -0.994403680f, - 0.104121634f, -0.994564571f, - 0.102595869f, -0.994723121f, - 0.101069863f, -0.994879331f, - 0.099543619f, -0.995033199f, - 0.098017140f, -0.995184727f, - 0.096490431f, -0.995333912f, - 0.094963495f, -0.995480755f, - 0.093436336f, -0.995625256f, - 0.091908956f, -0.995767414f, - 0.090381361f, -0.995907229f, - 0.088853553f, -0.996044701f, - 0.087325535f, -0.996179829f, - 0.085797312f, -0.996312612f, - 0.084268888f, -0.996443051f, - 0.082740265f, -0.996571146f, - 0.081211447f, -0.996696895f, - 0.079682438f, -0.996820299f, - 0.078153242f, -0.996941358f, - 0.076623861f, -0.997060070f, - 0.075094301f, -0.997176437f, - 0.073564564f, -0.997290457f, - 0.072034653f, -0.997402130f, - 0.070504573f, -0.997511456f, - 0.068974328f, -0.997618435f, - 0.067443920f, -0.997723067f, - 0.065913353f, -0.997825350f, - 0.064382631f, -0.997925286f, - 0.062851758f, -0.998022874f, - 0.061320736f, -0.998118113f, - 0.059789571f, -0.998211003f, - 0.058258265f, -0.998301545f, - 0.056726821f, -0.998389737f, - 0.055195244f, -0.998475581f, - 0.053663538f, -0.998559074f, - 0.052131705f, -0.998640218f, - 0.050599749f, -0.998719012f, - 0.049067674f, -0.998795456f, - 0.047535484f, -0.998869550f, - 0.046003182f, -0.998941293f, - 0.044470772f, -0.999010686f, - 0.042938257f, -0.999077728f, - 0.041405641f, -0.999142419f, - 0.039872928f, -0.999204759f, - 0.038340120f, -0.999264747f, - 0.036807223f, -0.999322385f, - 0.035274239f, -0.999377670f, - 0.033741172f, -0.999430605f, - 0.032208025f, -0.999481187f, - 0.030674803f, -0.999529418f, - 0.029141509f, -0.999575296f, - 0.027608146f, -0.999618822f, - 0.026074718f, -0.999659997f, - 0.024541229f, -0.999698819f, - 0.023007681f, -0.999735288f, - 0.021474080f, -0.999769405f, - 0.019940429f, -0.999801170f, - 0.018406730f, -0.999830582f, - 0.016872988f, -0.999857641f, - 0.015339206f, -0.999882347f, - 0.013805389f, -0.999904701f, - 0.012271538f, -0.999924702f, - 0.010737659f, -0.999942350f, - 0.009203755f, -0.999957645f, - 0.007669829f, -0.999970586f, - 0.006135885f, -0.999981175f, - 0.004601926f, -0.999989411f, - 0.003067957f, -0.999995294f, - 0.001533980f, -0.999998823f -}; - + 0.000000000f, 1.000000000f, 0.001533980f, 0.999998823f, 0.003067957f, + 0.999995294f, 0.004601926f, 0.999989411f, 0.006135885f, 0.999981175f, + 0.007669829f, 0.999970586f, 0.009203755f, 0.999957645f, 0.010737659f, + 0.999942350f, 0.012271538f, 0.999924702f, 0.013805389f, 0.999904701f, + 0.015339206f, 0.999882347f, 0.016872988f, 0.999857641f, 0.018406730f, + 0.999830582f, 0.019940429f, 0.999801170f, 0.021474080f, 0.999769405f, + 0.023007681f, 0.999735288f, 0.024541229f, 0.999698819f, 0.026074718f, + 0.999659997f, 0.027608146f, 0.999618822f, 0.029141509f, 0.999575296f, + 0.030674803f, 0.999529418f, 0.032208025f, 0.999481187f, 0.033741172f, + 0.999430605f, 0.035274239f, 0.999377670f, 0.036807223f, 0.999322385f, + 0.038340120f, 0.999264747f, 0.039872928f, 0.999204759f, 0.041405641f, + 0.999142419f, 0.042938257f, 0.999077728f, 0.044470772f, 0.999010686f, + 0.046003182f, 0.998941293f, 0.047535484f, 0.998869550f, 0.049067674f, + 0.998795456f, 0.050599749f, 0.998719012f, 0.052131705f, 0.998640218f, + 0.053663538f, 0.998559074f, 0.055195244f, 0.998475581f, 0.056726821f, + 0.998389737f, 0.058258265f, 0.998301545f, 0.059789571f, 0.998211003f, + 0.061320736f, 0.998118113f, 0.062851758f, 0.998022874f, 0.064382631f, + 0.997925286f, 0.065913353f, 0.997825350f, 0.067443920f, 0.997723067f, + 0.068974328f, 0.997618435f, 0.070504573f, 0.997511456f, 0.072034653f, + 0.997402130f, 0.073564564f, 0.997290457f, 0.075094301f, 0.997176437f, + 0.076623861f, 0.997060070f, 0.078153242f, 0.996941358f, 0.079682438f, + 0.996820299f, 0.081211447f, 0.996696895f, 0.082740265f, 0.996571146f, + 0.084268888f, 0.996443051f, 0.085797312f, 0.996312612f, 0.087325535f, + 0.996179829f, 0.088853553f, 0.996044701f, 0.090381361f, 0.995907229f, + 0.091908956f, 0.995767414f, 0.093436336f, 0.995625256f, 0.094963495f, + 0.995480755f, 0.096490431f, 0.995333912f, 0.098017140f, 0.995184727f, + 0.099543619f, 0.995033199f, 0.101069863f, 0.994879331f, 0.102595869f, + 0.994723121f, 0.104121634f, 0.994564571f, 0.105647154f, 0.994403680f, + 0.107172425f, 0.994240449f, 0.108697444f, 0.994074879f, 0.110222207f, + 0.993906970f, 0.111746711f, 0.993736722f, 0.113270952f, 0.993564136f, + 0.114794927f, 0.993389211f, 0.116318631f, 0.993211949f, 0.117842062f, + 0.993032350f, 0.119365215f, 0.992850414f, 0.120888087f, 0.992666142f, + 0.122410675f, 0.992479535f, 0.123932975f, 0.992290591f, 0.125454983f, + 0.992099313f, 0.126976696f, 0.991905700f, 0.128498111f, 0.991709754f, + 0.130019223f, 0.991511473f, 0.131540029f, 0.991310860f, 0.133060525f, + 0.991107914f, 0.134580709f, 0.990902635f, 0.136100575f, 0.990695025f, + 0.137620122f, 0.990485084f, 0.139139344f, 0.990272812f, 0.140658239f, + 0.990058210f, 0.142176804f, 0.989841278f, 0.143695033f, 0.989622017f, + 0.145212925f, 0.989400428f, 0.146730474f, 0.989176510f, 0.148247679f, + 0.988950265f, 0.149764535f, 0.988721692f, 0.151281038f, 0.988490793f, + 0.152797185f, 0.988257568f, 0.154312973f, 0.988022017f, 0.155828398f, + 0.987784142f, 0.157343456f, 0.987543942f, 0.158858143f, 0.987301418f, + 0.160372457f, 0.987056571f, 0.161886394f, 0.986809402f, 0.163399949f, + 0.986559910f, 0.164913120f, 0.986308097f, 0.166425904f, 0.986053963f, + 0.167938295f, 0.985797509f, 0.169450291f, 0.985538735f, 0.170961889f, + 0.985277642f, 0.172473084f, 0.985014231f, 0.173983873f, 0.984748502f, + 0.175494253f, 0.984480455f, 0.177004220f, 0.984210092f, 0.178513771f, + 0.983937413f, 0.180022901f, 0.983662419f, 0.181531608f, 0.983385110f, + 0.183039888f, 0.983105487f, 0.184547737f, 0.982823551f, 0.186055152f, + 0.982539302f, 0.187562129f, 0.982252741f, 0.189068664f, 0.981963869f, + 0.190574755f, 0.981672686f, 0.192080397f, 0.981379193f, 0.193585587f, + 0.981083391f, 0.195090322f, 0.980785280f, 0.196594598f, 0.980484862f, + 0.198098411f, 0.980182136f, 0.199601758f, 0.979877104f, 0.201104635f, + 0.979569766f, 0.202607039f, 0.979260123f, 0.204108966f, 0.978948175f, + 0.205610413f, 0.978633924f, 0.207111376f, 0.978317371f, 0.208611852f, + 0.977998515f, 0.210111837f, 0.977677358f, 0.211611327f, 0.977353900f, + 0.213110320f, 0.977028143f, 0.214608811f, 0.976700086f, 0.216106797f, + 0.976369731f, 0.217604275f, 0.976037079f, 0.219101240f, 0.975702130f, + 0.220597690f, 0.975364885f, 0.222093621f, 0.975025345f, 0.223589029f, + 0.974683511f, 0.225083911f, 0.974339383f, 0.226578264f, 0.973992962f, + 0.228072083f, 0.973644250f, 0.229565366f, 0.973293246f, 0.231058108f, + 0.972939952f, 0.232550307f, 0.972584369f, 0.234041959f, 0.972226497f, + 0.235533059f, 0.971866337f, 0.237023606f, 0.971503891f, 0.238513595f, + 0.971139158f, 0.240003022f, 0.970772141f, 0.241491885f, 0.970402839f, + 0.242980180f, 0.970031253f, 0.244467903f, 0.969657385f, 0.245955050f, + 0.969281235f, 0.247441619f, 0.968902805f, 0.248927606f, 0.968522094f, + 0.250413007f, 0.968139105f, 0.251897818f, 0.967753837f, 0.253382037f, + 0.967366292f, 0.254865660f, 0.966976471f, 0.256348682f, 0.966584374f, + 0.257831102f, 0.966190003f, 0.259312915f, 0.965793359f, 0.260794118f, + 0.965394442f, 0.262274707f, 0.964993253f, 0.263754679f, 0.964589793f, + 0.265234030f, 0.964184064f, 0.266712757f, 0.963776066f, 0.268190857f, + 0.963365800f, 0.269668326f, 0.962953267f, 0.271145160f, 0.962538468f, + 0.272621355f, 0.962121404f, 0.274096910f, 0.961702077f, 0.275571819f, + 0.961280486f, 0.277046080f, 0.960856633f, 0.278519689f, 0.960430519f, + 0.279992643f, 0.960002146f, 0.281464938f, 0.959571513f, 0.282936570f, + 0.959138622f, 0.284407537f, 0.958703475f, 0.285877835f, 0.958266071f, + 0.287347460f, 0.957826413f, 0.288816408f, 0.957384501f, 0.290284677f, + 0.956940336f, 0.291752263f, 0.956493919f, 0.293219163f, 0.956045251f, + 0.294685372f, 0.955594334f, 0.296150888f, 0.955141168f, 0.297615707f, + 0.954685755f, 0.299079826f, 0.954228095f, 0.300543241f, 0.953768190f, + 0.302005949f, 0.953306040f, 0.303467947f, 0.952841648f, 0.304929230f, + 0.952375013f, 0.306389795f, 0.951906137f, 0.307849640f, 0.951435021f, + 0.309308760f, 0.950961666f, 0.310767153f, 0.950486074f, 0.312224814f, + 0.950008245f, 0.313681740f, 0.949528181f, 0.315137929f, 0.949045882f, + 0.316593376f, 0.948561350f, 0.318048077f, 0.948074586f, 0.319502031f, + 0.947585591f, 0.320955232f, 0.947094366f, 0.322407679f, 0.946600913f, + 0.323859367f, 0.946105232f, 0.325310292f, 0.945607325f, 0.326760452f, + 0.945107193f, 0.328209844f, 0.944604837f, 0.329658463f, 0.944100258f, + 0.331106306f, 0.943593458f, 0.332553370f, 0.943084437f, 0.333999651f, + 0.942573198f, 0.335445147f, 0.942059740f, 0.336889853f, 0.941544065f, + 0.338333767f, 0.941026175f, 0.339776884f, 0.940506071f, 0.341219202f, + 0.939983753f, 0.342660717f, 0.939459224f, 0.344101426f, 0.938932484f, + 0.345541325f, 0.938403534f, 0.346980411f, 0.937872376f, 0.348418680f, + 0.937339012f, 0.349856130f, 0.936803442f, 0.351292756f, 0.936265667f, + 0.352728556f, 0.935725689f, 0.354163525f, 0.935183510f, 0.355597662f, + 0.934639130f, 0.357030961f, 0.934092550f, 0.358463421f, 0.933543773f, + 0.359895037f, 0.932992799f, 0.361325806f, 0.932439629f, 0.362755724f, + 0.931884266f, 0.364184790f, 0.931326709f, 0.365612998f, 0.930766961f, + 0.367040346f, 0.930205023f, 0.368466830f, 0.929640896f, 0.369892447f, + 0.929074581f, 0.371317194f, 0.928506080f, 0.372741067f, 0.927935395f, + 0.374164063f, 0.927362526f, 0.375586178f, 0.926787474f, 0.377007410f, + 0.926210242f, 0.378427755f, 0.925630831f, 0.379847209f, 0.925049241f, + 0.381265769f, 0.924465474f, 0.382683432f, 0.923879533f, 0.384100195f, + 0.923291417f, 0.385516054f, 0.922701128f, 0.386931006f, 0.922108669f, + 0.388345047f, 0.921514039f, 0.389758174f, 0.920917242f, 0.391170384f, + 0.920318277f, 0.392581674f, 0.919717146f, 0.393992040f, 0.919113852f, + 0.395401479f, 0.918508394f, 0.396809987f, 0.917900776f, 0.398217562f, + 0.917290997f, 0.399624200f, 0.916679060f, 0.401029897f, 0.916064966f, + 0.402434651f, 0.915448716f, 0.403838458f, 0.914830312f, 0.405241314f, + 0.914209756f, 0.406643217f, 0.913587048f, 0.408044163f, 0.912962190f, + 0.409444149f, 0.912335185f, 0.410843171f, 0.911706032f, 0.412241227f, + 0.911074734f, 0.413638312f, 0.910441292f, 0.415034424f, 0.909805708f, + 0.416429560f, 0.909167983f, 0.417823716f, 0.908528119f, 0.419216888f, + 0.907886116f, 0.420609074f, 0.907241978f, 0.422000271f, 0.906595705f, + 0.423390474f, 0.905947298f, 0.424779681f, 0.905296759f, 0.426167889f, + 0.904644091f, 0.427555093f, 0.903989293f, 0.428941292f, 0.903332368f, + 0.430326481f, 0.902673318f, 0.431710658f, 0.902012144f, 0.433093819f, + 0.901348847f, 0.434475961f, 0.900683429f, 0.435857080f, 0.900015892f, + 0.437237174f, 0.899346237f, 0.438616239f, 0.898674466f, 0.439994271f, + 0.898000580f, 0.441371269f, 0.897324581f, 0.442747228f, 0.896646470f, + 0.444122145f, 0.895966250f, 0.445496017f, 0.895283921f, 0.446868840f, + 0.894599486f, 0.448240612f, 0.893912945f, 0.449611330f, 0.893224301f, + 0.450980989f, 0.892533555f, 0.452349587f, 0.891840709f, 0.453717121f, + 0.891145765f, 0.455083587f, 0.890448723f, 0.456448982f, 0.889749586f, + 0.457813304f, 0.889048356f, 0.459176548f, 0.888345033f, 0.460538711f, + 0.887639620f, 0.461899791f, 0.886932119f, 0.463259784f, 0.886222530f, + 0.464618686f, 0.885510856f, 0.465976496f, 0.884797098f, 0.467333209f, + 0.884081259f, 0.468688822f, 0.883363339f, 0.470043332f, 0.882643340f, + 0.471396737f, 0.881921264f, 0.472749032f, 0.881197113f, 0.474100215f, + 0.880470889f, 0.475450282f, 0.879742593f, 0.476799230f, 0.879012226f, + 0.478147056f, 0.878279792f, 0.479493758f, 0.877545290f, 0.480839331f, + 0.876808724f, 0.482183772f, 0.876070094f, 0.483527079f, 0.875329403f, + 0.484869248f, 0.874586652f, 0.486210276f, 0.873841843f, 0.487550160f, + 0.873094978f, 0.488888897f, 0.872346059f, 0.490226483f, 0.871595087f, + 0.491562916f, 0.870842063f, 0.492898192f, 0.870086991f, 0.494232309f, + 0.869329871f, 0.495565262f, 0.868570706f, 0.496897049f, 0.867809497f, + 0.498227667f, 0.867046246f, 0.499557113f, 0.866280954f, 0.500885383f, + 0.865513624f, 0.502212474f, 0.864744258f, 0.503538384f, 0.863972856f, + 0.504863109f, 0.863199422f, 0.506186645f, 0.862423956f, 0.507508991f, + 0.861646461f, 0.508830143f, 0.860866939f, 0.510150097f, 0.860085390f, + 0.511468850f, 0.859301818f, 0.512786401f, 0.858516224f, 0.514102744f, + 0.857728610f, 0.515417878f, 0.856938977f, 0.516731799f, 0.856147328f, + 0.518044504f, 0.855353665f, 0.519355990f, 0.854557988f, 0.520666254f, + 0.853760301f, 0.521975293f, 0.852960605f, 0.523283103f, 0.852158902f, + 0.524589683f, 0.851355193f, 0.525895027f, 0.850549481f, 0.527199135f, + 0.849741768f, 0.528502002f, 0.848932055f, 0.529803625f, 0.848120345f, + 0.531104001f, 0.847306639f, 0.532403128f, 0.846490939f, 0.533701002f, + 0.845673247f, 0.534997620f, 0.844853565f, 0.536292979f, 0.844031895f, + 0.537587076f, 0.843208240f, 0.538879909f, 0.842382600f, 0.540171473f, + 0.841554977f, 0.541461766f, 0.840725375f, 0.542750785f, 0.839893794f, + 0.544038527f, 0.839060237f, 0.545324988f, 0.838224706f, 0.546610167f, + 0.837387202f, 0.547894059f, 0.836547727f, 0.549176662f, 0.835706284f, + 0.550457973f, 0.834862875f, 0.551737988f, 0.834017501f, 0.553016706f, + 0.833170165f, 0.554294121f, 0.832320868f, 0.555570233f, 0.831469612f, + 0.556845037f, 0.830616400f, 0.558118531f, 0.829761234f, 0.559390712f, + 0.828904115f, 0.560661576f, 0.828045045f, 0.561931121f, 0.827184027f, + 0.563199344f, 0.826321063f, 0.564466242f, 0.825456154f, 0.565731811f, + 0.824589303f, 0.566996049f, 0.823720511f, 0.568258953f, 0.822849781f, + 0.569520519f, 0.821977115f, 0.570780746f, 0.821102515f, 0.572039629f, + 0.820225983f, 0.573297167f, 0.819347520f, 0.574553355f, 0.818467130f, + 0.575808191f, 0.817584813f, 0.577061673f, 0.816700573f, 0.578313796f, + 0.815814411f, 0.579564559f, 0.814926329f, 0.580813958f, 0.814036330f, + 0.582061990f, 0.813144415f, 0.583308653f, 0.812250587f, 0.584553943f, + 0.811354847f, 0.585797857f, 0.810457198f, 0.587040394f, 0.809557642f, + 0.588281548f, 0.808656182f, 0.589521319f, 0.807752818f, 0.590759702f, + 0.806847554f, 0.591996695f, 0.805940391f, 0.593232295f, 0.805031331f, + 0.594466499f, 0.804120377f, 0.595699304f, 0.803207531f, 0.596930708f, + 0.802292796f, 0.598160707f, 0.801376172f, 0.599389298f, 0.800457662f, + 0.600616479f, 0.799537269f, 0.601842247f, 0.798614995f, 0.603066599f, + 0.797690841f, 0.604289531f, 0.796764810f, 0.605511041f, 0.795836905f, + 0.606731127f, 0.794907126f, 0.607949785f, 0.793975478f, 0.609167012f, + 0.793041960f, 0.610382806f, 0.792106577f, 0.611597164f, 0.791169330f, + 0.612810082f, 0.790230221f, 0.614021559f, 0.789289253f, 0.615231591f, + 0.788346428f, 0.616440175f, 0.787401747f, 0.617647308f, 0.786455214f, + 0.618852988f, 0.785506830f, 0.620057212f, 0.784556597f, 0.621259977f, + 0.783604519f, 0.622461279f, 0.782650596f, 0.623661118f, 0.781694832f, + 0.624859488f, 0.780737229f, 0.626056388f, 0.779777788f, 0.627251815f, + 0.778816512f, 0.628445767f, 0.777853404f, 0.629638239f, 0.776888466f, + 0.630829230f, 0.775921699f, 0.632018736f, 0.774953107f, 0.633206755f, + 0.773982691f, 0.634393284f, 0.773010453f, 0.635578320f, 0.772036397f, + 0.636761861f, 0.771060524f, 0.637943904f, 0.770082837f, 0.639124445f, + 0.769103338f, 0.640303482f, 0.768122029f, 0.641481013f, 0.767138912f, + 0.642657034f, 0.766153990f, 0.643831543f, 0.765167266f, 0.645004537f, + 0.764178741f, 0.646176013f, 0.763188417f, 0.647345969f, 0.762196298f, + 0.648514401f, 0.761202385f, 0.649681307f, 0.760206682f, 0.650846685f, + 0.759209189f, 0.652010531f, 0.758209910f, 0.653172843f, 0.757208847f, + 0.654333618f, 0.756206001f, 0.655492853f, 0.755201377f, 0.656650546f, + 0.754194975f, 0.657806693f, 0.753186799f, 0.658961293f, 0.752176850f, + 0.660114342f, 0.751165132f, 0.661265838f, 0.750151646f, 0.662415778f, + 0.749136395f, 0.663564159f, 0.748119380f, 0.664710978f, 0.747100606f, + 0.665856234f, 0.746080074f, 0.666999922f, 0.745057785f, 0.668142041f, + 0.744033744f, 0.669282588f, 0.743007952f, 0.670421560f, 0.741980412f, + 0.671558955f, 0.740951125f, 0.672694769f, 0.739920095f, 0.673829000f, + 0.738887324f, 0.674961646f, 0.737852815f, 0.676092704f, 0.736816569f, + 0.677222170f, 0.735778589f, 0.678350043f, 0.734738878f, 0.679476320f, + 0.733697438f, 0.680600998f, 0.732654272f, 0.681724074f, 0.731609381f, + 0.682845546f, 0.730562769f, 0.683965412f, 0.729514438f, 0.685083668f, + 0.728464390f, 0.686200312f, 0.727412629f, 0.687315341f, 0.726359155f, + 0.688428753f, 0.725303972f, 0.689540545f, 0.724247083f, 0.690650714f, + 0.723188489f, 0.691759258f, 0.722128194f, 0.692866175f, 0.721066199f, + 0.693971461f, 0.720002508f, 0.695075114f, 0.718937122f, 0.696177131f, + 0.717870045f, 0.697277511f, 0.716801279f, 0.698376249f, 0.715730825f, + 0.699473345f, 0.714658688f, 0.700568794f, 0.713584869f, 0.701662595f, + 0.712509371f, 0.702754744f, 0.711432196f, 0.703845241f, 0.710353347f, + 0.704934080f, 0.709272826f, 0.706021261f, 0.708190637f, 0.707106781f, + 0.707106781f, 0.708190637f, 0.706021261f, 0.709272826f, 0.704934080f, + 0.710353347f, 0.703845241f, 0.711432196f, 0.702754744f, 0.712509371f, + 0.701662595f, 0.713584869f, 0.700568794f, 0.714658688f, 0.699473345f, + 0.715730825f, 0.698376249f, 0.716801279f, 0.697277511f, 0.717870045f, + 0.696177131f, 0.718937122f, 0.695075114f, 0.720002508f, 0.693971461f, + 0.721066199f, 0.692866175f, 0.722128194f, 0.691759258f, 0.723188489f, + 0.690650714f, 0.724247083f, 0.689540545f, 0.725303972f, 0.688428753f, + 0.726359155f, 0.687315341f, 0.727412629f, 0.686200312f, 0.728464390f, + 0.685083668f, 0.729514438f, 0.683965412f, 0.730562769f, 0.682845546f, + 0.731609381f, 0.681724074f, 0.732654272f, 0.680600998f, 0.733697438f, + 0.679476320f, 0.734738878f, 0.678350043f, 0.735778589f, 0.677222170f, + 0.736816569f, 0.676092704f, 0.737852815f, 0.674961646f, 0.738887324f, + 0.673829000f, 0.739920095f, 0.672694769f, 0.740951125f, 0.671558955f, + 0.741980412f, 0.670421560f, 0.743007952f, 0.669282588f, 0.744033744f, + 0.668142041f, 0.745057785f, 0.666999922f, 0.746080074f, 0.665856234f, + 0.747100606f, 0.664710978f, 0.748119380f, 0.663564159f, 0.749136395f, + 0.662415778f, 0.750151646f, 0.661265838f, 0.751165132f, 0.660114342f, + 0.752176850f, 0.658961293f, 0.753186799f, 0.657806693f, 0.754194975f, + 0.656650546f, 0.755201377f, 0.655492853f, 0.756206001f, 0.654333618f, + 0.757208847f, 0.653172843f, 0.758209910f, 0.652010531f, 0.759209189f, + 0.650846685f, 0.760206682f, 0.649681307f, 0.761202385f, 0.648514401f, + 0.762196298f, 0.647345969f, 0.763188417f, 0.646176013f, 0.764178741f, + 0.645004537f, 0.765167266f, 0.643831543f, 0.766153990f, 0.642657034f, + 0.767138912f, 0.641481013f, 0.768122029f, 0.640303482f, 0.769103338f, + 0.639124445f, 0.770082837f, 0.637943904f, 0.771060524f, 0.636761861f, + 0.772036397f, 0.635578320f, 0.773010453f, 0.634393284f, 0.773982691f, + 0.633206755f, 0.774953107f, 0.632018736f, 0.775921699f, 0.630829230f, + 0.776888466f, 0.629638239f, 0.777853404f, 0.628445767f, 0.778816512f, + 0.627251815f, 0.779777788f, 0.626056388f, 0.780737229f, 0.624859488f, + 0.781694832f, 0.623661118f, 0.782650596f, 0.622461279f, 0.783604519f, + 0.621259977f, 0.784556597f, 0.620057212f, 0.785506830f, 0.618852988f, + 0.786455214f, 0.617647308f, 0.787401747f, 0.616440175f, 0.788346428f, + 0.615231591f, 0.789289253f, 0.614021559f, 0.790230221f, 0.612810082f, + 0.791169330f, 0.611597164f, 0.792106577f, 0.610382806f, 0.793041960f, + 0.609167012f, 0.793975478f, 0.607949785f, 0.794907126f, 0.606731127f, + 0.795836905f, 0.605511041f, 0.796764810f, 0.604289531f, 0.797690841f, + 0.603066599f, 0.798614995f, 0.601842247f, 0.799537269f, 0.600616479f, + 0.800457662f, 0.599389298f, 0.801376172f, 0.598160707f, 0.802292796f, + 0.596930708f, 0.803207531f, 0.595699304f, 0.804120377f, 0.594466499f, + 0.805031331f, 0.593232295f, 0.805940391f, 0.591996695f, 0.806847554f, + 0.590759702f, 0.807752818f, 0.589521319f, 0.808656182f, 0.588281548f, + 0.809557642f, 0.587040394f, 0.810457198f, 0.585797857f, 0.811354847f, + 0.584553943f, 0.812250587f, 0.583308653f, 0.813144415f, 0.582061990f, + 0.814036330f, 0.580813958f, 0.814926329f, 0.579564559f, 0.815814411f, + 0.578313796f, 0.816700573f, 0.577061673f, 0.817584813f, 0.575808191f, + 0.818467130f, 0.574553355f, 0.819347520f, 0.573297167f, 0.820225983f, + 0.572039629f, 0.821102515f, 0.570780746f, 0.821977115f, 0.569520519f, + 0.822849781f, 0.568258953f, 0.823720511f, 0.566996049f, 0.824589303f, + 0.565731811f, 0.825456154f, 0.564466242f, 0.826321063f, 0.563199344f, + 0.827184027f, 0.561931121f, 0.828045045f, 0.560661576f, 0.828904115f, + 0.559390712f, 0.829761234f, 0.558118531f, 0.830616400f, 0.556845037f, + 0.831469612f, 0.555570233f, 0.832320868f, 0.554294121f, 0.833170165f, + 0.553016706f, 0.834017501f, 0.551737988f, 0.834862875f, 0.550457973f, + 0.835706284f, 0.549176662f, 0.836547727f, 0.547894059f, 0.837387202f, + 0.546610167f, 0.838224706f, 0.545324988f, 0.839060237f, 0.544038527f, + 0.839893794f, 0.542750785f, 0.840725375f, 0.541461766f, 0.841554977f, + 0.540171473f, 0.842382600f, 0.538879909f, 0.843208240f, 0.537587076f, + 0.844031895f, 0.536292979f, 0.844853565f, 0.534997620f, 0.845673247f, + 0.533701002f, 0.846490939f, 0.532403128f, 0.847306639f, 0.531104001f, + 0.848120345f, 0.529803625f, 0.848932055f, 0.528502002f, 0.849741768f, + 0.527199135f, 0.850549481f, 0.525895027f, 0.851355193f, 0.524589683f, + 0.852158902f, 0.523283103f, 0.852960605f, 0.521975293f, 0.853760301f, + 0.520666254f, 0.854557988f, 0.519355990f, 0.855353665f, 0.518044504f, + 0.856147328f, 0.516731799f, 0.856938977f, 0.515417878f, 0.857728610f, + 0.514102744f, 0.858516224f, 0.512786401f, 0.859301818f, 0.511468850f, + 0.860085390f, 0.510150097f, 0.860866939f, 0.508830143f, 0.861646461f, + 0.507508991f, 0.862423956f, 0.506186645f, 0.863199422f, 0.504863109f, + 0.863972856f, 0.503538384f, 0.864744258f, 0.502212474f, 0.865513624f, + 0.500885383f, 0.866280954f, 0.499557113f, 0.867046246f, 0.498227667f, + 0.867809497f, 0.496897049f, 0.868570706f, 0.495565262f, 0.869329871f, + 0.494232309f, 0.870086991f, 0.492898192f, 0.870842063f, 0.491562916f, + 0.871595087f, 0.490226483f, 0.872346059f, 0.488888897f, 0.873094978f, + 0.487550160f, 0.873841843f, 0.486210276f, 0.874586652f, 0.484869248f, + 0.875329403f, 0.483527079f, 0.876070094f, 0.482183772f, 0.876808724f, + 0.480839331f, 0.877545290f, 0.479493758f, 0.878279792f, 0.478147056f, + 0.879012226f, 0.476799230f, 0.879742593f, 0.475450282f, 0.880470889f, + 0.474100215f, 0.881197113f, 0.472749032f, 0.881921264f, 0.471396737f, + 0.882643340f, 0.470043332f, 0.883363339f, 0.468688822f, 0.884081259f, + 0.467333209f, 0.884797098f, 0.465976496f, 0.885510856f, 0.464618686f, + 0.886222530f, 0.463259784f, 0.886932119f, 0.461899791f, 0.887639620f, + 0.460538711f, 0.888345033f, 0.459176548f, 0.889048356f, 0.457813304f, + 0.889749586f, 0.456448982f, 0.890448723f, 0.455083587f, 0.891145765f, + 0.453717121f, 0.891840709f, 0.452349587f, 0.892533555f, 0.450980989f, + 0.893224301f, 0.449611330f, 0.893912945f, 0.448240612f, 0.894599486f, + 0.446868840f, 0.895283921f, 0.445496017f, 0.895966250f, 0.444122145f, + 0.896646470f, 0.442747228f, 0.897324581f, 0.441371269f, 0.898000580f, + 0.439994271f, 0.898674466f, 0.438616239f, 0.899346237f, 0.437237174f, + 0.900015892f, 0.435857080f, 0.900683429f, 0.434475961f, 0.901348847f, + 0.433093819f, 0.902012144f, 0.431710658f, 0.902673318f, 0.430326481f, + 0.903332368f, 0.428941292f, 0.903989293f, 0.427555093f, 0.904644091f, + 0.426167889f, 0.905296759f, 0.424779681f, 0.905947298f, 0.423390474f, + 0.906595705f, 0.422000271f, 0.907241978f, 0.420609074f, 0.907886116f, + 0.419216888f, 0.908528119f, 0.417823716f, 0.909167983f, 0.416429560f, + 0.909805708f, 0.415034424f, 0.910441292f, 0.413638312f, 0.911074734f, + 0.412241227f, 0.911706032f, 0.410843171f, 0.912335185f, 0.409444149f, + 0.912962190f, 0.408044163f, 0.913587048f, 0.406643217f, 0.914209756f, + 0.405241314f, 0.914830312f, 0.403838458f, 0.915448716f, 0.402434651f, + 0.916064966f, 0.401029897f, 0.916679060f, 0.399624200f, 0.917290997f, + 0.398217562f, 0.917900776f, 0.396809987f, 0.918508394f, 0.395401479f, + 0.919113852f, 0.393992040f, 0.919717146f, 0.392581674f, 0.920318277f, + 0.391170384f, 0.920917242f, 0.389758174f, 0.921514039f, 0.388345047f, + 0.922108669f, 0.386931006f, 0.922701128f, 0.385516054f, 0.923291417f, + 0.384100195f, 0.923879533f, 0.382683432f, 0.924465474f, 0.381265769f, + 0.925049241f, 0.379847209f, 0.925630831f, 0.378427755f, 0.926210242f, + 0.377007410f, 0.926787474f, 0.375586178f, 0.927362526f, 0.374164063f, + 0.927935395f, 0.372741067f, 0.928506080f, 0.371317194f, 0.929074581f, + 0.369892447f, 0.929640896f, 0.368466830f, 0.930205023f, 0.367040346f, + 0.930766961f, 0.365612998f, 0.931326709f, 0.364184790f, 0.931884266f, + 0.362755724f, 0.932439629f, 0.361325806f, 0.932992799f, 0.359895037f, + 0.933543773f, 0.358463421f, 0.934092550f, 0.357030961f, 0.934639130f, + 0.355597662f, 0.935183510f, 0.354163525f, 0.935725689f, 0.352728556f, + 0.936265667f, 0.351292756f, 0.936803442f, 0.349856130f, 0.937339012f, + 0.348418680f, 0.937872376f, 0.346980411f, 0.938403534f, 0.345541325f, + 0.938932484f, 0.344101426f, 0.939459224f, 0.342660717f, 0.939983753f, + 0.341219202f, 0.940506071f, 0.339776884f, 0.941026175f, 0.338333767f, + 0.941544065f, 0.336889853f, 0.942059740f, 0.335445147f, 0.942573198f, + 0.333999651f, 0.943084437f, 0.332553370f, 0.943593458f, 0.331106306f, + 0.944100258f, 0.329658463f, 0.944604837f, 0.328209844f, 0.945107193f, + 0.326760452f, 0.945607325f, 0.325310292f, 0.946105232f, 0.323859367f, + 0.946600913f, 0.322407679f, 0.947094366f, 0.320955232f, 0.947585591f, + 0.319502031f, 0.948074586f, 0.318048077f, 0.948561350f, 0.316593376f, + 0.949045882f, 0.315137929f, 0.949528181f, 0.313681740f, 0.950008245f, + 0.312224814f, 0.950486074f, 0.310767153f, 0.950961666f, 0.309308760f, + 0.951435021f, 0.307849640f, 0.951906137f, 0.306389795f, 0.952375013f, + 0.304929230f, 0.952841648f, 0.303467947f, 0.953306040f, 0.302005949f, + 0.953768190f, 0.300543241f, 0.954228095f, 0.299079826f, 0.954685755f, + 0.297615707f, 0.955141168f, 0.296150888f, 0.955594334f, 0.294685372f, + 0.956045251f, 0.293219163f, 0.956493919f, 0.291752263f, 0.956940336f, + 0.290284677f, 0.957384501f, 0.288816408f, 0.957826413f, 0.287347460f, + 0.958266071f, 0.285877835f, 0.958703475f, 0.284407537f, 0.959138622f, + 0.282936570f, 0.959571513f, 0.281464938f, 0.960002146f, 0.279992643f, + 0.960430519f, 0.278519689f, 0.960856633f, 0.277046080f, 0.961280486f, + 0.275571819f, 0.961702077f, 0.274096910f, 0.962121404f, 0.272621355f, + 0.962538468f, 0.271145160f, 0.962953267f, 0.269668326f, 0.963365800f, + 0.268190857f, 0.963776066f, 0.266712757f, 0.964184064f, 0.265234030f, + 0.964589793f, 0.263754679f, 0.964993253f, 0.262274707f, 0.965394442f, + 0.260794118f, 0.965793359f, 0.259312915f, 0.966190003f, 0.257831102f, + 0.966584374f, 0.256348682f, 0.966976471f, 0.254865660f, 0.967366292f, + 0.253382037f, 0.967753837f, 0.251897818f, 0.968139105f, 0.250413007f, + 0.968522094f, 0.248927606f, 0.968902805f, 0.247441619f, 0.969281235f, + 0.245955050f, 0.969657385f, 0.244467903f, 0.970031253f, 0.242980180f, + 0.970402839f, 0.241491885f, 0.970772141f, 0.240003022f, 0.971139158f, + 0.238513595f, 0.971503891f, 0.237023606f, 0.971866337f, 0.235533059f, + 0.972226497f, 0.234041959f, 0.972584369f, 0.232550307f, 0.972939952f, + 0.231058108f, 0.973293246f, 0.229565366f, 0.973644250f, 0.228072083f, + 0.973992962f, 0.226578264f, 0.974339383f, 0.225083911f, 0.974683511f, + 0.223589029f, 0.975025345f, 0.222093621f, 0.975364885f, 0.220597690f, + 0.975702130f, 0.219101240f, 0.976037079f, 0.217604275f, 0.976369731f, + 0.216106797f, 0.976700086f, 0.214608811f, 0.977028143f, 0.213110320f, + 0.977353900f, 0.211611327f, 0.977677358f, 0.210111837f, 0.977998515f, + 0.208611852f, 0.978317371f, 0.207111376f, 0.978633924f, 0.205610413f, + 0.978948175f, 0.204108966f, 0.979260123f, 0.202607039f, 0.979569766f, + 0.201104635f, 0.979877104f, 0.199601758f, 0.980182136f, 0.198098411f, + 0.980484862f, 0.196594598f, 0.980785280f, 0.195090322f, 0.981083391f, + 0.193585587f, 0.981379193f, 0.192080397f, 0.981672686f, 0.190574755f, + 0.981963869f, 0.189068664f, 0.982252741f, 0.187562129f, 0.982539302f, + 0.186055152f, 0.982823551f, 0.184547737f, 0.983105487f, 0.183039888f, + 0.983385110f, 0.181531608f, 0.983662419f, 0.180022901f, 0.983937413f, + 0.178513771f, 0.984210092f, 0.177004220f, 0.984480455f, 0.175494253f, + 0.984748502f, 0.173983873f, 0.985014231f, 0.172473084f, 0.985277642f, + 0.170961889f, 0.985538735f, 0.169450291f, 0.985797509f, 0.167938295f, + 0.986053963f, 0.166425904f, 0.986308097f, 0.164913120f, 0.986559910f, + 0.163399949f, 0.986809402f, 0.161886394f, 0.987056571f, 0.160372457f, + 0.987301418f, 0.158858143f, 0.987543942f, 0.157343456f, 0.987784142f, + 0.155828398f, 0.988022017f, 0.154312973f, 0.988257568f, 0.152797185f, + 0.988490793f, 0.151281038f, 0.988721692f, 0.149764535f, 0.988950265f, + 0.148247679f, 0.989176510f, 0.146730474f, 0.989400428f, 0.145212925f, + 0.989622017f, 0.143695033f, 0.989841278f, 0.142176804f, 0.990058210f, + 0.140658239f, 0.990272812f, 0.139139344f, 0.990485084f, 0.137620122f, + 0.990695025f, 0.136100575f, 0.990902635f, 0.134580709f, 0.991107914f, + 0.133060525f, 0.991310860f, 0.131540029f, 0.991511473f, 0.130019223f, + 0.991709754f, 0.128498111f, 0.991905700f, 0.126976696f, 0.992099313f, + 0.125454983f, 0.992290591f, 0.123932975f, 0.992479535f, 0.122410675f, + 0.992666142f, 0.120888087f, 0.992850414f, 0.119365215f, 0.993032350f, + 0.117842062f, 0.993211949f, 0.116318631f, 0.993389211f, 0.114794927f, + 0.993564136f, 0.113270952f, 0.993736722f, 0.111746711f, 0.993906970f, + 0.110222207f, 0.994074879f, 0.108697444f, 0.994240449f, 0.107172425f, + 0.994403680f, 0.105647154f, 0.994564571f, 0.104121634f, 0.994723121f, + 0.102595869f, 0.994879331f, 0.101069863f, 0.995033199f, 0.099543619f, + 0.995184727f, 0.098017140f, 0.995333912f, 0.096490431f, 0.995480755f, + 0.094963495f, 0.995625256f, 0.093436336f, 0.995767414f, 0.091908956f, + 0.995907229f, 0.090381361f, 0.996044701f, 0.088853553f, 0.996179829f, + 0.087325535f, 0.996312612f, 0.085797312f, 0.996443051f, 0.084268888f, + 0.996571146f, 0.082740265f, 0.996696895f, 0.081211447f, 0.996820299f, + 0.079682438f, 0.996941358f, 0.078153242f, 0.997060070f, 0.076623861f, + 0.997176437f, 0.075094301f, 0.997290457f, 0.073564564f, 0.997402130f, + 0.072034653f, 0.997511456f, 0.070504573f, 0.997618435f, 0.068974328f, + 0.997723067f, 0.067443920f, 0.997825350f, 0.065913353f, 0.997925286f, + 0.064382631f, 0.998022874f, 0.062851758f, 0.998118113f, 0.061320736f, + 0.998211003f, 0.059789571f, 0.998301545f, 0.058258265f, 0.998389737f, + 0.056726821f, 0.998475581f, 0.055195244f, 0.998559074f, 0.053663538f, + 0.998640218f, 0.052131705f, 0.998719012f, 0.050599749f, 0.998795456f, + 0.049067674f, 0.998869550f, 0.047535484f, 0.998941293f, 0.046003182f, + 0.999010686f, 0.044470772f, 0.999077728f, 0.042938257f, 0.999142419f, + 0.041405641f, 0.999204759f, 0.039872928f, 0.999264747f, 0.038340120f, + 0.999322385f, 0.036807223f, 0.999377670f, 0.035274239f, 0.999430605f, + 0.033741172f, 0.999481187f, 0.032208025f, 0.999529418f, 0.030674803f, + 0.999575296f, 0.029141509f, 0.999618822f, 0.027608146f, 0.999659997f, + 0.026074718f, 0.999698819f, 0.024541229f, 0.999735288f, 0.023007681f, + 0.999769405f, 0.021474080f, 0.999801170f, 0.019940429f, 0.999830582f, + 0.018406730f, 0.999857641f, 0.016872988f, 0.999882347f, 0.015339206f, + 0.999904701f, 0.013805389f, 0.999924702f, 0.012271538f, 0.999942350f, + 0.010737659f, 0.999957645f, 0.009203755f, 0.999970586f, 0.007669829f, + 0.999981175f, 0.006135885f, 0.999989411f, 0.004601926f, 0.999995294f, + 0.003067957f, 0.999998823f, 0.001533980f, 1.000000000f, 0.000000000f, + 0.999998823f, -0.001533980f, 0.999995294f, -0.003067957f, 0.999989411f, + -0.004601926f, 0.999981175f, -0.006135885f, 0.999970586f, -0.007669829f, + 0.999957645f, -0.009203755f, 0.999942350f, -0.010737659f, 0.999924702f, + -0.012271538f, 0.999904701f, -0.013805389f, 0.999882347f, -0.015339206f, + 0.999857641f, -0.016872988f, 0.999830582f, -0.018406730f, 0.999801170f, + -0.019940429f, 0.999769405f, -0.021474080f, 0.999735288f, -0.023007681f, + 0.999698819f, -0.024541229f, 0.999659997f, -0.026074718f, 0.999618822f, + -0.027608146f, 0.999575296f, -0.029141509f, 0.999529418f, -0.030674803f, + 0.999481187f, -0.032208025f, 0.999430605f, -0.033741172f, 0.999377670f, + -0.035274239f, 0.999322385f, -0.036807223f, 0.999264747f, -0.038340120f, + 0.999204759f, -0.039872928f, 0.999142419f, -0.041405641f, 0.999077728f, + -0.042938257f, 0.999010686f, -0.044470772f, 0.998941293f, -0.046003182f, + 0.998869550f, -0.047535484f, 0.998795456f, -0.049067674f, 0.998719012f, + -0.050599749f, 0.998640218f, -0.052131705f, 0.998559074f, -0.053663538f, + 0.998475581f, -0.055195244f, 0.998389737f, -0.056726821f, 0.998301545f, + -0.058258265f, 0.998211003f, -0.059789571f, 0.998118113f, -0.061320736f, + 0.998022874f, -0.062851758f, 0.997925286f, -0.064382631f, 0.997825350f, + -0.065913353f, 0.997723067f, -0.067443920f, 0.997618435f, -0.068974328f, + 0.997511456f, -0.070504573f, 0.997402130f, -0.072034653f, 0.997290457f, + -0.073564564f, 0.997176437f, -0.075094301f, 0.997060070f, -0.076623861f, + 0.996941358f, -0.078153242f, 0.996820299f, -0.079682438f, 0.996696895f, + -0.081211447f, 0.996571146f, -0.082740265f, 0.996443051f, -0.084268888f, + 0.996312612f, -0.085797312f, 0.996179829f, -0.087325535f, 0.996044701f, + -0.088853553f, 0.995907229f, -0.090381361f, 0.995767414f, -0.091908956f, + 0.995625256f, -0.093436336f, 0.995480755f, -0.094963495f, 0.995333912f, + -0.096490431f, 0.995184727f, -0.098017140f, 0.995033199f, -0.099543619f, + 0.994879331f, -0.101069863f, 0.994723121f, -0.102595869f, 0.994564571f, + -0.104121634f, 0.994403680f, -0.105647154f, 0.994240449f, -0.107172425f, + 0.994074879f, -0.108697444f, 0.993906970f, -0.110222207f, 0.993736722f, + -0.111746711f, 0.993564136f, -0.113270952f, 0.993389211f, -0.114794927f, + 0.993211949f, -0.116318631f, 0.993032350f, -0.117842062f, 0.992850414f, + -0.119365215f, 0.992666142f, -0.120888087f, 0.992479535f, -0.122410675f, + 0.992290591f, -0.123932975f, 0.992099313f, -0.125454983f, 0.991905700f, + -0.126976696f, 0.991709754f, -0.128498111f, 0.991511473f, -0.130019223f, + 0.991310860f, -0.131540029f, 0.991107914f, -0.133060525f, 0.990902635f, + -0.134580709f, 0.990695025f, -0.136100575f, 0.990485084f, -0.137620122f, + 0.990272812f, -0.139139344f, 0.990058210f, -0.140658239f, 0.989841278f, + -0.142176804f, 0.989622017f, -0.143695033f, 0.989400428f, -0.145212925f, + 0.989176510f, -0.146730474f, 0.988950265f, -0.148247679f, 0.988721692f, + -0.149764535f, 0.988490793f, -0.151281038f, 0.988257568f, -0.152797185f, + 0.988022017f, -0.154312973f, 0.987784142f, -0.155828398f, 0.987543942f, + -0.157343456f, 0.987301418f, -0.158858143f, 0.987056571f, -0.160372457f, + 0.986809402f, -0.161886394f, 0.986559910f, -0.163399949f, 0.986308097f, + -0.164913120f, 0.986053963f, -0.166425904f, 0.985797509f, -0.167938295f, + 0.985538735f, -0.169450291f, 0.985277642f, -0.170961889f, 0.985014231f, + -0.172473084f, 0.984748502f, -0.173983873f, 0.984480455f, -0.175494253f, + 0.984210092f, -0.177004220f, 0.983937413f, -0.178513771f, 0.983662419f, + -0.180022901f, 0.983385110f, -0.181531608f, 0.983105487f, -0.183039888f, + 0.982823551f, -0.184547737f, 0.982539302f, -0.186055152f, 0.982252741f, + -0.187562129f, 0.981963869f, -0.189068664f, 0.981672686f, -0.190574755f, + 0.981379193f, -0.192080397f, 0.981083391f, -0.193585587f, 0.980785280f, + -0.195090322f, 0.980484862f, -0.196594598f, 0.980182136f, -0.198098411f, + 0.979877104f, -0.199601758f, 0.979569766f, -0.201104635f, 0.979260123f, + -0.202607039f, 0.978948175f, -0.204108966f, 0.978633924f, -0.205610413f, + 0.978317371f, -0.207111376f, 0.977998515f, -0.208611852f, 0.977677358f, + -0.210111837f, 0.977353900f, -0.211611327f, 0.977028143f, -0.213110320f, + 0.976700086f, -0.214608811f, 0.976369731f, -0.216106797f, 0.976037079f, + -0.217604275f, 0.975702130f, -0.219101240f, 0.975364885f, -0.220597690f, + 0.975025345f, -0.222093621f, 0.974683511f, -0.223589029f, 0.974339383f, + -0.225083911f, 0.973992962f, -0.226578264f, 0.973644250f, -0.228072083f, + 0.973293246f, -0.229565366f, 0.972939952f, -0.231058108f, 0.972584369f, + -0.232550307f, 0.972226497f, -0.234041959f, 0.971866337f, -0.235533059f, + 0.971503891f, -0.237023606f, 0.971139158f, -0.238513595f, 0.970772141f, + -0.240003022f, 0.970402839f, -0.241491885f, 0.970031253f, -0.242980180f, + 0.969657385f, -0.244467903f, 0.969281235f, -0.245955050f, 0.968902805f, + -0.247441619f, 0.968522094f, -0.248927606f, 0.968139105f, -0.250413007f, + 0.967753837f, -0.251897818f, 0.967366292f, -0.253382037f, 0.966976471f, + -0.254865660f, 0.966584374f, -0.256348682f, 0.966190003f, -0.257831102f, + 0.965793359f, -0.259312915f, 0.965394442f, -0.260794118f, 0.964993253f, + -0.262274707f, 0.964589793f, -0.263754679f, 0.964184064f, -0.265234030f, + 0.963776066f, -0.266712757f, 0.963365800f, -0.268190857f, 0.962953267f, + -0.269668326f, 0.962538468f, -0.271145160f, 0.962121404f, -0.272621355f, + 0.961702077f, -0.274096910f, 0.961280486f, -0.275571819f, 0.960856633f, + -0.277046080f, 0.960430519f, -0.278519689f, 0.960002146f, -0.279992643f, + 0.959571513f, -0.281464938f, 0.959138622f, -0.282936570f, 0.958703475f, + -0.284407537f, 0.958266071f, -0.285877835f, 0.957826413f, -0.287347460f, + 0.957384501f, -0.288816408f, 0.956940336f, -0.290284677f, 0.956493919f, + -0.291752263f, 0.956045251f, -0.293219163f, 0.955594334f, -0.294685372f, + 0.955141168f, -0.296150888f, 0.954685755f, -0.297615707f, 0.954228095f, + -0.299079826f, 0.953768190f, -0.300543241f, 0.953306040f, -0.302005949f, + 0.952841648f, -0.303467947f, 0.952375013f, -0.304929230f, 0.951906137f, + -0.306389795f, 0.951435021f, -0.307849640f, 0.950961666f, -0.309308760f, + 0.950486074f, -0.310767153f, 0.950008245f, -0.312224814f, 0.949528181f, + -0.313681740f, 0.949045882f, -0.315137929f, 0.948561350f, -0.316593376f, + 0.948074586f, -0.318048077f, 0.947585591f, -0.319502031f, 0.947094366f, + -0.320955232f, 0.946600913f, -0.322407679f, 0.946105232f, -0.323859367f, + 0.945607325f, -0.325310292f, 0.945107193f, -0.326760452f, 0.944604837f, + -0.328209844f, 0.944100258f, -0.329658463f, 0.943593458f, -0.331106306f, + 0.943084437f, -0.332553370f, 0.942573198f, -0.333999651f, 0.942059740f, + -0.335445147f, 0.941544065f, -0.336889853f, 0.941026175f, -0.338333767f, + 0.940506071f, -0.339776884f, 0.939983753f, -0.341219202f, 0.939459224f, + -0.342660717f, 0.938932484f, -0.344101426f, 0.938403534f, -0.345541325f, + 0.937872376f, -0.346980411f, 0.937339012f, -0.348418680f, 0.936803442f, + -0.349856130f, 0.936265667f, -0.351292756f, 0.935725689f, -0.352728556f, + 0.935183510f, -0.354163525f, 0.934639130f, -0.355597662f, 0.934092550f, + -0.357030961f, 0.933543773f, -0.358463421f, 0.932992799f, -0.359895037f, + 0.932439629f, -0.361325806f, 0.931884266f, -0.362755724f, 0.931326709f, + -0.364184790f, 0.930766961f, -0.365612998f, 0.930205023f, -0.367040346f, + 0.929640896f, -0.368466830f, 0.929074581f, -0.369892447f, 0.928506080f, + -0.371317194f, 0.927935395f, -0.372741067f, 0.927362526f, -0.374164063f, + 0.926787474f, -0.375586178f, 0.926210242f, -0.377007410f, 0.925630831f, + -0.378427755f, 0.925049241f, -0.379847209f, 0.924465474f, -0.381265769f, + 0.923879533f, -0.382683432f, 0.923291417f, -0.384100195f, 0.922701128f, + -0.385516054f, 0.922108669f, -0.386931006f, 0.921514039f, -0.388345047f, + 0.920917242f, -0.389758174f, 0.920318277f, -0.391170384f, 0.919717146f, + -0.392581674f, 0.919113852f, -0.393992040f, 0.918508394f, -0.395401479f, + 0.917900776f, -0.396809987f, 0.917290997f, -0.398217562f, 0.916679060f, + -0.399624200f, 0.916064966f, -0.401029897f, 0.915448716f, -0.402434651f, + 0.914830312f, -0.403838458f, 0.914209756f, -0.405241314f, 0.913587048f, + -0.406643217f, 0.912962190f, -0.408044163f, 0.912335185f, -0.409444149f, + 0.911706032f, -0.410843171f, 0.911074734f, -0.412241227f, 0.910441292f, + -0.413638312f, 0.909805708f, -0.415034424f, 0.909167983f, -0.416429560f, + 0.908528119f, -0.417823716f, 0.907886116f, -0.419216888f, 0.907241978f, + -0.420609074f, 0.906595705f, -0.422000271f, 0.905947298f, -0.423390474f, + 0.905296759f, -0.424779681f, 0.904644091f, -0.426167889f, 0.903989293f, + -0.427555093f, 0.903332368f, -0.428941292f, 0.902673318f, -0.430326481f, + 0.902012144f, -0.431710658f, 0.901348847f, -0.433093819f, 0.900683429f, + -0.434475961f, 0.900015892f, -0.435857080f, 0.899346237f, -0.437237174f, + 0.898674466f, -0.438616239f, 0.898000580f, -0.439994271f, 0.897324581f, + -0.441371269f, 0.896646470f, -0.442747228f, 0.895966250f, -0.444122145f, + 0.895283921f, -0.445496017f, 0.894599486f, -0.446868840f, 0.893912945f, + -0.448240612f, 0.893224301f, -0.449611330f, 0.892533555f, -0.450980989f, + 0.891840709f, -0.452349587f, 0.891145765f, -0.453717121f, 0.890448723f, + -0.455083587f, 0.889749586f, -0.456448982f, 0.889048356f, -0.457813304f, + 0.888345033f, -0.459176548f, 0.887639620f, -0.460538711f, 0.886932119f, + -0.461899791f, 0.886222530f, -0.463259784f, 0.885510856f, -0.464618686f, + 0.884797098f, -0.465976496f, 0.884081259f, -0.467333209f, 0.883363339f, + -0.468688822f, 0.882643340f, -0.470043332f, 0.881921264f, -0.471396737f, + 0.881197113f, -0.472749032f, 0.880470889f, -0.474100215f, 0.879742593f, + -0.475450282f, 0.879012226f, -0.476799230f, 0.878279792f, -0.478147056f, + 0.877545290f, -0.479493758f, 0.876808724f, -0.480839331f, 0.876070094f, + -0.482183772f, 0.875329403f, -0.483527079f, 0.874586652f, -0.484869248f, + 0.873841843f, -0.486210276f, 0.873094978f, -0.487550160f, 0.872346059f, + -0.488888897f, 0.871595087f, -0.490226483f, 0.870842063f, -0.491562916f, + 0.870086991f, -0.492898192f, 0.869329871f, -0.494232309f, 0.868570706f, + -0.495565262f, 0.867809497f, -0.496897049f, 0.867046246f, -0.498227667f, + 0.866280954f, -0.499557113f, 0.865513624f, -0.500885383f, 0.864744258f, + -0.502212474f, 0.863972856f, -0.503538384f, 0.863199422f, -0.504863109f, + 0.862423956f, -0.506186645f, 0.861646461f, -0.507508991f, 0.860866939f, + -0.508830143f, 0.860085390f, -0.510150097f, 0.859301818f, -0.511468850f, + 0.858516224f, -0.512786401f, 0.857728610f, -0.514102744f, 0.856938977f, + -0.515417878f, 0.856147328f, -0.516731799f, 0.855353665f, -0.518044504f, + 0.854557988f, -0.519355990f, 0.853760301f, -0.520666254f, 0.852960605f, + -0.521975293f, 0.852158902f, -0.523283103f, 0.851355193f, -0.524589683f, + 0.850549481f, -0.525895027f, 0.849741768f, -0.527199135f, 0.848932055f, + -0.528502002f, 0.848120345f, -0.529803625f, 0.847306639f, -0.531104001f, + 0.846490939f, -0.532403128f, 0.845673247f, -0.533701002f, 0.844853565f, + -0.534997620f, 0.844031895f, -0.536292979f, 0.843208240f, -0.537587076f, + 0.842382600f, -0.538879909f, 0.841554977f, -0.540171473f, 0.840725375f, + -0.541461766f, 0.839893794f, -0.542750785f, 0.839060237f, -0.544038527f, + 0.838224706f, -0.545324988f, 0.837387202f, -0.546610167f, 0.836547727f, + -0.547894059f, 0.835706284f, -0.549176662f, 0.834862875f, -0.550457973f, + 0.834017501f, -0.551737988f, 0.833170165f, -0.553016706f, 0.832320868f, + -0.554294121f, 0.831469612f, -0.555570233f, 0.830616400f, -0.556845037f, + 0.829761234f, -0.558118531f, 0.828904115f, -0.559390712f, 0.828045045f, + -0.560661576f, 0.827184027f, -0.561931121f, 0.826321063f, -0.563199344f, + 0.825456154f, -0.564466242f, 0.824589303f, -0.565731811f, 0.823720511f, + -0.566996049f, 0.822849781f, -0.568258953f, 0.821977115f, -0.569520519f, + 0.821102515f, -0.570780746f, 0.820225983f, -0.572039629f, 0.819347520f, + -0.573297167f, 0.818467130f, -0.574553355f, 0.817584813f, -0.575808191f, + 0.816700573f, -0.577061673f, 0.815814411f, -0.578313796f, 0.814926329f, + -0.579564559f, 0.814036330f, -0.580813958f, 0.813144415f, -0.582061990f, + 0.812250587f, -0.583308653f, 0.811354847f, -0.584553943f, 0.810457198f, + -0.585797857f, 0.809557642f, -0.587040394f, 0.808656182f, -0.588281548f, + 0.807752818f, -0.589521319f, 0.806847554f, -0.590759702f, 0.805940391f, + -0.591996695f, 0.805031331f, -0.593232295f, 0.804120377f, -0.594466499f, + 0.803207531f, -0.595699304f, 0.802292796f, -0.596930708f, 0.801376172f, + -0.598160707f, 0.800457662f, -0.599389298f, 0.799537269f, -0.600616479f, + 0.798614995f, -0.601842247f, 0.797690841f, -0.603066599f, 0.796764810f, + -0.604289531f, 0.795836905f, -0.605511041f, 0.794907126f, -0.606731127f, + 0.793975478f, -0.607949785f, 0.793041960f, -0.609167012f, 0.792106577f, + -0.610382806f, 0.791169330f, -0.611597164f, 0.790230221f, -0.612810082f, + 0.789289253f, -0.614021559f, 0.788346428f, -0.615231591f, 0.787401747f, + -0.616440175f, 0.786455214f, -0.617647308f, 0.785506830f, -0.618852988f, + 0.784556597f, -0.620057212f, 0.783604519f, -0.621259977f, 0.782650596f, + -0.622461279f, 0.781694832f, -0.623661118f, 0.780737229f, -0.624859488f, + 0.779777788f, -0.626056388f, 0.778816512f, -0.627251815f, 0.777853404f, + -0.628445767f, 0.776888466f, -0.629638239f, 0.775921699f, -0.630829230f, + 0.774953107f, -0.632018736f, 0.773982691f, -0.633206755f, 0.773010453f, + -0.634393284f, 0.772036397f, -0.635578320f, 0.771060524f, -0.636761861f, + 0.770082837f, -0.637943904f, 0.769103338f, -0.639124445f, 0.768122029f, + -0.640303482f, 0.767138912f, -0.641481013f, 0.766153990f, -0.642657034f, + 0.765167266f, -0.643831543f, 0.764178741f, -0.645004537f, 0.763188417f, + -0.646176013f, 0.762196298f, -0.647345969f, 0.761202385f, -0.648514401f, + 0.760206682f, -0.649681307f, 0.759209189f, -0.650846685f, 0.758209910f, + -0.652010531f, 0.757208847f, -0.653172843f, 0.756206001f, -0.654333618f, + 0.755201377f, -0.655492853f, 0.754194975f, -0.656650546f, 0.753186799f, + -0.657806693f, 0.752176850f, -0.658961293f, 0.751165132f, -0.660114342f, + 0.750151646f, -0.661265838f, 0.749136395f, -0.662415778f, 0.748119380f, + -0.663564159f, 0.747100606f, -0.664710978f, 0.746080074f, -0.665856234f, + 0.745057785f, -0.666999922f, 0.744033744f, -0.668142041f, 0.743007952f, + -0.669282588f, 0.741980412f, -0.670421560f, 0.740951125f, -0.671558955f, + 0.739920095f, -0.672694769f, 0.738887324f, -0.673829000f, 0.737852815f, + -0.674961646f, 0.736816569f, -0.676092704f, 0.735778589f, -0.677222170f, + 0.734738878f, -0.678350043f, 0.733697438f, -0.679476320f, 0.732654272f, + -0.680600998f, 0.731609381f, -0.681724074f, 0.730562769f, -0.682845546f, + 0.729514438f, -0.683965412f, 0.728464390f, -0.685083668f, 0.727412629f, + -0.686200312f, 0.726359155f, -0.687315341f, 0.725303972f, -0.688428753f, + 0.724247083f, -0.689540545f, 0.723188489f, -0.690650714f, 0.722128194f, + -0.691759258f, 0.721066199f, -0.692866175f, 0.720002508f, -0.693971461f, + 0.718937122f, -0.695075114f, 0.717870045f, -0.696177131f, 0.716801279f, + -0.697277511f, 0.715730825f, -0.698376249f, 0.714658688f, -0.699473345f, + 0.713584869f, -0.700568794f, 0.712509371f, -0.701662595f, 0.711432196f, + -0.702754744f, 0.710353347f, -0.703845241f, 0.709272826f, -0.704934080f, + 0.708190637f, -0.706021261f, 0.707106781f, -0.707106781f, 0.706021261f, + -0.708190637f, 0.704934080f, -0.709272826f, 0.703845241f, -0.710353347f, + 0.702754744f, -0.711432196f, 0.701662595f, -0.712509371f, 0.700568794f, + -0.713584869f, 0.699473345f, -0.714658688f, 0.698376249f, -0.715730825f, + 0.697277511f, -0.716801279f, 0.696177131f, -0.717870045f, 0.695075114f, + -0.718937122f, 0.693971461f, -0.720002508f, 0.692866175f, -0.721066199f, + 0.691759258f, -0.722128194f, 0.690650714f, -0.723188489f, 0.689540545f, + -0.724247083f, 0.688428753f, -0.725303972f, 0.687315341f, -0.726359155f, + 0.686200312f, -0.727412629f, 0.685083668f, -0.728464390f, 0.683965412f, + -0.729514438f, 0.682845546f, -0.730562769f, 0.681724074f, -0.731609381f, + 0.680600998f, -0.732654272f, 0.679476320f, -0.733697438f, 0.678350043f, + -0.734738878f, 0.677222170f, -0.735778589f, 0.676092704f, -0.736816569f, + 0.674961646f, -0.737852815f, 0.673829000f, -0.738887324f, 0.672694769f, + -0.739920095f, 0.671558955f, -0.740951125f, 0.670421560f, -0.741980412f, + 0.669282588f, -0.743007952f, 0.668142041f, -0.744033744f, 0.666999922f, + -0.745057785f, 0.665856234f, -0.746080074f, 0.664710978f, -0.747100606f, + 0.663564159f, -0.748119380f, 0.662415778f, -0.749136395f, 0.661265838f, + -0.750151646f, 0.660114342f, -0.751165132f, 0.658961293f, -0.752176850f, + 0.657806693f, -0.753186799f, 0.656650546f, -0.754194975f, 0.655492853f, + -0.755201377f, 0.654333618f, -0.756206001f, 0.653172843f, -0.757208847f, + 0.652010531f, -0.758209910f, 0.650846685f, -0.759209189f, 0.649681307f, + -0.760206682f, 0.648514401f, -0.761202385f, 0.647345969f, -0.762196298f, + 0.646176013f, -0.763188417f, 0.645004537f, -0.764178741f, 0.643831543f, + -0.765167266f, 0.642657034f, -0.766153990f, 0.641481013f, -0.767138912f, + 0.640303482f, -0.768122029f, 0.639124445f, -0.769103338f, 0.637943904f, + -0.770082837f, 0.636761861f, -0.771060524f, 0.635578320f, -0.772036397f, + 0.634393284f, -0.773010453f, 0.633206755f, -0.773982691f, 0.632018736f, + -0.774953107f, 0.630829230f, -0.775921699f, 0.629638239f, -0.776888466f, + 0.628445767f, -0.777853404f, 0.627251815f, -0.778816512f, 0.626056388f, + -0.779777788f, 0.624859488f, -0.780737229f, 0.623661118f, -0.781694832f, + 0.622461279f, -0.782650596f, 0.621259977f, -0.783604519f, 0.620057212f, + -0.784556597f, 0.618852988f, -0.785506830f, 0.617647308f, -0.786455214f, + 0.616440175f, -0.787401747f, 0.615231591f, -0.788346428f, 0.614021559f, + -0.789289253f, 0.612810082f, -0.790230221f, 0.611597164f, -0.791169330f, + 0.610382806f, -0.792106577f, 0.609167012f, -0.793041960f, 0.607949785f, + -0.793975478f, 0.606731127f, -0.794907126f, 0.605511041f, -0.795836905f, + 0.604289531f, -0.796764810f, 0.603066599f, -0.797690841f, 0.601842247f, + -0.798614995f, 0.600616479f, -0.799537269f, 0.599389298f, -0.800457662f, + 0.598160707f, -0.801376172f, 0.596930708f, -0.802292796f, 0.595699304f, + -0.803207531f, 0.594466499f, -0.804120377f, 0.593232295f, -0.805031331f, + 0.591996695f, -0.805940391f, 0.590759702f, -0.806847554f, 0.589521319f, + -0.807752818f, 0.588281548f, -0.808656182f, 0.587040394f, -0.809557642f, + 0.585797857f, -0.810457198f, 0.584553943f, -0.811354847f, 0.583308653f, + -0.812250587f, 0.582061990f, -0.813144415f, 0.580813958f, -0.814036330f, + 0.579564559f, -0.814926329f, 0.578313796f, -0.815814411f, 0.577061673f, + -0.816700573f, 0.575808191f, -0.817584813f, 0.574553355f, -0.818467130f, + 0.573297167f, -0.819347520f, 0.572039629f, -0.820225983f, 0.570780746f, + -0.821102515f, 0.569520519f, -0.821977115f, 0.568258953f, -0.822849781f, + 0.566996049f, -0.823720511f, 0.565731811f, -0.824589303f, 0.564466242f, + -0.825456154f, 0.563199344f, -0.826321063f, 0.561931121f, -0.827184027f, + 0.560661576f, -0.828045045f, 0.559390712f, -0.828904115f, 0.558118531f, + -0.829761234f, 0.556845037f, -0.830616400f, 0.555570233f, -0.831469612f, + 0.554294121f, -0.832320868f, 0.553016706f, -0.833170165f, 0.551737988f, + -0.834017501f, 0.550457973f, -0.834862875f, 0.549176662f, -0.835706284f, + 0.547894059f, -0.836547727f, 0.546610167f, -0.837387202f, 0.545324988f, + -0.838224706f, 0.544038527f, -0.839060237f, 0.542750785f, -0.839893794f, + 0.541461766f, -0.840725375f, 0.540171473f, -0.841554977f, 0.538879909f, + -0.842382600f, 0.537587076f, -0.843208240f, 0.536292979f, -0.844031895f, + 0.534997620f, -0.844853565f, 0.533701002f, -0.845673247f, 0.532403128f, + -0.846490939f, 0.531104001f, -0.847306639f, 0.529803625f, -0.848120345f, + 0.528502002f, -0.848932055f, 0.527199135f, -0.849741768f, 0.525895027f, + -0.850549481f, 0.524589683f, -0.851355193f, 0.523283103f, -0.852158902f, + 0.521975293f, -0.852960605f, 0.520666254f, -0.853760301f, 0.519355990f, + -0.854557988f, 0.518044504f, -0.855353665f, 0.516731799f, -0.856147328f, + 0.515417878f, -0.856938977f, 0.514102744f, -0.857728610f, 0.512786401f, + -0.858516224f, 0.511468850f, -0.859301818f, 0.510150097f, -0.860085390f, + 0.508830143f, -0.860866939f, 0.507508991f, -0.861646461f, 0.506186645f, + -0.862423956f, 0.504863109f, -0.863199422f, 0.503538384f, -0.863972856f, + 0.502212474f, -0.864744258f, 0.500885383f, -0.865513624f, 0.499557113f, + -0.866280954f, 0.498227667f, -0.867046246f, 0.496897049f, -0.867809497f, + 0.495565262f, -0.868570706f, 0.494232309f, -0.869329871f, 0.492898192f, + -0.870086991f, 0.491562916f, -0.870842063f, 0.490226483f, -0.871595087f, + 0.488888897f, -0.872346059f, 0.487550160f, -0.873094978f, 0.486210276f, + -0.873841843f, 0.484869248f, -0.874586652f, 0.483527079f, -0.875329403f, + 0.482183772f, -0.876070094f, 0.480839331f, -0.876808724f, 0.479493758f, + -0.877545290f, 0.478147056f, -0.878279792f, 0.476799230f, -0.879012226f, + 0.475450282f, -0.879742593f, 0.474100215f, -0.880470889f, 0.472749032f, + -0.881197113f, 0.471396737f, -0.881921264f, 0.470043332f, -0.882643340f, + 0.468688822f, -0.883363339f, 0.467333209f, -0.884081259f, 0.465976496f, + -0.884797098f, 0.464618686f, -0.885510856f, 0.463259784f, -0.886222530f, + 0.461899791f, -0.886932119f, 0.460538711f, -0.887639620f, 0.459176548f, + -0.888345033f, 0.457813304f, -0.889048356f, 0.456448982f, -0.889749586f, + 0.455083587f, -0.890448723f, 0.453717121f, -0.891145765f, 0.452349587f, + -0.891840709f, 0.450980989f, -0.892533555f, 0.449611330f, -0.893224301f, + 0.448240612f, -0.893912945f, 0.446868840f, -0.894599486f, 0.445496017f, + -0.895283921f, 0.444122145f, -0.895966250f, 0.442747228f, -0.896646470f, + 0.441371269f, -0.897324581f, 0.439994271f, -0.898000580f, 0.438616239f, + -0.898674466f, 0.437237174f, -0.899346237f, 0.435857080f, -0.900015892f, + 0.434475961f, -0.900683429f, 0.433093819f, -0.901348847f, 0.431710658f, + -0.902012144f, 0.430326481f, -0.902673318f, 0.428941292f, -0.903332368f, + 0.427555093f, -0.903989293f, 0.426167889f, -0.904644091f, 0.424779681f, + -0.905296759f, 0.423390474f, -0.905947298f, 0.422000271f, -0.906595705f, + 0.420609074f, -0.907241978f, 0.419216888f, -0.907886116f, 0.417823716f, + -0.908528119f, 0.416429560f, -0.909167983f, 0.415034424f, -0.909805708f, + 0.413638312f, -0.910441292f, 0.412241227f, -0.911074734f, 0.410843171f, + -0.911706032f, 0.409444149f, -0.912335185f, 0.408044163f, -0.912962190f, + 0.406643217f, -0.913587048f, 0.405241314f, -0.914209756f, 0.403838458f, + -0.914830312f, 0.402434651f, -0.915448716f, 0.401029897f, -0.916064966f, + 0.399624200f, -0.916679060f, 0.398217562f, -0.917290997f, 0.396809987f, + -0.917900776f, 0.395401479f, -0.918508394f, 0.393992040f, -0.919113852f, + 0.392581674f, -0.919717146f, 0.391170384f, -0.920318277f, 0.389758174f, + -0.920917242f, 0.388345047f, -0.921514039f, 0.386931006f, -0.922108669f, + 0.385516054f, -0.922701128f, 0.384100195f, -0.923291417f, 0.382683432f, + -0.923879533f, 0.381265769f, -0.924465474f, 0.379847209f, -0.925049241f, + 0.378427755f, -0.925630831f, 0.377007410f, -0.926210242f, 0.375586178f, + -0.926787474f, 0.374164063f, -0.927362526f, 0.372741067f, -0.927935395f, + 0.371317194f, -0.928506080f, 0.369892447f, -0.929074581f, 0.368466830f, + -0.929640896f, 0.367040346f, -0.930205023f, 0.365612998f, -0.930766961f, + 0.364184790f, -0.931326709f, 0.362755724f, -0.931884266f, 0.361325806f, + -0.932439629f, 0.359895037f, -0.932992799f, 0.358463421f, -0.933543773f, + 0.357030961f, -0.934092550f, 0.355597662f, -0.934639130f, 0.354163525f, + -0.935183510f, 0.352728556f, -0.935725689f, 0.351292756f, -0.936265667f, + 0.349856130f, -0.936803442f, 0.348418680f, -0.937339012f, 0.346980411f, + -0.937872376f, 0.345541325f, -0.938403534f, 0.344101426f, -0.938932484f, + 0.342660717f, -0.939459224f, 0.341219202f, -0.939983753f, 0.339776884f, + -0.940506071f, 0.338333767f, -0.941026175f, 0.336889853f, -0.941544065f, + 0.335445147f, -0.942059740f, 0.333999651f, -0.942573198f, 0.332553370f, + -0.943084437f, 0.331106306f, -0.943593458f, 0.329658463f, -0.944100258f, + 0.328209844f, -0.944604837f, 0.326760452f, -0.945107193f, 0.325310292f, + -0.945607325f, 0.323859367f, -0.946105232f, 0.322407679f, -0.946600913f, + 0.320955232f, -0.947094366f, 0.319502031f, -0.947585591f, 0.318048077f, + -0.948074586f, 0.316593376f, -0.948561350f, 0.315137929f, -0.949045882f, + 0.313681740f, -0.949528181f, 0.312224814f, -0.950008245f, 0.310767153f, + -0.950486074f, 0.309308760f, -0.950961666f, 0.307849640f, -0.951435021f, + 0.306389795f, -0.951906137f, 0.304929230f, -0.952375013f, 0.303467947f, + -0.952841648f, 0.302005949f, -0.953306040f, 0.300543241f, -0.953768190f, + 0.299079826f, -0.954228095f, 0.297615707f, -0.954685755f, 0.296150888f, + -0.955141168f, 0.294685372f, -0.955594334f, 0.293219163f, -0.956045251f, + 0.291752263f, -0.956493919f, 0.290284677f, -0.956940336f, 0.288816408f, + -0.957384501f, 0.287347460f, -0.957826413f, 0.285877835f, -0.958266071f, + 0.284407537f, -0.958703475f, 0.282936570f, -0.959138622f, 0.281464938f, + -0.959571513f, 0.279992643f, -0.960002146f, 0.278519689f, -0.960430519f, + 0.277046080f, -0.960856633f, 0.275571819f, -0.961280486f, 0.274096910f, + -0.961702077f, 0.272621355f, -0.962121404f, 0.271145160f, -0.962538468f, + 0.269668326f, -0.962953267f, 0.268190857f, -0.963365800f, 0.266712757f, + -0.963776066f, 0.265234030f, -0.964184064f, 0.263754679f, -0.964589793f, + 0.262274707f, -0.964993253f, 0.260794118f, -0.965394442f, 0.259312915f, + -0.965793359f, 0.257831102f, -0.966190003f, 0.256348682f, -0.966584374f, + 0.254865660f, -0.966976471f, 0.253382037f, -0.967366292f, 0.251897818f, + -0.967753837f, 0.250413007f, -0.968139105f, 0.248927606f, -0.968522094f, + 0.247441619f, -0.968902805f, 0.245955050f, -0.969281235f, 0.244467903f, + -0.969657385f, 0.242980180f, -0.970031253f, 0.241491885f, -0.970402839f, + 0.240003022f, -0.970772141f, 0.238513595f, -0.971139158f, 0.237023606f, + -0.971503891f, 0.235533059f, -0.971866337f, 0.234041959f, -0.972226497f, + 0.232550307f, -0.972584369f, 0.231058108f, -0.972939952f, 0.229565366f, + -0.973293246f, 0.228072083f, -0.973644250f, 0.226578264f, -0.973992962f, + 0.225083911f, -0.974339383f, 0.223589029f, -0.974683511f, 0.222093621f, + -0.975025345f, 0.220597690f, -0.975364885f, 0.219101240f, -0.975702130f, + 0.217604275f, -0.976037079f, 0.216106797f, -0.976369731f, 0.214608811f, + -0.976700086f, 0.213110320f, -0.977028143f, 0.211611327f, -0.977353900f, + 0.210111837f, -0.977677358f, 0.208611852f, -0.977998515f, 0.207111376f, + -0.978317371f, 0.205610413f, -0.978633924f, 0.204108966f, -0.978948175f, + 0.202607039f, -0.979260123f, 0.201104635f, -0.979569766f, 0.199601758f, + -0.979877104f, 0.198098411f, -0.980182136f, 0.196594598f, -0.980484862f, + 0.195090322f, -0.980785280f, 0.193585587f, -0.981083391f, 0.192080397f, + -0.981379193f, 0.190574755f, -0.981672686f, 0.189068664f, -0.981963869f, + 0.187562129f, -0.982252741f, 0.186055152f, -0.982539302f, 0.184547737f, + -0.982823551f, 0.183039888f, -0.983105487f, 0.181531608f, -0.983385110f, + 0.180022901f, -0.983662419f, 0.178513771f, -0.983937413f, 0.177004220f, + -0.984210092f, 0.175494253f, -0.984480455f, 0.173983873f, -0.984748502f, + 0.172473084f, -0.985014231f, 0.170961889f, -0.985277642f, 0.169450291f, + -0.985538735f, 0.167938295f, -0.985797509f, 0.166425904f, -0.986053963f, + 0.164913120f, -0.986308097f, 0.163399949f, -0.986559910f, 0.161886394f, + -0.986809402f, 0.160372457f, -0.987056571f, 0.158858143f, -0.987301418f, + 0.157343456f, -0.987543942f, 0.155828398f, -0.987784142f, 0.154312973f, + -0.988022017f, 0.152797185f, -0.988257568f, 0.151281038f, -0.988490793f, + 0.149764535f, -0.988721692f, 0.148247679f, -0.988950265f, 0.146730474f, + -0.989176510f, 0.145212925f, -0.989400428f, 0.143695033f, -0.989622017f, + 0.142176804f, -0.989841278f, 0.140658239f, -0.990058210f, 0.139139344f, + -0.990272812f, 0.137620122f, -0.990485084f, 0.136100575f, -0.990695025f, + 0.134580709f, -0.990902635f, 0.133060525f, -0.991107914f, 0.131540029f, + -0.991310860f, 0.130019223f, -0.991511473f, 0.128498111f, -0.991709754f, + 0.126976696f, -0.991905700f, 0.125454983f, -0.992099313f, 0.123932975f, + -0.992290591f, 0.122410675f, -0.992479535f, 0.120888087f, -0.992666142f, + 0.119365215f, -0.992850414f, 0.117842062f, -0.993032350f, 0.116318631f, + -0.993211949f, 0.114794927f, -0.993389211f, 0.113270952f, -0.993564136f, + 0.111746711f, -0.993736722f, 0.110222207f, -0.993906970f, 0.108697444f, + -0.994074879f, 0.107172425f, -0.994240449f, 0.105647154f, -0.994403680f, + 0.104121634f, -0.994564571f, 0.102595869f, -0.994723121f, 0.101069863f, + -0.994879331f, 0.099543619f, -0.995033199f, 0.098017140f, -0.995184727f, + 0.096490431f, -0.995333912f, 0.094963495f, -0.995480755f, 0.093436336f, + -0.995625256f, 0.091908956f, -0.995767414f, 0.090381361f, -0.995907229f, + 0.088853553f, -0.996044701f, 0.087325535f, -0.996179829f, 0.085797312f, + -0.996312612f, 0.084268888f, -0.996443051f, 0.082740265f, -0.996571146f, + 0.081211447f, -0.996696895f, 0.079682438f, -0.996820299f, 0.078153242f, + -0.996941358f, 0.076623861f, -0.997060070f, 0.075094301f, -0.997176437f, + 0.073564564f, -0.997290457f, 0.072034653f, -0.997402130f, 0.070504573f, + -0.997511456f, 0.068974328f, -0.997618435f, 0.067443920f, -0.997723067f, + 0.065913353f, -0.997825350f, 0.064382631f, -0.997925286f, 0.062851758f, + -0.998022874f, 0.061320736f, -0.998118113f, 0.059789571f, -0.998211003f, + 0.058258265f, -0.998301545f, 0.056726821f, -0.998389737f, 0.055195244f, + -0.998475581f, 0.053663538f, -0.998559074f, 0.052131705f, -0.998640218f, + 0.050599749f, -0.998719012f, 0.049067674f, -0.998795456f, 0.047535484f, + -0.998869550f, 0.046003182f, -0.998941293f, 0.044470772f, -0.999010686f, + 0.042938257f, -0.999077728f, 0.041405641f, -0.999142419f, 0.039872928f, + -0.999204759f, 0.038340120f, -0.999264747f, 0.036807223f, -0.999322385f, + 0.035274239f, -0.999377670f, 0.033741172f, -0.999430605f, 0.032208025f, + -0.999481187f, 0.030674803f, -0.999529418f, 0.029141509f, -0.999575296f, + 0.027608146f, -0.999618822f, 0.026074718f, -0.999659997f, 0.024541229f, + -0.999698819f, 0.023007681f, -0.999735288f, 0.021474080f, -0.999769405f, + 0.019940429f, -0.999801170f, 0.018406730f, -0.999830582f, 0.016872988f, + -0.999857641f, 0.015339206f, -0.999882347f, 0.013805389f, -0.999904701f, + 0.012271538f, -0.999924702f, 0.010737659f, -0.999942350f, 0.009203755f, + -0.999957645f, 0.007669829f, -0.999970586f, 0.006135885f, -0.999981175f, + 0.004601926f, -0.999989411f, 0.003067957f, -0.999995294f, 0.001533980f, + -0.999998823f}; /** @par @@ -21862,107 +13035,115 @@ const float32_t twiddleCoef_rfft_4096[4096] = { tableSize = 512; for (n = 0; n < (tableSize + 1); n++) { - sinTable[n] = sin(2*PI*n/tableSize); + sinTable[n] = sin(2*PI*n/tableSize); } @par where PI value is 3.14159265358979 */ const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1] = { - 0.00000000f, 0.01227154f, 0.02454123f, 0.03680722f, 0.04906767f, 0.06132074f, - 0.07356456f, 0.08579731f, 0.09801714f, 0.11022221f, 0.12241068f, 0.13458071f, - 0.14673047f, 0.15885814f, 0.17096189f, 0.18303989f, 0.19509032f, 0.20711138f, - 0.21910124f, 0.23105811f, 0.24298018f, 0.25486566f, 0.26671276f, 0.27851969f, - 0.29028468f, 0.30200595f, 0.31368174f, 0.32531029f, 0.33688985f, 0.34841868f, - 0.35989504f, 0.37131719f, 0.38268343f, 0.39399204f, 0.40524131f, 0.41642956f, - 0.42755509f, 0.43861624f, 0.44961133f, 0.46053871f, 0.47139674f, 0.48218377f, - 0.49289819f, 0.50353838f, 0.51410274f, 0.52458968f, 0.53499762f, 0.54532499f, - 0.55557023f, 0.56573181f, 0.57580819f, 0.58579786f, 0.59569930f, 0.60551104f, - 0.61523159f, 0.62485949f, 0.63439328f, 0.64383154f, 0.65317284f, 0.66241578f, - 0.67155895f, 0.68060100f, 0.68954054f, 0.69837625f, 0.70710678f, 0.71573083f, - 0.72424708f, 0.73265427f, 0.74095113f, 0.74913639f, 0.75720885f, 0.76516727f, - 0.77301045f, 0.78073723f, 0.78834643f, 0.79583690f, 0.80320753f, 0.81045720f, - 0.81758481f, 0.82458930f, 0.83146961f, 0.83822471f, 0.84485357f, 0.85135519f, - 0.85772861f, 0.86397286f, 0.87008699f, 0.87607009f, 0.88192126f, 0.88763962f, - 0.89322430f, 0.89867447f, 0.90398929f, 0.90916798f, 0.91420976f, 0.91911385f, - 0.92387953f, 0.92850608f, 0.93299280f, 0.93733901f, 0.94154407f, 0.94560733f, - 0.94952818f, 0.95330604f, 0.95694034f, 0.96043052f, 0.96377607f, 0.96697647f, - 0.97003125f, 0.97293995f, 0.97570213f, 0.97831737f, 0.98078528f, 0.98310549f, - 0.98527764f, 0.98730142f, 0.98917651f, 0.99090264f, 0.99247953f, 0.99390697f, - 0.99518473f, 0.99631261f, 0.99729046f, 0.99811811f, 0.99879546f, 0.99932238f, - 0.99969882f, 0.99992470f, 1.00000000f, 0.99992470f, 0.99969882f, 0.99932238f, - 0.99879546f, 0.99811811f, 0.99729046f, 0.99631261f, 0.99518473f, 0.99390697f, - 0.99247953f, 0.99090264f, 0.98917651f, 0.98730142f, 0.98527764f, 0.98310549f, - 0.98078528f, 0.97831737f, 0.97570213f, 0.97293995f, 0.97003125f, 0.96697647f, - 0.96377607f, 0.96043052f, 0.95694034f, 0.95330604f, 0.94952818f, 0.94560733f, - 0.94154407f, 0.93733901f, 0.93299280f, 0.92850608f, 0.92387953f, 0.91911385f, - 0.91420976f, 0.90916798f, 0.90398929f, 0.89867447f, 0.89322430f, 0.88763962f, - 0.88192126f, 0.87607009f, 0.87008699f, 0.86397286f, 0.85772861f, 0.85135519f, - 0.84485357f, 0.83822471f, 0.83146961f, 0.82458930f, 0.81758481f, 0.81045720f, - 0.80320753f, 0.79583690f, 0.78834643f, 0.78073723f, 0.77301045f, 0.76516727f, - 0.75720885f, 0.74913639f, 0.74095113f, 0.73265427f, 0.72424708f, 0.71573083f, - 0.70710678f, 0.69837625f, 0.68954054f, 0.68060100f, 0.67155895f, 0.66241578f, - 0.65317284f, 0.64383154f, 0.63439328f, 0.62485949f, 0.61523159f, 0.60551104f, - 0.59569930f, 0.58579786f, 0.57580819f, 0.56573181f, 0.55557023f, 0.54532499f, - 0.53499762f, 0.52458968f, 0.51410274f, 0.50353838f, 0.49289819f, 0.48218377f, - 0.47139674f, 0.46053871f, 0.44961133f, 0.43861624f, 0.42755509f, 0.41642956f, - 0.40524131f, 0.39399204f, 0.38268343f, 0.37131719f, 0.35989504f, 0.34841868f, - 0.33688985f, 0.32531029f, 0.31368174f, 0.30200595f, 0.29028468f, 0.27851969f, - 0.26671276f, 0.25486566f, 0.24298018f, 0.23105811f, 0.21910124f, 0.20711138f, - 0.19509032f, 0.18303989f, 0.17096189f, 0.15885814f, 0.14673047f, 0.13458071f, - 0.12241068f, 0.11022221f, 0.09801714f, 0.08579731f, 0.07356456f, 0.06132074f, - 0.04906767f, 0.03680722f, 0.02454123f, 0.01227154f, 0.00000000f, -0.01227154f, - -0.02454123f, -0.03680722f, -0.04906767f, -0.06132074f, -0.07356456f, - -0.08579731f, -0.09801714f, -0.11022221f, -0.12241068f, -0.13458071f, - -0.14673047f, -0.15885814f, -0.17096189f, -0.18303989f, -0.19509032f, - -0.20711138f, -0.21910124f, -0.23105811f, -0.24298018f, -0.25486566f, - -0.26671276f, -0.27851969f, -0.29028468f, -0.30200595f, -0.31368174f, - -0.32531029f, -0.33688985f, -0.34841868f, -0.35989504f, -0.37131719f, - -0.38268343f, -0.39399204f, -0.40524131f, -0.41642956f, -0.42755509f, - -0.43861624f, -0.44961133f, -0.46053871f, -0.47139674f, -0.48218377f, - -0.49289819f, -0.50353838f, -0.51410274f, -0.52458968f, -0.53499762f, - -0.54532499f, -0.55557023f, -0.56573181f, -0.57580819f, -0.58579786f, - -0.59569930f, -0.60551104f, -0.61523159f, -0.62485949f, -0.63439328f, - -0.64383154f, -0.65317284f, -0.66241578f, -0.67155895f, -0.68060100f, - -0.68954054f, -0.69837625f, -0.70710678f, -0.71573083f, -0.72424708f, - -0.73265427f, -0.74095113f, -0.74913639f, -0.75720885f, -0.76516727f, - -0.77301045f, -0.78073723f, -0.78834643f, -0.79583690f, -0.80320753f, - -0.81045720f, -0.81758481f, -0.82458930f, -0.83146961f, -0.83822471f, - -0.84485357f, -0.85135519f, -0.85772861f, -0.86397286f, -0.87008699f, - -0.87607009f, -0.88192126f, -0.88763962f, -0.89322430f, -0.89867447f, - -0.90398929f, -0.90916798f, -0.91420976f, -0.91911385f, -0.92387953f, - -0.92850608f, -0.93299280f, -0.93733901f, -0.94154407f, -0.94560733f, - -0.94952818f, -0.95330604f, -0.95694034f, -0.96043052f, -0.96377607f, - -0.96697647f, -0.97003125f, -0.97293995f, -0.97570213f, -0.97831737f, - -0.98078528f, -0.98310549f, -0.98527764f, -0.98730142f, -0.98917651f, - -0.99090264f, -0.99247953f, -0.99390697f, -0.99518473f, -0.99631261f, - -0.99729046f, -0.99811811f, -0.99879546f, -0.99932238f, -0.99969882f, - -0.99992470f, -1.00000000f, -0.99992470f, -0.99969882f, -0.99932238f, - -0.99879546f, -0.99811811f, -0.99729046f, -0.99631261f, -0.99518473f, - -0.99390697f, -0.99247953f, -0.99090264f, -0.98917651f, -0.98730142f, - -0.98527764f, -0.98310549f, -0.98078528f, -0.97831737f, -0.97570213f, - -0.97293995f, -0.97003125f, -0.96697647f, -0.96377607f, -0.96043052f, - -0.95694034f, -0.95330604f, -0.94952818f, -0.94560733f, -0.94154407f, - -0.93733901f, -0.93299280f, -0.92850608f, -0.92387953f, -0.91911385f, - -0.91420976f, -0.90916798f, -0.90398929f, -0.89867447f, -0.89322430f, - -0.88763962f, -0.88192126f, -0.87607009f, -0.87008699f, -0.86397286f, - -0.85772861f, -0.85135519f, -0.84485357f, -0.83822471f, -0.83146961f, - -0.82458930f, -0.81758481f, -0.81045720f, -0.80320753f, -0.79583690f, - -0.78834643f, -0.78073723f, -0.77301045f, -0.76516727f, -0.75720885f, - -0.74913639f, -0.74095113f, -0.73265427f, -0.72424708f, -0.71573083f, - -0.70710678f, -0.69837625f, -0.68954054f, -0.68060100f, -0.67155895f, - -0.66241578f, -0.65317284f, -0.64383154f, -0.63439328f, -0.62485949f, - -0.61523159f, -0.60551104f, -0.59569930f, -0.58579786f, -0.57580819f, - -0.56573181f, -0.55557023f, -0.54532499f, -0.53499762f, -0.52458968f, - -0.51410274f, -0.50353838f, -0.49289819f, -0.48218377f, -0.47139674f, - -0.46053871f, -0.44961133f, -0.43861624f, -0.42755509f, -0.41642956f, - -0.40524131f, -0.39399204f, -0.38268343f, -0.37131719f, -0.35989504f, - -0.34841868f, -0.33688985f, -0.32531029f, -0.31368174f, -0.30200595f, - -0.29028468f, -0.27851969f, -0.26671276f, -0.25486566f, -0.24298018f, - -0.23105811f, -0.21910124f, -0.20711138f, -0.19509032f, -0.18303989f, - -0.17096189f, -0.15885814f, -0.14673047f, -0.13458071f, -0.12241068f, - -0.11022221f, -0.09801714f, -0.08579731f, -0.07356456f, -0.06132074f, - -0.04906767f, -0.03680722f, -0.02454123f, -0.01227154f, -0.00000000f -}; + 0.00000000f, 0.01227154f, 0.02454123f, 0.03680722f, 0.04906767f, + 0.06132074f, 0.07356456f, 0.08579731f, 0.09801714f, 0.11022221f, + 0.12241068f, 0.13458071f, 0.14673047f, 0.15885814f, 0.17096189f, + 0.18303989f, 0.19509032f, 0.20711138f, 0.21910124f, 0.23105811f, + 0.24298018f, 0.25486566f, 0.26671276f, 0.27851969f, 0.29028468f, + 0.30200595f, 0.31368174f, 0.32531029f, 0.33688985f, 0.34841868f, + 0.35989504f, 0.37131719f, 0.38268343f, 0.39399204f, 0.40524131f, + 0.41642956f, 0.42755509f, 0.43861624f, 0.44961133f, 0.46053871f, + 0.47139674f, 0.48218377f, 0.49289819f, 0.50353838f, 0.51410274f, + 0.52458968f, 0.53499762f, 0.54532499f, 0.55557023f, 0.56573181f, + 0.57580819f, 0.58579786f, 0.59569930f, 0.60551104f, 0.61523159f, + 0.62485949f, 0.63439328f, 0.64383154f, 0.65317284f, 0.66241578f, + 0.67155895f, 0.68060100f, 0.68954054f, 0.69837625f, 0.70710678f, + 0.71573083f, 0.72424708f, 0.73265427f, 0.74095113f, 0.74913639f, + 0.75720885f, 0.76516727f, 0.77301045f, 0.78073723f, 0.78834643f, + 0.79583690f, 0.80320753f, 0.81045720f, 0.81758481f, 0.82458930f, + 0.83146961f, 0.83822471f, 0.84485357f, 0.85135519f, 0.85772861f, + 0.86397286f, 0.87008699f, 0.87607009f, 0.88192126f, 0.88763962f, + 0.89322430f, 0.89867447f, 0.90398929f, 0.90916798f, 0.91420976f, + 0.91911385f, 0.92387953f, 0.92850608f, 0.93299280f, 0.93733901f, + 0.94154407f, 0.94560733f, 0.94952818f, 0.95330604f, 0.95694034f, + 0.96043052f, 0.96377607f, 0.96697647f, 0.97003125f, 0.97293995f, + 0.97570213f, 0.97831737f, 0.98078528f, 0.98310549f, 0.98527764f, + 0.98730142f, 0.98917651f, 0.99090264f, 0.99247953f, 0.99390697f, + 0.99518473f, 0.99631261f, 0.99729046f, 0.99811811f, 0.99879546f, + 0.99932238f, 0.99969882f, 0.99992470f, 1.00000000f, 0.99992470f, + 0.99969882f, 0.99932238f, 0.99879546f, 0.99811811f, 0.99729046f, + 0.99631261f, 0.99518473f, 0.99390697f, 0.99247953f, 0.99090264f, + 0.98917651f, 0.98730142f, 0.98527764f, 0.98310549f, 0.98078528f, + 0.97831737f, 0.97570213f, 0.97293995f, 0.97003125f, 0.96697647f, + 0.96377607f, 0.96043052f, 0.95694034f, 0.95330604f, 0.94952818f, + 0.94560733f, 0.94154407f, 0.93733901f, 0.93299280f, 0.92850608f, + 0.92387953f, 0.91911385f, 0.91420976f, 0.90916798f, 0.90398929f, + 0.89867447f, 0.89322430f, 0.88763962f, 0.88192126f, 0.87607009f, + 0.87008699f, 0.86397286f, 0.85772861f, 0.85135519f, 0.84485357f, + 0.83822471f, 0.83146961f, 0.82458930f, 0.81758481f, 0.81045720f, + 0.80320753f, 0.79583690f, 0.78834643f, 0.78073723f, 0.77301045f, + 0.76516727f, 0.75720885f, 0.74913639f, 0.74095113f, 0.73265427f, + 0.72424708f, 0.71573083f, 0.70710678f, 0.69837625f, 0.68954054f, + 0.68060100f, 0.67155895f, 0.66241578f, 0.65317284f, 0.64383154f, + 0.63439328f, 0.62485949f, 0.61523159f, 0.60551104f, 0.59569930f, + 0.58579786f, 0.57580819f, 0.56573181f, 0.55557023f, 0.54532499f, + 0.53499762f, 0.52458968f, 0.51410274f, 0.50353838f, 0.49289819f, + 0.48218377f, 0.47139674f, 0.46053871f, 0.44961133f, 0.43861624f, + 0.42755509f, 0.41642956f, 0.40524131f, 0.39399204f, 0.38268343f, + 0.37131719f, 0.35989504f, 0.34841868f, 0.33688985f, 0.32531029f, + 0.31368174f, 0.30200595f, 0.29028468f, 0.27851969f, 0.26671276f, + 0.25486566f, 0.24298018f, 0.23105811f, 0.21910124f, 0.20711138f, + 0.19509032f, 0.18303989f, 0.17096189f, 0.15885814f, 0.14673047f, + 0.13458071f, 0.12241068f, 0.11022221f, 0.09801714f, 0.08579731f, + 0.07356456f, 0.06132074f, 0.04906767f, 0.03680722f, 0.02454123f, + 0.01227154f, 0.00000000f, -0.01227154f, -0.02454123f, -0.03680722f, + -0.04906767f, -0.06132074f, -0.07356456f, -0.08579731f, -0.09801714f, + -0.11022221f, -0.12241068f, -0.13458071f, -0.14673047f, -0.15885814f, + -0.17096189f, -0.18303989f, -0.19509032f, -0.20711138f, -0.21910124f, + -0.23105811f, -0.24298018f, -0.25486566f, -0.26671276f, -0.27851969f, + -0.29028468f, -0.30200595f, -0.31368174f, -0.32531029f, -0.33688985f, + -0.34841868f, -0.35989504f, -0.37131719f, -0.38268343f, -0.39399204f, + -0.40524131f, -0.41642956f, -0.42755509f, -0.43861624f, -0.44961133f, + -0.46053871f, -0.47139674f, -0.48218377f, -0.49289819f, -0.50353838f, + -0.51410274f, -0.52458968f, -0.53499762f, -0.54532499f, -0.55557023f, + -0.56573181f, -0.57580819f, -0.58579786f, -0.59569930f, -0.60551104f, + -0.61523159f, -0.62485949f, -0.63439328f, -0.64383154f, -0.65317284f, + -0.66241578f, -0.67155895f, -0.68060100f, -0.68954054f, -0.69837625f, + -0.70710678f, -0.71573083f, -0.72424708f, -0.73265427f, -0.74095113f, + -0.74913639f, -0.75720885f, -0.76516727f, -0.77301045f, -0.78073723f, + -0.78834643f, -0.79583690f, -0.80320753f, -0.81045720f, -0.81758481f, + -0.82458930f, -0.83146961f, -0.83822471f, -0.84485357f, -0.85135519f, + -0.85772861f, -0.86397286f, -0.87008699f, -0.87607009f, -0.88192126f, + -0.88763962f, -0.89322430f, -0.89867447f, -0.90398929f, -0.90916798f, + -0.91420976f, -0.91911385f, -0.92387953f, -0.92850608f, -0.93299280f, + -0.93733901f, -0.94154407f, -0.94560733f, -0.94952818f, -0.95330604f, + -0.95694034f, -0.96043052f, -0.96377607f, -0.96697647f, -0.97003125f, + -0.97293995f, -0.97570213f, -0.97831737f, -0.98078528f, -0.98310549f, + -0.98527764f, -0.98730142f, -0.98917651f, -0.99090264f, -0.99247953f, + -0.99390697f, -0.99518473f, -0.99631261f, -0.99729046f, -0.99811811f, + -0.99879546f, -0.99932238f, -0.99969882f, -0.99992470f, -1.00000000f, + -0.99992470f, -0.99969882f, -0.99932238f, -0.99879546f, -0.99811811f, + -0.99729046f, -0.99631261f, -0.99518473f, -0.99390697f, -0.99247953f, + -0.99090264f, -0.98917651f, -0.98730142f, -0.98527764f, -0.98310549f, + -0.98078528f, -0.97831737f, -0.97570213f, -0.97293995f, -0.97003125f, + -0.96697647f, -0.96377607f, -0.96043052f, -0.95694034f, -0.95330604f, + -0.94952818f, -0.94560733f, -0.94154407f, -0.93733901f, -0.93299280f, + -0.92850608f, -0.92387953f, -0.91911385f, -0.91420976f, -0.90916798f, + -0.90398929f, -0.89867447f, -0.89322430f, -0.88763962f, -0.88192126f, + -0.87607009f, -0.87008699f, -0.86397286f, -0.85772861f, -0.85135519f, + -0.84485357f, -0.83822471f, -0.83146961f, -0.82458930f, -0.81758481f, + -0.81045720f, -0.80320753f, -0.79583690f, -0.78834643f, -0.78073723f, + -0.77301045f, -0.76516727f, -0.75720885f, -0.74913639f, -0.74095113f, + -0.73265427f, -0.72424708f, -0.71573083f, -0.70710678f, -0.69837625f, + -0.68954054f, -0.68060100f, -0.67155895f, -0.66241578f, -0.65317284f, + -0.64383154f, -0.63439328f, -0.62485949f, -0.61523159f, -0.60551104f, + -0.59569930f, -0.58579786f, -0.57580819f, -0.56573181f, -0.55557023f, + -0.54532499f, -0.53499762f, -0.52458968f, -0.51410274f, -0.50353838f, + -0.49289819f, -0.48218377f, -0.47139674f, -0.46053871f, -0.44961133f, + -0.43861624f, -0.42755509f, -0.41642956f, -0.40524131f, -0.39399204f, + -0.38268343f, -0.37131719f, -0.35989504f, -0.34841868f, -0.33688985f, + -0.32531029f, -0.31368174f, -0.30200595f, -0.29028468f, -0.27851969f, + -0.26671276f, -0.25486566f, -0.24298018f, -0.23105811f, -0.21910124f, + -0.20711138f, -0.19509032f, -0.18303989f, -0.17096189f, -0.15885814f, + -0.14673047f, -0.13458071f, -0.12241068f, -0.11022221f, -0.09801714f, + -0.08579731f, -0.07356456f, -0.06132074f, -0.04906767f, -0.03680722f, + -0.02454123f, -0.01227154f, -0.00000000f}; /** @par @@ -21972,109 +13153,529 @@ const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1] = { tableSize = 512; for (n = 0; n < (tableSize + 1); n++) { - sinTable[n] = sin(2*PI*n/tableSize); + sinTable[n] = sin(2*PI*n/tableSize); } where PI value is 3.14159265358979 @par Second, convert floating-point to Q31 (Fixed point): - (sinTable[i] * pow(2, 31)) + (sinTable[i] * pow(2, 31)) @par Finally, round to the nearest integer value: - sinTable[i] += (sinTable[i] > 0 ? 0.5 : -0.5); + sinTable[i] += (sinTable[i] > 0 ? 0.5 : -0.5); */ -const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1] = { - 0L, 26352928L, 52701887L, 79042909L, 105372028L, 131685278L, 157978697L, - 184248325L, 210490206L, 236700388L, 262874923L, 289009871L, 315101295L, - 341145265L, 367137861L, 393075166L, 418953276L, 444768294L, 470516330L, - 496193509L, 521795963L, 547319836L, 572761285L, 598116479L, 623381598L, - 648552838L, 673626408L, 698598533L, 723465451L, 748223418L, 772868706L, - 797397602L, 821806413L, 846091463L, 870249095L, 894275671L, 918167572L, - 941921200L, 965532978L, 988999351L, 1012316784L, 1035481766L, 1058490808L, - 1081340445L, 1104027237L, 1126547765L, 1148898640L, 1171076495L, 1193077991L, - 1214899813L, 1236538675L, 1257991320L, 1279254516L, 1300325060L, 1321199781L, - 1341875533L, 1362349204L, 1382617710L, 1402678000L, 1422527051L, 1442161874L, - 1461579514L, 1480777044L, 1499751576L, 1518500250L, 1537020244L, 1555308768L, - 1573363068L, 1591180426L, 1608758157L, 1626093616L, 1643184191L, 1660027308L, - 1676620432L, 1692961062L, 1709046739L, 1724875040L, 1740443581L, 1755750017L, - 1770792044L, 1785567396L, 1800073849L, 1814309216L, 1828271356L, 1841958164L, - 1855367581L, 1868497586L, 1881346202L, 1893911494L, 1906191570L, 1918184581L, - 1929888720L, 1941302225L, 1952423377L, 1963250501L, 1973781967L, 1984016189L, - 1993951625L, 2003586779L, 2012920201L, 2021950484L, 2030676269L, 2039096241L, - 2047209133L, 2055013723L, 2062508835L, 2069693342L, 2076566160L, 2083126254L, - 2089372638L, 2095304370L, 2100920556L, 2106220352L, 2111202959L, 2115867626L, - 2120213651L, 2124240380L, 2127947206L, 2131333572L, 2134398966L, 2137142927L, - 2139565043L, 2141664948L, 2143442326L, 2144896910L, 2146028480L, 2146836866L, - 2147321946L, 2147483647L, 2147321946L, 2146836866L, 2146028480L, 2144896910L, - 2143442326L, 2141664948L, 2139565043L, 2137142927L, 2134398966L, 2131333572L, - 2127947206L, 2124240380L, 2120213651L, 2115867626L, 2111202959L, 2106220352L, - 2100920556L, 2095304370L, 2089372638L, 2083126254L, 2076566160L, 2069693342L, - 2062508835L, 2055013723L, 2047209133L, 2039096241L, 2030676269L, 2021950484L, - 2012920201L, 2003586779L, 1993951625L, 1984016189L, 1973781967L, 1963250501L, - 1952423377L, 1941302225L, 1929888720L, 1918184581L, 1906191570L, 1893911494L, - 1881346202L, 1868497586L, 1855367581L, 1841958164L, 1828271356L, 1814309216L, - 1800073849L, 1785567396L, 1770792044L, 1755750017L, 1740443581L, 1724875040L, - 1709046739L, 1692961062L, 1676620432L, 1660027308L, 1643184191L, 1626093616L, - 1608758157L, 1591180426L, 1573363068L, 1555308768L, 1537020244L, 1518500250L, - 1499751576L, 1480777044L, 1461579514L, 1442161874L, 1422527051L, 1402678000L, - 1382617710L, 1362349204L, 1341875533L, 1321199781L, 1300325060L, 1279254516L, - 1257991320L, 1236538675L, 1214899813L, 1193077991L, 1171076495L, 1148898640L, - 1126547765L, 1104027237L, 1081340445L, 1058490808L, 1035481766L, 1012316784L, - 988999351L, 965532978L, 941921200L, 918167572L, 894275671L, 870249095L, - 846091463L, 821806413L, 797397602L, 772868706L, 748223418L, 723465451L, - 698598533L, 673626408L, 648552838L, 623381598L, 598116479L, 572761285L, - 547319836L, 521795963L, 496193509L, 470516330L, 444768294L, 418953276L, - 393075166L, 367137861L, 341145265L, 315101295L, 289009871L, 262874923L, - 236700388L, 210490206L, 184248325L, 157978697L, 131685278L, 105372028L, - 79042909L, 52701887L, 26352928L, 0L, -26352928L, -52701887L, -79042909L, - -105372028L, -131685278L, -157978697L, -184248325L, -210490206L, -236700388L, - -262874923L, -289009871L, -315101295L, -341145265L, -367137861L, -393075166L, - -418953276L, -444768294L, -470516330L, -496193509L, -521795963L, -547319836L, - -572761285L, -598116479L, -623381598L, -648552838L, -673626408L, -698598533L, - -723465451L, -748223418L, -772868706L, -797397602L, -821806413L, -846091463L, - -870249095L, -894275671L, -918167572L, -941921200L, -965532978L, -988999351L, - -1012316784L, -1035481766L, -1058490808L, -1081340445L, -1104027237L, - -1126547765L, -1148898640L, -1171076495L, -1193077991L, -1214899813L, - -1236538675L, -1257991320L, -1279254516L, -1300325060L, -1321199781L, - -1341875533L, -1362349204L, -1382617710L, -1402678000L, -1422527051L, - -1442161874L, -1461579514L, -1480777044L, -1499751576L, -1518500250L, - -1537020244L, -1555308768L, -1573363068L, -1591180426L, -1608758157L, - -1626093616L, -1643184191L, -1660027308L, -1676620432L, -1692961062L, - -1709046739L, -1724875040L, -1740443581L, -1755750017L, -1770792044L, - -1785567396L, -1800073849L, -1814309216L, -1828271356L, -1841958164L, - -1855367581L, -1868497586L, -1881346202L, -1893911494L, -1906191570L, - -1918184581L, -1929888720L, -1941302225L, -1952423377L, -1963250501L, - -1973781967L, -1984016189L, -1993951625L, -2003586779L, -2012920201L, - -2021950484L, -2030676269L, -2039096241L, -2047209133L, -2055013723L, - -2062508835L, -2069693342L, -2076566160L, -2083126254L, -2089372638L, - -2095304370L, -2100920556L, -2106220352L, -2111202959L, -2115867626L, - -2120213651L, -2124240380L, -2127947206L, -2131333572L, -2134398966L, - -2137142927L, -2139565043L, -2141664948L, -2143442326L, -2144896910L, - -2146028480L, -2146836866L, -2147321946L, (q31_t)0x80000000, -2147321946L, - -2146836866L, -2146028480L, -2144896910L, -2143442326L, -2141664948L, - -2139565043L, -2137142927L, -2134398966L, -2131333572L, -2127947206L, - -2124240380L, -2120213651L, -2115867626L, -2111202959L, -2106220352L, - -2100920556L, -2095304370L, -2089372638L, -2083126254L, -2076566160L, - -2069693342L, -2062508835L, -2055013723L, -2047209133L, -2039096241L, - -2030676269L, -2021950484L, -2012920201L, -2003586779L, -1993951625L, - -1984016189L, -1973781967L, -1963250501L, -1952423377L, -1941302225L, - -1929888720L, -1918184581L, -1906191570L, -1893911494L, -1881346202L, - -1868497586L, -1855367581L, -1841958164L, -1828271356L, -1814309216L, - -1800073849L, -1785567396L, -1770792044L, -1755750017L, -1740443581L, - -1724875040L, -1709046739L, -1692961062L, -1676620432L, -1660027308L, - -1643184191L, -1626093616L, -1608758157L, -1591180426L, -1573363068L, - -1555308768L, -1537020244L, -1518500250L, -1499751576L, -1480777044L, - -1461579514L, -1442161874L, -1422527051L, -1402678000L, -1382617710L, - -1362349204L, -1341875533L, -1321199781L, -1300325060L, -1279254516L, - -1257991320L, -1236538675L, -1214899813L, -1193077991L, -1171076495L, - -1148898640L, -1126547765L, -1104027237L, -1081340445L, -1058490808L, - -1035481766L, -1012316784L, -988999351L, -965532978L, -941921200L, - -918167572L, -894275671L, -870249095L, -846091463L, -821806413L, -797397602L, - -772868706L, -748223418L, -723465451L, -698598533L, -673626408L, -648552838L, - -623381598L, -598116479L, -572761285L, -547319836L, -521795963L, -496193509L, - -470516330L, -444768294L, -418953276L, -393075166L, -367137861L, -341145265L, - -315101295L, -289009871L, -262874923L, -236700388L, -210490206L, -184248325L, - -157978697L, -131685278L, -105372028L, -79042909L, -52701887L, -26352928L, 0 -}; +const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1] = {0L, + 26352928L, + 52701887L, + 79042909L, + 105372028L, + 131685278L, + 157978697L, + 184248325L, + 210490206L, + 236700388L, + 262874923L, + 289009871L, + 315101295L, + 341145265L, + 367137861L, + 393075166L, + 418953276L, + 444768294L, + 470516330L, + 496193509L, + 521795963L, + 547319836L, + 572761285L, + 598116479L, + 623381598L, + 648552838L, + 673626408L, + 698598533L, + 723465451L, + 748223418L, + 772868706L, + 797397602L, + 821806413L, + 846091463L, + 870249095L, + 894275671L, + 918167572L, + 941921200L, + 965532978L, + 988999351L, + 1012316784L, + 1035481766L, + 1058490808L, + 1081340445L, + 1104027237L, + 1126547765L, + 1148898640L, + 1171076495L, + 1193077991L, + 1214899813L, + 1236538675L, + 1257991320L, + 1279254516L, + 1300325060L, + 1321199781L, + 1341875533L, + 1362349204L, + 1382617710L, + 1402678000L, + 1422527051L, + 1442161874L, + 1461579514L, + 1480777044L, + 1499751576L, + 1518500250L, + 1537020244L, + 1555308768L, + 1573363068L, + 1591180426L, + 1608758157L, + 1626093616L, + 1643184191L, + 1660027308L, + 1676620432L, + 1692961062L, + 1709046739L, + 1724875040L, + 1740443581L, + 1755750017L, + 1770792044L, + 1785567396L, + 1800073849L, + 1814309216L, + 1828271356L, + 1841958164L, + 1855367581L, + 1868497586L, + 1881346202L, + 1893911494L, + 1906191570L, + 1918184581L, + 1929888720L, + 1941302225L, + 1952423377L, + 1963250501L, + 1973781967L, + 1984016189L, + 1993951625L, + 2003586779L, + 2012920201L, + 2021950484L, + 2030676269L, + 2039096241L, + 2047209133L, + 2055013723L, + 2062508835L, + 2069693342L, + 2076566160L, + 2083126254L, + 2089372638L, + 2095304370L, + 2100920556L, + 2106220352L, + 2111202959L, + 2115867626L, + 2120213651L, + 2124240380L, + 2127947206L, + 2131333572L, + 2134398966L, + 2137142927L, + 2139565043L, + 2141664948L, + 2143442326L, + 2144896910L, + 2146028480L, + 2146836866L, + 2147321946L, + 2147483647L, + 2147321946L, + 2146836866L, + 2146028480L, + 2144896910L, + 2143442326L, + 2141664948L, + 2139565043L, + 2137142927L, + 2134398966L, + 2131333572L, + 2127947206L, + 2124240380L, + 2120213651L, + 2115867626L, + 2111202959L, + 2106220352L, + 2100920556L, + 2095304370L, + 2089372638L, + 2083126254L, + 2076566160L, + 2069693342L, + 2062508835L, + 2055013723L, + 2047209133L, + 2039096241L, + 2030676269L, + 2021950484L, + 2012920201L, + 2003586779L, + 1993951625L, + 1984016189L, + 1973781967L, + 1963250501L, + 1952423377L, + 1941302225L, + 1929888720L, + 1918184581L, + 1906191570L, + 1893911494L, + 1881346202L, + 1868497586L, + 1855367581L, + 1841958164L, + 1828271356L, + 1814309216L, + 1800073849L, + 1785567396L, + 1770792044L, + 1755750017L, + 1740443581L, + 1724875040L, + 1709046739L, + 1692961062L, + 1676620432L, + 1660027308L, + 1643184191L, + 1626093616L, + 1608758157L, + 1591180426L, + 1573363068L, + 1555308768L, + 1537020244L, + 1518500250L, + 1499751576L, + 1480777044L, + 1461579514L, + 1442161874L, + 1422527051L, + 1402678000L, + 1382617710L, + 1362349204L, + 1341875533L, + 1321199781L, + 1300325060L, + 1279254516L, + 1257991320L, + 1236538675L, + 1214899813L, + 1193077991L, + 1171076495L, + 1148898640L, + 1126547765L, + 1104027237L, + 1081340445L, + 1058490808L, + 1035481766L, + 1012316784L, + 988999351L, + 965532978L, + 941921200L, + 918167572L, + 894275671L, + 870249095L, + 846091463L, + 821806413L, + 797397602L, + 772868706L, + 748223418L, + 723465451L, + 698598533L, + 673626408L, + 648552838L, + 623381598L, + 598116479L, + 572761285L, + 547319836L, + 521795963L, + 496193509L, + 470516330L, + 444768294L, + 418953276L, + 393075166L, + 367137861L, + 341145265L, + 315101295L, + 289009871L, + 262874923L, + 236700388L, + 210490206L, + 184248325L, + 157978697L, + 131685278L, + 105372028L, + 79042909L, + 52701887L, + 26352928L, + 0L, + -26352928L, + -52701887L, + -79042909L, + -105372028L, + -131685278L, + -157978697L, + -184248325L, + -210490206L, + -236700388L, + -262874923L, + -289009871L, + -315101295L, + -341145265L, + -367137861L, + -393075166L, + -418953276L, + -444768294L, + -470516330L, + -496193509L, + -521795963L, + -547319836L, + -572761285L, + -598116479L, + -623381598L, + -648552838L, + -673626408L, + -698598533L, + -723465451L, + -748223418L, + -772868706L, + -797397602L, + -821806413L, + -846091463L, + -870249095L, + -894275671L, + -918167572L, + -941921200L, + -965532978L, + -988999351L, + -1012316784L, + -1035481766L, + -1058490808L, + -1081340445L, + -1104027237L, + -1126547765L, + -1148898640L, + -1171076495L, + -1193077991L, + -1214899813L, + -1236538675L, + -1257991320L, + -1279254516L, + -1300325060L, + -1321199781L, + -1341875533L, + -1362349204L, + -1382617710L, + -1402678000L, + -1422527051L, + -1442161874L, + -1461579514L, + -1480777044L, + -1499751576L, + -1518500250L, + -1537020244L, + -1555308768L, + -1573363068L, + -1591180426L, + -1608758157L, + -1626093616L, + -1643184191L, + -1660027308L, + -1676620432L, + -1692961062L, + -1709046739L, + -1724875040L, + -1740443581L, + -1755750017L, + -1770792044L, + -1785567396L, + -1800073849L, + -1814309216L, + -1828271356L, + -1841958164L, + -1855367581L, + -1868497586L, + -1881346202L, + -1893911494L, + -1906191570L, + -1918184581L, + -1929888720L, + -1941302225L, + -1952423377L, + -1963250501L, + -1973781967L, + -1984016189L, + -1993951625L, + -2003586779L, + -2012920201L, + -2021950484L, + -2030676269L, + -2039096241L, + -2047209133L, + -2055013723L, + -2062508835L, + -2069693342L, + -2076566160L, + -2083126254L, + -2089372638L, + -2095304370L, + -2100920556L, + -2106220352L, + -2111202959L, + -2115867626L, + -2120213651L, + -2124240380L, + -2127947206L, + -2131333572L, + -2134398966L, + -2137142927L, + -2139565043L, + -2141664948L, + -2143442326L, + -2144896910L, + -2146028480L, + -2146836866L, + -2147321946L, + (q31_t)0x80000000, + -2147321946L, + -2146836866L, + -2146028480L, + -2144896910L, + -2143442326L, + -2141664948L, + -2139565043L, + -2137142927L, + -2134398966L, + -2131333572L, + -2127947206L, + -2124240380L, + -2120213651L, + -2115867626L, + -2111202959L, + -2106220352L, + -2100920556L, + -2095304370L, + -2089372638L, + -2083126254L, + -2076566160L, + -2069693342L, + -2062508835L, + -2055013723L, + -2047209133L, + -2039096241L, + -2030676269L, + -2021950484L, + -2012920201L, + -2003586779L, + -1993951625L, + -1984016189L, + -1973781967L, + -1963250501L, + -1952423377L, + -1941302225L, + -1929888720L, + -1918184581L, + -1906191570L, + -1893911494L, + -1881346202L, + -1868497586L, + -1855367581L, + -1841958164L, + -1828271356L, + -1814309216L, + -1800073849L, + -1785567396L, + -1770792044L, + -1755750017L, + -1740443581L, + -1724875040L, + -1709046739L, + -1692961062L, + -1676620432L, + -1660027308L, + -1643184191L, + -1626093616L, + -1608758157L, + -1591180426L, + -1573363068L, + -1555308768L, + -1537020244L, + -1518500250L, + -1499751576L, + -1480777044L, + -1461579514L, + -1442161874L, + -1422527051L, + -1402678000L, + -1382617710L, + -1362349204L, + -1341875533L, + -1321199781L, + -1300325060L, + -1279254516L, + -1257991320L, + -1236538675L, + -1214899813L, + -1193077991L, + -1171076495L, + -1148898640L, + -1126547765L, + -1104027237L, + -1081340445L, + -1058490808L, + -1035481766L, + -1012316784L, + -988999351L, + -965532978L, + -941921200L, + -918167572L, + -894275671L, + -870249095L, + -846091463L, + -821806413L, + -797397602L, + -772868706L, + -748223418L, + -723465451L, + -698598533L, + -673626408L, + -648552838L, + -623381598L, + -598116479L, + -572761285L, + -547319836L, + -521795963L, + -496193509L, + -470516330L, + -444768294L, + -418953276L, + -393075166L, + -367137861L, + -341145265L, + -315101295L, + -289009871L, + -262874923L, + -236700388L, + -210490206L, + -184248325L, + -157978697L, + -131685278L, + -105372028L, + -79042909L, + -52701887L, + -26352928L, + 0}; /** @par @@ -22084,68 +13685,71 @@ const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1] = { tableSize = 512; for (n = 0; n < (tableSize + 1); n++) { - sinTable[n] = sin(2*PI*n/tableSize); + sinTable[n] = sin(2*PI*n/tableSize); } where PI value is 3.14159265358979 @par Second, convert floating-point to Q15 (Fixed point): - (sinTable[i] * pow(2, 15)) + (sinTable[i] * pow(2, 15)) @par Finally, round to the nearest integer value: - sinTable[i] += (sinTable[i] > 0 ? 0.5 :-0.5); + sinTable[i] += (sinTable[i] > 0 ? 0.5 :-0.5); */ const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1] = { - 0, 402, 804, 1206, 1608, 2009, 2411, 2811, 3212, 3612, 4011, 4410, 4808, - 5205, 5602, 5998, 6393, 6787, 7180, 7571, 7962, 8351, 8740, 9127, 9512, - 9896, 10279, 10660, 11039, 11417, 11793, 12167, 12540, 12910, 13279, - 13646, 14010, 14373, 14733, 15091, 15447, 15800, 16151, 16500, 16846, - 17190, 17531, 17869, 18205, 18538, 18868, 19195, 19520, 19841, 20160, - 20475, 20788, 21097, 21403, 21706, 22006, 22302, 22595, 22884, 23170, - 23453, 23732, 24008, 24279, 24548, 24812, 25073, 25330, 25583, 25833, - 26078, 26320, 26557, 26791, 27020, 27246, 27467, 27684, 27897, 28106, - 28311, 28511, 28707, 28899, 29086, 29269, 29448, 29622, 29792, 29957, - 30118, 30274, 30425, 30572, 30715, 30853, 30986, 31114, 31238, 31357, - 31471, 31581, 31686, 31786, 31881, 31972, 32058, 32138, 32214, 32286, - 32352, 32413, 32470, 32522, 32568, 32610, 32647, 32679, 32706, 32729, - 32746, 32758, 32766, 32767, 32766, 32758, 32746, 32729, 32706, 32679, - 32647, 32610, 32568, 32522, 32470, 32413, 32352, 32286, 32214, 32138, - 32058, 31972, 31881, 31786, 31686, 31581, 31471, 31357, 31238, 31114, - 30986, 30853, 30715, 30572, 30425, 30274, 30118, 29957, 29792, 29622, - 29448, 29269, 29086, 28899, 28707, 28511, 28311, 28106, 27897, 27684, - 27467, 27246, 27020, 26791, 26557, 26320, 26078, 25833, 25583, 25330, - 25073, 24812, 24548, 24279, 24008, 23732, 23453, 23170, 22884, 22595, - 22302, 22006, 21706, 21403, 21097, 20788, 20475, 20160, 19841, 19520, - 19195, 18868, 18538, 18205, 17869, 17531, 17190, 16846, 16500, 16151, - 15800, 15447, 15091, 14733, 14373, 14010, 13646, 13279, 12910, 12540, - 12167, 11793, 11417, 11039, 10660, 10279, 9896, 9512, 9127, 8740, 8351, - 7962, 7571, 7180, 6787, 6393, 5998, 5602, 5205, 4808, 4410, 4011, 3612, - 3212, 2811, 2411, 2009, 1608, 1206, 804, 402, 0, -402, -804, -1206, - -1608, -2009, -2411, -2811, -3212, -3612, -4011, -4410, -4808, -5205, - -5602, -5998, -6393, -6787, -7180, -7571, -7962, -8351, -8740, -9127, - -9512, -9896, -10279, -10660, -11039, -11417, -11793, -12167, -12540, - -12910, -13279, -13646, -14010, -14373, -14733, -15091, -15447, -15800, - -16151, -16500, -16846, -17190, -17531, -17869, -18205, -18538, -18868, - -19195, -19520, -19841, -20160, -20475, -20788, -21097, -21403, -21706, - -22006, -22302, -22595, -22884, -23170, -23453, -23732, -24008, -24279, - -24548, -24812, -25073, -25330, -25583, -25833, -26078, -26320, -26557, - -26791, -27020, -27246, -27467, -27684, -27897, -28106, -28311, -28511, - -28707, -28899, -29086, -29269, -29448, -29622, -29792, -29957, -30118, - -30274, -30425, -30572, -30715, -30853, -30986, -31114, -31238, -31357, - -31471, -31581, -31686, -31786, -31881, -31972, -32058, -32138, -32214, - -32286, -32352, -32413, -32470, -32522, -32568, -32610, -32647, -32679, - -32706, -32729, -32746, -32758, -32766, -32768, -32766, -32758, -32746, - -32729, -32706, -32679, -32647, -32610, -32568, -32522, -32470, -32413, - -32352, -32286, -32214, -32138, -32058, -31972, -31881, -31786, -31686, - -31581, -31471, -31357, -31238, -31114, -30986, -30853, -30715, -30572, - -30425, -30274, -30118, -29957, -29792, -29622, -29448, -29269, -29086, - -28899, -28707, -28511, -28311, -28106, -27897, -27684, -27467, -27246, - -27020, -26791, -26557, -26320, -26078, -25833, -25583, -25330, -25073, - -24812, -24548, -24279, -24008, -23732, -23453, -23170, -22884, -22595, - -22302, -22006, -21706, -21403, -21097, -20788, -20475, -20160, -19841, - -19520, -19195, -18868, -18538, -18205, -17869, -17531, -17190, -16846, - -16500, -16151, -15800, -15447, -15091, -14733, -14373, -14010, -13646, - -13279, -12910, -12540, -12167, -11793, -11417, -11039, -10660, -10279, - -9896, -9512, -9127, -8740, -8351, -7962, -7571, -7180, -6787, -6393, - -5998, -5602, -5205, -4808, -4410, -4011, -3612, -3212, -2811, -2411, - -2009, -1608, -1206, -804, -402, 0 -}; + 0, 402, 804, 1206, 1608, 2009, 2411, 2811, 3212, + 3612, 4011, 4410, 4808, 5205, 5602, 5998, 6393, 6787, + 7180, 7571, 7962, 8351, 8740, 9127, 9512, 9896, 10279, + 10660, 11039, 11417, 11793, 12167, 12540, 12910, 13279, 13646, + 14010, 14373, 14733, 15091, 15447, 15800, 16151, 16500, 16846, + 17190, 17531, 17869, 18205, 18538, 18868, 19195, 19520, 19841, + 20160, 20475, 20788, 21097, 21403, 21706, 22006, 22302, 22595, + 22884, 23170, 23453, 23732, 24008, 24279, 24548, 24812, 25073, + 25330, 25583, 25833, 26078, 26320, 26557, 26791, 27020, 27246, + 27467, 27684, 27897, 28106, 28311, 28511, 28707, 28899, 29086, + 29269, 29448, 29622, 29792, 29957, 30118, 30274, 30425, 30572, + 30715, 30853, 30986, 31114, 31238, 31357, 31471, 31581, 31686, + 31786, 31881, 31972, 32058, 32138, 32214, 32286, 32352, 32413, + 32470, 32522, 32568, 32610, 32647, 32679, 32706, 32729, 32746, + 32758, 32766, 32767, 32766, 32758, 32746, 32729, 32706, 32679, + 32647, 32610, 32568, 32522, 32470, 32413, 32352, 32286, 32214, + 32138, 32058, 31972, 31881, 31786, 31686, 31581, 31471, 31357, + 31238, 31114, 30986, 30853, 30715, 30572, 30425, 30274, 30118, + 29957, 29792, 29622, 29448, 29269, 29086, 28899, 28707, 28511, + 28311, 28106, 27897, 27684, 27467, 27246, 27020, 26791, 26557, + 26320, 26078, 25833, 25583, 25330, 25073, 24812, 24548, 24279, + 24008, 23732, 23453, 23170, 22884, 22595, 22302, 22006, 21706, + 21403, 21097, 20788, 20475, 20160, 19841, 19520, 19195, 18868, + 18538, 18205, 17869, 17531, 17190, 16846, 16500, 16151, 15800, + 15447, 15091, 14733, 14373, 14010, 13646, 13279, 12910, 12540, + 12167, 11793, 11417, 11039, 10660, 10279, 9896, 9512, 9127, + 8740, 8351, 7962, 7571, 7180, 6787, 6393, 5998, 5602, + 5205, 4808, 4410, 4011, 3612, 3212, 2811, 2411, 2009, + 1608, 1206, 804, 402, 0, -402, -804, -1206, -1608, + -2009, -2411, -2811, -3212, -3612, -4011, -4410, -4808, -5205, + -5602, -5998, -6393, -6787, -7180, -7571, -7962, -8351, -8740, + -9127, -9512, -9896, -10279, -10660, -11039, -11417, -11793, -12167, + -12540, -12910, -13279, -13646, -14010, -14373, -14733, -15091, -15447, + -15800, -16151, -16500, -16846, -17190, -17531, -17869, -18205, -18538, + -18868, -19195, -19520, -19841, -20160, -20475, -20788, -21097, -21403, + -21706, -22006, -22302, -22595, -22884, -23170, -23453, -23732, -24008, + -24279, -24548, -24812, -25073, -25330, -25583, -25833, -26078, -26320, + -26557, -26791, -27020, -27246, -27467, -27684, -27897, -28106, -28311, + -28511, -28707, -28899, -29086, -29269, -29448, -29622, -29792, -29957, + -30118, -30274, -30425, -30572, -30715, -30853, -30986, -31114, -31238, + -31357, -31471, -31581, -31686, -31786, -31881, -31972, -32058, -32138, + -32214, -32286, -32352, -32413, -32470, -32522, -32568, -32610, -32647, + -32679, -32706, -32729, -32746, -32758, -32766, -32768, -32766, -32758, + -32746, -32729, -32706, -32679, -32647, -32610, -32568, -32522, -32470, + -32413, -32352, -32286, -32214, -32138, -32058, -31972, -31881, -31786, + -31686, -31581, -31471, -31357, -31238, -31114, -30986, -30853, -30715, + -30572, -30425, -30274, -30118, -29957, -29792, -29622, -29448, -29269, + -29086, -28899, -28707, -28511, -28311, -28106, -27897, -27684, -27467, + -27246, -27020, -26791, -26557, -26320, -26078, -25833, -25583, -25330, + -25073, -24812, -24548, -24279, -24008, -23732, -23453, -23170, -22884, + -22595, -22302, -22006, -21706, -21403, -21097, -20788, -20475, -20160, + -19841, -19520, -19195, -18868, -18538, -18205, -17869, -17531, -17190, + -16846, -16500, -16151, -15800, -15447, -15091, -14733, -14373, -14010, + -13646, -13279, -12910, -12540, -12167, -11793, -11417, -11039, -10660, + -10279, -9896, -9512, -9127, -8740, -8351, -7962, -7571, -7180, + -6787, -6393, -5998, -5602, -5205, -4808, -4410, -4011, -3612, + -3212, -2811, -2411, -2009, -1608, -1206, -804, -402, 0}; diff --git a/platform/cmsis/DSP_Lib/CommonTables/arm_const_structs.c b/platform/cmsis/DSP_Lib/CommonTables/arm_const_structs.c index f0c114c..1573598 100644 --- a/platform/cmsis/DSP_Lib/CommonTables/arm_const_structs.c +++ b/platform/cmsis/DSP_Lib/CommonTables/arm_const_structs.c @@ -2,7 +2,8 @@ * Project: CMSIS DSP Library * Title: arm_const_structs.c * Description: Constant structs that are initialized for user convenience. - * For example, some can be given as arguments to the arm_cfft_f32() or arm_rfft_f32() functions. + * For example, some can be given as arguments to the + * arm_cfft_f32() or arm_rfft_f32() functions. * * $Date: 27. January 2017 * $Revision: V.1.5.1 @@ -31,349 +32,319 @@ /* Floating-point structs */ const arm_cfft_instance_f32 arm_cfft_sR_f32_len16 = { - 16, twiddleCoef_16, armBitRevIndexTable16, ARMBITREVINDEXTABLE_16_TABLE_LENGTH -}; + 16, twiddleCoef_16, armBitRevIndexTable16, + ARMBITREVINDEXTABLE_16_TABLE_LENGTH}; const arm_cfft_instance_f32 arm_cfft_sR_f32_len32 = { - 32, twiddleCoef_32, armBitRevIndexTable32, ARMBITREVINDEXTABLE_32_TABLE_LENGTH -}; + 32, twiddleCoef_32, armBitRevIndexTable32, + ARMBITREVINDEXTABLE_32_TABLE_LENGTH}; const arm_cfft_instance_f32 arm_cfft_sR_f32_len64 = { - 64, twiddleCoef_64, armBitRevIndexTable64, ARMBITREVINDEXTABLE_64_TABLE_LENGTH -}; + 64, twiddleCoef_64, armBitRevIndexTable64, + ARMBITREVINDEXTABLE_64_TABLE_LENGTH}; const arm_cfft_instance_f32 arm_cfft_sR_f32_len128 = { - 128, twiddleCoef_128, armBitRevIndexTable128, ARMBITREVINDEXTABLE_128_TABLE_LENGTH -}; + 128, twiddleCoef_128, armBitRevIndexTable128, + ARMBITREVINDEXTABLE_128_TABLE_LENGTH}; const arm_cfft_instance_f32 arm_cfft_sR_f32_len256 = { - 256, twiddleCoef_256, armBitRevIndexTable256, ARMBITREVINDEXTABLE_256_TABLE_LENGTH -}; + 256, twiddleCoef_256, armBitRevIndexTable256, + ARMBITREVINDEXTABLE_256_TABLE_LENGTH}; const arm_cfft_instance_f32 arm_cfft_sR_f32_len512 = { - 512, twiddleCoef_512, armBitRevIndexTable512, ARMBITREVINDEXTABLE_512_TABLE_LENGTH -}; + 512, twiddleCoef_512, armBitRevIndexTable512, + ARMBITREVINDEXTABLE_512_TABLE_LENGTH}; const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024 = { - 1024, twiddleCoef_1024, armBitRevIndexTable1024, ARMBITREVINDEXTABLE_1024_TABLE_LENGTH -}; + 1024, twiddleCoef_1024, armBitRevIndexTable1024, + ARMBITREVINDEXTABLE_1024_TABLE_LENGTH}; const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048 = { - 2048, twiddleCoef_2048, armBitRevIndexTable2048, ARMBITREVINDEXTABLE_2048_TABLE_LENGTH -}; + 2048, twiddleCoef_2048, armBitRevIndexTable2048, + ARMBITREVINDEXTABLE_2048_TABLE_LENGTH}; const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096 = { - 4096, twiddleCoef_4096, armBitRevIndexTable4096, ARMBITREVINDEXTABLE_4096_TABLE_LENGTH -}; + 4096, twiddleCoef_4096, armBitRevIndexTable4096, + ARMBITREVINDEXTABLE_4096_TABLE_LENGTH}; /* Fixed-point structs */ const arm_cfft_instance_q31 arm_cfft_sR_q31_len16 = { - 16, twiddleCoef_16_q31, armBitRevIndexTable_fixed_16, ARMBITREVINDEXTABLE_FIXED_16_TABLE_LENGTH -}; + 16, twiddleCoef_16_q31, armBitRevIndexTable_fixed_16, + ARMBITREVINDEXTABLE_FIXED_16_TABLE_LENGTH}; const arm_cfft_instance_q31 arm_cfft_sR_q31_len32 = { - 32, twiddleCoef_32_q31, armBitRevIndexTable_fixed_32, ARMBITREVINDEXTABLE_FIXED_32_TABLE_LENGTH -}; + 32, twiddleCoef_32_q31, armBitRevIndexTable_fixed_32, + ARMBITREVINDEXTABLE_FIXED_32_TABLE_LENGTH}; const arm_cfft_instance_q31 arm_cfft_sR_q31_len64 = { - 64, twiddleCoef_64_q31, armBitRevIndexTable_fixed_64, ARMBITREVINDEXTABLE_FIXED_64_TABLE_LENGTH -}; + 64, twiddleCoef_64_q31, armBitRevIndexTable_fixed_64, + ARMBITREVINDEXTABLE_FIXED_64_TABLE_LENGTH}; const arm_cfft_instance_q31 arm_cfft_sR_q31_len128 = { - 128, twiddleCoef_128_q31, armBitRevIndexTable_fixed_128, ARMBITREVINDEXTABLE_FIXED_128_TABLE_LENGTH -}; + 128, twiddleCoef_128_q31, armBitRevIndexTable_fixed_128, + ARMBITREVINDEXTABLE_FIXED_128_TABLE_LENGTH}; const arm_cfft_instance_q31 arm_cfft_sR_q31_len256 = { - 256, twiddleCoef_256_q31, armBitRevIndexTable_fixed_256, ARMBITREVINDEXTABLE_FIXED_256_TABLE_LENGTH -}; + 256, twiddleCoef_256_q31, armBitRevIndexTable_fixed_256, + ARMBITREVINDEXTABLE_FIXED_256_TABLE_LENGTH}; const arm_cfft_instance_q31 arm_cfft_sR_q31_len512 = { - 512, twiddleCoef_512_q31, armBitRevIndexTable_fixed_512, ARMBITREVINDEXTABLE_FIXED_512_TABLE_LENGTH -}; + 512, twiddleCoef_512_q31, armBitRevIndexTable_fixed_512, + ARMBITREVINDEXTABLE_FIXED_512_TABLE_LENGTH}; const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024 = { - 1024, twiddleCoef_1024_q31, armBitRevIndexTable_fixed_1024, ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH -}; + 1024, twiddleCoef_1024_q31, armBitRevIndexTable_fixed_1024, + ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH}; const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048 = { - 2048, twiddleCoef_2048_q31, armBitRevIndexTable_fixed_2048, ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH -}; + 2048, twiddleCoef_2048_q31, armBitRevIndexTable_fixed_2048, + ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH}; const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096 = { - 4096, twiddleCoef_4096_q31, armBitRevIndexTable_fixed_4096, ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH -}; + 4096, twiddleCoef_4096_q31, armBitRevIndexTable_fixed_4096, + ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH}; const arm_cfft_instance_q15 arm_cfft_sR_q15_len16 = { - 16, twiddleCoef_16_q15, armBitRevIndexTable_fixed_16, ARMBITREVINDEXTABLE_FIXED_16_TABLE_LENGTH -}; + 16, twiddleCoef_16_q15, armBitRevIndexTable_fixed_16, + ARMBITREVINDEXTABLE_FIXED_16_TABLE_LENGTH}; const arm_cfft_instance_q15 arm_cfft_sR_q15_len32 = { - 32, twiddleCoef_32_q15, armBitRevIndexTable_fixed_32, ARMBITREVINDEXTABLE_FIXED_32_TABLE_LENGTH -}; + 32, twiddleCoef_32_q15, armBitRevIndexTable_fixed_32, + ARMBITREVINDEXTABLE_FIXED_32_TABLE_LENGTH}; const arm_cfft_instance_q15 arm_cfft_sR_q15_len64 = { - 64, twiddleCoef_64_q15, armBitRevIndexTable_fixed_64, ARMBITREVINDEXTABLE_FIXED_64_TABLE_LENGTH -}; + 64, twiddleCoef_64_q15, armBitRevIndexTable_fixed_64, + ARMBITREVINDEXTABLE_FIXED_64_TABLE_LENGTH}; const arm_cfft_instance_q15 arm_cfft_sR_q15_len128 = { - 128, twiddleCoef_128_q15, armBitRevIndexTable_fixed_128, ARMBITREVINDEXTABLE_FIXED_128_TABLE_LENGTH -}; + 128, twiddleCoef_128_q15, armBitRevIndexTable_fixed_128, + ARMBITREVINDEXTABLE_FIXED_128_TABLE_LENGTH}; const arm_cfft_instance_q15 arm_cfft_sR_q15_len256 = { - 256, twiddleCoef_256_q15, armBitRevIndexTable_fixed_256, ARMBITREVINDEXTABLE_FIXED_256_TABLE_LENGTH -}; + 256, twiddleCoef_256_q15, armBitRevIndexTable_fixed_256, + ARMBITREVINDEXTABLE_FIXED_256_TABLE_LENGTH}; const arm_cfft_instance_q15 arm_cfft_sR_q15_len512 = { - 512, twiddleCoef_512_q15, armBitRevIndexTable_fixed_512, ARMBITREVINDEXTABLE_FIXED_512_TABLE_LENGTH -}; + 512, twiddleCoef_512_q15, armBitRevIndexTable_fixed_512, + ARMBITREVINDEXTABLE_FIXED_512_TABLE_LENGTH}; const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024 = { - 1024, twiddleCoef_1024_q15, armBitRevIndexTable_fixed_1024, ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH -}; + 1024, twiddleCoef_1024_q15, armBitRevIndexTable_fixed_1024, + ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH}; const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048 = { - 2048, twiddleCoef_2048_q15, armBitRevIndexTable_fixed_2048, ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH -}; + 2048, twiddleCoef_2048_q15, armBitRevIndexTable_fixed_2048, + ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH}; const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096 = { - 4096, twiddleCoef_4096_q15, armBitRevIndexTable_fixed_4096, ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH -}; + 4096, twiddleCoef_4096_q15, armBitRevIndexTable_fixed_4096, + ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH}; /* Structure for real-value inputs */ /* Floating-point structs */ const arm_rfft_fast_instance_f32 arm_rfft_fast_sR_f32_len32 = { - { 16, twiddleCoef_32, armBitRevIndexTable32, ARMBITREVINDEXTABLE_16_TABLE_LENGTH }, - 32U, - (float32_t *)twiddleCoef_rfft_32 -}; + {16, twiddleCoef_32, armBitRevIndexTable32, + ARMBITREVINDEXTABLE_16_TABLE_LENGTH}, + 32U, + (float32_t *)twiddleCoef_rfft_32}; const arm_rfft_fast_instance_f32 arm_rfft_fast_sR_f32_len64 = { - { 32, twiddleCoef_32, armBitRevIndexTable32, ARMBITREVINDEXTABLE_32_TABLE_LENGTH }, - 64U, - (float32_t *)twiddleCoef_rfft_64 -}; + {32, twiddleCoef_32, armBitRevIndexTable32, + ARMBITREVINDEXTABLE_32_TABLE_LENGTH}, + 64U, + (float32_t *)twiddleCoef_rfft_64}; const arm_rfft_fast_instance_f32 arm_rfft_fast_sR_f32_len128 = { - { 64, twiddleCoef_64, armBitRevIndexTable64, ARMBITREVINDEXTABLE_64_TABLE_LENGTH }, - 128U, - (float32_t *)twiddleCoef_rfft_128 -}; + {64, twiddleCoef_64, armBitRevIndexTable64, + ARMBITREVINDEXTABLE_64_TABLE_LENGTH}, + 128U, + (float32_t *)twiddleCoef_rfft_128}; const arm_rfft_fast_instance_f32 arm_rfft_fast_sR_f32_len256 = { - { 128, twiddleCoef_128, armBitRevIndexTable128, ARMBITREVINDEXTABLE_128_TABLE_LENGTH }, - 256U, - (float32_t *)twiddleCoef_rfft_256 -}; + {128, twiddleCoef_128, armBitRevIndexTable128, + ARMBITREVINDEXTABLE_128_TABLE_LENGTH}, + 256U, + (float32_t *)twiddleCoef_rfft_256}; const arm_rfft_fast_instance_f32 arm_rfft_fast_sR_f32_len512 = { - { 256, twiddleCoef_256, armBitRevIndexTable256, ARMBITREVINDEXTABLE_256_TABLE_LENGTH }, - 512U, - (float32_t *)twiddleCoef_rfft_512 -}; + {256, twiddleCoef_256, armBitRevIndexTable256, + ARMBITREVINDEXTABLE_256_TABLE_LENGTH}, + 512U, + (float32_t *)twiddleCoef_rfft_512}; const arm_rfft_fast_instance_f32 arm_rfft_fast_sR_f32_len1024 = { - { 512, twiddleCoef_512, armBitRevIndexTable512, ARMBITREVINDEXTABLE_512_TABLE_LENGTH }, - 1024U, - (float32_t *)twiddleCoef_rfft_1024 -}; + {512, twiddleCoef_512, armBitRevIndexTable512, + ARMBITREVINDEXTABLE_512_TABLE_LENGTH}, + 1024U, + (float32_t *)twiddleCoef_rfft_1024}; const arm_rfft_fast_instance_f32 arm_rfft_fast_sR_f32_len2048 = { - { 1024, twiddleCoef_1024, armBitRevIndexTable1024, ARMBITREVINDEXTABLE_1024_TABLE_LENGTH }, - 2048U, - (float32_t *)twiddleCoef_rfft_2048 -}; + {1024, twiddleCoef_1024, armBitRevIndexTable1024, + ARMBITREVINDEXTABLE_1024_TABLE_LENGTH}, + 2048U, + (float32_t *)twiddleCoef_rfft_2048}; const arm_rfft_fast_instance_f32 arm_rfft_fast_sR_f32_len4096 = { - { 2048, twiddleCoef_2048, armBitRevIndexTable2048, ARMBITREVINDEXTABLE_2048_TABLE_LENGTH }, - 4096U, - (float32_t *)twiddleCoef_rfft_4096 -}; + {2048, twiddleCoef_2048, armBitRevIndexTable2048, + ARMBITREVINDEXTABLE_2048_TABLE_LENGTH}, + 4096U, + (float32_t *)twiddleCoef_rfft_4096}; /* Fixed-point structs */ /* q31_t */ extern const q31_t realCoefAQ31[8192]; extern const q31_t realCoefBQ31[8192]; -const arm_rfft_instance_q31 arm_rfft_sR_q31_len32 = { - 32U, - 0, - 1, - 256U, - (q31_t*)realCoefAQ31, - (q31_t*)realCoefBQ31, - &arm_cfft_sR_q31_len16 -}; +const arm_rfft_instance_q31 arm_rfft_sR_q31_len32 = {32U, + 0, + 1, + 256U, + (q31_t *)realCoefAQ31, + (q31_t *)realCoefBQ31, + &arm_cfft_sR_q31_len16}; -const arm_rfft_instance_q31 arm_rfft_sR_q31_len64 = { - 64U, - 0, - 1, - 128U, - (q31_t*)realCoefAQ31, - (q31_t*)realCoefBQ31, - &arm_cfft_sR_q31_len32 -}; +const arm_rfft_instance_q31 arm_rfft_sR_q31_len64 = {64U, + 0, + 1, + 128U, + (q31_t *)realCoefAQ31, + (q31_t *)realCoefBQ31, + &arm_cfft_sR_q31_len32}; -const arm_rfft_instance_q31 arm_rfft_sR_q31_len128 = { - 128U, - 0, - 1, - 64U, - (q31_t*)realCoefAQ31, - (q31_t*)realCoefBQ31, - &arm_cfft_sR_q31_len64 -}; +const arm_rfft_instance_q31 arm_rfft_sR_q31_len128 = {128U, + 0, + 1, + 64U, + (q31_t *)realCoefAQ31, + (q31_t *)realCoefBQ31, + &arm_cfft_sR_q31_len64}; -const arm_rfft_instance_q31 arm_rfft_sR_q31_len256 = { - 256U, - 0, - 1, - 32U, - (q31_t*)realCoefAQ31, - (q31_t*)realCoefBQ31, - &arm_cfft_sR_q31_len128 -}; +const arm_rfft_instance_q31 arm_rfft_sR_q31_len256 = {256U, + 0, + 1, + 32U, + (q31_t *)realCoefAQ31, + (q31_t *)realCoefBQ31, + &arm_cfft_sR_q31_len128}; -const arm_rfft_instance_q31 arm_rfft_sR_q31_len512 = { - 512U, - 0, - 1, - 16U, - (q31_t*)realCoefAQ31, - (q31_t*)realCoefBQ31, - &arm_cfft_sR_q31_len256 -}; +const arm_rfft_instance_q31 arm_rfft_sR_q31_len512 = {512U, + 0, + 1, + 16U, + (q31_t *)realCoefAQ31, + (q31_t *)realCoefBQ31, + &arm_cfft_sR_q31_len256}; -const arm_rfft_instance_q31 arm_rfft_sR_q31_len1024 = { - 1024U, - 0, - 1, - 8U, - (q31_t*)realCoefAQ31, - (q31_t*)realCoefBQ31, - &arm_cfft_sR_q31_len512 -}; +const arm_rfft_instance_q31 arm_rfft_sR_q31_len1024 = {1024U, + 0, + 1, + 8U, + (q31_t *)realCoefAQ31, + (q31_t *)realCoefBQ31, + &arm_cfft_sR_q31_len512}; const arm_rfft_instance_q31 arm_rfft_sR_q31_len2048 = { - 2048U, - 0, - 1, - 4U, - (q31_t*)realCoefAQ31, - (q31_t*)realCoefBQ31, - &arm_cfft_sR_q31_len1024 -}; + 2048U, + 0, + 1, + 4U, + (q31_t *)realCoefAQ31, + (q31_t *)realCoefBQ31, + &arm_cfft_sR_q31_len1024}; const arm_rfft_instance_q31 arm_rfft_sR_q31_len4096 = { - 4096U, - 0, - 1, - 2U, - (q31_t*)realCoefAQ31, - (q31_t*)realCoefBQ31, - &arm_cfft_sR_q31_len2048 -}; + 4096U, + 0, + 1, + 2U, + (q31_t *)realCoefAQ31, + (q31_t *)realCoefBQ31, + &arm_cfft_sR_q31_len2048}; const arm_rfft_instance_q31 arm_rfft_sR_q31_len8192 = { - 8192U, - 0, - 1, - 1U, - (q31_t*)realCoefAQ31, - (q31_t*)realCoefBQ31, - &arm_cfft_sR_q31_len4096 -}; + 8192U, + 0, + 1, + 1U, + (q31_t *)realCoefAQ31, + (q31_t *)realCoefBQ31, + &arm_cfft_sR_q31_len4096}; /* q15_t */ extern const q15_t realCoefAQ15[8192]; extern const q15_t realCoefBQ15[8192]; -const arm_rfft_instance_q15 arm_rfft_sR_q15_len32 = { - 32U, - 0, - 1, - 256U, - (q15_t*)realCoefAQ15, - (q15_t*)realCoefBQ15, - &arm_cfft_sR_q15_len16 -}; +const arm_rfft_instance_q15 arm_rfft_sR_q15_len32 = {32U, + 0, + 1, + 256U, + (q15_t *)realCoefAQ15, + (q15_t *)realCoefBQ15, + &arm_cfft_sR_q15_len16}; -const arm_rfft_instance_q15 arm_rfft_sR_q15_len64 = { - 64U, - 0, - 1, - 128U, - (q15_t*)realCoefAQ15, - (q15_t*)realCoefBQ15, - &arm_cfft_sR_q15_len32 -}; +const arm_rfft_instance_q15 arm_rfft_sR_q15_len64 = {64U, + 0, + 1, + 128U, + (q15_t *)realCoefAQ15, + (q15_t *)realCoefBQ15, + &arm_cfft_sR_q15_len32}; -const arm_rfft_instance_q15 arm_rfft_sR_q15_len128 = { - 128U, - 0, - 1, - 64U, - (q15_t*)realCoefAQ15, - (q15_t*)realCoefBQ15, - &arm_cfft_sR_q15_len64 -}; +const arm_rfft_instance_q15 arm_rfft_sR_q15_len128 = {128U, + 0, + 1, + 64U, + (q15_t *)realCoefAQ15, + (q15_t *)realCoefBQ15, + &arm_cfft_sR_q15_len64}; -const arm_rfft_instance_q15 arm_rfft_sR_q15_len256 = { - 256U, - 0, - 1, - 32U, - (q15_t*)realCoefAQ15, - (q15_t*)realCoefBQ15, - &arm_cfft_sR_q15_len128 -}; +const arm_rfft_instance_q15 arm_rfft_sR_q15_len256 = {256U, + 0, + 1, + 32U, + (q15_t *)realCoefAQ15, + (q15_t *)realCoefBQ15, + &arm_cfft_sR_q15_len128}; -const arm_rfft_instance_q15 arm_rfft_sR_q15_len512 = { - 512U, - 0, - 1, - 16U, - (q15_t*)realCoefAQ15, - (q15_t*)realCoefBQ15, - &arm_cfft_sR_q15_len256 -}; +const arm_rfft_instance_q15 arm_rfft_sR_q15_len512 = {512U, + 0, + 1, + 16U, + (q15_t *)realCoefAQ15, + (q15_t *)realCoefBQ15, + &arm_cfft_sR_q15_len256}; -const arm_rfft_instance_q15 arm_rfft_sR_q15_len1024 = { - 1024U, - 0, - 1, - 8U, - (q15_t*)realCoefAQ15, - (q15_t*)realCoefBQ15, - &arm_cfft_sR_q15_len512 -}; +const arm_rfft_instance_q15 arm_rfft_sR_q15_len1024 = {1024U, + 0, + 1, + 8U, + (q15_t *)realCoefAQ15, + (q15_t *)realCoefBQ15, + &arm_cfft_sR_q15_len512}; const arm_rfft_instance_q15 arm_rfft_sR_q15_len2048 = { - 2048U, - 0, - 1, - 4U, - (q15_t*)realCoefAQ15, - (q15_t*)realCoefBQ15, - &arm_cfft_sR_q15_len1024 -}; + 2048U, + 0, + 1, + 4U, + (q15_t *)realCoefAQ15, + (q15_t *)realCoefBQ15, + &arm_cfft_sR_q15_len1024}; const arm_rfft_instance_q15 arm_rfft_sR_q15_len4096 = { - 4096U, - 0, - 1, - 2U, - (q15_t*)realCoefAQ15, - (q15_t*)realCoefBQ15, - &arm_cfft_sR_q15_len2048 -}; + 4096U, + 0, + 1, + 2U, + (q15_t *)realCoefAQ15, + (q15_t *)realCoefBQ15, + &arm_cfft_sR_q15_len2048}; const arm_rfft_instance_q15 arm_rfft_sR_q15_len8192 = { - 8192U, - 0, - 1, - 1U, - (q15_t*)realCoefAQ15, - (q15_t*)realCoefBQ15, - &arm_cfft_sR_q15_len4096 -}; + 8192U, + 0, + 1, + 1U, + (q15_t *)realCoefAQ15, + (q15_t *)realCoefBQ15, + &arm_cfft_sR_q15_len4096}; diff --git a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_conj_f32.c b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_conj_f32.c index 6387de5..dfd2fe7 100644 --- a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_conj_f32.c +++ b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_conj_f32.c @@ -38,11 +38,10 @@ Conjugates the elements of a complex data vector. The pSrc points to the source data and - pDst points to the destination data where the result should be written. - numSamples specifies the number of complex samples - and the data in each array is stored in an interleaved fashion - (real, imag, real, imag, ...). - Each array has a total of 2*numSamples values. + pDst points to the destination data where the result should be + written. numSamples specifies the number of complex samples and + the data in each array is stored in an interleaved fashion (real, imag, real, + imag, ...). Each array has a total of 2*numSamples values. The underlying algorithm is used:
@@ -68,33 +67,29 @@
   @return        none
  */
 
-void arm_cmplx_conj_f32(
-  const float32_t * pSrc,
-        float32_t * pDst,
-        uint32_t numSamples)
-{
-        uint32_t blkCnt;                               /* Loop counter */
+void arm_cmplx_conj_f32(const float32_t *pSrc, float32_t *pDst,
+                        uint32_t numSamples) {
+  uint32_t blkCnt; /* Loop counter */
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
   /* Loop unrolling: Compute 4 outputs at a time */
   blkCnt = numSamples >> 2U;
 
-  while (blkCnt > 0U)
-  {
+  while (blkCnt > 0U) {
     /* C[0] + jC[1] = A[0]+ j(-1)A[1] */
 
     /* Calculate Complex Conjugate and store result in destination buffer. */
-    *pDst++ =  *pSrc++;
+    *pDst++ = *pSrc++;
     *pDst++ = -*pSrc++;
 
-    *pDst++ =  *pSrc++;
+    *pDst++ = *pSrc++;
     *pDst++ = -*pSrc++;
 
-    *pDst++ =  *pSrc++;
+    *pDst++ = *pSrc++;
     *pDst++ = -*pSrc++;
 
-    *pDst++ =  *pSrc++;
+    *pDst++ = *pSrc++;
     *pDst++ = -*pSrc++;
 
     /* Decrement loop counter */
@@ -111,18 +106,16 @@ void arm_cmplx_conj_f32(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-  while (blkCnt > 0U)
-  {
+  while (blkCnt > 0U) {
     /* C[0] + jC[1] = A[0]+ j(-1)A[1] */
 
     /* Calculate Complex Conjugate and store result in destination buffer. */
-    *pDst++ =  *pSrc++;
+    *pDst++ = *pSrc++;
     *pDst++ = -*pSrc++;
 
     /* Decrement loop counter */
     blkCnt--;
   }
-
 }
 
 /**
diff --git a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_conj_q15.c b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_conj_q15.c
index 073a337..41228f7 100644
--- a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_conj_q15.c
+++ b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_conj_q15.c
@@ -46,38 +46,33 @@
 
   @par           Scaling and Overflow Behavior
                    The function uses saturating arithmetic.
-                   The Q15 value -1 (0x8000) is saturated to the maximum allowable positive value 0x7FFF.
+                   The Q15 value -1 (0x8000) is saturated to the maximum
+  allowable positive value 0x7FFF.
  */
 
-void arm_cmplx_conj_q15(
-  const q15_t * pSrc,
-        q15_t * pDst,
-        uint32_t numSamples)
-{
-        uint32_t blkCnt;                               /* Loop counter */
-        q31_t in1;                                     /* Temporary input variable */
+void arm_cmplx_conj_q15(const q15_t *pSrc, q15_t *pDst, uint32_t numSamples) {
+  uint32_t blkCnt; /* Loop counter */
+  q31_t in1;       /* Temporary input variable */
 
-#if defined (ARM_MATH_LOOPUNROLL) && defined (ARM_MATH_DSP)
-        q31_t in2, in3, in4;                           /* Temporary input variables */
+#if defined(ARM_MATH_LOOPUNROLL) && defined(ARM_MATH_DSP)
+  q31_t in2, in3, in4; /* Temporary input variables */
 #endif
 
-
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
   /* Loop unrolling: Compute 4 outputs at a time */
   blkCnt = numSamples >> 2U;
 
-  while (blkCnt > 0U)
-  {
+  while (blkCnt > 0U) {
     /* C[0] + jC[1] = A[0]+ j(-1)A[1] */
 
     /* Calculate Complex Conjugate and store result in destination buffer. */
 
-    #if defined (ARM_MATH_DSP)
-    in1 = read_q15x2_ia ((q15_t **) &pSrc);
-    in2 = read_q15x2_ia ((q15_t **) &pSrc);
-    in3 = read_q15x2_ia ((q15_t **) &pSrc);
-    in4 = read_q15x2_ia ((q15_t **) &pSrc);
+#if defined(ARM_MATH_DSP)
+    in1 = read_q15x2_ia((q15_t **)&pSrc);
+    in2 = read_q15x2_ia((q15_t **)&pSrc);
+    in3 = read_q15x2_ia((q15_t **)&pSrc);
+    in4 = read_q15x2_ia((q15_t **)&pSrc);
 
 #ifndef ARM_MATH_BIG_ENDIAN
     in1 = __QASX(0, in1);
@@ -91,31 +86,31 @@ void arm_cmplx_conj_q15(
     in4 = __QSAX(0, in4);
 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
 
-    in1 = ((uint32_t) in1 >> 16) | ((uint32_t) in1 << 16);
-    in2 = ((uint32_t) in2 >> 16) | ((uint32_t) in2 << 16);
-    in3 = ((uint32_t) in3 >> 16) | ((uint32_t) in3 << 16);
-    in4 = ((uint32_t) in4 >> 16) | ((uint32_t) in4 << 16);
+    in1 = ((uint32_t)in1 >> 16) | ((uint32_t)in1 << 16);
+    in2 = ((uint32_t)in2 >> 16) | ((uint32_t)in2 << 16);
+    in3 = ((uint32_t)in3 >> 16) | ((uint32_t)in3 << 16);
+    in4 = ((uint32_t)in4 >> 16) | ((uint32_t)in4 << 16);
 
-    write_q15x2_ia (&pDst, in1);
-    write_q15x2_ia (&pDst, in2);
-    write_q15x2_ia (&pDst, in3);
-    write_q15x2_ia (&pDst, in4);
+    write_q15x2_ia(&pDst, in1);
+    write_q15x2_ia(&pDst, in2);
+    write_q15x2_ia(&pDst, in3);
+    write_q15x2_ia(&pDst, in4);
 #else
-    *pDst++ =  *pSrc++;
+    *pDst++ = *pSrc++;
     in1 = *pSrc++;
-    *pDst++ = (in1 == (q15_t) 0x8000) ? (q15_t) 0x7fff : -in1;
+    *pDst++ = (in1 == (q15_t)0x8000) ? (q15_t)0x7fff : -in1;
 
-    *pDst++ =  *pSrc++;
+    *pDst++ = *pSrc++;
     in1 = *pSrc++;
-    *pDst++ = (in1 == (q15_t) 0x8000) ? (q15_t) 0x7fff : -in1;
+    *pDst++ = (in1 == (q15_t)0x8000) ? (q15_t)0x7fff : -in1;
 
-    *pDst++ =  *pSrc++;
+    *pDst++ = *pSrc++;
     in1 = *pSrc++;
-    *pDst++ = (in1 == (q15_t) 0x8000) ? (q15_t) 0x7fff : -in1;
+    *pDst++ = (in1 == (q15_t)0x8000) ? (q15_t)0x7fff : -in1;
 
-    *pDst++ =  *pSrc++;
+    *pDst++ = *pSrc++;
     in1 = *pSrc++;
-    *pDst++ = (in1 == (q15_t) 0x8000) ? (q15_t) 0x7fff : -in1;
+    *pDst++ = (in1 == (q15_t)0x8000) ? (q15_t)0x7fff : -in1;
 
 #endif /* #if defined (ARM_MATH_DSP) */
 
@@ -133,23 +128,21 @@ void arm_cmplx_conj_q15(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-  while (blkCnt > 0U)
-  {
+  while (blkCnt > 0U) {
     /* C[0] + jC[1] = A[0]+ j(-1)A[1] */
 
     /* Calculate Complex Conjugate and store result in destination buffer. */
-    *pDst++ =  *pSrc++;
+    *pDst++ = *pSrc++;
     in1 = *pSrc++;
-#if defined (ARM_MATH_DSP)
+#if defined(ARM_MATH_DSP)
     *pDst++ = __SSAT(-in1, 16);
 #else
-    *pDst++ = (in1 == (q15_t) 0x8000) ? (q15_t) 0x7fff : -in1;
+    *pDst++ = (in1 == (q15_t)0x8000) ? (q15_t)0x7fff : -in1;
 #endif
 
     /* Decrement loop counter */
     blkCnt--;
   }
-
 }
 
 /**
diff --git a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_conj_q31.c b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_conj_q31.c
index 6ef1ddb..44b22a4 100644
--- a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_conj_q31.c
+++ b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_conj_q31.c
@@ -46,54 +46,50 @@
 
   @par           Scaling and Overflow Behavior
                    The function uses saturating arithmetic.
-                   The Q31 value -1 (0x80000000) is saturated to the maximum allowable positive value 0x7FFFFFFF.
+                   The Q31 value -1 (0x80000000) is saturated to the maximum
+  allowable positive value 0x7FFFFFFF.
  */
 
-void arm_cmplx_conj_q31(
-  const q31_t * pSrc,
-        q31_t * pDst,
-        uint32_t numSamples)
-{
-        uint32_t blkCnt;                               /* Loop counter */
-        q31_t in;                                      /* Temporary input variable */
+void arm_cmplx_conj_q31(const q31_t *pSrc, q31_t *pDst, uint32_t numSamples) {
+  uint32_t blkCnt; /* Loop counter */
+  q31_t in;        /* Temporary input variable */
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
   /* Loop unrolling: Compute 4 outputs at a time */
   blkCnt = numSamples >> 2U;
 
-  while (blkCnt > 0U)
-  {
+  while (blkCnt > 0U) {
     /* C[0] + jC[1] = A[0]+ j(-1)A[1] */
 
     /* Calculate Complex Conjugate and store result in destination buffer. */
-    *pDst++ =  *pSrc++;
+    *pDst++ = *pSrc++;
     in = *pSrc++;
-#if defined (ARM_MATH_DSP)
+#if defined(ARM_MATH_DSP)
     *pDst++ = __QSUB(0, in);
 #else
     *pDst++ = (in == INT32_MIN) ? INT32_MAX : -in;
 #endif
 
-    *pDst++ =  *pSrc++;
-    in =  *pSrc++;
-#if defined (ARM_MATH_DSP)
+    *pDst++ = *pSrc++;
+    in = *pSrc++;
+#if defined(ARM_MATH_DSP)
     *pDst++ = __QSUB(0, in);
 #else
     *pDst++ = (in == INT32_MIN) ? INT32_MAX : -in;
 #endif
 
-    *pDst++ =  *pSrc++;
+    *pDst++ = *pSrc++;
     in = *pSrc++;
-#if defined (ARM_MATH_DSP)
+#if defined(ARM_MATH_DSP)
     *pDst++ = __QSUB(0, in);
 #else
     *pDst++ = (in == INT32_MIN) ? INT32_MAX : -in;
 #endif
 
-    *pDst++ =  *pSrc++;
+    *pDst++ = *pSrc++;
     in = *pSrc++;
-#if defined (ARM_MATH_DSP)
+#if defined(ARM_MATH_DSP)
     *pDst++ = __QSUB(0, in);
 #else
     *pDst++ = (in == INT32_MIN) ? INT32_MAX : -in;
@@ -113,14 +109,13 @@ void arm_cmplx_conj_q31(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-  while (blkCnt > 0U)
-  {
+  while (blkCnt > 0U) {
     /* C[0] + jC[1] = A[0]+ j(-1)A[1] */
 
     /* Calculate Complex Conjugate and store result in destination buffer. */
-    *pDst++ =  *pSrc++;
+    *pDst++ = *pSrc++;
     in = *pSrc++;
-#if defined (ARM_MATH_DSP)
+#if defined(ARM_MATH_DSP)
     *pDst++ = __QSUB(0, in);
 #else
     *pDst++ = (in == INT32_MIN) ? INT32_MAX : -in;
@@ -129,7 +124,6 @@ void arm_cmplx_conj_q31(
     /* Decrement loop counter */
     blkCnt--;
   }
-
 }
 
 /**
diff --git a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_dot_prod_f32.c b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_dot_prod_f32.c
index 9c8ef2d..692278d 100644
--- a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_dot_prod_f32.c
+++ b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_dot_prod_f32.c
@@ -51,8 +51,9 @@
   realResult = 0;
   imagResult = 0;
   for (n = 0; n < numSamples; n++) {
-      realResult += pSrcA[(2*n)+0] * pSrcB[(2*n)+0] - pSrcA[(2*n)+1] * pSrcB[(2*n)+1];
-      imagResult += pSrcA[(2*n)+0] * pSrcB[(2*n)+1] + pSrcA[(2*n)+1] * pSrcB[(2*n)+0];
+      realResult += pSrcA[(2*n)+0] * pSrcB[(2*n)+0] - pSrcA[(2*n)+1] *
+  pSrcB[(2*n)+1]; imagResult += pSrcA[(2*n)+0] * pSrcB[(2*n)+1] + pSrcA[(2*n)+1]
+  * pSrcB[(2*n)+0];
   }
   
@@ -74,24 +75,19 @@ @return none */ -void arm_cmplx_dot_prod_f32( - const float32_t * pSrcA, - const float32_t * pSrcB, - uint32_t numSamples, - float32_t * realResult, - float32_t * imagResult) -{ - uint32_t blkCnt; /* Loop counter */ - float32_t real_sum = 0.0f, imag_sum = 0.0f; /* Temporary result variables */ - float32_t a0,b0,c0,d0; +void arm_cmplx_dot_prod_f32(const float32_t *pSrcA, const float32_t *pSrcB, + uint32_t numSamples, float32_t *realResult, + float32_t *imagResult) { + uint32_t blkCnt; /* Loop counter */ + float32_t real_sum = 0.0f, imag_sum = 0.0f; /* Temporary result variables */ + float32_t a0, b0, c0, d0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { a0 = *pSrcA++; b0 = *pSrcA++; c0 = *pSrcB++; @@ -146,8 +142,7 @@ void arm_cmplx_dot_prod_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { a0 = *pSrcA++; b0 = *pSrcA++; c0 = *pSrcB++; diff --git a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_dot_prod_q15.c b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_dot_prod_q15.c index 2ecd801..fc80a16 100644 --- a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_dot_prod_q15.c +++ b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_dot_prod_q15.c @@ -47,31 +47,27 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using an internal 64-bit accumulator. - The intermediate 1.15 by 1.15 multiplications are performed with full precision and yield a 2.30 result. - These are accumulated in a 64-bit accumulator with 34.30 precision. - As a final step, the accumulators are converted to 8.24 format. - The return results realResult and imagResult are in 8.24 format. + The function is implemented using an internal 64-bit + accumulator. The intermediate 1.15 by 1.15 multiplications are performed with + full precision and yield a 2.30 result. These are accumulated in a 64-bit + accumulator with 34.30 precision. As a final step, the accumulators are + converted to 8.24 format. The return results realResult and + imagResult are in 8.24 format. */ -void arm_cmplx_dot_prod_q15( - const q15_t * pSrcA, - const q15_t * pSrcB, - uint32_t numSamples, - q31_t * realResult, - q31_t * imagResult) -{ - uint32_t blkCnt; /* Loop counter */ - q63_t real_sum = 0, imag_sum = 0; /* Temporary result variables */ - q15_t a0,b0,c0,d0; +void arm_cmplx_dot_prod_q15(const q15_t *pSrcA, const q15_t *pSrcB, + uint32_t numSamples, q31_t *realResult, + q31_t *imagResult) { + uint32_t blkCnt; /* Loop counter */ + q63_t real_sum = 0, imag_sum = 0; /* Temporary result variables */ + q15_t a0, b0, c0, d0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { a0 = *pSrcA++; b0 = *pSrcA++; c0 = *pSrcB++; @@ -126,8 +122,7 @@ void arm_cmplx_dot_prod_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { a0 = *pSrcA++; b0 = *pSrcA++; c0 = *pSrcB++; @@ -144,9 +139,9 @@ void arm_cmplx_dot_prod_q15( /* Store real and imaginary result in 8.24 format */ /* Convert real data in 34.30 to 8.24 by 6 right shifts */ - *realResult = (q31_t) (real_sum >> 6); + *realResult = (q31_t)(real_sum >> 6); /* Convert imaginary data in 34.30 to 8.24 by 6 right shifts */ - *imagResult = (q31_t) (imag_sum >> 6); + *imagResult = (q31_t)(imag_sum >> 6); } /** diff --git a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_dot_prod_q31.c b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_dot_prod_q31.c index d715d98..b3ed90e 100644 --- a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_dot_prod_q31.c +++ b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_dot_prod_q31.c @@ -47,32 +47,29 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using an internal 64-bit accumulator. - The intermediate 1.31 by 1.31 multiplications are performed with 64-bit precision and then shifted to 16.48 format. - The internal real and imaginary accumulators are in 16.48 format and provide 15 guard bits. - Additions are nonsaturating and no overflow will occur as long as numSamples is less than 32768. - The return results realResult and imagResult are in 16.48 format. - Input down scaling is not required. + The function is implemented using an internal 64-bit + accumulator. The intermediate 1.31 by 1.31 multiplications are performed with + 64-bit precision and then shifted to 16.48 format. The internal real and + imaginary accumulators are in 16.48 format and provide 15 guard bits. + Additions are nonsaturating and no overflow will occur as + long as numSamples is less than 32768. The return results + realResult and imagResult are in 16.48 format. Input + down scaling is not required. */ -void arm_cmplx_dot_prod_q31( - const q31_t * pSrcA, - const q31_t * pSrcB, - uint32_t numSamples, - q63_t * realResult, - q63_t * imagResult) -{ - uint32_t blkCnt; /* Loop counter */ - q63_t real_sum = 0, imag_sum = 0; /* Temporary result variables */ - q31_t a0,b0,c0,d0; +void arm_cmplx_dot_prod_q31(const q31_t *pSrcA, const q31_t *pSrcB, + uint32_t numSamples, q63_t *realResult, + q63_t *imagResult) { + uint32_t blkCnt; /* Loop counter */ + q63_t real_sum = 0, imag_sum = 0; /* Temporary result variables */ + q31_t a0, b0, c0, d0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { a0 = *pSrcA++; b0 = *pSrcA++; c0 = *pSrcB++; @@ -127,8 +124,7 @@ void arm_cmplx_dot_prod_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { a0 = *pSrcA++; b0 = *pSrcA++; c0 = *pSrcB++; diff --git a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_f32.c b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_f32.c index 39431c1..0ea48e4 100644 --- a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_f32.c +++ b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_f32.c @@ -69,21 +69,17 @@ @return none */ -void arm_cmplx_mag_f32( - const float32_t * pSrc, - float32_t * pDst, - uint32_t numSamples) -{ - uint32_t blkCnt; /* Loop counter */ - float32_t real, imag; /* Temporary input variables */ +void arm_cmplx_mag_f32(const float32_t *pSrc, float32_t *pDst, + uint32_t numSamples) { + uint32_t blkCnt; /* Loop counter */ + float32_t real, imag; /* Temporary input variables */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[0] = sqrt(A[0] * A[0] + A[1] * A[1]) */ real = *pSrc++; @@ -118,8 +114,7 @@ void arm_cmplx_mag_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[0] = sqrt(A[0] * A[0] + A[1] * A[1]) */ real = *pSrc++; @@ -131,7 +126,6 @@ void arm_cmplx_mag_f32( /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_q15.c b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_q15.c index a493274..232013c 100644 --- a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_q15.c +++ b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_q15.c @@ -45,76 +45,72 @@ @return none @par Scaling and Overflow Behavior - The function implements 1.15 by 1.15 multiplications and finally output is converted into 2.14 format. + The function implements 1.15 by 1.15 multiplications and + finally output is converted into 2.14 format. */ -void arm_cmplx_mag_q15( - const q15_t * pSrc, - q15_t * pDst, - uint32_t numSamples) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_cmplx_mag_q15(const q15_t *pSrc, q15_t *pDst, uint32_t numSamples) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_DSP) - q31_t in; - q31_t acc0; /* Accumulators */ +#if defined(ARM_MATH_DSP) + q31_t in; + q31_t acc0; /* Accumulators */ #else - q15_t real, imag; /* Temporary input variables */ - q31_t acc0, acc1; /* Accumulators */ + q15_t real, imag; /* Temporary input variables */ + q31_t acc0, acc1; /* Accumulators */ #endif -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[0] = sqrt(A[0] * A[0] + A[1] * A[1]) */ -#if defined (ARM_MATH_DSP) - in = read_q15x2_ia ((q15_t **) &pSrc); +#if defined(ARM_MATH_DSP) + in = read_q15x2_ia((q15_t **)&pSrc); acc0 = __SMUAD(in, in); /* store result in 2.14 format in destination buffer. */ - arm_sqrt_q15((q15_t) (acc0 >> 17), pDst++); + arm_sqrt_q15((q15_t)(acc0 >> 17), pDst++); - in = read_q15x2_ia ((q15_t **) &pSrc); + in = read_q15x2_ia((q15_t **)&pSrc); acc0 = __SMUAD(in, in); - arm_sqrt_q15((q15_t) (acc0 >> 17), pDst++); + arm_sqrt_q15((q15_t)(acc0 >> 17), pDst++); - in = read_q15x2_ia ((q15_t **) &pSrc); + in = read_q15x2_ia((q15_t **)&pSrc); acc0 = __SMUAD(in, in); - arm_sqrt_q15((q15_t) (acc0 >> 17), pDst++); + arm_sqrt_q15((q15_t)(acc0 >> 17), pDst++); - in = read_q15x2_ia ((q15_t **) &pSrc); + in = read_q15x2_ia((q15_t **)&pSrc); acc0 = __SMUAD(in, in); - arm_sqrt_q15((q15_t) (acc0 >> 17), pDst++); + arm_sqrt_q15((q15_t)(acc0 >> 17), pDst++); #else real = *pSrc++; imag = *pSrc++; - acc0 = ((q31_t) real * real); - acc1 = ((q31_t) imag * imag); + acc0 = ((q31_t)real * real); + acc1 = ((q31_t)imag * imag); /* store result in 2.14 format in destination buffer. */ - arm_sqrt_q15((q15_t) (((q63_t) acc0 + acc1) >> 17), pDst++); + arm_sqrt_q15((q15_t)(((q63_t)acc0 + acc1) >> 17), pDst++); real = *pSrc++; imag = *pSrc++; - acc0 = ((q31_t) real * real); - acc1 = ((q31_t) imag * imag); - arm_sqrt_q15((q15_t) (((q63_t) acc0 + acc1) >> 17), pDst++); + acc0 = ((q31_t)real * real); + acc1 = ((q31_t)imag * imag); + arm_sqrt_q15((q15_t)(((q63_t)acc0 + acc1) >> 17), pDst++); real = *pSrc++; imag = *pSrc++; - acc0 = ((q31_t) real * real); - acc1 = ((q31_t) imag * imag); - arm_sqrt_q15((q15_t) (((q63_t) acc0 + acc1) >> 17), pDst++); + acc0 = ((q31_t)real * real); + acc1 = ((q31_t)imag * imag); + arm_sqrt_q15((q15_t)(((q63_t)acc0 + acc1) >> 17), pDst++); real = *pSrc++; imag = *pSrc++; - acc0 = ((q31_t) real * real); - acc1 = ((q31_t) imag * imag); - arm_sqrt_q15((q15_t) (((q63_t) acc0 + acc1) >> 17), pDst++); + acc0 = ((q31_t)real * real); + acc1 = ((q31_t)imag * imag); + arm_sqrt_q15((q15_t)(((q63_t)acc0 + acc1) >> 17), pDst++); #endif /* #if defined (ARM_MATH_DSP) */ /* Decrement loop counter */ @@ -131,30 +127,28 @@ void arm_cmplx_mag_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[0] = sqrt(A[0] * A[0] + A[1] * A[1]) */ -#if defined (ARM_MATH_DSP) - in = read_q15x2_ia ((q15_t **) &pSrc); +#if defined(ARM_MATH_DSP) + in = read_q15x2_ia((q15_t **)&pSrc); acc0 = __SMUAD(in, in); /* store result in 2.14 format in destination buffer. */ - arm_sqrt_q15((q15_t) (acc0 >> 17), pDst++); + arm_sqrt_q15((q15_t)(acc0 >> 17), pDst++); #else real = *pSrc++; imag = *pSrc++; - acc0 = ((q31_t) real * real); - acc1 = ((q31_t) imag * imag); + acc0 = ((q31_t)real * real); + acc1 = ((q31_t)imag * imag); /* store result in 2.14 format in destination buffer. */ - arm_sqrt_q15((q15_t) (((q63_t) acc0 + acc1) >> 17), pDst++); + arm_sqrt_q15((q15_t)(((q63_t)acc0 + acc1) >> 17), pDst++); #endif /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_q31.c b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_q31.c index 873e566..2abc6f3 100644 --- a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_q31.c +++ b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_q31.c @@ -45,52 +45,48 @@ @return none @par Scaling and Overflow Behavior - The function implements 1.31 by 1.31 multiplications and finally output is converted into 2.30 format. - Input down scaling is not required. + The function implements 1.31 by 1.31 multiplications and + finally output is converted into 2.30 format. Input down scaling is not + required. */ -void arm_cmplx_mag_q31( - const q31_t * pSrc, - q31_t * pDst, - uint32_t numSamples) -{ - uint32_t blkCnt; /* Loop counter */ - q31_t real, imag; /* Temporary input variables */ - q31_t acc0, acc1; /* Accumulators */ +void arm_cmplx_mag_q31(const q31_t *pSrc, q31_t *pDst, uint32_t numSamples) { + uint32_t blkCnt; /* Loop counter */ + q31_t real, imag; /* Temporary input variables */ + q31_t acc0, acc1; /* Accumulators */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[0] = sqrt(A[0] * A[0] + A[1] * A[1]) */ real = *pSrc++; imag = *pSrc++; - acc0 = (q31_t) (((q63_t) real * real) >> 33); - acc1 = (q31_t) (((q63_t) imag * imag) >> 33); + acc0 = (q31_t)(((q63_t)real * real) >> 33); + acc1 = (q31_t)(((q63_t)imag * imag) >> 33); /* store result in 2.30 format in destination buffer. */ arm_sqrt_q31(acc0 + acc1, pDst++); real = *pSrc++; imag = *pSrc++; - acc0 = (q31_t) (((q63_t) real * real) >> 33); - acc1 = (q31_t) (((q63_t) imag * imag) >> 33); + acc0 = (q31_t)(((q63_t)real * real) >> 33); + acc1 = (q31_t)(((q63_t)imag * imag) >> 33); arm_sqrt_q31(acc0 + acc1, pDst++); real = *pSrc++; imag = *pSrc++; - acc0 = (q31_t) (((q63_t) real * real) >> 33); - acc1 = (q31_t) (((q63_t) imag * imag) >> 33); + acc0 = (q31_t)(((q63_t)real * real) >> 33); + acc1 = (q31_t)(((q63_t)imag * imag) >> 33); arm_sqrt_q31(acc0 + acc1, pDst++); real = *pSrc++; imag = *pSrc++; - acc0 = (q31_t) (((q63_t) real * real) >> 33); - acc1 = (q31_t) (((q63_t) imag * imag) >> 33); + acc0 = (q31_t)(((q63_t)real * real) >> 33); + acc1 = (q31_t)(((q63_t)imag * imag) >> 33); arm_sqrt_q31(acc0 + acc1, pDst++); /* Decrement loop counter */ @@ -107,14 +103,13 @@ void arm_cmplx_mag_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[0] = sqrt(A[0] * A[0] + A[1] * A[1]) */ real = *pSrc++; imag = *pSrc++; - acc0 = (q31_t) (((q63_t) real * real) >> 33); - acc1 = (q31_t) (((q63_t) imag * imag) >> 33); + acc0 = (q31_t)(((q63_t)real * real) >> 33); + acc1 = (q31_t)(((q63_t)imag * imag) >> 33); /* store result in 2.30 format in destination buffer. */ arm_sqrt_q31(acc0 + acc1, pDst++); @@ -122,7 +117,6 @@ void arm_cmplx_mag_q31( /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_squared_f32.c b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_squared_f32.c index ad2e577..cd9724c 100644 --- a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_squared_f32.c +++ b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_squared_f32.c @@ -69,21 +69,17 @@ @return none */ -void arm_cmplx_mag_squared_f32( - const float32_t * pSrc, - float32_t * pDst, - uint32_t numSamples) -{ - uint32_t blkCnt; /* Loop counter */ - float32_t real, imag; /* Temporary input variables */ +void arm_cmplx_mag_squared_f32(const float32_t *pSrc, float32_t *pDst, + uint32_t numSamples) { + uint32_t blkCnt; /* Loop counter */ + float32_t real, imag; /* Temporary input variables */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[0] = (A[0] * A[0] + A[1] * A[1]) */ real = *pSrc++; @@ -116,8 +112,7 @@ void arm_cmplx_mag_squared_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[0] = (A[0] * A[0] + A[1] * A[1]) */ real = *pSrc++; @@ -129,7 +124,6 @@ void arm_cmplx_mag_squared_f32( /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_squared_q15.c b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_squared_q15.c index fa5f4e6..bdca115 100644 --- a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_squared_q15.c +++ b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_squared_q15.c @@ -45,75 +45,72 @@ @return none @par Scaling and Overflow Behavior - The function implements 1.15 by 1.15 multiplications and finally output is converted into 3.13 format. + The function implements 1.15 by 1.15 multiplications and + finally output is converted into 3.13 format. */ -void arm_cmplx_mag_squared_q15( - const q15_t * pSrc, - q15_t * pDst, - uint32_t numSamples) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_cmplx_mag_squared_q15(const q15_t *pSrc, q15_t *pDst, + uint32_t numSamples) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_DSP) - q31_t in; - q31_t acc0; /* Accumulators */ +#if defined(ARM_MATH_DSP) + q31_t in; + q31_t acc0; /* Accumulators */ #else - q15_t real, imag; /* Temporary input variables */ - q31_t acc0, acc1; /* Accumulators */ + q15_t real, imag; /* Temporary input variables */ + q31_t acc0, acc1; /* Accumulators */ #endif -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[0] = (A[0] * A[0] + A[1] * A[1]) */ -#if defined (ARM_MATH_DSP) - in = read_q15x2_ia ((q15_t **) &pSrc); +#if defined(ARM_MATH_DSP) + in = read_q15x2_ia((q15_t **)&pSrc); acc0 = __SMUAD(in, in); /* store result in 3.13 format in destination buffer. */ - *pDst++ = (q15_t) (acc0 >> 17); + *pDst++ = (q15_t)(acc0 >> 17); - in = read_q15x2_ia ((q15_t **) &pSrc); + in = read_q15x2_ia((q15_t **)&pSrc); acc0 = __SMUAD(in, in); - *pDst++ = (q15_t) (acc0 >> 17); + *pDst++ = (q15_t)(acc0 >> 17); - in = read_q15x2_ia ((q15_t **) &pSrc); + in = read_q15x2_ia((q15_t **)&pSrc); acc0 = __SMUAD(in, in); - *pDst++ = (q15_t) (acc0 >> 17); + *pDst++ = (q15_t)(acc0 >> 17); - in = read_q15x2_ia ((q15_t **) &pSrc); + in = read_q15x2_ia((q15_t **)&pSrc); acc0 = __SMUAD(in, in); - *pDst++ = (q15_t) (acc0 >> 17); + *pDst++ = (q15_t)(acc0 >> 17); #else real = *pSrc++; imag = *pSrc++; - acc0 = ((q31_t) real * real); - acc1 = ((q31_t) imag * imag); + acc0 = ((q31_t)real * real); + acc1 = ((q31_t)imag * imag); /* store result in 3.13 format in destination buffer. */ - *pDst++ = (q15_t) (((q63_t) acc0 + acc1) >> 17); + *pDst++ = (q15_t)(((q63_t)acc0 + acc1) >> 17); real = *pSrc++; imag = *pSrc++; - acc0 = ((q31_t) real * real); - acc1 = ((q31_t) imag * imag); - *pDst++ = (q15_t) (((q63_t) acc0 + acc1) >> 17); + acc0 = ((q31_t)real * real); + acc1 = ((q31_t)imag * imag); + *pDst++ = (q15_t)(((q63_t)acc0 + acc1) >> 17); real = *pSrc++; imag = *pSrc++; - acc0 = ((q31_t) real * real); - acc1 = ((q31_t) imag * imag); - *pDst++ = (q15_t) (((q63_t) acc0 + acc1) >> 17); + acc0 = ((q31_t)real * real); + acc1 = ((q31_t)imag * imag); + *pDst++ = (q15_t)(((q63_t)acc0 + acc1) >> 17); real = *pSrc++; imag = *pSrc++; - acc0 = ((q31_t) real * real); - acc1 = ((q31_t) imag * imag); - *pDst++ = (q15_t) (((q63_t) acc0 + acc1) >> 17); + acc0 = ((q31_t)real * real); + acc1 = ((q31_t)imag * imag); + *pDst++ = (q15_t)(((q63_t)acc0 + acc1) >> 17); #endif /* #if defined (ARM_MATH_DSP) */ /* Decrement loop counter */ @@ -130,30 +127,28 @@ void arm_cmplx_mag_squared_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[0] = (A[0] * A[0] + A[1] * A[1]) */ -#if defined (ARM_MATH_DSP) - in = read_q15x2_ia ((q15_t **) &pSrc); +#if defined(ARM_MATH_DSP) + in = read_q15x2_ia((q15_t **)&pSrc); acc0 = __SMUAD(in, in); /* store result in 3.13 format in destination buffer. */ - *pDst++ = (q15_t) (acc0 >> 17); + *pDst++ = (q15_t)(acc0 >> 17); #else real = *pSrc++; imag = *pSrc++; - acc0 = ((q31_t) real * real); - acc1 = ((q31_t) imag * imag); + acc0 = ((q31_t)real * real); + acc1 = ((q31_t)imag * imag); /* store result in 3.13 format in destination buffer. */ - *pDst++ = (q15_t) (((q63_t) acc0 + acc1) >> 17); + *pDst++ = (q15_t)(((q63_t)acc0 + acc1) >> 17); #endif /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_squared_q31.c b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_squared_q31.c index 54863ef..213975d 100644 --- a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_squared_q31.c +++ b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mag_squared_q31.c @@ -45,51 +45,48 @@ @return none @par Scaling and Overflow Behavior - The function implements 1.31 by 1.31 multiplications and finally output is converted into 3.29 format. - Input down scaling is not required. + The function implements 1.31 by 1.31 multiplications and + finally output is converted into 3.29 format. Input down scaling is not + required. */ -void arm_cmplx_mag_squared_q31( - const q31_t * pSrc, - q31_t * pDst, - uint32_t numSamples) -{ - uint32_t blkCnt; /* Loop counter */ - q31_t real, imag; /* Temporary input variables */ - q31_t acc0, acc1; /* Accumulators */ +void arm_cmplx_mag_squared_q31(const q31_t *pSrc, q31_t *pDst, + uint32_t numSamples) { + uint32_t blkCnt; /* Loop counter */ + q31_t real, imag; /* Temporary input variables */ + q31_t acc0, acc1; /* Accumulators */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[0] = (A[0] * A[0] + A[1] * A[1]) */ real = *pSrc++; imag = *pSrc++; - acc0 = (q31_t) (((q63_t) real * real) >> 33); - acc1 = (q31_t) (((q63_t) imag * imag) >> 33); + acc0 = (q31_t)(((q63_t)real * real) >> 33); + acc1 = (q31_t)(((q63_t)imag * imag) >> 33); /* store the result in 3.29 format in the destination buffer. */ *pDst++ = acc0 + acc1; real = *pSrc++; imag = *pSrc++; - acc0 = (q31_t) (((q63_t) real * real) >> 33); - acc1 = (q31_t) (((q63_t) imag * imag) >> 33); + acc0 = (q31_t)(((q63_t)real * real) >> 33); + acc1 = (q31_t)(((q63_t)imag * imag) >> 33); *pDst++ = acc0 + acc1; real = *pSrc++; imag = *pSrc++; - acc0 = (q31_t) (((q63_t) real * real) >> 33); - acc1 = (q31_t) (((q63_t) imag * imag) >> 33); + acc0 = (q31_t)(((q63_t)real * real) >> 33); + acc1 = (q31_t)(((q63_t)imag * imag) >> 33); *pDst++ = acc0 + acc1; real = *pSrc++; imag = *pSrc++; - acc0 = (q31_t) (((q63_t) real * real) >> 33); - acc1 = (q31_t) (((q63_t) imag * imag) >> 33); + acc0 = (q31_t)(((q63_t)real * real) >> 33); + acc1 = (q31_t)(((q63_t)imag * imag) >> 33); *pDst++ = acc0 + acc1; /* Decrement loop counter */ @@ -106,14 +103,13 @@ void arm_cmplx_mag_squared_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[0] = (A[0] * A[0] + A[1] * A[1]) */ real = *pSrc++; imag = *pSrc++; - acc0 = (q31_t) (((q63_t) real * real) >> 33); - acc1 = (q31_t) (((q63_t) imag * imag) >> 33); + acc0 = (q31_t)(((q63_t)real * real) >> 33); + acc1 = (q31_t)(((q63_t)imag * imag) >> 33); /* store result in 3.29 format in destination buffer. */ *pDst++ = acc0 + acc1; @@ -121,7 +117,6 @@ void arm_cmplx_mag_squared_q31( /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_cmplx_f32.c b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_cmplx_f32.c index 766cd81..0594a32 100644 --- a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_cmplx_f32.c +++ b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_cmplx_f32.c @@ -35,19 +35,20 @@ /** @defgroup CmplxByCmplxMult Complex-by-Complex Multiplication - Multiplies a complex vector by another complex vector and generates a complex result. - The data in the complex arrays is stored in an interleaved fashion + Multiplies a complex vector by another complex vector and generates a complex + result. The data in the complex arrays is stored in an interleaved fashion (real, imag, real, imag, ...). The parameter numSamples represents the number of complex - samples processed. The complex arrays have a total of 2*numSamples - real values. + samples processed. The complex arrays have a total of + 2*numSamples real values. The underlying algorithm is used:
   for (n = 0; n < numSamples; n++) {
-      pDst[(2*n)+0] = pSrcA[(2*n)+0] * pSrcB[(2*n)+0] - pSrcA[(2*n)+1] * pSrcB[(2*n)+1];
-      pDst[(2*n)+1] = pSrcA[(2*n)+0] * pSrcB[(2*n)+1] + pSrcA[(2*n)+1] * pSrcB[(2*n)+0];
+      pDst[(2*n)+0] = pSrcA[(2*n)+0] * pSrcB[(2*n)+0] - pSrcA[(2*n)+1] *
+  pSrcB[(2*n)+1]; pDst[(2*n)+1] = pSrcA[(2*n)+0] * pSrcB[(2*n)+1] +
+  pSrcA[(2*n)+1] * pSrcB[(2*n)+0];
   }
   
@@ -68,22 +69,17 @@ @return none */ -void arm_cmplx_mult_cmplx_f32( - const float32_t * pSrcA, - const float32_t * pSrcB, - float32_t * pDst, - uint32_t numSamples) -{ - uint32_t blkCnt; /* Loop counter */ - float32_t a, b, c, d; /* Temporary variables */ +void arm_cmplx_mult_cmplx_f32(const float32_t *pSrcA, const float32_t *pSrcB, + float32_t *pDst, uint32_t numSamples) { + uint32_t blkCnt; /* Loop counter */ + float32_t a, b, c, d; /* Temporary variables */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[2 * i ] = A[2 * i] * B[2 * i ] - A[2 * i + 1] * B[2 * i + 1]. */ /* C[2 * i + 1] = A[2 * i] * B[2 * i + 1] + A[2 * i + 1] * B[2 * i ]. */ @@ -130,8 +126,7 @@ void arm_cmplx_mult_cmplx_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[2 * i ] = A[2 * i] * B[2 * i ] - A[2 * i + 1] * B[2 * i + 1]. */ /* C[2 * i + 1] = A[2 * i] * B[2 * i + 1] + A[2 * i + 1] * B[2 * i ]. */ @@ -147,7 +142,6 @@ void arm_cmplx_mult_cmplx_f32( /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_cmplx_q15.c b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_cmplx_q15.c index 6659427..c768eba 100644 --- a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_cmplx_q15.c +++ b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_cmplx_q15.c @@ -46,25 +46,21 @@ @return none @par Scaling and Overflow Behavior - The function implements 1.15 by 1.15 multiplications and finally output is converted into 3.13 format. + The function implements 1.15 by 1.15 multiplications and + finally output is converted into 3.13 format. */ -void arm_cmplx_mult_cmplx_q15( - const q15_t * pSrcA, - const q15_t * pSrcB, - q15_t * pDst, - uint32_t numSamples) -{ - uint32_t blkCnt; /* Loop counter */ - q15_t a, b, c, d; /* Temporary variables */ +void arm_cmplx_mult_cmplx_q15(const q15_t *pSrcA, const q15_t *pSrcB, + q15_t *pDst, uint32_t numSamples) { + uint32_t blkCnt; /* Loop counter */ + q15_t a, b, c, d; /* Temporary variables */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[2 * i ] = A[2 * i] * B[2 * i ] - A[2 * i + 1] * B[2 * i + 1]. */ /* C[2 * i + 1] = A[2 * i] * B[2 * i + 1] + A[2 * i + 1] * B[2 * i ]. */ @@ -73,29 +69,29 @@ void arm_cmplx_mult_cmplx_q15( c = *pSrcB++; d = *pSrcB++; /* store result in 3.13 format in destination buffer. */ - *pDst++ = (q15_t) ( (((q31_t) a * c) >> 17) - (((q31_t) b * d) >> 17) ); - *pDst++ = (q15_t) ( (((q31_t) a * d) >> 17) + (((q31_t) b * c) >> 17) ); + *pDst++ = (q15_t)((((q31_t)a * c) >> 17) - (((q31_t)b * d) >> 17)); + *pDst++ = (q15_t)((((q31_t)a * d) >> 17) + (((q31_t)b * c) >> 17)); a = *pSrcA++; b = *pSrcA++; c = *pSrcB++; d = *pSrcB++; - *pDst++ = (q15_t) ( (((q31_t) a * c) >> 17) - (((q31_t) b * d) >> 17) ); - *pDst++ = (q15_t) ( (((q31_t) a * d) >> 17) + (((q31_t) b * c) >> 17) ); + *pDst++ = (q15_t)((((q31_t)a * c) >> 17) - (((q31_t)b * d) >> 17)); + *pDst++ = (q15_t)((((q31_t)a * d) >> 17) + (((q31_t)b * c) >> 17)); a = *pSrcA++; b = *pSrcA++; c = *pSrcB++; d = *pSrcB++; - *pDst++ = (q15_t) ( (((q31_t) a * c) >> 17) - (((q31_t) b * d) >> 17) ); - *pDst++ = (q15_t) ( (((q31_t) a * d) >> 17) + (((q31_t) b * c) >> 17) ); + *pDst++ = (q15_t)((((q31_t)a * c) >> 17) - (((q31_t)b * d) >> 17)); + *pDst++ = (q15_t)((((q31_t)a * d) >> 17) + (((q31_t)b * c) >> 17)); a = *pSrcA++; b = *pSrcA++; c = *pSrcB++; d = *pSrcB++; - *pDst++ = (q15_t) ( (((q31_t) a * c) >> 17) - (((q31_t) b * d) >> 17) ); - *pDst++ = (q15_t) ( (((q31_t) a * d) >> 17) + (((q31_t) b * c) >> 17) ); + *pDst++ = (q15_t)((((q31_t)a * c) >> 17) - (((q31_t)b * d) >> 17)); + *pDst++ = (q15_t)((((q31_t)a * d) >> 17) + (((q31_t)b * c) >> 17)); /* Decrement loop counter */ blkCnt--; @@ -111,8 +107,7 @@ void arm_cmplx_mult_cmplx_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[2 * i ] = A[2 * i] * B[2 * i ] - A[2 * i + 1] * B[2 * i + 1]. */ /* C[2 * i + 1] = A[2 * i] * B[2 * i + 1] + A[2 * i + 1] * B[2 * i ]. */ @@ -122,13 +117,12 @@ void arm_cmplx_mult_cmplx_q15( d = *pSrcB++; /* store result in 3.13 format in destination buffer. */ - *pDst++ = (q15_t) ( (((q31_t) a * c) >> 17) - (((q31_t) b * d) >> 17) ); - *pDst++ = (q15_t) ( (((q31_t) a * d) >> 17) + (((q31_t) b * c) >> 17) ); + *pDst++ = (q15_t)((((q31_t)a * c) >> 17) - (((q31_t)b * d) >> 17)); + *pDst++ = (q15_t)((((q31_t)a * d) >> 17) + (((q31_t)b * c) >> 17)); /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_cmplx_q31.c b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_cmplx_q31.c index f6d6dc6..58952a8 100644 --- a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_cmplx_q31.c +++ b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_cmplx_q31.c @@ -46,26 +46,22 @@ @return none @par Scaling and Overflow Behavior - The function implements 1.31 by 1.31 multiplications and finally output is converted into 3.29 format. - Input down scaling is not required. + The function implements 1.31 by 1.31 multiplications and + finally output is converted into 3.29 format. Input down scaling is not + required. */ -void arm_cmplx_mult_cmplx_q31( - const q31_t * pSrcA, - const q31_t * pSrcB, - q31_t * pDst, - uint32_t numSamples) -{ - uint32_t blkCnt; /* Loop counter */ - q31_t a, b, c, d; /* Temporary variables */ +void arm_cmplx_mult_cmplx_q31(const q31_t *pSrcA, const q31_t *pSrcB, + q31_t *pDst, uint32_t numSamples) { + uint32_t blkCnt; /* Loop counter */ + q31_t a, b, c, d; /* Temporary variables */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[2 * i ] = A[2 * i] * B[2 * i ] - A[2 * i + 1] * B[2 * i + 1]. */ /* C[2 * i + 1] = A[2 * i] * B[2 * i + 1] + A[2 * i + 1] * B[2 * i ]. */ @@ -74,29 +70,29 @@ void arm_cmplx_mult_cmplx_q31( c = *pSrcB++; d = *pSrcB++; /* store result in 3.29 format in destination buffer. */ - *pDst++ = (q31_t) ( (((q63_t) a * c) >> 33) - (((q63_t) b * d) >> 33) ); - *pDst++ = (q31_t) ( (((q63_t) a * d) >> 33) + (((q63_t) b * c) >> 33) ); + *pDst++ = (q31_t)((((q63_t)a * c) >> 33) - (((q63_t)b * d) >> 33)); + *pDst++ = (q31_t)((((q63_t)a * d) >> 33) + (((q63_t)b * c) >> 33)); a = *pSrcA++; b = *pSrcA++; c = *pSrcB++; d = *pSrcB++; - *pDst++ = (q31_t) ( (((q63_t) a * c) >> 33) - (((q63_t) b * d) >> 33) ); - *pDst++ = (q31_t) ( (((q63_t) a * d) >> 33) + (((q63_t) b * c) >> 33) ); + *pDst++ = (q31_t)((((q63_t)a * c) >> 33) - (((q63_t)b * d) >> 33)); + *pDst++ = (q31_t)((((q63_t)a * d) >> 33) + (((q63_t)b * c) >> 33)); a = *pSrcA++; b = *pSrcA++; c = *pSrcB++; d = *pSrcB++; - *pDst++ = (q31_t) ( (((q63_t) a * c) >> 33) - (((q63_t) b * d) >> 33) ); - *pDst++ = (q31_t) ( (((q63_t) a * d) >> 33) + (((q63_t) b * c) >> 33) ); + *pDst++ = (q31_t)((((q63_t)a * c) >> 33) - (((q63_t)b * d) >> 33)); + *pDst++ = (q31_t)((((q63_t)a * d) >> 33) + (((q63_t)b * c) >> 33)); a = *pSrcA++; b = *pSrcA++; c = *pSrcB++; d = *pSrcB++; - *pDst++ = (q31_t) ( (((q63_t) a * c) >> 33) - (((q63_t) b * d) >> 33) ); - *pDst++ = (q31_t) ( (((q63_t) a * d) >> 33) + (((q63_t) b * c) >> 33) ); + *pDst++ = (q31_t)((((q63_t)a * c) >> 33) - (((q63_t)b * d) >> 33)); + *pDst++ = (q31_t)((((q63_t)a * d) >> 33) + (((q63_t)b * c) >> 33)); /* Decrement loop counter */ blkCnt--; @@ -112,8 +108,7 @@ void arm_cmplx_mult_cmplx_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[2 * i ] = A[2 * i] * B[2 * i ] - A[2 * i + 1] * B[2 * i + 1]. */ /* C[2 * i + 1] = A[2 * i] * B[2 * i + 1] + A[2 * i + 1] * B[2 * i ]. */ @@ -123,13 +118,12 @@ void arm_cmplx_mult_cmplx_q31( d = *pSrcB++; /* store result in 3.29 format in destination buffer. */ - *pDst++ = (q31_t) ( (((q63_t) a * c) >> 33) - (((q63_t) b * d) >> 33) ); - *pDst++ = (q31_t) ( (((q63_t) a * d) >> 33) + (((q63_t) b * c) >> 33) ); + *pDst++ = (q31_t)((((q63_t)a * c) >> 33) - (((q63_t)b * d) >> 33)); + *pDst++ = (q31_t)((((q63_t)a * d) >> 33) + (((q63_t)b * c) >> 33)); /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_real_f32.c b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_real_f32.c index 25409d7..d1e72c2 100644 --- a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_real_f32.c +++ b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_real_f32.c @@ -39,9 +39,9 @@ The data in the complex arrays is stored in an interleaved fashion (real, imag, real, imag, ...). The parameter numSamples represents the number of complex - samples processed. The complex arrays have a total of 2*numSamples - real values while the real array has a total of numSamples - real values. + samples processed. The complex arrays have a total of + 2*numSamples real values while the real array has a total of + numSamples real values. The underlying algorithm is used: @@ -69,22 +69,18 @@ @return none */ -void arm_cmplx_mult_real_f32( - const float32_t * pSrcCmplx, - const float32_t * pSrcReal, - float32_t * pCmplxDst, - uint32_t numSamples) -{ - uint32_t blkCnt; /* Loop counter */ - float32_t in; /* Temporary variable */ +void arm_cmplx_mult_real_f32(const float32_t *pSrcCmplx, + const float32_t *pSrcReal, float32_t *pCmplxDst, + uint32_t numSamples) { + uint32_t blkCnt; /* Loop counter */ + float32_t in; /* Temporary variable */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[2 * i ] = A[2 * i ] * B[i]. */ /* C[2 * i + 1] = A[2 * i + 1] * B[i]. */ @@ -102,7 +98,7 @@ void arm_cmplx_mult_real_f32( *pCmplxDst++ = *pSrcCmplx++ * in; in = *pSrcReal++; - *pCmplxDst++ = *pSrcCmplx++* in; + *pCmplxDst++ = *pSrcCmplx++ * in; *pCmplxDst++ = *pSrcCmplx++ * in; /* Decrement loop counter */ @@ -119,8 +115,7 @@ void arm_cmplx_mult_real_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[2 * i ] = A[2 * i ] * B[i]. */ /* C[2 * i + 1] = A[2 * i + 1] * B[i]. */ @@ -132,7 +127,6 @@ void arm_cmplx_mult_real_f32( /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_real_q15.c b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_real_q15.c index 4877d20..e4429a9 100644 --- a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_real_q15.c +++ b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_real_q15.c @@ -47,104 +47,102 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q15 range [0x8000 0x7FFF] are saturated. + Results outside of the allowable Q15 range [0x8000 0x7FFF] + are saturated. */ -void arm_cmplx_mult_real_q15( - const q15_t * pSrcCmplx, - const q15_t * pSrcReal, - q15_t * pCmplxDst, - uint32_t numSamples) -{ - uint32_t blkCnt; /* Loop counter */ - q15_t in; /* Temporary variable */ +void arm_cmplx_mult_real_q15(const q15_t *pSrcCmplx, const q15_t *pSrcReal, + q15_t *pCmplxDst, uint32_t numSamples) { + uint32_t blkCnt; /* Loop counter */ + q15_t in; /* Temporary variable */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) -#if defined (ARM_MATH_DSP) - q31_t inA1, inA2; /* Temporary variables to hold input data */ - q31_t inB1; /* Temporary variables to hold input data */ - q15_t out1, out2, out3, out4; /* Temporary variables to hold output data */ - q31_t mul1, mul2, mul3, mul4; /* Temporary variables to hold intermediate data */ +#if defined(ARM_MATH_DSP) + q31_t inA1, inA2; /* Temporary variables to hold input data */ + q31_t inB1; /* Temporary variables to hold input data */ + q15_t out1, out2, out3, out4; /* Temporary variables to hold output data */ + q31_t mul1, mul2, mul3, + mul4; /* Temporary variables to hold intermediate data */ #endif /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[2 * i ] = A[2 * i ] * B[i]. */ /* C[2 * i + 1] = A[2 * i + 1] * B[i]. */ -#if defined (ARM_MATH_DSP) - /* read 2 complex numbers both real and imaginary from complex input buffer */ - inA1 = read_q15x2_ia ((q15_t **) &pSrcCmplx); - inA2 = read_q15x2_ia ((q15_t **) &pSrcCmplx); +#if defined(ARM_MATH_DSP) + /* read 2 complex numbers both real and imaginary from complex input buffer + */ + inA1 = read_q15x2_ia((q15_t **)&pSrcCmplx); + inA2 = read_q15x2_ia((q15_t **)&pSrcCmplx); /* read 2 real values at a time from real input buffer */ - inB1 = read_q15x2_ia ((q15_t **) &pSrcReal); + inB1 = read_q15x2_ia((q15_t **)&pSrcReal); /* multiply complex number with real numbers */ #ifndef ARM_MATH_BIG_ENDIAN - mul1 = (q31_t) ((q15_t) (inA1) * (q15_t) (inB1)); - mul2 = (q31_t) ((q15_t) (inA1 >> 16) * (q15_t) (inB1)); - mul3 = (q31_t) ((q15_t) (inA2) * (q15_t) (inB1 >> 16)); - mul4 = (q31_t) ((q15_t) (inA2 >> 16) * (q15_t) (inB1 >> 16)); + mul1 = (q31_t)((q15_t)(inA1) * (q15_t)(inB1)); + mul2 = (q31_t)((q15_t)(inA1 >> 16) * (q15_t)(inB1)); + mul3 = (q31_t)((q15_t)(inA2) * (q15_t)(inB1 >> 16)); + mul4 = (q31_t)((q15_t)(inA2 >> 16) * (q15_t)(inB1 >> 16)); #else - mul2 = (q31_t) ((q15_t) (inA1 >> 16) * (q15_t) (inB1 >> 16)); - mul1 = (q31_t) ((q15_t) inA1 * (q15_t) (inB1 >> 16)); - mul4 = (q31_t) ((q15_t) (inA2 >> 16) * (q15_t) inB1); - mul3 = (q31_t) ((q15_t) inA2 * (q15_t) inB1); + mul2 = (q31_t)((q15_t)(inA1 >> 16) * (q15_t)(inB1 >> 16)); + mul1 = (q31_t)((q15_t)inA1 * (q15_t)(inB1 >> 16)); + mul4 = (q31_t)((q15_t)(inA2 >> 16) * (q15_t)inB1); + mul3 = (q31_t)((q15_t)inA2 * (q15_t)inB1); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* saturate the result */ - out1 = (q15_t) __SSAT(mul1 >> 15U, 16); - out2 = (q15_t) __SSAT(mul2 >> 15U, 16); - out3 = (q15_t) __SSAT(mul3 >> 15U, 16); - out4 = (q15_t) __SSAT(mul4 >> 15U, 16); + out1 = (q15_t)__SSAT(mul1 >> 15U, 16); + out2 = (q15_t)__SSAT(mul2 >> 15U, 16); + out3 = (q15_t)__SSAT(mul3 >> 15U, 16); + out4 = (q15_t)__SSAT(mul4 >> 15U, 16); /* pack real and imaginary outputs and store them to destination */ - write_q15x2_ia (&pCmplxDst, __PKHBT(out1, out2, 16)); - write_q15x2_ia (&pCmplxDst, __PKHBT(out3, out4, 16)); + write_q15x2_ia(&pCmplxDst, __PKHBT(out1, out2, 16)); + write_q15x2_ia(&pCmplxDst, __PKHBT(out3, out4, 16)); - inA1 = read_q15x2_ia ((q15_t **) &pSrcCmplx); - inA2 = read_q15x2_ia ((q15_t **) &pSrcCmplx); - inB1 = read_q15x2_ia ((q15_t **) &pSrcReal); + inA1 = read_q15x2_ia((q15_t **)&pSrcCmplx); + inA2 = read_q15x2_ia((q15_t **)&pSrcCmplx); + inB1 = read_q15x2_ia((q15_t **)&pSrcReal); #ifndef ARM_MATH_BIG_ENDIAN - mul1 = (q31_t) ((q15_t) (inA1) * (q15_t) (inB1)); - mul2 = (q31_t) ((q15_t) (inA1 >> 16) * (q15_t) (inB1)); - mul3 = (q31_t) ((q15_t) (inA2) * (q15_t) (inB1 >> 16)); - mul4 = (q31_t) ((q15_t) (inA2 >> 16) * (q15_t) (inB1 >> 16)); + mul1 = (q31_t)((q15_t)(inA1) * (q15_t)(inB1)); + mul2 = (q31_t)((q15_t)(inA1 >> 16) * (q15_t)(inB1)); + mul3 = (q31_t)((q15_t)(inA2) * (q15_t)(inB1 >> 16)); + mul4 = (q31_t)((q15_t)(inA2 >> 16) * (q15_t)(inB1 >> 16)); #else - mul2 = (q31_t) ((q15_t) (inA1 >> 16) * (q15_t) (inB1 >> 16)); - mul1 = (q31_t) ((q15_t) inA1 * (q15_t) (inB1 >> 16)); - mul4 = (q31_t) ((q15_t) (inA2 >> 16) * (q15_t) inB1); - mul3 = (q31_t) ((q15_t) inA2 * (q15_t) inB1); + mul2 = (q31_t)((q15_t)(inA1 >> 16) * (q15_t)(inB1 >> 16)); + mul1 = (q31_t)((q15_t)inA1 * (q15_t)(inB1 >> 16)); + mul4 = (q31_t)((q15_t)(inA2 >> 16) * (q15_t)inB1); + mul3 = (q31_t)((q15_t)inA2 * (q15_t)inB1); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ - out1 = (q15_t) __SSAT(mul1 >> 15U, 16); - out2 = (q15_t) __SSAT(mul2 >> 15U, 16); - out3 = (q15_t) __SSAT(mul3 >> 15U, 16); - out4 = (q15_t) __SSAT(mul4 >> 15U, 16); + out1 = (q15_t)__SSAT(mul1 >> 15U, 16); + out2 = (q15_t)__SSAT(mul2 >> 15U, 16); + out3 = (q15_t)__SSAT(mul3 >> 15U, 16); + out4 = (q15_t)__SSAT(mul4 >> 15U, 16); - write_q15x2_ia (&pCmplxDst, __PKHBT(out1, out2, 16)); - write_q15x2_ia (&pCmplxDst, __PKHBT(out3, out4, 16)); + write_q15x2_ia(&pCmplxDst, __PKHBT(out1, out2, 16)); + write_q15x2_ia(&pCmplxDst, __PKHBT(out3, out4, 16)); #else in = *pSrcReal++; - *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); - *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); + *pCmplxDst++ = (q15_t)__SSAT((((q31_t)*pSrcCmplx++ * in) >> 15), 16); + *pCmplxDst++ = (q15_t)__SSAT((((q31_t)*pSrcCmplx++ * in) >> 15), 16); in = *pSrcReal++; - *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); - *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); + *pCmplxDst++ = (q15_t)__SSAT((((q31_t)*pSrcCmplx++ * in) >> 15), 16); + *pCmplxDst++ = (q15_t)__SSAT((((q31_t)*pSrcCmplx++ * in) >> 15), 16); in = *pSrcReal++; - *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); - *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); + *pCmplxDst++ = (q15_t)__SSAT((((q31_t)*pSrcCmplx++ * in) >> 15), 16); + *pCmplxDst++ = (q15_t)__SSAT((((q31_t)*pSrcCmplx++ * in) >> 15), 16); in = *pSrcReal++; - *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); - *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); + *pCmplxDst++ = (q15_t)__SSAT((((q31_t)*pSrcCmplx++ * in) >> 15), 16); + *pCmplxDst++ = (q15_t)__SSAT((((q31_t)*pSrcCmplx++ * in) >> 15), 16); #endif /* Decrement loop counter */ @@ -161,20 +159,18 @@ void arm_cmplx_mult_real_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[2 * i ] = A[2 * i ] * B[i]. */ /* C[2 * i + 1] = A[2 * i + 1] * B[i]. */ in = *pSrcReal++; /* store the result in the destination buffer. */ - *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); - *pCmplxDst++ = (q15_t) __SSAT((((q31_t) *pSrcCmplx++ * in) >> 15), 16); + *pCmplxDst++ = (q15_t)__SSAT((((q31_t)*pSrcCmplx++ * in) >> 15), 16); + *pCmplxDst++ = (q15_t)__SSAT((((q31_t)*pSrcCmplx++ * in) >> 15), 16); /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_real_q31.c b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_real_q31.c index 906410f..37fba6a 100644 --- a/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_real_q31.c +++ b/platform/cmsis/DSP_Lib/ComplexMathFunctions/arm_cmplx_mult_real_q31.c @@ -47,64 +47,60 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q31 range[0x80000000 0x7FFFFFFF] are saturated. + Results outside of the allowable Q31 range[0x80000000 + 0x7FFFFFFF] are saturated. */ -void arm_cmplx_mult_real_q31( - const q31_t * pSrcCmplx, - const q31_t * pSrcReal, - q31_t * pCmplxDst, - uint32_t numSamples) -{ - uint32_t blkCnt; /* Loop counter */ - q31_t in; /* Temporary variable */ +void arm_cmplx_mult_real_q31(const q31_t *pSrcCmplx, const q31_t *pSrcReal, + q31_t *pCmplxDst, uint32_t numSamples) { + uint32_t blkCnt; /* Loop counter */ + q31_t in; /* Temporary variable */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[2 * i ] = A[2 * i ] * B[i]. */ /* C[2 * i + 1] = A[2 * i + 1] * B[i]. */ in = *pSrcReal++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* store saturated result in 1.31 format to destination buffer */ - *pCmplxDst++ = (__SSAT((q31_t) (((q63_t) *pSrcCmplx++ * in) >> 32), 31) << 1); - *pCmplxDst++ = (__SSAT((q31_t) (((q63_t) *pSrcCmplx++ * in) >> 32), 31) << 1); + *pCmplxDst++ = (__SSAT((q31_t)(((q63_t)*pSrcCmplx++ * in) >> 32), 31) << 1); + *pCmplxDst++ = (__SSAT((q31_t)(((q63_t)*pSrcCmplx++ * in) >> 32), 31) << 1); #else /* store result in destination buffer. */ - *pCmplxDst++ = (q31_t) clip_q63_to_q31(((q63_t) *pSrcCmplx++ * in) >> 31); - *pCmplxDst++ = (q31_t) clip_q63_to_q31(((q63_t) *pSrcCmplx++ * in) >> 31); + *pCmplxDst++ = (q31_t)clip_q63_to_q31(((q63_t)*pSrcCmplx++ * in) >> 31); + *pCmplxDst++ = (q31_t)clip_q63_to_q31(((q63_t)*pSrcCmplx++ * in) >> 31); #endif in = *pSrcReal++; -#if defined (ARM_MATH_DSP) - *pCmplxDst++ = (__SSAT((q31_t) (((q63_t) *pSrcCmplx++ * in) >> 32), 31) << 1); - *pCmplxDst++ = (__SSAT((q31_t) (((q63_t) *pSrcCmplx++ * in) >> 32), 31) << 1); +#if defined(ARM_MATH_DSP) + *pCmplxDst++ = (__SSAT((q31_t)(((q63_t)*pSrcCmplx++ * in) >> 32), 31) << 1); + *pCmplxDst++ = (__SSAT((q31_t)(((q63_t)*pSrcCmplx++ * in) >> 32), 31) << 1); #else - *pCmplxDst++ = (q31_t) clip_q63_to_q31(((q63_t) *pSrcCmplx++ * in) >> 31); - *pCmplxDst++ = (q31_t) clip_q63_to_q31(((q63_t) *pSrcCmplx++ * in) >> 31); + *pCmplxDst++ = (q31_t)clip_q63_to_q31(((q63_t)*pSrcCmplx++ * in) >> 31); + *pCmplxDst++ = (q31_t)clip_q63_to_q31(((q63_t)*pSrcCmplx++ * in) >> 31); #endif in = *pSrcReal++; -#if defined (ARM_MATH_DSP) - *pCmplxDst++ = (__SSAT((q31_t) (((q63_t) *pSrcCmplx++ * in) >> 32), 31) << 1); - *pCmplxDst++ = (__SSAT((q31_t) (((q63_t) *pSrcCmplx++ * in) >> 32), 31) << 1); +#if defined(ARM_MATH_DSP) + *pCmplxDst++ = (__SSAT((q31_t)(((q63_t)*pSrcCmplx++ * in) >> 32), 31) << 1); + *pCmplxDst++ = (__SSAT((q31_t)(((q63_t)*pSrcCmplx++ * in) >> 32), 31) << 1); #else - *pCmplxDst++ = (q31_t) clip_q63_to_q31(((q63_t) *pSrcCmplx++ * in) >> 31); - *pCmplxDst++ = (q31_t) clip_q63_to_q31(((q63_t) *pSrcCmplx++ * in) >> 31); + *pCmplxDst++ = (q31_t)clip_q63_to_q31(((q63_t)*pSrcCmplx++ * in) >> 31); + *pCmplxDst++ = (q31_t)clip_q63_to_q31(((q63_t)*pSrcCmplx++ * in) >> 31); #endif in = *pSrcReal++; -#if defined (ARM_MATH_DSP) - *pCmplxDst++ = (__SSAT((q31_t) (((q63_t) *pSrcCmplx++ * in) >> 32), 31) << 1); - *pCmplxDst++ = (__SSAT((q31_t) (((q63_t) *pSrcCmplx++ * in) >> 32), 31) << 1); +#if defined(ARM_MATH_DSP) + *pCmplxDst++ = (__SSAT((q31_t)(((q63_t)*pSrcCmplx++ * in) >> 32), 31) << 1); + *pCmplxDst++ = (__SSAT((q31_t)(((q63_t)*pSrcCmplx++ * in) >> 32), 31) << 1); #else - *pCmplxDst++ = (q31_t) clip_q63_to_q31(((q63_t) *pSrcCmplx++ * in) >> 31); - *pCmplxDst++ = (q31_t) clip_q63_to_q31(((q63_t) *pSrcCmplx++ * in) >> 31); + *pCmplxDst++ = (q31_t)clip_q63_to_q31(((q63_t)*pSrcCmplx++ * in) >> 31); + *pCmplxDst++ = (q31_t)clip_q63_to_q31(((q63_t)*pSrcCmplx++ * in) >> 31); #endif /* Decrement loop counter */ @@ -121,26 +117,24 @@ void arm_cmplx_mult_real_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C[2 * i ] = A[2 * i ] * B[i]. */ /* C[2 * i + 1] = A[2 * i + 1] * B[i]. */ in = *pSrcReal++; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* store saturated result in 1.31 format to destination buffer */ - *pCmplxDst++ = (__SSAT((q31_t) (((q63_t) *pSrcCmplx++ * in) >> 32), 31) << 1); - *pCmplxDst++ = (__SSAT((q31_t) (((q63_t) *pSrcCmplx++ * in) >> 32), 31) << 1); + *pCmplxDst++ = (__SSAT((q31_t)(((q63_t)*pSrcCmplx++ * in) >> 32), 31) << 1); + *pCmplxDst++ = (__SSAT((q31_t)(((q63_t)*pSrcCmplx++ * in) >> 32), 31) << 1); #else /* store result in destination buffer. */ - *pCmplxDst++ = (q31_t) clip_q63_to_q31(((q63_t) *pSrcCmplx++ * in) >> 31); - *pCmplxDst++ = (q31_t) clip_q63_to_q31(((q63_t) *pSrcCmplx++ * in) >> 31); + *pCmplxDst++ = (q31_t)clip_q63_to_q31(((q63_t)*pSrcCmplx++ * in) >> 31); + *pCmplxDst++ = (q31_t)clip_q63_to_q31(((q63_t)*pSrcCmplx++ * in) >> 31); #endif /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/ControllerFunctions/ControllerFunctions.c b/platform/cmsis/DSP_Lib/ControllerFunctions/ControllerFunctions.c index 51720bc..6979574 100644 --- a/platform/cmsis/DSP_Lib/ControllerFunctions/ControllerFunctions.c +++ b/platform/cmsis/DSP_Lib/ControllerFunctions/ControllerFunctions.c @@ -34,4 +34,3 @@ #include "arm_pid_reset_q31.c" #include "arm_sin_cos_f32.c" #include "arm_sin_cos_q31.c" - diff --git a/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_init_f32.c b/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_init_f32.c index 433a65a..061a696 100644 --- a/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_init_f32.c +++ b/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_init_f32.c @@ -42,32 +42,28 @@ @return none @par Details - The resetStateFlag specifies whether to set state to zero or not. \n - The function computes the structure fields: A0, A1 A2 - using the proportional gain( \c Kp), integral gain( \c Ki) and derivative gain( \c Kd) - also sets the state variables to all zeros. + The resetStateFlag specifies whether to set + state to zero or not. \n The function computes the structure fields: + A0, A1 A2 using the proportional gain( + \c Kp), integral gain( \c Ki) and derivative gain( \c Kd) also sets the state + variables to all zeros. */ -void arm_pid_init_f32( - arm_pid_instance_f32 * S, - int32_t resetStateFlag) -{ +void arm_pid_init_f32(arm_pid_instance_f32 *S, int32_t resetStateFlag) { /* Derived coefficient A0 */ S->A0 = S->Kp + S->Ki + S->Kd; /* Derived coefficient A1 */ - S->A1 = (-S->Kp) - ((float32_t) 2.0 * S->Kd); + S->A1 = (-S->Kp) - ((float32_t)2.0 * S->Kd); /* Derived coefficient A2 */ S->A2 = S->Kd; /* Check whether state needs reset or not */ - if (resetStateFlag) - { + if (resetStateFlag) { /* Reset state to zero, The size will be always 3 samples */ memset(S->state, 0, 3U * sizeof(float32_t)); } - } /** diff --git a/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_init_q15.c b/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_init_q15.c index c88a3d9..724616c 100644 --- a/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_init_q15.c +++ b/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_init_q15.c @@ -42,25 +42,23 @@ @return none @par Details - The resetStateFlag specifies whether to set state to zero or not. \n - The function computes the structure fields: A0, A1 A2 - using the proportional gain( \c Kp), integral gain( \c Ki) and derivative gain( \c Kd) - also sets the state variables to all zeros. + The resetStateFlag specifies whether to set + state to zero or not. \n The function computes the structure fields: + A0, A1 A2 using the proportional gain( + \c Kp), integral gain( \c Ki) and derivative gain( \c Kd) also sets the state + variables to all zeros. */ -void arm_pid_init_q15( - arm_pid_instance_q15 * S, - int32_t resetStateFlag) -{ +void arm_pid_init_q15(arm_pid_instance_q15 *S, int32_t resetStateFlag) { -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* Derived coefficient A0 */ S->A0 = __QADD16(__QADD16(S->Kp, S->Ki), S->Kd); /* Derived coefficients and pack into A1 */ -#ifndef ARM_MATH_BIG_ENDIAN +#ifndef ARM_MATH_BIG_ENDIAN S->A1 = __PKHBT(-__QADD16(__QADD16(S->Kd, S->Kd), S->Kp), S->Kd, 16); #else S->A1 = __PKHBT(S->Kd, -__QADD16(__QADD16(S->Kd, S->Kd), S->Kp), 16); @@ -68,26 +66,24 @@ void arm_pid_init_q15( #else - q31_t temp; /* to store the sum */ + q31_t temp; /* to store the sum */ /* Derived coefficient A0 */ temp = S->Kp + S->Ki + S->Kd; - S->A0 = (q15_t) __SSAT(temp, 16); + S->A0 = (q15_t)__SSAT(temp, 16); /* Derived coefficients and pack into A1 */ temp = -(S->Kd + S->Kd + S->Kp); - S->A1 = (q15_t) __SSAT(temp, 16); + S->A1 = (q15_t)__SSAT(temp, 16); S->A2 = S->Kd; #endif /* #if defined (ARM_MATH_DSP) */ /* Check whether state needs reset or not */ - if (resetStateFlag) - { + if (resetStateFlag) { /* Reset state to zero, The size will be always 3 samples */ memset(S->state, 0, 3U * sizeof(q15_t)); } - } /** diff --git a/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_init_q31.c b/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_init_q31.c index 1625a5f..306076a 100644 --- a/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_init_q31.c +++ b/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_init_q31.c @@ -42,18 +42,16 @@ @return none @par Details - The resetStateFlag specifies whether to set state to zero or not. \n - The function computes the structure fields: A0, A1 A2 - using the proportional gain( \c Kp), integral gain( \c Ki) and derivative gain( \c Kd) - also sets the state variables to all zeros. + The resetStateFlag specifies whether to set + state to zero or not. \n The function computes the structure fields: + A0, A1 A2 using the proportional gain( + \c Kp), integral gain( \c Ki) and derivative gain( \c Kd) also sets the state + variables to all zeros. */ -void arm_pid_init_q31( - arm_pid_instance_q31 * S, - int32_t resetStateFlag) -{ +void arm_pid_init_q31(arm_pid_instance_q31 *S, int32_t resetStateFlag) { -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* Derived coefficient A0 */ S->A0 = __QADD(__QADD(S->Kp, S->Ki), S->Kd); @@ -63,15 +61,15 @@ void arm_pid_init_q31( #else - q31_t temp; /* to store the sum */ + q31_t temp; /* to store the sum */ /* Derived coefficient A0 */ - temp = clip_q63_to_q31((q63_t) S->Kp + S->Ki); - S->A0 = clip_q63_to_q31((q63_t) temp + S->Kd); + temp = clip_q63_to_q31((q63_t)S->Kp + S->Ki); + S->A0 = clip_q63_to_q31((q63_t)temp + S->Kd); /* Derived coefficient A1 */ - temp = clip_q63_to_q31((q63_t) S->Kd + S->Kd); - S->A1 = -clip_q63_to_q31((q63_t) temp + S->Kp); + temp = clip_q63_to_q31((q63_t)S->Kd + S->Kd); + S->A1 = -clip_q63_to_q31((q63_t)temp + S->Kp); #endif /* #if defined (ARM_MATH_DSP) */ @@ -79,12 +77,10 @@ void arm_pid_init_q31( S->A2 = S->Kd; /* Check whether state needs reset or not */ - if (resetStateFlag) - { + if (resetStateFlag) { /* Reset state to zero, The size will be always 3 samples */ memset(S->state, 0, 3U * sizeof(q31_t)); } - } /** diff --git a/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_reset_f32.c b/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_reset_f32.c index d839e55..51a0c3e 100644 --- a/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_reset_f32.c +++ b/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_reset_f32.c @@ -42,9 +42,7 @@ The function resets the state buffer to zeros. */ -void arm_pid_reset_f32( - arm_pid_instance_f32 * S) -{ +void arm_pid_reset_f32(arm_pid_instance_f32 *S) { /* Reset state to zero, The size will be always 3 samples */ memset(S->state, 0, 3U * sizeof(float32_t)); } diff --git a/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_reset_q15.c b/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_reset_q15.c index 256fd8c..3ba2028 100644 --- a/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_reset_q15.c +++ b/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_reset_q15.c @@ -42,9 +42,7 @@ The function resets the state buffer to zeros. */ -void arm_pid_reset_q15( - arm_pid_instance_q15 * S) -{ +void arm_pid_reset_q15(arm_pid_instance_q15 *S) { /* Reset state to zero, The size will be always 3 samples */ memset(S->state, 0, 3U * sizeof(q15_t)); } diff --git a/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_reset_q31.c b/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_reset_q31.c index 2aa391c..a131cc7 100644 --- a/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_reset_q31.c +++ b/platform/cmsis/DSP_Lib/ControllerFunctions/arm_pid_reset_q31.c @@ -42,9 +42,7 @@ The function resets the state buffer to zeros. */ -void arm_pid_reset_q31( - arm_pid_instance_q31 * S) -{ +void arm_pid_reset_q31(arm_pid_instance_q31 *S) { /* Reset state to zero, The size will be always 3 samples */ memset(S->state, 0, 3U * sizeof(q31_t)); } diff --git a/platform/cmsis/DSP_Lib/ControllerFunctions/arm_sin_cos_f32.c b/platform/cmsis/DSP_Lib/ControllerFunctions/arm_sin_cos_f32.c index 12a1c83..fa5a7be 100644 --- a/platform/cmsis/DSP_Lib/ControllerFunctions/arm_sin_cos_f32.c +++ b/platform/cmsis/DSP_Lib/ControllerFunctions/arm_sin_cos_f32.c @@ -26,8 +26,8 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @ingroup groupController @@ -36,26 +36,30 @@ /** @defgroup SinCos Sine Cosine - Computes the trigonometric sine and cosine values using a combination of table lookup - and linear interpolation. - There are separate functions for Q31 and floating-point data types. - The input to the floating-point version is in degrees while the - fixed-point Q31 have a scaled input with the range + Computes the trigonometric sine and cosine values using a combination of table + lookup and linear interpolation. There are separate functions for Q31 and + floating-point data types. The input to the floating-point version is in + degrees while the fixed-point Q31 have a scaled input with the range [-1 0.9999] mapping to [-180 +180] degrees. - The floating point function also allows values that are out of the usual range. When this happens, the function will - take extra time to adjust the input value to the range of [-180 180]. + The floating point function also allows values that are out of the usual + range. When this happens, the function will take extra time to adjust the + input value to the range of [-180 180]. The result is accurate to 5 digits after the decimal point. - The implementation is based on table lookup using 360 values together with linear interpolation. - The steps used are: + The implementation is based on table lookup using 360 values together with + linear interpolation. The steps used are: -# Calculation of the nearest integer table index. -# Compute the fractional portion (fract) of the input. - -# Fetch the value corresponding to \c index from sine table to \c y0 and also value from \c index+1 to \c y1. - -# Sine value is computed as *psinVal = y0 + (fract * (y1 - y0)). - -# Fetch the value corresponding to \c index from cosine table to \c y0 and also value from \c index+1 to \c y1. - -# Cosine value is computed as *pcosVal = y0 + (fract * (y1 - y0)). + -# Fetch the value corresponding to \c index from sine table to \c y0 and + also value from \c index+1 to \c y1. + -# Sine value is computed as *psinVal = y0 + (fract * (y1 - + y0)). + -# Fetch the value corresponding to \c index from cosine table to \c y0 and + also value from \c index+1 to \c y1. + -# Cosine value is computed as *pcosVal = y0 + (fract * (y1 - + y0)). */ /** @@ -71,23 +75,19 @@ @return none */ -void arm_sin_cos_f32( - float32_t theta, - float32_t * pSinVal, - float32_t * pCosVal) -{ - float32_t fract, in; /* Temporary input, output variables */ - uint16_t indexS, indexC; /* Index variable */ - float32_t f1, f2, d1, d2; /* Two nearest output values */ +void arm_sin_cos_f32(float32_t theta, float32_t *pSinVal, float32_t *pCosVal) { + float32_t fract, in; /* Temporary input, output variables */ + uint16_t indexS, indexC; /* Index variable */ + float32_t f1, f2, d1, d2; /* Two nearest output values */ float32_t Dn, Df; float32_t temp, findex; /* input x is in degrees */ - /* Scale input, divide input by 360, for cosine add 0.25 (pi/2) to read sine table */ + /* Scale input, divide input by 360, for cosine add 0.25 (pi/2) to read sine + * table */ in = theta * 0.00277777777778f; - if (in < 0.0f) - { + if (in < 0.0f) { in = -in; } @@ -99,17 +99,18 @@ void arm_sin_cos_f32( indexC = (indexS + (FAST_MATH_TABLE_SIZE / 4)) & 0x1ff; /* Calculation of fractional value */ - fract = findex - (float32_t) indexS; + fract = findex - (float32_t)indexS; /* Read two nearest values of input value from the cos & sin tables */ - f1 = sinTable_f32[indexC ]; - f2 = sinTable_f32[indexC+1]; - d1 = -sinTable_f32[indexS ]; - d2 = -sinTable_f32[indexS+1]; + f1 = sinTable_f32[indexC]; + f2 = sinTable_f32[indexC + 1]; + d1 = -sinTable_f32[indexS]; + d2 = -sinTable_f32[indexS + 1]; temp = (1.0f - fract) * f1 + fract * f2; - Dn = 0.0122718463030f; /* delta between the two points (fixed), in this case 2*pi/FAST_MATH_TABLE_SIZE */ + Dn = 0.0122718463030f; /* delta between the two points (fixed), in this case + 2*pi/FAST_MATH_TABLE_SIZE */ Df = f2 - f1; /* delta between the values of the functions */ temp = Dn * (d1 + d2) - 2 * Df; @@ -120,10 +121,10 @@ void arm_sin_cos_f32( *pCosVal = fract * temp + f1; /* Read two nearest values of input value from the cos & sin tables */ - f1 = sinTable_f32[indexS ]; - f2 = sinTable_f32[indexS+1]; - d1 = sinTable_f32[indexC ]; - d2 = sinTable_f32[indexC+1]; + f1 = sinTable_f32[indexS]; + f2 = sinTable_f32[indexS + 1]; + d1 = sinTable_f32[indexC]; + d2 = sinTable_f32[indexC + 1]; temp = (1.0f - fract) * f1 + fract * f2; @@ -135,8 +136,7 @@ void arm_sin_cos_f32( /* Calculation of sine value */ *pSinVal = fract * temp + f1; - if (theta < 0.0f) - { + if (theta < 0.0f) { *pSinVal = -*pSinVal; } } diff --git a/platform/cmsis/DSP_Lib/ControllerFunctions/arm_sin_cos_q31.c b/platform/cmsis/DSP_Lib/ControllerFunctions/arm_sin_cos_q31.c index 84ee3d2..8ca01ae 100644 --- a/platform/cmsis/DSP_Lib/ControllerFunctions/arm_sin_cos_q31.c +++ b/platform/cmsis/DSP_Lib/ControllerFunctions/arm_sin_cos_q31.c @@ -26,8 +26,8 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @ingroup groupController @@ -45,17 +45,14 @@ @param[out] pCosVal points to processed cosine output @return none - The Q31 input value is in the range [-1 0.999999] and is mapped to a degree value in the range [-180 179]. + The Q31 input value is in the range [-1 0.999999] and is mapped to a degree + value in the range [-180 179]. */ -void arm_sin_cos_q31( - q31_t theta, - q31_t * pSinVal, - q31_t * pCosVal) -{ - q31_t fract; /* Temporary input, output variables */ - uint16_t indexS, indexC; /* Index variable */ - q31_t f1, f2, d1, d2; /* Two nearest output values */ +void arm_sin_cos_q31(q31_t theta, q31_t *pSinVal, q31_t *pCosVal) { + q31_t fract; /* Temporary input, output variables */ + uint16_t indexS, indexC; /* Index variable */ + q31_t f1, f2, d1, d2; /* Two nearest output values */ q31_t Dn, Df; q63_t temp; @@ -67,12 +64,13 @@ void arm_sin_cos_q31( fract = (theta - (indexS << CONTROLLER_Q31_SHIFT)) << 8; /* Read two nearest values of input value from the cos & sin tables */ - f1 = sinTable_q31[indexC ]; - f2 = sinTable_q31[indexC+1]; - d1 = -sinTable_q31[indexS ]; - d2 = -sinTable_q31[indexS+1]; + f1 = sinTable_q31[indexC]; + f2 = sinTable_q31[indexC + 1]; + d1 = -sinTable_q31[indexS]; + d2 = -sinTable_q31[indexS + 1]; - Dn = 0x1921FB5; /* delta between the two points (fixed), in this case 2*pi/FAST_MATH_TABLE_SIZE */ + Dn = 0x1921FB5; /* delta between the two points (fixed), in this case + 2*pi/FAST_MATH_TABLE_SIZE */ Df = f2 - f1; /* delta between the values of the functions */ temp = Dn * ((q63_t)d1 + d2); @@ -87,10 +85,10 @@ void arm_sin_cos_q31( *pCosVal = clip_q63_to_q31((temp >> 31) + (q63_t)f1); /* Read two nearest values of input value from the cos & sin tables */ - f1 = sinTable_q31[indexS ]; - f2 = sinTable_q31[indexS+1]; - d1 = sinTable_q31[indexC ]; - d2 = sinTable_q31[indexC+1]; + f1 = sinTable_q31[indexS]; + f2 = sinTable_q31[indexS + 1]; + d1 = sinTable_q31[indexC]; + d2 = sinTable_q31[indexC + 1]; Df = f2 - f1; // delta between the values of the functions temp = Dn * ((q63_t)d1 + d2); diff --git a/platform/cmsis/DSP_Lib/FastMathFunctions/FastMathFunctions.c b/platform/cmsis/DSP_Lib/FastMathFunctions/FastMathFunctions.c index abd919e..7a3ba97 100644 --- a/platform/cmsis/DSP_Lib/FastMathFunctions/FastMathFunctions.c +++ b/platform/cmsis/DSP_Lib/FastMathFunctions/FastMathFunctions.c @@ -34,4 +34,3 @@ #include "arm_sin_q31.c" #include "arm_sqrt_q15.c" #include "arm_sqrt_q31.c" - diff --git a/platform/cmsis/DSP_Lib/FastMathFunctions/arm_cos_f32.c b/platform/cmsis/DSP_Lib/FastMathFunctions/arm_cos_f32.c index 26bd66e..e07b4b7 100644 --- a/platform/cmsis/DSP_Lib/FastMathFunctions/arm_cos_f32.c +++ b/platform/cmsis/DSP_Lib/FastMathFunctions/arm_cos_f32.c @@ -26,8 +26,8 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @ingroup groupFastMath @@ -44,8 +44,8 @@ [0 +0.9999] mapping to [0 2*pi). The fixed-point range is chosen so that a value of 2*pi wraps around to 0. - The implementation is based on table lookup using 256 values together with linear interpolation. - The steps used are: + The implementation is based on table lookup using 256 values together with + linear interpolation. The steps used are: -# Calculation of the nearest integer table index -# Compute the fractional portion (fract) of the table index. -# The final result equals (1.0f-fract)*a + fract*b; @@ -63,35 +63,34 @@ */ /** - @brief Fast approximation to the trigonometric cosine function for floating-point data. + @brief Fast approximation to the trigonometric cosine function for + floating-point data. @param[in] x input value in radians @return cos(x) */ -float32_t arm_cos_f32( - float32_t x) -{ - float32_t cosVal, fract, in; /* Temporary input, output variables */ - uint16_t index; /* Index variable */ - float32_t a, b; /* Two nearest output values */ +float32_t arm_cos_f32(float32_t x) { + float32_t cosVal, fract, in; /* Temporary input, output variables */ + uint16_t index; /* Index variable */ + float32_t a, b; /* Two nearest output values */ int32_t n; float32_t findex; /* input x is in radians */ - /* Scale input to [0 1] range from [0 2*PI] , divide input by 2*pi, add 0.25 (pi/2) to read sine table */ + /* Scale input to [0 1] range from [0 2*PI] , divide input by 2*pi, add 0.25 + * (pi/2) to read sine table */ in = x * 0.159154943092f + 0.25f; /* Calculation of floor value of input */ - n = (int32_t) in; + n = (int32_t)in; /* Make negative values towards -infinity */ - if (in < 0.0f) - { + if (in < 0.0f) { n--; } /* Map input value to [0 1] */ - in = in - (float32_t) n; + in = in - (float32_t)n; /* Calculation of index of the table */ findex = (float32_t)FAST_MATH_TABLE_SIZE * in; @@ -104,11 +103,11 @@ float32_t arm_cos_f32( } /* fractional value calculation */ - fract = findex - (float32_t) index; + fract = findex - (float32_t)index; /* Read two nearest values of input value from the cos table */ a = sinTable_f32[index]; - b = sinTable_f32[index+1]; + b = sinTable_f32[index + 1]; /* Linear interpolation process */ cosVal = (1.0f - fract) * a + fract * b; diff --git a/platform/cmsis/DSP_Lib/FastMathFunctions/arm_cos_q15.c b/platform/cmsis/DSP_Lib/FastMathFunctions/arm_cos_q15.c index 3bb829c..14f7681 100644 --- a/platform/cmsis/DSP_Lib/FastMathFunctions/arm_cos_q15.c +++ b/platform/cmsis/DSP_Lib/FastMathFunctions/arm_cos_q15.c @@ -26,8 +26,8 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @ingroup groupFastMath @@ -39,25 +39,24 @@ */ /** - @brief Fast approximation to the trigonometric cosine function for Q15 data. + @brief Fast approximation to the trigonometric cosine function for Q15 + data. @param[in] x Scaled input value in radians @return cos(x) - The Q15 input value is in the range [0 +0.9999] and is mapped to a radian value in the range [0 2*PI). + The Q15 input value is in the range [0 +0.9999] and is mapped to a radian + value in the range [0 2*PI). */ -q15_t arm_cos_q15( - q15_t x) -{ - q15_t cosVal; /* Temporary input, output variables */ - int32_t index; /* Index variable */ - q15_t a, b; /* Two nearest output values */ - q15_t fract; /* Temporary values for fractional values */ +q15_t arm_cos_q15(q15_t x) { + q15_t cosVal; /* Temporary input, output variables */ + int32_t index; /* Index variable */ + q15_t a, b; /* Two nearest output values */ + q15_t fract; /* Temporary values for fractional values */ /* add 0.25 (pi/2) to read sine table */ x = (uint16_t)x + 0x2000; - if (x < 0) - { /* convert negative numbers to corresponding positive ones */ + if (x < 0) { /* convert negative numbers to corresponding positive ones */ x = (uint16_t)x + 0x8000; } @@ -69,11 +68,11 @@ q15_t arm_cos_q15( /* Read two nearest values of input value from the sin table */ a = sinTable_q15[index]; - b = sinTable_q15[index+1]; + b = sinTable_q15[index + 1]; /* Linear interpolation process */ - cosVal = (q31_t) (0x8000 - fract) * a >> 16; - cosVal = (q15_t) ((((q31_t) cosVal << 16) + ((q31_t) fract * b)) >> 16); + cosVal = (q31_t)(0x8000 - fract) * a >> 16; + cosVal = (q15_t)((((q31_t)cosVal << 16) + ((q31_t)fract * b)) >> 16); /* Return output value */ return (cosVal << 1); diff --git a/platform/cmsis/DSP_Lib/FastMathFunctions/arm_cos_q31.c b/platform/cmsis/DSP_Lib/FastMathFunctions/arm_cos_q31.c index 8b7ff78..9fcb6e3 100644 --- a/platform/cmsis/DSP_Lib/FastMathFunctions/arm_cos_q31.c +++ b/platform/cmsis/DSP_Lib/FastMathFunctions/arm_cos_q31.c @@ -26,8 +26,8 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @ingroup groupFastMath @@ -39,25 +39,24 @@ */ /** - @brief Fast approximation to the trigonometric cosine function for Q31 data. + @brief Fast approximation to the trigonometric cosine function for Q31 + data. @param[in] x Scaled input value in radians @return cos(x) - The Q31 input value is in the range [0 +0.9999] and is mapped to a radian value in the range [0 2*PI). + The Q31 input value is in the range [0 +0.9999] and is mapped to a radian + value in the range [0 2*PI). */ -q31_t arm_cos_q31( - q31_t x) -{ - q31_t cosVal; /* Temporary input, output variables */ - int32_t index; /* Index variable */ - q31_t a, b; /* Two nearest output values */ - q31_t fract; /* Temporary values for fractional values */ +q31_t arm_cos_q31(q31_t x) { + q31_t cosVal; /* Temporary input, output variables */ + int32_t index; /* Index variable */ + q31_t a, b; /* Two nearest output values */ + q31_t fract; /* Temporary values for fractional values */ /* add 0.25 (pi/2) to read sine table */ x = (uint32_t)x + 0x20000000; - if (x < 0) - { /* convert negative numbers to corresponding positive ones */ + if (x < 0) { /* convert negative numbers to corresponding positive ones */ x = (uint32_t)x + 0x80000000; } @@ -69,11 +68,11 @@ q31_t arm_cos_q31( /* Read two nearest values of input value from the sin table */ a = sinTable_q31[index]; - b = sinTable_q31[index+1]; + b = sinTable_q31[index + 1]; /* Linear interpolation process */ - cosVal = (q63_t) (0x80000000 - fract) * a >> 32; - cosVal = (q31_t) ((((q63_t) cosVal << 32) + ((q63_t) fract * b)) >> 32); + cosVal = (q63_t)(0x80000000 - fract) * a >> 32; + cosVal = (q31_t)((((q63_t)cosVal << 32) + ((q63_t)fract * b)) >> 32); /* Return output value */ return (cosVal << 1); diff --git a/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sin_f32.c b/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sin_f32.c index 97c6902..c2e0ea1 100644 --- a/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sin_f32.c +++ b/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sin_f32.c @@ -26,8 +26,8 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @ingroup groupFastMath @@ -44,8 +44,8 @@ [0 +0.9999] mapping to [0 2*pi). The fixed-point range is chosen so that a value of 2*pi wraps around to 0. - The implementation is based on table lookup using 256 values together with linear interpolation. - The steps used are: + The implementation is based on table lookup using 256 values together with + linear interpolation. The steps used are: -# Calculation of the nearest integer table index -# Compute the fractional portion (fract) of the table index. -# The final result equals (1.0f-fract)*a + fract*b; @@ -63,17 +63,16 @@ */ /** - @brief Fast approximation to the trigonometric sine function for floating-point data. + @brief Fast approximation to the trigonometric sine function for + floating-point data. @param[in] x input value in radians. @return sin(x) */ -float32_t arm_sin_f32( - float32_t x) -{ - float32_t sinVal, fract, in; /* Temporary input, output variables */ - uint16_t index; /* Index variable */ - float32_t a, b; /* Two nearest output values */ +float32_t arm_sin_f32(float32_t x) { + float32_t sinVal, fract, in; /* Temporary input, output variables */ + uint16_t index; /* Index variable */ + float32_t a, b; /* Two nearest output values */ int32_t n; float32_t findex; @@ -82,16 +81,15 @@ float32_t arm_sin_f32( in = x * 0.159154943092f; /* Calculation of floor value of input */ - n = (int32_t) in; + n = (int32_t)in; /* Make negative values towards -infinity */ - if (in < 0.0f) - { + if (in < 0.0f) { n--; } /* Map input value to [0 1] */ - in = in - (float32_t) n; + in = in - (float32_t)n; /* Calculation of index of the table */ findex = (float32_t)FAST_MATH_TABLE_SIZE * in; @@ -104,11 +102,11 @@ float32_t arm_sin_f32( } /* fractional value calculation */ - fract = findex - (float32_t) index; + fract = findex - (float32_t)index; /* Read two nearest values of input value from the sin table */ a = sinTable_f32[index]; - b = sinTable_f32[index+1]; + b = sinTable_f32[index + 1]; /* Linear interpolation process */ sinVal = (1.0f - fract) * a + fract * b; diff --git a/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sin_q15.c b/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sin_q15.c index 1f0c2bf..57509c6 100644 --- a/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sin_q15.c +++ b/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sin_q15.c @@ -26,8 +26,8 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @ingroup groupFastMath @@ -39,20 +39,20 @@ */ /** - @brief Fast approximation to the trigonometric sine function for Q15 data. + @brief Fast approximation to the trigonometric sine function for Q15 + data. @param[in] x Scaled input value in radians @return sin(x) - The Q15 input value is in the range [0 +0.9999] and is mapped to a radian value in the range [0 2*PI). + The Q15 input value is in the range [0 +0.9999] and is mapped to a radian + value in the range [0 2*PI). */ -q15_t arm_sin_q15( - q15_t x) -{ - q15_t sinVal; /* Temporary input, output variables */ - int32_t index; /* Index variable */ - q15_t a, b; /* Two nearest output values */ - q15_t fract; /* Temporary values for fractional values */ +q15_t arm_sin_q15(q15_t x) { + q15_t sinVal; /* Temporary input, output variables */ + int32_t index; /* Index variable */ + q15_t a, b; /* Two nearest output values */ + q15_t fract; /* Temporary values for fractional values */ /* Calculate the nearest index */ index = (uint32_t)x >> FAST_MATH_Q15_SHIFT; @@ -62,11 +62,11 @@ q15_t arm_sin_q15( /* Read two nearest values of input value from the sin table */ a = sinTable_q15[index]; - b = sinTable_q15[index+1]; + b = sinTable_q15[index + 1]; /* Linear interpolation process */ - sinVal = (q31_t) (0x8000 - fract) * a >> 16; - sinVal = (q15_t) ((((q31_t) sinVal << 16) + ((q31_t) fract * b)) >> 16); + sinVal = (q31_t)(0x8000 - fract) * a >> 16; + sinVal = (q15_t)((((q31_t)sinVal << 16) + ((q31_t)fract * b)) >> 16); /* Return output value */ return (sinVal << 1); diff --git a/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sin_q31.c b/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sin_q31.c index 8cefabb..d55a4d1 100644 --- a/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sin_q31.c +++ b/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sin_q31.c @@ -26,8 +26,8 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @ingroup groupFastMath @@ -39,20 +39,20 @@ */ /** - @brief Fast approximation to the trigonometric sine function for Q31 data. + @brief Fast approximation to the trigonometric sine function for Q31 + data. @param[in] x Scaled input value in radians @return sin(x) - The Q31 input value is in the range [0 +0.9999] and is mapped to a radian value in the range [0 2*PI). + The Q31 input value is in the range [0 +0.9999] and is mapped to a radian + value in the range [0 2*PI). */ -q31_t arm_sin_q31( - q31_t x) -{ - q31_t sinVal; /* Temporary variables for input, output */ - int32_t index; /* Index variable */ - q31_t a, b; /* Two nearest output values */ - q31_t fract; /* Temporary values for fractional values */ +q31_t arm_sin_q31(q31_t x) { + q31_t sinVal; /* Temporary variables for input, output */ + int32_t index; /* Index variable */ + q31_t a, b; /* Two nearest output values */ + q31_t fract; /* Temporary values for fractional values */ /* Calculate the nearest index */ index = (uint32_t)x >> FAST_MATH_Q31_SHIFT; @@ -62,11 +62,11 @@ q31_t arm_sin_q31( /* Read two nearest values of input value from the sin table */ a = sinTable_q31[index]; - b = sinTable_q31[index+1]; + b = sinTable_q31[index + 1]; /* Linear interpolation process */ - sinVal = (q63_t) (0x80000000 - fract) * a >> 32; - sinVal = (q31_t) ((((q63_t) sinVal << 32) + ((q63_t) fract * b)) >> 32); + sinVal = (q63_t)(0x80000000 - fract) * a >> 32; + sinVal = (q31_t)((((q63_t)sinVal << 32) + ((q63_t)fract * b)) >> 32); /* Return output value */ return (sinVal << 1); diff --git a/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sqrt_q15.c b/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sqrt_q15.c index fab0a32..44e762d 100644 --- a/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sqrt_q15.c +++ b/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sqrt_q15.c @@ -26,8 +26,8 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @ingroup groupFastMath @@ -40,22 +40,20 @@ /** @brief Q15 square root function. - @param[in] in input value. The range of the input value is [0 +1) or 0x0000 to 0x7FFF + @param[in] in input value. The range of the input value is [0 +1) or + 0x0000 to 0x7FFF @param[out] pOut points to square root of input value @return execution status - \ref ARM_MATH_SUCCESS : input value is positive - - \ref ARM_MATH_ARGUMENT_ERROR : input value is negative; *pOut is set to 0 + - \ref ARM_MATH_ARGUMENT_ERROR : input value is negative; + *pOut is set to 0 */ -arm_status arm_sqrt_q15( - q15_t in, - q15_t * pOut) -{ +arm_status arm_sqrt_q15(q15_t in, q15_t *pOut) { q31_t bits_val1; q15_t number, temp1, var1, signBits1, half; float32_t temp_float1; - union - { + union { q31_t fracval; float32_t floatval; } tempconv; @@ -63,17 +61,13 @@ arm_status arm_sqrt_q15( number = in; /* If the input is a positive number then compute the signBits. */ - if (number > 0) - { + if (number > 0) { signBits1 = __CLZ(number) - 17; /* Shift by the number of signBits1 */ - if ((signBits1 % 2) == 0) - { + if ((signBits1 % 2) == 0) { number = number << signBits1; - } - else - { + } else { number = number << (signBits1 - 1); } @@ -88,51 +82,54 @@ arm_status arm_sqrt_q15( tempconv.floatval = temp_float1; bits_val1 = tempconv.fracval; /* Subtract the shifted value from the magic number to give intial guess */ - bits_val1 = 0x5f3759df - (bits_val1 >> 1); /* gives initial guess */ + bits_val1 = 0x5f3759df - (bits_val1 >> 1); /* gives initial guess */ /* Store as float */ tempconv.fracval = bits_val1; temp_float1 = tempconv.floatval; /* Convert to integer format */ - var1 = (q31_t) (temp_float1 * 16384); + var1 = (q31_t)(temp_float1 * 16384); /* 1st iteration */ - var1 = ((q15_t) ((q31_t) var1 * (0x3000 - - ((q15_t) - ((((q15_t) - (((q31_t) var1 * var1) >> 15)) * - (q31_t) half) >> 15))) >> 15)) << 2; + var1 = + ((q15_t)((q31_t)var1 * + (0x3000 - ((q15_t)((((q15_t)(((q31_t)var1 * var1) >> 15)) * + (q31_t)half) >> + 15))) >> + 15)) + << 2; /* 2nd iteration */ - var1 = ((q15_t) ((q31_t) var1 * (0x3000 - - ((q15_t) - ((((q15_t) - (((q31_t) var1 * var1) >> 15)) * - (q31_t) half) >> 15))) >> 15)) << 2; + var1 = + ((q15_t)((q31_t)var1 * + (0x3000 - ((q15_t)((((q15_t)(((q31_t)var1 * var1) >> 15)) * + (q31_t)half) >> + 15))) >> + 15)) + << 2; /* 3rd iteration */ - var1 = ((q15_t) ((q31_t) var1 * (0x3000 - - ((q15_t) - ((((q15_t) - (((q31_t) var1 * var1) >> 15)) * - (q31_t) half) >> 15))) >> 15)) << 2; + var1 = + ((q15_t)((q31_t)var1 * + (0x3000 - ((q15_t)((((q15_t)(((q31_t)var1 * var1) >> 15)) * + (q31_t)half) >> + 15))) >> + 15)) + << 2; /* Multiply the inverse square root with the original value */ - var1 = ((q15_t) (((q31_t) temp1 * var1) >> 15)) << 1; + var1 = ((q15_t)(((q31_t)temp1 * var1) >> 15)) << 1; /* Shift the output down accordingly */ - if ((signBits1 % 2) == 0) - { + if ((signBits1 % 2) == 0) { var1 = var1 >> (signBits1 / 2); - } - else - { + } else { var1 = var1 >> ((signBits1 - 1) / 2); } *pOut = var1; return (ARM_MATH_SUCCESS); } - /* If the number is a negative number then store zero as its square root value */ - else - { + /* If the number is a negative number then store zero as its square root value + */ + else { *pOut = 0; return (ARM_MATH_ARGUMENT_ERROR); diff --git a/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sqrt_q31.c b/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sqrt_q31.c index 9889b13..4e24470 100644 --- a/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sqrt_q31.c +++ b/platform/cmsis/DSP_Lib/FastMathFunctions/arm_sqrt_q31.c @@ -26,8 +26,8 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @ingroup groupFastMath @@ -40,22 +40,20 @@ /** @brief Q31 square root function. - @param[in] in input value. The range of the input value is [0 +1) or 0x00000000 to 0x7FFFFFFF + @param[in] in input value. The range of the input value is [0 +1) or + 0x00000000 to 0x7FFFFFFF @param[out] pOut points to square root of input value @return execution status - \ref ARM_MATH_SUCCESS : input value is positive - - \ref ARM_MATH_ARGUMENT_ERROR : input value is negative; *pOut is set to 0 + - \ref ARM_MATH_ARGUMENT_ERROR : input value is negative; + *pOut is set to 0 */ -arm_status arm_sqrt_q31( - q31_t in, - q31_t * pOut) -{ +arm_status arm_sqrt_q31(q31_t in, q31_t *pOut) { q31_t bits_val1; q31_t number, temp1, var1, signBits1, half; float32_t temp_float1; - union - { + union { q31_t fracval; float32_t floatval; } tempconv; @@ -63,17 +61,13 @@ arm_status arm_sqrt_q31( number = in; /* If the input is a positive number then compute the signBits. */ - if (number > 0) - { + if (number > 0) { signBits1 = __CLZ(number) - 1; /* Shift by the number of signBits1 */ - if ((signBits1 % 2) == 0) - { + if ((signBits1 % 2) == 0) { number = number << signBits1; - } - else - { + } else { number = number << (signBits1 - 1); } @@ -88,51 +82,54 @@ arm_status arm_sqrt_q31( tempconv.floatval = temp_float1; bits_val1 = tempconv.fracval; /* Subtract the shifted value from the magic number to give intial guess */ - bits_val1 = 0x5f3759df - (bits_val1 >> 1); /* gives initial guess */ + bits_val1 = 0x5f3759df - (bits_val1 >> 1); /* gives initial guess */ /* Store as float */ tempconv.fracval = bits_val1; temp_float1 = tempconv.floatval; /* Convert to integer format */ - var1 = (q31_t) (temp_float1 * 1073741824); + var1 = (q31_t)(temp_float1 * 1073741824); /* 1st iteration */ - var1 = ((q31_t) ((q63_t) var1 * (0x30000000 - - ((q31_t) - ((((q31_t) - (((q63_t) var1 * var1) >> 31)) * - (q63_t) half) >> 31))) >> 31)) << 2; + var1 = ((q31_t)((q63_t)var1 * + (0x30000000 - + ((q31_t)((((q31_t)(((q63_t)var1 * var1) >> 31)) * + (q63_t)half) >> + 31))) >> + 31)) + << 2; /* 2nd iteration */ - var1 = ((q31_t) ((q63_t) var1 * (0x30000000 - - ((q31_t) - ((((q31_t) - (((q63_t) var1 * var1) >> 31)) * - (q63_t) half) >> 31))) >> 31)) << 2; + var1 = ((q31_t)((q63_t)var1 * + (0x30000000 - + ((q31_t)((((q31_t)(((q63_t)var1 * var1) >> 31)) * + (q63_t)half) >> + 31))) >> + 31)) + << 2; /* 3rd iteration */ - var1 = ((q31_t) ((q63_t) var1 * (0x30000000 - - ((q31_t) - ((((q31_t) - (((q63_t) var1 * var1) >> 31)) * - (q63_t) half) >> 31))) >> 31)) << 2; + var1 = ((q31_t)((q63_t)var1 * + (0x30000000 - + ((q31_t)((((q31_t)(((q63_t)var1 * var1) >> 31)) * + (q63_t)half) >> + 31))) >> + 31)) + << 2; /* Multiply the inverse square root with the original value */ - var1 = ((q31_t) (((q63_t) temp1 * var1) >> 31)) << 1; + var1 = ((q31_t)(((q63_t)temp1 * var1) >> 31)) << 1; /* Shift the output down accordingly */ - if ((signBits1 % 2) == 0) - { + if ((signBits1 % 2) == 0) { var1 = var1 >> (signBits1 / 2); - } - else - { + } else { var1 = var1 >> ((signBits1 - 1) / 2); } *pOut = var1; return (ARM_MATH_SUCCESS); } - /* If the number is a negative number then store zero as its square root value */ - else - { + /* If the number is a negative number then store zero as its square root value + */ + else { *pOut = 0; return (ARM_MATH_ARGUMENT_ERROR); diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_32x64_init_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_32x64_init_q31.c index ac2313f..c44b5ca 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_32x64_init_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_32x64_init_q31.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df1_32x64_init_q31.c - * Description: High precision Q31 Biquad cascade filter initialization function + * Description: High precision Q31 Biquad cascade filter initialization + * function * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -38,41 +39,42 @@ */ /** - @brief Initialization function for the Q31 Biquad cascade 32x64 filter. - @param[in,out] S points to an instance of the high precision Q31 Biquad cascade filter structure + @brief Initialization function for the Q31 Biquad cascade 32x64 + filter. + @param[in,out] S points to an instance of the high precision Q31 + Biquad cascade filter structure @param[in] numStages number of 2nd order stages in the filter @param[in] pCoeffs points to the filter coefficients @param[in] pState points to the state buffer - @param[in] postShift Shift to be applied after the accumulator. Varies according to the coefficients format + @param[in] postShift Shift to be applied after the accumulator. Varies + according to the coefficients format @return none @par Coefficient and State Ordering - The coefficients are stored in the array pCoeffs in the following order: -
-      {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...}
+                   The coefficients are stored in the array pCoeffs
+  in the following order: 
 {b10, b11, b12, a11, a12, b20, b21, b22, a21,
+  a22, ...}
   
- where b1x and a1x are the coefficients for the first stage, - b2x and a2x are the coefficients for the second stage, - and so on. The pCoeffs array contains a total of 5*numStages values. + where b1x and a1x are the + coefficients for the first stage, b2x and a2x are + the coefficients for the second stage, and so on. The pCoeffs + array contains a total of 5*numStages values. @par - The pState points to state variables array and size of each state variable is 1.63 format. - Each Biquad stage has 4 state variables x[n-1], x[n-2], y[n-1], and y[n-2]. - The state variables are arranged in the state array as: -
-      {x[n-1], x[n-2], y[n-1], y[n-2]}
+                   The pState points to state variables array and
+  size of each state variable is 1.63 format. Each Biquad stage has 4 state
+  variables x[n-1], x[n-2], y[n-1], and y[n-2]. The
+  state variables are arranged in the state array as: 
 {x[n-1], x[n-2],
+  y[n-1], y[n-2]}
   
- The 4 state variables for stage 1 are first, then the 4 state variables for stage 2, and so on. - The state array has a total length of 4*numStages values. - The state variables are updated after each block of data is processed; the coefficients are untouched. + The 4 state variables for stage 1 are first, then the 4 state + variables for stage 2, and so on. The state array has a total length of + 4*numStages values. The state variables are updated after each + block of data is processed; the coefficients are untouched. */ -void arm_biquad_cas_df1_32x64_init_q31( - arm_biquad_cas_df1_32x64_ins_q31 * S, - uint8_t numStages, - const q31_t * pCoeffs, - q63_t * pState, - uint8_t postShift) -{ +void arm_biquad_cas_df1_32x64_init_q31(arm_biquad_cas_df1_32x64_ins_q31 *S, + uint8_t numStages, const q31_t *pCoeffs, + q63_t *pState, uint8_t postShift) { /* Assign filter stages */ S->numStages = numStages; @@ -83,7 +85,7 @@ void arm_biquad_cas_df1_32x64_init_q31( S->pCoeffs = pCoeffs; /* Clear state buffer and size is always 4 * numStages */ - memset(pState, 0, (4U * (uint32_t) numStages) * sizeof(q63_t)); + memset(pState, 0, (4U * (uint32_t)numStages) * sizeof(q63_t)); /* Assign state pointer */ S->pState = pState; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_32x64_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_32x64_q31.c index 9a284b8..2ad5b81 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_32x64_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_32x64_q31.c @@ -35,82 +35,93 @@ /** @defgroup BiquadCascadeDF1_32x64 High Precision Q31 Biquad Cascade Filter - This function implements a high precision Biquad cascade filter which operates on - Q31 data values. The filter coefficients are in 1.31 format and the state variables - are in 1.63 format. The double precision state variables reduce quantization noise - in the filter and provide a cleaner output. - These filters are particularly useful when implementing filters in which the - singularities are close to the unit circle. This is common for low pass or high - pass filters with very low cutoff frequencies. + This function implements a high precision Biquad cascade filter which operates + on Q31 data values. The filter coefficients are in 1.31 format and the state + variables are in 1.63 format. The double precision state variables reduce + quantization noise in the filter and provide a cleaner output. These filters + are particularly useful when implementing filters in which the singularities + are close to the unit circle. This is common for low pass or high pass + filters with very low cutoff frequencies. The function operates on blocks of input and output data and each call to the function processes blockSize samples through - the filter. pSrc and pDst points to input and output arrays - containing blockSize Q31 values. + the filter. pSrc and pDst points to input and output + arrays containing blockSize Q31 values. @par Algorithm - Each Biquad stage implements a second order filter using the difference equation: -
-      y[n] = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2]
+                   Each Biquad stage implements a second order filter using the
+  difference equation: 
 y[n] = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 *
+  y[n-1] + a2 * y[n-2]
   
- A Direct Form I algorithm is used with 5 coefficients and 4 state variables per stage. - \image html Biquad.gif "Single Biquad filter stage" - Coefficients b0, b1 and b2 multiply the input signal x[n] and are referred to as the feedforward coefficients. - Coefficients a1 and a2 multiply the output signal y[n] and are referred to as the feedback coefficients. - Pay careful attention to the sign of the feedback coefficients. + A Direct Form I algorithm is used with 5 coefficients and 4 + state variables per stage. \image html Biquad.gif "Single Biquad filter stage" + Coefficients b0, b1 and b2 multiply the input + signal x[n] and are referred to as the feedforward coefficients. + Coefficients a1 and a2 multiply the + output signal y[n] and are referred to as the feedback + coefficients. Pay careful attention to the sign of the feedback coefficients. Some design tools use the difference equation
       y[n] = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] - a1 * y[n-1] - a2 * y[n-2]
   
- In this case the feedback coefficients a1 and a2 must be negated when used with the CMSIS DSP Library. + In this case the feedback coefficients a1 and + a2 must be negated when used with the CMSIS DSP Library. @par - Higher order filters are realized as a cascade of second order sections. - numStages refers to the number of second order stages used. - For example, an 8th order filter would be realized with numStages=4 second order stages. - \image html BiquadCascade.gif "8th order filter using a cascade of Biquad stages" - A 9th order filter would be realized with numStages=5 second order stages - with the coefficients for one of the stages configured as a first order filter + Higher order filters are realized as a cascade of second + order sections. numStages refers to the number of second order + stages used. For example, an 8th order filter would be realized with + numStages=4 second order stages. \image html BiquadCascade.gif + "8th order filter using a cascade of Biquad stages" A 9th order filter would + be realized with numStages=5 second order stages with the + coefficients for one of the stages configured as a first order filter (b2=0 and a2=0). @par The pState points to state variables array. - Each Biquad stage has 4 state variables x[n-1], x[n-2], y[n-1], and y[n-2] and each state variable in 1.63 format to improve precision. - The state variables are arranged in the array as: -
+                   Each Biquad stage has 4 state variables x[n-1], x[n-2],
+  y[n-1], and y[n-2] and each state variable in 1.63 format
+  to improve precision. The state variables are arranged in the array as: 
       {x[n-1], x[n-2], y[n-1], y[n-2]}
   
@par - The 4 state variables for stage 1 are first, then the 4 state variables for stage 2, and so on. - The state array has a total length of 4*numStages values of data in 1.63 format. - The state variables are updated after each block of data is processed, the coefficients are untouched. + The 4 state variables for stage 1 are first, then the 4 state + variables for stage 2, and so on. The state array has a total length of + 4*numStages values of data in 1.63 format. The state variables + are updated after each block of data is processed, the coefficients are + untouched. @par Instance Structure - The coefficients and state variables for a filter are stored together in an instance data structure. - A separate instance structure must be defined for each filter. - Coefficient arrays may be shared among several instances while state variable arrays cannot be shared. + The coefficients and state variables for a filter are stored + together in an instance data structure. A separate instance structure must be + defined for each filter. Coefficient arrays may be shared among several + instances while state variable arrays cannot be shared. @par Init Function - There is also an associated initialization function which performs the following operations: + There is also an associated initialization function which + performs the following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. - To do this manually without calling the init function, assign the follow subfields of the instance structure: - numStages, pCoeffs, postShift, pState. Also set all of the values in pState to zero. + To do this manually without calling the init function, assign + the follow subfields of the instance structure: numStages, pCoeffs, postShift, + pState. Also set all of the values in pState to zero. @par Use of the initialization function is optional. - However, if the initialization function is used, then the instance structure cannot be placed into a const data section. - To place an instance structure into a const data section, the instance structure must be manually initialized. - Set the values in the state buffer to zeros before static initialization. - For example, to statically initialize the filter instance structure use -
-      arm_biquad_cas_df1_32x64_ins_q31 S1 = {numStages, pState, pCoeffs, postShift};
+                   However, if the initialization function is used, then the
+  instance structure cannot be placed into a const data section. To place an
+  instance structure into a const data section, the instance structure must be
+  manually initialized. Set the values in the state buffer to zeros before
+  static initialization. For example, to statically initialize the filter
+  instance structure use 
 arm_biquad_cas_df1_32x64_ins_q31 S1 = {numStages,
+  pState, pCoeffs, postShift};
   
- where numStages is the number of Biquad stages in the filter; - pState is the address of the state buffer; - pCoeffs is the address of the coefficient buffer; - postShift shift to be applied which is described in detail below. + where numStages is the number of Biquad stages + in the filter; pState is the address of the state buffer; + pCoeffs is the address of the coefficient + buffer; postShift shift to be applied which is described in + detail below. @par Fixed-Point Behavior - Care must be taken while using Biquad Cascade 32x64 filter function. - Following issues must be considered: + Care must be taken while using Biquad Cascade 32x64 filter + function. Following issues must be considered: - Scaling of coefficients - Filter gain - Overflow and saturation @@ -118,14 +129,14 @@ @par Filter coefficients are represented as fractional values and restricted to lie in the range [-1 +1). - The processing function has an additional scaling parameter postShift - which allows the filter coefficients to exceed the range [+1 -1). - At the output of the filter's accumulator is a shift register which shifts the result by postShift bits. - \image html BiquadPostshift.gif "Fixed-point Biquad with shift by postShift bits after accumulator" - This essentially scales the filter coefficients by 2^postShift. - For example, to realize the coefficients -
-     {1.5, -0.8, 1.2, 1.6, -0.9}
+                   The processing function has an additional scaling parameter
+  postShift which allows the filter coefficients to exceed the
+  range [+1 -1). At the output of the filter's accumulator is a
+  shift register which shifts the result by postShift bits. \image
+  html BiquadPostshift.gif "Fixed-point Biquad with shift by postShift bits
+  after accumulator" This essentially scales the filter coefficients by
+  2^postShift. For example, to realize the coefficients 
 {1.5,
+  -0.8, 1.2, 1.6, -0.9}
   
set the Coefficient array to:
@@ -133,17 +144,19 @@
   
and set postShift=1 @par - The second thing to keep in mind is the gain through the filter. - The frequency response of a Biquad filter is a function of its coefficients. - It is possible for the gain through the filter to exceed 1.0 meaning that the - filter increases the amplitude of certain frequencies. - This means that an input signal with amplitude < 1.0 may result in an output > 1.0 - and these are saturated or overflowed based on the implementation of the filter. - To avoid this behavior the filter needs to be scaled down such that its peak gain < 1.0 - or the input signal must be scaled down so that the combination of input and filter are never overflowed. + The second thing to keep in mind is the gain through the + filter. The frequency response of a Biquad filter is a function of its + coefficients. It is possible for the gain through the filter to exceed 1.0 + meaning that the filter increases the amplitude of certain frequencies. This + means that an input signal with amplitude < 1.0 may result in an output > 1.0 + and these are saturated or overflowed based on the + implementation of the filter. To avoid this behavior the filter needs to be + scaled down such that its peak gain < 1.0 or the input signal must be scaled + down so that the combination of input and filter are never overflowed. @par - The third item to consider is the overflow and saturation behavior of the fixed-point Q31 version. - This is described in the function specific documentation below. + The third item to consider is the overflow and saturation + behavior of the fixed-point Q31 version. This is described in the function + specific documentation below. */ /** @@ -153,48 +166,51 @@ /** @brief Processing function for the Q31 Biquad cascade 32x64 filter. - @param[in] S points to an instance of the high precision Q31 Biquad cascade filter + @param[in] S points to an instance of the high precision Q31 + Biquad cascade filter @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Details - The function is implemented using an internal 64-bit accumulator. - The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. - Thus, if the accumulator result overflows it wraps around rather than clip. - In order to avoid overflows completely the input signal must be scaled down by 2 bits and lie in the range [-0.25 +0.25). - After all 5 multiply-accumulates are performed, the 2.62 accumulator is shifted by postShift bits and the result truncated to - 1.31 format by discarding the low 32 bits. + The function is implemented using an internal 64-bit + accumulator. The accumulator has a 2.62 format and maintains full precision of + the intermediate multiplication results but provides only a single guard bit. + Thus, if the accumulator result overflows it wraps around + rather than clip. In order to avoid overflows completely the input signal must + be scaled down by 2 bits and lie in the range [-0.25 +0.25). After all 5 + multiply-accumulates are performed, the 2.62 accumulator is shifted by + postShift bits and the result truncated to 1.31 format by + discarding the low 32 bits. @par Two related functions are provided in the CMSIS DSP library. - - \ref arm_biquad_cascade_df1_q31() implements a Biquad cascade with 32-bit coefficients and state variables with a Q63 accumulator. - - \ref arm_biquad_cascade_df1_fast_q31() implements a Biquad cascade with 32-bit coefficients and state variables with a Q31 accumulator. + - \ref arm_biquad_cascade_df1_q31() implements a Biquad + cascade with 32-bit coefficients and state variables with a Q63 accumulator. + - \ref arm_biquad_cascade_df1_fast_q31() implements a Biquad + cascade with 32-bit coefficients and state variables with a Q31 accumulator. */ -void arm_biquad_cas_df1_32x64_q31( - const arm_biquad_cas_df1_32x64_ins_q31 * S, - q31_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - q31_t *pIn = pSrc; /* input pointer initialization */ - q31_t *pOut = pDst; /* output pointer initialization */ - q63_t *pState = S->pState; /* state pointer initialization */ - const q31_t *pCoeffs = S->pCoeffs; /* coeff pointer initialization */ - q63_t acc; /* accumulator */ - q31_t Xn1, Xn2; /* Input Filter state variables */ - q63_t Yn1, Yn2; /* Output Filter state variables */ - q31_t b0, b1, b2, a1, a2; /* Filter coefficients */ - q31_t Xn; /* temporary input */ - int32_t shift = (int32_t) S->postShift + 1; /* Shift to be applied to the output */ - uint32_t sample, stage = S->numStages; /* loop counters */ - q31_t acc_l, acc_h; /* temporary output */ - uint32_t uShift = ((uint32_t) S->postShift + 1U); - uint32_t lShift = 32U - uShift; /* Shift to be applied to the output */ +void arm_biquad_cas_df1_32x64_q31(const arm_biquad_cas_df1_32x64_ins_q31 *S, + q31_t *pSrc, q31_t *pDst, + uint32_t blockSize) { + q31_t *pIn = pSrc; /* input pointer initialization */ + q31_t *pOut = pDst; /* output pointer initialization */ + q63_t *pState = S->pState; /* state pointer initialization */ + const q31_t *pCoeffs = S->pCoeffs; /* coeff pointer initialization */ + q63_t acc; /* accumulator */ + q31_t Xn1, Xn2; /* Input Filter state variables */ + q63_t Yn1, Yn2; /* Output Filter state variables */ + q31_t b0, b1, b2, a1, a2; /* Filter coefficients */ + q31_t Xn; /* temporary input */ + int32_t shift = + (int32_t)S->postShift + 1; /* Shift to be applied to the output */ + uint32_t sample, stage = S->numStages; /* loop counters */ + q31_t acc_l, acc_h; /* temporary output */ + uint32_t uShift = ((uint32_t)S->postShift + 1U); + uint32_t lShift = 32U - uShift; /* Shift to be applied to the output */ - do - { + do { /* Reading the coefficients */ b0 = *pCoeffs++; b1 = *pCoeffs++; @@ -203,36 +219,37 @@ void arm_biquad_cas_df1_32x64_q31( a2 = *pCoeffs++; /* Reading the state values */ - Xn1 = (q31_t) (pState[0]); - Xn2 = (q31_t) (pState[1]); + Xn1 = (q31_t)(pState[0]); + Xn2 = (q31_t)(pState[1]); Yn1 = pState[2]; Yn2 = pState[3]; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Apply loop unrolling and compute 4 output values simultaneously. */ - /* Variable acc hold output value that is being computed and stored in destination buffer - * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] + /* Variable acc hold output value that is being computed and stored in + * destination buffer acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * + * y[n-1] + a2 * y[n-2] */ /* Loop unrolling: Compute 4 outputs at a time */ sample = blockSize >> 2U; - while (sample > 0U) - { + while (sample > 0U) { /* Read the input */ Xn = *pIn++; - /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ + /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * + * y[n-2] */ /* acc = b0 * x[n] */ - acc = (q63_t) Xn * b0; + acc = (q63_t)Xn * b0; /* acc += b1 * x[n-1] */ - acc += (q63_t) Xn1 * b1; + acc += (q63_t)Xn1 * b1; /* acc += b[2] * x[n-2] */ - acc += (q63_t) Xn2 * b2; + acc += (q63_t)Xn2 * b2; /* acc += a1 * y[n-1] */ acc += mult32x64(Yn1, a1); @@ -250,7 +267,7 @@ void arm_biquad_cas_df1_32x64_q31( acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ - acc_h = (uint32_t) acc_l >> lShift | acc_h << uShift; + acc_h = (uint32_t)acc_l >> lShift | acc_h << uShift; /* Store the output in the destination buffer in 1.31 format. */ *pOut = acc_h; @@ -258,16 +275,17 @@ void arm_biquad_cas_df1_32x64_q31( /* Read the second input into Xn2, to reuse the value */ Xn2 = *pIn++; - /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ + /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * + * y[n-2] */ /* acc += b1 * x[n-1] */ - acc = (q63_t) Xn * b1; + acc = (q63_t)Xn * b1; /* acc = b0 * x[n] */ - acc += (q63_t) Xn2 * b0; + acc += (q63_t)Xn2 * b0; /* acc += b[2] * x[n-2] */ - acc += (q63_t) Xn1 * b2; + acc += (q63_t)Xn1 * b2; /* acc += a1 * y[n-1] */ acc += mult32x64(Yn2, a1); @@ -285,7 +303,7 @@ void arm_biquad_cas_df1_32x64_q31( acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ - acc_h = (uint32_t) acc_l >> lShift | acc_h << uShift; + acc_h = (uint32_t)acc_l >> lShift | acc_h << uShift; /* Read the third input into Xn1, to reuse the value */ Xn1 = *pIn++; @@ -294,16 +312,17 @@ void arm_biquad_cas_df1_32x64_q31( /* Store the output in the destination buffer. */ *(pOut + 1U) = acc_h; - /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ + /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * + * y[n-2] */ /* acc = b0 * x[n] */ - acc = (q63_t) Xn1 * b0; + acc = (q63_t)Xn1 * b0; /* acc += b1 * x[n-1] */ - acc += (q63_t) Xn2 * b1; + acc += (q63_t)Xn2 * b1; /* acc += b[2] * x[n-2] */ - acc += (q63_t) Xn * b2; + acc += (q63_t)Xn * b2; /* acc += a1 * y[n-1] */ acc += mult32x64(Yn1, a1); @@ -321,7 +340,7 @@ void arm_biquad_cas_df1_32x64_q31( acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ - acc_h = (uint32_t) acc_l >> lShift | acc_h << uShift; + acc_h = (uint32_t)acc_l >> lShift | acc_h << uShift; /* Store the output in the destination buffer in 1.31 format. */ *(pOut + 2U) = acc_h; @@ -329,15 +348,16 @@ void arm_biquad_cas_df1_32x64_q31( /* Read the fourth input into Xn, to reuse the value */ Xn = *pIn++; - /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ + /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * + * y[n-2] */ /* acc = b0 * x[n] */ - acc = (q63_t) Xn * b0; + acc = (q63_t)Xn * b0; /* acc += b1 * x[n-1] */ - acc += (q63_t) Xn1 * b1; + acc += (q63_t)Xn1 * b1; /* acc += b[2] * x[n-2] */ - acc += (q63_t) Xn2 * b2; + acc += (q63_t)Xn2 * b2; /* acc += a1 * y[n-1] */ acc += mult32x64(Yn2, a1); @@ -355,7 +375,7 @@ void arm_biquad_cas_df1_32x64_q31( acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ - acc_h = (uint32_t) acc_l >> lShift | acc_h << uShift; + acc_h = (uint32_t)acc_l >> lShift | acc_h << uShift; /* Store the output in the destination buffer in 1.31 format. */ *(pOut + 3U) = acc_h; @@ -386,19 +406,19 @@ void arm_biquad_cas_df1_32x64_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (sample > 0U) - { + while (sample > 0U) { /* Read the input */ Xn = *pIn++; - /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ + /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * + * y[n-2] */ /* acc = b0 * x[n] */ - acc = (q63_t) Xn * b0; + acc = (q63_t)Xn * b0; /* acc += b1 * x[n-1] */ - acc += (q63_t) Xn1 * b1; + acc += (q63_t)Xn1 * b1; /* acc += b[2] * x[n-2] */ - acc += (q63_t) Xn2 * b2; + acc += (q63_t)Xn2 * b2; /* acc += a1 * y[n-1] */ acc += mult32x64(Yn1, a1); /* acc += a2 * y[n-2] */ @@ -424,14 +444,14 @@ void arm_biquad_cas_df1_32x64_q31( acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ - acc_h = (uint32_t) acc_l >> lShift | acc_h << uShift; + acc_h = (uint32_t)acc_l >> lShift | acc_h << uShift; /* Store the output in the destination buffer in 1.31 format. */ *pOut++ = acc_h; /* Yn1 = acc << shift; */ /* Store the output in the destination buffer in 1.31 format. */ -/* *pOut++ = (q31_t) (acc >> (32 - shift)); */ + /* *pOut++ = (q31_t) (acc >> (32 - shift)); */ /* decrement loop counter */ sample--; @@ -444,13 +464,12 @@ void arm_biquad_cas_df1_32x64_q31( pOut = pDst; /* Store the updated state variables back into the pState array */ - *pState++ = (q63_t) Xn1; - *pState++ = (q63_t) Xn2; + *pState++ = (q63_t)Xn1; + *pState++ = (q63_t)Xn2; *pState++ = Yn1; *pState++ = Yn2; } while (--stage); - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_f32.c index 79571a1..7b3a52a 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_f32.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df1_f32.c - * Description: Processing function for the floating-point Biquad cascade DirectFormI(DF1) filter + * Description: Processing function for the floating-point Biquad cascade + * DirectFormI(DF1) filter * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -33,104 +34,113 @@ */ /** - @defgroup BiquadCascadeDF1 Biquad Cascade IIR Filters Using Direct Form I Structure + @defgroup BiquadCascadeDF1 Biquad Cascade IIR Filters Using Direct Form I + Structure This set of functions implements arbitrary order recursive (IIR) filters. The filters are implemented as a cascade of second order Biquad sections. The functions support Q15, Q31 and floating-point data types. Fast version of Q15 and Q31 also available. - The functions operate on blocks of input and output data and each call to the function - processes blockSize samples through the filter. + The functions operate on blocks of input and output data and each call to the + function processes blockSize samples through the filter. pSrc points to the array of input data and pDst points to the array of output data. Both arrays contain blockSize values. @par Algorithm - Each Biquad stage implements a second order filter using the difference equation: -
-      y[n] = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2]
+                   Each Biquad stage implements a second order filter using the
+  difference equation: 
 y[n] = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 *
+  y[n-1] + a2 * y[n-2]
   
- A Direct Form I algorithm is used with 5 coefficients and 4 state variables per stage. - \image html Biquad.gif "Single Biquad filter stage" - Coefficients b0, b1 and b2 multiply the input signal x[n] and are referred to as the feedforward coefficients. - Coefficients a1 and a2 multiply the output signal y[n] and are referred to as the feedback coefficients. - Pay careful attention to the sign of the feedback coefficients. + A Direct Form I algorithm is used with 5 coefficients and 4 + state variables per stage. \image html Biquad.gif "Single Biquad filter stage" + Coefficients b0, b1 and b2 multiply the input + signal x[n] and are referred to as the feedforward coefficients. + Coefficients a1 and a2 multiply the + output signal y[n] and are referred to as the feedback + coefficients. Pay careful attention to the sign of the feedback coefficients. Some design tools use the difference equation
       y[n] = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] - a1 * y[n-1] - a2 * y[n-2]
   
- In this case the feedback coefficients a1 and a2 - must be negated when used with the CMSIS DSP Library. + In this case the feedback coefficients a1 and + a2 must be negated when used with the CMSIS DSP Library. @par - Higher order filters are realized as a cascade of second order sections. - numStages refers to the number of second order stages used. - For example, an 8th order filter would be realized with numStages=4 second order stages. - \image html BiquadCascade.gif "8th order filter using a cascade of Biquad stages" - A 9th order filter would be realized with numStages=5 second order stages with the coefficients for one of the stages configured as a first order filter (b2=0 and a2=0). + Higher order filters are realized as a cascade of second + order sections. numStages refers to the number of second order + stages used. For example, an 8th order filter would be realized with + numStages=4 second order stages. \image html BiquadCascade.gif + "8th order filter using a cascade of Biquad stages" A 9th order filter would + be realized with numStages=5 second order stages with the + coefficients for one of the stages configured as a first order filter + (b2=0 and a2=0). @par The pState points to state variables array. - Each Biquad stage has 4 state variables x[n-1], x[n-2], y[n-1], and y[n-2]. - The state variables are arranged in the pState array as: -
-      {x[n-1], x[n-2], y[n-1], y[n-2]}
+                   Each Biquad stage has 4 state variables x[n-1], x[n-2],
+  y[n-1], and y[n-2]. The state variables are arranged in
+  the pState array as: 
 {x[n-1], x[n-2], y[n-1], y[n-2]}
   
@par - The 4 state variables for stage 1 are first, then the 4 state variables for stage 2, and so on. - The state array has a total length of 4*numStages values. - The state variables are updated after each block of data is processed, the coefficients are untouched. + The 4 state variables for stage 1 are first, then the 4 state + variables for stage 2, and so on. The state array has a total length of + 4*numStages values. The state variables are updated after each + block of data is processed, the coefficients are untouched. @par Instance Structure - The coefficients and state variables for a filter are stored together in an instance data structure. - A separate instance structure must be defined for each filter. - Coefficient arrays may be shared among several instances while state variable arrays cannot be shared. - There are separate instance structure declarations for each of the 3 supported data types. + The coefficients and state variables for a filter are stored + together in an instance data structure. A separate instance structure must be + defined for each filter. Coefficient arrays may be shared among several + instances while state variable arrays cannot be shared. There are separate + instance structure declarations for each of the 3 supported data types. @par Init Function - There is also an associated initialization function for each data type. - The initialization function performs following operations: + There is also an associated initialization function for each + data type. The initialization function performs following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. - To do this manually without calling the init function, assign the follow subfields of the instance structure: - numStages, pCoeffs, pState. Also set all of the values in pState to zero. + To do this manually without calling the init function, assign + the follow subfields of the instance structure: numStages, pCoeffs, pState. + Also set all of the values in pState to zero. @par Use of the initialization function is optional. - However, if the initialization function is used, then the instance structure cannot be placed into a const data section. - To place an instance structure into a const data section, the instance structure must be manually initialized. - Set the values in the state buffer to zeros before static initialization. - The code below statically initializes each of the 3 different data type filter instance structures -
+                   However, if the initialization function is used, then the
+  instance structure cannot be placed into a const data section. To place an
+  instance structure into a const data section, the instance structure must be
+  manually initialized. Set the values in the state buffer to zeros before
+  static initialization. The code below statically initializes each of the 3
+  different data type filter instance structures 
       arm_biquad_casd_df1_inst_f32 S1 = {numStages, pState, pCoeffs};
       arm_biquad_casd_df1_inst_q15 S2 = {numStages, pState, pCoeffs, postShift};
       arm_biquad_casd_df1_inst_q31 S3 = {numStages, pState, pCoeffs, postShift};
   
- where numStages is the number of Biquad stages in the filter; - pState is the address of the state buffer; - pCoeffs is the address of the coefficient buffer; - postShift shift to be applied. + where numStages is the number of Biquad stages + in the filter; pState is the address of the state buffer; + pCoeffs is the address of the coefficient + buffer; postShift shift to be applied. @par Fixed-Point Behavior - Care must be taken when using the Q15 and Q31 versions of the Biquad Cascade filter functions. - Following issues must be considered: + Care must be taken when using the Q15 and Q31 versions of the + Biquad Cascade filter functions. Following issues must be considered: - Scaling of coefficients - Filter gain - Overflow and saturation @par Scaling of coefficients Filter coefficients are represented as fractional values and - coefficients are restricted to lie in the range [-1 +1). - The fixed-point functions have an additional scaling parameter postShift - which allow the filter coefficients to exceed the range [+1 -1). - At the output of the filter's accumulator is a shift register which shifts the result by postShift bits. - \image html BiquadPostshift.gif "Fixed-point Biquad with shift by postShift bits after accumulator" - This essentially scales the filter coefficients by 2^postShift. - For example, to realize the coefficients -
-     {1.5, -0.8, 1.2, 1.6, -0.9}
+                   coefficients are restricted to lie in the range [-1
+  +1). The fixed-point functions have an additional scaling parameter
+  postShift which allow the filter coefficients to exceed the range
+  [+1 -1). At the output of the filter's accumulator is a shift
+  register which shifts the result by postShift bits. \image html
+  BiquadPostshift.gif "Fixed-point Biquad with shift by postShift bits after
+  accumulator" This essentially scales the filter coefficients by
+  2^postShift. For example, to realize the coefficients 
 {1.5,
+  -0.8, 1.2, 1.6, -0.9}
   
set the pCoeffs array to:
@@ -139,13 +149,18 @@
                    and set postShift=1
 
   @par           Filter gain
-                   The frequency response of a Biquad filter is a function of its coefficients.
-                   It is possible for the gain through the filter to exceed 1.0 meaning that the filter increases the amplitude of certain frequencies.
-                   This means that an input signal with amplitude < 1.0 may result in an output > 1.0 and these are saturated or overflowed based on the implementation of the filter.
-                   To avoid this behavior the filter needs to be scaled down such that its peak gain < 1.0 or the input signal must be scaled down so that the combination of input and filter are never overflowed.
+                   The frequency response of a Biquad filter is a function of
+  its coefficients. It is possible for the gain through the filter to exceed 1.0
+  meaning that the filter increases the amplitude of certain frequencies. This
+  means that an input signal with amplitude < 1.0 may result in an output > 1.0
+  and these are saturated or overflowed based on the implementation of the
+  filter. To avoid this behavior the filter needs to be scaled down such that
+  its peak gain < 1.0 or the input signal must be scaled down so that the
+  combination of input and filter are never overflowed.
 
   @par           Overflow and saturation
-                   For Q15 and Q31 versions, it is described separately as part of the function specific documentation below.
+                   For Q15 and Q31 versions, it is described separately as part
+  of the function specific documentation below.
  */
 
 /**
@@ -154,32 +169,30 @@
  */
 
 /**
-  @brief         Processing function for the floating-point Biquad cascade filter.
-  @param[in]     S         points to an instance of the floating-point Biquad cascade structure
+  @brief         Processing function for the floating-point Biquad cascade
+  filter.
+  @param[in]     S         points to an instance of the floating-point Biquad
+  cascade structure
   @param[in]     pSrc      points to the block of input data
   @param[out]    pDst      points to the block of output data
   @param[in]     blockSize  number of samples to process
   @return        none
  */
 
-void arm_biquad_cascade_df1_f32(
-  const arm_biquad_casd_df1_inst_f32 * S,
-  const float32_t * pSrc,
-        float32_t * pDst,
-        uint32_t blockSize)
-{
-  const float32_t *pIn = pSrc;                         /* Source pointer */
-        float32_t *pOut = pDst;                        /* Destination pointer */
-        float32_t *pState = S->pState;                 /* pState pointer */
-  const float32_t *pCoeffs = S->pCoeffs;               /* Coefficient pointer */
-        float32_t acc;                                 /* Accumulator */
-        float32_t b0, b1, b2, a1, a2;                  /* Filter coefficients */
-        float32_t Xn1, Xn2, Yn1, Yn2;                  /* Filter pState variables */
-        float32_t Xn;                                  /* Temporary input */
-        uint32_t sample, stage = S->numStages;         /* Loop counters */
+void arm_biquad_cascade_df1_f32(const arm_biquad_casd_df1_inst_f32 *S,
+                                const float32_t *pSrc, float32_t *pDst,
+                                uint32_t blockSize) {
+  const float32_t *pIn = pSrc;           /* Source pointer */
+  float32_t *pOut = pDst;                /* Destination pointer */
+  float32_t *pState = S->pState;         /* pState pointer */
+  const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */
+  float32_t acc;                         /* Accumulator */
+  float32_t b0, b1, b2, a1, a2;          /* Filter coefficients */
+  float32_t Xn1, Xn2, Yn1, Yn2;          /* Filter pState variables */
+  float32_t Xn;                          /* Temporary input */
+  uint32_t sample, stage = S->numStages; /* Loop counters */
 
-  do
-  {
+  do {
     /* Reading the coefficients */
     b0 = *pCoeffs++;
     b1 = *pCoeffs++;
@@ -193,7 +206,7 @@ void arm_biquad_cascade_df1_f32(
     Yn1 = pState[2];
     Yn2 = pState[3];
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
     /* Apply loop unrolling and compute 4 output values simultaneously. */
     /* Variable acc hold output values that are being computed:
@@ -207,12 +220,12 @@ void arm_biquad_cascade_df1_f32(
     /* Loop unrolling: Compute 4 outputs at a time */
     sample = blockSize >> 2U;
 
-    while (sample > 0U)
-    {
+    while (sample > 0U) {
       /* Read the first input */
       Xn = *pIn++;
 
-      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */
+      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 *
+       * y[n-2] */
       Yn2 = (b0 * Xn) + (b1 * Xn1) + (b2 * Xn2) + (a1 * Yn1) + (a2 * Yn2);
 
       /* Store output in destination buffer. */
@@ -228,7 +241,8 @@ void arm_biquad_cascade_df1_f32(
       /* Read the second input */
       Xn2 = *pIn++;
 
-      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */
+      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 *
+       * y[n-2] */
       Yn1 = (b0 * Xn2) + (b1 * Xn) + (b2 * Xn1) + (a1 * Yn2) + (a2 * Yn1);
 
       /* Store output in destination buffer. */
@@ -244,7 +258,8 @@ void arm_biquad_cascade_df1_f32(
       /* Read the third input */
       Xn1 = *pIn++;
 
-      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */
+      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 *
+       * y[n-2] */
       Yn2 = (b0 * Xn1) + (b1 * Xn2) + (b2 * Xn) + (a1 * Yn1) + (a2 * Yn2);
 
       /* Store output in destination buffer. */
@@ -260,7 +275,8 @@ void arm_biquad_cascade_df1_f32(
       /* Read the forth input */
       Xn = *pIn++;
 
-      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */
+      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 *
+       * y[n-2] */
       Yn1 = (b0 * Xn) + (b1 * Xn1) + (b2 * Xn2) + (a1 * Yn2) + (a2 * Yn1);
 
       /* Store output in destination buffer. */
@@ -289,12 +305,12 @@ void arm_biquad_cascade_df1_f32(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-    while (sample > 0U)
-    {
+    while (sample > 0U) {
       /* Read the input */
       Xn = *pIn++;
 
-      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */
+      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 *
+       * y[n-2] */
       acc = (b0 * Xn) + (b1 * Xn1) + (b2 * Xn2) + (a1 * Yn1) + (a2 * Yn2);
 
       /* Store output in destination buffer. */
@@ -332,7 +348,6 @@ void arm_biquad_cascade_df1_f32(
     stage--;
 
   } while (stage > 0U);
-
 }
 
 /**
diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_fast_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_fast_q15.c
index 1a568d7..30b4718 100644
--- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_fast_q15.c
+++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_fast_q15.c
@@ -38,8 +38,10 @@
  */
 
 /**
-  @brief         Processing function for the Q15 Biquad cascade filter (fast variant).
-  @param[in]     S         points to an instance of the Q15 Biquad cascade structure
+  @brief         Processing function for the Q15 Biquad cascade filter (fast
+ variant).
+  @param[in]     S         points to an instance of the Q15 Biquad cascade
+ structure
   @param[in]     pSrc      points to the block of input data
   @param[out]    pDst      points to the block of output data
   @param[in]     blockSize number of samples to process per call
@@ -47,53 +49,54 @@
 
   @par           Scaling and Overflow Behavior
                    This fast version uses a 32-bit accumulator with 2.30 format.
-                   The accumulator maintains full precision of the intermediate multiplication results but provides only a single guard bit.
-                   Thus, if the accumulator result overflows it wraps around and distorts the result.
-                   In order to avoid overflows completely the input signal must be scaled down by two bits and lie in the range [-0.25 +0.25).
-                   The 2.30 accumulator is then shifted by postShift bits and the result truncated to 1.15 format by discarding the low 16 bits.
+                   The accumulator maintains full precision of the intermediate
+ multiplication results but provides only a single guard bit. Thus, if the
+ accumulator result overflows it wraps around and distorts the result. In order
+ to avoid overflows completely the input signal must be scaled down by two bits
+ and lie in the range [-0.25 +0.25). The 2.30 accumulator is then shifted by
+ postShift bits and the result truncated to 1.15 format by
+ discarding the low 16 bits.
  @remark
-                   Refer to \ref arm_biquad_cascade_df1_q15() for a slower implementation of this function
-                   which uses 64-bit accumulation to avoid wrap around distortion. Both the slow and the fast versions use the same instance structure.
-                   Use the function \ref arm_biquad_cascade_df1_init_q15() to initialize the filter structure.
+                   Refer to \ref arm_biquad_cascade_df1_q15() for a slower
+ implementation of this function which uses 64-bit accumulation to avoid wrap
+ around distortion. Both the slow and the fast versions use the same instance
+ structure. Use the function \ref arm_biquad_cascade_df1_init_q15() to
+ initialize the filter structure.
  */
 
-void arm_biquad_cascade_df1_fast_q15(
-  const arm_biquad_casd_df1_inst_q15 * S,
-  const q15_t * pSrc,
-        q15_t * pDst,
-        uint32_t blockSize)
-{
-  const q15_t *pIn = pSrc;                             /* Source pointer */
-        q15_t *pOut = pDst;                            /* Destination pointer */
-        q15_t *pState = S->pState;                     /* State pointer */
-  const q15_t *pCoeffs = S->pCoeffs;                   /* Coefficient pointer */
-        q31_t acc;                                     /* Accumulator */
-        q31_t in;                                      /* Temporary variable to hold input value */
-        q31_t out;                                     /* Temporary variable to hold output value */
-        q31_t b0;                                      /* Temporary variable to hold bo value */
-        q31_t b1, a1;                                  /* Filter coefficients */
-        q31_t state_in, state_out;                     /* Filter state variables */
-        int32_t shift = (int32_t) (15 - S->postShift); /* Post shift */
-        uint32_t sample, stage = S->numStages;         /* Loop counters */
+void arm_biquad_cascade_df1_fast_q15(const arm_biquad_casd_df1_inst_q15 *S,
+                                     const q15_t *pSrc, q15_t *pDst,
+                                     uint32_t blockSize) {
+  const q15_t *pIn = pSrc;           /* Source pointer */
+  q15_t *pOut = pDst;                /* Destination pointer */
+  q15_t *pState = S->pState;         /* State pointer */
+  const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */
+  q31_t acc;                         /* Accumulator */
+  q31_t in;                  /* Temporary variable to hold input value */
+  q31_t out;                 /* Temporary variable to hold output value */
+  q31_t b0;                  /* Temporary variable to hold bo value */
+  q31_t b1, a1;              /* Filter coefficients */
+  q31_t state_in, state_out; /* Filter state variables */
+  int32_t shift = (int32_t)(15 - S->postShift); /* Post shift */
+  uint32_t sample, stage = S->numStages;        /* Loop counters */
 
-  do
-  {
+  do {
     /* Read the b0 and 0 coefficients using SIMD  */
-    b0 = read_q15x2_ia ((q15_t **) &pCoeffs);
+    b0 = read_q15x2_ia((q15_t **)&pCoeffs);
 
     /* Read the b1 and b2 coefficients using SIMD */
-    b1 = read_q15x2_ia ((q15_t **) &pCoeffs);
+    b1 = read_q15x2_ia((q15_t **)&pCoeffs);
 
     /* Read the a1 and a2 coefficients using SIMD */
-    a1 = read_q15x2_ia ((q15_t **) &pCoeffs);
+    a1 = read_q15x2_ia((q15_t **)&pCoeffs);
 
     /* Read the input state values from the state buffer:  x[n-1], x[n-2] */
-    state_in = read_q15x2_ia (&pState);
+    state_in = read_q15x2_ia(&pState);
 
     /* Read the output state values from the state buffer:  y[n-1], y[n-2] */
-    state_out = read_q15x2_da (&pState);
+    state_out = read_q15x2_da(&pState);
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
     /* Apply loop unrolling and compute 2 output values simultaneously. */
     /* Variable acc hold output values that are being computed:
@@ -105,11 +108,10 @@ void arm_biquad_cascade_df1_fast_q15(
     /* Loop unrolling: Compute 2 outputs at a time */
     sample = blockSize >> 1U;
 
-    while (sample > 0U)
-    {
+    while (sample > 0U) {
 
       /* Read the input */
-      in = read_q15x2_ia ((q15_t **) &pIn);
+      in = read_q15x2_ia((q15_t **)&pIn);
 
       /* out =  b0 * x[n] + 0 * 0 */
       out = __SMUAD(b0, in);
@@ -118,7 +120,8 @@ void arm_biquad_cascade_df1_fast_q15(
       /* acc +=  a1 * y[n-1] + acc +=  a2 * y[n-2] */
       acc = __SMLAD(a1, state_out, acc);
 
-      /* The result is converted from 3.29 to 1.31 and then saturation is applied */
+      /* The result is converted from 3.29 to 1.31 and then saturation is
+       * applied */
       out = __SSAT((acc >> shift), 16);
 
       /* Every time after the output is computed state should be updated. */
@@ -130,11 +133,11 @@ void arm_biquad_cascade_df1_fast_q15(
       /* x[n-N], x[n-N-1] are packed together to make state_in of type q31 */
       /* y[n-N], y[n-N-1] are packed together to make state_out of type q31 */
 
-#ifndef  ARM_MATH_BIG_ENDIAN
-      state_in  = __PKHBT(in, state_in, 16);
+#ifndef ARM_MATH_BIG_ENDIAN
+      state_in = __PKHBT(in, state_in, 16);
       state_out = __PKHBT(out, state_out, 16);
 #else
-      state_in  = __PKHBT(state_in >> 16, (in >> 16), 16);
+      state_in = __PKHBT(state_in >> 16, (in >> 16), 16);
       state_out = __PKHBT(state_out >> 16, (out), 16);
 #endif /* #ifndef  ARM_MATH_BIG_ENDIAN */
 
@@ -145,14 +148,15 @@ void arm_biquad_cascade_df1_fast_q15(
       /* acc +=  a1 * y[n-1] + acc +=  a2 * y[n-2] */
       acc = __SMLAD(a1, state_out, acc);
 
-      /* The result is converted from 3.29 to 1.31 and then saturation is applied */
+      /* The result is converted from 3.29 to 1.31 and then saturation is
+       * applied */
       out = __SSAT((acc >> shift), 16);
 
       /* Store the output in the destination buffer. */
-#ifndef  ARM_MATH_BIG_ENDIAN
-      write_q15x2_ia (&pOut, __PKHBT(state_out, out, 16));
+#ifndef ARM_MATH_BIG_ENDIAN
+      write_q15x2_ia(&pOut, __PKHBT(state_out, out, 16));
 #else
-      write_q15x2_ia (&pOut, __PKHBT(out, state_out >> 16, 16));
+      write_q15x2_ia(&pOut, __PKHBT(out, state_out >> 16, 16));
 #endif /* #ifndef  ARM_MATH_BIG_ENDIAN */
 
       /* Every time after the output is computed state should be updated. */
@@ -163,11 +167,11 @@ void arm_biquad_cascade_df1_fast_q15(
       /* Yn1 = acc */
       /* x[n-N], x[n-N-1] are packed together to make state_in of type q31 */
       /* y[n-N], y[n-N-1] are packed together to make state_out of type q31 */
-#ifndef  ARM_MATH_BIG_ENDIAN
-      state_in  = __PKHBT(in >> 16, state_in, 16);
+#ifndef ARM_MATH_BIG_ENDIAN
+      state_in = __PKHBT(in >> 16, state_in, 16);
       state_out = __PKHBT(out, state_out, 16);
 #else
-      state_in  = __PKHBT(state_in >> 16, in, 16);
+      state_in = __PKHBT(state_in >> 16, in, 16);
       state_out = __PKHBT(state_out >> 16, out, 16);
 #endif /* #ifndef  ARM_MATH_BIG_ENDIAN */
 
@@ -185,13 +189,12 @@ void arm_biquad_cascade_df1_fast_q15(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-    while (sample > 0U)
-    {
+    while (sample > 0U) {
       /* Read the input */
       in = *pIn++;
 
       /* out =  b0 * x[n] + 0 * 0 */
-#ifndef  ARM_MATH_BIG_ENDIAN
+#ifndef ARM_MATH_BIG_ENDIAN
       out = __SMUAD(b0, in);
 #else
       out = __SMUADX(b0, in);
@@ -202,11 +205,12 @@ void arm_biquad_cascade_df1_fast_q15(
       /* acc +=  a1 * y[n-1] + acc +=  a2 * y[n-2] */
       acc = __SMLAD(a1, state_out, acc);
 
-      /* The result is converted from 3.29 to 1.31 and then saturation is applied */
+      /* The result is converted from 3.29 to 1.31 and then saturation is
+       * applied */
       out = __SSAT((acc >> shift), 16);
 
       /* Store the output in the destination buffer. */
-      *pOut++ = (q15_t) out;
+      *pOut++ = (q15_t)out;
 
       /* Every time after the output is computed state should be updated. */
       /* The states should be updated as:  */
@@ -216,7 +220,7 @@ void arm_biquad_cascade_df1_fast_q15(
       /* Yn1 = acc */
       /* x[n-N], x[n-N-1] are packed together to make state_in of type q31 */
       /* y[n-N], y[n-N-1] are packed together to make state_out of type q31 */
-#ifndef  ARM_MATH_BIG_ENDIAN
+#ifndef ARM_MATH_BIG_ENDIAN
       state_in = __PKHBT(in, state_in, 16);
       state_out = __PKHBT(out, state_out, 16);
 #else
diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_fast_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_fast_q31.c
index 586296b..ad18096 100644
--- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_fast_q31.c
+++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_fast_q31.c
@@ -1,7 +1,8 @@
 /* ----------------------------------------------------------------------
  * Project:      CMSIS DSP Library
  * Title:        arm_biquad_cascade_df1_fast_q31.c
- * Description:  Processing function for the Q31 Fast Biquad cascade DirectFormI(DF1) filter
+ * Description:  Processing function for the Q31 Fast Biquad cascade
+ * DirectFormI(DF1) filter
  *
  * $Date:        18. March 2019
  * $Revision:    V1.6.0
@@ -38,46 +39,50 @@
  */
 
 /**
-  @brief         Processing function for the Q31 Biquad cascade filter (fast variant).
-  @param[in]     S         points to an instance of the Q31 Biquad cascade structure
+  @brief         Processing function for the Q31 Biquad cascade filter (fast
+  variant).
+  @param[in]     S         points to an instance of the Q31 Biquad cascade
+  structure
   @param[in]     pSrc      points to the block of input data
   @param[out]    pDst      points to the block of output data
   @param[in]     blockSize number of samples to process per call
   @return        none
 
   @par           Scaling and Overflow Behavior
-                   This function is optimized for speed at the expense of fixed-point precision and overflow protection.
-                   The result of each 1.31 x 1.31 multiplication is truncated to 2.30 format.
-                   These intermediate results are added to a 2.30 accumulator.
-                   Finally, the accumulator is saturated and converted to a 1.31 result.
-                   The fast version has the same overflow behavior as the standard version and provides less precision since it discards the low 32 bits of each multiplication result.
-                   In order to avoid overflows completely the input signal must be scaled down by two bits and lie in the range [-0.25 +0.25). Use the intialization function
-                   arm_biquad_cascade_df1_init_q31() to initialize filter structure.
+                   This function is optimized for speed at the expense of
+  fixed-point precision and overflow protection. The result of each 1.31 x 1.31
+  multiplication is truncated to 2.30 format. These intermediate results are
+  added to a 2.30 accumulator. Finally, the accumulator is saturated and
+  converted to a 1.31 result. The fast version has the same overflow behavior as
+  the standard version and provides less precision since it discards the low 32
+  bits of each multiplication result. In order to avoid overflows completely the
+  input signal must be scaled down by two bits and lie in the range [-0.25
+  +0.25). Use the intialization function arm_biquad_cascade_df1_init_q31() to
+  initialize filter structure.
   @remark
-                   Refer to \ref arm_biquad_cascade_df1_q31() for a slower implementation of this function
-                   which uses 64-bit accumulation to provide higher precision. Both the slow and the fast versions use the same instance structure.
-                   Use the function \ref arm_biquad_cascade_df1_init_q31() to initialize the filter structure.
+                   Refer to \ref arm_biquad_cascade_df1_q31() for a slower
+  implementation of this function which uses 64-bit accumulation to provide
+  higher precision. Both the slow and the fast versions use the same instance
+  structure. Use the function \ref arm_biquad_cascade_df1_init_q31() to
+  initialize the filter structure.
  */
 
-void arm_biquad_cascade_df1_fast_q31(
-  const arm_biquad_casd_df1_inst_q31 * S,
-  const q31_t * pSrc,
-        q31_t * pDst,
-        uint32_t blockSize)
-{
-  const q31_t *pIn = pSrc;                             /* Source pointer */
-        q31_t *pOut = pDst;                            /* Destination pointer */
-        q31_t *pState = S->pState;                     /* pState pointer */
-  const q31_t *pCoeffs = S->pCoeffs;                   /* Coefficient pointer */
-        q31_t acc = 0;                                 /* Accumulator */
-        q31_t b0, b1, b2, a1, a2;                      /* Filter coefficients */
-        q31_t Xn1, Xn2, Yn1, Yn2;                      /* Filter pState variables */
-        q31_t Xn;                                      /* Temporary input */
-        int32_t shift = (int32_t) S->postShift + 1;    /* Shift to be applied to the output */
-        uint32_t sample, stage = S->numStages;         /* Loop counters */
+void arm_biquad_cascade_df1_fast_q31(const arm_biquad_casd_df1_inst_q31 *S,
+                                     const q31_t *pSrc, q31_t *pDst,
+                                     uint32_t blockSize) {
+  const q31_t *pIn = pSrc;           /* Source pointer */
+  q31_t *pOut = pDst;                /* Destination pointer */
+  q31_t *pState = S->pState;         /* pState pointer */
+  const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */
+  q31_t acc = 0;                     /* Accumulator */
+  q31_t b0, b1, b2, a1, a2;          /* Filter coefficients */
+  q31_t Xn1, Xn2, Yn1, Yn2;          /* Filter pState variables */
+  q31_t Xn;                          /* Temporary input */
+  int32_t shift =
+      (int32_t)S->postShift + 1;         /* Shift to be applied to the output */
+  uint32_t sample, stage = S->numStages; /* Loop counters */
 
-  do
-  {
+  do {
     /* Reading the coefficients */
     b0 = *pCoeffs++;
     b1 = *pCoeffs++;
@@ -91,7 +96,7 @@ void arm_biquad_cascade_df1_fast_q31(
     Yn1 = pState[2];
     Yn2 = pState[3];
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
     /* Apply loop unrolling and compute 4 output values simultaneously. */
     /* Variables acc ... acc3 hold output values that are being computed:
@@ -102,12 +107,12 @@ void arm_biquad_cascade_df1_fast_q31(
     /* Loop unrolling: Compute 4 outputs at a time */
     sample = blockSize >> 2U;
 
-    while (sample > 0U)
-    {
+    while (sample > 0U) {
       /* Read the input */
       Xn = *pIn;
 
-      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */
+      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 *
+       * y[n-2] */
       /* acc =  b0 * x[n] */
       /* acc = (q31_t) (((q63_t) b1 * Xn1) >> 32);*/
       mult_32x32_keep32_R(acc, b1, Xn1);
@@ -133,7 +138,8 @@ void arm_biquad_cascade_df1_fast_q31(
       /* Store the output in the destination buffer. */
       *pOut = Yn2;
 
-      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */
+      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 *
+       * y[n-2] */
       /* acc =  b0 * x[n] */
       /* acc = (q31_t) (((q63_t) b0 * (Xn2)) >> 32);*/
       mult_32x32_keep32_R(acc, b0, Xn2);
@@ -159,7 +165,8 @@ void arm_biquad_cascade_df1_fast_q31(
       /* Store the output in the destination buffer. */
       *(pOut + 1U) = Yn1;
 
-      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */
+      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 *
+       * y[n-2] */
       /* acc =  b0 * x[n] */
       /* acc = (q31_t) (((q63_t) b0 * (Xn1)) >> 32);*/
       mult_32x32_keep32_R(acc, b0, Xn1);
@@ -186,7 +193,8 @@ void arm_biquad_cascade_df1_fast_q31(
       *(pOut + 2U) = Yn2;
       pIn += 4U;
 
-      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */
+      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 *
+       * y[n-2] */
       /* acc =  b0 * x[n] */
       /* acc = (q31_t) (((q63_t) b0 * (Xn)) >> 32);*/
       mult_32x32_keep32_R(acc, b0, Xn);
@@ -232,12 +240,12 @@ void arm_biquad_cascade_df1_fast_q31(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-    while (sample > 0U)
-    {
+    while (sample > 0U) {
       /* Read the input */
       Xn = *pIn++;
 
-      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */
+      /* acc =  b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 *
+       * y[n-2] */
       /* acc =  b0 * x[n] */
       /* acc = (q31_t) (((q63_t) b0 * (Xn)) >> 32);*/
       mult_32x32_keep32_R(acc, b0, Xn);
diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_init_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_init_f32.c
index f51c262..1f6d039 100644
--- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_init_f32.c
+++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_init_f32.c
@@ -1,7 +1,8 @@
 /* ----------------------------------------------------------------------
  * Project:      CMSIS DSP Library
  * Title:        arm_biquad_cascade_df1_init_f32.c
- * Description:  Floating-point Biquad cascade DirectFormI(DF1) filter initialization function
+ * Description:  Floating-point Biquad cascade DirectFormI(DF1) filter
+ * initialization function
  *
  * $Date:        18. March 2019
  * $Revision:    V1.6.0
@@ -38,41 +39,42 @@
  */
 
 /**
-  @brief         Initialization function for the floating-point Biquad cascade filter.
-  @param[in,out] S           points to an instance of the floating-point Biquad cascade structure.
+  @brief         Initialization function for the floating-point Biquad cascade
+  filter.
+  @param[in,out] S           points to an instance of the floating-point Biquad
+  cascade structure.
   @param[in]     numStages   number of 2nd order stages in the filter.
   @param[in]     pCoeffs     points to the filter coefficients.
   @param[in]     pState      points to the state buffer.
   @return        none
 
   @par           Coefficient and State Ordering
-                   The coefficients are stored in the array pCoeffs in the following order:
-  
-      {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...}
+                   The coefficients are stored in the array pCoeffs
+  in the following order: 
 {b10, b11, b12, a11, a12, b20, b21, b22, a21,
+  a22, ...}
   
@par - where b1x and a1x are the coefficients for the first stage, - b2x and a2x are the coefficients for the second stage, - and so on. The pCoeffs array contains a total of 5*numStages values. + where b1x and a1x are the + coefficients for the first stage, b2x and a2x are + the coefficients for the second stage, and so on. The pCoeffs + array contains a total of 5*numStages values. @par The pState is a pointer to state array. - Each Biquad stage has 4 state variables x[n-1], x[n-2], y[n-1], and y[n-2]. - The state variables are arranged in the pState array as: -
-      {x[n-1], x[n-2], y[n-1], y[n-2]}
+                   Each Biquad stage has 4 state variables x[n-1], x[n-2],
+  y[n-1], and y[n-2]. The state variables are arranged in
+  the pState array as: 
 {x[n-1], x[n-2], y[n-1], y[n-2]}
   
- The 4 state variables for stage 1 are first, then the 4 state variables for stage 2, and so on. - The state array has a total length of 4*numStages values. - The state variables are updated after each block of data is processed; the coefficients are untouched. + The 4 state variables for stage 1 are first, then the 4 state + variables for stage 2, and so on. The state array has a total length of + 4*numStages values. The state variables are updated after each + block of data is processed; the coefficients are untouched. */ -void arm_biquad_cascade_df1_init_f32( - arm_biquad_casd_df1_inst_f32 * S, - uint8_t numStages, - const float32_t * pCoeffs, - float32_t * pState) -{ +void arm_biquad_cascade_df1_init_f32(arm_biquad_casd_df1_inst_f32 *S, + uint8_t numStages, + const float32_t *pCoeffs, + float32_t *pState) { /* Assign filter stages */ S->numStages = numStages; @@ -80,7 +82,7 @@ void arm_biquad_cascade_df1_init_f32( S->pCoeffs = pCoeffs; /* Clear state buffer and size is always 4 * numStages */ - memset(pState, 0, (4U * (uint32_t) numStages) * sizeof(float32_t)); + memset(pState, 0, (4U * (uint32_t)numStages) * sizeof(float32_t)); /* Assign state pointer */ S->pState = pState; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_init_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_init_q15.c index c2e542c..418bd66 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_init_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_init_q15.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df1_init_q15.c - * Description: Q15 Biquad cascade DirectFormI(DF1) filter initialization function + * Description: Q15 Biquad cascade DirectFormI(DF1) filter initialization + * function * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -39,42 +40,43 @@ /** @brief Initialization function for the Q15 Biquad cascade filter. - @param[in,out] S points to an instance of the Q15 Biquad cascade structure. + @param[in,out] S points to an instance of the Q15 Biquad cascade + structure. @param[in] numStages number of 2nd order stages in the filter. @param[in] pCoeffs points to the filter coefficients. @param[in] pState points to the state buffer. - @param[in] postShift Shift to be applied to the accumulator result. Varies according to the coefficients format + @param[in] postShift Shift to be applied to the accumulator result. + Varies according to the coefficients format @return none @par Coefficient and State Ordering - The coefficients are stored in the array pCoeffs in the following order: -
-      {b10, 0, b11, b12, a11, a12, b20, 0, b21, b22, a21, a22, ...}
+                   The coefficients are stored in the array pCoeffs
+  in the following order: 
 {b10, 0, b11, b12, a11, a12, b20, 0, b21, b22,
+  a21, a22, ...}
   
@par - where b1x and a1x are the coefficients for the first stage, - b2x and a2x are the coefficients for the second stage, - and so on. The pCoeffs array contains a total of 6*numStages values. - The zero coefficient between b1 and b2 facilities use of 16-bit SIMD instructions on the Cortex-M4. + where b1x and a1x are the + coefficients for the first stage, b2x and a2x are + the coefficients for the second stage, and so on. The pCoeffs + array contains a total of 6*numStages values. The zero + coefficient between b1 and b2 facilities use of + 16-bit SIMD instructions on the Cortex-M4. @par - The state variables are stored in the array pState. - Each Biquad stage has 4 state variables x[n-1], x[n-2], y[n-1], and y[n-2]. - The state variables are arranged in the pState array as: -
-      {x[n-1], x[n-2], y[n-1], y[n-2]}
+                   The state variables are stored in the array
+  pState. Each Biquad stage has 4 state variables x[n-1],
+  x[n-2], y[n-1], and y[n-2]. The state variables are
+  arranged in the pState array as: 
 {x[n-1], x[n-2], y[n-1],
+  y[n-2]}
   
- The 4 state variables for stage 1 are first, then the 4 state variables for stage 2, and so on. - The state array has a total length of 4*numStages values. - The state variables are updated after each block of data is processed; the coefficients are untouched. + The 4 state variables for stage 1 are first, then the 4 state + variables for stage 2, and so on. The state array has a total length of + 4*numStages values. The state variables are updated after each + block of data is processed; the coefficients are untouched. */ -void arm_biquad_cascade_df1_init_q15( - arm_biquad_casd_df1_inst_q15 * S, - uint8_t numStages, - const q15_t * pCoeffs, - q15_t * pState, - int8_t postShift) -{ +void arm_biquad_cascade_df1_init_q15(arm_biquad_casd_df1_inst_q15 *S, + uint8_t numStages, const q15_t *pCoeffs, + q15_t *pState, int8_t postShift) { /* Assign filter stages */ S->numStages = numStages; @@ -85,7 +87,7 @@ void arm_biquad_cascade_df1_init_q15( S->pCoeffs = pCoeffs; /* Clear state buffer and size is always 4 * numStages */ - memset(pState, 0, (4U * (uint32_t) numStages) * sizeof(q15_t)); + memset(pState, 0, (4U * (uint32_t)numStages) * sizeof(q15_t)); /* Assign state pointer */ S->pState = pState; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_init_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_init_q31.c index 8637889..97ebe47 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_init_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_init_q31.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df1_init_q31.c - * Description: Q31 Biquad cascade DirectFormI(DF1) filter initialization function + * Description: Q31 Biquad cascade DirectFormI(DF1) filter initialization + * function * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -39,41 +40,40 @@ /** @brief Initialization function for the Q31 Biquad cascade filter. - @param[in,out] S points to an instance of the Q31 Biquad cascade structure. + @param[in,out] S points to an instance of the Q31 Biquad cascade + structure. @param[in] numStages number of 2nd order stages in the filter. @param[in] pCoeffs points to the filter coefficients. @param[in] pState points to the state buffer. - @param[in] postShift Shift to be applied after the accumulator. Varies according to the coefficients format + @param[in] postShift Shift to be applied after the accumulator. Varies + according to the coefficients format @return none @par Coefficient and State Ordering - The coefficients are stored in the array pCoeffs in the following order: -
-      {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...}
+                   The coefficients are stored in the array pCoeffs
+  in the following order: 
 {b10, b11, b12, a11, a12, b20, b21, b22, a21,
+  a22, ...}
   
@par - where b1x and a1x are the coefficients for the first stage, - b2x and a2x are the coefficients for the second stage, - and so on. The pCoeffs array contains a total of 5*numStages values. + where b1x and a1x are the + coefficients for the first stage, b2x and a2x are + the coefficients for the second stage, and so on. The pCoeffs + array contains a total of 5*numStages values. @par The pState points to state variables array. - Each Biquad stage has 4 state variables x[n-1], x[n-2], y[n-1], and y[n-2]. - The state variables are arranged in the pState array as: -
-      {x[n-1], x[n-2], y[n-1], y[n-2]}
+                   Each Biquad stage has 4 state variables x[n-1], x[n-2],
+  y[n-1], and y[n-2]. The state variables are arranged in
+  the pState array as: 
 {x[n-1], x[n-2], y[n-1], y[n-2]}
   
- The 4 state variables for stage 1 are first, then the 4 state variables for stage 2, and so on. - The state array has a total length of 4*numStages values. - The state variables are updated after each block of data is processed; the coefficients are untouched. + The 4 state variables for stage 1 are first, then the 4 state + variables for stage 2, and so on. The state array has a total length of + 4*numStages values. The state variables are updated after each + block of data is processed; the coefficients are untouched. */ -void arm_biquad_cascade_df1_init_q31( - arm_biquad_casd_df1_inst_q31 * S, - uint8_t numStages, - const q31_t * pCoeffs, - q31_t * pState, - int8_t postShift) -{ +void arm_biquad_cascade_df1_init_q31(arm_biquad_casd_df1_inst_q31 *S, + uint8_t numStages, const q31_t *pCoeffs, + q31_t *pState, int8_t postShift) { /* Assign filter stages */ S->numStages = numStages; @@ -84,7 +84,7 @@ void arm_biquad_cascade_df1_init_q31( S->pCoeffs = pCoeffs; /* Clear state buffer and size is always 4 * numStages */ - memset(pState, 0, (4U * (uint32_t) numStages) * sizeof(q31_t)); + memset(pState, 0, (4U * (uint32_t)numStages) * sizeof(q31_t)); /* Assign state pointer */ S->pState = pState; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_q15.c index 9e23897..04bf597 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_q15.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df1_q15.c - * Description: Processing function for the Q15 Biquad cascade DirectFormI(DF1) filter + * Description: Processing function for the Q15 Biquad cascade DirectFormI(DF1) + * filter * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -39,80 +40,81 @@ /** @brief Processing function for the Q15 Biquad cascade filter. - @param[in] S points to an instance of the Q15 Biquad cascade structure + @param[in] S points to an instance of the Q15 Biquad cascade + structure @param[in] pSrc points to the block of input data - @param[out] pDst points to the location where the output result is written + @param[out] pDst points to the location where the output result is + written @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior - The function is implemented using a 64-bit internal accumulator. - Both coefficients and state variables are represented in 1.15 format and multiplications yield a 2.30 result. - The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. - There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. - The accumulator is then shifted by postShift bits to truncate the result to 1.15 format by discarding the low 16 bits. - Finally, the result is saturated to 1.15 format. + The function is implemented using a 64-bit internal + accumulator. Both coefficients and state variables are represented in 1.15 + format and multiplications yield a 2.30 result. The 2.30 intermediate results + are accumulated in a 64-bit accumulator in 34.30 format. There is no risk of + internal overflow with this approach and the full precision of intermediate + multiplications is preserved. The accumulator is then shifted by + postShift bits to truncate the result to 1.15 format by + discarding the low 16 bits. Finally, the result is saturated to 1.15 format. @remark - Refer to \ref arm_biquad_cascade_df1_fast_q15() for a faster but less precise implementation of this filter. + Refer to \ref arm_biquad_cascade_df1_fast_q15() for a faster + but less precise implementation of this filter. */ -void arm_biquad_cascade_df1_q15( - const arm_biquad_casd_df1_inst_q15 * S, - const q15_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ +void arm_biquad_cascade_df1_q15(const arm_biquad_casd_df1_inst_q15 *S, + const q15_t *pSrc, q15_t *pDst, + uint32_t blockSize) { +#if defined(ARM_MATH_DSP) -#if defined (ARM_MATH_DSP) + const q15_t *pIn = pSrc; /* Source pointer */ + q15_t *pOut = pDst; /* Destination pointer */ + q31_t in; /* Temporary variable to hold input value */ + q31_t out; /* Temporary variable to hold output value */ + q31_t b0; /* Temporary variable to hold bo value */ + q31_t b1, a1; /* Filter coefficients */ + q31_t state_in, state_out; /* Filter state variables */ + q31_t acc_l, acc_h; + q63_t acc; /* Accumulator */ + q15_t *pState = S->pState; /* State pointer */ + const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + int32_t lShift = (15 - (int32_t)S->postShift); /* Post shift */ + uint32_t sample, stage = (uint32_t)S->numStages; /* Stage loop counter */ + int32_t uShift = (32 - lShift); - const q15_t *pIn = pSrc; /* Source pointer */ - q15_t *pOut = pDst; /* Destination pointer */ - q31_t in; /* Temporary variable to hold input value */ - q31_t out; /* Temporary variable to hold output value */ - q31_t b0; /* Temporary variable to hold bo value */ - q31_t b1, a1; /* Filter coefficients */ - q31_t state_in, state_out; /* Filter state variables */ - q31_t acc_l, acc_h; - q63_t acc; /* Accumulator */ - q15_t *pState = S->pState; /* State pointer */ - const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - int32_t lShift = (15 - (int32_t) S->postShift); /* Post shift */ - uint32_t sample, stage = (uint32_t) S->numStages; /* Stage loop counter */ - int32_t uShift = (32 - lShift); - - do - { + do { /* Read the b0 and 0 coefficients using SIMD */ - b0 = read_q15x2_ia ((q15_t **) &pCoeffs); + b0 = read_q15x2_ia((q15_t **)&pCoeffs); /* Read the b1 and b2 coefficients using SIMD */ - b1 = read_q15x2_ia ((q15_t **) &pCoeffs); + b1 = read_q15x2_ia((q15_t **)&pCoeffs); /* Read the a1 and a2 coefficients using SIMD */ - a1 = read_q15x2_ia ((q15_t **) &pCoeffs); + a1 = read_q15x2_ia((q15_t **)&pCoeffs); /* Read the input state values from the state buffer: x[n-1], x[n-2] */ - state_in = read_q15x2_ia (&pState); + state_in = read_q15x2_ia(&pState); /* Read the output state values from the state buffer: y[n-1], y[n-2] */ - state_out = read_q15x2_da (&pState); + state_out = read_q15x2_da(&pState); /* Apply loop unrolling and compute 2 output values simultaneously. */ /* The variable acc hold output values that are being computed: * - * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] - * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] + * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * + * y[n-2] acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * + * y[n-2] */ sample = blockSize >> 1U; - /* First part of the processing with loop unrolling. Compute 2 outputs at a time. + /* First part of the processing with loop unrolling. Compute 2 outputs at a + *time. ** a second loop below computes the remaining 1 sample. */ - while (sample > 0U) - { + while (sample > 0U) { /* Read the input */ - in = read_q15x2_ia ((q15_t **) &pIn); + in = read_q15x2_ia((q15_t **)&pIn); /* out = b0 * x[n] + 0 * 0 */ out = __SMUAD(b0, in); @@ -122,7 +124,8 @@ void arm_biquad_cascade_df1_q15( /* acc += a1 * y[n-1] + a2 * y[n-2] */ acc = __SMLALD(a1, state_out, acc); - /* The result is converted from 3.29 to 1.31 if postShift = 1, and then saturation is applied */ + /* The result is converted from 3.29 to 1.31 if postShift = 1, and then + * saturation is applied */ /* Calc lower part of acc */ acc_l = acc & 0xffffffff; @@ -130,7 +133,7 @@ void arm_biquad_cascade_df1_q15( acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ - out = (uint32_t) acc_l >> lShift | acc_h << uShift; + out = (uint32_t)acc_l >> lShift | acc_h << uShift; out = __SSAT(out, 16); @@ -143,11 +146,11 @@ void arm_biquad_cascade_df1_q15( /* x[n-N], x[n-N-1] are packed together to make state_in of type q31 */ /* y[n-N], y[n-N-1] are packed together to make state_out of type q31 */ -#ifndef ARM_MATH_BIG_ENDIAN - state_in = __PKHBT(in, state_in, 16); +#ifndef ARM_MATH_BIG_ENDIAN + state_in = __PKHBT(in, state_in, 16); state_out = __PKHBT(out, state_out, 16); #else - state_in = __PKHBT(state_in >> 16, (in >> 16), 16); + state_in = __PKHBT(state_in >> 16, (in >> 16), 16); state_out = __PKHBT(state_out >> 16, (out), 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ @@ -158,7 +161,8 @@ void arm_biquad_cascade_df1_q15( /* acc += a1 * y[n-1] + a2 * y[n-2] */ acc = __SMLALD(a1, state_out, acc); - /* The result is converted from 3.29 to 1.31 if postShift = 1, and then saturation is applied */ + /* The result is converted from 3.29 to 1.31 if postShift = 1, and then + * saturation is applied */ /* Calc lower part of acc */ acc_l = acc & 0xffffffff; @@ -166,15 +170,15 @@ void arm_biquad_cascade_df1_q15( acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ - out = (uint32_t) acc_l >> lShift | acc_h << uShift; + out = (uint32_t)acc_l >> lShift | acc_h << uShift; out = __SSAT(out, 16); /* Store the output in the destination buffer. */ -#ifndef ARM_MATH_BIG_ENDIAN - write_q15x2_ia (&pOut, __PKHBT(state_out, out, 16)); +#ifndef ARM_MATH_BIG_ENDIAN + write_q15x2_ia(&pOut, __PKHBT(state_out, out, 16)); #else - write_q15x2_ia (&pOut, __PKHBT(out, state_out >> 16, 16)); + write_q15x2_ia(&pOut, __PKHBT(out, state_out >> 16, 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Every time after the output is computed state should be updated. */ @@ -185,11 +189,11 @@ void arm_biquad_cascade_df1_q15( /* Yn1 = acc */ /* x[n-N], x[n-N-1] are packed together to make state_in of type q31 */ /* y[n-N], y[n-N-1] are packed together to make state_out of type q31 */ -#ifndef ARM_MATH_BIG_ENDIAN - state_in = __PKHBT(in >> 16, state_in, 16); +#ifndef ARM_MATH_BIG_ENDIAN + state_in = __PKHBT(in >> 16, state_in, 16); state_out = __PKHBT(out, state_out, 16); #else - state_in = __PKHBT(state_in >> 16, in, 16); + state_in = __PKHBT(state_in >> 16, in, 16); state_out = __PKHBT(state_out >> 16, out, 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ @@ -197,16 +201,16 @@ void arm_biquad_cascade_df1_q15( sample--; } - /* If the blockSize is not a multiple of 2, compute any remaining output samples here. + /* If the blockSize is not a multiple of 2, compute any remaining output + *samples here. ** No loop unrolling is used. */ - if ((blockSize & 0x1U) != 0U) - { + if ((blockSize & 0x1U) != 0U) { /* Read the input */ in = *pIn++; /* out = b0 * x[n] + 0 * 0 */ -#ifndef ARM_MATH_BIG_ENDIAN +#ifndef ARM_MATH_BIG_ENDIAN out = __SMUAD(b0, in); #else out = __SMUADX(b0, in); @@ -217,7 +221,8 @@ void arm_biquad_cascade_df1_q15( /* acc += a1 * y[n-1] + a2 * y[n-2] */ acc = __SMLALD(a1, state_out, acc); - /* The result is converted from 3.29 to 1.31 if postShift = 1, and then saturation is applied */ + /* The result is converted from 3.29 to 1.31 if postShift = 1, and then + * saturation is applied */ /* Calc lower part of acc */ acc_l = acc & 0xffffffff; @@ -225,12 +230,12 @@ void arm_biquad_cascade_df1_q15( acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ - out = (uint32_t) acc_l >> lShift | acc_h << uShift; + out = (uint32_t)acc_l >> lShift | acc_h << uShift; out = __SSAT(out, 16); /* Store the output in the destination buffer. */ - *pOut++ = (q15_t) out; + *pOut++ = (q15_t)out; /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ @@ -240,7 +245,7 @@ void arm_biquad_cascade_df1_q15( /* Yn1 = acc */ /* x[n-N], x[n-N-1] are packed together to make state_in of type q31 */ /* y[n-N], y[n-N-1] are packed together to make state_out of type q31 */ -#ifndef ARM_MATH_BIG_ENDIAN +#ifndef ARM_MATH_BIG_ENDIAN state_in = __PKHBT(in, state_in, 16); state_out = __PKHBT(out, state_out, 16); #else @@ -257,8 +262,8 @@ void arm_biquad_cascade_df1_q15( pOut = pDst; /* Store the updated state variables back into the state array */ - write_q15x2_ia (&pState, state_in); - write_q15x2_ia (&pState, state_out); + write_q15x2_ia(&pState, state_in); + write_q15x2_ia(&pState, state_out); /* Decrement loop counter */ stage--; @@ -267,22 +272,21 @@ void arm_biquad_cascade_df1_q15( #else - const q15_t *pIn = pSrc; /* Source pointer */ - q15_t *pOut = pDst; /* Destination pointer */ - q15_t b0, b1, b2, a1, a2; /* Filter coefficients */ - q15_t Xn1, Xn2, Yn1, Yn2; /* Filter state variables */ - q15_t Xn; /* temporary input */ - q63_t acc; /* Accumulator */ - int32_t shift = (15 - (int32_t) S->postShift); /* Post shift */ - q15_t *pState = S->pState; /* State pointer */ - const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - uint32_t sample, stage = (uint32_t) S->numStages; /* Stage loop counter */ + const q15_t *pIn = pSrc; /* Source pointer */ + q15_t *pOut = pDst; /* Destination pointer */ + q15_t b0, b1, b2, a1, a2; /* Filter coefficients */ + q15_t Xn1, Xn2, Yn1, Yn2; /* Filter state variables */ + q15_t Xn; /* temporary input */ + q63_t acc; /* Accumulator */ + int32_t shift = (15 - (int32_t)S->postShift); /* Post shift */ + q15_t *pState = S->pState; /* State pointer */ + const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + uint32_t sample, stage = (uint32_t)S->numStages; /* Stage loop counter */ - do - { + do { /* Reading the coefficients */ b0 = *pCoeffs++; - pCoeffs++; // skip the 0 coefficient + pCoeffs++; // skip the 0 coefficient b1 = *pCoeffs++; b2 = *pCoeffs++; a1 = *pCoeffs++; @@ -295,28 +299,29 @@ void arm_biquad_cascade_df1_q15( Yn2 = pState[3]; /* The variables acc holds the output value that is computed: - * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] + * acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * + * y[n-2] */ sample = blockSize; - while (sample > 0U) - { + while (sample > 0U) { /* Read the input */ Xn = *pIn++; - /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ + /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * + * y[n-2] */ /* acc = b0 * x[n] */ - acc = (q31_t) b0 *Xn; + acc = (q31_t)b0 * Xn; /* acc += b1 * x[n-1] */ - acc += (q31_t) b1 *Xn1; + acc += (q31_t)b1 * Xn1; /* acc += b[2] * x[n-2] */ - acc += (q31_t) b2 *Xn2; + acc += (q31_t)b2 * Xn2; /* acc += a1 * y[n-1] */ - acc += (q31_t) a1 *Yn1; + acc += (q31_t)a1 * Yn1; /* acc += a2 * y[n-2] */ - acc += (q31_t) a2 *Yn2; + acc += (q31_t)a2 * Yn2; /* The result is converted to 1.31 */ acc = __SSAT((acc >> shift), 16); @@ -330,10 +335,10 @@ void arm_biquad_cascade_df1_q15( Xn2 = Xn1; Xn1 = Xn; Yn2 = Yn1; - Yn1 = (q15_t) acc; + Yn1 = (q15_t)acc; /* Store the output in the destination buffer. */ - *pOut++ = (q15_t) acc; + *pOut++ = (q15_t)acc; /* decrement the loop counter */ sample--; @@ -355,7 +360,6 @@ void arm_biquad_cascade_df1_q15( } while (--stage); #endif /* #if defined (ARM_MATH_DSP) */ - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_q31.c index 011e21d..1f4035f 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df1_q31.c @@ -39,47 +39,48 @@ /** @brief Processing function for the Q31 Biquad cascade filter. - @param[in] S points to an instance of the Q31 Biquad cascade structure + @param[in] S points to an instance of the Q31 Biquad cascade + structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior - The function is implemented using an internal 64-bit accumulator. - The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. - Thus, if the accumulator result overflows it wraps around rather than clip. - In order to avoid overflows completely the input signal must be scaled down by 2 bits and lie in the range [-0.25 +0.25). - After all 5 multiply-accumulates are performed, the 2.62 accumulator is shifted by postShift bits and the result truncated to - 1.31 format by discarding the low 32 bits. + The function is implemented using an internal 64-bit + accumulator. The accumulator has a 2.62 format and maintains full precision of + the intermediate multiplication results but provides only a single guard bit. + Thus, if the accumulator result overflows it wraps around + rather than clip. In order to avoid overflows completely the input signal must + be scaled down by 2 bits and lie in the range [-0.25 +0.25). After all 5 + multiply-accumulates are performed, the 2.62 accumulator is shifted by + postShift bits and the result truncated to 1.31 format by + discarding the low 32 bits. @remark - Refer to \ref arm_biquad_cascade_df1_fast_q31() for a faster but less precise implementation of this filter. + Refer to \ref arm_biquad_cascade_df1_fast_q31() for a faster + but less precise implementation of this filter. */ -void arm_biquad_cascade_df1_q31( - const arm_biquad_casd_df1_inst_q31 * S, - const q31_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - const q31_t *pIn = pSrc; /* Source pointer */ - q31_t *pOut = pDst; /* Destination pointer */ - q31_t *pState = S->pState; /* pState pointer */ - const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q63_t acc; /* Accumulator */ - q31_t b0, b1, b2, a1, a2; /* Filter coefficients */ - q31_t Xn1, Xn2, Yn1, Yn2; /* Filter pState variables */ - q31_t Xn; /* Temporary input */ - uint32_t uShift = ((uint32_t) S->postShift + 1U); - uint32_t lShift = 32U - uShift; /* Shift to be applied to the output */ - uint32_t sample, stage = S->numStages; /* Loop counters */ +void arm_biquad_cascade_df1_q31(const arm_biquad_casd_df1_inst_q31 *S, + const q31_t *pSrc, q31_t *pDst, + uint32_t blockSize) { + const q31_t *pIn = pSrc; /* Source pointer */ + q31_t *pOut = pDst; /* Destination pointer */ + q31_t *pState = S->pState; /* pState pointer */ + const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q63_t acc; /* Accumulator */ + q31_t b0, b1, b2, a1, a2; /* Filter coefficients */ + q31_t Xn1, Xn2, Yn1, Yn2; /* Filter pState variables */ + q31_t Xn; /* Temporary input */ + uint32_t uShift = ((uint32_t)S->postShift + 1U); + uint32_t lShift = 32U - uShift; /* Shift to be applied to the output */ + uint32_t sample, stage = S->numStages; /* Loop counters */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t acc_l, acc_h; /* temporary output variables */ +#if defined(ARM_MATH_LOOPUNROLL) + q31_t acc_l, acc_h; /* temporary output variables */ #endif - do - { + do { /* Reading the coefficients */ b0 = *pCoeffs++; b1 = *pCoeffs++; @@ -93,7 +94,7 @@ void arm_biquad_cascade_df1_q31( Yn1 = pState[2]; Yn2 = pState[3]; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Apply loop unrolling and compute 4 output values simultaneously. */ /* Variable acc hold output values that are being computed: @@ -104,20 +105,21 @@ void arm_biquad_cascade_df1_q31( /* Loop unrolling: Compute 4 outputs at a time */ sample = blockSize >> 2U; - while (sample > 0U) - { + while (sample > 0U) { /* Read the first input */ Xn = *pIn++; - /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ - acc = ((q63_t) b0 * Xn) + ((q63_t) b1 * Xn1) + ((q63_t) b2 * Xn2) + ((q63_t) a1 * Yn1) + ((q63_t) a2 * Yn2); + /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * + * y[n-2] */ + acc = ((q63_t)b0 * Xn) + ((q63_t)b1 * Xn1) + ((q63_t)b2 * Xn2) + + ((q63_t)a1 * Yn1) + ((q63_t)a2 * Yn2); /* The result is converted to 1.31 , Yn2 variable is reused */ - acc_l = (acc ) & 0xffffffff; /* Calc lower part of acc */ + acc_l = (acc)&0xffffffff; /* Calc lower part of acc */ acc_h = (acc >> 32) & 0xffffffff; /* Calc upper part of acc */ /* Apply shift for lower part of acc and upper part of acc */ - Yn2 = (uint32_t) acc_l >> lShift | acc_h << uShift; + Yn2 = (uint32_t)acc_l >> lShift | acc_h << uShift; /* Store output in destination buffer. */ *pOut++ = Yn2; @@ -125,15 +127,17 @@ void arm_biquad_cascade_df1_q31( /* Read the second input */ Xn2 = *pIn++; - /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ - acc = ((q63_t) b0 * Xn2) + ((q63_t) b1 * Xn) + ((q63_t) b2 * Xn1) + ((q63_t) a1 * Yn2) + ((q63_t) a2 * Yn1); + /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * + * y[n-2] */ + acc = ((q63_t)b0 * Xn2) + ((q63_t)b1 * Xn) + ((q63_t)b2 * Xn1) + + ((q63_t)a1 * Yn2) + ((q63_t)a2 * Yn1); /* The result is converted to 1.31, Yn1 variable is reused */ - acc_l = (acc ) & 0xffffffff; /* Calc lower part of acc */ + acc_l = (acc)&0xffffffff; /* Calc lower part of acc */ acc_h = (acc >> 32) & 0xffffffff; /* Calc upper part of acc */ /* Apply shift for lower part of acc and upper part of acc */ - Yn1 = (uint32_t) acc_l >> lShift | acc_h << uShift; + Yn1 = (uint32_t)acc_l >> lShift | acc_h << uShift; /* Store output in destination buffer. */ *pOut++ = Yn1; @@ -141,15 +145,17 @@ void arm_biquad_cascade_df1_q31( /* Read the third input */ Xn1 = *pIn++; - /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ - acc = ((q63_t) b0 * Xn1) + ((q63_t) b1 * Xn2) + ((q63_t) b2 * Xn) + ((q63_t) a1 * Yn1) + ((q63_t) a2 * Yn2); + /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * + * y[n-2] */ + acc = ((q63_t)b0 * Xn1) + ((q63_t)b1 * Xn2) + ((q63_t)b2 * Xn) + + ((q63_t)a1 * Yn1) + ((q63_t)a2 * Yn2); /* The result is converted to 1.31, Yn2 variable is reused */ - acc_l = (acc ) & 0xffffffff; /* Calc lower part of acc */ + acc_l = (acc)&0xffffffff; /* Calc lower part of acc */ acc_h = (acc >> 32) & 0xffffffff; /* Calc upper part of acc */ /* Apply shift for lower part of acc and upper part of acc */ - Yn2 = (uint32_t) acc_l >> lShift | acc_h << uShift; + Yn2 = (uint32_t)acc_l >> lShift | acc_h << uShift; /* Store output in destination buffer. */ *pOut++ = Yn2; @@ -157,15 +163,17 @@ void arm_biquad_cascade_df1_q31( /* Read the forth input */ Xn = *pIn++; - /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ - acc = ((q63_t) b0 * Xn) + ((q63_t) b1 * Xn1) + ((q63_t) b2 * Xn2) + ((q63_t) a1 * Yn2) + ((q63_t) a2 * Yn1); + /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * + * y[n-2] */ + acc = ((q63_t)b0 * Xn) + ((q63_t)b1 * Xn1) + ((q63_t)b2 * Xn2) + + ((q63_t)a1 * Yn2) + ((q63_t)a2 * Yn1); /* The result is converted to 1.31, Yn1 variable is reused */ - acc_l = (acc ) & 0xffffffff; /* Calc lower part of acc */ + acc_l = (acc)&0xffffffff; /* Calc lower part of acc */ acc_h = (acc >> 32) & 0xffffffff; /* Calc upper part of acc */ /* Apply shift for lower part of acc and upper part of acc */ - Yn1 = (uint32_t) acc_l >> lShift | acc_h << uShift; + Yn1 = (uint32_t)acc_l >> lShift | acc_h << uShift; /* Store output in destination buffer. */ *pOut++ = Yn1; @@ -193,19 +201,20 @@ void arm_biquad_cascade_df1_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (sample > 0U) - { + while (sample > 0U) { /* Read the input */ Xn = *pIn++; - /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * y[n-2] */ - acc = ((q63_t) b0 * Xn) + ((q63_t) b1 * Xn1) + ((q63_t) b2 * Xn2) + ((q63_t) a1 * Yn1) + ((q63_t) a2 * Yn2); + /* acc = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] + a1 * y[n-1] + a2 * + * y[n-2] */ + acc = ((q63_t)b0 * Xn) + ((q63_t)b1 * Xn1) + ((q63_t)b2 * Xn2) + + ((q63_t)a1 * Yn1) + ((q63_t)a2 * Yn2); /* The result is converted to 1.31 */ acc = acc >> lShift; /* Store output in destination buffer. */ - *pOut++ = (q31_t) acc; + *pOut++ = (q31_t)acc; /* Every time after the output is computed state should be updated. */ /* The states should be updated as: */ @@ -216,7 +225,7 @@ void arm_biquad_cascade_df1_q31( Xn2 = Xn1; Xn1 = Xn; Yn2 = Yn1; - Yn1 = (q31_t) acc; + Yn1 = (q31_t)acc; /* decrement loop counter */ sample--; @@ -239,7 +248,6 @@ void arm_biquad_cascade_df1_q31( stage--; } while (stage > 0U); - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df2T_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df2T_f32.c index 112d75a..d35f730 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df2T_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df2T_f32.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df2T_f32.c - * Description: Processing function for floating-point transposed direct form II Biquad cascade filter + * Description: Processing function for floating-point transposed direct form + * II Biquad cascade filter * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -38,7 +39,8 @@ */ /** - @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. + @brief Processing function for the floating-point transposed direct + form II Biquad cascade filter. @param[in] S points to an instance of the filter data structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @@ -47,305 +49,299 @@ */ LOW_OPTIMIZATION_ENTER -void arm_biquad_cascade_df2T_f32( - const arm_biquad_cascade_df2T_instance_f32 * S, - const float32_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - const float32_t *pIn = pSrc; /* Source pointer */ - float32_t *pOut = pDst; /* Destination pointer */ - float32_t *pState = S->pState; /* State pointer */ - const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - float32_t acc1; /* Accumulator */ - float32_t b0, b1, b2, a1, a2; /* Filter coefficients */ - float32_t Xn1; /* Temporary input */ - float32_t d1, d2; /* State variables */ - uint32_t sample, stage = S->numStages; /* Loop counters */ +void arm_biquad_cascade_df2T_f32(const arm_biquad_cascade_df2T_instance_f32 *S, + const float32_t *pSrc, float32_t *pDst, + uint32_t blockSize) { + const float32_t *pIn = pSrc; /* Source pointer */ + float32_t *pOut = pDst; /* Destination pointer */ + float32_t *pState = S->pState; /* State pointer */ + const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + float32_t acc1; /* Accumulator */ + float32_t b0, b1, b2, a1, a2; /* Filter coefficients */ + float32_t Xn1; /* Temporary input */ + float32_t d1, d2; /* State variables */ + uint32_t sample, stage = S->numStages; /* Loop counters */ + do { + /* Reading the coefficients */ + b0 = pCoeffs[0]; + b1 = pCoeffs[1]; + b2 = pCoeffs[2]; + a1 = pCoeffs[3]; + a2 = pCoeffs[4]; - do - { - /* Reading the coefficients */ - b0 = pCoeffs[0]; - b1 = pCoeffs[1]; - b2 = pCoeffs[2]; - a1 = pCoeffs[3]; - a2 = pCoeffs[4]; + /* Reading the state values */ + d1 = pState[0]; + d2 = pState[1]; - /* Reading the state values */ - d1 = pState[0]; - d2 = pState[1]; + pCoeffs += 5U; - pCoeffs += 5U; +#if defined(ARM_MATH_LOOPUNROLL) -#if defined (ARM_MATH_LOOPUNROLL) + /* Loop unrolling: Compute 16 outputs at a time */ + sample = blockSize >> 4U; - /* Loop unrolling: Compute 16 outputs at a time */ - sample = blockSize >> 4U; + while (sample > 0U) { - while (sample > 0U) { + /* y[n] = b0 * x[n] + d1 */ + /* d1 = b1 * x[n] + a1 * y[n] + d2 */ + /* d2 = b2 * x[n] + a2 * y[n] */ - /* y[n] = b0 * x[n] + d1 */ - /* d1 = b1 * x[n] + a1 * y[n] + d2 */ - /* d2 = b2 * x[n] + a2 * y[n] */ + /* 1 */ + Xn1 = *pIn++; -/* 1 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 2 */ + Xn1 = *pIn++; -/* 2 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 3 */ + Xn1 = *pIn++; -/* 3 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 4 */ + Xn1 = *pIn++; -/* 4 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 5 */ + Xn1 = *pIn++; -/* 5 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 6 */ + Xn1 = *pIn++; -/* 6 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 7 */ + Xn1 = *pIn++; -/* 7 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 8 */ + Xn1 = *pIn++; -/* 8 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 9 */ + Xn1 = *pIn++; -/* 9 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 10 */ + Xn1 = *pIn++; -/* 10 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 11 */ + Xn1 = *pIn++; -/* 11 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 12 */ + Xn1 = *pIn++; -/* 12 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 13 */ + Xn1 = *pIn++; -/* 13 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 14 */ + Xn1 = *pIn++; -/* 14 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 15 */ + Xn1 = *pIn++; -/* 15 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 16 */ + Xn1 = *pIn++; -/* 16 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* decrement loop counter */ + sample--; + } - /* decrement loop counter */ - sample--; - } - - /* Loop unrolling: Compute remaining outputs */ - sample = blockSize & 0xFU; + /* Loop unrolling: Compute remaining outputs */ + sample = blockSize & 0xFU; #else - /* Initialize blkCnt with number of samples */ - sample = blockSize; + /* Initialize blkCnt with number of samples */ + sample = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (sample > 0U) { - Xn1 = *pIn++; + while (sample > 0U) { + Xn1 = *pIn++; - acc1 = b0 * Xn1 + d1; + acc1 = b0 * Xn1 + d1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - *pOut++ = acc1; - - /* decrement loop counter */ - sample--; - } - - /* Store the updated state variables back into the state array */ - pState[0] = d1; - pState[1] = d2; - - pState += 2U; - - /* The current stage input is given as the output to the next stage */ - pIn = pDst; - - /* Reset the output working pointer */ - pOut = pDst; + *pOut++ = acc1; /* decrement loop counter */ - stage--; + sample--; + } - } while (stage > 0U); + /* Store the updated state variables back into the state array */ + pState[0] = d1; + pState[1] = d2; + pState += 2U; + + /* The current stage input is given as the output to the next stage */ + pIn = pDst; + + /* Reset the output working pointer */ + pOut = pDst; + + /* decrement loop counter */ + stage--; + + } while (stage > 0U); } LOW_OPTIMIZATION_EXIT diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df2T_f64.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df2T_f64.c index a8af8ce..4c7b155 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df2T_f64.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df2T_f64.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df2T_f64.c - * Description: Processing function for floating-point transposed direct form II Biquad cascade filter + * Description: Processing function for floating-point transposed direct form + * II Biquad cascade filter * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -33,90 +34,103 @@ */ /** - @defgroup BiquadCascadeDF2T Biquad Cascade IIR Filters Using a Direct Form II Transposed Structure + @defgroup BiquadCascadeDF2T Biquad Cascade IIR Filters Using a Direct Form II + Transposed Structure - This set of functions implements arbitrary order recursive (IIR) filters using a transposed direct form II structure. - The filters are implemented as a cascade of second order Biquad sections. - These functions provide a slight memory savings as compared to the direct form I Biquad filter functions. - Only floating-point data is supported. + This set of functions implements arbitrary order recursive (IIR) filters using + a transposed direct form II structure. The filters are implemented as a + cascade of second order Biquad sections. These functions provide a slight + memory savings as compared to the direct form I Biquad filter functions. Only + floating-point data is supported. - This function operate on blocks of input and output data and each call to the function - processes blockSize samples through the filter. + This function operate on blocks of input and output data and each call to the + function processes blockSize samples through the filter. pSrc points to the array of input data and pDst points to the array of output data. Both arrays contain blockSize values. @par Algorithm - Each Biquad stage implements a second order filter using the difference equation: -
-     y[n] = b0 * x[n] + d1
-     d1 = b1 * x[n] + a1 * y[n] + d2
-     d2 = b2 * x[n] + a2 * y[n]
+                   Each Biquad stage implements a second order filter using the
+  difference equation: 
 y[n] = b0 * x[n] + d1 d1 = b1 * x[n] + a1 * y[n] +
+  d2 d2 = b2 * x[n] + a2 * y[n]
   
where d1 and d2 represent the two state values. @par - A Biquad filter using a transposed Direct Form II structure is shown below. - \image html BiquadDF2Transposed.gif "Single transposed Direct Form II Biquad" - Coefficients b0, b1, and b2 multiply the input signal x[n] and are referred to as the feedforward coefficients. - Coefficients a1 and a2 multiply the output signal y[n] and are referred to as the feedback coefficients. - Pay careful attention to the sign of the feedback coefficients. + A Biquad filter using a transposed Direct Form II structure + is shown below. \image html BiquadDF2Transposed.gif "Single transposed Direct + Form II Biquad" Coefficients b0, b1, and b2 multiply the input + signal x[n] and are referred to as the feedforward coefficients. + Coefficients a1 and a2 multiply the + output signal y[n] and are referred to as the feedback + coefficients. Pay careful attention to the sign of the feedback coefficients. Some design tools flip the sign of the feedback coefficients:
      y[n] = b0 * x[n] + d1;
      d1 = b1 * x[n] - a1 * y[n] + d2;
      d2 = b2 * x[n] - a2 * y[n];
   
- In this case the feedback coefficients a1 and a2 must be negated when used with the CMSIS DSP Library. + In this case the feedback coefficients a1 and + a2 must be negated when used with the CMSIS DSP Library. @par - Higher order filters are realized as a cascade of second order sections. - numStages refers to the number of second order stages used. - For example, an 8th order filter would be realized with numStages=4 second order stages. - A 9th order filter would be realized with numStages=5 second order stages with the - coefficients for one of the stages configured as a first order filter (b2=0 and a2=0). + Higher order filters are realized as a cascade of second + order sections. numStages refers to the number of second order + stages used. For example, an 8th order filter would be realized with + numStages=4 second order stages. A 9th order filter would be + realized with numStages=5 second order stages with the + coefficients for one of the stages configured as a first + order filter (b2=0 and a2=0). @par pState points to the state variable array. - Each Biquad stage has 2 state variables d1 and d2. - The state variables are arranged in the pState array as: -
-      {d11, d12, d21, d22, ...}
+                   Each Biquad stage has 2 state variables d1 and
+  d2. The state variables are arranged in the pState
+  array as: 
 {d11, d12, d21, d22, ...}
   
- where d1x refers to the state variables for the first Biquad and - d2x refers to the state variables for the second Biquad. - The state array has a total length of 2*numStages values. - The state variables are updated after each block of data is processed; the coefficients are untouched. + where d1x refers to the state variables for the + first Biquad and d2x refers to the state variables for the second + Biquad. The state array has a total length of 2*numStages values. + The state variables are updated after each block of data is + processed; the coefficients are untouched. @par - The CMSIS library contains Biquad filters in both Direct Form I and transposed Direct Form II. - The advantage of the Direct Form I structure is that it is numerically more robust for fixed-point data types. - That is why the Direct Form I structure supports Q15 and Q31 data types. - The transposed Direct Form II structure, on the other hand, requires a wide dynamic range for the state variables d1 and d2. - Because of this, the CMSIS library only has a floating-point version of the Direct Form II Biquad. - The advantage of the Direct Form II Biquad is that it requires half the number of state variables, 2 rather than 4, per Biquad stage. + The CMSIS library contains Biquad filters in both Direct Form + I and transposed Direct Form II. The advantage of the Direct Form I structure + is that it is numerically more robust for fixed-point data types. That is why + the Direct Form I structure supports Q15 and Q31 data types. The transposed + Direct Form II structure, on the other hand, requires a wide dynamic range for + the state variables d1 and d2. Because of this, the + CMSIS library only has a floating-point version of the Direct Form II Biquad. + The advantage of the Direct Form II Biquad is that it + requires half the number of state variables, 2 rather than 4, per Biquad + stage. @par Instance Structure - The coefficients and state variables for a filter are stored together in an instance data structure. - A separate instance structure must be defined for each filter. - Coefficient arrays may be shared among several instances while state variable arrays cannot be shared. + The coefficients and state variables for a filter are stored + together in an instance data structure. A separate instance structure must be + defined for each filter. Coefficient arrays may be shared among several + instances while state variable arrays cannot be shared. @par Init Functions There is also an associated initialization function. The initialization function performs following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. - To do this manually without calling the init function, assign the follow subfields of the instance structure: - numStages, pCoeffs, pState. Also set all of the values in pState to zero. + To do this manually without calling the init function, assign + the follow subfields of the instance structure: numStages, pCoeffs, pState. + Also set all of the values in pState to zero. @par Use of the initialization function is optional. - However, if the initialization function is used, then the instance structure cannot be placed into a const data section. - To place an instance structure into a const data section, the instance structure must be manually initialized. - Set the values in the state buffer to zeros before static initialization. - For example, to statically initialize the instance structure use -
-      arm_biquad_cascade_df2T_instance_f64 S1 = {numStages, pState, pCoeffs};
-      arm_biquad_cascade_df2T_instance_f32 S1 = {numStages, pState, pCoeffs};
+                   However, if the initialization function is used, then the
+  instance structure cannot be placed into a const data section. To place an
+  instance structure into a const data section, the instance structure must be
+  manually initialized. Set the values in the state buffer to zeros before
+  static initialization. For example, to statically initialize the instance
+  structure use 
 arm_biquad_cascade_df2T_instance_f64 S1 = {numStages,
+  pState, pCoeffs}; arm_biquad_cascade_df2T_instance_f32 S1 = {numStages,
+  pState, pCoeffs};
   
- where numStages is the number of Biquad stages in the filter; - pState is the address of the state buffer. - pCoeffs is the address of the coefficient buffer; + where numStages is the number of Biquad stages + in the filter; pState is the address of the state buffer. + pCoeffs is the address of the coefficient + buffer; */ /** @@ -125,7 +139,8 @@ */ /** - @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. + @brief Processing function for the floating-point transposed direct + form II Biquad cascade filter. @param[in] S points to an instance of the filter data structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @@ -134,265 +149,259 @@ */ LOW_OPTIMIZATION_ENTER -void arm_biquad_cascade_df2T_f64( - const arm_biquad_cascade_df2T_instance_f64 * S, - float64_t * pSrc, - float64_t * pDst, - uint32_t blockSize) -{ +void arm_biquad_cascade_df2T_f64(const arm_biquad_cascade_df2T_instance_f64 *S, + float64_t *pSrc, float64_t *pDst, + uint32_t blockSize) { - float64_t *pIn = pSrc; /* Source pointer */ - float64_t *pOut = pDst; /* Destination pointer */ - float64_t *pState = S->pState; /* State pointer */ - float64_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - float64_t acc1; /* Accumulator */ - float64_t b0, b1, b2, a1, a2; /* Filter coefficients */ - float64_t Xn1; /* Temporary input */ - float64_t d1, d2; /* State variables */ - uint32_t sample, stage = S->numStages; /* Loop counters */ + float64_t *pIn = pSrc; /* Source pointer */ + float64_t *pOut = pDst; /* Destination pointer */ + float64_t *pState = S->pState; /* State pointer */ + float64_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + float64_t acc1; /* Accumulator */ + float64_t b0, b1, b2, a1, a2; /* Filter coefficients */ + float64_t Xn1; /* Temporary input */ + float64_t d1, d2; /* State variables */ + uint32_t sample, stage = S->numStages; /* Loop counters */ + do { + /* Reading the coefficients */ + b0 = pCoeffs[0]; + b1 = pCoeffs[1]; + b2 = pCoeffs[2]; + a1 = pCoeffs[3]; + a2 = pCoeffs[4]; - do - { - /* Reading the coefficients */ - b0 = pCoeffs[0]; - b1 = pCoeffs[1]; - b2 = pCoeffs[2]; - a1 = pCoeffs[3]; - a2 = pCoeffs[4]; + /* Reading the state values */ + d1 = pState[0]; + d2 = pState[1]; - /* Reading the state values */ - d1 = pState[0]; - d2 = pState[1]; + pCoeffs += 5U; - pCoeffs += 5U; - -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 16 outputs at a time */ - sample = blockSize >> 4U; + sample = blockSize >> 4U; - while (sample > 0U) { + while (sample > 0U) { - /* y[n] = b0 * x[n] + d1 */ - /* d1 = b1 * x[n] + a1 * y[n] + d2 */ - /* d2 = b2 * x[n] + a2 * y[n] */ + /* y[n] = b0 * x[n] + d1 */ + /* d1 = b1 * x[n] + a1 * y[n] + d2 */ + /* d2 = b2 * x[n] + a2 * y[n] */ -/* 1 */ - Xn1 = *pIn++; + /* 1 */ + Xn1 = *pIn++; - acc1 = b0 * Xn1 + d1; + acc1 = b0 * Xn1 + d1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - *pOut++ = acc1; + *pOut++ = acc1; + /* 2 */ + Xn1 = *pIn++; -/* 2 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 3 */ + Xn1 = *pIn++; -/* 3 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 4 */ + Xn1 = *pIn++; -/* 4 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 5 */ + Xn1 = *pIn++; -/* 5 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 6 */ + Xn1 = *pIn++; -/* 6 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 7 */ + Xn1 = *pIn++; -/* 7 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 8 */ + Xn1 = *pIn++; -/* 8 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 9 */ + Xn1 = *pIn++; -/* 9 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 10 */ + Xn1 = *pIn++; -/* 10 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 11 */ + Xn1 = *pIn++; -/* 11 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 12 */ + Xn1 = *pIn++; -/* 12 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 13 */ + Xn1 = *pIn++; -/* 13 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 14 */ + Xn1 = *pIn++; -/* 14 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 15 */ + Xn1 = *pIn++; -/* 15 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; + /* 16 */ + Xn1 = *pIn++; -/* 16 */ - Xn1 = *pIn++; + acc1 = b0 * Xn1 + d1; - acc1 = b0 * Xn1 + d1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + *pOut++ = acc1; - *pOut++ = acc1; - - /* decrement loop counter */ - sample--; - } + /* decrement loop counter */ + sample--; + } /* Loop unrolling: Compute remaining outputs */ - sample = blockSize & 0xFU; + sample = blockSize & 0xFU; #else @@ -401,40 +410,39 @@ void arm_biquad_cascade_df2T_f64( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (sample > 0U) { - Xn1 = *pIn++; + while (sample > 0U) { + Xn1 = *pIn++; - acc1 = b0 * Xn1 + d1; + acc1 = b0 * Xn1 + d1; - d1 = b1 * Xn1 + d2; - d1 += a1 * acc1; + d1 = b1 * Xn1 + d2; + d1 += a1 * acc1; - d2 = b2 * Xn1; - d2 += a2 * acc1; + d2 = b2 * Xn1; + d2 += a2 * acc1; - *pOut++ = acc1; - - /* decrement loop counter */ - sample--; - } - - /* Store the updated state variables back into the state array */ - pState[0] = d1; - pState[1] = d2; - - pState += 2U; - - /* The current stage input is given as the output to the next stage */ - pIn = pDst; - - /* Reset the output working pointer */ - pOut = pDst; + *pOut++ = acc1; /* decrement loop counter */ - stage--; + sample--; + } - } while (stage > 0U); + /* Store the updated state variables back into the state array */ + pState[0] = d1; + pState[1] = d2; + pState += 2U; + + /* The current stage input is given as the output to the next stage */ + pIn = pDst; + + /* Reset the output working pointer */ + pOut = pDst; + + /* decrement loop counter */ + stage--; + + } while (stage > 0U); } LOW_OPTIMIZATION_EXIT diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df2T_init_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df2T_init_f32.c index 33b7f18..e1ee03d 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df2T_init_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df2T_init_f32.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df2T_init_f32.c - * Description: Initialization function for floating-point transposed direct form II Biquad cascade filter + * Description: Initialization function for floating-point transposed direct + * form II Biquad cascade filter * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -38,7 +39,8 @@ */ /** - @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter. + @brief Initialization function for the floating-point transposed + direct form II Biquad cascade filter. @param[in,out] S points to an instance of the filter data structure. @param[in] numStages number of 2nd order stages in the filter. @param[in] pCoeffs points to the filter coefficients. @@ -46,28 +48,28 @@ @return none @par Coefficient and State Ordering - The coefficients are stored in the array pCoeffs in the following order: -
-      {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...}
+                   The coefficients are stored in the array pCoeffs
+  in the following order: 
 {b10, b11, b12, a11, a12, b20, b21, b22, a21,
+  a22, ...}
   
@par - where b1x and a1x are the coefficients for the first stage, - b2x and a2x are the coefficients for the second stage, - and so on. The pCoeffs array contains a total of 5*numStages values. + where b1x and a1x are the + coefficients for the first stage, b2x and a2x are + the coefficients for the second stage, and so on. The pCoeffs + array contains a total of 5*numStages values. @par The pState is a pointer to state array. - Each Biquad stage has 2 state variables d1, and d2. - The 2 state variables for stage 1 are first, then the 2 state variables for stage 2, and so on. - The state array has a total length of 2*numStages values. - The state variables are updated after each block of data is processed; the coefficients are untouched. + Each Biquad stage has 2 state variables d1, and + d2. The 2 state variables for stage 1 are first, then the 2 state + variables for stage 2, and so on. The state array has a total length of + 2*numStages values. The state variables are updated after each + block of data is processed; the coefficients are untouched. */ -void arm_biquad_cascade_df2T_init_f32( - arm_biquad_cascade_df2T_instance_f32 * S, - uint8_t numStages, - const float32_t * pCoeffs, - float32_t * pState) -{ +void arm_biquad_cascade_df2T_init_f32(arm_biquad_cascade_df2T_instance_f32 *S, + uint8_t numStages, + const float32_t *pCoeffs, + float32_t *pState) { /* Assign filter stages */ S->numStages = numStages; @@ -75,7 +77,7 @@ void arm_biquad_cascade_df2T_init_f32( S->pCoeffs = pCoeffs; /* Clear state buffer and size is always 2 * numStages */ - memset(pState, 0, (2U * (uint32_t) numStages) * sizeof(float32_t)); + memset(pState, 0, (2U * (uint32_t)numStages) * sizeof(float32_t)); /* Assign state pointer */ S->pState = pState; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df2T_init_f64.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df2T_init_f64.c index fe6901e..2505266 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df2T_init_f64.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_df2T_init_f64.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df2T_init_f64.c - * Description: Initialization function for floating-point transposed direct form II Biquad cascade filter + * Description: Initialization function for floating-point transposed direct + * form II Biquad cascade filter * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -38,7 +39,8 @@ */ /** - @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter. + @brief Initialization function for the floating-point transposed + direct form II Biquad cascade filter. @param[in,out] S points to an instance of the filter data structure @param[in] numStages number of 2nd order stages in the filter @param[in] pCoeffs points to the filter coefficients @@ -46,28 +48,27 @@ @return none @par Coefficient and State Ordering - The coefficients are stored in the array pCoeffs in the following order: -
-      {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...}
+                   The coefficients are stored in the array pCoeffs
+  in the following order: 
 {b10, b11, b12, a11, a12, b20, b21, b22, a21,
+  a22, ...}
   
@par - where b1x and a1x are the coefficients for the first stage, - b2x and a2x are the coefficients for the second stage, - and so on. The pCoeffs array contains a total of 5*numStages values. + where b1x and a1x are the + coefficients for the first stage, b2x and a2x are + the coefficients for the second stage, and so on. The pCoeffs + array contains a total of 5*numStages values. @par The pState is a pointer to state array. - Each Biquad stage has 2 state variables d1, and d2. - The 2 state variables for stage 1 are first, then the 2 state variables for stage 2, and so on. - The state array has a total length of 2*numStages values. - The state variables are updated after each block of data is processed; the coefficients are untouched. + Each Biquad stage has 2 state variables d1, and + d2. The 2 state variables for stage 1 are first, then the 2 state + variables for stage 2, and so on. The state array has a total length of + 2*numStages values. The state variables are updated after each + block of data is processed; the coefficients are untouched. */ -void arm_biquad_cascade_df2T_init_f64( - arm_biquad_cascade_df2T_instance_f64 * S, - uint8_t numStages, - float64_t * pCoeffs, - float64_t * pState) -{ +void arm_biquad_cascade_df2T_init_f64(arm_biquad_cascade_df2T_instance_f64 *S, + uint8_t numStages, float64_t *pCoeffs, + float64_t *pState) { /* Assign filter stages */ S->numStages = numStages; @@ -75,7 +76,7 @@ void arm_biquad_cascade_df2T_init_f64( S->pCoeffs = pCoeffs; /* Clear state buffer and size is always 2 * numStages */ - memset(pState, 0, (2U * (uint32_t) numStages) * sizeof(float64_t)); + memset(pState, 0, (2U * (uint32_t)numStages) * sizeof(float64_t)); /* Assign state pointer */ S->pState = pState; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_stereo_df2T_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_stereo_df2T_f32.c index d6be426..c9d8631 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_stereo_df2T_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_stereo_df2T_f32.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_stereo_df2T_f32.c - * Description: Processing function for floating-point transposed direct form II Biquad cascade filter. 2 channels + * Description: Processing function for floating-point transposed direct form + * II Biquad cascade filter. 2 channels * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -38,7 +39,8 @@ */ /** - @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. + @brief Processing function for the floating-point transposed direct + form II Biquad cascade filter. @param[in] S points to an instance of the filter data structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @@ -48,236 +50,231 @@ LOW_OPTIMIZATION_ENTER void arm_biquad_cascade_stereo_df2T_f32( - const arm_biquad_cascade_stereo_df2T_instance_f32 * S, - const float32_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - const float32_t *pIn = pSrc; /* Source pointer */ - float32_t *pOut = pDst; /* Destination pointer */ - float32_t *pState = S->pState; /* State pointer */ - const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - float32_t acc1a, acc1b; /* Accumulator */ - float32_t b0, b1, b2, a1, a2; /* Filter coefficients */ - float32_t Xn1a, Xn1b; /* Temporary input */ - float32_t d1a, d2a, d1b, d2b; /* State variables */ - uint32_t sample, stage = S->numStages; /* Loop counters */ + const arm_biquad_cascade_stereo_df2T_instance_f32 *S, const float32_t *pSrc, + float32_t *pDst, uint32_t blockSize) { + const float32_t *pIn = pSrc; /* Source pointer */ + float32_t *pOut = pDst; /* Destination pointer */ + float32_t *pState = S->pState; /* State pointer */ + const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + float32_t acc1a, acc1b; /* Accumulator */ + float32_t b0, b1, b2, a1, a2; /* Filter coefficients */ + float32_t Xn1a, Xn1b; /* Temporary input */ + float32_t d1a, d2a, d1b, d2b; /* State variables */ + uint32_t sample, stage = S->numStages; /* Loop counters */ - do - { - /* Reading the coefficients */ - b0 = pCoeffs[0]; - b1 = pCoeffs[1]; - b2 = pCoeffs[2]; - a1 = pCoeffs[3]; - a2 = pCoeffs[4]; + do { + /* Reading the coefficients */ + b0 = pCoeffs[0]; + b1 = pCoeffs[1]; + b2 = pCoeffs[2]; + a1 = pCoeffs[3]; + a2 = pCoeffs[4]; - /* Reading the state values */ - d1a = pState[0]; - d2a = pState[1]; - d1b = pState[2]; - d2b = pState[3]; + /* Reading the state values */ + d1a = pState[0]; + d2a = pState[1]; + d1b = pState[2]; + d2b = pState[3]; - pCoeffs += 5U; + pCoeffs += 5U; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 8 outputs at a time */ - sample = blockSize >> 3U; + sample = blockSize >> 3U; - while (sample > 0U) { - /* y[n] = b0 * x[n] + d1 */ - /* d1 = b1 * x[n] + a1 * y[n] + d2 */ - /* d2 = b2 * x[n] + a2 * y[n] */ + while (sample > 0U) { + /* y[n] = b0 * x[n] + d1 */ + /* d1 = b1 * x[n] + a1 * y[n] + d2 */ + /* d2 = b2 * x[n] + a2 * y[n] */ -/* 1 */ - Xn1a = *pIn++; /* Channel a */ - Xn1b = *pIn++; /* Channel b */ + /* 1 */ + Xn1a = *pIn++; /* Channel a */ + Xn1b = *pIn++; /* Channel b */ - acc1a = (b0 * Xn1a) + d1a; - acc1b = (b0 * Xn1b) + d1b; + acc1a = (b0 * Xn1a) + d1a; + acc1b = (b0 * Xn1b) + d1b; - *pOut++ = acc1a; - *pOut++ = acc1b; + *pOut++ = acc1a; + *pOut++ = acc1b; - d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; - d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; + d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; + d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; - d2a = (b2 * Xn1a) + (a2 * acc1a); - d2b = (b2 * Xn1b) + (a2 * acc1b); + d2a = (b2 * Xn1a) + (a2 * acc1a); + d2b = (b2 * Xn1b) + (a2 * acc1b); -/* 2 */ - Xn1a = *pIn++; /* Channel a */ - Xn1b = *pIn++; /* Channel b */ + /* 2 */ + Xn1a = *pIn++; /* Channel a */ + Xn1b = *pIn++; /* Channel b */ - acc1a = (b0 * Xn1a) + d1a; - acc1b = (b0 * Xn1b) + d1b; + acc1a = (b0 * Xn1a) + d1a; + acc1b = (b0 * Xn1b) + d1b; - *pOut++ = acc1a; - *pOut++ = acc1b; + *pOut++ = acc1a; + *pOut++ = acc1b; - d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; - d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; + d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; + d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; - d2a = (b2 * Xn1a) + (a2 * acc1a); - d2b = (b2 * Xn1b) + (a2 * acc1b); + d2a = (b2 * Xn1a) + (a2 * acc1a); + d2b = (b2 * Xn1b) + (a2 * acc1b); -/* 3 */ - Xn1a = *pIn++; /* Channel a */ - Xn1b = *pIn++; /* Channel b */ + /* 3 */ + Xn1a = *pIn++; /* Channel a */ + Xn1b = *pIn++; /* Channel b */ - acc1a = (b0 * Xn1a) + d1a; - acc1b = (b0 * Xn1b) + d1b; + acc1a = (b0 * Xn1a) + d1a; + acc1b = (b0 * Xn1b) + d1b; - *pOut++ = acc1a; - *pOut++ = acc1b; + *pOut++ = acc1a; + *pOut++ = acc1b; - d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; - d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; + d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; + d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; - d2a = (b2 * Xn1a) + (a2 * acc1a); - d2b = (b2 * Xn1b) + (a2 * acc1b); + d2a = (b2 * Xn1a) + (a2 * acc1a); + d2b = (b2 * Xn1b) + (a2 * acc1b); -/* 4 */ - Xn1a = *pIn++; /* Channel a */ - Xn1b = *pIn++; /* Channel b */ + /* 4 */ + Xn1a = *pIn++; /* Channel a */ + Xn1b = *pIn++; /* Channel b */ - acc1a = (b0 * Xn1a) + d1a; - acc1b = (b0 * Xn1b) + d1b; + acc1a = (b0 * Xn1a) + d1a; + acc1b = (b0 * Xn1b) + d1b; - *pOut++ = acc1a; - *pOut++ = acc1b; + *pOut++ = acc1a; + *pOut++ = acc1b; - d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; - d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; + d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; + d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; - d2a = (b2 * Xn1a) + (a2 * acc1a); - d2b = (b2 * Xn1b) + (a2 * acc1b); + d2a = (b2 * Xn1a) + (a2 * acc1a); + d2b = (b2 * Xn1b) + (a2 * acc1b); -/* 5 */ - Xn1a = *pIn++; /* Channel a */ - Xn1b = *pIn++; /* Channel b */ + /* 5 */ + Xn1a = *pIn++; /* Channel a */ + Xn1b = *pIn++; /* Channel b */ - acc1a = (b0 * Xn1a) + d1a; - acc1b = (b0 * Xn1b) + d1b; + acc1a = (b0 * Xn1a) + d1a; + acc1b = (b0 * Xn1b) + d1b; - *pOut++ = acc1a; - *pOut++ = acc1b; + *pOut++ = acc1a; + *pOut++ = acc1b; - d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; - d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; + d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; + d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; - d2a = (b2 * Xn1a) + (a2 * acc1a); - d2b = (b2 * Xn1b) + (a2 * acc1b); + d2a = (b2 * Xn1a) + (a2 * acc1a); + d2b = (b2 * Xn1b) + (a2 * acc1b); -/* 6 */ - Xn1a = *pIn++; /* Channel a */ - Xn1b = *pIn++; /* Channel b */ + /* 6 */ + Xn1a = *pIn++; /* Channel a */ + Xn1b = *pIn++; /* Channel b */ - acc1a = (b0 * Xn1a) + d1a; - acc1b = (b0 * Xn1b) + d1b; + acc1a = (b0 * Xn1a) + d1a; + acc1b = (b0 * Xn1b) + d1b; - *pOut++ = acc1a; - *pOut++ = acc1b; + *pOut++ = acc1a; + *pOut++ = acc1b; - d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; - d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; + d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; + d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; - d2a = (b2 * Xn1a) + (a2 * acc1a); - d2b = (b2 * Xn1b) + (a2 * acc1b); + d2a = (b2 * Xn1a) + (a2 * acc1a); + d2b = (b2 * Xn1b) + (a2 * acc1b); -/* 7 */ - Xn1a = *pIn++; /* Channel a */ - Xn1b = *pIn++; /* Channel b */ + /* 7 */ + Xn1a = *pIn++; /* Channel a */ + Xn1b = *pIn++; /* Channel b */ - acc1a = (b0 * Xn1a) + d1a; - acc1b = (b0 * Xn1b) + d1b; + acc1a = (b0 * Xn1a) + d1a; + acc1b = (b0 * Xn1b) + d1b; - *pOut++ = acc1a; - *pOut++ = acc1b; + *pOut++ = acc1a; + *pOut++ = acc1b; - d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; - d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; + d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; + d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; - d2a = (b2 * Xn1a) + (a2 * acc1a); - d2b = (b2 * Xn1b) + (a2 * acc1b); + d2a = (b2 * Xn1a) + (a2 * acc1a); + d2b = (b2 * Xn1b) + (a2 * acc1b); -/* 8 */ - Xn1a = *pIn++; /* Channel a */ - Xn1b = *pIn++; /* Channel b */ + /* 8 */ + Xn1a = *pIn++; /* Channel a */ + Xn1b = *pIn++; /* Channel b */ - acc1a = (b0 * Xn1a) + d1a; - acc1b = (b0 * Xn1b) + d1b; + acc1a = (b0 * Xn1a) + d1a; + acc1b = (b0 * Xn1b) + d1b; - *pOut++ = acc1a; - *pOut++ = acc1b; + *pOut++ = acc1a; + *pOut++ = acc1b; - d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; - d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; + d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; + d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; - d2a = (b2 * Xn1a) + (a2 * acc1a); - d2b = (b2 * Xn1b) + (a2 * acc1b); + d2a = (b2 * Xn1a) + (a2 * acc1a); + d2b = (b2 * Xn1b) + (a2 * acc1b); - /* decrement loop counter */ - sample--; - } + /* decrement loop counter */ + sample--; + } - /* Loop unrolling: Compute remaining outputs */ - sample = blockSize & 0x7U; + /* Loop unrolling: Compute remaining outputs */ + sample = blockSize & 0x7U; #else - /* Initialize blkCnt with number of samples */ - sample = blockSize; + /* Initialize blkCnt with number of samples */ + sample = blockSize; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (sample > 0U) { - /* Read the input */ - Xn1a = *pIn++; /* Channel a */ - Xn1b = *pIn++; /* Channel b */ + while (sample > 0U) { + /* Read the input */ + Xn1a = *pIn++; /* Channel a */ + Xn1b = *pIn++; /* Channel b */ - /* y[n] = b0 * x[n] + d1 */ - acc1a = (b0 * Xn1a) + d1a; - acc1b = (b0 * Xn1b) + d1b; + /* y[n] = b0 * x[n] + d1 */ + acc1a = (b0 * Xn1a) + d1a; + acc1b = (b0 * Xn1b) + d1b; - /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = acc1a; - *pOut++ = acc1b; + /* Store the result in the accumulator in the destination buffer. */ + *pOut++ = acc1a; + *pOut++ = acc1b; - /* Every time after the output is computed state should be updated. */ - /* d1 = b1 * x[n] + a1 * y[n] + d2 */ - d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; - d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; + /* Every time after the output is computed state should be updated. */ + /* d1 = b1 * x[n] + a1 * y[n] + d2 */ + d1a = ((b1 * Xn1a) + (a1 * acc1a)) + d2a; + d1b = ((b1 * Xn1b) + (a1 * acc1b)) + d2b; - /* d2 = b2 * x[n] + a2 * y[n] */ - d2a = (b2 * Xn1a) + (a2 * acc1a); - d2b = (b2 * Xn1b) + (a2 * acc1b); + /* d2 = b2 * x[n] + a2 * y[n] */ + d2a = (b2 * Xn1a) + (a2 * acc1a); + d2b = (b2 * Xn1b) + (a2 * acc1b); - /* decrement loop counter */ - sample--; - } + /* decrement loop counter */ + sample--; + } - /* Store the updated state variables back into the state array */ - pState[0] = d1a; - pState[1] = d2a; + /* Store the updated state variables back into the state array */ + pState[0] = d1a; + pState[1] = d2a; - pState[2] = d1b; - pState[3] = d2b; + pState[2] = d1b; + pState[3] = d2b; - pState += 4U; + pState += 4U; - /* The current stage input is given as the output to the next stage */ - pIn = pDst; + /* The current stage input is given as the output to the next stage */ + pIn = pDst; - /* Reset the output working pointer */ - pOut = pDst; + /* Reset the output working pointer */ + pOut = pDst; - /* decrement the loop counter */ - stage--; - - } while (stage > 0U); + /* decrement the loop counter */ + stage--; + } while (stage > 0U); } LOW_OPTIMIZATION_EXIT diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_stereo_df2T_init_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_stereo_df2T_init_f32.c index d398f18..3a6a0b4 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_stereo_df2T_init_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_biquad_cascade_stereo_df2T_init_f32.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_biquad_cascade_stereo_df2T_init_f32.c - * Description: Initialization function for floating-point transposed direct form II Biquad cascade filter + * Description: Initialization function for floating-point transposed direct + * form II Biquad cascade filter * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -38,7 +39,8 @@ */ /** - @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter. + @brief Initialization function for the floating-point transposed + direct form II Biquad cascade filter. @param[in,out] S points to an instance of the filter data structure. @param[in] numStages number of 2nd order stages in the filter. @param[in] pCoeffs points to the filter coefficients. @@ -46,28 +48,27 @@ @return none @par Coefficient and State Ordering - The coefficients are stored in the array pCoeffs in the following order: -
-      {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...}
+                   The coefficients are stored in the array pCoeffs
+  in the following order: 
 {b10, b11, b12, a11, a12, b20, b21, b22, a21,
+  a22, ...}
   
@par - where b1x and a1x are the coefficients for the first stage, - b2x and a2x are the coefficients for the second stage, - and so on. The pCoeffs array contains a total of 5*numStages values. + where b1x and a1x are the + coefficients for the first stage, b2x and a2x are + the coefficients for the second stage, and so on. The pCoeffs + array contains a total of 5*numStages values. @par The pState is a pointer to state array. - Each Biquad stage has 2 state variables d1, and d2 for each channel. - The 2 state variables for stage 1 are first, then the 2 state variables for stage 2, and so on. - The state array has a total length of 2*numStages values. - The state variables are updated after each block of data is processed; the coefficients are untouched. + Each Biquad stage has 2 state variables d1, and + d2 for each channel. The 2 state variables for stage 1 are first, + then the 2 state variables for stage 2, and so on. The state array has a total + length of 2*numStages values. The state variables are updated + after each block of data is processed; the coefficients are untouched. */ void arm_biquad_cascade_stereo_df2T_init_f32( - arm_biquad_cascade_stereo_df2T_instance_f32 * S, - uint8_t numStages, - const float32_t * pCoeffs, - float32_t * pState) -{ + arm_biquad_cascade_stereo_df2T_instance_f32 *S, uint8_t numStages, + const float32_t *pCoeffs, float32_t *pState) { /* Assign filter stages */ S->numStages = numStages; @@ -75,7 +76,7 @@ void arm_biquad_cascade_stereo_df2T_init_f32( S->pCoeffs = pCoeffs; /* Clear state buffer and size is always 4 * numStages */ - memset(pState, 0, (4U * (uint32_t) numStages) * sizeof(float32_t)); + memset(pState, 0, (4U * (uint32_t)numStages) * sizeof(float32_t)); /* Assign state pointer */ S->pState = pState; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_f32.c index 4786b5b..93d9c80 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_f32.c @@ -35,49 +35,59 @@ /** @defgroup Conv Convolution - Convolution is a mathematical operation that operates on two finite length vectors to generate a finite length output vector. - Convolution is similar to correlation and is frequently used in filtering and data analysis. - The CMSIS DSP library contains functions for convolving Q7, Q15, Q31, and floating-point data types. - The library also provides fast versions of the Q15 and Q31 functions. + Convolution is a mathematical operation that operates on two finite length + vectors to generate a finite length output vector. Convolution is similar to + correlation and is frequently used in filtering and data analysis. The CMSIS + DSP library contains functions for convolving Q7, Q15, Q31, and floating-point + data types. The library also provides fast versions of the Q15 and Q31 + functions. @par Algorithm - Let a[n] and b[n] be sequences of length srcALen and - srcBLen samples respectively. Then the convolution -
-     c[n] = a[n] * b[n]
+                   Let a[n] and b[n] be sequences of
+ length srcALen and srcBLen samples respectively. Then
+ the convolution 
 c[n] = a[n] * b[n]
   
@par is defined as \image html ConvolutionEquation.gif @par - Note that c[n] is of length srcALen + srcBLen - 1 and is defined over the interval n=0, 1, 2, ..., srcALen + srcBLen - 2. - pSrcA points to the first input vector of length srcALen and - pSrcB points to the second input vector of length srcBLen. - The output result is written to pDst and the calling function must allocate srcALen+srcBLen-1 words for the result. + Note that c[n] is of length srcALen + + srcBLen - 1 and is defined over the interval n=0, 1, 2, ..., + srcALen + srcBLen - 2. pSrcA points to the first input + vector of length srcALen and pSrcB points to the + second input vector of length srcBLen. The output result is + written to pDst and the calling function must allocate + srcALen+srcBLen-1 words for the result. @par - Conceptually, when two signals a[n] and b[n] are convolved, - the signal b[n] slides over a[n]. - For each offset \c n, the overlapping portions of a[n] and b[n] are multiplied and summed together. + Conceptually, when two signals a[n] and + b[n] are convolved, the signal b[n] slides over + a[n]. For each offset \c n, the overlapping portions of a[n] and + b[n] are multiplied and summed together. @par Note that convolution is a commutative operation:
      a[n] * b[n] = b[n] * a[n].
   
@par - This means that switching the A and B arguments to the convolution functions has no effect. + This means that switching the A and B arguments to the + convolution functions has no effect. @par Fixed-Point Behavior - Convolution requires summing up a large number of intermediate products. - As such, the Q7, Q15, and Q31 functions run a risk of overflow and saturation. - Refer to the function specific documentation below for further details of the particular algorithm used. + Convolution requires summing up a large number of + intermediate products. As such, the Q7, Q15, and Q31 functions run a risk of + overflow and saturation. Refer to the function specific documentation below for + further details of the particular algorithm used. @par Fast Versions - Fast versions are supported for Q31 and Q15. Cycles for Fast versions are less compared to Q31 and Q15 of conv and the design requires - the input signals should be scaled down to avoid intermediate overflows. + Fast versions are supported for Q31 and Q15. Cycles for Fast + versions are less compared to Q31 and Q15 of conv and the design requires the + input signals should be scaled down to avoid intermediate overflows. @par Opt Versions - Opt versions are supported for Q15 and Q7. Design uses internal scratch buffer for getting good optimisation. - These versions are optimised in cycles and consumes more memory (Scratch memory) compared to Q15 and Q7 versions + Opt versions are supported for Q15 and Q7. Design uses + internal scratch buffer for getting good optimisation. These versions are + optimised in cycles and consumes more memory (Scratch memory) compared to Q15 + and Q7 versions */ /** @@ -91,49 +101,43 @@ @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence - @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1. + @param[out] pDst points to the location where the output result is + written. Length srcALen+srcBLen-1. @return none */ -void arm_conv_f32( - const float32_t * pSrcA, - uint32_t srcALen, - const float32_t * pSrcB, - uint32_t srcBLen, - float32_t * pDst) -{ +void arm_conv_f32(const float32_t *pSrcA, uint32_t srcALen, + const float32_t *pSrcB, uint32_t srcBLen, float32_t *pDst) { #if (1) -//#if !defined(ARM_MATH_CM0_FAMILY) + //#if !defined(ARM_MATH_CM0_FAMILY) - const float32_t *pIn1; /* InputA pointer */ - const float32_t *pIn2; /* InputB pointer */ - float32_t *pOut = pDst; /* Output pointer */ - const float32_t *px; /* Intermediate inputA pointer */ - const float32_t *py; /* Intermediate inputB pointer */ - const float32_t *pSrc1, *pSrc2; /* Intermediate pointers */ - float32_t sum; /* Accumulators */ - uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ - uint32_t j, k, count, blkCnt; /* Loop counters */ + const float32_t *pIn1; /* InputA pointer */ + const float32_t *pIn2; /* InputB pointer */ + float32_t *pOut = pDst; /* Output pointer */ + const float32_t *px; /* Intermediate inputA pointer */ + const float32_t *py; /* Intermediate inputB pointer */ + const float32_t *pSrc1, *pSrc2; /* Intermediate pointers */ + float32_t sum; /* Accumulators */ + uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ + uint32_t j, k, count, blkCnt; /* Loop counters */ -#if defined (ARM_MATH_LOOPUNROLL) - float32_t acc0, acc1, acc2, acc3; /* Accumulators */ - float32_t x0, x1, x2, x3, c0; /* Temporary variables to hold state and coefficient values */ +#if defined(ARM_MATH_LOOPUNROLL) + float32_t acc0, acc1, acc2, acc3; /* Accumulators */ + float32_t x0, x1, x2, x3, + c0; /* Temporary variables to hold state and coefficient values */ #endif /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ - if (srcALen >= srcBLen) - { + if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; - } - else - { + } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; @@ -146,14 +150,15 @@ void arm_conv_f32( srcALen = j; } - /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ x[n-N+1] * y[N -1] */ + /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ + * x[n-N+1] * y[N -1] */ /* The function is internally - * divided into three stages according to the number of multiplications that has to be - * taken place between inputA samples and inputB samples. In the first stage of the - * algorithm, the multiplications increase by one for every iteration. - * In the second stage of the algorithm, srcBLen number of multiplications are done. - * In the third stage of the algorithm, the multiplications decrease by one - * for every iteration. */ + * divided into three stages according to the number of multiplications that + * has to be taken place between inputA samples and inputB samples. In the + * first stage of the algorithm, the multiplications increase by one for every + * iteration. In the second stage of the algorithm, srcBLen number of + * multiplications are done. In the third stage of the algorithm, the + * multiplications decrease by one for every iteration. */ /* The algorithm is implemented in three stages. The loop counters of each stage is initiated here. */ @@ -168,7 +173,8 @@ void arm_conv_f32( /* sum = x[0] * y[0] * sum = x[0] * y[1] + x[1] * y[0] * .... - * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * y[0] + * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * + * y[0] */ /* In this stage the MAC operations are increased by 1 for every iteration. @@ -181,24 +187,21 @@ void arm_conv_f32( /* Working pointer of inputB */ py = pIn2; - /* ------------------------ * Stage1 process * ----------------------*/ /* The first stage starts here */ - while (blockSize1 > 0U) - { + while (blockSize1 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0.0f; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = count >> 2U; - while (k > 0U) - { + while (k > 0U) { /* x[0] * y[srcBLen - 1] */ sum += *px++ * *py--; @@ -225,8 +228,7 @@ void arm_conv_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ sum += *px++ * *py--; @@ -255,7 +257,8 @@ void arm_conv_f32( /* sum = x[0] * y[srcBLen-1] + x[1] * y[srcBLen-2] +...+ x[srcBLen-1] * y[0] * sum = x[1] * y[srcBLen-1] + x[2] * y[srcBLen-2] +...+ x[srcBLen] * y[0] * .... - * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ x[srcALen-1] * y[0] + * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ + * x[srcALen-1] * y[0] */ /* Working pointer of inputA */ @@ -272,18 +275,16 @@ void arm_conv_f32( * Stage2 process * ------------------*/ - /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed. - * So, to loop unroll over blockSize2, - * srcBLen should be greater than or equal to 4 */ - if (srcBLen >= 4U) - { -#if defined (ARM_MATH_LOOPUNROLL) + /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are + * performed. So, to loop unroll over blockSize2, srcBLen should be greater + * than or equal to 4 */ + if (srcBLen >= 4U) { +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize2 >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Set all accumulators to zero */ acc0 = 0.0f; acc1 = 0.0f; @@ -298,10 +299,10 @@ void arm_conv_f32( /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = srcBLen >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. + /* First part of the processing with loop unrolling. Compute 4 MACs at a + *time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - do - { + do { /* Read y[srcBLen - 1] sample */ c0 = *py--; /* Read x[3] sample */ @@ -369,8 +370,7 @@ void arm_conv_f32( ** No loop unrolling is used. */ k = srcBLen % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* Read y[srcBLen - 5] sample */ c0 = *py--; /* Read x[7] sample */ @@ -422,18 +422,16 @@ void arm_conv_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0.0f; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) - /* Loop unrolling: Compute 4 outputs at a time */ + /* Loop unrolling: Compute 4 outputs at a time */ k = srcBLen >> 2U; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ sum += *px++ * *py--; sum += *px++ * *py--; @@ -454,8 +452,7 @@ void arm_conv_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ sum += *px++ * *py--; @@ -476,23 +473,19 @@ void arm_conv_f32( /* Decrement the loop counter */ blkCnt--; } - } - else - { + } else { /* If the srcBLen is not a multiple of 4, * the blockSize2 loop cannot be unrolled by 4 */ blkCnt = blockSize2; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0.0f; /* srcBLen number of MACS should be performed */ k = srcBLen; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ sum += *px++ * *py--; @@ -515,13 +508,14 @@ void arm_conv_f32( } } - /* -------------------------- * Initializations of stage3 * -------------------------*/ - /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * y[srcBLen-2] +...+ x[srcALen-1] * y[1] - * sum += x[srcALen-srcBLen+2] * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * y[2] + /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * + * y[srcBLen-2] +...+ x[srcALen-1] * y[1] sum += x[srcALen-srcBLen+2] * + * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * + * y[2] * .... * sum += x[srcALen-2] * y[srcBLen-1] + x[srcALen-1] * y[srcBLen-2] * sum += x[srcALen-1] * y[srcBLen-1] @@ -542,18 +536,16 @@ void arm_conv_f32( * Stage3 process * ------------------*/ - while (blockSize3 > 0U) - { + while (blockSize3 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0.0f; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = blockSize3 >> 2U; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ /* sum += x[srcALen - srcBLen + 1] * y[srcBLen - 1] */ sum += *px++ * *py--; @@ -581,8 +573,7 @@ void arm_conv_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ /* sum += x[srcALen-1] * y[srcBLen-1] */ sum += *px++ * *py--; @@ -603,27 +594,24 @@ void arm_conv_f32( } #else -/* alternate version for CM0_FAMILY */ + /* alternate version for CM0_FAMILY */ - const float32_t *pIn1 = pSrcA; /* InputA pointer */ - const float32_t *pIn2 = pSrcB; /* InputB pointer */ - float32_t sum; /* Accumulator */ - uint32_t i, j; /* Loop counters */ + const float32_t *pIn1 = pSrcA; /* InputA pointer */ + const float32_t *pIn2 = pSrcB; /* InputB pointer */ + float32_t sum; /* Accumulator */ + uint32_t i, j; /* Loop counters */ /* Loop to calculate convolution for output length number of times */ - for (i = 0U; i < (srcALen + srcBLen - 1U); i++) - { + for (i = 0U; i < (srcALen + srcBLen - 1U); i++) { /* Initialize sum with zero to carry out MAC operations */ sum = 0.0f; /* Loop to perform MAC operations according to convolution equation */ - for (j = 0U; j <= i; j++) - { + for (j = 0U; j <= i; j++) { /* Check the array limitations */ - if (((i - j) < srcBLen) && (j < srcALen)) - { + if (((i - j) < srcBLen) && (j < srcALen)) { /* z[i] += x[i-j] * y[j] */ - sum += ( pIn1[j] * pIn2[i - j]); + sum += (pIn1[j] * pIn2[i - j]); } } @@ -632,7 +620,6 @@ void arm_conv_f32( } #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */ - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_fast_opt_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_fast_opt_q15.c index ed2aea9..e87e88d 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_fast_opt_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_fast_opt_q15.c @@ -43,65 +43,62 @@ @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence - @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1 - @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2 - @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen + @param[out] pDst points to the location where the output result is + written. Length srcALen+srcBLen-1 + @param[in] pScratch1 points to scratch buffer of size max(srcALen, + srcBLen) + 2*min(srcALen, srcBLen) - 2 + @param[in] pScratch2 points to scratch buffer of size min(srcALen, + srcBLen @return none @par Scaling and Overflow Behavior This fast version uses a 32-bit accumulator with 2.30 format. - The accumulator maintains full precision of the intermediate multiplication results - but provides only a single guard bit. There is no saturation on intermediate additions. - Thus, if the accumulator overflows it wraps around and distorts the result. - The input signals should be scaled down to avoid intermediate overflows. - Scale down the inputs by log2(min(srcALen, srcBLen)) (log2 is read as log to the base 2) times to avoid overflows, - as maximum of min(srcALen, srcBLen) number of additions are carried internally. - The 2.30 accumulator is right shifted by 15 bits and then saturated to 1.15 format to yield the final result. + The accumulator maintains full precision of the intermediate + multiplication results but provides only a single guard bit. There is no + saturation on intermediate additions. Thus, if the accumulator overflows it + wraps around and distorts the result. The input signals should be scaled down + to avoid intermediate overflows. Scale down the inputs by log2(min(srcALen, + srcBLen)) (log2 is read as log to the base 2) times to avoid overflows, as + maximum of min(srcALen, srcBLen) number of additions are carried internally. + The 2.30 accumulator is right shifted by 15 bits and then + saturated to 1.15 format to yield the final result. @remark - Refer to \ref arm_conv_q15() for a slower implementation of this function which uses 64-bit accumulation to avoid wrap around distortion. + Refer to \ref arm_conv_q15() for a slower implementation of + this function which uses 64-bit accumulation to avoid wrap around distortion. */ -void arm_conv_fast_opt_q15( - const q15_t * pSrcA, - uint32_t srcALen, - const q15_t * pSrcB, - uint32_t srcBLen, - q15_t * pDst, - q15_t * pScratch1, - q15_t * pScratch2) -{ - q31_t acc0; /* Accumulators */ - const q15_t *pIn1; /* InputA pointer */ - const q15_t *pIn2; /* InputB pointer */ - q15_t *pOut = pDst; /* Output pointer */ - q15_t *pScr1 = pScratch1; /* Temporary pointer for scratch1 */ - q15_t *pScr2 = pScratch2; /* Temporary pointer for scratch1 */ - const q15_t *px; /* Intermediate inputA pointer */ - q15_t *py; /* Intermediate inputB pointer */ - uint32_t j, k, blkCnt; /* Loop counter */ - uint32_t tapCnt; /* Loop count */ +void arm_conv_fast_opt_q15(const q15_t *pSrcA, uint32_t srcALen, + const q15_t *pSrcB, uint32_t srcBLen, q15_t *pDst, + q15_t *pScratch1, q15_t *pScratch2) { + q31_t acc0; /* Accumulators */ + const q15_t *pIn1; /* InputA pointer */ + const q15_t *pIn2; /* InputB pointer */ + q15_t *pOut = pDst; /* Output pointer */ + q15_t *pScr1 = pScratch1; /* Temporary pointer for scratch1 */ + q15_t *pScr2 = pScratch2; /* Temporary pointer for scratch1 */ + const q15_t *px; /* Intermediate inputA pointer */ + q15_t *py; /* Intermediate inputB pointer */ + uint32_t j, k, blkCnt; /* Loop counter */ + uint32_t tapCnt; /* Loop count */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t acc1, acc2, acc3; /* Accumulators */ - q31_t x1, x2, x3; /* Temporary variables to hold state and coefficient values */ - q31_t y1, y2; /* State variables */ +#if defined(ARM_MATH_LOOPUNROLL) + q31_t acc1, acc2, acc3; /* Accumulators */ + q31_t x1, x2, + x3; /* Temporary variables to hold state and coefficient values */ + q31_t y1, y2; /* State variables */ #endif - /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ - if (srcALen >= srcBLen) - { + if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; - } - else - { + } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; @@ -120,14 +117,14 @@ void arm_conv_fast_opt_q15( /* points to smaller length sequence */ px = pIn2; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = srcBLen >> 2U; - /* Copy smaller length input sequence in reverse order into second scratch buffer */ - while (k > 0U) - { + /* Copy smaller length input sequence in reverse order into second scratch + * buffer */ + while (k > 0U) { /* copy second buffer in reversal manner */ *pScr2-- = *px++; *pScr2-- = *px++; @@ -148,8 +145,7 @@ void arm_conv_fast_opt_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* copy second buffer in reversal manner for remaining samples */ *pScr2-- = *px++; @@ -175,7 +171,6 @@ void arm_conv_fast_opt_q15( /* Update pointers */ pScr1 += srcALen; - /* Fill (srcBLen - 1U) zeros at end of scratch buffer */ arm_fill_q15(0, pScr1, (srcBLen - 1U)); @@ -185,17 +180,15 @@ void arm_conv_fast_opt_q15( /* Temporary pointer for scratch2 */ py = pScratch2; - /* Initialization of pIn2 pointer */ pIn2 = py; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = (srcALen + srcBLen - 1U) >> 2; - while (blkCnt > 0) - { + while (blkCnt > 0) { /* Initialze temporary scratch pointer as scratch1 */ pScr1 = pScratch1; @@ -206,19 +199,18 @@ void arm_conv_fast_opt_q15( acc3 = 0; /* Read two samples from scratch1 buffer */ - x1 = read_q15x2_ia (&pScr1); + x1 = read_q15x2_ia(&pScr1); /* Read next two samples from scratch1 buffer */ - x2 = read_q15x2_ia (&pScr1); + x2 = read_q15x2_ia(&pScr1); tapCnt = (srcBLen) >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read four samples from smaller buffer */ - y1 = read_q15x2_ia ((q15_t **) &pIn2); - y2 = read_q15x2_ia ((q15_t **) &pIn2); + y1 = read_q15x2_ia((q15_t **)&pIn2); + y2 = read_q15x2_ia((q15_t **)&pIn2); /* multiply and accumlate */ acc0 = __SMLAD(x1, y1, acc0); @@ -235,7 +227,7 @@ void arm_conv_fast_opt_q15( acc1 = __SMLADX(x3, y1, acc1); /* Read next two samples from scratch1 buffer */ - x1 = read_q15x2_ia (&pScr1); + x1 = read_q15x2_ia(&pScr1); /* multiply and accumlate */ acc0 = __SMLAD(x2, y2, acc0); @@ -251,7 +243,7 @@ void arm_conv_fast_opt_q15( acc3 = __SMLADX(x3, y1, acc3); acc1 = __SMLADX(x3, y2, acc1); - x2 = read_q15x2_ia (&pScr1); + x2 = read_q15x2_ia(&pScr1); #ifndef ARM_MATH_BIG_ENDIAN x3 = __PKHBT(x2, x1, 0); @@ -265,14 +257,14 @@ void arm_conv_fast_opt_q15( tapCnt--; } - /* Update scratch pointer for remaining samples of smaller length sequence */ + /* Update scratch pointer for remaining samples of smaller length sequence + */ pScr1 -= 4U; /* apply same above for remaining samples of smaller length sequence */ - tapCnt = (srcBLen) & 3U; + tapCnt = (srcBLen)&3U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* accumlate the results */ acc0 += (*pScr1++ * *pIn2); acc1 += (*pScr1++ * *pIn2); @@ -289,11 +281,15 @@ void arm_conv_fast_opt_q15( /* Store the results in the accumulators in the destination buffer. */ #ifndef ARM_MATH_BIG_ENDIAN - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc0 >> 15), 16), __SSAT((acc1 >> 15), 16), 16)); - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc2 >> 15), 16), __SSAT((acc3 >> 15), 16), 16)); + write_q15x2_ia( + &pOut, __PKHBT(__SSAT((acc0 >> 15), 16), __SSAT((acc1 >> 15), 16), 16)); + write_q15x2_ia( + &pOut, __PKHBT(__SSAT((acc2 >> 15), 16), __SSAT((acc3 >> 15), 16), 16)); #else - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc1 >> 15), 16), __SSAT((acc0 >> 15), 16), 16)); - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc3 >> 15), 16), __SSAT((acc2 >> 15), 16), 16)); + write_q15x2_ia( + &pOut, __PKHBT(__SSAT((acc1 >> 15), 16), __SSAT((acc0 >> 15), 16), 16)); + write_q15x2_ia( + &pOut, __PKHBT(__SSAT((acc3 >> 15), 16), __SSAT((acc2 >> 15), 16), 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Initialization of inputB pointer */ @@ -313,8 +309,7 @@ void arm_conv_fast_opt_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Calculate convolution for remaining samples of Bigger length sequence */ - while (blkCnt > 0) - { + while (blkCnt > 0) { /* Initialze temporary scratch pointer as scratch1 */ pScr1 = pScratch1; @@ -323,8 +318,7 @@ void arm_conv_fast_opt_q15( tapCnt = (srcBLen) >> 1U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read next two samples from scratch1 buffer */ acc0 += (*pScr1++ * *pIn2++); @@ -334,11 +328,10 @@ void arm_conv_fast_opt_q15( tapCnt--; } - tapCnt = (srcBLen) & 1U; + tapCnt = (srcBLen)&1U; /* apply same above for remaining samples of smaller length sequence */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* accumlate the results */ acc0 += (*pScr1++ * *pIn2++); @@ -351,14 +344,13 @@ void arm_conv_fast_opt_q15( /* The result is in 2.30 format. Convert to 1.15 with saturation. Then store the output in the destination buffer. */ - *pOut++ = (q15_t) (__SSAT((acc0 >> 15), 16)); + *pOut++ = (q15_t)(__SSAT((acc0 >> 15), 16)); /* Initialization of inputB pointer */ pIn2 = py; pScratch1 += 1U; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_fast_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_fast_q15.c index 3102a05..f482e87 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_fast_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_fast_q15.c @@ -43,54 +43,51 @@ @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence - @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1 + @param[out] pDst points to the location where the output result is + written. Length srcALen+srcBLen-1 @return none @par Scaling and Overflow Behavior This fast version uses a 32-bit accumulator with 2.30 format. - The accumulator maintains full precision of the intermediate multiplication results - but provides only a single guard bit. There is no saturation on intermediate additions. - Thus, if the accumulator overflows it wraps around and distorts the result. - The input signals should be scaled down to avoid intermediate overflows. - Scale down the inputs by log2(min(srcALen, srcBLen)) (log2 is read as log to the base 2) times to avoid overflows, - as maximum of min(srcALen, srcBLen) number of additions are carried internally. - The 2.30 accumulator is right shifted by 15 bits and then saturated to 1.15 format to yield the final result. + The accumulator maintains full precision of the intermediate + multiplication results but provides only a single guard bit. There is no + saturation on intermediate additions. Thus, if the accumulator overflows it + wraps around and distorts the result. The input signals should be scaled down + to avoid intermediate overflows. Scale down the inputs by log2(min(srcALen, + srcBLen)) (log2 is read as log to the base 2) times to avoid overflows, as + maximum of min(srcALen, srcBLen) number of additions are carried internally. + The 2.30 accumulator is right shifted by 15 bits and then + saturated to 1.15 format to yield the final result. @remark - Refer to \ref arm_conv_q15() for a slower implementation of this function which uses 64-bit accumulation to avoid wrap around distortion. + Refer to \ref arm_conv_q15() for a slower implementation of + this function which uses 64-bit accumulation to avoid wrap around distortion. */ -void arm_conv_fast_q15( - const q15_t * pSrcA, - uint32_t srcALen, - const q15_t * pSrcB, - uint32_t srcBLen, - q15_t * pDst) -{ - const q15_t *pIn1; /* InputA pointer */ - const q15_t *pIn2; /* InputB pointer */ - q15_t *pOut = pDst; /* Output pointer */ - q31_t sum, acc0, acc1, acc2, acc3; /* Accumulators */ - const q15_t *px; /* Intermediate inputA pointer */ - const q15_t *py; /* Intermediate inputB pointer */ - const q15_t *pSrc1, *pSrc2; /* Intermediate pointers */ - q31_t x0, x1, x2, x3, c0; /* Temporary variables to hold state and coefficient values */ - uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ - uint32_t j, k, count, blkCnt; /* Loop counters */ +void arm_conv_fast_q15(const q15_t *pSrcA, uint32_t srcALen, const q15_t *pSrcB, + uint32_t srcBLen, q15_t *pDst) { + const q15_t *pIn1; /* InputA pointer */ + const q15_t *pIn2; /* InputB pointer */ + q15_t *pOut = pDst; /* Output pointer */ + q31_t sum, acc0, acc1, acc2, acc3; /* Accumulators */ + const q15_t *px; /* Intermediate inputA pointer */ + const q15_t *py; /* Intermediate inputB pointer */ + const q15_t *pSrc1, *pSrc2; /* Intermediate pointers */ + q31_t x0, x1, x2, x3, + c0; /* Temporary variables to hold state and coefficient values */ + uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ + uint32_t j, k, count, blkCnt; /* Loop counters */ /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ - if (srcALen >= srcBLen) - { + if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; - } - else - { + } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; @@ -103,14 +100,15 @@ void arm_conv_fast_q15( srcALen = j; } - /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ x[n-N+1] * y[N -1] */ + /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ + * x[n-N+1] * y[N -1] */ /* The function is internally - * divided into three stages according to the number of multiplications that has to be - * taken place between inputA samples and inputB samples. In the first stage of the - * algorithm, the multiplications increase by one for every iteration. - * In the second stage of the algorithm, srcBLen number of multiplications are done. - * In the third stage of the algorithm, the multiplications decrease by one - * for every iteration. */ + * divided into three stages according to the number of multiplications that + * has to be taken place between inputA samples and inputB samples. In the + * first stage of the algorithm, the multiplications increase by one for every + * iteration. In the second stage of the algorithm, srcBLen number of + * multiplications are done. In the third stage of the algorithm, the + * multiplications decrease by one for every iteration. */ /* The algorithm is implemented in three stages. The loop counters of each stage is initiated here. */ @@ -125,7 +123,8 @@ void arm_conv_fast_q15( /* sum = x[0] * y[0] * sum = x[0] * y[1] + x[1] * y[0] * .... - * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * y[0] + * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * + * y[0] */ /* In this stage the MAC operations are increased by 1 for every iteration. @@ -138,18 +137,17 @@ void arm_conv_fast_q15( /* Working pointer of inputB */ py = pIn2; - /* ------------------------ * Stage1 process * ----------------------*/ /* For loop unrolling by 4, this stage is divided into two. */ /* First part of this stage computes the MAC operations less than 4 */ - /* Second part of this stage computes the MAC operations greater than or equal to 4 */ + /* Second part of this stage computes the MAC operations greater than or equal + * to 4 */ /* The first part of the stage starts here */ - while ((count < 4U) && (blockSize1 > 0U)) - { + while ((count < 4U) && (blockSize1 > 0U)) { /* Accumulator is made zero for every iteration */ sum = 0; @@ -157,8 +155,7 @@ void arm_conv_fast_q15( * inputA samples and inputB samples */ k = count; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ sum = __SMLAD(*px++, *py--, sum); @@ -167,7 +164,7 @@ void arm_conv_fast_q15( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (sum >> 15); + *pOut++ = (q15_t)(sum >> 15); /* Update the inputA and inputB pointers for next MAC calculation */ py = pIn2 + count; @@ -186,23 +183,26 @@ void arm_conv_fast_q15( * y[srcBLen] and y[srcBLen-1] coefficients, py is decremented by 1 */ py = py - 1; - while (blockSize1 > 0U) - { + while (blockSize1 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = count >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. + /* First part of the processing with loop unrolling. Compute 4 MACs at a + *time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ - /* x[0], x[1] are multiplied with y[srcBLen - 1], y[srcBLen - 2] respectively */ - sum = __SMLADX(read_q15x2_ia ((q15_t **) &px), read_q15x2_da ((q15_t **) &py), sum); - /* x[2], x[3] are multiplied with y[srcBLen - 3], y[srcBLen - 4] respectively */ - sum = __SMLADX(read_q15x2_ia ((q15_t **) &px), read_q15x2_da ((q15_t **) &py), sum); + /* x[0], x[1] are multiplied with y[srcBLen - 1], y[srcBLen - 2] + * respectively */ + sum = __SMLADX(read_q15x2_ia((q15_t **)&px), read_q15x2_da((q15_t **)&py), + sum); + /* x[2], x[3] are multiplied with y[srcBLen - 3], y[srcBLen - 4] + * respectively */ + sum = __SMLADX(read_q15x2_ia((q15_t **)&px), read_q15x2_da((q15_t **)&py), + sum); /* Decrement loop counter */ k--; @@ -216,8 +216,7 @@ void arm_conv_fast_q15( ** No loop unrolling is used. */ k = count % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ sum = __SMLAD(*px++, *py--, sum); @@ -226,7 +225,7 @@ void arm_conv_fast_q15( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (sum >> 15); + *pOut++ = (q15_t)(sum >> 15); /* Update the inputA and inputB pointers for next MAC calculation */ py = pIn2 + (count - 1U); @@ -246,7 +245,8 @@ void arm_conv_fast_q15( /* sum = x[0] * y[srcBLen-1] + x[1] * y[srcBLen-2] +...+ x[srcBLen-1] * y[0] * sum = x[1] * y[srcBLen-1] + x[2] * y[srcBLen-2] +...+ x[srcBLen] * y[0] * .... - * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ x[srcALen-1] * y[0] + * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ + * x[srcALen-1] * y[0] */ /* Working pointer of inputA */ @@ -263,16 +263,14 @@ void arm_conv_fast_q15( * Stage2 process * -------------------*/ - /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed. - * So, to loop unroll over blockSize2, - * srcBLen should be greater than or equal to 4 */ - if (srcBLen >= 4U) - { + /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are + * performed. So, to loop unroll over blockSize2, srcBLen should be greater + * than or equal to 4 */ + if (srcBLen >= 4U) { /* Loop unroll over blockSize2, by 4 */ blkCnt = blockSize2 >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { py = py - 1U; /* Set all accumulators to zero */ @@ -282,21 +280,21 @@ void arm_conv_fast_q15( acc3 = 0; /* read x[0], x[1] samples */ - x0 = read_q15x2 ((q15_t *) px); + x0 = read_q15x2((q15_t *)px); /* read x[1], x[2] samples */ - x1 = read_q15x2 ((q15_t *) px + 1); - px += 2U; + x1 = read_q15x2((q15_t *)px + 1); + px += 2U; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = srcBLen >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. + /* First part of the processing with loop unrolling. Compute 4 MACs at a + *time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - do - { + do { /* Read the last two inputB samples using SIMD: * y[srcBLen - 1] and y[srcBLen - 2] */ - c0 = read_q15x2_da ((q15_t **) &py); + c0 = read_q15x2_da((q15_t **)&py); /* acc0 += x[0] * y[srcBLen - 1] + x[1] * y[srcBLen - 2] */ acc0 = __SMLADX(x0, c0, acc0); @@ -305,10 +303,10 @@ void arm_conv_fast_q15( acc1 = __SMLADX(x1, c0, acc1); /* Read x[2], x[3] */ - x2 = read_q15x2 ((q15_t *) px); + x2 = read_q15x2((q15_t *)px); /* Read x[3], x[4] */ - x3 = read_q15x2 ((q15_t *) px + 1); + x3 = read_q15x2((q15_t *)px + 1); /* acc2 += x[2] * y[srcBLen - 1] + x[3] * y[srcBLen - 2] */ acc2 = __SMLADX(x2, c0, acc2); @@ -317,7 +315,7 @@ void arm_conv_fast_q15( acc3 = __SMLADX(x3, c0, acc3); /* Read y[srcBLen - 3] and y[srcBLen - 4] */ - c0 = read_q15x2_da ((q15_t **) &py); + c0 = read_q15x2_da((q15_t **)&py); /* acc0 += x[2] * y[srcBLen - 3] + x[3] * y[srcBLen - 4] */ acc0 = __SMLADX(x2, c0, acc0); @@ -326,11 +324,11 @@ void arm_conv_fast_q15( acc1 = __SMLADX(x3, c0, acc1); /* Read x[4], x[5] */ - x0 = read_q15x2 ((q15_t *) px + 2); + x0 = read_q15x2((q15_t *)px + 2); /* Read x[5], x[6] */ - x1 = read_q15x2 ((q15_t *) px + 3); - px += 4U; + x1 = read_q15x2((q15_t *)px + 3); + px += 4U; /* acc2 += x[4] * y[srcBLen - 3] + x[5] * y[srcBLen - 4] */ acc2 = __SMLADX(x0, c0, acc2); @@ -347,20 +345,19 @@ void arm_conv_fast_q15( ** No loop unrolling is used. */ k = srcBLen % 0x4U; - if (k == 1U) - { + if (k == 1U) { /* Read y[srcBLen - 5] */ - c0 = *(py+1); + c0 = *(py + 1); -#ifdef ARM_MATH_BIG_ENDIAN +#ifdef ARM_MATH_BIG_ENDIAN c0 = c0 << 16U; #else c0 = c0 & 0x0000FFFF; #endif /* #ifdef ARM_MATH_BIG_ENDIAN */ /* Read x[7] */ - x3 = read_q15x2 ((q15_t *) px); - px++; + x3 = read_q15x2((q15_t *)px); + px++; /* Perform the multiply-accumulates */ acc0 = __SMLAD(x0, c0, acc0); @@ -369,17 +366,16 @@ void arm_conv_fast_q15( acc3 = __SMLADX(x3, c0, acc3); } - if (k == 2U) - { + if (k == 2U) { /* Read y[srcBLen - 5], y[srcBLen - 6] */ - c0 = read_q15x2 ((q15_t *) py); + c0 = read_q15x2((q15_t *)py); /* Read x[7], x[8] */ - x3 = read_q15x2 ((q15_t *) px); + x3 = read_q15x2((q15_t *)px); /* Read x[9] */ - x2 = read_q15x2 ((q15_t *) px + 1); - px += 2U; + x2 = read_q15x2((q15_t *)px + 1); + px += 2U; /* Perform the multiply-accumulates */ acc0 = __SMLADX(x0, c0, acc0); @@ -388,16 +384,15 @@ void arm_conv_fast_q15( acc3 = __SMLADX(x2, c0, acc3); } - if (k == 3U) - { + if (k == 3U) { /* Read y[srcBLen - 5], y[srcBLen - 6] */ - c0 = read_q15x2 ((q15_t *) py); + c0 = read_q15x2((q15_t *)py); /* Read x[7], x[8] */ - x3 = read_q15x2 ((q15_t *) px); + x3 = read_q15x2((q15_t *)px); /* Read x[9] */ - x2 = read_q15x2 ((q15_t *) px + 1); + x2 = read_q15x2((q15_t *)px + 1); /* Perform the multiply-accumulates */ acc0 = __SMLADX(x0, c0, acc0); @@ -406,16 +401,16 @@ void arm_conv_fast_q15( acc3 = __SMLADX(x2, c0, acc3); /* Read y[srcBLen - 7] */ - c0 = *(py-1); -#ifdef ARM_MATH_BIG_ENDIAN + c0 = *(py - 1); +#ifdef ARM_MATH_BIG_ENDIAN c0 = c0 << 16U; #else c0 = c0 & 0x0000FFFF; #endif /* #ifdef ARM_MATH_BIG_ENDIAN */ /* Read x[10] */ - x3 = read_q15x2 ((q15_t *) px + 2); - px += 3U; + x3 = read_q15x2((q15_t *)px + 2); + px += 3U; /* Perform the multiply-accumulates */ acc0 = __SMLADX(x1, c0, acc0); @@ -426,11 +421,11 @@ void arm_conv_fast_q15( /* Store the result in the accumulator in the destination buffer. */ #ifndef ARM_MATH_BIG_ENDIAN - write_q15x2_ia (&pOut, __PKHBT((acc0 >> 15), (acc1 >> 15), 16)); - write_q15x2_ia (&pOut, __PKHBT((acc2 >> 15), (acc3 >> 15), 16)); + write_q15x2_ia(&pOut, __PKHBT((acc0 >> 15), (acc1 >> 15), 16)); + write_q15x2_ia(&pOut, __PKHBT((acc2 >> 15), (acc3 >> 15), 16)); #else - write_q15x2_ia (&pOut, __PKHBT((acc1 >> 15), (acc0 >> 15), 16)); - write_q15x2_ia (&pOut, __PKHBT((acc3 >> 15), (acc2 >> 15), 16)); + write_q15x2_ia(&pOut, __PKHBT((acc1 >> 15), (acc0 >> 15), 16)); + write_q15x2_ia(&pOut, __PKHBT((acc3 >> 15), (acc2 >> 15), 16)); #endif /*#ifndef ARM_MATH_BIG_ENDIAN*/ /* Increment the pointer pIn1 index, count by 4 */ @@ -444,27 +439,27 @@ void arm_conv_fast_q15( blkCnt--; } - /* If the blockSize2 is not a multiple of 4, compute any remaining output samples here. + /* If the blockSize2 is not a multiple of 4, compute any remaining output + *samples here. ** No loop unrolling is used. */ blkCnt = blockSize2 % 0x4U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = srcBLen >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. + /* First part of the processing with loop unrolling. Compute 4 MACs at a + *time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ - sum += ((q31_t) *px++ * *py--); - sum += ((q31_t) *px++ * *py--); - sum += ((q31_t) *px++ * *py--); - sum += ((q31_t) *px++ * *py--); + sum += ((q31_t)*px++ * *py--); + sum += ((q31_t)*px++ * *py--); + sum += ((q31_t)*px++ * *py--); + sum += ((q31_t)*px++ * *py--); /* Decrement loop counter */ k--; @@ -474,17 +469,16 @@ void arm_conv_fast_q15( ** No loop unrolling is used. */ k = srcBLen % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ - sum += ((q31_t) *px++ * *py--); + sum += ((q31_t)*px++ * *py--); /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (sum >> 15); + *pOut++ = (q15_t)(sum >> 15); /* Increment the pointer pIn1 index, count by 1 */ count++; @@ -496,32 +490,28 @@ void arm_conv_fast_q15( /* Decrement loop counter */ blkCnt--; } - } - else - { + } else { /* If the srcBLen is not a multiple of 4, * the blockSize2 loop cannot be unrolled by 4 */ blkCnt = blockSize2; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* srcBLen number of MACS should be performed */ k = srcBLen; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum += ((q31_t) *px++ * *py--); + sum += ((q31_t)*px++ * *py--); /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (sum >> 15); + *pOut++ = (q15_t)(sum >> 15); /* Increment MAC count */ count++; @@ -539,8 +529,10 @@ void arm_conv_fast_q15( * Initializations of stage3 * -------------------------*/ - /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * y[srcBLen-2] +...+ x[srcALen-1] * y[1] - * sum += x[srcALen-srcBLen+2] * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * y[2] + /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * + * y[srcBLen-2] +...+ x[srcALen-1] * y[1] sum += x[srcALen-srcBLen+2] * + * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * + * y[2] * .... * sum += x[srcALen-2] * y[srcBLen-1] + x[srcALen-1] * y[srcBLen-2] * sum += x[srcALen-1] * y[srcBLen-1] @@ -564,29 +556,31 @@ void arm_conv_fast_q15( /* For loop unrolling by 4, this stage is divided into two. */ /* First part of this stage computes the MAC operations greater than 4 */ - /* Second part of this stage computes the MAC operations less than or equal to 4 */ + /* Second part of this stage computes the MAC operations less than or equal to + * 4 */ /* The first part of the stage starts here */ j = blockSize3 >> 2U; - while ((j > 0U) && (blockSize3 > 0U)) - { + while ((j > 0U) && (blockSize3 > 0U)) { /* Accumulator is made zero for every iteration */ sum = 0; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = blockSize3 >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. + /* First part of the processing with loop unrolling. Compute 4 MACs at a + *time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - while (k > 0U) - { + while (k > 0U) { /* x[srcALen - srcBLen + 1], x[srcALen - srcBLen + 2] are multiplied * with y[srcBLen - 1], y[srcBLen - 2] respectively */ - sum = __SMLADX(read_q15x2_ia ((q15_t **) &px), read_q15x2_da ((q15_t **) &py), sum); + sum = __SMLADX(read_q15x2_ia((q15_t **)&px), read_q15x2_da((q15_t **)&py), + sum); /* x[srcALen - srcBLen + 3], x[srcALen - srcBLen + 4] are multiplied * with y[srcBLen - 3], y[srcBLen - 4] respectively */ - sum = __SMLADX(read_q15x2_ia ((q15_t **) &px), read_q15x2_da ((q15_t **) &py), sum); + sum = __SMLADX(read_q15x2_ia((q15_t **)&px), read_q15x2_da((q15_t **)&py), + sum); /* Decrement loop counter */ k--; @@ -596,12 +590,12 @@ void arm_conv_fast_q15( * So, py is incremented by 1 */ py = py + 1U; - /* If the blockSize3 is not a multiple of 4, compute any remaining MACs here. + /* If the blockSize3 is not a multiple of 4, compute any remaining MACs + *here. ** No loop unrolling is used. */ k = blockSize3 % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* sum += x[srcALen - srcBLen + 5] * y[srcBLen - 5] */ sum = __SMLAD(*px++, *py--, sum); @@ -610,7 +604,7 @@ void arm_conv_fast_q15( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (sum >> 15); + *pOut++ = (q15_t)(sum >> 15); /* Update the inputA and inputB pointers for next MAC calculation */ px = ++pSrc1; @@ -627,16 +621,14 @@ void arm_conv_fast_q15( * so pointer py is updated to read only one sample at a time */ py = py + 1U; - while (blockSize3 > 0U) - { + while (blockSize3 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = blockSize3; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ /* sum += x[srcALen-1] * y[srcBLen-1] */ sum = __SMLAD(*px++, *py--, sum); @@ -646,7 +638,7 @@ void arm_conv_fast_q15( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (sum >> 15); + *pOut++ = (q15_t)(sum >> 15); /* Update the inputA and inputB pointers for next MAC calculation */ px = ++pSrc1; @@ -655,7 +647,6 @@ void arm_conv_fast_q15( /* Decrement the loop counter */ blockSize3--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_fast_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_fast_q31.c index e87eddc..2b37a1b 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_fast_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_fast_q31.c @@ -43,54 +43,52 @@ @param[in] srcALen length of the first input sequence. @param[in] pSrcB points to the second input sequence. @param[in] srcBLen length of the second input sequence. - @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1. + @param[out] pDst points to the location where the output result is + written. Length srcALen+srcBLen-1. @return none @par Scaling and Overflow Behavior - This function is optimized for speed at the expense of fixed-point precision and overflow protection. - The result of each 1.31 x 1.31 multiplication is truncated to 2.30 format. - These intermediate results are accumulated in a 32-bit register in 2.30 format. - Finally, the accumulator is saturated and converted to a 1.31 result. + This function is optimized for speed at the expense of + fixed-point precision and overflow protection. The result of each 1.31 x 1.31 + multiplication is truncated to 2.30 format. These intermediate results are + accumulated in a 32-bit register in 2.30 format. Finally, the accumulator is + saturated and converted to a 1.31 result. @par - The fast version has the same overflow behavior as the standard version but provides less precision since it discards the low 32 bits of each multiplication result. - In order to avoid overflows completely the input signals must be scaled down. - Scale down the inputs by log2(min(srcALen, srcBLen)) (log2 is read as log to the base 2) times to avoid overflows, - as maximum of min(srcALen, srcBLen) number of additions are carried internally. + The fast version has the same overflow behavior as the + standard version but provides less precision since it discards the low 32 bits + of each multiplication result. In order to avoid overflows completely the + input signals must be scaled down. Scale down the inputs by log2(min(srcALen, + srcBLen)) (log2 is read as log to the base 2) times to avoid overflows, as + maximum of min(srcALen, srcBLen) number of additions are carried internally. @remark - Refer to \ref arm_conv_q31() for a slower implementation of this function which uses 64-bit accumulation to provide higher precision. + Refer to \ref arm_conv_q31() for a slower implementation of + this function which uses 64-bit accumulation to provide higher precision. */ -void arm_conv_fast_q31( - const q31_t * pSrcA, - uint32_t srcALen, - const q31_t * pSrcB, - uint32_t srcBLen, - q31_t * pDst) -{ - const q31_t *pIn1; /* InputA pointer */ - const q31_t *pIn2; /* InputB pointer */ - q31_t *pOut = pDst; /* Output pointer */ - const q31_t *px; /* Intermediate inputA pointer */ - const q31_t *py; /* Intermediate inputB pointer */ - const q31_t *pSrc1, *pSrc2; /* Intermediate pointers */ - q31_t sum, acc0, acc1, acc2, acc3; /* Accumulators */ - q31_t x0, x1, x2, x3, c0; /* Temporary variables to hold state and coefficient values */ - uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ - uint32_t j, k, count, blkCnt; /* Loop counters */ +void arm_conv_fast_q31(const q31_t *pSrcA, uint32_t srcALen, const q31_t *pSrcB, + uint32_t srcBLen, q31_t *pDst) { + const q31_t *pIn1; /* InputA pointer */ + const q31_t *pIn2; /* InputB pointer */ + q31_t *pOut = pDst; /* Output pointer */ + const q31_t *px; /* Intermediate inputA pointer */ + const q31_t *py; /* Intermediate inputB pointer */ + const q31_t *pSrc1, *pSrc2; /* Intermediate pointers */ + q31_t sum, acc0, acc1, acc2, acc3; /* Accumulators */ + q31_t x0, x1, x2, x3, + c0; /* Temporary variables to hold state and coefficient values */ + uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ + uint32_t j, k, count, blkCnt; /* Loop counters */ /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ - if (srcALen >= srcBLen) - { + if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; - } - else - { + } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; @@ -103,14 +101,15 @@ void arm_conv_fast_q31( srcALen = j; } - /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ x[n-N+1] * y[N -1] */ + /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ + * x[n-N+1] * y[N -1] */ /* The function is internally - * divided into three stages according to the number of multiplications that has to be - * taken place between inputA samples and inputB samples. In the first stage of the - * algorithm, the multiplications increase by one for every iteration. - * In the second stage of the algorithm, srcBLen number of multiplications are done. - * In the third stage of the algorithm, the multiplications decrease by one - * for every iteration. */ + * divided into three stages according to the number of multiplications that + * has to be taken place between inputA samples and inputB samples. In the + * first stage of the algorithm, the multiplications increase by one for every + * iteration. In the second stage of the algorithm, srcBLen number of + * multiplications are done. In the third stage of the algorithm, the + * multiplications decrease by one for every iteration. */ /* The algorithm is implemented in three stages. The loop counters of each stage is initiated here. */ @@ -125,7 +124,8 @@ void arm_conv_fast_q31( /* sum = x[0] * y[0] * sum = x[0] * y[1] + x[1] * y[0] * .... - * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * y[0] + * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * + * y[0] */ /* In this stage the MAC operations are increased by 1 for every iteration. @@ -138,39 +138,33 @@ void arm_conv_fast_q31( /* Working pointer of inputB */ py = pIn2; - /* ------------------------ * Stage1 process * ----------------------*/ /* The first stage starts here */ - while (blockSize1 > 0U) - { + while (blockSize1 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = count >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. + /* First part of the processing with loop unrolling. Compute 4 MACs at a + *time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - while (k > 0U) - { + while (k > 0U) { /* x[0] * y[srcBLen - 1] */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* x[1] * y[srcBLen - 2] */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* x[2] * y[srcBLen - 3] */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* x[3] * y[srcBLen - 4] */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* Decrement loop counter */ k--; @@ -180,11 +174,9 @@ void arm_conv_fast_q31( ** No loop unrolling is used. */ k = count % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* Decrement loop counter */ k--; @@ -211,7 +203,8 @@ void arm_conv_fast_q31( /* sum = x[0] * y[srcBLen-1] + x[1] * y[srcBLen-2] +...+ x[srcBLen-1] * y[0] * sum = x[1] * y[srcBLen-1] + x[2] * y[srcBLen-2] +...+ x[srcBLen] * y[0] * .... - * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ x[srcALen-1] * y[0] + * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ + * x[srcALen-1] * y[0] */ /* Working pointer of inputA */ @@ -228,16 +221,14 @@ void arm_conv_fast_q31( * Stage2 process * ------------------*/ - /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed. - * So, to loop unroll over blockSize2, - * srcBLen should be greater than or equal to 4 */ - if (srcBLen >= 4U) - { + /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are + * performed. So, to loop unroll over blockSize2, srcBLen should be greater + * than or equal to 4 */ + if (srcBLen >= 4U) { /* Loop unroll over blockSize2, by 4 */ blkCnt = blockSize2 >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Set all accumulators to zero */ acc0 = 0; acc1 = 0; @@ -252,10 +243,10 @@ void arm_conv_fast_q31( /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = srcBLen >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. + /* First part of the processing with loop unrolling. Compute 4 MACs at a + *time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - do - { + do { /* Read y[srcBLen - 1] sample */ c0 = *py--; /* Read x[3] sample */ @@ -263,14 +254,13 @@ void arm_conv_fast_q31( /* Perform the multiply-accumulate */ /* acc0 += x[0] * y[srcBLen - 1] */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x0 * c0)) >> 32); /* acc1 += x[1] * y[srcBLen - 1] */ - acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32); + acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x1 * c0)) >> 32); /* acc2 += x[2] * y[srcBLen - 1] */ - acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x2 * c0)) >> 32); + acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x2 * c0)) >> 32); /* acc3 += x[3] * y[srcBLen - 1] */ - acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x3 * c0)) >> 32); - + acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x3 * c0)) >> 32); /* Read y[srcBLen - 2] sample */ c0 = *py--; @@ -279,14 +269,13 @@ void arm_conv_fast_q31( /* Perform the multiply-accumulate */ /* acc0 += x[1] * y[srcBLen - 2] */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x1 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x1 * c0)) >> 32); /* acc1 += x[2] * y[srcBLen - 2] */ - acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x2 * c0)) >> 32); + acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x2 * c0)) >> 32); /* acc2 += x[3] * y[srcBLen - 2] */ - acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x3 * c0)) >> 32); + acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x3 * c0)) >> 32); /* acc3 += x[4] * y[srcBLen - 2] */ - acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x0 * c0)) >> 32); - + acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x0 * c0)) >> 32); /* Read y[srcBLen - 3] sample */ c0 = *py--; @@ -295,14 +284,13 @@ void arm_conv_fast_q31( /* Perform the multiply-accumulates */ /* acc0 += x[2] * y[srcBLen - 3] */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x2 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x2 * c0)) >> 32); /* acc1 += x[3] * y[srcBLen - 3] */ - acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x3 * c0)) >> 32); + acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x3 * c0)) >> 32); /* acc2 += x[4] * y[srcBLen - 3] */ - acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x0 * c0)) >> 32); + acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x0 * c0)) >> 32); /* acc3 += x[5] * y[srcBLen - 3] */ - acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x1 * c0)) >> 32); - + acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x1 * c0)) >> 32); /* Read y[srcBLen - 4] sample */ c0 = *py--; @@ -311,14 +299,13 @@ void arm_conv_fast_q31( /* Perform the multiply-accumulates */ /* acc0 += x[3] * y[srcBLen - 4] */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x3 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x3 * c0)) >> 32); /* acc1 += x[4] * y[srcBLen - 4] */ - acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x0 * c0)) >> 32); + acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x0 * c0)) >> 32); /* acc2 += x[5] * y[srcBLen - 4] */ - acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x1 * c0)) >> 32); + acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x1 * c0)) >> 32); /* acc3 += x[6] * y[srcBLen - 4] */ - acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x2 * c0)) >> 32); - + acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x2 * c0)) >> 32); } while (--k); @@ -326,8 +313,7 @@ void arm_conv_fast_q31( ** No loop unrolling is used. */ k = srcBLen % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* Read y[srcBLen - 5] sample */ c0 = *py--; /* Read x[7] sample */ @@ -335,13 +321,13 @@ void arm_conv_fast_q31( /* Perform the multiply-accumulates */ /* acc0 += x[4] * y[srcBLen - 5] */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x0 * c0)) >> 32); /* acc1 += x[5] * y[srcBLen - 5] */ - acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32); + acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x1 * c0)) >> 32); /* acc2 += x[6] * y[srcBLen - 5] */ - acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x2 * c0)) >> 32); + acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x2 * c0)) >> 32); /* acc3 += x[7] * y[srcBLen - 5] */ - acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x3 * c0)) >> 32); + acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x3 * c0)) >> 32); /* Reuse the present samples for the next MAC */ x0 = x1; @@ -353,10 +339,10 @@ void arm_conv_fast_q31( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q31_t) (acc0 << 1); - *pOut++ = (q31_t) (acc1 << 1); - *pOut++ = (q31_t) (acc2 << 1); - *pOut++ = (q31_t) (acc3 << 1); + *pOut++ = (q31_t)(acc0 << 1); + *pOut++ = (q31_t)(acc1 << 1); + *pOut++ = (q31_t)(acc2 << 1); + *pOut++ = (q31_t)(acc3 << 1); /* Increment the pointer pIn1 index, count by 4 */ count += 4U; @@ -369,31 +355,27 @@ void arm_conv_fast_q31( blkCnt--; } - /* If the blockSize2 is not a multiple of 4, compute any remaining output samples here. + /* If the blockSize2 is not a multiple of 4, compute any remaining output + *samples here. ** No loop unrolling is used. */ blkCnt = blockSize2 % 0x4U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = srcBLen >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. + /* First part of the processing with loop unrolling. Compute 4 MACs at a + *time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* Decrement loop counter */ k--; @@ -403,11 +385,9 @@ void arm_conv_fast_q31( ** No loop unrolling is used. */ k = srcBLen % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* Decrement loop counter */ k--; @@ -426,26 +406,21 @@ void arm_conv_fast_q31( /* Decrement loop counter */ blkCnt--; } - } - else - { + } else { /* If the srcBLen is not a multiple of 4, * the blockSize2 loop cannot be unrolled by 4 */ blkCnt = blockSize2; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* srcBLen number of MACS should be performed */ k = srcBLen; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* Decrement loop counter */ k--; @@ -466,13 +441,14 @@ void arm_conv_fast_q31( } } - /* -------------------------- * Initializations of stage3 * -------------------------*/ - /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * y[srcBLen-2] +...+ x[srcALen-1] * y[1] - * sum += x[srcALen-srcBLen+2] * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * y[2] + /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * + * y[srcBLen-2] +...+ x[srcALen-1] * y[1] sum += x[srcALen-srcBLen+2] * + * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * + * y[2] * .... * sum += x[srcALen-2] * y[srcBLen-1] + x[srcALen-1] * y[srcBLen-2] * sum += x[srcALen-1] * y[srcBLen-1] @@ -493,48 +469,42 @@ void arm_conv_fast_q31( * Stage3 process * ------------------*/ - while (blockSize3 > 0U) - { + while (blockSize3 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = blockSize3 >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. + /* First part of the processing with loop unrolling. Compute 4 MACs at a + *time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ /* sum += x[srcALen - srcBLen + 1] * y[srcBLen - 1] */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* sum += x[srcALen - srcBLen + 2] * y[srcBLen - 2] */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* sum += x[srcALen - srcBLen + 3] * y[srcBLen - 3] */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* sum += x[srcALen - srcBLen + 4] * y[srcBLen - 4] */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* Decrement loop counter */ k--; } - /* If the blockSize3 is not a multiple of 4, compute any remaining MACs here. + /* If the blockSize3 is not a multiple of 4, compute any remaining MACs + *here. ** No loop unrolling is used. */ k = blockSize3 % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* Decrement loop counter */ k--; @@ -550,7 +520,6 @@ void arm_conv_fast_q31( /* Decrement loop counter */ blockSize3--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_opt_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_opt_q15.c index 6ad34cd..227eea6 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_opt_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_opt_q15.c @@ -43,61 +43,57 @@ @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence - @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1. - @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. - @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen). + @param[out] pDst points to the location where the output result is + written. Length srcALen+srcBLen-1. + @param[in] pScratch1 points to scratch buffer of size max(srcALen, + srcBLen) + 2*min(srcALen, srcBLen) - 2. + @param[in] pScratch2 points to scratch buffer of size min(srcALen, + srcBLen). @return none @par Scaling and Overflow Behavior - The function is implemented using a 64-bit internal accumulator. - Both inputs are in 1.15 format and multiplications yield a 2.30 result. - The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. - This approach provides 33 guard bits and there is no risk of overflow. - The 34.30 result is then truncated to 34.15 format by discarding the low 15 bits and then saturated to 1.15 format. + The function is implemented using a 64-bit internal + accumulator. Both inputs are in 1.15 format and multiplications yield a 2.30 + result. The 2.30 intermediate results are accumulated in a 64-bit accumulator + in 34.30 format. This approach provides 33 guard bits and there is no risk of + overflow. The 34.30 result is then truncated to 34.15 format by discarding the + low 15 bits and then saturated to 1.15 format. @remark - Refer to \ref arm_conv_fast_q15() for a faster but less precise version of this function. + Refer to \ref arm_conv_fast_q15() for a faster but less + precise version of this function. */ -void arm_conv_opt_q15( - const q15_t * pSrcA, - uint32_t srcALen, - const q15_t * pSrcB, - uint32_t srcBLen, - q15_t * pDst, - q15_t * pScratch1, - q15_t * pScratch2) -{ - q63_t acc0; /* Accumulators */ - const q15_t *pIn1; /* InputA pointer */ - const q15_t *pIn2; /* InputB pointer */ - q15_t *pOut = pDst; /* Output pointer */ - q15_t *pScr1 = pScratch1; /* Temporary pointer for scratch1 */ - q15_t *pScr2 = pScratch2; /* Temporary pointer for scratch1 */ - const q15_t *px; /* Intermediate inputA pointer */ - q15_t *py; /* Intermediate inputB pointer */ - uint32_t j, k, blkCnt; /* Loop counter */ - uint32_t tapCnt; /* Loop count */ +void arm_conv_opt_q15(const q15_t *pSrcA, uint32_t srcALen, const q15_t *pSrcB, + uint32_t srcBLen, q15_t *pDst, q15_t *pScratch1, + q15_t *pScratch2) { + q63_t acc0; /* Accumulators */ + const q15_t *pIn1; /* InputA pointer */ + const q15_t *pIn2; /* InputB pointer */ + q15_t *pOut = pDst; /* Output pointer */ + q15_t *pScr1 = pScratch1; /* Temporary pointer for scratch1 */ + q15_t *pScr2 = pScratch2; /* Temporary pointer for scratch1 */ + const q15_t *px; /* Intermediate inputA pointer */ + q15_t *py; /* Intermediate inputB pointer */ + uint32_t j, k, blkCnt; /* Loop counter */ + uint32_t tapCnt; /* Loop count */ -#if defined (ARM_MATH_LOOPUNROLL) - q63_t acc1, acc2, acc3; /* Accumulators */ - q31_t x1, x2, x3; /* Temporary variables to hold state and coefficient values */ - q31_t y1, y2; /* State variables */ +#if defined(ARM_MATH_LOOPUNROLL) + q63_t acc1, acc2, acc3; /* Accumulators */ + q31_t x1, x2, + x3; /* Temporary variables to hold state and coefficient values */ + q31_t y1, y2; /* State variables */ #endif - /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ - if (srcALen >= srcBLen) - { + if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; - } - else - { + } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; @@ -116,14 +112,14 @@ void arm_conv_opt_q15( /* points to smaller length sequence */ px = pIn2; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = srcBLen >> 2U; - /* Copy smaller length input sequence in reverse order into second scratch buffer */ - while (k > 0U) - { + /* Copy smaller length input sequence in reverse order into second scratch + * buffer */ + while (k > 0U) { /* copy second buffer in reversal manner */ *pScr2-- = *px++; *pScr2-- = *px++; @@ -144,8 +140,7 @@ void arm_conv_opt_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* copy second buffer in reversal manner for remaining samples */ *pScr2-- = *px++; @@ -171,7 +166,6 @@ void arm_conv_opt_q15( /* Update pointers */ pScr1 += srcALen; - /* Fill (srcBLen - 1U) zeros at end of scratch buffer */ arm_fill_q15(0, pScr1, (srcBLen - 1U)); @@ -181,17 +175,15 @@ void arm_conv_opt_q15( /* Temporary pointer for scratch2 */ py = pScratch2; - /* Initialization of pIn2 pointer */ pIn2 = py; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = (srcALen + srcBLen - 1U) >> 2; - while (blkCnt > 0) - { + while (blkCnt > 0) { /* Initialze temporary scratch pointer as scratch1 */ pScr1 = pScratch1; @@ -202,19 +194,18 @@ void arm_conv_opt_q15( acc3 = 0; /* Read two samples from scratch1 buffer */ - x1 = read_q15x2_ia (&pScr1); + x1 = read_q15x2_ia(&pScr1); /* Read next two samples from scratch1 buffer */ - x2 = read_q15x2_ia (&pScr1); + x2 = read_q15x2_ia(&pScr1); tapCnt = (srcBLen) >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read four samples from smaller buffer */ - y1 = read_q15x2_ia ((q15_t **) &pIn2); - y2 = read_q15x2_ia ((q15_t **) &pIn2); + y1 = read_q15x2_ia((q15_t **)&pIn2); + y2 = read_q15x2_ia((q15_t **)&pIn2); /* multiply and accumlate */ acc0 = __SMLALD(x1, y1, acc0); @@ -231,7 +222,7 @@ void arm_conv_opt_q15( acc1 = __SMLALDX(x3, y1, acc1); /* Read next two samples from scratch1 buffer */ - x1 = read_q15x2_ia (&pScr1); + x1 = read_q15x2_ia(&pScr1); /* multiply and accumlate */ acc0 = __SMLALD(x2, y2, acc0); @@ -247,7 +238,7 @@ void arm_conv_opt_q15( acc3 = __SMLALDX(x3, y1, acc3); acc1 = __SMLALDX(x3, y2, acc1); - x2 = read_q15x2_ia (&pScr1); + x2 = read_q15x2_ia(&pScr1); #ifndef ARM_MATH_BIG_ENDIAN x3 = __PKHBT(x2, x1, 0); @@ -261,14 +252,14 @@ void arm_conv_opt_q15( tapCnt--; } - /* Update scratch pointer for remaining samples of smaller length sequence */ + /* Update scratch pointer for remaining samples of smaller length sequence + */ pScr1 -= 4U; /* apply same above for remaining samples of smaller length sequence */ - tapCnt = (srcBLen) & 3U; + tapCnt = (srcBLen)&3U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* accumlate the results */ acc0 += (*pScr1++ * *pIn2); acc1 += (*pScr1++ * *pIn2); @@ -285,11 +276,15 @@ void arm_conv_opt_q15( /* Store the results in the accumulators in the destination buffer. */ #ifndef ARM_MATH_BIG_ENDIAN - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc0 >> 15), 16), __SSAT((acc1 >> 15), 16), 16)); - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc2 >> 15), 16), __SSAT((acc3 >> 15), 16), 16)); + write_q15x2_ia( + &pOut, __PKHBT(__SSAT((acc0 >> 15), 16), __SSAT((acc1 >> 15), 16), 16)); + write_q15x2_ia( + &pOut, __PKHBT(__SSAT((acc2 >> 15), 16), __SSAT((acc3 >> 15), 16), 16)); #else - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc1 >> 15), 16), __SSAT((acc0 >> 15), 16), 16)); - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc3 >> 15), 16), __SSAT((acc2 >> 15), 16), 16)); + write_q15x2_ia( + &pOut, __PKHBT(__SSAT((acc1 >> 15), 16), __SSAT((acc0 >> 15), 16), 16)); + write_q15x2_ia( + &pOut, __PKHBT(__SSAT((acc3 >> 15), 16), __SSAT((acc2 >> 15), 16), 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Initialization of inputB pointer */ @@ -309,8 +304,7 @@ void arm_conv_opt_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Calculate convolution for remaining samples of Bigger length sequence */ - while (blkCnt > 0) - { + while (blkCnt > 0) { /* Initialze temporary scratch pointer as scratch1 */ pScr1 = pScratch1; @@ -319,8 +313,7 @@ void arm_conv_opt_q15( tapCnt = (srcBLen) >> 1U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read next two samples from scratch1 buffer */ acc0 += (*pScr1++ * *pIn2++); @@ -330,11 +323,10 @@ void arm_conv_opt_q15( tapCnt--; } - tapCnt = (srcBLen) & 1U; + tapCnt = (srcBLen)&1U; /* apply same above for remaining samples of smaller length sequence */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* accumlate the results */ acc0 += (*pScr1++ * *pIn2++); @@ -347,14 +339,13 @@ void arm_conv_opt_q15( /* The result is in 2.30 format. Convert to 1.15 with saturation. Then store the output in the destination buffer. */ - *pOut++ = (q15_t) (__SSAT((acc0 >> 15), 16)); + *pOut++ = (q15_t)(__SSAT((acc0 >> 15), 16)); /* Initialization of inputB pointer */ pIn2 = py; pScratch1 += 1U; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_opt_q7.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_opt_q7.c index fb9e2ec..9df3bfa 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_opt_q7.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_opt_q7.c @@ -43,53 +43,49 @@ @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence - @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1. - @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. - @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen). + @param[out] pDst points to the location where the output result is + written. Length srcALen+srcBLen-1. + @param[in] pScratch1 points to scratch buffer(of type q15_t) of size + max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. + @param[in] pScratch2 points to scratch buffer (of type q15_t) of size + min(srcALen, srcBLen). @return none @par Scaling and Overflow Behavior - The function is implemented using a 32-bit internal accumulator. - Both the inputs are represented in 1.7 format and multiplications yield a 2.14 result. - The 2.14 intermediate results are accumulated in a 32-bit accumulator in 18.14 format. - This approach provides 17 guard bits and there is no risk of overflow as long as max(srcALen, srcBLen)<131072. - The 18.14 result is then truncated to 18.7 format by discarding the low 7 bits and then saturated to 1.7 format. + The function is implemented using a 32-bit internal + accumulator. Both the inputs are represented in 1.7 format and multiplications + yield a 2.14 result. The 2.14 intermediate results are accumulated in a 32-bit + accumulator in 18.14 format. This approach provides 17 guard bits and there is + no risk of overflow as long as max(srcALen, srcBLen)<131072. + The 18.14 result is then truncated to 18.7 format by + discarding the low 7 bits and then saturated to 1.7 format. */ -void arm_conv_opt_q7( - const q7_t * pSrcA, - uint32_t srcALen, - const q7_t * pSrcB, - uint32_t srcBLen, - q7_t * pDst, - q15_t * pScratch1, - q15_t * pScratch2) -{ - q15_t *pScr1 = pScratch1; /* Temporary pointer for scratch */ - q15_t *pScr2 = pScratch2; /* Temporary pointer for scratch */ - q15_t x4; /* Temporary input variable */ - q15_t *py; /* Temporary input2 pointer */ - q31_t acc0, acc1, acc2, acc3; /* Accumulators */ - const q7_t *pIn1, *pIn2; /* InputA and inputB pointer */ - uint32_t j, k, blkCnt, tapCnt; /* Loop counter */ - q31_t x1, x2, x3, y1; /* Temporary input variables */ - const q7_t *px; /* Temporary input1 pointer */ - q7_t *pOut = pDst; /* Output pointer */ - q7_t out0, out1, out2, out3; /* Temporary variables */ +void arm_conv_opt_q7(const q7_t *pSrcA, uint32_t srcALen, const q7_t *pSrcB, + uint32_t srcBLen, q7_t *pDst, q15_t *pScratch1, + q15_t *pScratch2) { + q15_t *pScr1 = pScratch1; /* Temporary pointer for scratch */ + q15_t *pScr2 = pScratch2; /* Temporary pointer for scratch */ + q15_t x4; /* Temporary input variable */ + q15_t *py; /* Temporary input2 pointer */ + q31_t acc0, acc1, acc2, acc3; /* Accumulators */ + const q7_t *pIn1, *pIn2; /* InputA and inputB pointer */ + uint32_t j, k, blkCnt, tapCnt; /* Loop counter */ + q31_t x1, x2, x3, y1; /* Temporary input variables */ + const q7_t *px; /* Temporary input1 pointer */ + q7_t *pOut = pDst; /* Output pointer */ + q7_t out0, out1, out2, out3; /* Temporary variables */ /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ - if (srcALen >= srcBLen) - { + if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; - } - else - { + } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; @@ -108,18 +104,18 @@ void arm_conv_opt_q7( /* Apply loop unrolling and do 4 Copies simultaneously. */ k = srcBLen >> 2U; - /* First part of the processing with loop unrolling copies 4 data points at a time. + /* First part of the processing with loop unrolling copies 4 data points at a + *time. ** a second loop below copies for the remaining 1 to 3 samples. */ - while (k > 0U) - { + while (k > 0U) { /* copy second buffer in reversal manner */ - x4 = (q15_t) *px--; + x4 = (q15_t)*px--; *pScr2++ = x4; - x4 = (q15_t) *px--; + x4 = (q15_t)*px--; *pScr2++ = x4; - x4 = (q15_t) *px--; + x4 = (q15_t)*px--; *pScr2++ = x4; - x4 = (q15_t) *px--; + x4 = (q15_t)*px--; *pScr2++ = x4; /* Decrement loop counter */ @@ -130,10 +126,9 @@ void arm_conv_opt_q7( ** No loop unrolling is used. */ k = srcBLen % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* copy second buffer in reversal manner for remaining samples */ - x4 = (q15_t) *px--; + x4 = (q15_t)*px--; *pScr2++ = x4; /* Decrement loop counter */ @@ -150,18 +145,18 @@ void arm_conv_opt_q7( /* Apply loop unrolling and do 4 Copies simultaneously. */ k = srcALen >> 2U; - /* First part of the processing with loop unrolling copies 4 data points at a time. + /* First part of the processing with loop unrolling copies 4 data points at a + *time. ** a second loop below copies for the remaining 1 to 3 samples. */ - while (k > 0U) - { + while (k > 0U) { /* copy second buffer in reversal manner */ - x4 = (q15_t) *pIn1++; + x4 = (q15_t)*pIn1++; *pScr1++ = x4; - x4 = (q15_t) *pIn1++; + x4 = (q15_t)*pIn1++; *pScr1++ = x4; - x4 = (q15_t) *pIn1++; + x4 = (q15_t)*pIn1++; *pScr1++ = x4; - x4 = (q15_t) *pIn1++; + x4 = (q15_t)*pIn1++; *pScr1++ = x4; /* Decrement loop counter */ @@ -172,10 +167,9 @@ void arm_conv_opt_q7( ** No loop unrolling is used. */ k = srcALen % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* copy second buffer in reversal manner for remaining samples */ - x4 = (q15_t) * pIn1++; + x4 = (q15_t)*pIn1++; *pScr1++ = x4; /* Decrement the loop counter */ @@ -192,15 +186,14 @@ void arm_conv_opt_q7( py = pScratch2; /* Initialization of pIn2 pointer */ - pIn2 = (q7_t *) py; + pIn2 = (q7_t *)py; pScr2 = py; /* Actual convolution process starts here */ blkCnt = (srcALen + srcBLen - 1U) >> 2U; - while (blkCnt > 0) - { + while (blkCnt > 0) { /* Initialze temporary scratch pointer as scratch1 */ pScr1 = pScratch1; @@ -211,17 +204,16 @@ void arm_conv_opt_q7( acc3 = 0; /* Read two samples from scratch1 buffer */ - x1 = read_q15x2_ia (&pScr1); + x1 = read_q15x2_ia(&pScr1); /* Read next two samples from scratch1 buffer */ - x2 = read_q15x2_ia (&pScr1); + x2 = read_q15x2_ia(&pScr1); tapCnt = (srcBLen) >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read four samples from smaller buffer */ - y1 = read_q15x2_ia (&pScr2); + y1 = read_q15x2_ia(&pScr2); /* multiply and accumlate */ acc0 = __SMLAD(x1, y1, acc0); @@ -238,7 +230,7 @@ void arm_conv_opt_q7( acc1 = __SMLADX(x3, y1, acc1); /* Read next two samples from scratch1 buffer */ - x1 = read_q15x2_ia (&pScr1); + x1 = read_q15x2_ia(&pScr1); /* pack input data */ #ifndef ARM_MATH_BIG_ENDIAN @@ -250,7 +242,7 @@ void arm_conv_opt_q7( acc3 = __SMLADX(x3, y1, acc3); /* Read four samples from smaller buffer */ - y1 = read_q15x2_ia (&pScr2); + y1 = read_q15x2_ia(&pScr2); acc0 = __SMLAD(x2, y1, acc0); @@ -258,7 +250,7 @@ void arm_conv_opt_q7( acc1 = __SMLADX(x3, y1, acc1); - x2 = read_q15x2_ia (&pScr1); + x2 = read_q15x2_ia(&pScr1); #ifndef ARM_MATH_BIG_ENDIAN x3 = __PKHBT(x2, x1, 0); @@ -272,14 +264,14 @@ void arm_conv_opt_q7( tapCnt--; } - /* Update scratch pointer for remaining samples of smaller length sequence */ + /* Update scratch pointer for remaining samples of smaller length sequence + */ pScr1 -= 4U; /* apply same above for remaining samples of smaller length sequence */ - tapCnt = (srcBLen) & 3U; + tapCnt = (srcBLen)&3U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* accumlate the results */ acc0 += (*pScr1++ * *pScr2); acc1 += (*pScr1++ * *pScr2); @@ -295,12 +287,12 @@ void arm_conv_opt_q7( blkCnt--; /* Store the result in the accumulator in the destination buffer. */ - out0 = (q7_t) (__SSAT(acc0 >> 7U, 8)); - out1 = (q7_t) (__SSAT(acc1 >> 7U, 8)); - out2 = (q7_t) (__SSAT(acc2 >> 7U, 8)); - out3 = (q7_t) (__SSAT(acc3 >> 7U, 8)); + out0 = (q7_t)(__SSAT(acc0 >> 7U, 8)); + out1 = (q7_t)(__SSAT(acc1 >> 7U, 8)); + out2 = (q7_t)(__SSAT(acc2 >> 7U, 8)); + out3 = (q7_t)(__SSAT(acc3 >> 7U, 8)); - write_q7x4_ia (&pOut, __PACKq7(out0, out1, out2, out3)); + write_q7x4_ia(&pOut, __PACKq7(out0, out1, out2, out3)); /* Initialization of inputB pointer */ pScr2 = py; @@ -311,8 +303,7 @@ void arm_conv_opt_q7( blkCnt = (srcALen + srcBLen - 1U) & 0x3; /* Calculate convolution for remaining samples of Bigger length sequence */ - while (blkCnt > 0) - { + while (blkCnt > 0) { /* Initialze temporary scratch pointer as scratch1 */ pScr1 = pScratch1; @@ -321,8 +312,7 @@ void arm_conv_opt_q7( tapCnt = (srcBLen) >> 1U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { acc0 += (*pScr1++ * *pScr2++); acc0 += (*pScr1++ * *pScr2++); @@ -330,11 +320,10 @@ void arm_conv_opt_q7( tapCnt--; } - tapCnt = (srcBLen) & 1U; + tapCnt = (srcBLen)&1U; /* apply same above for remaining samples of smaller length sequence */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* accumlate the results */ acc0 += (*pScr1++ * *pScr2++); @@ -345,14 +334,13 @@ void arm_conv_opt_q7( blkCnt--; /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q7_t) (__SSAT(acc0 >> 7U, 8)); + *pOut++ = (q7_t)(__SSAT(acc0 >> 7U, 8)); /* Initialization of inputB pointer */ pScr2 = py; pScratch1 += 1U; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_f32.c index e25f9ab..6820194 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_f32.c @@ -35,27 +35,30 @@ /** @defgroup PartialConv Partial Convolution - Partial Convolution is equivalent to Convolution except that a subset of the output samples is generated. - Each function has two additional arguments. - firstIndex specifies the starting index of the subset of output samples. - numPoints is the number of output samples to compute. + Partial Convolution is equivalent to Convolution except that a subset of the + output samples is generated. Each function has two additional arguments. + firstIndex specifies the starting index of the subset of output + samples. numPoints is the number of output samples to compute. The function computes the output in the range [firstIndex, ..., firstIndex+numPoints-1]. The output array pDst contains numPoints values. The allowable range of output indices is [0 srcALen+srcBLen-2]. - If the requested subset does not fall in this range then the functions return ARM_MATH_ARGUMENT_ERROR. - Otherwise the functions return ARM_MATH_SUCCESS. + If the requested subset does not fall in this range then the functions return + ARM_MATH_ARGUMENT_ERROR. Otherwise the functions return ARM_MATH_SUCCESS. \note Refer to \ref arm_conv_f32() for details on fixed point behavior. @par Fast Versions - Fast versions are supported for Q31 and Q15 of partial convolution. - Cycles for Fast versions are less compared to Q31 and Q15 of partial conv and the design requires - the input signals should be scaled down to avoid intermediate overflows. + Fast versions are supported for Q31 and Q15 of partial + convolution. Cycles for Fast versions are less compared to Q31 and Q15 of + partial conv and the design requires the input signals should be scaled down + to avoid intermediate overflows. @par Opt Versions - Opt versions are supported for Q15 and Q7. Design uses internal scratch buffer for getting good optimisation. - These versions are optimised in cycles and consumes more memory (Scratch memory) compared to Q15 and Q7 versions of partial convolution + Opt versions are supported for Q15 and Q7. Design uses + internal scratch buffer for getting good optimisation. These versions are + optimised in cycles and consumes more memory (Scratch memory) compared to Q15 + and Q7 versions of partial convolution */ /** @@ -69,64 +72,55 @@ @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence - @param[out] pDst points to the location where the output result is written + @param[out] pDst points to the location where the output result is + written @param[in] firstIndex is the first output sample to start with @param[in] numPoints is the number of output points to be computed @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : requested subset is not in the range [0 srcALen+srcBLen-2] + - \ref ARM_MATH_ARGUMENT_ERROR : requested subset is not in + the range [0 srcALen+srcBLen-2] */ -arm_status arm_conv_partial_f32( - const float32_t * pSrcA, - uint32_t srcALen, - const float32_t * pSrcB, - uint32_t srcBLen, - float32_t * pDst, - uint32_t firstIndex, - uint32_t numPoints) -{ +arm_status arm_conv_partial_f32(const float32_t *pSrcA, uint32_t srcALen, + const float32_t *pSrcB, uint32_t srcBLen, + float32_t *pDst, uint32_t firstIndex, + uint32_t numPoints) { #if (1) -//#if !defined(ARM_MATH_CM0_FAMILY) + //#if !defined(ARM_MATH_CM0_FAMILY) - const float32_t *pIn1 = pSrcA; /* InputA pointer */ - const float32_t *pIn2 = pSrcB; /* InputB pointer */ - float32_t *pOut = pDst; /* Output pointer */ - const float32_t *px; /* Intermediate inputA pointer */ - const float32_t *py; /* Intermediate inputB pointer */ - const float32_t *pSrc1, *pSrc2; /* Intermediate pointers */ - float32_t sum; /* Accumulator */ - uint32_t j, k, count, blkCnt, check; - int32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ - arm_status status; /* Status of Partial convolution */ + const float32_t *pIn1 = pSrcA; /* InputA pointer */ + const float32_t *pIn2 = pSrcB; /* InputB pointer */ + float32_t *pOut = pDst; /* Output pointer */ + const float32_t *px; /* Intermediate inputA pointer */ + const float32_t *py; /* Intermediate inputB pointer */ + const float32_t *pSrc1, *pSrc2; /* Intermediate pointers */ + float32_t sum; /* Accumulator */ + uint32_t j, k, count, blkCnt, check; + int32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ + arm_status status; /* Status of Partial convolution */ -#if defined (ARM_MATH_LOOPUNROLL) - float32_t acc0, acc1, acc2, acc3; /* Accumulator */ - float32_t x0, x1, x2, x3, c0; /* Temporary variables */ +#if defined(ARM_MATH_LOOPUNROLL) + float32_t acc0, acc1, acc2, acc3; /* Accumulator */ + float32_t x0, x1, x2, x3, c0; /* Temporary variables */ #endif /* Check for range of output samples to be calculated */ - if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) - { + if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) { /* Set status as ARM_MATH_ARGUMENT_ERROR */ status = ARM_MATH_ARGUMENT_ERROR; - } - else - { + } else { /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ - if (srcALen >= srcBLen) - { + if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; - } - else - { + } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; @@ -142,21 +136,30 @@ arm_status arm_conv_partial_f32( /* Conditions to check which loopCounter holds * the first and last indices of the output samples to be calculated. */ check = firstIndex + numPoints; - blockSize3 = ((int32_t)check > (int32_t)srcALen) ? (int32_t)check - (int32_t)srcALen : 0; - blockSize3 = ((int32_t)firstIndex > (int32_t)srcALen - 1) ? blockSize3 - (int32_t)firstIndex + (int32_t)srcALen : blockSize3; - blockSize1 = ((int32_t) srcBLen - 1) - (int32_t) firstIndex; - blockSize1 = (blockSize1 > 0) ? ((check > (srcBLen - 1U)) ? blockSize1 : (int32_t) numPoints) : 0; - blockSize2 = ((int32_t) check - blockSize3) - (blockSize1 + (int32_t) firstIndex); + blockSize3 = ((int32_t)check > (int32_t)srcALen) + ? (int32_t)check - (int32_t)srcALen + : 0; + blockSize3 = ((int32_t)firstIndex > (int32_t)srcALen - 1) + ? blockSize3 - (int32_t)firstIndex + (int32_t)srcALen + : blockSize3; + blockSize1 = ((int32_t)srcBLen - 1) - (int32_t)firstIndex; + blockSize1 = + (blockSize1 > 0) + ? ((check > (srcBLen - 1U)) ? blockSize1 : (int32_t)numPoints) + : 0; + blockSize2 = + ((int32_t)check - blockSize3) - (blockSize1 + (int32_t)firstIndex); blockSize2 = (blockSize2 > 0) ? blockSize2 : 0; - /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ x[n-N+1] * y[N -1] */ + /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ + * x[n-N+1] * y[N -1] */ /* The function is internally - * divided into three stages according to the number of multiplications that has to be - * taken place between inputA samples and inputB samples. In the first stage of the - * algorithm, the multiplications increase by one for every iteration. - * In the second stage of the algorithm, srcBLen number of multiplications are done. - * In the third stage of the algorithm, the multiplications decrease by one - * for every iteration. */ + * divided into three stages according to the number of multiplications that + * has to be taken place between inputA samples and inputB samples. In the + * first stage of the algorithm, the multiplications increase by one for + * every iteration. In the second stage of the algorithm, srcBLen number of + * multiplications are done. In the third stage of the algorithm, the + * multiplications decrease by one for every iteration. */ /* Set the output pointer to point to the firstIndex * of the output sample to be calculated. */ @@ -169,7 +172,8 @@ arm_status arm_conv_partial_f32( /* sum = x[0] * y[0] * sum = x[0] * y[1] + x[1] * y[0] * .... - * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * y[0] + * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] + * * y[0] */ /* In this stage the MAC operations are increased by 1 for every iteration. @@ -190,18 +194,16 @@ arm_status arm_conv_partial_f32( * ----------------------*/ /* The first stage starts here */ - while (blockSize1 > 0U) - { + while (blockSize1 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0.0f; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = count >> 2U; - while (k > 0U) - { + while (k > 0U) { /* x[0] * y[srcBLen - 1] */ sum += *px++ * *py--; @@ -228,8 +230,7 @@ arm_status arm_conv_partial_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ sum += *px++ * *py--; @@ -258,16 +259,14 @@ arm_status arm_conv_partial_f32( /* sum = x[0] * y[srcBLen-1] + x[1] * y[srcBLen-2] +...+ x[srcBLen-1] * y[0] * sum = x[1] * y[srcBLen-1] + x[2] * y[srcBLen-2] +...+ x[srcBLen] * y[0] * .... - * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ x[srcALen-1] * y[0] + * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] + * +...+ x[srcALen-1] * y[0] */ /* Working pointer of inputA */ - if ((int32_t)firstIndex - (int32_t)srcBLen + 1 > 0) - { + if ((int32_t)firstIndex - (int32_t)srcBLen + 1 > 0) { pSrc1 = pIn1 + firstIndex - srcBLen + 1; - } - else - { + } else { pSrc1 = pIn1; } px = pSrc1; @@ -283,18 +282,16 @@ arm_status arm_conv_partial_f32( * Stage2 process * ------------------*/ - /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed. - * So, to loop unroll over blockSize2, + /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are + * performed. So, to loop unroll over blockSize2, * srcBLen should be greater than or equal to 4 */ - if (srcBLen >= 4U) - { -#if defined (ARM_MATH_LOOPUNROLL) + if (srcBLen >= 4U) { +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = ((uint32_t) blockSize2 >> 2U); + blkCnt = ((uint32_t)blockSize2 >> 2U); - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Set all accumulators to zero */ acc0 = 0.0f; acc1 = 0.0f; @@ -309,10 +306,11 @@ arm_status arm_conv_partial_f32( /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = srcBLen >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. - ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - do - { + /* First part of the processing with loop unrolling. Compute 4 MACs at + *a time. + ** a second loop below computes MACs for the remaining 1 to 3 samples. + */ + do { /* Read y[srcBLen - 1] sample */ c0 = *py--; /* Read x[3] sample */ @@ -375,12 +373,12 @@ arm_status arm_conv_partial_f32( } while (--k); - /* If the srcBLen is not a multiple of 4, compute any remaining MACs here. + /* If the srcBLen is not a multiple of 4, compute any remaining MACs + *here. ** No loop unrolling is used. */ k = srcBLen % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* Read y[srcBLen - 5] sample */ c0 = *py--; /* Read x[7] sample */ @@ -423,7 +421,7 @@ arm_status arm_conv_partial_f32( } /* Loop unrolling: Compute remaining outputs */ - blkCnt = (uint32_t) blockSize2 % 0x4U; + blkCnt = (uint32_t)blockSize2 % 0x4U; #else @@ -432,18 +430,16 @@ arm_status arm_conv_partial_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0.0f; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = srcBLen >> 2U; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ sum += *px++ * *py--; sum += *px++ * *py--; @@ -464,8 +460,7 @@ arm_status arm_conv_partial_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ sum += *px++ * *py--; @@ -486,23 +481,19 @@ arm_status arm_conv_partial_f32( /* Decrement loop counter */ blkCnt--; } - } - else - { + } else { /* If the srcBLen is not a multiple of 4, * the blockSize2 loop cannot be unrolled by 4 */ - blkCnt = (uint32_t) blockSize2; + blkCnt = (uint32_t)blockSize2; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0.0f; /* srcBLen number of MACS should be performed */ k = srcBLen; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ sum += *px++ * *py--; @@ -525,13 +516,14 @@ arm_status arm_conv_partial_f32( } } - /* -------------------------- * Initializations of stage3 * -------------------------*/ - /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * y[srcBLen-2] +...+ x[srcALen-1] * y[1] - * sum += x[srcALen-srcBLen+2] * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * y[2] + /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * + * y[srcBLen-2] +...+ x[srcALen-1] * y[1] sum += x[srcALen-srcBLen+2] * + * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * + * y[2] * .... * sum += x[srcALen-2] * y[srcBLen-1] + x[srcALen-1] * y[srcBLen-2] * sum += x[srcALen-1] * y[srcBLen-1] @@ -553,18 +545,16 @@ arm_status arm_conv_partial_f32( * Stage3 process * ------------------*/ - while (blockSize3 > 0U) - { + while (blockSize3 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0.0f; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = count >> 2U; - while (k > 0U) - { + while (k > 0U) { /* sum += x[srcALen - srcBLen + 1] * y[srcBLen - 1] */ sum += *px++ * *py--; @@ -591,8 +581,7 @@ arm_status arm_conv_partial_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ /* sum += x[srcALen-1] * y[srcBLen-1] */ sum += *px++ * *py--; @@ -623,36 +612,30 @@ arm_status arm_conv_partial_f32( return (status); #else -/* alternate version for CM0_FAMILY */ + /* alternate version for CM0_FAMILY */ - const float32_t *pIn1 = pSrcA; /* InputA pointer */ - const float32_t *pIn2 = pSrcB; /* InputB pointer */ - float32_t sum; /* Accumulator */ - uint32_t i, j; /* Loop counters */ - arm_status status; /* Status of Partial convolution */ + const float32_t *pIn1 = pSrcA; /* InputA pointer */ + const float32_t *pIn2 = pSrcB; /* InputB pointer */ + float32_t sum; /* Accumulator */ + uint32_t i, j; /* Loop counters */ + arm_status status; /* Status of Partial convolution */ /* Check for range of output samples to be calculated */ - if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) - { + if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) { /* Set status as ARM_MATH_ARGUMENT_ERROR */ status = ARM_MATH_ARGUMENT_ERROR; - } - else - { + } else { /* Loop to calculate convolution for output length number of values */ - for (i = firstIndex; i <= (firstIndex + numPoints - 1); i++) - { + for (i = firstIndex; i <= (firstIndex + numPoints - 1); i++) { /* Initialize sum with zero to carry on MAC operations */ sum = 0.0f; /* Loop to perform MAC operations according to convolution equation */ - for (j = 0U; j <= i; j++) - { + for (j = 0U; j <= i; j++) { /* Check the array limitations */ - if (((i - j) < srcBLen) && (j < srcALen)) - { + if (((i - j) < srcBLen) && (j < srcALen)) { /* z[i] += x[i-j] * y[j] */ - sum += ( pIn1[j] * pIn2[i - j]); + sum += (pIn1[j] * pIn2[i - j]); } } @@ -668,7 +651,6 @@ arm_status arm_conv_partial_f32( return (status); #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */ - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_fast_opt_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_fast_opt_q15.c index 7166b57..215aa80 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_fast_opt_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_fast_opt_q15.c @@ -43,71 +43,65 @@ @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence - @param[out] pDst points to the location where the output result is written + @param[out] pDst points to the location where the output result is + written @param[in] firstIndex is the first output sample to start with @param[in] numPoints is the number of output points to be computed - @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2 - @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen) + @param[in] pScratch1 points to scratch buffer of size max(srcALen, + srcBLen) + 2*min(srcALen, srcBLen) - 2 + @param[in] pScratch2 points to scratch buffer of size min(srcALen, + srcBLen) @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : requested subset is not in the range [0 srcALen+srcBLen-2] + - \ref ARM_MATH_ARGUMENT_ERROR : requested subset is not in + the range [0 srcALen+srcBLen-2] @remark - Refer to \ref arm_conv_partial_q15() for a slower implementation of this function which uses a 64-bit accumulator to avoid wrap around distortion. + Refer to \ref arm_conv_partial_q15() for a slower + implementation of this function which uses a 64-bit accumulator to avoid wrap + around distortion. */ -arm_status arm_conv_partial_fast_opt_q15( - const q15_t * pSrcA, - uint32_t srcALen, - const q15_t * pSrcB, - uint32_t srcBLen, - q15_t * pDst, - uint32_t firstIndex, - uint32_t numPoints, - q15_t * pScratch1, - q15_t * pScratch2) -{ - q15_t *pOut = pDst; /* Output pointer */ - q15_t *pScr1 = pScratch1; /* Temporary pointer for scratch1 */ - q15_t *pScr2 = pScratch2; /* Temporary pointer for scratch1 */ - q31_t acc0; /* Accumulator */ - const q15_t *pIn1; /* InputA pointer */ - const q15_t *pIn2; /* InputB pointer */ - const q15_t *px; /* Intermediate inputA pointer */ - q15_t *py; /* Intermediate inputB pointer */ - uint32_t j, k, blkCnt; /* Loop counter */ - uint32_t tapCnt; /* Loop count */ - arm_status status; /* Status variable */ - q31_t x1; /* Temporary variables to hold state and coefficient values */ - q31_t y1; /* State variables */ +arm_status arm_conv_partial_fast_opt_q15(const q15_t *pSrcA, uint32_t srcALen, + const q15_t *pSrcB, uint32_t srcBLen, + q15_t *pDst, uint32_t firstIndex, + uint32_t numPoints, q15_t *pScratch1, + q15_t *pScratch2) { + q15_t *pOut = pDst; /* Output pointer */ + q15_t *pScr1 = pScratch1; /* Temporary pointer for scratch1 */ + q15_t *pScr2 = pScratch2; /* Temporary pointer for scratch1 */ + q31_t acc0; /* Accumulator */ + const q15_t *pIn1; /* InputA pointer */ + const q15_t *pIn2; /* InputB pointer */ + const q15_t *px; /* Intermediate inputA pointer */ + q15_t *py; /* Intermediate inputB pointer */ + uint32_t j, k, blkCnt; /* Loop counter */ + uint32_t tapCnt; /* Loop count */ + arm_status status; /* Status variable */ + q31_t x1; /* Temporary variables to hold state and coefficient values */ + q31_t y1; /* State variables */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t acc1, acc2, acc3; /* Accumulator */ - q31_t x2, x3; /* Temporary variables to hold state and coefficient values */ - q31_t y2; /* State variables */ +#if defined(ARM_MATH_LOOPUNROLL) + q31_t acc1, acc2, acc3; /* Accumulator */ + q31_t x2, x3; /* Temporary variables to hold state and coefficient values */ + q31_t y2; /* State variables */ #endif /* Check for range of output samples to be calculated */ - if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) - { + if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) { /* Set status as ARM_MATH_ARGUMENT_ERROR */ status = ARM_MATH_ARGUMENT_ERROR; - } - else - { + } else { /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ - if (srcALen >= srcBLen) - { + if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; - } - else - { + } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; @@ -129,14 +123,14 @@ arm_status arm_conv_partial_fast_opt_q15( /* points to smaller length sequence */ px = pIn2; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = srcBLen >> 2U; - /* Copy smaller length input sequence in reverse order into second scratch buffer */ - while (k > 0U) - { + /* Copy smaller length input sequence in reverse order into second scratch + * buffer */ + while (k > 0U) { /* copy second buffer in reversal manner */ *pScr2-- = *px++; *pScr2-- = *px++; @@ -157,8 +151,7 @@ arm_status arm_conv_partial_fast_opt_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* copy second buffer in reversal manner for remaining samples */ *pScr2-- = *px++; @@ -199,13 +192,12 @@ arm_status arm_conv_partial_fast_opt_q15( /* Actual convolution process starts here */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = (numPoints) >> 2; - while (blkCnt > 0) - { + while (blkCnt > 0) { /* Initialze temporary scratch pointer as scratch1 */ pScr1 = pScratch1; @@ -216,19 +208,18 @@ arm_status arm_conv_partial_fast_opt_q15( acc3 = 0; /* Read two samples from scratch1 buffer */ - x1 = read_q15x2_ia (&pScr1); + x1 = read_q15x2_ia(&pScr1); /* Read next two samples from scratch1 buffer */ - x2 = read_q15x2_ia (&pScr1); + x2 = read_q15x2_ia(&pScr1); tapCnt = (srcBLen) >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read four samples from smaller buffer */ - y1 = read_q15x2_ia ((q15_t **) &pIn2); - y2 = read_q15x2_ia ((q15_t **) &pIn2); + y1 = read_q15x2_ia((q15_t **)&pIn2); + y2 = read_q15x2_ia((q15_t **)&pIn2); /* multiply and accumlate */ acc0 = __SMLAD(x1, y1, acc0); @@ -245,7 +236,7 @@ arm_status arm_conv_partial_fast_opt_q15( acc1 = __SMLADX(x3, y1, acc1); /* Read next two samples from scratch1 buffer */ - x1 = read_q15x2_ia (&pScr1); + x1 = read_q15x2_ia(&pScr1); /* multiply and accumlate */ acc0 = __SMLAD(x2, y2, acc0); @@ -261,7 +252,7 @@ arm_status arm_conv_partial_fast_opt_q15( acc3 = __SMLADX(x3, y1, acc3); acc1 = __SMLADX(x3, y2, acc1); - x2 = read_q15x2_ia (&pScr1); + x2 = read_q15x2_ia(&pScr1); #ifndef ARM_MATH_BIG_ENDIAN x3 = __PKHBT(x2, x1, 0); @@ -276,14 +267,14 @@ arm_status arm_conv_partial_fast_opt_q15( tapCnt--; } - /* Update scratch pointer for remaining samples of smaller length sequence */ + /* Update scratch pointer for remaining samples of smaller length sequence + */ pScr1 -= 4U; /* apply same above for remaining samples of smaller length sequence */ - tapCnt = (srcBLen) & 3U; + tapCnt = (srcBLen)&3U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* accumlate the results */ acc0 += (*pScr1++ * *pIn2); acc1 += (*pScr1++ * *pIn2); @@ -299,12 +290,16 @@ arm_status arm_conv_partial_fast_opt_q15( blkCnt--; /* Store the results in the accumulators in the destination buffer. */ -#ifndef ARM_MATH_BIG_ENDIAN - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc0 >> 15), 16), __SSAT((acc1 >> 15), 16), 16)); - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc2 >> 15), 16), __SSAT((acc3 >> 15), 16), 16)); +#ifndef ARM_MATH_BIG_ENDIAN + write_q15x2_ia(&pOut, __PKHBT(__SSAT((acc0 >> 15), 16), + __SSAT((acc1 >> 15), 16), 16)); + write_q15x2_ia(&pOut, __PKHBT(__SSAT((acc2 >> 15), 16), + __SSAT((acc3 >> 15), 16), 16)); #else - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc1 >> 15), 16), __SSAT((acc0 >> 15), 16), 16)); - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc3 >> 15), 16), __SSAT((acc2 >> 15), 16), 16)); + write_q15x2_ia(&pOut, __PKHBT(__SSAT((acc1 >> 15), 16), + __SSAT((acc0 >> 15), 16), 16)); + write_q15x2_ia(&pOut, __PKHBT(__SSAT((acc3 >> 15), 16), + __SSAT((acc2 >> 15), 16), 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Initialization of inputB pointer */ @@ -324,8 +319,7 @@ arm_status arm_conv_partial_fast_opt_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Calculate convolution for remaining samples of Bigger length sequence */ - while (blkCnt > 0) - { + while (blkCnt > 0) { /* Initialze temporary scratch pointer as scratch1 */ pScr1 = pScratch1; @@ -334,13 +328,12 @@ arm_status arm_conv_partial_fast_opt_q15( tapCnt = (srcBLen) >> 1U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read next two samples from scratch1 buffer */ - x1 = read_q15x2_ia (&pScr1); + x1 = read_q15x2_ia(&pScr1); /* Read two samples from smaller buffer */ - y1 = read_q15x2_ia ((q15_t **) &pIn2); + y1 = read_q15x2_ia((q15_t **)&pIn2); /* multiply and accumlate */ acc0 = __SMLAD(x1, y1, acc0); @@ -349,11 +342,10 @@ arm_status arm_conv_partial_fast_opt_q15( tapCnt--; } - tapCnt = (srcBLen) & 1U; + tapCnt = (srcBLen)&1U; /* apply same above for remaining samples of smaller length sequence */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* accumlate the results */ acc0 += (*pScr1++ * *pIn2++); @@ -365,13 +357,12 @@ arm_status arm_conv_partial_fast_opt_q15( /* The result is in 2.30 format. Convert to 1.15 with saturation. ** Then store the output in the destination buffer. */ - *pOut++ = (q15_t) (__SSAT((acc0 >> 15), 16)); + *pOut++ = (q15_t)(__SSAT((acc0 >> 15), 16)); /* Initialization of inputB pointer */ pIn2 = py; pScratch1 += 1U; - } /* Set status as ARM_MATH_SUCCESS */ diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_fast_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_fast_q15.c index 535fbc7..122d77e 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_fast_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_fast_q15.c @@ -43,58 +43,51 @@ @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence - @param[out] pDst points to the location where the output result is written + @param[out] pDst points to the location where the output result is + written @param[in] firstIndex is the first output sample to start with @param[in] numPoints is the number of output points to be computed @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : requested subset is not in the range [0 srcALen+srcBLen-2] + - \ref ARM_MATH_ARGUMENT_ERROR : requested subset is not in + the range [0 srcALen+srcBLen-2] @remark - Refer to \ref arm_conv_partial_q15() for a slower implementation of this function which uses a 64-bit accumulator to avoid wrap around distortion. + Refer to \ref arm_conv_partial_q15() for a slower + implementation of this function which uses a 64-bit accumulator to avoid wrap + around distortion. */ -arm_status arm_conv_partial_fast_q15( - const q15_t * pSrcA, - uint32_t srcALen, - const q15_t * pSrcB, - uint32_t srcBLen, - q15_t * pDst, - uint32_t firstIndex, - uint32_t numPoints) -{ - const q15_t *pIn1; /* InputA pointer */ - const q15_t *pIn2; /* InputB pointer */ - q15_t *pOut = pDst; /* Output pointer */ - q31_t sum, acc0, acc1, acc2, acc3; /* Accumulator */ - const q15_t *px; /* Intermediate inputA pointer */ - const q15_t *py; /* Intermediate inputB pointer */ - const q15_t *pSrc1, *pSrc2; /* Intermediate pointers */ - q31_t x0, x1, x2, x3, c0; /* Temporary input variables */ - uint32_t j, k, count, blkCnt, check; - int32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ - arm_status status; /* Status of Partial convolution */ +arm_status arm_conv_partial_fast_q15(const q15_t *pSrcA, uint32_t srcALen, + const q15_t *pSrcB, uint32_t srcBLen, + q15_t *pDst, uint32_t firstIndex, + uint32_t numPoints) { + const q15_t *pIn1; /* InputA pointer */ + const q15_t *pIn2; /* InputB pointer */ + q15_t *pOut = pDst; /* Output pointer */ + q31_t sum, acc0, acc1, acc2, acc3; /* Accumulator */ + const q15_t *px; /* Intermediate inputA pointer */ + const q15_t *py; /* Intermediate inputB pointer */ + const q15_t *pSrc1, *pSrc2; /* Intermediate pointers */ + q31_t x0, x1, x2, x3, c0; /* Temporary input variables */ + uint32_t j, k, count, blkCnt, check; + int32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ + arm_status status; /* Status of Partial convolution */ /* Check for range of output samples to be calculated */ - if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) - { + if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) { /* Set status as ARM_MATH_ARGUMENT_ERROR */ status = ARM_MATH_ARGUMENT_ERROR; - } - else - { + } else { /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ - if (srcALen >= srcBLen) - { + if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; - } - else - { + } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; @@ -110,21 +103,30 @@ arm_status arm_conv_partial_fast_q15( /* Conditions to check which loopCounter holds * the first and last indices of the output samples to be calculated. */ check = firstIndex + numPoints; - blockSize3 = ((int32_t)check > (int32_t)srcALen) ? (int32_t)check - (int32_t)srcALen : 0; - blockSize3 = ((int32_t)firstIndex > (int32_t)srcALen - 1) ? blockSize3 - (int32_t)firstIndex + (int32_t)srcALen : blockSize3; - blockSize1 = ((int32_t) srcBLen - 1) - (int32_t) firstIndex; - blockSize1 = (blockSize1 > 0) ? ((check > (srcBLen - 1U)) ? blockSize1 : (int32_t) numPoints) : 0; - blockSize2 = (int32_t) check - ((blockSize3 + blockSize1) + (int32_t) firstIndex); + blockSize3 = ((int32_t)check > (int32_t)srcALen) + ? (int32_t)check - (int32_t)srcALen + : 0; + blockSize3 = ((int32_t)firstIndex > (int32_t)srcALen - 1) + ? blockSize3 - (int32_t)firstIndex + (int32_t)srcALen + : blockSize3; + blockSize1 = ((int32_t)srcBLen - 1) - (int32_t)firstIndex; + blockSize1 = + (blockSize1 > 0) + ? ((check > (srcBLen - 1U)) ? blockSize1 : (int32_t)numPoints) + : 0; + blockSize2 = + (int32_t)check - ((blockSize3 + blockSize1) + (int32_t)firstIndex); blockSize2 = (blockSize2 > 0) ? blockSize2 : 0; - /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ x[n-N+1] * y[N -1] */ + /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ + * x[n-N+1] * y[N -1] */ /* The function is internally - * divided into three stages according to the number of multiplications that has to be - * taken place between inputA samples and inputB samples. In the first stage of the - * algorithm, the multiplications increase by one for every iteration. - * In the second stage of the algorithm, srcBLen number of multiplications are done. - * In the third stage of the algorithm, the multiplications decrease by one - * for every iteration. */ + * divided into three stages according to the number of multiplications that + * has to be taken place between inputA samples and inputB samples. In the + * first stage of the algorithm, the multiplications increase by one for + * every iteration. In the second stage of the algorithm, srcBLen number of + * multiplications are done. In the third stage of the algorithm, the + * multiplications decrease by one for every iteration. */ /* Set the output pointer to point to the firstIndex * of the output sample to be calculated. */ @@ -137,7 +139,8 @@ arm_status arm_conv_partial_fast_q15( /* sum = x[0] * y[0] * sum = x[0] * y[1] + x[1] * y[0] * .... - * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * y[0] + * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] + * * y[0] */ /* In this stage the MAC operations are increased by 1 for every iteration. @@ -159,11 +162,11 @@ arm_status arm_conv_partial_fast_q15( /* For loop unrolling by 4, this stage is divided into two. */ /* First part of this stage computes the MAC operations less than 4 */ - /* Second part of this stage computes the MAC operations greater than or equal to 4 */ + /* Second part of this stage computes the MAC operations greater than or + * equal to 4 */ /* The first part of the stage starts here */ - while ((count < 4U) && (blockSize1 > 0)) - { + while ((count < 4U) && (blockSize1 > 0)) { /* Accumulator is made zero for every iteration */ sum = 0; @@ -171,8 +174,7 @@ arm_status arm_conv_partial_fast_q15( * inputA samples and inputB samples */ k = count; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ sum = __SMLAD(*px++, *py--, sum); @@ -181,7 +183,7 @@ arm_status arm_conv_partial_fast_q15( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (sum >> 15); + *pOut++ = (q15_t)(sum >> 15); /* Update the inputA and inputB pointers for next MAC calculation */ py = ++pSrc2; @@ -200,23 +202,26 @@ arm_status arm_conv_partial_fast_q15( * y[srcBLen] and y[srcBLen-1] coefficients, py is decremented by 1 */ py = py - 1; - while (blockSize1 > 0) - { + while (blockSize1 > 0) { /* Accumulator is made zero for every iteration */ sum = 0; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = count >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. - a second loop below computes MACs for the remaining 1 to 3 samples. */ - while (k > 0U) - { + /* First part of the processing with loop unrolling. Compute 4 MACs at a + time. a second loop below computes MACs for the remaining 1 to 3 + samples. */ + while (k > 0U) { /* Perform the multiply-accumulate */ - /* x[0], x[1] are multiplied with y[srcBLen - 1], y[srcBLen - 2] respectively */ - sum = __SMLADX(read_q15x2_ia ((q15_t **) &px), read_q15x2_da ((q15_t **) &py), sum); - /* x[2], x[3] are multiplied with y[srcBLen - 3], y[srcBLen - 4] respectively */ - sum = __SMLADX(read_q15x2_ia ((q15_t **) &px), read_q15x2_da ((q15_t **) &py), sum); + /* x[0], x[1] are multiplied with y[srcBLen - 1], y[srcBLen - 2] + * respectively */ + sum = __SMLADX(read_q15x2_ia((q15_t **)&px), + read_q15x2_da((q15_t **)&py), sum); + /* x[2], x[3] are multiplied with y[srcBLen - 3], y[srcBLen - 4] + * respectively */ + sum = __SMLADX(read_q15x2_ia((q15_t **)&px), + read_q15x2_da((q15_t **)&py), sum); /* Decrement loop counter */ k--; @@ -230,8 +235,7 @@ arm_status arm_conv_partial_fast_q15( No loop unrolling is used. */ k = count % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ sum = __SMLAD(*px++, *py--, sum); @@ -240,7 +244,7 @@ arm_status arm_conv_partial_fast_q15( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (sum >> 15); + *pOut++ = (q15_t)(sum >> 15); /* Update the inputA and inputB pointers for next MAC calculation */ py = ++pSrc2 - 1U; @@ -260,16 +264,14 @@ arm_status arm_conv_partial_fast_q15( /* sum = x[0] * y[srcBLen-1] + x[1] * y[srcBLen-2] +...+ x[srcBLen-1] * y[0] * sum = x[1] * y[srcBLen-1] + x[2] * y[srcBLen-2] +...+ x[srcBLen] * y[0] * .... - * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ x[srcALen-1] * y[0] + * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] + * +...+ x[srcALen-1] * y[0] */ /* Working pointer of inputA */ - if ((int32_t)firstIndex - (int32_t)srcBLen + 1 > 0) - { + if ((int32_t)firstIndex - (int32_t)srcBLen + 1 > 0) { pSrc1 = pIn1 + firstIndex - srcBLen + 1; - } - else - { + } else { pSrc1 = pIn1; } px = pSrc1; @@ -285,16 +287,14 @@ arm_status arm_conv_partial_fast_q15( * Stage2 process * ------------------*/ - /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed. - * So, to loop unroll over blockSize2, + /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are + * performed. So, to loop unroll over blockSize2, * srcBLen should be greater than or equal to 4 */ - if (srcBLen >= 4U) - { + if (srcBLen >= 4U) { /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = ((uint32_t) blockSize2 >> 2U); + blkCnt = ((uint32_t)blockSize2 >> 2U); - while (blkCnt > 0U) - { + while (blkCnt > 0U) { py = py - 1U; /* Set all accumulators to zero */ @@ -303,24 +303,23 @@ arm_status arm_conv_partial_fast_q15( acc2 = 0; acc3 = 0; - /* read x[0], x[1] samples */ - x0 = read_q15x2 ((q15_t *) px); + x0 = read_q15x2((q15_t *)px); /* read x[1], x[2] samples */ - x1 = read_q15x2 ((q15_t *) px + 1); + x1 = read_q15x2((q15_t *)px + 1); px += 2U; - /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = srcBLen >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. - ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - do - { + /* First part of the processing with loop unrolling. Compute 4 MACs at + *a time. + ** a second loop below computes MACs for the remaining 1 to 3 samples. + */ + do { /* Read the last two inputB samples using SIMD: * y[srcBLen - 1] and y[srcBLen - 2] */ - c0 = read_q15x2_da ((q15_t **) &py); + c0 = read_q15x2_da((q15_t **)&py); /* acc0 += x[0] * y[srcBLen - 1] + x[1] * y[srcBLen - 2] */ acc0 = __SMLADX(x0, c0, acc0); @@ -329,10 +328,10 @@ arm_status arm_conv_partial_fast_q15( acc1 = __SMLADX(x1, c0, acc1); /* Read x[2], x[3] */ - x2 = read_q15x2 ((q15_t *) px); + x2 = read_q15x2((q15_t *)px); /* Read x[3], x[4] */ - x3 = read_q15x2 ((q15_t *) px + 1); + x3 = read_q15x2((q15_t *)px + 1); /* acc2 += x[2] * y[srcBLen - 1] + x[3] * y[srcBLen - 2] */ acc2 = __SMLADX(x2, c0, acc2); @@ -341,7 +340,7 @@ arm_status arm_conv_partial_fast_q15( acc3 = __SMLADX(x3, c0, acc3); /* Read y[srcBLen - 3] and y[srcBLen - 4] */ - c0 = read_q15x2_da ((q15_t **) &py); + c0 = read_q15x2_da((q15_t **)&py); /* acc0 += x[2] * y[srcBLen - 3] + x[3] * y[srcBLen - 4] */ acc0 = __SMLADX(x2, c0, acc0); @@ -350,10 +349,10 @@ arm_status arm_conv_partial_fast_q15( acc1 = __SMLADX(x3, c0, acc1); /* Read x[4], x[5] */ - x0 = read_q15x2 ((q15_t *) px + 2); + x0 = read_q15x2((q15_t *)px + 2); /* Read x[5], x[6] */ - x1 = read_q15x2 ((q15_t *) px + 3); + x1 = read_q15x2((q15_t *)px + 3); px += 4U; /* acc2 += x[4] * y[srcBLen - 3] + x[5] * y[srcBLen - 4] */ @@ -367,41 +366,39 @@ arm_status arm_conv_partial_fast_q15( /* For the next MAC operations, SIMD is not used So, the 16 bit pointer if inputB, py is updated */ - /* If the srcBLen is not a multiple of 4, compute any remaining MACs here. - No loop unrolling is used. */ + /* If the srcBLen is not a multiple of 4, compute any remaining MACs + here. No loop unrolling is used. */ k = srcBLen % 0x4U; - if (k == 1U) - { + if (k == 1U) { /* Read y[srcBLen - 5] */ c0 = *(py + 1); -#ifdef ARM_MATH_BIG_ENDIAN +#ifdef ARM_MATH_BIG_ENDIAN c0 = c0 << 16U; #else c0 = c0 & 0x0000FFFF; #endif /* #ifdef ARM_MATH_BIG_ENDIAN */ /* Read x[7] */ - x3 = read_q15x2 ((q15_t *) px); + x3 = read_q15x2((q15_t *)px); px++; /* Perform the multiply-accumulate */ - acc0 = __SMLAD (x0, c0, acc0); - acc1 = __SMLAD (x1, c0, acc1); + acc0 = __SMLAD(x0, c0, acc0); + acc1 = __SMLAD(x1, c0, acc1); acc2 = __SMLADX(x1, c0, acc2); acc3 = __SMLADX(x3, c0, acc3); } - if (k == 2U) - { + if (k == 2U) { /* Read y[srcBLen - 5], y[srcBLen - 6] */ - c0 = read_q15x2 ((q15_t *) py); + c0 = read_q15x2((q15_t *)py); /* Read x[7], x[8] */ - x3 = read_q15x2 ((q15_t *) px); + x3 = read_q15x2((q15_t *)px); /* Read x[9] */ - x2 = read_q15x2 ((q15_t *) px + 1); + x2 = read_q15x2((q15_t *)px + 1); px += 2U; /* Perform the multiply-accumulate */ @@ -411,16 +408,15 @@ arm_status arm_conv_partial_fast_q15( acc3 = __SMLADX(x2, c0, acc3); } - if (k == 3U) - { + if (k == 3U) { /* Read y[srcBLen - 5], y[srcBLen - 6] */ - c0 = read_q15x2 ((q15_t *) py); + c0 = read_q15x2((q15_t *)py); /* Read x[7], x[8] */ - x3 = read_q15x2 ((q15_t *) px); + x3 = read_q15x2((q15_t *)px); /* Read x[9] */ - x2 = read_q15x2 ((q15_t *) px + 1); + x2 = read_q15x2((q15_t *)px + 1); /* Perform the multiply-accumulate */ acc0 = __SMLADX(x0, c0, acc0); @@ -428,31 +424,31 @@ arm_status arm_conv_partial_fast_q15( acc2 = __SMLADX(x3, c0, acc2); acc3 = __SMLADX(x2, c0, acc3); - c0 = *(py-1); -#ifdef ARM_MATH_BIG_ENDIAN + c0 = *(py - 1); +#ifdef ARM_MATH_BIG_ENDIAN c0 = c0 << 16U; #else c0 = c0 & 0x0000FFFF; #endif /* #ifdef ARM_MATH_BIG_ENDIAN */ /* Read x[10] */ - x3 = read_q15x2 ((q15_t *) px + 2); + x3 = read_q15x2((q15_t *)px + 2); px += 3U; /* Perform the multiply-accumulates */ acc0 = __SMLADX(x1, c0, acc0); - acc1 = __SMLAD (x2, c0, acc1); + acc1 = __SMLAD(x2, c0, acc1); acc2 = __SMLADX(x2, c0, acc2); acc3 = __SMLADX(x3, c0, acc3); } /* Store the results in the accumulators in the destination buffer. */ #ifndef ARM_MATH_BIG_ENDIAN - write_q15x2_ia (&pOut, __PKHBT(acc0 >> 15, acc1 >> 15, 16)); - write_q15x2_ia (&pOut, __PKHBT(acc2 >> 15, acc3 >> 15, 16)); + write_q15x2_ia(&pOut, __PKHBT(acc0 >> 15, acc1 >> 15, 16)); + write_q15x2_ia(&pOut, __PKHBT(acc2 >> 15, acc3 >> 15, 16)); #else - write_q15x2_ia (&pOut, __PKHBT(acc1 >> 15, acc0 >> 15, 16)); - write_q15x2_ia (&pOut, __PKHBT(acc3 >> 15, acc2 >> 15, 16)); + write_q15x2_ia(&pOut, __PKHBT(acc1 >> 15, acc0 >> 15, 16)); + write_q15x2_ia(&pOut, __PKHBT(acc3 >> 15, acc2 >> 15, 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Increment the pointer pIn1 index, count by 4 */ @@ -466,47 +462,46 @@ arm_status arm_conv_partial_fast_q15( blkCnt--; } - /* If the blockSize2 is not a multiple of 4, compute any remaining output samples here. - No loop unrolling is used. */ - blkCnt = (uint32_t) blockSize2 % 0x4U; + /* If the blockSize2 is not a multiple of 4, compute any remaining output + samples here. No loop unrolling is used. */ + blkCnt = (uint32_t)blockSize2 % 0x4U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = srcBLen >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. - a second loop below computes MACs for the remaining 1 to 3 samples. */ - while (k > 0U) - { + /* First part of the processing with loop unrolling. Compute 4 MACs at + a time. a second loop below computes MACs for the remaining 1 to 3 + samples. */ + while (k > 0U) { /* Perform the multiply-accumulates */ - sum += ((q31_t) *px++ * *py--); - sum += ((q31_t) *px++ * *py--); - sum += ((q31_t) *px++ * *py--); - sum += ((q31_t) *px++ * *py--); + sum += ((q31_t)*px++ * *py--); + sum += ((q31_t)*px++ * *py--); + sum += ((q31_t)*px++ * *py--); + sum += ((q31_t)*px++ * *py--); /* Decrement loop counter */ k--; } - /* If the srcBLen is not a multiple of 4, compute any remaining MACs here. + /* If the srcBLen is not a multiple of 4, compute any remaining MACs + *here. ** No loop unrolling is used. */ k = srcBLen % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ - sum += ((q31_t) *px++ * *py--); + sum += ((q31_t)*px++ * *py--); /* Decrement the loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (sum >> 15); + *pOut++ = (q15_t)(sum >> 15); /* Increment the pointer pIn1 index, count by 1 */ count++; @@ -518,32 +513,28 @@ arm_status arm_conv_partial_fast_q15( /* Decrement loop counter */ blkCnt--; } - } - else - { + } else { /* If the srcBLen is not a multiple of 4, * the blockSize2 loop cannot be unrolled by 4 */ - blkCnt = (uint32_t) blockSize2; + blkCnt = (uint32_t)blockSize2; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* srcBLen number of MACS should be performed */ k = srcBLen; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum += ((q31_t) *px++ * *py--); + sum += ((q31_t)*px++ * *py--); /* Decrement the loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (sum >> 15); + *pOut++ = (q15_t)(sum >> 15); /* Increment the MAC count */ count++; @@ -557,13 +548,14 @@ arm_status arm_conv_partial_fast_q15( } } - /* -------------------------- * Initializations of stage3 * -------------------------*/ - /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * y[srcBLen-2] +...+ x[srcALen-1] * y[1] - * sum += x[srcALen-srcBLen+2] * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * y[2] + /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * + * y[srcBLen-2] +...+ x[srcALen-1] * y[1] sum += x[srcALen-srcBLen+2] * + * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * + * y[2] * .... * sum += x[srcALen-2] * y[srcBLen-1] + x[srcALen-1] * y[srcBLen-2] * sum += x[srcALen-1] * y[srcBLen-1] @@ -588,29 +580,31 @@ arm_status arm_conv_partial_fast_q15( /* For loop unrolling by 4, this stage is divided into two. */ /* First part of this stage computes the MAC operations greater than 4 */ - /* Second part of this stage computes the MAC operations less than or equal to 4 */ + /* Second part of this stage computes the MAC operations less than or equal + * to 4 */ /* The first part of the stage starts here */ j = count >> 2U; - while ((j > 0U) && (blockSize3 > 0)) - { + while ((j > 0U) && (blockSize3 > 0)) { /* Accumulator is made zero for every iteration */ sum = 0; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = count >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. + /* First part of the processing with loop unrolling. Compute 4 MACs at a + *time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - while (k > 0U) - { + while (k > 0U) { /* x[srcALen - srcBLen + 1], x[srcALen - srcBLen + 2] are multiplied * with y[srcBLen - 1], y[srcBLen - 2] respectively */ - sum = __SMLADX(read_q15x2_ia ((q15_t **) &px), read_q15x2_da ((q15_t **) &py), sum); + sum = __SMLADX(read_q15x2_ia((q15_t **)&px), + read_q15x2_da((q15_t **)&py), sum); /* x[srcALen - srcBLen + 3], x[srcALen - srcBLen + 4] are multiplied * with y[srcBLen - 3], y[srcBLen - 4] respectively */ - sum = __SMLADX(read_q15x2_ia ((q15_t **) &px), read_q15x2_da ((q15_t **) &py), sum); + sum = __SMLADX(read_q15x2_ia((q15_t **)&px), + read_q15x2_da((q15_t **)&py), sum); /* Decrement loop counter */ k--; @@ -624,8 +618,7 @@ arm_status arm_conv_partial_fast_q15( No loop unrolling is used. */ k = count % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* sum += x[srcALen - srcBLen + 5] * y[srcBLen - 5] */ sum = __SMLAD(*px++, *py--, sum); @@ -634,7 +627,7 @@ arm_status arm_conv_partial_fast_q15( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (sum >> 15); + *pOut++ = (q15_t)(sum >> 15); /* Update the inputA and inputB pointers for next MAC calculation */ px = ++pSrc1; @@ -654,16 +647,14 @@ arm_status arm_conv_partial_fast_q15( * so pointer py is updated to read only one sample at a time */ py = py + 1U; - while (blockSize3 > 0) - { + while (blockSize3 > 0) { /* Accumulator is made zero for every iteration */ sum = 0; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = count; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ /* sum += x[srcALen-1] * y[srcBLen-1] */ sum = __SMLAD(*px++, *py--, sum); @@ -673,7 +664,7 @@ arm_status arm_conv_partial_fast_q15( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (sum >> 15); + *pOut++ = (q15_t)(sum >> 15); /* Update the inputA and inputB pointers for next MAC calculation */ px = ++pSrc1; @@ -692,7 +683,6 @@ arm_status arm_conv_partial_fast_q15( /* Return to application */ return (status); - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_fast_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_fast_q31.c index f232d51..5bb0430 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_fast_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_fast_q31.c @@ -43,63 +43,56 @@ @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence - @param[out] pDst points to the location where the output result is written + @param[out] pDst points to the location where the output result is + written @param[in] firstIndex is the first output sample to start with @param[in] numPoints is the number of output points to be computed @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : requested subset is not in the range [0 srcALen+srcBLen-2] + - \ref ARM_MATH_ARGUMENT_ERROR : requested subset is not in + the range [0 srcALen+srcBLen-2] @remark - Refer to \ref arm_conv_partial_q31() for a slower implementation of this function which uses a 64-bit accumulator to provide higher precision. + Refer to \ref arm_conv_partial_q31() for a slower + implementation of this function which uses a 64-bit accumulator to provide + higher precision. */ -arm_status arm_conv_partial_fast_q31( - const q31_t * pSrcA, - uint32_t srcALen, - const q31_t * pSrcB, - uint32_t srcBLen, - q31_t * pDst, - uint32_t firstIndex, - uint32_t numPoints) -{ - const q31_t *pIn1; /* InputA pointer */ - const q31_t *pIn2; /* InputB pointer */ - q31_t *pOut = pDst; /* Output pointer */ - const q31_t *px; /* Intermediate inputA pointer */ - const q31_t *py; /* Intermediate inputB pointer */ - const q31_t *pSrc1, *pSrc2; /* Intermediate pointers */ - q31_t sum; /* Accumulators */ - uint32_t j, k, count, check, blkCnt; - int32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ - arm_status status; /* Status of Partial convolution */ +arm_status arm_conv_partial_fast_q31(const q31_t *pSrcA, uint32_t srcALen, + const q31_t *pSrcB, uint32_t srcBLen, + q31_t *pDst, uint32_t firstIndex, + uint32_t numPoints) { + const q31_t *pIn1; /* InputA pointer */ + const q31_t *pIn2; /* InputB pointer */ + q31_t *pOut = pDst; /* Output pointer */ + const q31_t *px; /* Intermediate inputA pointer */ + const q31_t *py; /* Intermediate inputB pointer */ + const q31_t *pSrc1, *pSrc2; /* Intermediate pointers */ + q31_t sum; /* Accumulators */ + uint32_t j, k, count, check, blkCnt; + int32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ + arm_status status; /* Status of Partial convolution */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t acc0, acc1, acc2, acc3; /* Accumulators */ - q31_t x0, x1, x2, x3, c0; +#if defined(ARM_MATH_LOOPUNROLL) + q31_t acc0, acc1, acc2, acc3; /* Accumulators */ + q31_t x0, x1, x2, x3, c0; #endif /* Check for range of output samples to be calculated */ - if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) - { + if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) { /* Set status as ARM_MATH_ARGUMENT_ERROR */ status = ARM_MATH_ARGUMENT_ERROR; - } - else - { + } else { /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ - if (srcALen >= srcBLen) - { + if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; - } - else - { + } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; @@ -115,21 +108,30 @@ arm_status arm_conv_partial_fast_q31( /* Conditions to check which loopCounter holds * the first and last indices of the output samples to be calculated. */ check = firstIndex + numPoints; - blockSize3 = ((int32_t)check > (int32_t)srcALen) ? (int32_t)check - (int32_t)srcALen : 0; - blockSize3 = ((int32_t)firstIndex > (int32_t)srcALen - 1) ? blockSize3 - (int32_t)firstIndex + (int32_t)srcALen : blockSize3; - blockSize1 = ((int32_t) srcBLen - 1) - (int32_t) firstIndex; - blockSize1 = (blockSize1 > 0) ? ((check > (srcBLen - 1U)) ? blockSize1 : (int32_t) numPoints) : 0; - blockSize2 = (int32_t) check - ((blockSize3 + blockSize1) + (int32_t) firstIndex); + blockSize3 = ((int32_t)check > (int32_t)srcALen) + ? (int32_t)check - (int32_t)srcALen + : 0; + blockSize3 = ((int32_t)firstIndex > (int32_t)srcALen - 1) + ? blockSize3 - (int32_t)firstIndex + (int32_t)srcALen + : blockSize3; + blockSize1 = ((int32_t)srcBLen - 1) - (int32_t)firstIndex; + blockSize1 = + (blockSize1 > 0) + ? ((check > (srcBLen - 1U)) ? blockSize1 : (int32_t)numPoints) + : 0; + blockSize2 = + (int32_t)check - ((blockSize3 + blockSize1) + (int32_t)firstIndex); blockSize2 = (blockSize2 > 0) ? blockSize2 : 0; - /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ x[n-N+1] * y[N -1] */ + /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ + * x[n-N+1] * y[N -1] */ /* The function is internally - * divided into three stages according to the number of multiplications that has to be - * taken place between inputA samples and inputB samples. In the first stage of the - * algorithm, the multiplications increase by one for every iteration. - * In the second stage of the algorithm, srcBLen number of multiplications are done. - * In the third stage of the algorithm, the multiplications decrease by one - * for every iteration. */ + * divided into three stages according to the number of multiplications that + * has to be taken place between inputA samples and inputB samples. In the + * first stage of the algorithm, the multiplications increase by one for + * every iteration. In the second stage of the algorithm, srcBLen number of + * multiplications are done. In the third stage of the algorithm, the + * multiplications decrease by one for every iteration. */ /* Set the output pointer to point to the firstIndex * of the output sample to be calculated. */ @@ -142,7 +144,8 @@ arm_status arm_conv_partial_fast_q31( /* sum = x[0] * y[0] * sum = x[0] * y[1] + x[1] * y[0] * .... - * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * y[0] + * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] + * * y[0] */ /* In this stage the MAC operations are increased by 1 for every iteration. @@ -163,33 +166,27 @@ arm_status arm_conv_partial_fast_q31( * ----------------------*/ /* The first stage starts here */ - while (blockSize1 > 0U) - { + while (blockSize1 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = count >> 2U; - while (k > 0U) - { + while (k > 0U) { /* x[0] * y[srcBLen - 1] */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* x[1] * y[srcBLen - 2] */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* x[2] * y[srcBLen - 3] */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* x[3] * y[srcBLen - 4] */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* Decrement loop counter */ k--; @@ -205,11 +202,9 @@ arm_status arm_conv_partial_fast_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* Decrement loop counter */ k--; @@ -236,16 +231,14 @@ arm_status arm_conv_partial_fast_q31( /* sum = x[0] * y[srcBLen-1] + x[1] * y[srcBLen-2] +...+ x[srcBLen-1] * y[0] * sum = x[1] * y[srcBLen-1] + x[2] * y[srcBLen-2] +...+ x[srcBLen] * y[0] * .... - * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ x[srcALen-1] * y[0] + * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] + * +...+ x[srcALen-1] * y[0] */ /* Working pointer of inputA */ - if ((int32_t)firstIndex - (int32_t)srcBLen + 1 > 0) - { + if ((int32_t)firstIndex - (int32_t)srcBLen + 1 > 0) { pSrc1 = pIn1 + firstIndex - srcBLen + 1; - } - else - { + } else { pSrc1 = pIn1; } px = pSrc1; @@ -261,18 +254,16 @@ arm_status arm_conv_partial_fast_q31( * Stage2 process * ------------------*/ - /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed. - * So, to loop unroll over blockSize2, + /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are + * performed. So, to loop unroll over blockSize2, * srcBLen should be greater than or equal to 4 */ - if (srcBLen >= 4U) - { -#if defined (ARM_MATH_LOOPUNROLL) + if (srcBLen >= 4U) { +#if defined(ARM_MATH_LOOPUNROLL) - /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = ((uint32_t) blockSize2 >> 2U); + /* Loop unrolling: Compute 4 outputs at a time */ + blkCnt = ((uint32_t)blockSize2 >> 2U); - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Set all accumulators to zero */ acc0 = 0; acc1 = 0; @@ -287,10 +278,11 @@ arm_status arm_conv_partial_fast_q31( /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = srcBLen >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. - ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - do - { + /* First part of the processing with loop unrolling. Compute 4 MACs at + *a time. + ** a second loop below computes MACs for the remaining 1 to 3 samples. + */ + do { /* Read y[srcBLen - 1] sample */ c0 = *py--; /* Read x[3] sample */ @@ -298,13 +290,13 @@ arm_status arm_conv_partial_fast_q31( /* Perform the multiply-accumulate */ /* acc0 += x[0] * y[srcBLen - 1] */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x0 * c0)) >> 32); /* acc1 += x[1] * y[srcBLen - 1] */ - acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32); + acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x1 * c0)) >> 32); /* acc2 += x[2] * y[srcBLen - 1] */ - acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x2 * c0)) >> 32); + acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x2 * c0)) >> 32); /* acc3 += x[3] * y[srcBLen - 1] */ - acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x3 * c0)) >> 32); + acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x3 * c0)) >> 32); /* Read y[srcBLen - 2] sample */ c0 = *py--; @@ -313,13 +305,13 @@ arm_status arm_conv_partial_fast_q31( /* Perform the multiply-accumulate */ /* acc0 += x[1] * y[srcBLen - 2] */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x1 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x1 * c0)) >> 32); /* acc1 += x[2] * y[srcBLen - 2] */ - acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x2 * c0)) >> 32); + acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x2 * c0)) >> 32); /* acc2 += x[3] * y[srcBLen - 2] */ - acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x3 * c0)) >> 32); + acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x3 * c0)) >> 32); /* acc3 += x[4] * y[srcBLen - 2] */ - acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x0 * c0)) >> 32); + acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x0 * c0)) >> 32); /* Read y[srcBLen - 3] sample */ c0 = *py--; @@ -328,13 +320,13 @@ arm_status arm_conv_partial_fast_q31( /* Perform the multiply-accumulates */ /* acc0 += x[2] * y[srcBLen - 3] */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x2 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x2 * c0)) >> 32); /* acc1 += x[3] * y[srcBLen - 2] */ - acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x3 * c0)) >> 32); + acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x3 * c0)) >> 32); /* acc2 += x[4] * y[srcBLen - 2] */ - acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x0 * c0)) >> 32); + acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x0 * c0)) >> 32); /* acc3 += x[5] * y[srcBLen - 2] */ - acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x1 * c0)) >> 32); + acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x1 * c0)) >> 32); /* Read y[srcBLen - 4] sample */ c0 = *py--; @@ -343,22 +335,22 @@ arm_status arm_conv_partial_fast_q31( /* Perform the multiply-accumulates */ /* acc0 += x[3] * y[srcBLen - 4] */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x3 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x3 * c0)) >> 32); /* acc1 += x[4] * y[srcBLen - 4] */ - acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x0 * c0)) >> 32); + acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x0 * c0)) >> 32); /* acc2 += x[5] * y[srcBLen - 4] */ - acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x1 * c0)) >> 32); + acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x1 * c0)) >> 32); /* acc3 += x[6] * y[srcBLen - 4] */ - acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x2 * c0)) >> 32); + acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x2 * c0)) >> 32); } while (--k); - /* If the srcBLen is not a multiple of 4, compute any remaining MACs here. + /* If the srcBLen is not a multiple of 4, compute any remaining MACs + *here. ** No loop unrolling is used. */ k = srcBLen % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* Read y[srcBLen - 5] sample */ c0 = *py--; /* Read x[7] sample */ @@ -366,13 +358,13 @@ arm_status arm_conv_partial_fast_q31( /* Perform the multiply-accumulates */ /* acc0 += x[4] * y[srcBLen - 5] */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x0 * c0)) >> 32); /* acc1 += x[5] * y[srcBLen - 5] */ - acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32); + acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x1 * c0)) >> 32); /* acc2 += x[6] * y[srcBLen - 5] */ - acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x2 * c0)) >> 32); + acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x2 * c0)) >> 32); /* acc3 += x[7] * y[srcBLen - 5] */ - acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x3 * c0)) >> 32); + acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x3 * c0)) >> 32); /* Reuse the present samples for the next MAC */ x0 = x1; @@ -384,10 +376,10 @@ arm_status arm_conv_partial_fast_q31( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q31_t) (acc0 << 1); - *pOut++ = (q31_t) (acc1 << 1); - *pOut++ = (q31_t) (acc2 << 1); - *pOut++ = (q31_t) (acc3 << 1); + *pOut++ = (q31_t)(acc0 << 1); + *pOut++ = (q31_t)(acc1 << 1); + *pOut++ = (q31_t)(acc2 << 1); + *pOut++ = (q31_t)(acc3 << 1); /* Increment the pointer pIn1 index, count by 4 */ count += 4U; @@ -401,7 +393,7 @@ arm_status arm_conv_partial_fast_q31( } /* Loop unrolling: Compute remaining outputs */ - blkCnt = (uint32_t) blockSize2 % 0x4U; + blkCnt = (uint32_t)blockSize2 % 0x4U; #else @@ -410,27 +402,21 @@ arm_status arm_conv_partial_fast_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = srcBLen >> 2U; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) * px++ * (*py--))) >> 32); - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) * px++ * (*py--))) >> 32); - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) * px++ * (*py--))) >> 32); - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) * px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* Decrement loop counter */ k--; @@ -446,11 +432,9 @@ arm_status arm_conv_partial_fast_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* Decrement loop counter */ k--; @@ -469,26 +453,21 @@ arm_status arm_conv_partial_fast_q31( /* Decrement loop counter */ blkCnt--; } - } - else - { + } else { /* If the srcBLen is not a multiple of 4, * the blockSize2 loop cannot be unrolled by 4 */ - blkCnt = (uint32_t) blockSize2; + blkCnt = (uint32_t)blockSize2; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* srcBLen number of MACS should be performed */ k = srcBLen; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* Decrement loop counter */ k--; @@ -509,13 +488,14 @@ arm_status arm_conv_partial_fast_q31( } } - /* -------------------------- * Initializations of stage3 * -------------------------*/ - /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * y[srcBLen-2] +...+ x[srcALen-1] * y[1] - * sum += x[srcALen-srcBLen+2] * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * y[2] + /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * + * y[srcBLen-2] +...+ x[srcALen-1] * y[1] sum += x[srcALen-srcBLen+2] * + * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * + * y[2] * .... * sum += x[srcALen-2] * y[srcBLen-1] + x[srcALen-1] * y[srcBLen-2] * sum += x[srcALen-1] * y[srcBLen-1] @@ -537,33 +517,27 @@ arm_status arm_conv_partial_fast_q31( * Stage3 process * ------------------*/ - while (blockSize3 > 0U) - { + while (blockSize3 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = count >> 2U; - while (k > 0U) - { + while (k > 0U) { /* sum += x[srcALen - srcBLen + 1] * y[srcBLen - 1] */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* sum += x[srcALen - srcBLen + 2] * y[srcBLen - 2] */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* sum += x[srcALen - srcBLen + 3] * y[srcBLen - 3] */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* sum += x[srcALen - srcBLen + 4] * y[srcBLen - 4] */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* Decrement loop counter */ k--; @@ -579,12 +553,10 @@ arm_status arm_conv_partial_fast_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ /* sum += x[srcALen-1] * y[srcBLen-1] */ - sum = (q31_t) ((((q63_t) sum << 32) + - ((q63_t) *px++ * (*py--))) >> 32); + sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py--))) >> 32); /* Decrement loop counter */ k--; @@ -610,7 +582,6 @@ arm_status arm_conv_partial_fast_q31( /* Return to application */ return (status); - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_opt_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_opt_q15.c index 21999d2..032cf48 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_opt_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_opt_q15.c @@ -43,72 +43,65 @@ @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence - @param[out] pDst points to the location where the output result is written + @param[out] pDst points to the location where the output result is + written @param[in] firstIndex is the first output sample to start with @param[in] numPoints is the number of output points to be computed - @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. - @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen). + @param[in] pScratch1 points to scratch buffer of size max(srcALen, + srcBLen) + 2*min(srcALen, srcBLen) - 2. + @param[in] pScratch2 points to scratch buffer of size min(srcALen, + srcBLen). @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : requested subset is not in the range [0 srcALen+srcBLen-2] + - \ref ARM_MATH_ARGUMENT_ERROR : requested subset is not in + the range [0 srcALen+srcBLen-2] @remark - Refer to \ref arm_conv_partial_fast_q15() for a faster but less precise version of this function. + Refer to \ref arm_conv_partial_fast_q15() for a faster but + less precise version of this function. */ -arm_status arm_conv_partial_opt_q15( - const q15_t * pSrcA, - uint32_t srcALen, - const q15_t * pSrcB, - uint32_t srcBLen, - q15_t * pDst, - uint32_t firstIndex, - uint32_t numPoints, - q15_t * pScratch1, - q15_t * pScratch2) -{ +arm_status arm_conv_partial_opt_q15(const q15_t *pSrcA, uint32_t srcALen, + const q15_t *pSrcB, uint32_t srcBLen, + q15_t *pDst, uint32_t firstIndex, + uint32_t numPoints, q15_t *pScratch1, + q15_t *pScratch2) { - q15_t *pOut = pDst; /* Output pointer */ - q15_t *pScr1 = pScratch1; /* Temporary pointer for scratch1 */ - q15_t *pScr2 = pScratch2; /* Temporary pointer for scratch1 */ - q63_t acc0; /* Accumulator */ - q31_t x1; /* Temporary variables to hold state and coefficient values */ - q31_t y1; /* State variables */ - const q15_t *pIn1; /* InputA pointer */ - const q15_t *pIn2; /* InputB pointer */ - const q15_t *px; /* Intermediate inputA pointer */ - q15_t *py; /* Intermediate inputB pointer */ - uint32_t j, k, blkCnt; /* Loop counter */ - uint32_t tapCnt; /* Loop count */ - arm_status status; /* Status variable */ + q15_t *pOut = pDst; /* Output pointer */ + q15_t *pScr1 = pScratch1; /* Temporary pointer for scratch1 */ + q15_t *pScr2 = pScratch2; /* Temporary pointer for scratch1 */ + q63_t acc0; /* Accumulator */ + q31_t x1; /* Temporary variables to hold state and coefficient values */ + q31_t y1; /* State variables */ + const q15_t *pIn1; /* InputA pointer */ + const q15_t *pIn2; /* InputB pointer */ + const q15_t *px; /* Intermediate inputA pointer */ + q15_t *py; /* Intermediate inputB pointer */ + uint32_t j, k, blkCnt; /* Loop counter */ + uint32_t tapCnt; /* Loop count */ + arm_status status; /* Status variable */ -#if defined (ARM_MATH_LOOPUNROLL) - q63_t acc1, acc2, acc3; /* Accumulator */ - q31_t x2, x3; /* Temporary variables to hold state and coefficient values */ - q31_t y2; /* State variables */ +#if defined(ARM_MATH_LOOPUNROLL) + q63_t acc1, acc2, acc3; /* Accumulator */ + q31_t x2, x3; /* Temporary variables to hold state and coefficient values */ + q31_t y2; /* State variables */ #endif /* Check for range of output samples to be calculated */ - if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) - { + if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) { /* Set status as ARM_MATH_ARGUMENT_ERROR */ status = ARM_MATH_ARGUMENT_ERROR; - } - else - { + } else { /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ - if (srcALen >= srcBLen) - { + if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; - } - else - { + } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; @@ -130,14 +123,14 @@ arm_status arm_conv_partial_opt_q15( /* points to smaller length sequence */ px = pIn2; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = srcBLen >> 2U; - /* Copy smaller length input sequence in reverse order into second scratch buffer */ - while (k > 0U) - { + /* Copy smaller length input sequence in reverse order into second scratch + * buffer */ + while (k > 0U) { /* copy second buffer in reversal manner */ *pScr2-- = *px++; *pScr2-- = *px++; @@ -158,8 +151,7 @@ arm_status arm_conv_partial_opt_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* copy second buffer in reversal manner for remaining samples */ *pScr2-- = *px++; @@ -200,13 +192,12 @@ arm_status arm_conv_partial_opt_q15( /* Actual convolution process starts here */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = (numPoints) >> 2; - while (blkCnt > 0) - { + while (blkCnt > 0) { /* Initialze temporary scratch pointer as scratch1 */ pScr1 = pScratch1; @@ -217,19 +208,18 @@ arm_status arm_conv_partial_opt_q15( acc3 = 0; /* Read two samples from scratch1 buffer */ - x1 = read_q15x2_ia (&pScr1); + x1 = read_q15x2_ia(&pScr1); /* Read next two samples from scratch1 buffer */ - x2 = read_q15x2_ia (&pScr1); + x2 = read_q15x2_ia(&pScr1); tapCnt = (srcBLen) >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read four samples from smaller buffer */ - y1 = read_q15x2_ia ((q15_t **) &pIn2); - y2 = read_q15x2_ia ((q15_t **) &pIn2); + y1 = read_q15x2_ia((q15_t **)&pIn2); + y2 = read_q15x2_ia((q15_t **)&pIn2); /* multiply and accumlate */ acc0 = __SMLALD(x1, y1, acc0); @@ -246,7 +236,7 @@ arm_status arm_conv_partial_opt_q15( acc1 = __SMLALDX(x3, y1, acc1); /* Read next two samples from scratch1 buffer */ - x1 = read_q15x2_ia (&pScr1); + x1 = read_q15x2_ia(&pScr1); /* multiply and accumlate */ acc0 = __SMLALD(x2, y2, acc0); @@ -262,7 +252,7 @@ arm_status arm_conv_partial_opt_q15( acc3 = __SMLALDX(x3, y1, acc3); acc1 = __SMLALDX(x3, y2, acc1); - x2 = read_q15x2_ia (&pScr1); + x2 = read_q15x2_ia(&pScr1); #ifndef ARM_MATH_BIG_ENDIAN x3 = __PKHBT(x2, x1, 0); @@ -276,14 +266,14 @@ arm_status arm_conv_partial_opt_q15( tapCnt--; } - /* Update scratch pointer for remaining samples of smaller length sequence */ + /* Update scratch pointer for remaining samples of smaller length sequence + */ pScr1 -= 4U; /* apply same above for remaining samples of smaller length sequence */ - tapCnt = (srcBLen) & 3U; + tapCnt = (srcBLen)&3U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* accumlate the results */ acc0 += (*pScr1++ * *pIn2); acc1 += (*pScr1++ * *pIn2); @@ -299,12 +289,16 @@ arm_status arm_conv_partial_opt_q15( blkCnt--; /* Store the results in the accumulators in the destination buffer. */ -#ifndef ARM_MATH_BIG_ENDIAN - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc0 >> 15), 16), __SSAT((acc1 >> 15), 16), 16)); - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc2 >> 15), 16), __SSAT((acc3 >> 15), 16), 16)); +#ifndef ARM_MATH_BIG_ENDIAN + write_q15x2_ia(&pOut, __PKHBT(__SSAT((acc0 >> 15), 16), + __SSAT((acc1 >> 15), 16), 16)); + write_q15x2_ia(&pOut, __PKHBT(__SSAT((acc2 >> 15), 16), + __SSAT((acc3 >> 15), 16), 16)); #else - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc1 >> 15), 16), __SSAT((acc0 >> 15), 16), 16)); - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc3 >> 15), 16), __SSAT((acc2 >> 15), 16), 16)); + write_q15x2_ia(&pOut, __PKHBT(__SSAT((acc1 >> 15), 16), + __SSAT((acc0 >> 15), 16), 16)); + write_q15x2_ia(&pOut, __PKHBT(__SSAT((acc3 >> 15), 16), + __SSAT((acc2 >> 15), 16), 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Initialization of inputB pointer */ @@ -324,8 +318,7 @@ arm_status arm_conv_partial_opt_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Calculate convolution for remaining samples of Bigger length sequence */ - while (blkCnt > 0) - { + while (blkCnt > 0) { /* Initialze temporary scratch pointer as scratch1 */ pScr1 = pScratch1; @@ -334,13 +327,12 @@ arm_status arm_conv_partial_opt_q15( tapCnt = (srcBLen) >> 1U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read next two samples from scratch1 buffer */ - x1 = read_q15x2_ia (&pScr1); + x1 = read_q15x2_ia(&pScr1); /* Read two samples from smaller buffer */ - y1 = read_q15x2_ia ((q15_t **) &pIn2); + y1 = read_q15x2_ia((q15_t **)&pIn2); acc0 = __SMLALD(x1, y1, acc0); @@ -348,11 +340,10 @@ arm_status arm_conv_partial_opt_q15( tapCnt--; } - tapCnt = (srcBLen) & 1U; + tapCnt = (srcBLen)&1U; /* apply same above for remaining samples of smaller length sequence */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* accumlate the results */ acc0 += (*pScr1++ * *pIn2++); @@ -364,13 +355,12 @@ arm_status arm_conv_partial_opt_q15( /* The result is in 2.30 format. Convert to 1.15 with saturation. ** Then store the output in the destination buffer. */ - *pOut++ = (q15_t) (__SSAT((acc0 >> 15), 16)); + *pOut++ = (q15_t)(__SSAT((acc0 >> 15), 16)); /* Initialization of inputB pointer */ pIn2 = py; pScratch1 += 1U; - } /* Set status as ARM_MATH_SUCCESS */ diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_opt_q7.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_opt_q7.c index 811f386..77b9481 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_opt_q7.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_opt_q7.c @@ -43,60 +43,52 @@ @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence - @param[out] pDst points to the location where the output result is written + @param[out] pDst points to the location where the output result is + written @param[in] firstIndex is the first output sample to start with @param[in] numPoints is the number of output points to be computed - @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. - @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen). + @param[in] pScratch1 points to scratch buffer(of type q15_t) of size + max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. + @param[in] pScratch2 points to scratch buffer (of type q15_t) of size + min(srcALen, srcBLen). @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : requested subset is not in the range [0 srcALen+srcBLen-2] + - \ref ARM_MATH_ARGUMENT_ERROR : requested subset is not in + the range [0 srcALen+srcBLen-2] */ -arm_status arm_conv_partial_opt_q7( - const q7_t * pSrcA, - uint32_t srcALen, - const q7_t * pSrcB, - uint32_t srcBLen, - q7_t * pDst, - uint32_t firstIndex, - uint32_t numPoints, - q15_t * pScratch1, - q15_t * pScratch2) -{ - q15_t *pScr2, *pScr1; /* Intermediate pointers for scratch pointers */ - q15_t x4; /* Temporary input variable */ - const q7_t *pIn1, *pIn2; /* InputA and inputB pointer */ - uint32_t j, k, blkCnt, tapCnt; /* Loop counter */ - const q7_t *px; /* Temporary input1 pointer */ - q15_t *py; /* Temporary input2 pointer */ - q31_t acc0, acc1, acc2, acc3; /* Accumulator */ - q31_t x1, x2, x3, y1; /* Temporary input variables */ - arm_status status; - q7_t *pOut = pDst; /* Output pointer */ - q7_t out0, out1, out2, out3; /* Temporary variables */ +arm_status arm_conv_partial_opt_q7(const q7_t *pSrcA, uint32_t srcALen, + const q7_t *pSrcB, uint32_t srcBLen, + q7_t *pDst, uint32_t firstIndex, + uint32_t numPoints, q15_t *pScratch1, + q15_t *pScratch2) { + q15_t *pScr2, *pScr1; /* Intermediate pointers for scratch pointers */ + q15_t x4; /* Temporary input variable */ + const q7_t *pIn1, *pIn2; /* InputA and inputB pointer */ + uint32_t j, k, blkCnt, tapCnt; /* Loop counter */ + const q7_t *px; /* Temporary input1 pointer */ + q15_t *py; /* Temporary input2 pointer */ + q31_t acc0, acc1, acc2, acc3; /* Accumulator */ + q31_t x1, x2, x3, y1; /* Temporary input variables */ + arm_status status; + q7_t *pOut = pDst; /* Output pointer */ + q7_t out0, out1, out2, out3; /* Temporary variables */ /* Check for range of output samples to be calculated */ - if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) - { + if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) { /* Set status as ARM_MATH_ARGUMENT_ERROR */ status = ARM_MATH_ARGUMENT_ERROR; - } - else - { + } else { /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ - if (srcALen >= srcBLen) - { + if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; - } - else - { + } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; @@ -118,18 +110,18 @@ arm_status arm_conv_partial_opt_q7( /* Apply loop unrolling and do 4 Copies simultaneously. */ k = srcBLen >> 2U; - /* First part of the processing with loop unrolling copies 4 data points at a time. + /* First part of the processing with loop unrolling copies 4 data points at + *a time. ** a second loop below copies for the remaining 1 to 3 samples. */ - while (k > 0U) - { + while (k > 0U) { /* copy second buffer in reversal manner */ - x4 = (q15_t) *px--; + x4 = (q15_t)*px--; *pScr2++ = x4; - x4 = (q15_t) *px--; + x4 = (q15_t)*px--; *pScr2++ = x4; - x4 = (q15_t) *px--; + x4 = (q15_t)*px--; *pScr2++ = x4; - x4 = (q15_t) *px--; + x4 = (q15_t)*px--; *pScr2++ = x4; /* Decrement loop counter */ @@ -140,10 +132,9 @@ arm_status arm_conv_partial_opt_q7( ** No loop unrolling is used. */ k = srcBLen % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* copy second buffer in reversal manner for remaining samples */ - x4 = (q15_t) *px--; + x4 = (q15_t)*px--; *pScr2++ = x4; /* Decrement loop counter */ @@ -163,18 +154,18 @@ arm_status arm_conv_partial_opt_q7( /* Apply loop unrolling and do 4 Copies simultaneously. */ k = srcALen >> 2U; - /* First part of the processing with loop unrolling copies 4 data points at a time. + /* First part of the processing with loop unrolling copies 4 data points at + *a time. ** a second loop below copies for the remaining 1 to 3 samples. */ - while (k > 0U) - { + while (k > 0U) { /* copy second buffer in reversal manner */ - x4 = (q15_t) *pIn1++; + x4 = (q15_t)*pIn1++; *pScr1++ = x4; - x4 = (q15_t) *pIn1++; + x4 = (q15_t)*pIn1++; *pScr1++ = x4; - x4 = (q15_t) *pIn1++; + x4 = (q15_t)*pIn1++; *pScr1++ = x4; - x4 = (q15_t) *pIn1++; + x4 = (q15_t)*pIn1++; *pScr1++ = x4; /* Decrement loop counter */ @@ -185,10 +176,9 @@ arm_status arm_conv_partial_opt_q7( ** No loop unrolling is used. */ k = srcALen % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* copy second buffer in reversal manner for remaining samples */ - x4 = (q15_t) *pIn1++; + x4 = (q15_t)*pIn1++; *pScr1++ = x4; /* Decrement the loop counter */ @@ -201,12 +191,11 @@ arm_status arm_conv_partial_opt_q7( /* Update pointer */ pScr1 += (srcBLen - 1U); - /* Temporary pointer for scratch2 */ py = pScratch2; /* Initialization of pIn2 pointer */ - pIn2 = (q7_t *) py; + pIn2 = (q7_t *)py; pScr2 = py; @@ -217,8 +206,7 @@ arm_status arm_conv_partial_opt_q7( /* Actual convolution process starts here */ blkCnt = (numPoints) >> 2; - while (blkCnt > 0) - { + while (blkCnt > 0) { /* Initialize temporary scratch pointer as scratch1 */ pScr1 = pScratch1; @@ -229,17 +217,16 @@ arm_status arm_conv_partial_opt_q7( acc3 = 0; /* Read two samples from scratch1 buffer */ - x1 = read_q15x2_ia (&pScr1); + x1 = read_q15x2_ia(&pScr1); /* Read next two samples from scratch1 buffer */ - x2 = read_q15x2_ia (&pScr1); + x2 = read_q15x2_ia(&pScr1); tapCnt = (srcBLen) >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read four samples from smaller buffer */ - y1 = read_q15x2_ia (&pScr2); + y1 = read_q15x2_ia(&pScr2); /* multiply and accumlate */ acc0 = __SMLAD(x1, y1, acc0); @@ -256,7 +243,7 @@ arm_status arm_conv_partial_opt_q7( acc1 = __SMLADX(x3, y1, acc1); /* Read next two samples from scratch1 buffer */ - x1 = read_q15x2_ia (&pScr1); + x1 = read_q15x2_ia(&pScr1); /* pack input data */ #ifndef ARM_MATH_BIG_ENDIAN @@ -268,7 +255,7 @@ arm_status arm_conv_partial_opt_q7( acc3 = __SMLADX(x3, y1, acc3); /* Read four samples from smaller buffer */ - y1 = read_q15x2_ia (&pScr2); + y1 = read_q15x2_ia(&pScr2); acc0 = __SMLAD(x2, y1, acc0); @@ -276,7 +263,7 @@ arm_status arm_conv_partial_opt_q7( acc1 = __SMLADX(x3, y1, acc1); - x2 = read_q15x2_ia (&pScr1); + x2 = read_q15x2_ia(&pScr1); #ifndef ARM_MATH_BIG_ENDIAN x3 = __PKHBT(x2, x1, 0); @@ -290,14 +277,14 @@ arm_status arm_conv_partial_opt_q7( tapCnt--; } - /* Update scratch pointer for remaining samples of smaller length sequence */ + /* Update scratch pointer for remaining samples of smaller length sequence + */ pScr1 -= 4U; /* apply same above for remaining samples of smaller length sequence */ - tapCnt = (srcBLen) & 3U; + tapCnt = (srcBLen)&3U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* accumlate the results */ acc0 += (*pScr1++ * *pScr2); acc1 += (*pScr1++ * *pScr2); @@ -313,12 +300,12 @@ arm_status arm_conv_partial_opt_q7( blkCnt--; /* Store the result in the accumulator in the destination buffer. */ - out0 = (q7_t) (__SSAT(acc0 >> 7U, 8)); - out1 = (q7_t) (__SSAT(acc1 >> 7U, 8)); - out2 = (q7_t) (__SSAT(acc2 >> 7U, 8)); - out3 = (q7_t) (__SSAT(acc3 >> 7U, 8)); + out0 = (q7_t)(__SSAT(acc0 >> 7U, 8)); + out1 = (q7_t)(__SSAT(acc1 >> 7U, 8)); + out2 = (q7_t)(__SSAT(acc2 >> 7U, 8)); + out3 = (q7_t)(__SSAT(acc3 >> 7U, 8)); - write_q7x4_ia (&pOut, __PACKq7(out0, out1, out2, out3)); + write_q7x4_ia(&pOut, __PACKq7(out0, out1, out2, out3)); /* Initialization of inputB pointer */ pScr2 = py; @@ -326,11 +313,10 @@ arm_status arm_conv_partial_opt_q7( pScratch1 += 4U; } - blkCnt = (numPoints) & 0x3; + blkCnt = (numPoints)&0x3; /* Calculate convolution for remaining samples of Bigger length sequence */ - while (blkCnt > 0) - { + while (blkCnt > 0) { /* Initialze temporary scratch pointer as scratch1 */ pScr1 = pScratch1; @@ -339,14 +325,13 @@ arm_status arm_conv_partial_opt_q7( tapCnt = (srcBLen) >> 1U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read next two samples from scratch1 buffer */ - x1 = read_q15x2_ia (&pScr1); + x1 = read_q15x2_ia(&pScr1); /* Read two samples from smaller buffer */ - y1 = read_q15x2_ia (&pScr2); + y1 = read_q15x2_ia(&pScr2); acc0 = __SMLAD(x1, y1, acc0); @@ -354,11 +339,10 @@ arm_status arm_conv_partial_opt_q7( tapCnt--; } - tapCnt = (srcBLen) & 1U; + tapCnt = (srcBLen)&1U; /* apply same above for remaining samples of smaller length sequence */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* accumlate the results */ acc0 += (*pScr1++ * *pScr2++); @@ -370,7 +354,7 @@ arm_status arm_conv_partial_opt_q7( blkCnt--; /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q7_t) (__SSAT(acc0 >> 7U, 8)); + *pOut++ = (q7_t)(__SSAT(acc0 >> 7U, 8)); /* Initialization of inputB pointer */ pScr2 = py; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_q15.c index 55272ea..3d4690c 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_q15.c @@ -43,64 +43,58 @@ @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence - @param[out] pDst points to the location where the output result is written + @param[out] pDst points to the location where the output result is + written @param[in] firstIndex is the first output sample to start with @param[in] numPoints is the number of output points to be computed @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : requested subset is not in the range [0 srcALen+srcBLen-2] + - \ref ARM_MATH_ARGUMENT_ERROR : requested subset is not in + the range [0 srcALen+srcBLen-2] @remark - Refer to \ref arm_conv_partial_fast_q15() for a faster but less precise version of this function. + Refer to \ref arm_conv_partial_fast_q15() for a faster but + less precise version of this function. @remark - Refer to \ref arm_conv_partial_opt_q15() for a faster implementation of this function using scratch buffers. + Refer to \ref arm_conv_partial_opt_q15() for a faster + implementation of this function using scratch buffers. */ -arm_status arm_conv_partial_q15( - const q15_t * pSrcA, - uint32_t srcALen, - const q15_t * pSrcB, - uint32_t srcBLen, - q15_t * pDst, - uint32_t firstIndex, - uint32_t numPoints) -{ +arm_status arm_conv_partial_q15(const q15_t *pSrcA, uint32_t srcALen, + const q15_t *pSrcB, uint32_t srcBLen, + q15_t *pDst, uint32_t firstIndex, + uint32_t numPoints) { -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) - const q15_t *pIn1; /* InputA pointer */ - const q15_t *pIn2; /* InputB pointer */ - q15_t *pOut = pDst; /* Output pointer */ - q63_t sum, acc0, acc1, acc2, acc3; /* Accumulator */ - const q15_t *px; /* Intermediate inputA pointer */ - const q15_t *py; /* Intermediate inputB pointer */ - const q15_t *pSrc1, *pSrc2; /* Intermediate pointers */ - q31_t x0, x1, x2, x3, c0; /* Temporary input variables to hold state and coefficient values */ - int32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ - uint32_t j, k, count, blkCnt, check; - arm_status status; /* Status of Partial convolution */ + const q15_t *pIn1; /* InputA pointer */ + const q15_t *pIn2; /* InputB pointer */ + q15_t *pOut = pDst; /* Output pointer */ + q63_t sum, acc0, acc1, acc2, acc3; /* Accumulator */ + const q15_t *px; /* Intermediate inputA pointer */ + const q15_t *py; /* Intermediate inputB pointer */ + const q15_t *pSrc1, *pSrc2; /* Intermediate pointers */ + q31_t x0, x1, x2, x3, + c0; /* Temporary input variables to hold state and coefficient values */ + int32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ + uint32_t j, k, count, blkCnt, check; + arm_status status; /* Status of Partial convolution */ /* Check for range of output samples to be calculated */ - if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) - { + if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) { /* Set status as ARM_MATH_ARGUMENT_ERROR */ status = ARM_MATH_ARGUMENT_ERROR; - } - else - { + } else { /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ - if (srcALen >= srcBLen) - { + if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; - } - else - { + } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; @@ -116,21 +110,30 @@ arm_status arm_conv_partial_q15( /* Conditions to check which loopCounter holds * the first and last indices of the output samples to be calculated. */ check = firstIndex + numPoints; - blockSize3 = ((int32_t)check > (int32_t)srcALen) ? (int32_t)check - (int32_t)srcALen : 0; - blockSize3 = ((int32_t)firstIndex > (int32_t)srcALen - 1) ? blockSize3 - (int32_t)firstIndex + (int32_t)srcALen : blockSize3; - blockSize1 = ((int32_t) srcBLen - 1) - (int32_t) firstIndex; - blockSize1 = (blockSize1 > 0) ? ((check > (srcBLen - 1U)) ? blockSize1 : (int32_t) numPoints) : 0; - blockSize2 = (int32_t) check - ((blockSize3 + blockSize1) + (int32_t) firstIndex); + blockSize3 = ((int32_t)check > (int32_t)srcALen) + ? (int32_t)check - (int32_t)srcALen + : 0; + blockSize3 = ((int32_t)firstIndex > (int32_t)srcALen - 1) + ? blockSize3 - (int32_t)firstIndex + (int32_t)srcALen + : blockSize3; + blockSize1 = ((int32_t)srcBLen - 1) - (int32_t)firstIndex; + blockSize1 = + (blockSize1 > 0) + ? ((check > (srcBLen - 1U)) ? blockSize1 : (int32_t)numPoints) + : 0; + blockSize2 = + (int32_t)check - ((blockSize3 + blockSize1) + (int32_t)firstIndex); blockSize2 = (blockSize2 > 0) ? blockSize2 : 0; - /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ x[n-N+1] * y[N -1] */ + /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ + * x[n-N+1] * y[N -1] */ /* The function is internally - * divided into three stages according to the number of multiplications that has to be - * taken place between inputA samples and inputB samples. In the first stage of the - * algorithm, the multiplications increase by one for every iteration. - * In the second stage of the algorithm, srcBLen number of multiplications are done. - * In the third stage of the algorithm, the multiplications decrease by one - * for every iteration. */ + * divided into three stages according to the number of multiplications that + * has to be taken place between inputA samples and inputB samples. In the + * first stage of the algorithm, the multiplications increase by one for + * every iteration. In the second stage of the algorithm, srcBLen number of + * multiplications are done. In the third stage of the algorithm, the + * multiplications decrease by one for every iteration. */ /* Set the output pointer to point to the firstIndex * of the output sample to be calculated. */ @@ -143,7 +146,8 @@ arm_status arm_conv_partial_q15( /* sum = x[0] * y[0] * sum = x[0] * y[1] + x[1] * y[0] * .... - * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * y[0] + * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] + * * y[0] */ /* In this stage the MAC operations are increased by 1 for every iteration. @@ -165,11 +169,11 @@ arm_status arm_conv_partial_q15( /* For loop unrolling by 4, this stage is divided into two. */ /* First part of this stage computes the MAC operations less than 4 */ - /* Second part of this stage computes the MAC operations greater than or equal to 4 */ + /* Second part of this stage computes the MAC operations greater than or + * equal to 4 */ /* The first part of the stage starts here */ - while ((count < 4U) && (blockSize1 > 0U)) - { + while ((count < 4U) && (blockSize1 > 0U)) { /* Accumulator is made zero for every iteration */ sum = 0; @@ -177,8 +181,7 @@ arm_status arm_conv_partial_q15( * inputA samples and inputB samples */ k = count; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ sum = __SMLALD(*px++, *py--, sum); @@ -187,7 +190,7 @@ arm_status arm_conv_partial_q15( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (__SSAT((sum >> 15), 16)); + *pOut++ = (q15_t)(__SSAT((sum >> 15), 16)); /* Update the inputA and inputB pointers for next MAC calculation */ py = ++pSrc2; @@ -206,23 +209,26 @@ arm_status arm_conv_partial_q15( * y[srcBLen] and y[srcBLen-1] coefficients, py is decremented by 1 */ py = py - 1; - while (blockSize1 > 0U) - { + while (blockSize1 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = count >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. - a second loop below computes MACs for the remaining 1 to 3 samples. */ - while (k > 0U) - { + /* First part of the processing with loop unrolling. Compute 4 MACs at a + time. a second loop below computes MACs for the remaining 1 to 3 + samples. */ + while (k > 0U) { /* Perform the multiply-accumulate */ - /* x[0], x[1] are multiplied with y[srcBLen - 1], y[srcBLen - 2] respectively */ - sum = __SMLALDX(read_q15x2_ia ((q15_t **) &px), read_q15x2_da ((q15_t **) &py), sum); - /* x[2], x[3] are multiplied with y[srcBLen - 3], y[srcBLen - 4] respectively */ - sum = __SMLALDX(read_q15x2_ia ((q15_t **) &px), read_q15x2_da ((q15_t **) &py), sum); + /* x[0], x[1] are multiplied with y[srcBLen - 1], y[srcBLen - 2] + * respectively */ + sum = __SMLALDX(read_q15x2_ia((q15_t **)&px), + read_q15x2_da((q15_t **)&py), sum); + /* x[2], x[3] are multiplied with y[srcBLen - 3], y[srcBLen - 4] + * respectively */ + sum = __SMLALDX(read_q15x2_ia((q15_t **)&px), + read_q15x2_da((q15_t **)&py), sum); /* Decrement loop counter */ k--; @@ -236,8 +242,7 @@ arm_status arm_conv_partial_q15( No loop unrolling is used. */ k = count % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ sum = __SMLALD(*px++, *py--, sum); @@ -246,7 +251,7 @@ arm_status arm_conv_partial_q15( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (__SSAT((sum >> 15), 16)); + *pOut++ = (q15_t)(__SSAT((sum >> 15), 16)); /* Update the inputA and inputB pointers for next MAC calculation */ py = ++pSrc2 - 1U; @@ -266,16 +271,14 @@ arm_status arm_conv_partial_q15( /* sum = x[0] * y[srcBLen-1] + x[1] * y[srcBLen-2] +...+ x[srcBLen-1] * y[0] * sum = x[1] * y[srcBLen-1] + x[2] * y[srcBLen-2] +...+ x[srcBLen] * y[0] * .... - * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ x[srcALen-1] * y[0] + * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] + * +...+ x[srcALen-1] * y[0] */ /* Working pointer of inputA */ - if ((int32_t)firstIndex - (int32_t)srcBLen + 1 > 0) - { + if ((int32_t)firstIndex - (int32_t)srcBLen + 1 > 0) { pSrc1 = pIn1 + firstIndex - srcBLen + 1; - } - else - { + } else { pSrc1 = pIn1; } px = pSrc1; @@ -291,16 +294,14 @@ arm_status arm_conv_partial_q15( * Stage2 process * ------------------*/ - /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed. - * So, to loop unroll over blockSize2, + /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are + * performed. So, to loop unroll over blockSize2, * srcBLen should be greater than or equal to 4 */ - if (srcBLen >= 4U) - { + if (srcBLen >= 4U) { /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = ((uint32_t) blockSize2 >> 2U); + blkCnt = ((uint32_t)blockSize2 >> 2U); - while (blkCnt > 0U) - { + while (blkCnt > 0U) { py = py - 1U; /* Set all accumulators to zero */ @@ -309,24 +310,23 @@ arm_status arm_conv_partial_q15( acc2 = 0; acc3 = 0; - /* read x[0], x[1] samples */ - x0 = read_q15x2 ((q15_t *) px); + x0 = read_q15x2((q15_t *)px); /* read x[1], x[2] samples */ - x1 = read_q15x2 ((q15_t *) px + 1); + x1 = read_q15x2((q15_t *)px + 1); px += 2U; - /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = srcBLen >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. - ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - do - { + /* First part of the processing with loop unrolling. Compute 4 MACs at + *a time. + ** a second loop below computes MACs for the remaining 1 to 3 samples. + */ + do { /* Read the last two inputB samples using SIMD: * y[srcBLen - 1] and y[srcBLen - 2] */ - c0 = read_q15x2_da ((q15_t **) &py); + c0 = read_q15x2_da((q15_t **)&py); /* acc0 += x[0] * y[srcBLen - 1] + x[1] * y[srcBLen - 2] */ acc0 = __SMLALDX(x0, c0, acc0); @@ -335,10 +335,10 @@ arm_status arm_conv_partial_q15( acc1 = __SMLALDX(x1, c0, acc1); /* Read x[2], x[3] */ - x2 = read_q15x2 ((q15_t *) px); + x2 = read_q15x2((q15_t *)px); /* Read x[3], x[4] */ - x3 = read_q15x2 ((q15_t *) px + 1); + x3 = read_q15x2((q15_t *)px + 1); /* acc2 += x[2] * y[srcBLen - 1] + x[3] * y[srcBLen - 2] */ acc2 = __SMLALDX(x2, c0, acc2); @@ -347,7 +347,7 @@ arm_status arm_conv_partial_q15( acc3 = __SMLALDX(x3, c0, acc3); /* Read y[srcBLen - 3] and y[srcBLen - 4] */ - c0 = read_q15x2_da ((q15_t **) &py); + c0 = read_q15x2_da((q15_t **)&py); /* acc0 += x[2] * y[srcBLen - 3] + x[3] * y[srcBLen - 4] */ acc0 = __SMLALDX(x2, c0, acc0); @@ -356,10 +356,10 @@ arm_status arm_conv_partial_q15( acc1 = __SMLALDX(x3, c0, acc1); /* Read x[4], x[5] */ - x0 = read_q15x2 ((q15_t *) px + 2); + x0 = read_q15x2((q15_t *)px + 2); /* Read x[5], x[6] */ - x1 = read_q15x2 ((q15_t *) px + 3); + x1 = read_q15x2((q15_t *)px + 3); px += 4U; /* acc2 += x[4] * y[srcBLen - 3] + x[5] * y[srcBLen - 4] */ @@ -373,41 +373,40 @@ arm_status arm_conv_partial_q15( /* For the next MAC operations, SIMD is not used * So, the 16 bit pointer if inputB, py is updated */ - /* If the srcBLen is not a multiple of 4, compute any remaining MACs here. + /* If the srcBLen is not a multiple of 4, compute any remaining MACs + *here. ** No loop unrolling is used. */ k = srcBLen % 0x4U; - if (k == 1U) - { + if (k == 1U) { /* Read y[srcBLen - 5] */ - c0 = *(py+1); -#ifdef ARM_MATH_BIG_ENDIAN + c0 = *(py + 1); +#ifdef ARM_MATH_BIG_ENDIAN c0 = c0 << 16U; #else c0 = c0 & 0x0000FFFF; #endif /* #ifdef ARM_MATH_BIG_ENDIAN */ /* Read x[7] */ - x3 = read_q15x2 ((q15_t *) px); + x3 = read_q15x2((q15_t *)px); px++; /* Perform the multiply-accumulate */ - acc0 = __SMLALD (x0, c0, acc0); - acc1 = __SMLALD (x1, c0, acc1); + acc0 = __SMLALD(x0, c0, acc0); + acc1 = __SMLALD(x1, c0, acc1); acc2 = __SMLALDX(x1, c0, acc2); acc3 = __SMLALDX(x3, c0, acc3); } - if (k == 2U) - { + if (k == 2U) { /* Read y[srcBLen - 5], y[srcBLen - 6] */ - c0 = read_q15x2 ((q15_t *) py); + c0 = read_q15x2((q15_t *)py); /* Read x[7], x[8] */ - x3 = read_q15x2 ((q15_t *) px); + x3 = read_q15x2((q15_t *)px); /* Read x[9] */ - x2 = read_q15x2 ((q15_t *) px + 1); + x2 = read_q15x2((q15_t *)px + 1); px += 2U; /* Perform the multiply-accumulate */ @@ -417,16 +416,15 @@ arm_status arm_conv_partial_q15( acc3 = __SMLALDX(x2, c0, acc3); } - if (k == 3U) - { + if (k == 3U) { /* Read y[srcBLen - 5], y[srcBLen - 6] */ - c0 = read_q15x2 ((q15_t *) py); + c0 = read_q15x2((q15_t *)py); /* Read x[7], x[8] */ - x3 = read_q15x2 ((q15_t *) px); + x3 = read_q15x2((q15_t *)px); /* Read x[9] */ - x2 = read_q15x2 ((q15_t *) px + 1); + x2 = read_q15x2((q15_t *)px + 1); /* Perform the multiply-accumulate */ acc0 = __SMLALDX(x0, c0, acc0); @@ -434,31 +432,35 @@ arm_status arm_conv_partial_q15( acc2 = __SMLALDX(x3, c0, acc2); acc3 = __SMLALDX(x2, c0, acc3); - c0 = *(py-1); -#ifdef ARM_MATH_BIG_ENDIAN + c0 = *(py - 1); +#ifdef ARM_MATH_BIG_ENDIAN c0 = c0 << 16U; #else c0 = c0 & 0x0000FFFF; #endif /* #ifdef ARM_MATH_BIG_ENDIAN */ /* Read x[10] */ - x3 = read_q15x2 ((q15_t *) px + 2); + x3 = read_q15x2((q15_t *)px + 2); px += 3U; /* Perform the multiply-accumulates */ acc0 = __SMLALDX(x1, c0, acc0); - acc1 = __SMLALD (x2, c0, acc1); + acc1 = __SMLALD(x2, c0, acc1); acc2 = __SMLALDX(x2, c0, acc2); acc3 = __SMLALDX(x3, c0, acc3); } /* Store the results in the accumulators in the destination buffer. */ #ifndef ARM_MATH_BIG_ENDIAN - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc0 >> 15), 16), __SSAT((acc1 >> 15), 16), 16)); - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc2 >> 15), 16), __SSAT((acc3 >> 15), 16), 16)); + write_q15x2_ia(&pOut, __PKHBT(__SSAT((acc0 >> 15), 16), + __SSAT((acc1 >> 15), 16), 16)); + write_q15x2_ia(&pOut, __PKHBT(__SSAT((acc2 >> 15), 16), + __SSAT((acc3 >> 15), 16), 16)); #else - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc1 >> 15), 16), __SSAT((acc0 >> 15), 16), 16)); - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc3 >> 15), 16), __SSAT((acc2 >> 15), 16), 16)); + write_q15x2_ia(&pOut, __PKHBT(__SSAT((acc1 >> 15), 16), + __SSAT((acc0 >> 15), 16), 16)); + write_q15x2_ia(&pOut, __PKHBT(__SSAT((acc3 >> 15), 16), + __SSAT((acc2 >> 15), 16), 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Increment the pointer pIn1 index, count by 4 */ @@ -472,47 +474,46 @@ arm_status arm_conv_partial_q15( blkCnt--; } - /* If the blockSize2 is not a multiple of 4, compute any remaining output samples here. - No loop unrolling is used. */ - blkCnt = (uint32_t) blockSize2 % 0x4U; + /* If the blockSize2 is not a multiple of 4, compute any remaining output + samples here. No loop unrolling is used. */ + blkCnt = (uint32_t)blockSize2 % 0x4U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = srcBLen >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. - a second loop below computes MACs for the remaining 1 to 3 samples. */ - while (k > 0U) - { + /* First part of the processing with loop unrolling. Compute 4 MACs at + a time. a second loop below computes MACs for the remaining 1 to 3 + samples. */ + while (k > 0U) { /* Perform the multiply-accumulates */ - sum += (q63_t) ((q31_t) *px++ * *py--); - sum += (q63_t) ((q31_t) *px++ * *py--); - sum += (q63_t) ((q31_t) *px++ * *py--); - sum += (q63_t) ((q31_t) *px++ * *py--); + sum += (q63_t)((q31_t)*px++ * *py--); + sum += (q63_t)((q31_t)*px++ * *py--); + sum += (q63_t)((q31_t)*px++ * *py--); + sum += (q63_t)((q31_t)*px++ * *py--); /* Decrement loop counter */ k--; } - /* If the srcBLen is not a multiple of 4, compute any remaining MACs here. + /* If the srcBLen is not a multiple of 4, compute any remaining MACs + *here. ** No loop unrolling is used. */ k = srcBLen % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum += (q63_t) ((q31_t) *px++ * *py--); + sum += (q63_t)((q31_t)*px++ * *py--); /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (__SSAT(sum >> 15, 16)); + *pOut++ = (q15_t)(__SSAT(sum >> 15, 16)); /* Increment the pointer pIn1 index, count by 1 */ count++; @@ -524,32 +525,28 @@ arm_status arm_conv_partial_q15( /* Decrement loop counter */ blkCnt--; } - } - else - { + } else { /* If the srcBLen is not a multiple of 4, * the blockSize2 loop cannot be unrolled by 4 */ - blkCnt = (uint32_t) blockSize2; + blkCnt = (uint32_t)blockSize2; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* srcBLen number of MACS should be performed */ k = srcBLen; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum += (q63_t) ((q31_t) *px++ * *py--); + sum += (q63_t)((q31_t)*px++ * *py--); /* Decrement the loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (__SSAT(sum >> 15, 16)); + *pOut++ = (q15_t)(__SSAT(sum >> 15, 16)); /* Increment the MAC count */ count++; @@ -563,13 +560,14 @@ arm_status arm_conv_partial_q15( } } - /* -------------------------- * Initializations of stage3 * -------------------------*/ - /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * y[srcBLen-2] +...+ x[srcALen-1] * y[1] - * sum += x[srcALen-srcBLen+2] * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * y[2] + /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * + * y[srcBLen-2] +...+ x[srcALen-1] * y[1] sum += x[srcALen-srcBLen+2] * + * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * + * y[2] * .... * sum += x[srcALen-2] * y[srcBLen-1] + x[srcALen-1] * y[srcBLen-2] * sum += x[srcALen-1] * y[srcBLen-1] @@ -594,29 +592,31 @@ arm_status arm_conv_partial_q15( /* For loop unrolling by 4, this stage is divided into two. */ /* First part of this stage computes the MAC operations greater than 4 */ - /* Second part of this stage computes the MAC operations less than or equal to 4 */ + /* Second part of this stage computes the MAC operations less than or equal + * to 4 */ /* The first part of the stage starts here */ j = count >> 2U; - while ((j > 0U) && (blockSize3 > 0U)) - { + while ((j > 0U) && (blockSize3 > 0U)) { /* Accumulator is made zero for every iteration */ sum = 0; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = count >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. + /* First part of the processing with loop unrolling. Compute 4 MACs at a + *time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - while (k > 0U) - { + while (k > 0U) { /* x[srcALen - srcBLen + 1], x[srcALen - srcBLen + 2] are multiplied * with y[srcBLen - 1], y[srcBLen - 2] respectively */ - sum = __SMLALDX(read_q15x2_ia ((q15_t **) &px), read_q15x2_da ((q15_t **) &py), sum); + sum = __SMLALDX(read_q15x2_ia((q15_t **)&px), + read_q15x2_da((q15_t **)&py), sum); /* x[srcALen - srcBLen + 3], x[srcALen - srcBLen + 4] are multiplied * with y[srcBLen - 3], y[srcBLen - 4] respectively */ - sum = __SMLALDX(read_q15x2_ia ((q15_t **) &px), read_q15x2_da ((q15_t **) &py), sum); + sum = __SMLALDX(read_q15x2_ia((q15_t **)&px), + read_q15x2_da((q15_t **)&py), sum); /* Decrement loop counter */ k--; @@ -630,8 +630,7 @@ arm_status arm_conv_partial_q15( ** No loop unrolling is used. */ k = count % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* sum += x[srcALen - srcBLen + 5] * y[srcBLen - 5] */ sum = __SMLALD(*px++, *py--, sum); @@ -640,7 +639,7 @@ arm_status arm_conv_partial_q15( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (__SSAT((sum >> 15), 16)); + *pOut++ = (q15_t)(__SSAT((sum >> 15), 16)); /* Update the inputA and inputB pointers for next MAC calculation */ px = ++pSrc1; @@ -660,16 +659,14 @@ arm_status arm_conv_partial_q15( * so pointer py is updated to read only one sample at a time */ py = py + 1U; - while (blockSize3 > 0U) - { + while (blockSize3 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = count; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ /* sum += x[srcALen-1] * y[srcBLen-1] */ sum = __SMLALD(*px++, *py--, sum); @@ -679,7 +676,7 @@ arm_status arm_conv_partial_q15( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (__SSAT((sum >> 15), 16)); + *pOut++ = (q15_t)(__SSAT((sum >> 15), 16)); /* Update the inputA and inputB pointers for next MAC calculation */ px = ++pSrc1; @@ -701,39 +698,33 @@ arm_status arm_conv_partial_q15( #else /* #if defined (ARM_MATH_DSP) */ - const q15_t *pIn1 = pSrcA; /* InputA pointer */ - const q15_t *pIn2 = pSrcB; /* InputB pointer */ - q63_t sum; /* Accumulator */ - uint32_t i, j; /* Loop counters */ - arm_status status; /* Status of Partial convolution */ + const q15_t *pIn1 = pSrcA; /* InputA pointer */ + const q15_t *pIn2 = pSrcB; /* InputB pointer */ + q63_t sum; /* Accumulator */ + uint32_t i, j; /* Loop counters */ + arm_status status; /* Status of Partial convolution */ /* Check for range of output samples to be calculated */ - if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) - { + if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) { /* Set status as ARM_MATH_ARGUMENT_ERROR */ status = ARM_MATH_ARGUMENT_ERROR; - } - else - { + } else { /* Loop to calculate convolution for output length number of values */ - for (i = firstIndex; i <= (firstIndex + numPoints - 1); i++) - { + for (i = firstIndex; i <= (firstIndex + numPoints - 1); i++) { /* Initialize sum with zero to carry on MAC operations */ sum = 0; /* Loop to perform MAC operations according to convolution equation */ - for (j = 0U; j <= i; j++) - { + for (j = 0U; j <= i; j++) { /* Check the array limitations */ - if (((i - j) < srcBLen) && (j < srcALen)) - { + if (((i - j) < srcBLen) && (j < srcALen)) { /* z[i] += x[i-j] * y[j] */ - sum += ((q31_t) pIn1[j] * pIn2[i - j]); + sum += ((q31_t)pIn1[j] * pIn2[i - j]); } } /* Store the output in the destination buffer */ - pDst[i] = (q15_t) __SSAT((sum >> 15U), 16U); + pDst[i] = (q15_t)__SSAT((sum >> 15U), 16U); } /* Set status as ARM_MATH_SUCCESS */ @@ -744,7 +735,6 @@ arm_status arm_conv_partial_q15( return (status); #endif /* #if defined (ARM_MATH_DSP) */ - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_q31.c index d0f0122..f277285 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_q31.c @@ -43,67 +43,59 @@ @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence - @param[out] pDst points to the location where the output result is written + @param[out] pDst points to the location where the output result is + written @param[in] firstIndex is the first output sample to start with @param[in] numPoints is the number of output points to be computed @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : requested subset is not in the range [0 srcALen+srcBLen-2] + - \ref ARM_MATH_ARGUMENT_ERROR : requested subset is not in + the range [0 srcALen+srcBLen-2] @remark - Refer to \ref arm_conv_partial_fast_q31() for a faster but less precise implementation of this function. + Refer to \ref arm_conv_partial_fast_q31() for a faster but + less precise implementation of this function. */ -arm_status arm_conv_partial_q31( - const q31_t * pSrcA, - uint32_t srcALen, - const q31_t * pSrcB, - uint32_t srcBLen, - q31_t * pDst, - uint32_t firstIndex, - uint32_t numPoints) -{ +arm_status arm_conv_partial_q31(const q31_t *pSrcA, uint32_t srcALen, + const q31_t *pSrcB, uint32_t srcBLen, + q31_t *pDst, uint32_t firstIndex, + uint32_t numPoints) { #if (1) -//#if !defined(ARM_MATH_CM0_FAMILY) + //#if !defined(ARM_MATH_CM0_FAMILY) - const q31_t *pIn1; /* InputA pointer */ - const q31_t *pIn2; /* InputB pointer */ - q31_t *pOut = pDst; /* Output pointer */ - const q31_t *px; /* Intermediate inputA pointer */ - const q31_t *py; /* Intermediate inputB pointer */ - const q31_t *pSrc1, *pSrc2; /* Intermediate pointers */ - q63_t sum; /* Accumulator */ - uint32_t j, k, count, blkCnt, check; - int32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ - arm_status status; /* Status of Partial convolution */ + const q31_t *pIn1; /* InputA pointer */ + const q31_t *pIn2; /* InputB pointer */ + q31_t *pOut = pDst; /* Output pointer */ + const q31_t *px; /* Intermediate inputA pointer */ + const q31_t *py; /* Intermediate inputB pointer */ + const q31_t *pSrc1, *pSrc2; /* Intermediate pointers */ + q63_t sum; /* Accumulator */ + uint32_t j, k, count, blkCnt, check; + int32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ + arm_status status; /* Status of Partial convolution */ -#if defined (ARM_MATH_LOOPUNROLL) - q63_t acc0, acc1, acc2; /* Accumulator */ - q31_t x0, x1, x2, c0; /* Temporary variables */ +#if defined(ARM_MATH_LOOPUNROLL) + q63_t acc0, acc1, acc2; /* Accumulator */ + q31_t x0, x1, x2, c0; /* Temporary variables */ #endif /* Check for range of output samples to be calculated */ - if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) - { + if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) { /* Set status as ARM_MATH_ARGUMENT_ERROR */ status = ARM_MATH_ARGUMENT_ERROR; - } - else - { + } else { /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ - if (srcALen >= srcBLen) - { + if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; - } - else - { + } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; @@ -119,21 +111,30 @@ arm_status arm_conv_partial_q31( /* Conditions to check which loopCounter holds * the first and last indices of the output samples to be calculated. */ check = firstIndex + numPoints; - blockSize3 = ((int32_t)check > (int32_t)srcALen) ? (int32_t)check - (int32_t)srcALen : 0; - blockSize3 = ((int32_t)firstIndex > (int32_t)srcALen - 1) ? blockSize3 - (int32_t)firstIndex + (int32_t)srcALen : blockSize3; - blockSize1 = ((int32_t) srcBLen - 1) - (int32_t) firstIndex; - blockSize1 = (blockSize1 > 0) ? ((check > (srcBLen - 1U)) ? blockSize1 : (int32_t) numPoints) : 0; - blockSize2 = (int32_t) check - ((blockSize3 + blockSize1) + (int32_t) firstIndex); + blockSize3 = ((int32_t)check > (int32_t)srcALen) + ? (int32_t)check - (int32_t)srcALen + : 0; + blockSize3 = ((int32_t)firstIndex > (int32_t)srcALen - 1) + ? blockSize3 - (int32_t)firstIndex + (int32_t)srcALen + : blockSize3; + blockSize1 = ((int32_t)srcBLen - 1) - (int32_t)firstIndex; + blockSize1 = + (blockSize1 > 0) + ? ((check > (srcBLen - 1U)) ? blockSize1 : (int32_t)numPoints) + : 0; + blockSize2 = + (int32_t)check - ((blockSize3 + blockSize1) + (int32_t)firstIndex); blockSize2 = (blockSize2 > 0) ? blockSize2 : 0; - /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ x[n-N+1] * y[N -1] */ + /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ + * x[n-N+1] * y[N -1] */ /* The function is internally - * divided into three stages according to the number of multiplications that has to be - * taken place between inputA samples and inputB samples. In the first stage of the - * algorithm, the multiplications increase by one for every iteration. - * In the second stage of the algorithm, srcBLen number of multiplications are done. - * In the third stage of the algorithm, the multiplications decrease by one - * for every iteration. */ + * divided into three stages according to the number of multiplications that + * has to be taken place between inputA samples and inputB samples. In the + * first stage of the algorithm, the multiplications increase by one for + * every iteration. In the second stage of the algorithm, srcBLen number of + * multiplications are done. In the third stage of the algorithm, the + * multiplications decrease by one for every iteration. */ /* Set the output pointer to point to the firstIndex * of the output sample to be calculated. */ @@ -146,7 +147,8 @@ arm_status arm_conv_partial_q31( /* sum = x[0] * y[0] * sum = x[0] * y[1] + x[1] * y[0] * .... - * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * y[0] + * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] + * * y[0] */ /* In this stage the MAC operations are increased by 1 for every iteration. @@ -167,29 +169,27 @@ arm_status arm_conv_partial_q31( * ----------------------*/ /* The first stage starts here */ - while (blockSize1 > 0U) - { + while (blockSize1 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = count >> 2U; - while (k > 0U) - { + while (k > 0U) { /* x[0] * y[srcBLen - 1] */ - sum += (q63_t) *px++ * (*py--); + sum += (q63_t)*px++ * (*py--); /* x[1] * y[srcBLen - 2] */ - sum += (q63_t) *px++ * (*py--); + sum += (q63_t)*px++ * (*py--); /* x[2] * y[srcBLen - 3] */ - sum += (q63_t) *px++ * (*py--); + sum += (q63_t)*px++ * (*py--); /* x[3] * y[srcBLen - 4] */ - sum += (q63_t) *px++ * (*py--); + sum += (q63_t)*px++ * (*py--); /* Decrement loop counter */ k--; @@ -205,17 +205,16 @@ arm_status arm_conv_partial_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum += (q63_t) *px++ * (*py--); + sum += (q63_t)*px++ * (*py--); /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q31_t) (sum >> 31); + *pOut++ = (q31_t)(sum >> 31); /* Update the inputA and inputB pointers for next MAC calculation */ py = ++pSrc2; @@ -235,16 +234,14 @@ arm_status arm_conv_partial_q31( /* sum = x[0] * y[srcBLen-1] + x[1] * y[srcBLen-2] +...+ x[srcBLen-1] * y[0] * sum = x[1] * y[srcBLen-1] + x[2] * y[srcBLen-2] +...+ x[srcBLen] * y[0] * .... - * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ x[srcALen-1] * y[0] + * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] + * +...+ x[srcALen-1] * y[0] */ /* Working pointer of inputA */ - if ((int32_t)firstIndex - (int32_t)srcBLen + 1 > 0) - { + if ((int32_t)firstIndex - (int32_t)srcBLen + 1 > 0) { pSrc1 = pIn1 + firstIndex - srcBLen + 1; - } - else - { + } else { pSrc1 = pIn1; } px = pSrc1; @@ -260,18 +257,16 @@ arm_status arm_conv_partial_q31( * Stage2 process * ------------------*/ - /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed. - * So, to loop unroll over blockSize2, + /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are + * performed. So, to loop unroll over blockSize2, * srcBLen should be greater than or equal to 4 */ - if (srcBLen >= 4U) - { -#if defined (ARM_MATH_LOOPUNROLL) + if (srcBLen >= 4U) { +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unroll over blkCnt */ blkCnt = blockSize2 / 3; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Set all accumulators to zero */ acc0 = 0; acc1 = 0; @@ -284,10 +279,11 @@ arm_status arm_conv_partial_q31( /* Apply loop unrolling and compute 3 MACs simultaneously. */ k = srcBLen / 3; - /* First part of the processing with loop unrolling. Compute 3 MACs at a time. - ** a second loop below computes MACs for the remaining 1 to 2 samples. */ - do - { + /* First part of the processing with loop unrolling. Compute 3 MACs at + *a time. + ** a second loop below computes MACs for the remaining 1 to 2 samples. + */ + do { /* Read y[srcBLen - 1] sample */ c0 = *(py); @@ -296,11 +292,11 @@ arm_status arm_conv_partial_q31( /* Perform the multiply-accumulate */ /* acc0 += x[0] * y[srcBLen - 1] */ - acc0 += (q63_t) x0 * c0; + acc0 += (q63_t)x0 * c0; /* acc1 += x[1] * y[srcBLen - 1] */ - acc1 += (q63_t) x1 * c0; + acc1 += (q63_t)x1 * c0; /* acc2 += x[2] * y[srcBLen - 1] */ - acc2 += (q63_t) x2 * c0; + acc2 += (q63_t)x2 * c0; /* Read y[srcBLen - 2] sample */ c0 = *(py - 1U); @@ -310,11 +306,11 @@ arm_status arm_conv_partial_q31( /* Perform the multiply-accumulate */ /* acc0 += x[1] * y[srcBLen - 2] */ - acc0 += (q63_t) x1 * c0; + acc0 += (q63_t)x1 * c0; /* acc1 += x[2] * y[srcBLen - 2] */ - acc1 += (q63_t) x2 * c0; + acc1 += (q63_t)x2 * c0; /* acc2 += x[3] * y[srcBLen - 2] */ - acc2 += (q63_t) x0 * c0; + acc2 += (q63_t)x0 * c0; /* Read y[srcBLen - 3] sample */ c0 = *(py - 2U); @@ -324,12 +320,11 @@ arm_status arm_conv_partial_q31( /* Perform the multiply-accumulate */ /* acc0 += x[2] * y[srcBLen - 3] */ - acc0 += (q63_t) x2 * c0; + acc0 += (q63_t)x2 * c0; /* acc1 += x[3] * y[srcBLen - 2] */ - acc1 += (q63_t) x0 * c0; + acc1 += (q63_t)x0 * c0; /* acc2 += x[4] * y[srcBLen - 2] */ - acc2 += (q63_t) x1 * c0; - + acc2 += (q63_t)x1 * c0; px += 3U; @@ -337,12 +332,12 @@ arm_status arm_conv_partial_q31( } while (--k); - /* If the srcBLen is not a multiple of 3, compute any remaining MACs here. + /* If the srcBLen is not a multiple of 3, compute any remaining MACs + *here. ** No loop unrolling is used. */ k = srcBLen - (3 * (srcBLen / 3)); - while (k > 0U) - { + while (k > 0U) { /* Read y[srcBLen - 5] sample */ c0 = *py--; /* Read x[7] sample */ @@ -350,11 +345,11 @@ arm_status arm_conv_partial_q31( /* Perform the multiply-accumulates */ /* acc0 += x[4] * y[srcBLen - 5] */ - acc0 += (q63_t) x0 * c0; + acc0 += (q63_t)x0 * c0; /* acc1 += x[5] * y[srcBLen - 5] */ - acc1 += (q63_t) x1 * c0; + acc1 += (q63_t)x1 * c0; /* acc2 += x[6] * y[srcBLen - 5] */ - acc2 += (q63_t) x2 * c0; + acc2 += (q63_t)x2 * c0; /* Reuse the present samples for the next MAC */ x0 = x1; @@ -365,9 +360,9 @@ arm_status arm_conv_partial_q31( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q31_t) (acc0 >> 31); - *pOut++ = (q31_t) (acc1 >> 31); - *pOut++ = (q31_t) (acc2 >> 31); + *pOut++ = (q31_t)(acc0 >> 31); + *pOut++ = (q31_t)(acc1 >> 31); + *pOut++ = (q31_t)(acc2 >> 31); /* Increment the pointer pIn1 index, count by 3 */ count += 3U; @@ -390,23 +385,21 @@ arm_status arm_conv_partial_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = srcBLen >> 2U; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ - sum += (q63_t) *px++ * (*py--); - sum += (q63_t) *px++ * (*py--); - sum += (q63_t) *px++ * (*py--); - sum += (q63_t) *px++ * (*py--); + sum += (q63_t)*px++ * (*py--); + sum += (q63_t)*px++ * (*py--); + sum += (q63_t)*px++ * (*py--); + sum += (q63_t)*px++ * (*py--); /* Decrement loop counter */ k--; @@ -422,17 +415,16 @@ arm_status arm_conv_partial_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum += (q63_t) *px++ * *py--; + sum += (q63_t)*px++ * *py--; /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q31_t) (sum >> 31); + *pOut++ = (q31_t)(sum >> 31); /* Increment MAC count */ count++; @@ -444,32 +436,28 @@ arm_status arm_conv_partial_q31( /* Decrement loop counter */ blkCnt--; } - } - else - { + } else { /* If the srcBLen is not a multiple of 4, * the blockSize2 loop cannot be unrolled by 4 */ - blkCnt = (uint32_t) blockSize2; + blkCnt = (uint32_t)blockSize2; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* srcBLen number of MACS should be performed */ k = srcBLen; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum += (q63_t) *px++ * *py--; + sum += (q63_t)*px++ * *py--; /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q31_t) (sum >> 31); + *pOut++ = (q31_t)(sum >> 31); /* Increment the MAC count */ count++; @@ -483,13 +471,14 @@ arm_status arm_conv_partial_q31( } } - /* -------------------------- * Initializations of stage3 * -------------------------*/ - /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * y[srcBLen-2] +...+ x[srcALen-1] * y[1] - * sum += x[srcALen-srcBLen+2] * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * y[2] + /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * + * y[srcBLen-2] +...+ x[srcALen-1] * y[1] sum += x[srcALen-srcBLen+2] * + * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * + * y[2] * .... * sum += x[srcALen-2] * y[srcBLen-1] + x[srcALen-1] * y[srcBLen-2] * sum += x[srcALen-1] * y[srcBLen-1] @@ -511,29 +500,27 @@ arm_status arm_conv_partial_q31( * Stage3 process * ------------------*/ - while (blockSize3 > 0U) - { + while (blockSize3 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = count >> 2U; - while (k > 0U) - { + while (k > 0U) { /* sum += x[srcALen - srcBLen + 1] * y[srcBLen - 1] */ - sum += (q63_t) *px++ * *py--; + sum += (q63_t)*px++ * *py--; /* sum += x[srcALen - srcBLen + 2] * y[srcBLen - 2] */ - sum += (q63_t) *px++ * *py--; + sum += (q63_t)*px++ * *py--; /* sum += x[srcALen - srcBLen + 3] * y[srcBLen - 3] */ - sum += (q63_t) *px++ * *py--; + sum += (q63_t)*px++ * *py--; /* sum += x[srcALen - srcBLen + 4] * y[srcBLen - 4] */ - sum += (q63_t) *px++ * *py--; + sum += (q63_t)*px++ * *py--; /* Decrement loop counter */ k--; @@ -549,18 +536,17 @@ arm_status arm_conv_partial_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ /* sum += x[srcALen-1] * y[srcBLen-1] */ - sum += (q63_t) *px++ * *py--; + sum += (q63_t)*px++ * *py--; /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q31_t) (sum >> 31); + *pOut++ = (q31_t)(sum >> 31); /* Update the inputA and inputB pointers for next MAC calculation */ px = ++pSrc1; @@ -581,41 +567,35 @@ arm_status arm_conv_partial_q31( return (status); #else -/* alternate version for CM0_FAMILY */ + /* alternate version for CM0_FAMILY */ - const q31_t *pIn1 = pSrcA; /* InputA pointer */ - const q31_t *pIn2 = pSrcB; /* InputB pointer */ - q63_t sum; /* Accumulator */ - uint32_t i, j; /* Loop counters */ - arm_status status; /* Status of Partial convolution */ + const q31_t *pIn1 = pSrcA; /* InputA pointer */ + const q31_t *pIn2 = pSrcB; /* InputB pointer */ + q63_t sum; /* Accumulator */ + uint32_t i, j; /* Loop counters */ + arm_status status; /* Status of Partial convolution */ /* Check for range of output samples to be calculated */ - if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) - { + if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) { /* Set status as ARM_MATH_ARGUMENT_ERROR */ status = ARM_MATH_ARGUMENT_ERROR; - } - else - { + } else { /* Loop to calculate convolution for output length number of values */ - for (i = firstIndex; i <= (firstIndex + numPoints - 1); i++) - { + for (i = firstIndex; i <= (firstIndex + numPoints - 1); i++) { /* Initialize sum with zero to carry on MAC operations */ sum = 0; /* Loop to perform MAC operations according to convolution equation */ - for (j = 0U; j <= i; j++) - { + for (j = 0U; j <= i; j++) { /* Check the array limitations */ - if (((i - j) < srcBLen) && (j < srcALen)) - { + if (((i - j) < srcBLen) && (j < srcALen)) { /* z[i] += x[i-j] * y[j] */ - sum += ((q63_t) pIn1[j] * pIn2[i - j]); + sum += ((q63_t)pIn1[j] * pIn2[i - j]); } } /* Store the output in the destination buffer */ - pDst[i] = (q31_t) (sum >> 31U); + pDst[i] = (q31_t)(sum >> 31U); } /* Set status as ARM_MATH_SUCCESS */ @@ -626,7 +606,6 @@ arm_status arm_conv_partial_q31( return (status); #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */ - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_q7.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_q7.c index 9b0228c..45415bc 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_q7.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_partial_q7.c @@ -43,69 +43,61 @@ @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence - @param[out] pDst points to the location where the output result is written + @param[out] pDst points to the location where the output result is + written @param[in] firstIndex is the first output sample to start with @param[in] numPoints is the number of output points to be computed @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : requested subset is not in the range [0 srcALen+srcBLen-2] + - \ref ARM_MATH_ARGUMENT_ERROR : requested subset is not in + the range [0 srcALen+srcBLen-2] @remark - Refer to \ref arm_conv_partial_opt_q7() for a faster implementation of this function. + Refer to \ref arm_conv_partial_opt_q7() for a faster + implementation of this function. */ -arm_status arm_conv_partial_q7( - const q7_t * pSrcA, - uint32_t srcALen, - const q7_t * pSrcB, - uint32_t srcBLen, - q7_t * pDst, - uint32_t firstIndex, - uint32_t numPoints) -{ +arm_status arm_conv_partial_q7(const q7_t *pSrcA, uint32_t srcALen, + const q7_t *pSrcB, uint32_t srcBLen, q7_t *pDst, + uint32_t firstIndex, uint32_t numPoints) { #if (1) -//#if !defined(ARM_MATH_CM0_FAMILY) + //#if !defined(ARM_MATH_CM0_FAMILY) - const q7_t *pIn1; /* InputA pointer */ - const q7_t *pIn2; /* InputB pointer */ - q7_t *pOut = pDst; /* Output pointer */ - const q7_t *px; /* Intermediate inputA pointer */ - const q7_t *py; /* Intermediate inputB pointer */ - const q7_t *pSrc1, *pSrc2; /* Intermediate pointers */ - q31_t sum; /* Accumulator */ - uint32_t j, k, count, blkCnt, check; /* Loop counters */ - int32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ - arm_status status; /* Status of Partial convolution */ + const q7_t *pIn1; /* InputA pointer */ + const q7_t *pIn2; /* InputB pointer */ + q7_t *pOut = pDst; /* Output pointer */ + const q7_t *px; /* Intermediate inputA pointer */ + const q7_t *py; /* Intermediate inputB pointer */ + const q7_t *pSrc1, *pSrc2; /* Intermediate pointers */ + q31_t sum; /* Accumulator */ + uint32_t j, k, count, blkCnt, check; /* Loop counters */ + int32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ + arm_status status; /* Status of Partial convolution */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t acc0, acc1, acc2, acc3; /* Accumulator */ - q31_t input1, input2; /* Temporary input variables */ - q15_t in1, in2; /* Temporary input variables */ - q7_t x0, x1, x2, x3, c0, c1; /* Temporary variables to hold state and coefficient values */ +#if defined(ARM_MATH_LOOPUNROLL) + q31_t acc0, acc1, acc2, acc3; /* Accumulator */ + q31_t input1, input2; /* Temporary input variables */ + q15_t in1, in2; /* Temporary input variables */ + q7_t x0, x1, x2, x3, c0, + c1; /* Temporary variables to hold state and coefficient values */ #endif /* Check for range of output samples to be calculated */ - if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) - { + if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) { /* Set status as ARM_MATH_ARGUMENT_ERROR */ status = ARM_MATH_ARGUMENT_ERROR; - } - else - { + } else { /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ - if (srcALen >= srcBLen) - { + if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; - } - else - { + } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; @@ -121,21 +113,30 @@ arm_status arm_conv_partial_q7( /* Conditions to check which loopCounter holds * the first and last indices of the output samples to be calculated. */ check = firstIndex + numPoints; - blockSize3 = ((int32_t)check > (int32_t)srcALen) ? (int32_t)check - (int32_t)srcALen : 0; - blockSize3 = ((int32_t)firstIndex > (int32_t)srcALen - 1) ? blockSize3 - (int32_t)firstIndex + (int32_t)srcALen : blockSize3; - blockSize1 = ((int32_t) srcBLen - 1) - (int32_t) firstIndex; - blockSize1 = (blockSize1 > 0) ? ((check > (srcBLen - 1U)) ? blockSize1 : (int32_t) numPoints) : 0; - blockSize2 = (int32_t) check - ((blockSize3 + blockSize1) + (int32_t) firstIndex); + blockSize3 = ((int32_t)check > (int32_t)srcALen) + ? (int32_t)check - (int32_t)srcALen + : 0; + blockSize3 = ((int32_t)firstIndex > (int32_t)srcALen - 1) + ? blockSize3 - (int32_t)firstIndex + (int32_t)srcALen + : blockSize3; + blockSize1 = ((int32_t)srcBLen - 1) - (int32_t)firstIndex; + blockSize1 = + (blockSize1 > 0) + ? ((check > (srcBLen - 1U)) ? blockSize1 : (int32_t)numPoints) + : 0; + blockSize2 = + (int32_t)check - ((blockSize3 + blockSize1) + (int32_t)firstIndex); blockSize2 = (blockSize2 > 0) ? blockSize2 : 0; - /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ x[n-N+1] * y[N -1] */ + /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ + * x[n-N+1] * y[N -1] */ /* The function is internally - * divided into three stages according to the number of multiplications that has to be - * taken place between inputA samples and inputB samples. In the first stage of the - * algorithm, the multiplications increase by one for every iteration. - * In the second stage of the algorithm, srcBLen number of multiplications are done. - * In the third stage of the algorithm, the multiplications decrease by one - * for every iteration. */ + * divided into three stages according to the number of multiplications that + * has to be taken place between inputA samples and inputB samples. In the + * first stage of the algorithm, the multiplications increase by one for + * every iteration. In the second stage of the algorithm, srcBLen number of + * multiplications are done. In the third stage of the algorithm, the + * multiplications decrease by one for every iteration. */ /* Set the output pointer to point to the firstIndex * of the output sample to be calculated. */ @@ -148,7 +149,8 @@ arm_status arm_conv_partial_q7( /* sum = x[0] * y[0] * sum = x[0] * y[1] + x[1] * y[0] * .... - * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * y[0] + * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] + * * y[0] */ /* In this stage the MAC operations are increased by 1 for every iteration. @@ -169,41 +171,39 @@ arm_status arm_conv_partial_q7( * ----------------------*/ /* The first stage starts here */ - while (blockSize1 > 0U) - { + while (blockSize1 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = count >> 2U; - while (k > 0U) - { + while (k > 0U) { /* x[0] , x[1] */ - in1 = (q15_t) *px++; - in2 = (q15_t) *px++; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + in1 = (q15_t)*px++; + in2 = (q15_t)*px++; + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* y[srcBLen - 1] , y[srcBLen - 2] */ - in1 = (q15_t) *py--; - in2 = (q15_t) *py--; - input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + in1 = (q15_t)*py--; + in2 = (q15_t)*py--; + input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* x[0] * y[srcBLen - 1] */ /* x[1] * y[srcBLen - 2] */ sum = __SMLAD(input1, input2, sum); /* x[2] , x[3] */ - in1 = (q15_t) *px++; - in2 = (q15_t) *px++; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + in1 = (q15_t)*px++; + in2 = (q15_t)*px++; + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* y[srcBLen - 3] , y[srcBLen - 4] */ - in1 = (q15_t) *py--; - in2 = (q15_t) *py--; - input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + in1 = (q15_t)*py--; + in2 = (q15_t)*py--; + input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* x[2] * y[srcBLen - 3] */ /* x[3] * y[srcBLen - 4] */ @@ -223,17 +223,16 @@ arm_status arm_conv_partial_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum += ((q31_t) * px++ * *py--); + sum += ((q31_t)*px++ * *py--); /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q7_t) (__SSAT(sum >> 7, 8)); + *pOut++ = (q7_t)(__SSAT(sum >> 7, 8)); /* Update the inputA and inputB pointers for next MAC calculation */ py = ++pSrc2; @@ -253,16 +252,14 @@ arm_status arm_conv_partial_q7( /* sum = x[0] * y[srcBLen-1] + x[1] * y[srcBLen-2] +...+ x[srcBLen-1] * y[0] * sum = x[1] * y[srcBLen-1] + x[2] * y[srcBLen-2] +...+ x[srcBLen] * y[0] * .... - * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ x[srcALen-1] * y[0] + * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] + * +...+ x[srcALen-1] * y[0] */ /* Working pointer of inputA */ - if ((int32_t)firstIndex - (int32_t)srcBLen + 1 > 0) - { + if ((int32_t)firstIndex - (int32_t)srcBLen + 1 > 0) { pSrc1 = pIn1 + firstIndex - srcBLen + 1; - } - else - { + } else { pSrc1 = pIn1; } px = pSrc1; @@ -278,18 +275,16 @@ arm_status arm_conv_partial_q7( * Stage2 process * ------------------*/ - /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed. - * So, to loop unroll over blockSize2, + /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are + * performed. So, to loop unroll over blockSize2, * srcBLen should be greater than or equal to 4 */ - if (srcBLen >= 4U) - { -#if defined (ARM_MATH_LOOPUNROLL) + if (srcBLen >= 4U) { +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ - blkCnt = ((uint32_t) blockSize2 >> 2U); + blkCnt = ((uint32_t)blockSize2 >> 2U); - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Set all accumulators to zero */ acc0 = 0; acc1 = 0; @@ -304,10 +299,11 @@ arm_status arm_conv_partial_q7( /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = srcBLen >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. - ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - do - { + /* First part of the processing with loop unrolling. Compute 4 MACs at + *a time. + ** a second loop below computes MACs for the remaining 1 to 3 samples. + */ + do { /* Read y[srcBLen - 1] sample */ c0 = *py--; /* Read y[srcBLen - 2] sample */ @@ -317,34 +313,34 @@ arm_status arm_conv_partial_q7( x3 = *px++; /* x[0] and x[1] are packed */ - in1 = (q15_t) x0; - in2 = (q15_t) x1; + in1 = (q15_t)x0; + in2 = (q15_t)x1; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* y[srcBLen - 1] and y[srcBLen - 2] are packed */ - in1 = (q15_t) c0; - in2 = (q15_t) c1; + in1 = (q15_t)c0; + in2 = (q15_t)c1; - input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* acc0 += x[0] * y[srcBLen - 1] + x[1] * y[srcBLen - 2] */ acc0 = __SMLAD(input1, input2, acc0); /* x[1] and x[2] are packed */ - in1 = (q15_t) x1; - in2 = (q15_t) x2; + in1 = (q15_t)x1; + in2 = (q15_t)x2; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* acc1 += x[1] * y[srcBLen - 1] + x[2] * y[srcBLen - 2] */ acc1 = __SMLAD(input1, input2, acc1); /* x[2] and x[3] are packed */ - in1 = (q15_t) x2; - in2 = (q15_t) x3; + in1 = (q15_t)x2; + in2 = (q15_t)x3; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* acc2 += x[2] * y[srcBLen - 1] + x[3] * y[srcBLen - 2] */ acc2 = __SMLAD(input1, input2, acc2); @@ -353,10 +349,10 @@ arm_status arm_conv_partial_q7( x0 = *px++; /* x[3] and x[4] are packed */ - in1 = (q15_t) x3; - in2 = (q15_t) x0; + in1 = (q15_t)x3; + in2 = (q15_t)x0; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* acc3 += x[3] * y[srcBLen - 1] + x[4] * y[srcBLen - 2] */ acc3 = __SMLAD(input1, input2, acc3); @@ -370,34 +366,34 @@ arm_status arm_conv_partial_q7( x1 = *px++; /* x[2] and x[3] are packed */ - in1 = (q15_t) x2; - in2 = (q15_t) x3; + in1 = (q15_t)x2; + in2 = (q15_t)x3; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* y[srcBLen - 3] and y[srcBLen - 4] are packed */ - in1 = (q15_t) c0; - in2 = (q15_t) c1; + in1 = (q15_t)c0; + in2 = (q15_t)c1; - input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* acc0 += x[2] * y[srcBLen - 3] + x[3] * y[srcBLen - 4] */ acc0 = __SMLAD(input1, input2, acc0); /* x[3] and x[4] are packed */ - in1 = (q15_t) x3; - in2 = (q15_t) x0; + in1 = (q15_t)x3; + in2 = (q15_t)x0; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* acc1 += x[3] * y[srcBLen - 3] + x[4] * y[srcBLen - 4] */ acc1 = __SMLAD(input1, input2, acc1); /* x[4] and x[5] are packed */ - in1 = (q15_t) x0; - in2 = (q15_t) x1; + in1 = (q15_t)x0; + in2 = (q15_t)x1; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* acc2 += x[4] * y[srcBLen - 3] + x[5] * y[srcBLen - 4] */ acc2 = __SMLAD(input1, input2, acc2); @@ -406,22 +402,22 @@ arm_status arm_conv_partial_q7( x2 = *px++; /* x[5] and x[6] are packed */ - in1 = (q15_t) x1; - in2 = (q15_t) x2; + in1 = (q15_t)x1; + in2 = (q15_t)x2; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* acc3 += x[5] * y[srcBLen - 3] + x[6] * y[srcBLen - 4] */ acc3 = __SMLAD(input1, input2, acc3); } while (--k); - /* If the srcBLen is not a multiple of 4, compute any remaining MACs here. + /* If the srcBLen is not a multiple of 4, compute any remaining MACs + *here. ** No loop unrolling is used. */ k = srcBLen % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* Read y[srcBLen - 5] sample */ c0 = *py--; /* Read x[7] sample */ @@ -429,13 +425,13 @@ arm_status arm_conv_partial_q7( /* Perform the multiply-accumulates */ /* acc0 += x[4] * y[srcBLen - 5] */ - acc0 += ((q31_t) x0 * c0); + acc0 += ((q31_t)x0 * c0); /* acc1 += x[5] * y[srcBLen - 5] */ - acc1 += ((q31_t) x1 * c0); + acc1 += ((q31_t)x1 * c0); /* acc2 += x[6] * y[srcBLen - 5] */ - acc2 += ((q31_t) x2 * c0); + acc2 += ((q31_t)x2 * c0); /* acc3 += x[7] * y[srcBLen - 5] */ - acc3 += ((q31_t) x3 * c0); + acc3 += ((q31_t)x3 * c0); /* Reuse the present samples for the next MAC */ x0 = x1; @@ -447,10 +443,10 @@ arm_status arm_conv_partial_q7( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q7_t) (__SSAT(acc0 >> 7, 8)); - *pOut++ = (q7_t) (__SSAT(acc1 >> 7, 8)); - *pOut++ = (q7_t) (__SSAT(acc2 >> 7, 8)); - *pOut++ = (q7_t) (__SSAT(acc3 >> 7, 8)); + *pOut++ = (q7_t)(__SSAT(acc0 >> 7, 8)); + *pOut++ = (q7_t)(__SSAT(acc1 >> 7, 8)); + *pOut++ = (q7_t)(__SSAT(acc2 >> 7, 8)); + *pOut++ = (q7_t)(__SSAT(acc3 >> 7, 8)); /* Increment the pointer pIn1 index, count by 4 */ count += 4U; @@ -464,7 +460,7 @@ arm_status arm_conv_partial_q7( } /* Loop unrolling: Compute remaining outputs */ - blkCnt = (uint32_t) blockSize2 % 0x4U; + blkCnt = (uint32_t)blockSize2 % 0x4U; #else @@ -473,40 +469,38 @@ arm_status arm_conv_partial_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = srcBLen >> 2U; - while (k > 0U) - { + while (k > 0U) { /* Reading two inputs of SrcA buffer and packing */ - in1 = (q15_t) *px++; - in2 = (q15_t) *px++; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + in1 = (q15_t)*px++; + in2 = (q15_t)*px++; + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* Reading two inputs of SrcB buffer and packing */ - in1 = (q15_t) *py--; - in2 = (q15_t) *py--; - input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + in1 = (q15_t)*py--; + in2 = (q15_t)*py--; + input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* Perform the multiply-accumulate */ sum = __SMLAD(input1, input2, sum); /* Reading two inputs of SrcA buffer and packing */ - in1 = (q15_t) *px++; - in2 = (q15_t) *px++; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + in1 = (q15_t)*px++; + in2 = (q15_t)*px++; + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* Reading two inputs of SrcB buffer and packing */ - in1 = (q15_t) *py--; - in2 = (q15_t) *py--; - input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + in1 = (q15_t)*py--; + in2 = (q15_t)*py--; + input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* Perform the multiply-accumulate */ sum = __SMLAD(input1, input2, sum); @@ -525,17 +519,16 @@ arm_status arm_conv_partial_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum += ((q31_t) * px++ * *py--); + sum += ((q31_t)*px++ * *py--); /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q7_t) (__SSAT(sum >> 7, 8)); + *pOut++ = (q7_t)(__SSAT(sum >> 7, 8)); /* Increment the pointer pIn1 index, count by 1 */ count++; @@ -547,32 +540,28 @@ arm_status arm_conv_partial_q7( /* Decrement loop counter */ blkCnt--; } - } - else - { + } else { /* If the srcBLen is not a multiple of 4, * the blockSize2 loop cannot be unrolled by 4 */ - blkCnt = (uint32_t) blockSize2; + blkCnt = (uint32_t)blockSize2; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* srcBLen number of MACS should be performed */ k = srcBLen; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum += ((q31_t) * px++ * *py--); + sum += ((q31_t)*px++ * *py--); /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q7_t) (__SSAT(sum >> 7, 8)); + *pOut++ = (q7_t)(__SSAT(sum >> 7, 8)); /* Increment the MAC count */ count++; @@ -586,13 +575,14 @@ arm_status arm_conv_partial_q7( } } - /* -------------------------- * Initializations of stage3 * -------------------------*/ - /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * y[srcBLen-2] +...+ x[srcALen-1] * y[1] - * sum += x[srcALen-srcBLen+2] * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * y[2] + /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * + * y[srcBLen-2] +...+ x[srcALen-1] * y[1] sum += x[srcALen-srcBLen+2] * + * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * + * y[2] * .... * sum += x[srcALen-2] * y[srcBLen-1] + x[srcALen-1] * y[srcBLen-2] * sum += x[srcALen-1] * y[srcBLen-1] @@ -614,41 +604,43 @@ arm_status arm_conv_partial_q7( * Stage3 process * ------------------*/ - while (blockSize3 > 0U) - { + while (blockSize3 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = count >> 2U; - while (k > 0U) - { - /* Reading two inputs, x[srcALen - srcBLen + 1] and x[srcALen - srcBLen + 2] of SrcA buffer and packing */ - in1 = (q15_t) *px++; - in2 = (q15_t) *px++; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + while (k > 0U) { + /* Reading two inputs, x[srcALen - srcBLen + 1] and x[srcALen - srcBLen + * + 2] of SrcA buffer and packing */ + in1 = (q15_t)*px++; + in2 = (q15_t)*px++; + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); - /* Reading two inputs, y[srcBLen - 1] and y[srcBLen - 2] of SrcB buffer and packing */ - in1 = (q15_t) *py--; - in2 = (q15_t) *py--; - input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + /* Reading two inputs, y[srcBLen - 1] and y[srcBLen - 2] of SrcB buffer + * and packing */ + in1 = (q15_t)*py--; + in2 = (q15_t)*py--; + input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* sum += x[srcALen - srcBLen + 1] * y[srcBLen - 1] */ /* sum += x[srcALen - srcBLen + 2] * y[srcBLen - 2] */ sum = __SMLAD(input1, input2, sum); - /* Reading two inputs, x[srcALen - srcBLen + 3] and x[srcALen - srcBLen + 4] of SrcA buffer and packing */ - in1 = (q15_t) *px++; - in2 = (q15_t) *px++; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + /* Reading two inputs, x[srcALen - srcBLen + 3] and x[srcALen - srcBLen + * + 4] of SrcA buffer and packing */ + in1 = (q15_t)*px++; + in2 = (q15_t)*px++; + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); - /* Reading two inputs, y[srcBLen - 3] and y[srcBLen - 4] of SrcB buffer and packing */ - in1 = (q15_t) *py--; - in2 = (q15_t) *py--; - input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16); + /* Reading two inputs, y[srcBLen - 3] and y[srcBLen - 4] of SrcB buffer + * and packing */ + in1 = (q15_t)*py--; + in2 = (q15_t)*py--; + input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16); /* sum += x[srcALen - srcBLen + 3] * y[srcBLen - 3] */ /* sum += x[srcALen - srcBLen + 4] * y[srcBLen - 4] */ @@ -668,18 +660,17 @@ arm_status arm_conv_partial_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ /* sum += x[srcALen-1] * y[srcBLen-1] */ - sum += ((q31_t) * px++ * *py--); + sum += ((q31_t)*px++ * *py--); /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q7_t) (__SSAT(sum >> 7, 8)); + *pOut++ = (q7_t)(__SSAT(sum >> 7, 8)); /* Update the inputA and inputB pointers for next MAC calculation */ px = ++pSrc1; @@ -700,41 +691,35 @@ arm_status arm_conv_partial_q7( return (status); #else -/* alternate version for CM0_FAMILY */ + /* alternate version for CM0_FAMILY */ - const q7_t *pIn1 = pSrcA; /* InputA pointer */ - const q7_t *pIn2 = pSrcB; /* InputB pointer */ - q31_t sum; /* Accumulator */ - uint32_t i, j; /* Loop counters */ - arm_status status; /* Status of Partial convolution */ + const q7_t *pIn1 = pSrcA; /* InputA pointer */ + const q7_t *pIn2 = pSrcB; /* InputB pointer */ + q31_t sum; /* Accumulator */ + uint32_t i, j; /* Loop counters */ + arm_status status; /* Status of Partial convolution */ /* Check for range of output samples to be calculated */ - if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) - { + if ((firstIndex + numPoints) > ((srcALen + (srcBLen - 1U)))) { /* Set status as ARM_MATH_ARGUMENT_ERROR */ status = ARM_MATH_ARGUMENT_ERROR; - } - else - { + } else { /* Loop to calculate convolution for output length number of values */ - for (i = firstIndex; i <= (firstIndex + numPoints - 1); i++) - { + for (i = firstIndex; i <= (firstIndex + numPoints - 1); i++) { /* Initialize sum with zero to carry on MAC operations */ sum = 0; /* Loop to perform MAC operations according to convolution equation */ - for (j = 0U; j <= i; j++) - { + for (j = 0U; j <= i; j++) { /* Check the array limitations */ - if (((i - j) < srcBLen) && (j < srcALen)) - { + if (((i - j) < srcBLen) && (j < srcALen)) { /* z[i] += x[i-j] * y[j] */ - sum += ((q15_t) pIn1[j] * (pIn2[i - j])); + sum += ((q15_t)pIn1[j] * (pIn2[i - j])); } } /* Store the output in the destination buffer */ - pDst[i] = (q7_t) __SSAT((sum >> 7U), 8U); + pDst[i] = (q7_t)__SSAT((sum >> 7U), 8U); } /* Set status as ARM_MATH_SUCCESS */ @@ -745,7 +730,6 @@ arm_status arm_conv_partial_q7( return (status); #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */ - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_q15.c index ad2b629..2d92797 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_q15.c @@ -43,56 +43,53 @@ @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence - @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1. + @param[out] pDst points to the location where the output result is + written. Length srcALen+srcBLen-1. @return none @par Scaling and Overflow Behavior - The function is implemented using a 64-bit internal accumulator. - Both inputs are in 1.15 format and multiplications yield a 2.30 result. - The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. - This approach provides 33 guard bits and there is no risk of overflow. - The 34.30 result is then truncated to 34.15 format by discarding the low 15 bits and then saturated to 1.15 format. + The function is implemented using a 64-bit internal + accumulator. Both inputs are in 1.15 format and multiplications yield a 2.30 + result. The 2.30 intermediate results are accumulated in a 64-bit accumulator + in 34.30 format. This approach provides 33 guard bits and there is no risk of + overflow. The 34.30 result is then truncated to 34.15 format by discarding the + low 15 bits and then saturated to 1.15 format. @remark - Refer to \ref arm_conv_fast_q15() for a faster but less precise version of this function. + Refer to \ref arm_conv_fast_q15() for a faster but less + precise version of this function. @remark - Refer to \ref arm_conv_opt_q15() for a faster implementation of this function using scratch buffers. + Refer to \ref arm_conv_opt_q15() for a faster implementation + of this function using scratch buffers. */ -void arm_conv_q15( - const q15_t * pSrcA, - uint32_t srcALen, - const q15_t * pSrcB, - uint32_t srcBLen, - q15_t * pDst) -{ +void arm_conv_q15(const q15_t *pSrcA, uint32_t srcALen, const q15_t *pSrcB, + uint32_t srcBLen, q15_t *pDst) { -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) - const q15_t *pIn1; /* InputA pointer */ - const q15_t *pIn2; /* InputB pointer */ - q15_t *pOut = pDst; /* Output pointer */ - q63_t sum, acc0, acc1, acc2, acc3; /* Accumulators */ - const q15_t *px; /* Intermediate inputA pointer */ - const q15_t *py; /* Intermediate inputB pointer */ - const q15_t *pSrc1, *pSrc2; /* Intermediate pointers */ - q31_t x0, x1, x2, x3, c0; /* Temporary input variables to hold state and coefficient values */ - uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ - uint32_t j, k, count, blkCnt; /* Loop counters */ + const q15_t *pIn1; /* InputA pointer */ + const q15_t *pIn2; /* InputB pointer */ + q15_t *pOut = pDst; /* Output pointer */ + q63_t sum, acc0, acc1, acc2, acc3; /* Accumulators */ + const q15_t *px; /* Intermediate inputA pointer */ + const q15_t *py; /* Intermediate inputB pointer */ + const q15_t *pSrc1, *pSrc2; /* Intermediate pointers */ + q31_t x0, x1, x2, x3, + c0; /* Temporary input variables to hold state and coefficient values */ + uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ + uint32_t j, k, count, blkCnt; /* Loop counters */ /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ - if (srcALen >= srcBLen) - { + if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; - } - else - { + } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; @@ -105,14 +102,15 @@ void arm_conv_q15( srcALen = j; } - /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ x[n-N+1] * y[N -1] */ + /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ + * x[n-N+1] * y[N -1] */ /* The function is internally - * divided into three stages according to the number of multiplications that has to be - * taken place between inputA samples and inputB samples. In the first stage of the - * algorithm, the multiplications increase by one for every iteration. - * In the second stage of the algorithm, srcBLen number of multiplications are done. - * In the third stage of the algorithm, the multiplications decrease by one - * for every iteration. */ + * divided into three stages according to the number of multiplications that + * has to be taken place between inputA samples and inputB samples. In the + * first stage of the algorithm, the multiplications increase by one for every + * iteration. In the second stage of the algorithm, srcBLen number of + * multiplications are done. In the third stage of the algorithm, the + * multiplications decrease by one for every iteration. */ /* The algorithm is implemented in three stages. The loop counters of each stage is initiated here. */ @@ -126,7 +124,8 @@ void arm_conv_q15( /* sum = x[0] * y[0] * sum = x[0] * y[1] + x[1] * y[0] * .... - * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * y[0] + * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * + * y[0] */ /* In this stage the MAC operations are increased by 1 for every iteration. @@ -145,11 +144,11 @@ void arm_conv_q15( /* For loop unrolling by 4, this stage is divided into two. */ /* First part of this stage computes the MAC operations less than 4 */ - /* Second part of this stage computes the MAC operations greater than or equal to 4 */ + /* Second part of this stage computes the MAC operations greater than or equal + * to 4 */ /* The first part of the stage starts here */ - while ((count < 4U) && (blockSize1 > 0U)) - { + while ((count < 4U) && (blockSize1 > 0U)) { /* Accumulator is made zero for every iteration */ sum = 0; @@ -157,8 +156,7 @@ void arm_conv_q15( * inputA samples and inputB samples */ k = count; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ sum = __SMLALD(*px++, *py--, sum); @@ -167,7 +165,7 @@ void arm_conv_q15( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (__SSAT((sum >> 15), 16)); + *pOut++ = (q15_t)(__SSAT((sum >> 15), 16)); /* Update the inputA and inputB pointers for next MAC calculation */ py = pIn2 + count; @@ -186,23 +184,26 @@ void arm_conv_q15( * y[srcBLen] and y[srcBLen-1] coefficients, py is decremented by 1 */ py = py - 1; - while (blockSize1 > 0U) - { + while (blockSize1 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = count >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. + /* First part of the processing with loop unrolling. Compute 4 MACs at a + *time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - /* x[0], x[1] are multiplied with y[srcBLen - 1], y[srcBLen - 2] respectively */ - sum = __SMLALDX(read_q15x2_ia ((q15_t **) &px), read_q15x2_da ((q15_t **) &py), sum); - /* x[2], x[3] are multiplied with y[srcBLen - 3], y[srcBLen - 4] respectively */ - sum = __SMLALDX(read_q15x2_ia ((q15_t **) &px), read_q15x2_da ((q15_t **) &py), sum); + /* x[0], x[1] are multiplied with y[srcBLen - 1], y[srcBLen - 2] + * respectively */ + sum = __SMLALDX(read_q15x2_ia((q15_t **)&px), + read_q15x2_da((q15_t **)&py), sum); + /* x[2], x[3] are multiplied with y[srcBLen - 3], y[srcBLen - 4] + * respectively */ + sum = __SMLALDX(read_q15x2_ia((q15_t **)&px), + read_q15x2_da((q15_t **)&py), sum); /* Decrement loop counter */ k--; @@ -216,8 +217,7 @@ void arm_conv_q15( ** No loop unrolling is used. */ k = count % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ sum = __SMLALD(*px++, *py--, sum); @@ -226,7 +226,7 @@ void arm_conv_q15( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (__SSAT((sum >> 15), 16)); + *pOut++ = (q15_t)(__SSAT((sum >> 15), 16)); /* Update the inputA and inputB pointers for next MAC calculation */ py = pIn2 + (count - 1U); @@ -246,7 +246,8 @@ void arm_conv_q15( /* sum = x[0] * y[srcBLen-1] + x[1] * y[srcBLen-2] +...+ x[srcBLen-1] * y[0] * sum = x[1] * y[srcBLen-1] + x[2] * y[srcBLen-2] +...+ x[srcBLen] * y[0] * .... - * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ x[srcALen-1] * y[0] + * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ + * x[srcALen-1] * y[0] */ /* Working pointer of inputA */ @@ -263,16 +264,14 @@ void arm_conv_q15( * Stage2 process * ------------------*/ - /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed. - * So, to loop unroll over blockSize2, - * srcBLen should be greater than or equal to 4 */ - if (srcBLen >= 4U) - { + /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are + * performed. So, to loop unroll over blockSize2, srcBLen should be greater + * than or equal to 4 */ + if (srcBLen >= 4U) { /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize2 >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { py = py - 1U; /* Set all accumulators to zero */ @@ -282,22 +281,22 @@ void arm_conv_q15( acc3 = 0; /* read x[0], x[1] samples */ - x0 = read_q15x2 ((q15_t *) px); + x0 = read_q15x2((q15_t *)px); /* read x[1], x[2] samples */ - x1 = read_q15x2 ((q15_t *) px + 1); + x1 = read_q15x2((q15_t *)px + 1); px += 2U; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = srcBLen >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. + /* First part of the processing with loop unrolling. Compute 4 MACs at a + *time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - do - { + do { /* Read the last two inputB samples using SIMD: * y[srcBLen - 1] and y[srcBLen - 2] */ - c0 = read_q15x2_da ((q15_t **) &py); + c0 = read_q15x2_da((q15_t **)&py); /* acc0 += x[0] * y[srcBLen - 1] + x[1] * y[srcBLen - 2] */ acc0 = __SMLALDX(x0, c0, acc0); @@ -306,10 +305,10 @@ void arm_conv_q15( acc1 = __SMLALDX(x1, c0, acc1); /* Read x[2], x[3] */ - x2 = read_q15x2 ((q15_t *) px); + x2 = read_q15x2((q15_t *)px); /* Read x[3], x[4] */ - x3 = read_q15x2 ((q15_t *) px + 1); + x3 = read_q15x2((q15_t *)px + 1); /* acc2 += x[2] * y[srcBLen - 1] + x[3] * y[srcBLen - 2] */ acc2 = __SMLALDX(x2, c0, acc2); @@ -318,7 +317,7 @@ void arm_conv_q15( acc3 = __SMLALDX(x3, c0, acc3); /* Read y[srcBLen - 3] and y[srcBLen - 4] */ - c0 = read_q15x2_da ((q15_t **) &py); + c0 = read_q15x2_da((q15_t **)&py); /* acc0 += x[2] * y[srcBLen - 3] + x[3] * y[srcBLen - 4] */ acc0 = __SMLALDX(x2, c0, acc0); @@ -327,10 +326,10 @@ void arm_conv_q15( acc1 = __SMLALDX(x3, c0, acc1); /* Read x[4], x[5] */ - x0 = read_q15x2 ((q15_t *) px + 2); + x0 = read_q15x2((q15_t *)px + 2); /* Read x[5], x[6] */ - x1 = read_q15x2 ((q15_t *) px + 3); + x1 = read_q15x2((q15_t *)px + 3); px += 4U; @@ -349,18 +348,17 @@ void arm_conv_q15( ** No loop unrolling is used. */ k = srcBLen % 0x4U; - if (k == 1U) - { + if (k == 1U) { /* Read y[srcBLen - 5] */ c0 = *(py + 1); -#ifdef ARM_MATH_BIG_ENDIAN +#ifdef ARM_MATH_BIG_ENDIAN c0 = c0 << 16U; #else c0 = c0 & 0x0000FFFF; #endif /* #ifdef ARM_MATH_BIG_ENDIAN */ /* Read x[7] */ - x3 = read_q15x2 ((q15_t *) px); + x3 = read_q15x2((q15_t *)px); px++; /* Perform the multiply-accumulate */ @@ -370,16 +368,15 @@ void arm_conv_q15( acc3 = __SMLALDX(x3, c0, acc3); } - if (k == 2U) - { + if (k == 2U) { /* Read y[srcBLen - 5], y[srcBLen - 6] */ - c0 = read_q15x2 ((q15_t *) py); + c0 = read_q15x2((q15_t *)py); /* Read x[7], x[8] */ - x3 = read_q15x2 ((q15_t *) px); + x3 = read_q15x2((q15_t *)px); /* Read x[9] */ - x2 = read_q15x2 ((q15_t *) px + 1); + x2 = read_q15x2((q15_t *)px + 1); px += 2U; /* Perform the multiply-accumulate */ @@ -389,16 +386,15 @@ void arm_conv_q15( acc3 = __SMLALDX(x2, c0, acc3); } - if (k == 3U) - { + if (k == 3U) { /* Read y[srcBLen - 5], y[srcBLen - 6] */ - c0 = read_q15x2 ((q15_t *) py); + c0 = read_q15x2((q15_t *)py); /* Read x[7], x[8] */ - x3 = read_q15x2 ((q15_t *) px); + x3 = read_q15x2((q15_t *)px); /* Read x[9] */ - x2 = read_q15x2 ((q15_t *) px + 1); + x2 = read_q15x2((q15_t *)px + 1); /* Perform the multiply-accumulate */ acc0 = __SMLALDX(x0, c0, acc0); @@ -406,15 +402,15 @@ void arm_conv_q15( acc2 = __SMLALDX(x3, c0, acc2); acc3 = __SMLALDX(x2, c0, acc3); - c0 = *(py-1); -#ifdef ARM_MATH_BIG_ENDIAN + c0 = *(py - 1); +#ifdef ARM_MATH_BIG_ENDIAN c0 = c0 << 16U; #else c0 = c0 & 0x0000FFFF; #endif /* #ifdef ARM_MATH_BIG_ENDIAN */ /* Read x[10] */ - x3 = read_q15x2 ((q15_t *) px + 2); + x3 = read_q15x2((q15_t *)px + 2); px += 3U; /* Perform the multiply-accumulates */ @@ -425,12 +421,16 @@ void arm_conv_q15( } /* Store the result in the accumulator in the destination buffer. */ -#ifndef ARM_MATH_BIG_ENDIAN - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc0 >> 15), 16), __SSAT((acc1 >> 15), 16), 16)); - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc2 >> 15), 16), __SSAT((acc3 >> 15), 16), 16)); +#ifndef ARM_MATH_BIG_ENDIAN + write_q15x2_ia(&pOut, __PKHBT(__SSAT((acc0 >> 15), 16), + __SSAT((acc1 >> 15), 16), 16)); + write_q15x2_ia(&pOut, __PKHBT(__SSAT((acc2 >> 15), 16), + __SSAT((acc3 >> 15), 16), 16)); #else - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc1 >> 15), 16), __SSAT((acc0 >> 15), 16), 16)); - write_q15x2_ia (&pOut, __PKHBT(__SSAT((acc3 >> 15), 16), __SSAT((acc2 >> 15), 16), 16)); + write_q15x2_ia(&pOut, __PKHBT(__SSAT((acc1 >> 15), 16), + __SSAT((acc0 >> 15), 16), 16)); + write_q15x2_ia(&pOut, __PKHBT(__SSAT((acc3 >> 15), 16), + __SSAT((acc2 >> 15), 16), 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Increment the pointer pIn1 index, count by 4 */ @@ -444,27 +444,27 @@ void arm_conv_q15( blkCnt--; } - /* If the blockSize2 is not a multiple of 4, compute any remaining output samples here. + /* If the blockSize2 is not a multiple of 4, compute any remaining output + *samples here. ** No loop unrolling is used. */ blkCnt = blockSize2 % 0x4U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = srcBLen >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. + /* First part of the processing with loop unrolling. Compute 4 MACs at a + *time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ - sum += (q63_t) ((q31_t) *px++ * *py--); - sum += (q63_t) ((q31_t) *px++ * *py--); - sum += (q63_t) ((q31_t) *px++ * *py--); - sum += (q63_t) ((q31_t) *px++ * *py--); + sum += (q63_t)((q31_t)*px++ * *py--); + sum += (q63_t)((q31_t)*px++ * *py--); + sum += (q63_t)((q31_t)*px++ * *py--); + sum += (q63_t)((q31_t)*px++ * *py--); /* Decrement loop counter */ k--; @@ -474,17 +474,16 @@ void arm_conv_q15( ** No loop unrolling is used. */ k = srcBLen % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ - sum += (q63_t) ((q31_t) *px++ * *py--); + sum += (q63_t)((q31_t)*px++ * *py--); /* Decrement the loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (__SSAT(sum >> 15, 16)); + *pOut++ = (q15_t)(__SSAT(sum >> 15, 16)); /* Increment the pointer pIn1 index, count by 1 */ count++; @@ -496,32 +495,28 @@ void arm_conv_q15( /* Decrement the loop counter */ blkCnt--; } - } - else - { + } else { /* If the srcBLen is not a multiple of 4, * the blockSize2 loop cannot be unrolled by 4 */ blkCnt = blockSize2; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* srcBLen number of MACS should be performed */ k = srcBLen; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum += (q63_t) ((q31_t) *px++ * *py--); + sum += (q63_t)((q31_t)*px++ * *py--); /* Decrement the loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (__SSAT(sum >> 15, 16)); + *pOut++ = (q15_t)(__SSAT(sum >> 15, 16)); /* Increment the MAC count */ count++; @@ -535,13 +530,14 @@ void arm_conv_q15( } } - /* -------------------------- * Initializations of stage3 * -------------------------*/ - /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * y[srcBLen-2] +...+ x[srcALen-1] * y[1] - * sum += x[srcALen-srcBLen+2] * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * y[2] + /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * + * y[srcBLen-2] +...+ x[srcALen-1] * y[1] sum += x[srcALen-srcBLen+2] * + * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * + * y[2] * .... * sum += x[srcALen-2] * y[srcBLen-1] + x[srcALen-1] * y[srcBLen-2] * sum += x[srcALen-1] * y[srcBLen-1] @@ -566,30 +562,32 @@ void arm_conv_q15( /* For loop unrolling by 4, this stage is divided into two. */ /* First part of this stage computes the MAC operations greater than 4 */ - /* Second part of this stage computes the MAC operations less than or equal to 4 */ + /* Second part of this stage computes the MAC operations less than or equal to + * 4 */ /* The first part of the stage starts here */ j = blockSize3 >> 2U; - while ((j > 0U) && (blockSize3 > 0U)) - { + while ((j > 0U) && (blockSize3 > 0U)) { /* Accumulator is made zero for every iteration */ sum = 0; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = blockSize3 >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. + /* First part of the processing with loop unrolling. Compute 4 MACs at a + *time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ /* x[srcALen - srcBLen + 1], x[srcALen - srcBLen + 2] are multiplied * with y[srcBLen - 1], y[srcBLen - 2] respectively */ - sum = __SMLALDX(read_q15x2_ia ((q15_t **) &px), read_q15x2_da ((q15_t **) &py), sum); + sum = __SMLALDX(read_q15x2_ia((q15_t **)&px), + read_q15x2_da((q15_t **)&py), sum); /* x[srcALen - srcBLen + 3], x[srcALen - srcBLen + 4] are multiplied * with y[srcBLen - 3], y[srcBLen - 4] respectively */ - sum = __SMLALDX(read_q15x2_ia ((q15_t **) &px), read_q15x2_da ((q15_t **) &py), sum); + sum = __SMLALDX(read_q15x2_ia((q15_t **)&px), + read_q15x2_da((q15_t **)&py), sum); /* Decrement loop counter */ k--; @@ -599,12 +597,12 @@ void arm_conv_q15( * So, py is incremented by 1 */ py = py + 1U; - /* If the blockSize3 is not a multiple of 4, compute any remaining MACs here. + /* If the blockSize3 is not a multiple of 4, compute any remaining MACs + *here. ** No loop unrolling is used. */ k = blockSize3 % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* sum += x[srcALen - srcBLen + 5] * y[srcBLen - 5] */ sum = __SMLALD(*px++, *py--, sum); @@ -613,7 +611,7 @@ void arm_conv_q15( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (__SSAT((sum >> 15), 16)); + *pOut++ = (q15_t)(__SSAT((sum >> 15), 16)); /* Update the inputA and inputB pointers for next MAC calculation */ px = ++pSrc1; @@ -630,16 +628,14 @@ void arm_conv_q15( * so pointer py is updated to read only one sample at a time */ py = py + 1U; - while (blockSize3 > 0U) - { + while (blockSize3 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = blockSize3; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ /* sum += x[srcALen-1] * y[srcBLen-1] */ sum = __SMLALD(*px++, *py--, sum); @@ -649,7 +645,7 @@ void arm_conv_q15( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q15_t) (__SSAT((sum >> 15), 16)); + *pOut++ = (q15_t)(__SSAT((sum >> 15), 16)); /* Update the inputA and inputB pointers for next MAC calculation */ px = ++pSrc1; @@ -661,34 +657,30 @@ void arm_conv_q15( #else /* #if defined (ARM_MATH_DSP) */ - const q15_t *pIn1 = pSrcA; /* InputA pointer */ - const q15_t *pIn2 = pSrcB; /* InputB pointer */ - q63_t sum; /* Accumulator */ - uint32_t i, j; /* Loop counters */ + const q15_t *pIn1 = pSrcA; /* InputA pointer */ + const q15_t *pIn2 = pSrcB; /* InputB pointer */ + q63_t sum; /* Accumulator */ + uint32_t i, j; /* Loop counters */ /* Loop to calculate convolution for output length number of values */ - for (i = 0; i < (srcALen + srcBLen - 1); i++) - { + for (i = 0; i < (srcALen + srcBLen - 1); i++) { /* Initialize sum with zero to carry on MAC operations */ sum = 0; /* Loop to perform MAC operations according to convolution equation */ - for (j = 0U; j <= i; j++) - { + for (j = 0U; j <= i; j++) { /* Check the array limitations */ - if (((i - j) < srcBLen) && (j < srcALen)) - { + if (((i - j) < srcBLen) && (j < srcALen)) { /* z[i] += x[i-j] * y[j] */ - sum += ((q31_t) pIn1[j] * pIn2[i - j]); + sum += ((q31_t)pIn1[j] * pIn2[i - j]); } } /* Store the output in the destination buffer */ - pDst[i] = (q15_t) __SSAT((sum >> 15U), 16U); + pDst[i] = (q15_t)__SSAT((sum >> 15U), 16U); } #endif /* #if defined (ARM_MATH_DSP) */ - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_q31.c index 39550ec..908ea24 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_q31.c @@ -43,62 +43,60 @@ @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence - @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1. + @param[out] pDst points to the location where the output result is + written. Length srcALen+srcBLen-1. @return none @par Scaling and Overflow Behavior - The function is implemented using an internal 64-bit accumulator. - The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. + The function is implemented using an internal 64-bit + accumulator. The accumulator has a 2.62 format and maintains full precision of + the intermediate multiplication results but provides only a single guard bit. There is no saturation on intermediate additions. - Thus, if the accumulator overflows it wraps around and distorts the result. - The input signals should be scaled down to avoid intermediate overflows. - Scale down the inputs by log2(min(srcALen, srcBLen)) (log2 is read as log to the base 2) times to avoid overflows, - as maximum of min(srcALen, srcBLen) number of additions are carried internally. - The 2.62 accumulator is right shifted by 31 bits and saturated to 1.31 format to yield the final result. + Thus, if the accumulator overflows it wraps around and + distorts the result. The input signals should be scaled down to avoid + intermediate overflows. Scale down the inputs by log2(min(srcALen, srcBLen)) + (log2 is read as log to the base 2) times to avoid overflows, as maximum of + min(srcALen, srcBLen) number of additions are carried internally. The 2.62 + accumulator is right shifted by 31 bits and saturated to 1.31 format to yield + the final result. @remark - Refer to \ref arm_conv_fast_q31() for a faster but less precise implementation of this function. + Refer to \ref arm_conv_fast_q31() for a faster but less + precise implementation of this function. */ -void arm_conv_q31( - const q31_t * pSrcA, - uint32_t srcALen, - const q31_t * pSrcB, - uint32_t srcBLen, - q31_t * pDst) -{ +void arm_conv_q31(const q31_t *pSrcA, uint32_t srcALen, const q31_t *pSrcB, + uint32_t srcBLen, q31_t *pDst) { #if (1) -//#if !defined(ARM_MATH_CM0_FAMILY) + //#if !defined(ARM_MATH_CM0_FAMILY) - const q31_t *pIn1; /* InputA pointer */ - const q31_t *pIn2; /* InputB pointer */ - q31_t *pOut = pDst; /* Output pointer */ - const q31_t *px; /* Intermediate inputA pointer */ - const q31_t *py; /* Intermediate inputB pointer */ - const q31_t *pSrc1, *pSrc2; /* Intermediate pointers */ - q63_t sum; /* Accumulators */ - uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ - uint32_t j, k, count, blkCnt; /* Loop counters */ + const q31_t *pIn1; /* InputA pointer */ + const q31_t *pIn2; /* InputB pointer */ + q31_t *pOut = pDst; /* Output pointer */ + const q31_t *px; /* Intermediate inputA pointer */ + const q31_t *py; /* Intermediate inputB pointer */ + const q31_t *pSrc1, *pSrc2; /* Intermediate pointers */ + q63_t sum; /* Accumulators */ + uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ + uint32_t j, k, count, blkCnt; /* Loop counters */ -#if defined (ARM_MATH_LOOPUNROLL) - q63_t acc0, acc1, acc2; /* Accumulators */ - q31_t x0, x1, x2, c0; /* Temporary variables to hold state and coefficient values */ +#if defined(ARM_MATH_LOOPUNROLL) + q63_t acc0, acc1, acc2; /* Accumulators */ + q31_t x0, x1, x2, + c0; /* Temporary variables to hold state and coefficient values */ #endif /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ - if (srcALen >= srcBLen) - { + if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; - } - else - { + } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; @@ -111,14 +109,15 @@ void arm_conv_q31( srcALen = j; } - /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ x[n-N+1] * y[N -1] */ + /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ + * x[n-N+1] * y[N -1] */ /* The function is internally - * divided into three stages according to the number of multiplications that has to be - * taken place between inputA samples and inputB samples. In the first stage of the - * algorithm, the multiplications increase by one for every iteration. - * In the second stage of the algorithm, srcBLen number of multiplications are done. - * In the third stage of the algorithm, the multiplications decrease by one - * for every iteration. */ + * divided into three stages according to the number of multiplications that + * has to be taken place between inputA samples and inputB samples. In the + * first stage of the algorithm, the multiplications increase by one for every + * iteration. In the second stage of the algorithm, srcBLen number of + * multiplications are done. In the third stage of the algorithm, the + * multiplications decrease by one for every iteration. */ /* The algorithm is implemented in three stages. The loop counters of each stage is initiated here. */ @@ -133,7 +132,8 @@ void arm_conv_q31( /* sum = x[0] * y[0] * sum = x[0] * y[1] + x[1] * y[0] * .... - * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * y[0] + * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * + * y[0] */ /* In this stage the MAC operations are increased by 1 for every iteration. @@ -146,35 +146,32 @@ void arm_conv_q31( /* Working pointer of inputB */ py = pIn2; - /* ------------------------ * Stage1 process * ----------------------*/ /* The first stage starts here */ - while (blockSize1 > 0U) - { + while (blockSize1 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = count >> 2U; - while (k > 0U) - { + while (k > 0U) { /* x[0] * y[srcBLen - 1] */ - sum += (q63_t) *px++ * (*py--); + sum += (q63_t)*px++ * (*py--); /* x[1] * y[srcBLen - 2] */ - sum += (q63_t) *px++ * (*py--); + sum += (q63_t)*px++ * (*py--); /* x[2] * y[srcBLen - 3] */ - sum += (q63_t) *px++ * (*py--); + sum += (q63_t)*px++ * (*py--); /* x[3] * y[srcBLen - 4] */ - sum += (q63_t) *px++ * (*py--); + sum += (q63_t)*px++ * (*py--); /* Decrement loop counter */ k--; @@ -190,17 +187,16 @@ void arm_conv_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum += (q63_t) *px++ * *py--; + sum += (q63_t)*px++ * *py--; /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q31_t) (sum >> 31); + *pOut++ = (q31_t)(sum >> 31); /* Update the inputA and inputB pointers for next MAC calculation */ py = pIn2 + count; @@ -220,7 +216,8 @@ void arm_conv_q31( /* sum = x[0] * y[srcBLen-1] + x[1] * y[srcBLen-2] +...+ x[srcBLen-1] * y[0] * sum = x[1] * y[srcBLen-1] + x[2] * y[srcBLen-2] +...+ x[srcBLen] * y[0] * .... - * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ x[srcALen-1] * y[0] + * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ + * x[srcALen-1] * y[0] */ /* Working pointer of inputA */ @@ -237,18 +234,16 @@ void arm_conv_q31( * Stage2 process * ------------------*/ - /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed. - * So, to loop unroll over blockSize2, - * srcBLen should be greater than or equal to 4 */ - if (srcBLen >= 4U) - { -#if defined (ARM_MATH_LOOPUNROLL) + /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are + * performed. So, to loop unroll over blockSize2, srcBLen should be greater + * than or equal to 4 */ + if (srcBLen >= 4U) { +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unroll by 3 */ blkCnt = blockSize2 / 3; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Set all accumulators to zero */ acc0 = 0; acc1 = 0; @@ -261,10 +256,10 @@ void arm_conv_q31( /* Apply loop unrolling and compute 3 MACs simultaneously. */ k = srcBLen / 3; - /* First part of the processing with loop unrolling. Compute 3 MACs at a time. + /* First part of the processing with loop unrolling. Compute 3 MACs at a + *time. ** a second loop below computes MACs for the remaining 1 to 2 samples. */ - do - { + do { /* Read y[srcBLen - 1] sample */ c0 = *(py); /* Read x[3] sample */ @@ -272,11 +267,11 @@ void arm_conv_q31( /* Perform the multiply-accumulate */ /* acc0 += x[0] * y[srcBLen - 1] */ - acc0 += ((q63_t) x0 * c0); + acc0 += ((q63_t)x0 * c0); /* acc1 += x[1] * y[srcBLen - 1] */ - acc1 += ((q63_t) x1 * c0); + acc1 += ((q63_t)x1 * c0); /* acc2 += x[2] * y[srcBLen - 1] */ - acc2 += ((q63_t) x2 * c0); + acc2 += ((q63_t)x2 * c0); /* Read y[srcBLen - 2] sample */ c0 = *(py - 1U); @@ -285,11 +280,11 @@ void arm_conv_q31( /* Perform the multiply-accumulate */ /* acc0 += x[1] * y[srcBLen - 2] */ - acc0 += ((q63_t) x1 * c0); + acc0 += ((q63_t)x1 * c0); /* acc1 += x[2] * y[srcBLen - 2] */ - acc1 += ((q63_t) x2 * c0); + acc1 += ((q63_t)x2 * c0); /* acc2 += x[3] * y[srcBLen - 2] */ - acc2 += ((q63_t) x0 * c0); + acc2 += ((q63_t)x0 * c0); /* Read y[srcBLen - 3] sample */ c0 = *(py - 2U); @@ -298,11 +293,11 @@ void arm_conv_q31( /* Perform the multiply-accumulate */ /* acc0 += x[2] * y[srcBLen - 3] */ - acc0 += ((q63_t) x2 * c0); + acc0 += ((q63_t)x2 * c0); /* acc1 += x[3] * y[srcBLen - 2] */ - acc1 += ((q63_t) x0 * c0); + acc1 += ((q63_t)x0 * c0); /* acc2 += x[4] * y[srcBLen - 2] */ - acc2 += ((q63_t) x1 * c0); + acc2 += ((q63_t)x1 * c0); /* update scratch pointers */ px += 3U; @@ -314,8 +309,7 @@ void arm_conv_q31( ** No loop unrolling is used. */ k = srcBLen - (3 * (srcBLen / 3)); - while (k > 0U) - { + while (k > 0U) { /* Read y[srcBLen - 5] sample */ c0 = *py--; /* Read x[7] sample */ @@ -323,11 +317,11 @@ void arm_conv_q31( /* Perform the multiply-accumulates */ /* acc0 += x[4] * y[srcBLen - 5] */ - acc0 += ((q63_t) x0 * c0); + acc0 += ((q63_t)x0 * c0); /* acc1 += x[5] * y[srcBLen - 5] */ - acc1 += ((q63_t) x1 * c0); + acc1 += ((q63_t)x1 * c0); /* acc2 += x[6] * y[srcBLen - 5] */ - acc2 += ((q63_t) x2 * c0); + acc2 += ((q63_t)x2 * c0); /* Reuse the present samples for the next MAC */ x0 = x1; @@ -338,9 +332,9 @@ void arm_conv_q31( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q31_t) (acc0 >> 31); - *pOut++ = (q31_t) (acc1 >> 31); - *pOut++ = (q31_t) (acc2 >> 31); + *pOut++ = (q31_t)(acc0 >> 31); + *pOut++ = (q31_t)(acc1 >> 31); + *pOut++ = (q31_t)(acc2 >> 31); /* Increment the pointer pIn1 index, count by 3 */ count += 3U; @@ -363,23 +357,21 @@ void arm_conv_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) - /* Loop unrolling: Compute 4 outputs at a time */ + /* Loop unrolling: Compute 4 outputs at a time */ k = srcBLen >> 2U; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulates */ - sum += (q63_t) *px++ * *py--; - sum += (q63_t) *px++ * *py--; - sum += (q63_t) *px++ * *py--; - sum += (q63_t) *px++ * *py--; + sum += (q63_t)*px++ * *py--; + sum += (q63_t)*px++ * *py--; + sum += (q63_t)*px++ * *py--; + sum += (q63_t)*px++ * *py--; /* Decrement loop counter */ k--; @@ -395,17 +387,16 @@ void arm_conv_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum += (q63_t) *px++ * *py--; + sum += (q63_t)*px++ * *py--; /* Decrement the loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q31_t) (sum >> 31); + *pOut++ = (q31_t)(sum >> 31); /* Increment MAC count */ count++; @@ -417,32 +408,28 @@ void arm_conv_q31( /* Decrement loop counter */ blkCnt--; } - } - else - { + } else { /* If the srcBLen is not a multiple of 4, * the blockSize2 loop cannot be unrolled by 4 */ blkCnt = blockSize2; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* srcBLen number of MACS should be performed */ k = srcBLen; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum += (q63_t) *px++ * *py--; + sum += (q63_t)*px++ * *py--; /* Decrement the loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q31_t) (sum >> 31); + *pOut++ = (q31_t)(sum >> 31); /* Increment MAC count */ count++; @@ -456,13 +443,14 @@ void arm_conv_q31( } } - /* -------------------------- * Initializations of stage3 * -------------------------*/ - /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * y[srcBLen-2] +...+ x[srcALen-1] * y[1] - * sum += x[srcALen-srcBLen+2] * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * y[2] + /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * + * y[srcBLen-2] +...+ x[srcALen-1] * y[1] sum += x[srcALen-srcBLen+2] * + * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * + * y[2] * .... * sum += x[srcALen-2] * y[srcBLen-1] + x[srcALen-1] * y[srcBLen-2] * sum += x[srcALen-1] * y[srcBLen-1] @@ -483,30 +471,28 @@ void arm_conv_q31( * Stage3 process * ------------------*/ - while (blockSize3 > 0U) - { + while (blockSize3 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = blockSize3 >> 2U; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ /* sum += x[srcALen - srcBLen + 1] * y[srcBLen - 1] */ - sum += (q63_t) *px++ * *py--; + sum += (q63_t)*px++ * *py--; /* sum += x[srcALen - srcBLen + 2] * y[srcBLen - 2] */ - sum += (q63_t) *px++ * *py--; + sum += (q63_t)*px++ * *py--; /* sum += x[srcALen - srcBLen + 3] * y[srcBLen - 3] */ - sum += (q63_t) *px++ * *py--; + sum += (q63_t)*px++ * *py--; /* sum += x[srcALen - srcBLen + 4] * y[srcBLen - 4] */ - sum += (q63_t) *px++ * *py--; + sum += (q63_t)*px++ * *py--; /* Decrement loop counter */ k--; @@ -522,18 +508,17 @@ void arm_conv_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ /* sum += x[srcALen-1] * y[srcBLen-1] */ - sum += (q63_t) *px++ * *py--; + sum += (q63_t)*px++ * *py--; /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q31_t) (sum >> 31); + *pOut++ = (q31_t)(sum >> 31); /* Update the inputA and inputB pointers for next MAC calculation */ px = ++pSrc1; @@ -544,36 +529,32 @@ void arm_conv_q31( } #else -/* alternate version for CM0_FAMILY */ + /* alternate version for CM0_FAMILY */ - const q31_t *pIn1 = pSrcA; /* InputA pointer */ - const q31_t *pIn2 = pSrcB; /* InputB pointer */ - q63_t sum; /* Accumulators */ - uint32_t i, j; /* Loop counters */ + const q31_t *pIn1 = pSrcA; /* InputA pointer */ + const q31_t *pIn2 = pSrcB; /* InputB pointer */ + q63_t sum; /* Accumulators */ + uint32_t i, j; /* Loop counters */ /* Loop to calculate convolution for output length number of times */ - for (i = 0U; i < (srcALen + srcBLen - 1U); i++) - { + for (i = 0U; i < (srcALen + srcBLen - 1U); i++) { /* Initialize sum with zero to carry out MAC operations */ sum = 0; /* Loop to perform MAC operations according to convolution equation */ - for (j = 0U; j <= i; j++) - { + for (j = 0U; j <= i; j++) { /* Check the array limitations */ - if (((i - j) < srcBLen) && (j < srcALen)) - { + if (((i - j) < srcBLen) && (j < srcALen)) { /* z[i] += x[i-j] * y[j] */ - sum += ((q63_t) pIn1[j] * pIn2[i - j]); + sum += ((q63_t)pIn1[j] * pIn2[i - j]); } } /* Store the output in the destination buffer */ - pDst[i] = (q31_t) (sum >> 31U); + pDst[i] = (q31_t)(sum >> 31U); } #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */ - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_q7.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_q7.c index bdd1cab..0360ce4 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_q7.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_conv_q7.c @@ -43,60 +43,57 @@ @param[in] srcALen length of the first input sequence @param[in] pSrcB points to the second input sequence @param[in] srcBLen length of the second input sequence - @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1. + @param[out] pDst points to the location where the output result is + written. Length srcALen+srcBLen-1. @return none @par Scaling and Overflow Behavior - The function is implemented using a 32-bit internal accumulator. - Both the inputs are represented in 1.7 format and multiplications yield a 2.14 result. - The 2.14 intermediate results are accumulated in a 32-bit accumulator in 18.14 format. - This approach provides 17 guard bits and there is no risk of overflow as long as max(srcALen, srcBLen)<131072. - The 18.14 result is then truncated to 18.7 format by discarding the low 7 bits and then saturated to 1.7 format. + The function is implemented using a 32-bit internal + accumulator. Both the inputs are represented in 1.7 format and multiplications + yield a 2.14 result. The 2.14 intermediate results are accumulated in a 32-bit + accumulator in 18.14 format. This approach provides 17 guard bits and there is + no risk of overflow as long as max(srcALen, srcBLen)<131072. + The 18.14 result is then truncated to 18.7 format by + discarding the low 7 bits and then saturated to 1.7 format. @remark - Refer to \ref arm_conv_opt_q7() for a faster implementation of this function. + Refer to \ref arm_conv_opt_q7() for a faster implementation + of this function. */ -void arm_conv_q7( - const q7_t * pSrcA, - uint32_t srcALen, - const q7_t * pSrcB, - uint32_t srcBLen, - q7_t * pDst) -{ +void arm_conv_q7(const q7_t *pSrcA, uint32_t srcALen, const q7_t *pSrcB, + uint32_t srcBLen, q7_t *pDst) { #if (1) -//#if !defined(ARM_MATH_CM0_FAMILY) + //#if !defined(ARM_MATH_CM0_FAMILY) - const q7_t *pIn1; /* InputA pointer */ - const q7_t *pIn2; /* InputB pointer */ - q7_t *pOut = pDst; /* Output pointer */ - const q7_t *px; /* Intermediate inputA pointer */ - const q7_t *py; /* Intermediate inputB pointer */ - const q7_t *pSrc1, *pSrc2; /* Intermediate pointers */ - q31_t sum; /* Accumulators */ - uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ - uint32_t j, k, count, blkCnt; /* Loop counters */ + const q7_t *pIn1; /* InputA pointer */ + const q7_t *pIn2; /* InputB pointer */ + q7_t *pOut = pDst; /* Output pointer */ + const q7_t *px; /* Intermediate inputA pointer */ + const q7_t *py; /* Intermediate inputB pointer */ + const q7_t *pSrc1, *pSrc2; /* Intermediate pointers */ + q31_t sum; /* Accumulators */ + uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */ + uint32_t j, k, count, blkCnt; /* Loop counters */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t acc0, acc1, acc2, acc3; /* Accumulators */ - q31_t input1, input2; /* Temporary input variables */ - q15_t in1, in2; /* Temporary input variables */ - q7_t x0, x1, x2, x3, c0, c1; /* Temporary variables to hold state and coefficient values */ +#if defined(ARM_MATH_LOOPUNROLL) + q31_t acc0, acc1, acc2, acc3; /* Accumulators */ + q31_t input1, input2; /* Temporary input variables */ + q15_t in1, in2; /* Temporary input variables */ + q7_t x0, x1, x2, x3, c0, + c1; /* Temporary variables to hold state and coefficient values */ #endif /* The algorithm implementation is based on the lengths of the inputs. */ /* srcB is always made to slide across srcA. */ /* So srcBLen is always considered as shorter or equal to srcALen */ - if (srcALen >= srcBLen) - { + if (srcALen >= srcBLen) { /* Initialization of inputA pointer */ pIn1 = pSrcA; /* Initialization of inputB pointer */ pIn2 = pSrcB; - } - else - { + } else { /* Initialization of inputA pointer */ pIn1 = pSrcB; @@ -109,14 +106,15 @@ void arm_conv_q7( srcALen = j; } - /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ x[n-N+1] * y[N -1] */ + /* conv(x,y) at n = x[n] * y[0] + x[n-1] * y[1] + x[n-2] * y[2] + ...+ + * x[n-N+1] * y[N -1] */ /* The function is internally - * divided into three stages according to the number of multiplications that has to be - * taken place between inputA samples and inputB samples. In the first stage of the - * algorithm, the multiplications increase by one for every iteration. - * In the second stage of the algorithm, srcBLen number of multiplications are done. - * In the third stage of the algorithm, the multiplications decrease by one - * for every iteration. */ + * divided into three stages according to the number of multiplications that + * has to be taken place between inputA samples and inputB samples. In the + * first stage of the algorithm, the multiplications increase by one for every + * iteration. In the second stage of the algorithm, srcBLen number of + * multiplications are done. In the third stage of the algorithm, the + * multiplications decrease by one for every iteration. */ /* The algorithm is implemented in three stages. The loop counters of each stage is initiated here. */ @@ -131,7 +129,8 @@ void arm_conv_q7( /* sum = x[0] * y[0] * sum = x[0] * y[1] + x[1] * y[0] * .... - * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * y[0] + * sum = x[0] * y[srcBlen - 1] + x[1] * y[srcBlen - 2] +...+ x[srcBLen - 1] * + * y[0] */ /* In this stage the MAC operations are increased by 1 for every iteration. @@ -144,47 +143,44 @@ void arm_conv_q7( /* Working pointer of inputB */ py = pIn2; - /* ------------------------ * Stage1 process * ----------------------*/ /* The first stage starts here */ - while (blockSize1 > 0U) - { + while (blockSize1 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = count >> 2U; - while (k > 0U) - { + while (k > 0U) { /* x[0] , x[1] */ - in1 = (q15_t) *px++; - in2 = (q15_t) *px++; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + in1 = (q15_t)*px++; + in2 = (q15_t)*px++; + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* y[srcBLen - 1] , y[srcBLen - 2] */ - in1 = (q15_t) *py--; - in2 = (q15_t) *py--; - input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + in1 = (q15_t)*py--; + in2 = (q15_t)*py--; + input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* x[0] * y[srcBLen - 1] */ /* x[1] * y[srcBLen - 2] */ sum = __SMLAD(input1, input2, sum); /* x[2] , x[3] */ - in1 = (q15_t) *px++; - in2 = (q15_t) *px++; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + in1 = (q15_t)*px++; + in2 = (q15_t)*px++; + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* y[srcBLen - 3] , y[srcBLen - 4] */ - in1 = (q15_t) *py--; - in2 = (q15_t) *py--; - input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + in1 = (q15_t)*py--; + in2 = (q15_t)*py--; + input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* x[2] * y[srcBLen - 3] */ /* x[3] * y[srcBLen - 4] */ @@ -204,17 +200,16 @@ void arm_conv_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum += ((q15_t) *px++ * *py--); + sum += ((q15_t)*px++ * *py--); /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q7_t) (__SSAT(sum >> 7U, 8)); + *pOut++ = (q7_t)(__SSAT(sum >> 7U, 8)); /* Update the inputA and inputB pointers for next MAC calculation */ py = pIn2 + count; @@ -234,7 +229,8 @@ void arm_conv_q7( /* sum = x[0] * y[srcBLen-1] + x[1] * y[srcBLen-2] +...+ x[srcBLen-1] * y[0] * sum = x[1] * y[srcBLen-1] + x[2] * y[srcBLen-2] +...+ x[srcBLen] * y[0] * .... - * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ x[srcALen-1] * y[0] + * sum = x[srcALen-srcBLen-2] * y[srcBLen-1] + x[srcALen] * y[srcBLen-2] +...+ + * x[srcALen-1] * y[0] */ /* Working pointer of inputA */ @@ -251,18 +247,16 @@ void arm_conv_q7( * Stage2 process * ------------------*/ - /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed. - * So, to loop unroll over blockSize2, - * srcBLen should be greater than or equal to 4 */ - if (srcBLen >= 4U) - { -#if defined (ARM_MATH_LOOPUNROLL) + /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are + * performed. So, to loop unroll over blockSize2, srcBLen should be greater + * than or equal to 4 */ + if (srcBLen >= 4U) { +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize2 >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Set all accumulators to zero */ acc0 = 0; acc1 = 0; @@ -277,10 +271,10 @@ void arm_conv_q7( /* Apply loop unrolling and compute 4 MACs simultaneously. */ k = srcBLen >> 2U; - /* First part of the processing with loop unrolling. Compute 4 MACs at a time. + /* First part of the processing with loop unrolling. Compute 4 MACs at a + *time. ** a second loop below computes MACs for the remaining 1 to 3 samples. */ - do - { + do { /* Read y[srcBLen - 1] sample */ c0 = *py--; /* Read y[srcBLen - 2] sample */ @@ -290,34 +284,34 @@ void arm_conv_q7( x3 = *px++; /* x[0] and x[1] are packed */ - in1 = (q15_t) x0; - in2 = (q15_t) x1; + in1 = (q15_t)x0; + in2 = (q15_t)x1; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* y[srcBLen - 1] and y[srcBLen - 2] are packed */ - in1 = (q15_t) c0; - in2 = (q15_t) c1; + in1 = (q15_t)c0; + in2 = (q15_t)c1; - input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* acc0 += x[0] * y[srcBLen - 1] + x[1] * y[srcBLen - 2] */ acc0 = __SMLAD(input1, input2, acc0); /* x[1] and x[2] are packed */ - in1 = (q15_t) x1; - in2 = (q15_t) x2; + in1 = (q15_t)x1; + in2 = (q15_t)x2; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* acc1 += x[1] * y[srcBLen - 1] + x[2] * y[srcBLen - 2] */ acc1 = __SMLAD(input1, input2, acc1); /* x[2] and x[3] are packed */ - in1 = (q15_t) x2; - in2 = (q15_t) x3; + in1 = (q15_t)x2; + in2 = (q15_t)x3; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* acc2 += x[2] * y[srcBLen - 1] + x[3] * y[srcBLen - 2] */ acc2 = __SMLAD(input1, input2, acc2); @@ -326,10 +320,10 @@ void arm_conv_q7( x0 = *px++; /* x[3] and x[4] are packed */ - in1 = (q15_t) x3; - in2 = (q15_t) x0; + in1 = (q15_t)x3; + in2 = (q15_t)x0; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* acc3 += x[3] * y[srcBLen - 1] + x[4] * y[srcBLen - 2] */ acc3 = __SMLAD(input1, input2, acc3); @@ -343,34 +337,34 @@ void arm_conv_q7( x1 = *px++; /* x[2] and x[3] are packed */ - in1 = (q15_t) x2; - in2 = (q15_t) x3; + in1 = (q15_t)x2; + in2 = (q15_t)x3; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* y[srcBLen - 3] and y[srcBLen - 4] are packed */ - in1 = (q15_t) c0; - in2 = (q15_t) c1; + in1 = (q15_t)c0; + in2 = (q15_t)c1; - input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* acc0 += x[2] * y[srcBLen - 3] + x[3] * y[srcBLen - 4] */ acc0 = __SMLAD(input1, input2, acc0); /* x[3] and x[4] are packed */ - in1 = (q15_t) x3; - in2 = (q15_t) x0; + in1 = (q15_t)x3; + in2 = (q15_t)x0; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* acc1 += x[3] * y[srcBLen - 3] + x[4] * y[srcBLen - 4] */ acc1 = __SMLAD(input1, input2, acc1); /* x[4] and x[5] are packed */ - in1 = (q15_t) x0; - in2 = (q15_t) x1; + in1 = (q15_t)x0; + in2 = (q15_t)x1; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* acc2 += x[4] * y[srcBLen - 3] + x[5] * y[srcBLen - 4] */ acc2 = __SMLAD(input1, input2, acc2); @@ -379,10 +373,10 @@ void arm_conv_q7( x2 = *px++; /* x[5] and x[6] are packed */ - in1 = (q15_t) x1; - in2 = (q15_t) x2; + in1 = (q15_t)x1; + in2 = (q15_t)x2; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* acc3 += x[5] * y[srcBLen - 3] + x[6] * y[srcBLen - 4] */ acc3 = __SMLAD(input1, input2, acc3); @@ -393,8 +387,7 @@ void arm_conv_q7( ** No loop unrolling is used. */ k = srcBLen % 0x4U; - while (k > 0U) - { + while (k > 0U) { /* Read y[srcBLen - 5] sample */ c0 = *py--; /* Read x[7] sample */ @@ -402,13 +395,13 @@ void arm_conv_q7( /* Perform the multiply-accumulates */ /* acc0 += x[4] * y[srcBLen - 5] */ - acc0 += ((q15_t) x0 * c0); + acc0 += ((q15_t)x0 * c0); /* acc1 += x[5] * y[srcBLen - 5] */ - acc1 += ((q15_t) x1 * c0); + acc1 += ((q15_t)x1 * c0); /* acc2 += x[6] * y[srcBLen - 5] */ - acc2 += ((q15_t) x2 * c0); + acc2 += ((q15_t)x2 * c0); /* acc3 += x[7] * y[srcBLen - 5] */ - acc3 += ((q15_t) x3 * c0); + acc3 += ((q15_t)x3 * c0); /* Reuse the present samples for the next MAC */ x0 = x1; @@ -420,10 +413,10 @@ void arm_conv_q7( } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q7_t) (__SSAT(acc0 >> 7U, 8)); - *pOut++ = (q7_t) (__SSAT(acc1 >> 7U, 8)); - *pOut++ = (q7_t) (__SSAT(acc2 >> 7U, 8)); - *pOut++ = (q7_t) (__SSAT(acc3 >> 7U, 8)); + *pOut++ = (q7_t)(__SSAT(acc0 >> 7U, 8)); + *pOut++ = (q7_t)(__SSAT(acc1 >> 7U, 8)); + *pOut++ = (q7_t)(__SSAT(acc2 >> 7U, 8)); + *pOut++ = (q7_t)(__SSAT(acc3 >> 7U, 8)); /* Increment the pointer pIn1 index, count by 4 */ count += 4U; @@ -446,41 +439,39 @@ void arm_conv_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) - /* Loop unrolling: Compute 4 outputs at a time */ + /* Loop unrolling: Compute 4 outputs at a time */ k = srcBLen >> 2U; - while (k > 0U) - { + while (k > 0U) { /* Reading two inputs of SrcA buffer and packing */ - in1 = (q15_t) *px++; - in2 = (q15_t) *px++; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + in1 = (q15_t)*px++; + in2 = (q15_t)*px++; + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* Reading two inputs of SrcB buffer and packing */ - in1 = (q15_t) *py--; - in2 = (q15_t) *py--; - input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + in1 = (q15_t)*py--; + in2 = (q15_t)*py--; + input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* Perform the multiply-accumulate */ sum = __SMLAD(input1, input2, sum); /* Reading two inputs of SrcA buffer and packing */ - in1 = (q15_t) *px++; - in2 = (q15_t) *px++; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + in1 = (q15_t)*px++; + in2 = (q15_t)*px++; + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* Reading two inputs of SrcB buffer and packing */ - in1 = (q15_t) *py--; - in2 = (q15_t) *py--; - input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + in1 = (q15_t)*py--; + in2 = (q15_t)*py--; + input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* Perform the multiply-accumulate */ sum = __SMLAD(input1, input2, sum); @@ -499,17 +490,16 @@ void arm_conv_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum += ((q15_t) *px++ * *py--); + sum += ((q15_t)*px++ * *py--); /* Decrement the loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q7_t) (__SSAT(sum >> 7U, 8)); + *pOut++ = (q7_t)(__SSAT(sum >> 7U, 8)); /* Increment the pointer pIn1 index, count by 1 */ count++; @@ -521,32 +511,28 @@ void arm_conv_q7( /* Decrement the loop counter */ blkCnt--; } - } - else - { + } else { /* If the srcBLen is not a multiple of 4, * the blockSize2 loop cannot be unrolled by 4 */ blkCnt = blockSize2; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; /* srcBLen number of MACS should be performed */ k = srcBLen; - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ - sum += ((q15_t) *px++ * *py--); + sum += ((q15_t)*px++ * *py--); /* Decrement the loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q7_t) (__SSAT(sum >> 7U, 8)); + *pOut++ = (q7_t)(__SSAT(sum >> 7U, 8)); /* Increment the MAC count */ count++; @@ -560,13 +546,14 @@ void arm_conv_q7( } } - /* -------------------------- * Initializations of stage3 * -------------------------*/ - /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * y[srcBLen-2] +...+ x[srcALen-1] * y[1] - * sum += x[srcALen-srcBLen+2] * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * y[2] + /* sum += x[srcALen-srcBLen+1] * y[srcBLen-1] + x[srcALen-srcBLen+2] * + * y[srcBLen-2] +...+ x[srcALen-1] * y[1] sum += x[srcALen-srcBLen+2] * + * y[srcBLen-1] + x[srcALen-srcBLen+3] * y[srcBLen-2] +...+ x[srcALen-1] * + * y[2] * .... * sum += x[srcALen-2] * y[srcBLen-1] + x[srcALen-1] * y[srcBLen-2] * sum += x[srcALen-1] * y[srcBLen-1] @@ -587,41 +574,43 @@ void arm_conv_q7( * Stage3 process * ------------------*/ - while (blockSize3 > 0U) - { + while (blockSize3 > 0U) { /* Accumulator is made zero for every iteration */ sum = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ k = blockSize3 >> 2U; - while (k > 0U) - { - /* Reading two inputs, x[srcALen - srcBLen + 1] and x[srcALen - srcBLen + 2] of SrcA buffer and packing */ - in1 = (q15_t) *px++; - in2 = (q15_t) *px++; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + while (k > 0U) { + /* Reading two inputs, x[srcALen - srcBLen + 1] and x[srcALen - srcBLen + + * 2] of SrcA buffer and packing */ + in1 = (q15_t)*px++; + in2 = (q15_t)*px++; + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); - /* Reading two inputs, y[srcBLen - 1] and y[srcBLen - 2] of SrcB buffer and packing */ - in1 = (q15_t) *py--; - in2 = (q15_t) *py--; - input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + /* Reading two inputs, y[srcBLen - 1] and y[srcBLen - 2] of SrcB buffer + * and packing */ + in1 = (q15_t)*py--; + in2 = (q15_t)*py--; + input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* sum += x[srcALen - srcBLen + 1] * y[srcBLen - 1] */ /* sum += x[srcALen - srcBLen + 2] * y[srcBLen - 2] */ sum = __SMLAD(input1, input2, sum); - /* Reading two inputs, x[srcALen - srcBLen + 3] and x[srcALen - srcBLen + 4] of SrcA buffer and packing */ - in1 = (q15_t) *px++; - in2 = (q15_t) *px++; - input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + /* Reading two inputs, x[srcALen - srcBLen + 3] and x[srcALen - srcBLen + + * 4] of SrcA buffer and packing */ + in1 = (q15_t)*px++; + in2 = (q15_t)*px++; + input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); - /* Reading two inputs, y[srcBLen - 3] and y[srcBLen - 4] of SrcB buffer and packing */ - in1 = (q15_t) *py--; - in2 = (q15_t) *py--; - input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U); + /* Reading two inputs, y[srcBLen - 3] and y[srcBLen - 4] of SrcB buffer + * and packing */ + in1 = (q15_t)*py--; + in2 = (q15_t)*py--; + input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U); /* sum += x[srcALen - srcBLen + 3] * y[srcBLen - 3] */ /* sum += x[srcALen - srcBLen + 4] * y[srcBLen - 4] */ @@ -641,18 +630,17 @@ void arm_conv_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (k > 0U) - { + while (k > 0U) { /* Perform the multiply-accumulate */ /* sum += x[srcALen-1] * y[srcBLen-1] */ - sum += ((q15_t) *px++ * *py--); + sum += ((q15_t)*px++ * *py--); /* Decrement loop counter */ k--; } /* Store the result in the accumulator in the destination buffer. */ - *pOut++ = (q7_t) (__SSAT(sum >> 7U, 8)); + *pOut++ = (q7_t)(__SSAT(sum >> 7U, 8)); /* Update the inputA and inputB pointers for next MAC calculation */ px = ++pSrc1; @@ -663,36 +651,32 @@ void arm_conv_q7( } #else -/* alternate version for CM0_FAMILY */ + /* alternate version for CM0_FAMILY */ - const q7_t *pIn1 = pSrcA; /* InputA pointer */ - const q7_t *pIn2 = pSrcB; /* InputB pointer */ - q31_t sum; /* Accumulator */ - uint32_t i, j; /* Loop counters */ + const q7_t *pIn1 = pSrcA; /* InputA pointer */ + const q7_t *pIn2 = pSrcB; /* InputB pointer */ + q31_t sum; /* Accumulator */ + uint32_t i, j; /* Loop counters */ /* Loop to calculate convolution for output length number of times */ - for (i = 0U; i < (srcALen + srcBLen - 1U); i++) - { + for (i = 0U; i < (srcALen + srcBLen - 1U); i++) { /* Initialize sum with zero to carry out MAC operations */ sum = 0; /* Loop to perform MAC operations according to convolution equation */ - for (j = 0U; j <= i; j++) - { + for (j = 0U; j <= i; j++) { /* Check the array limitations */ - if (((i - j) < srcBLen) && (j < srcALen)) - { + if (((i - j) < srcBLen) && (j < srcALen)) { /* z[i] += x[i-j] * y[j] */ - sum += ((q15_t) pIn1[j] * pIn2[i - j]); + sum += ((q15_t)pIn1[j] * pIn2[i - j]); } } /* Store the output in the destination buffer */ - pDst[i] = (q7_t) __SSAT((sum >> 7U), 8U); + pDst[i] = (q7_t)__SSAT((sum >> 7U), 8U); } #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */ - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_f32.c index 4438c77..ae01184 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_f32.c @@ -37,17 +37,17 @@ Correlation is a mathematical operation that is similar to convolution. As with convolution, correlation uses two signals to produce a third signal. - The underlying algorithms in correlation and convolution are identical except that one of the inputs is flipped in convolution. - Correlation is commonly used to measure the similarity between two signals. - It has applications in pattern recognition, cryptanalysis, and searching. - The CMSIS library provides correlation functions for Q7, Q15, Q31 and floating-point data types. - Fast versions of the Q15 and Q31 functions are also provided. + The underlying algorithms in correlation and convolution are identical except + that one of the inputs is flipped in convolution. Correlation is commonly used + to measure the similarity between two signals. It has applications in pattern + recognition, cryptanalysis, and searching. The CMSIS library provides + correlation functions for Q7, Q15, Q31 and floating-point data types. Fast + versions of the Q15 and Q31 functions are also provided. @par Algorithm - Let a[n] and b[n] be sequences of length srcALen and srcBLen samples respectively. - The convolution of the two signals is denoted by -
-      c[n] = a[n] * b[n]
+                   Let a[n] and b[n] be sequences of
+  length srcALen and srcBLen samples respectively. The
+  convolution of the two signals is denoted by 
 c[n] = a[n] * b[n]
   
In correlation, one of the signals is flipped in time
@@ -57,25 +57,35 @@
                    and this is mathematically defined as
                    \image html CorrelateEquation.gif
   @par
-                   The pSrcA points to the first input vector of length srcALen and pSrcB points to the second input vector of length srcBLen.
-                   The result c[n] is of length 2 * max(srcALen, srcBLen) - 1 and is defined over the interval n=0, 1, 2, ..., (2 * max(srcALen, srcBLen) - 2).
-                   The output result is written to pDst and the calling function must allocate 2 * max(srcALen, srcBLen) - 1 words for the result.
+                   The pSrcA points to the first input vector of
+  length srcALen and pSrcB points to the second input
+  vector of length srcBLen. The result c[n] is of
+  length 2 * max(srcALen, srcBLen) - 1 and is defined over the
+  interval n=0, 1, 2, ..., (2 * max(srcALen, srcBLen) - 2). The
+  output result is written to pDst and the calling function must
+  allocate 2 * max(srcALen, srcBLen) - 1 words for the result.
 
   @note
-                   The pDst should be initialized to all zeros before being used.
+                   The pDst should be initialized to all zeros
+  before being used.
 
   @par           Fixed-Point Behavior
-                   Correlation requires summing up a large number of intermediate products.
-                   As such, the Q7, Q15, and Q31 functions run a risk of overflow and saturation.
-                   Refer to the function specific documentation below for further details of the particular algorithm used.
+                   Correlation requires summing up a large number of
+  intermediate products. As such, the Q7, Q15, and Q31 functions run a risk of
+  overflow and saturation. Refer to the function specific documentation below
+  for further details of the particular algorithm used.
 
   @par           Fast Versions
-                   Fast versions are supported for Q31 and Q15.  Cycles for Fast versions are less compared to Q31 and Q15 of correlate and the design requires
-                   the input signals should be scaled down to avoid intermediate overflows.
+                   Fast versions are supported for Q31 and Q15.  Cycles for Fast
+  versions are less compared to Q31 and Q15 of correlate and the design requires
+                   the input signals should be scaled down to avoid intermediate
+  overflows.
 
   @par           Opt Versions
-                   Opt versions are supported for Q15 and Q7.  Design uses internal scratch buffer for getting good optimisation.
-                   These versions are optimised in cycles and consumes more memory (Scratch memory) compared to Q15 and Q7 versions of correlate
+                   Opt versions are supported for Q15 and Q7.  Design uses
+  internal scratch buffer for getting good optimisation. These versions are
+  optimised in cycles and consumes more memory (Scratch memory) compared to Q15
+  and Q7 versions of correlate
  */
 
 /**
@@ -89,53 +99,55 @@
   @param[in]     srcALen    length of the first input sequence
   @param[in]     pSrcB      points to the second input sequence
   @param[in]     srcBLen    length of the second input sequence
-  @param[out]    pDst       points to the location where the output result is written.  Length 2 * max(srcALen, srcBLen) - 1.
+  @param[out]    pDst       points to the location where the output result is
+  written.  Length 2 * max(srcALen, srcBLen) - 1.
   @return        none
  */
 
-void arm_correlate_f32(
-  const float32_t * pSrcA,
-        uint32_t srcALen,
-  const float32_t * pSrcB,
-        uint32_t srcBLen,
-        float32_t * pDst)
-{
+void arm_correlate_f32(const float32_t *pSrcA, uint32_t srcALen,
+                       const float32_t *pSrcB, uint32_t srcBLen,
+                       float32_t *pDst) {
 
 #if (1)
-//#if !defined(ARM_MATH_CM0_FAMILY)
+  //#if !defined(ARM_MATH_CM0_FAMILY)
 
-  const float32_t *pIn1;                               /* InputA pointer */
-  const float32_t *pIn2;                               /* InputB pointer */
-        float32_t *pOut = pDst;                        /* Output pointer */
-  const float32_t *px;                                 /* Intermediate inputA pointer */
-  const float32_t *py;                                 /* Intermediate inputB pointer */
-  const float32_t *pSrc1;                              /* Intermediate pointers */
-        float32_t sum;                                 /* Accumulators */
-        uint32_t blockSize1, blockSize2, blockSize3;   /* Loop counters */
-        uint32_t j, k, count, blkCnt;                  /* Loop counters */
-        uint32_t outBlockSize;                         /* Loop counter */
-        int32_t inc = 1;                               /* Destination address modifier */
+  const float32_t *pIn1;                       /* InputA pointer */
+  const float32_t *pIn2;                       /* InputB pointer */
+  float32_t *pOut = pDst;                      /* Output pointer */
+  const float32_t *px;                         /* Intermediate inputA pointer */
+  const float32_t *py;                         /* Intermediate inputB pointer */
+  const float32_t *pSrc1;                      /* Intermediate pointers */
+  float32_t sum;                               /* Accumulators */
+  uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */
+  uint32_t j, k, count, blkCnt;                /* Loop counters */
+  uint32_t outBlockSize;                       /* Loop counter */
+  int32_t inc = 1; /* Destination address modifier */
 
-#if defined (ARM_MATH_LOOPUNROLL)
-        float32_t acc0, acc1, acc2, acc3;              /* Accumulators */
-        float32_t x0, x1, x2, x3, c0;                  /* Temporary variables for holding input and coefficient values */
+#if defined(ARM_MATH_LOOPUNROLL)
+  float32_t acc0, acc1, acc2, acc3; /* Accumulators */
+  float32_t x0, x1, x2, x3,
+      c0; /* Temporary variables for holding input and coefficient values */
 #endif
 
   /* The algorithm implementation is based on the lengths of the inputs. */
   /* srcB is always made to slide across srcA. */
   /* So srcBLen is always considered as shorter or equal to srcALen */
   /* But CORR(x, y) is reverse of CORR(y, x) */
-  /* So, when srcBLen > srcALen, output pointer is made to point to the end of the output buffer */
+  /* So, when srcBLen > srcALen, output pointer is made to point to the end of
+   * the output buffer */
   /* and the destination pointer modifier, inc is set to -1 */
-  /* If srcALen > srcBLen, zero pad has to be done to srcB to make the two inputs of same length */
+  /* If srcALen > srcBLen, zero pad has to be done to srcB to make the two
+   * inputs of same length */
   /* But to improve the performance,
-   * we assume zeroes in the output instead of zero padding either of the the inputs*/
+   * we assume zeroes in the output instead of zero padding either of the the
+   * inputs*/
   /* If srcALen > srcBLen,
-   * (srcALen - srcBLen) zeroes has to included in the starting of the output buffer */
+   * (srcALen - srcBLen) zeroes has to included in the starting of the output
+   * buffer */
   /* If srcALen < srcBLen,
-   * (srcALen - srcBLen) zeroes has to included in the ending of the output buffer */
-  if (srcALen >= srcBLen)
-  {
+   * (srcALen - srcBLen) zeroes has to included in the ending of the output
+   * buffer */
+  if (srcALen >= srcBLen) {
     /* Initialization of inputA pointer */
     pIn1 = pSrcA;
 
@@ -154,7 +166,7 @@ void arm_correlate_f32(
     /* Updating the pointer position to non zero value */
     pOut += j;
 
-    //while (j > 0U)
+    // while (j > 0U)
     //{
     //  /* Zero is stored in the destination buffer */
     //  *pOut++ = 0.0f;
@@ -163,9 +175,7 @@ void arm_correlate_f32(
     //  j--;
     //}
 
-  }
-  else
-  {
+  } else {
     /* Initialization of inputA pointer */
     pIn1 = pSrcB;
 
@@ -183,16 +193,15 @@ void arm_correlate_f32(
 
     /* Destination address modifier is set to -1 */
     inc = -1;
-
   }
 
   /* The function is internally
-   * divided into three stages according to the number of multiplications that has to be
-   * taken place between inputA samples and inputB samples. In the first stage of the
-   * algorithm, the multiplications increase by one for every iteration.
-   * In the second stage of the algorithm, srcBLen number of multiplications are done.
-   * In the third stage of the algorithm, the multiplications decrease by one
-   * for every iteration. */
+   * divided into three stages according to the number of multiplications that
+   * has to be taken place between inputA samples and inputB samples. In the
+   * first stage of the algorithm, the multiplications increase by one for every
+   * iteration. In the second stage of the algorithm, srcBLen number of
+   * multiplications are done. In the third stage of the algorithm, the
+   * multiplications decrease by one for every iteration. */
 
   /* The algorithm is implemented in three stages.
      The loop counters of each stage is initiated here. */
@@ -226,18 +235,16 @@ void arm_correlate_f32(
    * ----------------------*/
 
   /* The first stage starts here */
-  while (blockSize1 > 0U)
-  {
+  while (blockSize1 > 0U) {
     /* Accumulator is made zero for every iteration */
     sum = 0.0f;
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
     /* Loop unrolling: Compute 4 outputs at a time */
     k = count >> 2U;
 
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* x[0] * y[srcBLen - 4] */
       sum += *px++ * *py++;
 
@@ -264,8 +271,7 @@ void arm_correlate_f32(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* Perform the multiply-accumulate */
       /* x[0] * y[srcBLen - 1] */
       sum += *px++ * *py++;
@@ -297,7 +303,8 @@ void arm_correlate_f32(
   /* sum = x[0] * y[0] + x[1] * y[1] +...+ x[srcBLen-1] * y[srcBLen-1]
    * sum = x[1] * y[0] + x[2] * y[1] +...+ x[srcBLen]   * y[srcBLen-1]
    * ....
-   * sum = x[srcALen-srcBLen-2] * y[0] + x[srcALen-srcBLen-1] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
+   * sum = x[srcALen-srcBLen-2] * y[0] + x[srcALen-srcBLen-1] * y[1] +...+
+   * x[srcALen-1] * y[srcBLen-1]
    */
 
   /* Working pointer of inputA */
@@ -313,18 +320,16 @@ void arm_correlate_f32(
    * Stage2 process
    * ------------------*/
 
-  /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed.
-   * So, to loop unroll over blockSize2,
-   * srcBLen should be greater than or equal to 4 */
-  if (srcBLen >= 4U)
-  {
-#if defined (ARM_MATH_LOOPUNROLL)
+  /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are
+   * performed. So, to loop unroll over blockSize2, srcBLen should be greater
+   * than or equal to 4 */
+  if (srcBLen >= 4U) {
+#if defined(ARM_MATH_LOOPUNROLL)
 
     /* Loop unrolling: Compute 4 outputs at a time */
     blkCnt = blockSize2 >> 2U;
 
-    while (blkCnt > 0U)
-    {
+    while (blkCnt > 0U) {
       /* Set all accumulators to zero */
       acc0 = 0.0f;
       acc1 = 0.0f;
@@ -339,10 +344,10 @@ void arm_correlate_f32(
       /* Apply loop unrolling and compute 4 MACs simultaneously. */
       k = srcBLen >> 2U;
 
-      /* First part of the processing with loop unrolling.  Compute 4 MACs at a time.
+      /* First part of the processing with loop unrolling.  Compute 4 MACs at a
+       *time.
        ** a second loop below computes MACs for the remaining 1 to 3 samples. */
-      do
-      {
+      do {
         /* Read y[0] sample */
         c0 = *(py++);
         /* Read x[3] sample */
@@ -409,8 +414,7 @@ void arm_correlate_f32(
        ** No loop unrolling is used. */
       k = srcBLen % 0x4U;
 
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Read y[4] sample */
         c0 = *(py++);
         /* Read x[7] sample */
@@ -437,7 +441,8 @@ void arm_correlate_f32(
 
       /* Store the result in the accumulator in the destination buffer. */
       *pOut = acc0;
-      /* Destination pointer is updated according to the address modifier, inc */
+      /* Destination pointer is updated according to the address modifier, inc
+       */
       pOut += inc;
 
       *pOut = acc1;
@@ -470,18 +475,16 @@ void arm_correlate_f32(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-    while (blkCnt > 0U)
-    {
+    while (blkCnt > 0U) {
       /* Accumulator is made zero for every iteration */
       sum = 0.0f;
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
-    /* Loop unrolling: Compute 4 outputs at a time */
+      /* Loop unrolling: Compute 4 outputs at a time */
       k = srcBLen >> 2U;
 
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Perform the multiply-accumulate */
         sum += *px++ * *py++;
         sum += *px++ * *py++;
@@ -502,8 +505,7 @@ void arm_correlate_f32(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Perform the multiply-accumulate */
         sum += *px++ * *py++;
 
@@ -513,7 +515,8 @@ void arm_correlate_f32(
 
       /* Store the result in the accumulator in the destination buffer. */
       *pOut = sum;
-      /* Destination pointer is updated according to the address modifier, inc */
+      /* Destination pointer is updated according to the address modifier, inc
+       */
       pOut += inc;
 
       /* Increment the pointer pIn1 index, count by 1 */
@@ -526,23 +529,19 @@ void arm_correlate_f32(
       /* Decrement the loop counter */
       blkCnt--;
     }
-  }
-  else
-  {
+  } else {
     /* If the srcBLen is not a multiple of 4,
      * the blockSize2 loop cannot be unrolled by 4 */
     blkCnt = blockSize2;
 
-    while (blkCnt > 0U)
-    {
+    while (blkCnt > 0U) {
       /* Accumulator is made zero for every iteration */
       sum = 0.0f;
 
       /* Loop over srcBLen */
       k = srcBLen;
 
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Perform the multiply-accumulate */
         sum += *px++ * *py++;
 
@@ -552,7 +551,8 @@ void arm_correlate_f32(
 
       /* Store the result in the accumulator in the destination buffer. */
       *pOut = sum;
-      /* Destination pointer is updated according to the address modifier, inc */
+      /* Destination pointer is updated according to the address modifier, inc
+       */
       pOut += inc;
 
       /* Increment the pointer pIn1 index, count by 1 */
@@ -567,13 +567,13 @@ void arm_correlate_f32(
     }
   }
 
-
   /* --------------------------
    * Initializations of stage3
    * -------------------------*/
 
-  /* sum += x[srcALen-srcBLen+1] * y[0] + x[srcALen-srcBLen+2] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
-   * sum += x[srcALen-srcBLen+2] * y[0] + x[srcALen-srcBLen+3] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
+  /* sum += x[srcALen-srcBLen+1] * y[0] + x[srcALen-srcBLen+2] * y[1] +...+
+   * x[srcALen-1] * y[srcBLen-1] sum += x[srcALen-srcBLen+2] * y[0] +
+   * x[srcALen-srcBLen+3] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
    * ....
    * sum +=  x[srcALen-2] * y[0] + x[srcALen-1] * y[1]
    * sum +=  x[srcALen-1] * y[0]
@@ -594,18 +594,16 @@ void arm_correlate_f32(
    * Stage3 process
    * ------------------*/
 
-  while (blockSize3 > 0U)
-  {
+  while (blockSize3 > 0U) {
     /* Accumulator is made zero for every iteration */
     sum = 0.0f;
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
     /* Loop unrolling: Compute 4 outputs at a time */
     k = count >> 2U;
 
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* Perform the multiply-accumulate */
       /* sum += x[srcALen - srcBLen + 4] * y[3] */
       sum += *px++ * *py++;
@@ -633,8 +631,7 @@ void arm_correlate_f32(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* Perform the multiply-accumulate */
       sum += *px++ * *py++;
 
@@ -659,20 +656,21 @@ void arm_correlate_f32(
   }
 
 #else
-/* alternate version for CM0_FAMILY */
+  /* alternate version for CM0_FAMILY */
 
-  const float32_t *pIn1 = pSrcA;                       /* inputA pointer */
-  const float32_t *pIn2 = pSrcB + (srcBLen - 1U);      /* inputB pointer */
-        float32_t sum;                                 /* Accumulator */
-        uint32_t i = 0U, j;                            /* Loop counters */
-        uint32_t inv = 0U;                             /* Reverse order flag */
-        uint32_t tot = 0U;                             /* Length */
+  const float32_t *pIn1 = pSrcA;                  /* inputA pointer */
+  const float32_t *pIn2 = pSrcB + (srcBLen - 1U); /* inputB pointer */
+  float32_t sum;                                  /* Accumulator */
+  uint32_t i = 0U, j;                             /* Loop counters */
+  uint32_t inv = 0U;                              /* Reverse order flag */
+  uint32_t tot = 0U;                              /* Length */
 
   /* The algorithm implementation is based on the lengths of the inputs. */
   /* srcB is always made to slide across srcA. */
   /* So srcBLen is always considered as shorter or equal to srcALen */
   /* But CORR(x, y) is reverse of CORR(y, x) */
-  /* So, when srcBLen > srcALen, output pointer is made to point to the end of the output buffer */
+  /* So, when srcBLen > srcALen, output pointer is made to point to the end of
+   * the output buffer */
   /* and a varaible, inv is set to 1 */
   /* If lengths are not equal then zero pad has to be done to  make the two
    * inputs of same length. But to improve the performance, we assume zeroes
@@ -687,8 +685,7 @@ void arm_correlate_f32(
   /* Calculate the length of the remaining sequence */
   tot = ((srcALen + srcBLen) - 2U);
 
-  if (srcALen > srcBLen)
-  {
+  if (srcALen > srcBLen) {
     /* Calculating the number of zeros to be padded to the output */
     j = srcALen - srcBLen;
 
@@ -696,8 +693,7 @@ void arm_correlate_f32(
     pDst += j;
   }
 
-  else if (srcALen < srcBLen)
-  {
+  else if (srcALen < srcBLen) {
     /* Initialization to inputB pointer */
     pIn1 = pSrcB;
 
@@ -714,23 +710,19 @@ void arm_correlate_f32(
 
     /* Setting the reverse flag */
     inv = 1;
-
   }
 
   /* Loop to calculate convolution for output length number of times */
-  for (i = 0U; i <= tot; i++)
-  {
+  for (i = 0U; i <= tot; i++) {
     /* Initialize sum with zero to carry out MAC operations */
     sum = 0.0f;
 
     /* Loop to perform MAC operations according to convolution equation */
-    for (j = 0U; j <= i; j++)
-    {
+    for (j = 0U; j <= i; j++) {
       /* Check the array limitations */
-      if ((((i - j) < srcBLen) && (j < srcALen)))
-      {
+      if ((((i - j) < srcBLen) && (j < srcALen))) {
         /* z[i] += x[i-j] * y[j] */
-        sum += pIn1[j] * pIn2[-((int32_t) i - j)];
+        sum += pIn1[j] * pIn2[-((int32_t)i - j)];
       }
     }
 
@@ -742,7 +734,6 @@ void arm_correlate_f32(
   }
 
 #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */
-
 }
 
 /**
diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_fast_opt_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_fast_opt_q15.c
index 13661cb..537445b 100644
--- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_fast_opt_q15.c
+++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_fast_opt_q15.c
@@ -43,63 +43,69 @@
   @param[in]     srcALen    length of the first input sequence
   @param[in]     pSrcB      points to the second input sequence
   @param[in]     srcBLen    length of the second input sequence.
-  @param[out]    pDst       points to the location where the output result is written.  Length 2 * max(srcALen, srcBLen) - 1.
-  @param[in]     pScratch   points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
+  @param[out]    pDst       points to the location where the output result is
+  written.  Length 2 * max(srcALen, srcBLen) - 1.
+  @param[in]     pScratch   points to scratch buffer of size max(srcALen,
+  srcBLen) + 2*min(srcALen, srcBLen) - 2.
   @return        none
 
   @par           Scaling and Overflow Behavior
                    This fast version uses a 32-bit accumulator with 2.30 format.
-                   The accumulator maintains full precision of the intermediate multiplication results but provides only a single guard bit.
-                   There is no saturation on intermediate additions.
-                   Thus, if the accumulator overflows it wraps around and distorts the result.
-                   The input signals should be scaled down to avoid intermediate overflows.
-                   Scale down one of the inputs by 1/min(srcALen, srcBLen) to avoid overflow since a
-                   maximum of min(srcALen, srcBLen) number of additions is carried internally.
-                   The 2.30 accumulator is right shifted by 15 bits and then saturated to 1.15 format to yield the final result.
+                   The accumulator maintains full precision of the intermediate
+  multiplication results but provides only a single guard bit. There is no
+  saturation on intermediate additions. Thus, if the accumulator overflows it
+  wraps around and distorts the result. The input signals should be scaled down
+  to avoid intermediate overflows. Scale down one of the inputs by
+  1/min(srcALen, srcBLen) to avoid overflow since a maximum of min(srcALen,
+  srcBLen) number of additions is carried internally. The 2.30 accumulator is
+  right shifted by 15 bits and then saturated to 1.15 format to yield the final
+  result.
 
   @remark
-                   Refer to \ref arm_correlate_q15() for a slower implementation of this function which uses a 64-bit accumulator to avoid wrap around distortion.
+                   Refer to \ref arm_correlate_q15() for a slower implementation
+  of this function which uses a 64-bit accumulator to avoid wrap around
+  distortion.
  */
 
-void arm_correlate_fast_opt_q15(
-  const q15_t * pSrcA,
-        uint32_t srcALen,
-  const q15_t * pSrcB,
-        uint32_t srcBLen,
-        q15_t * pDst,
-        q15_t * pScratch)
-{
-  const q15_t *pIn1;                                   /* InputA pointer */
-  const q15_t *pIn2;                                   /* InputB pointer */
-        q31_t acc0;                                    /* Accumulators */
-        q15_t *pOut = pDst;                            /* Output pointer */
-        q15_t *pScr1 = pScratch;                       /* Temporary pointer for scratch */
-  const q15_t *py;                                     /* Intermediate inputB pointer */
-        uint32_t j, blkCnt, outBlockSize;              /* Loop counter */
-        int32_t inc = 1;                               /* Destination address modifier */
-        uint32_t tapCnt;                               /* Loop count */
+void arm_correlate_fast_opt_q15(const q15_t *pSrcA, uint32_t srcALen,
+                                const q15_t *pSrcB, uint32_t srcBLen,
+                                q15_t *pDst, q15_t *pScratch) {
+  const q15_t *pIn1;                /* InputA pointer */
+  const q15_t *pIn2;                /* InputB pointer */
+  q31_t acc0;                       /* Accumulators */
+  q15_t *pOut = pDst;               /* Output pointer */
+  q15_t *pScr1 = pScratch;          /* Temporary pointer for scratch */
+  const q15_t *py;                  /* Intermediate inputB pointer */
+  uint32_t j, blkCnt, outBlockSize; /* Loop counter */
+  int32_t inc = 1;                  /* Destination address modifier */
+  uint32_t tapCnt;                  /* Loop count */
 
-#if defined (ARM_MATH_LOOPUNROLL)
-        q31_t acc1, acc2, acc3;                        /* Accumulators */
-        q31_t x1, x2, x3;                              /* Temporary variables for holding input and coefficient values */
-        q31_t y1, y2;                                  /* State variables */
+#if defined(ARM_MATH_LOOPUNROLL)
+  q31_t acc1, acc2, acc3; /* Accumulators */
+  q31_t x1, x2,
+      x3; /* Temporary variables for holding input and coefficient values */
+  q31_t y1, y2; /* State variables */
 #endif
 
   /* The algorithm implementation is based on the lengths of the inputs. */
   /* srcB is always made to slide across srcA. */
   /* So srcBLen is always considered as shorter or equal to srcALen */
   /* But CORR(x, y) is reverse of CORR(y, x) */
-  /* So, when srcBLen > srcALen, output pointer is made to point to the end of the output buffer */
+  /* So, when srcBLen > srcALen, output pointer is made to point to the end of
+   * the output buffer */
   /* and the destination pointer modifier, inc is set to -1 */
-  /* If srcALen > srcBLen, zero pad has to be done to srcB to make the two inputs of same length */
+  /* If srcALen > srcBLen, zero pad has to be done to srcB to make the two
+   * inputs of same length */
   /* But to improve the performance,
-   * we include zeroes in the output instead of zero padding either of the the inputs*/
+   * we include zeroes in the output instead of zero padding either of the the
+   * inputs*/
   /* If srcALen > srcBLen,
-   * (srcALen - srcBLen) zeroes has to included in the starting of the output buffer */
+   * (srcALen - srcBLen) zeroes has to included in the starting of the output
+   * buffer */
   /* If srcALen < srcBLen,
-   * (srcALen - srcBLen) zeroes has to included in the ending of the output buffer */
-  if (srcALen >= srcBLen)
-  {
+   * (srcALen - srcBLen) zeroes has to included in the ending of the output
+   * buffer */
+  if (srcALen >= srcBLen) {
     /* Initialization of inputA pointer */
     pIn1 = pSrcA;
 
@@ -117,9 +123,7 @@ void arm_correlate_fast_opt_q15(
 
     /* Updating the pointer position to non zero value */
     pOut += j;
-  }
-  else
-  {
+  } else {
     /* Initialization of inputA pointer */
     pIn1 = pSrcB;
 
@@ -147,14 +151,12 @@ void arm_correlate_fast_opt_q15(
   /* Update temporary scratch pointer */
   pScr1 += (srcBLen - 1U);
 
-
   /* Copy (srcALen) samples in scratch buffer */
   arm_copy_q15(pIn1, pScr1, srcALen);
 
   /* Update pointers */
   pScr1 += srcALen;
 
-
   /* Fill (srcBLen - 1U) zeros at end of scratch buffer */
   arm_fill_q15(0, pScr1, (srcBLen - 1U));
 
@@ -164,16 +166,14 @@ void arm_correlate_fast_opt_q15(
   /* Temporary pointer for scratch2 */
   py = pIn2;
 
-
   /* Actual correlation process starts here */
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
   /* Loop unrolling: Compute 4 outputs at a time */
   blkCnt = (srcALen + srcBLen - 1U) >> 2;
 
-  while (blkCnt > 0)
-  {
+  while (blkCnt > 0) {
     /* Initialze temporary scratch pointer as scratch1 */
     pScr1 = pScratch;
 
@@ -184,18 +184,17 @@ void arm_correlate_fast_opt_q15(
     acc3 = 0;
 
     /* Read two samples from scratch buffer */
-    x1 = read_q15x2_ia (&pScr1);
+    x1 = read_q15x2_ia(&pScr1);
 
     /* Read next two samples from scratch buffer */
-    x2 = read_q15x2_ia (&pScr1);
+    x2 = read_q15x2_ia(&pScr1);
 
     tapCnt = (srcBLen) >> 2U;
 
-    while (tapCnt > 0U)
-    {
+    while (tapCnt > 0U) {
       /* Read four samples from smaller buffer */
-      y1 = read_q15x2_ia ((q15_t **) &pIn2);
-      y2 = read_q15x2_ia ((q15_t **) &pIn2);
+      y1 = read_q15x2_ia((q15_t **)&pIn2);
+      y2 = read_q15x2_ia((q15_t **)&pIn2);
 
       /* multiply and accumlate */
       acc0 = __SMLAD(x1, y1, acc0);
@@ -212,7 +211,7 @@ void arm_correlate_fast_opt_q15(
       acc1 = __SMLADX(x3, y1, acc1);
 
       /* Read next two samples from scratch buffer */
-      x1 = read_q15x2_ia (&pScr1);
+      x1 = read_q15x2_ia(&pScr1);
 
       /* multiply and accumlate */
       acc0 = __SMLAD(x2, y2, acc0);
@@ -228,7 +227,7 @@ void arm_correlate_fast_opt_q15(
       acc3 = __SMLADX(x3, y1, acc3);
       acc1 = __SMLADX(x3, y2, acc1);
 
-      x2 = read_q15x2_ia (&pScr1);
+      x2 = read_q15x2_ia(&pScr1);
 
 #ifndef ARM_MATH_BIG_ENDIAN
       x3 = __PKHBT(x2, x1, 0);
@@ -242,14 +241,14 @@ void arm_correlate_fast_opt_q15(
       tapCnt--;
     }
 
-    /* Update scratch pointer for remaining samples of smaller length sequence */
+    /* Update scratch pointer for remaining samples of smaller length sequence
+     */
     pScr1 -= 4U;
 
     /* apply same above for remaining samples of smaller length sequence */
-    tapCnt = (srcBLen) & 3U;
+    tapCnt = (srcBLen)&3U;
 
-    while (tapCnt > 0U)
-    {
+    while (tapCnt > 0U) {
       /* accumlate the results */
       acc0 += (*pScr1++ * *pIn2);
       acc1 += (*pScr1++ * *pIn2);
@@ -291,8 +290,7 @@ void arm_correlate_fast_opt_q15(
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
   /* Calculate correlation for remaining samples of Bigger length sequence */
-  while (blkCnt > 0)
-  {
+  while (blkCnt > 0) {
     /* Initialze temporary scratch pointer as scratch1 */
     pScr1 = pScratch;
 
@@ -301,8 +299,7 @@ void arm_correlate_fast_opt_q15(
 
     tapCnt = (srcBLen) >> 1U;
 
-    while (tapCnt > 0U)
-    {
+    while (tapCnt > 0U) {
 
       /* Read next two samples from scratch buffer */
       acc0 += (*pScr1++ * *pIn2++);
@@ -312,11 +309,10 @@ void arm_correlate_fast_opt_q15(
       tapCnt--;
     }
 
-    tapCnt = (srcBLen) & 1U;
+    tapCnt = (srcBLen)&1U;
 
     /* apply same above for remaining samples of smaller length sequence */
-    while (tapCnt > 0U)
-    {
+    while (tapCnt > 0U) {
 
       /* accumlate the results */
       acc0 += (*pScr1++ * *pIn2++);
@@ -329,7 +325,7 @@ void arm_correlate_fast_opt_q15(
 
     /* The result is in 2.30 format.  Convert to 1.15 with saturation.
      ** Then store the output in the destination buffer. */
-    *pOut = (q15_t) (__SSAT((acc0 >> 15), 16));
+    *pOut = (q15_t)(__SSAT((acc0 >> 15), 16));
     pOut += inc;
 
     /* Initialization of inputB pointer */
@@ -337,7 +333,6 @@ void arm_correlate_fast_opt_q15(
 
     pScratch += 1U;
   }
-
 }
 
 /**
diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_fast_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_fast_q15.c
index 6898618..aed0d83 100644
--- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_fast_q15.c
+++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_fast_q15.c
@@ -43,59 +43,63 @@
   @param[in]     srcALen    length of the first input sequence
   @param[in]     pSrcB      points to the second input sequence
   @param[in]     srcBLen    length of the second input sequence
-  @param[out]    pDst       points to the location where the output result is written.  Length 2 * max(srcALen, srcBLen) - 1.
+  @param[out]    pDst       points to the location where the output result is
+  written.  Length 2 * max(srcALen, srcBLen) - 1.
   @return        none
 
   @par           Scaling and Overflow Behavior
                    This fast version uses a 32-bit accumulator with 2.30 format.
-                   The accumulator maintains full precision of the intermediate multiplication results but provides only a single guard bit.
-                   There is no saturation on intermediate additions.
-                   Thus, if the accumulator overflows it wraps around and distorts the result.
-                   The input signals should be scaled down to avoid intermediate overflows.
-                   Scale down one of the inputs by 1/min(srcALen, srcBLen) to avoid overflow since a
-                   maximum of min(srcALen, srcBLen) number of additions is carried internally.
-                   The 2.30 accumulator is right shifted by 15 bits and then saturated to 1.15 format to yield the final result.
+                   The accumulator maintains full precision of the intermediate
+  multiplication results but provides only a single guard bit. There is no
+  saturation on intermediate additions. Thus, if the accumulator overflows it
+  wraps around and distorts the result. The input signals should be scaled down
+  to avoid intermediate overflows. Scale down one of the inputs by
+  1/min(srcALen, srcBLen) to avoid overflow since a maximum of min(srcALen,
+  srcBLen) number of additions is carried internally. The 2.30 accumulator is
+  right shifted by 15 bits and then saturated to 1.15 format to yield the final
+  result.
 
   @remark
-                   Refer to \ref arm_correlate_q15() for a slower implementation of this function which uses a 64-bit accumulator to avoid wrap around distortion.
+                   Refer to \ref arm_correlate_q15() for a slower implementation
+  of this function which uses a 64-bit accumulator to avoid wrap around
+  distortion.
  */
 
-void arm_correlate_fast_q15(
-  const q15_t * pSrcA,
-        uint32_t srcALen,
-  const q15_t * pSrcB,
-        uint32_t srcBLen,
-        q15_t * pDst)
-{
-  const q15_t *pIn1;                                   /* InputA pointer */
-  const q15_t *pIn2;                                   /* InputB pointer */
-        q15_t *pOut = pDst;                            /* Output pointer */
-        q31_t sum, acc0, acc1, acc2, acc3;             /* Accumulators */
-  const q15_t *px;                                     /* Intermediate inputA pointer */
-  const q15_t *py;                                     /* Intermediate inputB pointer */
-  const q15_t *pSrc1;                                  /* Intermediate pointers */
-        q31_t x0, x1, x2, x3, c0;                      /* Temporary variables for holding input and coefficient values */
-        uint32_t blockSize1, blockSize2, blockSize3;   /* Loop counters */
-        uint32_t j, k, count, blkCnt;                  /* Loop counters */
-        uint32_t outBlockSize;
-        int32_t inc = 1;                               /* Destination address modifier */
-
+void arm_correlate_fast_q15(const q15_t *pSrcA, uint32_t srcALen,
+                            const q15_t *pSrcB, uint32_t srcBLen, q15_t *pDst) {
+  const q15_t *pIn1;                 /* InputA pointer */
+  const q15_t *pIn2;                 /* InputB pointer */
+  q15_t *pOut = pDst;                /* Output pointer */
+  q31_t sum, acc0, acc1, acc2, acc3; /* Accumulators */
+  const q15_t *px;                   /* Intermediate inputA pointer */
+  const q15_t *py;                   /* Intermediate inputB pointer */
+  const q15_t *pSrc1;                /* Intermediate pointers */
+  q31_t x0, x1, x2, x3,
+      c0; /* Temporary variables for holding input and coefficient values */
+  uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */
+  uint32_t j, k, count, blkCnt;                /* Loop counters */
+  uint32_t outBlockSize;
+  int32_t inc = 1; /* Destination address modifier */
 
   /* The algorithm implementation is based on the lengths of the inputs. */
   /* srcB is always made to slide across srcA. */
   /* So srcBLen is always considered as shorter or equal to srcALen */
   /* But CORR(x, y) is reverse of CORR(y, x) */
-  /* So, when srcBLen > srcALen, output pointer is made to point to the end of the output buffer */
+  /* So, when srcBLen > srcALen, output pointer is made to point to the end of
+   * the output buffer */
   /* and the destination pointer modifier, inc is set to -1 */
-  /* If srcALen > srcBLen, zero pad has to be done to srcB to make the two inputs of same length */
+  /* If srcALen > srcBLen, zero pad has to be done to srcB to make the two
+   * inputs of same length */
   /* But to improve the performance,
-   * we include zeroes in the output instead of zero padding either of the the inputs*/
+   * we include zeroes in the output instead of zero padding either of the the
+   * inputs*/
   /* If srcALen > srcBLen,
-   * (srcALen - srcBLen) zeroes has to included in the starting of the output buffer */
+   * (srcALen - srcBLen) zeroes has to included in the starting of the output
+   * buffer */
   /* If srcALen < srcBLen,
-   * (srcALen - srcBLen) zeroes has to included in the ending of the output buffer */
-  if (srcALen >= srcBLen)
-  {
+   * (srcALen - srcBLen) zeroes has to included in the ending of the output
+   * buffer */
+  if (srcALen >= srcBLen) {
     /* Initialization of inputA pointer */
     pIn1 = pSrcA;
 
@@ -114,9 +118,7 @@ void arm_correlate_fast_q15(
     /* Updating the pointer position to non zero value */
     pOut += j;
 
-  }
-  else
-  {
+  } else {
     /* Initialization of inputA pointer */
     pIn1 = pSrcB;
 
@@ -134,16 +136,15 @@ void arm_correlate_fast_q15(
 
     /* Destination address modifier is set to -1 */
     inc = -1;
-
   }
 
   /* The function is internally
-   * divided into three stages according to the number of multiplications that has to be
-   * taken place between inputA samples and inputB samples. In the first stage of the
-   * algorithm, the multiplications increase by one for every iteration.
-   * In the second stage of the algorithm, srcBLen number of multiplications are done.
-   * In the third stage of the algorithm, the multiplications decrease by one
-   * for every iteration. */
+   * divided into three stages according to the number of multiplications that
+   * has to be taken place between inputA samples and inputB samples. In the
+   * first stage of the algorithm, the multiplications increase by one for every
+   * iteration. In the second stage of the algorithm, srcBLen number of
+   * multiplications are done. In the third stage of the algorithm, the
+   * multiplications decrease by one for every iteration. */
 
   /* The algorithm is implemented in three stages.
      The loop counters of each stage is initiated here. */
@@ -177,22 +178,23 @@ void arm_correlate_fast_q15(
    * ----------------------*/
 
   /* The first loop starts here */
-  while (blockSize1 > 0U)
-  {
+  while (blockSize1 > 0U) {
     /* Accumulator is made zero for every iteration */
     sum = 0;
 
     /* Apply loop unrolling and compute 4 MACs simultaneously. */
     k = count >> 2U;
 
-    /* First part of the processing with loop unrolling.  Compute 4 MACs at a time.
+    /* First part of the processing with loop unrolling.  Compute 4 MACs at a
+     *time.
      ** a second loop below computes MACs for the remaining 1 to 3 samples. */
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* x[0] * y[srcBLen - 4] , x[1] * y[srcBLen - 3] */
-      sum = __SMLAD(read_q15x2_ia ((q15_t **) &px), read_q15x2_ia ((q15_t **) &py), sum);
+      sum = __SMLAD(read_q15x2_ia((q15_t **)&px), read_q15x2_ia((q15_t **)&py),
+                    sum);
       /* x[3] * y[srcBLen - 1] , x[2] * y[srcBLen - 2] */
-      sum = __SMLAD(read_q15x2_ia ((q15_t **) &px), read_q15x2_ia ((q15_t **) &py), sum);
+      sum = __SMLAD(read_q15x2_ia((q15_t **)&px), read_q15x2_ia((q15_t **)&py),
+                    sum);
 
       /* Decrement loop counter */
       k--;
@@ -202,8 +204,7 @@ void arm_correlate_fast_q15(
        No loop unrolling is used. */
     k = count % 0x4U;
 
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* Perform the multiply-accumulates */
       /* x[0] * y[srcBLen - 1] */
       sum = __SMLAD(*px++, *py++, sum);
@@ -213,7 +214,7 @@ void arm_correlate_fast_q15(
     }
 
     /* Store the result in the accumulator in the destination buffer. */
-    *pOut = (q15_t) (sum >> 15);
+    *pOut = (q15_t)(sum >> 15);
     /* Destination pointer is updated according to the address modifier, inc */
     pOut += inc;
 
@@ -235,7 +236,8 @@ void arm_correlate_fast_q15(
   /* sum = x[0] * y[0] + x[1] * y[1] +...+ x[srcBLen-1] * y[srcBLen-1]
    * sum = x[1] * y[0] + x[2] * y[1] +...+ x[srcBLen] * y[srcBLen-1]
    * ....
-   * sum = x[srcALen-srcBLen-2] * y[0] + x[srcALen-srcBLen-1] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
+   * sum = x[srcALen-srcBLen-2] * y[0] + x[srcALen-srcBLen-1] * y[1] +...+
+   * x[srcALen-1] * y[srcBLen-1]
    */
 
   /* Working pointer of inputA */
@@ -251,16 +253,14 @@ void arm_correlate_fast_q15(
    * Stage2 process
    * -------------------*/
 
-  /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed.
-   * So, to loop unroll over blockSize2,
-   * srcBLen should be greater than or equal to 4 */
-  if (srcBLen >= 4U)
-  {
+  /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are
+   * performed. So, to loop unroll over blockSize2, srcBLen should be greater
+   * than or equal to 4 */
+  if (srcBLen >= 4U) {
     /* Loop unroll over blockSize2, by 4 */
     blkCnt = blockSize2 >> 2U;
 
-    while (blkCnt > 0U)
-    {
+    while (blkCnt > 0U) {
       /* Set all accumulators to zero */
       acc0 = 0;
       acc1 = 0;
@@ -268,21 +268,21 @@ void arm_correlate_fast_q15(
       acc3 = 0;
 
       /* read x[0], x[1] samples */
-      x0 = read_q15x2 ((q15_t *) px);
+      x0 = read_q15x2((q15_t *)px);
       /* read x[1], x[2] samples */
-      x1 = read_q15x2 ((q15_t *) px + 1);
-	  px += 2U;
+      x1 = read_q15x2((q15_t *)px + 1);
+      px += 2U;
 
       /* Apply loop unrolling and compute 4 MACs simultaneously. */
       k = srcBLen >> 2U;
 
-      /* First part of the processing with loop unrolling.  Compute 4 MACs at a time.
+      /* First part of the processing with loop unrolling.  Compute 4 MACs at a
+       *time.
        ** a second loop below computes MACs for the remaining 1 to 3 samples. */
-      do
-      {
+      do {
         /* Read the first two inputB samples using SIMD:
          * y[0] and y[1] */
-        c0 = read_q15x2_ia ((q15_t **) &py);
+        c0 = read_q15x2_ia((q15_t **)&py);
 
         /* acc0 +=  x[0] * y[0] + x[1] * y[1] */
         acc0 = __SMLAD(x0, c0, acc0);
@@ -291,10 +291,10 @@ void arm_correlate_fast_q15(
         acc1 = __SMLAD(x1, c0, acc1);
 
         /* Read x[2], x[3] */
-        x2 = read_q15x2 ((q15_t *) px);
+        x2 = read_q15x2((q15_t *)px);
 
         /* Read x[3], x[4] */
-        x3 = read_q15x2 ((q15_t *) px + 1);
+        x3 = read_q15x2((q15_t *)px + 1);
 
         /* acc2 +=  x[2] * y[0] + x[3] * y[1] */
         acc2 = __SMLAD(x2, c0, acc2);
@@ -303,7 +303,7 @@ void arm_correlate_fast_q15(
         acc3 = __SMLAD(x3, c0, acc3);
 
         /* Read y[2] and y[3] */
-        c0 = read_q15x2_ia ((q15_t **) &py);
+        c0 = read_q15x2_ia((q15_t **)&py);
 
         /* acc0 +=  x[2] * y[2] + x[3] * y[3] */
         acc0 = __SMLAD(x2, c0, acc0);
@@ -312,11 +312,11 @@ void arm_correlate_fast_q15(
         acc1 = __SMLAD(x3, c0, acc1);
 
         /* Read x[4], x[5] */
-        x0 = read_q15x2 ((q15_t *) px + 2);
+        x0 = read_q15x2((q15_t *)px + 2);
 
         /* Read x[5], x[6] */
-        x1 = read_q15x2 ((q15_t *) px + 3);
-		px += 4U;
+        x1 = read_q15x2((q15_t *)px + 3);
+        px += 4U;
 
         /* acc2 +=  x[4] * y[2] + x[5] * y[3] */
         acc2 = __SMLAD(x0, c0, acc2);
@@ -333,39 +333,37 @@ void arm_correlate_fast_q15(
        ** No loop unrolling is used. */
       k = srcBLen % 0x4U;
 
-      if (k == 1U)
-      {
+      if (k == 1U) {
         /* Read y[4] */
         c0 = *py;
 
-#ifdef  ARM_MATH_BIG_ENDIAN
+#ifdef ARM_MATH_BIG_ENDIAN
         c0 = c0 << 16U;
 #else
         c0 = c0 & 0x0000FFFF;
 #endif /* #ifdef  ARM_MATH_BIG_ENDIAN */
 
         /* Read x[7] */
-        x3 = read_q15x2 ((q15_t *) px);
-		px++;
+        x3 = read_q15x2((q15_t *)px);
+        px++;
 
         /* Perform the multiply-accumulates */
-        acc0 = __SMLAD (x0, c0, acc0);
-        acc1 = __SMLAD (x1, c0, acc1);
+        acc0 = __SMLAD(x0, c0, acc0);
+        acc1 = __SMLAD(x1, c0, acc1);
         acc2 = __SMLADX(x1, c0, acc2);
         acc3 = __SMLADX(x3, c0, acc3);
       }
 
-      if (k == 2U)
-      {
+      if (k == 2U) {
         /* Read y[4], y[5] */
-        c0 = read_q15x2 ((q15_t *) py);
+        c0 = read_q15x2((q15_t *)py);
 
         /* Read x[7], x[8] */
-        x3 = read_q15x2 ((q15_t *) px);
+        x3 = read_q15x2((q15_t *)px);
 
         /* Read x[9] */
-        x2 = read_q15x2 ((q15_t *) px + 1);
-		px += 2U;
+        x2 = read_q15x2((q15_t *)px + 1);
+        px += 2U;
 
         /* Perform the multiply-accumulates */
         acc0 = __SMLAD(x0, c0, acc0);
@@ -374,16 +372,15 @@ void arm_correlate_fast_q15(
         acc3 = __SMLAD(x2, c0, acc3);
       }
 
-      if (k == 3U)
-      {
+      if (k == 3U) {
         /* Read y[4], y[5] */
-        c0 = read_q15x2_ia ((q15_t **) &py);
+        c0 = read_q15x2_ia((q15_t **)&py);
 
         /* Read x[7], x[8] */
-        x3 = read_q15x2 ((q15_t *) px);
+        x3 = read_q15x2((q15_t *)px);
 
         /* Read x[9] */
-        x2 = read_q15x2 ((q15_t *) px + 1);
+        x2 = read_q15x2((q15_t *)px + 1);
 
         /* Perform the multiply-accumulates */
         acc0 = __SMLAD(x0, c0, acc0);
@@ -393,35 +390,36 @@ void arm_correlate_fast_q15(
 
         c0 = (*py);
         /* Read y[6] */
-#ifdef  ARM_MATH_BIG_ENDIAN
+#ifdef ARM_MATH_BIG_ENDIAN
         c0 = c0 << 16U;
 #else
         c0 = c0 & 0x0000FFFF;
 #endif /* #ifdef  ARM_MATH_BIG_ENDIAN */
 
         /* Read x[10] */
-        x3 = read_q15x2 ((q15_t *) px + 2);
-		px += 3U;
+        x3 = read_q15x2((q15_t *)px + 2);
+        px += 3U;
 
         /* Perform the multiply-accumulates */
         acc0 = __SMLADX(x1, c0, acc0);
-        acc1 = __SMLAD (x2, c0, acc1);
+        acc1 = __SMLAD(x2, c0, acc1);
         acc2 = __SMLADX(x2, c0, acc2);
         acc3 = __SMLADX(x3, c0, acc3);
       }
 
       /* Store the result in the accumulator in the destination buffer. */
-      *pOut = (q15_t) (acc0 >> 15);
-      /* Destination pointer is updated according to the address modifier, inc */
+      *pOut = (q15_t)(acc0 >> 15);
+      /* Destination pointer is updated according to the address modifier, inc
+       */
       pOut += inc;
 
-      *pOut = (q15_t) (acc1 >> 15);
+      *pOut = (q15_t)(acc1 >> 15);
       pOut += inc;
 
-      *pOut = (q15_t) (acc2 >> 15);
+      *pOut = (q15_t)(acc2 >> 15);
       pOut += inc;
 
-      *pOut = (q15_t) (acc3 >> 15);
+      *pOut = (q15_t)(acc3 >> 15);
       pOut += inc;
 
       /* Increment the pointer pIn1 index, count by 4 */
@@ -435,27 +433,27 @@ void arm_correlate_fast_q15(
       blkCnt--;
     }
 
-    /* If the blockSize2 is not a multiple of 4, compute any remaining output samples here.
+    /* If the blockSize2 is not a multiple of 4, compute any remaining output
+     *samples here.
      ** No loop unrolling is used. */
     blkCnt = blockSize2 % 0x4U;
 
-    while (blkCnt > 0U)
-    {
+    while (blkCnt > 0U) {
       /* Accumulator is made zero for every iteration */
       sum = 0;
 
       /* Apply loop unrolling and compute 4 MACs simultaneously. */
       k = srcBLen >> 2U;
 
-      /* First part of the processing with loop unrolling.  Compute 4 MACs at a time.
+      /* First part of the processing with loop unrolling.  Compute 4 MACs at a
+       *time.
        ** a second loop below computes MACs for the remaining 1 to 3 samples. */
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Perform the multiply-accumulates */
-        sum += ((q31_t) *px++ * *py++);
-        sum += ((q31_t) *px++ * *py++);
-        sum += ((q31_t) *px++ * *py++);
-        sum += ((q31_t) *px++ * *py++);
+        sum += ((q31_t)*px++ * *py++);
+        sum += ((q31_t)*px++ * *py++);
+        sum += ((q31_t)*px++ * *py++);
+        sum += ((q31_t)*px++ * *py++);
 
         /* Decrement loop counter */
         k--;
@@ -465,18 +463,18 @@ void arm_correlate_fast_q15(
        ** No loop unrolling is used. */
       k = srcBLen % 0x4U;
 
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Perform the multiply-accumulates */
-        sum += ((q31_t) * px++ * *py++);
+        sum += ((q31_t)*px++ * *py++);
 
         /* Decrement loop counter */
         k--;
       }
 
       /* Store the result in the accumulator in the destination buffer. */
-      *pOut = (q15_t) (sum >> 15);
-      /* Destination pointer is updated according to the address modifier, inc */
+      *pOut = (q15_t)(sum >> 15);
+      /* Destination pointer is updated according to the address modifier, inc
+       */
       pOut += inc;
 
       /* Increment the pointer pIn1 index, count by 1 */
@@ -489,33 +487,30 @@ void arm_correlate_fast_q15(
       /* Decrement loop counter */
       blkCnt--;
     }
-  }
-  else
-  {
+  } else {
     /* If the srcBLen is not a multiple of 4,
      * the blockSize2 loop cannot be unrolled by 4 */
     blkCnt = blockSize2;
 
-    while (blkCnt > 0U)
-    {
+    while (blkCnt > 0U) {
       /* Accumulator is made zero for every iteration */
       sum = 0;
 
       /* srcBLen number of MACS should be performed */
       k = srcBLen;
 
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Perform the multiply-accumulate */
-        sum += ((q31_t) *px++ * *py++);
+        sum += ((q31_t)*px++ * *py++);
 
         /* Decrement loop counter */
         k--;
       }
 
       /* Store the result in the accumulator in the destination buffer. */
-      *pOut = (q15_t) (sum >> 15);
-      /* Destination pointer is updated according to the address modifier, inc */
+      *pOut = (q15_t)(sum >> 15);
+      /* Destination pointer is updated according to the address modifier, inc
+       */
       pOut += inc;
 
       /* Increment MAC count */
@@ -534,8 +529,9 @@ void arm_correlate_fast_q15(
    * Initializations of stage3
    * -------------------------*/
 
-  /* sum += x[srcALen-srcBLen+1] * y[0] + x[srcALen-srcBLen+2] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
-   * sum += x[srcALen-srcBLen+2] * y[0] + x[srcALen-srcBLen+3] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
+  /* sum += x[srcALen-srcBLen+1] * y[0] + x[srcALen-srcBLen+2] * y[1] +...+
+   * x[srcALen-1] * y[srcBLen-1] sum += x[srcALen-srcBLen+2] * y[0] +
+   * x[srcALen-srcBLen+3] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
    * ....
    * sum +=  x[srcALen-2] * y[0] + x[srcALen-1] * y[1]
    * sum +=  x[srcALen-1] * y[0]
@@ -556,23 +552,26 @@ void arm_correlate_fast_q15(
    * Stage3 process
    * ------------------*/
 
-  while (blockSize3 > 0U)
-  {
+  while (blockSize3 > 0U) {
     /* Accumulator is made zero for every iteration */
     sum = 0;
 
     /* Apply loop unrolling and compute 4 MACs simultaneously. */
     k = count >> 2U;
 
-    /* First part of the processing with loop unrolling.  Compute 4 MACs at a time.
+    /* First part of the processing with loop unrolling.  Compute 4 MACs at a
+     *time.
      ** a second loop below computes MACs for the remaining 1 to 3 samples. */
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* Perform the multiply-accumulates */
-      /* sum += x[srcALen - srcBLen + 4] * y[3] , sum += x[srcALen - srcBLen + 3] * y[2] */
-      sum = __SMLAD(read_q15x2_ia ((q15_t **) &px), read_q15x2_ia ((q15_t **) &py), sum);
-      /* sum += x[srcALen - srcBLen + 2] * y[1] , sum += x[srcALen - srcBLen + 1] * y[0] */
-      sum = __SMLAD(read_q15x2_ia ((q15_t **) &px), read_q15x2_ia ((q15_t **) &py), sum);
+      /* sum += x[srcALen - srcBLen + 4] * y[3] , sum += x[srcALen - srcBLen +
+       * 3] * y[2] */
+      sum = __SMLAD(read_q15x2_ia((q15_t **)&px), read_q15x2_ia((q15_t **)&py),
+                    sum);
+      /* sum += x[srcALen - srcBLen + 2] * y[1] , sum += x[srcALen - srcBLen +
+       * 1] * y[0] */
+      sum = __SMLAD(read_q15x2_ia((q15_t **)&px), read_q15x2_ia((q15_t **)&py),
+                    sum);
 
       /* Decrement loop counter */
       k--;
@@ -582,8 +581,7 @@ void arm_correlate_fast_q15(
      ** No loop unrolling is used. */
     k = count % 0x4U;
 
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* Perform the multiply-accumulates */
       sum = __SMLAD(*px++, *py++, sum);
 
@@ -592,7 +590,7 @@ void arm_correlate_fast_q15(
     }
 
     /* Store the result in the accumulator in the destination buffer. */
-    *pOut = (q15_t) (sum >> 15);
+    *pOut = (q15_t)(sum >> 15);
     /* Destination pointer is updated according to the address modifier, inc */
     pOut += inc;
 
@@ -606,7 +604,6 @@ void arm_correlate_fast_q15(
     /* Decrement the loop counter */
     blockSize3--;
   }
-
 }
 
 /**
diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_fast_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_fast_q31.c
index a5840b7..3e8ac13 100644
--- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_fast_q31.c
+++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_fast_q31.c
@@ -43,50 +43,50 @@
   @param[in]     srcALen    length of the first input sequence
   @param[in]     pSrcB      points to the second input sequence
   @param[in]     srcBLen    length of the second input sequence
-  @param[out]    pDst       points to the location where the output result is written.  Length 2 * max(srcALen, srcBLen) - 1.
+  @param[out]    pDst       points to the location where the output result is
+ written.  Length 2 * max(srcALen, srcBLen) - 1.
   @return        none
 
   @par           Scaling and Overflow Behavior
-                   This function is optimized for speed at the expense of fixed-point precision and overflow protection.
-                   The result of each 1.31 x 1.31 multiplication is truncated to 2.30 format.
-                   These intermediate results are accumulated in a 32-bit register in 2.30 format.
-                   Finally, the accumulator is saturated and converted to a 1.31 result.
+                   This function is optimized for speed at the expense of
+ fixed-point precision and overflow protection. The result of each 1.31 x 1.31
+ multiplication is truncated to 2.30 format. These intermediate results are
+ accumulated in a 32-bit register in 2.30 format. Finally, the accumulator is
+ saturated and converted to a 1.31 result.
   @par
-                   The fast version has the same overflow behavior as the standard version but provides less precision since it discards the low 32 bits of each multiplication result.
-                   In order to avoid overflows completely the input signals must be scaled down.
-                   The input signals should be scaled down to avoid intermediate overflows.
-                   Scale down one of the inputs by 1/min(srcALen, srcBLen)to avoid overflows since a
-                   maximum of min(srcALen, srcBLen) number of additions is carried internally.
+                   The fast version has the same overflow behavior as the
+ standard version but provides less precision since it discards the low 32 bits
+ of each multiplication result. In order to avoid overflows completely the input
+ signals must be scaled down. The input signals should be scaled down to avoid
+ intermediate overflows. Scale down one of the inputs by 1/min(srcALen,
+ srcBLen)to avoid overflows since a maximum of min(srcALen, srcBLen) number of
+ additions is carried internally.
 
  @remark
-                   Refer to \ref arm_correlate_q31() for a slower implementation of this function which uses 64-bit accumulation to provide higher precision.
+                   Refer to \ref arm_correlate_q31() for a slower implementation
+ of this function which uses 64-bit accumulation to provide higher precision.
  */
 
-void arm_correlate_fast_q31(
-  const q31_t * pSrcA,
-        uint32_t srcALen,
-  const q31_t * pSrcB,
-        uint32_t srcBLen,
-        q31_t * pDst)
-{
-  const q31_t *pIn1;                                   /* InputA pointer */
-  const q31_t *pIn2;                                   /* InputB pointer */
-        q31_t *pOut = pDst;                            /* Output pointer */
-  const q31_t *px;                                     /* Intermediate inputA pointer */
-  const q31_t *py;                                     /* Intermediate inputB pointer */
-  const q31_t *pSrc1;                                  /* Intermediate pointers */
-        q31_t sum, acc0, acc1, acc2, acc3;             /* Accumulators */
-        q31_t x0, x1, x2, x3, c0;                      /* Temporary variables for holding input and coefficient values */
-        uint32_t blockSize1, blockSize2, blockSize3;   /* Loop counters */
-        uint32_t j, k, count, blkCnt;                  /* Loop counters */
-        uint32_t outBlockSize;
-        int32_t inc = 1;                               /* Destination address modifier */
+void arm_correlate_fast_q31(const q31_t *pSrcA, uint32_t srcALen,
+                            const q31_t *pSrcB, uint32_t srcBLen, q31_t *pDst) {
+  const q31_t *pIn1;                 /* InputA pointer */
+  const q31_t *pIn2;                 /* InputB pointer */
+  q31_t *pOut = pDst;                /* Output pointer */
+  const q31_t *px;                   /* Intermediate inputA pointer */
+  const q31_t *py;                   /* Intermediate inputB pointer */
+  const q31_t *pSrc1;                /* Intermediate pointers */
+  q31_t sum, acc0, acc1, acc2, acc3; /* Accumulators */
+  q31_t x0, x1, x2, x3,
+      c0; /* Temporary variables for holding input and coefficient values */
+  uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */
+  uint32_t j, k, count, blkCnt;                /* Loop counters */
+  uint32_t outBlockSize;
+  int32_t inc = 1; /* Destination address modifier */
 
   /* The algorithm implementation is based on the lengths of the inputs. */
   /* srcB is always made to slide across srcA. */
   /* So srcBLen is always considered as shorter or equal to srcALen */
-  if (srcALen >= srcBLen)
-  {
+  if (srcALen >= srcBLen) {
     /* Initialization of inputA pointer */
     pIn1 = pSrcA;
 
@@ -105,9 +105,7 @@ void arm_correlate_fast_q31(
     /* Updating the pointer position to non zero value */
     pOut += j;
 
-  }
-  else
-  {
+  } else {
     /* Initialization of inputA pointer */
     pIn1 = pSrcB;
 
@@ -125,16 +123,15 @@ void arm_correlate_fast_q31(
 
     /* Destination address modifier is set to -1 */
     inc = -1;
-
   }
 
   /* The function is internally
-   * divided into three stages according to the number of multiplications that has to be
-   * taken place between inputA samples and inputB samples. In the first stage of the
-   * algorithm, the multiplications increase by one for every iteration.
-   * In the second stage of the algorithm, srcBLen number of multiplications are done.
-   * In the third stage of the algorithm, the multiplications decrease by one
-   * for every iteration. */
+   * divided into three stages according to the number of multiplications that
+   * has to be taken place between inputA samples and inputB samples. In the
+   * first stage of the algorithm, the multiplications increase by one for every
+   * iteration. In the second stage of the algorithm, srcBLen number of
+   * multiplications are done. In the third stage of the algorithm, the
+   * multiplications decrease by one for every iteration. */
 
   /* The algorithm is implemented in three stages.
      The loop counters of each stage is initiated here. */
@@ -168,33 +165,28 @@ void arm_correlate_fast_q31(
    * ----------------------*/
 
   /* The first stage starts here */
-  while (blockSize1 > 0U)
-  {
+  while (blockSize1 > 0U) {
     /* Accumulator is made zero for every iteration */
     sum = 0;
 
     /* Apply loop unrolling and compute 4 MACs simultaneously. */
     k = count >> 2U;
 
-    /* First part of the processing with loop unrolling.  Compute 4 MACs at a time.
+    /* First part of the processing with loop unrolling.  Compute 4 MACs at a
+     *time.
      ** a second loop below computes MACs for the remaining 1 to 3 samples. */
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* x[0] * y[srcBLen - 4] */
-      sum = (q31_t) ((((q63_t) sum << 32) +
-                      ((q63_t) *px++ * (*py++))) >> 32);
+      sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py++))) >> 32);
 
       /* x[1] * y[srcBLen - 3] */
-      sum = (q31_t) ((((q63_t) sum << 32) +
-                      ((q63_t) *px++ * (*py++))) >> 32);
+      sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py++))) >> 32);
 
       /* x[2] * y[srcBLen - 2] */
-      sum = (q31_t) ((((q63_t) sum << 32) +
-                      ((q63_t) *px++ * (*py++))) >> 32);
+      sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py++))) >> 32);
 
       /* x[3] * y[srcBLen - 1] */
-      sum = (q31_t) ((((q63_t) sum << 32) +
-                      ((q63_t) *px++ * (*py++))) >> 32);
+      sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py++))) >> 32);
 
       /* Decrement loop counter */
       k--;
@@ -204,12 +196,10 @@ void arm_correlate_fast_q31(
      ** No loop unrolling is used. */
     k = count % 0x4U;
 
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* Perform the multiply-accumulate */
       /* x[0] * y[srcBLen - 1] */
-      sum = (q31_t) ((((q63_t) sum << 32) +
-                      ((q63_t) *px++ * (*py++))) >> 32);
+      sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py++))) >> 32);
 
       /* Decrement loop counter */
       k--;
@@ -238,7 +228,8 @@ void arm_correlate_fast_q31(
   /* sum = x[0] * y[0] + x[1] * y[1] +...+ x[srcBLen-1] * y[srcBLen-1]
    * sum = x[1] * y[0] + x[2] * y[1] +...+ x[srcBLen] * y[srcBLen-1]
    * ....
-   * sum = x[srcALen-srcBLen-2] * y[0] + x[srcALen-srcBLen-1] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
+   * sum = x[srcALen-srcBLen-2] * y[0] + x[srcALen-srcBLen-1] * y[1] +...+
+   * x[srcALen-1] * y[srcBLen-1]
    */
 
   /* Working pointer of inputA */
@@ -254,16 +245,14 @@ void arm_correlate_fast_q31(
    * Stage2 process
    * ------------------*/
 
-  /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed.
-   * So, to loop unroll over blockSize2,
-   * srcBLen should be greater than or equal to 4 */
-  if (srcBLen >= 4U)
-  {
+  /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are
+   * performed. So, to loop unroll over blockSize2, srcBLen should be greater
+   * than or equal to 4 */
+  if (srcBLen >= 4U) {
     /* Loop unroll over blockSize2, by 4 */
     blkCnt = blockSize2 >> 2U;
 
-    while (blkCnt > 0U)
-    {
+    while (blkCnt > 0U) {
       /* Set all accumulators to zero */
       acc0 = 0;
       acc1 = 0;
@@ -278,10 +267,10 @@ void arm_correlate_fast_q31(
       /* Apply loop unrolling and compute 4 MACs simultaneously. */
       k = srcBLen >> 2U;
 
-      /* First part of the processing with loop unrolling.  Compute 4 MACs at a time.
+      /* First part of the processing with loop unrolling.  Compute 4 MACs at a
+       *time.
        ** a second loop below computes MACs for the remaining 1 to 3 samples. */
-      do
-      {
+      do {
         /* Read y[0] sample */
         c0 = *py++;
         /* Read x[3] sample */
@@ -289,14 +278,13 @@ void arm_correlate_fast_q31(
 
         /* Perform the multiply-accumulate */
         /* acc0 +=  x[0] * y[0] */
-        acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32);
+        acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x0 * c0)) >> 32);
         /* acc1 +=  x[1] * y[0] */
-        acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32);
+        acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x1 * c0)) >> 32);
         /* acc2 +=  x[2] * y[0] */
-        acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x2 * c0)) >> 32);
+        acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x2 * c0)) >> 32);
         /* acc3 +=  x[3] * y[0] */
-        acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x3 * c0)) >> 32);
-
+        acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x3 * c0)) >> 32);
 
         /* Read y[1] sample */
         c0 = *py++;
@@ -305,14 +293,13 @@ void arm_correlate_fast_q31(
 
         /* Perform the multiply-accumulate */
         /* acc0 +=  x[1] * y[1] */
-        acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x1 * c0)) >> 32);
+        acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x1 * c0)) >> 32);
         /* acc1 +=  x[2] * y[1] */
-        acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x2 * c0)) >> 32);
+        acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x2 * c0)) >> 32);
         /* acc2 +=  x[3] * y[1] */
-        acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x3 * c0)) >> 32);
+        acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x3 * c0)) >> 32);
         /* acc3 +=  x[4] * y[1] */
-        acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x0 * c0)) >> 32);
-
+        acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x0 * c0)) >> 32);
 
         /* Read y[2] sample */
         c0 = *py++;
@@ -321,14 +308,13 @@ void arm_correlate_fast_q31(
 
         /* Perform the multiply-accumulates */
         /* acc0 +=  x[2] * y[2] */
-        acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x2 * c0)) >> 32);
+        acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x2 * c0)) >> 32);
         /* acc1 +=  x[3] * y[2] */
-        acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x3 * c0)) >> 32);
+        acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x3 * c0)) >> 32);
         /* acc2 +=  x[4] * y[2] */
-        acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x0 * c0)) >> 32);
+        acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x0 * c0)) >> 32);
         /* acc3 +=  x[5] * y[2] */
-        acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x1 * c0)) >> 32);
-
+        acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x1 * c0)) >> 32);
 
         /* Read y[3] sample */
         c0 = *py++;
@@ -337,14 +323,13 @@ void arm_correlate_fast_q31(
 
         /* Perform the multiply-accumulates */
         /* acc0 +=  x[3] * y[3] */
-        acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x3 * c0)) >> 32);
+        acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x3 * c0)) >> 32);
         /* acc1 +=  x[4] * y[3] */
-        acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x0 * c0)) >> 32);
+        acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x0 * c0)) >> 32);
         /* acc2 +=  x[5] * y[3] */
-        acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x1 * c0)) >> 32);
+        acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x1 * c0)) >> 32);
         /* acc3 +=  x[6] * y[3] */
-        acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x2 * c0)) >> 32);
-
+        acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x2 * c0)) >> 32);
 
       } while (--k);
 
@@ -352,8 +337,7 @@ void arm_correlate_fast_q31(
        ** No loop unrolling is used. */
       k = srcBLen % 0x4U;
 
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Read y[4] sample */
         c0 = *py++;
         /* Read x[7] sample */
@@ -361,13 +345,13 @@ void arm_correlate_fast_q31(
 
         /* Perform the multiply-accumulates */
         /* acc0 +=  x[4] * y[4] */
-        acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32);
+        acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x0 * c0)) >> 32);
         /* acc1 +=  x[5] * y[4] */
-        acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32);
+        acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x1 * c0)) >> 32);
         /* acc2 +=  x[6] * y[4] */
-        acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x2 * c0)) >> 32);
+        acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x2 * c0)) >> 32);
         /* acc3 +=  x[7] * y[4] */
-        acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x3 * c0)) >> 32);
+        acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x3 * c0)) >> 32);
 
         /* Reuse the present samples for the next MAC */
         x0 = x1;
@@ -379,17 +363,18 @@ void arm_correlate_fast_q31(
       }
 
       /* Store the result in the accumulator in the destination buffer. */
-      *pOut = (q31_t) (acc0 << 1);
-      /* Destination pointer is updated according to the address modifier, inc */
+      *pOut = (q31_t)(acc0 << 1);
+      /* Destination pointer is updated according to the address modifier, inc
+       */
       pOut += inc;
 
-      *pOut = (q31_t) (acc1 << 1);
+      *pOut = (q31_t)(acc1 << 1);
       pOut += inc;
 
-      *pOut = (q31_t) (acc2 << 1);
+      *pOut = (q31_t)(acc2 << 1);
       pOut += inc;
 
-      *pOut = (q31_t) (acc3 << 1);
+      *pOut = (q31_t)(acc3 << 1);
       pOut += inc;
 
       /* Increment the pointer pIn1 index, count by 4 */
@@ -403,31 +388,27 @@ void arm_correlate_fast_q31(
       blkCnt--;
     }
 
-    /* If the blockSize2 is not a multiple of 4, compute any remaining output samples here.
+    /* If the blockSize2 is not a multiple of 4, compute any remaining output
+     *samples here.
      ** No loop unrolling is used. */
     blkCnt = blockSize2 % 0x4U;
 
-    while (blkCnt > 0U)
-    {
+    while (blkCnt > 0U) {
       /* Accumulator is made zero for every iteration */
       sum = 0;
 
       /* Apply loop unrolling and compute 4 MACs simultaneously. */
       k = srcBLen >> 2U;
 
-      /* First part of the processing with loop unrolling.  Compute 4 MACs at a time.
+      /* First part of the processing with loop unrolling.  Compute 4 MACs at a
+       *time.
        ** a second loop below computes MACs for the remaining 1 to 3 samples. */
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Perform the multiply-accumulates */
-        sum = (q31_t) ((((q63_t) sum << 32) +
-                        ((q63_t) *px++ * (*py++))) >> 32);
-        sum = (q31_t) ((((q63_t) sum << 32) +
-                        ((q63_t) *px++ * (*py++))) >> 32);
-        sum = (q31_t) ((((q63_t) sum << 32) +
-                        ((q63_t) *px++ * (*py++))) >> 32);
-        sum = (q31_t) ((((q63_t) sum << 32) +
-                        ((q63_t) *px++ * (*py++))) >> 32);
+        sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py++))) >> 32);
+        sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py++))) >> 32);
+        sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py++))) >> 32);
+        sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py++))) >> 32);
 
         /* Decrement loop counter */
         k--;
@@ -437,11 +418,9 @@ void arm_correlate_fast_q31(
        ** No loop unrolling is used. */
       k = srcBLen % 0x4U;
 
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Perform the multiply-accumulate */
-        sum = (q31_t) ((((q63_t) sum << 32) +
-                        ((q63_t) *px++ * (*py++))) >> 32);
+        sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py++))) >> 32);
 
         /* Decrement loop counter */
         k--;
@@ -449,7 +428,8 @@ void arm_correlate_fast_q31(
 
       /* Store the result in the accumulator in the destination buffer. */
       *pOut = sum << 1;
-      /* Destination pointer is updated according to the address modifier, inc */
+      /* Destination pointer is updated according to the address modifier, inc
+       */
       pOut += inc;
 
       /* Increment MAC count */
@@ -462,26 +442,21 @@ void arm_correlate_fast_q31(
       /* Decrement loop counter */
       blkCnt--;
     }
-  }
-  else
-  {
+  } else {
     /* If the srcBLen is not a multiple of 4,
      * the blockSize2 loop cannot be unrolled by 4 */
     blkCnt = blockSize2;
 
-    while (blkCnt > 0U)
-    {
+    while (blkCnt > 0U) {
       /* Accumulator is made zero for every iteration */
       sum = 0;
 
       /* srcBLen number of MACS should be performed */
       k = srcBLen;
 
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Perform the multiply-accumulate */
-        sum = (q31_t) ((((q63_t) sum << 32) +
-                        ((q63_t) *px++ * (*py++))) >> 32);
+        sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py++))) >> 32);
 
         /* Decrement loop counter */
         k--;
@@ -489,7 +464,8 @@ void arm_correlate_fast_q31(
 
       /* Store the result in the accumulator in the destination buffer. */
       *pOut = sum << 1;
-      /* Destination pointer is updated according to the address modifier, inc */
+      /* Destination pointer is updated according to the address modifier, inc
+       */
       pOut += inc;
 
       /* Increment MAC count */
@@ -504,13 +480,13 @@ void arm_correlate_fast_q31(
     }
   }
 
-
   /* --------------------------
    * Initializations of stage3
    * -------------------------*/
 
-  /* sum += x[srcALen-srcBLen+1] * y[0] + x[srcALen-srcBLen+2] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
-   * sum += x[srcALen-srcBLen+2] * y[0] + x[srcALen-srcBLen+3] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
+  /* sum += x[srcALen-srcBLen+1] * y[0] + x[srcALen-srcBLen+2] * y[1] +...+
+   * x[srcALen-1] * y[srcBLen-1] sum += x[srcALen-srcBLen+2] * y[0] +
+   * x[srcALen-srcBLen+3] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
    * ....
    * sum +=  x[srcALen-2] * y[0] + x[srcALen-1] * y[1]
    * sum +=  x[srcALen-1] * y[0]
@@ -531,34 +507,29 @@ void arm_correlate_fast_q31(
    * Stage3 process
    * ------------------*/
 
-  while (blockSize3 > 0U)
-  {
+  while (blockSize3 > 0U) {
     /* Accumulator is made zero for every iteration */
     sum = 0;
 
     /* Apply loop unrolling and compute 4 MACs simultaneously. */
     k = count >> 2U;
 
-    /* First part of the processing with loop unrolling.  Compute 4 MACs at a time.
+    /* First part of the processing with loop unrolling.  Compute 4 MACs at a
+     *time.
      ** a second loop below computes MACs for the remaining 1 to 3 samples. */
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* Perform the multiply-accumulate */
       /* sum += x[srcALen - srcBLen + 4] * y[3] */
-      sum = (q31_t) ((((q63_t) sum << 32) +
-                      ((q63_t) *px++ * (*py++))) >> 32);
+      sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py++))) >> 32);
 
       /* sum += x[srcALen - srcBLen + 3] * y[2] */
-      sum = (q31_t) ((((q63_t) sum << 32) +
-                      ((q63_t) *px++ * (*py++))) >> 32);
+      sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py++))) >> 32);
 
       /* sum += x[srcALen - srcBLen + 2] * y[1] */
-      sum = (q31_t) ((((q63_t) sum << 32) +
-                      ((q63_t) *px++ * (*py++))) >> 32);
+      sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py++))) >> 32);
 
       /* sum += x[srcALen - srcBLen + 1] * y[0] */
-      sum = (q31_t) ((((q63_t) sum << 32) +
-                      ((q63_t) *px++ * (*py++))) >> 32);
+      sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py++))) >> 32);
 
       /* Decrement loop counter */
       k--;
@@ -568,11 +539,9 @@ void arm_correlate_fast_q31(
      ** No loop unrolling is used. */
     k = count % 0x4U;
 
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* Perform the multiply-accumulate */
-      sum = (q31_t) ((((q63_t) sum << 32) +
-                      ((q63_t) *px++ * (*py++))) >> 32);
+      sum = (q31_t)((((q63_t)sum << 32) + ((q63_t)*px++ * (*py++))) >> 32);
 
       /* Decrement loop counter */
       k--;
@@ -593,7 +562,6 @@ void arm_correlate_fast_q31(
     /* Decrement loop counter */
     blockSize3--;
   }
-
 }
 
 /**
diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_opt_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_opt_q15.c
index d46d9a0..7c4e248 100644
--- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_opt_q15.c
+++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_opt_q15.c
@@ -43,60 +43,64 @@
   @param[in]     srcALen    length of the first input sequence
   @param[in]     pSrcB      points to the second input sequence
   @param[in]     srcBLen    length of the second input sequence
-  @param[out]    pDst       points to the location where the output result is written.  Length 2 * max(srcALen, srcBLen) - 1.
-  @param[in]     pScratch   points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
+  @param[out]    pDst       points to the location where the output result is
+ written.  Length 2 * max(srcALen, srcBLen) - 1.
+  @param[in]     pScratch   points to scratch buffer of size max(srcALen,
+ srcBLen) + 2*min(srcALen, srcBLen) - 2.
   @return        none
 
   @par           Scaling and Overflow Behavior
-                   The function is implemented using a 64-bit internal accumulator.
-                   Both inputs are in 1.15 format and multiplications yield a 2.30 result.
-                   The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format.
-                   This approach provides 33 guard bits and there is no risk of overflow.
-                   The 34.30 result is then truncated to 34.15 format by discarding the low 15 bits and then saturated to 1.15 format.
+                   The function is implemented using a 64-bit internal
+ accumulator. Both inputs are in 1.15 format and multiplications yield a 2.30
+ result. The 2.30 intermediate results are accumulated in a 64-bit accumulator
+ in 34.30 format. This approach provides 33 guard bits and there is no risk of
+ overflow. The 34.30 result is then truncated to 34.15 format by discarding the
+ low 15 bits and then saturated to 1.15 format.
 
  @remark
-                   Refer to \ref arm_correlate_fast_q15() for a faster but less precise version of this function.
+                   Refer to \ref arm_correlate_fast_q15() for a faster but less
+ precise version of this function.
  */
 
-void arm_correlate_opt_q15(
-  const q15_t * pSrcA,
-        uint32_t srcALen,
-  const q15_t * pSrcB,
-        uint32_t srcBLen,
-        q15_t * pDst,
-        q15_t * pScratch)
-{
-        q63_t acc0;                                    /* Accumulators */
-        q15_t *pOut = pDst;                            /* Output pointer */
-        q15_t *pScr1;                                  /* Temporary pointer for scratch1 */
-  const q15_t *pIn1;                                   /* InputA pointer */
-  const q15_t *pIn2;                                   /* InputB pointer */
-  const q15_t *py;                                     /* Intermediate inputB pointer */
-        uint32_t j, blkCnt, outBlockSize;              /* Loop counter */
-        int32_t inc = 1;                               /* Output pointer increment */
-        uint32_t tapCnt;
+void arm_correlate_opt_q15(const q15_t *pSrcA, uint32_t srcALen,
+                           const q15_t *pSrcB, uint32_t srcBLen, q15_t *pDst,
+                           q15_t *pScratch) {
+  q63_t acc0;                       /* Accumulators */
+  q15_t *pOut = pDst;               /* Output pointer */
+  q15_t *pScr1;                     /* Temporary pointer for scratch1 */
+  const q15_t *pIn1;                /* InputA pointer */
+  const q15_t *pIn2;                /* InputB pointer */
+  const q15_t *py;                  /* Intermediate inputB pointer */
+  uint32_t j, blkCnt, outBlockSize; /* Loop counter */
+  int32_t inc = 1;                  /* Output pointer increment */
+  uint32_t tapCnt;
 
-#if defined (ARM_MATH_LOOPUNROLL)
-        q63_t acc1, acc2, acc3;                        /* Accumulators */
-        q31_t x1, x2, x3;                              /* Temporary variables for holding input1 and input2 values */
-        q31_t y1, y2;                                  /* State variables */
+#if defined(ARM_MATH_LOOPUNROLL)
+  q63_t acc1, acc2, acc3; /* Accumulators */
+  q31_t x1, x2,
+      x3;       /* Temporary variables for holding input1 and input2 values */
+  q31_t y1, y2; /* State variables */
 #endif
 
   /* The algorithm implementation is based on the lengths of the inputs. */
   /* srcB is always made to slide across srcA. */
   /* So srcBLen is always considered as shorter or equal to srcALen */
   /* But CORR(x, y) is reverse of CORR(y, x) */
-  /* So, when srcBLen > srcALen, output pointer is made to point to the end of the output buffer */
+  /* So, when srcBLen > srcALen, output pointer is made to point to the end of
+   * the output buffer */
   /* and the destination pointer modifier, inc is set to -1 */
-  /* If srcALen > srcBLen, zero pad has to be done to srcB to make the two inputs of same length */
+  /* If srcALen > srcBLen, zero pad has to be done to srcB to make the two
+   * inputs of same length */
   /* But to improve the performance,
-   * we include zeroes in the output instead of zero padding either of the the inputs*/
+   * we include zeroes in the output instead of zero padding either of the the
+   * inputs*/
   /* If srcALen > srcBLen,
-   * (srcALen - srcBLen) zeroes has to included in the starting of the output buffer */
+   * (srcALen - srcBLen) zeroes has to included in the starting of the output
+   * buffer */
   /* If srcALen < srcBLen,
-   * (srcALen - srcBLen) zeroes has to included in the ending of the output buffer */
-  if (srcALen >= srcBLen)
-  {
+   * (srcALen - srcBLen) zeroes has to included in the ending of the output
+   * buffer */
+  if (srcALen >= srcBLen) {
     /* Initialization of inputA pointer */
     pIn1 = pSrcA;
 
@@ -114,9 +118,7 @@ void arm_correlate_opt_q15(
 
     /* Updating the pointer position to non zero value */
     pOut += j;
-  }
-  else
-  {
+  } else {
     /* Initialization of inputA pointer */
     pIn1 = pSrcB;
 
@@ -150,7 +152,6 @@ void arm_correlate_opt_q15(
   /* Update pointers */
   pScr1 += srcALen;
 
-
   /* Fill (srcBLen - 1U) zeros at end of scratch buffer */
   arm_fill_q15(0, pScr1, (srcBLen - 1U));
 
@@ -160,15 +161,13 @@ void arm_correlate_opt_q15(
   /* Temporary pointer for scratch2 */
   py = pIn2;
 
-
   /* Actual correlation process starts here */
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
   /* Loop unrolling: Compute 4 outputs at a time */
   blkCnt = (srcALen + srcBLen - 1U) >> 2;
 
-  while (blkCnt > 0)
-  {
+  while (blkCnt > 0) {
     /* Initialze temporary scratch pointer as scratch1 */
     pScr1 = pScratch;
 
@@ -179,18 +178,17 @@ void arm_correlate_opt_q15(
     acc3 = 0;
 
     /* Read two samples from scratch1 buffer */
-    x1 = read_q15x2_ia (&pScr1);
+    x1 = read_q15x2_ia(&pScr1);
 
     /* Read next two samples from scratch1 buffer */
-    x2 = read_q15x2_ia (&pScr1);
+    x2 = read_q15x2_ia(&pScr1);
 
     tapCnt = (srcBLen) >> 2U;
 
-    while (tapCnt > 0U)
-    {
+    while (tapCnt > 0U) {
       /* Read four samples from smaller buffer */
-      y1 = read_q15x2_ia ((q15_t **) &pIn2);
-      y2 = read_q15x2_ia ((q15_t **) &pIn2);
+      y1 = read_q15x2_ia((q15_t **)&pIn2);
+      y2 = read_q15x2_ia((q15_t **)&pIn2);
 
       /* multiply and accumlate */
       acc0 = __SMLALD(x1, y1, acc0);
@@ -207,7 +205,7 @@ void arm_correlate_opt_q15(
       acc1 = __SMLALDX(x3, y1, acc1);
 
       /* Read next two samples from scratch1 buffer */
-      x1 = read_q15x2_ia (&pScr1);
+      x1 = read_q15x2_ia(&pScr1);
 
       /* multiply and accumlate */
       acc0 = __SMLALD(x2, y2, acc0);
@@ -223,7 +221,7 @@ void arm_correlate_opt_q15(
       acc3 = __SMLALDX(x3, y1, acc3);
       acc1 = __SMLALDX(x3, y2, acc1);
 
-      x2 = read_q15x2_ia (&pScr1);
+      x2 = read_q15x2_ia(&pScr1);
 
 #ifndef ARM_MATH_BIG_ENDIAN
       x3 = __PKHBT(x2, x1, 0);
@@ -237,14 +235,14 @@ void arm_correlate_opt_q15(
       tapCnt--;
     }
 
-    /* Update scratch pointer for remaining samples of smaller length sequence */
+    /* Update scratch pointer for remaining samples of smaller length sequence
+     */
     pScr1 -= 4U;
 
     /* apply same above for remaining samples of smaller length sequence */
-    tapCnt = (srcBLen) & 3U;
+    tapCnt = (srcBLen)&3U;
 
-    while (tapCnt > 0U)
-    {
+    while (tapCnt > 0U) {
       /* accumlate the results */
       acc0 += (*pScr1++ * *pIn2);
       acc1 += (*pScr1++ * *pIn2);
@@ -259,7 +257,6 @@ void arm_correlate_opt_q15(
 
     blkCnt--;
 
-
     /* Store the results in the accumulators in the destination buffer. */
     *pOut = (__SSAT(acc0 >> 15U, 16));
     pOut += inc;
@@ -276,7 +273,6 @@ void arm_correlate_opt_q15(
     pScratch += 4U;
   }
 
-
   /* Loop unrolling: Compute remaining outputs */
   blkCnt = (srcALen + srcBLen - 1U) & 0x3;
 
@@ -288,8 +284,7 @@ void arm_correlate_opt_q15(
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
   /* Calculate correlation for remaining samples of Bigger length sequence */
-  while (blkCnt > 0)
-  {
+  while (blkCnt > 0) {
     /* Initialze temporary scratch pointer as scratch1 */
     pScr1 = pScratch;
 
@@ -298,8 +293,7 @@ void arm_correlate_opt_q15(
 
     tapCnt = (srcBLen) >> 1U;
 
-    while (tapCnt > 0U)
-    {
+    while (tapCnt > 0U) {
 
       /* Read next two samples from scratch1 buffer */
       acc0 += (*pScr1++ * *pIn2++);
@@ -309,11 +303,10 @@ void arm_correlate_opt_q15(
       tapCnt--;
     }
 
-    tapCnt = (srcBLen) & 1U;
+    tapCnt = (srcBLen)&1U;
 
     /* apply same above for remaining samples of smaller length sequence */
-    while (tapCnt > 0U)
-    {
+    while (tapCnt > 0U) {
       /* accumlate the results */
       acc0 += (*pScr1++ * *pIn2++);
 
@@ -325,7 +318,7 @@ void arm_correlate_opt_q15(
 
     /* The result is in 2.30 format.  Convert to 1.15 with saturation.
        Then store the output in the destination buffer. */
-    *pOut = (q15_t) (__SSAT((acc0 >> 15), 16));
+    *pOut = (q15_t)(__SSAT((acc0 >> 15), 16));
     pOut += inc;
 
     /* Initialization of inputB pointer */
@@ -333,7 +326,6 @@ void arm_correlate_opt_q15(
 
     pScratch += 1U;
   }
-
 }
 
 /**
diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_opt_q7.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_opt_q7.c
index 035bfba..8a0c182 100644
--- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_opt_q7.c
+++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_opt_q7.c
@@ -43,55 +43,58 @@
   @param[in]     srcALen    length of the first input sequence
   @param[in]     pSrcB      points to the second input sequence
   @param[in]     srcBLen    length of the second input sequence
-  @param[out]    pDst       points to the location where the output result is written.  Length 2 * max(srcALen, srcBLen) - 1.
-  @param[in]     pScratch1  points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
-  @param[in]     pScratch2  points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
+  @param[out]    pDst       points to the location where the output result is
+  written.  Length 2 * max(srcALen, srcBLen) - 1.
+  @param[in]     pScratch1  points to scratch buffer(of type q15_t) of size
+  max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
+  @param[in]     pScratch2  points to scratch buffer (of type q15_t) of size
+  min(srcALen, srcBLen).
   @return        none
 
   @par           Scaling and Overflow Behavior
-                   The function is implemented using a 32-bit internal accumulator.
-                   Both the inputs are represented in 1.7 format and multiplications yield a 2.14 result.
-                   The 2.14 intermediate results are accumulated in a 32-bit accumulator in 18.14 format.
-                   This approach provides 17 guard bits and there is no risk of overflow as long as max(srcALen, srcBLen)<131072.
-                   The 18.14 result is then truncated to 18.7 format by discarding the low 7 bits and then saturated to 1.7 format.
+                   The function is implemented using a 32-bit internal
+  accumulator. Both the inputs are represented in 1.7 format and multiplications
+  yield a 2.14 result. The 2.14 intermediate results are accumulated in a 32-bit
+  accumulator in 18.14 format. This approach provides 17 guard bits and there is
+  no risk of overflow as long as max(srcALen, srcBLen)<131072.
+                   The 18.14 result is then truncated to 18.7 format by
+  discarding the low 7 bits and then saturated to 1.7 format.
  */
 
-void arm_correlate_opt_q7(
-  const q7_t * pSrcA,
-        uint32_t srcALen,
-  const q7_t * pSrcB,
-        uint32_t srcBLen,
-        q7_t * pDst,
-        q15_t * pScratch1,
-        q15_t * pScratch2)
-{
-        q15_t *pScr1 = pScratch1;                      /* Temporary pointer for scratch */
-        q15_t *pScr2 = pScratch2;                      /* Temporary pointer for scratch */
-        q15_t x4;                                      /* Temporary input variable */
-        q15_t *py;                                     /* Temporary input2 pointer */
-        q31_t acc0, acc1, acc2, acc3;                  /* Accumulators */
-  const q7_t *pIn1, *pIn2;                             /* InputA and inputB pointer */
-        uint32_t j, k, blkCnt, tapCnt;                 /* Loop counter */
-        int32_t inc = 1;                               /* Output pointer increment */
-        uint32_t outBlockSize;                         /* Loop counter */
-        q31_t x1, x2, x3, y1;                          /* Temporary input variables */
-        q7_t *pOut = pDst;                             /* Output pointer */
+void arm_correlate_opt_q7(const q7_t *pSrcA, uint32_t srcALen,
+                          const q7_t *pSrcB, uint32_t srcBLen, q7_t *pDst,
+                          q15_t *pScratch1, q15_t *pScratch2) {
+  q15_t *pScr1 = pScratch1;      /* Temporary pointer for scratch */
+  q15_t *pScr2 = pScratch2;      /* Temporary pointer for scratch */
+  q15_t x4;                      /* Temporary input variable */
+  q15_t *py;                     /* Temporary input2 pointer */
+  q31_t acc0, acc1, acc2, acc3;  /* Accumulators */
+  const q7_t *pIn1, *pIn2;       /* InputA and inputB pointer */
+  uint32_t j, k, blkCnt, tapCnt; /* Loop counter */
+  int32_t inc = 1;               /* Output pointer increment */
+  uint32_t outBlockSize;         /* Loop counter */
+  q31_t x1, x2, x3, y1;          /* Temporary input variables */
+  q7_t *pOut = pDst;             /* Output pointer */
 
   /* The algorithm implementation is based on the lengths of the inputs. */
   /* srcB is always made to slide across srcA. */
   /* So srcBLen is always considered as shorter or equal to srcALen */
   /* But CORR(x, y) is reverse of CORR(y, x) */
-  /* So, when srcBLen > srcALen, output pointer is made to point to the end of the output buffer */
+  /* So, when srcBLen > srcALen, output pointer is made to point to the end of
+   * the output buffer */
   /* and the destination pointer modifier, inc is set to -1 */
-  /* If srcALen > srcBLen, zero pad has to be done to srcB to make the two inputs of same length */
+  /* If srcALen > srcBLen, zero pad has to be done to srcB to make the two
+   * inputs of same length */
   /* But to improve the performance,
-   * we include zeroes in the output instead of zero padding either of the the inputs*/
+   * we include zeroes in the output instead of zero padding either of the the
+   * inputs*/
   /* If srcALen > srcBLen,
-   * (srcALen - srcBLen) zeroes has to included in the starting of the output buffer */
+   * (srcALen - srcBLen) zeroes has to included in the starting of the output
+   * buffer */
   /* If srcALen < srcBLen,
-   * (srcALen - srcBLen) zeroes has to included in the ending of the output buffer */
-  if (srcALen >= srcBLen)
-  {
+   * (srcALen - srcBLen) zeroes has to included in the ending of the output
+   * buffer */
+  if (srcALen >= srcBLen) {
     /* Initialization of inputA pointer */
     pIn1 = pSrcA;
 
@@ -109,9 +112,7 @@ void arm_correlate_opt_q7(
 
     /* Updating the pointer position to non zero value */
     pOut += j;
-  }
-  else
-  {
+  } else {
     /* Initialization of inputA pointer */
     pIn1 = pSrcB;
 
@@ -131,22 +132,20 @@ void arm_correlate_opt_q7(
     inc = -1;
   }
 
-
   /* Copy (srcBLen) samples in scratch buffer */
   k = srcBLen >> 2U;
 
-  /* First part of the processing with loop unrolling copies 4 data points at a time.
-     a second loop below copies for the remaining 1 to 3 samples. */
-  while (k > 0U)
-  {
+  /* First part of the processing with loop unrolling copies 4 data points at a
+     time. a second loop below copies for the remaining 1 to 3 samples. */
+  while (k > 0U) {
     /* copy second buffer in reversal manner */
-    x4 = (q15_t) *pIn2++;
+    x4 = (q15_t)*pIn2++;
     *pScr2++ = x4;
-    x4 = (q15_t) *pIn2++;
+    x4 = (q15_t)*pIn2++;
     *pScr2++ = x4;
-    x4 = (q15_t) *pIn2++;
+    x4 = (q15_t)*pIn2++;
     *pScr2++ = x4;
-    x4 = (q15_t) *pIn2++;
+    x4 = (q15_t)*pIn2++;
     *pScr2++ = x4;
 
     /* Decrement loop counter */
@@ -157,10 +156,9 @@ void arm_correlate_opt_q7(
      No loop unrolling is used. */
   k = srcBLen % 0x4U;
 
-  while (k > 0U)
-  {
+  while (k > 0U) {
     /* copy second buffer in reversal manner for remaining samples */
-    x4 = (q15_t) *pIn2++;
+    x4 = (q15_t)*pIn2++;
     *pScr2++ = x4;
 
     /* Decrement loop counter */
@@ -177,18 +175,17 @@ void arm_correlate_opt_q7(
   /* Apply loop unrolling and do 4 Copies simultaneously. */
   k = srcALen >> 2U;
 
-  /* First part of the processing with loop unrolling copies 4 data points at a time.
-     a second loop below copies for the remaining 1 to 3 samples. */
-  while (k > 0U)
-  {
+  /* First part of the processing with loop unrolling copies 4 data points at a
+     time. a second loop below copies for the remaining 1 to 3 samples. */
+  while (k > 0U) {
     /* copy second buffer in reversal manner */
-    x4 = (q15_t) *pIn1++;
+    x4 = (q15_t)*pIn1++;
     *pScr1++ = x4;
-    x4 = (q15_t) *pIn1++;
+    x4 = (q15_t)*pIn1++;
     *pScr1++ = x4;
-    x4 = (q15_t) *pIn1++;
+    x4 = (q15_t)*pIn1++;
     *pScr1++ = x4;
-    x4 = (q15_t) *pIn1++;
+    x4 = (q15_t)*pIn1++;
     *pScr1++ = x4;
 
     /* Decrement loop counter */
@@ -199,10 +196,9 @@ void arm_correlate_opt_q7(
      No loop unrolling is used. */
   k = srcALen % 0x4U;
 
-  while (k > 0U)
-  {
+  while (k > 0U) {
     /* copy second buffer in reversal manner for remaining samples */
-    x4 = (q15_t) * pIn1++;
+    x4 = (q15_t)*pIn1++;
     *pScr1++ = x4;
 
     /* Decrement the loop counter */
@@ -224,8 +220,7 @@ void arm_correlate_opt_q7(
   /* Actual correlation process starts here */
   blkCnt = (srcALen + srcBLen - 1U) >> 2;
 
-  while (blkCnt > 0)
-  {
+  while (blkCnt > 0) {
     /* Initialze temporary scratch pointer as scratch1 */
     pScr1 = pScratch1;
 
@@ -236,17 +231,16 @@ void arm_correlate_opt_q7(
     acc3 = 0;
 
     /* Read two samples from scratch1 buffer */
-    x1 = read_q15x2_ia (&pScr1);
+    x1 = read_q15x2_ia(&pScr1);
 
     /* Read next two samples from scratch1 buffer */
-    x2 = read_q15x2_ia (&pScr1);
+    x2 = read_q15x2_ia(&pScr1);
 
     tapCnt = (srcBLen) >> 2U;
 
-    while (tapCnt > 0U)
-    {
+    while (tapCnt > 0U) {
       /* Read four samples from smaller buffer */
-      y1 = read_q15x2_ia (&pScr2);
+      y1 = read_q15x2_ia(&pScr2);
 
       /* multiply and accumlate */
       acc0 = __SMLAD(x1, y1, acc0);
@@ -263,7 +257,7 @@ void arm_correlate_opt_q7(
       acc1 = __SMLADX(x3, y1, acc1);
 
       /* Read next two samples from scratch1 buffer */
-      x1 = read_q15x2_ia (&pScr1);
+      x1 = read_q15x2_ia(&pScr1);
 
       /* pack input data */
 #ifndef ARM_MATH_BIG_ENDIAN
@@ -275,7 +269,7 @@ void arm_correlate_opt_q7(
       acc3 = __SMLADX(x3, y1, acc3);
 
       /* Read four samples from smaller buffer */
-      y1 = read_q15x2_ia (&pScr2);
+      y1 = read_q15x2_ia(&pScr2);
 
       acc0 = __SMLAD(x2, y1, acc0);
 
@@ -283,7 +277,7 @@ void arm_correlate_opt_q7(
 
       acc1 = __SMLADX(x3, y1, acc1);
 
-      x2 = read_q15x2_ia (&pScr1);
+      x2 = read_q15x2_ia(&pScr1);
 
 #ifndef ARM_MATH_BIG_ENDIAN
       x3 = __PKHBT(x2, x1, 0);
@@ -297,14 +291,14 @@ void arm_correlate_opt_q7(
       tapCnt--;
     }
 
-    /* Update scratch pointer for remaining samples of smaller length sequence */
+    /* Update scratch pointer for remaining samples of smaller length sequence
+     */
     pScr1 -= 4U;
 
     /* apply same above for remaining samples of smaller length sequence */
-    tapCnt = (srcBLen) & 3U;
+    tapCnt = (srcBLen)&3U;
 
-    while (tapCnt > 0U)
-    {
+    while (tapCnt > 0U) {
       /* accumlate the results */
       acc0 += (*pScr1++ * *pScr2);
       acc1 += (*pScr1++ * *pScr2);
@@ -320,13 +314,13 @@ void arm_correlate_opt_q7(
     blkCnt--;
 
     /* Store the result in the accumulator in the destination buffer. */
-    *pOut = (q7_t) (__SSAT(acc0 >> 7U, 8));
+    *pOut = (q7_t)(__SSAT(acc0 >> 7U, 8));
     pOut += inc;
-    *pOut = (q7_t) (__SSAT(acc1 >> 7U, 8));
+    *pOut = (q7_t)(__SSAT(acc1 >> 7U, 8));
     pOut += inc;
-    *pOut = (q7_t) (__SSAT(acc2 >> 7U, 8));
+    *pOut = (q7_t)(__SSAT(acc2 >> 7U, 8));
     pOut += inc;
-    *pOut = (q7_t) (__SSAT(acc3 >> 7U, 8));
+    *pOut = (q7_t)(__SSAT(acc3 >> 7U, 8));
     pOut += inc;
 
     /* Initialization of inputB pointer */
@@ -338,8 +332,7 @@ void arm_correlate_opt_q7(
   blkCnt = (srcALen + srcBLen - 1U) & 0x3;
 
   /* Calculate correlation for remaining samples of Bigger length sequence */
-  while (blkCnt > 0)
-  {
+  while (blkCnt > 0) {
     /* Initialze temporary scratch pointer as scratch1 */
     pScr1 = pScratch1;
 
@@ -348,8 +341,7 @@ void arm_correlate_opt_q7(
 
     tapCnt = (srcBLen) >> 1U;
 
-    while (tapCnt > 0U)
-    {
+    while (tapCnt > 0U) {
       acc0 += (*pScr1++ * *pScr2++);
       acc0 += (*pScr1++ * *pScr2++);
 
@@ -357,11 +349,10 @@ void arm_correlate_opt_q7(
       tapCnt--;
     }
 
-    tapCnt = (srcBLen) & 1U;
+    tapCnt = (srcBLen)&1U;
 
     /* apply same above for remaining samples of smaller length sequence */
-    while (tapCnt > 0U)
-    {
+    while (tapCnt > 0U) {
       /* accumlate the results */
       acc0 += (*pScr1++ * *pScr2++);
 
@@ -372,7 +363,7 @@ void arm_correlate_opt_q7(
     blkCnt--;
 
     /* Store the result in the accumulator in the destination buffer. */
-    *pOut = (q7_t) (__SSAT(acc0 >> 7U, 8));
+    *pOut = (q7_t)(__SSAT(acc0 >> 7U, 8));
     pOut += inc;
 
     /* Initialization of inputB pointer */
@@ -380,7 +371,6 @@ void arm_correlate_opt_q7(
 
     pScratch1 += 1U;
   }
-
 }
 
 /**
diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_q15.c
index 9837875..460f081 100644
--- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_q15.c
+++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_q15.c
@@ -43,60 +43,64 @@
   @param[in]     srcALen    length of the first input sequence
   @param[in]     pSrcB      points to the second input sequence
   @param[in]     srcBLen    length of the second input sequence
-  @param[out]    pDst       points to the location where the output result is written.  Length 2 * max(srcALen, srcBLen) - 1.
+  @param[out]    pDst       points to the location where the output result is
+  written.  Length 2 * max(srcALen, srcBLen) - 1.
   @return        none
 
   @par           Scaling and Overflow Behavior
-                   The function is implemented using a 64-bit internal accumulator.
-                   Both inputs are in 1.15 format and multiplications yield a 2.30 result.
-                   The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format.
-                   This approach provides 33 guard bits and there is no risk of overflow.
-                   The 34.30 result is then truncated to 34.15 format by discarding the low 15 bits and then saturated to 1.15 format.
+                   The function is implemented using a 64-bit internal
+  accumulator. Both inputs are in 1.15 format and multiplications yield a 2.30
+  result. The 2.30 intermediate results are accumulated in a 64-bit accumulator
+  in 34.30 format. This approach provides 33 guard bits and there is no risk of
+  overflow. The 34.30 result is then truncated to 34.15 format by discarding the
+  low 15 bits and then saturated to 1.15 format.
 
   @remark
-                   Refer to \ref arm_correlate_fast_q15() for a faster but less precise version of this function.
+                   Refer to \ref arm_correlate_fast_q15() for a faster but less
+  precise version of this function.
   @remark
-                   Refer to \ref arm_correlate_opt_q15() for a faster implementation of this function using scratch buffers.
+                   Refer to \ref arm_correlate_opt_q15() for a faster
+  implementation of this function using scratch buffers.
  */
 
-void arm_correlate_q15(
-  const q15_t * pSrcA,
-        uint32_t srcALen,
-  const q15_t * pSrcB,
-        uint32_t srcBLen,
-        q15_t * pDst)
-{
+void arm_correlate_q15(const q15_t *pSrcA, uint32_t srcALen, const q15_t *pSrcB,
+                       uint32_t srcBLen, q15_t *pDst) {
 
-#if defined (ARM_MATH_DSP)
+#if defined(ARM_MATH_DSP)
 
-  const q15_t *pIn1;                                   /* InputA pointer */
-  const q15_t *pIn2;                                   /* InputB pointer */
-        q15_t *pOut = pDst;                            /* Output pointer */
-        q63_t sum, acc0, acc1, acc2, acc3;             /* Accumulators */
-  const q15_t *px;                                     /* Intermediate inputA pointer */
-  const q15_t *py;                                     /* Intermediate inputB pointer */
-  const q15_t *pSrc1;                                  /* Intermediate pointers */
-        q31_t x0, x1, x2, x3, c0;                      /* Temporary input variables for holding input and coefficient values */
-        uint32_t blockSize1, blockSize2, blockSize3;   /* Loop counters */
-        uint32_t j, k, count, blkCnt;                  /* Loop counters */
-        uint32_t outBlockSize;
-        int32_t inc = 1;                               /* Destination address modifier */
+  const q15_t *pIn1;                 /* InputA pointer */
+  const q15_t *pIn2;                 /* InputB pointer */
+  q15_t *pOut = pDst;                /* Output pointer */
+  q63_t sum, acc0, acc1, acc2, acc3; /* Accumulators */
+  const q15_t *px;                   /* Intermediate inputA pointer */
+  const q15_t *py;                   /* Intermediate inputB pointer */
+  const q15_t *pSrc1;                /* Intermediate pointers */
+  q31_t x0, x1, x2, x3, c0; /* Temporary input variables for holding input and
+                               coefficient values */
+  uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */
+  uint32_t j, k, count, blkCnt;                /* Loop counters */
+  uint32_t outBlockSize;
+  int32_t inc = 1; /* Destination address modifier */
 
   /* The algorithm implementation is based on the lengths of the inputs. */
   /* srcB is always made to slide across srcA. */
   /* So srcBLen is always considered as shorter or equal to srcALen */
   /* But CORR(x, y) is reverse of CORR(y, x) */
-  /* So, when srcBLen > srcALen, output pointer is made to point to the end of the output buffer */
+  /* So, when srcBLen > srcALen, output pointer is made to point to the end of
+   * the output buffer */
   /* and the destination pointer modifier, inc is set to -1 */
-  /* If srcALen > srcBLen, zero pad has to be done to srcB to make the two inputs of same length */
+  /* If srcALen > srcBLen, zero pad has to be done to srcB to make the two
+   * inputs of same length */
   /* But to improve the performance,
-   * we include zeroes in the output instead of zero padding either of the the inputs*/
+   * we include zeroes in the output instead of zero padding either of the the
+   * inputs*/
   /* If srcALen > srcBLen,
-   * (srcALen - srcBLen) zeroes has to included in the starting of the output buffer */
+   * (srcALen - srcBLen) zeroes has to included in the starting of the output
+   * buffer */
   /* If srcALen < srcBLen,
-   * (srcALen - srcBLen) zeroes has to included in the ending of the output buffer */
-  if (srcALen >= srcBLen)
-  {
+   * (srcALen - srcBLen) zeroes has to included in the ending of the output
+   * buffer */
+  if (srcALen >= srcBLen) {
     /* Initialization of inputA pointer */
     pIn1 = pSrcA;
 
@@ -114,9 +118,7 @@ void arm_correlate_q15(
 
     /* Updating the pointer position to non zero value */
     pOut += j;
-  }
-  else
-  {
+  } else {
     /* Initialization of inputA pointer */
     pIn1 = pSrcB;
 
@@ -137,12 +139,12 @@ void arm_correlate_q15(
   }
 
   /* The function is internally
-   * divided into three stages according to the number of multiplications that has to be
-   * taken place between inputA samples and inputB samples. In the first stage of the
-   * algorithm, the multiplications increase by one for every iteration.
-   * In the second stage of the algorithm, srcBLen number of multiplications are done.
-   * In the third stage of the algorithm, the multiplications decrease by one
-   * for every iteration. */
+   * divided into three stages according to the number of multiplications that
+   * has to be taken place between inputA samples and inputB samples. In the
+   * first stage of the algorithm, the multiplications increase by one for every
+   * iteration. In the second stage of the algorithm, srcBLen number of
+   * multiplications are done. In the third stage of the algorithm, the
+   * multiplications decrease by one for every iteration. */
 
   /* The algorithm is implemented in three stages.
      The loop counters of each stage is initiated here. */
@@ -176,23 +178,24 @@ void arm_correlate_q15(
    * ----------------------*/
 
   /* The first loop starts here */
-  while (blockSize1 > 0U)
-  {
+  while (blockSize1 > 0U) {
     /* Accumulator is made zero for every iteration */
     sum = 0;
 
     /* Apply loop unrolling and compute 4 MACs simultaneously. */
     k = count >> 2U;
 
-    /* First part of the processing with loop unrolling.  Compute 4 MACs at a time.
+    /* First part of the processing with loop unrolling.  Compute 4 MACs at a
+     *time.
      ** a second loop below computes MACs for the remaining 1 to 3 samples. */
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* Perform the multiply-accumulate */
       /* x[0] * y[srcBLen - 4] , x[1] * y[srcBLen - 3] */
-      sum = __SMLALD(read_q15x2_ia ((q15_t **) &px), read_q15x2_ia ((q15_t **) &py), sum);
+      sum = __SMLALD(read_q15x2_ia((q15_t **)&px), read_q15x2_ia((q15_t **)&py),
+                     sum);
       /* x[3] * y[srcBLen - 1] , x[2] * y[srcBLen - 2] */
-      sum = __SMLALD(read_q15x2_ia ((q15_t **) &px), read_q15x2_ia ((q15_t **) &py), sum);
+      sum = __SMLALD(read_q15x2_ia((q15_t **)&px), read_q15x2_ia((q15_t **)&py),
+                     sum);
 
       /* Decrement loop counter */
       k--;
@@ -202,8 +205,7 @@ void arm_correlate_q15(
      ** No loop unrolling is used. */
     k = count % 0x4U;
 
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* Perform the multiply-accumulate */
       /* x[0] * y[srcBLen - 1] */
       sum = __SMLALD(*px++, *py++, sum);
@@ -213,7 +215,7 @@ void arm_correlate_q15(
     }
 
     /* Store the result in the accumulator in the destination buffer. */
-    *pOut = (q15_t) (__SSAT((sum >> 15), 16));
+    *pOut = (q15_t)(__SSAT((sum >> 15), 16));
     /* Destination pointer is updated according to the address modifier, inc */
     pOut += inc;
 
@@ -235,7 +237,8 @@ void arm_correlate_q15(
   /* sum = x[0] * y[0] + x[1] * y[1] +...+ x[srcBLen-1] * y[srcBLen-1]
    * sum = x[1] * y[0] + x[2] * y[1] +...+ x[srcBLen] * y[srcBLen-1]
    * ....
-   * sum = x[srcALen-srcBLen-2] * y[0] + x[srcALen-srcBLen-1] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
+   * sum = x[srcALen-srcBLen-2] * y[0] + x[srcALen-srcBLen-1] * y[1] +...+
+   * x[srcALen-1] * y[srcBLen-1]
    */
 
   /* Working pointer of inputA */
@@ -251,16 +254,14 @@ void arm_correlate_q15(
    * Stage2 process
    * ------------------*/
 
-  /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed.
-   * So, to loop unroll over blockSize2,
-   * srcBLen should be greater than or equal to 4 */
-  if (srcBLen >= 4U)
-  {
+  /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are
+   * performed. So, to loop unroll over blockSize2, srcBLen should be greater
+   * than or equal to 4 */
+  if (srcBLen >= 4U) {
     /* Loop unrolling: Compute 4 outputs at a time */
     blkCnt = blockSize2 >> 2U;
 
-    while (blkCnt > 0U)
-    {
+    while (blkCnt > 0U) {
       /* Set all accumulators to zero */
       acc0 = 0;
       acc1 = 0;
@@ -268,22 +269,22 @@ void arm_correlate_q15(
       acc3 = 0;
 
       /* read x[0], x[1] samples */
-      x0 = read_q15x2 ((q15_t *) px);
+      x0 = read_q15x2((q15_t *)px);
 
       /* read x[1], x[2] samples */
-      x1 = read_q15x2 ((q15_t *) px + 1);
+      x1 = read_q15x2((q15_t *)px + 1);
       px += 2U;
 
       /* Apply loop unrolling and compute 4 MACs simultaneously. */
       k = srcBLen >> 2U;
 
-      /* First part of the processing with loop unrolling.  Compute 4 MACs at a time.
+      /* First part of the processing with loop unrolling.  Compute 4 MACs at a
+       *time.
        ** a second loop below computes MACs for the remaining 1 to 3 samples. */
-      do
-      {
+      do {
         /* Read the first two inputB samples using SIMD:
          * y[0] and y[1] */
-        c0 = read_q15x2_ia ((q15_t **) &py);
+        c0 = read_q15x2_ia((q15_t **)&py);
 
         /* acc0 +=  x[0] * y[0] + x[1] * y[1] */
         acc0 = __SMLALD(x0, c0, acc0);
@@ -292,10 +293,10 @@ void arm_correlate_q15(
         acc1 = __SMLALD(x1, c0, acc1);
 
         /* Read x[2], x[3] */
-        x2 = read_q15x2 ((q15_t *) px);
+        x2 = read_q15x2((q15_t *)px);
 
         /* Read x[3], x[4] */
-        x3 = read_q15x2 ((q15_t *) px + 1);
+        x3 = read_q15x2((q15_t *)px + 1);
 
         /* acc2 +=  x[2] * y[0] + x[3] * y[1] */
         acc2 = __SMLALD(x2, c0, acc2);
@@ -304,7 +305,7 @@ void arm_correlate_q15(
         acc3 = __SMLALD(x3, c0, acc3);
 
         /* Read y[2] and y[3] */
-        c0 = read_q15x2_ia ((q15_t **) &py);
+        c0 = read_q15x2_ia((q15_t **)&py);
 
         /* acc0 +=  x[2] * y[2] + x[3] * y[3] */
         acc0 = __SMLALD(x2, c0, acc0);
@@ -313,10 +314,10 @@ void arm_correlate_q15(
         acc1 = __SMLALD(x3, c0, acc1);
 
         /* Read x[4], x[5] */
-        x0 = read_q15x2 ((q15_t *) px + 2);
+        x0 = read_q15x2((q15_t *)px + 2);
 
         /* Read x[5], x[6] */
-        x1 = read_q15x2 ((q15_t *) px + 3);
+        x1 = read_q15x2((q15_t *)px + 3);
         px += 4U;
 
         /* acc2 +=  x[4] * y[2] + x[5] * y[3] */
@@ -331,37 +332,35 @@ void arm_correlate_q15(
        ** No loop unrolling is used. */
       k = srcBLen % 0x4U;
 
-      if (k == 1U)
-      {
+      if (k == 1U) {
         /* Read y[4] */
         c0 = *py;
-#ifdef  ARM_MATH_BIG_ENDIAN
+#ifdef ARM_MATH_BIG_ENDIAN
         c0 = c0 << 16U;
 #else
         c0 = c0 & 0x0000FFFF;
 #endif /* #ifdef  ARM_MATH_BIG_ENDIAN */
 
         /* Read x[7] */
-        x3 = read_q15x2 ((q15_t *) px);
+        x3 = read_q15x2((q15_t *)px);
         px++;
 
         /* Perform the multiply-accumulate */
-        acc0 = __SMLALD (x0, c0, acc0);
-        acc1 = __SMLALD (x1, c0, acc1);
+        acc0 = __SMLALD(x0, c0, acc0);
+        acc1 = __SMLALD(x1, c0, acc1);
         acc2 = __SMLALDX(x1, c0, acc2);
         acc3 = __SMLALDX(x3, c0, acc3);
       }
 
-      if (k == 2U)
-      {
+      if (k == 2U) {
         /* Read y[4], y[5] */
-        c0 = read_q15x2 ((q15_t *) py);
+        c0 = read_q15x2((q15_t *)py);
 
         /* Read x[7], x[8] */
-        x3 = read_q15x2 ((q15_t *) px);
+        x3 = read_q15x2((q15_t *)px);
 
         /* Read x[9] */
-        x2 = read_q15x2 ((q15_t *) px + 1);
+        x2 = read_q15x2((q15_t *)px + 1);
         px += 2U;
 
         /* Perform the multiply-accumulate */
@@ -371,16 +370,15 @@ void arm_correlate_q15(
         acc3 = __SMLALD(x2, c0, acc3);
       }
 
-      if (k == 3U)
-      {
+      if (k == 3U) {
         /* Read y[4], y[5] */
-        c0 = read_q15x2_ia ((q15_t **) &py);
+        c0 = read_q15x2_ia((q15_t **)&py);
 
         /* Read x[7], x[8] */
-        x3 = read_q15x2 ((q15_t *) px);
+        x3 = read_q15x2((q15_t *)px);
 
         /* Read x[9] */
-        x2 = read_q15x2 ((q15_t *) px + 1);
+        x2 = read_q15x2((q15_t *)px + 1);
 
         /* Perform the multiply-accumulate */
         acc0 = __SMLALD(x0, c0, acc0);
@@ -391,35 +389,36 @@ void arm_correlate_q15(
         c0 = (*py);
 
         /* Read y[6] */
-#ifdef  ARM_MATH_BIG_ENDIAN
+#ifdef ARM_MATH_BIG_ENDIAN
         c0 = c0 << 16U;
 #else
         c0 = c0 & 0x0000FFFF;
 #endif /* #ifdef  ARM_MATH_BIG_ENDIAN */
 
         /* Read x[10] */
-        x3 = read_q15x2 ((q15_t *) px + 2);
+        x3 = read_q15x2((q15_t *)px + 2);
         px += 3U;
 
         /* Perform the multiply-accumulates */
         acc0 = __SMLALDX(x1, c0, acc0);
-        acc1 = __SMLALD (x2, c0, acc1);
+        acc1 = __SMLALD(x2, c0, acc1);
         acc2 = __SMLALDX(x2, c0, acc2);
         acc3 = __SMLALDX(x3, c0, acc3);
       }
 
       /* Store the result in the accumulator in the destination buffer. */
-      *pOut = (q15_t) (__SSAT(acc0 >> 15, 16));
-      /* Destination pointer is updated according to the address modifier, inc */
+      *pOut = (q15_t)(__SSAT(acc0 >> 15, 16));
+      /* Destination pointer is updated according to the address modifier, inc
+       */
       pOut += inc;
 
-      *pOut = (q15_t) (__SSAT(acc1 >> 15, 16));
+      *pOut = (q15_t)(__SSAT(acc1 >> 15, 16));
       pOut += inc;
 
-      *pOut = (q15_t) (__SSAT(acc2 >> 15, 16));
+      *pOut = (q15_t)(__SSAT(acc2 >> 15, 16));
       pOut += inc;
 
-      *pOut = (q15_t) (__SSAT(acc3 >> 15, 16));
+      *pOut = (q15_t)(__SSAT(acc3 >> 15, 16));
       pOut += inc;
 
       /* Increment the count by 4 as 4 output values are computed */
@@ -433,27 +432,27 @@ void arm_correlate_q15(
       blkCnt--;
     }
 
-    /* If the blockSize2 is not a multiple of 4, compute any remaining output samples here.
+    /* If the blockSize2 is not a multiple of 4, compute any remaining output
+     *samples here.
      ** No loop unrolling is used. */
     blkCnt = blockSize2 % 0x4U;
 
-    while (blkCnt > 0U)
-    {
+    while (blkCnt > 0U) {
       /* Accumulator is made zero for every iteration */
       sum = 0;
 
       /* Apply loop unrolling and compute 4 MACs simultaneously. */
       k = srcBLen >> 2U;
 
-      /* First part of the processing with loop unrolling.  Compute 4 MACs at a time.
+      /* First part of the processing with loop unrolling.  Compute 4 MACs at a
+       *time.
        ** a second loop below computes MACs for the remaining 1 to 3 samples. */
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Perform the multiply-accumulates */
-        sum += ((q63_t) *px++ * *py++);
-        sum += ((q63_t) *px++ * *py++);
-        sum += ((q63_t) *px++ * *py++);
-        sum += ((q63_t) *px++ * *py++);
+        sum += ((q63_t)*px++ * *py++);
+        sum += ((q63_t)*px++ * *py++);
+        sum += ((q63_t)*px++ * *py++);
+        sum += ((q63_t)*px++ * *py++);
 
         /* Decrement loop counter */
         k--;
@@ -463,18 +462,18 @@ void arm_correlate_q15(
        ** No loop unrolling is used. */
       k = srcBLen % 0x4U;
 
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Perform the multiply-accumulates */
-        sum += ((q63_t) *px++ * *py++);
+        sum += ((q63_t)*px++ * *py++);
 
         /* Decrement the loop counter */
         k--;
       }
 
       /* Store the result in the accumulator in the destination buffer. */
-      *pOut = (q15_t) (__SSAT(sum >> 15, 16));
-      /* Destination pointer is updated according to the address modifier, inc */
+      *pOut = (q15_t)(__SSAT(sum >> 15, 16));
+      /* Destination pointer is updated according to the address modifier, inc
+       */
       pOut += inc;
 
       /* Increment count by 1, as one output value is computed */
@@ -487,33 +486,30 @@ void arm_correlate_q15(
       /* Decrement the loop counter */
       blkCnt--;
     }
-  }
-  else
-  {
+  } else {
     /* If the srcBLen is not a multiple of 4,
      * the blockSize2 loop cannot be unrolled by 4 */
     blkCnt = blockSize2;
 
-    while (blkCnt > 0U)
-    {
+    while (blkCnt > 0U) {
       /* Accumulator is made zero for every iteration */
       sum = 0;
 
       /* srcBLen number of MACS should be performed */
       k = srcBLen;
 
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Perform the multiply-accumulate */
-        sum += ((q63_t) *px++ * *py++);
+        sum += ((q63_t)*px++ * *py++);
 
         /* Decrement the loop counter */
         k--;
       }
 
       /* Store the result in the accumulator in the destination buffer. */
-      *pOut = (q15_t) (__SSAT(sum >> 15, 16));
-      /* Destination pointer is updated according to the address modifier, inc */
+      *pOut = (q15_t)(__SSAT(sum >> 15, 16));
+      /* Destination pointer is updated according to the address modifier, inc
+       */
       pOut += inc;
 
       /* Increment the MAC count */
@@ -528,13 +524,13 @@ void arm_correlate_q15(
     }
   }
 
-
   /* --------------------------
    * Initializations of stage3
    * -------------------------*/
 
-  /* sum += x[srcALen-srcBLen+1] * y[0] + x[srcALen-srcBLen+2] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
-   * sum += x[srcALen-srcBLen+2] * y[0] + x[srcALen-srcBLen+3] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
+  /* sum += x[srcALen-srcBLen+1] * y[0] + x[srcALen-srcBLen+2] * y[1] +...+
+   * x[srcALen-1] * y[srcBLen-1] sum += x[srcALen-srcBLen+2] * y[0] +
+   * x[srcALen-srcBLen+3] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
    * ....
    * sum +=  x[srcALen-2] * y[0] + x[srcALen-1] * y[1]
    * sum +=  x[srcALen-1] * y[0]
@@ -555,23 +551,26 @@ void arm_correlate_q15(
    * Stage3 process
    * ------------------*/
 
-  while (blockSize3 > 0U)
-  {
+  while (blockSize3 > 0U) {
     /* Accumulator is made zero for every iteration */
     sum = 0;
 
     /* Apply loop unrolling and compute 4 MACs simultaneously. */
     k = count >> 2U;
 
-    /* First part of the processing with loop unrolling.  Compute 4 MACs at a time.
+    /* First part of the processing with loop unrolling.  Compute 4 MACs at a
+     *time.
      ** a second loop below computes MACs for the remaining 1 to 3 samples. */
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* Perform the multiply-accumulate */
-      /* sum += x[srcALen - srcBLen + 4] * y[3] , sum += x[srcALen - srcBLen + 3] * y[2] */
-      sum = __SMLALD(read_q15x2_ia ((q15_t **) &px), read_q15x2_ia ((q15_t **) &py), sum);
-      /* sum += x[srcALen - srcBLen + 2] * y[1] , sum += x[srcALen - srcBLen + 1] * y[0] */
-      sum = __SMLALD(read_q15x2_ia ((q15_t **) &px), read_q15x2_ia ((q15_t **) &py), sum);
+      /* sum += x[srcALen - srcBLen + 4] * y[3] , sum += x[srcALen - srcBLen +
+       * 3] * y[2] */
+      sum = __SMLALD(read_q15x2_ia((q15_t **)&px), read_q15x2_ia((q15_t **)&py),
+                     sum);
+      /* sum += x[srcALen - srcBLen + 2] * y[1] , sum += x[srcALen - srcBLen +
+       * 1] * y[0] */
+      sum = __SMLALD(read_q15x2_ia((q15_t **)&px), read_q15x2_ia((q15_t **)&py),
+                     sum);
 
       /* Decrement loop counter */
       k--;
@@ -581,8 +580,7 @@ void arm_correlate_q15(
      ** No loop unrolling is used. */
     k = count % 0x4U;
 
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* Perform the multiply-accumulate */
       sum = __SMLALD(*px++, *py++, sum);
 
@@ -591,7 +589,7 @@ void arm_correlate_q15(
     }
 
     /* Store the result in the accumulator in the destination buffer. */
-    *pOut = (q15_t) (__SSAT((sum >> 15), 16));
+    *pOut = (q15_t)(__SSAT((sum >> 15), 16));
     /* Destination pointer is updated according to the address modifier, inc */
     pOut += inc;
 
@@ -608,18 +606,19 @@ void arm_correlate_q15(
 
 #else /* #if defined (ARM_MATH_DSP) */
 
-  const q15_t *pIn1 = pSrcA;                           /* InputA pointer */
-  const q15_t *pIn2 = pSrcB + (srcBLen - 1U);          /* InputB pointer */
-        q63_t sum;                                     /* Accumulators */
-        uint32_t i = 0U, j;                            /* Loop counters */
-        uint32_t inv = 0U;                             /* Reverse order flag */
-        uint32_t tot = 0U;                             /* Length */
+  const q15_t *pIn1 = pSrcA;                  /* InputA pointer */
+  const q15_t *pIn2 = pSrcB + (srcBLen - 1U); /* InputB pointer */
+  q63_t sum;                                  /* Accumulators */
+  uint32_t i = 0U, j;                         /* Loop counters */
+  uint32_t inv = 0U;                          /* Reverse order flag */
+  uint32_t tot = 0U;                          /* Length */
 
   /* The algorithm implementation is based on the lengths of the inputs. */
   /* srcB is always made to slide across srcA. */
   /* So srcBLen is always considered as shorter or equal to srcALen */
   /* But CORR(x, y) is reverse of CORR(y, x) */
-  /* So, when srcBLen > srcALen, output pointer is made to point to the end of the output buffer */
+  /* So, when srcBLen > srcALen, output pointer is made to point to the end of
+   * the output buffer */
   /* and a varaible, inv is set to 1 */
   /* If lengths are not equal then zero pad has to be done to  make the two
    * inputs of same length. But to improve the performance, we include zeroes
@@ -634,8 +633,7 @@ void arm_correlate_q15(
   /* Calculate the length of the remaining sequence */
   tot = ((srcALen + srcBLen) - 2U);
 
-  if (srcALen > srcBLen)
-  {
+  if (srcALen > srcBLen) {
     /* Calculating the number of zeros to be padded to the output */
     j = srcALen - srcBLen;
 
@@ -643,8 +641,7 @@ void arm_correlate_q15(
     pDst += j;
   }
 
-  else if (srcALen < srcBLen)
-  {
+  else if (srcALen < srcBLen) {
     /* Initialization to inputB pointer */
     pIn1 = pSrcB;
 
@@ -664,31 +661,27 @@ void arm_correlate_q15(
   }
 
   /* Loop to calculate convolution for output length number of values */
-  for (i = 0U; i <= tot; i++)
-  {
+  for (i = 0U; i <= tot; i++) {
     /* Initialize sum with zero to carry on MAC operations */
     sum = 0;
 
     /* Loop to perform MAC operations according to convolution equation */
-    for (j = 0U; j <= i; j++)
-    {
+    for (j = 0U; j <= i; j++) {
       /* Check the array limitations */
-      if (((i - j) < srcBLen) && (j < srcALen))
-      {
+      if (((i - j) < srcBLen) && (j < srcALen)) {
         /* z[i] += x[i-j] * y[j] */
-        sum += ((q31_t) pIn1[j] * pIn2[-((int32_t) i - j)]);
+        sum += ((q31_t)pIn1[j] * pIn2[-((int32_t)i - j)]);
       }
     }
 
     /* Store the output in the destination buffer */
     if (inv == 1)
-      *pDst-- = (q15_t) __SSAT((sum >> 15U), 16U);
+      *pDst-- = (q15_t)__SSAT((sum >> 15U), 16U);
     else
-      *pDst++ = (q15_t) __SSAT((sum >> 15U), 16U);
+      *pDst++ = (q15_t)__SSAT((sum >> 15U), 16U);
   }
 
 #endif /* #if defined (ARM_MATH_DSP) */
-
 }
 
 /**
diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_q31.c
index caa2f51..27a46bf 100644
--- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_q31.c
+++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_q31.c
@@ -43,66 +43,70 @@
   @param[in]     srcALen    length of the first input sequence
   @param[in]     pSrcB      points to the second input sequence
   @param[in]     srcBLen    length of the second input sequence
-  @param[out]    pDst       points to the location where the output result is written.  Length 2 * max(srcALen, srcBLen) - 1.
+  @param[out]    pDst       points to the location where the output result is
+  written.  Length 2 * max(srcALen, srcBLen) - 1.
   @return        none
 
   @par           Scaling and Overflow Behavior
-                   The function is implemented using an internal 64-bit accumulator.
-                   The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit.
+                   The function is implemented using an internal 64-bit
+  accumulator. The accumulator has a 2.62 format and maintains full precision of
+  the intermediate multiplication results but provides only a single guard bit.
                    There is no saturation on intermediate additions.
-                   Thus, if the accumulator overflows it wraps around and distorts the result.
-                   The input signals should be scaled down to avoid intermediate overflows.
-                   Scale down one of the inputs by 1/min(srcALen, srcBLen)to avoid overflows since a
-                   maximum of min(srcALen, srcBLen) number of additions is carried internally.
-                   The 2.62 accumulator is right shifted by 31 bits and saturated to 1.31 format to yield the final result.
+                   Thus, if the accumulator overflows it wraps around and
+  distorts the result. The input signals should be scaled down to avoid
+  intermediate overflows. Scale down one of the inputs by 1/min(srcALen,
+  srcBLen)to avoid overflows since a maximum of min(srcALen, srcBLen) number of
+  additions is carried internally. The 2.62 accumulator is right shifted by 31
+  bits and saturated to 1.31 format to yield the final result.
 
   @remark
-                   Refer to \ref arm_correlate_fast_q31() for a faster but less precise implementation of this function.
+                   Refer to \ref arm_correlate_fast_q31() for a faster but less
+  precise implementation of this function.
  */
 
-void arm_correlate_q31(
-  const q31_t * pSrcA,
-        uint32_t srcALen,
-  const q31_t * pSrcB,
-        uint32_t srcBLen,
-        q31_t * pDst)
-{
+void arm_correlate_q31(const q31_t *pSrcA, uint32_t srcALen, const q31_t *pSrcB,
+                       uint32_t srcBLen, q31_t *pDst) {
 
 #if (1)
-//#if !defined(ARM_MATH_CM0_FAMILY)
+  //#if !defined(ARM_MATH_CM0_FAMILY)
 
-  const q31_t *pIn1;                                   /* InputA pointer */
-  const q31_t *pIn2;                                   /* InputB pointer */
-        q31_t *pOut = pDst;                            /* Output pointer */
-  const q31_t *px;                                     /* Intermediate inputA pointer */
-  const q31_t *py;                                     /* Intermediate inputB pointer */
-  const q31_t *pSrc1;                                  /* Intermediate pointers */
-        q63_t sum;                                     /* Accumulators */
-        uint32_t blockSize1, blockSize2, blockSize3;   /* Loop counters */
-        uint32_t j, k, count, blkCnt;                  /* Loop counters */
-        uint32_t outBlockSize;
-        int32_t inc = 1;                               /* Destination address modifier */
+  const q31_t *pIn1;                           /* InputA pointer */
+  const q31_t *pIn2;                           /* InputB pointer */
+  q31_t *pOut = pDst;                          /* Output pointer */
+  const q31_t *px;                             /* Intermediate inputA pointer */
+  const q31_t *py;                             /* Intermediate inputB pointer */
+  const q31_t *pSrc1;                          /* Intermediate pointers */
+  q63_t sum;                                   /* Accumulators */
+  uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */
+  uint32_t j, k, count, blkCnt;                /* Loop counters */
+  uint32_t outBlockSize;
+  int32_t inc = 1; /* Destination address modifier */
 
-#if defined (ARM_MATH_LOOPUNROLL)
-        q63_t acc0, acc1, acc2;                        /* Accumulators */
-        q31_t x0, x1, x2, c0;                          /* Temporary variables for holding input and coefficient values */
+#if defined(ARM_MATH_LOOPUNROLL)
+  q63_t acc0, acc1, acc2; /* Accumulators */
+  q31_t x0, x1, x2,
+      c0; /* Temporary variables for holding input and coefficient values */
 #endif
 
   /* The algorithm implementation is based on the lengths of the inputs. */
   /* srcB is always made to slide across srcA. */
   /* So srcBLen is always considered as shorter or equal to srcALen */
   /* But CORR(x, y) is reverse of CORR(y, x) */
-  /* So, when srcBLen > srcALen, output pointer is made to point to the end of the output buffer */
+  /* So, when srcBLen > srcALen, output pointer is made to point to the end of
+   * the output buffer */
   /* and the destination pointer modifier, inc is set to -1 */
-  /* If srcALen > srcBLen, zero pad has to be done to srcB to make the two inputs of same length */
+  /* If srcALen > srcBLen, zero pad has to be done to srcB to make the two
+   * inputs of same length */
   /* But to improve the performance,
-   * we include zeroes in the output instead of zero padding either of the the inputs*/
+   * we include zeroes in the output instead of zero padding either of the the
+   * inputs*/
   /* If srcALen > srcBLen,
-   * (srcALen - srcBLen) zeroes has to included in the starting of the output buffer */
+   * (srcALen - srcBLen) zeroes has to included in the starting of the output
+   * buffer */
   /* If srcALen < srcBLen,
-   * (srcALen - srcBLen) zeroes has to included in the ending of the output buffer */
-  if (srcALen >= srcBLen)
-  {
+   * (srcALen - srcBLen) zeroes has to included in the ending of the output
+   * buffer */
+  if (srcALen >= srcBLen) {
     /* Initialization of inputA pointer */
     pIn1 = pSrcA;
 
@@ -120,9 +124,7 @@ void arm_correlate_q31(
 
     /* Updating the pointer position to non zero value */
     pOut += j;
-  }
-  else
-  {
+  } else {
     /* Initialization of inputA pointer */
     pIn1 = pSrcB;
 
@@ -143,12 +145,12 @@ void arm_correlate_q31(
   }
 
   /* The function is internally
-   * divided into three stages according to the number of multiplications that has to be
-   * taken place between inputA samples and inputB samples. In the first stage of the
-   * algorithm, the multiplications increase by one for every iteration.
-   * In the second stage of the algorithm, srcBLen number of multiplications are done.
-   * In the third stage of the algorithm, the multiplications decrease by one
-   * for every iteration. */
+   * divided into three stages according to the number of multiplications that
+   * has to be taken place between inputA samples and inputB samples. In the
+   * first stage of the algorithm, the multiplications increase by one for every
+   * iteration. In the second stage of the algorithm, srcBLen number of
+   * multiplications are done. In the third stage of the algorithm, the
+   * multiplications decrease by one for every iteration. */
 
   /* The algorithm is implemented in three stages.
      The loop counters of each stage is initiated here. */
@@ -177,35 +179,32 @@ void arm_correlate_q31(
   pSrc1 = pIn2 + (srcBLen - 1U);
   py = pSrc1;
 
-
   /* ------------------------
    * Stage1 process
    * ----------------------*/
 
   /* The first stage starts here */
-  while (blockSize1 > 0U)
-  {
+  while (blockSize1 > 0U) {
     /* Accumulator is made zero for every iteration */
     sum = 0;
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
     /* Loop unrolling: Compute 4 outputs at a time */
     k = count >> 2U;
 
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* x[0] * y[srcBLen - 4] */
-      sum += (q63_t) *px++ * (*py++);
+      sum += (q63_t)*px++ * (*py++);
 
       /* x[1] * y[srcBLen - 3] */
-      sum += (q63_t) *px++ * (*py++);
+      sum += (q63_t)*px++ * (*py++);
 
       /* x[2] * y[srcBLen - 2] */
-      sum += (q63_t) *px++ * (*py++);
+      sum += (q63_t)*px++ * (*py++);
 
       /* x[3] * y[srcBLen - 1] */
-      sum += (q63_t) *px++ * (*py++);
+      sum += (q63_t)*px++ * (*py++);
 
       /* Decrement loop counter */
       k--;
@@ -221,18 +220,17 @@ void arm_correlate_q31(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* Perform the multiply-accumulate */
       /* x[0] * y[srcBLen - 1] */
-      sum += (q63_t) *px++ * (*py++);
+      sum += (q63_t)*px++ * (*py++);
 
       /* Decrement loop counter */
       k--;
     }
 
     /* Store the result in the accumulator in the destination buffer. */
-    *pOut = (q31_t) (sum >> 31);
+    *pOut = (q31_t)(sum >> 31);
     /* Destination pointer is updated according to the address modifier, inc */
     pOut += inc;
 
@@ -254,7 +252,8 @@ void arm_correlate_q31(
   /* sum = x[0] * y[0] + x[1] * y[1] +...+ x[srcBLen-1] * y[srcBLen-1]
    * sum = x[1] * y[0] + x[2] * y[1] +...+ x[srcBLen] * y[srcBLen-1]
    * ....
-   * sum = x[srcALen-srcBLen-2] * y[0] + x[srcALen-srcBLen-1] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
+   * sum = x[srcALen-srcBLen-2] * y[0] + x[srcALen-srcBLen-1] * y[1] +...+
+   * x[srcALen-1] * y[srcBLen-1]
    */
 
   /* Working pointer of inputA */
@@ -270,18 +269,16 @@ void arm_correlate_q31(
    * Stage2 process
    * ------------------*/
 
-  /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed.
-   * So, to loop unroll over blockSize2,
-   * srcBLen should be greater than or equal to 4 */
-  if (srcBLen >= 4U)
-  {
-#if defined (ARM_MATH_LOOPUNROLL)
+  /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are
+   * performed. So, to loop unroll over blockSize2, srcBLen should be greater
+   * than or equal to 4 */
+  if (srcBLen >= 4U) {
+#if defined(ARM_MATH_LOOPUNROLL)
 
     /* Loop unroll by 3 */
     blkCnt = blockSize2 / 3;
 
-    while (blkCnt > 0U)
-    {
+    while (blkCnt > 0U) {
       /* Set all accumulators to zero */
       acc0 = 0;
       acc1 = 0;
@@ -294,10 +291,10 @@ void arm_correlate_q31(
       /* Apply loop unrolling and compute 3 MACs simultaneously. */
       k = srcBLen / 3;
 
-      /* First part of the processing with loop unrolling.  Compute 3 MACs at a time.
+      /* First part of the processing with loop unrolling.  Compute 3 MACs at a
+       *time.
        ** a second loop below computes MACs for the remaining 1 to 2 samples. */
-      do
-      {
+      do {
         /* Read y[0] sample */
         c0 = *(py);
         /* Read x[2] sample */
@@ -305,11 +302,11 @@ void arm_correlate_q31(
 
         /* Perform the multiply-accumulate */
         /* acc0 +=  x[0] * y[0] */
-        acc0 += ((q63_t) x0 * c0);
+        acc0 += ((q63_t)x0 * c0);
         /* acc1 +=  x[1] * y[0] */
-        acc1 += ((q63_t) x1 * c0);
+        acc1 += ((q63_t)x1 * c0);
         /* acc2 +=  x[2] * y[0] */
-        acc2 += ((q63_t) x2 * c0);
+        acc2 += ((q63_t)x2 * c0);
 
         /* Read y[1] sample */
         c0 = *(py + 1U);
@@ -318,11 +315,11 @@ void arm_correlate_q31(
 
         /* Perform the multiply-accumulate */
         /* acc0 +=  x[1] * y[1] */
-        acc0 += ((q63_t) x1 * c0);
+        acc0 += ((q63_t)x1 * c0);
         /* acc1 +=  x[2] * y[1] */
-        acc1 += ((q63_t) x2 * c0);
+        acc1 += ((q63_t)x2 * c0);
         /* acc2 +=  x[3] * y[1] */
-        acc2 += ((q63_t) x0 * c0);
+        acc2 += ((q63_t)x0 * c0);
 
         /* Read y[2] sample */
         c0 = *(py + 2U);
@@ -331,11 +328,11 @@ void arm_correlate_q31(
 
         /* Perform the multiply-accumulate */
         /* acc0 +=  x[2] * y[2] */
-        acc0 += ((q63_t) x2 * c0);
+        acc0 += ((q63_t)x2 * c0);
         /* acc1 +=  x[3] * y[2] */
-        acc1 += ((q63_t) x0 * c0);
+        acc1 += ((q63_t)x0 * c0);
         /* acc2 +=  x[4] * y[2] */
-        acc2 += ((q63_t) x1 * c0);
+        acc2 += ((q63_t)x1 * c0);
 
         /* update scratch pointers */
         px += 3U;
@@ -347,8 +344,7 @@ void arm_correlate_q31(
        ** No loop unrolling is used. */
       k = srcBLen - (3 * (srcBLen / 3));
 
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Read y[4] sample */
         c0 = *(py++);
 
@@ -357,11 +353,11 @@ void arm_correlate_q31(
 
         /* Perform the multiply-accumulates */
         /* acc0 +=  x[4] * y[4] */
-        acc0 += ((q63_t) x0 * c0);
+        acc0 += ((q63_t)x0 * c0);
         /* acc1 +=  x[5] * y[4] */
-        acc1 += ((q63_t) x1 * c0);
+        acc1 += ((q63_t)x1 * c0);
         /* acc2 +=  x[6] * y[4] */
-        acc2 += ((q63_t) x2 * c0);
+        acc2 += ((q63_t)x2 * c0);
 
         /* Reuse the present samples for the next MAC */
         x0 = x1;
@@ -372,14 +368,15 @@ void arm_correlate_q31(
       }
 
       /* Store the result in the accumulator in the destination buffer. */
-      *pOut = (q31_t) (acc0 >> 31);
-      /* Destination pointer is updated according to the address modifier, inc */
+      *pOut = (q31_t)(acc0 >> 31);
+      /* Destination pointer is updated according to the address modifier, inc
+       */
       pOut += inc;
 
-      *pOut = (q31_t) (acc1 >> 31);
+      *pOut = (q31_t)(acc1 >> 31);
       pOut += inc;
 
-      *pOut = (q31_t) (acc2 >> 31);
+      *pOut = (q31_t)(acc2 >> 31);
       pOut += inc;
 
       /* Increment the pointer pIn1 index, count by 3 */
@@ -403,23 +400,21 @@ void arm_correlate_q31(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-    while (blkCnt > 0U)
-    {
+    while (blkCnt > 0U) {
       /* Accumulator is made zero for every iteration */
       sum = 0;
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
-    /* Loop unrolling: Compute 4 outputs at a time */
+      /* Loop unrolling: Compute 4 outputs at a time */
       k = srcBLen >> 2U;
 
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Perform the multiply-accumulates */
-        sum += (q63_t) *px++ * *py++;
-        sum += (q63_t) *px++ * *py++;
-        sum += (q63_t) *px++ * *py++;
-        sum += (q63_t) *px++ * *py++;
+        sum += (q63_t)*px++ * *py++;
+        sum += (q63_t)*px++ * *py++;
+        sum += (q63_t)*px++ * *py++;
+        sum += (q63_t)*px++ * *py++;
 
         /* Decrement loop counter */
         k--;
@@ -435,18 +430,18 @@ void arm_correlate_q31(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Perform the multiply-accumulate */
-        sum += (q63_t) *px++ * *py++;
+        sum += (q63_t)*px++ * *py++;
 
         /* Decrement the loop counter */
         k--;
       }
 
       /* Store the result in the accumulator in the destination buffer. */
-      *pOut = (q31_t) (sum >> 31);
-      /* Destination pointer is updated according to the address modifier, inc */
+      *pOut = (q31_t)(sum >> 31);
+      /* Destination pointer is updated according to the address modifier, inc
+       */
       pOut += inc;
 
       /* Increment MAC count */
@@ -459,33 +454,30 @@ void arm_correlate_q31(
       /* Decrement loop counter */
       blkCnt--;
     }
-  }
-  else
-  {
+  } else {
     /* If the srcBLen is not a multiple of 4,
      * the blockSize2 loop cannot be unrolled by 4 */
     blkCnt = blockSize2;
 
-    while (blkCnt > 0U)
-    {
+    while (blkCnt > 0U) {
       /* Accumulator is made zero for every iteration */
       sum = 0;
 
       /* srcBLen number of MACS should be performed */
       k = srcBLen;
 
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Perform the multiply-accumulate */
-        sum += (q63_t) *px++ * *py++;
+        sum += (q63_t)*px++ * *py++;
 
         /* Decrement the loop counter */
         k--;
       }
 
       /* Store the result in the accumulator in the destination buffer. */
-      *pOut = (q31_t) (sum >> 31);
-      /* Destination pointer is updated according to the address modifier, inc */
+      *pOut = (q31_t)(sum >> 31);
+      /* Destination pointer is updated according to the address modifier, inc
+       */
       pOut += inc;
 
       /* Increment MAC count */
@@ -500,13 +492,13 @@ void arm_correlate_q31(
     }
   }
 
-
   /* --------------------------
    * Initializations of stage3
    * -------------------------*/
 
-  /* sum += x[srcALen-srcBLen+1] * y[0] + x[srcALen-srcBLen+2] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
-   * sum += x[srcALen-srcBLen+2] * y[0] + x[srcALen-srcBLen+3] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
+  /* sum += x[srcALen-srcBLen+1] * y[0] + x[srcALen-srcBLen+2] * y[1] +...+
+   * x[srcALen-1] * y[srcBLen-1] sum += x[srcALen-srcBLen+2] * y[0] +
+   * x[srcALen-srcBLen+3] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
    * ....
    * sum +=  x[srcALen-2] * y[0] + x[srcALen-1] * y[1]
    * sum +=  x[srcALen-1] * y[0]
@@ -527,30 +519,28 @@ void arm_correlate_q31(
    * Stage3 process
    * ------------------*/
 
-  while (blockSize3 > 0U)
-  {
+  while (blockSize3 > 0U) {
     /* Accumulator is made zero for every iteration */
     sum = 0;
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
     /* Loop unrolling: Compute 4 outputs at a time */
     k = count >> 2U;
 
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* Perform the multiply-accumulate */
       /* sum += x[srcALen - srcBLen + 4] * y[3] */
-      sum += (q63_t) *px++ * *py++;
+      sum += (q63_t)*px++ * *py++;
 
       /* sum += x[srcALen - srcBLen + 3] * y[2] */
-      sum += (q63_t) *px++ * *py++;
+      sum += (q63_t)*px++ * *py++;
 
       /* sum += x[srcALen - srcBLen + 2] * y[1] */
-      sum += (q63_t) *px++ * *py++;
+      sum += (q63_t)*px++ * *py++;
 
       /* sum += x[srcALen - srcBLen + 1] * y[0] */
-      sum += (q63_t) *px++ * *py++;
+      sum += (q63_t)*px++ * *py++;
 
       /* Decrement loop counter */
       k--;
@@ -566,17 +556,16 @@ void arm_correlate_q31(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* Perform the multiply-accumulate */
-      sum += (q63_t) *px++ * *py++;
+      sum += (q63_t)*px++ * *py++;
 
       /* Decrement loop counter */
       k--;
     }
 
     /* Store the result in the accumulator in the destination buffer. */
-    *pOut = (q31_t) (sum >> 31);
+    *pOut = (q31_t)(sum >> 31);
     /* Destination pointer is updated according to the address modifier, inc */
     pOut += inc;
 
@@ -592,20 +581,21 @@ void arm_correlate_q31(
   }
 
 #else
-/* alternate version for CM0_FAMILY */
+  /* alternate version for CM0_FAMILY */
 
-  const q31_t *pIn1 = pSrcA;                           /* InputA pointer */
-  const q31_t *pIn2 = pSrcB + (srcBLen - 1U);          /* InputB pointer */
-        q63_t sum;                                     /* Accumulators */
-        uint32_t i = 0U, j;                            /* Loop counters */
-        uint32_t inv = 0U;                             /* Reverse order flag */
-        uint32_t tot = 0U;                             /* Length */
+  const q31_t *pIn1 = pSrcA;                  /* InputA pointer */
+  const q31_t *pIn2 = pSrcB + (srcBLen - 1U); /* InputB pointer */
+  q63_t sum;                                  /* Accumulators */
+  uint32_t i = 0U, j;                         /* Loop counters */
+  uint32_t inv = 0U;                          /* Reverse order flag */
+  uint32_t tot = 0U;                          /* Length */
 
   /* The algorithm implementation is based on the lengths of the inputs. */
   /* srcB is always made to slide across srcA. */
   /* So srcBLen is always considered as shorter or equal to srcALen */
   /* But CORR(x, y) is reverse of CORR(y, x) */
-  /* So, when srcBLen > srcALen, output pointer is made to point to the end of the output buffer */
+  /* So, when srcBLen > srcALen, output pointer is made to point to the end of
+   * the output buffer */
   /* and a varaible, inv is set to 1 */
   /* If lengths are not equal then zero pad has to be done to  make the two
    * inputs of same length. But to improve the performance, we include zeroes
@@ -620,8 +610,7 @@ void arm_correlate_q31(
   /* Calculate the length of the remaining sequence */
   tot = ((srcALen + srcBLen) - 2U);
 
-  if (srcALen > srcBLen)
-  {
+  if (srcALen > srcBLen) {
     /* Calculating the number of zeros to be padded to the output */
     j = srcALen - srcBLen;
 
@@ -629,8 +618,7 @@ void arm_correlate_q31(
     pDst += j;
   }
 
-  else if (srcALen < srcBLen)
-  {
+  else if (srcALen < srcBLen) {
     /* Initialization to inputB pointer */
     pIn1 = pSrcB;
 
@@ -650,31 +638,27 @@ void arm_correlate_q31(
   }
 
   /* Loop to calculate correlation for output length number of times */
-  for (i = 0U; i <= tot; i++)
-  {
+  for (i = 0U; i <= tot; i++) {
     /* Initialize sum with zero to carry out MAC operations */
     sum = 0;
 
     /* Loop to perform MAC operations according to correlation equation */
-    for (j = 0U; j <= i; j++)
-    {
+    for (j = 0U; j <= i; j++) {
       /* Check the array limitations */
-      if (((i - j) < srcBLen) && (j < srcALen))
-      {
+      if (((i - j) < srcBLen) && (j < srcALen)) {
         /* z[i] += x[i-j] * y[j] */
-        sum += ((q63_t) pIn1[j] * pIn2[-((int32_t) i - j)]);
+        sum += ((q63_t)pIn1[j] * pIn2[-((int32_t)i - j)]);
       }
     }
 
     /* Store the output in the destination buffer */
     if (inv == 1)
-      *pDst-- = (q31_t) (sum >> 31U);
+      *pDst-- = (q31_t)(sum >> 31U);
     else
-      *pDst++ = (q31_t) (sum >> 31U);
+      *pDst++ = (q31_t)(sum >> 31U);
   }
 
 #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */
-
 }
 
 /**
diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_q7.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_q7.c
index e5881ac..cb9ccb9 100644
--- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_q7.c
+++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_correlate_q7.c
@@ -43,65 +43,69 @@
   @param[in]     srcALen    length of the first input sequence
   @param[in]     pSrcB      points to the second input sequence
   @param[in]     srcBLen    length of the second input sequence
-  @param[out]    pDst       points to the location where the output result is written.  Length 2 * max(srcALen, srcBLen) - 1.
+  @param[out]    pDst       points to the location where the output result is
+ written.  Length 2 * max(srcALen, srcBLen) - 1.
   @return        none
 
   @par           Scaling and Overflow Behavior
-                   The function is implemented using a 32-bit internal accumulator.
-                   Both the inputs are represented in 1.7 format and multiplications yield a 2.14 result.
-                   The 2.14 intermediate results are accumulated in a 32-bit accumulator in 18.14 format.
-                   This approach provides 17 guard bits and there is no risk of overflow as long as max(srcALen, srcBLen)<131072.
-                   The 18.14 result is then truncated to 18.7 format by discarding the low 7 bits and saturated to 1.7 format.
+                   The function is implemented using a 32-bit internal
+ accumulator. Both the inputs are represented in 1.7 format and multiplications
+ yield a 2.14 result. The 2.14 intermediate results are accumulated in a 32-bit
+ accumulator in 18.14 format. This approach provides 17 guard bits and there is
+ no risk of overflow as long as max(srcALen, srcBLen)<131072.
+                   The 18.14 result is then truncated to 18.7 format by
+ discarding the low 7 bits and saturated to 1.7 format.
 
  @remark
-                   Refer to \ref arm_correlate_opt_q7() for a faster implementation of this function.
+                   Refer to \ref arm_correlate_opt_q7() for a faster
+ implementation of this function.
  */
 
-void arm_correlate_q7(
-  const q7_t * pSrcA,
-        uint32_t srcALen,
-  const q7_t * pSrcB,
-        uint32_t srcBLen,
-        q7_t * pDst)
-{
+void arm_correlate_q7(const q7_t *pSrcA, uint32_t srcALen, const q7_t *pSrcB,
+                      uint32_t srcBLen, q7_t *pDst) {
 
 #if (1)
-//#if !defined(ARM_MATH_CM0_FAMILY)
+  //#if !defined(ARM_MATH_CM0_FAMILY)
 
-  const q7_t *pIn1;                                    /* InputA pointer */
-  const q7_t *pIn2;                                    /* InputB pointer */
-        q7_t *pOut = pDst;                             /* Output pointer */
-  const q7_t *px;                                      /* Intermediate inputA pointer */
-  const q7_t *py;                                      /* Intermediate inputB pointer */
-  const q7_t *pSrc1;                                   /* Intermediate pointers */
-        q31_t sum;                                     /* Accumulators */
-        uint32_t blockSize1, blockSize2, blockSize3;   /* Loop counters */
-        uint32_t j, k, count, blkCnt;                  /* Loop counters */
-        uint32_t outBlockSize;
-        int32_t inc = 1;
+  const q7_t *pIn1;                            /* InputA pointer */
+  const q7_t *pIn2;                            /* InputB pointer */
+  q7_t *pOut = pDst;                           /* Output pointer */
+  const q7_t *px;                              /* Intermediate inputA pointer */
+  const q7_t *py;                              /* Intermediate inputB pointer */
+  const q7_t *pSrc1;                           /* Intermediate pointers */
+  q31_t sum;                                   /* Accumulators */
+  uint32_t blockSize1, blockSize2, blockSize3; /* Loop counters */
+  uint32_t j, k, count, blkCnt;                /* Loop counters */
+  uint32_t outBlockSize;
+  int32_t inc = 1;
 
-#if defined (ARM_MATH_LOOPUNROLL)
-        q31_t acc0, acc1, acc2, acc3;                  /* Accumulators */
-        q31_t input1, input2;                          /* Temporary input variables */
-        q15_t in1, in2;                                /* Temporary input variables */
-        q7_t x0, x1, x2, x3, c0, c1;                   /* Temporary variables for holding input and coefficient values */
+#if defined(ARM_MATH_LOOPUNROLL)
+  q31_t acc0, acc1, acc2, acc3; /* Accumulators */
+  q31_t input1, input2;         /* Temporary input variables */
+  q15_t in1, in2;               /* Temporary input variables */
+  q7_t x0, x1, x2, x3, c0,
+      c1; /* Temporary variables for holding input and coefficient values */
 #endif
 
   /* The algorithm implementation is based on the lengths of the inputs. */
   /* srcB is always made to slide across srcA. */
   /* So srcBLen is always considered as shorter or equal to srcALen */
   /* But CORR(x, y) is reverse of CORR(y, x) */
-  /* So, when srcBLen > srcALen, output pointer is made to point to the end of the output buffer */
+  /* So, when srcBLen > srcALen, output pointer is made to point to the end of
+   * the output buffer */
   /* and the destination pointer modifier, inc is set to -1 */
-  /* If srcALen > srcBLen, zero pad has to be done to srcB to make the two inputs of same length */
+  /* If srcALen > srcBLen, zero pad has to be done to srcB to make the two
+   * inputs of same length */
   /* But to improve the performance,
-   * we include zeroes in the output instead of zero padding either of the the inputs*/
+   * we include zeroes in the output instead of zero padding either of the the
+   * inputs*/
   /* If srcALen > srcBLen,
-   * (srcALen - srcBLen) zeroes has to included in the starting of the output buffer */
+   * (srcALen - srcBLen) zeroes has to included in the starting of the output
+   * buffer */
   /* If srcALen < srcBLen,
-   * (srcALen - srcBLen) zeroes has to included in the ending of the output buffer */
-  if (srcALen >= srcBLen)
-  {
+   * (srcALen - srcBLen) zeroes has to included in the ending of the output
+   * buffer */
+  if (srcALen >= srcBLen) {
     /* Initialization of inputA pointer */
     pIn1 = pSrcA;
 
@@ -119,9 +123,7 @@ void arm_correlate_q7(
 
     /* Updating the pointer position to non zero value */
     pOut += j;
-  }
-  else
-  {
+  } else {
     /* Initialization of inputA pointer */
     pIn1 = pSrcB;
 
@@ -142,12 +144,12 @@ void arm_correlate_q7(
   }
 
   /* The function is internally
-   * divided into three stages according to the number of multiplications that has to be
-   * taken place between inputA samples and inputB samples. In the first stage of the
-   * algorithm, the multiplications increase by one for every iteration.
-   * In the second stage of the algorithm, srcBLen number of multiplications are done.
-   * In the third stage of the algorithm, the multiplications decrease by one
-   * for every iteration. */
+   * divided into three stages according to the number of multiplications that
+   * has to be taken place between inputA samples and inputB samples. In the
+   * first stage of the algorithm, the multiplications increase by one for every
+   * iteration. In the second stage of the algorithm, srcBLen number of
+   * multiplications are done. In the third stage of the algorithm, the
+   * multiplications decrease by one for every iteration. */
 
   /* The algorithm is implemented in three stages.
      The loop counters of each stage is initiated here. */
@@ -181,41 +183,39 @@ void arm_correlate_q7(
    * ----------------------*/
 
   /* The first stage starts here */
-  while (blockSize1 > 0U)
-  {
+  while (blockSize1 > 0U) {
     /* Accumulator is made zero for every iteration */
     sum = 0;
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
     /* Loop unrolling: Compute 4 outputs at a time */
     k = count >> 2U;
 
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* x[0] , x[1] */
-      in1 = (q15_t) *px++;
-      in2 = (q15_t) *px++;
-      input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
+      in1 = (q15_t)*px++;
+      in2 = (q15_t)*px++;
+      input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16);
 
       /* y[srcBLen - 4] , y[srcBLen - 3] */
-      in1 = (q15_t) *py++;
-      in2 = (q15_t) *py++;
-      input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
+      in1 = (q15_t)*py++;
+      in2 = (q15_t)*py++;
+      input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16);
 
       /* x[0] * y[srcBLen - 4] */
       /* x[1] * y[srcBLen - 3] */
       sum = __SMLAD(input1, input2, sum);
 
       /* x[2] , x[3] */
-      in1 = (q15_t) *px++;
-      in2 = (q15_t) *px++;
-      input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
+      in1 = (q15_t)*px++;
+      in2 = (q15_t)*px++;
+      input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16);
 
       /* y[srcBLen - 2] , y[srcBLen - 1] */
-      in1 = (q15_t) *py++;
-      in2 = (q15_t) *py++;
-      input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16);
+      in1 = (q15_t)*py++;
+      in2 = (q15_t)*py++;
+      input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16);
 
       /* x[2] * y[srcBLen - 2] */
       /* x[3] * y[srcBLen - 1] */
@@ -235,18 +235,17 @@ void arm_correlate_q7(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* Perform the multiply-accumulate */
       /* x[0] * y[srcBLen - 1] */
-      sum += (q31_t) ((q15_t) *px++ * *py++);
+      sum += (q31_t)((q15_t)*px++ * *py++);
 
       /* Decrement loop counter */
       k--;
     }
 
     /* Store the result in the accumulator in the destination buffer. */
-    *pOut = (q7_t) (__SSAT(sum >> 7U, 8));
+    *pOut = (q7_t)(__SSAT(sum >> 7U, 8));
     /* Destination pointer is updated according to the address modifier, inc */
     pOut += inc;
 
@@ -268,7 +267,8 @@ void arm_correlate_q7(
   /* sum = x[0] * y[0] + x[1] * y[1] +...+ x[srcBLen-1] * y[srcBLen-1]
    * sum = x[1] * y[0] + x[2] * y[1] +...+ x[srcBLen] * y[srcBLen-1]
    * ....
-   * sum = x[srcALen-srcBLen-2] * y[0] + x[srcALen-srcBLen-1] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
+   * sum = x[srcALen-srcBLen-2] * y[0] + x[srcALen-srcBLen-1] * y[1] +...+
+   * x[srcALen-1] * y[srcBLen-1]
    */
 
   /* Working pointer of inputA */
@@ -284,18 +284,16 @@ void arm_correlate_q7(
    * Stage2 process
    * ------------------*/
 
-  /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are performed.
-   * So, to loop unroll over blockSize2,
-   * srcBLen should be greater than or equal to 4 */
-  if (srcBLen >= 4U)
-  {
-#if defined (ARM_MATH_LOOPUNROLL)
+  /* Stage2 depends on srcBLen as in this stage srcBLen number of MACS are
+   * performed. So, to loop unroll over blockSize2, srcBLen should be greater
+   * than or equal to 4 */
+  if (srcBLen >= 4U) {
+#if defined(ARM_MATH_LOOPUNROLL)
 
     /* Loop unrolling: Compute 4 outputs at a time */
     blkCnt = blockSize2 >> 2U;
 
-    while (blkCnt > 0U)
-    {
+    while (blkCnt > 0U) {
       /* Set all accumulators to zero */
       acc0 = 0;
       acc1 = 0;
@@ -310,10 +308,10 @@ void arm_correlate_q7(
       /* Apply loop unrolling and compute 4 MACs simultaneously. */
       k = srcBLen >> 2U;
 
-      /* First part of the processing with loop unrolling.  Compute 4 MACs at a time.
+      /* First part of the processing with loop unrolling.  Compute 4 MACs at a
+       *time.
        ** a second loop below computes MACs for the remaining 1 to 3 samples. */
-      do
-      {
+      do {
         /* Read y[0] sample */
         c0 = *py++;
         /* Read y[1] sample */
@@ -323,34 +321,34 @@ void arm_correlate_q7(
         x3 = *px++;
 
         /* x[0] and x[1] are packed */
-        in1 = (q15_t) x0;
-        in2 = (q15_t) x1;
+        in1 = (q15_t)x0;
+        in2 = (q15_t)x1;
 
-        input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U);
+        input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U);
 
         /* y[0] and y[1] are packed */
-        in1 = (q15_t) c0;
-        in2 = (q15_t) c1;
+        in1 = (q15_t)c0;
+        in2 = (q15_t)c1;
 
-        input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U);
+        input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U);
 
         /* acc0 += x[0] * y[0] + x[1] * y[1]  */
         acc0 = __SMLAD(input1, input2, acc0);
 
         /* x[1] and x[2] are packed */
-        in1 = (q15_t) x1;
-        in2 = (q15_t) x2;
+        in1 = (q15_t)x1;
+        in2 = (q15_t)x2;
 
-        input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U);
+        input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U);
 
         /* acc1 += x[1] * y[0] + x[2] * y[1] */
         acc1 = __SMLAD(input1, input2, acc1);
 
         /* x[2] and x[3] are packed */
-        in1 = (q15_t) x2;
-        in2 = (q15_t) x3;
+        in1 = (q15_t)x2;
+        in2 = (q15_t)x3;
 
-        input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U);
+        input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U);
 
         /* acc2 += x[2] * y[0] + x[3] * y[1]  */
         acc2 = __SMLAD(input1, input2, acc2);
@@ -359,10 +357,10 @@ void arm_correlate_q7(
         x0 = *px++;
 
         /* x[3] and x[4] are packed */
-        in1 = (q15_t) x3;
-        in2 = (q15_t) x0;
+        in1 = (q15_t)x3;
+        in2 = (q15_t)x0;
 
-        input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U);
+        input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U);
 
         /* acc3 += x[3] * y[0] + x[4] * y[1]  */
         acc3 = __SMLAD(input1, input2, acc3);
@@ -376,34 +374,34 @@ void arm_correlate_q7(
         x1 = *px++;
 
         /* x[2] and x[3] are packed */
-        in1 = (q15_t) x2;
-        in2 = (q15_t) x3;
+        in1 = (q15_t)x2;
+        in2 = (q15_t)x3;
 
-        input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U);
+        input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U);
 
         /* y[2] and y[3] are packed */
-        in1 = (q15_t) c0;
-        in2 = (q15_t) c1;
+        in1 = (q15_t)c0;
+        in2 = (q15_t)c1;
 
-        input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U);
+        input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U);
 
         /* acc0 += x[2] * y[2] + x[3] * y[3]  */
         acc0 = __SMLAD(input1, input2, acc0);
 
         /* x[3] and x[4] are packed */
-        in1 = (q15_t) x3;
-        in2 = (q15_t) x0;
+        in1 = (q15_t)x3;
+        in2 = (q15_t)x0;
 
-        input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U);
+        input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U);
 
         /* acc1 += x[3] * y[2] + x[4] * y[3]  */
         acc1 = __SMLAD(input1, input2, acc1);
 
         /* x[4] and x[5] are packed */
-        in1 = (q15_t) x0;
-        in2 = (q15_t) x1;
+        in1 = (q15_t)x0;
+        in2 = (q15_t)x1;
 
-        input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U);
+        input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U);
 
         /* acc2 += x[4] * y[2] + x[5] * y[3]  */
         acc2 = __SMLAD(input1, input2, acc2);
@@ -412,10 +410,10 @@ void arm_correlate_q7(
         x2 = *px++;
 
         /* x[5] and x[6] are packed */
-        in1 = (q15_t) x1;
-        in2 = (q15_t) x2;
+        in1 = (q15_t)x1;
+        in2 = (q15_t)x2;
 
-        input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U);
+        input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U);
 
         /* acc3 += x[5] * y[2] + x[6] * y[3]  */
         acc3 = __SMLAD(input1, input2, acc3);
@@ -426,8 +424,7 @@ void arm_correlate_q7(
        ** No loop unrolling is used. */
       k = srcBLen % 0x4U;
 
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Read y[4] sample */
         c0 = *py++;
         /* Read x[7] sample */
@@ -435,13 +432,13 @@ void arm_correlate_q7(
 
         /* Perform the multiply-accumulates */
         /* acc0 +=  x[4] * y[4] */
-        acc0 += ((q15_t) x0 * c0);
+        acc0 += ((q15_t)x0 * c0);
         /* acc1 +=  x[5] * y[4] */
-        acc1 += ((q15_t) x1 * c0);
+        acc1 += ((q15_t)x1 * c0);
         /* acc2 +=  x[6] * y[4] */
-        acc2 += ((q15_t) x2 * c0);
+        acc2 += ((q15_t)x2 * c0);
         /* acc3 +=  x[7] * y[4] */
-        acc3 += ((q15_t) x3 * c0);
+        acc3 += ((q15_t)x3 * c0);
 
         /* Reuse the present samples for the next MAC */
         x0 = x1;
@@ -453,20 +450,21 @@ void arm_correlate_q7(
       }
 
       /* Store the result in the accumulator in the destination buffer. */
-      *pOut = (q7_t) (__SSAT(acc0 >> 7, 8));
-      /* Destination pointer is updated according to the address modifier, inc */
+      *pOut = (q7_t)(__SSAT(acc0 >> 7, 8));
+      /* Destination pointer is updated according to the address modifier, inc
+       */
       pOut += inc;
 
-      *pOut = (q7_t) (__SSAT(acc1 >> 7, 8));
+      *pOut = (q7_t)(__SSAT(acc1 >> 7, 8));
       pOut += inc;
 
-      *pOut = (q7_t) (__SSAT(acc2 >> 7, 8));
+      *pOut = (q7_t)(__SSAT(acc2 >> 7, 8));
       pOut += inc;
 
-      *pOut = (q7_t) (__SSAT(acc3 >> 7, 8));
+      *pOut = (q7_t)(__SSAT(acc3 >> 7, 8));
       pOut += inc;
 
-	  count += 4U;
+      count += 4U;
       /* Update the inputA and inputB pointers for next MAC calculation */
       px = pIn1 + count;
       py = pIn2;
@@ -485,41 +483,39 @@ void arm_correlate_q7(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-    while (blkCnt > 0U)
-    {
+    while (blkCnt > 0U) {
       /* Accumulator is made zero for every iteration */
       sum = 0;
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
-    /* Loop unrolling: Compute 4 outputs at a time */
+      /* Loop unrolling: Compute 4 outputs at a time */
       k = srcBLen >> 2U;
 
-      while (k > 0U)
-      {
+      while (k > 0U) {
 
         /* Reading two inputs of SrcA buffer and packing */
-        in1 = (q15_t) *px++;
-        in2 = (q15_t) *px++;
-        input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U);
+        in1 = (q15_t)*px++;
+        in2 = (q15_t)*px++;
+        input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U);
 
         /* Reading two inputs of SrcB buffer and packing */
-        in1 = (q15_t) *py++;
-        in2 = (q15_t) *py++;
-        input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U);
+        in1 = (q15_t)*py++;
+        in2 = (q15_t)*py++;
+        input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U);
 
         /* Perform the multiply-accumulate */
         sum = __SMLAD(input1, input2, sum);
 
         /* Reading two inputs of SrcA buffer and packing */
-        in1 = (q15_t) *px++;
-        in2 = (q15_t) *px++;
-        input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U);
+        in1 = (q15_t)*px++;
+        in2 = (q15_t)*px++;
+        input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U);
 
         /* Reading two inputs of SrcB buffer and packing */
-        in1 = (q15_t) *py++;
-        in2 = (q15_t) *py++;
-        input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U);
+        in1 = (q15_t)*py++;
+        in2 = (q15_t)*py++;
+        input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U);
 
         /* Perform the multiply-accumulate */
         sum = __SMLAD(input1, input2, sum);
@@ -538,18 +534,18 @@ void arm_correlate_q7(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Perform the multiply-accumulate */
-        sum += ((q15_t) *px++ * *py++);
+        sum += ((q15_t)*px++ * *py++);
 
         /* Decrement the loop counter */
         k--;
       }
 
       /* Store the result in the accumulator in the destination buffer. */
-      *pOut = (q7_t) (__SSAT(sum >> 7U, 8));
-      /* Destination pointer is updated according to the address modifier, inc */
+      *pOut = (q7_t)(__SSAT(sum >> 7U, 8));
+      /* Destination pointer is updated according to the address modifier, inc
+       */
       pOut += inc;
 
       /* Increment the pointer pIn1 index, count by 1 */
@@ -562,33 +558,30 @@ void arm_correlate_q7(
       /* Decrement the loop counter */
       blkCnt--;
     }
-  }
-  else
-  {
+  } else {
     /* If the srcBLen is not a multiple of 4,
      * the blockSize2 loop cannot be unrolled by 4 */
     blkCnt = blockSize2;
 
-    while (blkCnt > 0U)
-    {
+    while (blkCnt > 0U) {
       /* Accumulator is made zero for every iteration */
       sum = 0;
 
       /* srcBLen number of MACS should be performed */
       k = srcBLen;
 
-      while (k > 0U)
-      {
+      while (k > 0U) {
         /* Perform the multiply-accumulate */
-        sum += ((q15_t) *px++ * *py++);
+        sum += ((q15_t)*px++ * *py++);
 
         /* Decrement the loop counter */
         k--;
       }
 
       /* Store the result in the accumulator in the destination buffer. */
-      *pOut = (q7_t) (__SSAT(sum >> 7U, 8));
-      /* Destination pointer is updated according to the address modifier, inc */
+      *pOut = (q7_t)(__SSAT(sum >> 7U, 8));
+      /* Destination pointer is updated according to the address modifier, inc
+       */
       pOut += inc;
 
       /* Increment the MAC count */
@@ -603,13 +596,13 @@ void arm_correlate_q7(
     }
   }
 
-
   /* --------------------------
    * Initializations of stage3
    * -------------------------*/
 
-  /* sum += x[srcALen-srcBLen+1] * y[0] + x[srcALen-srcBLen+2] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
-   * sum += x[srcALen-srcBLen+2] * y[0] + x[srcALen-srcBLen+3] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
+  /* sum += x[srcALen-srcBLen+1] * y[0] + x[srcALen-srcBLen+2] * y[1] +...+
+   * x[srcALen-1] * y[srcBLen-1] sum += x[srcALen-srcBLen+2] * y[0] +
+   * x[srcALen-srcBLen+3] * y[1] +...+ x[srcALen-1] * y[srcBLen-1]
    * ....
    * sum +=  x[srcALen-2] * y[0] + x[srcALen-1] * y[1]
    * sum +=  x[srcALen-1] * y[0]
@@ -630,41 +623,39 @@ void arm_correlate_q7(
    * Stage3 process
    * ------------------*/
 
-  while (blockSize3 > 0U)
-  {
+  while (blockSize3 > 0U) {
     /* Accumulator is made zero for every iteration */
     sum = 0;
 
-#if defined (ARM_MATH_LOOPUNROLL)
+#if defined(ARM_MATH_LOOPUNROLL)
 
     /* Loop unrolling: Compute 4 outputs at a time */
     k = count >> 2U;
 
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* x[srcALen - srcBLen + 1] , x[srcALen - srcBLen + 2]  */
-      in1 = (q15_t) *px++;
-      in2 = (q15_t) *px++;
-      input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U);
+      in1 = (q15_t)*px++;
+      in2 = (q15_t)*px++;
+      input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U);
 
       /* y[0] , y[1] */
-      in1 = (q15_t) *py++;
-      in2 = (q15_t) *py++;
-      input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U);
+      in1 = (q15_t)*py++;
+      in2 = (q15_t)*py++;
+      input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U);
 
       /* sum += x[srcALen - srcBLen + 1] * y[0] */
       /* sum += x[srcALen - srcBLen + 2] * y[1] */
       sum = __SMLAD(input1, input2, sum);
 
       /* x[srcALen - srcBLen + 3] , x[srcALen - srcBLen + 4] */
-      in1 = (q15_t) *px++;
-      in2 = (q15_t) *px++;
-      input1 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U);
+      in1 = (q15_t)*px++;
+      in2 = (q15_t)*px++;
+      input1 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U);
 
       /* y[2] , y[3] */
-      in1 = (q15_t) *py++;
-      in2 = (q15_t) *py++;
-      input2 = ((q31_t) in1 & 0x0000FFFF) | ((q31_t) in2 << 16U);
+      in1 = (q15_t)*py++;
+      in2 = (q15_t)*py++;
+      input2 = ((q31_t)in1 & 0x0000FFFF) | ((q31_t)in2 << 16U);
 
       /* sum += x[srcALen - srcBLen + 3] * y[2] */
       /* sum += x[srcALen - srcBLen + 4] * y[3] */
@@ -684,17 +675,16 @@ void arm_correlate_q7(
 
 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
 
-    while (k > 0U)
-    {
+    while (k > 0U) {
       /* Perform the multiply-accumulate */
-      sum += ((q15_t) *px++ * *py++);
+      sum += ((q15_t)*px++ * *py++);
 
       /* Decrement loop counter */
       k--;
     }
 
     /* Store the result in the accumulator in the destination buffer. */
-    *pOut = (q7_t) (__SSAT(sum >> 7U, 8));
+    *pOut = (q7_t)(__SSAT(sum >> 7U, 8));
     /* Destination pointer is updated according to the address modifier, inc */
     pOut += inc;
 
@@ -710,20 +700,21 @@ void arm_correlate_q7(
   }
 
 #else
-/* alternate version for CM0_FAMILY */
+  /* alternate version for CM0_FAMILY */
 
-  const q7_t *pIn1 = pSrcA;                            /* InputA pointer */
-  const q7_t *pIn2 = pSrcB + (srcBLen - 1U);           /* InputB pointer */
-        q31_t sum;                                     /* Accumulator */
-        uint32_t i = 0U, j;                            /* Loop counters */
-        uint32_t inv = 0U;                             /* Reverse order flag */
-        uint32_t tot = 0U;                             /* Length */
+  const q7_t *pIn1 = pSrcA;                  /* InputA pointer */
+  const q7_t *pIn2 = pSrcB + (srcBLen - 1U); /* InputB pointer */
+  q31_t sum;                                 /* Accumulator */
+  uint32_t i = 0U, j;                        /* Loop counters */
+  uint32_t inv = 0U;                         /* Reverse order flag */
+  uint32_t tot = 0U;                         /* Length */
 
   /* The algorithm implementation is based on the lengths of the inputs. */
   /* srcB is always made to slide across srcA. */
   /* So srcBLen is always considered as shorter or equal to srcALen */
   /* But CORR(x, y) is reverse of CORR(y, x) */
-  /* So, when srcBLen > srcALen, output pointer is made to point to the end of the output buffer */
+  /* So, when srcBLen > srcALen, output pointer is made to point to the end of
+   * the output buffer */
   /* and a varaible, inv is set to 1 */
   /* If lengths are not equal then zero pad has to be done to  make the two
    * inputs of same length. But to improve the performance, we include zeroes
@@ -738,8 +729,7 @@ void arm_correlate_q7(
   /* Calculate the length of the remaining sequence */
   tot = ((srcALen + srcBLen) - 2U);
 
-  if (srcALen > srcBLen)
-  {
+  if (srcALen > srcBLen) {
     /* Calculating the number of zeros to be padded to the output */
     j = srcALen - srcBLen;
 
@@ -747,8 +737,7 @@ void arm_correlate_q7(
     pDst += j;
   }
 
-  else if (srcALen < srcBLen)
-  {
+  else if (srcALen < srcBLen) {
     /* Initialization to inputB pointer */
     pIn1 = pSrcB;
 
@@ -768,31 +757,27 @@ void arm_correlate_q7(
   }
 
   /* Loop to calculate convolution for output length number of times */
-  for (i = 0U; i <= tot; i++)
-  {
+  for (i = 0U; i <= tot; i++) {
     /* Initialize sum with zero to carry out MAC operations */
     sum = 0;
 
     /* Loop to perform MAC operations according to convolution equation */
-    for (j = 0U; j <= i; j++)
-    {
+    for (j = 0U; j <= i; j++) {
       /* Check the array limitations */
-      if (((i - j) < srcBLen) && (j < srcALen))
-      {
+      if (((i - j) < srcBLen) && (j < srcALen)) {
         /* z[i] += x[i-j] * y[j] */
-        sum += ((q15_t) pIn1[j] * pIn2[-((int32_t) i - j)]);
+        sum += ((q15_t)pIn1[j] * pIn2[-((int32_t)i - j)]);
       }
     }
 
     /* Store the output in the destination buffer */
     if (inv == 1)
-      *pDst-- = (q7_t) __SSAT((sum >> 7U), 8U);
+      *pDst-- = (q7_t)__SSAT((sum >> 7U), 8U);
     else
-      *pDst++ = (q7_t) __SSAT((sum >> 7U), 8U);
+      *pDst++ = (q7_t)__SSAT((sum >> 7U), 8U);
   }
 
 #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */
-
 }
 
 /**
diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_f32.c
index 3287116..0736900 100644
--- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_f32.c
+++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_f32.c
@@ -36,79 +36,93 @@
   @defgroup FIR_decimate Finite Impulse Response (FIR) Decimator
 
   These functions combine an FIR filter together with a decimator.
-  They are used in multirate systems for reducing the sample rate of a signal without introducing aliasing distortion.
-  Conceptually, the functions are equivalent to the block diagram below:
-  \image html FIRDecimator.gif "Components included in the FIR Decimator functions"
-  When decimating by a factor of M, the signal should be prefiltered by a lowpass filter with a normalized
-  cutoff frequency of 1/M in order to prevent aliasing distortion.
-  The user of the function is responsible for providing the filter coefficients.
+  They are used in multirate systems for reducing the sample rate of a signal
+ without introducing aliasing distortion. Conceptually, the functions are
+ equivalent to the block diagram below: \image html FIRDecimator.gif "Components
+ included in the FIR Decimator functions" When decimating by a factor of
+ M, the signal should be prefiltered by a lowpass filter with a
+ normalized cutoff frequency of 1/M in order to prevent aliasing
+ distortion. The user of the function is responsible for providing the filter
+ coefficients.
 
-  The FIR decimator functions provided in the CMSIS DSP Library combine the FIR filter and the decimator in an efficient manner.
-  Instead of calculating all of the FIR filter outputs and discarding M-1 out of every M, only the
-  samples output by the decimator are computed.
-  The functions operate on blocks of input and output data.
-  pSrc points to an array of blockSize input values and
-  pDst points to an array of blockSize/M output values.
-  In order to have an integer number of output samples blockSize
-  must always be a multiple of the decimation factor M.
+  The FIR decimator functions provided in the CMSIS DSP Library combine the FIR
+ filter and the decimator in an efficient manner. Instead of calculating all of
+ the FIR filter outputs and discarding M-1 out of every
+ M, only the samples output by the decimator are computed. The
+ functions operate on blocks of input and output data. pSrc points
+ to an array of blockSize input values and pDst points
+ to an array of blockSize/M output values. In order to have an
+ integer number of output samples blockSize must always be a
+ multiple of the decimation factor M.
 
-  The library provides separate functions for Q15, Q31 and floating-point data types.
+  The library provides separate functions for Q15, Q31 and floating-point data
+ types.
 
   @par           Algorithm:
-                   The FIR portion of the algorithm uses the standard form filter:
-  
-      y[n] = b[0] * x[n] + b[1] * x[n-1] + b[2] * x[n-2] + ...+ b[numTaps-1] * x[n-numTaps+1]
+                   The FIR portion of the algorithm uses the standard form
+ filter: 
 y[n] = b[0] * x[n] + b[1] * x[n-1] + b[2] * x[n-2] + ...+
+ b[numTaps-1] * x[n-numTaps+1]
   
where, b[n] are the filter coefficients. @par - The pCoeffs points to a coefficient array of size numTaps. - Coefficients are stored in time reversed order. + The pCoeffs points to a coefficient array of + size numTaps. Coefficients are stored in time reversed order. @par
       {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
   
@par - pState points to a state array of size numTaps + blockSize - 1. - Samples in the state buffer are stored in the order: + pState points to a state array of size + numTaps + blockSize - 1. Samples in the state buffer are stored in + the order: @par
-      {x[n-numTaps+1], x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2]....x[0], x[1], ..., x[blockSize-1]}
+      {x[n-numTaps+1], x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2]....x[0],
+ x[1], ..., x[blockSize-1]}
   
- The state variables are updated after each block of data is processed, the coefficients are untouched. + The state variables are updated after each block of data is + processed, the coefficients are untouched. @par Instance Structure - The coefficients and state variables for a filter are stored together in an instance data structure. - A separate instance structure must be defined for each filter. - Coefficient arrays may be shared among several instances while state variable array should be allocated separately. - There are separate instance structure declarations for each of the 3 supported data types. + The coefficients and state variables for a filter are stored + together in an instance data structure. A separate instance structure must be + defined for each filter. Coefficient arrays may be shared among several + instances while state variable array should be allocated separately. There are + separate instance structure declarations for each of the 3 supported data + types. @par Initialization Functions - There is also an associated initialization function for each data type. - The initialization function performs the following operations: + There is also an associated initialization function for each + data type. The initialization function performs the following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. - - Checks to make sure that the size of the input is a multiple of the decimation factor. - To do this manually without calling the init function, assign the follow subfields of the instance structure: - numTaps, pCoeffs, M (decimation factor), pState. Also set all of the values in pState to zero. + - Checks to make sure that the size of the input is a + multiple of the decimation factor. To do this manually without calling the init + function, assign the follow subfields of the instance structure: numTaps, + pCoeffs, M (decimation factor), pState. Also set all of the values in pState to + zero. @par Use of the initialization function is optional. - However, if the initialization function is used, then the instance structure cannot be placed into a const data section. - To place an instance structure into a const data section, the instance structure must be manually initialized. - The code below statically initializes each of the 3 different data type filter instance structures -
+                   However, if the initialization function is used, then the
+ instance structure cannot be placed into a const data section. To place an
+ instance structure into a const data section, the instance structure must be
+ manually initialized. The code below statically initializes each of the 3
+ different data type filter instance structures 
       arm_fir_decimate_instance_f32 S = {M, numTaps, pCoeffs, pState};
       arm_fir_decimate_instance_q31 S = {M, numTaps, pCoeffs, pState};
       arm_fir_decimate_instance_q15 S = {M, numTaps, pCoeffs, pState};
   
- where M is the decimation factor; numTaps is the number of filter coefficients in the filter; - pCoeffs is the address of the coefficient buffer; - pState is the address of the state buffer. - Be sure to set the values in the state buffer to zeros when doing static initialization. + where M is the decimation factor; + numTaps is the number of filter coefficients in the filter; + pCoeffs is the address of the coefficient + buffer; pState is the address of the state buffer. Be sure to set + the values in the state buffer to zeros when doing static initialization. @par Fixed-Point Behavior - Care must be taken when using the fixed-point versions of the FIR decimate filter functions. - In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. - Refer to the function specific documentation below for usage guidelines. + Care must be taken when using the fixed-point versions of the + FIR decimate filter functions. In particular, the overflow and saturation + behavior of the accumulator used in each function must be considered. Refer to + the function specific documentation below for usage guidelines. */ /** @@ -118,52 +132,53 @@ /** @brief Processing function for floating-point FIR decimator. - @param[in] S points to an instance of the floating-point FIR decimator structure + @param[in] S points to an instance of the floating-point FIR + decimator structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none */ -void arm_fir_decimate_f32( - const arm_fir_decimate_instance_f32 * S, - const float32_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - float32_t *pState = S->pState; /* State pointer */ - const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - float32_t *pStateCur; /* Points to the current sample of the state */ - float32_t *px0; /* Temporary pointer for state buffer */ - const float32_t *pb; /* Temporary pointer for coefficient buffer */ - float32_t x0, c0; /* Temporary variables to hold state and coefficient values */ - float32_t acc0; /* Accumulator */ - uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ - uint32_t i, tapCnt, blkCnt, outBlockSize = blockSize / S->M; /* Loop counters */ +void arm_fir_decimate_f32(const arm_fir_decimate_instance_f32 *S, + const float32_t *pSrc, float32_t *pDst, + uint32_t blockSize) { + float32_t *pState = S->pState; /* State pointer */ + const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + float32_t *pStateCur; /* Points to the current sample of the state */ + float32_t *px0; /* Temporary pointer for state buffer */ + const float32_t *pb; /* Temporary pointer for coefficient buffer */ + float32_t x0, + c0; /* Temporary variables to hold state and coefficient values */ + float32_t acc0; /* Accumulator */ + uint32_t numTaps = + S->numTaps; /* Number of filter coefficients in the filter */ + uint32_t i, tapCnt, blkCnt, + outBlockSize = blockSize / S->M; /* Loop counters */ -#if defined (ARM_MATH_LOOPUNROLL) - float32_t *px1, *px2, *px3; - float32_t x1, x2, x3; - float32_t acc1, acc2, acc3; +#if defined(ARM_MATH_LOOPUNROLL) + float32_t *px1, *px2, *px3; + float32_t x1, x2, x3; + float32_t acc1, acc2, acc3; #endif /* S->pState buffer contains previous frame (numTaps - 1) samples */ - /* pStateCur points to the location where the new input data should be written */ + /* pStateCur points to the location where the new input data should be written + */ pStateCur = S->pState + (numTaps - 1U); -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) - /* Loop unrolling: Compute 4 samples at a time */ + /* Loop unrolling: Compute 4 samples at a time */ blkCnt = outBlockSize >> 2U; /* Samples loop unrolled by 4 */ - while (blkCnt > 0U) - { - /* Copy 4 * decimation factor number of new input samples into the state buffer */ + while (blkCnt > 0U) { + /* Copy 4 * decimation factor number of new input samples into the state + * buffer */ i = S->M * 4; - do - { + do { *pStateCur++ = *pSrc++; } while (--i); @@ -186,8 +201,7 @@ void arm_fir_decimate_f32( /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the b[numTaps-1] coefficient */ c0 = *(pb++); @@ -258,8 +272,7 @@ void arm_fir_decimate_f32( /* Loop unrolling: Compute remaining taps */ tapCnt = numTaps % 0x4U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read coefficients */ c0 = *(pb++); @@ -303,13 +316,12 @@ void arm_fir_decimate_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { - /* Copy decimation factor number of new input samples into the state buffer */ + while (blkCnt > 0U) { + /* Copy decimation factor number of new input samples into the state buffer + */ i = S->M; - do - { + do { *pStateCur++ = *pSrc++; } while (--i); @@ -323,13 +335,12 @@ void arm_fir_decimate_f32( /* Initialize coeff pointer */ pb = pCoeffs; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the b[numTaps-1] coefficient */ c0 = *pb++; @@ -380,8 +391,7 @@ void arm_fir_decimate_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read coefficients */ c0 = *pb++; @@ -413,14 +423,13 @@ void arm_fir_decimate_f32( /* Points to the start of the state buffer */ pStateCur = S->pState; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = (numTaps - 1U) >> 2U; /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; @@ -441,14 +450,12 @@ void arm_fir_decimate_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_fast_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_fast_q15.c index 948b15c..a9dddca 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_fast_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_fast_q15.c @@ -39,7 +39,8 @@ /** @brief Processing function for the Q15 FIR decimator (fast variant). - @param[in] S points to an instance of the Q15 FIR decimator structure + @param[in] S points to an instance of the Q15 FIR decimator + structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of input samples to process per call @@ -47,56 +48,59 @@ @par Scaling and Overflow Behavior This fast version uses a 32-bit accumulator with 2.30 format. - The accumulator maintains full precision of the intermediate multiplication results but provides only a single guard bit. - Thus, if the accumulator result overflows it wraps around and distorts the result. - In order to avoid overflows completely the input signal must be scaled down by log2(numTaps) bits (log2 is read as log to the base 2). - The 2.30 accumulator is then truncated to 2.15 format and saturated to yield the 1.15 result. + The accumulator maintains full precision of the intermediate + multiplication results but provides only a single guard bit. Thus, if the + accumulator result overflows it wraps around and distorts the result. In order + to avoid overflows completely the input signal must be scaled down by + log2(numTaps) bits (log2 is read as log to the base 2). The 2.30 accumulator + is then truncated to 2.15 format and saturated to yield the 1.15 result. @remark - Refer to \ref arm_fir_decimate_q15() for a slower implementation of this function which uses 64-bit accumulation to avoid wrap around distortion. - Both the slow and the fast versions use the same instance structure. - Use function \ref arm_fir_decimate_init_q15() to initialize the filter structure. + Refer to \ref arm_fir_decimate_q15() for a slower + implementation of this function which uses 64-bit accumulation to avoid wrap + around distortion. Both the slow and the fast versions use the same instance + structure. Use function \ref arm_fir_decimate_init_q15() to initialize the + filter structure. */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) -void arm_fir_decimate_fast_q15( - const arm_fir_decimate_instance_q15 * S, - const q15_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - q15_t *pState = S->pState; /* State pointer */ - const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q15_t *pStateCur; /* Points to the current sample of the state */ - q15_t *px; /* Temporary pointer for state buffer */ - const q15_t *pb; /* Temporary pointer for coefficient buffer */ - q31_t x0, x1, c0; /* Temporary variables to hold state and coefficient values */ - q31_t sum0; /* Accumulators */ - q31_t acc0, acc1; - q15_t *px0, *px1; - uint32_t blkCntN3; - uint32_t numTaps = S->numTaps; /* Number of taps */ - uint32_t i, blkCnt, tapCnt, outBlockSize = blockSize / S->M; /* Loop counters */ +void arm_fir_decimate_fast_q15(const arm_fir_decimate_instance_q15 *S, + const q15_t *pSrc, q15_t *pDst, + uint32_t blockSize) { + q15_t *pState = S->pState; /* State pointer */ + const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q15_t *pStateCur; /* Points to the current sample of the state */ + q15_t *px; /* Temporary pointer for state buffer */ + const q15_t *pb; /* Temporary pointer for coefficient buffer */ + q31_t x0, x1, + c0; /* Temporary variables to hold state and coefficient values */ + q31_t sum0; /* Accumulators */ + q31_t acc0, acc1; + q15_t *px0, *px1; + uint32_t blkCntN3; + uint32_t numTaps = S->numTaps; /* Number of taps */ + uint32_t i, blkCnt, tapCnt, + outBlockSize = blockSize / S->M; /* Loop counters */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t c1; /* Temporary variables to hold state and coefficient values */ +#if defined(ARM_MATH_LOOPUNROLL) + q31_t c1; /* Temporary variables to hold state and coefficient values */ #endif /* S->pState buffer contains previous frame (numTaps - 1) samples */ - /* pStateCur points to the location where the new input data should be written */ + /* pStateCur points to the location where the new input data should be written + */ pStateCur = S->pState + (numTaps - 1U); /* Total number of output samples to be computed */ blkCnt = outBlockSize / 2; blkCntN3 = outBlockSize - (2 * blkCnt); - while (blkCnt > 0U) - { - /* Copy 2 * decimation factor number of new input samples into the state buffer */ + while (blkCnt > 0U) { + /* Copy 2 * decimation factor number of new input samples into the state + * buffer */ i = S->M * 2; - do - { + do { *pStateCur++ = *pSrc++; } while (--i); @@ -112,30 +116,29 @@ void arm_fir_decimate_fast_q15( /* Initialize coeff pointer */ pb = pCoeffs; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the b[numTaps-1] and b[numTaps-2] coefficients */ - c0 = read_q15x2_ia ((q15_t **) &pb); + c0 = read_q15x2_ia((q15_t **)&pb); /* Read x[n-numTaps-1] and x[n-numTaps-2]sample */ - x0 = read_q15x2_ia (&px0); - x1 = read_q15x2_ia (&px1); + x0 = read_q15x2_ia(&px0); + x1 = read_q15x2_ia(&px1); /* Perform the multiply-accumulate */ acc0 = __SMLAD(x0, c0, acc0); acc1 = __SMLAD(x1, c0, acc1); /* Read the b[numTaps-3] and b[numTaps-4] coefficient */ - c0 = read_q15x2_ia ((q15_t **) &pb); + c0 = read_q15x2_ia((q15_t **)&pb); /* Read x[n-numTaps-2] and x[n-numTaps-3] sample */ - x0 = read_q15x2_ia (&px0); - x1 = read_q15x2_ia (&px1); + x0 = read_q15x2_ia(&px0); + x1 = read_q15x2_ia(&px1); /* Perform the multiply-accumulate */ acc0 = __SMLAD(x0, c0, acc0); @@ -155,8 +158,7 @@ void arm_fir_decimate_fast_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read coefficients */ c0 = *pb++; @@ -178,20 +180,19 @@ void arm_fir_decimate_fast_q15( /* Store filter output, smlad returns the values in 2.14 format */ /* so downsacle by 15 to get output in 1.15 */ - *pDst++ = (q15_t) (__SSAT((acc0 >> 15), 16)); - *pDst++ = (q15_t) (__SSAT((acc1 >> 15), 16)); + *pDst++ = (q15_t)(__SSAT((acc0 >> 15), 16)); + *pDst++ = (q15_t)(__SSAT((acc1 >> 15), 16)); /* Decrement loop counter */ blkCnt--; } - while (blkCntN3 > 0U) - { - /* Copy decimation factor number of new input samples into the state buffer */ + while (blkCntN3 > 0U) { + /* Copy decimation factor number of new input samples into the state buffer + */ i = S->M; - do - { + do { *pStateCur++ = *pSrc++; } while (--i); @@ -205,27 +206,26 @@ void arm_fir_decimate_fast_q15( /* Initialize coeff pointer */ pb = pCoeffs; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the b[numTaps-1] and b[numTaps-2] coefficients */ - c0 = read_q15x2_ia ((q15_t **) &pb); + c0 = read_q15x2_ia((q15_t **)&pb); /* Read x[n-numTaps-1] and x[n-numTaps-2] sample */ - x0 = read_q15x2_ia (&px); + x0 = read_q15x2_ia(&px); /* Read the b[numTaps-3] and b[numTaps-4] coefficients */ - c1 = read_q15x2_ia ((q15_t **) &pb); + c1 = read_q15x2_ia((q15_t **)&pb); /* Perform the multiply-accumulate */ sum0 = __SMLAD(x0, c0, sum0); /* Read x[n-numTaps-2] and x[n-numTaps-3] sample */ - x0 = read_q15x2_ia (&px); + x0 = read_q15x2_ia(&px); /* Perform the multiply-accumulate */ sum0 = __SMLAD(x0, c1, sum0); @@ -244,8 +244,7 @@ void arm_fir_decimate_fast_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read coefficients */ c0 = *pb++; @@ -265,7 +264,7 @@ void arm_fir_decimate_fast_q15( /* Store filter output, smlad returns the values in 2.14 format */ /* so downsacle by 15 to get output in 1.15 */ - *pDst++ = (q15_t) (__SSAT((sum0 >> 15), 16)); + *pDst++ = (q15_t)(__SSAT((sum0 >> 15), 16)); /* Decrement loop counter */ blkCntN3--; @@ -281,10 +280,9 @@ void arm_fir_decimate_fast_q15( i = (numTaps - 1U) >> 2U; /* copy data */ - while (i > 0U) - { - write_q15x2_ia (&pStateCur, read_q15x2_ia (&pState)); - write_q15x2_ia (&pStateCur, read_q15x2_ia (&pState)); + while (i > 0U) { + write_q15x2_ia(&pStateCur, read_q15x2_ia(&pState)); + write_q15x2_ia(&pStateCur, read_q15x2_ia(&pState)); /* Decrement loop counter */ i--; @@ -293,53 +291,49 @@ void arm_fir_decimate_fast_q15( i = (numTaps - 1U) % 0x04U; /* Copy data */ - while (i > 0U) - { + while (i > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ i--; } - } #else /* #if defined (ARM_MATH_DSP) */ -void arm_fir_decimate_fast_q15( - const arm_fir_decimate_instance_q15 * S, - const q15_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - q15_t *pState = S->pState; /* State pointer */ - const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q15_t *pStateCur; /* Points to the current sample of the state */ - q15_t *px; /* Temporary pointer for state buffer */ - const q15_t *pb; /* Temporary pointer for coefficient buffer */ - q15_t x0, x1, c0; /* Temporary variables to hold state and coefficient values */ - q31_t sum0; /* Accumulators */ - q31_t acc0, acc1; - q15_t *px0, *px1; - uint32_t blkCntN3; - uint32_t numTaps = S->numTaps; /* Number of taps */ - uint32_t i, blkCnt, tapCnt, outBlockSize = blockSize / S->M; /* Loop counters */ - +void arm_fir_decimate_fast_q15(const arm_fir_decimate_instance_q15 *S, + const q15_t *pSrc, q15_t *pDst, + uint32_t blockSize) { + q15_t *pState = S->pState; /* State pointer */ + const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q15_t *pStateCur; /* Points to the current sample of the state */ + q15_t *px; /* Temporary pointer for state buffer */ + const q15_t *pb; /* Temporary pointer for coefficient buffer */ + q15_t x0, x1, + c0; /* Temporary variables to hold state and coefficient values */ + q31_t sum0; /* Accumulators */ + q31_t acc0, acc1; + q15_t *px0, *px1; + uint32_t blkCntN3; + uint32_t numTaps = S->numTaps; /* Number of taps */ + uint32_t i, blkCnt, tapCnt, + outBlockSize = blockSize / S->M; /* Loop counters */ /* S->pState buffer contains previous frame (numTaps - 1) samples */ - /* pStateCur points to the location where the new input data should be written */ + /* pStateCur points to the location where the new input data should be written + */ pStateCur = S->pState + (numTaps - 1U); /* Total number of output samples to be computed */ blkCnt = outBlockSize / 2; blkCntN3 = outBlockSize - (2 * blkCnt); - while (blkCnt > 0U) - { - /* Copy 2 * decimation factor number of new input samples into the state buffer */ + while (blkCnt > 0U) { + /* Copy 2 * decimation factor number of new input samples into the state + * buffer */ i = S->M * 2; - do - { + do { *pStateCur++ = *pSrc++; } while (--i); @@ -355,13 +349,12 @@ void arm_fir_decimate_fast_q15( /* Initialize coeff pointer */ pb = pCoeffs; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the Read b[numTaps-1] coefficients */ c0 = *pb++; @@ -420,8 +413,7 @@ void arm_fir_decimate_fast_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read coefficients */ c0 = *pb++; @@ -444,20 +436,19 @@ void arm_fir_decimate_fast_q15( /* Store filter output, smlad returns the values in 2.14 format */ /* so downsacle by 15 to get output in 1.15 */ - *pDst++ = (q15_t) (__SSAT((acc0 >> 15), 16)); - *pDst++ = (q15_t) (__SSAT((acc1 >> 15), 16)); + *pDst++ = (q15_t)(__SSAT((acc0 >> 15), 16)); + *pDst++ = (q15_t)(__SSAT((acc1 >> 15), 16)); /* Decrement loop counter */ blkCnt--; } - while (blkCntN3 > 0U) - { - /* Copy decimation factor number of new input samples into the state buffer */ + while (blkCntN3 > 0U) { + /* Copy decimation factor number of new input samples into the state buffer + */ i = S->M; - do - { + do { *pStateCur++ = *pSrc++; } while (--i); @@ -471,13 +462,12 @@ void arm_fir_decimate_fast_q15( /* Initialize coeff pointer */ pb = pCoeffs; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the b[numTaps-1] coefficient */ c0 = *pb++; @@ -528,8 +518,7 @@ void arm_fir_decimate_fast_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read coefficients */ c0 = *pb++; @@ -549,7 +538,7 @@ void arm_fir_decimate_fast_q15( /* Store filter output, smlad returns the values in 2.14 format */ /* so downsacle by 15 to get output in 1.15 */ - *pDst++ = (q15_t) (__SSAT((sum0 >> 15), 16)); + *pDst++ = (q15_t)(__SSAT((sum0 >> 15), 16)); /* Decrement loop counter */ blkCntN3--; @@ -565,8 +554,7 @@ void arm_fir_decimate_fast_q15( i = (numTaps - 1U) >> 2U; /* copy data */ - while (i > 0U) - { + while (i > 0U) { *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; @@ -579,8 +567,7 @@ void arm_fir_decimate_fast_q15( i = (numTaps - 1U) % 0x04U; /* copy data */ - while (i > 0U) - { + while (i > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_fast_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_fast_q31.c index 2c3a28a..31b45be 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_fast_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_fast_q31.c @@ -39,65 +39,70 @@ /** @brief Processing function for the Q31 FIR decimator (fast variant). - @param[in] S points to an instance of the Q31 FIR decimator structure + @param[in] S points to an instance of the Q31 FIR decimator + structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior - This function is optimized for speed at the expense of fixed-point precision and overflow protection. - The result of each 1.31 x 1.31 multiplication is truncated to 2.30 format. - These intermediate results are added to a 2.30 accumulator. - Finally, the accumulator is saturated and converted to a 1.31 result. - The fast version has the same overflow behavior as the standard version and provides less precision since it discards the low 32 bits of each multiplication result. - In order to avoid overflows completely the input signal must be scaled down by log2(numTaps) bits (where log2 is read as log to the base 2). + This function is optimized for speed at the expense of + fixed-point precision and overflow protection. The result of each 1.31 x 1.31 + multiplication is truncated to 2.30 format. These intermediate results are + added to a 2.30 accumulator. Finally, the accumulator is saturated and + converted to a 1.31 result. The fast version has the same overflow behavior as + the standard version and provides less precision since it discards the low 32 + bits of each multiplication result. In order to avoid overflows completely the + input signal must be scaled down by log2(numTaps) bits (where log2 is read as + log to the base 2). @remark - Refer to \ref arm_fir_decimate_q31() for a slower implementation of this function which uses a 64-bit accumulator to provide higher precision. - Both the slow and the fast versions use the same instance structure. - Use function \ref arm_fir_decimate_init_q31() to initialize the filter structure. + Refer to \ref arm_fir_decimate_q31() for a slower + implementation of this function which uses a 64-bit accumulator to provide + higher precision. Both the slow and the fast versions use the same instance + structure. Use function \ref arm_fir_decimate_init_q31() to initialize the + filter structure. */ -void arm_fir_decimate_fast_q31( - const arm_fir_decimate_instance_q31 * S, - const q31_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - q31_t *pState = S->pState; /* State pointer */ - const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q31_t *pStateCur; /* Points to the current sample of the state */ - q31_t *px0; /* Temporary pointer for state buffer */ - const q31_t *pb; /* Temporary pointer for coefficient buffer */ - q31_t x0, c0; /* Temporary variables to hold state and coefficient values */ - q63_t acc0; /* Accumulator */ - uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ - uint32_t i, tapCnt, blkCnt, outBlockSize = blockSize / S->M; /* Loop counters */ +void arm_fir_decimate_fast_q31(const arm_fir_decimate_instance_q31 *S, + const q31_t *pSrc, q31_t *pDst, + uint32_t blockSize) { + q31_t *pState = S->pState; /* State pointer */ + const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q31_t *pStateCur; /* Points to the current sample of the state */ + q31_t *px0; /* Temporary pointer for state buffer */ + const q31_t *pb; /* Temporary pointer for coefficient buffer */ + q31_t x0, c0; /* Temporary variables to hold state and coefficient values */ + q63_t acc0; /* Accumulator */ + uint32_t numTaps = + S->numTaps; /* Number of filter coefficients in the filter */ + uint32_t i, tapCnt, blkCnt, + outBlockSize = blockSize / S->M; /* Loop counters */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t *px1, *px2, *px3; - q31_t x1, x2, x3; - q63_t acc1, acc2, acc3; +#if defined(ARM_MATH_LOOPUNROLL) + q31_t *px1, *px2, *px3; + q31_t x1, x2, x3; + q63_t acc1, acc2, acc3; #endif /* S->pState buffer contains previous frame (numTaps - 1) samples */ - /* pStateCur points to the location where the new input data should be written */ + /* pStateCur points to the location where the new input data should be written + */ pStateCur = S->pState + (numTaps - 1U); -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) - /* Loop unrolling: Compute 4 samples at a time */ + /* Loop unrolling: Compute 4 samples at a time */ blkCnt = outBlockSize >> 2U; /* Samples loop unrolled by 4 */ - while (blkCnt > 0U) - { - /* Copy 4 * decimation factor number of new input samples into the state buffer */ + while (blkCnt > 0U) { + /* Copy 4 * decimation factor number of new input samples into the state + * buffer */ i = S->M * 4; - do - { + do { *pStateCur++ = *pSrc++; } while (--i); @@ -120,8 +125,7 @@ void arm_fir_decimate_fast_q31( /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the b[numTaps-1] coefficient */ c0 = *(pb++); @@ -135,10 +139,10 @@ void arm_fir_decimate_fast_q31( x3 = *(px3++); /* Perform the multiply-accumulate */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32); - acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32); - acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x2 * c0)) >> 32); - acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x3 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x0 * c0)) >> 32); + acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x1 * c0)) >> 32); + acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x2 * c0)) >> 32); + acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x3 * c0)) >> 32); /* Read the b[numTaps-2] coefficient */ c0 = *(pb++); @@ -150,10 +154,10 @@ void arm_fir_decimate_fast_q31( x3 = *(px3++); /* Perform the multiply-accumulate */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32); - acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32); - acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x2 * c0)) >> 32); - acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x3 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x0 * c0)) >> 32); + acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x1 * c0)) >> 32); + acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x2 * c0)) >> 32); + acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x3 * c0)) >> 32); /* Read the b[numTaps-3] coefficient */ c0 = *(pb++); @@ -165,10 +169,10 @@ void arm_fir_decimate_fast_q31( x3 = *(px3++); /* Perform the multiply-accumulate */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32); - acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32); - acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x2 * c0)) >> 32); - acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x3 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x0 * c0)) >> 32); + acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x1 * c0)) >> 32); + acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x2 * c0)) >> 32); + acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x3 * c0)) >> 32); /* Read the b[numTaps-4] coefficient */ c0 = *(pb++); @@ -180,10 +184,10 @@ void arm_fir_decimate_fast_q31( x3 = *(px3++); /* Perform the multiply-accumulate */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32); - acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32); - acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x2 * c0)) >> 32); - acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x3 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x0 * c0)) >> 32); + acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x1 * c0)) >> 32); + acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x2 * c0)) >> 32); + acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x3 * c0)) >> 32); /* Decrement loop counter */ tapCnt--; @@ -192,8 +196,7 @@ void arm_fir_decimate_fast_q31( /* Loop unrolling: Compute remaining taps */ tapCnt = numTaps % 0x4U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read coefficients */ c0 = *(pb++); @@ -204,10 +207,10 @@ void arm_fir_decimate_fast_q31( x3 = *(px3++); /* Perform the multiply-accumulate */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32); - acc1 = (q31_t) ((((q63_t) acc1 << 32) + ((q63_t) x1 * c0)) >> 32); - acc2 = (q31_t) ((((q63_t) acc2 << 32) + ((q63_t) x2 * c0)) >> 32); - acc3 = (q31_t) ((((q63_t) acc3 << 32) + ((q63_t) x3 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x0 * c0)) >> 32); + acc1 = (q31_t)((((q63_t)acc1 << 32) + ((q63_t)x1 * c0)) >> 32); + acc2 = (q31_t)((((q63_t)acc2 << 32) + ((q63_t)x2 * c0)) >> 32); + acc3 = (q31_t)((((q63_t)acc3 << 32) + ((q63_t)x3 * c0)) >> 32); /* Decrement loop counter */ tapCnt--; @@ -218,10 +221,10 @@ void arm_fir_decimate_fast_q31( pState = pState + S->M * 4; /* The result is in the accumulator, store in the destination buffer. */ - *pDst++ = (q31_t) (acc0 << 1); - *pDst++ = (q31_t) (acc1 << 1); - *pDst++ = (q31_t) (acc2 << 1); - *pDst++ = (q31_t) (acc3 << 1); + *pDst++ = (q31_t)(acc0 << 1); + *pDst++ = (q31_t)(acc1 << 1); + *pDst++ = (q31_t)(acc2 << 1); + *pDst++ = (q31_t)(acc3 << 1); /* Decrement loop counter */ blkCnt--; @@ -237,13 +240,12 @@ void arm_fir_decimate_fast_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { - /* Copy decimation factor number of new input samples into the state buffer */ + while (blkCnt > 0U) { + /* Copy decimation factor number of new input samples into the state buffer + */ i = S->M; - do - { + do { *pStateCur++ = *pSrc++; } while (--i); @@ -257,13 +259,12 @@ void arm_fir_decimate_fast_q31( /* Initialize coeff pointer */ pb = pCoeffs; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the b[numTaps-1] coefficient */ c0 = *pb++; @@ -271,7 +272,7 @@ void arm_fir_decimate_fast_q31( x0 = *px0++; /* Perform the multiply-accumulate */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x0 * c0)) >> 32); /* Read the b[numTaps-2] coefficient */ c0 = *pb++; @@ -280,7 +281,7 @@ void arm_fir_decimate_fast_q31( x0 = *px0++; /* Perform the multiply-accumulate */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x0 * c0)) >> 32); /* Read the b[numTaps-3] coefficient */ c0 = *pb++; @@ -289,7 +290,7 @@ void arm_fir_decimate_fast_q31( x0 = *px0++; /* Perform the multiply-accumulate */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x0 * c0)) >> 32); /* Read the b[numTaps-4] coefficient */ c0 = *pb++; @@ -298,7 +299,7 @@ void arm_fir_decimate_fast_q31( x0 = *px0++; /* Perform the multiply-accumulate */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x0 * c0)) >> 32); /* Decrement loop counter */ tapCnt--; @@ -314,8 +315,7 @@ void arm_fir_decimate_fast_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read coefficients */ c0 = *pb++; @@ -323,7 +323,7 @@ void arm_fir_decimate_fast_q31( x0 = *px0++; /* Perform the multiply-accumulate */ - acc0 = (q31_t) ((((q63_t) acc0 << 32) + ((q63_t) x0 * c0)) >> 32); + acc0 = (q31_t)((((q63_t)acc0 << 32) + ((q63_t)x0 * c0)) >> 32); /* Decrement loop counter */ tapCnt--; @@ -334,7 +334,7 @@ void arm_fir_decimate_fast_q31( pState = pState + S->M; /* The result is in the accumulator, store in the destination buffer. */ - *pDst++ = (q31_t) (acc0 << 1); + *pDst++ = (q31_t)(acc0 << 1); /* Decrement loop counter */ blkCnt--; @@ -347,14 +347,13 @@ void arm_fir_decimate_fast_q31( /* Points to the start of the state buffer */ pStateCur = S->pState; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = (numTaps - 1U) >> 2U; /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; @@ -375,14 +374,12 @@ void arm_fir_decimate_fast_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_init_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_init_f32.c index 9382f09..906a220 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_init_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_init_f32.c @@ -39,7 +39,8 @@ /** @brief Initialization function for the floating-point FIR decimator. - @param[in,out] S points to an instance of the floating-point FIR decimator structure + @param[in,out] S points to an instance of the floating-point FIR + decimator structure @param[in] numTaps number of coefficients in the filter @param[in] M decimation factor @param[in] pCoeffs points to the filter coefficients @@ -47,37 +48,33 @@ @param[in] blockSize number of input samples to process per call @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_LENGTH_ERROR : blockSize is not a multiple of M + - \ref ARM_MATH_LENGTH_ERROR : blockSize is not + a multiple of M @par Details - pCoeffs points to the array of filter coefficients stored in time reversed order: -
-      {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
+                   pCoeffs points to the array of filter
+  coefficients stored in time reversed order: 
 {b[numTaps-1], b[numTaps-2],
+  b[N-2], ..., b[1], b[0]}
   
@par pState points to the array of state variables. - pState is of length numTaps+blockSize-1 words where blockSize is the number of input samples passed to arm_fir_decimate_f32(). + pState is of length + numTaps+blockSize-1 words where blockSize is the + number of input samples passed to arm_fir_decimate_f32(). M is the decimation factor. */ -arm_status arm_fir_decimate_init_f32( - arm_fir_decimate_instance_f32 * S, - uint16_t numTaps, - uint8_t M, - const float32_t * pCoeffs, - float32_t * pState, - uint32_t blockSize) -{ +arm_status arm_fir_decimate_init_f32(arm_fir_decimate_instance_f32 *S, + uint16_t numTaps, uint8_t M, + const float32_t *pCoeffs, + float32_t *pState, uint32_t blockSize) { arm_status status; /* The size of the input block must be a multiple of the decimation factor */ - if ((blockSize % M) != 0U) - { + if ((blockSize % M) != 0U) { /* Set status as ARM_MATH_LENGTH_ERROR */ status = ARM_MATH_LENGTH_ERROR; - } - else - { + } else { /* Assign filter taps */ S->numTaps = numTaps; @@ -97,7 +94,6 @@ arm_status arm_fir_decimate_init_f32( } return (status); - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_init_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_init_q15.c index f583a03..8b50ef6 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_init_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_init_q15.c @@ -39,7 +39,8 @@ /** @brief Initialization function for the Q15 FIR decimator. - @param[in,out] S points to an instance of the Q15 FIR decimator structure + @param[in,out] S points to an instance of the Q15 FIR decimator + structure @param[in] numTaps number of coefficients in the filter @param[in] M decimation factor @param[in] pCoeffs points to the filter coefficients @@ -47,38 +48,33 @@ @param[in] blockSize number of input samples to process @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_LENGTH_ERROR : blockSize is not a multiple of M + - \ref ARM_MATH_LENGTH_ERROR : blockSize is not + a multiple of M @par Details - pCoeffs points to the array of filter coefficients stored in time reversed order: -
-      {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
+                   pCoeffs points to the array of filter
+  coefficients stored in time reversed order: 
 {b[numTaps-1], b[numTaps-2],
+  b[N-2], ..., b[1], b[0]}
   
@par pState points to the array of state variables. - pState is of length numTaps+blockSize-1 words where blockSize is the number of input samples - to the call arm_fir_decimate_q15(). + pState is of length + numTaps+blockSize-1 words where blockSize is the + number of input samples to the call arm_fir_decimate_q15(). M is the decimation factor. */ -arm_status arm_fir_decimate_init_q15( - arm_fir_decimate_instance_q15 * S, - uint16_t numTaps, - uint8_t M, - const q15_t * pCoeffs, - q15_t * pState, - uint32_t blockSize) -{ +arm_status arm_fir_decimate_init_q15(arm_fir_decimate_instance_q15 *S, + uint16_t numTaps, uint8_t M, + const q15_t *pCoeffs, q15_t *pState, + uint32_t blockSize) { arm_status status; /* The size of the input block must be a multiple of the decimation factor */ - if ((blockSize % M) != 0U) - { + if ((blockSize % M) != 0U) { /* Set status as ARM_MATH_LENGTH_ERROR */ status = ARM_MATH_LENGTH_ERROR; - } - else - { + } else { /* Assign filter taps */ S->numTaps = numTaps; @@ -98,7 +94,6 @@ arm_status arm_fir_decimate_init_q15( } return (status); - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_init_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_init_q31.c index 5ee69c6..b44ca57 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_init_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_init_q31.c @@ -39,7 +39,8 @@ /** @brief Initialization function for the Q31 FIR decimator. - @param[in,out] S points to an instance of the Q31 FIR decimator structure + @param[in,out] S points to an instance of the Q31 FIR decimator + structure @param[in] numTaps number of coefficients in the filter @param[in] M decimation factor @param[in] pCoeffs points to the filter coefficients @@ -47,37 +48,33 @@ @param[in] blockSize number of input samples to process @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_LENGTH_ERROR : blockSize is not a multiple of M + - \ref ARM_MATH_LENGTH_ERROR : blockSize is not + a multiple of M @par Details - pCoeffs points to the array of filter coefficients stored in time reversed order: -
-      {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
+                   pCoeffs points to the array of filter
+  coefficients stored in time reversed order: 
 {b[numTaps-1], b[numTaps-2],
+  b[N-2], ..., b[1], b[0]}
   
@par pState points to the array of state variables. - pState is of length numTaps+blockSize-1 words where blockSize is the number of input samples passed to arm_fir_decimate_q31(). + pState is of length + numTaps+blockSize-1 words where blockSize is the + number of input samples passed to arm_fir_decimate_q31(). M is the decimation factor. */ -arm_status arm_fir_decimate_init_q31( - arm_fir_decimate_instance_q31 * S, - uint16_t numTaps, - uint8_t M, - const q31_t * pCoeffs, - q31_t * pState, - uint32_t blockSize) -{ +arm_status arm_fir_decimate_init_q31(arm_fir_decimate_instance_q31 *S, + uint16_t numTaps, uint8_t M, + const q31_t *pCoeffs, q31_t *pState, + uint32_t blockSize) { arm_status status; /* The size of the input block must be a multiple of the decimation factor */ - if ((blockSize % M) != 0U) - { + if ((blockSize % M) != 0U) { /* Set status as ARM_MATH_LENGTH_ERROR */ status = ARM_MATH_LENGTH_ERROR; - } - else - { + } else { /* Assign filter taps */ S->numTaps = numTaps; @@ -97,7 +94,6 @@ arm_status arm_fir_decimate_init_q31( } return (status); - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_q15.c index f9d92c0..960e97c 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_q15.c @@ -39,64 +39,66 @@ /** @brief Processing function for the Q15 FIR decimator. - @param[in] S points to an instance of the Q15 FIR decimator structure + @param[in] S points to an instance of the Q15 FIR decimator + structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of input samples to process per call @return none @par Scaling and Overflow Behavior - The function is implemented using a 64-bit internal accumulator. - Both coefficients and state variables are represented in 1.15 format and multiplications yield a 2.30 result. - The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. - There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. - After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits. - Lastly, the accumulator is saturated to yield a result in 1.15 format. + The function is implemented using a 64-bit internal + accumulator. Both coefficients and state variables are represented in 1.15 + format and multiplications yield a 2.30 result. The 2.30 intermediate results + are accumulated in a 64-bit accumulator in 34.30 format. There is no risk of + internal overflow with this approach and the full precision of intermediate + multiplications is preserved. After all additions have been performed, the + accumulator is truncated to 34.15 format by discarding low 15 bits. Lastly, the + accumulator is saturated to yield a result in 1.15 format. @remark - Refer to \ref arm_fir_decimate_fast_q15() for a faster but less precise implementation of this function. + Refer to \ref arm_fir_decimate_fast_q15() for a faster but + less precise implementation of this function. */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) -void arm_fir_decimate_q15( - const arm_fir_decimate_instance_q15 * S, - const q15_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - q15_t *pState = S->pState; /* State pointer */ - const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q15_t *pStateCur; /* Points to the current sample of the state */ - q15_t *px; /* Temporary pointer for state buffer */ - const q15_t *pb; /* Temporary pointer for coefficient buffer */ - q31_t x0, x1, c0; /* Temporary variables to hold state and coefficient values */ - q63_t sum0; /* Accumulators */ - q63_t acc0, acc1; - q15_t *px0, *px1; - uint32_t blkCntN3; - uint32_t numTaps = S->numTaps; /* Number of taps */ - uint32_t i, blkCnt, tapCnt, outBlockSize = blockSize / S->M; /* Loop counters */ +void arm_fir_decimate_q15(const arm_fir_decimate_instance_q15 *S, + const q15_t *pSrc, q15_t *pDst, uint32_t blockSize) { + q15_t *pState = S->pState; /* State pointer */ + const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q15_t *pStateCur; /* Points to the current sample of the state */ + q15_t *px; /* Temporary pointer for state buffer */ + const q15_t *pb; /* Temporary pointer for coefficient buffer */ + q31_t x0, x1, + c0; /* Temporary variables to hold state and coefficient values */ + q63_t sum0; /* Accumulators */ + q63_t acc0, acc1; + q15_t *px0, *px1; + uint32_t blkCntN3; + uint32_t numTaps = S->numTaps; /* Number of taps */ + uint32_t i, blkCnt, tapCnt, + outBlockSize = blockSize / S->M; /* Loop counters */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t c1; /* Temporary variables to hold state and coefficient values */ +#if defined(ARM_MATH_LOOPUNROLL) + q31_t c1; /* Temporary variables to hold state and coefficient values */ #endif /* S->pState buffer contains previous frame (numTaps - 1) samples */ - /* pStateCur points to the location where the new input data should be written */ + /* pStateCur points to the location where the new input data should be written + */ pStateCur = S->pState + (numTaps - 1U); /* Total number of output samples to be computed */ blkCnt = outBlockSize / 2; blkCntN3 = outBlockSize - (2 * blkCnt); - while (blkCnt > 0U) - { - /* Copy 2 * decimation factor number of new input samples into the state buffer */ + while (blkCnt > 0U) { + /* Copy 2 * decimation factor number of new input samples into the state + * buffer */ i = S->M * 2; - do - { + do { *pStateCur++ = *pSrc++; } while (--i); @@ -112,30 +114,29 @@ void arm_fir_decimate_q15( /* Initialize coeff pointer */ pb = pCoeffs; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the b[numTaps-1] and b[numTaps-2] coefficients */ - c0 = read_q15x2_ia ((q15_t **) &pb); + c0 = read_q15x2_ia((q15_t **)&pb); /* Read x[n-numTaps-1] and x[n-numTaps-2]sample */ - x0 = read_q15x2_ia (&px0); - x1 = read_q15x2_ia (&px1); + x0 = read_q15x2_ia(&px0); + x1 = read_q15x2_ia(&px1); /* Perform the multiply-accumulate */ acc0 = __SMLALD(x0, c0, acc0); acc1 = __SMLALD(x1, c0, acc1); /* Read the b[numTaps-3] and b[numTaps-4] coefficient */ - c0 = read_q15x2_ia ((q15_t **) &pb); + c0 = read_q15x2_ia((q15_t **)&pb); /* Read x[n-numTaps-2] and x[n-numTaps-3] sample */ - x0 = read_q15x2_ia (&px0); - x1 = read_q15x2_ia (&px1); + x0 = read_q15x2_ia(&px0); + x1 = read_q15x2_ia(&px1); /* Perform the multiply-accumulate */ acc0 = __SMLALD(x0, c0, acc0); @@ -155,8 +156,7 @@ void arm_fir_decimate_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read coefficients */ c0 = *pb++; @@ -178,20 +178,19 @@ void arm_fir_decimate_q15( /* Store filter output, smlad returns the values in 2.14 format */ /* so downsacle by 15 to get output in 1.15 */ - *pDst++ = (q15_t) (__SSAT((acc0 >> 15), 16)); - *pDst++ = (q15_t) (__SSAT((acc1 >> 15), 16)); + *pDst++ = (q15_t)(__SSAT((acc0 >> 15), 16)); + *pDst++ = (q15_t)(__SSAT((acc1 >> 15), 16)); /* Decrement loop counter */ blkCnt--; } - while (blkCntN3 > 0U) - { - /* Copy decimation factor number of new input samples into the state buffer */ + while (blkCntN3 > 0U) { + /* Copy decimation factor number of new input samples into the state buffer + */ i = S->M; - do - { + do { *pStateCur++ = *pSrc++; } while (--i); @@ -205,27 +204,26 @@ void arm_fir_decimate_q15( /* Initialize coeff pointer */ pb = pCoeffs; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the b[numTaps-1] and b[numTaps-2] coefficients */ - c0 = read_q15x2_ia ((q15_t **) &pb); + c0 = read_q15x2_ia((q15_t **)&pb); /* Read x[n-numTaps-1] and x[n-numTaps-2] sample */ - x0 = read_q15x2_ia (&px); + x0 = read_q15x2_ia(&px); /* Read the b[numTaps-3] and b[numTaps-4] coefficients */ - c1 = read_q15x2_ia ((q15_t **) &pb); + c1 = read_q15x2_ia((q15_t **)&pb); /* Perform the multiply-accumulate */ sum0 = __SMLALD(x0, c0, sum0); /* Read x[n-numTaps-2] and x[n-numTaps-3] sample */ - x0 = read_q15x2_ia (&px); + x0 = read_q15x2_ia(&px); /* Perform the multiply-accumulate */ sum0 = __SMLALD(x0, c1, sum0); @@ -244,8 +242,7 @@ void arm_fir_decimate_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read coefficients */ c0 = *pb++; @@ -265,7 +262,7 @@ void arm_fir_decimate_q15( /* Store filter output, smlad returns the values in 2.14 format */ /* so downsacle by 15 to get output in 1.15 */ - *pDst++ = (q15_t) (__SSAT((sum0 >> 15), 16)); + *pDst++ = (q15_t)(__SSAT((sum0 >> 15), 16)); /* Decrement loop counter */ blkCntN3--; @@ -281,10 +278,9 @@ void arm_fir_decimate_q15( i = (numTaps - 1U) >> 2U; /* copy data */ - while (i > 0U) - { - write_q15x2_ia (&pStateCur, read_q15x2_ia (&pState)); - write_q15x2_ia (&pStateCur, read_q15x2_ia (&pState)); + while (i > 0U) { + write_q15x2_ia(&pStateCur, read_q15x2_ia(&pState)); + write_q15x2_ia(&pStateCur, read_q15x2_ia(&pState)); /* Decrement loop counter */ i--; @@ -293,53 +289,48 @@ void arm_fir_decimate_q15( i = (numTaps - 1U) % 0x04U; /* Copy data */ - while (i > 0U) - { + while (i > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ i--; } - } #else /* #if defined (ARM_MATH_DSP) */ -void arm_fir_decimate_q15( - const arm_fir_decimate_instance_q15 * S, - const q15_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - q15_t *pState = S->pState; /* State pointer */ - const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q15_t *pStateCur; /* Points to the current sample of the state */ - q15_t *px; /* Temporary pointer for state buffer */ - const q15_t *pb; /* Temporary pointer for coefficient buffer */ - q15_t x0, x1, c0; /* Temporary variables to hold state and coefficient values */ - q63_t sum0; /* Accumulators */ - q63_t acc0, acc1; - q15_t *px0, *px1; - uint32_t blkCntN3; - uint32_t numTaps = S->numTaps; /* Number of taps */ - uint32_t i, blkCnt, tapCnt, outBlockSize = blockSize / S->M; /* Loop counters */ - +void arm_fir_decimate_q15(const arm_fir_decimate_instance_q15 *S, + const q15_t *pSrc, q15_t *pDst, uint32_t blockSize) { + q15_t *pState = S->pState; /* State pointer */ + const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q15_t *pStateCur; /* Points to the current sample of the state */ + q15_t *px; /* Temporary pointer for state buffer */ + const q15_t *pb; /* Temporary pointer for coefficient buffer */ + q15_t x0, x1, + c0; /* Temporary variables to hold state and coefficient values */ + q63_t sum0; /* Accumulators */ + q63_t acc0, acc1; + q15_t *px0, *px1; + uint32_t blkCntN3; + uint32_t numTaps = S->numTaps; /* Number of taps */ + uint32_t i, blkCnt, tapCnt, + outBlockSize = blockSize / S->M; /* Loop counters */ /* S->pState buffer contains previous frame (numTaps - 1) samples */ - /* pStateCur points to the location where the new input data should be written */ + /* pStateCur points to the location where the new input data should be written + */ pStateCur = S->pState + (numTaps - 1U); /* Total number of output samples to be computed */ blkCnt = outBlockSize / 2; blkCntN3 = outBlockSize - (2 * blkCnt); - while (blkCnt > 0U) - { - /* Copy 2 * decimation factor number of new input samples into the state buffer */ + while (blkCnt > 0U) { + /* Copy 2 * decimation factor number of new input samples into the state + * buffer */ i = S->M * 2; - do - { + do { *pStateCur++ = *pSrc++; } while (--i); @@ -355,13 +346,12 @@ void arm_fir_decimate_q15( /* Initialize coeff pointer */ pb = pCoeffs; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the Read b[numTaps-1] coefficients */ c0 = *pb++; @@ -420,8 +410,7 @@ void arm_fir_decimate_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read coefficients */ c0 = *pb++; @@ -444,20 +433,19 @@ void arm_fir_decimate_q15( /* Store filter output, smlad returns the values in 2.14 format */ /* so downsacle by 15 to get output in 1.15 */ - *pDst++ = (q15_t) (__SSAT((acc0 >> 15), 16)); - *pDst++ = (q15_t) (__SSAT((acc1 >> 15), 16)); + *pDst++ = (q15_t)(__SSAT((acc0 >> 15), 16)); + *pDst++ = (q15_t)(__SSAT((acc1 >> 15), 16)); /* Decrement loop counter */ blkCnt--; } - while (blkCntN3 > 0U) - { - /* Copy decimation factor number of new input samples into the state buffer */ + while (blkCntN3 > 0U) { + /* Copy decimation factor number of new input samples into the state buffer + */ i = S->M; - do - { + do { *pStateCur++ = *pSrc++; } while (--i); @@ -471,13 +459,12 @@ void arm_fir_decimate_q15( /* Initialize coeff pointer */ pb = pCoeffs; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the b[numTaps-1] coefficient */ c0 = *pb++; @@ -528,8 +515,7 @@ void arm_fir_decimate_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read coefficients */ c0 = *pb++; @@ -549,7 +535,7 @@ void arm_fir_decimate_q15( /* Store filter output, smlad returns the values in 2.14 format */ /* so downsacle by 15 to get output in 1.15 */ - *pDst++ = (q15_t) (__SSAT((sum0 >> 15), 16)); + *pDst++ = (q15_t)(__SSAT((sum0 >> 15), 16)); /* Decrement loop counter */ blkCntN3--; @@ -565,8 +551,7 @@ void arm_fir_decimate_q15( i = (numTaps - 1U) >> 2U; /* copy data */ - while (i > 0U) - { + while (i > 0U) { *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; @@ -579,8 +564,7 @@ void arm_fir_decimate_q15( i = (numTaps - 1U) % 0x04U; /* copy data */ - while (i > 0U) - { + while (i > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_q31.c index 7af8a44..7720740 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_decimate_q31.c @@ -39,62 +39,65 @@ /** @brief Processing function for the Q31 FIR decimator. - @param[in] S points to an instance of the Q31 FIR decimator structure + @param[in] S points to an instance of the Q31 FIR decimator + structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior - The function is implemented using an internal 64-bit accumulator. - The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. - Thus, if the accumulator result overflows it wraps around rather than clip. - In order to avoid overflows completely the input signal must be scaled down by log2(numTaps) bits (where log2 is read as log to the base 2). - After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format. + The function is implemented using an internal 64-bit + accumulator. The accumulator has a 2.62 format and maintains full precision of + the intermediate multiplication results but provides only a single guard bit. + Thus, if the accumulator result overflows it wraps around + rather than clip. In order to avoid overflows completely the input signal must + be scaled down by log2(numTaps) bits (where log2 is read as log to the base 2). + After all multiply-accumulates are performed, the 2.62 + accumulator is truncated to 1.32 format and then saturated to 1.31 format. @remark - Refer to \ref arm_fir_decimate_fast_q31() for a faster but less precise implementation of this function. + Refer to \ref arm_fir_decimate_fast_q31() for a faster but + less precise implementation of this function. */ -void arm_fir_decimate_q31( - const arm_fir_decimate_instance_q31 * S, - const q31_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - q31_t *pState = S->pState; /* State pointer */ - const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q31_t *pStateCur; /* Points to the current sample of the state */ - q31_t *px0; /* Temporary pointer for state buffer */ - const q31_t *pb; /* Temporary pointer for coefficient buffer */ - q31_t x0, c0; /* Temporary variables to hold state and coefficient values */ - q63_t acc0; /* Accumulator */ - uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ - uint32_t i, tapCnt, blkCnt, outBlockSize = blockSize / S->M; /* Loop counters */ +void arm_fir_decimate_q31(const arm_fir_decimate_instance_q31 *S, + const q31_t *pSrc, q31_t *pDst, uint32_t blockSize) { + q31_t *pState = S->pState; /* State pointer */ + const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q31_t *pStateCur; /* Points to the current sample of the state */ + q31_t *px0; /* Temporary pointer for state buffer */ + const q31_t *pb; /* Temporary pointer for coefficient buffer */ + q31_t x0, c0; /* Temporary variables to hold state and coefficient values */ + q63_t acc0; /* Accumulator */ + uint32_t numTaps = + S->numTaps; /* Number of filter coefficients in the filter */ + uint32_t i, tapCnt, blkCnt, + outBlockSize = blockSize / S->M; /* Loop counters */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t *px1, *px2, *px3; - q31_t x1, x2, x3; - q63_t acc1, acc2, acc3; +#if defined(ARM_MATH_LOOPUNROLL) + q31_t *px1, *px2, *px3; + q31_t x1, x2, x3; + q63_t acc1, acc2, acc3; #endif /* S->pState buffer contains previous frame (numTaps - 1) samples */ - /* pStateCur points to the location where the new input data should be written */ + /* pStateCur points to the location where the new input data should be written + */ pStateCur = S->pState + (numTaps - 1U); -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) - /* Loop unrolling: Compute 4 samples at a time */ + /* Loop unrolling: Compute 4 samples at a time */ blkCnt = outBlockSize >> 2U; /* Samples loop unrolled by 4 */ - while (blkCnt > 0U) - { - /* Copy 4 * decimation factor number of new input samples into the state buffer */ + while (blkCnt > 0U) { + /* Copy 4 * decimation factor number of new input samples into the state + * buffer */ i = S->M * 4; - do - { + do { *pStateCur++ = *pSrc++; } while (--i); @@ -117,8 +120,7 @@ void arm_fir_decimate_q31( /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the b[numTaps-1] coefficient */ c0 = *(pb++); @@ -132,10 +134,10 @@ void arm_fir_decimate_q31( x3 = *(px3++); /* Perform the multiply-accumulate */ - acc0 += (q63_t) x0 * c0; - acc1 += (q63_t) x1 * c0; - acc2 += (q63_t) x2 * c0; - acc3 += (q63_t) x3 * c0; + acc0 += (q63_t)x0 * c0; + acc1 += (q63_t)x1 * c0; + acc2 += (q63_t)x2 * c0; + acc3 += (q63_t)x3 * c0; /* Read the b[numTaps-2] coefficient */ c0 = *(pb++); @@ -147,10 +149,10 @@ void arm_fir_decimate_q31( x3 = *(px3++); /* Perform the multiply-accumulate */ - acc0 += (q63_t) x0 * c0; - acc1 += (q63_t) x1 * c0; - acc2 += (q63_t) x2 * c0; - acc3 += (q63_t) x3 * c0; + acc0 += (q63_t)x0 * c0; + acc1 += (q63_t)x1 * c0; + acc2 += (q63_t)x2 * c0; + acc3 += (q63_t)x3 * c0; /* Read the b[numTaps-3] coefficient */ c0 = *(pb++); @@ -162,10 +164,10 @@ void arm_fir_decimate_q31( x3 = *(px3++); /* Perform the multiply-accumulate */ - acc0 += (q63_t) x0 * c0; - acc1 += (q63_t) x1 * c0; - acc2 += (q63_t) x2 * c0; - acc3 += (q63_t) x3 * c0; + acc0 += (q63_t)x0 * c0; + acc1 += (q63_t)x1 * c0; + acc2 += (q63_t)x2 * c0; + acc3 += (q63_t)x3 * c0; /* Read the b[numTaps-4] coefficient */ c0 = *(pb++); @@ -177,10 +179,10 @@ void arm_fir_decimate_q31( x3 = *(px3++); /* Perform the multiply-accumulate */ - acc0 += (q63_t) x0 * c0; - acc1 += (q63_t) x1 * c0; - acc2 += (q63_t) x2 * c0; - acc3 += (q63_t) x3 * c0; + acc0 += (q63_t)x0 * c0; + acc1 += (q63_t)x1 * c0; + acc2 += (q63_t)x2 * c0; + acc3 += (q63_t)x3 * c0; /* Decrement loop counter */ tapCnt--; @@ -189,8 +191,7 @@ void arm_fir_decimate_q31( /* Loop unrolling: Compute remaining taps */ tapCnt = numTaps % 0x4U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read coefficients */ c0 = *(pb++); @@ -201,10 +202,10 @@ void arm_fir_decimate_q31( x3 = *(px3++); /* Perform the multiply-accumulate */ - acc0 += (q63_t) x0 * c0; - acc1 += (q63_t) x1 * c0; - acc2 += (q63_t) x2 * c0; - acc3 += (q63_t) x3 * c0; + acc0 += (q63_t)x0 * c0; + acc1 += (q63_t)x1 * c0; + acc2 += (q63_t)x2 * c0; + acc3 += (q63_t)x3 * c0; /* Decrement loop counter */ tapCnt--; @@ -215,10 +216,10 @@ void arm_fir_decimate_q31( pState = pState + S->M * 4; /* The result is in the accumulator, store in the destination buffer. */ - *pDst++ = (q31_t) (acc0 >> 31); - *pDst++ = (q31_t) (acc1 >> 31); - *pDst++ = (q31_t) (acc2 >> 31); - *pDst++ = (q31_t) (acc3 >> 31); + *pDst++ = (q31_t)(acc0 >> 31); + *pDst++ = (q31_t)(acc1 >> 31); + *pDst++ = (q31_t)(acc2 >> 31); + *pDst++ = (q31_t)(acc3 >> 31); /* Decrement loop counter */ blkCnt--; @@ -234,13 +235,12 @@ void arm_fir_decimate_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { - /* Copy decimation factor number of new input samples into the state buffer */ + while (blkCnt > 0U) { + /* Copy decimation factor number of new input samples into the state buffer + */ i = S->M; - do - { + do { *pStateCur++ = *pSrc++; } while (--i); @@ -254,13 +254,12 @@ void arm_fir_decimate_q31( /* Initialize coeff pointer */ pb = pCoeffs; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the b[numTaps-1] coefficient */ c0 = *pb++; @@ -268,7 +267,7 @@ void arm_fir_decimate_q31( x0 = *px0++; /* Perform the multiply-accumulate */ - acc0 += (q63_t) x0 * c0; + acc0 += (q63_t)x0 * c0; /* Read the b[numTaps-2] coefficient */ c0 = *pb++; @@ -277,7 +276,7 @@ void arm_fir_decimate_q31( x0 = *px0++; /* Perform the multiply-accumulate */ - acc0 += (q63_t) x0 * c0; + acc0 += (q63_t)x0 * c0; /* Read the b[numTaps-3] coefficient */ c0 = *pb++; @@ -286,7 +285,7 @@ void arm_fir_decimate_q31( x0 = *px0++; /* Perform the multiply-accumulate */ - acc0 += (q63_t) x0 * c0; + acc0 += (q63_t)x0 * c0; /* Read the b[numTaps-4] coefficient */ c0 = *pb++; @@ -295,7 +294,7 @@ void arm_fir_decimate_q31( x0 = *px0++; /* Perform the multiply-accumulate */ - acc0 += (q63_t) x0 * c0; + acc0 += (q63_t)x0 * c0; /* Decrement loop counter */ tapCnt--; @@ -311,8 +310,7 @@ void arm_fir_decimate_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read coefficients */ c0 = *pb++; @@ -320,7 +318,7 @@ void arm_fir_decimate_q31( x0 = *px0++; /* Perform the multiply-accumulate */ - acc0 += (q63_t) x0 * c0; + acc0 += (q63_t)x0 * c0; /* Decrement loop counter */ tapCnt--; @@ -331,7 +329,7 @@ void arm_fir_decimate_q31( pState = pState + S->M; /* The result is in the accumulator, store in the destination buffer. */ - *pDst++ = (q31_t) (acc0 >> 31); + *pDst++ = (q31_t)(acc0 >> 31); /* Decrement loop counter */ blkCnt--; @@ -344,14 +342,13 @@ void arm_fir_decimate_q31( /* Points to the start of the state buffer */ pStateCur = S->pState; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = (numTaps - 1U) >> 2U; /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; @@ -372,14 +369,12 @@ void arm_fir_decimate_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_f32.c index b368b04..33876e2 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_f32.c @@ -36,71 +36,81 @@ @defgroup FIR Finite Impulse Response (FIR) Filters This set of functions implements Finite Impulse Response (FIR) filters - for Q7, Q15, Q31, and floating-point data types. Fast versions of Q15 and Q31 are also provided. - The functions operate on blocks of input and output data and each call to the function processes - blockSize samples through the filter. pSrc and - pDst points to input and output arrays containing blockSize values. + for Q7, Q15, Q31, and floating-point data types. Fast versions of Q15 and Q31 + are also provided. The functions operate on blocks of input and output data + and each call to the function processes blockSize samples through + the filter. pSrc and pDst points to input and + output arrays containing blockSize values. @par Algorithm - The FIR filter algorithm is based upon a sequence of multiply-accumulate (MAC) operations. - Each filter coefficient b[n] is multiplied by a state variable which equals a previous input sample x[n]. -
-      y[n] = b[0] * x[n] + b[1] * x[n-1] + b[2] * x[n-2] + ...+ b[numTaps-1] * x[n-numTaps+1]
+                   The FIR filter algorithm is based upon a sequence of
+  multiply-accumulate (MAC) operations. Each filter coefficient
+  b[n] is multiplied by a state variable which equals a previous
+  input sample x[n]. 
 y[n] = b[0] * x[n] + b[1] * x[n-1] +
+  b[2] * x[n-2] + ...+ b[numTaps-1] * x[n-numTaps+1]
   
@par \image html FIR.GIF "Finite Impulse Response filter" @par - pCoeffs points to a coefficient array of size numTaps. - Coefficients are stored in time reversed order. + pCoeffs points to a coefficient array of size + numTaps. Coefficients are stored in time reversed order. @par
       {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
   
@par - pState points to a state array of size numTaps + blockSize - 1. - Samples in the state buffer are stored in the following order. + pState points to a state array of size + numTaps + blockSize - 1. Samples in the state buffer are stored + in the following order. @par
-      {x[n-numTaps+1], x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2]....x[0], x[1], ..., x[blockSize-1]}
+      {x[n-numTaps+1], x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2]....x[0],
+  x[1], ..., x[blockSize-1]}
   
@par - Note that the length of the state buffer exceeds the length of the coefficient array by blockSize-1. - The increased state buffer length allows circular addressing, which is traditionally used in the FIR filters, - to be avoided and yields a significant speed improvement. - The state variables are updated after each block of data is processed; the coefficients are untouched. + Note that the length of the state buffer exceeds the length + of the coefficient array by blockSize-1. The increased state + buffer length allows circular addressing, which is traditionally used in the + FIR filters, to be avoided and yields a significant speed improvement. The + state variables are updated after each block of data is processed; the + coefficients are untouched. @par Instance Structure - The coefficients and state variables for a filter are stored together in an instance data structure. - A separate instance structure must be defined for each filter. - Coefficient arrays may be shared among several instances while state variable arrays cannot be shared. - There are separate instance structure declarations for each of the 4 supported data types. + The coefficients and state variables for a filter are stored + together in an instance data structure. A separate instance structure must be + defined for each filter. Coefficient arrays may be shared among several + instances while state variable arrays cannot be shared. There are separate + instance structure declarations for each of the 4 supported data types. @par Initialization Functions - There is also an associated initialization function for each data type. - The initialization function performs the following operations: + There is also an associated initialization function for each + data type. The initialization function performs the following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. - To do this manually without calling the init function, assign the follow subfields of the instance structure: - numTaps, pCoeffs, pState. Also set all of the values in pState to zero. + To do this manually without calling the init function, assign + the follow subfields of the instance structure: numTaps, pCoeffs, pState. Also + set all of the values in pState to zero. @par Use of the initialization function is optional. - However, if the initialization function is used, then the instance structure cannot be placed into a const data section. - To place an instance structure into a const data section, the instance structure must be manually initialized. - Set the values in the state buffer to zeros before static initialization. - The code below statically initializes each of the 4 different data type filter instance structures -
-      arm_fir_instance_f32 S = {numTaps, pState, pCoeffs};
-      arm_fir_instance_q31 S = {numTaps, pState, pCoeffs};
-      arm_fir_instance_q15 S = {numTaps, pState, pCoeffs};
+                   However, if the initialization function is used, then the
+  instance structure cannot be placed into a const data section. To place an
+  instance structure into a const data section, the instance structure must be
+  manually initialized. Set the values in the state buffer to zeros before
+  static initialization. The code below statically initializes each of the 4
+  different data type filter instance structures 
 arm_fir_instance_f32 S =
+  {numTaps, pState, pCoeffs}; arm_fir_instance_q31 S = {numTaps, pState,
+  pCoeffs}; arm_fir_instance_q15 S = {numTaps, pState, pCoeffs};
       arm_fir_instance_q7 S =  {numTaps, pState, pCoeffs};
   
- where numTaps is the number of filter coefficients in the filter; pState is the address of the state buffer; - pCoeffs is the address of the coefficient buffer. + where numTaps is the number of filter + coefficients in the filter; pState is the address of the state + buffer; pCoeffs is the address of the coefficient buffer. @par Fixed-Point Behavior - Care must be taken when using the fixed-point versions of the FIR filter functions. - In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. - Refer to the function specific documentation below for usage guidelines. + Care must be taken when using the fixed-point versions of the + FIR filter functions. In particular, the overflow and saturation behavior of + the accumulator used in each function must be considered. Refer to the + function specific documentation below for usage guidelines. */ /** @@ -110,53 +120,56 @@ /** @brief Processing function for floating-point FIR filter. - @param[in] S points to an instance of the floating-point FIR filter structure + @param[in] S points to an instance of the floating-point FIR + filter structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none */ -void arm_fir_f32( - const arm_fir_instance_f32 * S, - const float32_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - float32_t *pState = S->pState; /* State pointer */ - const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - float32_t *pStateCurnt; /* Points to the current sample of the state */ - float32_t *px; /* Temporary pointer for state buffer */ - const float32_t *pb; /* Temporary pointer for coefficient buffer */ - float32_t acc0; /* Accumulator */ - uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ - uint32_t i, tapCnt, blkCnt; /* Loop counters */ +void arm_fir_f32(const arm_fir_instance_f32 *S, const float32_t *pSrc, + float32_t *pDst, uint32_t blockSize) { + float32_t *pState = S->pState; /* State pointer */ + const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + float32_t *pStateCurnt; /* Points to the current sample of the state */ + float32_t *px; /* Temporary pointer for state buffer */ + const float32_t *pb; /* Temporary pointer for coefficient buffer */ + float32_t acc0; /* Accumulator */ + uint32_t numTaps = + S->numTaps; /* Number of filter coefficients in the filter */ + uint32_t i, tapCnt, blkCnt; /* Loop counters */ -#if defined (ARM_MATH_LOOPUNROLL) - float32_t acc1, acc2, acc3, acc4, acc5, acc6, acc7; /* Accumulators */ - float32_t x0, x1, x2, x3, x4, x5, x6, x7; /* Temporary variables to hold state values */ - float32_t c0; /* Temporary variable to hold coefficient value */ +#if defined(ARM_MATH_LOOPUNROLL) + float32_t acc1, acc2, acc3, acc4, acc5, acc6, acc7; /* Accumulators */ + float32_t x0, x1, x2, x3, x4, x5, x6, + x7; /* Temporary variables to hold state values */ + float32_t c0; /* Temporary variable to hold coefficient value */ #endif - /* S->pState points to state array which contains previous frame (numTaps - 1) samples */ - /* pStateCurnt points to the location where the new input data should be written */ + /* S->pState points to state array which contains previous frame (numTaps - 1) + * samples */ + /* pStateCurnt points to the location where the new input data should be + * written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 8 output values simultaneously. * The variables acc0 ... acc7 hold output values that are being computed: * - * acc0 = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] - * acc1 = b[numTaps-1] * x[n-numTaps] + b[numTaps-2] * x[n-numTaps-1] + b[numTaps-3] * x[n-numTaps-2] +...+ b[0] * x[1] - * acc2 = b[numTaps-1] * x[n-numTaps+1] + b[numTaps-2] * x[n-numTaps] + b[numTaps-3] * x[n-numTaps-1] +...+ b[0] * x[2] - * acc3 = b[numTaps-1] * x[n-numTaps+2] + b[numTaps-2] * x[n-numTaps+1] + b[numTaps-3] * x[n-numTaps] +...+ b[0] * x[3] + * acc0 = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + + * b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] acc1 = b[numTaps-1] * + * x[n-numTaps] + b[numTaps-2] * x[n-numTaps-1] + b[numTaps-3] * + * x[n-numTaps-2] +...+ b[0] * x[1] acc2 = b[numTaps-1] * x[n-numTaps+1] + + * b[numTaps-2] * x[n-numTaps] + b[numTaps-3] * x[n-numTaps-1] +...+ b[0] * + * x[2] acc3 = b[numTaps-1] * x[n-numTaps+2] + b[numTaps-2] * x[n-numTaps+1] + * + b[numTaps-3] * x[n-numTaps] +...+ b[0] * x[3] */ blkCnt = blockSize >> 3U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy 4 new input samples into the state buffer. */ *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; @@ -187,7 +200,8 @@ void arm_fir_f32( *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; - /* Read the first 7 samples from the state buffer: x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2] */ + /* Read the first 7 samples from the state buffer: x[n-numTaps], + * x[n-numTaps-1], x[n-numTaps-2] */ x0 = *px++; x1 = *px++; x2 = *px++; @@ -199,8 +213,7 @@ void arm_fir_f32( /* Loop unrolling: process 8 taps at a time. */ tapCnt = numTaps >> 3U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the b[numTaps-1] coefficient */ c0 = *(pb++); @@ -349,8 +362,7 @@ void arm_fir_f32( /* Loop unrolling: Compute remaining outputs */ tapCnt = numTaps % 0x8U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read coefficients */ c0 = *(pb++); @@ -393,7 +405,6 @@ void arm_fir_f32( *pDst++ = acc6; *pDst++ = acc7; - /* Decrement loop counter */ blkCnt--; } @@ -408,8 +419,7 @@ void arm_fir_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy one sample at a time into state buffer */ *pStateCurnt++ = *pSrc++; @@ -425,9 +435,9 @@ void arm_fir_f32( i = numTaps; /* Perform the multiply-accumulates */ - do - { - /* acc = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] */ + do { + /* acc = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + + * b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] */ acc0 += *px++ * *pb++; i--; @@ -450,14 +460,13 @@ void arm_fir_f32( /* Points to the start of the state buffer */ pStateCurnt = S->pState; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = (numTaps - 1U) >> 2U; /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; @@ -478,14 +487,12 @@ void arm_fir_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy remaining data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_fast_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_fast_q15.c index 5f8df95..1edbfa8 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_fast_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_fast_q15.c @@ -39,7 +39,8 @@ /** @brief Processing function for the Q15 FIR filter (fast version). - @param[in] S points to an instance of the Q15 FIR filter structure + @param[in] S points to an instance of the Q15 FIR filter + structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @@ -47,54 +48,60 @@ @par Scaling and Overflow Behavior This fast version uses a 32-bit accumulator with 2.30 format. - The accumulator maintains full precision of the intermediate multiplication results but provides only a single guard bit. - Thus, if the accumulator result overflows it wraps around and distorts the result. - In order to avoid overflows completely the input signal must be scaled down by log2(numTaps) bits. - The 2.30 accumulator is then truncated to 2.15 format and saturated to yield the 1.15 result. + The accumulator maintains full precision of the intermediate + multiplication results but provides only a single guard bit. Thus, if the + accumulator result overflows it wraps around and distorts the result. In order + to avoid overflows completely the input signal must be scaled down by + log2(numTaps) bits. The 2.30 accumulator is then truncated to 2.15 format and + saturated to yield the 1.15 result. @remark - Refer to \ref arm_fir_q15() for a slower implementation of this function which uses 64-bit accumulation to avoid wrap around distortion. Both the slow and the fast versions use the same instance structure. - Use function \ref arm_fir_init_q15() to initialize the filter structure. + Refer to \ref arm_fir_q15() for a slower implementation of + this function which uses 64-bit accumulation to avoid wrap around distortion. + Both the slow and the fast versions use the same instance structure. Use + function \ref arm_fir_init_q15() to initialize the filter structure. */ -void arm_fir_fast_q15( - const arm_fir_instance_q15 * S, - const q15_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - q15_t *pState = S->pState; /* State pointer */ - const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q15_t *pStateCurnt; /* Points to the current sample of the state */ - q15_t *px; /* Temporary pointer for state buffer */ - const q15_t *pb; /* Temporary pointer for coefficient buffer */ - q31_t acc0; /* Accumulators */ - uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ - uint32_t tapCnt, blkCnt; /* Loop counters */ +void arm_fir_fast_q15(const arm_fir_instance_q15 *S, const q15_t *pSrc, + q15_t *pDst, uint32_t blockSize) { + q15_t *pState = S->pState; /* State pointer */ + const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q15_t *pStateCurnt; /* Points to the current sample of the state */ + q15_t *px; /* Temporary pointer for state buffer */ + const q15_t *pb; /* Temporary pointer for coefficient buffer */ + q31_t acc0; /* Accumulators */ + uint32_t numTaps = + S->numTaps; /* Number of filter coefficients in the filter */ + uint32_t tapCnt, blkCnt; /* Loop counters */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t acc1, acc2, acc3; /* Accumulators */ - q31_t x0, x1, x2, c0; /* Temporary variables to hold state and coefficient values */ +#if defined(ARM_MATH_LOOPUNROLL) + q31_t acc1, acc2, acc3; /* Accumulators */ + q31_t x0, x1, x2, + c0; /* Temporary variables to hold state and coefficient values */ #endif - /* S->pState points to state array which contains previous frame (numTaps - 1) samples */ - /* pStateCurnt points to the location where the new input data should be written */ + /* S->pState points to state array which contains previous frame (numTaps - 1) + * samples */ + /* pStateCurnt points to the location where the new input data should be + * written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 output values simultaneously. * The variables acc0 ... acc3 hold output values that are being computed: * - * acc0 = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] - * acc1 = b[numTaps-1] * x[n-numTaps] + b[numTaps-2] * x[n-numTaps-1] + b[numTaps-3] * x[n-numTaps-2] +...+ b[0] * x[1] - * acc2 = b[numTaps-1] * x[n-numTaps+1] + b[numTaps-2] * x[n-numTaps] + b[numTaps-3] * x[n-numTaps-1] +...+ b[0] * x[2] - * acc3 = b[numTaps-1] * x[n-numTaps+2] + b[numTaps-2] * x[n-numTaps+1] + b[numTaps-3] * x[n-numTaps] +...+ b[0] * x[3] + * acc0 = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + + * b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] acc1 = b[numTaps-1] * + * x[n-numTaps] + b[numTaps-2] * x[n-numTaps-1] + b[numTaps-3] * + * x[n-numTaps-2] +...+ b[0] * x[1] acc2 = b[numTaps-1] * x[n-numTaps+1] + + * b[numTaps-2] * x[n-numTaps] + b[numTaps-3] * x[n-numTaps-1] +...+ b[0] * + * x[2] acc3 = b[numTaps-1] * x[n-numTaps+2] + b[numTaps-2] * x[n-numTaps+1] + * + b[numTaps-3] * x[n-numTaps] +...+ b[0] * x[3] */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy 4 new input samples into the state buffer. */ *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; @@ -110,23 +117,25 @@ void arm_fir_fast_q15( /* Typecast q15_t pointer to q31_t pointer for state reading in q31_t */ px = pState; - /* Typecast q15_t pointer to q31_t pointer for coefficient reading in q31_t */ + /* Typecast q15_t pointer to q31_t pointer for coefficient reading in q31_t + */ pb = pCoeffs; /* Read the first two samples from the state buffer: x[n-N], x[n-N-1] */ - x0 = read_q15x2_ia (&px); + x0 = read_q15x2_ia(&px); - /* Read the third and forth samples from the state buffer: x[n-N-2], x[n-N-3] */ - x2 = read_q15x2_ia (&px); + /* Read the third and forth samples from the state buffer: x[n-N-2], + * x[n-N-3] */ + x2 = read_q15x2_ia(&px); /* Loop over the number of taps. Unroll by a factor of 4. Repeat until we've computed numTaps-(numTaps%4) coefficients. */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { - /* Read the first two coefficients using SIMD: b[N] and b[N-1] coefficients */ - c0 = read_q15x2_ia ((q15_t **) &pb); + while (tapCnt > 0U) { + /* Read the first two coefficients using SIMD: b[N] and b[N-1] + * coefficients */ + c0 = read_q15x2_ia((q15_t **)&pb); /* acc0 += b[N] * x[n-N] + b[N-1] * x[n-N-1] */ acc0 = __SMLAD(x0, c0, acc0); @@ -142,7 +151,7 @@ void arm_fir_fast_q15( #endif /* Read state x[n-N-4], x[n-N-5] */ - x0 = read_q15x2_ia (&px); + x0 = read_q15x2_ia(&px); /* acc1 += b[N] * x[n-N-1] + b[N-1] * x[n-N-2] */ acc1 = __SMLADX(x1, c0, acc1); @@ -158,13 +167,13 @@ void arm_fir_fast_q15( acc3 = __SMLADX(x1, c0, acc3); /* Read coefficients b[N-2], b[N-3] */ - c0 = read_q15x2_ia ((q15_t **) &pb); + c0 = read_q15x2_ia((q15_t **)&pb); /* acc0 += b[N-2] * x[n-N-2] + b[N-3] * x[n-N-3] */ acc0 = __SMLAD(x2, c0, acc0); /* Read state x[n-N-6], x[n-N-7] with offset */ - x2 = read_q15x2_ia (&px); + x2 = read_q15x2_ia(&px); /* acc2 += b[N-2] * x[n-N-4] + b[N-3] * x[n-N-5] */ acc2 = __SMLAD(x0, c0, acc2); @@ -186,12 +195,11 @@ void arm_fir_fast_q15( tapCnt--; } - /* If the filter length is not a multiple of 4, compute the remaining filter taps. - This is always be 2 taps since the filter length is even. */ - if ((numTaps & 0x3U) != 0U) - { + /* If the filter length is not a multiple of 4, compute the remaining filter + taps. This is always be 2 taps since the filter length is even. */ + if ((numTaps & 0x3U) != 0U) { /* Read last two coefficients */ - c0 = read_q15x2_ia ((q15_t **) &pb); + c0 = read_q15x2_ia((q15_t **)&pb); /* Perform the multiply-accumulates */ acc0 = __SMLAD(x0, c0, acc0); @@ -205,7 +213,7 @@ void arm_fir_fast_q15( #endif /* Read last state variables */ - x0 = read_q15x2 (px); + x0 = read_q15x2(px); /* Perform the multiply-accumulates */ acc1 = __SMLADX(x1, c0, acc1); @@ -221,14 +229,18 @@ void arm_fir_fast_q15( acc3 = __SMLADX(x1, c0, acc3); } - /* The results in the 4 accumulators are in 2.30 format. Convert to 1.15 with saturation. - Then store the 4 outputs in the destination buffer. */ + /* The results in the 4 accumulators are in 2.30 format. Convert to 1.15 + with saturation. Then store the 4 outputs in the destination buffer. */ #ifndef ARM_MATH_BIG_ENDIAN - write_q15x2_ia (&pDst, __PKHBT(__SSAT((acc0 >> 15), 16), __SSAT((acc1 >> 15), 16), 16)); - write_q15x2_ia (&pDst, __PKHBT(__SSAT((acc2 >> 15), 16), __SSAT((acc3 >> 15), 16), 16)); + write_q15x2_ia( + &pDst, __PKHBT(__SSAT((acc0 >> 15), 16), __SSAT((acc1 >> 15), 16), 16)); + write_q15x2_ia( + &pDst, __PKHBT(__SSAT((acc2 >> 15), 16), __SSAT((acc3 >> 15), 16), 16)); #else - write_q15x2_ia (&pDst, __PKHBT(__SSAT((acc1 >> 15), 16), __SSAT((acc0 >> 15), 16), 16)); - write_q15x2_ia (&pDst, __PKHBT(__SSAT((acc3 >> 15), 16), __SSAT((acc2 >> 15), 16), 16)); + write_q15x2_ia( + &pDst, __PKHBT(__SSAT((acc1 >> 15), 16), __SSAT((acc0 >> 15), 16), 16)); + write_q15x2_ia( + &pDst, __PKHBT(__SSAT((acc3 >> 15), 16), __SSAT((acc2 >> 15), 16), 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Advance the state pointer by 4 to process the next group of 4 samples */ @@ -248,8 +260,7 @@ void arm_fir_fast_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy two samples into state buffer */ *pStateCurnt++ = *pSrc++; @@ -262,18 +273,16 @@ void arm_fir_fast_q15( tapCnt = numTaps >> 1U; - do - { - acc0 += (q31_t) *px++ * *pb++; - acc0 += (q31_t) *px++ * *pb++; + do { + acc0 += (q31_t)*px++ * *pb++; + acc0 += (q31_t)*px++ * *pb++; tapCnt--; - } - while (tapCnt > 0U); + } while (tapCnt > 0U); /* The result is in 2.30 format. Convert to 1.15 with saturation. Then store the output in the destination buffer. */ - *pDst++ = (q15_t) (__SSAT((acc0 >> 15), 16)); + *pDst++ = (q15_t)(__SSAT((acc0 >> 15), 16)); /* Advance state pointer by 1 for the next sample */ pState = pState + 1U; @@ -289,14 +298,13 @@ void arm_fir_fast_q15( /* Points to the start of the state buffer */ pStateCurnt = S->pState; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = (numTaps - 1U) >> 2U; /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; @@ -317,14 +325,12 @@ void arm_fir_fast_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy remaining data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_fast_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_fast_q31.c index 513cb72..90c4193 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_fast_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_fast_q31.c @@ -46,57 +46,63 @@ @return none @par Scaling and Overflow Behavior - This function is optimized for speed at the expense of fixed-point precision and overflow protection. - The result of each 1.31 x 1.31 multiplication is truncated to 2.30 format. - These intermediate results are added to a 2.30 accumulator. - Finally, the accumulator is saturated and converted to a 1.31 result. - The fast version has the same overflow behavior as the standard version and provides less precision since it discards the low 32 bits of each multiplication result. - In order to avoid overflows completely the input signal must be scaled down by log2(numTaps) bits. + This function is optimized for speed at the expense of + fixed-point precision and overflow protection. The result of each 1.31 x 1.31 + multiplication is truncated to 2.30 format. These intermediate results are + added to a 2.30 accumulator. Finally, the accumulator is saturated and + converted to a 1.31 result. The fast version has the same overflow behavior as + the standard version and provides less precision since it discards the low 32 + bits of each multiplication result. In order to avoid overflows completely the + input signal must be scaled down by log2(numTaps) bits. @remark - Refer to \ref arm_fir_q31() for a slower implementation of this function which uses a 64-bit accumulator to provide higher precision. Both the slow and the fast versions use the same instance structure. - Use function \ref arm_fir_init_q31() to initialize the filter structure. + Refer to \ref arm_fir_q31() for a slower implementation of + this function which uses a 64-bit accumulator to provide higher precision. Both + the slow and the fast versions use the same instance structure. Use function + \ref arm_fir_init_q31() to initialize the filter structure. */ IAR_ONLY_LOW_OPTIMIZATION_ENTER -void arm_fir_fast_q31( - const arm_fir_instance_q31 * S, - const q31_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - q31_t *pState = S->pState; /* State pointer */ - const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q31_t *pStateCurnt; /* Points to the current sample of the state */ - q31_t *px; /* Temporary pointer for state buffer */ - const q31_t *pb; /* Temporary pointer for coefficient buffer */ - q31_t acc0; /* Accumulators */ - uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ - uint32_t i, tapCnt, blkCnt; /* Loop counters */ +void arm_fir_fast_q31(const arm_fir_instance_q31 *S, const q31_t *pSrc, + q31_t *pDst, uint32_t blockSize) { + q31_t *pState = S->pState; /* State pointer */ + const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q31_t *pStateCurnt; /* Points to the current sample of the state */ + q31_t *px; /* Temporary pointer for state buffer */ + const q31_t *pb; /* Temporary pointer for coefficient buffer */ + q31_t acc0; /* Accumulators */ + uint32_t numTaps = + S->numTaps; /* Number of filter coefficients in the filter */ + uint32_t i, tapCnt, blkCnt; /* Loop counters */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t acc1, acc2, acc3; /* Accumulators */ - q31_t x0, x1, x2, x3, c0; /* Temporary variables to hold state and coefficient values */ +#if defined(ARM_MATH_LOOPUNROLL) + q31_t acc1, acc2, acc3; /* Accumulators */ + q31_t x0, x1, x2, x3, + c0; /* Temporary variables to hold state and coefficient values */ #endif - /* S->pState points to state array which contains previous frame (numTaps - 1) samples */ - /* pStateCurnt points to the location where the new input data should be written */ + /* S->pState points to state array which contains previous frame (numTaps - 1) + * samples */ + /* pStateCurnt points to the location where the new input data should be + * written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 output values simultaneously. * The variables acc0 ... acc3 hold output values that are being computed: * - * acc0 = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] - * acc1 = b[numTaps-1] * x[n-numTaps] + b[numTaps-2] * x[n-numTaps-1] + b[numTaps-3] * x[n-numTaps-2] +...+ b[0] * x[1] - * acc2 = b[numTaps-1] * x[n-numTaps+1] + b[numTaps-2] * x[n-numTaps] + b[numTaps-3] * x[n-numTaps-1] +...+ b[0] * x[2] - * acc3 = b[numTaps-1] * x[n-numTaps+2] + b[numTaps-2] * x[n-numTaps+1] + b[numTaps-3] * x[n-numTaps] +...+ b[0] * x[3] + * acc0 = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + + * b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] acc1 = b[numTaps-1] * + * x[n-numTaps] + b[numTaps-2] * x[n-numTaps-1] + b[numTaps-3] * + * x[n-numTaps-2] +...+ b[0] * x[1] acc2 = b[numTaps-1] * x[n-numTaps+1] + + * b[numTaps-2] * x[n-numTaps] + b[numTaps-3] * x[n-numTaps-1] +...+ b[0] * + * x[2] acc3 = b[numTaps-1] * x[n-numTaps+2] + b[numTaps-2] * x[n-numTaps+1] + * + b[numTaps-3] * x[n-numTaps] +...+ b[0] * x[3] */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy 4 new input samples into the state buffer. */ *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; @@ -126,8 +132,7 @@ void arm_fir_fast_q31( /* Loop over the number of taps. Unroll by a factor of 4. Repeat until we've computed numTaps-4 coefficients. */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the b[numTaps] coefficient */ c0 = *pb; @@ -190,11 +195,11 @@ void arm_fir_fast_q31( tapCnt--; } - /* If the filter length is not a multiple of 4, compute the remaining filter taps */ + /* If the filter length is not a multiple of 4, compute the remaining filter + * taps */ tapCnt = numTaps % 0x4U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read coefficients */ c0 = *(pb++); @@ -218,10 +223,10 @@ void arm_fir_fast_q31( /* The results in the 4 accumulators are in 2.30 format. Convert to 1.31 Then store the 4 outputs in the destination buffer. */ - *pDst++ = (q31_t) (acc0 << 1); - *pDst++ = (q31_t) (acc1 << 1); - *pDst++ = (q31_t) (acc2 << 1); - *pDst++ = (q31_t) (acc3 << 1); + *pDst++ = (q31_t)(acc0 << 1); + *pDst++ = (q31_t)(acc1 << 1); + *pDst++ = (q31_t)(acc2 << 1); + *pDst++ = (q31_t)(acc3 << 1); /* Advance the state pointer by 4 to process the next group of 4 samples */ pState = pState + 4U; @@ -240,8 +245,7 @@ void arm_fir_fast_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy one sample at a time into state buffer */ *pStateCurnt++ = *pSrc++; @@ -257,15 +261,14 @@ void arm_fir_fast_q31( i = numTaps; /* Perform the multiply-accumulates */ - do - { + do { multAcc_32x32_keep32_R(acc0, (*px++), (*pb++)); i--; } while (i > 0U); /* The result is in 2.30 format. Convert to 1.31 Then store the output in the destination buffer. */ - *pDst++ = (q31_t) (acc0 << 1); + *pDst++ = (q31_t)(acc0 << 1); /* Advance state pointer by 1 for the next sample */ pState = pState + 1U; @@ -281,14 +284,13 @@ void arm_fir_fast_q31( /* Points to the start of the state buffer */ pStateCurnt = S->pState; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = (numTaps - 1U) >> 2U; /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; @@ -309,14 +311,12 @@ void arm_fir_fast_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy remaining data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement the loop counter */ tapCnt--; } - } IAR_ONLY_LOW_OPTIMIZATION_EXIT /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_init_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_init_f32.c index 02e82ad..d564f10 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_init_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_init_f32.c @@ -39,7 +39,8 @@ /** @brief Initialization function for the floating-point FIR filter. - @param[in,out] S points to an instance of the floating-point FIR filter structure + @param[in,out] S points to an instance of the floating-point FIR + filter structure @param[in] numTaps number of filter coefficients in the filter @param[in] pCoeffs points to the filter coefficients buffer @param[in] pState points to the state buffer @@ -47,22 +48,20 @@ @return none @par Details - pCoeffs points to the array of filter coefficients stored in time reversed order: -
-      {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
+                   pCoeffs points to the array of filter
+  coefficients stored in time reversed order: 
 {b[numTaps-1], b[numTaps-2],
+  b[N-2], ..., b[1], b[0]}
   
@par pState points to the array of state variables. - pState is of length numTaps+blockSize-1 samples, where blockSize is the number of input samples processed by each call to arm_fir_f32(). + pState is of length + numTaps+blockSize-1 samples, where blockSize is the + number of input samples processed by each call to arm_fir_f32(). */ -void arm_fir_init_f32( - arm_fir_instance_f32 * S, - uint16_t numTaps, - const float32_t * pCoeffs, - float32_t * pState, - uint32_t blockSize) -{ +void arm_fir_init_f32(arm_fir_instance_f32 *S, uint16_t numTaps, + const float32_t *pCoeffs, float32_t *pState, + uint32_t blockSize) { /* Assign filter taps */ S->numTaps = numTaps; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_init_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_init_q15.c index a5b2d06..64e6588 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_init_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_init_q15.c @@ -39,25 +39,28 @@ /** @brief Initialization function for the Q15 FIR filter. - @param[in,out] S points to an instance of the Q15 FIR filter structure. - @param[in] numTaps number of filter coefficients in the filter. Must be even and greater than or equal to 4. + @param[in,out] S points to an instance of the Q15 FIR filter + structure. + @param[in] numTaps number of filter coefficients in the filter. Must be + even and greater than or equal to 4. @param[in] pCoeffs points to the filter coefficients buffer. @param[in] pState points to the state buffer. @param[in] blockSize number of samples processed per call. @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : numTaps is not greater than or equal to 4 and even + - \ref ARM_MATH_ARGUMENT_ERROR : numTaps is not + greater than or equal to 4 and even @par Details - pCoeffs points to the array of filter coefficients stored in time reversed order: -
-      {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
+                   pCoeffs points to the array of filter
+  coefficients stored in time reversed order: 
 {b[numTaps-1], b[numTaps-2],
+  b[N-2], ..., b[1], b[0]}
   
- Note that numTaps must be even and greater than or equal to 4. - To implement an odd length filter simply increase numTaps by 1 and set the last coefficient to zero. - For example, to implement a filter with numTaps=3 and coefficients -
-      {0.3, -0.8, 0.3}
+                   Note that numTaps must be even and greater than
+  or equal to 4. To implement an odd length filter simply increase
+  numTaps by 1 and set the last coefficient to zero. For example,
+  to implement a filter with numTaps=3 and coefficients 
 {0.3,
+  -0.8, 0.3}
   
set numTaps=4 and use the coefficients:
@@ -72,27 +75,25 @@
       {0.3, -0.3, 0, 0}.
   
pState points to the array of state variables. - pState is of length numTaps+blockSize, when running on Cortex-M4 and Cortex-M3 and is of length numTaps+blockSize-1, when running on Cortex-M0 where blockSize is the number of input samples processed by each call to arm_fir_q15(). + pState is of length + numTaps+blockSize, when running on Cortex-M4 and Cortex-M3 and + is of length numTaps+blockSize-1, when running on Cortex-M0 where + blockSize is the number of input samples processed by each call + to arm_fir_q15(). */ -arm_status arm_fir_init_q15( - arm_fir_instance_q15 * S, - uint16_t numTaps, - const q15_t * pCoeffs, - q15_t * pState, - uint32_t blockSize) -{ +arm_status arm_fir_init_q15(arm_fir_instance_q15 *S, uint16_t numTaps, + const q15_t *pCoeffs, q15_t *pState, + uint32_t blockSize) { arm_status status; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) - /* The Number of filter coefficients in the filter must be even and at least 4 */ - if (numTaps & 0x1U) - { + /* The Number of filter coefficients in the filter must be even and at least 4 + */ + if (numTaps & 0x1U) { status = ARM_MATH_ARGUMENT_ERROR; - } - else - { + } else { /* Assign filter taps */ S->numTaps = numTaps; @@ -129,7 +130,6 @@ arm_status arm_fir_init_q15( return (status); #endif /* #if defined (ARM_MATH_DSP) */ - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_init_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_init_q31.c index 7d8376f..c7ff147 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_init_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_init_q31.c @@ -39,7 +39,8 @@ /** @brief Initialization function for the Q31 FIR filter. - @param[in,out] S points to an instance of the Q31 FIR filter structure + @param[in,out] S points to an instance of the Q31 FIR filter + structure @param[in] numTaps number of filter coefficients in the filter @param[in] pCoeffs points to the filter coefficients buffer @param[in] pState points to the state buffer @@ -47,21 +48,18 @@ @return none @par Details - pCoeffs points to the array of filter coefficients stored in time reversed order: -
-      {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
+                   pCoeffs points to the array of filter
+  coefficients stored in time reversed order: 
 {b[numTaps-1], b[numTaps-2],
+  b[N-2], ..., b[1], b[0]}
   
pState points to the array of state variables. - pState is of length numTaps+blockSize-1 samples, where blockSize is the number of input samples processed by each call to arm_fir_q31(). + pState is of length + numTaps+blockSize-1 samples, where blockSize is the + number of input samples processed by each call to arm_fir_q31(). */ -void arm_fir_init_q31( - arm_fir_instance_q31 * S, - uint16_t numTaps, - const q31_t * pCoeffs, - q31_t * pState, - uint32_t blockSize) -{ +void arm_fir_init_q31(arm_fir_instance_q31 *S, uint16_t numTaps, + const q31_t *pCoeffs, q31_t *pState, uint32_t blockSize) { /* Assign filter taps */ S->numTaps = numTaps; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_init_q7.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_init_q7.c index f96d250..79c77de 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_init_q7.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_init_q7.c @@ -47,22 +47,19 @@ @return none @par Details - pCoeffs points to the array of filter coefficients stored in time reversed order: -
-      {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
+                   pCoeffs points to the array of filter
+  coefficients stored in time reversed order: 
 {b[numTaps-1], b[numTaps-2],
+  b[N-2], ..., b[1], b[0]}
   
@par pState points to the array of state variables. - pState is of length numTaps+blockSize-1 samples, where blockSize is the number of input samples processed by each call to arm_fir_q7(). + pState is of length + numTaps+blockSize-1 samples, where blockSize is the + number of input samples processed by each call to arm_fir_q7(). */ -void arm_fir_init_q7( - arm_fir_instance_q7 * S, - uint16_t numTaps, - const q7_t * pCoeffs, - q7_t * pState, - uint32_t blockSize) -{ +void arm_fir_init_q7(arm_fir_instance_q7 *S, uint16_t numTaps, + const q7_t *pCoeffs, q7_t *pState, uint32_t blockSize) { /* Assign filter taps */ S->numTaps = numTaps; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_f32.c index 91ef699..481371c 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_f32.c @@ -32,87 +32,102 @@ @defgroup FIR_Interpolate Finite Impulse Response (FIR) Interpolator These functions combine an upsampler (zero stuffer) and an FIR filter. - They are used in multirate systems for increasing the sample rate of a signal without introducing high frequency images. - Conceptually, the functions are equivalent to the block diagram below: - \image html FIRInterpolator.gif "Components included in the FIR Interpolator functions" - After upsampling by a factor of L, the signal should be filtered by a lowpass filter with a normalized - cutoff frequency of 1/L in order to eliminate high frequency copies of the spectrum. - The user of the function is responsible for providing the filter coefficients. + They are used in multirate systems for increasing the sample rate of a signal + without introducing high frequency images. Conceptually, the functions are + equivalent to the block diagram below: \image html FIRInterpolator.gif + "Components included in the FIR Interpolator functions" After upsampling by a + factor of L, the signal should be filtered by a lowpass filter + with a normalized cutoff frequency of 1/L in order to eliminate + high frequency copies of the spectrum. The user of the function is responsible + for providing the filter coefficients. - The FIR interpolator functions provided in the CMSIS DSP Library combine the upsampler and FIR filter in an efficient manner. - The upsampler inserts L-1 zeros between each sample. - Instead of multiplying by these zero values, the FIR filter is designed to skip them. - This leads to an efficient implementation without any wasted effort. - The functions operate on blocks of input and output data. - pSrc points to an array of blockSize input values and - pDst points to an array of blockSize*L output values. + The FIR interpolator functions provided in the CMSIS DSP Library combine the + upsampler and FIR filter in an efficient manner. The upsampler inserts + L-1 zeros between each sample. Instead of multiplying by these + zero values, the FIR filter is designed to skip them. This leads to an + efficient implementation without any wasted effort. The functions operate on + blocks of input and output data. pSrc points to an array of + blockSize input values and pDst points to an array + of blockSize*L output values. - The library provides separate functions for Q15, Q31, and floating-point data types. + The library provides separate functions for Q15, Q31, and floating-point data + types. @par Algorithm The functions use a polyphase filter structure:
-      y[n] = b[0] * x[n] + b[L]   * x[n-1] + ... + b[L*(phaseLength-1)] * x[n-phaseLength+1]
-      y[n+1] = b[1] * x[n] + b[L+1] * x[n-1] + ... + b[L*(phaseLength-1)+1] * x[n-phaseLength+1]
+      y[n] = b[0] * x[n] + b[L]   * x[n-1] + ... + b[L*(phaseLength-1)] *
+  x[n-phaseLength+1] y[n+1] = b[1] * x[n] + b[L+1] * x[n-1] + ... +
+  b[L*(phaseLength-1)+1] * x[n-phaseLength+1]
       ...
-      y[n+(L-1)] = b[L-1] * x[n] + b[2*L-1] * x[n-1] + ....+ b[L*(phaseLength-1)+(L-1)] * x[n-phaseLength+1]
+      y[n+(L-1)] = b[L-1] * x[n] + b[2*L-1] * x[n-1] + ....+
+  b[L*(phaseLength-1)+(L-1)] * x[n-phaseLength+1]
   
- This approach is more efficient than straightforward upsample-then-filter algorithms. - With this method the computation is reduced by a factor of 1/L when compared to using a standard FIR filter. + This approach is more efficient than straightforward + upsample-then-filter algorithms. With this method the computation is reduced + by a factor of 1/L when compared to using a standard FIR filter. @par - pCoeffs points to a coefficient array of size numTaps. - numTaps must be a multiple of the interpolation factor L and this is checked by the - initialization functions. - Internally, the function divides the FIR filter's impulse response into shorter filters of length - phaseLength=numTaps/L. + pCoeffs points to a coefficient array of size + numTaps. numTaps must be a multiple of the + interpolation factor L and this is checked by the initialization + functions. Internally, the function divides the FIR filter's impulse response + into shorter filters of length phaseLength=numTaps/L. Coefficients are stored in time reversed order.
       {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
   
@par - pState points to a state array of size blockSize + phaseLength - 1. - Samples in the state buffer are stored in the order: -
-     {x[n-phaseLength+1], x[n-phaseLength], x[n-phaseLength-1], x[n-phaseLength-2]....x[0], x[1], ..., x[blockSize-1]}
+                   pState points to a state array of size
+  blockSize + phaseLength - 1. Samples in the state buffer are
+  stored in the order: 
 {x[n-phaseLength+1], x[n-phaseLength],
+  x[n-phaseLength-1], x[n-phaseLength-2]....x[0], x[1], ..., x[blockSize-1]}
   
@par - The state variables are updated after each block of data is processed, the coefficients are untouched. + The state variables are updated after each block of data is + processed, the coefficients are untouched. @par Instance Structure - The coefficients and state variables for a filter are stored together in an instance data structure. - A separate instance structure must be defined for each filter. - Coefficient arrays may be shared among several instances while state variable array should be allocated separately. - There are separate instance structure declarations for each of the 3 supported data types. + The coefficients and state variables for a filter are stored + together in an instance data structure. A separate instance structure must be + defined for each filter. Coefficient arrays may be shared among several + instances while state variable array should be allocated separately. There are + separate instance structure declarations for each of the 3 supported data + types. @par Initialization Functions - There is also an associated initialization function for each data type. - The initialization function performs the following operations: + There is also an associated initialization function for each + data type. The initialization function performs the following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. - - Checks to make sure that the length of the filter is a multiple of the interpolation factor. - To do this manually without calling the init function, assign the follow subfields of the instance structure: - L (interpolation factor), pCoeffs, phaseLength (numTaps / L), pState. Also set all of the values in pState to zero. + - Checks to make sure that the length of the filter is a + multiple of the interpolation factor. To do this manually without calling the + init function, assign the follow subfields of the instance structure: L + (interpolation factor), pCoeffs, phaseLength (numTaps / L), pState. Also set + all of the values in pState to zero. @par Use of the initialization function is optional. - However, if the initialization function is used, then the instance structure cannot be placed into a const data section. - To place an instance structure into a const data section, the instance structure must be manually initialized. - The code below statically initializes each of the 3 different data type filter instance structures -
+                   However, if the initialization function is used, then the
+  instance structure cannot be placed into a const data section. To place an
+  instance structure into a const data section, the instance structure must be
+  manually initialized. The code below statically initializes each of the 3
+  different data type filter instance structures 
       arm_fir_interpolate_instance_f32 S = {L, phaseLength, pCoeffs, pState};
       arm_fir_interpolate_instance_q31 S = {L, phaseLength, pCoeffs, pState};
       arm_fir_interpolate_instance_q15 S = {L, phaseLength, pCoeffs, pState};
   
@par - where L is the interpolation factor; phaseLength=numTaps/L is the - length of each of the shorter FIR filters used internally, - pCoeffs is the address of the coefficient buffer; - pState is the address of the state buffer. - Be sure to set the values in the state buffer to zeros when doing static initialization. + where L is the interpolation factor; + phaseLength=numTaps/L is the length of each of the shorter FIR + filters used internally, pCoeffs is the address of the + coefficient buffer; pState is the address of the state buffer. Be + sure to set the values in the state buffer to zeros when doing static + initialization. @par Fixed-Point Behavior - Care must be taken when using the fixed-point versions of the FIR interpolate filter functions. - In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. - Refer to the function specific documentation below for usage guidelines. + Care must be taken when using the fixed-point versions of the + FIR interpolate filter functions. In particular, the overflow and saturation + behavior of the accumulator used in each function must be considered. Refer to + the function specific documentation below for usage guidelines. */ /** @@ -122,49 +137,48 @@ /** @brief Processing function for floating-point FIR interpolator. - @param[in] S points to an instance of the floating-point FIR interpolator structure + @param[in] S points to an instance of the floating-point FIR + interpolator structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none */ -void arm_fir_interpolate_f32( - const arm_fir_interpolate_instance_f32 * S, - const float32_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ +void arm_fir_interpolate_f32(const arm_fir_interpolate_instance_f32 *S, + const float32_t *pSrc, float32_t *pDst, + uint32_t blockSize) { #if (1) -//#if !defined(ARM_MATH_CM0_FAMILY) + //#if !defined(ARM_MATH_CM0_FAMILY) - float32_t *pState = S->pState; /* State pointer */ - const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - float32_t *pStateCur; /* Points to the current sample of the state */ - float32_t *ptr1; /* Temporary pointer for state buffer */ - const float32_t *ptr2; /* Temporary pointer for coefficient buffer */ - float32_t sum0; /* Accumulators */ - uint32_t i, blkCnt, tapCnt; /* Loop counters */ - uint32_t phaseLen = S->phaseLength; /* Length of each polyphase filter component */ - uint32_t j; + float32_t *pState = S->pState; /* State pointer */ + const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + float32_t *pStateCur; /* Points to the current sample of the state */ + float32_t *ptr1; /* Temporary pointer for state buffer */ + const float32_t *ptr2; /* Temporary pointer for coefficient buffer */ + float32_t sum0; /* Accumulators */ + uint32_t i, blkCnt, tapCnt; /* Loop counters */ + uint32_t phaseLen = + S->phaseLength; /* Length of each polyphase filter component */ + uint32_t j; -#if defined (ARM_MATH_LOOPUNROLL) - float32_t acc0, acc1, acc2, acc3; - float32_t x0, x1, x2, x3; - float32_t c0, c1, c2, c3; +#if defined(ARM_MATH_LOOPUNROLL) + float32_t acc0, acc1, acc2, acc3; + float32_t x0, x1, x2, x3; + float32_t c0, c1, c2, c3; #endif /* S->pState buffer contains previous frame (phaseLen - 1) samples */ - /* pStateCur points to the location where the new input data should be written */ + /* pStateCur points to the location where the new input data should be written + */ pStateCur = S->pState + (phaseLen - 1U); -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy new input sample into the state buffer */ *pStateCur++ = *pSrc++; *pStateCur++ = *pSrc++; @@ -177,8 +191,7 @@ void arm_fir_interpolate_f32( /* Loop over the Interpolation factor. */ i = (S->L); - while (i > 0U) - { + while (i > 0U) { /* Set accumulator to zero */ acc0 = 0.0f; acc1 = 0.0f; @@ -199,8 +212,7 @@ void arm_fir_interpolate_f32( x1 = *(ptr1++); x2 = *(ptr1++); - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the input sample */ x3 = *(ptr1++); @@ -249,7 +261,6 @@ void arm_fir_interpolate_f32( acc2 += x1 * c3; acc3 += x2 * c3; - /* Upsampling is done by stuffing L-1 zeros between each sample. * So instead of multiplying zeros with coefficients, * Increment the coefficient pointer by interpolation factor times. */ @@ -259,11 +270,11 @@ void arm_fir_interpolate_f32( tapCnt--; } - /* If the polyPhase length is not a multiple of 4, compute the remaining filter taps */ + /* If the polyPhase length is not a multiple of 4, compute the remaining + * filter taps */ tapCnt = phaseLen % 0x4U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the input sample */ x3 = *(ptr1++); @@ -289,8 +300,8 @@ void arm_fir_interpolate_f32( } /* The result is in the accumulator, store in the destination buffer. */ - *(pDst ) = acc0; - *(pDst + S->L) = acc1; + *(pDst) = acc0; + *(pDst + S->L) = acc1; *(pDst + 2 * S->L) = acc2; *(pDst + 3 * S->L) = acc3; @@ -323,8 +334,7 @@ void arm_fir_interpolate_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy new input sample into the state buffer */ *pStateCur++ = *pSrc++; @@ -333,8 +343,7 @@ void arm_fir_interpolate_f32( /* Loop over the Interpolation factor. */ i = S->L; - while (i > 0U) - { + while (i > 0U) { /* Set accumulator to zero */ sum0 = 0.0f; @@ -347,13 +356,12 @@ void arm_fir_interpolate_f32( /* Loop over the polyPhase length. Repeat until we've computed numTaps-(4*S->L) coefficients. */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) - /* Loop unrolling: Compute 4 outputs at a time */ + /* Loop unrolling: Compute 4 outputs at a time */ tapCnt = phaseLen >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ sum0 += *ptr1++ * *ptr2; @@ -385,8 +393,7 @@ void arm_fir_interpolate_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ sum0 += *ptr1++ * *ptr2; @@ -424,14 +431,13 @@ void arm_fir_interpolate_f32( /* Points to the start of the state buffer */ pStateCur = S->pState; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ tapCnt = (phaseLen - 1U) >> 2U; /* copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; @@ -446,14 +452,13 @@ void arm_fir_interpolate_f32( #else - /* Initialize tapCnt with number of samples */ - tapCnt = (phaseLen - 1U); + /* Initialize tapCnt with number of samples */ + tapCnt = (phaseLen - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ @@ -461,35 +466,35 @@ void arm_fir_interpolate_f32( } #else -/* alternate version for CM0_FAMILY */ + /* alternate version for CM0_FAMILY */ - float32_t *pState = S->pState; /* State pointer */ - const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - float32_t *pStateCur; /* Points to the current sample of the state */ - float32_t *ptr1; /* Temporary pointer for state buffer */ - const float32_t *ptr2; /* Temporary pointer for coefficient buffer */ - float32_t sum0; /* Accumulators */ - uint32_t i, blkCnt, tapCnt; /* Loop counters */ - uint32_t phaseLen = S->phaseLength; /* Length of each polyphase filter component */ + float32_t *pState = S->pState; /* State pointer */ + const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + float32_t *pStateCur; /* Points to the current sample of the state */ + float32_t *ptr1; /* Temporary pointer for state buffer */ + const float32_t *ptr2; /* Temporary pointer for coefficient buffer */ + float32_t sum0; /* Accumulators */ + uint32_t i, blkCnt, tapCnt; /* Loop counters */ + uint32_t phaseLen = + S->phaseLength; /* Length of each polyphase filter component */ /* S->pState buffer contains previous frame (phaseLen - 1) samples */ - /* pStateCur points to the location where the new input data should be written */ + /* pStateCur points to the location where the new input data should be written + */ pStateCur = S->pState + (phaseLen - 1U); /* Total number of intput samples */ blkCnt = blockSize; /* Loop over the blockSize. */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy new input sample into the state buffer */ *pStateCur++ = *pSrc++; /* Loop over the Interpolation factor. */ i = S->L; - while (i > 0U) - { + while (i > 0U) { /* Set accumulator to zero */ sum0 = 0.0f; @@ -502,8 +507,7 @@ void arm_fir_interpolate_f32( /* Loop over the polyPhase length */ tapCnt = phaseLen; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ sum0 += *ptr1++ * *ptr2; @@ -539,8 +543,7 @@ void arm_fir_interpolate_f32( tapCnt = phaseLen - 1U; /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ @@ -548,7 +551,6 @@ void arm_fir_interpolate_f32( } #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */ - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_init_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_init_f32.c index 287d347..8684b93 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_init_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_init_f32.c @@ -38,8 +38,10 @@ */ /** - @brief Initialization function for the floating-point FIR interpolator. - @param[in,out] S points to an instance of the floating-point FIR interpolator structure + @brief Initialization function for the floating-point FIR + interpolator. + @param[in,out] S points to an instance of the floating-point FIR + interpolator structure @param[in] L upsample factor @param[in] numTaps number of filter coefficients in the filter @param[in] pCoeffs points to the filter coefficient buffer @@ -47,39 +49,37 @@ @param[in] blockSize number of input samples to process per call @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : filter length numTaps is not a multiple of the interpolation factor L + - \ref ARM_MATH_ARGUMENT_ERROR : filter length + numTaps is not a multiple of the interpolation factor + L @par Details - pCoeffs points to the array of filter coefficients stored in time reversed order: -
-      {b[numTaps-1], b[numTaps-2], b[numTaps-2], ..., b[1], b[0]}
+                   pCoeffs points to the array of filter
+  coefficients stored in time reversed order: 
 {b[numTaps-1], b[numTaps-2],
+  b[numTaps-2], ..., b[1], b[0]}
   
@par - The length of the filter numTaps must be a multiple of the interpolation factor L. + The length of the filter numTaps must be a + multiple of the interpolation factor L. @par pState points to the array of state variables. - pState is of length (numTaps/L)+blockSize-1 words - where blockSize is the number of input samples processed by each call to arm_fir_interpolate_f32(). + pState is of length + (numTaps/L)+blockSize-1 words where blockSize is the + number of input samples processed by each call to + arm_fir_interpolate_f32(). */ -arm_status arm_fir_interpolate_init_f32( - arm_fir_interpolate_instance_f32 * S, - uint8_t L, - uint16_t numTaps, - const float32_t * pCoeffs, - float32_t * pState, - uint32_t blockSize) -{ +arm_status arm_fir_interpolate_init_f32(arm_fir_interpolate_instance_f32 *S, + uint8_t L, uint16_t numTaps, + const float32_t *pCoeffs, + float32_t *pState, uint32_t blockSize) { arm_status status; /* The filter length must be a multiple of the interpolation factor */ - if ((numTaps % L) != 0U) - { + if ((numTaps % L) != 0U) { /* Set status as ARM_MATH_LENGTH_ERROR */ status = ARM_MATH_LENGTH_ERROR; - } - else - { + } else { /* Assign coefficient pointer */ S->pCoeffs = pCoeffs; @@ -89,8 +89,10 @@ arm_status arm_fir_interpolate_init_f32( /* Assign polyPhaseLength */ S->phaseLength = numTaps / L; - /* Clear state buffer and size of buffer is always phaseLength + blockSize - 1 */ - memset(pState, 0, (blockSize + ((uint32_t) S->phaseLength - 1U)) * sizeof(float32_t)); + /* Clear state buffer and size of buffer is always phaseLength + blockSize - + * 1 */ + memset(pState, 0, + (blockSize + ((uint32_t)S->phaseLength - 1U)) * sizeof(float32_t)); /* Assign state pointer */ S->pState = pState; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_init_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_init_q15.c index 7f43bbf..a64e478 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_init_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_init_q15.c @@ -39,7 +39,8 @@ /** @brief Initialization function for the Q15 FIR interpolator. - @param[in,out] S points to an instance of the Q15 FIR interpolator structure + @param[in,out] S points to an instance of the Q15 FIR interpolator + structure @param[in] L upsample factor @param[in] numTaps number of filter coefficients in the filter @param[in] pCoeffs points to the filter coefficient buffer @@ -47,39 +48,37 @@ @param[in] blockSize number of input samples to process per call @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : filter length numTaps is not a multiple of the interpolation factor L + - \ref ARM_MATH_ARGUMENT_ERROR : filter length + numTaps is not a multiple of the interpolation factor + L @par Details - pCoeffs points to the array of filter coefficients stored in time reversed order: -
-      {b[numTaps-1], b[numTaps-2], b[numTaps-2], ..., b[1], b[0]}
+                   pCoeffs points to the array of filter
+  coefficients stored in time reversed order: 
 {b[numTaps-1], b[numTaps-2],
+  b[numTaps-2], ..., b[1], b[0]}
   
- The length of the filter numTaps must be a multiple of the interpolation factor L. + The length of the filter numTaps must be a + multiple of the interpolation factor L. @par pState points to the array of state variables. - pState is of length (numTaps/L)+blockSize-1 words - where blockSize is the number of input samples processed by each call to arm_fir_interpolate_q15(). + pState is of length + (numTaps/L)+blockSize-1 words where blockSize is the + number of input samples processed by each call to + arm_fir_interpolate_q15(). */ -arm_status arm_fir_interpolate_init_q15( - arm_fir_interpolate_instance_q15 * S, - uint8_t L, - uint16_t numTaps, - const q15_t * pCoeffs, - q15_t * pState, - uint32_t blockSize) -{ +arm_status arm_fir_interpolate_init_q15(arm_fir_interpolate_instance_q15 *S, + uint8_t L, uint16_t numTaps, + const q15_t *pCoeffs, q15_t *pState, + uint32_t blockSize) { arm_status status; /* The filter length must be a multiple of the interpolation factor */ - if ((numTaps % L) != 0U) - { + if ((numTaps % L) != 0U) { /* Set status as ARM_MATH_LENGTH_ERROR */ status = ARM_MATH_LENGTH_ERROR; - } - else - { + } else { /* Assign coefficient pointer */ S->pCoeffs = pCoeffs; @@ -89,8 +88,10 @@ arm_status arm_fir_interpolate_init_q15( /* Assign polyPhaseLength */ S->phaseLength = numTaps / L; - /* Clear state buffer and size of buffer is always phaseLength + blockSize - 1 */ - memset(pState, 0, (blockSize + ((uint32_t) S->phaseLength - 1U)) * sizeof(q15_t)); + /* Clear state buffer and size of buffer is always phaseLength + blockSize - + * 1 */ + memset(pState, 0, + (blockSize + ((uint32_t)S->phaseLength - 1U)) * sizeof(q15_t)); /* Assign state pointer */ S->pState = pState; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_init_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_init_q31.c index 973e715..4b7bde0 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_init_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_init_q31.c @@ -39,7 +39,8 @@ /** @brief Initialization function for the Q31 FIR interpolator. - @param[in,out] S points to an instance of the Q31 FIR interpolator structure + @param[in,out] S points to an instance of the Q31 FIR interpolator + structure @param[in] L upsample factor @param[in] numTaps number of filter coefficients in the filter @param[in] pCoeffs points to the filter coefficient buffer @@ -47,38 +48,36 @@ @param[in] blockSize number of input samples to process per call @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : filter length numTaps is not a multiple of the interpolation factor L - + - \ref ARM_MATH_ARGUMENT_ERROR : filter length + numTaps is not a multiple of the interpolation factor + L + @par Details - pCoeffs points to the array of filter coefficients stored in time reversed order: -
-      {b[numTaps-1], b[numTaps-2], b[numTaps-2], ..., b[1], b[0]}
+                   pCoeffs points to the array of filter
+  coefficients stored in time reversed order: 
 {b[numTaps-1], b[numTaps-2],
+  b[numTaps-2], ..., b[1], b[0]}
   
- The length of the filter numTaps must be a multiple of the interpolation factor L. + The length of the filter numTaps must be a + multiple of the interpolation factor L. @par pState points to the array of state variables. - pState is of length (numTaps/L)+blockSize-1 words - where blockSize is the number of input samples processed by each call to arm_fir_interpolate_q31(). + pState is of length + (numTaps/L)+blockSize-1 words where blockSize is the + number of input samples processed by each call to + arm_fir_interpolate_q31(). */ -arm_status arm_fir_interpolate_init_q31( - arm_fir_interpolate_instance_q31 * S, - uint8_t L, - uint16_t numTaps, - const q31_t * pCoeffs, - q31_t * pState, - uint32_t blockSize) -{ +arm_status arm_fir_interpolate_init_q31(arm_fir_interpolate_instance_q31 *S, + uint8_t L, uint16_t numTaps, + const q31_t *pCoeffs, q31_t *pState, + uint32_t blockSize) { arm_status status; /* The filter length must be a multiple of the interpolation factor */ - if ((numTaps % L) != 0U) - { + if ((numTaps % L) != 0U) { /* Set status as ARM_MATH_LENGTH_ERROR */ status = ARM_MATH_LENGTH_ERROR; - } - else - { + } else { /* Assign coefficient pointer */ S->pCoeffs = pCoeffs; @@ -88,8 +87,10 @@ arm_status arm_fir_interpolate_init_q31( /* Assign polyPhaseLength */ S->phaseLength = numTaps / L; - /* Clear state buffer and size of buffer is always phaseLength + blockSize - 1 */ - memset(pState, 0, (blockSize + ((uint32_t) S->phaseLength - 1U)) * sizeof(q31_t)); + /* Clear state buffer and size of buffer is always phaseLength + blockSize - + * 1 */ + memset(pState, 0, + (blockSize + ((uint32_t)S->phaseLength - 1U)) * sizeof(q31_t)); /* Assign state pointer */ S->pState = pState; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_q15.c index 7efec94..708acfb 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_q15.c @@ -39,57 +39,58 @@ /** @brief Processing function for the Q15 FIR interpolator. - @param[in] S points to an instance of the Q15 FIR interpolator structure + @param[in] S points to an instance of the Q15 FIR interpolator + structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior - The function is implemented using a 64-bit internal accumulator. - Both coefficients and state variables are represented in 1.15 format and multiplications yield a 2.30 result. - The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. - There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. - After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits. - Lastly, the accumulator is saturated to yield a result in 1.15 format. + The function is implemented using a 64-bit internal + accumulator. Both coefficients and state variables are represented in 1.15 + format and multiplications yield a 2.30 result. The 2.30 intermediate results + are accumulated in a 64-bit accumulator in 34.30 format. There is no risk of + internal overflow with this approach and the full precision of intermediate + multiplications is preserved. After all additions have been performed, the + accumulator is truncated to 34.15 format by discarding low 15 bits. Lastly, + the accumulator is saturated to yield a result in 1.15 format. */ -void arm_fir_interpolate_q15( - const arm_fir_interpolate_instance_q15 * S, - const q15_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ +void arm_fir_interpolate_q15(const arm_fir_interpolate_instance_q15 *S, + const q15_t *pSrc, q15_t *pDst, + uint32_t blockSize) { #if (1) -//#if !defined(ARM_MATH_CM0_FAMILY) + //#if !defined(ARM_MATH_CM0_FAMILY) - q15_t *pState = S->pState; /* State pointer */ - const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q15_t *pStateCur; /* Points to the current sample of the state */ - q15_t *ptr1; /* Temporary pointer for state buffer */ - const q15_t *ptr2; /* Temporary pointer for coefficient buffer */ - q63_t sum0; /* Accumulators */ - uint32_t i, blkCnt, tapCnt; /* Loop counters */ - uint32_t phaseLen = S->phaseLength; /* Length of each polyphase filter component */ - uint32_t j; + q15_t *pState = S->pState; /* State pointer */ + const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q15_t *pStateCur; /* Points to the current sample of the state */ + q15_t *ptr1; /* Temporary pointer for state buffer */ + const q15_t *ptr2; /* Temporary pointer for coefficient buffer */ + q63_t sum0; /* Accumulators */ + uint32_t i, blkCnt, tapCnt; /* Loop counters */ + uint32_t phaseLen = + S->phaseLength; /* Length of each polyphase filter component */ + uint32_t j; -#if defined (ARM_MATH_LOOPUNROLL) - q63_t acc0, acc1, acc2, acc3; - q15_t x0, x1, x2, x3; - q15_t c0, c1, c2, c3; +#if defined(ARM_MATH_LOOPUNROLL) + q63_t acc0, acc1, acc2, acc3; + q15_t x0, x1, x2, x3; + q15_t c0, c1, c2, c3; #endif /* S->pState buffer contains previous frame (phaseLen - 1) samples */ - /* pStateCur points to the location where the new input data should be written */ + /* pStateCur points to the location where the new input data should be written + */ pStateCur = S->pState + (phaseLen - 1U); -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy new input sample into the state buffer */ *pStateCur++ = *pSrc++; *pStateCur++ = *pSrc++; @@ -102,8 +103,7 @@ void arm_fir_interpolate_q15( /* Loop over the Interpolation factor. */ i = (S->L); - while (i > 0U) - { + while (i > 0U) { /* Set accumulator to zero */ acc0 = 0; acc1 = 0; @@ -124,8 +124,7 @@ void arm_fir_interpolate_q15( x1 = *(ptr1++); x2 = *(ptr1++); - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the input sample */ x3 = *(ptr1++); @@ -133,10 +132,10 @@ void arm_fir_interpolate_q15( c0 = *(ptr2); /* Perform the multiply-accumulate */ - acc0 += (q63_t) x0 * c0; - acc1 += (q63_t) x1 * c0; - acc2 += (q63_t) x2 * c0; - acc3 += (q63_t) x3 * c0; + acc0 += (q63_t)x0 * c0; + acc1 += (q63_t)x1 * c0; + acc2 += (q63_t)x2 * c0; + acc3 += (q63_t)x3 * c0; /* Read the coefficient */ c1 = *(ptr2 + S->L); @@ -145,10 +144,10 @@ void arm_fir_interpolate_q15( x0 = *(ptr1++); /* Perform the multiply-accumulate */ - acc0 += (q63_t) x1 * c1; - acc1 += (q63_t) x2 * c1; - acc2 += (q63_t) x3 * c1; - acc3 += (q63_t) x0 * c1; + acc0 += (q63_t)x1 * c1; + acc1 += (q63_t)x2 * c1; + acc2 += (q63_t)x3 * c1; + acc3 += (q63_t)x0 * c1; /* Read the coefficient */ c2 = *(ptr2 + S->L * 2); @@ -157,10 +156,10 @@ void arm_fir_interpolate_q15( x1 = *(ptr1++); /* Perform the multiply-accumulate */ - acc0 += (q63_t) x2 * c2; - acc1 += (q63_t) x3 * c2; - acc2 += (q63_t) x0 * c2; - acc3 += (q63_t) x1 * c2; + acc0 += (q63_t)x2 * c2; + acc1 += (q63_t)x3 * c2; + acc2 += (q63_t)x0 * c2; + acc3 += (q63_t)x1 * c2; /* Read the coefficient */ c3 = *(ptr2 + S->L * 3); @@ -169,11 +168,10 @@ void arm_fir_interpolate_q15( x2 = *(ptr1++); /* Perform the multiply-accumulate */ - acc0 += (q63_t) x3 * c3; - acc1 += (q63_t) x0 * c3; - acc2 += (q63_t) x1 * c3; - acc3 += (q63_t) x2 * c3; - + acc0 += (q63_t)x3 * c3; + acc1 += (q63_t)x0 * c3; + acc2 += (q63_t)x1 * c3; + acc3 += (q63_t)x2 * c3; /* Upsampling is done by stuffing L-1 zeros between each sample. * So instead of multiplying zeros with coefficients, @@ -184,11 +182,11 @@ void arm_fir_interpolate_q15( tapCnt--; } - /* If the polyPhase length is not a multiple of 4, compute the remaining filter taps */ + /* If the polyPhase length is not a multiple of 4, compute the remaining + * filter taps */ tapCnt = phaseLen % 0x4U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the input sample */ x3 = *(ptr1++); @@ -196,10 +194,10 @@ void arm_fir_interpolate_q15( c0 = *(ptr2); /* Perform the multiply-accumulate */ - acc0 += (q63_t) x0 * c0; - acc1 += (q63_t) x1 * c0; - acc2 += (q63_t) x2 * c0; - acc3 += (q63_t) x3 * c0; + acc0 += (q63_t)x0 * c0; + acc1 += (q63_t)x1 * c0; + acc2 += (q63_t)x2 * c0; + acc3 += (q63_t)x3 * c0; /* Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; @@ -214,10 +212,10 @@ void arm_fir_interpolate_q15( } /* The result is in the accumulator, store in the destination buffer. */ - *(pDst ) = (q15_t) (__SSAT((acc0 >> 15), 16)); - *(pDst + S->L) = (q15_t) (__SSAT((acc1 >> 15), 16)); - *(pDst + 2 * S->L) = (q15_t) (__SSAT((acc2 >> 15), 16)); - *(pDst + 3 * S->L) = (q15_t) (__SSAT((acc3 >> 15), 16)); + *(pDst) = (q15_t)(__SSAT((acc0 >> 15), 16)); + *(pDst + S->L) = (q15_t)(__SSAT((acc1 >> 15), 16)); + *(pDst + 2 * S->L) = (q15_t)(__SSAT((acc2 >> 15), 16)); + *(pDst + 3 * S->L) = (q15_t)(__SSAT((acc3 >> 15), 16)); pDst++; @@ -248,8 +246,7 @@ void arm_fir_interpolate_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy new input sample into the state buffer */ *pStateCur++ = *pSrc++; @@ -258,8 +255,7 @@ void arm_fir_interpolate_q15( /* Loop over the Interpolation factor. */ i = S->L; - while (i > 0U) - { + while (i > 0U) { /* Set accumulator to zero */ sum0 = 0; @@ -272,28 +268,27 @@ void arm_fir_interpolate_q15( /* Loop over the polyPhase length. Repeat until we've computed numTaps-(4*S->L) coefficients. */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) - /* Loop unrolling: Compute 4 outputs at a time */ + /* Loop unrolling: Compute 4 outputs at a time */ tapCnt = phaseLen >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ - sum0 += (q63_t) *ptr1++ * *ptr2; + sum0 += (q63_t)*ptr1++ * *ptr2; /* Upsampling is done by stuffing L-1 zeros between each sample. * So instead of multiplying zeros with coefficients, * Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; - sum0 += (q63_t) *ptr1++ * *ptr2; + sum0 += (q63_t)*ptr1++ * *ptr2; ptr2 += S->L; - sum0 += (q63_t) *ptr1++ * *ptr2; + sum0 += (q63_t)*ptr1++ * *ptr2; ptr2 += S->L; - sum0 += (q63_t) *ptr1++ * *ptr2; + sum0 += (q63_t)*ptr1++ * *ptr2; ptr2 += S->L; /* Decrement loop counter */ @@ -310,10 +305,9 @@ void arm_fir_interpolate_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ - sum0 += (q63_t) *ptr1++ * *ptr2; + sum0 += (q63_t)*ptr1++ * *ptr2; /* Upsampling is done by stuffing L-1 zeros between each sample. * So instead of multiplying zeros with coefficients, @@ -325,7 +319,7 @@ void arm_fir_interpolate_q15( } /* The result is in the accumulator, store in the destination buffer. */ - *pDst++ = (q15_t) (__SSAT((sum0 >> 15), 16)); + *pDst++ = (q15_t)(__SSAT((sum0 >> 15), 16)); /* Increment the address modifier index of coefficient buffer */ j++; @@ -349,16 +343,15 @@ void arm_fir_interpolate_q15( /* Points to the start of the state buffer */ pStateCur = S->pState; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ tapCnt = (phaseLen - 1U) >> 2U; /* copy data */ - while (tapCnt > 0U) - { - write_q15x2_ia (&pStateCur, read_q15x2_ia (&pState)); - write_q15x2_ia (&pStateCur, read_q15x2_ia (&pState)); + while (tapCnt > 0U) { + write_q15x2_ia(&pStateCur, read_q15x2_ia(&pState)); + write_q15x2_ia(&pStateCur, read_q15x2_ia(&pState)); /* Decrement loop counter */ tapCnt--; @@ -369,14 +362,13 @@ void arm_fir_interpolate_q15( #else - /* Initialize tapCnt with number of samples */ - tapCnt = (phaseLen - 1U); + /* Initialize tapCnt with number of samples */ + tapCnt = (phaseLen - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ @@ -384,35 +376,35 @@ void arm_fir_interpolate_q15( } #else -/* alternate version for CM0_FAMILY */ + /* alternate version for CM0_FAMILY */ - q15_t *pState = S->pState; /* State pointer */ - const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q15_t *pStateCur; /* Points to the current sample of the state */ - q15_t *ptr1; /* Temporary pointer for state buffer */ - const q15_t *ptr2; /* Temporary pointer for coefficient buffer */ - q63_t sum0; /* Accumulators */ - uint32_t i, blkCnt, tapCnt; /* Loop counters */ - uint32_t phaseLen = S->phaseLength; /* Length of each polyphase filter component */ + q15_t *pState = S->pState; /* State pointer */ + const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q15_t *pStateCur; /* Points to the current sample of the state */ + q15_t *ptr1; /* Temporary pointer for state buffer */ + const q15_t *ptr2; /* Temporary pointer for coefficient buffer */ + q63_t sum0; /* Accumulators */ + uint32_t i, blkCnt, tapCnt; /* Loop counters */ + uint32_t phaseLen = + S->phaseLength; /* Length of each polyphase filter component */ /* S->pState buffer contains previous frame (phaseLen - 1) samples */ - /* pStateCur points to the location where the new input data should be written */ + /* pStateCur points to the location where the new input data should be written + */ pStateCur = S->pState + (phaseLen - 1U); /* Total number of intput samples */ blkCnt = blockSize; /* Loop over the blockSize. */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy new input sample into the state buffer */ *pStateCur++ = *pSrc++; /* Loop over the Interpolation factor. */ i = S->L; - while (i > 0U) - { + while (i > 0U) { /* Set accumulator to zero */ sum0 = 0; @@ -425,10 +417,9 @@ void arm_fir_interpolate_q15( /* Loop over the polyPhase length */ tapCnt = phaseLen; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ - sum0 += ((q63_t) *ptr1++ * *ptr2); + sum0 += ((q63_t)*ptr1++ * *ptr2); /* Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; @@ -437,8 +428,9 @@ void arm_fir_interpolate_q15( tapCnt--; } - /* Store the result after converting to 1.15 format in the destination buffer. */ - *pDst++ = (q15_t) (__SSAT((sum0 >> 15), 16)); + /* Store the result after converting to 1.15 format in the destination + * buffer. */ + *pDst++ = (q15_t)(__SSAT((sum0 >> 15), 16)); /* Decrement loop counter */ i--; @@ -462,8 +454,7 @@ void arm_fir_interpolate_q15( tapCnt = phaseLen - 1U; /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ @@ -471,7 +462,6 @@ void arm_fir_interpolate_q15( } #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */ - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_q31.c index d6a8ca3..67509f6 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_interpolate_q31.c @@ -39,57 +39,59 @@ /** @brief Processing function for the Q31 FIR interpolator. - @param[in] S points to an instance of the Q31 FIR interpolator structure + @param[in] S points to an instance of the Q31 FIR interpolator + structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior - The function is implemented using an internal 64-bit accumulator. - The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. - Thus, if the accumulator result overflows it wraps around rather than clip. - In order to avoid overflows completely the input signal must be scaled down by 1/(numTaps/L). - since numTaps/L additions occur per output sample. - After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format. + The function is implemented using an internal 64-bit + accumulator. The accumulator has a 2.62 format and maintains full precision of + the intermediate multiplication results but provides only a single guard bit. + Thus, if the accumulator result overflows it wraps around + rather than clip. In order to avoid overflows completely the input signal must + be scaled down by 1/(numTaps/L). since numTaps/L + additions occur per output sample. After all multiply-accumulates are + performed, the 2.62 accumulator is truncated to 1.32 format and then saturated + to 1.31 format. */ -void arm_fir_interpolate_q31( - const arm_fir_interpolate_instance_q31 * S, - const q31_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ +void arm_fir_interpolate_q31(const arm_fir_interpolate_instance_q31 *S, + const q31_t *pSrc, q31_t *pDst, + uint32_t blockSize) { #if (1) -//#if !defined(ARM_MATH_CM0_FAMILY) + //#if !defined(ARM_MATH_CM0_FAMILY) - q31_t *pState = S->pState; /* State pointer */ - const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q31_t *pStateCur; /* Points to the current sample of the state */ - q31_t *ptr1; /* Temporary pointer for state buffer */ - const q31_t *ptr2; /* Temporary pointer for coefficient buffer */ - q63_t sum0; /* Accumulators */ - uint32_t i, blkCnt, tapCnt; /* Loop counters */ - uint32_t phaseLen = S->phaseLength; /* Length of each polyphase filter component */ - uint32_t j; + q31_t *pState = S->pState; /* State pointer */ + const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q31_t *pStateCur; /* Points to the current sample of the state */ + q31_t *ptr1; /* Temporary pointer for state buffer */ + const q31_t *ptr2; /* Temporary pointer for coefficient buffer */ + q63_t sum0; /* Accumulators */ + uint32_t i, blkCnt, tapCnt; /* Loop counters */ + uint32_t phaseLen = + S->phaseLength; /* Length of each polyphase filter component */ + uint32_t j; -#if defined (ARM_MATH_LOOPUNROLL) - q63_t acc0, acc1, acc2, acc3; - q31_t x0, x1, x2, x3; - q31_t c0, c1, c2, c3; +#if defined(ARM_MATH_LOOPUNROLL) + q63_t acc0, acc1, acc2, acc3; + q31_t x0, x1, x2, x3; + q31_t c0, c1, c2, c3; #endif /* S->pState buffer contains previous frame (phaseLen - 1) samples */ - /* pStateCur points to the location where the new input data should be written */ + /* pStateCur points to the location where the new input data should be written + */ pStateCur = S->pState + (phaseLen - 1U); -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy new input sample into the state buffer */ *pStateCur++ = *pSrc++; *pStateCur++ = *pSrc++; @@ -102,8 +104,7 @@ void arm_fir_interpolate_q31( /* Loop over the Interpolation factor. */ i = (S->L); - while (i > 0U) - { + while (i > 0U) { /* Set accumulator to zero */ acc0 = 0; acc1 = 0; @@ -124,8 +125,7 @@ void arm_fir_interpolate_q31( x1 = *(ptr1++); x2 = *(ptr1++); - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the input sample */ x3 = *(ptr1++); @@ -133,10 +133,10 @@ void arm_fir_interpolate_q31( c0 = *(ptr2); /* Perform the multiply-accumulate */ - acc0 += (q63_t) x0 * c0; - acc1 += (q63_t) x1 * c0; - acc2 += (q63_t) x2 * c0; - acc3 += (q63_t) x3 * c0; + acc0 += (q63_t)x0 * c0; + acc1 += (q63_t)x1 * c0; + acc2 += (q63_t)x2 * c0; + acc3 += (q63_t)x3 * c0; /* Read the coefficient */ c1 = *(ptr2 + S->L); @@ -145,10 +145,10 @@ void arm_fir_interpolate_q31( x0 = *(ptr1++); /* Perform the multiply-accumulate */ - acc0 += (q63_t) x1 * c1; - acc1 += (q63_t) x2 * c1; - acc2 += (q63_t) x3 * c1; - acc3 += (q63_t) x0 * c1; + acc0 += (q63_t)x1 * c1; + acc1 += (q63_t)x2 * c1; + acc2 += (q63_t)x3 * c1; + acc3 += (q63_t)x0 * c1; /* Read the coefficient */ c2 = *(ptr2 + S->L * 2); @@ -157,10 +157,10 @@ void arm_fir_interpolate_q31( x1 = *(ptr1++); /* Perform the multiply-accumulate */ - acc0 += (q63_t) x2 * c2; - acc1 += (q63_t) x3 * c2; - acc2 += (q63_t) x0 * c2; - acc3 += (q63_t) x1 * c2; + acc0 += (q63_t)x2 * c2; + acc1 += (q63_t)x3 * c2; + acc2 += (q63_t)x0 * c2; + acc3 += (q63_t)x1 * c2; /* Read the coefficient */ c3 = *(ptr2 + S->L * 3); @@ -169,11 +169,10 @@ void arm_fir_interpolate_q31( x2 = *(ptr1++); /* Perform the multiply-accumulate */ - acc0 += (q63_t) x3 * c3; - acc1 += (q63_t) x0 * c3; - acc2 += (q63_t) x1 * c3; - acc3 += (q63_t) x2 * c3; - + acc0 += (q63_t)x3 * c3; + acc1 += (q63_t)x0 * c3; + acc2 += (q63_t)x1 * c3; + acc3 += (q63_t)x2 * c3; /* Upsampling is done by stuffing L-1 zeros between each sample. * So instead of multiplying zeros with coefficients, @@ -184,11 +183,11 @@ void arm_fir_interpolate_q31( tapCnt--; } - /* If the polyPhase length is not a multiple of 4, compute the remaining filter taps */ + /* If the polyPhase length is not a multiple of 4, compute the remaining + * filter taps */ tapCnt = phaseLen % 0x4U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the input sample */ x3 = *(ptr1++); @@ -196,10 +195,10 @@ void arm_fir_interpolate_q31( c0 = *(ptr2); /* Perform the multiply-accumulate */ - acc0 += (q63_t) x0 * c0; - acc1 += (q63_t) x1 * c0; - acc2 += (q63_t) x2 * c0; - acc3 += (q63_t) x3 * c0; + acc0 += (q63_t)x0 * c0; + acc1 += (q63_t)x1 * c0; + acc2 += (q63_t)x2 * c0; + acc3 += (q63_t)x3 * c0; /* Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; @@ -214,10 +213,10 @@ void arm_fir_interpolate_q31( } /* The result is in the accumulator, store in the destination buffer. */ - *(pDst ) = (q31_t) (acc0 >> 31); - *(pDst + S->L) = (q31_t) (acc1 >> 31); - *(pDst + 2 * S->L) = (q31_t) (acc2 >> 31); - *(pDst + 3 * S->L) = (q31_t) (acc3 >> 31); + *(pDst) = (q31_t)(acc0 >> 31); + *(pDst + S->L) = (q31_t)(acc1 >> 31); + *(pDst + 2 * S->L) = (q31_t)(acc2 >> 31); + *(pDst + 3 * S->L) = (q31_t)(acc3 >> 31); pDst++; @@ -248,8 +247,7 @@ void arm_fir_interpolate_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy new input sample into the state buffer */ *pStateCur++ = *pSrc++; @@ -258,8 +256,7 @@ void arm_fir_interpolate_q31( /* Loop over the Interpolation factor. */ i = S->L; - while (i > 0U) - { + while (i > 0U) { /* Set accumulator to zero */ sum0 = 0; @@ -272,28 +269,27 @@ void arm_fir_interpolate_q31( /* Loop over the polyPhase length. Repeat until we've computed numTaps-(4*S->L) coefficients. */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) - /* Loop unrolling: Compute 4 outputs at a time */ + /* Loop unrolling: Compute 4 outputs at a time */ tapCnt = phaseLen >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ - sum0 += (q63_t) *ptr1++ * *ptr2; + sum0 += (q63_t)*ptr1++ * *ptr2; /* Upsampling is done by stuffing L-1 zeros between each sample. * So instead of multiplying zeros with coefficients, * Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; - sum0 += (q63_t) *ptr1++ * *ptr2; + sum0 += (q63_t)*ptr1++ * *ptr2; ptr2 += S->L; - sum0 += (q63_t) *ptr1++ * *ptr2; + sum0 += (q63_t)*ptr1++ * *ptr2; ptr2 += S->L; - sum0 += (q63_t) *ptr1++ * *ptr2; + sum0 += (q63_t)*ptr1++ * *ptr2; ptr2 += S->L; /* Decrement loop counter */ @@ -310,10 +306,9 @@ void arm_fir_interpolate_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ - sum0 += (q63_t) *ptr1++ * *ptr2; + sum0 += (q63_t)*ptr1++ * *ptr2; /* Upsampling is done by stuffing L-1 zeros between each sample. * So instead of multiplying zeros with coefficients, @@ -325,7 +320,7 @@ void arm_fir_interpolate_q31( } /* The result is in the accumulator, store in the destination buffer. */ - *pDst++ = (q31_t) (sum0 >> 31); + *pDst++ = (q31_t)(sum0 >> 31); /* Increment the address modifier index of coefficient buffer */ j++; @@ -349,14 +344,13 @@ void arm_fir_interpolate_q31( /* Points to the start of the state buffer */ pStateCur = S->pState; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ tapCnt = (phaseLen - 1U) >> 2U; /* copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; @@ -371,14 +365,13 @@ void arm_fir_interpolate_q31( #else - /* Initialize tapCnt with number of samples */ - tapCnt = (phaseLen - 1U); + /* Initialize tapCnt with number of samples */ + tapCnt = (phaseLen - 1U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ @@ -386,35 +379,35 @@ void arm_fir_interpolate_q31( } #else -/* alternate version for CM0_FAMILY */ + /* alternate version for CM0_FAMILY */ - q31_t *pState = S->pState; /* State pointer */ - const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q31_t *pStateCur; /* Points to the current sample of the state */ - q31_t *ptr1; /* Temporary pointer for state buffer */ - const q31_t *ptr2; /* Temporary pointer for coefficient buffer */ - q63_t sum0; /* Accumulators */ - uint32_t i, blkCnt, tapCnt; /* Loop counters */ - uint32_t phaseLen = S->phaseLength; /* Length of each polyphase filter component */ + q31_t *pState = S->pState; /* State pointer */ + const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q31_t *pStateCur; /* Points to the current sample of the state */ + q31_t *ptr1; /* Temporary pointer for state buffer */ + const q31_t *ptr2; /* Temporary pointer for coefficient buffer */ + q63_t sum0; /* Accumulators */ + uint32_t i, blkCnt, tapCnt; /* Loop counters */ + uint32_t phaseLen = + S->phaseLength; /* Length of each polyphase filter component */ /* S->pState buffer contains previous frame (phaseLen - 1) samples */ - /* pStateCur points to the location where the new input data should be written */ + /* pStateCur points to the location where the new input data should be written + */ pStateCur = S->pState + (phaseLen - 1U); /* Total number of intput samples */ blkCnt = blockSize; /* Loop over the blockSize. */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy new input sample into the state buffer */ *pStateCur++ = *pSrc++; /* Loop over the Interpolation factor. */ i = S->L; - while (i > 0U) - { + while (i > 0U) { /* Set accumulator to zero */ sum0 = 0; @@ -427,10 +420,9 @@ void arm_fir_interpolate_q31( /* Loop over the polyPhase length */ tapCnt = phaseLen; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ - sum0 += ((q63_t) *ptr1++ * *ptr2); + sum0 += ((q63_t)*ptr1++ * *ptr2); /* Increment the coefficient pointer by interpolation factor times. */ ptr2 += S->L; @@ -440,7 +432,7 @@ void arm_fir_interpolate_q31( } /* The result is in the accumulator, store in the destination buffer. */ - *pDst++ = (q31_t) (sum0 >> 31); + *pDst++ = (q31_t)(sum0 >> 31); /* Decrement loop counter */ i--; @@ -464,8 +456,7 @@ void arm_fir_interpolate_q31( tapCnt = phaseLen - 1U; /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ @@ -473,7 +464,6 @@ void arm_fir_interpolate_q31( } #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */ - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_f32.c index a3d95c1..1ff71bc 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_f32.c @@ -37,16 +37,16 @@ This set of functions implements Finite Impulse Response (FIR) lattice filters for Q15, Q31 and floating-point data types. Lattice filters are used in a - variety of adaptive filter applications. The filter structure is feedforward and - the net impulse response is finite length. - The functions operate on blocks + variety of adaptive filter applications. The filter structure is feedforward + and the net impulse response is finite length. The functions operate on blocks of input and output data and each call to the function processes blockSize samples through the filter. pSrc and - pDst point to input and output arrays containing blockSize values. + pDst point to input and output arrays containing + blockSize values. @par Algorithm - \image html FIRLattice.gif "Finite Impulse Response Lattice filter" - The following difference equation is implemented: + \image html FIRLattice.gif "Finite Impulse Response Lattice + filter" The following difference equation is implemented: @par
       f0[n] = g0[n] = x[n]
@@ -55,53 +55,59 @@
       y[n] = fM[n]
   
@par - pCoeffs points to tha array of reflection coefficients of size numStages. - Reflection Coefficients are stored in the following order. + pCoeffs points to tha array of reflection + coefficients of size numStages. Reflection Coefficients are + stored in the following order. @par
       {k1, k2, ..., kM}
   
where M is number of stages @par - pState points to a state array of size numStages. - The state variables (g values) hold previous inputs and are stored in the following order. -
-    {g0[n], g1[n], g2[n] ...gM-1[n]}
+                   pState points to a state array of size
+  numStages. The state variables (g values) hold previous inputs
+  and are stored in the following order. 
 {g0[n], g1[n], g2[n] ...gM-1[n]}
   
- The state variables are updated after each block of data is processed; the coefficients are untouched. + The state variables are updated after each block of data is + processed; the coefficients are untouched. @par Instance Structure - The coefficients and state variables for a filter are stored together in an instance data structure. - A separate instance structure must be defined for each filter. - Coefficient arrays may be shared among several instances while state variable arrays cannot be shared. - There are separate instance structure declarations for each of the 3 supported data types. + The coefficients and state variables for a filter are stored + together in an instance data structure. A separate instance structure must be + defined for each filter. Coefficient arrays may be shared among several + instances while state variable arrays cannot be shared. There are separate + instance structure declarations for each of the 3 supported data types. @par Initialization Functions - There is also an associated initialization function for each data type. - The initialization function performs the following operations: + There is also an associated initialization function for each + data type. The initialization function performs the following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. - To do this manually without calling the init function, assign the follow subfields of the instance structure: - numStages, pCoeffs, pState. Also set all of the values in pState to zero. + To do this manually without calling the init function, assign + the follow subfields of the instance structure: numStages, pCoeffs, pState. + Also set all of the values in pState to zero. @par Use of the initialization function is optional. - However, if the initialization function is used, then the instance structure cannot be placed into a const data section. - To place an instance structure into a const data section, the instance structure must be manually initialized. - Set the values in the state buffer to zeros and then manually initialize the instance structure as follows: -
+                   However, if the initialization function is used, then the
+  instance structure cannot be placed into a const data section. To place an
+  instance structure into a const data section, the instance structure must be
+  manually initialized. Set the values in the state buffer to zeros and then
+  manually initialize the instance structure as follows: 
       arm_fir_lattice_instance_f32 S = {numStages, pState, pCoeffs};
       arm_fir_lattice_instance_q31 S = {numStages, pState, pCoeffs};
       arm_fir_lattice_instance_q15 S = {numStages, pState, pCoeffs};
   
@par - where numStages is the number of stages in the filter; - pState is the address of the state buffer; - pCoeffs is the address of the coefficient buffer. + where numStages is the number of stages in the + filter; pState is the address of the state buffer; + pCoeffs is the address of the coefficient + buffer. @par Fixed-Point Behavior - Care must be taken when using the fixed-point versions of the FIR Lattice filter functions. - In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. - Refer to the function specific documentation below for usage guidelines. + Care must be taken when using the fixed-point versions of the + FIR Lattice filter functions. In particular, the overflow and saturation + behavior of the accumulator used in each function must be considered. Refer to + the function specific documentation below for usage guidelines. */ /** @@ -111,42 +117,42 @@ /** @brief Processing function for the floating-point FIR lattice filter. - @param[in] S points to an instance of the floating-point FIR lattice structure + @param[in] S points to an instance of the floating-point FIR + lattice structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none */ -void arm_fir_lattice_f32( - const arm_fir_lattice_instance_f32 * S, - const float32_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - float32_t *pState = S->pState; /* State pointer */ - const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - float32_t *px; /* Temporary state pointer */ - const float32_t *pk; /* Temporary coefficient pointer */ - uint32_t numStages = S->numStages; /* Number of stages in the filter */ - uint32_t blkCnt, stageCnt; /* Loop counters */ - float32_t fcurr0, fnext0, gnext0, gcurr0; /* Temporary variables */ +void arm_fir_lattice_f32(const arm_fir_lattice_instance_f32 *S, + const float32_t *pSrc, float32_t *pDst, + uint32_t blockSize) { + float32_t *pState = S->pState; /* State pointer */ + const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + float32_t *px; /* Temporary state pointer */ + const float32_t *pk; /* Temporary coefficient pointer */ + uint32_t numStages = S->numStages; /* Number of stages in the filter */ + uint32_t blkCnt, stageCnt; /* Loop counters */ + float32_t fcurr0, fnext0, gnext0, gcurr0; /* Temporary variables */ -#if defined (ARM_MATH_LOOPUNROLL) - float32_t fcurr1, fnext1, gnext1; /* Temporary variables for second sample in loop unrolling */ - float32_t fcurr2, fnext2, gnext2; /* Temporary variables for third sample in loop unrolling */ - float32_t fcurr3, fnext3, gnext3; /* Temporary variables for fourth sample in loop unrolling */ +#if defined(ARM_MATH_LOOPUNROLL) + float32_t fcurr1, fnext1, + gnext1; /* Temporary variables for second sample in loop unrolling */ + float32_t fcurr2, fnext2, + gnext2; /* Temporary variables for third sample in loop unrolling */ + float32_t fcurr3, fnext3, + gnext3; /* Temporary variables for fourth sample in loop unrolling */ #endif gcurr0 = 0.0f; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Read two samples from input buffer */ /* f0(n) = x(n) */ fcurr0 = *pSrc++; @@ -182,7 +188,7 @@ void arm_fir_lattice_f32( gnext2 = (fcurr2 * (*pk)) + fcurr1; /* Process fourth sample for first tap */ - fnext3 = (fcurr2 * (*pk )) + fcurr3; + fnext3 = (fcurr2 * (*pk)) + fcurr3; gnext3 = (fcurr3 * (*pk++)) + fcurr2; /* Copy only last input sample into the state buffer @@ -202,8 +208,7 @@ void arm_fir_lattice_f32( Repeat until we've computed numStages-3 coefficients. */ /* Process 2nd, 3rd, 4th and 5th taps ... here */ - while (stageCnt > 0U) - { + while (stageCnt > 0U) { /* Read g1(n-1), g3(n-1) .... from state */ gcurr0 = *px; @@ -235,7 +240,6 @@ void arm_fir_lattice_f32( gnext0 = (fcurr0 * (*pk++)) + gcurr0; - /* Read g2(n-1), g4(n-1) .... from state */ gcurr0 = *px; @@ -266,7 +270,6 @@ void arm_fir_lattice_f32( gnext0 = (fnext0 * (*pk++)) + gcurr0; - /* Read g1(n-1), g3(n-1) .... from state */ gcurr0 = *px; @@ -298,7 +301,6 @@ void arm_fir_lattice_f32( gnext0 = (fcurr0 * (*pk++)) + gcurr0; - /* Read g2(n-1), g4(n-1) .... from state */ gcurr0 = *px; @@ -332,11 +334,11 @@ void arm_fir_lattice_f32( stageCnt--; } - /* If the (filter length -1) is not a multiple of 4, compute the remaining filter taps */ + /* If the (filter length -1) is not a multiple of 4, compute the remaining + * filter taps */ stageCnt = (numStages - 1U) % 0x4U; - while (stageCnt > 0U) - { + while (stageCnt > 0U) { gcurr0 = *px; /* save g value in state buffer */ @@ -389,8 +391,7 @@ void arm_fir_lattice_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* f0(n) = x(n) */ fcurr0 = *pSrc++; @@ -419,8 +420,7 @@ void arm_fir_lattice_f32( stageCnt = (numStages - 1U); /* stage loop */ - while (stageCnt > 0U) - { + while (stageCnt > 0U) { /* read g2(n) from state buffer */ gcurr0 = *px; @@ -445,7 +445,6 @@ void arm_fir_lattice_f32( blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_init_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_init_f32.c index 7929629..5f3b42e 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_init_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_init_f32.c @@ -38,20 +38,21 @@ */ /** - @brief Initialization function for the floating-point FIR lattice filter. - @param[in] S points to an instance of the floating-point FIR lattice structure + @brief Initialization function for the floating-point FIR lattice + filter. + @param[in] S points to an instance of the floating-point FIR + lattice structure @param[in] numStages number of filter stages - @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages - @param[in] pState points to the state buffer. The array is of length numStages + @param[in] pCoeffs points to the coefficient buffer. The array is of + length numStages + @param[in] pState points to the state buffer. The array is of length + numStages @return none */ -void arm_fir_lattice_init_f32( - arm_fir_lattice_instance_f32 * S, - uint16_t numStages, - const float32_t * pCoeffs, - float32_t * pState) -{ +void arm_fir_lattice_init_f32(arm_fir_lattice_instance_f32 *S, + uint16_t numStages, const float32_t *pCoeffs, + float32_t *pState) { /* Assign filter taps */ S->numStages = numStages; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_init_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_init_q15.c index 5c80dff..1aebcf5 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_init_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_init_q15.c @@ -39,19 +39,19 @@ /** @brief Initialization function for the Q15 FIR lattice filter. - @param[in] S points to an instance of the Q15 FIR lattice structure + @param[in] S points to an instance of the Q15 FIR lattice + structure @param[in] numStages number of filter stages - @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages - @param[in] pState points to the state buffer. The array is of length numStages + @param[in] pCoeffs points to the coefficient buffer. The array is of + length numStages + @param[in] pState points to the state buffer. The array is of length + numStages @return none */ -void arm_fir_lattice_init_q15( - arm_fir_lattice_instance_q15 * S, - uint16_t numStages, - const q15_t * pCoeffs, - q15_t * pState) -{ +void arm_fir_lattice_init_q15(arm_fir_lattice_instance_q15 *S, + uint16_t numStages, const q15_t *pCoeffs, + q15_t *pState) { /* Assign filter taps */ S->numStages = numStages; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_init_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_init_q31.c index 476296d..5862ef5 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_init_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_init_q31.c @@ -39,19 +39,19 @@ /** @brief Initialization function for the Q31 FIR lattice filter. - @param[in] S points to an instance of the Q31 FIR lattice structure + @param[in] S points to an instance of the Q31 FIR lattice + structure @param[in] numStages number of filter stages - @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages - @param[in] pState points to the state buffer. The array is of length numStages + @param[in] pCoeffs points to the coefficient buffer. The array is of + length numStages + @param[in] pState points to the state buffer. The array is of length + numStages @return none */ -void arm_fir_lattice_init_q31( - arm_fir_lattice_instance_q31 * S, - uint16_t numStages, - const q31_t * pCoeffs, - q31_t * pState) -{ +void arm_fir_lattice_init_q31(arm_fir_lattice_instance_q31 *S, + uint16_t numStages, const q31_t *pCoeffs, + q31_t *pState) { /* Assign filter taps */ S->numStages = numStages; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_q15.c index 42e7c0d..dce7bb4 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_q15.c @@ -39,45 +39,44 @@ /** @brief Processing function for Q15 FIR lattice filter. - @param[in] S points to an instance of the Q15 FIR lattice structure + @param[in] S points to an instance of the Q15 FIR lattice + structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none */ -void arm_fir_lattice_q15( - const arm_fir_lattice_instance_q15 * S, - const q15_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - q15_t *pState = S->pState; /* State pointer */ - const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q15_t *px; /* Temporary state pointer */ - const q15_t *pk; /* Temporary coefficient pointer */ - uint32_t numStages = S->numStages; /* Number of stages in the filter */ - uint32_t blkCnt, stageCnt; /* Loop counters */ - q31_t fcurr0, fnext0, gnext0, gcurr0; /* Temporary variables */ +void arm_fir_lattice_q15(const arm_fir_lattice_instance_q15 *S, + const q15_t *pSrc, q15_t *pDst, uint32_t blockSize) { + q15_t *pState = S->pState; /* State pointer */ + const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q15_t *px; /* Temporary state pointer */ + const q15_t *pk; /* Temporary coefficient pointer */ + uint32_t numStages = S->numStages; /* Number of stages in the filter */ + uint32_t blkCnt, stageCnt; /* Loop counters */ + q31_t fcurr0, fnext0, gnext0, gcurr0; /* Temporary variables */ #if (1) -//#if !defined(ARM_MATH_CM0_FAMILY) + //#if !defined(ARM_MATH_CM0_FAMILY) -#if defined (ARM_MATH_LOOPUNROLL) - q31_t fcurr1, fnext1, gnext1; /* Temporary variables for second sample in loop unrolling */ - q31_t fcurr2, fnext2, gnext2; /* Temporary variables for third sample in loop unrolling */ - q31_t fcurr3, fnext3, gnext3; /* Temporary variables for fourth sample in loop unrolling */ +#if defined(ARM_MATH_LOOPUNROLL) + q31_t fcurr1, fnext1, + gnext1; /* Temporary variables for second sample in loop unrolling */ + q31_t fcurr2, fnext2, + gnext2; /* Temporary variables for third sample in loop unrolling */ + q31_t fcurr3, fnext3, + gnext3; /* Temporary variables for fourth sample in loop unrolling */ #endif gcurr0 = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Read two samples from input buffer */ /* f0(n) = x(n) */ fcurr0 = *pSrc++; @@ -94,17 +93,17 @@ void arm_fir_lattice_q15( /* Process first sample for first tap */ /* f1(n) = f0(n) + K1 * g0(n-1) */ - fnext0 = (q31_t) ((gcurr0 * (*pk)) >> 15U) + fcurr0; + fnext0 = (q31_t)((gcurr0 * (*pk)) >> 15U) + fcurr0; fnext0 = __SSAT(fnext0, 16); /* g1(n) = f0(n) * K1 + g0(n-1) */ - gnext0 = (q31_t) ((fcurr0 * (*pk)) >> 15U) + gcurr0; + gnext0 = (q31_t)((fcurr0 * (*pk)) >> 15U) + gcurr0; gnext0 = __SSAT(gnext0, 16); /* Process second sample for first tap */ - fnext1 = (q31_t) ((fcurr0 * (*pk)) >> 15U) + fcurr1; + fnext1 = (q31_t)((fcurr0 * (*pk)) >> 15U) + fcurr1; fnext1 = __SSAT(fnext1, 16); - gnext1 = (q31_t) ((fcurr1 * (*pk)) >> 15U) + fcurr0; + gnext1 = (q31_t)((fcurr1 * (*pk)) >> 15U) + fcurr0; gnext1 = __SSAT(gnext1, 16); /* Read next two samples from input buffer */ @@ -113,20 +112,20 @@ void arm_fir_lattice_q15( fcurr3 = *pSrc++; /* Process third sample for first tap */ - fnext2 = (q31_t) ((fcurr1 * (*pk)) >> 15U) + fcurr2; + fnext2 = (q31_t)((fcurr1 * (*pk)) >> 15U) + fcurr2; fnext2 = __SSAT(fnext2, 16); - gnext2 = (q31_t) ((fcurr2 * (*pk)) >> 15U) + fcurr1; + gnext2 = (q31_t)((fcurr2 * (*pk)) >> 15U) + fcurr1; gnext2 = __SSAT(gnext2, 16); /* Process fourth sample for first tap */ - fnext3 = (q31_t) ((fcurr2 * (*pk )) >> 15U) + fcurr3; + fnext3 = (q31_t)((fcurr2 * (*pk)) >> 15U) + fcurr3; fnext3 = __SSAT(fnext3, 16); - gnext3 = (q31_t) ((fcurr3 * (*pk++)) >> 15U) + fcurr2; + gnext3 = (q31_t)((fcurr3 * (*pk++)) >> 15U) + fcurr2; gnext3 = __SSAT(gnext3, 16); /* Copy only last input sample into the state buffer which will be used for next samples processing */ - *px++ = (q15_t) fcurr3; + *px++ = (q15_t)fcurr3; /* Update of f values for next coefficient set processing */ fcurr0 = fnext0; @@ -141,200 +140,198 @@ void arm_fir_lattice_q15( Repeat until we've computed numStages-3 coefficients. */ /* Process 2nd, 3rd, 4th and 5th taps ... here */ - while (stageCnt > 0U) - { + while (stageCnt > 0U) { /* Read g1(n-1), g3(n-1) .... from state */ gcurr0 = *px; /* save g1(n) in state buffer */ - *px++ = (q15_t) gnext3; + *px++ = (q15_t)gnext3; /* Process first sample for 2nd, 6th .. tap */ /* Sample processing for K2, K6.... */ /* f1(n) = f0(n) + K1 * g0(n-1) */ - fnext0 = (q31_t) ((gcurr0 * (*pk)) >> 15U) + fcurr0; + fnext0 = (q31_t)((gcurr0 * (*pk)) >> 15U) + fcurr0; fnext0 = __SSAT(fnext0, 16); /* Process second sample for 2nd, 6th .. tap */ /* for sample 2 processing */ - fnext1 = (q31_t) ((gnext0 * (*pk)) >> 15U) + fcurr1; + fnext1 = (q31_t)((gnext0 * (*pk)) >> 15U) + fcurr1; fnext1 = __SSAT(fnext1, 16); /* Process third sample for 2nd, 6th .. tap */ - fnext2 = (q31_t) ((gnext1 * (*pk)) >> 15U) + fcurr2; + fnext2 = (q31_t)((gnext1 * (*pk)) >> 15U) + fcurr2; fnext2 = __SSAT(fnext2, 16); /* Process fourth sample for 2nd, 6th .. tap */ - fnext3 = (q31_t) ((gnext2 * (*pk)) >> 15U) + fcurr3; + fnext3 = (q31_t)((gnext2 * (*pk)) >> 15U) + fcurr3; fnext3 = __SSAT(fnext3, 16); /* g1(n) = f0(n) * K1 + g0(n-1) */ /* Calculation of state values for next stage */ - gnext3 = (q31_t) ((fcurr3 * (*pk)) >> 15U) + gnext2; + gnext3 = (q31_t)((fcurr3 * (*pk)) >> 15U) + gnext2; gnext3 = __SSAT(gnext3, 16); - gnext2 = (q31_t) ((fcurr2 * (*pk)) >> 15U) + gnext1; + gnext2 = (q31_t)((fcurr2 * (*pk)) >> 15U) + gnext1; gnext2 = __SSAT(gnext2, 16); - gnext1 = (q31_t) ((fcurr1 * (*pk)) >> 15U) + gnext0; + gnext1 = (q31_t)((fcurr1 * (*pk)) >> 15U) + gnext0; gnext1 = __SSAT(gnext1, 16); - gnext0 = (q31_t) ((fcurr0 * (*pk++)) >> 15U) + gcurr0; + gnext0 = (q31_t)((fcurr0 * (*pk++)) >> 15U) + gcurr0; gnext0 = __SSAT(gnext0, 16); - /* Read g2(n-1), g4(n-1) .... from state */ gcurr0 = *px; /* save g1(n) in state buffer */ - *px++ = (q15_t) gnext3; + *px++ = (q15_t)gnext3; /* Sample processing for K3, K7.... */ /* Process first sample for 3rd, 7th .. tap */ /* f3(n) = f2(n) + K3 * g2(n-1) */ - fcurr0 = (q31_t) ((gcurr0 * (*pk)) >> 15U) + fnext0; + fcurr0 = (q31_t)((gcurr0 * (*pk)) >> 15U) + fnext0; fcurr0 = __SSAT(fcurr0, 16); /* Process second sample for 3rd, 7th .. tap */ - fcurr1 = (q31_t) ((gnext0 * (*pk)) >> 15U) + fnext1; + fcurr1 = (q31_t)((gnext0 * (*pk)) >> 15U) + fnext1; fcurr1 = __SSAT(fcurr1, 16); /* Process third sample for 3rd, 7th .. tap */ - fcurr2 = (q31_t) ((gnext1 * (*pk)) >> 15U) + fnext2; + fcurr2 = (q31_t)((gnext1 * (*pk)) >> 15U) + fnext2; fcurr2 = __SSAT(fcurr2, 16); /* Process fourth sample for 3rd, 7th .. tap */ - fcurr3 = (q31_t) ((gnext2 * (*pk)) >> 15U) + fnext3; + fcurr3 = (q31_t)((gnext2 * (*pk)) >> 15U) + fnext3; fcurr3 = __SSAT(fcurr3, 16); /* Calculation of state values for next stage */ /* g3(n) = f2(n) * K3 + g2(n-1) */ - gnext3 = (q31_t) ((fnext3 * (*pk)) >> 15U) + gnext2; + gnext3 = (q31_t)((fnext3 * (*pk)) >> 15U) + gnext2; gnext3 = __SSAT(gnext3, 16); - gnext2 = (q31_t) ((fnext2 * (*pk)) >> 15U) + gnext1; + gnext2 = (q31_t)((fnext2 * (*pk)) >> 15U) + gnext1; gnext2 = __SSAT(gnext2, 16); - gnext1 = (q31_t) ((fnext1 * (*pk)) >> 15U) + gnext0; + gnext1 = (q31_t)((fnext1 * (*pk)) >> 15U) + gnext0; gnext1 = __SSAT(gnext1, 16); - gnext0 = (q31_t) ((fnext0 * (*pk++)) >> 15U) + gcurr0; + gnext0 = (q31_t)((fnext0 * (*pk++)) >> 15U) + gcurr0; gnext0 = __SSAT(gnext0, 16); /* Read g1(n-1), g3(n-1) .... from state */ gcurr0 = *px; /* save g1(n) in state buffer */ - *px++ = (q15_t) gnext3; + *px++ = (q15_t)gnext3; /* Sample processing for K4, K8.... */ /* Process first sample for 4th, 8th .. tap */ /* f4(n) = f3(n) + K4 * g3(n-1) */ - fnext0 = (q31_t) ((gcurr0 * (*pk)) >> 15U) + fcurr0; + fnext0 = (q31_t)((gcurr0 * (*pk)) >> 15U) + fcurr0; fnext0 = __SSAT(fnext0, 16); /* Process second sample for 4th, 8th .. tap */ /* for sample 2 processing */ - fnext1 = (q31_t) ((gnext0 * (*pk)) >> 15U) + fcurr1; + fnext1 = (q31_t)((gnext0 * (*pk)) >> 15U) + fcurr1; fnext1 = __SSAT(fnext1, 16); /* Process third sample for 4th, 8th .. tap */ - fnext2 = (q31_t) ((gnext1 * (*pk)) >> 15U) + fcurr2; + fnext2 = (q31_t)((gnext1 * (*pk)) >> 15U) + fcurr2; fnext2 = __SSAT(fnext2, 16); /* Process fourth sample for 4th, 8th .. tap */ - fnext3 = (q31_t) ((gnext2 * (*pk)) >> 15U) + fcurr3; + fnext3 = (q31_t)((gnext2 * (*pk)) >> 15U) + fcurr3; fnext3 = __SSAT(fnext3, 16); /* g4(n) = f3(n) * K4 + g3(n-1) */ /* Calculation of state values for next stage */ - gnext3 = (q31_t) ((fcurr3 * (*pk)) >> 15U) + gnext2; + gnext3 = (q31_t)((fcurr3 * (*pk)) >> 15U) + gnext2; gnext3 = __SSAT(gnext3, 16); - gnext2 = (q31_t) ((fcurr2 * (*pk)) >> 15U) + gnext1; + gnext2 = (q31_t)((fcurr2 * (*pk)) >> 15U) + gnext1; gnext2 = __SSAT(gnext2, 16); - gnext1 = (q31_t) ((fcurr1 * (*pk)) >> 15U) + gnext0; + gnext1 = (q31_t)((fcurr1 * (*pk)) >> 15U) + gnext0; gnext1 = __SSAT(gnext1, 16); - gnext0 = (q31_t) ((fcurr0 * (*pk++)) >> 15U) + gcurr0; + gnext0 = (q31_t)((fcurr0 * (*pk++)) >> 15U) + gcurr0; gnext0 = __SSAT(gnext0, 16); /* Read g2(n-1), g4(n-1) .... from state */ gcurr0 = *px; /* save g4(n) in state buffer */ - *px++ = (q15_t) gnext3; + *px++ = (q15_t)gnext3; /* Sample processing for K5, K9.... */ /* Process first sample for 5th, 9th .. tap */ /* f5(n) = f4(n) + K5 * g4(n-1) */ - fcurr0 = (q31_t) ((gcurr0 * (*pk)) >> 15U) + fnext0; + fcurr0 = (q31_t)((gcurr0 * (*pk)) >> 15U) + fnext0; fcurr0 = __SSAT(fcurr0, 16); /* Process second sample for 5th, 9th .. tap */ - fcurr1 = (q31_t) ((gnext0 * (*pk)) >> 15U) + fnext1; + fcurr1 = (q31_t)((gnext0 * (*pk)) >> 15U) + fnext1; fcurr1 = __SSAT(fcurr1, 16); /* Process third sample for 5th, 9th .. tap */ - fcurr2 = (q31_t) ((gnext1 * (*pk)) >> 15U) + fnext2; + fcurr2 = (q31_t)((gnext1 * (*pk)) >> 15U) + fnext2; fcurr2 = __SSAT(fcurr2, 16); /* Process fourth sample for 5th, 9th .. tap */ - fcurr3 = (q31_t) ((gnext2 * (*pk)) >> 15U) + fnext3; + fcurr3 = (q31_t)((gnext2 * (*pk)) >> 15U) + fnext3; fcurr3 = __SSAT(fcurr3, 16); /* Calculation of state values for next stage */ /* g5(n) = f4(n) * K5 + g4(n-1) */ - gnext3 = (q31_t) ((fnext3 * (*pk)) >> 15U) + gnext2; + gnext3 = (q31_t)((fnext3 * (*pk)) >> 15U) + gnext2; gnext3 = __SSAT(gnext3, 16); - gnext2 = (q31_t) ((fnext2 * (*pk)) >> 15U) + gnext1; + gnext2 = (q31_t)((fnext2 * (*pk)) >> 15U) + gnext1; gnext2 = __SSAT(gnext2, 16); - gnext1 = (q31_t) ((fnext1 * (*pk)) >> 15U) + gnext0; + gnext1 = (q31_t)((fnext1 * (*pk)) >> 15U) + gnext0; gnext1 = __SSAT(gnext1, 16); - gnext0 = (q31_t) ((fnext0 * (*pk++)) >> 15U) + gcurr0; + gnext0 = (q31_t)((fnext0 * (*pk++)) >> 15U) + gcurr0; gnext0 = __SSAT(gnext0, 16); stageCnt--; } - /* If the (filter length -1) is not a multiple of 4, compute the remaining filter taps */ + /* If the (filter length -1) is not a multiple of 4, compute the remaining + * filter taps */ stageCnt = (numStages - 1U) % 0x4U; - while (stageCnt > 0U) - { + while (stageCnt > 0U) { gcurr0 = *px; /* save g value in state buffer */ - *px++ = (q15_t) gnext3; + *px++ = (q15_t)gnext3; /* Process four samples for last three taps here */ - fnext0 = (q31_t) ((gcurr0 * (*pk)) >> 15U) + fcurr0; + fnext0 = (q31_t)((gcurr0 * (*pk)) >> 15U) + fcurr0; fnext0 = __SSAT(fnext0, 16); - fnext1 = (q31_t) ((gnext0 * (*pk)) >> 15U) + fcurr1; + fnext1 = (q31_t)((gnext0 * (*pk)) >> 15U) + fcurr1; fnext1 = __SSAT(fnext1, 16); - fnext2 = (q31_t) ((gnext1 * (*pk)) >> 15U) + fcurr2; + fnext2 = (q31_t)((gnext1 * (*pk)) >> 15U) + fcurr2; fnext2 = __SSAT(fnext2, 16); - fnext3 = (q31_t) ((gnext2 * (*pk)) >> 15U) + fcurr3; + fnext3 = (q31_t)((gnext2 * (*pk)) >> 15U) + fcurr3; fnext3 = __SSAT(fnext3, 16); /* g1(n) = f0(n) * K1 + g0(n-1) */ - gnext3 = (q31_t) ((fcurr3 * (*pk)) >> 15U) + gnext2; + gnext3 = (q31_t)((fcurr3 * (*pk)) >> 15U) + gnext2; gnext3 = __SSAT(gnext3, 16); - gnext2 = (q31_t) ((fcurr2 * (*pk)) >> 15U) + gnext1; + gnext2 = (q31_t)((fcurr2 * (*pk)) >> 15U) + gnext1; gnext2 = __SSAT(gnext2, 16); - gnext1 = (q31_t) ((fcurr1 * (*pk)) >> 15U) + gnext0; + gnext1 = (q31_t)((fcurr1 * (*pk)) >> 15U) + gnext0; gnext1 = __SSAT(gnext1, 16); - gnext0 = (q31_t) ((fcurr0 * (*pk++)) >> 15U) + gcurr0; + gnext0 = (q31_t)((fcurr0 * (*pk++)) >> 15U) + gcurr0; gnext0 = __SSAT(gnext0, 16); /* Update of f values for next coefficient set processing */ @@ -349,12 +346,12 @@ void arm_fir_lattice_q15( /* The results in the 4 accumulators, store in the destination buffer. */ /* y(n) = fN(n) */ -#ifndef ARM_MATH_BIG_ENDIAN - write_q15x2_ia (&pDst, __PKHBT(fcurr0, fcurr1, 16)); - write_q15x2_ia (&pDst, __PKHBT(fcurr2, fcurr3, 16)); +#ifndef ARM_MATH_BIG_ENDIAN + write_q15x2_ia(&pDst, __PKHBT(fcurr0, fcurr1, 16)); + write_q15x2_ia(&pDst, __PKHBT(fcurr2, fcurr3, 16)); #else - write_q15x2_ia (&pDst, __PKHBT(fcurr1, fcurr0, 16)); - write_q15x2_ia (&pDst, __PKHBT(fcurr3, fcurr2, 16)); + write_q15x2_ia(&pDst, __PKHBT(fcurr1, fcurr0, 16)); + write_q15x2_ia(&pDst, __PKHBT(fcurr3, fcurr2, 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ blkCnt--; @@ -370,8 +367,7 @@ void arm_fir_lattice_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* f0(n) = x(n) */ fcurr0 = *pSrc++; @@ -386,15 +382,15 @@ void arm_fir_lattice_q15( /* for sample 1 processing */ /* f1(n) = f0(n) + K1 * g0(n-1) */ - fnext0 = (((q31_t) gcurr0 * (*pk)) >> 15U) + fcurr0; + fnext0 = (((q31_t)gcurr0 * (*pk)) >> 15U) + fcurr0; fnext0 = __SSAT(fnext0, 16); /* g1(n) = f0(n) * K1 + g0(n-1) */ - gnext0 = (((q31_t) fcurr0 * (*pk++)) >> 15U) + gcurr0; + gnext0 = (((q31_t)fcurr0 * (*pk++)) >> 15U) + gcurr0; gnext0 = __SSAT(gnext0, 16); /* save g1(n) in state buffer */ - *px++ = (q15_t) fcurr0; + *px++ = (q15_t)fcurr0; /* f1(n) is saved in fcurr0 for next stage processing */ fcurr0 = fnext0; @@ -402,21 +398,20 @@ void arm_fir_lattice_q15( stageCnt = (numStages - 1U); /* stage loop */ - while (stageCnt > 0U) - { + while (stageCnt > 0U) { /* read g2(n) from state buffer */ gcurr0 = *px; /* save g1(n) in state buffer */ - *px++ = (q15_t) gnext0; + *px++ = (q15_t)gnext0; /* Sample processing for K2, K3.... */ /* f2(n) = f1(n) + K2 * g1(n-1) */ - fnext0 = (((q31_t) gcurr0 * (*pk)) >> 15U) + fcurr0; + fnext0 = (((q31_t)gcurr0 * (*pk)) >> 15U) + fcurr0; fnext0 = __SSAT(fnext0, 16); /* g2(n) = f1(n) * K2 + g1(n-1) */ - gnext0 = (((q31_t) fcurr0 * (*pk++)) >> 15U) + gcurr0; + gnext0 = (((q31_t)fcurr0 * (*pk++)) >> 15U) + gcurr0; gnext0 = __SSAT(gnext0, 16); /* f1(n) is saved in fcurr0 for next stage processing */ @@ -432,12 +427,11 @@ void arm_fir_lattice_q15( } #else -/* alternate version for CM0_FAMILY */ + /* alternate version for CM0_FAMILY */ blkCnt = blockSize; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* f0(n) = x(n) */ fcurr0 = *pSrc++; @@ -460,7 +454,7 @@ void arm_fir_lattice_q15( gnext0 = __SSAT(gnext0, 16); /* save f0(n) in state buffer */ - *px++ = (q15_t) fcurr0; + *px++ = (q15_t)fcurr0; /* f1(n) is saved in fcurr for next stage processing */ fcurr0 = fnext0; @@ -468,13 +462,12 @@ void arm_fir_lattice_q15( stageCnt = (numStages - 1U); /* stage loop */ - while (stageCnt > 0U) - { + while (stageCnt > 0U) { /* read g1(n-1) from state buffer */ gcurr0 = *px; /* save g0(n-1) in state buffer */ - *px++ = (q15_t) gnext0; + *px++ = (q15_t)gnext0; /* Sample processing for K2, K3.... */ /* f2(n) = f1(n) + K2 * g1(n-1) */ @@ -498,7 +491,6 @@ void arm_fir_lattice_q15( } #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */ - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_q31.c index c8d28d7..b4d2fb2 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_lattice_q31.c @@ -39,48 +39,48 @@ /** @brief Processing function for the Q31 FIR lattice filter. - @param[in] S points to an instance of the Q31 FIR lattice structure + @param[in] S points to an instance of the Q31 FIR lattice + structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior - In order to avoid overflows the input signal must be scaled down by 2*log2(numStages) bits. + In order to avoid overflows the input signal must be scaled + down by 2*log2(numStages) bits. */ -void arm_fir_lattice_q31( - const arm_fir_lattice_instance_q31 * S, - const q31_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - q31_t *pState = S->pState; /* State pointer */ - const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q31_t *px; /* Temporary state pointer */ - const q31_t *pk; /* Temporary coefficient pointer */ - uint32_t numStages = S->numStages; /* Number of stages in the filter */ - uint32_t blkCnt, stageCnt; /* Loop counters */ - q31_t fcurr0, fnext0, gnext0, gcurr0; /* Temporary variables */ +void arm_fir_lattice_q31(const arm_fir_lattice_instance_q31 *S, + const q31_t *pSrc, q31_t *pDst, uint32_t blockSize) { + q31_t *pState = S->pState; /* State pointer */ + const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q31_t *px; /* Temporary state pointer */ + const q31_t *pk; /* Temporary coefficient pointer */ + uint32_t numStages = S->numStages; /* Number of stages in the filter */ + uint32_t blkCnt, stageCnt; /* Loop counters */ + q31_t fcurr0, fnext0, gnext0, gcurr0; /* Temporary variables */ #if (1) -//#if !defined(ARM_MATH_CM0_FAMILY) + //#if !defined(ARM_MATH_CM0_FAMILY) -#if defined (ARM_MATH_LOOPUNROLL) - q31_t fcurr1, fnext1, gnext1; /* Temporary variables for second sample in loop unrolling */ - q31_t fcurr2, fnext2, gnext2; /* Temporary variables for third sample in loop unrolling */ - q31_t fcurr3, fnext3, gnext3; /* Temporary variables for fourth sample in loop unrolling */ +#if defined(ARM_MATH_LOOPUNROLL) + q31_t fcurr1, fnext1, + gnext1; /* Temporary variables for second sample in loop unrolling */ + q31_t fcurr2, fnext2, + gnext2; /* Temporary variables for third sample in loop unrolling */ + q31_t fcurr3, fnext3, + gnext3; /* Temporary variables for fourth sample in loop unrolling */ #endif gcurr0 = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Read two samples from input buffer */ /* f0(n) = x(n) */ fcurr0 = *pSrc++; @@ -97,17 +97,17 @@ void arm_fir_lattice_q31( /* Process first sample for first tap */ /* f1(n) = f0(n) + K1 * g0(n-1) */ - fnext0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); + fnext0 = (q31_t)(((q63_t)gcurr0 * (*pk)) >> 32U); fnext0 = (fnext0 << 1U) + fcurr0; /* g1(n) = f0(n) * K1 + g0(n-1) */ - gnext0 = (q31_t) (((q63_t) fcurr0 * (*pk)) >> 32U); + gnext0 = (q31_t)(((q63_t)fcurr0 * (*pk)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; /* Process second sample for first tap */ - fnext1 = (q31_t) (((q63_t) fcurr0 * (*pk)) >> 32U); + fnext1 = (q31_t)(((q63_t)fcurr0 * (*pk)) >> 32U); fnext1 = (fnext1 << 1U) + fcurr1; - gnext1 = (q31_t) (((q63_t) fcurr1 * (*pk)) >> 32U); + gnext1 = (q31_t)(((q63_t)fcurr1 * (*pk)) >> 32U); gnext1 = (gnext1 << 1U) + fcurr0; /* Read next two samples from input buffer */ @@ -116,15 +116,15 @@ void arm_fir_lattice_q31( fcurr3 = *pSrc++; /* Process third sample for first tap */ - fnext2 = (q31_t) (((q63_t) fcurr1 * (*pk)) >> 32U); + fnext2 = (q31_t)(((q63_t)fcurr1 * (*pk)) >> 32U); fnext2 = (fnext2 << 1U) + fcurr2; - gnext2 = (q31_t) (((q63_t) fcurr2 * (*pk)) >> 32U); + gnext2 = (q31_t)(((q63_t)fcurr2 * (*pk)) >> 32U); gnext2 = (gnext2 << 1U) + fcurr1; /* Process fourth sample for first tap */ - fnext3 = (q31_t) (((q63_t) fcurr2 * (*pk )) >> 32U); + fnext3 = (q31_t)(((q63_t)fcurr2 * (*pk)) >> 32U); fnext3 = (fnext3 << 1U) + fcurr3; - gnext3 = (q31_t) (((q63_t) fcurr3 * (*pk++)) >> 32U); + gnext3 = (q31_t)(((q63_t)fcurr3 * (*pk++)) >> 32U); gnext3 = (gnext3 << 1U) + fcurr2; /* Copy only last input sample into the state buffer @@ -144,8 +144,7 @@ void arm_fir_lattice_q31( Repeat until we've computed numStages-3 coefficients. */ /* Process 2nd, 3rd, 4th and 5th taps ... here */ - while (stageCnt > 0U) - { + while (stageCnt > 0U) { /* Read g1(n-1), g3(n-1) .... from state */ gcurr0 = *px; @@ -155,37 +154,36 @@ void arm_fir_lattice_q31( /* Process first sample for 2nd, 6th .. tap */ /* Sample processing for K2, K6.... */ /* f1(n) = f0(n) + K1 * g0(n-1) */ - fnext0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); + fnext0 = (q31_t)(((q63_t)gcurr0 * (*pk)) >> 32U); fnext0 = (fnext0 << 1U) + fcurr0; /* Process second sample for 2nd, 6th .. tap */ /* for sample 2 processing */ - fnext1 = (q31_t) (((q63_t) gnext0 * (*pk)) >> 32U); + fnext1 = (q31_t)(((q63_t)gnext0 * (*pk)) >> 32U); fnext1 = (fnext1 << 1U) + fcurr1; /* Process third sample for 2nd, 6th .. tap */ - fnext2 = (q31_t) (((q63_t) gnext1 * (*pk)) >> 32U); + fnext2 = (q31_t)(((q63_t)gnext1 * (*pk)) >> 32U); fnext2 = (fnext2 << 1U) + fcurr2; /* Process fourth sample for 2nd, 6th .. tap */ - fnext3 = (q31_t) (((q63_t) gnext2 * (*pk)) >> 32U); + fnext3 = (q31_t)(((q63_t)gnext2 * (*pk)) >> 32U); fnext3 = (fnext3 << 1U) + fcurr3; /* g1(n) = f0(n) * K1 + g0(n-1) */ /* Calculation of state values for next stage */ - gnext3 = (q31_t) (((q63_t) fcurr3 * (*pk)) >> 32U); + gnext3 = (q31_t)(((q63_t)fcurr3 * (*pk)) >> 32U); gnext3 = (gnext3 << 1U) + gnext2; - gnext2 = (q31_t) (((q63_t) fcurr2 * (*pk)) >> 32U); + gnext2 = (q31_t)(((q63_t)fcurr2 * (*pk)) >> 32U); gnext2 = (gnext2 << 1U) + gnext1; - gnext1 = (q31_t) (((q63_t) fcurr1 * (*pk)) >> 32U); + gnext1 = (q31_t)(((q63_t)fcurr1 * (*pk)) >> 32U); gnext1 = (gnext1 << 1U) + gnext0; - gnext0 = (q31_t) (((q63_t) fcurr0 * (*pk++)) >> 32U); + gnext0 = (q31_t)(((q63_t)fcurr0 * (*pk++)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; - /* Read g2(n-1), g4(n-1) .... from state */ gcurr0 = *px; @@ -195,33 +193,33 @@ void arm_fir_lattice_q31( /* Sample processing for K3, K7.... */ /* Process first sample for 3rd, 7th .. tap */ /* f3(n) = f2(n) + K3 * g2(n-1) */ - fcurr0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); + fcurr0 = (q31_t)(((q63_t)gcurr0 * (*pk)) >> 32U); fcurr0 = (fcurr0 << 1U) + fnext0; /* Process second sample for 3rd, 7th .. tap */ - fcurr1 = (q31_t) (((q63_t) gnext0 * (*pk)) >> 32U); + fcurr1 = (q31_t)(((q63_t)gnext0 * (*pk)) >> 32U); fcurr1 = (fcurr1 << 1U) + fnext1; /* Process third sample for 3rd, 7th .. tap */ - fcurr2 = (q31_t) (((q63_t) gnext1 * (*pk)) >> 32U); + fcurr2 = (q31_t)(((q63_t)gnext1 * (*pk)) >> 32U); fcurr2 = (fcurr2 << 1U) + fnext2; /* Process fourth sample for 3rd, 7th .. tap */ - fcurr3 = (q31_t) (((q63_t) gnext2 * (*pk)) >> 32U); + fcurr3 = (q31_t)(((q63_t)gnext2 * (*pk)) >> 32U); fcurr3 = (fcurr3 << 1U) + fnext3; /* Calculation of state values for next stage */ /* g3(n) = f2(n) * K3 + g2(n-1) */ - gnext3 = (q31_t) (((q63_t) fnext3 * (*pk)) >> 32U); + gnext3 = (q31_t)(((q63_t)fnext3 * (*pk)) >> 32U); gnext3 = (gnext3 << 1U) + gnext2; - gnext2 = (q31_t) (((q63_t) fnext2 * (*pk)) >> 32U); + gnext2 = (q31_t)(((q63_t)fnext2 * (*pk)) >> 32U); gnext2 = (gnext2 << 1U) + gnext1; - gnext1 = (q31_t) (((q63_t) fnext1 * (*pk)) >> 32U); + gnext1 = (q31_t)(((q63_t)fnext1 * (*pk)) >> 32U); gnext1 = (gnext1 << 1U) + gnext0; - gnext0 = (q31_t) (((q63_t) fnext0 * (*pk++)) >> 32U); + gnext0 = (q31_t)(((q63_t)fnext0 * (*pk++)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; /* Read g1(n-1), g3(n-1) .... from state */ @@ -233,34 +231,34 @@ void arm_fir_lattice_q31( /* Sample processing for K4, K8.... */ /* Process first sample for 4th, 8th .. tap */ /* f4(n) = f3(n) + K4 * g3(n-1) */ - fnext0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); + fnext0 = (q31_t)(((q63_t)gcurr0 * (*pk)) >> 32U); fnext0 = (fnext0 << 1U) + fcurr0; /* Process second sample for 4th, 8th .. tap */ /* for sample 2 processing */ - fnext1 = (q31_t) (((q63_t) gnext0 * (*pk)) >> 32U); + fnext1 = (q31_t)(((q63_t)gnext0 * (*pk)) >> 32U); fnext1 = (fnext1 << 1U) + fcurr1; /* Process third sample for 4th, 8th .. tap */ - fnext2 = (q31_t) (((q63_t) gnext1 * (*pk)) >> 32U); + fnext2 = (q31_t)(((q63_t)gnext1 * (*pk)) >> 32U); fnext2 = (fnext2 << 1U) + fcurr2; /* Process fourth sample for 4th, 8th .. tap */ - fnext3 = (q31_t) (((q63_t) gnext2 * (*pk)) >> 32U); + fnext3 = (q31_t)(((q63_t)gnext2 * (*pk)) >> 32U); fnext3 = (fnext3 << 1U) + fcurr3; /* g4(n) = f3(n) * K4 + g3(n-1) */ /* Calculation of state values for next stage */ - gnext3 = (q31_t) (((q63_t) fcurr3 * (*pk)) >> 32U); + gnext3 = (q31_t)(((q63_t)fcurr3 * (*pk)) >> 32U); gnext3 = (gnext3 << 1U) + gnext2; - gnext2 = (q31_t) (((q63_t) fcurr2 * (*pk)) >> 32U); + gnext2 = (q31_t)(((q63_t)fcurr2 * (*pk)) >> 32U); gnext2 = (gnext2 << 1U) + gnext1; - gnext1 = (q31_t) (((q63_t) fcurr1 * (*pk)) >> 32U); + gnext1 = (q31_t)(((q63_t)fcurr1 * (*pk)) >> 32U); gnext1 = (gnext1 << 1U) + gnext0; - gnext0 = (q31_t) (((q63_t) fcurr0 * (*pk++)) >> 32U); + gnext0 = (q31_t)(((q63_t)fcurr0 * (*pk++)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; /* Read g2(n-1), g4(n-1) .... from state */ @@ -272,72 +270,72 @@ void arm_fir_lattice_q31( /* Sample processing for K5, K9.... */ /* Process first sample for 5th, 9th .. tap */ /* f5(n) = f4(n) + K5 * g4(n-1) */ - fcurr0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); + fcurr0 = (q31_t)(((q63_t)gcurr0 * (*pk)) >> 32U); fcurr0 = (fcurr0 << 1U) + fnext0; /* Process second sample for 5th, 9th .. tap */ - fcurr1 = (q31_t) (((q63_t) gnext0 * (*pk)) >> 32U); + fcurr1 = (q31_t)(((q63_t)gnext0 * (*pk)) >> 32U); fcurr1 = (fcurr1 << 1U) + fnext1; /* Process third sample for 5th, 9th .. tap */ - fcurr2 = (q31_t) (((q63_t) gnext1 * (*pk)) >> 32U); + fcurr2 = (q31_t)(((q63_t)gnext1 * (*pk)) >> 32U); fcurr2 = (fcurr2 << 1U) + fnext2; /* Process fourth sample for 5th, 9th .. tap */ - fcurr3 = (q31_t) (((q63_t) gnext2 * (*pk)) >> 32U); + fcurr3 = (q31_t)(((q63_t)gnext2 * (*pk)) >> 32U); fcurr3 = (fcurr3 << 1U) + fnext3; /* Calculation of state values for next stage */ /* g5(n) = f4(n) * K5 + g4(n-1) */ - gnext3 = (q31_t) (((q63_t) fnext3 * (*pk)) >> 32U); + gnext3 = (q31_t)(((q63_t)fnext3 * (*pk)) >> 32U); gnext3 = (gnext3 << 1U) + gnext2; - gnext2 = (q31_t) (((q63_t) fnext2 * (*pk)) >> 32U); + gnext2 = (q31_t)(((q63_t)fnext2 * (*pk)) >> 32U); gnext2 = (gnext2 << 1U) + gnext1; - gnext1 = (q31_t) (((q63_t) fnext1 * (*pk)) >> 32U); + gnext1 = (q31_t)(((q63_t)fnext1 * (*pk)) >> 32U); gnext1 = (gnext1 << 1U) + gnext0; - gnext0 = (q31_t) (((q63_t) fnext0 * (*pk++)) >> 32U); + gnext0 = (q31_t)(((q63_t)fnext0 * (*pk++)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; stageCnt--; } - /* If the (filter length -1) is not a multiple of 4, compute the remaining filter taps */ + /* If the (filter length -1) is not a multiple of 4, compute the remaining + * filter taps */ stageCnt = (numStages - 1U) % 0x4U; - while (stageCnt > 0U) - { + while (stageCnt > 0U) { gcurr0 = *px; /* save g value in state buffer */ *px++ = gnext3; /* Process four samples for last three taps here */ - fnext0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); + fnext0 = (q31_t)(((q63_t)gcurr0 * (*pk)) >> 32U); fnext0 = (fnext0 << 1U) + fcurr0; - fnext1 = (q31_t) (((q63_t) gnext0 * (*pk)) >> 32U); + fnext1 = (q31_t)(((q63_t)gnext0 * (*pk)) >> 32U); fnext1 = (fnext1 << 1U) + fcurr1; - fnext2 = (q31_t) (((q63_t) gnext1 * (*pk)) >> 32U); + fnext2 = (q31_t)(((q63_t)gnext1 * (*pk)) >> 32U); fnext2 = (fnext2 << 1U) + fcurr2; - fnext3 = (q31_t) (((q63_t) gnext2 * (*pk)) >> 32U); + fnext3 = (q31_t)(((q63_t)gnext2 * (*pk)) >> 32U); fnext3 = (fnext3 << 1U) + fcurr3; /* g1(n) = f0(n) * K1 + g0(n-1) */ - gnext3 = (q31_t) (((q63_t) fcurr3 * (*pk)) >> 32U); + gnext3 = (q31_t)(((q63_t)fcurr3 * (*pk)) >> 32U); gnext3 = (gnext3 << 1U) + gnext2; - gnext2 = (q31_t) (((q63_t) fcurr2 * (*pk)) >> 32U); + gnext2 = (q31_t)(((q63_t)fcurr2 * (*pk)) >> 32U); gnext2 = (gnext2 << 1U) + gnext1; - gnext1 = (q31_t) (((q63_t) fcurr1 * (*pk)) >> 32U); + gnext1 = (q31_t)(((q63_t)fcurr1 * (*pk)) >> 32U); gnext1 = (gnext1 << 1U) + gnext0; - gnext0 = (q31_t) (((q63_t) fcurr0 * (*pk++)) >> 32U); + gnext0 = (q31_t)(((q63_t)fcurr0 * (*pk++)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; /* Update of f values for next coefficient set processing */ @@ -369,8 +367,7 @@ void arm_fir_lattice_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* f0(n) = x(n) */ fcurr0 = *pSrc++; @@ -385,11 +382,11 @@ void arm_fir_lattice_q31( /* for sample 1 processing */ /* f1(n) = f0(n) + K1 * g0(n-1) */ - fnext0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); + fnext0 = (q31_t)(((q63_t)gcurr0 * (*pk)) >> 32U); fnext0 = (fnext0 << 1U) + fcurr0; /* g1(n) = f0(n) * K1 + g0(n-1) */ - gnext0 = (q31_t) (((q63_t) fcurr0 * (*pk++)) >> 32U); + gnext0 = (q31_t)(((q63_t)fcurr0 * (*pk++)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; /* save g1(n) in state buffer */ @@ -401,8 +398,7 @@ void arm_fir_lattice_q31( stageCnt = (numStages - 1U); /* stage loop */ - while (stageCnt > 0U) - { + while (stageCnt > 0U) { /* read g2(n) from state buffer */ gcurr0 = *px; @@ -411,11 +407,11 @@ void arm_fir_lattice_q31( /* Sample processing for K2, K3.... */ /* f2(n) = f1(n) + K2 * g1(n-1) */ - fnext0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); + fnext0 = (q31_t)(((q63_t)gcurr0 * (*pk)) >> 32U); fnext0 = (fnext0 << 1U) + fcurr0; /* g2(n) = f1(n) * K2 + g1(n-1) */ - gnext0 = (q31_t) (((q63_t) fcurr0 * (*pk++)) >> 32U); + gnext0 = (q31_t)(((q63_t)fcurr0 * (*pk++)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; /* f1(n) is saved in fcurr0 for next stage processing */ @@ -431,12 +427,11 @@ void arm_fir_lattice_q31( } #else -/* alternate version for CM0_FAMILY */ + /* alternate version for CM0_FAMILY */ blkCnt = blockSize; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* f0(n) = x(n) */ fcurr0 = *pSrc++; @@ -451,11 +446,11 @@ void arm_fir_lattice_q31( /* for sample 1 processing */ /* f1(n) = f0(n) + K1 * g0(n-1) */ - fnext0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); + fnext0 = (q31_t)(((q63_t)gcurr0 * (*pk)) >> 32U); fnext0 = (fnext << 1U) + fcurr0; /* g1(n) = f0(n) * K1 + g0(n-1) */ - gnext0 = (q31_t) (((q63_t) fcurr0 * (*pk++)) >> 32U); + gnext0 = (q31_t)(((q63_t)fcurr0 * (*pk++)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; /* save f0(n) in state buffer */ @@ -467,8 +462,7 @@ void arm_fir_lattice_q31( stageCnt = (numStages - 1U); /* stage loop */ - while (stageCnt > 0U) - { + while (stageCnt > 0U) { /* read g1(n-1) from state buffer */ gcurr0 = *px; @@ -477,11 +471,11 @@ void arm_fir_lattice_q31( /* Sample processing for K2, K3.... */ /* f2(n) = f1(n) + K2 * g1(n-1) */ - fnext0 = (q31_t) (((q63_t) gcurr0 * (*pk)) >> 32U); + fnext0 = (q31_t)(((q63_t)gcurr0 * (*pk)) >> 32U); fnext0 = (fnext0 << 1U) + fcurr0; /* g2(n) = f1(n) * K2 + g1(n-1) */ - gnext0 = (q31_t) (((q63_t) fcurr0 * (*pk++)) >> 32U); + gnext0 = (q31_t)(((q63_t)fcurr0 * (*pk++)) >> 32U); gnext0 = (gnext0 << 1U) + gcurr0; /* f1(n) is saved in fcurr0 for next stage processing */ @@ -497,7 +491,6 @@ void arm_fir_lattice_q31( } #endif /* #if !defined(ARM_MATH_CM0_FAMILY) */ - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_q15.c index e20798e..57b8ff3 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_q15.c @@ -39,62 +39,68 @@ /** @brief Processing function for the Q15 FIR filter. - @param[in] S points to an instance of the Q15 FIR filter structure + @param[in] S points to an instance of the Q15 FIR filter + structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior - The function is implemented using a 64-bit internal accumulator. - Both coefficients and state variables are represented in 1.15 format and multiplications yield a 2.30 result. - The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. - There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. - After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits. - Lastly, the accumulator is saturated to yield a result in 1.15 format. + The function is implemented using a 64-bit internal + accumulator. Both coefficients and state variables are represented in 1.15 + format and multiplications yield a 2.30 result. The 2.30 intermediate results + are accumulated in a 64-bit accumulator in 34.30 format. There is no risk of + internal overflow with this approach and the full precision of intermediate + multiplications is preserved. After all additions have been performed, the + accumulator is truncated to 34.15 format by discarding low 15 bits. Lastly, + the accumulator is saturated to yield a result in 1.15 format. @remark - Refer to \ref arm_fir_fast_q15() for a faster but less precise implementation of this function. + Refer to \ref arm_fir_fast_q15() for a faster but less + precise implementation of this function. */ -void arm_fir_q15( - const arm_fir_instance_q15 * S, - const q15_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - q15_t *pState = S->pState; /* State pointer */ - const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q15_t *pStateCurnt; /* Points to the current sample of the state */ - q15_t *px; /* Temporary pointer for state buffer */ - const q15_t *pb; /* Temporary pointer for coefficient buffer */ - q63_t acc0; /* Accumulators */ - uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ - uint32_t tapCnt, blkCnt; /* Loop counters */ +void arm_fir_q15(const arm_fir_instance_q15 *S, const q15_t *pSrc, q15_t *pDst, + uint32_t blockSize) { + q15_t *pState = S->pState; /* State pointer */ + const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q15_t *pStateCurnt; /* Points to the current sample of the state */ + q15_t *px; /* Temporary pointer for state buffer */ + const q15_t *pb; /* Temporary pointer for coefficient buffer */ + q63_t acc0; /* Accumulators */ + uint32_t numTaps = + S->numTaps; /* Number of filter coefficients in the filter */ + uint32_t tapCnt, blkCnt; /* Loop counters */ -#if defined (ARM_MATH_LOOPUNROLL) - q63_t acc1, acc2, acc3; /* Accumulators */ - q31_t x0, x1, x2, c0; /* Temporary variables to hold state and coefficient values */ +#if defined(ARM_MATH_LOOPUNROLL) + q63_t acc1, acc2, acc3; /* Accumulators */ + q31_t x0, x1, x2, + c0; /* Temporary variables to hold state and coefficient values */ #endif - /* S->pState points to state array which contains previous frame (numTaps - 1) samples */ - /* pStateCurnt points to the location where the new input data should be written */ + /* S->pState points to state array which contains previous frame (numTaps - 1) + * samples */ + /* pStateCurnt points to the location where the new input data should be + * written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 output values simultaneously. * The variables acc0 ... acc3 hold output values that are being computed: * - * acc0 = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] - * acc1 = b[numTaps-1] * x[n-numTaps] + b[numTaps-2] * x[n-numTaps-1] + b[numTaps-3] * x[n-numTaps-2] +...+ b[0] * x[1] - * acc2 = b[numTaps-1] * x[n-numTaps+1] + b[numTaps-2] * x[n-numTaps] + b[numTaps-3] * x[n-numTaps-1] +...+ b[0] * x[2] - * acc3 = b[numTaps-1] * x[n-numTaps+2] + b[numTaps-2] * x[n-numTaps+1] + b[numTaps-3] * x[n-numTaps] +...+ b[0] * x[3] + * acc0 = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + + * b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] acc1 = b[numTaps-1] * + * x[n-numTaps] + b[numTaps-2] * x[n-numTaps-1] + b[numTaps-3] * + * x[n-numTaps-2] +...+ b[0] * x[1] acc2 = b[numTaps-1] * x[n-numTaps+1] + + * b[numTaps-2] * x[n-numTaps] + b[numTaps-3] * x[n-numTaps-1] +...+ b[0] * + * x[2] acc3 = b[numTaps-1] * x[n-numTaps+2] + b[numTaps-2] * x[n-numTaps+1] + * + b[numTaps-3] * x[n-numTaps] +...+ b[0] * x[3] */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy 4 new input samples into the state buffer. */ *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; @@ -110,23 +116,25 @@ void arm_fir_q15( /* Typecast q15_t pointer to q31_t pointer for state reading in q31_t */ px = pState; - /* Typecast q15_t pointer to q31_t pointer for coefficient reading in q31_t */ + /* Typecast q15_t pointer to q31_t pointer for coefficient reading in q31_t + */ pb = pCoeffs; /* Read the first two samples from the state buffer: x[n-N], x[n-N-1] */ - x0 = read_q15x2_ia (&px); + x0 = read_q15x2_ia(&px); - /* Read the third and forth samples from the state buffer: x[n-N-2], x[n-N-3] */ - x2 = read_q15x2_ia (&px); + /* Read the third and forth samples from the state buffer: x[n-N-2], + * x[n-N-3] */ + x2 = read_q15x2_ia(&px); /* Loop over the number of taps. Unroll by a factor of 4. Repeat until we've computed numTaps-(numTaps%4) coefficients. */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { - /* Read the first two coefficients using SIMD: b[N] and b[N-1] coefficients */ - c0 = read_q15x2_ia ((q15_t **) &pb); + while (tapCnt > 0U) { + /* Read the first two coefficients using SIMD: b[N] and b[N-1] + * coefficients */ + c0 = read_q15x2_ia((q15_t **)&pb); /* acc0 += b[N] * x[n-N] + b[N-1] * x[n-N-1] */ acc0 = __SMLALD(x0, c0, acc0); @@ -142,7 +150,7 @@ void arm_fir_q15( #endif /* Read state x[n-N-4], x[n-N-5] */ - x0 = read_q15x2_ia (&px); + x0 = read_q15x2_ia(&px); /* acc1 += b[N] * x[n-N-1] + b[N-1] * x[n-N-2] */ acc1 = __SMLALDX(x1, c0, acc1); @@ -158,13 +166,13 @@ void arm_fir_q15( acc3 = __SMLALDX(x1, c0, acc3); /* Read coefficients b[N-2], b[N-3] */ - c0 = read_q15x2_ia ((q15_t **) &pb); + c0 = read_q15x2_ia((q15_t **)&pb); /* acc0 += b[N-2] * x[n-N-2] + b[N-3] * x[n-N-3] */ acc0 = __SMLALD(x2, c0, acc0); /* Read state x[n-N-6], x[n-N-7] with offset */ - x2 = read_q15x2_ia (&px); + x2 = read_q15x2_ia(&px); /* acc2 += b[N-2] * x[n-N-4] + b[N-3] * x[n-N-5] */ acc2 = __SMLALD(x0, c0, acc2); @@ -186,12 +194,11 @@ void arm_fir_q15( tapCnt--; } - /* If the filter length is not a multiple of 4, compute the remaining filter taps. - This is always be 2 taps since the filter length is even. */ - if ((numTaps & 0x3U) != 0U) - { + /* If the filter length is not a multiple of 4, compute the remaining filter + taps. This is always be 2 taps since the filter length is even. */ + if ((numTaps & 0x3U) != 0U) { /* Read last two coefficients */ - c0 = read_q15x2_ia ((q15_t **) &pb); + c0 = read_q15x2_ia((q15_t **)&pb); /* Perform the multiply-accumulates */ acc0 = __SMLALD(x0, c0, acc0); @@ -205,7 +212,7 @@ void arm_fir_q15( #endif /* Read last state variables */ - x0 = read_q15x2 (px); + x0 = read_q15x2(px); /* Perform the multiply-accumulates */ acc1 = __SMLALDX(x1, c0, acc1); @@ -221,14 +228,18 @@ void arm_fir_q15( acc3 = __SMLALDX(x1, c0, acc3); } - /* The results in the 4 accumulators are in 2.30 format. Convert to 1.15 with saturation. - Then store the 4 outputs in the destination buffer. */ + /* The results in the 4 accumulators are in 2.30 format. Convert to 1.15 + with saturation. Then store the 4 outputs in the destination buffer. */ #ifndef ARM_MATH_BIG_ENDIAN - write_q15x2_ia (&pDst, __PKHBT(__SSAT((acc0 >> 15), 16), __SSAT((acc1 >> 15), 16), 16)); - write_q15x2_ia (&pDst, __PKHBT(__SSAT((acc2 >> 15), 16), __SSAT((acc3 >> 15), 16), 16)); + write_q15x2_ia( + &pDst, __PKHBT(__SSAT((acc0 >> 15), 16), __SSAT((acc1 >> 15), 16), 16)); + write_q15x2_ia( + &pDst, __PKHBT(__SSAT((acc2 >> 15), 16), __SSAT((acc3 >> 15), 16), 16)); #else - write_q15x2_ia (&pDst, __PKHBT(__SSAT((acc1 >> 15), 16), __SSAT((acc0 >> 15), 16), 16)); - write_q15x2_ia (&pDst, __PKHBT(__SSAT((acc3 >> 15), 16), __SSAT((acc2 >> 15), 16), 16)); + write_q15x2_ia( + &pDst, __PKHBT(__SSAT((acc1 >> 15), 16), __SSAT((acc0 >> 15), 16), 16)); + write_q15x2_ia( + &pDst, __PKHBT(__SSAT((acc3 >> 15), 16), __SSAT((acc2 >> 15), 16), 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Advance the state pointer by 4 to process the next group of 4 samples */ @@ -248,8 +259,7 @@ void arm_fir_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy two samples into state buffer */ *pStateCurnt++ = *pSrc++; @@ -262,18 +272,16 @@ void arm_fir_q15( tapCnt = numTaps >> 1U; - do - { - acc0 += (q31_t) *px++ * *pb++; - acc0 += (q31_t) *px++ * *pb++; + do { + acc0 += (q31_t)*px++ * *pb++; + acc0 += (q31_t)*px++ * *pb++; tapCnt--; - } - while (tapCnt > 0U); + } while (tapCnt > 0U); /* The result is in 2.30 format. Convert to 1.15 with saturation. Then store the output in the destination buffer. */ - *pDst++ = (q15_t) (__SSAT((acc0 >> 15), 16)); + *pDst++ = (q15_t)(__SSAT((acc0 >> 15), 16)); /* Advance state pointer by 1 for the next sample */ pState = pState + 1U; @@ -289,14 +297,13 @@ void arm_fir_q15( /* Points to the start of the state buffer */ pStateCurnt = S->pState; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = (numTaps - 1U) >> 2U; /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; @@ -317,14 +324,12 @@ void arm_fir_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy remaining data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_q31.c index c57371b..19a167a 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_q31.c @@ -39,63 +39,69 @@ /** @brief Processing function for Q31 FIR filter. - @param[in] S points to an instance of the Q31 FIR filter structure + @param[in] S points to an instance of the Q31 FIR filter + structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior - The function is implemented using an internal 64-bit accumulator. - The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. - Thus, if the accumulator result overflows it wraps around rather than clip. - In order to avoid overflows completely the input signal must be scaled down by log2(numTaps) bits. - After all multiply-accumulates are performed, the 2.62 accumulator is right shifted by 31 bits and saturated to 1.31 format to yield the final result. + The function is implemented using an internal 64-bit + accumulator. The accumulator has a 2.62 format and maintains full precision of + the intermediate multiplication results but provides only a single guard bit. + Thus, if the accumulator result overflows it wraps around + rather than clip. In order to avoid overflows completely the input signal must + be scaled down by log2(numTaps) bits. After all multiply-accumulates are + performed, the 2.62 accumulator is right shifted by 31 bits and saturated + to 1.31 format to yield the final result. @remark - Refer to \ref arm_fir_fast_q31() for a faster but less precise implementation of this filter. + Refer to \ref arm_fir_fast_q31() for a faster but less + precise implementation of this filter. */ -void arm_fir_q31( - const arm_fir_instance_q31 * S, - const q31_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - q31_t *pState = S->pState; /* State pointer */ - const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q31_t *pStateCurnt; /* Points to the current sample of the state */ - q31_t *px; /* Temporary pointer for state buffer */ - const q31_t *pb; /* Temporary pointer for coefficient buffer */ - q63_t acc0; /* Accumulator */ - uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ - uint32_t i, tapCnt, blkCnt; /* Loop counters */ +void arm_fir_q31(const arm_fir_instance_q31 *S, const q31_t *pSrc, q31_t *pDst, + uint32_t blockSize) { + q31_t *pState = S->pState; /* State pointer */ + const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q31_t *pStateCurnt; /* Points to the current sample of the state */ + q31_t *px; /* Temporary pointer for state buffer */ + const q31_t *pb; /* Temporary pointer for coefficient buffer */ + q63_t acc0; /* Accumulator */ + uint32_t numTaps = + S->numTaps; /* Number of filter coefficients in the filter */ + uint32_t i, tapCnt, blkCnt; /* Loop counters */ -#if defined (ARM_MATH_LOOPUNROLL) - q63_t acc1, acc2; /* Accumulators */ - q31_t x0, x1, x2; /* Temporary variables to hold state values */ - q31_t c0; /* Temporary variable to hold coefficient value */ +#if defined(ARM_MATH_LOOPUNROLL) + q63_t acc1, acc2; /* Accumulators */ + q31_t x0, x1, x2; /* Temporary variables to hold state values */ + q31_t c0; /* Temporary variable to hold coefficient value */ #endif - /* S->pState points to state array which contains previous frame (numTaps - 1) samples */ - /* pStateCurnt points to the location where the new input data should be written */ + /* S->pState points to state array which contains previous frame (numTaps - 1) + * samples */ + /* pStateCurnt points to the location where the new input data should be + * written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 output values simultaneously. * The variables acc0 ... acc3 hold output values that are being computed: * - * acc0 = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] - * acc1 = b[numTaps-1] * x[n-numTaps] + b[numTaps-2] * x[n-numTaps-1] + b[numTaps-3] * x[n-numTaps-2] +...+ b[0] * x[1] - * acc2 = b[numTaps-1] * x[n-numTaps+1] + b[numTaps-2] * x[n-numTaps] + b[numTaps-3] * x[n-numTaps-1] +...+ b[0] * x[2] - * acc3 = b[numTaps-1] * x[n-numTaps+2] + b[numTaps-2] * x[n-numTaps+1] + b[numTaps-3] * x[n-numTaps] +...+ b[0] * x[3] + * acc0 = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + + * b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] acc1 = b[numTaps-1] * + * x[n-numTaps] + b[numTaps-2] * x[n-numTaps-1] + b[numTaps-3] * + * x[n-numTaps-2] +...+ b[0] * x[1] acc2 = b[numTaps-1] * x[n-numTaps+1] + + * b[numTaps-2] * x[n-numTaps] + b[numTaps-3] * x[n-numTaps-1] +...+ b[0] * + * x[2] acc3 = b[numTaps-1] * x[n-numTaps+2] + b[numTaps-2] * x[n-numTaps+1] + * + b[numTaps-3] * x[n-numTaps] +...+ b[0] * x[3] */ blkCnt = blockSize / 3; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy 3 new input samples into the state buffer. */ *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; @@ -112,15 +118,15 @@ void arm_fir_q31( /* Initialize coefficient pointer */ pb = pCoeffs; - /* Read the first 2 samples from the state buffer: x[n-numTaps], x[n-numTaps-1] */ + /* Read the first 2 samples from the state buffer: x[n-numTaps], + * x[n-numTaps-1] */ x0 = *px++; x1 = *px++; /* Loop unrolling: process 3 taps at a time. */ tapCnt = numTaps / 3; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the b[numTaps] coefficient */ c0 = *pb; @@ -128,18 +134,18 @@ void arm_fir_q31( x2 = *(px++); /* Perform the multiply-accumulates */ - acc0 += ((q63_t) x0 * c0); - acc1 += ((q63_t) x1 * c0); - acc2 += ((q63_t) x2 * c0); + acc0 += ((q63_t)x0 * c0); + acc1 += ((q63_t)x1 * c0); + acc2 += ((q63_t)x2 * c0); /* Read the coefficient and state */ c0 = *(pb + 1U); x0 = *(px++); /* Perform the multiply-accumulates */ - acc0 += ((q63_t) x1 * c0); - acc1 += ((q63_t) x2 * c0); - acc2 += ((q63_t) x0 * c0); + acc0 += ((q63_t)x1 * c0); + acc1 += ((q63_t)x2 * c0); + acc2 += ((q63_t)x0 * c0); /* Read the coefficient and state */ c0 = *(pb + 2U); @@ -149,9 +155,9 @@ void arm_fir_q31( pb += 3U; /* Perform the multiply-accumulates */ - acc0 += ((q63_t) x2 * c0); - acc1 += ((q63_t) x0 * c0); - acc2 += ((q63_t) x1 * c0); + acc0 += ((q63_t)x2 * c0); + acc1 += ((q63_t)x0 * c0); + acc2 += ((q63_t)x1 * c0); /* Decrement loop counter */ tapCnt--; @@ -160,8 +166,7 @@ void arm_fir_q31( /* Loop unrolling: Compute remaining outputs */ tapCnt = numTaps % 0x3U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read coefficients */ c0 = *(pb++); @@ -169,9 +174,9 @@ void arm_fir_q31( x2 = *(px++); /* Perform the multiply-accumulates */ - acc0 += ((q63_t) x0 * c0); - acc1 += ((q63_t) x1 * c0); - acc2 += ((q63_t) x2 * c0); + acc0 += ((q63_t)x0 * c0); + acc1 += ((q63_t)x1 * c0); + acc2 += ((q63_t)x2 * c0); /* Reuse the present sample states for next sample */ x0 = x1; @@ -184,10 +189,11 @@ void arm_fir_q31( /* Advance the state pointer by 3 to process the next group of 3 samples */ pState = pState + 3; - /* The result is in 2.30 format. Convert to 1.31 and store in destination buffer. */ - *pDst++ = (q31_t) (acc0 >> 31U); - *pDst++ = (q31_t) (acc1 >> 31U); - *pDst++ = (q31_t) (acc2 >> 31U); + /* The result is in 2.30 format. Convert to 1.31 and store in destination + * buffer. */ + *pDst++ = (q31_t)(acc0 >> 31U); + *pDst++ = (q31_t)(acc1 >> 31U); + *pDst++ = (q31_t)(acc2 >> 31U); /* Decrement loop counter */ blkCnt--; @@ -203,8 +209,7 @@ void arm_fir_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy one sample at a time into state buffer */ *pStateCurnt++ = *pSrc++; @@ -220,16 +225,17 @@ void arm_fir_q31( i = numTaps; /* Perform the multiply-accumulates */ - do - { - /* acc = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] */ - acc0 += (q63_t) *px++ * *pb++; + do { + /* acc = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + + * b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] */ + acc0 += (q63_t)*px++ * *pb++; i--; } while (i > 0U); - /* Result is in 2.62 format. Convert to 1.31 and store in destination buffer. */ - *pDst++ = (q31_t) (acc0 >> 31U); + /* Result is in 2.62 format. Convert to 1.31 and store in destination + * buffer. */ + *pDst++ = (q31_t)(acc0 >> 31U); /* Advance state pointer by 1 for the next sample */ pState = pState + 1U; @@ -245,14 +251,13 @@ void arm_fir_q31( /* Points to the start of the state buffer */ pStateCurnt = S->pState; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = (numTaps - 1U) >> 2U; /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; @@ -273,14 +278,12 @@ void arm_fir_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy remaining data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_q7.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_q7.c index 5f6d354..cbf4658 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_q7.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_q7.c @@ -46,52 +46,54 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using a 32-bit internal accumulator. - Both coefficients and state variables are represented in 1.7 format and multiplications yield a 2.14 result. - The 2.14 intermediate results are accumulated in a 32-bit accumulator in 18.14 format. - There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. - The accumulator is converted to 18.7 format by discarding the low 7 bits. - Finally, the result is truncated to 1.7 format. + The function is implemented using a 32-bit internal + accumulator. Both coefficients and state variables are represented in 1.7 + format and multiplications yield a 2.14 result. The 2.14 intermediate results + are accumulated in a 32-bit accumulator in 18.14 format. There is no risk of + internal overflow with this approach and the full precision of intermediate + multiplications is preserved. The accumulator is converted to 18.7 format by + discarding the low 7 bits. Finally, the result is truncated to 1.7 format. */ -void arm_fir_q7( - const arm_fir_instance_q7 * S, - const q7_t * pSrc, - q7_t * pDst, - uint32_t blockSize) -{ - q7_t *pState = S->pState; /* State pointer */ - const q7_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q7_t *pStateCurnt; /* Points to the current sample of the state */ - q7_t *px; /* Temporary pointer for state buffer */ - const q7_t *pb; /* Temporary pointer for coefficient buffer */ - q31_t acc0; /* Accumulators */ - uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ - uint32_t i, tapCnt, blkCnt; /* Loop counters */ +void arm_fir_q7(const arm_fir_instance_q7 *S, const q7_t *pSrc, q7_t *pDst, + uint32_t blockSize) { + q7_t *pState = S->pState; /* State pointer */ + const q7_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q7_t *pStateCurnt; /* Points to the current sample of the state */ + q7_t *px; /* Temporary pointer for state buffer */ + const q7_t *pb; /* Temporary pointer for coefficient buffer */ + q31_t acc0; /* Accumulators */ + uint32_t numTaps = + S->numTaps; /* Number of filter coefficients in the filter */ + uint32_t i, tapCnt, blkCnt; /* Loop counters */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t acc1, acc2, acc3; /* Accumulators */ - q7_t x0, x1, x2, x3, c0; /* Temporary variables to hold state */ +#if defined(ARM_MATH_LOOPUNROLL) + q31_t acc1, acc2, acc3; /* Accumulators */ + q7_t x0, x1, x2, x3, c0; /* Temporary variables to hold state */ #endif - /* S->pState points to state array which contains previous frame (numTaps - 1) samples */ - /* pStateCurnt points to the location where the new input data should be written */ + /* S->pState points to state array which contains previous frame (numTaps - 1) + * samples */ + /* pStateCurnt points to the location where the new input data should be + * written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 output values simultaneously. * The variables acc0 ... acc3 hold output values that are being computed: * - * acc0 = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] - * acc1 = b[numTaps-1] * x[n-numTaps] + b[numTaps-2] * x[n-numTaps-1] + b[numTaps-3] * x[n-numTaps-2] +...+ b[0] * x[1] - * acc2 = b[numTaps-1] * x[n-numTaps+1] + b[numTaps-2] * x[n-numTaps] + b[numTaps-3] * x[n-numTaps-1] +...+ b[0] * x[2] - * acc3 = b[numTaps-1] * x[n-numTaps+2] + b[numTaps-2] * x[n-numTaps+1] + b[numTaps-3] * x[n-numTaps] +...+ b[0] * x[3] + * acc0 = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + + * b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] acc1 = b[numTaps-1] * + * x[n-numTaps] + b[numTaps-2] * x[n-numTaps-1] + b[numTaps-3] * + * x[n-numTaps-2] +...+ b[0] * x[1] acc2 = b[numTaps-1] * x[n-numTaps+1] + + * b[numTaps-2] * x[n-numTaps] + b[numTaps-3] * x[n-numTaps-1] +...+ b[0] * + * x[2] acc3 = b[numTaps-1] * x[n-numTaps+2] + b[numTaps-2] * x[n-numTaps+1] + * + b[numTaps-3] * x[n-numTaps] +...+ b[0] * x[3] */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy 4 new input samples into the state buffer. */ *pStateCurnt++ = *pSrc++; *pStateCurnt++ = *pSrc++; @@ -121,8 +123,7 @@ void arm_fir_q7( /* Loop over the number of taps. Unroll by a factor of 4. Repeat until we've computed numTaps-4 coefficients. */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read the b[numTaps] coefficient */ c0 = *pb; @@ -130,16 +131,16 @@ void arm_fir_q7( x3 = *px; /* acc0 += b[numTaps] * x[n-numTaps] */ - acc0 += ((q15_t) x0 * c0); + acc0 += ((q15_t)x0 * c0); /* acc1 += b[numTaps] * x[n-numTaps-1] */ - acc1 += ((q15_t) x1 * c0); + acc1 += ((q15_t)x1 * c0); /* acc2 += b[numTaps] * x[n-numTaps-2] */ - acc2 += ((q15_t) x2 * c0); + acc2 += ((q15_t)x2 * c0); /* acc3 += b[numTaps] * x[n-numTaps-3] */ - acc3 += ((q15_t) x3 * c0); + acc3 += ((q15_t)x3 * c0); /* Read the b[numTaps-1] coefficient */ c0 = *(pb + 1U); @@ -148,10 +149,10 @@ void arm_fir_q7( x0 = *(px + 1U); /* Perform the multiply-accumulates */ - acc0 += ((q15_t) x1 * c0); - acc1 += ((q15_t) x2 * c0); - acc2 += ((q15_t) x3 * c0); - acc3 += ((q15_t) x0 * c0); + acc0 += ((q15_t)x1 * c0); + acc1 += ((q15_t)x2 * c0); + acc2 += ((q15_t)x3 * c0); + acc3 += ((q15_t)x0 * c0); /* Read the b[numTaps-2] coefficient */ c0 = *(pb + 2U); @@ -160,10 +161,10 @@ void arm_fir_q7( x1 = *(px + 2U); /* Perform the multiply-accumulates */ - acc0 += ((q15_t) x2 * c0); - acc1 += ((q15_t) x3 * c0); - acc2 += ((q15_t) x0 * c0); - acc3 += ((q15_t) x1 * c0); + acc0 += ((q15_t)x2 * c0); + acc1 += ((q15_t)x3 * c0); + acc2 += ((q15_t)x0 * c0); + acc3 += ((q15_t)x1 * c0); /* Read the b[numTaps-3] coefficients */ c0 = *(pb + 3U); @@ -172,10 +173,10 @@ void arm_fir_q7( x2 = *(px + 3U); /* Perform the multiply-accumulates */ - acc0 += ((q15_t) x3 * c0); - acc1 += ((q15_t) x0 * c0); - acc2 += ((q15_t) x1 * c0); - acc3 += ((q15_t) x2 * c0); + acc0 += ((q15_t)x3 * c0); + acc1 += ((q15_t)x0 * c0); + acc2 += ((q15_t)x1 * c0); + acc3 += ((q15_t)x2 * c0); /* update coefficient pointer */ pb += 4U; @@ -185,11 +186,11 @@ void arm_fir_q7( tapCnt--; } - /* If the filter length is not a multiple of 4, compute the remaining filter taps */ + /* If the filter length is not a multiple of 4, compute the remaining filter + * taps */ tapCnt = numTaps % 0x4U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read coefficients */ c0 = *(pb++); @@ -197,10 +198,10 @@ void arm_fir_q7( x3 = *(px++); /* Perform the multiply-accumulates */ - acc0 += ((q15_t) x0 * c0); - acc1 += ((q15_t) x1 * c0); - acc2 += ((q15_t) x2 * c0); - acc3 += ((q15_t) x3 * c0); + acc0 += ((q15_t)x0 * c0); + acc1 += ((q15_t)x1 * c0); + acc2 += ((q15_t)x2 * c0); + acc3 += ((q15_t)x3 * c0); /* Reuse the present sample states for next sample */ x0 = x1; @@ -239,8 +240,7 @@ void arm_fir_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy one sample at a time into state buffer */ *pStateCurnt++ = *pSrc++; @@ -256,8 +256,7 @@ void arm_fir_q7( i = numTaps; /* Perform the multiply-accumulates */ - do - { + do { acc0 += (q15_t) * (px++) * (*(pb++)); i--; } while (i > 0U); @@ -280,14 +279,13 @@ void arm_fir_q7( /* Points to the start of the state buffer */ pStateCurnt = S->pState; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time */ tapCnt = (numTaps - 1U) >> 2U; /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; @@ -308,14 +306,12 @@ void arm_fir_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ /* Copy remaining data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement the loop counter */ tapCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_f32.c index f44f037..0343280 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_f32.c @@ -36,60 +36,73 @@ @defgroup FIR_Sparse Finite Impulse Response (FIR) Sparse Filters This group of functions implements sparse FIR filters. - Sparse FIR filters are equivalent to standard FIR filters except that most of the coefficients are equal to zero. - Sparse filters are used for simulating reflections in communications and audio applications. + Sparse FIR filters are equivalent to standard FIR filters except that most of + the coefficients are equal to zero. Sparse filters are used for simulating + reflections in communications and audio applications. There are separate functions for Q7, Q15, Q31, and floating-point data types. - The functions operate on blocks of input and output data and each call to the function processes - blockSize samples through the filter. pSrc and - pDst points to input and output arrays respectively containing blockSize values. + The functions operate on blocks of input and output data and each call to the + function processes blockSize samples through the filter. + pSrc and pDst points to input and output arrays + respectively containing blockSize values. @par Algorithm - The sparse filter instant structure contains an array of tap indices pTapDelay which specifies the locations of the non-zero coefficients. - This is in addition to the coefficient array b. - The implementation essentially skips the multiplications by zero and leads to an efficient realization. -
-      y[n] = b[0] * x[n-pTapDelay[0]] + b[1] * x[n-pTapDelay[1]] + b[2] * x[n-pTapDelay[2]] + ...+ b[numTaps-1] * x[n-pTapDelay[numTaps-1]]
+                   The sparse filter instant structure contains an array of tap
+  indices pTapDelay which specifies the locations of the non-zero
+  coefficients. This is in addition to the coefficient array b. The
+  implementation essentially skips the multiplications by zero and leads to an
+  efficient realization. 
 y[n] = b[0] * x[n-pTapDelay[0]] + b[1] *
+  x[n-pTapDelay[1]] + b[2] * x[n-pTapDelay[2]] + ...+ b[numTaps-1] *
+  x[n-pTapDelay[numTaps-1]]
   
@par - \image html FIRSparse.gif "Sparse FIR filter. b[n] represents the filter coefficients" + \image html FIRSparse.gif "Sparse FIR filter. b[n] + represents the filter coefficients" @par - pCoeffs points to a coefficient array of size numTaps; - pTapDelay points to an array of nonzero indices and is also of size numTaps; - pState points to a state array of size maxDelay + blockSize, where - maxDelay is the largest offset value that is ever used in the pTapDelay array. - Some of the processing functions also require temporary working buffers. + pCoeffs points to a coefficient array of size + numTaps; pTapDelay points to an array of nonzero + indices and is also of size numTaps; pState points + to a state array of size maxDelay + blockSize, where + maxDelay is the largest offset value that is + ever used in the pTapDelay array. Some of the processing + functions also require temporary working buffers. @par Instance Structure - The coefficients and state variables for a filter are stored together in an instance data structure. - A separate instance structure must be defined for each filter. - Coefficient and offset arrays may be shared among several instances while state variable arrays cannot be shared. - There are separate instance structure declarations for each of the 4 supported data types. + The coefficients and state variables for a filter are stored + together in an instance data structure. A separate instance structure must be + defined for each filter. Coefficient and offset arrays may be shared among + several instances while state variable arrays cannot be shared. There are + separate instance structure declarations for each of the 4 supported data + types. @par Initialization Functions - There is also an associated initialization function for each data type. - The initialization function performs the following operations: + There is also an associated initialization function for each + data type. The initialization function performs the following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. - To do this manually without calling the init function, assign the follow subfields of the instance structure: - numTaps, pCoeffs, pTapDelay, maxDelay, stateIndex, pState. Also set all of the values in pState to zero. + To do this manually without calling the init function, assign + the follow subfields of the instance structure: numTaps, pCoeffs, pTapDelay, + maxDelay, stateIndex, pState. Also set all of the values in pState to zero. @par Use of the initialization function is optional. - However, if the initialization function is used, then the instance structure cannot be placed into a const data section. - To place an instance structure into a const data section, the instance structure must be manually initialized. - Set the values in the state buffer to zeros before static initialization. - The code below statically initializes each of the 4 different data type filter instance structures -
-      arm_fir_sparse_instance_f32 S = {numTaps, 0, pState, pCoeffs, maxDelay, pTapDelay};
-      arm_fir_sparse_instance_q31 S = {numTaps, 0, pState, pCoeffs, maxDelay, pTapDelay};
-      arm_fir_sparse_instance_q15 S = {numTaps, 0, pState, pCoeffs, maxDelay, pTapDelay};
-      arm_fir_sparse_instance_q7 S =  {numTaps, 0, pState, pCoeffs, maxDelay, pTapDelay};
+                   However, if the initialization function is used, then the
+  instance structure cannot be placed into a const data section. To place an
+  instance structure into a const data section, the instance structure must be
+  manually initialized. Set the values in the state buffer to zeros before
+  static initialization. The code below statically initializes each of the 4
+  different data type filter instance structures 
+      arm_fir_sparse_instance_f32 S = {numTaps, 0, pState, pCoeffs, maxDelay,
+  pTapDelay}; arm_fir_sparse_instance_q31 S = {numTaps, 0, pState, pCoeffs,
+  maxDelay, pTapDelay}; arm_fir_sparse_instance_q15 S = {numTaps, 0, pState,
+  pCoeffs, maxDelay, pTapDelay}; arm_fir_sparse_instance_q7 S =  {numTaps, 0,
+  pState, pCoeffs, maxDelay, pTapDelay};
   
@par Fixed-Point Behavior - Care must be taken when using the fixed-point versions of the sparse FIR filter functions. - In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. - Refer to the function specific documentation below for usage guidelines. + Care must be taken when using the fixed-point versions of the + sparse FIR filter functions. In particular, the overflow and saturation + behavior of the accumulator used in each function must be considered. Refer to + the function specific documentation below for usage guidelines. */ /** @@ -99,7 +112,8 @@ /** @brief Processing function for the floating-point sparse FIR filter. - @param[in] S points to an instance of the floating-point sparse FIR structure + @param[in] S points to an instance of the floating-point sparse + FIR structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] pScratchIn points to a temporary buffer of size blockSize @@ -107,46 +121,43 @@ @return none */ -void arm_fir_sparse_f32( - arm_fir_sparse_instance_f32 * S, - const float32_t * pSrc, - float32_t * pDst, - float32_t * pScratchIn, - uint32_t blockSize) -{ - float32_t *pState = S->pState; /* State pointer */ - const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - float32_t *px; /* Scratch buffer pointer */ - float32_t *py = pState; /* Temporary pointers for state buffer */ - float32_t *pb = pScratchIn; /* Temporary pointers for scratch buffer */ - float32_t *pOut; /* Destination pointer */ - int32_t *pTapDelay = S->pTapDelay; /* Pointer to the array containing offset of the non-zero tap values. */ - uint32_t delaySize = S->maxDelay + blockSize; /* state length */ - uint16_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ - int32_t readIndex; /* Read index of the state buffer */ - uint32_t tapCnt, blkCnt; /* loop counters */ - float32_t coeff = *pCoeffs++; /* Read the first coefficient value */ - +void arm_fir_sparse_f32(arm_fir_sparse_instance_f32 *S, const float32_t *pSrc, + float32_t *pDst, float32_t *pScratchIn, + uint32_t blockSize) { + float32_t *pState = S->pState; /* State pointer */ + const float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + float32_t *px; /* Scratch buffer pointer */ + float32_t *py = pState; /* Temporary pointers for state buffer */ + float32_t *pb = pScratchIn; /* Temporary pointers for scratch buffer */ + float32_t *pOut; /* Destination pointer */ + int32_t *pTapDelay = S->pTapDelay; /* Pointer to the array containing offset + of the non-zero tap values. */ + uint32_t delaySize = S->maxDelay + blockSize; /* state length */ + uint16_t numTaps = + S->numTaps; /* Number of filter coefficients in the filter */ + int32_t readIndex; /* Read index of the state buffer */ + uint32_t tapCnt, blkCnt; /* loop counters */ + float32_t coeff = *pCoeffs++; /* Read the first coefficient value */ /* BlockSize of Input samples are copied into the state buffer */ /* StateIndex points to the starting position to write in the state buffer */ - arm_circularWrite_f32((int32_t *) py, delaySize, &S->stateIndex, 1, (int32_t *) pSrc, 1, blockSize); + arm_circularWrite_f32((int32_t *)py, delaySize, &S->stateIndex, 1, + (int32_t *)pSrc, 1, blockSize); /* Read Index, from where the state buffer should be read, is calculated. */ - readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; + readIndex = (int32_t)(S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ - if (readIndex < 0) - { - readIndex += (int32_t) delaySize; + if (readIndex < 0) { + readIndex += (int32_t)delaySize; } /* Working pointer for state buffer is updated */ py = pState; /* blockSize samples are read from the state buffer */ - arm_circularRead_f32((int32_t *) py, delaySize, &readIndex, 1, - (int32_t *) pb, (int32_t *) pb, blockSize, 1, blockSize); + arm_circularRead_f32((int32_t *)py, delaySize, &readIndex, 1, (int32_t *)pb, + (int32_t *)pb, blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; @@ -154,14 +165,12 @@ void arm_fir_sparse_f32( /* Working pointer for scratch buffer of output values */ pOut = pDst; - -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiplications and store in destination buffer */ *pOut++ = *px++ * coeff; @@ -185,8 +194,7 @@ void arm_fir_sparse_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiplication and store in destination buffer */ *pOut++ = *px++ * coeff; @@ -199,25 +207,23 @@ void arm_fir_sparse_f32( coeff = *pCoeffs++; /* Read Index, from where the state buffer should be read, is calculated. */ - readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; + readIndex = (int32_t)(S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ - if (readIndex < 0) - { - readIndex += (int32_t) delaySize; + if (readIndex < 0) { + readIndex += (int32_t)delaySize; } /* Loop over the number of taps. */ - tapCnt = (uint32_t) numTaps - 2U; + tapCnt = (uint32_t)numTaps - 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Working pointer for state buffer is updated */ py = pState; /* blockSize samples are read from the state buffer */ - arm_circularRead_f32((int32_t *) py, delaySize, &readIndex, 1, - (int32_t *) pb, (int32_t *) pb, blockSize, 1, blockSize); + arm_circularRead_f32((int32_t *)py, delaySize, &readIndex, 1, (int32_t *)pb, + (int32_t *)pb, blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; @@ -225,14 +231,12 @@ void arm_fir_sparse_f32( /* Working pointer for scratch buffer of output values */ pOut = pDst; - -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ *pOut++ += *px++ * coeff; @@ -256,8 +260,7 @@ void arm_fir_sparse_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ *pOut++ += *px++ * coeff; @@ -270,12 +273,11 @@ void arm_fir_sparse_f32( coeff = *pCoeffs++; /* Read Index, from where the state buffer should be read, is calculated. */ - readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; + readIndex = (int32_t)(S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ - if (readIndex < 0) - { - readIndex += (int32_t) delaySize; + if (readIndex < 0) { + readIndex += (int32_t)delaySize; } /* Decrement tap loop counter */ @@ -288,8 +290,8 @@ void arm_fir_sparse_f32( py = pState; /* blockSize samples are read from the state buffer */ - arm_circularRead_f32((int32_t *) py, delaySize, &readIndex, 1, - (int32_t *) pb, (int32_t *) pb, blockSize, 1, blockSize); + arm_circularRead_f32((int32_t *)py, delaySize, &readIndex, 1, (int32_t *)pb, + (int32_t *)pb, blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; @@ -297,14 +299,12 @@ void arm_fir_sparse_f32( /* Working pointer for scratch buffer of output values */ pOut = pDst; - -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ *pOut++ += *px++ * coeff; *pOut++ += *px++ * coeff; @@ -325,15 +325,13 @@ void arm_fir_sparse_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ *pOut++ += *px++ * coeff; /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_init_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_init_f32.c index 7745e71..c982a9d 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_init_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_init_f32.c @@ -38,8 +38,10 @@ */ /** - @brief Initialization function for the floating-point sparse FIR filter. - @param[in,out] S points to an instance of the floating-point sparse FIR structure + @brief Initialization function for the floating-point sparse FIR + filter. + @param[in,out] S points to an instance of the floating-point sparse + FIR structure @param[in] numTaps number of nonzero coefficients in the filter @param[in] pCoeffs points to the array of filter coefficients @param[in] pState points to the state buffer @@ -49,23 +51,19 @@ @return none @par Details - pCoeffs holds the filter coefficients and has length numTaps. - pState holds the filter's state variables and must be of length - maxDelay + blockSize, where maxDelay - is the maximum number of delay line values. - blockSize is the - number of samples processed by the arm_fir_sparse_f32() function. + pCoeffs holds the filter coefficients and has + length numTaps. pState holds the filter's state + variables and must be of length maxDelay + blockSize, where + maxDelay is the maximum number of delay line values. + blockSize is the + number of samples processed by the + arm_fir_sparse_f32() function. */ -void arm_fir_sparse_init_f32( - arm_fir_sparse_instance_f32 * S, - uint16_t numTaps, - const float32_t * pCoeffs, - float32_t * pState, - int32_t * pTapDelay, - uint16_t maxDelay, - uint32_t blockSize) -{ +void arm_fir_sparse_init_f32(arm_fir_sparse_instance_f32 *S, uint16_t numTaps, + const float32_t *pCoeffs, float32_t *pState, + int32_t *pTapDelay, uint16_t maxDelay, + uint32_t blockSize) { /* Assign filter taps */ S->numTaps = numTaps; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_init_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_init_q15.c index d07d611..679dde9 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_init_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_init_q15.c @@ -39,7 +39,8 @@ /** @brief Initialization function for the Q15 sparse FIR filter. - @param[in,out] S points to an instance of the Q15 sparse FIR structure + @param[in,out] S points to an instance of the Q15 sparse FIR + structure @param[in] numTaps number of nonzero coefficients in the filter @param[in] pCoeffs points to the array of filter coefficients @param[in] pState points to the state buffer @@ -49,23 +50,19 @@ @return none @par Details - pCoeffs holds the filter coefficients and has length numTaps. - pState holds the filter's state variables and must be of length - maxDelay + blockSize, where maxDelay - is the maximum number of delay line values. + pCoeffs holds the filter coefficients and has + length numTaps. pState holds the filter's state + variables and must be of length maxDelay + blockSize, where + maxDelay is the maximum number of delay line values. blockSize is the - number of words processed by arm_fir_sparse_q15() function. + number of words processed by + arm_fir_sparse_q15() function. */ -void arm_fir_sparse_init_q15( - arm_fir_sparse_instance_q15 * S, - uint16_t numTaps, - const q15_t * pCoeffs, - q15_t * pState, - int32_t * pTapDelay, - uint16_t maxDelay, - uint32_t blockSize) -{ +void arm_fir_sparse_init_q15(arm_fir_sparse_instance_q15 *S, uint16_t numTaps, + const q15_t *pCoeffs, q15_t *pState, + int32_t *pTapDelay, uint16_t maxDelay, + uint32_t blockSize) { /* Assign filter taps */ S->numTaps = numTaps; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_init_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_init_q31.c index 7c32cea..693a876 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_init_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_init_q31.c @@ -39,7 +39,8 @@ /** @brief Initialization function for the Q31 sparse FIR filter. - @param[in,out] S points to an instance of the Q31 sparse FIR structure + @param[in,out] S points to an instance of the Q31 sparse FIR + structure @param[in] numTaps number of nonzero coefficients in the filter @param[in] pCoeffs points to the array of filter coefficients @param[in] pState points to the state buffer @@ -49,22 +50,18 @@ @return none @par Details - pCoeffs holds the filter coefficients and has length numTaps. - pState holds the filter's state variables and must be of length - maxDelay + blockSize, where maxDelay - is the maximum number of delay line values. - blockSize is the number of words processed by arm_fir_sparse_q31() function. + pCoeffs holds the filter coefficients and has + length numTaps. pState holds the filter's state + variables and must be of length maxDelay + blockSize, where + maxDelay is the maximum number of delay line values. + blockSize is the number of words processed by + arm_fir_sparse_q31() function. */ -void arm_fir_sparse_init_q31( - arm_fir_sparse_instance_q31 * S, - uint16_t numTaps, - const q31_t * pCoeffs, - q31_t * pState, - int32_t * pTapDelay, - uint16_t maxDelay, - uint32_t blockSize) -{ +void arm_fir_sparse_init_q31(arm_fir_sparse_instance_q31 *S, uint16_t numTaps, + const q31_t *pCoeffs, q31_t *pState, + int32_t *pTapDelay, uint16_t maxDelay, + uint32_t blockSize) { /* Assign filter taps */ S->numTaps = numTaps; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_init_q7.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_init_q7.c index 98153f3..b5526b3 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_init_q7.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_init_q7.c @@ -49,23 +49,19 @@ @return none @par Details - pCoeffs holds the filter coefficients and has length numTaps. - pState holds the filter's state variables and must be of length - maxDelay + blockSize, where maxDelay - is the maximum number of delay line values. + pCoeffs holds the filter coefficients and has + length numTaps. pState holds the filter's state + variables and must be of length maxDelay + blockSize, where + maxDelay is the maximum number of delay line values. blockSize is the - number of samples processed by the arm_fir_sparse_q7() function. + number of samples processed by the + arm_fir_sparse_q7() function. */ -void arm_fir_sparse_init_q7( - arm_fir_sparse_instance_q7 * S, - uint16_t numTaps, - const q7_t * pCoeffs, - q7_t * pState, - int32_t * pTapDelay, - uint16_t maxDelay, - uint32_t blockSize) -{ +void arm_fir_sparse_init_q7(arm_fir_sparse_instance_q7 *S, uint16_t numTaps, + const q7_t *pCoeffs, q7_t *pState, + int32_t *pTapDelay, uint16_t maxDelay, + uint32_t blockSize) { /* Assign filter taps */ S->numTaps = numTaps; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_q15.c index 9cea93e..554587a 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_q15.c @@ -39,7 +39,8 @@ /** @brief Processing function for the Q15 sparse FIR filter. - @param[in] S points to an instance of the Q15 sparse FIR structure + @param[in] S points to an instance of the Q15 sparse FIR + structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] pScratchIn points to a temporary buffer of size blockSize @@ -48,62 +49,62 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using an internal 32-bit accumulator. - The 1.15 x 1.15 multiplications yield a 2.30 result and these are added to a 2.30 accumulator. - Thus the full precision of the multiplications is maintained but there is only a single guard bit in the accumulator. - If the accumulator result overflows it will wrap around rather than saturate. - After all multiply-accumulates are performed, the 2.30 accumulator is truncated to 2.15 format and then saturated to 1.15 format. - In order to avoid overflows the input signal or coefficients must be scaled down by log2(numTaps) bits. + The function is implemented using an internal 32-bit + accumulator. The 1.15 x 1.15 multiplications yield a 2.30 result and these are + added to a 2.30 accumulator. Thus the full precision of the multiplications is + maintained but there is only a single guard bit in the accumulator. If the + accumulator result overflows it will wrap around rather than saturate. After + all multiply-accumulates are performed, the 2.30 accumulator is truncated + to 2.15 format and then saturated to 1.15 format. In order to avoid overflows + the input signal or coefficients must be scaled down by log2(numTaps) bits. */ -void arm_fir_sparse_q15( - arm_fir_sparse_instance_q15 * S, - const q15_t * pSrc, - q15_t * pDst, - q15_t * pScratchIn, - q31_t * pScratchOut, - uint32_t blockSize) -{ - q15_t *pState = S->pState; /* State pointer */ - const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q15_t *px; /* Temporary pointers for scratch buffer */ - q15_t *py = pState; /* Temporary pointers for state buffer */ - q15_t *pb = pScratchIn; /* Temporary pointers for scratch buffer */ - q15_t *pOut = pDst; /* Working pointer for output */ - int32_t *pTapDelay = S->pTapDelay; /* Pointer to the array containing offset of the non-zero tap values. */ - uint32_t delaySize = S->maxDelay + blockSize; /* state length */ - uint16_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ - int32_t readIndex; /* Read index of the state buffer */ - uint32_t tapCnt, blkCnt; /* loop counters */ - q31_t *pScr2 = pScratchOut; /* Working pointer for scratch buffer of output values */ - q15_t coeff = *pCoeffs++; /* Read the first coefficient value */ +void arm_fir_sparse_q15(arm_fir_sparse_instance_q15 *S, const q15_t *pSrc, + q15_t *pDst, q15_t *pScratchIn, q31_t *pScratchOut, + uint32_t blockSize) { + q15_t *pState = S->pState; /* State pointer */ + const q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q15_t *px; /* Temporary pointers for scratch buffer */ + q15_t *py = pState; /* Temporary pointers for state buffer */ + q15_t *pb = pScratchIn; /* Temporary pointers for scratch buffer */ + q15_t *pOut = pDst; /* Working pointer for output */ + int32_t *pTapDelay = S->pTapDelay; /* Pointer to the array containing offset + of the non-zero tap values. */ + uint32_t delaySize = S->maxDelay + blockSize; /* state length */ + uint16_t numTaps = + S->numTaps; /* Number of filter coefficients in the filter */ + int32_t readIndex; /* Read index of the state buffer */ + uint32_t tapCnt, blkCnt; /* loop counters */ + q31_t *pScr2 = + pScratchOut; /* Working pointer for scratch buffer of output values */ + q15_t coeff = *pCoeffs++; /* Read the first coefficient value */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t in1, in2; /* Temporary variables */ +#if defined(ARM_MATH_LOOPUNROLL) + q31_t in1, in2; /* Temporary variables */ #endif /* BlockSize of Input samples are copied into the state buffer */ /* StateIndex points to the starting position to write in the state buffer */ - arm_circularWrite_q15(py, (int32_t) delaySize, &S->stateIndex, 1,pSrc, 1, blockSize); + arm_circularWrite_q15(py, (int32_t)delaySize, &S->stateIndex, 1, pSrc, 1, + blockSize); /* Loop over the number of taps. */ tapCnt = numTaps; /* Read Index, from where the state buffer should be read, is calculated. */ - readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; + readIndex = (int32_t)(S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ - if (readIndex < 0) - { - readIndex += (int32_t) delaySize; + if (readIndex < 0) { + readIndex += (int32_t)delaySize; } /* Working pointer for state buffer is updated */ py = pState; /* blockSize samples are read from the state buffer */ - arm_circularRead_q15(py, (int32_t) delaySize, &readIndex, 1, - pb, pb, (int32_t) blockSize, 1, blockSize); + arm_circularRead_q15(py, (int32_t)delaySize, &readIndex, 1, pb, pb, + (int32_t)blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; @@ -111,19 +112,17 @@ void arm_fir_sparse_q15( /* Working pointer for scratch buffer of output values */ pScratchOut = pScr2; - -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform multiplication and store in the scratch buffer */ - *pScratchOut++ = ((q31_t) *px++ * coeff); - *pScratchOut++ = ((q31_t) *px++ * coeff); - *pScratchOut++ = ((q31_t) *px++ * coeff); - *pScratchOut++ = ((q31_t) *px++ * coeff); + *pScratchOut++ = ((q31_t)*px++ * coeff); + *pScratchOut++ = ((q31_t)*px++ * coeff); + *pScratchOut++ = ((q31_t)*px++ * coeff); + *pScratchOut++ = ((q31_t)*px++ * coeff); /* Decrement loop counter */ blkCnt--; @@ -139,10 +138,9 @@ void arm_fir_sparse_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiplication and store in the scratch buffer */ - *pScratchOut++ = ((q31_t) *px++ * coeff); + *pScratchOut++ = ((q31_t)*px++ * coeff); /* Decrement loop counter */ blkCnt--; @@ -153,25 +151,23 @@ void arm_fir_sparse_q15( coeff = *pCoeffs++; /* Read Index, from where the state buffer should be read, is calculated. */ - readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; + readIndex = (int32_t)(S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ - if (readIndex < 0) - { - readIndex += (int32_t) delaySize; + if (readIndex < 0) { + readIndex += (int32_t)delaySize; } /* Loop over the number of taps. */ - tapCnt = (uint32_t) numTaps - 2U; + tapCnt = (uint32_t)numTaps - 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Working pointer for state buffer is updated */ py = pState; /* blockSize samples are read from the state buffer */ - arm_circularRead_q15(py, (int32_t) delaySize, &readIndex, 1, - pb, pb, (int32_t) blockSize, 1, blockSize); + arm_circularRead_q15(py, (int32_t)delaySize, &readIndex, 1, pb, pb, + (int32_t)blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; @@ -179,19 +175,17 @@ void arm_fir_sparse_q15( /* Working pointer for scratch buffer of output values */ pScratchOut = pScr2; - -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ - *pScratchOut++ += (q31_t) *px++ * coeff; - *pScratchOut++ += (q31_t) *px++ * coeff; - *pScratchOut++ += (q31_t) *px++ * coeff; - *pScratchOut++ += (q31_t) *px++ * coeff; + *pScratchOut++ += (q31_t)*px++ * coeff; + *pScratchOut++ += (q31_t)*px++ * coeff; + *pScratchOut++ += (q31_t)*px++ * coeff; + *pScratchOut++ += (q31_t)*px++ * coeff; /* Decrement loop counter */ blkCnt--; @@ -207,10 +201,9 @@ void arm_fir_sparse_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ - *pScratchOut++ += (q31_t) *px++ * coeff; + *pScratchOut++ += (q31_t)*px++ * coeff; /* Decrement loop counter */ blkCnt--; @@ -221,12 +214,11 @@ void arm_fir_sparse_q15( coeff = *pCoeffs++; /* Read Index, from where the state buffer should be read, is calculated. */ - readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; + readIndex = (int32_t)(S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ - if (readIndex < 0) - { - readIndex += (int32_t) delaySize; + if (readIndex < 0) { + readIndex += (int32_t)delaySize; } /* Decrement loop counter */ @@ -239,8 +231,8 @@ void arm_fir_sparse_q15( py = pState; /* blockSize samples are read from the state buffer */ - arm_circularRead_q15(py, (int32_t) delaySize, &readIndex, 1, - pb, pb, (int32_t) blockSize, 1, blockSize); + arm_circularRead_q15(py, (int32_t)delaySize, &readIndex, 1, pb, pb, + (int32_t)blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; @@ -248,19 +240,17 @@ void arm_fir_sparse_q15( /* Working pointer for scratch buffer of output values */ pScratchOut = pScr2; - -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ - *pScratchOut++ += (q31_t) *px++ * coeff; - *pScratchOut++ += (q31_t) *px++ * coeff; - *pScratchOut++ += (q31_t) *px++ * coeff; - *pScratchOut++ += (q31_t) *px++ * coeff; + *pScratchOut++ += (q31_t)*px++ * coeff; + *pScratchOut++ += (q31_t)*px++ * coeff; + *pScratchOut++ += (q31_t)*px++ * coeff; + *pScratchOut++ += (q31_t)*px++ * coeff; /* Decrement loop counter */ blkCnt--; @@ -276,40 +266,43 @@ void arm_fir_sparse_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ - *pScratchOut++ += (q31_t) *px++ * coeff; + *pScratchOut++ += (q31_t)*px++ * coeff; /* Decrement loop counter */ blkCnt--; } /* All the output values are in pScratchOut buffer. - Convert them into 1.15 format, saturate and store in the destination buffer. */ -#if defined (ARM_MATH_LOOPUNROLL) + Convert them into 1.15 format, saturate and store in the destination + buffer. */ +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { in1 = *pScr2++; in2 = *pScr2++; #ifndef ARM_MATH_BIG_ENDIAN - write_q15x2_ia (&pOut, __PKHBT((q15_t) __SSAT(in1 >> 15, 16), (q15_t) __SSAT(in2 >> 15, 16), 16)); + write_q15x2_ia(&pOut, __PKHBT((q15_t)__SSAT(in1 >> 15, 16), + (q15_t)__SSAT(in2 >> 15, 16), 16)); #else - write_q15x2_ia (&pOut, __PKHBT((q15_t) __SSAT(in2 >> 15, 16), (q15_t) __SSAT(in1 >> 15, 16), 16)); + write_q15x2_ia(&pOut, __PKHBT((q15_t)__SSAT(in2 >> 15, 16), + (q15_t)__SSAT(in1 >> 15, 16), 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ in1 = *pScr2++; in2 = *pScr2++; #ifndef ARM_MATH_BIG_ENDIAN - write_q15x2_ia (&pOut, __PKHBT((q15_t) __SSAT(in1 >> 15, 16), (q15_t) __SSAT(in2 >> 15, 16), 16)); + write_q15x2_ia(&pOut, __PKHBT((q15_t)__SSAT(in1 >> 15, 16), + (q15_t)__SSAT(in2 >> 15, 16), 16)); #else - write_q15x2_ia (&pOut, __PKHBT((q15_t) __SSAT(in2 >> 15, 16), (q15_t) __SSAT(in1 >> 15, 16), 16)); + write_q15x2_ia(&pOut, __PKHBT((q15_t)__SSAT(in2 >> 15, 16), + (q15_t)__SSAT(in1 >> 15, 16), 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Decrement loop counter */ @@ -326,14 +319,12 @@ void arm_fir_sparse_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { - *pOut++ = (q15_t) __SSAT(*pScr2++ >> 15, 16); + while (blkCnt > 0U) { + *pOut++ = (q15_t)__SSAT(*pScr2++ >> 15, 16); /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_q31.c index 86d3e1d..af4ed4f 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_q31.c @@ -39,7 +39,8 @@ /** @brief Processing function for the Q31 sparse FIR filter. - @param[in] S points to an instance of the Q31 sparse FIR structure + @param[in] S points to an instance of the Q31 sparse FIR + structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] pScratchIn points to a temporary buffer of size blockSize @@ -47,56 +48,53 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using an internal 32-bit accumulator. - The 1.31 x 1.31 multiplications are truncated to 2.30 format. - This leads to loss of precision on the intermediate multiplications and provides only a single guard bit. - If the accumulator result overflows, it wraps around rather than saturate. - In order to avoid overflows the input signal or coefficients must be scaled down by log2(numTaps) bits. + The function is implemented using an internal 32-bit + accumulator. The 1.31 x 1.31 multiplications are truncated to 2.30 format. + This leads to loss of precision on the intermediate + multiplications and provides only a single guard bit. If the accumulator + result overflows, it wraps around rather than saturate. In order to avoid + overflows the input signal or coefficients must be scaled down by + log2(numTaps) bits. */ -void arm_fir_sparse_q31( - arm_fir_sparse_instance_q31 * S, - const q31_t * pSrc, - q31_t * pDst, - q31_t * pScratchIn, - uint32_t blockSize) -{ - q31_t *pState = S->pState; /* State pointer */ - const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q31_t *px; /* Scratch buffer pointer */ - q31_t *py = pState; /* Temporary pointers for state buffer */ - q31_t *pb = pScratchIn; /* Temporary pointers for scratch buffer */ - q31_t *pOut; /* Destination pointer */ - int32_t *pTapDelay = S->pTapDelay; /* Pointer to the array containing offset of the non-zero tap values. */ - uint32_t delaySize = S->maxDelay + blockSize; /* state length */ - uint16_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ - int32_t readIndex; /* Read index of the state buffer */ - uint32_t tapCnt, blkCnt; /* loop counters */ - q31_t coeff = *pCoeffs++; /* Read the first coefficient value */ - q31_t in; - q63_t out; /* Temporary output variable */ - +void arm_fir_sparse_q31(arm_fir_sparse_instance_q31 *S, const q31_t *pSrc, + q31_t *pDst, q31_t *pScratchIn, uint32_t blockSize) { + q31_t *pState = S->pState; /* State pointer */ + const q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q31_t *px; /* Scratch buffer pointer */ + q31_t *py = pState; /* Temporary pointers for state buffer */ + q31_t *pb = pScratchIn; /* Temporary pointers for scratch buffer */ + q31_t *pOut; /* Destination pointer */ + int32_t *pTapDelay = S->pTapDelay; /* Pointer to the array containing offset + of the non-zero tap values. */ + uint32_t delaySize = S->maxDelay + blockSize; /* state length */ + uint16_t numTaps = + S->numTaps; /* Number of filter coefficients in the filter */ + int32_t readIndex; /* Read index of the state buffer */ + uint32_t tapCnt, blkCnt; /* loop counters */ + q31_t coeff = *pCoeffs++; /* Read the first coefficient value */ + q31_t in; + q63_t out; /* Temporary output variable */ /* BlockSize of Input samples are copied into the state buffer */ /* StateIndex points to the starting position to write in the state buffer */ - arm_circularWrite_f32((int32_t *) py, delaySize, &S->stateIndex, 1, - (int32_t *) pSrc, 1, blockSize); + arm_circularWrite_f32((int32_t *)py, delaySize, &S->stateIndex, 1, + (int32_t *)pSrc, 1, blockSize); /* Read Index, from where the state buffer should be read, is calculated. */ - readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; + readIndex = (int32_t)(S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ - if (readIndex < 0) - { - readIndex += (int32_t) delaySize; + if (readIndex < 0) { + readIndex += (int32_t)delaySize; } /* Working pointer for state buffer is updated */ py = pState; /* blockSize samples are read from the state buffer */ - arm_circularRead_f32((int32_t *) py, delaySize, &readIndex, 1, - (int32_t *) pb, (int32_t *) pb, blockSize, 1, blockSize); + arm_circularRead_f32((int32_t *)py, delaySize, &readIndex, 1, (int32_t *)pb, + (int32_t *)pb, blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; @@ -104,22 +102,20 @@ void arm_fir_sparse_q31( /* Working pointer for scratch buffer of output values */ pOut = pDst; - -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiplications and store in destination buffer */ - *pOut++ = (q31_t) (((q63_t) *px++ * coeff) >> 32); + *pOut++ = (q31_t)(((q63_t)*px++ * coeff) >> 32); - *pOut++ = (q31_t) (((q63_t) *px++ * coeff) >> 32); + *pOut++ = (q31_t)(((q63_t)*px++ * coeff) >> 32); - *pOut++ = (q31_t) (((q63_t) *px++ * coeff) >> 32); + *pOut++ = (q31_t)(((q63_t)*px++ * coeff) >> 32); - *pOut++ = (q31_t) (((q63_t) *px++ * coeff) >> 32); + *pOut++ = (q31_t)(((q63_t)*px++ * coeff) >> 32); /* Decrement loop counter */ blkCnt--; @@ -135,10 +131,9 @@ void arm_fir_sparse_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiplication and store in destination buffer */ - *pOut++ = (q31_t) (((q63_t) *px++ * coeff) >> 32); + *pOut++ = (q31_t)(((q63_t)*px++ * coeff) >> 32); /* Decrement loop counter */ blkCnt--; @@ -149,25 +144,23 @@ void arm_fir_sparse_q31( coeff = *pCoeffs++; /* Read Index, from where the state buffer should be read, is calculated. */ - readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; + readIndex = (int32_t)(S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ - if (readIndex < 0) - { - readIndex += (int32_t) delaySize; + if (readIndex < 0) { + readIndex += (int32_t)delaySize; } /* Loop over the number of taps. */ - tapCnt = (uint32_t) numTaps - 2U; + tapCnt = (uint32_t)numTaps - 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Working pointer for state buffer is updated */ py = pState; /* blockSize samples are read from the state buffer */ - arm_circularRead_f32((int32_t *) py, delaySize, &readIndex, 1, - (int32_t *) pb, (int32_t *) pb, blockSize, 1, blockSize); + arm_circularRead_f32((int32_t *)py, delaySize, &readIndex, 1, (int32_t *)pb, + (int32_t *)pb, blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; @@ -175,30 +168,28 @@ void arm_fir_sparse_q31( /* Working pointer for scratch buffer of output values */ pOut = pDst; - -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ out = *pOut; - out += ((q63_t) *px++ * coeff) >> 32; - *pOut++ = (q31_t) (out); + out += ((q63_t)*px++ * coeff) >> 32; + *pOut++ = (q31_t)(out); out = *pOut; - out += ((q63_t) *px++ * coeff) >> 32; - *pOut++ = (q31_t) (out); + out += ((q63_t)*px++ * coeff) >> 32; + *pOut++ = (q31_t)(out); out = *pOut; - out += ((q63_t) *px++ * coeff) >> 32; - *pOut++ = (q31_t) (out); + out += ((q63_t)*px++ * coeff) >> 32; + *pOut++ = (q31_t)(out); out = *pOut; - out += ((q63_t) *px++ * coeff) >> 32; - *pOut++ = (q31_t) (out); + out += ((q63_t)*px++ * coeff) >> 32; + *pOut++ = (q31_t)(out); /* Decrement loop counter */ blkCnt--; @@ -214,12 +205,11 @@ void arm_fir_sparse_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ out = *pOut; - out += ((q63_t) *px++ * coeff) >> 32; - *pOut++ = (q31_t) (out); + out += ((q63_t)*px++ * coeff) >> 32; + *pOut++ = (q31_t)(out); /* Decrement loop counter */ blkCnt--; @@ -230,12 +220,11 @@ void arm_fir_sparse_q31( coeff = *pCoeffs++; /* Read Index, from where the state buffer should be read, is calculated. */ - readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; + readIndex = (int32_t)(S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ - if (readIndex < 0) - { - readIndex += (int32_t) delaySize; + if (readIndex < 0) { + readIndex += (int32_t)delaySize; } /* Decrement tap loop counter */ @@ -248,8 +237,8 @@ void arm_fir_sparse_q31( py = pState; /* blockSize samples are read from the state buffer */ - arm_circularRead_f32((int32_t *) py, delaySize, &readIndex, 1, - (int32_t *) pb, (int32_t *) pb, blockSize, 1, blockSize); + arm_circularRead_f32((int32_t *)py, delaySize, &readIndex, 1, (int32_t *)pb, + (int32_t *)pb, blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; @@ -257,30 +246,28 @@ void arm_fir_sparse_q31( /* Working pointer for scratch buffer of output values */ pOut = pDst; - -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ out = *pOut; - out += ((q63_t) * px++ * coeff) >> 32; - *pOut++ = (q31_t) (out); + out += ((q63_t)*px++ * coeff) >> 32; + *pOut++ = (q31_t)(out); out = *pOut; - out += ((q63_t) * px++ * coeff) >> 32; - *pOut++ = (q31_t) (out); + out += ((q63_t)*px++ * coeff) >> 32; + *pOut++ = (q31_t)(out); out = *pOut; - out += ((q63_t) * px++ * coeff) >> 32; - *pOut++ = (q31_t) (out); + out += ((q63_t)*px++ * coeff) >> 32; + *pOut++ = (q31_t)(out); out = *pOut; - out += ((q63_t) * px++ * coeff) >> 32; - *pOut++ = (q31_t) (out); + out += ((q63_t)*px++ * coeff) >> 32; + *pOut++ = (q31_t)(out); /* Decrement loop counter */ blkCnt--; @@ -296,12 +283,11 @@ void arm_fir_sparse_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ out = *pOut; - out += ((q63_t) *px++ * coeff) >> 32; - *pOut++ = (q31_t) (out); + out += ((q63_t)*px++ * coeff) >> 32; + *pOut++ = (q31_t)(out); /* Decrement loop counter */ blkCnt--; @@ -311,13 +297,12 @@ void arm_fir_sparse_q31( pOut = pDst; /* Output is converted into 1.31 format. */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { in = *pOut << 1; *pOut++ = in; in = *pOut << 1; @@ -341,15 +326,13 @@ void arm_fir_sparse_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { in = *pOut << 1; *pOut++ = in; /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_q7.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_q7.c index 7a2b57f..a86235e 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_q7.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_fir_sparse_q7.c @@ -39,7 +39,8 @@ /** @brief Processing function for the Q7 sparse FIR filter. - @param[in] S points to an instance of the Q7 sparse FIR structure + @param[in] S points to an instance of the Q7 sparse FIR + structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] pScratchIn points to a temporary buffer of size blockSize @@ -48,63 +49,62 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using a 32-bit internal accumulator. - Both coefficients and state variables are represented in 1.7 format and multiplications yield a 2.14 result. - The 2.14 intermediate results are accumulated in a 32-bit accumulator in 18.14 format. - There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. - The accumulator is then converted to 18.7 format by discarding the low 7 bits. - Finally, the result is truncated to 1.7 format. + The function is implemented using a 32-bit internal + accumulator. Both coefficients and state variables are represented in 1.7 + format and multiplications yield a 2.14 result. The 2.14 intermediate results + are accumulated in a 32-bit accumulator in 18.14 format. There is no risk of + internal overflow with this approach and the full precision of intermediate + multiplications is preserved. The accumulator is then converted to 18.7 format + by discarding the low 7 bits. Finally, the result is truncated to 1.7 format. */ -void arm_fir_sparse_q7( - arm_fir_sparse_instance_q7 * S, - const q7_t * pSrc, - q7_t * pDst, - q7_t * pScratchIn, - q31_t * pScratchOut, - uint32_t blockSize) -{ - q7_t *pState = S->pState; /* State pointer */ - const q7_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q7_t *px; /* Scratch buffer pointer */ - q7_t *py = pState; /* Temporary pointers for state buffer */ - q7_t *pb = pScratchIn; /* Temporary pointers for scratch buffer */ - q7_t *pOut = pDst; /* Destination pointer */ - int32_t *pTapDelay = S->pTapDelay; /* Pointer to the array containing offset of the non-zero tap values. */ - uint32_t delaySize = S->maxDelay + blockSize; /* state length */ - uint16_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ - int32_t readIndex; /* Read index of the state buffer */ - uint32_t tapCnt, blkCnt; /* loop counters */ - q31_t *pScr2 = pScratchOut; /* Working pointer for scratch buffer of output values */ - q31_t in; - q7_t coeff = *pCoeffs++; /* Read the coefficient value */ +void arm_fir_sparse_q7(arm_fir_sparse_instance_q7 *S, const q7_t *pSrc, + q7_t *pDst, q7_t *pScratchIn, q31_t *pScratchOut, + uint32_t blockSize) { + q7_t *pState = S->pState; /* State pointer */ + const q7_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q7_t *px; /* Scratch buffer pointer */ + q7_t *py = pState; /* Temporary pointers for state buffer */ + q7_t *pb = pScratchIn; /* Temporary pointers for scratch buffer */ + q7_t *pOut = pDst; /* Destination pointer */ + int32_t *pTapDelay = S->pTapDelay; /* Pointer to the array containing offset + of the non-zero tap values. */ + uint32_t delaySize = S->maxDelay + blockSize; /* state length */ + uint16_t numTaps = + S->numTaps; /* Number of filter coefficients in the filter */ + int32_t readIndex; /* Read index of the state buffer */ + uint32_t tapCnt, blkCnt; /* loop counters */ + q31_t *pScr2 = + pScratchOut; /* Working pointer for scratch buffer of output values */ + q31_t in; + q7_t coeff = *pCoeffs++; /* Read the coefficient value */ -#if defined (ARM_MATH_LOOPUNROLL) - q7_t in1, in2, in3, in4; +#if defined(ARM_MATH_LOOPUNROLL) + q7_t in1, in2, in3, in4; #endif /* BlockSize of Input samples are copied into the state buffer */ /* StateIndex points to the starting position to write in the state buffer */ - arm_circularWrite_q7(py, (int32_t) delaySize, &S->stateIndex, 1, pSrc, 1, blockSize); + arm_circularWrite_q7(py, (int32_t)delaySize, &S->stateIndex, 1, pSrc, 1, + blockSize); /* Loop over the number of taps. */ tapCnt = numTaps; /* Read Index, from where the state buffer should be read, is calculated. */ - readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; + readIndex = (int32_t)(S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ - if (readIndex < 0) - { - readIndex += (int32_t) delaySize; + if (readIndex < 0) { + readIndex += (int32_t)delaySize; } /* Working pointer for state buffer is updated */ py = pState; /* blockSize samples are read from the state buffer */ - arm_circularRead_q7(py, (int32_t) delaySize, &readIndex, 1, - pb, pb, (int32_t) blockSize, 1, blockSize); + arm_circularRead_q7(py, (int32_t)delaySize, &readIndex, 1, pb, pb, + (int32_t)blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; @@ -112,19 +112,17 @@ void arm_fir_sparse_q7( /* Working pointer for scratch buffer of output values */ pScratchOut = pScr2; - -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform multiplication and store in the scratch buffer */ - *pScratchOut++ = ((q31_t) *px++ * coeff); - *pScratchOut++ = ((q31_t) *px++ * coeff); - *pScratchOut++ = ((q31_t) *px++ * coeff); - *pScratchOut++ = ((q31_t) *px++ * coeff); + *pScratchOut++ = ((q31_t)*px++ * coeff); + *pScratchOut++ = ((q31_t)*px++ * coeff); + *pScratchOut++ = ((q31_t)*px++ * coeff); + *pScratchOut++ = ((q31_t)*px++ * coeff); /* Decrement loop counter */ blkCnt--; @@ -140,10 +138,9 @@ void arm_fir_sparse_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiplication and store in the scratch buffer */ - *pScratchOut++ = ((q31_t) *px++ * coeff); + *pScratchOut++ = ((q31_t)*px++ * coeff); /* Decrement loop counter */ blkCnt--; @@ -154,25 +151,23 @@ void arm_fir_sparse_q7( coeff = *pCoeffs++; /* Read Index, from where the state buffer should be read, is calculated. */ - readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; + readIndex = (int32_t)(S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ - if (readIndex < 0) - { - readIndex += (int32_t) delaySize; + if (readIndex < 0) { + readIndex += (int32_t)delaySize; } /* Loop over the number of taps. */ - tapCnt = (uint32_t) numTaps - 2U; + tapCnt = (uint32_t)numTaps - 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Working pointer for state buffer is updated */ py = pState; /* blockSize samples are read from the state buffer */ - arm_circularRead_q7(py, (int32_t) delaySize, &readIndex, 1, - pb, pb, (int32_t) blockSize, 1, blockSize); + arm_circularRead_q7(py, (int32_t)delaySize, &readIndex, 1, pb, pb, + (int32_t)blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; @@ -180,22 +175,20 @@ void arm_fir_sparse_q7( /* Working pointer for scratch buffer of output values */ pScratchOut = pScr2; - -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ - in = *pScratchOut + ((q31_t) * px++ * coeff); + in = *pScratchOut + ((q31_t)*px++ * coeff); *pScratchOut++ = in; - in = *pScratchOut + ((q31_t) * px++ * coeff); + in = *pScratchOut + ((q31_t)*px++ * coeff); *pScratchOut++ = in; - in = *pScratchOut + ((q31_t) * px++ * coeff); + in = *pScratchOut + ((q31_t)*px++ * coeff); *pScratchOut++ = in; - in = *pScratchOut + ((q31_t) * px++ * coeff); + in = *pScratchOut + ((q31_t)*px++ * coeff); *pScratchOut++ = in; /* Decrement loop counter */ @@ -212,10 +205,9 @@ void arm_fir_sparse_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ - in = *pScratchOut + ((q31_t) *px++ * coeff); + in = *pScratchOut + ((q31_t)*px++ * coeff); *pScratchOut++ = in; /* Decrement loop counter */ @@ -227,12 +219,11 @@ void arm_fir_sparse_q7( coeff = *pCoeffs++; /* Read Index, from where the state buffer should be read, is calculated. */ - readIndex = (int32_t) (S->stateIndex - blockSize) - *pTapDelay++; + readIndex = (int32_t)(S->stateIndex - blockSize) - *pTapDelay++; /* Wraparound of readIndex */ - if (readIndex < 0) - { - readIndex += (int32_t) delaySize; + if (readIndex < 0) { + readIndex += (int32_t)delaySize; } /* Decrement loop counter */ @@ -245,8 +236,8 @@ void arm_fir_sparse_q7( py = pState; /* blockSize samples are read from the state buffer */ - arm_circularRead_q7(py, (int32_t) delaySize, &readIndex, 1, - pb, pb, (int32_t) blockSize, 1, blockSize); + arm_circularRead_q7(py, (int32_t)delaySize, &readIndex, 1, pb, pb, + (int32_t)blockSize, 1, blockSize); /* Working pointer for the scratch buffer of state values */ px = pb; @@ -254,22 +245,20 @@ void arm_fir_sparse_q7( /* Working pointer for scratch buffer of output values */ pScratchOut = pScr2; - -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ - in = *pScratchOut + ((q31_t) *px++ * coeff); + in = *pScratchOut + ((q31_t)*px++ * coeff); *pScratchOut++ = in; - in = *pScratchOut + ((q31_t) *px++ * coeff); + in = *pScratchOut + ((q31_t)*px++ * coeff); *pScratchOut++ = in; - in = *pScratchOut + ((q31_t) *px++ * coeff); + in = *pScratchOut + ((q31_t)*px++ * coeff); *pScratchOut++ = in; - in = *pScratchOut + ((q31_t) *px++ * coeff); + in = *pScratchOut + ((q31_t)*px++ * coeff); *pScratchOut++ = in; /* Decrement loop counter */ @@ -286,10 +275,9 @@ void arm_fir_sparse_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Perform Multiply-Accumulate */ - in = *pScratchOut + ((q31_t) *px++ * coeff); + in = *pScratchOut + ((q31_t)*px++ * coeff); *pScratchOut++ = in; /* Decrement loop counter */ @@ -297,20 +285,20 @@ void arm_fir_sparse_q7( } /* All the output values are in pScratchOut buffer. - Convert them into 1.15 format, saturate and store in the destination buffer. */ -#if defined (ARM_MATH_LOOPUNROLL) + Convert them into 1.15 format, saturate and store in the destination + buffer. */ +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time. */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { - in1 = (q7_t) __SSAT(*pScr2++ >> 7, 8); - in2 = (q7_t) __SSAT(*pScr2++ >> 7, 8); - in3 = (q7_t) __SSAT(*pScr2++ >> 7, 8); - in4 = (q7_t) __SSAT(*pScr2++ >> 7, 8); + while (blkCnt > 0U) { + in1 = (q7_t)__SSAT(*pScr2++ >> 7, 8); + in2 = (q7_t)__SSAT(*pScr2++ >> 7, 8); + in3 = (q7_t)__SSAT(*pScr2++ >> 7, 8); + in4 = (q7_t)__SSAT(*pScr2++ >> 7, 8); - write_q7x4_ia (&pOut, __PACKq7(in1, in2, in3, in4)); + write_q7x4_ia(&pOut, __PACKq7(in1, in2, in3, in4)); /* Decrement loop counter */ blkCnt--; @@ -326,14 +314,12 @@ void arm_fir_sparse_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { - *pOut++ = (q7_t) __SSAT(*pScr2++ >> 7, 8); + while (blkCnt > 0U) { + *pOut++ = (q7_t)__SSAT(*pScr2++ >> 7, 8); /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_f32.c index c48efe3..02dbad7 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_f32.c @@ -37,15 +37,16 @@ This set of functions implements lattice filters for Q15, Q31 and floating-point data types. Lattice filters are used in a - variety of adaptive filter applications. The filter structure has feedforward and - feedback components and the net impulse response is infinite length. - The functions operate on blocks - of input and output data and each call to the function processes - blockSize samples through the filter. pSrc and - pDst point to input and output arrays containing blockSize values. + variety of adaptive filter applications. The filter structure has feedforward + and feedback components and the net impulse response is infinite length. The + functions operate on blocks of input and output data and each call to the + function processes blockSize samples through the filter. + pSrc and pDst point to input and output arrays + containing blockSize values. @par Algorithm - \image html IIRLattice.gif "Infinite Impulse Response Lattice filter" + \image html IIRLattice.gif "Infinite Impulse Response Lattice + filter" @par
       fN(n)   = x(n)
@@ -54,54 +55,63 @@
       y(n)    = vN * gN(n) + vN-1 * gN-1(n) + ...+ v0 * g0(n)
   
@par - pkCoeffs points to array of reflection coefficients of size numStages. - Reflection Coefficients are stored in time-reversed order. + pkCoeffs points to array of reflection + coefficients of size numStages. Reflection Coefficients are + stored in time-reversed order. @par
      {kN, kN-1, ..., k1}
   
@par - pvCoeffs points to the array of ladder coefficients of size (numStages+1). - Ladder coefficients are stored in time-reversed order. -
-      {vN, vN-1, ..., v0}
+                  pvCoeffs points to the array of ladder
+  coefficients of size (numStages+1). Ladder coefficients are
+  stored in time-reversed order. 
 {vN, vN-1, ..., v0}
   
@par - pState points to a state array of size numStages + blockSize. - The state variables shown in the figure above (the g values) are stored in the pState array. - The state variables are updated after each block of data is processed; the coefficients are untouched. + pState points to a state array of size + numStages + blockSize. The state variables shown in the figure + above (the g values) are stored in the pState array. The state + variables are updated after each block of data is processed; the coefficients + are untouched. @par Instance Structure - The coefficients and state variables for a filter are stored together in an instance data structure. - A separate instance structure must be defined for each filter. - Coefficient arrays may be shared among several instances while state variable arrays cannot be shared. - There are separate instance structure declarations for each of the 3 supported data types. + The coefficients and state variables for a filter are stored + together in an instance data structure. A separate instance structure must be + defined for each filter. Coefficient arrays may be shared among several + instances while state variable arrays cannot be shared. There are separate + instance structure declarations for each of the 3 supported data types. @par Initialization Functions - There is also an associated initialization function for each data type. - The initialization function performs the following operations: + There is also an associated initialization function for each + data type. The initialization function performs the following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. - To do this manually without calling the init function, assign the follow subfields of the instance structure: - numStages, pkCoeffs, pvCoeffs, pState. Also set all of the values in pState to zero. + To do this manually without calling the init function, assign + the follow subfields of the instance structure: numStages, pkCoeffs, pvCoeffs, + pState. Also set all of the values in pState to zero. @par Use of the initialization function is optional. - However, if the initialization function is used, then the instance structure cannot be placed into a const data section. - To place an instance structure into a const data section, the instance structure must be manually initialized. - Set the values in the state buffer to zeros and then manually initialize the instance structure as follows: -
+                   However, if the initialization function is used, then the
+  instance structure cannot be placed into a const data section. To place an
+  instance structure into a const data section, the instance structure must be
+  manually initialized. Set the values in the state buffer to zeros and then
+  manually initialize the instance structure as follows: 
       arm_iir_lattice_instance_f32 S = {numStages, pState, pkCoeffs, pvCoeffs};
       arm_iir_lattice_instance_q31 S = {numStages, pState, pkCoeffs, pvCoeffs};
       arm_iir_lattice_instance_q15 S = {numStages, pState, pkCoeffs, pvCoeffs};
   
@par - where numStages is the number of stages in the filter; pState points to the state buffer array; - pkCoeffs points to array of the reflection coefficients; pvCoeffs points to the array of ladder coefficients. + where numStages is the number of stages in the + filter; pState points to the state buffer array; + pkCoeffs points to array of the reflection + coefficients; pvCoeffs points to the array of ladder + coefficients. @par Fixed-Point Behavior - Care must be taken when using the fixed-point versions of the IIR lattice filter functions. - In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. - Refer to the function specific documentation below for usage guidelines. + Care must be taken when using the fixed-point versions of the + IIR lattice filter functions. In particular, the overflow and saturation + behavior of the accumulator used in each function must be considered. Refer to + the function specific documentation below for usage guidelines. */ /** @@ -111,39 +121,37 @@ /** @brief Processing function for the floating-point IIR lattice filter. - @param[in] S points to an instance of the floating-point IIR lattice structure + @param[in] S points to an instance of the floating-point IIR + lattice structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none */ -void arm_iir_lattice_f32( - const arm_iir_lattice_instance_f32 * S, - const float32_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - float32_t *pState = S->pState; /* State pointer */ - float32_t *pStateCur; /* State current pointer */ - float32_t acc; /* Accumlator */ - float32_t fnext1, fnext2, gcurr1, gnext; /* Temporary variables for lattice stages */ - float32_t *px1, *px2, *pk, *pv; /* Temporary pointers for state and coef */ - uint32_t numStages = S->numStages; /* Number of stages */ - uint32_t blkCnt, tapCnt; /* Temporary variables for counts */ +void arm_iir_lattice_f32(const arm_iir_lattice_instance_f32 *S, + const float32_t *pSrc, float32_t *pDst, + uint32_t blockSize) { + float32_t *pState = S->pState; /* State pointer */ + float32_t *pStateCur; /* State current pointer */ + float32_t acc; /* Accumlator */ + float32_t fnext1, fnext2, gcurr1, + gnext; /* Temporary variables for lattice stages */ + float32_t *px1, *px2, *pk, *pv; /* Temporary pointers for state and coef */ + uint32_t numStages = S->numStages; /* Number of stages */ + uint32_t blkCnt, tapCnt; /* Temporary variables for counts */ -#if defined (ARM_MATH_LOOPUNROLL) - float32_t gcurr2; /* Temporary variables for lattice stages */ - float32_t k1, k2; - float32_t v1, v2, v3, v4; +#if defined(ARM_MATH_LOOPUNROLL) + float32_t gcurr2; /* Temporary variables for lattice stages */ + float32_t k1, k2; + float32_t v1, v2, v3, v4; #endif /* initialise loop count */ blkCnt = blockSize; /* Sample processing */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Read Sample from input buffer */ /* fN(n) = x(n) */ fnext2 = *pSrc++; @@ -163,13 +171,12 @@ void arm_iir_lattice_f32( /* Set accumulator to zero */ acc = 0.0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = (numStages) >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Read gN-1(n-1) from state buffer */ gcurr1 = *px1; @@ -275,8 +282,7 @@ void arm_iir_lattice_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { gcurr1 = *px1++; /* Process sample for last taps */ fnext1 = fnext2 - ((*pk) * gcurr1); @@ -305,21 +311,20 @@ void arm_iir_lattice_f32( blkCnt--; } - /* Processing is complete. Now copy last S->numStages samples to start of the buffer - for the preperation of next frame process */ + /* Processing is complete. Now copy last S->numStages samples to start of the + buffer for the preperation of next frame process */ /* Points to the start of the state buffer */ pStateCur = &S->pState[0]; pState = &S->pState[blockSize]; /* Copy data */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numStages >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; @@ -339,14 +344,12 @@ void arm_iir_lattice_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ tapCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_init_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_init_f32.c index bd9f933..b8dba26 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_init_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_init_f32.c @@ -38,24 +38,25 @@ */ /** - @brief Initialization function for the floating-point IIR lattice filter. - @param[in] S points to an instance of the floating-point IIR lattice structure + @brief Initialization function for the floating-point IIR lattice + filter. + @param[in] S points to an instance of the floating-point IIR + lattice structure @param[in] numStages number of stages in the filter - @param[in] pkCoeffs points to reflection coefficient buffer. The array is of length numStages - @param[in] pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1 - @param[in] pState points to state buffer. The array is of length numStages+blockSize + @param[in] pkCoeffs points to reflection coefficient buffer. The array + is of length numStages + @param[in] pvCoeffs points to ladder coefficient buffer. The array is + of length numStages+1 + @param[in] pState points to state buffer. The array is of length + numStages+blockSize @param[in] blockSize number of samples to process @return none */ -void arm_iir_lattice_init_f32( - arm_iir_lattice_instance_f32 * S, - uint16_t numStages, - float32_t * pkCoeffs, - float32_t * pvCoeffs, - float32_t * pState, - uint32_t blockSize) -{ +void arm_iir_lattice_init_f32(arm_iir_lattice_instance_f32 *S, + uint16_t numStages, float32_t *pkCoeffs, + float32_t *pvCoeffs, float32_t *pState, + uint32_t blockSize) { /* Assign filter taps */ S->numStages = numStages; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_init_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_init_q15.c index 01abf48..c30f99e 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_init_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_init_q15.c @@ -41,21 +41,20 @@ @brief Initialization function for the Q15 IIR lattice filter. @param[in] S points to an instance of the Q15 IIR lattice structure @param[in] numStages number of stages in the filter - @param[in] pkCoeffs points to reflection coefficient buffer. The array is of length numStages - @param[in] pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1 - @param[in] pState points to state buffer. The array is of length numStages+blockSize + @param[in] pkCoeffs points to reflection coefficient buffer. The array is + of length numStages + @param[in] pvCoeffs points to ladder coefficient buffer. The array is of + length numStages+1 + @param[in] pState points to state buffer. The array is of length + numStages+blockSize @param[in] blockSize number of samples to process @return none */ -void arm_iir_lattice_init_q15( - arm_iir_lattice_instance_q15 * S, - uint16_t numStages, - q15_t * pkCoeffs, - q15_t * pvCoeffs, - q15_t * pState, - uint32_t blockSize) -{ +void arm_iir_lattice_init_q15(arm_iir_lattice_instance_q15 *S, + uint16_t numStages, q15_t *pkCoeffs, + q15_t *pvCoeffs, q15_t *pState, + uint32_t blockSize) { /* Assign filter taps */ S->numStages = numStages; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_init_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_init_q31.c index b472f6c..7e89e26 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_init_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_init_q31.c @@ -39,23 +39,23 @@ /** @brief Initialization function for the Q31 IIR lattice filter. - @param[in] S points to an instance of the Q31 IIR lattice structure + @param[in] S points to an instance of the Q31 IIR lattice + structure @param[in] numStages number of stages in the filter - @param[in] pkCoeffs points to reflection coefficient buffer. The array is of length numStages - @param[in] pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1 - @param[in] pState points to state buffer. The array is of length numStages+blockSize + @param[in] pkCoeffs points to reflection coefficient buffer. The array + is of length numStages + @param[in] pvCoeffs points to ladder coefficient buffer. The array is + of length numStages+1 + @param[in] pState points to state buffer. The array is of length + numStages+blockSize @param[in] blockSize number of samples to process @return none */ -void arm_iir_lattice_init_q31( - arm_iir_lattice_instance_q31 * S, - uint16_t numStages, - q31_t * pkCoeffs, - q31_t * pvCoeffs, - q31_t * pState, - uint32_t blockSize) -{ +void arm_iir_lattice_init_q31(arm_iir_lattice_instance_q31 *S, + uint16_t numStages, q31_t *pkCoeffs, + q31_t *pvCoeffs, q31_t *pState, + uint32_t blockSize) { /* Assign filter taps */ S->numStages = numStages; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_q15.c index 9dbea81..72b7004 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_q15.c @@ -39,49 +39,48 @@ /** @brief Processing function for the Q15 IIR lattice filter. - @param[in] S points to an instance of the Q15 IIR lattice structure + @param[in] S points to an instance of the Q15 IIR lattice + structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior - The function is implemented using an internal 64-bit accumulator. - Both coefficients and state variables are represented in 1.15 format and multiplications yield a 2.30 result. - The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. - There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. - After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits. - Lastly, the accumulator is saturated to yield a result in 1.15 format. + The function is implemented using an internal 64-bit + accumulator. Both coefficients and state variables are represented in 1.15 + format and multiplications yield a 2.30 result. The 2.30 intermediate results + are accumulated in a 64-bit accumulator in 34.30 format. There is no risk of + internal overflow with this approach and the full precision of intermediate + multiplications is preserved. After all additions have been performed, the + accumulator is truncated to 34.15 format by discarding low 15 bits. Lastly, + the accumulator is saturated to yield a result in 1.15 format. */ -void arm_iir_lattice_q15( - const arm_iir_lattice_instance_q15 * S, - const q15_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - q15_t *pState = S->pState; /* State pointer */ - q15_t *pStateCur; /* State current pointer */ - q31_t fcurr, fnext = 0, gcurr = 0, gnext; /* Temporary variables for lattice stages */ - q63_t acc; /* Accumlator */ - q15_t *px1, *px2, *pk, *pv; /* Temporary pointers for state and coef */ - uint32_t numStages = S->numStages; /* Number of stages */ - uint32_t blkCnt, tapCnt; /* Temporary variables for counts */ - q15_t out; /* Temporary variable for output */ +void arm_iir_lattice_q15(const arm_iir_lattice_instance_q15 *S, + const q15_t *pSrc, q15_t *pDst, uint32_t blockSize) { + q15_t *pState = S->pState; /* State pointer */ + q15_t *pStateCur; /* State current pointer */ + q31_t fcurr, fnext = 0, gcurr = 0, + gnext; /* Temporary variables for lattice stages */ + q63_t acc; /* Accumlator */ + q15_t *px1, *px2, *pk, *pv; /* Temporary pointers for state and coef */ + uint32_t numStages = S->numStages; /* Number of stages */ + uint32_t blkCnt, tapCnt; /* Temporary variables for counts */ + q15_t out; /* Temporary variable for output */ -#if defined (ARM_MATH_DSP) && defined (ARM_MATH_LOOPUNROLL) - q15_t gnext1, gnext2; /* Temporary variables for lattice stages */ - q31_t v; /* Temporary variable for ladder coefficient */ +#if defined(ARM_MATH_DSP) && defined(ARM_MATH_LOOPUNROLL) + q15_t gnext1, gnext2; /* Temporary variables for lattice stages */ + q31_t v; /* Temporary variable for ladder coefficient */ #endif /* initialise loop count */ blkCnt = blockSize; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* Sample processing */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Read Sample from input buffer */ /* fN(n) = x(n) */ fcurr = *pSrc++; @@ -104,61 +103,59 @@ void arm_iir_lattice_q15( /* Process sample for first tap */ gcurr = *px1++; /* fN-1(n) = fN(n) - kN * gN-1(n-1) */ - fnext = fcurr - (((q31_t) gcurr * (*pk)) >> 15); + fnext = fcurr - (((q31_t)gcurr * (*pk)) >> 15); fnext = __SSAT(fnext, 16); /* gN(n) = kN * fN-1(n) + gN-1(n-1) */ - gnext = (((q31_t) fnext * (*pk++)) >> 15) + gcurr; + gnext = (((q31_t)fnext * (*pk++)) >> 15) + gcurr; gnext = __SSAT(gnext, 16); /* write gN(n) into state for next sample processing */ - *px2++ = (q15_t) gnext; + *px2++ = (q15_t)gnext; /* y(n) += gN(n) * vN */ - acc += (q31_t) ((gnext * (*pv++))); + acc += (q31_t)((gnext * (*pv++))); /* Update f values for next coefficient processing */ fcurr = fnext; - -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = (numStages - 1U) >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Process sample for 2nd, 6th ...taps */ /* Read gN-2(n-1) from state buffer */ gcurr = *px1++; /* fN-2(n) = fN-1(n) - kN-1 * gN-2(n-1) */ - fnext = fcurr - (((q31_t) gcurr * (*pk)) >> 15); + fnext = fcurr - (((q31_t)gcurr * (*pk)) >> 15); fnext = __SSAT(fnext, 16); /* gN-1(n) = kN-1 * fN-2(n) + gN-2(n-1) */ - gnext = (((q31_t) fnext * (*pk++)) >> 15) + gcurr; - gnext1 = (q15_t) __SSAT(gnext, 16); + gnext = (((q31_t)fnext * (*pk++)) >> 15) + gcurr; + gnext1 = (q15_t)__SSAT(gnext, 16); /* write gN-1(n) into state for next sample processing */ - *px2++ = (q15_t) gnext1; + *px2++ = (q15_t)gnext1; /* Process sample for 3nd, 7th ...taps */ /* Read gN-3(n-1) from state buffer */ gcurr = *px1++; /* Process sample for 3rd, 7th .. taps */ /* fN-3(n) = fN-2(n) - kN-2 * gN-3(n-1) */ - fcurr = fnext - (((q31_t) gcurr * (*pk)) >> 15); + fcurr = fnext - (((q31_t)gcurr * (*pk)) >> 15); fcurr = __SSAT(fcurr, 16); /* gN-2(n) = kN-2 * fN-3(n) + gN-3(n-1) */ - gnext = (((q31_t) fcurr * (*pk++)) >> 15) + gcurr; - gnext2 = (q15_t) __SSAT(gnext, 16); + gnext = (((q31_t)fcurr * (*pk++)) >> 15) + gcurr; + gnext2 = (q15_t)__SSAT(gnext, 16); /* write gN-2(n) into state */ - *px2++ = (q15_t) gnext2; + *px2++ = (q15_t)gnext2; /* Read vN-1 and vN-2 at a time */ - v = read_q15x2_ia (&pv); + v = read_q15x2_ia(&pv); /* Pack gN-1(n) and gN-2(n) */ -#ifndef ARM_MATH_BIG_ENDIAN +#ifndef ARM_MATH_BIG_ENDIAN gnext = __PKHBT(gnext1, gnext2, 16); #else gnext = __PKHBT(gnext2, gnext1, 16); @@ -175,29 +172,29 @@ void arm_iir_lattice_q15( gcurr = *px1++; /* Process sample for 4th, 8th .. taps */ /* fN-4(n) = fN-3(n) - kN-3 * gN-4(n-1) */ - fnext = fcurr - (((q31_t) gcurr * (*pk)) >> 15); + fnext = fcurr - (((q31_t)gcurr * (*pk)) >> 15); fnext = __SSAT(fnext, 16); /* gN-3(n) = kN-3 * fN-1(n) + gN-1(n-1) */ - gnext = (((q31_t) fnext * (*pk++)) >> 15) + gcurr; - gnext1 = (q15_t) __SSAT(gnext, 16); + gnext = (((q31_t)fnext * (*pk++)) >> 15) + gcurr; + gnext1 = (q15_t)__SSAT(gnext, 16); /* write gN-3(n) for the next sample process */ - *px2++ = (q15_t) gnext1; + *px2++ = (q15_t)gnext1; /* Process sample for 5th, 9th ...taps */ /* Read gN-5(n-1) from state buffer */ gcurr = *px1++; /* Process sample for 5th, 9th .. taps */ /* fN-5(n) = fN-4(n) - kN-4 * gN-5(n-1) */ - fcurr = fnext - (((q31_t) gcurr * (*pk)) >> 15); + fcurr = fnext - (((q31_t)gcurr * (*pk)) >> 15); fcurr = __SSAT(fcurr, 16); /* gN-4(n) = kN-4 * fN-5(n) + gN-5(n-1) */ - gnext = (((q31_t) fcurr * (*pk++)) >> 15) + gcurr; - gnext2 = (q15_t) __SSAT(gnext, 16); + gnext = (((q31_t)fcurr * (*pk++)) >> 15) + gcurr; + gnext2 = (q15_t)__SSAT(gnext, 16); /* write gN-4(n) for the next sample process */ - *px2++ = (q15_t) gnext2; + *px2++ = (q15_t)gnext2; /* Read vN-3 and vN-4 at a time */ - v = read_q15x2_ia (&pv); + v = read_q15x2_ia(&pv); /* Pack gN-3(n) and gN-4(n) */ #ifndef ARM_MATH_BIG_ENDIAN @@ -228,18 +225,17 @@ void arm_iir_lattice_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { gcurr = *px1++; /* Process sample for last taps */ - fnext = fcurr - (((q31_t) gcurr * (*pk)) >> 15); + fnext = fcurr - (((q31_t)gcurr * (*pk)) >> 15); fnext = __SSAT(fnext, 16); - gnext = (((q31_t) fnext * (*pk++)) >> 15) + gcurr; + gnext = (((q31_t)fnext * (*pk++)) >> 15) + gcurr; gnext = __SSAT(gnext, 16); /* Output samples for last taps */ - acc += (q31_t) (((q31_t) gnext * (*pv++))); - *px2++ = (q15_t) gnext; + acc += (q31_t)(((q31_t)gnext * (*pv++))); + *px2++ = (q15_t)gnext; fcurr = fnext; /* Decrement loop counter */ @@ -247,10 +243,10 @@ void arm_iir_lattice_q15( } /* y(n) += g0(n) * v0 */ - acc += (q31_t) (((q31_t) fnext * (*pv++))); + acc += (q31_t)(((q31_t)fnext * (*pv++))); - out = (q15_t) __SSAT(acc >> 15, 16); - *px2++ = (q15_t) fnext; + out = (q15_t)__SSAT(acc >> 15, 16); + *px2++ = (q15_t)fnext; /* write out into pDst */ *pDst++ = out; @@ -262,23 +258,22 @@ void arm_iir_lattice_q15( blkCnt--; } - /* Processing is complete. Now copy last S->numStages samples to start of the buffer - for the preperation of next frame process */ + /* Processing is complete. Now copy last S->numStages samples to start of the + buffer for the preperation of next frame process */ /* Points to the start of the state buffer */ pStateCur = &S->pState[0]; pState = &S->pState[blockSize]; /* copy data */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numStages >> 2U; - while (tapCnt > 0U) - { - write_q15x2_ia (&pStateCur, read_q15x2_ia (&pState)); - write_q15x2_ia (&pStateCur, read_q15x2_ia (&pState)); + while (tapCnt > 0U) { + write_q15x2_ia(&pStateCur, read_q15x2_ia(&pState)); + write_q15x2_ia(&pStateCur, read_q15x2_ia(&pState)); /* Decrement loop counter */ tapCnt--; @@ -294,8 +289,7 @@ void arm_iir_lattice_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ @@ -305,8 +299,7 @@ void arm_iir_lattice_q15( #else /* #if defined (ARM_MATH_DSP) */ /* Sample processing */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Read Sample from input buffer */ /* fN(n) = x(n) */ fcurr = *pSrc++; @@ -328,8 +321,7 @@ void arm_iir_lattice_q15( tapCnt = numStages; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { gcurr = *px1++; /* Process sample */ /* fN-1(n) = fN(n) - kN * gN-1(n-1) */ @@ -342,10 +334,10 @@ void arm_iir_lattice_q15( /* Output samples */ /* y(n) += gN(n) * vN */ - acc += (q31_t) ((gnext * (*pv++))); + acc += (q31_t)((gnext * (*pv++))); /* write gN(n) into state for next sample processing */ - *px2++ = (q15_t) gnext; + *px2++ = (q15_t)gnext; /* Update f values for next coefficient processing */ fcurr = fnext; @@ -354,10 +346,10 @@ void arm_iir_lattice_q15( } /* y(n) += g0(n) * v0 */ - acc += (q31_t) ((fnext * (*pv++))); + acc += (q31_t)((fnext * (*pv++))); - out = (q15_t) __SSAT(acc >> 15, 16); - *px2++ = (q15_t) fnext; + out = (q15_t)__SSAT(acc >> 15, 16); + *px2++ = (q15_t)fnext; /* write out into pDst */ *pDst++ = out; @@ -369,8 +361,8 @@ void arm_iir_lattice_q15( blkCnt--; } - /* Processing is complete. Now copy last S->numStages samples to start of the buffer - for the preperation of next frame process */ + /* Processing is complete. Now copy last S->numStages samples to start of the + buffer for the preperation of next frame process */ /* Points to the start of the state buffer */ pStateCur = &S->pState[0]; @@ -379,8 +371,7 @@ void arm_iir_lattice_q15( tapCnt = numStages; /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ @@ -388,7 +379,6 @@ void arm_iir_lattice_q15( } #endif /* #if defined (ARM_MATH_DSP) */ - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_q31.c index c4b9a76..9ab77c2 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_iir_lattice_q31.c @@ -39,43 +39,42 @@ /** @brief Processing function for the Q31 IIR lattice filter. - @param[in] S points to an instance of the Q31 IIR lattice structure + @param[in] S points to an instance of the Q31 IIR lattice + structure @param[in] pSrc points to the block of input data @param[out] pDst points to the block of output data @param[in] blockSize number of samples to process @return none @par Scaling and Overflow Behavior - The function is implemented using an internal 64-bit accumulator. - The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. - Thus, if the accumulator result overflows it wraps around rather than clip. - In order to avoid overflows completely the input signal must be scaled down by 2*log2(numStages) bits. - After all multiply-accumulates are performed, the 2.62 accumulator is saturated to 1.32 format and then truncated to 1.31 format. + The function is implemented using an internal 64-bit + accumulator. The accumulator has a 2.62 format and maintains full precision of + the intermediate multiplication results but provides only a single guard bit. + Thus, if the accumulator result overflows it wraps around + rather than clip. In order to avoid overflows completely the input signal must + be scaled down by 2*log2(numStages) bits. After all multiply-accumulates are + performed, the 2.62 accumulator is saturated to 1.32 format and then truncated + to 1.31 format. */ -void arm_iir_lattice_q31( - const arm_iir_lattice_instance_q31 * S, - const q31_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - q31_t *pState = S->pState; /* State pointer */ - q31_t *pStateCur; /* State current pointer */ - q31_t fcurr, fnext = 0, gcurr = 0, gnext; /* Temporary variables for lattice stages */ - q63_t acc; /* Accumlator */ - q31_t *px1, *px2, *pk, *pv; /* Temporary pointers for state and coef */ - uint32_t numStages = S->numStages; /* Number of stages */ - uint32_t blkCnt, tapCnt; /* Temporary variables for counts */ - +void arm_iir_lattice_q31(const arm_iir_lattice_instance_q31 *S, + const q31_t *pSrc, q31_t *pDst, uint32_t blockSize) { + q31_t *pState = S->pState; /* State pointer */ + q31_t *pStateCur; /* State current pointer */ + q31_t fcurr, fnext = 0, gcurr = 0, + gnext; /* Temporary variables for lattice stages */ + q63_t acc; /* Accumlator */ + q31_t *px1, *px2, *pk, *pv; /* Temporary pointers for state and coef */ + uint32_t numStages = S->numStages; /* Number of stages */ + uint32_t blkCnt, tapCnt; /* Temporary variables for counts */ /* initialise loop count */ blkCnt = blockSize; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* Sample processing */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Read Sample from input buffer */ /* fN(n) = x(n) */ fcurr = *pSrc++; @@ -98,38 +97,36 @@ void arm_iir_lattice_q31( /* Process sample for first tap */ gcurr = *px1++; /* fN-1(n) = fN(n) - kN * gN-1(n-1) */ - fnext = __QSUB(fcurr, (q31_t) (((q63_t) gcurr * (*pk )) >> 31)); + fnext = __QSUB(fcurr, (q31_t)(((q63_t)gcurr * (*pk)) >> 31)); /* gN(n) = kN * fN-1(n) + gN-1(n-1) */ - gnext = __QADD(gcurr, (q31_t) (((q63_t) fnext * (*pk++)) >> 31)); + gnext = __QADD(gcurr, (q31_t)(((q63_t)fnext * (*pk++)) >> 31)); /* write gN-1(n-1) into state for next sample processing */ *px2++ = gnext; /* y(n) += gN(n) * vN */ - acc += ((q63_t) gnext * *pv++); + acc += ((q63_t)gnext * *pv++); /* Update f values for next coefficient processing */ fcurr = fnext; - -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = (numStages - 1U) >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Process sample for 2nd, 6th ...taps */ /* Read gN-2(n-1) from state buffer */ gcurr = *px1++; /* fN-2(n) = fN-1(n) - kN-1 * gN-2(n-1) */ - fnext = __QSUB(fcurr, (q31_t) (((q63_t) gcurr * (*pk )) >> 31)); + fnext = __QSUB(fcurr, (q31_t)(((q63_t)gcurr * (*pk)) >> 31)); /* gN-1(n) = kN-1 * fN-2(n) + gN-2(n-1) */ - gnext = __QADD(gcurr, (q31_t) (((q63_t) fnext * (*pk++)) >> 31)); + gnext = __QADD(gcurr, (q31_t)(((q63_t)fnext * (*pk++)) >> 31)); /* y(n) += gN-1(n) * vN-1 */ /* process for gN-5(n) * vN-5, gN-9(n) * vN-9 ... */ - acc += ((q63_t) gnext * *pv++); + acc += ((q63_t)gnext * *pv++); /* write gN-1(n) into state for next sample processing */ *px2++ = gnext; @@ -138,12 +135,12 @@ void arm_iir_lattice_q31( gcurr = *px1++; /* Process sample for 3rd, 7th .. taps */ /* fN-3(n) = fN-2(n) - kN-2 * gN-3(n-1) */ - fcurr = __QSUB(fnext, (q31_t) (((q63_t) gcurr * (*pk )) >> 31)); + fcurr = __QSUB(fnext, (q31_t)(((q63_t)gcurr * (*pk)) >> 31)); /* gN-2(n) = kN-2 * fN-3(n) + gN-3(n-1) */ - gnext = __QADD(gcurr, (q31_t) (((q63_t) fcurr * (*pk++)) >> 31)); + gnext = __QADD(gcurr, (q31_t)(((q63_t)fcurr * (*pk++)) >> 31)); /* y(n) += gN-2(n) * vN-2 */ /* process for gN-6(n) * vN-6, gN-10(n) * vN-10 ... */ - acc += ((q63_t) gnext * *pv++); + acc += ((q63_t)gnext * *pv++); /* write gN-2(n) into state for next sample processing */ *px2++ = gnext; @@ -152,12 +149,12 @@ void arm_iir_lattice_q31( gcurr = *px1++; /* Process sample for 4th, 8th .. taps */ /* fN-4(n) = fN-3(n) - kN-3 * gN-4(n-1) */ - fnext = __QSUB(fcurr, (q31_t) (((q63_t) gcurr * (*pk )) >> 31)); + fnext = __QSUB(fcurr, (q31_t)(((q63_t)gcurr * (*pk)) >> 31)); /* gN-3(n) = kN-3 * fN-4(n) + gN-4(n-1) */ - gnext = __QADD(gcurr, (q31_t) (((q63_t) fnext * (*pk++)) >> 31)); + gnext = __QADD(gcurr, (q31_t)(((q63_t)fnext * (*pk++)) >> 31)); /* y(n) += gN-3(n) * vN-3 */ /* process for gN-7(n) * vN-7, gN-11(n) * vN-11 ... */ - acc += ((q63_t) gnext * *pv++); + acc += ((q63_t)gnext * *pv++); /* write gN-3(n) into state for next sample processing */ *px2++ = gnext; @@ -166,12 +163,12 @@ void arm_iir_lattice_q31( gcurr = *px1++; /* Process sample for 5th, 9th .. taps */ /* fN-5(n) = fN-4(n) - kN-4 * gN-1(n-1) */ - fcurr = __QSUB(fnext, (q31_t) (((q63_t) gcurr * (*pk )) >> 31)); + fcurr = __QSUB(fnext, (q31_t)(((q63_t)gcurr * (*pk)) >> 31)); /* gN-4(n) = kN-4 * fN-5(n) + gN-5(n-1) */ - gnext = __QADD(gcurr, (q31_t) (((q63_t) fcurr * (*pk++)) >> 31)); + gnext = __QADD(gcurr, (q31_t)(((q63_t)fcurr * (*pk++)) >> 31)); /* y(n) += gN-4(n) * vN-4 */ /* process for gN-8(n) * vN-8, gN-12(n) * vN-12 ... */ - acc += ((q63_t) gnext * *pv++); + acc += ((q63_t)gnext * *pv++); /* write gN-4(n) into state for next sample processing */ *px2++ = gnext; @@ -192,15 +189,14 @@ void arm_iir_lattice_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { gcurr = *px1++; /* Process sample for last taps */ - fnext = __QSUB(fcurr, (q31_t) (((q63_t) gcurr * (*pk )) >> 31)); - gnext = __QADD(gcurr, (q31_t) (((q63_t) fnext * (*pk++)) >> 31)); + fnext = __QSUB(fcurr, (q31_t)(((q63_t)gcurr * (*pk)) >> 31)); + gnext = __QADD(gcurr, (q31_t)(((q63_t)fnext * (*pk++)) >> 31)); /* Output samples for last taps */ - acc += ((q63_t) gnext * *pv++); + acc += ((q63_t)gnext * *pv++); *px2++ = gnext; fcurr = fnext; @@ -209,12 +205,12 @@ void arm_iir_lattice_q31( } /* y(n) += g0(n) * v0 */ - acc += ((q63_t) fnext * *pv++); + acc += ((q63_t)fnext * *pv++); *px2++ = fnext; /* write out into pDst */ - *pDst++ = (q31_t) (acc >> 31U); + *pDst++ = (q31_t)(acc >> 31U); /* Advance the state pointer by 4 to process the next group of 4 samples */ pState = pState + 1U; @@ -223,21 +219,20 @@ void arm_iir_lattice_q31( blkCnt--; } - /* Processing is complete. Now copy last S->numStages samples to start of the buffer - for the preperation of next frame process */ + /* Processing is complete. Now copy last S->numStages samples to start of the + buffer for the preperation of next frame process */ /* Points to the start of the state buffer */ pStateCur = &S->pState[0]; pState = &S->pState[blockSize]; /* Copy data */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numStages >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; *pStateCur++ = *pState++; *pStateCur++ = *pState++; @@ -257,8 +252,7 @@ void arm_iir_lattice_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ @@ -268,8 +262,7 @@ void arm_iir_lattice_q31( #else /* #if defined (ARM_MATH_DSP) */ /* Sample processing */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Read Sample from input buffer */ /* fN(n) = x(n) */ fcurr = *pSrc++; @@ -291,19 +284,20 @@ void arm_iir_lattice_q31( tapCnt = numStages; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { gcurr = *px1++; /* Process sample */ /* fN-1(n) = fN(n) - kN * gN-1(n-1) */ - fnext = clip_q63_to_q31(((q63_t) fcurr - ((q31_t) (((q63_t) gcurr * (*pk )) >> 31)))); + fnext = clip_q63_to_q31( + ((q63_t)fcurr - ((q31_t)(((q63_t)gcurr * (*pk)) >> 31)))); /* gN(n) = kN * fN-1(n) + gN-1(n-1) */ - gnext = clip_q63_to_q31(((q63_t) gcurr + ((q31_t) (((q63_t) fnext * (*pk++)) >> 31)))); + gnext = clip_q63_to_q31( + ((q63_t)gcurr + ((q31_t)(((q63_t)fnext * (*pk++)) >> 31)))); /* Output samples */ /* y(n) += gN(n) * vN */ - acc += ((q63_t) gnext * *pv++); + acc += ((q63_t)gnext * *pv++); /* write gN-1(n-1) into state for next sample processing */ *px2++ = gnext; @@ -315,12 +309,12 @@ void arm_iir_lattice_q31( } /* y(n) += g0(n) * v0 */ - acc += ((q63_t) fnext * *pv++); + acc += ((q63_t)fnext * *pv++); *px2++ = fnext; /* write out into pDst */ - *pDst++ = (q31_t) (acc >> 31U); + *pDst++ = (q31_t)(acc >> 31U); /* Advance the state pointer by 1 to process the next group of samples */ pState = pState + 1U; @@ -329,8 +323,8 @@ void arm_iir_lattice_q31( blkCnt--; } - /* Processing is complete. Now copy last S->numStages samples to start of the buffer - for the preperation of next frame process */ + /* Processing is complete. Now copy last S->numStages samples to start of the + buffer for the preperation of next frame process */ /* Points to the start of the state buffer */ pStateCur = &S->pState[0]; @@ -339,8 +333,7 @@ void arm_iir_lattice_q31( tapCnt = numStages; /* Copy data */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCur++ = *pState++; /* Decrement loop counter */ @@ -348,7 +341,6 @@ void arm_iir_lattice_q31( } #endif /* #if defined (ARM_MATH_DSP) */ - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_f32.c index 07a9526..eb5de98 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_f32.c @@ -35,116 +35,135 @@ /** @defgroup LMS Least Mean Square (LMS) Filters - LMS filters are a class of adaptive filters that are able to "learn" an unknown transfer functions. - LMS filters use a gradient descent method in which the filter coefficients are updated based on the instantaneous error signal. - Adaptive filters are often used in communication systems, equalizers, and noise removal. - The CMSIS DSP Library contains LMS filter functions that operate on Q15, Q31, and floating-point data types. - The library also contains normalized LMS filters in which the filter coefficient adaptation is indepedent of the level of the input signal. + LMS filters are a class of adaptive filters that are able to "learn" an + unknown transfer functions. LMS filters use a gradient descent method in which + the filter coefficients are updated based on the instantaneous error signal. + Adaptive filters are often used in communication systems, equalizers, and + noise removal. The CMSIS DSP Library contains LMS filter functions that + operate on Q15, Q31, and floating-point data types. The library also contains + normalized LMS filters in which the filter coefficient adaptation is + indepedent of the level of the input signal. An LMS filter consists of two components as shown below. The first component is a standard transversal or FIR filter. The second component is a coefficient update mechanism. The LMS filter has two input signals. - The "input" feeds the FIR filter while the "reference input" corresponds to the desired output of the FIR filter. - That is, the FIR filter coefficients are updated so that the output of the FIR filter matches the reference input. - The filter coefficient update mechanism is based on the difference between the FIR filter output and the reference input. - This "error signal" tends towards zero as the filter adapts. - The LMS processing functions accept the input and reference input signals and generate the filter output and error signal. + The "input" feeds the FIR filter while the "reference input" corresponds to + the desired output of the FIR filter. That is, the FIR filter coefficients are + updated so that the output of the FIR filter matches the reference input. The + filter coefficient update mechanism is based on the difference between the FIR + filter output and the reference input. This "error signal" tends towards zero + as the filter adapts. The LMS processing functions accept the input and + reference input signals and generate the filter output and error signal. \image html LMS.gif "Internal structure of the Least Mean Square filter" - The functions operate on blocks of data and each call to the function processes - blockSize samples through the filter. - pSrc points to input signal, pRef points to reference signal, - pOut points to output signal and pErr points to error signal. - All arrays contain blockSize values. + The functions operate on blocks of data and each call to the function + processes blockSize samples through the filter. pSrc + points to input signal, pRef points to reference signal, + pOut points to output signal and pErr points to + error signal. All arrays contain blockSize values. The functions operate on a block-by-block basis. - Internally, the filter coefficients b[n] are updated on a sample-by-sample basis. - The convergence of the LMS filter is slower compared to the normalized LMS algorithm. + Internally, the filter coefficients b[n] are updated on a + sample-by-sample basis. The convergence of the LMS filter is slower compared + to the normalized LMS algorithm. @par Algorithm - The output signal y[n] is computed by a standard FIR filter: -
-      y[n] = b[0] * x[n] + b[1] * x[n-1] + b[2] * x[n-2] + ...+ b[numTaps-1] * x[n-numTaps+1]
+                   The output signal y[n] is computed by a standard
+  FIR filter: 
 y[n] = b[0] * x[n] + b[1] * x[n-1] + b[2] * x[n-2] + ...+
+  b[numTaps-1] * x[n-numTaps+1]
   
@par - The error signal equals the difference between the reference signal d[n] and the filter output: -
-      e[n] = d[n] - y[n].
+                   The error signal equals the difference between the reference
+  signal d[n] and the filter output: 
 e[n] = d[n] - y[n].
   
@par - After each sample of the error signal is computed, the filter coefficients b[k] are updated on a sample-by-sample basis: -
+                   After each sample of the error signal is computed, the filter
+  coefficients b[k] are updated on a sample-by-sample basis: 
       b[k] = b[k] + e[n] * mu * x[n-k],  for k=0, 1, ..., numTaps-1
   
- where mu is the step size and controls the rate of coefficient convergence. + where mu is the step size and controls the rate + of coefficient convergence. @par - In the APIs, pCoeffs points to a coefficient array of size numTaps. - Coefficients are stored in time reversed order. + In the APIs, pCoeffs points to a coefficient + array of size numTaps. Coefficients are stored in time reversed + order. @par
      {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
   
@par - pState points to a state array of size numTaps + blockSize - 1. - Samples in the state buffer are stored in the order: + pState points to a state array of size + numTaps + blockSize - 1. Samples in the state buffer are stored + in the order: @par
-     {x[n-numTaps+1], x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2]....x[0], x[1], ..., x[blockSize-1]}
+     {x[n-numTaps+1], x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2]....x[0],
+  x[1], ..., x[blockSize-1]}
   
@par - Note that the length of the state buffer exceeds the length of the coefficient array by blockSize-1 samples. - The increased state buffer length allows circular addressing, which is traditionally used in FIR filters, - to be avoided and yields a significant speed improvement. - The state variables are updated after each block of data is processed. + Note that the length of the state buffer exceeds the length + of the coefficient array by blockSize-1 samples. The increased + state buffer length allows circular addressing, which is traditionally used in + FIR filters, to be avoided and yields a significant speed improvement. The + state variables are updated after each block of data is processed. @par Instance Structure - The coefficients and state variables for a filter are stored together in an instance data structure. - A separate instance structure must be defined for each filter and - coefficient and state arrays cannot be shared among instances. - There are separate instance structure declarations for each of the 3 supported data types. + The coefficients and state variables for a filter are stored + together in an instance data structure. A separate instance structure must be + defined for each filter and coefficient and state arrays cannot be shared + among instances. There are separate instance structure declarations for each + of the 3 supported data types. @par Initialization Functions - There is also an associated initialization function for each data type. - The initialization function performs the following operations: + There is also an associated initialization function for each + data type. The initialization function performs the following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. - To do this manually without calling the init function, assign the follow subfields of the instance structure: - numTaps, pCoeffs, mu, postShift (not for f32), pState. Also set all of the values in pState to zero. + To do this manually without calling the init function, assign + the follow subfields of the instance structure: numTaps, pCoeffs, mu, + postShift (not for f32), pState. Also set all of the values in pState to zero. @par Use of the initialization function is optional. - However, if the initialization function is used, then the instance structure cannot be placed into a const data section. - To place an instance structure into a const data section, the instance structure must be manually initialized. - Set the values in the state buffer to zeros before static initialization. - The code below statically initializes each of the 3 different data type filter instance structures -
-     arm_lms_instance_f32 S = {numTaps, pState, pCoeffs, mu};
-     arm_lms_instance_q31 S = {numTaps, pState, pCoeffs, mu, postShift};
-     arm_lms_instance_q15 S = {numTaps, pState, pCoeffs, mu, postShift};
+                 However, if the initialization function is used, then the
+  instance structure cannot be placed into a const data section. To place an
+  instance structure into a const data section, the instance structure must be
+  manually initialized. Set the values in the state buffer to zeros before
+  static initialization. The code below statically initializes each of the 3
+  different data type filter instance structures 
 arm_lms_instance_f32 S =
+  {numTaps, pState, pCoeffs, mu}; arm_lms_instance_q31 S = {numTaps, pState,
+  pCoeffs, mu, postShift}; arm_lms_instance_q15 S = {numTaps, pState, pCoeffs,
+  mu, postShift};
   
- where numTaps is the number of filter coefficients in the filter; pState is the address of the state buffer; - pCoeffs is the address of the coefficient buffer; mu is the step size parameter; and postShift is the shift applied to coefficients. + where numTaps is the number of filter coefficients + in the filter; pState is the address of the state buffer; + pCoeffs is the address of the coefficient buffer; + mu is the step size parameter; and postShift is the + shift applied to coefficients. @par Fixed-Point Behavior - Care must be taken when using the Q15 and Q31 versions of the LMS filter. - The following issues must be considered: + Care must be taken when using the Q15 and Q31 versions of the + LMS filter. The following issues must be considered: - Scaling of coefficients - Overflow and saturation @par Scaling of Coefficients Filter coefficients are represented as fractional values and - coefficients are restricted to lie in the range [-1 +1). - The fixed-point functions have an additional scaling parameter postShift. - At the output of the filter's accumulator is a shift register which shifts the result by postShift bits. - This essentially scales the filter coefficients by 2^postShift and - allows the filter coefficients to exceed the range [+1 -1). - The value of postShift is set by the user based on the expected gain through the system being modeled. + coefficients are restricted to lie in the range [-1 + +1). The fixed-point functions have an additional scaling parameter + postShift. At the output of the filter's accumulator is a shift + register which shifts the result by postShift bits. This + essentially scales the filter coefficients by 2^postShift and + allows the filter coefficients to exceed the range [+1 + -1). The value of postShift is set by the user based on + the expected gain through the system being modeled. @par Overflow and Saturation - Overflow and saturation behavior of the fixed-point Q15 and Q31 versions are - described separately as part of the function specific documentation below. + Overflow and saturation behavior of the fixed-point Q15 and + Q31 versions are described separately as part of the function specific + documentation below. */ /** @@ -154,7 +173,8 @@ /** @brief Processing function for floating-point LMS filter. - @param[in] S points to an instance of the floating-point LMS filter structure + @param[in] S points to an instance of the floating-point LMS + filter structure @param[in] pSrc points to the block of input data @param[in] pRef points to the block of reference data @param[out] pOut points to the block of output data @@ -163,37 +183,34 @@ @return none */ -void arm_lms_f32( - const arm_lms_instance_f32 * S, - const float32_t * pSrc, - float32_t * pRef, - float32_t * pOut, - float32_t * pErr, - uint32_t blockSize) -{ - float32_t *pState = S->pState; /* State pointer */ - float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - float32_t *pStateCurnt; /* Points to the current sample of the state */ - float32_t *px, *pb; /* Temporary pointers for state and coefficient buffers */ - float32_t mu = S->mu; /* Adaptive factor */ - float32_t acc, e; /* Accumulator, error */ - float32_t w; /* Weight factor */ - uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ - uint32_t tapCnt, blkCnt; /* Loop counters */ +void arm_lms_f32(const arm_lms_instance_f32 *S, const float32_t *pSrc, + float32_t *pRef, float32_t *pOut, float32_t *pErr, + uint32_t blockSize) { + float32_t *pState = S->pState; /* State pointer */ + float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + float32_t *pStateCurnt; /* Points to the current sample of the state */ + float32_t *px, *pb; /* Temporary pointers for state and coefficient buffers */ + float32_t mu = S->mu; /* Adaptive factor */ + float32_t acc, e; /* Accumulator, error */ + float32_t w; /* Weight factor */ + uint32_t numTaps = + S->numTaps; /* Number of filter coefficients in the filter */ + uint32_t tapCnt, blkCnt; /* Loop counters */ /* Initializations of error, difference, Coefficient update */ e = 0.0f; w = 0.0f; - /* S->pState points to state array which contains previous frame (numTaps - 1) samples */ - /* pStateCurnt points to the location where the new input data should be written */ + /* S->pState points to state array which contains previous frame (numTaps - 1) + * samples */ + /* pStateCurnt points to the location where the new input data should be + * written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); /* initialise loop count */ blkCnt = blockSize; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy the new input sample into the state buffer */ *pStateCurnt++ = *pSrc++; @@ -206,13 +223,12 @@ void arm_lms_f32( /* Set the accumulator to zero */ acc = 0.0f; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ acc += (*px++) * (*pb++); @@ -236,8 +252,7 @@ void arm_lms_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ acc += (*px++) * (*pb++); @@ -249,7 +264,7 @@ void arm_lms_f32( *pOut++ = acc; /* Compute and store error */ - e = (float32_t) *pRef++ - acc; + e = (float32_t)*pRef++ - acc; *pErr++ = e; /* Calculation of Weighting factor for updating filter coefficients */ @@ -262,14 +277,13 @@ void arm_lms_f32( /* Initialize coefficient pointer */ pb = pCoeffs; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; /* Update filter coefficients */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ *pb += w * (*px++); pb++; @@ -297,8 +311,7 @@ void arm_lms_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ *pb += w * (*px++); pb++; @@ -319,13 +332,12 @@ void arm_lms_f32( pStateCurnt = S->pState; /* copy data */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = (numTaps - 1U) >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; @@ -345,14 +357,12 @@ void arm_lms_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_init_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_init_f32.c index f418f46..6c213d3 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_init_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_init_f32.c @@ -35,7 +35,8 @@ /** @brief Initialization function for floating-point LMS filter. - @param[in] S points to an instance of the floating-point LMS filter structure + @param[in] S points to an instance of the floating-point LMS + filter structure @param[in] numTaps number of filter coefficients @param[in] pCoeffs points to coefficient buffer @param[in] pState points to state buffer @@ -44,22 +45,19 @@ @return none @par Details - pCoeffs points to the array of filter coefficients stored in time reversed order: -
-     {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
+                   pCoeffs points to the array of filter
+  coefficients stored in time reversed order: 
 {b[numTaps-1], b[numTaps-2],
+  b[N-2], ..., b[1], b[0]}
   
- The initial filter coefficients serve as a starting point for the adaptive filter. - pState points to an array of length numTaps+blockSize-1 samples, where blockSize is the number of input samples processed by each call to arm_lms_f32(). + The initial filter coefficients serve as a starting point for + the adaptive filter. pState points to an array of length + numTaps+blockSize-1 samples, where blockSize is the + number of input samples processed by each call to arm_lms_f32(). */ -void arm_lms_init_f32( - arm_lms_instance_f32 * S, - uint16_t numTaps, - float32_t * pCoeffs, - float32_t * pState, - float32_t mu, - uint32_t blockSize) -{ +void arm_lms_init_f32(arm_lms_instance_f32 *S, uint16_t numTaps, + float32_t *pCoeffs, float32_t *pState, float32_t mu, + uint32_t blockSize) { /* Assign filter taps */ S->numTaps = numTaps; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_init_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_init_q15.c index fe0a5c5..f831917 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_init_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_init_q15.c @@ -39,7 +39,8 @@ /** @brief Initialization function for the Q15 LMS filter. - @param[in] S points to an instance of the Q15 LMS filter structure. + @param[in] S points to an instance of the Q15 LMS filter + structure. @param[in] numTaps number of filter coefficients. @param[in] pCoeffs points to coefficient buffer. @param[in] pState points to state buffer. @@ -49,25 +50,20 @@ @return none @par Details - pCoeffs points to the array of filter coefficients stored in time reversed order: -
-     {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
+                   pCoeffs points to the array of filter
+  coefficients stored in time reversed order: 
 {b[numTaps-1], b[numTaps-2],
+  b[N-2], ..., b[1], b[0]}
   
- The initial filter coefficients serve as a starting point for the adaptive filter. - pState points to the array of state variables and size of array is - numTaps+blockSize-1 samples, where blockSize is the number of - input samples processed by each call to arm_lms_q15(). + The initial filter coefficients serve as a starting point for + the adaptive filter. pState points to the array of state + variables and size of array is numTaps+blockSize-1 samples, where + blockSize is the number of input samples processed by each call + to arm_lms_q15(). */ -void arm_lms_init_q15( - arm_lms_instance_q15 * S, - uint16_t numTaps, - q15_t * pCoeffs, - q15_t * pState, - q15_t mu, - uint32_t blockSize, - uint32_t postShift) -{ +void arm_lms_init_q15(arm_lms_instance_q15 *S, uint16_t numTaps, q15_t *pCoeffs, + q15_t *pState, q15_t mu, uint32_t blockSize, + uint32_t postShift) { /* Assign filter taps */ S->numTaps = numTaps; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_init_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_init_q31.c index 3410b9f..df6dbbc 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_init_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_init_q31.c @@ -39,7 +39,8 @@ /** @brief Initialization function for Q31 LMS filter. - @param[in] S points to an instance of the Q31 LMS filter structure + @param[in] S points to an instance of the Q31 LMS filter + structure @param[in] numTaps number of filter coefficients @param[in] pCoeffs points to coefficient buffer @param[in] pState points to state buffer @@ -49,25 +50,19 @@ @return none @par Details - pCoeffs points to the array of filter coefficients stored in time reversed order: -
-     {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
+                   pCoeffs points to the array of filter
+  coefficients stored in time reversed order: 
 {b[numTaps-1], b[numTaps-2],
+  b[N-2], ..., b[1], b[0]}
   
- The initial filter coefficients serve as a starting point for the adaptive filter. - pState points to an array of length numTaps+blockSize-1 samples, - where blockSize is the number of input samples processed by each call to - arm_lms_q31(). + The initial filter coefficients serve as a starting point for + the adaptive filter. pState points to an array of length + numTaps+blockSize-1 samples, where blockSize is the + number of input samples processed by each call to arm_lms_q31(). */ -void arm_lms_init_q31( - arm_lms_instance_q31 * S, - uint16_t numTaps, - q31_t * pCoeffs, - q31_t * pState, - q31_t mu, - uint32_t blockSize, - uint32_t postShift) -{ +void arm_lms_init_q31(arm_lms_instance_q31 *S, uint16_t numTaps, q31_t *pCoeffs, + q31_t *pState, q31_t mu, uint32_t blockSize, + uint32_t postShift) { /* Assign filter taps */ S->numTaps = numTaps; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_f32.c index 5ae9229..5492a79 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_f32.c @@ -36,108 +36,121 @@ @defgroup LMS_NORM Normalized LMS Filters This set of functions implements a commonly used adaptive filter. - It is related to the Least Mean Square (LMS) adaptive filter and includes an additional normalization - factor which increases the adaptation rate of the filter. - The CMSIS DSP Library contains normalized LMS filter functions that operate on Q15, Q31, and floating-point data types. + It is related to the Least Mean Square (LMS) adaptive filter and includes an + additional normalization factor which increases the adaptation rate of the + filter. The CMSIS DSP Library contains normalized LMS filter functions that + operate on Q15, Q31, and floating-point data types. - A normalized least mean square (NLMS) filter consists of two components as shown below. - The first component is a standard transversal or FIR filter. - The second component is a coefficient update mechanism. - The NLMS filter has two input signals. - The "input" feeds the FIR filter while the "reference input" corresponds to the desired output of the FIR filter. - That is, the FIR filter coefficients are updated so that the output of the FIR filter matches the reference input. - The filter coefficient update mechanism is based on the difference between the FIR filter output and the reference input. - This "error signal" tends towards zero as the filter adapts. - The NLMS processing functions accept the input and reference input signals and generate the filter output and error signal. - \image html LMS.gif "Internal structure of the NLMS adaptive filter" + A normalized least mean square (NLMS) filter consists of two components as + shown below. The first component is a standard transversal or FIR filter. The + second component is a coefficient update mechanism. The NLMS filter has two + input signals. The "input" feeds the FIR filter while the "reference input" + corresponds to the desired output of the FIR filter. That is, the FIR filter + coefficients are updated so that the output of the FIR filter matches the + reference input. The filter coefficient update mechanism is based on the + difference between the FIR filter output and the reference input. This "error + signal" tends towards zero as the filter adapts. The NLMS processing functions + accept the input and reference input signals and generate the filter output and + error signal. \image html LMS.gif "Internal structure of the NLMS adaptive + filter" - The functions operate on blocks of data and each call to the function processes - blockSize samples through the filter. - pSrc points to input signal, pRef points to reference signal, - pOut points to output signal and pErr points to error signal. - All arrays contain blockSize values. + The functions operate on blocks of data and each call to the function + processes blockSize samples through the filter. pSrc + points to input signal, pRef points to reference signal, + pOut points to output signal and pErr points to + error signal. All arrays contain blockSize values. The functions operate on a block-by-block basis. - Internally, the filter coefficients b[n] are updated on a sample-by-sample basis. - The convergence of the LMS filter is slower compared to the normalized LMS algorithm. + Internally, the filter coefficients b[n] are updated on a + sample-by-sample basis. The convergence of the LMS filter is slower compared to + the normalized LMS algorithm. @par Algorithm - The output signal y[n] is computed by a standard FIR filter: -
-      y[n] = b[0] * x[n] + b[1] * x[n-1] + b[2] * x[n-2] + ...+ b[numTaps-1] * x[n-numTaps+1]
+                   The output signal y[n] is computed by a standard
+ FIR filter: 
 y[n] = b[0] * x[n] + b[1] * x[n-1] + b[2] * x[n-2] + ...+
+ b[numTaps-1] * x[n-numTaps+1]
   
@par - The error signal equals the difference between the reference signal d[n] and the filter output: -
-      e[n] = d[n] - y[n].
+                   The error signal equals the difference between the reference
+ signal d[n] and the filter output: 
 e[n] = d[n] - y[n].
   
@par - After each sample of the error signal is computed the instanteous energy of the filter state variables is calculated: -
-     E = x[n]^2 + x[n-1]^2 + ... + x[n-numTaps+1]^2.
+                   After each sample of the error signal is computed the
+ instanteous energy of the filter state variables is calculated: 
 E =
+ x[n]^2 + x[n-1]^2 + ... + x[n-numTaps+1]^2.
   
- The filter coefficients b[k] are then updated on a sample-by-sample basis: -
-      b[k] = b[k] + e[n] * (mu/E) * x[n-k],  for k=0, 1, ..., numTaps-1
+                   The filter coefficients b[k] are then updated on
+ a sample-by-sample basis: 
 b[k] = b[k] + e[n] * (mu/E) * x[n-k],  for k=0,
+ 1, ..., numTaps-1
   
- where mu is the step size and controls the rate of coefficient convergence. + where mu is the step size and controls the rate + of coefficient convergence. @par - In the APIs, pCoeffs points to a coefficient array of size numTaps. - Coefficients are stored in time reversed order. + In the APIs, pCoeffs points to a coefficient + array of size numTaps. Coefficients are stored in time reversed + order. @par
      {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
   
@par - pState points to a state array of size numTaps + blockSize - 1. - Samples in the state buffer are stored in the order: + pState points to a state array of size + numTaps + blockSize - 1. Samples in the state buffer are stored in + the order: @par
-     {x[n-numTaps+1], x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2]....x[0], x[1], ..., x[blockSize-1]}
+     {x[n-numTaps+1], x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2]....x[0],
+ x[1], ..., x[blockSize-1]}
   
@par - Note that the length of the state buffer exceeds the length of the coefficient array by blockSize-1 samples. - The increased state buffer length allows circular addressing, which is traditionally used in FIR filters, - to be avoided and yields a significant speed improvement. - The state variables are updated after each block of data is processed. + Note that the length of the state buffer exceeds the length + of the coefficient array by blockSize-1 samples. The increased + state buffer length allows circular addressing, which is traditionally used in + FIR filters, to be avoided and yields a significant speed improvement. The + state variables are updated after each block of data is processed. @par Instance Structure - The coefficients and state variables for a filter are stored together in an instance data structure. - A separate instance structure must be defined for each filter and - coefficient and state arrays cannot be shared among instances. - There are separate instance structure declarations for each of the 3 supported data types. + The coefficients and state variables for a filter are stored + together in an instance data structure. A separate instance structure must be + defined for each filter and coefficient and state arrays cannot be shared among + instances. There are separate instance structure declarations for each of the 3 + supported data types. @par Initialization Functions - There is also an associated initialization function for each data type. - The initialization function performs the following operations: + There is also an associated initialization function for each + data type. The initialization function performs the following operations: - Sets the values of the internal structure fields. - Zeros out the values in the state buffer. - To do this manually without calling the init function, assign the follow subfields of the instance structure: - numTaps, pCoeffs, mu, energy, x0, pState. Also set all of the values in pState to zero. - For Q7, Q15, and Q31 the following fields must also be initialized; - recipTable, postShift + To do this manually without calling the init function, assign + the follow subfields of the instance structure: numTaps, pCoeffs, mu, energy, + x0, pState. Also set all of the values in pState to zero. For Q7, Q15, and Q31 + the following fields must also be initialized; recipTable, postShift @par - Instance structure cannot be placed into a const data section and it is recommended to use the initialization function. + Instance structure cannot be placed into a const data section + and it is recommended to use the initialization function. @par Fixed-Point Behavior - Care must be taken when using the Q15 and Q31 versions of the normalised LMS filter. - The following issues must be considered: + Care must be taken when using the Q15 and Q31 versions of the + normalised LMS filter. The following issues must be considered: - Scaling of coefficients - Overflow and saturation @par Scaling of Coefficients Filter coefficients are represented as fractional values and - coefficients are restricted to lie in the range [-1 +1). - The fixed-point functions have an additional scaling parameter postShift. - At the output of the filter's accumulator is a shift register which shifts the result by postShift bits. - This essentially scales the filter coefficients by 2^postShift and - allows the filter coefficients to exceed the range [+1 -1). - The value of postShift is set by the user based on the expected gain through the system being modeled. + coefficients are restricted to lie in the range [-1 + +1). The fixed-point functions have an additional scaling parameter + postShift. At the output of the filter's accumulator is a shift + register which shifts the result by postShift bits. This + essentially scales the filter coefficients by 2^postShift and + allows the filter coefficients to exceed the range [+1 + -1). The value of postShift is set by the user based on the + expected gain through the system being modeled. @par Overflow and Saturation - Overflow and saturation behavior of the fixed-point Q15 and Q31 versions are - described separately as part of the function specific documentation below. + Overflow and saturation behavior of the fixed-point Q15 and + Q31 versions are described separately as part of the function specific + documentation below. */ /** @@ -147,7 +160,8 @@ /** @brief Processing function for floating-point normalized LMS filter. - @param[in] S points to an instance of the floating-point normalized LMS filter structure + @param[in] S points to an instance of the floating-point + normalized LMS filter structure @param[in] pSrc points to the block of input data @param[in] pRef points to the block of reference data @param[out] pOut points to the block of output data @@ -156,25 +170,21 @@ @return none */ -void arm_lms_norm_f32( - arm_lms_norm_instance_f32 * S, - const float32_t * pSrc, - float32_t * pRef, - float32_t * pOut, - float32_t * pErr, - uint32_t blockSize) -{ - float32_t *pState = S->pState; /* State pointer */ - float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - float32_t *pStateCurnt; /* Points to the current sample of the state */ - float32_t *px, *pb; /* Temporary pointers for state and coefficient buffers */ - float32_t mu = S->mu; /* Adaptive factor */ - float32_t acc, e; /* Accumulator, error */ - float32_t w; /* Weight factor */ - uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ - uint32_t tapCnt, blkCnt; /* Loop counters */ - float32_t energy; /* Energy of the input */ - float32_t x0, in; /* Temporary variable to hold input sample and state */ +void arm_lms_norm_f32(arm_lms_norm_instance_f32 *S, const float32_t *pSrc, + float32_t *pRef, float32_t *pOut, float32_t *pErr, + uint32_t blockSize) { + float32_t *pState = S->pState; /* State pointer */ + float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + float32_t *pStateCurnt; /* Points to the current sample of the state */ + float32_t *px, *pb; /* Temporary pointers for state and coefficient buffers */ + float32_t mu = S->mu; /* Adaptive factor */ + float32_t acc, e; /* Accumulator, error */ + float32_t w; /* Weight factor */ + uint32_t numTaps = + S->numTaps; /* Number of filter coefficients in the filter */ + uint32_t tapCnt, blkCnt; /* Loop counters */ + float32_t energy; /* Energy of the input */ + float32_t x0, in; /* Temporary variable to hold input sample and state */ /* Initializations of error, difference, Coefficient update */ e = 0.0f; @@ -183,15 +193,16 @@ void arm_lms_norm_f32( energy = S->energy; x0 = S->x0; - /* S->pState points to buffer which contains previous frame (numTaps - 1) samples */ - /* pStateCurnt points to the location where the new input data should be written */ + /* S->pState points to buffer which contains previous frame (numTaps - 1) + * samples */ + /* pStateCurnt points to the location where the new input data should be + * written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); /* initialise loop count */ blkCnt = blockSize; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy the new input sample into the state buffer */ *pStateCurnt++ = *pSrc; @@ -211,13 +222,12 @@ void arm_lms_norm_f32( /* Set the accumulator to zero */ acc = 0.0f; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ acc += (*px++) * (*pb++); @@ -241,8 +251,7 @@ void arm_lms_norm_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ acc += (*px++) * (*pb++); @@ -254,7 +263,7 @@ void arm_lms_norm_f32( *pOut++ = acc; /* Compute and store error */ - e = (float32_t) *pRef++ - acc; + e = (float32_t)*pRef++ - acc; *pErr++ = e; /* Calculation of Weighting factor for updating filter coefficients */ @@ -267,14 +276,13 @@ void arm_lms_norm_f32( /* Initialize coefficient pointer */ pb = pCoeffs; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; /* Update filter coefficients */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ *pb += w * (*px++); pb++; @@ -302,8 +310,7 @@ void arm_lms_norm_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ *pb += w * (*px++); pb++; @@ -333,13 +340,12 @@ void arm_lms_norm_f32( pStateCurnt = S->pState; /* copy data */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = (numTaps - 1U) >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; @@ -359,14 +365,12 @@ void arm_lms_norm_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_init_f32.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_init_f32.c index 543dc72..ed1fd83 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_init_f32.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_init_f32.c @@ -38,8 +38,10 @@ */ /** - @brief Initialization function for floating-point normalized LMS filter. - @param[in] S points to an instance of the floating-point LMS filter structure + @brief Initialization function for floating-point normalized LMS + filter. + @param[in] S points to an instance of the floating-point LMS + filter structure @param[in] numTaps number of filter coefficients @param[in] pCoeffs points to coefficient buffer @param[in] pState points to state buffer @@ -48,23 +50,20 @@ @return none @par Details - pCoeffs points to the array of filter coefficients stored in time reversed order: -
-     {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
+                   pCoeffs points to the array of filter
+  coefficients stored in time reversed order: 
 {b[numTaps-1], b[numTaps-2],
+  b[N-2], ..., b[1], b[0]}
   
- The initial filter coefficients serve as a starting point for the adaptive filter. - pState points to an array of length numTaps+blockSize-1 samples, - where blockSize is the number of input samples processed by each call to arm_lms_norm_f32(). + The initial filter coefficients serve as a starting point for + the adaptive filter. pState points to an array of length + numTaps+blockSize-1 samples, where blockSize is the + number of input samples processed by each call to + arm_lms_norm_f32(). */ -void arm_lms_norm_init_f32( - arm_lms_norm_instance_f32 * S, - uint16_t numTaps, - float32_t * pCoeffs, - float32_t * pState, - float32_t mu, - uint32_t blockSize) -{ +void arm_lms_norm_init_f32(arm_lms_norm_instance_f32 *S, uint16_t numTaps, + float32_t *pCoeffs, float32_t *pState, float32_t mu, + uint32_t blockSize) { /* Assign filter taps */ S->numTaps = numTaps; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_init_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_init_q15.c index d581ac1..c2532de 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_init_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_init_q15.c @@ -26,8 +26,8 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @addtogroup LMS_NORM @@ -36,7 +36,8 @@ /** @brief Initialization function for Q15 normalized LMS filter. - @param[in] S points to an instance of the Q15 normalized LMS filter structure. + @param[in] S points to an instance of the Q15 normalized LMS + filter structure. @param[in] numTaps number of filter coefficients. @param[in] pCoeffs points to coefficient buffer. @param[in] pState points to state buffer. @@ -46,25 +47,20 @@ @return none @par Details - pCoeffs points to the array of filter coefficients stored in time reversed order: -
-     {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
+                   pCoeffs points to the array of filter
+  coefficients stored in time reversed order: 
 {b[numTaps-1], b[numTaps-2],
+  b[N-2], ..., b[1], b[0]}
   
- The initial filter coefficients serve as a starting point for the adaptive filter. - pState points to the array of state variables and size of array is - numTaps+blockSize-1 samples, where blockSize is the number of input samples processed - by each call to arm_lms_norm_q15(). + The initial filter coefficients serve as a starting point for + the adaptive filter. pState points to the array of state + variables and size of array is numTaps+blockSize-1 samples, where + blockSize is the number of input samples processed by each call + to arm_lms_norm_q15(). */ -void arm_lms_norm_init_q15( - arm_lms_norm_instance_q15 * S, - uint16_t numTaps, - q15_t * pCoeffs, - q15_t * pState, - q15_t mu, - uint32_t blockSize, - uint8_t postShift) -{ +void arm_lms_norm_init_q15(arm_lms_norm_instance_q15 *S, uint16_t numTaps, + q15_t *pCoeffs, q15_t *pState, q15_t mu, + uint32_t blockSize, uint8_t postShift) { /* Assign filter taps */ S->numTaps = numTaps; @@ -84,7 +80,7 @@ void arm_lms_norm_init_q15( S->mu = mu; /* Initialize reciprocal pointer table */ - S->recipTable = (q15_t *) armRecipTableQ15; + S->recipTable = (q15_t *)armRecipTableQ15; /* Initialise Energy to zero */ S->energy = 0; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_init_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_init_q31.c index 30e78ec..98262f1 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_init_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_init_q31.c @@ -26,8 +26,8 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @addtogroup LMS_NORM @@ -36,7 +36,8 @@ /** @brief Initialization function for Q31 normalized LMS filter. - @param[in] S points to an instance of the Q31 normalized LMS filter structure. + @param[in] S points to an instance of the Q31 normalized LMS + filter structure. @param[in] numTaps number of filter coefficients. @param[in] pCoeffs points to coefficient buffer. @param[in] pState points to state buffer. @@ -46,24 +47,20 @@ @return none @par Details - pCoeffs points to the array of filter coefficients stored in time reversed order: -
-     {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
+                   pCoeffs points to the array of filter
+  coefficients stored in time reversed order: 
 {b[numTaps-1], b[numTaps-2],
+  b[N-2], ..., b[1], b[0]}
   
- The initial filter coefficients serve as a starting point for the adaptive filter. - pState points to an array of length numTaps+blockSize-1 samples, - where blockSize is the number of input samples processed by each call to arm_lms_norm_q31(). + The initial filter coefficients serve as a starting point for + the adaptive filter. pState points to an array of length + numTaps+blockSize-1 samples, where blockSize is the + number of input samples processed by each call to + arm_lms_norm_q31(). */ -void arm_lms_norm_init_q31( - arm_lms_norm_instance_q31 * S, - uint16_t numTaps, - q31_t * pCoeffs, - q31_t * pState, - q31_t mu, - uint32_t blockSize, - uint8_t postShift) -{ +void arm_lms_norm_init_q31(arm_lms_norm_instance_q31 *S, uint16_t numTaps, + q31_t *pCoeffs, q31_t *pState, q31_t mu, + uint32_t blockSize, uint8_t postShift) { /* Assign filter taps */ S->numTaps = numTaps; @@ -83,7 +80,7 @@ void arm_lms_norm_init_q31( S->mu = mu; /* Initialize reciprocal pointer table */ - S->recipTable = (q31_t *) armRecipTableQ31; + S->recipTable = (q31_t *)armRecipTableQ31; /* Initialise Energy to zero */ S->energy = 0; diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_q15.c index c15ad5e..7f0c5b5 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_q15.c @@ -39,7 +39,8 @@ /** @brief Processing function for Q15 normalized LMS filter. - @param[in] S points to an instance of the Q15 normalized LMS filter structure + @param[in] S points to an instance of the Q15 normalized LMS + filter structure @param[in] pSrc points to the block of input data @param[in] pRef points to the block of reference data @param[out] pOut points to the block of output data @@ -48,59 +49,57 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using a 64-bit internal accumulator. - Both coefficients and state variables are represented in 1.15 format and - multiplications yield a 2.30 result. The 2.30 intermediate results are - accumulated in a 64-bit accumulator in 34.30 format. - There is no risk of internal overflow with this approach and the full - precision of intermediate multiplications is preserved. After all additions - have been performed, the accumulator is truncated to 34.15 format by - discarding low 15 bits. Lastly, the accumulator is saturated to yield a - result in 1.15 format. + The function is implemented using a 64-bit internal + accumulator. Both coefficients and state variables are represented in 1.15 + format and multiplications yield a 2.30 result. The 2.30 intermediate results + are accumulated in a 64-bit accumulator in 34.30 format. There is no risk of + internal overflow with this approach and the full precision of intermediate + multiplications is preserved. After all additions have been performed, the + accumulator is truncated to 34.15 format by discarding low 15 bits. Lastly, the + accumulator is saturated to yield a result in 1.15 format. @par - In this filter, filter coefficients are updated for each sample and the - updation of filter cofficients are saturted. + In this filter, filter coefficients are updated for each + sample and the updation of filter cofficients are saturted. */ -void arm_lms_norm_q15( - arm_lms_norm_instance_q15 * S, - const q15_t * pSrc, - q15_t * pRef, - q15_t * pOut, - q15_t * pErr, - uint32_t blockSize) -{ - q15_t *pState = S->pState; /* State pointer */ - q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q15_t *pStateCurnt; /* Points to the current sample of the state */ - q15_t *px, *pb; /* Temporary pointers for state and coefficient buffers */ - q15_t mu = S->mu; /* Adaptive factor */ - uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ - uint32_t tapCnt, blkCnt; /* Loop counters */ - q63_t acc; /* Accumulator */ - q31_t energy; /* Energy of the input */ - q15_t e = 0, d = 0; /* Error, reference data sample */ - q15_t w = 0, in; /* Weight factor and state */ - q15_t x0; /* Temporary variable to hold input sample */ - q15_t errorXmu, oneByEnergy; /* Temporary variables to store error and mu product and reciprocal of energy */ - q15_t postShift; /* Post shift to be applied to weight after reciprocal calculation */ - q31_t coef; /* Temporary variable for coefficient */ - q31_t acc_l, acc_h; /* Temporary input */ - int32_t lShift = (15 - (int32_t) S->postShift); /* Post shift */ - int32_t uShift = (32 - lShift); +void arm_lms_norm_q15(arm_lms_norm_instance_q15 *S, const q15_t *pSrc, + q15_t *pRef, q15_t *pOut, q15_t *pErr, + uint32_t blockSize) { + q15_t *pState = S->pState; /* State pointer */ + q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q15_t *pStateCurnt; /* Points to the current sample of the state */ + q15_t *px, *pb; /* Temporary pointers for state and coefficient buffers */ + q15_t mu = S->mu; /* Adaptive factor */ + uint32_t numTaps = + S->numTaps; /* Number of filter coefficients in the filter */ + uint32_t tapCnt, blkCnt; /* Loop counters */ + q63_t acc; /* Accumulator */ + q31_t energy; /* Energy of the input */ + q15_t e = 0, d = 0; /* Error, reference data sample */ + q15_t w = 0, in; /* Weight factor and state */ + q15_t x0; /* Temporary variable to hold input sample */ + q15_t errorXmu, oneByEnergy; /* Temporary variables to store error and mu + product and reciprocal of energy */ + q15_t postShift; /* Post shift to be applied to weight after reciprocal + calculation */ + q31_t coef; /* Temporary variable for coefficient */ + q31_t acc_l, acc_h; /* Temporary input */ + int32_t lShift = (15 - (int32_t)S->postShift); /* Post shift */ + int32_t uShift = (32 - lShift); energy = S->energy; x0 = S->x0; - /* S->pState points to buffer which contains previous frame (numTaps - 1) samples */ - /* pStateCurnt points to the location where the new input data should be written */ + /* S->pState points to buffer which contains previous frame (numTaps - 1) + * samples */ + /* pStateCurnt points to the location where the new input data should be + * written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); /* initialise loop count */ blkCnt = blockSize; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy the new input sample into the state buffer */ *pStateCurnt++ = *pSrc; @@ -114,23 +113,22 @@ void arm_lms_norm_q15( in = *pSrc++; /* Update the energy calculation */ - energy -= (((q31_t) x0 * (x0)) >> 15); - energy += (((q31_t) in * (in)) >> 15); + energy -= (((q31_t)x0 * (x0)) >> 15); + energy += (((q31_t)in * (in)) >> 15); /* Set the accumulator to zero */ acc = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ /* acc += b[N] * x[n-N] + b[N-1] * x[n-N-1] */ - acc = __SMLALD(read_q15x2_ia (&px), read_q15x2_ia (&pb), acc); - acc = __SMLALD(read_q15x2_ia (&px), read_q15x2_ia (&pb), acc); + acc = __SMLALD(read_q15x2_ia(&px), read_q15x2_ia(&pb), acc); + acc = __SMLALD(read_q15x2_ia(&px), read_q15x2_ia(&pb), acc); /* Decrement loop counter */ tapCnt--; @@ -146,10 +144,9 @@ void arm_lms_norm_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ - acc += (q63_t) (((q31_t) (*px++) * (*pb++))); + acc += (q63_t)(((q31_t)(*px++) * (*pb++))); /* Decrement the loop counter */ tapCnt--; @@ -162,30 +159,31 @@ void arm_lms_norm_q15( acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ - acc = (uint32_t) acc_l >> lShift | acc_h << uShift; + acc = (uint32_t)acc_l >> lShift | acc_h << uShift; /* Converting the result to 1.15 format and saturate the output */ acc = __SSAT(acc, 16U); /* Store the result from accumulator into the destination buffer. */ - *pOut++ = (q15_t) acc; + *pOut++ = (q15_t)acc; /* Compute and store error */ d = *pRef++; - e = d - (q15_t) acc; + e = d - (q15_t)acc; *pErr++ = e; /* Calculation of 1/energy */ - postShift = arm_recip_q15((q15_t) energy + DELTA_Q15, &oneByEnergy, S->recipTable); + postShift = + arm_recip_q15((q15_t)energy + DELTA_Q15, &oneByEnergy, S->recipTable); /* Calculation of e * mu value */ - errorXmu = (q15_t) (((q31_t) e * mu) >> 15); + errorXmu = (q15_t)(((q31_t)e * mu) >> 15); /* Calculation of (e * mu) * (1/energy) value */ - acc = (((q31_t) errorXmu * oneByEnergy) >> (15 - postShift)); + acc = (((q31_t)errorXmu * oneByEnergy) >> (15 - postShift)); /* Weighting factor for the normalized version */ - w = (q15_t) __SSAT((q31_t) acc, 16); + w = (q15_t)__SSAT((q31_t)acc, 16); /* Initialize pState pointer */ px = pState; @@ -193,25 +191,24 @@ void arm_lms_norm_q15( /* Initialize coefficient pointer */ pb = pCoeffs; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; /* Update filter coefficients */ - while (tapCnt > 0U) - { - coef = (q31_t) *pb + (((q31_t) w * (*px++)) >> 15); - *pb++ = (q15_t) __SSAT(coef, 16); + while (tapCnt > 0U) { + coef = (q31_t)*pb + (((q31_t)w * (*px++)) >> 15); + *pb++ = (q15_t)__SSAT(coef, 16); - coef = (q31_t) *pb + (((q31_t) w * (*px++)) >> 15); - *pb++ = (q15_t) __SSAT(coef, 16); + coef = (q31_t)*pb + (((q31_t)w * (*px++)) >> 15); + *pb++ = (q15_t)__SSAT(coef, 16); - coef = (q31_t) *pb + (((q31_t) w * (*px++)) >> 15); - *pb++ = (q15_t) __SSAT(coef, 16); + coef = (q31_t)*pb + (((q31_t)w * (*px++)) >> 15); + *pb++ = (q15_t)__SSAT(coef, 16); - coef = (q31_t) *pb + (((q31_t) w * (*px++)) >> 15); - *pb++ = (q15_t) __SSAT(coef, 16); + coef = (q31_t)*pb + (((q31_t)w * (*px++)) >> 15); + *pb++ = (q15_t)__SSAT(coef, 16); /* Decrement loop counter */ tapCnt--; @@ -227,11 +224,10 @@ void arm_lms_norm_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ - coef = (q31_t) *pb + (((q31_t) w * (*px++)) >> 15); - *pb++ = (q15_t) __SSAT(coef, 16); + coef = (q31_t)*pb + (((q31_t)w * (*px++)) >> 15); + *pb++ = (q15_t)__SSAT(coef, 16); /* Decrement loop counter */ tapCnt--; @@ -247,7 +243,7 @@ void arm_lms_norm_q15( } /* Save energy and x0 values for the next frame */ - S->energy = (q15_t) energy; + S->energy = (q15_t)energy; S->x0 = x0; /* Processing is complete. @@ -258,15 +254,14 @@ void arm_lms_norm_q15( pStateCurnt = S->pState; /* copy data */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = (numTaps - 1U) >> 2U; - while (tapCnt > 0U) - { - write_q15x2_ia (&pStateCurnt, read_q15x2_ia (&pState)); - write_q15x2_ia (&pStateCurnt, read_q15x2_ia (&pState)); + while (tapCnt > 0U) { + write_q15x2_ia(&pStateCurnt, read_q15x2_ia(&pState)); + write_q15x2_ia(&pStateCurnt, read_q15x2_ia(&pState)); /* Decrement loop counter */ tapCnt--; @@ -282,14 +277,12 @@ void arm_lms_norm_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_q31.c index e26219e..1bfc65b 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_norm_q31.c @@ -39,7 +39,8 @@ /** @brief Processing function for Q31 normalized LMS filter. - @param[in] S points to an instance of the Q31 normalized LMS filter structure + @param[in] S points to an instance of the Q31 normalized LMS + filter structure @param[in] pSrc points to the block of input data @param[in] pRef points to the block of reference data @param[out] pOut points to the block of output data @@ -48,59 +49,58 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using an internal 64-bit accumulator. - The accumulator has a 2.62 format and maintains full precision of the intermediate - multiplication results but provides only a single guard bit. - Thus, if the accumulator result overflows it wraps around rather than clip. - In order to avoid overflows completely the input signal must be scaled down by - log2(numTaps) bits. The reference signal should not be scaled down. - After all multiply-accumulates are performed, the 2.62 accumulator is shifted - and saturated to 1.31 format to yield the final result. - The output signal and error signal are in 1.31 format. + The function is implemented using an internal 64-bit + accumulator. The accumulator has a 2.62 format and maintains full precision of + the intermediate multiplication results but provides only a single guard bit. + Thus, if the accumulator result overflows it wraps around + rather than clip. In order to avoid overflows completely the input signal must + be scaled down by log2(numTaps) bits. The reference signal should not be scaled + down. After all multiply-accumulates are performed, the 2.62 accumulator is + shifted and saturated to 1.31 format to yield the final result. The output + signal and error signal are in 1.31 format. @par - In this filter, filter coefficients are updated for each sample and the - updation of filter cofficients are saturted. + In this filter, filter coefficients are updated for each + sample and the updation of filter cofficients are saturted. */ -void arm_lms_norm_q31( - arm_lms_norm_instance_q31 * S, - const q31_t * pSrc, - q31_t * pRef, - q31_t * pOut, - q31_t * pErr, - uint32_t blockSize) -{ - q31_t *pState = S->pState; /* State pointer */ - q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q31_t *pStateCurnt; /* Points to the current sample of the state */ - q31_t *px, *pb; /* Temporary pointers for state and coefficient buffers */ - q31_t mu = S->mu; /* Adaptive factor */ - uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ - uint32_t tapCnt, blkCnt; /* Loop counters */ - q63_t acc; /* Accumulator */ - q63_t energy; /* Energy of the input */ - q31_t e = 0; /* Error data sample */ - q31_t w = 0, in; /* Weight factor and state */ - q31_t x0; /* Temporary variable to hold input sample */ - q31_t errorXmu, oneByEnergy; /* Temporary variables to store error and mu product and reciprocal of energy */ - q31_t postShift; /* Post shift to be applied to weight after reciprocal calculation */ - q31_t coef; /* Temporary variable for coef */ - q31_t acc_l, acc_h; /* Temporary input */ - uint32_t uShift = ((uint32_t) S->postShift + 1U); - uint32_t lShift = 32U - uShift; /* Shift to be applied to the output */ +void arm_lms_norm_q31(arm_lms_norm_instance_q31 *S, const q31_t *pSrc, + q31_t *pRef, q31_t *pOut, q31_t *pErr, + uint32_t blockSize) { + q31_t *pState = S->pState; /* State pointer */ + q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q31_t *pStateCurnt; /* Points to the current sample of the state */ + q31_t *px, *pb; /* Temporary pointers for state and coefficient buffers */ + q31_t mu = S->mu; /* Adaptive factor */ + uint32_t numTaps = + S->numTaps; /* Number of filter coefficients in the filter */ + uint32_t tapCnt, blkCnt; /* Loop counters */ + q63_t acc; /* Accumulator */ + q63_t energy; /* Energy of the input */ + q31_t e = 0; /* Error data sample */ + q31_t w = 0, in; /* Weight factor and state */ + q31_t x0; /* Temporary variable to hold input sample */ + q31_t errorXmu, oneByEnergy; /* Temporary variables to store error and mu + product and reciprocal of energy */ + q31_t postShift; /* Post shift to be applied to weight after reciprocal + calculation */ + q31_t coef; /* Temporary variable for coef */ + q31_t acc_l, acc_h; /* Temporary input */ + uint32_t uShift = ((uint32_t)S->postShift + 1U); + uint32_t lShift = 32U - uShift; /* Shift to be applied to the output */ energy = S->energy; x0 = S->x0; - /* S->pState points to buffer which contains previous frame (numTaps - 1) samples */ - /* pStateCurnt points to the location where the new input data should be written */ + /* S->pState points to buffer which contains previous frame (numTaps - 1) + * samples */ + /* pStateCurnt points to the location where the new input data should be + * written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); /* initialise loop count */ blkCnt = blockSize; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy the new input sample into the state buffer */ *pStateCurnt++ = *pSrc; @@ -114,31 +114,30 @@ void arm_lms_norm_q31( in = *pSrc++; /* Update the energy calculation */ - energy = (q31_t) ((((q63_t) energy << 32) - (((q63_t) x0 * x0) << 1)) >> 32); - energy = (q31_t) (((((q63_t) in * in) << 1) + (energy << 32)) >> 32); + energy = (q31_t)((((q63_t)energy << 32) - (((q63_t)x0 * x0) << 1)) >> 32); + energy = (q31_t)(((((q63_t)in * in) << 1) + (energy << 32)) >> 32); /* Set the accumulator to zero */ acc = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ /* acc += b[N] * x[n-N] */ - acc += ((q63_t) (*px++)) * (*pb++); + acc += ((q63_t)(*px++)) * (*pb++); /* acc += b[N-1] * x[n-N-1] */ - acc += ((q63_t) (*px++)) * (*pb++); + acc += ((q63_t)(*px++)) * (*pb++); /* acc += b[N-2] * x[n-N-2] */ - acc += ((q63_t) (*px++)) * (*pb++); + acc += ((q63_t)(*px++)) * (*pb++); /* acc += b[N-3] * x[n-N-3] */ - acc += ((q63_t) (*px++)) * (*pb++); + acc += ((q63_t)(*px++)) * (*pb++); /* Decrement loop counter */ tapCnt--; @@ -154,10 +153,9 @@ void arm_lms_norm_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ - acc += ((q63_t) (*px++)) * (*pb++); + acc += ((q63_t)(*px++)) * (*pb++); /* Decrement the loop counter */ tapCnt--; @@ -170,23 +168,24 @@ void arm_lms_norm_q31( /* Calc upper part of acc */ acc_h = (acc >> 32) & 0xffffffff; - acc = (uint32_t) acc_l >> lShift | acc_h << uShift; + acc = (uint32_t)acc_l >> lShift | acc_h << uShift; /* Store the result from accumulator into the destination buffer. */ - *pOut++ = (q31_t) acc; + *pOut++ = (q31_t)acc; /* Compute and store error */ - e = *pRef++ - (q31_t) acc; + e = *pRef++ - (q31_t)acc; *pErr++ = e; /* Calculates the reciprocal of energy */ - postShift = arm_recip_q31(energy + DELTA_Q31, &oneByEnergy, &S->recipTable[0]); + postShift = + arm_recip_q31(energy + DELTA_Q31, &oneByEnergy, &S->recipTable[0]); /* Calculation of product of (e * mu) */ - errorXmu = (q31_t) (((q63_t) e * mu) >> 31); + errorXmu = (q31_t)(((q63_t)e * mu) >> 31); /* Weighting factor for the normalized version */ - w = clip_q63_to_q31(((q63_t) errorXmu * oneByEnergy) >> (31 - postShift)); + w = clip_q63_to_q31(((q63_t)errorXmu * oneByEnergy) >> (31 - postShift)); /* Initialize pState pointer */ px = pState; @@ -194,33 +193,32 @@ void arm_lms_norm_q31( /* Initialize coefficient pointer */ pb = pCoeffs; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; /* Update filter coefficients */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ /* coef is in 2.30 format */ - coef = (q31_t) (((q63_t) w * (*px++)) >> (32)); + coef = (q31_t)(((q63_t)w * (*px++)) >> (32)); /* get coef in 1.31 format by left shifting */ - *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1U)); + *pb = clip_q63_to_q31((q63_t)*pb + (coef << 1U)); /* update coefficient buffer to next coefficient */ pb++; - coef = (q31_t) (((q63_t) w * (*px++)) >> (32)); - *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1U)); + coef = (q31_t)(((q63_t)w * (*px++)) >> (32)); + *pb = clip_q63_to_q31((q63_t)*pb + (coef << 1U)); pb++; - coef = (q31_t) (((q63_t) w * (*px++)) >> (32)); - *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1U)); + coef = (q31_t)(((q63_t)w * (*px++)) >> (32)); + *pb = clip_q63_to_q31((q63_t)*pb + (coef << 1U)); pb++; - coef = (q31_t) (((q63_t) w * (*px++)) >> (32)); - *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1U)); + coef = (q31_t)(((q63_t)w * (*px++)) >> (32)); + *pb = clip_q63_to_q31((q63_t)*pb + (coef << 1U)); pb++; /* Decrement loop counter */ @@ -237,11 +235,10 @@ void arm_lms_norm_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ - coef = (q31_t) (((q63_t) w * (*px++)) >> (32)); - *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1U)); + coef = (q31_t)(((q63_t)w * (*px++)) >> (32)); + *pb = clip_q63_to_q31((q63_t)*pb + (coef << 1U)); pb++; /* Decrement loop counter */ @@ -259,7 +256,7 @@ void arm_lms_norm_q31( } /* Save energy and x0 values for the next frame */ - S->energy = (q31_t) energy; + S->energy = (q31_t)energy; S->x0 = x0; /* Processing is complete. @@ -270,13 +267,12 @@ void arm_lms_norm_q31( pStateCurnt = S->pState; /* copy data */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = (numTaps - 1U) >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; @@ -296,14 +292,12 @@ void arm_lms_norm_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_q15.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_q15.c index 0fc9878..1cd7c07 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_q15.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_q15.c @@ -48,49 +48,47 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using an internal 64-bit accumulator. - Both coefficients and state variables are represented in 1.15 format and multiplications yield a 2.30 result. - The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. - There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. - After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits. - Lastly, the accumulator is saturated to yield a result in 1.15 format. + The function is implemented using an internal 64-bit + accumulator. Both coefficients and state variables are represented in 1.15 + format and multiplications yield a 2.30 result. The 2.30 intermediate results + are accumulated in a 64-bit accumulator in 34.30 format. There is no risk of + internal overflow with this approach and the full precision of intermediate + multiplications is preserved. After all additions have been performed, the + accumulator is truncated to 34.15 format by discarding low 15 bits. Lastly, + the accumulator is saturated to yield a result in 1.15 format. @par - In this filter, filter coefficients are updated for each sample and - the updation of filter cofficients are saturted. + In this filter, filter coefficients are updated for each + sample and the updation of filter cofficients are saturted. */ -void arm_lms_q15( - const arm_lms_instance_q15 * S, - const q15_t * pSrc, - q15_t * pRef, - q15_t * pOut, - q15_t * pErr, - uint32_t blockSize) -{ - q15_t *pState = S->pState; /* State pointer */ - q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q15_t *pStateCurnt; /* Points to the current sample of the state */ - q15_t *px, *pb; /* Temporary pointers for state and coefficient buffers */ - q15_t mu = S->mu; /* Adaptive factor */ - uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ - uint32_t tapCnt, blkCnt; /* Loop counters */ - q63_t acc; /* Accumulator */ - q15_t e = 0; /* Error of data sample */ - q15_t alpha; /* Intermediate constant for taps update */ - q31_t coef; /* Temporary variable for coefficient */ - q31_t acc_l, acc_h; /* Temporary input */ - int32_t lShift = (15 - (int32_t) S->postShift); /* Post shift */ - int32_t uShift = (32 - lShift); +void arm_lms_q15(const arm_lms_instance_q15 *S, const q15_t *pSrc, q15_t *pRef, + q15_t *pOut, q15_t *pErr, uint32_t blockSize) { + q15_t *pState = S->pState; /* State pointer */ + q15_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q15_t *pStateCurnt; /* Points to the current sample of the state */ + q15_t *px, *pb; /* Temporary pointers for state and coefficient buffers */ + q15_t mu = S->mu; /* Adaptive factor */ + uint32_t numTaps = + S->numTaps; /* Number of filter coefficients in the filter */ + uint32_t tapCnt, blkCnt; /* Loop counters */ + q63_t acc; /* Accumulator */ + q15_t e = 0; /* Error of data sample */ + q15_t alpha; /* Intermediate constant for taps update */ + q31_t coef; /* Temporary variable for coefficient */ + q31_t acc_l, acc_h; /* Temporary input */ + int32_t lShift = (15 - (int32_t)S->postShift); /* Post shift */ + int32_t uShift = (32 - lShift); - /* S->pState points to buffer which contains previous frame (numTaps - 1) samples */ - /* pStateCurnt points to the location where the new input data should be written */ + /* S->pState points to buffer which contains previous frame (numTaps - 1) + * samples */ + /* pStateCurnt points to the location where the new input data should be + * written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); /* initialise loop count */ blkCnt = blockSize; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy the new input sample into the state buffer */ *pStateCurnt++ = *pSrc++; @@ -103,17 +101,16 @@ void arm_lms_q15( /* Set the accumulator to zero */ acc = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ /* acc += b[N] * x[n-N] + b[N-1] * x[n-N-1] */ - acc = __SMLALD(read_q15x2_ia (&px), read_q15x2_ia (&pb), acc); - acc = __SMLALD(read_q15x2_ia (&px), read_q15x2_ia (&pb), acc); + acc = __SMLALD(read_q15x2_ia(&px), read_q15x2_ia(&pb), acc); + acc = __SMLALD(read_q15x2_ia(&px), read_q15x2_ia(&pb), acc); /* Decrement loop counter */ tapCnt--; @@ -129,10 +126,9 @@ void arm_lms_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ - acc += (q63_t) (((q31_t) (*px++) * (*pb++))); + acc += (q63_t)(((q31_t)(*px++) * (*pb++))); /* Decrement the loop counter */ tapCnt--; @@ -145,20 +141,20 @@ void arm_lms_q15( acc_h = (acc >> 32) & 0xffffffff; /* Apply shift for lower part of acc and upper part of acc */ - acc = (uint32_t) acc_l >> lShift | acc_h << uShift; + acc = (uint32_t)acc_l >> lShift | acc_h << uShift; /* Converting the result to 1.15 format and saturate the output */ acc = __SSAT(acc, 16U); /* Store the result from accumulator into the destination buffer. */ - *pOut++ = (q15_t) acc; + *pOut++ = (q15_t)acc; /* Compute and store error */ - e = *pRef++ - (q15_t) acc; - *pErr++ = (q15_t) e; + e = *pRef++ - (q15_t)acc; + *pErr++ = (q15_t)e; /* Compute alpha i.e. intermediate constant for taps update */ - alpha = (q15_t) (((q31_t) e * (mu)) >> 15); + alpha = (q15_t)(((q31_t)e * (mu)) >> 15); /* Initialize pState pointer */ /* Advance state pointer by 1 for the next sample */ @@ -167,25 +163,24 @@ void arm_lms_q15( /* Initialize coefficient pointer */ pb = pCoeffs; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; /* Update filter coefficients */ - while (tapCnt > 0U) - { - coef = (q31_t) *pb + (((q31_t) alpha * (*px++)) >> 15); - *pb++ = (q15_t) __SSAT((coef), 16); + while (tapCnt > 0U) { + coef = (q31_t)*pb + (((q31_t)alpha * (*px++)) >> 15); + *pb++ = (q15_t)__SSAT((coef), 16); - coef = (q31_t) *pb + (((q31_t) alpha * (*px++)) >> 15); - *pb++ = (q15_t) __SSAT((coef), 16); + coef = (q31_t)*pb + (((q31_t)alpha * (*px++)) >> 15); + *pb++ = (q15_t)__SSAT((coef), 16); - coef = (q31_t) *pb + (((q31_t) alpha * (*px++)) >> 15); - *pb++ = (q15_t) __SSAT((coef), 16); + coef = (q31_t)*pb + (((q31_t)alpha * (*px++)) >> 15); + *pb++ = (q15_t)__SSAT((coef), 16); - coef = (q31_t) *pb + (((q31_t) alpha * (*px++)) >> 15); - *pb++ = (q15_t) __SSAT((coef), 16); + coef = (q31_t)*pb + (((q31_t)alpha * (*px++)) >> 15); + *pb++ = (q15_t)__SSAT((coef), 16); /* Decrement loop counter */ tapCnt--; @@ -201,11 +196,10 @@ void arm_lms_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ - coef = (q31_t) *pb + (((q31_t) alpha * (*px++)) >> 15); - *pb++ = (q15_t) __SSAT((coef), 16); + coef = (q31_t)*pb + (((q31_t)alpha * (*px++)) >> 15); + *pb++ = (q15_t)__SSAT((coef), 16); /* Decrement loop counter */ tapCnt--; @@ -223,15 +217,14 @@ void arm_lms_q15( pStateCurnt = S->pState; /* copy data */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = (numTaps - 1U) >> 2U; - while (tapCnt > 0U) - { - write_q15x2_ia (&pStateCurnt, read_q15x2_ia (&pState)); - write_q15x2_ia (&pStateCurnt, read_q15x2_ia (&pState)); + while (tapCnt > 0U) { + write_q15x2_ia(&pStateCurnt, read_q15x2_ia(&pState)); + write_q15x2_ia(&pStateCurnt, read_q15x2_ia(&pState)); /* Decrement loop counter */ tapCnt--; @@ -247,14 +240,12 @@ void arm_lms_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_q31.c b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_q31.c index b0c0e27..cb24407 100644 --- a/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_q31.c +++ b/platform/cmsis/DSP_Lib/FilteringFunctions/arm_lms_q31.c @@ -39,7 +39,8 @@ /** @brief Processing function for Q31 LMS filter. - @param[in] S points to an instance of the Q31 LMS filter structure. + @param[in] S points to an instance of the Q31 LMS filter + structure. @param[in] pSrc points to the block of input data. @param[in] pRef points to the block of reference data. @param[out] pOut points to the block of output data. @@ -48,53 +49,48 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using an internal 64-bit accumulator. - The accumulator has a 2.62 format and maintains full precision of the intermediate - multiplication results but provides only a single guard bit. - Thus, if the accumulator result overflows it wraps around rather than clips. - In order to avoid overflows completely the input signal must be scaled down by - log2(numTaps) bits. - The reference signal should not be scaled down. - After all multiply-accumulates are performed, the 2.62 accumulator is shifted - and saturated to 1.31 format to yield the final result. - The output signal and error signal are in 1.31 format. + The function is implemented using an internal 64-bit + accumulator. The accumulator has a 2.62 format and maintains full precision of + the intermediate multiplication results but provides only a single guard bit. + Thus, if the accumulator result overflows it wraps around + rather than clips. In order to avoid overflows completely the input signal must + be scaled down by log2(numTaps) bits. The reference signal should not be scaled + down. After all multiply-accumulates are performed, the 2.62 accumulator is + shifted and saturated to 1.31 format to yield the final result. The output + signal and error signal are in 1.31 format. @par - In this filter, filter coefficients are updated for each sample and - the updation of filter cofficients are saturted. + In this filter, filter coefficients are updated for each + sample and the updation of filter cofficients are saturted. */ -void arm_lms_q31( - const arm_lms_instance_q31 * S, - const q31_t * pSrc, - q31_t * pRef, - q31_t * pOut, - q31_t * pErr, - uint32_t blockSize) -{ - q31_t *pState = S->pState; /* State pointer */ - q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ - q31_t *pStateCurnt; /* Points to the current sample of the state */ - q31_t *px, *pb; /* Temporary pointers for state and coefficient buffers */ - q31_t mu = S->mu; /* Adaptive factor */ - uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */ - uint32_t tapCnt, blkCnt; /* Loop counters */ - q63_t acc; /* Accumulator */ - q31_t e = 0; /* Error of data sample */ - q31_t alpha; /* Intermediate constant for taps update */ - q31_t coef; /* Temporary variable for coef */ - q31_t acc_l, acc_h; /* Temporary input */ - uint32_t uShift = ((uint32_t) S->postShift + 1U); - uint32_t lShift = 32U - uShift; /* Shift to be applied to the output */ +void arm_lms_q31(const arm_lms_instance_q31 *S, const q31_t *pSrc, q31_t *pRef, + q31_t *pOut, q31_t *pErr, uint32_t blockSize) { + q31_t *pState = S->pState; /* State pointer */ + q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ + q31_t *pStateCurnt; /* Points to the current sample of the state */ + q31_t *px, *pb; /* Temporary pointers for state and coefficient buffers */ + q31_t mu = S->mu; /* Adaptive factor */ + uint32_t numTaps = + S->numTaps; /* Number of filter coefficients in the filter */ + uint32_t tapCnt, blkCnt; /* Loop counters */ + q63_t acc; /* Accumulator */ + q31_t e = 0; /* Error of data sample */ + q31_t alpha; /* Intermediate constant for taps update */ + q31_t coef; /* Temporary variable for coef */ + q31_t acc_l, acc_h; /* Temporary input */ + uint32_t uShift = ((uint32_t)S->postShift + 1U); + uint32_t lShift = 32U - uShift; /* Shift to be applied to the output */ - /* S->pState points to buffer which contains previous frame (numTaps - 1) samples */ - /* pStateCurnt points to the location where the new input data should be written */ + /* S->pState points to buffer which contains previous frame (numTaps - 1) + * samples */ + /* pStateCurnt points to the location where the new input data should be + * written */ pStateCurnt = &(S->pState[(numTaps - 1U)]); /* initialise loop count */ blkCnt = blockSize; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Copy the new input sample into the state buffer */ *pStateCurnt++ = *pSrc++; @@ -107,25 +103,24 @@ void arm_lms_q31( /* Set the accumulator to zero */ acc = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ /* acc += b[N] * x[n-N] */ - acc += ((q63_t) (*px++)) * (*pb++); + acc += ((q63_t)(*px++)) * (*pb++); /* acc += b[N-1] * x[n-N-1] */ - acc += ((q63_t) (*px++)) * (*pb++); + acc += ((q63_t)(*px++)) * (*pb++); /* acc += b[N-2] * x[n-N-2] */ - acc += ((q63_t) (*px++)) * (*pb++); + acc += ((q63_t)(*px++)) * (*pb++); /* acc += b[N-3] * x[n-N-3] */ - acc += ((q63_t) (*px++)) * (*pb++); + acc += ((q63_t)(*px++)) * (*pb++); /* Decrement loop counter */ tapCnt--; @@ -141,10 +136,9 @@ void arm_lms_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ - acc += ((q63_t) (*px++)) * (*pb++); + acc += ((q63_t)(*px++)) * (*pb++); /* Decrement the loop counter */ tapCnt--; @@ -157,17 +151,17 @@ void arm_lms_q31( /* Calc upper part of acc */ acc_h = (acc >> 32) & 0xffffffff; - acc = (uint32_t) acc_l >> lShift | acc_h << uShift; + acc = (uint32_t)acc_l >> lShift | acc_h << uShift; /* Store the result from accumulator into the destination buffer. */ - *pOut++ = (q31_t) acc; + *pOut++ = (q31_t)acc; /* Compute and store error */ - e = *pRef++ - (q31_t) acc; + e = *pRef++ - (q31_t)acc; *pErr++ = e; /* Compute alpha i.e. intermediate constant for taps update */ - alpha = (q31_t) (((q63_t) e * mu) >> 31); + alpha = (q31_t)(((q63_t)e * mu) >> 31); /* Initialize pState pointer */ /* Advance state pointer by 1 for the next sample */ @@ -176,33 +170,32 @@ void arm_lms_q31( /* Initialize coefficient pointer */ pb = pCoeffs; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = numTaps >> 2U; /* Update filter coefficients */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ /* coef is in 2.30 format */ - coef = (q31_t) (((q63_t) alpha * (*px++)) >> (32)); + coef = (q31_t)(((q63_t)alpha * (*px++)) >> (32)); /* get coef in 1.31 format by left shifting */ - *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1U)); + *pb = clip_q63_to_q31((q63_t)*pb + (coef << 1U)); /* update coefficient buffer to next coefficient */ pb++; - coef = (q31_t) (((q63_t) alpha * (*px++)) >> (32)); - *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1U)); + coef = (q31_t)(((q63_t)alpha * (*px++)) >> (32)); + *pb = clip_q63_to_q31((q63_t)*pb + (coef << 1U)); pb++; - coef = (q31_t) (((q63_t) alpha * (*px++)) >> (32)); - *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1U)); + coef = (q31_t)(((q63_t)alpha * (*px++)) >> (32)); + *pb = clip_q63_to_q31((q63_t)*pb + (coef << 1U)); pb++; - coef = (q31_t) (((q63_t) alpha * (*px++)) >> (32)); - *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1U)); + coef = (q31_t)(((q63_t)alpha * (*px++)) >> (32)); + *pb = clip_q63_to_q31((q63_t)*pb + (coef << 1U)); pb++; /* Decrement loop counter */ @@ -219,11 +212,10 @@ void arm_lms_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { /* Perform the multiply-accumulate */ - coef = (q31_t) (((q63_t) alpha * (*px++)) >> (32)); - *pb = clip_q63_to_q31((q63_t) * pb + (coef << 1U)); + coef = (q31_t)(((q63_t)alpha * (*px++)) >> (32)); + *pb = clip_q63_to_q31((q63_t)*pb + (coef << 1U)); pb++; /* Decrement loop counter */ @@ -242,13 +234,12 @@ void arm_lms_q31( pStateCurnt = S->pState; /* copy data */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 taps at a time. */ tapCnt = (numTaps - 1U) >> 2U; - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; *pStateCurnt++ = *pState++; @@ -268,14 +259,12 @@ void arm_lms_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (tapCnt > 0U) - { + while (tapCnt > 0U) { *pStateCurnt++ = *pState++; /* Decrement loop counter */ tapCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_add_f32.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_add_f32.c index d7bb44f..e85e8c3 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_add_f32.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_add_f32.c @@ -58,45 +58,39 @@ - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed */ -arm_status arm_mat_add_f32( - const arm_matrix_instance_f32 * pSrcA, - const arm_matrix_instance_f32 * pSrcB, - arm_matrix_instance_f32 * pDst) -{ - float32_t *pInA = pSrcA->pData; /* input data matrix pointer A */ - float32_t *pInB = pSrcB->pData; /* input data matrix pointer B */ - float32_t *pOut = pDst->pData; /* output data matrix pointer */ +arm_status arm_mat_add_f32(const arm_matrix_instance_f32 *pSrcA, + const arm_matrix_instance_f32 *pSrcB, + arm_matrix_instance_f32 *pDst) { + float32_t *pInA = pSrcA->pData; /* input data matrix pointer A */ + float32_t *pInB = pSrcB->pData; /* input data matrix pointer B */ + float32_t *pOut = pDst->pData; /* output data matrix pointer */ - uint32_t numSamples; /* total number of elements in the matrix */ - uint32_t blkCnt; /* loop counters */ - arm_status status; /* status of matrix addition */ + uint32_t numSamples; /* total number of elements in the matrix */ + uint32_t blkCnt; /* loop counters */ + arm_status status; /* status of matrix addition */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrcA->numRows != pSrcB->numRows) || - (pSrcA->numCols != pSrcB->numCols) || - (pSrcA->numRows != pDst->numRows) || - (pSrcA->numCols != pDst->numCols) ) - { + (pSrcA->numCols != pSrcB->numCols) || (pSrcA->numRows != pDst->numRows) || + (pSrcA->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Total number of samples in input matrix */ - numSamples = (uint32_t) pSrcA->numRows * pSrcA->numCols; + numSamples = (uint32_t)pSrcA->numRows * pSrcA->numCols; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C(m,n) = A(m,n) + B(m,n) */ /* Add and store result in destination buffer. */ @@ -122,8 +116,7 @@ arm_status arm_mat_add_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C(m,n) = A(m,n) + B(m,n) */ /* Add and store result in destination buffer. */ diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_add_q15.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_add_q15.c index 2aaf849..8918f27 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_add_q15.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_add_q15.c @@ -48,63 +48,60 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q15 range [0x8000 0x7FFF] are saturated. + Results outside of the allowable Q15 range [0x8000 0x7FFF] + are saturated. */ -arm_status arm_mat_add_q15( - const arm_matrix_instance_q15 * pSrcA, - const arm_matrix_instance_q15 * pSrcB, - arm_matrix_instance_q15 * pDst) -{ - q15_t *pInA = pSrcA->pData; /* input data matrix pointer A */ - q15_t *pInB = pSrcB->pData; /* input data matrix pointer B */ - q15_t *pOut = pDst->pData; /* output data matrix pointer */ - - uint32_t numSamples; /* total number of elements in the matrix */ - uint32_t blkCnt; /* loop counters */ - arm_status status; /* status of matrix addition */ +arm_status arm_mat_add_q15(const arm_matrix_instance_q15 *pSrcA, + const arm_matrix_instance_q15 *pSrcB, + arm_matrix_instance_q15 *pDst) { + q15_t *pInA = pSrcA->pData; /* input data matrix pointer A */ + q15_t *pInB = pSrcB->pData; /* input data matrix pointer B */ + q15_t *pOut = pDst->pData; /* output data matrix pointer */ + + uint32_t numSamples; /* total number of elements in the matrix */ + uint32_t blkCnt; /* loop counters */ + arm_status status; /* status of matrix addition */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrcA->numRows != pSrcB->numRows) || - (pSrcA->numCols != pSrcB->numCols) || - (pSrcA->numRows != pDst->numRows) || - (pSrcA->numCols != pDst->numCols) ) - { + (pSrcA->numCols != pSrcB->numCols) || (pSrcA->numRows != pDst->numRows) || + (pSrcA->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Total number of samples in input matrix */ - numSamples = (uint32_t) pSrcA->numRows * pSrcA->numCols; + numSamples = (uint32_t)pSrcA->numRows * pSrcA->numCols; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C(m,n) = A(m,n) + B(m,n) */ /* Add, saturate and store result in destination buffer. */ -#if defined (ARM_MATH_DSP) - write_q15x2_ia (&pOut, __QADD16(read_q15x2_ia (&pInA), read_q15x2_ia (&pInB))); +#if defined(ARM_MATH_DSP) + write_q15x2_ia(&pOut, + __QADD16(read_q15x2_ia(&pInA), read_q15x2_ia(&pInB))); - write_q15x2_ia (&pOut, __QADD16(read_q15x2_ia (&pInA), read_q15x2_ia (&pInB))); + write_q15x2_ia(&pOut, + __QADD16(read_q15x2_ia(&pInA), read_q15x2_ia(&pInB))); #else - *pOut++ = (q15_t) __SSAT(((q31_t) *pInA++ + *pInB++), 16); + *pOut++ = (q15_t)__SSAT(((q31_t)*pInA++ + *pInB++), 16); - *pOut++ = (q15_t) __SSAT(((q31_t) *pInA++ + *pInB++), 16); + *pOut++ = (q15_t)__SSAT(((q31_t)*pInA++ + *pInB++), 16); - *pOut++ = (q15_t) __SSAT(((q31_t) *pInA++ + *pInB++), 16); + *pOut++ = (q15_t)__SSAT(((q31_t)*pInA++ + *pInB++), 16); - *pOut++ = (q15_t) __SSAT(((q31_t) *pInA++ + *pInB++), 16); + *pOut++ = (q15_t)__SSAT(((q31_t)*pInA++ + *pInB++), 16); #endif /* Decrement loop counter */ @@ -121,15 +118,14 @@ arm_status arm_mat_add_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C(m,n) = A(m,n) + B(m,n) */ /* Add, saturate and store result in destination buffer. */ -#if defined (ARM_MATH_DSP) - *pOut++ = (q15_t) __QADD16(*pInA++, *pInB++); +#if defined(ARM_MATH_DSP) + *pOut++ = (q15_t)__QADD16(*pInA++, *pInB++); #else - *pOut++ = (q15_t) __SSAT(((q31_t) *pInA++ + *pInB++), 16); + *pOut++ = (q15_t)__SSAT(((q31_t)*pInA++ + *pInB++), 16); #endif /* Decrement loop counter */ diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_add_q31.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_add_q31.c index 6194809..629dc3c 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_add_q31.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_add_q31.c @@ -48,48 +48,43 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q31 range [0x80000000 0x7FFFFFFF] are saturated. + Results outside of the allowable Q31 range [0x80000000 + 0x7FFFFFFF] are saturated. */ -arm_status arm_mat_add_q31( - const arm_matrix_instance_q31 * pSrcA, - const arm_matrix_instance_q31 * pSrcB, - arm_matrix_instance_q31 * pDst) -{ - q31_t *pInA = pSrcA->pData; /* input data matrix pointer A */ - q31_t *pInB = pSrcB->pData; /* input data matrix pointer B */ - q31_t *pOut = pDst->pData; /* output data matrix pointer */ +arm_status arm_mat_add_q31(const arm_matrix_instance_q31 *pSrcA, + const arm_matrix_instance_q31 *pSrcB, + arm_matrix_instance_q31 *pDst) { + q31_t *pInA = pSrcA->pData; /* input data matrix pointer A */ + q31_t *pInB = pSrcB->pData; /* input data matrix pointer B */ + q31_t *pOut = pDst->pData; /* output data matrix pointer */ - uint32_t numSamples; /* total number of elements in the matrix */ - uint32_t blkCnt; /* loop counters */ - arm_status status; /* status of matrix addition */ + uint32_t numSamples; /* total number of elements in the matrix */ + uint32_t blkCnt; /* loop counters */ + arm_status status; /* status of matrix addition */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrcA->numRows != pSrcB->numRows) || - (pSrcA->numCols != pSrcB->numCols) || - (pSrcA->numRows != pDst->numRows) || - (pSrcA->numCols != pDst->numCols) ) - { + (pSrcA->numCols != pSrcB->numCols) || (pSrcA->numRows != pDst->numRows) || + (pSrcA->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Total number of samples in input matrix */ - numSamples = (uint32_t) pSrcA->numRows * pSrcA->numCols; + numSamples = (uint32_t)pSrcA->numRows * pSrcA->numCols; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C(m,n) = A(m,n) + B(m,n) */ /* Add, saturate and store result in destination buffer. */ @@ -115,8 +110,7 @@ arm_status arm_mat_add_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C(m,n) = A(m,n) + B(m,n) */ /* Add, saturate and store result in destination buffer. */ diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_cmplx_mult_f32.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_cmplx_mult_f32.c index 1f50fcd..fd656db 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_cmplx_mult_f32.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_cmplx_mult_f32.c @@ -37,12 +37,14 @@ Complex Matrix multiplication is only defined if the number of columns of the first matrix equals the number of rows of the second matrix. - Multiplying an M x N matrix with an N x P matrix results - in an M x P matrix. + Multiplying an M x N matrix with an N x P matrix + results in an M x P matrix. @par When matrix size checking is enabled, the functions check: - - that the inner dimensions of pSrcA and pSrcB are equal; - - that the size of the output matrix equals the outer dimensions of pSrcA and pSrcB. + - that the inner dimensions of pSrcA and pSrcB are + equal; + - that the size of the output matrix equals the outer dimensions of + pSrcA and pSrcB. */ /** @@ -60,51 +62,47 @@ - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed */ -arm_status arm_mat_cmplx_mult_f32( - const arm_matrix_instance_f32 * pSrcA, - const arm_matrix_instance_f32 * pSrcB, - arm_matrix_instance_f32 * pDst) -{ - float32_t *pIn1 = pSrcA->pData; /* Input data matrix pointer A */ - float32_t *pIn2 = pSrcB->pData; /* Input data matrix pointer B */ - float32_t *pInA = pSrcA->pData; /* Input data matrix pointer A */ - float32_t *pOut = pDst->pData; /* Output data matrix pointer */ - float32_t *px; /* Temporary output data matrix pointer */ - uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ - uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ - uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ - float32_t sumReal, sumImag; /* Accumulator */ +arm_status arm_mat_cmplx_mult_f32(const arm_matrix_instance_f32 *pSrcA, + const arm_matrix_instance_f32 *pSrcB, + arm_matrix_instance_f32 *pDst) { + float32_t *pIn1 = pSrcA->pData; /* Input data matrix pointer A */ + float32_t *pIn2 = pSrcB->pData; /* Input data matrix pointer B */ + float32_t *pInA = pSrcA->pData; /* Input data matrix pointer A */ + float32_t *pOut = pDst->pData; /* Output data matrix pointer */ + float32_t *px; /* Temporary output data matrix pointer */ + uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ + uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ + uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ + float32_t sumReal, sumImag; /* Accumulator */ float32_t a1, b1, c1, d1; uint32_t col, i = 0U, j, row = numRowsA, colCnt; /* loop counters */ - arm_status status; /* status of matrix multiplication */ + arm_status status; /* status of matrix multiplication */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) float32_t a0, b0, c0, d0; #endif #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ - if ((pSrcA->numCols != pSrcB->numRows) || - (pSrcA->numRows != pDst->numRows) || - (pSrcB->numCols != pDst->numCols) ) - { + if ((pSrcA->numCols != pSrcB->numRows) || (pSrcA->numRows != pDst->numRows) || + (pSrcB->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { - /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */ + /* The following loop performs the dot-product of each row in pSrcA with + * each column in pSrcB */ /* row loop */ - do - { + do { /* Output pointer is set to starting address of the row being processed */ px = pOut + 2 * i; - /* For every row wise process, the column loop counter is to be initiated */ + /* For every row wise process, the column loop counter is to be initiated + */ col = numColsB; /* For every row wise process, the pIn2 pointer is set @@ -114,23 +112,22 @@ arm_status arm_mat_cmplx_mult_f32( j = 0U; /* column loop */ - do - { + do { /* Set the variable sum, that acts as accumulator, to zero */ sumReal = 0.0f; sumImag = 0.0f; - /* Initiate pointer pIn1 to point to starting address of column being processed */ + /* Initiate pointer pIn1 to point to starting address of column being + * processed */ pIn1 = pInA; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Apply loop unrolling and compute 4 MACs simultaneously. */ colCnt = numColsA >> 2U; /* matrix multiplication */ - while (colCnt > 0U) - { + while (colCnt > 0U) { /* Reading real part of complex matrix A */ a0 = *pIn1; @@ -156,11 +153,12 @@ arm_status arm_mat_cmplx_mult_f32( sumReal -= b0 * d0; sumImag += a0 * d0; - /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ + /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) + */ /* read real and imag values from pSrcA and pSrcB buffer */ - a1 = *(pIn1 ); - c1 = *(pIn2 ); + a1 = *(pIn1); + c1 = *(pIn2); b1 = *(pIn1 + 1U); d1 = *(pIn2 + 1U); @@ -176,8 +174,8 @@ arm_status arm_mat_cmplx_mult_f32( sumReal -= b1 * d1; sumImag += a1 * d1; - a0 = *(pIn1 ); - c0 = *(pIn2 ); + a0 = *(pIn1); + c0 = *(pIn2); b0 = *(pIn1 + 1U); d0 = *(pIn2 + 1U); @@ -193,10 +191,11 @@ arm_status arm_mat_cmplx_mult_f32( sumReal -= b0 * d0; sumImag += a0 * d0; - /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ + /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) + */ - a1 = *(pIn1 ); - c1 = *(pIn2 ); + a1 = *(pIn1); + c1 = *(pIn2); b1 = *(pIn1 + 1U); d1 = *(pIn2 + 1U); @@ -216,7 +215,8 @@ arm_status arm_mat_cmplx_mult_f32( colCnt--; } - /* If the columns of pSrcA is not a multiple of 4, compute any remaining MACs here. + /* If the columns of pSrcA is not a multiple of 4, compute any remaining + *MACs here. ** No loop unrolling is used. */ colCnt = numColsA % 0x4U; @@ -227,11 +227,11 @@ arm_status arm_mat_cmplx_mult_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (colCnt > 0U) - { - /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ - a1 = *(pIn1 ); - c1 = *(pIn2 ); + while (colCnt > 0U) { + /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) + */ + a1 = *(pIn1); + c1 = *(pIn2); b1 = *(pIn1 + 1U); d1 = *(pIn2 + 1U); diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_cmplx_mult_q15.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_cmplx_mult_q15.c index 4c5a45b..598efe8 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_cmplx_mult_q15.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_cmplx_mult_q15.c @@ -51,88 +51,83 @@ Input, output and state buffers should be aligned by 32-bit @par Scaling and Overflow Behavior - The function is implemented using an internal 64-bit accumulator. The inputs to the - multiplications are in 1.15 format and multiplications yield a 2.30 result. - The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. - This approach provides 33 guard bits and there is no risk of overflow. The 34.30 result is then - truncated to 34.15 format by discarding the low 15 bits and then saturated to 1.15 format. + The function is implemented using an internal 64-bit + accumulator. The inputs to the multiplications are in 1.15 format and + multiplications yield a 2.30 result. The 2.30 intermediate results are + accumulated in a 64-bit accumulator in 34.30 format. This approach provides 33 + guard bits and there is no risk of overflow. The 34.30 result is then + truncated to 34.15 format by discarding the low 15 bits and + then saturated to 1.15 format. */ -arm_status arm_mat_cmplx_mult_q15( - const arm_matrix_instance_q15 * pSrcA, - const arm_matrix_instance_q15 * pSrcB, - arm_matrix_instance_q15 * pDst, - q15_t * pScratch) -{ - q15_t *pSrcBT = pScratch; /* input data matrix pointer for transpose */ - q15_t *pInA = pSrcA->pData; /* input data matrix pointer A of Q15 type */ - q15_t *pInB = pSrcB->pData; /* input data matrix pointer B of Q15 type */ - q15_t *px; /* Temporary output data matrix pointer */ - uint16_t numRowsA = pSrcA->numRows; /* number of rows of input matrix A */ - uint16_t numColsB = pSrcB->numCols; /* number of columns of input matrix B */ - uint16_t numColsA = pSrcA->numCols; /* number of columns of input matrix A */ - uint16_t numRowsB = pSrcB->numRows; /* number of rows of input matrix A */ - q63_t sumReal, sumImag; /* accumulator */ - uint32_t col, i = 0U, row = numRowsB, colCnt; /* Loop counters */ - arm_status status; /* Status of matrix multiplication */ +arm_status arm_mat_cmplx_mult_q15(const arm_matrix_instance_q15 *pSrcA, + const arm_matrix_instance_q15 *pSrcB, + arm_matrix_instance_q15 *pDst, + q15_t *pScratch) { + q15_t *pSrcBT = pScratch; /* input data matrix pointer for transpose */ + q15_t *pInA = pSrcA->pData; /* input data matrix pointer A of Q15 type */ + q15_t *pInB = pSrcB->pData; /* input data matrix pointer B of Q15 type */ + q15_t *px; /* Temporary output data matrix pointer */ + uint16_t numRowsA = pSrcA->numRows; /* number of rows of input matrix A */ + uint16_t numColsB = pSrcB->numCols; /* number of columns of input matrix B */ + uint16_t numColsA = pSrcA->numCols; /* number of columns of input matrix A */ + uint16_t numRowsB = pSrcB->numRows; /* number of rows of input matrix A */ + q63_t sumReal, sumImag; /* accumulator */ + uint32_t col, i = 0U, row = numRowsB, colCnt; /* Loop counters */ + arm_status status; /* Status of matrix multiplication */ -#if defined (ARM_MATH_DSP) - q31_t prod1, prod2; - q31_t pSourceA, pSourceB; +#if defined(ARM_MATH_DSP) + q31_t prod1, prod2; + q31_t pSourceA, pSourceB; #else - q15_t a, b, c, d; + q15_t a, b, c, d; #endif /* #if defined (ARM_MATH_DSP) */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ - if ((pSrcA->numCols != pSrcB->numRows) || - (pSrcA->numRows != pDst->numRows) || - (pSrcB->numCols != pDst->numCols) ) - { + if ((pSrcA->numCols != pSrcB->numRows) || (pSrcA->numRows != pDst->numRows) || + (pSrcB->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Matrix transpose */ - do - { + do { /* The pointer px is set to starting address of column being processed */ px = pSrcBT + i; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Apply loop unrolling and exchange the columns with row elements */ col = numColsB >> 2; - /* First part of the processing with loop unrolling. Compute 4 outputs at a time. - a second loop below computes the remaining 1 to 3 samples. */ - while (col > 0U) - { + /* First part of the processing with loop unrolling. Compute 4 outputs at + a time. a second loop below computes the remaining 1 to 3 samples. */ + while (col > 0U) { /* Read two elements from row */ - write_q15x2 (px, read_q15x2_ia (&pInB)); + write_q15x2(px, read_q15x2_ia(&pInB)); /* Update pointer px to point to next row of transposed matrix */ px += numRowsB * 2; /* Read two elements from row */ - write_q15x2 (px, read_q15x2_ia (&pInB)); + write_q15x2(px, read_q15x2_ia(&pInB)); /* Update pointer px to point to next row of transposed matrix */ px += numRowsB * 2; /* Read two elements from row */ - write_q15x2 (px, read_q15x2_ia (&pInB)); + write_q15x2(px, read_q15x2_ia(&pInB)); /* Update pointer px to point to next row of transposed matrix */ px += numRowsB * 2; /* Read two elements from row */ - write_q15x2 (px, read_q15x2_ia (&pInB)); + write_q15x2(px, read_q15x2_ia(&pInB)); /* Update pointer px to point to next row of transposed matrix */ px += numRowsB * 2; @@ -141,21 +136,21 @@ arm_status arm_mat_cmplx_mult_q15( col--; } - /* If the columns of pSrcB is not a multiple of 4, compute any remaining output samples here. + /* If the columns of pSrcB is not a multiple of 4, compute any remaining + *output samples here. ** No loop unrolling is used. */ col = numColsB % 0x4U; #else - /* Initialize blkCnt with number of samples */ - col = numColsB; + /* Initialize blkCnt with number of samples */ + col = numColsB; #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (col > 0U) - { + while (col > 0U) { /* Read two elements from row */ - write_q15x2 (px, read_q15x2_ia (&pInB)); + write_q15x2(px, read_q15x2_ia(&pInB)); /* Update pointer px to point to next row of transposed matrix */ px += numRowsB * 2; @@ -176,39 +171,40 @@ arm_status arm_mat_cmplx_mult_q15( i = 0U; px = pDst->pData; - /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */ + /* The following loop performs the dot-product of each row in pSrcA with + * each column in pSrcB */ /* row loop */ - do - { + do { /* For every row wise process, column loop counter is to be initiated */ col = numColsB; - /* For every row wise process, pIn2 pointer is set to starting address of transposed pSrcB data */ + /* For every row wise process, pIn2 pointer is set to starting address of + * transposed pSrcB data */ pInB = pSrcBT; /* column loop */ - do - { + do { /* Set variable sum, that acts as accumulator, to zero */ sumReal = 0; sumImag = 0; - /* Initiate pointer pInA to point to starting address of column being processed */ + /* Initiate pointer pInA to point to starting address of column being + * processed */ pInA = pSrcA->pData + i * 2; /* Apply loop unrolling and compute 2 MACs simultaneously. */ colCnt = numColsA >> 1U; /* matrix multiplication */ - while (colCnt > 0U) - { - /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ + while (colCnt > 0U) { + /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) + */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* read real and imag values from pSrcA and pSrcB buffer */ - pSourceA = read_q15x2_ia ((q15_t **) &pInA); - pSourceB = read_q15x2_ia ((q15_t **) &pInB); + pSourceA = read_q15x2_ia((q15_t **)&pInA); + pSourceB = read_q15x2_ia((q15_t **)&pInB); /* Multiply and Accumlates */ #ifdef ARM_MATH_BIG_ENDIAN @@ -217,12 +213,12 @@ arm_status arm_mat_cmplx_mult_q15( prod1 = __SMUSD(pSourceA, pSourceB); #endif prod2 = __SMUADX(pSourceA, pSourceB); - sumReal += (q63_t) prod1; - sumImag += (q63_t) prod2; + sumReal += (q63_t)prod1; + sumImag += (q63_t)prod2; /* read real and imag values from pSrcA and pSrcB buffer */ - pSourceA = read_q15x2_ia ((q15_t **) &pInA); - pSourceB = read_q15x2_ia ((q15_t **) &pInB); + pSourceA = read_q15x2_ia((q15_t **)&pInA); + pSourceB = read_q15x2_ia((q15_t **)&pInB); /* Multiply and Accumlates */ #ifdef ARM_MATH_BIG_ENDIAN @@ -231,8 +227,8 @@ arm_status arm_mat_cmplx_mult_q15( prod1 = __SMUSD(pSourceA, pSourceB); #endif prod2 = __SMUADX(pSourceA, pSourceB); - sumReal += (q63_t) prod1; - sumImag += (q63_t) prod2; + sumReal += (q63_t)prod1; + sumImag += (q63_t)prod2; #else /* #if defined (ARM_MATH_DSP) */ @@ -244,10 +240,10 @@ arm_status arm_mat_cmplx_mult_q15( d = *(pInB + 1U); /* Multiply and Accumlates */ - sumReal += (q31_t) a *c; - sumImag += (q31_t) a *d; - sumReal -= (q31_t) b *d; - sumImag += (q31_t) b *c; + sumReal += (q31_t)a * c; + sumImag += (q31_t)a * d; + sumReal -= (q31_t)b * d; + sumImag += (q31_t)b * c; /* read next real and imag values from pSrcA buffer */ a = *(pInA + 2U); @@ -260,10 +256,10 @@ arm_status arm_mat_cmplx_mult_q15( pInA += 4U; /* Multiply and Accumlates */ - sumReal += (q31_t) a * c; - sumImag += (q31_t) a * d; - sumReal -= (q31_t) b * d; - sumImag += (q31_t) b * c; + sumReal += (q31_t)a * c; + sumImag += (q31_t)a * d; + sumReal -= (q31_t)b * d; + sumImag += (q31_t)b * c; /* update pointer */ pInB += 4U; @@ -274,14 +270,14 @@ arm_status arm_mat_cmplx_mult_q15( } /* process odd column samples */ - if ((numColsA & 0x1U) > 0U) - { - /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ + if ((numColsA & 0x1U) > 0U) { + /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) + */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* read real and imag values from pSrcA and pSrcB buffer */ - pSourceA = read_q15x2_ia ((q15_t **) &pInA); - pSourceB = read_q15x2_ia ((q15_t **) &pInB); + pSourceA = read_q15x2_ia((q15_t **)&pInA); + pSourceB = read_q15x2_ia((q15_t **)&pInB); /* Multiply and Accumlates */ #ifdef ARM_MATH_BIG_ENDIAN @@ -290,8 +286,8 @@ arm_status arm_mat_cmplx_mult_q15( prod1 = __SMUSD(pSourceA, pSourceB); #endif prod2 = __SMUADX(pSourceA, pSourceB); - sumReal += (q63_t) prod1; - sumImag += (q63_t) prod2; + sumReal += (q63_t)prod1; + sumImag += (q63_t)prod2; #else /* #if defined (ARM_MATH_DSP) */ @@ -302,18 +298,17 @@ arm_status arm_mat_cmplx_mult_q15( d = *pInB++; /* Multiply and Accumlates */ - sumReal += (q31_t) a * c; - sumImag += (q31_t) a * d; - sumReal -= (q31_t) b * d; - sumImag += (q31_t) b * c; + sumReal += (q31_t)a * c; + sumImag += (q31_t)a * d; + sumReal -= (q31_t)b * d; + sumImag += (q31_t)b * c; #endif /* #if defined (ARM_MATH_DSP) */ - } /* Saturate and store result in destination buffer */ - *px++ = (q15_t) (__SSAT(sumReal >> 15, 16)); - *px++ = (q15_t) (__SSAT(sumImag >> 15, 16)); + *px++ = (q15_t)(__SSAT(sumReal >> 15, 16)); + *px++ = (q15_t)(__SSAT(sumImag >> 15, 16)); /* Decrement column loop counter */ col--; diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_cmplx_mult_q31.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_cmplx_mult_q31.c index 7b458f9..3cf6b50 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_cmplx_mult_q31.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_cmplx_mult_q31.c @@ -47,61 +47,58 @@ - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed @par Scaling and Overflow Behavior - The function is implemented using an internal 64-bit accumulator. - The accumulator has a 2.62 format and maintains full precision of the intermediate - multiplication results but provides only a single guard bit. There is no saturation - on intermediate additions. Thus, if the accumulator overflows it wraps around and - distorts the result. The input signals should be scaled down to avoid intermediate - overflows. The input is thus scaled down by log2(numColsA) bits - to avoid overflows, as a total of numColsA additions are performed internally. - The 2.62 accumulator is right shifted by 31 bits and saturated to 1.31 format to yield the final result. + The function is implemented using an internal 64-bit + accumulator. The accumulator has a 2.62 format and maintains full precision of + the intermediate multiplication results but provides only a single guard bit. + There is no saturation on intermediate additions. Thus, if the accumulator + overflows it wraps around and distorts the result. The input signals should be + scaled down to avoid intermediate overflows. The input is thus scaled down by + log2(numColsA) bits to avoid overflows, as a total of numColsA additions are + performed internally. The 2.62 accumulator is right shifted by 31 bits and + saturated to 1.31 format to yield the final result. */ -arm_status arm_mat_cmplx_mult_q31( - const arm_matrix_instance_q31 * pSrcA, - const arm_matrix_instance_q31 * pSrcB, - arm_matrix_instance_q31 * pDst) -{ - q31_t *pIn1 = pSrcA->pData; /* Input data matrix pointer A */ - q31_t *pIn2 = pSrcB->pData; /* Input data matrix pointer B */ - q31_t *pInA = pSrcA->pData; /* Input data matrix pointer A */ - q31_t *pOut = pDst->pData; /* Output data matrix pointer */ - q31_t *px; /* Temporary output data matrix pointer */ - uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ - uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ - uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ - q63_t sumReal, sumImag; /* Accumulator */ +arm_status arm_mat_cmplx_mult_q31(const arm_matrix_instance_q31 *pSrcA, + const arm_matrix_instance_q31 *pSrcB, + arm_matrix_instance_q31 *pDst) { + q31_t *pIn1 = pSrcA->pData; /* Input data matrix pointer A */ + q31_t *pIn2 = pSrcB->pData; /* Input data matrix pointer B */ + q31_t *pInA = pSrcA->pData; /* Input data matrix pointer A */ + q31_t *pOut = pDst->pData; /* Output data matrix pointer */ + q31_t *px; /* Temporary output data matrix pointer */ + uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ + uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ + uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ + q63_t sumReal, sumImag; /* Accumulator */ q31_t a1, b1, c1, d1; uint32_t col, i = 0U, j, row = numRowsA, colCnt; /* loop counters */ - arm_status status; /* status of matrix multiplication */ + arm_status status; /* status of matrix multiplication */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) q31_t a0, b0, c0, d0; #endif #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ - if ((pSrcA->numCols != pSrcB->numRows) || - (pSrcA->numRows != pDst->numRows) || - (pSrcB->numCols != pDst->numCols) ) - { + if ((pSrcA->numCols != pSrcB->numRows) || (pSrcA->numRows != pDst->numRows) || + (pSrcB->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { - /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */ + /* The following loop performs the dot-product of each row in pSrcA with + * each column in pSrcB */ /* row loop */ - do - { + do { /* Output pointer is set to starting address of the row being processed */ px = pOut + 2 * i; - /* For every row wise process, the column loop counter is to be initiated */ + /* For every row wise process, the column loop counter is to be initiated + */ col = numColsB; /* For every row wise process, the pIn2 pointer is set @@ -111,23 +108,22 @@ arm_status arm_mat_cmplx_mult_q31( j = 0U; /* column loop */ - do - { + do { /* Set the variable sum, that acts as accumulator, to zero */ sumReal = 0.0; sumImag = 0.0; - /* Initiate pointer pIn1 to point to starting address of column being processed */ + /* Initiate pointer pIn1 to point to starting address of column being + * processed */ pIn1 = pInA; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Apply loop unrolling and compute 4 MACs simultaneously. */ colCnt = numColsA >> 2U; /* matrix multiplication */ - while (colCnt > 0U) - { + while (colCnt > 0U) { /* Reading real part of complex matrix A */ a0 = *pIn1; @@ -142,78 +138,81 @@ arm_status arm_mat_cmplx_mult_q31( d0 = *(pIn2 + 1U); /* Multiply and Accumlates */ - sumReal += (q63_t) a0 * c0; - sumImag += (q63_t) b0 * c0; + sumReal += (q63_t)a0 * c0; + sumImag += (q63_t)b0 * c0; /* update pointers */ pIn1 += 2U; pIn2 += 2 * numColsB; /* Multiply and Accumlates */ - sumReal -= (q63_t) b0 * d0; - sumImag += (q63_t) a0 * d0; + sumReal -= (q63_t)b0 * d0; + sumImag += (q63_t)a0 * d0; - /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ + /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) + */ /* read real and imag values from pSrcA and pSrcB buffer */ - a1 = *(pIn1 ); - c1 = *(pIn2 ); + a1 = *(pIn1); + c1 = *(pIn2); b1 = *(pIn1 + 1U); d1 = *(pIn2 + 1U); /* Multiply and Accumlates */ - sumReal += (q63_t) a1 * c1; - sumImag += (q63_t) b1 * c1; + sumReal += (q63_t)a1 * c1; + sumImag += (q63_t)b1 * c1; /* update pointers */ pIn1 += 2U; pIn2 += 2 * numColsB; /* Multiply and Accumlates */ - sumReal -= (q63_t) b1 * d1; - sumImag += (q63_t) a1 * d1; + sumReal -= (q63_t)b1 * d1; + sumImag += (q63_t)a1 * d1; - a0 = *(pIn1 ); - c0 = *(pIn2 ); + a0 = *(pIn1); + c0 = *(pIn2); b0 = *(pIn1 + 1U); d0 = *(pIn2 + 1U); /* Multiply and Accumlates */ - sumReal += (q63_t) a0 * c0; - sumImag += (q63_t) b0 * c0; + sumReal += (q63_t)a0 * c0; + sumImag += (q63_t)b0 * c0; /* update pointers */ pIn1 += 2U; pIn2 += 2 * numColsB; /* Multiply and Accumlates */ - sumReal -= (q63_t) b0 * d0; - sumImag += (q63_t) a0 * d0; + sumReal -= (q63_t)b0 * d0; + sumImag += (q63_t)a0 * d0; - /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ + /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) + */ - a1 = *(pIn1 ); - c1 = *(pIn2 ); + a1 = *(pIn1); + c1 = *(pIn2); b1 = *(pIn1 + 1U); d1 = *(pIn2 + 1U); /* Multiply and Accumlates */ - sumReal += (q63_t) a1 * c1; - sumImag += (q63_t) b1 * c1; + sumReal += (q63_t)a1 * c1; + sumImag += (q63_t)b1 * c1; /* update pointers */ pIn1 += 2U; pIn2 += 2 * numColsB; /* Multiply and Accumlates */ - sumReal -= (q63_t) b1 * d1; - sumImag += (q63_t) a1 * d1; + sumReal -= (q63_t)b1 * d1; + sumImag += (q63_t)a1 * d1; /* Decrement loop count */ colCnt--; } - /* If the columns of pSrcA is not a multiple of 4, compute any remaining MACs here. + /* If the columns of pSrcA is not a multiple of 4, compute any remaining + *MACs here. ** No loop unrolling is used. */ colCnt = numColsA % 0x4U; @@ -224,33 +223,33 @@ arm_status arm_mat_cmplx_mult_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (colCnt > 0U) - { - /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ - a1 = *(pIn1 ); - c1 = *(pIn2 ); + while (colCnt > 0U) { + /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) + */ + a1 = *(pIn1); + c1 = *(pIn2); b1 = *(pIn1 + 1U); d1 = *(pIn2 + 1U); /* Multiply and Accumlates */ - sumReal += (q63_t) a1 * c1; - sumImag += (q63_t) b1 * c1; + sumReal += (q63_t)a1 * c1; + sumImag += (q63_t)b1 * c1; /* update pointers */ pIn1 += 2U; pIn2 += 2 * numColsB; /* Multiply and Accumlates */ - sumReal -= (q63_t) b1 * d1; - sumImag += (q63_t) a1 * d1; + sumReal -= (q63_t)b1 * d1; + sumImag += (q63_t)a1 * d1; /* Decrement loop counter */ colCnt--; } /* Store result in destination buffer */ - *px++ = (q31_t) clip_q63_to_q31(sumReal >> 31); - *px++ = (q31_t) clip_q63_to_q31(sumImag >> 31); + *px++ = (q31_t)clip_q63_to_q31(sumReal >> 31); + *px++ = (q31_t)clip_q63_to_q31(sumImag >> 31); /* Update pointer pIn2 to point to starting address of next column */ j++; diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_init_f32.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_init_f32.c index ce02a25..33e1ea0 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_init_f32.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_init_f32.c @@ -34,7 +34,7 @@ /** @defgroup MatrixInit Matrix Initialization - + Initializes the underlying matrix data structure. The functions set the numRows, numCols, and pData fields @@ -48,19 +48,16 @@ /** @brief Floating-point matrix initialization. - @param[in,out] S points to an instance of the floating-point matrix structure + @param[in,out] S points to an instance of the floating-point matrix + structure @param[in] nRows number of rows in the matrix @param[in] nColumns number of columns in the matrix @param[in] pData points to the matrix data array @return none */ -void arm_mat_init_f32( - arm_matrix_instance_f32 * S, - uint16_t nRows, - uint16_t nColumns, - float32_t * pData) -{ +void arm_mat_init_f32(arm_matrix_instance_f32 *S, uint16_t nRows, + uint16_t nColumns, float32_t *pData) { /* Assign Number of Rows */ S->numRows = nRows; diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_init_q15.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_init_q15.c index 0275503..7d795b9 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_init_q15.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_init_q15.c @@ -39,19 +39,16 @@ /** @brief Q15 matrix initialization. - @param[in,out] S points to an instance of the floating-point matrix structure + @param[in,out] S points to an instance of the floating-point matrix + structure @param[in] nRows number of rows in the matrix @param[in] nColumns number of columns in the matrix @param[in] pData points to the matrix data array @return none */ -void arm_mat_init_q15( - arm_matrix_instance_q15 * S, - uint16_t nRows, - uint16_t nColumns, - q15_t * pData) -{ +void arm_mat_init_q15(arm_matrix_instance_q15 *S, uint16_t nRows, + uint16_t nColumns, q15_t *pData) { /* Assign Number of Rows */ S->numRows = nRows; diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_init_q31.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_init_q31.c index d5c5722..eecc9a1 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_init_q31.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_init_q31.c @@ -34,7 +34,7 @@ /** @defgroup MatrixInit Matrix Initialization - + */ /** @@ -51,12 +51,8 @@ @return none */ -void arm_mat_init_q31( - arm_matrix_instance_q31 * S, - uint16_t nRows, - uint16_t nColumns, - q31_t * pData) -{ +void arm_mat_init_q31(arm_matrix_instance_q31 *S, uint16_t nRows, + uint16_t nColumns, q31_t *pData) { /* Assign Number of Rows */ S->numRows = nRows; diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_inverse_f32.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_inverse_f32.c index 91dad22..9a85e5a 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_inverse_f32.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_inverse_f32.c @@ -37,20 +37,21 @@ Computes the inverse of a matrix. - The inverse is defined only if the input matrix is square and non-singular (the determinant is non-zero). - The function checks that the input and output matrices are square and of the same size. + The inverse is defined only if the input matrix is square and non-singular + (the determinant is non-zero). The function checks that the input and output + matrices are square and of the same size. - Matrix inversion is numerically sensitive and the CMSIS DSP library only supports matrix - inversion of floating-point matrices. + Matrix inversion is numerically sensitive and the CMSIS DSP library only + supports matrix inversion of floating-point matrices. @par Algorithm The Gauss-Jordan method is used to find the inverse. The algorithm performs a sequence of elementary row-operations until it reduces the input matrix to an identity matrix. Applying the same sequence of elementary row-operations to an identity matrix yields the inverse matrix. - If the input matrix is singular, then the algorithm terminates and returns error status - ARM_MATH_SINGULAR. - \image html MatrixInverse.gif "Matrix Inverse of a 3 x 3 matrix using Gauss-Jordan Method" + If the input matrix is singular, then the algorithm terminates and returns + error status ARM_MATH_SINGULAR. \image html MatrixInverse.gif + "Matrix Inverse of a 3 x 3 matrix using Gauss-Jordan Method" */ /** @@ -65,39 +66,36 @@ @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed - - \ref ARM_MATH_SINGULAR : Input matrix is found to be singular (non-invertible) + - \ref ARM_MATH_SINGULAR : Input matrix is found to be + singular (non-invertible) */ -arm_status arm_mat_inverse_f32( - const arm_matrix_instance_f32 * pSrc, - arm_matrix_instance_f32 * pDst) -{ - float32_t *pIn = pSrc->pData; /* input data matrix pointer */ - float32_t *pOut = pDst->pData; /* output data matrix pointer */ - float32_t *pInT1, *pInT2; /* Temporary input data matrix pointer */ - float32_t *pOutT1, *pOutT2; /* Temporary output data matrix pointer */ - float32_t *pPivotRowIn, *pPRT_in, *pPivotRowDst, *pPRT_pDst; /* Temporary input and output data matrix pointer */ - uint32_t numRows = pSrc->numRows; /* Number of rows in the matrix */ - uint32_t numCols = pSrc->numCols; /* Number of Cols in the matrix */ +arm_status arm_mat_inverse_f32(const arm_matrix_instance_f32 *pSrc, + arm_matrix_instance_f32 *pDst) { + float32_t *pIn = pSrc->pData; /* input data matrix pointer */ + float32_t *pOut = pDst->pData; /* output data matrix pointer */ + float32_t *pInT1, *pInT2; /* Temporary input data matrix pointer */ + float32_t *pOutT1, *pOutT2; /* Temporary output data matrix pointer */ + float32_t *pPivotRowIn, *pPRT_in, *pPivotRowDst, + *pPRT_pDst; /* Temporary input and output data matrix pointer */ + uint32_t numRows = pSrc->numRows; /* Number of rows in the matrix */ + uint32_t numCols = pSrc->numCols; /* Number of Cols in the matrix */ -#if defined (ARM_MATH_DSP) - float32_t maxC; /* maximum value in the column */ +#if defined(ARM_MATH_DSP) + float32_t maxC; /* maximum value in the column */ - float32_t Xchg, in = 0.0f, in1; /* Temporary input values */ - uint32_t i, rowCnt, flag = 0U, j, loopCnt, k, l; /* loop counters */ - arm_status status; /* status of matrix inverse */ + float32_t Xchg, in = 0.0f, in1; /* Temporary input values */ + uint32_t i, rowCnt, flag = 0U, j, loopCnt, k, l; /* loop counters */ + arm_status status; /* status of matrix inverse */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ - if ((pSrc->numRows != pSrc->numCols) || - (pDst->numRows != pDst->numCols) || - (pSrc->numRows != pDst->numRows) ) - { + if ((pSrc->numRows != pSrc->numCols) || (pDst->numRows != pDst->numCols) || + (pSrc->numRows != pDst->numRows)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ @@ -108,9 +106,8 @@ arm_status arm_mat_inverse_f32( * * Gauss-Jordan Method: * - * 1. First combine the identity matrix and the input matrix separated by a bar to form an - * augmented matrix as follows: - * _ _ _ _ + * 1. First combine the identity matrix and the input matrix separated + *by a bar to form an augmented matrix as follows: _ _ _ _ * | a11 a12 | 1 0 | | X11 X12 | * | | | = | | * |_ a21 a22 | 0 1 _| |_ X21 X21 _| @@ -119,24 +116,27 @@ arm_status arm_mat_inverse_f32( * * 3. Begin with the first row. Let i = 1. * - * 4. Check to see if the pivot for column i is the greatest of the column. - * The pivot is the element of the main diagonal that is on the current row. - * For instance, if working with row i, then the pivot element is aii. - * If the pivot is not the most significant of the columns, exchange that row with a row - * below it that does contain the most significant value in column i. If the most - * significant value of the column is zero, then an inverse to that matrix does not exist. - * The most significant value of the column is the absolute maximum. + * 4. Check to see if the pivot for column i is the greatest of the + *column. The pivot is the element of the main diagonal that is on the + *current row. For instance, if working with row i, then the pivot element + *is aii. If the pivot is not the most significant of the columns, exchange + *that row with a row below it that does contain the most significant value + *in column i. If the most significant value of the column is zero, then an + *inverse to that matrix does not exist. The most significant value of the + *column is the absolute maximum. * * 5. Divide every element of row i by the pivot. * - * 6. For every row below and row i, replace that row with the sum of that row and - * a multiple of row i so that each new element in column i below row i is zero. + * 6. For every row below and row i, replace that row with the sum of + *that row and a multiple of row i so that each new element in column i + *below row i is zero. * - * 7. Move to the next row and column and repeat steps 2 through 5 until you have zeros - * for every element below and above the main diagonal. + * 7. Move to the next row and column and repeat steps 2 through 5 + *until you have zeros for every element below and above the main diagonal. * - * 8. Now an identical matrix is formed to the left of the bar(input matrix, pSrc). - * Therefore, the matrix to the right of the bar is our solution(pDst matrix, pDst). + * 8. Now an identical matrix is formed to the left of the bar(input + *matrix, pSrc). Therefore, the matrix to the right of the bar is our + *solution(pDst matrix, pDst). *----------------------------------------------------------------------------------------------------------------*/ /* Working pointer for destination matrix */ @@ -146,12 +146,10 @@ arm_status arm_mat_inverse_f32( rowCnt = numRows; /* Making the destination matrix as identity matrix */ - while (rowCnt > 0U) - { + while (rowCnt > 0U) { /* Writing all zeroes in lower triangle of the destination matrix */ j = numRows - rowCnt; - while (j > 0U) - { + while (j > 0U) { *pOutT1++ = 0.0f; j--; } @@ -161,8 +159,7 @@ arm_status arm_mat_inverse_f32( /* Writing all zeroes in upper triangle of the destination matrix */ j = rowCnt - 1U; - while (j > 0U) - { + while (j > 0U) { *pOutT1++ = 0.0f; j--; } @@ -178,8 +175,7 @@ arm_status arm_mat_inverse_f32( /* Index modifier to navigate through the columns */ l = 0U; - while (loopCnt > 0U) - { + while (loopCnt > 0U) { /* Check if the pivot element is zero.. * If it is zero then interchange the row with non zero row below. * If there is no non zero element to replace in the rows below, @@ -198,15 +194,14 @@ arm_status arm_mat_inverse_f32( /* Grab the most significant value from column l */ maxC = 0; - for (i = l; i < numRows; i++) - { - maxC = *pInT1 > 0 ? (*pInT1 > maxC ? *pInT1 : maxC) : (-*pInT1 > maxC ? -*pInT1 : maxC); + for (i = l; i < numRows; i++) { + maxC = *pInT1 > 0 ? (*pInT1 > maxC ? *pInT1 : maxC) + : (-*pInT1 > maxC ? -*pInT1 : maxC); pInT1 += numCols; } /* Update the status if the matrix is singular */ - if (maxC == 0.0f) - { + if (maxC == 0.0f) { return ARM_MATH_SINGULAR; } @@ -217,27 +212,23 @@ arm_status arm_mat_inverse_f32( k = 1U; /* Check if the pivot element is the most significant of the column */ - if ( (in > 0.0f ? in : -in) != maxC) - { + if ((in > 0.0f ? in : -in) != maxC) { /* Loop over the number rows present below */ i = numRows - (l + 1U); - while (i > 0U) - { + while (i > 0U) { /* Update the input and destination pointers */ pInT2 = pInT1 + (numCols * l); pOutT2 = pOutT1 + (numCols * k); /* Look for the most significant element to * replace in the rows below */ - if ((*pInT2 > 0.0f ? *pInT2: -*pInT2) == maxC) - { + if ((*pInT2 > 0.0f ? *pInT2 : -*pInT2) == maxC) { /* Loop over number of columns * to the right of the pilot element */ j = numCols - l; - while (j > 0U) - { + while (j > 0U) { /* Exchange the row elements of the input matrix */ Xchg = *pInT2; *pInT2++ = *pInT1; @@ -250,8 +241,7 @@ arm_status arm_mat_inverse_f32( /* Loop over number of columns of the destination matrix */ j = numCols; - while (j > 0U) - { + while (j > 0U) { /* Exchange the row elements of the destination matrix */ Xchg = *pOutT2; *pOutT2++ = *pOutT1; @@ -277,8 +267,7 @@ arm_status arm_mat_inverse_f32( } /* Update the status if the matrix is singular */ - if ((flag != 1U) && (in == 0.0f)) - { + if ((flag != 1U) && (in == 0.0f)) { return ARM_MATH_SINGULAR; } @@ -297,8 +286,7 @@ arm_status arm_mat_inverse_f32( * to the right of the pilot element */ j = (numCols - l); - while (j > 0U) - { + while (j > 0U) { /* Divide each element of the row of the input matrix * by the pivot element */ in1 = *pInT1; @@ -311,8 +299,7 @@ arm_status arm_mat_inverse_f32( /* Loop over number of columns of the destination matrix */ j = numCols; - while (j > 0U) - { + while (j > 0U) { /* Divide each element of the row of the destination matrix * by the pivot element */ in1 = *pInT2; @@ -336,19 +323,15 @@ arm_status arm_mat_inverse_f32( /* to be replaced by the sum of that row and a multiple of row i */ k = numRows; - while (k > 0U) - { + while (k > 0U) { /* Check for the pivot element */ - if (i == l) - { + if (i == l) { /* If the processing element is the pivot element, only the columns to the right are to be processed */ pInT1 += numCols - l; pInT2 += numCols; - } - else - { + } else { /* Element of the reference row */ in = *pInT1; @@ -360,8 +343,7 @@ arm_status arm_mat_inverse_f32( to replace the elements in the input matrix */ j = (numCols - l); - while (j > 0U) - { + while (j > 0U) { /* Replace the element by the sum of that row and a multiple of the reference row */ in1 = *pInT1; @@ -375,8 +357,7 @@ arm_status arm_mat_inverse_f32( replace the elements in the destination matrix */ j = numCols; - while (j > 0U) - { + while (j > 0U) { /* Replace the element by the sum of that row and a multiple of the reference row */ in1 = *pInT2; @@ -385,7 +366,6 @@ arm_status arm_mat_inverse_f32( /* Decrement loop counter */ j--; } - } /* Increment temporary input pointer */ @@ -408,24 +388,20 @@ arm_status arm_mat_inverse_f32( l++; } - #else - float32_t Xchg, in = 0.0f; /* Temporary input values */ - uint32_t i, rowCnt, flag = 0U, j, loopCnt, k, l; /* loop counters */ - arm_status status; /* status of matrix inverse */ + float32_t Xchg, in = 0.0f; /* Temporary input values */ + uint32_t i, rowCnt, flag = 0U, j, loopCnt, k, l; /* loop counters */ + arm_status status; /* status of matrix inverse */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ - if ((pSrc->numRows != pSrc->numCols) || - (pDst->numRows != pDst->numCols) || - (pSrc->numRows != pDst->numRows) ) - { + if ((pSrc->numRows != pSrc->numCols) || (pDst->numRows != pDst->numCols) || + (pSrc->numRows != pDst->numRows)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ @@ -436,34 +412,36 @@ arm_status arm_mat_inverse_f32( * * Gauss-Jordan Method: * - * 1. First combine the identity matrix and the input matrix separated by a bar to form an - * augmented matrix as follows: - * _ _ _ _ _ _ _ _ - * | | a11 a12 | | | 1 0 | | | X11 X12 | - * | | | | | | | = | | - * |_ |_ a21 a22 _| | |_0 1 _| _| |_ X21 X21 _| + * 1. First combine the identity matrix and the input matrix separated + *by a bar to form an augmented matrix as follows: _ _ _ _ _ + *_ _ _ | | a11 a12 | | | 1 0 | | | X11 X12 + *| | | | | | | | = | | + * |_ |_ a21 a22 _| | |_0 1 _| _| |_ X21 X21 + *_| * * 2. In our implementation, pDst Matrix is used as identity matrix. * * 3. Begin with the first row. Let i = 1. * * 4. Check to see if the pivot for row i is zero. - * The pivot is the element of the main diagonal that is on the current row. - * For instance, if working with row i, then the pivot element is aii. - * If the pivot is zero, exchange that row with a row below it that does not - * contain a zero in column i. If this is not possible, then an inverse - * to that matrix does not exist. + * The pivot is the element of the main diagonal that is on the + *current row. For instance, if working with row i, then the pivot element + *is aii. If the pivot is zero, exchange that row with a row below it that + *does not contain a zero in column i. If this is not possible, then an + *inverse to that matrix does not exist. * * 5. Divide every element of row i by the pivot. * - * 6. For every row below and row i, replace that row with the sum of that row and - * a multiple of row i so that each new element in column i below row i is zero. + * 6. For every row below and row i, replace that row with the sum of + *that row and a multiple of row i so that each new element in column i + *below row i is zero. * - * 7. Move to the next row and column and repeat steps 2 through 5 until you have zeros - * for every element below and above the main diagonal. + * 7. Move to the next row and column and repeat steps 2 through 5 + *until you have zeros for every element below and above the main diagonal. * - * 8. Now an identical matrix is formed to the left of the bar(input matrix, src). - * Therefore, the matrix to the right of the bar is our solution(dst matrix, dst). + * 8. Now an identical matrix is formed to the left of the bar(input + *matrix, src). Therefore, the matrix to the right of the bar is our + *solution(dst matrix, dst). *----------------------------------------------------------------------------------------------------------------*/ /* Working pointer for destination matrix */ @@ -473,12 +451,10 @@ arm_status arm_mat_inverse_f32( rowCnt = numRows; /* Making the destination matrix as identity matrix */ - while (rowCnt > 0U) - { + while (rowCnt > 0U) { /* Writing all zeroes in lower triangle of the destination matrix */ j = numRows - rowCnt; - while (j > 0U) - { + while (j > 0U) { *pOutT1++ = 0.0f; j--; } @@ -488,8 +464,7 @@ arm_status arm_mat_inverse_f32( /* Writing all zeroes in upper triangle of the destination matrix */ j = rowCnt - 1U; - while (j > 0U) - { + while (j > 0U) { *pOutT1++ = 0.0f; j--; } @@ -505,8 +480,7 @@ arm_status arm_mat_inverse_f32( /* Index modifier to navigate through the columns */ l = 0U; - while (loopCnt > 0U) - { + while (loopCnt > 0U) { /* Check if the pivot element is zero.. * If it is zero then interchange the row with non zero row below. * If there is no non zero element to replace in the rows below, @@ -527,31 +501,26 @@ arm_status arm_mat_inverse_f32( k = 1U; /* Check if the pivot element is zero */ - if (*pInT1 == 0.0f) - { + if (*pInT1 == 0.0f) { /* Loop over the number rows present below */ - for (i = (l + 1U); i < numRows; i++) - { + for (i = (l + 1U); i < numRows; i++) { /* Update the input and destination pointers */ pInT2 = pInT1 + (numCols * l); pOutT2 = pOutT1 + (numCols * k); /* Check if there is a non zero pivot element to * replace in the rows below */ - if (*pInT2 != 0.0f) - { + if (*pInT2 != 0.0f) { /* Loop over number of columns * to the right of the pilot element */ - for (j = 0U; j < (numCols - l); j++) - { + for (j = 0U; j < (numCols - l); j++) { /* Exchange the row elements of the input matrix */ Xchg = *pInT2; *pInT2++ = *pInT1; *pInT1++ = Xchg; } - for (j = 0U; j < numCols; j++) - { + for (j = 0U; j < numCols; j++) { Xchg = *pOutT2; *pOutT2++ = *pOutT1; *pOutT1++ = Xchg; @@ -570,8 +539,7 @@ arm_status arm_mat_inverse_f32( } /* Update the status if the matrix is singular */ - if ((flag != 1U) && (in == 0.0f)) - { + if ((flag != 1U) && (in == 0.0f)) { return ARM_MATH_SINGULAR; } @@ -588,15 +556,13 @@ arm_status arm_mat_inverse_f32( /* Loop over number of columns * to the right of the pilot element */ - for (j = 0U; j < (numCols - l); j++) - { + for (j = 0U; j < (numCols - l); j++) { /* Divide each element of the row of the input matrix * by the pivot element */ *pInT1 = *pInT1 / in; pInT1++; } - for (j = 0U; j < numCols; j++) - { + for (j = 0U; j < numCols; j++) { /* Divide each element of the row of the destination matrix * by the pivot element */ *pOutT1 = *pOutT1 / in; @@ -610,18 +576,14 @@ arm_status arm_mat_inverse_f32( pInT1 = pIn; pOutT1 = pOut; - for (i = 0U; i < numRows; i++) - { + for (i = 0U; i < numRows; i++) { /* Check for the pivot element */ - if (i == l) - { + if (i == l) { /* If the processing element is the pivot element, only the columns to the right are to be processed */ pInT1 += numCols - l; pOutT1 += numCols; - } - else - { + } else { /* Element of the reference row */ in = *pInT1; @@ -631,8 +593,7 @@ arm_status arm_mat_inverse_f32( /* Loop over the number of columns to the right of the pivot element, to replace the elements in the input matrix */ - for (j = 0U; j < (numCols - l); j++) - { + for (j = 0U; j < (numCols - l); j++) { /* Replace the element by the sum of that row and a multiple of the reference row */ *pInT1 = *pInT1 - (in * *pPRT_in++); @@ -641,14 +602,12 @@ arm_status arm_mat_inverse_f32( /* Loop over the number of columns to replace the elements in the destination matrix */ - for (j = 0U; j < numCols; j++) - { + for (j = 0U; j < numCols; j++) { /* Replace the element by the sum of that row and a multiple of the reference row */ *pOutT1 = *pOutT1 - (in * *pPRT_pDst++); pOutT1++; } - } /* Increment temporary input pointer */ @@ -670,13 +629,11 @@ arm_status arm_mat_inverse_f32( /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; - if ((flag != 1U) && (in == 0.0f)) - { + if ((flag != 1U) && (in == 0.0f)) { pIn = pSrc->pData; - for (i = 0; i < numRows * numCols; i++) - { + for (i = 0; i < numRows * numCols; i++) { if (pIn[i] != 0.0f) - break; + break; } if (i == numRows * numCols) diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_inverse_f64.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_inverse_f64.c index 26b0f70..e7d1c56 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_inverse_f64.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_inverse_f64.c @@ -32,7 +32,6 @@ @ingroup groupMatrix */ - /** @addtogroup MatrixInv @{ @@ -45,39 +44,36 @@ @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed - - \ref ARM_MATH_SINGULAR : Input matrix is found to be singular (non-invertible) + - \ref ARM_MATH_SINGULAR : Input matrix is found to be + singular (non-invertible) */ -arm_status arm_mat_inverse_f64( - const arm_matrix_instance_f64 * pSrc, - arm_matrix_instance_f64 * pDst) -{ - float64_t *pIn = pSrc->pData; /* input data matrix pointer */ - float64_t *pOut = pDst->pData; /* output data matrix pointer */ - float64_t *pInT1, *pInT2; /* Temporary input data matrix pointer */ - float64_t *pOutT1, *pOutT2; /* Temporary output data matrix pointer */ - float64_t *pPivotRowIn, *pPRT_in, *pPivotRowDst, *pPRT_pDst; /* Temporary input and output data matrix pointer */ - uint32_t numRows = pSrc->numRows; /* Number of rows in the matrix */ - uint32_t numCols = pSrc->numCols; /* Number of Cols in the matrix */ +arm_status arm_mat_inverse_f64(const arm_matrix_instance_f64 *pSrc, + arm_matrix_instance_f64 *pDst) { + float64_t *pIn = pSrc->pData; /* input data matrix pointer */ + float64_t *pOut = pDst->pData; /* output data matrix pointer */ + float64_t *pInT1, *pInT2; /* Temporary input data matrix pointer */ + float64_t *pOutT1, *pOutT2; /* Temporary output data matrix pointer */ + float64_t *pPivotRowIn, *pPRT_in, *pPivotRowDst, + *pPRT_pDst; /* Temporary input and output data matrix pointer */ + uint32_t numRows = pSrc->numRows; /* Number of rows in the matrix */ + uint32_t numCols = pSrc->numCols; /* Number of Cols in the matrix */ -#if defined (ARM_MATH_DSP) - float64_t maxC; /* maximum value in the column */ +#if defined(ARM_MATH_DSP) + float64_t maxC; /* maximum value in the column */ - float64_t Xchg, in = 0.0, in1; /* Temporary input values */ - uint32_t i, rowCnt, flag = 0U, j, loopCnt, k, l; /* loop counters */ - arm_status status; /* status of matrix inverse */ + float64_t Xchg, in = 0.0, in1; /* Temporary input values */ + uint32_t i, rowCnt, flag = 0U, j, loopCnt, k, l; /* loop counters */ + arm_status status; /* status of matrix inverse */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ - if ((pSrc->numRows != pSrc->numCols) || - (pDst->numRows != pDst->numCols) || - (pSrc->numRows != pDst->numRows) ) - { + if ((pSrc->numRows != pSrc->numCols) || (pDst->numRows != pDst->numCols) || + (pSrc->numRows != pDst->numRows)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ @@ -88,9 +84,8 @@ arm_status arm_mat_inverse_f64( * * Gauss-Jordan Method: * - * 1. First combine the identity matrix and the input matrix separated by a bar to form an - * augmented matrix as follows: - * _ _ _ _ + * 1. First combine the identity matrix and the input matrix separated + *by a bar to form an augmented matrix as follows: _ _ _ _ * | a11 a12 | 1 0 | | X11 X12 | * | | | = | | * |_ a21 a22 | 0 1 _| |_ X21 X21 _| @@ -99,24 +94,27 @@ arm_status arm_mat_inverse_f64( * * 3. Begin with the first row. Let i = 1. * - * 4. Check to see if the pivot for column i is the greatest of the column. - * The pivot is the element of the main diagonal that is on the current row. - * For instance, if working with row i, then the pivot element is aii. - * If the pivot is not the most significant of the columns, exchange that row with a row - * below it that does contain the most significant value in column i. If the most - * significant value of the column is zero, then an inverse to that matrix does not exist. - * The most significant value of the column is the absolute maximum. + * 4. Check to see if the pivot for column i is the greatest of the + *column. The pivot is the element of the main diagonal that is on the + *current row. For instance, if working with row i, then the pivot element + *is aii. If the pivot is not the most significant of the columns, exchange + *that row with a row below it that does contain the most significant value + *in column i. If the most significant value of the column is zero, then an + *inverse to that matrix does not exist. The most significant value of the + *column is the absolute maximum. * * 5. Divide every element of row i by the pivot. * - * 6. For every row below and row i, replace that row with the sum of that row and - * a multiple of row i so that each new element in column i below row i is zero. + * 6. For every row below and row i, replace that row with the sum of + *that row and a multiple of row i so that each new element in column i + *below row i is zero. * - * 7. Move to the next row and column and repeat steps 2 through 5 until you have zeros - * for every element below and above the main diagonal. + * 7. Move to the next row and column and repeat steps 2 through 5 + *until you have zeros for every element below and above the main diagonal. * - * 8. Now an identical matrix is formed to the left of the bar(input matrix, pSrc). - * Therefore, the matrix to the right of the bar is our solution(pDst matrix, pDst). + * 8. Now an identical matrix is formed to the left of the bar(input + *matrix, pSrc). Therefore, the matrix to the right of the bar is our + *solution(pDst matrix, pDst). *----------------------------------------------------------------------------------------------------------------*/ /* Working pointer for destination matrix */ @@ -126,12 +124,10 @@ arm_status arm_mat_inverse_f64( rowCnt = numRows; /* Making the destination matrix as identity matrix */ - while (rowCnt > 0U) - { + while (rowCnt > 0U) { /* Writing all zeroes in lower triangle of the destination matrix */ j = numRows - rowCnt; - while (j > 0U) - { + while (j > 0U) { *pOutT1++ = 0.0; j--; } @@ -141,8 +137,7 @@ arm_status arm_mat_inverse_f64( /* Writing all zeroes in upper triangle of the destination matrix */ j = rowCnt - 1U; - while (j > 0U) - { + while (j > 0U) { *pOutT1++ = 0.0; j--; } @@ -158,8 +153,7 @@ arm_status arm_mat_inverse_f64( /* Index modifier to navigate through the columns */ l = 0U; - while (loopCnt > 0U) - { + while (loopCnt > 0U) { /* Check if the pivot element is zero.. * If it is zero then interchange the row with non zero row below. * If there is no non zero element to replace in the rows below, @@ -178,15 +172,14 @@ arm_status arm_mat_inverse_f64( /* Grab the most significant value from column l */ maxC = 0; - for (i = l; i < numRows; i++) - { - maxC = *pInT1 > 0 ? (*pInT1 > maxC ? *pInT1 : maxC) : (-*pInT1 > maxC ? -*pInT1 : maxC); + for (i = l; i < numRows; i++) { + maxC = *pInT1 > 0 ? (*pInT1 > maxC ? *pInT1 : maxC) + : (-*pInT1 > maxC ? -*pInT1 : maxC); pInT1 += numCols; } /* Update the status if the matrix is singular */ - if (maxC == (float64_t)0.0) - { + if (maxC == (float64_t)0.0) { return ARM_MATH_SINGULAR; } @@ -197,27 +190,23 @@ arm_status arm_mat_inverse_f64( k = 1U; /* Check if the pivot element is the most significant of the column */ - if ( (in > (float64_t)0.0 ? in : -in) != maxC) - { + if ((in > (float64_t)0.0 ? in : -in) != maxC) { /* Loop over the number rows present below */ i = numRows - (l + 1U); - while (i > 0U) - { + while (i > 0U) { /* Update the input and destination pointers */ pInT2 = pInT1 + (numCols * l); pOutT2 = pOutT1 + (numCols * k); /* Look for the most significant element to * replace in the rows below */ - if ((*pInT2 > (float64_t)0.0 ? *pInT2: -*pInT2) == maxC) - { + if ((*pInT2 > (float64_t)0.0 ? *pInT2 : -*pInT2) == maxC) { /* Loop over number of columns * to the right of the pilot element */ j = numCols - l; - while (j > 0U) - { + while (j > 0U) { /* Exchange the row elements of the input matrix */ Xchg = *pInT2; *pInT2++ = *pInT1; @@ -230,8 +219,7 @@ arm_status arm_mat_inverse_f64( /* Loop over number of columns of the destination matrix */ j = numCols; - while (j > 0U) - { + while (j > 0U) { /* Exchange the row elements of the destination matrix */ Xchg = *pOutT2; *pOutT2++ = *pOutT1; @@ -257,8 +245,7 @@ arm_status arm_mat_inverse_f64( } /* Update the status if the matrix is singular */ - if ((flag != 1U) && (in == (float64_t)0.0)) - { + if ((flag != 1U) && (in == (float64_t)0.0)) { return ARM_MATH_SINGULAR; } @@ -277,8 +264,7 @@ arm_status arm_mat_inverse_f64( * to the right of the pilot element */ j = (numCols - l); - while (j > 0U) - { + while (j > 0U) { /* Divide each element of the row of the input matrix * by the pivot element */ in1 = *pInT1; @@ -291,8 +277,7 @@ arm_status arm_mat_inverse_f64( /* Loop over number of columns of the destination matrix */ j = numCols; - while (j > 0U) - { + while (j > 0U) { /* Divide each element of the row of the destination matrix * by the pivot element */ in1 = *pInT2; @@ -316,19 +301,15 @@ arm_status arm_mat_inverse_f64( /* to be replaced by the sum of that row and a multiple of row i */ k = numRows; - while (k > 0U) - { + while (k > 0U) { /* Check for the pivot element */ - if (i == l) - { + if (i == l) { /* If the processing element is the pivot element, only the columns to the right are to be processed */ pInT1 += numCols - l; pInT2 += numCols; - } - else - { + } else { /* Element of the reference row */ in = *pInT1; @@ -340,8 +321,7 @@ arm_status arm_mat_inverse_f64( to replace the elements in the input matrix */ j = (numCols - l); - while (j > 0U) - { + while (j > 0U) { /* Replace the element by the sum of that row and a multiple of the reference row */ in1 = *pInT1; @@ -355,8 +335,7 @@ arm_status arm_mat_inverse_f64( replace the elements in the destination matrix */ j = numCols; - while (j > 0U) - { + while (j > 0U) { /* Replace the element by the sum of that row and a multiple of the reference row */ in1 = *pInT2; @@ -365,7 +344,6 @@ arm_status arm_mat_inverse_f64( /* Decrement loop counter */ j--; } - } /* Increment temporary input pointer */ @@ -388,24 +366,20 @@ arm_status arm_mat_inverse_f64( l++; } - #else - float64_t Xchg, in = 0.0; /* Temporary input values */ - uint32_t i, rowCnt, flag = 0U, j, loopCnt, k, l; /* loop counters */ - arm_status status; /* status of matrix inverse */ + float64_t Xchg, in = 0.0; /* Temporary input values */ + uint32_t i, rowCnt, flag = 0U, j, loopCnt, k, l; /* loop counters */ + arm_status status; /* status of matrix inverse */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ - if ((pSrc->numRows != pSrc->numCols) || - (pDst->numRows != pDst->numCols) || - (pSrc->numRows != pDst->numRows) ) - { + if ((pSrc->numRows != pSrc->numCols) || (pDst->numRows != pDst->numCols) || + (pSrc->numRows != pDst->numRows)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ @@ -416,34 +390,36 @@ arm_status arm_mat_inverse_f64( * * Gauss-Jordan Method: * - * 1. First combine the identity matrix and the input matrix separated by a bar to form an - * augmented matrix as follows: - * _ _ _ _ _ _ _ _ - * | | a11 a12 | | | 1 0 | | | X11 X12 | - * | | | | | | | = | | - * |_ |_ a21 a22 _| | |_0 1 _| _| |_ X21 X21 _| + * 1. First combine the identity matrix and the input matrix separated + *by a bar to form an augmented matrix as follows: _ _ _ _ _ + *_ _ _ | | a11 a12 | | | 1 0 | | | X11 X12 + *| | | | | | | | = | | + * |_ |_ a21 a22 _| | |_0 1 _| _| |_ X21 X21 + *_| * * 2. In our implementation, pDst Matrix is used as identity matrix. * * 3. Begin with the first row. Let i = 1. * * 4. Check to see if the pivot for row i is zero. - * The pivot is the element of the main diagonal that is on the current row. - * For instance, if working with row i, then the pivot element is aii. - * If the pivot is zero, exchange that row with a row below it that does not - * contain a zero in column i. If this is not possible, then an inverse - * to that matrix does not exist. + * The pivot is the element of the main diagonal that is on the + *current row. For instance, if working with row i, then the pivot element + *is aii. If the pivot is zero, exchange that row with a row below it that + *does not contain a zero in column i. If this is not possible, then an + *inverse to that matrix does not exist. * * 5. Divide every element of row i by the pivot. * - * 6. For every row below and row i, replace that row with the sum of that row and - * a multiple of row i so that each new element in column i below row i is zero. + * 6. For every row below and row i, replace that row with the sum of + *that row and a multiple of row i so that each new element in column i + *below row i is zero. * - * 7. Move to the next row and column and repeat steps 2 through 5 until you have zeros - * for every element below and above the main diagonal. + * 7. Move to the next row and column and repeat steps 2 through 5 + *until you have zeros for every element below and above the main diagonal. * - * 8. Now an identical matrix is formed to the left of the bar(input matrix, src). - * Therefore, the matrix to the right of the bar is our solution(dst matrix, dst). + * 8. Now an identical matrix is formed to the left of the bar(input + *matrix, src). Therefore, the matrix to the right of the bar is our + *solution(dst matrix, dst). *----------------------------------------------------------------------------------------------------------------*/ /* Working pointer for destination matrix */ @@ -453,12 +429,10 @@ arm_status arm_mat_inverse_f64( rowCnt = numRows; /* Making the destination matrix as identity matrix */ - while (rowCnt > 0U) - { + while (rowCnt > 0U) { /* Writing all zeroes in lower triangle of the destination matrix */ j = numRows - rowCnt; - while (j > 0U) - { + while (j > 0U) { *pOutT1++ = 0.0; j--; } @@ -468,8 +442,7 @@ arm_status arm_mat_inverse_f64( /* Writing all zeroes in upper triangle of the destination matrix */ j = rowCnt - 1U; - while (j > 0U) - { + while (j > 0U) { *pOutT1++ = 0.0; j--; } @@ -485,8 +458,7 @@ arm_status arm_mat_inverse_f64( /* Index modifier to navigate through the columns */ l = 0U; - while (loopCnt > 0U) - { + while (loopCnt > 0U) { /* Check if the pivot element is zero.. * If it is zero then interchange the row with non zero row below. * If there is no non zero element to replace in the rows below, @@ -507,31 +479,26 @@ arm_status arm_mat_inverse_f64( k = 1U; /* Check if the pivot element is zero */ - if (*pInT1 == 0.0) - { + if (*pInT1 == 0.0) { /* Loop over the number rows present below */ - for (i = (l + 1U); i < numRows; i++) - { + for (i = (l + 1U); i < numRows; i++) { /* Update the input and destination pointers */ pInT2 = pInT1 + (numCols * l); pOutT2 = pOutT1 + (numCols * k); /* Check if there is a non zero pivot element to * replace in the rows below */ - if (*pInT2 != 0.0) - { + if (*pInT2 != 0.0) { /* Loop over number of columns * to the right of the pilot element */ - for (j = 0U; j < (numCols - l); j++) - { + for (j = 0U; j < (numCols - l); j++) { /* Exchange the row elements of the input matrix */ Xchg = *pInT2; *pInT2++ = *pInT1; *pInT1++ = Xchg; } - for (j = 0U; j < numCols; j++) - { + for (j = 0U; j < numCols; j++) { Xchg = *pOutT2; *pOutT2++ = *pOutT1; *pOutT1++ = Xchg; @@ -550,8 +517,7 @@ arm_status arm_mat_inverse_f64( } /* Update the status if the matrix is singular */ - if ((flag != 1U) && (in == 0.0)) - { + if ((flag != 1U) && (in == 0.0)) { return ARM_MATH_SINGULAR; } @@ -568,15 +534,13 @@ arm_status arm_mat_inverse_f64( /* Loop over number of columns * to the right of the pilot element */ - for (j = 0U; j < (numCols - l); j++) - { + for (j = 0U; j < (numCols - l); j++) { /* Divide each element of the row of the input matrix * by the pivot element */ *pInT1 = *pInT1 / in; pInT1++; } - for (j = 0U; j < numCols; j++) - { + for (j = 0U; j < numCols; j++) { /* Divide each element of the row of the destination matrix * by the pivot element */ *pOutT1 = *pOutT1 / in; @@ -590,18 +554,14 @@ arm_status arm_mat_inverse_f64( pInT1 = pIn; pOutT1 = pOut; - for (i = 0U; i < numRows; i++) - { + for (i = 0U; i < numRows; i++) { /* Check for the pivot element */ - if (i == l) - { + if (i == l) { /* If the processing element is the pivot element, only the columns to the right are to be processed */ pInT1 += numCols - l; pOutT1 += numCols; - } - else - { + } else { /* Element of the reference row */ in = *pInT1; @@ -611,8 +571,7 @@ arm_status arm_mat_inverse_f64( /* Loop over the number of columns to the right of the pivot element, to replace the elements in the input matrix */ - for (j = 0U; j < (numCols - l); j++) - { + for (j = 0U; j < (numCols - l); j++) { /* Replace the element by the sum of that row and a multiple of the reference row */ *pInT1 = *pInT1 - (in * *pPRT_in++); @@ -621,14 +580,12 @@ arm_status arm_mat_inverse_f64( /* Loop over the number of columns to replace the elements in the destination matrix */ - for (j = 0U; j < numCols; j++) - { + for (j = 0U; j < numCols; j++) { /* Replace the element by the sum of that row and a multiple of the reference row */ *pOutT1 = *pOutT1 - (in * *pPRT_pDst++); pOutT1++; } - } /* Increment temporary input pointer */ @@ -650,13 +607,11 @@ arm_status arm_mat_inverse_f64( /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; - if ((flag != 1U) && (in == (float64_t)0.0)) - { + if ((flag != 1U) && (in == (float64_t)0.0)) { pIn = pSrc->pData; - for (i = 0; i < numRows * numCols; i++) - { + for (i = 0; i < numRows * numCols; i++) { if (pIn[i] != (float64_t)0.0) - break; + break; } if (i == numRows * numCols) diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_f32.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_f32.c index e52d60c..dcbfcb6 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_f32.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_f32.c @@ -41,11 +41,13 @@ Matrix multiplication is only defined if the number of columns of the first matrix equals the number of rows of the second matrix. - Multiplying an M x N matrix with an N x P matrix results - in an M x P matrix. - When matrix size checking is enabled, the functions check: - - that the inner dimensions of pSrcA and pSrcB are equal; - - that the size of the output matrix equals the outer dimensions of pSrcA and pSrcB. + Multiplying an M x N matrix with an N x P matrix + results in an M x P matrix. When matrix size checking is enabled, + the functions check: + - that the inner dimensions of pSrcA and pSrcB are + equal; + - that the size of the output matrix equals the outer dimensions of + pSrcA and pSrcB. */ /** @@ -63,70 +65,66 @@ - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed */ -arm_status arm_mat_mult_f32( - const arm_matrix_instance_f32 * pSrcA, - const arm_matrix_instance_f32 * pSrcB, - arm_matrix_instance_f32 * pDst) -{ - float32_t *pIn1 = pSrcA->pData; /* Input data matrix pointer A */ - float32_t *pIn2 = pSrcB->pData; /* Input data matrix pointer B */ - float32_t *pInA = pSrcA->pData; /* Input data matrix pointer A */ - float32_t *pInB = pSrcB->pData; /* Input data matrix pointer B */ - float32_t *pOut = pDst->pData; /* Output data matrix pointer */ - float32_t *px; /* Temporary output data matrix pointer */ - float32_t sum; /* Accumulator */ - uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ - uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ - uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ - uint32_t col, i = 0U, row = numRowsA, colCnt; /* Loop counters */ - arm_status status; /* Status of matrix multiplication */ +arm_status arm_mat_mult_f32(const arm_matrix_instance_f32 *pSrcA, + const arm_matrix_instance_f32 *pSrcB, + arm_matrix_instance_f32 *pDst) { + float32_t *pIn1 = pSrcA->pData; /* Input data matrix pointer A */ + float32_t *pIn2 = pSrcB->pData; /* Input data matrix pointer B */ + float32_t *pInA = pSrcA->pData; /* Input data matrix pointer A */ + float32_t *pInB = pSrcB->pData; /* Input data matrix pointer B */ + float32_t *pOut = pDst->pData; /* Output data matrix pointer */ + float32_t *px; /* Temporary output data matrix pointer */ + float32_t sum; /* Accumulator */ + uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ + uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ + uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ + uint32_t col, i = 0U, row = numRowsA, colCnt; /* Loop counters */ + arm_status status; /* Status of matrix multiplication */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ - if ((pSrcA->numCols != pSrcB->numRows) || - (pSrcA->numRows != pDst->numRows) || - (pSrcB->numCols != pDst->numCols) ) - { + if ((pSrcA->numCols != pSrcB->numRows) || (pSrcA->numRows != pDst->numRows) || + (pSrcB->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { - /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */ + /* The following loop performs the dot-product of each row in pSrcA with + * each column in pSrcB */ /* row loop */ - do - { + do { /* Output pointer is set to starting address of row being processed */ px = pOut + i; /* For every row wise process, column loop counter is to be initiated */ col = numColsB; - /* For every row wise process, pIn2 pointer is set to starting address of pSrcB data */ + /* For every row wise process, pIn2 pointer is set to starting address of + * pSrcB data */ pIn2 = pSrcB->pData; /* column loop */ - do - { + do { /* Set the variable sum, that acts as accumulator, to zero */ sum = 0.0f; - /* Initialize pointer pIn1 to point to starting address of column being processed */ + /* Initialize pointer pIn1 to point to starting address of column being + * processed */ pIn1 = pInA; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 MACs at a time. */ colCnt = numColsA >> 2U; /* matrix multiplication */ - while (colCnt > 0U) - { - /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ + while (colCnt > 0U) { + /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) + */ /* Perform the multiply-accumulates */ sum += *pIn1++ * *pIn2; @@ -155,9 +153,9 @@ arm_status arm_mat_mult_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (colCnt > 0U) - { - /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ + while (colCnt > 0U) { + /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) + */ /* Perform the multiply-accumulates */ sum += *pIn1++ * *pIn2; diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_fast_q15.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_fast_q15.c index 670ace1..186cc22 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_fast_q15.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_fast_q15.c @@ -48,90 +48,85 @@ - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed @par Scaling and Overflow Behavior - The difference between the function \ref arm_mat_mult_q15() and this fast variant is that - the fast variant use a 32-bit rather than a 64-bit accumulator. - The result of each 1.15 x 1.15 multiplication is truncated to - 2.30 format. These intermediate results are accumulated in a 32-bit register in 2.30 - format. Finally, the accumulator is saturated and converted to a 1.15 result. + The difference between the function \ref arm_mat_mult_q15() + and this fast variant is that the fast variant use a 32-bit rather than a + 64-bit accumulator. The result of each 1.15 x 1.15 multiplication is truncated + to 2.30 format. These intermediate results are accumulated in a 32-bit + register in 2.30 format. Finally, the accumulator is saturated and converted + to a 1.15 result. @par - The fast version has the same overflow behavior as the standard version but provides - less precision since it discards the low 16 bits of each multiplication result. - In order to avoid overflows completely the input signals must be scaled down. - Scale down one of the input matrices by log2(numColsA) bits to avoid overflows, - as a total of numColsA additions are computed internally for each output element. + The fast version has the same overflow behavior as the + standard version but provides less precision since it discards the low 16 bits + of each multiplication result. In order to avoid overflows completely the + input signals must be scaled down. Scale down one of the input matrices by + log2(numColsA) bits to avoid overflows, as a total of numColsA additions are + computed internally for each output element. @remark - Refer to \ref arm_mat_mult_q15() for a slower implementation of this function - which uses 64-bit accumulation to provide higher precision. + Refer to \ref arm_mat_mult_q15() for a slower implementation + of this function which uses 64-bit accumulation to provide higher precision. */ -arm_status arm_mat_mult_fast_q15( - const arm_matrix_instance_q15 * pSrcA, - const arm_matrix_instance_q15 * pSrcB, - arm_matrix_instance_q15 * pDst, - q15_t * pState) -{ - q31_t sum; /* Accumulator */ - q15_t *pSrcBT = pState; /* Input data matrix pointer for transpose */ - q15_t *pInA = pSrcA->pData; /* Input data matrix pointer A of Q15 type */ - q15_t *pInB = pSrcB->pData; /* Input data matrix pointer B of Q15 type */ - q15_t *px; /* Temporary output data matrix pointer */ - uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ - uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ - uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ - uint16_t numRowsB = pSrcB->numRows; /* Number of rows of input matrix A */ - uint32_t col, i = 0U, row = numRowsB, colCnt; /* Loop counters */ - arm_status status; /* Status of matrix multiplication */ +arm_status arm_mat_mult_fast_q15(const arm_matrix_instance_q15 *pSrcA, + const arm_matrix_instance_q15 *pSrcB, + arm_matrix_instance_q15 *pDst, q15_t *pState) { + q31_t sum; /* Accumulator */ + q15_t *pSrcBT = pState; /* Input data matrix pointer for transpose */ + q15_t *pInA = pSrcA->pData; /* Input data matrix pointer A of Q15 type */ + q15_t *pInB = pSrcB->pData; /* Input data matrix pointer B of Q15 type */ + q15_t *px; /* Temporary output data matrix pointer */ + uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ + uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ + uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ + uint16_t numRowsB = pSrcB->numRows; /* Number of rows of input matrix A */ + uint32_t col, i = 0U, row = numRowsB, colCnt; /* Loop counters */ + arm_status status; /* Status of matrix multiplication */ -#if defined (ARM_MATH_DSP) - q31_t in; /* Temporary variable to hold the input value */ - q31_t inA1, inB1, inA2, inB2; - q31_t sum2, sum3, sum4; - q15_t *pInA2, *pInB2, *px2; - uint32_t j = 0; +#if defined(ARM_MATH_DSP) + q31_t in; /* Temporary variable to hold the input value */ + q31_t inA1, inB1, inA2, inB2; + q31_t sum2, sum3, sum4; + q15_t *pInA2, *pInB2, *px2; + uint32_t j = 0; #else - q15_t in; /* Temporary variable to hold the input value */ - q15_t inA1, inB1, inA2, inB2; + q15_t in; /* Temporary variable to hold the input value */ + q15_t inA1, inB1, inA2, inB2; #endif /* #if defined (ARM_MATH_DSP) */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ - if ((pSrcA->numCols != pSrcB->numRows) || - (pSrcA->numRows != pDst->numRows) || - (pSrcB->numCols != pDst->numCols) ) - { + if ((pSrcA->numCols != pSrcB->numRows) || (pSrcA->numRows != pDst->numRows) || + (pSrcB->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Matrix transpose */ - do - { + do { /* The pointer px is set to starting address of column being processed */ px = pSrcBT + i; /* Apply loop unrolling and exchange columns with row elements */ col = numColsB >> 2U; - /* First part of the processing with loop unrolling. Compute 4 outputs at a time. + /* First part of the processing with loop unrolling. Compute 4 outputs at + *a time. ** a second loop below computes the remaining 1 to 3 samples. */ - while (col > 0U) - { + while (col > 0U) { -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* Read two elements from row */ - in = read_q15x2_ia ((q15_t **) &pInB); + in = read_q15x2_ia((q15_t **)&pInB); /* Unpack and store one element in destination */ #ifndef ARM_MATH_BIG_ENDIAN - *px = (q15_t) in; + *px = (q15_t)in; #else - *px = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); + *px = (q15_t)((in & (q31_t)0xffff0000) >> 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Update pointer px to point to next row of transposed matrix */ @@ -139,26 +134,26 @@ arm_status arm_mat_mult_fast_q15( /* Unpack and store second element in destination */ #ifndef ARM_MATH_BIG_ENDIAN - *px = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); + *px = (q15_t)((in & (q31_t)0xffff0000) >> 16); #else - *px = (q15_t) in; + *px = (q15_t)in; #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Update pointer px to point to next row of transposed matrix */ px += numRowsB; - in = read_q15x2_ia ((q15_t **) &pInB); + in = read_q15x2_ia((q15_t **)&pInB); #ifndef ARM_MATH_BIG_ENDIAN - *px = (q15_t) in; + *px = (q15_t)in; #else - *px = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); + *px = (q15_t)((in & (q31_t)0xffff0000) >> 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ px += numRowsB; #ifndef ARM_MATH_BIG_ENDIAN - *px = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); + *px = (q15_t)((in & (q31_t)0xffff0000) >> 16); #else - *px = (q15_t) in; + *px = (q15_t)in; #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ px += numRowsB; @@ -191,12 +186,12 @@ arm_status arm_mat_mult_fast_q15( col--; } - /* If the columns of pSrcB is not a multiple of 4, compute any remaining output samples here. + /* If the columns of pSrcB is not a multiple of 4, compute any remaining + *output samples here. ** No loop unrolling is used. */ col = numColsB % 0x4U; - while (col > 0U) - { + while (col > 0U) { /* Read and store input element in destination */ *px = *pInB++; @@ -219,42 +214,43 @@ arm_status arm_mat_mult_fast_q15( i = 0U; px = pDst->pData; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* Process two rows from matrix A at a time and output two rows at a time */ row = row >> 1U; px2 = px + numColsB; #endif - /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */ + /* The following loop performs the dot-product of each row in pSrcA with + * each column in pSrcB */ /* row loop */ - while (row > 0U) - { + while (row > 0U) { /* For every row wise process, column loop counter is to be initiated */ col = numColsB; - /* For every row wise process, pIn2 pointer is set to starting address of transposed pSrcB data */ + /* For every row wise process, pIn2 pointer is set to starting address of + * transposed pSrcB data */ pInB = pSrcBT; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* Process two (transposed) columns from matrix B at a time */ col = col >> 1U; j = 0; #endif /* column loop */ - while (col > 0U) - { + while (col > 0U) { /* Set variable sum, that acts as accumulator, to zero */ sum = 0; - /* Initiate pointer pInA to point to starting address of column being processed */ + /* Initiate pointer pInA to point to starting address of column being + * processed */ pInA = pSrcA->pData + i; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) sum2 = 0; sum3 = 0; sum4 = 0; - pInB = pSrcBT + j; + pInB = pSrcBT + j; pInA2 = pInA + numColsA; pInB2 = pInB + numRowsB; @@ -265,20 +261,20 @@ arm_status arm_mat_mult_fast_q15( #endif /* matrix multiplication */ - while (colCnt > 0U) - { - /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ + while (colCnt > 0U) { + /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) + */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* read real and imag values from pSrcA and pSrcB buffer */ - inA1 = read_q15x2_ia ((q15_t **) &pInA); - inB1 = read_q15x2_ia ((q15_t **) &pInB); + inA1 = read_q15x2_ia((q15_t **)&pInA); + inB1 = read_q15x2_ia((q15_t **)&pInB); - inA2 = read_q15x2_ia ((q15_t **) &pInA2); - inB2 = read_q15x2_ia ((q15_t **) &pInB2); + inA2 = read_q15x2_ia((q15_t **)&pInA2); + inB2 = read_q15x2_ia((q15_t **)&pInB2); /* Multiply and Accumlates */ - sum = __SMLAD(inA1, inB1, sum); + sum = __SMLAD(inA1, inB1, sum); sum2 = __SMLAD(inA1, inB2, sum2); sum3 = __SMLAD(inA2, inB1, sum3); sum4 = __SMLAD(inA2, inB2, sum4); @@ -307,13 +303,13 @@ arm_status arm_mat_mult_fast_q15( } /* process odd column samples */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) if (numColsA & 1U) { inA1 = *pInA++; inB1 = *pInB++; inA2 = *pInA2++; inB2 = *pInB2++; - sum += inA1 * inB1; + sum += inA1 * inB1; sum2 += inA1 * inB2; sum3 += inA2 * inB1; sum4 += inA2 * inB2; @@ -321,10 +317,10 @@ arm_status arm_mat_mult_fast_q15( #else colCnt = numColsA % 0x4U; - while (colCnt > 0U) - { - /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ - sum += (q31_t) *pInA++ * *pInB++; + while (colCnt > 0U) { + /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) + */ + sum += (q31_t)*pInA++ * *pInB++; /* Decrement loop counter */ colCnt--; @@ -332,23 +328,22 @@ arm_status arm_mat_mult_fast_q15( #endif /* #if defined (ARM_MATH_DSP) */ /* Saturate and store result in destination buffer */ - *px++ = (q15_t) (sum >> 15); + *px++ = (q15_t)(sum >> 15); -#if defined (ARM_MATH_DSP) - *px++ = (q15_t) (sum2 >> 15); - *px2++ = (q15_t) (sum3 >> 15); - *px2++ = (q15_t) (sum4 >> 15); +#if defined(ARM_MATH_DSP) + *px++ = (q15_t)(sum2 >> 15); + *px2++ = (q15_t)(sum3 >> 15); + *px2++ = (q15_t)(sum4 >> 15); j += numRowsB * 2; #endif /* Decrement column loop counter */ col--; - } i = i + numColsA; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) i = i + numColsA; px = px2 + (numColsB & 1U); px2 = px + numColsB; @@ -356,12 +351,11 @@ arm_status arm_mat_mult_fast_q15( /* Decrement row loop counter */ row--; - } /* Compute any remaining odd row/column below */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* Compute remaining output column */ if (numColsB & 1U) { @@ -370,32 +364,30 @@ arm_status arm_mat_mult_fast_q15( row = numRowsA & (~0x1); /* Point to remaining unfilled column in output matrix */ - px = pDst->pData + numColsB-1; + px = pDst->pData + numColsB - 1; pInA = pSrcA->pData; /* row loop */ - while (row > 0) - { + while (row > 0) { /* point to last column in matrix B */ - pInB = pSrcBT + numRowsB * (numColsB-1); + pInB = pSrcBT + numRowsB * (numColsB - 1); /* Set variable sum, that acts as accumulator, to zero */ - sum = 0; + sum = 0; /* Compute 4 columns at once */ colCnt = numColsA >> 2U; /* matrix multiplication */ - while (colCnt > 0U) - { - inA1 = read_q15x2_ia ((q15_t **) &pInA); - inA2 = read_q15x2_ia ((q15_t **) &pInA); - inB1 = read_q15x2_ia ((q15_t **) &pInB); - inB2 = read_q15x2_ia ((q15_t **) &pInB); + while (colCnt > 0U) { + inA1 = read_q15x2_ia((q15_t **)&pInA); + inA2 = read_q15x2_ia((q15_t **)&pInA); + inB1 = read_q15x2_ia((q15_t **)&pInB); + inB2 = read_q15x2_ia((q15_t **)&pInB); - sum = __SMLAD(inA1, inB1, sum); - sum = __SMLAD(inA2, inB2, sum); + sum = __SMLAD(inA1, inB1, sum); + sum = __SMLAD(inA2, inB2, sum); /* Decrement loop counter */ colCnt--; @@ -403,12 +395,12 @@ arm_status arm_mat_mult_fast_q15( colCnt = numColsA & 3U; while (colCnt > 0U) { - sum += (q31_t) (*pInA++) * (*pInB++); + sum += (q31_t)(*pInA++) * (*pInB++); colCnt--; } /* Store result in destination buffer */ - *px = (q15_t) (sum >> 15); + *px = (q15_t)(sum >> 15); px += numColsB; /* Decrement row loop counter */ @@ -420,34 +412,32 @@ arm_status arm_mat_mult_fast_q15( if (numRowsA & 1U) { /* point to last row in output matrix */ - px = pDst->pData + (numColsB) * (numRowsA-1); + px = pDst->pData + (numColsB) * (numRowsA - 1); - pInB = pSrcBT; + pInB = pSrcBT; col = numColsB; i = 0U; /* col loop */ - while (col > 0) - { + while (col > 0) { /* point to last row in matrix A */ - pInA = pSrcA->pData + (numRowsA-1) * numColsA; + pInA = pSrcA->pData + (numRowsA - 1) * numColsA; /* Set variable sum, that acts as accumulator, to zero */ - sum = 0; + sum = 0; /* Compute 4 columns at once */ colCnt = numColsA >> 2U; /* matrix multiplication */ - while (colCnt > 0U) - { - inA1 = read_q15x2_ia ((q15_t **) &pInA); - inA2 = read_q15x2_ia ((q15_t **) &pInA); - inB1 = read_q15x2_ia ((q15_t **) &pInB); - inB2 = read_q15x2_ia ((q15_t **) &pInB); + while (colCnt > 0U) { + inA1 = read_q15x2_ia((q15_t **)&pInA); + inA2 = read_q15x2_ia((q15_t **)&pInA); + inB1 = read_q15x2_ia((q15_t **)&pInB); + inB2 = read_q15x2_ia((q15_t **)&pInB); - sum = __SMLAD(inA1, inB1, sum); - sum = __SMLAD(inA2, inB2, sum); + sum = __SMLAD(inA1, inB1, sum); + sum = __SMLAD(inA2, inB2, sum); /* Decrement loop counter */ colCnt--; @@ -455,13 +445,13 @@ arm_status arm_mat_mult_fast_q15( colCnt = numColsA % 4U; while (colCnt > 0U) { - sum += (q31_t) (*pInA++) * (*pInB++); + sum += (q31_t)(*pInA++) * (*pInB++); colCnt--; } /* Store result in destination buffer */ - *px++ = (q15_t) (sum >> 15); + *px++ = (q15_t)(sum >> 15); /* Decrement column loop counter */ col--; diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_fast_q31.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_fast_q31.c index 011959a..6a756bc 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_fast_q31.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_fast_q31.c @@ -47,52 +47,48 @@ - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed @par Scaling and Overflow Behavior - The difference between the function \ref arm_mat_mult_q31() and this fast variant is that - the fast variant use a 32-bit rather than a 64-bit accumulator. - The result of each 1.31 x 1.31 multiplication is truncated to - 2.30 format. These intermediate results are accumulated in a 32-bit register in 2.30 - format. Finally, the accumulator is saturated and converted to a 1.31 result. + The difference between the function \ref arm_mat_mult_q31() + and this fast variant is that the fast variant use a 32-bit rather than a + 64-bit accumulator. The result of each 1.31 x 1.31 multiplication is truncated + to 2.30 format. These intermediate results are accumulated in a 32-bit + register in 2.30 format. Finally, the accumulator is saturated and converted + to a 1.31 result. @par - The fast version has the same overflow behavior as the standard version but provides - less precision since it discards the low 32 bits of each multiplication result. - In order to avoid overflows completely the input signals must be scaled down. - Scale down one of the input matrices by log2(numColsA) bits to avoid overflows, - as a total of numColsA additions are computed internally for each output element. + The fast version has the same overflow behavior as the + standard version but provides less precision since it discards the low 32 bits + of each multiplication result. In order to avoid overflows completely the + input signals must be scaled down. Scale down one of the input matrices by + log2(numColsA) bits to avoid overflows, as a total of numColsA additions are + computed internally for each output element. @remark - Refer to \ref arm_mat_mult_q31() for a slower implementation of this function - which uses 64-bit accumulation to provide higher precision. + Refer to \ref arm_mat_mult_q31() for a slower implementation + of this function which uses 64-bit accumulation to provide higher precision. */ -arm_status arm_mat_mult_fast_q31( - const arm_matrix_instance_q31 * pSrcA, - const arm_matrix_instance_q31 * pSrcB, - arm_matrix_instance_q31 * pDst) -{ - q31_t *pInA = pSrcA->pData; /* Input data matrix pointer A */ - q31_t *pInB = pSrcB->pData; /* Input data matrix pointer B */ +arm_status arm_mat_mult_fast_q31(const arm_matrix_instance_q31 *pSrcA, + const arm_matrix_instance_q31 *pSrcB, + arm_matrix_instance_q31 *pDst) { + q31_t *pInA = pSrcA->pData; /* Input data matrix pointer A */ + q31_t *pInB = pSrcB->pData; /* Input data matrix pointer B */ q31_t *pInA2; - q31_t *px; /* Temporary output data matrix pointer */ + q31_t *px; /* Temporary output data matrix pointer */ q31_t *px2; - q31_t sum1, sum2, sum3, sum4; /* Accumulator */ + q31_t sum1, sum2, sum3, sum4; /* Accumulator */ q31_t inA1, inA2, inB1, inB2; - uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ - uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ - uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ - uint32_t col, i = 0U, j, row = numRowsA, colCnt; /* Loop counters */ - arm_status status; /* Status of matrix multiplication */ - + uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ + uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ + uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ + uint32_t col, i = 0U, j, row = numRowsA, colCnt; /* Loop counters */ + arm_status status; /* Status of matrix multiplication */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ - if ((pSrcA->numCols != pSrcB->numRows) || - (pSrcA->numRows != pDst->numRows) || - (pSrcB->numCols != pDst->numCols) ) - { + if ((pSrcA->numCols != pSrcB->numRows) || (pSrcA->numRows != pDst->numRows) || + (pSrcB->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ @@ -102,14 +98,15 @@ arm_status arm_mat_mult_fast_q31( row = row >> 1U; px2 = px + numColsB; - /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */ + /* The following loop performs the dot-product of each row in pSrcA with + * each column in pSrcB */ /* row loop */ - while (row > 0U) - { + while (row > 0U) { /* For every row wise process, column loop counter is to be initiated */ col = numColsB; - /* For every row wise process, pIn2 pointer is set to starting address of pSrcB data */ + /* For every row wise process, pIn2 pointer is set to starting address of + * pSrcB data */ pInB = pSrcB->pData; j = 0U; @@ -117,25 +114,24 @@ arm_status arm_mat_mult_fast_q31( col = col >> 1U; /* column loop */ - while (col > 0U) - { + while (col > 0U) { /* Set the variable sum, that acts as accumulator, to zero */ sum1 = 0; sum2 = 0; sum3 = 0; sum4 = 0; - + /* Initiate data pointers */ pInA = pSrcA->pData + i; pInB = pSrcB->pData + j; pInA2 = pInA + numColsA; - + colCnt = numColsA; /* matrix multiplication */ - while (colCnt > 0U) - { - /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ + while (colCnt > 0U) { + /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) + */ inA1 = *pInA++; inB1 = pInB[0]; @@ -143,25 +139,26 @@ arm_status arm_mat_mult_fast_q31( inB2 = pInB[1]; pInB += numColsB; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) sum1 = __SMMLA(inA1, inB1, sum1); sum2 = __SMMLA(inA1, inB2, sum2); sum3 = __SMMLA(inA2, inB1, sum3); sum4 = __SMMLA(inA2, inB2, sum4); #else - sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) inA1 * inB1)) >> 32); - sum2 = (q31_t) ((((q63_t) sum2 << 32) + ((q63_t) inA1 * inB2)) >> 32); - sum3 = (q31_t) ((((q63_t) sum3 << 32) + ((q63_t) inA2 * inB1)) >> 32); - sum4 = (q31_t) ((((q63_t) sum4 << 32) + ((q63_t) inA2 * inB2)) >> 32); + sum1 = (q31_t)((((q63_t)sum1 << 32) + ((q63_t)inA1 * inB1)) >> 32); + sum2 = (q31_t)((((q63_t)sum2 << 32) + ((q63_t)inA1 * inB2)) >> 32); + sum3 = (q31_t)((((q63_t)sum3 << 32) + ((q63_t)inA2 * inB1)) >> 32); + sum4 = (q31_t)((((q63_t)sum4 << 32) + ((q63_t)inA2 * inB2)) >> 32); #endif /* Decrement loop counter */ colCnt--; } - /* Convert the result from 2.30 to 1.31 format and store in destination buffer */ - *px++ = sum1 << 1; - *px++ = sum2 << 1; + /* Convert the result from 2.30 to 1.31 format and store in destination + * buffer */ + *px++ = sum1 << 1; + *px++ = sum2 << 1; *px2++ = sum3 << 1; *px2++ = sum4 << 1; @@ -172,8 +169,8 @@ arm_status arm_mat_mult_fast_q31( } i = i + (numColsA << 1U); - px = px2 + (numColsB & 1U); - px2 = px + numColsB; + px = px2 + (numColsB & 1U); + px2 = px + numColsB; /* Decrement row loop counter */ row--; @@ -188,52 +185,54 @@ arm_status arm_mat_mult_fast_q31( row = numRowsA & (~1U); /* Point to remaining unfilled column in output matrix */ - px = pDst->pData + numColsB-1; + px = pDst->pData + numColsB - 1; pInA = pSrcA->pData; /* row loop */ - while (row > 0) - { + while (row > 0) { /* point to last column in matrix B */ - pInB = pSrcB->pData + numColsB-1; + pInB = pSrcB->pData + numColsB - 1; /* Set variable sum1, that acts as accumulator, to zero */ - sum1 = 0; + sum1 = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 columns at a time. */ colCnt = numColsA >> 2U; /* matrix multiplication */ - while (colCnt > 0U) - { -#if defined (ARM_MATH_DSP) + while (colCnt > 0U) { +#if defined(ARM_MATH_DSP) sum1 = __SMMLA(*pInA++, *pInB, sum1); #else - sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) *pInA++ * *pInB)) >> 32); + sum1 = + (q31_t)((((q63_t)sum1 << 32) + ((q63_t)*pInA++ * *pInB)) >> 32); #endif pInB += numColsB; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) sum1 = __SMMLA(*pInA++, *pInB, sum1); #else - sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) *pInA++ * *pInB)) >> 32); + sum1 = + (q31_t)((((q63_t)sum1 << 32) + ((q63_t)*pInA++ * *pInB)) >> 32); #endif pInB += numColsB; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) sum1 = __SMMLA(*pInA++, *pInB, sum1); #else - sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) *pInA++ * *pInB)) >> 32); + sum1 = + (q31_t)((((q63_t)sum1 << 32) + ((q63_t)*pInA++ * *pInB)) >> 32); #endif pInB += numColsB; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) sum1 = __SMMLA(*pInA++, *pInB, sum1); #else - sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) *pInA++ * *pInB)) >> 32); + sum1 = + (q31_t)((((q63_t)sum1 << 32) + ((q63_t)*pInA++ * *pInB)) >> 32); #endif pInB += numColsB; @@ -252,17 +251,19 @@ arm_status arm_mat_mult_fast_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (colCnt > 0U) { -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) sum1 = __SMMLA(*pInA++, *pInB, sum1); #else - sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) *pInA++ * *pInB)) >> 32); + sum1 = + (q31_t)((((q63_t)sum1 << 32) + ((q63_t)*pInA++ * *pInB)) >> 32); #endif pInB += numColsB; - + colCnt--; } - /* Convert the result from 2.30 to 1.31 format and store in destination buffer */ + /* Convert the result from 2.30 to 1.31 format and store in destination + * buffer */ *px = sum1 << 1; px += numColsB; @@ -275,42 +276,40 @@ arm_status arm_mat_mult_fast_q31( if (numRowsA & 1U) { /* point to last row in output matrix */ - px = pDst->pData + (numColsB) * (numRowsA-1); + px = pDst->pData + (numColsB) * (numRowsA - 1); col = numColsB; i = 0U; /* col loop */ - while (col > 0) - { + while (col > 0) { /* point to last row in matrix A */ - pInA = pSrcA->pData + (numRowsA-1) * numColsA; - pInB = pSrcB->pData + i; + pInA = pSrcA->pData + (numRowsA - 1) * numColsA; + pInB = pSrcB->pData + i; /* Set variable sum1, that acts as accumulator, to zero */ - sum1 = 0; + sum1 = 0; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 columns at a time. */ colCnt = numColsA >> 2U; /* matrix multiplication */ - while (colCnt > 0U) - { + while (colCnt > 0U) { inA1 = *pInA++; inA2 = *pInA++; inB1 = *pInB; pInB += numColsB; inB2 = *pInB; pInB += numColsB; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) sum1 = __SMMLA(inA1, inB1, sum1); sum1 = __SMMLA(inA2, inB2, sum1); #else - sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) inA1 * inB1)) >> 32); - sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) inA2 * inB2)) >> 32); + sum1 = (q31_t)((((q63_t)sum1 << 32) + ((q63_t)inA1 * inB1)) >> 32); + sum1 = (q31_t)((((q63_t)sum1 << 32) + ((q63_t)inA2 * inB2)) >> 32); #endif inA1 = *pInA++; @@ -319,12 +318,12 @@ arm_status arm_mat_mult_fast_q31( pInB += numColsB; inB2 = *pInB; pInB += numColsB; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) sum1 = __SMMLA(inA1, inB1, sum1); sum1 = __SMMLA(inA2, inB2, sum1); #else - sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) inA1 * inB1)) >> 32); - sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) inA2 * inB2)) >> 32); + sum1 = (q31_t)((((q63_t)sum1 << 32) + ((q63_t)inA1 * inB1)) >> 32); + sum1 = (q31_t)((((q63_t)sum1 << 32) + ((q63_t)inA2 * inB2)) >> 32); #endif /* Decrement loop counter */ @@ -342,10 +341,11 @@ arm_status arm_mat_mult_fast_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ while (colCnt > 0U) { -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) sum1 = __SMMLA(*pInA++, *pInB, sum1); #else - sum1 = (q31_t) ((((q63_t) sum1 << 32) + ((q63_t) *pInA++ * *pInB)) >> 32); + sum1 = + (q31_t)((((q63_t)sum1 << 32) + ((q63_t)*pInA++ * *pInB)) >> 32); #endif pInB += numColsB; diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_q15.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_q15.c index 1d2b69c..b59172e 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_q15.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_q15.c @@ -42,82 +42,78 @@ @param[in] pSrcA points to the first input matrix structure @param[in] pSrcB points to the second input matrix structure @param[out] pDst points to output matrix structure - @param[in] pState points to the array for storing intermediate results (Unused) + @param[in] pState points to the array for storing intermediate results + (Unused) @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed @par Scaling and Overflow Behavior - The function is implemented using an internal 64-bit accumulator. The inputs to the - multiplications are in 1.15 format and multiplications yield a 2.30 result. - The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. - This approach provides 33 guard bits and there is no risk of overflow. - The 34.30 result is then truncated to 34.15 format by discarding the low 15 bits - and then saturated to 1.15 format. + The function is implemented using an internal 64-bit + accumulator. The inputs to the multiplications are in 1.15 format and + multiplications yield a 2.30 result. The 2.30 intermediate results are + accumulated in a 64-bit accumulator in 34.30 format. This approach provides 33 + guard bits and there is no risk of overflow. The 34.30 result is then + truncated to 34.15 format by discarding the low 15 bits and then saturated + to 1.15 format. @par - Refer to \ref arm_mat_mult_fast_q15() for a faster but less precise version of this function. + Refer to \ref arm_mat_mult_fast_q15() for a faster but less + precise version of this function. */ -arm_status arm_mat_mult_q15( - const arm_matrix_instance_q15 * pSrcA, - const arm_matrix_instance_q15 * pSrcB, - arm_matrix_instance_q15 * pDst, - q15_t * pState) -{ - q63_t sum; /* Accumulator */ +arm_status arm_mat_mult_q15(const arm_matrix_instance_q15 *pSrcA, + const arm_matrix_instance_q15 *pSrcB, + arm_matrix_instance_q15 *pDst, q15_t *pState) { + q63_t sum; /* Accumulator */ -#if defined (ARM_MATH_DSP) /* != CM0 */ +#if defined(ARM_MATH_DSP) /* != CM0 */ - q15_t *pSrcBT = pState; /* Input data matrix pointer for transpose */ - q15_t *pInA = pSrcA->pData; /* Input data matrix pointer A of Q15 type */ - q15_t *pInB = pSrcB->pData; /* Input data matrix pointer B of Q15 type */ - q15_t *px; /* Temporary output data matrix pointer */ - uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ - uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ - uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ - uint16_t numRowsB = pSrcB->numRows; /* Number of rows of input matrix A */ - uint32_t col, i = 0U, row = numRowsB, colCnt; /* Loop counters */ - arm_status status; /* Status of matrix multiplication */ - - q31_t in; /* Temporary variable to hold the input value */ - q31_t inA1, inB1, inA2, inB2; + q15_t *pSrcBT = pState; /* Input data matrix pointer for transpose */ + q15_t *pInA = pSrcA->pData; /* Input data matrix pointer A of Q15 type */ + q15_t *pInB = pSrcB->pData; /* Input data matrix pointer B of Q15 type */ + q15_t *px; /* Temporary output data matrix pointer */ + uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ + uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ + uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ + uint16_t numRowsB = pSrcB->numRows; /* Number of rows of input matrix A */ + uint32_t col, i = 0U, row = numRowsB, colCnt; /* Loop counters */ + arm_status status; /* Status of matrix multiplication */ + + q31_t in; /* Temporary variable to hold the input value */ + q31_t inA1, inB1, inA2, inB2; #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ - if ((pSrcA->numCols != pSrcB->numRows) || - (pSrcA->numRows != pDst->numRows) || - (pSrcB->numCols != pDst->numCols) ) - { + if ((pSrcA->numCols != pSrcB->numRows) || (pSrcA->numRows != pDst->numRows) || + (pSrcB->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Matrix transpose */ - do - { + do { /* The pointer px is set to starting address of column being processed */ px = pSrcBT + i; /* Apply loop unrolling and exchange columns with row elements */ col = numColsB >> 2U; - /* First part of the processing with loop unrolling. Compute 4 outputs at a time. + /* First part of the processing with loop unrolling. Compute 4 outputs at + *a time. ** a second loop below computes the remaining 1 to 3 samples. */ - while (col > 0U) - { + while (col > 0U) { /* Read two elements from row */ - in = read_q15x2_ia ((q15_t **) &pInB); + in = read_q15x2_ia((q15_t **)&pInB); /* Unpack and store one element in destination */ #ifndef ARM_MATH_BIG_ENDIAN - *px = (q15_t) in; + *px = (q15_t)in; #else - *px = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); + *px = (q15_t)((in & (q31_t)0xffff0000) >> 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Update pointer px to point to next row of transposed matrix */ @@ -125,29 +121,29 @@ arm_status arm_mat_mult_q15( /* Unpack and store second element in destination */ #ifndef ARM_MATH_BIG_ENDIAN - *px = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); + *px = (q15_t)((in & (q31_t)0xffff0000) >> 16); #else - *px = (q15_t) in; + *px = (q15_t)in; #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Update pointer px to point to next row of transposed matrix */ px += numRowsB; /* Read two elements from row */ - in = read_q15x2_ia ((q15_t **) &pInB); + in = read_q15x2_ia((q15_t **)&pInB); /* Unpack and store one element in destination */ #ifndef ARM_MATH_BIG_ENDIAN - *px = (q15_t) in; + *px = (q15_t)in; #else - *px = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); + *px = (q15_t)((in & (q31_t)0xffff0000) >> 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ px += numRowsB; #ifndef ARM_MATH_BIG_ENDIAN - *px = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); + *px = (q15_t)((in & (q31_t)0xffff0000) >> 16); #else - *px = (q15_t) in; + *px = (q15_t)in; #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ px += numRowsB; @@ -155,12 +151,12 @@ arm_status arm_mat_mult_q15( col--; } - /* If the columns of pSrcB is not a multiple of 4, compute any remaining output samples here. + /* If the columns of pSrcB is not a multiple of 4, compute any remaining + *output samples here. ** No loop unrolling is used. */ col = numColsB % 0x4U; - while (col > 0U) - { + while (col > 0U) { /* Read and store input element in destination */ *px = *pInB++; @@ -183,39 +179,40 @@ arm_status arm_mat_mult_q15( i = 0U; px = pDst->pData; - /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */ + /* The following loop performs the dot-product of each row in pSrcA with + * each column in pSrcB */ /* row loop */ - do - { + do { /* For every row wise process, column loop counter is to be initiated */ col = numColsB; - /* For every row wise process, pIn2 pointer is set to starting address of transposed pSrcB data */ + /* For every row wise process, pIn2 pointer is set to starting address of + * transposed pSrcB data */ pInB = pSrcBT; /* column loop */ - do - { + do { /* Set variable sum, that acts as accumulator, to zero */ sum = 0; - /* Initiate pointer pInA to point to starting address of column being processed */ + /* Initiate pointer pInA to point to starting address of column being + * processed */ pInA = pSrcA->pData + i; /* Apply loop unrolling and compute 2 MACs simultaneously. */ colCnt = numColsA >> 2U; /* matrix multiplication */ - while (colCnt > 0U) - { - /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ + while (colCnt > 0U) { + /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) + */ /* read real and imag values from pSrcA and pSrcB buffer */ - inA1 = read_q15x2_ia ((q15_t **) &pInA); - inB1 = read_q15x2_ia ((q15_t **) &pInB); + inA1 = read_q15x2_ia((q15_t **)&pInA); + inB1 = read_q15x2_ia((q15_t **)&pInB); - inA2 = read_q15x2_ia ((q15_t **) &pInA); - inB2 = read_q15x2_ia ((q15_t **) &pInB); + inA2 = read_q15x2_ia((q15_t **)&pInA); + inB2 = read_q15x2_ia((q15_t **)&pInB); /* Multiply and Accumlates */ sum = __SMLALD(inA1, inB1, sum); @@ -228,9 +225,9 @@ arm_status arm_mat_mult_q15( /* process remaining column samples */ colCnt = numColsA % 0x4U; - while (colCnt > 0U) - { - /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ + while (colCnt > 0U) { + /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) + */ sum += *pInA++ * *pInB++; /* Decrement loop counter */ @@ -238,7 +235,7 @@ arm_status arm_mat_mult_q15( } /* Saturate and store result in destination buffer */ - *px = (q15_t) (__SSAT((sum >> 15), 16)); + *px = (q15_t)(__SSAT((sum >> 15), 16)); px++; /* Decrement column loop counter */ @@ -255,49 +252,46 @@ arm_status arm_mat_mult_q15( #else /* #if defined (ARM_MATH_DSP) */ - q15_t *pIn1 = pSrcA->pData; /* Input data matrix pointer A */ - q15_t *pIn2 = pSrcB->pData; /* Input data matrix pointer B */ - q15_t *pInA = pSrcA->pData; /* Input data matrix pointer A of Q15 type */ - q15_t *pInB = pSrcB->pData; /* Input data matrix pointer B of Q15 type */ - q15_t *pOut = pDst->pData; /* Output data matrix pointer */ - q15_t *px; /* Temporary output data matrix pointer */ - uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ - uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ - uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ - uint32_t col, i = 0U, row = numRowsA, colCnt; /* Loop counters */ - arm_status status; /* Status of matrix multiplication */ + q15_t *pIn1 = pSrcA->pData; /* Input data matrix pointer A */ + q15_t *pIn2 = pSrcB->pData; /* Input data matrix pointer B */ + q15_t *pInA = pSrcA->pData; /* Input data matrix pointer A of Q15 type */ + q15_t *pInB = pSrcB->pData; /* Input data matrix pointer B of Q15 type */ + q15_t *pOut = pDst->pData; /* Output data matrix pointer */ + q15_t *px; /* Temporary output data matrix pointer */ + uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ + uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ + uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ + uint32_t col, i = 0U, row = numRowsA, colCnt; /* Loop counters */ + arm_status status; /* Status of matrix multiplication */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ - if ((pSrcA->numCols != pSrcB->numRows) || - (pSrcA->numRows != pDst->numRows) || - (pSrcB->numCols != pDst->numCols) ) - { + if ((pSrcA->numCols != pSrcB->numRows) || (pSrcA->numRows != pDst->numRows) || + (pSrcB->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { - /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */ + /* The following loop performs the dot-product of each row in pSrcA with + * each column in pSrcB */ /* row loop */ - do - { + do { /* Output pointer is set to starting address of the row being processed */ px = pOut + i; /* For every row wise process, column loop counter is to be initiated */ col = numColsB; - /* For every row wise process, pIn2 pointer is set to starting address of pSrcB data */ + /* For every row wise process, pIn2 pointer is set to starting address of + * pSrcB data */ pIn2 = pSrcB->pData; /* column loop */ - do - { + do { /* Set the variable sum, that acts as accumulator, to zero */ sum = 0; @@ -308,22 +302,23 @@ arm_status arm_mat_mult_q15( colCnt = numColsA; /* matrix multiplication */ - while (colCnt > 0U) - { - /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ + while (colCnt > 0U) { + /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) + */ /* Perform multiply-accumulates */ - sum += (q31_t) * pIn1++ * *pIn2; + sum += (q31_t)*pIn1++ * *pIn2; pIn2 += numColsB; /* Decrement loop counter */ colCnt--; } - /* Convert result from 34.30 to 1.15 format and store saturated value in destination buffer */ + /* Convert result from 34.30 to 1.15 format and store saturated value in + * destination buffer */ /* Saturate and store result in destination buffer */ - *px++ = (q15_t) __SSAT((sum >> 15), 16); + *px++ = (q15_t)__SSAT((sum >> 15), 16); /* Decrement column loop counter */ col--; diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_q31.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_q31.c index 161e723..70229c5 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_q31.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_mult_q31.c @@ -47,94 +47,92 @@ - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed @par Scaling and Overflow Behavior - The function is implemented using an internal 64-bit accumulator. - The accumulator has a 2.62 format and maintains full precision of the intermediate - multiplication results but provides only a single guard bit. There is no saturation - on intermediate additions. Thus, if the accumulator overflows it wraps around and - distorts the result. The input signals should be scaled down to avoid intermediate - overflows. The input is thus scaled down by log2(numColsA) bits - to avoid overflows, as a total of numColsA additions are performed internally. - The 2.62 accumulator is right shifted by 31 bits and saturated to 1.31 format to yield the final result. + The function is implemented using an internal 64-bit + accumulator. The accumulator has a 2.62 format and maintains full precision of + the intermediate multiplication results but provides only a single guard bit. + There is no saturation on intermediate additions. Thus, if the accumulator + overflows it wraps around and distorts the result. The input signals should be + scaled down to avoid intermediate overflows. The input is thus scaled down by + log2(numColsA) bits to avoid overflows, as a total of numColsA additions are + performed internally. The 2.62 accumulator is right shifted by 31 bits and + saturated to 1.31 format to yield the final result. @remark - Refer to \ref arm_mat_mult_fast_q31() for a faster but less precise implementation of this function. + Refer to \ref arm_mat_mult_fast_q31() for a faster but less + precise implementation of this function. */ -arm_status arm_mat_mult_q31( - const arm_matrix_instance_q31 * pSrcA, - const arm_matrix_instance_q31 * pSrcB, - arm_matrix_instance_q31 * pDst) -{ - q31_t *pIn1 = pSrcA->pData; /* Input data matrix pointer A */ - q31_t *pIn2 = pSrcB->pData; /* Input data matrix pointer B */ - q31_t *pInA = pSrcA->pData; /* Input data matrix pointer A */ - q31_t *pInB = pSrcB->pData; /* Input data matrix pointer B */ - q31_t *pOut = pDst->pData; /* Output data matrix pointer */ - q31_t *px; /* Temporary output data matrix pointer */ - q63_t sum; /* Accumulator */ - uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ - uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ - uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ - uint32_t col, i = 0U, row = numRowsA, colCnt; /* Loop counters */ - arm_status status; /* Status of matrix multiplication */ +arm_status arm_mat_mult_q31(const arm_matrix_instance_q31 *pSrcA, + const arm_matrix_instance_q31 *pSrcB, + arm_matrix_instance_q31 *pDst) { + q31_t *pIn1 = pSrcA->pData; /* Input data matrix pointer A */ + q31_t *pIn2 = pSrcB->pData; /* Input data matrix pointer B */ + q31_t *pInA = pSrcA->pData; /* Input data matrix pointer A */ + q31_t *pInB = pSrcB->pData; /* Input data matrix pointer B */ + q31_t *pOut = pDst->pData; /* Output data matrix pointer */ + q31_t *px; /* Temporary output data matrix pointer */ + q63_t sum; /* Accumulator */ + uint16_t numRowsA = pSrcA->numRows; /* Number of rows of input matrix A */ + uint16_t numColsB = pSrcB->numCols; /* Number of columns of input matrix B */ + uint16_t numColsA = pSrcA->numCols; /* Number of columns of input matrix A */ + uint32_t col, i = 0U, row = numRowsA, colCnt; /* Loop counters */ + arm_status status; /* Status of matrix multiplication */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ - if ((pSrcA->numCols != pSrcB->numRows) || - (pSrcA->numRows != pDst->numRows) || - (pSrcB->numCols != pDst->numCols) ) - { + if ((pSrcA->numCols != pSrcB->numRows) || (pSrcA->numRows != pDst->numRows) || + (pSrcB->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { - /* The following loop performs the dot-product of each row in pSrcA with each column in pSrcB */ + /* The following loop performs the dot-product of each row in pSrcA with + * each column in pSrcB */ /* row loop */ - do - { + do { /* Output pointer is set to starting address of row being processed */ px = pOut + i; /* For every row wise process, column loop counter is to be initiated */ col = numColsB; - /* For every row wise process, pIn2 pointer is set to starting address of pSrcB data */ + /* For every row wise process, pIn2 pointer is set to starting address of + * pSrcB data */ pIn2 = pSrcB->pData; /* column loop */ - do - { + do { /* Set the variable sum, that acts as accumulator, to zero */ sum = 0; - /* Initialize pointer pIn1 to point to starting address of column being processed */ + /* Initialize pointer pIn1 to point to starting address of column being + * processed */ pIn1 = pInA; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 MACs at a time. */ colCnt = numColsA >> 2U; /* matrix multiplication */ - while (colCnt > 0U) - { - /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ + while (colCnt > 0U) { + /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) + */ /* Perform the multiply-accumulates */ - sum += (q63_t) *pIn1++ * *pIn2; + sum += (q63_t)*pIn1++ * *pIn2; pIn2 += numColsB; - sum += (q63_t) *pIn1++ * *pIn2; + sum += (q63_t)*pIn1++ * *pIn2; pIn2 += numColsB; - sum += (q63_t) *pIn1++ * *pIn2; + sum += (q63_t)*pIn1++ * *pIn2; pIn2 += numColsB; - sum += (q63_t) *pIn1++ * *pIn2; + sum += (q63_t)*pIn1++ * *pIn2; pIn2 += numColsB; /* Decrement loop counter */ @@ -151,20 +149,21 @@ arm_status arm_mat_mult_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (colCnt > 0U) - { - /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) */ + while (colCnt > 0U) { + /* c(m,n) = a(1,1) * b(1,1) + a(1,2) * b(2,1) + .... + a(m,p) * b(p,n) + */ /* Perform the multiply-accumulates */ - sum += (q63_t) *pIn1++ * *pIn2; + sum += (q63_t)*pIn1++ * *pIn2; pIn2 += numColsB; /* Decrement loop counter */ colCnt--; } - /* Convert result from 2.62 to 1.31 format and store in destination buffer */ - *px++ = (q31_t) (sum >> 31); + /* Convert result from 2.62 to 1.31 format and store in destination + * buffer */ + *px++ = (q31_t)(sum >> 31); /* Decrement column loop counter */ col--; diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_scale_f32.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_scale_f32.c index cbf3182..4236c2d 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_scale_f32.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_scale_f32.c @@ -35,17 +35,17 @@ /** @defgroup MatrixScale Matrix Scale - Multiplies a matrix by a scalar. This is accomplished by multiplying each element in the - matrix by the scalar. For example: - \image html MatrixScale.gif "Matrix Scaling of a 3 x 3 matrix" + Multiplies a matrix by a scalar. This is accomplished by multiplying each + element in the matrix by the scalar. For example: \image html MatrixScale.gif + "Matrix Scaling of a 3 x 3 matrix" - The function checks to make sure that the input and output matrices are of the same size. + The function checks to make sure that the input and output matrices are of the + same size. In the fixed-point Q15 and Q31 functions, scale is represented by - a fractional multiplication scaleFract and an arithmetic shift shift. - The shift allows the gain of the scaling operation to exceed 1.0. - The overall scale factor applied to the fixed-point data is -
+  a fractional multiplication scaleFract and an arithmetic shift
+  shift. The shift allows the gain of the scaling operation to
+  exceed 1.0. The overall scale factor applied to the fixed-point data is 
       scale = scaleFract * 2^shift.
   
*/ @@ -65,41 +65,34 @@ - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed */ -arm_status arm_mat_scale_f32( - const arm_matrix_instance_f32 * pSrc, - float32_t scale, - arm_matrix_instance_f32 * pDst) -{ - float32_t *pIn = pSrc->pData; /* Input data matrix pointer */ - float32_t *pOut = pDst->pData; /* Output data matrix pointer */ - uint32_t numSamples; /* Total number of elements in the matrix */ - uint32_t blkCnt; /* Loop counters */ - arm_status status; /* Status of matrix scaling */ +arm_status arm_mat_scale_f32(const arm_matrix_instance_f32 *pSrc, + float32_t scale, arm_matrix_instance_f32 *pDst) { + float32_t *pIn = pSrc->pData; /* Input data matrix pointer */ + float32_t *pOut = pDst->pData; /* Output data matrix pointer */ + uint32_t numSamples; /* Total number of elements in the matrix */ + uint32_t blkCnt; /* Loop counters */ + arm_status status; /* Status of matrix scaling */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ - if ((pSrc->numRows != pDst->numRows) || - (pSrc->numCols != pDst->numCols) ) - { + if ((pSrc->numRows != pDst->numRows) || (pSrc->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Total number of samples in input matrix */ - numSamples = (uint32_t) pSrc->numRows * pSrc->numCols; + numSamples = (uint32_t)pSrc->numRows * pSrc->numCols; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C(m,n) = A(m,n) * scale */ /* Scale and store result in destination buffer. */ @@ -122,8 +115,7 @@ arm_status arm_mat_scale_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C(m,n) = A(m,n) * scale */ /* Scale and store result in destination buffer. */ diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_scale_q15.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_scale_q15.c index 9b75d4e..4af3e43 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_scale_q15.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_scale_q15.c @@ -48,66 +48,60 @@ - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed @par Scaling and Overflow Behavior - The input data *pSrc and scaleFract are in 1.15 format. - These are multiplied to yield a 2.30 intermediate result and this is shifted with saturation to 1.15 format. + The input data *pSrc and scaleFract + are in 1.15 format. These are multiplied to yield a 2.30 intermediate result + and this is shifted with saturation to 1.15 format. */ -arm_status arm_mat_scale_q15( - const arm_matrix_instance_q15 * pSrc, - q15_t scaleFract, - int32_t shift, - arm_matrix_instance_q15 * pDst) -{ - q15_t *pIn = pSrc->pData; /* Input data matrix pointer */ - q15_t *pOut = pDst->pData; /* Output data matrix pointer */ - uint32_t numSamples; /* Total number of elements in the matrix */ - uint32_t blkCnt; /* Loop counter */ - arm_status status; /* Status of matrix scaling */ - int32_t kShift = 15 - shift; /* Total shift to apply after scaling */ +arm_status arm_mat_scale_q15(const arm_matrix_instance_q15 *pSrc, + q15_t scaleFract, int32_t shift, + arm_matrix_instance_q15 *pDst) { + q15_t *pIn = pSrc->pData; /* Input data matrix pointer */ + q15_t *pOut = pDst->pData; /* Output data matrix pointer */ + uint32_t numSamples; /* Total number of elements in the matrix */ + uint32_t blkCnt; /* Loop counter */ + arm_status status; /* Status of matrix scaling */ + int32_t kShift = 15 - shift; /* Total shift to apply after scaling */ -#if defined (ARM_MATH_LOOPUNROLL) && defined (ARM_MATH_DSP) - q31_t inA1, inA2; - q31_t out1, out2, out3, out4; /* Temporary output variables */ - q15_t in1, in2, in3, in4; /* Temporary input variables */ +#if defined(ARM_MATH_LOOPUNROLL) && defined(ARM_MATH_DSP) + q31_t inA1, inA2; + q31_t out1, out2, out3, out4; /* Temporary output variables */ + q15_t in1, in2, in3, in4; /* Temporary input variables */ #endif #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ - if ((pSrc->numRows != pDst->numRows) || - (pSrc->numCols != pDst->numCols) ) - { + if ((pSrc->numRows != pDst->numRows) || (pSrc->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Total number of samples in input matrix */ - numSamples = (uint32_t) pSrc->numRows * pSrc->numCols; + numSamples = (uint32_t)pSrc->numRows * pSrc->numCols; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C(m,n) = A(m,n) * k */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) /* read 2 times 2 samples at a time from source */ - inA1 = read_q15x2_ia ((q15_t **) &pIn); - inA2 = read_q15x2_ia ((q15_t **) &pIn); + inA1 = read_q15x2_ia((q15_t **)&pIn); + inA2 = read_q15x2_ia((q15_t **)&pIn); /* Scale inputs and store result in temporary variables * in single cycle by packing the outputs */ - out1 = (q31_t) ((q15_t) (inA1 >> 16) * scaleFract); - out2 = (q31_t) ((q15_t) (inA1 ) * scaleFract); - out3 = (q31_t) ((q15_t) (inA2 >> 16) * scaleFract); - out4 = (q31_t) ((q15_t) (inA2 ) * scaleFract); + out1 = (q31_t)((q15_t)(inA1 >> 16) * scaleFract); + out2 = (q31_t)((q15_t)(inA1)*scaleFract); + out3 = (q31_t)((q15_t)(inA2 >> 16) * scaleFract); + out4 = (q31_t)((q15_t)(inA2)*scaleFract); /* apply shifting */ out1 = out1 >> kShift; @@ -116,20 +110,20 @@ arm_status arm_mat_scale_q15( out4 = out4 >> kShift; /* saturate the output */ - in1 = (q15_t) (__SSAT(out1, 16)); - in2 = (q15_t) (__SSAT(out2, 16)); - in3 = (q15_t) (__SSAT(out3, 16)); - in4 = (q15_t) (__SSAT(out4, 16)); + in1 = (q15_t)(__SSAT(out1, 16)); + in2 = (q15_t)(__SSAT(out2, 16)); + in3 = (q15_t)(__SSAT(out3, 16)); + in4 = (q15_t)(__SSAT(out4, 16)); /* store result to destination */ - write_q15x2_ia (&pOut, __PKHBT(in2, in1, 16)); - write_q15x2_ia (&pOut, __PKHBT(in4, in3, 16)); + write_q15x2_ia(&pOut, __PKHBT(in2, in1, 16)); + write_q15x2_ia(&pOut, __PKHBT(in4, in3, 16)); #else - *pOut++ = (q15_t) (__SSAT(((q31_t) (*pIn++) * scaleFract) >> kShift, 16)); - *pOut++ = (q15_t) (__SSAT(((q31_t) (*pIn++) * scaleFract) >> kShift, 16)); - *pOut++ = (q15_t) (__SSAT(((q31_t) (*pIn++) * scaleFract) >> kShift, 16)); - *pOut++ = (q15_t) (__SSAT(((q31_t) (*pIn++) * scaleFract) >> kShift, 16)); + *pOut++ = (q15_t)(__SSAT(((q31_t)(*pIn++) * scaleFract) >> kShift, 16)); + *pOut++ = (q15_t)(__SSAT(((q31_t)(*pIn++) * scaleFract) >> kShift, 16)); + *pOut++ = (q15_t)(__SSAT(((q31_t)(*pIn++) * scaleFract) >> kShift, 16)); + *pOut++ = (q15_t)(__SSAT(((q31_t)(*pIn++) * scaleFract) >> kShift, 16)); #endif /* Decrement loop counter */ @@ -146,12 +140,11 @@ arm_status arm_mat_scale_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C(m,n) = A(m,n) * k */ /* Scale, saturate and store result in destination buffer. */ - *pOut++ = (q15_t) (__SSAT(((q31_t) (*pIn++) * scaleFract) >> kShift, 16)); + *pOut++ = (q15_t)(__SSAT(((q31_t)(*pIn++) * scaleFract) >> kShift, 16)); /* Decrement loop counter */ blkCnt--; diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_scale_q31.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_scale_q31.c index 929b17f..fb8a9b2 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_scale_q31.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_scale_q31.c @@ -48,74 +48,69 @@ - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed @par Scaling and Overflow Behavior - The input data *pSrc and scaleFract are in 1.31 format. - These are multiplied to yield a 2.62 intermediate result which is shifted with saturation to 1.31 format. + The input data *pSrc and scaleFract + are in 1.31 format. These are multiplied to yield a 2.62 intermediate result + which is shifted with saturation to 1.31 format. */ -arm_status arm_mat_scale_q31( - const arm_matrix_instance_q31 * pSrc, - q31_t scaleFract, - int32_t shift, - arm_matrix_instance_q31 * pDst) -{ - q31_t *pIn = pSrc->pData; /* Input data matrix pointer */ - q31_t *pOut = pDst->pData; /* Output data matrix pointer */ - uint32_t numSamples; /* Total number of elements in the matrix */ - uint32_t blkCnt; /* Loop counter */ - arm_status status; /* Status of matrix scaling */ - int32_t kShift = shift + 1; /* Shift to apply after scaling */ - q31_t in, out; /* Temporary variabels */ +arm_status arm_mat_scale_q31(const arm_matrix_instance_q31 *pSrc, + q31_t scaleFract, int32_t shift, + arm_matrix_instance_q31 *pDst) { + q31_t *pIn = pSrc->pData; /* Input data matrix pointer */ + q31_t *pOut = pDst->pData; /* Output data matrix pointer */ + uint32_t numSamples; /* Total number of elements in the matrix */ + uint32_t blkCnt; /* Loop counter */ + arm_status status; /* Status of matrix scaling */ + int32_t kShift = shift + 1; /* Shift to apply after scaling */ + q31_t in, out; /* Temporary variabels */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ - if ((pSrc->numRows != pDst->numRows) || - (pSrc->numCols != pDst->numCols) ) - { + if ((pSrc->numRows != pDst->numRows) || (pSrc->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Total number of samples in input matrix */ - numSamples = (uint32_t) pSrc->numRows * pSrc->numCols; + numSamples = (uint32_t)pSrc->numRows * pSrc->numCols; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C(m,n) = A(m,n) * k */ /* Scale, saturate and store result in destination buffer. */ - in = *pIn++; /* read four inputs from source */ - in = ((q63_t) in * scaleFract) >> 32; /* multiply input with scaler value */ - out = in << kShift; /* apply shifting */ - if (in != (out >> kShift)) /* saturate the results. */ + in = *pIn++; /* read four inputs from source */ + in = + ((q63_t)in * scaleFract) >> 32; /* multiply input with scaler value */ + out = in << kShift; /* apply shifting */ + if (in != (out >> kShift)) /* saturate the results. */ out = 0x7FFFFFFF ^ (in >> 31); - *pOut++ = out; /* Store result destination */ + *pOut++ = out; /* Store result destination */ in = *pIn++; - in = ((q63_t) in * scaleFract) >> 32; + in = ((q63_t)in * scaleFract) >> 32; out = in << kShift; if (in != (out >> kShift)) out = 0x7FFFFFFF ^ (in >> 31); *pOut++ = out; in = *pIn++; - in = ((q63_t) in * scaleFract) >> 32; + in = ((q63_t)in * scaleFract) >> 32; out = in << kShift; if (in != (out >> kShift)) out = 0x7FFFFFFF ^ (in >> 31); *pOut++ = out; in = *pIn++; - in = ((q63_t) in * scaleFract) >> 32; + in = ((q63_t)in * scaleFract) >> 32; out = in << kShift; if (in != (out >> kShift)) out = 0x7FFFFFFF ^ (in >> 31); @@ -135,13 +130,12 @@ arm_status arm_mat_scale_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C(m,n) = A(m,n) * k */ /* Scale, saturate and store result in destination buffer. */ in = *pIn++; - in = ((q63_t) in * scaleFract) >> 32; + in = ((q63_t)in * scaleFract) >> 32; out = in << kShift; if (in != (out >> kShift)) out = 0x7FFFFFFF ^ (in >> 31); diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_sub_f32.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_sub_f32.c index 5341216..8c67404 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_sub_f32.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_sub_f32.c @@ -58,45 +58,39 @@ - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed */ -arm_status arm_mat_sub_f32( - const arm_matrix_instance_f32 * pSrcA, - const arm_matrix_instance_f32 * pSrcB, - arm_matrix_instance_f32 * pDst) -{ - float32_t *pInA = pSrcA->pData; /* input data matrix pointer A */ - float32_t *pInB = pSrcB->pData; /* input data matrix pointer B */ - float32_t *pOut = pDst->pData; /* output data matrix pointer */ +arm_status arm_mat_sub_f32(const arm_matrix_instance_f32 *pSrcA, + const arm_matrix_instance_f32 *pSrcB, + arm_matrix_instance_f32 *pDst) { + float32_t *pInA = pSrcA->pData; /* input data matrix pointer A */ + float32_t *pInB = pSrcB->pData; /* input data matrix pointer B */ + float32_t *pOut = pDst->pData; /* output data matrix pointer */ - uint32_t numSamples; /* total number of elements in the matrix */ - uint32_t blkCnt; /* loop counters */ - arm_status status; /* status of matrix subtraction */ + uint32_t numSamples; /* total number of elements in the matrix */ + uint32_t blkCnt; /* loop counters */ + arm_status status; /* status of matrix subtraction */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrcA->numRows != pSrcB->numRows) || - (pSrcA->numCols != pSrcB->numCols) || - (pSrcA->numRows != pDst->numRows) || - (pSrcA->numCols != pDst->numCols) ) - { + (pSrcA->numCols != pSrcB->numCols) || (pSrcA->numRows != pDst->numRows) || + (pSrcA->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Total number of samples in input matrix */ - numSamples = (uint32_t) pSrcA->numRows * pSrcA->numCols; + numSamples = (uint32_t)pSrcA->numRows * pSrcA->numCols; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C(m,n) = A(m,n) - B(m,n) */ /* Subtract and store result in destination buffer. */ @@ -119,8 +113,7 @@ arm_status arm_mat_sub_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C(m,n) = A(m,n) - B(m,n) */ /* Subtract and store result in destination buffer. */ diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_sub_q15.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_sub_q15.c index 5d5e5d0..19434f9 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_sub_q15.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_sub_q15.c @@ -48,58 +48,55 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q15 range [0x8000 0x7FFF] are saturated. + Results outside of the allowable Q15 range [0x8000 0x7FFF] + are saturated. */ -arm_status arm_mat_sub_q15( - const arm_matrix_instance_q15 * pSrcA, - const arm_matrix_instance_q15 * pSrcB, - arm_matrix_instance_q15 * pDst) -{ - q15_t *pInA = pSrcA->pData; /* input data matrix pointer A */ - q15_t *pInB = pSrcB->pData; /* input data matrix pointer B */ - q15_t *pOut = pDst->pData; /* output data matrix pointer */ +arm_status arm_mat_sub_q15(const arm_matrix_instance_q15 *pSrcA, + const arm_matrix_instance_q15 *pSrcB, + arm_matrix_instance_q15 *pDst) { + q15_t *pInA = pSrcA->pData; /* input data matrix pointer A */ + q15_t *pInB = pSrcB->pData; /* input data matrix pointer B */ + q15_t *pOut = pDst->pData; /* output data matrix pointer */ - uint32_t numSamples; /* total number of elements in the matrix */ - uint32_t blkCnt; /* loop counters */ - arm_status status; /* status of matrix subtraction */ + uint32_t numSamples; /* total number of elements in the matrix */ + uint32_t blkCnt; /* loop counters */ + arm_status status; /* status of matrix subtraction */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrcA->numRows != pSrcB->numRows) || - (pSrcA->numCols != pSrcB->numCols) || - (pSrcA->numRows != pDst->numRows) || - (pSrcA->numCols != pDst->numCols) ) - { + (pSrcA->numCols != pSrcB->numCols) || (pSrcA->numRows != pDst->numRows) || + (pSrcA->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Total number of samples in input matrix */ - numSamples = (uint32_t) pSrcA->numRows * pSrcA->numCols; + numSamples = (uint32_t)pSrcA->numRows * pSrcA->numCols; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C(m,n) = A(m,n) - B(m,n) */ /* Subtract, Saturate and store result in destination buffer. */ -#if defined (ARM_MATH_DSP) - write_q15x2_ia (&pOut, __QSUB16(read_q15x2_ia ((q15_t **) &pInA), read_q15x2_ia ((q15_t **) &pInB))); - write_q15x2_ia (&pOut, __QSUB16(read_q15x2_ia ((q15_t **) &pInA), read_q15x2_ia ((q15_t **) &pInB))); +#if defined(ARM_MATH_DSP) + write_q15x2_ia(&pOut, __QSUB16(read_q15x2_ia((q15_t **)&pInA), + read_q15x2_ia((q15_t **)&pInB))); + write_q15x2_ia(&pOut, __QSUB16(read_q15x2_ia((q15_t **)&pInA), + read_q15x2_ia((q15_t **)&pInB))); #else - *pOut++ = (q15_t) __SSAT(((q31_t) * pInA++ - *pInB++), 16); - *pOut++ = (q15_t) __SSAT(((q31_t) * pInA++ - *pInB++), 16); - *pOut++ = (q15_t) __SSAT(((q31_t) * pInA++ - *pInB++), 16); - *pOut++ = (q15_t) __SSAT(((q31_t) * pInA++ - *pInB++), 16); + *pOut++ = (q15_t)__SSAT(((q31_t)*pInA++ - *pInB++), 16); + *pOut++ = (q15_t)__SSAT(((q31_t)*pInA++ - *pInB++), 16); + *pOut++ = (q15_t)__SSAT(((q31_t)*pInA++ - *pInB++), 16); + *pOut++ = (q15_t)__SSAT(((q31_t)*pInA++ - *pInB++), 16); #endif /* Decrement loop counter */ @@ -116,15 +113,14 @@ arm_status arm_mat_sub_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C(m,n) = A(m,n) - B(m,n) */ /* Subtract and store result in destination buffer. */ -#if defined (ARM_MATH_DSP) - *pOut++ = (q15_t) __QSUB16(*pInA++, *pInB++); +#if defined(ARM_MATH_DSP) + *pOut++ = (q15_t)__QSUB16(*pInA++, *pInB++); #else - *pOut++ = (q15_t) __SSAT(((q31_t) * pInA++ - *pInB++), 16); + *pOut++ = (q15_t)__SSAT(((q31_t)*pInA++ - *pInB++), 16); #endif /* Decrement loop counter */ diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_sub_q31.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_sub_q31.c index 40d1bef..b63e959 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_sub_q31.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_sub_q31.c @@ -48,51 +48,47 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q31 range [0x80000000 0x7FFFFFFF] are saturated. + Results outside of the allowable Q31 range [0x80000000 + 0x7FFFFFFF] are saturated. */ -arm_status arm_mat_sub_q31( - const arm_matrix_instance_q31 * pSrcA, - const arm_matrix_instance_q31 * pSrcB, - arm_matrix_instance_q31 * pDst) -{ - q31_t *pInA = pSrcA->pData; /* input data matrix pointer A */ - q31_t *pInB = pSrcB->pData; /* input data matrix pointer B */ - q31_t *pOut = pDst->pData; /* output data matrix pointer */ +arm_status arm_mat_sub_q31(const arm_matrix_instance_q31 *pSrcA, + const arm_matrix_instance_q31 *pSrcB, + arm_matrix_instance_q31 *pDst) { + q31_t *pInA = pSrcA->pData; /* input data matrix pointer A */ + q31_t *pInB = pSrcB->pData; /* input data matrix pointer B */ + q31_t *pOut = pDst->pData; /* output data matrix pointer */ - uint32_t numSamples; /* total number of elements in the matrix */ - uint32_t blkCnt; /* loop counters */ - arm_status status; /* status of matrix subtraction */ + uint32_t numSamples; /* total number of elements in the matrix */ + uint32_t blkCnt; /* loop counters */ + arm_status status; /* status of matrix subtraction */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ if ((pSrcA->numRows != pSrcB->numRows) || - (pSrcA->numCols != pSrcB->numCols) || - (pSrcA->numRows != pDst->numRows) || - (pSrcA->numCols != pDst->numCols) ) - { + (pSrcA->numCols != pSrcB->numCols) || (pSrcA->numRows != pDst->numRows) || + (pSrcA->numCols != pDst->numCols)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Total number of samples in input matrix */ - numSamples = (uint32_t) pSrcA->numRows * pSrcA->numCols; + numSamples = (uint32_t)pSrcA->numRows * pSrcA->numCols; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = numSamples >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C(m,n) = A(m,n) - B(m,n) */ - /* Subtract, saturate and then store the results in the destination buffer. */ + /* Subtract, saturate and then store the results in the destination + * buffer. */ *pOut++ = __QSUB(*pInA++, *pInB++); *pOut++ = __QSUB(*pInA++, *pInB++); @@ -115,8 +111,7 @@ arm_status arm_mat_sub_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C(m,n) = A(m,n) - B(m,n) */ /* Subtract, saturate and store result in destination buffer. */ diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_trans_f32.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_trans_f32.c index b137e61..da181ad 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_trans_f32.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_trans_f32.c @@ -37,8 +37,9 @@ Tranposes a matrix. - Transposing an M x N matrix flips it around the center diagonal and results in an N x M matrix. - \image html MatrixTranspose.gif "Transpose of a 3 x 3 matrix" + Transposing an M x N matrix flips it around the center diagonal + and results in an N x M matrix. \image html MatrixTranspose.gif + "Transpose of a 3 x 3 matrix" */ /** @@ -55,45 +56,39 @@ - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed */ -arm_status arm_mat_trans_f32( - const arm_matrix_instance_f32 * pSrc, - arm_matrix_instance_f32 * pDst) -{ - float32_t *pIn = pSrc->pData; /* input data matrix pointer */ - float32_t *pOut = pDst->pData; /* output data matrix pointer */ - float32_t *px; /* Temporary output data matrix pointer */ - uint16_t nRows = pSrc->numRows; /* number of rows */ - uint16_t nCols = pSrc->numCols; /* number of columns */ - uint32_t col, row = nRows, i = 0U; /* Loop counters */ - arm_status status; /* status of matrix transpose */ +arm_status arm_mat_trans_f32(const arm_matrix_instance_f32 *pSrc, + arm_matrix_instance_f32 *pDst) { + float32_t *pIn = pSrc->pData; /* input data matrix pointer */ + float32_t *pOut = pDst->pData; /* output data matrix pointer */ + float32_t *px; /* Temporary output data matrix pointer */ + uint16_t nRows = pSrc->numRows; /* number of rows */ + uint16_t nCols = pSrc->numCols; /* number of columns */ + uint32_t col, row = nRows, i = 0U; /* Loop counters */ + arm_status status; /* status of matrix transpose */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ - if ((pSrc->numRows != pDst->numCols) || - (pSrc->numCols != pDst->numRows) ) - { + if ((pSrc->numRows != pDst->numCols) || (pSrc->numCols != pDst->numRows)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Matrix transpose by exchanging the rows with columns */ /* row loop */ - do - { + do { /* Pointer px is set to starting address of column being processed */ px = pOut + i; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ col = nCols >> 2U; - while (col > 0U) /* column loop */ + while (col > 0U) /* column loop */ { /* Read and store input element in destination */ *px = *pIn++; @@ -123,8 +118,7 @@ arm_status arm_mat_trans_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (col > 0U) - { + while (col > 0U) { /* Read and store input element in destination */ *px = *pIn++; @@ -140,7 +134,7 @@ arm_status arm_mat_trans_f32( /* Decrement row loop counter */ row--; - } while (row > 0U); /* row loop end */ + } while (row > 0U); /* row loop end */ /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_trans_q15.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_trans_q15.c index 707e0d6..c556776 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_trans_q15.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_trans_q15.c @@ -46,57 +46,51 @@ - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed */ -arm_status arm_mat_trans_q15( - const arm_matrix_instance_q15 * pSrc, - arm_matrix_instance_q15 * pDst) -{ - q15_t *pIn = pSrc->pData; /* input data matrix pointer */ - q15_t *pOut = pDst->pData; /* output data matrix pointer */ - uint16_t nRows = pSrc->numRows; /* number of rows */ - uint16_t nCols = pSrc->numCols; /* number of columns */ - uint32_t col, row = nRows, i = 0U; /* Loop counters */ - arm_status status; /* status of matrix transpose */ +arm_status arm_mat_trans_q15(const arm_matrix_instance_q15 *pSrc, + arm_matrix_instance_q15 *pDst) { + q15_t *pIn = pSrc->pData; /* input data matrix pointer */ + q15_t *pOut = pDst->pData; /* output data matrix pointer */ + uint16_t nRows = pSrc->numRows; /* number of rows */ + uint16_t nCols = pSrc->numCols; /* number of columns */ + uint32_t col, row = nRows, i = 0U; /* Loop counters */ + arm_status status; /* status of matrix transpose */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t in; /* variable to hold temporary output */ +#if defined(ARM_MATH_LOOPUNROLL) + q31_t in; /* variable to hold temporary output */ #endif #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ - if ((pSrc->numRows != pDst->numCols) || - (pSrc->numCols != pDst->numRows) ) - { + if ((pSrc->numRows != pDst->numCols) || (pSrc->numCols != pDst->numRows)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Matrix transpose by exchanging the rows with columns */ /* row loop */ - do - { + do { /* Pointer pOut is set to starting address of column being processed */ pOut = pDst->pData + i; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ col = nCols >> 2U; - while (col > 0U) /* column loop */ + while (col > 0U) /* column loop */ { /* Read two elements from row */ - in = read_q15x2_ia ((q15_t **) &pIn); + in = read_q15x2_ia((q15_t **)&pIn); /* Unpack and store one element in destination */ #ifndef ARM_MATH_BIG_ENDIAN - *pOut = (q15_t) in; + *pOut = (q15_t)in; #else - *pOut = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); + *pOut = (q15_t)((in & (q31_t)0xffff0000) >> 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Update pointer pOut to point to next row of transposed matrix */ @@ -104,22 +98,22 @@ arm_status arm_mat_trans_q15( /* Unpack and store second element in destination */ #ifndef ARM_MATH_BIG_ENDIAN - *pOut = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); + *pOut = (q15_t)((in & (q31_t)0xffff0000) >> 16); #else - *pOut = (q15_t) in; + *pOut = (q15_t)in; #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Update pointer pOut to point to next row of transposed matrix */ pOut += nRows; /* Read two elements from row */ - in = read_q15x2_ia ((q15_t **) &pIn); + in = read_q15x2_ia((q15_t **)&pIn); /* Unpack and store one element in destination */ #ifndef ARM_MATH_BIG_ENDIAN - *pOut = (q15_t) in; + *pOut = (q15_t)in; #else - *pOut = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); + *pOut = (q15_t)((in & (q31_t)0xffff0000) >> 16); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ @@ -128,9 +122,9 @@ arm_status arm_mat_trans_q15( /* Unpack and store second element in destination */ #ifndef ARM_MATH_BIG_ENDIAN - *pOut = (q15_t) ((in & (q31_t) 0xffff0000) >> 16); + *pOut = (q15_t)((in & (q31_t)0xffff0000) >> 16); #else - *pOut = (q15_t) in; + *pOut = (q15_t)in; #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* Update pointer pOut to point to next row of transposed matrix */ @@ -150,8 +144,7 @@ arm_status arm_mat_trans_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (col > 0U) - { + while (col > 0U) { /* Read and store input element in destination */ *pOut = *pIn++; @@ -167,7 +160,7 @@ arm_status arm_mat_trans_q15( /* Decrement row loop counter */ row--; - } while (row > 0U); /* row loop end */ + } while (row > 0U); /* row loop end */ /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; diff --git a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_trans_q31.c b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_trans_q31.c index 5d0b5e2..5369c21 100644 --- a/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_trans_q31.c +++ b/platform/cmsis/DSP_Lib/MatrixFunctions/arm_mat_trans_q31.c @@ -46,45 +46,39 @@ - \ref ARM_MATH_SIZE_MISMATCH : Matrix size check failed */ -arm_status arm_mat_trans_q31( - const arm_matrix_instance_q31 * pSrc, - arm_matrix_instance_q31 * pDst) -{ - q31_t *pIn = pSrc->pData; /* input data matrix pointer */ - q31_t *pOut = pDst->pData; /* output data matrix pointer */ - q31_t *px; /* Temporary output data matrix pointer */ - uint16_t nRows = pSrc->numRows; /* number of rows */ - uint16_t nCols = pSrc->numCols; /* number of columns */ - uint32_t col, row = nRows, i = 0U; /* Loop counters */ - arm_status status; /* status of matrix transpose */ +arm_status arm_mat_trans_q31(const arm_matrix_instance_q31 *pSrc, + arm_matrix_instance_q31 *pDst) { + q31_t *pIn = pSrc->pData; /* input data matrix pointer */ + q31_t *pOut = pDst->pData; /* output data matrix pointer */ + q31_t *px; /* Temporary output data matrix pointer */ + uint16_t nRows = pSrc->numRows; /* number of rows */ + uint16_t nCols = pSrc->numCols; /* number of columns */ + uint32_t col, row = nRows, i = 0U; /* Loop counters */ + arm_status status; /* status of matrix transpose */ #ifdef ARM_MATH_MATRIX_CHECK /* Check for matrix mismatch condition */ - if ((pSrc->numRows != pDst->numCols) || - (pSrc->numCols != pDst->numRows) ) - { + if ((pSrc->numRows != pDst->numCols) || (pSrc->numCols != pDst->numRows)) { /* Set status as ARM_MATH_SIZE_MISMATCH */ status = ARM_MATH_SIZE_MISMATCH; - } - else + } else #endif /* #ifdef ARM_MATH_MATRIX_CHECK */ { /* Matrix transpose by exchanging the rows with columns */ /* row loop */ - do - { + do { /* Pointer px is set to starting address of column being processed */ px = pOut + i; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ col = nCols >> 2U; - while (col > 0U) /* column loop */ + while (col > 0U) /* column loop */ { /* Read and store input element in destination */ *px = *pIn++; @@ -114,8 +108,7 @@ arm_status arm_mat_trans_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (col > 0U) - { + while (col > 0U) { /* Read and store input element in destination */ *px = *pIn++; @@ -131,7 +124,7 @@ arm_status arm_mat_trans_q31( /* Decrement row loop counter */ row--; - } while (row > 0U); /* row loop end */ + } while (row > 0U); /* row loop end */ /* Set status as ARM_MATH_SUCCESS */ status = ARM_MATH_SUCCESS; diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_max_f32.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_max_f32.c index 175fa92..11ae030 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_max_f32.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_max_f32.c @@ -54,17 +54,13 @@ @return none */ -void arm_max_f32( - const float32_t * pSrc, - uint32_t blockSize, - float32_t * pResult, - uint32_t * pIndex) -{ - float32_t maxVal, out; /* Temporary variables to store the output value. */ - uint32_t blkCnt, outIndex; /* Loop counter */ +void arm_max_f32(const float32_t *pSrc, uint32_t blockSize, float32_t *pResult, + uint32_t *pIndex) { + float32_t maxVal, out; /* Temporary variables to store the output value. */ + uint32_t blkCnt, outIndex; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) - uint32_t index; /* index of maximum value */ +#if defined(ARM_MATH_LOOPUNROLL) + uint32_t index; /* index of maximum value */ #endif /* Initialise index value to zero. */ @@ -72,43 +68,38 @@ void arm_max_f32( /* Load first input value that act as reference value for comparision */ out = *pSrc++; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Initialise index of maximum value. */ index = 0U; /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = (blockSize - 1U) >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Initialize maxVal to next consecutive values one by one */ maxVal = *pSrc++; /* compare for the maximum value */ - if (out < maxVal) - { + if (out < maxVal) { /* Update the maximum value and it's index */ out = maxVal; outIndex = index + 1U; } maxVal = *pSrc++; - if (out < maxVal) - { + if (out < maxVal) { out = maxVal; outIndex = index + 2U; } maxVal = *pSrc++; - if (out < maxVal) - { + if (out < maxVal) { out = maxVal; outIndex = index + 3U; } maxVal = *pSrc++; - if (out < maxVal) - { + if (out < maxVal) { out = maxVal; outIndex = index + 4U; } @@ -129,14 +120,12 @@ void arm_max_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Initialize maxVal to the next consecutive values one by one */ maxVal = *pSrc++; /* compare for the maximum value */ - if (out < maxVal) - { + if (out < maxVal) { /* Update the maximum value and it's index */ out = maxVal; outIndex = blockSize - blkCnt; diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_max_q15.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_max_q15.c index 329b0c8..0f7e2eb 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_max_q15.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_max_q15.c @@ -46,17 +46,13 @@ @return none */ -void arm_max_q15( - const q15_t * pSrc, - uint32_t blockSize, - q15_t * pResult, - uint32_t * pIndex) -{ - q15_t maxVal, out; /* Temporary variables to store the output value. */ - uint32_t blkCnt, outIndex; /* Loop counter */ +void arm_max_q15(const q15_t *pSrc, uint32_t blockSize, q15_t *pResult, + uint32_t *pIndex) { + q15_t maxVal, out; /* Temporary variables to store the output value. */ + uint32_t blkCnt, outIndex; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) - uint32_t index; /* index of maximum value */ +#if defined(ARM_MATH_LOOPUNROLL) + uint32_t index; /* index of maximum value */ #endif /* Initialise index value to zero. */ @@ -64,43 +60,38 @@ void arm_max_q15( /* Load first input value that act as reference value for comparision */ out = *pSrc++; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Initialise index of maximum value. */ index = 0U; /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = (blockSize - 1U) >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Initialize maxVal to next consecutive values one by one */ maxVal = *pSrc++; /* compare for the maximum value */ - if (out < maxVal) - { + if (out < maxVal) { /* Update the maximum value and it's index */ out = maxVal; outIndex = index + 1U; } maxVal = *pSrc++; - if (out < maxVal) - { + if (out < maxVal) { out = maxVal; outIndex = index + 2U; } maxVal = *pSrc++; - if (out < maxVal) - { + if (out < maxVal) { out = maxVal; outIndex = index + 3U; } maxVal = *pSrc++; - if (out < maxVal) - { + if (out < maxVal) { out = maxVal; outIndex = index + 4U; } @@ -121,14 +112,12 @@ void arm_max_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Initialize maxVal to the next consecutive values one by one */ maxVal = *pSrc++; /* compare for the maximum value */ - if (out < maxVal) - { + if (out < maxVal) { /* Update the maximum value and it's index */ out = maxVal; outIndex = blockSize - blkCnt; diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_max_q31.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_max_q31.c index 99de13e..7405629 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_max_q31.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_max_q31.c @@ -46,17 +46,13 @@ @return none */ -void arm_max_q31( - const q31_t * pSrc, - uint32_t blockSize, - q31_t * pResult, - uint32_t * pIndex) -{ - q31_t maxVal, out; /* Temporary variables to store the output value. */ - uint32_t blkCnt, outIndex; /* Loop counter */ +void arm_max_q31(const q31_t *pSrc, uint32_t blockSize, q31_t *pResult, + uint32_t *pIndex) { + q31_t maxVal, out; /* Temporary variables to store the output value. */ + uint32_t blkCnt, outIndex; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) - uint32_t index; /* index of maximum value */ +#if defined(ARM_MATH_LOOPUNROLL) + uint32_t index; /* index of maximum value */ #endif /* Initialise index value to zero. */ @@ -64,43 +60,38 @@ void arm_max_q31( /* Load first input value that act as reference value for comparision */ out = *pSrc++; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Initialise index of maximum value. */ index = 0U; /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = (blockSize - 1U) >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Initialize maxVal to next consecutive values one by one */ maxVal = *pSrc++; /* compare for the maximum value */ - if (out < maxVal) - { + if (out < maxVal) { /* Update the maximum value and it's index */ out = maxVal; outIndex = index + 1U; } maxVal = *pSrc++; - if (out < maxVal) - { + if (out < maxVal) { out = maxVal; outIndex = index + 2U; } maxVal = *pSrc++; - if (out < maxVal) - { + if (out < maxVal) { out = maxVal; outIndex = index + 3U; } maxVal = *pSrc++; - if (out < maxVal) - { + if (out < maxVal) { out = maxVal; outIndex = index + 4U; } @@ -121,14 +112,12 @@ void arm_max_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Initialize maxVal to the next consecutive values one by one */ maxVal = *pSrc++; /* compare for the maximum value */ - if (out < maxVal) - { + if (out < maxVal) { /* Update the maximum value and it's index */ out = maxVal; outIndex = blockSize - blkCnt; diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_max_q7.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_max_q7.c index 9c8b6d3..071b07e 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_max_q7.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_max_q7.c @@ -46,17 +46,13 @@ @return none */ -void arm_max_q7( - const q7_t * pSrc, - uint32_t blockSize, - q7_t * pResult, - uint32_t * pIndex) -{ - q7_t maxVal, out; /* Temporary variables to store the output value. */ - uint32_t blkCnt, outIndex; /* Loop counter */ +void arm_max_q7(const q7_t *pSrc, uint32_t blockSize, q7_t *pResult, + uint32_t *pIndex) { + q7_t maxVal, out; /* Temporary variables to store the output value. */ + uint32_t blkCnt, outIndex; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) - uint32_t index; /* index of maximum value */ +#if defined(ARM_MATH_LOOPUNROLL) + uint32_t index; /* index of maximum value */ #endif /* Initialise index value to zero. */ @@ -64,43 +60,38 @@ void arm_max_q7( /* Load first input value that act as reference value for comparision */ out = *pSrc++; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Initialise index of maximum value. */ index = 0U; /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = (blockSize - 1U) >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Initialize maxVal to next consecutive values one by one */ maxVal = *pSrc++; /* compare for the maximum value */ - if (out < maxVal) - { + if (out < maxVal) { /* Update the maximum value and it's index */ out = maxVal; outIndex = index + 1U; } maxVal = *pSrc++; - if (out < maxVal) - { + if (out < maxVal) { out = maxVal; outIndex = index + 2U; } maxVal = *pSrc++; - if (out < maxVal) - { + if (out < maxVal) { out = maxVal; outIndex = index + 3U; } maxVal = *pSrc++; - if (out < maxVal) - { + if (out < maxVal) { out = maxVal; outIndex = index + 4U; } @@ -121,14 +112,12 @@ void arm_max_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Initialize maxVal to the next consecutive values one by one */ maxVal = *pSrc++; /* compare for the maximum value */ - if (out < maxVal) - { + if (out < maxVal) { /* Update the maximum value and it's index */ out = maxVal; outIndex = blockSize - blkCnt; diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_mean_f32.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_mean_f32.c index 11389c0..16e03ea 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_mean_f32.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_mean_f32.c @@ -35,11 +35,12 @@ /** @defgroup mean Mean - Calculates the mean of the input vector. Mean is defined as the average of the elements in the vector. - The underlying algorithm is used: + Calculates the mean of the input vector. Mean is defined as the average of the + elements in the vector. The underlying algorithm is used:
-      Result = (pSrc[0] + pSrc[1] + pSrc[2] + ... + pSrc[blockSize-1]) / blockSize;
+      Result = (pSrc[0] + pSrc[1] + pSrc[2] + ... + pSrc[blockSize-1]) /
+  blockSize;
   
There are separate functions for floating-point, Q31, Q15, and Q7 data types. @@ -58,21 +59,17 @@ @return none */ -void arm_mean_f32( - const float32_t * pSrc, - uint32_t blockSize, - float32_t * pResult) -{ - uint32_t blkCnt; /* Loop counter */ - float32_t sum = 0.0f; /* Temporary result storage */ +void arm_mean_f32(const float32_t *pSrc, uint32_t blockSize, + float32_t *pResult) { + uint32_t blkCnt; /* Loop counter */ + float32_t sum = 0.0f; /* Temporary result storage */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (A[0] + A[1] + A[2] + ... + A[blockSize-1]) */ sum += *pSrc++; @@ -96,8 +93,7 @@ void arm_mean_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (A[0] + A[1] + A[2] + ... + A[blockSize-1]) */ sum += *pSrc++; diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_mean_q15.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_mean_q15.c index 463aa84..5fa981f 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_mean_q15.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_mean_q15.c @@ -45,41 +45,36 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using a 32-bit internal accumulator. - The input is represented in 1.15 format and is accumulated in a 32-bit - accumulator in 17.15 format. - There is no risk of internal overflow with this approach, and the - full precision of intermediate result is preserved. - Finally, the accumulator is truncated to yield a result of 1.15 format. + The function is implemented using a 32-bit internal + accumulator. The input is represented in 1.15 format and is accumulated in a + 32-bit accumulator in 17.15 format. There is no risk of internal overflow with + this approach, and the full precision of intermediate result is preserved. + Finally, the accumulator is truncated to yield a result + of 1.15 format. */ -void arm_mean_q15( - const q15_t * pSrc, - uint32_t blockSize, - q15_t * pResult) -{ - uint32_t blkCnt; /* Loop counter */ - q31_t sum = 0; /* Temporary result storage */ +void arm_mean_q15(const q15_t *pSrc, uint32_t blockSize, q15_t *pResult) { + uint32_t blkCnt; /* Loop counter */ + q31_t sum = 0; /* Temporary result storage */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t in; +#if defined(ARM_MATH_LOOPUNROLL) + q31_t in; #endif -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (A[0] + A[1] + A[2] + ... + A[blockSize-1]) */ - in = read_q15x2_ia ((q15_t **) &pSrc); + in = read_q15x2_ia((q15_t **)&pSrc); sum += ((in << 16U) >> 16U); - sum += (in >> 16U); + sum += (in >> 16U); - in = read_q15x2_ia ((q15_t **) &pSrc); + in = read_q15x2_ia((q15_t **)&pSrc); sum += ((in << 16U) >> 16U); - sum += (in >> 16U); + sum += (in >> 16U); /* Decrement the loop counter */ blkCnt--; @@ -95,8 +90,7 @@ void arm_mean_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (A[0] + A[1] + A[2] + ... + A[blockSize-1]) */ sum += *pSrc++; @@ -106,7 +100,7 @@ void arm_mean_q15( /* C = (A[0] + A[1] + A[2] + ... + A[blockSize-1]) / blockSize */ /* Store result to destination */ - *pResult = (q15_t) (sum / (int32_t) blockSize); + *pResult = (q15_t)(sum / (int32_t)blockSize); } /** diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_mean_q31.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_mean_q31.c index 4b0ed6e..12f47c1 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_mean_q31.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_mean_q31.c @@ -45,29 +45,24 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using a 64-bit internal accumulator. - The input is represented in 1.31 format and is accumulated in a 64-bit - accumulator in 33.31 format. - There is no risk of internal overflow with this approach, and the - full precision of intermediate result is preserved. - Finally, the accumulator is truncated to yield a result of 1.31 format. + The function is implemented using a 64-bit internal + accumulator. The input is represented in 1.31 format and is accumulated in a + 64-bit accumulator in 33.31 format. There is no risk of internal overflow with + this approach, and the full precision of intermediate result is preserved. + Finally, the accumulator is truncated to yield a result + of 1.31 format. */ -void arm_mean_q31( - const q31_t * pSrc, - uint32_t blockSize, - q31_t * pResult) -{ - uint32_t blkCnt; /* Loop counter */ - q63_t sum = 0; /* Temporary result storage */ +void arm_mean_q31(const q31_t *pSrc, uint32_t blockSize, q31_t *pResult) { + uint32_t blkCnt; /* Loop counter */ + q63_t sum = 0; /* Temporary result storage */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (A[0] + A[1] + A[2] + ... + A[blockSize-1]) */ sum += *pSrc++; @@ -91,8 +86,7 @@ void arm_mean_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (A[0] + A[1] + A[2] + ... + A[blockSize-1]) */ sum += *pSrc++; @@ -102,7 +96,7 @@ void arm_mean_q31( /* C = (A[0] + A[1] + A[2] + ... + A[blockSize-1]) / blockSize */ /* Store result to destination */ - *pResult = (q31_t) (sum / blockSize); + *pResult = (q31_t)(sum / blockSize); } /** diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_mean_q7.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_mean_q7.c index 8f52211..b91bb47 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_mean_q7.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_mean_q7.c @@ -45,39 +45,34 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using a 32-bit internal accumulator. - The input is represented in 1.7 format and is accumulated in a 32-bit - accumulator in 25.7 format. - There is no risk of internal overflow with this approach, and the - full precision of intermediate result is preserved. - Finally, the accumulator is truncated to yield a result of 1.7 format. + The function is implemented using a 32-bit internal + accumulator. The input is represented in 1.7 format and is accumulated in a + 32-bit accumulator in 25.7 format. There is no risk of internal overflow with + this approach, and the full precision of intermediate result is preserved. + Finally, the accumulator is truncated to yield a result + of 1.7 format. */ -void arm_mean_q7( - const q7_t * pSrc, - uint32_t blockSize, - q7_t * pResult) -{ - uint32_t blkCnt; /* Loop counter */ - q31_t sum = 0; /* Temporary result storage */ +void arm_mean_q7(const q7_t *pSrc, uint32_t blockSize, q7_t *pResult) { + uint32_t blkCnt; /* Loop counter */ + q31_t sum = 0; /* Temporary result storage */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t in; +#if defined(ARM_MATH_LOOPUNROLL) + q31_t in; #endif -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (A[0] + A[1] + A[2] + ... + A[blockSize-1]) */ - in = read_q7x4_ia ((q7_t **) &pSrc); + in = read_q7x4_ia((q7_t **)&pSrc); sum += ((in << 24U) >> 24U); sum += ((in << 16U) >> 24U); - sum += ((in << 8U) >> 24U); - sum += (in >> 24U); + sum += ((in << 8U) >> 24U); + sum += (in >> 24U); /* Decrement the loop counter */ blkCnt--; @@ -93,8 +88,7 @@ void arm_mean_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (A[0] + A[1] + A[2] + ... + A[blockSize-1]) */ sum += *pSrc++; @@ -104,7 +98,7 @@ void arm_mean_q7( /* C = (A[0] + A[1] + A[2] + ... + A[blockSize-1]) / blockSize */ /* Store result to destination */ - *pResult = (q7_t) (sum / (int32_t) blockSize); + *pResult = (q7_t)(sum / (int32_t)blockSize); } /** diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_min_f32.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_min_f32.c index 6daec0e..9011223 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_min_f32.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_min_f32.c @@ -54,17 +54,13 @@ @return none */ -void arm_min_f32( - const float32_t * pSrc, - uint32_t blockSize, - float32_t * pResult, - uint32_t * pIndex) -{ - float32_t minVal, out; /* Temporary variables to store the output value. */ - uint32_t blkCnt, outIndex; /* Loop counter */ +void arm_min_f32(const float32_t *pSrc, uint32_t blockSize, float32_t *pResult, + uint32_t *pIndex) { + float32_t minVal, out; /* Temporary variables to store the output value. */ + uint32_t blkCnt, outIndex; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) - uint32_t index; /* index of maximum value */ +#if defined(ARM_MATH_LOOPUNROLL) + uint32_t index; /* index of maximum value */ #endif /* Initialise index value to zero. */ @@ -72,43 +68,38 @@ void arm_min_f32( /* Load first input value that act as reference value for comparision */ out = *pSrc++; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Initialise index of maximum value. */ index = 0U; /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = (blockSize - 1U) >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Initialize minVal to next consecutive values one by one */ minVal = *pSrc++; /* compare for the minimum value */ - if (out > minVal) - { + if (out > minVal) { /* Update the minimum value and it's index */ out = minVal; outIndex = index + 1U; } minVal = *pSrc++; - if (out > minVal) - { + if (out > minVal) { out = minVal; outIndex = index + 2U; } minVal = *pSrc++; - if (out > minVal) - { + if (out > minVal) { out = minVal; outIndex = index + 3U; } minVal = *pSrc++; - if (out > minVal) - { + if (out > minVal) { out = minVal; outIndex = index + 4U; } @@ -129,14 +120,12 @@ void arm_min_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Initialize minVal to the next consecutive values one by one */ minVal = *pSrc++; /* compare for the minimum value */ - if (out > minVal) - { + if (out > minVal) { /* Update the minimum value and it's index */ out = minVal; outIndex = blockSize - blkCnt; diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_min_q15.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_min_q15.c index 9450383..e1909cb 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_min_q15.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_min_q15.c @@ -32,7 +32,6 @@ @ingroup groupStats */ - /** @addtogroup Min @{ @@ -47,17 +46,13 @@ @return none */ -void arm_min_q15( - const q15_t * pSrc, - uint32_t blockSize, - q15_t * pResult, - uint32_t * pIndex) -{ - q15_t minVal, out; /* Temporary variables to store the output value. */ - uint32_t blkCnt, outIndex; /* Loop counter */ +void arm_min_q15(const q15_t *pSrc, uint32_t blockSize, q15_t *pResult, + uint32_t *pIndex) { + q15_t minVal, out; /* Temporary variables to store the output value. */ + uint32_t blkCnt, outIndex; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) - uint32_t index; /* index of maximum value */ +#if defined(ARM_MATH_LOOPUNROLL) + uint32_t index; /* index of maximum value */ #endif /* Initialise index value to zero. */ @@ -65,43 +60,38 @@ void arm_min_q15( /* Load first input value that act as reference value for comparision */ out = *pSrc++; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Initialise index of maximum value. */ index = 0U; /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = (blockSize - 1U) >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Initialize minVal to next consecutive values one by one */ minVal = *pSrc++; /* compare for the minimum value */ - if (out > minVal) - { + if (out > minVal) { /* Update the minimum value and it's index */ out = minVal; outIndex = index + 1U; } minVal = *pSrc++; - if (out > minVal) - { + if (out > minVal) { out = minVal; outIndex = index + 2U; } minVal = *pSrc++; - if (out > minVal) - { + if (out > minVal) { out = minVal; outIndex = index + 3U; } minVal = *pSrc++; - if (out > minVal) - { + if (out > minVal) { out = minVal; outIndex = index + 4U; } @@ -122,14 +112,12 @@ void arm_min_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Initialize minVal to the next consecutive values one by one */ minVal = *pSrc++; /* compare for the minimum value */ - if (out > minVal) - { + if (out > minVal) { /* Update the minimum value and it's index */ out = minVal; outIndex = blockSize - blkCnt; diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_min_q31.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_min_q31.c index e25eb47..0ec78bb 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_min_q31.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_min_q31.c @@ -32,7 +32,6 @@ @ingroup groupStats */ - /** @addtogroup Min @{ @@ -47,17 +46,13 @@ @return none */ -void arm_min_q31( - const q31_t * pSrc, - uint32_t blockSize, - q31_t * pResult, - uint32_t * pIndex) -{ - q31_t minVal, out; /* Temporary variables to store the output value. */ - uint32_t blkCnt, outIndex; /* Loop counter */ +void arm_min_q31(const q31_t *pSrc, uint32_t blockSize, q31_t *pResult, + uint32_t *pIndex) { + q31_t minVal, out; /* Temporary variables to store the output value. */ + uint32_t blkCnt, outIndex; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) - uint32_t index; /* index of maximum value */ +#if defined(ARM_MATH_LOOPUNROLL) + uint32_t index; /* index of maximum value */ #endif /* Initialise index value to zero. */ @@ -65,43 +60,38 @@ void arm_min_q31( /* Load first input value that act as reference value for comparision */ out = *pSrc++; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Initialise index of maximum value. */ index = 0U; /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = (blockSize - 1U) >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Initialize minVal to next consecutive values one by one */ minVal = *pSrc++; /* compare for the minimum value */ - if (out > minVal) - { + if (out > minVal) { /* Update the minimum value and it's index */ out = minVal; outIndex = index + 1U; } minVal = *pSrc++; - if (out > minVal) - { + if (out > minVal) { out = minVal; outIndex = index + 2U; } minVal = *pSrc++; - if (out > minVal) - { + if (out > minVal) { out = minVal; outIndex = index + 3U; } minVal = *pSrc++; - if (out > minVal) - { + if (out > minVal) { out = minVal; outIndex = index + 4U; } @@ -122,14 +112,12 @@ void arm_min_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Initialize minVal to the next consecutive values one by one */ minVal = *pSrc++; /* compare for the minimum value */ - if (out > minVal) - { + if (out > minVal) { /* Update the minimum value and it's index */ out = minVal; outIndex = blockSize - blkCnt; diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_min_q7.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_min_q7.c index 2b171f0..37c394b 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_min_q7.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_min_q7.c @@ -32,7 +32,6 @@ @ingroup groupStats */ - /** @addtogroup Min @{ @@ -47,17 +46,13 @@ @return none */ -void arm_min_q7( - const q7_t * pSrc, - uint32_t blockSize, - q7_t * pResult, - uint32_t * pIndex) -{ - q7_t minVal, out; /* Temporary variables to store the output value. */ - uint32_t blkCnt, outIndex; /* Loop counter */ +void arm_min_q7(const q7_t *pSrc, uint32_t blockSize, q7_t *pResult, + uint32_t *pIndex) { + q7_t minVal, out; /* Temporary variables to store the output value. */ + uint32_t blkCnt, outIndex; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) - uint32_t index; /* index of maximum value */ +#if defined(ARM_MATH_LOOPUNROLL) + uint32_t index; /* index of maximum value */ #endif /* Initialise index value to zero. */ @@ -65,43 +60,38 @@ void arm_min_q7( /* Load first input value that act as reference value for comparision */ out = *pSrc++; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Initialise index of maximum value. */ index = 0U; /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = (blockSize - 1U) >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Initialize minVal to next consecutive values one by one */ minVal = *pSrc++; /* compare for the minimum value */ - if (out > minVal) - { + if (out > minVal) { /* Update the minimum value and it's index */ out = minVal; outIndex = index + 1U; } minVal = *pSrc++; - if (out > minVal) - { + if (out > minVal) { out = minVal; outIndex = index + 2U; } minVal = *pSrc++; - if (out > minVal) - { + if (out > minVal) { out = minVal; outIndex = index + 3U; } minVal = *pSrc++; - if (out > minVal) - { + if (out > minVal) { out = minVal; outIndex = index + 4U; } @@ -122,14 +112,12 @@ void arm_min_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* Initialize minVal to the next consecutive values one by one */ minVal = *pSrc++; /* compare for the minimum value */ - if (out > minVal) - { + if (out > minVal) { /* Update the minimum value and it's index */ out = minVal; outIndex = blockSize - blkCnt; diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_power_f32.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_power_f32.c index ad32211..3ab0ae3 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_power_f32.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_power_f32.c @@ -39,7 +39,8 @@ The underlying algorithm is used:
-      Result = pSrc[0] * pSrc[0] + pSrc[1] * pSrc[1] + pSrc[2] * pSrc[2] + ... + pSrc[blockSize-1] * pSrc[blockSize-1];
+      Result = pSrc[0] * pSrc[0] + pSrc[1] * pSrc[1] + pSrc[2] * pSrc[2] + ... +
+  pSrc[blockSize-1] * pSrc[blockSize-1];
   
There are separate functions for floating point, Q31, Q15, and Q7 data types. @@ -58,22 +59,18 @@ @return none */ -void arm_power_f32( - const float32_t * pSrc, - uint32_t blockSize, - float32_t * pResult) -{ - uint32_t blkCnt; /* Loop counter */ - float32_t sum = 0.0f; /* Temporary result storage */ - float32_t in; /* Temporary variable to store input value */ +void arm_power_f32(const float32_t *pSrc, uint32_t blockSize, + float32_t *pResult) { + uint32_t blkCnt; /* Loop counter */ + float32_t sum = 0.0f; /* Temporary result storage */ + float32_t in; /* Temporary variable to store input value */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* Compute Power and store result in a temporary variable, sum. */ @@ -103,8 +100,7 @@ void arm_power_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* Compute Power and store result in a temporary variable, sum. */ diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_power_q15.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_power_q15.c index 12f524d..a844c90 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_power_q15.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_power_q15.c @@ -45,56 +45,51 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using a 64-bit internal accumulator. - The input is represented in 1.15 format. - Intermediate multiplication yields a 2.30 format, and this - result is added without saturation to a 64-bit accumulator in 34.30 format. - With 33 guard bits in the accumulator, there is no risk of overflow, and the - full precision of the intermediate multiplication is preserved. - Finally, the return result is in 34.30 format. + The function is implemented using a 64-bit internal + accumulator. The input is represented in 1.15 format. Intermediate + multiplication yields a 2.30 format, and this result is added without + saturation to a 64-bit accumulator in 34.30 format. With 33 guard bits in the + accumulator, there is no risk of overflow, and the full precision of the + intermediate multiplication is preserved. Finally, the return result is + in 34.30 format. */ -void arm_power_q15( - const q15_t * pSrc, - uint32_t blockSize, - q63_t * pResult) -{ - uint32_t blkCnt; /* Loop counter */ - q63_t sum = 0; /* Temporary result storage */ - q15_t in; /* Temporary variable to store input value */ +void arm_power_q15(const q15_t *pSrc, uint32_t blockSize, q63_t *pResult) { + uint32_t blkCnt; /* Loop counter */ + q63_t sum = 0; /* Temporary result storage */ + q15_t in; /* Temporary variable to store input value */ -#if defined (ARM_MATH_LOOPUNROLL) && defined (ARM_MATH_DSP) - q31_t in32; /* Temporary variable to store packed input value */ +#if defined(ARM_MATH_LOOPUNROLL) && defined(ARM_MATH_DSP) + q31_t in32; /* Temporary variable to store packed input value */ #endif -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* Compute Power and store result in a temporary variable, sum. */ -#if defined (ARM_MATH_DSP) - in32 = read_q15x2_ia ((q15_t **) &pSrc); +#if defined(ARM_MATH_DSP) + in32 = read_q15x2_ia((q15_t **)&pSrc); sum = __SMLALD(in32, in32, sum); - in32 = read_q15x2_ia ((q15_t **) &pSrc); + in32 = read_q15x2_ia((q15_t **)&pSrc); sum = __SMLALD(in32, in32, sum); #else in = *pSrc++; - sum += ((q31_t) in * in); + sum += ((q31_t)in * in); in = *pSrc++; - sum += ((q31_t) in * in); + sum += ((q31_t)in * in); in = *pSrc++; - sum += ((q31_t) in * in); + sum += ((q31_t)in * in); in = *pSrc++; - sum += ((q31_t) in * in); + sum += ((q31_t)in * in); #endif /* #if defined (ARM_MATH_DSP) */ /* Decrement loop counter */ @@ -111,13 +106,12 @@ void arm_power_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* Compute Power and store result in a temporary variable, sum. */ in = *pSrc++; - sum += ((q31_t) in * in); + sum += ((q31_t)in * in); /* Decrement loop counter */ blkCnt--; diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_power_q31.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_power_q31.c index 1e193b3..2a10461 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_power_q31.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_power_q31.c @@ -45,46 +45,43 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using a 64-bit internal accumulator. - The input is represented in 1.31 format. - Intermediate multiplication yields a 2.62 format, and this - result is truncated to 2.48 format by discarding the lower 14 bits. - The 2.48 result is then added without saturation to a 64-bit accumulator in 16.48 format. - With 15 guard bits in the accumulator, there is no risk of overflow, and the - full precision of the intermediate multiplication is preserved. - Finally, the return result is in 16.48 format. + The function is implemented using a 64-bit internal + accumulator. The input is represented in 1.31 format. Intermediate + multiplication yields a 2.62 format, and this result is truncated to 2.48 + format by discarding the lower 14 bits. The 2.48 result is then added without + saturation to a 64-bit accumulator in 16.48 format. With 15 guard bits in the + accumulator, there is no risk of overflow, and the full precision of the + intermediate multiplication is preserved. Finally, the return result is + in 16.48 format. */ -void arm_power_q31( - const q31_t * pSrc, - uint32_t blockSize, - q63_t * pResult) -{ - uint32_t blkCnt; /* Loop counter */ - q63_t sum = 0; /* Temporary result storage */ - q31_t in; /* Temporary variable to store input value */ +void arm_power_q31(const q31_t *pSrc, uint32_t blockSize, q63_t *pResult) { + uint32_t blkCnt; /* Loop counter */ + q63_t sum = 0; /* Temporary result storage */ + q31_t in; /* Temporary variable to store input value */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ - /* Compute Power then shift intermediate results by 14 bits to maintain 16.48 format and store result in a temporary variable sum, providing 15 guard bits. */ + /* Compute Power then shift intermediate results by 14 bits to + * maintain 16.48 format and store result in a temporary variable sum, + * providing 15 guard bits. */ in = *pSrc++; - sum += ((q63_t) in * in) >> 14U; + sum += ((q63_t)in * in) >> 14U; in = *pSrc++; - sum += ((q63_t) in * in) >> 14U; + sum += ((q63_t)in * in) >> 14U; in = *pSrc++; - sum += ((q63_t) in * in) >> 14U; + sum += ((q63_t)in * in) >> 14U; in = *pSrc++; - sum += ((q63_t) in * in) >> 14U; + sum += ((q63_t)in * in) >> 14U; /* Decrement loop counter */ blkCnt--; @@ -100,13 +97,12 @@ void arm_power_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* Compute Power and store result in a temporary variable, sum. */ in = *pSrc++; - sum += ((q63_t) in * in) >> 14U; + sum += ((q63_t)in * in) >> 14U; /* Decrement loop counter */ blkCnt--; diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_power_q7.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_power_q7.c index 47405cd..b5414dc 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_power_q7.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_power_q7.c @@ -45,41 +45,36 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using a 32-bit internal accumulator. - The input is represented in 1.7 format. - Intermediate multiplication yields a 2.14 format, and this - result is added without saturation to an accumulator in 18.14 format. - With 17 guard bits in the accumulator, there is no risk of overflow, and the - full precision of the intermediate multiplication is preserved. - Finally, the return result is in 18.14 format. + The function is implemented using a 32-bit internal + accumulator. The input is represented in 1.7 format. Intermediate + multiplication yields a 2.14 format, and this result is added without + saturation to an accumulator in 18.14 format. With 17 guard bits in the + accumulator, there is no risk of overflow, and the full precision of the + intermediate multiplication is preserved. Finally, the return result is + in 18.14 format. */ -void arm_power_q7( - const q7_t * pSrc, - uint32_t blockSize, - q31_t * pResult) -{ - uint32_t blkCnt; /* Loop counter */ - q31_t sum = 0; /* Temporary result storage */ - q7_t in; /* Temporary variable to store input value */ +void arm_power_q7(const q7_t *pSrc, uint32_t blockSize, q31_t *pResult) { + uint32_t blkCnt; /* Loop counter */ + q31_t sum = 0; /* Temporary result storage */ + q7_t in; /* Temporary variable to store input value */ -#if defined (ARM_MATH_LOOPUNROLL) && defined (ARM_MATH_DSP) - q31_t in32; /* Temporary variable to store packed input value */ - q31_t in1, in2; /* Temporary variables to store input value */ +#if defined(ARM_MATH_LOOPUNROLL) && defined(ARM_MATH_DSP) + q31_t in32; /* Temporary variable to store packed input value */ + q31_t in1, in2; /* Temporary variables to store input value */ #endif -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* Compute Power and store result in a temporary variable, sum. */ -#if defined (ARM_MATH_DSP) - in32 = read_q7x4_ia ((q7_t **) &pSrc); +#if defined(ARM_MATH_DSP) + in32 = read_q7x4_ia((q7_t **)&pSrc); in1 = __SXTB16(__ROR(in32, 8)); in2 = __SXTB16(in32); @@ -89,16 +84,16 @@ void arm_power_q7( sum = __SMLAD(in2, in2, sum); #else in = *pSrc++; - sum += ((q15_t) in * in); + sum += ((q15_t)in * in); in = *pSrc++; - sum += ((q15_t) in * in); + sum += ((q15_t)in * in); in = *pSrc++; - sum += ((q15_t) in * in); + sum += ((q15_t)in * in); in = *pSrc++; - sum += ((q15_t) in * in); + sum += ((q15_t)in * in); #endif /* #if defined (ARM_MATH_DSP) */ /* Decrement loop counter */ @@ -115,13 +110,12 @@ void arm_power_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* Compute Power and store result in a temporary variable, sum. */ in = *pSrc++; - sum += ((q15_t) in * in); + sum += ((q15_t)in * in); /* Decrement loop counter */ blkCnt--; diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_rms_f32.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_rms_f32.c index 68f7868..808d708 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_rms_f32.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_rms_f32.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_rms_f32.c - * Description: Root mean square value of the elements of a floating-point vector + * Description: Root mean square value of the elements of a floating-point + * vector * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -39,7 +40,8 @@ The underlying algorithm is used:
-      Result = sqrt(((pSrc[0] * pSrc[0] + pSrc[1] * pSrc[1] + ... + pSrc[blockSize-1] * pSrc[blockSize-1]) / blockSize));
+      Result = sqrt(((pSrc[0] * pSrc[0] + pSrc[1] * pSrc[1] + ... +
+  pSrc[blockSize-1] * pSrc[blockSize-1]) / blockSize));
   
There are separate functions for floating point, Q31, and Q15 data types. @@ -58,22 +60,18 @@ @return none */ -void arm_rms_f32( - const float32_t * pSrc, - uint32_t blockSize, - float32_t * pResult) -{ - uint32_t blkCnt; /* Loop counter */ - float32_t sum = 0.0f; /* Temporary result storage */ - float32_t in; /* Temporary variable to store input value */ +void arm_rms_f32(const float32_t *pSrc, uint32_t blockSize, + float32_t *pResult) { + uint32_t blkCnt; /* Loop counter */ + float32_t sum = 0.0f; /* Temporary result storage */ + float32_t in; /* Temporary variable to store input value */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ in = *pSrc++; @@ -103,20 +101,19 @@ void arm_rms_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ in = *pSrc++; /* Compute sum of squares and store result in a temporary variable. */ - sum += ( in * in); + sum += (in * in); /* Decrement loop counter */ blkCnt--; } /* Compute Rms and store result in destination */ - arm_sqrt_f32(sum / (float32_t) blockSize, pResult); + arm_sqrt_f32(sum / (float32_t)blockSize, pResult); } /** diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_rms_q15.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_rms_q15.c index 9fcd964..5002987 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_rms_q15.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_rms_q15.c @@ -45,57 +45,52 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using a 64-bit internal accumulator. - The input is represented in 1.15 format. - Intermediate multiplication yields a 2.30 format, and this - result is added without saturation to a 64-bit accumulator in 34.30 format. - With 33 guard bits in the accumulator, there is no risk of overflow, and the - full precision of the intermediate multiplication is preserved. - Finally, the 34.30 result is truncated to 34.15 format by discarding the lower - 15 bits, and then saturated to yield a result in 1.15 format. + The function is implemented using a 64-bit internal + accumulator. The input is represented in 1.15 format. Intermediate + multiplication yields a 2.30 format, and this result is added without + saturation to a 64-bit accumulator in 34.30 format. With 33 guard bits in the + accumulator, there is no risk of overflow, and the full precision of the + intermediate multiplication is preserved. Finally, the 34.30 result is + truncated to 34.15 format by discarding the lower 15 bits, and then saturated + to yield a result in 1.15 format. */ -void arm_rms_q15( - const q15_t * pSrc, - uint32_t blockSize, - q15_t * pResult) -{ - uint32_t blkCnt; /* Loop counter */ - q63_t sum = 0; /* Temporary result storage */ - q15_t in; /* Temporary variable to store input value */ +void arm_rms_q15(const q15_t *pSrc, uint32_t blockSize, q15_t *pResult) { + uint32_t blkCnt; /* Loop counter */ + q63_t sum = 0; /* Temporary result storage */ + q15_t in; /* Temporary variable to store input value */ -#if defined (ARM_MATH_LOOPUNROLL) && defined (ARM_MATH_DSP) - q31_t in32; /* Temporary variable to store input value */ +#if defined(ARM_MATH_LOOPUNROLL) && defined(ARM_MATH_DSP) + q31_t in32; /* Temporary variable to store input value */ #endif -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* Compute sum of squares and store result in a temporary variable. */ -#if defined (ARM_MATH_DSP) - in32 = read_q15x2_ia ((q15_t **) &pSrc); +#if defined(ARM_MATH_DSP) + in32 = read_q15x2_ia((q15_t **)&pSrc); sum = __SMLALD(in32, in32, sum); - in32 = read_q15x2_ia ((q15_t **) &pSrc); + in32 = read_q15x2_ia((q15_t **)&pSrc); sum = __SMLALD(in32, in32, sum); #else in = *pSrc++; - sum += ((q31_t) in * in); + sum += ((q31_t)in * in); in = *pSrc++; - sum += ((q31_t) in * in); + sum += ((q31_t)in * in); in = *pSrc++; - sum += ((q31_t) in * in); + sum += ((q31_t)in * in); in = *pSrc++; - sum += ((q31_t) in * in); + sum += ((q31_t)in * in); #endif /* #if defined (ARM_MATH_DSP) */ /* Decrement loop counter */ @@ -112,13 +107,12 @@ void arm_rms_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ in = *pSrc++; /* Compute sum of squares and store result in a temporary variable. */ - sum += ((q31_t) in * in); + sum += ((q31_t)in * in); /* Decrement loop counter */ blkCnt--; diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_rms_q31.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_rms_q31.c index 5a3e8f3..d1c27c3 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_rms_q31.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_rms_q31.c @@ -45,48 +45,43 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using an internal 64-bit accumulator. - The input is represented in 1.31 format, and intermediate multiplication - yields a 2.62 format. - The accumulator maintains full precision of the intermediate multiplication results, - but provides only a single guard bit. - There is no saturation on intermediate additions. - If the accumulator overflows, it wraps around and distorts the result. - In order to avoid overflows completely, the input signal must be scaled down by - log2(blockSize) bits, as a total of blockSize additions are performed internally. - Finally, the 2.62 accumulator is right shifted by 31 bits to yield a 1.31 format value. + The function is implemented using an internal 64-bit + accumulator. The input is represented in 1.31 format, and intermediate + multiplication yields a 2.62 format. The accumulator maintains full precision + of the intermediate multiplication results, but provides only a single guard + bit. There is no saturation on intermediate additions. If the accumulator + overflows, it wraps around and distorts the result. In order to avoid + overflows completely, the input signal must be scaled down by log2(blockSize) + bits, as a total of blockSize additions are performed internally. Finally, + the 2.62 accumulator is right shifted by 31 bits to yield a 1.31 format value. */ -void arm_rms_q31( - const q31_t * pSrc, - uint32_t blockSize, - q31_t * pResult) -{ - uint32_t blkCnt; /* Loop counter */ - uint64_t sum = 0; /* Temporary result storage (can get never negative. changed type from q63 to uint64 */ - q31_t in; /* Temporary variable to store input value */ +void arm_rms_q31(const q31_t *pSrc, uint32_t blockSize, q31_t *pResult) { + uint32_t blkCnt; /* Loop counter */ + uint64_t sum = 0; /* Temporary result storage (can get never negative. changed + type from q63 to uint64 */ + q31_t in; /* Temporary variable to store input value */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ in = *pSrc++; /* Compute sum of squares and store result in a temporary variable, sum. */ - sum += ((q63_t) in * in); + sum += ((q63_t)in * in); in = *pSrc++; - sum += ((q63_t) in * in); + sum += ((q63_t)in * in); in = *pSrc++; - sum += ((q63_t) in * in); + sum += ((q63_t)in * in); in = *pSrc++; - sum += ((q63_t) in * in); + sum += ((q63_t)in * in); /* Decrement loop counter */ blkCnt--; @@ -102,13 +97,12 @@ void arm_rms_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ in = *pSrc++; /* Compute sum of squares and store result in a temporary variable. */ - sum += ((q63_t) in * in); + sum += ((q63_t)in * in); /* Decrement loop counter */ blkCnt--; @@ -116,7 +110,7 @@ void arm_rms_q31( /* Convert data in 2.62 to 1.31 by 31 right shifts and saturate */ /* Compute Rms and store result in destination vector */ - arm_sqrt_q31(clip_q63_to_q31((sum / (q63_t) blockSize) >> 31), pResult); + arm_sqrt_q31(clip_q63_to_q31((sum / (q63_t)blockSize) >> 31), pResult); } /** diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_std_f32.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_std_f32.c index 041d1f4..e5ea92e 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_std_f32.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_std_f32.c @@ -39,10 +39,12 @@ The underlying algorithm is used:
-      Result = sqrt((sumOfSquares - sum2 / blockSize) / (blockSize - 1))
+      Result = sqrt((sumOfSquares - sum2 / blockSize) / (blockSize -
+  1))
 
-      sumOfSquares = pSrc[0] * pSrc[0] + pSrc[1] * pSrc[1] + ... + pSrc[blockSize-1] * pSrc[blockSize-1]
-      sum = pSrc[0] + pSrc[1] + pSrc[2] + ... + pSrc[blockSize-1]
+      sumOfSquares = pSrc[0] * pSrc[0] + pSrc[1] * pSrc[1] + ... +
+  pSrc[blockSize-1] * pSrc[blockSize-1] sum = pSrc[0] + pSrc[1] + pSrc[2] + ...
+  + pSrc[blockSize-1]
   
There are separate functions for floating point, Q31, and Q15 data types. @@ -61,41 +63,37 @@ @return none */ -void arm_std_f32( - const float32_t * pSrc, - uint32_t blockSize, - float32_t * pResult) -{ - uint32_t blkCnt; /* Loop counter */ - float32_t sum = 0.0f; /* Temporary result storage */ - float32_t sumOfSquares = 0.0f; /* Sum of squares */ - float32_t in; /* Temporary variable to store input value */ +void arm_std_f32(const float32_t *pSrc, uint32_t blockSize, + float32_t *pResult) { + uint32_t blkCnt; /* Loop counter */ + float32_t sum = 0.0f; /* Temporary result storage */ + float32_t sumOfSquares = 0.0f; /* Sum of squares */ + float32_t in; /* Temporary variable to store input value */ #ifndef ARM_MATH_CM0_FAMILY - float32_t meanOfSquares, mean, squareOfMean; /* Temporary variables */ + float32_t meanOfSquares, mean, squareOfMean; /* Temporary variables */ #else - float32_t squareOfSum; /* Square of Sum */ - float32_t var; /* Temporary varaince storage */ + float32_t squareOfSum; /* Square of Sum */ + float32_t var; /* Temporary varaince storage */ #endif - if (blockSize <= 1U) - { + if (blockSize <= 1U) { *pResult = 0; return; } -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* C = A[0] + A[1] + ... + A[blockSize-1] */ in = *pSrc++; - /* Compute sum of squares and store result in a temporary variable, sumOfSquares. */ + /* Compute sum of squares and store result in a temporary variable, + * sumOfSquares. */ sumOfSquares += in * in; /* Compute sum and store result in a temporary variable, sum. */ sum += in; @@ -126,14 +124,14 @@ void arm_std_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* C = A[0] + A[1] + ... + A[blockSize-1] */ in = *pSrc++; - /* Compute sum of squares and store result in a temporary variable, sumOfSquares. */ - sumOfSquares += ( in * in); + /* Compute sum of squares and store result in a temporary variable, + * sumOfSquares. */ + sumOfSquares += (in * in); /* Compute sum and store result in a temporary variable, sum. */ sum += in; @@ -143,15 +141,16 @@ void arm_std_f32( #ifndef ARM_MATH_CM0_FAMILY - /* Compute Mean of squares and store result in a temporary variable, meanOfSquares. */ - meanOfSquares = sumOfSquares / ((float32_t) blockSize - 1.0f); + /* Compute Mean of squares and store result in a temporary variable, + * meanOfSquares. */ + meanOfSquares = sumOfSquares / ((float32_t)blockSize - 1.0f); /* Compute mean of all input values */ - mean = sum / (float32_t) blockSize; + mean = sum / (float32_t)blockSize; /* Compute square of mean */ - squareOfMean = (mean * mean) * (((float32_t) blockSize) / - ((float32_t) blockSize - 1.0f)); + squareOfMean = + (mean * mean) * (((float32_t)blockSize) / ((float32_t)blockSize - 1.0f)); /* Compute standard deviation and store result to destination */ arm_sqrt_f32((meanOfSquares - squareOfMean), pResult); @@ -159,16 +158,15 @@ void arm_std_f32( #else /* Compute square of sum */ - squareOfSum = ((sum * sum) / (float32_t) blockSize); + squareOfSum = ((sum * sum) / (float32_t)blockSize); /* Compute variance */ - var = ((sumOfSquares - squareOfSum) / (float32_t) (blockSize - 1.0f)); + var = ((sumOfSquares - squareOfSum) / (float32_t)(blockSize - 1.0f)); /* Compute standard deviation and store result in destination */ arm_sqrt_f32(var, pResult); #endif /* #ifndef ARM_MATH_CM0_FAMILY */ - } /** diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_std_q15.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_std_q15.c index 8e5c042..2f59970 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_std_q15.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_std_q15.c @@ -45,59 +45,54 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using a 64-bit internal accumulator. - The input is represented in 1.15 format. - Intermediate multiplication yields a 2.30 format, and this - result is added without saturation to a 64-bit accumulator in 34.30 format. - With 33 guard bits in the accumulator, there is no risk of overflow, and the - full precision of the intermediate multiplication is preserved. - Finally, the 34.30 result is truncated to 34.15 format by discarding the lower - 15 bits, and then saturated to yield a result in 1.15 format. + The function is implemented using a 64-bit internal + accumulator. The input is represented in 1.15 format. Intermediate + multiplication yields a 2.30 format, and this result is added without + saturation to a 64-bit accumulator in 34.30 format. With 33 guard bits in the + accumulator, there is no risk of overflow, and the full precision of the + intermediate multiplication is preserved. Finally, the 34.30 result is + truncated to 34.15 format by discarding the lower 15 bits, and then saturated + to yield a result in 1.15 format. */ -void arm_std_q15( - const q15_t * pSrc, - uint32_t blockSize, - q15_t * pResult) -{ - uint32_t blkCnt; /* Loop counter */ - q31_t sum = 0; /* Accumulator */ - q31_t meanOfSquares, squareOfMean; /* Square of mean and mean of square */ - q63_t sumOfSquares = 0; /* Sum of squares */ - q15_t in; /* Temporary variable to store input value */ +void arm_std_q15(const q15_t *pSrc, uint32_t blockSize, q15_t *pResult) { + uint32_t blkCnt; /* Loop counter */ + q31_t sum = 0; /* Accumulator */ + q31_t meanOfSquares, squareOfMean; /* Square of mean and mean of square */ + q63_t sumOfSquares = 0; /* Sum of squares */ + q15_t in; /* Temporary variable to store input value */ -#if defined (ARM_MATH_LOOPUNROLL) && defined (ARM_MATH_DSP) - q31_t in32; /* Temporary variable to store input value */ +#if defined(ARM_MATH_LOOPUNROLL) && defined(ARM_MATH_DSP) + q31_t in32; /* Temporary variable to store input value */ #endif - if (blockSize <= 1U) - { + if (blockSize <= 1U) { *pResult = 0; return; } -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* C = A[0] + A[1] + ... + A[blockSize-1] */ - /* Compute sum of squares and store result in a temporary variable, sumOfSquares. */ + /* Compute sum of squares and store result in a temporary variable, + * sumOfSquares. */ /* Compute sum and store result in a temporary variable, sum. */ -#if defined (ARM_MATH_DSP) - in32 = read_q15x2_ia ((q15_t **) &pSrc); +#if defined(ARM_MATH_DSP) + in32 = read_q15x2_ia((q15_t **)&pSrc); sumOfSquares = __SMLALD(in32, in32, sumOfSquares); sum += ((in32 << 16U) >> 16U); - sum += (in32 >> 16U); + sum += (in32 >> 16U); - in32 = read_q15x2_ia ((q15_t **) &pSrc); + in32 = read_q15x2_ia((q15_t **)&pSrc); sumOfSquares = __SMLALD(in32, in32, sumOfSquares); sum += ((in32 << 16U) >> 16U); - sum += (in32 >> 16U); + sum += (in32 >> 16U); #else in = *pSrc++; sumOfSquares += (in * in); @@ -130,13 +125,13 @@ void arm_std_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* C = A[0] + A[1] + ... + A[blockSize-1] */ in = *pSrc++; - /* Compute sum of squares and store result in a temporary variable, sumOfSquares. */ + /* Compute sum of squares and store result in a temporary variable, + * sumOfSquares. */ sumOfSquares += (in * in); /* Compute sum and store result in a temporary variable, sum. */ sum += in; @@ -145,11 +140,13 @@ void arm_std_q15( blkCnt--; } - /* Compute Mean of squares and store result in a temporary variable, meanOfSquares. */ - meanOfSquares = (q31_t) (sumOfSquares / (q63_t)(blockSize - 1U)); + /* Compute Mean of squares and store result in a temporary variable, + * meanOfSquares. */ + meanOfSquares = (q31_t)(sumOfSquares / (q63_t)(blockSize - 1U)); /* Compute square of mean */ - squareOfMean = (q31_t) ((q63_t) sum * sum / (q63_t)(blockSize * (blockSize - 1U))); + squareOfMean = + (q31_t)((q63_t)sum * sum / (q63_t)(blockSize * (blockSize - 1U))); /* mean of squares minus the square of mean. */ /* Compute standard deviation and store result in destination */ diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_std_q31.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_std_q31.c index cfb6cb8..52c91a4 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_std_q31.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_std_q31.c @@ -45,62 +45,57 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using an internal 64-bit accumulator. - The input is represented in 1.31 format, which is then downshifted by 8 bits - which yields 1.23, and intermediate multiplication yields a 2.46 format. - The accumulator maintains full precision of the intermediate multiplication results, - but provides only a 16 guard bits. - There is no saturation on intermediate additions. - If the accumulator overflows it wraps around and distorts the result. - In order to avoid overflows completely the input signal must be scaled down by - log2(blockSize)-8 bits, as a total of blockSize additions are performed internally. - After division, internal variables should be Q18.46 - Finally, the 18.46 accumulator is right shifted by 15 bits to yield a 1.31 format value. + The function is implemented using an internal 64-bit + accumulator. The input is represented in 1.31 format, which is then + downshifted by 8 bits which yields 1.23, and intermediate multiplication + yields a 2.46 format. The accumulator maintains full precision of the + intermediate multiplication results, but provides only a 16 guard bits. There + is no saturation on intermediate additions. If the accumulator overflows it + wraps around and distorts the result. In order to avoid overflows completely + the input signal must be scaled down by log2(blockSize)-8 bits, as a total of + blockSize additions are performed internally. After division, internal + variables should be Q18.46 Finally, the 18.46 accumulator is right shifted by + 15 bits to yield a 1.31 format value. */ -void arm_std_q31( - const q31_t * pSrc, - uint32_t blockSize, - q31_t * pResult) -{ - uint32_t blkCnt; /* Loop counter */ - q63_t sum = 0; /* Accumulator */ - q63_t meanOfSquares, squareOfMean; /* Square of mean and mean of square */ - q63_t sumOfSquares = 0; /* Sum of squares */ - q31_t in; /* Temporary variable to store input value */ +void arm_std_q31(const q31_t *pSrc, uint32_t blockSize, q31_t *pResult) { + uint32_t blkCnt; /* Loop counter */ + q63_t sum = 0; /* Accumulator */ + q63_t meanOfSquares, squareOfMean; /* Square of mean and mean of square */ + q63_t sumOfSquares = 0; /* Sum of squares */ + q31_t in; /* Temporary variable to store input value */ - if (blockSize <= 1U) - { + if (blockSize <= 1U) { *pResult = 0; return; } -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* C = A[0] + A[1] + ... + A[blockSize-1] */ in = *pSrc++ >> 8U; - /* Compute sum of squares and store result in a temporary variable, sumOfSquares. */ - sumOfSquares += ((q63_t) (in) * (in)); + /* Compute sum of squares and store result in a temporary variable, + * sumOfSquares. */ + sumOfSquares += ((q63_t)(in) * (in)); /* Compute sum and store result in a temporary variable, sum. */ sum += in; in = *pSrc++ >> 8U; - sumOfSquares += ((q63_t) (in) * (in)); + sumOfSquares += ((q63_t)(in) * (in)); sum += in; in = *pSrc++ >> 8U; - sumOfSquares += ((q63_t) (in) * (in)); + sumOfSquares += ((q63_t)(in) * (in)); sum += in; in = *pSrc++ >> 8U; - sumOfSquares += ((q63_t) (in) * (in)); + sumOfSquares += ((q63_t)(in) * (in)); sum += in; /* Decrement loop counter */ @@ -117,14 +112,14 @@ void arm_std_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* C = A[0] + A[1] + ... + A[blockSize-1] */ in = *pSrc++ >> 8U; - /* Compute sum of squares and store result in a temporary variable, sumOfSquares. */ - sumOfSquares += ((q63_t) (in) * (in)); + /* Compute sum of squares and store result in a temporary variable, + * sumOfSquares. */ + sumOfSquares += ((q63_t)(in) * (in)); /* Compute sum and store result in a temporary variable, sum. */ sum += in; @@ -132,11 +127,12 @@ void arm_std_q31( blkCnt--; } - /* Compute Mean of squares and store result in a temporary variable, meanOfSquares. */ + /* Compute Mean of squares and store result in a temporary variable, + * meanOfSquares. */ meanOfSquares = (sumOfSquares / (q63_t)(blockSize - 1U)); /* Compute square of mean */ - squareOfMean = ( sum * sum / (q63_t)(blockSize * (blockSize - 1U))); + squareOfMean = (sum * sum / (q63_t)(blockSize * (blockSize - 1U))); /* Compute standard deviation and store result in destination */ arm_sqrt_q31((meanOfSquares - squareOfMean) >> 15U, pResult); diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_var_f32.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_var_f32.c index f545d92..49896fc 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_var_f32.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_var_f32.c @@ -36,12 +36,14 @@ @defgroup variance Variance Calculates the variance of the elements in the input vector. - The underlying algorithm used is the direct method sometimes referred to as the two-pass method: + The underlying algorithm used is the direct method sometimes referred to as + the two-pass method:
       Result = sum(element - meanOfElements)^2) / numElement - 1
 
-      meanOfElements = ( pSrc[0] * pSrc[0] + pSrc[1] * pSrc[1] + ... + pSrc[blockSize-1] ) / blockSize
+      meanOfElements = ( pSrc[0] * pSrc[0] + pSrc[1] * pSrc[1] + ... +
+  pSrc[blockSize-1] ) / blockSize
   
There are separate functions for floating point, Q31, and Q15 data types. @@ -60,30 +62,25 @@ @return none */ -void arm_var_f32( - const float32_t * pSrc, - uint32_t blockSize, - float32_t * pResult) -{ - uint32_t blkCnt; /* Loop counter */ - float32_t sum = 0.0f; /* Temporary result storage */ - float32_t fSum = 0.0f; - float32_t fMean, fValue; - const float32_t * pInput = pSrc; +void arm_var_f32(const float32_t *pSrc, uint32_t blockSize, + float32_t *pResult) { + uint32_t blkCnt; /* Loop counter */ + float32_t sum = 0.0f; /* Temporary result storage */ + float32_t fSum = 0.0f; + float32_t fMean, fValue; + const float32_t *pInput = pSrc; - if (blockSize <= 1U) - { + if (blockSize <= 1U) { *pResult = 0; return; } -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (A[0] + A[1] + A[2] + ... + A[blockSize-1]) */ sum += *pInput++; @@ -91,7 +88,6 @@ void arm_var_f32( sum += *pInput++; sum += *pInput++; - /* Decrement loop counter */ blkCnt--; } @@ -106,8 +102,7 @@ void arm_var_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (A[0] + A[1] + A[2] + ... + A[blockSize-1]) */ sum += *pInput++; @@ -117,17 +112,16 @@ void arm_var_f32( } /* C = (A[0] + A[1] + A[2] + ... + A[blockSize-1]) / blockSize */ - fMean = sum / (float32_t) blockSize; + fMean = sum / (float32_t)blockSize; pInput = pSrc; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { fValue = *pInput++ - fMean; fSum += fValue * fValue; @@ -154,8 +148,7 @@ void arm_var_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { fValue = *pInput++ - fMean; fSum += fValue * fValue; diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_var_q15.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_var_q15.c index 259e76b..2216c96 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_var_q15.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_var_q15.c @@ -45,59 +45,54 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using a 64-bit internal accumulator. - The input is represented in 1.15 format. - Intermediate multiplication yields a 2.30 format, and this - result is added without saturation to a 64-bit accumulator in 34.30 format. - With 33 guard bits in the accumulator, there is no risk of overflow, and the - full precision of the intermediate multiplication is preserved. - Finally, the 34.30 result is truncated to 34.15 format by discarding the lower - 15 bits, and then saturated to yield a result in 1.15 format. + The function is implemented using a 64-bit internal + accumulator. The input is represented in 1.15 format. Intermediate + multiplication yields a 2.30 format, and this result is added without + saturation to a 64-bit accumulator in 34.30 format. With 33 guard bits in the + accumulator, there is no risk of overflow, and the full precision of the + intermediate multiplication is preserved. Finally, the 34.30 result is + truncated to 34.15 format by discarding the lower 15 bits, and then saturated + to yield a result in 1.15 format. */ -void arm_var_q15( - const q15_t * pSrc, - uint32_t blockSize, - q15_t * pResult) -{ - uint32_t blkCnt; /* Loop counter */ - q31_t sum = 0; /* Accumulator */ - q31_t meanOfSquares, squareOfMean; /* Square of mean and mean of square */ - q63_t sumOfSquares = 0; /* Sum of squares */ - q15_t in; /* Temporary variable to store input value */ +void arm_var_q15(const q15_t *pSrc, uint32_t blockSize, q15_t *pResult) { + uint32_t blkCnt; /* Loop counter */ + q31_t sum = 0; /* Accumulator */ + q31_t meanOfSquares, squareOfMean; /* Square of mean and mean of square */ + q63_t sumOfSquares = 0; /* Sum of squares */ + q15_t in; /* Temporary variable to store input value */ -#if defined (ARM_MATH_LOOPUNROLL) && defined (ARM_MATH_DSP) - q31_t in32; /* Temporary variable to store input value */ +#if defined(ARM_MATH_LOOPUNROLL) && defined(ARM_MATH_DSP) + q31_t in32; /* Temporary variable to store input value */ #endif - if (blockSize <= 1U) - { + if (blockSize <= 1U) { *pResult = 0; return; } -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* C = A[0] + A[1] + ... + A[blockSize-1] */ - /* Compute sum of squares and store result in a temporary variable, sumOfSquares. */ + /* Compute sum of squares and store result in a temporary variable, + * sumOfSquares. */ /* Compute sum and store result in a temporary variable, sum. */ -#if defined (ARM_MATH_DSP) - in32 = read_q15x2_ia ((q15_t **) &pSrc); +#if defined(ARM_MATH_DSP) + in32 = read_q15x2_ia((q15_t **)&pSrc); sumOfSquares = __SMLALD(in32, in32, sumOfSquares); sum += ((in32 << 16U) >> 16U); - sum += (in32 >> 16U); + sum += (in32 >> 16U); - in32 = read_q15x2_ia ((q15_t **) &pSrc); + in32 = read_q15x2_ia((q15_t **)&pSrc); sumOfSquares = __SMLALD(in32, in32, sumOfSquares); sum += ((in32 << 16U) >> 16U); - sum += (in32 >> 16U); + sum += (in32 >> 16U); #else in = *pSrc++; sumOfSquares += (in * in); @@ -130,14 +125,14 @@ void arm_var_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* C = A[0] + A[1] + ... + A[blockSize-1] */ in = *pSrc++; - /* Compute sum of squares and store result in a temporary variable, sumOfSquares. */ -#if defined (ARM_MATH_DSP) + /* Compute sum of squares and store result in a temporary variable, + * sumOfSquares. */ +#if defined(ARM_MATH_DSP) sumOfSquares = __SMLALD(in, in, sumOfSquares); #else sumOfSquares += (in * in); @@ -149,11 +144,13 @@ void arm_var_q15( blkCnt--; } - /* Compute Mean of squares and store result in a temporary variable, meanOfSquares. */ - meanOfSquares = (q31_t) (sumOfSquares / (q63_t)(blockSize - 1U)); + /* Compute Mean of squares and store result in a temporary variable, + * meanOfSquares. */ + meanOfSquares = (q31_t)(sumOfSquares / (q63_t)(blockSize - 1U)); /* Compute square of mean */ - squareOfMean = (q31_t) ((q63_t) sum * sum / (q63_t)(blockSize * (blockSize - 1U))); + squareOfMean = + (q31_t)((q63_t)sum * sum / (q63_t)(blockSize * (blockSize - 1U))); /* mean of squares minus the square of mean. */ *pResult = (meanOfSquares - squareOfMean) >> 15U; diff --git a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_var_q31.c b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_var_q31.c index 558332f..a54b697 100644 --- a/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_var_q31.c +++ b/platform/cmsis/DSP_Lib/StatisticsFunctions/arm_var_q31.c @@ -45,62 +45,57 @@ @return none @par Scaling and Overflow Behavior - The function is implemented using an internal 64-bit accumulator. - The input is represented in 1.31 format, which is then downshifted by 8 bits - which yields 1.23, and intermediate multiplication yields a 2.46 format. - The accumulator maintains full precision of the intermediate multiplication results, - but provides only a 16 guard bits. - There is no saturation on intermediate additions. - If the accumulator overflows it wraps around and distorts the result. - In order to avoid overflows completely the input signal must be scaled down by - log2(blockSize)-8 bits, as a total of blockSize additions are performed internally. - After division, internal variables should be Q18.46 - Finally, the 18.46 accumulator is right shifted by 15 bits to yield a 1.31 format value. + The function is implemented using an internal 64-bit + accumulator. The input is represented in 1.31 format, which is then + downshifted by 8 bits which yields 1.23, and intermediate multiplication + yields a 2.46 format. The accumulator maintains full precision of the + intermediate multiplication results, but provides only a 16 guard bits. There + is no saturation on intermediate additions. If the accumulator overflows it + wraps around and distorts the result. In order to avoid overflows completely + the input signal must be scaled down by log2(blockSize)-8 bits, as a total of + blockSize additions are performed internally. After division, internal + variables should be Q18.46 Finally, the 18.46 accumulator is right shifted by + 15 bits to yield a 1.31 format value. */ -void arm_var_q31( - const q31_t * pSrc, - uint32_t blockSize, - q31_t * pResult) -{ - uint32_t blkCnt; /* Loop counter */ - q63_t sum = 0; /* Temporary result storage */ - q63_t meanOfSquares, squareOfMean; /* Square of mean and mean of square */ - q63_t sumOfSquares = 0; /* Sum of squares */ - q31_t in; /* Temporary variable to store input value */ +void arm_var_q31(const q31_t *pSrc, uint32_t blockSize, q31_t *pResult) { + uint32_t blkCnt; /* Loop counter */ + q63_t sum = 0; /* Temporary result storage */ + q63_t meanOfSquares, squareOfMean; /* Square of mean and mean of square */ + q63_t sumOfSquares = 0; /* Sum of squares */ + q31_t in; /* Temporary variable to store input value */ - if (blockSize <= 1U) - { + if (blockSize <= 1U) { *pResult = 0; return; } -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* C = A[0] + A[1] + ... + A[blockSize-1] */ in = *pSrc++ >> 8U; - /* Compute sum of squares and store result in a temporary variable, sumOfSquares. */ - sumOfSquares += ((q63_t) (in) * (in)); + /* Compute sum of squares and store result in a temporary variable, + * sumOfSquares. */ + sumOfSquares += ((q63_t)(in) * (in)); /* Compute sum and store result in a temporary variable, sum. */ sum += in; in = *pSrc++ >> 8U; - sumOfSquares += ((q63_t) (in) * (in)); + sumOfSquares += ((q63_t)(in) * (in)); sum += in; in = *pSrc++ >> 8U; - sumOfSquares += ((q63_t) (in) * (in)); + sumOfSquares += ((q63_t)(in) * (in)); sum += in; in = *pSrc++ >> 8U; - sumOfSquares += ((q63_t) (in) * (in)); + sumOfSquares += ((q63_t)(in) * (in)); sum += in; /* Decrement loop counter */ @@ -117,14 +112,14 @@ void arm_var_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A[0] * A[0] + A[1] * A[1] + ... + A[blockSize-1] * A[blockSize-1] */ /* C = A[0] + A[1] + ... + A[blockSize-1] */ in = *pSrc++ >> 8U; - /* Compute sum of squares and store result in a temporary variable, sumOfSquares. */ - sumOfSquares += ((q63_t) (in) * (in)); + /* Compute sum of squares and store result in a temporary variable, + * sumOfSquares. */ + sumOfSquares += ((q63_t)(in) * (in)); /* Compute sum and store result in a temporary variable, sum. */ sum += in; @@ -132,11 +127,12 @@ void arm_var_q31( blkCnt--; } - /* Compute Mean of squares and store result in a temporary variable, meanOfSquares. */ + /* Compute Mean of squares and store result in a temporary variable, + * meanOfSquares. */ meanOfSquares = (sumOfSquares / (q63_t)(blockSize - 1U)); /* Compute square of mean */ - squareOfMean = ( sum * sum / (q63_t)(blockSize * (blockSize - 1U))); + squareOfMean = (sum * sum / (q63_t)(blockSize * (blockSize - 1U))); /* Compute variance and store result in destination */ *pResult = (meanOfSquares - squareOfMean) >> 15U; diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_copy_f32.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_copy_f32.c index a0ceb00..f543945 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_copy_f32.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_copy_f32.c @@ -57,20 +57,15 @@ @return none */ -void arm_copy_f32( - const float32_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_copy_f32(const float32_t *pSrc, float32_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A */ /* Copy and store result in destination buffer */ @@ -93,8 +88,7 @@ void arm_copy_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A */ /* Copy and store result in destination buffer */ diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_copy_q15.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_copy_q15.c index d8da113..12a3e03 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_copy_q15.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_copy_q15.c @@ -45,25 +45,20 @@ @return none */ -void arm_copy_q15( - const q15_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_copy_q15(const q15_t *pSrc, q15_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A */ /* read 2 times 2 samples at a time */ - write_q15x2_ia (&pDst, read_q15x2_ia ((q15_t **) &pSrc)); - write_q15x2_ia (&pDst, read_q15x2_ia ((q15_t **) &pSrc)); + write_q15x2_ia(&pDst, read_q15x2_ia((q15_t **)&pSrc)); + write_q15x2_ia(&pDst, read_q15x2_ia((q15_t **)&pSrc)); /* Decrement loop counter */ blkCnt--; @@ -79,8 +74,7 @@ void arm_copy_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A */ /* Copy and store result in destination buffer */ diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_copy_q31.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_copy_q31.c index e342a32..96d3094 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_copy_q31.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_copy_q31.c @@ -45,20 +45,15 @@ @return none */ -void arm_copy_q31( - const q31_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_copy_q31(const q31_t *pSrc, q31_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A */ /* Copy and store result in destination buffer */ @@ -81,8 +76,7 @@ void arm_copy_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A */ /* Copy and store result in destination buffer */ diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_copy_q7.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_copy_q7.c index 77da8ca..d1eb019 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_copy_q7.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_copy_q7.c @@ -45,24 +45,19 @@ @return none */ -void arm_copy_q7( - const q7_t * pSrc, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_copy_q7(const q7_t *pSrc, q7_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A */ /* read 4 samples at a time */ - write_q7x4_ia (&pDst, read_q7x4_ia ((q7_t **) &pSrc)); + write_q7x4_ia(&pDst, read_q7x4_ia((q7_t **)&pSrc)); /* Decrement loop counter */ blkCnt--; @@ -78,8 +73,7 @@ void arm_copy_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A */ /* Copy and store result in destination buffer */ diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_fill_f32.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_fill_f32.c index b307d7f..bfff602 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_fill_f32.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_fill_f32.c @@ -57,20 +57,15 @@ @return none */ -void arm_fill_f32( - float32_t value, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_fill_f32(float32_t value, float32_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = value */ /* Fill value in destination buffer */ @@ -93,8 +88,7 @@ void arm_fill_f32( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = value */ /* Fill value in destination buffer */ diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_fill_q15.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_fill_q15.c index d8c0f8d..27fa632 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_fill_q15.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_fill_q15.c @@ -45,15 +45,11 @@ @return none */ -void arm_fill_q15( - q15_t value, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_fill_q15(q15_t value, q15_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t packedValue; /* value packed to 32 bits */ +#if defined(ARM_MATH_LOOPUNROLL) + q31_t packedValue; /* value packed to 32 bits */ /* Packing two 16 bit values to 32 bit value in order to use SIMD */ packedValue = __PKHBT(value, value, 16U); @@ -61,13 +57,12 @@ void arm_fill_q15( /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = value */ /* fill 2 times 2 samples at a time */ - write_q15x2_ia (&pDst, packedValue); - write_q15x2_ia (&pDst, packedValue); + write_q15x2_ia(&pDst, packedValue); + write_q15x2_ia(&pDst, packedValue); /* Decrement loop counter */ blkCnt--; @@ -83,8 +78,7 @@ void arm_fill_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = value */ /* Fill value in destination buffer */ diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_fill_q31.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_fill_q31.c index e174889..d95fe98 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_fill_q31.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_fill_q31.c @@ -45,20 +45,15 @@ @return none */ -void arm_fill_q31( - q31_t value, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_fill_q31(q31_t value, q31_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = value */ /* Fill value in destination buffer */ @@ -81,8 +76,7 @@ void arm_fill_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = value */ /* Fill value in destination buffer */ diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_fill_q7.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_fill_q7.c index bca3267..67aa179 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_fill_q7.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_fill_q7.c @@ -45,15 +45,11 @@ @return none */ -void arm_fill_q7( - q7_t value, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ +void arm_fill_q7(q7_t value, q7_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t packedValue; /* value packed to 32 bits */ +#if defined(ARM_MATH_LOOPUNROLL) + q31_t packedValue; /* value packed to 32 bits */ /* Packing four 8 bit values to 32 bit value in order to use SIMD */ packedValue = __PACKq7(value, value, value, value); @@ -61,12 +57,11 @@ void arm_fill_q7( /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = value */ /* fill 4 samples at a time */ - write_q7x4_ia (&pDst, packedValue); + write_q7x4_ia(&pDst, packedValue); /* Decrement loop counter */ blkCnt--; @@ -82,8 +77,7 @@ void arm_fill_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = value */ /* Fill value in destination buffer */ diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_float_to_q15.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_float_to_q15.c index 6633afe..e634233 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_float_to_q15.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_float_to_q15.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_float_to_q15.c - * Description: Converts the elements of the floating-point vector to Q15 vector + * Description: Converts the elements of the floating-point vector to Q15 + * vector * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -38,7 +39,8 @@ */ /** - @brief Converts the elements of the floating-point vector to Q15 vector. + @brief Converts the elements of the floating-point vector to Q15 + vector. @param[in] pSrc points to the floating-point input vector @param[out] pDst points to the Q15 output vector @param[in] blockSize number of samples in each vector @@ -52,32 +54,29 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q15 range [0x8000 0x7FFF] are saturated. + Results outside of the allowable Q15 range [0x8000 0x7FFF] + are saturated. @note - In order to apply rounding, the library should be rebuilt with the ROUNDING macro - defined in the preprocessor section of project options. + In order to apply rounding, the library should be rebuilt + with the ROUNDING macro defined in the preprocessor section of project + options. */ -void arm_float_to_q15( - const float32_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const float32_t *pIn = pSrc; /* Source pointer */ +void arm_float_to_q15(const float32_t *pSrc, q15_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + const float32_t *pIn = pSrc; /* Source pointer */ #ifdef ARM_MATH_ROUNDING - float32_t in; + float32_t in; #endif /* #ifdef ARM_MATH_ROUNDING */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A * 32768 */ /* convert from float to Q15 and store result in destination buffer */ @@ -85,26 +84,26 @@ void arm_float_to_q15( in = (*pIn++ * 32768.0f); in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16)); + *pDst++ = (q15_t)(__SSAT((q31_t)(in), 16)); in = (*pIn++ * 32768.0f); in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16)); + *pDst++ = (q15_t)(__SSAT((q31_t)(in), 16)); in = (*pIn++ * 32768.0f); in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16)); + *pDst++ = (q15_t)(__SSAT((q31_t)(in), 16)); in = (*pIn++ * 32768.0f); in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16)); + *pDst++ = (q15_t)(__SSAT((q31_t)(in), 16)); #else - *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16); - *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16); - *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16); - *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16); + *pDst++ = (q15_t)__SSAT((q31_t)(*pIn++ * 32768.0f), 16); + *pDst++ = (q15_t)__SSAT((q31_t)(*pIn++ * 32768.0f), 16); + *pDst++ = (q15_t)__SSAT((q31_t)(*pIn++ * 32768.0f), 16); + *pDst++ = (q15_t)__SSAT((q31_t)(*pIn++ * 32768.0f), 16); #endif /* #ifdef ARM_MATH_ROUNDING */ @@ -122,8 +121,7 @@ void arm_float_to_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A * 32768 */ /* convert from float to Q15 and store result in destination buffer */ @@ -131,18 +129,17 @@ void arm_float_to_q15( in = (*pIn++ * 32768.0f); in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q15_t) (__SSAT((q31_t) (in), 16)); + *pDst++ = (q15_t)(__SSAT((q31_t)(in), 16)); #else - *pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16); + *pDst++ = (q15_t)__SSAT((q31_t)(*pIn++ * 32768.0f), 16); #endif /* #ifdef ARM_MATH_ROUNDING */ /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_float_to_q31.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_float_to_q31.c index c9879d3..84bb3ec 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_float_to_q31.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_float_to_q31.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_float_to_q31.c - * Description: Converts the elements of the floating-point vector to Q31 vector + * Description: Converts the elements of the floating-point vector to Q31 + * vector * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -42,7 +43,8 @@ */ /** - @brief Converts the elements of the floating-point vector to Q31 vector. + @brief Converts the elements of the floating-point vector to Q31 + vector. @param[in] pSrc points to the floating-point input vector @param[out] pDst points to the Q31 output vector @param[in] blockSize number of samples in each vector @@ -56,32 +58,29 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q31 range[0x80000000 0x7FFFFFFF] are saturated. + Results outside of the allowable Q31 range[0x80000000 + 0x7FFFFFFF] are saturated. @note - In order to apply rounding, the library should be rebuilt with the ROUNDING macro - defined in the preprocessor section of project options. + In order to apply rounding, the library should be rebuilt + with the ROUNDING macro defined in the preprocessor section of project + options. */ -void arm_float_to_q31( - const float32_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const float32_t *pIn = pSrc; /* Source pointer */ +void arm_float_to_q31(const float32_t *pSrc, q31_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + const float32_t *pIn = pSrc; /* Source pointer */ #ifdef ARM_MATH_ROUNDING - float32_t in; + float32_t in; #endif /* #ifdef ARM_MATH_ROUNDING */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A * 2147483648 */ /* convert from float to Q31 and store result in destination buffer */ @@ -89,26 +88,26 @@ void arm_float_to_q31( in = (*pIn++ * 2147483648.0f); in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = clip_q63_to_q31((q63_t) (in)); + *pDst++ = clip_q63_to_q31((q63_t)(in)); in = (*pIn++ * 2147483648.0f); in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = clip_q63_to_q31((q63_t) (in)); + *pDst++ = clip_q63_to_q31((q63_t)(in)); in = (*pIn++ * 2147483648.0f); in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = clip_q63_to_q31((q63_t) (in)); + *pDst++ = clip_q63_to_q31((q63_t)(in)); in = (*pIn++ * 2147483648.0f); in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = clip_q63_to_q31((q63_t) (in)); + *pDst++ = clip_q63_to_q31((q63_t)(in)); #else - *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f)); - *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f)); - *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f)); - *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f)); + *pDst++ = clip_q63_to_q31((q63_t)(*pIn++ * 2147483648.0f)); + *pDst++ = clip_q63_to_q31((q63_t)(*pIn++ * 2147483648.0f)); + *pDst++ = clip_q63_to_q31((q63_t)(*pIn++ * 2147483648.0f)); + *pDst++ = clip_q63_to_q31((q63_t)(*pIn++ * 2147483648.0f)); #endif /* #ifdef ARM_MATH_ROUNDING */ @@ -126,8 +125,7 @@ void arm_float_to_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A * 2147483648 */ /* convert from float to Q31 and store result in destination buffer */ @@ -135,18 +133,17 @@ void arm_float_to_q31( in = (*pIn++ * 2147483648.0f); in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = clip_q63_to_q31((q63_t) (in)); + *pDst++ = clip_q63_to_q31((q63_t)(in)); #else - *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f)); + *pDst++ = clip_q63_to_q31((q63_t)(*pIn++ * 2147483648.0f)); #endif /* #ifdef ARM_MATH_ROUNDING */ /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_float_to_q7.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_float_to_q7.c index 4855ce4..0370a1d 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_float_to_q7.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_float_to_q7.c @@ -38,7 +38,8 @@ */ /** - @brief Converts the elements of the floating-point vector to Q7 vector. + @brief Converts the elements of the floating-point vector to Q7 + vector. @param[in] pSrc points to the floating-point input vector @param[out] pDst points to the Q7 output vector @param[in] blockSize number of samples in each vector @@ -52,31 +53,27 @@ @par Scaling and Overflow Behavior The function uses saturating arithmetic. - Results outside of the allowable Q7 range [0x80 0x7F] are saturated. + Results outside of the allowable Q7 range [0x80 0x7F] are + saturated. @note - In order to apply rounding, the library should be rebuilt with the ROUNDING macro - defined in the preprocessor section of project options. + In order to apply rounding, the library should be rebuilt with + the ROUNDING macro defined in the preprocessor section of project options. */ -void arm_float_to_q7( - const float32_t * pSrc, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const float32_t *pIn = pSrc; /* Source pointer */ +void arm_float_to_q7(const float32_t *pSrc, q7_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + const float32_t *pIn = pSrc; /* Source pointer */ #ifdef ARM_MATH_ROUNDING - float32_t in; + float32_t in; #endif /* #ifdef ARM_MATH_ROUNDING */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A * 128 */ /* Convert from float to q7 and store result in destination buffer */ @@ -84,26 +81,26 @@ void arm_float_to_q7( in = (*pIn++ * 128); in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8)); + *pDst++ = (q7_t)(__SSAT((q15_t)(in), 8)); in = (*pIn++ * 128); in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8)); + *pDst++ = (q7_t)(__SSAT((q15_t)(in), 8)); in = (*pIn++ * 128); in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8)); + *pDst++ = (q7_t)(__SSAT((q15_t)(in), 8)); in = (*pIn++ * 128); in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8)); + *pDst++ = (q7_t)(__SSAT((q15_t)(in), 8)); #else - *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8); - *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8); - *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8); - *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8); + *pDst++ = __SSAT((q31_t)(*pIn++ * 128.0f), 8); + *pDst++ = __SSAT((q31_t)(*pIn++ * 128.0f), 8); + *pDst++ = __SSAT((q31_t)(*pIn++ * 128.0f), 8); + *pDst++ = __SSAT((q31_t)(*pIn++ * 128.0f), 8); #endif /* #ifdef ARM_MATH_ROUNDING */ @@ -121,8 +118,7 @@ void arm_float_to_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = A * 128 */ /* Convert from float to q7 and store result in destination buffer */ @@ -130,18 +126,17 @@ void arm_float_to_q7( in = (*pIn++ * 128); in += in > 0.0f ? 0.5f : -0.5f; - *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8)); + *pDst++ = (q7_t)(__SSAT((q15_t)(in), 8)); #else - *pDst++ = (q7_t) __SSAT((q31_t) (*pIn++ * 128.0f), 8); + *pDst++ = (q7_t)__SSAT((q31_t)(*pIn++ * 128.0f), 8); #endif /* #ifdef ARM_MATH_ROUNDING */ /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_q15_to_float.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_q15_to_float.c index a9384dc..4269f43 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_q15_to_float.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_q15_to_float.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_q15_to_float.c - * Description: Converts the elements of the Q15 vector to floating-point vector + * Description: Converts the elements of the Q15 vector to floating-point + * vector * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -42,7 +43,8 @@ */ /** - @brief Converts the elements of the Q15 vector to floating-point vector. + @brief Converts the elements of the Q15 vector to floating-point + vector. @param[in] pSrc points to the Q15 input vector @param[out] pDst points to the floating-point output vector @param[in] blockSize number of samples in each vector @@ -55,28 +57,23 @@
*/ -void arm_q15_to_float( - const q15_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const q15_t *pIn = pSrc; /* Source pointer */ +void arm_q15_to_float(const q15_t *pSrc, float32_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + const q15_t *pIn = pSrc; /* Source pointer */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (float32_t) A / 32768 */ /* Convert from q15 to float and store result in destination buffer */ - *pDst++ = ((float32_t) * pIn++ / 32768.0f); - *pDst++ = ((float32_t) * pIn++ / 32768.0f); - *pDst++ = ((float32_t) * pIn++ / 32768.0f); - *pDst++ = ((float32_t) * pIn++ / 32768.0f); + *pDst++ = ((float32_t)*pIn++ / 32768.0f); + *pDst++ = ((float32_t)*pIn++ / 32768.0f); + *pDst++ = ((float32_t)*pIn++ / 32768.0f); + *pDst++ = ((float32_t)*pIn++ / 32768.0f); /* Decrement loop counter */ blkCnt--; @@ -92,17 +89,15 @@ void arm_q15_to_float( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (float32_t) A / 32768 */ /* Convert from q15 to float and store result in destination buffer */ - *pDst++ = ((float32_t) *pIn++ / 32768.0f); + *pDst++ = ((float32_t)*pIn++ / 32768.0f); /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_q15_to_q31.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_q15_to_q31.c index 1afd489..54cc73f 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_q15_to_q31.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_q15_to_q31.c @@ -51,31 +51,26 @@
*/ -void arm_q15_to_q31( - const q15_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const q15_t *pIn = pSrc; /* Source pointer */ +void arm_q15_to_q31(const q15_t *pSrc, q31_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + const q15_t *pIn = pSrc; /* Source pointer */ -#if defined (ARM_MATH_LOOPUNROLL) - q31_t in1, in2; - q31_t out1, out2, out3, out4; +#if defined(ARM_MATH_LOOPUNROLL) + q31_t in1, in2; + q31_t out1, out2, out3, out4; #endif -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (q31_t)A << 16 */ /* Convert from q15 to q31 and store result in destination buffer */ - in1 = read_q15x2_ia ((q15_t **) &pIn); - in2 = read_q15x2_ia ((q15_t **) &pIn); + in1 = read_q15x2_ia((q15_t **)&pIn); + in2 = read_q15x2_ia((q15_t **)&pIn); #ifndef ARM_MATH_BIG_ENDIAN @@ -120,17 +115,15 @@ void arm_q15_to_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (q31_t) A << 16 */ /* Convert from q15 to q31 and store result in destination buffer */ - *pDst++ = (q31_t) *pIn++ << 16; + *pDst++ = (q31_t)*pIn++ << 16; /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_q15_to_q7.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_q15_to_q7.c index d118b76..a6b4074 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_q15_to_q7.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_q15_to_q7.c @@ -51,33 +51,28 @@
*/ -void arm_q15_to_q7( - const q15_t * pSrc, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const q15_t *pIn = pSrc; /* Source pointer */ +void arm_q15_to_q7(const q15_t *pSrc, q7_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + const q15_t *pIn = pSrc; /* Source pointer */ -#if defined (ARM_MATH_LOOPUNROLL) && defined (ARM_MATH_DSP) - q31_t in1, in2; - q31_t out1, out2; +#if defined(ARM_MATH_LOOPUNROLL) && defined(ARM_MATH_DSP) + q31_t in1, in2; + q31_t out1, out2; #endif -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (q7_t) A >> 8 */ /* Convert from q15 to q7 and store result in destination buffer */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) - in1 = read_q15x2_ia ((q15_t **) &pIn); - in2 = read_q15x2_ia ((q15_t **) &pIn); + in1 = read_q15x2_ia((q15_t **)&pIn); + in2 = read_q15x2_ia((q15_t **)&pIn); #ifndef ARM_MATH_BIG_ENDIAN @@ -92,25 +87,26 @@ void arm_q15_to_q7( #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* rotate packed value by 24 */ - out2 = ((uint32_t) out2 << 8) | ((uint32_t) out2 >> 24); + out2 = ((uint32_t)out2 << 8) | ((uint32_t)out2 >> 24); /* anding with 0xff00ff00 to get two 8 bit values */ out1 = out1 & 0xFF00FF00; /* anding with 0x00ff00ff to get two 8 bit values */ out2 = out2 & 0x00FF00FF; - /* oring two values(contains two 8 bit values) to get four packed 8 bit values */ + /* oring two values(contains two 8 bit values) to get four packed 8 bit + * values */ out1 = out1 | out2; /* store 4 samples at a time to destiantion buffer */ - write_q7x4_ia (&pDst, out1); + write_q7x4_ia(&pDst, out1); #else - *pDst++ = (q7_t) (*pIn++ >> 8); - *pDst++ = (q7_t) (*pIn++ >> 8); - *pDst++ = (q7_t) (*pIn++ >> 8); - *pDst++ = (q7_t) (*pIn++ >> 8); + *pDst++ = (q7_t)(*pIn++ >> 8); + *pDst++ = (q7_t)(*pIn++ >> 8); + *pDst++ = (q7_t)(*pIn++ >> 8); + *pDst++ = (q7_t)(*pIn++ >> 8); #endif /* #if defined (ARM_MATH_DSP) */ @@ -128,17 +124,15 @@ void arm_q15_to_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (q7_t) A >> 8 */ /* Convert from q15 to q7 and store result in destination buffer */ - *pDst++ = (q7_t) (*pIn++ >> 8); + *pDst++ = (q7_t)(*pIn++ >> 8); /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_q31_to_float.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_q31_to_float.c index 2ad8736..5643329 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_q31_to_float.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_q31_to_float.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_q31_to_float.c - * Description: Converts the elements of the Q31 vector to floating-point vector + * Description: Converts the elements of the Q31 vector to floating-point + * vector * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -42,7 +43,8 @@ */ /** - @brief Converts the elements of the Q31 vector to floating-point vector. + @brief Converts the elements of the Q31 vector to floating-point + vector. @param[in] pSrc points to the Q31 input vector @param[out] pDst points to the floating-point output vector @param[in] blockSize number of samples in each vector @@ -55,28 +57,23 @@
*/ -void arm_q31_to_float( - const q31_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const q31_t *pIn = pSrc; /* Source pointer */ +void arm_q31_to_float(const q31_t *pSrc, float32_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + const q31_t *pIn = pSrc; /* Source pointer */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (float32_t) A / 2147483648 */ /* Convert from q31 to float and store result in destination buffer */ - *pDst++ = ((float32_t) *pIn++ / 2147483648.0f); - *pDst++ = ((float32_t) *pIn++ / 2147483648.0f); - *pDst++ = ((float32_t) *pIn++ / 2147483648.0f); - *pDst++ = ((float32_t) *pIn++ / 2147483648.0f); + *pDst++ = ((float32_t)*pIn++ / 2147483648.0f); + *pDst++ = ((float32_t)*pIn++ / 2147483648.0f); + *pDst++ = ((float32_t)*pIn++ / 2147483648.0f); + *pDst++ = ((float32_t)*pIn++ / 2147483648.0f); /* Decrement loop counter */ blkCnt--; @@ -92,17 +89,15 @@ void arm_q31_to_float( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (float32_t) A / 2147483648 */ /* Convert from q31 to float and store result in destination buffer */ - *pDst++ = ((float32_t) *pIn++ / 2147483648.0f); + *pDst++ = ((float32_t)*pIn++ / 2147483648.0f); /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_q31_to_q15.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_q31_to_q15.c index 8d82c28..3365510 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_q31_to_q15.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_q31_to_q15.c @@ -51,30 +51,25 @@
*/ -void arm_q31_to_q15( - const q31_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const q31_t *pIn = pSrc; /* Source pointer */ +void arm_q31_to_q15(const q31_t *pSrc, q15_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + const q31_t *pIn = pSrc; /* Source pointer */ -#if defined (ARM_MATH_LOOPUNROLL) && defined (ARM_MATH_DSP) - q31_t in1, in2, in3, in4; - q31_t out1, out2; +#if defined(ARM_MATH_LOOPUNROLL) && defined(ARM_MATH_DSP) + q31_t in1, in2, in3, in4; + q31_t out1, out2; #endif -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (q15_t) (A >> 16) */ /* Convert from q31 to q15 and store result in destination buffer */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) in1 = *pIn++; in2 = *pIn++; @@ -90,15 +85,15 @@ void arm_q31_to_q15( out2 = __PKHTB(in3, in4, 16); #endif /* #ifdef ARM_MATH_BIG_ENDIAN */ - write_q15x2_ia (&pDst, out1); - write_q15x2_ia (&pDst, out2); + write_q15x2_ia(&pDst, out1); + write_q15x2_ia(&pDst, out2); #else - *pDst++ = (q15_t) (*pIn++ >> 16); - *pDst++ = (q15_t) (*pIn++ >> 16); - *pDst++ = (q15_t) (*pIn++ >> 16); - *pDst++ = (q15_t) (*pIn++ >> 16); + *pDst++ = (q15_t)(*pIn++ >> 16); + *pDst++ = (q15_t)(*pIn++ >> 16); + *pDst++ = (q15_t)(*pIn++ >> 16); + *pDst++ = (q15_t)(*pIn++ >> 16); #endif /* #if defined (ARM_MATH_DSP) */ @@ -116,17 +111,15 @@ void arm_q31_to_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (q15_t) (A >> 16) */ /* Convert from q31 to q15 and store result in destination buffer */ - *pDst++ = (q15_t) (*pIn++ >> 16); + *pDst++ = (q15_t)(*pIn++ >> 16); /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_q31_to_q7.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_q31_to_q7.c index c7d1b4c..de81eb0 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_q31_to_q7.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_q31_to_q7.c @@ -51,32 +51,27 @@
*/ -void arm_q31_to_q7( - const q31_t * pSrc, - q7_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const q31_t *pIn = pSrc; /* Source pointer */ +void arm_q31_to_q7(const q31_t *pSrc, q7_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + const q31_t *pIn = pSrc; /* Source pointer */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) q7_t out1, out2, out3, out4; /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (q7_t) (A >> 24) */ /* Convert from q31 to q7 and store result in destination buffer */ - out1 = (q7_t) (*pIn++ >> 24); - out2 = (q7_t) (*pIn++ >> 24); - out3 = (q7_t) (*pIn++ >> 24); - out4 = (q7_t) (*pIn++ >> 24); - write_q7x4_ia (&pDst, __PACKq7(out1, out2, out3, out4)); + out1 = (q7_t)(*pIn++ >> 24); + out2 = (q7_t)(*pIn++ >> 24); + out3 = (q7_t)(*pIn++ >> 24); + out4 = (q7_t)(*pIn++ >> 24); + write_q7x4_ia(&pDst, __PACKq7(out1, out2, out3, out4)); /* Decrement loop counter */ blkCnt--; @@ -92,17 +87,15 @@ void arm_q31_to_q7( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (q7_t) (A >> 24) */ /* Convert from q31 to q7 and store result in destination buffer */ - *pDst++ = (q7_t) (*pIn++ >> 24); + *pDst++ = (q7_t)(*pIn++ >> 24); /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_q7_to_float.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_q7_to_float.c index c8e940b..639d300 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_q7_to_float.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_q7_to_float.c @@ -42,7 +42,8 @@ */ /** - @brief Converts the elements of the Q7 vector to floating-point vector. + @brief Converts the elements of the Q7 vector to floating-point + vector. @param[in] pSrc points to the Q7 input vector @param[out] pDst points to the floating-point output vector @param[in] blockSize number of samples in each vector @@ -55,28 +56,23 @@
*/ -void arm_q7_to_float( - const q7_t * pSrc, - float32_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const q7_t *pIn = pSrc; /* Source pointer */ +void arm_q7_to_float(const q7_t *pSrc, float32_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + const q7_t *pIn = pSrc; /* Source pointer */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (float32_t) A / 128 */ /* Convert from q7 to float and store result in destination buffer */ - *pDst++ = ((float32_t) * pIn++ / 128.0f); - *pDst++ = ((float32_t) * pIn++ / 128.0f); - *pDst++ = ((float32_t) * pIn++ / 128.0f); - *pDst++ = ((float32_t) * pIn++ / 128.0f); + *pDst++ = ((float32_t)*pIn++ / 128.0f); + *pDst++ = ((float32_t)*pIn++ / 128.0f); + *pDst++ = ((float32_t)*pIn++ / 128.0f); + *pDst++ = ((float32_t)*pIn++ / 128.0f); /* Decrement loop counter */ blkCnt--; @@ -92,17 +88,15 @@ void arm_q7_to_float( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (float32_t) A / 128 */ /* Convert from q7 to float and store result in destination buffer */ - *pDst++ = ((float32_t) * pIn++ / 128.0f); + *pDst++ = ((float32_t)*pIn++ / 128.0f); /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_q7_to_q15.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_q7_to_q15.c index 89afd10..a7a0e5f 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_q7_to_q15.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_q7_to_q15.c @@ -51,33 +51,28 @@
*/ -void arm_q7_to_q15( - const q7_t * pSrc, - q15_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const q7_t *pIn = pSrc; /* Source pointer */ +void arm_q7_to_q15(const q7_t *pSrc, q15_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + const q7_t *pIn = pSrc; /* Source pointer */ -#if defined (ARM_MATH_LOOPUNROLL) && defined (ARM_MATH_DSP) - q31_t in; - q31_t in1, in2; - q31_t out1, out2; +#if defined(ARM_MATH_LOOPUNROLL) && defined(ARM_MATH_DSP) + q31_t in; + q31_t in1, in2; + q31_t out1, out2; #endif -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (q15_t) A << 8 */ /* Convert from q7 to q15 and store result in destination buffer */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) - in = read_q7x4_ia ((q7_t **) &pIn); + in = read_q7x4_ia((q7_t **)&pIn); /* rotatate in by 8 and extend two q7_t values to q15_t values */ in1 = __SXTB16(__ROR(in, 8)); @@ -99,15 +94,15 @@ void arm_q7_to_q15( out2 = __PKHBT(in2, in1, 16); #endif - write_q15x2_ia (&pDst, out1); - write_q15x2_ia (&pDst, out2); + write_q15x2_ia(&pDst, out1); + write_q15x2_ia(&pDst, out2); #else - *pDst++ = (q15_t) *pIn++ << 8; - *pDst++ = (q15_t) *pIn++ << 8; - *pDst++ = (q15_t) *pIn++ << 8; - *pDst++ = (q15_t) *pIn++ << 8; + *pDst++ = (q15_t)*pIn++ << 8; + *pDst++ = (q15_t)*pIn++ << 8; + *pDst++ = (q15_t)*pIn++ << 8; + *pDst++ = (q15_t)*pIn++ << 8; #endif /* #if defined (ARM_MATH_DSP) */ @@ -125,17 +120,15 @@ void arm_q7_to_q15( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (q15_t) A << 8 */ /* Convert from q7 to q15 and store result in destination buffer */ - *pDst++ = (q15_t) * pIn++ << 8; + *pDst++ = (q15_t)*pIn++ << 8; /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/SupportFunctions/arm_q7_to_q31.c b/platform/cmsis/DSP_Lib/SupportFunctions/arm_q7_to_q31.c index 641c02d..367a7fc 100644 --- a/platform/cmsis/DSP_Lib/SupportFunctions/arm_q7_to_q31.c +++ b/platform/cmsis/DSP_Lib/SupportFunctions/arm_q7_to_q31.c @@ -51,27 +51,22 @@
*/ -void arm_q7_to_q31( - const q7_t * pSrc, - q31_t * pDst, - uint32_t blockSize) -{ - uint32_t blkCnt; /* Loop counter */ - const q7_t *pIn = pSrc; /* Source pointer */ +void arm_q7_to_q31(const q7_t *pSrc, q31_t *pDst, uint32_t blockSize) { + uint32_t blkCnt; /* Loop counter */ + const q7_t *pIn = pSrc; /* Source pointer */ -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) - q31_t in; + q31_t in; /* Loop unrolling: Compute 4 outputs at a time */ blkCnt = blockSize >> 2U; - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (q31_t) A << 24 */ /* Convert from q7 to q31 and store result in destination buffer */ - in = read_q7x4_ia ((q7_t **) &pIn); + in = read_q7x4_ia((q7_t **)&pIn); #ifndef ARM_MATH_BIG_ENDIAN @@ -103,17 +98,15 @@ void arm_q7_to_q31( #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - while (blkCnt > 0U) - { + while (blkCnt > 0U) { /* C = (q31_t) A << 24 */ /* Convert from q7 to q31 and store result in destination buffer */ - *pDst++ = (q31_t) * pIn++ << 24; + *pDst++ = (q31_t)*pIn++ << 24; /* Decrement loop counter */ blkCnt--; } - } /** diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_bitreversal.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_bitreversal.c index c608129..6bd5e9b 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_bitreversal.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_bitreversal.c @@ -26,204 +26,182 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @brief In-place floating-point bit reversal function. @param[in,out] pSrc points to in-place floating-point data buffer @param[in] fftSize length of FFT - @param[in] bitRevFactor bit reversal modifier that supports different size FFTs with the same bit reversal table + @param[in] bitRevFactor bit reversal modifier that supports different size + FFTs with the same bit reversal table @param[in] pBitRevTab points to bit reversal table @return none */ -void arm_bitreversal_f32( - float32_t * pSrc, - uint16_t fftSize, - uint16_t bitRevFactor, - const uint16_t * pBitRevTab) -{ - uint16_t fftLenBy2, fftLenBy2p1; - uint16_t i, j; - float32_t in; +void arm_bitreversal_f32(float32_t *pSrc, uint16_t fftSize, + uint16_t bitRevFactor, const uint16_t *pBitRevTab) { + uint16_t fftLenBy2, fftLenBy2p1; + uint16_t i, j; + float32_t in; - /* Initializations */ - j = 0U; - fftLenBy2 = fftSize >> 1U; - fftLenBy2p1 = (fftSize >> 1U) + 1U; + /* Initializations */ + j = 0U; + fftLenBy2 = fftSize >> 1U; + fftLenBy2p1 = (fftSize >> 1U) + 1U; - /* Bit Reversal Implementation */ - for (i = 0U; i <= (fftLenBy2 - 2U); i += 2U) - { - if (i < j) - { - /* pSrc[i] <-> pSrc[j]; */ - in = pSrc[2U * i]; - pSrc[2U * i] = pSrc[2U * j]; - pSrc[2U * j] = in; - - /* pSrc[i+1U] <-> pSrc[j+1U] */ - in = pSrc[(2U * i) + 1U]; - pSrc[(2U * i) + 1U] = pSrc[(2U * j) + 1U]; - pSrc[(2U * j) + 1U] = in; - - /* pSrc[i+fftLenBy2p1] <-> pSrc[j+fftLenBy2p1] */ - in = pSrc[2U * (i + fftLenBy2p1)]; - pSrc[2U * (i + fftLenBy2p1)] = pSrc[2U * (j + fftLenBy2p1)]; - pSrc[2U * (j + fftLenBy2p1)] = in; - - /* pSrc[i+fftLenBy2p1+1U] <-> pSrc[j+fftLenBy2p1+1U] */ - in = pSrc[(2U * (i + fftLenBy2p1)) + 1U]; - pSrc[(2U * (i + fftLenBy2p1)) + 1U] = - pSrc[(2U * (j + fftLenBy2p1)) + 1U]; - pSrc[(2U * (j + fftLenBy2p1)) + 1U] = in; - - } + /* Bit Reversal Implementation */ + for (i = 0U; i <= (fftLenBy2 - 2U); i += 2U) { + if (i < j) { + /* pSrc[i] <-> pSrc[j]; */ + in = pSrc[2U * i]; + pSrc[2U * i] = pSrc[2U * j]; + pSrc[2U * j] = in; /* pSrc[i+1U] <-> pSrc[j+1U] */ - in = pSrc[2U * (i + 1U)]; - pSrc[2U * (i + 1U)] = pSrc[2U * (j + fftLenBy2)]; - pSrc[2U * (j + fftLenBy2)] = in; + in = pSrc[(2U * i) + 1U]; + pSrc[(2U * i) + 1U] = pSrc[(2U * j) + 1U]; + pSrc[(2U * j) + 1U] = in; - /* pSrc[i+2U] <-> pSrc[j+2U] */ - in = pSrc[(2U * (i + 1U)) + 1U]; - pSrc[(2U * (i + 1U)) + 1U] = pSrc[(2U * (j + fftLenBy2)) + 1U]; - pSrc[(2U * (j + fftLenBy2)) + 1U] = in; + /* pSrc[i+fftLenBy2p1] <-> pSrc[j+fftLenBy2p1] */ + in = pSrc[2U * (i + fftLenBy2p1)]; + pSrc[2U * (i + fftLenBy2p1)] = pSrc[2U * (j + fftLenBy2p1)]; + pSrc[2U * (j + fftLenBy2p1)] = in; - /* Reading the index for the bit reversal */ - j = *pBitRevTab; + /* pSrc[i+fftLenBy2p1+1U] <-> pSrc[j+fftLenBy2p1+1U] */ + in = pSrc[(2U * (i + fftLenBy2p1)) + 1U]; + pSrc[(2U * (i + fftLenBy2p1)) + 1U] = pSrc[(2U * (j + fftLenBy2p1)) + 1U]; + pSrc[(2U * (j + fftLenBy2p1)) + 1U] = in; + } - /* Updating the bit reversal index depending on the fft length */ - pBitRevTab += bitRevFactor; - } + /* pSrc[i+1U] <-> pSrc[j+1U] */ + in = pSrc[2U * (i + 1U)]; + pSrc[2U * (i + 1U)] = pSrc[2U * (j + fftLenBy2)]; + pSrc[2U * (j + fftLenBy2)] = in; + + /* pSrc[i+2U] <-> pSrc[j+2U] */ + in = pSrc[(2U * (i + 1U)) + 1U]; + pSrc[(2U * (i + 1U)) + 1U] = pSrc[(2U * (j + fftLenBy2)) + 1U]; + pSrc[(2U * (j + fftLenBy2)) + 1U] = in; + + /* Reading the index for the bit reversal */ + j = *pBitRevTab; + + /* Updating the bit reversal index depending on the fft length */ + pBitRevTab += bitRevFactor; + } } - /** @brief In-place Q31 bit reversal function. @param[in,out] pSrc points to in-place Q31 data buffer. @param[in] fftLen length of FFT. - @param[in] bitRevFactor bit reversal modifier that supports different size FFTs with the same bit reversal table + @param[in] bitRevFactor bit reversal modifier that supports different size + FFTs with the same bit reversal table @param[in] pBitRevTab points to bit reversal table @return none */ -void arm_bitreversal_q31( - q31_t * pSrc, - uint32_t fftLen, - uint16_t bitRevFactor, - const uint16_t * pBitRevTab) -{ - uint32_t fftLenBy2, fftLenBy2p1, i, j; - q31_t in; +void arm_bitreversal_q31(q31_t *pSrc, uint32_t fftLen, uint16_t bitRevFactor, + const uint16_t *pBitRevTab) { + uint32_t fftLenBy2, fftLenBy2p1, i, j; + q31_t in; - /* Initializations */ - j = 0U; - fftLenBy2 = fftLen / 2U; - fftLenBy2p1 = (fftLen / 2U) + 1U; + /* Initializations */ + j = 0U; + fftLenBy2 = fftLen / 2U; + fftLenBy2p1 = (fftLen / 2U) + 1U; - /* Bit Reversal Implementation */ - for (i = 0U; i <= (fftLenBy2 - 2U); i += 2U) - { - if (i < j) - { - /* pSrc[i] <-> pSrc[j]; */ - in = pSrc[2U * i]; - pSrc[2U * i] = pSrc[2U * j]; - pSrc[2U * j] = in; - - /* pSrc[i+1U] <-> pSrc[j+1U] */ - in = pSrc[(2U * i) + 1U]; - pSrc[(2U * i) + 1U] = pSrc[(2U * j) + 1U]; - pSrc[(2U * j) + 1U] = in; - - /* pSrc[i+fftLenBy2p1] <-> pSrc[j+fftLenBy2p1] */ - in = pSrc[2U * (i + fftLenBy2p1)]; - pSrc[2U * (i + fftLenBy2p1)] = pSrc[2U * (j + fftLenBy2p1)]; - pSrc[2U * (j + fftLenBy2p1)] = in; - - /* pSrc[i+fftLenBy2p1+1U] <-> pSrc[j+fftLenBy2p1+1U] */ - in = pSrc[(2U * (i + fftLenBy2p1)) + 1U]; - pSrc[(2U * (i + fftLenBy2p1)) + 1U] = - pSrc[(2U * (j + fftLenBy2p1)) + 1U]; - pSrc[(2U * (j + fftLenBy2p1)) + 1U] = in; - - } + /* Bit Reversal Implementation */ + for (i = 0U; i <= (fftLenBy2 - 2U); i += 2U) { + if (i < j) { + /* pSrc[i] <-> pSrc[j]; */ + in = pSrc[2U * i]; + pSrc[2U * i] = pSrc[2U * j]; + pSrc[2U * j] = in; /* pSrc[i+1U] <-> pSrc[j+1U] */ - in = pSrc[2U * (i + 1U)]; - pSrc[2U * (i + 1U)] = pSrc[2U * (j + fftLenBy2)]; - pSrc[2U * (j + fftLenBy2)] = in; + in = pSrc[(2U * i) + 1U]; + pSrc[(2U * i) + 1U] = pSrc[(2U * j) + 1U]; + pSrc[(2U * j) + 1U] = in; - /* pSrc[i+2U] <-> pSrc[j+2U] */ - in = pSrc[(2U * (i + 1U)) + 1U]; - pSrc[(2U * (i + 1U)) + 1U] = pSrc[(2U * (j + fftLenBy2)) + 1U]; - pSrc[(2U * (j + fftLenBy2)) + 1U] = in; + /* pSrc[i+fftLenBy2p1] <-> pSrc[j+fftLenBy2p1] */ + in = pSrc[2U * (i + fftLenBy2p1)]; + pSrc[2U * (i + fftLenBy2p1)] = pSrc[2U * (j + fftLenBy2p1)]; + pSrc[2U * (j + fftLenBy2p1)] = in; - /* Reading the index for the bit reversal */ - j = *pBitRevTab; + /* pSrc[i+fftLenBy2p1+1U] <-> pSrc[j+fftLenBy2p1+1U] */ + in = pSrc[(2U * (i + fftLenBy2p1)) + 1U]; + pSrc[(2U * (i + fftLenBy2p1)) + 1U] = pSrc[(2U * (j + fftLenBy2p1)) + 1U]; + pSrc[(2U * (j + fftLenBy2p1)) + 1U] = in; + } - /* Updating the bit reversal index depending on the fft length */ - pBitRevTab += bitRevFactor; - } + /* pSrc[i+1U] <-> pSrc[j+1U] */ + in = pSrc[2U * (i + 1U)]; + pSrc[2U * (i + 1U)] = pSrc[2U * (j + fftLenBy2)]; + pSrc[2U * (j + fftLenBy2)] = in; + + /* pSrc[i+2U] <-> pSrc[j+2U] */ + in = pSrc[(2U * (i + 1U)) + 1U]; + pSrc[(2U * (i + 1U)) + 1U] = pSrc[(2U * (j + fftLenBy2)) + 1U]; + pSrc[(2U * (j + fftLenBy2)) + 1U] = in; + + /* Reading the index for the bit reversal */ + j = *pBitRevTab; + + /* Updating the bit reversal index depending on the fft length */ + pBitRevTab += bitRevFactor; + } } - - /** @brief In-place Q15 bit reversal function. @param[in,out] pSrc16 points to in-place Q15 data buffer @param[in] fftLen length of FFT - @param[in] bitRevFactor bit reversal modifier that supports different size FFTs with the same bit reversal table + @param[in] bitRevFactor bit reversal modifier that supports different size + FFTs with the same bit reversal table @param[in] pBitRevTab points to bit reversal table @return none */ -void arm_bitreversal_q15( - q15_t * pSrc16, - uint32_t fftLen, - uint16_t bitRevFactor, - const uint16_t * pBitRevTab) -{ - q31_t *pSrc = (q31_t *) pSrc16; - q31_t in; - uint32_t fftLenBy2, fftLenBy2p1; - uint32_t i, j; +void arm_bitreversal_q15(q15_t *pSrc16, uint32_t fftLen, uint16_t bitRevFactor, + const uint16_t *pBitRevTab) { + q31_t *pSrc = (q31_t *)pSrc16; + q31_t in; + uint32_t fftLenBy2, fftLenBy2p1; + uint32_t i, j; - /* Initializations */ - j = 0U; - fftLenBy2 = fftLen / 2U; - fftLenBy2p1 = (fftLen / 2U) + 1U; + /* Initializations */ + j = 0U; + fftLenBy2 = fftLen / 2U; + fftLenBy2p1 = (fftLen / 2U) + 1U; - /* Bit Reversal Implementation */ - for (i = 0U; i <= (fftLenBy2 - 2U); i += 2U) - { - if (i < j) - { - /* pSrc[i] <-> pSrc[j]; */ - /* pSrc[i+1U] <-> pSrc[j+1U] */ - in = pSrc[i]; - pSrc[i] = pSrc[j]; - pSrc[j] = in; + /* Bit Reversal Implementation */ + for (i = 0U; i <= (fftLenBy2 - 2U); i += 2U) { + if (i < j) { + /* pSrc[i] <-> pSrc[j]; */ + /* pSrc[i+1U] <-> pSrc[j+1U] */ + in = pSrc[i]; + pSrc[i] = pSrc[j]; + pSrc[j] = in; - /* pSrc[i + fftLenBy2p1] <-> pSrc[j + fftLenBy2p1]; */ - /* pSrc[i + fftLenBy2p1+1U] <-> pSrc[j + fftLenBy2p1+1U] */ - in = pSrc[i + fftLenBy2p1]; - pSrc[i + fftLenBy2p1] = pSrc[j + fftLenBy2p1]; - pSrc[j + fftLenBy2p1] = in; - } + /* pSrc[i + fftLenBy2p1] <-> pSrc[j + fftLenBy2p1]; */ + /* pSrc[i + fftLenBy2p1+1U] <-> pSrc[j + fftLenBy2p1+1U] */ + in = pSrc[i + fftLenBy2p1]; + pSrc[i + fftLenBy2p1] = pSrc[j + fftLenBy2p1]; + pSrc[j + fftLenBy2p1] = in; + } - /* pSrc[i+1U] <-> pSrc[j+fftLenBy2]; */ - /* pSrc[i+2] <-> pSrc[j+fftLenBy2+1U] */ - in = pSrc[i + 1U]; - pSrc[i + 1U] = pSrc[j + fftLenBy2]; - pSrc[j + fftLenBy2] = in; + /* pSrc[i+1U] <-> pSrc[j+fftLenBy2]; */ + /* pSrc[i+2] <-> pSrc[j+fftLenBy2+1U] */ + in = pSrc[i + 1U]; + pSrc[i + 1U] = pSrc[j + fftLenBy2]; + pSrc[j + fftLenBy2] = in; - /* Reading the index for the bit reversal */ - j = *pBitRevTab; + /* Reading the index for the bit reversal */ + j = *pBitRevTab; - /* Updating the bit reversal index depending on the fft length */ - pBitRevTab += bitRevFactor; - } + /* Updating the bit reversal index depending on the fft length */ + pBitRevTab += bitRevFactor; + } } diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_bitreversal2.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_bitreversal2.c index c5fe60f..b1575d8 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_bitreversal2.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_bitreversal2.c @@ -26,73 +26,66 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @brief In-place 32 bit reversal function. - @param[in,out] pSrc points to in-place buffer of unknown 32-bit data type + @param[in,out] pSrc points to in-place buffer of unknown 32-bit data + type @param[in] bitRevLen bit reversal table length @param[in] pBitRevTab points to bit reversal table @return none */ -void arm_bitreversal_32( - uint32_t *pSrc, - const uint16_t bitRevLen, - const uint16_t *pBitRevTab) -{ +void arm_bitreversal_32(uint32_t *pSrc, const uint16_t bitRevLen, + const uint16_t *pBitRevTab) { uint32_t a, b, i, tmp; - for (i = 0; i < bitRevLen; ) - { - a = pBitRevTab[i ] >> 2; - b = pBitRevTab[i + 1] >> 2; + for (i = 0; i < bitRevLen;) { + a = pBitRevTab[i] >> 2; + b = pBitRevTab[i + 1] >> 2; - //real - tmp = pSrc[a]; - pSrc[a] = pSrc[b]; - pSrc[b] = tmp; + // real + tmp = pSrc[a]; + pSrc[a] = pSrc[b]; + pSrc[b] = tmp; - //complex - tmp = pSrc[a+1]; - pSrc[a+1] = pSrc[b+1]; - pSrc[b+1] = tmp; + // complex + tmp = pSrc[a + 1]; + pSrc[a + 1] = pSrc[b + 1]; + pSrc[b + 1] = tmp; i += 2; } } - /** @brief In-place 16 bit reversal function. - @param[in,out] pSrc points to in-place buffer of unknown 16-bit data type + @param[in,out] pSrc points to in-place buffer of unknown 16-bit data + type @param[in] bitRevLen bit reversal table length @param[in] pBitRevTab points to bit reversal table @return none */ -void arm_bitreversal_16( - uint16_t *pSrc, - const uint16_t bitRevLen, - const uint16_t *pBitRevTab) -{ +void arm_bitreversal_16(uint16_t *pSrc, const uint16_t bitRevLen, + const uint16_t *pBitRevTab) { uint16_t a, b, i, tmp; - for (i = 0; i < bitRevLen; ) - { - a = pBitRevTab[i ] >> 2; - b = pBitRevTab[i + 1] >> 2; + for (i = 0; i < bitRevLen;) { + a = pBitRevTab[i] >> 2; + b = pBitRevTab[i + 1] >> 2; - //real - tmp = pSrc[a]; - pSrc[a] = pSrc[b]; - pSrc[b] = tmp; + // real + tmp = pSrc[a]; + pSrc[a] = pSrc[b]; + pSrc[b] = tmp; - //complex - tmp = pSrc[a+1]; - pSrc[a+1] = pSrc[b+1]; - pSrc[b+1] = tmp; + // complex + tmp = pSrc[a + 1]; + pSrc[a + 1] = pSrc[b + 1]; + pSrc[b + 1] = tmp; i += 2; } diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_f32.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_f32.c index 2fff61c..f8b25f3 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_f32.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_f32.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_f32.c - * Description: Combined Radix Decimation in Frequency CFFT Floating point processing function + * Description: Combined Radix Decimation in Frequency CFFT Floating point + * processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -26,19 +27,15 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" -extern void arm_radix8_butterfly_f32( - float32_t * pSrc, - uint16_t fftLen, - const float32_t * pCoef, - uint16_t twidCoefModifier); +extern void arm_radix8_butterfly_f32(float32_t *pSrc, uint16_t fftLen, + const float32_t *pCoef, + uint16_t twidCoefModifier); -extern void arm_bitreversal_32( - uint32_t * pSrc, - const uint16_t bitRevLen, - const uint16_t * pBitRevTable); +extern void arm_bitreversal_32(uint32_t *pSrc, const uint16_t bitRevLen, + const uint16_t *pBitRevTable); /** @ingroup groupTransforms @@ -46,54 +43,57 @@ extern void arm_bitreversal_32( /** @defgroup ComplexFFT Complex FFT Functions - + @par - The Fast Fourier Transform (FFT) is an efficient algorithm for computing the - Discrete Fourier Transform (DFT). The FFT can be orders of magnitude faster - than the DFT, especially for long lengths. - The algorithms described in this section - operate on complex data. A separate set of functions is devoted to handling - of real sequences. + The Fast Fourier Transform (FFT) is an efficient algorithm + for computing the Discrete Fourier Transform (DFT). The FFT can be orders of + magnitude faster than the DFT, especially for long lengths. The algorithms + described in this section operate on complex data. A separate set of + functions is devoted to handling of real sequences. @par - There are separate algorithms for handling floating-point, Q15, and Q31 data - types. The algorithms available for each data type are described next. + There are separate algorithms for handling floating-point, + Q15, and Q31 data types. The algorithms available for each data type are + described next. @par - The FFT functions operate in-place. That is, the array holding the input data - will also be used to hold the corresponding result. The input data is complex - and contains 2*fftLen interleaved values as shown below. -
{real[0], imag[0], real[1], imag[1], ...} 
- The FFT result will be contained in the same array and the frequency domain - values will have the same interleaving. - + The FFT functions operate in-place. That is, the array + holding the input data will also be used to hold the corresponding result. The + input data is complex and contains 2*fftLen interleaved values as + shown below.
{real[0], imag[0], real[1], imag[1], ...} 
The FFT + result will be contained in the same array and the frequency domain values + will have the same interleaving. + @par Floating-point - The floating-point complex FFT uses a mixed-radix algorithm. Multiple radix-8 - stages are performed along with a single radix-2 or radix-4 stage, as needed. - The algorithm supports lengths of [16, 32, 64, ..., 4096] and each length uses - a different twiddle factor table. + The floating-point complex FFT uses a mixed-radix algorithm. + Multiple radix-8 stages are performed along with a single radix-2 or radix-4 + stage, as needed. The algorithm supports lengths of [16, 32, 64, ..., 4096] + and each length uses a different twiddle factor table. @par - The function uses the standard FFT definition and output values may grow by a - factor of fftLen when computing the forward transform. The - inverse transform includes a scale of 1/fftLen as part of the - calculation and this matches the textbook definition of the inverse FFT. + The function uses the standard FFT definition and output + values may grow by a factor of fftLen when computing the forward + transform. The inverse transform includes a scale of 1/fftLen as + part of the calculation and this matches the textbook definition of the + inverse FFT. @par - Pre-initialized data structures containing twiddle factors and bit reversal - tables are provided and defined in arm_const_structs.h. Include - this header in your function and then pass one of the constant structures as - an argument to arm_cfft_f32. For example: + Pre-initialized data structures containing twiddle factors + and bit reversal tables are provided and defined in + arm_const_structs.h. Include this header in your function and + then pass one of the constant structures as an argument to arm_cfft_f32. For + example: @par arm_cfft_f32(arm_cfft_sR_f32_len64, pSrc, 1, 1) @par - computes a 64-point inverse complex FFT including bit reversal. - The data structures are treated as constant data and not modified during the - calculation. The same data structure can be reused for multiple transforms - including mixing forward and inverse transforms. + computes a 64-point inverse complex FFT including bit + reversal. The data structures are treated as constant data and not modified + during the calculation. The same data structure can be reused for multiple + transforms including mixing forward and inverse transforms. @par - Earlier releases of the library provided separate radix-2 and radix-4 - algorithms that operated on floating-point data. These functions are still - provided but are deprecated. The older functions are slower and less general - than the new functions. + Earlier releases of the library provided separate radix-2 and + radix-4 algorithms that operated on floating-point data. These functions are + still provided but are deprecated. The older functions are slower and less + general than the new functions. @par - An example of initialization of the constants for the arm_cfft_f32 function follows: + An example of initialization of the constants for the + arm_cfft_f32 function follows: @code const static arm_cfft_instance_f32 *S; ... @@ -128,34 +128,37 @@ extern void arm_bitreversal_32( } @endcode @par Q15 and Q31 - The floating-point complex FFT uses a mixed-radix algorithm. Multiple radix-4 - stages are performed along with a single radix-2 stage, as needed. - The algorithm supports lengths of [16, 32, 64, ..., 4096] and each length uses - a different twiddle factor table. + The floating-point complex FFT uses a mixed-radix algorithm. + Multiple radix-4 stages are performed along with a single radix-2 stage, as + needed. The algorithm supports lengths of [16, 32, 64, ..., 4096] and each + length uses a different twiddle factor table. @par - The function uses the standard FFT definition and output values may grow by a - factor of fftLen when computing the forward transform. The - inverse transform includes a scale of 1/fftLen as part of the - calculation and this matches the textbook definition of the inverse FFT. + The function uses the standard FFT definition and output + values may grow by a factor of fftLen when computing the forward + transform. The inverse transform includes a scale of 1/fftLen as + part of the calculation and this matches the textbook definition of the + inverse FFT. @par - Pre-initialized data structures containing twiddle factors and bit reversal - tables are provided and defined in arm_const_structs.h. Include - this header in your function and then pass one of the constant structures as - an argument to arm_cfft_q31. For example: + Pre-initialized data structures containing twiddle factors + and bit reversal tables are provided and defined in + arm_const_structs.h. Include this header in your function and + then pass one of the constant structures as an argument to arm_cfft_q31. For + example: @par arm_cfft_q31(arm_cfft_sR_q31_len64, pSrc, 1, 1) @par - computes a 64-point inverse complex FFT including bit reversal. - The data structures are treated as constant data and not modified during the - calculation. The same data structure can be reused for multiple transforms - including mixing forward and inverse transforms. + computes a 64-point inverse complex FFT including bit + reversal. The data structures are treated as constant data and not modified + during the calculation. The same data structure can be reused for multiple + transforms including mixing forward and inverse transforms. @par - Earlier releases of the library provided separate radix-2 and radix-4 - algorithms that operated on floating-point data. These functions are still - provided but are deprecated. The older functions are slower and less general - than the new functions. + Earlier releases of the library provided separate radix-2 and + radix-4 algorithms that operated on floating-point data. These functions are + still provided but are deprecated. The older functions are slower and less + general than the new functions. @par - An example of initialization of the constants for the arm_cfft_q31 function follows: + An example of initialization of the constants for the + arm_cfft_q31 function follows: @code const static arm_cfft_instance_q31 *S; ... @@ -189,15 +192,14 @@ extern void arm_bitreversal_32( break; } @endcode - + */ -void arm_cfft_radix8by2_f32 (arm_cfft_instance_f32 * S, float32_t * p1) -{ - uint32_t L = S->fftLen; - float32_t * pCol1, * pCol2, * pMid1, * pMid2; - float32_t * p2 = p1 + L; - const float32_t * tw = (float32_t *) S->pTwiddle; +void arm_cfft_radix8by2_f32(arm_cfft_instance_f32 *S, float32_t *p1) { + uint32_t L = S->fftLen; + float32_t *pCol1, *pCol2, *pMid1, *pMid2; + float32_t *p2 = p1 + L; + const float32_t *tw = (float32_t *)S->pTwiddle; float32_t t1[4], t2[4], t3[4], t4[4], twR, twI; float32_t m0, m1, m2, m3; uint32_t l; @@ -213,8 +215,7 @@ void arm_cfft_radix8by2_f32 (arm_cfft_instance_f32 * S, float32_t * p1) pMid2 = p2 + L; /* do two dot Fourier transform */ - for (l = L >> 2; l > 0; l-- ) - { + for (l = L >> 2; l > 0; l--) { t1[0] = p1[0]; t1[1] = p1[1]; t1[2] = p1[2]; @@ -238,12 +239,12 @@ void arm_cfft_radix8by2_f32 (arm_cfft_instance_f32 * S, float32_t * p1) *p1++ = t1[0] + t2[0]; *p1++ = t1[1] + t2[1]; *p1++ = t1[2] + t2[2]; - *p1++ = t1[3] + t2[3]; /* col 1 */ + *p1++ = t1[3] + t2[3]; /* col 1 */ t2[0] = t1[0] - t2[0]; t2[1] = t1[1] - t2[1]; t2[2] = t1[2] - t2[2]; - t2[3] = t1[3] - t2[3]; /* for col 2 */ + t2[3] = t1[3] - t2[3]; /* for col 2 */ *pMid1++ = t3[0] + t4[0]; *pMid1++ = t3[1] + t4[1]; @@ -253,7 +254,7 @@ void arm_cfft_radix8by2_f32 (arm_cfft_instance_f32 * S, float32_t * p1) t4[0] = t4[0] - t3[0]; t4[1] = t4[1] - t3[1]; t4[2] = t4[2] - t3[2]; - t4[3] = t4[3] - t3[3]; /* for col 2 */ + t4[3] = t4[3] - t3[3]; /* for col 2 */ twR = *tw++; twI = *tw++; @@ -300,50 +301,80 @@ void arm_cfft_radix8by2_f32 (arm_cfft_instance_f32 * S, float32_t * p1) } /* first col */ - arm_radix8_butterfly_f32 (pCol1, L, (float32_t *) S->pTwiddle, 2U); + arm_radix8_butterfly_f32(pCol1, L, (float32_t *)S->pTwiddle, 2U); /* second col */ - arm_radix8_butterfly_f32 (pCol2, L, (float32_t *) S->pTwiddle, 2U); + arm_radix8_butterfly_f32(pCol2, L, (float32_t *)S->pTwiddle, 2U); } -void arm_cfft_radix8by4_f32 (arm_cfft_instance_f32 * S, float32_t * p1) -{ - uint32_t L = S->fftLen >> 1; - float32_t * pCol1, *pCol2, *pCol3, *pCol4, *pEnd1, *pEnd2, *pEnd3, *pEnd4; - const float32_t *tw2, *tw3, *tw4; - float32_t * p2 = p1 + L; - float32_t * p3 = p2 + L; - float32_t * p4 = p3 + L; - float32_t t2[4], t3[4], t4[4], twR, twI; - float32_t p1ap3_0, p1sp3_0, p1ap3_1, p1sp3_1; - float32_t m0, m1, m2, m3; - uint32_t l, twMod2, twMod3, twMod4; +void arm_cfft_radix8by4_f32(arm_cfft_instance_f32 *S, float32_t *p1) { + uint32_t L = S->fftLen >> 1; + float32_t *pCol1, *pCol2, *pCol3, *pCol4, *pEnd1, *pEnd2, *pEnd3, *pEnd4; + const float32_t *tw2, *tw3, *tw4; + float32_t *p2 = p1 + L; + float32_t *p3 = p2 + L; + float32_t *p4 = p3 + L; + float32_t t2[4], t3[4], t4[4], twR, twI; + float32_t p1ap3_0, p1sp3_0, p1ap3_1, p1sp3_1; + float32_t m0, m1, m2, m3; + uint32_t l, twMod2, twMod3, twMod4; - pCol1 = p1; /* points to real values by default */ - pCol2 = p2; - pCol3 = p3; - pCol4 = p4; - pEnd1 = p2 - 1; /* points to imaginary values by default */ - pEnd2 = p3 - 1; - pEnd3 = p4 - 1; - pEnd4 = pEnd3 + L; + pCol1 = p1; /* points to real values by default */ + pCol2 = p2; + pCol3 = p3; + pCol4 = p4; + pEnd1 = p2 - 1; /* points to imaginary values by default */ + pEnd2 = p3 - 1; + pEnd3 = p4 - 1; + pEnd4 = pEnd3 + L; - tw2 = tw3 = tw4 = (float32_t *) S->pTwiddle; + tw2 = tw3 = tw4 = (float32_t *)S->pTwiddle; - L >>= 1; + L >>= 1; - /* do four dot Fourier transform */ + /* do four dot Fourier transform */ - twMod2 = 2; - twMod3 = 4; - twMod4 = 6; + twMod2 = 2; + twMod3 = 4; + twMod4 = 6; + /* TOP */ + p1ap3_0 = p1[0] + p3[0]; + p1sp3_0 = p1[0] - p3[0]; + p1ap3_1 = p1[1] + p3[1]; + p1sp3_1 = p1[1] - p3[1]; + + /* col 2 */ + t2[0] = p1sp3_0 + p2[1] - p4[1]; + t2[1] = p1sp3_1 - p2[0] + p4[0]; + /* col 3 */ + t3[0] = p1ap3_0 - p2[0] - p4[0]; + t3[1] = p1ap3_1 - p2[1] - p4[1]; + /* col 4 */ + t4[0] = p1sp3_0 - p2[1] + p4[1]; + t4[1] = p1sp3_1 + p2[0] - p4[0]; + /* col 1 */ + *p1++ = p1ap3_0 + p2[0] + p4[0]; + *p1++ = p1ap3_1 + p2[1] + p4[1]; + + /* Twiddle factors are ones */ + *p2++ = t2[0]; + *p2++ = t2[1]; + *p3++ = t3[0]; + *p3++ = t3[1]; + *p4++ = t4[0]; + *p4++ = t4[1]; + + tw2 += twMod2; + tw3 += twMod3; + tw4 += twMod4; + + for (l = (L - 2) >> 1; l > 0; l--) { /* TOP */ p1ap3_0 = p1[0] + p3[0]; p1sp3_0 = p1[0] - p3[0]; p1ap3_1 = p1[1] + p3[1]; p1sp3_1 = p1[1] - p3[1]; - /* col 2 */ t2[0] = p1sp3_0 + p2[1] - p4[1]; t2[1] = p1sp3_1 - p2[0] + p4[0]; @@ -353,159 +384,37 @@ void arm_cfft_radix8by4_f32 (arm_cfft_instance_f32 * S, float32_t * p1) /* col 4 */ t4[0] = p1sp3_0 - p2[1] + p4[1]; t4[1] = p1sp3_1 + p2[0] - p4[0]; - /* col 1 */ + /* col 1 - top */ *p1++ = p1ap3_0 + p2[0] + p4[0]; *p1++ = p1ap3_1 + p2[1] + p4[1]; - /* Twiddle factors are ones */ - *p2++ = t2[0]; - *p2++ = t2[1]; - *p3++ = t3[0]; - *p3++ = t3[1]; - *p4++ = t4[0]; - *p4++ = t4[1]; - - tw2 += twMod2; - tw3 += twMod3; - tw4 += twMod4; - - for (l = (L - 2) >> 1; l > 0; l-- ) - { - /* TOP */ - p1ap3_0 = p1[0] + p3[0]; - p1sp3_0 = p1[0] - p3[0]; - p1ap3_1 = p1[1] + p3[1]; - p1sp3_1 = p1[1] - p3[1]; - /* col 2 */ - t2[0] = p1sp3_0 + p2[1] - p4[1]; - t2[1] = p1sp3_1 - p2[0] + p4[0]; - /* col 3 */ - t3[0] = p1ap3_0 - p2[0] - p4[0]; - t3[1] = p1ap3_1 - p2[1] - p4[1]; - /* col 4 */ - t4[0] = p1sp3_0 - p2[1] + p4[1]; - t4[1] = p1sp3_1 + p2[0] - p4[0]; - /* col 1 - top */ - *p1++ = p1ap3_0 + p2[0] + p4[0]; - *p1++ = p1ap3_1 + p2[1] + p4[1]; - - /* BOTTOM */ - p1ap3_1 = pEnd1[-1] + pEnd3[-1]; - p1sp3_1 = pEnd1[-1] - pEnd3[-1]; - p1ap3_0 = pEnd1[ 0] + pEnd3[0]; - p1sp3_0 = pEnd1[ 0] - pEnd3[0]; - /* col 2 */ - t2[2] = pEnd2[0] - pEnd4[0] + p1sp3_1; - t2[3] = pEnd1[0] - pEnd3[0] - pEnd2[-1] + pEnd4[-1]; - /* col 3 */ - t3[2] = p1ap3_1 - pEnd2[-1] - pEnd4[-1]; - t3[3] = p1ap3_0 - pEnd2[ 0] - pEnd4[ 0]; - /* col 4 */ - t4[2] = pEnd2[ 0] - pEnd4[ 0] - p1sp3_1; - t4[3] = pEnd4[-1] - pEnd2[-1] - p1sp3_0; - /* col 1 - Bottom */ - *pEnd1-- = p1ap3_0 + pEnd2[ 0] + pEnd4[ 0]; - *pEnd1-- = p1ap3_1 + pEnd2[-1] + pEnd4[-1]; - - /* COL 2 */ - /* read twiddle factors */ - twR = *tw2++; - twI = *tw2++; - /* multiply by twiddle factors */ - /* let Z1 = a + i(b), Z2 = c + i(d) */ - /* => Z1 * Z2 = (a*c - b*d) + i(b*c + a*d) */ - - /* Top */ - m0 = t2[0] * twR; - m1 = t2[1] * twI; - m2 = t2[1] * twR; - m3 = t2[0] * twI; - - *p2++ = m0 + m1; - *p2++ = m2 - m3; - /* use vertical symmetry col 2 */ - /* 0.9997 - 0.0245i <==> 0.0245 - 0.9997i */ - /* Bottom */ - m0 = t2[3] * twI; - m1 = t2[2] * twR; - m2 = t2[2] * twI; - m3 = t2[3] * twR; - - *pEnd2-- = m0 - m1; - *pEnd2-- = m2 + m3; - - /* COL 3 */ - twR = tw3[0]; - twI = tw3[1]; - tw3 += twMod3; - /* Top */ - m0 = t3[0] * twR; - m1 = t3[1] * twI; - m2 = t3[1] * twR; - m3 = t3[0] * twI; - - *p3++ = m0 + m1; - *p3++ = m2 - m3; - /* use vertical symmetry col 3 */ - /* 0.9988 - 0.0491i <==> -0.9988 - 0.0491i */ - /* Bottom */ - m0 = -t3[3] * twR; - m1 = t3[2] * twI; - m2 = t3[2] * twR; - m3 = t3[3] * twI; - - *pEnd3-- = m0 - m1; - *pEnd3-- = m3 - m2; - - /* COL 4 */ - twR = tw4[0]; - twI = tw4[1]; - tw4 += twMod4; - /* Top */ - m0 = t4[0] * twR; - m1 = t4[1] * twI; - m2 = t4[1] * twR; - m3 = t4[0] * twI; - - *p4++ = m0 + m1; - *p4++ = m2 - m3; - /* use vertical symmetry col 4 */ - /* 0.9973 - 0.0736i <==> -0.0736 + 0.9973i */ - /* Bottom */ - m0 = t4[3] * twI; - m1 = t4[2] * twR; - m2 = t4[2] * twI; - m3 = t4[3] * twR; - - *pEnd4-- = m0 - m1; - *pEnd4-- = m2 + m3; - } - - /* MIDDLE */ - /* Twiddle factors are */ - /* 1.0000 0.7071-0.7071i -1.0000i -0.7071-0.7071i */ - p1ap3_0 = p1[0] + p3[0]; - p1sp3_0 = p1[0] - p3[0]; - p1ap3_1 = p1[1] + p3[1]; - p1sp3_1 = p1[1] - p3[1]; - + /* BOTTOM */ + p1ap3_1 = pEnd1[-1] + pEnd3[-1]; + p1sp3_1 = pEnd1[-1] - pEnd3[-1]; + p1ap3_0 = pEnd1[0] + pEnd3[0]; + p1sp3_0 = pEnd1[0] - pEnd3[0]; /* col 2 */ - t2[0] = p1sp3_0 + p2[1] - p4[1]; - t2[1] = p1sp3_1 - p2[0] + p4[0]; + t2[2] = pEnd2[0] - pEnd4[0] + p1sp3_1; + t2[3] = pEnd1[0] - pEnd3[0] - pEnd2[-1] + pEnd4[-1]; /* col 3 */ - t3[0] = p1ap3_0 - p2[0] - p4[0]; - t3[1] = p1ap3_1 - p2[1] - p4[1]; + t3[2] = p1ap3_1 - pEnd2[-1] - pEnd4[-1]; + t3[3] = p1ap3_0 - pEnd2[0] - pEnd4[0]; /* col 4 */ - t4[0] = p1sp3_0 - p2[1] + p4[1]; - t4[1] = p1sp3_1 + p2[0] - p4[0]; - /* col 1 - Top */ - *p1++ = p1ap3_0 + p2[0] + p4[0]; - *p1++ = p1ap3_1 + p2[1] + p4[1]; + t4[2] = pEnd2[0] - pEnd4[0] - p1sp3_1; + t4[3] = pEnd4[-1] - pEnd2[-1] - p1sp3_0; + /* col 1 - Bottom */ + *pEnd1-- = p1ap3_0 + pEnd2[0] + pEnd4[0]; + *pEnd1-- = p1ap3_1 + pEnd2[-1] + pEnd4[-1]; /* COL 2 */ - twR = tw2[0]; - twI = tw2[1]; + /* read twiddle factors */ + twR = *tw2++; + twI = *tw2++; + /* multiply by twiddle factors */ + /* let Z1 = a + i(b), Z2 = c + i(d) */ + /* => Z1 * Z2 = (a*c - b*d) + i(b*c + a*d) */ + /* Top */ m0 = t2[0] * twR; m1 = t2[1] * twI; m2 = t2[1] * twR; @@ -513,10 +422,22 @@ void arm_cfft_radix8by4_f32 (arm_cfft_instance_f32 * S, float32_t * p1) *p2++ = m0 + m1; *p2++ = m2 - m3; + /* use vertical symmetry col 2 */ + /* 0.9997 - 0.0245i <==> 0.0245 - 0.9997i */ + /* Bottom */ + m0 = t2[3] * twI; + m1 = t2[2] * twR; + m2 = t2[2] * twI; + m3 = t2[3] * twR; + + *pEnd2-- = m0 - m1; + *pEnd2-- = m2 + m3; + /* COL 3 */ twR = tw3[0]; twI = tw3[1]; - + tw3 += twMod3; + /* Top */ m0 = t3[0] * twR; m1 = t3[1] * twI; m2 = t3[1] * twR; @@ -524,10 +445,22 @@ void arm_cfft_radix8by4_f32 (arm_cfft_instance_f32 * S, float32_t * p1) *p3++ = m0 + m1; *p3++ = m2 - m3; + /* use vertical symmetry col 3 */ + /* 0.9988 - 0.0491i <==> -0.9988 - 0.0491i */ + /* Bottom */ + m0 = -t3[3] * twR; + m1 = t3[2] * twI; + m2 = t3[2] * twR; + m3 = t3[3] * twI; + + *pEnd3-- = m0 - m1; + *pEnd3-- = m3 - m2; + /* COL 4 */ twR = tw4[0]; twI = tw4[1]; - + tw4 += twMod4; + /* Top */ m0 = t4[0] * twR; m1 = t4[1] * twI; m2 = t4[1] * twR; @@ -535,18 +468,84 @@ void arm_cfft_radix8by4_f32 (arm_cfft_instance_f32 * S, float32_t * p1) *p4++ = m0 + m1; *p4++ = m2 - m3; + /* use vertical symmetry col 4 */ + /* 0.9973 - 0.0736i <==> -0.0736 + 0.9973i */ + /* Bottom */ + m0 = t4[3] * twI; + m1 = t4[2] * twR; + m2 = t4[2] * twI; + m3 = t4[3] * twR; - /* first col */ - arm_radix8_butterfly_f32 (pCol1, L, (float32_t *) S->pTwiddle, 4U); + *pEnd4-- = m0 - m1; + *pEnd4-- = m2 + m3; + } - /* second col */ - arm_radix8_butterfly_f32 (pCol2, L, (float32_t *) S->pTwiddle, 4U); + /* MIDDLE */ + /* Twiddle factors are */ + /* 1.0000 0.7071-0.7071i -1.0000i -0.7071-0.7071i */ + p1ap3_0 = p1[0] + p3[0]; + p1sp3_0 = p1[0] - p3[0]; + p1ap3_1 = p1[1] + p3[1]; + p1sp3_1 = p1[1] - p3[1]; - /* third col */ - arm_radix8_butterfly_f32 (pCol3, L, (float32_t *) S->pTwiddle, 4U); + /* col 2 */ + t2[0] = p1sp3_0 + p2[1] - p4[1]; + t2[1] = p1sp3_1 - p2[0] + p4[0]; + /* col 3 */ + t3[0] = p1ap3_0 - p2[0] - p4[0]; + t3[1] = p1ap3_1 - p2[1] - p4[1]; + /* col 4 */ + t4[0] = p1sp3_0 - p2[1] + p4[1]; + t4[1] = p1sp3_1 + p2[0] - p4[0]; + /* col 1 - Top */ + *p1++ = p1ap3_0 + p2[0] + p4[0]; + *p1++ = p1ap3_1 + p2[1] + p4[1]; - /* fourth col */ - arm_radix8_butterfly_f32 (pCol4, L, (float32_t *) S->pTwiddle, 4U); + /* COL 2 */ + twR = tw2[0]; + twI = tw2[1]; + + m0 = t2[0] * twR; + m1 = t2[1] * twI; + m2 = t2[1] * twR; + m3 = t2[0] * twI; + + *p2++ = m0 + m1; + *p2++ = m2 - m3; + /* COL 3 */ + twR = tw3[0]; + twI = tw3[1]; + + m0 = t3[0] * twR; + m1 = t3[1] * twI; + m2 = t3[1] * twR; + m3 = t3[0] * twI; + + *p3++ = m0 + m1; + *p3++ = m2 - m3; + /* COL 4 */ + twR = tw4[0]; + twI = tw4[1]; + + m0 = t4[0] * twR; + m1 = t4[1] * twI; + m2 = t4[1] * twR; + m3 = t4[0] * twI; + + *p4++ = m0 + m1; + *p4++ = m2 - m3; + + /* first col */ + arm_radix8_butterfly_f32(pCol1, L, (float32_t *)S->pTwiddle, 4U); + + /* second col */ + arm_radix8_butterfly_f32(pCol2, L, (float32_t *)S->pTwiddle, 4U); + + /* third col */ + arm_radix8_butterfly_f32(pCol3, L, (float32_t *)S->pTwiddle, 4U); + + /* fourth col */ + arm_radix8_butterfly_f32(pCol4, L, (float32_t *)S->pTwiddle, 4U); } /** @@ -556,69 +555,63 @@ void arm_cfft_radix8by4_f32 (arm_cfft_instance_f32 * S, float32_t * p1) /** @brief Processing function for the floating-point complex FFT. - @param[in] S points to an instance of the floating-point CFFT structure - @param[in,out] p1 points to the complex data buffer of size 2*fftLen. Processing occurs in-place + @param[in] S points to an instance of the floating-point CFFT + structure + @param[in,out] p1 points to the complex data buffer of size + 2*fftLen. Processing occurs in-place @param[in] ifftFlag flag that selects transform direction - value = 0: forward transform - value = 1: inverse transform - @param[in] bitReverseFlag flag that enables / disables bit reversal of output + @param[in] bitReverseFlag flag that enables / disables bit reversal of + output - value = 0: disables bit reversal of output - value = 1: enables bit reversal of output @return none */ -void arm_cfft_f32( - const arm_cfft_instance_f32 * S, - float32_t * p1, - uint8_t ifftFlag, - uint8_t bitReverseFlag) -{ - uint32_t L = S->fftLen, l; - float32_t invL, * pSrc; +void arm_cfft_f32(const arm_cfft_instance_f32 *S, float32_t *p1, + uint8_t ifftFlag, uint8_t bitReverseFlag) { + uint32_t L = S->fftLen, l; + float32_t invL, *pSrc; - if (ifftFlag == 1U) - { + if (ifftFlag == 1U) { /* Conjugate input data */ pSrc = p1 + 1; - for (l = 0; l < L; l++) - { + for (l = 0; l < L; l++) { *pSrc = -*pSrc; pSrc += 2; } } - switch (L) - { + switch (L) { case 16: case 128: case 1024: - arm_cfft_radix8by2_f32 ( (arm_cfft_instance_f32 *) S, p1); + arm_cfft_radix8by2_f32((arm_cfft_instance_f32 *)S, p1); break; case 32: case 256: case 2048: - arm_cfft_radix8by4_f32 ( (arm_cfft_instance_f32 *) S, p1); + arm_cfft_radix8by4_f32((arm_cfft_instance_f32 *)S, p1); break; case 64: case 512: case 4096: - arm_radix8_butterfly_f32 ( p1, L, (float32_t *) S->pTwiddle, 1); + arm_radix8_butterfly_f32(p1, L, (float32_t *)S->pTwiddle, 1); break; } - if ( bitReverseFlag ) - arm_bitreversal_32 ((uint32_t*) p1, S->bitRevLength, S->pBitRevTable); + if (bitReverseFlag) + arm_bitreversal_32((uint32_t *)p1, S->bitRevLength, S->pBitRevTable); - if (ifftFlag == 1U) - { + if (ifftFlag == 1U) { invL = 1.0f / (float32_t)L; /* Conjugate and scale output data */ pSrc = p1; - for (l= 0; l < L; l++) - { - *pSrc++ *= invL ; - *pSrc = -(*pSrc) * invL; + for (l = 0; l < L; l++) { + *pSrc++ *= invL; + *pSrc = -(*pSrc) * invL; pSrc++; } } diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_q15.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_q15.c index 28ad1e1..96a4e7c 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_q15.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_q15.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_q15.c - * Description: Combined Radix Decimation in Q15 Frequency CFFT processing function + * Description: Combined Radix Decimation in Q15 Frequency CFFT processing + * function * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -28,32 +29,21 @@ #include "arm_math.h" -extern void arm_radix4_butterfly_q15( - q15_t * pSrc, - uint32_t fftLen, - const q15_t * pCoef, - uint32_t twidCoefModifier); +extern void arm_radix4_butterfly_q15(q15_t *pSrc, uint32_t fftLen, + const q15_t *pCoef, + uint32_t twidCoefModifier); -extern void arm_radix4_butterfly_inverse_q15( - q15_t * pSrc, - uint32_t fftLen, - const q15_t * pCoef, - uint32_t twidCoefModifier); +extern void arm_radix4_butterfly_inverse_q15(q15_t *pSrc, uint32_t fftLen, + const q15_t *pCoef, + uint32_t twidCoefModifier); -extern void arm_bitreversal_16( - uint16_t * pSrc, - const uint16_t bitRevLen, - const uint16_t * pBitRevTable); +extern void arm_bitreversal_16(uint16_t *pSrc, const uint16_t bitRevLen, + const uint16_t *pBitRevTable); -void arm_cfft_radix4by2_q15( - q15_t * pSrc, - uint32_t fftLen, - const q15_t * pCoef); +void arm_cfft_radix4by2_q15(q15_t *pSrc, uint32_t fftLen, const q15_t *pCoef); -void arm_cfft_radix4by2_inverse_q15( - q15_t * pSrc, - uint32_t fftLen, - const q15_t * pCoef); +void arm_cfft_radix4by2_inverse_q15(q15_t *pSrc, uint32_t fftLen, + const q15_t *pCoef); /** @ingroup groupTransforms @@ -67,266 +57,245 @@ void arm_cfft_radix4by2_inverse_q15( /** @brief Processing function for Q15 complex FFT. @param[in] S points to an instance of Q15 CFFT structure - @param[in,out] p1 points to the complex data buffer of size 2*fftLen. Processing occurs in-place + @param[in,out] p1 points to the complex data buffer of size + 2*fftLen. Processing occurs in-place @param[in] ifftFlag flag that selects transform direction - value = 0: forward transform - value = 1: inverse transform - @param[in] bitReverseFlag flag that enables / disables bit reversal of output + @param[in] bitReverseFlag flag that enables / disables bit reversal of + output - value = 0: disables bit reversal of output - value = 1: enables bit reversal of output @return none */ -void arm_cfft_q15( - const arm_cfft_instance_q15 * S, - q15_t * p1, - uint8_t ifftFlag, - uint8_t bitReverseFlag) -{ +void arm_cfft_q15(const arm_cfft_instance_q15 *S, q15_t *p1, uint8_t ifftFlag, + uint8_t bitReverseFlag) { uint32_t L = S->fftLen; - if (ifftFlag == 1U) - { - switch (L) - { - case 16: - case 64: - case 256: - case 1024: - case 4096: - arm_radix4_butterfly_inverse_q15 ( p1, L, (q15_t*)S->pTwiddle, 1 ); - break; + if (ifftFlag == 1U) { + switch (L) { + case 16: + case 64: + case 256: + case 1024: + case 4096: + arm_radix4_butterfly_inverse_q15(p1, L, (q15_t *)S->pTwiddle, 1); + break; - case 32: - case 128: - case 512: - case 2048: - arm_cfft_radix4by2_inverse_q15 ( p1, L, S->pTwiddle ); - break; - } - } - else - { - switch (L) - { - case 16: - case 64: - case 256: - case 1024: - case 4096: - arm_radix4_butterfly_q15 ( p1, L, (q15_t*)S->pTwiddle, 1 ); - break; + case 32: + case 128: + case 512: + case 2048: + arm_cfft_radix4by2_inverse_q15(p1, L, S->pTwiddle); + break; + } + } else { + switch (L) { + case 16: + case 64: + case 256: + case 1024: + case 4096: + arm_radix4_butterfly_q15(p1, L, (q15_t *)S->pTwiddle, 1); + break; - case 32: - case 128: - case 512: - case 2048: - arm_cfft_radix4by2_q15 ( p1, L, S->pTwiddle ); - break; - } + case 32: + case 128: + case 512: + case 2048: + arm_cfft_radix4by2_q15(p1, L, S->pTwiddle); + break; + } } - if ( bitReverseFlag ) - arm_bitreversal_16 ((uint16_t*) p1, S->bitRevLength, S->pBitRevTable); + if (bitReverseFlag) + arm_bitreversal_16((uint16_t *)p1, S->bitRevLength, S->pBitRevTable); } /** @} end of ComplexFFT group */ -void arm_cfft_radix4by2_q15( - q15_t * pSrc, - uint32_t fftLen, - const q15_t * pCoef) -{ - uint32_t i; - uint32_t n2; - q15_t p0, p1, p2, p3; -#if defined (ARM_MATH_DSP) - q31_t T, S, R; - q31_t coeff, out1, out2; +void arm_cfft_radix4by2_q15(q15_t *pSrc, uint32_t fftLen, const q15_t *pCoef) { + uint32_t i; + uint32_t n2; + q15_t p0, p1, p2, p3; +#if defined(ARM_MATH_DSP) + q31_t T, S, R; + q31_t coeff, out1, out2; const q15_t *pC = pCoef; - q15_t *pSi = pSrc; - q15_t *pSl = pSrc + fftLen; + q15_t *pSi = pSrc; + q15_t *pSl = pSrc + fftLen; #else - uint32_t l; - q15_t xt, yt, cosVal, sinVal; + uint32_t l; + q15_t xt, yt, cosVal, sinVal; #endif n2 = fftLen >> 1U; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) - for (i = n2; i > 0; i--) - { - coeff = read_q15x2_ia ((q15_t **) &pC); + for (i = n2; i > 0; i--) { + coeff = read_q15x2_ia((q15_t **)&pC); - T = read_q15x2 (pSi); - T = __SHADD16(T, 0); /* this is just a SIMD arithmetic shift right by 1 */ + T = read_q15x2(pSi); + T = __SHADD16(T, 0); /* this is just a SIMD arithmetic shift right by 1 */ - S = read_q15x2 (pSl); - S = __SHADD16(S, 0); /* this is just a SIMD arithmetic shift right by 1 */ + S = read_q15x2(pSl); + S = __SHADD16(S, 0); /* this is just a SIMD arithmetic shift right by 1 */ - R = __QSUB16(T, S); + R = __QSUB16(T, S); - write_q15x2_ia (&pSi, __SHADD16(T, S)); + write_q15x2_ia(&pSi, __SHADD16(T, S)); #ifndef ARM_MATH_BIG_ENDIAN - out1 = __SMUAD(coeff, R) >> 16U; - out2 = __SMUSDX(coeff, R); + out1 = __SMUAD(coeff, R) >> 16U; + out2 = __SMUSDX(coeff, R); #else - out1 = __SMUSDX(R, coeff) >> 16U; - out2 = __SMUAD(coeff, R); + out1 = __SMUSDX(R, coeff) >> 16U; + out2 = __SMUAD(coeff, R); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ - write_q15x2_ia (&pSl, (q31_t) ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2_ia(&pSl, (q31_t)((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); } #else /* #if defined (ARM_MATH_DSP) */ - for (i = 0; i < n2; i++) - { - cosVal = pCoef[2 * i]; - sinVal = pCoef[2 * i + 1]; + for (i = 0; i < n2; i++) { + cosVal = pCoef[2 * i]; + sinVal = pCoef[2 * i + 1]; - l = i + n2; + l = i + n2; - xt = (pSrc[2 * i] >> 1U) - (pSrc[2 * l] >> 1U); - pSrc[2 * i] = ((pSrc[2 * i] >> 1U) + (pSrc[2 * l] >> 1U)) >> 1U; + xt = (pSrc[2 * i] >> 1U) - (pSrc[2 * l] >> 1U); + pSrc[2 * i] = ((pSrc[2 * i] >> 1U) + (pSrc[2 * l] >> 1U)) >> 1U; - yt = (pSrc[2 * i + 1] >> 1U) - (pSrc[2 * l + 1] >> 1U); - pSrc[2 * i + 1] = ((pSrc[2 * l + 1] >> 1U) + (pSrc[2 * i + 1] >> 1U)) >> 1U; + yt = (pSrc[2 * i + 1] >> 1U) - (pSrc[2 * l + 1] >> 1U); + pSrc[2 * i + 1] = ((pSrc[2 * l + 1] >> 1U) + (pSrc[2 * i + 1] >> 1U)) >> 1U; - pSrc[2 * l] = (((int16_t) (((q31_t) xt * cosVal) >> 16U)) + - ((int16_t) (((q31_t) yt * sinVal) >> 16U)) ); + pSrc[2 * l] = (((int16_t)(((q31_t)xt * cosVal) >> 16U)) + + ((int16_t)(((q31_t)yt * sinVal) >> 16U))); - pSrc[2 * l + 1] = (((int16_t) (((q31_t) yt * cosVal) >> 16U)) - - ((int16_t) (((q31_t) xt * sinVal) >> 16U)) ); + pSrc[2 * l + 1] = (((int16_t)(((q31_t)yt * cosVal) >> 16U)) - + ((int16_t)(((q31_t)xt * sinVal) >> 16U))); } #endif /* #if defined (ARM_MATH_DSP) */ /* first col */ - arm_radix4_butterfly_q15( pSrc, n2, (q15_t*)pCoef, 2U); + arm_radix4_butterfly_q15(pSrc, n2, (q15_t *)pCoef, 2U); /* second col */ - arm_radix4_butterfly_q15( pSrc + fftLen, n2, (q15_t*)pCoef, 2U); + arm_radix4_butterfly_q15(pSrc + fftLen, n2, (q15_t *)pCoef, 2U); n2 = fftLen >> 1U; - for (i = 0; i < n2; i++) - { - p0 = pSrc[4 * i + 0]; - p1 = pSrc[4 * i + 1]; - p2 = pSrc[4 * i + 2]; - p3 = pSrc[4 * i + 3]; + for (i = 0; i < n2; i++) { + p0 = pSrc[4 * i + 0]; + p1 = pSrc[4 * i + 1]; + p2 = pSrc[4 * i + 2]; + p3 = pSrc[4 * i + 3]; - p0 <<= 1U; - p1 <<= 1U; - p2 <<= 1U; - p3 <<= 1U; + p0 <<= 1U; + p1 <<= 1U; + p2 <<= 1U; + p3 <<= 1U; - pSrc[4 * i + 0] = p0; - pSrc[4 * i + 1] = p1; - pSrc[4 * i + 2] = p2; - pSrc[4 * i + 3] = p3; + pSrc[4 * i + 0] = p0; + pSrc[4 * i + 1] = p1; + pSrc[4 * i + 2] = p2; + pSrc[4 * i + 3] = p3; } - } -void arm_cfft_radix4by2_inverse_q15( - q15_t * pSrc, - uint32_t fftLen, - const q15_t * pCoef) -{ - uint32_t i; - uint32_t n2; - q15_t p0, p1, p2, p3; -#if defined (ARM_MATH_DSP) - q31_t T, S, R; - q31_t coeff, out1, out2; +void arm_cfft_radix4by2_inverse_q15(q15_t *pSrc, uint32_t fftLen, + const q15_t *pCoef) { + uint32_t i; + uint32_t n2; + q15_t p0, p1, p2, p3; +#if defined(ARM_MATH_DSP) + q31_t T, S, R; + q31_t coeff, out1, out2; const q15_t *pC = pCoef; - q15_t *pSi = pSrc; - q15_t *pSl = pSrc + fftLen; + q15_t *pSi = pSrc; + q15_t *pSl = pSrc + fftLen; #else - uint32_t l; - q15_t xt, yt, cosVal, sinVal; + uint32_t l; + q15_t xt, yt, cosVal, sinVal; #endif n2 = fftLen >> 1U; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) - for (i = n2; i > 0; i--) - { - coeff = read_q15x2_ia ((q15_t **) &pC); + for (i = n2; i > 0; i--) { + coeff = read_q15x2_ia((q15_t **)&pC); - T = read_q15x2 (pSi); - T = __SHADD16(T, 0); /* this is just a SIMD arithmetic shift right by 1 */ + T = read_q15x2(pSi); + T = __SHADD16(T, 0); /* this is just a SIMD arithmetic shift right by 1 */ - S = read_q15x2 (pSl); - S = __SHADD16(S, 0); /* this is just a SIMD arithmetic shift right by 1 */ + S = read_q15x2(pSl); + S = __SHADD16(S, 0); /* this is just a SIMD arithmetic shift right by 1 */ - R = __QSUB16(T, S); + R = __QSUB16(T, S); - write_q15x2_ia (&pSi, __SHADD16(T, S)); + write_q15x2_ia(&pSi, __SHADD16(T, S)); #ifndef ARM_MATH_BIG_ENDIAN - out1 = __SMUSD(coeff, R) >> 16U; - out2 = __SMUADX(coeff, R); + out1 = __SMUSD(coeff, R) >> 16U; + out2 = __SMUADX(coeff, R); #else - out1 = __SMUADX(R, coeff) >> 16U; - out2 = __SMUSD(__QSUB(0, coeff), R); + out1 = __SMUADX(R, coeff) >> 16U; + out2 = __SMUSD(__QSUB(0, coeff), R); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ - write_q15x2_ia (&pSl, (q31_t) ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2_ia(&pSl, (q31_t)((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); } #else /* #if defined (ARM_MATH_DSP) */ - for (i = 0; i < n2; i++) - { - cosVal = pCoef[2 * i]; - sinVal = pCoef[2 * i + 1]; + for (i = 0; i < n2; i++) { + cosVal = pCoef[2 * i]; + sinVal = pCoef[2 * i + 1]; - l = i + n2; + l = i + n2; - xt = (pSrc[2 * i] >> 1U) - (pSrc[2 * l] >> 1U); - pSrc[2 * i] = ((pSrc[2 * i] >> 1U) + (pSrc[2 * l] >> 1U)) >> 1U; + xt = (pSrc[2 * i] >> 1U) - (pSrc[2 * l] >> 1U); + pSrc[2 * i] = ((pSrc[2 * i] >> 1U) + (pSrc[2 * l] >> 1U)) >> 1U; - yt = (pSrc[2 * i + 1] >> 1U) - (pSrc[2 * l + 1] >> 1U); - pSrc[2 * i + 1] = ((pSrc[2 * l + 1] >> 1U) + (pSrc[2 * i + 1] >> 1U)) >> 1U; + yt = (pSrc[2 * i + 1] >> 1U) - (pSrc[2 * l + 1] >> 1U); + pSrc[2 * i + 1] = ((pSrc[2 * l + 1] >> 1U) + (pSrc[2 * i + 1] >> 1U)) >> 1U; - pSrc[2 * l] = (((int16_t) (((q31_t) xt * cosVal) >> 16U)) - - ((int16_t) (((q31_t) yt * sinVal) >> 16U)) ); + pSrc[2 * l] = (((int16_t)(((q31_t)xt * cosVal) >> 16U)) - + ((int16_t)(((q31_t)yt * sinVal) >> 16U))); - pSrc[2 * l + 1] = (((int16_t) (((q31_t) yt * cosVal) >> 16U)) + - ((int16_t) (((q31_t) xt * sinVal) >> 16U)) ); + pSrc[2 * l + 1] = (((int16_t)(((q31_t)yt * cosVal) >> 16U)) + + ((int16_t)(((q31_t)xt * sinVal) >> 16U))); } #endif /* #if defined (ARM_MATH_DSP) */ /* first col */ - arm_radix4_butterfly_inverse_q15( pSrc, n2, (q15_t*)pCoef, 2U); + arm_radix4_butterfly_inverse_q15(pSrc, n2, (q15_t *)pCoef, 2U); /* second col */ - arm_radix4_butterfly_inverse_q15( pSrc + fftLen, n2, (q15_t*)pCoef, 2U); + arm_radix4_butterfly_inverse_q15(pSrc + fftLen, n2, (q15_t *)pCoef, 2U); n2 = fftLen >> 1U; - for (i = 0; i < n2; i++) - { - p0 = pSrc[4 * i + 0]; - p1 = pSrc[4 * i + 1]; - p2 = pSrc[4 * i + 2]; - p3 = pSrc[4 * i + 3]; + for (i = 0; i < n2; i++) { + p0 = pSrc[4 * i + 0]; + p1 = pSrc[4 * i + 1]; + p2 = pSrc[4 * i + 2]; + p3 = pSrc[4 * i + 3]; - p0 <<= 1U; - p1 <<= 1U; - p2 <<= 1U; - p3 <<= 1U; + p0 <<= 1U; + p1 <<= 1U; + p2 <<= 1U; + p3 <<= 1U; - pSrc[4 * i + 0] = p0; - pSrc[4 * i + 1] = p1; - pSrc[4 * i + 2] = p2; - pSrc[4 * i + 3] = p3; + pSrc[4 * i + 0] = p0; + pSrc[4 * i + 1] = p1; + pSrc[4 * i + 2] = p2; + pSrc[4 * i + 3] = p3; } } diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_q31.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_q31.c index 701ac95..4392331 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_q31.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_q31.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_q31.c - * Description: Combined Radix Decimation in Frequency CFFT fixed point processing function + * Description: Combined Radix Decimation in Frequency CFFT fixed point + * processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -28,32 +29,21 @@ #include "arm_math.h" -extern void arm_radix4_butterfly_q31( - q31_t * pSrc, - uint32_t fftLen, - const q31_t * pCoef, - uint32_t twidCoefModifier); +extern void arm_radix4_butterfly_q31(q31_t *pSrc, uint32_t fftLen, + const q31_t *pCoef, + uint32_t twidCoefModifier); -extern void arm_radix4_butterfly_inverse_q31( - q31_t * pSrc, - uint32_t fftLen, - const q31_t * pCoef, - uint32_t twidCoefModifier); +extern void arm_radix4_butterfly_inverse_q31(q31_t *pSrc, uint32_t fftLen, + const q31_t *pCoef, + uint32_t twidCoefModifier); -extern void arm_bitreversal_32( - uint32_t * pSrc, - const uint16_t bitRevLen, - const uint16_t * pBitRevTable); +extern void arm_bitreversal_32(uint32_t *pSrc, const uint16_t bitRevLen, + const uint16_t *pBitRevTable); -void arm_cfft_radix4by2_q31( - q31_t * pSrc, - uint32_t fftLen, - const q31_t * pCoef); +void arm_cfft_radix4by2_q31(q31_t *pSrc, uint32_t fftLen, const q31_t *pCoef); -void arm_cfft_radix4by2_inverse_q31( - q31_t * pSrc, - uint32_t fftLen, - const q31_t * pCoef); +void arm_cfft_radix4by2_inverse_q31(q31_t *pSrc, uint32_t fftLen, + const q31_t *pCoef); /** @ingroup groupTransforms @@ -66,189 +56,171 @@ void arm_cfft_radix4by2_inverse_q31( /** @brief Processing function for the Q31 complex FFT. - @param[in] S points to an instance of the fixed-point CFFT structure - @param[in,out] p1 points to the complex data buffer of size 2*fftLen. Processing occurs in-place + @param[in] S points to an instance of the fixed-point CFFT + structure + @param[in,out] p1 points to the complex data buffer of size + 2*fftLen. Processing occurs in-place @param[in] ifftFlag flag that selects transform direction - value = 0: forward transform - value = 1: inverse transform - @param[in] bitReverseFlag flag that enables / disables bit reversal of output + @param[in] bitReverseFlag flag that enables / disables bit reversal of + output - value = 0: disables bit reversal of output - value = 1: enables bit reversal of output @return none */ -void arm_cfft_q31( - const arm_cfft_instance_q31 * S, - q31_t * p1, - uint8_t ifftFlag, - uint8_t bitReverseFlag) -{ +void arm_cfft_q31(const arm_cfft_instance_q31 *S, q31_t *p1, uint8_t ifftFlag, + uint8_t bitReverseFlag) { uint32_t L = S->fftLen; - if (ifftFlag == 1U) - { - switch (L) - { - case 16: - case 64: - case 256: - case 1024: - case 4096: - arm_radix4_butterfly_inverse_q31 ( p1, L, (q31_t*)S->pTwiddle, 1 ); - break; + if (ifftFlag == 1U) { + switch (L) { + case 16: + case 64: + case 256: + case 1024: + case 4096: + arm_radix4_butterfly_inverse_q31(p1, L, (q31_t *)S->pTwiddle, 1); + break; - case 32: - case 128: - case 512: - case 2048: - arm_cfft_radix4by2_inverse_q31 ( p1, L, S->pTwiddle ); - break; - } - } - else - { - switch (L) - { - case 16: - case 64: - case 256: - case 1024: - case 4096: - arm_radix4_butterfly_q31 ( p1, L, (q31_t*)S->pTwiddle, 1 ); - break; + case 32: + case 128: + case 512: + case 2048: + arm_cfft_radix4by2_inverse_q31(p1, L, S->pTwiddle); + break; + } + } else { + switch (L) { + case 16: + case 64: + case 256: + case 1024: + case 4096: + arm_radix4_butterfly_q31(p1, L, (q31_t *)S->pTwiddle, 1); + break; - case 32: - case 128: - case 512: - case 2048: - arm_cfft_radix4by2_q31 ( p1, L, S->pTwiddle ); - break; - } + case 32: + case 128: + case 512: + case 2048: + arm_cfft_radix4by2_q31(p1, L, S->pTwiddle); + break; + } } - if ( bitReverseFlag ) - arm_bitreversal_32 ((uint32_t*) p1, S->bitRevLength, S->pBitRevTable); + if (bitReverseFlag) + arm_bitreversal_32((uint32_t *)p1, S->bitRevLength, S->pBitRevTable); } /** @} end of ComplexFFT group */ -void arm_cfft_radix4by2_q31( - q31_t * pSrc, - uint32_t fftLen, - const q31_t * pCoef) -{ - uint32_t i, l; - uint32_t n2; - q31_t xt, yt, cosVal, sinVal; - q31_t p0, p1; - - n2 = fftLen >> 1U; - for (i = 0; i < n2; i++) - { - cosVal = pCoef[2 * i]; - sinVal = pCoef[2 * i + 1]; - - l = i + n2; - - xt = (pSrc[2 * i] >> 2U) - (pSrc[2 * l] >> 2U); - pSrc[2 * i] = (pSrc[2 * i] >> 2U) + (pSrc[2 * l] >> 2U); - - yt = (pSrc[2 * i + 1] >> 2U) - (pSrc[2 * l + 1] >> 2U); - pSrc[2 * i + 1] = (pSrc[2 * l + 1] >> 2U) + (pSrc[2 * i + 1] >> 2U); - - mult_32x32_keep32_R(p0, xt, cosVal); - mult_32x32_keep32_R(p1, yt, cosVal); - multAcc_32x32_keep32_R(p0, yt, sinVal); - multSub_32x32_keep32_R(p1, xt, sinVal); - - pSrc[2 * l] = p0 << 1; - pSrc[2 * l + 1] = p1 << 1; - } - - /* first col */ - arm_radix4_butterfly_q31 (pSrc, n2, (q31_t*)pCoef, 2U); - - /* second col */ - arm_radix4_butterfly_q31 (pSrc + fftLen, n2, (q31_t*)pCoef, 2U); - - n2 = fftLen >> 1U; - for (i = 0; i < n2; i++) - { - p0 = pSrc[4 * i + 0]; - p1 = pSrc[4 * i + 1]; - xt = pSrc[4 * i + 2]; - yt = pSrc[4 * i + 3]; - - p0 <<= 1U; - p1 <<= 1U; - xt <<= 1U; - yt <<= 1U; - - pSrc[4 * i + 0] = p0; - pSrc[4 * i + 1] = p1; - pSrc[4 * i + 2] = xt; - pSrc[4 * i + 3] = yt; - } - -} - -void arm_cfft_radix4by2_inverse_q31( - q31_t * pSrc, - uint32_t fftLen, - const q31_t * pCoef) -{ +void arm_cfft_radix4by2_q31(q31_t *pSrc, uint32_t fftLen, const q31_t *pCoef) { uint32_t i, l; uint32_t n2; q31_t xt, yt, cosVal, sinVal; q31_t p0, p1; n2 = fftLen >> 1U; - for (i = 0; i < n2; i++) - { - cosVal = pCoef[2 * i]; - sinVal = pCoef[2 * i + 1]; + for (i = 0; i < n2; i++) { + cosVal = pCoef[2 * i]; + sinVal = pCoef[2 * i + 1]; - l = i + n2; + l = i + n2; - xt = (pSrc[2 * i] >> 2U) - (pSrc[2 * l] >> 2U); - pSrc[2 * i] = (pSrc[2 * i] >> 2U) + (pSrc[2 * l] >> 2U); + xt = (pSrc[2 * i] >> 2U) - (pSrc[2 * l] >> 2U); + pSrc[2 * i] = (pSrc[2 * i] >> 2U) + (pSrc[2 * l] >> 2U); - yt = (pSrc[2 * i + 1] >> 2U) - (pSrc[2 * l + 1] >> 2U); - pSrc[2 * i + 1] = (pSrc[2 * l + 1] >> 2U) + (pSrc[2 * i + 1] >> 2U); + yt = (pSrc[2 * i + 1] >> 2U) - (pSrc[2 * l + 1] >> 2U); + pSrc[2 * i + 1] = (pSrc[2 * l + 1] >> 2U) + (pSrc[2 * i + 1] >> 2U); - mult_32x32_keep32_R(p0, xt, cosVal); - mult_32x32_keep32_R(p1, yt, cosVal); - multSub_32x32_keep32_R(p0, yt, sinVal); - multAcc_32x32_keep32_R(p1, xt, sinVal); + mult_32x32_keep32_R(p0, xt, cosVal); + mult_32x32_keep32_R(p1, yt, cosVal); + multAcc_32x32_keep32_R(p0, yt, sinVal); + multSub_32x32_keep32_R(p1, xt, sinVal); - pSrc[2 * l] = p0 << 1U; - pSrc[2 * l + 1] = p1 << 1U; + pSrc[2 * l] = p0 << 1; + pSrc[2 * l + 1] = p1 << 1; } /* first col */ - arm_radix4_butterfly_inverse_q31( pSrc, n2, (q31_t*)pCoef, 2U); + arm_radix4_butterfly_q31(pSrc, n2, (q31_t *)pCoef, 2U); /* second col */ - arm_radix4_butterfly_inverse_q31( pSrc + fftLen, n2, (q31_t*)pCoef, 2U); + arm_radix4_butterfly_q31(pSrc + fftLen, n2, (q31_t *)pCoef, 2U); n2 = fftLen >> 1U; - for (i = 0; i < n2; i++) - { - p0 = pSrc[4 * i + 0]; - p1 = pSrc[4 * i + 1]; - xt = pSrc[4 * i + 2]; - yt = pSrc[4 * i + 3]; + for (i = 0; i < n2; i++) { + p0 = pSrc[4 * i + 0]; + p1 = pSrc[4 * i + 1]; + xt = pSrc[4 * i + 2]; + yt = pSrc[4 * i + 3]; - p0 <<= 1U; - p1 <<= 1U; - xt <<= 1U; - yt <<= 1U; + p0 <<= 1U; + p1 <<= 1U; + xt <<= 1U; + yt <<= 1U; - pSrc[4 * i + 0] = p0; - pSrc[4 * i + 1] = p1; - pSrc[4 * i + 2] = xt; - pSrc[4 * i + 3] = yt; + pSrc[4 * i + 0] = p0; + pSrc[4 * i + 1] = p1; + pSrc[4 * i + 2] = xt; + pSrc[4 * i + 3] = yt; + } +} + +void arm_cfft_radix4by2_inverse_q31(q31_t *pSrc, uint32_t fftLen, + const q31_t *pCoef) { + uint32_t i, l; + uint32_t n2; + q31_t xt, yt, cosVal, sinVal; + q31_t p0, p1; + + n2 = fftLen >> 1U; + for (i = 0; i < n2; i++) { + cosVal = pCoef[2 * i]; + sinVal = pCoef[2 * i + 1]; + + l = i + n2; + + xt = (pSrc[2 * i] >> 2U) - (pSrc[2 * l] >> 2U); + pSrc[2 * i] = (pSrc[2 * i] >> 2U) + (pSrc[2 * l] >> 2U); + + yt = (pSrc[2 * i + 1] >> 2U) - (pSrc[2 * l + 1] >> 2U); + pSrc[2 * i + 1] = (pSrc[2 * l + 1] >> 2U) + (pSrc[2 * i + 1] >> 2U); + + mult_32x32_keep32_R(p0, xt, cosVal); + mult_32x32_keep32_R(p1, yt, cosVal); + multSub_32x32_keep32_R(p0, yt, sinVal); + multAcc_32x32_keep32_R(p1, xt, sinVal); + + pSrc[2 * l] = p0 << 1U; + pSrc[2 * l + 1] = p1 << 1U; + } + + /* first col */ + arm_radix4_butterfly_inverse_q31(pSrc, n2, (q31_t *)pCoef, 2U); + + /* second col */ + arm_radix4_butterfly_inverse_q31(pSrc + fftLen, n2, (q31_t *)pCoef, 2U); + + n2 = fftLen >> 1U; + for (i = 0; i < n2; i++) { + p0 = pSrc[4 * i + 0]; + p1 = pSrc[4 * i + 1]; + xt = pSrc[4 * i + 2]; + yt = pSrc[4 * i + 3]; + + p0 <<= 1U; + p1 <<= 1U; + xt <<= 1U; + yt <<= 1U; + + pSrc[4 * i + 0] = p0; + pSrc[4 * i + 1] = p1; + pSrc[4 * i + 2] = xt; + pSrc[4 * i + 3] = yt; } } diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_f32.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_f32.c index f75e329..8c18178 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_f32.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_f32.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_radix2_f32.c - * Description: Radix-2 Decimation in Frequency CFFT & CIFFT Floating point processing function + * Description: Radix-2 Decimation in Frequency CFFT & CIFFT Floating point + * processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -28,24 +29,18 @@ #include "arm_math.h" -void arm_radix2_butterfly_f32( - float32_t * pSrc, - uint32_t fftLen, - const float32_t * pCoef, - uint16_t twidCoefModifier); +void arm_radix2_butterfly_f32(float32_t *pSrc, uint32_t fftLen, + const float32_t *pCoef, + uint16_t twidCoefModifier); -void arm_radix2_butterfly_inverse_f32( - float32_t * pSrc, - uint32_t fftLen, - const float32_t * pCoef, - uint16_t twidCoefModifier, - float32_t onebyfftLen); +void arm_radix2_butterfly_inverse_f32(float32_t *pSrc, uint32_t fftLen, + const float32_t *pCoef, + uint16_t twidCoefModifier, + float32_t onebyfftLen); -extern void arm_bitreversal_f32( - float32_t * pSrc, - uint16_t fftSize, - uint16_t bitRevFactor, - const uint16_t * pBitRevTab); +extern void arm_bitreversal_f32(float32_t *pSrc, uint16_t fftSize, + uint16_t bitRevFactor, + const uint16_t *pBitRevTab); /** @ingroup groupTransforms @@ -58,413 +53,379 @@ extern void arm_bitreversal_f32( /** @brief Radix-2 CFFT/CIFFT. - @deprecated Do not use this function. It has been superseded by \ref arm_cfft_f32 and will be removed in the future - @param[in] S points to an instance of the floating-point Radix-2 CFFT/CIFFT structure - @param[in,out] pSrc points to the complex data buffer of size 2*fftLen. Processing occurs in-place + @deprecated Do not use this function. It has been superseded by \ref + arm_cfft_f32 and will be removed in the future + @param[in] S points to an instance of the floating-point Radix-2 + CFFT/CIFFT structure + @param[in,out] pSrc points to the complex data buffer of size + 2*fftLen. Processing occurs in-place @return none */ -void arm_cfft_radix2_f32( -const arm_cfft_radix2_instance_f32 * S, - float32_t * pSrc) -{ +void arm_cfft_radix2_f32(const arm_cfft_radix2_instance_f32 *S, + float32_t *pSrc) { - if (S->ifftFlag == 1U) - { - /* Complex IFFT radix-2 */ - arm_radix2_butterfly_inverse_f32(pSrc, S->fftLen, S->pTwiddle, - S->twidCoefModifier, S->onebyfftLen); - } - else - { - /* Complex FFT radix-2 */ - arm_radix2_butterfly_f32(pSrc, S->fftLen, S->pTwiddle, - S->twidCoefModifier); - } - - if (S->bitReverseFlag == 1U) - { - /* Bit Reversal */ - arm_bitreversal_f32(pSrc, S->fftLen, S->bitRevFactor, S->pBitRevTable); - } + if (S->ifftFlag == 1U) { + /* Complex IFFT radix-2 */ + arm_radix2_butterfly_inverse_f32(pSrc, S->fftLen, S->pTwiddle, + S->twidCoefModifier, S->onebyfftLen); + } else { + /* Complex FFT radix-2 */ + arm_radix2_butterfly_f32(pSrc, S->fftLen, S->pTwiddle, S->twidCoefModifier); + } + if (S->bitReverseFlag == 1U) { + /* Bit Reversal */ + arm_bitreversal_f32(pSrc, S->fftLen, S->bitRevFactor, S->pBitRevTable); + } } - /** @} end of ComplexFFT group */ - - /* ---------------------------------------------------------------------- ** Internal helper function used by the FFTs ** ------------------------------------------------------------------- */ /** brief Core function for the floating-point CFFT butterfly process. - param[in,out] pSrc points to in-place buffer of floating-point data type - param[in] fftLen length of the FFT - param[in] pCoef points to twiddle coefficient buffer - param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table - return none + param[in,out] pSrc points to in-place buffer of floating-point + data type param[in] fftLen length of the FFT param[in] pCoef + points to twiddle coefficient buffer param[in] twidCoefModifier twiddle + coefficient modifier that supports different size FFTs with the same twiddle + factor table return none */ -void arm_radix2_butterfly_f32( - float32_t * pSrc, - uint32_t fftLen, - const float32_t * pCoef, - uint16_t twidCoefModifier) -{ +void arm_radix2_butterfly_f32(float32_t *pSrc, uint32_t fftLen, + const float32_t *pCoef, + uint16_t twidCoefModifier) { - uint32_t i, j, k, l; - uint32_t n1, n2, ia; - float32_t xt, yt, cosVal, sinVal; - float32_t p0, p1, p2, p3; - float32_t a0, a1; + uint32_t i, j, k, l; + uint32_t n1, n2, ia; + float32_t xt, yt, cosVal, sinVal; + float32_t p0, p1, p2, p3; + float32_t a0, a1; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) - /* Initializations for the first stage */ - n2 = fftLen >> 1; - ia = 0; - i = 0; + /* Initializations for the first stage */ + n2 = fftLen >> 1; + ia = 0; + i = 0; - // loop for groups - for (k = n2; k > 0; k--) - { - cosVal = pCoef[ia * 2]; - sinVal = pCoef[(ia * 2) + 1]; + // loop for groups + for (k = n2; k > 0; k--) { + cosVal = pCoef[ia * 2]; + sinVal = pCoef[(ia * 2) + 1]; - /* Twiddle coefficients index modifier */ - ia += twidCoefModifier; + /* Twiddle coefficients index modifier */ + ia += twidCoefModifier; - /* index calculation for the input as, */ - /* pSrc[i + 0], pSrc[i + fftLen/1] */ - l = i + n2; + /* index calculation for the input as, */ + /* pSrc[i + 0], pSrc[i + fftLen/1] */ + l = i + n2; - /* Butterfly implementation */ - a0 = pSrc[2 * i] + pSrc[2 * l]; - xt = pSrc[2 * i] - pSrc[2 * l]; + /* Butterfly implementation */ + a0 = pSrc[2 * i] + pSrc[2 * l]; + xt = pSrc[2 * i] - pSrc[2 * l]; - yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; - a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; + yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; + a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; - p0 = xt * cosVal; - p1 = yt * sinVal; - p2 = yt * cosVal; - p3 = xt * sinVal; + p0 = xt * cosVal; + p1 = yt * sinVal; + p2 = yt * cosVal; + p3 = xt * sinVal; - pSrc[2 * i] = a0; - pSrc[2 * i + 1] = a1; + pSrc[2 * i] = a0; + pSrc[2 * i + 1] = a1; - pSrc[2 * l] = p0 + p1; - pSrc[2 * l + 1] = p2 - p3; + pSrc[2 * l] = p0 + p1; + pSrc[2 * l + 1] = p2 - p3; - i++; - } // groups loop end + i++; + } // groups loop end - twidCoefModifier <<= 1U; + twidCoefModifier <<= 1U; - // loop for stage - for (k = n2; k > 2; k = k >> 1) - { - n1 = n2; - n2 = n2 >> 1; - ia = 0; + // loop for stage + for (k = n2; k > 2; k = k >> 1) { + n1 = n2; + n2 = n2 >> 1; + ia = 0; - // loop for groups - j = 0; - do - { - cosVal = pCoef[ia * 2]; - sinVal = pCoef[(ia * 2) + 1]; - ia += twidCoefModifier; - - // loop for butterfly - i = j; - do - { - l = i + n2; - a0 = pSrc[2 * i] + pSrc[2 * l]; - xt = pSrc[2 * i] - pSrc[2 * l]; - - yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; - a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; - - p0 = xt * cosVal; - p1 = yt * sinVal; - p2 = yt * cosVal; - p3 = xt * sinVal; - - pSrc[2 * i] = a0; - pSrc[2 * i + 1] = a1; - - pSrc[2 * l] = p0 + p1; - pSrc[2 * l + 1] = p2 - p3; - - i += n1; - } while ( i < fftLen ); // butterfly loop end - j++; - } while ( j < n2); // groups loop end - twidCoefModifier <<= 1U; - } // stages loop end - - // loop for butterfly - for (i = 0; i < fftLen; i += 2) - { - a0 = pSrc[2 * i] + pSrc[2 * i + 2]; - xt = pSrc[2 * i] - pSrc[2 * i + 2]; - - yt = pSrc[2 * i + 1] - pSrc[2 * i + 3]; - a1 = pSrc[2 * i + 3] + pSrc[2 * i + 1]; - - pSrc[2 * i] = a0; - pSrc[2 * i + 1] = a1; - pSrc[2 * i + 2] = xt; - pSrc[2 * i + 3] = yt; - } // groups loop end - -#else /* #if defined (ARM_MATH_DSP) */ - - n2 = fftLen; - - // loop for stage - for (k = fftLen; k > 1; k = k >> 1) - { - n1 = n2; - n2 = n2 >> 1; - ia = 0; - - // loop for groups - j = 0; - do - { - cosVal = pCoef[ia * 2]; - sinVal = pCoef[(ia * 2) + 1]; - ia += twidCoefModifier; - - // loop for butterfly - i = j; - do - { - l = i + n2; - a0 = pSrc[2 * i] + pSrc[2 * l]; - xt = pSrc[2 * i] - pSrc[2 * l]; - - yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; - a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; - - p0 = xt * cosVal; - p1 = yt * sinVal; - p2 = yt * cosVal; - p3 = xt * sinVal; - - pSrc[2 * i] = a0; - pSrc[2 * i + 1] = a1; - - pSrc[2 * l] = p0 + p1; - pSrc[2 * l + 1] = p2 - p3; - - i += n1; - } while (i < fftLen); - j++; - } while (j < n2); - twidCoefModifier <<= 1U; - } - -#endif /* #if defined (ARM_MATH_DSP) */ - -} - - -void arm_radix2_butterfly_inverse_f32( - float32_t * pSrc, - uint32_t fftLen, - const float32_t * pCoef, - uint16_t twidCoefModifier, - float32_t onebyfftLen) -{ - - uint32_t i, j, k, l; - uint32_t n1, n2, ia; - float32_t xt, yt, cosVal, sinVal; - float32_t p0, p1, p2, p3; - float32_t a0, a1; - -#if defined (ARM_MATH_DSP) - - n2 = fftLen >> 1; - ia = 0; - - // loop for groups - for (i = 0; i < n2; i++) - { + // loop for groups + j = 0; + do { cosVal = pCoef[ia * 2]; sinVal = pCoef[(ia * 2) + 1]; ia += twidCoefModifier; - l = i + n2; - a0 = pSrc[2 * i] + pSrc[2 * l]; - xt = pSrc[2 * i] - pSrc[2 * l]; + // loop for butterfly + i = j; + do { + l = i + n2; + a0 = pSrc[2 * i] + pSrc[2 * l]; + xt = pSrc[2 * i] - pSrc[2 * l]; - yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; - a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; + yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; + a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; - p0 = xt * cosVal; - p1 = yt * sinVal; - p2 = yt * cosVal; - p3 = xt * sinVal; + p0 = xt * cosVal; + p1 = yt * sinVal; + p2 = yt * cosVal; + p3 = xt * sinVal; - pSrc[2 * i] = a0; - pSrc[2 * i + 1] = a1; + pSrc[2 * i] = a0; + pSrc[2 * i + 1] = a1; - pSrc[2 * l] = p0 - p1; - pSrc[2 * l + 1] = p2 + p3; - } // groups loop end + pSrc[2 * l] = p0 + p1; + pSrc[2 * l + 1] = p2 - p3; - twidCoefModifier <<= 1U; + i += n1; + } while (i < fftLen); // butterfly loop end + j++; + } while (j < n2); // groups loop end + twidCoefModifier <<= 1U; + } // stages loop end - // loop for stage - for (k = fftLen / 2; k > 2; k = k >> 1) - { - n1 = n2; - n2 = n2 >> 1; - ia = 0; + // loop for butterfly + for (i = 0; i < fftLen; i += 2) { + a0 = pSrc[2 * i] + pSrc[2 * i + 2]; + xt = pSrc[2 * i] - pSrc[2 * i + 2]; - // loop for groups - j = 0; - do - { - cosVal = pCoef[ia * 2]; - sinVal = pCoef[(ia * 2) + 1]; - ia += twidCoefModifier; + yt = pSrc[2 * i + 1] - pSrc[2 * i + 3]; + a1 = pSrc[2 * i + 3] + pSrc[2 * i + 1]; - // loop for butterfly - i = j; - do - { - l = i + n2; - a0 = pSrc[2 * i] + pSrc[2 * l]; - xt = pSrc[2 * i] - pSrc[2 * l]; - - yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; - a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; - - p0 = xt * cosVal; - p1 = yt * sinVal; - p2 = yt * cosVal; - p3 = xt * sinVal; - - pSrc[2 * i] = a0; - pSrc[2 * i + 1] = a1; - - pSrc[2 * l] = p0 - p1; - pSrc[2 * l + 1] = p2 + p3; - - i += n1; - } while ( i < fftLen ); // butterfly loop end - j++; - } while (j < n2); // groups loop end - - twidCoefModifier <<= 1U; - } // stages loop end - - // loop for butterfly - for (i = 0; i < fftLen; i += 2) - { - a0 = pSrc[2 * i] + pSrc[2 * i + 2]; - xt = pSrc[2 * i] - pSrc[2 * i + 2]; - - a1 = pSrc[2 * i + 3] + pSrc[2 * i + 1]; - yt = pSrc[2 * i + 1] - pSrc[2 * i + 3]; - - p0 = a0 * onebyfftLen; - p2 = xt * onebyfftLen; - p1 = a1 * onebyfftLen; - p3 = yt * onebyfftLen; - - pSrc[2 * i] = p0; - pSrc[2 * i + 1] = p1; - pSrc[2 * i + 2] = p2; - pSrc[2 * i + 3] = p3; - } // butterfly loop end + pSrc[2 * i] = a0; + pSrc[2 * i + 1] = a1; + pSrc[2 * i + 2] = xt; + pSrc[2 * i + 3] = yt; + } // groups loop end #else /* #if defined (ARM_MATH_DSP) */ - n2 = fftLen; + n2 = fftLen; - // loop for stage - for (k = fftLen; k > 2; k = k >> 1) - { - n1 = n2; - n2 = n2 >> 1; - ia = 0; + // loop for stage + for (k = fftLen; k > 1; k = k >> 1) { + n1 = n2; + n2 = n2 >> 1; + ia = 0; - // loop for groups - j = 0; - do - { - cosVal = pCoef[ia * 2]; - sinVal = pCoef[(ia * 2) + 1]; - ia = ia + twidCoefModifier; + // loop for groups + j = 0; + do { + cosVal = pCoef[ia * 2]; + sinVal = pCoef[(ia * 2) + 1]; + ia += twidCoefModifier; - // loop for butterfly - i = j; - do - { - l = i + n2; - a0 = pSrc[2 * i] + pSrc[2 * l]; - xt = pSrc[2 * i] - pSrc[2 * l]; + // loop for butterfly + i = j; + do { + l = i + n2; + a0 = pSrc[2 * i] + pSrc[2 * l]; + xt = pSrc[2 * i] - pSrc[2 * l]; - yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; - a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; + yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; + a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; - p0 = xt * cosVal; - p1 = yt * sinVal; - p2 = yt * cosVal; - p3 = xt * sinVal; + p0 = xt * cosVal; + p1 = yt * sinVal; + p2 = yt * cosVal; + p3 = xt * sinVal; - pSrc[2 * i] = a0; - pSrc[2 * i + 1] = a1; + pSrc[2 * i] = a0; + pSrc[2 * i + 1] = a1; - pSrc[2 * l] = p0 - p1; - pSrc[2 * l + 1] = p2 + p3; + pSrc[2 * l] = p0 + p1; + pSrc[2 * l + 1] = p2 - p3; - i += n1; - } while ( i < fftLen ); // butterfly loop end - j++; - } while ( j < n2 ); // groups loop end - - twidCoefModifier = twidCoefModifier << 1U; - } // stages loop end - - n1 = n2; - n2 = n2 >> 1; - - // loop for butterfly - for (i = 0; i < fftLen; i += n1) - { - l = i + n2; - - a0 = pSrc[2 * i] + pSrc[2 * l]; - xt = pSrc[2 * i] - pSrc[2 * l]; - - a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; - yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; - - p0 = a0 * onebyfftLen; - p2 = xt * onebyfftLen; - p1 = a1 * onebyfftLen; - p3 = yt * onebyfftLen; - - pSrc[2 * i] = p0; - pSrc[2 * l] = p2; - - pSrc[2 * i + 1] = p1; - pSrc[2 * l + 1] = p3; - } // butterfly loop end + i += n1; + } while (i < fftLen); + j++; + } while (j < n2); + twidCoefModifier <<= 1U; + } + +#endif /* #if defined (ARM_MATH_DSP) */ +} + +void arm_radix2_butterfly_inverse_f32(float32_t *pSrc, uint32_t fftLen, + const float32_t *pCoef, + uint16_t twidCoefModifier, + float32_t onebyfftLen) { + + uint32_t i, j, k, l; + uint32_t n1, n2, ia; + float32_t xt, yt, cosVal, sinVal; + float32_t p0, p1, p2, p3; + float32_t a0, a1; + +#if defined(ARM_MATH_DSP) + + n2 = fftLen >> 1; + ia = 0; + + // loop for groups + for (i = 0; i < n2; i++) { + cosVal = pCoef[ia * 2]; + sinVal = pCoef[(ia * 2) + 1]; + ia += twidCoefModifier; + + l = i + n2; + a0 = pSrc[2 * i] + pSrc[2 * l]; + xt = pSrc[2 * i] - pSrc[2 * l]; + + yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; + a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; + + p0 = xt * cosVal; + p1 = yt * sinVal; + p2 = yt * cosVal; + p3 = xt * sinVal; + + pSrc[2 * i] = a0; + pSrc[2 * i + 1] = a1; + + pSrc[2 * l] = p0 - p1; + pSrc[2 * l + 1] = p2 + p3; + } // groups loop end + + twidCoefModifier <<= 1U; + + // loop for stage + for (k = fftLen / 2; k > 2; k = k >> 1) { + n1 = n2; + n2 = n2 >> 1; + ia = 0; + + // loop for groups + j = 0; + do { + cosVal = pCoef[ia * 2]; + sinVal = pCoef[(ia * 2) + 1]; + ia += twidCoefModifier; + + // loop for butterfly + i = j; + do { + l = i + n2; + a0 = pSrc[2 * i] + pSrc[2 * l]; + xt = pSrc[2 * i] - pSrc[2 * l]; + + yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; + a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; + + p0 = xt * cosVal; + p1 = yt * sinVal; + p2 = yt * cosVal; + p3 = xt * sinVal; + + pSrc[2 * i] = a0; + pSrc[2 * i + 1] = a1; + + pSrc[2 * l] = p0 - p1; + pSrc[2 * l + 1] = p2 + p3; + + i += n1; + } while (i < fftLen); // butterfly loop end + j++; + } while (j < n2); // groups loop end + + twidCoefModifier <<= 1U; + } // stages loop end + + // loop for butterfly + for (i = 0; i < fftLen; i += 2) { + a0 = pSrc[2 * i] + pSrc[2 * i + 2]; + xt = pSrc[2 * i] - pSrc[2 * i + 2]; + + a1 = pSrc[2 * i + 3] + pSrc[2 * i + 1]; + yt = pSrc[2 * i + 1] - pSrc[2 * i + 3]; + + p0 = a0 * onebyfftLen; + p2 = xt * onebyfftLen; + p1 = a1 * onebyfftLen; + p3 = yt * onebyfftLen; + + pSrc[2 * i] = p0; + pSrc[2 * i + 1] = p1; + pSrc[2 * i + 2] = p2; + pSrc[2 * i + 3] = p3; + } // butterfly loop end + +#else /* #if defined (ARM_MATH_DSP) */ + + n2 = fftLen; + + // loop for stage + for (k = fftLen; k > 2; k = k >> 1) { + n1 = n2; + n2 = n2 >> 1; + ia = 0; + + // loop for groups + j = 0; + do { + cosVal = pCoef[ia * 2]; + sinVal = pCoef[(ia * 2) + 1]; + ia = ia + twidCoefModifier; + + // loop for butterfly + i = j; + do { + l = i + n2; + a0 = pSrc[2 * i] + pSrc[2 * l]; + xt = pSrc[2 * i] - pSrc[2 * l]; + + yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; + a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; + + p0 = xt * cosVal; + p1 = yt * sinVal; + p2 = yt * cosVal; + p3 = xt * sinVal; + + pSrc[2 * i] = a0; + pSrc[2 * i + 1] = a1; + + pSrc[2 * l] = p0 - p1; + pSrc[2 * l + 1] = p2 + p3; + + i += n1; + } while (i < fftLen); // butterfly loop end + j++; + } while (j < n2); // groups loop end + + twidCoefModifier = twidCoefModifier << 1U; + } // stages loop end + + n1 = n2; + n2 = n2 >> 1; + + // loop for butterfly + for (i = 0; i < fftLen; i += n1) { + l = i + n2; + + a0 = pSrc[2 * i] + pSrc[2 * l]; + xt = pSrc[2 * i] - pSrc[2 * l]; + + a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; + yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; + + p0 = a0 * onebyfftLen; + p2 = xt * onebyfftLen; + p1 = a1 * onebyfftLen; + p3 = yt * onebyfftLen; + + pSrc[2 * i] = p0; + pSrc[2 * l] = p2; + + pSrc[2 * i + 1] = p1; + pSrc[2 * l + 1] = p3; + } // butterfly loop end #endif /* #if defined (ARM_MATH_DSP) */ - } diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_init_f32.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_init_f32.c index 417ad91..c0d1c59 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_init_f32.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_init_f32.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_radix2_init_f32.c - * Description: Radix-2 Decimation in Frequency Floating-point CFFT & CIFFT Initialization function + * Description: Radix-2 Decimation in Frequency Floating-point CFFT & CIFFT + * Initialization function * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -26,8 +27,8 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @ingroup groupTransforms @@ -40,37 +41,42 @@ /** @brief Initialization function for the floating-point CFFT/CIFFT. - @deprecated Do not use this function. It has been superseded by \ref arm_cfft_f32 and will be removed in the future. - @param[in,out] S points to an instance of the floating-point CFFT/CIFFT structure + @deprecated Do not use this function. It has been superseded by \ref + arm_cfft_f32 and will be removed in the future. + @param[in,out] S points to an instance of the floating-point + CFFT/CIFFT structure @param[in] fftLen length of the FFT @param[in] ifftFlag flag that selects transform direction - value = 0: forward transform - value = 1: inverse transform - @param[in] bitReverseFlag flag that enables / disables bit reversal of output + @param[in] bitReverseFlag flag that enables / disables bit reversal of + output - value = 0: disables bit reversal of output - value = 1: enables bit reversal of output @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : fftLen is not a supported length + - \ref ARM_MATH_ARGUMENT_ERROR : fftLen is not a + supported length @par Details - The parameter ifftFlag controls whether a forward or inverse transform is computed. - Set(=1) ifftFlag for calculation of CIFFT otherwise CFFT is calculated + The parameter ifftFlag controls whether a + forward or inverse transform is computed. Set(=1) ifftFlag for calculation of + CIFFT otherwise CFFT is calculated @par - The parameter bitReverseFlag controls whether output is in normal order or bit reversed order. - Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order. + The parameter bitReverseFlag controls whether + output is in normal order or bit reversed order. Set(=1) bitReverseFlag for + output to be in normal order otherwise output is in bit reversed order. @par - The parameter fftLen Specifies length of CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024. + The parameter fftLen Specifies length of + CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024. @par - This Function also initializes Twiddle factor table pointer and Bit reversal table pointer. + This Function also initializes Twiddle factor table pointer + and Bit reversal table pointer. */ -arm_status arm_cfft_radix2_init_f32( - arm_cfft_radix2_instance_f32 * S, - uint16_t fftLen, - uint8_t ifftFlag, - uint8_t bitReverseFlag) -{ +arm_status arm_cfft_radix2_init_f32(arm_cfft_radix2_instance_f32 *S, + uint16_t fftLen, uint8_t ifftFlag, + uint8_t bitReverseFlag) { /* Initialise the default arm status */ arm_status status = ARM_MATH_SUCCESS; @@ -78,7 +84,7 @@ arm_status arm_cfft_radix2_init_f32( S->fftLen = fftLen; /* Initialise the Twiddle coefficient pointer */ - S->pTwiddle = (float32_t *) twiddleCoef; + S->pTwiddle = (float32_t *)twiddleCoef; /* Initialise the Flag for selection of CFFT or CIFFT */ S->ifftFlag = ifftFlag; @@ -87,8 +93,7 @@ arm_status arm_cfft_radix2_init_f32( S->bitReverseFlag = bitReverseFlag; /* Initializations of structure parameters depending on the FFT length */ - switch (S->fftLen) - { + switch (S->fftLen) { case 4096U: /* Initializations of structure parameters for 4096 point FFT */ @@ -98,7 +103,7 @@ arm_status arm_cfft_radix2_init_f32( /* Initialise the bit reversal table modifier */ S->bitRevFactor = 1U; /* Initialise the bit reversal table pointer */ - S->pBitRevTable = (uint16_t *) armBitRevTable; + S->pBitRevTable = (uint16_t *)armBitRevTable; /* Initialise the 1/fftLen Value */ S->onebyfftLen = 0.000244140625; break; @@ -111,7 +116,7 @@ arm_status arm_cfft_radix2_init_f32( /* Initialise the bit reversal table modifier */ S->bitRevFactor = 2U; /* Initialise the bit reversal table pointer */ - S->pBitRevTable = (uint16_t *) & armBitRevTable[1]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[1]; /* Initialise the 1/fftLen Value */ S->onebyfftLen = 0.00048828125; break; @@ -124,7 +129,7 @@ arm_status arm_cfft_radix2_init_f32( /* Initialise the bit reversal table modifier */ S->bitRevFactor = 4U; /* Initialise the bit reversal table pointer */ - S->pBitRevTable = (uint16_t *) & armBitRevTable[3]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[3]; /* Initialise the 1/fftLen Value */ S->onebyfftLen = 0.0009765625f; break; @@ -137,7 +142,7 @@ arm_status arm_cfft_radix2_init_f32( /* Initialise the bit reversal table modifier */ S->bitRevFactor = 8U; /* Initialise the bit reversal table pointer */ - S->pBitRevTable = (uint16_t *) & armBitRevTable[7]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[7]; /* Initialise the 1/fftLen Value */ S->onebyfftLen = 0.001953125; break; @@ -146,7 +151,7 @@ arm_status arm_cfft_radix2_init_f32( /* Initializations of structure parameters for 256 point FFT */ S->twidCoefModifier = 16U; S->bitRevFactor = 16U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[15]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[15]; S->onebyfftLen = 0.00390625f; break; @@ -154,7 +159,7 @@ arm_status arm_cfft_radix2_init_f32( /* Initializations of structure parameters for 128 point FFT */ S->twidCoefModifier = 32U; S->bitRevFactor = 32U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[31]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[31]; S->onebyfftLen = 0.0078125; break; @@ -162,7 +167,7 @@ arm_status arm_cfft_radix2_init_f32( /* Initializations of structure parameters for 64 point FFT */ S->twidCoefModifier = 64U; S->bitRevFactor = 64U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[63]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[63]; S->onebyfftLen = 0.015625f; break; @@ -170,7 +175,7 @@ arm_status arm_cfft_radix2_init_f32( /* Initializations of structure parameters for 64 point FFT */ S->twidCoefModifier = 128U; S->bitRevFactor = 128U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[127]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[127]; S->onebyfftLen = 0.03125; break; @@ -178,11 +183,10 @@ arm_status arm_cfft_radix2_init_f32( /* Initializations of structure parameters for 16 point FFT */ S->twidCoefModifier = 256U; S->bitRevFactor = 256U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[255]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[255]; S->onebyfftLen = 0.0625f; break; - default: /* Reporting argument error if fftSize is not valid value */ status = ARM_MATH_ARGUMENT_ERROR; diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_init_q15.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_init_q15.c index 3d865d0..3fe5c0a 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_init_q15.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_init_q15.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_radix2_init_q15.c - * Description: Radix-2 Decimation in Frequency Q15 FFT & IFFT initialization function + * Description: Radix-2 Decimation in Frequency Q15 FFT & IFFT initialization + * function * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -26,14 +27,13 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @ingroup groupTransforms */ - /** @addtogroup ComplexFFT @{ @@ -41,37 +41,42 @@ /** @brief Initialization function for the Q15 CFFT/CIFFT. - @deprecated Do not use this function. It has been superseded by \ref arm_cfft_q15 and will be removed - @param[in,out] S points to an instance of the Q15 CFFT/CIFFT structure. + @deprecated Do not use this function. It has been superseded + by \ref arm_cfft_q15 and will be removed + @param[in,out] S points to an instance of the Q15 CFFT/CIFFT + structure. @param[in] fftLen length of the FFT. @param[in] ifftFlag flag that selects transform direction - value = 0: forward transform - value = 1: inverse transform - @param[in] bitReverseFlag flag that enables / disables bit reversal of output + @param[in] bitReverseFlag flag that enables / disables bit reversal of + output - value = 0: disables bit reversal of output - value = 1: enables bit reversal of output @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : fftLen is not a supported length + - \ref ARM_MATH_ARGUMENT_ERROR : fftLen is not a + supported length @par Details - The parameter ifftFlag controls whether a forward or inverse transform is computed. - Set(=1) ifftFlag for calculation of CIFFT otherwise CFFT is calculated + The parameter ifftFlag controls whether a + forward or inverse transform is computed. Set(=1) ifftFlag for calculation of + CIFFT otherwise CFFT is calculated @par - The parameter bitReverseFlag controls whether output is in normal order or bit reversed order. - Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order. + The parameter bitReverseFlag controls whether + output is in normal order or bit reversed order. Set(=1) bitReverseFlag for + output to be in normal order otherwise output is in bit reversed order. @par - The parameter fftLen Specifies length of CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024. + The parameter fftLen Specifies length of + CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024. @par - This Function also initializes Twiddle factor table pointer and Bit reversal table pointer. + This Function also initializes Twiddle factor table pointer + and Bit reversal table pointer. */ -arm_status arm_cfft_radix2_init_q15( - arm_cfft_radix2_instance_q15 * S, - uint16_t fftLen, - uint8_t ifftFlag, - uint8_t bitReverseFlag) -{ +arm_status arm_cfft_radix2_init_q15(arm_cfft_radix2_instance_q15 *S, + uint16_t fftLen, uint8_t ifftFlag, + uint8_t bitReverseFlag) { /* Initialise the default arm status */ arm_status status = ARM_MATH_SUCCESS; @@ -79,15 +84,14 @@ arm_status arm_cfft_radix2_init_q15( S->fftLen = fftLen; /* Initialise the Twiddle coefficient pointer */ - S->pTwiddle = (q15_t *) twiddleCoef_4096_q15; + S->pTwiddle = (q15_t *)twiddleCoef_4096_q15; /* Initialise the Flag for selection of CFFT or CIFFT */ S->ifftFlag = ifftFlag; /* Initialise the Flag for calculation Bit reversal or not */ S->bitReverseFlag = bitReverseFlag; /* Initializations of structure parameters depending on the FFT length */ - switch (S->fftLen) - { + switch (S->fftLen) { case 4096U: /* Initializations of structure parameters for 4096 point FFT */ @@ -96,7 +100,7 @@ arm_status arm_cfft_radix2_init_q15( /* Initialise the bit reversal table modifier */ S->bitRevFactor = 1U; /* Initialise the bit reversal table pointer */ - S->pBitRevTable = (uint16_t *) armBitRevTable; + S->pBitRevTable = (uint16_t *)armBitRevTable; break; @@ -108,7 +112,7 @@ arm_status arm_cfft_radix2_init_q15( /* Initialise the bit reversal table modifier */ S->bitRevFactor = 2U; /* Initialise the bit reversal table pointer */ - S->pBitRevTable = (uint16_t *) & armBitRevTable[1]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[1]; break; @@ -116,7 +120,7 @@ arm_status arm_cfft_radix2_init_q15( /* Initializations of structure parameters for 1024 point FFT */ S->twidCoefModifier = 4U; S->bitRevFactor = 4U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[3]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[3]; break; @@ -124,7 +128,7 @@ arm_status arm_cfft_radix2_init_q15( /* Initializations of structure parameters for 512 point FFT */ S->twidCoefModifier = 8U; S->bitRevFactor = 8U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[7]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[7]; break; @@ -132,7 +136,7 @@ arm_status arm_cfft_radix2_init_q15( /* Initializations of structure parameters for 256 point FFT */ S->twidCoefModifier = 16U; S->bitRevFactor = 16U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[15]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[15]; break; @@ -140,7 +144,7 @@ arm_status arm_cfft_radix2_init_q15( /* Initializations of structure parameters for 128 point FFT */ S->twidCoefModifier = 32U; S->bitRevFactor = 32U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[31]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[31]; break; @@ -148,7 +152,7 @@ arm_status arm_cfft_radix2_init_q15( /* Initializations of structure parameters for 64 point FFT */ S->twidCoefModifier = 64U; S->bitRevFactor = 64U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[63]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[63]; break; @@ -156,7 +160,7 @@ arm_status arm_cfft_radix2_init_q15( /* Initializations of structure parameters for 32 point FFT */ S->twidCoefModifier = 128U; S->bitRevFactor = 128U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[127]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[127]; break; @@ -164,7 +168,7 @@ arm_status arm_cfft_radix2_init_q15( /* Initializations of structure parameters for 16 point FFT */ S->twidCoefModifier = 256U; S->bitRevFactor = 256U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[255]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[255]; break; diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_init_q31.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_init_q31.c index f4a20d6..e448ec5 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_init_q31.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_init_q31.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_radix2_init_q31.c - * Description: Radix-2 Decimation in Frequency Fixed-point CFFT & CIFFT Initialization function + * Description: Radix-2 Decimation in Frequency Fixed-point CFFT & CIFFT + * Initialization function * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -26,8 +27,8 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @ingroup groupTransforms @@ -40,37 +41,42 @@ /** @brief Initialization function for the Q31 CFFT/CIFFT. - @deprecated Do not use this function. It has been superseded by \ref arm_cfft_q31 and will be removed in the future. - @param[in,out] S points to an instance of the Q31 CFFT/CIFFT structure + @deprecated Do not use this function. It has been superseded by \ref + arm_cfft_q31 and will be removed in the future. + @param[in,out] S points to an instance of the Q31 CFFT/CIFFT + structure @param[in] fftLen length of the FFT @param[in] ifftFlag flag that selects transform direction - value = 0: forward transform - value = 1: inverse transform - @param[in] bitReverseFlag flag that enables / disables bit reversal of output + @param[in] bitReverseFlag flag that enables / disables bit reversal of + output - value = 0: disables bit reversal of output - value = 1: enables bit reversal of output @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : fftLen is not a supported length + - \ref ARM_MATH_ARGUMENT_ERROR : fftLen is not a + supported length @par Details - The parameter ifftFlag controls whether a forward or inverse transform is computed. - Set(=1) ifftFlag for calculation of CIFFT otherwise CFFT is calculated + The parameter ifftFlag controls whether a + forward or inverse transform is computed. Set(=1) ifftFlag for calculation of + CIFFT otherwise CFFT is calculated @par - The parameter bitReverseFlag controls whether output is in normal order or bit reversed order. - Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order. + The parameter bitReverseFlag controls whether + output is in normal order or bit reversed order. Set(=1) bitReverseFlag for + output to be in normal order otherwise output is in bit reversed order. @par - The parameter fftLen Specifies length of CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024. + The parameter fftLen Specifies length of + CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024. @par - This Function also initializes Twiddle factor table pointer and Bit reversal table pointer. + This Function also initializes Twiddle factor table pointer + and Bit reversal table pointer. */ -arm_status arm_cfft_radix2_init_q31( - arm_cfft_radix2_instance_q31 * S, - uint16_t fftLen, - uint8_t ifftFlag, - uint8_t bitReverseFlag) -{ +arm_status arm_cfft_radix2_init_q31(arm_cfft_radix2_instance_q31 *S, + uint16_t fftLen, uint8_t ifftFlag, + uint8_t bitReverseFlag) { /* Initialise the default arm status */ arm_status status = ARM_MATH_SUCCESS; @@ -78,7 +84,7 @@ arm_status arm_cfft_radix2_init_q31( S->fftLen = fftLen; /* Initialise the Twiddle coefficient pointer */ - S->pTwiddle = (q31_t *) twiddleCoef_4096_q31; + S->pTwiddle = (q31_t *)twiddleCoef_4096_q31; /* Initialise the Flag for selection of CFFT or CIFFT */ S->ifftFlag = ifftFlag; @@ -87,8 +93,7 @@ arm_status arm_cfft_radix2_init_q31( S->bitReverseFlag = bitReverseFlag; /* Initializations of Instance structure depending on the FFT length */ - switch (S->fftLen) - { + switch (S->fftLen) { /* Initializations of structure parameters for 4096 point FFT */ case 4096U: /* Initialise the twiddle coef modifier value */ @@ -96,7 +101,7 @@ arm_status arm_cfft_radix2_init_q31( /* Initialise the bit reversal table modifier */ S->bitRevFactor = 1U; /* Initialise the bit reversal table pointer */ - S->pBitRevTable = (uint16_t *) armBitRevTable; + S->pBitRevTable = (uint16_t *)armBitRevTable; break; /* Initializations of structure parameters for 2048 point FFT */ @@ -106,7 +111,7 @@ arm_status arm_cfft_radix2_init_q31( /* Initialise the bit reversal table modifier */ S->bitRevFactor = 2U; /* Initialise the bit reversal table pointer */ - S->pBitRevTable = (uint16_t *) & armBitRevTable[1]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[1]; break; /* Initializations of structure parameters for 1024 point FFT */ @@ -116,7 +121,7 @@ arm_status arm_cfft_radix2_init_q31( /* Initialise the bit reversal table modifier */ S->bitRevFactor = 4U; /* Initialise the bit reversal table pointer */ - S->pBitRevTable = (uint16_t *) & armBitRevTable[3]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[3]; break; /* Initializations of structure parameters for 512 point FFT */ @@ -126,45 +131,44 @@ arm_status arm_cfft_radix2_init_q31( /* Initialise the bit reversal table modifier */ S->bitRevFactor = 8U; /* Initialise the bit reversal table pointer */ - S->pBitRevTable = (uint16_t *) & armBitRevTable[7]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[7]; break; case 256U: /* Initializations of structure parameters for 256 point FFT */ S->twidCoefModifier = 16U; S->bitRevFactor = 16U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[15]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[15]; break; case 128U: /* Initializations of structure parameters for 128 point FFT */ S->twidCoefModifier = 32U; S->bitRevFactor = 32U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[31]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[31]; break; case 64U: /* Initializations of structure parameters for 64 point FFT */ S->twidCoefModifier = 64U; S->bitRevFactor = 64U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[63]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[63]; break; case 32U: /* Initializations of structure parameters for 32 point FFT */ S->twidCoefModifier = 128U; S->bitRevFactor = 128U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[127]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[127]; break; case 16U: /* Initializations of structure parameters for 16 point FFT */ S->twidCoefModifier = 256U; S->bitRevFactor = 256U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[255]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[255]; break; - default: /* Reporting argument error if fftSize is not valid value */ status = ARM_MATH_ARGUMENT_ERROR; diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_q15.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_q15.c index 2a03b57..f82cce8 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_q15.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_q15.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_radix2_q15.c - * Description: Radix-2 Decimation in Frequency CFFT & CIFFT Fixed point processing function + * Description: Radix-2 Decimation in Frequency CFFT & CIFFT Fixed point + * processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -28,23 +29,15 @@ #include "arm_math.h" -void arm_radix2_butterfly_q15( - q15_t * pSrc, - uint32_t fftLen, - const q15_t * pCoef, - uint16_t twidCoefModifier); +void arm_radix2_butterfly_q15(q15_t *pSrc, uint32_t fftLen, const q15_t *pCoef, + uint16_t twidCoefModifier); -void arm_radix2_butterfly_inverse_q15( - q15_t * pSrc, - uint32_t fftLen, - const q15_t * pCoef, - uint16_t twidCoefModifier); +void arm_radix2_butterfly_inverse_q15(q15_t *pSrc, uint32_t fftLen, + const q15_t *pCoef, + uint16_t twidCoefModifier); -void arm_bitreversal_q15( - q15_t * pSrc, - uint32_t fftLen, - uint16_t bitRevFactor, - const uint16_t * pBitRevTab); +void arm_bitreversal_q15(q15_t *pSrc, uint32_t fftLen, uint16_t bitRevFactor, + const uint16_t *pBitRevTab); /** @ingroup groupTransforms @@ -57,24 +50,22 @@ void arm_bitreversal_q15( /** @brief Processing function for the fixed-point CFFT/CIFFT. - @deprecated Do not use this function. It has been superseded by \ref arm_cfft_q15 and will be removed in the future. - @param[in] S points to an instance of the fixed-point CFFT/CIFFT structure - @param[in,out] pSrc points to the complex data buffer of size 2*fftLen. Processing occurs in-place + @deprecated Do not use this function. It has been superseded by \ref + arm_cfft_q15 and will be removed in the future. + @param[in] S points to an instance of the fixed-point CFFT/CIFFT + structure + @param[in,out] pSrc points to the complex data buffer of size + 2*fftLen. Processing occurs in-place @return none */ -void arm_cfft_radix2_q15( - const arm_cfft_radix2_instance_q15 * S, - q15_t * pSrc) -{ +void arm_cfft_radix2_q15(const arm_cfft_radix2_instance_q15 *S, q15_t *pSrc) { - if (S->ifftFlag == 1U) - { - arm_radix2_butterfly_inverse_q15 (pSrc, S->fftLen, S->pTwiddle, S->twidCoefModifier); - } - else - { - arm_radix2_butterfly_q15 (pSrc, S->fftLen, S->pTwiddle, S->twidCoefModifier); + if (S->ifftFlag == 1U) { + arm_radix2_butterfly_inverse_q15(pSrc, S->fftLen, S->pTwiddle, + S->twidCoefModifier); + } else { + arm_radix2_butterfly_q15(pSrc, S->fftLen, S->pTwiddle, S->twidCoefModifier); } arm_bitreversal_q15(pSrc, S->fftLen, S->bitRevFactor, S->pBitRevTable); @@ -84,13 +75,9 @@ void arm_cfft_radix2_q15( @} end of ComplexFFT group */ -void arm_radix2_butterfly_q15( - q15_t * pSrc, - uint32_t fftLen, - const q15_t * pCoef, - uint16_t twidCoefModifier) -{ -#if defined (ARM_MATH_DSP) +void arm_radix2_butterfly_q15(q15_t *pSrc, uint32_t fftLen, const q15_t *pCoef, + uint16_t twidCoefModifier) { +#if defined(ARM_MATH_DSP) uint32_t i, j, k, l; uint32_t n1, n2, ia; @@ -98,7 +85,7 @@ void arm_radix2_butterfly_q15( q31_t T, S, R; q31_t coeff, out1, out2; - //N = fftLen; + // N = fftLen; n2 = fftLen; n1 = n2; @@ -106,25 +93,24 @@ void arm_radix2_butterfly_q15( ia = 0; // loop for groups - for (i = 0; i < n2; i++) - { - coeff = read_q15x2 ((q15_t *)pCoef + (ia * 2U)); + for (i = 0; i < n2; i++) { + coeff = read_q15x2((q15_t *)pCoef + (ia * 2U)); ia = ia + twidCoefModifier; l = i + n2; - T = read_q15x2 (pSrc + (2 * i)); - in = ((int16_t) (T & 0xFFFF)) >> 1; + T = read_q15x2(pSrc + (2 * i)); + in = ((int16_t)(T & 0xFFFF)) >> 1; T = ((T >> 1) & 0xFFFF0000) | (in & 0xFFFF); - S = read_q15x2 (pSrc + (2 * l)); - in = ((int16_t) (S & 0xFFFF)) >> 1; + S = read_q15x2(pSrc + (2 * l)); + in = ((int16_t)(S & 0xFFFF)) >> 1; S = ((S >> 1) & 0xFFFF0000) | (in & 0xFFFF); R = __QSUB16(T, S); - write_q15x2 (pSrc + (2 * i), __SHADD16(T, S)); + write_q15x2(pSrc + (2 * i), __SHADD16(T, S)); #ifndef ARM_MATH_BIG_ENDIAN out1 = __SMUAD(coeff, R) >> 16; @@ -134,9 +120,10 @@ void arm_radix2_butterfly_q15( out2 = __SMUAD(coeff, R); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ - write_q15x2 (pSrc + (2U * l), (q31_t) ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2(pSrc + (2U * l), + (q31_t)((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); - coeff = read_q15x2 ((q15_t *)pCoef + (ia * 2U)); + coeff = read_q15x2((q15_t *)pCoef + (ia * 2U)); ia = ia + twidCoefModifier; @@ -144,17 +131,17 @@ void arm_radix2_butterfly_q15( i++; l++; - T = read_q15x2 (pSrc + (2 * i)); - in = ((int16_t) (T & 0xFFFF)) >> 1; + T = read_q15x2(pSrc + (2 * i)); + in = ((int16_t)(T & 0xFFFF)) >> 1; T = ((T >> 1) & 0xFFFF0000) | (in & 0xFFFF); - S = read_q15x2 (pSrc + (2 * l)); - in = ((int16_t) (S & 0xFFFF)) >> 1; + S = read_q15x2(pSrc + (2 * l)); + in = ((int16_t)(S & 0xFFFF)) >> 1; S = ((S >> 1) & 0xFFFF0000) | (in & 0xFFFF); R = __QSUB16(T, S); - write_q15x2 (pSrc + (2 * i), __SHADD16(T, S)); + write_q15x2(pSrc + (2 * i), __SHADD16(T, S)); #ifndef ARM_MATH_BIG_ENDIAN out1 = __SMUAD(coeff, R) >> 16; @@ -165,38 +152,36 @@ void arm_radix2_butterfly_q15( out2 = __SMUAD(coeff, R); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ - write_q15x2 (pSrc + (2U * l), (q31_t) ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2(pSrc + (2U * l), + (q31_t)((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); } /* groups loop end */ twidCoefModifier = twidCoefModifier << 1U; /* loop for stage */ - for (k = fftLen / 2; k > 2; k = k >> 1) - { + for (k = fftLen / 2; k > 2; k = k >> 1) { n1 = n2; n2 = n2 >> 1; ia = 0; /* loop for groups */ - for (j = 0; j < n2; j++) - { - coeff = read_q15x2 ((q15_t *)pCoef + (ia * 2U)); + for (j = 0; j < n2; j++) { + coeff = read_q15x2((q15_t *)pCoef + (ia * 2U)); ia = ia + twidCoefModifier; /* loop for butterfly */ - for (i = j; i < fftLen; i += n1) - { + for (i = j; i < fftLen; i += n1) { l = i + n2; - T = read_q15x2 (pSrc + (2 * i)); + T = read_q15x2(pSrc + (2 * i)); - S = read_q15x2 (pSrc + (2 * l)); + S = read_q15x2(pSrc + (2 * l)); R = __QSUB16(T, S); - write_q15x2 (pSrc + (2 * i), __SHADD16(T, S)); + write_q15x2(pSrc + (2 * i), __SHADD16(T, S)); #ifndef ARM_MATH_BIG_ENDIAN out1 = __SMUAD(coeff, R) >> 16; @@ -206,19 +191,20 @@ void arm_radix2_butterfly_q15( out2 = __SMUAD(coeff, R); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ - write_q15x2 (pSrc + (2U * l), (q31_t) ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2(pSrc + (2U * l), + (q31_t)((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); i += n1; l = i + n2; - T = read_q15x2 (pSrc + (2 * i)); + T = read_q15x2(pSrc + (2 * i)); - S = read_q15x2 (pSrc + (2 * l)); + S = read_q15x2(pSrc + (2 * l)); R = __QSUB16(T, S); - write_q15x2 (pSrc + (2 * i), __SHADD16(T, S)); + write_q15x2(pSrc + (2 * i), __SHADD16(T, S)); #ifndef ARM_MATH_BIG_ENDIAN out1 = __SMUAD(coeff, R) >> 16; @@ -228,7 +214,8 @@ void arm_radix2_butterfly_q15( out2 = __SMUAD(coeff, R); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ - write_q15x2 (pSrc + (2U * l), (q31_t) ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2(pSrc + (2U * l), + (q31_t)((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); } /* butterfly loop end */ @@ -241,48 +228,45 @@ void arm_radix2_butterfly_q15( n2 = n2 >> 1; ia = 0; - coeff = read_q15x2 ((q15_t *)pCoef + (ia * 2U)); + coeff = read_q15x2((q15_t *)pCoef + (ia * 2U)); ia = ia + twidCoefModifier; /* loop for butterfly */ - for (i = 0; i < fftLen; i += n1) - { + for (i = 0; i < fftLen; i += n1) { l = i + n2; - T = read_q15x2 (pSrc + (2 * i)); + T = read_q15x2(pSrc + (2 * i)); - S = read_q15x2 (pSrc + (2 * l)); + S = read_q15x2(pSrc + (2 * l)); R = __QSUB16(T, S); - write_q15x2 (pSrc + (2 * i), __QADD16(T, S)); + write_q15x2(pSrc + (2 * i), __QADD16(T, S)); - write_q15x2 (pSrc + (2 * l), R); + write_q15x2(pSrc + (2 * l), R); i += n1; l = i + n2; - T = read_q15x2 (pSrc + (2 * i)); + T = read_q15x2(pSrc + (2 * i)); - S = read_q15x2 (pSrc + (2 * l)); + S = read_q15x2(pSrc + (2 * l)); R = __QSUB16(T, S); - write_q15x2 (pSrc + (2 * i), __QADD16(T, S)); + write_q15x2(pSrc + (2 * i), __QADD16(T, S)); - write_q15x2 (pSrc + (2 * l), R); + write_q15x2(pSrc + (2 * l), R); } /* groups loop end */ - #else /* #if defined (ARM_MATH_DSP) */ uint32_t i, j, k, l; uint32_t n1, n2, ia; q15_t xt, yt, cosVal, sinVal; - // N = fftLen; n2 = fftLen; @@ -291,28 +275,26 @@ void arm_radix2_butterfly_q15( ia = 0; /* loop for groups */ - for (j = 0; j < n2; j++) - { + for (j = 0; j < n2; j++) { cosVal = pCoef[(ia * 2)]; sinVal = pCoef[(ia * 2) + 1]; ia = ia + twidCoefModifier; /* loop for butterfly */ - for (i = j; i < fftLen; i += n1) - { + for (i = j; i < fftLen; i += n1) { l = i + n2; xt = (pSrc[2 * i] >> 1U) - (pSrc[2 * l] >> 1U); pSrc[2 * i] = ((pSrc[2 * i] >> 1U) + (pSrc[2 * l] >> 1U)) >> 1U; yt = (pSrc[2 * i + 1] >> 1U) - (pSrc[2 * l + 1] >> 1U); - pSrc[2 * i + 1] = ((pSrc[2 * l + 1] >> 1U) + - (pSrc[2 * i + 1] >> 1U) ) >> 1U; + pSrc[2 * i + 1] = + ((pSrc[2 * l + 1] >> 1U) + (pSrc[2 * i + 1] >> 1U)) >> 1U; - pSrc[2 * l] = (((int16_t) (((q31_t) xt * cosVal) >> 16)) + - ((int16_t) (((q31_t) yt * sinVal) >> 16))); + pSrc[2 * l] = (((int16_t)(((q31_t)xt * cosVal) >> 16)) + + ((int16_t)(((q31_t)yt * sinVal) >> 16))); - pSrc[2U * l + 1] = (((int16_t) (((q31_t) yt * cosVal) >> 16)) - - ((int16_t) (((q31_t) xt * sinVal) >> 16))); + pSrc[2U * l + 1] = (((int16_t)(((q31_t)yt * cosVal) >> 16)) - + ((int16_t)(((q31_t)xt * sinVal) >> 16))); } /* butterfly loop end */ @@ -321,22 +303,19 @@ void arm_radix2_butterfly_q15( twidCoefModifier = twidCoefModifier << 1U; /* loop for stage */ - for (k = fftLen / 2; k > 2; k = k >> 1) - { + for (k = fftLen / 2; k > 2; k = k >> 1) { n1 = n2; n2 = n2 >> 1; ia = 0; /* loop for groups */ - for (j = 0; j < n2; j++) - { + for (j = 0; j < n2; j++) { cosVal = pCoef[ia * 2]; sinVal = pCoef[(ia * 2) + 1]; ia = ia + twidCoefModifier; /* loop for butterfly */ - for (i = j; i < fftLen; i += n1) - { + for (i = j; i < fftLen; i += n1) { l = i + n2; xt = pSrc[2 * i] - pSrc[2 * l]; pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]) >> 1U; @@ -344,11 +323,11 @@ void arm_radix2_butterfly_q15( yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]) >> 1U; - pSrc[2 * l] = (((int16_t) (((q31_t) xt * cosVal) >> 16)) + - ((int16_t) (((q31_t) yt * sinVal) >> 16))); + pSrc[2 * l] = (((int16_t)(((q31_t)xt * cosVal) >> 16)) + + ((int16_t)(((q31_t)yt * sinVal) >> 16))); - pSrc[2U * l + 1] = (((int16_t) (((q31_t) yt * cosVal) >> 16)) - - ((int16_t) (((q31_t) xt * sinVal) >> 16))); + pSrc[2U * l + 1] = (((int16_t)(((q31_t)yt * cosVal) >> 16)) - + ((int16_t)(((q31_t)xt * sinVal) >> 16))); } /* butterfly loop end */ @@ -362,16 +341,14 @@ void arm_radix2_butterfly_q15( ia = 0; /* loop for groups */ - for (j = 0; j < n2; j++) - { + for (j = 0; j < n2; j++) { cosVal = pCoef[ia * 2]; sinVal = pCoef[(ia * 2) + 1]; ia = ia + twidCoefModifier; /* loop for butterfly */ - for (i = j; i < fftLen; i += n1) - { + for (i = j; i < fftLen; i += n1) { l = i + n2; xt = pSrc[2 * i] - pSrc[2 * l]; pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]); @@ -390,23 +367,18 @@ void arm_radix2_butterfly_q15( twidCoefModifier = twidCoefModifier << 1U; #endif /* #if defined (ARM_MATH_DSP) */ - } +void arm_radix2_butterfly_inverse_q15(q15_t *pSrc, uint32_t fftLen, + const q15_t *pCoef, + uint16_t twidCoefModifier) { +#if defined(ARM_MATH_DSP) -void arm_radix2_butterfly_inverse_q15( - q15_t * pSrc, - uint32_t fftLen, - const q15_t * pCoef, - uint16_t twidCoefModifier) -{ -#if defined (ARM_MATH_DSP) - - uint32_t i, j, k, l; - uint32_t n1, n2, ia; - q15_t in; - q31_t T, S, R; - q31_t coeff, out1, out2; + uint32_t i, j, k, l; + uint32_t n1, n2, ia; + q15_t in; + q31_t T, S, R; + q31_t coeff, out1, out2; // N = fftLen; n2 = fftLen; @@ -416,25 +388,24 @@ void arm_radix2_butterfly_inverse_q15( ia = 0; /* loop for groups */ - for (i = 0; i < n2; i++) - { - coeff = read_q15x2 ((q15_t *)pCoef + (ia * 2U)); + for (i = 0; i < n2; i++) { + coeff = read_q15x2((q15_t *)pCoef + (ia * 2U)); ia = ia + twidCoefModifier; l = i + n2; - T = read_q15x2 (pSrc + (2 * i)); - in = ((int16_t) (T & 0xFFFF)) >> 1; + T = read_q15x2(pSrc + (2 * i)); + in = ((int16_t)(T & 0xFFFF)) >> 1; T = ((T >> 1) & 0xFFFF0000) | (in & 0xFFFF); - S = read_q15x2 (pSrc + (2 * l)); - in = ((int16_t) (S & 0xFFFF)) >> 1; + S = read_q15x2(pSrc + (2 * l)); + in = ((int16_t)(S & 0xFFFF)) >> 1; S = ((S >> 1) & 0xFFFF0000) | (in & 0xFFFF); R = __QSUB16(T, S); - write_q15x2 (pSrc + (2 * i), __SHADD16(T, S)); + write_q15x2(pSrc + (2 * i), __SHADD16(T, S)); #ifndef ARM_MATH_BIG_ENDIAN out1 = __SMUSD(coeff, R) >> 16; @@ -444,9 +415,10 @@ void arm_radix2_butterfly_inverse_q15( out2 = __SMUSD(__QSUB(0, coeff), R); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ - write_q15x2 (pSrc + (2 * l), (q31_t) ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2(pSrc + (2 * l), + (q31_t)((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); - coeff = read_q15x2 ((q15_t *)pCoef + (ia * 2U)); + coeff = read_q15x2((q15_t *)pCoef + (ia * 2U)); ia = ia + twidCoefModifier; @@ -454,17 +426,17 @@ void arm_radix2_butterfly_inverse_q15( i++; l++; - T = read_q15x2 (pSrc + (2 * i)); - in = ((int16_t) (T & 0xFFFF)) >> 1; + T = read_q15x2(pSrc + (2 * i)); + in = ((int16_t)(T & 0xFFFF)) >> 1; T = ((T >> 1) & 0xFFFF0000) | (in & 0xFFFF); - S = read_q15x2 (pSrc + (2 * l)); - in = ((int16_t) (S & 0xFFFF)) >> 1; + S = read_q15x2(pSrc + (2 * l)); + in = ((int16_t)(S & 0xFFFF)) >> 1; S = ((S >> 1) & 0xFFFF0000) | (in & 0xFFFF); R = __QSUB16(T, S); - write_q15x2 (pSrc + (2 * i), __SHADD16(T, S)); + write_q15x2(pSrc + (2 * i), __SHADD16(T, S)); #ifndef ARM_MATH_BIG_ENDIAN out1 = __SMUSD(coeff, R) >> 16; @@ -474,38 +446,36 @@ void arm_radix2_butterfly_inverse_q15( out2 = __SMUSD(__QSUB(0, coeff), R); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ - write_q15x2 (pSrc + (2 * l), (q31_t) ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2(pSrc + (2 * l), + (q31_t)((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); } /* groups loop end */ twidCoefModifier = twidCoefModifier << 1U; /* loop for stage */ - for (k = fftLen / 2; k > 2; k = k >> 1) - { + for (k = fftLen / 2; k > 2; k = k >> 1) { n1 = n2; n2 = n2 >> 1; ia = 0; /* loop for groups */ - for (j = 0; j < n2; j++) - { - coeff = read_q15x2 ((q15_t *)pCoef + (ia * 2U)); + for (j = 0; j < n2; j++) { + coeff = read_q15x2((q15_t *)pCoef + (ia * 2U)); ia = ia + twidCoefModifier; /* loop for butterfly */ - for (i = j; i < fftLen; i += n1) - { + for (i = j; i < fftLen; i += n1) { l = i + n2; - T = read_q15x2 (pSrc + (2 * i)); + T = read_q15x2(pSrc + (2 * i)); - S = read_q15x2 (pSrc + (2 * l)); + S = read_q15x2(pSrc + (2 * l)); R = __QSUB16(T, S); - write_q15x2 (pSrc + (2 * i), __SHADD16(T, S)); + write_q15x2(pSrc + (2 * i), __SHADD16(T, S)); #ifndef ARM_MATH_BIG_ENDIAN out1 = __SMUSD(coeff, R) >> 16; @@ -515,19 +485,20 @@ void arm_radix2_butterfly_inverse_q15( out2 = __SMUSD(__QSUB(0, coeff), R); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ - write_q15x2 (pSrc + (2 * l), (q31_t) ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2(pSrc + (2 * l), + (q31_t)((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); i += n1; l = i + n2; - T = read_q15x2 (pSrc + (2 * i)); + T = read_q15x2(pSrc + (2 * i)); - S = read_q15x2 (pSrc + (2 * l)); + S = read_q15x2(pSrc + (2 * l)); R = __QSUB16(T, S); - write_q15x2 (pSrc + (2 * i), __SHADD16(T, S)); + write_q15x2(pSrc + (2 * i), __SHADD16(T, S)); #ifndef ARM_MATH_BIG_ENDIAN out1 = __SMUSD(coeff, R) >> 16; @@ -537,7 +508,8 @@ void arm_radix2_butterfly_inverse_q15( out2 = __SMUSD(__QSUB(0, coeff), R); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ - write_q15x2 (pSrc + (2 * l), (q31_t) ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2(pSrc + (2 * l), + (q31_t)((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); } /* butterfly loop end */ @@ -551,26 +523,24 @@ void arm_radix2_butterfly_inverse_q15( ia = 0; /* loop for groups */ - for (j = 0; j < n2; j++) - { - coeff = read_q15x2 ((q15_t *)pCoef + (ia * 2U)); + for (j = 0; j < n2; j++) { + coeff = read_q15x2((q15_t *)pCoef + (ia * 2U)); ia = ia + twidCoefModifier; /* loop for butterfly */ - for (i = j; i < fftLen; i += n1) - { + for (i = j; i < fftLen; i += n1) { l = i + n2; - T = read_q15x2 (pSrc + (2 * i)); + T = read_q15x2(pSrc + (2 * i)); - S = read_q15x2 (pSrc + (2 * l)); + S = read_q15x2(pSrc + (2 * l)); R = __QSUB16(T, S); - write_q15x2 (pSrc + (2 * i), __QADD16(T, S)); + write_q15x2(pSrc + (2 * i), __QADD16(T, S)); - write_q15x2 (pSrc + (2 * l), R); + write_q15x2(pSrc + (2 * l), R); } /* butterfly loop end */ @@ -580,9 +550,9 @@ void arm_radix2_butterfly_inverse_q15( #else /* #if defined (ARM_MATH_DSP) */ - uint32_t i, j, k, l; - uint32_t n1, n2, ia; - q15_t xt, yt, cosVal, sinVal; + uint32_t i, j, k, l; + uint32_t n1, n2, ia; + q15_t xt, yt, cosVal, sinVal; // N = fftLen; n2 = fftLen; @@ -592,28 +562,26 @@ void arm_radix2_butterfly_inverse_q15( ia = 0; /* loop for groups */ - for (j = 0; j < n2; j++) - { + for (j = 0; j < n2; j++) { cosVal = pCoef[(ia * 2)]; sinVal = pCoef[(ia * 2) + 1]; ia = ia + twidCoefModifier; /* loop for butterfly */ - for (i = j; i < fftLen; i += n1) - { + for (i = j; i < fftLen; i += n1) { l = i + n2; xt = (pSrc[2 * i] >> 1U) - (pSrc[2 * l] >> 1U); pSrc[2 * i] = ((pSrc[2 * i] >> 1U) + (pSrc[2 * l] >> 1U)) >> 1U; yt = (pSrc[2 * i + 1] >> 1U) - (pSrc[2 * l + 1] >> 1U); - pSrc[2 * i + 1] = ((pSrc[2 * l + 1] >> 1U) + - (pSrc[2 * i + 1] >> 1U) ) >> 1U; + pSrc[2 * i + 1] = + ((pSrc[2 * l + 1] >> 1U) + (pSrc[2 * i + 1] >> 1U)) >> 1U; - pSrc[2 * l] = (((int16_t) (((q31_t) xt * cosVal) >> 16)) - - ((int16_t) (((q31_t) yt * sinVal) >> 16))); + pSrc[2 * l] = (((int16_t)(((q31_t)xt * cosVal) >> 16)) - + ((int16_t)(((q31_t)yt * sinVal) >> 16))); - pSrc[2 * l + 1] = (((int16_t) (((q31_t) yt * cosVal) >> 16)) + - ((int16_t) (((q31_t) xt * sinVal) >> 16))); + pSrc[2 * l + 1] = (((int16_t)(((q31_t)yt * cosVal) >> 16)) + + ((int16_t)(((q31_t)xt * sinVal) >> 16))); } /* butterfly loop end */ @@ -622,22 +590,19 @@ void arm_radix2_butterfly_inverse_q15( twidCoefModifier = twidCoefModifier << 1U; /* loop for stage */ - for (k = fftLen / 2; k > 2; k = k >> 1) - { + for (k = fftLen / 2; k > 2; k = k >> 1) { n1 = n2; n2 = n2 >> 1; ia = 0; /* loop for groups */ - for (j = 0; j < n2; j++) - { + for (j = 0; j < n2; j++) { cosVal = pCoef[(ia * 2)]; sinVal = pCoef[(ia * 2) + 1]; ia = ia + twidCoefModifier; /* loop for butterfly */ - for (i = j; i < fftLen; i += n1) - { + for (i = j; i < fftLen; i += n1) { l = i + n2; xt = pSrc[2 * i] - pSrc[2 * l]; pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]) >> 1U; @@ -645,11 +610,11 @@ void arm_radix2_butterfly_inverse_q15( yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]) >> 1U; - pSrc[2 * l] = (((int16_t) (((q31_t) xt * cosVal) >> 16)) - - ((int16_t) (((q31_t) yt * sinVal) >> 16)) ); + pSrc[2 * l] = (((int16_t)(((q31_t)xt * cosVal) >> 16)) - + ((int16_t)(((q31_t)yt * sinVal) >> 16))); - pSrc[2 * l + 1] = (((int16_t) (((q31_t) yt * cosVal) >> 16)) + - ((int16_t) (((q31_t) xt * sinVal) >> 16)) ); + pSrc[2 * l + 1] = (((int16_t)(((q31_t)yt * cosVal) >> 16)) + + ((int16_t)(((q31_t)xt * sinVal) >> 16))); } /* butterfly loop end */ @@ -668,8 +633,7 @@ void arm_radix2_butterfly_inverse_q15( ia = ia + twidCoefModifier; /* loop for butterfly */ - for (i = 0; i < fftLen; i += n1) - { + for (i = 0; i < fftLen; i += n1) { l = i + n2; xt = pSrc[2 * i] - pSrc[2 * l]; pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]); @@ -683,7 +647,5 @@ void arm_radix2_butterfly_inverse_q15( } /* groups loop end */ - #endif /* #if defined (ARM_MATH_DSP) */ - } diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_q31.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_q31.c index 6c79a65..18bddd5 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_q31.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix2_q31.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_radix2_q31.c - * Description: Radix-2 Decimation in Frequency CFFT & CIFFT Fixed point processing function + * Description: Radix-2 Decimation in Frequency CFFT & CIFFT Fixed point + * processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -28,23 +29,15 @@ #include "arm_math.h" -void arm_radix2_butterfly_q31( - q31_t * pSrc, - uint32_t fftLen, - const q31_t * pCoef, - uint16_t twidCoefModifier); +void arm_radix2_butterfly_q31(q31_t *pSrc, uint32_t fftLen, const q31_t *pCoef, + uint16_t twidCoefModifier); -void arm_radix2_butterfly_inverse_q31( - q31_t * pSrc, - uint32_t fftLen, - const q31_t * pCoef, - uint16_t twidCoefModifier); +void arm_radix2_butterfly_inverse_q31(q31_t *pSrc, uint32_t fftLen, + const q31_t *pCoef, + uint16_t twidCoefModifier); -void arm_bitreversal_q31( - q31_t * pSrc, - uint32_t fftLen, - uint16_t bitRevFactor, - const uint16_t * pBitRevTab); +void arm_bitreversal_q31(q31_t *pSrc, uint32_t fftLen, uint16_t bitRevFactor, + const uint16_t *pBitRevTab); /** @ingroup groupTransforms @@ -57,281 +50,255 @@ void arm_bitreversal_q31( /** @brief Processing function for the fixed-point CFFT/CIFFT. - @deprecated Do not use this function. It has been superseded by \ref arm_cfft_q31 and will be removed in the future. - @param[in] S points to an instance of the fixed-point CFFT/CIFFT structure - @param[in,out] pSrc points to the complex data buffer of size 2*fftLen. Processing occurs in-place + @deprecated Do not use this function. It has been superseded by \ref + arm_cfft_q31 and will be removed in the future. + @param[in] S points to an instance of the fixed-point CFFT/CIFFT + structure + @param[in,out] pSrc points to the complex data buffer of size + 2*fftLen. Processing occurs in-place @return none */ -void arm_cfft_radix2_q31( - const arm_cfft_radix2_instance_q31 * S, - q31_t * pSrc) -{ +void arm_cfft_radix2_q31(const arm_cfft_radix2_instance_q31 *S, q31_t *pSrc) { - if (S->ifftFlag == 1U) - { - arm_radix2_butterfly_inverse_q31(pSrc, S->fftLen, - S->pTwiddle, S->twidCoefModifier); - } - else - { - arm_radix2_butterfly_q31(pSrc, S->fftLen, - S->pTwiddle, S->twidCoefModifier); - } + if (S->ifftFlag == 1U) { + arm_radix2_butterfly_inverse_q31(pSrc, S->fftLen, S->pTwiddle, + S->twidCoefModifier); + } else { + arm_radix2_butterfly_q31(pSrc, S->fftLen, S->pTwiddle, S->twidCoefModifier); + } - arm_bitreversal_q31(pSrc, S->fftLen, S->bitRevFactor, S->pBitRevTable); + arm_bitreversal_q31(pSrc, S->fftLen, S->bitRevFactor, S->pBitRevTable); } /** @} end of ComplexFFT group */ -void arm_radix2_butterfly_q31( - q31_t * pSrc, - uint32_t fftLen, - const q31_t * pCoef, - uint16_t twidCoefModifier) -{ +void arm_radix2_butterfly_q31(q31_t *pSrc, uint32_t fftLen, const q31_t *pCoef, + uint16_t twidCoefModifier) { - unsigned i, j, k, l, m; - unsigned n1, n2, ia; - q31_t xt, yt, cosVal, sinVal; - q31_t p0, p1; + unsigned i, j, k, l, m; + unsigned n1, n2, ia; + q31_t xt, yt, cosVal, sinVal; + q31_t p0, p1; - //N = fftLen; - n2 = fftLen; + // N = fftLen; + n2 = fftLen; - n1 = n2; - n2 = n2 >> 1; - ia = 0; + n1 = n2; + n2 = n2 >> 1; + ia = 0; - // loop for groups - for (i = 0; i < n2; i++) - { + // loop for groups + for (i = 0; i < n2; i++) { + cosVal = pCoef[ia * 2]; + sinVal = pCoef[(ia * 2) + 1]; + ia = ia + twidCoefModifier; + + l = i + n2; + xt = (pSrc[2 * i] >> 1U) - (pSrc[2 * l] >> 1U); + pSrc[2 * i] = ((pSrc[2 * i] >> 1U) + (pSrc[2 * l] >> 1U)) >> 1U; + + yt = (pSrc[2 * i + 1] >> 1U) - (pSrc[2 * l + 1] >> 1U); + pSrc[2 * i + 1] = ((pSrc[2 * l + 1] >> 1U) + (pSrc[2 * i + 1] >> 1U)) >> 1U; + + mult_32x32_keep32_R(p0, xt, cosVal); + mult_32x32_keep32_R(p1, yt, cosVal); + multAcc_32x32_keep32_R(p0, yt, sinVal); + multSub_32x32_keep32_R(p1, xt, sinVal); + + pSrc[2U * l] = p0; + pSrc[2U * l + 1U] = p1; + + } // groups loop end + + twidCoefModifier <<= 1U; + + // loop for stage + for (k = fftLen / 2; k > 2; k = k >> 1) { + n1 = n2; + n2 = n2 >> 1; + ia = 0; + + // loop for groups + for (j = 0; j < n2; j++) { cosVal = pCoef[ia * 2]; sinVal = pCoef[(ia * 2) + 1]; ia = ia + twidCoefModifier; - l = i + n2; - xt = (pSrc[2 * i] >> 1U) - (pSrc[2 * l] >> 1U); - pSrc[2 * i] = ((pSrc[2 * i] >> 1U) + (pSrc[2 * l] >> 1U)) >> 1U; + // loop for butterfly + i = j; + m = fftLen / n1; + do { + l = i + n2; + xt = pSrc[2 * i] - pSrc[2 * l]; + pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]) >> 1U; - yt = (pSrc[2 * i + 1] >> 1U) - (pSrc[2 * l + 1] >> 1U); - pSrc[2 * i + 1] = - ((pSrc[2 * l + 1] >> 1U) + (pSrc[2 * i + 1] >> 1U)) >> 1U; + yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; + pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]) >> 1U; - mult_32x32_keep32_R(p0, xt, cosVal); - mult_32x32_keep32_R(p1, yt, cosVal); - multAcc_32x32_keep32_R(p0, yt, sinVal); - multSub_32x32_keep32_R(p1, xt, sinVal); + mult_32x32_keep32_R(p0, xt, cosVal); + mult_32x32_keep32_R(p1, yt, cosVal); + multAcc_32x32_keep32_R(p0, yt, sinVal); + multSub_32x32_keep32_R(p1, xt, sinVal); - pSrc[2U * l] = p0; - pSrc[2U * l + 1U] = p1; + pSrc[2U * l] = p0; + pSrc[2U * l + 1U] = p1; + i += n1; + m--; + } while (m > 0); // butterfly loop end - } // groups loop end + } // groups loop end - twidCoefModifier <<= 1U; + twidCoefModifier <<= 1U; + } // stages loop end - // loop for stage - for (k = fftLen / 2; k > 2; k = k >> 1) - { - n1 = n2; - n2 = n2 >> 1; - ia = 0; + n1 = n2; + n2 = n2 >> 1; + ia = 0; - // loop for groups - for (j = 0; j < n2; j++) - { - cosVal = pCoef[ia * 2]; - sinVal = pCoef[(ia * 2) + 1]; - ia = ia + twidCoefModifier; + cosVal = pCoef[ia * 2]; + sinVal = pCoef[(ia * 2) + 1]; + ia = ia + twidCoefModifier; - // loop for butterfly - i = j; - m = fftLen / n1; - do - { - l = i + n2; - xt = pSrc[2 * i] - pSrc[2 * l]; - pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]) >> 1U; + // loop for butterfly + for (i = 0; i < fftLen; i += n1) { + l = i + n2; + xt = pSrc[2 * i] - pSrc[2 * l]; + pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]); - yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; - pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]) >> 1U; + yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; + pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]); - mult_32x32_keep32_R(p0, xt, cosVal); - mult_32x32_keep32_R(p1, yt, cosVal); - multAcc_32x32_keep32_R(p0, yt, sinVal); - multSub_32x32_keep32_R(p1, xt, sinVal); + pSrc[2U * l] = xt; - pSrc[2U * l] = p0; - pSrc[2U * l + 1U] = p1; - i += n1; - m--; - } while ( m > 0); // butterfly loop end + pSrc[2U * l + 1U] = yt; - } // groups loop end + i += n1; + l = i + n2; - twidCoefModifier <<= 1U; - } // stages loop end + xt = pSrc[2 * i] - pSrc[2 * l]; + pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]); - n1 = n2; - n2 = n2 >> 1; - ia = 0; + yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; + pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]); - cosVal = pCoef[ia * 2]; - sinVal = pCoef[(ia * 2) + 1]; - ia = ia + twidCoefModifier; + pSrc[2U * l] = xt; - // loop for butterfly - for (i = 0; i < fftLen; i += n1) - { - l = i + n2; - xt = pSrc[2 * i] - pSrc[2 * l]; - pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]); - - yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; - pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]); - - pSrc[2U * l] = xt; - - pSrc[2U * l + 1U] = yt; - - i += n1; - l = i + n2; - - xt = pSrc[2 * i] - pSrc[2 * l]; - pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]); - - yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; - pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]); - - pSrc[2U * l] = xt; - - pSrc[2U * l + 1U] = yt; - - } // butterfly loop end + pSrc[2U * l + 1U] = yt; + } // butterfly loop end } +void arm_radix2_butterfly_inverse_q31(q31_t *pSrc, uint32_t fftLen, + const q31_t *pCoef, + uint16_t twidCoefModifier) { -void arm_radix2_butterfly_inverse_q31( - q31_t * pSrc, - uint32_t fftLen, - const q31_t * pCoef, - uint16_t twidCoefModifier) -{ + unsigned i, j, k, l; + unsigned n1, n2, ia; + q31_t xt, yt, cosVal, sinVal; + q31_t p0, p1; - unsigned i, j, k, l; - unsigned n1, n2, ia; - q31_t xt, yt, cosVal, sinVal; - q31_t p0, p1; + // N = fftLen; + n2 = fftLen; - //N = fftLen; - n2 = fftLen; + n1 = n2; + n2 = n2 >> 1; + ia = 0; - n1 = n2; - n2 = n2 >> 1; - ia = 0; + // loop for groups + for (i = 0; i < n2; i++) { + cosVal = pCoef[ia * 2]; + sinVal = pCoef[(ia * 2) + 1]; + ia = ia + twidCoefModifier; - // loop for groups - for (i = 0; i < n2; i++) - { + l = i + n2; + xt = (pSrc[2 * i] >> 1U) - (pSrc[2 * l] >> 1U); + pSrc[2 * i] = ((pSrc[2 * i] >> 1U) + (pSrc[2 * l] >> 1U)) >> 1U; + + yt = (pSrc[2 * i + 1] >> 1U) - (pSrc[2 * l + 1] >> 1U); + pSrc[2 * i + 1] = ((pSrc[2 * l + 1] >> 1U) + (pSrc[2 * i + 1] >> 1U)) >> 1U; + + mult_32x32_keep32_R(p0, xt, cosVal); + mult_32x32_keep32_R(p1, yt, cosVal); + multSub_32x32_keep32_R(p0, yt, sinVal); + multAcc_32x32_keep32_R(p1, xt, sinVal); + + pSrc[2U * l] = p0; + pSrc[2U * l + 1U] = p1; + } // groups loop end + + twidCoefModifier = twidCoefModifier << 1U; + + // loop for stage + for (k = fftLen / 2; k > 2; k = k >> 1) { + n1 = n2; + n2 = n2 >> 1; + ia = 0; + + // loop for groups + for (j = 0; j < n2; j++) { cosVal = pCoef[ia * 2]; sinVal = pCoef[(ia * 2) + 1]; ia = ia + twidCoefModifier; - l = i + n2; - xt = (pSrc[2 * i] >> 1U) - (pSrc[2 * l] >> 1U); - pSrc[2 * i] = ((pSrc[2 * i] >> 1U) + (pSrc[2 * l] >> 1U)) >> 1U; + // loop for butterfly + for (i = j; i < fftLen; i += n1) { + l = i + n2; + xt = pSrc[2 * i] - pSrc[2 * l]; + pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]) >> 1U; - yt = (pSrc[2 * i + 1] >> 1U) - (pSrc[2 * l + 1] >> 1U); - pSrc[2 * i + 1] = - ((pSrc[2 * l + 1] >> 1U) + (pSrc[2 * i + 1] >> 1U)) >> 1U; + yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; + pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]) >> 1U; - mult_32x32_keep32_R(p0, xt, cosVal); - mult_32x32_keep32_R(p1, yt, cosVal); - multSub_32x32_keep32_R(p0, yt, sinVal); - multAcc_32x32_keep32_R(p1, xt, sinVal); + mult_32x32_keep32_R(p0, xt, cosVal); + mult_32x32_keep32_R(p1, yt, cosVal); + multSub_32x32_keep32_R(p0, yt, sinVal); + multAcc_32x32_keep32_R(p1, xt, sinVal); - pSrc[2U * l] = p0; - pSrc[2U * l + 1U] = p1; - } // groups loop end + pSrc[2U * l] = p0; + pSrc[2U * l + 1U] = p1; + } // butterfly loop end - twidCoefModifier = twidCoefModifier << 1U; + } // groups loop end - // loop for stage - for (k = fftLen / 2; k > 2; k = k >> 1) - { - n1 = n2; - n2 = n2 >> 1; - ia = 0; + twidCoefModifier = twidCoefModifier << 1U; + } // stages loop end - // loop for groups - for (j = 0; j < n2; j++) - { - cosVal = pCoef[ia * 2]; - sinVal = pCoef[(ia * 2) + 1]; - ia = ia + twidCoefModifier; + n1 = n2; + n2 = n2 >> 1; + ia = 0; - // loop for butterfly - for (i = j; i < fftLen; i += n1) - { - l = i + n2; - xt = pSrc[2 * i] - pSrc[2 * l]; - pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]) >> 1U; + cosVal = pCoef[ia * 2]; + sinVal = pCoef[(ia * 2) + 1]; + ia = ia + twidCoefModifier; - yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; - pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]) >> 1U; + // loop for butterfly + for (i = 0; i < fftLen; i += n1) { + l = i + n2; + xt = pSrc[2 * i] - pSrc[2 * l]; + pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]); - mult_32x32_keep32_R(p0, xt, cosVal); - mult_32x32_keep32_R(p1, yt, cosVal); - multSub_32x32_keep32_R(p0, yt, sinVal); - multAcc_32x32_keep32_R(p1, xt, sinVal); + yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; + pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]); - pSrc[2U * l] = p0; - pSrc[2U * l + 1U] = p1; - } // butterfly loop end + pSrc[2U * l] = xt; - } // groups loop end + pSrc[2U * l + 1U] = yt; - twidCoefModifier = twidCoefModifier << 1U; - } // stages loop end + i += n1; + l = i + n2; - n1 = n2; - n2 = n2 >> 1; - ia = 0; + xt = pSrc[2 * i] - pSrc[2 * l]; + pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]); - cosVal = pCoef[ia * 2]; - sinVal = pCoef[(ia * 2) + 1]; - ia = ia + twidCoefModifier; + yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; + pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]); - // loop for butterfly - for (i = 0; i < fftLen; i += n1) - { - l = i + n2; - xt = pSrc[2 * i] - pSrc[2 * l]; - pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]); + pSrc[2U * l] = xt; - yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; - pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]); - - pSrc[2U * l] = xt; - - pSrc[2U * l + 1U] = yt; - - i += n1; - l = i + n2; - - xt = pSrc[2 * i] - pSrc[2 * l]; - pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]); - - yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; - pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]); - - pSrc[2U * l] = xt; - - pSrc[2U * l + 1U] = yt; - - } // butterfly loop end + pSrc[2U * l + 1U] = yt; + } // butterfly loop end } diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_f32.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_f32.c index 9629145..046460a 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_f32.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_f32.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_radix4_f32.c - * Description: Radix-4 Decimation in Frequency CFFT & CIFFT Floating point processing function + * Description: Radix-4 Decimation in Frequency CFFT & CIFFT Floating point + * processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -28,25 +29,18 @@ #include "arm_math.h" -extern void arm_bitreversal_f32( - float32_t * pSrc, - uint16_t fftSize, - uint16_t bitRevFactor, - const uint16_t * pBitRevTab); +extern void arm_bitreversal_f32(float32_t *pSrc, uint16_t fftSize, + uint16_t bitRevFactor, + const uint16_t *pBitRevTab); -void arm_radix4_butterfly_f32( - float32_t * pSrc, - uint16_t fftLen, - const float32_t * pCoef, - uint16_t twidCoefModifier); - -void arm_radix4_butterfly_inverse_f32( - float32_t * pSrc, - uint16_t fftLen, - const float32_t * pCoef, - uint16_t twidCoefModifier, - float32_t onebyfftLen); +void arm_radix4_butterfly_f32(float32_t *pSrc, uint16_t fftLen, + const float32_t *pCoef, + uint16_t twidCoefModifier); +void arm_radix4_butterfly_inverse_f32(float32_t *pSrc, uint16_t fftLen, + const float32_t *pCoef, + uint16_t twidCoefModifier, + float32_t onebyfftLen); /** @ingroup groupTransforms @@ -59,33 +53,30 @@ void arm_radix4_butterfly_inverse_f32( /** @brief Processing function for the floating-point Radix-4 CFFT/CIFFT. - @deprecated Do not use this function. It has been superseded by \ref arm_cfft_f32 and will be removed in the future. - @param[in] S points to an instance of the floating-point Radix-4 CFFT/CIFFT structure - @param[in,out] pSrc points to the complex data buffer of size 2*fftLen. Processing occurs in-place + @deprecated Do not use this function. It has been superseded by \ref + arm_cfft_f32 and will be removed in the future. + @param[in] S points to an instance of the floating-point Radix-4 + CFFT/CIFFT structure + @param[in,out] pSrc points to the complex data buffer of size + 2*fftLen. Processing occurs in-place @return none */ -void arm_cfft_radix4_f32( - const arm_cfft_radix4_instance_f32 * S, - float32_t * pSrc) -{ - if (S->ifftFlag == 1U) - { - /* Complex IFFT radix-4 */ - arm_radix4_butterfly_inverse_f32(pSrc, S->fftLen, S->pTwiddle, S->twidCoefModifier, S->onebyfftLen); - } - else - { - /* Complex FFT radix-4 */ - arm_radix4_butterfly_f32(pSrc, S->fftLen, S->pTwiddle, S->twidCoefModifier); - } - - if (S->bitReverseFlag == 1U) - { - /* Bit Reversal */ - arm_bitreversal_f32(pSrc, S->fftLen, S->bitRevFactor, S->pBitRevTable); - } +void arm_cfft_radix4_f32(const arm_cfft_radix4_instance_f32 *S, + float32_t *pSrc) { + if (S->ifftFlag == 1U) { + /* Complex IFFT radix-4 */ + arm_radix4_butterfly_inverse_f32(pSrc, S->fftLen, S->pTwiddle, + S->twidCoefModifier, S->onebyfftLen); + } else { + /* Complex FFT radix-4 */ + arm_radix4_butterfly_f32(pSrc, S->fftLen, S->pTwiddle, S->twidCoefModifier); + } + if (S->bitReverseFlag == 1U) { + /* Bit Reversal */ + arm_bitreversal_f32(pSrc, S->fftLen, S->bitRevFactor, S->pBitRevTable); + } } /** @@ -98,1103 +89,1081 @@ void arm_cfft_radix4_f32( /** brief Core function for the floating-point CFFT butterfly process. - param[in,out] pSrc points to the in-place buffer of floating-point data type - param[in] fftLen length of the FFT - param[in] pCoef points to the twiddle coefficient buffer - param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table - return none + param[in,out] pSrc points to the in-place buffer of floating-point + data type param[in] fftLen length of the FFT param[in] pCoef + points to the twiddle coefficient buffer param[in] twidCoefModifier + twiddle coefficient modifier that supports different size FFTs with the same + twiddle factor table return none */ -void arm_radix4_butterfly_f32( - float32_t * pSrc, - uint16_t fftLen, - const float32_t * pCoef, - uint16_t twidCoefModifier) -{ - float32_t co1, co2, co3, si1, si2, si3; - uint32_t ia1, ia2, ia3; - uint32_t i0, i1, i2, i3; - uint32_t n1, n2, j, k; +void arm_radix4_butterfly_f32(float32_t *pSrc, uint16_t fftLen, + const float32_t *pCoef, + uint16_t twidCoefModifier) { + float32_t co1, co2, co3, si1, si2, si3; + uint32_t ia1, ia2, ia3; + uint32_t i0, i1, i2, i3; + uint32_t n1, n2, j, k; -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) - float32_t xaIn, yaIn, xbIn, ybIn, xcIn, ycIn, xdIn, ydIn; - float32_t Xaplusc, Xbplusd, Yaplusc, Ybplusd, Xaminusc, Xbminusd, Yaminusc, - Ybminusd; - float32_t Xb12C_out, Yb12C_out, Xc12C_out, Yc12C_out, Xd12C_out, Yd12C_out; - float32_t Xb12_out, Yb12_out, Xc12_out, Yc12_out, Xd12_out, Yd12_out; - float32_t *ptr1; - float32_t p0,p1,p2,p3,p4,p5; - float32_t a0,a1,a2,a3,a4,a5,a6,a7; + float32_t xaIn, yaIn, xbIn, ybIn, xcIn, ycIn, xdIn, ydIn; + float32_t Xaplusc, Xbplusd, Yaplusc, Ybplusd, Xaminusc, Xbminusd, Yaminusc, + Ybminusd; + float32_t Xb12C_out, Yb12C_out, Xc12C_out, Yc12C_out, Xd12C_out, Yd12C_out; + float32_t Xb12_out, Yb12_out, Xc12_out, Yc12_out, Xd12_out, Yd12_out; + float32_t *ptr1; + float32_t p0, p1, p2, p3, p4, p5; + float32_t a0, a1, a2, a3, a4, a5, a6, a7; - /* Initializations for the first stage */ - n2 = fftLen; - n1 = n2; + /* Initializations for the first stage */ + n2 = fftLen; + n1 = n2; - /* n2 = fftLen/4 */ - n2 >>= 2U; - i0 = 0U; - ia1 = 0U; + /* n2 = fftLen/4 */ + n2 >>= 2U; + i0 = 0U; + ia1 = 0U; - j = n2; + j = n2; - /* Calculation of first stage */ - do - { - /* index calculation for the input as, */ - /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ - i1 = i0 + n2; - i2 = i1 + n2; - i3 = i2 + n2; + /* Calculation of first stage */ + do { + /* index calculation for the input as, */ + /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + + * 3fftLen/4] */ + i1 = i0 + n2; + i2 = i1 + n2; + i3 = i2 + n2; - xaIn = pSrc[(2U * i0)]; - yaIn = pSrc[(2U * i0) + 1U]; + xaIn = pSrc[(2U * i0)]; + yaIn = pSrc[(2U * i0) + 1U]; - xbIn = pSrc[(2U * i1)]; - ybIn = pSrc[(2U * i1) + 1U]; + xbIn = pSrc[(2U * i1)]; + ybIn = pSrc[(2U * i1) + 1U]; - xcIn = pSrc[(2U * i2)]; - ycIn = pSrc[(2U * i2) + 1U]; + xcIn = pSrc[(2U * i2)]; + ycIn = pSrc[(2U * i2) + 1U]; - xdIn = pSrc[(2U * i3)]; - ydIn = pSrc[(2U * i3) + 1U]; + xdIn = pSrc[(2U * i3)]; + ydIn = pSrc[(2U * i3) + 1U]; - /* xa + xc */ - Xaplusc = xaIn + xcIn; - /* xb + xd */ - Xbplusd = xbIn + xdIn; - /* ya + yc */ - Yaplusc = yaIn + ycIn; - /* yb + yd */ - Ybplusd = ybIn + ydIn; + /* xa + xc */ + Xaplusc = xaIn + xcIn; + /* xb + xd */ + Xbplusd = xbIn + xdIn; + /* ya + yc */ + Yaplusc = yaIn + ycIn; + /* yb + yd */ + Ybplusd = ybIn + ydIn; + /* index calculation for the coefficients */ + ia2 = ia1 + ia1; + co2 = pCoef[ia2 * 2U]; + si2 = pCoef[(ia2 * 2U) + 1U]; + + /* xa - xc */ + Xaminusc = xaIn - xcIn; + /* xb - xd */ + Xbminusd = xbIn - xdIn; + /* ya - yc */ + Yaminusc = yaIn - ycIn; + /* yb - yd */ + Ybminusd = ybIn - ydIn; + + /* xa' = xa + xb + xc + xd */ + pSrc[(2U * i0)] = Xaplusc + Xbplusd; + /* ya' = ya + yb + yc + yd */ + pSrc[(2U * i0) + 1U] = Yaplusc + Ybplusd; + + /* (xa - xc) + (yb - yd) */ + Xb12C_out = (Xaminusc + Ybminusd); + /* (ya - yc) + (xb - xd) */ + Yb12C_out = (Yaminusc - Xbminusd); + /* (xa + xc) - (xb + xd) */ + Xc12C_out = (Xaplusc - Xbplusd); + /* (ya + yc) - (yb + yd) */ + Yc12C_out = (Yaplusc - Ybplusd); + /* (xa - xc) - (yb - yd) */ + Xd12C_out = (Xaminusc - Ybminusd); + /* (ya - yc) + (xb - xd) */ + Yd12C_out = (Xbminusd + Yaminusc); + + co1 = pCoef[ia1 * 2U]; + si1 = pCoef[(ia1 * 2U) + 1U]; + + /* index calculation for the coefficients */ + ia3 = ia2 + ia1; + co3 = pCoef[ia3 * 2U]; + si3 = pCoef[(ia3 * 2U) + 1U]; + + Xb12_out = Xb12C_out * co1; + Yb12_out = Yb12C_out * co1; + Xc12_out = Xc12C_out * co2; + Yc12_out = Yc12C_out * co2; + Xd12_out = Xd12C_out * co3; + Yd12_out = Yd12C_out * co3; + + /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ + // Xb12_out -= Yb12C_out * si1; + p0 = Yb12C_out * si1; + /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ + // Yb12_out += Xb12C_out * si1; + p1 = Xb12C_out * si1; + /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ + // Xc12_out -= Yc12C_out * si2; + p2 = Yc12C_out * si2; + /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ + // Yc12_out += Xc12C_out * si2; + p3 = Xc12C_out * si2; + /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ + // Xd12_out -= Yd12C_out * si3; + p4 = Yd12C_out * si3; + /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ + // Yd12_out += Xd12C_out * si3; + p5 = Xd12C_out * si3; + + Xb12_out += p0; + Yb12_out -= p1; + Xc12_out += p2; + Yc12_out -= p3; + Xd12_out += p4; + Yd12_out -= p5; + + /* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */ + pSrc[2U * i1] = Xc12_out; + + /* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */ + pSrc[(2U * i1) + 1U] = Yc12_out; + + /* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */ + pSrc[2U * i2] = Xb12_out; + + /* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */ + pSrc[(2U * i2) + 1U] = Yb12_out; + + /* xd' = (xa-yb-xc+yd)co3 + (ya+xb-yc-xd)(si3) */ + pSrc[2U * i3] = Xd12_out; + + /* yd' = (ya+xb-yc-xd)co3 - (xa-yb-xc+yd)(si3) */ + pSrc[(2U * i3) + 1U] = Yd12_out; + + /* Twiddle coefficients index modifier */ + ia1 += twidCoefModifier; + + /* Updating input index */ + i0++; + + } while (--j); + + twidCoefModifier <<= 2U; + + /* Calculation of second stage to excluding last stage */ + for (k = fftLen >> 2U; k > 4U; k >>= 2U) { + /* Initializations for the first stage */ + n1 = n2; + n2 >>= 2U; + ia1 = 0U; + + /* Calculation of first stage */ + j = 0; + do { /* index calculation for the coefficients */ ia2 = ia1 + ia1; - co2 = pCoef[ia2 * 2U]; - si2 = pCoef[(ia2 * 2U) + 1U]; - - /* xa - xc */ - Xaminusc = xaIn - xcIn; - /* xb - xd */ - Xbminusd = xbIn - xdIn; - /* ya - yc */ - Yaminusc = yaIn - ycIn; - /* yb - yd */ - Ybminusd = ybIn - ydIn; - - /* xa' = xa + xb + xc + xd */ - pSrc[(2U * i0)] = Xaplusc + Xbplusd; - /* ya' = ya + yb + yc + yd */ - pSrc[(2U * i0) + 1U] = Yaplusc + Ybplusd; - - /* (xa - xc) + (yb - yd) */ - Xb12C_out = (Xaminusc + Ybminusd); - /* (ya - yc) + (xb - xd) */ - Yb12C_out = (Yaminusc - Xbminusd); - /* (xa + xc) - (xb + xd) */ - Xc12C_out = (Xaplusc - Xbplusd); - /* (ya + yc) - (yb + yd) */ - Yc12C_out = (Yaplusc - Ybplusd); - /* (xa - xc) - (yb - yd) */ - Xd12C_out = (Xaminusc - Ybminusd); - /* (ya - yc) + (xb - xd) */ - Yd12C_out = (Xbminusd + Yaminusc); - - co1 = pCoef[ia1 * 2U]; - si1 = pCoef[(ia1 * 2U) + 1U]; - - /* index calculation for the coefficients */ ia3 = ia2 + ia1; - co3 = pCoef[ia3 * 2U]; + co1 = pCoef[(ia1 * 2U)]; + si1 = pCoef[(ia1 * 2U) + 1U]; + co2 = pCoef[(ia2 * 2U)]; + si2 = pCoef[(ia2 * 2U) + 1U]; + co3 = pCoef[(ia3 * 2U)]; si3 = pCoef[(ia3 * 2U) + 1U]; - Xb12_out = Xb12C_out * co1; - Yb12_out = Yb12C_out * co1; - Xc12_out = Xc12C_out * co2; - Yc12_out = Yc12C_out * co2; - Xd12_out = Xd12C_out * co3; - Yd12_out = Yd12C_out * co3; - - /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ - //Xb12_out -= Yb12C_out * si1; - p0 = Yb12C_out * si1; - /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ - //Yb12_out += Xb12C_out * si1; - p1 = Xb12C_out * si1; - /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ - //Xc12_out -= Yc12C_out * si2; - p2 = Yc12C_out * si2; - /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ - //Yc12_out += Xc12C_out * si2; - p3 = Xc12C_out * si2; - /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ - //Xd12_out -= Yd12C_out * si3; - p4 = Yd12C_out * si3; - /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ - //Yd12_out += Xd12C_out * si3; - p5 = Xd12C_out * si3; - - Xb12_out += p0; - Yb12_out -= p1; - Xc12_out += p2; - Yc12_out -= p3; - Xd12_out += p4; - Yd12_out -= p5; - - /* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */ - pSrc[2U * i1] = Xc12_out; - - /* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */ - pSrc[(2U * i1) + 1U] = Yc12_out; - - /* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */ - pSrc[2U * i2] = Xb12_out; - - /* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */ - pSrc[(2U * i2) + 1U] = Yb12_out; - - /* xd' = (xa-yb-xc+yd)co3 + (ya+xb-yc-xd)(si3) */ - pSrc[2U * i3] = Xd12_out; - - /* yd' = (ya+xb-yc-xd)co3 - (xa-yb-xc+yd)(si3) */ - pSrc[(2U * i3) + 1U] = Yd12_out; - /* Twiddle coefficients index modifier */ ia1 += twidCoefModifier; - /* Updating input index */ - i0++; + i0 = j; + do { + /* index calculation for the input as, */ + /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + + * 3fftLen/4] */ + i1 = i0 + n2; + i2 = i1 + n2; + i3 = i2 + n2; - } - while (--j); + xaIn = pSrc[(2U * i0)]; + yaIn = pSrc[(2U * i0) + 1U]; - twidCoefModifier <<= 2U; + xbIn = pSrc[(2U * i1)]; + ybIn = pSrc[(2U * i1) + 1U]; - /* Calculation of second stage to excluding last stage */ - for (k = fftLen >> 2U; k > 4U; k >>= 2U) - { - /* Initializations for the first stage */ - n1 = n2; - n2 >>= 2U; - ia1 = 0U; + xcIn = pSrc[(2U * i2)]; + ycIn = pSrc[(2U * i2) + 1U]; - /* Calculation of first stage */ - j = 0; - do - { - /* index calculation for the coefficients */ - ia2 = ia1 + ia1; - ia3 = ia2 + ia1; - co1 = pCoef[(ia1 * 2U)]; - si1 = pCoef[(ia1 * 2U) + 1U]; - co2 = pCoef[(ia2 * 2U)]; - si2 = pCoef[(ia2 * 2U) + 1U]; - co3 = pCoef[(ia3 * 2U)]; - si3 = pCoef[(ia3 * 2U) + 1U]; + xdIn = pSrc[(2U * i3)]; + ydIn = pSrc[(2U * i3) + 1U]; - /* Twiddle coefficients index modifier */ - ia1 += twidCoefModifier; + /* xa - xc */ + Xaminusc = xaIn - xcIn; + /* (xb - xd) */ + Xbminusd = xbIn - xdIn; + /* ya - yc */ + Yaminusc = yaIn - ycIn; + /* (yb - yd) */ + Ybminusd = ybIn - ydIn; - i0 = j; - do - { - /* index calculation for the input as, */ - /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ - i1 = i0 + n2; - i2 = i1 + n2; - i3 = i2 + n2; + /* xa + xc */ + Xaplusc = xaIn + xcIn; + /* xb + xd */ + Xbplusd = xbIn + xdIn; + /* ya + yc */ + Yaplusc = yaIn + ycIn; + /* yb + yd */ + Ybplusd = ybIn + ydIn; - xaIn = pSrc[(2U * i0)]; - yaIn = pSrc[(2U * i0) + 1U]; + /* (xa - xc) + (yb - yd) */ + Xb12C_out = (Xaminusc + Ybminusd); + /* (ya - yc) - (xb - xd) */ + Yb12C_out = (Yaminusc - Xbminusd); + /* xa + xc -(xb + xd) */ + Xc12C_out = (Xaplusc - Xbplusd); + /* (ya + yc) - (yb + yd) */ + Yc12C_out = (Yaplusc - Ybplusd); + /* (xa - xc) - (yb - yd) */ + Xd12C_out = (Xaminusc - Ybminusd); + /* (ya - yc) + (xb - xd) */ + Yd12C_out = (Xbminusd + Yaminusc); - xbIn = pSrc[(2U * i1)]; - ybIn = pSrc[(2U * i1) + 1U]; + pSrc[(2U * i0)] = Xaplusc + Xbplusd; + pSrc[(2U * i0) + 1U] = Yaplusc + Ybplusd; - xcIn = pSrc[(2U * i2)]; - ycIn = pSrc[(2U * i2) + 1U]; + Xb12_out = Xb12C_out * co1; + Yb12_out = Yb12C_out * co1; + Xc12_out = Xc12C_out * co2; + Yc12_out = Yc12C_out * co2; + Xd12_out = Xd12C_out * co3; + Yd12_out = Yd12C_out * co3; - xdIn = pSrc[(2U * i3)]; - ydIn = pSrc[(2U * i3) + 1U]; + /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ + // Xb12_out -= Yb12C_out * si1; + p0 = Yb12C_out * si1; + /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ + // Yb12_out += Xb12C_out * si1; + p1 = Xb12C_out * si1; + /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ + // Xc12_out -= Yc12C_out * si2; + p2 = Yc12C_out * si2; + /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ + // Yc12_out += Xc12C_out * si2; + p3 = Xc12C_out * si2; + /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ + // Xd12_out -= Yd12C_out * si3; + p4 = Yd12C_out * si3; + /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ + // Yd12_out += Xd12C_out * si3; + p5 = Xd12C_out * si3; - /* xa - xc */ - Xaminusc = xaIn - xcIn; - /* (xb - xd) */ - Xbminusd = xbIn - xdIn; - /* ya - yc */ - Yaminusc = yaIn - ycIn; - /* (yb - yd) */ - Ybminusd = ybIn - ydIn; + Xb12_out += p0; + Yb12_out -= p1; + Xc12_out += p2; + Yc12_out -= p3; + Xd12_out += p4; + Yd12_out -= p5; - /* xa + xc */ - Xaplusc = xaIn + xcIn; - /* xb + xd */ - Xbplusd = xbIn + xdIn; - /* ya + yc */ - Yaplusc = yaIn + ycIn; - /* yb + yd */ - Ybplusd = ybIn + ydIn; + /* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */ + pSrc[2U * i1] = Xc12_out; - /* (xa - xc) + (yb - yd) */ - Xb12C_out = (Xaminusc + Ybminusd); - /* (ya - yc) - (xb - xd) */ - Yb12C_out = (Yaminusc - Xbminusd); - /* xa + xc -(xb + xd) */ - Xc12C_out = (Xaplusc - Xbplusd); - /* (ya + yc) - (yb + yd) */ - Yc12C_out = (Yaplusc - Ybplusd); - /* (xa - xc) - (yb - yd) */ - Xd12C_out = (Xaminusc - Ybminusd); - /* (ya - yc) + (xb - xd) */ - Yd12C_out = (Xbminusd + Yaminusc); + /* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */ + pSrc[(2U * i1) + 1U] = Yc12_out; - pSrc[(2U * i0)] = Xaplusc + Xbplusd; - pSrc[(2U * i0) + 1U] = Yaplusc + Ybplusd; + /* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */ + pSrc[2U * i2] = Xb12_out; - Xb12_out = Xb12C_out * co1; - Yb12_out = Yb12C_out * co1; - Xc12_out = Xc12C_out * co2; - Yc12_out = Yc12C_out * co2; - Xd12_out = Xd12C_out * co3; - Yd12_out = Yd12C_out * co3; + /* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */ + pSrc[(2U * i2) + 1U] = Yb12_out; - /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ - //Xb12_out -= Yb12C_out * si1; - p0 = Yb12C_out * si1; - /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ - //Yb12_out += Xb12C_out * si1; - p1 = Xb12C_out * si1; - /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ - //Xc12_out -= Yc12C_out * si2; - p2 = Yc12C_out * si2; - /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ - //Yc12_out += Xc12C_out * si2; - p3 = Xc12C_out * si2; - /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ - //Xd12_out -= Yd12C_out * si3; - p4 = Yd12C_out * si3; - /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ - //Yd12_out += Xd12C_out * si3; - p5 = Xd12C_out * si3; + /* xd' = (xa-yb-xc+yd)co3 + (ya+xb-yc-xd)(si3) */ + pSrc[2U * i3] = Xd12_out; - Xb12_out += p0; - Yb12_out -= p1; - Xc12_out += p2; - Yc12_out -= p3; - Xd12_out += p4; - Yd12_out -= p5; + /* yd' = (ya+xb-yc-xd)co3 - (xa-yb-xc+yd)(si3) */ + pSrc[(2U * i3) + 1U] = Yd12_out; - /* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */ - pSrc[2U * i1] = Xc12_out; + i0 += n1; + } while (i0 < fftLen); + j++; + } while (j <= (n2 - 1U)); + twidCoefModifier <<= 2U; + } - /* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */ - pSrc[(2U * i1) + 1U] = Yc12_out; + j = fftLen >> 2; + ptr1 = &pSrc[0]; - /* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */ - pSrc[2U * i2] = Xb12_out; + /* Calculations of last stage */ + do { + xaIn = ptr1[0]; + yaIn = ptr1[1]; + xbIn = ptr1[2]; + ybIn = ptr1[3]; + xcIn = ptr1[4]; + ycIn = ptr1[5]; + xdIn = ptr1[6]; + ydIn = ptr1[7]; - /* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */ - pSrc[(2U * i2) + 1U] = Yb12_out; + /* xa + xc */ + Xaplusc = xaIn + xcIn; - /* xd' = (xa-yb-xc+yd)co3 + (ya+xb-yc-xd)(si3) */ - pSrc[2U * i3] = Xd12_out; + /* xa - xc */ + Xaminusc = xaIn - xcIn; - /* yd' = (ya+xb-yc-xd)co3 - (xa-yb-xc+yd)(si3) */ - pSrc[(2U * i3) + 1U] = Yd12_out; + /* ya + yc */ + Yaplusc = yaIn + ycIn; - i0 += n1; - } while (i0 < fftLen); - j++; - } while (j <= (n2 - 1U)); - twidCoefModifier <<= 2U; - } + /* ya - yc */ + Yaminusc = yaIn - ycIn; - j = fftLen >> 2; - ptr1 = &pSrc[0]; + /* xb + xd */ + Xbplusd = xbIn + xdIn; - /* Calculations of last stage */ - do - { - xaIn = ptr1[0]; - yaIn = ptr1[1]; - xbIn = ptr1[2]; - ybIn = ptr1[3]; - xcIn = ptr1[4]; - ycIn = ptr1[5]; - xdIn = ptr1[6]; - ydIn = ptr1[7]; + /* yb + yd */ + Ybplusd = ybIn + ydIn; - /* xa + xc */ - Xaplusc = xaIn + xcIn; + /* (xb-xd) */ + Xbminusd = xbIn - xdIn; - /* xa - xc */ - Xaminusc = xaIn - xcIn; + /* (yb-yd) */ + Ybminusd = ybIn - ydIn; - /* ya + yc */ - Yaplusc = yaIn + ycIn; + /* xa' = xa + xb + xc + xd */ + a0 = (Xaplusc + Xbplusd); + /* ya' = ya + yb + yc + yd */ + a1 = (Yaplusc + Ybplusd); + /* xc' = (xa-xb+xc-xd) */ + a2 = (Xaplusc - Xbplusd); + /* yc' = (ya-yb+yc-yd) */ + a3 = (Yaplusc - Ybplusd); + /* xb' = (xa+yb-xc-yd) */ + a4 = (Xaminusc + Ybminusd); + /* yb' = (ya-xb-yc+xd) */ + a5 = (Yaminusc - Xbminusd); + /* xd' = (xa-yb-xc+yd)) */ + a6 = (Xaminusc - Ybminusd); + /* yd' = (ya+xb-yc-xd) */ + a7 = (Xbminusd + Yaminusc); - /* ya - yc */ - Yaminusc = yaIn - ycIn; + ptr1[0] = a0; + ptr1[1] = a1; + ptr1[2] = a2; + ptr1[3] = a3; + ptr1[4] = a4; + ptr1[5] = a5; + ptr1[6] = a6; + ptr1[7] = a7; - /* xb + xd */ - Xbplusd = xbIn + xdIn; - - /* yb + yd */ - Ybplusd = ybIn + ydIn; - - /* (xb-xd) */ - Xbminusd = xbIn - xdIn; - - /* (yb-yd) */ - Ybminusd = ybIn - ydIn; - - /* xa' = xa + xb + xc + xd */ - a0 = (Xaplusc + Xbplusd); - /* ya' = ya + yb + yc + yd */ - a1 = (Yaplusc + Ybplusd); - /* xc' = (xa-xb+xc-xd) */ - a2 = (Xaplusc - Xbplusd); - /* yc' = (ya-yb+yc-yd) */ - a3 = (Yaplusc - Ybplusd); - /* xb' = (xa+yb-xc-yd) */ - a4 = (Xaminusc + Ybminusd); - /* yb' = (ya-xb-yc+xd) */ - a5 = (Yaminusc - Xbminusd); - /* xd' = (xa-yb-xc+yd)) */ - a6 = (Xaminusc - Ybminusd); - /* yd' = (ya+xb-yc-xd) */ - a7 = (Xbminusd + Yaminusc); - - ptr1[0] = a0; - ptr1[1] = a1; - ptr1[2] = a2; - ptr1[3] = a3; - ptr1[4] = a4; - ptr1[5] = a5; - ptr1[6] = a6; - ptr1[7] = a7; - - /* increment pointer by 8 */ - ptr1 += 8U; - } while (--j); + /* increment pointer by 8 */ + ptr1 += 8U; + } while (--j); #else - float32_t t1, t2, r1, r2, s1, s2; + float32_t t1, t2, r1, r2, s1, s2; - /* Initializations for the fft calculation */ - n2 = fftLen; - n1 = n2; - for (k = fftLen; k > 1U; k >>= 2U) - { - /* Initializations for the fft calculation */ - n1 = n2; - n2 >>= 2U; - ia1 = 0U; - - /* FFT Calculation */ - j = 0; - do - { - /* index calculation for the coefficients */ - ia2 = ia1 + ia1; - ia3 = ia2 + ia1; - co1 = pCoef[ia1 * 2U]; - si1 = pCoef[(ia1 * 2U) + 1U]; - co2 = pCoef[ia2 * 2U]; - si2 = pCoef[(ia2 * 2U) + 1U]; - co3 = pCoef[ia3 * 2U]; - si3 = pCoef[(ia3 * 2U) + 1U]; - - /* Twiddle coefficients index modifier */ - ia1 = ia1 + twidCoefModifier; - - i0 = j; - do - { - /* index calculation for the input as, */ - /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ - i1 = i0 + n2; - i2 = i1 + n2; - i3 = i2 + n2; - - /* xa + xc */ - r1 = pSrc[(2U * i0)] + pSrc[(2U * i2)]; - - /* xa - xc */ - r2 = pSrc[(2U * i0)] - pSrc[(2U * i2)]; - - /* ya + yc */ - s1 = pSrc[(2U * i0) + 1U] + pSrc[(2U * i2) + 1U]; - - /* ya - yc */ - s2 = pSrc[(2U * i0) + 1U] - pSrc[(2U * i2) + 1U]; - - /* xb + xd */ - t1 = pSrc[2U * i1] + pSrc[2U * i3]; - - /* xa' = xa + xb + xc + xd */ - pSrc[2U * i0] = r1 + t1; - - /* xa + xc -(xb + xd) */ - r1 = r1 - t1; - - /* yb + yd */ - t2 = pSrc[(2U * i1) + 1U] + pSrc[(2U * i3) + 1U]; - - /* ya' = ya + yb + yc + yd */ - pSrc[(2U * i0) + 1U] = s1 + t2; - - /* (ya + yc) - (yb + yd) */ - s1 = s1 - t2; - - /* (yb - yd) */ - t1 = pSrc[(2U * i1) + 1U] - pSrc[(2U * i3) + 1U]; - - /* (xb - xd) */ - t2 = pSrc[2U * i1] - pSrc[2U * i3]; - - /* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */ - pSrc[2U * i1] = (r1 * co2) + (s1 * si2); - - /* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */ - pSrc[(2U * i1) + 1U] = (s1 * co2) - (r1 * si2); - - /* (xa - xc) + (yb - yd) */ - r1 = r2 + t1; - - /* (xa - xc) - (yb - yd) */ - r2 = r2 - t1; - - /* (ya - yc) - (xb - xd) */ - s1 = s2 - t2; - - /* (ya - yc) + (xb - xd) */ - s2 = s2 + t2; - - /* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */ - pSrc[2U * i2] = (r1 * co1) + (s1 * si1); - - /* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */ - pSrc[(2U * i2) + 1U] = (s1 * co1) - (r1 * si1); - - /* xd' = (xa-yb-xc+yd)co3 + (ya+xb-yc-xd)(si3) */ - pSrc[2U * i3] = (r2 * co3) + (s2 * si3); - - /* yd' = (ya+xb-yc-xd)co3 - (xa-yb-xc+yd)(si3) */ - pSrc[(2U * i3) + 1U] = (s2 * co3) - (r2 * si3); - - i0 += n1; - } while ( i0 < fftLen); - j++; - } while (j <= (n2 - 1U)); - twidCoefModifier <<= 2U; - } - -#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - -} - -/** - brief Core function for the floating-point CIFFT butterfly process. - param[in,out] pSrc points to the in-place buffer of floating-point data type - param[in] fftLen length of the FFT - param[in] pCoef points to twiddle coefficient buffer - param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. - param[in] onebyfftLen value of 1/fftLen - return none - */ - -void arm_radix4_butterfly_inverse_f32( - float32_t * pSrc, - uint16_t fftLen, - const float32_t * pCoef, - uint16_t twidCoefModifier, - float32_t onebyfftLen) -{ - float32_t co1, co2, co3, si1, si2, si3; - uint32_t ia1, ia2, ia3; - uint32_t i0, i1, i2, i3; - uint32_t n1, n2, j, k; - -#if defined (ARM_MATH_LOOPUNROLL) - - float32_t xaIn, yaIn, xbIn, ybIn, xcIn, ycIn, xdIn, ydIn; - float32_t Xaplusc, Xbplusd, Yaplusc, Ybplusd, Xaminusc, Xbminusd, Yaminusc, - Ybminusd; - float32_t Xb12C_out, Yb12C_out, Xc12C_out, Yc12C_out, Xd12C_out, Yd12C_out; - float32_t Xb12_out, Yb12_out, Xc12_out, Yc12_out, Xd12_out, Yd12_out; - float32_t *ptr1; - float32_t p0,p1,p2,p3,p4,p5,p6,p7; - float32_t a0,a1,a2,a3,a4,a5,a6,a7; - - - /* Initializations for the first stage */ - n2 = fftLen; - n1 = n2; - - /* n2 = fftLen/4 */ - n2 >>= 2U; - i0 = 0U; - ia1 = 0U; - - j = n2; - - /* Calculation of first stage */ - do - { - /* index calculation for the input as, */ - /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ - i1 = i0 + n2; - i2 = i1 + n2; - i3 = i2 + n2; - - /* Butterfly implementation */ - xaIn = pSrc[(2U * i0)]; - yaIn = pSrc[(2U * i0) + 1U]; - - xcIn = pSrc[(2U * i2)]; - ycIn = pSrc[(2U * i2) + 1U]; - - xbIn = pSrc[(2U * i1)]; - ybIn = pSrc[(2U * i1) + 1U]; - - xdIn = pSrc[(2U * i3)]; - ydIn = pSrc[(2U * i3) + 1U]; - - /* xa + xc */ - Xaplusc = xaIn + xcIn; - /* xb + xd */ - Xbplusd = xbIn + xdIn; - /* ya + yc */ - Yaplusc = yaIn + ycIn; - /* yb + yd */ - Ybplusd = ybIn + ydIn; + /* Initializations for the fft calculation */ + n2 = fftLen; + n1 = n2; + for (k = fftLen; k > 1U; k >>= 2U) { + /* Initializations for the fft calculation */ + n1 = n2; + n2 >>= 2U; + ia1 = 0U; + /* FFT Calculation */ + j = 0; + do { /* index calculation for the coefficients */ ia2 = ia1 + ia1; - co2 = pCoef[ia2 * 2U]; - si2 = pCoef[(ia2 * 2U) + 1U]; - - /* xa - xc */ - Xaminusc = xaIn - xcIn; - /* xb - xd */ - Xbminusd = xbIn - xdIn; - /* ya - yc */ - Yaminusc = yaIn - ycIn; - /* yb - yd */ - Ybminusd = ybIn - ydIn; - - /* xa' = xa + xb + xc + xd */ - pSrc[(2U * i0)] = Xaplusc + Xbplusd; - - /* ya' = ya + yb + yc + yd */ - pSrc[(2U * i0) + 1U] = Yaplusc + Ybplusd; - - /* (xa - xc) - (yb - yd) */ - Xb12C_out = (Xaminusc - Ybminusd); - /* (ya - yc) + (xb - xd) */ - Yb12C_out = (Yaminusc + Xbminusd); - /* (xa + xc) - (xb + xd) */ - Xc12C_out = (Xaplusc - Xbplusd); - /* (ya + yc) - (yb + yd) */ - Yc12C_out = (Yaplusc - Ybplusd); - /* (xa - xc) + (yb - yd) */ - Xd12C_out = (Xaminusc + Ybminusd); - /* (ya - yc) - (xb - xd) */ - Yd12C_out = (Yaminusc - Xbminusd); - + ia3 = ia2 + ia1; co1 = pCoef[ia1 * 2U]; si1 = pCoef[(ia1 * 2U) + 1U]; - - /* index calculation for the coefficients */ - ia3 = ia2 + ia1; + co2 = pCoef[ia2 * 2U]; + si2 = pCoef[(ia2 * 2U) + 1U]; co3 = pCoef[ia3 * 2U]; si3 = pCoef[(ia3 * 2U) + 1U]; - Xb12_out = Xb12C_out * co1; - Yb12_out = Yb12C_out * co1; - Xc12_out = Xc12C_out * co2; - Yc12_out = Yc12C_out * co2; - Xd12_out = Xd12C_out * co3; - Yd12_out = Yd12C_out * co3; - - /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ - //Xb12_out -= Yb12C_out * si1; - p0 = Yb12C_out * si1; - /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ - //Yb12_out += Xb12C_out * si1; - p1 = Xb12C_out * si1; - /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ - //Xc12_out -= Yc12C_out * si2; - p2 = Yc12C_out * si2; - /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ - //Yc12_out += Xc12C_out * si2; - p3 = Xc12C_out * si2; - /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ - //Xd12_out -= Yd12C_out * si3; - p4 = Yd12C_out * si3; - /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ - //Yd12_out += Xd12C_out * si3; - p5 = Xd12C_out * si3; - - Xb12_out -= p0; - Yb12_out += p1; - Xc12_out -= p2; - Yc12_out += p3; - Xd12_out -= p4; - Yd12_out += p5; - - /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ - pSrc[2U * i1] = Xc12_out; - - /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ - pSrc[(2U * i1) + 1U] = Yc12_out; - - /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ - pSrc[2U * i2] = Xb12_out; - - /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ - pSrc[(2U * i2) + 1U] = Yb12_out; - - /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ - pSrc[2U * i3] = Xd12_out; - - /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ - pSrc[(2U * i3) + 1U] = Yd12_out; - /* Twiddle coefficients index modifier */ ia1 = ia1 + twidCoefModifier; - /* Updating input index */ - i0 = i0 + 1U; + i0 = j; + do { + /* index calculation for the input as, */ + /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + + * 3fftLen/4] */ + i1 = i0 + n2; + i2 = i1 + n2; + i3 = i2 + n2; - } while (--j); + /* xa + xc */ + r1 = pSrc[(2U * i0)] + pSrc[(2U * i2)]; - twidCoefModifier <<= 2U; + /* xa - xc */ + r2 = pSrc[(2U * i0)] - pSrc[(2U * i2)]; - /* Calculation of second stage to excluding last stage */ - for (k = fftLen >> 2U; k > 4U; k >>= 2U) - { - /* Initializations for the first stage */ - n1 = n2; - n2 >>= 2U; - ia1 = 0U; + /* ya + yc */ + s1 = pSrc[(2U * i0) + 1U] + pSrc[(2U * i2) + 1U]; - /* Calculation of first stage */ - j = 0; - do - { - /* index calculation for the coefficients */ - ia2 = ia1 + ia1; - ia3 = ia2 + ia1; - co1 = pCoef[ia1 * 2U]; - si1 = pCoef[(ia1 * 2U) + 1U]; - co2 = pCoef[ia2 * 2U]; - si2 = pCoef[(ia2 * 2U) + 1U]; - co3 = pCoef[ia3 * 2U]; - si3 = pCoef[(ia3 * 2U) + 1U]; + /* ya - yc */ + s2 = pSrc[(2U * i0) + 1U] - pSrc[(2U * i2) + 1U]; - /* Twiddle coefficients index modifier */ - ia1 = ia1 + twidCoefModifier; + /* xb + xd */ + t1 = pSrc[2U * i1] + pSrc[2U * i3]; - i0 = j; - do - { - /* index calculation for the input as, */ - /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ - i1 = i0 + n2; - i2 = i1 + n2; - i3 = i2 + n2; + /* xa' = xa + xb + xc + xd */ + pSrc[2U * i0] = r1 + t1; - xaIn = pSrc[(2U * i0)]; - yaIn = pSrc[(2U * i0) + 1U]; + /* xa + xc -(xb + xd) */ + r1 = r1 - t1; - xbIn = pSrc[(2U * i1)]; - ybIn = pSrc[(2U * i1) + 1U]; + /* yb + yd */ + t2 = pSrc[(2U * i1) + 1U] + pSrc[(2U * i3) + 1U]; - xcIn = pSrc[(2U * i2)]; - ycIn = pSrc[(2U * i2) + 1U]; + /* ya' = ya + yb + yc + yd */ + pSrc[(2U * i0) + 1U] = s1 + t2; - xdIn = pSrc[(2U * i3)]; - ydIn = pSrc[(2U * i3) + 1U]; + /* (ya + yc) - (yb + yd) */ + s1 = s1 - t2; - /* xa - xc */ - Xaminusc = xaIn - xcIn; - /* (xb - xd) */ - Xbminusd = xbIn - xdIn; - /* ya - yc */ - Yaminusc = yaIn - ycIn; - /* (yb - yd) */ - Ybminusd = ybIn - ydIn; + /* (yb - yd) */ + t1 = pSrc[(2U * i1) + 1U] - pSrc[(2U * i3) + 1U]; - /* xa + xc */ - Xaplusc = xaIn + xcIn; - /* xb + xd */ - Xbplusd = xbIn + xdIn; - /* ya + yc */ - Yaplusc = yaIn + ycIn; - /* yb + yd */ - Ybplusd = ybIn + ydIn; + /* (xb - xd) */ + t2 = pSrc[2U * i1] - pSrc[2U * i3]; - /* (xa - xc) - (yb - yd) */ - Xb12C_out = (Xaminusc - Ybminusd); - /* (ya - yc) + (xb - xd) */ - Yb12C_out = (Yaminusc + Xbminusd); - /* xa + xc -(xb + xd) */ - Xc12C_out = (Xaplusc - Xbplusd); - /* (ya + yc) - (yb + yd) */ - Yc12C_out = (Yaplusc - Ybplusd); - /* (xa - xc) + (yb - yd) */ - Xd12C_out = (Xaminusc + Ybminusd); - /* (ya - yc) - (xb - xd) */ - Yd12C_out = (Yaminusc - Xbminusd); + /* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */ + pSrc[2U * i1] = (r1 * co2) + (s1 * si2); - pSrc[(2U * i0)] = Xaplusc + Xbplusd; - pSrc[(2U * i0) + 1U] = Yaplusc + Ybplusd; + /* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */ + pSrc[(2U * i1) + 1U] = (s1 * co2) - (r1 * si2); - Xb12_out = Xb12C_out * co1; - Yb12_out = Yb12C_out * co1; - Xc12_out = Xc12C_out * co2; - Yc12_out = Yc12C_out * co2; - Xd12_out = Xd12C_out * co3; - Yd12_out = Yd12C_out * co3; + /* (xa - xc) + (yb - yd) */ + r1 = r2 + t1; - /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ - //Xb12_out -= Yb12C_out * si1; - p0 = Yb12C_out * si1; - /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ - //Yb12_out += Xb12C_out * si1; - p1 = Xb12C_out * si1; - /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ - //Xc12_out -= Yc12C_out * si2; - p2 = Yc12C_out * si2; - /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ - //Yc12_out += Xc12C_out * si2; - p3 = Xc12C_out * si2; - /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ - //Xd12_out -= Yd12C_out * si3; - p4 = Yd12C_out * si3; - /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ - //Yd12_out += Xd12C_out * si3; - p5 = Xd12C_out * si3; + /* (xa - xc) - (yb - yd) */ + r2 = r2 - t1; - Xb12_out -= p0; - Yb12_out += p1; - Xc12_out -= p2; - Yc12_out += p3; - Xd12_out -= p4; - Yd12_out += p5; + /* (ya - yc) - (xb - xd) */ + s1 = s2 - t2; - /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ - pSrc[2U * i1] = Xc12_out; + /* (ya - yc) + (xb - xd) */ + s2 = s2 + t2; - /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ - pSrc[(2U * i1) + 1U] = Yc12_out; + /* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */ + pSrc[2U * i2] = (r1 * co1) + (s1 * si1); - /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ - pSrc[2U * i2] = Xb12_out; + /* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */ + pSrc[(2U * i2) + 1U] = (s1 * co1) - (r1 * si1); - /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ - pSrc[(2U * i2) + 1U] = Yb12_out; + /* xd' = (xa-yb-xc+yd)co3 + (ya+xb-yc-xd)(si3) */ + pSrc[2U * i3] = (r2 * co3) + (s2 * si3); - /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ - pSrc[2U * i3] = Xd12_out; + /* yd' = (ya+xb-yc-xd)co3 - (xa-yb-xc+yd)(si3) */ + pSrc[(2U * i3) + 1U] = (s2 * co3) - (r2 * si3); - /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ - pSrc[(2U * i3) + 1U] = Yd12_out; - - i0 += n1; - } while (i0 < fftLen); - j++; - } while (j <= (n2 - 1U)); - twidCoefModifier <<= 2U; - } - /* Initializations of last stage */ - - j = fftLen >> 2; - ptr1 = &pSrc[0]; - - /* Calculations of last stage */ - do - { - xaIn = ptr1[0]; - yaIn = ptr1[1]; - xbIn = ptr1[2]; - ybIn = ptr1[3]; - xcIn = ptr1[4]; - ycIn = ptr1[5]; - xdIn = ptr1[6]; - ydIn = ptr1[7]; - - /* Butterfly implementation */ - /* xa + xc */ - Xaplusc = xaIn + xcIn; - - /* xa - xc */ - Xaminusc = xaIn - xcIn; - - /* ya + yc */ - Yaplusc = yaIn + ycIn; - - /* ya - yc */ - Yaminusc = yaIn - ycIn; - - /* xb + xd */ - Xbplusd = xbIn + xdIn; - - /* yb + yd */ - Ybplusd = ybIn + ydIn; - - /* (xb-xd) */ - Xbminusd = xbIn - xdIn; - - /* (yb-yd) */ - Ybminusd = ybIn - ydIn; - - /* xa' = (xa+xb+xc+xd) * onebyfftLen */ - a0 = (Xaplusc + Xbplusd); - /* ya' = (ya+yb+yc+yd) * onebyfftLen */ - a1 = (Yaplusc + Ybplusd); - /* xc' = (xa-xb+xc-xd) * onebyfftLen */ - a2 = (Xaplusc - Xbplusd); - /* yc' = (ya-yb+yc-yd) * onebyfftLen */ - a3 = (Yaplusc - Ybplusd); - /* xb' = (xa-yb-xc+yd) * onebyfftLen */ - a4 = (Xaminusc - Ybminusd); - /* yb' = (ya+xb-yc-xd) * onebyfftLen */ - a5 = (Yaminusc + Xbminusd); - /* xd' = (xa-yb-xc+yd) * onebyfftLen */ - a6 = (Xaminusc + Ybminusd); - /* yd' = (ya-xb-yc+xd) * onebyfftLen */ - a7 = (Yaminusc - Xbminusd); - - p0 = a0 * onebyfftLen; - p1 = a1 * onebyfftLen; - p2 = a2 * onebyfftLen; - p3 = a3 * onebyfftLen; - p4 = a4 * onebyfftLen; - p5 = a5 * onebyfftLen; - p6 = a6 * onebyfftLen; - p7 = a7 * onebyfftLen; - - /* xa' = (xa+xb+xc+xd) * onebyfftLen */ - ptr1[0] = p0; - /* ya' = (ya+yb+yc+yd) * onebyfftLen */ - ptr1[1] = p1; - /* xc' = (xa-xb+xc-xd) * onebyfftLen */ - ptr1[2] = p2; - /* yc' = (ya-yb+yc-yd) * onebyfftLen */ - ptr1[3] = p3; - /* xb' = (xa-yb-xc+yd) * onebyfftLen */ - ptr1[4] = p4; - /* yb' = (ya+xb-yc-xd) * onebyfftLen */ - ptr1[5] = p5; - /* xd' = (xa-yb-xc+yd) * onebyfftLen */ - ptr1[6] = p6; - /* yd' = (ya-xb-yc+xd) * onebyfftLen */ - ptr1[7] = p7; - - /* increment source pointer by 8 for next calculations */ - ptr1 = ptr1 + 8U; - - } while (--j); - -#else - - float32_t t1, t2, r1, r2, s1, s2; - - /* Initializations for the first stage */ - n2 = fftLen; - n1 = n2; - - /* Calculation of first stage */ - for (k = fftLen; k > 4U; k >>= 2U) - { - /* Initializations for the first stage */ - n1 = n2; - n2 >>= 2U; - ia1 = 0U; - - /* Calculation of first stage */ - j = 0; - do - { - /* index calculation for the coefficients */ - ia2 = ia1 + ia1; - ia3 = ia2 + ia1; - co1 = pCoef[ia1 * 2U]; - si1 = pCoef[(ia1 * 2U) + 1U]; - co2 = pCoef[ia2 * 2U]; - si2 = pCoef[(ia2 * 2U) + 1U]; - co3 = pCoef[ia3 * 2U]; - si3 = pCoef[(ia3 * 2U) + 1U]; - - /* Twiddle coefficients index modifier */ - ia1 = ia1 + twidCoefModifier; - - i0 = j; - do - { - /* index calculation for the input as, */ - /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ - i1 = i0 + n2; - i2 = i1 + n2; - i3 = i2 + n2; - - /* xa + xc */ - r1 = pSrc[(2U * i0)] + pSrc[(2U * i2)]; - - /* xa - xc */ - r2 = pSrc[(2U * i0)] - pSrc[(2U * i2)]; - - /* ya + yc */ - s1 = pSrc[(2U * i0) + 1U] + pSrc[(2U * i2) + 1U]; - - /* ya - yc */ - s2 = pSrc[(2U * i0) + 1U] - pSrc[(2U * i2) + 1U]; - - /* xb + xd */ - t1 = pSrc[2U * i1] + pSrc[2U * i3]; - - /* xa' = xa + xb + xc + xd */ - pSrc[2U * i0] = r1 + t1; - - /* xa + xc -(xb + xd) */ - r1 = r1 - t1; - - /* yb + yd */ - t2 = pSrc[(2U * i1) + 1U] + pSrc[(2U * i3) + 1U]; - - /* ya' = ya + yb + yc + yd */ - pSrc[(2U * i0) + 1U] = s1 + t2; - - /* (ya + yc) - (yb + yd) */ - s1 = s1 - t2; - - /* (yb - yd) */ - t1 = pSrc[(2U * i1) + 1U] - pSrc[(2U * i3) + 1U]; - - /* (xb - xd) */ - t2 = pSrc[2U * i1] - pSrc[2U * i3]; - - /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ - pSrc[2U * i1] = (r1 * co2) - (s1 * si2); - - /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ - pSrc[(2U * i1) + 1U] = (s1 * co2) + (r1 * si2); - - /* (xa - xc) - (yb - yd) */ - r1 = r2 - t1; - - /* (xa - xc) + (yb - yd) */ - r2 = r2 + t1; - - /* (ya - yc) + (xb - xd) */ - s1 = s2 + t2; - - /* (ya - yc) - (xb - xd) */ - s2 = s2 - t2; - - /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ - pSrc[2U * i2] = (r1 * co1) - (s1 * si1); - - /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ - pSrc[(2U * i2) + 1U] = (s1 * co1) + (r1 * si1); - - /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ - pSrc[2U * i3] = (r2 * co3) - (s2 * si3); - - /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ - pSrc[(2U * i3) + 1U] = (s2 * co3) + (r2 * si3); - - i0 += n1; - } while ( i0 < fftLen); - j++; - } while (j <= (n2 - 1U)); - twidCoefModifier <<= 2U; - } - /* Initializations of last stage */ - n1 = n2; - n2 >>= 2U; - - /* Calculations of last stage */ - for (i0 = 0U; i0 <= (fftLen - n1); i0 += n1) - { - /* index calculation for the input as, */ - /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + 3fftLen/4] */ - i1 = i0 + n2; - i2 = i1 + n2; - i3 = i2 + n2; - - /* Butterfly implementation */ - /* xa + xc */ - r1 = pSrc[2U * i0] + pSrc[2U * i2]; - - /* xa - xc */ - r2 = pSrc[2U * i0] - pSrc[2U * i2]; - - /* ya + yc */ - s1 = pSrc[(2U * i0) + 1U] + pSrc[(2U * i2) + 1U]; - - /* ya - yc */ - s2 = pSrc[(2U * i0) + 1U] - pSrc[(2U * i2) + 1U]; - - /* xc + xd */ - t1 = pSrc[2U * i1] + pSrc[2U * i3]; - - /* xa' = xa + xb + xc + xd */ - pSrc[2U * i0] = (r1 + t1) * onebyfftLen; - - /* (xa + xb) - (xc + xd) */ - r1 = r1 - t1; - - /* yb + yd */ - t2 = pSrc[(2U * i1) + 1U] + pSrc[(2U * i3) + 1U]; - - /* ya' = ya + yb + yc + yd */ - pSrc[(2U * i0) + 1U] = (s1 + t2) * onebyfftLen; - - /* (ya + yc) - (yb + yd) */ - s1 = s1 - t2; - - /* (yb-yd) */ - t1 = pSrc[(2U * i1) + 1U] - pSrc[(2U * i3) + 1U]; - - /* (xb-xd) */ - t2 = pSrc[2U * i1] - pSrc[2U * i3]; - - /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ - pSrc[2U * i1] = r1 * onebyfftLen; - - /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ - pSrc[(2U * i1) + 1U] = s1 * onebyfftLen; - - /* (xa - xc) - (yb-yd) */ - r1 = r2 - t1; - - /* (xa - xc) + (yb-yd) */ - r2 = r2 + t1; - - /* (ya - yc) + (xb-xd) */ - s1 = s2 + t2; - - /* (ya - yc) - (xb-xd) */ - s2 = s2 - t2; - - /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ - pSrc[2U * i2] = r1 * onebyfftLen; - - /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ - pSrc[(2U * i2) + 1U] = s1 * onebyfftLen; - - /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ - pSrc[2U * i3] = r2 * onebyfftLen; - - /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ - pSrc[(2U * i3) + 1U] = s2 * onebyfftLen; - } + i0 += n1; + } while (i0 < fftLen); + j++; + } while (j <= (n2 - 1U)); + twidCoefModifier <<= 2U; + } #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ } +/** + brief Core function for the floating-point CIFFT butterfly process. + param[in,out] pSrc points to the in-place buffer of floating-point + data type param[in] fftLen length of the FFT param[in] pCoef + points to twiddle coefficient buffer param[in] twidCoefModifier twiddle + coefficient modifier that supports different size FFTs with the same twiddle + factor table. param[in] onebyfftLen value of 1/fftLen return none + */ +void arm_radix4_butterfly_inverse_f32(float32_t *pSrc, uint16_t fftLen, + const float32_t *pCoef, + uint16_t twidCoefModifier, + float32_t onebyfftLen) { + float32_t co1, co2, co3, si1, si2, si3; + uint32_t ia1, ia2, ia3; + uint32_t i0, i1, i2, i3; + uint32_t n1, n2, j, k; + +#if defined(ARM_MATH_LOOPUNROLL) + + float32_t xaIn, yaIn, xbIn, ybIn, xcIn, ycIn, xdIn, ydIn; + float32_t Xaplusc, Xbplusd, Yaplusc, Ybplusd, Xaminusc, Xbminusd, Yaminusc, + Ybminusd; + float32_t Xb12C_out, Yb12C_out, Xc12C_out, Yc12C_out, Xd12C_out, Yd12C_out; + float32_t Xb12_out, Yb12_out, Xc12_out, Yc12_out, Xd12_out, Yd12_out; + float32_t *ptr1; + float32_t p0, p1, p2, p3, p4, p5, p6, p7; + float32_t a0, a1, a2, a3, a4, a5, a6, a7; + + /* Initializations for the first stage */ + n2 = fftLen; + n1 = n2; + + /* n2 = fftLen/4 */ + n2 >>= 2U; + i0 = 0U; + ia1 = 0U; + + j = n2; + + /* Calculation of first stage */ + do { + /* index calculation for the input as, */ + /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + + * 3fftLen/4] */ + i1 = i0 + n2; + i2 = i1 + n2; + i3 = i2 + n2; + + /* Butterfly implementation */ + xaIn = pSrc[(2U * i0)]; + yaIn = pSrc[(2U * i0) + 1U]; + + xcIn = pSrc[(2U * i2)]; + ycIn = pSrc[(2U * i2) + 1U]; + + xbIn = pSrc[(2U * i1)]; + ybIn = pSrc[(2U * i1) + 1U]; + + xdIn = pSrc[(2U * i3)]; + ydIn = pSrc[(2U * i3) + 1U]; + + /* xa + xc */ + Xaplusc = xaIn + xcIn; + /* xb + xd */ + Xbplusd = xbIn + xdIn; + /* ya + yc */ + Yaplusc = yaIn + ycIn; + /* yb + yd */ + Ybplusd = ybIn + ydIn; + + /* index calculation for the coefficients */ + ia2 = ia1 + ia1; + co2 = pCoef[ia2 * 2U]; + si2 = pCoef[(ia2 * 2U) + 1U]; + + /* xa - xc */ + Xaminusc = xaIn - xcIn; + /* xb - xd */ + Xbminusd = xbIn - xdIn; + /* ya - yc */ + Yaminusc = yaIn - ycIn; + /* yb - yd */ + Ybminusd = ybIn - ydIn; + + /* xa' = xa + xb + xc + xd */ + pSrc[(2U * i0)] = Xaplusc + Xbplusd; + + /* ya' = ya + yb + yc + yd */ + pSrc[(2U * i0) + 1U] = Yaplusc + Ybplusd; + + /* (xa - xc) - (yb - yd) */ + Xb12C_out = (Xaminusc - Ybminusd); + /* (ya - yc) + (xb - xd) */ + Yb12C_out = (Yaminusc + Xbminusd); + /* (xa + xc) - (xb + xd) */ + Xc12C_out = (Xaplusc - Xbplusd); + /* (ya + yc) - (yb + yd) */ + Yc12C_out = (Yaplusc - Ybplusd); + /* (xa - xc) + (yb - yd) */ + Xd12C_out = (Xaminusc + Ybminusd); + /* (ya - yc) - (xb - xd) */ + Yd12C_out = (Yaminusc - Xbminusd); + + co1 = pCoef[ia1 * 2U]; + si1 = pCoef[(ia1 * 2U) + 1U]; + + /* index calculation for the coefficients */ + ia3 = ia2 + ia1; + co3 = pCoef[ia3 * 2U]; + si3 = pCoef[(ia3 * 2U) + 1U]; + + Xb12_out = Xb12C_out * co1; + Yb12_out = Yb12C_out * co1; + Xc12_out = Xc12C_out * co2; + Yc12_out = Yc12C_out * co2; + Xd12_out = Xd12C_out * co3; + Yd12_out = Yd12C_out * co3; + + /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ + // Xb12_out -= Yb12C_out * si1; + p0 = Yb12C_out * si1; + /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ + // Yb12_out += Xb12C_out * si1; + p1 = Xb12C_out * si1; + /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ + // Xc12_out -= Yc12C_out * si2; + p2 = Yc12C_out * si2; + /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ + // Yc12_out += Xc12C_out * si2; + p3 = Xc12C_out * si2; + /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ + // Xd12_out -= Yd12C_out * si3; + p4 = Yd12C_out * si3; + /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ + // Yd12_out += Xd12C_out * si3; + p5 = Xd12C_out * si3; + + Xb12_out -= p0; + Yb12_out += p1; + Xc12_out -= p2; + Yc12_out += p3; + Xd12_out -= p4; + Yd12_out += p5; + + /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ + pSrc[2U * i1] = Xc12_out; + + /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ + pSrc[(2U * i1) + 1U] = Yc12_out; + + /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ + pSrc[2U * i2] = Xb12_out; + + /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ + pSrc[(2U * i2) + 1U] = Yb12_out; + + /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ + pSrc[2U * i3] = Xd12_out; + + /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ + pSrc[(2U * i3) + 1U] = Yd12_out; + + /* Twiddle coefficients index modifier */ + ia1 = ia1 + twidCoefModifier; + + /* Updating input index */ + i0 = i0 + 1U; + + } while (--j); + + twidCoefModifier <<= 2U; + + /* Calculation of second stage to excluding last stage */ + for (k = fftLen >> 2U; k > 4U; k >>= 2U) { + /* Initializations for the first stage */ + n1 = n2; + n2 >>= 2U; + ia1 = 0U; + + /* Calculation of first stage */ + j = 0; + do { + /* index calculation for the coefficients */ + ia2 = ia1 + ia1; + ia3 = ia2 + ia1; + co1 = pCoef[ia1 * 2U]; + si1 = pCoef[(ia1 * 2U) + 1U]; + co2 = pCoef[ia2 * 2U]; + si2 = pCoef[(ia2 * 2U) + 1U]; + co3 = pCoef[ia3 * 2U]; + si3 = pCoef[(ia3 * 2U) + 1U]; + + /* Twiddle coefficients index modifier */ + ia1 = ia1 + twidCoefModifier; + + i0 = j; + do { + /* index calculation for the input as, */ + /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + + * 3fftLen/4] */ + i1 = i0 + n2; + i2 = i1 + n2; + i3 = i2 + n2; + + xaIn = pSrc[(2U * i0)]; + yaIn = pSrc[(2U * i0) + 1U]; + + xbIn = pSrc[(2U * i1)]; + ybIn = pSrc[(2U * i1) + 1U]; + + xcIn = pSrc[(2U * i2)]; + ycIn = pSrc[(2U * i2) + 1U]; + + xdIn = pSrc[(2U * i3)]; + ydIn = pSrc[(2U * i3) + 1U]; + + /* xa - xc */ + Xaminusc = xaIn - xcIn; + /* (xb - xd) */ + Xbminusd = xbIn - xdIn; + /* ya - yc */ + Yaminusc = yaIn - ycIn; + /* (yb - yd) */ + Ybminusd = ybIn - ydIn; + + /* xa + xc */ + Xaplusc = xaIn + xcIn; + /* xb + xd */ + Xbplusd = xbIn + xdIn; + /* ya + yc */ + Yaplusc = yaIn + ycIn; + /* yb + yd */ + Ybplusd = ybIn + ydIn; + + /* (xa - xc) - (yb - yd) */ + Xb12C_out = (Xaminusc - Ybminusd); + /* (ya - yc) + (xb - xd) */ + Yb12C_out = (Yaminusc + Xbminusd); + /* xa + xc -(xb + xd) */ + Xc12C_out = (Xaplusc - Xbplusd); + /* (ya + yc) - (yb + yd) */ + Yc12C_out = (Yaplusc - Ybplusd); + /* (xa - xc) + (yb - yd) */ + Xd12C_out = (Xaminusc + Ybminusd); + /* (ya - yc) - (xb - xd) */ + Yd12C_out = (Yaminusc - Xbminusd); + + pSrc[(2U * i0)] = Xaplusc + Xbplusd; + pSrc[(2U * i0) + 1U] = Yaplusc + Ybplusd; + + Xb12_out = Xb12C_out * co1; + Yb12_out = Yb12C_out * co1; + Xc12_out = Xc12C_out * co2; + Yc12_out = Yc12C_out * co2; + Xd12_out = Xd12C_out * co3; + Yd12_out = Yd12C_out * co3; + + /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ + // Xb12_out -= Yb12C_out * si1; + p0 = Yb12C_out * si1; + /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ + // Yb12_out += Xb12C_out * si1; + p1 = Xb12C_out * si1; + /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ + // Xc12_out -= Yc12C_out * si2; + p2 = Yc12C_out * si2; + /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ + // Yc12_out += Xc12C_out * si2; + p3 = Xc12C_out * si2; + /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ + // Xd12_out -= Yd12C_out * si3; + p4 = Yd12C_out * si3; + /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ + // Yd12_out += Xd12C_out * si3; + p5 = Xd12C_out * si3; + + Xb12_out -= p0; + Yb12_out += p1; + Xc12_out -= p2; + Yc12_out += p3; + Xd12_out -= p4; + Yd12_out += p5; + + /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ + pSrc[2U * i1] = Xc12_out; + + /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ + pSrc[(2U * i1) + 1U] = Yc12_out; + + /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ + pSrc[2U * i2] = Xb12_out; + + /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ + pSrc[(2U * i2) + 1U] = Yb12_out; + + /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ + pSrc[2U * i3] = Xd12_out; + + /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ + pSrc[(2U * i3) + 1U] = Yd12_out; + + i0 += n1; + } while (i0 < fftLen); + j++; + } while (j <= (n2 - 1U)); + twidCoefModifier <<= 2U; + } + /* Initializations of last stage */ + + j = fftLen >> 2; + ptr1 = &pSrc[0]; + + /* Calculations of last stage */ + do { + xaIn = ptr1[0]; + yaIn = ptr1[1]; + xbIn = ptr1[2]; + ybIn = ptr1[3]; + xcIn = ptr1[4]; + ycIn = ptr1[5]; + xdIn = ptr1[6]; + ydIn = ptr1[7]; + + /* Butterfly implementation */ + /* xa + xc */ + Xaplusc = xaIn + xcIn; + + /* xa - xc */ + Xaminusc = xaIn - xcIn; + + /* ya + yc */ + Yaplusc = yaIn + ycIn; + + /* ya - yc */ + Yaminusc = yaIn - ycIn; + + /* xb + xd */ + Xbplusd = xbIn + xdIn; + + /* yb + yd */ + Ybplusd = ybIn + ydIn; + + /* (xb-xd) */ + Xbminusd = xbIn - xdIn; + + /* (yb-yd) */ + Ybminusd = ybIn - ydIn; + + /* xa' = (xa+xb+xc+xd) * onebyfftLen */ + a0 = (Xaplusc + Xbplusd); + /* ya' = (ya+yb+yc+yd) * onebyfftLen */ + a1 = (Yaplusc + Ybplusd); + /* xc' = (xa-xb+xc-xd) * onebyfftLen */ + a2 = (Xaplusc - Xbplusd); + /* yc' = (ya-yb+yc-yd) * onebyfftLen */ + a3 = (Yaplusc - Ybplusd); + /* xb' = (xa-yb-xc+yd) * onebyfftLen */ + a4 = (Xaminusc - Ybminusd); + /* yb' = (ya+xb-yc-xd) * onebyfftLen */ + a5 = (Yaminusc + Xbminusd); + /* xd' = (xa-yb-xc+yd) * onebyfftLen */ + a6 = (Xaminusc + Ybminusd); + /* yd' = (ya-xb-yc+xd) * onebyfftLen */ + a7 = (Yaminusc - Xbminusd); + + p0 = a0 * onebyfftLen; + p1 = a1 * onebyfftLen; + p2 = a2 * onebyfftLen; + p3 = a3 * onebyfftLen; + p4 = a4 * onebyfftLen; + p5 = a5 * onebyfftLen; + p6 = a6 * onebyfftLen; + p7 = a7 * onebyfftLen; + + /* xa' = (xa+xb+xc+xd) * onebyfftLen */ + ptr1[0] = p0; + /* ya' = (ya+yb+yc+yd) * onebyfftLen */ + ptr1[1] = p1; + /* xc' = (xa-xb+xc-xd) * onebyfftLen */ + ptr1[2] = p2; + /* yc' = (ya-yb+yc-yd) * onebyfftLen */ + ptr1[3] = p3; + /* xb' = (xa-yb-xc+yd) * onebyfftLen */ + ptr1[4] = p4; + /* yb' = (ya+xb-yc-xd) * onebyfftLen */ + ptr1[5] = p5; + /* xd' = (xa-yb-xc+yd) * onebyfftLen */ + ptr1[6] = p6; + /* yd' = (ya-xb-yc+xd) * onebyfftLen */ + ptr1[7] = p7; + + /* increment source pointer by 8 for next calculations */ + ptr1 = ptr1 + 8U; + + } while (--j); + +#else + + float32_t t1, t2, r1, r2, s1, s2; + + /* Initializations for the first stage */ + n2 = fftLen; + n1 = n2; + + /* Calculation of first stage */ + for (k = fftLen; k > 4U; k >>= 2U) { + /* Initializations for the first stage */ + n1 = n2; + n2 >>= 2U; + ia1 = 0U; + + /* Calculation of first stage */ + j = 0; + do { + /* index calculation for the coefficients */ + ia2 = ia1 + ia1; + ia3 = ia2 + ia1; + co1 = pCoef[ia1 * 2U]; + si1 = pCoef[(ia1 * 2U) + 1U]; + co2 = pCoef[ia2 * 2U]; + si2 = pCoef[(ia2 * 2U) + 1U]; + co3 = pCoef[ia3 * 2U]; + si3 = pCoef[(ia3 * 2U) + 1U]; + + /* Twiddle coefficients index modifier */ + ia1 = ia1 + twidCoefModifier; + + i0 = j; + do { + /* index calculation for the input as, */ + /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + + * 3fftLen/4] */ + i1 = i0 + n2; + i2 = i1 + n2; + i3 = i2 + n2; + + /* xa + xc */ + r1 = pSrc[(2U * i0)] + pSrc[(2U * i2)]; + + /* xa - xc */ + r2 = pSrc[(2U * i0)] - pSrc[(2U * i2)]; + + /* ya + yc */ + s1 = pSrc[(2U * i0) + 1U] + pSrc[(2U * i2) + 1U]; + + /* ya - yc */ + s2 = pSrc[(2U * i0) + 1U] - pSrc[(2U * i2) + 1U]; + + /* xb + xd */ + t1 = pSrc[2U * i1] + pSrc[2U * i3]; + + /* xa' = xa + xb + xc + xd */ + pSrc[2U * i0] = r1 + t1; + + /* xa + xc -(xb + xd) */ + r1 = r1 - t1; + + /* yb + yd */ + t2 = pSrc[(2U * i1) + 1U] + pSrc[(2U * i3) + 1U]; + + /* ya' = ya + yb + yc + yd */ + pSrc[(2U * i0) + 1U] = s1 + t2; + + /* (ya + yc) - (yb + yd) */ + s1 = s1 - t2; + + /* (yb - yd) */ + t1 = pSrc[(2U * i1) + 1U] - pSrc[(2U * i3) + 1U]; + + /* (xb - xd) */ + t2 = pSrc[2U * i1] - pSrc[2U * i3]; + + /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ + pSrc[2U * i1] = (r1 * co2) - (s1 * si2); + + /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ + pSrc[(2U * i1) + 1U] = (s1 * co2) + (r1 * si2); + + /* (xa - xc) - (yb - yd) */ + r1 = r2 - t1; + + /* (xa - xc) + (yb - yd) */ + r2 = r2 + t1; + + /* (ya - yc) + (xb - xd) */ + s1 = s2 + t2; + + /* (ya - yc) - (xb - xd) */ + s2 = s2 - t2; + + /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ + pSrc[2U * i2] = (r1 * co1) - (s1 * si1); + + /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ + pSrc[(2U * i2) + 1U] = (s1 * co1) + (r1 * si1); + + /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ + pSrc[2U * i3] = (r2 * co3) - (s2 * si3); + + /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ + pSrc[(2U * i3) + 1U] = (s2 * co3) + (r2 * si3); + + i0 += n1; + } while (i0 < fftLen); + j++; + } while (j <= (n2 - 1U)); + twidCoefModifier <<= 2U; + } + /* Initializations of last stage */ + n1 = n2; + n2 >>= 2U; + + /* Calculations of last stage */ + for (i0 = 0U; i0 <= (fftLen - n1); i0 += n1) { + /* index calculation for the input as, */ + /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2], pSrc[i0 + + * 3fftLen/4] */ + i1 = i0 + n2; + i2 = i1 + n2; + i3 = i2 + n2; + + /* Butterfly implementation */ + /* xa + xc */ + r1 = pSrc[2U * i0] + pSrc[2U * i2]; + + /* xa - xc */ + r2 = pSrc[2U * i0] - pSrc[2U * i2]; + + /* ya + yc */ + s1 = pSrc[(2U * i0) + 1U] + pSrc[(2U * i2) + 1U]; + + /* ya - yc */ + s2 = pSrc[(2U * i0) + 1U] - pSrc[(2U * i2) + 1U]; + + /* xc + xd */ + t1 = pSrc[2U * i1] + pSrc[2U * i3]; + + /* xa' = xa + xb + xc + xd */ + pSrc[2U * i0] = (r1 + t1) * onebyfftLen; + + /* (xa + xb) - (xc + xd) */ + r1 = r1 - t1; + + /* yb + yd */ + t2 = pSrc[(2U * i1) + 1U] + pSrc[(2U * i3) + 1U]; + + /* ya' = ya + yb + yc + yd */ + pSrc[(2U * i0) + 1U] = (s1 + t2) * onebyfftLen; + + /* (ya + yc) - (yb + yd) */ + s1 = s1 - t2; + + /* (yb-yd) */ + t1 = pSrc[(2U * i1) + 1U] - pSrc[(2U * i3) + 1U]; + + /* (xb-xd) */ + t2 = pSrc[2U * i1] - pSrc[2U * i3]; + + /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ + pSrc[2U * i1] = r1 * onebyfftLen; + + /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ + pSrc[(2U * i1) + 1U] = s1 * onebyfftLen; + + /* (xa - xc) - (yb-yd) */ + r1 = r2 - t1; + + /* (xa - xc) + (yb-yd) */ + r2 = r2 + t1; + + /* (ya - yc) + (xb-xd) */ + s1 = s2 + t2; + + /* (ya - yc) - (xb-xd) */ + s2 = s2 - t2; + + /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ + pSrc[2U * i2] = r1 * onebyfftLen; + + /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ + pSrc[(2U * i2) + 1U] = s1 * onebyfftLen; + + /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ + pSrc[2U * i3] = r2 * onebyfftLen; + + /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ + pSrc[(2U * i3) + 1U] = s2 * onebyfftLen; + } + +#endif /* #if defined (ARM_MATH_LOOPUNROLL) */ +} diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_init_f32.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_init_f32.c index 930c2c1..c4b8304 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_init_f32.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_init_f32.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_radix4_init_f32.c - * Description: Radix-4 Decimation in Frequency Floating-point CFFT & CIFFT Initialization function + * Description: Radix-4 Decimation in Frequency Floating-point CFFT & CIFFT + * Initialization function * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -26,8 +27,8 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @ingroup groupTransforms @@ -40,37 +41,42 @@ /** @brief Initialization function for the floating-point CFFT/CIFFT. - @deprecated Do not use this function. It has been superceded by \ref arm_cfft_f32 and will be removed in the future. - @param[in,out] S points to an instance of the floating-point CFFT/CIFFT structure + @deprecated Do not use this function. It has been superceded by \ref + arm_cfft_f32 and will be removed in the future. + @param[in,out] S points to an instance of the floating-point + CFFT/CIFFT structure @param[in] fftLen length of the FFT @param[in] ifftFlag flag that selects transform direction - value = 0: forward transform - value = 1: inverse transform - @param[in] bitReverseFlag flag that enables / disables bit reversal of output + @param[in] bitReverseFlag flag that enables / disables bit reversal of + output - value = 0: disables bit reversal of output - value = 1: enables bit reversal of output @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : fftLen is not a supported length + - \ref ARM_MATH_ARGUMENT_ERROR : fftLen is not a + supported length @par Details - The parameter ifftFlag controls whether a forward or inverse transform is computed. - Set(=1) ifftFlag for calculation of CIFFT otherwise CFFT is calculated + The parameter ifftFlag controls whether a + forward or inverse transform is computed. Set(=1) ifftFlag for calculation of + CIFFT otherwise CFFT is calculated @par - The parameter bitReverseFlag controls whether output is in normal order or bit reversed order. - Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order. + The parameter bitReverseFlag controls whether + output is in normal order or bit reversed order. Set(=1) bitReverseFlag for + output to be in normal order otherwise output is in bit reversed order. @par - The parameter fftLen Specifies length of CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024. + The parameter fftLen Specifies length of + CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024. @par - This Function also initializes Twiddle factor table pointer and Bit reversal table pointer. + This Function also initializes Twiddle factor table pointer + and Bit reversal table pointer. */ -arm_status arm_cfft_radix4_init_f32( - arm_cfft_radix4_instance_f32 * S, - uint16_t fftLen, - uint8_t ifftFlag, - uint8_t bitReverseFlag) -{ +arm_status arm_cfft_radix4_init_f32(arm_cfft_radix4_instance_f32 *S, + uint16_t fftLen, uint8_t ifftFlag, + uint8_t bitReverseFlag) { /* Initialise the default arm status */ arm_status status = ARM_MATH_SUCCESS; @@ -78,7 +84,7 @@ arm_status arm_cfft_radix4_init_f32( S->fftLen = fftLen; /* Initialise the Twiddle coefficient pointer */ - S->pTwiddle = (float32_t *) twiddleCoef; + S->pTwiddle = (float32_t *)twiddleCoef; /* Initialise the Flag for selection of CFFT or CIFFT */ S->ifftFlag = ifftFlag; @@ -87,8 +93,7 @@ arm_status arm_cfft_radix4_init_f32( S->bitReverseFlag = bitReverseFlag; /* Initializations of structure parameters depending on the FFT length */ - switch (S->fftLen) - { + switch (S->fftLen) { case 4096U: /* Initializations of structure parameters for 4096 point FFT */ @@ -98,7 +103,7 @@ arm_status arm_cfft_radix4_init_f32( /* Initialise the bit reversal table modifier */ S->bitRevFactor = 1U; /* Initialise the bit reversal table pointer */ - S->pBitRevTable = (uint16_t *) armBitRevTable; + S->pBitRevTable = (uint16_t *)armBitRevTable; /* Initialise the 1/fftLen Value */ S->onebyfftLen = 0.000244140625; break; @@ -111,17 +116,16 @@ arm_status arm_cfft_radix4_init_f32( /* Initialise the bit reversal table modifier */ S->bitRevFactor = 4U; /* Initialise the bit reversal table pointer */ - S->pBitRevTable = (uint16_t *) & armBitRevTable[3]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[3]; /* Initialise the 1/fftLen Value */ S->onebyfftLen = 0.0009765625f; break; - case 256U: /* Initializations of structure parameters for 256 point FFT */ S->twidCoefModifier = 16U; S->bitRevFactor = 16U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[15]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[15]; S->onebyfftLen = 0.00390625f; break; @@ -129,7 +133,7 @@ arm_status arm_cfft_radix4_init_f32( /* Initializations of structure parameters for 64 point FFT */ S->twidCoefModifier = 64U; S->bitRevFactor = 64U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[63]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[63]; S->onebyfftLen = 0.015625f; break; @@ -137,11 +141,10 @@ arm_status arm_cfft_radix4_init_f32( /* Initializations of structure parameters for 16 point FFT */ S->twidCoefModifier = 256U; S->bitRevFactor = 256U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[255]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[255]; S->onebyfftLen = 0.0625f; break; - default: /* Reporting argument error if fftSize is not valid value */ status = ARM_MATH_ARGUMENT_ERROR; diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_init_q15.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_init_q15.c index 0090688..3aaa107 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_init_q15.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_init_q15.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_radix4_init_q15.c - * Description: Radix-4 Decimation in Frequency Q15 FFT & IFFT initialization function + * Description: Radix-4 Decimation in Frequency Q15 FFT & IFFT initialization + * function * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -26,67 +27,69 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @ingroup groupTransforms */ - /** @addtogroup ComplexFFT @{ */ - /** @brief Initialization function for the Q15 CFFT/CIFFT. - @deprecated Do not use this function. It has been superseded by \ref arm_cfft_q15 and will be removed in the future. - @param[in,out] S points to an instance of the Q15 CFFT/CIFFT structure + @deprecated Do not use this function. It has been superseded by \ref + arm_cfft_q15 and will be removed in the future. + @param[in,out] S points to an instance of the Q15 CFFT/CIFFT + structure @param[in] fftLen length of the FFT @param[in] ifftFlag flag that selects transform direction - value = 0: forward transform - value = 1: inverse transform - @param[in] bitReverseFlag flag that enables / disables bit reversal of output + @param[in] bitReverseFlag flag that enables / disables bit reversal of + output - value = 0: disables bit reversal of output - value = 1: enables bit reversal of output @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : fftLen is not a supported length + - \ref ARM_MATH_ARGUMENT_ERROR : fftLen is not a + supported length @par Details - The parameter ifftFlag controls whether a forward or inverse transform is computed. - Set(=1) ifftFlag for calculation of CIFFT otherwise CFFT is calculated + The parameter ifftFlag controls whether a + forward or inverse transform is computed. Set(=1) ifftFlag for calculation of + CIFFT otherwise CFFT is calculated @par - The parameter bitReverseFlag controls whether output is in normal order or bit reversed order. - Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order. + The parameter bitReverseFlag controls whether + output is in normal order or bit reversed order. Set(=1) bitReverseFlag for + output to be in normal order otherwise output is in bit reversed order. @par - The parameter fftLen Specifies length of CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024. + The parameter fftLen Specifies length of + CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024. @par - This Function also initializes Twiddle factor table pointer and Bit reversal table pointer. + This Function also initializes Twiddle factor table pointer + and Bit reversal table pointer. */ -arm_status arm_cfft_radix4_init_q15( - arm_cfft_radix4_instance_q15 * S, - uint16_t fftLen, - uint8_t ifftFlag, - uint8_t bitReverseFlag) -{ +arm_status arm_cfft_radix4_init_q15(arm_cfft_radix4_instance_q15 *S, + uint16_t fftLen, uint8_t ifftFlag, + uint8_t bitReverseFlag) { /* Initialise the default arm status */ arm_status status = ARM_MATH_SUCCESS; /* Initialise the FFT length */ S->fftLen = fftLen; /* Initialise the Twiddle coefficient pointer */ - S->pTwiddle = (q15_t *) twiddleCoef_4096_q15; + S->pTwiddle = (q15_t *)twiddleCoef_4096_q15; /* Initialise the Flag for selection of CFFT or CIFFT */ S->ifftFlag = ifftFlag; /* Initialise the Flag for calculation Bit reversal or not */ S->bitReverseFlag = bitReverseFlag; /* Initializations of structure parameters depending on the FFT length */ - switch (S->fftLen) - { + switch (S->fftLen) { case 4096U: /* Initializations of structure parameters for 4096 point FFT */ @@ -95,7 +98,7 @@ arm_status arm_cfft_radix4_init_q15( /* Initialise the bit reversal table modifier */ S->bitRevFactor = 1U; /* Initialise the bit reversal table pointer */ - S->pBitRevTable = (uint16_t *) armBitRevTable; + S->pBitRevTable = (uint16_t *)armBitRevTable; break; @@ -103,7 +106,7 @@ arm_status arm_cfft_radix4_init_q15( /* Initializations of structure parameters for 1024 point FFT */ S->twidCoefModifier = 4U; S->bitRevFactor = 4U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[3]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[3]; break; @@ -111,7 +114,7 @@ arm_status arm_cfft_radix4_init_q15( /* Initializations of structure parameters for 256 point FFT */ S->twidCoefModifier = 16U; S->bitRevFactor = 16U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[15]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[15]; break; @@ -119,7 +122,7 @@ arm_status arm_cfft_radix4_init_q15( /* Initializations of structure parameters for 64 point FFT */ S->twidCoefModifier = 64U; S->bitRevFactor = 64U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[63]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[63]; break; @@ -127,7 +130,7 @@ arm_status arm_cfft_radix4_init_q15( /* Initializations of structure parameters for 16 point FFT */ S->twidCoefModifier = 256U; S->bitRevFactor = 256U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[255]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[255]; break; diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_init_q31.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_init_q31.c index 17d16b7..8864c7c 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_init_q31.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_init_q31.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_radix4_init_q31.c - * Description: Radix-4 Decimation in Frequency Q31 FFT & IFFT initialization function + * Description: Radix-4 Decimation in Frequency Q31 FFT & IFFT initialization + * function * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -26,8 +27,8 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @ingroup groupTransforms @@ -41,51 +42,55 @@ /** @brief Initialization function for the Q31 CFFT/CIFFT. - @deprecated Do not use this function. It has been superseded by \ref arm_cfft_q31 and will be removed in the future. - @param[in,out] S points to an instance of the Q31 CFFT/CIFFT structure. + @deprecated Do not use this function. It has been superseded by \ref + arm_cfft_q31 and will be removed in the future. + @param[in,out] S points to an instance of the Q31 CFFT/CIFFT + structure. @param[in] fftLen length of the FFT. @param[in] ifftFlag flag that selects transform direction - value = 0: forward transform - value = 1: inverse transform - @param[in] bitReverseFlag flag that enables / disables bit reversal of output + @param[in] bitReverseFlag flag that enables / disables bit reversal of + output - value = 0: disables bit reversal of output - value = 1: enables bit reversal of output @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : fftLen is not a supported length + - \ref ARM_MATH_ARGUMENT_ERROR : fftLen is not a + supported length @par Details - The parameter ifftFlag controls whether a forward or inverse transform is computed. - Set(=1) ifftFlag for calculation of CIFFT otherwise CFFT is calculated + The parameter ifftFlag controls whether a + forward or inverse transform is computed. Set(=1) ifftFlag for calculation of + CIFFT otherwise CFFT is calculated @par - The parameter bitReverseFlag controls whether output is in normal order or bit reversed order. - Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order. + The parameter bitReverseFlag controls whether + output is in normal order or bit reversed order. Set(=1) bitReverseFlag for + output to be in normal order otherwise output is in bit reversed order. @par - The parameter fftLen Specifies length of CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024. + The parameter fftLen Specifies length of + CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024. @par - This Function also initializes Twiddle factor table pointer and Bit reversal table pointer. + This Function also initializes Twiddle factor table pointer + and Bit reversal table pointer. */ -arm_status arm_cfft_radix4_init_q31( - arm_cfft_radix4_instance_q31 * S, - uint16_t fftLen, - uint8_t ifftFlag, - uint8_t bitReverseFlag) -{ +arm_status arm_cfft_radix4_init_q31(arm_cfft_radix4_instance_q31 *S, + uint16_t fftLen, uint8_t ifftFlag, + uint8_t bitReverseFlag) { /* Initialise the default arm status */ arm_status status = ARM_MATH_SUCCESS; /* Initialise the FFT length */ S->fftLen = fftLen; /* Initialise the Twiddle coefficient pointer */ - S->pTwiddle = (q31_t *) twiddleCoef_4096_q31; + S->pTwiddle = (q31_t *)twiddleCoef_4096_q31; /* Initialise the Flag for selection of CFFT or CIFFT */ S->ifftFlag = ifftFlag; /* Initialise the Flag for calculation Bit reversal or not */ S->bitReverseFlag = bitReverseFlag; /* Initializations of Instance structure depending on the FFT length */ - switch (S->fftLen) - { + switch (S->fftLen) { /* Initializations of structure parameters for 4096 point FFT */ case 4096U: /* Initialise the twiddle coef modifier value */ @@ -93,7 +98,7 @@ arm_status arm_cfft_radix4_init_q31( /* Initialise the bit reversal table modifier */ S->bitRevFactor = 1U; /* Initialise the bit reversal table pointer */ - S->pBitRevTable = (uint16_t *) armBitRevTable; + S->pBitRevTable = (uint16_t *)armBitRevTable; break; /* Initializations of structure parameters for 1024 point FFT */ @@ -103,28 +108,28 @@ arm_status arm_cfft_radix4_init_q31( /* Initialise the bit reversal table modifier */ S->bitRevFactor = 4U; /* Initialise the bit reversal table pointer */ - S->pBitRevTable = (uint16_t *) & armBitRevTable[3]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[3]; break; case 256U: /* Initializations of structure parameters for 256 point FFT */ S->twidCoefModifier = 16U; S->bitRevFactor = 16U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[15]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[15]; break; case 64U: /* Initializations of structure parameters for 64 point FFT */ S->twidCoefModifier = 64U; S->bitRevFactor = 64U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[63]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[63]; break; case 16U: /* Initializations of structure parameters for 16 point FFT */ S->twidCoefModifier = 256U; S->bitRevFactor = 256U; - S->pBitRevTable = (uint16_t *) & armBitRevTable[255]; + S->pBitRevTable = (uint16_t *)&armBitRevTable[255]; break; default: diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_q15.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_q15.c index b4cabb1..cd159b3 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_q15.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_q15.c @@ -1,8 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_radix4_q15.c - * Description: This file has function definition of Radix-4 FFT & IFFT function and - * In-place bit reversal using bit reversal table + * Description: This file has function definition of Radix-4 FFT & IFFT + * function and In-place bit reversal using bit reversal table * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -29,24 +29,15 @@ #include "arm_math.h" +void arm_radix4_butterfly_q15(q15_t *pSrc16, uint32_t fftLen, + const q15_t *pCoef16, uint32_t twidCoefModifier); -void arm_radix4_butterfly_q15( - q15_t * pSrc16, - uint32_t fftLen, - const q15_t * pCoef16, - uint32_t twidCoefModifier); +void arm_radix4_butterfly_inverse_q15(q15_t *pSrc16, uint32_t fftLen, + const q15_t *pCoef16, + uint32_t twidCoefModifier); -void arm_radix4_butterfly_inverse_q15( - q15_t * pSrc16, - uint32_t fftLen, - const q15_t * pCoef16, - uint32_t twidCoefModifier); - -void arm_bitreversal_q15( - q15_t * pSrc, - uint32_t fftLen, - uint16_t bitRevFactor, - const uint16_t * pBitRevTab); +void arm_bitreversal_q15(q15_t *pSrc, uint32_t fftLen, uint16_t bitRevFactor, + const uint16_t *pBitRevTab); /** @ingroup groupTransforms @@ -57,44 +48,41 @@ void arm_bitreversal_q15( @{ */ - /** @brief Processing function for the Q15 CFFT/CIFFT. - @deprecated Do not use this function. It has been superseded by \ref arm_cfft_q15 and will be removed in the future. + @deprecated Do not use this function. It has been superseded by \ref + arm_cfft_q15 and will be removed in the future. @param[in] S points to an instance of the Q15 CFFT/CIFFT structure. - @param[in,out] pSrc points to the complex data buffer. Processing occurs in-place. + @param[in,out] pSrc points to the complex data buffer. Processing occurs + in-place. @return none - + @par Input and output formats: - Internally input is downscaled by 2 for every stage to avoid saturations inside CFFT/CIFFT process. - Hence the output format is different for different FFT sizes. - The input and output formats for different FFT sizes and number of bits to upscale are mentioned in the tables below for CFFT and CIFFT: + Internally input is downscaled by 2 for every stage to avoid + saturations inside CFFT/CIFFT process. Hence the output format is different + for different FFT sizes. The input and output formats for different FFT sizes + and number of bits to upscale are mentioned in the tables below for CFFT and + CIFFT: @par \image html CFFTQ15.gif "Input and Output Formats for Q15 CFFT" - \image html CIFFTQ15.gif "Input and Output Formats for Q15 CIFFT" + \image html CIFFTQ15.gif "Input and Output Formats for Q15 + CIFFT" */ -void arm_cfft_radix4_q15( - const arm_cfft_radix4_instance_q15 * S, - q15_t * pSrc) -{ - if (S->ifftFlag == 1U) - { +void arm_cfft_radix4_q15(const arm_cfft_radix4_instance_q15 *S, q15_t *pSrc) { + if (S->ifftFlag == 1U) { /* Complex IFFT radix-4 */ - arm_radix4_butterfly_inverse_q15(pSrc, S->fftLen, S->pTwiddle, S->twidCoefModifier); - } - else - { + arm_radix4_butterfly_inverse_q15(pSrc, S->fftLen, S->pTwiddle, + S->twidCoefModifier); + } else { /* Complex FFT radix-4 */ arm_radix4_butterfly_q15(pSrc, S->fftLen, S->pTwiddle, S->twidCoefModifier); } - if (S->bitReverseFlag == 1U) - { + if (S->bitReverseFlag == 1U) { /* Bit Reversal */ arm_bitreversal_q15(pSrc, S->fftLen, S->bitRevFactor, S->pBitRevTable); } - } /** @@ -122,7 +110,7 @@ void arm_cfft_radix4_q15( * Wn = co1 + j * (- si1) * W2n = co2 + j * (- si2) * W3n = co3 + j * (- si3) - + * The real and imaginary output values for the radix-4 butterfly are * xa' = xa + xb + xc + xd * ya' = ya + yb + yc + yd @@ -140,30 +128,27 @@ void arm_cfft_radix4_q15( @param[in,out] pSrc16 points to the in-place buffer of Q15 data type @param[in] fftLen length of the FFT @param[in] pCoef16 points to twiddle coefficient buffer - @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table + @param[in] twidCoefModifier twiddle coefficient modifier that supports + different size FFTs with the same twiddle factor table @return none */ -void arm_radix4_butterfly_q15( - q15_t * pSrc16, - uint32_t fftLen, - const q15_t * pCoef16, - uint32_t twidCoefModifier) -{ +void arm_radix4_butterfly_q15(q15_t *pSrc16, uint32_t fftLen, + const q15_t *pCoef16, uint32_t twidCoefModifier) { -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) - q31_t R, S, T, U; - q31_t C1, C2, C3, out1, out2; - uint32_t n1, n2, ic, i0, j, k; + q31_t R, S, T, U; + q31_t C1, C2, C3, out1, out2; + uint32_t n1, n2, ic, i0, j, k; - q15_t *ptr1; - q15_t *pSi0; - q15_t *pSi1; - q15_t *pSi2; - q15_t *pSi3; + q15_t *ptr1; + q15_t *pSi0; + q15_t *pSi1; + q15_t *pSi2; + q15_t *pSi3; - q31_t xaya, xbyb, xcyc, xdyd; + q31_t xaya, xbyb, xcyc, xdyd; /* Total process is divided into three stages */ @@ -190,22 +175,23 @@ void arm_radix4_butterfly_q15( /* Input is in 1.15(q15) format */ /* start of first stage process */ - do - { + do { /* Butterfly implementation */ /* Reading i0, i0+fftLen/2 inputs */ /* Read ya (real), xa(imag) input */ - T = read_q15x2 (pSi0); + T = read_q15x2(pSi0); T = __SHADD16(T, 0); /* this is just a SIMD arithmetic shift right by 1 */ - T = __SHADD16(T, 0); /* it turns out doing this twice is 2 cycles, the alternative takes 3 cycles */ -/* - in = ((int16_t) (T & 0xFFFF)) >> 2; // alternative code that takes 3 cycles - T = ((T >> 2) & 0xFFFF0000) | (in & 0xFFFF); -*/ + T = __SHADD16(T, 0); /* it turns out doing this twice is 2 cycles, the + alternative takes 3 cycles */ + /* + in = ((int16_t) (T & 0xFFFF)) >> 2; // alternative code that takes + 3 cycles T = ((T >> 2) & 0xFFFF0000) | (in & + 0xFFFF); + */ /* Read yc (real), xc(imag) input */ - S = read_q15x2 (pSi2); + S = read_q15x2(pSi2); S = __SHADD16(S, 0); S = __SHADD16(S, 0); @@ -217,12 +203,12 @@ void arm_radix4_butterfly_q15( /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */ /* Read yb (real), xb(imag) input */ - T = read_q15x2 (pSi1); + T = read_q15x2(pSi1); T = __SHADD16(T, 0); T = __SHADD16(T, 0); /* Read yd (real), xd(imag) input */ - U = read_q15x2 (pSi3); + U = read_q15x2(pSi3); U = __SHADD16(U, 0); U = __SHADD16(U, 0); @@ -232,13 +218,13 @@ void arm_radix4_butterfly_q15( /* writing the butterfly processed i0 sample */ /* xa' = xa + xb + xc + xd */ /* ya' = ya + yb + yc + yd */ - write_q15x2_ia (&pSi0, __SHADD16(R, T)); + write_q15x2_ia(&pSi0, __SHADD16(R, T)); /* R = packed((ya + yc) - (yb + yd), (xa + xc)- (xb + xd)) */ R = __QSUB16(R, T); /* co2 & si2 are read from SIMD Coefficient pointer */ - C2 = read_q15x2 ((q15_t *) pCoef16 + (4U * ic)); + C2 = read_q15x2((q15_t *)pCoef16 + (4U * ic)); #ifndef ARM_MATH_BIG_ENDIAN /* xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */ @@ -254,17 +240,17 @@ void arm_radix4_butterfly_q15( /* Reading i0+fftLen/4 */ /* T = packed(yb, xb) */ - T = read_q15x2 (pSi1); + T = read_q15x2(pSi1); T = __SHADD16(T, 0); T = __SHADD16(T, 0); /* writing the butterfly processed i0 + fftLen/4 sample */ /* writing output(xc', yc') in little endian format */ - write_q15x2_ia (&pSi1, (q31_t) ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2_ia(&pSi1, (q31_t)((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); /* Butterfly calculations */ /* U = packed(yd, xd) */ - U = read_q15x2 (pSi3); + U = read_q15x2(pSi3); U = __SHADD16(U, 0); U = __SHADD16(U, 0); @@ -284,7 +270,7 @@ void arm_radix4_butterfly_q15( #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* co1 & si1 are read from SIMD Coefficient pointer */ - C1 = read_q15x2 ((q15_t *) pCoef16 + (2U * ic)); + C1 = read_q15x2((q15_t *)pCoef16 + (2U * ic)); /* Butterfly process for the i0+fftLen/2 sample */ #ifndef ARM_MATH_BIG_ENDIAN @@ -300,10 +286,10 @@ void arm_radix4_butterfly_q15( #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* writing output(xb', yb') in little endian format */ - write_q15x2_ia (&pSi2, ((out2) & 0xFFFF0000) | ((out1) & 0x0000FFFF)); + write_q15x2_ia(&pSi2, ((out2)&0xFFFF0000) | ((out1)&0x0000FFFF)); /* co3 & si3 are read from SIMD Coefficient pointer */ - C3 = read_q15x2 ((q15_t *) pCoef16 + (6U * ic)); + C3 = read_q15x2((q15_t *)pCoef16 + (6U * ic)); /* Butterfly process for the i0+3fftLen/4 sample */ #ifndef ARM_MATH_BIG_ENDIAN @@ -319,7 +305,7 @@ void arm_radix4_butterfly_q15( #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* writing output(xd', yd') in little endian format */ - write_q15x2_ia (&pSi3, ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2_ia(&pSi3, ((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); /* Twiddle coefficients index modifier */ ic = ic + twidCoefModifier; @@ -329,26 +315,23 @@ void arm_radix4_butterfly_q15( /* end of first stage process */ - /* start of middle stage process */ /* Twiddle coefficients index modifier */ twidCoefModifier <<= 2U; /* Calculation of Middle stage */ - for (k = fftLen / 4U; k > 4U; k >>= 2U) - { + for (k = fftLen / 4U; k > 4U; k >>= 2U) { /* Initializations for the middle stage */ n1 = n2; n2 >>= 2U; ic = 0U; - for (j = 0U; j <= (n2 - 1U); j++) - { + for (j = 0U; j <= (n2 - 1U); j++) { /* index calculation for the coefficients */ - C1 = read_q15x2 ((q15_t *) pCoef16 + (2U * ic)); - C2 = read_q15x2 ((q15_t *) pCoef16 + (4U * ic)); - C3 = read_q15x2 ((q15_t *) pCoef16 + (6U * ic)); + C1 = read_q15x2((q15_t *)pCoef16 + (2U * ic)); + C2 = read_q15x2((q15_t *)pCoef16 + (4U * ic)); + C3 = read_q15x2((q15_t *)pCoef16 + (6U * ic)); /* Twiddle coefficients index modifier */ ic = ic + twidCoefModifier; @@ -359,14 +342,13 @@ void arm_radix4_butterfly_q15( pSi3 = pSi2 + 2 * n2; /* Butterfly implementation */ - for (i0 = j; i0 < fftLen; i0 += n1) - { + for (i0 = j; i0 < fftLen; i0 += n1) { /* Reading i0, i0+fftLen/2 inputs */ /* Read ya (real), xa(imag) input */ - T = read_q15x2 (pSi0); + T = read_q15x2(pSi0); /* Read yc (real), xc(imag) input */ - S = read_q15x2 (pSi2); + S = read_q15x2(pSi2); /* R = packed( (ya + yc), (xa + xc)) */ R = __QADD16(T, S); @@ -376,10 +358,10 @@ void arm_radix4_butterfly_q15( /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */ /* Read yb (real), xb(imag) input */ - T = read_q15x2 (pSi1); + T = read_q15x2(pSi1); /* Read yd (real), xd(imag) input */ - U = read_q15x2 (pSi3); + U = read_q15x2(pSi3); /* T = packed( (yb + yd), (xb + xd)) */ T = __QADD16(T, U); @@ -390,7 +372,7 @@ void arm_radix4_butterfly_q15( /* ya' = ya + yb + yc + yd */ out1 = __SHADD16(R, T); out1 = __SHADD16(out1, 0); - write_q15x2 (pSi0, out1); + write_q15x2(pSi0, out1); pSi0 += 2 * n1; /* R = packed( (ya + yc) - (yb + yd), (xa + xc) - (xb + xd)) */ @@ -412,18 +394,18 @@ void arm_radix4_butterfly_q15( /* Reading i0+3fftLen/4 */ /* Read yb (real), xb(imag) input */ - T = read_q15x2 (pSi1); + T = read_q15x2(pSi1); /* writing the butterfly processed i0 + fftLen/4 sample */ /* xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */ /* yc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */ - write_q15x2 (pSi1, ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2(pSi1, ((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); pSi1 += 2 * n1; /* Butterfly calculations */ /* Read yd (real), xd(imag) input */ - U = read_q15x2 (pSi3); + U = read_q15x2(pSi3); /* T = packed(yb-yd, xb-xd) */ T = __QSUB16(T, U); @@ -435,7 +417,6 @@ void arm_radix4_butterfly_q15( /* S = packed((ya-yc) - (xb- xd), (xa-xc) + (yb-yd)) */ S = __SHSAX(S, T); - /* Butterfly process for the i0+fftLen/2 sample */ out1 = __SMUAD(C1, S) >> 16U; out2 = __SMUSDX(C1, S); @@ -446,7 +427,6 @@ void arm_radix4_butterfly_q15( /* S = packed((ya-yc) - (xb- xd), (xa-xc) + (yb-yd)) */ S = __SHASX(S, T); - /* Butterfly process for the i0+fftLen/2 sample */ out1 = __SMUSDX(S, C1) >> 16U; out2 = __SMUAD(C1, S); @@ -454,7 +434,7 @@ void arm_radix4_butterfly_q15( /* xb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */ /* yb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */ - write_q15x2 (pSi2, ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2(pSi2, ((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); pSi2 += 2 * n1; /* Butterfly process for the i0+3fftLen/4 sample */ @@ -469,7 +449,7 @@ void arm_radix4_butterfly_q15( /* xd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (si3) */ /* yd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (si3) */ - write_q15x2 (pSi3, ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2(pSi3, ((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); pSi3 += 2 * n1; } } @@ -478,7 +458,6 @@ void arm_radix4_butterfly_q15( } /* end of middle stage process */ - /* data is in 10.6(q6) format for the 1024 point */ /* data is in 8.8(q8) format for the 256 point */ /* data is in 6.10(q10) format for the 64 point */ @@ -492,19 +471,18 @@ void arm_radix4_butterfly_q15( /* start of last stage process */ /* Butterfly implementation */ - do - { + do { /* Read xa (real), ya(imag) input */ - xaya = read_q15x2_ia ((q15_t **) &ptr1); + xaya = read_q15x2_ia((q15_t **)&ptr1); /* Read xb (real), yb(imag) input */ - xbyb = read_q15x2_ia ((q15_t **) &ptr1); + xbyb = read_q15x2_ia((q15_t **)&ptr1); /* Read xc (real), yc(imag) input */ - xcyc = read_q15x2_ia ((q15_t **) &ptr1); + xcyc = read_q15x2_ia((q15_t **)&ptr1); /* Read xd (real), yd(imag) input */ - xdyd = read_q15x2_ia ((q15_t **) &ptr1); + xdyd = read_q15x2_ia((q15_t **)&ptr1); /* R = packed((ya + yc), (xa + xc)) */ R = __QADD16(xaya, xcyc); @@ -515,17 +493,16 @@ void arm_radix4_butterfly_q15( /* pointer updation for writing */ ptr1 = ptr1 - 8U; - /* xa' = xa + xb + xc + xd */ /* ya' = ya + yb + yc + yd */ - write_q15x2_ia (&ptr1, __SHADD16(R, T)); + write_q15x2_ia(&ptr1, __SHADD16(R, T)); /* T = packed((yb + yd), (xb + xd)) */ T = __QADD16(xbyb, xdyd); /* xc' = (xa-xb+xc-xd) */ /* yc' = (ya-yb+yc-yd) */ - write_q15x2_ia (&ptr1, __SHSUB16(R, T)); + write_q15x2_ia(&ptr1, __SHSUB16(R, T)); /* S = packed((ya - yc), (xa - xc)) */ S = __QSUB16(xaya, xcyc); @@ -537,19 +514,19 @@ void arm_radix4_butterfly_q15( #ifndef ARM_MATH_BIG_ENDIAN /* xb' = (xa+yb-xc-yd) */ /* yb' = (ya-xb-yc+xd) */ - write_q15x2_ia (&ptr1, __SHSAX(S, U)); + write_q15x2_ia(&ptr1, __SHSAX(S, U)); /* xd' = (xa-yb-xc+yd) */ /* yd' = (ya+xb-yc-xd) */ - write_q15x2_ia (&ptr1, __SHASX(S, U)); + write_q15x2_ia(&ptr1, __SHASX(S, U)); #else /* xb' = (xa+yb-xc-yd) */ /* yb' = (ya-xb-yc+xd) */ - write_q15x2_ia (&ptr1, __SHASX(S, U)); + write_q15x2_ia(&ptr1, __SHASX(S, U)); /* xd' = (xa-yb-xc+yd) */ /* yd' = (ya+xb-yc-xd) */ - write_q15x2_ia (&ptr1, __SHSAX(S, U)); + write_q15x2_ia(&ptr1, __SHSAX(S, U)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ } while (--j); @@ -561,12 +538,11 @@ void arm_radix4_butterfly_q15( /* output is in 7.9(q9) format for the 64 point */ /* output is in 5.11(q11) format for the 16 point */ - #else /* #if defined (ARM_MATH_DSP) */ - q15_t R0, R1, S0, S1, T0, T1, U0, U1; - q15_t Co1, Si1, Co2, Si2, Co3, Si3, out1, out2; - uint32_t n1, n2, ic, i0, i1, i2, i3, j, k; + q15_t R0, R1, S0, S1, T0, T1, U0, U1; + q15_t Co1, Si1, Co2, Si2, Co3, Si3, out1, out2; + uint32_t n1, n2, ic, i0, i1, i2, i3, j, k; /* Total process is divided into three stages */ @@ -589,12 +565,12 @@ void arm_radix4_butterfly_q15( /* Input is in 1.15(q15) format */ /* start of first stage process */ - do - { + do { /* Butterfly implementation */ /* index calculation for the input as, */ - /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */ + /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + * + 3fftLen/4] */ i1 = i0 + n2; i2 = i1 + n2; i3 = i2 + n2; @@ -653,9 +629,9 @@ void arm_radix4_butterfly_q15( Si2 = pCoef16[(2U * ic * 2U) + 1]; /* xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */ - out1 = (q15_t) ((Co2 * R0 + Si2 * R1) >> 16U); + out1 = (q15_t)((Co2 * R0 + Si2 * R1) >> 16U); /* yc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */ - out2 = (q15_t) ((-Si2 * R0 + Co2 * R1) >> 16U); + out2 = (q15_t)((-Si2 * R0 + Co2 * R1) >> 16U); /* Reading i0+fftLen/4 */ /* input is down scale by 4 to avoid overflow */ @@ -679,21 +655,21 @@ void arm_radix4_butterfly_q15( T1 = __SSAT(T1 - U1, 16); /* R1 = (ya-yc) + (xb- xd), R0 = (xa-xc) - (yb-yd)) */ - R0 = (q15_t) __SSAT((q31_t) (S0 - T1), 16); - R1 = (q15_t) __SSAT((q31_t) (S1 + T0), 16); + R0 = (q15_t)__SSAT((q31_t)(S0 - T1), 16); + R1 = (q15_t)__SSAT((q31_t)(S1 + T0), 16); /* S1 = (ya-yc) - (xb- xd), S0 = (xa-xc) + (yb-yd)) */ - S0 = (q15_t) __SSAT(((q31_t) S0 + T1), 16U); - S1 = (q15_t) __SSAT(((q31_t) S1 - T0), 16U); + S0 = (q15_t)__SSAT(((q31_t)S0 + T1), 16U); + S1 = (q15_t)__SSAT(((q31_t)S1 - T0), 16U); /* co1 & si1 are read from Coefficient pointer */ Co1 = pCoef16[ic * 2U]; Si1 = pCoef16[(ic * 2U) + 1]; /* Butterfly process for the i0+fftLen/2 sample */ /* xb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */ - out1 = (q15_t) ((Si1 * S1 + Co1 * S0) >> 16); + out1 = (q15_t)((Si1 * S1 + Co1 * S0) >> 16); /* yb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */ - out2 = (q15_t) ((-Si1 * S0 + Co1 * S1) >> 16); + out2 = (q15_t)((-Si1 * S0 + Co1 * S1) >> 16); /* writing output(xb', yb') in little endian format */ pSrc16[i2 * 2U] = out1; @@ -704,9 +680,9 @@ void arm_radix4_butterfly_q15( Si3 = pCoef16[(3U * (ic * 2U)) + 1]; /* Butterfly process for the i0+3fftLen/4 sample */ /* xd' = (xa-yb-xc+yd)* Co3 + (ya+xb-yc-xd)* (si3) */ - out1 = (q15_t) ((Si3 * R1 + Co3 * R0) >> 16U); + out1 = (q15_t)((Si3 * R1 + Co3 * R0) >> 16U); /* yd' = (ya+xb-yc-xd)* Co3 - (xa-yb-xc+yd)* (si3) */ - out2 = (q15_t) ((-Si3 * R0 + Co3 * R1) >> 16U); + out2 = (q15_t)((-Si3 * R0 + Co3 * R1) >> 16U); /* writing output(xd', yd') in little endian format */ pSrc16[i3 * 2U] = out1; pSrc16[(i3 * 2U) + 1] = out2; @@ -722,22 +698,19 @@ void arm_radix4_butterfly_q15( /* end of first stage process */ - /* start of middle stage process */ /* Twiddle coefficients index modifier */ twidCoefModifier <<= 2U; /* Calculation of Middle stage */ - for (k = fftLen / 4U; k > 4U; k >>= 2U) - { + for (k = fftLen / 4U; k > 4U; k >>= 2U) { /* Initializations for the middle stage */ n1 = n2; n2 >>= 2U; ic = 0U; - for (j = 0U; j <= (n2 - 1U); j++) - { + for (j = 0U; j <= (n2 - 1U); j++) { /* index calculation for the coefficients */ Co1 = pCoef16[ic * 2U]; Si1 = pCoef16[(ic * 2U) + 1U]; @@ -750,10 +723,10 @@ void arm_radix4_butterfly_q15( ic = ic + twidCoefModifier; /* Butterfly implementation */ - for (i0 = j; i0 < fftLen; i0 += n1) - { + for (i0 = j; i0 < fftLen; i0 += n1) { /* index calculation for the input as, */ - /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */ + /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], + * pSrc16[i0 + 3fftLen/4] */ i1 = i0 + n2; i2 = i1 + n2; i3 = i2 + n2; @@ -784,7 +757,6 @@ void arm_radix4_butterfly_q15( U0 = pSrc16[i3 * 2U]; U1 = pSrc16[(i3 * 2U) + 1U]; - /* T0 = (yb + yd), T1 = (xb + xd) */ T0 = __SSAT(T0 + U0, 16); T1 = __SSAT(T1 + U1, 16); @@ -804,10 +776,10 @@ void arm_radix4_butterfly_q15( R1 = (R1 >> 1U) - (T1 >> 1U); /* (ya-yb+yc-yd)* (si2) + (xa-xb+xc-xd)* co2 */ - out1 = (q15_t) ((Co2 * R0 + Si2 * R1) >> 16U); + out1 = (q15_t)((Co2 * R0 + Si2 * R1) >> 16U); /* (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */ - out2 = (q15_t) ((-Si2 * R0 + Co2 * R1) >> 16U); + out2 = (q15_t)((-Si2 * R0 + Co2 * R1) >> 16U); /* Reading i0+3fftLen/4 */ /* Read yb (real), xb(imag) input */ @@ -839,9 +811,9 @@ void arm_radix4_butterfly_q15( S1 = (S1 >> 1U) - (T0 >> 1U); /* Butterfly process for the i0+fftLen/2 sample */ - out1 = (q15_t) ((Co1 * S0 + Si1 * S1) >> 16U); + out1 = (q15_t)((Co1 * S0 + Si1 * S1) >> 16U); - out2 = (q15_t) ((-Si1 * S0 + Co1 * S1) >> 16U); + out2 = (q15_t)((-Si1 * S0 + Co1 * S1) >> 16U); /* xb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */ /* yb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */ @@ -849,9 +821,9 @@ void arm_radix4_butterfly_q15( pSrc16[(i2 * 2U) + 1U] = out2; /* Butterfly process for the i0+3fftLen/4 sample */ - out1 = (q15_t) ((Si3 * R1 + Co3 * R0) >> 16U); + out1 = (q15_t)((Si3 * R1 + Co3 * R0) >> 16U); - out2 = (q15_t) ((-Si3 * R0 + Co3 * R1) >> 16U); + out2 = (q15_t)((-Si3 * R0 + Co3 * R1) >> 16U); /* xd' = (xa-yb-xc+yd)* Co3 + (ya+xb-yc-xd)* (si3) */ /* yd' = (ya+xb-yc-xd)* Co3 - (xa-yb-xc+yd)* (si3) */ pSrc16[i3 * 2U] = out1; @@ -863,7 +835,6 @@ void arm_radix4_butterfly_q15( } /* end of middle stage process */ - /* data is in 10.6(q6) format for the 1024 point */ /* data is in 8.8(q8) format for the 256 point */ /* data is in 6.10(q10) format for the 64 point */ @@ -876,10 +847,10 @@ void arm_radix4_butterfly_q15( /* start of last stage process */ /* Butterfly implementation */ - for (i0 = 0U; i0 <= (fftLen - n1); i0 += n1) - { + for (i0 = 0U; i0 <= (fftLen - n1); i0 += n1) { /* index calculation for the input as, */ - /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */ + /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + * + 3fftLen/4] */ i1 = i0 + n2; i2 = i1 + n2; i3 = i2 + n2; @@ -950,7 +921,6 @@ void arm_radix4_butterfly_q15( /* yd' = (ya+xb-yc-xd) */ pSrc16[i3 * 2U] = (S0 >> 1U) - (T1 >> 1U); pSrc16[(i3 * 2U) + 1U] = (S1 >> 1U) + (T0 >> 1U); - } /* end of last stage process */ @@ -961,16 +931,15 @@ void arm_radix4_butterfly_q15( /* output is in 5.11(q11) format for the 16 point */ #endif /* #if defined (ARM_MATH_DSP) */ - } - /** @brief Core function for the Q15 CIFFT butterfly process. @param[in,out] pSrc16 points to the in-place buffer of Q15 data type @param[in] fftLen length of the FFT @param[in] pCoef16 points to twiddle coefficient buffer - @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. + @param[in] twidCoefModifier twiddle coefficient modifier that supports + different size FFTs with the same twiddle factor table. @return none */ @@ -978,7 +947,8 @@ void arm_radix4_butterfly_q15( * Radix-4 IFFT algorithm used is : * * CIFFT uses same twiddle coefficients as CFFT function - * x[k] = x[n] + (j)k * x[n + fftLen/4] + (-1)k * x[n+fftLen/2] + (-j)k * x[n+3*fftLen/4] + * x[k] = x[n] + (j)k * x[n + fftLen/4] + (-1)k * x[n+fftLen/2] + (-j)k * + x[n+3*fftLen/4] * * * IFFT is implemented with following changes in equations from FFT @@ -1001,7 +971,7 @@ void arm_radix4_butterfly_q15( * Wn = co1 + j * (si1) * W2n = co2 + j * (si2) * W3n = co3 + j * (si3) - + * The real and imaginary output values for the radix-4 butterfly are * xa' = xa + xb + xc + xd * ya' = ya + yb + yc + yd @@ -1014,26 +984,23 @@ void arm_radix4_butterfly_q15( * */ -void arm_radix4_butterfly_inverse_q15( - q15_t * pSrc16, - uint32_t fftLen, - const q15_t * pCoef16, - uint32_t twidCoefModifier) -{ +void arm_radix4_butterfly_inverse_q15(q15_t *pSrc16, uint32_t fftLen, + const q15_t *pCoef16, + uint32_t twidCoefModifier) { -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) - q31_t R, S, T, U; - q31_t C1, C2, C3, out1, out2; - uint32_t n1, n2, ic, i0, j, k; - - q15_t *ptr1; - q15_t *pSi0; - q15_t *pSi1; - q15_t *pSi2; - q15_t *pSi3; - - q31_t xaya, xbyb, xcyc, xdyd; + q31_t R, S, T, U; + q31_t C1, C2, C3, out1, out2; + uint32_t n1, n2, ic, i0, j, k; + + q15_t *ptr1; + q15_t *pSi0; + q15_t *pSi1; + q15_t *pSi2; + q15_t *pSi3; + + q31_t xaya, xbyb, xcyc, xdyd; /* Total process is divided into three stages */ @@ -1060,18 +1027,17 @@ void arm_radix4_butterfly_inverse_q15( /* Input is in 1.15(q15) format */ /* start of first stage process */ - do - { + do { /* Butterfly implementation */ /* Reading i0, i0+fftLen/2 inputs */ /* Read ya (real), xa(imag) input */ - T = read_q15x2 (pSi0); + T = read_q15x2(pSi0); T = __SHADD16(T, 0); T = __SHADD16(T, 0); /* Read yc (real), xc(imag) input */ - S = read_q15x2 (pSi2); + S = read_q15x2(pSi2); S = __SHADD16(S, 0); S = __SHADD16(S, 0); @@ -1083,12 +1049,12 @@ void arm_radix4_butterfly_inverse_q15( /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */ /* Read yb (real), xb(imag) input */ - T = read_q15x2 (pSi1); + T = read_q15x2(pSi1); T = __SHADD16(T, 0); T = __SHADD16(T, 0); /* Read yd (real), xd(imag) input */ - U = read_q15x2 (pSi3); + U = read_q15x2(pSi3); U = __SHADD16(U, 0); U = __SHADD16(U, 0); @@ -1098,13 +1064,13 @@ void arm_radix4_butterfly_inverse_q15( /* writing the butterfly processed i0 sample */ /* xa' = xa + xb + xc + xd */ /* ya' = ya + yb + yc + yd */ - write_q15x2_ia (&pSi0, __SHADD16(R, T)); + write_q15x2_ia(&pSi0, __SHADD16(R, T)); /* R = packed((ya + yc) - (yb + yd), (xa + xc)- (xb + xd)) */ R = __QSUB16(R, T); /* co2 & si2 are read from SIMD Coefficient pointer */ - C2 = read_q15x2 ((q15_t *) pCoef16 + (4U * ic)); + C2 = read_q15x2((q15_t *)pCoef16 + (4U * ic)); #ifndef ARM_MATH_BIG_ENDIAN /* xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */ @@ -1120,17 +1086,17 @@ void arm_radix4_butterfly_inverse_q15( /* Reading i0+fftLen/4 */ /* T = packed(yb, xb) */ - T = read_q15x2 (pSi1); + T = read_q15x2(pSi1); T = __SHADD16(T, 0); T = __SHADD16(T, 0); /* writing the butterfly processed i0 + fftLen/4 sample */ /* writing output(xc', yc') in little endian format */ - write_q15x2_ia (&pSi1, (q31_t) ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2_ia(&pSi1, (q31_t)((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); /* Butterfly calculations */ /* U = packed(yd, xd) */ - U = read_q15x2 (pSi3); + U = read_q15x2(pSi3); U = __SHADD16(U, 0); U = __SHADD16(U, 0); @@ -1150,7 +1116,7 @@ void arm_radix4_butterfly_inverse_q15( #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* co1 & si1 are read from SIMD Coefficient pointer */ - C1 = read_q15x2 ((q15_t *) pCoef16 + (2U * ic)); + C1 = read_q15x2((q15_t *)pCoef16 + (2U * ic)); /* Butterfly process for the i0+fftLen/2 sample */ #ifndef ARM_MATH_BIG_ENDIAN @@ -1166,10 +1132,10 @@ void arm_radix4_butterfly_inverse_q15( #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* writing output(xb', yb') in little endian format */ - write_q15x2_ia (&pSi2, ((out2) & 0xFFFF0000) | ((out1) & 0x0000FFFF)); + write_q15x2_ia(&pSi2, ((out2)&0xFFFF0000) | ((out1)&0x0000FFFF)); /* co3 & si3 are read from SIMD Coefficient pointer */ - C3 = read_q15x2 ((q15_t *) pCoef16 + (6U * ic)); + C3 = read_q15x2((q15_t *)pCoef16 + (6U * ic)); /* Butterfly process for the i0+3fftLen/4 sample */ #ifndef ARM_MATH_BIG_ENDIAN @@ -1185,7 +1151,7 @@ void arm_radix4_butterfly_inverse_q15( #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ /* writing output(xd', yd') in little endian format */ - write_q15x2_ia (&pSi3, ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2_ia(&pSi3, ((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); /* Twiddle coefficients index modifier */ ic = ic + twidCoefModifier; @@ -1195,26 +1161,23 @@ void arm_radix4_butterfly_inverse_q15( /* end of first stage process */ - /* start of middle stage process */ /* Twiddle coefficients index modifier */ twidCoefModifier <<= 2U; /* Calculation of Middle stage */ - for (k = fftLen / 4U; k > 4U; k >>= 2U) - { + for (k = fftLen / 4U; k > 4U; k >>= 2U) { /* Initializations for the middle stage */ n1 = n2; n2 >>= 2U; ic = 0U; - for (j = 0U; j <= (n2 - 1U); j++) - { + for (j = 0U; j <= (n2 - 1U); j++) { /* index calculation for the coefficients */ - C1 = read_q15x2 ((q15_t *) pCoef16 + (2U * ic)); - C2 = read_q15x2 ((q15_t *) pCoef16 + (4U * ic)); - C3 = read_q15x2 ((q15_t *) pCoef16 + (6U * ic)); + C1 = read_q15x2((q15_t *)pCoef16 + (2U * ic)); + C2 = read_q15x2((q15_t *)pCoef16 + (4U * ic)); + C3 = read_q15x2((q15_t *)pCoef16 + (6U * ic)); /* Twiddle coefficients index modifier */ ic = ic + twidCoefModifier; @@ -1225,14 +1188,13 @@ void arm_radix4_butterfly_inverse_q15( pSi3 = pSi2 + 2 * n2; /* Butterfly implementation */ - for (i0 = j; i0 < fftLen; i0 += n1) - { + for (i0 = j; i0 < fftLen; i0 += n1) { /* Reading i0, i0+fftLen/2 inputs */ /* Read ya (real), xa(imag) input */ - T = read_q15x2 (pSi0); + T = read_q15x2(pSi0); /* Read yc (real), xc(imag) input */ - S = read_q15x2 (pSi2); + S = read_q15x2(pSi2); /* R = packed( (ya + yc), (xa + xc)) */ R = __QADD16(T, S); @@ -1242,10 +1204,10 @@ void arm_radix4_butterfly_inverse_q15( /* Reading i0+fftLen/4 , i0+3fftLen/4 inputs */ /* Read yb (real), xb(imag) input */ - T = read_q15x2 (pSi1); + T = read_q15x2(pSi1); /* Read yd (real), xd(imag) input */ - U = read_q15x2 (pSi3); + U = read_q15x2(pSi3); /* T = packed( (yb + yd), (xb + xd)) */ T = __QADD16(T, U); @@ -1256,7 +1218,7 @@ void arm_radix4_butterfly_inverse_q15( /* ya' = ya + yb + yc + yd */ out1 = __SHADD16(R, T); out1 = __SHADD16(out1, 0); - write_q15x2 (pSi0, out1); + write_q15x2(pSi0, out1); pSi0 += 2 * n1; /* R = packed( (ya + yc) - (yb + yd), (xa + xc) - (xb + xd)) */ @@ -1278,18 +1240,18 @@ void arm_radix4_butterfly_inverse_q15( /* Reading i0+3fftLen/4 */ /* Read yb (real), xb(imag) input */ - T = read_q15x2 (pSi1); + T = read_q15x2(pSi1); /* writing the butterfly processed i0 + fftLen/4 sample */ /* xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2) */ /* yc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2) */ - write_q15x2 (pSi1, ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2(pSi1, ((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); pSi1 += 2 * n1; /* Butterfly calculations */ /* Read yd (real), xd(imag) input */ - U = read_q15x2 (pSi3); + U = read_q15x2(pSi3); /* T = packed(yb-yd, xb-xd) */ T = __QSUB16(T, U); @@ -1318,7 +1280,7 @@ void arm_radix4_butterfly_inverse_q15( /* xb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1) */ /* yb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1) */ - write_q15x2 (pSi2, ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2(pSi2, ((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); pSi2 += 2 * n1; /* Butterfly process for the i0+3fftLen/4 sample */ @@ -1333,7 +1295,7 @@ void arm_radix4_butterfly_inverse_q15( /* xd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (si3) */ /* yd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (si3) */ - write_q15x2 (pSi3, ((out2) & 0xFFFF0000) | (out1 & 0x0000FFFF)); + write_q15x2(pSi3, ((out2)&0xFFFF0000) | (out1 & 0x0000FFFF)); pSi3 += 2 * n1; } } @@ -1355,19 +1317,18 @@ void arm_radix4_butterfly_inverse_q15( /* start of last stage process */ /* Butterfly implementation */ - do - { + do { /* Read xa (real), ya(imag) input */ - xaya = read_q15x2_ia ((q15_t **) &ptr1); + xaya = read_q15x2_ia((q15_t **)&ptr1); /* Read xb (real), yb(imag) input */ - xbyb = read_q15x2_ia ((q15_t **) &ptr1); + xbyb = read_q15x2_ia((q15_t **)&ptr1); /* Read xc (real), yc(imag) input */ - xcyc = read_q15x2_ia ((q15_t **) &ptr1); + xcyc = read_q15x2_ia((q15_t **)&ptr1); /* Read xd (real), yd(imag) input */ - xdyd = read_q15x2_ia ((q15_t **) &ptr1); + xdyd = read_q15x2_ia((q15_t **)&ptr1); /* R = packed((ya + yc), (xa + xc)) */ R = __QADD16(xaya, xcyc); @@ -1378,17 +1339,16 @@ void arm_radix4_butterfly_inverse_q15( /* pointer updation for writing */ ptr1 = ptr1 - 8U; - /* xa' = xa + xb + xc + xd */ /* ya' = ya + yb + yc + yd */ - write_q15x2_ia (&ptr1, __SHADD16(R, T)); + write_q15x2_ia(&ptr1, __SHADD16(R, T)); /* T = packed((yb + yd), (xb + xd)) */ T = __QADD16(xbyb, xdyd); /* xc' = (xa-xb+xc-xd) */ /* yc' = (ya-yb+yc-yd) */ - write_q15x2_ia (&ptr1, __SHSUB16(R, T)); + write_q15x2_ia(&ptr1, __SHSUB16(R, T)); /* S = packed((ya - yc), (xa - xc)) */ S = __QSUB16(xaya, xcyc); @@ -1400,19 +1360,19 @@ void arm_radix4_butterfly_inverse_q15( #ifndef ARM_MATH_BIG_ENDIAN /* xb' = (xa+yb-xc-yd) */ /* yb' = (ya-xb-yc+xd) */ - write_q15x2_ia (&ptr1, __SHASX(S, U)); + write_q15x2_ia(&ptr1, __SHASX(S, U)); /* xd' = (xa-yb-xc+yd) */ /* yd' = (ya+xb-yc-xd) */ - write_q15x2_ia (&ptr1, __SHSAX(S, U)); + write_q15x2_ia(&ptr1, __SHSAX(S, U)); #else /* xb' = (xa+yb-xc-yd) */ /* yb' = (ya-xb-yc+xd) */ - write_q15x2_ia (&ptr1, __SHSAX(S, U)); + write_q15x2_ia(&ptr1, __SHSAX(S, U)); /* xd' = (xa-yb-xc+yd) */ /* yd' = (ya+xb-yc-xd) */ - write_q15x2_ia (&ptr1, __SHASX(S, U)); + write_q15x2_ia(&ptr1, __SHASX(S, U)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ } while (--j); @@ -1424,12 +1384,11 @@ void arm_radix4_butterfly_inverse_q15( /* output is in 7.9(q9) format for the 64 point */ /* output is in 5.11(q11) format for the 16 point */ - #else /* arm_radix4_butterfly_inverse_q15 */ - q15_t R0, R1, S0, S1, T0, T1, U0, U1; - q15_t Co1, Si1, Co2, Si2, Co3, Si3, out1, out2; - uint32_t n1, n2, ic, i0, i1, i2, i3, j, k; + q15_t R0, R1, S0, S1, T0, T1, U0, U1; + q15_t Co1, Si1, Co2, Si2, Co3, Si3, out1, out2; + uint32_t n1, n2, ic, i0, i1, i2, i3, j, k; /* Total process is divided into three stages */ @@ -1453,12 +1412,12 @@ void arm_radix4_butterfly_inverse_q15( /* Input is in 1.15(q15) format */ /* Start of first stage process */ - do - { + do { /* Butterfly implementation */ /* index calculation for the input as, */ - /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */ + /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + * + 3fftLen/4] */ i1 = i0 + n2; i2 = i1 + n2; i3 = i2 + n2; @@ -1507,9 +1466,9 @@ void arm_radix4_butterfly_inverse_q15( Co2 = pCoef16[2U * ic * 2U]; Si2 = pCoef16[(2U * ic * 2U) + 1U]; /* xc' = (xa-xb+xc-xd)* co2 - (ya-yb+yc-yd)* (si2) */ - out1 = (q15_t) ((Co2 * R0 - Si2 * R1) >> 16U); + out1 = (q15_t)((Co2 * R0 - Si2 * R1) >> 16U); /* yc' = (ya-yb+yc-yd)* co2 + (xa-xb+xc-xd)* (si2) */ - out2 = (q15_t) ((Si2 * R0 + Co2 * R1) >> 16U); + out2 = (q15_t)((Si2 * R0 + Co2 * R1) >> 16U); /* Reading i0+fftLen/4 */ /* input is down scale by 4 to avoid overflow */ @@ -1532,20 +1491,20 @@ void arm_radix4_butterfly_inverse_q15( T0 = __SSAT(T0 - U0, 16U); T1 = __SSAT(T1 - U1, 16U); /* R0 = (ya-yc) - (xb- xd) , R1 = (xa-xc) + (yb-yd) */ - R0 = (q15_t) __SSAT((q31_t) (S0 + T1), 16); - R1 = (q15_t) __SSAT((q31_t) (S1 - T0), 16); + R0 = (q15_t)__SSAT((q31_t)(S0 + T1), 16); + R1 = (q15_t)__SSAT((q31_t)(S1 - T0), 16); /* S = (ya-yc) + (xb- xd), S1 = (xa-xc) - (yb-yd) */ - S0 = (q15_t) __SSAT((q31_t) (S0 - T1), 16); - S1 = (q15_t) __SSAT((q31_t) (S1 + T0), 16); + S0 = (q15_t)__SSAT((q31_t)(S0 - T1), 16); + S1 = (q15_t)__SSAT((q31_t)(S1 + T0), 16); /* co1 & si1 are read from Coefficient pointer */ Co1 = pCoef16[ic * 2U]; Si1 = pCoef16[(ic * 2U) + 1U]; /* Butterfly process for the i0+fftLen/2 sample */ /* xb' = (xa-yb-xc+yd)* co1 - (ya+xb-yc-xd)* (si1) */ - out1 = (q15_t) ((Co1 * S0 - Si1 * S1) >> 16U); + out1 = (q15_t)((Co1 * S0 - Si1 * S1) >> 16U); /* yb' = (ya+xb-yc-xd)* co1 + (xa-yb-xc+yd)* (si1) */ - out2 = (q15_t) ((Si1 * S0 + Co1 * S1) >> 16U); + out2 = (q15_t)((Si1 * S0 + Co1 * S1) >> 16U); /* writing output(xb', yb') in little endian format */ pSrc16[i2 * 2U] = out1; pSrc16[(i2 * 2U) + 1U] = out2; @@ -1555,9 +1514,9 @@ void arm_radix4_butterfly_inverse_q15( Si3 = pCoef16[(3U * ic * 2U) + 1U]; /* Butterfly process for the i0+3fftLen/4 sample */ /* xd' = (xa+yb-xc-yd)* Co3 - (ya-xb-yc+xd)* (si3) */ - out1 = (q15_t) ((Co3 * R0 - Si3 * R1) >> 16U); + out1 = (q15_t)((Co3 * R0 - Si3 * R1) >> 16U); /* yd' = (ya-xb-yc+xd)* Co3 + (xa+yb-xc-yd)* (si3) */ - out2 = (q15_t) ((Si3 * R0 + Co3 * R1) >> 16U); + out2 = (q15_t)((Si3 * R0 + Co3 * R1) >> 16U); /* writing output(xd', yd') in little endian format */ pSrc16[i3 * 2U] = out1; pSrc16[(i3 * 2U) + 1U] = out2; @@ -1574,22 +1533,19 @@ void arm_radix4_butterfly_inverse_q15( /* data is in 4.11(q11) format */ - /* Start of Middle stage process */ /* Twiddle coefficients index modifier */ twidCoefModifier <<= 2U; /* Calculation of Middle stage */ - for (k = fftLen / 4U; k > 4U; k >>= 2U) - { + for (k = fftLen / 4U; k > 4U; k >>= 2U) { /* Initializations for the middle stage */ n1 = n2; n2 >>= 2U; ic = 0U; - for (j = 0U; j <= (n2 - 1U); j++) - { + for (j = 0U; j <= (n2 - 1U); j++) { /* index calculation for the coefficients */ Co1 = pCoef16[ic * 2U]; Si1 = pCoef16[(ic * 2U) + 1U]; @@ -1602,10 +1558,10 @@ void arm_radix4_butterfly_inverse_q15( ic = ic + twidCoefModifier; /* Butterfly implementation */ - for (i0 = j; i0 < fftLen; i0 += n1) - { + for (i0 = j; i0 < fftLen; i0 += n1) { /* index calculation for the input as, */ - /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */ + /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], + * pSrc16[i0 + 3fftLen/4] */ i1 = i0 + n2; i2 = i1 + n2; i3 = i2 + n2; @@ -1619,7 +1575,6 @@ void arm_radix4_butterfly_inverse_q15( S0 = pSrc16[i2 * 2U]; S1 = pSrc16[(i2 * 2U) + 1U]; - /* R0 = (ya + yc), R1 = (xa + xc) */ R0 = __SSAT(T0 + S0, 16U); R1 = __SSAT(T1 + S1, 16U); @@ -1651,9 +1606,9 @@ void arm_radix4_butterfly_inverse_q15( R1 = (R1 >> 1U) - (T1 >> 1U); /* (ya-yb+yc-yd)* (si2) - (xa-xb+xc-xd)* co2 */ - out1 = (q15_t) ((Co2 * R0 - Si2 * R1) >> 16); + out1 = (q15_t)((Co2 * R0 - Si2 * R1) >> 16); /* (ya-yb+yc-yd)* co2 + (xa-xb+xc-xd)* (si2) */ - out2 = (q15_t) ((Si2 * R0 + Co2 * R1) >> 16); + out2 = (q15_t)((Si2 * R0 + Co2 * R1) >> 16); /* Reading i0+3fftLen/4 */ /* Read yb (real), xb(imag) input */ @@ -1684,23 +1639,21 @@ void arm_radix4_butterfly_inverse_q15( S1 = (S1 >> 1U) + (T0 >> 1U); /* Butterfly process for the i0+fftLen/2 sample */ - out1 = (q15_t) ((Co1 * S0 - Si1 * S1) >> 16U); - out2 = (q15_t) ((Si1 * S0 + Co1 * S1) >> 16U); + out1 = (q15_t)((Co1 * S0 - Si1 * S1) >> 16U); + out2 = (q15_t)((Si1 * S0 + Co1 * S1) >> 16U); /* xb' = (xa-yb-xc+yd)* co1 - (ya+xb-yc-xd)* (si1) */ /* yb' = (ya+xb-yc-xd)* co1 + (xa-yb-xc+yd)* (si1) */ pSrc16[i2 * 2U] = out1; pSrc16[(i2 * 2U) + 1U] = out2; /* Butterfly process for the i0+3fftLen/4 sample */ - out1 = (q15_t) ((Co3 * R0 - Si3 * R1) >> 16U); + out1 = (q15_t)((Co3 * R0 - Si3 * R1) >> 16U); - out2 = (q15_t) ((Si3 * R0 + Co3 * R1) >> 16U); + out2 = (q15_t)((Si3 * R0 + Co3 * R1) >> 16U); /* xd' = (xa+yb-xc-yd)* Co3 - (ya-xb-yc+xd)* (si3) */ /* yd' = (ya-xb-yc+xd)* Co3 + (xa+yb-xc-yd)* (si3) */ pSrc16[i3 * 2U] = out1; pSrc16[(i3 * 2U) + 1U] = out2; - - } } /* Twiddle coefficients index modifier */ @@ -1708,7 +1661,6 @@ void arm_radix4_butterfly_inverse_q15( } /* End of Middle stages process */ - /* data is in 10.6(q6) format for the 1024 point */ /* data is in 8.8(q8) format for the 256 point */ /* data is in 6.10(q10) format for the 64 point */ @@ -1716,16 +1668,15 @@ void arm_radix4_butterfly_inverse_q15( /* start of last stage process */ - /* Initializations for the last stage */ n1 = n2; n2 >>= 2U; /* Butterfly implementation */ - for (i0 = 0U; i0 <= (fftLen - n1); i0 += n1) - { + for (i0 = 0U; i0 <= (fftLen - n1); i0 += n1) { /* index calculation for the input as, */ - /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + 3fftLen/4] */ + /* pSrc16[i0 + 0], pSrc16[i0 + fftLen/4], pSrc16[i0 + fftLen/2], pSrc16[i0 + * + 3fftLen/4] */ i1 = i0 + n2; i2 = i1 + n2; i3 = i2 + n2; @@ -1790,7 +1741,6 @@ void arm_radix4_butterfly_inverse_q15( pSrc16[i2 * 2U] = (S0 >> 1U) - (T1 >> 1U); pSrc16[(i2 * 2U) + 1U] = (S1 >> 1U) + (T0 >> 1U); - /* writing the butterfly processed i0 + 3fftLen/4 sample */ /* xd' = (xa+yb-xc-yd) */ /* yd' = (ya-xb-yc+xd) */ @@ -1805,5 +1755,4 @@ void arm_radix4_butterfly_inverse_q15( /* output is in 5.11(q11) format for the 16 point */ #endif /* #if defined (ARM_MATH_DSP) */ - } diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_q31.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_q31.c index a9a59dd..68ed2d0 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_q31.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix4_q31.c @@ -1,8 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_radix4_q31.c - * Description: This file has function definition of Radix-4 FFT & IFFT function and - * In-place bit reversal using bit reversal table + * Description: This file has function definition of Radix-4 FFT & IFFT + * function and In-place bit reversal using bit reversal table * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -29,23 +29,15 @@ #include "arm_math.h" -void arm_radix4_butterfly_inverse_q31( - q31_t * pSrc, - uint32_t fftLen, - const q31_t * pCoef, - uint32_t twidCoefModifier); +void arm_radix4_butterfly_inverse_q31(q31_t *pSrc, uint32_t fftLen, + const q31_t *pCoef, + uint32_t twidCoefModifier); -void arm_radix4_butterfly_q31( - q31_t * pSrc, - uint32_t fftLen, - const q31_t * pCoef, - uint32_t twidCoefModifier); +void arm_radix4_butterfly_q31(q31_t *pSrc, uint32_t fftLen, const q31_t *pCoef, + uint32_t twidCoefModifier); -void arm_bitreversal_q31( - q31_t * pSrc, - uint32_t fftLen, - uint16_t bitRevFactor, - const uint16_t * pBitRevTab); +void arm_bitreversal_q31(q31_t *pSrc, uint32_t fftLen, uint16_t bitRevFactor, + const uint16_t *pBitRevTab); /** @ingroup groupTransforms @@ -58,41 +50,39 @@ void arm_bitreversal_q31( /** @brief Processing function for the Q31 CFFT/CIFFT. - @deprecated Do not use this function. It has been superseded by \ref arm_cfft_q31 and will be removed in the future. + @deprecated Do not use this function. It has been superseded by \ref + arm_cfft_q31 and will be removed in the future. @param[in] S points to an instance of the Q31 CFFT/CIFFT structure - @param[in,out] pSrc points to the complex data buffer of size 2*fftLen. Processing occurs in-place + @param[in,out] pSrc points to the complex data buffer of size + 2*fftLen. Processing occurs in-place @return none - + @par Input and output formats: - Internally input is downscaled by 2 for every stage to avoid saturations inside CFFT/CIFFT process. - Hence the output format is different for different FFT sizes. - The input and output formats for different FFT sizes and number of bits to upscale are mentioned in the tables below for CFFT and CIFFT: + Internally input is downscaled by 2 for every stage to avoid + saturations inside CFFT/CIFFT process. Hence the output format is different + for different FFT sizes. The input and output formats for different FFT sizes + and number of bits to upscale are mentioned in the tables below for CFFT and + CIFFT: @par \image html CFFTQ31.gif "Input and Output Formats for Q31 CFFT" - \image html CIFFTQ31.gif "Input and Output Formats for Q31 CIFFT" + \image html CIFFTQ31.gif "Input and Output Formats for Q31 + CIFFT" */ -void arm_cfft_radix4_q31( - const arm_cfft_radix4_instance_q31 * S, - q31_t * pSrc) -{ - if (S->ifftFlag == 1U) - { +void arm_cfft_radix4_q31(const arm_cfft_radix4_instance_q31 *S, q31_t *pSrc) { + if (S->ifftFlag == 1U) { /* Complex IFFT radix-4 */ - arm_radix4_butterfly_inverse_q31(pSrc, S->fftLen, S->pTwiddle, S->twidCoefModifier); - } - else - { + arm_radix4_butterfly_inverse_q31(pSrc, S->fftLen, S->pTwiddle, + S->twidCoefModifier); + } else { /* Complex FFT radix-4 */ arm_radix4_butterfly_q31(pSrc, S->fftLen, S->pTwiddle, S->twidCoefModifier); } - if (S->bitReverseFlag == 1U) - { + if (S->bitReverseFlag == 1U) { /* Bit Reversal */ arm_bitreversal_q31(pSrc, S->fftLen, S->bitRevFactor, S->pBitRevTable); } - } /** @@ -135,34 +125,31 @@ void arm_cfft_radix4_q31( /** @brief Core function for the Q31 CFFT butterfly process. - @param[in,out] pSrc points to the in-place buffer of Q31 data type. + @param[in,out] pSrc points to the in-place buffer of Q31 data + type. @param[in] fftLen length of the FFT. @param[in] pCoef points to twiddle coefficient buffer. - @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. + @param[in] twidCoefModifier twiddle coefficient modifier that supports + different size FFTs with the same twiddle factor table. @return none */ -void arm_radix4_butterfly_q31( - q31_t * pSrc, - uint32_t fftLen, - const q31_t * pCoef, - uint32_t twidCoefModifier) -{ - uint32_t n1, n2, ia1, ia2, ia3, i0, i1, i2, i3, j, k; - q31_t t1, t2, r1, r2, s1, s2, co1, co2, co3, si1, si2, si3; - - q31_t xa, xb, xc, xd; - q31_t ya, yb, yc, yd; - q31_t xa_out, xb_out, xc_out, xd_out; - q31_t ya_out, yb_out, yc_out, yd_out; - - q31_t *ptr1; +void arm_radix4_butterfly_q31(q31_t *pSrc, uint32_t fftLen, const q31_t *pCoef, + uint32_t twidCoefModifier) { + uint32_t n1, n2, ia1, ia2, ia3, i0, i1, i2, i3, j, k; + q31_t t1, t2, r1, r2, s1, s2, co1, co2, co3, si1, si2, si3; + + q31_t xa, xb, xc, xd; + q31_t ya, yb, yc, yd; + q31_t xa_out, xb_out, xc_out, xd_out; + q31_t ya_out, yb_out, yc_out, yd_out; + + q31_t *ptr1; /* Total process is divided into three stages */ /* process first stage, middle stages, & last stage */ - /* start of first stage process */ /* Initializations for the first stage */ @@ -176,10 +163,10 @@ void arm_radix4_butterfly_q31( j = n2; /* Calculation of first stage */ - do - { + do { /* index calculation for the input as, */ - /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2U], pSrc[i0 + 3fftLen/4] */ + /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2U], pSrc[i0 + + * 3fftLen/4] */ i1 = i0 + n2; i2 = i1 + n2; i3 = i2 + n2; @@ -224,12 +211,14 @@ void arm_radix4_butterfly_q31( si2 = pCoef[(ia2 * 2U) + 1U]; /* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */ - pSrc[2U * i1] = (((int32_t) (((q63_t) r1 * co2) >> 32)) + - ((int32_t) (((q63_t) s1 * si2) >> 32))) << 1U; + pSrc[2U * i1] = (((int32_t)(((q63_t)r1 * co2) >> 32)) + + ((int32_t)(((q63_t)s1 * si2) >> 32))) + << 1U; /* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */ - pSrc[(2U * i1) + 1U] = (((int32_t) (((q63_t) s1 * co2) >> 32)) - - ((int32_t) (((q63_t) r1 * si2) >> 32))) << 1U; + pSrc[(2U * i1) + 1U] = (((int32_t)(((q63_t)s1 * co2) >> 32)) - + ((int32_t)(((q63_t)r1 * si2) >> 32))) + << 1U; /* (xa - xc) + (yb - yd) */ r1 = r2 + t1; @@ -245,12 +234,14 @@ void arm_radix4_butterfly_q31( si1 = pCoef[(ia1 * 2U) + 1U]; /* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */ - pSrc[2U * i2] = (((int32_t) (((q63_t) r1 * co1) >> 32)) + - ((int32_t) (((q63_t) s1 * si1) >> 32))) << 1U; + pSrc[2U * i2] = (((int32_t)(((q63_t)r1 * co1) >> 32)) + + ((int32_t)(((q63_t)s1 * si1) >> 32))) + << 1U; /* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */ - pSrc[(2U * i2) + 1U] = (((int32_t) (((q63_t) s1 * co1) >> 32)) - - ((int32_t) (((q63_t) r1 * si1) >> 32))) << 1U; + pSrc[(2U * i2) + 1U] = (((int32_t)(((q63_t)s1 * co1) >> 32)) - + ((int32_t)(((q63_t)r1 * si1) >> 32))) + << 1U; /* index calculation for the coefficients */ ia3 = 3U * ia1; @@ -258,12 +249,14 @@ void arm_radix4_butterfly_q31( si3 = pCoef[(ia3 * 2U) + 1U]; /* xd' = (xa-yb-xc+yd)co3 + (ya+xb-yc-xd)(si3) */ - pSrc[2U * i3] = (((int32_t) (((q63_t) r2 * co3) >> 32)) + - ((int32_t) (((q63_t) s2 * si3) >> 32))) << 1U; + pSrc[2U * i3] = (((int32_t)(((q63_t)r2 * co3) >> 32)) + + ((int32_t)(((q63_t)s2 * si3) >> 32))) + << 1U; /* yd' = (ya+xb-yc-xd)co3 - (xa-yb-xc+yd)(si3) */ - pSrc[(2U * i3) + 1U] = (((int32_t) (((q63_t) s2 * co3) >> 32)) - - ((int32_t) (((q63_t) r2 * si3) >> 32))) << 1U; + pSrc[(2U * i3) + 1U] = (((int32_t)(((q63_t)s2 * co3) >> 32)) - + ((int32_t)(((q63_t)r2 * si3) >> 32))) + << 1U; /* Twiddle coefficients index modifier */ ia1 = ia1 + twidCoefModifier; @@ -277,25 +270,20 @@ void arm_radix4_butterfly_q31( /* data is in 5.27(q27) format */ - /* start of Middle stages process */ - /* each stage in middle stages provides two down scaling of the input */ twidCoefModifier <<= 2U; - - for (k = fftLen / 4U; k > 4U; k >>= 2U) - { + for (k = fftLen / 4U; k > 4U; k >>= 2U) { /* Initializations for the first stage */ n1 = n2; n2 >>= 2U; ia1 = 0U; /* Calculation of first stage */ - for (j = 0U; j <= (n2 - 1U); j++) - { + for (j = 0U; j <= (n2 - 1U); j++) { /* index calculation for the coefficients */ ia2 = ia1 + ia1; ia3 = ia2 + ia1; @@ -308,10 +296,10 @@ void arm_radix4_butterfly_q31( /* Twiddle coefficients index modifier */ ia1 = ia1 + twidCoefModifier; - for (i0 = j; i0 < fftLen; i0 += n1) - { + for (i0 = j; i0 < fftLen; i0 += n1) { /* index calculation for the input as, */ - /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2U], pSrc[i0 + 3fftLen/4] */ + /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2U], pSrc[i0 + + * 3fftLen/4] */ i1 = i0 + n2; i2 = i1 + n2; i3 = i2 + n2; @@ -349,12 +337,14 @@ void arm_radix4_butterfly_q31( t2 = pSrc[2U * i1] - pSrc[2U * i3]; /* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */ - pSrc[2U * i1] = (((int32_t) (((q63_t) r1 * co2) >> 32)) + - ((int32_t) (((q63_t) s1 * si2) >> 32))) >> 1U; + pSrc[2U * i1] = (((int32_t)(((q63_t)r1 * co2) >> 32)) + + ((int32_t)(((q63_t)s1 * si2) >> 32))) >> + 1U; /* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */ - pSrc[(2U * i1) + 1U] = (((int32_t) (((q63_t) s1 * co2) >> 32)) - - ((int32_t) (((q63_t) r1 * si2) >> 32))) >> 1U; + pSrc[(2U * i1) + 1U] = (((int32_t)(((q63_t)s1 * co2) >> 32)) - + ((int32_t)(((q63_t)r1 * si2) >> 32))) >> + 1U; /* (xa - xc) + (yb - yd) */ r1 = r2 + t1; @@ -367,20 +357,24 @@ void arm_radix4_butterfly_q31( s2 = s2 + t2; /* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */ - pSrc[2U * i2] = (((int32_t) (((q63_t) r1 * co1) >> 32)) + - ((int32_t) (((q63_t) s1 * si1) >> 32))) >> 1U; + pSrc[2U * i2] = (((int32_t)(((q63_t)r1 * co1) >> 32)) + + ((int32_t)(((q63_t)s1 * si1) >> 32))) >> + 1U; /* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */ - pSrc[(2U * i2) + 1U] = (((int32_t) (((q63_t) s1 * co1) >> 32)) - - ((int32_t) (((q63_t) r1 * si1) >> 32))) >> 1U; + pSrc[(2U * i2) + 1U] = (((int32_t)(((q63_t)s1 * co1) >> 32)) - + ((int32_t)(((q63_t)r1 * si1) >> 32))) >> + 1U; /* xd' = (xa-yb-xc+yd)co3 + (ya+xb-yc-xd)(si3) */ - pSrc[2U * i3] = (((int32_t) (((q63_t) r2 * co3) >> 32)) + - ((int32_t) (((q63_t) s2 * si3) >> 32))) >> 1U; + pSrc[2U * i3] = (((int32_t)(((q63_t)r2 * co3) >> 32)) + + ((int32_t)(((q63_t)s2 * si3) >> 32))) >> + 1U; /* yd' = (ya+xb-yc-xd)co3 - (xa-yb-xc+yd)(si3) */ - pSrc[(2U * i3) + 1U] = (((int32_t) (((q63_t) s2 * co3) >> 32)) - - ((int32_t) (((q63_t) r2 * si3) >> 32))) >> 1U; + pSrc[(2U * i3) + 1U] = (((int32_t)(((q63_t)s2 * co3) >> 32)) - + ((int32_t)(((q63_t)r2 * si3) >> 32))) >> + 1U; } } twidCoefModifier <<= 2U; @@ -388,11 +382,13 @@ void arm_radix4_butterfly_q31( /* End of Middle stages process */ - /* data is in 11.21(q21) format for the 1024 point as there are 3 middle stages */ - /* data is in 9.23(q23) format for the 256 point as there are 2 middle stages */ + /* data is in 11.21(q21) format for the 1024 point as there are 3 middle + * stages */ + /* data is in 9.23(q23) format for the 256 point as there are 2 middle stages + */ /* data is in 7.25(q25) format for the 64 point as there are 1 middle stage */ - /* data is in 5.27(q27) format for the 16 point as there are no middle stages */ - + /* data is in 5.27(q27) format for the 16 point as there are no middle stages + */ /* start of Last stage process */ /* Initializations for the last stage */ @@ -400,8 +396,7 @@ void arm_radix4_butterfly_q31( ptr1 = &pSrc[0]; /* Calculations of last stage */ - do - { + do { /* Read xa (real), ya(imag) input */ xa = *ptr1++; ya = *ptr1++; @@ -452,7 +447,6 @@ void arm_radix4_butterfly_q31( *ptr1++ = xd_out; *ptr1++ = yd_out; - } while (--j); /* output is in 11.21(q21) format for the 1024 point */ @@ -461,16 +455,16 @@ void arm_radix4_butterfly_q31( /* output is in 5.27(q27) format for the 16 point */ /* End of last stage process */ - } - /** @brief Core function for the Q31 CIFFT butterfly process. - @param[in,out] pSrc points to the in-place buffer of Q31 data type. + @param[in,out] pSrc points to the in-place buffer of Q31 data + type. @param[in] fftLen length of the FFT. @param[in] pCoef points to twiddle coefficient buffer. - @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. + @param[in] twidCoefModifier twiddle coefficient modifier that supports + different size FFTs with the same twiddle factor table. @return none */ @@ -478,7 +472,8 @@ void arm_radix4_butterfly_q31( * Radix-4 IFFT algorithm used is : * * CIFFT uses same twiddle coefficients as CFFT Function - * x[k] = x[n] + (j)k * x[n + fftLen/4] + (-1)k * x[n+fftLen/2] + (-j)k * x[n+3*fftLen/4] + * x[k] = x[n] + (j)k * x[n + fftLen/4] + (-1)k * x[n+fftLen/2] + (-j)k * + x[n+3*fftLen/4] * * * IFFT is implemented with following changes in equations from FFT @@ -501,7 +496,7 @@ void arm_radix4_butterfly_q31( * Wn = co1 + j * (si1) * W2n = co2 + j * (si2) * W3n = co3 + j * (si3) - + * The real and imaginary output values for the radix-4 butterfly are * xa' = xa + xb + xc + xd * ya' = ya + yb + yc + yd @@ -514,20 +509,17 @@ void arm_radix4_butterfly_q31( * */ -void arm_radix4_butterfly_inverse_q31( - q31_t * pSrc, - uint32_t fftLen, - const q31_t * pCoef, - uint32_t twidCoefModifier) -{ - uint32_t n1, n2, ia1, ia2, ia3, i0, i1, i2, i3, j, k; - q31_t t1, t2, r1, r2, s1, s2, co1, co2, co3, si1, si2, si3; - q31_t xa, xb, xc, xd; - q31_t ya, yb, yc, yd; - q31_t xa_out, xb_out, xc_out, xd_out; - q31_t ya_out, yb_out, yc_out, yd_out; - - q31_t *ptr1; +void arm_radix4_butterfly_inverse_q31(q31_t *pSrc, uint32_t fftLen, + const q31_t *pCoef, + uint32_t twidCoefModifier) { + uint32_t n1, n2, ia1, ia2, ia3, i0, i1, i2, i3, j, k; + q31_t t1, t2, r1, r2, s1, s2, co1, co2, co3, si1, si2, si3; + q31_t xa, xb, xc, xd; + q31_t ya, yb, yc, yd; + q31_t xa_out, xb_out, xc_out, xd_out; + q31_t ya_out, yb_out, yc_out, yd_out; + + q31_t *ptr1; /* input is be 1.31(q31) format for all FFT sizes */ /* Total process is divided into three stages */ @@ -545,12 +537,12 @@ void arm_radix4_butterfly_inverse_q31( j = n2; - do - { + do { /* input is in 1.31(q31) format and provide 4 guard bits for the input */ /* index calculation for the input as, */ - /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2U], pSrc[i0 + 3fftLen/4] */ + /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2U], pSrc[i0 + + * 3fftLen/4] */ i1 = i0 + n2; i2 = i1 + n2; i3 = i2 + n2; @@ -592,12 +584,14 @@ void arm_radix4_butterfly_inverse_q31( si2 = pCoef[(ia2 * 2U) + 1U]; /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ - pSrc[2U * i1] = (((int32_t) (((q63_t) r1 * co2) >> 32)) - - ((int32_t) (((q63_t) s1 * si2) >> 32))) << 1U; + pSrc[2U * i1] = (((int32_t)(((q63_t)r1 * co2) >> 32)) - + ((int32_t)(((q63_t)s1 * si2) >> 32))) + << 1U; /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ - pSrc[2U * i1 + 1U] = (((int32_t) (((q63_t) s1 * co2) >> 32)) + - ((int32_t) (((q63_t) r1 * si2) >> 32))) << 1U; + pSrc[2U * i1 + 1U] = (((int32_t)(((q63_t)s1 * co2) >> 32)) + + ((int32_t)(((q63_t)r1 * si2) >> 32))) + << 1U; /* (xa - xc) - (yb - yd) */ r1 = r2 - t1; @@ -613,12 +607,14 @@ void arm_radix4_butterfly_inverse_q31( si1 = pCoef[(ia1 * 2U) + 1U]; /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ - pSrc[2U * i2] = (((int32_t) (((q63_t) r1 * co1) >> 32)) - - ((int32_t) (((q63_t) s1 * si1) >> 32))) << 1U; + pSrc[2U * i2] = (((int32_t)(((q63_t)r1 * co1) >> 32)) - + ((int32_t)(((q63_t)s1 * si1) >> 32))) + << 1U; /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ - pSrc[(2U * i2) + 1U] = (((int32_t) (((q63_t) s1 * co1) >> 32)) + - ((int32_t) (((q63_t) r1 * si1) >> 32))) << 1U; + pSrc[(2U * i2) + 1U] = (((int32_t)(((q63_t)s1 * co1) >> 32)) + + ((int32_t)(((q63_t)r1 * si1) >> 32))) + << 1U; /* index calculation for the coefficients */ ia3 = 3U * ia1; @@ -626,12 +622,14 @@ void arm_radix4_butterfly_inverse_q31( si3 = pCoef[(ia3 * 2U) + 1U]; /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ - pSrc[2U * i3] = (((int32_t) (((q63_t) r2 * co3) >> 32)) - - ((int32_t) (((q63_t) s2 * si3) >> 32))) << 1U; + pSrc[2U * i3] = (((int32_t)(((q63_t)r2 * co3) >> 32)) - + ((int32_t)(((q63_t)s2 * si3) >> 32))) + << 1U; /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ - pSrc[(2U * i3) + 1U] = (((int32_t) (((q63_t) s2 * co3) >> 32)) + - ((int32_t) (((q63_t) r2 * si3) >> 32))) << 1U; + pSrc[(2U * i3) + 1U] = (((int32_t)(((q63_t)s2 * co3) >> 32)) + + ((int32_t)(((q63_t)r2 * si3) >> 32))) + << 1U; /* Twiddle coefficients index modifier */ ia1 = ia1 + twidCoefModifier; @@ -644,21 +642,18 @@ void arm_radix4_butterfly_inverse_q31( /* data is in 5.27(q27) format */ /* each stage provides two down scaling of the input */ - /* Start of Middle stages process */ twidCoefModifier <<= 2U; /* Calculation of second stage to excluding last stage */ - for (k = fftLen / 4U; k > 4U; k >>= 2U) - { + for (k = fftLen / 4U; k > 4U; k >>= 2U) { /* Initializations for the first stage */ n1 = n2; n2 >>= 2U; ia1 = 0U; - for (j = 0; j <= (n2 - 1U); j++) - { + for (j = 0; j <= (n2 - 1U); j++) { /* index calculation for the coefficients */ ia2 = ia1 + ia1; ia3 = ia2 + ia1; @@ -671,10 +666,10 @@ void arm_radix4_butterfly_inverse_q31( /* Twiddle coefficients index modifier */ ia1 = ia1 + twidCoefModifier; - for (i0 = j; i0 < fftLen; i0 += n1) - { + for (i0 = j; i0 < fftLen; i0 += n1) { /* index calculation for the input as, */ - /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2U], pSrc[i0 + 3fftLen/4] */ + /* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2U], pSrc[i0 + + * 3fftLen/4] */ i1 = i0 + n2; i2 = i1 + n2; i3 = i2 + n2; @@ -711,12 +706,14 @@ void arm_radix4_butterfly_inverse_q31( t2 = pSrc[2U * i1] - pSrc[2U * i3]; /* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */ - pSrc[2U * i1] = (((int32_t) (((q63_t) r1 * co2) >> 32U)) - - ((int32_t) (((q63_t) s1 * si2) >> 32U))) >> 1U; + pSrc[2U * i1] = (((int32_t)(((q63_t)r1 * co2) >> 32U)) - + ((int32_t)(((q63_t)s1 * si2) >> 32U))) >> + 1U; /* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */ - pSrc[(2U * i1) + 1U] = (((int32_t) (((q63_t) s1 * co2) >> 32U)) + - ((int32_t) (((q63_t) r1 * si2) >> 32U))) >> 1U; + pSrc[(2U * i1) + 1U] = (((int32_t)(((q63_t)s1 * co2) >> 32U)) + + ((int32_t)(((q63_t)r1 * si2) >> 32U))) >> + 1U; /* (xa - xc) - (yb - yd) */ r1 = r2 - t1; @@ -729,20 +726,24 @@ void arm_radix4_butterfly_inverse_q31( s2 = s2 - t2; /* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */ - pSrc[2U * i2] = (((int32_t) (((q63_t) r1 * co1) >> 32)) - - ((int32_t) (((q63_t) s1 * si1) >> 32))) >> 1U; + pSrc[2U * i2] = (((int32_t)(((q63_t)r1 * co1) >> 32)) - + ((int32_t)(((q63_t)s1 * si1) >> 32))) >> + 1U; /* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */ - pSrc[(2U * i2) + 1U] = (((int32_t) (((q63_t) s1 * co1) >> 32)) + - ((int32_t) (((q63_t) r1 * si1) >> 32))) >> 1U; + pSrc[(2U * i2) + 1U] = (((int32_t)(((q63_t)s1 * co1) >> 32)) + + ((int32_t)(((q63_t)r1 * si1) >> 32))) >> + 1U; /* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */ - pSrc[(2U * i3)] = (((int32_t) (((q63_t) r2 * co3) >> 32)) - - ((int32_t) (((q63_t) s2 * si3) >> 32))) >> 1U; + pSrc[(2U * i3)] = (((int32_t)(((q63_t)r2 * co3) >> 32)) - + ((int32_t)(((q63_t)s2 * si3) >> 32))) >> + 1U; /* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */ - pSrc[(2U * i3) + 1U] = (((int32_t) (((q63_t) s2 * co3) >> 32)) + - ((int32_t) (((q63_t) r2 * si3) >> 32))) >> 1U; + pSrc[(2U * i3) + 1U] = (((int32_t)(((q63_t)s2 * co3) >> 32)) + + ((int32_t)(((q63_t)r2 * si3) >> 32))) >> + 1U; } } twidCoefModifier <<= 2U; @@ -750,22 +751,22 @@ void arm_radix4_butterfly_inverse_q31( /* End of Middle stages process */ - /* data is in 11.21(q21) format for the 1024 point as there are 3 middle stages */ - /* data is in 9.23(q23) format for the 256 point as there are 2 middle stages */ + /* data is in 11.21(q21) format for the 1024 point as there are 3 middle + * stages */ + /* data is in 9.23(q23) format for the 256 point as there are 2 middle stages + */ /* data is in 7.25(q25) format for the 64 point as there are 1 middle stage */ - /* data is in 5.27(q27) format for the 16 point as there are no middle stages */ - + /* data is in 5.27(q27) format for the 16 point as there are no middle stages + */ /* Start of last stage process */ - /* Initializations for the last stage */ j = fftLen >> 2; ptr1 = &pSrc[0]; /* Calculations of last stage */ - do - { + do { /* Read xa (real), ya(imag) input */ xa = *ptr1++; ya = *ptr1++; diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix8_f32.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix8_f32.c index 50048f6..1072cff 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix8_f32.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_cfft_radix8_f32.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_radix8_f32.c - * Description: Radix-8 Decimation in Frequency CFFT & CIFFT Floating point processing function + * Description: Radix-8 Decimation in Frequency CFFT & CIFFT Floating point + * processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -28,258 +29,250 @@ #include "arm_math.h" - /* ---------------------------------------------------------------------- * Internal helper function used by the FFTs * -------------------------------------------------------------------- */ /** brief Core function for the floating-point CFFT butterfly process. - param[in,out] pSrc points to the in-place buffer of floating-point data type. - param[in] fftLen length of the FFT. - param[in] pCoef points to the twiddle coefficient buffer. - param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. - return none + param[in,out] pSrc points to the in-place buffer of floating-point + data type. param[in] fftLen length of the FFT. param[in] pCoef + points to the twiddle coefficient buffer. param[in] twidCoefModifier + twiddle coefficient modifier that supports different size FFTs with the same + twiddle factor table. return none */ -void arm_radix8_butterfly_f32( - float32_t * pSrc, - uint16_t fftLen, - const float32_t * pCoef, - uint16_t twidCoefModifier) -{ - uint32_t ia1, ia2, ia3, ia4, ia5, ia6, ia7; - uint32_t i1, i2, i3, i4, i5, i6, i7, i8; - uint32_t id; - uint32_t n1, n2, j; +void arm_radix8_butterfly_f32(float32_t *pSrc, uint16_t fftLen, + const float32_t *pCoef, + uint16_t twidCoefModifier) { + uint32_t ia1, ia2, ia3, ia4, ia5, ia6, ia7; + uint32_t i1, i2, i3, i4, i5, i6, i7, i8; + uint32_t id; + uint32_t n1, n2, j; - float32_t r1, r2, r3, r4, r5, r6, r7, r8; - float32_t t1, t2; - float32_t s1, s2, s3, s4, s5, s6, s7, s8; - float32_t p1, p2, p3, p4; - float32_t co2, co3, co4, co5, co6, co7, co8; - float32_t si2, si3, si4, si5, si6, si7, si8; - const float32_t C81 = 0.70710678118f; + float32_t r1, r2, r3, r4, r5, r6, r7, r8; + float32_t t1, t2; + float32_t s1, s2, s3, s4, s5, s6, s7, s8; + float32_t p1, p2, p3, p4; + float32_t co2, co3, co4, co5, co6, co7, co8; + float32_t si2, si3, si4, si5, si6, si7, si8; + const float32_t C81 = 0.70710678118f; - n2 = fftLen; + n2 = fftLen; - do - { - n1 = n2; - n2 = n2 >> 3; - i1 = 0; + do { + n1 = n2; + n2 = n2 >> 3; + i1 = 0; - do - { - i2 = i1 + n2; - i3 = i2 + n2; - i4 = i3 + n2; - i5 = i4 + n2; - i6 = i5 + n2; - i7 = i6 + n2; - i8 = i7 + n2; - r1 = pSrc[2 * i1] + pSrc[2 * i5]; - r5 = pSrc[2 * i1] - pSrc[2 * i5]; - r2 = pSrc[2 * i2] + pSrc[2 * i6]; - r6 = pSrc[2 * i2] - pSrc[2 * i6]; - r3 = pSrc[2 * i3] + pSrc[2 * i7]; - r7 = pSrc[2 * i3] - pSrc[2 * i7]; - r4 = pSrc[2 * i4] + pSrc[2 * i8]; - r8 = pSrc[2 * i4] - pSrc[2 * i8]; - t1 = r1 - r3; - r1 = r1 + r3; - r3 = r2 - r4; - r2 = r2 + r4; - pSrc[2 * i1] = r1 + r2; - pSrc[2 * i5] = r1 - r2; - r1 = pSrc[2 * i1 + 1] + pSrc[2 * i5 + 1]; - s5 = pSrc[2 * i1 + 1] - pSrc[2 * i5 + 1]; - r2 = pSrc[2 * i2 + 1] + pSrc[2 * i6 + 1]; - s6 = pSrc[2 * i2 + 1] - pSrc[2 * i6 + 1]; - s3 = pSrc[2 * i3 + 1] + pSrc[2 * i7 + 1]; - s7 = pSrc[2 * i3 + 1] - pSrc[2 * i7 + 1]; - r4 = pSrc[2 * i4 + 1] + pSrc[2 * i8 + 1]; - s8 = pSrc[2 * i4 + 1] - pSrc[2 * i8 + 1]; - t2 = r1 - s3; - r1 = r1 + s3; - s3 = r2 - r4; - r2 = r2 + r4; - pSrc[2 * i1 + 1] = r1 + r2; - pSrc[2 * i5 + 1] = r1 - r2; - pSrc[2 * i3] = t1 + s3; - pSrc[2 * i7] = t1 - s3; - pSrc[2 * i3 + 1] = t2 - r3; - pSrc[2 * i7 + 1] = t2 + r3; - r1 = (r6 - r8) * C81; - r6 = (r6 + r8) * C81; - r2 = (s6 - s8) * C81; - s6 = (s6 + s8) * C81; - t1 = r5 - r1; - r5 = r5 + r1; - r8 = r7 - r6; - r7 = r7 + r6; - t2 = s5 - r2; - s5 = s5 + r2; - s8 = s7 - s6; - s7 = s7 + s6; - pSrc[2 * i2] = r5 + s7; - pSrc[2 * i8] = r5 - s7; - pSrc[2 * i6] = t1 + s8; - pSrc[2 * i4] = t1 - s8; - pSrc[2 * i2 + 1] = s5 - r7; - pSrc[2 * i8 + 1] = s5 + r7; - pSrc[2 * i6 + 1] = t2 - r8; - pSrc[2 * i4 + 1] = t2 + r8; + do { + i2 = i1 + n2; + i3 = i2 + n2; + i4 = i3 + n2; + i5 = i4 + n2; + i6 = i5 + n2; + i7 = i6 + n2; + i8 = i7 + n2; + r1 = pSrc[2 * i1] + pSrc[2 * i5]; + r5 = pSrc[2 * i1] - pSrc[2 * i5]; + r2 = pSrc[2 * i2] + pSrc[2 * i6]; + r6 = pSrc[2 * i2] - pSrc[2 * i6]; + r3 = pSrc[2 * i3] + pSrc[2 * i7]; + r7 = pSrc[2 * i3] - pSrc[2 * i7]; + r4 = pSrc[2 * i4] + pSrc[2 * i8]; + r8 = pSrc[2 * i4] - pSrc[2 * i8]; + t1 = r1 - r3; + r1 = r1 + r3; + r3 = r2 - r4; + r2 = r2 + r4; + pSrc[2 * i1] = r1 + r2; + pSrc[2 * i5] = r1 - r2; + r1 = pSrc[2 * i1 + 1] + pSrc[2 * i5 + 1]; + s5 = pSrc[2 * i1 + 1] - pSrc[2 * i5 + 1]; + r2 = pSrc[2 * i2 + 1] + pSrc[2 * i6 + 1]; + s6 = pSrc[2 * i2 + 1] - pSrc[2 * i6 + 1]; + s3 = pSrc[2 * i3 + 1] + pSrc[2 * i7 + 1]; + s7 = pSrc[2 * i3 + 1] - pSrc[2 * i7 + 1]; + r4 = pSrc[2 * i4 + 1] + pSrc[2 * i8 + 1]; + s8 = pSrc[2 * i4 + 1] - pSrc[2 * i8 + 1]; + t2 = r1 - s3; + r1 = r1 + s3; + s3 = r2 - r4; + r2 = r2 + r4; + pSrc[2 * i1 + 1] = r1 + r2; + pSrc[2 * i5 + 1] = r1 - r2; + pSrc[2 * i3] = t1 + s3; + pSrc[2 * i7] = t1 - s3; + pSrc[2 * i3 + 1] = t2 - r3; + pSrc[2 * i7 + 1] = t2 + r3; + r1 = (r6 - r8) * C81; + r6 = (r6 + r8) * C81; + r2 = (s6 - s8) * C81; + s6 = (s6 + s8) * C81; + t1 = r5 - r1; + r5 = r5 + r1; + r8 = r7 - r6; + r7 = r7 + r6; + t2 = s5 - r2; + s5 = s5 + r2; + s8 = s7 - s6; + s7 = s7 + s6; + pSrc[2 * i2] = r5 + s7; + pSrc[2 * i8] = r5 - s7; + pSrc[2 * i6] = t1 + s8; + pSrc[2 * i4] = t1 - s8; + pSrc[2 * i2 + 1] = s5 - r7; + pSrc[2 * i8 + 1] = s5 + r7; + pSrc[2 * i6 + 1] = t2 - r8; + pSrc[2 * i4 + 1] = t2 + r8; - i1 += n1; + i1 += n1; + } while (i1 < fftLen); + + if (n2 < 8) + break; + + ia1 = 0; + j = 1; + + do { + /* index calculation for the coefficients */ + id = ia1 + twidCoefModifier; + ia1 = id; + ia2 = ia1 + id; + ia3 = ia2 + id; + ia4 = ia3 + id; + ia5 = ia4 + id; + ia6 = ia5 + id; + ia7 = ia6 + id; + + co2 = pCoef[2 * ia1]; + co3 = pCoef[2 * ia2]; + co4 = pCoef[2 * ia3]; + co5 = pCoef[2 * ia4]; + co6 = pCoef[2 * ia5]; + co7 = pCoef[2 * ia6]; + co8 = pCoef[2 * ia7]; + si2 = pCoef[2 * ia1 + 1]; + si3 = pCoef[2 * ia2 + 1]; + si4 = pCoef[2 * ia3 + 1]; + si5 = pCoef[2 * ia4 + 1]; + si6 = pCoef[2 * ia5 + 1]; + si7 = pCoef[2 * ia6 + 1]; + si8 = pCoef[2 * ia7 + 1]; + + i1 = j; + + do { + /* index calculation for the input */ + i2 = i1 + n2; + i3 = i2 + n2; + i4 = i3 + n2; + i5 = i4 + n2; + i6 = i5 + n2; + i7 = i6 + n2; + i8 = i7 + n2; + r1 = pSrc[2 * i1] + pSrc[2 * i5]; + r5 = pSrc[2 * i1] - pSrc[2 * i5]; + r2 = pSrc[2 * i2] + pSrc[2 * i6]; + r6 = pSrc[2 * i2] - pSrc[2 * i6]; + r3 = pSrc[2 * i3] + pSrc[2 * i7]; + r7 = pSrc[2 * i3] - pSrc[2 * i7]; + r4 = pSrc[2 * i4] + pSrc[2 * i8]; + r8 = pSrc[2 * i4] - pSrc[2 * i8]; + t1 = r1 - r3; + r1 = r1 + r3; + r3 = r2 - r4; + r2 = r2 + r4; + pSrc[2 * i1] = r1 + r2; + r2 = r1 - r2; + s1 = pSrc[2 * i1 + 1] + pSrc[2 * i5 + 1]; + s5 = pSrc[2 * i1 + 1] - pSrc[2 * i5 + 1]; + s2 = pSrc[2 * i2 + 1] + pSrc[2 * i6 + 1]; + s6 = pSrc[2 * i2 + 1] - pSrc[2 * i6 + 1]; + s3 = pSrc[2 * i3 + 1] + pSrc[2 * i7 + 1]; + s7 = pSrc[2 * i3 + 1] - pSrc[2 * i7 + 1]; + s4 = pSrc[2 * i4 + 1] + pSrc[2 * i8 + 1]; + s8 = pSrc[2 * i4 + 1] - pSrc[2 * i8 + 1]; + t2 = s1 - s3; + s1 = s1 + s3; + s3 = s2 - s4; + s2 = s2 + s4; + r1 = t1 + s3; + t1 = t1 - s3; + pSrc[2 * i1 + 1] = s1 + s2; + s2 = s1 - s2; + s1 = t2 - r3; + t2 = t2 + r3; + p1 = co5 * r2; + p2 = si5 * s2; + p3 = co5 * s2; + p4 = si5 * r2; + pSrc[2 * i5] = p1 + p2; + pSrc[2 * i5 + 1] = p3 - p4; + p1 = co3 * r1; + p2 = si3 * s1; + p3 = co3 * s1; + p4 = si3 * r1; + pSrc[2 * i3] = p1 + p2; + pSrc[2 * i3 + 1] = p3 - p4; + p1 = co7 * t1; + p2 = si7 * t2; + p3 = co7 * t2; + p4 = si7 * t1; + pSrc[2 * i7] = p1 + p2; + pSrc[2 * i7 + 1] = p3 - p4; + r1 = (r6 - r8) * C81; + r6 = (r6 + r8) * C81; + s1 = (s6 - s8) * C81; + s6 = (s6 + s8) * C81; + t1 = r5 - r1; + r5 = r5 + r1; + r8 = r7 - r6; + r7 = r7 + r6; + t2 = s5 - s1; + s5 = s5 + s1; + s8 = s7 - s6; + s7 = s7 + s6; + r1 = r5 + s7; + r5 = r5 - s7; + r6 = t1 + s8; + t1 = t1 - s8; + s1 = s5 - r7; + s5 = s5 + r7; + s6 = t2 - r8; + t2 = t2 + r8; + p1 = co2 * r1; + p2 = si2 * s1; + p3 = co2 * s1; + p4 = si2 * r1; + pSrc[2 * i2] = p1 + p2; + pSrc[2 * i2 + 1] = p3 - p4; + p1 = co8 * r5; + p2 = si8 * s5; + p3 = co8 * s5; + p4 = si8 * r5; + pSrc[2 * i8] = p1 + p2; + pSrc[2 * i8 + 1] = p3 - p4; + p1 = co6 * r6; + p2 = si6 * s6; + p3 = co6 * s6; + p4 = si6 * r6; + pSrc[2 * i6] = p1 + p2; + pSrc[2 * i6 + 1] = p3 - p4; + p1 = co4 * t1; + p2 = si4 * t2; + p3 = co4 * t2; + p4 = si4 * t1; + pSrc[2 * i4] = p1 + p2; + pSrc[2 * i4 + 1] = p3 - p4; + + i1 += n1; } while (i1 < fftLen); - if (n2 < 8) - break; + j++; + } while (j < n2); - ia1 = 0; - j = 1; - - do - { - /* index calculation for the coefficients */ - id = ia1 + twidCoefModifier; - ia1 = id; - ia2 = ia1 + id; - ia3 = ia2 + id; - ia4 = ia3 + id; - ia5 = ia4 + id; - ia6 = ia5 + id; - ia7 = ia6 + id; - - co2 = pCoef[2 * ia1]; - co3 = pCoef[2 * ia2]; - co4 = pCoef[2 * ia3]; - co5 = pCoef[2 * ia4]; - co6 = pCoef[2 * ia5]; - co7 = pCoef[2 * ia6]; - co8 = pCoef[2 * ia7]; - si2 = pCoef[2 * ia1 + 1]; - si3 = pCoef[2 * ia2 + 1]; - si4 = pCoef[2 * ia3 + 1]; - si5 = pCoef[2 * ia4 + 1]; - si6 = pCoef[2 * ia5 + 1]; - si7 = pCoef[2 * ia6 + 1]; - si8 = pCoef[2 * ia7 + 1]; - - i1 = j; - - do - { - /* index calculation for the input */ - i2 = i1 + n2; - i3 = i2 + n2; - i4 = i3 + n2; - i5 = i4 + n2; - i6 = i5 + n2; - i7 = i6 + n2; - i8 = i7 + n2; - r1 = pSrc[2 * i1] + pSrc[2 * i5]; - r5 = pSrc[2 * i1] - pSrc[2 * i5]; - r2 = pSrc[2 * i2] + pSrc[2 * i6]; - r6 = pSrc[2 * i2] - pSrc[2 * i6]; - r3 = pSrc[2 * i3] + pSrc[2 * i7]; - r7 = pSrc[2 * i3] - pSrc[2 * i7]; - r4 = pSrc[2 * i4] + pSrc[2 * i8]; - r8 = pSrc[2 * i4] - pSrc[2 * i8]; - t1 = r1 - r3; - r1 = r1 + r3; - r3 = r2 - r4; - r2 = r2 + r4; - pSrc[2 * i1] = r1 + r2; - r2 = r1 - r2; - s1 = pSrc[2 * i1 + 1] + pSrc[2 * i5 + 1]; - s5 = pSrc[2 * i1 + 1] - pSrc[2 * i5 + 1]; - s2 = pSrc[2 * i2 + 1] + pSrc[2 * i6 + 1]; - s6 = pSrc[2 * i2 + 1] - pSrc[2 * i6 + 1]; - s3 = pSrc[2 * i3 + 1] + pSrc[2 * i7 + 1]; - s7 = pSrc[2 * i3 + 1] - pSrc[2 * i7 + 1]; - s4 = pSrc[2 * i4 + 1] + pSrc[2 * i8 + 1]; - s8 = pSrc[2 * i4 + 1] - pSrc[2 * i8 + 1]; - t2 = s1 - s3; - s1 = s1 + s3; - s3 = s2 - s4; - s2 = s2 + s4; - r1 = t1 + s3; - t1 = t1 - s3; - pSrc[2 * i1 + 1] = s1 + s2; - s2 = s1 - s2; - s1 = t2 - r3; - t2 = t2 + r3; - p1 = co5 * r2; - p2 = si5 * s2; - p3 = co5 * s2; - p4 = si5 * r2; - pSrc[2 * i5] = p1 + p2; - pSrc[2 * i5 + 1] = p3 - p4; - p1 = co3 * r1; - p2 = si3 * s1; - p3 = co3 * s1; - p4 = si3 * r1; - pSrc[2 * i3] = p1 + p2; - pSrc[2 * i3 + 1] = p3 - p4; - p1 = co7 * t1; - p2 = si7 * t2; - p3 = co7 * t2; - p4 = si7 * t1; - pSrc[2 * i7] = p1 + p2; - pSrc[2 * i7 + 1] = p3 - p4; - r1 = (r6 - r8) * C81; - r6 = (r6 + r8) * C81; - s1 = (s6 - s8) * C81; - s6 = (s6 + s8) * C81; - t1 = r5 - r1; - r5 = r5 + r1; - r8 = r7 - r6; - r7 = r7 + r6; - t2 = s5 - s1; - s5 = s5 + s1; - s8 = s7 - s6; - s7 = s7 + s6; - r1 = r5 + s7; - r5 = r5 - s7; - r6 = t1 + s8; - t1 = t1 - s8; - s1 = s5 - r7; - s5 = s5 + r7; - s6 = t2 - r8; - t2 = t2 + r8; - p1 = co2 * r1; - p2 = si2 * s1; - p3 = co2 * s1; - p4 = si2 * r1; - pSrc[2 * i2] = p1 + p2; - pSrc[2 * i2 + 1] = p3 - p4; - p1 = co8 * r5; - p2 = si8 * s5; - p3 = co8 * s5; - p4 = si8 * r5; - pSrc[2 * i8] = p1 + p2; - pSrc[2 * i8 + 1] = p3 - p4; - p1 = co6 * r6; - p2 = si6 * s6; - p3 = co6 * s6; - p4 = si6 * r6; - pSrc[2 * i6] = p1 + p2; - pSrc[2 * i6 + 1] = p3 - p4; - p1 = co4 * t1; - p2 = si4 * t2; - p3 = co4 * t2; - p4 = si4 * t1; - pSrc[2 * i4] = p1 + p2; - pSrc[2 * i4 + 1] = p3 - p4; - - i1 += n1; - } while (i1 < fftLen); - - j++; - } while (j < n2); - - twidCoefModifier <<= 3; - } while (n2 > 7); + twidCoefModifier <<= 3; + } while (n2 > 7); } diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_f32.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_f32.c index 87455dc..e2597ba 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_f32.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_f32.c @@ -35,106 +35,118 @@ /** @defgroup DCT4_IDCT4 DCT Type IV Functions - Representation of signals by minimum number of values is important for storage and transmission. - The possibility of large discontinuity between the beginning and end of a period of a signal - in DFT can be avoided by extending the signal so that it is even-symmetric. - Discrete Cosine Transform (DCT) is constructed such that its energy is heavily concentrated in the lower part of the - spectrum and is very widely used in signal and image coding applications. - The family of DCTs (DCT type- 1,2,3,4) is the outcome of different combinations of homogeneous boundary conditions. - DCT has an excellent energy-packing capability, hence has many applications and in data compression in particular. - - DCT is essentially the Discrete Fourier Transform(DFT) of an even-extended real signal. - Reordering of the input data makes the computation of DCT just a problem of - computing the DFT of a real signal with a few additional operations. - This approach provides regular, simple, and very efficient DCT algorithms for practical hardware and software implementations. - - DCT type-II can be implemented using Fast fourier transform (FFT) internally, as the transform is applied on real values, Real FFT can be used. - DCT4 is implemented using DCT2 as their implementations are similar except with some added pre-processing and post-processing. - DCT2 implementation can be described in the following steps: + Representation of signals by minimum number of values is important for storage + and transmission. The possibility of large discontinuity between the beginning + and end of a period of a signal in DFT can be avoided by extending the signal + so that it is even-symmetric. Discrete Cosine Transform (DCT) is constructed + such that its energy is heavily concentrated in the lower part of the spectrum + and is very widely used in signal and image coding applications. The family of + DCTs (DCT type- 1,2,3,4) is the outcome of different combinations of + homogeneous boundary conditions. DCT has an excellent energy-packing + capability, hence has many applications and in data compression in particular. + + DCT is essentially the Discrete Fourier Transform(DFT) of an even-extended + real signal. Reordering of the input data makes the computation of DCT just a + problem of computing the DFT of a real signal with a few additional + operations. This approach provides regular, simple, and very efficient DCT + algorithms for practical hardware and software implementations. + + DCT type-II can be implemented using Fast fourier transform (FFT) internally, + as the transform is applied on real values, Real FFT can be used. DCT4 is + implemented using DCT2 as their implementations are similar except with some + added pre-processing and post-processing. DCT2 implementation can be described + in the following steps: - Re-ordering input - Calculating Real FFT - - Multiplication of weights and Real FFT output and getting real part from the product. - + - Multiplication of weights and Real FFT output and getting real part from the + product. + This process is explained by the block diagram below: \image html DCT4.gif "Discrete Cosine Transform - type-IV" - + @par Algorithm - The N-point type-IV DCT is defined as a real, linear transformation by the formula: - \image html DCT4Equation.gif - where k = 0, 1, 2, ..., N-1 + The N-point type-IV DCT is defined as a real, linear + transformation by the formula: \image html DCT4Equation.gif where k = 0, + 1, 2, ..., N-1 @par Its inverse is defined as follows: \image html IDCT4Equation.gif where n = 0, 1, 2, ..., N-1 @par - The DCT4 matrices become involutory (i.e. they are self-inverse) by multiplying with an overall scale factor of sqrt(2/N). - The symmetry of the transform matrix indicates that the fast algorithms for the forward - and inverse transform computation are identical. - Note that the implementation of Inverse DCT4 and DCT4 is same, hence same process function can be used for both. - + The DCT4 matrices become involutory (i.e. they are + self-inverse) by multiplying with an overall scale factor of sqrt(2/N). The + symmetry of the transform matrix indicates that the fast algorithms for the + forward and inverse transform computation are identical. Note that the + implementation of Inverse DCT4 and DCT4 is same, hence same process function + can be used for both. + @par Lengths supported by the transform: - As DCT4 internally uses Real FFT, it supports all the lengths 128, 512, 2048 and 8192. - The library provides separate functions for Q15, Q31, and floating-point data types. + As DCT4 internally uses Real FFT, it supports all the lengths + 128, 512, 2048 and 8192. The library provides separate functions for Q15, Q31, + and floating-point data types. @par Instance Structure - The instances for Real FFT and FFT, cosine values table and twiddle factor table are stored in an instance data structure. - A separate instance structure must be defined for each transform. - There are separate instance structure declarations for each of the 3 supported data types. - + The instances for Real FFT and FFT, cosine values table and + twiddle factor table are stored in an instance data structure. A separate + instance structure must be defined for each transform. There are separate + instance structure declarations for each of the 3 supported data types. + @par Initialization Functions - There is also an associated initialization function for each data type. - The initialization function performs the following operations: + There is also an associated initialization function for each + data type. The initialization function performs the following operations: - Sets the values of the internal structure fields. - - Initializes Real FFT as its process function is used internally in DCT4, by calling \ref arm_rfft_init_f32(). + - Initializes Real FFT as its process function is used + internally in DCT4, by calling \ref arm_rfft_init_f32(). @par Use of the initialization function is optional. - However, if the initialization function is used, then the instance structure cannot be placed into a const data section. - To place an instance structure into a const data section, the instance structure must be manually initialized. - Manually initialize the instance structure as follows: + However, if the initialization function is used, then the + instance structure cannot be placed into a const data section. To place an + instance structure into a const data section, the instance structure must be + manually initialized. Manually initialize the instance structure as follows:
-      arm_dct4_instance_f32 S = {N, Nby2, normalize, pTwiddle, pCosFactor, pRfft, pCfft};
-      arm_dct4_instance_q31 S = {N, Nby2, normalize, pTwiddle, pCosFactor, pRfft, pCfft};
-      arm_dct4_instance_q15 S = {N, Nby2, normalize, pTwiddle, pCosFactor, pRfft, pCfft};
+      arm_dct4_instance_f32 S = {N, Nby2, normalize, pTwiddle, pCosFactor,
+  pRfft, pCfft}; arm_dct4_instance_q31 S = {N, Nby2, normalize, pTwiddle,
+  pCosFactor, pRfft, pCfft}; arm_dct4_instance_q15 S = {N, Nby2, normalize,
+  pTwiddle, pCosFactor, pRfft, pCfft};
   
- where \c N is the length of the DCT4; \c Nby2 is half of the length of the DCT4; - \c normalize is normalizing factor used and is equal to sqrt(2/N); - \c pTwiddle points to the twiddle factor table; - \c pCosFactor points to the cosFactor table; - \c pRfft points to the real FFT instance; - \c pCfft points to the complex FFT instance; - The CFFT and RFFT structures also needs to be initialized, refer to arm_cfft_radix4_f32() - and arm_rfft_f32() respectively for details regarding static initialization. - - @par Fixed-Point Behavior - Care must be taken when using the fixed-point versions of the DCT4 transform functions. - In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. - Refer to the function specific documentation below for usage guidelines. - */ + where \c N is the length of the DCT4; \c Nby2 is half of the + length of the DCT4; \c normalize is normalizing factor used and is equal to + sqrt(2/N); \c pTwiddle points to the twiddle factor table; \c + pCosFactor points to the cosFactor table; \c pRfft points to the real FFT + instance; \c pCfft points to the complex FFT instance; The CFFT and RFFT + structures also needs to be initialized, refer to arm_cfft_radix4_f32() and + arm_rfft_f32() respectively for details regarding static initialization. - /** - @addtogroup DCT4_IDCT4 - @{ + @par Fixed-Point Behavior + Care must be taken when using the fixed-point versions of the + DCT4 transform functions. In particular, the overflow and saturation behavior + of the accumulator used in each function must be considered. Refer to the + function specific documentation below for usage guidelines. */ +/** + @addtogroup DCT4_IDCT4 + @{ +*/ + /** @brief Processing function for the floating-point DCT4/IDCT4. - @param[in] S points to an instance of the floating-point DCT4/IDCT4 structure + @param[in] S points to an instance of the floating-point + DCT4/IDCT4 structure @param[in] pState points to state buffer @param[in,out] pInlineBuffer points to the in-place input and output buffer @return none */ -void arm_dct4_f32( - const arm_dct4_instance_f32 * S, - float32_t * pState, - float32_t * pInlineBuffer) -{ - const float32_t *weights = S->pTwiddle; /* Pointer to the Weights table */ - const float32_t *cosFact = S->pCosFactor; /* Pointer to the cos factors table */ - float32_t *pS1, *pS2, *pbuff; /* Temporary pointers for input buffer and pState buffer */ - float32_t in; /* Temporary variable */ - uint32_t i; /* Loop counter */ - +void arm_dct4_f32(const arm_dct4_instance_f32 *S, float32_t *pState, + float32_t *pInlineBuffer) { + const float32_t *weights = S->pTwiddle; /* Pointer to the Weights table */ + const float32_t *cosFact = + S->pCosFactor; /* Pointer to the cos factors table */ + float32_t *pS1, *pS2, + *pbuff; /* Temporary pointers for input buffer and pState buffer */ + float32_t in; /* Temporary variable */ + uint32_t i; /* Loop counter */ /* DCT4 computation involves DCT2 (which is calculated using RFFT) * along with some pre-processing and post-processing. @@ -147,16 +159,17 @@ void arm_dct4_f32( * (b) Calculation of DCT2 using FFT is divided into three steps: * Step1: Re-ordering of even and odd elements of input. * Step2: Calculating FFT of the re-ordered input. - * Step3: Taking the real part of the product of FFT output and weights. - * (c) Post-processing - DCT4 can be obtained from DCT2 output using the following equation: - * Y4(k) = Y2(k) - Y4(k-1) and Y4(-1) = Y4(0) + * Step3: Taking the real part of the product of FFT output + * and weights. (c) Post-processing - DCT4 can be obtained from DCT2 output + * using the following equation: Y4(k) = Y2(k) - Y4(k-1) and Y4(-1) = Y4(0) * where, * Y4 -- DCT4 output, Y2 -- DCT2 output * (d) Multiplying the output with the normalizing factor sqrt(2/N). */ /*-------- Pre-processing ------------*/ - /* Multiplying input with cos factor i.e. r(n) = 2 * x(n) * cos(pi*(2*n+1)/(4*n)) */ + /* Multiplying input with cos factor i.e. r(n) = 2 * x(n) * + * cos(pi*(2*n+1)/(4*n)) */ arm_scale_f32(pInlineBuffer, 2.0f, pInlineBuffer, S->N); arm_mult_f32(pInlineBuffer, cosFact, pInlineBuffer, S->N); @@ -169,22 +182,22 @@ void arm_dct4_f32( /* pS1 initialized to pState */ pS1 = pState; - /* pS2 initialized to pState+N-1, so that it points to the end of the state buffer */ + /* pS2 initialized to pState+N-1, so that it points to the end of the state + * buffer */ pS2 = pState + (S->N - 1U); /* pbuff initialized to input buffer */ pbuff = pInlineBuffer; - -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Initializing the loop counter to N/2 >> 2 for loop unrolling by 4 */ i = S->Nby2 >> 2U; - /* First part of the processing with loop unrolling. Compute 4 outputs at a time. + /* First part of the processing with loop unrolling. Compute 4 outputs at a + *time. ** a second loop below computes the remaining 1 to 3 samples. */ - do - { + do { /* Re-ordering of even and odd elements */ /* pState[i] = pInlineBuffer[2*i] */ *pS1++ = *pbuff++; @@ -215,8 +228,7 @@ void arm_dct4_f32( /* Processing with loop unrolling 4 times as N is always multiple of 4. * Compute 4 outputs at a time */ - do - { + do { /* Writing the re-ordered output back to inplace input buffer */ *pbuff++ = *pS1++; *pbuff++ = *pS1++; @@ -227,17 +239,17 @@ void arm_dct4_f32( i--; } while (i > 0U); - /* --------------------------------------------------------- * Step2: Calculate RFFT for N-point input * ---------------------------------------------------------- */ - /* pInlineBuffer is real input of length N , pState is the complex output of length 2N */ - arm_rfft_f32 (S->pRfft, pInlineBuffer, pState); + /* pInlineBuffer is real input of length N , pState is the complex output of + * length 2N */ + arm_rfft_f32(S->pRfft, pInlineBuffer, pState); /*---------------------------------------------------------------------- * Step3: Multiply the FFT output with the weights. *----------------------------------------------------------------------*/ - arm_cmplx_mult_cmplx_f32 (pState, weights, pState, S->N); + arm_cmplx_mult_cmplx_f32(pState, weights, pState, S->N); /* ----------- Post-processing ---------- */ /* DCT-IV can be obtained from DCT-II by the equation, @@ -255,19 +267,23 @@ void arm_dct4_f32( pS1 = pState; /* Calculating Y4(0) from Y2(0) using Y4(0) = Y2(0)/2 */ - in = *pS1++ * (float32_t) 0.5; - /* input buffer acts as inplace, so output values are stored in the input itself. */ + in = *pS1++ * (float32_t)0.5; + /* input buffer acts as inplace, so output values are stored in the input + * itself. */ *pbuff++ = in; - /* pState pointer is incremented twice as the real values are located alternatively in the array */ + /* pState pointer is incremented twice as the real values are located + * alternatively in the array */ pS1++; - /* First part of the processing with loop unrolling. Compute 4 outputs at a time. + /* First part of the processing with loop unrolling. Compute 4 outputs at a + *time. ** a second loop below computes the remaining 1 to 3 samples. */ - do - { - /* Calculating Y4(1) to Y4(N-1) from Y2 using equation Y4(k) = Y2(k) - Y4(k-1) */ - /* pState pointer (pS1) is incremented twice as the real values are located alternatively in the array */ + do { + /* Calculating Y4(1) to Y4(N-1) from Y2 using equation Y4(k) = Y2(k) - + * Y4(k-1) */ + /* pState pointer (pS1) is incremented twice as the real values are located + * alternatively in the array */ in = *pS1++ - in; *pbuff++ = in; /* points to the next real value */ @@ -289,14 +305,16 @@ void arm_dct4_f32( i--; } while (i > 0U); - /* If the blockSize is not a multiple of 4, compute any remaining output samples here. + /* If the blockSize is not a multiple of 4, compute any remaining output + *samples here. ** No loop unrolling is used. */ i = (S->N - 1U) % 0x4U; - while (i > 0U) - { - /* Calculating Y4(1) to Y4(N-1) from Y2 using equation Y4(k) = Y2(k) - Y4(k-1) */ - /* pState pointer (pS1) is incremented twice as the real values are located alternatively in the array */ + while (i > 0U) { + /* Calculating Y4(1) to Y4(N-1) from Y2 using equation Y4(k) = Y2(k) - + * Y4(k-1) */ + /* pState pointer (pS1) is incremented twice as the real values are located + * alternatively in the array */ in = *pS1++ - in; *pbuff++ = in; @@ -307,8 +325,8 @@ void arm_dct4_f32( i--; } - - /*------------ Normalizing the output by multiplying with the normalizing factor ----------*/ + /*------------ Normalizing the output by multiplying with the normalizing + * factor ----------*/ /* Initializing the loop counter to N/4 instead of N for loop unrolling */ i = S->N >> 2U; @@ -316,9 +334,9 @@ void arm_dct4_f32( /* pbuff initialized to the pInlineBuffer(now contains the output values) */ pbuff = pInlineBuffer; - /* Processing with loop unrolling 4 times as N is always multiple of 4. Compute 4 outputs at a time */ - do - { + /* Processing with loop unrolling 4 times as N is always multiple of 4. + * Compute 4 outputs at a time */ + do { /* Multiplying pInlineBuffer with the normalizing factor sqrt(2/N) */ in = *pbuff; *pbuff++ = in * S->normalize; @@ -336,14 +354,12 @@ void arm_dct4_f32( i--; } while (i > 0U); - #else /* Initializing the loop counter to N/2 */ i = S->Nby2; - do - { + do { /* Re-ordering of even and odd elements */ /* pState[i] = pInlineBuffer[2*i] */ *pS1++ = *pbuff++; @@ -363,8 +379,7 @@ void arm_dct4_f32( /* Initializing the loop counter */ i = S->N; - do - { + do { /* Writing the re-ordered output back to inplace input buffer */ *pbuff++ = *pS1++; @@ -372,17 +387,17 @@ void arm_dct4_f32( i--; } while (i > 0U); - /* --------------------------------------------------------- * Step2: Calculate RFFT for N-point input * ---------------------------------------------------------- */ - /* pInlineBuffer is real input of length N , pState is the complex output of length 2N */ - arm_rfft_f32 (S->pRfft, pInlineBuffer, pState); + /* pInlineBuffer is real input of length N , pState is the complex output of + * length 2N */ + arm_rfft_f32(S->pRfft, pInlineBuffer, pState); /*---------------------------------------------------------------------- * Step3: Multiply the FFT output with the weights. *----------------------------------------------------------------------*/ - arm_cmplx_mult_cmplx_f32 (pState, weights, pState, S->N); + arm_cmplx_mult_cmplx_f32(pState, weights, pState, S->N); /* ----------- Post-processing ---------- */ /* DCT-IV can be obtained from DCT-II by the equation, @@ -397,20 +412,23 @@ void arm_dct4_f32( pS1 = pState; /* Calculating Y4(0) from Y2(0) using Y4(0) = Y2(0)/2 */ - in = *pS1++ * (float32_t) 0.5; - /* input buffer acts as inplace, so output values are stored in the input itself. */ + in = *pS1++ * (float32_t)0.5; + /* input buffer acts as inplace, so output values are stored in the input + * itself. */ *pbuff++ = in; - /* pState pointer is incremented twice as the real values are located alternatively in the array */ + /* pState pointer is incremented twice as the real values are located + * alternatively in the array */ pS1++; /* Initializing the loop counter */ i = (S->N - 1U); - do - { - /* Calculating Y4(1) to Y4(N-1) from Y2 using equation Y4(k) = Y2(k) - Y4(k-1) */ - /* pState pointer (pS1) is incremented twice as the real values are located alternatively in the array */ + do { + /* Calculating Y4(1) to Y4(N-1) from Y2 using equation Y4(k) = Y2(k) - + * Y4(k-1) */ + /* pState pointer (pS1) is incremented twice as the real values are located + * alternatively in the array */ in = *pS1++ - in; *pbuff++ = in; @@ -421,7 +439,8 @@ void arm_dct4_f32( i--; } while (i > 0U); - /*------------ Normalizing the output by multiplying with the normalizing factor ----------*/ + /*------------ Normalizing the output by multiplying with the normalizing + * factor ----------*/ /* Initializing loop counter */ i = S->N; @@ -429,8 +448,7 @@ void arm_dct4_f32( /* pbuff initialized to the pInlineBuffer (now contains the output values) */ pbuff = pInlineBuffer; - do - { + do { /* Multiplying pInlineBuffer with the normalizing factor sqrt(2/N) */ in = *pbuff; *pbuff++ = in * S->normalize; @@ -440,7 +458,6 @@ void arm_dct4_f32( } while (i > 0U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - } /** diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_init_f32.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_init_f32.c index 588ee7d..398dcba 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_init_f32.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_init_f32.c @@ -43,7 +43,8 @@ /** @par - Weights tables are generated using the formula :
weights[n] = e^(-j*n*pi/(2*N))
+ Weights tables are generated using the formula :
weights[n] =
+  e^(-j*n*pi/(2*N))
@par C command to generate the table
@@ -53,10417 +54,7281 @@
     weights[(2*i)+1] = -sin (i*c);
   } 
@par - where N is the Number of weights to be calculated and c is pi/(2*N) + where N is the Number of weights to be calculated and + c is pi/(2*N) @par - In the tables below the real and imaginary values are placed alternatively, hence the - array length is 2*N. + In the tables below the real and imaginary values are placed alternatively, + hence the array length is 2*N. */ static const float32_t Weights_128[256] = { - 1.000000000000000000f, 0.000000000000000000f, 0.999924701839144500f, -0.012271538285719925f, - 0.999698818696204250f, -0.024541228522912288f, 0.999322384588349540f, -0.036807222941358832f, - 0.998795456205172410f, -0.049067674327418015f, 0.998118112900149180f, -0.061320736302208578f, - 0.997290456678690210f, -0.073564563599667426f, 0.996312612182778000f, -0.085797312344439894f, - 0.995184726672196930f, -0.098017140329560604f, 0.993906970002356060f, -0.110222207293883060f, - 0.992479534598709970f, -0.122410675199216200f, 0.990902635427780010f, -0.134580708507126170f, - 0.989176509964781010f, -0.146730474455361750f, 0.987301418157858430f, -0.158858143333861450f, - 0.985277642388941220f, -0.170961888760301220f, 0.983105487431216290f, -0.183039887955140950f, - 0.980785280403230430f, -0.195090322016128250f, 0.978317370719627650f, -0.207111376192218560f, - 0.975702130038528570f, -0.219101240156869800f, 0.972939952205560180f, -0.231058108280671110f, - 0.970031253194543970f, -0.242980179903263870f, 0.966976471044852070f, -0.254865659604514570f, - 0.963776065795439840f, -0.266712757474898370f, 0.960430519415565790f, -0.278519689385053060f, - 0.956940335732208820f, -0.290284677254462330f, 0.953306040354193860f, -0.302005949319228080f, - 0.949528180593036670f, -0.313681740398891520f, 0.945607325380521280f, -0.325310292162262930f, - 0.941544065183020810f, -0.336889853392220050f, 0.937339011912574960f, -0.348418680249434560f, - 0.932992798834738960f, -0.359895036534988110f, 0.928506080473215590f, -0.371317193951837540f, - 0.923879532511286740f, -0.382683432365089780f, 0.919113851690057770f, -0.393992040061048100f, - 0.914209755703530690f, -0.405241314004989860f, 0.909167983090522380f, -0.416429560097637150f, - 0.903989293123443340f, -0.427555093430282080f, 0.898674465693953820f, -0.438616238538527660f, - 0.893224301195515320f, -0.449611329654606540f, 0.887639620402853930f, -0.460538710958240010f, - 0.881921264348355050f, -0.471396736825997640f, 0.876070094195406600f, -0.482183772079122720f, - 0.870086991108711460f, -0.492898192229784040f, 0.863972856121586810f, -0.503538383725717580f, - 0.857728610000272120f, -0.514102744193221660f, 0.851355193105265200f, -0.524589682678468950f, - 0.844853565249707120f, -0.534997619887097150f, 0.838224705554838080f, -0.545324988422046460f, - 0.831469612302545240f, -0.555570233019602180f, 0.824589302785025290f, -0.565731810783613120f, - 0.817584813151583710f, -0.575808191417845340f, 0.810457198252594770f, -0.585797857456438860f, - 0.803207531480644940f, -0.595699304492433360f, 0.795836904608883570f, -0.605511041404325550f, - 0.788346427626606340f, -0.615231590580626820f, 0.780737228572094490f, -0.624859488142386340f, - 0.773010453362736990f, -0.634393284163645490f, 0.765167265622458960f, -0.643831542889791390f, - 0.757208846506484570f, -0.653172842953776760f, 0.749136394523459370f, -0.662415777590171780f, - 0.740951125354959110f, -0.671558954847018330f, 0.732654271672412820f, -0.680600997795453020f, - 0.724247082951467000f, -0.689540544737066830f, 0.715730825283818590f, -0.698376249408972920f, - 0.707106781186547570f, -0.707106781186547460f, 0.698376249408972920f, -0.715730825283818590f, - 0.689540544737066940f, -0.724247082951466890f, 0.680600997795453130f, -0.732654271672412820f, - 0.671558954847018330f, -0.740951125354959110f, 0.662415777590171780f, -0.749136394523459260f, - 0.653172842953776760f, -0.757208846506484460f, 0.643831542889791500f, -0.765167265622458960f, - 0.634393284163645490f, -0.773010453362736990f, 0.624859488142386450f, -0.780737228572094380f, - 0.615231590580626820f, -0.788346427626606230f, 0.605511041404325550f, -0.795836904608883460f, - 0.595699304492433470f, -0.803207531480644830f, 0.585797857456438860f, -0.810457198252594770f, - 0.575808191417845340f, -0.817584813151583710f, 0.565731810783613230f, -0.824589302785025290f, - 0.555570233019602290f, -0.831469612302545240f, 0.545324988422046460f, -0.838224705554837970f, - 0.534997619887097260f, -0.844853565249707010f, 0.524589682678468840f, -0.851355193105265200f, - 0.514102744193221660f, -0.857728610000272120f, 0.503538383725717580f, -0.863972856121586700f, - 0.492898192229784090f, -0.870086991108711350f, 0.482183772079122830f, -0.876070094195406600f, - 0.471396736825997810f, -0.881921264348354940f, 0.460538710958240010f, -0.887639620402853930f, - 0.449611329654606600f, -0.893224301195515320f, 0.438616238538527710f, -0.898674465693953820f, - 0.427555093430282200f, -0.903989293123443340f, 0.416429560097637320f, -0.909167983090522270f, - 0.405241314004989860f, -0.914209755703530690f, 0.393992040061048100f, -0.919113851690057770f, - 0.382683432365089840f, -0.923879532511286740f, 0.371317193951837600f, -0.928506080473215480f, - 0.359895036534988280f, -0.932992798834738850f, 0.348418680249434510f, -0.937339011912574960f, - 0.336889853392220050f, -0.941544065183020810f, 0.325310292162262980f, -0.945607325380521280f, - 0.313681740398891570f, -0.949528180593036670f, 0.302005949319228200f, -0.953306040354193750f, - 0.290284677254462330f, -0.956940335732208940f, 0.278519689385053060f, -0.960430519415565790f, - 0.266712757474898420f, -0.963776065795439840f, 0.254865659604514630f, -0.966976471044852070f, - 0.242980179903263980f, -0.970031253194543970f, 0.231058108280671280f, -0.972939952205560070f, - 0.219101240156869770f, -0.975702130038528570f, 0.207111376192218560f, -0.978317370719627650f, - 0.195090322016128330f, -0.980785280403230430f, 0.183039887955141060f, -0.983105487431216290f, - 0.170961888760301360f, -0.985277642388941220f, 0.158858143333861390f, -0.987301418157858430f, - 0.146730474455361750f, -0.989176509964781010f, 0.134580708507126220f, -0.990902635427780010f, - 0.122410675199216280f, -0.992479534598709970f, 0.110222207293883180f, -0.993906970002356060f, - 0.098017140329560770f, -0.995184726672196820f, 0.085797312344439880f, -0.996312612182778000f, - 0.073564563599667454f, -0.997290456678690210f, 0.061320736302208648f, -0.998118112900149180f, - 0.049067674327418126f, -0.998795456205172410f, 0.036807222941358991f, -0.999322384588349540f, - 0.024541228522912264f, -0.999698818696204250f, 0.012271538285719944f, -0.999924701839144500f -}; + 1.000000000000000000f, 0.000000000000000000f, 0.999924701839144500f, + -0.012271538285719925f, 0.999698818696204250f, -0.024541228522912288f, + 0.999322384588349540f, -0.036807222941358832f, 0.998795456205172410f, + -0.049067674327418015f, 0.998118112900149180f, -0.061320736302208578f, + 0.997290456678690210f, -0.073564563599667426f, 0.996312612182778000f, + -0.085797312344439894f, 0.995184726672196930f, -0.098017140329560604f, + 0.993906970002356060f, -0.110222207293883060f, 0.992479534598709970f, + -0.122410675199216200f, 0.990902635427780010f, -0.134580708507126170f, + 0.989176509964781010f, -0.146730474455361750f, 0.987301418157858430f, + -0.158858143333861450f, 0.985277642388941220f, -0.170961888760301220f, + 0.983105487431216290f, -0.183039887955140950f, 0.980785280403230430f, + -0.195090322016128250f, 0.978317370719627650f, -0.207111376192218560f, + 0.975702130038528570f, -0.219101240156869800f, 0.972939952205560180f, + -0.231058108280671110f, 0.970031253194543970f, -0.242980179903263870f, + 0.966976471044852070f, -0.254865659604514570f, 0.963776065795439840f, + -0.266712757474898370f, 0.960430519415565790f, -0.278519689385053060f, + 0.956940335732208820f, -0.290284677254462330f, 0.953306040354193860f, + -0.302005949319228080f, 0.949528180593036670f, -0.313681740398891520f, + 0.945607325380521280f, -0.325310292162262930f, 0.941544065183020810f, + -0.336889853392220050f, 0.937339011912574960f, -0.348418680249434560f, + 0.932992798834738960f, -0.359895036534988110f, 0.928506080473215590f, + -0.371317193951837540f, 0.923879532511286740f, -0.382683432365089780f, + 0.919113851690057770f, -0.393992040061048100f, 0.914209755703530690f, + -0.405241314004989860f, 0.909167983090522380f, -0.416429560097637150f, + 0.903989293123443340f, -0.427555093430282080f, 0.898674465693953820f, + -0.438616238538527660f, 0.893224301195515320f, -0.449611329654606540f, + 0.887639620402853930f, -0.460538710958240010f, 0.881921264348355050f, + -0.471396736825997640f, 0.876070094195406600f, -0.482183772079122720f, + 0.870086991108711460f, -0.492898192229784040f, 0.863972856121586810f, + -0.503538383725717580f, 0.857728610000272120f, -0.514102744193221660f, + 0.851355193105265200f, -0.524589682678468950f, 0.844853565249707120f, + -0.534997619887097150f, 0.838224705554838080f, -0.545324988422046460f, + 0.831469612302545240f, -0.555570233019602180f, 0.824589302785025290f, + -0.565731810783613120f, 0.817584813151583710f, -0.575808191417845340f, + 0.810457198252594770f, -0.585797857456438860f, 0.803207531480644940f, + -0.595699304492433360f, 0.795836904608883570f, -0.605511041404325550f, + 0.788346427626606340f, -0.615231590580626820f, 0.780737228572094490f, + -0.624859488142386340f, 0.773010453362736990f, -0.634393284163645490f, + 0.765167265622458960f, -0.643831542889791390f, 0.757208846506484570f, + -0.653172842953776760f, 0.749136394523459370f, -0.662415777590171780f, + 0.740951125354959110f, -0.671558954847018330f, 0.732654271672412820f, + -0.680600997795453020f, 0.724247082951467000f, -0.689540544737066830f, + 0.715730825283818590f, -0.698376249408972920f, 0.707106781186547570f, + -0.707106781186547460f, 0.698376249408972920f, -0.715730825283818590f, + 0.689540544737066940f, -0.724247082951466890f, 0.680600997795453130f, + -0.732654271672412820f, 0.671558954847018330f, -0.740951125354959110f, + 0.662415777590171780f, -0.749136394523459260f, 0.653172842953776760f, + -0.757208846506484460f, 0.643831542889791500f, -0.765167265622458960f, + 0.634393284163645490f, -0.773010453362736990f, 0.624859488142386450f, + -0.780737228572094380f, 0.615231590580626820f, -0.788346427626606230f, + 0.605511041404325550f, -0.795836904608883460f, 0.595699304492433470f, + -0.803207531480644830f, 0.585797857456438860f, -0.810457198252594770f, + 0.575808191417845340f, -0.817584813151583710f, 0.565731810783613230f, + -0.824589302785025290f, 0.555570233019602290f, -0.831469612302545240f, + 0.545324988422046460f, -0.838224705554837970f, 0.534997619887097260f, + -0.844853565249707010f, 0.524589682678468840f, -0.851355193105265200f, + 0.514102744193221660f, -0.857728610000272120f, 0.503538383725717580f, + -0.863972856121586700f, 0.492898192229784090f, -0.870086991108711350f, + 0.482183772079122830f, -0.876070094195406600f, 0.471396736825997810f, + -0.881921264348354940f, 0.460538710958240010f, -0.887639620402853930f, + 0.449611329654606600f, -0.893224301195515320f, 0.438616238538527710f, + -0.898674465693953820f, 0.427555093430282200f, -0.903989293123443340f, + 0.416429560097637320f, -0.909167983090522270f, 0.405241314004989860f, + -0.914209755703530690f, 0.393992040061048100f, -0.919113851690057770f, + 0.382683432365089840f, -0.923879532511286740f, 0.371317193951837600f, + -0.928506080473215480f, 0.359895036534988280f, -0.932992798834738850f, + 0.348418680249434510f, -0.937339011912574960f, 0.336889853392220050f, + -0.941544065183020810f, 0.325310292162262980f, -0.945607325380521280f, + 0.313681740398891570f, -0.949528180593036670f, 0.302005949319228200f, + -0.953306040354193750f, 0.290284677254462330f, -0.956940335732208940f, + 0.278519689385053060f, -0.960430519415565790f, 0.266712757474898420f, + -0.963776065795439840f, 0.254865659604514630f, -0.966976471044852070f, + 0.242980179903263980f, -0.970031253194543970f, 0.231058108280671280f, + -0.972939952205560070f, 0.219101240156869770f, -0.975702130038528570f, + 0.207111376192218560f, -0.978317370719627650f, 0.195090322016128330f, + -0.980785280403230430f, 0.183039887955141060f, -0.983105487431216290f, + 0.170961888760301360f, -0.985277642388941220f, 0.158858143333861390f, + -0.987301418157858430f, 0.146730474455361750f, -0.989176509964781010f, + 0.134580708507126220f, -0.990902635427780010f, 0.122410675199216280f, + -0.992479534598709970f, 0.110222207293883180f, -0.993906970002356060f, + 0.098017140329560770f, -0.995184726672196820f, 0.085797312344439880f, + -0.996312612182778000f, 0.073564563599667454f, -0.997290456678690210f, + 0.061320736302208648f, -0.998118112900149180f, 0.049067674327418126f, + -0.998795456205172410f, 0.036807222941358991f, -0.999322384588349540f, + 0.024541228522912264f, -0.999698818696204250f, 0.012271538285719944f, + -0.999924701839144500f}; static const float32_t Weights_512[1024] = { - 1.000000000000000000f, 0.000000000000000000f, 0.999995293809576190f, -0.003067956762965976f, - 0.999981175282601110f, -0.006135884649154475f, 0.999957644551963900f, -0.009203754782059819f, - 0.999924701839144500f, -0.012271538285719925f, 0.999882347454212560f, -0.015339206284988100f, - 0.999830581795823400f, -0.018406729905804820f, 0.999769405351215280f, -0.021474080275469508f, - 0.999698818696204250f, -0.024541228522912288f, 0.999618822495178640f, -0.027608145778965740f, - 0.999529417501093140f, -0.030674803176636626f, 0.999430604555461730f, -0.033741171851377580f, - 0.999322384588349540f, -0.036807222941358832f, 0.999204758618363890f, -0.039872927587739811f, - 0.999077727752645360f, -0.042938256934940820f, 0.998941293186856870f, -0.046003182130914623f, - 0.998795456205172410f, -0.049067674327418015f, 0.998640218180265270f, -0.052131704680283324f, - 0.998475580573294770f, -0.055195244349689934f, 0.998301544933892890f, -0.058258264500435752f, - 0.998118112900149180f, -0.061320736302208578f, 0.997925286198596000f, -0.064382630929857465f, - 0.997723066644191640f, -0.067443919563664051f, 0.997511456140303450f, -0.070504573389613856f, - 0.997290456678690210f, -0.073564563599667426f, 0.997060070339482960f, -0.076623861392031492f, - 0.996820299291165670f, -0.079682437971430126f, 0.996571145790554840f, -0.082740264549375692f, - 0.996312612182778000f, -0.085797312344439894f, 0.996044700901251970f, -0.088853552582524600f, - 0.995767414467659820f, -0.091908956497132724f, 0.995480755491926940f, -0.094963495329638992f, - 0.995184726672196930f, -0.098017140329560604f, 0.994879330794805620f, -0.101069862754827820f, - 0.994564570734255420f, -0.104121633872054590f, 0.994240449453187900f, -0.107172424956808840f, - 0.993906970002356060f, -0.110222207293883060f, 0.993564135520595300f, -0.113270952177564350f, - 0.993211949234794500f, -0.116318630911904750f, 0.992850414459865100f, -0.119365214810991350f, - 0.992479534598709970f, -0.122410675199216200f, 0.992099313142191800f, -0.125454983411546230f, - 0.991709753669099530f, -0.128498110793793170f, 0.991310859846115440f, -0.131540028702883120f, - 0.990902635427780010f, -0.134580708507126170f, 0.990485084256457090f, -0.137620121586486040f, - 0.990058210262297120f, -0.140658239332849210f, 0.989622017463200890f, -0.143695033150294470f, - 0.989176509964781010f, -0.146730474455361750f, 0.988721691960323780f, -0.149764534677321510f, - 0.988257567730749460f, -0.152797185258443440f, 0.987784141644572180f, -0.155828397654265230f, - 0.987301418157858430f, -0.158858143333861450f, 0.986809401814185530f, -0.161886393780111830f, - 0.986308097244598670f, -0.164913120489969890f, 0.985797509167567480f, -0.167938294974731170f, - 0.985277642388941220f, -0.170961888760301220f, 0.984748501801904210f, -0.173983873387463820f, - 0.984210092386929030f, -0.177004220412148750f, 0.983662419211730250f, -0.180022901405699510f, - 0.983105487431216290f, -0.183039887955140950f, 0.982539302287441240f, -0.186055151663446630f, - 0.981963869109555240f, -0.189068664149806190f, 0.981379193313754560f, -0.192080397049892440f, - 0.980785280403230430f, -0.195090322016128250f, 0.980182135968117430f, -0.198098410717953560f, - 0.979569765685440520f, -0.201104634842091900f, 0.978948175319062200f, -0.204108966092816870f, - 0.978317370719627650f, -0.207111376192218560f, 0.977677357824509930f, -0.210111836880469610f, - 0.977028142657754390f, -0.213110319916091360f, 0.976369731330021140f, -0.216106797076219520f, - 0.975702130038528570f, -0.219101240156869800f, 0.975025345066994120f, -0.222093620973203510f, - 0.974339382785575860f, -0.225083911359792830f, 0.973644249650811980f, -0.228072083170885730f, - 0.972939952205560180f, -0.231058108280671110f, 0.972226497078936270f, -0.234041958583543430f, - 0.971503890986251780f, -0.237023605994367200f, 0.970772140728950350f, -0.240003022448741500f, - 0.970031253194543970f, -0.242980179903263870f, 0.969281235356548530f, -0.245955050335794590f, - 0.968522094274417380f, -0.248927605745720150f, 0.967753837093475510f, -0.251897818154216970f, - 0.966976471044852070f, -0.254865659604514570f, 0.966190003445412500f, -0.257831102162158990f, - 0.965394441697689400f, -0.260794117915275510f, 0.964589793289812760f, -0.263754678974831350f, - 0.963776065795439840f, -0.266712757474898370f, 0.962953266873683880f, -0.269668325572915090f, - 0.962121404269041580f, -0.272621355449948980f, 0.961280485811320640f, -0.275571819310958140f, - 0.960430519415565790f, -0.278519689385053060f, 0.959571513081984520f, -0.281464937925757940f, - 0.958703474895871600f, -0.284407537211271880f, 0.957826413027532910f, -0.287347459544729510f, - 0.956940335732208820f, -0.290284677254462330f, 0.956045251349996410f, -0.293219162694258630f, - 0.955141168305770780f, -0.296150888243623790f, 0.954228095109105670f, -0.299079826308040480f, - 0.953306040354193860f, -0.302005949319228080f, 0.952375012719765880f, -0.304929229735402370f, - 0.951435020969008340f, -0.307849640041534870f, 0.950486073949481700f, -0.310767152749611470f, - 0.949528180593036670f, -0.313681740398891520f, 0.948561349915730270f, -0.316593375556165850f, - 0.947585591017741090f, -0.319502030816015690f, 0.946600913083283530f, -0.322407678801069850f, - 0.945607325380521280f, -0.325310292162262930f, 0.944604837261480260f, -0.328209843579092500f, - 0.943593458161960390f, -0.331106305759876430f, 0.942573197601446870f, -0.333999651442009380f, - 0.941544065183020810f, -0.336889853392220050f, 0.940506070593268300f, -0.339776884406826850f, - 0.939459223602189920f, -0.342660717311994380f, 0.938403534063108060f, -0.345541324963989090f, - 0.937339011912574960f, -0.348418680249434560f, 0.936265667170278260f, -0.351292756085567090f, - 0.935183509938947610f, -0.354163525420490340f, 0.934092550404258980f, -0.357030961233429980f, - 0.932992798834738960f, -0.359895036534988110f, 0.931884265581668150f, -0.362755724367397230f, - 0.930766961078983710f, -0.365612997804773850f, 0.929640895843181330f, -0.368466829953372320f, - 0.928506080473215590f, -0.371317193951837540f, 0.927362525650401110f, -0.374164062971457930f, - 0.926210242138311380f, -0.377007410216418260f, 0.925049240782677580f, -0.379847208924051160f, - 0.923879532511286740f, -0.382683432365089780f, 0.922701128333878630f, -0.385516053843918850f, - 0.921514039342042010f, -0.388345046698826250f, 0.920318276709110590f, -0.391170384302253870f, - 0.919113851690057770f, -0.393992040061048100f, 0.917900775621390500f, -0.396809987416710310f, - 0.916679059921042700f, -0.399624199845646790f, 0.915448716088267830f, -0.402434650859418430f, - 0.914209755703530690f, -0.405241314004989860f, 0.912962190428398210f, -0.408044162864978690f, - 0.911706032005429880f, -0.410843171057903910f, 0.910441292258067250f, -0.413638312238434500f, - 0.909167983090522380f, -0.416429560097637150f, 0.907886116487666260f, -0.419216888363223910f, - 0.906595704514915330f, -0.422000270799799680f, 0.905296759318118820f, -0.424779681209108810f, - 0.903989293123443340f, -0.427555093430282080f, 0.902673318237258830f, -0.430326481340082610f, - 0.901348847046022030f, -0.433093818853151960f, 0.900015892016160280f, -0.435857079922255470f, - 0.898674465693953820f, -0.438616238538527660f, 0.897324580705418320f, -0.441371268731716670f, - 0.895966249756185220f, -0.444122144570429200f, 0.894599485631382700f, -0.446868840162374160f, - 0.893224301195515320f, -0.449611329654606540f, 0.891840709392342720f, -0.452349587233770890f, - 0.890448723244757880f, -0.455083587126343840f, 0.889048355854664570f, -0.457813303598877170f, - 0.887639620402853930f, -0.460538710958240010f, 0.886222530148880640f, -0.463259783551860150f, - 0.884797098430937790f, -0.465976495767966180f, 0.883363338665731580f, -0.468688822035827900f, - 0.881921264348355050f, -0.471396736825997640f, 0.880470889052160750f, -0.474100214650549970f, - 0.879012226428633530f, -0.476799230063322090f, 0.877545290207261350f, -0.479493757660153010f, - 0.876070094195406600f, -0.482183772079122720f, 0.874586652278176110f, -0.484869248000791060f, - 0.873094978418290090f, -0.487550160148436000f, 0.871595086655950980f, -0.490226483288291160f, - 0.870086991108711460f, -0.492898192229784040f, 0.868570705971340900f, -0.495565261825772540f, - 0.867046245515692650f, -0.498227666972781870f, 0.865513624090569090f, -0.500885382611240710f, - 0.863972856121586810f, -0.503538383725717580f, 0.862423956111040610f, -0.506186645345155230f, - 0.860866938637767310f, -0.508830142543106990f, 0.859301818357008470f, -0.511468850437970300f, - 0.857728610000272120f, -0.514102744193221660f, 0.856147328375194470f, -0.516731799017649870f, - 0.854557988365400530f, -0.519355990165589640f, 0.852960604930363630f, -0.521975292937154390f, - 0.851355193105265200f, -0.524589682678468950f, 0.849741768000852550f, -0.527199134781901280f, - 0.848120344803297230f, -0.529803624686294610f, 0.846490938774052130f, -0.532403127877197900f, - 0.844853565249707120f, -0.534997619887097150f, 0.843208239641845440f, -0.537587076295645390f, - 0.841554977436898440f, -0.540171472729892850f, 0.839893794195999520f, -0.542750784864515890f, - 0.838224705554838080f, -0.545324988422046460f, 0.836547727223512010f, -0.547894059173100190f, - 0.834862874986380010f, -0.550457972936604810f, 0.833170164701913190f, -0.553016705580027470f, - 0.831469612302545240f, -0.555570233019602180f, 0.829761233794523050f, -0.558118531220556100f, - 0.828045045257755800f, -0.560661576197336030f, 0.826321062845663530f, -0.563199344013834090f, - 0.824589302785025290f, -0.565731810783613120f, 0.822849781375826430f, -0.568258952670131490f, - 0.821102514991104650f, -0.570780745886967260f, 0.819347520076796900f, -0.573297166698042200f, - 0.817584813151583710f, -0.575808191417845340f, 0.815814410806733780f, -0.578313796411655590f, - 0.814036329705948410f, -0.580813958095764530f, 0.812250586585203880f, -0.583308652937698290f, - 0.810457198252594770f, -0.585797857456438860f, 0.808656181588174980f, -0.588281548222645220f, - 0.806847553543799330f, -0.590759701858874160f, 0.805031331142963660f, -0.593232295039799800f, - 0.803207531480644940f, -0.595699304492433360f, 0.801376171723140240f, -0.598160706996342270f, - 0.799537269107905010f, -0.600616479383868970f, 0.797690840943391160f, -0.603066598540348160f, - 0.795836904608883570f, -0.605511041404325550f, 0.793975477554337170f, -0.607949784967773630f, - 0.792106577300212390f, -0.610382806276309480f, 0.790230221437310030f, -0.612810082429409710f, - 0.788346427626606340f, -0.615231590580626820f, 0.786455213599085770f, -0.617647307937803870f, - 0.784556597155575240f, -0.620057211763289100f, 0.782650596166575730f, -0.622461279374149970f, - 0.780737228572094490f, -0.624859488142386340f, 0.778816512381475980f, -0.627251815495144080f, - 0.776888465673232440f, -0.629638238914926980f, 0.774953106594873930f, -0.632018735939809060f, - 0.773010453362736990f, -0.634393284163645490f, 0.771060524261813820f, -0.636761861236284200f, - 0.769103337645579700f, -0.639124444863775730f, 0.767138911935820400f, -0.641481012808583160f, - 0.765167265622458960f, -0.643831542889791390f, 0.763188417263381270f, -0.646176012983316280f, - 0.761202385484261780f, -0.648514401022112440f, 0.759209188978388070f, -0.650846684996380880f, - 0.757208846506484570f, -0.653172842953776760f, 0.755201376896536550f, -0.655492852999615350f, - 0.753186799043612520f, -0.657806693297078640f, 0.751165131909686480f, -0.660114342067420480f, - 0.749136394523459370f, -0.662415777590171780f, 0.747100605980180130f, -0.664710978203344790f, - 0.745057785441466060f, -0.666999922303637470f, 0.743007952135121720f, -0.669282588346636010f, - 0.740951125354959110f, -0.671558954847018330f, 0.738887324460615110f, -0.673829000378756040f, - 0.736816568877369900f, -0.676092703575315920f, 0.734738878095963500f, -0.678350043129861470f, - 0.732654271672412820f, -0.680600997795453020f, 0.730562769227827590f, -0.682845546385248080f, - 0.728464390448225200f, -0.685083667772700360f, 0.726359155084346010f, -0.687315340891759050f, - 0.724247082951467000f, -0.689540544737066830f, 0.722128193929215350f, -0.691759258364157750f, - 0.720002507961381650f, -0.693971460889654000f, 0.717870045055731710f, -0.696177131491462990f, - 0.715730825283818590f, -0.698376249408972920f, 0.713584868780793640f, -0.700568793943248340f, - 0.711432195745216430f, -0.702754744457225300f, 0.709272826438865690f, -0.704934080375904880f, - 0.707106781186547570f, -0.707106781186547460f, 0.704934080375904990f, -0.709272826438865580f, - 0.702754744457225300f, -0.711432195745216430f, 0.700568793943248450f, -0.713584868780793520f, - 0.698376249408972920f, -0.715730825283818590f, 0.696177131491462990f, -0.717870045055731710f, - 0.693971460889654000f, -0.720002507961381650f, 0.691759258364157750f, -0.722128193929215350f, - 0.689540544737066940f, -0.724247082951466890f, 0.687315340891759160f, -0.726359155084346010f, - 0.685083667772700360f, -0.728464390448225200f, 0.682845546385248080f, -0.730562769227827590f, - 0.680600997795453130f, -0.732654271672412820f, 0.678350043129861580f, -0.734738878095963390f, - 0.676092703575316030f, -0.736816568877369790f, 0.673829000378756150f, -0.738887324460615110f, - 0.671558954847018330f, -0.740951125354959110f, 0.669282588346636010f, -0.743007952135121720f, - 0.666999922303637470f, -0.745057785441465950f, 0.664710978203344900f, -0.747100605980180130f, - 0.662415777590171780f, -0.749136394523459260f, 0.660114342067420480f, -0.751165131909686370f, - 0.657806693297078640f, -0.753186799043612410f, 0.655492852999615460f, -0.755201376896536550f, - 0.653172842953776760f, -0.757208846506484460f, 0.650846684996380990f, -0.759209188978387960f, - 0.648514401022112550f, -0.761202385484261780f, 0.646176012983316390f, -0.763188417263381270f, - 0.643831542889791500f, -0.765167265622458960f, 0.641481012808583160f, -0.767138911935820400f, - 0.639124444863775730f, -0.769103337645579590f, 0.636761861236284200f, -0.771060524261813710f, - 0.634393284163645490f, -0.773010453362736990f, 0.632018735939809060f, -0.774953106594873820f, - 0.629638238914927100f, -0.776888465673232440f, 0.627251815495144190f, -0.778816512381475870f, - 0.624859488142386450f, -0.780737228572094380f, 0.622461279374150080f, -0.782650596166575730f, - 0.620057211763289210f, -0.784556597155575240f, 0.617647307937803980f, -0.786455213599085770f, - 0.615231590580626820f, -0.788346427626606230f, 0.612810082429409710f, -0.790230221437310030f, - 0.610382806276309480f, -0.792106577300212390f, 0.607949784967773740f, -0.793975477554337170f, - 0.605511041404325550f, -0.795836904608883460f, 0.603066598540348280f, -0.797690840943391040f, - 0.600616479383868970f, -0.799537269107905010f, 0.598160706996342380f, -0.801376171723140130f, - 0.595699304492433470f, -0.803207531480644830f, 0.593232295039799800f, -0.805031331142963660f, - 0.590759701858874280f, -0.806847553543799220f, 0.588281548222645330f, -0.808656181588174980f, - 0.585797857456438860f, -0.810457198252594770f, 0.583308652937698290f, -0.812250586585203880f, - 0.580813958095764530f, -0.814036329705948300f, 0.578313796411655590f, -0.815814410806733780f, - 0.575808191417845340f, -0.817584813151583710f, 0.573297166698042320f, -0.819347520076796900f, - 0.570780745886967370f, -0.821102514991104650f, 0.568258952670131490f, -0.822849781375826320f, - 0.565731810783613230f, -0.824589302785025290f, 0.563199344013834090f, -0.826321062845663420f, - 0.560661576197336030f, -0.828045045257755800f, 0.558118531220556100f, -0.829761233794523050f, - 0.555570233019602290f, -0.831469612302545240f, 0.553016705580027580f, -0.833170164701913190f, - 0.550457972936604810f, -0.834862874986380010f, 0.547894059173100190f, -0.836547727223511890f, - 0.545324988422046460f, -0.838224705554837970f, 0.542750784864516000f, -0.839893794195999410f, - 0.540171472729892970f, -0.841554977436898330f, 0.537587076295645510f, -0.843208239641845440f, - 0.534997619887097260f, -0.844853565249707010f, 0.532403127877198010f, -0.846490938774052020f, - 0.529803624686294830f, -0.848120344803297120f, 0.527199134781901390f, -0.849741768000852440f, - 0.524589682678468840f, -0.851355193105265200f, 0.521975292937154390f, -0.852960604930363630f, - 0.519355990165589530f, -0.854557988365400530f, 0.516731799017649980f, -0.856147328375194470f, - 0.514102744193221660f, -0.857728610000272120f, 0.511468850437970520f, -0.859301818357008360f, - 0.508830142543106990f, -0.860866938637767310f, 0.506186645345155450f, -0.862423956111040500f, - 0.503538383725717580f, -0.863972856121586700f, 0.500885382611240940f, -0.865513624090568980f, - 0.498227666972781870f, -0.867046245515692650f, 0.495565261825772490f, -0.868570705971340900f, - 0.492898192229784090f, -0.870086991108711350f, 0.490226483288291100f, -0.871595086655951090f, - 0.487550160148436050f, -0.873094978418290090f, 0.484869248000791120f, -0.874586652278176110f, - 0.482183772079122830f, -0.876070094195406600f, 0.479493757660153010f, -0.877545290207261240f, - 0.476799230063322250f, -0.879012226428633410f, 0.474100214650550020f, -0.880470889052160750f, - 0.471396736825997810f, -0.881921264348354940f, 0.468688822035827960f, -0.883363338665731580f, - 0.465976495767966130f, -0.884797098430937790f, 0.463259783551860260f, -0.886222530148880640f, - 0.460538710958240010f, -0.887639620402853930f, 0.457813303598877290f, -0.889048355854664570f, - 0.455083587126343840f, -0.890448723244757880f, 0.452349587233771000f, -0.891840709392342720f, - 0.449611329654606600f, -0.893224301195515320f, 0.446868840162374330f, -0.894599485631382580f, - 0.444122144570429260f, -0.895966249756185110f, 0.441371268731716620f, -0.897324580705418320f, - 0.438616238538527710f, -0.898674465693953820f, 0.435857079922255470f, -0.900015892016160280f, - 0.433093818853152010f, -0.901348847046022030f, 0.430326481340082610f, -0.902673318237258830f, - 0.427555093430282200f, -0.903989293123443340f, 0.424779681209108810f, -0.905296759318118820f, - 0.422000270799799790f, -0.906595704514915330f, 0.419216888363223960f, -0.907886116487666150f, - 0.416429560097637320f, -0.909167983090522270f, 0.413638312238434560f, -0.910441292258067140f, - 0.410843171057903910f, -0.911706032005429880f, 0.408044162864978740f, -0.912962190428398100f, - 0.405241314004989860f, -0.914209755703530690f, 0.402434650859418540f, -0.915448716088267830f, - 0.399624199845646790f, -0.916679059921042700f, 0.396809987416710420f, -0.917900775621390390f, - 0.393992040061048100f, -0.919113851690057770f, 0.391170384302253980f, -0.920318276709110480f, - 0.388345046698826300f, -0.921514039342041900f, 0.385516053843919020f, -0.922701128333878520f, - 0.382683432365089840f, -0.923879532511286740f, 0.379847208924051110f, -0.925049240782677580f, - 0.377007410216418310f, -0.926210242138311270f, 0.374164062971457990f, -0.927362525650401110f, - 0.371317193951837600f, -0.928506080473215480f, 0.368466829953372320f, -0.929640895843181330f, - 0.365612997804773960f, -0.930766961078983710f, 0.362755724367397230f, -0.931884265581668150f, - 0.359895036534988280f, -0.932992798834738850f, 0.357030961233430030f, -0.934092550404258870f, - 0.354163525420490510f, -0.935183509938947500f, 0.351292756085567150f, -0.936265667170278260f, - 0.348418680249434510f, -0.937339011912574960f, 0.345541324963989150f, -0.938403534063108060f, - 0.342660717311994380f, -0.939459223602189920f, 0.339776884406826960f, -0.940506070593268300f, - 0.336889853392220050f, -0.941544065183020810f, 0.333999651442009490f, -0.942573197601446870f, - 0.331106305759876430f, -0.943593458161960390f, 0.328209843579092660f, -0.944604837261480260f, - 0.325310292162262980f, -0.945607325380521280f, 0.322407678801070020f, -0.946600913083283530f, - 0.319502030816015750f, -0.947585591017741090f, 0.316593375556165850f, -0.948561349915730270f, - 0.313681740398891570f, -0.949528180593036670f, 0.310767152749611470f, -0.950486073949481700f, - 0.307849640041534980f, -0.951435020969008340f, 0.304929229735402430f, -0.952375012719765880f, - 0.302005949319228200f, -0.953306040354193750f, 0.299079826308040480f, -0.954228095109105670f, - 0.296150888243623960f, -0.955141168305770670f, 0.293219162694258680f, -0.956045251349996410f, - 0.290284677254462330f, -0.956940335732208940f, 0.287347459544729570f, -0.957826413027532910f, - 0.284407537211271820f, -0.958703474895871600f, 0.281464937925758050f, -0.959571513081984520f, - 0.278519689385053060f, -0.960430519415565790f, 0.275571819310958250f, -0.961280485811320640f, - 0.272621355449948980f, -0.962121404269041580f, 0.269668325572915200f, -0.962953266873683880f, - 0.266712757474898420f, -0.963776065795439840f, 0.263754678974831510f, -0.964589793289812650f, - 0.260794117915275570f, -0.965394441697689400f, 0.257831102162158930f, -0.966190003445412620f, - 0.254865659604514630f, -0.966976471044852070f, 0.251897818154216910f, -0.967753837093475510f, - 0.248927605745720260f, -0.968522094274417270f, 0.245955050335794590f, -0.969281235356548530f, - 0.242980179903263980f, -0.970031253194543970f, 0.240003022448741500f, -0.970772140728950350f, - 0.237023605994367340f, -0.971503890986251780f, 0.234041958583543460f, -0.972226497078936270f, - 0.231058108280671280f, -0.972939952205560070f, 0.228072083170885790f, -0.973644249650811870f, - 0.225083911359792780f, -0.974339382785575860f, 0.222093620973203590f, -0.975025345066994120f, - 0.219101240156869770f, -0.975702130038528570f, 0.216106797076219600f, -0.976369731330021140f, - 0.213110319916091360f, -0.977028142657754390f, 0.210111836880469720f, -0.977677357824509930f, - 0.207111376192218560f, -0.978317370719627650f, 0.204108966092817010f, -0.978948175319062200f, - 0.201104634842091960f, -0.979569765685440520f, 0.198098410717953730f, -0.980182135968117320f, - 0.195090322016128330f, -0.980785280403230430f, 0.192080397049892380f, -0.981379193313754560f, - 0.189068664149806280f, -0.981963869109555240f, 0.186055151663446630f, -0.982539302287441240f, - 0.183039887955141060f, -0.983105487431216290f, 0.180022901405699510f, -0.983662419211730250f, - 0.177004220412148860f, -0.984210092386929030f, 0.173983873387463850f, -0.984748501801904210f, - 0.170961888760301360f, -0.985277642388941220f, 0.167938294974731230f, -0.985797509167567370f, - 0.164913120489970090f, -0.986308097244598670f, 0.161886393780111910f, -0.986809401814185420f, - 0.158858143333861390f, -0.987301418157858430f, 0.155828397654265320f, -0.987784141644572180f, - 0.152797185258443410f, -0.988257567730749460f, 0.149764534677321620f, -0.988721691960323780f, - 0.146730474455361750f, -0.989176509964781010f, 0.143695033150294580f, -0.989622017463200780f, - 0.140658239332849240f, -0.990058210262297120f, 0.137620121586486180f, -0.990485084256456980f, - 0.134580708507126220f, -0.990902635427780010f, 0.131540028702883280f, -0.991310859846115440f, - 0.128498110793793220f, -0.991709753669099530f, 0.125454983411546210f, -0.992099313142191800f, - 0.122410675199216280f, -0.992479534598709970f, 0.119365214810991350f, -0.992850414459865100f, - 0.116318630911904880f, -0.993211949234794500f, 0.113270952177564360f, -0.993564135520595300f, - 0.110222207293883180f, -0.993906970002356060f, 0.107172424956808870f, -0.994240449453187900f, - 0.104121633872054730f, -0.994564570734255420f, 0.101069862754827880f, -0.994879330794805620f, - 0.098017140329560770f, -0.995184726672196820f, 0.094963495329639061f, -0.995480755491926940f, - 0.091908956497132696f, -0.995767414467659820f, 0.088853552582524684f, -0.996044700901251970f, - 0.085797312344439880f, -0.996312612182778000f, 0.082740264549375803f, -0.996571145790554840f, - 0.079682437971430126f, -0.996820299291165670f, 0.076623861392031617f, -0.997060070339482960f, - 0.073564563599667454f, -0.997290456678690210f, 0.070504573389614009f, -0.997511456140303450f, - 0.067443919563664106f, -0.997723066644191640f, 0.064382630929857410f, -0.997925286198596000f, - 0.061320736302208648f, -0.998118112900149180f, 0.058258264500435732f, -0.998301544933892890f, - 0.055195244349690031f, -0.998475580573294770f, 0.052131704680283317f, -0.998640218180265270f, - 0.049067674327418126f, -0.998795456205172410f, 0.046003182130914644f, -0.998941293186856870f, - 0.042938256934940959f, -0.999077727752645360f, 0.039872927587739845f, -0.999204758618363890f, - 0.036807222941358991f, -0.999322384588349540f, 0.033741171851377642f, -0.999430604555461730f, - 0.030674803176636581f, -0.999529417501093140f, 0.027608145778965820f, -0.999618822495178640f, - 0.024541228522912264f, -0.999698818696204250f, 0.021474080275469605f, -0.999769405351215280f, - 0.018406729905804820f, -0.999830581795823400f, 0.015339206284988220f, -0.999882347454212560f, - 0.012271538285719944f, -0.999924701839144500f, 0.009203754782059960f, -0.999957644551963900f, - 0.006135884649154515f, -0.999981175282601110f, 0.003067956762966138f, -0.999995293809576190f -}; + 1.000000000000000000f, 0.000000000000000000f, 0.999995293809576190f, + -0.003067956762965976f, 0.999981175282601110f, -0.006135884649154475f, + 0.999957644551963900f, -0.009203754782059819f, 0.999924701839144500f, + -0.012271538285719925f, 0.999882347454212560f, -0.015339206284988100f, + 0.999830581795823400f, -0.018406729905804820f, 0.999769405351215280f, + -0.021474080275469508f, 0.999698818696204250f, -0.024541228522912288f, + 0.999618822495178640f, -0.027608145778965740f, 0.999529417501093140f, + -0.030674803176636626f, 0.999430604555461730f, -0.033741171851377580f, + 0.999322384588349540f, -0.036807222941358832f, 0.999204758618363890f, + -0.039872927587739811f, 0.999077727752645360f, -0.042938256934940820f, + 0.998941293186856870f, -0.046003182130914623f, 0.998795456205172410f, + -0.049067674327418015f, 0.998640218180265270f, -0.052131704680283324f, + 0.998475580573294770f, -0.055195244349689934f, 0.998301544933892890f, + -0.058258264500435752f, 0.998118112900149180f, -0.061320736302208578f, + 0.997925286198596000f, -0.064382630929857465f, 0.997723066644191640f, + -0.067443919563664051f, 0.997511456140303450f, -0.070504573389613856f, + 0.997290456678690210f, -0.073564563599667426f, 0.997060070339482960f, + -0.076623861392031492f, 0.996820299291165670f, -0.079682437971430126f, + 0.996571145790554840f, -0.082740264549375692f, 0.996312612182778000f, + -0.085797312344439894f, 0.996044700901251970f, -0.088853552582524600f, + 0.995767414467659820f, -0.091908956497132724f, 0.995480755491926940f, + -0.094963495329638992f, 0.995184726672196930f, -0.098017140329560604f, + 0.994879330794805620f, -0.101069862754827820f, 0.994564570734255420f, + -0.104121633872054590f, 0.994240449453187900f, -0.107172424956808840f, + 0.993906970002356060f, -0.110222207293883060f, 0.993564135520595300f, + -0.113270952177564350f, 0.993211949234794500f, -0.116318630911904750f, + 0.992850414459865100f, -0.119365214810991350f, 0.992479534598709970f, + -0.122410675199216200f, 0.992099313142191800f, -0.125454983411546230f, + 0.991709753669099530f, -0.128498110793793170f, 0.991310859846115440f, + -0.131540028702883120f, 0.990902635427780010f, -0.134580708507126170f, + 0.990485084256457090f, -0.137620121586486040f, 0.990058210262297120f, + -0.140658239332849210f, 0.989622017463200890f, -0.143695033150294470f, + 0.989176509964781010f, -0.146730474455361750f, 0.988721691960323780f, + -0.149764534677321510f, 0.988257567730749460f, -0.152797185258443440f, + 0.987784141644572180f, -0.155828397654265230f, 0.987301418157858430f, + -0.158858143333861450f, 0.986809401814185530f, -0.161886393780111830f, + 0.986308097244598670f, -0.164913120489969890f, 0.985797509167567480f, + -0.167938294974731170f, 0.985277642388941220f, -0.170961888760301220f, + 0.984748501801904210f, -0.173983873387463820f, 0.984210092386929030f, + -0.177004220412148750f, 0.983662419211730250f, -0.180022901405699510f, + 0.983105487431216290f, -0.183039887955140950f, 0.982539302287441240f, + -0.186055151663446630f, 0.981963869109555240f, -0.189068664149806190f, + 0.981379193313754560f, -0.192080397049892440f, 0.980785280403230430f, + -0.195090322016128250f, 0.980182135968117430f, -0.198098410717953560f, + 0.979569765685440520f, -0.201104634842091900f, 0.978948175319062200f, + -0.204108966092816870f, 0.978317370719627650f, -0.207111376192218560f, + 0.977677357824509930f, -0.210111836880469610f, 0.977028142657754390f, + -0.213110319916091360f, 0.976369731330021140f, -0.216106797076219520f, + 0.975702130038528570f, -0.219101240156869800f, 0.975025345066994120f, + -0.222093620973203510f, 0.974339382785575860f, -0.225083911359792830f, + 0.973644249650811980f, -0.228072083170885730f, 0.972939952205560180f, + -0.231058108280671110f, 0.972226497078936270f, -0.234041958583543430f, + 0.971503890986251780f, -0.237023605994367200f, 0.970772140728950350f, + -0.240003022448741500f, 0.970031253194543970f, -0.242980179903263870f, + 0.969281235356548530f, -0.245955050335794590f, 0.968522094274417380f, + -0.248927605745720150f, 0.967753837093475510f, -0.251897818154216970f, + 0.966976471044852070f, -0.254865659604514570f, 0.966190003445412500f, + -0.257831102162158990f, 0.965394441697689400f, -0.260794117915275510f, + 0.964589793289812760f, -0.263754678974831350f, 0.963776065795439840f, + -0.266712757474898370f, 0.962953266873683880f, -0.269668325572915090f, + 0.962121404269041580f, -0.272621355449948980f, 0.961280485811320640f, + -0.275571819310958140f, 0.960430519415565790f, -0.278519689385053060f, + 0.959571513081984520f, -0.281464937925757940f, 0.958703474895871600f, + -0.284407537211271880f, 0.957826413027532910f, -0.287347459544729510f, + 0.956940335732208820f, -0.290284677254462330f, 0.956045251349996410f, + -0.293219162694258630f, 0.955141168305770780f, -0.296150888243623790f, + 0.954228095109105670f, -0.299079826308040480f, 0.953306040354193860f, + -0.302005949319228080f, 0.952375012719765880f, -0.304929229735402370f, + 0.951435020969008340f, -0.307849640041534870f, 0.950486073949481700f, + -0.310767152749611470f, 0.949528180593036670f, -0.313681740398891520f, + 0.948561349915730270f, -0.316593375556165850f, 0.947585591017741090f, + -0.319502030816015690f, 0.946600913083283530f, -0.322407678801069850f, + 0.945607325380521280f, -0.325310292162262930f, 0.944604837261480260f, + -0.328209843579092500f, 0.943593458161960390f, -0.331106305759876430f, + 0.942573197601446870f, -0.333999651442009380f, 0.941544065183020810f, + -0.336889853392220050f, 0.940506070593268300f, -0.339776884406826850f, + 0.939459223602189920f, -0.342660717311994380f, 0.938403534063108060f, + -0.345541324963989090f, 0.937339011912574960f, -0.348418680249434560f, + 0.936265667170278260f, -0.351292756085567090f, 0.935183509938947610f, + -0.354163525420490340f, 0.934092550404258980f, -0.357030961233429980f, + 0.932992798834738960f, -0.359895036534988110f, 0.931884265581668150f, + -0.362755724367397230f, 0.930766961078983710f, -0.365612997804773850f, + 0.929640895843181330f, -0.368466829953372320f, 0.928506080473215590f, + -0.371317193951837540f, 0.927362525650401110f, -0.374164062971457930f, + 0.926210242138311380f, -0.377007410216418260f, 0.925049240782677580f, + -0.379847208924051160f, 0.923879532511286740f, -0.382683432365089780f, + 0.922701128333878630f, -0.385516053843918850f, 0.921514039342042010f, + -0.388345046698826250f, 0.920318276709110590f, -0.391170384302253870f, + 0.919113851690057770f, -0.393992040061048100f, 0.917900775621390500f, + -0.396809987416710310f, 0.916679059921042700f, -0.399624199845646790f, + 0.915448716088267830f, -0.402434650859418430f, 0.914209755703530690f, + -0.405241314004989860f, 0.912962190428398210f, -0.408044162864978690f, + 0.911706032005429880f, -0.410843171057903910f, 0.910441292258067250f, + -0.413638312238434500f, 0.909167983090522380f, -0.416429560097637150f, + 0.907886116487666260f, -0.419216888363223910f, 0.906595704514915330f, + -0.422000270799799680f, 0.905296759318118820f, -0.424779681209108810f, + 0.903989293123443340f, -0.427555093430282080f, 0.902673318237258830f, + -0.430326481340082610f, 0.901348847046022030f, -0.433093818853151960f, + 0.900015892016160280f, -0.435857079922255470f, 0.898674465693953820f, + -0.438616238538527660f, 0.897324580705418320f, -0.441371268731716670f, + 0.895966249756185220f, -0.444122144570429200f, 0.894599485631382700f, + -0.446868840162374160f, 0.893224301195515320f, -0.449611329654606540f, + 0.891840709392342720f, -0.452349587233770890f, 0.890448723244757880f, + -0.455083587126343840f, 0.889048355854664570f, -0.457813303598877170f, + 0.887639620402853930f, -0.460538710958240010f, 0.886222530148880640f, + -0.463259783551860150f, 0.884797098430937790f, -0.465976495767966180f, + 0.883363338665731580f, -0.468688822035827900f, 0.881921264348355050f, + -0.471396736825997640f, 0.880470889052160750f, -0.474100214650549970f, + 0.879012226428633530f, -0.476799230063322090f, 0.877545290207261350f, + -0.479493757660153010f, 0.876070094195406600f, -0.482183772079122720f, + 0.874586652278176110f, -0.484869248000791060f, 0.873094978418290090f, + -0.487550160148436000f, 0.871595086655950980f, -0.490226483288291160f, + 0.870086991108711460f, -0.492898192229784040f, 0.868570705971340900f, + -0.495565261825772540f, 0.867046245515692650f, -0.498227666972781870f, + 0.865513624090569090f, -0.500885382611240710f, 0.863972856121586810f, + -0.503538383725717580f, 0.862423956111040610f, -0.506186645345155230f, + 0.860866938637767310f, -0.508830142543106990f, 0.859301818357008470f, + -0.511468850437970300f, 0.857728610000272120f, -0.514102744193221660f, + 0.856147328375194470f, -0.516731799017649870f, 0.854557988365400530f, + -0.519355990165589640f, 0.852960604930363630f, -0.521975292937154390f, + 0.851355193105265200f, -0.524589682678468950f, 0.849741768000852550f, + -0.527199134781901280f, 0.848120344803297230f, -0.529803624686294610f, + 0.846490938774052130f, -0.532403127877197900f, 0.844853565249707120f, + -0.534997619887097150f, 0.843208239641845440f, -0.537587076295645390f, + 0.841554977436898440f, -0.540171472729892850f, 0.839893794195999520f, + -0.542750784864515890f, 0.838224705554838080f, -0.545324988422046460f, + 0.836547727223512010f, -0.547894059173100190f, 0.834862874986380010f, + -0.550457972936604810f, 0.833170164701913190f, -0.553016705580027470f, + 0.831469612302545240f, -0.555570233019602180f, 0.829761233794523050f, + -0.558118531220556100f, 0.828045045257755800f, -0.560661576197336030f, + 0.826321062845663530f, -0.563199344013834090f, 0.824589302785025290f, + -0.565731810783613120f, 0.822849781375826430f, -0.568258952670131490f, + 0.821102514991104650f, -0.570780745886967260f, 0.819347520076796900f, + -0.573297166698042200f, 0.817584813151583710f, -0.575808191417845340f, + 0.815814410806733780f, -0.578313796411655590f, 0.814036329705948410f, + -0.580813958095764530f, 0.812250586585203880f, -0.583308652937698290f, + 0.810457198252594770f, -0.585797857456438860f, 0.808656181588174980f, + -0.588281548222645220f, 0.806847553543799330f, -0.590759701858874160f, + 0.805031331142963660f, -0.593232295039799800f, 0.803207531480644940f, + -0.595699304492433360f, 0.801376171723140240f, -0.598160706996342270f, + 0.799537269107905010f, -0.600616479383868970f, 0.797690840943391160f, + -0.603066598540348160f, 0.795836904608883570f, -0.605511041404325550f, + 0.793975477554337170f, -0.607949784967773630f, 0.792106577300212390f, + -0.610382806276309480f, 0.790230221437310030f, -0.612810082429409710f, + 0.788346427626606340f, -0.615231590580626820f, 0.786455213599085770f, + -0.617647307937803870f, 0.784556597155575240f, -0.620057211763289100f, + 0.782650596166575730f, -0.622461279374149970f, 0.780737228572094490f, + -0.624859488142386340f, 0.778816512381475980f, -0.627251815495144080f, + 0.776888465673232440f, -0.629638238914926980f, 0.774953106594873930f, + -0.632018735939809060f, 0.773010453362736990f, -0.634393284163645490f, + 0.771060524261813820f, -0.636761861236284200f, 0.769103337645579700f, + -0.639124444863775730f, 0.767138911935820400f, -0.641481012808583160f, + 0.765167265622458960f, -0.643831542889791390f, 0.763188417263381270f, + -0.646176012983316280f, 0.761202385484261780f, -0.648514401022112440f, + 0.759209188978388070f, -0.650846684996380880f, 0.757208846506484570f, + -0.653172842953776760f, 0.755201376896536550f, -0.655492852999615350f, + 0.753186799043612520f, -0.657806693297078640f, 0.751165131909686480f, + -0.660114342067420480f, 0.749136394523459370f, -0.662415777590171780f, + 0.747100605980180130f, -0.664710978203344790f, 0.745057785441466060f, + -0.666999922303637470f, 0.743007952135121720f, -0.669282588346636010f, + 0.740951125354959110f, -0.671558954847018330f, 0.738887324460615110f, + -0.673829000378756040f, 0.736816568877369900f, -0.676092703575315920f, + 0.734738878095963500f, -0.678350043129861470f, 0.732654271672412820f, + -0.680600997795453020f, 0.730562769227827590f, -0.682845546385248080f, + 0.728464390448225200f, -0.685083667772700360f, 0.726359155084346010f, + -0.687315340891759050f, 0.724247082951467000f, -0.689540544737066830f, + 0.722128193929215350f, -0.691759258364157750f, 0.720002507961381650f, + -0.693971460889654000f, 0.717870045055731710f, -0.696177131491462990f, + 0.715730825283818590f, -0.698376249408972920f, 0.713584868780793640f, + -0.700568793943248340f, 0.711432195745216430f, -0.702754744457225300f, + 0.709272826438865690f, -0.704934080375904880f, 0.707106781186547570f, + -0.707106781186547460f, 0.704934080375904990f, -0.709272826438865580f, + 0.702754744457225300f, -0.711432195745216430f, 0.700568793943248450f, + -0.713584868780793520f, 0.698376249408972920f, -0.715730825283818590f, + 0.696177131491462990f, -0.717870045055731710f, 0.693971460889654000f, + -0.720002507961381650f, 0.691759258364157750f, -0.722128193929215350f, + 0.689540544737066940f, -0.724247082951466890f, 0.687315340891759160f, + -0.726359155084346010f, 0.685083667772700360f, -0.728464390448225200f, + 0.682845546385248080f, -0.730562769227827590f, 0.680600997795453130f, + -0.732654271672412820f, 0.678350043129861580f, -0.734738878095963390f, + 0.676092703575316030f, -0.736816568877369790f, 0.673829000378756150f, + -0.738887324460615110f, 0.671558954847018330f, -0.740951125354959110f, + 0.669282588346636010f, -0.743007952135121720f, 0.666999922303637470f, + -0.745057785441465950f, 0.664710978203344900f, -0.747100605980180130f, + 0.662415777590171780f, -0.749136394523459260f, 0.660114342067420480f, + -0.751165131909686370f, 0.657806693297078640f, -0.753186799043612410f, + 0.655492852999615460f, -0.755201376896536550f, 0.653172842953776760f, + -0.757208846506484460f, 0.650846684996380990f, -0.759209188978387960f, + 0.648514401022112550f, -0.761202385484261780f, 0.646176012983316390f, + -0.763188417263381270f, 0.643831542889791500f, -0.765167265622458960f, + 0.641481012808583160f, -0.767138911935820400f, 0.639124444863775730f, + -0.769103337645579590f, 0.636761861236284200f, -0.771060524261813710f, + 0.634393284163645490f, -0.773010453362736990f, 0.632018735939809060f, + -0.774953106594873820f, 0.629638238914927100f, -0.776888465673232440f, + 0.627251815495144190f, -0.778816512381475870f, 0.624859488142386450f, + -0.780737228572094380f, 0.622461279374150080f, -0.782650596166575730f, + 0.620057211763289210f, -0.784556597155575240f, 0.617647307937803980f, + -0.786455213599085770f, 0.615231590580626820f, -0.788346427626606230f, + 0.612810082429409710f, -0.790230221437310030f, 0.610382806276309480f, + -0.792106577300212390f, 0.607949784967773740f, -0.793975477554337170f, + 0.605511041404325550f, -0.795836904608883460f, 0.603066598540348280f, + -0.797690840943391040f, 0.600616479383868970f, -0.799537269107905010f, + 0.598160706996342380f, -0.801376171723140130f, 0.595699304492433470f, + -0.803207531480644830f, 0.593232295039799800f, -0.805031331142963660f, + 0.590759701858874280f, -0.806847553543799220f, 0.588281548222645330f, + -0.808656181588174980f, 0.585797857456438860f, -0.810457198252594770f, + 0.583308652937698290f, -0.812250586585203880f, 0.580813958095764530f, + -0.814036329705948300f, 0.578313796411655590f, -0.815814410806733780f, + 0.575808191417845340f, -0.817584813151583710f, 0.573297166698042320f, + -0.819347520076796900f, 0.570780745886967370f, -0.821102514991104650f, + 0.568258952670131490f, -0.822849781375826320f, 0.565731810783613230f, + -0.824589302785025290f, 0.563199344013834090f, -0.826321062845663420f, + 0.560661576197336030f, -0.828045045257755800f, 0.558118531220556100f, + -0.829761233794523050f, 0.555570233019602290f, -0.831469612302545240f, + 0.553016705580027580f, -0.833170164701913190f, 0.550457972936604810f, + -0.834862874986380010f, 0.547894059173100190f, -0.836547727223511890f, + 0.545324988422046460f, -0.838224705554837970f, 0.542750784864516000f, + -0.839893794195999410f, 0.540171472729892970f, -0.841554977436898330f, + 0.537587076295645510f, -0.843208239641845440f, 0.534997619887097260f, + -0.844853565249707010f, 0.532403127877198010f, -0.846490938774052020f, + 0.529803624686294830f, -0.848120344803297120f, 0.527199134781901390f, + -0.849741768000852440f, 0.524589682678468840f, -0.851355193105265200f, + 0.521975292937154390f, -0.852960604930363630f, 0.519355990165589530f, + -0.854557988365400530f, 0.516731799017649980f, -0.856147328375194470f, + 0.514102744193221660f, -0.857728610000272120f, 0.511468850437970520f, + -0.859301818357008360f, 0.508830142543106990f, -0.860866938637767310f, + 0.506186645345155450f, -0.862423956111040500f, 0.503538383725717580f, + -0.863972856121586700f, 0.500885382611240940f, -0.865513624090568980f, + 0.498227666972781870f, -0.867046245515692650f, 0.495565261825772490f, + -0.868570705971340900f, 0.492898192229784090f, -0.870086991108711350f, + 0.490226483288291100f, -0.871595086655951090f, 0.487550160148436050f, + -0.873094978418290090f, 0.484869248000791120f, -0.874586652278176110f, + 0.482183772079122830f, -0.876070094195406600f, 0.479493757660153010f, + -0.877545290207261240f, 0.476799230063322250f, -0.879012226428633410f, + 0.474100214650550020f, -0.880470889052160750f, 0.471396736825997810f, + -0.881921264348354940f, 0.468688822035827960f, -0.883363338665731580f, + 0.465976495767966130f, -0.884797098430937790f, 0.463259783551860260f, + -0.886222530148880640f, 0.460538710958240010f, -0.887639620402853930f, + 0.457813303598877290f, -0.889048355854664570f, 0.455083587126343840f, + -0.890448723244757880f, 0.452349587233771000f, -0.891840709392342720f, + 0.449611329654606600f, -0.893224301195515320f, 0.446868840162374330f, + -0.894599485631382580f, 0.444122144570429260f, -0.895966249756185110f, + 0.441371268731716620f, -0.897324580705418320f, 0.438616238538527710f, + -0.898674465693953820f, 0.435857079922255470f, -0.900015892016160280f, + 0.433093818853152010f, -0.901348847046022030f, 0.430326481340082610f, + -0.902673318237258830f, 0.427555093430282200f, -0.903989293123443340f, + 0.424779681209108810f, -0.905296759318118820f, 0.422000270799799790f, + -0.906595704514915330f, 0.419216888363223960f, -0.907886116487666150f, + 0.416429560097637320f, -0.909167983090522270f, 0.413638312238434560f, + -0.910441292258067140f, 0.410843171057903910f, -0.911706032005429880f, + 0.408044162864978740f, -0.912962190428398100f, 0.405241314004989860f, + -0.914209755703530690f, 0.402434650859418540f, -0.915448716088267830f, + 0.399624199845646790f, -0.916679059921042700f, 0.396809987416710420f, + -0.917900775621390390f, 0.393992040061048100f, -0.919113851690057770f, + 0.391170384302253980f, -0.920318276709110480f, 0.388345046698826300f, + -0.921514039342041900f, 0.385516053843919020f, -0.922701128333878520f, + 0.382683432365089840f, -0.923879532511286740f, 0.379847208924051110f, + -0.925049240782677580f, 0.377007410216418310f, -0.926210242138311270f, + 0.374164062971457990f, -0.927362525650401110f, 0.371317193951837600f, + -0.928506080473215480f, 0.368466829953372320f, -0.929640895843181330f, + 0.365612997804773960f, -0.930766961078983710f, 0.362755724367397230f, + -0.931884265581668150f, 0.359895036534988280f, -0.932992798834738850f, + 0.357030961233430030f, -0.934092550404258870f, 0.354163525420490510f, + -0.935183509938947500f, 0.351292756085567150f, -0.936265667170278260f, + 0.348418680249434510f, -0.937339011912574960f, 0.345541324963989150f, + -0.938403534063108060f, 0.342660717311994380f, -0.939459223602189920f, + 0.339776884406826960f, -0.940506070593268300f, 0.336889853392220050f, + -0.941544065183020810f, 0.333999651442009490f, -0.942573197601446870f, + 0.331106305759876430f, -0.943593458161960390f, 0.328209843579092660f, + -0.944604837261480260f, 0.325310292162262980f, -0.945607325380521280f, + 0.322407678801070020f, -0.946600913083283530f, 0.319502030816015750f, + -0.947585591017741090f, 0.316593375556165850f, -0.948561349915730270f, + 0.313681740398891570f, -0.949528180593036670f, 0.310767152749611470f, + -0.950486073949481700f, 0.307849640041534980f, -0.951435020969008340f, + 0.304929229735402430f, -0.952375012719765880f, 0.302005949319228200f, + -0.953306040354193750f, 0.299079826308040480f, -0.954228095109105670f, + 0.296150888243623960f, -0.955141168305770670f, 0.293219162694258680f, + -0.956045251349996410f, 0.290284677254462330f, -0.956940335732208940f, + 0.287347459544729570f, -0.957826413027532910f, 0.284407537211271820f, + -0.958703474895871600f, 0.281464937925758050f, -0.959571513081984520f, + 0.278519689385053060f, -0.960430519415565790f, 0.275571819310958250f, + -0.961280485811320640f, 0.272621355449948980f, -0.962121404269041580f, + 0.269668325572915200f, -0.962953266873683880f, 0.266712757474898420f, + -0.963776065795439840f, 0.263754678974831510f, -0.964589793289812650f, + 0.260794117915275570f, -0.965394441697689400f, 0.257831102162158930f, + -0.966190003445412620f, 0.254865659604514630f, -0.966976471044852070f, + 0.251897818154216910f, -0.967753837093475510f, 0.248927605745720260f, + -0.968522094274417270f, 0.245955050335794590f, -0.969281235356548530f, + 0.242980179903263980f, -0.970031253194543970f, 0.240003022448741500f, + -0.970772140728950350f, 0.237023605994367340f, -0.971503890986251780f, + 0.234041958583543460f, -0.972226497078936270f, 0.231058108280671280f, + -0.972939952205560070f, 0.228072083170885790f, -0.973644249650811870f, + 0.225083911359792780f, -0.974339382785575860f, 0.222093620973203590f, + -0.975025345066994120f, 0.219101240156869770f, -0.975702130038528570f, + 0.216106797076219600f, -0.976369731330021140f, 0.213110319916091360f, + -0.977028142657754390f, 0.210111836880469720f, -0.977677357824509930f, + 0.207111376192218560f, -0.978317370719627650f, 0.204108966092817010f, + -0.978948175319062200f, 0.201104634842091960f, -0.979569765685440520f, + 0.198098410717953730f, -0.980182135968117320f, 0.195090322016128330f, + -0.980785280403230430f, 0.192080397049892380f, -0.981379193313754560f, + 0.189068664149806280f, -0.981963869109555240f, 0.186055151663446630f, + -0.982539302287441240f, 0.183039887955141060f, -0.983105487431216290f, + 0.180022901405699510f, -0.983662419211730250f, 0.177004220412148860f, + -0.984210092386929030f, 0.173983873387463850f, -0.984748501801904210f, + 0.170961888760301360f, -0.985277642388941220f, 0.167938294974731230f, + -0.985797509167567370f, 0.164913120489970090f, -0.986308097244598670f, + 0.161886393780111910f, -0.986809401814185420f, 0.158858143333861390f, + -0.987301418157858430f, 0.155828397654265320f, -0.987784141644572180f, + 0.152797185258443410f, -0.988257567730749460f, 0.149764534677321620f, + -0.988721691960323780f, 0.146730474455361750f, -0.989176509964781010f, + 0.143695033150294580f, -0.989622017463200780f, 0.140658239332849240f, + -0.990058210262297120f, 0.137620121586486180f, -0.990485084256456980f, + 0.134580708507126220f, -0.990902635427780010f, 0.131540028702883280f, + -0.991310859846115440f, 0.128498110793793220f, -0.991709753669099530f, + 0.125454983411546210f, -0.992099313142191800f, 0.122410675199216280f, + -0.992479534598709970f, 0.119365214810991350f, -0.992850414459865100f, + 0.116318630911904880f, -0.993211949234794500f, 0.113270952177564360f, + -0.993564135520595300f, 0.110222207293883180f, -0.993906970002356060f, + 0.107172424956808870f, -0.994240449453187900f, 0.104121633872054730f, + -0.994564570734255420f, 0.101069862754827880f, -0.994879330794805620f, + 0.098017140329560770f, -0.995184726672196820f, 0.094963495329639061f, + -0.995480755491926940f, 0.091908956497132696f, -0.995767414467659820f, + 0.088853552582524684f, -0.996044700901251970f, 0.085797312344439880f, + -0.996312612182778000f, 0.082740264549375803f, -0.996571145790554840f, + 0.079682437971430126f, -0.996820299291165670f, 0.076623861392031617f, + -0.997060070339482960f, 0.073564563599667454f, -0.997290456678690210f, + 0.070504573389614009f, -0.997511456140303450f, 0.067443919563664106f, + -0.997723066644191640f, 0.064382630929857410f, -0.997925286198596000f, + 0.061320736302208648f, -0.998118112900149180f, 0.058258264500435732f, + -0.998301544933892890f, 0.055195244349690031f, -0.998475580573294770f, + 0.052131704680283317f, -0.998640218180265270f, 0.049067674327418126f, + -0.998795456205172410f, 0.046003182130914644f, -0.998941293186856870f, + 0.042938256934940959f, -0.999077727752645360f, 0.039872927587739845f, + -0.999204758618363890f, 0.036807222941358991f, -0.999322384588349540f, + 0.033741171851377642f, -0.999430604555461730f, 0.030674803176636581f, + -0.999529417501093140f, 0.027608145778965820f, -0.999618822495178640f, + 0.024541228522912264f, -0.999698818696204250f, 0.021474080275469605f, + -0.999769405351215280f, 0.018406729905804820f, -0.999830581795823400f, + 0.015339206284988220f, -0.999882347454212560f, 0.012271538285719944f, + -0.999924701839144500f, 0.009203754782059960f, -0.999957644551963900f, + 0.006135884649154515f, -0.999981175282601110f, 0.003067956762966138f, + -0.999995293809576190f}; static const float32_t Weights_2048[4096] = { - 1.000000000000000000f, 0.000000000000000000f, 0.999999705862882230f, -0.000766990318742704f, - 0.999998823451701880f, -0.001533980186284766f, 0.999997352766978210f, -0.002300969151425805f, - 0.999995293809576190f, -0.003067956762965976f, 0.999992646580707190f, -0.003834942569706228f, - 0.999989411081928400f, -0.004601926120448571f, 0.999985587315143200f, -0.005368906963996343f, - 0.999981175282601110f, -0.006135884649154475f, 0.999976174986897610f, -0.006902858724729756f, - 0.999970586430974140f, -0.007669828739531097f, 0.999964409618118280f, -0.008436794242369799f, - 0.999957644551963900f, -0.009203754782059819f, 0.999950291236490480f, -0.009970709907418031f, - 0.999942349676023910f, -0.010737659167264491f, 0.999933819875236000f, -0.011504602110422714f, - 0.999924701839144500f, -0.012271538285719925f, 0.999914995573113470f, -0.013038467241987334f, - 0.999904701082852900f, -0.013805388528060391f, 0.999893818374418490f, -0.014572301692779064f, - 0.999882347454212560f, -0.015339206284988100f, 0.999870288328982950f, -0.016106101853537287f, - 0.999857641005823860f, -0.016872987947281710f, 0.999844405492175240f, -0.017639864115082053f, - 0.999830581795823400f, -0.018406729905804820f, 0.999816169924900410f, -0.019173584868322623f, - 0.999801169887884260f, -0.019940428551514441f, 0.999785581693599210f, -0.020707260504265895f, - 0.999769405351215280f, -0.021474080275469508f, 0.999752640870248840f, -0.022240887414024961f, - 0.999735288260561680f, -0.023007681468839369f, 0.999717347532362190f, -0.023774461988827555f, - 0.999698818696204250f, -0.024541228522912288f, 0.999679701762987930f, -0.025307980620024571f, - 0.999659996743959220f, -0.026074717829103901f, 0.999639703650710200f, -0.026841439699098531f, - 0.999618822495178640f, -0.027608145778965740f, 0.999597353289648380f, -0.028374835617672099f, - 0.999575296046749220f, -0.029141508764193722f, 0.999552650779456990f, -0.029908164767516555f, - 0.999529417501093140f, -0.030674803176636626f, 0.999505596225325310f, -0.031441423540560301f, - 0.999481186966166950f, -0.032208025408304586f, 0.999456189737977340f, -0.032974608328897335f, - 0.999430604555461730f, -0.033741171851377580f, 0.999404431433671300f, -0.034507715524795750f, - 0.999377670388002850f, -0.035274238898213947f, 0.999350321434199440f, -0.036040741520706229f, - 0.999322384588349540f, -0.036807222941358832f, 0.999293859866887790f, -0.037573682709270494f, - 0.999264747286594420f, -0.038340120373552694f, 0.999235046864595850f, -0.039106535483329888f, - 0.999204758618363890f, -0.039872927587739811f, 0.999173882565716380f, -0.040639296235933736f, - 0.999142418724816910f, -0.041405640977076739f, 0.999110367114174890f, -0.042171961360347947f, - 0.999077727752645360f, -0.042938256934940820f, 0.999044500659429290f, -0.043704527250063421f, - 0.999010685854073380f, -0.044470771854938668f, 0.998976283356469820f, -0.045236990298804590f, - 0.998941293186856870f, -0.046003182130914623f, 0.998905715365818290f, -0.046769346900537863f, - 0.998869549914283560f, -0.047535484156959303f, 0.998832796853527990f, -0.048301593449480144f, - 0.998795456205172410f, -0.049067674327418015f, 0.998757527991183340f, -0.049833726340107277f, - 0.998719012233872940f, -0.050599749036899282f, 0.998679908955899090f, -0.051365741967162593f, - 0.998640218180265270f, -0.052131704680283324f, 0.998599939930320370f, -0.052897636725665324f, - 0.998559074229759310f, -0.053663537652730520f, 0.998517621102622210f, -0.054429407010919133f, - 0.998475580573294770f, -0.055195244349689934f, 0.998432952666508440f, -0.055961049218520569f, - 0.998389737407340160f, -0.056726821166907748f, 0.998345934821212370f, -0.057492559744367566f, - 0.998301544933892890f, -0.058258264500435752f, 0.998256567771495180f, -0.059023934984667931f, - 0.998211003360478190f, -0.059789570746639868f, 0.998164851727646240f, -0.060555171335947788f, - 0.998118112900149180f, -0.061320736302208578f, 0.998070786905482340f, -0.062086265195060088f, - 0.998022873771486240f, -0.062851757564161406f, 0.997974373526346990f, -0.063617212959193106f, - 0.997925286198596000f, -0.064382630929857465f, 0.997875611817110150f, -0.065148011025878833f, - 0.997825350411111640f, -0.065913352797003805f, 0.997774502010167820f, -0.066678655793001557f, - 0.997723066644191640f, -0.067443919563664051f, 0.997671044343441000f, -0.068209143658806329f, - 0.997618435138519550f, -0.068974327628266746f, 0.997565239060375750f, -0.069739471021907307f, - 0.997511456140303450f, -0.070504573389613856f, 0.997457086409941910f, -0.071269634281296401f, - 0.997402129901275300f, -0.072034653246889332f, 0.997346586646633230f, -0.072799629836351673f, - 0.997290456678690210f, -0.073564563599667426f, 0.997233740030466280f, -0.074329454086845756f, - 0.997176436735326190f, -0.075094300847921305f, 0.997118546826979980f, -0.075859103432954447f, - 0.997060070339482960f, -0.076623861392031492f, 0.997001007307235290f, -0.077388574275265049f, - 0.996941357764982160f, -0.078153241632794232f, 0.996881121747813850f, -0.078917863014784942f, - 0.996820299291165670f, -0.079682437971430126f, 0.996758890430818000f, -0.080446966052950014f, - 0.996696895202896060f, -0.081211446809592441f, 0.996634313643869900f, -0.081975879791633066f, - 0.996571145790554840f, -0.082740264549375692f, 0.996507391680110820f, -0.083504600633152432f, - 0.996443051350042630f, -0.084268887593324071f, 0.996378124838200210f, -0.085033124980280275f, - 0.996312612182778000f, -0.085797312344439894f, 0.996246513422315520f, -0.086561449236251170f, - 0.996179828595696980f, -0.087325535206192059f, 0.996112557742151130f, -0.088089569804770507f, - 0.996044700901251970f, -0.088853552582524600f, 0.995976258112917790f, -0.089617483090022959f, - 0.995907229417411720f, -0.090381360877864983f, 0.995837614855341610f, -0.091145185496681005f, - 0.995767414467659820f, -0.091908956497132724f, 0.995696628295663520f, -0.092672673429913310f, - 0.995625256380994310f, -0.093436335845747787f, 0.995553298765638470f, -0.094199943295393204f, - 0.995480755491926940f, -0.094963495329638992f, 0.995407626602534900f, -0.095726991499307162f, - 0.995333912140482280f, -0.096490431355252593f, 0.995259612149133390f, -0.097253814448363271f, - 0.995184726672196930f, -0.098017140329560604f, 0.995109255753726110f, -0.098780408549799623f, - 0.995033199438118630f, -0.099543618660069319f, 0.994956557770116380f, -0.100306770211392860f, - 0.994879330794805620f, -0.101069862754827820f, 0.994801518557617110f, -0.101832895841466530f, - 0.994723121104325700f, -0.102595869022436280f, 0.994644138481050710f, -0.103358781848899610f, - 0.994564570734255420f, -0.104121633872054590f, 0.994484417910747600f, -0.104884424643134970f, - 0.994403680057679100f, -0.105647153713410620f, 0.994322357222545810f, -0.106409820634187680f, - 0.994240449453187900f, -0.107172424956808840f, 0.994157956797789730f, -0.107934966232653650f, - 0.994074879304879370f, -0.108697444013138720f, 0.993991217023329380f, -0.109459857849717980f, - 0.993906970002356060f, -0.110222207293883060f, 0.993822138291519660f, -0.110984491897163390f, - 0.993736721940724600f, -0.111746711211126590f, 0.993650721000219120f, -0.112508864787378690f, - 0.993564135520595300f, -0.113270952177564350f, 0.993476965552789190f, -0.114032972933367200f, - 0.993389211148080650f, -0.114794926606510080f, 0.993300872358093280f, -0.115556812748755260f, - 0.993211949234794500f, -0.116318630911904750f, 0.993122441830495580f, -0.117080380647800590f, - 0.993032350197851410f, -0.117842061508324980f, 0.992941674389860470f, -0.118603673045400720f, - 0.992850414459865100f, -0.119365214810991350f, 0.992758570461551140f, -0.120126686357101500f, - 0.992666142448948020f, -0.120888087235777080f, 0.992573130476428810f, -0.121649416999105530f, - 0.992479534598709970f, -0.122410675199216200f, 0.992385354870851670f, -0.123171861388280480f, - 0.992290591348257370f, -0.123932975118512160f, 0.992195244086673920f, -0.124694015942167640f, - 0.992099313142191800f, -0.125454983411546230f, 0.992002798571244520f, -0.126215877078990350f, - 0.991905700430609330f, -0.126976696496885870f, 0.991808018777406430f, -0.127737441217662310f, - 0.991709753669099530f, -0.128498110793793170f, 0.991610905163495370f, -0.129258704777796140f, - 0.991511473318743900f, -0.130019222722233350f, 0.991411458193338540f, -0.130779664179711710f, - 0.991310859846115440f, -0.131540028702883120f, 0.991209678336254060f, -0.132300315844444650f, - 0.991107913723276890f, -0.133060525157139060f, 0.991005566067049370f, -0.133820656193754720f, - 0.990902635427780010f, -0.134580708507126170f, 0.990799121866020370f, -0.135340681650134210f, - 0.990695025442664630f, -0.136100575175706200f, 0.990590346218950150f, -0.136860388636816380f, - 0.990485084256457090f, -0.137620121586486040f, 0.990379239617108160f, -0.138379773577783890f, - 0.990272812363169110f, -0.139139344163826200f, 0.990165802557248400f, -0.139898832897777210f, - 0.990058210262297120f, -0.140658239332849210f, 0.989950035541608990f, -0.141417563022303020f, - 0.989841278458820530f, -0.142176803519448030f, 0.989731939077910570f, -0.142935960377642670f, - 0.989622017463200890f, -0.143695033150294470f, 0.989511513679355190f, -0.144454021390860470f, - 0.989400427791380380f, -0.145212924652847460f, 0.989288759864625170f, -0.145971742489812210f, - 0.989176509964781010f, -0.146730474455361750f, 0.989063678157881540f, -0.147489120103153570f, - 0.988950264510302990f, -0.148247678986896030f, 0.988836269088763540f, -0.149006150660348450f, - 0.988721691960323780f, -0.149764534677321510f, 0.988606533192386450f, -0.150522830591677400f, - 0.988490792852696590f, -0.151281037957330220f, 0.988374471009341280f, -0.152039156328246050f, - 0.988257567730749460f, -0.152797185258443440f, 0.988140083085692570f, -0.153555124301993450f, - 0.988022017143283530f, -0.154312973013020100f, 0.987903369972977790f, -0.155070730945700510f, - 0.987784141644572180f, -0.155828397654265230f, 0.987664332228205710f, -0.156585972692998430f, - 0.987543941794359230f, -0.157343455616238250f, 0.987422970413855410f, -0.158100845978376980f, - 0.987301418157858430f, -0.158858143333861450f, 0.987179285097874340f, -0.159615347237193060f, - 0.987056571305750970f, -0.160372457242928280f, 0.986933276853677710f, -0.161129472905678810f, - 0.986809401814185530f, -0.161886393780111830f, 0.986684946260146690f, -0.162643219420950310f, - 0.986559910264775410f, -0.163399949382973230f, 0.986434293901627180f, -0.164156583221015810f, - 0.986308097244598670f, -0.164913120489969890f, 0.986181320367928270f, -0.165669560744784120f, - 0.986053963346195440f, -0.166425903540464100f, 0.985926026254321130f, -0.167182148432072940f, - 0.985797509167567480f, -0.167938294974731170f, 0.985668412161537550f, -0.168694342723617330f, - 0.985538735312176060f, -0.169450291233967960f, 0.985408478695768420f, -0.170206140061078070f, - 0.985277642388941220f, -0.170961888760301220f, 0.985146226468662230f, -0.171717536887049970f, - 0.985014231012239840f, -0.172473083996795950f, 0.984881656097323700f, -0.173228529645070320f, - 0.984748501801904210f, -0.173983873387463820f, 0.984614768204312600f, -0.174739114779627200f, - 0.984480455383220930f, -0.175494253377271430f, 0.984345563417641900f, -0.176249288736167880f, - 0.984210092386929030f, -0.177004220412148750f, 0.984074042370776450f, -0.177759047961107170f, - 0.983937413449218920f, -0.178513770938997510f, 0.983800205702631600f, -0.179268388901835750f, - 0.983662419211730250f, -0.180022901405699510f, 0.983524054057571260f, -0.180777308006728590f, - 0.983385110321551180f, -0.181531608261124970f, 0.983245588085407070f, -0.182285801725153300f, - 0.983105487431216290f, -0.183039887955140950f, 0.982964808441396440f, -0.183793866507478450f, - 0.982823551198705240f, -0.184547736938619620f, 0.982681715786240860f, -0.185301498805081900f, - 0.982539302287441240f, -0.186055151663446630f, 0.982396310786084690f, -0.186808695070359270f, - 0.982252741366289370f, -0.187562128582529600f, 0.982108594112513610f, -0.188315451756732120f, - 0.981963869109555240f, -0.189068664149806190f, 0.981818566442552500f, -0.189821765318656410f, - 0.981672686196983110f, -0.190574754820252740f, 0.981526228458664770f, -0.191327632211630900f, - 0.981379193313754560f, -0.192080397049892440f, 0.981231580848749730f, -0.192833048892205230f, - 0.981083391150486710f, -0.193585587295803610f, 0.980934624306141640f, -0.194338011817988600f, - 0.980785280403230430f, -0.195090322016128250f, 0.980635359529608120f, -0.195842517447657850f, - 0.980484861773469380f, -0.196594597670080220f, 0.980333787223347960f, -0.197346562240965920f, - 0.980182135968117430f, -0.198098410717953560f, 0.980029908096990090f, -0.198850142658750090f, - 0.979877103699517640f, -0.199601757621130970f, 0.979723722865591170f, -0.200353255162940450f, - 0.979569765685440520f, -0.201104634842091900f, 0.979415232249634780f, -0.201855896216568050f, - 0.979260122649082020f, -0.202607038844421130f, 0.979104436975029250f, -0.203358062283773320f, - 0.978948175319062200f, -0.204108966092816870f, 0.978791337773105670f, -0.204859749829814420f, - 0.978633924429423210f, -0.205610413053099240f, 0.978475935380616830f, -0.206360955321075510f, - 0.978317370719627650f, -0.207111376192218560f, 0.978158230539735050f, -0.207861675225075070f, - 0.977998514934557140f, -0.208611851978263490f, 0.977838223998050430f, -0.209361906010474160f, - 0.977677357824509930f, -0.210111836880469610f, 0.977515916508569280f, -0.210861644147084860f, - 0.977353900145199960f, -0.211611327369227550f, 0.977191308829712280f, -0.212360886105878420f, - 0.977028142657754390f, -0.213110319916091360f, 0.976864401725312640f, -0.213859628358993750f, - 0.976700086128711840f, -0.214608810993786760f, 0.976535195964614470f, -0.215357867379745550f, - 0.976369731330021140f, -0.216106797076219520f, 0.976203692322270560f, -0.216855599642632620f, - 0.976037079039039020f, -0.217604274638483640f, 0.975869891578341030f, -0.218352821623346320f, - 0.975702130038528570f, -0.219101240156869800f, 0.975533794518291360f, -0.219849529798778700f, - 0.975364885116656980f, -0.220597690108873510f, 0.975195401932990370f, -0.221345720647030810f, - 0.975025345066994120f, -0.222093620973203510f, 0.974854714618708430f, -0.222841390647421120f, - 0.974683510688510670f, -0.223589029229789990f, 0.974511733377115720f, -0.224336536280493600f, - 0.974339382785575860f, -0.225083911359792830f, 0.974166459015280320f, -0.225831154028026170f, - 0.973992962167955830f, -0.226578263845610000f, 0.973818892345666100f, -0.227325240373038860f, - 0.973644249650811980f, -0.228072083170885730f, 0.973469034186131070f, -0.228818791799802220f, - 0.973293246054698250f, -0.229565365820518870f, 0.973116885359925130f, -0.230311804793845440f, - 0.972939952205560180f, -0.231058108280671110f, 0.972762446695688570f, -0.231804275841964780f, - 0.972584368934732210f, -0.232550307038775240f, 0.972405719027449770f, -0.233296201432231590f, - 0.972226497078936270f, -0.234041958583543430f, 0.972046703194623500f, -0.234787578054000970f, - 0.971866337480279400f, -0.235533059404975490f, 0.971685400042008540f, -0.236278402197919570f, - 0.971503890986251780f, -0.237023605994367200f, 0.971321810419786160f, -0.237768670355934190f, - 0.971139158449725090f, -0.238513594844318420f, 0.970955935183517970f, -0.239258379021299980f, - 0.970772140728950350f, -0.240003022448741500f, 0.970587775194143630f, -0.240747524688588430f, - 0.970402838687555500f, -0.241491885302869330f, 0.970217331317979160f, -0.242236103853696010f, - 0.970031253194543970f, -0.242980179903263870f, 0.969844604426714830f, -0.243724113013852160f, - 0.969657385124292450f, -0.244467902747824150f, 0.969469595397413060f, -0.245211548667627540f, - 0.969281235356548530f, -0.245955050335794590f, 0.969092305112506210f, -0.246698407314942410f, - 0.968902804776428870f, -0.247441619167773270f, 0.968712734459794780f, -0.248184685457074780f, - 0.968522094274417380f, -0.248927605745720150f, 0.968330884332445190f, -0.249670379596668570f, - 0.968139104746362440f, -0.250413006572965220f, 0.967946755628987800f, -0.251155486237741920f, - 0.967753837093475510f, -0.251897818154216970f, 0.967560349253314360f, -0.252640001885695520f, - 0.967366292222328510f, -0.253382036995570160f, 0.967171666114676640f, -0.254123923047320620f, - 0.966976471044852070f, -0.254865659604514570f, 0.966780707127683270f, -0.255607246230807380f, - 0.966584374478333120f, -0.256348682489942910f, 0.966387473212298900f, -0.257089967945753120f, - 0.966190003445412500f, -0.257831102162158990f, 0.965991965293840570f, - -0.258572084703170340f, - 0.965793358874083680f, -0.259312915132886230f, 0.965594184302976830f, - -0.260053593015495190f, - 0.965394441697689400f, -0.260794117915275510f, 0.965194131175724720f, - -0.261534489396595520f, - 0.964993252854920320f, -0.262274707023913590f, 0.964791806853447900f, - -0.263014770361779000f, - 0.964589793289812760f, -0.263754678974831350f, 0.964387212282854290f, - -0.264494432427801630f, - 0.964184063951745830f, -0.265234030285511790f, 0.963980348415994110f, - -0.265973472112875590f, - 0.963776065795439840f, -0.266712757474898370f, 0.963571216210257320f, - -0.267451885936677620f, - 0.963365799780954050f, -0.268190857063403180f, 0.963159816628371360f, - -0.268929670420357260f, - 0.962953266873683880f, -0.269668325572915090f, 0.962746150638399410f, - -0.270406822086544820f, - 0.962538468044359160f, -0.271145159526808010f, 0.962330219213737400f, - -0.271883337459359720f, - 0.962121404269041580f, -0.272621355449948980f, 0.961912023333112210f, - -0.273359213064418680f, - 0.961702076529122540f, -0.274096909868706380f, 0.961491563980579000f, - -0.274834445428843940f, - 0.961280485811320640f, -0.275571819310958140f, 0.961068842145519350f, - -0.276309031081271080f, - 0.960856633107679660f, -0.277046080306099900f, 0.960643858822638590f, - -0.277782966551857690f, - 0.960430519415565790f, -0.278519689385053060f, 0.960216615011963430f, - -0.279256248372291180f, - 0.960002145737665960f, -0.279992643080273220f, 0.959787111718839900f, - -0.280728873075797190f, - 0.959571513081984520f, -0.281464937925757940f, 0.959355349953930790f, - -0.282200837197147560f, - 0.959138622461841890f, -0.282936570457055390f, 0.958921330733213170f, - -0.283672137272668430f, - 0.958703474895871600f, -0.284407537211271880f, 0.958485055077976100f, - -0.285142769840248670f, - 0.958266071408017670f, -0.285877834727080620f, 0.958046524014818600f, - -0.286612731439347790f, - 0.957826413027532910f, -0.287347459544729510f, 0.957605738575646350f, - -0.288082018611004130f, - 0.957384500788975860f, -0.288816408206049480f, 0.957162699797670210f, - -0.289550627897843030f, - 0.956940335732208820f, -0.290284677254462330f, 0.956717408723403050f, - -0.291018555844085090f, - 0.956493918902395100f, -0.291752263234989260f, 0.956269866400658030f, - -0.292485798995553880f, - 0.956045251349996410f, -0.293219162694258630f, 0.955820073882545420f, - -0.293952353899684660f, - 0.955594334130771110f, -0.294685372180514330f, 0.955368032227470350f, - -0.295418217105532010f, - 0.955141168305770780f, -0.296150888243623790f, 0.954913742499130520f, - -0.296883385163778270f, - 0.954685754941338340f, -0.297615707435086200f, 0.954457205766513490f, - -0.298347854626741400f, - 0.954228095109105670f, -0.299079826308040480f, 0.953998423103894490f, - -0.299811622048383350f, - 0.953768189885990330f, -0.300543241417273450f, 0.953537395590833280f, - -0.301274683984317950f, - 0.953306040354193860f, -0.302005949319228080f, 0.953074124312172200f, - -0.302737036991819140f, - 0.952841647601198720f, -0.303467946572011320f, 0.952608610358033350f, - -0.304198677629829110f, - 0.952375012719765880f, -0.304929229735402370f, 0.952140854823815830f, - -0.305659602458966120f, - 0.951906136807932350f, -0.306389795370860920f, 0.951670858810193860f, - -0.307119808041533100f, - 0.951435020969008340f, -0.307849640041534870f, 0.951198623423113230f, - -0.308579290941525090f, - 0.950961666311575080f, -0.309308760312268730f, 0.950724149773789610f, - -0.310038047724637890f, - 0.950486073949481700f, -0.310767152749611470f, 0.950247438978705230f, - -0.311496074958275910f, - 0.950008245001843000f, -0.312224813921824880f, 0.949768492159606680f, - -0.312953369211560200f, - 0.949528180593036670f, -0.313681740398891520f, 0.949287310443502120f, - -0.314409927055336660f, - 0.949045881852700560f, -0.315137928752522440f, 0.948803894962658490f, - -0.315865745062183960f, - 0.948561349915730270f, -0.316593375556165850f, 0.948318246854599090f, - -0.317320819806421740f, - 0.948074585922276230f, -0.318048077385014950f, 0.947830367262101010f, - -0.318775147864118480f, - 0.947585591017741090f, -0.319502030816015690f, 0.947340257333192050f, - -0.320228725813099860f, - 0.947094366352777220f, -0.320955232427875210f, 0.946847918221148000f, - -0.321681550232956580f, - 0.946600913083283530f, -0.322407678801069850f, 0.946353351084490590f, - -0.323133617705052330f, - 0.946105232370403450f, -0.323859366517852850f, 0.945856557086983910f, - -0.324584924812532150f, - 0.945607325380521280f, -0.325310292162262930f, 0.945357537397632290f, - -0.326035468140330240f, - 0.945107193285260610f, -0.326760452320131730f, 0.944856293190677210f, - -0.327485244275178000f, - 0.944604837261480260f, -0.328209843579092500f, 0.944352825645594750f, - -0.328934249805612200f, - 0.944100258491272660f, -0.329658462528587490f, 0.943847135947092690f, - -0.330382481321982780f, - 0.943593458161960390f, -0.331106305759876430f, 0.943339225285107720f, - -0.331829935416461110f, - 0.943084437466093490f, -0.332553369866044220f, 0.942829094854802710f, - -0.333276608683047930f, - 0.942573197601446870f, -0.333999651442009380f, 0.942316745856563780f, - -0.334722497717581220f, - 0.942059739771017310f, -0.335445147084531600f, 0.941802179495997650f, - -0.336167599117744520f, - 0.941544065183020810f, -0.336889853392220050f, 0.941285396983928660f, - -0.337611909483074620f, - 0.941026175050889260f, -0.338333766965541130f, 0.940766399536396070f, - -0.339055425414969640f, - 0.940506070593268300f, -0.339776884406826850f, 0.940245188374650880f, - -0.340498143516697160f, - 0.939983753034014050f, -0.341219202320282360f, 0.939721764725153340f, - -0.341940060393402190f, - 0.939459223602189920f, -0.342660717311994380f, 0.939196129819569900f, - -0.343381172652115040f, - 0.938932483532064600f, -0.344101425989938810f, 0.938668284894770170f, - -0.344821476901759290f, - 0.938403534063108060f, -0.345541324963989090f, 0.938138231192824360f, - -0.346260969753160010f, - 0.937872376439989890f, -0.346980410845923680f, 0.937605969960999990f, - -0.347699647819051380f, - 0.937339011912574960f, -0.348418680249434560f, 0.937071502451759190f, - -0.349137507714084970f, - 0.936803441735921560f, -0.349856129790134920f, 0.936534829922755500f, - -0.350574546054837510f, - 0.936265667170278260f, -0.351292756085567090f, 0.935995953636831410f, - -0.352010759459819080f, - 0.935725689481080370f, -0.352728555755210730f, 0.935454874862014620f, - -0.353446144549480810f, - 0.935183509938947610f, -0.354163525420490340f, 0.934911594871516090f, - -0.354880697946222790f, - 0.934639129819680780f, -0.355597661704783850f, 0.934366114943725790f, - -0.356314416274402410f, - 0.934092550404258980f, -0.357030961233429980f, 0.933818436362210960f, - -0.357747296160341900f, - 0.933543772978836170f, -0.358463420633736540f, 0.933268560415712050f, - -0.359179334232336500f, - 0.932992798834738960f, -0.359895036534988110f, 0.932716488398140250f, - -0.360610527120662270f, - 0.932439629268462360f, -0.361325805568454280f, 0.932162221608574430f, - -0.362040871457584180f, - 0.931884265581668150f, -0.362755724367397230f, 0.931605761351257830f, - -0.363470363877363760f, - 0.931326709081180430f, -0.364184789567079890f, 0.931047108935595280f, - -0.364899001016267320f, - 0.930766961078983710f, -0.365612997804773850f, 0.930486265676149780f, - -0.366326779512573590f, - 0.930205022892219070f, -0.367040345719767180f, 0.929923232892639670f, - -0.367753696006581980f, - 0.929640895843181330f, -0.368466829953372320f, 0.929358011909935500f, - -0.369179747140620020f, - 0.929074581259315860f, -0.369892447148934100f, 0.928790604058057020f, - -0.370604929559051670f, - 0.928506080473215590f, -0.371317193951837540f, 0.928221010672169440f, - -0.372029239908285010f, - 0.927935394822617890f, -0.372741067009515760f, 0.927649233092581180f, - -0.373452674836780300f, - 0.927362525650401110f, -0.374164062971457930f, 0.927075272664740100f, - -0.374875230995057540f, - 0.926787474304581750f, -0.375586178489217220f, 0.926499130739230510f, - -0.376296905035704790f, - 0.926210242138311380f, -0.377007410216418260f, 0.925920808671770070f, - -0.377717693613385640f, - 0.925630830509872720f, -0.378427754808765560f, 0.925340307823206310f, - -0.379137593384847320f, - 0.925049240782677580f, -0.379847208924051160f, 0.924757629559513910f, - -0.380556601008928520f, - 0.924465474325262600f, -0.381265769222162380f, 0.924172775251791200f, - -0.381974713146567220f, - 0.923879532511286740f, -0.382683432365089780f, 0.923585746276256670f, - -0.383391926460808660f, - 0.923291416719527640f, -0.384100195016935040f, 0.922996544014246250f, - -0.384808237616812880f, - 0.922701128333878630f, -0.385516053843918850f, 0.922405169852209880f, - -0.386223643281862980f, - 0.922108668743345180f, -0.386931005514388580f, 0.921811625181708120f, - -0.387638140125372730f, - 0.921514039342042010f, -0.388345046698826250f, 0.921215911399408730f, - -0.389051724818894380f, - 0.920917241529189520f, -0.389758174069856410f, 0.920618029907083970f, - -0.390464394036126590f, - 0.920318276709110590f, -0.391170384302253870f, 0.920017982111606570f, - -0.391876144452922350f, - 0.919717146291227360f, -0.392581674072951470f, 0.919415769424947070f, - -0.393286972747296400f, - 0.919113851690057770f, -0.393992040061048100f, 0.918811393264170050f, - -0.394696875599433560f, - 0.918508394325212250f, -0.395401478947816350f, 0.918204855051430900f, - -0.396105849691696270f, - 0.917900775621390500f, -0.396809987416710310f, 0.917596156213972950f, - -0.397513891708632330f, - 0.917290997008377910f, -0.398217562153373560f, 0.916985298184123000f, - -0.398920998336982910f, - 0.916679059921042700f, -0.399624199845646790f, 0.916372282399289140f, - -0.400327166265690090f, - 0.916064965799331720f, -0.401029897183575620f, 0.915757110301956720f, - -0.401732392185905010f, - 0.915448716088267830f, -0.402434650859418430f, 0.915139783339685260f, - -0.403136672790995300f, - 0.914830312237946200f, -0.403838457567654070f, 0.914520302965104450f, - -0.404540004776553000f, - 0.914209755703530690f, -0.405241314004989860f, 0.913898670635911680f, - -0.405942384840402510f, - 0.913587047945250810f, -0.406643216870369030f, 0.913274887814867760f, - -0.407343809682607970f, - 0.912962190428398210f, -0.408044162864978690f, 0.912648955969793900f, - -0.408744276005481360f, - 0.912335184623322750f, -0.409444148692257590f, 0.912020876573568340f, - -0.410143780513590240f, - 0.911706032005429880f, -0.410843171057903910f, 0.911390651104122430f, - -0.411542319913765220f, - 0.911074734055176360f, -0.412241226669882890f, 0.910758281044437570f, - -0.412939890915108080f, - 0.910441292258067250f, -0.413638312238434500f, 0.910123767882541680f, - -0.414336490228999100f, - 0.909805708104652220f, -0.415034424476081630f, 0.909487113111505430f, - -0.415732114569105360f, - 0.909167983090522380f, -0.416429560097637150f, 0.908848318229439120f, - -0.417126760651387870f, - 0.908528118716306120f, -0.417823715820212270f, 0.908207384739488700f, - -0.418520425194109700f, - 0.907886116487666260f, -0.419216888363223910f, 0.907564314149832630f, - -0.419913104917843620f, - 0.907241977915295820f, -0.420609074448402510f, 0.906919107973678140f, - -0.421304796545479640f, - 0.906595704514915330f, -0.422000270799799680f, 0.906271767729257660f, - -0.422695496802232950f, - 0.905947297807268460f, -0.423390474143796050f, 0.905622294939825270f, - -0.424085202415651560f, - 0.905296759318118820f, -0.424779681209108810f, 0.904970691133653250f, - -0.425473910115623800f, - 0.904644090578246240f, -0.426167888726799620f, 0.904316957844028320f, - -0.426861616634386430f, - 0.903989293123443340f, -0.427555093430282080f, 0.903661096609247980f, - -0.428248318706531960f, - 0.903332368494511820f, -0.428941292055329490f, 0.903003108972617150f, - -0.429634013069016380f, - 0.902673318237258830f, -0.430326481340082610f, 0.902342996482444200f, - -0.431018696461167030f, - 0.902012143902493180f, -0.431710658025057260f, 0.901680760692037730f, - -0.432402365624690140f, - 0.901348847046022030f, -0.433093818853151960f, 0.901016403159702330f, - -0.433785017303678520f, - 0.900683429228646970f, -0.434475960569655650f, 0.900349925448735600f, - -0.435166648244619260f, - 0.900015892016160280f, -0.435857079922255470f, 0.899681329127423930f, - -0.436547255196401200f, - 0.899346236979341570f, -0.437237173661044090f, 0.899010615769039070f, - -0.437926834910322860f, - 0.898674465693953820f, -0.438616238538527660f, 0.898337786951834310f, - -0.439305384140099950f, - 0.898000579740739880f, -0.439994271309633260f, 0.897662844259040860f, - -0.440682899641872900f, - 0.897324580705418320f, -0.441371268731716670f, 0.896985789278863970f, - -0.442059378174214700f, - 0.896646470178680150f, -0.442747227564570020f, 0.896306623604479550f, - -0.443434816498138480f, - 0.895966249756185220f, -0.444122144570429200f, 0.895625348834030110f, - -0.444809211377104880f, - 0.895283921038557580f, -0.445496016513981740f, 0.894941966570620750f, - -0.446182559577030070f, - 0.894599485631382700f, -0.446868840162374160f, 0.894256478422316040f, - -0.447554857866293010f, - 0.893912945145203250f, -0.448240612285219890f, 0.893568886002135910f, - -0.448926103015743260f, - 0.893224301195515320f, -0.449611329654606540f, 0.892879190928051680f, - -0.450296291798708610f, - 0.892533555402764580f, -0.450980989045103860f, 0.892187394822982480f, - -0.451665420991002490f, - 0.891840709392342720f, -0.452349587233770890f, 0.891493499314791380f, - -0.453033487370931580f, - 0.891145764794583180f, -0.453717121000163870f, 0.890797506036281490f, - -0.454400487719303580f, - 0.890448723244757880f, -0.455083587126343840f, 0.890099416625192320f, - -0.455766418819434640f, - 0.889749586383072780f, -0.456448982396883920f, 0.889399232724195520f, - -0.457131277457156980f, - 0.889048355854664570f, -0.457813303598877170f, 0.888696955980891600f, - -0.458495060420826270f, - 0.888345033309596350f, -0.459176547521944090f, 0.887992588047805560f, - -0.459857764501329540f, - 0.887639620402853930f, -0.460538710958240010f, 0.887286130582383150f, - -0.461219386492092380f, - 0.886932118794342190f, -0.461899790702462730f, 0.886577585246987040f, - -0.462579923189086810f, - 0.886222530148880640f, -0.463259783551860150f, 0.885866953708892790f, - -0.463939371390838520f, - 0.885510856136199950f, -0.464618686306237820f, 0.885154237640285110f, - -0.465297727898434600f, - 0.884797098430937790f, -0.465976495767966180f, 0.884439438718253810f, - -0.466654989515530920f, - 0.884081258712634990f, -0.467333208741988420f, 0.883722558624789660f, - -0.468011153048359830f, - 0.883363338665731580f, -0.468688822035827900f, 0.883003599046780830f, - -0.469366215305737520f, - 0.882643339979562790f, -0.470043332459595620f, 0.882282561676008710f, - -0.470720173099071600f, - 0.881921264348355050f, -0.471396736825997640f, 0.881559448209143780f, - -0.472073023242368660f, - 0.881197113471222090f, -0.472749031950342790f, 0.880834260347742040f, - -0.473424762552241530f, - 0.880470889052160750f, -0.474100214650549970f, 0.880106999798240360f, - -0.474775387847917120f, - 0.879742592800047410f, -0.475450281747155870f, 0.879377668271953290f, - -0.476124895951243580f, - 0.879012226428633530f, -0.476799230063322090f, 0.878646267485068130f, - -0.477473283686698060f, - 0.878279791656541580f, -0.478147056424843010f, 0.877912799158641840f, - -0.478820547881393890f, - 0.877545290207261350f, -0.479493757660153010f, 0.877177265018595940f, - -0.480166685365088390f, - 0.876808723809145650f, -0.480839330600333960f, 0.876439666795713610f, - -0.481511692970189860f, - 0.876070094195406600f, -0.482183772079122720f, 0.875700006225634600f, - -0.482855567531765670f, - 0.875329403104110890f, -0.483527078932918740f, 0.874958285048851650f, - -0.484198305887549030f, - 0.874586652278176110f, -0.484869248000791060f, 0.874214505010706300f, - -0.485539904877946960f, - 0.873841843465366860f, -0.486210276124486420f, 0.873468667861384880f, - -0.486880361346047340f, - 0.873094978418290090f, -0.487550160148436000f, 0.872720775355914300f, - -0.488219672137626790f, - 0.872346058894391540f, -0.488888896919763170f, 0.871970829254157810f, - -0.489557834101157440f, - 0.871595086655950980f, -0.490226483288291160f, 0.871218831320811020f, - -0.490894844087815090f, - 0.870842063470078980f, -0.491562916106549900f, 0.870464783325397670f, - -0.492230698951486020f, - 0.870086991108711460f, -0.492898192229784040f, 0.869708687042265670f, - -0.493565395548774770f, - 0.869329871348606840f, -0.494232308515959670f, 0.868950544250582380f, - -0.494898930739011260f, - 0.868570705971340900f, -0.495565261825772540f, 0.868190356734331310f, - -0.496231301384258250f, - 0.867809496763303320f, -0.496897049022654470f, 0.867428126282306920f, - -0.497562504349319150f, - 0.867046245515692650f, -0.498227666972781870f, 0.866663854688111130f, - -0.498892536501744590f, - 0.866280954024512990f, -0.499557112545081840f, 0.865897543750148820f, - -0.500221394711840680f, - 0.865513624090569090f, -0.500885382611240710f, 0.865129195271623800f, - -0.501549075852675390f, - 0.864744257519462380f, -0.502212474045710790f, 0.864358811060534030f, - -0.502875576800086990f, - 0.863972856121586810f, -0.503538383725717580f, 0.863586392929668100f, - -0.504200894432690340f, - 0.863199421712124160f, -0.504863108531267590f, 0.862811942696600330f, - -0.505525025631885390f, - 0.862423956111040610f, -0.506186645345155230f, 0.862035462183687210f, - -0.506847967281863210f, - 0.861646461143081300f, -0.507508991052970870f, 0.861256953218062170f, - -0.508169716269614600f, - 0.860866938637767310f, -0.508830142543106990f, 0.860476417631632070f, - -0.509490269484936360f, - 0.860085390429390140f, -0.510150096706766810f, 0.859693857261072610f, - -0.510809623820439040f, - 0.859301818357008470f, -0.511468850437970300f, 0.858909273947823900f, - -0.512127776171554690f, - 0.858516224264442740f, -0.512786400633562960f, 0.858122669538086140f, - -0.513444723436543460f, - 0.857728610000272120f, -0.514102744193221660f, 0.857334045882815590f, - -0.514760462516501200f, - 0.856938977417828760f, -0.515417878019462930f, 0.856543404837719960f, - -0.516074990315366630f, - 0.856147328375194470f, -0.516731799017649870f, 0.855750748263253920f, - -0.517388303739929060f, - 0.855353664735196030f, -0.518044504095999340f, 0.854956078024614930f, - -0.518700399699834950f, - 0.854557988365400530f, -0.519355990165589640f, 0.854159395991738850f, - -0.520011275107596040f, - 0.853760301138111410f, -0.520666254140367160f, 0.853360704039295430f, - -0.521320926878595660f, - 0.852960604930363630f, -0.521975292937154390f, 0.852560004046684080f, - -0.522629351931096610f, - 0.852158901623919830f, -0.523283103475656430f, 0.851757297898029120f, - -0.523936547186248600f, - 0.851355193105265200f, -0.524589682678468950f, 0.850952587482175730f, - -0.525242509568094710f, - 0.850549481265603480f, -0.525895027471084630f, 0.850145874692685210f, - -0.526547236003579440f, - 0.849741768000852550f, -0.527199134781901280f, 0.849337161427830780f, - -0.527850723422555230f, - 0.848932055211639610f, -0.528502001542228480f, 0.848526449590592650f, - -0.529152968757790610f, - 0.848120344803297230f, -0.529803624686294610f, 0.847713741088654380f, - -0.530453968944976320f, - 0.847306638685858320f, -0.531104001151255000f, 0.846899037834397240f, - -0.531753720922733320f, - 0.846490938774052130f, -0.532403127877197900f, 0.846082341744897050f, - -0.533052221632619450f, - 0.845673246987299070f, -0.533701001807152960f, 0.845263654741918220f, - -0.534349468019137520f, - 0.844853565249707120f, -0.534997619887097150f, 0.844442978751910660f, - -0.535645457029741090f, - 0.844031895490066410f, -0.536292979065963180f, 0.843620315706004150f, - -0.536940185614842910f, - 0.843208239641845440f, -0.537587076295645390f, 0.842795667540004120f, - -0.538233650727821700f, - 0.842382599643185850f, -0.538879908531008420f, 0.841969036194387680f, - -0.539525849325028890f, - 0.841554977436898440f, -0.540171472729892850f, 0.841140423614298080f, - -0.540816778365796670f, - 0.840725374970458070f, -0.541461765853123440f, 0.840309831749540770f, - -0.542106434812443920f, - 0.839893794195999520f, -0.542750784864515890f, 0.839477262554578550f, - -0.543394815630284800f, - 0.839060237070312740f, -0.544038526730883820f, 0.838642717988527300f, - -0.544681917787634530f, - 0.838224705554838080f, -0.545324988422046460f, 0.837806200015150940f, - -0.545967738255817570f, - 0.837387201615661940f, -0.546610166910834860f, 0.836967710602857020f, - -0.547252274009174090f, - 0.836547727223512010f, -0.547894059173100190f, 0.836127251724692270f, - -0.548535522025067390f, - 0.835706284353752600f, -0.549176662187719660f, 0.835284825358337370f, - -0.549817479283890910f, - 0.834862874986380010f, -0.550457972936604810f, 0.834440433486103190f, - -0.551098142769075430f, - 0.834017501106018130f, -0.551737988404707340f, 0.833594078094925140f, - -0.552377509467096070f, - 0.833170164701913190f, -0.553016705580027470f, 0.832745761176359460f, - -0.553655576367479310f, - 0.832320867767929680f, -0.554294121453620000f, 0.831895484726577590f, - -0.554932340462810370f, - 0.831469612302545240f, -0.555570233019602180f, 0.831043250746362320f, - -0.556207798748739930f, - 0.830616400308846310f, -0.556845037275160100f, 0.830189061241102370f, - -0.557481948223991550f, - 0.829761233794523050f, -0.558118531220556100f, 0.829332918220788250f, - -0.558754785890368310f, - 0.828904114771864870f, -0.559390711859136140f, 0.828474823700007130f, - -0.560026308752760380f, - 0.828045045257755800f, -0.560661576197336030f, 0.827614779697938400f, - -0.561296513819151470f, - 0.827184027273669130f, -0.561931121244689470f, 0.826752788238348520f, - -0.562565398100626560f, - 0.826321062845663530f, -0.563199344013834090f, 0.825888851349586780f, - -0.563832958611378170f, - 0.825456154004377550f, -0.564466241520519500f, 0.825022971064580220f, - -0.565099192368713980f, - 0.824589302785025290f, -0.565731810783613120f, 0.824155149420828570f, - -0.566364096393063840f, - 0.823720511227391430f, -0.566996048825108680f, 0.823285388460400110f, - -0.567627667707986230f, - 0.822849781375826430f, -0.568258952670131490f, 0.822413690229926390f, - -0.568889903340175860f, - 0.821977115279241550f, -0.569520519346947140f, 0.821540056780597610f, - -0.570150800319470300f, - 0.821102514991104650f, -0.570780745886967260f, 0.820664490168157460f, - -0.571410355678857230f, - 0.820225982569434690f, -0.572039629324757050f, 0.819786992452898990f, - -0.572668566454481160f, - 0.819347520076796900f, -0.573297166698042200f, 0.818907565699658950f, - -0.573925429685650750f, - 0.818467129580298660f, -0.574553355047715760f, 0.818026211977813440f, - -0.575180942414845080f, - 0.817584813151583710f, -0.575808191417845340f, 0.817142933361272970f, - -0.576435101687721830f, - 0.816700572866827850f, -0.577061672855679440f, 0.816257731928477390f, - -0.577687904553122800f, - 0.815814410806733780f, -0.578313796411655590f, 0.815370609762391290f, - -0.578939348063081780f, - 0.814926329056526620f, -0.579564559139405630f, 0.814481568950498610f, - -0.580189429272831680f, - 0.814036329705948410f, -0.580813958095764530f, 0.813590611584798510f, - -0.581438145240810170f, - 0.813144414849253590f, -0.582061990340775440f, 0.812697739761799490f, - -0.582685493028668460f, - 0.812250586585203880f, -0.583308652937698290f, 0.811802955582515470f, - -0.583931469701276180f, - 0.811354847017063730f, -0.584553942953015330f, 0.810906261152459670f, - -0.585176072326730410f, - 0.810457198252594770f, -0.585797857456438860f, 0.810007658581641140f, - -0.586419297976360500f, - 0.809557642404051260f, -0.587040393520917970f, 0.809107149984558240f, - -0.587661143724736660f, - 0.808656181588174980f, -0.588281548222645220f, 0.808204737480194720f, - -0.588901606649675720f, - 0.807752817926190360f, -0.589521318641063940f, 0.807300423192014450f, - -0.590140683832248820f, - 0.806847553543799330f, -0.590759701858874160f, 0.806394209247956240f, - -0.591378372356787580f, - 0.805940390571176280f, -0.591996694962040990f, 0.805486097780429230f, - -0.592614669310891130f, - 0.805031331142963660f, -0.593232295039799800f, 0.804576090926307110f, - -0.593849571785433630f, - 0.804120377398265810f, -0.594466499184664430f, 0.803664190826924090f, - -0.595083076874569960f, - 0.803207531480644940f, -0.595699304492433360f, 0.802750399628069160f, - -0.596315181675743710f, - 0.802292795538115720f, -0.596930708062196500f, 0.801834719479981310f, - -0.597545883289693160f, - 0.801376171723140240f, -0.598160706996342270f, 0.800917152537344300f, - -0.598775178820458720f, - 0.800457662192622820f, -0.599389298400564540f, 0.799997700959281910f, - -0.600003065375388940f, - 0.799537269107905010f, -0.600616479383868970f, 0.799076366909352350f, - -0.601229540065148500f, - 0.798614994634760820f, -0.601842247058580030f, 0.798153152555543750f, - -0.602454600003723750f, - 0.797690840943391160f, -0.603066598540348160f, 0.797228060070268810f, - -0.603678242308430370f, - 0.796764810208418830f, -0.604289530948155960f, 0.796301091630359110f, - -0.604900464099919820f, - 0.795836904608883570f, -0.605511041404325550f, 0.795372249417061310f, - -0.606121262502186120f, - 0.794907126328237010f, -0.606731127034524480f, 0.794441535616030590f, - -0.607340634642572930f, - 0.793975477554337170f, -0.607949784967773630f, 0.793508952417326660f, - -0.608558577651779450f, - 0.793041960479443640f, -0.609167012336453210f, 0.792574502015407690f, - -0.609775088663868430f, - 0.792106577300212390f, -0.610382806276309480f, 0.791638186609125880f, - -0.610990164816271660f, - 0.791169330217690200f, -0.611597163926461910f, 0.790700008401721610f, - -0.612203803249797950f, - 0.790230221437310030f, -0.612810082429409710f, 0.789759969600819070f, - -0.613416001108638590f, - 0.789289253168885650f, -0.614021558931038380f, 0.788818072418420280f, - -0.614626755540375050f, - 0.788346427626606340f, -0.615231590580626820f, 0.787874319070900220f, - -0.615836063695985090f, - 0.787401747029031430f, -0.616440174530853650f, 0.786928711779001810f, - -0.617043922729849760f, - 0.786455213599085770f, -0.617647307937803870f, 0.785981252767830150f, - -0.618250329799760250f, - 0.785506829564053930f, -0.618852987960976320f, 0.785031944266848080f, - -0.619455282066924020f, - 0.784556597155575240f, -0.620057211763289100f, 0.784080788509869950f, - -0.620658776695972140f, - 0.783604518609638200f, -0.621259976511087550f, 0.783127787735057310f, - -0.621860810854965360f, - 0.782650596166575730f, -0.622461279374149970f, 0.782172944184913010f, - -0.623061381715401260f, - 0.781694832071059390f, -0.623661117525694530f, 0.781216260106276090f, - -0.624260486452220650f, - 0.780737228572094490f, -0.624859488142386340f, 0.780257737750316590f, - -0.625458122243814360f, - 0.779777787923014550f, -0.626056388404343520f, 0.779297379372530300f, - -0.626654286272029350f, - 0.778816512381475980f, -0.627251815495144080f, 0.778335187232733210f, - -0.627848975722176460f, - 0.777853404209453150f, -0.628445766601832710f, 0.777371163595056310f, - -0.629042187783036000f, - 0.776888465673232440f, -0.629638238914926980f, 0.776405310727940390f, - -0.630233919646864370f, - 0.775921699043407690f, -0.630829229628424470f, 0.775437630904130540f, - -0.631424168509401860f, - 0.774953106594873930f, -0.632018735939809060f, 0.774468126400670860f, - -0.632612931569877410f, - 0.773982690606822900f, -0.633206755050057190f, 0.773496799498899050f, - -0.633800206031017280f, - 0.773010453362736990f, -0.634393284163645490f, 0.772523652484441330f, - -0.634985989099049460f, - 0.772036397150384520f, -0.635578320488556110f, 0.771548687647206300f, - -0.636170277983712170f, - 0.771060524261813820f, -0.636761861236284200f, 0.770571907281380810f, - -0.637353069898259130f, - 0.770082836993347900f, -0.637943903621844060f, 0.769593313685422940f, - -0.638534362059466790f, - 0.769103337645579700f, -0.639124444863775730f, 0.768612909162058380f, - -0.639714151687640450f, - 0.768122028523365420f, -0.640303482184151670f, 0.767630696018273380f, - -0.640892436006621380f, - 0.767138911935820400f, -0.641481012808583160f, 0.766646676565310380f, - -0.642069212243792540f, - 0.766153990196312920f, -0.642657033966226860f, 0.765660853118662500f, - -0.643244477630085850f, - 0.765167265622458960f, -0.643831542889791390f, 0.764673227998067140f, - -0.644418229399988380f, - 0.764178740536116670f, -0.645004536815543930f, 0.763683803527501870f, - -0.645590464791548690f, - 0.763188417263381270f, -0.646176012983316280f, 0.762692582035177980f, - -0.646761181046383920f, - 0.762196298134578900f, -0.647345968636512060f, 0.761699565853535380f, - -0.647930375409685340f, - 0.761202385484261780f, -0.648514401022112440f, 0.760704757319236920f, - -0.649098045130225950f, - 0.760206681651202420f, -0.649681307390683190f, 0.759708158773163440f, - -0.650264187460365850f, - 0.759209188978388070f, -0.650846684996380880f, 0.758709772560407390f, - -0.651428799656059820f, - 0.758209909813015280f, -0.652010531096959500f, 0.757709601030268080f, - -0.652591878976862440f, - 0.757208846506484570f, -0.653172842953776760f, 0.756707646536245670f, - -0.653753422685936060f, - 0.756206001414394540f, -0.654333617831800440f, 0.755703911436035880f, - -0.654913428050056030f, - 0.755201376896536550f, -0.655492852999615350f, 0.754698398091524500f, - -0.656071892339617600f, - 0.754194975316889170f, -0.656650545729428940f, 0.753691108868781210f, - -0.657228812828642540f, - 0.753186799043612520f, -0.657806693297078640f, 0.752682046138055340f, - -0.658384186794785050f, - 0.752176850449042810f, -0.658961292982037320f, 0.751671212273768430f, - -0.659538011519338660f, - 0.751165131909686480f, -0.660114342067420480f, 0.750658609654510700f, - -0.660690284287242300f, - 0.750151645806215070f, -0.661265837839992270f, 0.749644240663033480f, - -0.661841002387086870f, - 0.749136394523459370f, -0.662415777590171780f, 0.748628107686245440f, - -0.662990163111121470f, - 0.748119380450403600f, -0.663564158612039770f, 0.747610213115205150f, - -0.664137763755260010f, - 0.747100605980180130f, -0.664710978203344790f, 0.746590559345117310f, - -0.665283801619087180f, - 0.746080073510063780f, -0.665856233665509720f, 0.745569148775325430f, - -0.666428274005865240f, - 0.745057785441466060f, -0.666999922303637470f, 0.744545983809307370f, - -0.667571178222540310f, - 0.744033744179929290f, -0.668142041426518450f, 0.743521066854669120f, - -0.668712511579747980f, - 0.743007952135121720f, -0.669282588346636010f, 0.742494400323139180f, - -0.669852271391821020f, - 0.741980411720831070f, -0.670421560380173090f, 0.741465986630563290f, - -0.670990454976794220f, - 0.740951125354959110f, -0.671558954847018330f, 0.740435828196898020f, - -0.672127059656411730f, - 0.739920095459516200f, -0.672694769070772860f, 0.739403927446205760f, - -0.673262082756132970f, - 0.738887324460615110f, -0.673829000378756040f, 0.738370286806648620f, - -0.674395521605139050f, - 0.737852814788465980f, -0.674961646102011930f, 0.737334908710482910f, - -0.675527373536338520f, - 0.736816568877369900f, -0.676092703575315920f, 0.736297795594053170f, - -0.676657635886374950f, - 0.735778589165713590f, -0.677222170137180330f, 0.735258949897786840f, - -0.677786305995631500f, - 0.734738878095963500f, -0.678350043129861470f, 0.734218374066188280f, - -0.678913381208238410f, - 0.733697438114660370f, -0.679476319899364970f, 0.733176070547832740f, - -0.680038858872078930f, - 0.732654271672412820f, -0.680600997795453020f, 0.732132041795361290f, - -0.681162736338795430f, - 0.731609381223892630f, -0.681724074171649710f, 0.731086290265474340f, - -0.682285010963795570f, - 0.730562769227827590f, -0.682845546385248080f, 0.730038818418926260f, - -0.683405680106258680f, - 0.729514438146997010f, -0.683965411797315400f, 0.728989628720519420f, - -0.684524741129142300f, - 0.728464390448225200f, -0.685083667772700360f, 0.727938723639098620f, - -0.685642191399187470f, - 0.727412628602375770f, -0.686200311680038590f, 0.726886105647544970f, - -0.686758028286925890f, - 0.726359155084346010f, -0.687315340891759050f, 0.725831777222770370f, - -0.687872249166685550f, - 0.725303972373060770f, -0.688428752784090440f, 0.724775740845711280f, - -0.688984851416597040f, - 0.724247082951467000f, -0.689540544737066830f, 0.723717999001323500f, - -0.690095832418599950f, - 0.723188489306527460f, -0.690650714134534600f, 0.722658554178575610f, - -0.691205189558448450f, - 0.722128193929215350f, -0.691759258364157750f, 0.721597408870443770f, - -0.692312920225718220f, - 0.721066199314508110f, -0.692866174817424630f, 0.720534565573905270f, - -0.693419021813811760f, - 0.720002507961381650f, -0.693971460889654000f, 0.719470026789932990f, - -0.694523491719965520f, - 0.718937122372804490f, -0.695075113980000880f, 0.718403795023489830f, - -0.695626327345254870f, - 0.717870045055731710f, -0.696177131491462990f, 0.717335872783521730f, - -0.696727526094601200f, - 0.716801278521099540f, -0.697277510830886520f, 0.716266262582953120f, - -0.697827085376777290f, - 0.715730825283818590f, -0.698376249408972920f, 0.715194966938680120f, - -0.698925002604414150f, - 0.714658687862769090f, -0.699473344640283770f, 0.714121988371564820f, - -0.700021275194006250f, - 0.713584868780793640f, -0.700568793943248340f, 0.713047329406429340f, - -0.701115900565918660f, - 0.712509370564692320f, -0.701662594740168450f, 0.711970992572050100f, - -0.702208876144391870f, - 0.711432195745216430f, -0.702754744457225300f, 0.710892980401151680f, - -0.703300199357548730f, - 0.710353346857062420f, -0.703845240524484940f, 0.709813295430400840f, - -0.704389867637400410f, - 0.709272826438865690f, -0.704934080375904880f, 0.708731940200400650f, - -0.705477878419852100f, - 0.708190637033195400f, -0.706021261449339740f, 0.707648917255684350f, - -0.706564229144709510f, - 0.707106781186547570f, -0.707106781186547460f, 0.706564229144709620f, - -0.707648917255684350f, - 0.706021261449339740f, -0.708190637033195290f, 0.705477878419852210f, - -0.708731940200400650f, - 0.704934080375904990f, -0.709272826438865580f, 0.704389867637400410f, - -0.709813295430400840f, - 0.703845240524484940f, -0.710353346857062310f, 0.703300199357548730f, - -0.710892980401151680f, - 0.702754744457225300f, -0.711432195745216430f, 0.702208876144391870f, - -0.711970992572049990f, - 0.701662594740168570f, -0.712509370564692320f, 0.701115900565918660f, - -0.713047329406429230f, - 0.700568793943248450f, -0.713584868780793520f, 0.700021275194006360f, - -0.714121988371564710f, - 0.699473344640283770f, -0.714658687862768980f, 0.698925002604414150f, - -0.715194966938680010f, - 0.698376249408972920f, -0.715730825283818590f, 0.697827085376777290f, - -0.716266262582953120f, - 0.697277510830886630f, -0.716801278521099540f, 0.696727526094601200f, - -0.717335872783521730f, - 0.696177131491462990f, -0.717870045055731710f, 0.695626327345254870f, - -0.718403795023489720f, - 0.695075113980000880f, -0.718937122372804380f, 0.694523491719965520f, - -0.719470026789932990f, - 0.693971460889654000f, -0.720002507961381650f, 0.693419021813811880f, - -0.720534565573905270f, - 0.692866174817424740f, -0.721066199314508110f, 0.692312920225718220f, - -0.721597408870443660f, - 0.691759258364157750f, -0.722128193929215350f, 0.691205189558448450f, - -0.722658554178575610f, - 0.690650714134534720f, -0.723188489306527350f, 0.690095832418599950f, - -0.723717999001323390f, - 0.689540544737066940f, -0.724247082951466890f, 0.688984851416597150f, - -0.724775740845711280f, - 0.688428752784090550f, -0.725303972373060660f, 0.687872249166685550f, - -0.725831777222770370f, - 0.687315340891759160f, -0.726359155084346010f, 0.686758028286925890f, - -0.726886105647544970f, - 0.686200311680038700f, -0.727412628602375770f, 0.685642191399187470f, - -0.727938723639098620f, - 0.685083667772700360f, -0.728464390448225200f, 0.684524741129142300f, - -0.728989628720519310f, - 0.683965411797315510f, -0.729514438146996900f, 0.683405680106258790f, - -0.730038818418926150f, - 0.682845546385248080f, -0.730562769227827590f, 0.682285010963795570f, - -0.731086290265474230f, - 0.681724074171649820f, -0.731609381223892520f, 0.681162736338795430f, - -0.732132041795361290f, - 0.680600997795453130f, -0.732654271672412820f, 0.680038858872079040f, - -0.733176070547832740f, - 0.679476319899365080f, -0.733697438114660260f, 0.678913381208238410f, - -0.734218374066188170f, - 0.678350043129861580f, -0.734738878095963390f, 0.677786305995631500f, - -0.735258949897786730f, - 0.677222170137180450f, -0.735778589165713480f, 0.676657635886374950f, - -0.736297795594053060f, - 0.676092703575316030f, -0.736816568877369790f, 0.675527373536338630f, - -0.737334908710482790f, - 0.674961646102012040f, -0.737852814788465980f, 0.674395521605139050f, - -0.738370286806648510f, - 0.673829000378756150f, -0.738887324460615110f, 0.673262082756132970f, - -0.739403927446205760f, - 0.672694769070772970f, -0.739920095459516090f, 0.672127059656411840f, - -0.740435828196898020f, - 0.671558954847018330f, -0.740951125354959110f, 0.670990454976794220f, - -0.741465986630563290f, - 0.670421560380173090f, -0.741980411720830960f, 0.669852271391821130f, - -0.742494400323139180f, - 0.669282588346636010f, -0.743007952135121720f, 0.668712511579748090f, - -0.743521066854669120f, - 0.668142041426518560f, -0.744033744179929180f, 0.667571178222540310f, - -0.744545983809307250f, - 0.666999922303637470f, -0.745057785441465950f, 0.666428274005865350f, - -0.745569148775325430f, - 0.665856233665509720f, -0.746080073510063780f, 0.665283801619087180f, - -0.746590559345117310f, - 0.664710978203344900f, -0.747100605980180130f, 0.664137763755260010f, - -0.747610213115205150f, - 0.663564158612039880f, -0.748119380450403490f, 0.662990163111121470f, - -0.748628107686245330f, - 0.662415777590171780f, -0.749136394523459260f, 0.661841002387086870f, - -0.749644240663033480f, - 0.661265837839992270f, -0.750151645806214960f, 0.660690284287242300f, - -0.750658609654510590f, - 0.660114342067420480f, -0.751165131909686370f, 0.659538011519338770f, - -0.751671212273768430f, - 0.658961292982037320f, -0.752176850449042700f, 0.658384186794785050f, - -0.752682046138055230f, - 0.657806693297078640f, -0.753186799043612410f, 0.657228812828642650f, - -0.753691108868781210f, - 0.656650545729429050f, -0.754194975316889170f, 0.656071892339617710f, - -0.754698398091524390f, - 0.655492852999615460f, -0.755201376896536550f, 0.654913428050056150f, - -0.755703911436035880f, - 0.654333617831800550f, -0.756206001414394540f, 0.653753422685936170f, - -0.756707646536245670f, - 0.653172842953776760f, -0.757208846506484460f, 0.652591878976862550f, - -0.757709601030268080f, - 0.652010531096959500f, -0.758209909813015280f, 0.651428799656059820f, - -0.758709772560407390f, - 0.650846684996380990f, -0.759209188978387960f, 0.650264187460365960f, - -0.759708158773163440f, - 0.649681307390683190f, -0.760206681651202420f, 0.649098045130226060f, - -0.760704757319236920f, - 0.648514401022112550f, -0.761202385484261780f, 0.647930375409685460f, - -0.761699565853535270f, - 0.647345968636512060f, -0.762196298134578900f, 0.646761181046383920f, - -0.762692582035177870f, - 0.646176012983316390f, -0.763188417263381270f, 0.645590464791548800f, - -0.763683803527501870f, - 0.645004536815544040f, -0.764178740536116670f, 0.644418229399988380f, - -0.764673227998067140f, - 0.643831542889791500f, -0.765167265622458960f, 0.643244477630085850f, - -0.765660853118662390f, - 0.642657033966226860f, -0.766153990196312810f, 0.642069212243792540f, - -0.766646676565310380f, - 0.641481012808583160f, -0.767138911935820400f, 0.640892436006621380f, - -0.767630696018273270f, - 0.640303482184151670f, -0.768122028523365310f, 0.639714151687640450f, - -0.768612909162058270f, - 0.639124444863775730f, -0.769103337645579590f, 0.638534362059466790f, - -0.769593313685422940f, - 0.637943903621844170f, -0.770082836993347900f, 0.637353069898259130f, - -0.770571907281380700f, - 0.636761861236284200f, -0.771060524261813710f, 0.636170277983712170f, - -0.771548687647206300f, - 0.635578320488556230f, -0.772036397150384410f, 0.634985989099049460f, - -0.772523652484441330f, - 0.634393284163645490f, -0.773010453362736990f, 0.633800206031017280f, - -0.773496799498899050f, - 0.633206755050057190f, -0.773982690606822790f, 0.632612931569877520f, - -0.774468126400670860f, - 0.632018735939809060f, -0.774953106594873820f, 0.631424168509401860f, - -0.775437630904130430f, - 0.630829229628424470f, -0.775921699043407580f, 0.630233919646864480f, - -0.776405310727940390f, - 0.629638238914927100f, -0.776888465673232440f, 0.629042187783036000f, - -0.777371163595056200f, - 0.628445766601832710f, -0.777853404209453040f, 0.627848975722176570f, - -0.778335187232733090f, - 0.627251815495144190f, -0.778816512381475870f, 0.626654286272029460f, - -0.779297379372530300f, - 0.626056388404343520f, -0.779777787923014440f, 0.625458122243814360f, - -0.780257737750316590f, - 0.624859488142386450f, -0.780737228572094380f, 0.624260486452220650f, - -0.781216260106276090f, - 0.623661117525694640f, -0.781694832071059390f, 0.623061381715401370f, - -0.782172944184912900f, - 0.622461279374150080f, -0.782650596166575730f, 0.621860810854965360f, - -0.783127787735057310f, - 0.621259976511087660f, -0.783604518609638200f, 0.620658776695972140f, - -0.784080788509869950f, - 0.620057211763289210f, -0.784556597155575240f, 0.619455282066924020f, - -0.785031944266848080f, - 0.618852987960976320f, -0.785506829564053930f, 0.618250329799760250f, - -0.785981252767830150f, - 0.617647307937803980f, -0.786455213599085770f, 0.617043922729849760f, - -0.786928711779001700f, - 0.616440174530853650f, -0.787401747029031320f, 0.615836063695985090f, - -0.787874319070900110f, - 0.615231590580626820f, -0.788346427626606230f, 0.614626755540375050f, - -0.788818072418420170f, - 0.614021558931038490f, -0.789289253168885650f, 0.613416001108638590f, - -0.789759969600819070f, - 0.612810082429409710f, -0.790230221437310030f, 0.612203803249798060f, - -0.790700008401721610f, - 0.611597163926462020f, -0.791169330217690090f, 0.610990164816271770f, - -0.791638186609125770f, - 0.610382806276309480f, -0.792106577300212390f, 0.609775088663868430f, - -0.792574502015407580f, - 0.609167012336453210f, -0.793041960479443640f, 0.608558577651779450f, - -0.793508952417326660f, - 0.607949784967773740f, -0.793975477554337170f, 0.607340634642572930f, - -0.794441535616030590f, - 0.606731127034524480f, -0.794907126328237010f, 0.606121262502186230f, - -0.795372249417061190f, - 0.605511041404325550f, -0.795836904608883460f, 0.604900464099919930f, - -0.796301091630359110f, - 0.604289530948156070f, -0.796764810208418720f, 0.603678242308430370f, - -0.797228060070268700f, - 0.603066598540348280f, -0.797690840943391040f, 0.602454600003723860f, - -0.798153152555543750f, - 0.601842247058580030f, -0.798614994634760820f, 0.601229540065148620f, - -0.799076366909352350f, - 0.600616479383868970f, -0.799537269107905010f, 0.600003065375389060f, - -0.799997700959281910f, - 0.599389298400564540f, -0.800457662192622710f, 0.598775178820458720f, - -0.800917152537344300f, - 0.598160706996342380f, -0.801376171723140130f, 0.597545883289693270f, - -0.801834719479981310f, - 0.596930708062196500f, -0.802292795538115720f, 0.596315181675743820f, - -0.802750399628069160f, - 0.595699304492433470f, -0.803207531480644830f, 0.595083076874569960f, - -0.803664190826924090f, - 0.594466499184664540f, -0.804120377398265700f, 0.593849571785433630f, - -0.804576090926307000f, - 0.593232295039799800f, -0.805031331142963660f, 0.592614669310891130f, - -0.805486097780429120f, - 0.591996694962040990f, -0.805940390571176280f, 0.591378372356787580f, - -0.806394209247956240f, - 0.590759701858874280f, -0.806847553543799220f, 0.590140683832248940f, - -0.807300423192014450f, - 0.589521318641063940f, -0.807752817926190360f, 0.588901606649675840f, - -0.808204737480194720f, - 0.588281548222645330f, -0.808656181588174980f, 0.587661143724736770f, - -0.809107149984558130f, - 0.587040393520918080f, -0.809557642404051260f, 0.586419297976360500f, - -0.810007658581641140f, - 0.585797857456438860f, -0.810457198252594770f, 0.585176072326730410f, - -0.810906261152459670f, - 0.584553942953015330f, -0.811354847017063730f, 0.583931469701276300f, - -0.811802955582515360f, - 0.583308652937698290f, -0.812250586585203880f, 0.582685493028668460f, - -0.812697739761799490f, - 0.582061990340775550f, -0.813144414849253590f, 0.581438145240810280f, - -0.813590611584798510f, - 0.580813958095764530f, -0.814036329705948300f, 0.580189429272831680f, - -0.814481568950498610f, - 0.579564559139405740f, -0.814926329056526620f, 0.578939348063081890f, - -0.815370609762391290f, - 0.578313796411655590f, -0.815814410806733780f, 0.577687904553122800f, - -0.816257731928477390f, - 0.577061672855679550f, -0.816700572866827850f, 0.576435101687721830f, - -0.817142933361272970f, - 0.575808191417845340f, -0.817584813151583710f, 0.575180942414845190f, - -0.818026211977813440f, - 0.574553355047715760f, -0.818467129580298660f, 0.573925429685650750f, - -0.818907565699658950f, - 0.573297166698042320f, -0.819347520076796900f, 0.572668566454481160f, - -0.819786992452898990f, - 0.572039629324757050f, -0.820225982569434690f, 0.571410355678857340f, - -0.820664490168157460f, - 0.570780745886967370f, -0.821102514991104650f, 0.570150800319470300f, - -0.821540056780597610f, - 0.569520519346947250f, -0.821977115279241550f, 0.568889903340175970f, - -0.822413690229926390f, - 0.568258952670131490f, -0.822849781375826320f, 0.567627667707986230f, - -0.823285388460400110f, - 0.566996048825108680f, -0.823720511227391320f, 0.566364096393063950f, - -0.824155149420828570f, - 0.565731810783613230f, -0.824589302785025290f, 0.565099192368714090f, - -0.825022971064580220f, - 0.564466241520519500f, -0.825456154004377440f, 0.563832958611378170f, - -0.825888851349586780f, - 0.563199344013834090f, -0.826321062845663420f, 0.562565398100626560f, - -0.826752788238348520f, - 0.561931121244689470f, -0.827184027273669020f, 0.561296513819151470f, - -0.827614779697938400f, - 0.560661576197336030f, -0.828045045257755800f, 0.560026308752760380f, - -0.828474823700007130f, - 0.559390711859136140f, -0.828904114771864870f, 0.558754785890368310f, - -0.829332918220788250f, - 0.558118531220556100f, -0.829761233794523050f, 0.557481948223991660f, - -0.830189061241102370f, - 0.556845037275160100f, -0.830616400308846200f, 0.556207798748739930f, - -0.831043250746362320f, - 0.555570233019602290f, -0.831469612302545240f, 0.554932340462810370f, - -0.831895484726577590f, - 0.554294121453620110f, -0.832320867767929680f, 0.553655576367479310f, - -0.832745761176359460f, - 0.553016705580027580f, -0.833170164701913190f, 0.552377509467096070f, - -0.833594078094925140f, - 0.551737988404707450f, -0.834017501106018130f, 0.551098142769075430f, - -0.834440433486103190f, - 0.550457972936604810f, -0.834862874986380010f, 0.549817479283891020f, - -0.835284825358337370f, - 0.549176662187719770f, -0.835706284353752600f, 0.548535522025067390f, - -0.836127251724692160f, - 0.547894059173100190f, -0.836547727223511890f, 0.547252274009174090f, - -0.836967710602857020f, - 0.546610166910834860f, -0.837387201615661940f, 0.545967738255817680f, - -0.837806200015150940f, - 0.545324988422046460f, -0.838224705554837970f, 0.544681917787634530f, - -0.838642717988527300f, - 0.544038526730883930f, -0.839060237070312630f, 0.543394815630284800f, - -0.839477262554578550f, - 0.542750784864516000f, -0.839893794195999410f, 0.542106434812444030f, - -0.840309831749540770f, - 0.541461765853123560f, -0.840725374970458070f, 0.540816778365796670f, - -0.841140423614298080f, - 0.540171472729892970f, -0.841554977436898330f, 0.539525849325029010f, - -0.841969036194387680f, - 0.538879908531008420f, -0.842382599643185960f, 0.538233650727821700f, - -0.842795667540004120f, - 0.537587076295645510f, -0.843208239641845440f, 0.536940185614843020f, - -0.843620315706004040f, - 0.536292979065963180f, -0.844031895490066410f, 0.535645457029741090f, - -0.844442978751910660f, - 0.534997619887097260f, -0.844853565249707010f, 0.534349468019137520f, - -0.845263654741918220f, - 0.533701001807152960f, -0.845673246987299070f, 0.533052221632619670f, - -0.846082341744896940f, - 0.532403127877198010f, -0.846490938774052020f, 0.531753720922733320f, - -0.846899037834397350f, - 0.531104001151255000f, -0.847306638685858320f, 0.530453968944976320f, - -0.847713741088654270f, - 0.529803624686294830f, -0.848120344803297120f, 0.529152968757790720f, - -0.848526449590592650f, - 0.528502001542228480f, -0.848932055211639610f, 0.527850723422555460f, - -0.849337161427830670f, - 0.527199134781901390f, -0.849741768000852440f, 0.526547236003579330f, - -0.850145874692685210f, - 0.525895027471084740f, -0.850549481265603370f, 0.525242509568094710f, - -0.850952587482175730f, - 0.524589682678468840f, -0.851355193105265200f, 0.523936547186248600f, - -0.851757297898029120f, - 0.523283103475656430f, -0.852158901623919830f, 0.522629351931096720f, - -0.852560004046683970f, - 0.521975292937154390f, -0.852960604930363630f, 0.521320926878595550f, - -0.853360704039295430f, - 0.520666254140367270f, -0.853760301138111300f, 0.520011275107596040f, - -0.854159395991738730f, - 0.519355990165589530f, -0.854557988365400530f, 0.518700399699835170f, - -0.854956078024614820f, - 0.518044504095999340f, -0.855353664735196030f, 0.517388303739929060f, - -0.855750748263253920f, - 0.516731799017649980f, -0.856147328375194470f, 0.516074990315366630f, - -0.856543404837719960f, - 0.515417878019463150f, -0.856938977417828650f, 0.514760462516501200f, - -0.857334045882815590f, - 0.514102744193221660f, -0.857728610000272120f, 0.513444723436543570f, - -0.858122669538086020f, - 0.512786400633563070f, -0.858516224264442740f, 0.512127776171554690f, - -0.858909273947823900f, - 0.511468850437970520f, -0.859301818357008360f, 0.510809623820439040f, - -0.859693857261072610f, - 0.510150096706766700f, -0.860085390429390140f, 0.509490269484936360f, - -0.860476417631632070f, - 0.508830142543106990f, -0.860866938637767310f, 0.508169716269614710f, - -0.861256953218062060f, - 0.507508991052970870f, -0.861646461143081300f, 0.506847967281863320f, - -0.862035462183687210f, - 0.506186645345155450f, -0.862423956111040500f, 0.505525025631885510f, - -0.862811942696600330f, - 0.504863108531267480f, -0.863199421712124160f, 0.504200894432690560f, - -0.863586392929667990f, - 0.503538383725717580f, -0.863972856121586700f, 0.502875576800086880f, - -0.864358811060534030f, - 0.502212474045710900f, -0.864744257519462380f, 0.501549075852675390f, - -0.865129195271623690f, - 0.500885382611240940f, -0.865513624090568980f, 0.500221394711840680f, - -0.865897543750148820f, - 0.499557112545081890f, -0.866280954024512990f, 0.498892536501744750f, - -0.866663854688111020f, - 0.498227666972781870f, -0.867046245515692650f, 0.497562504349319090f, - -0.867428126282306920f, - 0.496897049022654640f, -0.867809496763303210f, 0.496231301384258310f, - -0.868190356734331310f, - 0.495565261825772490f, -0.868570705971340900f, 0.494898930739011310f, - -0.868950544250582380f, - 0.494232308515959730f, -0.869329871348606730f, 0.493565395548774880f, - -0.869708687042265560f, - 0.492898192229784090f, -0.870086991108711350f, 0.492230698951486080f, - -0.870464783325397670f, - 0.491562916106550060f, -0.870842063470078860f, 0.490894844087815140f, - -0.871218831320810900f, - 0.490226483288291100f, -0.871595086655951090f, 0.489557834101157550f, - -0.871970829254157700f, - 0.488888896919763230f, -0.872346058894391540f, 0.488219672137626740f, - -0.872720775355914300f, - 0.487550160148436050f, -0.873094978418290090f, 0.486880361346047400f, - -0.873468667861384880f, - 0.486210276124486530f, -0.873841843465366750f, 0.485539904877947020f, - -0.874214505010706300f, - 0.484869248000791120f, -0.874586652278176110f, 0.484198305887549140f, - -0.874958285048851540f, - 0.483527078932918740f, -0.875329403104110780f, 0.482855567531765670f, - -0.875700006225634600f, - 0.482183772079122830f, -0.876070094195406600f, 0.481511692970189920f, - -0.876439666795713610f, - 0.480839330600333900f, -0.876808723809145760f, 0.480166685365088440f, - -0.877177265018595940f, - 0.479493757660153010f, -0.877545290207261240f, 0.478820547881394050f, - -0.877912799158641730f, - 0.478147056424843120f, -0.878279791656541460f, 0.477473283686698060f, - -0.878646267485068130f, - 0.476799230063322250f, -0.879012226428633410f, 0.476124895951243630f, - -0.879377668271953180f, - 0.475450281747155870f, -0.879742592800047410f, 0.474775387847917230f, - -0.880106999798240360f, - 0.474100214650550020f, -0.880470889052160750f, 0.473424762552241530f, - -0.880834260347742040f, - 0.472749031950342900f, -0.881197113471221980f, 0.472073023242368660f, - -0.881559448209143780f, - 0.471396736825997810f, -0.881921264348354940f, 0.470720173099071710f, - -0.882282561676008600f, - 0.470043332459595620f, -0.882643339979562790f, 0.469366215305737630f, - -0.883003599046780720f, - 0.468688822035827960f, -0.883363338665731580f, 0.468011153048359830f, - -0.883722558624789660f, - 0.467333208741988530f, -0.884081258712634990f, 0.466654989515530970f, - -0.884439438718253700f, - 0.465976495767966130f, -0.884797098430937790f, 0.465297727898434650f, - -0.885154237640285110f, - 0.464618686306237820f, -0.885510856136199950f, 0.463939371390838460f, - -0.885866953708892790f, - 0.463259783551860260f, -0.886222530148880640f, 0.462579923189086810f, - -0.886577585246987040f, - 0.461899790702462840f, -0.886932118794342080f, 0.461219386492092430f, - -0.887286130582383150f, - 0.460538710958240010f, -0.887639620402853930f, 0.459857764501329650f, - -0.887992588047805560f, - 0.459176547521944150f, -0.888345033309596240f, 0.458495060420826220f, - -0.888696955980891710f, - 0.457813303598877290f, -0.889048355854664570f, 0.457131277457156980f, - -0.889399232724195520f, - 0.456448982396883860f, -0.889749586383072890f, 0.455766418819434750f, - -0.890099416625192210f, - 0.455083587126343840f, -0.890448723244757880f, 0.454400487719303750f, - -0.890797506036281490f, - 0.453717121000163930f, -0.891145764794583180f, 0.453033487370931580f, - -0.891493499314791380f, - 0.452349587233771000f, -0.891840709392342720f, 0.451665420991002540f, - -0.892187394822982480f, - 0.450980989045103810f, -0.892533555402764690f, 0.450296291798708730f, - -0.892879190928051680f, - 0.449611329654606600f, -0.893224301195515320f, 0.448926103015743260f, - -0.893568886002136020f, - 0.448240612285220000f, -0.893912945145203250f, 0.447554857866293010f, - -0.894256478422316040f, - 0.446868840162374330f, -0.894599485631382580f, 0.446182559577030120f, - -0.894941966570620750f, - 0.445496016513981740f, -0.895283921038557580f, 0.444809211377105000f, - -0.895625348834030000f, - 0.444122144570429260f, -0.895966249756185110f, 0.443434816498138430f, - -0.896306623604479660f, - 0.442747227564570130f, -0.896646470178680150f, 0.442059378174214760f, - -0.896985789278863970f, - 0.441371268731716620f, -0.897324580705418320f, 0.440682899641873020f, - -0.897662844259040750f, - 0.439994271309633260f, -0.898000579740739880f, 0.439305384140100060f, - -0.898337786951834190f, - 0.438616238538527710f, -0.898674465693953820f, 0.437926834910322860f, - -0.899010615769039070f, - 0.437237173661044200f, -0.899346236979341460f, 0.436547255196401250f, - -0.899681329127423930f, - 0.435857079922255470f, -0.900015892016160280f, 0.435166648244619370f, - -0.900349925448735600f, - 0.434475960569655710f, -0.900683429228646860f, 0.433785017303678520f, - -0.901016403159702330f, - 0.433093818853152010f, -0.901348847046022030f, 0.432402365624690140f, - -0.901680760692037730f, - 0.431710658025057370f, -0.902012143902493070f, 0.431018696461167080f, - -0.902342996482444200f, - 0.430326481340082610f, -0.902673318237258830f, 0.429634013069016500f, - -0.903003108972617040f, - 0.428941292055329550f, -0.903332368494511820f, 0.428248318706531910f, - -0.903661096609247980f, - 0.427555093430282200f, -0.903989293123443340f, 0.426861616634386490f, - -0.904316957844028320f, - 0.426167888726799620f, -0.904644090578246240f, 0.425473910115623910f, - -0.904970691133653250f, - 0.424779681209108810f, -0.905296759318118820f, 0.424085202415651670f, - -0.905622294939825160f, - 0.423390474143796100f, -0.905947297807268460f, 0.422695496802232950f, - -0.906271767729257660f, - 0.422000270799799790f, -0.906595704514915330f, 0.421304796545479700f, - -0.906919107973678030f, - 0.420609074448402510f, -0.907241977915295930f, 0.419913104917843730f, - -0.907564314149832520f, - 0.419216888363223960f, -0.907886116487666150f, 0.418520425194109700f, - -0.908207384739488700f, - 0.417823715820212380f, -0.908528118716306120f, 0.417126760651387870f, - -0.908848318229439120f, - 0.416429560097637320f, -0.909167983090522270f, 0.415732114569105420f, - -0.909487113111505430f, - 0.415034424476081630f, -0.909805708104652220f, 0.414336490228999210f, - -0.910123767882541570f, - 0.413638312238434560f, -0.910441292258067140f, 0.412939890915108020f, - -0.910758281044437570f, - 0.412241226669883000f, -0.911074734055176250f, 0.411542319913765280f, - -0.911390651104122320f, - 0.410843171057903910f, -0.911706032005429880f, 0.410143780513590350f, - -0.912020876573568230f, - 0.409444148692257590f, -0.912335184623322750f, 0.408744276005481520f, - -0.912648955969793900f, - 0.408044162864978740f, -0.912962190428398100f, 0.407343809682607970f, - -0.913274887814867760f, - 0.406643216870369140f, -0.913587047945250810f, 0.405942384840402570f, - -0.913898670635911680f, - 0.405241314004989860f, -0.914209755703530690f, 0.404540004776553110f, - -0.914520302965104450f, - 0.403838457567654130f, -0.914830312237946090f, 0.403136672790995240f, - -0.915139783339685260f, - 0.402434650859418540f, -0.915448716088267830f, 0.401732392185905010f, - -0.915757110301956720f, - 0.401029897183575790f, -0.916064965799331610f, 0.400327166265690150f, - -0.916372282399289140f, - 0.399624199845646790f, -0.916679059921042700f, 0.398920998336983020f, - -0.916985298184122890f, - 0.398217562153373620f, -0.917290997008377910f, 0.397513891708632330f, - -0.917596156213972950f, - 0.396809987416710420f, -0.917900775621390390f, 0.396105849691696320f, - -0.918204855051430900f, - 0.395401478947816300f, -0.918508394325212250f, 0.394696875599433670f, - -0.918811393264169940f, - 0.393992040061048100f, -0.919113851690057770f, 0.393286972747296570f, - -0.919415769424946960f, - 0.392581674072951530f, -0.919717146291227360f, 0.391876144452922350f, - -0.920017982111606570f, - 0.391170384302253980f, -0.920318276709110480f, 0.390464394036126650f, - -0.920618029907083860f, - 0.389758174069856410f, -0.920917241529189520f, 0.389051724818894500f, - -0.921215911399408730f, - 0.388345046698826300f, -0.921514039342041900f, 0.387638140125372680f, - -0.921811625181708120f, - 0.386931005514388690f, -0.922108668743345070f, 0.386223643281862980f, - -0.922405169852209880f, - 0.385516053843919020f, -0.922701128333878520f, 0.384808237616812930f, - -0.922996544014246250f, - 0.384100195016935040f, -0.923291416719527640f, 0.383391926460808770f, - -0.923585746276256560f, - 0.382683432365089840f, -0.923879532511286740f, 0.381974713146567220f, - -0.924172775251791200f, - 0.381265769222162490f, -0.924465474325262600f, 0.380556601008928570f, - -0.924757629559513910f, - 0.379847208924051110f, -0.925049240782677580f, 0.379137593384847430f, - -0.925340307823206200f, - 0.378427754808765620f, -0.925630830509872720f, 0.377717693613385810f, - -0.925920808671769960f, - 0.377007410216418310f, -0.926210242138311270f, 0.376296905035704790f, - -0.926499130739230510f, - 0.375586178489217330f, -0.926787474304581750f, 0.374875230995057600f, - -0.927075272664740100f, - 0.374164062971457990f, -0.927362525650401110f, 0.373452674836780410f, - -0.927649233092581180f, - 0.372741067009515810f, -0.927935394822617890f, 0.372029239908284960f, - -0.928221010672169440f, - 0.371317193951837600f, -0.928506080473215480f, 0.370604929559051670f, - -0.928790604058057020f, - 0.369892447148934270f, -0.929074581259315750f, 0.369179747140620070f, - -0.929358011909935500f, - 0.368466829953372320f, -0.929640895843181330f, 0.367753696006582090f, - -0.929923232892639560f, - 0.367040345719767240f, -0.930205022892219070f, 0.366326779512573590f, - -0.930486265676149780f, - 0.365612997804773960f, -0.930766961078983710f, 0.364899001016267380f, - -0.931047108935595170f, - 0.364184789567079840f, -0.931326709081180430f, 0.363470363877363870f, - -0.931605761351257830f, - 0.362755724367397230f, -0.931884265581668150f, 0.362040871457584350f, - -0.932162221608574320f, - 0.361325805568454340f, -0.932439629268462360f, 0.360610527120662270f, - -0.932716488398140250f, - 0.359895036534988280f, -0.932992798834738850f, 0.359179334232336560f, - -0.933268560415712050f, - 0.358463420633736540f, -0.933543772978836170f, 0.357747296160342010f, - -0.933818436362210960f, - 0.357030961233430030f, -0.934092550404258870f, 0.356314416274402360f, - -0.934366114943725900f, - 0.355597661704783960f, -0.934639129819680780f, 0.354880697946222790f, - -0.934911594871516090f, - 0.354163525420490510f, -0.935183509938947500f, 0.353446144549480870f, - -0.935454874862014620f, - 0.352728555755210730f, -0.935725689481080370f, 0.352010759459819240f, - -0.935995953636831300f, - 0.351292756085567150f, -0.936265667170278260f, 0.350574546054837570f, - -0.936534829922755500f, - 0.349856129790135030f, -0.936803441735921560f, 0.349137507714085030f, - -0.937071502451759190f, - 0.348418680249434510f, -0.937339011912574960f, 0.347699647819051490f, - -0.937605969960999990f, - 0.346980410845923680f, -0.937872376439989890f, 0.346260969753160170f, - -0.938138231192824360f, - 0.345541324963989150f, -0.938403534063108060f, 0.344821476901759290f, - -0.938668284894770170f, - 0.344101425989938980f, -0.938932483532064490f, 0.343381172652115100f, - -0.939196129819569900f, - 0.342660717311994380f, -0.939459223602189920f, 0.341940060393402300f, - -0.939721764725153340f, - 0.341219202320282410f, -0.939983753034013940f, 0.340498143516697100f, - -0.940245188374650880f, - 0.339776884406826960f, -0.940506070593268300f, 0.339055425414969640f, - -0.940766399536396070f, - 0.338333766965541290f, -0.941026175050889260f, 0.337611909483074680f, - -0.941285396983928660f, - 0.336889853392220050f, -0.941544065183020810f, 0.336167599117744690f, - -0.941802179495997650f, - 0.335445147084531660f, -0.942059739771017310f, 0.334722497717581220f, - -0.942316745856563780f, - 0.333999651442009490f, -0.942573197601446870f, 0.333276608683047980f, - -0.942829094854802710f, - 0.332553369866044220f, -0.943084437466093490f, 0.331829935416461220f, - -0.943339225285107720f, - 0.331106305759876430f, -0.943593458161960390f, 0.330382481321982950f, - -0.943847135947092690f, - 0.329658462528587550f, -0.944100258491272660f, 0.328934249805612200f, - -0.944352825645594750f, - 0.328209843579092660f, -0.944604837261480260f, 0.327485244275178060f, - -0.944856293190677210f, - 0.326760452320131790f, -0.945107193285260610f, 0.326035468140330350f, - -0.945357537397632290f, - 0.325310292162262980f, -0.945607325380521280f, 0.324584924812532150f, - -0.945856557086983910f, - 0.323859366517852960f, -0.946105232370403340f, 0.323133617705052330f, - -0.946353351084490590f, - 0.322407678801070020f, -0.946600913083283530f, 0.321681550232956640f, - -0.946847918221148000f, - 0.320955232427875210f, -0.947094366352777220f, 0.320228725813100020f, - -0.947340257333191940f, - 0.319502030816015750f, -0.947585591017741090f, 0.318775147864118480f, - -0.947830367262101010f, - 0.318048077385015060f, -0.948074585922276230f, 0.317320819806421790f, - -0.948318246854599090f, - 0.316593375556165850f, -0.948561349915730270f, 0.315865745062184070f, - -0.948803894962658380f, - 0.315137928752522440f, -0.949045881852700560f, 0.314409927055336820f, - -0.949287310443502010f, - 0.313681740398891570f, -0.949528180593036670f, 0.312953369211560200f, - -0.949768492159606680f, - 0.312224813921825050f, -0.950008245001843000f, 0.311496074958275970f, - -0.950247438978705230f, - 0.310767152749611470f, -0.950486073949481700f, 0.310038047724638000f, - -0.950724149773789610f, - 0.309308760312268780f, -0.950961666311575080f, 0.308579290941525030f, - -0.951198623423113230f, - 0.307849640041534980f, -0.951435020969008340f, 0.307119808041533100f, - -0.951670858810193860f, - 0.306389795370861080f, -0.951906136807932230f, 0.305659602458966230f, - -0.952140854823815830f, - 0.304929229735402430f, -0.952375012719765880f, 0.304198677629829270f, - -0.952608610358033240f, - 0.303467946572011370f, -0.952841647601198720f, 0.302737036991819140f, - -0.953074124312172200f, - 0.302005949319228200f, -0.953306040354193750f, 0.301274683984318000f, - -0.953537395590833280f, - 0.300543241417273400f, -0.953768189885990330f, 0.299811622048383460f, - -0.953998423103894490f, - 0.299079826308040480f, -0.954228095109105670f, 0.298347854626741570f, - -0.954457205766513490f, - 0.297615707435086310f, -0.954685754941338340f, 0.296883385163778270f, - -0.954913742499130520f, - 0.296150888243623960f, -0.955141168305770670f, 0.295418217105532070f, - -0.955368032227470240f, - 0.294685372180514330f, -0.955594334130771110f, 0.293952353899684770f, - -0.955820073882545420f, - 0.293219162694258680f, -0.956045251349996410f, 0.292485798995553830f, - -0.956269866400658140f, - 0.291752263234989370f, -0.956493918902394990f, 0.291018555844085090f, - -0.956717408723403050f, - 0.290284677254462330f, -0.956940335732208940f, 0.289550627897843140f, - -0.957162699797670100f, - 0.288816408206049480f, -0.957384500788975860f, 0.288082018611004300f, - -0.957605738575646240f, - 0.287347459544729570f, -0.957826413027532910f, 0.286612731439347790f, - -0.958046524014818600f, - 0.285877834727080730f, -0.958266071408017670f, 0.285142769840248720f, - -0.958485055077976100f, - 0.284407537211271820f, -0.958703474895871600f, 0.283672137272668550f, - -0.958921330733213060f, - 0.282936570457055390f, -0.959138622461841890f, 0.282200837197147500f, - -0.959355349953930790f, - 0.281464937925758050f, -0.959571513081984520f, 0.280728873075797190f, - -0.959787111718839900f, - 0.279992643080273380f, -0.960002145737665850f, 0.279256248372291240f, - -0.960216615011963430f, - 0.278519689385053060f, -0.960430519415565790f, 0.277782966551857800f, - -0.960643858822638470f, - 0.277046080306099950f, -0.960856633107679660f, 0.276309031081271030f, - -0.961068842145519350f, - 0.275571819310958250f, -0.961280485811320640f, 0.274834445428843940f, - -0.961491563980579000f, - 0.274096909868706330f, -0.961702076529122540f, 0.273359213064418790f, - -0.961912023333112100f, - 0.272621355449948980f, -0.962121404269041580f, 0.271883337459359890f, - -0.962330219213737400f, - 0.271145159526808070f, -0.962538468044359160f, 0.270406822086544820f, - -0.962746150638399410f, - 0.269668325572915200f, -0.962953266873683880f, 0.268929670420357310f, - -0.963159816628371360f, - 0.268190857063403180f, -0.963365799780954050f, 0.267451885936677740f, - -0.963571216210257210f, - 0.266712757474898420f, -0.963776065795439840f, 0.265973472112875530f, - -0.963980348415994110f, - 0.265234030285511900f, -0.964184063951745720f, 0.264494432427801630f, - -0.964387212282854290f, - 0.263754678974831510f, -0.964589793289812650f, 0.263014770361779060f, - -0.964791806853447900f, - 0.262274707023913590f, -0.964993252854920320f, 0.261534489396595630f, - -0.965194131175724720f, - 0.260794117915275570f, -0.965394441697689400f, 0.260053593015495130f, - -0.965594184302976830f, - 0.259312915132886350f, -0.965793358874083570f, 0.258572084703170390f, - -0.965991965293840570f, - 0.257831102162158930f, -0.966190003445412620f, 0.257089967945753230f, - -0.966387473212298790f, - 0.256348682489942910f, -0.966584374478333120f, 0.255607246230807550f, - -0.966780707127683270f, - 0.254865659604514630f, -0.966976471044852070f, 0.254123923047320620f, - -0.967171666114676640f, - 0.253382036995570270f, -0.967366292222328510f, 0.252640001885695580f, - -0.967560349253314360f, - 0.251897818154216910f, -0.967753837093475510f, 0.251155486237742030f, - -0.967946755628987800f, - 0.250413006572965280f, -0.968139104746362330f, 0.249670379596668520f, - -0.968330884332445300f, - 0.248927605745720260f, -0.968522094274417270f, 0.248184685457074780f, - -0.968712734459794780f, - 0.247441619167773440f, -0.968902804776428870f, 0.246698407314942500f, - -0.969092305112506100f, - 0.245955050335794590f, -0.969281235356548530f, 0.245211548667627680f, - -0.969469595397412950f, - 0.244467902747824210f, -0.969657385124292450f, 0.243724113013852130f, - -0.969844604426714830f, - 0.242980179903263980f, -0.970031253194543970f, 0.242236103853696070f, - -0.970217331317979160f, - 0.241491885302869300f, -0.970402838687555500f, 0.240747524688588540f, - -0.970587775194143630f, - 0.240003022448741500f, -0.970772140728950350f, 0.239258379021300120f, - -0.970955935183517970f, - 0.238513594844318500f, -0.971139158449725090f, 0.237768670355934210f, - -0.971321810419786160f, - 0.237023605994367340f, -0.971503890986251780f, 0.236278402197919620f, - -0.971685400042008540f, - 0.235533059404975460f, -0.971866337480279400f, 0.234787578054001080f, - -0.972046703194623500f, - 0.234041958583543460f, -0.972226497078936270f, 0.233296201432231560f, - -0.972405719027449770f, - 0.232550307038775330f, -0.972584368934732210f, 0.231804275841964780f, - -0.972762446695688570f, - 0.231058108280671280f, -0.972939952205560070f, 0.230311804793845530f, - -0.973116885359925130f, - 0.229565365820518870f, -0.973293246054698250f, 0.228818791799802360f, - -0.973469034186130950f, - 0.228072083170885790f, -0.973644249650811870f, 0.227325240373038830f, - -0.973818892345666100f, - 0.226578263845610110f, -0.973992962167955830f, 0.225831154028026200f, - -0.974166459015280320f, - 0.225083911359792780f, -0.974339382785575860f, 0.224336536280493690f, - -0.974511733377115720f, - 0.223589029229790020f, -0.974683510688510670f, 0.222841390647421280f, - -0.974854714618708430f, - 0.222093620973203590f, -0.975025345066994120f, 0.221345720647030810f, - -0.975195401932990370f, - 0.220597690108873650f, -0.975364885116656870f, 0.219849529798778750f, - -0.975533794518291360f, - 0.219101240156869770f, -0.975702130038528570f, 0.218352821623346430f, - -0.975869891578341030f, - 0.217604274638483670f, -0.976037079039039020f, 0.216855599642632570f, - -0.976203692322270560f, - 0.216106797076219600f, -0.976369731330021140f, 0.215357867379745550f, - -0.976535195964614470f, - 0.214608810993786920f, -0.976700086128711840f, 0.213859628358993830f, - -0.976864401725312640f, - 0.213110319916091360f, -0.977028142657754390f, 0.212360886105878580f, - -0.977191308829712280f, - 0.211611327369227610f, -0.977353900145199960f, 0.210861644147084830f, - -0.977515916508569280f, - 0.210111836880469720f, -0.977677357824509930f, 0.209361906010474190f, - -0.977838223998050430f, - 0.208611851978263460f, -0.977998514934557140f, 0.207861675225075150f, - -0.978158230539735050f, - 0.207111376192218560f, -0.978317370719627650f, 0.206360955321075680f, - -0.978475935380616830f, - 0.205610413053099320f, -0.978633924429423100f, 0.204859749829814420f, - -0.978791337773105670f, - 0.204108966092817010f, -0.978948175319062200f, 0.203358062283773370f, - -0.979104436975029250f, - 0.202607038844421110f, -0.979260122649082020f, 0.201855896216568160f, - -0.979415232249634780f, - 0.201104634842091960f, -0.979569765685440520f, 0.200353255162940420f, - -0.979723722865591170f, - 0.199601757621131050f, -0.979877103699517640f, 0.198850142658750120f, - -0.980029908096989980f, - 0.198098410717953730f, -0.980182135968117320f, 0.197346562240966000f, - -0.980333787223347960f, - 0.196594597670080220f, -0.980484861773469380f, 0.195842517447657990f, - -0.980635359529608120f, - 0.195090322016128330f, -0.980785280403230430f, 0.194338011817988600f, - -0.980934624306141640f, - 0.193585587295803750f, -0.981083391150486590f, 0.192833048892205290f, - -0.981231580848749730f, - 0.192080397049892380f, -0.981379193313754560f, 0.191327632211630990f, - -0.981526228458664660f, - 0.190574754820252800f, -0.981672686196983110f, 0.189821765318656580f, - -0.981818566442552500f, - 0.189068664149806280f, -0.981963869109555240f, 0.188315451756732120f, - -0.982108594112513610f, - 0.187562128582529740f, -0.982252741366289370f, 0.186808695070359330f, - -0.982396310786084690f, - 0.186055151663446630f, -0.982539302287441240f, 0.185301498805082040f, - -0.982681715786240860f, - 0.184547736938619640f, -0.982823551198705240f, 0.183793866507478390f, - -0.982964808441396440f, - 0.183039887955141060f, -0.983105487431216290f, 0.182285801725153320f, - -0.983245588085407070f, - 0.181531608261125130f, -0.983385110321551180f, 0.180777308006728670f, - -0.983524054057571260f, - 0.180022901405699510f, -0.983662419211730250f, 0.179268388901835880f, - -0.983800205702631490f, - 0.178513770938997590f, -0.983937413449218920f, 0.177759047961107140f, - -0.984074042370776450f, - 0.177004220412148860f, -0.984210092386929030f, 0.176249288736167940f, - -0.984345563417641900f, - 0.175494253377271400f, -0.984480455383220930f, 0.174739114779627310f, - -0.984614768204312600f, - 0.173983873387463850f, -0.984748501801904210f, 0.173228529645070490f, - -0.984881656097323700f, - 0.172473083996796030f, -0.985014231012239840f, 0.171717536887049970f, - -0.985146226468662230f, - 0.170961888760301360f, -0.985277642388941220f, 0.170206140061078120f, - -0.985408478695768420f, - 0.169450291233967930f, -0.985538735312176060f, 0.168694342723617440f, - -0.985668412161537550f, - 0.167938294974731230f, -0.985797509167567370f, 0.167182148432072880f, - -0.985926026254321130f, - 0.166425903540464220f, -0.986053963346195440f, 0.165669560744784140f, - -0.986181320367928270f, - 0.164913120489970090f, -0.986308097244598670f, 0.164156583221015890f, - -0.986434293901627070f, - 0.163399949382973230f, -0.986559910264775410f, 0.162643219420950450f, - -0.986684946260146690f, - 0.161886393780111910f, -0.986809401814185420f, 0.161129472905678780f, - -0.986933276853677710f, - 0.160372457242928400f, -0.987056571305750970f, 0.159615347237193090f, - -0.987179285097874340f, - 0.158858143333861390f, -0.987301418157858430f, 0.158100845978377090f, - -0.987422970413855410f, - 0.157343455616238280f, -0.987543941794359230f, 0.156585972692998590f, - -0.987664332228205710f, - 0.155828397654265320f, -0.987784141644572180f, 0.155070730945700510f, - -0.987903369972977790f, - 0.154312973013020240f, -0.988022017143283530f, 0.153555124301993500f, - -0.988140083085692570f, - 0.152797185258443410f, -0.988257567730749460f, 0.152039156328246160f, - -0.988374471009341280f, - 0.151281037957330250f, -0.988490792852696590f, 0.150522830591677370f, - -0.988606533192386450f, - 0.149764534677321620f, -0.988721691960323780f, 0.149006150660348470f, - -0.988836269088763540f, - 0.148247678986896200f, -0.988950264510302990f, 0.147489120103153680f, - -0.989063678157881540f, - 0.146730474455361750f, -0.989176509964781010f, 0.145971742489812370f, - -0.989288759864625170f, - 0.145212924652847520f, -0.989400427791380380f, 0.144454021390860440f, - -0.989511513679355190f, - 0.143695033150294580f, -0.989622017463200780f, 0.142935960377642700f, - -0.989731939077910570f, - 0.142176803519448000f, -0.989841278458820530f, 0.141417563022303130f, - -0.989950035541608990f, - 0.140658239332849240f, -0.990058210262297120f, 0.139898832897777380f, - -0.990165802557248400f, - 0.139139344163826280f, -0.990272812363169110f, 0.138379773577783890f, - -0.990379239617108160f, - 0.137620121586486180f, -0.990485084256456980f, 0.136860388636816430f, - -0.990590346218950150f, - 0.136100575175706200f, -0.990695025442664630f, 0.135340681650134330f, - -0.990799121866020370f, - 0.134580708507126220f, -0.990902635427780010f, 0.133820656193754690f, - -0.991005566067049370f, - 0.133060525157139180f, -0.991107913723276780f, 0.132300315844444680f, - -0.991209678336254060f, - 0.131540028702883280f, -0.991310859846115440f, 0.130779664179711790f, - -0.991411458193338540f, - 0.130019222722233350f, -0.991511473318743900f, 0.129258704777796270f, - -0.991610905163495370f, - 0.128498110793793220f, -0.991709753669099530f, 0.127737441217662280f, - -0.991808018777406430f, - 0.126976696496885980f, -0.991905700430609330f, 0.126215877078990400f, - -0.992002798571244520f, - 0.125454983411546210f, -0.992099313142191800f, 0.124694015942167770f, - -0.992195244086673920f, - 0.123932975118512200f, -0.992290591348257370f, 0.123171861388280650f, - -0.992385354870851670f, - 0.122410675199216280f, -0.992479534598709970f, 0.121649416999105540f, - -0.992573130476428810f, - 0.120888087235777220f, -0.992666142448948020f, 0.120126686357101580f, - -0.992758570461551140f, - 0.119365214810991350f, -0.992850414459865100f, 0.118603673045400840f, - -0.992941674389860470f, - 0.117842061508325020f, -0.993032350197851410f, 0.117080380647800550f, - -0.993122441830495580f, - 0.116318630911904880f, -0.993211949234794500f, 0.115556812748755290f, - -0.993300872358093280f, - 0.114794926606510250f, -0.993389211148080650f, 0.114032972933367300f, - -0.993476965552789190f, - 0.113270952177564360f, -0.993564135520595300f, 0.112508864787378830f, - -0.993650721000219120f, - 0.111746711211126660f, -0.993736721940724600f, 0.110984491897163380f, - -0.993822138291519660f, - 0.110222207293883180f, -0.993906970002356060f, 0.109459857849718030f, - -0.993991217023329380f, - 0.108697444013138670f, -0.994074879304879370f, 0.107934966232653760f, - -0.994157956797789730f, - 0.107172424956808870f, -0.994240449453187900f, 0.106409820634187840f, - -0.994322357222545810f, - 0.105647153713410700f, -0.994403680057679100f, 0.104884424643134970f, - -0.994484417910747600f, - 0.104121633872054730f, -0.994564570734255420f, 0.103358781848899700f, - -0.994644138481050710f, - 0.102595869022436280f, -0.994723121104325700f, 0.101832895841466670f, - -0.994801518557617110f, - 0.101069862754827880f, -0.994879330794805620f, 0.100306770211392820f, - -0.994956557770116380f, - 0.099543618660069444f, -0.995033199438118630f, 0.098780408549799664f, - -0.995109255753726110f, - 0.098017140329560770f, -0.995184726672196820f, 0.097253814448363354f, - -0.995259612149133390f, - 0.096490431355252607f, -0.995333912140482280f, 0.095726991499307315f, - -0.995407626602534900f, - 0.094963495329639061f, -0.995480755491926940f, 0.094199943295393190f, - -0.995553298765638470f, - 0.093436335845747912f, -0.995625256380994310f, 0.092672673429913366f, - -0.995696628295663520f, - 0.091908956497132696f, -0.995767414467659820f, 0.091145185496681130f, - -0.995837614855341610f, - 0.090381360877865011f, -0.995907229417411720f, 0.089617483090022917f, - -0.995976258112917790f, - 0.088853552582524684f, -0.996044700901251970f, 0.088089569804770507f, - -0.996112557742151130f, - 0.087325535206192226f, -0.996179828595696870f, 0.086561449236251239f, - -0.996246513422315520f, - 0.085797312344439880f, -0.996312612182778000f, 0.085033124980280414f, - -0.996378124838200210f, - 0.084268887593324127f, -0.996443051350042630f, 0.083504600633152404f, - -0.996507391680110820f, - 0.082740264549375803f, -0.996571145790554840f, 0.081975879791633108f, - -0.996634313643869900f, - 0.081211446809592386f, -0.996696895202896060f, 0.080446966052950097f, - -0.996758890430818000f, - 0.079682437971430126f, -0.996820299291165670f, 0.078917863014785095f, - -0.996881121747813850f, - 0.078153241632794315f, -0.996941357764982160f, 0.077388574275265049f, - -0.997001007307235290f, - 0.076623861392031617f, -0.997060070339482960f, 0.075859103432954503f, - -0.997118546826979980f, - 0.075094300847921291f, -0.997176436735326190f, 0.074329454086845867f, - -0.997233740030466160f, - 0.073564563599667454f, -0.997290456678690210f, 0.072799629836351618f, - -0.997346586646633230f, - 0.072034653246889416f, -0.997402129901275300f, 0.071269634281296415f, - -0.997457086409941910f, - 0.070504573389614009f, -0.997511456140303450f, 0.069739471021907376f, - -0.997565239060375750f, - 0.068974327628266732f, -0.997618435138519550f, 0.068209143658806454f, - -0.997671044343441000f, - 0.067443919563664106f, -0.997723066644191640f, 0.066678655793001543f, - -0.997774502010167820f, - 0.065913352797003930f, -0.997825350411111640f, 0.065148011025878860f, - -0.997875611817110150f, - 0.064382630929857410f, -0.997925286198596000f, 0.063617212959193190f, - -0.997974373526346990f, - 0.062851757564161420f, -0.998022873771486240f, 0.062086265195060247f, - -0.998070786905482340f, - 0.061320736302208648f, -0.998118112900149180f, 0.060555171335947781f, - -0.998164851727646240f, - 0.059789570746640007f, -0.998211003360478190f, 0.059023934984667986f, - -0.998256567771495180f, - 0.058258264500435732f, -0.998301544933892890f, 0.057492559744367684f, - -0.998345934821212370f, - 0.056726821166907783f, -0.998389737407340160f, 0.055961049218520520f, - -0.998432952666508440f, - 0.055195244349690031f, -0.998475580573294770f, 0.054429407010919147f, - -0.998517621102622210f, - 0.053663537652730679f, -0.998559074229759310f, 0.052897636725665401f, - -0.998599939930320370f, - 0.052131704680283317f, -0.998640218180265270f, 0.051365741967162731f, - -0.998679908955899090f, - 0.050599749036899337f, -0.998719012233872940f, 0.049833726340107257f, - -0.998757527991183340f, - 0.049067674327418126f, -0.998795456205172410f, 0.048301593449480172f, - -0.998832796853527990f, - 0.047535484156959261f, -0.998869549914283560f, 0.046769346900537960f, - -0.998905715365818290f, - 0.046003182130914644f, -0.998941293186856870f, 0.045236990298804750f, - -0.998976283356469820f, - 0.044470771854938744f, -0.999010685854073380f, 0.043704527250063421f, - -0.999044500659429290f, - 0.042938256934940959f, -0.999077727752645360f, 0.042171961360348002f, - -0.999110367114174890f, - 0.041405640977076712f, -0.999142418724816910f, 0.040639296235933854f, - -0.999173882565716380f, - 0.039872927587739845f, -0.999204758618363890f, 0.039106535483329839f, - -0.999235046864595850f, - 0.038340120373552791f, -0.999264747286594420f, 0.037573682709270514f, - -0.999293859866887790f, - 0.036807222941358991f, -0.999322384588349540f, 0.036040741520706299f, - -0.999350321434199440f, - 0.035274238898213947f, -0.999377670388002850f, 0.034507715524795889f, - -0.999404431433671300f, - 0.033741171851377642f, -0.999430604555461730f, 0.032974608328897315f, - -0.999456189737977340f, - 0.032208025408304704f, -0.999481186966166950f, 0.031441423540560343f, - -0.999505596225325310f, - 0.030674803176636581f, -0.999529417501093140f, 0.029908164767516655f, - -0.999552650779456990f, - 0.029141508764193740f, -0.999575296046749220f, 0.028374835617672258f, - -0.999597353289648380f, - 0.027608145778965820f, -0.999618822495178640f, 0.026841439699098527f, - -0.999639703650710200f, - 0.026074717829104040f, -0.999659996743959220f, 0.025307980620024630f, - -0.999679701762987930f, - 0.024541228522912264f, -0.999698818696204250f, 0.023774461988827676f, - -0.999717347532362190f, - 0.023007681468839410f, -0.999735288260561680f, 0.022240887414024919f, - -0.999752640870248840f, - 0.021474080275469605f, -0.999769405351215280f, 0.020707260504265912f, - -0.999785581693599210f, - 0.019940428551514598f, -0.999801169887884260f, 0.019173584868322699f, - -0.999816169924900410f, - 0.018406729905804820f, -0.999830581795823400f, 0.017639864115082195f, - -0.999844405492175240f, - 0.016872987947281773f, -0.999857641005823860f, 0.016106101853537263f, - -0.999870288328982950f, - 0.015339206284988220f, -0.999882347454212560f, 0.014572301692779104f, - -0.999893818374418490f, - 0.013805388528060349f, -0.999904701082852900f, 0.013038467241987433f, - -0.999914995573113470f, - 0.012271538285719944f, -0.999924701839144500f, 0.011504602110422875f, - -0.999933819875236000f, - 0.010737659167264572f, -0.999942349676023910f, 0.009970709907418029f, - -0.999950291236490480f, - 0.009203754782059960f, -0.999957644551963900f, 0.008436794242369860f, - -0.999964409618118280f, - 0.007669828739531077f, -0.999970586430974140f, 0.006902858724729877f, - -0.999976174986897610f, - 0.006135884649154515f, -0.999981175282601110f, 0.005368906963996303f, - -0.999985587315143200f, - 0.004601926120448672f, -0.999989411081928400f, 0.003834942569706248f, - -0.999992646580707190f, - 0.003067956762966138f, -0.999995293809576190f, 0.002300969151425887f, - -0.999997352766978210f, - 0.001533980186284766f, -0.999998823451701880f, 0.000766990318742846f, - -0.999999705862882230f -}; + 1.000000000000000000f, 0.000000000000000000f, 0.999999705862882230f, + -0.000766990318742704f, 0.999998823451701880f, -0.001533980186284766f, + 0.999997352766978210f, -0.002300969151425805f, 0.999995293809576190f, + -0.003067956762965976f, 0.999992646580707190f, -0.003834942569706228f, + 0.999989411081928400f, -0.004601926120448571f, 0.999985587315143200f, + -0.005368906963996343f, 0.999981175282601110f, -0.006135884649154475f, + 0.999976174986897610f, -0.006902858724729756f, 0.999970586430974140f, + -0.007669828739531097f, 0.999964409618118280f, -0.008436794242369799f, + 0.999957644551963900f, -0.009203754782059819f, 0.999950291236490480f, + -0.009970709907418031f, 0.999942349676023910f, -0.010737659167264491f, + 0.999933819875236000f, -0.011504602110422714f, 0.999924701839144500f, + -0.012271538285719925f, 0.999914995573113470f, -0.013038467241987334f, + 0.999904701082852900f, -0.013805388528060391f, 0.999893818374418490f, + -0.014572301692779064f, 0.999882347454212560f, -0.015339206284988100f, + 0.999870288328982950f, -0.016106101853537287f, 0.999857641005823860f, + -0.016872987947281710f, 0.999844405492175240f, -0.017639864115082053f, + 0.999830581795823400f, -0.018406729905804820f, 0.999816169924900410f, + -0.019173584868322623f, 0.999801169887884260f, -0.019940428551514441f, + 0.999785581693599210f, -0.020707260504265895f, 0.999769405351215280f, + -0.021474080275469508f, 0.999752640870248840f, -0.022240887414024961f, + 0.999735288260561680f, -0.023007681468839369f, 0.999717347532362190f, + -0.023774461988827555f, 0.999698818696204250f, -0.024541228522912288f, + 0.999679701762987930f, -0.025307980620024571f, 0.999659996743959220f, + -0.026074717829103901f, 0.999639703650710200f, -0.026841439699098531f, + 0.999618822495178640f, -0.027608145778965740f, 0.999597353289648380f, + -0.028374835617672099f, 0.999575296046749220f, -0.029141508764193722f, + 0.999552650779456990f, -0.029908164767516555f, 0.999529417501093140f, + -0.030674803176636626f, 0.999505596225325310f, -0.031441423540560301f, + 0.999481186966166950f, -0.032208025408304586f, 0.999456189737977340f, + -0.032974608328897335f, 0.999430604555461730f, -0.033741171851377580f, + 0.999404431433671300f, -0.034507715524795750f, 0.999377670388002850f, + -0.035274238898213947f, 0.999350321434199440f, -0.036040741520706229f, + 0.999322384588349540f, -0.036807222941358832f, 0.999293859866887790f, + -0.037573682709270494f, 0.999264747286594420f, -0.038340120373552694f, + 0.999235046864595850f, -0.039106535483329888f, 0.999204758618363890f, + -0.039872927587739811f, 0.999173882565716380f, -0.040639296235933736f, + 0.999142418724816910f, -0.041405640977076739f, 0.999110367114174890f, + -0.042171961360347947f, 0.999077727752645360f, -0.042938256934940820f, + 0.999044500659429290f, -0.043704527250063421f, 0.999010685854073380f, + -0.044470771854938668f, 0.998976283356469820f, -0.045236990298804590f, + 0.998941293186856870f, -0.046003182130914623f, 0.998905715365818290f, + -0.046769346900537863f, 0.998869549914283560f, -0.047535484156959303f, + 0.998832796853527990f, -0.048301593449480144f, 0.998795456205172410f, + -0.049067674327418015f, 0.998757527991183340f, -0.049833726340107277f, + 0.998719012233872940f, -0.050599749036899282f, 0.998679908955899090f, + -0.051365741967162593f, 0.998640218180265270f, -0.052131704680283324f, + 0.998599939930320370f, -0.052897636725665324f, 0.998559074229759310f, + -0.053663537652730520f, 0.998517621102622210f, -0.054429407010919133f, + 0.998475580573294770f, -0.055195244349689934f, 0.998432952666508440f, + -0.055961049218520569f, 0.998389737407340160f, -0.056726821166907748f, + 0.998345934821212370f, -0.057492559744367566f, 0.998301544933892890f, + -0.058258264500435752f, 0.998256567771495180f, -0.059023934984667931f, + 0.998211003360478190f, -0.059789570746639868f, 0.998164851727646240f, + -0.060555171335947788f, 0.998118112900149180f, -0.061320736302208578f, + 0.998070786905482340f, -0.062086265195060088f, 0.998022873771486240f, + -0.062851757564161406f, 0.997974373526346990f, -0.063617212959193106f, + 0.997925286198596000f, -0.064382630929857465f, 0.997875611817110150f, + -0.065148011025878833f, 0.997825350411111640f, -0.065913352797003805f, + 0.997774502010167820f, -0.066678655793001557f, 0.997723066644191640f, + -0.067443919563664051f, 0.997671044343441000f, -0.068209143658806329f, + 0.997618435138519550f, -0.068974327628266746f, 0.997565239060375750f, + -0.069739471021907307f, 0.997511456140303450f, -0.070504573389613856f, + 0.997457086409941910f, -0.071269634281296401f, 0.997402129901275300f, + -0.072034653246889332f, 0.997346586646633230f, -0.072799629836351673f, + 0.997290456678690210f, -0.073564563599667426f, 0.997233740030466280f, + -0.074329454086845756f, 0.997176436735326190f, -0.075094300847921305f, + 0.997118546826979980f, -0.075859103432954447f, 0.997060070339482960f, + -0.076623861392031492f, 0.997001007307235290f, -0.077388574275265049f, + 0.996941357764982160f, -0.078153241632794232f, 0.996881121747813850f, + -0.078917863014784942f, 0.996820299291165670f, -0.079682437971430126f, + 0.996758890430818000f, -0.080446966052950014f, 0.996696895202896060f, + -0.081211446809592441f, 0.996634313643869900f, -0.081975879791633066f, + 0.996571145790554840f, -0.082740264549375692f, 0.996507391680110820f, + -0.083504600633152432f, 0.996443051350042630f, -0.084268887593324071f, + 0.996378124838200210f, -0.085033124980280275f, 0.996312612182778000f, + -0.085797312344439894f, 0.996246513422315520f, -0.086561449236251170f, + 0.996179828595696980f, -0.087325535206192059f, 0.996112557742151130f, + -0.088089569804770507f, 0.996044700901251970f, -0.088853552582524600f, + 0.995976258112917790f, -0.089617483090022959f, 0.995907229417411720f, + -0.090381360877864983f, 0.995837614855341610f, -0.091145185496681005f, + 0.995767414467659820f, -0.091908956497132724f, 0.995696628295663520f, + -0.092672673429913310f, 0.995625256380994310f, -0.093436335845747787f, + 0.995553298765638470f, -0.094199943295393204f, 0.995480755491926940f, + -0.094963495329638992f, 0.995407626602534900f, -0.095726991499307162f, + 0.995333912140482280f, -0.096490431355252593f, 0.995259612149133390f, + -0.097253814448363271f, 0.995184726672196930f, -0.098017140329560604f, + 0.995109255753726110f, -0.098780408549799623f, 0.995033199438118630f, + -0.099543618660069319f, 0.994956557770116380f, -0.100306770211392860f, + 0.994879330794805620f, -0.101069862754827820f, 0.994801518557617110f, + -0.101832895841466530f, 0.994723121104325700f, -0.102595869022436280f, + 0.994644138481050710f, -0.103358781848899610f, 0.994564570734255420f, + -0.104121633872054590f, 0.994484417910747600f, -0.104884424643134970f, + 0.994403680057679100f, -0.105647153713410620f, 0.994322357222545810f, + -0.106409820634187680f, 0.994240449453187900f, -0.107172424956808840f, + 0.994157956797789730f, -0.107934966232653650f, 0.994074879304879370f, + -0.108697444013138720f, 0.993991217023329380f, -0.109459857849717980f, + 0.993906970002356060f, -0.110222207293883060f, 0.993822138291519660f, + -0.110984491897163390f, 0.993736721940724600f, -0.111746711211126590f, + 0.993650721000219120f, -0.112508864787378690f, 0.993564135520595300f, + -0.113270952177564350f, 0.993476965552789190f, -0.114032972933367200f, + 0.993389211148080650f, -0.114794926606510080f, 0.993300872358093280f, + -0.115556812748755260f, 0.993211949234794500f, -0.116318630911904750f, + 0.993122441830495580f, -0.117080380647800590f, 0.993032350197851410f, + -0.117842061508324980f, 0.992941674389860470f, -0.118603673045400720f, + 0.992850414459865100f, -0.119365214810991350f, 0.992758570461551140f, + -0.120126686357101500f, 0.992666142448948020f, -0.120888087235777080f, + 0.992573130476428810f, -0.121649416999105530f, 0.992479534598709970f, + -0.122410675199216200f, 0.992385354870851670f, -0.123171861388280480f, + 0.992290591348257370f, -0.123932975118512160f, 0.992195244086673920f, + -0.124694015942167640f, 0.992099313142191800f, -0.125454983411546230f, + 0.992002798571244520f, -0.126215877078990350f, 0.991905700430609330f, + -0.126976696496885870f, 0.991808018777406430f, -0.127737441217662310f, + 0.991709753669099530f, -0.128498110793793170f, 0.991610905163495370f, + -0.129258704777796140f, 0.991511473318743900f, -0.130019222722233350f, + 0.991411458193338540f, -0.130779664179711710f, 0.991310859846115440f, + -0.131540028702883120f, 0.991209678336254060f, -0.132300315844444650f, + 0.991107913723276890f, -0.133060525157139060f, 0.991005566067049370f, + -0.133820656193754720f, 0.990902635427780010f, -0.134580708507126170f, + 0.990799121866020370f, -0.135340681650134210f, 0.990695025442664630f, + -0.136100575175706200f, 0.990590346218950150f, -0.136860388636816380f, + 0.990485084256457090f, -0.137620121586486040f, 0.990379239617108160f, + -0.138379773577783890f, 0.990272812363169110f, -0.139139344163826200f, + 0.990165802557248400f, -0.139898832897777210f, 0.990058210262297120f, + -0.140658239332849210f, 0.989950035541608990f, -0.141417563022303020f, + 0.989841278458820530f, -0.142176803519448030f, 0.989731939077910570f, + -0.142935960377642670f, 0.989622017463200890f, -0.143695033150294470f, + 0.989511513679355190f, -0.144454021390860470f, 0.989400427791380380f, + -0.145212924652847460f, 0.989288759864625170f, -0.145971742489812210f, + 0.989176509964781010f, -0.146730474455361750f, 0.989063678157881540f, + -0.147489120103153570f, 0.988950264510302990f, -0.148247678986896030f, + 0.988836269088763540f, -0.149006150660348450f, 0.988721691960323780f, + -0.149764534677321510f, 0.988606533192386450f, -0.150522830591677400f, + 0.988490792852696590f, -0.151281037957330220f, 0.988374471009341280f, + -0.152039156328246050f, 0.988257567730749460f, -0.152797185258443440f, + 0.988140083085692570f, -0.153555124301993450f, 0.988022017143283530f, + -0.154312973013020100f, 0.987903369972977790f, -0.155070730945700510f, + 0.987784141644572180f, -0.155828397654265230f, 0.987664332228205710f, + -0.156585972692998430f, 0.987543941794359230f, -0.157343455616238250f, + 0.987422970413855410f, -0.158100845978376980f, 0.987301418157858430f, + -0.158858143333861450f, 0.987179285097874340f, -0.159615347237193060f, + 0.987056571305750970f, -0.160372457242928280f, 0.986933276853677710f, + -0.161129472905678810f, 0.986809401814185530f, -0.161886393780111830f, + 0.986684946260146690f, -0.162643219420950310f, 0.986559910264775410f, + -0.163399949382973230f, 0.986434293901627180f, -0.164156583221015810f, + 0.986308097244598670f, -0.164913120489969890f, 0.986181320367928270f, + -0.165669560744784120f, 0.986053963346195440f, -0.166425903540464100f, + 0.985926026254321130f, -0.167182148432072940f, 0.985797509167567480f, + -0.167938294974731170f, 0.985668412161537550f, -0.168694342723617330f, + 0.985538735312176060f, -0.169450291233967960f, 0.985408478695768420f, + -0.170206140061078070f, 0.985277642388941220f, -0.170961888760301220f, + 0.985146226468662230f, -0.171717536887049970f, 0.985014231012239840f, + -0.172473083996795950f, 0.984881656097323700f, -0.173228529645070320f, + 0.984748501801904210f, -0.173983873387463820f, 0.984614768204312600f, + -0.174739114779627200f, 0.984480455383220930f, -0.175494253377271430f, + 0.984345563417641900f, -0.176249288736167880f, 0.984210092386929030f, + -0.177004220412148750f, 0.984074042370776450f, -0.177759047961107170f, + 0.983937413449218920f, -0.178513770938997510f, 0.983800205702631600f, + -0.179268388901835750f, 0.983662419211730250f, -0.180022901405699510f, + 0.983524054057571260f, -0.180777308006728590f, 0.983385110321551180f, + -0.181531608261124970f, 0.983245588085407070f, -0.182285801725153300f, + 0.983105487431216290f, -0.183039887955140950f, 0.982964808441396440f, + -0.183793866507478450f, 0.982823551198705240f, -0.184547736938619620f, + 0.982681715786240860f, -0.185301498805081900f, 0.982539302287441240f, + -0.186055151663446630f, 0.982396310786084690f, -0.186808695070359270f, + 0.982252741366289370f, -0.187562128582529600f, 0.982108594112513610f, + -0.188315451756732120f, 0.981963869109555240f, -0.189068664149806190f, + 0.981818566442552500f, -0.189821765318656410f, 0.981672686196983110f, + -0.190574754820252740f, 0.981526228458664770f, -0.191327632211630900f, + 0.981379193313754560f, -0.192080397049892440f, 0.981231580848749730f, + -0.192833048892205230f, 0.981083391150486710f, -0.193585587295803610f, + 0.980934624306141640f, -0.194338011817988600f, 0.980785280403230430f, + -0.195090322016128250f, 0.980635359529608120f, -0.195842517447657850f, + 0.980484861773469380f, -0.196594597670080220f, 0.980333787223347960f, + -0.197346562240965920f, 0.980182135968117430f, -0.198098410717953560f, + 0.980029908096990090f, -0.198850142658750090f, 0.979877103699517640f, + -0.199601757621130970f, 0.979723722865591170f, -0.200353255162940450f, + 0.979569765685440520f, -0.201104634842091900f, 0.979415232249634780f, + -0.201855896216568050f, 0.979260122649082020f, -0.202607038844421130f, + 0.979104436975029250f, -0.203358062283773320f, 0.978948175319062200f, + -0.204108966092816870f, 0.978791337773105670f, -0.204859749829814420f, + 0.978633924429423210f, -0.205610413053099240f, 0.978475935380616830f, + -0.206360955321075510f, 0.978317370719627650f, -0.207111376192218560f, + 0.978158230539735050f, -0.207861675225075070f, 0.977998514934557140f, + -0.208611851978263490f, 0.977838223998050430f, -0.209361906010474160f, + 0.977677357824509930f, -0.210111836880469610f, 0.977515916508569280f, + -0.210861644147084860f, 0.977353900145199960f, -0.211611327369227550f, + 0.977191308829712280f, -0.212360886105878420f, 0.977028142657754390f, + -0.213110319916091360f, 0.976864401725312640f, -0.213859628358993750f, + 0.976700086128711840f, -0.214608810993786760f, 0.976535195964614470f, + -0.215357867379745550f, 0.976369731330021140f, -0.216106797076219520f, + 0.976203692322270560f, -0.216855599642632620f, 0.976037079039039020f, + -0.217604274638483640f, 0.975869891578341030f, -0.218352821623346320f, + 0.975702130038528570f, -0.219101240156869800f, 0.975533794518291360f, + -0.219849529798778700f, 0.975364885116656980f, -0.220597690108873510f, + 0.975195401932990370f, -0.221345720647030810f, 0.975025345066994120f, + -0.222093620973203510f, 0.974854714618708430f, -0.222841390647421120f, + 0.974683510688510670f, -0.223589029229789990f, 0.974511733377115720f, + -0.224336536280493600f, 0.974339382785575860f, -0.225083911359792830f, + 0.974166459015280320f, -0.225831154028026170f, 0.973992962167955830f, + -0.226578263845610000f, 0.973818892345666100f, -0.227325240373038860f, + 0.973644249650811980f, -0.228072083170885730f, 0.973469034186131070f, + -0.228818791799802220f, 0.973293246054698250f, -0.229565365820518870f, + 0.973116885359925130f, -0.230311804793845440f, 0.972939952205560180f, + -0.231058108280671110f, 0.972762446695688570f, -0.231804275841964780f, + 0.972584368934732210f, -0.232550307038775240f, 0.972405719027449770f, + -0.233296201432231590f, 0.972226497078936270f, -0.234041958583543430f, + 0.972046703194623500f, -0.234787578054000970f, 0.971866337480279400f, + -0.235533059404975490f, 0.971685400042008540f, -0.236278402197919570f, + 0.971503890986251780f, -0.237023605994367200f, 0.971321810419786160f, + -0.237768670355934190f, 0.971139158449725090f, -0.238513594844318420f, + 0.970955935183517970f, -0.239258379021299980f, 0.970772140728950350f, + -0.240003022448741500f, 0.970587775194143630f, -0.240747524688588430f, + 0.970402838687555500f, -0.241491885302869330f, 0.970217331317979160f, + -0.242236103853696010f, 0.970031253194543970f, -0.242980179903263870f, + 0.969844604426714830f, -0.243724113013852160f, 0.969657385124292450f, + -0.244467902747824150f, 0.969469595397413060f, -0.245211548667627540f, + 0.969281235356548530f, -0.245955050335794590f, 0.969092305112506210f, + -0.246698407314942410f, 0.968902804776428870f, -0.247441619167773270f, + 0.968712734459794780f, -0.248184685457074780f, 0.968522094274417380f, + -0.248927605745720150f, 0.968330884332445190f, -0.249670379596668570f, + 0.968139104746362440f, -0.250413006572965220f, 0.967946755628987800f, + -0.251155486237741920f, 0.967753837093475510f, -0.251897818154216970f, + 0.967560349253314360f, -0.252640001885695520f, 0.967366292222328510f, + -0.253382036995570160f, 0.967171666114676640f, -0.254123923047320620f, + 0.966976471044852070f, -0.254865659604514570f, 0.966780707127683270f, + -0.255607246230807380f, 0.966584374478333120f, -0.256348682489942910f, + 0.966387473212298900f, -0.257089967945753120f, 0.966190003445412500f, + -0.257831102162158990f, 0.965991965293840570f, -0.258572084703170340f, + 0.965793358874083680f, -0.259312915132886230f, 0.965594184302976830f, + -0.260053593015495190f, 0.965394441697689400f, -0.260794117915275510f, + 0.965194131175724720f, -0.261534489396595520f, 0.964993252854920320f, + -0.262274707023913590f, 0.964791806853447900f, -0.263014770361779000f, + 0.964589793289812760f, -0.263754678974831350f, 0.964387212282854290f, + -0.264494432427801630f, 0.964184063951745830f, -0.265234030285511790f, + 0.963980348415994110f, -0.265973472112875590f, 0.963776065795439840f, + -0.266712757474898370f, 0.963571216210257320f, -0.267451885936677620f, + 0.963365799780954050f, -0.268190857063403180f, 0.963159816628371360f, + -0.268929670420357260f, 0.962953266873683880f, -0.269668325572915090f, + 0.962746150638399410f, -0.270406822086544820f, 0.962538468044359160f, + -0.271145159526808010f, 0.962330219213737400f, -0.271883337459359720f, + 0.962121404269041580f, -0.272621355449948980f, 0.961912023333112210f, + -0.273359213064418680f, 0.961702076529122540f, -0.274096909868706380f, + 0.961491563980579000f, -0.274834445428843940f, 0.961280485811320640f, + -0.275571819310958140f, 0.961068842145519350f, -0.276309031081271080f, + 0.960856633107679660f, -0.277046080306099900f, 0.960643858822638590f, + -0.277782966551857690f, 0.960430519415565790f, -0.278519689385053060f, + 0.960216615011963430f, -0.279256248372291180f, 0.960002145737665960f, + -0.279992643080273220f, 0.959787111718839900f, -0.280728873075797190f, + 0.959571513081984520f, -0.281464937925757940f, 0.959355349953930790f, + -0.282200837197147560f, 0.959138622461841890f, -0.282936570457055390f, + 0.958921330733213170f, -0.283672137272668430f, 0.958703474895871600f, + -0.284407537211271880f, 0.958485055077976100f, -0.285142769840248670f, + 0.958266071408017670f, -0.285877834727080620f, 0.958046524014818600f, + -0.286612731439347790f, 0.957826413027532910f, -0.287347459544729510f, + 0.957605738575646350f, -0.288082018611004130f, 0.957384500788975860f, + -0.288816408206049480f, 0.957162699797670210f, -0.289550627897843030f, + 0.956940335732208820f, -0.290284677254462330f, 0.956717408723403050f, + -0.291018555844085090f, 0.956493918902395100f, -0.291752263234989260f, + 0.956269866400658030f, -0.292485798995553880f, 0.956045251349996410f, + -0.293219162694258630f, 0.955820073882545420f, -0.293952353899684660f, + 0.955594334130771110f, -0.294685372180514330f, 0.955368032227470350f, + -0.295418217105532010f, 0.955141168305770780f, -0.296150888243623790f, + 0.954913742499130520f, -0.296883385163778270f, 0.954685754941338340f, + -0.297615707435086200f, 0.954457205766513490f, -0.298347854626741400f, + 0.954228095109105670f, -0.299079826308040480f, 0.953998423103894490f, + -0.299811622048383350f, 0.953768189885990330f, -0.300543241417273450f, + 0.953537395590833280f, -0.301274683984317950f, 0.953306040354193860f, + -0.302005949319228080f, 0.953074124312172200f, -0.302737036991819140f, + 0.952841647601198720f, -0.303467946572011320f, 0.952608610358033350f, + -0.304198677629829110f, 0.952375012719765880f, -0.304929229735402370f, + 0.952140854823815830f, -0.305659602458966120f, 0.951906136807932350f, + -0.306389795370860920f, 0.951670858810193860f, -0.307119808041533100f, + 0.951435020969008340f, -0.307849640041534870f, 0.951198623423113230f, + -0.308579290941525090f, 0.950961666311575080f, -0.309308760312268730f, + 0.950724149773789610f, -0.310038047724637890f, 0.950486073949481700f, + -0.310767152749611470f, 0.950247438978705230f, -0.311496074958275910f, + 0.950008245001843000f, -0.312224813921824880f, 0.949768492159606680f, + -0.312953369211560200f, 0.949528180593036670f, -0.313681740398891520f, + 0.949287310443502120f, -0.314409927055336660f, 0.949045881852700560f, + -0.315137928752522440f, 0.948803894962658490f, -0.315865745062183960f, + 0.948561349915730270f, -0.316593375556165850f, 0.948318246854599090f, + -0.317320819806421740f, 0.948074585922276230f, -0.318048077385014950f, + 0.947830367262101010f, -0.318775147864118480f, 0.947585591017741090f, + -0.319502030816015690f, 0.947340257333192050f, -0.320228725813099860f, + 0.947094366352777220f, -0.320955232427875210f, 0.946847918221148000f, + -0.321681550232956580f, 0.946600913083283530f, -0.322407678801069850f, + 0.946353351084490590f, -0.323133617705052330f, 0.946105232370403450f, + -0.323859366517852850f, 0.945856557086983910f, -0.324584924812532150f, + 0.945607325380521280f, -0.325310292162262930f, 0.945357537397632290f, + -0.326035468140330240f, 0.945107193285260610f, -0.326760452320131730f, + 0.944856293190677210f, -0.327485244275178000f, 0.944604837261480260f, + -0.328209843579092500f, 0.944352825645594750f, -0.328934249805612200f, + 0.944100258491272660f, -0.329658462528587490f, 0.943847135947092690f, + -0.330382481321982780f, 0.943593458161960390f, -0.331106305759876430f, + 0.943339225285107720f, -0.331829935416461110f, 0.943084437466093490f, + -0.332553369866044220f, 0.942829094854802710f, -0.333276608683047930f, + 0.942573197601446870f, -0.333999651442009380f, 0.942316745856563780f, + -0.334722497717581220f, 0.942059739771017310f, -0.335445147084531600f, + 0.941802179495997650f, -0.336167599117744520f, 0.941544065183020810f, + -0.336889853392220050f, 0.941285396983928660f, -0.337611909483074620f, + 0.941026175050889260f, -0.338333766965541130f, 0.940766399536396070f, + -0.339055425414969640f, 0.940506070593268300f, -0.339776884406826850f, + 0.940245188374650880f, -0.340498143516697160f, 0.939983753034014050f, + -0.341219202320282360f, 0.939721764725153340f, -0.341940060393402190f, + 0.939459223602189920f, -0.342660717311994380f, 0.939196129819569900f, + -0.343381172652115040f, 0.938932483532064600f, -0.344101425989938810f, + 0.938668284894770170f, -0.344821476901759290f, 0.938403534063108060f, + -0.345541324963989090f, 0.938138231192824360f, -0.346260969753160010f, + 0.937872376439989890f, -0.346980410845923680f, 0.937605969960999990f, + -0.347699647819051380f, 0.937339011912574960f, -0.348418680249434560f, + 0.937071502451759190f, -0.349137507714084970f, 0.936803441735921560f, + -0.349856129790134920f, 0.936534829922755500f, -0.350574546054837510f, + 0.936265667170278260f, -0.351292756085567090f, 0.935995953636831410f, + -0.352010759459819080f, 0.935725689481080370f, -0.352728555755210730f, + 0.935454874862014620f, -0.353446144549480810f, 0.935183509938947610f, + -0.354163525420490340f, 0.934911594871516090f, -0.354880697946222790f, + 0.934639129819680780f, -0.355597661704783850f, 0.934366114943725790f, + -0.356314416274402410f, 0.934092550404258980f, -0.357030961233429980f, + 0.933818436362210960f, -0.357747296160341900f, 0.933543772978836170f, + -0.358463420633736540f, 0.933268560415712050f, -0.359179334232336500f, + 0.932992798834738960f, -0.359895036534988110f, 0.932716488398140250f, + -0.360610527120662270f, 0.932439629268462360f, -0.361325805568454280f, + 0.932162221608574430f, -0.362040871457584180f, 0.931884265581668150f, + -0.362755724367397230f, 0.931605761351257830f, -0.363470363877363760f, + 0.931326709081180430f, -0.364184789567079890f, 0.931047108935595280f, + -0.364899001016267320f, 0.930766961078983710f, -0.365612997804773850f, + 0.930486265676149780f, -0.366326779512573590f, 0.930205022892219070f, + -0.367040345719767180f, 0.929923232892639670f, -0.367753696006581980f, + 0.929640895843181330f, -0.368466829953372320f, 0.929358011909935500f, + -0.369179747140620020f, 0.929074581259315860f, -0.369892447148934100f, + 0.928790604058057020f, -0.370604929559051670f, 0.928506080473215590f, + -0.371317193951837540f, 0.928221010672169440f, -0.372029239908285010f, + 0.927935394822617890f, -0.372741067009515760f, 0.927649233092581180f, + -0.373452674836780300f, 0.927362525650401110f, -0.374164062971457930f, + 0.927075272664740100f, -0.374875230995057540f, 0.926787474304581750f, + -0.375586178489217220f, 0.926499130739230510f, -0.376296905035704790f, + 0.926210242138311380f, -0.377007410216418260f, 0.925920808671770070f, + -0.377717693613385640f, 0.925630830509872720f, -0.378427754808765560f, + 0.925340307823206310f, -0.379137593384847320f, 0.925049240782677580f, + -0.379847208924051160f, 0.924757629559513910f, -0.380556601008928520f, + 0.924465474325262600f, -0.381265769222162380f, 0.924172775251791200f, + -0.381974713146567220f, 0.923879532511286740f, -0.382683432365089780f, + 0.923585746276256670f, -0.383391926460808660f, 0.923291416719527640f, + -0.384100195016935040f, 0.922996544014246250f, -0.384808237616812880f, + 0.922701128333878630f, -0.385516053843918850f, 0.922405169852209880f, + -0.386223643281862980f, 0.922108668743345180f, -0.386931005514388580f, + 0.921811625181708120f, -0.387638140125372730f, 0.921514039342042010f, + -0.388345046698826250f, 0.921215911399408730f, -0.389051724818894380f, + 0.920917241529189520f, -0.389758174069856410f, 0.920618029907083970f, + -0.390464394036126590f, 0.920318276709110590f, -0.391170384302253870f, + 0.920017982111606570f, -0.391876144452922350f, 0.919717146291227360f, + -0.392581674072951470f, 0.919415769424947070f, -0.393286972747296400f, + 0.919113851690057770f, -0.393992040061048100f, 0.918811393264170050f, + -0.394696875599433560f, 0.918508394325212250f, -0.395401478947816350f, + 0.918204855051430900f, -0.396105849691696270f, 0.917900775621390500f, + -0.396809987416710310f, 0.917596156213972950f, -0.397513891708632330f, + 0.917290997008377910f, -0.398217562153373560f, 0.916985298184123000f, + -0.398920998336982910f, 0.916679059921042700f, -0.399624199845646790f, + 0.916372282399289140f, -0.400327166265690090f, 0.916064965799331720f, + -0.401029897183575620f, 0.915757110301956720f, -0.401732392185905010f, + 0.915448716088267830f, -0.402434650859418430f, 0.915139783339685260f, + -0.403136672790995300f, 0.914830312237946200f, -0.403838457567654070f, + 0.914520302965104450f, -0.404540004776553000f, 0.914209755703530690f, + -0.405241314004989860f, 0.913898670635911680f, -0.405942384840402510f, + 0.913587047945250810f, -0.406643216870369030f, 0.913274887814867760f, + -0.407343809682607970f, 0.912962190428398210f, -0.408044162864978690f, + 0.912648955969793900f, -0.408744276005481360f, 0.912335184623322750f, + -0.409444148692257590f, 0.912020876573568340f, -0.410143780513590240f, + 0.911706032005429880f, -0.410843171057903910f, 0.911390651104122430f, + -0.411542319913765220f, 0.911074734055176360f, -0.412241226669882890f, + 0.910758281044437570f, -0.412939890915108080f, 0.910441292258067250f, + -0.413638312238434500f, 0.910123767882541680f, -0.414336490228999100f, + 0.909805708104652220f, -0.415034424476081630f, 0.909487113111505430f, + -0.415732114569105360f, 0.909167983090522380f, -0.416429560097637150f, + 0.908848318229439120f, -0.417126760651387870f, 0.908528118716306120f, + -0.417823715820212270f, 0.908207384739488700f, -0.418520425194109700f, + 0.907886116487666260f, -0.419216888363223910f, 0.907564314149832630f, + -0.419913104917843620f, 0.907241977915295820f, -0.420609074448402510f, + 0.906919107973678140f, -0.421304796545479640f, 0.906595704514915330f, + -0.422000270799799680f, 0.906271767729257660f, -0.422695496802232950f, + 0.905947297807268460f, -0.423390474143796050f, 0.905622294939825270f, + -0.424085202415651560f, 0.905296759318118820f, -0.424779681209108810f, + 0.904970691133653250f, -0.425473910115623800f, 0.904644090578246240f, + -0.426167888726799620f, 0.904316957844028320f, -0.426861616634386430f, + 0.903989293123443340f, -0.427555093430282080f, 0.903661096609247980f, + -0.428248318706531960f, 0.903332368494511820f, -0.428941292055329490f, + 0.903003108972617150f, -0.429634013069016380f, 0.902673318237258830f, + -0.430326481340082610f, 0.902342996482444200f, -0.431018696461167030f, + 0.902012143902493180f, -0.431710658025057260f, 0.901680760692037730f, + -0.432402365624690140f, 0.901348847046022030f, -0.433093818853151960f, + 0.901016403159702330f, -0.433785017303678520f, 0.900683429228646970f, + -0.434475960569655650f, 0.900349925448735600f, -0.435166648244619260f, + 0.900015892016160280f, -0.435857079922255470f, 0.899681329127423930f, + -0.436547255196401200f, 0.899346236979341570f, -0.437237173661044090f, + 0.899010615769039070f, -0.437926834910322860f, 0.898674465693953820f, + -0.438616238538527660f, 0.898337786951834310f, -0.439305384140099950f, + 0.898000579740739880f, -0.439994271309633260f, 0.897662844259040860f, + -0.440682899641872900f, 0.897324580705418320f, -0.441371268731716670f, + 0.896985789278863970f, -0.442059378174214700f, 0.896646470178680150f, + -0.442747227564570020f, 0.896306623604479550f, -0.443434816498138480f, + 0.895966249756185220f, -0.444122144570429200f, 0.895625348834030110f, + -0.444809211377104880f, 0.895283921038557580f, -0.445496016513981740f, + 0.894941966570620750f, -0.446182559577030070f, 0.894599485631382700f, + -0.446868840162374160f, 0.894256478422316040f, -0.447554857866293010f, + 0.893912945145203250f, -0.448240612285219890f, 0.893568886002135910f, + -0.448926103015743260f, 0.893224301195515320f, -0.449611329654606540f, + 0.892879190928051680f, -0.450296291798708610f, 0.892533555402764580f, + -0.450980989045103860f, 0.892187394822982480f, -0.451665420991002490f, + 0.891840709392342720f, -0.452349587233770890f, 0.891493499314791380f, + -0.453033487370931580f, 0.891145764794583180f, -0.453717121000163870f, + 0.890797506036281490f, -0.454400487719303580f, 0.890448723244757880f, + -0.455083587126343840f, 0.890099416625192320f, -0.455766418819434640f, + 0.889749586383072780f, -0.456448982396883920f, 0.889399232724195520f, + -0.457131277457156980f, 0.889048355854664570f, -0.457813303598877170f, + 0.888696955980891600f, -0.458495060420826270f, 0.888345033309596350f, + -0.459176547521944090f, 0.887992588047805560f, -0.459857764501329540f, + 0.887639620402853930f, -0.460538710958240010f, 0.887286130582383150f, + -0.461219386492092380f, 0.886932118794342190f, -0.461899790702462730f, + 0.886577585246987040f, -0.462579923189086810f, 0.886222530148880640f, + -0.463259783551860150f, 0.885866953708892790f, -0.463939371390838520f, + 0.885510856136199950f, -0.464618686306237820f, 0.885154237640285110f, + -0.465297727898434600f, 0.884797098430937790f, -0.465976495767966180f, + 0.884439438718253810f, -0.466654989515530920f, 0.884081258712634990f, + -0.467333208741988420f, 0.883722558624789660f, -0.468011153048359830f, + 0.883363338665731580f, -0.468688822035827900f, 0.883003599046780830f, + -0.469366215305737520f, 0.882643339979562790f, -0.470043332459595620f, + 0.882282561676008710f, -0.470720173099071600f, 0.881921264348355050f, + -0.471396736825997640f, 0.881559448209143780f, -0.472073023242368660f, + 0.881197113471222090f, -0.472749031950342790f, 0.880834260347742040f, + -0.473424762552241530f, 0.880470889052160750f, -0.474100214650549970f, + 0.880106999798240360f, -0.474775387847917120f, 0.879742592800047410f, + -0.475450281747155870f, 0.879377668271953290f, -0.476124895951243580f, + 0.879012226428633530f, -0.476799230063322090f, 0.878646267485068130f, + -0.477473283686698060f, 0.878279791656541580f, -0.478147056424843010f, + 0.877912799158641840f, -0.478820547881393890f, 0.877545290207261350f, + -0.479493757660153010f, 0.877177265018595940f, -0.480166685365088390f, + 0.876808723809145650f, -0.480839330600333960f, 0.876439666795713610f, + -0.481511692970189860f, 0.876070094195406600f, -0.482183772079122720f, + 0.875700006225634600f, -0.482855567531765670f, 0.875329403104110890f, + -0.483527078932918740f, 0.874958285048851650f, -0.484198305887549030f, + 0.874586652278176110f, -0.484869248000791060f, 0.874214505010706300f, + -0.485539904877946960f, 0.873841843465366860f, -0.486210276124486420f, + 0.873468667861384880f, -0.486880361346047340f, 0.873094978418290090f, + -0.487550160148436000f, 0.872720775355914300f, -0.488219672137626790f, + 0.872346058894391540f, -0.488888896919763170f, 0.871970829254157810f, + -0.489557834101157440f, 0.871595086655950980f, -0.490226483288291160f, + 0.871218831320811020f, -0.490894844087815090f, 0.870842063470078980f, + -0.491562916106549900f, 0.870464783325397670f, -0.492230698951486020f, + 0.870086991108711460f, -0.492898192229784040f, 0.869708687042265670f, + -0.493565395548774770f, 0.869329871348606840f, -0.494232308515959670f, + 0.868950544250582380f, -0.494898930739011260f, 0.868570705971340900f, + -0.495565261825772540f, 0.868190356734331310f, -0.496231301384258250f, + 0.867809496763303320f, -0.496897049022654470f, 0.867428126282306920f, + -0.497562504349319150f, 0.867046245515692650f, -0.498227666972781870f, + 0.866663854688111130f, -0.498892536501744590f, 0.866280954024512990f, + -0.499557112545081840f, 0.865897543750148820f, -0.500221394711840680f, + 0.865513624090569090f, -0.500885382611240710f, 0.865129195271623800f, + -0.501549075852675390f, 0.864744257519462380f, -0.502212474045710790f, + 0.864358811060534030f, -0.502875576800086990f, 0.863972856121586810f, + -0.503538383725717580f, 0.863586392929668100f, -0.504200894432690340f, + 0.863199421712124160f, -0.504863108531267590f, 0.862811942696600330f, + -0.505525025631885390f, 0.862423956111040610f, -0.506186645345155230f, + 0.862035462183687210f, -0.506847967281863210f, 0.861646461143081300f, + -0.507508991052970870f, 0.861256953218062170f, -0.508169716269614600f, + 0.860866938637767310f, -0.508830142543106990f, 0.860476417631632070f, + -0.509490269484936360f, 0.860085390429390140f, -0.510150096706766810f, + 0.859693857261072610f, -0.510809623820439040f, 0.859301818357008470f, + -0.511468850437970300f, 0.858909273947823900f, -0.512127776171554690f, + 0.858516224264442740f, -0.512786400633562960f, 0.858122669538086140f, + -0.513444723436543460f, 0.857728610000272120f, -0.514102744193221660f, + 0.857334045882815590f, -0.514760462516501200f, 0.856938977417828760f, + -0.515417878019462930f, 0.856543404837719960f, -0.516074990315366630f, + 0.856147328375194470f, -0.516731799017649870f, 0.855750748263253920f, + -0.517388303739929060f, 0.855353664735196030f, -0.518044504095999340f, + 0.854956078024614930f, -0.518700399699834950f, 0.854557988365400530f, + -0.519355990165589640f, 0.854159395991738850f, -0.520011275107596040f, + 0.853760301138111410f, -0.520666254140367160f, 0.853360704039295430f, + -0.521320926878595660f, 0.852960604930363630f, -0.521975292937154390f, + 0.852560004046684080f, -0.522629351931096610f, 0.852158901623919830f, + -0.523283103475656430f, 0.851757297898029120f, -0.523936547186248600f, + 0.851355193105265200f, -0.524589682678468950f, 0.850952587482175730f, + -0.525242509568094710f, 0.850549481265603480f, -0.525895027471084630f, + 0.850145874692685210f, -0.526547236003579440f, 0.849741768000852550f, + -0.527199134781901280f, 0.849337161427830780f, -0.527850723422555230f, + 0.848932055211639610f, -0.528502001542228480f, 0.848526449590592650f, + -0.529152968757790610f, 0.848120344803297230f, -0.529803624686294610f, + 0.847713741088654380f, -0.530453968944976320f, 0.847306638685858320f, + -0.531104001151255000f, 0.846899037834397240f, -0.531753720922733320f, + 0.846490938774052130f, -0.532403127877197900f, 0.846082341744897050f, + -0.533052221632619450f, 0.845673246987299070f, -0.533701001807152960f, + 0.845263654741918220f, -0.534349468019137520f, 0.844853565249707120f, + -0.534997619887097150f, 0.844442978751910660f, -0.535645457029741090f, + 0.844031895490066410f, -0.536292979065963180f, 0.843620315706004150f, + -0.536940185614842910f, 0.843208239641845440f, -0.537587076295645390f, + 0.842795667540004120f, -0.538233650727821700f, 0.842382599643185850f, + -0.538879908531008420f, 0.841969036194387680f, -0.539525849325028890f, + 0.841554977436898440f, -0.540171472729892850f, 0.841140423614298080f, + -0.540816778365796670f, 0.840725374970458070f, -0.541461765853123440f, + 0.840309831749540770f, -0.542106434812443920f, 0.839893794195999520f, + -0.542750784864515890f, 0.839477262554578550f, -0.543394815630284800f, + 0.839060237070312740f, -0.544038526730883820f, 0.838642717988527300f, + -0.544681917787634530f, 0.838224705554838080f, -0.545324988422046460f, + 0.837806200015150940f, -0.545967738255817570f, 0.837387201615661940f, + -0.546610166910834860f, 0.836967710602857020f, -0.547252274009174090f, + 0.836547727223512010f, -0.547894059173100190f, 0.836127251724692270f, + -0.548535522025067390f, 0.835706284353752600f, -0.549176662187719660f, + 0.835284825358337370f, -0.549817479283890910f, 0.834862874986380010f, + -0.550457972936604810f, 0.834440433486103190f, -0.551098142769075430f, + 0.834017501106018130f, -0.551737988404707340f, 0.833594078094925140f, + -0.552377509467096070f, 0.833170164701913190f, -0.553016705580027470f, + 0.832745761176359460f, -0.553655576367479310f, 0.832320867767929680f, + -0.554294121453620000f, 0.831895484726577590f, -0.554932340462810370f, + 0.831469612302545240f, -0.555570233019602180f, 0.831043250746362320f, + -0.556207798748739930f, 0.830616400308846310f, -0.556845037275160100f, + 0.830189061241102370f, -0.557481948223991550f, 0.829761233794523050f, + -0.558118531220556100f, 0.829332918220788250f, -0.558754785890368310f, + 0.828904114771864870f, -0.559390711859136140f, 0.828474823700007130f, + -0.560026308752760380f, 0.828045045257755800f, -0.560661576197336030f, + 0.827614779697938400f, -0.561296513819151470f, 0.827184027273669130f, + -0.561931121244689470f, 0.826752788238348520f, -0.562565398100626560f, + 0.826321062845663530f, -0.563199344013834090f, 0.825888851349586780f, + -0.563832958611378170f, 0.825456154004377550f, -0.564466241520519500f, + 0.825022971064580220f, -0.565099192368713980f, 0.824589302785025290f, + -0.565731810783613120f, 0.824155149420828570f, -0.566364096393063840f, + 0.823720511227391430f, -0.566996048825108680f, 0.823285388460400110f, + -0.567627667707986230f, 0.822849781375826430f, -0.568258952670131490f, + 0.822413690229926390f, -0.568889903340175860f, 0.821977115279241550f, + -0.569520519346947140f, 0.821540056780597610f, -0.570150800319470300f, + 0.821102514991104650f, -0.570780745886967260f, 0.820664490168157460f, + -0.571410355678857230f, 0.820225982569434690f, -0.572039629324757050f, + 0.819786992452898990f, -0.572668566454481160f, 0.819347520076796900f, + -0.573297166698042200f, 0.818907565699658950f, -0.573925429685650750f, + 0.818467129580298660f, -0.574553355047715760f, 0.818026211977813440f, + -0.575180942414845080f, 0.817584813151583710f, -0.575808191417845340f, + 0.817142933361272970f, -0.576435101687721830f, 0.816700572866827850f, + -0.577061672855679440f, 0.816257731928477390f, -0.577687904553122800f, + 0.815814410806733780f, -0.578313796411655590f, 0.815370609762391290f, + -0.578939348063081780f, 0.814926329056526620f, -0.579564559139405630f, + 0.814481568950498610f, -0.580189429272831680f, 0.814036329705948410f, + -0.580813958095764530f, 0.813590611584798510f, -0.581438145240810170f, + 0.813144414849253590f, -0.582061990340775440f, 0.812697739761799490f, + -0.582685493028668460f, 0.812250586585203880f, -0.583308652937698290f, + 0.811802955582515470f, -0.583931469701276180f, 0.811354847017063730f, + -0.584553942953015330f, 0.810906261152459670f, -0.585176072326730410f, + 0.810457198252594770f, -0.585797857456438860f, 0.810007658581641140f, + -0.586419297976360500f, 0.809557642404051260f, -0.587040393520917970f, + 0.809107149984558240f, -0.587661143724736660f, 0.808656181588174980f, + -0.588281548222645220f, 0.808204737480194720f, -0.588901606649675720f, + 0.807752817926190360f, -0.589521318641063940f, 0.807300423192014450f, + -0.590140683832248820f, 0.806847553543799330f, -0.590759701858874160f, + 0.806394209247956240f, -0.591378372356787580f, 0.805940390571176280f, + -0.591996694962040990f, 0.805486097780429230f, -0.592614669310891130f, + 0.805031331142963660f, -0.593232295039799800f, 0.804576090926307110f, + -0.593849571785433630f, 0.804120377398265810f, -0.594466499184664430f, + 0.803664190826924090f, -0.595083076874569960f, 0.803207531480644940f, + -0.595699304492433360f, 0.802750399628069160f, -0.596315181675743710f, + 0.802292795538115720f, -0.596930708062196500f, 0.801834719479981310f, + -0.597545883289693160f, 0.801376171723140240f, -0.598160706996342270f, + 0.800917152537344300f, -0.598775178820458720f, 0.800457662192622820f, + -0.599389298400564540f, 0.799997700959281910f, -0.600003065375388940f, + 0.799537269107905010f, -0.600616479383868970f, 0.799076366909352350f, + -0.601229540065148500f, 0.798614994634760820f, -0.601842247058580030f, + 0.798153152555543750f, -0.602454600003723750f, 0.797690840943391160f, + -0.603066598540348160f, 0.797228060070268810f, -0.603678242308430370f, + 0.796764810208418830f, -0.604289530948155960f, 0.796301091630359110f, + -0.604900464099919820f, 0.795836904608883570f, -0.605511041404325550f, + 0.795372249417061310f, -0.606121262502186120f, 0.794907126328237010f, + -0.606731127034524480f, 0.794441535616030590f, -0.607340634642572930f, + 0.793975477554337170f, -0.607949784967773630f, 0.793508952417326660f, + -0.608558577651779450f, 0.793041960479443640f, -0.609167012336453210f, + 0.792574502015407690f, -0.609775088663868430f, 0.792106577300212390f, + -0.610382806276309480f, 0.791638186609125880f, -0.610990164816271660f, + 0.791169330217690200f, -0.611597163926461910f, 0.790700008401721610f, + -0.612203803249797950f, 0.790230221437310030f, -0.612810082429409710f, + 0.789759969600819070f, -0.613416001108638590f, 0.789289253168885650f, + -0.614021558931038380f, 0.788818072418420280f, -0.614626755540375050f, + 0.788346427626606340f, -0.615231590580626820f, 0.787874319070900220f, + -0.615836063695985090f, 0.787401747029031430f, -0.616440174530853650f, + 0.786928711779001810f, -0.617043922729849760f, 0.786455213599085770f, + -0.617647307937803870f, 0.785981252767830150f, -0.618250329799760250f, + 0.785506829564053930f, -0.618852987960976320f, 0.785031944266848080f, + -0.619455282066924020f, 0.784556597155575240f, -0.620057211763289100f, + 0.784080788509869950f, -0.620658776695972140f, 0.783604518609638200f, + -0.621259976511087550f, 0.783127787735057310f, -0.621860810854965360f, + 0.782650596166575730f, -0.622461279374149970f, 0.782172944184913010f, + -0.623061381715401260f, 0.781694832071059390f, -0.623661117525694530f, + 0.781216260106276090f, -0.624260486452220650f, 0.780737228572094490f, + -0.624859488142386340f, 0.780257737750316590f, -0.625458122243814360f, + 0.779777787923014550f, -0.626056388404343520f, 0.779297379372530300f, + -0.626654286272029350f, 0.778816512381475980f, -0.627251815495144080f, + 0.778335187232733210f, -0.627848975722176460f, 0.777853404209453150f, + -0.628445766601832710f, 0.777371163595056310f, -0.629042187783036000f, + 0.776888465673232440f, -0.629638238914926980f, 0.776405310727940390f, + -0.630233919646864370f, 0.775921699043407690f, -0.630829229628424470f, + 0.775437630904130540f, -0.631424168509401860f, 0.774953106594873930f, + -0.632018735939809060f, 0.774468126400670860f, -0.632612931569877410f, + 0.773982690606822900f, -0.633206755050057190f, 0.773496799498899050f, + -0.633800206031017280f, 0.773010453362736990f, -0.634393284163645490f, + 0.772523652484441330f, -0.634985989099049460f, 0.772036397150384520f, + -0.635578320488556110f, 0.771548687647206300f, -0.636170277983712170f, + 0.771060524261813820f, -0.636761861236284200f, 0.770571907281380810f, + -0.637353069898259130f, 0.770082836993347900f, -0.637943903621844060f, + 0.769593313685422940f, -0.638534362059466790f, 0.769103337645579700f, + -0.639124444863775730f, 0.768612909162058380f, -0.639714151687640450f, + 0.768122028523365420f, -0.640303482184151670f, 0.767630696018273380f, + -0.640892436006621380f, 0.767138911935820400f, -0.641481012808583160f, + 0.766646676565310380f, -0.642069212243792540f, 0.766153990196312920f, + -0.642657033966226860f, 0.765660853118662500f, -0.643244477630085850f, + 0.765167265622458960f, -0.643831542889791390f, 0.764673227998067140f, + -0.644418229399988380f, 0.764178740536116670f, -0.645004536815543930f, + 0.763683803527501870f, -0.645590464791548690f, 0.763188417263381270f, + -0.646176012983316280f, 0.762692582035177980f, -0.646761181046383920f, + 0.762196298134578900f, -0.647345968636512060f, 0.761699565853535380f, + -0.647930375409685340f, 0.761202385484261780f, -0.648514401022112440f, + 0.760704757319236920f, -0.649098045130225950f, 0.760206681651202420f, + -0.649681307390683190f, 0.759708158773163440f, -0.650264187460365850f, + 0.759209188978388070f, -0.650846684996380880f, 0.758709772560407390f, + -0.651428799656059820f, 0.758209909813015280f, -0.652010531096959500f, + 0.757709601030268080f, -0.652591878976862440f, 0.757208846506484570f, + -0.653172842953776760f, 0.756707646536245670f, -0.653753422685936060f, + 0.756206001414394540f, -0.654333617831800440f, 0.755703911436035880f, + -0.654913428050056030f, 0.755201376896536550f, -0.655492852999615350f, + 0.754698398091524500f, -0.656071892339617600f, 0.754194975316889170f, + -0.656650545729428940f, 0.753691108868781210f, -0.657228812828642540f, + 0.753186799043612520f, -0.657806693297078640f, 0.752682046138055340f, + -0.658384186794785050f, 0.752176850449042810f, -0.658961292982037320f, + 0.751671212273768430f, -0.659538011519338660f, 0.751165131909686480f, + -0.660114342067420480f, 0.750658609654510700f, -0.660690284287242300f, + 0.750151645806215070f, -0.661265837839992270f, 0.749644240663033480f, + -0.661841002387086870f, 0.749136394523459370f, -0.662415777590171780f, + 0.748628107686245440f, -0.662990163111121470f, 0.748119380450403600f, + -0.663564158612039770f, 0.747610213115205150f, -0.664137763755260010f, + 0.747100605980180130f, -0.664710978203344790f, 0.746590559345117310f, + -0.665283801619087180f, 0.746080073510063780f, -0.665856233665509720f, + 0.745569148775325430f, -0.666428274005865240f, 0.745057785441466060f, + -0.666999922303637470f, 0.744545983809307370f, -0.667571178222540310f, + 0.744033744179929290f, -0.668142041426518450f, 0.743521066854669120f, + -0.668712511579747980f, 0.743007952135121720f, -0.669282588346636010f, + 0.742494400323139180f, -0.669852271391821020f, 0.741980411720831070f, + -0.670421560380173090f, 0.741465986630563290f, -0.670990454976794220f, + 0.740951125354959110f, -0.671558954847018330f, 0.740435828196898020f, + -0.672127059656411730f, 0.739920095459516200f, -0.672694769070772860f, + 0.739403927446205760f, -0.673262082756132970f, 0.738887324460615110f, + -0.673829000378756040f, 0.738370286806648620f, -0.674395521605139050f, + 0.737852814788465980f, -0.674961646102011930f, 0.737334908710482910f, + -0.675527373536338520f, 0.736816568877369900f, -0.676092703575315920f, + 0.736297795594053170f, -0.676657635886374950f, 0.735778589165713590f, + -0.677222170137180330f, 0.735258949897786840f, -0.677786305995631500f, + 0.734738878095963500f, -0.678350043129861470f, 0.734218374066188280f, + -0.678913381208238410f, 0.733697438114660370f, -0.679476319899364970f, + 0.733176070547832740f, -0.680038858872078930f, 0.732654271672412820f, + -0.680600997795453020f, 0.732132041795361290f, -0.681162736338795430f, + 0.731609381223892630f, -0.681724074171649710f, 0.731086290265474340f, + -0.682285010963795570f, 0.730562769227827590f, -0.682845546385248080f, + 0.730038818418926260f, -0.683405680106258680f, 0.729514438146997010f, + -0.683965411797315400f, 0.728989628720519420f, -0.684524741129142300f, + 0.728464390448225200f, -0.685083667772700360f, 0.727938723639098620f, + -0.685642191399187470f, 0.727412628602375770f, -0.686200311680038590f, + 0.726886105647544970f, -0.686758028286925890f, 0.726359155084346010f, + -0.687315340891759050f, 0.725831777222770370f, -0.687872249166685550f, + 0.725303972373060770f, -0.688428752784090440f, 0.724775740845711280f, + -0.688984851416597040f, 0.724247082951467000f, -0.689540544737066830f, + 0.723717999001323500f, -0.690095832418599950f, 0.723188489306527460f, + -0.690650714134534600f, 0.722658554178575610f, -0.691205189558448450f, + 0.722128193929215350f, -0.691759258364157750f, 0.721597408870443770f, + -0.692312920225718220f, 0.721066199314508110f, -0.692866174817424630f, + 0.720534565573905270f, -0.693419021813811760f, 0.720002507961381650f, + -0.693971460889654000f, 0.719470026789932990f, -0.694523491719965520f, + 0.718937122372804490f, -0.695075113980000880f, 0.718403795023489830f, + -0.695626327345254870f, 0.717870045055731710f, -0.696177131491462990f, + 0.717335872783521730f, -0.696727526094601200f, 0.716801278521099540f, + -0.697277510830886520f, 0.716266262582953120f, -0.697827085376777290f, + 0.715730825283818590f, -0.698376249408972920f, 0.715194966938680120f, + -0.698925002604414150f, 0.714658687862769090f, -0.699473344640283770f, + 0.714121988371564820f, -0.700021275194006250f, 0.713584868780793640f, + -0.700568793943248340f, 0.713047329406429340f, -0.701115900565918660f, + 0.712509370564692320f, -0.701662594740168450f, 0.711970992572050100f, + -0.702208876144391870f, 0.711432195745216430f, -0.702754744457225300f, + 0.710892980401151680f, -0.703300199357548730f, 0.710353346857062420f, + -0.703845240524484940f, 0.709813295430400840f, -0.704389867637400410f, + 0.709272826438865690f, -0.704934080375904880f, 0.708731940200400650f, + -0.705477878419852100f, 0.708190637033195400f, -0.706021261449339740f, + 0.707648917255684350f, -0.706564229144709510f, 0.707106781186547570f, + -0.707106781186547460f, 0.706564229144709620f, -0.707648917255684350f, + 0.706021261449339740f, -0.708190637033195290f, 0.705477878419852210f, + -0.708731940200400650f, 0.704934080375904990f, -0.709272826438865580f, + 0.704389867637400410f, -0.709813295430400840f, 0.703845240524484940f, + -0.710353346857062310f, 0.703300199357548730f, -0.710892980401151680f, + 0.702754744457225300f, -0.711432195745216430f, 0.702208876144391870f, + -0.711970992572049990f, 0.701662594740168570f, -0.712509370564692320f, + 0.701115900565918660f, -0.713047329406429230f, 0.700568793943248450f, + -0.713584868780793520f, 0.700021275194006360f, -0.714121988371564710f, + 0.699473344640283770f, -0.714658687862768980f, 0.698925002604414150f, + -0.715194966938680010f, 0.698376249408972920f, -0.715730825283818590f, + 0.697827085376777290f, -0.716266262582953120f, 0.697277510830886630f, + -0.716801278521099540f, 0.696727526094601200f, -0.717335872783521730f, + 0.696177131491462990f, -0.717870045055731710f, 0.695626327345254870f, + -0.718403795023489720f, 0.695075113980000880f, -0.718937122372804380f, + 0.694523491719965520f, -0.719470026789932990f, 0.693971460889654000f, + -0.720002507961381650f, 0.693419021813811880f, -0.720534565573905270f, + 0.692866174817424740f, -0.721066199314508110f, 0.692312920225718220f, + -0.721597408870443660f, 0.691759258364157750f, -0.722128193929215350f, + 0.691205189558448450f, -0.722658554178575610f, 0.690650714134534720f, + -0.723188489306527350f, 0.690095832418599950f, -0.723717999001323390f, + 0.689540544737066940f, -0.724247082951466890f, 0.688984851416597150f, + -0.724775740845711280f, 0.688428752784090550f, -0.725303972373060660f, + 0.687872249166685550f, -0.725831777222770370f, 0.687315340891759160f, + -0.726359155084346010f, 0.686758028286925890f, -0.726886105647544970f, + 0.686200311680038700f, -0.727412628602375770f, 0.685642191399187470f, + -0.727938723639098620f, 0.685083667772700360f, -0.728464390448225200f, + 0.684524741129142300f, -0.728989628720519310f, 0.683965411797315510f, + -0.729514438146996900f, 0.683405680106258790f, -0.730038818418926150f, + 0.682845546385248080f, -0.730562769227827590f, 0.682285010963795570f, + -0.731086290265474230f, 0.681724074171649820f, -0.731609381223892520f, + 0.681162736338795430f, -0.732132041795361290f, 0.680600997795453130f, + -0.732654271672412820f, 0.680038858872079040f, -0.733176070547832740f, + 0.679476319899365080f, -0.733697438114660260f, 0.678913381208238410f, + -0.734218374066188170f, 0.678350043129861580f, -0.734738878095963390f, + 0.677786305995631500f, -0.735258949897786730f, 0.677222170137180450f, + -0.735778589165713480f, 0.676657635886374950f, -0.736297795594053060f, + 0.676092703575316030f, -0.736816568877369790f, 0.675527373536338630f, + -0.737334908710482790f, 0.674961646102012040f, -0.737852814788465980f, + 0.674395521605139050f, -0.738370286806648510f, 0.673829000378756150f, + -0.738887324460615110f, 0.673262082756132970f, -0.739403927446205760f, + 0.672694769070772970f, -0.739920095459516090f, 0.672127059656411840f, + -0.740435828196898020f, 0.671558954847018330f, -0.740951125354959110f, + 0.670990454976794220f, -0.741465986630563290f, 0.670421560380173090f, + -0.741980411720830960f, 0.669852271391821130f, -0.742494400323139180f, + 0.669282588346636010f, -0.743007952135121720f, 0.668712511579748090f, + -0.743521066854669120f, 0.668142041426518560f, -0.744033744179929180f, + 0.667571178222540310f, -0.744545983809307250f, 0.666999922303637470f, + -0.745057785441465950f, 0.666428274005865350f, -0.745569148775325430f, + 0.665856233665509720f, -0.746080073510063780f, 0.665283801619087180f, + -0.746590559345117310f, 0.664710978203344900f, -0.747100605980180130f, + 0.664137763755260010f, -0.747610213115205150f, 0.663564158612039880f, + -0.748119380450403490f, 0.662990163111121470f, -0.748628107686245330f, + 0.662415777590171780f, -0.749136394523459260f, 0.661841002387086870f, + -0.749644240663033480f, 0.661265837839992270f, -0.750151645806214960f, + 0.660690284287242300f, -0.750658609654510590f, 0.660114342067420480f, + -0.751165131909686370f, 0.659538011519338770f, -0.751671212273768430f, + 0.658961292982037320f, -0.752176850449042700f, 0.658384186794785050f, + -0.752682046138055230f, 0.657806693297078640f, -0.753186799043612410f, + 0.657228812828642650f, -0.753691108868781210f, 0.656650545729429050f, + -0.754194975316889170f, 0.656071892339617710f, -0.754698398091524390f, + 0.655492852999615460f, -0.755201376896536550f, 0.654913428050056150f, + -0.755703911436035880f, 0.654333617831800550f, -0.756206001414394540f, + 0.653753422685936170f, -0.756707646536245670f, 0.653172842953776760f, + -0.757208846506484460f, 0.652591878976862550f, -0.757709601030268080f, + 0.652010531096959500f, -0.758209909813015280f, 0.651428799656059820f, + -0.758709772560407390f, 0.650846684996380990f, -0.759209188978387960f, + 0.650264187460365960f, -0.759708158773163440f, 0.649681307390683190f, + -0.760206681651202420f, 0.649098045130226060f, -0.760704757319236920f, + 0.648514401022112550f, -0.761202385484261780f, 0.647930375409685460f, + -0.761699565853535270f, 0.647345968636512060f, -0.762196298134578900f, + 0.646761181046383920f, -0.762692582035177870f, 0.646176012983316390f, + -0.763188417263381270f, 0.645590464791548800f, -0.763683803527501870f, + 0.645004536815544040f, -0.764178740536116670f, 0.644418229399988380f, + -0.764673227998067140f, 0.643831542889791500f, -0.765167265622458960f, + 0.643244477630085850f, -0.765660853118662390f, 0.642657033966226860f, + -0.766153990196312810f, 0.642069212243792540f, -0.766646676565310380f, + 0.641481012808583160f, -0.767138911935820400f, 0.640892436006621380f, + -0.767630696018273270f, 0.640303482184151670f, -0.768122028523365310f, + 0.639714151687640450f, -0.768612909162058270f, 0.639124444863775730f, + -0.769103337645579590f, 0.638534362059466790f, -0.769593313685422940f, + 0.637943903621844170f, -0.770082836993347900f, 0.637353069898259130f, + -0.770571907281380700f, 0.636761861236284200f, -0.771060524261813710f, + 0.636170277983712170f, -0.771548687647206300f, 0.635578320488556230f, + -0.772036397150384410f, 0.634985989099049460f, -0.772523652484441330f, + 0.634393284163645490f, -0.773010453362736990f, 0.633800206031017280f, + -0.773496799498899050f, 0.633206755050057190f, -0.773982690606822790f, + 0.632612931569877520f, -0.774468126400670860f, 0.632018735939809060f, + -0.774953106594873820f, 0.631424168509401860f, -0.775437630904130430f, + 0.630829229628424470f, -0.775921699043407580f, 0.630233919646864480f, + -0.776405310727940390f, 0.629638238914927100f, -0.776888465673232440f, + 0.629042187783036000f, -0.777371163595056200f, 0.628445766601832710f, + -0.777853404209453040f, 0.627848975722176570f, -0.778335187232733090f, + 0.627251815495144190f, -0.778816512381475870f, 0.626654286272029460f, + -0.779297379372530300f, 0.626056388404343520f, -0.779777787923014440f, + 0.625458122243814360f, -0.780257737750316590f, 0.624859488142386450f, + -0.780737228572094380f, 0.624260486452220650f, -0.781216260106276090f, + 0.623661117525694640f, -0.781694832071059390f, 0.623061381715401370f, + -0.782172944184912900f, 0.622461279374150080f, -0.782650596166575730f, + 0.621860810854965360f, -0.783127787735057310f, 0.621259976511087660f, + -0.783604518609638200f, 0.620658776695972140f, -0.784080788509869950f, + 0.620057211763289210f, -0.784556597155575240f, 0.619455282066924020f, + -0.785031944266848080f, 0.618852987960976320f, -0.785506829564053930f, + 0.618250329799760250f, -0.785981252767830150f, 0.617647307937803980f, + -0.786455213599085770f, 0.617043922729849760f, -0.786928711779001700f, + 0.616440174530853650f, -0.787401747029031320f, 0.615836063695985090f, + -0.787874319070900110f, 0.615231590580626820f, -0.788346427626606230f, + 0.614626755540375050f, -0.788818072418420170f, 0.614021558931038490f, + -0.789289253168885650f, 0.613416001108638590f, -0.789759969600819070f, + 0.612810082429409710f, -0.790230221437310030f, 0.612203803249798060f, + -0.790700008401721610f, 0.611597163926462020f, -0.791169330217690090f, + 0.610990164816271770f, -0.791638186609125770f, 0.610382806276309480f, + -0.792106577300212390f, 0.609775088663868430f, -0.792574502015407580f, + 0.609167012336453210f, -0.793041960479443640f, 0.608558577651779450f, + -0.793508952417326660f, 0.607949784967773740f, -0.793975477554337170f, + 0.607340634642572930f, -0.794441535616030590f, 0.606731127034524480f, + -0.794907126328237010f, 0.606121262502186230f, -0.795372249417061190f, + 0.605511041404325550f, -0.795836904608883460f, 0.604900464099919930f, + -0.796301091630359110f, 0.604289530948156070f, -0.796764810208418720f, + 0.603678242308430370f, -0.797228060070268700f, 0.603066598540348280f, + -0.797690840943391040f, 0.602454600003723860f, -0.798153152555543750f, + 0.601842247058580030f, -0.798614994634760820f, 0.601229540065148620f, + -0.799076366909352350f, 0.600616479383868970f, -0.799537269107905010f, + 0.600003065375389060f, -0.799997700959281910f, 0.599389298400564540f, + -0.800457662192622710f, 0.598775178820458720f, -0.800917152537344300f, + 0.598160706996342380f, -0.801376171723140130f, 0.597545883289693270f, + -0.801834719479981310f, 0.596930708062196500f, -0.802292795538115720f, + 0.596315181675743820f, -0.802750399628069160f, 0.595699304492433470f, + -0.803207531480644830f, 0.595083076874569960f, -0.803664190826924090f, + 0.594466499184664540f, -0.804120377398265700f, 0.593849571785433630f, + -0.804576090926307000f, 0.593232295039799800f, -0.805031331142963660f, + 0.592614669310891130f, -0.805486097780429120f, 0.591996694962040990f, + -0.805940390571176280f, 0.591378372356787580f, -0.806394209247956240f, + 0.590759701858874280f, -0.806847553543799220f, 0.590140683832248940f, + -0.807300423192014450f, 0.589521318641063940f, -0.807752817926190360f, + 0.588901606649675840f, -0.808204737480194720f, 0.588281548222645330f, + -0.808656181588174980f, 0.587661143724736770f, -0.809107149984558130f, + 0.587040393520918080f, -0.809557642404051260f, 0.586419297976360500f, + -0.810007658581641140f, 0.585797857456438860f, -0.810457198252594770f, + 0.585176072326730410f, -0.810906261152459670f, 0.584553942953015330f, + -0.811354847017063730f, 0.583931469701276300f, -0.811802955582515360f, + 0.583308652937698290f, -0.812250586585203880f, 0.582685493028668460f, + -0.812697739761799490f, 0.582061990340775550f, -0.813144414849253590f, + 0.581438145240810280f, -0.813590611584798510f, 0.580813958095764530f, + -0.814036329705948300f, 0.580189429272831680f, -0.814481568950498610f, + 0.579564559139405740f, -0.814926329056526620f, 0.578939348063081890f, + -0.815370609762391290f, 0.578313796411655590f, -0.815814410806733780f, + 0.577687904553122800f, -0.816257731928477390f, 0.577061672855679550f, + -0.816700572866827850f, 0.576435101687721830f, -0.817142933361272970f, + 0.575808191417845340f, -0.817584813151583710f, 0.575180942414845190f, + -0.818026211977813440f, 0.574553355047715760f, -0.818467129580298660f, + 0.573925429685650750f, -0.818907565699658950f, 0.573297166698042320f, + -0.819347520076796900f, 0.572668566454481160f, -0.819786992452898990f, + 0.572039629324757050f, -0.820225982569434690f, 0.571410355678857340f, + -0.820664490168157460f, 0.570780745886967370f, -0.821102514991104650f, + 0.570150800319470300f, -0.821540056780597610f, 0.569520519346947250f, + -0.821977115279241550f, 0.568889903340175970f, -0.822413690229926390f, + 0.568258952670131490f, -0.822849781375826320f, 0.567627667707986230f, + -0.823285388460400110f, 0.566996048825108680f, -0.823720511227391320f, + 0.566364096393063950f, -0.824155149420828570f, 0.565731810783613230f, + -0.824589302785025290f, 0.565099192368714090f, -0.825022971064580220f, + 0.564466241520519500f, -0.825456154004377440f, 0.563832958611378170f, + -0.825888851349586780f, 0.563199344013834090f, -0.826321062845663420f, + 0.562565398100626560f, -0.826752788238348520f, 0.561931121244689470f, + -0.827184027273669020f, 0.561296513819151470f, -0.827614779697938400f, + 0.560661576197336030f, -0.828045045257755800f, 0.560026308752760380f, + -0.828474823700007130f, 0.559390711859136140f, -0.828904114771864870f, + 0.558754785890368310f, -0.829332918220788250f, 0.558118531220556100f, + -0.829761233794523050f, 0.557481948223991660f, -0.830189061241102370f, + 0.556845037275160100f, -0.830616400308846200f, 0.556207798748739930f, + -0.831043250746362320f, 0.555570233019602290f, -0.831469612302545240f, + 0.554932340462810370f, -0.831895484726577590f, 0.554294121453620110f, + -0.832320867767929680f, 0.553655576367479310f, -0.832745761176359460f, + 0.553016705580027580f, -0.833170164701913190f, 0.552377509467096070f, + -0.833594078094925140f, 0.551737988404707450f, -0.834017501106018130f, + 0.551098142769075430f, -0.834440433486103190f, 0.550457972936604810f, + -0.834862874986380010f, 0.549817479283891020f, -0.835284825358337370f, + 0.549176662187719770f, -0.835706284353752600f, 0.548535522025067390f, + -0.836127251724692160f, 0.547894059173100190f, -0.836547727223511890f, + 0.547252274009174090f, -0.836967710602857020f, 0.546610166910834860f, + -0.837387201615661940f, 0.545967738255817680f, -0.837806200015150940f, + 0.545324988422046460f, -0.838224705554837970f, 0.544681917787634530f, + -0.838642717988527300f, 0.544038526730883930f, -0.839060237070312630f, + 0.543394815630284800f, -0.839477262554578550f, 0.542750784864516000f, + -0.839893794195999410f, 0.542106434812444030f, -0.840309831749540770f, + 0.541461765853123560f, -0.840725374970458070f, 0.540816778365796670f, + -0.841140423614298080f, 0.540171472729892970f, -0.841554977436898330f, + 0.539525849325029010f, -0.841969036194387680f, 0.538879908531008420f, + -0.842382599643185960f, 0.538233650727821700f, -0.842795667540004120f, + 0.537587076295645510f, -0.843208239641845440f, 0.536940185614843020f, + -0.843620315706004040f, 0.536292979065963180f, -0.844031895490066410f, + 0.535645457029741090f, -0.844442978751910660f, 0.534997619887097260f, + -0.844853565249707010f, 0.534349468019137520f, -0.845263654741918220f, + 0.533701001807152960f, -0.845673246987299070f, 0.533052221632619670f, + -0.846082341744896940f, 0.532403127877198010f, -0.846490938774052020f, + 0.531753720922733320f, -0.846899037834397350f, 0.531104001151255000f, + -0.847306638685858320f, 0.530453968944976320f, -0.847713741088654270f, + 0.529803624686294830f, -0.848120344803297120f, 0.529152968757790720f, + -0.848526449590592650f, 0.528502001542228480f, -0.848932055211639610f, + 0.527850723422555460f, -0.849337161427830670f, 0.527199134781901390f, + -0.849741768000852440f, 0.526547236003579330f, -0.850145874692685210f, + 0.525895027471084740f, -0.850549481265603370f, 0.525242509568094710f, + -0.850952587482175730f, 0.524589682678468840f, -0.851355193105265200f, + 0.523936547186248600f, -0.851757297898029120f, 0.523283103475656430f, + -0.852158901623919830f, 0.522629351931096720f, -0.852560004046683970f, + 0.521975292937154390f, -0.852960604930363630f, 0.521320926878595550f, + -0.853360704039295430f, 0.520666254140367270f, -0.853760301138111300f, + 0.520011275107596040f, -0.854159395991738730f, 0.519355990165589530f, + -0.854557988365400530f, 0.518700399699835170f, -0.854956078024614820f, + 0.518044504095999340f, -0.855353664735196030f, 0.517388303739929060f, + -0.855750748263253920f, 0.516731799017649980f, -0.856147328375194470f, + 0.516074990315366630f, -0.856543404837719960f, 0.515417878019463150f, + -0.856938977417828650f, 0.514760462516501200f, -0.857334045882815590f, + 0.514102744193221660f, -0.857728610000272120f, 0.513444723436543570f, + -0.858122669538086020f, 0.512786400633563070f, -0.858516224264442740f, + 0.512127776171554690f, -0.858909273947823900f, 0.511468850437970520f, + -0.859301818357008360f, 0.510809623820439040f, -0.859693857261072610f, + 0.510150096706766700f, -0.860085390429390140f, 0.509490269484936360f, + -0.860476417631632070f, 0.508830142543106990f, -0.860866938637767310f, + 0.508169716269614710f, -0.861256953218062060f, 0.507508991052970870f, + -0.861646461143081300f, 0.506847967281863320f, -0.862035462183687210f, + 0.506186645345155450f, -0.862423956111040500f, 0.505525025631885510f, + -0.862811942696600330f, 0.504863108531267480f, -0.863199421712124160f, + 0.504200894432690560f, -0.863586392929667990f, 0.503538383725717580f, + -0.863972856121586700f, 0.502875576800086880f, -0.864358811060534030f, + 0.502212474045710900f, -0.864744257519462380f, 0.501549075852675390f, + -0.865129195271623690f, 0.500885382611240940f, -0.865513624090568980f, + 0.500221394711840680f, -0.865897543750148820f, 0.499557112545081890f, + -0.866280954024512990f, 0.498892536501744750f, -0.866663854688111020f, + 0.498227666972781870f, -0.867046245515692650f, 0.497562504349319090f, + -0.867428126282306920f, 0.496897049022654640f, -0.867809496763303210f, + 0.496231301384258310f, -0.868190356734331310f, 0.495565261825772490f, + -0.868570705971340900f, 0.494898930739011310f, -0.868950544250582380f, + 0.494232308515959730f, -0.869329871348606730f, 0.493565395548774880f, + -0.869708687042265560f, 0.492898192229784090f, -0.870086991108711350f, + 0.492230698951486080f, -0.870464783325397670f, 0.491562916106550060f, + -0.870842063470078860f, 0.490894844087815140f, -0.871218831320810900f, + 0.490226483288291100f, -0.871595086655951090f, 0.489557834101157550f, + -0.871970829254157700f, 0.488888896919763230f, -0.872346058894391540f, + 0.488219672137626740f, -0.872720775355914300f, 0.487550160148436050f, + -0.873094978418290090f, 0.486880361346047400f, -0.873468667861384880f, + 0.486210276124486530f, -0.873841843465366750f, 0.485539904877947020f, + -0.874214505010706300f, 0.484869248000791120f, -0.874586652278176110f, + 0.484198305887549140f, -0.874958285048851540f, 0.483527078932918740f, + -0.875329403104110780f, 0.482855567531765670f, -0.875700006225634600f, + 0.482183772079122830f, -0.876070094195406600f, 0.481511692970189920f, + -0.876439666795713610f, 0.480839330600333900f, -0.876808723809145760f, + 0.480166685365088440f, -0.877177265018595940f, 0.479493757660153010f, + -0.877545290207261240f, 0.478820547881394050f, -0.877912799158641730f, + 0.478147056424843120f, -0.878279791656541460f, 0.477473283686698060f, + -0.878646267485068130f, 0.476799230063322250f, -0.879012226428633410f, + 0.476124895951243630f, -0.879377668271953180f, 0.475450281747155870f, + -0.879742592800047410f, 0.474775387847917230f, -0.880106999798240360f, + 0.474100214650550020f, -0.880470889052160750f, 0.473424762552241530f, + -0.880834260347742040f, 0.472749031950342900f, -0.881197113471221980f, + 0.472073023242368660f, -0.881559448209143780f, 0.471396736825997810f, + -0.881921264348354940f, 0.470720173099071710f, -0.882282561676008600f, + 0.470043332459595620f, -0.882643339979562790f, 0.469366215305737630f, + -0.883003599046780720f, 0.468688822035827960f, -0.883363338665731580f, + 0.468011153048359830f, -0.883722558624789660f, 0.467333208741988530f, + -0.884081258712634990f, 0.466654989515530970f, -0.884439438718253700f, + 0.465976495767966130f, -0.884797098430937790f, 0.465297727898434650f, + -0.885154237640285110f, 0.464618686306237820f, -0.885510856136199950f, + 0.463939371390838460f, -0.885866953708892790f, 0.463259783551860260f, + -0.886222530148880640f, 0.462579923189086810f, -0.886577585246987040f, + 0.461899790702462840f, -0.886932118794342080f, 0.461219386492092430f, + -0.887286130582383150f, 0.460538710958240010f, -0.887639620402853930f, + 0.459857764501329650f, -0.887992588047805560f, 0.459176547521944150f, + -0.888345033309596240f, 0.458495060420826220f, -0.888696955980891710f, + 0.457813303598877290f, -0.889048355854664570f, 0.457131277457156980f, + -0.889399232724195520f, 0.456448982396883860f, -0.889749586383072890f, + 0.455766418819434750f, -0.890099416625192210f, 0.455083587126343840f, + -0.890448723244757880f, 0.454400487719303750f, -0.890797506036281490f, + 0.453717121000163930f, -0.891145764794583180f, 0.453033487370931580f, + -0.891493499314791380f, 0.452349587233771000f, -0.891840709392342720f, + 0.451665420991002540f, -0.892187394822982480f, 0.450980989045103810f, + -0.892533555402764690f, 0.450296291798708730f, -0.892879190928051680f, + 0.449611329654606600f, -0.893224301195515320f, 0.448926103015743260f, + -0.893568886002136020f, 0.448240612285220000f, -0.893912945145203250f, + 0.447554857866293010f, -0.894256478422316040f, 0.446868840162374330f, + -0.894599485631382580f, 0.446182559577030120f, -0.894941966570620750f, + 0.445496016513981740f, -0.895283921038557580f, 0.444809211377105000f, + -0.895625348834030000f, 0.444122144570429260f, -0.895966249756185110f, + 0.443434816498138430f, -0.896306623604479660f, 0.442747227564570130f, + -0.896646470178680150f, 0.442059378174214760f, -0.896985789278863970f, + 0.441371268731716620f, -0.897324580705418320f, 0.440682899641873020f, + -0.897662844259040750f, 0.439994271309633260f, -0.898000579740739880f, + 0.439305384140100060f, -0.898337786951834190f, 0.438616238538527710f, + -0.898674465693953820f, 0.437926834910322860f, -0.899010615769039070f, + 0.437237173661044200f, -0.899346236979341460f, 0.436547255196401250f, + -0.899681329127423930f, 0.435857079922255470f, -0.900015892016160280f, + 0.435166648244619370f, -0.900349925448735600f, 0.434475960569655710f, + -0.900683429228646860f, 0.433785017303678520f, -0.901016403159702330f, + 0.433093818853152010f, -0.901348847046022030f, 0.432402365624690140f, + -0.901680760692037730f, 0.431710658025057370f, -0.902012143902493070f, + 0.431018696461167080f, -0.902342996482444200f, 0.430326481340082610f, + -0.902673318237258830f, 0.429634013069016500f, -0.903003108972617040f, + 0.428941292055329550f, -0.903332368494511820f, 0.428248318706531910f, + -0.903661096609247980f, 0.427555093430282200f, -0.903989293123443340f, + 0.426861616634386490f, -0.904316957844028320f, 0.426167888726799620f, + -0.904644090578246240f, 0.425473910115623910f, -0.904970691133653250f, + 0.424779681209108810f, -0.905296759318118820f, 0.424085202415651670f, + -0.905622294939825160f, 0.423390474143796100f, -0.905947297807268460f, + 0.422695496802232950f, -0.906271767729257660f, 0.422000270799799790f, + -0.906595704514915330f, 0.421304796545479700f, -0.906919107973678030f, + 0.420609074448402510f, -0.907241977915295930f, 0.419913104917843730f, + -0.907564314149832520f, 0.419216888363223960f, -0.907886116487666150f, + 0.418520425194109700f, -0.908207384739488700f, 0.417823715820212380f, + -0.908528118716306120f, 0.417126760651387870f, -0.908848318229439120f, + 0.416429560097637320f, -0.909167983090522270f, 0.415732114569105420f, + -0.909487113111505430f, 0.415034424476081630f, -0.909805708104652220f, + 0.414336490228999210f, -0.910123767882541570f, 0.413638312238434560f, + -0.910441292258067140f, 0.412939890915108020f, -0.910758281044437570f, + 0.412241226669883000f, -0.911074734055176250f, 0.411542319913765280f, + -0.911390651104122320f, 0.410843171057903910f, -0.911706032005429880f, + 0.410143780513590350f, -0.912020876573568230f, 0.409444148692257590f, + -0.912335184623322750f, 0.408744276005481520f, -0.912648955969793900f, + 0.408044162864978740f, -0.912962190428398100f, 0.407343809682607970f, + -0.913274887814867760f, 0.406643216870369140f, -0.913587047945250810f, + 0.405942384840402570f, -0.913898670635911680f, 0.405241314004989860f, + -0.914209755703530690f, 0.404540004776553110f, -0.914520302965104450f, + 0.403838457567654130f, -0.914830312237946090f, 0.403136672790995240f, + -0.915139783339685260f, 0.402434650859418540f, -0.915448716088267830f, + 0.401732392185905010f, -0.915757110301956720f, 0.401029897183575790f, + -0.916064965799331610f, 0.400327166265690150f, -0.916372282399289140f, + 0.399624199845646790f, -0.916679059921042700f, 0.398920998336983020f, + -0.916985298184122890f, 0.398217562153373620f, -0.917290997008377910f, + 0.397513891708632330f, -0.917596156213972950f, 0.396809987416710420f, + -0.917900775621390390f, 0.396105849691696320f, -0.918204855051430900f, + 0.395401478947816300f, -0.918508394325212250f, 0.394696875599433670f, + -0.918811393264169940f, 0.393992040061048100f, -0.919113851690057770f, + 0.393286972747296570f, -0.919415769424946960f, 0.392581674072951530f, + -0.919717146291227360f, 0.391876144452922350f, -0.920017982111606570f, + 0.391170384302253980f, -0.920318276709110480f, 0.390464394036126650f, + -0.920618029907083860f, 0.389758174069856410f, -0.920917241529189520f, + 0.389051724818894500f, -0.921215911399408730f, 0.388345046698826300f, + -0.921514039342041900f, 0.387638140125372680f, -0.921811625181708120f, + 0.386931005514388690f, -0.922108668743345070f, 0.386223643281862980f, + -0.922405169852209880f, 0.385516053843919020f, -0.922701128333878520f, + 0.384808237616812930f, -0.922996544014246250f, 0.384100195016935040f, + -0.923291416719527640f, 0.383391926460808770f, -0.923585746276256560f, + 0.382683432365089840f, -0.923879532511286740f, 0.381974713146567220f, + -0.924172775251791200f, 0.381265769222162490f, -0.924465474325262600f, + 0.380556601008928570f, -0.924757629559513910f, 0.379847208924051110f, + -0.925049240782677580f, 0.379137593384847430f, -0.925340307823206200f, + 0.378427754808765620f, -0.925630830509872720f, 0.377717693613385810f, + -0.925920808671769960f, 0.377007410216418310f, -0.926210242138311270f, + 0.376296905035704790f, -0.926499130739230510f, 0.375586178489217330f, + -0.926787474304581750f, 0.374875230995057600f, -0.927075272664740100f, + 0.374164062971457990f, -0.927362525650401110f, 0.373452674836780410f, + -0.927649233092581180f, 0.372741067009515810f, -0.927935394822617890f, + 0.372029239908284960f, -0.928221010672169440f, 0.371317193951837600f, + -0.928506080473215480f, 0.370604929559051670f, -0.928790604058057020f, + 0.369892447148934270f, -0.929074581259315750f, 0.369179747140620070f, + -0.929358011909935500f, 0.368466829953372320f, -0.929640895843181330f, + 0.367753696006582090f, -0.929923232892639560f, 0.367040345719767240f, + -0.930205022892219070f, 0.366326779512573590f, -0.930486265676149780f, + 0.365612997804773960f, -0.930766961078983710f, 0.364899001016267380f, + -0.931047108935595170f, 0.364184789567079840f, -0.931326709081180430f, + 0.363470363877363870f, -0.931605761351257830f, 0.362755724367397230f, + -0.931884265581668150f, 0.362040871457584350f, -0.932162221608574320f, + 0.361325805568454340f, -0.932439629268462360f, 0.360610527120662270f, + -0.932716488398140250f, 0.359895036534988280f, -0.932992798834738850f, + 0.359179334232336560f, -0.933268560415712050f, 0.358463420633736540f, + -0.933543772978836170f, 0.357747296160342010f, -0.933818436362210960f, + 0.357030961233430030f, -0.934092550404258870f, 0.356314416274402360f, + -0.934366114943725900f, 0.355597661704783960f, -0.934639129819680780f, + 0.354880697946222790f, -0.934911594871516090f, 0.354163525420490510f, + -0.935183509938947500f, 0.353446144549480870f, -0.935454874862014620f, + 0.352728555755210730f, -0.935725689481080370f, 0.352010759459819240f, + -0.935995953636831300f, 0.351292756085567150f, -0.936265667170278260f, + 0.350574546054837570f, -0.936534829922755500f, 0.349856129790135030f, + -0.936803441735921560f, 0.349137507714085030f, -0.937071502451759190f, + 0.348418680249434510f, -0.937339011912574960f, 0.347699647819051490f, + -0.937605969960999990f, 0.346980410845923680f, -0.937872376439989890f, + 0.346260969753160170f, -0.938138231192824360f, 0.345541324963989150f, + -0.938403534063108060f, 0.344821476901759290f, -0.938668284894770170f, + 0.344101425989938980f, -0.938932483532064490f, 0.343381172652115100f, + -0.939196129819569900f, 0.342660717311994380f, -0.939459223602189920f, + 0.341940060393402300f, -0.939721764725153340f, 0.341219202320282410f, + -0.939983753034013940f, 0.340498143516697100f, -0.940245188374650880f, + 0.339776884406826960f, -0.940506070593268300f, 0.339055425414969640f, + -0.940766399536396070f, 0.338333766965541290f, -0.941026175050889260f, + 0.337611909483074680f, -0.941285396983928660f, 0.336889853392220050f, + -0.941544065183020810f, 0.336167599117744690f, -0.941802179495997650f, + 0.335445147084531660f, -0.942059739771017310f, 0.334722497717581220f, + -0.942316745856563780f, 0.333999651442009490f, -0.942573197601446870f, + 0.333276608683047980f, -0.942829094854802710f, 0.332553369866044220f, + -0.943084437466093490f, 0.331829935416461220f, -0.943339225285107720f, + 0.331106305759876430f, -0.943593458161960390f, 0.330382481321982950f, + -0.943847135947092690f, 0.329658462528587550f, -0.944100258491272660f, + 0.328934249805612200f, -0.944352825645594750f, 0.328209843579092660f, + -0.944604837261480260f, 0.327485244275178060f, -0.944856293190677210f, + 0.326760452320131790f, -0.945107193285260610f, 0.326035468140330350f, + -0.945357537397632290f, 0.325310292162262980f, -0.945607325380521280f, + 0.324584924812532150f, -0.945856557086983910f, 0.323859366517852960f, + -0.946105232370403340f, 0.323133617705052330f, -0.946353351084490590f, + 0.322407678801070020f, -0.946600913083283530f, 0.321681550232956640f, + -0.946847918221148000f, 0.320955232427875210f, -0.947094366352777220f, + 0.320228725813100020f, -0.947340257333191940f, 0.319502030816015750f, + -0.947585591017741090f, 0.318775147864118480f, -0.947830367262101010f, + 0.318048077385015060f, -0.948074585922276230f, 0.317320819806421790f, + -0.948318246854599090f, 0.316593375556165850f, -0.948561349915730270f, + 0.315865745062184070f, -0.948803894962658380f, 0.315137928752522440f, + -0.949045881852700560f, 0.314409927055336820f, -0.949287310443502010f, + 0.313681740398891570f, -0.949528180593036670f, 0.312953369211560200f, + -0.949768492159606680f, 0.312224813921825050f, -0.950008245001843000f, + 0.311496074958275970f, -0.950247438978705230f, 0.310767152749611470f, + -0.950486073949481700f, 0.310038047724638000f, -0.950724149773789610f, + 0.309308760312268780f, -0.950961666311575080f, 0.308579290941525030f, + -0.951198623423113230f, 0.307849640041534980f, -0.951435020969008340f, + 0.307119808041533100f, -0.951670858810193860f, 0.306389795370861080f, + -0.951906136807932230f, 0.305659602458966230f, -0.952140854823815830f, + 0.304929229735402430f, -0.952375012719765880f, 0.304198677629829270f, + -0.952608610358033240f, 0.303467946572011370f, -0.952841647601198720f, + 0.302737036991819140f, -0.953074124312172200f, 0.302005949319228200f, + -0.953306040354193750f, 0.301274683984318000f, -0.953537395590833280f, + 0.300543241417273400f, -0.953768189885990330f, 0.299811622048383460f, + -0.953998423103894490f, 0.299079826308040480f, -0.954228095109105670f, + 0.298347854626741570f, -0.954457205766513490f, 0.297615707435086310f, + -0.954685754941338340f, 0.296883385163778270f, -0.954913742499130520f, + 0.296150888243623960f, -0.955141168305770670f, 0.295418217105532070f, + -0.955368032227470240f, 0.294685372180514330f, -0.955594334130771110f, + 0.293952353899684770f, -0.955820073882545420f, 0.293219162694258680f, + -0.956045251349996410f, 0.292485798995553830f, -0.956269866400658140f, + 0.291752263234989370f, -0.956493918902394990f, 0.291018555844085090f, + -0.956717408723403050f, 0.290284677254462330f, -0.956940335732208940f, + 0.289550627897843140f, -0.957162699797670100f, 0.288816408206049480f, + -0.957384500788975860f, 0.288082018611004300f, -0.957605738575646240f, + 0.287347459544729570f, -0.957826413027532910f, 0.286612731439347790f, + -0.958046524014818600f, 0.285877834727080730f, -0.958266071408017670f, + 0.285142769840248720f, -0.958485055077976100f, 0.284407537211271820f, + -0.958703474895871600f, 0.283672137272668550f, -0.958921330733213060f, + 0.282936570457055390f, -0.959138622461841890f, 0.282200837197147500f, + -0.959355349953930790f, 0.281464937925758050f, -0.959571513081984520f, + 0.280728873075797190f, -0.959787111718839900f, 0.279992643080273380f, + -0.960002145737665850f, 0.279256248372291240f, -0.960216615011963430f, + 0.278519689385053060f, -0.960430519415565790f, 0.277782966551857800f, + -0.960643858822638470f, 0.277046080306099950f, -0.960856633107679660f, + 0.276309031081271030f, -0.961068842145519350f, 0.275571819310958250f, + -0.961280485811320640f, 0.274834445428843940f, -0.961491563980579000f, + 0.274096909868706330f, -0.961702076529122540f, 0.273359213064418790f, + -0.961912023333112100f, 0.272621355449948980f, -0.962121404269041580f, + 0.271883337459359890f, -0.962330219213737400f, 0.271145159526808070f, + -0.962538468044359160f, 0.270406822086544820f, -0.962746150638399410f, + 0.269668325572915200f, -0.962953266873683880f, 0.268929670420357310f, + -0.963159816628371360f, 0.268190857063403180f, -0.963365799780954050f, + 0.267451885936677740f, -0.963571216210257210f, 0.266712757474898420f, + -0.963776065795439840f, 0.265973472112875530f, -0.963980348415994110f, + 0.265234030285511900f, -0.964184063951745720f, 0.264494432427801630f, + -0.964387212282854290f, 0.263754678974831510f, -0.964589793289812650f, + 0.263014770361779060f, -0.964791806853447900f, 0.262274707023913590f, + -0.964993252854920320f, 0.261534489396595630f, -0.965194131175724720f, + 0.260794117915275570f, -0.965394441697689400f, 0.260053593015495130f, + -0.965594184302976830f, 0.259312915132886350f, -0.965793358874083570f, + 0.258572084703170390f, -0.965991965293840570f, 0.257831102162158930f, + -0.966190003445412620f, 0.257089967945753230f, -0.966387473212298790f, + 0.256348682489942910f, -0.966584374478333120f, 0.255607246230807550f, + -0.966780707127683270f, 0.254865659604514630f, -0.966976471044852070f, + 0.254123923047320620f, -0.967171666114676640f, 0.253382036995570270f, + -0.967366292222328510f, 0.252640001885695580f, -0.967560349253314360f, + 0.251897818154216910f, -0.967753837093475510f, 0.251155486237742030f, + -0.967946755628987800f, 0.250413006572965280f, -0.968139104746362330f, + 0.249670379596668520f, -0.968330884332445300f, 0.248927605745720260f, + -0.968522094274417270f, 0.248184685457074780f, -0.968712734459794780f, + 0.247441619167773440f, -0.968902804776428870f, 0.246698407314942500f, + -0.969092305112506100f, 0.245955050335794590f, -0.969281235356548530f, + 0.245211548667627680f, -0.969469595397412950f, 0.244467902747824210f, + -0.969657385124292450f, 0.243724113013852130f, -0.969844604426714830f, + 0.242980179903263980f, -0.970031253194543970f, 0.242236103853696070f, + -0.970217331317979160f, 0.241491885302869300f, -0.970402838687555500f, + 0.240747524688588540f, -0.970587775194143630f, 0.240003022448741500f, + -0.970772140728950350f, 0.239258379021300120f, -0.970955935183517970f, + 0.238513594844318500f, -0.971139158449725090f, 0.237768670355934210f, + -0.971321810419786160f, 0.237023605994367340f, -0.971503890986251780f, + 0.236278402197919620f, -0.971685400042008540f, 0.235533059404975460f, + -0.971866337480279400f, 0.234787578054001080f, -0.972046703194623500f, + 0.234041958583543460f, -0.972226497078936270f, 0.233296201432231560f, + -0.972405719027449770f, 0.232550307038775330f, -0.972584368934732210f, + 0.231804275841964780f, -0.972762446695688570f, 0.231058108280671280f, + -0.972939952205560070f, 0.230311804793845530f, -0.973116885359925130f, + 0.229565365820518870f, -0.973293246054698250f, 0.228818791799802360f, + -0.973469034186130950f, 0.228072083170885790f, -0.973644249650811870f, + 0.227325240373038830f, -0.973818892345666100f, 0.226578263845610110f, + -0.973992962167955830f, 0.225831154028026200f, -0.974166459015280320f, + 0.225083911359792780f, -0.974339382785575860f, 0.224336536280493690f, + -0.974511733377115720f, 0.223589029229790020f, -0.974683510688510670f, + 0.222841390647421280f, -0.974854714618708430f, 0.222093620973203590f, + -0.975025345066994120f, 0.221345720647030810f, -0.975195401932990370f, + 0.220597690108873650f, -0.975364885116656870f, 0.219849529798778750f, + -0.975533794518291360f, 0.219101240156869770f, -0.975702130038528570f, + 0.218352821623346430f, -0.975869891578341030f, 0.217604274638483670f, + -0.976037079039039020f, 0.216855599642632570f, -0.976203692322270560f, + 0.216106797076219600f, -0.976369731330021140f, 0.215357867379745550f, + -0.976535195964614470f, 0.214608810993786920f, -0.976700086128711840f, + 0.213859628358993830f, -0.976864401725312640f, 0.213110319916091360f, + -0.977028142657754390f, 0.212360886105878580f, -0.977191308829712280f, + 0.211611327369227610f, -0.977353900145199960f, 0.210861644147084830f, + -0.977515916508569280f, 0.210111836880469720f, -0.977677357824509930f, + 0.209361906010474190f, -0.977838223998050430f, 0.208611851978263460f, + -0.977998514934557140f, 0.207861675225075150f, -0.978158230539735050f, + 0.207111376192218560f, -0.978317370719627650f, 0.206360955321075680f, + -0.978475935380616830f, 0.205610413053099320f, -0.978633924429423100f, + 0.204859749829814420f, -0.978791337773105670f, 0.204108966092817010f, + -0.978948175319062200f, 0.203358062283773370f, -0.979104436975029250f, + 0.202607038844421110f, -0.979260122649082020f, 0.201855896216568160f, + -0.979415232249634780f, 0.201104634842091960f, -0.979569765685440520f, + 0.200353255162940420f, -0.979723722865591170f, 0.199601757621131050f, + -0.979877103699517640f, 0.198850142658750120f, -0.980029908096989980f, + 0.198098410717953730f, -0.980182135968117320f, 0.197346562240966000f, + -0.980333787223347960f, 0.196594597670080220f, -0.980484861773469380f, + 0.195842517447657990f, -0.980635359529608120f, 0.195090322016128330f, + -0.980785280403230430f, 0.194338011817988600f, -0.980934624306141640f, + 0.193585587295803750f, -0.981083391150486590f, 0.192833048892205290f, + -0.981231580848749730f, 0.192080397049892380f, -0.981379193313754560f, + 0.191327632211630990f, -0.981526228458664660f, 0.190574754820252800f, + -0.981672686196983110f, 0.189821765318656580f, -0.981818566442552500f, + 0.189068664149806280f, -0.981963869109555240f, 0.188315451756732120f, + -0.982108594112513610f, 0.187562128582529740f, -0.982252741366289370f, + 0.186808695070359330f, -0.982396310786084690f, 0.186055151663446630f, + -0.982539302287441240f, 0.185301498805082040f, -0.982681715786240860f, + 0.184547736938619640f, -0.982823551198705240f, 0.183793866507478390f, + -0.982964808441396440f, 0.183039887955141060f, -0.983105487431216290f, + 0.182285801725153320f, -0.983245588085407070f, 0.181531608261125130f, + -0.983385110321551180f, 0.180777308006728670f, -0.983524054057571260f, + 0.180022901405699510f, -0.983662419211730250f, 0.179268388901835880f, + -0.983800205702631490f, 0.178513770938997590f, -0.983937413449218920f, + 0.177759047961107140f, -0.984074042370776450f, 0.177004220412148860f, + -0.984210092386929030f, 0.176249288736167940f, -0.984345563417641900f, + 0.175494253377271400f, -0.984480455383220930f, 0.174739114779627310f, + -0.984614768204312600f, 0.173983873387463850f, -0.984748501801904210f, + 0.173228529645070490f, -0.984881656097323700f, 0.172473083996796030f, + -0.985014231012239840f, 0.171717536887049970f, -0.985146226468662230f, + 0.170961888760301360f, -0.985277642388941220f, 0.170206140061078120f, + -0.985408478695768420f, 0.169450291233967930f, -0.985538735312176060f, + 0.168694342723617440f, -0.985668412161537550f, 0.167938294974731230f, + -0.985797509167567370f, 0.167182148432072880f, -0.985926026254321130f, + 0.166425903540464220f, -0.986053963346195440f, 0.165669560744784140f, + -0.986181320367928270f, 0.164913120489970090f, -0.986308097244598670f, + 0.164156583221015890f, -0.986434293901627070f, 0.163399949382973230f, + -0.986559910264775410f, 0.162643219420950450f, -0.986684946260146690f, + 0.161886393780111910f, -0.986809401814185420f, 0.161129472905678780f, + -0.986933276853677710f, 0.160372457242928400f, -0.987056571305750970f, + 0.159615347237193090f, -0.987179285097874340f, 0.158858143333861390f, + -0.987301418157858430f, 0.158100845978377090f, -0.987422970413855410f, + 0.157343455616238280f, -0.987543941794359230f, 0.156585972692998590f, + -0.987664332228205710f, 0.155828397654265320f, -0.987784141644572180f, + 0.155070730945700510f, -0.987903369972977790f, 0.154312973013020240f, + -0.988022017143283530f, 0.153555124301993500f, -0.988140083085692570f, + 0.152797185258443410f, -0.988257567730749460f, 0.152039156328246160f, + -0.988374471009341280f, 0.151281037957330250f, -0.988490792852696590f, + 0.150522830591677370f, -0.988606533192386450f, 0.149764534677321620f, + -0.988721691960323780f, 0.149006150660348470f, -0.988836269088763540f, + 0.148247678986896200f, -0.988950264510302990f, 0.147489120103153680f, + -0.989063678157881540f, 0.146730474455361750f, -0.989176509964781010f, + 0.145971742489812370f, -0.989288759864625170f, 0.145212924652847520f, + -0.989400427791380380f, 0.144454021390860440f, -0.989511513679355190f, + 0.143695033150294580f, -0.989622017463200780f, 0.142935960377642700f, + -0.989731939077910570f, 0.142176803519448000f, -0.989841278458820530f, + 0.141417563022303130f, -0.989950035541608990f, 0.140658239332849240f, + -0.990058210262297120f, 0.139898832897777380f, -0.990165802557248400f, + 0.139139344163826280f, -0.990272812363169110f, 0.138379773577783890f, + -0.990379239617108160f, 0.137620121586486180f, -0.990485084256456980f, + 0.136860388636816430f, -0.990590346218950150f, 0.136100575175706200f, + -0.990695025442664630f, 0.135340681650134330f, -0.990799121866020370f, + 0.134580708507126220f, -0.990902635427780010f, 0.133820656193754690f, + -0.991005566067049370f, 0.133060525157139180f, -0.991107913723276780f, + 0.132300315844444680f, -0.991209678336254060f, 0.131540028702883280f, + -0.991310859846115440f, 0.130779664179711790f, -0.991411458193338540f, + 0.130019222722233350f, -0.991511473318743900f, 0.129258704777796270f, + -0.991610905163495370f, 0.128498110793793220f, -0.991709753669099530f, + 0.127737441217662280f, -0.991808018777406430f, 0.126976696496885980f, + -0.991905700430609330f, 0.126215877078990400f, -0.992002798571244520f, + 0.125454983411546210f, -0.992099313142191800f, 0.124694015942167770f, + -0.992195244086673920f, 0.123932975118512200f, -0.992290591348257370f, + 0.123171861388280650f, -0.992385354870851670f, 0.122410675199216280f, + -0.992479534598709970f, 0.121649416999105540f, -0.992573130476428810f, + 0.120888087235777220f, -0.992666142448948020f, 0.120126686357101580f, + -0.992758570461551140f, 0.119365214810991350f, -0.992850414459865100f, + 0.118603673045400840f, -0.992941674389860470f, 0.117842061508325020f, + -0.993032350197851410f, 0.117080380647800550f, -0.993122441830495580f, + 0.116318630911904880f, -0.993211949234794500f, 0.115556812748755290f, + -0.993300872358093280f, 0.114794926606510250f, -0.993389211148080650f, + 0.114032972933367300f, -0.993476965552789190f, 0.113270952177564360f, + -0.993564135520595300f, 0.112508864787378830f, -0.993650721000219120f, + 0.111746711211126660f, -0.993736721940724600f, 0.110984491897163380f, + -0.993822138291519660f, 0.110222207293883180f, -0.993906970002356060f, + 0.109459857849718030f, -0.993991217023329380f, 0.108697444013138670f, + -0.994074879304879370f, 0.107934966232653760f, -0.994157956797789730f, + 0.107172424956808870f, -0.994240449453187900f, 0.106409820634187840f, + -0.994322357222545810f, 0.105647153713410700f, -0.994403680057679100f, + 0.104884424643134970f, -0.994484417910747600f, 0.104121633872054730f, + -0.994564570734255420f, 0.103358781848899700f, -0.994644138481050710f, + 0.102595869022436280f, -0.994723121104325700f, 0.101832895841466670f, + -0.994801518557617110f, 0.101069862754827880f, -0.994879330794805620f, + 0.100306770211392820f, -0.994956557770116380f, 0.099543618660069444f, + -0.995033199438118630f, 0.098780408549799664f, -0.995109255753726110f, + 0.098017140329560770f, -0.995184726672196820f, 0.097253814448363354f, + -0.995259612149133390f, 0.096490431355252607f, -0.995333912140482280f, + 0.095726991499307315f, -0.995407626602534900f, 0.094963495329639061f, + -0.995480755491926940f, 0.094199943295393190f, -0.995553298765638470f, + 0.093436335845747912f, -0.995625256380994310f, 0.092672673429913366f, + -0.995696628295663520f, 0.091908956497132696f, -0.995767414467659820f, + 0.091145185496681130f, -0.995837614855341610f, 0.090381360877865011f, + -0.995907229417411720f, 0.089617483090022917f, -0.995976258112917790f, + 0.088853552582524684f, -0.996044700901251970f, 0.088089569804770507f, + -0.996112557742151130f, 0.087325535206192226f, -0.996179828595696870f, + 0.086561449236251239f, -0.996246513422315520f, 0.085797312344439880f, + -0.996312612182778000f, 0.085033124980280414f, -0.996378124838200210f, + 0.084268887593324127f, -0.996443051350042630f, 0.083504600633152404f, + -0.996507391680110820f, 0.082740264549375803f, -0.996571145790554840f, + 0.081975879791633108f, -0.996634313643869900f, 0.081211446809592386f, + -0.996696895202896060f, 0.080446966052950097f, -0.996758890430818000f, + 0.079682437971430126f, -0.996820299291165670f, 0.078917863014785095f, + -0.996881121747813850f, 0.078153241632794315f, -0.996941357764982160f, + 0.077388574275265049f, -0.997001007307235290f, 0.076623861392031617f, + -0.997060070339482960f, 0.075859103432954503f, -0.997118546826979980f, + 0.075094300847921291f, -0.997176436735326190f, 0.074329454086845867f, + -0.997233740030466160f, 0.073564563599667454f, -0.997290456678690210f, + 0.072799629836351618f, -0.997346586646633230f, 0.072034653246889416f, + -0.997402129901275300f, 0.071269634281296415f, -0.997457086409941910f, + 0.070504573389614009f, -0.997511456140303450f, 0.069739471021907376f, + -0.997565239060375750f, 0.068974327628266732f, -0.997618435138519550f, + 0.068209143658806454f, -0.997671044343441000f, 0.067443919563664106f, + -0.997723066644191640f, 0.066678655793001543f, -0.997774502010167820f, + 0.065913352797003930f, -0.997825350411111640f, 0.065148011025878860f, + -0.997875611817110150f, 0.064382630929857410f, -0.997925286198596000f, + 0.063617212959193190f, -0.997974373526346990f, 0.062851757564161420f, + -0.998022873771486240f, 0.062086265195060247f, -0.998070786905482340f, + 0.061320736302208648f, -0.998118112900149180f, 0.060555171335947781f, + -0.998164851727646240f, 0.059789570746640007f, -0.998211003360478190f, + 0.059023934984667986f, -0.998256567771495180f, 0.058258264500435732f, + -0.998301544933892890f, 0.057492559744367684f, -0.998345934821212370f, + 0.056726821166907783f, -0.998389737407340160f, 0.055961049218520520f, + -0.998432952666508440f, 0.055195244349690031f, -0.998475580573294770f, + 0.054429407010919147f, -0.998517621102622210f, 0.053663537652730679f, + -0.998559074229759310f, 0.052897636725665401f, -0.998599939930320370f, + 0.052131704680283317f, -0.998640218180265270f, 0.051365741967162731f, + -0.998679908955899090f, 0.050599749036899337f, -0.998719012233872940f, + 0.049833726340107257f, -0.998757527991183340f, 0.049067674327418126f, + -0.998795456205172410f, 0.048301593449480172f, -0.998832796853527990f, + 0.047535484156959261f, -0.998869549914283560f, 0.046769346900537960f, + -0.998905715365818290f, 0.046003182130914644f, -0.998941293186856870f, + 0.045236990298804750f, -0.998976283356469820f, 0.044470771854938744f, + -0.999010685854073380f, 0.043704527250063421f, -0.999044500659429290f, + 0.042938256934940959f, -0.999077727752645360f, 0.042171961360348002f, + -0.999110367114174890f, 0.041405640977076712f, -0.999142418724816910f, + 0.040639296235933854f, -0.999173882565716380f, 0.039872927587739845f, + -0.999204758618363890f, 0.039106535483329839f, -0.999235046864595850f, + 0.038340120373552791f, -0.999264747286594420f, 0.037573682709270514f, + -0.999293859866887790f, 0.036807222941358991f, -0.999322384588349540f, + 0.036040741520706299f, -0.999350321434199440f, 0.035274238898213947f, + -0.999377670388002850f, 0.034507715524795889f, -0.999404431433671300f, + 0.033741171851377642f, -0.999430604555461730f, 0.032974608328897315f, + -0.999456189737977340f, 0.032208025408304704f, -0.999481186966166950f, + 0.031441423540560343f, -0.999505596225325310f, 0.030674803176636581f, + -0.999529417501093140f, 0.029908164767516655f, -0.999552650779456990f, + 0.029141508764193740f, -0.999575296046749220f, 0.028374835617672258f, + -0.999597353289648380f, 0.027608145778965820f, -0.999618822495178640f, + 0.026841439699098527f, -0.999639703650710200f, 0.026074717829104040f, + -0.999659996743959220f, 0.025307980620024630f, -0.999679701762987930f, + 0.024541228522912264f, -0.999698818696204250f, 0.023774461988827676f, + -0.999717347532362190f, 0.023007681468839410f, -0.999735288260561680f, + 0.022240887414024919f, -0.999752640870248840f, 0.021474080275469605f, + -0.999769405351215280f, 0.020707260504265912f, -0.999785581693599210f, + 0.019940428551514598f, -0.999801169887884260f, 0.019173584868322699f, + -0.999816169924900410f, 0.018406729905804820f, -0.999830581795823400f, + 0.017639864115082195f, -0.999844405492175240f, 0.016872987947281773f, + -0.999857641005823860f, 0.016106101853537263f, -0.999870288328982950f, + 0.015339206284988220f, -0.999882347454212560f, 0.014572301692779104f, + -0.999893818374418490f, 0.013805388528060349f, -0.999904701082852900f, + 0.013038467241987433f, -0.999914995573113470f, 0.012271538285719944f, + -0.999924701839144500f, 0.011504602110422875f, -0.999933819875236000f, + 0.010737659167264572f, -0.999942349676023910f, 0.009970709907418029f, + -0.999950291236490480f, 0.009203754782059960f, -0.999957644551963900f, + 0.008436794242369860f, -0.999964409618118280f, 0.007669828739531077f, + -0.999970586430974140f, 0.006902858724729877f, -0.999976174986897610f, + 0.006135884649154515f, -0.999981175282601110f, 0.005368906963996303f, + -0.999985587315143200f, 0.004601926120448672f, -0.999989411081928400f, + 0.003834942569706248f, -0.999992646580707190f, 0.003067956762966138f, + -0.999995293809576190f, 0.002300969151425887f, -0.999997352766978210f, + 0.001533980186284766f, -0.999998823451701880f, 0.000766990318742846f, + -0.999999705862882230f}; static const float32_t Weights_8192[16384] = { - 1.000000000000000000f, -0.000000000000000000f, 0.999999981616429330f, - -0.000191747597310703f, - 0.999999926465717890f, -0.000383495187571396f, 0.999999834547867670f, - -0.000575242763732066f, - 0.999999705862882230f, -0.000766990318742704f, 0.999999540410766110f, - -0.000958737845553301f, - 0.999999338191525530f, -0.001150485337113849f, 0.999999099205167830f, - -0.001342232786374338f, - 0.999998823451701880f, -0.001533980186284766f, 0.999998510931137790f, - -0.001725727529795126f, - 0.999998161643486980f, -0.001917474809855419f, 0.999997775588762350f, - -0.002109222019415644f, - 0.999997352766978210f, -0.002300969151425805f, 0.999996893178149880f, - -0.002492716198835908f, - 0.999996396822294350f, -0.002684463154595962f, 0.999995863699429940f, - -0.002876210011655979f, - 0.999995293809576190f, -0.003067956762965976f, 0.999994687152754080f, - -0.003259703401475973f, - 0.999994043728985820f, -0.003451449920135994f, 0.999993363538295150f, - -0.003643196311896068f, - 0.999992646580707190f, -0.003834942569706228f, 0.999991892856248010f, - -0.004026688686516512f, - 0.999991102364945590f, -0.004218434655276963f, 0.999990275106828920f, - -0.004410180468937631f, - 0.999989411081928400f, -0.004601926120448571f, 0.999988510290275690f, - -0.004793671602759841f, - 0.999987572731904080f, -0.004985416908821511f, 0.999986598406848000f, - -0.005177162031583651f, - 0.999985587315143200f, -0.005368906963996343f, 0.999984539456826970f, - -0.005560651699009674f, - 0.999983454831937730f, -0.005752396229573736f, 0.999982333440515350f, - -0.005944140548638633f, - 0.999981175282601110f, -0.006135884649154475f, 0.999979980358237650f, - -0.006327628524071378f, - 0.999978748667468830f, -0.006519372166339468f, 0.999977480210339940f, - -0.006711115568908879f, - 0.999976174986897610f, -0.006902858724729756f, 0.999974832997189810f, - -0.007094601626752250f, - 0.999973454241265940f, -0.007286344267926521f, 0.999972038719176730f, - -0.007478086641202744f, - 0.999970586430974140f, -0.007669828739531097f, 0.999969097376711580f, - -0.007861570555861772f, - 0.999967571556443780f, -0.008053312083144972f, 0.999966008970226920f, - -0.008245053314330906f, - 0.999964409618118280f, -0.008436794242369799f, 0.999962773500176930f, - -0.008628534860211886f, - 0.999961100616462820f, -0.008820275160807412f, 0.999959390967037450f, - -0.009012015137106633f, - 0.999957644551963900f, -0.009203754782059819f, 0.999955861371306100f, - -0.009395494088617252f, - 0.999954041425129780f, -0.009587233049729225f, 0.999952184713501780f, - -0.009778971658346044f, - 0.999950291236490480f, -0.009970709907418031f, 0.999948360994165400f, - -0.010162447789895513f, - 0.999946393986597460f, -0.010354185298728842f, 0.999944390213859060f, - -0.010545922426868378f, - 0.999942349676023910f, -0.010737659167264491f, 0.999940272373166960f, - -0.010929395512867571f, - 0.999938158305364590f, -0.011121131456628021f, 0.999936007472694620f, - -0.011312866991496258f, - 0.999933819875236000f, -0.011504602110422714f, 0.999931595513069200f, - -0.011696336806357838f, - 0.999929334386276070f, -0.011888071072252092f, 0.999927036494939640f, - -0.012079804901055957f, - 0.999924701839144500f, -0.012271538285719925f, 0.999922330418976490f, - -0.012463271219194511f, - 0.999919922234522750f, -0.012655003694430242f, 0.999917477285871770f, - -0.012846735704377662f, - 0.999914995573113470f, -0.013038467241987334f, 0.999912477096339240f, - -0.013230198300209835f, - 0.999909921855641540f, -0.013421928871995765f, 0.999907329851114300f, - -0.013613658950295740f, - 0.999904701082852900f, -0.013805388528060391f, 0.999902035550953920f, - -0.013997117598240367f, - 0.999899333255515390f, -0.014188846153786345f, 0.999896594196636680f, - -0.014380574187649006f, - 0.999893818374418490f, -0.014572301692779064f, 0.999891005788962950f, - -0.014764028662127246f, - 0.999888156440373320f, -0.014955755088644296f, 0.999885270328754520f, - -0.015147480965280987f, - 0.999882347454212560f, -0.015339206284988100f, 0.999879387816854930f, - -0.015530931040716447f, - 0.999876391416790410f, -0.015722655225416857f, 0.999873358254129260f, - -0.015914378832040183f, - 0.999870288328982950f, -0.016106101853537287f, 0.999867181641464380f, - -0.016297824282859065f, - 0.999864038191687680f, -0.016489546112956437f, 0.999860857979768540f, - -0.016681267336780332f, - 0.999857641005823860f, -0.016872987947281710f, 0.999854387269971890f, - -0.017064707937411563f, - 0.999851096772332190f, -0.017256427300120877f, 0.999847769513025900f, - -0.017448146028360693f, - 0.999844405492175240f, -0.017639864115082053f, 0.999841004709904000f, - -0.017831581553236039f, - 0.999837567166337090f, -0.018023298335773746f, 0.999834092861600960f, - -0.018215014455646290f, - 0.999830581795823400f, -0.018406729905804820f, 0.999827033969133420f, - -0.018598444679200511f, - 0.999823449381661570f, -0.018790158768784555f, 0.999819828033539420f, - -0.018981872167508178f, - 0.999816169924900410f, -0.019173584868322623f, 0.999812475055878780f, - -0.019365296864179156f, - 0.999808743426610520f, -0.019557008148029083f, 0.999804975037232870f, - -0.019748718712823729f, - 0.999801169887884260f, -0.019940428551514441f, 0.999797327978704690f, - -0.020132137657052594f, - 0.999793449309835270f, -0.020323846022389593f, 0.999789533881418780f, - -0.020515553640476875f, - 0.999785581693599210f, -0.020707260504265895f, 0.999781592746521670f, - -0.020898966606708137f, - 0.999777567040332940f, -0.021090671940755121f, 0.999773504575180990f, - -0.021282376499358387f, - 0.999769405351215280f, -0.021474080275469508f, 0.999765269368586450f, - -0.021665783262040078f, - 0.999761096627446610f, -0.021857485452021735f, 0.999756887127949080f, - -0.022049186838366135f, - 0.999752640870248840f, -0.022240887414024961f, 0.999748357854501780f, - -0.022432587171949934f, - 0.999744038080865430f, -0.022624286105092803f, 0.999739681549498660f, - -0.022815984206405345f, - 0.999735288260561680f, -0.023007681468839369f, 0.999730858214216030f, - -0.023199377885346720f, - 0.999726391410624470f, -0.023391073448879258f, 0.999721887849951310f, - -0.023582768152388894f, - 0.999717347532362190f, -0.023774461988827555f, 0.999712770458023870f, - -0.023966154951147210f, - 0.999708156627104880f, -0.024157847032299864f, 0.999703506039774650f, - -0.024349538225237534f, - 0.999698818696204250f, -0.024541228522912288f, 0.999694094596566000f, - -0.024732917918276223f, - 0.999689333741033640f, -0.024924606404281468f, 0.999684536129782140f, - -0.025116293973880186f, - 0.999679701762987930f, -0.025307980620024571f, 0.999674830640828740f, - -0.025499666335666853f, - 0.999669922763483760f, -0.025691351113759295f, 0.999664978131133310f, - -0.025883034947254198f, - 0.999659996743959220f, -0.026074717829103901f, 0.999654978602144690f, - -0.026266399752260760f, - 0.999649923705874240f, -0.026458080709677187f, 0.999644832055333610f, - -0.026649760694305618f, - 0.999639703650710200f, -0.026841439699098531f, 0.999634538492192300f, - -0.027033117717008431f, - 0.999629336579970110f, -0.027224794740987875f, 0.999624097914234570f, - -0.027416470763989436f, - 0.999618822495178640f, -0.027608145778965740f, 0.999613510322995950f, - -0.027799819778869445f, - 0.999608161397882110f, -0.027991492756653243f, 0.999602775720033530f, - -0.028183164705269874f, - 0.999597353289648380f, -0.028374835617672099f, 0.999591894106925950f, - -0.028566505486812728f, - 0.999586398172067070f, -0.028758174305644615f, 0.999580865485273700f, - -0.028949842067120635f, - 0.999575296046749220f, -0.029141508764193722f, 0.999569689856698580f, - -0.029333174389816835f, - 0.999564046915327740f, -0.029524838936942976f, 0.999558367222844300f, - -0.029716502398525191f, - 0.999552650779456990f, -0.029908164767516555f, 0.999546897585375960f, - -0.030099826036870198f, - 0.999541107640812940f, -0.030291486199539284f, 0.999535280945980540f, - -0.030483145248477009f, - 0.999529417501093140f, -0.030674803176636626f, 0.999523517306366350f, - -0.030866459976971412f, - 0.999517580362016990f, -0.031058115642434700f, 0.999511606668263440f, - -0.031249770165979861f, - 0.999505596225325310f, -0.031441423540560301f, 0.999499549033423640f, - -0.031633075759129478f, - 0.999493465092780590f, -0.031824726814640887f, 0.999487344403620080f, - -0.032016376700048060f, - 0.999481186966166950f, -0.032208025408304586f, 0.999474992780647780f, - -0.032399672932364086f, - 0.999468761847290050f, -0.032591319265180226f, 0.999462494166323160f, - -0.032782964399706724f, - 0.999456189737977340f, -0.032974608328897335f, 0.999449848562484530f, - -0.033166251045705857f, - 0.999443470640077770f, -0.033357892543086139f, 0.999437055970991530f, - -0.033549532813992068f, - 0.999430604555461730f, -0.033741171851377580f, 0.999424116393725640f, - -0.033932809648196664f, - 0.999417591486021720f, -0.034124446197403326f, 0.999411029832589780f, - -0.034316081491951651f, - 0.999404431433671300f, -0.034507715524795750f, 0.999397796289508640f, - -0.034699348288889799f, - 0.999391124400346050f, -0.034890979777188004f, 0.999384415766428560f, - -0.035082609982644619f, - 0.999377670388002850f, -0.035274238898213947f, 0.999370888265317170f, - -0.035465866516850353f, - 0.999364069398620550f, -0.035657492831508222f, 0.999357213788164000f, - -0.035849117835142018f, - 0.999350321434199440f, -0.036040741520706229f, 0.999343392336980220f, - -0.036232363881155395f, - 0.999336426496761240f, -0.036423984909444110f, 0.999329423913798420f, - -0.036615604598527030f, - 0.999322384588349540f, -0.036807222941358832f, 0.999315308520673070f, - -0.036998839930894263f, - 0.999308195711029470f, -0.037190455560088119f, 0.999301046159680070f, - -0.037382069821895229f, - 0.999293859866887790f, -0.037573682709270494f, 0.999286636832916740f, - -0.037765294215168860f, - 0.999279377058032710f, -0.037956904332545310f, 0.999272080542502610f, - -0.038148513054354891f, - 0.999264747286594420f, -0.038340120373552694f, 0.999257377290578060f, - -0.038531726283093870f, - 0.999249970554724420f, -0.038723330775933623f, 0.999242527079305830f, - -0.038914933845027193f, - 0.999235046864595850f, -0.039106535483329888f, 0.999227529910869610f, - -0.039298135683797059f, - 0.999219976218403530f, -0.039489734439384118f, 0.999212385787475290f, - -0.039681331743046527f, - 0.999204758618363890f, -0.039872927587739811f, 0.999197094711349880f, - -0.040064521966419520f, - 0.999189394066714920f, -0.040256114872041282f, 0.999181656684742350f, - -0.040447706297560782f, - 0.999173882565716380f, -0.040639296235933736f, 0.999166071709923000f, - -0.040830884680115948f, - 0.999158224117649430f, -0.041022471623063238f, 0.999150339789184110f, - -0.041214057057731519f, - 0.999142418724816910f, -0.041405640977076739f, 0.999134460924839150f, - -0.041597223374054894f, - 0.999126466389543390f, -0.041788804241622061f, 0.999118435119223490f, - -0.041980383572734356f, - 0.999110367114174890f, -0.042171961360347947f, 0.999102262374694130f, - -0.042363537597419072f, - 0.999094120901079070f, -0.042555112276904020f, 0.999085942693629270f, - -0.042746685391759132f, - 0.999077727752645360f, -0.042938256934940820f, 0.999069476078429330f, - -0.043129826899405546f, - 0.999061187671284600f, -0.043321395278109825f, 0.999052862531515930f, - -0.043512962064010237f, - 0.999044500659429290f, -0.043704527250063421f, 0.999036102055332330f, - -0.043896090829226068f, - 0.999027666719533690f, -0.044087652794454944f, 0.999019194652343460f, - -0.044279213138706849f, - 0.999010685854073380f, -0.044470771854938668f, 0.999002140325035980f, - -0.044662328936107325f, - 0.998993558065545680f, -0.044853884375169815f, 0.998984939075918010f, - -0.045045438165083197f, - 0.998976283356469820f, -0.045236990298804590f, 0.998967590907519300f, - -0.045428540769291155f, - 0.998958861729386080f, -0.045620089569500144f, 0.998950095822391250f, - -0.045811636692388844f, - 0.998941293186856870f, -0.046003182130914623f, 0.998932453823106690f, - -0.046194725878034908f, - 0.998923577731465780f, -0.046386267926707157f, 0.998914664912260440f, - -0.046577808269888943f, - 0.998905715365818290f, -0.046769346900537863f, 0.998896729092468410f, - -0.046960883811611592f, - 0.998887706092541290f, -0.047152418996067869f, 0.998878646366368690f, - -0.047343952446864478f, - 0.998869549914283560f, -0.047535484156959303f, 0.998860416736620520f, - -0.047727014119310254f, - 0.998851246833715180f, -0.047918542326875327f, 0.998842040205904840f, - -0.048110068772612591f, - 0.998832796853527990f, -0.048301593449480144f, 0.998823516776924490f, - -0.048493116350436176f, - 0.998814199976435390f, -0.048684637468438943f, 0.998804846452403420f, - -0.048876156796446760f, - 0.998795456205172410f, -0.049067674327418015f, 0.998786029235087640f, - -0.049259190054311140f, - 0.998776565542495610f, -0.049450703970084664f, 0.998767065127744380f, - -0.049642216067697156f, - 0.998757527991183340f, -0.049833726340107277f, 0.998747954133162860f, - -0.050025234780273729f, - 0.998738343554035230f, -0.050216741381155311f, 0.998728696254153720f, - -0.050408246135710856f, - 0.998719012233872940f, -0.050599749036899282f, 0.998709291493549030f, - -0.050791250077679581f, - 0.998699534033539280f, -0.050982749251010803f, 0.998689739854202620f, - -0.051174246549852080f, - 0.998679908955899090f, -0.051365741967162593f, 0.998670041338990070f, - -0.051557235495901611f, - 0.998660137003838490f, -0.051748727129028456f, 0.998650195950808280f, - -0.051940216859502536f, - 0.998640218180265270f, -0.052131704680283324f, 0.998630203692576050f, - -0.052323190584330347f, - 0.998620152488108870f, -0.052514674564603223f, 0.998610064567233340f, - -0.052706156614061632f, - 0.998599939930320370f, -0.052897636725665324f, 0.998589778577742230f, - -0.053089114892374133f, - 0.998579580509872500f, -0.053280591107147945f, 0.998569345727086110f, - -0.053472065362946727f, - 0.998559074229759310f, -0.053663537652730520f, 0.998548766018269920f, - -0.053855007969459440f, - 0.998538421092996730f, -0.054046476306093660f, 0.998528039454320230f, - -0.054237942655593452f, - 0.998517621102622210f, -0.054429407010919133f, 0.998507166038285490f, - -0.054620869365031105f, - 0.998496674261694640f, -0.054812329710889854f, 0.998486145773235360f, - -0.055003788041455920f, - 0.998475580573294770f, -0.055195244349689934f, 0.998464978662261250f, - -0.055386698628552597f, - 0.998454340040524800f, -0.055578150871004678f, 0.998443664708476340f, - -0.055769601070007030f, - 0.998432952666508440f, -0.055961049218520569f, 0.998422203915015020f, - -0.056152495309506292f, - 0.998411418454391300f, -0.056343939335925290f, 0.998400596285033640f, - -0.056535381290738700f, - 0.998389737407340160f, -0.056726821166907748f, 0.998378841821709990f, - -0.056918258957393740f, - 0.998367909528543820f, -0.057109694655158062f, 0.998356940528243420f, - -0.057301128253162158f, - 0.998345934821212370f, -0.057492559744367566f, 0.998334892407855000f, - -0.057683989121735904f, - 0.998323813288577560f, -0.057875416378228857f, 0.998312697463787260f, - -0.058066841506808194f, - 0.998301544933892890f, -0.058258264500435752f, 0.998290355699304350f, - -0.058449685352073476f, - 0.998279129760433200f, -0.058641104054683341f, 0.998267867117692110f, - -0.058832520601227435f, - 0.998256567771495180f, -0.059023934984667931f, 0.998245231722257880f, - -0.059215347197967061f, - 0.998233858970396850f, -0.059406757234087150f, 0.998222449516330550f, - -0.059598165085990591f, - 0.998211003360478190f, -0.059789570746639868f, 0.998199520503260660f, - -0.059980974208997548f, - 0.998188000945100300f, -0.060172375466026259f, 0.998176444686420530f, - -0.060363774510688743f, - 0.998164851727646240f, -0.060555171335947788f, 0.998153222069203760f, - -0.060746565934766288f, - 0.998141555711520520f, -0.060937958300107203f, 0.998129852655025630f, - -0.061129348424933588f, - 0.998118112900149180f, -0.061320736302208578f, 0.998106336447323050f, - -0.061512121924895378f, - 0.998094523296980010f, -0.061703505285957298f, 0.998082673449554590f, - -0.061894886378357716f, - 0.998070786905482340f, -0.062086265195060088f, 0.998058863665200250f, - -0.062277641729027972f, - 0.998046903729146840f, -0.062469015973224996f, 0.998034907097761770f, - -0.062660387920614874f, - 0.998022873771486240f, -0.062851757564161406f, 0.998010803750762450f, - -0.063043124896828492f, - 0.997998697036034390f, -0.063234489911580066f, 0.997986553627747020f, - -0.063425852601380228f, - 0.997974373526346990f, -0.063617212959193106f, 0.997962156732281950f, - -0.063808570977982898f, - 0.997949903246001190f, -0.063999926650713940f, 0.997937613067955250f, - -0.064191279970350637f, - 0.997925286198596000f, -0.064382630929857465f, 0.997912922638376610f, - -0.064573979522198982f, - 0.997900522387751620f, -0.064765325740339885f, 0.997888085447177110f, - -0.064956669577244872f, - 0.997875611817110150f, -0.065148011025878833f, 0.997863101498009500f, - -0.065339350079206632f, - 0.997850554490335110f, -0.065530686730193327f, 0.997837970794548280f, - -0.065722020971803990f, - 0.997825350411111640f, -0.065913352797003805f, 0.997812693340489280f, - -0.066104682198758077f, - 0.997799999583146470f, -0.066296009170032130f, 0.997787269139549960f, - -0.066487333703791451f, - 0.997774502010167820f, -0.066678655793001557f, 0.997761698195469560f, - -0.066869975430628115f, - 0.997748857695925690f, -0.067061292609636822f, 0.997735980512008620f, - -0.067252607322993499f, - 0.997723066644191640f, -0.067443919563664051f, 0.997710116092949570f, - -0.067635229324614479f, - 0.997697128858758500f, -0.067826536598810869f, 0.997684104942096030f, - -0.068017841379219388f, - 0.997671044343441000f, -0.068209143658806329f, 0.997657947063273710f, - -0.068400443430538013f, - 0.997644813102075420f, -0.068591740687380942f, 0.997631642460329320f, - -0.068783035422301630f, - 0.997618435138519550f, -0.068974327628266746f, 0.997605191137131640f, - -0.069165617298242985f, - 0.997591910456652630f, -0.069356904425197208f, 0.997578593097570800f, - -0.069548189002096306f, - 0.997565239060375750f, -0.069739471021907307f, 0.997551848345558430f, - -0.069930750477597309f, - 0.997538420953611340f, -0.070122027362133521f, 0.997524956885027960f, - -0.070313301668483250f, - 0.997511456140303450f, -0.070504573389613856f, 0.997497918719934210f, - -0.070695842518492855f, - 0.997484344624417930f, -0.070887109048087801f, 0.997470733854253670f, - -0.071078372971366405f, - 0.997457086409941910f, -0.071269634281296401f, 0.997443402291984360f, - -0.071460892970845680f, - 0.997429681500884180f, -0.071652149032982212f, 0.997415924037145960f, - -0.071843402460674027f, - 0.997402129901275300f, -0.072034653246889332f, 0.997388299093779460f, - -0.072225901384596322f, - 0.997374431615167150f, -0.072417146866763413f, 0.997360527465947940f, - -0.072608389686358993f, - 0.997346586646633230f, -0.072799629836351673f, 0.997332609157735470f, - -0.072990867309710036f, - 0.997318594999768600f, -0.073182102099402888f, 0.997304544173247990f, - -0.073373334198399032f, - 0.997290456678690210f, -0.073564563599667426f, 0.997276332516613180f, - -0.073755790296177098f, - 0.997262171687536170f, -0.073947014280897200f, 0.997247974191979860f, - -0.074138235546796979f, - 0.997233740030466280f, -0.074329454086845756f, 0.997219469203518670f, - -0.074520669894013000f, - 0.997205161711661850f, -0.074711882961268211f, 0.997190817555421940f, - -0.074903093281581082f, - 0.997176436735326190f, -0.075094300847921305f, 0.997162019251903290f, - -0.075285505653258769f, - 0.997147565105683480f, -0.075476707690563388f, 0.997133074297198110f, - -0.075667906952805231f, - 0.997118546826979980f, -0.075859103432954447f, 0.997103982695563330f, - -0.076050297123981259f, - 0.997089381903483400f, -0.076241488018856066f, 0.997074744451277310f, - -0.076432676110549283f, - 0.997060070339482960f, -0.076623861392031492f, 0.997045359568640040f, - -0.076815043856273343f, - 0.997030612139289450f, -0.077006223496245640f, 0.997015828051973310f, - -0.077197400304919200f, - 0.997001007307235290f, -0.077388574275265049f, 0.996986149905620180f, - -0.077579745400254224f, - 0.996971255847674320f, -0.077770913672857947f, 0.996956325133945280f, - -0.077962079086047492f, - 0.996941357764982160f, -0.078153241632794232f, 0.996926353741335090f, - -0.078344401306069705f, - 0.996911313063555740f, -0.078535558098845479f, 0.996896235732197210f, - -0.078726712004093299f, - 0.996881121747813850f, -0.078917863014784942f, 0.996865971110961310f, - -0.079109011123892375f, - 0.996850783822196610f, -0.079300156324387597f, 0.996835559882078170f, - -0.079491298609242769f, - 0.996820299291165670f, -0.079682437971430126f, 0.996805002050020430f, - -0.079873574403921996f, - 0.996789668159204560f, -0.080064707899690890f, 0.996774297619282050f, - -0.080255838451709319f, - 0.996758890430818000f, -0.080446966052950014f, 0.996743446594378860f, - -0.080638090696385709f, - 0.996727966110532490f, -0.080829212374989329f, 0.996712448979848010f, - -0.081020331081733857f, - 0.996696895202896060f, -0.081211446809592441f, 0.996681304780248300f, - -0.081402559551538245f, - 0.996665677712478160f, -0.081593669300544652f, 0.996650014000160070f, - -0.081784776049585076f, - 0.996634313643869900f, -0.081975879791633066f, 0.996618576644185070f, - -0.082166980519662314f, - 0.996602803001684130f, -0.082358078226646536f, 0.996586992716946950f, - -0.082549172905559673f, - 0.996571145790554840f, -0.082740264549375692f, 0.996555262223090540f, - -0.082931353151068699f, - 0.996539342015137940f, -0.083122438703612911f, 0.996523385167282450f, - -0.083313521199982685f, - 0.996507391680110820f, -0.083504600633152432f, 0.996491361554210920f, - -0.083695676996096716f, - 0.996475294790172160f, -0.083886750281790226f, 0.996459191388585410f, - -0.084077820483207694f, - 0.996443051350042630f, -0.084268887593324071f, 0.996426874675137240f, - -0.084459951605114325f, - 0.996410661364464100f, -0.084651012511553617f, 0.996394411418619290f, - -0.084842070305617134f, - 0.996378124838200210f, -0.085033124980280275f, 0.996361801623805720f, - -0.085224176528518478f, - 0.996345441776035900f, -0.085415224943307333f, 0.996329045295492380f, - -0.085606270217622529f, - 0.996312612182778000f, -0.085797312344439894f, 0.996296142438496850f, - -0.085988351316735337f, - 0.996279636063254650f, -0.086179387127484894f, 0.996263093057658140f, - -0.086370419769664752f, - 0.996246513422315520f, -0.086561449236251170f, 0.996229897157836500f, - -0.086752475520220543f, - 0.996213244264832040f, -0.086943498614549378f, 0.996196554743914220f, - -0.087134518512214307f, - 0.996179828595696980f, -0.087325535206192059f, 0.996163065820794950f, - -0.087516548689459531f, - 0.996146266419824620f, -0.087707558954993659f, 0.996129430393403740f, - -0.087898565995771588f, - 0.996112557742151130f, -0.088089569804770507f, 0.996095648466687300f, - -0.088280570374967740f, - 0.996078702567633980f, -0.088471567699340767f, 0.996061720045614000f, - -0.088662561770867149f, - 0.996044700901251970f, -0.088853552582524600f, 0.996027645135173610f, - -0.089044540127290892f, - 0.996010552748005870f, -0.089235524398144014f, 0.995993423740377360f, - -0.089426505388061961f, - 0.995976258112917790f, -0.089617483090022959f, 0.995959055866258320f, - -0.089808457497005278f, - 0.995941817001031350f, -0.089999428601987341f, 0.995924541517870800f, - -0.090190396397947695f, - 0.995907229417411720f, -0.090381360877864983f, 0.995889880700290720f, - -0.090572322034717989f, - 0.995872495367145730f, -0.090763279861485621f, 0.995855073418615790f, - -0.090954234351146926f, - 0.995837614855341610f, -0.091145185496681005f, 0.995820119677964910f, - -0.091336133291067184f, - 0.995802587887129160f, -0.091527077727284828f, 0.995785019483478750f, - -0.091718018798313455f, - 0.995767414467659820f, -0.091908956497132724f, 0.995749772840319510f, - -0.092099890816722388f, - 0.995732094602106430f, -0.092290821750062355f, 0.995714379753670610f, - -0.092481749290132600f, - 0.995696628295663520f, -0.092672673429913310f, 0.995678840228737540f, - -0.092863594162384724f, - 0.995661015553546910f, -0.093054511480527249f, 0.995643154270746900f, - -0.093245425377321375f, - 0.995625256380994310f, -0.093436335845747787f, 0.995607321884947050f, - -0.093627242878787195f, - 0.995589350783264600f, -0.093818146469420549f, 0.995571343076607770f, - -0.094009046610628838f, - 0.995553298765638470f, -0.094199943295393204f, 0.995535217851020390f, - -0.094390836516694943f, - 0.995517100333418110f, -0.094581726267515445f, 0.995498946213497770f, - -0.094772612540836243f, - 0.995480755491926940f, -0.094963495329638992f, 0.995462528169374420f, - -0.095154374626905486f, - 0.995444264246510340f, -0.095345250425617617f, 0.995425963724006160f, - -0.095536122718757471f, - 0.995407626602534900f, -0.095726991499307162f, 0.995389252882770690f, - -0.095917856760249040f, - 0.995370842565388990f, -0.096108718494565509f, 0.995352395651066810f, - -0.096299576695239128f, - 0.995333912140482280f, -0.096490431355252593f, 0.995315392034315070f, - -0.096681282467588725f, - 0.995296835333246090f, -0.096872130025230471f, 0.995278242037957670f, - -0.097062974021160917f, - 0.995259612149133390f, -0.097253814448363271f, 0.995240945667458130f, - -0.097444651299820870f, - 0.995222242593618360f, -0.097635484568517200f, 0.995203502928301510f, - -0.097826314247435861f, - 0.995184726672196930f, -0.098017140329560604f, 0.995165913825994620f, - -0.098207962807875276f, - 0.995147064390386470f, -0.098398781675363881f, 0.995128178366065490f, - -0.098589596925010584f, - 0.995109255753726110f, -0.098780408549799623f, 0.995090296554064000f, - -0.098971216542715429f, - 0.995071300767776170f, -0.099162020896742503f, 0.995052268395561050f, - -0.099352821604865540f, - 0.995033199438118630f, -0.099543618660069319f, 0.995014093896149700f, - -0.099734412055338825f, - 0.994994951770357020f, -0.099925201783659073f, 0.994975773061444140f, - -0.100115987838015310f, - 0.994956557770116380f, -0.100306770211392860f, 0.994937305897080070f, - -0.100497548896777200f, - 0.994918017443043200f, -0.100688323887153960f, 0.994898692408714870f, - -0.100879095175508860f, - 0.994879330794805620f, -0.101069862754827820f, 0.994859932602027320f, - -0.101260626618096830f, - 0.994840497831093180f, -0.101451386758302080f, 0.994821026482717860f, - -0.101642143168429830f, - 0.994801518557617110f, -0.101832895841466530f, 0.994781974056508260f, - -0.102023644770398740f, - 0.994762392980109930f, -0.102214389948213210f, 0.994742775329142010f, - -0.102405131367896720f, - 0.994723121104325700f, -0.102595869022436280f, 0.994703430306383860f, - -0.102786602904819040f, - 0.994683702936040250f, -0.102977333008032220f, 0.994663938994020390f, - -0.103168059325063230f, - 0.994644138481050710f, -0.103358781848899610f, 0.994624301397859400f, - -0.103549500572529070f, - 0.994604427745175660f, -0.103740215488939370f, 0.994584517523730340f, - -0.103930926591118510f, - 0.994564570734255420f, -0.104121633872054590f, 0.994544587377484300f, - -0.104312337324735800f, - 0.994524567454151740f, -0.104503036942150570f, 0.994504510964993700f, - -0.104693732717287390f, - 0.994484417910747600f, -0.104884424643134970f, 0.994464288292152390f, - -0.105075112712682040f, - 0.994444122109948040f, -0.105265796918917600f, 0.994423919364875950f, - -0.105456477254830710f, - 0.994403680057679100f, -0.105647153713410620f, 0.994383404189101430f, - -0.105837826287646670f, - 0.994363091759888570f, -0.106028494970528410f, 0.994342742770787270f, - -0.106219159755045480f, - 0.994322357222545810f, -0.106409820634187680f, 0.994301935115913580f, - -0.106600477600944960f, - 0.994281476451641550f, -0.106791130648307390f, 0.994260981230481790f, - -0.106981779769265230f, - 0.994240449453187900f, -0.107172424956808840f, 0.994219881120514960f, - -0.107363066203928760f, - 0.994199276233218910f, -0.107553703503615620f, 0.994178634792057590f, - -0.107744336848860280f, - 0.994157956797789730f, -0.107934966232653650f, 0.994137242251175720f, - -0.108125591647986870f, - 0.994116491152977070f, -0.108316213087851170f, 0.994095703503956930f, - -0.108506830545237920f, - 0.994074879304879370f, -0.108697444013138720f, 0.994054018556510210f, - -0.108888053484545190f, - 0.994033121259616400f, -0.109078658952449240f, 0.994012187414966220f, - -0.109269260409842780f, - 0.993991217023329380f, -0.109459857849717980f, 0.993970210085476920f, - -0.109650451265067100f, - 0.993949166602181130f, -0.109841040648882600f, 0.993928086574215830f, - -0.110031625994157000f, - 0.993906970002356060f, -0.110222207293883060f, 0.993885816887378090f, - -0.110412784541053630f, - 0.993864627230059750f, -0.110603357728661730f, 0.993843401031180180f, - -0.110793926849700560f, - 0.993822138291519660f, -0.110984491897163390f, 0.993800839011860120f, - -0.111175052864043720f, - 0.993779503192984580f, -0.111365609743335160f, 0.993758130835677430f, - -0.111556162528031480f, - 0.993736721940724600f, -0.111746711211126590f, 0.993715276508913230f, - -0.111937255785614570f, - 0.993693794541031790f, -0.112127796244489640f, 0.993672276037870010f, - -0.112318332580746170f, - 0.993650721000219120f, -0.112508864787378690f, 0.993629129428871720f, - -0.112699392857381860f, - 0.993607501324621610f, -0.112889916783750520f, 0.993585836688263950f, - -0.113080436559479620f, - 0.993564135520595300f, -0.113270952177564350f, 0.993542397822413600f, - -0.113461463630999950f, - 0.993520623594518090f, -0.113651970912781870f, 0.993498812837709360f, - -0.113842474015905710f, - 0.993476965552789190f, -0.114032972933367200f, 0.993455081740560960f, - -0.114223467658162260f, - 0.993433161401829360f, -0.114413958183286920f, 0.993411204537400060f, - -0.114604444501737420f, - 0.993389211148080650f, -0.114794926606510080f, 0.993367181234679600f, - -0.114985404490601460f, - 0.993345114798006910f, -0.115175878147008190f, 0.993323011838873950f, - -0.115366347568727140f, - 0.993300872358093280f, -0.115556812748755260f, 0.993278696356479030f, - -0.115747273680089720f, - 0.993256483834846440f, -0.115937730355727780f, 0.993234234794012290f, - -0.116128182768666930f, - 0.993211949234794500f, -0.116318630911904750f, 0.993189627158012620f, - -0.116509074778439040f, - 0.993167268564487230f, -0.116699514361267690f, 0.993144873455040430f, - -0.116889949653388780f, - 0.993122441830495580f, -0.117080380647800590f, 0.993099973691677570f, - -0.117270807337501460f, - 0.993077469039412300f, -0.117461229715489990f, 0.993054927874527320f, - -0.117651647774764860f, - 0.993032350197851410f, -0.117842061508324980f, 0.993009736010214580f, - -0.118032470909169340f, - 0.992987085312448390f, -0.118222875970297170f, 0.992964398105385610f, - -0.118413276684707790f, - 0.992941674389860470f, -0.118603673045400720f, 0.992918914166708300f, - -0.118794065045375640f, - 0.992896117436765980f, -0.118984452677632340f, 0.992873284200871730f, - -0.119174835935170880f, - 0.992850414459865100f, -0.119365214810991350f, 0.992827508214586760f, - -0.119555589298094110f, - 0.992804565465879140f, -0.119745959389479600f, 0.992781586214585570f, - -0.119936325078148470f, - 0.992758570461551140f, -0.120126686357101500f, 0.992735518207621850f, - -0.120317043219339680f, - 0.992712429453645460f, -0.120507395657864130f, 0.992689304200470750f, - -0.120697743665676110f, - 0.992666142448948020f, -0.120888087235777080f, 0.992642944199928820f, - -0.121078426361168640f, - 0.992619709454266140f, -0.121268761034852600f, 0.992596438212814290f, - -0.121459091249830840f, - 0.992573130476428810f, -0.121649416999105530f, 0.992549786245966680f, - -0.121839738275678890f, - 0.992526405522286100f, -0.122030055072553360f, 0.992502988306246950f, - -0.122220367382731540f, - 0.992479534598709970f, -0.122410675199216200f, 0.992456044400537700f, - -0.122600978515010240f, - 0.992432517712593660f, -0.122791277323116770f, 0.992408954535742850f, - -0.122981571616539050f, - 0.992385354870851670f, -0.123171861388280480f, 0.992361718718787870f, - -0.123362146631344680f, - 0.992338046080420420f, -0.123552427338735370f, 0.992314336956619640f, - -0.123742703503456510f, - 0.992290591348257370f, -0.123932975118512160f, 0.992266809256206580f, - -0.124123242176906600f, - 0.992242990681341700f, -0.124313504671644230f, 0.992219135624538450f, - -0.124503762595729660f, - 0.992195244086673920f, -0.124694015942167640f, 0.992171316068626520f, - -0.124884264703963130f, - 0.992147351571276090f, -0.125074508874121170f, 0.992123350595503720f, - -0.125264748445647060f, - 0.992099313142191800f, -0.125454983411546230f, 0.992075239212224070f, - -0.125645213764824290f, - 0.992051128806485720f, -0.125835439498487000f, 0.992026981925863360f, - -0.126025660605540320f, - 0.992002798571244520f, -0.126215877078990350f, 0.991978578743518580f, - -0.126406088911843380f, - 0.991954322443575950f, -0.126596296097105850f, 0.991930029672308480f, - -0.126786498627784410f, - 0.991905700430609330f, -0.126976696496885870f, 0.991881334719373010f, - -0.127166889697417160f, - 0.991856932539495470f, -0.127357078222385400f, 0.991832493891873780f, - -0.127547262064797970f, - 0.991808018777406430f, -0.127737441217662310f, 0.991783507196993490f, - -0.127927615673986080f, - 0.991758959151536110f, -0.128117785426777130f, 0.991734374641936810f, - -0.128307950469043420f, - 0.991709753669099530f, -0.128498110793793170f, 0.991685096233929420f, - -0.128688266394034690f, - 0.991660402337333210f, -0.128878417262776550f, 0.991635671980218740f, - -0.129068563393027410f, - 0.991610905163495370f, -0.129258704777796140f, 0.991586101888073500f, - -0.129448841410091780f, - 0.991561262154865290f, -0.129638973282923560f, 0.991536385964783880f, - -0.129829100389300930f, - 0.991511473318743900f, -0.130019222722233350f, 0.991486524217661480f, - -0.130209340274730630f, - 0.991461538662453790f, -0.130399453039802690f, 0.991436516654039420f, - -0.130589561010459650f, - 0.991411458193338540f, -0.130779664179711710f, 0.991386363281272280f, - -0.130969762540569380f, - 0.991361231918763460f, -0.131159856086043270f, 0.991336064106736140f, - -0.131349944809144190f, - 0.991310859846115440f, -0.131540028702883120f, 0.991285619137828200f, - -0.131730107760271160f, - 0.991260341982802440f, -0.131920181974319790f, 0.991235028381967420f, - -0.132110251338040360f, - 0.991209678336254060f, -0.132300315844444650f, 0.991184291846594180f, - -0.132490375486544550f, - 0.991158868913921350f, -0.132680430257352070f, 0.991133409539170170f, - -0.132870480149879430f, - 0.991107913723276890f, -0.133060525157139060f, 0.991082381467178640f, - -0.133250565272143570f, - 0.991056812771814340f, -0.133440600487905680f, 0.991031207638124130f, - -0.133630630797438340f, - 0.991005566067049370f, -0.133820656193754720f, 0.990979888059532740f, - -0.134010676669868130f, - 0.990954173616518500f, -0.134200692218792020f, 0.990928422738951990f, - -0.134390702833540070f, - 0.990902635427780010f, -0.134580708507126170f, 0.990876811683950700f, - -0.134770709232564350f, - 0.990850951508413620f, -0.134960705002868750f, 0.990825054902119470f, - -0.135150695811053850f, - 0.990799121866020370f, -0.135340681650134210f, 0.990773152401069780f, - -0.135530662513124590f, - 0.990747146508222710f, -0.135720638393039910f, 0.990721104188435180f, - -0.135910609282895330f, - 0.990695025442664630f, -0.136100575175706200f, 0.990668910271870100f, - -0.136290536064487960f, - 0.990642758677011570f, -0.136480491942256280f, 0.990616570659050620f, - -0.136670442802027090f, - 0.990590346218950150f, -0.136860388636816380f, 0.990564085357674370f, - -0.137050329439640410f, - 0.990537788076188750f, -0.137240265203515590f, 0.990511454375460290f, - -0.137430195921458550f, - 0.990485084256457090f, -0.137620121586486040f, 0.990458677720148620f, - -0.137810042191615080f, - 0.990432234767505970f, -0.137999957729862790f, 0.990405755399501260f, - -0.138189868194246560f, - 0.990379239617108160f, -0.138379773577783890f, 0.990352687421301450f, - -0.138569673873492500f, - 0.990326098813057330f, -0.138759569074390350f, 0.990299473793353590f, - -0.138949459173495490f, - 0.990272812363169110f, -0.139139344163826200f, 0.990246114523483990f, - -0.139329224038400980f, - 0.990219380275280000f, -0.139519098790238490f, 0.990192609619540030f, - -0.139708968412357550f, - 0.990165802557248400f, -0.139898832897777210f, 0.990138959089390650f, - -0.140088692239516670f, - 0.990112079216953770f, -0.140278546430595420f, 0.990085162940925970f, - -0.140468395464033000f, - 0.990058210262297120f, -0.140658239332849210f, 0.990031221182058000f, - -0.140848078030064080f, - 0.990004195701200910f, -0.141037911548697710f, 0.989977133820719610f, - -0.141227739881770510f, - 0.989950035541608990f, -0.141417563022303020f, 0.989922900864865450f, - -0.141607380963316020f, - 0.989895729791486660f, -0.141797193697830390f, 0.989868522322471580f, - -0.141987001218867290f, - 0.989841278458820530f, -0.142176803519448030f, 0.989813998201535260f, - -0.142366600592594180f, - 0.989786681551618640f, -0.142556392431327340f, 0.989759328510075200f, - -0.142746179028669460f, - 0.989731939077910570f, -0.142935960377642670f, 0.989704513256131850f, - -0.143125736471269190f, - 0.989677051045747210f, -0.143315507302571500f, 0.989649552447766530f, - -0.143505272864572290f, - 0.989622017463200890f, -0.143695033150294470f, 0.989594446093062460f, - -0.143884788152760980f, - 0.989566838338365120f, -0.144074537864995160f, 0.989539194200123930f, - -0.144264282280020440f, - 0.989511513679355190f, -0.144454021390860470f, 0.989483796777076760f, - -0.144643755190539040f, - 0.989456043494307710f, -0.144833483672080210f, 0.989428253832068230f, - -0.145023206828508220f, - 0.989400427791380380f, -0.145212924652847460f, 0.989372565373267010f, - -0.145402637138122570f, - 0.989344666578752640f, -0.145592344277358340f, 0.989316731408863000f, - -0.145782046063579860f, - 0.989288759864625170f, -0.145971742489812210f, 0.989260751947067640f, - -0.146161433549080900f, - 0.989232707657220050f, -0.146351119234411460f, 0.989204626996113780f, - -0.146540799538829760f, - 0.989176509964781010f, -0.146730474455361750f, 0.989148356564255590f, - -0.146920143977033620f, - 0.989120166795572690f, -0.147109808096871820f, 0.989091940659768800f, - -0.147299466807902850f, - 0.989063678157881540f, -0.147489120103153570f, 0.989035379290950310f, - -0.147678767975650970f, - 0.989007044060015270f, -0.147868410418422220f, 0.988978672466118480f, - -0.148058047424494720f, - 0.988950264510302990f, -0.148247678986896030f, 0.988921820193613190f, - -0.148437305098653970f, - 0.988893339517095130f, -0.148626925752796540f, 0.988864822481795640f, - -0.148816540942351920f, - 0.988836269088763540f, -0.149006150660348450f, 0.988807679339048450f, - -0.149195754899814820f, - 0.988779053233701520f, -0.149385353653779720f, 0.988750390773775360f, - -0.149574946915272230f, - 0.988721691960323780f, -0.149764534677321510f, 0.988692956794401940f, - -0.149954116932956960f, - 0.988664185277066230f, -0.150143693675208190f, 0.988635377409374790f, - -0.150333264897105000f, - 0.988606533192386450f, -0.150522830591677400f, 0.988577652627162020f, - -0.150712390751955610f, - 0.988548735714763200f, -0.150901945370970040f, 0.988519782456253270f, - -0.151091494441751300f, - 0.988490792852696590f, -0.151281037957330220f, 0.988461766905159300f, - -0.151470575910737810f, - 0.988432704614708340f, -0.151660108295005310f, 0.988403605982412390f, - -0.151849635103164180f, - 0.988374471009341280f, -0.152039156328246050f, 0.988345299696566150f, - -0.152228671963282740f, - 0.988316092045159690f, -0.152418182001306330f, 0.988286848056195820f, - -0.152607686435349050f, - 0.988257567730749460f, -0.152797185258443440f, 0.988228251069897420f, - -0.152986678463622040f, - 0.988198898074717610f, -0.153176166043917840f, 0.988169508746289060f, - -0.153365647992363880f, - 0.988140083085692570f, -0.153555124301993450f, 0.988110621094009820f, - -0.153744594965840030f, - 0.988081122772324070f, -0.153934059976937350f, 0.988051588121720110f, - -0.154123519328319360f, - 0.988022017143283530f, -0.154312973013020100f, 0.987992409838101880f, - -0.154502421024073940f, - 0.987962766207263420f, -0.154691863354515430f, 0.987933086251858380f, - -0.154881299997379320f, - 0.987903369972977790f, -0.155070730945700510f, 0.987873617371714200f, - -0.155260156192514240f, - 0.987843828449161740f, -0.155449575730855850f, 0.987814003206415550f, - -0.155638989553760900f, - 0.987784141644572180f, -0.155828397654265230f, 0.987754243764729530f, - -0.156017800025404800f, - 0.987724309567986960f, -0.156207196660215900f, 0.987694339055445130f, - -0.156396587551734880f, - 0.987664332228205710f, -0.156585972692998430f, 0.987634289087372160f, - -0.156775352077043350f, - 0.987604209634049160f, -0.156964725696906780f, 0.987574093869342360f, - -0.157154093545625900f, - 0.987543941794359230f, -0.157343455616238250f, 0.987513753410208420f, - -0.157532811901781530f, - 0.987483528717999710f, -0.157722162395293630f, 0.987453267718844560f, - -0.157911507089812660f, - 0.987422970413855410f, -0.158100845978376980f, 0.987392636804146240f, - -0.158290179054025180f, - 0.987362266890832400f, -0.158479506309795960f, 0.987331860675030430f, - -0.158668827738728310f, - 0.987301418157858430f, -0.158858143333861450f, 0.987270939340435420f, - -0.159047453088234760f, - 0.987240424223882250f, -0.159236756994887850f, 0.987209872809320820f, - -0.159426055046860580f, - 0.987179285097874340f, -0.159615347237193060f, 0.987148661090667570f, - -0.159804633558925440f, - 0.987118000788826280f, -0.159993914005098270f, 0.987087304193477900f, - -0.160183188568752220f, - 0.987056571305750970f, -0.160372457242928280f, 0.987025802126775600f, - -0.160561720020667490f, - 0.986994996657682980f, -0.160750976895011220f, 0.986964154899605650f, - -0.160940227859001080f, - 0.986933276853677710f, -0.161129472905678810f, 0.986902362521034470f, - -0.161318712028086400f, - 0.986871411902812470f, -0.161507945219266120f, 0.986840425000149680f, - -0.161697172472260400f, - 0.986809401814185530f, -0.161886393780111830f, 0.986778342346060430f, - -0.162075609135863330f, - 0.986747246596916590f, -0.162264818532558000f, 0.986716114567897100f, - -0.162454021963239190f, - 0.986684946260146690f, -0.162643219420950310f, 0.986653741674811350f, - -0.162832410898735210f, - 0.986622500813038480f, -0.163021596389637840f, 0.986591223675976400f, - -0.163210775886702380f, - 0.986559910264775410f, -0.163399949382973230f, 0.986528560580586690f, - -0.163589116871495020f, - 0.986497174624562880f, -0.163778278345312670f, 0.986465752397857940f, - -0.163967433797471170f, - 0.986434293901627180f, -0.164156583221015810f, 0.986402799137027220f, - -0.164345726608992190f, - 0.986371268105216030f, -0.164534863954446000f, 0.986339700807353000f, - -0.164723995250423170f, - 0.986308097244598670f, -0.164913120489969890f, 0.986276457418115090f, - -0.165102239666132660f, - 0.986244781329065460f, -0.165291352771958000f, 0.986213068978614490f, - -0.165480459800492780f, - 0.986181320367928270f, -0.165669560744784120f, 0.986149535498173860f, - -0.165858655597879300f, - 0.986117714370520090f, -0.166047744352825790f, 0.986085856986136820f, - -0.166236827002671420f, - 0.986053963346195440f, -0.166425903540464100f, 0.986022033451868560f, - -0.166614973959252090f, - 0.985990067304330140f, -0.166804038252083730f, 0.985958064904755460f, - -0.166993096412007710f, - 0.985926026254321130f, -0.167182148432072940f, 0.985893951354205210f, - -0.167371194305328430f, - 0.985861840205586980f, -0.167560234024823560f, 0.985829692809647050f, - -0.167749267583607890f, - 0.985797509167567480f, -0.167938294974731170f, 0.985765289280531310f, - -0.168127316191243410f, - 0.985733033149723490f, -0.168316331226194830f, 0.985700740776329850f, - -0.168505340072635900f, - 0.985668412161537550f, -0.168694342723617330f, 0.985636047306535420f, - -0.168883339172189980f, - 0.985603646212513400f, -0.169072329411405010f, 0.985571208880662740f, - -0.169261313434313830f, - 0.985538735312176060f, -0.169450291233967960f, 0.985506225508247290f, - -0.169639262803419290f, - 0.985473679470071810f, -0.169828228135719850f, 0.985441097198846210f, - -0.170017187223921950f, - 0.985408478695768420f, -0.170206140061078070f, 0.985375823962037710f, - -0.170395086640240940f, - 0.985343132998854790f, -0.170584026954463590f, 0.985310405807421570f, - -0.170772960996799230f, - 0.985277642388941220f, -0.170961888760301220f, 0.985244842744618540f, - -0.171150810238023280f, - 0.985212006875659350f, -0.171339725423019310f, 0.985179134783271130f, - -0.171528634308343420f, - 0.985146226468662230f, -0.171717536887049970f, 0.985113281933042710f, - -0.171906433152193530f, - 0.985080301177623800f, -0.172095323096829010f, 0.985047284203618200f, - -0.172284206714011370f, - 0.985014231012239840f, -0.172473083996795950f, 0.984981141604703960f, - -0.172661954938238270f, - 0.984948015982227030f, -0.172850819531394080f, 0.984914854146027200f, - -0.173039677769319360f, - 0.984881656097323700f, -0.173228529645070320f, 0.984848421837337010f, - -0.173417375151703470f, - 0.984815151367289140f, -0.173606214282275410f, 0.984781844688403350f, - -0.173795047029843160f, - 0.984748501801904210f, -0.173983873387463820f, 0.984715122709017620f, - -0.174172693348194820f, - 0.984681707410970940f, -0.174361506905093750f, 0.984648255908992630f, - -0.174550314051218510f, - 0.984614768204312600f, -0.174739114779627200f, 0.984581244298162180f, - -0.174927909083378160f, - 0.984547684191773960f, -0.175116696955529920f, 0.984514087886381840f, - -0.175305478389141320f, - 0.984480455383220930f, -0.175494253377271430f, 0.984446786683527920f, - -0.175683021912979490f, - 0.984413081788540700f, -0.175871783989325040f, 0.984379340699498510f, - -0.176060539599367820f, - 0.984345563417641900f, -0.176249288736167880f, 0.984311749944212780f, - -0.176438031392785410f, - 0.984277900280454370f, -0.176626767562280880f, 0.984244014427611110f, - -0.176815497237715000f, - 0.984210092386929030f, -0.177004220412148750f, 0.984176134159655320f, - -0.177192937078643280f, - 0.984142139747038570f, -0.177381647230260040f, 0.984108109150328540f, - -0.177570350860060710f, - 0.984074042370776450f, -0.177759047961107170f, 0.984039939409634970f, - -0.177947738526461560f, - 0.984005800268157870f, -0.178136422549186300f, 0.983971624947600270f, - -0.178325100022344000f, - 0.983937413449218920f, -0.178513770938997510f, 0.983903165774271500f, - -0.178702435292209970f, - 0.983868881924017220f, -0.178891093075044720f, 0.983834561899716630f, - -0.179079744280565390f, - 0.983800205702631600f, -0.179268388901835750f, 0.983765813334025240f, - -0.179457026931919890f, - 0.983731384795162090f, -0.179645658363882160f, 0.983696920087308140f, - -0.179834283190787090f, - 0.983662419211730250f, -0.180022901405699510f, 0.983627882169697210f, - -0.180211513001684450f, - 0.983593308962478650f, -0.180400117971807240f, 0.983558699591345900f, - -0.180588716309133340f, - 0.983524054057571260f, -0.180777308006728590f, 0.983489372362428730f, - -0.180965893057658980f, - 0.983454654507193270f, -0.181154471454990810f, 0.983419900493141540f, - -0.181343043191790540f, - 0.983385110321551180f, -0.181531608261124970f, 0.983350283993701500f, - -0.181720166656061110f, - 0.983315421510872810f, -0.181908718369666160f, 0.983280522874346970f, - -0.182097263395007650f, - 0.983245588085407070f, -0.182285801725153300f, 0.983210617145337640f, - -0.182474333353171120f, - 0.983175610055424420f, -0.182662858272129270f, 0.983140566816954500f, - -0.182851376475096330f, - 0.983105487431216290f, -0.183039887955140950f, 0.983070371899499640f, - -0.183228392705332140f, - 0.983035220223095640f, -0.183416890718739100f, 0.983000032403296590f, - -0.183605381988431270f, - 0.982964808441396440f, -0.183793866507478450f, 0.982929548338690170f, - -0.183982344268950520f, - 0.982894252096474070f, -0.184170815265917720f, 0.982858919716046110f, - -0.184359279491450510f, - 0.982823551198705240f, -0.184547736938619620f, 0.982788146545751970f, - -0.184736187600495950f, - 0.982752705758487830f, -0.184924631470150790f, 0.982717228838215990f, - -0.185113068540655540f, - 0.982681715786240860f, -0.185301498805081900f, 0.982646166603868050f, - -0.185489922256501880f, - 0.982610581292404750f, -0.185678338887987630f, 0.982574959853159240f, - -0.185866748692611660f, - 0.982539302287441240f, -0.186055151663446630f, 0.982503608596561830f, - -0.186243547793565560f, - 0.982467878781833170f, -0.186431937076041610f, 0.982432112844569110f, - -0.186620319503948280f, - 0.982396310786084690f, -0.186808695070359270f, 0.982360472607696210f, - -0.186997063768348540f, - 0.982324598310721280f, -0.187185425590990330f, 0.982288687896478830f, - -0.187373780531359110f, - 0.982252741366289370f, -0.187562128582529600f, 0.982216758721474510f, - -0.187750469737576780f, - 0.982180739963357090f, -0.187938803989575910f, 0.982144685093261580f, - -0.188127131331602420f, - 0.982108594112513610f, -0.188315451756732120f, 0.982072467022440000f, - -0.188503765258040940f, - 0.982036303824369020f, -0.188692071828605230f, 0.982000104519630490f, - -0.188880371461501380f, - 0.981963869109555240f, -0.189068664149806190f, 0.981927597595475540f, - -0.189256949886596750f, - 0.981891289978725100f, -0.189445228664950230f, 0.981854946260638630f, - -0.189633500477944190f, - 0.981818566442552500f, -0.189821765318656410f, 0.981782150525804310f, - -0.190010023180164990f, - 0.981745698511732990f, -0.190198274055548150f, 0.981709210401678800f, - -0.190386517937884470f, - 0.981672686196983110f, -0.190574754820252740f, 0.981636125898989080f, - -0.190762984695732110f, - 0.981599529509040720f, -0.190951207557401800f, 0.981562897028483650f, - -0.191139423398341450f, - 0.981526228458664770f, -0.191327632211630900f, 0.981489523800932130f, - -0.191515833990350210f, - 0.981452783056635520f, -0.191704028727579800f, 0.981416006227125550f, - -0.191892216416400220f, - 0.981379193313754560f, -0.192080397049892440f, 0.981342344317876040f, - -0.192268570621137500f, - 0.981305459240844670f, -0.192456737123216840f, 0.981268538084016710f, - -0.192644896549212100f, - 0.981231580848749730f, -0.192833048892205230f, 0.981194587536402320f, - -0.193021194145278380f, - 0.981157558148334830f, -0.193209332301513960f, 0.981120492685908730f, - -0.193397463353994740f, - 0.981083391150486710f, -0.193585587295803610f, 0.981046253543432780f, - -0.193773704120023820f, - 0.981009079866112630f, -0.193961813819738840f, 0.980971870119892840f, - -0.194149916388032450f, - 0.980934624306141640f, -0.194338011817988600f, 0.980897342426228390f, - -0.194526100102691610f, - 0.980860024481523870f, -0.194714181235225960f, 0.980822670473400100f, - -0.194902255208676520f, - 0.980785280403230430f, -0.195090322016128250f, 0.980747854272389750f, - -0.195278381650666550f, - 0.980710392082253970f, -0.195466434105376980f, 0.980672893834200530f, - -0.195654479373345370f, - 0.980635359529608120f, -0.195842517447657850f, 0.980597789169856850f, - -0.196030548321400790f, - 0.980560182756327840f, -0.196218571987660880f, 0.980522540290404090f, - -0.196406588439524970f, - 0.980484861773469380f, -0.196594597670080220f, 0.980447147206909060f, - -0.196782599672414100f, - 0.980409396592109910f, -0.196970594439614340f, 0.980371609930459800f, - -0.197158581964768880f, - 0.980333787223347960f, -0.197346562240965920f, 0.980295928472165290f, - -0.197534535261294030f, - 0.980258033678303550f, -0.197722501018841920f, 0.980220102843156080f, - -0.197910459506698670f, - 0.980182135968117430f, -0.198098410717953560f, 0.980144133054583590f, - -0.198286354645696220f, - 0.980106094103951770f, -0.198474291283016390f, 0.980068019117620650f, - -0.198662220623004200f, - 0.980029908096990090f, -0.198850142658750090f, 0.979991761043461200f, - -0.199038057383344680f, - 0.979953577958436740f, -0.199225964789878830f, 0.979915358843320480f, - -0.199413864871443770f, - 0.979877103699517640f, -0.199601757621130970f, 0.979838812528434740f, - -0.199789643032032090f, - 0.979800485331479790f, -0.199977521097239150f, 0.979762122110061750f, - -0.200165391809844440f, - 0.979723722865591170f, -0.200353255162940450f, 0.979685287599479930f, - -0.200541111149619980f, - 0.979646816313141210f, -0.200728959762976140f, 0.979608309007989450f, - -0.200916800996102230f, - 0.979569765685440520f, -0.201104634842091900f, 0.979531186346911500f, - -0.201292461294039020f, - 0.979492570993820810f, -0.201480280345037730f, 0.979453919627588210f, - -0.201668091988182530f, - 0.979415232249634780f, -0.201855896216568050f, 0.979376508861383170f, - -0.202043693023289260f, - 0.979337749464256780f, -0.202231482401441450f, 0.979298954059681040f, - -0.202419264344120160f, - 0.979260122649082020f, -0.202607038844421130f, 0.979221255233887700f, - -0.202794805895440440f, - 0.979182351815526930f, -0.202982565490274440f, 0.979143412395430230f, - -0.203170317622019790f, - 0.979104436975029250f, -0.203358062283773320f, 0.979065425555756930f, - -0.203545799468632190f, - 0.979026378139047580f, -0.203733529169693920f, 0.978987294726337050f, - -0.203921251380056120f, - 0.978948175319062200f, -0.204108966092816870f, 0.978909019918661310f, - -0.204296673301074370f, - 0.978869828526574120f, -0.204484372997927240f, 0.978830601144241470f, - -0.204672065176474210f, - 0.978791337773105670f, -0.204859749829814420f, 0.978752038414610340f, - -0.205047426951047250f, - 0.978712703070200420f, -0.205235096533272350f, 0.978673331741322210f, - -0.205422758569589610f, - 0.978633924429423210f, -0.205610413053099240f, 0.978594481135952270f, - -0.205798059976901790f, - 0.978555001862359550f, -0.205985699334097910f, 0.978515486610096910f, - -0.206173331117788710f, - 0.978475935380616830f, -0.206360955321075510f, 0.978436348175373730f, - -0.206548571937059890f, - 0.978396724995823090f, -0.206736180958843690f, 0.978357065843421640f, - -0.206923782379529100f, - 0.978317370719627650f, -0.207111376192218560f, 0.978277639625900530f, - -0.207298962390014750f, - 0.978237872563701090f, -0.207486540966020650f, 0.978198069534491400f, - -0.207674111913339570f, - 0.978158230539735050f, -0.207861675225075070f, 0.978118355580896660f, - -0.208049230894330940f, - 0.978078444659442380f, -0.208236778914211330f, 0.978038497776839600f, - -0.208424319277820600f, - 0.977998514934557140f, -0.208611851978263490f, 0.977958496134064830f, - -0.208799377008644900f, - 0.977918441376834370f, -0.208986894362070070f, 0.977878350664338150f, - -0.209174404031644580f, - 0.977838223998050430f, -0.209361906010474160f, 0.977798061379446360f, - -0.209549400291664940f, - 0.977757862810002760f, -0.209736886868323290f, 0.977717628291197460f, - -0.209924365733555880f, - 0.977677357824509930f, -0.210111836880469610f, 0.977637051411420770f, - -0.210299300302171730f, - 0.977596709053411890f, -0.210486755991769720f, 0.977556330751966460f, - -0.210674203942371440f, - 0.977515916508569280f, -0.210861644147084860f, 0.977475466324706170f, - -0.211049076599018390f, - 0.977434980201864260f, -0.211236501291280710f, 0.977394458141532250f, - -0.211423918216980670f, - 0.977353900145199960f, -0.211611327369227550f, 0.977313306214358750f, - -0.211798728741130840f, - 0.977272676350500860f, -0.211986122325800330f, 0.977232010555120320f, - -0.212173508116346080f, - 0.977191308829712280f, -0.212360886105878420f, 0.977150571175773200f, - -0.212548256287508060f, - 0.977109797594800880f, -0.212735618654345930f, 0.977068988088294450f, - -0.212922973199503180f, - 0.977028142657754390f, -0.213110319916091360f, 0.976987261304682390f, - -0.213297658797222320f, - 0.976946344030581670f, -0.213484989836008050f, 0.976905390836956490f, - -0.213672313025560970f, - 0.976864401725312640f, -0.213859628358993750f, 0.976823376697157240f, - -0.214046935829419360f, - 0.976782315753998650f, -0.214234235429950990f, 0.976741218897346550f, - -0.214421527153702160f, - 0.976700086128711840f, -0.214608810993786760f, 0.976658917449606980f, - -0.214796086943318860f, - 0.976617712861545640f, -0.214983354995412820f, 0.976576472366042610f, - -0.215170615143183390f, - 0.976535195964614470f, -0.215357867379745550f, 0.976493883658778650f, - -0.215545111698214500f, - 0.976452535450054060f, -0.215732348091705880f, 0.976411151339961040f, - -0.215919576553335490f, - 0.976369731330021140f, -0.216106797076219520f, 0.976328275421757260f, - -0.216294009653474340f, - 0.976286783616693630f, -0.216481214278216730f, 0.976245255916355800f, - -0.216668410943563730f, - 0.976203692322270560f, -0.216855599642632620f, 0.976162092835966110f, - -0.217042780368540990f, - 0.976120457458971910f, -0.217229953114406790f, 0.976078786192818850f, - -0.217417117873348190f, - 0.976037079039039020f, -0.217604274638483640f, 0.975995335999165990f, - -0.217791423402931950f, - 0.975953557074734300f, -0.217978564159812200f, 0.975911742267280170f, - -0.218165696902243800f, - 0.975869891578341030f, -0.218352821623346320f, 0.975828005009455660f, - -0.218539938316239770f, - 0.975786082562163930f, -0.218727046974044440f, 0.975744124238007270f, - -0.218914147589880840f, - 0.975702130038528570f, -0.219101240156869800f, 0.975660099965271590f, - -0.219288324668132470f, - 0.975618034019781750f, -0.219475401116790310f, 0.975575932203605720f, - -0.219662469495965050f, - 0.975533794518291360f, -0.219849529798778700f, 0.975491620965388110f, - -0.220036582018353580f, - 0.975449411546446380f, -0.220223626147812380f, 0.975407166263018270f, - -0.220410662180277940f, - 0.975364885116656980f, -0.220597690108873510f, 0.975322568108916930f, - -0.220784709926722610f, - 0.975280215241354220f, -0.220971721626949110f, 0.975237826515525820f, - -0.221158725202677010f, - 0.975195401932990370f, -0.221345720647030810f, 0.975152941495307620f, - -0.221532707953135230f, - 0.975110445204038890f, -0.221719687114115220f, 0.975067913060746470f, - -0.221906658123096100f, - 0.975025345066994120f, -0.222093620973203510f, 0.974982741224347140f, - -0.222280575657563370f, - 0.974940101534371830f, -0.222467522169301880f, 0.974897425998635820f, - -0.222654460501545500f, - 0.974854714618708430f, -0.222841390647421120f, 0.974811967396159830f, - -0.223028312600055820f, - 0.974769184332561770f, -0.223215226352576980f, 0.974726365429487320f, - -0.223402131898112370f, - 0.974683510688510670f, -0.223589029229789990f, 0.974640620111207560f, - -0.223775918340738150f, - 0.974597693699155050f, -0.223962799224085460f, 0.974554731453931230f, - -0.224149671872960870f, - 0.974511733377115720f, -0.224336536280493600f, 0.974468699470289580f, - -0.224523392439813170f, - 0.974425629735034990f, -0.224710240344049430f, 0.974382524172935470f, - -0.224897079986332490f, - 0.974339382785575860f, -0.225083911359792830f, 0.974296205574542440f, - -0.225270734457561160f, - 0.974252992541422500f, -0.225457549272768540f, 0.974209743687805220f, - -0.225644355798546330f, - 0.974166459015280320f, -0.225831154028026170f, 0.974123138525439640f, - -0.226017943954340020f, - 0.974079782219875680f, -0.226204725570620190f, 0.974036390100182610f, - -0.226391498869999240f, - 0.973992962167955830f, -0.226578263845610000f, 0.973949498424792170f, - -0.226765020490585690f, - 0.973905998872289570f, -0.226951768798059810f, 0.973862463512047300f, - -0.227138508761166170f, - 0.973818892345666100f, -0.227325240373038860f, 0.973775285374748110f, - -0.227511963626812280f, - 0.973731642600896400f, -0.227698678515621170f, 0.973687964025715670f, - -0.227885385032600530f, - 0.973644249650811980f, -0.228072083170885730f, 0.973600499477792370f, - -0.228258772923612380f, - 0.973556713508265560f, -0.228445454283916470f, 0.973512891743841370f, - -0.228632127244934230f, - 0.973469034186131070f, -0.228818791799802220f, 0.973425140836747030f, - -0.229005447941657340f, - 0.973381211697303290f, -0.229192095663636770f, 0.973337246769414910f, - -0.229378734958878010f, - 0.973293246054698250f, -0.229565365820518870f, 0.973249209554771230f, - -0.229751988241697490f, - 0.973205137271252800f, -0.229938602215552210f, 0.973161029205763530f, - -0.230125207735221850f, - 0.973116885359925130f, -0.230311804793845440f, 0.973072705735360530f, - -0.230498393384562350f, - 0.973028490333694210f, -0.230684973500512200f, 0.972984239156551740f, - -0.230871545134835020f, - 0.972939952205560180f, -0.231058108280671110f, 0.972895629482347760f, - -0.231244662931161050f, - 0.972851270988544180f, -0.231431209079445750f, 0.972806876725780370f, - -0.231617746718666470f, - 0.972762446695688570f, -0.231804275841964780f, 0.972717980899902250f, - -0.231990796442482440f, - 0.972673479340056430f, -0.232177308513361710f, 0.972628942017787270f, - -0.232363812047745030f, - 0.972584368934732210f, -0.232550307038775240f, 0.972539760092530180f, - -0.232736793479595390f, - 0.972495115492821190f, -0.232923271363348980f, 0.972450435137246830f, - -0.233109740683179690f, - 0.972405719027449770f, -0.233296201432231590f, 0.972360967165074140f, - -0.233482653603649090f, - 0.972316179551765300f, -0.233669097190576820f, 0.972271356189170040f, - -0.233855532186159840f, - 0.972226497078936270f, -0.234041958583543430f, 0.972181602222713440f, - -0.234228376375873210f, - 0.972136671622152230f, -0.234414785556295160f, 0.972091705278904430f, - -0.234601186117955550f, - 0.972046703194623500f, -0.234787578054000970f, 0.972001665370963890f, - -0.234973961357578250f, - 0.971956591809581720f, -0.235160336021834730f, 0.971911482512134000f, - -0.235346702039917840f, - 0.971866337480279400f, -0.235533059404975490f, 0.971821156715677700f, - -0.235719408110155820f, - 0.971775940219990140f, -0.235905748148607370f, 0.971730687994879160f, - -0.236092079513478910f, - 0.971685400042008540f, -0.236278402197919570f, 0.971640076363043390f, - -0.236464716195078780f, - 0.971594716959650160f, -0.236651021498106380f, 0.971549321833496630f, - -0.236837318100152380f, - 0.971503890986251780f, -0.237023605994367200f, 0.971458424419585960f, - -0.237209885173901600f, - 0.971412922135170940f, -0.237396155631906610f, 0.971367384134679490f, - -0.237582417361533570f, - 0.971321810419786160f, -0.237768670355934190f, 0.971276200992166490f, - -0.237954914608260540f, - 0.971230555853497380f, -0.238141150111664840f, 0.971184875005457030f, - -0.238327376859299810f, - 0.971139158449725090f, -0.238513594844318420f, 0.971093406187982460f, - -0.238699804059873980f, - 0.971047618221911100f, -0.238886004499120040f, 0.971001794553194690f, - -0.239072196155210610f, - 0.970955935183517970f, -0.239258379021299980f, 0.970910040114567050f, - -0.239444553090542630f, - 0.970864109348029470f, -0.239630718356093560f, 0.970818142885593870f, - -0.239816874811108000f, - 0.970772140728950350f, -0.240003022448741500f, 0.970726102879790110f, - -0.240189161262149900f, - 0.970680029339806130f, -0.240375291244489450f, 0.970633920110692160f, - -0.240561412388916650f, - 0.970587775194143630f, -0.240747524688588430f, 0.970541594591857070f, - -0.240933628136661910f, - 0.970495378305530560f, -0.241119722726294590f, 0.970449126336863090f, - -0.241305808450644370f, - 0.970402838687555500f, -0.241491885302869330f, 0.970356515359309450f, - -0.241677953276128010f, - 0.970310156353828110f, -0.241864012363579180f, 0.970263761672816140f, - -0.242050062558382070f, - 0.970217331317979160f, -0.242236103853696010f, 0.970170865291024480f, - -0.242422136242680890f, - 0.970124363593660280f, -0.242608159718496810f, 0.970077826227596420f, - -0.242794174274304220f, - 0.970031253194543970f, -0.242980179903263870f, 0.969984644496215240f, - -0.243166176598536900f, - 0.969938000134323960f, -0.243352164353284740f, 0.969891320110585100f, - -0.243538143160669130f, - 0.969844604426714830f, -0.243724113013852160f, 0.969797853084430890f, - -0.243910073905996260f, - 0.969751066085452140f, -0.244096025830264210f, 0.969704243431498860f, - -0.244281968779819030f, - 0.969657385124292450f, -0.244467902747824150f, 0.969610491165555870f, - -0.244653827727443320f, - 0.969563561557013180f, -0.244839743711840670f, 0.969516596300390000f, - -0.245025650694180470f, - 0.969469595397413060f, -0.245211548667627540f, 0.969422558849810320f, - -0.245397437625346960f, - 0.969375486659311280f, -0.245583317560504060f, 0.969328378827646660f, - -0.245769188466264580f, - 0.969281235356548530f, -0.245955050335794590f, 0.969234056247750050f, - -0.246140903162260530f, - 0.969186841502985950f, -0.246326746938829030f, 0.969139591123992280f, - -0.246512581658667210f, - 0.969092305112506210f, -0.246698407314942410f, 0.969044983470266240f, - -0.246884223900822430f, - 0.968997626199012420f, -0.247070031409475250f, 0.968950233300485800f, - -0.247255829834069300f, - 0.968902804776428870f, -0.247441619167773270f, 0.968855340628585580f, - -0.247627399403756280f, - 0.968807840858700970f, -0.247813170535187670f, 0.968760305468521430f, - -0.247998932555237110f, - 0.968712734459794780f, -0.248184685457074780f, 0.968665127834270060f, - -0.248370429233870980f, - 0.968617485593697540f, -0.248556163878796560f, 0.968569807739828930f, - -0.248741889385022480f, - 0.968522094274417380f, -0.248927605745720150f, 0.968474345199216820f, - -0.249113312954061360f, - 0.968426560515983190f, -0.249299011003218190f, 0.968378740226473300f, - -0.249484699886362960f, - 0.968330884332445190f, -0.249670379596668550f, 0.968282992835658660f, - -0.249856050127307990f, - 0.968235065737874320f, -0.250041711471454650f, 0.968187103040854420f, - -0.250227363622282370f, - 0.968139104746362440f, -0.250413006572965220f, 0.968091070856162970f, - -0.250598640316677670f, - 0.968043001372022260f, -0.250784264846594500f, 0.967994896295707670f, - -0.250969880155890720f, - 0.967946755628987800f, -0.251155486237741920f, 0.967898579373632660f, - -0.251341083085323880f, - 0.967850367531413620f, -0.251526670691812610f, 0.967802120104103270f, - -0.251712249050384700f, - 0.967753837093475510f, -0.251897818154216970f, 0.967705518501305480f, - -0.252083377996486450f, - 0.967657164329369880f, -0.252268928570370810f, 0.967608774579446500f, - -0.252454469869047740f, - 0.967560349253314360f, -0.252640001885695520f, 0.967511888352754150f, - -0.252825524613492610f, - 0.967463391879547550f, -0.253011038045617860f, 0.967414859835477480f, - -0.253196542175250560f, - 0.967366292222328510f, -0.253382036995570160f, 0.967317689041886310f, - -0.253567522499756560f, - 0.967269050295937790f, -0.253752998680989990f, 0.967220375986271420f, - -0.253938465532451090f, - 0.967171666114676640f, -0.254123923047320620f, 0.967122920682944360f, - -0.254309371218780000f, - 0.967074139692867040f, -0.254494810040010730f, 0.967025323146238010f, - -0.254680239504194830f, - 0.966976471044852070f, -0.254865659604514570f, 0.966927583390505660f, - -0.255051070334152470f, - 0.966878660184995910f, -0.255236471686291710f, 0.966829701430121810f, - -0.255421863654115460f, - 0.966780707127683270f, -0.255607246230807380f, 0.966731677279481840f, - -0.255792619409551610f, - 0.966682611887320080f, -0.255977983183532430f, 0.966633510953002100f, - -0.256163337545934460f, - 0.966584374478333120f, -0.256348682489942910f, 0.966535202465119700f, - -0.256534018008743040f, - 0.966485994915169840f, -0.256719344095520660f, 0.966436751830292650f, - -0.256904660743461910f, - 0.966387473212298900f, -0.257089967945753120f, 0.966338159063000130f, - -0.257275265695581120f, - 0.966288809384209690f, -0.257460553986133100f, 0.966239424177741890f, - -0.257645832810596390f, - 0.966190003445412500f, -0.257831102162158990f, 0.966140547189038750f, - -0.258016362034009020f, - 0.966091055410438830f, -0.258201612419334870f, 0.966041528111432400f, - -0.258386853311325600f, - 0.965991965293840570f, -0.258572084703170340f, 0.965942366959485540f, - -0.258757306588058680f, - 0.965892733110190860f, -0.258942518959180520f, 0.965843063747781510f, - -0.259127721809726150f, - 0.965793358874083680f, -0.259312915132886230f, 0.965743618490924830f, - -0.259498098921851660f, - 0.965693842600133690f, -0.259683273169813770f, 0.965644031203540590f, - -0.259868437869964270f, - 0.965594184302976830f, -0.260053593015495190f, 0.965544301900275180f, - -0.260238738599598840f, - 0.965494383997269500f, -0.260423874615468010f, 0.965444430595795430f, - -0.260609001056295750f, - 0.965394441697689400f, -0.260794117915275510f, 0.965344417304789370f, - -0.260979225185601070f, - 0.965294357418934660f, -0.261164322860466480f, 0.965244262041965780f, - -0.261349410933066350f, - 0.965194131175724720f, -0.261534489396595520f, 0.965143964822054450f, - -0.261719558244249030f, - 0.965093762982799590f, -0.261904617469222610f, 0.965043525659805890f, - -0.262089667064712040f, - 0.964993252854920320f, -0.262274707023913590f, 0.964942944569991410f, - -0.262459737340023980f, - 0.964892600806868890f, -0.262644758006240040f, 0.964842221567403620f, - -0.262829769015759160f, - 0.964791806853447900f, -0.263014770361779000f, 0.964741356666855340f, - -0.263199762037497560f, - 0.964690871009481030f, -0.263384744036113280f, 0.964640349883180930f, - -0.263569716350824880f, - 0.964589793289812760f, -0.263754678974831350f, 0.964539201231235150f, - -0.263939631901332350f, - 0.964488573709308410f, -0.264124575123527550f, 0.964437910725893910f, - -0.264309508634617110f, - 0.964387212282854290f, -0.264494432427801630f, 0.964336478382053720f, - -0.264679346496281890f, - 0.964285709025357480f, -0.264864250833259260f, 0.964234904214632200f, - -0.265049145431935250f, - 0.964184063951745830f, -0.265234030285511790f, 0.964133188238567640f, - -0.265418905387191260f, - 0.964082277076968140f, -0.265603770730176330f, 0.964031330468819280f, - -0.265788626307669920f, - 0.963980348415994110f, -0.265973472112875590f, 0.963929330920367140f, - -0.266158308138996990f, - 0.963878277983814200f, -0.266343134379238180f, 0.963827189608212340f, - -0.266527950826803690f, - 0.963776065795439840f, -0.266712757474898370f, 0.963724906547376530f, - -0.266897554316727350f, - 0.963673711865903230f, -0.267082341345496300f, 0.963622481752902220f, - -0.267267118554410930f, - 0.963571216210257320f, -0.267451885936677620f, 0.963519915239853140f, - -0.267636643485503090f, - 0.963468578843575950f, -0.267821391194094150f, 0.963417207023313350f, - -0.268006129055658290f, - 0.963365799780954050f, -0.268190857063403180f, 0.963314357118388200f, - -0.268375575210536900f, - 0.963262879037507070f, -0.268560283490267890f, 0.963211365540203480f, - -0.268744981895804980f, - 0.963159816628371360f, -0.268929670420357260f, 0.963108232303906190f, - -0.269114349057134380f, - 0.963056612568704340f, -0.269299017799346120f, 0.963004957424663850f, - -0.269483676640202840f, - 0.962953266873683880f, -0.269668325572915090f, 0.962901540917665000f, - -0.269852964590693860f, - 0.962849779558509030f, -0.270037593686750570f, 0.962797982798119010f, - -0.270222212854296870f, - 0.962746150638399410f, -0.270406822086544820f, 0.962694283081255930f, - -0.270591421376706940f, - 0.962642380128595710f, -0.270776010717996010f, 0.962590441782326890f, - -0.270960590103625170f, - 0.962538468044359160f, -0.271145159526808010f, 0.962486458916603450f, - -0.271329718980758420f, - 0.962434414400972100f, -0.271514268458690700f, 0.962382334499378380f, - -0.271698807953819510f, - 0.962330219213737400f, -0.271883337459359720f, 0.962278068545965090f, - -0.272067856968526920f, - 0.962225882497979020f, -0.272252366474536710f, 0.962173661071697880f, - -0.272436865970605240f, - 0.962121404269041580f, -0.272621355449948980f, 0.962069112091931580f, - -0.272805834905784810f, - 0.962016784542290560f, -0.272990304331329920f, 0.961964421622042320f, - -0.273174763719801930f, - 0.961912023333112210f, -0.273359213064418680f, 0.961859589677426570f, - -0.273543652358398730f, - 0.961807120656913540f, -0.273728081594960540f, 0.961754616273502010f, - -0.273912500767323260f, - 0.961702076529122540f, -0.274096909868706380f, 0.961649501425706820f, - -0.274281308892329660f, - 0.961596890965187860f, -0.274465697831413220f, 0.961544245149499990f, - -0.274650076679177680f, - 0.961491563980579000f, -0.274834445428843940f, 0.961438847460361680f, - -0.275018804073633220f, - 0.961386095590786250f, -0.275203152606767310f, 0.961333308373792270f, - -0.275387491021468140f, - 0.961280485811320640f, -0.275571819310958140f, 0.961227627905313460f, - -0.275756137468460120f, - 0.961174734657714080f, -0.275940445487197150f, 0.961121806070467380f, - -0.276124743360392830f, - 0.961068842145519350f, -0.276309031081271080f, 0.961015842884817230f, - -0.276493308643055990f, - 0.960962808290309780f, -0.276677576038972420f, 0.960909738363946770f, - -0.276861833262245280f, - 0.960856633107679660f, -0.277046080306099900f, 0.960803492523460760f, - -0.277230317163762170f, - 0.960750316613243950f, -0.277414543828458090f, 0.960697105378984450f, - -0.277598760293414290f, - 0.960643858822638590f, -0.277782966551857690f, 0.960590576946164120f, - -0.277967162597015370f, - 0.960537259751520050f, -0.278151348422115090f, 0.960483907240666790f, - -0.278335524020384920f, - 0.960430519415565790f, -0.278519689385053060f, 0.960377096278180130f, - -0.278703844509348490f, - 0.960323637830473920f, -0.278887989386500280f, 0.960270144074412800f, - -0.279072124009737800f, - 0.960216615011963430f, -0.279256248372291180f, 0.960163050645094000f, - -0.279440362467390510f, - 0.960109450975773940f, -0.279624466288266590f, 0.960055816005973890f, - -0.279808559828150390f, - 0.960002145737665960f, -0.279992643080273220f, 0.959948440172823210f, - -0.280176716037866980f, - 0.959894699313420530f, -0.280360778694163810f, 0.959840923161433770f, - -0.280544831042396250f, - 0.959787111718839900f, -0.280728873075797190f, 0.959733264987617680f, - -0.280912904787600000f, - 0.959679382969746750f, -0.281096926171038260f, 0.959625465667208190f, - -0.281280937219346110f, - 0.959571513081984520f, -0.281464937925757940f, 0.959517525216059260f, - -0.281648928283508630f, - 0.959463502071417510f, -0.281832908285833350f, 0.959409443650045550f, - -0.282016877925967640f, - 0.959355349953930790f, -0.282200837197147560f, 0.959301220985062210f, - -0.282384786092609360f, - 0.959247056745430090f, -0.282568724605589740f, 0.959192857237025740f, - -0.282752652729325930f, - 0.959138622461841890f, -0.282936570457055390f, 0.959084352421872730f, - -0.283120477782015820f, - 0.959030047119113660f, -0.283304374697445740f, 0.958975706555561080f, - -0.283488261196583550f, - 0.958921330733213170f, -0.283672137272668430f, 0.958866919654069010f, - -0.283856002918939750f, - 0.958812473320129310f, -0.284039858128637190f, 0.958757991733395710f, - -0.284223702895001040f, - 0.958703474895871600f, -0.284407537211271880f, 0.958648922809561150f, - -0.284591361070690440f, - 0.958594335476470220f, -0.284775174466498300f, 0.958539712898605730f, - -0.284958977391937040f, - 0.958485055077976100f, -0.285142769840248670f, 0.958430362016590930f, - -0.285326551804675870f, - 0.958375633716461170f, -0.285510323278461260f, 0.958320870179598880f, - -0.285694084254848320f, - 0.958266071408017670f, -0.285877834727080620f, 0.958211237403732260f, - -0.286061574688402040f, - 0.958156368168758820f, -0.286245304132057120f, 0.958101463705114730f, - -0.286429023051290700f, - 0.958046524014818600f, -0.286612731439347790f, 0.957991549099890370f, - -0.286796429289474080f, - 0.957936538962351420f, -0.286980116594915570f, 0.957881493604224370f, - -0.287163793348918390f, - 0.957826413027532910f, -0.287347459544729510f, 0.957771297234302320f, - -0.287531115175595930f, - 0.957716146226558870f, -0.287714760234765170f, 0.957660960006330610f, - -0.287898394715485170f, - 0.957605738575646350f, -0.288082018611004130f, 0.957550481936536470f, - -0.288265631914570770f, - 0.957495190091032570f, -0.288449234619434220f, 0.957439863041167680f, - -0.288632826718843830f, - 0.957384500788975860f, -0.288816408206049480f, 0.957329103336492790f, - -0.288999979074301420f, - 0.957273670685755200f, -0.289183539316850200f, 0.957218202838801210f, - -0.289367088926947010f, - 0.957162699797670210f, -0.289550627897843030f, 0.957107161564402790f, - -0.289734156222790250f, - 0.957051588141040970f, -0.289917673895040750f, 0.956995979529628230f, - -0.290101180907847090f, - 0.956940335732208820f, -0.290284677254462330f, 0.956884656750828900f, - -0.290468162928139820f, - 0.956828942587535370f, -0.290651637922133220f, 0.956773193244376930f, - -0.290835102229696830f, - 0.956717408723403050f, -0.291018555844085090f, 0.956661589026665090f, - -0.291201998758552900f, - 0.956605734156215080f, -0.291385430966355660f, 0.956549844114106820f, - -0.291568852460749040f, - 0.956493918902395100f, -0.291752263234989260f, 0.956437958523136180f, - -0.291935663282332780f, - 0.956381962978387730f, -0.292119052596036380f, 0.956325932270208230f, - -0.292302431169357560f, - 0.956269866400658030f, -0.292485798995553880f, 0.956213765371798470f, - -0.292669156067883460f, - 0.956157629185692140f, -0.292852502379604810f, 0.956101457844403040f, - -0.293035837923976810f, - 0.956045251349996410f, -0.293219162694258630f, 0.955989009704538930f, - -0.293402476683710110f, - 0.955932732910098280f, -0.293585779885591200f, 0.955876420968743590f, - -0.293769072293162400f, - 0.955820073882545420f, -0.293952353899684660f, 0.955763691653575440f, - -0.294135624698419030f, - 0.955707274283906560f, -0.294318884682627400f, 0.955650821775613330f, - -0.294502133845571670f, - 0.955594334130771110f, -0.294685372180514330f, 0.955537811351456880f, - -0.294868599680718270f, - 0.955481253439748770f, -0.295051816339446720f, 0.955424660397726330f, - -0.295235022149963220f, - 0.955368032227470350f, -0.295418217105532010f, 0.955311368931062720f, - -0.295601401199417360f, - 0.955254670510586990f, -0.295784574424884260f, 0.955197936968127710f, - -0.295967736775197890f, - 0.955141168305770780f, -0.296150888243623790f, 0.955084364525603410f, - -0.296334028823428190f, - 0.955027525629714160f, -0.296517158507877470f, 0.954970651620192790f, - -0.296700277290238350f, - 0.954913742499130520f, -0.296883385163778270f, 0.954856798268619580f, - -0.297066482121764730f, - 0.954799818930753720f, -0.297249568157465840f, 0.954742804487627940f, - -0.297432643264150030f, - 0.954685754941338340f, -0.297615707435086200f, 0.954628670293982680f, - -0.297798760663543550f, - 0.954571550547659630f, -0.297981802942791810f, 0.954514395704469500f, - -0.298164834266100850f, - 0.954457205766513490f, -0.298347854626741400f, 0.954399980735894490f, - -0.298530864017984120f, - 0.954342720614716480f, -0.298713862433100330f, 0.954285425405084650f, - -0.298896849865361800f, - 0.954228095109105670f, -0.299079826308040480f, 0.954170729728887280f, - -0.299262791754408840f, - 0.954113329266538800f, -0.299445746197739890f, 0.954055893724170660f, - -0.299628689631306790f, - 0.953998423103894490f, -0.299811622048383350f, 0.953940917407823500f, - -0.299994543442243580f, - 0.953883376638071770f, -0.300177453806161950f, 0.953825800796755050f, - -0.300360353133413530f, - 0.953768189885990330f, -0.300543241417273450f, 0.953710543907895670f, - -0.300726118651017500f, - 0.953652862864590500f, -0.300908984827921890f, 0.953595146758195680f, - -0.301091839941263100f, - 0.953537395590833280f, -0.301274683984317950f, 0.953479609364626610f, - -0.301457516950363940f, - 0.953421788081700310f, -0.301640338832678770f, 0.953363931744180330f, - -0.301823149624540650f, - 0.953306040354193860f, -0.302005949319228080f, 0.953248113913869320f, - -0.302188737910019990f, - 0.953190152425336670f, -0.302371515390195970f, 0.953132155890726750f, - -0.302554281753035610f, - 0.953074124312172200f, -0.302737036991819140f, 0.953016057691806530f, - -0.302919781099827310f, - 0.952957956031764700f, -0.303102514070341060f, 0.952899819334182880f, - -0.303285235896641750f, - 0.952841647601198720f, -0.303467946572011320f, 0.952783440834950920f, - -0.303650646089731910f, - 0.952725199037579570f, -0.303833334443086360f, 0.952666922211226170f, - -0.304016011625357570f, - 0.952608610358033350f, -0.304198677629829110f, 0.952550263480144930f, - -0.304381332449784880f, - 0.952491881579706320f, -0.304563976078509100f, 0.952433464658864030f, - -0.304746608509286530f, - 0.952375012719765880f, -0.304929229735402370f, 0.952316525764560940f, - -0.305111839750142110f, - 0.952258003795399600f, -0.305294438546791670f, 0.952199446814433580f, - -0.305477026118637420f, - 0.952140854823815830f, -0.305659602458966120f, 0.952082227825700620f, - -0.305842167561065080f, - 0.952023565822243570f, -0.306024721418221790f, 0.951964868815601380f, - -0.306207264023724220f, - 0.951906136807932350f, -0.306389795370860920f, 0.951847369801395620f, - -0.306572315452920740f, - 0.951788567798152130f, -0.306754824263192780f, 0.951729730800363830f, - -0.306937321794966910f, - 0.951670858810193860f, -0.307119808041533100f, 0.951611951829806850f, - -0.307302282996181790f, - 0.951553009861368590f, -0.307484746652204100f, 0.951494032907046370f, - -0.307667199002891190f, - 0.951435020969008340f, -0.307849640041534870f, 0.951375974049424420f, - -0.308032069761427330f, - 0.951316892150465550f, -0.308214488155861050f, 0.951257775274304000f, - -0.308396895218129190f, - 0.951198623423113230f, -0.308579290941525090f, 0.951139436599068190f, - -0.308761675319342450f, - 0.951080214804345010f, -0.308944048344875710f, 0.951020958041121080f, - -0.309126410011419440f, - 0.950961666311575080f, -0.309308760312268730f, 0.950902339617887060f, - -0.309491099240719100f, - 0.950842977962238160f, -0.309673426790066380f, 0.950783581346811070f, - -0.309855742953607070f, - 0.950724149773789610f, -0.310038047724637890f, 0.950664683245358910f, - -0.310220341096455850f, - 0.950605181763705340f, -0.310402623062358720f, 0.950545645331016600f, - -0.310584893615644450f, - 0.950486073949481700f, -0.310767152749611470f, 0.950426467621290900f, - -0.310949400457558640f, - 0.950366826348635780f, -0.311131636732785270f, 0.950307150133709260f, - -0.311313861568590920f, - 0.950247438978705230f, -0.311496074958275910f, 0.950187692885819280f, - -0.311678276895140550f, - 0.950127911857248100f, -0.311860467372486020f, 0.950068095895189590f, - -0.312042646383613510f, - 0.950008245001843000f, -0.312224813921824880f, 0.949948359179409010f, - -0.312406969980422440f, - 0.949888438430089300f, -0.312589114552708710f, 0.949828482756087110f, - -0.312771247631986770f, - 0.949768492159606680f, -0.312953369211560200f, 0.949708466642853800f, - -0.313135479284732840f, - 0.949648406208035480f, -0.313317577844809010f, 0.949588310857359950f, - -0.313499664885093510f, - 0.949528180593036670f, -0.313681740398891520f, 0.949468015417276550f, - -0.313863804379508500f, - 0.949407815332291570f, -0.314045856820250710f, 0.949347580340295210f, - -0.314227897714424440f, - 0.949287310443502120f, -0.314409927055336660f, 0.949227005644128210f, - -0.314591944836294660f, - 0.949166665944390700f, -0.314773951050606070f, 0.949106291346508260f, - -0.314955945691579140f, - 0.949045881852700560f, -0.315137928752522440f, 0.948985437465188710f, - -0.315319900226744890f, - 0.948924958186195160f, -0.315501860107555990f, 0.948864444017943340f, - -0.315683808388265650f, - 0.948803894962658490f, -0.315865745062183960f, 0.948743311022566480f, - -0.316047670122621860f, - 0.948682692199895090f, -0.316229583562890330f, 0.948622038496872990f, - -0.316411485376300980f, - 0.948561349915730270f, -0.316593375556165850f, 0.948500626458698260f, - -0.316775254095797270f, - 0.948439868128009620f, -0.316957120988508150f, 0.948379074925898120f, - -0.317138976227611780f, - 0.948318246854599090f, -0.317320819806421740f, 0.948257383916349060f, - -0.317502651718252260f, - 0.948196486113385580f, -0.317684471956417970f, 0.948135553447947980f, - -0.317866280514233660f, - 0.948074585922276230f, -0.318048077385014950f, 0.948013583538612200f, - -0.318229862562077530f, - 0.947952546299198670f, -0.318411636038737790f, 0.947891474206279840f, - -0.318593397808312420f, - 0.947830367262101010f, -0.318775147864118480f, 0.947769225468909180f, - -0.318956886199473650f, - 0.947708048828952100f, -0.319138612807695900f, 0.947646837344479300f, - -0.319320327682103610f, - 0.947585591017741090f, -0.319502030816015690f, 0.947524309850989570f, - -0.319683722202751430f, - 0.947462993846477700f, -0.319865401835630500f, 0.947401643006459900f, - -0.320047069707973140f, - 0.947340257333192050f, -0.320228725813099860f, 0.947278836828930880f, - -0.320410370144331820f, - 0.947217381495934820f, -0.320592002694990330f, 0.947155891336463270f, - -0.320773623458397330f, - 0.947094366352777220f, -0.320955232427875210f, 0.947032806547138620f, - -0.321136829596746660f, - 0.946971211921810880f, -0.321318414958334850f, 0.946909582479058760f, - -0.321499988505963510f, - 0.946847918221148000f, -0.321681550232956580f, 0.946786219150346000f, - -0.321863100132638580f, - 0.946724485268921170f, -0.322044638198334510f, 0.946662716579143360f, - -0.322226164423369600f, - 0.946600913083283530f, -0.322407678801069850f, 0.946539074783614100f, - -0.322589181324761330f, - 0.946477201682408680f, -0.322770671987770710f, 0.946415293781942110f, - -0.322952150783425260f, - 0.946353351084490590f, -0.323133617705052330f, 0.946291373592331620f, - -0.323315072745979980f, - 0.946229361307743820f, -0.323496515899536710f, 0.946167314233007370f, - -0.323677947159051240f, - 0.946105232370403450f, -0.323859366517852850f, 0.946043115722214560f, - -0.324040773969271450f, - 0.945980964290724760f, -0.324222169506636960f, 0.945918778078219110f, - -0.324403553123280230f, - 0.945856557086983910f, -0.324584924812532150f, 0.945794301319306970f, - -0.324766284567724220f, - 0.945732010777477150f, -0.324947632382188430f, 0.945669685463784710f, - -0.325128968249257080f, - 0.945607325380521280f, -0.325310292162262930f, 0.945544930529979680f, - -0.325491604114539310f, - 0.945482500914453740f, -0.325672904099419850f, 0.945420036536239070f, - -0.325854192110238580f, - 0.945357537397632290f, -0.326035468140330240f, 0.945295003500931210f, - -0.326216732183029710f, - 0.945232434848435000f, -0.326397984231672490f, 0.945169831442444150f, - -0.326579224279594400f, - 0.945107193285260610f, -0.326760452320131730f, 0.945044520379187070f, - -0.326941668346621420f, - 0.944981812726528150f, -0.327122872352400510f, 0.944919070329589220f, - -0.327304064330806670f, - 0.944856293190677210f, -0.327485244275178000f, 0.944793481312100280f, - -0.327666412178853120f, - 0.944730634696167800f, -0.327847568035170840f, 0.944667753345190490f, - -0.328028711837470680f, - 0.944604837261480260f, -0.328209843579092500f, 0.944541886447350490f, - -0.328390963253376580f, - 0.944478900905115550f, -0.328572070853663740f, 0.944415880637091250f, - -0.328753166373294990f, - 0.944352825645594750f, -0.328934249805612200f, 0.944289735932944410f, - -0.329115321143957250f, - 0.944226611501459810f, -0.329296380381672750f, 0.944163452353461770f, - -0.329477427512101740f, - 0.944100258491272660f, -0.329658462528587490f, 0.944037029917215830f, - -0.329839485424473940f, - 0.943973766633615980f, -0.330020496193105420f, 0.943910468642799150f, - -0.330201494827826570f, - 0.943847135947092690f, -0.330382481321982780f, 0.943783768548825060f, - -0.330563455668919540f, - 0.943720366450326200f, -0.330744417861982890f, 0.943656929653927220f, - -0.330925367894519540f, - 0.943593458161960390f, -0.331106305759876430f, 0.943529951976759480f, - -0.331287231451400820f, - 0.943466411100659320f, -0.331468144962440870f, 0.943402835535996240f, - -0.331649046286344670f, - 0.943339225285107720f, -0.331829935416461110f, 0.943275580350332540f, - -0.332010812346139380f, - 0.943211900734010620f, -0.332191677068729150f, 0.943148186438483420f, - -0.332372529577580620f, - 0.943084437466093490f, -0.332553369866044220f, 0.943020653819184650f, - -0.332734197927471050f, - 0.942956835500102120f, -0.332915013755212650f, 0.942892982511192250f, - -0.333095817342620780f, - 0.942829094854802710f, -0.333276608683047930f, 0.942765172533282510f, - -0.333457387769846850f, - 0.942701215548981900f, -0.333638154596370860f, 0.942637223904252530f, - -0.333818909155973620f, - 0.942573197601446870f, -0.333999651442009380f, 0.942509136642919240f, - -0.334180381447832690f, - 0.942445041031024890f, -0.334361099166798740f, 0.942380910768120470f, - -0.334541804592262900f, - 0.942316745856563780f, -0.334722497717581220f, 0.942252546298714020f, - -0.334903178536110180f, - 0.942188312096931770f, -0.335083847041206580f, 0.942124043253578570f, - -0.335264503226227810f, - 0.942059739771017310f, -0.335445147084531600f, 0.941995401651612550f, - -0.335625778609476290f, - 0.941931028897729620f, -0.335806397794420450f, 0.941866621511735280f, - -0.335987004632723350f, - 0.941802179495997650f, -0.336167599117744520f, 0.941737702852886160f, - -0.336348181242844050f, - 0.941673191584771360f, -0.336528751001382410f, 0.941608645694025250f, - -0.336709308386720580f, - 0.941544065183020810f, -0.336889853392220050f, 0.941479450054132580f, - -0.337070386011242620f, - 0.941414800309736340f, -0.337250906237150590f, 0.941350115952208970f, - -0.337431414063306840f, - 0.941285396983928660f, -0.337611909483074620f, 0.941220643407275180f, - -0.337792392489817460f, - 0.941155855224629190f, -0.337972863076899720f, 0.941091032438372780f, - -0.338153321237685930f, - 0.941026175050889260f, -0.338333766965541130f, 0.940961283064563280f, - -0.338514200253830940f, - 0.940896356481780830f, -0.338694621095921190f, 0.940831395304928870f, - -0.338875029485178450f, - 0.940766399536396070f, -0.339055425414969640f, 0.940701369178571940f, - -0.339235808878661950f, - 0.940636304233847590f, -0.339416179869623360f, 0.940571204704615190f, - -0.339596538381222110f, - 0.940506070593268300f, -0.339776884406826850f, 0.940440901902201750f, - -0.339957217939806880f, - 0.940375698633811540f, -0.340137538973531720f, 0.940310460790495070f, - -0.340317847501371670f, - 0.940245188374650880f, -0.340498143516697160f, 0.940179881388678920f, - -0.340678427012879200f, - 0.940114539834980280f, -0.340858697983289440f, 0.940049163715957370f, - -0.341038956421299720f, - 0.939983753034014050f, -0.341219202320282360f, 0.939918307791555050f, - -0.341399435673610420f, - 0.939852827990986680f, -0.341579656474657160f, 0.939787313634716570f, - -0.341759864716796310f, - 0.939721764725153340f, -0.341940060393402190f, 0.939656181264707180f, - -0.342120243497849530f, - 0.939590563255789270f, -0.342300414023513520f, 0.939524910700812230f, - -0.342480571963769800f, - 0.939459223602189920f, -0.342660717311994380f, 0.939393501962337510f, - -0.342840850061563950f, - 0.939327745783671400f, -0.343020970205855540f, 0.939261955068609210f, - -0.343201077738246540f, - 0.939196129819569900f, -0.343381172652115040f, 0.939130270038973650f, - -0.343561254940839390f, - 0.939064375729241950f, -0.343741324597798490f, 0.938998446892797540f, - -0.343921381616371700f, - 0.938932483532064600f, -0.344101425989938810f, 0.938866485649468060f, - -0.344281457711880180f, - 0.938800453247434770f, -0.344461476775576540f, 0.938734386328392460f, - -0.344641483174408960f, - 0.938668284894770170f, -0.344821476901759290f, 0.938602148948998400f, - -0.345001457951009670f, - 0.938535978493508560f, -0.345181426315542550f, 0.938469773530733800f, - -0.345361381988741220f, - 0.938403534063108060f, -0.345541324963989090f, 0.938337260093066950f, - -0.345721255234670120f, - 0.938270951623047190f, -0.345901172794168990f, 0.938204608655486490f, - -0.346081077635870430f, - 0.938138231192824360f, -0.346260969753160010f, 0.938071819237501270f, - -0.346440849139423520f, - 0.938005372791958840f, -0.346620715788047320f, 0.937938891858640320f, - -0.346800569692418290f, - 0.937872376439989890f, -0.346980410845923680f, 0.937805826538453120f, - -0.347160239241951160f, - 0.937739242156476970f, -0.347340054873889140f, 0.937672623296509470f, - -0.347519857735126110f, - 0.937605969960999990f, -0.347699647819051380f, 0.937539282152399230f, - -0.347879425119054510f, - 0.937472559873159250f, -0.348059189628525610f, 0.937405803125732960f, - -0.348238941340855260f, - 0.937339011912574960f, -0.348418680249434560f, 0.937272186236140950f, - -0.348598406347654930f, - 0.937205326098887960f, -0.348778119628908420f, 0.937138431503274140f, - -0.348957820086587490f, - 0.937071502451759190f, -0.349137507714084970f, 0.937004538946803690f, - -0.349317182504794380f, - 0.936937540990869900f, -0.349496844452109550f, 0.936870508586420960f, - -0.349676493549424760f, - 0.936803441735921560f, -0.349856129790134920f, 0.936736340441837620f, - -0.350035753167635240f, - 0.936669204706636170f, -0.350215363675321580f, 0.936602034532785570f, - -0.350394961306590150f, - 0.936534829922755500f, -0.350574546054837510f, 0.936467590879016990f, - -0.350754117913461060f, - 0.936400317404042060f, -0.350933676875858360f, 0.936333009500304180f, - -0.351113222935427460f, - 0.936265667170278260f, -0.351292756085567090f, 0.936198290416440090f, - -0.351472276319676310f, - 0.936130879241267030f, -0.351651783631154570f, 0.936063433647237540f, - -0.351831278013402030f, - 0.935995953636831410f, -0.352010759459819080f, 0.935928439212529660f, - -0.352190227963806830f, - 0.935860890376814640f, -0.352369683518766630f, 0.935793307132169900f, - -0.352549126118100460f, - 0.935725689481080370f, -0.352728555755210730f, 0.935658037426032040f, - -0.352907972423500250f, - 0.935590350969512370f, -0.353087376116372480f, 0.935522630114009930f, - -0.353266766827231240f, - 0.935454874862014620f, -0.353446144549480810f, 0.935387085216017770f, - -0.353625509276525970f, - 0.935319261178511610f, -0.353804861001772050f, 0.935251402751989920f, - -0.353984199718624770f, - 0.935183509938947610f, -0.354163525420490340f, 0.935115582741880890f, - -0.354342838100775550f, - 0.935047621163287430f, -0.354522137752887430f, 0.934979625205665800f, - -0.354701424370233830f, - 0.934911594871516090f, -0.354880697946222790f, 0.934843530163339540f, - -0.355059958474262860f, - 0.934775431083638700f, -0.355239205947763310f, 0.934707297634917440f, - -0.355418440360133650f, - 0.934639129819680780f, -0.355597661704783850f, 0.934570927640435030f, - -0.355776869975124640f, - 0.934502691099687870f, -0.355956065164566850f, 0.934434420199948050f, - -0.356135247266522130f, - 0.934366114943725790f, -0.356314416274402410f, 0.934297775333532530f, - -0.356493572181620090f, - 0.934229401371880820f, -0.356672714981588260f, 0.934160993061284530f, - -0.356851844667720300f, - 0.934092550404258980f, -0.357030961233429980f, 0.934024073403320390f, - -0.357210064672131960f, - 0.933955562060986730f, -0.357389154977240940f, 0.933887016379776890f, - -0.357568232142172260f, - 0.933818436362210960f, -0.357747296160341900f, 0.933749822010810580f, - -0.357926347025166010f, - 0.933681173328098410f, -0.358105384730061590f, 0.933612490316598540f, - -0.358284409268445850f, - 0.933543772978836170f, -0.358463420633736540f, 0.933475021317337950f, - -0.358642418819351990f, - 0.933406235334631520f, -0.358821403818710860f, 0.933337415033246190f, - -0.359000375625232460f, - 0.933268560415712050f, -0.359179334232336500f, 0.933199671484560730f, - -0.359358279633443130f, - 0.933130748242325230f, -0.359537211821973070f, 0.933061790691539380f, - -0.359716130791347570f, - 0.932992798834738960f, -0.359895036534988110f, 0.932923772674460140f, - -0.360073929046317020f, - 0.932854712213241120f, -0.360252808318756890f, 0.932785617453621100f, - -0.360431674345730700f, - 0.932716488398140250f, -0.360610527120662270f, 0.932647325049340450f, - -0.360789366636975580f, - 0.932578127409764420f, -0.360968192888095230f, 0.932508895481956590f, - -0.361147005867446250f, - 0.932439629268462360f, -0.361325805568454280f, 0.932370328771828460f, - -0.361504591984545260f, - 0.932300993994602760f, -0.361683365109145840f, 0.932231624939334540f, - -0.361862124935682980f, - 0.932162221608574430f, -0.362040871457584180f, 0.932092784004874050f, - -0.362219604668277460f, - 0.932023312130786490f, -0.362398324561191310f, 0.931953805988866010f, - -0.362577031129754760f, - 0.931884265581668150f, -0.362755724367397230f, 0.931814690911749730f, - -0.362934404267548640f, - 0.931745081981668720f, -0.363113070823639470f, 0.931675438793984620f, - -0.363291724029100760f, - 0.931605761351257830f, -0.363470363877363760f, 0.931536049656050300f, - -0.363648990361860550f, - 0.931466303710925090f, -0.363827603476023500f, 0.931396523518446600f, - -0.364006203213285470f, - 0.931326709081180430f, -0.364184789567079890f, 0.931256860401693420f, - -0.364363362530840620f, - 0.931186977482553750f, -0.364541922098002120f, 0.931117060326330790f, - -0.364720468261999280f, - 0.931047108935595280f, -0.364899001016267320f, 0.930977123312918930f, - -0.365077520354242180f, - 0.930907103460875130f, -0.365256026269360320f, 0.930837049382038150f, - -0.365434518755058390f, - 0.930766961078983710f, -0.365612997804773850f, 0.930696838554288860f, - -0.365791463411944570f, - 0.930626681810531760f, -0.365969915570008740f, 0.930556490850291800f, - -0.366148354272405330f, - 0.930486265676149780f, -0.366326779512573590f, 0.930416006290687550f, - -0.366505191283953370f, - 0.930345712696488470f, -0.366683589579984930f, 0.930275384896137150f, - -0.366861974394109060f, - 0.930205022892219070f, -0.367040345719767180f, 0.930134626687321390f, - -0.367218703550400980f, - 0.930064196284032360f, -0.367397047879452710f, 0.929993731684941480f, - -0.367575378700365330f, - 0.929923232892639670f, -0.367753696006581980f, 0.929852699909718750f, - -0.367931999791546450f, - 0.929782132738772190f, -0.368110290048703050f, 0.929711531382394370f, - -0.368288566771496570f, - 0.929640895843181330f, -0.368466829953372320f, 0.929570226123729860f, - -0.368645079587776040f, - 0.929499522226638560f, -0.368823315668153910f, 0.929428784154506800f, - -0.369001538187952780f, - 0.929358011909935500f, -0.369179747140620020f, 0.929287205495526790f, - -0.369357942519603130f, - 0.929216364913884040f, -0.369536124318350650f, 0.929145490167611720f, - -0.369714292530311240f, - 0.929074581259315860f, -0.369892447148934100f, 0.929003638191603360f, - -0.370070588167669080f, - 0.928932660967082820f, -0.370248715579966360f, 0.928861649588363700f, - -0.370426829379276790f, - 0.928790604058057020f, -0.370604929559051670f, 0.928719524378774810f, - -0.370783016112742560f, - 0.928648410553130520f, -0.370961089033801980f, 0.928577262583738850f, - -0.371139148315682570f, - 0.928506080473215590f, -0.371317193951837540f, 0.928434864224177980f, - -0.371495225935720760f, - 0.928363613839244370f, -0.371673244260786520f, 0.928292329321034670f, - -0.371851248920489490f, - 0.928221010672169440f, -0.372029239908285010f, 0.928149657895271150f, - -0.372207217217628840f, - 0.928078270992963140f, -0.372385180841977360f, 0.928006849967869970f, - -0.372563130774787250f, - 0.927935394822617890f, -0.372741067009515760f, 0.927863905559833780f, - -0.372918989539620830f, - 0.927792382182146320f, -0.373096898358560640f, 0.927720824692185200f, - -0.373274793459793970f, - 0.927649233092581180f, -0.373452674836780300f, 0.927577607385966730f, - -0.373630542482979280f, - 0.927505947574975180f, -0.373808396391851210f, 0.927434253662241300f, - -0.373986236556857030f, - 0.927362525650401110f, -0.374164062971457930f, 0.927290763542091720f, - -0.374341875629115920f, - 0.927218967339951790f, -0.374519674523293210f, 0.927147137046620880f, - -0.374697459647452600f, - 0.927075272664740100f, -0.374875230995057540f, 0.927003374196951670f, - -0.375052988559571920f, - 0.926931441645899130f, -0.375230732334459920f, 0.926859475014227160f, - -0.375408462313186590f, - 0.926787474304581750f, -0.375586178489217220f, 0.926715439519610330f, - -0.375763880856017700f, - 0.926643370661961230f, -0.375941569407054420f, 0.926571267734284330f, - -0.376119244135794340f, - 0.926499130739230510f, -0.376296905035704790f, 0.926426959679452210f, - -0.376474552100253770f, - 0.926354754557602860f, -0.376652185322909560f, 0.926282515376337210f, - -0.376829804697141280f, - 0.926210242138311380f, -0.377007410216418260f, 0.926137934846182560f, - -0.377185001874210450f, - 0.926065593502609310f, -0.377362579663988340f, 0.925993218110251480f, - -0.377540143579222940f, - 0.925920808671770070f, -0.377717693613385640f, 0.925848365189827270f, - -0.377895229759948490f, - 0.925775887667086740f, -0.378072752012383990f, 0.925703376106213230f, - -0.378250260364165200f, - 0.925630830509872720f, -0.378427754808765560f, 0.925558250880732740f, - -0.378605235339659120f, - 0.925485637221461490f, -0.378782701950320540f, 0.925412989534729060f, - -0.378960154634224720f, - 0.925340307823206310f, -0.379137593384847320f, 0.925267592089565660f, - -0.379315018195664430f, - 0.925194842336480530f, -0.379492429060152630f, 0.925122058566625880f, - -0.379669825971788940f, - 0.925049240782677580f, -0.379847208924051160f, 0.924976388987313160f, - -0.380024577910417270f, - 0.924903503183210910f, -0.380201932924366050f, 0.924830583373050800f, - -0.380379273959376600f, - 0.924757629559513910f, -0.380556601008928520f, 0.924684641745282420f, - -0.380733914066502140f, - 0.924611619933039970f, -0.380911213125578070f, 0.924538564125471420f, - -0.381088498179637520f, - 0.924465474325262600f, -0.381265769222162380f, 0.924392350535101050f, - -0.381443026246634730f, - 0.924319192757675160f, -0.381620269246537360f, 0.924246000995674890f, - -0.381797498215353640f, - 0.924172775251791200f, -0.381974713146567220f, 0.924099515528716280f, - -0.382151914033662610f, - 0.924026221829143850f, -0.382329100870124510f, 0.923952894155768640f, - -0.382506273649438230f, - 0.923879532511286740f, -0.382683432365089780f, 0.923806136898395410f, - -0.382860577010565420f, - 0.923732707319793290f, -0.383037707579352020f, 0.923659243778179980f, - -0.383214824064937180f, - 0.923585746276256670f, -0.383391926460808660f, 0.923512214816725630f, - -0.383569014760454910f, - 0.923438649402290370f, -0.383746088957365010f, 0.923365050035655720f, - -0.383923149045028390f, - 0.923291416719527640f, -0.384100195016935040f, 0.923217749456613500f, - -0.384277226866575510f, - 0.923144048249621930f, -0.384454244587440820f, 0.923070313101262420f, - -0.384631248173022580f, - 0.922996544014246250f, -0.384808237616812880f, 0.922922740991285680f, - -0.384985212912304200f, - 0.922848904035094120f, -0.385162174052989860f, 0.922775033148386380f, - -0.385339121032363340f, - 0.922701128333878630f, -0.385516053843918850f, 0.922627189594287910f, - -0.385692972481151140f, - 0.922553216932332830f, -0.385869876937555310f, 0.922479210350733210f, - -0.386046767206627170f, - 0.922405169852209880f, -0.386223643281862980f, 0.922331095439485440f, - -0.386400505156759440f, - 0.922256987115283030f, -0.386577352824813920f, 0.922182844882327600f, - -0.386754186279524180f, - 0.922108668743345180f, -0.386931005514388580f, 0.922034458701062820f, - -0.387107810522905990f, - 0.921960214758209220f, -0.387284601298575840f, 0.921885936917513970f, - -0.387461377834897870f, - 0.921811625181708120f, -0.387638140125372730f, 0.921737279553523910f, - -0.387814888163501180f, - 0.921662900035694730f, -0.387991621942784860f, 0.921588486630955490f, - -0.388168341456725740f, - 0.921514039342042010f, -0.388345046698826250f, 0.921439558171691430f, - -0.388521737662589570f, - 0.921365043122642340f, -0.388698414341519190f, 0.921290494197634540f, - -0.388875076729119250f, - 0.921215911399408730f, -0.389051724818894380f, 0.921141294730707270f, - -0.389228358604349730f, - 0.921066644194273640f, -0.389404978078990940f, 0.920991959792852310f, - -0.389581583236324300f, - 0.920917241529189520f, -0.389758174069856410f, 0.920842489406032190f, - -0.389934750573094730f, - 0.920767703426128790f, -0.390111312739546910f, 0.920692883592229120f, - -0.390287860562721190f, - 0.920618029907083970f, -0.390464394036126590f, 0.920543142373445480f, - -0.390640913153272430f, - 0.920468220994067110f, -0.390817417907668500f, 0.920393265771703550f, - -0.390993908292825380f, - 0.920318276709110590f, -0.391170384302253870f, 0.920243253809045370f, - -0.391346845929465560f, - 0.920168197074266340f, -0.391523293167972410f, 0.920093106507533180f, - -0.391699726011286940f, - 0.920017982111606570f, -0.391876144452922350f, 0.919942823889248640f, - -0.392052548486392090f, - 0.919867631843222950f, -0.392228938105210310f, 0.919792405976293860f, - -0.392405313302891690f, - 0.919717146291227360f, -0.392581674072951470f, 0.919641852790790470f, - -0.392758020408905280f, - 0.919566525477751530f, -0.392934352304269490f, 0.919491164354880100f, - -0.393110669752560760f, - 0.919415769424947070f, -0.393286972747296400f, 0.919340340690724340f, - -0.393463261281994330f, - 0.919264878154985370f, -0.393639535350172880f, 0.919189381820504470f, - -0.393815794945351020f, - 0.919113851690057770f, -0.393992040061048100f, 0.919038287766422050f, - -0.394168270690784080f, - 0.918962690052375630f, -0.394344486828079600f, 0.918887058550697970f, - -0.394520688466455600f, - 0.918811393264170050f, -0.394696875599433560f, 0.918735694195573550f, - -0.394873048220535760f, - 0.918659961347691900f, -0.395049206323284770f, 0.918584194723309540f, - -0.395225349901203670f, - 0.918508394325212250f, -0.395401478947816350f, 0.918432560156186910f, - -0.395577593456646840f, - 0.918356692219021720f, -0.395753693421220080f, 0.918280790516506130f, - -0.395929778835061250f, - 0.918204855051430900f, -0.396105849691696270f, 0.918128885826588030f, - -0.396281905984651520f, - 0.918052882844770380f, -0.396457947707453910f, 0.917976846108772730f, - -0.396633974853630830f, - 0.917900775621390500f, -0.396809987416710310f, 0.917824671385420570f, - -0.396985985390220900f, - 0.917748533403661250f, -0.397161968767691610f, 0.917672361678911860f, - -0.397337937542652060f, - 0.917596156213972950f, -0.397513891708632330f, 0.917519917011646260f, - -0.397689831259163180f, - 0.917443644074735220f, -0.397865756187775750f, 0.917367337406043930f, - -0.398041666488001770f, - 0.917290997008377910f, -0.398217562153373560f, 0.917214622884544250f, - -0.398393443177423980f, - 0.917138215037350710f, -0.398569309553686300f, 0.917061773469606820f, - -0.398745161275694430f, - 0.916985298184123000f, -0.398920998336982910f, 0.916908789183710990f, - -0.399096820731086540f, - 0.916832246471183890f, -0.399272628451540990f, 0.916755670049355990f, - -0.399448421491882140f, - 0.916679059921042700f, -0.399624199845646790f, 0.916602416089060790f, - -0.399799963506371980f, - 0.916525738556228210f, -0.399975712467595330f, 0.916449027325364150f, - -0.400151446722855130f, - 0.916372282399289140f, -0.400327166265690090f, 0.916295503780824800f, - -0.400502871089639500f, - 0.916218691472794220f, -0.400678561188243240f, 0.916141845478021350f, - -0.400854236555041650f, - 0.916064965799331720f, -0.401029897183575620f, 0.915988052439551950f, - -0.401205543067386710f, - 0.915911105401509880f, -0.401381174200016790f, 0.915834124688034710f, - -0.401556790575008540f, - 0.915757110301956720f, -0.401732392185905010f, 0.915680062246107650f, - -0.401907979026249700f, - 0.915602980523320230f, -0.402083551089586990f, 0.915525865136428530f, - -0.402259108369461490f, - 0.915448716088267830f, -0.402434650859418430f, 0.915371533381674760f, - -0.402610178553003680f, - 0.915294317019487050f, -0.402785691443763530f, 0.915217067004543860f, - -0.402961189525244900f, - 0.915139783339685260f, -0.403136672790995300f, 0.915062466027752760f, - -0.403312141234562550f, - 0.914985115071589310f, -0.403487594849495310f, 0.914907730474038730f, - -0.403663033629342640f, - 0.914830312237946200f, -0.403838457567654070f, 0.914752860366158220f, - -0.404013866657979890f, - 0.914675374861522390f, -0.404189260893870690f, 0.914597855726887790f, - -0.404364640268877810f, - 0.914520302965104450f, -0.404540004776553000f, 0.914442716579023870f, - -0.404715354410448650f, - 0.914365096571498560f, -0.404890689164117580f, 0.914287442945382440f, - -0.405066009031113340f, - 0.914209755703530690f, -0.405241314004989860f, 0.914132034848799460f, - -0.405416604079301630f, - 0.914054280384046570f, -0.405591879247603870f, 0.913976492312130630f, - -0.405767139503452060f, - 0.913898670635911680f, -0.405942384840402510f, 0.913820815358251100f, - -0.406117615252011840f, - 0.913742926482011390f, -0.406292830731837360f, 0.913665004010056350f, - -0.406468031273437000f, - 0.913587047945250810f, -0.406643216870369030f, 0.913509058290461140f, - -0.406818387516192310f, - 0.913431035048554720f, -0.406993543204466510f, 0.913352978222400250f, - -0.407168683928751550f, - 0.913274887814867760f, -0.407343809682607970f, 0.913196763828828200f, - -0.407518920459596920f, - 0.913118606267154240f, -0.407694016253280110f, 0.913040415132719160f, - -0.407869097057219800f, - 0.912962190428398210f, -0.408044162864978690f, 0.912883932157067200f, - -0.408219213670120100f, - 0.912805640321603500f, -0.408394249466208000f, 0.912727314924885900f, - -0.408569270246806780f, - 0.912648955969793900f, -0.408744276005481360f, 0.912570563459208730f, - -0.408919266735797430f, - 0.912492137396012650f, -0.409094242431320980f, 0.912413677783089020f, - -0.409269203085618590f, - 0.912335184623322750f, -0.409444148692257590f, 0.912256657919599760f, - -0.409619079244805670f, - 0.912178097674807180f, -0.409793994736831150f, 0.912099503891833470f, - -0.409968895161902880f, - 0.912020876573568340f, -0.410143780513590240f, 0.911942215722902570f, - -0.410318650785463260f, - 0.911863521342728520f, -0.410493505971092410f, 0.911784793435939430f, - -0.410668346064048730f, - 0.911706032005429880f, -0.410843171057903910f, 0.911627237054095650f, - -0.411017980946230210f, - 0.911548408584833990f, -0.411192775722600160f, 0.911469546600543020f, - -0.411367555380587220f, - 0.911390651104122430f, -0.411542319913765220f, 0.911311722098472780f, - -0.411717069315708560f, - 0.911232759586496190f, -0.411891803579992170f, 0.911153763571095900f, - -0.412066522700191560f, - 0.911074734055176360f, -0.412241226669882890f, 0.910995671041643140f, - -0.412415915482642730f, - 0.910916574533403360f, -0.412590589132048210f, 0.910837444533365010f, - -0.412765247611677270f, - 0.910758281044437570f, -0.412939890915108080f, 0.910679084069531570f, - -0.413114519035919450f, - 0.910599853611558930f, -0.413289131967690960f, 0.910520589673432750f, - -0.413463729704002410f, - 0.910441292258067250f, -0.413638312238434500f, 0.910361961368377990f, - -0.413812879564568300f, - 0.910282597007281760f, -0.413987431675985400f, 0.910203199177696540f, - -0.414161968566268080f, - 0.910123767882541680f, -0.414336490228999100f, 0.910044303124737500f, - -0.414510996657761750f, - 0.909964804907205660f, -0.414685487846140010f, 0.909885273232869160f, - -0.414859963787718330f, - 0.909805708104652220f, -0.415034424476081630f, 0.909726109525480160f, - -0.415208869904815590f, - 0.909646477498279540f, -0.415383300067506230f, 0.909566812025978330f, - -0.415557714957740410f, - 0.909487113111505430f, -0.415732114569105360f, 0.909407380757791260f, - -0.415906498895188770f, - 0.909327614967767260f, -0.416080867929579210f, 0.909247815744366310f, - -0.416255221665865480f, - 0.909167983090522380f, -0.416429560097637150f, 0.909088117009170580f, - -0.416603883218484350f, - 0.909008217503247450f, -0.416778191021997650f, 0.908928284575690640f, - -0.416952483501768170f, - 0.908848318229439120f, -0.417126760651387870f, 0.908768318467432890f, - -0.417301022464448890f, - 0.908688285292613360f, -0.417475268934544290f, 0.908608218707923190f, - -0.417649500055267410f, - 0.908528118716306120f, -0.417823715820212270f, 0.908447985320707250f, - -0.417997916222973550f, - 0.908367818524072890f, -0.418172101257146320f, 0.908287618329350450f, - -0.418346270916326260f, - 0.908207384739488700f, -0.418520425194109700f, 0.908127117757437600f, - -0.418694564084093560f, - 0.908046817386148340f, -0.418868687579875050f, 0.907966483628573350f, - -0.419042795675052370f, - 0.907886116487666260f, -0.419216888363223910f, 0.907805715966381930f, - -0.419390965637988890f, - 0.907725282067676440f, -0.419565027492946880f, 0.907644814794507200f, - -0.419739073921698180f, - 0.907564314149832630f, -0.419913104917843620f, 0.907483780136612570f, - -0.420087120474984530f, - 0.907403212757808110f, -0.420261120586722880f, 0.907322612016381420f, - -0.420435105246661170f, - 0.907241977915295820f, -0.420609074448402510f, 0.907161310457516250f, - -0.420783028185550520f, - 0.907080609646008450f, -0.420956966451709440f, 0.906999875483739610f, - -0.421130889240483970f, - 0.906919107973678140f, -0.421304796545479640f, 0.906838307118793430f, - -0.421478688360302280f, - 0.906757472922056550f, -0.421652564678558330f, 0.906676605386439460f, - -0.421826425493854910f, - 0.906595704514915330f, -0.422000270799799680f, 0.906514770310458800f, - -0.422174100590000770f, - 0.906433802776045460f, -0.422347914858067050f, 0.906352801914652400f, - -0.422521713597607820f, - 0.906271767729257660f, -0.422695496802232950f, 0.906190700222840650f, - -0.422869264465553060f, - 0.906109599398381980f, -0.423043016581179040f, 0.906028465258863600f, - -0.423216753142722610f, - 0.905947297807268460f, -0.423390474143796050f, 0.905866097046580940f, - -0.423564179578011960f, - 0.905784862979786550f, -0.423737869438983840f, 0.905703595609872010f, - -0.423911543720325580f, - 0.905622294939825270f, -0.424085202415651560f, 0.905540960972635590f, - -0.424258845518576950f, - 0.905459593711293250f, -0.424432473022717420f, 0.905378193158790090f, - -0.424606084921689110f, - 0.905296759318118820f, -0.424779681209108810f, 0.905215292192273590f, - -0.424953261878593890f, - 0.905133791784249690f, -0.425126826923762360f, 0.905052258097043590f, - -0.425300376338232640f, - 0.904970691133653250f, -0.425473910115623800f, 0.904889090897077470f, - -0.425647428249555590f, - 0.904807457390316540f, -0.425820930733648240f, 0.904725790616371930f, - -0.425994417561522400f, - 0.904644090578246240f, -0.426167888726799620f, 0.904562357278943300f, - -0.426341344223101830f, - 0.904480590721468250f, -0.426514784044051520f, 0.904398790908827350f, - -0.426688208183271860f, - 0.904316957844028320f, -0.426861616634386430f, 0.904235091530079750f, - -0.427035009391019680f, - 0.904153191969991780f, -0.427208386446796320f, 0.904071259166775440f, - -0.427381747795341770f, - 0.903989293123443340f, -0.427555093430282080f, 0.903907293843009050f, - -0.427728423345243800f, - 0.903825261328487510f, -0.427901737533854080f, 0.903743195582894620f, - -0.428075035989740730f, - 0.903661096609247980f, -0.428248318706531960f, 0.903578964410566070f, - -0.428421585677856650f, - 0.903496798989868450f, -0.428594836897344400f, 0.903414600350176290f, - -0.428768072358625070f, - 0.903332368494511820f, -0.428941292055329490f, 0.903250103425898400f, - -0.429114495981088750f, - 0.903167805147360720f, -0.429287684129534610f, 0.903085473661924600f, - -0.429460856494299490f, - 0.903003108972617150f, -0.429634013069016380f, 0.902920711082466740f, - -0.429807153847318710f, - 0.902838279994502830f, -0.429980278822840620f, 0.902755815711756120f, - -0.430153387989216870f, - 0.902673318237258830f, -0.430326481340082610f, 0.902590787574043870f, - -0.430499558869073820f, - 0.902508223725145940f, -0.430672620569826800f, 0.902425626693600380f, - -0.430845666435978660f, - 0.902342996482444200f, -0.431018696461167030f, 0.902260333094715540f, - -0.431191710639029950f, - 0.902177636533453620f, -0.431364708963206330f, 0.902094906801698900f, - -0.431537691427335500f, - 0.902012143902493180f, -0.431710658025057260f, 0.901929347838879460f, - -0.431883608750012250f, - 0.901846518613901750f, -0.432056543595841500f, 0.901763656230605730f, - -0.432229462556186720f, - 0.901680760692037730f, -0.432402365624690140f, 0.901597832001245660f, - -0.432575252794994650f, - 0.901514870161278740f, -0.432748124060743700f, 0.901431875175186970f, - -0.432920979415581280f, - 0.901348847046022030f, -0.433093818853151960f, 0.901265785776836580f, - -0.433266642367100940f, - 0.901182691370684520f, -0.433439449951074090f, 0.901099563830620950f, - -0.433612241598717580f, - 0.901016403159702330f, -0.433785017303678520f, 0.900933209360986200f, - -0.433957777059604420f, - 0.900849982437531450f, -0.434130520860143310f, 0.900766722392397860f, - -0.434303248698943990f, - 0.900683429228646970f, -0.434475960569655650f, 0.900600102949340900f, - -0.434648656465928320f, - 0.900516743557543520f, -0.434821336381412290f, 0.900433351056319830f, - -0.434994000309758710f, - 0.900349925448735600f, -0.435166648244619260f, 0.900266466737858480f, - -0.435339280179646070f, - 0.900182974926756810f, -0.435511896108492000f, 0.900099450018500450f, - -0.435684496024810460f, - 0.900015892016160280f, -0.435857079922255470f, 0.899932300922808510f, - -0.436029647794481560f, - 0.899848676741518580f, -0.436202199635143950f, 0.899765019475365140f, - -0.436374735437898340f, - 0.899681329127423930f, -0.436547255196401200f, 0.899597605700772180f, - -0.436719758904309360f, - 0.899513849198487980f, -0.436892246555280360f, 0.899430059623650860f, - -0.437064718142972370f, - 0.899346236979341570f, -0.437237173661044090f, 0.899262381268642000f, - -0.437409613103154790f, - 0.899178492494635330f, -0.437582036462964400f, 0.899094570660405770f, - -0.437754443734133410f, - 0.899010615769039070f, -0.437926834910322860f, 0.898926627823621870f, - -0.438099209985194470f, - 0.898842606827242370f, -0.438271568952410430f, 0.898758552782989440f, - -0.438443911805633690f, - 0.898674465693953820f, -0.438616238538527660f, 0.898590345563227030f, - -0.438788549144756290f, - 0.898506192393901950f, -0.438960843617984320f, 0.898422006189072530f, - -0.439133121951876930f, - 0.898337786951834310f, -0.439305384140099950f, 0.898253534685283570f, - -0.439477630176319800f, - 0.898169249392518080f, -0.439649860054203480f, 0.898084931076636780f, - -0.439822073767418500f, - 0.898000579740739880f, -0.439994271309633260f, 0.897916195387928660f, - -0.440166452674516320f, - 0.897831778021305650f, -0.440338617855737250f, 0.897747327643974690f, - -0.440510766846965940f, - 0.897662844259040860f, -0.440682899641872900f, 0.897578327869610230f, - -0.440855016234129430f, - 0.897493778478790310f, -0.441027116617407230f, 0.897409196089689720f, - -0.441199200785378660f, - 0.897324580705418320f, -0.441371268731716670f, 0.897239932329087160f, - -0.441543320450094870f, - 0.897155250963808550f, -0.441715355934187310f, 0.897070536612695870f, - -0.441887375177668850f, - 0.896985789278863970f, -0.442059378174214700f, 0.896901008965428790f, - -0.442231364917500980f, - 0.896816195675507300f, -0.442403335401204080f, 0.896731349412217880f, - -0.442575289619001170f, - 0.896646470178680150f, -0.442747227564570020f, 0.896561557978014960f, - -0.442919149231588980f, - 0.896476612813344120f, -0.443091054613736880f, 0.896391634687790820f, - -0.443262943704693320f, - 0.896306623604479550f, -0.443434816498138480f, 0.896221579566536030f, - -0.443606672987752970f, - 0.896136502577086770f, -0.443778513167218220f, 0.896051392639260150f, - -0.443950337030216140f, - 0.895966249756185220f, -0.444122144570429200f, 0.895881073930992370f, - -0.444293935781540580f, - 0.895795865166813530f, -0.444465710657234000f, 0.895710623466781320f, - -0.444637469191193790f, - 0.895625348834030110f, -0.444809211377104880f, 0.895540041271694950f, - -0.444980937208652730f, - 0.895454700782912450f, -0.445152646679523640f, 0.895369327370820310f, - -0.445324339783404190f, - 0.895283921038557580f, -0.445496016513981740f, 0.895198481789264200f, - -0.445667676864944300f, - 0.895113009626081760f, -0.445839320829980290f, 0.895027504552152630f, - -0.446010948402778940f, - 0.894941966570620750f, -0.446182559577030070f, 0.894856395684631050f, - -0.446354154346423840f, - 0.894770791897329550f, -0.446525732704651350f, 0.894685155211863980f, - -0.446697294645404090f, - 0.894599485631382700f, -0.446868840162374160f, 0.894513783159035620f, - -0.447040369249254440f, - 0.894428047797973800f, -0.447211881899738320f, 0.894342279551349480f, - -0.447383378107519600f, - 0.894256478422316040f, -0.447554857866293010f, 0.894170644414028270f, - -0.447726321169753580f, - 0.894084777529641990f, -0.447897768011597310f, 0.893998877772314240f, - -0.448069198385520400f, - 0.893912945145203250f, -0.448240612285219890f, 0.893826979651468620f, - -0.448412009704393430f, - 0.893740981294271040f, -0.448583390636739240f, 0.893654950076772540f, - -0.448754755075955970f, - 0.893568886002135910f, -0.448926103015743260f, 0.893482789073525850f, - -0.449097434449801050f, - 0.893396659294107720f, -0.449268749371829920f, 0.893310496667048200f, - -0.449440047775531150f, - 0.893224301195515320f, -0.449611329654606540f, 0.893138072882678320f, - -0.449782595002758690f, - 0.893051811731707450f, -0.449953843813690520f, 0.892965517745774370f, - -0.450125076081105690f, - 0.892879190928051680f, -0.450296291798708610f, 0.892792831281713610f, - -0.450467490960204110f, - 0.892706438809935390f, -0.450638673559297600f, 0.892620013515893150f, - -0.450809839589695280f, - 0.892533555402764580f, -0.450980989045103860f, 0.892447064473728680f, - -0.451152121919230600f, - 0.892360540731965360f, -0.451323238205783520f, 0.892273984180655840f, - -0.451494337898471100f, - 0.892187394822982480f, -0.451665420991002490f, 0.892100772662129060f, - -0.451836487477087490f, - 0.892014117701280470f, -0.452007537350436420f, 0.891927429943622510f, - -0.452178570604760350f, - 0.891840709392342720f, -0.452349587233770890f, 0.891753956050629460f, - -0.452520587231180050f, - 0.891667169921672280f, -0.452691570590700920f, 0.891580351008662290f, - -0.452862537306046750f, - 0.891493499314791380f, -0.453033487370931580f, 0.891406614843252900f, - -0.453204420779070190f, - 0.891319697597241390f, -0.453375337524177750f, 0.891232747579952520f, - -0.453546237599970090f, - 0.891145764794583180f, -0.453717121000163870f, 0.891058749244331590f, - -0.453887987718476050f, - 0.890971700932396860f, -0.454058837748624430f, 0.890884619861979530f, - -0.454229671084327320f, - 0.890797506036281490f, -0.454400487719303580f, 0.890710359458505630f, - -0.454571287647272950f, - 0.890623180131855930f, -0.454742070861955450f, 0.890535968059537830f, - -0.454912837357071940f, - 0.890448723244757880f, -0.455083587126343840f, 0.890361445690723840f, - -0.455254320163493100f, - 0.890274135400644600f, -0.455425036462242360f, 0.890186792377730240f, - -0.455595736016314980f, - 0.890099416625192320f, -0.455766418819434640f, 0.890012008146243260f, - -0.455937084865326030f, - 0.889924566944096720f, -0.456107734147714110f, 0.889837093021967900f, - -0.456278366660324620f, - 0.889749586383072780f, -0.456448982396883920f, 0.889662047030628900f, - -0.456619581351118910f, - 0.889574474967854580f, -0.456790163516757160f, 0.889486870197969900f, - -0.456960728887526980f, - 0.889399232724195520f, -0.457131277457156980f, 0.889311562549753850f, - -0.457301809219376630f, - 0.889223859677868210f, -0.457472324167916060f, 0.889136124111763240f, - -0.457642822296505770f, - 0.889048355854664570f, -0.457813303598877170f, 0.888960554909799310f, - -0.457983768068762120f, - 0.888872721280395630f, -0.458154215699893060f, 0.888784854969682850f, - -0.458324646486003240f, - 0.888696955980891600f, -0.458495060420826270f, 0.888609024317253860f, - -0.458665457498096560f, - 0.888521059982002260f, -0.458835837711549120f, 0.888433062978371320f, - -0.459006201054919630f, - 0.888345033309596350f, -0.459176547521944090f, 0.888256970978913870f, - -0.459346877106359630f, - 0.888168875989561730f, -0.459517189801903480f, 0.888080748344778900f, - -0.459687485602313870f, - 0.887992588047805560f, -0.459857764501329540f, 0.887904395101883240f, - -0.460028026492689650f, - 0.887816169510254440f, -0.460198271570134320f, 0.887727911276163020f, - -0.460368499727404010f, - 0.887639620402853930f, -0.460538710958240010f, 0.887551296893573370f, - -0.460708905256384080f, - 0.887462940751568840f, -0.460879082615578690f, 0.887374551980088850f, - -0.461049243029566900f, - 0.887286130582383150f, -0.461219386492092380f, 0.887197676561702900f, - -0.461389512996899450f, - 0.887109189921300170f, -0.461559622537733080f, 0.887020670664428360f, - -0.461729715108338770f, - 0.886932118794342190f, -0.461899790702462730f, 0.886843534314297410f, - -0.462069849313851750f, - 0.886754917227550840f, -0.462239890936253340f, 0.886666267537361000f, - -0.462409915563415430f, - 0.886577585246987040f, -0.462579923189086810f, 0.886488870359689600f, - -0.462749913807016740f, - 0.886400122878730600f, -0.462919887410955080f, 0.886311342807372780f, - -0.463089843994652530f, - 0.886222530148880640f, -0.463259783551860150f, 0.886133684906519340f, - -0.463429706076329830f, - 0.886044807083555600f, -0.463599611561814010f, 0.885955896683257030f, - -0.463769500002065630f, - 0.885866953708892790f, -0.463939371390838520f, 0.885777978163732940f, - -0.464109225721886950f, - 0.885688970051048960f, -0.464279062988965760f, 0.885599929374113360f, - -0.464448883185830660f, - 0.885510856136199950f, -0.464618686306237820f, 0.885421750340583680f, - -0.464788472343943990f, - 0.885332611990540590f, -0.464958241292706690f, 0.885243441089348270f, - -0.465127993146283950f, - 0.885154237640285110f, -0.465297727898434600f, 0.885065001646630930f, - -0.465467445542917800f, - 0.884975733111666660f, -0.465637146073493660f, 0.884886432038674560f, - -0.465806829483922710f, - 0.884797098430937790f, -0.465976495767966180f, 0.884707732291741040f, - -0.466146144919385890f, - 0.884618333624369920f, -0.466315776931944430f, 0.884528902432111460f, - -0.466485391799404900f, - 0.884439438718253810f, -0.466654989515530920f, 0.884349942486086120f, - -0.466824570074086950f, - 0.884260413738899190f, -0.466994133468838000f, 0.884170852479984500f, - -0.467163679693549770f, - 0.884081258712634990f, -0.467333208741988420f, 0.883991632440144890f, - -0.467502720607920920f, - 0.883901973665809470f, -0.467672215285114770f, 0.883812282392925090f, - -0.467841692767338170f, - 0.883722558624789660f, -0.468011153048359830f, 0.883632802364701870f, - -0.468180596121949290f, - 0.883543013615961880f, -0.468350021981876530f, 0.883453192381870920f, - -0.468519430621912310f, - 0.883363338665731580f, -0.468688822035827900f, 0.883273452470847430f, - -0.468858196217395330f, - 0.883183533800523390f, -0.469027553160387130f, 0.883093582658065370f, - -0.469196892858576580f, - 0.883003599046780830f, -0.469366215305737520f, 0.882913582969978020f, - -0.469535520495644450f, - 0.882823534430966620f, -0.469704808422072460f, 0.882733453433057650f, - -0.469874079078797360f, - 0.882643339979562790f, -0.470043332459595620f, 0.882553194073795510f, - -0.470212568558244170f, - 0.882463015719070150f, -0.470381787368520650f, 0.882372804918702290f, - -0.470550988884203550f, - 0.882282561676008710f, -0.470720173099071600f, 0.882192285994307430f, - -0.470889340006904520f, - 0.882101977876917580f, -0.471058489601482500f, 0.882011637327159590f, - -0.471227621876586340f, - 0.881921264348355050f, -0.471396736825997640f, 0.881830858943826620f, - -0.471565834443498420f, - 0.881740421116898320f, -0.471734914722871430f, 0.881649950870895260f, - -0.471903977657900210f, - 0.881559448209143780f, -0.472073023242368660f, 0.881468913134971440f, - -0.472242051470061490f, - 0.881378345651706920f, -0.472411062334764040f, 0.881287745762680100f, - -0.472580055830262250f, - 0.881197113471222090f, -0.472749031950342790f, 0.881106448780665130f, - -0.472917990688792760f, - 0.881015751694342870f, -0.473086932039400050f, 0.880925022215589880f, - -0.473255855995953320f, - 0.880834260347742040f, -0.473424762552241530f, 0.880743466094136340f, - -0.473593651702054530f, - 0.880652639458111010f, -0.473762523439182850f, 0.880561780443005700f, - -0.473931377757417450f, - 0.880470889052160750f, -0.474100214650549970f, 0.880379965288918150f, - -0.474269034112372980f, - 0.880289009156621010f, -0.474437836136679230f, 0.880198020658613190f, - -0.474606620717262560f, - 0.880106999798240360f, -0.474775387847917120f, 0.880015946578849070f, - -0.474944137522437800f, - 0.879924861003786860f, -0.475112869734620300f, 0.879833743076402940f, - -0.475281584478260740f, - 0.879742592800047410f, -0.475450281747155870f, 0.879651410178071580f, - -0.475618961535103300f, - 0.879560195213827890f, -0.475787623835901120f, 0.879468947910670210f, - -0.475956268643348060f, - 0.879377668271953290f, -0.476124895951243580f, 0.879286356301033250f, - -0.476293505753387690f, - 0.879195012001267480f, -0.476462098043581190f, 0.879103635376014330f, - -0.476630672815625320f, - 0.879012226428633530f, -0.476799230063322090f, 0.878920785162485840f, - -0.476967769780474170f, - 0.878829311580933360f, -0.477136291960884810f, 0.878737805687339390f, - -0.477304796598357890f, - 0.878646267485068130f, -0.477473283686698060f, 0.878554696977485450f, - -0.477641753219710470f, - 0.878463094167957870f, -0.477810205191200990f, 0.878371459059853480f, - -0.477978639594976160f, - 0.878279791656541580f, -0.478147056424843010f, 0.878188091961392250f, - -0.478315455674609480f, - 0.878096359977777130f, -0.478483837338083970f, 0.878004595709069080f, - -0.478652201409075500f, - 0.877912799158641840f, -0.478820547881393890f, 0.877820970329870500f, - -0.478988876748849490f, - 0.877729109226131570f, -0.479157188005253310f, 0.877637215850802230f, - -0.479325481644417070f, - 0.877545290207261350f, -0.479493757660153010f, 0.877453332298888560f, - -0.479662016046274180f, - 0.877361342129065140f, -0.479830256796594190f, 0.877269319701173170f, - -0.479998479904927280f, - 0.877177265018595940f, -0.480166685365088390f, 0.877085178084718420f, - -0.480334873170893020f, - 0.876993058902925890f, -0.480503043316157510f, 0.876900907476605650f, - -0.480671195794698640f, - 0.876808723809145650f, -0.480839330600333960f, 0.876716507903935400f, - -0.481007447726881590f, - 0.876624259764365310f, -0.481175547168160300f, 0.876531979393827100f, - -0.481343628917989710f, - 0.876439666795713610f, -0.481511692970189860f, 0.876347321973419020f, - -0.481679739318581490f, - 0.876254944930338510f, -0.481847767956986030f, 0.876162535669868460f, - -0.482015778879225590f, - 0.876070094195406600f, -0.482183772079122720f, 0.875977620510351770f, - -0.482351747550500980f, - 0.875885114618103810f, -0.482519705287184350f, 0.875792576522063880f, - -0.482687645282997460f, - 0.875700006225634600f, -0.482855567531765670f, 0.875607403732219350f, - -0.483023472027314880f, - 0.875514769045222850f, -0.483191358763471860f, 0.875422102168050940f, - -0.483359227734063810f, - 0.875329403104110890f, -0.483527078932918740f, 0.875236671856810870f, - -0.483694912353865140f, - 0.875143908429560360f, -0.483862727990732270f, 0.875051112825769970f, - -0.484030525837350010f, - 0.874958285048851650f, -0.484198305887549030f, 0.874865425102218320f, - -0.484366068135160420f, - 0.874772532989284150f, -0.484533812574016180f, 0.874679608713464510f, - -0.484701539197948670f, - 0.874586652278176110f, -0.484869248000791060f, 0.874493663686836560f, - -0.485036938976377290f, - 0.874400642942864790f, -0.485204612118541820f, 0.874307590049680950f, - -0.485372267421119770f, - 0.874214505010706300f, -0.485539904877946960f, 0.874121387829363330f, - -0.485707524482859750f, - 0.874028238509075740f, -0.485875126229695250f, 0.873935057053268240f, - -0.486042710112291330f, - 0.873841843465366860f, -0.486210276124486420f, 0.873748597748798870f, - -0.486377824260119440f, - 0.873655319906992630f, -0.486545354513030270f, 0.873562009943377850f, - -0.486712866877059170f, - 0.873468667861384880f, -0.486880361346047340f, 0.873375293664446000f, - -0.487047837913836380f, - 0.873281887355994210f, -0.487215296574268760f, 0.873188448939463790f, - -0.487382737321187360f, - 0.873094978418290090f, -0.487550160148436000f, 0.873001475795909920f, - -0.487717565049858800f, - 0.872907941075761080f, -0.487884952019301040f, 0.872814374261282390f, - -0.488052321050608250f, - 0.872720775355914300f, -0.488219672137626790f, 0.872627144363097960f, - -0.488387005274203530f, - 0.872533481286276170f, -0.488554320454186180f, 0.872439786128892280f, - -0.488721617671423080f, - 0.872346058894391540f, -0.488888896919763170f, 0.872252299586219860f, - -0.489056158193056030f, - 0.872158508207824480f, -0.489223401485151980f, 0.872064684762653860f, - -0.489390626789901920f, - 0.871970829254157810f, -0.489557834101157440f, 0.871876941685786890f, - -0.489725023412770910f, - 0.871783022060993120f, -0.489892194718595190f, 0.871689070383229740f, - -0.490059348012483850f, - 0.871595086655950980f, -0.490226483288291160f, 0.871501070882612530f, - -0.490393600539871970f, - 0.871407023066670950f, -0.490560699761082020f, 0.871312943211584030f, - -0.490727780945777400f, - 0.871218831320811020f, -0.490894844087815090f, 0.871124687397811900f, - -0.491061889181052650f, - 0.871030511446048260f, -0.491228916219348280f, 0.870936303468982760f, - -0.491395925196560780f, - 0.870842063470078980f, -0.491562916106549900f, 0.870747791452801790f, - -0.491729888943175760f, - 0.870653487420617430f, -0.491896843700299290f, 0.870559151376993250f, - -0.492063780371782000f, - 0.870464783325397670f, -0.492230698951486020f, 0.870370383269300270f, - -0.492397599433274380f, - 0.870275951212171940f, -0.492564481811010590f, 0.870181487157484560f, - -0.492731346078558840f, - 0.870086991108711460f, -0.492898192229784040f, 0.869992463069326870f, - -0.493065020258551700f, - 0.869897903042806340f, -0.493231830158727900f, 0.869803311032626650f, - -0.493398621924179770f, - 0.869708687042265670f, -0.493565395548774770f, 0.869614031075202300f, - -0.493732151026381020f, - 0.869519343134916860f, -0.493898888350867480f, 0.869424623224890890f, - -0.494065607516103570f, - 0.869329871348606840f, -0.494232308515959670f, 0.869235087509548370f, - -0.494398991344306650f, - 0.869140271711200560f, -0.494565655995015950f, 0.869045423957049530f, - -0.494732302461959870f, - 0.868950544250582380f, -0.494898930739011260f, 0.868855632595287860f, - -0.495065540820043560f, - 0.868760688994655310f, -0.495232132698931180f, 0.868665713452175690f, - -0.495398706369549020f, - 0.868570705971340900f, -0.495565261825772540f, 0.868475666555644120f, - -0.495731799061477960f, - 0.868380595208579800f, -0.495898318070542190f, 0.868285491933643350f, - -0.496064818846842890f, - 0.868190356734331310f, -0.496231301384258250f, 0.868095189614141670f, - -0.496397765676667160f, - 0.867999990576573510f, -0.496564211717949290f, 0.867904759625126920f, - -0.496730639501984760f, - 0.867809496763303320f, -0.496897049022654470f, 0.867714201994605140f, - -0.497063440273840250f, - 0.867618875322536230f, -0.497229813249424220f, 0.867523516750601460f, - -0.497396167943289280f, - 0.867428126282306920f, -0.497562504349319150f, 0.867332703921159800f, - -0.497728822461397940f, - 0.867237249670668400f, -0.497895122273410870f, 0.867141763534342470f, - -0.498061403779243410f, - 0.867046245515692650f, -0.498227666972781870f, 0.866950695618230900f, - -0.498393911847913210f, - 0.866855113845470430f, -0.498560138398525140f, 0.866759500200925400f, - -0.498726346618505900f, - 0.866663854688111130f, -0.498892536501744590f, 0.866568177310544470f, - -0.499058708042130870f, - 0.866472468071743050f, -0.499224861233555080f, 0.866376726975225830f, - -0.499390996069908170f, - 0.866280954024512990f, -0.499557112545081840f, 0.866185149223125840f, - -0.499723210652968540f, - 0.866089312574586770f, -0.499889290387461330f, 0.865993444082419520f, - -0.500055351742453860f, - 0.865897543750148820f, -0.500221394711840680f, 0.865801611581300760f, - -0.500387419289516580f, - 0.865705647579402380f, -0.500553425469377420f, 0.865609651747981990f, - -0.500719413245319880f, - 0.865513624090569090f, -0.500885382611240710f, 0.865417564610694410f, - -0.501051333561038040f, - 0.865321473311889800f, -0.501217266088609950f, 0.865225350197688200f, - -0.501383180187855770f, - 0.865129195271623800f, -0.501549075852675390f, 0.865033008537231860f, - -0.501714953076969120f, - 0.864936789998049020f, -0.501880811854638290f, 0.864840539657612870f, - -0.502046652179584660f, - 0.864744257519462380f, -0.502212474045710790f, 0.864647943587137480f, - -0.502378277446919760f, - 0.864551597864179340f, -0.502544062377115690f, 0.864455220354130360f, - -0.502709828830202990f, - 0.864358811060534030f, -0.502875576800086990f, 0.864262369986934950f, - -0.503041306280673450f, - 0.864165897136879300f, -0.503207017265868920f, 0.864069392513913790f, - -0.503372709749581040f, - 0.863972856121586810f, -0.503538383725717580f, 0.863876287963447510f, - -0.503704039188187070f, - 0.863779688043046720f, -0.503869676130898950f, 0.863683056363935830f, - -0.504035294547763190f, - 0.863586392929668100f, -0.504200894432690340f, 0.863489697743797140f, - -0.504366475779592040f, - 0.863392970809878420f, -0.504532038582380270f, 0.863296212131468230f, - -0.504697582834967570f, - 0.863199421712124160f, -0.504863108531267590f, 0.863102599555404910f, - -0.505028615665194080f, - 0.863005745664870320f, -0.505194104230662240f, 0.862908860044081400f, - -0.505359574221587280f, - 0.862811942696600330f, -0.505525025631885390f, 0.862714993625990690f, - -0.505690458455473450f, - 0.862618012835816740f, -0.505855872686268860f, 0.862521000329644520f, - -0.506021268318189720f, - 0.862423956111040610f, -0.506186645345155230f, 0.862326880183573060f, - -0.506352003761084800f, - 0.862229772550811240f, -0.506517343559898530f, 0.862132633216325380f, - -0.506682664735517600f, - 0.862035462183687210f, -0.506847967281863210f, 0.861938259456469290f, - -0.507013251192858230f, - 0.861841025038245330f, -0.507178516462425180f, 0.861743758932590700f, - -0.507343763084487920f, - 0.861646461143081300f, -0.507508991052970870f, 0.861549131673294720f, - -0.507674200361798890f, - 0.861451770526809320f, -0.507839391004897720f, 0.861354377707204910f, - -0.508004562976194010f, - 0.861256953218062170f, -0.508169716269614600f, 0.861159497062963350f, - -0.508334850879087360f, - 0.861062009245491480f, -0.508499966798540930f, 0.860964489769231010f, - -0.508665064021904030f, - 0.860866938637767310f, -0.508830142543106990f, 0.860769355854687170f, - -0.508995202356080090f, - 0.860671741423578380f, -0.509160243454754640f, 0.860574095348029980f, - -0.509325265833062480f, - 0.860476417631632070f, -0.509490269484936360f, 0.860378708277976130f, - -0.509655254404309250f, - 0.860280967290654510f, -0.509820220585115450f, 0.860183194673260990f, - -0.509985168021289460f, - 0.860085390429390140f, -0.510150096706766810f, 0.859987554562638200f, - -0.510315006635483240f, - 0.859889687076602290f, -0.510479897801375700f, 0.859791787974880650f, - -0.510644770198381610f, - 0.859693857261072610f, -0.510809623820439040f, 0.859595894938779080f, - -0.510974458661486830f, - 0.859497901011601730f, -0.511139274715464390f, 0.859399875483143450f, - -0.511304071976312000f, - 0.859301818357008470f, -0.511468850437970300f, 0.859203729636801920f, - -0.511633610094381240f, - 0.859105609326130450f, -0.511798350939486890f, 0.859007457428601520f, - -0.511963072967230200f, - 0.858909273947823900f, -0.512127776171554690f, 0.858811058887407610f, - -0.512292460546404870f, - 0.858712812250963520f, -0.512457126085725690f, 0.858614534042104190f, - -0.512621772783462990f, - 0.858516224264442740f, -0.512786400633562960f, 0.858417882921593930f, - -0.512951009629972980f, - 0.858319510017173440f, -0.513115599766640560f, 0.858221105554798250f, - -0.513280171037514220f, - 0.858122669538086140f, -0.513444723436543460f, 0.858024201970656540f, - -0.513609256957677780f, - 0.857925702856129790f, -0.513773771594868030f, 0.857827172198127430f, - -0.513938267342065380f, - 0.857728610000272120f, -0.514102744193221660f, 0.857630016266187620f, - -0.514267202142289710f, - 0.857531390999499150f, -0.514431641183222820f, 0.857432734203832700f, - -0.514596061309975040f, - 0.857334045882815590f, -0.514760462516501200f, 0.857235326040076460f, - -0.514924844796756490f, - 0.857136574679244980f, -0.515089208144697160f, 0.857037791803951680f, - -0.515253552554280180f, - 0.856938977417828760f, -0.515417878019462930f, 0.856840131524509220f, - -0.515582184534203790f, - 0.856741254127627470f, -0.515746472092461380f, 0.856642345230818840f, - -0.515910740688195650f, - 0.856543404837719960f, -0.516074990315366630f, 0.856444432951968590f, - -0.516239220967935510f, - 0.856345429577203610f, -0.516403432639863990f, 0.856246394717065210f, - -0.516567625325114350f, - 0.856147328375194470f, -0.516731799017649870f, 0.856048230555233940f, - -0.516895953711434150f, - 0.855949101260826910f, -0.517060089400431910f, 0.855849940495618240f, - -0.517224206078608310f, - 0.855750748263253920f, -0.517388303739929060f, 0.855651524567380690f, - -0.517552382378360880f, - 0.855552269411646860f, -0.517716441987871150f, 0.855452982799701830f, - -0.517880482562427690f, - 0.855353664735196030f, -0.518044504095999340f, 0.855254315221780970f, - -0.518208506582555460f, - 0.855154934263109620f, -0.518372490016066110f, 0.855055521862835950f, - -0.518536454390502220f, - 0.854956078024614930f, -0.518700399699834950f, 0.854856602752102850f, - -0.518864325938036890f, - 0.854757096048957220f, -0.519028233099080860f, 0.854657557918836460f, - -0.519192121176940250f, - 0.854557988365400530f, -0.519355990165589640f, 0.854458387392310170f, - -0.519519840059003760f, - 0.854358755003227440f, -0.519683670851158410f, 0.854259091201815530f, - -0.519847482536030190f, - 0.854159395991738850f, -0.520011275107596040f, 0.854059669376662780f, - -0.520175048559833760f, - 0.853959911360254180f, -0.520338802886721960f, 0.853860121946180770f, - -0.520502538082239670f, - 0.853760301138111410f, -0.520666254140367160f, 0.853660448939716380f, - -0.520829951055084670f, - 0.853560565354666840f, -0.520993628820373920f, 0.853460650386635320f, - -0.521157287430216610f, - 0.853360704039295430f, -0.521320926878595660f, 0.853260726316321880f, - -0.521484547159494330f, - 0.853160717221390420f, -0.521648148266897090f, 0.853060676758178320f, - -0.521811730194788550f, - 0.852960604930363630f, -0.521975292937154390f, 0.852860501741625750f, - -0.522138836487980760f, - 0.852760367195645300f, -0.522302360841254590f, 0.852660201296103760f, - -0.522465865990963780f, - 0.852560004046684080f, -0.522629351931096610f, 0.852459775451070100f, - -0.522792818655642090f, - 0.852359515512947090f, -0.522956266158590140f, 0.852259224236001090f, - -0.523119694433931250f, - 0.852158901623919830f, -0.523283103475656430f, 0.852058547680391690f, - -0.523446493277757830f, - 0.851958162409106380f, -0.523609863834227920f, 0.851857745813754840f, - -0.523773215139060170f, - 0.851757297898029120f, -0.523936547186248600f, 0.851656818665622370f, - -0.524099859969787700f, - 0.851556308120228980f, -0.524263153483673360f, 0.851455766265544310f, - -0.524426427721901400f, - 0.851355193105265200f, -0.524589682678468950f, 0.851254588643089120f, - -0.524752918347373360f, - 0.851153952882715340f, -0.524916134722613000f, 0.851053285827843790f, - -0.525079331798186780f, - 0.850952587482175730f, -0.525242509568094710f, 0.850851857849413530f, - -0.525405668026336930f, - 0.850751096933260790f, -0.525568807166914680f, 0.850650304737422090f, - -0.525731926983829760f, - 0.850549481265603480f, -0.525895027471084630f, 0.850448626521511760f, - -0.526058108622682760f, - 0.850347740508854980f, -0.526221170432628060f, 0.850246823231342710f, - -0.526384212894925100f, - 0.850145874692685210f, -0.526547236003579440f, 0.850044894896594180f, - -0.526710239752597010f, - 0.849943883846782210f, -0.526873224135984590f, 0.849842841546963320f, - -0.527036189147750080f, - 0.849741768000852550f, -0.527199134781901280f, 0.849640663212165910f, - -0.527362061032447540f, - 0.849539527184620890f, -0.527524967893398200f, 0.849438359921936060f, - -0.527687855358763720f, - 0.849337161427830780f, -0.527850723422555230f, 0.849235931706025960f, - -0.528013572078784630f, - 0.849134670760243630f, -0.528176401321464370f, 0.849033378594206800f, - -0.528339211144607690f, - 0.848932055211639610f, -0.528502001542228480f, 0.848830700616267530f, - -0.528664772508341320f, - 0.848729314811817130f, -0.528827524036961870f, 0.848627897802015860f, - -0.528990256122106040f, - 0.848526449590592650f, -0.529152968757790610f, 0.848424970181277600f, - -0.529315661938033260f, - 0.848323459577801640f, -0.529478335656851980f, 0.848221917783896990f, - -0.529640989908265910f, - 0.848120344803297230f, -0.529803624686294610f, 0.848018740639736810f, - -0.529966239984958620f, - 0.847917105296951410f, -0.530128835798278960f, 0.847815438778677930f, - -0.530291412120277310f, - 0.847713741088654380f, -0.530453968944976320f, 0.847612012230619660f, - -0.530616506266399330f, - 0.847510252208314330f, -0.530779024078570140f, 0.847408461025479730f, - -0.530941522375513620f, - 0.847306638685858320f, -0.531104001151255000f, 0.847204785193194090f, - -0.531266460399820390f, - 0.847102900551231500f, -0.531428900115236800f, 0.847000984763716880f, - -0.531591320291531670f, - 0.846899037834397240f, -0.531753720922733320f, 0.846797059767020910f, - -0.531916102002870650f, - 0.846695050565337450f, -0.532078463525973540f, 0.846593010233097190f, - -0.532240805486072220f, - 0.846490938774052130f, -0.532403127877197900f, 0.846388836191954930f, - -0.532565430693382580f, - 0.846286702490559710f, -0.532727713928658810f, 0.846184537673621560f, - -0.532889977577059800f, - 0.846082341744897050f, -0.533052221632619450f, 0.845980114708143270f, - -0.533214446089372960f, - 0.845877856567119000f, -0.533376650941355330f, 0.845775567325584010f, - -0.533538836182603120f, - 0.845673246987299070f, -0.533701001807152960f, 0.845570895556026270f, - -0.533863147809042650f, - 0.845468513035528830f, -0.534025274182310380f, 0.845366099429570970f, - -0.534187380920995380f, - 0.845263654741918220f, -0.534349468019137520f, 0.845161178976337140f, - -0.534511535470777120f, - 0.845058672136595470f, -0.534673583269955510f, 0.844956134226462210f, - -0.534835611410714560f, - 0.844853565249707120f, -0.534997619887097150f, 0.844750965210101510f, - -0.535159608693146600f, - 0.844648334111417820f, -0.535321577822907120f, 0.844545671957429240f, - -0.535483527270423370f, - 0.844442978751910660f, -0.535645457029741090f, 0.844340254498637590f, - -0.535807367094906390f, - 0.844237499201387020f, -0.535969257459966710f, 0.844134712863936930f, - -0.536131128118969460f, - 0.844031895490066410f, -0.536292979065963180f, 0.843929047083555870f, - -0.536454810294997090f, - 0.843826167648186740f, -0.536616621800121040f, 0.843723257187741660f, - -0.536778413575385920f, - 0.843620315706004150f, -0.536940185614842910f, 0.843517343206759200f, - -0.537101937912544130f, - 0.843414339693792760f, -0.537263670462542530f, 0.843311305170892140f, - -0.537425383258891550f, - 0.843208239641845440f, -0.537587076295645390f, 0.843105143110442160f, - -0.537748749566859360f, - 0.843002015580472940f, -0.537910403066588880f, 0.842898857055729310f, - -0.538072036788890600f, - 0.842795667540004120f, -0.538233650727821700f, 0.842692447037091670f, - -0.538395244877439950f, - 0.842589195550786710f, -0.538556819231804100f, 0.842485913084885630f, - -0.538718373784973560f, - 0.842382599643185850f, -0.538879908531008420f, 0.842279255229485990f, - -0.539041423463969440f, - 0.842175879847585570f, -0.539202918577918240f, 0.842072473501285560f, - -0.539364393866917040f, - 0.841969036194387680f, -0.539525849325028890f, 0.841865567930695340f, - -0.539687284946317570f, - 0.841762068714012490f, -0.539848700724847590f, 0.841658538548144760f, - -0.540010096654684020f, - 0.841554977436898440f, -0.540171472729892850f, 0.841451385384081260f, - -0.540332828944540710f, - 0.841347762393501950f, -0.540494165292695230f, 0.841244108468970580f, - -0.540655481768424150f, - 0.841140423614298080f, -0.540816778365796670f, 0.841036707833296650f, - -0.540978055078882080f, - 0.840932961129779780f, -0.541139311901750800f, 0.840829183507561640f, - -0.541300548828474120f, - 0.840725374970458070f, -0.541461765853123440f, 0.840621535522285690f, - -0.541622962969771530f, - 0.840517665166862550f, -0.541784140172491550f, 0.840413763908007480f, - -0.541945297455357360f, - 0.840309831749540770f, -0.542106434812443920f, 0.840205868695283580f, - -0.542267552237826520f, - 0.840101874749058400f, -0.542428649725581250f, 0.839997849914688840f, - -0.542589727269785270f, - 0.839893794195999520f, -0.542750784864515890f, 0.839789707596816370f, - -0.542911822503851730f, - 0.839685590120966110f, -0.543072840181871740f, 0.839581441772277120f, - -0.543233837892655890f, - 0.839477262554578550f, -0.543394815630284800f, 0.839373052471700690f, - -0.543555773388839540f, - 0.839268811527475230f, -0.543716711162402280f, 0.839164539725734680f, - -0.543877628945055980f, - 0.839060237070312740f, -0.544038526730883820f, 0.838955903565044460f, - -0.544199404513970310f, - 0.838851539213765760f, -0.544360262288400400f, 0.838747144020313920f, - -0.544521100048259600f, - 0.838642717988527300f, -0.544681917787634530f, 0.838538261122245280f, - -0.544842715500612360f, - 0.838433773425308340f, -0.545003493181281160f, 0.838329254901558300f, - -0.545164250823729320f, - 0.838224705554838080f, -0.545324988422046460f, 0.838120125388991500f, - -0.545485705970322530f, - 0.838015514407863820f, -0.545646403462648590f, 0.837910872615301170f, - -0.545807080893116140f, - 0.837806200015150940f, -0.545967738255817570f, 0.837701496611261700f, - -0.546128375544845950f, - 0.837596762407483040f, -0.546288992754295210f, 0.837491997407665890f, - -0.546449589878259650f, - 0.837387201615661940f, -0.546610166910834860f, 0.837282375035324320f, - -0.546770723846116800f, - 0.837177517670507300f, -0.546931260678202190f, 0.837072629525066000f, - -0.547091777401188530f, - 0.836967710602857020f, -0.547252274009174090f, 0.836862760907737920f, - -0.547412750496257930f, - 0.836757780443567190f, -0.547573206856539760f, 0.836652769214204950f, - -0.547733643084120090f, - 0.836547727223512010f, -0.547894059173100190f, 0.836442654475350380f, - -0.548054455117581880f, - 0.836337550973583530f, -0.548214830911667780f, 0.836232416722075600f, - -0.548375186549461600f, - 0.836127251724692270f, -0.548535522025067390f, 0.836022055985299880f, - -0.548695837332590090f, - 0.835916829507766360f, -0.548856132466135290f, 0.835811572295960700f, - -0.549016407419809390f, - 0.835706284353752600f, -0.549176662187719660f, 0.835600965685013410f, - -0.549336896763974010f, - 0.835495616293615350f, -0.549497111142680960f, 0.835390236183431890f, - -0.549657305317949870f, - 0.835284825358337370f, -0.549817479283890910f, 0.835179383822207690f, - -0.549977633034614890f, - 0.835073911578919410f, -0.550137766564233630f, 0.834968408632350450f, - -0.550297879866859190f, - 0.834862874986380010f, -0.550457972936604810f, 0.834757310644888230f, - -0.550618045767584330f, - 0.834651715611756440f, -0.550778098353912120f, 0.834546089890866870f, - -0.550938130689703880f, - 0.834440433486103190f, -0.551098142769075430f, 0.834334746401350080f, - -0.551258134586143590f, - 0.834229028640493420f, -0.551418106135026060f, 0.834123280207420100f, - -0.551578057409841000f, - 0.834017501106018130f, -0.551737988404707340f, 0.833911691340176840f, - -0.551897899113745210f, - 0.833805850913786340f, -0.552057789531074980f, 0.833699979830738290f, - -0.552217659650817930f, - 0.833594078094925140f, -0.552377509467096070f, 0.833488145710240770f, - -0.552537338974032120f, - 0.833382182680579730f, -0.552697148165749770f, 0.833276189009838240f, - -0.552856937036373290f, - 0.833170164701913190f, -0.553016705580027470f, 0.833064109760702890f, - -0.553176453790838350f, - 0.832958024190106670f, -0.553336181662932300f, 0.832851907994025090f, - -0.553495889190436570f, - 0.832745761176359460f, -0.553655576367479310f, 0.832639583741012770f, - -0.553815243188189090f, - 0.832533375691888680f, -0.553974889646695500f, 0.832427137032892280f, - -0.554134515737128910f, - 0.832320867767929680f, -0.554294121453620000f, 0.832214567900907980f, - -0.554453706790300930f, - 0.832108237435735590f, -0.554613271741304040f, 0.832001876376321950f, - -0.554772816300762470f, - 0.831895484726577590f, -0.554932340462810370f, 0.831789062490414400f, - -0.555091844221582420f, - 0.831682609671745120f, -0.555251327571213980f, 0.831576126274483740f, - -0.555410790505841630f, - 0.831469612302545240f, -0.555570233019602180f, 0.831363067759845920f, - -0.555729655106633410f, - 0.831256492650303210f, -0.555889056761073810f, 0.831149886977835540f, - -0.556048437977062600f, - 0.831043250746362320f, -0.556207798748739930f, 0.830936583959804410f, - -0.556367139070246370f, - 0.830829886622083570f, -0.556526458935723610f, 0.830723158737122880f, - -0.556685758339313890f, - 0.830616400308846310f, -0.556845037275160100f, 0.830509611341179070f, - -0.557004295737405950f, - 0.830402791838047550f, -0.557163533720196220f, 0.830295941803379070f, - -0.557322751217676160f, - 0.830189061241102370f, -0.557481948223991550f, 0.830082150155146970f, - -0.557641124733289420f, - 0.829975208549443950f, -0.557800280739716990f, 0.829868236427924840f, - -0.557959416237422960f, - 0.829761233794523050f, -0.558118531220556100f, 0.829654200653172640f, - -0.558277625683266330f, - 0.829547137007808910f, -0.558436699619704100f, 0.829440042862368170f, - -0.558595753024020760f, - 0.829332918220788250f, -0.558754785890368310f, 0.829225763087007570f, - -0.558913798212899770f, - 0.829118577464965980f, -0.559072789985768480f, 0.829011361358604430f, - -0.559231761203128900f, - 0.828904114771864870f, -0.559390711859136140f, 0.828796837708690610f, - -0.559549641947945760f, - 0.828689530173025820f, -0.559708551463714680f, 0.828582192168815790f, - -0.559867440400600210f, - 0.828474823700007130f, -0.560026308752760380f, 0.828367424770547480f, - -0.560185156514354080f, - 0.828259995384385660f, -0.560343983679540860f, 0.828152535545471410f, - -0.560502790242481060f, - 0.828045045257755800f, -0.560661576197336030f, 0.827937524525190870f, - -0.560820341538267430f, - 0.827829973351729920f, -0.560979086259438150f, 0.827722391741327220f, - -0.561137810355011420f, - 0.827614779697938400f, -0.561296513819151470f, 0.827507137225519830f, - -0.561455196646023280f, - 0.827399464328029470f, -0.561613858829792420f, 0.827291761009425810f, - -0.561772500364625340f, - 0.827184027273669130f, -0.561931121244689470f, 0.827076263124720270f, - -0.562089721464152480f, - 0.826968468566541600f, -0.562248301017183150f, 0.826860643603096190f, - -0.562406859897951140f, - 0.826752788238348520f, -0.562565398100626560f, 0.826644902476264320f, - -0.562723915619380400f, - 0.826536986320809960f, -0.562882412448384440f, 0.826429039775953500f, - -0.563040888581811230f, - 0.826321062845663530f, -0.563199344013834090f, 0.826213055533910220f, - -0.563357778738627020f, - 0.826105017844664610f, -0.563516192750364800f, 0.825996949781899080f, - -0.563674586043223070f, - 0.825888851349586780f, -0.563832958611378170f, 0.825780722551702430f, - -0.563991310449006970f, - 0.825672563392221390f, -0.564149641550287680f, 0.825564373875120490f, - -0.564307951909398640f, - 0.825456154004377550f, -0.564466241520519500f, 0.825347903783971380f, - -0.564624510377830120f, - 0.825239623217882250f, -0.564782758475511400f, 0.825131312310091070f, - -0.564940985807745210f, - 0.825022971064580220f, -0.565099192368713980f, 0.824914599485333190f, - -0.565257378152600800f, - 0.824806197576334330f, -0.565415543153589660f, 0.824697765341569470f, - -0.565573687365865330f, - 0.824589302785025290f, -0.565731810783613120f, 0.824480809910689500f, - -0.565889913401019570f, - 0.824372286722551250f, -0.566047995212271450f, 0.824263733224600560f, - -0.566206056211556730f, - 0.824155149420828570f, -0.566364096393063840f, 0.824046535315227760f, - -0.566522115750982100f, - 0.823937890911791370f, -0.566680114279501600f, 0.823829216214513990f, - -0.566838091972813320f, - 0.823720511227391430f, -0.566996048825108680f, 0.823611775954420260f, - -0.567153984830580100f, - 0.823503010399598500f, -0.567311899983420800f, 0.823394214566925080f, - -0.567469794277824510f, - 0.823285388460400110f, -0.567627667707986230f, 0.823176532084024860f, - -0.567785520268101140f, - 0.823067645441801670f, -0.567943351952365560f, 0.822958728537734000f, - -0.568101162754976460f, - 0.822849781375826430f, -0.568258952670131490f, 0.822740803960084420f, - -0.568416721692029280f, - 0.822631796294514990f, -0.568574469814869140f, 0.822522758383125940f, - -0.568732197032851050f, - 0.822413690229926390f, -0.568889903340175860f, 0.822304591838926350f, - -0.569047588731045110f, - 0.822195463214137170f, -0.569205253199661200f, 0.822086304359571090f, - -0.569362896740227220f, - 0.821977115279241550f, -0.569520519346947140f, 0.821867895977163250f, - -0.569678121014025600f, - 0.821758646457351750f, -0.569835701735668000f, 0.821649366723823940f, - -0.569993261506080540f, - 0.821540056780597610f, -0.570150800319470300f, 0.821430716631691870f, - -0.570308318170044900f, - 0.821321346281126740f, -0.570465815052012990f, 0.821211945732923550f, - -0.570623290959583750f, - 0.821102514991104650f, -0.570780745886967260f, 0.820993054059693580f, - -0.570938179828374360f, - 0.820883562942714580f, -0.571095592778016690f, 0.820774041644193650f, - -0.571252984730106660f, - 0.820664490168157460f, -0.571410355678857230f, 0.820554908518633890f, - -0.571567705618482580f, - 0.820445296699652050f, -0.571725034543197120f, 0.820335654715241840f, - -0.571882342447216590f, - 0.820225982569434690f, -0.572039629324757050f, 0.820116280266262820f, - -0.572196895170035580f, - 0.820006547809759680f, -0.572354139977269920f, 0.819896785203959810f, - -0.572511363740678790f, - 0.819786992452898990f, -0.572668566454481160f, 0.819677169560613870f, - -0.572825748112897550f, - 0.819567316531142230f, -0.572982908710148560f, 0.819457433368523280f, - -0.573140048240455950f, - 0.819347520076796900f, -0.573297166698042200f, 0.819237576660004520f, - -0.573454264077130400f, - 0.819127603122188240f, -0.573611340371944610f, 0.819017599467391500f, - -0.573768395576709560f, - 0.818907565699658950f, -0.573925429685650750f, 0.818797501823036010f, - -0.574082442692994470f, - 0.818687407841569680f, -0.574239434592967890f, 0.818577283759307610f, - -0.574396405379798750f, - 0.818467129580298660f, -0.574553355047715760f, 0.818356945308593150f, - -0.574710283590948330f, - 0.818246730948242070f, -0.574867191003726740f, 0.818136486503297730f, - -0.575024077280281710f, - 0.818026211977813440f, -0.575180942414845080f, 0.817915907375843850f, - -0.575337786401649450f, - 0.817805572701444270f, -0.575494609234928120f, 0.817695207958671680f, - -0.575651410908915140f, - 0.817584813151583710f, -0.575808191417845340f, 0.817474388284239240f, - -0.575964950755954220f, - 0.817363933360698460f, -0.576121688917478280f, 0.817253448385022340f, - -0.576278405896654910f, - 0.817142933361272970f, -0.576435101687721830f, 0.817032388293513880f, - -0.576591776284917760f, - 0.816921813185809480f, -0.576748429682482410f, 0.816811208042225290f, - -0.576905061874655960f, - 0.816700572866827850f, -0.577061672855679440f, 0.816589907663684890f, - -0.577218262619794920f, - 0.816479212436865390f, -0.577374831161244880f, 0.816368487190439200f, - -0.577531378474272720f, - 0.816257731928477390f, -0.577687904553122800f, 0.816146946655052270f, - -0.577844409392039850f, - 0.816036131374236810f, -0.578000892985269910f, 0.815925286090105510f, - -0.578157355327059360f, - 0.815814410806733780f, -0.578313796411655590f, 0.815703505528198260f, - -0.578470216233306630f, - 0.815592570258576790f, -0.578626614786261430f, 0.815481605001947770f, - -0.578782992064769690f, - 0.815370609762391290f, -0.578939348063081780f, 0.815259584543988280f, - -0.579095682775449090f, - 0.815148529350820830f, -0.579251996196123550f, 0.815037444186972220f, - -0.579408288319357870f, - 0.814926329056526620f, -0.579564559139405630f, 0.814815183963569440f, - -0.579720808650521450f, - 0.814704008912187080f, -0.579877036846960350f, 0.814592803906467270f, - -0.580033243722978150f, - 0.814481568950498610f, -0.580189429272831680f, 0.814370304048371070f, - -0.580345593490778300f, - 0.814259009204175270f, -0.580501736371076490f, 0.814147684422003360f, - -0.580657857907985300f, - 0.814036329705948410f, -0.580813958095764530f, 0.813924945060104600f, - -0.580970036928674770f, - 0.813813530488567190f, -0.581126094400977620f, 0.813702085995432700f, - -0.581282130506935000f, - 0.813590611584798510f, -0.581438145240810170f, 0.813479107260763220f, - -0.581594138596866930f, - 0.813367573027426570f, -0.581750110569369650f, 0.813256008888889380f, - -0.581906061152583810f, - 0.813144414849253590f, -0.582061990340775440f, 0.813032790912622040f, - -0.582217898128211670f, - 0.812921137083098770f, -0.582373784509160110f, 0.812809453364789270f, - -0.582529649477889320f, - 0.812697739761799490f, -0.582685493028668460f, 0.812585996278237130f, - -0.582841315155767650f, - 0.812474222918210480f, -0.582997115853457700f, 0.812362419685829230f, - -0.583152895116010430f, - 0.812250586585203880f, -0.583308652937698290f, 0.812138723620446480f, - -0.583464389312794320f, - 0.812026830795669730f, -0.583620104235572760f, 0.811914908114987790f, - -0.583775797700308070f, - 0.811802955582515470f, -0.583931469701276180f, 0.811690973202369050f, - -0.584087120232753440f, - 0.811578960978665890f, -0.584242749289016980f, 0.811466918915524250f, - -0.584398356864344600f, - 0.811354847017063730f, -0.584553942953015330f, 0.811242745287404810f, - -0.584709507549308390f, - 0.811130613730669190f, -0.584865050647504490f, 0.811018452350979470f, - -0.585020572241884530f, - 0.810906261152459670f, -0.585176072326730410f, 0.810794040139234730f, - -0.585331550896324940f, - 0.810681789315430780f, -0.585487007944951340f, 0.810569508685174630f, - -0.585642443466894420f, - 0.810457198252594770f, -0.585797857456438860f, 0.810344858021820550f, - -0.585953249907870570f, - 0.810232487996982330f, -0.586108620815476430f, 0.810120088182211600f, - -0.586263970173543590f, - 0.810007658581641140f, -0.586419297976360500f, 0.809895199199404450f, - -0.586574604218216170f, - 0.809782710039636530f, -0.586729888893400390f, 0.809670191106473090f, - -0.586885151996203950f, - 0.809557642404051260f, -0.587040393520917970f, 0.809445063936509170f, - -0.587195613461834800f, - 0.809332455707985950f, -0.587350811813247660f, 0.809219817722621750f, - -0.587505988569450020f, - 0.809107149984558240f, -0.587661143724736660f, 0.808994452497937670f, - -0.587816277273402910f, - 0.808881725266903610f, -0.587971389209745010f, 0.808768968295600850f, - -0.588126479528059850f, - 0.808656181588174980f, -0.588281548222645220f, 0.808543365148773010f, - -0.588436595287799790f, - 0.808430518981542720f, -0.588591620717822890f, 0.808317643090633250f, - -0.588746624507014540f, - 0.808204737480194720f, -0.588901606649675720f, 0.808091802154378370f, - -0.589056567140108460f, - 0.807978837117336310f, -0.589211505972614960f, 0.807865842373222120f, - -0.589366423141498790f, - 0.807752817926190360f, -0.589521318641063940f, 0.807639763780396480f, - -0.589676192465615420f, - 0.807526679939997160f, -0.589831044609458790f, 0.807413566409150190f, - -0.589985875066900920f, - 0.807300423192014450f, -0.590140683832248820f, 0.807187250292749960f, - -0.590295470899810830f, - 0.807074047715517610f, -0.590450236263895810f, 0.806960815464479730f, - -0.590604979918813330f, - 0.806847553543799330f, -0.590759701858874160f, 0.806734261957640860f, - -0.590914402078389520f, - 0.806620940710169650f, -0.591069080571671400f, 0.806507589805552260f, - -0.591223737333032910f, - 0.806394209247956240f, -0.591378372356787580f, 0.806280799041550480f, - -0.591532985637249990f, - 0.806167359190504420f, -0.591687577168735430f, 0.806053889698989060f, - -0.591842146945560140f, - 0.805940390571176280f, -0.591996694962040990f, 0.805826861811239300f, - -0.592151221212495530f, - 0.805713303423352230f, -0.592305725691242290f, 0.805599715411690060f, - -0.592460208392600830f, - 0.805486097780429230f, -0.592614669310891130f, 0.805372450533747060f, - -0.592769108440434070f, - 0.805258773675822210f, -0.592923525775551300f, 0.805145067210834230f, - -0.593077921310565470f, - 0.805031331142963660f, -0.593232295039799800f, 0.804917565476392260f, - -0.593386646957578480f, - 0.804803770215302920f, -0.593540977058226390f, 0.804689945363879500f, - -0.593695285336069190f, - 0.804576090926307110f, -0.593849571785433630f, 0.804462206906771840f, - -0.594003836400646690f, - 0.804348293309460780f, -0.594158079176036800f, 0.804234350138562260f, - -0.594312300105932830f, - 0.804120377398265810f, -0.594466499184664430f, 0.804006375092761520f, - -0.594620676406562240f, - 0.803892343226241260f, -0.594774831765957580f, 0.803778281802897570f, - -0.594928965257182420f, - 0.803664190826924090f, -0.595083076874569960f, 0.803550070302515680f, - -0.595237166612453850f, - 0.803435920233868120f, -0.595391234465168730f, 0.803321740625178580f, - -0.595545280427049790f, - 0.803207531480644940f, -0.595699304492433360f, 0.803093292804466400f, - -0.595853306655656280f, - 0.802979024600843250f, -0.596007286911056530f, 0.802864726873976700f, - -0.596161245252972540f, - 0.802750399628069160f, -0.596315181675743710f, 0.802636042867324150f, - -0.596469096173710360f, - 0.802521656595946430f, -0.596622988741213220f, 0.802407240818141300f, - -0.596776859372594390f, - 0.802292795538115720f, -0.596930708062196500f, 0.802178320760077450f, - -0.597084534804362740f, - 0.802063816488235440f, -0.597238339593437420f, 0.801949282726799770f, - -0.597392122423765710f, - 0.801834719479981310f, -0.597545883289693160f, 0.801720126751992330f, - -0.597699622185566830f, - 0.801605504547046150f, -0.597853339105733910f, 0.801490852869356950f, - -0.598007034044542700f, - 0.801376171723140240f, -0.598160706996342270f, 0.801261461112612540f, - -0.598314357955482600f, - 0.801146721041991360f, -0.598467986916314310f, 0.801031951515495330f, - -0.598621593873188920f, - 0.800917152537344300f, -0.598775178820458720f, 0.800802324111759110f, - -0.598928741752476900f, - 0.800687466242961610f, -0.599082282663597310f, 0.800572578935174860f, - -0.599235801548174570f, - 0.800457662192622820f, -0.599389298400564540f, 0.800342716019530660f, - -0.599542773215123390f, - 0.800227740420124790f, -0.599696225986208310f, 0.800112735398632370f, - -0.599849656708177250f, - 0.799997700959281910f, -0.600003065375388940f, 0.799882637106302810f, - -0.600156451982203240f, - 0.799767543843925680f, -0.600309816522980430f, 0.799652421176382240f, - -0.600463158992081580f, - 0.799537269107905010f, -0.600616479383868970f, 0.799422087642728040f, - -0.600769777692705230f, - 0.799306876785086160f, -0.600923053912954090f, 0.799191636539215210f, - -0.601076308038980160f, - 0.799076366909352350f, -0.601229540065148500f, 0.798961067899735760f, - -0.601382749985825420f, - 0.798845739514604580f, -0.601535937795377730f, 0.798730381758199210f, - -0.601689103488172950f, - 0.798614994634760820f, -0.601842247058580030f, 0.798499578148532120f, - -0.601995368500968020f, - 0.798384132303756380f, -0.602148467809707210f, 0.798268657104678430f, - -0.602301544979168550f, - 0.798153152555543750f, -0.602454600003723750f, 0.798037618660599410f, - -0.602607632877745440f, - 0.797922055424093000f, -0.602760643595607220f, 0.797806462850273570f, - -0.602913632151683030f, - 0.797690840943391160f, -0.603066598540348160f, 0.797575189707696700f, - -0.603219542755978440f, - 0.797459509147442460f, -0.603372464792950260f, 0.797343799266881700f, - -0.603525364645641550f, - 0.797228060070268700f, -0.603678242308430370f, 0.797112291561858920f, - -0.603831097775695880f, - 0.796996493745908750f, -0.603983931041818020f, 0.796880666626675780f, - -0.604136742101177520f, - 0.796764810208418830f, -0.604289530948155960f, 0.796648924495397260f, - -0.604442297577135860f, - 0.796533009491872000f, -0.604595041982500360f, 0.796417065202104980f, - -0.604747764158633410f, - 0.796301091630359110f, -0.604900464099919820f, 0.796185088780898440f, - -0.605053141800745320f, - 0.796069056657987990f, -0.605205797255496500f, 0.795952995265893910f, - -0.605358430458560530f, - 0.795836904608883570f, -0.605511041404325550f, 0.795720784691225090f, - -0.605663630087180380f, - 0.795604635517188070f, -0.605816196501514970f, 0.795488457091042990f, - -0.605968740641719680f, - 0.795372249417061310f, -0.606121262502186120f, 0.795256012499515610f, - -0.606273762077306430f, - 0.795139746342679590f, -0.606426239361473550f, 0.795023450950828050f, - -0.606578694349081290f, - 0.794907126328237010f, -0.606731127034524480f, 0.794790772479183170f, - -0.606883537412198470f, - 0.794674389407944550f, -0.607035925476499650f, 0.794557977118800380f, - -0.607188291221825160f, - 0.794441535616030590f, -0.607340634642572930f, 0.794325064903916520f, - -0.607492955733141550f, - 0.794208564986740640f, -0.607645254487930830f, 0.794092035868785960f, - -0.607797530901341140f, - 0.793975477554337170f, -0.607949784967773630f, 0.793858890047679730f, - -0.608102016681630440f, - 0.793742273353100210f, -0.608254226037314490f, 0.793625627474886300f, - -0.608406413029229150f, - 0.793508952417326660f, -0.608558577651779450f, 0.793392248184711100f, - -0.608710719899370310f, - 0.793275514781330630f, -0.608862839766408200f, 0.793158752211477140f, - -0.609014937247299830f, - 0.793041960479443640f, -0.609167012336453210f, 0.792925139589524260f, - -0.609319065028276820f, - 0.792808289546014120f, -0.609471095317180240f, 0.792691410353209450f, - -0.609623103197573730f, - 0.792574502015407690f, -0.609775088663868430f, 0.792457564536907080f, - -0.609927051710476120f, - 0.792340597922007170f, -0.610078992331809620f, 0.792223602175008310f, - -0.610230910522282620f, - 0.792106577300212390f, -0.610382806276309480f, 0.791989523301921850f, - -0.610534679588305320f, - 0.791872440184440470f, -0.610686530452686280f, 0.791755327952073150f, - -0.610838358863869170f, - 0.791638186609125880f, -0.610990164816271660f, 0.791521016159905220f, - -0.611141948304312570f, - 0.791403816608719500f, -0.611293709322410890f, 0.791286587959877830f, - -0.611445447864987000f, - 0.791169330217690200f, -0.611597163926461910f, 0.791052043386467950f, - -0.611748857501257290f, - 0.790934727470523290f, -0.611900528583796070f, 0.790817382474169770f, - -0.612052177168501470f, - 0.790700008401721610f, -0.612203803249797950f, 0.790582605257494460f, - -0.612355406822110650f, - 0.790465173045804880f, -0.612506987879865570f, 0.790347711770970520f, - -0.612658546417489290f, - 0.790230221437310030f, -0.612810082429409710f, 0.790112702049143300f, - -0.612961595910055170f, - 0.789995153610791090f, -0.613113086853854910f, 0.789877576126575280f, - -0.613264555255239040f, - 0.789759969600819070f, -0.613416001108638590f, 0.789642334037846340f, - -0.613567424408485330f, - 0.789524669441982190f, -0.613718825149211720f, 0.789406975817552930f, - -0.613870203325251330f, - 0.789289253168885650f, -0.614021558931038380f, 0.789171501500308900f, - -0.614172891961007990f, - 0.789053720816151880f, -0.614324202409595950f, 0.788935911120745240f, - -0.614475490271239040f, - 0.788818072418420280f, -0.614626755540375050f, 0.788700204713509660f, - -0.614777998211442080f, - 0.788582308010347120f, -0.614929218278879590f, 0.788464382313267540f, - -0.615080415737127460f, - 0.788346427626606340f, -0.615231590580626820f, 0.788228443954700490f, - -0.615382742803819220f, - 0.788110431301888070f, -0.615533872401147320f, 0.787992389672507950f, - -0.615684979367054570f, - 0.787874319070900220f, -0.615836063695985090f, 0.787756219501406060f, - -0.615987125382383760f, - 0.787638090968367450f, -0.616138164420696910f, 0.787519933476127810f, - -0.616289180805370980f, - 0.787401747029031430f, -0.616440174530853650f, 0.787283531631423620f, - -0.616591145591593110f, - 0.787165287287651010f, -0.616742093982038720f, 0.787047014002060790f, - -0.616893019696640680f, - 0.786928711779001810f, -0.617043922729849760f, 0.786810380622823490f, - -0.617194803076117630f, - 0.786692020537876790f, -0.617345660729896830f, 0.786573631528513230f, - -0.617496495685640910f, - 0.786455213599085770f, -0.617647307937803870f, 0.786336766753948260f, - -0.617798097480841020f, - 0.786218290997455660f, -0.617948864309208150f, 0.786099786333963930f, - -0.618099608417362000f, - 0.785981252767830150f, -0.618250329799760250f, 0.785862690303412600f, - -0.618401028450860980f, - 0.785744098945070360f, -0.618551704365123740f, 0.785625478697163700f, - -0.618702357537008530f, - 0.785506829564053930f, -0.618852987960976320f, 0.785388151550103550f, - -0.619003595631488660f, - 0.785269444659675850f, -0.619154180543008410f, 0.785150708897135560f, - -0.619304742689998690f, - 0.785031944266848080f, -0.619455282066924020f, 0.784913150773180020f, - -0.619605798668249270f, - 0.784794328420499230f, -0.619756292488440660f, 0.784675477213174320f, - -0.619906763521964720f, - 0.784556597155575240f, -0.620057211763289100f, 0.784437688252072830f, - -0.620207637206882430f, - 0.784318750507038920f, -0.620358039847213720f, 0.784199783924846570f, - -0.620508419678753360f, - 0.784080788509869950f, -0.620658776695972140f, 0.783961764266484120f, - -0.620809110893341900f, - 0.783842711199065230f, -0.620959422265335180f, 0.783723629311990470f, - -0.621109710806425630f, - 0.783604518609638200f, -0.621259976511087550f, 0.783485379096387820f, - -0.621410219373796150f, - 0.783366210776619720f, -0.621560439389027160f, 0.783247013654715380f, - -0.621710636551257690f, - 0.783127787735057310f, -0.621860810854965360f, 0.783008533022029110f, - -0.622010962294628600f, - 0.782889249520015480f, -0.622161090864726820f, 0.782769937233402050f, - -0.622311196559740320f, - 0.782650596166575730f, -0.622461279374149970f, 0.782531226323924240f, - -0.622611339302437730f, - 0.782411827709836530f, -0.622761376339086350f, 0.782292400328702400f, - -0.622911390478579460f, - 0.782172944184913010f, -0.623061381715401260f, 0.782053459282860300f, - -0.623211350044037270f, - 0.781933945626937630f, -0.623361295458973230f, 0.781814403221538830f, - -0.623511217954696440f, - 0.781694832071059390f, -0.623661117525694530f, 0.781575232179895550f, - -0.623810994166456130f, - 0.781455603552444590f, -0.623960847871470660f, 0.781335946193104870f, - -0.624110678635228510f, - 0.781216260106276090f, -0.624260486452220650f, 0.781096545296358520f, - -0.624410271316939270f, - 0.780976801767753750f, -0.624560033223877210f, 0.780857029524864580f, - -0.624709772167528100f, - 0.780737228572094490f, -0.624859488142386340f, 0.780617398913848400f, - -0.625009181142947460f, - 0.780497540554531910f, -0.625158851163707620f, 0.780377653498552040f, - -0.625308498199164010f, - 0.780257737750316590f, -0.625458122243814360f, 0.780137793314234610f, - -0.625607723292157410f, - 0.780017820194715990f, -0.625757301338692900f, 0.779897818396172000f, - -0.625906856377921090f, - 0.779777787923014550f, -0.626056388404343520f, 0.779657728779656890f, - -0.626205897412462130f, - 0.779537640970513260f, -0.626355383396779990f, 0.779417524499998900f, - -0.626504846351800810f, - 0.779297379372530300f, -0.626654286272029350f, 0.779177205592524680f, - -0.626803703151971200f, - 0.779057003164400630f, -0.626953096986132660f, 0.778936772092577500f, - -0.627102467769020900f, - 0.778816512381475980f, -0.627251815495144080f, 0.778696224035517530f, - -0.627401140159011050f, - 0.778575907059125050f, -0.627550441755131530f, 0.778455561456721900f, - -0.627699720278016240f, - 0.778335187232733210f, -0.627848975722176460f, 0.778214784391584540f, - -0.627998208082124700f, - 0.778094352937702790f, -0.628147417352374000f, 0.777973892875516100f, - -0.628296603527438320f, - 0.777853404209453150f, -0.628445766601832710f, 0.777732886943944050f, - -0.628594906570072550f, - 0.777612341083420030f, -0.628744023426674680f, 0.777491766632313010f, - -0.628893117166156480f, - 0.777371163595056310f, -0.629042187783036000f, 0.777250531976084070f, - -0.629191235271832290f, - 0.777129871779831620f, -0.629340259627065630f, 0.777009183010735290f, - -0.629489260843256630f, - 0.776888465673232440f, -0.629638238914926980f, 0.776767719771761510f, - -0.629787193836599200f, - 0.776646945310762060f, -0.629936125602796440f, 0.776526142294674430f, - -0.630085034208043180f, - 0.776405310727940390f, -0.630233919646864370f, 0.776284450615002510f, - -0.630382781913785940f, - 0.776163561960304340f, -0.630531621003334600f, 0.776042644768290770f, - -0.630680436910037940f, - 0.775921699043407690f, -0.630829229628424470f, 0.775800724790101650f, - -0.630977999153023550f, - 0.775679722012820650f, -0.631126745478365340f, 0.775558690716013580f, - -0.631275468598980760f, - 0.775437630904130540f, -0.631424168509401860f, 0.775316542581622530f, - -0.631572845204161020f, - 0.775195425752941420f, -0.631721498677792260f, 0.775074280422540450f, - -0.631870128924829850f, - 0.774953106594873930f, -0.632018735939809060f, 0.774831904274396850f, - -0.632167319717265920f, - 0.774710673465565550f, -0.632315880251737570f, 0.774589414172837550f, - -0.632464417537761840f, - 0.774468126400670860f, -0.632612931569877410f, 0.774346810153525130f, - -0.632761422342624000f, - 0.774225465435860680f, -0.632909889850541750f, 0.774104092252139050f, - -0.633058334088172140f, - 0.773982690606822900f, -0.633206755050057190f, 0.773861260504375540f, - -0.633355152730739950f, - 0.773739801949261840f, -0.633503527124764320f, 0.773618314945947460f, - -0.633651878226674900f, - 0.773496799498899050f, -0.633800206031017280f, 0.773375255612584470f, - -0.633948510532337810f, - 0.773253683291472590f, -0.634096791725183740f, 0.773132082540033070f, - -0.634245049604103330f, - 0.773010453362736990f, -0.634393284163645490f, 0.772888795764056220f, - -0.634541495398360020f, - 0.772767109748463850f, -0.634689683302797740f, 0.772645395320433860f, - -0.634837847871509990f, - 0.772523652484441330f, -0.634985989099049460f, 0.772401881244962450f, - -0.635134106979969190f, - 0.772280081606474320f, -0.635282201508823420f, 0.772158253573455240f, - -0.635430272680167160f, - 0.772036397150384520f, -0.635578320488556110f, 0.771914512341742350f, - -0.635726344928547070f, - 0.771792599152010150f, -0.635874345994697720f, 0.771670657585670330f, - -0.636022323681566300f, - 0.771548687647206300f, -0.636170277983712170f, 0.771426689341102590f, - -0.636318208895695460f, - 0.771304662671844830f, -0.636466116412077180f, 0.771182607643919330f, - -0.636614000527419120f, - 0.771060524261813820f, -0.636761861236284200f, 0.770938412530016940f, - -0.636909698533235870f, - 0.770816272453018540f, -0.637057512412838590f, 0.770694104035309140f, - -0.637205302869657600f, - 0.770571907281380810f, -0.637353069898259130f, 0.770449682195725960f, - -0.637500813493210190f, - 0.770327428782838890f, -0.637648533649078810f, 0.770205147047214210f, - -0.637796230360433540f, - 0.770082836993347900f, -0.637943903621844060f, 0.769960498625737230f, - -0.638091553427880820f, - 0.769838131948879840f, -0.638239179773115280f, 0.769715736967275130f, - -0.638386782652119570f, - 0.769593313685422940f, -0.638534362059466790f, 0.769470862107824670f, - -0.638681917989730730f, - 0.769348382238982280f, -0.638829450437486290f, 0.769225874083399260f, - -0.638976959397309140f, - 0.769103337645579700f, -0.639124444863775730f, 0.768980772930028870f, - -0.639271906831463510f, - 0.768858179941253270f, -0.639419345294950700f, 0.768735558683760310f, - -0.639566760248816310f, - 0.768612909162058380f, -0.639714151687640450f, 0.768490231380656860f, - -0.639861519606003900f, - 0.768367525344066270f, -0.640008863998488440f, 0.768244791056798330f, - -0.640156184859676510f, - 0.768122028523365420f, -0.640303482184151670f, 0.767999237748281270f, - -0.640450755966498140f, - 0.767876418736060610f, -0.640598006201301030f, 0.767753571491219030f, - -0.640745232883146440f, - 0.767630696018273380f, -0.640892436006621380f, 0.767507792321741270f, - -0.641039615566313390f, - 0.767384860406141730f, -0.641186771556811250f, 0.767261900275994500f, - -0.641333903972704290f, - 0.767138911935820400f, -0.641481012808583160f, 0.767015895390141480f, - -0.641628098059038750f, - 0.766892850643480670f, -0.641775159718663500f, 0.766769777700361920f, - -0.641922197782050170f, - 0.766646676565310380f, -0.642069212243792540f, 0.766523547242852210f, - -0.642216203098485370f, - 0.766400389737514230f, -0.642363170340724320f, 0.766277204053824710f, - -0.642510113965105710f, - 0.766153990196312920f, -0.642657033966226860f, 0.766030748169509000f, - -0.642803930338685990f, - 0.765907477977944340f, -0.642950803077082080f, 0.765784179626150970f, - -0.643097652176015110f, - 0.765660853118662500f, -0.643244477630085850f, 0.765537498460013070f, - -0.643391279433895850f, - 0.765414115654738270f, -0.643538057582047740f, 0.765290704707374370f, - -0.643684812069144850f, - 0.765167265622458960f, -0.643831542889791390f, 0.765043798404530520f, - -0.643978250038592660f, - 0.764920303058128410f, -0.644124933510154540f, 0.764796779587793460f, - -0.644271593299083790f, - 0.764673227998067140f, -0.644418229399988380f, 0.764549648293492150f, - -0.644564841807476640f, - 0.764426040478612070f, -0.644711430516158310f, 0.764302404557971720f, - -0.644857995520643710f, - 0.764178740536116670f, -0.645004536815543930f, 0.764055048417593970f, - -0.645151054395471160f, - 0.763931328206951090f, -0.645297548255038380f, 0.763807579908737160f, - -0.645444018388859230f, - 0.763683803527501870f, -0.645590464791548690f, 0.763559999067796150f, - -0.645736887457722290f, - 0.763436166534172010f, -0.645883286381996320f, 0.763312305931182380f, - -0.646029661558988330f, - 0.763188417263381270f, -0.646176012983316280f, 0.763064500535323710f, - -0.646322340649599480f, - 0.762940555751565720f, -0.646468644552457780f, 0.762816582916664430f, - -0.646614924686512050f, - 0.762692582035177980f, -0.646761181046383920f, 0.762568553111665380f, - -0.646907413626696020f, - 0.762444496150687210f, -0.647053622422071540f, 0.762320411156804270f, - -0.647199807427135230f, - 0.762196298134578900f, -0.647345968636512060f, 0.762072157088574560f, - -0.647492106044828100f, - 0.761947988023355390f, -0.647638219646710310f, 0.761823790943486960f, - -0.647784309436786440f, - 0.761699565853535380f, -0.647930375409685340f, 0.761575312758068000f, - -0.648076417560036530f, - 0.761451031661653620f, -0.648222435882470420f, 0.761326722568861360f, - -0.648368430371618290f, - 0.761202385484261780f, -0.648514401022112440f, 0.761078020412426560f, - -0.648660347828585840f, - 0.760953627357928150f, -0.648806270785672550f, 0.760829206325340010f, - -0.648952169888007300f, - 0.760704757319236920f, -0.649098045130225950f, 0.760580280344194450f, - -0.649243896506964900f, - 0.760455775404789260f, -0.649389724012861660f, 0.760331242505599030f, - -0.649535527642554730f, - 0.760206681651202420f, -0.649681307390683190f, 0.760082092846179340f, - -0.649827063251887100f, - 0.759957476095110330f, -0.649972795220807530f, 0.759832831402577400f, - -0.650118503292086200f, - 0.759708158773163440f, -0.650264187460365850f, 0.759583458211452010f, - -0.650409847720290310f, - 0.759458729722028210f, -0.650555484066503880f, 0.759333973309477940f, - -0.650701096493652040f, - 0.759209188978388070f, -0.650846684996380880f, 0.759084376733346610f, - -0.650992249569337660f, - 0.758959536578942440f, -0.651137790207170330f, 0.758834668519765660f, - -0.651283306904527740f, - 0.758709772560407390f, -0.651428799656059820f, 0.758584848705459610f, - -0.651574268456416970f, - 0.758459896959515430f, -0.651719713300250910f, 0.758334917327168960f, - -0.651865134182213920f, - 0.758209909813015280f, -0.652010531096959500f, 0.758084874421650730f, - -0.652155904039141590f, - 0.757959811157672300f, -0.652301253003415460f, 0.757834720025678310f, - -0.652446577984436730f, - 0.757709601030268080f, -0.652591878976862440f, 0.757584454176041810f, - -0.652737155975350310f, - 0.757459279467600720f, -0.652882408974558850f, 0.757334076909547130f, - -0.653027637969147530f, - 0.757208846506484570f, -0.653172842953776760f, 0.757083588263017140f, - -0.653318023923107670f, - 0.756958302183750490f, -0.653463180871802330f, 0.756832988273290820f, - -0.653608313794523890f, - 0.756707646536245670f, -0.653753422685936060f, 0.756582276977223470f, - -0.653898507540703780f, - 0.756456879600833740f, -0.654043568353492640f, 0.756331454411686920f, - -0.654188605118969040f, - 0.756206001414394540f, -0.654333617831800440f, 0.756080520613569120f, - -0.654478606486655350f, - 0.755955012013824420f, -0.654623571078202680f, 0.755829475619774760f, - -0.654768511601112600f, - 0.755703911436035880f, -0.654913428050056030f, 0.755578319467224540f, - -0.655058320419704910f, - 0.755452699717958250f, -0.655203188704731820f, 0.755327052192855670f, - -0.655348032899810470f, - 0.755201376896536550f, -0.655492852999615350f, 0.755075673833621620f, - -0.655637648998821820f, - 0.754949943008732640f, -0.655782420892106030f, 0.754824184426492350f, - -0.655927168674145360f, - 0.754698398091524500f, -0.656071892339617600f, 0.754572584008453840f, - -0.656216591883201920f, - 0.754446742181906440f, -0.656361267299578000f, 0.754320872616508820f, - -0.656505918583426550f, - 0.754194975316889170f, -0.656650545729428940f, 0.754069050287676120f, - -0.656795148732268070f, - 0.753943097533499640f, -0.656939727586627110f, 0.753817117058990790f, - -0.657084282287190180f, - 0.753691108868781210f, -0.657228812828642540f, 0.753565072967504300f, - -0.657373319205670210f, - 0.753439009359793580f, -0.657517801412960120f, 0.753312918050284330f, - -0.657662259445200070f, - 0.753186799043612520f, -0.657806693297078640f, 0.753060652344415100f, - -0.657951102963285520f, - 0.752934477957330150f, -0.658095488438511180f, 0.752808275886996950f, - -0.658239849717446870f, - 0.752682046138055340f, -0.658384186794785050f, 0.752555788715146390f, - -0.658528499665218650f, - 0.752429503622912390f, -0.658672788323441890f, 0.752303190865996400f, - -0.658817052764149480f, - 0.752176850449042810f, -0.658961292982037320f, 0.752050482376696360f, - -0.659105508971802090f, - 0.751924086653603550f, -0.659249700728141490f, 0.751797663284411550f, - -0.659393868245753860f, - 0.751671212273768430f, -0.659538011519338660f, 0.751544733626323680f, - -0.659682130543596150f, - 0.751418227346727470f, -0.659826225313227320f, 0.751291693439630870f, - -0.659970295822934540f, - 0.751165131909686480f, -0.660114342067420480f, 0.751038542761547360f, - -0.660258364041389050f, - 0.750911925999867890f, -0.660402361739545030f, 0.750785281629303690f, - -0.660546335156593890f, - 0.750658609654510700f, -0.660690284287242300f, 0.750531910080146410f, - -0.660834209126197610f, - 0.750405182910869330f, -0.660978109668168060f, 0.750278428151338720f, - -0.661121985907862860f, - 0.750151645806215070f, -0.661265837839992270f, 0.750024835880159780f, - -0.661409665459266940f, - 0.749897998377835330f, -0.661553468760398890f, 0.749771133303905100f, - -0.661697247738101010f, - 0.749644240663033480f, -0.661841002387086870f, 0.749517320459886170f, - -0.661984732702070920f, - 0.749390372699129560f, -0.662128438677768720f, 0.749263397385431130f, - -0.662272120308896590f, - 0.749136394523459370f, -0.662415777590171780f, 0.749009364117883880f, - -0.662559410516312290f, - 0.748882306173375150f, -0.662703019082037440f, 0.748755220694604760f, - -0.662846603282066900f, - 0.748628107686245440f, -0.662990163111121470f, 0.748500967152970430f, - -0.663133698563923010f, - 0.748373799099454560f, -0.663277209635194100f, 0.748246603530373420f, - -0.663420696319658280f, - 0.748119380450403600f, -0.663564158612039770f, 0.747992129864222700f, - -0.663707596507064010f, - 0.747864851776509410f, -0.663851009999457340f, 0.747737546191943330f, - -0.663994399083946640f, - 0.747610213115205150f, -0.664137763755260010f, 0.747482852550976570f, - -0.664281104008126230f, - 0.747355464503940190f, -0.664424419837275180f, 0.747228048978779920f, - -0.664567711237437520f, - 0.747100605980180130f, -0.664710978203344790f, 0.746973135512826850f, - -0.664854220729729660f, - 0.746845637581406540f, -0.664997438811325340f, 0.746718112190607130f, - -0.665140632442866140f, - 0.746590559345117310f, -0.665283801619087180f, 0.746462979049626770f, - -0.665426946334724660f, - 0.746335371308826320f, -0.665570066584515450f, 0.746207736127407760f, - -0.665713162363197550f, - 0.746080073510063780f, -0.665856233665509720f, 0.745952383461488290f, - -0.665999280486191500f, - 0.745824665986376090f, -0.666142302819983540f, 0.745696921089422760f, - -0.666285300661627280f, - 0.745569148775325430f, -0.666428274005865240f, 0.745441349048781680f, - -0.666571222847440640f, - 0.745313521914490520f, -0.666714147181097670f, 0.745185667377151640f, - -0.666857047001581220f, - 0.745057785441466060f, -0.666999922303637470f, 0.744929876112135350f, - -0.667142773082013310f, - 0.744801939393862630f, -0.667285599331456370f, 0.744673975291351710f, - -0.667428401046715520f, - 0.744545983809307370f, -0.667571178222540310f, 0.744417964952435620f, - -0.667713930853681030f, - 0.744289918725443260f, -0.667856658934889320f, 0.744161845133038180f, - -0.667999362460917400f, - 0.744033744179929290f, -0.668142041426518450f, 0.743905615870826490f, - -0.668284695826446670f, - 0.743777460210440890f, -0.668427325655456820f, 0.743649277203484060f, - -0.668569930908304970f, - 0.743521066854669120f, -0.668712511579747980f, 0.743392829168709970f, - -0.668855067664543610f, - 0.743264564150321600f, -0.668997599157450270f, 0.743136271804219820f, - -0.669140106053227600f, - 0.743007952135121720f, -0.669282588346636010f, 0.742879605147745200f, - -0.669425046032436910f, - 0.742751230846809050f, -0.669567479105392490f, 0.742622829237033490f, - -0.669709887560265840f, - 0.742494400323139180f, -0.669852271391821020f, 0.742365944109848460f, - -0.669994630594823000f, - 0.742237460601884000f, -0.670136965164037650f, 0.742108949803969910f, - -0.670279275094231800f, - 0.741980411720831070f, -0.670421560380173090f, 0.741851846357193480f, - -0.670563821016630040f, - 0.741723253717784140f, -0.670706056998372160f, 0.741594633807331150f, - -0.670848268320169640f, - 0.741465986630563290f, -0.670990454976794220f, 0.741337312192210660f, - -0.671132616963017740f, - 0.741208610497004260f, -0.671274754273613490f, 0.741079881549676080f, - -0.671416866903355450f, - 0.740951125354959110f, -0.671558954847018330f, 0.740822341917587330f, - -0.671701018099378320f, - 0.740693531242295760f, -0.671843056655211930f, 0.740564693333820250f, - -0.671985070509296900f, - 0.740435828196898020f, -0.672127059656411730f, 0.740306935836266940f, - -0.672269024091335930f, - 0.740178016256666240f, -0.672410963808849790f, 0.740049069462835550f, - -0.672552878803734710f, - 0.739920095459516200f, -0.672694769070772860f, 0.739791094251449950f, - -0.672836634604747300f, - 0.739662065843380010f, -0.672978475400442090f, 0.739533010240050250f, - -0.673120291452642070f, - 0.739403927446205760f, -0.673262082756132970f, 0.739274817466592520f, - -0.673403849305701740f, - 0.739145680305957510f, -0.673545591096136100f, 0.739016515969048720f, - -0.673687308122224330f, - 0.738887324460615110f, -0.673829000378756040f, 0.738758105785406900f, - -0.673970667860521620f, - 0.738628859948174840f, -0.674112310562312360f, 0.738499586953671130f, - -0.674253928478920410f, - 0.738370286806648620f, -0.674395521605139050f, 0.738240959511861310f, - -0.674537089935762000f, - 0.738111605074064260f, -0.674678633465584540f, 0.737982223498013570f, - -0.674820152189402170f, - 0.737852814788465980f, -0.674961646102011930f, 0.737723378950179700f, - -0.675103115198211420f, - 0.737593915987913570f, -0.675244559472799270f, 0.737464425906427580f, - -0.675385978920574840f, - 0.737334908710482910f, -0.675527373536338520f, 0.737205364404841190f, - -0.675668743314891910f, - 0.737075792994265730f, -0.675810088251036940f, 0.736946194483520280f, - -0.675951408339577010f, - 0.736816568877369900f, -0.676092703575315920f, 0.736686916180580460f, - -0.676233973953058950f, - 0.736557236397919150f, -0.676375219467611590f, 0.736427529534153690f, - -0.676516440113781090f, - 0.736297795594053170f, -0.676657635886374950f, 0.736168034582387330f, - -0.676798806780201770f, - 0.736038246503927350f, -0.676939952790071130f, 0.735908431363445190f, - -0.677081073910793530f, - 0.735778589165713590f, -0.677222170137180330f, 0.735648719915506510f, - -0.677363241464043920f, - 0.735518823617598900f, -0.677504287886197430f, 0.735388900276766730f, - -0.677645309398454910f, - 0.735258949897786840f, -0.677786305995631500f, 0.735128972485437180f, - -0.677927277672543020f, - 0.734998968044496710f, -0.678068224424006600f, 0.734868936579745170f, - -0.678209146244839860f, - 0.734738878095963500f, -0.678350043129861470f, 0.734608792597933550f, - -0.678490915073891140f, - 0.734478680090438370f, -0.678631762071749360f, 0.734348540578261600f, - -0.678772584118257690f, - 0.734218374066188280f, -0.678913381208238410f, 0.734088180559004040f, - -0.679054153336514870f, - 0.733957960061495940f, -0.679194900497911200f, 0.733827712578451700f, - -0.679335622687252560f, - 0.733697438114660370f, -0.679476319899364970f, 0.733567136674911360f, - -0.679616992129075560f, - 0.733436808263995710f, -0.679757639371212030f, 0.733306452886705260f, - -0.679898261620603290f, - 0.733176070547832740f, -0.680038858872078930f, 0.733045661252172080f, - -0.680179431120469750f, - 0.732915225004517780f, -0.680319978360607200f, 0.732784761809665790f, - -0.680460500587323880f, - 0.732654271672412820f, -0.680600997795453020f, 0.732523754597556700f, - -0.680741469979829090f, - 0.732393210589896040f, -0.680881917135287230f, 0.732262639654230770f, - -0.681022339256663670f, - 0.732132041795361290f, -0.681162736338795430f, 0.732001417018089630f, - -0.681303108376520530f, - 0.731870765327218290f, -0.681443455364677870f, 0.731740086727550980f, - -0.681583777298107480f, - 0.731609381223892630f, -0.681724074171649710f, 0.731478648821048520f, - -0.681864345980146670f, - 0.731347889523825570f, -0.682004592718440830f, 0.731217103337031270f, - -0.682144814381375640f, - 0.731086290265474340f, -0.682285010963795570f, 0.730955450313964360f, - -0.682425182460546060f, - 0.730824583487312160f, -0.682565328866473250f, 0.730693689790329000f, - -0.682705450176424590f, - 0.730562769227827590f, -0.682845546385248080f, 0.730431821804621520f, - -0.682985617487792740f, - 0.730300847525525490f, -0.683125663478908680f, 0.730169846395354870f, - -0.683265684353446700f, - 0.730038818418926260f, -0.683405680106258680f, 0.729907763601057140f, - -0.683545650732197530f, - 0.729776681946566090f, -0.683685596226116580f, 0.729645573460272480f, - -0.683825516582870720f, - 0.729514438146997010f, -0.683965411797315400f, 0.729383276011561050f, - -0.684105281864307080f, - 0.729252087058786970f, -0.684245126778703080f, 0.729120871293498230f, - -0.684384946535361750f, - 0.728989628720519420f, -0.684524741129142300f, 0.728858359344675800f, - -0.684664510554904960f, - 0.728727063170793830f, -0.684804254807510620f, 0.728595740203700770f, - -0.684943973881821490f, - 0.728464390448225200f, -0.685083667772700360f, 0.728333013909196360f, - -0.685223336475011210f, - 0.728201610591444610f, -0.685362979983618730f, 0.728070180499801210f, - -0.685502598293388550f, - 0.727938723639098620f, -0.685642191399187470f, 0.727807240014169960f, - -0.685781759295883030f, - 0.727675729629849610f, -0.685921301978343560f, 0.727544192490972800f, - -0.686060819441438710f, - 0.727412628602375770f, -0.686200311680038590f, 0.727281037968895870f, - -0.686339778689014520f, - 0.727149420595371020f, -0.686479220463238950f, 0.727017776486640680f, - -0.686618636997584630f, - 0.726886105647544970f, -0.686758028286925890f, 0.726754408082925020f, - -0.686897394326137610f, - 0.726622683797622850f, -0.687036735110095660f, 0.726490932796481910f, - -0.687176050633676820f, - 0.726359155084346010f, -0.687315340891759050f, 0.726227350666060370f, - -0.687454605879221030f, - 0.726095519546471000f, -0.687593845590942170f, 0.725963661730424930f, - -0.687733060021803230f, - 0.725831777222770370f, -0.687872249166685550f, 0.725699866028356120f, - -0.688011413020471640f, - 0.725567928152032300f, -0.688150551578044830f, 0.725435963598649810f, - -0.688289664834289330f, - 0.725303972373060770f, -0.688428752784090440f, 0.725171954480117950f, - -0.688567815422334250f, - 0.725039909924675370f, -0.688706852743907750f, 0.724907838711587820f, - -0.688845864743699020f, - 0.724775740845711280f, -0.688984851416597040f, 0.724643616331902550f, - -0.689123812757491570f, - 0.724511465175019630f, -0.689262748761273470f, 0.724379287379921190f, - -0.689401659422834270f, - 0.724247082951467000f, -0.689540544737066830f, 0.724114851894517850f, - -0.689679404698864800f, - 0.723982594213935520f, -0.689818239303122470f, 0.723850309914582880f, - -0.689957048544735390f, - 0.723717999001323500f, -0.690095832418599950f, 0.723585661479022150f, - -0.690234590919613370f, - 0.723453297352544380f, -0.690373324042674040f, 0.723320906626756970f, - -0.690512031782681060f, - 0.723188489306527460f, -0.690650714134534600f, 0.723056045396724410f, - -0.690789371093135650f, - 0.722923574902217700f, -0.690928002653386160f, 0.722791077827877550f, - -0.691066608810189220f, - 0.722658554178575610f, -0.691205189558448450f, 0.722526003959184540f, - -0.691343744893068710f, - 0.722393427174577550f, -0.691482274808955850f, 0.722260823829629310f, - -0.691620779301016290f, - 0.722128193929215350f, -0.691759258364157750f, 0.721995537478211880f, - -0.691897711993288760f, - 0.721862854481496340f, -0.692036140183318720f, 0.721730144943947160f, - -0.692174542929158140f, - 0.721597408870443770f, -0.692312920225718220f, 0.721464646265866370f, - -0.692451272067911130f, - 0.721331857135096290f, -0.692589598450650380f, 0.721199041483015720f, - -0.692727899368849820f, - 0.721066199314508110f, -0.692866174817424630f, 0.720933330634457530f, - -0.693004424791290870f, - 0.720800435447749190f, -0.693142649285365400f, 0.720667513759269520f, - -0.693280848294566040f, - 0.720534565573905270f, -0.693419021813811760f, 0.720401590896544760f, - -0.693557169838022290f, - 0.720268589732077190f, -0.693695292362118240f, 0.720135562085392420f, - -0.693833389381021350f, - 0.720002507961381650f, -0.693971460889654000f, 0.719869427364936860f, - -0.694109506882939820f, - 0.719736320300951030f, -0.694247527355803310f, 0.719603186774318120f, - -0.694385522303169740f, - 0.719470026789932990f, -0.694523491719965520f, 0.719336840352691740f, - -0.694661435601117820f, - 0.719203627467491220f, -0.694799353941554900f, 0.719070388139229190f, - -0.694937246736205830f, - 0.718937122372804490f, -0.695075113980000880f, 0.718803830173116890f, - -0.695212955667870780f, - 0.718670511545067230f, -0.695350771794747690f, 0.718537166493557370f, - -0.695488562355564440f, - 0.718403795023489830f, -0.695626327345254870f, 0.718270397139768260f, - -0.695764066758753690f, - 0.718136972847297490f, -0.695901780590996830f, 0.718003522150983180f, - -0.696039468836920690f, - 0.717870045055731710f, -0.696177131491462990f, 0.717736541566450950f, - -0.696314768549562090f, - 0.717603011688049080f, -0.696452380006157830f, 0.717469455425435830f, - -0.696589965856190370f, - 0.717335872783521730f, -0.696727526094601200f, 0.717202263767218070f, - -0.696865060716332470f, - 0.717068628381437480f, -0.697002569716327460f, 0.716934966631093130f, - -0.697140053089530420f, - 0.716801278521099540f, -0.697277510830886520f, 0.716667564056371890f, - -0.697414942935341790f, - 0.716533823241826680f, -0.697552349397843160f, 0.716400056082381000f, - -0.697689730213338800f, - 0.716266262582953120f, -0.697827085376777290f, 0.716132442748462330f, - -0.697964414883108670f, - 0.715998596583828690f, -0.698101718727283770f, 0.715864724093973500f, - -0.698238996904254280f, - 0.715730825283818590f, -0.698376249408972920f, 0.715596900158287470f, - -0.698513476236393040f, - 0.715462948722303760f, -0.698650677381469460f, 0.715328970980792620f, - -0.698787852839157670f, - 0.715194966938680120f, -0.698925002604414150f, 0.715060936600893090f, - -0.699062126672196140f, - 0.714926879972359490f, -0.699199225037462120f, 0.714792797058008240f, - -0.699336297695171140f, - 0.714658687862769090f, -0.699473344640283770f, 0.714524552391572860f, - -0.699610365867761040f, - 0.714390390649351390f, -0.699747361372564990f, 0.714256202641037510f, - -0.699884331149658760f, - 0.714121988371564820f, -0.700021275194006250f, 0.713987747845867830f, - -0.700158193500572730f, - 0.713853481068882470f, -0.700295086064323780f, 0.713719188045545240f, - -0.700431952880226420f, - 0.713584868780793640f, -0.700568793943248340f, 0.713450523279566260f, - -0.700705609248358450f, - 0.713316151546802610f, -0.700842398790526120f, 0.713181753587443180f, - -0.700979162564722370f, - 0.713047329406429340f, -0.701115900565918660f, 0.712912879008703480f, - -0.701252612789087460f, - 0.712778402399208980f, -0.701389299229202230f, 0.712643899582890210f, - -0.701525959881237340f, - 0.712509370564692320f, -0.701662594740168450f, 0.712374815349561710f, - -0.701799203800971720f, - 0.712240233942445510f, -0.701935787058624360f, 0.712105626348291890f, - -0.702072344508104630f, - 0.711970992572050100f, -0.702208876144391870f, 0.711836332618670080f, - -0.702345381962465880f, - 0.711701646493102970f, -0.702481861957308000f, 0.711566934200300700f, - -0.702618316123900130f, - 0.711432195745216430f, -0.702754744457225300f, 0.711297431132803970f, - -0.702891146952267400f, - 0.711162640368018350f, -0.703027523604011220f, 0.711027823455815280f, - -0.703163874407442770f, - 0.710892980401151680f, -0.703300199357548730f, 0.710758111208985350f, - -0.703436498449316660f, - 0.710623215884275020f, -0.703572771677735580f, 0.710488294431980470f, - -0.703709019037794810f, - 0.710353346857062420f, -0.703845240524484940f, 0.710218373164482220f, - -0.703981436132797620f, - 0.710083373359202800f, -0.704117605857725310f, 0.709948347446187400f, - -0.704253749694261470f, - 0.709813295430400840f, -0.704389867637400410f, 0.709678217316808580f, - -0.704525959682137380f, - 0.709543113110376770f, -0.704662025823468820f, 0.709407982816072980f, - -0.704798066056391950f, - 0.709272826438865690f, -0.704934080375904880f, 0.709137643983724030f, - -0.705070068777006840f, - 0.709002435455618250f, -0.705206031254697830f, 0.708867200859519820f, - -0.705341967803978840f, - 0.708731940200400650f, -0.705477878419852100f, 0.708596653483234080f, - -0.705613763097320490f, - 0.708461340712994160f, -0.705749621831387790f, 0.708326001894655890f, - -0.705885454617058980f, - 0.708190637033195400f, -0.706021261449339740f, 0.708055246133589500f, - -0.706157042323237060f, - 0.707919829200816310f, -0.706292797233758480f, 0.707784386239854620f, - -0.706428526175912790f, - 0.707648917255684350f, -0.706564229144709510f, 0.707513422253286280f, - -0.706699906135159430f, - 0.707377901237642100f, -0.706835557142273750f, 0.707242354213734710f, - -0.706971182161065360f, - 0.707106781186547570f, -0.707106781186547460f, 0.706971182161065360f, - -0.707242354213734600f, - 0.706835557142273860f, -0.707377901237642100f, 0.706699906135159430f, - -0.707513422253286170f, - 0.706564229144709620f, -0.707648917255684350f, 0.706428526175912790f, - -0.707784386239854620f, - 0.706292797233758480f, -0.707919829200816310f, 0.706157042323237060f, - -0.708055246133589500f, - 0.706021261449339740f, -0.708190637033195290f, 0.705885454617058980f, - -0.708326001894655780f, - 0.705749621831387790f, -0.708461340712994050f, 0.705613763097320490f, - -0.708596653483234080f, - 0.705477878419852210f, -0.708731940200400650f, 0.705341967803978950f, - -0.708867200859519820f, - 0.705206031254697830f, -0.709002435455618250f, 0.705070068777006840f, - -0.709137643983723920f, - 0.704934080375904990f, -0.709272826438865580f, 0.704798066056391950f, - -0.709407982816072980f, - 0.704662025823468930f, -0.709543113110376770f, 0.704525959682137380f, - -0.709678217316808470f, - 0.704389867637400410f, -0.709813295430400840f, 0.704253749694261580f, - -0.709948347446187400f, - 0.704117605857725430f, -0.710083373359202690f, 0.703981436132797730f, - -0.710218373164482220f, - 0.703845240524484940f, -0.710353346857062310f, 0.703709019037794810f, - -0.710488294431980470f, - 0.703572771677735580f, -0.710623215884275020f, 0.703436498449316770f, - -0.710758111208985350f, - 0.703300199357548730f, -0.710892980401151680f, 0.703163874407442770f, - -0.711027823455815280f, - 0.703027523604011220f, -0.711162640368018350f, 0.702891146952267400f, - -0.711297431132803970f, - 0.702754744457225300f, -0.711432195745216430f, 0.702618316123900130f, - -0.711566934200300700f, - 0.702481861957308000f, -0.711701646493102970f, 0.702345381962465880f, - -0.711836332618670080f, - 0.702208876144391870f, -0.711970992572049990f, 0.702072344508104740f, - -0.712105626348291890f, - 0.701935787058624360f, -0.712240233942445510f, 0.701799203800971720f, - -0.712374815349561710f, - 0.701662594740168570f, -0.712509370564692320f, 0.701525959881237450f, - -0.712643899582890210f, - 0.701389299229202230f, -0.712778402399208870f, 0.701252612789087460f, - -0.712912879008703370f, - 0.701115900565918660f, -0.713047329406429230f, 0.700979162564722480f, - -0.713181753587443070f, - 0.700842398790526230f, -0.713316151546802610f, 0.700705609248358450f, - -0.713450523279566150f, - 0.700568793943248450f, -0.713584868780793520f, 0.700431952880226420f, - -0.713719188045545130f, - 0.700295086064323780f, -0.713853481068882470f, 0.700158193500572730f, - -0.713987747845867830f, - 0.700021275194006360f, -0.714121988371564710f, 0.699884331149658760f, - -0.714256202641037400f, - 0.699747361372564990f, -0.714390390649351390f, 0.699610365867761040f, - -0.714524552391572860f, - 0.699473344640283770f, -0.714658687862768980f, 0.699336297695171250f, - -0.714792797058008130f, - 0.699199225037462120f, -0.714926879972359370f, 0.699062126672196140f, - -0.715060936600892980f, - 0.698925002604414150f, -0.715194966938680010f, 0.698787852839157790f, - -0.715328970980792620f, - 0.698650677381469580f, -0.715462948722303650f, 0.698513476236393040f, - -0.715596900158287360f, - 0.698376249408972920f, -0.715730825283818590f, 0.698238996904254390f, - -0.715864724093973390f, - 0.698101718727283880f, -0.715998596583828690f, 0.697964414883108790f, - -0.716132442748462330f, - 0.697827085376777290f, -0.716266262582953120f, 0.697689730213338800f, - -0.716400056082380890f, - 0.697552349397843270f, -0.716533823241826570f, 0.697414942935341790f, - -0.716667564056371890f, - 0.697277510830886630f, -0.716801278521099540f, 0.697140053089530530f, - -0.716934966631093130f, - 0.697002569716327460f, -0.717068628381437480f, 0.696865060716332470f, - -0.717202263767218070f, - 0.696727526094601200f, -0.717335872783521730f, 0.696589965856190370f, - -0.717469455425435830f, - 0.696452380006157830f, -0.717603011688049080f, 0.696314768549562200f, - -0.717736541566450840f, - 0.696177131491462990f, -0.717870045055731710f, 0.696039468836920690f, - -0.718003522150983060f, - 0.695901780590996830f, -0.718136972847297490f, 0.695764066758753800f, - -0.718270397139768260f, - 0.695626327345254870f, -0.718403795023489720f, 0.695488562355564440f, - -0.718537166493557370f, - 0.695350771794747800f, -0.718670511545067230f, 0.695212955667870890f, - -0.718803830173116890f, - 0.695075113980000880f, -0.718937122372804380f, 0.694937246736205940f, - -0.719070388139229190f, - 0.694799353941554900f, -0.719203627467491220f, 0.694661435601117930f, - -0.719336840352691740f, - 0.694523491719965520f, -0.719470026789932990f, 0.694385522303169860f, - -0.719603186774318000f, - 0.694247527355803310f, -0.719736320300951030f, 0.694109506882939820f, - -0.719869427364936860f, - 0.693971460889654000f, -0.720002507961381650f, 0.693833389381021350f, - -0.720135562085392310f, - 0.693695292362118350f, -0.720268589732077080f, 0.693557169838022400f, - -0.720401590896544760f, - 0.693419021813811880f, -0.720534565573905270f, 0.693280848294566150f, - -0.720667513759269410f, - 0.693142649285365510f, -0.720800435447749190f, 0.693004424791290870f, - -0.720933330634457530f, - 0.692866174817424740f, -0.721066199314508110f, 0.692727899368849820f, - -0.721199041483015720f, - 0.692589598450650380f, -0.721331857135096180f, 0.692451272067911240f, - -0.721464646265866370f, - 0.692312920225718220f, -0.721597408870443660f, 0.692174542929158140f, - -0.721730144943947160f, - 0.692036140183318830f, -0.721862854481496340f, 0.691897711993288760f, - -0.721995537478211880f, - 0.691759258364157750f, -0.722128193929215350f, 0.691620779301016400f, - -0.722260823829629310f, - 0.691482274808955850f, -0.722393427174577550f, 0.691343744893068820f, - -0.722526003959184430f, - 0.691205189558448450f, -0.722658554178575610f, 0.691066608810189220f, - -0.722791077827877550f, - 0.690928002653386280f, -0.722923574902217700f, 0.690789371093135760f, - -0.723056045396724410f, - 0.690650714134534720f, -0.723188489306527350f, 0.690512031782681170f, - -0.723320906626756850f, - 0.690373324042674040f, -0.723453297352544380f, 0.690234590919613370f, - -0.723585661479022040f, - 0.690095832418599950f, -0.723717999001323390f, 0.689957048544735390f, - -0.723850309914582880f, - 0.689818239303122470f, -0.723982594213935520f, 0.689679404698864800f, - -0.724114851894517850f, - 0.689540544737066940f, -0.724247082951466890f, 0.689401659422834380f, - -0.724379287379921080f, - 0.689262748761273470f, -0.724511465175019520f, 0.689123812757491680f, - -0.724643616331902550f, - 0.688984851416597150f, -0.724775740845711280f, 0.688845864743699130f, - -0.724907838711587820f, - 0.688706852743907750f, -0.725039909924675370f, 0.688567815422334360f, - -0.725171954480117840f, - 0.688428752784090550f, -0.725303972373060660f, 0.688289664834289440f, - -0.725435963598649810f, - 0.688150551578044830f, -0.725567928152032300f, 0.688011413020471640f, - -0.725699866028356120f, - 0.687872249166685550f, -0.725831777222770370f, 0.687733060021803230f, - -0.725963661730424930f, - 0.687593845590942170f, -0.726095519546470890f, 0.687454605879221030f, - -0.726227350666060260f, - 0.687315340891759160f, -0.726359155084346010f, 0.687176050633676930f, - -0.726490932796481910f, - 0.687036735110095660f, -0.726622683797622850f, 0.686897394326137610f, - -0.726754408082924910f, - 0.686758028286925890f, -0.726886105647544970f, 0.686618636997584740f, - -0.727017776486640680f, - 0.686479220463238950f, -0.727149420595371020f, 0.686339778689014630f, - -0.727281037968895760f, - 0.686200311680038700f, -0.727412628602375770f, 0.686060819441438710f, - -0.727544192490972800f, - 0.685921301978343670f, -0.727675729629849610f, 0.685781759295883030f, - -0.727807240014169960f, - 0.685642191399187470f, -0.727938723639098620f, 0.685502598293388670f, - -0.728070180499801210f, - 0.685362979983618730f, -0.728201610591444500f, 0.685223336475011210f, - -0.728333013909196360f, - 0.685083667772700360f, -0.728464390448225200f, 0.684943973881821490f, - -0.728595740203700770f, - 0.684804254807510620f, -0.728727063170793720f, 0.684664510554904960f, - -0.728858359344675690f, - 0.684524741129142300f, -0.728989628720519310f, 0.684384946535361750f, - -0.729120871293498230f, - 0.684245126778703080f, -0.729252087058786970f, 0.684105281864307080f, - -0.729383276011561050f, - 0.683965411797315510f, -0.729514438146996900f, 0.683825516582870830f, - -0.729645573460272480f, - 0.683685596226116690f, -0.729776681946565970f, 0.683545650732197530f, - -0.729907763601057140f, - 0.683405680106258790f, -0.730038818418926150f, 0.683265684353446700f, - -0.730169846395354870f, - 0.683125663478908800f, -0.730300847525525380f, 0.682985617487792850f, - -0.730431821804621520f, - 0.682845546385248080f, -0.730562769227827590f, 0.682705450176424590f, - -0.730693689790328890f, - 0.682565328866473250f, -0.730824583487312050f, 0.682425182460546060f, - -0.730955450313964360f, - 0.682285010963795570f, -0.731086290265474230f, 0.682144814381375640f, - -0.731217103337031160f, - 0.682004592718440830f, -0.731347889523825460f, 0.681864345980146780f, - -0.731478648821048520f, - 0.681724074171649820f, -0.731609381223892520f, 0.681583777298107480f, - -0.731740086727550980f, - 0.681443455364677990f, -0.731870765327218290f, 0.681303108376520530f, - -0.732001417018089520f, - 0.681162736338795430f, -0.732132041795361290f, 0.681022339256663670f, - -0.732262639654230660f, - 0.680881917135287340f, -0.732393210589896040f, 0.680741469979829090f, - -0.732523754597556590f, - 0.680600997795453130f, -0.732654271672412820f, 0.680460500587323880f, - -0.732784761809665790f, - 0.680319978360607200f, -0.732915225004517780f, 0.680179431120469750f, - -0.733045661252171970f, - 0.680038858872079040f, -0.733176070547832740f, 0.679898261620603290f, - -0.733306452886705260f, - 0.679757639371212030f, -0.733436808263995710f, 0.679616992129075560f, - -0.733567136674911360f, - 0.679476319899365080f, -0.733697438114660260f, 0.679335622687252670f, - -0.733827712578451700f, - 0.679194900497911200f, -0.733957960061495940f, 0.679054153336514870f, - -0.734088180559004040f, - 0.678913381208238410f, -0.734218374066188170f, 0.678772584118257690f, - -0.734348540578261600f, - 0.678631762071749470f, -0.734478680090438370f, 0.678490915073891250f, - -0.734608792597933550f, - 0.678350043129861580f, -0.734738878095963390f, 0.678209146244839860f, - -0.734868936579745060f, - 0.678068224424006600f, -0.734998968044496600f, 0.677927277672543130f, - -0.735128972485437180f, - 0.677786305995631500f, -0.735258949897786730f, 0.677645309398454910f, - -0.735388900276766620f, - 0.677504287886197430f, -0.735518823617598900f, 0.677363241464044030f, - -0.735648719915506400f, - 0.677222170137180450f, -0.735778589165713480f, 0.677081073910793530f, - -0.735908431363445190f, - 0.676939952790071240f, -0.736038246503927350f, 0.676798806780201770f, - -0.736168034582387330f, - 0.676657635886374950f, -0.736297795594053060f, 0.676516440113781090f, - -0.736427529534153690f, - 0.676375219467611700f, -0.736557236397919150f, 0.676233973953058950f, - -0.736686916180580460f, - 0.676092703575316030f, -0.736816568877369790f, 0.675951408339577010f, - -0.736946194483520170f, - 0.675810088251037060f, -0.737075792994265620f, 0.675668743314891910f, - -0.737205364404841190f, - 0.675527373536338630f, -0.737334908710482790f, 0.675385978920574950f, - -0.737464425906427580f, - 0.675244559472799270f, -0.737593915987913460f, 0.675103115198211530f, - -0.737723378950179590f, - 0.674961646102012040f, -0.737852814788465980f, 0.674820152189402280f, - -0.737982223498013570f, - 0.674678633465584540f, -0.738111605074064260f, 0.674537089935762110f, - -0.738240959511861310f, - 0.674395521605139050f, -0.738370286806648510f, 0.674253928478920520f, - -0.738499586953671130f, - 0.674112310562312360f, -0.738628859948174840f, 0.673970667860521620f, - -0.738758105785406900f, - 0.673829000378756150f, -0.738887324460615110f, 0.673687308122224330f, - -0.739016515969048600f, - 0.673545591096136100f, -0.739145680305957400f, 0.673403849305701850f, - -0.739274817466592520f, - 0.673262082756132970f, -0.739403927446205760f, 0.673120291452642070f, - -0.739533010240050250f, - 0.672978475400442090f, -0.739662065843379900f, 0.672836634604747410f, - -0.739791094251449950f, - 0.672694769070772970f, -0.739920095459516090f, 0.672552878803734820f, - -0.740049069462835550f, - 0.672410963808849900f, -0.740178016256666240f, 0.672269024091336040f, - -0.740306935836266940f, - 0.672127059656411840f, -0.740435828196898020f, 0.671985070509296900f, - -0.740564693333820250f, - 0.671843056655211930f, -0.740693531242295640f, 0.671701018099378320f, - -0.740822341917587330f, - 0.671558954847018330f, -0.740951125354959110f, 0.671416866903355450f, - -0.741079881549676080f, - 0.671274754273613490f, -0.741208610497004260f, 0.671132616963017850f, - -0.741337312192210660f, - 0.670990454976794220f, -0.741465986630563290f, 0.670848268320169750f, - -0.741594633807331150f, - 0.670706056998372160f, -0.741723253717784140f, 0.670563821016630040f, - -0.741851846357193480f, - 0.670421560380173090f, -0.741980411720830960f, 0.670279275094231910f, - -0.742108949803969800f, - 0.670136965164037760f, -0.742237460601884000f, 0.669994630594823000f, - -0.742365944109848460f, - 0.669852271391821130f, -0.742494400323139180f, 0.669709887560265840f, - -0.742622829237033380f, - 0.669567479105392490f, -0.742751230846809050f, 0.669425046032436910f, - -0.742879605147745090f, - 0.669282588346636010f, -0.743007952135121720f, 0.669140106053227710f, - -0.743136271804219820f, - 0.668997599157450270f, -0.743264564150321490f, 0.668855067664543610f, - -0.743392829168709970f, - 0.668712511579748090f, -0.743521066854669120f, 0.668569930908305080f, - -0.743649277203484060f, - 0.668427325655456820f, -0.743777460210440780f, 0.668284695826446670f, - -0.743905615870826490f, - 0.668142041426518560f, -0.744033744179929180f, 0.667999362460917510f, - -0.744161845133038070f, - 0.667856658934889440f, -0.744289918725443140f, 0.667713930853681140f, - -0.744417964952435620f, - 0.667571178222540310f, -0.744545983809307250f, 0.667428401046715640f, - -0.744673975291351600f, - 0.667285599331456480f, -0.744801939393862630f, 0.667142773082013310f, - -0.744929876112135350f, - 0.666999922303637470f, -0.745057785441465950f, 0.666857047001581220f, - -0.745185667377151640f, - 0.666714147181097670f, -0.745313521914490410f, 0.666571222847440750f, - -0.745441349048781680f, - 0.666428274005865350f, -0.745569148775325430f, 0.666285300661627390f, - -0.745696921089422760f, - 0.666142302819983540f, -0.745824665986375980f, 0.665999280486191500f, - -0.745952383461488180f, - 0.665856233665509720f, -0.746080073510063780f, 0.665713162363197660f, - -0.746207736127407650f, - 0.665570066584515560f, -0.746335371308826320f, 0.665426946334724660f, - -0.746462979049626770f, - 0.665283801619087180f, -0.746590559345117310f, 0.665140632442866140f, - -0.746718112190607020f, - 0.664997438811325340f, -0.746845637581406540f, 0.664854220729729660f, - -0.746973135512826740f, - 0.664710978203344900f, -0.747100605980180130f, 0.664567711237437520f, - -0.747228048978779920f, - 0.664424419837275180f, -0.747355464503940190f, 0.664281104008126230f, - -0.747482852550976570f, - 0.664137763755260010f, -0.747610213115205150f, 0.663994399083946640f, - -0.747737546191943330f, - 0.663851009999457340f, -0.747864851776509410f, 0.663707596507064120f, - -0.747992129864222700f, - 0.663564158612039880f, -0.748119380450403490f, 0.663420696319658280f, - -0.748246603530373420f, - 0.663277209635194100f, -0.748373799099454560f, 0.663133698563923010f, - -0.748500967152970430f, - 0.662990163111121470f, -0.748628107686245330f, 0.662846603282066900f, - -0.748755220694604760f, - 0.662703019082037440f, -0.748882306173375030f, 0.662559410516312400f, - -0.749009364117883770f, - 0.662415777590171780f, -0.749136394523459260f, 0.662272120308896590f, - -0.749263397385431020f, - 0.662128438677768720f, -0.749390372699129560f, 0.661984732702071030f, - -0.749517320459886170f, - 0.661841002387086870f, -0.749644240663033480f, 0.661697247738101120f, - -0.749771133303904990f, - 0.661553468760399000f, -0.749897998377835220f, 0.661409665459266940f, - -0.750024835880159780f, - 0.661265837839992270f, -0.750151645806214960f, 0.661121985907862970f, - -0.750278428151338610f, - 0.660978109668168060f, -0.750405182910869220f, 0.660834209126197610f, - -0.750531910080146410f, - 0.660690284287242300f, -0.750658609654510590f, 0.660546335156593890f, - -0.750785281629303580f, - 0.660402361739545030f, -0.750911925999867890f, 0.660258364041389050f, - -0.751038542761547250f, - 0.660114342067420480f, -0.751165131909686370f, 0.659970295822934540f, - -0.751291693439630870f, - 0.659826225313227430f, -0.751418227346727360f, 0.659682130543596150f, - -0.751544733626323570f, - 0.659538011519338770f, -0.751671212273768430f, 0.659393868245753970f, - -0.751797663284411440f, - 0.659249700728141490f, -0.751924086653603550f, 0.659105508971802200f, - -0.752050482376696360f, - 0.658961292982037320f, -0.752176850449042700f, 0.658817052764149480f, - -0.752303190865996400f, - 0.658672788323441890f, -0.752429503622912390f, 0.658528499665218760f, - -0.752555788715146390f, - 0.658384186794785050f, -0.752682046138055230f, 0.658239849717446980f, - -0.752808275886996950f, - 0.658095488438511290f, -0.752934477957330150f, 0.657951102963285630f, - -0.753060652344415100f, - 0.657806693297078640f, -0.753186799043612410f, 0.657662259445200070f, - -0.753312918050284330f, - 0.657517801412960120f, -0.753439009359793580f, 0.657373319205670210f, - -0.753565072967504190f, - 0.657228812828642650f, -0.753691108868781210f, 0.657084282287190180f, - -0.753817117058990680f, - 0.656939727586627110f, -0.753943097533499640f, 0.656795148732268070f, - -0.754069050287676120f, - 0.656650545729429050f, -0.754194975316889170f, 0.656505918583426550f, - -0.754320872616508820f, - 0.656361267299578000f, -0.754446742181906330f, 0.656216591883202030f, - -0.754572584008453840f, - 0.656071892339617710f, -0.754698398091524390f, 0.655927168674145360f, - -0.754824184426492240f, - 0.655782420892106030f, -0.754949943008732640f, 0.655637648998821820f, - -0.755075673833621510f, - 0.655492852999615460f, -0.755201376896536550f, 0.655348032899810580f, - -0.755327052192855560f, - 0.655203188704731930f, -0.755452699717958140f, 0.655058320419704910f, - -0.755578319467224540f, - 0.654913428050056150f, -0.755703911436035880f, 0.654768511601112600f, - -0.755829475619774760f, - 0.654623571078202680f, -0.755955012013824310f, 0.654478606486655350f, - -0.756080520613569120f, - 0.654333617831800550f, -0.756206001414394540f, 0.654188605118969040f, - -0.756331454411686920f, - 0.654043568353492640f, -0.756456879600833630f, 0.653898507540703890f, - -0.756582276977223470f, - 0.653753422685936170f, -0.756707646536245670f, 0.653608313794523890f, - -0.756832988273290820f, - 0.653463180871802330f, -0.756958302183750490f, 0.653318023923107670f, - -0.757083588263017140f, - 0.653172842953776760f, -0.757208846506484460f, 0.653027637969147650f, - -0.757334076909547130f, - 0.652882408974558960f, -0.757459279467600720f, 0.652737155975350420f, - -0.757584454176041810f, - 0.652591878976862550f, -0.757709601030268080f, 0.652446577984436840f, - -0.757834720025678310f, - 0.652301253003415460f, -0.757959811157672300f, 0.652155904039141700f, - -0.758084874421650620f, - 0.652010531096959500f, -0.758209909813015280f, 0.651865134182214030f, - -0.758334917327168960f, - 0.651719713300251020f, -0.758459896959515320f, 0.651574268456417080f, - -0.758584848705459500f, - 0.651428799656059820f, -0.758709772560407390f, 0.651283306904527850f, - -0.758834668519765660f, - 0.651137790207170330f, -0.758959536578942440f, 0.650992249569337660f, - -0.759084376733346500f, - 0.650846684996380990f, -0.759209188978387960f, 0.650701096493652040f, - -0.759333973309477940f, - 0.650555484066503990f, -0.759458729722028210f, 0.650409847720290420f, - -0.759583458211452010f, - 0.650264187460365960f, -0.759708158773163440f, 0.650118503292086200f, - -0.759832831402577400f, - 0.649972795220807530f, -0.759957476095110330f, 0.649827063251887100f, - -0.760082092846179220f, - 0.649681307390683190f, -0.760206681651202420f, 0.649535527642554730f, - -0.760331242505599030f, - 0.649389724012861770f, -0.760455775404789260f, 0.649243896506965010f, - -0.760580280344194340f, - 0.649098045130226060f, -0.760704757319236920f, 0.648952169888007410f, - -0.760829206325340010f, - 0.648806270785672550f, -0.760953627357928040f, 0.648660347828585840f, - -0.761078020412426560f, - 0.648514401022112550f, -0.761202385484261780f, 0.648368430371618400f, - -0.761326722568861250f, - 0.648222435882470420f, -0.761451031661653510f, 0.648076417560036530f, - -0.761575312758068000f, - 0.647930375409685460f, -0.761699565853535270f, 0.647784309436786550f, - -0.761823790943486840f, - 0.647638219646710420f, -0.761947988023355390f, 0.647492106044828100f, - -0.762072157088574560f, - 0.647345968636512060f, -0.762196298134578900f, 0.647199807427135230f, - -0.762320411156804160f, - 0.647053622422071650f, -0.762444496150687100f, 0.646907413626696020f, - -0.762568553111665380f, - 0.646761181046383920f, -0.762692582035177870f, 0.646614924686512050f, - -0.762816582916664320f, - 0.646468644552457890f, -0.762940555751565720f, 0.646322340649599590f, - -0.763064500535323710f, - 0.646176012983316390f, -0.763188417263381270f, 0.646029661558988330f, - -0.763312305931182380f, - 0.645883286381996440f, -0.763436166534172010f, 0.645736887457722290f, - -0.763559999067796150f, - 0.645590464791548800f, -0.763683803527501870f, 0.645444018388859230f, - -0.763807579908737160f, - 0.645297548255038380f, -0.763931328206951090f, 0.645151054395471270f, - -0.764055048417593860f, - 0.645004536815544040f, -0.764178740536116670f, 0.644857995520643710f, - -0.764302404557971720f, - 0.644711430516158420f, -0.764426040478612070f, 0.644564841807476750f, - -0.764549648293492150f, - 0.644418229399988380f, -0.764673227998067140f, 0.644271593299083900f, - -0.764796779587793460f, - 0.644124933510154540f, -0.764920303058128410f, 0.643978250038592660f, - -0.765043798404530410f, - 0.643831542889791500f, -0.765167265622458960f, 0.643684812069144960f, - -0.765290704707374260f, - 0.643538057582047850f, -0.765414115654738160f, 0.643391279433895960f, - -0.765537498460013070f, - 0.643244477630085850f, -0.765660853118662390f, 0.643097652176015110f, - -0.765784179626150970f, - 0.642950803077082080f, -0.765907477977944230f, 0.642803930338686100f, - -0.766030748169509000f, - 0.642657033966226860f, -0.766153990196312810f, 0.642510113965105710f, - -0.766277204053824710f, - 0.642363170340724320f, -0.766400389737514120f, 0.642216203098485370f, - -0.766523547242852100f, - 0.642069212243792540f, -0.766646676565310380f, 0.641922197782050170f, - -0.766769777700361920f, - 0.641775159718663500f, -0.766892850643480670f, 0.641628098059038860f, - -0.767015895390141480f, - 0.641481012808583160f, -0.767138911935820400f, 0.641333903972704290f, - -0.767261900275994390f, - 0.641186771556811250f, -0.767384860406141620f, 0.641039615566313390f, - -0.767507792321741270f, - 0.640892436006621380f, -0.767630696018273270f, 0.640745232883146440f, - -0.767753571491219030f, - 0.640598006201301030f, -0.767876418736060610f, 0.640450755966498140f, - -0.767999237748281270f, - 0.640303482184151670f, -0.768122028523365310f, 0.640156184859676620f, - -0.768244791056798220f, - 0.640008863998488440f, -0.768367525344066270f, 0.639861519606004010f, - -0.768490231380656750f, - 0.639714151687640450f, -0.768612909162058270f, 0.639566760248816420f, - -0.768735558683760310f, - 0.639419345294950700f, -0.768858179941253270f, 0.639271906831463510f, - -0.768980772930028870f, - 0.639124444863775730f, -0.769103337645579590f, 0.638976959397309140f, - -0.769225874083399260f, - 0.638829450437486400f, -0.769348382238982280f, 0.638681917989730840f, - -0.769470862107824560f, - 0.638534362059466790f, -0.769593313685422940f, 0.638386782652119680f, - -0.769715736967275020f, - 0.638239179773115390f, -0.769838131948879840f, 0.638091553427880930f, - -0.769960498625737230f, - 0.637943903621844170f, -0.770082836993347900f, 0.637796230360433540f, - -0.770205147047214100f, - 0.637648533649078810f, -0.770327428782838770f, 0.637500813493210310f, - -0.770449682195725960f, - 0.637353069898259130f, -0.770571907281380700f, 0.637205302869657600f, - -0.770694104035309140f, - 0.637057512412838590f, -0.770816272453018430f, 0.636909698533235870f, - -0.770938412530016940f, - 0.636761861236284200f, -0.771060524261813710f, 0.636614000527419230f, - -0.771182607643919220f, - 0.636466116412077180f, -0.771304662671844720f, 0.636318208895695570f, - -0.771426689341102590f, - 0.636170277983712170f, -0.771548687647206300f, 0.636022323681566300f, - -0.771670657585670330f, - 0.635874345994697720f, -0.771792599152010150f, 0.635726344928547180f, - -0.771914512341742350f, - 0.635578320488556230f, -0.772036397150384410f, 0.635430272680167160f, - -0.772158253573455240f, - 0.635282201508823530f, -0.772280081606474320f, 0.635134106979969300f, - -0.772401881244962340f, - 0.634985989099049460f, -0.772523652484441330f, 0.634837847871510100f, - -0.772645395320433860f, - 0.634689683302797850f, -0.772767109748463740f, 0.634541495398360130f, - -0.772888795764056220f, - 0.634393284163645490f, -0.773010453362736990f, 0.634245049604103330f, - -0.773132082540033070f, - 0.634096791725183740f, -0.773253683291472590f, 0.633948510532337810f, - -0.773375255612584470f, - 0.633800206031017280f, -0.773496799498899050f, 0.633651878226674900f, - -0.773618314945947460f, - 0.633503527124764320f, -0.773739801949261840f, 0.633355152730740060f, - -0.773861260504375540f, - 0.633206755050057190f, -0.773982690606822790f, 0.633058334088172250f, - -0.774104092252138940f, - 0.632909889850541860f, -0.774225465435860570f, 0.632761422342624000f, - -0.774346810153525020f, - 0.632612931569877520f, -0.774468126400670860f, 0.632464417537761840f, - -0.774589414172837550f, - 0.632315880251737680f, -0.774710673465565550f, 0.632167319717266030f, - -0.774831904274396850f, - 0.632018735939809060f, -0.774953106594873820f, 0.631870128924829850f, - -0.775074280422540450f, - 0.631721498677792370f, -0.775195425752941310f, 0.631572845204161130f, - -0.775316542581622410f, - 0.631424168509401860f, -0.775437630904130430f, 0.631275468598980870f, - -0.775558690716013580f, - 0.631126745478365340f, -0.775679722012820540f, 0.630977999153023660f, - -0.775800724790101540f, - 0.630829229628424470f, -0.775921699043407580f, 0.630680436910038060f, - -0.776042644768290770f, - 0.630531621003334600f, -0.776163561960304340f, 0.630382781913785940f, - -0.776284450615002400f, - 0.630233919646864480f, -0.776405310727940390f, 0.630085034208043290f, - -0.776526142294674430f, - 0.629936125602796550f, -0.776646945310762060f, 0.629787193836599200f, - -0.776767719771761510f, - 0.629638238914927100f, -0.776888465673232440f, 0.629489260843256740f, - -0.777009183010735290f, - 0.629340259627065750f, -0.777129871779831620f, 0.629191235271832410f, - -0.777250531976084070f, - 0.629042187783036000f, -0.777371163595056200f, 0.628893117166156480f, - -0.777491766632312900f, - 0.628744023426674790f, -0.777612341083419920f, 0.628594906570072660f, - -0.777732886943944050f, - 0.628445766601832710f, -0.777853404209453040f, 0.628296603527438440f, - -0.777973892875515990f, - 0.628147417352374120f, -0.778094352937702790f, 0.627998208082124810f, - -0.778214784391584420f, - 0.627848975722176570f, -0.778335187232733090f, 0.627699720278016240f, - -0.778455561456721900f, - 0.627550441755131530f, -0.778575907059124940f, 0.627401140159011160f, - -0.778696224035517530f, - 0.627251815495144190f, -0.778816512381475870f, 0.627102467769021010f, - -0.778936772092577500f, - 0.626953096986132770f, -0.779057003164400630f, 0.626803703151971310f, - -0.779177205592524680f, - 0.626654286272029460f, -0.779297379372530300f, 0.626504846351800930f, - -0.779417524499998900f, - 0.626355383396779990f, -0.779537640970513150f, 0.626205897412462130f, - -0.779657728779656780f, - 0.626056388404343520f, -0.779777787923014440f, 0.625906856377921210f, - -0.779897818396171890f, - 0.625757301338692900f, -0.780017820194715990f, 0.625607723292157410f, - -0.780137793314234500f, - 0.625458122243814360f, -0.780257737750316590f, 0.625308498199164010f, - -0.780377653498552040f, - 0.625158851163707730f, -0.780497540554531910f, 0.625009181142947460f, - -0.780617398913848290f, - 0.624859488142386450f, -0.780737228572094380f, 0.624709772167528100f, - -0.780857029524864470f, - 0.624560033223877320f, -0.780976801767753750f, 0.624410271316939380f, - -0.781096545296358410f, - 0.624260486452220650f, -0.781216260106276090f, 0.624110678635228510f, - -0.781335946193104870f, - 0.623960847871470770f, -0.781455603552444480f, 0.623810994166456130f, - -0.781575232179895550f, - 0.623661117525694640f, -0.781694832071059390f, 0.623511217954696550f, - -0.781814403221538830f, - 0.623361295458973340f, -0.781933945626937630f, 0.623211350044037270f, - -0.782053459282860300f, - 0.623061381715401370f, -0.782172944184912900f, 0.622911390478579460f, - -0.782292400328702400f, - 0.622761376339086460f, -0.782411827709836420f, 0.622611339302437730f, - -0.782531226323924240f, - 0.622461279374150080f, -0.782650596166575730f, 0.622311196559740320f, - -0.782769937233402050f, - 0.622161090864726930f, -0.782889249520015480f, 0.622010962294628600f, - -0.783008533022029110f, - 0.621860810854965360f, -0.783127787735057310f, 0.621710636551257690f, - -0.783247013654715380f, - 0.621560439389027270f, -0.783366210776619720f, 0.621410219373796150f, - -0.783485379096387820f, - 0.621259976511087660f, -0.783604518609638200f, 0.621109710806425740f, - -0.783723629311990470f, - 0.620959422265335180f, -0.783842711199065230f, 0.620809110893341900f, - -0.783961764266484010f, - 0.620658776695972140f, -0.784080788509869950f, 0.620508419678753360f, - -0.784199783924846570f, - 0.620358039847213830f, -0.784318750507038920f, 0.620207637206882430f, - -0.784437688252072720f, - 0.620057211763289210f, -0.784556597155575240f, 0.619906763521964830f, - -0.784675477213174320f, - 0.619756292488440660f, -0.784794328420499230f, 0.619605798668249390f, - -0.784913150773180020f, - 0.619455282066924020f, -0.785031944266848080f, 0.619304742689998690f, - -0.785150708897135560f, - 0.619154180543008410f, -0.785269444659675850f, 0.619003595631488770f, - -0.785388151550103550f, - 0.618852987960976320f, -0.785506829564053930f, 0.618702357537008640f, - -0.785625478697163700f, - 0.618551704365123860f, -0.785744098945070360f, 0.618401028450860980f, - -0.785862690303412600f, - 0.618250329799760250f, -0.785981252767830150f, 0.618099608417362110f, - -0.786099786333963820f, - 0.617948864309208260f, -0.786218290997455550f, 0.617798097480841140f, - -0.786336766753948260f, - 0.617647307937803980f, -0.786455213599085770f, 0.617496495685640910f, - -0.786573631528513230f, - 0.617345660729896940f, -0.786692020537876680f, 0.617194803076117630f, - -0.786810380622823490f, - 0.617043922729849760f, -0.786928711779001700f, 0.616893019696640790f, - -0.787047014002060790f, - 0.616742093982038830f, -0.787165287287650890f, 0.616591145591593230f, - -0.787283531631423620f, - 0.616440174530853650f, -0.787401747029031320f, 0.616289180805370980f, - -0.787519933476127810f, - 0.616138164420696910f, -0.787638090968367450f, 0.615987125382383870f, - -0.787756219501405950f, - 0.615836063695985090f, -0.787874319070900110f, 0.615684979367054570f, - -0.787992389672507950f, - 0.615533872401147430f, -0.788110431301888070f, 0.615382742803819330f, - -0.788228443954700490f, - 0.615231590580626820f, -0.788346427626606230f, 0.615080415737127460f, - -0.788464382313267430f, - 0.614929218278879590f, -0.788582308010347120f, 0.614777998211442190f, - -0.788700204713509660f, - 0.614626755540375050f, -0.788818072418420170f, 0.614475490271239160f, - -0.788935911120745130f, - 0.614324202409595950f, -0.789053720816151880f, 0.614172891961007990f, - -0.789171501500308790f, - 0.614021558931038490f, -0.789289253168885650f, 0.613870203325251440f, - -0.789406975817552810f, - 0.613718825149211830f, -0.789524669441982190f, 0.613567424408485330f, - -0.789642334037846340f, - 0.613416001108638590f, -0.789759969600819070f, 0.613264555255239150f, - -0.789877576126575280f, - 0.613113086853854910f, -0.789995153610791090f, 0.612961595910055170f, - -0.790112702049143300f, - 0.612810082429409710f, -0.790230221437310030f, 0.612658546417489290f, - -0.790347711770970520f, - 0.612506987879865570f, -0.790465173045804880f, 0.612355406822110760f, - -0.790582605257494460f, - 0.612203803249798060f, -0.790700008401721610f, 0.612052177168501580f, - -0.790817382474169660f, - 0.611900528583796070f, -0.790934727470523290f, 0.611748857501257400f, - -0.791052043386467950f, - 0.611597163926462020f, -0.791169330217690090f, 0.611445447864987110f, - -0.791286587959877720f, - 0.611293709322411010f, -0.791403816608719500f, 0.611141948304312570f, - -0.791521016159905220f, - 0.610990164816271770f, -0.791638186609125770f, 0.610838358863869280f, - -0.791755327952073150f, - 0.610686530452686280f, -0.791872440184440470f, 0.610534679588305320f, - -0.791989523301921850f, - 0.610382806276309480f, -0.792106577300212390f, 0.610230910522282620f, - -0.792223602175008310f, - 0.610078992331809620f, -0.792340597922007060f, 0.609927051710476230f, - -0.792457564536906970f, - 0.609775088663868430f, -0.792574502015407580f, 0.609623103197573730f, - -0.792691410353209450f, - 0.609471095317180240f, -0.792808289546014120f, 0.609319065028276820f, - -0.792925139589524260f, - 0.609167012336453210f, -0.793041960479443640f, 0.609014937247299940f, - -0.793158752211477140f, - 0.608862839766408200f, -0.793275514781330630f, 0.608710719899370420f, - -0.793392248184711100f, - 0.608558577651779450f, -0.793508952417326660f, 0.608406413029229260f, - -0.793625627474886190f, - 0.608254226037314490f, -0.793742273353100100f, 0.608102016681630550f, - -0.793858890047679620f, - 0.607949784967773740f, -0.793975477554337170f, 0.607797530901341140f, - -0.794092035868785960f, - 0.607645254487930830f, -0.794208564986740640f, 0.607492955733141660f, - -0.794325064903916520f, - 0.607340634642572930f, -0.794441535616030590f, 0.607188291221825160f, - -0.794557977118800270f, - 0.607035925476499760f, -0.794674389407944550f, 0.606883537412198580f, - -0.794790772479183170f, - 0.606731127034524480f, -0.794907126328237010f, 0.606578694349081400f, - -0.795023450950828050f, - 0.606426239361473550f, -0.795139746342679590f, 0.606273762077306430f, - -0.795256012499515500f, - 0.606121262502186230f, -0.795372249417061190f, 0.605968740641719790f, - -0.795488457091042990f, - 0.605816196501515080f, -0.795604635517188070f, 0.605663630087180490f, - -0.795720784691225090f, - 0.605511041404325550f, -0.795836904608883460f, 0.605358430458560530f, - -0.795952995265893910f, - 0.605205797255496500f, -0.796069056657987990f, 0.605053141800745430f, - -0.796185088780898440f, - 0.604900464099919930f, -0.796301091630359110f, 0.604747764158633410f, - -0.796417065202104980f, - 0.604595041982500360f, -0.796533009491872000f, 0.604442297577135970f, - -0.796648924495397150f, - 0.604289530948156070f, -0.796764810208418720f, 0.604136742101177630f, - -0.796880666626675780f, - 0.603983931041818020f, -0.796996493745908750f, 0.603831097775695880f, - -0.797112291561858920f, - 0.603678242308430370f, -0.797228060070268700f, 0.603525364645641550f, - -0.797343799266881700f, - 0.603372464792950370f, -0.797459509147442460f, 0.603219542755978440f, - -0.797575189707696590f, - 0.603066598540348280f, -0.797690840943391040f, 0.602913632151683140f, - -0.797806462850273570f, - 0.602760643595607220f, -0.797922055424093000f, 0.602607632877745550f, - -0.798037618660599410f, - 0.602454600003723860f, -0.798153152555543750f, 0.602301544979168550f, - -0.798268657104678310f, - 0.602148467809707320f, -0.798384132303756380f, 0.601995368500968130f, - -0.798499578148532010f, - 0.601842247058580030f, -0.798614994634760820f, 0.601689103488173060f, - -0.798730381758199210f, - 0.601535937795377730f, -0.798845739514604580f, 0.601382749985825420f, - -0.798961067899735760f, - 0.601229540065148620f, -0.799076366909352350f, 0.601076308038980160f, - -0.799191636539215210f, - 0.600923053912954090f, -0.799306876785086160f, 0.600769777692705230f, - -0.799422087642728040f, - 0.600616479383868970f, -0.799537269107905010f, 0.600463158992081690f, - -0.799652421176382130f, - 0.600309816522980430f, -0.799767543843925680f, 0.600156451982203350f, - -0.799882637106302810f, - 0.600003065375389060f, -0.799997700959281910f, 0.599849656708177360f, - -0.800112735398632370f, - 0.599696225986208310f, -0.800227740420124790f, 0.599542773215123390f, - -0.800342716019530660f, - 0.599389298400564540f, -0.800457662192622710f, 0.599235801548174570f, - -0.800572578935174750f, - 0.599082282663597310f, -0.800687466242961500f, 0.598928741752476900f, - -0.800802324111759110f, - 0.598775178820458720f, -0.800917152537344300f, 0.598621593873188920f, - -0.801031951515495330f, - 0.598467986916314310f, -0.801146721041991250f, 0.598314357955482600f, - -0.801261461112612540f, - 0.598160706996342380f, -0.801376171723140130f, 0.598007034044542700f, - -0.801490852869356840f, - 0.597853339105733910f, -0.801605504547046040f, 0.597699622185566830f, - -0.801720126751992330f, - 0.597545883289693270f, -0.801834719479981310f, 0.597392122423765710f, - -0.801949282726799660f, - 0.597238339593437530f, -0.802063816488235440f, 0.597084534804362740f, - -0.802178320760077450f, - 0.596930708062196500f, -0.802292795538115720f, 0.596776859372594500f, - -0.802407240818141300f, - 0.596622988741213330f, -0.802521656595946320f, 0.596469096173710360f, - -0.802636042867324150f, - 0.596315181675743820f, -0.802750399628069160f, 0.596161245252972540f, - -0.802864726873976590f, - 0.596007286911056530f, -0.802979024600843140f, 0.595853306655656390f, - -0.803093292804466400f, - 0.595699304492433470f, -0.803207531480644830f, 0.595545280427049790f, - -0.803321740625178470f, - 0.595391234465168730f, -0.803435920233868120f, 0.595237166612453850f, - -0.803550070302515570f, - 0.595083076874569960f, -0.803664190826924090f, 0.594928965257182420f, - -0.803778281802897570f, - 0.594774831765957580f, -0.803892343226241260f, 0.594620676406562240f, - -0.804006375092761520f, - 0.594466499184664540f, -0.804120377398265700f, 0.594312300105932830f, - -0.804234350138562260f, - 0.594158079176036800f, -0.804348293309460780f, 0.594003836400646690f, - -0.804462206906771840f, - 0.593849571785433630f, -0.804576090926307000f, 0.593695285336069300f, - -0.804689945363879500f, - 0.593540977058226390f, -0.804803770215302810f, 0.593386646957578480f, - -0.804917565476392150f, - 0.593232295039799800f, -0.805031331142963660f, 0.593077921310565580f, - -0.805145067210834120f, - 0.592923525775551410f, -0.805258773675822210f, 0.592769108440434070f, - -0.805372450533747060f, - 0.592614669310891130f, -0.805486097780429120f, 0.592460208392600940f, - -0.805599715411689950f, - 0.592305725691242400f, -0.805713303423352120f, 0.592151221212495640f, - -0.805826861811239300f, - 0.591996694962040990f, -0.805940390571176280f, 0.591842146945560250f, - -0.806053889698988950f, - 0.591687577168735550f, -0.806167359190504310f, 0.591532985637249990f, - -0.806280799041550370f, - 0.591378372356787580f, -0.806394209247956240f, 0.591223737333032910f, - -0.806507589805552260f, - 0.591069080571671510f, -0.806620940710169650f, 0.590914402078389520f, - -0.806734261957640750f, - 0.590759701858874280f, -0.806847553543799220f, 0.590604979918813440f, - -0.806960815464479620f, - 0.590450236263895920f, -0.807074047715517610f, 0.590295470899810940f, - -0.807187250292749850f, - 0.590140683832248940f, -0.807300423192014450f, 0.589985875066900920f, - -0.807413566409150190f, - 0.589831044609458900f, -0.807526679939997160f, 0.589676192465615420f, - -0.807639763780396370f, - 0.589521318641063940f, -0.807752817926190360f, 0.589366423141498790f, - -0.807865842373222120f, - 0.589211505972615070f, -0.807978837117336310f, 0.589056567140108460f, - -0.808091802154378260f, - 0.588901606649675840f, -0.808204737480194720f, 0.588746624507014650f, - -0.808317643090633250f, - 0.588591620717822890f, -0.808430518981542720f, 0.588436595287799900f, - -0.808543365148773010f, - 0.588281548222645330f, -0.808656181588174980f, 0.588126479528059850f, - -0.808768968295600850f, - 0.587971389209745120f, -0.808881725266903610f, 0.587816277273403020f, - -0.808994452497937560f, - 0.587661143724736770f, -0.809107149984558130f, 0.587505988569450020f, - -0.809219817722621750f, - 0.587350811813247660f, -0.809332455707985840f, 0.587195613461834910f, - -0.809445063936509170f, - 0.587040393520918080f, -0.809557642404051260f, 0.586885151996203950f, - -0.809670191106473090f, - 0.586729888893400500f, -0.809782710039636420f, 0.586574604218216280f, - -0.809895199199404450f, - 0.586419297976360500f, -0.810007658581641140f, 0.586263970173543700f, - -0.810120088182211600f, - 0.586108620815476430f, -0.810232487996982330f, 0.585953249907870680f, - -0.810344858021820550f, - 0.585797857456438860f, -0.810457198252594770f, 0.585642443466894420f, - -0.810569508685174630f, - 0.585487007944951450f, -0.810681789315430670f, 0.585331550896324940f, - -0.810794040139234730f, - 0.585176072326730410f, -0.810906261152459670f, 0.585020572241884530f, - -0.811018452350979470f, - 0.584865050647504490f, -0.811130613730669190f, 0.584709507549308500f, - -0.811242745287404810f, - 0.584553942953015330f, -0.811354847017063730f, 0.584398356864344710f, - -0.811466918915524250f, - 0.584242749289016980f, -0.811578960978665890f, 0.584087120232753550f, - -0.811690973202369050f, - 0.583931469701276300f, -0.811802955582515360f, 0.583775797700308070f, - -0.811914908114987680f, - 0.583620104235572760f, -0.812026830795669730f, 0.583464389312794430f, - -0.812138723620446480f, - 0.583308652937698290f, -0.812250586585203880f, 0.583152895116010540f, - -0.812362419685829120f, - 0.582997115853457700f, -0.812474222918210480f, 0.582841315155767650f, - -0.812585996278237020f, - 0.582685493028668460f, -0.812697739761799490f, 0.582529649477889320f, - -0.812809453364789160f, - 0.582373784509160220f, -0.812921137083098770f, 0.582217898128211790f, - -0.813032790912621930f, - 0.582061990340775550f, -0.813144414849253590f, 0.581906061152583920f, - -0.813256008888889380f, - 0.581750110569369760f, -0.813367573027426570f, 0.581594138596866930f, - -0.813479107260763220f, - 0.581438145240810280f, -0.813590611584798510f, 0.581282130506935110f, - -0.813702085995432700f, - 0.581126094400977620f, -0.813813530488567190f, 0.580970036928674880f, - -0.813924945060104490f, - 0.580813958095764530f, -0.814036329705948300f, 0.580657857907985410f, - -0.814147684422003360f, - 0.580501736371076600f, -0.814259009204175270f, 0.580345593490778300f, - -0.814370304048371070f, - 0.580189429272831680f, -0.814481568950498610f, 0.580033243722978150f, - -0.814592803906467270f, - 0.579877036846960350f, -0.814704008912187080f, 0.579720808650521560f, - -0.814815183963569330f, - 0.579564559139405740f, -0.814926329056526620f, 0.579408288319357980f, - -0.815037444186972220f, - 0.579251996196123550f, -0.815148529350820830f, 0.579095682775449210f, - -0.815259584543988280f, - 0.578939348063081890f, -0.815370609762391290f, 0.578782992064769690f, - -0.815481605001947770f, - 0.578626614786261430f, -0.815592570258576680f, 0.578470216233306740f, - -0.815703505528198260f, - 0.578313796411655590f, -0.815814410806733780f, 0.578157355327059360f, - -0.815925286090105390f, - 0.578000892985269910f, -0.816036131374236700f, 0.577844409392039850f, - -0.816146946655052160f, - 0.577687904553122800f, -0.816257731928477390f, 0.577531378474272830f, - -0.816368487190439200f, - 0.577374831161244880f, -0.816479212436865390f, 0.577218262619794920f, - -0.816589907663684890f, - 0.577061672855679550f, -0.816700572866827850f, 0.576905061874655960f, - -0.816811208042225290f, - 0.576748429682482520f, -0.816921813185809480f, 0.576591776284917870f, - -0.817032388293513880f, - 0.576435101687721830f, -0.817142933361272970f, 0.576278405896654910f, - -0.817253448385022230f, - 0.576121688917478390f, -0.817363933360698460f, 0.575964950755954330f, - -0.817474388284239240f, - 0.575808191417845340f, -0.817584813151583710f, 0.575651410908915250f, - -0.817695207958671680f, - 0.575494609234928230f, -0.817805572701444270f, 0.575337786401649560f, - -0.817915907375843740f, - 0.575180942414845190f, -0.818026211977813440f, 0.575024077280281820f, - -0.818136486503297620f, - 0.574867191003726740f, -0.818246730948241960f, 0.574710283590948450f, - -0.818356945308593150f, - 0.574553355047715760f, -0.818467129580298660f, 0.574396405379798750f, - -0.818577283759307490f, - 0.574239434592967890f, -0.818687407841569570f, 0.574082442692994470f, - -0.818797501823036010f, - 0.573925429685650750f, -0.818907565699658950f, 0.573768395576709560f, - -0.819017599467391500f, - 0.573611340371944610f, -0.819127603122188240f, 0.573454264077130400f, - -0.819237576660004520f, - 0.573297166698042320f, -0.819347520076796900f, 0.573140048240456060f, - -0.819457433368523280f, - 0.572982908710148680f, -0.819567316531142230f, 0.572825748112897550f, - -0.819677169560613760f, - 0.572668566454481160f, -0.819786992452898990f, 0.572511363740678790f, - -0.819896785203959810f, - 0.572354139977270030f, -0.820006547809759680f, 0.572196895170035580f, - -0.820116280266262710f, - 0.572039629324757050f, -0.820225982569434690f, 0.571882342447216590f, - -0.820335654715241840f, - 0.571725034543197120f, -0.820445296699652050f, 0.571567705618482580f, - -0.820554908518633890f, - 0.571410355678857340f, -0.820664490168157460f, 0.571252984730106660f, - -0.820774041644193650f, - 0.571095592778016690f, -0.820883562942714580f, 0.570938179828374360f, - -0.820993054059693470f, - 0.570780745886967370f, -0.821102514991104650f, 0.570623290959583860f, - -0.821211945732923550f, - 0.570465815052012990f, -0.821321346281126740f, 0.570308318170045010f, - -0.821430716631691760f, - 0.570150800319470300f, -0.821540056780597610f, 0.569993261506080650f, - -0.821649366723823830f, - 0.569835701735668110f, -0.821758646457351640f, 0.569678121014025710f, - -0.821867895977163140f, - 0.569520519346947250f, -0.821977115279241550f, 0.569362896740227330f, - -0.822086304359571090f, - 0.569205253199661200f, -0.822195463214137170f, 0.569047588731045220f, - -0.822304591838926350f, - 0.568889903340175970f, -0.822413690229926390f, 0.568732197032851160f, - -0.822522758383125940f, - 0.568574469814869250f, -0.822631796294514990f, 0.568416721692029390f, - -0.822740803960084420f, - 0.568258952670131490f, -0.822849781375826320f, 0.568101162754976570f, - -0.822958728537734000f, - 0.567943351952365670f, -0.823067645441801670f, 0.567785520268101250f, - -0.823176532084024860f, - 0.567627667707986230f, -0.823285388460400110f, 0.567469794277824620f, - -0.823394214566925080f, - 0.567311899983420800f, -0.823503010399598390f, 0.567153984830580100f, - -0.823611775954420260f, - 0.566996048825108680f, -0.823720511227391320f, 0.566838091972813320f, - -0.823829216214513990f, - 0.566680114279501710f, -0.823937890911791370f, 0.566522115750982100f, - -0.824046535315227760f, - 0.566364096393063950f, -0.824155149420828570f, 0.566206056211556840f, - -0.824263733224600450f, - 0.566047995212271560f, -0.824372286722551250f, 0.565889913401019570f, - -0.824480809910689500f, - 0.565731810783613230f, -0.824589302785025290f, 0.565573687365865440f, - -0.824697765341569470f, - 0.565415543153589770f, -0.824806197576334330f, 0.565257378152600910f, - -0.824914599485333080f, - 0.565099192368714090f, -0.825022971064580220f, 0.564940985807745320f, - -0.825131312310090960f, - 0.564782758475511400f, -0.825239623217882130f, 0.564624510377830120f, - -0.825347903783971380f, - 0.564466241520519500f, -0.825456154004377440f, 0.564307951909398750f, - -0.825564373875120490f, - 0.564149641550287680f, -0.825672563392221390f, 0.563991310449007080f, - -0.825780722551702430f, - 0.563832958611378170f, -0.825888851349586780f, 0.563674586043223180f, - -0.825996949781898970f, - 0.563516192750364910f, -0.826105017844664610f, 0.563357778738627020f, - -0.826213055533910110f, - 0.563199344013834090f, -0.826321062845663420f, 0.563040888581811230f, - -0.826429039775953390f, - 0.562882412448384550f, -0.826536986320809960f, 0.562723915619380400f, - -0.826644902476264210f, - 0.562565398100626560f, -0.826752788238348520f, 0.562406859897951140f, - -0.826860643603096080f, - 0.562248301017183150f, -0.826968468566541490f, 0.562089721464152480f, - -0.827076263124720270f, - 0.561931121244689470f, -0.827184027273669020f, 0.561772500364625450f, - -0.827291761009425810f, - 0.561613858829792420f, -0.827399464328029350f, 0.561455196646023280f, - -0.827507137225519830f, - 0.561296513819151470f, -0.827614779697938400f, 0.561137810355011530f, - -0.827722391741327220f, - 0.560979086259438260f, -0.827829973351729810f, 0.560820341538267540f, - -0.827937524525190870f, - 0.560661576197336030f, -0.828045045257755800f, 0.560502790242481060f, - -0.828152535545471410f, - 0.560343983679540860f, -0.828259995384385550f, 0.560185156514354080f, - -0.828367424770547480f, - 0.560026308752760380f, -0.828474823700007130f, 0.559867440400600320f, - -0.828582192168815790f, - 0.559708551463714790f, -0.828689530173025710f, 0.559549641947945870f, - -0.828796837708690610f, - 0.559390711859136140f, -0.828904114771864870f, 0.559231761203129010f, - -0.829011361358604430f, - 0.559072789985768480f, -0.829118577464965980f, 0.558913798212899770f, - -0.829225763087007570f, - 0.558754785890368310f, -0.829332918220788250f, 0.558595753024020760f, - -0.829440042862368170f, - 0.558436699619704100f, -0.829547137007808800f, 0.558277625683266330f, - -0.829654200653172640f, - 0.558118531220556100f, -0.829761233794523050f, 0.557959416237422960f, - -0.829868236427924840f, - 0.557800280739717100f, -0.829975208549443840f, 0.557641124733289420f, - -0.830082150155146970f, - 0.557481948223991660f, -0.830189061241102370f, 0.557322751217676160f, - -0.830295941803379070f, - 0.557163533720196340f, -0.830402791838047550f, 0.557004295737406060f, - -0.830509611341179070f, - 0.556845037275160100f, -0.830616400308846200f, 0.556685758339313890f, - -0.830723158737122880f, - 0.556526458935723720f, -0.830829886622083570f, 0.556367139070246490f, - -0.830936583959804410f, - 0.556207798748739930f, -0.831043250746362320f, 0.556048437977062720f, - -0.831149886977835430f, - 0.555889056761073920f, -0.831256492650303210f, 0.555729655106633520f, - -0.831363067759845920f, - 0.555570233019602290f, -0.831469612302545240f, 0.555410790505841740f, - -0.831576126274483630f, - 0.555251327571214090f, -0.831682609671745120f, 0.555091844221582420f, - -0.831789062490414400f, - 0.554932340462810370f, -0.831895484726577590f, 0.554772816300762580f, - -0.832001876376321840f, - 0.554613271741304040f, -0.832108237435735480f, 0.554453706790301040f, - -0.832214567900907980f, - 0.554294121453620110f, -0.832320867767929680f, 0.554134515737128910f, - -0.832427137032892280f, - 0.553974889646695610f, -0.832533375691888680f, 0.553815243188189090f, - -0.832639583741012770f, - 0.553655576367479310f, -0.832745761176359460f, 0.553495889190436570f, - -0.832851907994024980f, - 0.553336181662932410f, -0.832958024190106670f, 0.553176453790838460f, - -0.833064109760702890f, - 0.553016705580027580f, -0.833170164701913190f, 0.552856937036373290f, - -0.833276189009838240f, - 0.552697148165749770f, -0.833382182680579730f, 0.552537338974032120f, - -0.833488145710240770f, - 0.552377509467096070f, -0.833594078094925140f, 0.552217659650817930f, - -0.833699979830738290f, - 0.552057789531074980f, -0.833805850913786340f, 0.551897899113745320f, - -0.833911691340176730f, - 0.551737988404707450f, -0.834017501106018130f, 0.551578057409841000f, - -0.834123280207419990f, - 0.551418106135026060f, -0.834229028640493420f, 0.551258134586143700f, - -0.834334746401350080f, - 0.551098142769075430f, -0.834440433486103190f, 0.550938130689703880f, - -0.834546089890866760f, - 0.550778098353912230f, -0.834651715611756330f, 0.550618045767584330f, - -0.834757310644888230f, - 0.550457972936604810f, -0.834862874986380010f, 0.550297879866859190f, - -0.834968408632350450f, - 0.550137766564233630f, -0.835073911578919300f, 0.549977633034615000f, - -0.835179383822207580f, - 0.549817479283891020f, -0.835284825358337370f, 0.549657305317949980f, - -0.835390236183431780f, - 0.549497111142680960f, -0.835495616293615350f, 0.549336896763974010f, - -0.835600965685013410f, - 0.549176662187719770f, -0.835706284353752600f, 0.549016407419809390f, - -0.835811572295960590f, - 0.548856132466135290f, -0.835916829507766360f, 0.548695837332590090f, - -0.836022055985299880f, - 0.548535522025067390f, -0.836127251724692160f, 0.548375186549461600f, - -0.836232416722075600f, - 0.548214830911667780f, -0.836337550973583530f, 0.548054455117581880f, - -0.836442654475350380f, - 0.547894059173100190f, -0.836547727223511890f, 0.547733643084120200f, - -0.836652769214204950f, - 0.547573206856539870f, -0.836757780443567190f, 0.547412750496257930f, - -0.836862760907737810f, - 0.547252274009174090f, -0.836967710602857020f, 0.547091777401188530f, - -0.837072629525066000f, - 0.546931260678202190f, -0.837177517670507190f, 0.546770723846116800f, - -0.837282375035324320f, - 0.546610166910834860f, -0.837387201615661940f, 0.546449589878259760f, - -0.837491997407665890f, - 0.546288992754295210f, -0.837596762407483040f, 0.546128375544846060f, - -0.837701496611261700f, - 0.545967738255817680f, -0.837806200015150940f, 0.545807080893116140f, - -0.837910872615301060f, - 0.545646403462648590f, -0.838015514407863700f, 0.545485705970322530f, - -0.838120125388991500f, - 0.545324988422046460f, -0.838224705554837970f, 0.545164250823729320f, - -0.838329254901558300f, - 0.545003493181281160f, -0.838433773425308340f, 0.544842715500612470f, - -0.838538261122245170f, - 0.544681917787634530f, -0.838642717988527300f, 0.544521100048259710f, - -0.838747144020313920f, - 0.544360262288400400f, -0.838851539213765760f, 0.544199404513970420f, - -0.838955903565044350f, - 0.544038526730883930f, -0.839060237070312630f, 0.543877628945055980f, - -0.839164539725734570f, - 0.543716711162402390f, -0.839268811527475230f, 0.543555773388839650f, - -0.839373052471700690f, - 0.543394815630284800f, -0.839477262554578550f, 0.543233837892656000f, - -0.839581441772277120f, - 0.543072840181871850f, -0.839685590120966110f, 0.542911822503851730f, - -0.839789707596816260f, - 0.542750784864516000f, -0.839893794195999410f, 0.542589727269785270f, - -0.839997849914688730f, - 0.542428649725581360f, -0.840101874749058400f, 0.542267552237826520f, - -0.840205868695283580f, - 0.542106434812444030f, -0.840309831749540770f, 0.541945297455357470f, - -0.840413763908007480f, - 0.541784140172491660f, -0.840517665166862440f, 0.541622962969771640f, - -0.840621535522285690f, - 0.541461765853123560f, -0.840725374970458070f, 0.541300548828474120f, - -0.840829183507561640f, - 0.541139311901750910f, -0.840932961129779670f, 0.540978055078882190f, - -0.841036707833296650f, - 0.540816778365796670f, -0.841140423614298080f, 0.540655481768424260f, - -0.841244108468970580f, - 0.540494165292695230f, -0.841347762393501950f, 0.540332828944540820f, - -0.841451385384081260f, - 0.540171472729892970f, -0.841554977436898330f, 0.540010096654684020f, - -0.841658538548144760f, - 0.539848700724847700f, -0.841762068714012490f, 0.539687284946317570f, - -0.841865567930695340f, - 0.539525849325029010f, -0.841969036194387680f, 0.539364393866917150f, - -0.842072473501285450f, - 0.539202918577918240f, -0.842175879847585570f, 0.539041423463969550f, - -0.842279255229485880f, - 0.538879908531008420f, -0.842382599643185960f, 0.538718373784973670f, - -0.842485913084885630f, - 0.538556819231804210f, -0.842589195550786600f, 0.538395244877439950f, - -0.842692447037091560f, - 0.538233650727821700f, -0.842795667540004120f, 0.538072036788890600f, - -0.842898857055729310f, - 0.537910403066588990f, -0.843002015580472830f, 0.537748749566859470f, - -0.843105143110442050f, - 0.537587076295645510f, -0.843208239641845440f, 0.537425383258891660f, - -0.843311305170892030f, - 0.537263670462542530f, -0.843414339693792760f, 0.537101937912544240f, - -0.843517343206759080f, - 0.536940185614843020f, -0.843620315706004040f, 0.536778413575385920f, - -0.843723257187741550f, - 0.536616621800121150f, -0.843826167648186740f, 0.536454810294997090f, - -0.843929047083555870f, - 0.536292979065963180f, -0.844031895490066410f, 0.536131128118969350f, - -0.844134712863936930f, - 0.535969257459966710f, -0.844237499201387020f, 0.535807367094906620f, - -0.844340254498637590f, - 0.535645457029741090f, -0.844442978751910660f, 0.535483527270423370f, - -0.844545671957429240f, - 0.535321577822907010f, -0.844648334111417820f, 0.535159608693146720f, - -0.844750965210101510f, - 0.534997619887097260f, -0.844853565249707010f, 0.534835611410714670f, - -0.844956134226462100f, - 0.534673583269955510f, -0.845058672136595470f, 0.534511535470777010f, - -0.845161178976337140f, - 0.534349468019137520f, -0.845263654741918220f, 0.534187380920995600f, - -0.845366099429570970f, - 0.534025274182310380f, -0.845468513035528830f, 0.533863147809042650f, - -0.845570895556026270f, - 0.533701001807152960f, -0.845673246987299070f, 0.533538836182603120f, - -0.845775567325583900f, - 0.533376650941355560f, -0.845877856567118890f, 0.533214446089372960f, - -0.845980114708143270f, - 0.533052221632619670f, -0.846082341744896940f, 0.532889977577059690f, - -0.846184537673621670f, - 0.532727713928658810f, -0.846286702490559710f, 0.532565430693382580f, - -0.846388836191954930f, - 0.532403127877198010f, -0.846490938774052020f, 0.532240805486072330f, - -0.846593010233097190f, - 0.532078463525973540f, -0.846695050565337450f, 0.531916102002870760f, - -0.846797059767020910f, - 0.531753720922733320f, -0.846899037834397350f, 0.531591320291531780f, - -0.847000984763716880f, - 0.531428900115236910f, -0.847102900551231500f, 0.531266460399820390f, - -0.847204785193193980f, - 0.531104001151255000f, -0.847306638685858320f, 0.530941522375513510f, - -0.847408461025479730f, - 0.530779024078570250f, -0.847510252208314330f, 0.530616506266399450f, - -0.847612012230619660f, - 0.530453968944976320f, -0.847713741088654270f, 0.530291412120277420f, - -0.847815438778677930f, - 0.530128835798278850f, -0.847917105296951410f, 0.529966239984958620f, - -0.848018740639736810f, - 0.529803624686294830f, -0.848120344803297120f, 0.529640989908265910f, - -0.848221917783896990f, - 0.529478335656852090f, -0.848323459577801530f, 0.529315661938033140f, - -0.848424970181277600f, - 0.529152968757790720f, -0.848526449590592650f, 0.528990256122106040f, - -0.848627897802015860f, - 0.528827524036961980f, -0.848729314811817010f, 0.528664772508341540f, - -0.848830700616267530f, - 0.528502001542228480f, -0.848932055211639610f, 0.528339211144607690f, - -0.849033378594206690f, - 0.528176401321464370f, -0.849134670760243630f, 0.528013572078784740f, - -0.849235931706025960f, - 0.527850723422555460f, -0.849337161427830670f, 0.527687855358763720f, - -0.849438359921935950f, - 0.527524967893398200f, -0.849539527184620890f, 0.527362061032447430f, - -0.849640663212165910f, - 0.527199134781901390f, -0.849741768000852440f, 0.527036189147750190f, - -0.849842841546963210f, - 0.526873224135984700f, -0.849943883846782210f, 0.526710239752597010f, - -0.850044894896594070f, - 0.526547236003579330f, -0.850145874692685210f, 0.526384212894925210f, - -0.850246823231342710f, - 0.526221170432628170f, -0.850347740508854980f, 0.526058108622682760f, - -0.850448626521511650f, - 0.525895027471084740f, -0.850549481265603370f, 0.525731926983829640f, - -0.850650304737422200f, - 0.525568807166914680f, -0.850751096933260790f, 0.525405668026336810f, - -0.850851857849413640f, - 0.525242509568094710f, -0.850952587482175730f, 0.525079331798186890f, - -0.851053285827843790f, - 0.524916134722612890f, -0.851153952882715340f, 0.524752918347373360f, - -0.851254588643089120f, - 0.524589682678468840f, -0.851355193105265200f, 0.524426427721901510f, - -0.851455766265544310f, - 0.524263153483673470f, -0.851556308120228870f, 0.524099859969787810f, - -0.851656818665622370f, - 0.523936547186248600f, -0.851757297898029120f, 0.523773215139060170f, - -0.851857745813754840f, - 0.523609863834228030f, -0.851958162409106380f, 0.523446493277757940f, - -0.852058547680391580f, - 0.523283103475656430f, -0.852158901623919830f, 0.523119694433931250f, - -0.852259224236001090f, - 0.522956266158590140f, -0.852359515512947090f, 0.522792818655642200f, - -0.852459775451070100f, - 0.522629351931096720f, -0.852560004046683970f, 0.522465865990963900f, - -0.852660201296103760f, - 0.522302360841254700f, -0.852760367195645300f, 0.522138836487980650f, - -0.852860501741625860f, - 0.521975292937154390f, -0.852960604930363630f, 0.521811730194788550f, - -0.853060676758178320f, - 0.521648148266897090f, -0.853160717221390420f, 0.521484547159494550f, - -0.853260726316321770f, - 0.521320926878595550f, -0.853360704039295430f, 0.521157287430216610f, - -0.853460650386635320f, - 0.520993628820373810f, -0.853560565354666840f, 0.520829951055084780f, - -0.853660448939716270f, - 0.520666254140367270f, -0.853760301138111300f, 0.520502538082239790f, - -0.853860121946180660f, - 0.520338802886721960f, -0.853959911360254060f, 0.520175048559833760f, - -0.854059669376662780f, - 0.520011275107596040f, -0.854159395991738730f, 0.519847482536030300f, - -0.854259091201815420f, - 0.519683670851158520f, -0.854358755003227440f, 0.519519840059003870f, - -0.854458387392310060f, - 0.519355990165589530f, -0.854557988365400530f, 0.519192121176940360f, - -0.854657557918836460f, - 0.519028233099080970f, -0.854757096048957110f, 0.518864325938037000f, - -0.854856602752102850f, - 0.518700399699835170f, -0.854956078024614820f, 0.518536454390502110f, - -0.855055521862835950f, - 0.518372490016066220f, -0.855154934263109620f, 0.518208506582555460f, - -0.855254315221781080f, - 0.518044504095999340f, -0.855353664735196030f, 0.517880482562427800f, - -0.855452982799701830f, - 0.517716441987871150f, -0.855552269411646970f, 0.517552382378360990f, - -0.855651524567380690f, - 0.517388303739929060f, -0.855750748263253920f, 0.517224206078608310f, - -0.855849940495618240f, - 0.517060089400432130f, -0.855949101260826790f, 0.516895953711434260f, - -0.856048230555233820f, - 0.516731799017649980f, -0.856147328375194470f, 0.516567625325114350f, - -0.856246394717065210f, - 0.516403432639863990f, -0.856345429577203610f, 0.516239220967935620f, - -0.856444432951968480f, - 0.516074990315366630f, -0.856543404837719960f, 0.515910740688195650f, - -0.856642345230818720f, - 0.515746472092461380f, -0.856741254127627470f, 0.515582184534203790f, - -0.856840131524509220f, - 0.515417878019463150f, -0.856938977417828650f, 0.515253552554280290f, - -0.857037791803951680f, - 0.515089208144697270f, -0.857136574679244870f, 0.514924844796756490f, - -0.857235326040076460f, - 0.514760462516501200f, -0.857334045882815590f, 0.514596061309975040f, - -0.857432734203832700f, - 0.514431641183222930f, -0.857531390999499040f, 0.514267202142289830f, - -0.857630016266187620f, - 0.514102744193221660f, -0.857728610000272120f, 0.513938267342065490f, - -0.857827172198127320f, - 0.513773771594868030f, -0.857925702856129790f, 0.513609256957677900f, - -0.858024201970656540f, - 0.513444723436543570f, -0.858122669538086020f, 0.513280171037514330f, - -0.858221105554798250f, - 0.513115599766640560f, -0.858319510017173440f, 0.512951009629972860f, - -0.858417882921594040f, - 0.512786400633563070f, -0.858516224264442740f, 0.512621772783463100f, - -0.858614534042104080f, - 0.512457126085725800f, -0.858712812250963520f, 0.512292460546404980f, - -0.858811058887407500f, - 0.512127776171554690f, -0.858909273947823900f, 0.511963072967230200f, - -0.859007457428601410f, - 0.511798350939487000f, -0.859105609326130340f, 0.511633610094381350f, - -0.859203729636801920f, - 0.511468850437970520f, -0.859301818357008360f, 0.511304071976311890f, - -0.859399875483143450f, - 0.511139274715464390f, -0.859497901011601620f, 0.510974458661486720f, - -0.859595894938779080f, - 0.510809623820439040f, -0.859693857261072610f, 0.510644770198381730f, - -0.859791787974880540f, - 0.510479897801375700f, -0.859889687076602290f, 0.510315006635483350f, - -0.859987554562638200f, - 0.510150096706766700f, -0.860085390429390140f, 0.509985168021289570f, - -0.860183194673260880f, - 0.509820220585115560f, -0.860280967290654510f, 0.509655254404309250f, - -0.860378708277976130f, - 0.509490269484936360f, -0.860476417631632070f, 0.509325265833062480f, - -0.860574095348029980f, - 0.509160243454754750f, -0.860671741423578380f, 0.508995202356080310f, - -0.860769355854687060f, - 0.508830142543106990f, -0.860866938637767310f, 0.508665064021904260f, - -0.860964489769230900f, - 0.508499966798540810f, -0.861062009245491480f, 0.508334850879087470f, - -0.861159497062963350f, - 0.508169716269614710f, -0.861256953218062060f, 0.508004562976194010f, - -0.861354377707204800f, - 0.507839391004897940f, -0.861451770526809210f, 0.507674200361798890f, - -0.861549131673294720f, - 0.507508991052970870f, -0.861646461143081300f, 0.507343763084487920f, - -0.861743758932590700f, - 0.507178516462425290f, -0.861841025038245330f, 0.507013251192858340f, - -0.861938259456469180f, - 0.506847967281863320f, -0.862035462183687210f, 0.506682664735517600f, - -0.862132633216325380f, - 0.506517343559898530f, -0.862229772550811240f, 0.506352003761084800f, - -0.862326880183573060f, - 0.506186645345155450f, -0.862423956111040500f, 0.506021268318189830f, - -0.862521000329644520f, - 0.505855872686268860f, -0.862618012835816740f, 0.505690458455473340f, - -0.862714993625990690f, - 0.505525025631885510f, -0.862811942696600330f, 0.505359574221587390f, - -0.862908860044081290f, - 0.505194104230662240f, -0.863005745664870210f, 0.505028615665194300f, - -0.863102599555404800f, - 0.504863108531267480f, -0.863199421712124160f, 0.504697582834967680f, - -0.863296212131468230f, - 0.504532038582380380f, -0.863392970809878310f, 0.504366475779592150f, - -0.863489697743797140f, - 0.504200894432690560f, -0.863586392929667990f, 0.504035294547763080f, - -0.863683056363935940f, - 0.503869676130898950f, -0.863779688043046610f, 0.503704039188186960f, - -0.863876287963447510f, - 0.503538383725717580f, -0.863972856121586700f, 0.503372709749581150f, - -0.864069392513913680f, - 0.503207017265869030f, -0.864165897136879300f, 0.503041306280673450f, - -0.864262369986934950f, - 0.502875576800086880f, -0.864358811060534030f, 0.502709828830203100f, - -0.864455220354130250f, - 0.502544062377115800f, -0.864551597864179230f, 0.502378277446919870f, - -0.864647943587137480f, - 0.502212474045710900f, -0.864744257519462380f, 0.502046652179584660f, - -0.864840539657612980f, - 0.501880811854638400f, -0.864936789998049020f, 0.501714953076969230f, - -0.865033008537231750f, - 0.501549075852675390f, -0.865129195271623690f, 0.501383180187855880f, - -0.865225350197688090f, - 0.501217266088609950f, -0.865321473311889800f, 0.501051333561038040f, - -0.865417564610694410f, - 0.500885382611240940f, -0.865513624090568980f, 0.500719413245319880f, - -0.865609651747981880f, - 0.500553425469377640f, -0.865705647579402270f, 0.500387419289516580f, - -0.865801611581300760f, - 0.500221394711840680f, -0.865897543750148820f, 0.500055351742453860f, - -0.865993444082419520f, - 0.499889290387461380f, -0.866089312574586770f, 0.499723210652968710f, - -0.866185149223125730f, - 0.499557112545081890f, -0.866280954024512990f, 0.499390996069908220f, - -0.866376726975225830f, - 0.499224861233555030f, -0.866472468071743050f, 0.499058708042130930f, - -0.866568177310544360f, - 0.498892536501744750f, -0.866663854688111020f, 0.498726346618505960f, - -0.866759500200925290f, - 0.498560138398525200f, -0.866855113845470320f, 0.498393911847913150f, - -0.866950695618231020f, - 0.498227666972781870f, -0.867046245515692650f, 0.498061403779243520f, - -0.867141763534342360f, - 0.497895122273410930f, -0.867237249670668400f, 0.497728822461398100f, - -0.867332703921159690f, - 0.497562504349319090f, -0.867428126282306920f, 0.497396167943289340f, - -0.867523516750601460f, - 0.497229813249424340f, -0.867618875322536230f, 0.497063440273840310f, - -0.867714201994605140f, - 0.496897049022654640f, -0.867809496763303210f, 0.496730639501984710f, - -0.867904759625126920f, - 0.496564211717949340f, -0.867999990576573400f, 0.496397765676667160f, - -0.868095189614141670f, - 0.496231301384258310f, -0.868190356734331310f, 0.496064818846843060f, - -0.868285491933643240f, - 0.495898318070542240f, -0.868380595208579800f, 0.495731799061478020f, - -0.868475666555644120f, - 0.495565261825772490f, -0.868570705971340900f, 0.495398706369549080f, - -0.868665713452175580f, - 0.495232132698931350f, -0.868760688994655190f, 0.495065540820043610f, - -0.868855632595287750f, - 0.494898930739011310f, -0.868950544250582380f, 0.494732302461959820f, - -0.869045423957049530f, - 0.494565655995016010f, -0.869140271711200560f, 0.494398991344306760f, - -0.869235087509548250f, - 0.494232308515959730f, -0.869329871348606730f, 0.494065607516103730f, - -0.869424623224890780f, - 0.493898888350867430f, -0.869519343134916970f, 0.493732151026381070f, - -0.869614031075202300f, - 0.493565395548774880f, -0.869708687042265560f, 0.493398621924179830f, - -0.869803311032626650f, - 0.493231830158728070f, -0.869897903042806340f, 0.493065020258551650f, - -0.869992463069326870f, - 0.492898192229784090f, -0.870086991108711350f, 0.492731346078558840f, - -0.870181487157484560f, - 0.492564481811010650f, -0.870275951212171830f, 0.492397599433274550f, - -0.870370383269300160f, - 0.492230698951486080f, -0.870464783325397670f, 0.492063780371782060f, - -0.870559151376993250f, - 0.491896843700299240f, -0.870653487420617540f, 0.491729888943175820f, - -0.870747791452801790f, - 0.491562916106550060f, -0.870842063470078860f, 0.491395925196560830f, - -0.870936303468982760f, - 0.491228916219348330f, -0.871030511446048260f, 0.491061889181052590f, - -0.871124687397811900f, - 0.490894844087815140f, -0.871218831320810900f, 0.490727780945777570f, - -0.871312943211583920f, - 0.490560699761082080f, -0.871407023066670950f, 0.490393600539872130f, - -0.871501070882612530f, - 0.490226483288291100f, -0.871595086655951090f, 0.490059348012483910f, - -0.871689070383229740f, - 0.489892194718595300f, -0.871783022060993010f, 0.489725023412770970f, - -0.871876941685786890f, - 0.489557834101157550f, -0.871970829254157700f, 0.489390626789901920f, - -0.872064684762653970f, - 0.489223401485152030f, -0.872158508207824480f, 0.489056158193055980f, - -0.872252299586219860f, - 0.488888896919763230f, -0.872346058894391540f, 0.488721617671423250f, - -0.872439786128892280f, - 0.488554320454186230f, -0.872533481286276060f, 0.488387005274203590f, - -0.872627144363097960f, - 0.488219672137626740f, -0.872720775355914300f, 0.488052321050608310f, - -0.872814374261282390f, - 0.487884952019301210f, -0.872907941075760970f, 0.487717565049858860f, - -0.873001475795909920f, - 0.487550160148436050f, -0.873094978418290090f, 0.487382737321187310f, - -0.873188448939463790f, - 0.487215296574268820f, -0.873281887355994210f, 0.487047837913836550f, - -0.873375293664446000f, - 0.486880361346047400f, -0.873468667861384880f, 0.486712866877059340f, - -0.873562009943377740f, - 0.486545354513030270f, -0.873655319906992630f, 0.486377824260119500f, - -0.873748597748798870f, - 0.486210276124486530f, -0.873841843465366750f, 0.486042710112291390f, - -0.873935057053268130f, - 0.485875126229695420f, -0.874028238509075630f, 0.485707524482859750f, - -0.874121387829363330f, - 0.485539904877947020f, -0.874214505010706300f, 0.485372267421119770f, - -0.874307590049680950f, - 0.485204612118541880f, -0.874400642942864790f, 0.485036938976377450f, - -0.874493663686836450f, - 0.484869248000791120f, -0.874586652278176110f, 0.484701539197948730f, - -0.874679608713464510f, - 0.484533812574016120f, -0.874772532989284150f, 0.484366068135160480f, - -0.874865425102218210f, - 0.484198305887549140f, -0.874958285048851540f, 0.484030525837350010f, - -0.875051112825769970f, - 0.483862727990732320f, -0.875143908429560250f, 0.483694912353865080f, - -0.875236671856810870f, - 0.483527078932918740f, -0.875329403104110780f, 0.483359227734063980f, - -0.875422102168050830f, - 0.483191358763471910f, -0.875514769045222740f, 0.483023472027315050f, - -0.875607403732219240f, - 0.482855567531765670f, -0.875700006225634600f, 0.482687645282997510f, - -0.875792576522063880f, - 0.482519705287184520f, -0.875885114618103700f, 0.482351747550501030f, - -0.875977620510351660f, - 0.482183772079122830f, -0.876070094195406600f, 0.482015778879225530f, - -0.876162535669868460f, - 0.481847767956986080f, -0.876254944930338400f, 0.481679739318581490f, - -0.876347321973419020f, - 0.481511692970189920f, -0.876439666795713610f, 0.481343628917989870f, - -0.876531979393827100f, - 0.481175547168160360f, -0.876624259764365310f, 0.481007447726881640f, - -0.876716507903935400f, - 0.480839330600333900f, -0.876808723809145760f, 0.480671195794698690f, - -0.876900907476605650f, - 0.480503043316157670f, -0.876993058902925780f, 0.480334873170893070f, - -0.877085178084718310f, - 0.480166685365088440f, -0.877177265018595940f, 0.479998479904927220f, - -0.877269319701173170f, - 0.479830256796594250f, -0.877361342129065140f, 0.479662016046274340f, - -0.877453332298888560f, - 0.479493757660153060f, -0.877545290207261240f, 0.479325481644417130f, - -0.877637215850802120f, - 0.479157188005253310f, -0.877729109226131570f, 0.478988876748849550f, - -0.877820970329870500f, - 0.478820547881394050f, -0.877912799158641730f, 0.478652201409075550f, - -0.878004595709069080f, - 0.478483837338084080f, -0.878096359977777130f, 0.478315455674609480f, - -0.878188091961392250f, - 0.478147056424843120f, -0.878279791656541460f, 0.477978639594976110f, - -0.878371459059853590f, - 0.477810205191201040f, -0.878463094167957870f, 0.477641753219710590f, - -0.878554696977485340f, - 0.477473283686698060f, -0.878646267485068130f, 0.477304796598358010f, - -0.878737805687339280f, - 0.477136291960884750f, -0.878829311580933360f, 0.476967769780474230f, - -0.878920785162485840f, - 0.476799230063322250f, -0.879012226428633410f, 0.476630672815625380f, - -0.879103635376014330f, - 0.476462098043581310f, -0.879195012001267370f, 0.476293505753387750f, - -0.879286356301033250f, - 0.476124895951243630f, -0.879377668271953180f, 0.475956268643348220f, - -0.879468947910670100f, - 0.475787623835901120f, -0.879560195213827890f, 0.475618961535103410f, - -0.879651410178071470f, - 0.475450281747155870f, -0.879742592800047410f, 0.475281584478260800f, - -0.879833743076402940f, - 0.475112869734620470f, -0.879924861003786860f, 0.474944137522437860f, - -0.880015946578848960f, - 0.474775387847917230f, -0.880106999798240360f, 0.474606620717262560f, - -0.880198020658613190f, - 0.474437836136679340f, -0.880289009156620890f, 0.474269034112372920f, - -0.880379965288918260f, - 0.474100214650550020f, -0.880470889052160750f, 0.473931377757417560f, - -0.880561780443005590f, - 0.473762523439182850f, -0.880652639458111010f, 0.473593651702054640f, - -0.880743466094136230f, - 0.473424762552241530f, -0.880834260347742040f, 0.473255855995953380f, - -0.880925022215589880f, - 0.473086932039400220f, -0.881015751694342760f, 0.472917990688792760f, - -0.881106448780665130f, - 0.472749031950342900f, -0.881197113471221980f, 0.472580055830262250f, - -0.881287745762680100f, - 0.472411062334764100f, -0.881378345651706810f, 0.472242051470061650f, - -0.881468913134971330f, - 0.472073023242368660f, -0.881559448209143780f, 0.471903977657900320f, - -0.881649950870895260f, - 0.471734914722871430f, -0.881740421116898320f, 0.471565834443498480f, - -0.881830858943826620f, - 0.471396736825997810f, -0.881921264348354940f, 0.471227621876586400f, - -0.882011637327159590f, - 0.471058489601482610f, -0.882101977876917580f, 0.470889340006904520f, - -0.882192285994307430f, - 0.470720173099071710f, -0.882282561676008600f, 0.470550988884203490f, - -0.882372804918702290f, - 0.470381787368520710f, -0.882463015719070040f, 0.470212568558244280f, - -0.882553194073795400f, - 0.470043332459595620f, -0.882643339979562790f, 0.469874079078797470f, - -0.882733453433057540f, - 0.469704808422072460f, -0.882823534430966730f, 0.469535520495644510f, - -0.882913582969978020f, - 0.469366215305737630f, -0.883003599046780720f, 0.469196892858576630f, - -0.883093582658065370f, - 0.469027553160387240f, -0.883183533800523280f, 0.468858196217395330f, - -0.883273452470847430f, - 0.468688822035827960f, -0.883363338665731580f, 0.468519430621912420f, - -0.883453192381870920f, - 0.468350021981876530f, -0.883543013615961880f, 0.468180596121949400f, - -0.883632802364701760f, - 0.468011153048359830f, -0.883722558624789660f, 0.467841692767338220f, - -0.883812282392925090f, - 0.467672215285114710f, -0.883901973665809470f, 0.467502720607920920f, - -0.883991632440144890f, - 0.467333208741988530f, -0.884081258712634990f, 0.467163679693549770f, - -0.884170852479984500f, - 0.466994133468838110f, -0.884260413738899080f, 0.466824570074086950f, - -0.884349942486086120f, - 0.466654989515530970f, -0.884439438718253700f, 0.466485391799405010f, - -0.884528902432111350f, - 0.466315776931944480f, -0.884618333624369920f, 0.466146144919386000f, - -0.884707732291740930f, - 0.465976495767966130f, -0.884797098430937790f, 0.465806829483922770f, - -0.884886432038674560f, - 0.465637146073493770f, -0.884975733111666660f, 0.465467445542917800f, - -0.885065001646630930f, - 0.465297727898434650f, -0.885154237640285110f, 0.465127993146283950f, - -0.885243441089348270f, - 0.464958241292706740f, -0.885332611990540590f, 0.464788472343944160f, - -0.885421750340583570f, - 0.464618686306237820f, -0.885510856136199950f, 0.464448883185830770f, - -0.885599929374113360f, - 0.464279062988965760f, -0.885688970051048960f, 0.464109225721887010f, - -0.885777978163732940f, - 0.463939371390838460f, -0.885866953708892790f, 0.463769500002065680f, - -0.885955896683257030f, - 0.463599611561814120f, -0.886044807083555490f, 0.463429706076329880f, - -0.886133684906519340f, - 0.463259783551860260f, -0.886222530148880640f, 0.463089843994652470f, - -0.886311342807372890f, - 0.462919887410955130f, -0.886400122878730490f, 0.462749913807016850f, - -0.886488870359689600f, - 0.462579923189086810f, -0.886577585246987040f, 0.462409915563415540f, - -0.886666267537360890f, - 0.462239890936253280f, -0.886754917227550950f, 0.462069849313851810f, - -0.886843534314297300f, - 0.461899790702462840f, -0.886932118794342080f, 0.461729715108338770f, - -0.887020670664428360f, - 0.461559622537733190f, -0.887109189921300060f, 0.461389512996899450f, - -0.887197676561702900f, - 0.461219386492092430f, -0.887286130582383150f, 0.461049243029567010f, - -0.887374551980088740f, - 0.460879082615578690f, -0.887462940751568840f, 0.460708905256384190f, - -0.887551296893573370f, - 0.460538710958240010f, -0.887639620402853930f, 0.460368499727404070f, - -0.887727911276163020f, - 0.460198271570134270f, -0.887816169510254550f, 0.460028026492689700f, - -0.887904395101883240f, - 0.459857764501329650f, -0.887992588047805560f, 0.459687485602313870f, - -0.888080748344778900f, - 0.459517189801903590f, -0.888168875989561620f, 0.459346877106359570f, - -0.888256970978913870f, - 0.459176547521944150f, -0.888345033309596240f, 0.459006201054919680f, - -0.888433062978371320f, - 0.458835837711549120f, -0.888521059982002260f, 0.458665457498096670f, - -0.888609024317253750f, - 0.458495060420826220f, -0.888696955980891710f, 0.458324646486003300f, - -0.888784854969682850f, - 0.458154215699893230f, -0.888872721280395520f, 0.457983768068762180f, - -0.888960554909799310f, - 0.457813303598877290f, -0.889048355854664570f, 0.457642822296505770f, - -0.889136124111763240f, - 0.457472324167916110f, -0.889223859677868210f, 0.457301809219376800f, - -0.889311562549753850f, - 0.457131277457156980f, -0.889399232724195520f, 0.456960728887527030f, - -0.889486870197969790f, - 0.456790163516757220f, -0.889574474967854580f, 0.456619581351118960f, - -0.889662047030628790f, - 0.456448982396883860f, -0.889749586383072890f, 0.456278366660324670f, - -0.889837093021967900f, - 0.456107734147714220f, -0.889924566944096720f, 0.455937084865326030f, - -0.890012008146243260f, - 0.455766418819434750f, -0.890099416625192210f, 0.455595736016314920f, - -0.890186792377730240f, - 0.455425036462242420f, -0.890274135400644480f, 0.455254320163493210f, - -0.890361445690723730f, - 0.455083587126343840f, -0.890448723244757880f, 0.454912837357072050f, - -0.890535968059537830f, - 0.454742070861955450f, -0.890623180131855930f, 0.454571287647273000f, - -0.890710359458505520f, - 0.454400487719303750f, -0.890797506036281490f, 0.454229671084327320f, - -0.890884619861979530f, - 0.454058837748624540f, -0.890971700932396750f, 0.453887987718476050f, - -0.891058749244331590f, - 0.453717121000163930f, -0.891145764794583180f, 0.453546237599970260f, - -0.891232747579952520f, - 0.453375337524177750f, -0.891319697597241390f, 0.453204420779070300f, - -0.891406614843252900f, - 0.453033487370931580f, -0.891493499314791380f, 0.452862537306046810f, - -0.891580351008662290f, - 0.452691570590700860f, -0.891667169921672390f, 0.452520587231180100f, - -0.891753956050629460f, - 0.452349587233771000f, -0.891840709392342720f, 0.452178570604760410f, - -0.891927429943622510f, - 0.452007537350436530f, -0.892014117701280360f, 0.451836487477087430f, - -0.892100772662129170f, - 0.451665420991002540f, -0.892187394822982480f, 0.451494337898471210f, - -0.892273984180655730f, - 0.451323238205783520f, -0.892360540731965360f, 0.451152121919230710f, - -0.892447064473728680f, - 0.450980989045103810f, -0.892533555402764690f, 0.450809839589695340f, - -0.892620013515893040f, - 0.450638673559297760f, -0.892706438809935280f, 0.450467490960204110f, - -0.892792831281713610f, - 0.450296291798708730f, -0.892879190928051680f, 0.450125076081105750f, - -0.892965517745774260f, - 0.449953843813690580f, -0.893051811731707450f, 0.449782595002758860f, - -0.893138072882678210f, - 0.449611329654606600f, -0.893224301195515320f, 0.449440047775531260f, - -0.893310496667048090f, - 0.449268749371829920f, -0.893396659294107610f, 0.449097434449801100f, - -0.893482789073525850f, - 0.448926103015743260f, -0.893568886002136020f, 0.448754755075956020f, - -0.893654950076772430f, - 0.448583390636739300f, -0.893740981294271040f, 0.448412009704393430f, - -0.893826979651468620f, - 0.448240612285220000f, -0.893912945145203250f, 0.448069198385520340f, - -0.893998877772314240f, - 0.447897768011597310f, -0.894084777529641990f, 0.447726321169753750f, - -0.894170644414028270f, - 0.447554857866293010f, -0.894256478422316040f, 0.447383378107519710f, - -0.894342279551349480f, - 0.447211881899738260f, -0.894428047797973800f, 0.447040369249254500f, - -0.894513783159035620f, - 0.446868840162374330f, -0.894599485631382580f, 0.446697294645404090f, - -0.894685155211863980f, - 0.446525732704651400f, -0.894770791897329550f, 0.446354154346423840f, - -0.894856395684630930f, - 0.446182559577030120f, -0.894941966570620750f, 0.446010948402779110f, - -0.895027504552152630f, - 0.445839320829980350f, -0.895113009626081760f, 0.445667676864944350f, - -0.895198481789264200f, - 0.445496016513981740f, -0.895283921038557580f, 0.445324339783404240f, - -0.895369327370820310f, - 0.445152646679523590f, -0.895454700782912450f, 0.444980937208652780f, - -0.895540041271694840f, - 0.444809211377105000f, -0.895625348834030000f, 0.444637469191193790f, - -0.895710623466781320f, - 0.444465710657234110f, -0.895795865166813420f, 0.444293935781540580f, - -0.895881073930992370f, - 0.444122144570429260f, -0.895966249756185110f, 0.443950337030216250f, - -0.896051392639260040f, - 0.443778513167218220f, -0.896136502577086770f, 0.443606672987753080f, - -0.896221579566535920f, - 0.443434816498138430f, -0.896306623604479660f, 0.443262943704693380f, - -0.896391634687790820f, - 0.443091054613736990f, -0.896476612813344010f, 0.442919149231588980f, - -0.896561557978014960f, - 0.442747227564570130f, -0.896646470178680150f, 0.442575289619001170f, - -0.896731349412217880f, - 0.442403335401204130f, -0.896816195675507190f, 0.442231364917501090f, - -0.896901008965428680f, - 0.442059378174214760f, -0.896985789278863970f, 0.441887375177668960f, - -0.897070536612695870f, - 0.441715355934187310f, -0.897155250963808550f, 0.441543320450094920f, - -0.897239932329087050f, - 0.441371268731716620f, -0.897324580705418320f, 0.441199200785378660f, - -0.897409196089689720f, - 0.441027116617407340f, -0.897493778478790190f, 0.440855016234129430f, - -0.897578327869610230f, - 0.440682899641873020f, -0.897662844259040750f, 0.440510766846965880f, - -0.897747327643974690f, - 0.440338617855737300f, -0.897831778021305650f, 0.440166452674516480f, - -0.897916195387928550f, - 0.439994271309633260f, -0.898000579740739880f, 0.439822073767418610f, - -0.898084931076636780f, - 0.439649860054203420f, -0.898169249392518080f, 0.439477630176319860f, - -0.898253534685283570f, - 0.439305384140100060f, -0.898337786951834190f, 0.439133121951876930f, - -0.898422006189072530f, - 0.438960843617984430f, -0.898506192393901840f, 0.438788549144756290f, - -0.898590345563227030f, - 0.438616238538527710f, -0.898674465693953820f, 0.438443911805633860f, - -0.898758552782989440f, - 0.438271568952410480f, -0.898842606827242260f, 0.438099209985194580f, - -0.898926627823621870f, - 0.437926834910322860f, -0.899010615769039070f, 0.437754443734133470f, - -0.899094570660405770f, - 0.437582036462964340f, -0.899178492494635330f, 0.437409613103154850f, - -0.899262381268642000f, - 0.437237173661044200f, -0.899346236979341460f, 0.437064718142972370f, - -0.899430059623650860f, - 0.436892246555280470f, -0.899513849198487870f, 0.436719758904309310f, - -0.899597605700772180f, - 0.436547255196401250f, -0.899681329127423930f, 0.436374735437898510f, - -0.899765019475365020f, - 0.436202199635143950f, -0.899848676741518580f, 0.436029647794481670f, - -0.899932300922808400f, - 0.435857079922255470f, -0.900015892016160280f, 0.435684496024810520f, - -0.900099450018500340f, - 0.435511896108492170f, -0.900182974926756700f, 0.435339280179646070f, - -0.900266466737858480f, - 0.435166648244619370f, -0.900349925448735600f, 0.434994000309758710f, - -0.900433351056319830f, - 0.434821336381412350f, -0.900516743557543520f, 0.434648656465928430f, - -0.900600102949340790f, - 0.434475960569655710f, -0.900683429228646860f, 0.434303248698944100f, - -0.900766722392397860f, - 0.434130520860143310f, -0.900849982437531450f, 0.433957777059604480f, - -0.900933209360986200f, - 0.433785017303678520f, -0.901016403159702330f, 0.433612241598717640f, - -0.901099563830620950f, - 0.433439449951074200f, -0.901182691370684410f, 0.433266642367100940f, - -0.901265785776836580f, - 0.433093818853152010f, -0.901348847046022030f, 0.432920979415581220f, - -0.901431875175186970f, - 0.432748124060743760f, -0.901514870161278630f, 0.432575252794994810f, - -0.901597832001245660f, - 0.432402365624690140f, -0.901680760692037730f, 0.432229462556186770f, - -0.901763656230605610f, - 0.432056543595841450f, -0.901846518613901860f, 0.431883608750012300f, - -0.901929347838879350f, - 0.431710658025057370f, -0.902012143902493070f, 0.431537691427335500f, - -0.902094906801698900f, - 0.431364708963206440f, -0.902177636533453510f, 0.431191710639030000f, - -0.902260333094715540f, - 0.431018696461167080f, -0.902342996482444200f, 0.430845666435978820f, - -0.902425626693600270f, - 0.430672620569826860f, -0.902508223725145830f, 0.430499558869073930f, - -0.902590787574043870f, - 0.430326481340082610f, -0.902673318237258830f, 0.430153387989216930f, - -0.902755815711756120f, - 0.429980278822840570f, -0.902838279994502830f, 0.429807153847318770f, - -0.902920711082466630f, - 0.429634013069016500f, -0.903003108972617040f, 0.429460856494299490f, - -0.903085473661924600f, - 0.429287684129534720f, -0.903167805147360610f, 0.429114495981088690f, - -0.903250103425898400f, - 0.428941292055329550f, -0.903332368494511820f, 0.428768072358625240f, - -0.903414600350176290f, - 0.428594836897344400f, -0.903496798989868450f, 0.428421585677856760f, - -0.903578964410565950f, - 0.428248318706531910f, -0.903661096609247980f, 0.428075035989740780f, - -0.903743195582894620f, - 0.427901737533854240f, -0.903825261328487390f, 0.427728423345243860f, - -0.903907293843009050f, - 0.427555093430282200f, -0.903989293123443340f, 0.427381747795341770f, - -0.904071259166775440f, - 0.427208386446796370f, -0.904153191969991670f, 0.427035009391019790f, - -0.904235091530079750f, - 0.426861616634386490f, -0.904316957844028320f, 0.426688208183271970f, - -0.904398790908827350f, - 0.426514784044051520f, -0.904480590721468250f, 0.426341344223101880f, - -0.904562357278943190f, - 0.426167888726799620f, -0.904644090578246240f, 0.425994417561522450f, - -0.904725790616371930f, - 0.425820930733648300f, -0.904807457390316540f, 0.425647428249555590f, - -0.904889090897077470f, - 0.425473910115623910f, -0.904970691133653250f, 0.425300376338232590f, - -0.905052258097043590f, - 0.425126826923762410f, -0.905133791784249580f, 0.424953261878594060f, - -0.905215292192273480f, - 0.424779681209108810f, -0.905296759318118820f, 0.424606084921689220f, - -0.905378193158789980f, - 0.424432473022717420f, -0.905459593711293250f, 0.424258845518577010f, - -0.905540960972635480f, - 0.424085202415651670f, -0.905622294939825160f, 0.423911543720325580f, - -0.905703595609872010f, - 0.423737869438983950f, -0.905784862979786440f, 0.423564179578011960f, - -0.905866097046580940f, - 0.423390474143796100f, -0.905947297807268460f, 0.423216753142722780f, - -0.906028465258863490f, - 0.423043016581179100f, -0.906109599398381980f, 0.422869264465553170f, - -0.906190700222840540f, - 0.422695496802232950f, -0.906271767729257660f, 0.422521713597607870f, - -0.906352801914652280f, - 0.422347914858067000f, -0.906433802776045460f, 0.422174100590000820f, - -0.906514770310458800f, - 0.422000270799799790f, -0.906595704514915330f, 0.421826425493854910f, - -0.906676605386439460f, - 0.421652564678558380f, -0.906757472922056550f, 0.421478688360302220f, - -0.906838307118793540f, - 0.421304796545479700f, -0.906919107973678030f, 0.421130889240484140f, - -0.906999875483739610f, - 0.420956966451709440f, -0.907080609646008450f, 0.420783028185550630f, - -0.907161310457516250f, - 0.420609074448402510f, -0.907241977915295930f, 0.420435105246661220f, - -0.907322612016381310f, - 0.420261120586723050f, -0.907403212757808000f, 0.420087120474984590f, - -0.907483780136612570f, - 0.419913104917843730f, -0.907564314149832520f, 0.419739073921698180f, - -0.907644814794507090f, - 0.419565027492946940f, -0.907725282067676330f, 0.419390965637989050f, - -0.907805715966381820f, - 0.419216888363223960f, -0.907886116487666150f, 0.419042795675052480f, - -0.907966483628573240f, - 0.418868687579875110f, -0.908046817386148340f, 0.418694564084093610f, - -0.908127117757437600f, - 0.418520425194109700f, -0.908207384739488700f, 0.418346270916326310f, - -0.908287618329350450f, - 0.418172101257146430f, -0.908367818524072780f, 0.417997916222973550f, - -0.908447985320707250f, - 0.417823715820212380f, -0.908528118716306120f, 0.417649500055267410f, - -0.908608218707923190f, - 0.417475268934544340f, -0.908688285292613360f, 0.417301022464449060f, - -0.908768318467432780f, - 0.417126760651387870f, -0.908848318229439120f, 0.416952483501768280f, - -0.908928284575690640f, - 0.416778191021997590f, -0.909008217503247450f, 0.416603883218484410f, - -0.909088117009170580f, - 0.416429560097637320f, -0.909167983090522270f, 0.416255221665865480f, - -0.909247815744366310f, - 0.416080867929579320f, -0.909327614967767260f, 0.415906498895188770f, - -0.909407380757791260f, - 0.415732114569105420f, -0.909487113111505430f, 0.415557714957740580f, - -0.909566812025978220f, - 0.415383300067506290f, -0.909646477498279540f, 0.415208869904815650f, - -0.909726109525480160f, - 0.415034424476081630f, -0.909805708104652220f, 0.414859963787718390f, - -0.909885273232869160f, - 0.414685487846140010f, -0.909964804907205660f, 0.414510996657761810f, - -0.910044303124737390f, - 0.414336490228999210f, -0.910123767882541570f, 0.414161968566268080f, - -0.910203199177696540f, - 0.413987431675985510f, -0.910282597007281760f, 0.413812879564568300f, - -0.910361961368377990f, - 0.413638312238434560f, -0.910441292258067140f, 0.413463729704002580f, - -0.910520589673432630f, - 0.413289131967690960f, -0.910599853611558930f, 0.413114519035919560f, - -0.910679084069531570f, - 0.412939890915108020f, -0.910758281044437570f, 0.412765247611677320f, - -0.910837444533365010f, - 0.412590589132048380f, -0.910916574533403240f, 0.412415915482642730f, - -0.910995671041643140f, - 0.412241226669883000f, -0.911074734055176250f, 0.412066522700191560f, - -0.911153763571095900f, - 0.411891803579992220f, -0.911232759586496190f, 0.411717069315708670f, - -0.911311722098472670f, - 0.411542319913765280f, -0.911390651104122320f, 0.411367555380587340f, - -0.911469546600543020f, - 0.411192775722600160f, -0.911548408584833990f, 0.411017980946230270f, - -0.911627237054095650f, - 0.410843171057903910f, -0.911706032005429880f, 0.410668346064048780f, - -0.911784793435939430f, - 0.410493505971092520f, -0.911863521342728520f, 0.410318650785463260f, - -0.911942215722902570f, - 0.410143780513590350f, -0.912020876573568230f, 0.409968895161902820f, - -0.912099503891833470f, - 0.409793994736831200f, -0.912178097674807060f, 0.409619079244805840f, - -0.912256657919599650f, - 0.409444148692257590f, -0.912335184623322750f, 0.409269203085618700f, - -0.912413677783089020f, - 0.409094242431320920f, -0.912492137396012650f, 0.408919266735797480f, - -0.912570563459208730f, - 0.408744276005481520f, -0.912648955969793900f, 0.408569270246806780f, - -0.912727314924885900f, - 0.408394249466208110f, -0.912805640321603500f, 0.408219213670120100f, - -0.912883932157067200f, - 0.408044162864978740f, -0.912962190428398100f, 0.407869097057219960f, - -0.913040415132719160f, - 0.407694016253280170f, -0.913118606267154130f, 0.407518920459597030f, - -0.913196763828828200f, - 0.407343809682607970f, -0.913274887814867760f, 0.407168683928751610f, - -0.913352978222400250f, - 0.406993543204466460f, -0.913431035048554720f, 0.406818387516192370f, - -0.913509058290461140f, - 0.406643216870369140f, -0.913587047945250810f, 0.406468031273437000f, - -0.913665004010056350f, - 0.406292830731837470f, -0.913742926482011390f, 0.406117615252011790f, - -0.913820815358251100f, - 0.405942384840402570f, -0.913898670635911680f, 0.405767139503452220f, - -0.913976492312130520f, - 0.405591879247603870f, -0.914054280384046460f, 0.405416604079301750f, - -0.914132034848799460f, - 0.405241314004989860f, -0.914209755703530690f, 0.405066009031113390f, - -0.914287442945382440f, - 0.404890689164117750f, -0.914365096571498450f, 0.404715354410448650f, - -0.914442716579023870f, - 0.404540004776553110f, -0.914520302965104450f, 0.404364640268877810f, - -0.914597855726887790f, - 0.404189260893870750f, -0.914675374861522390f, 0.404013866657980060f, - -0.914752860366158100f, - 0.403838457567654130f, -0.914830312237946090f, 0.403663033629342750f, - -0.914907730474038620f, - 0.403487594849495310f, -0.914985115071589310f, 0.403312141234562660f, - -0.915062466027752760f, - 0.403136672790995240f, -0.915139783339685260f, 0.402961189525244960f, - -0.915217067004543750f, - 0.402785691443763640f, -0.915294317019487050f, 0.402610178553003680f, - -0.915371533381674760f, - 0.402434650859418540f, -0.915448716088267830f, 0.402259108369461440f, - -0.915525865136428530f, - 0.402083551089587040f, -0.915602980523320230f, 0.401907979026249860f, - -0.915680062246107650f, - 0.401732392185905010f, -0.915757110301956720f, 0.401556790575008650f, - -0.915834124688034710f, - 0.401381174200016790f, -0.915911105401509880f, 0.401205543067386760f, - -0.915988052439551840f, - 0.401029897183575790f, -0.916064965799331610f, 0.400854236555041650f, - -0.916141845478021350f, - 0.400678561188243350f, -0.916218691472794110f, 0.400502871089639500f, - -0.916295503780824800f, - 0.400327166265690150f, -0.916372282399289140f, 0.400151446722855300f, - -0.916449027325364040f, - 0.399975712467595390f, -0.916525738556228100f, 0.399799963506372090f, - -0.916602416089060680f, - 0.399624199845646790f, -0.916679059921042700f, 0.399448421491882260f, - -0.916755670049355990f, - 0.399272628451540930f, -0.916832246471183890f, 0.399096820731086600f, - -0.916908789183710990f, - 0.398920998336983020f, -0.916985298184122890f, 0.398745161275694480f, - -0.917061773469606820f, - 0.398569309553686360f, -0.917138215037350710f, 0.398393443177423920f, - -0.917214622884544250f, - 0.398217562153373620f, -0.917290997008377910f, 0.398041666488001930f, - -0.917367337406043810f, - 0.397865756187775750f, -0.917443644074735220f, 0.397689831259163240f, - -0.917519917011646260f, - 0.397513891708632330f, -0.917596156213972950f, 0.397337937542652120f, - -0.917672361678911750f, - 0.397161968767691720f, -0.917748533403661250f, 0.396985985390220900f, - -0.917824671385420570f, - 0.396809987416710420f, -0.917900775621390390f, 0.396633974853630830f, - -0.917976846108772730f, - 0.396457947707453960f, -0.918052882844770380f, 0.396281905984651680f, - -0.918128885826587910f, - 0.396105849691696320f, -0.918204855051430900f, 0.395929778835061360f, - -0.918280790516506130f, - 0.395753693421220080f, -0.918356692219021720f, 0.395577593456646950f, - -0.918432560156186790f, - 0.395401478947816300f, -0.918508394325212250f, 0.395225349901203730f, - -0.918584194723309540f, - 0.395049206323284880f, -0.918659961347691900f, 0.394873048220535760f, - -0.918735694195573550f, - 0.394696875599433670f, -0.918811393264169940f, 0.394520688466455550f, - -0.918887058550697970f, - 0.394344486828079650f, -0.918962690052375630f, 0.394168270690784250f, - -0.919038287766421940f, - 0.393992040061048100f, -0.919113851690057770f, 0.393815794945351130f, - -0.919189381820504470f, - 0.393639535350172880f, -0.919264878154985250f, 0.393463261281994380f, - -0.919340340690724230f, - 0.393286972747296570f, -0.919415769424946960f, 0.393110669752560760f, - -0.919491164354880100f, - 0.392934352304269600f, -0.919566525477751530f, 0.392758020408905280f, - -0.919641852790790470f, - 0.392581674072951530f, -0.919717146291227360f, 0.392405313302891860f, - -0.919792405976293750f, - 0.392228938105210370f, -0.919867631843222950f, 0.392052548486392200f, - -0.919942823889248640f, - 0.391876144452922350f, -0.920017982111606570f, 0.391699726011287050f, - -0.920093106507533070f, - 0.391523293167972350f, -0.920168197074266450f, 0.391346845929465610f, - -0.920243253809045370f, - 0.391170384302253980f, -0.920318276709110480f, 0.390993908292825380f, - -0.920393265771703550f, - 0.390817417907668610f, -0.920468220994067110f, 0.390640913153272370f, - -0.920543142373445480f, - 0.390464394036126650f, -0.920618029907083860f, 0.390287860562721360f, - -0.920692883592229010f, - 0.390111312739546910f, -0.920767703426128790f, 0.389934750573094790f, - -0.920842489406032080f, - 0.389758174069856410f, -0.920917241529189520f, 0.389581583236324360f, - -0.920991959792852310f, - 0.389404978078991100f, -0.921066644194273530f, 0.389228358604349730f, - -0.921141294730707270f, - 0.389051724818894500f, -0.921215911399408730f, 0.388875076729119250f, - -0.921290494197634540f, - 0.388698414341519250f, -0.921365043122642340f, 0.388521737662589740f, - -0.921439558171691320f, - 0.388345046698826300f, -0.921514039342041900f, 0.388168341456725850f, - -0.921588486630955380f, - 0.387991621942784910f, -0.921662900035694730f, 0.387814888163501290f, - -0.921737279553523800f, - 0.387638140125372680f, -0.921811625181708120f, 0.387461377834897920f, - -0.921885936917513970f, - 0.387284601298575890f, -0.921960214758209110f, 0.387107810522905990f, - -0.922034458701062820f, - 0.386931005514388690f, -0.922108668743345070f, 0.386754186279524130f, - -0.922182844882327600f, - 0.386577352824813980f, -0.922256987115283030f, 0.386400505156759610f, - -0.922331095439485330f, - 0.386223643281862980f, -0.922405169852209880f, 0.386046767206627280f, - -0.922479210350733100f, - 0.385869876937555310f, -0.922553216932332830f, 0.385692972481151200f, - -0.922627189594287800f, - 0.385516053843919020f, -0.922701128333878520f, 0.385339121032363340f, - -0.922775033148386380f, - 0.385162174052989970f, -0.922848904035094120f, 0.384985212912304200f, - -0.922922740991285680f, - 0.384808237616812930f, -0.922996544014246250f, 0.384631248173022740f, - -0.923070313101262420f, - 0.384454244587440870f, -0.923144048249621820f, 0.384277226866575620f, - -0.923217749456613500f, - 0.384100195016935040f, -0.923291416719527640f, 0.383923149045028500f, - -0.923365050035655610f, - 0.383746088957365010f, -0.923438649402290370f, 0.383569014760454960f, - -0.923512214816725520f, - 0.383391926460808770f, -0.923585746276256560f, 0.383214824064937180f, - -0.923659243778179980f, - 0.383037707579352130f, -0.923732707319793180f, 0.382860577010565360f, - -0.923806136898395410f, - 0.382683432365089840f, -0.923879532511286740f, 0.382506273649438400f, - -0.923952894155768640f, - 0.382329100870124510f, -0.924026221829143850f, 0.382151914033662720f, - -0.924099515528716280f, - 0.381974713146567220f, -0.924172775251791200f, 0.381797498215353690f, - -0.924246000995674890f, - 0.381620269246537520f, -0.924319192757675160f, 0.381443026246634730f, - -0.924392350535101050f, - 0.381265769222162490f, -0.924465474325262600f, 0.381088498179637520f, - -0.924538564125471420f, - 0.380911213125578130f, -0.924611619933039970f, 0.380733914066502090f, - -0.924684641745282530f, - 0.380556601008928570f, -0.924757629559513910f, 0.380379273959376710f, - -0.924830583373050800f, - 0.380201932924366050f, -0.924903503183210910f, 0.380024577910417380f, - -0.924976388987313050f, - 0.379847208924051110f, -0.925049240782677580f, 0.379669825971789000f, - -0.925122058566625770f, - 0.379492429060152740f, -0.925194842336480420f, 0.379315018195664430f, - -0.925267592089565550f, - 0.379137593384847430f, -0.925340307823206200f, 0.378960154634224720f, - -0.925412989534729060f, - 0.378782701950320600f, -0.925485637221461490f, 0.378605235339659290f, - -0.925558250880732620f, - 0.378427754808765620f, -0.925630830509872720f, 0.378250260364165310f, - -0.925703376106213120f, - 0.378072752012383990f, -0.925775887667086740f, 0.377895229759948550f, - -0.925848365189827270f, - 0.377717693613385810f, -0.925920808671769960f, 0.377540143579222940f, - -0.925993218110251480f, - 0.377362579663988450f, -0.926065593502609310f, 0.377185001874210450f, - -0.926137934846182560f, - 0.377007410216418310f, -0.926210242138311270f, 0.376829804697141220f, - -0.926282515376337210f, - 0.376652185322909620f, -0.926354754557602860f, 0.376474552100253880f, - -0.926426959679452100f, - 0.376296905035704790f, -0.926499130739230510f, 0.376119244135794390f, - -0.926571267734284220f, - 0.375941569407054420f, -0.926643370661961230f, 0.375763880856017750f, - -0.926715439519610330f, - 0.375586178489217330f, -0.926787474304581750f, 0.375408462313186590f, - -0.926859475014227160f, - 0.375230732334460030f, -0.926931441645899130f, 0.375052988559571860f, - -0.927003374196951670f, - 0.374875230995057600f, -0.927075272664740100f, 0.374697459647452770f, - -0.927147137046620880f, - 0.374519674523293210f, -0.927218967339951790f, 0.374341875629116030f, - -0.927290763542091720f, - 0.374164062971457990f, -0.927362525650401110f, 0.373986236556857090f, - -0.927434253662241300f, - 0.373808396391851370f, -0.927505947574975180f, 0.373630542482979280f, - -0.927577607385966730f, - 0.373452674836780410f, -0.927649233092581180f, 0.373274793459794030f, - -0.927720824692185200f, - 0.373096898358560690f, -0.927792382182146320f, 0.372918989539620770f, - -0.927863905559833780f, - 0.372741067009515810f, -0.927935394822617890f, 0.372563130774787370f, - -0.928006849967869970f, - 0.372385180841977360f, -0.928078270992963140f, 0.372207217217628950f, - -0.928149657895271150f, - 0.372029239908284960f, -0.928221010672169440f, 0.371851248920489540f, - -0.928292329321034560f, - 0.371673244260786630f, -0.928363613839244370f, 0.371495225935720760f, - -0.928434864224177980f, - 0.371317193951837600f, -0.928506080473215480f, 0.371139148315682510f, - -0.928577262583738850f, - 0.370961089033802040f, -0.928648410553130520f, 0.370783016112742720f, - -0.928719524378774700f, - 0.370604929559051670f, -0.928790604058057020f, 0.370426829379276900f, - -0.928861649588363700f, - 0.370248715579966360f, -0.928932660967082820f, 0.370070588167669130f, - -0.929003638191603360f, - 0.369892447148934270f, -0.929074581259315750f, 0.369714292530311240f, - -0.929145490167611720f, - 0.369536124318350760f, -0.929216364913883930f, 0.369357942519603190f, - -0.929287205495526790f, - 0.369179747140620070f, -0.929358011909935500f, 0.369001538187952780f, - -0.929428784154506800f, - 0.368823315668153960f, -0.929499522226638560f, 0.368645079587776150f, - -0.929570226123729860f, - 0.368466829953372320f, -0.929640895843181330f, 0.368288566771496680f, - -0.929711531382394370f, - 0.368110290048703050f, -0.929782132738772190f, 0.367931999791546500f, - -0.929852699909718750f, - 0.367753696006582090f, -0.929923232892639560f, 0.367575378700365330f, - -0.929993731684941480f, - 0.367397047879452820f, -0.930064196284032360f, 0.367218703550400930f, - -0.930134626687321390f, - 0.367040345719767240f, -0.930205022892219070f, 0.366861974394109220f, - -0.930275384896137040f, - 0.366683589579984930f, -0.930345712696488470f, 0.366505191283953480f, - -0.930416006290687550f, - 0.366326779512573590f, -0.930486265676149780f, 0.366148354272405390f, - -0.930556490850291800f, - 0.365969915570008910f, -0.930626681810531650f, 0.365791463411944570f, - -0.930696838554288860f, - 0.365612997804773960f, -0.930766961078983710f, 0.365434518755058390f, - -0.930837049382038150f, - 0.365256026269360380f, -0.930907103460875020f, 0.365077520354242180f, - -0.930977123312918930f, - 0.364899001016267380f, -0.931047108935595170f, 0.364720468261999390f, - -0.931117060326330790f, - 0.364541922098002180f, -0.931186977482553750f, 0.364363362530840730f, - -0.931256860401693420f, - 0.364184789567079840f, -0.931326709081180430f, 0.364006203213285530f, - -0.931396523518446600f, - 0.363827603476023610f, -0.931466303710925090f, 0.363648990361860550f, - -0.931536049656050300f, - 0.363470363877363870f, -0.931605761351257830f, 0.363291724029100700f, - -0.931675438793984620f, - 0.363113070823639530f, -0.931745081981668720f, 0.362934404267548750f, - -0.931814690911749620f, - 0.362755724367397230f, -0.931884265581668150f, 0.362577031129754870f, - -0.931953805988865900f, - 0.362398324561191310f, -0.932023312130786490f, 0.362219604668277570f, - -0.932092784004874050f, - 0.362040871457584350f, -0.932162221608574320f, 0.361862124935682980f, - -0.932231624939334540f, - 0.361683365109145950f, -0.932300993994602640f, 0.361504591984545260f, - -0.932370328771828460f, - 0.361325805568454340f, -0.932439629268462360f, 0.361147005867446190f, - -0.932508895481956700f, - 0.360968192888095290f, -0.932578127409764420f, 0.360789366636975690f, - -0.932647325049340340f, - 0.360610527120662270f, -0.932716488398140250f, 0.360431674345730810f, - -0.932785617453620990f, - 0.360252808318756830f, -0.932854712213241230f, 0.360073929046317080f, - -0.932923772674460140f, - 0.359895036534988280f, -0.932992798834738850f, 0.359716130791347570f, - -0.933061790691539380f, - 0.359537211821973180f, -0.933130748242325110f, 0.359358279633443080f, - -0.933199671484560730f, - 0.359179334232336560f, -0.933268560415712050f, 0.359000375625232630f, - -0.933337415033246080f, - 0.358821403818710920f, -0.933406235334631520f, 0.358642418819352100f, - -0.933475021317337950f, - 0.358463420633736540f, -0.933543772978836170f, 0.358284409268445900f, - -0.933612490316598540f, - 0.358105384730061760f, -0.933681173328098300f, 0.357926347025166070f, - -0.933749822010810580f, - 0.357747296160342010f, -0.933818436362210960f, 0.357568232142172260f, - -0.933887016379776890f, - 0.357389154977241000f, -0.933955562060986730f, 0.357210064672131900f, - -0.934024073403320500f, - 0.357030961233430030f, -0.934092550404258870f, 0.356851844667720410f, - -0.934160993061284420f, - 0.356672714981588260f, -0.934229401371880820f, 0.356493572181620200f, - -0.934297775333532530f, - 0.356314416274402360f, -0.934366114943725900f, 0.356135247266522180f, - -0.934434420199948050f, - 0.355956065164567010f, -0.934502691099687870f, 0.355776869975124640f, - -0.934570927640435030f, - 0.355597661704783960f, -0.934639129819680780f, 0.355418440360133590f, - -0.934707297634917440f, - 0.355239205947763370f, -0.934775431083638700f, 0.355059958474263030f, - -0.934843530163339430f, - 0.354880697946222790f, -0.934911594871516090f, 0.354701424370233940f, - -0.934979625205665800f, - 0.354522137752887430f, -0.935047621163287430f, 0.354342838100775600f, - -0.935115582741880890f, - 0.354163525420490510f, -0.935183509938947500f, 0.353984199718624830f, - -0.935251402751989810f, - 0.353804861001772160f, -0.935319261178511500f, 0.353625509276525970f, - -0.935387085216017770f, - 0.353446144549480870f, -0.935454874862014620f, 0.353266766827231180f, - -0.935522630114009930f, - 0.353087376116372530f, -0.935590350969512370f, 0.352907972423500360f, - -0.935658037426032040f, - 0.352728555755210730f, -0.935725689481080370f, 0.352549126118100580f, - -0.935793307132169900f, - 0.352369683518766630f, -0.935860890376814640f, 0.352190227963806890f, - -0.935928439212529660f, - 0.352010759459819240f, -0.935995953636831300f, 0.351831278013402030f, - -0.936063433647237540f, - 0.351651783631154680f, -0.936130879241266920f, 0.351472276319676260f, - -0.936198290416440090f, - 0.351292756085567150f, -0.936265667170278260f, 0.351113222935427630f, - -0.936333009500304180f, - 0.350933676875858360f, -0.936400317404042060f, 0.350754117913461170f, - -0.936467590879016880f, - 0.350574546054837570f, -0.936534829922755500f, 0.350394961306590200f, - -0.936602034532785570f, - 0.350215363675321740f, -0.936669204706636060f, 0.350035753167635300f, - -0.936736340441837620f, - 0.349856129790135030f, -0.936803441735921560f, 0.349676493549424760f, - -0.936870508586420960f, - 0.349496844452109600f, -0.936937540990869900f, 0.349317182504794320f, - -0.937004538946803690f, - 0.349137507714085030f, -0.937071502451759190f, 0.348957820086587600f, - -0.937138431503274140f, - 0.348778119628908420f, -0.937205326098887960f, 0.348598406347655040f, - -0.937272186236140950f, - 0.348418680249434510f, -0.937339011912574960f, 0.348238941340855310f, - -0.937405803125732850f, - 0.348059189628525780f, -0.937472559873159140f, 0.347879425119054510f, - -0.937539282152399230f, - 0.347699647819051490f, -0.937605969960999990f, 0.347519857735126110f, - -0.937672623296509470f, - 0.347340054873889190f, -0.937739242156476970f, 0.347160239241951330f, - -0.937805826538453010f, - 0.346980410845923680f, -0.937872376439989890f, 0.346800569692418400f, - -0.937938891858640210f, - 0.346620715788047320f, -0.938005372791958840f, 0.346440849139423580f, - -0.938071819237501160f, - 0.346260969753160170f, -0.938138231192824360f, 0.346081077635870480f, - -0.938204608655486490f, - 0.345901172794169100f, -0.938270951623047080f, 0.345721255234670120f, - -0.938337260093066950f, - 0.345541324963989150f, -0.938403534063108060f, 0.345361381988741170f, - -0.938469773530733800f, - 0.345181426315542610f, -0.938535978493508560f, 0.345001457951009780f, - -0.938602148948998290f, - 0.344821476901759290f, -0.938668284894770170f, 0.344641483174409070f, - -0.938734386328392460f, - 0.344461476775576480f, -0.938800453247434770f, 0.344281457711880230f, - -0.938866485649468060f, - 0.344101425989938980f, -0.938932483532064490f, 0.343921381616371700f, - -0.938998446892797540f, - 0.343741324597798600f, -0.939064375729241950f, 0.343561254940839330f, - -0.939130270038973650f, - 0.343381172652115100f, -0.939196129819569900f, 0.343201077738246710f, - -0.939261955068609100f, - 0.343020970205855540f, -0.939327745783671400f, 0.342840850061564060f, - -0.939393501962337510f, - 0.342660717311994380f, -0.939459223602189920f, 0.342480571963769850f, - -0.939524910700812120f, - 0.342300414023513690f, -0.939590563255789160f, 0.342120243497849590f, - -0.939656181264707070f, - 0.341940060393402300f, -0.939721764725153340f, 0.341759864716796310f, - -0.939787313634716570f, - 0.341579656474657210f, -0.939852827990986680f, 0.341399435673610360f, - -0.939918307791555050f, - 0.341219202320282410f, -0.939983753034013940f, 0.341038956421299830f, - -0.940049163715957370f, - 0.340858697983289440f, -0.940114539834980280f, 0.340678427012879310f, - -0.940179881388678810f, - 0.340498143516697100f, -0.940245188374650880f, 0.340317847501371730f, - -0.940310460790495070f, - 0.340137538973531880f, -0.940375698633811540f, 0.339957217939806880f, - -0.940440901902201750f, - 0.339776884406826960f, -0.940506070593268300f, 0.339596538381222060f, - -0.940571204704615190f, - 0.339416179869623410f, -0.940636304233847590f, 0.339235808878662120f, - -0.940701369178571940f, - 0.339055425414969640f, -0.940766399536396070f, 0.338875029485178560f, - -0.940831395304928870f, - 0.338694621095921190f, -0.940896356481780830f, 0.338514200253831000f, - -0.940961283064563280f, - 0.338333766965541290f, -0.941026175050889260f, 0.338153321237685990f, - -0.941091032438372780f, - 0.337972863076899830f, -0.941155855224629190f, 0.337792392489817460f, - -0.941220643407275180f, - 0.337611909483074680f, -0.941285396983928660f, 0.337431414063306790f, - -0.941350115952208970f, - 0.337250906237150650f, -0.941414800309736230f, 0.337070386011242730f, - -0.941479450054132580f, - 0.336889853392220050f, -0.941544065183020810f, 0.336709308386720700f, - -0.941608645694025140f, - 0.336528751001382350f, -0.941673191584771360f, 0.336348181242844100f, - -0.941737702852886160f, - 0.336167599117744690f, -0.941802179495997650f, 0.335987004632723350f, - -0.941866621511735280f, - 0.335806397794420560f, -0.941931028897729510f, 0.335625778609476230f, - -0.941995401651612550f, - 0.335445147084531660f, -0.942059739771017310f, 0.335264503226227970f, - -0.942124043253578460f, - 0.335083847041206580f, -0.942188312096931770f, 0.334903178536110290f, - -0.942252546298714020f, - 0.334722497717581220f, -0.942316745856563780f, 0.334541804592262960f, - -0.942380910768120470f, - 0.334361099166798900f, -0.942445041031024890f, 0.334180381447832740f, - -0.942509136642919240f, - 0.333999651442009490f, -0.942573197601446870f, 0.333818909155973620f, - -0.942637223904252530f, - 0.333638154596370920f, -0.942701215548981900f, 0.333457387769846790f, - -0.942765172533282510f, - 0.333276608683047980f, -0.942829094854802710f, 0.333095817342620890f, - -0.942892982511192130f, - 0.332915013755212650f, -0.942956835500102120f, 0.332734197927471160f, - -0.943020653819184650f, - 0.332553369866044220f, -0.943084437466093490f, 0.332372529577580680f, - -0.943148186438483420f, - 0.332191677068729320f, -0.943211900734010620f, 0.332010812346139380f, - -0.943275580350332540f, - 0.331829935416461220f, -0.943339225285107720f, 0.331649046286344620f, - -0.943402835535996240f, - 0.331468144962440920f, -0.943466411100659320f, 0.331287231451400990f, - -0.943529951976759370f, - 0.331106305759876430f, -0.943593458161960390f, 0.330925367894519650f, - -0.943656929653927110f, - 0.330744417861982890f, -0.943720366450326200f, 0.330563455668919590f, - -0.943783768548825060f, - 0.330382481321982950f, -0.943847135947092690f, 0.330201494827826620f, - -0.943910468642799150f, - 0.330020496193105530f, -0.943973766633615980f, 0.329839485424473940f, - -0.944037029917215830f, - 0.329658462528587550f, -0.944100258491272660f, 0.329477427512101680f, - -0.944163452353461770f, - 0.329296380381672800f, -0.944226611501459810f, 0.329115321143957360f, - -0.944289735932944410f, - 0.328934249805612200f, -0.944352825645594750f, 0.328753166373295100f, - -0.944415880637091250f, - 0.328572070853663690f, -0.944478900905115550f, 0.328390963253376630f, - -0.944541886447350380f, - 0.328209843579092660f, -0.944604837261480260f, 0.328028711837470730f, - -0.944667753345190490f, - 0.327847568035170960f, -0.944730634696167800f, 0.327666412178853060f, - -0.944793481312100280f, - 0.327485244275178060f, -0.944856293190677210f, 0.327304064330806830f, - -0.944919070329589220f, - 0.327122872352400510f, -0.944981812726528150f, 0.326941668346621530f, - -0.945044520379187070f, - 0.326760452320131790f, -0.945107193285260610f, 0.326579224279594460f, - -0.945169831442444150f, - 0.326397984231672660f, -0.945232434848434890f, 0.326216732183029770f, - -0.945295003500931100f, - 0.326035468140330350f, -0.945357537397632290f, 0.325854192110238580f, - -0.945420036536239070f, - 0.325672904099419900f, -0.945482500914453740f, 0.325491604114539260f, - -0.945544930529979680f, - 0.325310292162262980f, -0.945607325380521280f, 0.325128968249257190f, - -0.945669685463784710f, - 0.324947632382188430f, -0.945732010777477150f, 0.324766284567724330f, - -0.945794301319306860f, - 0.324584924812532150f, -0.945856557086983910f, 0.324403553123280290f, - -0.945918778078219110f, - 0.324222169506637130f, -0.945980964290724760f, 0.324040773969271450f, - -0.946043115722214560f, - 0.323859366517852960f, -0.946105232370403340f, 0.323677947159051180f, - -0.946167314233007370f, - 0.323496515899536760f, -0.946229361307743820f, 0.323315072745980150f, - -0.946291373592331510f, - 0.323133617705052330f, -0.946353351084490590f, 0.322952150783425370f, - -0.946415293781942110f, - 0.322770671987770710f, -0.946477201682408680f, 0.322589181324761390f, - -0.946539074783614100f, - 0.322407678801070020f, -0.946600913083283530f, 0.322226164423369650f, - -0.946662716579143360f, - 0.322044638198334620f, -0.946724485268921170f, 0.321863100132638580f, - -0.946786219150346000f, - 0.321681550232956640f, -0.946847918221148000f, 0.321499988505963450f, - -0.946909582479058760f, - 0.321318414958334910f, -0.946971211921810880f, 0.321136829596746780f, - -0.947032806547138620f, - 0.320955232427875210f, -0.947094366352777220f, 0.320773623458397440f, - -0.947155891336463270f, - 0.320592002694990330f, -0.947217381495934820f, 0.320410370144331880f, - -0.947278836828930880f, - 0.320228725813100020f, -0.947340257333191940f, 0.320047069707973140f, - -0.947401643006459900f, - 0.319865401835630610f, -0.947462993846477700f, 0.319683722202751370f, - -0.947524309850989570f, - 0.319502030816015750f, -0.947585591017741090f, 0.319320327682103720f, - -0.947646837344479190f, - 0.319138612807695900f, -0.947708048828952100f, 0.318956886199473770f, - -0.947769225468909180f, - 0.318775147864118480f, -0.947830367262101010f, 0.318593397808312470f, - -0.947891474206279730f, - 0.318411636038737960f, -0.947952546299198560f, 0.318229862562077580f, - -0.948013583538612200f, - 0.318048077385015060f, -0.948074585922276230f, 0.317866280514233660f, - -0.948135553447947980f, - 0.317684471956418020f, -0.948196486113385580f, 0.317502651718252260f, - -0.948257383916349060f, - 0.317320819806421790f, -0.948318246854599090f, 0.317138976227611890f, - -0.948379074925898120f, - 0.316957120988508150f, -0.948439868128009620f, 0.316775254095797380f, - -0.948500626458698260f, - 0.316593375556165850f, -0.948561349915730270f, 0.316411485376301090f, - -0.948622038496872990f, - 0.316229583562890490f, -0.948682692199895090f, 0.316047670122621860f, - -0.948743311022566480f, - 0.315865745062184070f, -0.948803894962658380f, 0.315683808388265600f, - -0.948864444017943340f, - 0.315501860107556040f, -0.948924958186195160f, 0.315319900226745050f, - -0.948985437465188710f, - 0.315137928752522440f, -0.949045881852700560f, 0.314955945691579250f, - -0.949106291346508260f, - 0.314773951050606070f, -0.949166665944390700f, 0.314591944836294710f, - -0.949227005644128210f, - 0.314409927055336820f, -0.949287310443502010f, 0.314227897714424500f, - -0.949347580340295210f, - 0.314045856820250820f, -0.949407815332291460f, 0.313863804379508500f, - -0.949468015417276550f, - 0.313681740398891570f, -0.949528180593036670f, 0.313499664885093450f, - -0.949588310857359950f, - 0.313317577844809070f, -0.949648406208035480f, 0.313135479284732950f, - -0.949708466642853800f, - 0.312953369211560200f, -0.949768492159606680f, 0.312771247631986880f, - -0.949828482756087000f, - 0.312589114552708660f, -0.949888438430089300f, 0.312406969980422500f, - -0.949948359179409010f, - 0.312224813921825050f, -0.950008245001843000f, 0.312042646383613510f, - -0.950068095895189590f, - 0.311860467372486130f, -0.950127911857248100f, 0.311678276895140550f, - -0.950187692885819280f, - 0.311496074958275970f, -0.950247438978705230f, 0.311313861568591090f, - -0.950307150133709140f, - 0.311131636732785270f, -0.950366826348635780f, 0.310949400457558760f, - -0.950426467621290900f, - 0.310767152749611470f, -0.950486073949481700f, 0.310584893615644560f, - -0.950545645331016600f, - 0.310402623062358880f, -0.950605181763705230f, 0.310220341096455910f, - -0.950664683245358910f, - 0.310038047724638000f, -0.950724149773789610f, 0.309855742953607130f, - -0.950783581346811070f, - 0.309673426790066490f, -0.950842977962238160f, 0.309491099240719050f, - -0.950902339617887060f, - 0.309308760312268780f, -0.950961666311575080f, 0.309126410011419550f, - -0.951020958041121080f, - 0.308944048344875710f, -0.951080214804345010f, 0.308761675319342570f, - -0.951139436599068190f, - 0.308579290941525030f, -0.951198623423113230f, 0.308396895218129240f, - -0.951257775274304000f, - 0.308214488155861220f, -0.951316892150465550f, 0.308032069761427330f, - -0.951375974049424420f, - 0.307849640041534980f, -0.951435020969008340f, 0.307667199002891190f, - -0.951494032907046370f, - 0.307484746652204160f, -0.951553009861368590f, 0.307302282996181950f, - -0.951611951829806730f, - 0.307119808041533100f, -0.951670858810193860f, 0.306937321794967020f, - -0.951729730800363720f, - 0.306754824263192780f, -0.951788567798152130f, 0.306572315452920800f, - -0.951847369801395620f, - 0.306389795370861080f, -0.951906136807932230f, 0.306207264023724280f, - -0.951964868815601380f, - 0.306024721418221900f, -0.952023565822243570f, 0.305842167561065080f, - -0.952082227825700620f, - 0.305659602458966230f, -0.952140854823815830f, 0.305477026118637360f, - -0.952199446814433580f, - 0.305294438546791720f, -0.952258003795399600f, 0.305111839750142220f, - -0.952316525764560830f, - 0.304929229735402430f, -0.952375012719765880f, 0.304746608509286640f, - -0.952433464658864030f, - 0.304563976078509050f, -0.952491881579706320f, 0.304381332449784940f, - -0.952550263480144930f, - 0.304198677629829270f, -0.952608610358033240f, 0.304016011625357570f, - -0.952666922211226170f, - 0.303833334443086470f, -0.952725199037579570f, 0.303650646089731910f, - -0.952783440834950920f, - 0.303467946572011370f, -0.952841647601198720f, 0.303285235896641910f, - -0.952899819334182880f, - 0.303102514070341060f, -0.952957956031764700f, 0.302919781099827420f, - -0.953016057691806530f, - 0.302737036991819140f, -0.953074124312172200f, 0.302554281753035670f, - -0.953132155890726750f, - 0.302371515390196130f, -0.953190152425336560f, 0.302188737910020040f, - -0.953248113913869320f, - 0.302005949319228200f, -0.953306040354193750f, 0.301823149624540650f, - -0.953363931744180330f, - 0.301640338832678880f, -0.953421788081700310f, 0.301457516950363940f, - -0.953479609364626610f, - 0.301274683984318000f, -0.953537395590833280f, 0.301091839941263210f, - -0.953595146758195680f, - 0.300908984827921890f, -0.953652862864590500f, 0.300726118651017620f, - -0.953710543907895560f, - 0.300543241417273400f, -0.953768189885990330f, 0.300360353133413580f, - -0.953825800796755050f, - 0.300177453806162120f, -0.953883376638071770f, 0.299994543442243580f, - -0.953940917407823500f, - 0.299811622048383460f, -0.953998423103894490f, 0.299628689631306790f, - -0.954055893724170660f, - 0.299445746197739950f, -0.954113329266538800f, 0.299262791754409010f, - -0.954170729728887280f, - 0.299079826308040480f, -0.954228095109105670f, 0.298896849865361910f, - -0.954285425405084650f, - 0.298713862433100390f, -0.954342720614716480f, 0.298530864017984230f, - -0.954399980735894490f, - 0.298347854626741570f, -0.954457205766513490f, 0.298164834266100910f, - -0.954514395704469500f, - 0.297981802942791920f, -0.954571550547659630f, 0.297798760663543550f, - -0.954628670293982680f, - 0.297615707435086310f, -0.954685754941338340f, 0.297432643264150030f, - -0.954742804487627940f, - 0.297249568157465890f, -0.954799818930753720f, 0.297066482121764840f, - -0.954856798268619580f, - 0.296883385163778270f, -0.954913742499130520f, 0.296700277290238460f, - -0.954970651620192790f, - 0.296517158507877410f, -0.955027525629714160f, 0.296334028823428240f, - -0.955084364525603410f, - 0.296150888243623960f, -0.955141168305770670f, 0.295967736775197890f, - -0.955197936968127710f, - 0.295784574424884370f, -0.955254670510586990f, 0.295601401199417360f, - -0.955311368931062720f, - 0.295418217105532070f, -0.955368032227470240f, 0.295235022149963390f, - -0.955424660397726330f, - 0.295051816339446720f, -0.955481253439748770f, 0.294868599680718380f, - -0.955537811351456770f, - 0.294685372180514330f, -0.955594334130771110f, 0.294502133845571720f, - -0.955650821775613220f, - 0.294318884682627570f, -0.955707274283906560f, 0.294135624698419080f, - -0.955763691653575440f, - 0.293952353899684770f, -0.955820073882545420f, 0.293769072293162400f, - -0.955876420968743590f, - 0.293585779885591310f, -0.955932732910098170f, 0.293402476683710060f, - -0.955989009704538930f, - 0.293219162694258680f, -0.956045251349996410f, 0.293035837923976920f, - -0.956101457844403040f, - 0.292852502379604810f, -0.956157629185692140f, 0.292669156067883570f, - -0.956213765371798470f, - 0.292485798995553830f, -0.956269866400658140f, 0.292302431169357610f, - -0.956325932270208230f, - 0.292119052596036540f, -0.956381962978387620f, 0.291935663282332780f, - -0.956437958523136180f, - 0.291752263234989370f, -0.956493918902394990f, 0.291568852460749040f, - -0.956549844114106820f, - 0.291385430966355720f, -0.956605734156215080f, 0.291201998758553020f, - -0.956661589026664980f, - 0.291018555844085090f, -0.956717408723403050f, 0.290835102229696940f, - -0.956773193244376930f, - 0.290651637922133220f, -0.956828942587535370f, 0.290468162928139870f, - -0.956884656750828900f, - 0.290284677254462330f, -0.956940335732208940f, 0.290101180907847140f, - -0.956995979529628230f, - 0.289917673895040860f, -0.957051588141040970f, 0.289734156222790250f, - -0.957107161564402790f, - 0.289550627897843140f, -0.957162699797670100f, 0.289367088926946960f, - -0.957218202838801210f, - 0.289183539316850310f, -0.957273670685755200f, 0.288999979074301530f, - -0.957329103336492790f, - 0.288816408206049480f, -0.957384500788975860f, 0.288632826718843940f, - -0.957439863041167570f, - 0.288449234619434170f, -0.957495190091032570f, 0.288265631914570830f, - -0.957550481936536470f, - 0.288082018611004300f, -0.957605738575646240f, 0.287898394715485170f, - -0.957660960006330610f, - 0.287714760234765280f, -0.957716146226558870f, 0.287531115175595930f, - -0.957771297234302320f, - 0.287347459544729570f, -0.957826413027532910f, 0.287163793348918560f, - -0.957881493604224250f, - 0.286980116594915570f, -0.957936538962351420f, 0.286796429289474190f, - -0.957991549099890370f, - 0.286612731439347790f, -0.958046524014818600f, 0.286429023051290750f, - -0.958101463705114620f, - 0.286245304132057120f, -0.958156368168758820f, 0.286061574688402100f, - -0.958211237403732260f, - 0.285877834727080730f, -0.958266071408017670f, 0.285694084254848320f, - -0.958320870179598880f, - 0.285510323278461380f, -0.958375633716461170f, 0.285326551804675810f, - -0.958430362016591040f, - 0.285142769840248720f, -0.958485055077976100f, 0.284958977391937150f, - -0.958539712898605730f, - 0.284775174466498300f, -0.958594335476470220f, 0.284591361070690550f, - -0.958648922809561040f, - 0.284407537211271820f, -0.958703474895871600f, 0.284223702895001100f, - -0.958757991733395710f, - 0.284039858128637360f, -0.958812473320129200f, 0.283856002918939750f, - -0.958866919654069010f, - 0.283672137272668550f, -0.958921330733213060f, 0.283488261196583550f, - -0.958975706555561080f, - 0.283304374697445790f, -0.959030047119113550f, 0.283120477782015990f, - -0.959084352421872730f, - 0.282936570457055390f, -0.959138622461841890f, 0.282752652729326040f, - -0.959192857237025740f, - 0.282568724605589740f, -0.959247056745430090f, 0.282384786092609420f, - -0.959301220985062210f, - 0.282200837197147500f, -0.959355349953930790f, 0.282016877925967690f, - -0.959409443650045550f, - 0.281832908285833460f, -0.959463502071417510f, 0.281648928283508680f, - -0.959517525216059260f, - 0.281464937925758050f, -0.959571513081984520f, 0.281280937219346110f, - -0.959625465667208300f, - 0.281096926171038320f, -0.959679382969746750f, 0.280912904787600120f, - -0.959733264987617680f, - 0.280728873075797190f, -0.959787111718839900f, 0.280544831042396360f, - -0.959840923161433660f, - 0.280360778694163810f, -0.959894699313420530f, 0.280176716037867040f, - -0.959948440172823210f, - 0.279992643080273380f, -0.960002145737665850f, 0.279808559828150390f, - -0.960055816005973890f, - 0.279624466288266700f, -0.960109450975773940f, 0.279440362467390510f, - -0.960163050645094000f, - 0.279256248372291240f, -0.960216615011963430f, 0.279072124009737970f, - -0.960270144074412800f, - 0.278887989386500280f, -0.960323637830473920f, 0.278703844509348600f, - -0.960377096278180130f, - 0.278519689385053060f, -0.960430519415565790f, 0.278335524020384970f, - -0.960483907240666790f, - 0.278151348422115090f, -0.960537259751520050f, 0.277967162597015430f, - -0.960590576946164120f, - 0.277782966551857800f, -0.960643858822638470f, 0.277598760293414290f, - -0.960697105378984450f, - 0.277414543828458200f, -0.960750316613243950f, 0.277230317163762120f, - -0.960803492523460760f, - 0.277046080306099950f, -0.960856633107679660f, 0.276861833262245390f, - -0.960909738363946770f, - 0.276677576038972420f, -0.960962808290309780f, 0.276493308643056100f, - -0.961015842884817230f, - 0.276309031081271030f, -0.961068842145519350f, 0.276124743360392890f, - -0.961121806070467380f, - 0.275940445487197320f, -0.961174734657714080f, 0.275756137468460120f, - -0.961227627905313460f, - 0.275571819310958250f, -0.961280485811320640f, 0.275387491021468140f, - -0.961333308373792270f, - 0.275203152606767370f, -0.961386095590786250f, 0.275018804073633380f, - -0.961438847460361570f, - 0.274834445428843940f, -0.961491563980579000f, 0.274650076679177790f, - -0.961544245149499990f, - 0.274465697831413220f, -0.961596890965187860f, 0.274281308892329710f, - -0.961649501425706820f, - 0.274096909868706330f, -0.961702076529122540f, 0.273912500767323320f, - -0.961754616273502010f, - 0.273728081594960650f, -0.961807120656913540f, 0.273543652358398730f, - -0.961859589677426570f, - 0.273359213064418790f, -0.961912023333112100f, 0.273174763719801870f, - -0.961964421622042320f, - 0.272990304331329980f, -0.962016784542290560f, 0.272805834905784920f, - -0.962069112091931580f, - 0.272621355449948980f, -0.962121404269041580f, 0.272436865970605350f, - -0.962173661071697770f, - 0.272252366474536660f, -0.962225882497979020f, 0.272067856968526980f, - -0.962278068545965090f, - 0.271883337459359890f, -0.962330219213737400f, 0.271698807953819510f, - -0.962382334499378380f, - 0.271514268458690810f, -0.962434414400971990f, 0.271329718980758420f, - -0.962486458916603450f, - 0.271145159526808070f, -0.962538468044359160f, 0.270960590103625330f, - -0.962590441782326780f, - 0.270776010717996010f, -0.962642380128595710f, 0.270591421376707050f, - -0.962694283081255930f, - 0.270406822086544820f, -0.962746150638399410f, 0.270222212854296930f, - -0.962797982798119010f, - 0.270037593686750510f, -0.962849779558509030f, 0.269852964590693910f, - -0.962901540917665000f, - 0.269668325572915200f, -0.962953266873683880f, 0.269483676640202840f, - -0.963004957424663850f, - 0.269299017799346230f, -0.963056612568704340f, 0.269114349057134330f, - -0.963108232303906190f, - 0.268929670420357310f, -0.963159816628371360f, 0.268744981895805090f, - -0.963211365540203480f, - 0.268560283490267890f, -0.963262879037507070f, 0.268375575210537010f, - -0.963314357118388090f, - 0.268190857063403180f, -0.963365799780954050f, 0.268006129055658350f, - -0.963417207023313350f, - 0.267821391194094320f, -0.963468578843575950f, 0.267636643485503090f, - -0.963519915239853140f, - 0.267451885936677740f, -0.963571216210257210f, 0.267267118554410930f, - -0.963622481752902220f, - 0.267082341345496350f, -0.963673711865903230f, 0.266897554316727510f, - -0.963724906547376410f, - 0.266712757474898420f, -0.963776065795439840f, 0.266527950826803810f, - -0.963827189608212340f, - 0.266343134379238180f, -0.963878277983814200f, 0.266158308138997050f, - -0.963929330920367140f, - 0.265973472112875530f, -0.963980348415994110f, 0.265788626307669970f, - -0.964031330468819280f, - 0.265603770730176440f, -0.964082277076968140f, 0.265418905387191260f, - -0.964133188238567640f, - 0.265234030285511900f, -0.964184063951745720f, 0.265049145431935200f, - -0.964234904214632200f, - 0.264864250833259320f, -0.964285709025357370f, 0.264679346496282050f, - -0.964336478382053720f, - 0.264494432427801630f, -0.964387212282854290f, 0.264309508634617220f, - -0.964437910725893910f, - 0.264124575123527490f, -0.964488573709308410f, 0.263939631901332410f, - -0.964539201231235150f, - 0.263754678974831510f, -0.964589793289812650f, 0.263569716350824880f, - -0.964640349883180930f, - 0.263384744036113390f, -0.964690871009480920f, 0.263199762037497560f, - -0.964741356666855340f, - 0.263014770361779060f, -0.964791806853447900f, 0.262829769015759330f, - -0.964842221567403510f, - 0.262644758006240100f, -0.964892600806868890f, 0.262459737340024090f, - -0.964942944569991410f, - 0.262274707023913590f, -0.964993252854920320f, 0.262089667064712100f, - -0.965043525659805890f, - 0.261904617469222560f, -0.965093762982799590f, 0.261719558244249080f, - -0.965143964822054450f, - 0.261534489396595630f, -0.965194131175724720f, 0.261349410933066350f, - -0.965244262041965780f, - 0.261164322860466590f, -0.965294357418934660f, 0.260979225185601020f, - -0.965344417304789370f, - 0.260794117915275570f, -0.965394441697689400f, 0.260609001056295920f, - -0.965444430595795430f, - 0.260423874615468010f, -0.965494383997269500f, 0.260238738599598950f, - -0.965544301900275070f, - 0.260053593015495130f, -0.965594184302976830f, 0.259868437869964330f, - -0.965644031203540590f, - 0.259683273169813930f, -0.965693842600133690f, 0.259498098921851660f, - -0.965743618490924830f, - 0.259312915132886350f, -0.965793358874083570f, 0.259127721809726150f, - -0.965843063747781510f, - 0.258942518959180580f, -0.965892733110190860f, 0.258757306588058840f, - -0.965942366959485540f, - 0.258572084703170390f, -0.965991965293840570f, 0.258386853311325710f, - -0.966041528111432400f, - 0.258201612419334870f, -0.966091055410438830f, 0.258016362034009070f, - -0.966140547189038750f, - 0.257831102162158930f, -0.966190003445412620f, 0.257645832810596440f, - -0.966239424177741890f, - 0.257460553986133210f, -0.966288809384209580f, 0.257275265695581120f, - -0.966338159063000130f, - 0.257089967945753230f, -0.966387473212298790f, 0.256904660743461850f, - -0.966436751830292650f, - 0.256719344095520720f, -0.966485994915169840f, 0.256534018008743200f, - -0.966535202465119700f, - 0.256348682489942910f, -0.966584374478333120f, 0.256163337545934570f, - -0.966633510953002100f, - 0.255977983183532380f, -0.966682611887320190f, 0.255792619409551670f, - -0.966731677279481840f, - 0.255607246230807550f, -0.966780707127683270f, 0.255421863654115460f, - -0.966829701430121810f, - 0.255236471686291820f, -0.966878660184995910f, 0.255051070334152530f, - -0.966927583390505660f, - 0.254865659604514630f, -0.966976471044852070f, 0.254680239504194990f, - -0.967025323146237900f, - 0.254494810040010790f, -0.967074139692867040f, 0.254309371218780110f, - -0.967122920682944360f, - 0.254123923047320620f, -0.967171666114676640f, 0.253938465532451140f, - -0.967220375986271310f, - 0.253752998680989940f, -0.967269050295937790f, 0.253567522499756610f, - -0.967317689041886310f, - 0.253382036995570270f, -0.967366292222328510f, 0.253196542175250560f, - -0.967414859835477480f, - 0.253011038045617980f, -0.967463391879547440f, 0.252825524613492610f, - -0.967511888352754150f, - 0.252640001885695580f, -0.967560349253314360f, 0.252454469869047900f, - -0.967608774579446380f, - 0.252268928570370810f, -0.967657164329369880f, 0.252083377996486560f, - -0.967705518501305480f, - 0.251897818154216910f, -0.967753837093475510f, 0.251712249050384750f, - -0.967802120104103270f, - 0.251526670691812780f, -0.967850367531413620f, 0.251341083085323880f, - -0.967898579373632660f, - 0.251155486237742030f, -0.967946755628987800f, 0.250969880155890720f, - -0.967994896295707670f, - 0.250784264846594550f, -0.968043001372022260f, 0.250598640316677830f, - -0.968091070856162970f, - 0.250413006572965280f, -0.968139104746362330f, 0.250227363622282540f, - -0.968187103040854420f, - 0.250041711471454650f, -0.968235065737874320f, 0.249856050127308050f, - -0.968282992835658660f, - 0.249670379596668520f, -0.968330884332445300f, 0.249484699886363010f, - -0.968378740226473300f, - 0.249299011003218300f, -0.968426560515983190f, 0.249113312954061360f, - -0.968474345199216820f, - 0.248927605745720260f, -0.968522094274417270f, 0.248741889385022420f, - -0.968569807739828930f, - 0.248556163878796620f, -0.968617485593697540f, 0.248370429233871150f, - -0.968665127834269950f, - 0.248184685457074780f, -0.968712734459794780f, 0.247998932555237220f, - -0.968760305468521430f, - 0.247813170535187620f, -0.968807840858700970f, 0.247627399403756330f, - -0.968855340628585580f, - 0.247441619167773440f, -0.968902804776428870f, 0.247255829834069320f, - -0.968950233300485800f, - 0.247070031409475370f, -0.968997626199012310f, 0.246884223900822430f, - -0.969044983470266240f, - 0.246698407314942500f, -0.969092305112506100f, 0.246512581658667380f, - -0.969139591123992280f, - 0.246326746938829060f, -0.969186841502985950f, 0.246140903162260640f, - -0.969234056247750050f, - 0.245955050335794590f, -0.969281235356548530f, 0.245769188466264670f, - -0.969328378827646660f, - 0.245583317560504000f, -0.969375486659311280f, 0.245397437625346990f, - -0.969422558849810320f, - 0.245211548667627680f, -0.969469595397412950f, 0.245025650694180470f, - -0.969516596300390000f, - 0.244839743711840750f, -0.969563561557013180f, 0.244653827727443320f, - -0.969610491165555870f, - 0.244467902747824210f, -0.969657385124292450f, 0.244281968779819170f, - -0.969704243431498750f, - 0.244096025830264210f, -0.969751066085452140f, 0.243910073905996370f, - -0.969797853084430890f, - 0.243724113013852130f, -0.969844604426714830f, 0.243538143160669180f, - -0.969891320110585100f, - 0.243352164353284880f, -0.969938000134323960f, 0.243166176598536930f, - -0.969984644496215240f, - 0.242980179903263980f, -0.970031253194543970f, 0.242794174274304190f, - -0.970077826227596420f, - 0.242608159718496890f, -0.970124363593660280f, 0.242422136242681050f, - -0.970170865291024360f, - 0.242236103853696040f, -0.970217331317979160f, 0.242050062558382180f, - -0.970263761672816140f, - 0.241864012363579210f, -0.970310156353828110f, 0.241677953276128090f, - -0.970356515359309450f, - 0.241491885302869300f, -0.970402838687555500f, 0.241305808450644390f, - -0.970449126336863090f, - 0.241119722726294730f, -0.970495378305530450f, 0.240933628136661910f, - -0.970541594591857070f, - 0.240747524688588540f, -0.970587775194143630f, 0.240561412388916620f, - -0.970633920110692160f, - 0.240375291244489500f, -0.970680029339806130f, 0.240189161262150040f, - -0.970726102879790110f, - 0.240003022448741500f, -0.970772140728950350f, 0.239816874811108110f, - -0.970818142885593870f, - 0.239630718356093560f, -0.970864109348029470f, 0.239444553090542720f, - -0.970910040114567050f, - 0.239258379021300120f, -0.970955935183517970f, 0.239072196155210660f, - -0.971001794553194690f, - 0.238886004499120170f, -0.971047618221911100f, 0.238699804059873950f, - -0.971093406187982460f, - 0.238513594844318500f, -0.971139158449725090f, 0.238327376859299970f, - -0.971184875005457030f, - 0.238141150111664870f, -0.971230555853497380f, 0.237954914608260650f, - -0.971276200992166490f, - 0.237768670355934210f, -0.971321810419786160f, 0.237582417361533650f, - -0.971367384134679490f, - 0.237396155631906550f, -0.971412922135170940f, 0.237209885173901620f, - -0.971458424419585960f, - 0.237023605994367340f, -0.971503890986251780f, 0.236837318100152380f, - -0.971549321833496630f, - 0.236651021498106460f, -0.971594716959650160f, 0.236464716195078750f, - -0.971640076363043390f, - 0.236278402197919620f, -0.971685400042008540f, 0.236092079513479050f, - -0.971730687994879160f, - 0.235905748148607370f, -0.971775940219990140f, 0.235719408110155930f, - -0.971821156715677700f, - 0.235533059404975460f, -0.971866337480279400f, 0.235346702039917920f, - -0.971911482512134000f, - 0.235160336021834860f, -0.971956591809581600f, 0.234973961357578310f, - -0.972001665370963890f, - 0.234787578054001080f, -0.972046703194623380f, 0.234601186117955550f, - -0.972091705278904430f, - 0.234414785556295250f, -0.972136671622152120f, 0.234228376375873380f, - -0.972181602222713440f, - 0.234041958583543460f, -0.972226497078936270f, 0.233855532186159950f, - -0.972271356189170040f, - 0.233669097190576820f, -0.972316179551765300f, 0.233482653603649170f, - -0.972360967165074140f, - 0.233296201432231560f, -0.972405719027449770f, 0.233109740683179740f, - -0.972450435137246830f, - 0.232923271363349120f, -0.972495115492821190f, 0.232736793479595420f, - -0.972539760092530180f, - 0.232550307038775330f, -0.972584368934732210f, 0.232363812047745010f, - -0.972628942017787270f, - 0.232177308513361770f, -0.972673479340056430f, 0.231990796442482580f, - -0.972717980899902250f, - 0.231804275841964780f, -0.972762446695688570f, 0.231617746718666580f, - -0.972806876725780370f, - 0.231431209079445730f, -0.972851270988544180f, 0.231244662931161110f, - -0.972895629482347760f, - 0.231058108280671280f, -0.972939952205560070f, 0.230871545134835070f, - -0.972984239156551740f, - 0.230684973500512310f, -0.973028490333694100f, 0.230498393384562320f, - -0.973072705735360530f, - 0.230311804793845530f, -0.973116885359925130f, 0.230125207735222020f, - -0.973161029205763530f, - 0.229938602215552260f, -0.973205137271252800f, 0.229751988241697600f, - -0.973249209554771120f, - 0.229565365820518870f, -0.973293246054698250f, 0.229378734958878120f, - -0.973337246769414800f, - 0.229192095663636740f, -0.973381211697303290f, 0.229005447941657390f, - -0.973425140836747030f, - 0.228818791799802360f, -0.973469034186130950f, 0.228632127244934230f, - -0.973512891743841370f, - 0.228445454283916550f, -0.973556713508265560f, 0.228258772923612350f, - -0.973600499477792370f, - 0.228072083170885790f, -0.973644249650811870f, 0.227885385032600700f, - -0.973687964025715670f, - 0.227698678515621170f, -0.973731642600896400f, 0.227511963626812390f, - -0.973775285374748000f, - 0.227325240373038830f, -0.973818892345666100f, 0.227138508761166260f, - -0.973862463512047300f, - 0.226951768798059980f, -0.973905998872289460f, 0.226765020490585720f, - -0.973949498424792170f, - 0.226578263845610110f, -0.973992962167955830f, 0.226391498869999210f, - -0.974036390100182610f, - 0.226204725570620270f, -0.974079782219875680f, 0.226017943954340190f, - -0.974123138525439520f, - 0.225831154028026200f, -0.974166459015280320f, 0.225644355798546440f, - -0.974209743687805110f, - 0.225457549272768540f, -0.974252992541422500f, 0.225270734457561240f, - -0.974296205574542330f, - 0.225083911359792780f, -0.974339382785575860f, 0.224897079986332540f, - -0.974382524172935470f, - 0.224710240344049570f, -0.974425629735034990f, 0.224523392439813170f, - -0.974468699470289580f, - 0.224336536280493690f, -0.974511733377115720f, 0.224149671872960840f, - -0.974554731453931230f, - 0.223962799224085520f, -0.974597693699155050f, 0.223775918340738290f, - -0.974640620111207560f, - 0.223589029229790020f, -0.974683510688510670f, 0.223402131898112480f, - -0.974726365429487320f, - 0.223215226352576960f, -0.974769184332561770f, 0.223028312600055870f, - -0.974811967396159830f, - 0.222841390647421280f, -0.974854714618708430f, 0.222654460501545550f, - -0.974897425998635820f, - 0.222467522169301990f, -0.974940101534371720f, 0.222280575657563370f, - -0.974982741224347140f, - 0.222093620973203590f, -0.975025345066994120f, 0.221906658123096260f, - -0.975067913060746360f, - 0.221719687114115240f, -0.975110445204038890f, 0.221532707953135340f, - -0.975152941495307620f, - 0.221345720647030810f, -0.975195401932990370f, 0.221158725202677100f, - -0.975237826515525820f, - 0.220971721626949060f, -0.975280215241354220f, 0.220784709926722670f, - -0.975322568108916930f, - 0.220597690108873650f, -0.975364885116656870f, 0.220410662180277940f, - -0.975407166263018270f, - 0.220223626147812460f, -0.975449411546446380f, 0.220036582018353550f, - -0.975491620965388110f, - 0.219849529798778750f, -0.975533794518291360f, 0.219662469495965180f, - -0.975575932203605610f, - 0.219475401116790340f, -0.975618034019781750f, 0.219288324668132580f, - -0.975660099965271590f, - 0.219101240156869770f, -0.975702130038528570f, 0.218914147589880900f, - -0.975744124238007270f, - 0.218727046974044600f, -0.975786082562163930f, 0.218539938316239830f, - -0.975828005009455550f, - 0.218352821623346430f, -0.975869891578341030f, 0.218165696902243770f, - -0.975911742267280170f, - 0.217978564159812290f, -0.975953557074734300f, 0.217791423402932120f, - -0.975995335999165880f, - 0.217604274638483670f, -0.976037079039039020f, 0.217417117873348300f, - -0.976078786192818850f, - 0.217229953114406790f, -0.976120457458971910f, 0.217042780368541080f, - -0.976162092835966110f, - 0.216855599642632570f, -0.976203692322270560f, 0.216668410943563790f, - -0.976245255916355800f, - 0.216481214278216900f, -0.976286783616693630f, 0.216294009653474370f, - -0.976328275421757260f, - 0.216106797076219600f, -0.976369731330021140f, 0.215919576553335460f, - -0.976411151339961040f, - 0.215732348091705940f, -0.976452535450054060f, 0.215545111698214660f, - -0.976493883658778540f, - 0.215357867379745550f, -0.976535195964614470f, 0.215170615143183500f, - -0.976576472366042610f, - 0.214983354995412820f, -0.976617712861545640f, 0.214796086943318920f, - -0.976658917449606980f, - 0.214608810993786920f, -0.976700086128711840f, 0.214421527153702190f, - -0.976741218897346550f, - 0.214234235429951100f, -0.976782315753998650f, 0.214046935829419330f, - -0.976823376697157240f, - 0.213859628358993830f, -0.976864401725312640f, 0.213672313025561140f, - -0.976905390836956490f, - 0.213484989836008080f, -0.976946344030581560f, 0.213297658797222430f, - -0.976987261304682390f, - 0.213110319916091360f, -0.977028142657754390f, 0.212922973199503260f, - -0.977068988088294450f, - 0.212735618654345870f, -0.977109797594800880f, 0.212548256287508120f, - -0.977150571175773200f, - 0.212360886105878580f, -0.977191308829712280f, 0.212173508116346080f, - -0.977232010555120320f, - 0.211986122325800410f, -0.977272676350500860f, 0.211798728741130820f, - -0.977313306214358750f, - 0.211611327369227610f, -0.977353900145199960f, 0.211423918216980810f, - -0.977394458141532250f, - 0.211236501291280710f, -0.977434980201864260f, 0.211049076599018500f, - -0.977475466324706050f, - 0.210861644147084830f, -0.977515916508569280f, 0.210674203942371490f, - -0.977556330751966460f, - 0.210486755991769890f, -0.977596709053411780f, 0.210299300302171750f, - -0.977637051411420770f, - 0.210111836880469720f, -0.977677357824509930f, 0.209924365733555860f, - -0.977717628291197570f, - 0.209736886868323370f, -0.977757862810002760f, 0.209549400291665110f, - -0.977798061379446360f, - 0.209361906010474190f, -0.977838223998050430f, 0.209174404031644700f, - -0.977878350664338150f, - 0.208986894362070070f, -0.977918441376834370f, 0.208799377008644980f, - -0.977958496134064830f, - 0.208611851978263460f, -0.977998514934557140f, 0.208424319277820650f, - -0.978038497776839600f, - 0.208236778914211470f, -0.978078444659442380f, 0.208049230894330940f, - -0.978118355580896660f, - 0.207861675225075150f, -0.978158230539735050f, 0.207674111913339540f, - -0.978198069534491400f, - 0.207486540966020700f, -0.978237872563701090f, 0.207298962390014880f, - -0.978277639625900420f, - 0.207111376192218560f, -0.978317370719627650f, 0.206923782379529210f, - -0.978357065843421640f, - 0.206736180958843660f, -0.978396724995823090f, 0.206548571937059940f, - -0.978436348175373730f, - 0.206360955321075680f, -0.978475935380616830f, 0.206173331117788770f, - -0.978515486610096910f, - 0.205985699334098050f, -0.978555001862359550f, 0.205798059976901760f, - -0.978594481135952270f, - 0.205610413053099320f, -0.978633924429423100f, 0.205422758569589780f, - -0.978673331741322210f, - 0.205235096533272380f, -0.978712703070200420f, 0.205047426951047380f, - -0.978752038414610340f, - 0.204859749829814420f, -0.978791337773105670f, 0.204672065176474290f, - -0.978830601144241470f, - 0.204484372997927180f, -0.978869828526574120f, 0.204296673301074430f, - -0.978909019918661310f, - 0.204108966092817010f, -0.978948175319062200f, 0.203921251380056150f, - -0.978987294726337050f, - 0.203733529169694010f, -0.979026378139047580f, 0.203545799468632190f, - -0.979065425555756930f, - 0.203358062283773370f, -0.979104436975029250f, 0.203170317622019920f, - -0.979143412395430230f, - 0.202982565490274460f, -0.979182351815526930f, 0.202794805895440550f, - -0.979221255233887700f, - 0.202607038844421110f, -0.979260122649082020f, 0.202419264344120220f, - -0.979298954059681040f, - 0.202231482401441620f, -0.979337749464256780f, 0.202043693023289280f, - -0.979376508861383170f, - 0.201855896216568160f, -0.979415232249634780f, 0.201668091988182500f, - -0.979453919627588210f, - 0.201480280345037820f, -0.979492570993820700f, 0.201292461294039190f, - -0.979531186346911390f, - 0.201104634842091960f, -0.979569765685440520f, 0.200916800996102370f, - -0.979608309007989450f, - 0.200728959762976140f, -0.979646816313141210f, 0.200541111149620090f, - -0.979685287599479930f, - 0.200353255162940420f, -0.979723722865591170f, 0.200165391809844500f, - -0.979762122110061640f, - 0.199977521097239290f, -0.979800485331479680f, 0.199789643032032120f, - -0.979838812528434740f, - 0.199601757621131050f, -0.979877103699517640f, 0.199413864871443750f, - -0.979915358843320480f, - 0.199225964789878890f, -0.979953577958436740f, 0.199038057383344820f, - -0.979991761043461200f, - 0.198850142658750120f, -0.980029908096989980f, 0.198662220623004320f, - -0.980068019117620650f, - 0.198474291283016360f, -0.980106094103951770f, 0.198286354645696270f, - -0.980144133054583590f, - 0.198098410717953730f, -0.980182135968117320f, 0.197910459506698720f, - -0.980220102843155970f, - 0.197722501018842030f, -0.980258033678303550f, 0.197534535261294000f, - -0.980295928472165290f, - 0.197346562240966000f, -0.980333787223347960f, 0.197158581964769040f, - -0.980371609930459690f, - 0.196970594439614370f, -0.980409396592109910f, 0.196782599672414240f, - -0.980447147206909060f, - 0.196594597670080220f, -0.980484861773469380f, 0.196406588439525050f, - -0.980522540290404090f, - 0.196218571987660850f, -0.980560182756327950f, 0.196030548321400880f, - -0.980597789169856850f, - 0.195842517447657990f, -0.980635359529608120f, 0.195654479373345370f, - -0.980672893834200530f, - 0.195466434105377090f, -0.980710392082253970f, 0.195278381650666520f, - -0.980747854272389750f, - 0.195090322016128330f, -0.980785280403230430f, 0.194902255208676660f, - -0.980822670473399990f, - 0.194714181235225990f, -0.980860024481523870f, 0.194526100102691720f, - -0.980897342426228390f, - 0.194338011817988600f, -0.980934624306141640f, 0.194149916388032530f, - -0.980971870119892840f, - 0.193961813819739010f, -0.981009079866112630f, 0.193773704120023840f, - -0.981046253543432780f, - 0.193585587295803750f, -0.981083391150486590f, 0.193397463353994740f, - -0.981120492685908730f, - 0.193209332301514080f, -0.981157558148334830f, 0.193021194145278320f, - -0.981194587536402320f, - 0.192833048892205290f, -0.981231580848749730f, 0.192644896549212240f, - -0.981268538084016710f, - 0.192456737123216840f, -0.981305459240844670f, 0.192268570621137590f, - -0.981342344317875930f, - 0.192080397049892380f, -0.981379193313754560f, 0.191892216416400310f, - -0.981416006227125550f, - 0.191704028727579940f, -0.981452783056635520f, 0.191515833990350240f, - -0.981489523800932130f, - 0.191327632211630990f, -0.981526228458664660f, 0.191139423398341420f, - -0.981562897028483650f, - 0.190951207557401860f, -0.981599529509040720f, 0.190762984695732250f, - -0.981636125898989080f, - 0.190574754820252800f, -0.981672686196983110f, 0.190386517937884580f, - -0.981709210401678800f, - 0.190198274055548120f, -0.981745698511732990f, 0.190010023180165050f, - -0.981782150525804310f, - 0.189821765318656580f, -0.981818566442552500f, 0.189633500477944220f, - -0.981854946260638630f, - 0.189445228664950340f, -0.981891289978724990f, 0.189256949886596720f, - -0.981927597595475540f, - 0.189068664149806280f, -0.981963869109555240f, 0.188880371461501330f, - -0.982000104519630490f, - 0.188692071828605260f, -0.982036303824369020f, 0.188503765258041080f, - -0.982072467022439890f, - 0.188315451756732120f, -0.982108594112513610f, 0.188127131331602530f, - -0.982144685093261580f, - 0.187938803989575850f, -0.982180739963357200f, 0.187750469737576840f, - -0.982216758721474510f, - 0.187562128582529740f, -0.982252741366289370f, 0.187373780531359110f, - -0.982288687896478830f, - 0.187185425590990440f, -0.982324598310721160f, 0.186997063768348510f, - -0.982360472607696210f, - 0.186808695070359330f, -0.982396310786084690f, 0.186620319503948420f, - -0.982432112844569110f, - 0.186431937076041640f, -0.982467878781833170f, 0.186243547793565670f, - -0.982503608596561720f, - 0.186055151663446630f, -0.982539302287441240f, 0.185866748692611720f, - -0.982574959853159240f, - 0.185678338887987790f, -0.982610581292404750f, 0.185489922256501900f, - -0.982646166603868050f, - 0.185301498805082040f, -0.982681715786240860f, 0.185113068540655510f, - -0.982717228838215990f, - 0.184924631470150870f, -0.982752705758487830f, 0.184736187600495930f, - -0.982788146545751970f, - 0.184547736938619640f, -0.982823551198705240f, 0.184359279491450640f, - -0.982858919716046110f, - 0.184170815265917720f, -0.982894252096474070f, 0.183982344268950600f, - -0.982929548338690060f, - 0.183793866507478390f, -0.982964808441396440f, 0.183605381988431350f, - -0.983000032403296590f, - 0.183416890718739230f, -0.983035220223095640f, 0.183228392705332140f, - -0.983070371899499640f, - 0.183039887955141060f, -0.983105487431216290f, 0.182851376475096310f, - -0.983140566816954500f, - 0.182662858272129360f, -0.983175610055424420f, 0.182474333353171260f, - -0.983210617145337640f, - 0.182285801725153320f, -0.983245588085407070f, 0.182097263395007760f, - -0.983280522874346970f, - 0.181908718369666160f, -0.983315421510872810f, 0.181720166656061170f, - -0.983350283993701500f, - 0.181531608261125130f, -0.983385110321551180f, 0.181343043191790590f, - -0.983419900493141540f, - 0.181154471454990920f, -0.983454654507193270f, 0.180965893057658980f, - -0.983489372362428730f, - 0.180777308006728670f, -0.983524054057571260f, 0.180588716309133280f, - -0.983558699591345900f, - 0.180400117971807270f, -0.983593308962478650f, 0.180211513001684590f, - -0.983627882169697210f, - 0.180022901405699510f, -0.983662419211730250f, 0.179834283190787180f, - -0.983696920087308020f, - 0.179645658363882100f, -0.983731384795162090f, 0.179457026931919950f, - -0.983765813334025240f, - 0.179268388901835880f, -0.983800205702631490f, 0.179079744280565390f, - -0.983834561899716630f, - 0.178891093075044830f, -0.983868881924017220f, 0.178702435292209940f, - -0.983903165774271500f, - 0.178513770938997590f, -0.983937413449218920f, 0.178325100022344140f, - -0.983971624947600270f, - 0.178136422549186320f, -0.984005800268157870f, 0.177947738526461670f, - -0.984039939409634970f, - 0.177759047961107140f, -0.984074042370776450f, 0.177570350860060790f, - -0.984108109150328540f, - 0.177381647230260200f, -0.984142139747038570f, 0.177192937078643310f, - -0.984176134159655320f, - 0.177004220412148860f, -0.984210092386929030f, 0.176815497237715000f, - -0.984244014427611110f, - 0.176626767562280960f, -0.984277900280454370f, 0.176438031392785350f, - -0.984311749944212780f, - 0.176249288736167940f, -0.984345563417641900f, 0.176060539599367960f, - -0.984379340699498510f, - 0.175871783989325040f, -0.984413081788540700f, 0.175683021912979580f, - -0.984446786683527920f, - 0.175494253377271400f, -0.984480455383220930f, 0.175305478389141370f, - -0.984514087886381840f, - 0.175116696955530060f, -0.984547684191773960f, 0.174927909083378160f, - -0.984581244298162180f, - 0.174739114779627310f, -0.984614768204312600f, 0.174550314051218490f, - -0.984648255908992630f, - 0.174361506905093830f, -0.984681707410970940f, 0.174172693348194960f, - -0.984715122709017620f, - 0.173983873387463850f, -0.984748501801904210f, 0.173795047029843270f, - -0.984781844688403350f, - 0.173606214282275410f, -0.984815151367289140f, 0.173417375151703520f, - -0.984848421837337010f, - 0.173228529645070490f, -0.984881656097323700f, 0.173039677769319390f, - -0.984914854146027200f, - 0.172850819531394200f, -0.984948015982227030f, 0.172661954938238270f, - -0.984981141604703960f, - 0.172473083996796030f, -0.985014231012239840f, 0.172284206714011350f, - -0.985047284203618200f, - 0.172095323096829040f, -0.985080301177623800f, 0.171906433152193700f, - -0.985113281933042590f, - 0.171717536887049970f, -0.985146226468662230f, 0.171528634308343500f, - -0.985179134783271020f, - 0.171339725423019260f, -0.985212006875659460f, 0.171150810238023340f, - -0.985244842744618540f, - 0.170961888760301360f, -0.985277642388941220f, 0.170772960996799230f, - -0.985310405807421570f, - 0.170584026954463700f, -0.985343132998854790f, 0.170395086640240920f, - -0.985375823962037710f, - 0.170206140061078120f, -0.985408478695768420f, 0.170017187223922090f, - -0.985441097198846210f, - 0.169828228135719880f, -0.985473679470071810f, 0.169639262803419400f, - -0.985506225508247290f, - 0.169450291233967930f, -0.985538735312176060f, 0.169261313434313890f, - -0.985571208880662740f, - 0.169072329411405180f, -0.985603646212513400f, 0.168883339172190010f, - -0.985636047306535420f, - 0.168694342723617440f, -0.985668412161537550f, 0.168505340072635900f, - -0.985700740776329850f, - 0.168316331226194910f, -0.985733033149723490f, 0.168127316191243350f, - -0.985765289280531310f, - 0.167938294974731230f, -0.985797509167567370f, 0.167749267583608030f, - -0.985829692809647050f, - 0.167560234024823590f, -0.985861840205586980f, 0.167371194305328540f, - -0.985893951354205210f, - 0.167182148432072880f, -0.985926026254321130f, 0.166993096412007770f, - -0.985958064904755460f, - 0.166804038252083870f, -0.985990067304330030f, 0.166614973959252090f, - -0.986022033451868560f, - 0.166425903540464220f, -0.986053963346195440f, 0.166236827002671390f, - -0.986085856986136820f, - 0.166047744352825850f, -0.986117714370520090f, 0.165858655597879430f, - -0.986149535498173860f, - 0.165669560744784140f, -0.986181320367928270f, 0.165480459800492890f, - -0.986213068978614490f, - 0.165291352771957970f, -0.986244781329065460f, 0.165102239666132720f, - -0.986276457418114980f, - 0.164913120489970090f, -0.986308097244598670f, 0.164723995250423190f, - -0.986339700807353000f, - 0.164534863954446110f, -0.986371268105216030f, 0.164345726608992190f, - -0.986402799137027220f, - 0.164156583221015890f, -0.986434293901627070f, 0.163967433797471110f, - -0.986465752397857940f, - 0.163778278345312690f, -0.986497174624562880f, 0.163589116871495160f, - -0.986528560580586690f, - 0.163399949382973230f, -0.986559910264775410f, 0.163210775886702460f, - -0.986591223675976400f, - 0.163021596389637810f, -0.986622500813038480f, 0.162832410898735260f, - -0.986653741674811350f, - 0.162643219420950450f, -0.986684946260146690f, 0.162454021963239190f, - -0.986716114567897100f, - 0.162264818532558110f, -0.986747246596916480f, 0.162075609135863330f, - -0.986778342346060430f, - 0.161886393780111910f, -0.986809401814185420f, 0.161697172472260540f, - -0.986840425000149680f, - 0.161507945219266150f, -0.986871411902812470f, 0.161318712028086540f, - -0.986902362521034470f, - 0.161129472905678780f, -0.986933276853677710f, 0.160940227859001140f, - -0.986964154899605650f, - 0.160750976895011390f, -0.986994996657682870f, 0.160561720020667510f, - -0.987025802126775600f, - 0.160372457242928400f, -0.987056571305750970f, 0.160183188568752240f, - -0.987087304193477900f, - 0.159993914005098350f, -0.987118000788826280f, 0.159804633558925380f, - -0.987148661090667570f, - 0.159615347237193090f, -0.987179285097874340f, 0.159426055046860750f, - -0.987209872809320820f, - 0.159236756994887850f, -0.987240424223882250f, 0.159047453088234840f, - -0.987270939340435420f, - 0.158858143333861390f, -0.987301418157858430f, 0.158668827738728370f, - -0.987331860675030430f, - 0.158479506309796100f, -0.987362266890832400f, 0.158290179054025180f, - -0.987392636804146240f, - 0.158100845978377090f, -0.987422970413855410f, 0.157911507089812640f, - -0.987453267718844560f, - 0.157722162395293690f, -0.987483528717999710f, 0.157532811901781670f, - -0.987513753410208420f, - 0.157343455616238280f, -0.987543941794359230f, 0.157154093545626010f, - -0.987574093869342360f, - 0.156964725696906750f, -0.987604209634049160f, 0.156775352077043430f, - -0.987634289087372160f, - 0.156585972692998590f, -0.987664332228205710f, 0.156396587551734940f, - -0.987694339055445130f, - 0.156207196660216040f, -0.987724309567986960f, 0.156017800025404830f, - -0.987754243764729530f, - 0.155828397654265320f, -0.987784141644572180f, 0.155638989553760850f, - -0.987814003206415550f, - 0.155449575730855880f, -0.987843828449161740f, 0.155260156192514380f, - -0.987873617371714200f, - 0.155070730945700510f, -0.987903369972977790f, 0.154881299997379400f, - -0.987933086251858380f, - 0.154691863354515400f, -0.987962766207263420f, 0.154502421024073990f, - -0.987992409838101880f, - 0.154312973013020240f, -0.988022017143283530f, 0.154123519328319360f, - -0.988051588121720110f, - 0.153934059976937460f, -0.988081122772324070f, 0.153744594965840000f, - -0.988110621094009820f, - 0.153555124301993500f, -0.988140083085692570f, 0.153365647992364020f, - -0.988169508746289060f, - 0.153176166043917870f, -0.988198898074717610f, 0.152986678463622160f, - -0.988228251069897420f, - 0.152797185258443410f, -0.988257567730749460f, 0.152607686435349140f, - -0.988286848056195710f, - 0.152418182001306500f, -0.988316092045159690f, 0.152228671963282770f, - -0.988345299696566150f, - 0.152039156328246160f, -0.988374471009341280f, 0.151849635103164180f, - -0.988403605982412390f, - 0.151660108295005400f, -0.988432704614708340f, 0.151470575910737760f, - -0.988461766905159300f, - 0.151281037957330250f, -0.988490792852696590f, 0.151091494441751430f, - -0.988519782456253270f, - 0.150901945370970040f, -0.988548735714763200f, 0.150712390751955720f, - -0.988577652627162020f, - 0.150522830591677370f, -0.988606533192386450f, 0.150333264897105050f, - -0.988635377409374790f, - 0.150143693675208330f, -0.988664185277066230f, 0.149954116932956990f, - -0.988692956794401940f, - 0.149764534677321620f, -0.988721691960323780f, 0.149574946915272210f, - -0.988750390773775360f, - 0.149385353653779810f, -0.988779053233701520f, 0.149195754899814960f, - -0.988807679339048340f, - 0.149006150660348470f, -0.988836269088763540f, 0.148816540942352030f, - -0.988864822481795640f, - 0.148626925752796540f, -0.988893339517095130f, 0.148437305098654050f, - -0.988921820193613190f, - 0.148247678986896200f, -0.988950264510302990f, 0.148058047424494740f, - -0.988978672466118480f, - 0.147868410418422360f, -0.989007044060015270f, 0.147678767975650970f, - -0.989035379290950310f, - 0.147489120103153680f, -0.989063678157881540f, 0.147299466807902820f, - -0.989091940659768800f, - 0.147109808096871850f, -0.989120166795572690f, 0.146920143977033760f, - -0.989148356564255590f, - 0.146730474455361750f, -0.989176509964781010f, 0.146540799538829870f, - -0.989204626996113780f, - 0.146351119234411440f, -0.989232707657220050f, 0.146161433549080950f, - -0.989260751947067640f, - 0.145971742489812370f, -0.989288759864625170f, 0.145782046063579860f, - -0.989316731408863000f, - 0.145592344277358450f, -0.989344666578752640f, 0.145402637138122540f, - -0.989372565373267010f, - 0.145212924652847520f, -0.989400427791380380f, 0.145023206828508360f, - -0.989428253832068230f, - 0.144833483672080240f, -0.989456043494307710f, 0.144643755190539150f, - -0.989483796777076760f, - 0.144454021390860440f, -0.989511513679355190f, 0.144264282280020530f, - -0.989539194200123930f, - 0.144074537864995330f, -0.989566838338365120f, 0.143884788152761010f, - -0.989594446093062460f, - 0.143695033150294580f, -0.989622017463200780f, 0.143505272864572290f, - -0.989649552447766530f, - 0.143315507302571590f, -0.989677051045747210f, 0.143125736471269140f, - -0.989704513256131850f, - 0.142935960377642700f, -0.989731939077910570f, 0.142746179028669620f, - -0.989759328510075200f, - 0.142556392431327340f, -0.989786681551618640f, 0.142366600592594260f, - -0.989813998201535260f, - 0.142176803519448000f, -0.989841278458820530f, 0.141987001218867340f, - -0.989868522322471580f, - 0.141797193697830530f, -0.989895729791486660f, 0.141607380963316020f, - -0.989922900864865450f, - 0.141417563022303130f, -0.989950035541608990f, 0.141227739881770480f, - -0.989977133820719610f, - 0.141037911548697770f, -0.990004195701200910f, 0.140848078030064220f, - -0.990031221182058000f, - 0.140658239332849240f, -0.990058210262297120f, 0.140468395464033110f, - -0.990085162940925970f, - 0.140278546430595420f, -0.990112079216953770f, 0.140088692239516780f, - -0.990138959089390650f, - 0.139898832897777380f, -0.990165802557248400f, 0.139708968412357580f, - -0.990192609619540030f, - 0.139519098790238600f, -0.990219380275280000f, 0.139329224038400980f, - -0.990246114523483990f, - 0.139139344163826280f, -0.990272812363169110f, 0.138949459173495440f, - -0.990299473793353590f, - 0.138759569074390380f, -0.990326098813057330f, 0.138569673873492640f, - -0.990352687421301340f, - 0.138379773577783890f, -0.990379239617108160f, 0.138189868194246640f, - -0.990405755399501260f, - 0.137999957729862760f, -0.990432234767505970f, 0.137810042191615130f, - -0.990458677720148620f, - 0.137620121586486180f, -0.990485084256456980f, 0.137430195921458550f, - -0.990511454375460290f, - 0.137240265203515700f, -0.990537788076188750f, 0.137050329439640380f, - -0.990564085357674370f, - 0.136860388636816430f, -0.990590346218950150f, 0.136670442802027230f, - -0.990616570659050620f, - 0.136480491942256310f, -0.990642758677011570f, 0.136290536064488070f, - -0.990668910271869980f, - 0.136100575175706200f, -0.990695025442664630f, 0.135910609282895440f, - -0.990721104188435180f, - 0.135720638393040080f, -0.990747146508222710f, 0.135530662513124620f, - -0.990773152401069780f, - 0.135340681650134330f, -0.990799121866020370f, 0.135150695811053850f, - -0.990825054902119470f, - 0.134960705002868830f, -0.990850951508413620f, 0.134770709232564290f, - -0.990876811683950810f, - 0.134580708507126220f, -0.990902635427780010f, 0.134390702833540240f, - -0.990928422738951990f, - 0.134200692218792020f, -0.990954173616518500f, 0.134010676669868210f, - -0.990979888059532740f, - 0.133820656193754690f, -0.991005566067049370f, 0.133630630797438390f, - -0.991031207638124130f, - 0.133440600487905820f, -0.991056812771814340f, 0.133250565272143570f, - -0.991082381467178640f, - 0.133060525157139180f, -0.991107913723276780f, 0.132870480149879400f, - -0.991133409539170170f, - 0.132680430257352130f, -0.991158868913921350f, 0.132490375486544710f, - -0.991184291846594180f, - 0.132300315844444680f, -0.991209678336254060f, 0.132110251338040470f, - -0.991235028381967420f, - 0.131920181974319760f, -0.991260341982802440f, 0.131730107760271280f, - -0.991285619137828200f, - 0.131540028702883280f, -0.991310859846115440f, 0.131349944809144220f, - -0.991336064106736140f, - 0.131159856086043410f, -0.991361231918763460f, 0.130969762540569380f, - -0.991386363281272280f, - 0.130779664179711790f, -0.991411458193338540f, 0.130589561010459600f, - -0.991436516654039420f, - 0.130399453039802740f, -0.991461538662453790f, 0.130209340274730770f, - -0.991486524217661480f, - 0.130019222722233350f, -0.991511473318743900f, 0.129829100389301010f, - -0.991536385964783880f, - 0.129638973282923540f, -0.991561262154865290f, 0.129448841410091830f, - -0.991586101888073500f, - 0.129258704777796270f, -0.991610905163495370f, 0.129068563393027410f, - -0.991635671980218740f, - 0.128878417262776660f, -0.991660402337333210f, 0.128688266394034690f, - -0.991685096233929530f, - 0.128498110793793220f, -0.991709753669099530f, 0.128307950469043590f, - -0.991734374641936810f, - 0.128117785426777150f, -0.991758959151536110f, 0.127927615673986190f, - -0.991783507196993490f, - 0.127737441217662280f, -0.991808018777406430f, 0.127547262064798050f, - -0.991832493891873780f, - 0.127357078222385570f, -0.991856932539495360f, 0.127166889697417180f, - -0.991881334719373010f, - 0.126976696496885980f, -0.991905700430609330f, 0.126786498627784430f, - -0.991930029672308480f, - 0.126596296097105960f, -0.991954322443575950f, 0.126406088911843320f, - -0.991978578743518580f, - 0.126215877078990400f, -0.992002798571244520f, 0.126025660605540460f, - -0.992026981925863360f, - 0.125835439498487020f, -0.992051128806485720f, 0.125645213764824380f, - -0.992075239212224070f, - 0.125454983411546210f, -0.992099313142191800f, 0.125264748445647110f, - -0.992123350595503720f, - 0.125074508874121300f, -0.992147351571276090f, 0.124884264703963150f, - -0.992171316068626520f, - 0.124694015942167770f, -0.992195244086673920f, 0.124503762595729650f, - -0.992219135624538450f, - 0.124313504671644300f, -0.992242990681341700f, 0.124123242176906760f, - -0.992266809256206580f, - 0.123932975118512200f, -0.992290591348257370f, 0.123742703503456630f, - -0.992314336956619640f, - 0.123552427338735370f, -0.992338046080420420f, 0.123362146631344750f, - -0.992361718718787870f, - 0.123171861388280650f, -0.992385354870851670f, 0.122981571616539080f, - -0.992408954535742850f, - 0.122791277323116900f, -0.992432517712593550f, 0.122600978515010240f, - -0.992456044400537700f, - 0.122410675199216280f, -0.992479534598709970f, 0.122220367382731500f, - -0.992502988306246950f, - 0.122030055072553410f, -0.992526405522286100f, 0.121839738275679020f, - -0.992549786245966570f, - 0.121649416999105540f, -0.992573130476428810f, 0.121459091249830950f, - -0.992596438212814290f, - 0.121268761034852550f, -0.992619709454266140f, 0.121078426361168710f, - -0.992642944199928820f, - 0.120888087235777220f, -0.992666142448948020f, 0.120697743665676120f, - -0.992689304200470750f, - 0.120507395657864240f, -0.992712429453645460f, 0.120317043219339670f, - -0.992735518207621850f, - 0.120126686357101580f, -0.992758570461551140f, 0.119936325078148620f, - -0.992781586214585570f, - 0.119745959389479630f, -0.992804565465879140f, 0.119555589298094230f, - -0.992827508214586760f, - 0.119365214810991350f, -0.992850414459865100f, 0.119174835935170960f, - -0.992873284200871730f, - 0.118984452677632520f, -0.992896117436765980f, 0.118794065045375670f, - -0.992918914166708300f, - 0.118603673045400840f, -0.992941674389860470f, 0.118413276684707770f, - -0.992964398105385610f, - 0.118222875970297250f, -0.992987085312448390f, 0.118032470909169300f, - -0.993009736010214580f, - 0.117842061508325020f, -0.993032350197851410f, 0.117651647774765000f, - -0.993054927874527320f, - 0.117461229715489990f, -0.993077469039412300f, 0.117270807337501560f, - -0.993099973691677570f, - 0.117080380647800550f, -0.993122441830495580f, 0.116889949653388850f, - -0.993144873455040430f, - 0.116699514361267840f, -0.993167268564487230f, 0.116509074778439050f, - -0.993189627158012620f, - 0.116318630911904880f, -0.993211949234794500f, 0.116128182768666920f, - -0.993234234794012290f, - 0.115937730355727850f, -0.993256483834846440f, 0.115747273680089870f, - -0.993278696356479030f, - 0.115556812748755290f, -0.993300872358093280f, 0.115366347568727250f, - -0.993323011838873950f, - 0.115175878147008180f, -0.993345114798006910f, 0.114985404490601530f, - -0.993367181234679600f, - 0.114794926606510250f, -0.993389211148080650f, 0.114604444501737460f, - -0.993411204537400060f, - 0.114413958183287050f, -0.993433161401829360f, 0.114223467658162260f, - -0.993455081740560960f, - 0.114032972933367300f, -0.993476965552789190f, 0.113842474015905660f, - -0.993498812837709360f, - 0.113651970912781920f, -0.993520623594518090f, 0.113461463631000080f, - -0.993542397822413600f, - 0.113270952177564360f, -0.993564135520595300f, 0.113080436559479720f, - -0.993585836688263950f, - 0.112889916783750470f, -0.993607501324621610f, 0.112699392857381910f, - -0.993629129428871720f, - 0.112508864787378830f, -0.993650721000219120f, 0.112318332580746190f, - -0.993672276037870010f, - 0.112127796244489750f, -0.993693794541031680f, 0.111937255785614560f, - -0.993715276508913230f, - 0.111746711211126660f, -0.993736721940724600f, 0.111556162528031630f, - -0.993758130835677430f, - 0.111365609743335190f, -0.993779503192984580f, 0.111175052864043830f, - -0.993800839011860120f, - 0.110984491897163380f, -0.993822138291519660f, 0.110793926849700630f, - -0.993843401031180180f, - 0.110603357728661910f, -0.993864627230059750f, 0.110412784541053660f, - -0.993885816887378090f, - 0.110222207293883180f, -0.993906970002356060f, 0.110031625994157000f, - -0.993928086574215830f, - 0.109841040648882680f, -0.993949166602181130f, 0.109650451265067080f, - -0.993970210085476920f, - 0.109459857849718030f, -0.993991217023329380f, 0.109269260409842920f, - -0.994012187414966220f, - 0.109078658952449240f, -0.994033121259616400f, 0.108888053484545310f, - -0.994054018556510210f, - 0.108697444013138670f, -0.994074879304879370f, 0.108506830545237980f, - -0.994095703503956930f, - 0.108316213087851300f, -0.994116491152977070f, 0.108125591647986880f, - -0.994137242251175720f, - 0.107934966232653760f, -0.994157956797789730f, 0.107744336848860260f, - -0.994178634792057590f, - 0.107553703503615710f, -0.994199276233218910f, 0.107363066203928920f, - -0.994219881120514850f, - 0.107172424956808870f, -0.994240449453187900f, 0.106981779769265340f, - -0.994260981230481790f, - 0.106791130648307380f, -0.994281476451641550f, 0.106600477600945030f, - -0.994301935115913580f, - 0.106409820634187840f, -0.994322357222545810f, 0.106219159755045520f, - -0.994342742770787270f, - 0.106028494970528530f, -0.994363091759888570f, 0.105837826287646670f, - -0.994383404189101430f, - 0.105647153713410700f, -0.994403680057679100f, 0.105456477254830660f, - -0.994423919364875950f, - 0.105265796918917650f, -0.994444122109948040f, 0.105075112712682180f, - -0.994464288292152390f, - 0.104884424643134970f, -0.994484417910747600f, 0.104693732717287500f, - -0.994504510964993590f, - 0.104503036942150550f, -0.994524567454151740f, 0.104312337324735870f, - -0.994544587377484300f, - 0.104121633872054730f, -0.994564570734255420f, 0.103930926591118540f, - -0.994584517523730340f, - 0.103740215488939480f, -0.994604427745175660f, 0.103549500572529040f, - -0.994624301397859400f, - 0.103358781848899700f, -0.994644138481050710f, 0.103168059325063390f, - -0.994663938994020280f, - 0.102977333008032250f, -0.994683702936040250f, 0.102786602904819150f, - -0.994703430306383860f, - 0.102595869022436280f, -0.994723121104325700f, 0.102405131367896790f, - -0.994742775329142010f, - 0.102214389948213370f, -0.994762392980109930f, 0.102023644770398800f, - -0.994781974056508260f, - 0.101832895841466670f, -0.994801518557617110f, 0.101642143168429830f, - -0.994821026482717860f, - 0.101451386758302160f, -0.994840497831093180f, 0.101260626618096800f, - -0.994859932602027320f, - 0.101069862754827880f, -0.994879330794805620f, 0.100879095175509010f, - -0.994898692408714870f, - 0.100688323887153970f, -0.994918017443043200f, 0.100497548896777310f, - -0.994937305897080070f, - 0.100306770211392820f, -0.994956557770116380f, 0.100115987838015370f, - -0.994975773061444140f, - 0.099925201783659226f, -0.994994951770357020f, 0.099734412055338839f, - -0.995014093896149700f, - 0.099543618660069444f, -0.995033199438118630f, 0.099352821604865513f, - -0.995052268395561160f, - 0.099162020896742573f, -0.995071300767776170f, 0.098971216542715582f, - -0.995090296554063890f, - 0.098780408549799664f, -0.995109255753726110f, 0.098589596925010708f, - -0.995128178366065490f, - 0.098398781675363881f, -0.995147064390386470f, 0.098207962807875346f, - -0.995165913825994620f, - 0.098017140329560770f, -0.995184726672196820f, 0.097826314247435903f, - -0.995203502928301510f, - 0.097635484568517339f, -0.995222242593618240f, 0.097444651299820870f, - -0.995240945667458130f, - 0.097253814448363354f, -0.995259612149133390f, 0.097062974021160875f, - -0.995278242037957670f, - 0.096872130025230527f, -0.995296835333246090f, 0.096681282467588864f, - -0.995315392034315070f, - 0.096490431355252607f, -0.995333912140482280f, 0.096299576695239225f, - -0.995352395651066810f, - 0.096108718494565468f, -0.995370842565388990f, 0.095917856760249096f, - -0.995389252882770690f, - 0.095726991499307315f, -0.995407626602534900f, 0.095536122718757485f, - -0.995425963724006160f, - 0.095345250425617742f, -0.995444264246510340f, 0.095154374626905472f, - -0.995462528169374420f, - 0.094963495329639061f, -0.995480755491926940f, 0.094772612540836410f, - -0.995498946213497770f, - 0.094581726267515473f, -0.995517100333418110f, 0.094390836516695067f, - -0.995535217851020390f, - 0.094199943295393190f, -0.995553298765638470f, 0.094009046610628907f, - -0.995571343076607770f, - 0.093818146469420494f, -0.995589350783264600f, 0.093627242878787237f, - -0.995607321884947050f, - 0.093436335845747912f, -0.995625256380994310f, 0.093245425377321389f, - -0.995643154270746900f, - 0.093054511480527333f, -0.995661015553546910f, 0.092863594162384697f, - -0.995678840228737540f, - 0.092672673429913366f, -0.995696628295663520f, 0.092481749290132753f, - -0.995714379753670610f, - 0.092290821750062355f, -0.995732094602106430f, 0.092099890816722485f, - -0.995749772840319400f, - 0.091908956497132696f, -0.995767414467659820f, 0.091718018798313525f, - -0.995785019483478750f, - 0.091527077727284981f, -0.995802587887129160f, 0.091336133291067212f, - -0.995820119677964910f, - 0.091145185496681130f, -0.995837614855341610f, 0.090954234351146898f, - -0.995855073418615790f, - 0.090763279861485704f, -0.995872495367145730f, 0.090572322034718156f, - -0.995889880700290720f, - 0.090381360877865011f, -0.995907229417411720f, 0.090190396397947820f, - -0.995924541517870690f, - 0.089999428601987341f, -0.995941817001031350f, 0.089808457497005362f, - -0.995959055866258320f, - 0.089617483090022917f, -0.995976258112917790f, 0.089426505388062016f, - -0.995993423740377360f, - 0.089235524398144139f, -0.996010552748005870f, 0.089044540127290905f, - -0.996027645135173610f, - 0.088853552582524684f, -0.996044700901251970f, 0.088662561770867121f, - -0.996061720045614000f, - 0.088471567699340822f, -0.996078702567633980f, 0.088280570374967879f, - -0.996095648466687300f, - 0.088089569804770507f, -0.996112557742151130f, 0.087898565995771685f, - -0.996129430393403740f, - 0.087707558954993645f, -0.996146266419824620f, 0.087516548689459586f, - -0.996163065820794950f, - 0.087325535206192226f, -0.996179828595696870f, 0.087134518512214321f, - -0.996196554743914220f, - 0.086943498614549489f, -0.996213244264832040f, 0.086752475520220515f, - -0.996229897157836500f, - 0.086561449236251239f, -0.996246513422315520f, 0.086370419769664919f, - -0.996263093057658030f, - 0.086179387127484922f, -0.996279636063254650f, 0.085988351316735448f, - -0.996296142438496850f, - 0.085797312344439880f, -0.996312612182778000f, 0.085606270217622613f, - -0.996329045295492380f, - 0.085415224943307277f, -0.996345441776035900f, 0.085224176528518519f, - -0.996361801623805720f, - 0.085033124980280414f, -0.996378124838200210f, 0.084842070305617148f, - -0.996394411418619290f, - 0.084651012511553700f, -0.996410661364464100f, 0.084459951605114297f, - -0.996426874675137240f, - 0.084268887593324127f, -0.996443051350042630f, 0.084077820483207846f, - -0.996459191388585410f, - 0.083886750281790226f, -0.996475294790172160f, 0.083695676996096827f, - -0.996491361554210920f, - 0.083504600633152404f, -0.996507391680110820f, 0.083313521199982740f, - -0.996523385167282450f, - 0.083122438703613077f, -0.996539342015137940f, 0.082931353151068726f, - -0.996555262223090540f, - 0.082740264549375803f, -0.996571145790554840f, 0.082549172905559659f, - -0.996586992716946950f, - 0.082358078226646619f, -0.996602803001684130f, 0.082166980519662466f, - -0.996618576644185070f, - 0.081975879791633108f, -0.996634313643869900f, 0.081784776049585201f, - -0.996650014000160070f, - 0.081593669300544638f, -0.996665677712478160f, 0.081402559551538328f, - -0.996681304780248300f, - 0.081211446809592386f, -0.996696895202896060f, 0.081020331081733912f, - -0.996712448979848010f, - 0.080829212374989468f, -0.996727966110532490f, 0.080638090696385709f, - -0.996743446594378860f, - 0.080446966052950097f, -0.996758890430818000f, 0.080255838451709291f, - -0.996774297619282050f, - 0.080064707899690932f, -0.996789668159204560f, 0.079873574403922148f, - -0.996805002050020320f, - 0.079682437971430126f, -0.996820299291165670f, 0.079491298609242866f, - -0.996835559882078170f, - 0.079300156324387569f, -0.996850783822196610f, 0.079109011123892431f, - -0.996865971110961310f, - 0.078917863014785095f, -0.996881121747813850f, 0.078726712004093313f, - -0.996896235732197210f, - 0.078535558098845590f, -0.996911313063555740f, 0.078344401306069678f, - -0.996926353741335090f, - 0.078153241632794315f, -0.996941357764982160f, 0.077962079086047645f, - -0.996956325133945280f, - 0.077770913672857989f, -0.996971255847674320f, 0.077579745400254363f, - -0.996986149905620180f, - 0.077388574275265049f, -0.997001007307235290f, 0.077197400304919297f, - -0.997015828051973310f, - 0.077006223496245585f, -0.997030612139289450f, 0.076815043856273399f, - -0.997045359568640040f, - 0.076623861392031617f, -0.997060070339482960f, 0.076432676110549283f, - -0.997074744451277310f, - 0.076241488018856149f, -0.997089381903483400f, 0.076050297123981231f, - -0.997103982695563330f, - 0.075859103432954503f, -0.997118546826979980f, 0.075667906952805383f, - -0.997133074297198110f, - 0.075476707690563416f, -0.997147565105683480f, 0.075285505653258880f, - -0.997162019251903290f, - 0.075094300847921291f, -0.997176436735326190f, 0.074903093281581137f, - -0.997190817555421940f, - 0.074711882961268378f, -0.997205161711661850f, 0.074520669894013014f, - -0.997219469203518670f, - 0.074329454086845867f, -0.997233740030466160f, 0.074138235546796952f, - -0.997247974191979860f, - 0.073947014280897269f, -0.997262171687536170f, 0.073755790296177265f, - -0.997276332516613180f, - 0.073564563599667454f, -0.997290456678690210f, 0.073373334198399157f, - -0.997304544173247990f, - 0.073182102099402888f, -0.997318594999768600f, 0.072990867309710133f, - -0.997332609157735470f, - 0.072799629836351618f, -0.997346586646633230f, 0.072608389686359048f, - -0.997360527465947940f, - 0.072417146866763538f, -0.997374431615167030f, 0.072225901384596336f, - -0.997388299093779460f, - 0.072034653246889416f, -0.997402129901275300f, 0.071843402460674000f, - -0.997415924037145960f, - 0.071652149032982254f, -0.997429681500884180f, 0.071460892970845832f, - -0.997443402291984360f, - 0.071269634281296415f, -0.997457086409941910f, 0.071078372971366502f, - -0.997470733854253670f, - 0.070887109048087787f, -0.997484344624417930f, 0.070695842518492924f, - -0.997497918719934210f, - 0.070504573389614009f, -0.997511456140303450f, 0.070313301668483263f, - -0.997524956885027960f, - 0.070122027362133646f, -0.997538420953611230f, 0.069930750477597295f, - -0.997551848345558430f, - 0.069739471021907376f, -0.997565239060375750f, 0.069548189002096472f, - -0.997578593097570800f, - 0.069356904425197236f, -0.997591910456652630f, 0.069165617298243109f, - -0.997605191137131640f, - 0.068974327628266732f, -0.997618435138519550f, 0.068783035422301728f, - -0.997631642460329320f, - 0.068591740687380900f, -0.997644813102075420f, 0.068400443430538069f, - -0.997657947063273710f, - 0.068209143658806454f, -0.997671044343441000f, 0.068017841379219388f, - -0.997684104942096030f, - 0.067826536598810966f, -0.997697128858758500f, 0.067635229324614451f, - -0.997710116092949570f, - 0.067443919563664106f, -0.997723066644191640f, 0.067252607322993652f, - -0.997735980512008620f, - 0.067061292609636836f, -0.997748857695925690f, 0.066869975430628226f, - -0.997761698195469560f, - 0.066678655793001543f, -0.997774502010167820f, 0.066487333703791507f, - -0.997787269139549960f, - 0.066296009170032283f, -0.997799999583146470f, 0.066104682198758091f, - -0.997812693340489280f, - 0.065913352797003930f, -0.997825350411111640f, 0.065722020971803977f, - -0.997837970794548280f, - 0.065530686730193397f, -0.997850554490335110f, 0.065339350079206798f, - -0.997863101498009500f, - 0.065148011025878860f, -0.997875611817110150f, 0.064956669577245010f, - -0.997888085447177110f, - 0.064765325740339871f, -0.997900522387751620f, 0.064573979522199065f, - -0.997912922638376610f, - 0.064382630929857410f, -0.997925286198596000f, 0.064191279970350679f, - -0.997937613067955250f, - 0.063999926650714078f, -0.997949903246001190f, 0.063808570977982898f, - -0.997962156732281950f, - 0.063617212959193190f, -0.997974373526346990f, 0.063425852601380200f, - -0.997986553627747020f, - 0.063234489911580136f, -0.997998697036034390f, 0.063043124896828631f, - -0.998010803750762450f, - 0.062851757564161420f, -0.998022873771486240f, 0.062660387920614985f, - -0.998034907097761770f, - 0.062469015973224969f, -0.998046903729146840f, 0.062277641729028041f, - -0.998058863665200250f, - 0.062086265195060247f, -0.998070786905482340f, 0.061894886378357744f, - -0.998082673449554590f, - 0.061703505285957416f, -0.998094523296980010f, 0.061512121924895365f, - -0.998106336447323050f, - 0.061320736302208648f, -0.998118112900149180f, 0.061129348424933755f, - -0.998129852655025520f, - 0.060937958300107238f, -0.998141555711520520f, 0.060746565934766412f, - -0.998153222069203650f, - 0.060555171335947781f, -0.998164851727646240f, 0.060363774510688827f, - -0.998176444686420530f, - 0.060172375466026218f, -0.998188000945100300f, 0.059980974208997596f, - -0.998199520503260660f, - 0.059789570746640007f, -0.998211003360478190f, 0.059598165085990598f, - -0.998222449516330550f, - 0.059406757234087247f, -0.998233858970396850f, 0.059215347197967026f, - -0.998245231722257880f, - 0.059023934984667986f, -0.998256567771495180f, 0.058832520601227581f, - -0.998267867117692110f, - 0.058641104054683348f, -0.998279129760433200f, 0.058449685352073573f, - -0.998290355699304350f, - 0.058258264500435732f, -0.998301544933892890f, 0.058066841506808263f, - -0.998312697463787260f, - 0.057875416378229017f, -0.998323813288577560f, 0.057683989121735932f, - -0.998334892407855000f, - 0.057492559744367684f, -0.998345934821212370f, 0.057301128253162144f, - -0.998356940528243420f, - 0.057109694655158132f, -0.998367909528543820f, 0.056918258957393907f, - -0.998378841821709990f, - 0.056726821166907783f, -0.998389737407340160f, 0.056535381290738825f, - -0.998400596285033640f, - 0.056343939335925283f, -0.998411418454391300f, 0.056152495309506383f, - -0.998422203915015020f, - 0.055961049218520520f, -0.998432952666508440f, 0.055769601070007072f, - -0.998443664708476340f, - 0.055578150871004817f, -0.998454340040524800f, 0.055386698628552604f, - -0.998464978662261250f, - 0.055195244349690031f, -0.998475580573294770f, 0.055003788041455885f, - -0.998486145773235360f, - 0.054812329710889909f, -0.998496674261694640f, 0.054620869365031251f, - -0.998507166038285490f, - 0.054429407010919147f, -0.998517621102622210f, 0.054237942655593556f, - -0.998528039454320230f, - 0.054046476306093640f, -0.998538421092996730f, 0.053855007969459509f, - -0.998548766018269920f, - 0.053663537652730679f, -0.998559074229759310f, 0.053472065362946755f, - -0.998569345727086110f, - 0.053280591107148056f, -0.998579580509872500f, 0.053089114892374119f, - -0.998589778577742230f, - 0.052897636725665401f, -0.998599939930320370f, 0.052706156614061798f, - -0.998610064567233340f, - 0.052514674564603257f, -0.998620152488108870f, 0.052323190584330471f, - -0.998630203692576050f, - 0.052131704680283317f, -0.998640218180265270f, 0.051940216859502626f, - -0.998650195950808280f, - 0.051748727129028414f, -0.998660137003838490f, 0.051557235495901653f, - -0.998670041338990070f, - 0.051365741967162731f, -0.998679908955899090f, 0.051174246549852087f, - -0.998689739854202620f, - 0.050982749251010900f, -0.998699534033539280f, 0.050791250077679546f, - -0.998709291493549030f, - 0.050599749036899337f, -0.998719012233872940f, 0.050408246135710995f, - -0.998728696254153720f, - 0.050216741381155325f, -0.998738343554035230f, 0.050025234780273840f, - -0.998747954133162860f, - 0.049833726340107257f, -0.998757527991183340f, 0.049642216067697226f, - -0.998767065127744380f, - 0.049450703970084824f, -0.998776565542495610f, 0.049259190054311168f, - -0.998786029235087640f, - 0.049067674327418126f, -0.998795456205172410f, 0.048876156796446746f, - -0.998804846452403420f, - 0.048684637468439020f, -0.998814199976435390f, 0.048493116350436342f, - -0.998823516776924380f, - 0.048301593449480172f, -0.998832796853527990f, 0.048110068772612716f, - -0.998842040205904840f, - 0.047918542326875327f, -0.998851246833715180f, 0.047727014119310344f, - -0.998860416736620520f, - 0.047535484156959261f, -0.998869549914283560f, 0.047343952446864526f, - -0.998878646366368690f, - 0.047152418996068000f, -0.998887706092541290f, 0.046960883811611599f, - -0.998896729092468410f, - 0.046769346900537960f, -0.998905715365818290f, 0.046577808269888908f, - -0.998914664912260440f, - 0.046386267926707213f, -0.998923577731465780f, 0.046194725878035046f, - -0.998932453823106690f, - 0.046003182130914644f, -0.998941293186856870f, 0.045811636692388955f, - -0.998950095822391250f, - 0.045620089569500123f, -0.998958861729386080f, 0.045428540769291224f, - -0.998967590907519300f, - 0.045236990298804750f, -0.998976283356469820f, 0.045045438165083225f, - -0.998984939075918010f, - 0.044853884375169933f, -0.998993558065545680f, 0.044662328936107311f, - -0.999002140325035980f, - 0.044470771854938744f, -0.999010685854073380f, 0.044279213138707016f, - -0.999019194652343460f, - 0.044087652794454979f, -0.999027666719533690f, 0.043896090829226200f, - -0.999036102055332330f, - 0.043704527250063421f, -0.999044500659429290f, 0.043512962064010327f, - -0.999052862531515930f, - 0.043321395278109784f, -0.999061187671284600f, 0.043129826899405595f, - -0.999069476078429330f, - 0.042938256934940959f, -0.999077727752645360f, 0.042746685391759139f, - -0.999085942693629270f, - 0.042555112276904117f, -0.999094120901079070f, 0.042363537597419038f, - -0.999102262374694130f, - 0.042171961360348002f, -0.999110367114174890f, 0.041980383572734502f, - -0.999118435119223490f, - 0.041788804241622082f, -0.999126466389543390f, 0.041597223374055005f, - -0.999134460924839150f, - 0.041405640977076712f, -0.999142418724816910f, 0.041214057057731589f, - -0.999150339789184110f, - 0.041022471623063397f, -0.999158224117649430f, 0.040830884680115968f, - -0.999166071709923000f, - 0.040639296235933854f, -0.999173882565716380f, 0.040447706297560768f, - -0.999181656684742350f, - 0.040256114872041358f, -0.999189394066714920f, 0.040064521966419686f, - -0.999197094711349880f, - 0.039872927587739845f, -0.999204758618363890f, 0.039681331743046659f, - -0.999212385787475290f, - 0.039489734439384118f, -0.999219976218403530f, 0.039298135683797149f, - -0.999227529910869610f, - 0.039106535483329839f, -0.999235046864595850f, 0.038914933845027241f, - -0.999242527079305830f, - 0.038723330775933762f, -0.999249970554724420f, 0.038531726283093877f, - -0.999257377290578060f, - 0.038340120373552791f, -0.999264747286594420f, 0.038148513054354856f, - -0.999272080542502610f, - 0.037956904332545366f, -0.999279377058032710f, 0.037765294215169005f, - -0.999286636832916740f, - 0.037573682709270514f, -0.999293859866887790f, 0.037382069821895340f, - -0.999301046159680070f, - 0.037190455560088091f, -0.999308195711029470f, 0.036998839930894332f, - -0.999315308520673070f, - 0.036807222941358991f, -0.999322384588349540f, 0.036615604598527057f, - -0.999329423913798420f, - 0.036423984909444228f, -0.999336426496761240f, 0.036232363881155374f, - -0.999343392336980220f, - 0.036040741520706299f, -0.999350321434199440f, 0.035849117835142184f, - -0.999357213788164000f, - 0.035657492831508264f, -0.999364069398620550f, 0.035465866516850478f, - -0.999370888265317060f, - 0.035274238898213947f, -0.999377670388002850f, 0.035082609982644702f, - -0.999384415766428560f, - 0.034890979777187955f, -0.999391124400346050f, 0.034699348288889847f, - -0.999397796289508640f, - 0.034507715524795889f, -0.999404431433671300f, 0.034316081491951658f, - -0.999411029832589780f, - 0.034124446197403423f, -0.999417591486021720f, 0.033932809648196623f, - -0.999424116393725640f, - 0.033741171851377642f, -0.999430604555461730f, 0.033549532813992221f, - -0.999437055970991530f, - 0.033357892543086159f, -0.999443470640077770f, 0.033166251045705968f, - -0.999449848562484530f, - 0.032974608328897315f, -0.999456189737977340f, 0.032782964399706793f, - -0.999462494166323160f, - 0.032591319265180385f, -0.999468761847290050f, 0.032399672932364114f, - -0.999474992780647780f, - 0.032208025408304704f, -0.999481186966166950f, 0.032016376700048046f, - -0.999487344403620080f, - 0.031824726814640963f, -0.999493465092780590f, 0.031633075759129645f, - -0.999499549033423640f, - 0.031441423540560343f, -0.999505596225325310f, 0.031249770165979990f, - -0.999511606668263440f, - 0.031058115642434700f, -0.999517580362016990f, 0.030866459976971503f, - -0.999523517306366350f, - 0.030674803176636581f, -0.999529417501093140f, 0.030483145248477058f, - -0.999535280945980540f, - 0.030291486199539423f, -0.999541107640812940f, 0.030099826036870208f, - -0.999546897585375960f, - 0.029908164767516655f, -0.999552650779456990f, 0.029716502398525156f, - -0.999558367222844300f, - 0.029524838936943035f, -0.999564046915327740f, 0.029333174389816984f, - -0.999569689856698580f, - 0.029141508764193740f, -0.999575296046749220f, 0.028949842067120746f, - -0.999580865485273700f, - 0.028758174305644590f, -0.999586398172067070f, 0.028566505486812797f, - -0.999591894106925950f, - 0.028374835617672258f, -0.999597353289648380f, 0.028183164705269902f, - -0.999602775720033530f, - 0.027991492756653365f, -0.999608161397882110f, 0.027799819778869434f, - -0.999613510322995950f, - 0.027608145778965820f, -0.999618822495178640f, 0.027416470763989606f, - -0.999624097914234570f, - 0.027224794740987910f, -0.999629336579970110f, 0.027033117717008563f, - -0.999634538492192300f, - 0.026841439699098527f, -0.999639703650710200f, 0.026649760694305708f, - -0.999644832055333610f, - 0.026458080709677145f, -0.999649923705874240f, 0.026266399752260809f, - -0.999654978602144690f, - 0.026074717829104040f, -0.999659996743959220f, 0.025883034947254208f, - -0.999664978131133310f, - 0.025691351113759395f, -0.999669922763483760f, 0.025499666335666818f, - -0.999674830640828740f, - 0.025307980620024630f, -0.999679701762987930f, 0.025116293973880335f, - -0.999684536129782140f, - 0.024924606404281485f, -0.999689333741033640f, 0.024732917918276334f, - -0.999694094596566000f, - 0.024541228522912264f, -0.999698818696204250f, 0.024349538225237600f, - -0.999703506039774650f, - 0.024157847032300020f, -0.999708156627104880f, 0.023966154951147241f, - -0.999712770458023870f, - 0.023774461988827676f, -0.999717347532362190f, 0.023582768152388880f, - -0.999721887849951310f, - 0.023391073448879338f, -0.999726391410624470f, 0.023199377885346890f, - -0.999730858214216030f, - 0.023007681468839410f, -0.999735288260561680f, 0.022815984206405477f, - -0.999739681549498660f, - 0.022624286105092803f, -0.999744038080865430f, 0.022432587171950024f, - -0.999748357854501780f, - 0.022240887414024919f, -0.999752640870248840f, 0.022049186838366180f, - -0.999756887127949080f, - 0.021857485452021874f, -0.999761096627446610f, 0.021665783262040089f, - -0.999765269368586450f, - 0.021474080275469605f, -0.999769405351215280f, 0.021282376499358355f, - -0.999773504575180990f, - 0.021090671940755180f, -0.999777567040332940f, 0.020898966606708289f, - -0.999781592746521670f, - 0.020707260504265912f, -0.999785581693599210f, 0.020515553640476986f, - -0.999789533881418780f, - 0.020323846022389572f, -0.999793449309835270f, 0.020132137657052664f, - -0.999797327978704690f, - 0.019940428551514598f, -0.999801169887884260f, 0.019748718712823757f, - -0.999804975037232870f, - 0.019557008148029204f, -0.999808743426610520f, 0.019365296864179146f, - -0.999812475055878780f, - 0.019173584868322699f, -0.999816169924900410f, 0.018981872167508348f, - -0.999819828033539420f, - 0.018790158768784596f, -0.999823449381661570f, 0.018598444679200642f, - -0.999827033969133420f, - 0.018406729905804820f, -0.999830581795823400f, 0.018215014455646376f, - -0.999834092861600960f, - 0.018023298335773701f, -0.999837567166337090f, 0.017831581553236088f, - -0.999841004709904000f, - 0.017639864115082195f, -0.999844405492175240f, 0.017448146028360704f, - -0.999847769513025900f, - 0.017256427300120978f, -0.999851096772332190f, 0.017064707937411529f, - -0.999854387269971890f, - 0.016872987947281773f, -0.999857641005823860f, 0.016681267336780482f, - -0.999860857979768540f, - 0.016489546112956454f, -0.999864038191687680f, 0.016297824282859176f, - -0.999867181641464380f, - 0.016106101853537263f, -0.999870288328982950f, 0.015914378832040249f, - -0.999873358254129260f, - 0.015722655225417017f, -0.999876391416790410f, 0.015530931040716478f, - -0.999879387816854930f, - 0.015339206284988220f, -0.999882347454212560f, 0.015147480965280975f, - -0.999885270328754520f, - 0.014955755088644378f, -0.999888156440373320f, 0.014764028662127416f, - -0.999891005788962950f, - 0.014572301692779104f, -0.999893818374418490f, 0.014380574187649138f, - -0.999896594196636680f, - 0.014188846153786343f, -0.999899333255515390f, 0.013997117598240459f, - -0.999902035550953920f, - 0.013805388528060349f, -0.999904701082852900f, 0.013613658950295789f, - -0.999907329851114300f, - 0.013421928871995907f, -0.999909921855641540f, 0.013230198300209845f, - -0.999912477096339240f, - 0.013038467241987433f, -0.999914995573113470f, 0.012846735704377631f, - -0.999917477285871770f, - 0.012655003694430301f, -0.999919922234522750f, 0.012463271219194662f, - -0.999922330418976490f, - 0.012271538285719944f, -0.999924701839144500f, 0.012079804901056066f, - -0.999927036494939640f, - 0.011888071072252072f, -0.999929334386276070f, 0.011696336806357907f, - -0.999931595513069200f, - 0.011504602110422875f, -0.999933819875236000f, 0.011312866991496287f, - -0.999936007472694620f, - 0.011121131456628141f, -0.999938158305364590f, 0.010929395512867561f, - -0.999940272373166960f, - 0.010737659167264572f, -0.999942349676023910f, 0.010545922426868548f, - -0.999944390213859060f, - 0.010354185298728884f, -0.999946393986597460f, 0.010162447789895645f, - -0.999948360994165400f, - 0.009970709907418029f, -0.999950291236490480f, 0.009778971658346134f, - -0.999952184713501780f, - 0.009587233049729183f, -0.999954041425129780f, 0.009395494088617302f, - -0.999955861371306100f, - 0.009203754782059960f, -0.999957644551963900f, 0.009012015137106642f, - -0.999959390967037450f, - 0.008820275160807512f, -0.999961100616462820f, 0.008628534860211857f, - -0.999962773500176930f, - 0.008436794242369860f, -0.999964409618118280f, 0.008245053314331058f, - -0.999966008970226920f, - 0.008053312083144991f, -0.999967571556443780f, 0.007861570555861883f, - -0.999969097376711580f, - 0.007669828739531077f, -0.999970586430974140f, 0.007478086641202815f, - -0.999972038719176730f, - 0.007286344267926684f, -0.999973454241265940f, 0.007094601626752279f, - -0.999974832997189810f, - 0.006902858724729877f, -0.999976174986897610f, 0.006711115568908869f, - -0.999977480210339940f, - 0.006519372166339549f, -0.999978748667468830f, 0.006327628524071549f, - -0.999979980358237650f, - 0.006135884649154515f, -0.999981175282601110f, 0.005944140548638765f, - -0.999982333440515350f, - 0.005752396229573737f, -0.999983454831937730f, 0.005560651699009764f, - -0.999984539456826970f, - 0.005368906963996303f, -0.999985587315143200f, 0.005177162031583702f, - -0.999986598406848000f, - 0.004985416908821652f, -0.999987572731904080f, 0.004793671602759852f, - -0.999988510290275690f, - 0.004601926120448672f, -0.999989411081928400f, 0.004410180468937601f, - -0.999990275106828920f, - 0.004218434655277024f, -0.999991102364945590f, 0.004026688686516664f, - -0.999991892856248010f, - 0.003834942569706248f, -0.999992646580707190f, 0.003643196311896179f, - -0.999993363538295150f, - 0.003451449920135975f, -0.999994043728985820f, 0.003259703401476044f, - -0.999994687152754080f, - 0.003067956762966138f, -0.999995293809576190f, 0.002876210011656010f, - -0.999995863699429940f, - 0.002684463154596083f, -0.999996396822294350f, 0.002492716198835898f, - -0.999996893178149880f, - 0.002300969151425887f, -0.999997352766978210f, 0.002109222019415816f, - -0.999997775588762350f, - 0.001917474809855460f, -0.999998161643486980f, 0.001725727529795258f, - -0.999998510931137790f, - 0.001533980186284766f, -0.999998823451701880f, 0.001342232786374430f, - -0.999999099205167830f, - 0.001150485337113809f, -0.999999338191525530f, 0.000958737845553352f, - -0.999999540410766110f, - 0.000766990318742846f, -0.999999705862882230f, 0.000575242763732077f, - -0.999999834547867670f, - 0.000383495187571497f, -0.999999926465717890f, 0.000191747597310674f, - -0.999999981616429330f -}; + 1.000000000000000000f, -0.000000000000000000f, 0.999999981616429330f, + -0.000191747597310703f, 0.999999926465717890f, -0.000383495187571396f, + 0.999999834547867670f, -0.000575242763732066f, 0.999999705862882230f, + -0.000766990318742704f, 0.999999540410766110f, -0.000958737845553301f, + 0.999999338191525530f, -0.001150485337113849f, 0.999999099205167830f, + -0.001342232786374338f, 0.999998823451701880f, -0.001533980186284766f, + 0.999998510931137790f, -0.001725727529795126f, 0.999998161643486980f, + -0.001917474809855419f, 0.999997775588762350f, -0.002109222019415644f, + 0.999997352766978210f, -0.002300969151425805f, 0.999996893178149880f, + -0.002492716198835908f, 0.999996396822294350f, -0.002684463154595962f, + 0.999995863699429940f, -0.002876210011655979f, 0.999995293809576190f, + -0.003067956762965976f, 0.999994687152754080f, -0.003259703401475973f, + 0.999994043728985820f, -0.003451449920135994f, 0.999993363538295150f, + -0.003643196311896068f, 0.999992646580707190f, -0.003834942569706228f, + 0.999991892856248010f, -0.004026688686516512f, 0.999991102364945590f, + -0.004218434655276963f, 0.999990275106828920f, -0.004410180468937631f, + 0.999989411081928400f, -0.004601926120448571f, 0.999988510290275690f, + -0.004793671602759841f, 0.999987572731904080f, -0.004985416908821511f, + 0.999986598406848000f, -0.005177162031583651f, 0.999985587315143200f, + -0.005368906963996343f, 0.999984539456826970f, -0.005560651699009674f, + 0.999983454831937730f, -0.005752396229573736f, 0.999982333440515350f, + -0.005944140548638633f, 0.999981175282601110f, -0.006135884649154475f, + 0.999979980358237650f, -0.006327628524071378f, 0.999978748667468830f, + -0.006519372166339468f, 0.999977480210339940f, -0.006711115568908879f, + 0.999976174986897610f, -0.006902858724729756f, 0.999974832997189810f, + -0.007094601626752250f, 0.999973454241265940f, -0.007286344267926521f, + 0.999972038719176730f, -0.007478086641202744f, 0.999970586430974140f, + -0.007669828739531097f, 0.999969097376711580f, -0.007861570555861772f, + 0.999967571556443780f, -0.008053312083144972f, 0.999966008970226920f, + -0.008245053314330906f, 0.999964409618118280f, -0.008436794242369799f, + 0.999962773500176930f, -0.008628534860211886f, 0.999961100616462820f, + -0.008820275160807412f, 0.999959390967037450f, -0.009012015137106633f, + 0.999957644551963900f, -0.009203754782059819f, 0.999955861371306100f, + -0.009395494088617252f, 0.999954041425129780f, -0.009587233049729225f, + 0.999952184713501780f, -0.009778971658346044f, 0.999950291236490480f, + -0.009970709907418031f, 0.999948360994165400f, -0.010162447789895513f, + 0.999946393986597460f, -0.010354185298728842f, 0.999944390213859060f, + -0.010545922426868378f, 0.999942349676023910f, -0.010737659167264491f, + 0.999940272373166960f, -0.010929395512867571f, 0.999938158305364590f, + -0.011121131456628021f, 0.999936007472694620f, -0.011312866991496258f, + 0.999933819875236000f, -0.011504602110422714f, 0.999931595513069200f, + -0.011696336806357838f, 0.999929334386276070f, -0.011888071072252092f, + 0.999927036494939640f, -0.012079804901055957f, 0.999924701839144500f, + -0.012271538285719925f, 0.999922330418976490f, -0.012463271219194511f, + 0.999919922234522750f, -0.012655003694430242f, 0.999917477285871770f, + -0.012846735704377662f, 0.999914995573113470f, -0.013038467241987334f, + 0.999912477096339240f, -0.013230198300209835f, 0.999909921855641540f, + -0.013421928871995765f, 0.999907329851114300f, -0.013613658950295740f, + 0.999904701082852900f, -0.013805388528060391f, 0.999902035550953920f, + -0.013997117598240367f, 0.999899333255515390f, -0.014188846153786345f, + 0.999896594196636680f, -0.014380574187649006f, 0.999893818374418490f, + -0.014572301692779064f, 0.999891005788962950f, -0.014764028662127246f, + 0.999888156440373320f, -0.014955755088644296f, 0.999885270328754520f, + -0.015147480965280987f, 0.999882347454212560f, -0.015339206284988100f, + 0.999879387816854930f, -0.015530931040716447f, 0.999876391416790410f, + -0.015722655225416857f, 0.999873358254129260f, -0.015914378832040183f, + 0.999870288328982950f, -0.016106101853537287f, 0.999867181641464380f, + -0.016297824282859065f, 0.999864038191687680f, -0.016489546112956437f, + 0.999860857979768540f, -0.016681267336780332f, 0.999857641005823860f, + -0.016872987947281710f, 0.999854387269971890f, -0.017064707937411563f, + 0.999851096772332190f, -0.017256427300120877f, 0.999847769513025900f, + -0.017448146028360693f, 0.999844405492175240f, -0.017639864115082053f, + 0.999841004709904000f, -0.017831581553236039f, 0.999837567166337090f, + -0.018023298335773746f, 0.999834092861600960f, -0.018215014455646290f, + 0.999830581795823400f, -0.018406729905804820f, 0.999827033969133420f, + -0.018598444679200511f, 0.999823449381661570f, -0.018790158768784555f, + 0.999819828033539420f, -0.018981872167508178f, 0.999816169924900410f, + -0.019173584868322623f, 0.999812475055878780f, -0.019365296864179156f, + 0.999808743426610520f, -0.019557008148029083f, 0.999804975037232870f, + -0.019748718712823729f, 0.999801169887884260f, -0.019940428551514441f, + 0.999797327978704690f, -0.020132137657052594f, 0.999793449309835270f, + -0.020323846022389593f, 0.999789533881418780f, -0.020515553640476875f, + 0.999785581693599210f, -0.020707260504265895f, 0.999781592746521670f, + -0.020898966606708137f, 0.999777567040332940f, -0.021090671940755121f, + 0.999773504575180990f, -0.021282376499358387f, 0.999769405351215280f, + -0.021474080275469508f, 0.999765269368586450f, -0.021665783262040078f, + 0.999761096627446610f, -0.021857485452021735f, 0.999756887127949080f, + -0.022049186838366135f, 0.999752640870248840f, -0.022240887414024961f, + 0.999748357854501780f, -0.022432587171949934f, 0.999744038080865430f, + -0.022624286105092803f, 0.999739681549498660f, -0.022815984206405345f, + 0.999735288260561680f, -0.023007681468839369f, 0.999730858214216030f, + -0.023199377885346720f, 0.999726391410624470f, -0.023391073448879258f, + 0.999721887849951310f, -0.023582768152388894f, 0.999717347532362190f, + -0.023774461988827555f, 0.999712770458023870f, -0.023966154951147210f, + 0.999708156627104880f, -0.024157847032299864f, 0.999703506039774650f, + -0.024349538225237534f, 0.999698818696204250f, -0.024541228522912288f, + 0.999694094596566000f, -0.024732917918276223f, 0.999689333741033640f, + -0.024924606404281468f, 0.999684536129782140f, -0.025116293973880186f, + 0.999679701762987930f, -0.025307980620024571f, 0.999674830640828740f, + -0.025499666335666853f, 0.999669922763483760f, -0.025691351113759295f, + 0.999664978131133310f, -0.025883034947254198f, 0.999659996743959220f, + -0.026074717829103901f, 0.999654978602144690f, -0.026266399752260760f, + 0.999649923705874240f, -0.026458080709677187f, 0.999644832055333610f, + -0.026649760694305618f, 0.999639703650710200f, -0.026841439699098531f, + 0.999634538492192300f, -0.027033117717008431f, 0.999629336579970110f, + -0.027224794740987875f, 0.999624097914234570f, -0.027416470763989436f, + 0.999618822495178640f, -0.027608145778965740f, 0.999613510322995950f, + -0.027799819778869445f, 0.999608161397882110f, -0.027991492756653243f, + 0.999602775720033530f, -0.028183164705269874f, 0.999597353289648380f, + -0.028374835617672099f, 0.999591894106925950f, -0.028566505486812728f, + 0.999586398172067070f, -0.028758174305644615f, 0.999580865485273700f, + -0.028949842067120635f, 0.999575296046749220f, -0.029141508764193722f, + 0.999569689856698580f, -0.029333174389816835f, 0.999564046915327740f, + -0.029524838936942976f, 0.999558367222844300f, -0.029716502398525191f, + 0.999552650779456990f, -0.029908164767516555f, 0.999546897585375960f, + -0.030099826036870198f, 0.999541107640812940f, -0.030291486199539284f, + 0.999535280945980540f, -0.030483145248477009f, 0.999529417501093140f, + -0.030674803176636626f, 0.999523517306366350f, -0.030866459976971412f, + 0.999517580362016990f, -0.031058115642434700f, 0.999511606668263440f, + -0.031249770165979861f, 0.999505596225325310f, -0.031441423540560301f, + 0.999499549033423640f, -0.031633075759129478f, 0.999493465092780590f, + -0.031824726814640887f, 0.999487344403620080f, -0.032016376700048060f, + 0.999481186966166950f, -0.032208025408304586f, 0.999474992780647780f, + -0.032399672932364086f, 0.999468761847290050f, -0.032591319265180226f, + 0.999462494166323160f, -0.032782964399706724f, 0.999456189737977340f, + -0.032974608328897335f, 0.999449848562484530f, -0.033166251045705857f, + 0.999443470640077770f, -0.033357892543086139f, 0.999437055970991530f, + -0.033549532813992068f, 0.999430604555461730f, -0.033741171851377580f, + 0.999424116393725640f, -0.033932809648196664f, 0.999417591486021720f, + -0.034124446197403326f, 0.999411029832589780f, -0.034316081491951651f, + 0.999404431433671300f, -0.034507715524795750f, 0.999397796289508640f, + -0.034699348288889799f, 0.999391124400346050f, -0.034890979777188004f, + 0.999384415766428560f, -0.035082609982644619f, 0.999377670388002850f, + -0.035274238898213947f, 0.999370888265317170f, -0.035465866516850353f, + 0.999364069398620550f, -0.035657492831508222f, 0.999357213788164000f, + -0.035849117835142018f, 0.999350321434199440f, -0.036040741520706229f, + 0.999343392336980220f, -0.036232363881155395f, 0.999336426496761240f, + -0.036423984909444110f, 0.999329423913798420f, -0.036615604598527030f, + 0.999322384588349540f, -0.036807222941358832f, 0.999315308520673070f, + -0.036998839930894263f, 0.999308195711029470f, -0.037190455560088119f, + 0.999301046159680070f, -0.037382069821895229f, 0.999293859866887790f, + -0.037573682709270494f, 0.999286636832916740f, -0.037765294215168860f, + 0.999279377058032710f, -0.037956904332545310f, 0.999272080542502610f, + -0.038148513054354891f, 0.999264747286594420f, -0.038340120373552694f, + 0.999257377290578060f, -0.038531726283093870f, 0.999249970554724420f, + -0.038723330775933623f, 0.999242527079305830f, -0.038914933845027193f, + 0.999235046864595850f, -0.039106535483329888f, 0.999227529910869610f, + -0.039298135683797059f, 0.999219976218403530f, -0.039489734439384118f, + 0.999212385787475290f, -0.039681331743046527f, 0.999204758618363890f, + -0.039872927587739811f, 0.999197094711349880f, -0.040064521966419520f, + 0.999189394066714920f, -0.040256114872041282f, 0.999181656684742350f, + -0.040447706297560782f, 0.999173882565716380f, -0.040639296235933736f, + 0.999166071709923000f, -0.040830884680115948f, 0.999158224117649430f, + -0.041022471623063238f, 0.999150339789184110f, -0.041214057057731519f, + 0.999142418724816910f, -0.041405640977076739f, 0.999134460924839150f, + -0.041597223374054894f, 0.999126466389543390f, -0.041788804241622061f, + 0.999118435119223490f, -0.041980383572734356f, 0.999110367114174890f, + -0.042171961360347947f, 0.999102262374694130f, -0.042363537597419072f, + 0.999094120901079070f, -0.042555112276904020f, 0.999085942693629270f, + -0.042746685391759132f, 0.999077727752645360f, -0.042938256934940820f, + 0.999069476078429330f, -0.043129826899405546f, 0.999061187671284600f, + -0.043321395278109825f, 0.999052862531515930f, -0.043512962064010237f, + 0.999044500659429290f, -0.043704527250063421f, 0.999036102055332330f, + -0.043896090829226068f, 0.999027666719533690f, -0.044087652794454944f, + 0.999019194652343460f, -0.044279213138706849f, 0.999010685854073380f, + -0.044470771854938668f, 0.999002140325035980f, -0.044662328936107325f, + 0.998993558065545680f, -0.044853884375169815f, 0.998984939075918010f, + -0.045045438165083197f, 0.998976283356469820f, -0.045236990298804590f, + 0.998967590907519300f, -0.045428540769291155f, 0.998958861729386080f, + -0.045620089569500144f, 0.998950095822391250f, -0.045811636692388844f, + 0.998941293186856870f, -0.046003182130914623f, 0.998932453823106690f, + -0.046194725878034908f, 0.998923577731465780f, -0.046386267926707157f, + 0.998914664912260440f, -0.046577808269888943f, 0.998905715365818290f, + -0.046769346900537863f, 0.998896729092468410f, -0.046960883811611592f, + 0.998887706092541290f, -0.047152418996067869f, 0.998878646366368690f, + -0.047343952446864478f, 0.998869549914283560f, -0.047535484156959303f, + 0.998860416736620520f, -0.047727014119310254f, 0.998851246833715180f, + -0.047918542326875327f, 0.998842040205904840f, -0.048110068772612591f, + 0.998832796853527990f, -0.048301593449480144f, 0.998823516776924490f, + -0.048493116350436176f, 0.998814199976435390f, -0.048684637468438943f, + 0.998804846452403420f, -0.048876156796446760f, 0.998795456205172410f, + -0.049067674327418015f, 0.998786029235087640f, -0.049259190054311140f, + 0.998776565542495610f, -0.049450703970084664f, 0.998767065127744380f, + -0.049642216067697156f, 0.998757527991183340f, -0.049833726340107277f, + 0.998747954133162860f, -0.050025234780273729f, 0.998738343554035230f, + -0.050216741381155311f, 0.998728696254153720f, -0.050408246135710856f, + 0.998719012233872940f, -0.050599749036899282f, 0.998709291493549030f, + -0.050791250077679581f, 0.998699534033539280f, -0.050982749251010803f, + 0.998689739854202620f, -0.051174246549852080f, 0.998679908955899090f, + -0.051365741967162593f, 0.998670041338990070f, -0.051557235495901611f, + 0.998660137003838490f, -0.051748727129028456f, 0.998650195950808280f, + -0.051940216859502536f, 0.998640218180265270f, -0.052131704680283324f, + 0.998630203692576050f, -0.052323190584330347f, 0.998620152488108870f, + -0.052514674564603223f, 0.998610064567233340f, -0.052706156614061632f, + 0.998599939930320370f, -0.052897636725665324f, 0.998589778577742230f, + -0.053089114892374133f, 0.998579580509872500f, -0.053280591107147945f, + 0.998569345727086110f, -0.053472065362946727f, 0.998559074229759310f, + -0.053663537652730520f, 0.998548766018269920f, -0.053855007969459440f, + 0.998538421092996730f, -0.054046476306093660f, 0.998528039454320230f, + -0.054237942655593452f, 0.998517621102622210f, -0.054429407010919133f, + 0.998507166038285490f, -0.054620869365031105f, 0.998496674261694640f, + -0.054812329710889854f, 0.998486145773235360f, -0.055003788041455920f, + 0.998475580573294770f, -0.055195244349689934f, 0.998464978662261250f, + -0.055386698628552597f, 0.998454340040524800f, -0.055578150871004678f, + 0.998443664708476340f, -0.055769601070007030f, 0.998432952666508440f, + -0.055961049218520569f, 0.998422203915015020f, -0.056152495309506292f, + 0.998411418454391300f, -0.056343939335925290f, 0.998400596285033640f, + -0.056535381290738700f, 0.998389737407340160f, -0.056726821166907748f, + 0.998378841821709990f, -0.056918258957393740f, 0.998367909528543820f, + -0.057109694655158062f, 0.998356940528243420f, -0.057301128253162158f, + 0.998345934821212370f, -0.057492559744367566f, 0.998334892407855000f, + -0.057683989121735904f, 0.998323813288577560f, -0.057875416378228857f, + 0.998312697463787260f, -0.058066841506808194f, 0.998301544933892890f, + -0.058258264500435752f, 0.998290355699304350f, -0.058449685352073476f, + 0.998279129760433200f, -0.058641104054683341f, 0.998267867117692110f, + -0.058832520601227435f, 0.998256567771495180f, -0.059023934984667931f, + 0.998245231722257880f, -0.059215347197967061f, 0.998233858970396850f, + -0.059406757234087150f, 0.998222449516330550f, -0.059598165085990591f, + 0.998211003360478190f, -0.059789570746639868f, 0.998199520503260660f, + -0.059980974208997548f, 0.998188000945100300f, -0.060172375466026259f, + 0.998176444686420530f, -0.060363774510688743f, 0.998164851727646240f, + -0.060555171335947788f, 0.998153222069203760f, -0.060746565934766288f, + 0.998141555711520520f, -0.060937958300107203f, 0.998129852655025630f, + -0.061129348424933588f, 0.998118112900149180f, -0.061320736302208578f, + 0.998106336447323050f, -0.061512121924895378f, 0.998094523296980010f, + -0.061703505285957298f, 0.998082673449554590f, -0.061894886378357716f, + 0.998070786905482340f, -0.062086265195060088f, 0.998058863665200250f, + -0.062277641729027972f, 0.998046903729146840f, -0.062469015973224996f, + 0.998034907097761770f, -0.062660387920614874f, 0.998022873771486240f, + -0.062851757564161406f, 0.998010803750762450f, -0.063043124896828492f, + 0.997998697036034390f, -0.063234489911580066f, 0.997986553627747020f, + -0.063425852601380228f, 0.997974373526346990f, -0.063617212959193106f, + 0.997962156732281950f, -0.063808570977982898f, 0.997949903246001190f, + -0.063999926650713940f, 0.997937613067955250f, -0.064191279970350637f, + 0.997925286198596000f, -0.064382630929857465f, 0.997912922638376610f, + -0.064573979522198982f, 0.997900522387751620f, -0.064765325740339885f, + 0.997888085447177110f, -0.064956669577244872f, 0.997875611817110150f, + -0.065148011025878833f, 0.997863101498009500f, -0.065339350079206632f, + 0.997850554490335110f, -0.065530686730193327f, 0.997837970794548280f, + -0.065722020971803990f, 0.997825350411111640f, -0.065913352797003805f, + 0.997812693340489280f, -0.066104682198758077f, 0.997799999583146470f, + -0.066296009170032130f, 0.997787269139549960f, -0.066487333703791451f, + 0.997774502010167820f, -0.066678655793001557f, 0.997761698195469560f, + -0.066869975430628115f, 0.997748857695925690f, -0.067061292609636822f, + 0.997735980512008620f, -0.067252607322993499f, 0.997723066644191640f, + -0.067443919563664051f, 0.997710116092949570f, -0.067635229324614479f, + 0.997697128858758500f, -0.067826536598810869f, 0.997684104942096030f, + -0.068017841379219388f, 0.997671044343441000f, -0.068209143658806329f, + 0.997657947063273710f, -0.068400443430538013f, 0.997644813102075420f, + -0.068591740687380942f, 0.997631642460329320f, -0.068783035422301630f, + 0.997618435138519550f, -0.068974327628266746f, 0.997605191137131640f, + -0.069165617298242985f, 0.997591910456652630f, -0.069356904425197208f, + 0.997578593097570800f, -0.069548189002096306f, 0.997565239060375750f, + -0.069739471021907307f, 0.997551848345558430f, -0.069930750477597309f, + 0.997538420953611340f, -0.070122027362133521f, 0.997524956885027960f, + -0.070313301668483250f, 0.997511456140303450f, -0.070504573389613856f, + 0.997497918719934210f, -0.070695842518492855f, 0.997484344624417930f, + -0.070887109048087801f, 0.997470733854253670f, -0.071078372971366405f, + 0.997457086409941910f, -0.071269634281296401f, 0.997443402291984360f, + -0.071460892970845680f, 0.997429681500884180f, -0.071652149032982212f, + 0.997415924037145960f, -0.071843402460674027f, 0.997402129901275300f, + -0.072034653246889332f, 0.997388299093779460f, -0.072225901384596322f, + 0.997374431615167150f, -0.072417146866763413f, 0.997360527465947940f, + -0.072608389686358993f, 0.997346586646633230f, -0.072799629836351673f, + 0.997332609157735470f, -0.072990867309710036f, 0.997318594999768600f, + -0.073182102099402888f, 0.997304544173247990f, -0.073373334198399032f, + 0.997290456678690210f, -0.073564563599667426f, 0.997276332516613180f, + -0.073755790296177098f, 0.997262171687536170f, -0.073947014280897200f, + 0.997247974191979860f, -0.074138235546796979f, 0.997233740030466280f, + -0.074329454086845756f, 0.997219469203518670f, -0.074520669894013000f, + 0.997205161711661850f, -0.074711882961268211f, 0.997190817555421940f, + -0.074903093281581082f, 0.997176436735326190f, -0.075094300847921305f, + 0.997162019251903290f, -0.075285505653258769f, 0.997147565105683480f, + -0.075476707690563388f, 0.997133074297198110f, -0.075667906952805231f, + 0.997118546826979980f, -0.075859103432954447f, 0.997103982695563330f, + -0.076050297123981259f, 0.997089381903483400f, -0.076241488018856066f, + 0.997074744451277310f, -0.076432676110549283f, 0.997060070339482960f, + -0.076623861392031492f, 0.997045359568640040f, -0.076815043856273343f, + 0.997030612139289450f, -0.077006223496245640f, 0.997015828051973310f, + -0.077197400304919200f, 0.997001007307235290f, -0.077388574275265049f, + 0.996986149905620180f, -0.077579745400254224f, 0.996971255847674320f, + -0.077770913672857947f, 0.996956325133945280f, -0.077962079086047492f, + 0.996941357764982160f, -0.078153241632794232f, 0.996926353741335090f, + -0.078344401306069705f, 0.996911313063555740f, -0.078535558098845479f, + 0.996896235732197210f, -0.078726712004093299f, 0.996881121747813850f, + -0.078917863014784942f, 0.996865971110961310f, -0.079109011123892375f, + 0.996850783822196610f, -0.079300156324387597f, 0.996835559882078170f, + -0.079491298609242769f, 0.996820299291165670f, -0.079682437971430126f, + 0.996805002050020430f, -0.079873574403921996f, 0.996789668159204560f, + -0.080064707899690890f, 0.996774297619282050f, -0.080255838451709319f, + 0.996758890430818000f, -0.080446966052950014f, 0.996743446594378860f, + -0.080638090696385709f, 0.996727966110532490f, -0.080829212374989329f, + 0.996712448979848010f, -0.081020331081733857f, 0.996696895202896060f, + -0.081211446809592441f, 0.996681304780248300f, -0.081402559551538245f, + 0.996665677712478160f, -0.081593669300544652f, 0.996650014000160070f, + -0.081784776049585076f, 0.996634313643869900f, -0.081975879791633066f, + 0.996618576644185070f, -0.082166980519662314f, 0.996602803001684130f, + -0.082358078226646536f, 0.996586992716946950f, -0.082549172905559673f, + 0.996571145790554840f, -0.082740264549375692f, 0.996555262223090540f, + -0.082931353151068699f, 0.996539342015137940f, -0.083122438703612911f, + 0.996523385167282450f, -0.083313521199982685f, 0.996507391680110820f, + -0.083504600633152432f, 0.996491361554210920f, -0.083695676996096716f, + 0.996475294790172160f, -0.083886750281790226f, 0.996459191388585410f, + -0.084077820483207694f, 0.996443051350042630f, -0.084268887593324071f, + 0.996426874675137240f, -0.084459951605114325f, 0.996410661364464100f, + -0.084651012511553617f, 0.996394411418619290f, -0.084842070305617134f, + 0.996378124838200210f, -0.085033124980280275f, 0.996361801623805720f, + -0.085224176528518478f, 0.996345441776035900f, -0.085415224943307333f, + 0.996329045295492380f, -0.085606270217622529f, 0.996312612182778000f, + -0.085797312344439894f, 0.996296142438496850f, -0.085988351316735337f, + 0.996279636063254650f, -0.086179387127484894f, 0.996263093057658140f, + -0.086370419769664752f, 0.996246513422315520f, -0.086561449236251170f, + 0.996229897157836500f, -0.086752475520220543f, 0.996213244264832040f, + -0.086943498614549378f, 0.996196554743914220f, -0.087134518512214307f, + 0.996179828595696980f, -0.087325535206192059f, 0.996163065820794950f, + -0.087516548689459531f, 0.996146266419824620f, -0.087707558954993659f, + 0.996129430393403740f, -0.087898565995771588f, 0.996112557742151130f, + -0.088089569804770507f, 0.996095648466687300f, -0.088280570374967740f, + 0.996078702567633980f, -0.088471567699340767f, 0.996061720045614000f, + -0.088662561770867149f, 0.996044700901251970f, -0.088853552582524600f, + 0.996027645135173610f, -0.089044540127290892f, 0.996010552748005870f, + -0.089235524398144014f, 0.995993423740377360f, -0.089426505388061961f, + 0.995976258112917790f, -0.089617483090022959f, 0.995959055866258320f, + -0.089808457497005278f, 0.995941817001031350f, -0.089999428601987341f, + 0.995924541517870800f, -0.090190396397947695f, 0.995907229417411720f, + -0.090381360877864983f, 0.995889880700290720f, -0.090572322034717989f, + 0.995872495367145730f, -0.090763279861485621f, 0.995855073418615790f, + -0.090954234351146926f, 0.995837614855341610f, -0.091145185496681005f, + 0.995820119677964910f, -0.091336133291067184f, 0.995802587887129160f, + -0.091527077727284828f, 0.995785019483478750f, -0.091718018798313455f, + 0.995767414467659820f, -0.091908956497132724f, 0.995749772840319510f, + -0.092099890816722388f, 0.995732094602106430f, -0.092290821750062355f, + 0.995714379753670610f, -0.092481749290132600f, 0.995696628295663520f, + -0.092672673429913310f, 0.995678840228737540f, -0.092863594162384724f, + 0.995661015553546910f, -0.093054511480527249f, 0.995643154270746900f, + -0.093245425377321375f, 0.995625256380994310f, -0.093436335845747787f, + 0.995607321884947050f, -0.093627242878787195f, 0.995589350783264600f, + -0.093818146469420549f, 0.995571343076607770f, -0.094009046610628838f, + 0.995553298765638470f, -0.094199943295393204f, 0.995535217851020390f, + -0.094390836516694943f, 0.995517100333418110f, -0.094581726267515445f, + 0.995498946213497770f, -0.094772612540836243f, 0.995480755491926940f, + -0.094963495329638992f, 0.995462528169374420f, -0.095154374626905486f, + 0.995444264246510340f, -0.095345250425617617f, 0.995425963724006160f, + -0.095536122718757471f, 0.995407626602534900f, -0.095726991499307162f, + 0.995389252882770690f, -0.095917856760249040f, 0.995370842565388990f, + -0.096108718494565509f, 0.995352395651066810f, -0.096299576695239128f, + 0.995333912140482280f, -0.096490431355252593f, 0.995315392034315070f, + -0.096681282467588725f, 0.995296835333246090f, -0.096872130025230471f, + 0.995278242037957670f, -0.097062974021160917f, 0.995259612149133390f, + -0.097253814448363271f, 0.995240945667458130f, -0.097444651299820870f, + 0.995222242593618360f, -0.097635484568517200f, 0.995203502928301510f, + -0.097826314247435861f, 0.995184726672196930f, -0.098017140329560604f, + 0.995165913825994620f, -0.098207962807875276f, 0.995147064390386470f, + -0.098398781675363881f, 0.995128178366065490f, -0.098589596925010584f, + 0.995109255753726110f, -0.098780408549799623f, 0.995090296554064000f, + -0.098971216542715429f, 0.995071300767776170f, -0.099162020896742503f, + 0.995052268395561050f, -0.099352821604865540f, 0.995033199438118630f, + -0.099543618660069319f, 0.995014093896149700f, -0.099734412055338825f, + 0.994994951770357020f, -0.099925201783659073f, 0.994975773061444140f, + -0.100115987838015310f, 0.994956557770116380f, -0.100306770211392860f, + 0.994937305897080070f, -0.100497548896777200f, 0.994918017443043200f, + -0.100688323887153960f, 0.994898692408714870f, -0.100879095175508860f, + 0.994879330794805620f, -0.101069862754827820f, 0.994859932602027320f, + -0.101260626618096830f, 0.994840497831093180f, -0.101451386758302080f, + 0.994821026482717860f, -0.101642143168429830f, 0.994801518557617110f, + -0.101832895841466530f, 0.994781974056508260f, -0.102023644770398740f, + 0.994762392980109930f, -0.102214389948213210f, 0.994742775329142010f, + -0.102405131367896720f, 0.994723121104325700f, -0.102595869022436280f, + 0.994703430306383860f, -0.102786602904819040f, 0.994683702936040250f, + -0.102977333008032220f, 0.994663938994020390f, -0.103168059325063230f, + 0.994644138481050710f, -0.103358781848899610f, 0.994624301397859400f, + -0.103549500572529070f, 0.994604427745175660f, -0.103740215488939370f, + 0.994584517523730340f, -0.103930926591118510f, 0.994564570734255420f, + -0.104121633872054590f, 0.994544587377484300f, -0.104312337324735800f, + 0.994524567454151740f, -0.104503036942150570f, 0.994504510964993700f, + -0.104693732717287390f, 0.994484417910747600f, -0.104884424643134970f, + 0.994464288292152390f, -0.105075112712682040f, 0.994444122109948040f, + -0.105265796918917600f, 0.994423919364875950f, -0.105456477254830710f, + 0.994403680057679100f, -0.105647153713410620f, 0.994383404189101430f, + -0.105837826287646670f, 0.994363091759888570f, -0.106028494970528410f, + 0.994342742770787270f, -0.106219159755045480f, 0.994322357222545810f, + -0.106409820634187680f, 0.994301935115913580f, -0.106600477600944960f, + 0.994281476451641550f, -0.106791130648307390f, 0.994260981230481790f, + -0.106981779769265230f, 0.994240449453187900f, -0.107172424956808840f, + 0.994219881120514960f, -0.107363066203928760f, 0.994199276233218910f, + -0.107553703503615620f, 0.994178634792057590f, -0.107744336848860280f, + 0.994157956797789730f, -0.107934966232653650f, 0.994137242251175720f, + -0.108125591647986870f, 0.994116491152977070f, -0.108316213087851170f, + 0.994095703503956930f, -0.108506830545237920f, 0.994074879304879370f, + -0.108697444013138720f, 0.994054018556510210f, -0.108888053484545190f, + 0.994033121259616400f, -0.109078658952449240f, 0.994012187414966220f, + -0.109269260409842780f, 0.993991217023329380f, -0.109459857849717980f, + 0.993970210085476920f, -0.109650451265067100f, 0.993949166602181130f, + -0.109841040648882600f, 0.993928086574215830f, -0.110031625994157000f, + 0.993906970002356060f, -0.110222207293883060f, 0.993885816887378090f, + -0.110412784541053630f, 0.993864627230059750f, -0.110603357728661730f, + 0.993843401031180180f, -0.110793926849700560f, 0.993822138291519660f, + -0.110984491897163390f, 0.993800839011860120f, -0.111175052864043720f, + 0.993779503192984580f, -0.111365609743335160f, 0.993758130835677430f, + -0.111556162528031480f, 0.993736721940724600f, -0.111746711211126590f, + 0.993715276508913230f, -0.111937255785614570f, 0.993693794541031790f, + -0.112127796244489640f, 0.993672276037870010f, -0.112318332580746170f, + 0.993650721000219120f, -0.112508864787378690f, 0.993629129428871720f, + -0.112699392857381860f, 0.993607501324621610f, -0.112889916783750520f, + 0.993585836688263950f, -0.113080436559479620f, 0.993564135520595300f, + -0.113270952177564350f, 0.993542397822413600f, -0.113461463630999950f, + 0.993520623594518090f, -0.113651970912781870f, 0.993498812837709360f, + -0.113842474015905710f, 0.993476965552789190f, -0.114032972933367200f, + 0.993455081740560960f, -0.114223467658162260f, 0.993433161401829360f, + -0.114413958183286920f, 0.993411204537400060f, -0.114604444501737420f, + 0.993389211148080650f, -0.114794926606510080f, 0.993367181234679600f, + -0.114985404490601460f, 0.993345114798006910f, -0.115175878147008190f, + 0.993323011838873950f, -0.115366347568727140f, 0.993300872358093280f, + -0.115556812748755260f, 0.993278696356479030f, -0.115747273680089720f, + 0.993256483834846440f, -0.115937730355727780f, 0.993234234794012290f, + -0.116128182768666930f, 0.993211949234794500f, -0.116318630911904750f, + 0.993189627158012620f, -0.116509074778439040f, 0.993167268564487230f, + -0.116699514361267690f, 0.993144873455040430f, -0.116889949653388780f, + 0.993122441830495580f, -0.117080380647800590f, 0.993099973691677570f, + -0.117270807337501460f, 0.993077469039412300f, -0.117461229715489990f, + 0.993054927874527320f, -0.117651647774764860f, 0.993032350197851410f, + -0.117842061508324980f, 0.993009736010214580f, -0.118032470909169340f, + 0.992987085312448390f, -0.118222875970297170f, 0.992964398105385610f, + -0.118413276684707790f, 0.992941674389860470f, -0.118603673045400720f, + 0.992918914166708300f, -0.118794065045375640f, 0.992896117436765980f, + -0.118984452677632340f, 0.992873284200871730f, -0.119174835935170880f, + 0.992850414459865100f, -0.119365214810991350f, 0.992827508214586760f, + -0.119555589298094110f, 0.992804565465879140f, -0.119745959389479600f, + 0.992781586214585570f, -0.119936325078148470f, 0.992758570461551140f, + -0.120126686357101500f, 0.992735518207621850f, -0.120317043219339680f, + 0.992712429453645460f, -0.120507395657864130f, 0.992689304200470750f, + -0.120697743665676110f, 0.992666142448948020f, -0.120888087235777080f, + 0.992642944199928820f, -0.121078426361168640f, 0.992619709454266140f, + -0.121268761034852600f, 0.992596438212814290f, -0.121459091249830840f, + 0.992573130476428810f, -0.121649416999105530f, 0.992549786245966680f, + -0.121839738275678890f, 0.992526405522286100f, -0.122030055072553360f, + 0.992502988306246950f, -0.122220367382731540f, 0.992479534598709970f, + -0.122410675199216200f, 0.992456044400537700f, -0.122600978515010240f, + 0.992432517712593660f, -0.122791277323116770f, 0.992408954535742850f, + -0.122981571616539050f, 0.992385354870851670f, -0.123171861388280480f, + 0.992361718718787870f, -0.123362146631344680f, 0.992338046080420420f, + -0.123552427338735370f, 0.992314336956619640f, -0.123742703503456510f, + 0.992290591348257370f, -0.123932975118512160f, 0.992266809256206580f, + -0.124123242176906600f, 0.992242990681341700f, -0.124313504671644230f, + 0.992219135624538450f, -0.124503762595729660f, 0.992195244086673920f, + -0.124694015942167640f, 0.992171316068626520f, -0.124884264703963130f, + 0.992147351571276090f, -0.125074508874121170f, 0.992123350595503720f, + -0.125264748445647060f, 0.992099313142191800f, -0.125454983411546230f, + 0.992075239212224070f, -0.125645213764824290f, 0.992051128806485720f, + -0.125835439498487000f, 0.992026981925863360f, -0.126025660605540320f, + 0.992002798571244520f, -0.126215877078990350f, 0.991978578743518580f, + -0.126406088911843380f, 0.991954322443575950f, -0.126596296097105850f, + 0.991930029672308480f, -0.126786498627784410f, 0.991905700430609330f, + -0.126976696496885870f, 0.991881334719373010f, -0.127166889697417160f, + 0.991856932539495470f, -0.127357078222385400f, 0.991832493891873780f, + -0.127547262064797970f, 0.991808018777406430f, -0.127737441217662310f, + 0.991783507196993490f, -0.127927615673986080f, 0.991758959151536110f, + -0.128117785426777130f, 0.991734374641936810f, -0.128307950469043420f, + 0.991709753669099530f, -0.128498110793793170f, 0.991685096233929420f, + -0.128688266394034690f, 0.991660402337333210f, -0.128878417262776550f, + 0.991635671980218740f, -0.129068563393027410f, 0.991610905163495370f, + -0.129258704777796140f, 0.991586101888073500f, -0.129448841410091780f, + 0.991561262154865290f, -0.129638973282923560f, 0.991536385964783880f, + -0.129829100389300930f, 0.991511473318743900f, -0.130019222722233350f, + 0.991486524217661480f, -0.130209340274730630f, 0.991461538662453790f, + -0.130399453039802690f, 0.991436516654039420f, -0.130589561010459650f, + 0.991411458193338540f, -0.130779664179711710f, 0.991386363281272280f, + -0.130969762540569380f, 0.991361231918763460f, -0.131159856086043270f, + 0.991336064106736140f, -0.131349944809144190f, 0.991310859846115440f, + -0.131540028702883120f, 0.991285619137828200f, -0.131730107760271160f, + 0.991260341982802440f, -0.131920181974319790f, 0.991235028381967420f, + -0.132110251338040360f, 0.991209678336254060f, -0.132300315844444650f, + 0.991184291846594180f, -0.132490375486544550f, 0.991158868913921350f, + -0.132680430257352070f, 0.991133409539170170f, -0.132870480149879430f, + 0.991107913723276890f, -0.133060525157139060f, 0.991082381467178640f, + -0.133250565272143570f, 0.991056812771814340f, -0.133440600487905680f, + 0.991031207638124130f, -0.133630630797438340f, 0.991005566067049370f, + -0.133820656193754720f, 0.990979888059532740f, -0.134010676669868130f, + 0.990954173616518500f, -0.134200692218792020f, 0.990928422738951990f, + -0.134390702833540070f, 0.990902635427780010f, -0.134580708507126170f, + 0.990876811683950700f, -0.134770709232564350f, 0.990850951508413620f, + -0.134960705002868750f, 0.990825054902119470f, -0.135150695811053850f, + 0.990799121866020370f, -0.135340681650134210f, 0.990773152401069780f, + -0.135530662513124590f, 0.990747146508222710f, -0.135720638393039910f, + 0.990721104188435180f, -0.135910609282895330f, 0.990695025442664630f, + -0.136100575175706200f, 0.990668910271870100f, -0.136290536064487960f, + 0.990642758677011570f, -0.136480491942256280f, 0.990616570659050620f, + -0.136670442802027090f, 0.990590346218950150f, -0.136860388636816380f, + 0.990564085357674370f, -0.137050329439640410f, 0.990537788076188750f, + -0.137240265203515590f, 0.990511454375460290f, -0.137430195921458550f, + 0.990485084256457090f, -0.137620121586486040f, 0.990458677720148620f, + -0.137810042191615080f, 0.990432234767505970f, -0.137999957729862790f, + 0.990405755399501260f, -0.138189868194246560f, 0.990379239617108160f, + -0.138379773577783890f, 0.990352687421301450f, -0.138569673873492500f, + 0.990326098813057330f, -0.138759569074390350f, 0.990299473793353590f, + -0.138949459173495490f, 0.990272812363169110f, -0.139139344163826200f, + 0.990246114523483990f, -0.139329224038400980f, 0.990219380275280000f, + -0.139519098790238490f, 0.990192609619540030f, -0.139708968412357550f, + 0.990165802557248400f, -0.139898832897777210f, 0.990138959089390650f, + -0.140088692239516670f, 0.990112079216953770f, -0.140278546430595420f, + 0.990085162940925970f, -0.140468395464033000f, 0.990058210262297120f, + -0.140658239332849210f, 0.990031221182058000f, -0.140848078030064080f, + 0.990004195701200910f, -0.141037911548697710f, 0.989977133820719610f, + -0.141227739881770510f, 0.989950035541608990f, -0.141417563022303020f, + 0.989922900864865450f, -0.141607380963316020f, 0.989895729791486660f, + -0.141797193697830390f, 0.989868522322471580f, -0.141987001218867290f, + 0.989841278458820530f, -0.142176803519448030f, 0.989813998201535260f, + -0.142366600592594180f, 0.989786681551618640f, -0.142556392431327340f, + 0.989759328510075200f, -0.142746179028669460f, 0.989731939077910570f, + -0.142935960377642670f, 0.989704513256131850f, -0.143125736471269190f, + 0.989677051045747210f, -0.143315507302571500f, 0.989649552447766530f, + -0.143505272864572290f, 0.989622017463200890f, -0.143695033150294470f, + 0.989594446093062460f, -0.143884788152760980f, 0.989566838338365120f, + -0.144074537864995160f, 0.989539194200123930f, -0.144264282280020440f, + 0.989511513679355190f, -0.144454021390860470f, 0.989483796777076760f, + -0.144643755190539040f, 0.989456043494307710f, -0.144833483672080210f, + 0.989428253832068230f, -0.145023206828508220f, 0.989400427791380380f, + -0.145212924652847460f, 0.989372565373267010f, -0.145402637138122570f, + 0.989344666578752640f, -0.145592344277358340f, 0.989316731408863000f, + -0.145782046063579860f, 0.989288759864625170f, -0.145971742489812210f, + 0.989260751947067640f, -0.146161433549080900f, 0.989232707657220050f, + -0.146351119234411460f, 0.989204626996113780f, -0.146540799538829760f, + 0.989176509964781010f, -0.146730474455361750f, 0.989148356564255590f, + -0.146920143977033620f, 0.989120166795572690f, -0.147109808096871820f, + 0.989091940659768800f, -0.147299466807902850f, 0.989063678157881540f, + -0.147489120103153570f, 0.989035379290950310f, -0.147678767975650970f, + 0.989007044060015270f, -0.147868410418422220f, 0.988978672466118480f, + -0.148058047424494720f, 0.988950264510302990f, -0.148247678986896030f, + 0.988921820193613190f, -0.148437305098653970f, 0.988893339517095130f, + -0.148626925752796540f, 0.988864822481795640f, -0.148816540942351920f, + 0.988836269088763540f, -0.149006150660348450f, 0.988807679339048450f, + -0.149195754899814820f, 0.988779053233701520f, -0.149385353653779720f, + 0.988750390773775360f, -0.149574946915272230f, 0.988721691960323780f, + -0.149764534677321510f, 0.988692956794401940f, -0.149954116932956960f, + 0.988664185277066230f, -0.150143693675208190f, 0.988635377409374790f, + -0.150333264897105000f, 0.988606533192386450f, -0.150522830591677400f, + 0.988577652627162020f, -0.150712390751955610f, 0.988548735714763200f, + -0.150901945370970040f, 0.988519782456253270f, -0.151091494441751300f, + 0.988490792852696590f, -0.151281037957330220f, 0.988461766905159300f, + -0.151470575910737810f, 0.988432704614708340f, -0.151660108295005310f, + 0.988403605982412390f, -0.151849635103164180f, 0.988374471009341280f, + -0.152039156328246050f, 0.988345299696566150f, -0.152228671963282740f, + 0.988316092045159690f, -0.152418182001306330f, 0.988286848056195820f, + -0.152607686435349050f, 0.988257567730749460f, -0.152797185258443440f, + 0.988228251069897420f, -0.152986678463622040f, 0.988198898074717610f, + -0.153176166043917840f, 0.988169508746289060f, -0.153365647992363880f, + 0.988140083085692570f, -0.153555124301993450f, 0.988110621094009820f, + -0.153744594965840030f, 0.988081122772324070f, -0.153934059976937350f, + 0.988051588121720110f, -0.154123519328319360f, 0.988022017143283530f, + -0.154312973013020100f, 0.987992409838101880f, -0.154502421024073940f, + 0.987962766207263420f, -0.154691863354515430f, 0.987933086251858380f, + -0.154881299997379320f, 0.987903369972977790f, -0.155070730945700510f, + 0.987873617371714200f, -0.155260156192514240f, 0.987843828449161740f, + -0.155449575730855850f, 0.987814003206415550f, -0.155638989553760900f, + 0.987784141644572180f, -0.155828397654265230f, 0.987754243764729530f, + -0.156017800025404800f, 0.987724309567986960f, -0.156207196660215900f, + 0.987694339055445130f, -0.156396587551734880f, 0.987664332228205710f, + -0.156585972692998430f, 0.987634289087372160f, -0.156775352077043350f, + 0.987604209634049160f, -0.156964725696906780f, 0.987574093869342360f, + -0.157154093545625900f, 0.987543941794359230f, -0.157343455616238250f, + 0.987513753410208420f, -0.157532811901781530f, 0.987483528717999710f, + -0.157722162395293630f, 0.987453267718844560f, -0.157911507089812660f, + 0.987422970413855410f, -0.158100845978376980f, 0.987392636804146240f, + -0.158290179054025180f, 0.987362266890832400f, -0.158479506309795960f, + 0.987331860675030430f, -0.158668827738728310f, 0.987301418157858430f, + -0.158858143333861450f, 0.987270939340435420f, -0.159047453088234760f, + 0.987240424223882250f, -0.159236756994887850f, 0.987209872809320820f, + -0.159426055046860580f, 0.987179285097874340f, -0.159615347237193060f, + 0.987148661090667570f, -0.159804633558925440f, 0.987118000788826280f, + -0.159993914005098270f, 0.987087304193477900f, -0.160183188568752220f, + 0.987056571305750970f, -0.160372457242928280f, 0.987025802126775600f, + -0.160561720020667490f, 0.986994996657682980f, -0.160750976895011220f, + 0.986964154899605650f, -0.160940227859001080f, 0.986933276853677710f, + -0.161129472905678810f, 0.986902362521034470f, -0.161318712028086400f, + 0.986871411902812470f, -0.161507945219266120f, 0.986840425000149680f, + -0.161697172472260400f, 0.986809401814185530f, -0.161886393780111830f, + 0.986778342346060430f, -0.162075609135863330f, 0.986747246596916590f, + -0.162264818532558000f, 0.986716114567897100f, -0.162454021963239190f, + 0.986684946260146690f, -0.162643219420950310f, 0.986653741674811350f, + -0.162832410898735210f, 0.986622500813038480f, -0.163021596389637840f, + 0.986591223675976400f, -0.163210775886702380f, 0.986559910264775410f, + -0.163399949382973230f, 0.986528560580586690f, -0.163589116871495020f, + 0.986497174624562880f, -0.163778278345312670f, 0.986465752397857940f, + -0.163967433797471170f, 0.986434293901627180f, -0.164156583221015810f, + 0.986402799137027220f, -0.164345726608992190f, 0.986371268105216030f, + -0.164534863954446000f, 0.986339700807353000f, -0.164723995250423170f, + 0.986308097244598670f, -0.164913120489969890f, 0.986276457418115090f, + -0.165102239666132660f, 0.986244781329065460f, -0.165291352771958000f, + 0.986213068978614490f, -0.165480459800492780f, 0.986181320367928270f, + -0.165669560744784120f, 0.986149535498173860f, -0.165858655597879300f, + 0.986117714370520090f, -0.166047744352825790f, 0.986085856986136820f, + -0.166236827002671420f, 0.986053963346195440f, -0.166425903540464100f, + 0.986022033451868560f, -0.166614973959252090f, 0.985990067304330140f, + -0.166804038252083730f, 0.985958064904755460f, -0.166993096412007710f, + 0.985926026254321130f, -0.167182148432072940f, 0.985893951354205210f, + -0.167371194305328430f, 0.985861840205586980f, -0.167560234024823560f, + 0.985829692809647050f, -0.167749267583607890f, 0.985797509167567480f, + -0.167938294974731170f, 0.985765289280531310f, -0.168127316191243410f, + 0.985733033149723490f, -0.168316331226194830f, 0.985700740776329850f, + -0.168505340072635900f, 0.985668412161537550f, -0.168694342723617330f, + 0.985636047306535420f, -0.168883339172189980f, 0.985603646212513400f, + -0.169072329411405010f, 0.985571208880662740f, -0.169261313434313830f, + 0.985538735312176060f, -0.169450291233967960f, 0.985506225508247290f, + -0.169639262803419290f, 0.985473679470071810f, -0.169828228135719850f, + 0.985441097198846210f, -0.170017187223921950f, 0.985408478695768420f, + -0.170206140061078070f, 0.985375823962037710f, -0.170395086640240940f, + 0.985343132998854790f, -0.170584026954463590f, 0.985310405807421570f, + -0.170772960996799230f, 0.985277642388941220f, -0.170961888760301220f, + 0.985244842744618540f, -0.171150810238023280f, 0.985212006875659350f, + -0.171339725423019310f, 0.985179134783271130f, -0.171528634308343420f, + 0.985146226468662230f, -0.171717536887049970f, 0.985113281933042710f, + -0.171906433152193530f, 0.985080301177623800f, -0.172095323096829010f, + 0.985047284203618200f, -0.172284206714011370f, 0.985014231012239840f, + -0.172473083996795950f, 0.984981141604703960f, -0.172661954938238270f, + 0.984948015982227030f, -0.172850819531394080f, 0.984914854146027200f, + -0.173039677769319360f, 0.984881656097323700f, -0.173228529645070320f, + 0.984848421837337010f, -0.173417375151703470f, 0.984815151367289140f, + -0.173606214282275410f, 0.984781844688403350f, -0.173795047029843160f, + 0.984748501801904210f, -0.173983873387463820f, 0.984715122709017620f, + -0.174172693348194820f, 0.984681707410970940f, -0.174361506905093750f, + 0.984648255908992630f, -0.174550314051218510f, 0.984614768204312600f, + -0.174739114779627200f, 0.984581244298162180f, -0.174927909083378160f, + 0.984547684191773960f, -0.175116696955529920f, 0.984514087886381840f, + -0.175305478389141320f, 0.984480455383220930f, -0.175494253377271430f, + 0.984446786683527920f, -0.175683021912979490f, 0.984413081788540700f, + -0.175871783989325040f, 0.984379340699498510f, -0.176060539599367820f, + 0.984345563417641900f, -0.176249288736167880f, 0.984311749944212780f, + -0.176438031392785410f, 0.984277900280454370f, -0.176626767562280880f, + 0.984244014427611110f, -0.176815497237715000f, 0.984210092386929030f, + -0.177004220412148750f, 0.984176134159655320f, -0.177192937078643280f, + 0.984142139747038570f, -0.177381647230260040f, 0.984108109150328540f, + -0.177570350860060710f, 0.984074042370776450f, -0.177759047961107170f, + 0.984039939409634970f, -0.177947738526461560f, 0.984005800268157870f, + -0.178136422549186300f, 0.983971624947600270f, -0.178325100022344000f, + 0.983937413449218920f, -0.178513770938997510f, 0.983903165774271500f, + -0.178702435292209970f, 0.983868881924017220f, -0.178891093075044720f, + 0.983834561899716630f, -0.179079744280565390f, 0.983800205702631600f, + -0.179268388901835750f, 0.983765813334025240f, -0.179457026931919890f, + 0.983731384795162090f, -0.179645658363882160f, 0.983696920087308140f, + -0.179834283190787090f, 0.983662419211730250f, -0.180022901405699510f, + 0.983627882169697210f, -0.180211513001684450f, 0.983593308962478650f, + -0.180400117971807240f, 0.983558699591345900f, -0.180588716309133340f, + 0.983524054057571260f, -0.180777308006728590f, 0.983489372362428730f, + -0.180965893057658980f, 0.983454654507193270f, -0.181154471454990810f, + 0.983419900493141540f, -0.181343043191790540f, 0.983385110321551180f, + -0.181531608261124970f, 0.983350283993701500f, -0.181720166656061110f, + 0.983315421510872810f, -0.181908718369666160f, 0.983280522874346970f, + -0.182097263395007650f, 0.983245588085407070f, -0.182285801725153300f, + 0.983210617145337640f, -0.182474333353171120f, 0.983175610055424420f, + -0.182662858272129270f, 0.983140566816954500f, -0.182851376475096330f, + 0.983105487431216290f, -0.183039887955140950f, 0.983070371899499640f, + -0.183228392705332140f, 0.983035220223095640f, -0.183416890718739100f, + 0.983000032403296590f, -0.183605381988431270f, 0.982964808441396440f, + -0.183793866507478450f, 0.982929548338690170f, -0.183982344268950520f, + 0.982894252096474070f, -0.184170815265917720f, 0.982858919716046110f, + -0.184359279491450510f, 0.982823551198705240f, -0.184547736938619620f, + 0.982788146545751970f, -0.184736187600495950f, 0.982752705758487830f, + -0.184924631470150790f, 0.982717228838215990f, -0.185113068540655540f, + 0.982681715786240860f, -0.185301498805081900f, 0.982646166603868050f, + -0.185489922256501880f, 0.982610581292404750f, -0.185678338887987630f, + 0.982574959853159240f, -0.185866748692611660f, 0.982539302287441240f, + -0.186055151663446630f, 0.982503608596561830f, -0.186243547793565560f, + 0.982467878781833170f, -0.186431937076041610f, 0.982432112844569110f, + -0.186620319503948280f, 0.982396310786084690f, -0.186808695070359270f, + 0.982360472607696210f, -0.186997063768348540f, 0.982324598310721280f, + -0.187185425590990330f, 0.982288687896478830f, -0.187373780531359110f, + 0.982252741366289370f, -0.187562128582529600f, 0.982216758721474510f, + -0.187750469737576780f, 0.982180739963357090f, -0.187938803989575910f, + 0.982144685093261580f, -0.188127131331602420f, 0.982108594112513610f, + -0.188315451756732120f, 0.982072467022440000f, -0.188503765258040940f, + 0.982036303824369020f, -0.188692071828605230f, 0.982000104519630490f, + -0.188880371461501380f, 0.981963869109555240f, -0.189068664149806190f, + 0.981927597595475540f, -0.189256949886596750f, 0.981891289978725100f, + -0.189445228664950230f, 0.981854946260638630f, -0.189633500477944190f, + 0.981818566442552500f, -0.189821765318656410f, 0.981782150525804310f, + -0.190010023180164990f, 0.981745698511732990f, -0.190198274055548150f, + 0.981709210401678800f, -0.190386517937884470f, 0.981672686196983110f, + -0.190574754820252740f, 0.981636125898989080f, -0.190762984695732110f, + 0.981599529509040720f, -0.190951207557401800f, 0.981562897028483650f, + -0.191139423398341450f, 0.981526228458664770f, -0.191327632211630900f, + 0.981489523800932130f, -0.191515833990350210f, 0.981452783056635520f, + -0.191704028727579800f, 0.981416006227125550f, -0.191892216416400220f, + 0.981379193313754560f, -0.192080397049892440f, 0.981342344317876040f, + -0.192268570621137500f, 0.981305459240844670f, -0.192456737123216840f, + 0.981268538084016710f, -0.192644896549212100f, 0.981231580848749730f, + -0.192833048892205230f, 0.981194587536402320f, -0.193021194145278380f, + 0.981157558148334830f, -0.193209332301513960f, 0.981120492685908730f, + -0.193397463353994740f, 0.981083391150486710f, -0.193585587295803610f, + 0.981046253543432780f, -0.193773704120023820f, 0.981009079866112630f, + -0.193961813819738840f, 0.980971870119892840f, -0.194149916388032450f, + 0.980934624306141640f, -0.194338011817988600f, 0.980897342426228390f, + -0.194526100102691610f, 0.980860024481523870f, -0.194714181235225960f, + 0.980822670473400100f, -0.194902255208676520f, 0.980785280403230430f, + -0.195090322016128250f, 0.980747854272389750f, -0.195278381650666550f, + 0.980710392082253970f, -0.195466434105376980f, 0.980672893834200530f, + -0.195654479373345370f, 0.980635359529608120f, -0.195842517447657850f, + 0.980597789169856850f, -0.196030548321400790f, 0.980560182756327840f, + -0.196218571987660880f, 0.980522540290404090f, -0.196406588439524970f, + 0.980484861773469380f, -0.196594597670080220f, 0.980447147206909060f, + -0.196782599672414100f, 0.980409396592109910f, -0.196970594439614340f, + 0.980371609930459800f, -0.197158581964768880f, 0.980333787223347960f, + -0.197346562240965920f, 0.980295928472165290f, -0.197534535261294030f, + 0.980258033678303550f, -0.197722501018841920f, 0.980220102843156080f, + -0.197910459506698670f, 0.980182135968117430f, -0.198098410717953560f, + 0.980144133054583590f, -0.198286354645696220f, 0.980106094103951770f, + -0.198474291283016390f, 0.980068019117620650f, -0.198662220623004200f, + 0.980029908096990090f, -0.198850142658750090f, 0.979991761043461200f, + -0.199038057383344680f, 0.979953577958436740f, -0.199225964789878830f, + 0.979915358843320480f, -0.199413864871443770f, 0.979877103699517640f, + -0.199601757621130970f, 0.979838812528434740f, -0.199789643032032090f, + 0.979800485331479790f, -0.199977521097239150f, 0.979762122110061750f, + -0.200165391809844440f, 0.979723722865591170f, -0.200353255162940450f, + 0.979685287599479930f, -0.200541111149619980f, 0.979646816313141210f, + -0.200728959762976140f, 0.979608309007989450f, -0.200916800996102230f, + 0.979569765685440520f, -0.201104634842091900f, 0.979531186346911500f, + -0.201292461294039020f, 0.979492570993820810f, -0.201480280345037730f, + 0.979453919627588210f, -0.201668091988182530f, 0.979415232249634780f, + -0.201855896216568050f, 0.979376508861383170f, -0.202043693023289260f, + 0.979337749464256780f, -0.202231482401441450f, 0.979298954059681040f, + -0.202419264344120160f, 0.979260122649082020f, -0.202607038844421130f, + 0.979221255233887700f, -0.202794805895440440f, 0.979182351815526930f, + -0.202982565490274440f, 0.979143412395430230f, -0.203170317622019790f, + 0.979104436975029250f, -0.203358062283773320f, 0.979065425555756930f, + -0.203545799468632190f, 0.979026378139047580f, -0.203733529169693920f, + 0.978987294726337050f, -0.203921251380056120f, 0.978948175319062200f, + -0.204108966092816870f, 0.978909019918661310f, -0.204296673301074370f, + 0.978869828526574120f, -0.204484372997927240f, 0.978830601144241470f, + -0.204672065176474210f, 0.978791337773105670f, -0.204859749829814420f, + 0.978752038414610340f, -0.205047426951047250f, 0.978712703070200420f, + -0.205235096533272350f, 0.978673331741322210f, -0.205422758569589610f, + 0.978633924429423210f, -0.205610413053099240f, 0.978594481135952270f, + -0.205798059976901790f, 0.978555001862359550f, -0.205985699334097910f, + 0.978515486610096910f, -0.206173331117788710f, 0.978475935380616830f, + -0.206360955321075510f, 0.978436348175373730f, -0.206548571937059890f, + 0.978396724995823090f, -0.206736180958843690f, 0.978357065843421640f, + -0.206923782379529100f, 0.978317370719627650f, -0.207111376192218560f, + 0.978277639625900530f, -0.207298962390014750f, 0.978237872563701090f, + -0.207486540966020650f, 0.978198069534491400f, -0.207674111913339570f, + 0.978158230539735050f, -0.207861675225075070f, 0.978118355580896660f, + -0.208049230894330940f, 0.978078444659442380f, -0.208236778914211330f, + 0.978038497776839600f, -0.208424319277820600f, 0.977998514934557140f, + -0.208611851978263490f, 0.977958496134064830f, -0.208799377008644900f, + 0.977918441376834370f, -0.208986894362070070f, 0.977878350664338150f, + -0.209174404031644580f, 0.977838223998050430f, -0.209361906010474160f, + 0.977798061379446360f, -0.209549400291664940f, 0.977757862810002760f, + -0.209736886868323290f, 0.977717628291197460f, -0.209924365733555880f, + 0.977677357824509930f, -0.210111836880469610f, 0.977637051411420770f, + -0.210299300302171730f, 0.977596709053411890f, -0.210486755991769720f, + 0.977556330751966460f, -0.210674203942371440f, 0.977515916508569280f, + -0.210861644147084860f, 0.977475466324706170f, -0.211049076599018390f, + 0.977434980201864260f, -0.211236501291280710f, 0.977394458141532250f, + -0.211423918216980670f, 0.977353900145199960f, -0.211611327369227550f, + 0.977313306214358750f, -0.211798728741130840f, 0.977272676350500860f, + -0.211986122325800330f, 0.977232010555120320f, -0.212173508116346080f, + 0.977191308829712280f, -0.212360886105878420f, 0.977150571175773200f, + -0.212548256287508060f, 0.977109797594800880f, -0.212735618654345930f, + 0.977068988088294450f, -0.212922973199503180f, 0.977028142657754390f, + -0.213110319916091360f, 0.976987261304682390f, -0.213297658797222320f, + 0.976946344030581670f, -0.213484989836008050f, 0.976905390836956490f, + -0.213672313025560970f, 0.976864401725312640f, -0.213859628358993750f, + 0.976823376697157240f, -0.214046935829419360f, 0.976782315753998650f, + -0.214234235429950990f, 0.976741218897346550f, -0.214421527153702160f, + 0.976700086128711840f, -0.214608810993786760f, 0.976658917449606980f, + -0.214796086943318860f, 0.976617712861545640f, -0.214983354995412820f, + 0.976576472366042610f, -0.215170615143183390f, 0.976535195964614470f, + -0.215357867379745550f, 0.976493883658778650f, -0.215545111698214500f, + 0.976452535450054060f, -0.215732348091705880f, 0.976411151339961040f, + -0.215919576553335490f, 0.976369731330021140f, -0.216106797076219520f, + 0.976328275421757260f, -0.216294009653474340f, 0.976286783616693630f, + -0.216481214278216730f, 0.976245255916355800f, -0.216668410943563730f, + 0.976203692322270560f, -0.216855599642632620f, 0.976162092835966110f, + -0.217042780368540990f, 0.976120457458971910f, -0.217229953114406790f, + 0.976078786192818850f, -0.217417117873348190f, 0.976037079039039020f, + -0.217604274638483640f, 0.975995335999165990f, -0.217791423402931950f, + 0.975953557074734300f, -0.217978564159812200f, 0.975911742267280170f, + -0.218165696902243800f, 0.975869891578341030f, -0.218352821623346320f, + 0.975828005009455660f, -0.218539938316239770f, 0.975786082562163930f, + -0.218727046974044440f, 0.975744124238007270f, -0.218914147589880840f, + 0.975702130038528570f, -0.219101240156869800f, 0.975660099965271590f, + -0.219288324668132470f, 0.975618034019781750f, -0.219475401116790310f, + 0.975575932203605720f, -0.219662469495965050f, 0.975533794518291360f, + -0.219849529798778700f, 0.975491620965388110f, -0.220036582018353580f, + 0.975449411546446380f, -0.220223626147812380f, 0.975407166263018270f, + -0.220410662180277940f, 0.975364885116656980f, -0.220597690108873510f, + 0.975322568108916930f, -0.220784709926722610f, 0.975280215241354220f, + -0.220971721626949110f, 0.975237826515525820f, -0.221158725202677010f, + 0.975195401932990370f, -0.221345720647030810f, 0.975152941495307620f, + -0.221532707953135230f, 0.975110445204038890f, -0.221719687114115220f, + 0.975067913060746470f, -0.221906658123096100f, 0.975025345066994120f, + -0.222093620973203510f, 0.974982741224347140f, -0.222280575657563370f, + 0.974940101534371830f, -0.222467522169301880f, 0.974897425998635820f, + -0.222654460501545500f, 0.974854714618708430f, -0.222841390647421120f, + 0.974811967396159830f, -0.223028312600055820f, 0.974769184332561770f, + -0.223215226352576980f, 0.974726365429487320f, -0.223402131898112370f, + 0.974683510688510670f, -0.223589029229789990f, 0.974640620111207560f, + -0.223775918340738150f, 0.974597693699155050f, -0.223962799224085460f, + 0.974554731453931230f, -0.224149671872960870f, 0.974511733377115720f, + -0.224336536280493600f, 0.974468699470289580f, -0.224523392439813170f, + 0.974425629735034990f, -0.224710240344049430f, 0.974382524172935470f, + -0.224897079986332490f, 0.974339382785575860f, -0.225083911359792830f, + 0.974296205574542440f, -0.225270734457561160f, 0.974252992541422500f, + -0.225457549272768540f, 0.974209743687805220f, -0.225644355798546330f, + 0.974166459015280320f, -0.225831154028026170f, 0.974123138525439640f, + -0.226017943954340020f, 0.974079782219875680f, -0.226204725570620190f, + 0.974036390100182610f, -0.226391498869999240f, 0.973992962167955830f, + -0.226578263845610000f, 0.973949498424792170f, -0.226765020490585690f, + 0.973905998872289570f, -0.226951768798059810f, 0.973862463512047300f, + -0.227138508761166170f, 0.973818892345666100f, -0.227325240373038860f, + 0.973775285374748110f, -0.227511963626812280f, 0.973731642600896400f, + -0.227698678515621170f, 0.973687964025715670f, -0.227885385032600530f, + 0.973644249650811980f, -0.228072083170885730f, 0.973600499477792370f, + -0.228258772923612380f, 0.973556713508265560f, -0.228445454283916470f, + 0.973512891743841370f, -0.228632127244934230f, 0.973469034186131070f, + -0.228818791799802220f, 0.973425140836747030f, -0.229005447941657340f, + 0.973381211697303290f, -0.229192095663636770f, 0.973337246769414910f, + -0.229378734958878010f, 0.973293246054698250f, -0.229565365820518870f, + 0.973249209554771230f, -0.229751988241697490f, 0.973205137271252800f, + -0.229938602215552210f, 0.973161029205763530f, -0.230125207735221850f, + 0.973116885359925130f, -0.230311804793845440f, 0.973072705735360530f, + -0.230498393384562350f, 0.973028490333694210f, -0.230684973500512200f, + 0.972984239156551740f, -0.230871545134835020f, 0.972939952205560180f, + -0.231058108280671110f, 0.972895629482347760f, -0.231244662931161050f, + 0.972851270988544180f, -0.231431209079445750f, 0.972806876725780370f, + -0.231617746718666470f, 0.972762446695688570f, -0.231804275841964780f, + 0.972717980899902250f, -0.231990796442482440f, 0.972673479340056430f, + -0.232177308513361710f, 0.972628942017787270f, -0.232363812047745030f, + 0.972584368934732210f, -0.232550307038775240f, 0.972539760092530180f, + -0.232736793479595390f, 0.972495115492821190f, -0.232923271363348980f, + 0.972450435137246830f, -0.233109740683179690f, 0.972405719027449770f, + -0.233296201432231590f, 0.972360967165074140f, -0.233482653603649090f, + 0.972316179551765300f, -0.233669097190576820f, 0.972271356189170040f, + -0.233855532186159840f, 0.972226497078936270f, -0.234041958583543430f, + 0.972181602222713440f, -0.234228376375873210f, 0.972136671622152230f, + -0.234414785556295160f, 0.972091705278904430f, -0.234601186117955550f, + 0.972046703194623500f, -0.234787578054000970f, 0.972001665370963890f, + -0.234973961357578250f, 0.971956591809581720f, -0.235160336021834730f, + 0.971911482512134000f, -0.235346702039917840f, 0.971866337480279400f, + -0.235533059404975490f, 0.971821156715677700f, -0.235719408110155820f, + 0.971775940219990140f, -0.235905748148607370f, 0.971730687994879160f, + -0.236092079513478910f, 0.971685400042008540f, -0.236278402197919570f, + 0.971640076363043390f, -0.236464716195078780f, 0.971594716959650160f, + -0.236651021498106380f, 0.971549321833496630f, -0.236837318100152380f, + 0.971503890986251780f, -0.237023605994367200f, 0.971458424419585960f, + -0.237209885173901600f, 0.971412922135170940f, -0.237396155631906610f, + 0.971367384134679490f, -0.237582417361533570f, 0.971321810419786160f, + -0.237768670355934190f, 0.971276200992166490f, -0.237954914608260540f, + 0.971230555853497380f, -0.238141150111664840f, 0.971184875005457030f, + -0.238327376859299810f, 0.971139158449725090f, -0.238513594844318420f, + 0.971093406187982460f, -0.238699804059873980f, 0.971047618221911100f, + -0.238886004499120040f, 0.971001794553194690f, -0.239072196155210610f, + 0.970955935183517970f, -0.239258379021299980f, 0.970910040114567050f, + -0.239444553090542630f, 0.970864109348029470f, -0.239630718356093560f, + 0.970818142885593870f, -0.239816874811108000f, 0.970772140728950350f, + -0.240003022448741500f, 0.970726102879790110f, -0.240189161262149900f, + 0.970680029339806130f, -0.240375291244489450f, 0.970633920110692160f, + -0.240561412388916650f, 0.970587775194143630f, -0.240747524688588430f, + 0.970541594591857070f, -0.240933628136661910f, 0.970495378305530560f, + -0.241119722726294590f, 0.970449126336863090f, -0.241305808450644370f, + 0.970402838687555500f, -0.241491885302869330f, 0.970356515359309450f, + -0.241677953276128010f, 0.970310156353828110f, -0.241864012363579180f, + 0.970263761672816140f, -0.242050062558382070f, 0.970217331317979160f, + -0.242236103853696010f, 0.970170865291024480f, -0.242422136242680890f, + 0.970124363593660280f, -0.242608159718496810f, 0.970077826227596420f, + -0.242794174274304220f, 0.970031253194543970f, -0.242980179903263870f, + 0.969984644496215240f, -0.243166176598536900f, 0.969938000134323960f, + -0.243352164353284740f, 0.969891320110585100f, -0.243538143160669130f, + 0.969844604426714830f, -0.243724113013852160f, 0.969797853084430890f, + -0.243910073905996260f, 0.969751066085452140f, -0.244096025830264210f, + 0.969704243431498860f, -0.244281968779819030f, 0.969657385124292450f, + -0.244467902747824150f, 0.969610491165555870f, -0.244653827727443320f, + 0.969563561557013180f, -0.244839743711840670f, 0.969516596300390000f, + -0.245025650694180470f, 0.969469595397413060f, -0.245211548667627540f, + 0.969422558849810320f, -0.245397437625346960f, 0.969375486659311280f, + -0.245583317560504060f, 0.969328378827646660f, -0.245769188466264580f, + 0.969281235356548530f, -0.245955050335794590f, 0.969234056247750050f, + -0.246140903162260530f, 0.969186841502985950f, -0.246326746938829030f, + 0.969139591123992280f, -0.246512581658667210f, 0.969092305112506210f, + -0.246698407314942410f, 0.969044983470266240f, -0.246884223900822430f, + 0.968997626199012420f, -0.247070031409475250f, 0.968950233300485800f, + -0.247255829834069300f, 0.968902804776428870f, -0.247441619167773270f, + 0.968855340628585580f, -0.247627399403756280f, 0.968807840858700970f, + -0.247813170535187670f, 0.968760305468521430f, -0.247998932555237110f, + 0.968712734459794780f, -0.248184685457074780f, 0.968665127834270060f, + -0.248370429233870980f, 0.968617485593697540f, -0.248556163878796560f, + 0.968569807739828930f, -0.248741889385022480f, 0.968522094274417380f, + -0.248927605745720150f, 0.968474345199216820f, -0.249113312954061360f, + 0.968426560515983190f, -0.249299011003218190f, 0.968378740226473300f, + -0.249484699886362960f, 0.968330884332445190f, -0.249670379596668550f, + 0.968282992835658660f, -0.249856050127307990f, 0.968235065737874320f, + -0.250041711471454650f, 0.968187103040854420f, -0.250227363622282370f, + 0.968139104746362440f, -0.250413006572965220f, 0.968091070856162970f, + -0.250598640316677670f, 0.968043001372022260f, -0.250784264846594500f, + 0.967994896295707670f, -0.250969880155890720f, 0.967946755628987800f, + -0.251155486237741920f, 0.967898579373632660f, -0.251341083085323880f, + 0.967850367531413620f, -0.251526670691812610f, 0.967802120104103270f, + -0.251712249050384700f, 0.967753837093475510f, -0.251897818154216970f, + 0.967705518501305480f, -0.252083377996486450f, 0.967657164329369880f, + -0.252268928570370810f, 0.967608774579446500f, -0.252454469869047740f, + 0.967560349253314360f, -0.252640001885695520f, 0.967511888352754150f, + -0.252825524613492610f, 0.967463391879547550f, -0.253011038045617860f, + 0.967414859835477480f, -0.253196542175250560f, 0.967366292222328510f, + -0.253382036995570160f, 0.967317689041886310f, -0.253567522499756560f, + 0.967269050295937790f, -0.253752998680989990f, 0.967220375986271420f, + -0.253938465532451090f, 0.967171666114676640f, -0.254123923047320620f, + 0.967122920682944360f, -0.254309371218780000f, 0.967074139692867040f, + -0.254494810040010730f, 0.967025323146238010f, -0.254680239504194830f, + 0.966976471044852070f, -0.254865659604514570f, 0.966927583390505660f, + -0.255051070334152470f, 0.966878660184995910f, -0.255236471686291710f, + 0.966829701430121810f, -0.255421863654115460f, 0.966780707127683270f, + -0.255607246230807380f, 0.966731677279481840f, -0.255792619409551610f, + 0.966682611887320080f, -0.255977983183532430f, 0.966633510953002100f, + -0.256163337545934460f, 0.966584374478333120f, -0.256348682489942910f, + 0.966535202465119700f, -0.256534018008743040f, 0.966485994915169840f, + -0.256719344095520660f, 0.966436751830292650f, -0.256904660743461910f, + 0.966387473212298900f, -0.257089967945753120f, 0.966338159063000130f, + -0.257275265695581120f, 0.966288809384209690f, -0.257460553986133100f, + 0.966239424177741890f, -0.257645832810596390f, 0.966190003445412500f, + -0.257831102162158990f, 0.966140547189038750f, -0.258016362034009020f, + 0.966091055410438830f, -0.258201612419334870f, 0.966041528111432400f, + -0.258386853311325600f, 0.965991965293840570f, -0.258572084703170340f, + 0.965942366959485540f, -0.258757306588058680f, 0.965892733110190860f, + -0.258942518959180520f, 0.965843063747781510f, -0.259127721809726150f, + 0.965793358874083680f, -0.259312915132886230f, 0.965743618490924830f, + -0.259498098921851660f, 0.965693842600133690f, -0.259683273169813770f, + 0.965644031203540590f, -0.259868437869964270f, 0.965594184302976830f, + -0.260053593015495190f, 0.965544301900275180f, -0.260238738599598840f, + 0.965494383997269500f, -0.260423874615468010f, 0.965444430595795430f, + -0.260609001056295750f, 0.965394441697689400f, -0.260794117915275510f, + 0.965344417304789370f, -0.260979225185601070f, 0.965294357418934660f, + -0.261164322860466480f, 0.965244262041965780f, -0.261349410933066350f, + 0.965194131175724720f, -0.261534489396595520f, 0.965143964822054450f, + -0.261719558244249030f, 0.965093762982799590f, -0.261904617469222610f, + 0.965043525659805890f, -0.262089667064712040f, 0.964993252854920320f, + -0.262274707023913590f, 0.964942944569991410f, -0.262459737340023980f, + 0.964892600806868890f, -0.262644758006240040f, 0.964842221567403620f, + -0.262829769015759160f, 0.964791806853447900f, -0.263014770361779000f, + 0.964741356666855340f, -0.263199762037497560f, 0.964690871009481030f, + -0.263384744036113280f, 0.964640349883180930f, -0.263569716350824880f, + 0.964589793289812760f, -0.263754678974831350f, 0.964539201231235150f, + -0.263939631901332350f, 0.964488573709308410f, -0.264124575123527550f, + 0.964437910725893910f, -0.264309508634617110f, 0.964387212282854290f, + -0.264494432427801630f, 0.964336478382053720f, -0.264679346496281890f, + 0.964285709025357480f, -0.264864250833259260f, 0.964234904214632200f, + -0.265049145431935250f, 0.964184063951745830f, -0.265234030285511790f, + 0.964133188238567640f, -0.265418905387191260f, 0.964082277076968140f, + -0.265603770730176330f, 0.964031330468819280f, -0.265788626307669920f, + 0.963980348415994110f, -0.265973472112875590f, 0.963929330920367140f, + -0.266158308138996990f, 0.963878277983814200f, -0.266343134379238180f, + 0.963827189608212340f, -0.266527950826803690f, 0.963776065795439840f, + -0.266712757474898370f, 0.963724906547376530f, -0.266897554316727350f, + 0.963673711865903230f, -0.267082341345496300f, 0.963622481752902220f, + -0.267267118554410930f, 0.963571216210257320f, -0.267451885936677620f, + 0.963519915239853140f, -0.267636643485503090f, 0.963468578843575950f, + -0.267821391194094150f, 0.963417207023313350f, -0.268006129055658290f, + 0.963365799780954050f, -0.268190857063403180f, 0.963314357118388200f, + -0.268375575210536900f, 0.963262879037507070f, -0.268560283490267890f, + 0.963211365540203480f, -0.268744981895804980f, 0.963159816628371360f, + -0.268929670420357260f, 0.963108232303906190f, -0.269114349057134380f, + 0.963056612568704340f, -0.269299017799346120f, 0.963004957424663850f, + -0.269483676640202840f, 0.962953266873683880f, -0.269668325572915090f, + 0.962901540917665000f, -0.269852964590693860f, 0.962849779558509030f, + -0.270037593686750570f, 0.962797982798119010f, -0.270222212854296870f, + 0.962746150638399410f, -0.270406822086544820f, 0.962694283081255930f, + -0.270591421376706940f, 0.962642380128595710f, -0.270776010717996010f, + 0.962590441782326890f, -0.270960590103625170f, 0.962538468044359160f, + -0.271145159526808010f, 0.962486458916603450f, -0.271329718980758420f, + 0.962434414400972100f, -0.271514268458690700f, 0.962382334499378380f, + -0.271698807953819510f, 0.962330219213737400f, -0.271883337459359720f, + 0.962278068545965090f, -0.272067856968526920f, 0.962225882497979020f, + -0.272252366474536710f, 0.962173661071697880f, -0.272436865970605240f, + 0.962121404269041580f, -0.272621355449948980f, 0.962069112091931580f, + -0.272805834905784810f, 0.962016784542290560f, -0.272990304331329920f, + 0.961964421622042320f, -0.273174763719801930f, 0.961912023333112210f, + -0.273359213064418680f, 0.961859589677426570f, -0.273543652358398730f, + 0.961807120656913540f, -0.273728081594960540f, 0.961754616273502010f, + -0.273912500767323260f, 0.961702076529122540f, -0.274096909868706380f, + 0.961649501425706820f, -0.274281308892329660f, 0.961596890965187860f, + -0.274465697831413220f, 0.961544245149499990f, -0.274650076679177680f, + 0.961491563980579000f, -0.274834445428843940f, 0.961438847460361680f, + -0.275018804073633220f, 0.961386095590786250f, -0.275203152606767310f, + 0.961333308373792270f, -0.275387491021468140f, 0.961280485811320640f, + -0.275571819310958140f, 0.961227627905313460f, -0.275756137468460120f, + 0.961174734657714080f, -0.275940445487197150f, 0.961121806070467380f, + -0.276124743360392830f, 0.961068842145519350f, -0.276309031081271080f, + 0.961015842884817230f, -0.276493308643055990f, 0.960962808290309780f, + -0.276677576038972420f, 0.960909738363946770f, -0.276861833262245280f, + 0.960856633107679660f, -0.277046080306099900f, 0.960803492523460760f, + -0.277230317163762170f, 0.960750316613243950f, -0.277414543828458090f, + 0.960697105378984450f, -0.277598760293414290f, 0.960643858822638590f, + -0.277782966551857690f, 0.960590576946164120f, -0.277967162597015370f, + 0.960537259751520050f, -0.278151348422115090f, 0.960483907240666790f, + -0.278335524020384920f, 0.960430519415565790f, -0.278519689385053060f, + 0.960377096278180130f, -0.278703844509348490f, 0.960323637830473920f, + -0.278887989386500280f, 0.960270144074412800f, -0.279072124009737800f, + 0.960216615011963430f, -0.279256248372291180f, 0.960163050645094000f, + -0.279440362467390510f, 0.960109450975773940f, -0.279624466288266590f, + 0.960055816005973890f, -0.279808559828150390f, 0.960002145737665960f, + -0.279992643080273220f, 0.959948440172823210f, -0.280176716037866980f, + 0.959894699313420530f, -0.280360778694163810f, 0.959840923161433770f, + -0.280544831042396250f, 0.959787111718839900f, -0.280728873075797190f, + 0.959733264987617680f, -0.280912904787600000f, 0.959679382969746750f, + -0.281096926171038260f, 0.959625465667208190f, -0.281280937219346110f, + 0.959571513081984520f, -0.281464937925757940f, 0.959517525216059260f, + -0.281648928283508630f, 0.959463502071417510f, -0.281832908285833350f, + 0.959409443650045550f, -0.282016877925967640f, 0.959355349953930790f, + -0.282200837197147560f, 0.959301220985062210f, -0.282384786092609360f, + 0.959247056745430090f, -0.282568724605589740f, 0.959192857237025740f, + -0.282752652729325930f, 0.959138622461841890f, -0.282936570457055390f, + 0.959084352421872730f, -0.283120477782015820f, 0.959030047119113660f, + -0.283304374697445740f, 0.958975706555561080f, -0.283488261196583550f, + 0.958921330733213170f, -0.283672137272668430f, 0.958866919654069010f, + -0.283856002918939750f, 0.958812473320129310f, -0.284039858128637190f, + 0.958757991733395710f, -0.284223702895001040f, 0.958703474895871600f, + -0.284407537211271880f, 0.958648922809561150f, -0.284591361070690440f, + 0.958594335476470220f, -0.284775174466498300f, 0.958539712898605730f, + -0.284958977391937040f, 0.958485055077976100f, -0.285142769840248670f, + 0.958430362016590930f, -0.285326551804675870f, 0.958375633716461170f, + -0.285510323278461260f, 0.958320870179598880f, -0.285694084254848320f, + 0.958266071408017670f, -0.285877834727080620f, 0.958211237403732260f, + -0.286061574688402040f, 0.958156368168758820f, -0.286245304132057120f, + 0.958101463705114730f, -0.286429023051290700f, 0.958046524014818600f, + -0.286612731439347790f, 0.957991549099890370f, -0.286796429289474080f, + 0.957936538962351420f, -0.286980116594915570f, 0.957881493604224370f, + -0.287163793348918390f, 0.957826413027532910f, -0.287347459544729510f, + 0.957771297234302320f, -0.287531115175595930f, 0.957716146226558870f, + -0.287714760234765170f, 0.957660960006330610f, -0.287898394715485170f, + 0.957605738575646350f, -0.288082018611004130f, 0.957550481936536470f, + -0.288265631914570770f, 0.957495190091032570f, -0.288449234619434220f, + 0.957439863041167680f, -0.288632826718843830f, 0.957384500788975860f, + -0.288816408206049480f, 0.957329103336492790f, -0.288999979074301420f, + 0.957273670685755200f, -0.289183539316850200f, 0.957218202838801210f, + -0.289367088926947010f, 0.957162699797670210f, -0.289550627897843030f, + 0.957107161564402790f, -0.289734156222790250f, 0.957051588141040970f, + -0.289917673895040750f, 0.956995979529628230f, -0.290101180907847090f, + 0.956940335732208820f, -0.290284677254462330f, 0.956884656750828900f, + -0.290468162928139820f, 0.956828942587535370f, -0.290651637922133220f, + 0.956773193244376930f, -0.290835102229696830f, 0.956717408723403050f, + -0.291018555844085090f, 0.956661589026665090f, -0.291201998758552900f, + 0.956605734156215080f, -0.291385430966355660f, 0.956549844114106820f, + -0.291568852460749040f, 0.956493918902395100f, -0.291752263234989260f, + 0.956437958523136180f, -0.291935663282332780f, 0.956381962978387730f, + -0.292119052596036380f, 0.956325932270208230f, -0.292302431169357560f, + 0.956269866400658030f, -0.292485798995553880f, 0.956213765371798470f, + -0.292669156067883460f, 0.956157629185692140f, -0.292852502379604810f, + 0.956101457844403040f, -0.293035837923976810f, 0.956045251349996410f, + -0.293219162694258630f, 0.955989009704538930f, -0.293402476683710110f, + 0.955932732910098280f, -0.293585779885591200f, 0.955876420968743590f, + -0.293769072293162400f, 0.955820073882545420f, -0.293952353899684660f, + 0.955763691653575440f, -0.294135624698419030f, 0.955707274283906560f, + -0.294318884682627400f, 0.955650821775613330f, -0.294502133845571670f, + 0.955594334130771110f, -0.294685372180514330f, 0.955537811351456880f, + -0.294868599680718270f, 0.955481253439748770f, -0.295051816339446720f, + 0.955424660397726330f, -0.295235022149963220f, 0.955368032227470350f, + -0.295418217105532010f, 0.955311368931062720f, -0.295601401199417360f, + 0.955254670510586990f, -0.295784574424884260f, 0.955197936968127710f, + -0.295967736775197890f, 0.955141168305770780f, -0.296150888243623790f, + 0.955084364525603410f, -0.296334028823428190f, 0.955027525629714160f, + -0.296517158507877470f, 0.954970651620192790f, -0.296700277290238350f, + 0.954913742499130520f, -0.296883385163778270f, 0.954856798268619580f, + -0.297066482121764730f, 0.954799818930753720f, -0.297249568157465840f, + 0.954742804487627940f, -0.297432643264150030f, 0.954685754941338340f, + -0.297615707435086200f, 0.954628670293982680f, -0.297798760663543550f, + 0.954571550547659630f, -0.297981802942791810f, 0.954514395704469500f, + -0.298164834266100850f, 0.954457205766513490f, -0.298347854626741400f, + 0.954399980735894490f, -0.298530864017984120f, 0.954342720614716480f, + -0.298713862433100330f, 0.954285425405084650f, -0.298896849865361800f, + 0.954228095109105670f, -0.299079826308040480f, 0.954170729728887280f, + -0.299262791754408840f, 0.954113329266538800f, -0.299445746197739890f, + 0.954055893724170660f, -0.299628689631306790f, 0.953998423103894490f, + -0.299811622048383350f, 0.953940917407823500f, -0.299994543442243580f, + 0.953883376638071770f, -0.300177453806161950f, 0.953825800796755050f, + -0.300360353133413530f, 0.953768189885990330f, -0.300543241417273450f, + 0.953710543907895670f, -0.300726118651017500f, 0.953652862864590500f, + -0.300908984827921890f, 0.953595146758195680f, -0.301091839941263100f, + 0.953537395590833280f, -0.301274683984317950f, 0.953479609364626610f, + -0.301457516950363940f, 0.953421788081700310f, -0.301640338832678770f, + 0.953363931744180330f, -0.301823149624540650f, 0.953306040354193860f, + -0.302005949319228080f, 0.953248113913869320f, -0.302188737910019990f, + 0.953190152425336670f, -0.302371515390195970f, 0.953132155890726750f, + -0.302554281753035610f, 0.953074124312172200f, -0.302737036991819140f, + 0.953016057691806530f, -0.302919781099827310f, 0.952957956031764700f, + -0.303102514070341060f, 0.952899819334182880f, -0.303285235896641750f, + 0.952841647601198720f, -0.303467946572011320f, 0.952783440834950920f, + -0.303650646089731910f, 0.952725199037579570f, -0.303833334443086360f, + 0.952666922211226170f, -0.304016011625357570f, 0.952608610358033350f, + -0.304198677629829110f, 0.952550263480144930f, -0.304381332449784880f, + 0.952491881579706320f, -0.304563976078509100f, 0.952433464658864030f, + -0.304746608509286530f, 0.952375012719765880f, -0.304929229735402370f, + 0.952316525764560940f, -0.305111839750142110f, 0.952258003795399600f, + -0.305294438546791670f, 0.952199446814433580f, -0.305477026118637420f, + 0.952140854823815830f, -0.305659602458966120f, 0.952082227825700620f, + -0.305842167561065080f, 0.952023565822243570f, -0.306024721418221790f, + 0.951964868815601380f, -0.306207264023724220f, 0.951906136807932350f, + -0.306389795370860920f, 0.951847369801395620f, -0.306572315452920740f, + 0.951788567798152130f, -0.306754824263192780f, 0.951729730800363830f, + -0.306937321794966910f, 0.951670858810193860f, -0.307119808041533100f, + 0.951611951829806850f, -0.307302282996181790f, 0.951553009861368590f, + -0.307484746652204100f, 0.951494032907046370f, -0.307667199002891190f, + 0.951435020969008340f, -0.307849640041534870f, 0.951375974049424420f, + -0.308032069761427330f, 0.951316892150465550f, -0.308214488155861050f, + 0.951257775274304000f, -0.308396895218129190f, 0.951198623423113230f, + -0.308579290941525090f, 0.951139436599068190f, -0.308761675319342450f, + 0.951080214804345010f, -0.308944048344875710f, 0.951020958041121080f, + -0.309126410011419440f, 0.950961666311575080f, -0.309308760312268730f, + 0.950902339617887060f, -0.309491099240719100f, 0.950842977962238160f, + -0.309673426790066380f, 0.950783581346811070f, -0.309855742953607070f, + 0.950724149773789610f, -0.310038047724637890f, 0.950664683245358910f, + -0.310220341096455850f, 0.950605181763705340f, -0.310402623062358720f, + 0.950545645331016600f, -0.310584893615644450f, 0.950486073949481700f, + -0.310767152749611470f, 0.950426467621290900f, -0.310949400457558640f, + 0.950366826348635780f, -0.311131636732785270f, 0.950307150133709260f, + -0.311313861568590920f, 0.950247438978705230f, -0.311496074958275910f, + 0.950187692885819280f, -0.311678276895140550f, 0.950127911857248100f, + -0.311860467372486020f, 0.950068095895189590f, -0.312042646383613510f, + 0.950008245001843000f, -0.312224813921824880f, 0.949948359179409010f, + -0.312406969980422440f, 0.949888438430089300f, -0.312589114552708710f, + 0.949828482756087110f, -0.312771247631986770f, 0.949768492159606680f, + -0.312953369211560200f, 0.949708466642853800f, -0.313135479284732840f, + 0.949648406208035480f, -0.313317577844809010f, 0.949588310857359950f, + -0.313499664885093510f, 0.949528180593036670f, -0.313681740398891520f, + 0.949468015417276550f, -0.313863804379508500f, 0.949407815332291570f, + -0.314045856820250710f, 0.949347580340295210f, -0.314227897714424440f, + 0.949287310443502120f, -0.314409927055336660f, 0.949227005644128210f, + -0.314591944836294660f, 0.949166665944390700f, -0.314773951050606070f, + 0.949106291346508260f, -0.314955945691579140f, 0.949045881852700560f, + -0.315137928752522440f, 0.948985437465188710f, -0.315319900226744890f, + 0.948924958186195160f, -0.315501860107555990f, 0.948864444017943340f, + -0.315683808388265650f, 0.948803894962658490f, -0.315865745062183960f, + 0.948743311022566480f, -0.316047670122621860f, 0.948682692199895090f, + -0.316229583562890330f, 0.948622038496872990f, -0.316411485376300980f, + 0.948561349915730270f, -0.316593375556165850f, 0.948500626458698260f, + -0.316775254095797270f, 0.948439868128009620f, -0.316957120988508150f, + 0.948379074925898120f, -0.317138976227611780f, 0.948318246854599090f, + -0.317320819806421740f, 0.948257383916349060f, -0.317502651718252260f, + 0.948196486113385580f, -0.317684471956417970f, 0.948135553447947980f, + -0.317866280514233660f, 0.948074585922276230f, -0.318048077385014950f, + 0.948013583538612200f, -0.318229862562077530f, 0.947952546299198670f, + -0.318411636038737790f, 0.947891474206279840f, -0.318593397808312420f, + 0.947830367262101010f, -0.318775147864118480f, 0.947769225468909180f, + -0.318956886199473650f, 0.947708048828952100f, -0.319138612807695900f, + 0.947646837344479300f, -0.319320327682103610f, 0.947585591017741090f, + -0.319502030816015690f, 0.947524309850989570f, -0.319683722202751430f, + 0.947462993846477700f, -0.319865401835630500f, 0.947401643006459900f, + -0.320047069707973140f, 0.947340257333192050f, -0.320228725813099860f, + 0.947278836828930880f, -0.320410370144331820f, 0.947217381495934820f, + -0.320592002694990330f, 0.947155891336463270f, -0.320773623458397330f, + 0.947094366352777220f, -0.320955232427875210f, 0.947032806547138620f, + -0.321136829596746660f, 0.946971211921810880f, -0.321318414958334850f, + 0.946909582479058760f, -0.321499988505963510f, 0.946847918221148000f, + -0.321681550232956580f, 0.946786219150346000f, -0.321863100132638580f, + 0.946724485268921170f, -0.322044638198334510f, 0.946662716579143360f, + -0.322226164423369600f, 0.946600913083283530f, -0.322407678801069850f, + 0.946539074783614100f, -0.322589181324761330f, 0.946477201682408680f, + -0.322770671987770710f, 0.946415293781942110f, -0.322952150783425260f, + 0.946353351084490590f, -0.323133617705052330f, 0.946291373592331620f, + -0.323315072745979980f, 0.946229361307743820f, -0.323496515899536710f, + 0.946167314233007370f, -0.323677947159051240f, 0.946105232370403450f, + -0.323859366517852850f, 0.946043115722214560f, -0.324040773969271450f, + 0.945980964290724760f, -0.324222169506636960f, 0.945918778078219110f, + -0.324403553123280230f, 0.945856557086983910f, -0.324584924812532150f, + 0.945794301319306970f, -0.324766284567724220f, 0.945732010777477150f, + -0.324947632382188430f, 0.945669685463784710f, -0.325128968249257080f, + 0.945607325380521280f, -0.325310292162262930f, 0.945544930529979680f, + -0.325491604114539310f, 0.945482500914453740f, -0.325672904099419850f, + 0.945420036536239070f, -0.325854192110238580f, 0.945357537397632290f, + -0.326035468140330240f, 0.945295003500931210f, -0.326216732183029710f, + 0.945232434848435000f, -0.326397984231672490f, 0.945169831442444150f, + -0.326579224279594400f, 0.945107193285260610f, -0.326760452320131730f, + 0.945044520379187070f, -0.326941668346621420f, 0.944981812726528150f, + -0.327122872352400510f, 0.944919070329589220f, -0.327304064330806670f, + 0.944856293190677210f, -0.327485244275178000f, 0.944793481312100280f, + -0.327666412178853120f, 0.944730634696167800f, -0.327847568035170840f, + 0.944667753345190490f, -0.328028711837470680f, 0.944604837261480260f, + -0.328209843579092500f, 0.944541886447350490f, -0.328390963253376580f, + 0.944478900905115550f, -0.328572070853663740f, 0.944415880637091250f, + -0.328753166373294990f, 0.944352825645594750f, -0.328934249805612200f, + 0.944289735932944410f, -0.329115321143957250f, 0.944226611501459810f, + -0.329296380381672750f, 0.944163452353461770f, -0.329477427512101740f, + 0.944100258491272660f, -0.329658462528587490f, 0.944037029917215830f, + -0.329839485424473940f, 0.943973766633615980f, -0.330020496193105420f, + 0.943910468642799150f, -0.330201494827826570f, 0.943847135947092690f, + -0.330382481321982780f, 0.943783768548825060f, -0.330563455668919540f, + 0.943720366450326200f, -0.330744417861982890f, 0.943656929653927220f, + -0.330925367894519540f, 0.943593458161960390f, -0.331106305759876430f, + 0.943529951976759480f, -0.331287231451400820f, 0.943466411100659320f, + -0.331468144962440870f, 0.943402835535996240f, -0.331649046286344670f, + 0.943339225285107720f, -0.331829935416461110f, 0.943275580350332540f, + -0.332010812346139380f, 0.943211900734010620f, -0.332191677068729150f, + 0.943148186438483420f, -0.332372529577580620f, 0.943084437466093490f, + -0.332553369866044220f, 0.943020653819184650f, -0.332734197927471050f, + 0.942956835500102120f, -0.332915013755212650f, 0.942892982511192250f, + -0.333095817342620780f, 0.942829094854802710f, -0.333276608683047930f, + 0.942765172533282510f, -0.333457387769846850f, 0.942701215548981900f, + -0.333638154596370860f, 0.942637223904252530f, -0.333818909155973620f, + 0.942573197601446870f, -0.333999651442009380f, 0.942509136642919240f, + -0.334180381447832690f, 0.942445041031024890f, -0.334361099166798740f, + 0.942380910768120470f, -0.334541804592262900f, 0.942316745856563780f, + -0.334722497717581220f, 0.942252546298714020f, -0.334903178536110180f, + 0.942188312096931770f, -0.335083847041206580f, 0.942124043253578570f, + -0.335264503226227810f, 0.942059739771017310f, -0.335445147084531600f, + 0.941995401651612550f, -0.335625778609476290f, 0.941931028897729620f, + -0.335806397794420450f, 0.941866621511735280f, -0.335987004632723350f, + 0.941802179495997650f, -0.336167599117744520f, 0.941737702852886160f, + -0.336348181242844050f, 0.941673191584771360f, -0.336528751001382410f, + 0.941608645694025250f, -0.336709308386720580f, 0.941544065183020810f, + -0.336889853392220050f, 0.941479450054132580f, -0.337070386011242620f, + 0.941414800309736340f, -0.337250906237150590f, 0.941350115952208970f, + -0.337431414063306840f, 0.941285396983928660f, -0.337611909483074620f, + 0.941220643407275180f, -0.337792392489817460f, 0.941155855224629190f, + -0.337972863076899720f, 0.941091032438372780f, -0.338153321237685930f, + 0.941026175050889260f, -0.338333766965541130f, 0.940961283064563280f, + -0.338514200253830940f, 0.940896356481780830f, -0.338694621095921190f, + 0.940831395304928870f, -0.338875029485178450f, 0.940766399536396070f, + -0.339055425414969640f, 0.940701369178571940f, -0.339235808878661950f, + 0.940636304233847590f, -0.339416179869623360f, 0.940571204704615190f, + -0.339596538381222110f, 0.940506070593268300f, -0.339776884406826850f, + 0.940440901902201750f, -0.339957217939806880f, 0.940375698633811540f, + -0.340137538973531720f, 0.940310460790495070f, -0.340317847501371670f, + 0.940245188374650880f, -0.340498143516697160f, 0.940179881388678920f, + -0.340678427012879200f, 0.940114539834980280f, -0.340858697983289440f, + 0.940049163715957370f, -0.341038956421299720f, 0.939983753034014050f, + -0.341219202320282360f, 0.939918307791555050f, -0.341399435673610420f, + 0.939852827990986680f, -0.341579656474657160f, 0.939787313634716570f, + -0.341759864716796310f, 0.939721764725153340f, -0.341940060393402190f, + 0.939656181264707180f, -0.342120243497849530f, 0.939590563255789270f, + -0.342300414023513520f, 0.939524910700812230f, -0.342480571963769800f, + 0.939459223602189920f, -0.342660717311994380f, 0.939393501962337510f, + -0.342840850061563950f, 0.939327745783671400f, -0.343020970205855540f, + 0.939261955068609210f, -0.343201077738246540f, 0.939196129819569900f, + -0.343381172652115040f, 0.939130270038973650f, -0.343561254940839390f, + 0.939064375729241950f, -0.343741324597798490f, 0.938998446892797540f, + -0.343921381616371700f, 0.938932483532064600f, -0.344101425989938810f, + 0.938866485649468060f, -0.344281457711880180f, 0.938800453247434770f, + -0.344461476775576540f, 0.938734386328392460f, -0.344641483174408960f, + 0.938668284894770170f, -0.344821476901759290f, 0.938602148948998400f, + -0.345001457951009670f, 0.938535978493508560f, -0.345181426315542550f, + 0.938469773530733800f, -0.345361381988741220f, 0.938403534063108060f, + -0.345541324963989090f, 0.938337260093066950f, -0.345721255234670120f, + 0.938270951623047190f, -0.345901172794168990f, 0.938204608655486490f, + -0.346081077635870430f, 0.938138231192824360f, -0.346260969753160010f, + 0.938071819237501270f, -0.346440849139423520f, 0.938005372791958840f, + -0.346620715788047320f, 0.937938891858640320f, -0.346800569692418290f, + 0.937872376439989890f, -0.346980410845923680f, 0.937805826538453120f, + -0.347160239241951160f, 0.937739242156476970f, -0.347340054873889140f, + 0.937672623296509470f, -0.347519857735126110f, 0.937605969960999990f, + -0.347699647819051380f, 0.937539282152399230f, -0.347879425119054510f, + 0.937472559873159250f, -0.348059189628525610f, 0.937405803125732960f, + -0.348238941340855260f, 0.937339011912574960f, -0.348418680249434560f, + 0.937272186236140950f, -0.348598406347654930f, 0.937205326098887960f, + -0.348778119628908420f, 0.937138431503274140f, -0.348957820086587490f, + 0.937071502451759190f, -0.349137507714084970f, 0.937004538946803690f, + -0.349317182504794380f, 0.936937540990869900f, -0.349496844452109550f, + 0.936870508586420960f, -0.349676493549424760f, 0.936803441735921560f, + -0.349856129790134920f, 0.936736340441837620f, -0.350035753167635240f, + 0.936669204706636170f, -0.350215363675321580f, 0.936602034532785570f, + -0.350394961306590150f, 0.936534829922755500f, -0.350574546054837510f, + 0.936467590879016990f, -0.350754117913461060f, 0.936400317404042060f, + -0.350933676875858360f, 0.936333009500304180f, -0.351113222935427460f, + 0.936265667170278260f, -0.351292756085567090f, 0.936198290416440090f, + -0.351472276319676310f, 0.936130879241267030f, -0.351651783631154570f, + 0.936063433647237540f, -0.351831278013402030f, 0.935995953636831410f, + -0.352010759459819080f, 0.935928439212529660f, -0.352190227963806830f, + 0.935860890376814640f, -0.352369683518766630f, 0.935793307132169900f, + -0.352549126118100460f, 0.935725689481080370f, -0.352728555755210730f, + 0.935658037426032040f, -0.352907972423500250f, 0.935590350969512370f, + -0.353087376116372480f, 0.935522630114009930f, -0.353266766827231240f, + 0.935454874862014620f, -0.353446144549480810f, 0.935387085216017770f, + -0.353625509276525970f, 0.935319261178511610f, -0.353804861001772050f, + 0.935251402751989920f, -0.353984199718624770f, 0.935183509938947610f, + -0.354163525420490340f, 0.935115582741880890f, -0.354342838100775550f, + 0.935047621163287430f, -0.354522137752887430f, 0.934979625205665800f, + -0.354701424370233830f, 0.934911594871516090f, -0.354880697946222790f, + 0.934843530163339540f, -0.355059958474262860f, 0.934775431083638700f, + -0.355239205947763310f, 0.934707297634917440f, -0.355418440360133650f, + 0.934639129819680780f, -0.355597661704783850f, 0.934570927640435030f, + -0.355776869975124640f, 0.934502691099687870f, -0.355956065164566850f, + 0.934434420199948050f, -0.356135247266522130f, 0.934366114943725790f, + -0.356314416274402410f, 0.934297775333532530f, -0.356493572181620090f, + 0.934229401371880820f, -0.356672714981588260f, 0.934160993061284530f, + -0.356851844667720300f, 0.934092550404258980f, -0.357030961233429980f, + 0.934024073403320390f, -0.357210064672131960f, 0.933955562060986730f, + -0.357389154977240940f, 0.933887016379776890f, -0.357568232142172260f, + 0.933818436362210960f, -0.357747296160341900f, 0.933749822010810580f, + -0.357926347025166010f, 0.933681173328098410f, -0.358105384730061590f, + 0.933612490316598540f, -0.358284409268445850f, 0.933543772978836170f, + -0.358463420633736540f, 0.933475021317337950f, -0.358642418819351990f, + 0.933406235334631520f, -0.358821403818710860f, 0.933337415033246190f, + -0.359000375625232460f, 0.933268560415712050f, -0.359179334232336500f, + 0.933199671484560730f, -0.359358279633443130f, 0.933130748242325230f, + -0.359537211821973070f, 0.933061790691539380f, -0.359716130791347570f, + 0.932992798834738960f, -0.359895036534988110f, 0.932923772674460140f, + -0.360073929046317020f, 0.932854712213241120f, -0.360252808318756890f, + 0.932785617453621100f, -0.360431674345730700f, 0.932716488398140250f, + -0.360610527120662270f, 0.932647325049340450f, -0.360789366636975580f, + 0.932578127409764420f, -0.360968192888095230f, 0.932508895481956590f, + -0.361147005867446250f, 0.932439629268462360f, -0.361325805568454280f, + 0.932370328771828460f, -0.361504591984545260f, 0.932300993994602760f, + -0.361683365109145840f, 0.932231624939334540f, -0.361862124935682980f, + 0.932162221608574430f, -0.362040871457584180f, 0.932092784004874050f, + -0.362219604668277460f, 0.932023312130786490f, -0.362398324561191310f, + 0.931953805988866010f, -0.362577031129754760f, 0.931884265581668150f, + -0.362755724367397230f, 0.931814690911749730f, -0.362934404267548640f, + 0.931745081981668720f, -0.363113070823639470f, 0.931675438793984620f, + -0.363291724029100760f, 0.931605761351257830f, -0.363470363877363760f, + 0.931536049656050300f, -0.363648990361860550f, 0.931466303710925090f, + -0.363827603476023500f, 0.931396523518446600f, -0.364006203213285470f, + 0.931326709081180430f, -0.364184789567079890f, 0.931256860401693420f, + -0.364363362530840620f, 0.931186977482553750f, -0.364541922098002120f, + 0.931117060326330790f, -0.364720468261999280f, 0.931047108935595280f, + -0.364899001016267320f, 0.930977123312918930f, -0.365077520354242180f, + 0.930907103460875130f, -0.365256026269360320f, 0.930837049382038150f, + -0.365434518755058390f, 0.930766961078983710f, -0.365612997804773850f, + 0.930696838554288860f, -0.365791463411944570f, 0.930626681810531760f, + -0.365969915570008740f, 0.930556490850291800f, -0.366148354272405330f, + 0.930486265676149780f, -0.366326779512573590f, 0.930416006290687550f, + -0.366505191283953370f, 0.930345712696488470f, -0.366683589579984930f, + 0.930275384896137150f, -0.366861974394109060f, 0.930205022892219070f, + -0.367040345719767180f, 0.930134626687321390f, -0.367218703550400980f, + 0.930064196284032360f, -0.367397047879452710f, 0.929993731684941480f, + -0.367575378700365330f, 0.929923232892639670f, -0.367753696006581980f, + 0.929852699909718750f, -0.367931999791546450f, 0.929782132738772190f, + -0.368110290048703050f, 0.929711531382394370f, -0.368288566771496570f, + 0.929640895843181330f, -0.368466829953372320f, 0.929570226123729860f, + -0.368645079587776040f, 0.929499522226638560f, -0.368823315668153910f, + 0.929428784154506800f, -0.369001538187952780f, 0.929358011909935500f, + -0.369179747140620020f, 0.929287205495526790f, -0.369357942519603130f, + 0.929216364913884040f, -0.369536124318350650f, 0.929145490167611720f, + -0.369714292530311240f, 0.929074581259315860f, -0.369892447148934100f, + 0.929003638191603360f, -0.370070588167669080f, 0.928932660967082820f, + -0.370248715579966360f, 0.928861649588363700f, -0.370426829379276790f, + 0.928790604058057020f, -0.370604929559051670f, 0.928719524378774810f, + -0.370783016112742560f, 0.928648410553130520f, -0.370961089033801980f, + 0.928577262583738850f, -0.371139148315682570f, 0.928506080473215590f, + -0.371317193951837540f, 0.928434864224177980f, -0.371495225935720760f, + 0.928363613839244370f, -0.371673244260786520f, 0.928292329321034670f, + -0.371851248920489490f, 0.928221010672169440f, -0.372029239908285010f, + 0.928149657895271150f, -0.372207217217628840f, 0.928078270992963140f, + -0.372385180841977360f, 0.928006849967869970f, -0.372563130774787250f, + 0.927935394822617890f, -0.372741067009515760f, 0.927863905559833780f, + -0.372918989539620830f, 0.927792382182146320f, -0.373096898358560640f, + 0.927720824692185200f, -0.373274793459793970f, 0.927649233092581180f, + -0.373452674836780300f, 0.927577607385966730f, -0.373630542482979280f, + 0.927505947574975180f, -0.373808396391851210f, 0.927434253662241300f, + -0.373986236556857030f, 0.927362525650401110f, -0.374164062971457930f, + 0.927290763542091720f, -0.374341875629115920f, 0.927218967339951790f, + -0.374519674523293210f, 0.927147137046620880f, -0.374697459647452600f, + 0.927075272664740100f, -0.374875230995057540f, 0.927003374196951670f, + -0.375052988559571920f, 0.926931441645899130f, -0.375230732334459920f, + 0.926859475014227160f, -0.375408462313186590f, 0.926787474304581750f, + -0.375586178489217220f, 0.926715439519610330f, -0.375763880856017700f, + 0.926643370661961230f, -0.375941569407054420f, 0.926571267734284330f, + -0.376119244135794340f, 0.926499130739230510f, -0.376296905035704790f, + 0.926426959679452210f, -0.376474552100253770f, 0.926354754557602860f, + -0.376652185322909560f, 0.926282515376337210f, -0.376829804697141280f, + 0.926210242138311380f, -0.377007410216418260f, 0.926137934846182560f, + -0.377185001874210450f, 0.926065593502609310f, -0.377362579663988340f, + 0.925993218110251480f, -0.377540143579222940f, 0.925920808671770070f, + -0.377717693613385640f, 0.925848365189827270f, -0.377895229759948490f, + 0.925775887667086740f, -0.378072752012383990f, 0.925703376106213230f, + -0.378250260364165200f, 0.925630830509872720f, -0.378427754808765560f, + 0.925558250880732740f, -0.378605235339659120f, 0.925485637221461490f, + -0.378782701950320540f, 0.925412989534729060f, -0.378960154634224720f, + 0.925340307823206310f, -0.379137593384847320f, 0.925267592089565660f, + -0.379315018195664430f, 0.925194842336480530f, -0.379492429060152630f, + 0.925122058566625880f, -0.379669825971788940f, 0.925049240782677580f, + -0.379847208924051160f, 0.924976388987313160f, -0.380024577910417270f, + 0.924903503183210910f, -0.380201932924366050f, 0.924830583373050800f, + -0.380379273959376600f, 0.924757629559513910f, -0.380556601008928520f, + 0.924684641745282420f, -0.380733914066502140f, 0.924611619933039970f, + -0.380911213125578070f, 0.924538564125471420f, -0.381088498179637520f, + 0.924465474325262600f, -0.381265769222162380f, 0.924392350535101050f, + -0.381443026246634730f, 0.924319192757675160f, -0.381620269246537360f, + 0.924246000995674890f, -0.381797498215353640f, 0.924172775251791200f, + -0.381974713146567220f, 0.924099515528716280f, -0.382151914033662610f, + 0.924026221829143850f, -0.382329100870124510f, 0.923952894155768640f, + -0.382506273649438230f, 0.923879532511286740f, -0.382683432365089780f, + 0.923806136898395410f, -0.382860577010565420f, 0.923732707319793290f, + -0.383037707579352020f, 0.923659243778179980f, -0.383214824064937180f, + 0.923585746276256670f, -0.383391926460808660f, 0.923512214816725630f, + -0.383569014760454910f, 0.923438649402290370f, -0.383746088957365010f, + 0.923365050035655720f, -0.383923149045028390f, 0.923291416719527640f, + -0.384100195016935040f, 0.923217749456613500f, -0.384277226866575510f, + 0.923144048249621930f, -0.384454244587440820f, 0.923070313101262420f, + -0.384631248173022580f, 0.922996544014246250f, -0.384808237616812880f, + 0.922922740991285680f, -0.384985212912304200f, 0.922848904035094120f, + -0.385162174052989860f, 0.922775033148386380f, -0.385339121032363340f, + 0.922701128333878630f, -0.385516053843918850f, 0.922627189594287910f, + -0.385692972481151140f, 0.922553216932332830f, -0.385869876937555310f, + 0.922479210350733210f, -0.386046767206627170f, 0.922405169852209880f, + -0.386223643281862980f, 0.922331095439485440f, -0.386400505156759440f, + 0.922256987115283030f, -0.386577352824813920f, 0.922182844882327600f, + -0.386754186279524180f, 0.922108668743345180f, -0.386931005514388580f, + 0.922034458701062820f, -0.387107810522905990f, 0.921960214758209220f, + -0.387284601298575840f, 0.921885936917513970f, -0.387461377834897870f, + 0.921811625181708120f, -0.387638140125372730f, 0.921737279553523910f, + -0.387814888163501180f, 0.921662900035694730f, -0.387991621942784860f, + 0.921588486630955490f, -0.388168341456725740f, 0.921514039342042010f, + -0.388345046698826250f, 0.921439558171691430f, -0.388521737662589570f, + 0.921365043122642340f, -0.388698414341519190f, 0.921290494197634540f, + -0.388875076729119250f, 0.921215911399408730f, -0.389051724818894380f, + 0.921141294730707270f, -0.389228358604349730f, 0.921066644194273640f, + -0.389404978078990940f, 0.920991959792852310f, -0.389581583236324300f, + 0.920917241529189520f, -0.389758174069856410f, 0.920842489406032190f, + -0.389934750573094730f, 0.920767703426128790f, -0.390111312739546910f, + 0.920692883592229120f, -0.390287860562721190f, 0.920618029907083970f, + -0.390464394036126590f, 0.920543142373445480f, -0.390640913153272430f, + 0.920468220994067110f, -0.390817417907668500f, 0.920393265771703550f, + -0.390993908292825380f, 0.920318276709110590f, -0.391170384302253870f, + 0.920243253809045370f, -0.391346845929465560f, 0.920168197074266340f, + -0.391523293167972410f, 0.920093106507533180f, -0.391699726011286940f, + 0.920017982111606570f, -0.391876144452922350f, 0.919942823889248640f, + -0.392052548486392090f, 0.919867631843222950f, -0.392228938105210310f, + 0.919792405976293860f, -0.392405313302891690f, 0.919717146291227360f, + -0.392581674072951470f, 0.919641852790790470f, -0.392758020408905280f, + 0.919566525477751530f, -0.392934352304269490f, 0.919491164354880100f, + -0.393110669752560760f, 0.919415769424947070f, -0.393286972747296400f, + 0.919340340690724340f, -0.393463261281994330f, 0.919264878154985370f, + -0.393639535350172880f, 0.919189381820504470f, -0.393815794945351020f, + 0.919113851690057770f, -0.393992040061048100f, 0.919038287766422050f, + -0.394168270690784080f, 0.918962690052375630f, -0.394344486828079600f, + 0.918887058550697970f, -0.394520688466455600f, 0.918811393264170050f, + -0.394696875599433560f, 0.918735694195573550f, -0.394873048220535760f, + 0.918659961347691900f, -0.395049206323284770f, 0.918584194723309540f, + -0.395225349901203670f, 0.918508394325212250f, -0.395401478947816350f, + 0.918432560156186910f, -0.395577593456646840f, 0.918356692219021720f, + -0.395753693421220080f, 0.918280790516506130f, -0.395929778835061250f, + 0.918204855051430900f, -0.396105849691696270f, 0.918128885826588030f, + -0.396281905984651520f, 0.918052882844770380f, -0.396457947707453910f, + 0.917976846108772730f, -0.396633974853630830f, 0.917900775621390500f, + -0.396809987416710310f, 0.917824671385420570f, -0.396985985390220900f, + 0.917748533403661250f, -0.397161968767691610f, 0.917672361678911860f, + -0.397337937542652060f, 0.917596156213972950f, -0.397513891708632330f, + 0.917519917011646260f, -0.397689831259163180f, 0.917443644074735220f, + -0.397865756187775750f, 0.917367337406043930f, -0.398041666488001770f, + 0.917290997008377910f, -0.398217562153373560f, 0.917214622884544250f, + -0.398393443177423980f, 0.917138215037350710f, -0.398569309553686300f, + 0.917061773469606820f, -0.398745161275694430f, 0.916985298184123000f, + -0.398920998336982910f, 0.916908789183710990f, -0.399096820731086540f, + 0.916832246471183890f, -0.399272628451540990f, 0.916755670049355990f, + -0.399448421491882140f, 0.916679059921042700f, -0.399624199845646790f, + 0.916602416089060790f, -0.399799963506371980f, 0.916525738556228210f, + -0.399975712467595330f, 0.916449027325364150f, -0.400151446722855130f, + 0.916372282399289140f, -0.400327166265690090f, 0.916295503780824800f, + -0.400502871089639500f, 0.916218691472794220f, -0.400678561188243240f, + 0.916141845478021350f, -0.400854236555041650f, 0.916064965799331720f, + -0.401029897183575620f, 0.915988052439551950f, -0.401205543067386710f, + 0.915911105401509880f, -0.401381174200016790f, 0.915834124688034710f, + -0.401556790575008540f, 0.915757110301956720f, -0.401732392185905010f, + 0.915680062246107650f, -0.401907979026249700f, 0.915602980523320230f, + -0.402083551089586990f, 0.915525865136428530f, -0.402259108369461490f, + 0.915448716088267830f, -0.402434650859418430f, 0.915371533381674760f, + -0.402610178553003680f, 0.915294317019487050f, -0.402785691443763530f, + 0.915217067004543860f, -0.402961189525244900f, 0.915139783339685260f, + -0.403136672790995300f, 0.915062466027752760f, -0.403312141234562550f, + 0.914985115071589310f, -0.403487594849495310f, 0.914907730474038730f, + -0.403663033629342640f, 0.914830312237946200f, -0.403838457567654070f, + 0.914752860366158220f, -0.404013866657979890f, 0.914675374861522390f, + -0.404189260893870690f, 0.914597855726887790f, -0.404364640268877810f, + 0.914520302965104450f, -0.404540004776553000f, 0.914442716579023870f, + -0.404715354410448650f, 0.914365096571498560f, -0.404890689164117580f, + 0.914287442945382440f, -0.405066009031113340f, 0.914209755703530690f, + -0.405241314004989860f, 0.914132034848799460f, -0.405416604079301630f, + 0.914054280384046570f, -0.405591879247603870f, 0.913976492312130630f, + -0.405767139503452060f, 0.913898670635911680f, -0.405942384840402510f, + 0.913820815358251100f, -0.406117615252011840f, 0.913742926482011390f, + -0.406292830731837360f, 0.913665004010056350f, -0.406468031273437000f, + 0.913587047945250810f, -0.406643216870369030f, 0.913509058290461140f, + -0.406818387516192310f, 0.913431035048554720f, -0.406993543204466510f, + 0.913352978222400250f, -0.407168683928751550f, 0.913274887814867760f, + -0.407343809682607970f, 0.913196763828828200f, -0.407518920459596920f, + 0.913118606267154240f, -0.407694016253280110f, 0.913040415132719160f, + -0.407869097057219800f, 0.912962190428398210f, -0.408044162864978690f, + 0.912883932157067200f, -0.408219213670120100f, 0.912805640321603500f, + -0.408394249466208000f, 0.912727314924885900f, -0.408569270246806780f, + 0.912648955969793900f, -0.408744276005481360f, 0.912570563459208730f, + -0.408919266735797430f, 0.912492137396012650f, -0.409094242431320980f, + 0.912413677783089020f, -0.409269203085618590f, 0.912335184623322750f, + -0.409444148692257590f, 0.912256657919599760f, -0.409619079244805670f, + 0.912178097674807180f, -0.409793994736831150f, 0.912099503891833470f, + -0.409968895161902880f, 0.912020876573568340f, -0.410143780513590240f, + 0.911942215722902570f, -0.410318650785463260f, 0.911863521342728520f, + -0.410493505971092410f, 0.911784793435939430f, -0.410668346064048730f, + 0.911706032005429880f, -0.410843171057903910f, 0.911627237054095650f, + -0.411017980946230210f, 0.911548408584833990f, -0.411192775722600160f, + 0.911469546600543020f, -0.411367555380587220f, 0.911390651104122430f, + -0.411542319913765220f, 0.911311722098472780f, -0.411717069315708560f, + 0.911232759586496190f, -0.411891803579992170f, 0.911153763571095900f, + -0.412066522700191560f, 0.911074734055176360f, -0.412241226669882890f, + 0.910995671041643140f, -0.412415915482642730f, 0.910916574533403360f, + -0.412590589132048210f, 0.910837444533365010f, -0.412765247611677270f, + 0.910758281044437570f, -0.412939890915108080f, 0.910679084069531570f, + -0.413114519035919450f, 0.910599853611558930f, -0.413289131967690960f, + 0.910520589673432750f, -0.413463729704002410f, 0.910441292258067250f, + -0.413638312238434500f, 0.910361961368377990f, -0.413812879564568300f, + 0.910282597007281760f, -0.413987431675985400f, 0.910203199177696540f, + -0.414161968566268080f, 0.910123767882541680f, -0.414336490228999100f, + 0.910044303124737500f, -0.414510996657761750f, 0.909964804907205660f, + -0.414685487846140010f, 0.909885273232869160f, -0.414859963787718330f, + 0.909805708104652220f, -0.415034424476081630f, 0.909726109525480160f, + -0.415208869904815590f, 0.909646477498279540f, -0.415383300067506230f, + 0.909566812025978330f, -0.415557714957740410f, 0.909487113111505430f, + -0.415732114569105360f, 0.909407380757791260f, -0.415906498895188770f, + 0.909327614967767260f, -0.416080867929579210f, 0.909247815744366310f, + -0.416255221665865480f, 0.909167983090522380f, -0.416429560097637150f, + 0.909088117009170580f, -0.416603883218484350f, 0.909008217503247450f, + -0.416778191021997650f, 0.908928284575690640f, -0.416952483501768170f, + 0.908848318229439120f, -0.417126760651387870f, 0.908768318467432890f, + -0.417301022464448890f, 0.908688285292613360f, -0.417475268934544290f, + 0.908608218707923190f, -0.417649500055267410f, 0.908528118716306120f, + -0.417823715820212270f, 0.908447985320707250f, -0.417997916222973550f, + 0.908367818524072890f, -0.418172101257146320f, 0.908287618329350450f, + -0.418346270916326260f, 0.908207384739488700f, -0.418520425194109700f, + 0.908127117757437600f, -0.418694564084093560f, 0.908046817386148340f, + -0.418868687579875050f, 0.907966483628573350f, -0.419042795675052370f, + 0.907886116487666260f, -0.419216888363223910f, 0.907805715966381930f, + -0.419390965637988890f, 0.907725282067676440f, -0.419565027492946880f, + 0.907644814794507200f, -0.419739073921698180f, 0.907564314149832630f, + -0.419913104917843620f, 0.907483780136612570f, -0.420087120474984530f, + 0.907403212757808110f, -0.420261120586722880f, 0.907322612016381420f, + -0.420435105246661170f, 0.907241977915295820f, -0.420609074448402510f, + 0.907161310457516250f, -0.420783028185550520f, 0.907080609646008450f, + -0.420956966451709440f, 0.906999875483739610f, -0.421130889240483970f, + 0.906919107973678140f, -0.421304796545479640f, 0.906838307118793430f, + -0.421478688360302280f, 0.906757472922056550f, -0.421652564678558330f, + 0.906676605386439460f, -0.421826425493854910f, 0.906595704514915330f, + -0.422000270799799680f, 0.906514770310458800f, -0.422174100590000770f, + 0.906433802776045460f, -0.422347914858067050f, 0.906352801914652400f, + -0.422521713597607820f, 0.906271767729257660f, -0.422695496802232950f, + 0.906190700222840650f, -0.422869264465553060f, 0.906109599398381980f, + -0.423043016581179040f, 0.906028465258863600f, -0.423216753142722610f, + 0.905947297807268460f, -0.423390474143796050f, 0.905866097046580940f, + -0.423564179578011960f, 0.905784862979786550f, -0.423737869438983840f, + 0.905703595609872010f, -0.423911543720325580f, 0.905622294939825270f, + -0.424085202415651560f, 0.905540960972635590f, -0.424258845518576950f, + 0.905459593711293250f, -0.424432473022717420f, 0.905378193158790090f, + -0.424606084921689110f, 0.905296759318118820f, -0.424779681209108810f, + 0.905215292192273590f, -0.424953261878593890f, 0.905133791784249690f, + -0.425126826923762360f, 0.905052258097043590f, -0.425300376338232640f, + 0.904970691133653250f, -0.425473910115623800f, 0.904889090897077470f, + -0.425647428249555590f, 0.904807457390316540f, -0.425820930733648240f, + 0.904725790616371930f, -0.425994417561522400f, 0.904644090578246240f, + -0.426167888726799620f, 0.904562357278943300f, -0.426341344223101830f, + 0.904480590721468250f, -0.426514784044051520f, 0.904398790908827350f, + -0.426688208183271860f, 0.904316957844028320f, -0.426861616634386430f, + 0.904235091530079750f, -0.427035009391019680f, 0.904153191969991780f, + -0.427208386446796320f, 0.904071259166775440f, -0.427381747795341770f, + 0.903989293123443340f, -0.427555093430282080f, 0.903907293843009050f, + -0.427728423345243800f, 0.903825261328487510f, -0.427901737533854080f, + 0.903743195582894620f, -0.428075035989740730f, 0.903661096609247980f, + -0.428248318706531960f, 0.903578964410566070f, -0.428421585677856650f, + 0.903496798989868450f, -0.428594836897344400f, 0.903414600350176290f, + -0.428768072358625070f, 0.903332368494511820f, -0.428941292055329490f, + 0.903250103425898400f, -0.429114495981088750f, 0.903167805147360720f, + -0.429287684129534610f, 0.903085473661924600f, -0.429460856494299490f, + 0.903003108972617150f, -0.429634013069016380f, 0.902920711082466740f, + -0.429807153847318710f, 0.902838279994502830f, -0.429980278822840620f, + 0.902755815711756120f, -0.430153387989216870f, 0.902673318237258830f, + -0.430326481340082610f, 0.902590787574043870f, -0.430499558869073820f, + 0.902508223725145940f, -0.430672620569826800f, 0.902425626693600380f, + -0.430845666435978660f, 0.902342996482444200f, -0.431018696461167030f, + 0.902260333094715540f, -0.431191710639029950f, 0.902177636533453620f, + -0.431364708963206330f, 0.902094906801698900f, -0.431537691427335500f, + 0.902012143902493180f, -0.431710658025057260f, 0.901929347838879460f, + -0.431883608750012250f, 0.901846518613901750f, -0.432056543595841500f, + 0.901763656230605730f, -0.432229462556186720f, 0.901680760692037730f, + -0.432402365624690140f, 0.901597832001245660f, -0.432575252794994650f, + 0.901514870161278740f, -0.432748124060743700f, 0.901431875175186970f, + -0.432920979415581280f, 0.901348847046022030f, -0.433093818853151960f, + 0.901265785776836580f, -0.433266642367100940f, 0.901182691370684520f, + -0.433439449951074090f, 0.901099563830620950f, -0.433612241598717580f, + 0.901016403159702330f, -0.433785017303678520f, 0.900933209360986200f, + -0.433957777059604420f, 0.900849982437531450f, -0.434130520860143310f, + 0.900766722392397860f, -0.434303248698943990f, 0.900683429228646970f, + -0.434475960569655650f, 0.900600102949340900f, -0.434648656465928320f, + 0.900516743557543520f, -0.434821336381412290f, 0.900433351056319830f, + -0.434994000309758710f, 0.900349925448735600f, -0.435166648244619260f, + 0.900266466737858480f, -0.435339280179646070f, 0.900182974926756810f, + -0.435511896108492000f, 0.900099450018500450f, -0.435684496024810460f, + 0.900015892016160280f, -0.435857079922255470f, 0.899932300922808510f, + -0.436029647794481560f, 0.899848676741518580f, -0.436202199635143950f, + 0.899765019475365140f, -0.436374735437898340f, 0.899681329127423930f, + -0.436547255196401200f, 0.899597605700772180f, -0.436719758904309360f, + 0.899513849198487980f, -0.436892246555280360f, 0.899430059623650860f, + -0.437064718142972370f, 0.899346236979341570f, -0.437237173661044090f, + 0.899262381268642000f, -0.437409613103154790f, 0.899178492494635330f, + -0.437582036462964400f, 0.899094570660405770f, -0.437754443734133410f, + 0.899010615769039070f, -0.437926834910322860f, 0.898926627823621870f, + -0.438099209985194470f, 0.898842606827242370f, -0.438271568952410430f, + 0.898758552782989440f, -0.438443911805633690f, 0.898674465693953820f, + -0.438616238538527660f, 0.898590345563227030f, -0.438788549144756290f, + 0.898506192393901950f, -0.438960843617984320f, 0.898422006189072530f, + -0.439133121951876930f, 0.898337786951834310f, -0.439305384140099950f, + 0.898253534685283570f, -0.439477630176319800f, 0.898169249392518080f, + -0.439649860054203480f, 0.898084931076636780f, -0.439822073767418500f, + 0.898000579740739880f, -0.439994271309633260f, 0.897916195387928660f, + -0.440166452674516320f, 0.897831778021305650f, -0.440338617855737250f, + 0.897747327643974690f, -0.440510766846965940f, 0.897662844259040860f, + -0.440682899641872900f, 0.897578327869610230f, -0.440855016234129430f, + 0.897493778478790310f, -0.441027116617407230f, 0.897409196089689720f, + -0.441199200785378660f, 0.897324580705418320f, -0.441371268731716670f, + 0.897239932329087160f, -0.441543320450094870f, 0.897155250963808550f, + -0.441715355934187310f, 0.897070536612695870f, -0.441887375177668850f, + 0.896985789278863970f, -0.442059378174214700f, 0.896901008965428790f, + -0.442231364917500980f, 0.896816195675507300f, -0.442403335401204080f, + 0.896731349412217880f, -0.442575289619001170f, 0.896646470178680150f, + -0.442747227564570020f, 0.896561557978014960f, -0.442919149231588980f, + 0.896476612813344120f, -0.443091054613736880f, 0.896391634687790820f, + -0.443262943704693320f, 0.896306623604479550f, -0.443434816498138480f, + 0.896221579566536030f, -0.443606672987752970f, 0.896136502577086770f, + -0.443778513167218220f, 0.896051392639260150f, -0.443950337030216140f, + 0.895966249756185220f, -0.444122144570429200f, 0.895881073930992370f, + -0.444293935781540580f, 0.895795865166813530f, -0.444465710657234000f, + 0.895710623466781320f, -0.444637469191193790f, 0.895625348834030110f, + -0.444809211377104880f, 0.895540041271694950f, -0.444980937208652730f, + 0.895454700782912450f, -0.445152646679523640f, 0.895369327370820310f, + -0.445324339783404190f, 0.895283921038557580f, -0.445496016513981740f, + 0.895198481789264200f, -0.445667676864944300f, 0.895113009626081760f, + -0.445839320829980290f, 0.895027504552152630f, -0.446010948402778940f, + 0.894941966570620750f, -0.446182559577030070f, 0.894856395684631050f, + -0.446354154346423840f, 0.894770791897329550f, -0.446525732704651350f, + 0.894685155211863980f, -0.446697294645404090f, 0.894599485631382700f, + -0.446868840162374160f, 0.894513783159035620f, -0.447040369249254440f, + 0.894428047797973800f, -0.447211881899738320f, 0.894342279551349480f, + -0.447383378107519600f, 0.894256478422316040f, -0.447554857866293010f, + 0.894170644414028270f, -0.447726321169753580f, 0.894084777529641990f, + -0.447897768011597310f, 0.893998877772314240f, -0.448069198385520400f, + 0.893912945145203250f, -0.448240612285219890f, 0.893826979651468620f, + -0.448412009704393430f, 0.893740981294271040f, -0.448583390636739240f, + 0.893654950076772540f, -0.448754755075955970f, 0.893568886002135910f, + -0.448926103015743260f, 0.893482789073525850f, -0.449097434449801050f, + 0.893396659294107720f, -0.449268749371829920f, 0.893310496667048200f, + -0.449440047775531150f, 0.893224301195515320f, -0.449611329654606540f, + 0.893138072882678320f, -0.449782595002758690f, 0.893051811731707450f, + -0.449953843813690520f, 0.892965517745774370f, -0.450125076081105690f, + 0.892879190928051680f, -0.450296291798708610f, 0.892792831281713610f, + -0.450467490960204110f, 0.892706438809935390f, -0.450638673559297600f, + 0.892620013515893150f, -0.450809839589695280f, 0.892533555402764580f, + -0.450980989045103860f, 0.892447064473728680f, -0.451152121919230600f, + 0.892360540731965360f, -0.451323238205783520f, 0.892273984180655840f, + -0.451494337898471100f, 0.892187394822982480f, -0.451665420991002490f, + 0.892100772662129060f, -0.451836487477087490f, 0.892014117701280470f, + -0.452007537350436420f, 0.891927429943622510f, -0.452178570604760350f, + 0.891840709392342720f, -0.452349587233770890f, 0.891753956050629460f, + -0.452520587231180050f, 0.891667169921672280f, -0.452691570590700920f, + 0.891580351008662290f, -0.452862537306046750f, 0.891493499314791380f, + -0.453033487370931580f, 0.891406614843252900f, -0.453204420779070190f, + 0.891319697597241390f, -0.453375337524177750f, 0.891232747579952520f, + -0.453546237599970090f, 0.891145764794583180f, -0.453717121000163870f, + 0.891058749244331590f, -0.453887987718476050f, 0.890971700932396860f, + -0.454058837748624430f, 0.890884619861979530f, -0.454229671084327320f, + 0.890797506036281490f, -0.454400487719303580f, 0.890710359458505630f, + -0.454571287647272950f, 0.890623180131855930f, -0.454742070861955450f, + 0.890535968059537830f, -0.454912837357071940f, 0.890448723244757880f, + -0.455083587126343840f, 0.890361445690723840f, -0.455254320163493100f, + 0.890274135400644600f, -0.455425036462242360f, 0.890186792377730240f, + -0.455595736016314980f, 0.890099416625192320f, -0.455766418819434640f, + 0.890012008146243260f, -0.455937084865326030f, 0.889924566944096720f, + -0.456107734147714110f, 0.889837093021967900f, -0.456278366660324620f, + 0.889749586383072780f, -0.456448982396883920f, 0.889662047030628900f, + -0.456619581351118910f, 0.889574474967854580f, -0.456790163516757160f, + 0.889486870197969900f, -0.456960728887526980f, 0.889399232724195520f, + -0.457131277457156980f, 0.889311562549753850f, -0.457301809219376630f, + 0.889223859677868210f, -0.457472324167916060f, 0.889136124111763240f, + -0.457642822296505770f, 0.889048355854664570f, -0.457813303598877170f, + 0.888960554909799310f, -0.457983768068762120f, 0.888872721280395630f, + -0.458154215699893060f, 0.888784854969682850f, -0.458324646486003240f, + 0.888696955980891600f, -0.458495060420826270f, 0.888609024317253860f, + -0.458665457498096560f, 0.888521059982002260f, -0.458835837711549120f, + 0.888433062978371320f, -0.459006201054919630f, 0.888345033309596350f, + -0.459176547521944090f, 0.888256970978913870f, -0.459346877106359630f, + 0.888168875989561730f, -0.459517189801903480f, 0.888080748344778900f, + -0.459687485602313870f, 0.887992588047805560f, -0.459857764501329540f, + 0.887904395101883240f, -0.460028026492689650f, 0.887816169510254440f, + -0.460198271570134320f, 0.887727911276163020f, -0.460368499727404010f, + 0.887639620402853930f, -0.460538710958240010f, 0.887551296893573370f, + -0.460708905256384080f, 0.887462940751568840f, -0.460879082615578690f, + 0.887374551980088850f, -0.461049243029566900f, 0.887286130582383150f, + -0.461219386492092380f, 0.887197676561702900f, -0.461389512996899450f, + 0.887109189921300170f, -0.461559622537733080f, 0.887020670664428360f, + -0.461729715108338770f, 0.886932118794342190f, -0.461899790702462730f, + 0.886843534314297410f, -0.462069849313851750f, 0.886754917227550840f, + -0.462239890936253340f, 0.886666267537361000f, -0.462409915563415430f, + 0.886577585246987040f, -0.462579923189086810f, 0.886488870359689600f, + -0.462749913807016740f, 0.886400122878730600f, -0.462919887410955080f, + 0.886311342807372780f, -0.463089843994652530f, 0.886222530148880640f, + -0.463259783551860150f, 0.886133684906519340f, -0.463429706076329830f, + 0.886044807083555600f, -0.463599611561814010f, 0.885955896683257030f, + -0.463769500002065630f, 0.885866953708892790f, -0.463939371390838520f, + 0.885777978163732940f, -0.464109225721886950f, 0.885688970051048960f, + -0.464279062988965760f, 0.885599929374113360f, -0.464448883185830660f, + 0.885510856136199950f, -0.464618686306237820f, 0.885421750340583680f, + -0.464788472343943990f, 0.885332611990540590f, -0.464958241292706690f, + 0.885243441089348270f, -0.465127993146283950f, 0.885154237640285110f, + -0.465297727898434600f, 0.885065001646630930f, -0.465467445542917800f, + 0.884975733111666660f, -0.465637146073493660f, 0.884886432038674560f, + -0.465806829483922710f, 0.884797098430937790f, -0.465976495767966180f, + 0.884707732291741040f, -0.466146144919385890f, 0.884618333624369920f, + -0.466315776931944430f, 0.884528902432111460f, -0.466485391799404900f, + 0.884439438718253810f, -0.466654989515530920f, 0.884349942486086120f, + -0.466824570074086950f, 0.884260413738899190f, -0.466994133468838000f, + 0.884170852479984500f, -0.467163679693549770f, 0.884081258712634990f, + -0.467333208741988420f, 0.883991632440144890f, -0.467502720607920920f, + 0.883901973665809470f, -0.467672215285114770f, 0.883812282392925090f, + -0.467841692767338170f, 0.883722558624789660f, -0.468011153048359830f, + 0.883632802364701870f, -0.468180596121949290f, 0.883543013615961880f, + -0.468350021981876530f, 0.883453192381870920f, -0.468519430621912310f, + 0.883363338665731580f, -0.468688822035827900f, 0.883273452470847430f, + -0.468858196217395330f, 0.883183533800523390f, -0.469027553160387130f, + 0.883093582658065370f, -0.469196892858576580f, 0.883003599046780830f, + -0.469366215305737520f, 0.882913582969978020f, -0.469535520495644450f, + 0.882823534430966620f, -0.469704808422072460f, 0.882733453433057650f, + -0.469874079078797360f, 0.882643339979562790f, -0.470043332459595620f, + 0.882553194073795510f, -0.470212568558244170f, 0.882463015719070150f, + -0.470381787368520650f, 0.882372804918702290f, -0.470550988884203550f, + 0.882282561676008710f, -0.470720173099071600f, 0.882192285994307430f, + -0.470889340006904520f, 0.882101977876917580f, -0.471058489601482500f, + 0.882011637327159590f, -0.471227621876586340f, 0.881921264348355050f, + -0.471396736825997640f, 0.881830858943826620f, -0.471565834443498420f, + 0.881740421116898320f, -0.471734914722871430f, 0.881649950870895260f, + -0.471903977657900210f, 0.881559448209143780f, -0.472073023242368660f, + 0.881468913134971440f, -0.472242051470061490f, 0.881378345651706920f, + -0.472411062334764040f, 0.881287745762680100f, -0.472580055830262250f, + 0.881197113471222090f, -0.472749031950342790f, 0.881106448780665130f, + -0.472917990688792760f, 0.881015751694342870f, -0.473086932039400050f, + 0.880925022215589880f, -0.473255855995953320f, 0.880834260347742040f, + -0.473424762552241530f, 0.880743466094136340f, -0.473593651702054530f, + 0.880652639458111010f, -0.473762523439182850f, 0.880561780443005700f, + -0.473931377757417450f, 0.880470889052160750f, -0.474100214650549970f, + 0.880379965288918150f, -0.474269034112372980f, 0.880289009156621010f, + -0.474437836136679230f, 0.880198020658613190f, -0.474606620717262560f, + 0.880106999798240360f, -0.474775387847917120f, 0.880015946578849070f, + -0.474944137522437800f, 0.879924861003786860f, -0.475112869734620300f, + 0.879833743076402940f, -0.475281584478260740f, 0.879742592800047410f, + -0.475450281747155870f, 0.879651410178071580f, -0.475618961535103300f, + 0.879560195213827890f, -0.475787623835901120f, 0.879468947910670210f, + -0.475956268643348060f, 0.879377668271953290f, -0.476124895951243580f, + 0.879286356301033250f, -0.476293505753387690f, 0.879195012001267480f, + -0.476462098043581190f, 0.879103635376014330f, -0.476630672815625320f, + 0.879012226428633530f, -0.476799230063322090f, 0.878920785162485840f, + -0.476967769780474170f, 0.878829311580933360f, -0.477136291960884810f, + 0.878737805687339390f, -0.477304796598357890f, 0.878646267485068130f, + -0.477473283686698060f, 0.878554696977485450f, -0.477641753219710470f, + 0.878463094167957870f, -0.477810205191200990f, 0.878371459059853480f, + -0.477978639594976160f, 0.878279791656541580f, -0.478147056424843010f, + 0.878188091961392250f, -0.478315455674609480f, 0.878096359977777130f, + -0.478483837338083970f, 0.878004595709069080f, -0.478652201409075500f, + 0.877912799158641840f, -0.478820547881393890f, 0.877820970329870500f, + -0.478988876748849490f, 0.877729109226131570f, -0.479157188005253310f, + 0.877637215850802230f, -0.479325481644417070f, 0.877545290207261350f, + -0.479493757660153010f, 0.877453332298888560f, -0.479662016046274180f, + 0.877361342129065140f, -0.479830256796594190f, 0.877269319701173170f, + -0.479998479904927280f, 0.877177265018595940f, -0.480166685365088390f, + 0.877085178084718420f, -0.480334873170893020f, 0.876993058902925890f, + -0.480503043316157510f, 0.876900907476605650f, -0.480671195794698640f, + 0.876808723809145650f, -0.480839330600333960f, 0.876716507903935400f, + -0.481007447726881590f, 0.876624259764365310f, -0.481175547168160300f, + 0.876531979393827100f, -0.481343628917989710f, 0.876439666795713610f, + -0.481511692970189860f, 0.876347321973419020f, -0.481679739318581490f, + 0.876254944930338510f, -0.481847767956986030f, 0.876162535669868460f, + -0.482015778879225590f, 0.876070094195406600f, -0.482183772079122720f, + 0.875977620510351770f, -0.482351747550500980f, 0.875885114618103810f, + -0.482519705287184350f, 0.875792576522063880f, -0.482687645282997460f, + 0.875700006225634600f, -0.482855567531765670f, 0.875607403732219350f, + -0.483023472027314880f, 0.875514769045222850f, -0.483191358763471860f, + 0.875422102168050940f, -0.483359227734063810f, 0.875329403104110890f, + -0.483527078932918740f, 0.875236671856810870f, -0.483694912353865140f, + 0.875143908429560360f, -0.483862727990732270f, 0.875051112825769970f, + -0.484030525837350010f, 0.874958285048851650f, -0.484198305887549030f, + 0.874865425102218320f, -0.484366068135160420f, 0.874772532989284150f, + -0.484533812574016180f, 0.874679608713464510f, -0.484701539197948670f, + 0.874586652278176110f, -0.484869248000791060f, 0.874493663686836560f, + -0.485036938976377290f, 0.874400642942864790f, -0.485204612118541820f, + 0.874307590049680950f, -0.485372267421119770f, 0.874214505010706300f, + -0.485539904877946960f, 0.874121387829363330f, -0.485707524482859750f, + 0.874028238509075740f, -0.485875126229695250f, 0.873935057053268240f, + -0.486042710112291330f, 0.873841843465366860f, -0.486210276124486420f, + 0.873748597748798870f, -0.486377824260119440f, 0.873655319906992630f, + -0.486545354513030270f, 0.873562009943377850f, -0.486712866877059170f, + 0.873468667861384880f, -0.486880361346047340f, 0.873375293664446000f, + -0.487047837913836380f, 0.873281887355994210f, -0.487215296574268760f, + 0.873188448939463790f, -0.487382737321187360f, 0.873094978418290090f, + -0.487550160148436000f, 0.873001475795909920f, -0.487717565049858800f, + 0.872907941075761080f, -0.487884952019301040f, 0.872814374261282390f, + -0.488052321050608250f, 0.872720775355914300f, -0.488219672137626790f, + 0.872627144363097960f, -0.488387005274203530f, 0.872533481286276170f, + -0.488554320454186180f, 0.872439786128892280f, -0.488721617671423080f, + 0.872346058894391540f, -0.488888896919763170f, 0.872252299586219860f, + -0.489056158193056030f, 0.872158508207824480f, -0.489223401485151980f, + 0.872064684762653860f, -0.489390626789901920f, 0.871970829254157810f, + -0.489557834101157440f, 0.871876941685786890f, -0.489725023412770910f, + 0.871783022060993120f, -0.489892194718595190f, 0.871689070383229740f, + -0.490059348012483850f, 0.871595086655950980f, -0.490226483288291160f, + 0.871501070882612530f, -0.490393600539871970f, 0.871407023066670950f, + -0.490560699761082020f, 0.871312943211584030f, -0.490727780945777400f, + 0.871218831320811020f, -0.490894844087815090f, 0.871124687397811900f, + -0.491061889181052650f, 0.871030511446048260f, -0.491228916219348280f, + 0.870936303468982760f, -0.491395925196560780f, 0.870842063470078980f, + -0.491562916106549900f, 0.870747791452801790f, -0.491729888943175760f, + 0.870653487420617430f, -0.491896843700299290f, 0.870559151376993250f, + -0.492063780371782000f, 0.870464783325397670f, -0.492230698951486020f, + 0.870370383269300270f, -0.492397599433274380f, 0.870275951212171940f, + -0.492564481811010590f, 0.870181487157484560f, -0.492731346078558840f, + 0.870086991108711460f, -0.492898192229784040f, 0.869992463069326870f, + -0.493065020258551700f, 0.869897903042806340f, -0.493231830158727900f, + 0.869803311032626650f, -0.493398621924179770f, 0.869708687042265670f, + -0.493565395548774770f, 0.869614031075202300f, -0.493732151026381020f, + 0.869519343134916860f, -0.493898888350867480f, 0.869424623224890890f, + -0.494065607516103570f, 0.869329871348606840f, -0.494232308515959670f, + 0.869235087509548370f, -0.494398991344306650f, 0.869140271711200560f, + -0.494565655995015950f, 0.869045423957049530f, -0.494732302461959870f, + 0.868950544250582380f, -0.494898930739011260f, 0.868855632595287860f, + -0.495065540820043560f, 0.868760688994655310f, -0.495232132698931180f, + 0.868665713452175690f, -0.495398706369549020f, 0.868570705971340900f, + -0.495565261825772540f, 0.868475666555644120f, -0.495731799061477960f, + 0.868380595208579800f, -0.495898318070542190f, 0.868285491933643350f, + -0.496064818846842890f, 0.868190356734331310f, -0.496231301384258250f, + 0.868095189614141670f, -0.496397765676667160f, 0.867999990576573510f, + -0.496564211717949290f, 0.867904759625126920f, -0.496730639501984760f, + 0.867809496763303320f, -0.496897049022654470f, 0.867714201994605140f, + -0.497063440273840250f, 0.867618875322536230f, -0.497229813249424220f, + 0.867523516750601460f, -0.497396167943289280f, 0.867428126282306920f, + -0.497562504349319150f, 0.867332703921159800f, -0.497728822461397940f, + 0.867237249670668400f, -0.497895122273410870f, 0.867141763534342470f, + -0.498061403779243410f, 0.867046245515692650f, -0.498227666972781870f, + 0.866950695618230900f, -0.498393911847913210f, 0.866855113845470430f, + -0.498560138398525140f, 0.866759500200925400f, -0.498726346618505900f, + 0.866663854688111130f, -0.498892536501744590f, 0.866568177310544470f, + -0.499058708042130870f, 0.866472468071743050f, -0.499224861233555080f, + 0.866376726975225830f, -0.499390996069908170f, 0.866280954024512990f, + -0.499557112545081840f, 0.866185149223125840f, -0.499723210652968540f, + 0.866089312574586770f, -0.499889290387461330f, 0.865993444082419520f, + -0.500055351742453860f, 0.865897543750148820f, -0.500221394711840680f, + 0.865801611581300760f, -0.500387419289516580f, 0.865705647579402380f, + -0.500553425469377420f, 0.865609651747981990f, -0.500719413245319880f, + 0.865513624090569090f, -0.500885382611240710f, 0.865417564610694410f, + -0.501051333561038040f, 0.865321473311889800f, -0.501217266088609950f, + 0.865225350197688200f, -0.501383180187855770f, 0.865129195271623800f, + -0.501549075852675390f, 0.865033008537231860f, -0.501714953076969120f, + 0.864936789998049020f, -0.501880811854638290f, 0.864840539657612870f, + -0.502046652179584660f, 0.864744257519462380f, -0.502212474045710790f, + 0.864647943587137480f, -0.502378277446919760f, 0.864551597864179340f, + -0.502544062377115690f, 0.864455220354130360f, -0.502709828830202990f, + 0.864358811060534030f, -0.502875576800086990f, 0.864262369986934950f, + -0.503041306280673450f, 0.864165897136879300f, -0.503207017265868920f, + 0.864069392513913790f, -0.503372709749581040f, 0.863972856121586810f, + -0.503538383725717580f, 0.863876287963447510f, -0.503704039188187070f, + 0.863779688043046720f, -0.503869676130898950f, 0.863683056363935830f, + -0.504035294547763190f, 0.863586392929668100f, -0.504200894432690340f, + 0.863489697743797140f, -0.504366475779592040f, 0.863392970809878420f, + -0.504532038582380270f, 0.863296212131468230f, -0.504697582834967570f, + 0.863199421712124160f, -0.504863108531267590f, 0.863102599555404910f, + -0.505028615665194080f, 0.863005745664870320f, -0.505194104230662240f, + 0.862908860044081400f, -0.505359574221587280f, 0.862811942696600330f, + -0.505525025631885390f, 0.862714993625990690f, -0.505690458455473450f, + 0.862618012835816740f, -0.505855872686268860f, 0.862521000329644520f, + -0.506021268318189720f, 0.862423956111040610f, -0.506186645345155230f, + 0.862326880183573060f, -0.506352003761084800f, 0.862229772550811240f, + -0.506517343559898530f, 0.862132633216325380f, -0.506682664735517600f, + 0.862035462183687210f, -0.506847967281863210f, 0.861938259456469290f, + -0.507013251192858230f, 0.861841025038245330f, -0.507178516462425180f, + 0.861743758932590700f, -0.507343763084487920f, 0.861646461143081300f, + -0.507508991052970870f, 0.861549131673294720f, -0.507674200361798890f, + 0.861451770526809320f, -0.507839391004897720f, 0.861354377707204910f, + -0.508004562976194010f, 0.861256953218062170f, -0.508169716269614600f, + 0.861159497062963350f, -0.508334850879087360f, 0.861062009245491480f, + -0.508499966798540930f, 0.860964489769231010f, -0.508665064021904030f, + 0.860866938637767310f, -0.508830142543106990f, 0.860769355854687170f, + -0.508995202356080090f, 0.860671741423578380f, -0.509160243454754640f, + 0.860574095348029980f, -0.509325265833062480f, 0.860476417631632070f, + -0.509490269484936360f, 0.860378708277976130f, -0.509655254404309250f, + 0.860280967290654510f, -0.509820220585115450f, 0.860183194673260990f, + -0.509985168021289460f, 0.860085390429390140f, -0.510150096706766810f, + 0.859987554562638200f, -0.510315006635483240f, 0.859889687076602290f, + -0.510479897801375700f, 0.859791787974880650f, -0.510644770198381610f, + 0.859693857261072610f, -0.510809623820439040f, 0.859595894938779080f, + -0.510974458661486830f, 0.859497901011601730f, -0.511139274715464390f, + 0.859399875483143450f, -0.511304071976312000f, 0.859301818357008470f, + -0.511468850437970300f, 0.859203729636801920f, -0.511633610094381240f, + 0.859105609326130450f, -0.511798350939486890f, 0.859007457428601520f, + -0.511963072967230200f, 0.858909273947823900f, -0.512127776171554690f, + 0.858811058887407610f, -0.512292460546404870f, 0.858712812250963520f, + -0.512457126085725690f, 0.858614534042104190f, -0.512621772783462990f, + 0.858516224264442740f, -0.512786400633562960f, 0.858417882921593930f, + -0.512951009629972980f, 0.858319510017173440f, -0.513115599766640560f, + 0.858221105554798250f, -0.513280171037514220f, 0.858122669538086140f, + -0.513444723436543460f, 0.858024201970656540f, -0.513609256957677780f, + 0.857925702856129790f, -0.513773771594868030f, 0.857827172198127430f, + -0.513938267342065380f, 0.857728610000272120f, -0.514102744193221660f, + 0.857630016266187620f, -0.514267202142289710f, 0.857531390999499150f, + -0.514431641183222820f, 0.857432734203832700f, -0.514596061309975040f, + 0.857334045882815590f, -0.514760462516501200f, 0.857235326040076460f, + -0.514924844796756490f, 0.857136574679244980f, -0.515089208144697160f, + 0.857037791803951680f, -0.515253552554280180f, 0.856938977417828760f, + -0.515417878019462930f, 0.856840131524509220f, -0.515582184534203790f, + 0.856741254127627470f, -0.515746472092461380f, 0.856642345230818840f, + -0.515910740688195650f, 0.856543404837719960f, -0.516074990315366630f, + 0.856444432951968590f, -0.516239220967935510f, 0.856345429577203610f, + -0.516403432639863990f, 0.856246394717065210f, -0.516567625325114350f, + 0.856147328375194470f, -0.516731799017649870f, 0.856048230555233940f, + -0.516895953711434150f, 0.855949101260826910f, -0.517060089400431910f, + 0.855849940495618240f, -0.517224206078608310f, 0.855750748263253920f, + -0.517388303739929060f, 0.855651524567380690f, -0.517552382378360880f, + 0.855552269411646860f, -0.517716441987871150f, 0.855452982799701830f, + -0.517880482562427690f, 0.855353664735196030f, -0.518044504095999340f, + 0.855254315221780970f, -0.518208506582555460f, 0.855154934263109620f, + -0.518372490016066110f, 0.855055521862835950f, -0.518536454390502220f, + 0.854956078024614930f, -0.518700399699834950f, 0.854856602752102850f, + -0.518864325938036890f, 0.854757096048957220f, -0.519028233099080860f, + 0.854657557918836460f, -0.519192121176940250f, 0.854557988365400530f, + -0.519355990165589640f, 0.854458387392310170f, -0.519519840059003760f, + 0.854358755003227440f, -0.519683670851158410f, 0.854259091201815530f, + -0.519847482536030190f, 0.854159395991738850f, -0.520011275107596040f, + 0.854059669376662780f, -0.520175048559833760f, 0.853959911360254180f, + -0.520338802886721960f, 0.853860121946180770f, -0.520502538082239670f, + 0.853760301138111410f, -0.520666254140367160f, 0.853660448939716380f, + -0.520829951055084670f, 0.853560565354666840f, -0.520993628820373920f, + 0.853460650386635320f, -0.521157287430216610f, 0.853360704039295430f, + -0.521320926878595660f, 0.853260726316321880f, -0.521484547159494330f, + 0.853160717221390420f, -0.521648148266897090f, 0.853060676758178320f, + -0.521811730194788550f, 0.852960604930363630f, -0.521975292937154390f, + 0.852860501741625750f, -0.522138836487980760f, 0.852760367195645300f, + -0.522302360841254590f, 0.852660201296103760f, -0.522465865990963780f, + 0.852560004046684080f, -0.522629351931096610f, 0.852459775451070100f, + -0.522792818655642090f, 0.852359515512947090f, -0.522956266158590140f, + 0.852259224236001090f, -0.523119694433931250f, 0.852158901623919830f, + -0.523283103475656430f, 0.852058547680391690f, -0.523446493277757830f, + 0.851958162409106380f, -0.523609863834227920f, 0.851857745813754840f, + -0.523773215139060170f, 0.851757297898029120f, -0.523936547186248600f, + 0.851656818665622370f, -0.524099859969787700f, 0.851556308120228980f, + -0.524263153483673360f, 0.851455766265544310f, -0.524426427721901400f, + 0.851355193105265200f, -0.524589682678468950f, 0.851254588643089120f, + -0.524752918347373360f, 0.851153952882715340f, -0.524916134722613000f, + 0.851053285827843790f, -0.525079331798186780f, 0.850952587482175730f, + -0.525242509568094710f, 0.850851857849413530f, -0.525405668026336930f, + 0.850751096933260790f, -0.525568807166914680f, 0.850650304737422090f, + -0.525731926983829760f, 0.850549481265603480f, -0.525895027471084630f, + 0.850448626521511760f, -0.526058108622682760f, 0.850347740508854980f, + -0.526221170432628060f, 0.850246823231342710f, -0.526384212894925100f, + 0.850145874692685210f, -0.526547236003579440f, 0.850044894896594180f, + -0.526710239752597010f, 0.849943883846782210f, -0.526873224135984590f, + 0.849842841546963320f, -0.527036189147750080f, 0.849741768000852550f, + -0.527199134781901280f, 0.849640663212165910f, -0.527362061032447540f, + 0.849539527184620890f, -0.527524967893398200f, 0.849438359921936060f, + -0.527687855358763720f, 0.849337161427830780f, -0.527850723422555230f, + 0.849235931706025960f, -0.528013572078784630f, 0.849134670760243630f, + -0.528176401321464370f, 0.849033378594206800f, -0.528339211144607690f, + 0.848932055211639610f, -0.528502001542228480f, 0.848830700616267530f, + -0.528664772508341320f, 0.848729314811817130f, -0.528827524036961870f, + 0.848627897802015860f, -0.528990256122106040f, 0.848526449590592650f, + -0.529152968757790610f, 0.848424970181277600f, -0.529315661938033260f, + 0.848323459577801640f, -0.529478335656851980f, 0.848221917783896990f, + -0.529640989908265910f, 0.848120344803297230f, -0.529803624686294610f, + 0.848018740639736810f, -0.529966239984958620f, 0.847917105296951410f, + -0.530128835798278960f, 0.847815438778677930f, -0.530291412120277310f, + 0.847713741088654380f, -0.530453968944976320f, 0.847612012230619660f, + -0.530616506266399330f, 0.847510252208314330f, -0.530779024078570140f, + 0.847408461025479730f, -0.530941522375513620f, 0.847306638685858320f, + -0.531104001151255000f, 0.847204785193194090f, -0.531266460399820390f, + 0.847102900551231500f, -0.531428900115236800f, 0.847000984763716880f, + -0.531591320291531670f, 0.846899037834397240f, -0.531753720922733320f, + 0.846797059767020910f, -0.531916102002870650f, 0.846695050565337450f, + -0.532078463525973540f, 0.846593010233097190f, -0.532240805486072220f, + 0.846490938774052130f, -0.532403127877197900f, 0.846388836191954930f, + -0.532565430693382580f, 0.846286702490559710f, -0.532727713928658810f, + 0.846184537673621560f, -0.532889977577059800f, 0.846082341744897050f, + -0.533052221632619450f, 0.845980114708143270f, -0.533214446089372960f, + 0.845877856567119000f, -0.533376650941355330f, 0.845775567325584010f, + -0.533538836182603120f, 0.845673246987299070f, -0.533701001807152960f, + 0.845570895556026270f, -0.533863147809042650f, 0.845468513035528830f, + -0.534025274182310380f, 0.845366099429570970f, -0.534187380920995380f, + 0.845263654741918220f, -0.534349468019137520f, 0.845161178976337140f, + -0.534511535470777120f, 0.845058672136595470f, -0.534673583269955510f, + 0.844956134226462210f, -0.534835611410714560f, 0.844853565249707120f, + -0.534997619887097150f, 0.844750965210101510f, -0.535159608693146600f, + 0.844648334111417820f, -0.535321577822907120f, 0.844545671957429240f, + -0.535483527270423370f, 0.844442978751910660f, -0.535645457029741090f, + 0.844340254498637590f, -0.535807367094906390f, 0.844237499201387020f, + -0.535969257459966710f, 0.844134712863936930f, -0.536131128118969460f, + 0.844031895490066410f, -0.536292979065963180f, 0.843929047083555870f, + -0.536454810294997090f, 0.843826167648186740f, -0.536616621800121040f, + 0.843723257187741660f, -0.536778413575385920f, 0.843620315706004150f, + -0.536940185614842910f, 0.843517343206759200f, -0.537101937912544130f, + 0.843414339693792760f, -0.537263670462542530f, 0.843311305170892140f, + -0.537425383258891550f, 0.843208239641845440f, -0.537587076295645390f, + 0.843105143110442160f, -0.537748749566859360f, 0.843002015580472940f, + -0.537910403066588880f, 0.842898857055729310f, -0.538072036788890600f, + 0.842795667540004120f, -0.538233650727821700f, 0.842692447037091670f, + -0.538395244877439950f, 0.842589195550786710f, -0.538556819231804100f, + 0.842485913084885630f, -0.538718373784973560f, 0.842382599643185850f, + -0.538879908531008420f, 0.842279255229485990f, -0.539041423463969440f, + 0.842175879847585570f, -0.539202918577918240f, 0.842072473501285560f, + -0.539364393866917040f, 0.841969036194387680f, -0.539525849325028890f, + 0.841865567930695340f, -0.539687284946317570f, 0.841762068714012490f, + -0.539848700724847590f, 0.841658538548144760f, -0.540010096654684020f, + 0.841554977436898440f, -0.540171472729892850f, 0.841451385384081260f, + -0.540332828944540710f, 0.841347762393501950f, -0.540494165292695230f, + 0.841244108468970580f, -0.540655481768424150f, 0.841140423614298080f, + -0.540816778365796670f, 0.841036707833296650f, -0.540978055078882080f, + 0.840932961129779780f, -0.541139311901750800f, 0.840829183507561640f, + -0.541300548828474120f, 0.840725374970458070f, -0.541461765853123440f, + 0.840621535522285690f, -0.541622962969771530f, 0.840517665166862550f, + -0.541784140172491550f, 0.840413763908007480f, -0.541945297455357360f, + 0.840309831749540770f, -0.542106434812443920f, 0.840205868695283580f, + -0.542267552237826520f, 0.840101874749058400f, -0.542428649725581250f, + 0.839997849914688840f, -0.542589727269785270f, 0.839893794195999520f, + -0.542750784864515890f, 0.839789707596816370f, -0.542911822503851730f, + 0.839685590120966110f, -0.543072840181871740f, 0.839581441772277120f, + -0.543233837892655890f, 0.839477262554578550f, -0.543394815630284800f, + 0.839373052471700690f, -0.543555773388839540f, 0.839268811527475230f, + -0.543716711162402280f, 0.839164539725734680f, -0.543877628945055980f, + 0.839060237070312740f, -0.544038526730883820f, 0.838955903565044460f, + -0.544199404513970310f, 0.838851539213765760f, -0.544360262288400400f, + 0.838747144020313920f, -0.544521100048259600f, 0.838642717988527300f, + -0.544681917787634530f, 0.838538261122245280f, -0.544842715500612360f, + 0.838433773425308340f, -0.545003493181281160f, 0.838329254901558300f, + -0.545164250823729320f, 0.838224705554838080f, -0.545324988422046460f, + 0.838120125388991500f, -0.545485705970322530f, 0.838015514407863820f, + -0.545646403462648590f, 0.837910872615301170f, -0.545807080893116140f, + 0.837806200015150940f, -0.545967738255817570f, 0.837701496611261700f, + -0.546128375544845950f, 0.837596762407483040f, -0.546288992754295210f, + 0.837491997407665890f, -0.546449589878259650f, 0.837387201615661940f, + -0.546610166910834860f, 0.837282375035324320f, -0.546770723846116800f, + 0.837177517670507300f, -0.546931260678202190f, 0.837072629525066000f, + -0.547091777401188530f, 0.836967710602857020f, -0.547252274009174090f, + 0.836862760907737920f, -0.547412750496257930f, 0.836757780443567190f, + -0.547573206856539760f, 0.836652769214204950f, -0.547733643084120090f, + 0.836547727223512010f, -0.547894059173100190f, 0.836442654475350380f, + -0.548054455117581880f, 0.836337550973583530f, -0.548214830911667780f, + 0.836232416722075600f, -0.548375186549461600f, 0.836127251724692270f, + -0.548535522025067390f, 0.836022055985299880f, -0.548695837332590090f, + 0.835916829507766360f, -0.548856132466135290f, 0.835811572295960700f, + -0.549016407419809390f, 0.835706284353752600f, -0.549176662187719660f, + 0.835600965685013410f, -0.549336896763974010f, 0.835495616293615350f, + -0.549497111142680960f, 0.835390236183431890f, -0.549657305317949870f, + 0.835284825358337370f, -0.549817479283890910f, 0.835179383822207690f, + -0.549977633034614890f, 0.835073911578919410f, -0.550137766564233630f, + 0.834968408632350450f, -0.550297879866859190f, 0.834862874986380010f, + -0.550457972936604810f, 0.834757310644888230f, -0.550618045767584330f, + 0.834651715611756440f, -0.550778098353912120f, 0.834546089890866870f, + -0.550938130689703880f, 0.834440433486103190f, -0.551098142769075430f, + 0.834334746401350080f, -0.551258134586143590f, 0.834229028640493420f, + -0.551418106135026060f, 0.834123280207420100f, -0.551578057409841000f, + 0.834017501106018130f, -0.551737988404707340f, 0.833911691340176840f, + -0.551897899113745210f, 0.833805850913786340f, -0.552057789531074980f, + 0.833699979830738290f, -0.552217659650817930f, 0.833594078094925140f, + -0.552377509467096070f, 0.833488145710240770f, -0.552537338974032120f, + 0.833382182680579730f, -0.552697148165749770f, 0.833276189009838240f, + -0.552856937036373290f, 0.833170164701913190f, -0.553016705580027470f, + 0.833064109760702890f, -0.553176453790838350f, 0.832958024190106670f, + -0.553336181662932300f, 0.832851907994025090f, -0.553495889190436570f, + 0.832745761176359460f, -0.553655576367479310f, 0.832639583741012770f, + -0.553815243188189090f, 0.832533375691888680f, -0.553974889646695500f, + 0.832427137032892280f, -0.554134515737128910f, 0.832320867767929680f, + -0.554294121453620000f, 0.832214567900907980f, -0.554453706790300930f, + 0.832108237435735590f, -0.554613271741304040f, 0.832001876376321950f, + -0.554772816300762470f, 0.831895484726577590f, -0.554932340462810370f, + 0.831789062490414400f, -0.555091844221582420f, 0.831682609671745120f, + -0.555251327571213980f, 0.831576126274483740f, -0.555410790505841630f, + 0.831469612302545240f, -0.555570233019602180f, 0.831363067759845920f, + -0.555729655106633410f, 0.831256492650303210f, -0.555889056761073810f, + 0.831149886977835540f, -0.556048437977062600f, 0.831043250746362320f, + -0.556207798748739930f, 0.830936583959804410f, -0.556367139070246370f, + 0.830829886622083570f, -0.556526458935723610f, 0.830723158737122880f, + -0.556685758339313890f, 0.830616400308846310f, -0.556845037275160100f, + 0.830509611341179070f, -0.557004295737405950f, 0.830402791838047550f, + -0.557163533720196220f, 0.830295941803379070f, -0.557322751217676160f, + 0.830189061241102370f, -0.557481948223991550f, 0.830082150155146970f, + -0.557641124733289420f, 0.829975208549443950f, -0.557800280739716990f, + 0.829868236427924840f, -0.557959416237422960f, 0.829761233794523050f, + -0.558118531220556100f, 0.829654200653172640f, -0.558277625683266330f, + 0.829547137007808910f, -0.558436699619704100f, 0.829440042862368170f, + -0.558595753024020760f, 0.829332918220788250f, -0.558754785890368310f, + 0.829225763087007570f, -0.558913798212899770f, 0.829118577464965980f, + -0.559072789985768480f, 0.829011361358604430f, -0.559231761203128900f, + 0.828904114771864870f, -0.559390711859136140f, 0.828796837708690610f, + -0.559549641947945760f, 0.828689530173025820f, -0.559708551463714680f, + 0.828582192168815790f, -0.559867440400600210f, 0.828474823700007130f, + -0.560026308752760380f, 0.828367424770547480f, -0.560185156514354080f, + 0.828259995384385660f, -0.560343983679540860f, 0.828152535545471410f, + -0.560502790242481060f, 0.828045045257755800f, -0.560661576197336030f, + 0.827937524525190870f, -0.560820341538267430f, 0.827829973351729920f, + -0.560979086259438150f, 0.827722391741327220f, -0.561137810355011420f, + 0.827614779697938400f, -0.561296513819151470f, 0.827507137225519830f, + -0.561455196646023280f, 0.827399464328029470f, -0.561613858829792420f, + 0.827291761009425810f, -0.561772500364625340f, 0.827184027273669130f, + -0.561931121244689470f, 0.827076263124720270f, -0.562089721464152480f, + 0.826968468566541600f, -0.562248301017183150f, 0.826860643603096190f, + -0.562406859897951140f, 0.826752788238348520f, -0.562565398100626560f, + 0.826644902476264320f, -0.562723915619380400f, 0.826536986320809960f, + -0.562882412448384440f, 0.826429039775953500f, -0.563040888581811230f, + 0.826321062845663530f, -0.563199344013834090f, 0.826213055533910220f, + -0.563357778738627020f, 0.826105017844664610f, -0.563516192750364800f, + 0.825996949781899080f, -0.563674586043223070f, 0.825888851349586780f, + -0.563832958611378170f, 0.825780722551702430f, -0.563991310449006970f, + 0.825672563392221390f, -0.564149641550287680f, 0.825564373875120490f, + -0.564307951909398640f, 0.825456154004377550f, -0.564466241520519500f, + 0.825347903783971380f, -0.564624510377830120f, 0.825239623217882250f, + -0.564782758475511400f, 0.825131312310091070f, -0.564940985807745210f, + 0.825022971064580220f, -0.565099192368713980f, 0.824914599485333190f, + -0.565257378152600800f, 0.824806197576334330f, -0.565415543153589660f, + 0.824697765341569470f, -0.565573687365865330f, 0.824589302785025290f, + -0.565731810783613120f, 0.824480809910689500f, -0.565889913401019570f, + 0.824372286722551250f, -0.566047995212271450f, 0.824263733224600560f, + -0.566206056211556730f, 0.824155149420828570f, -0.566364096393063840f, + 0.824046535315227760f, -0.566522115750982100f, 0.823937890911791370f, + -0.566680114279501600f, 0.823829216214513990f, -0.566838091972813320f, + 0.823720511227391430f, -0.566996048825108680f, 0.823611775954420260f, + -0.567153984830580100f, 0.823503010399598500f, -0.567311899983420800f, + 0.823394214566925080f, -0.567469794277824510f, 0.823285388460400110f, + -0.567627667707986230f, 0.823176532084024860f, -0.567785520268101140f, + 0.823067645441801670f, -0.567943351952365560f, 0.822958728537734000f, + -0.568101162754976460f, 0.822849781375826430f, -0.568258952670131490f, + 0.822740803960084420f, -0.568416721692029280f, 0.822631796294514990f, + -0.568574469814869140f, 0.822522758383125940f, -0.568732197032851050f, + 0.822413690229926390f, -0.568889903340175860f, 0.822304591838926350f, + -0.569047588731045110f, 0.822195463214137170f, -0.569205253199661200f, + 0.822086304359571090f, -0.569362896740227220f, 0.821977115279241550f, + -0.569520519346947140f, 0.821867895977163250f, -0.569678121014025600f, + 0.821758646457351750f, -0.569835701735668000f, 0.821649366723823940f, + -0.569993261506080540f, 0.821540056780597610f, -0.570150800319470300f, + 0.821430716631691870f, -0.570308318170044900f, 0.821321346281126740f, + -0.570465815052012990f, 0.821211945732923550f, -0.570623290959583750f, + 0.821102514991104650f, -0.570780745886967260f, 0.820993054059693580f, + -0.570938179828374360f, 0.820883562942714580f, -0.571095592778016690f, + 0.820774041644193650f, -0.571252984730106660f, 0.820664490168157460f, + -0.571410355678857230f, 0.820554908518633890f, -0.571567705618482580f, + 0.820445296699652050f, -0.571725034543197120f, 0.820335654715241840f, + -0.571882342447216590f, 0.820225982569434690f, -0.572039629324757050f, + 0.820116280266262820f, -0.572196895170035580f, 0.820006547809759680f, + -0.572354139977269920f, 0.819896785203959810f, -0.572511363740678790f, + 0.819786992452898990f, -0.572668566454481160f, 0.819677169560613870f, + -0.572825748112897550f, 0.819567316531142230f, -0.572982908710148560f, + 0.819457433368523280f, -0.573140048240455950f, 0.819347520076796900f, + -0.573297166698042200f, 0.819237576660004520f, -0.573454264077130400f, + 0.819127603122188240f, -0.573611340371944610f, 0.819017599467391500f, + -0.573768395576709560f, 0.818907565699658950f, -0.573925429685650750f, + 0.818797501823036010f, -0.574082442692994470f, 0.818687407841569680f, + -0.574239434592967890f, 0.818577283759307610f, -0.574396405379798750f, + 0.818467129580298660f, -0.574553355047715760f, 0.818356945308593150f, + -0.574710283590948330f, 0.818246730948242070f, -0.574867191003726740f, + 0.818136486503297730f, -0.575024077280281710f, 0.818026211977813440f, + -0.575180942414845080f, 0.817915907375843850f, -0.575337786401649450f, + 0.817805572701444270f, -0.575494609234928120f, 0.817695207958671680f, + -0.575651410908915140f, 0.817584813151583710f, -0.575808191417845340f, + 0.817474388284239240f, -0.575964950755954220f, 0.817363933360698460f, + -0.576121688917478280f, 0.817253448385022340f, -0.576278405896654910f, + 0.817142933361272970f, -0.576435101687721830f, 0.817032388293513880f, + -0.576591776284917760f, 0.816921813185809480f, -0.576748429682482410f, + 0.816811208042225290f, -0.576905061874655960f, 0.816700572866827850f, + -0.577061672855679440f, 0.816589907663684890f, -0.577218262619794920f, + 0.816479212436865390f, -0.577374831161244880f, 0.816368487190439200f, + -0.577531378474272720f, 0.816257731928477390f, -0.577687904553122800f, + 0.816146946655052270f, -0.577844409392039850f, 0.816036131374236810f, + -0.578000892985269910f, 0.815925286090105510f, -0.578157355327059360f, + 0.815814410806733780f, -0.578313796411655590f, 0.815703505528198260f, + -0.578470216233306630f, 0.815592570258576790f, -0.578626614786261430f, + 0.815481605001947770f, -0.578782992064769690f, 0.815370609762391290f, + -0.578939348063081780f, 0.815259584543988280f, -0.579095682775449090f, + 0.815148529350820830f, -0.579251996196123550f, 0.815037444186972220f, + -0.579408288319357870f, 0.814926329056526620f, -0.579564559139405630f, + 0.814815183963569440f, -0.579720808650521450f, 0.814704008912187080f, + -0.579877036846960350f, 0.814592803906467270f, -0.580033243722978150f, + 0.814481568950498610f, -0.580189429272831680f, 0.814370304048371070f, + -0.580345593490778300f, 0.814259009204175270f, -0.580501736371076490f, + 0.814147684422003360f, -0.580657857907985300f, 0.814036329705948410f, + -0.580813958095764530f, 0.813924945060104600f, -0.580970036928674770f, + 0.813813530488567190f, -0.581126094400977620f, 0.813702085995432700f, + -0.581282130506935000f, 0.813590611584798510f, -0.581438145240810170f, + 0.813479107260763220f, -0.581594138596866930f, 0.813367573027426570f, + -0.581750110569369650f, 0.813256008888889380f, -0.581906061152583810f, + 0.813144414849253590f, -0.582061990340775440f, 0.813032790912622040f, + -0.582217898128211670f, 0.812921137083098770f, -0.582373784509160110f, + 0.812809453364789270f, -0.582529649477889320f, 0.812697739761799490f, + -0.582685493028668460f, 0.812585996278237130f, -0.582841315155767650f, + 0.812474222918210480f, -0.582997115853457700f, 0.812362419685829230f, + -0.583152895116010430f, 0.812250586585203880f, -0.583308652937698290f, + 0.812138723620446480f, -0.583464389312794320f, 0.812026830795669730f, + -0.583620104235572760f, 0.811914908114987790f, -0.583775797700308070f, + 0.811802955582515470f, -0.583931469701276180f, 0.811690973202369050f, + -0.584087120232753440f, 0.811578960978665890f, -0.584242749289016980f, + 0.811466918915524250f, -0.584398356864344600f, 0.811354847017063730f, + -0.584553942953015330f, 0.811242745287404810f, -0.584709507549308390f, + 0.811130613730669190f, -0.584865050647504490f, 0.811018452350979470f, + -0.585020572241884530f, 0.810906261152459670f, -0.585176072326730410f, + 0.810794040139234730f, -0.585331550896324940f, 0.810681789315430780f, + -0.585487007944951340f, 0.810569508685174630f, -0.585642443466894420f, + 0.810457198252594770f, -0.585797857456438860f, 0.810344858021820550f, + -0.585953249907870570f, 0.810232487996982330f, -0.586108620815476430f, + 0.810120088182211600f, -0.586263970173543590f, 0.810007658581641140f, + -0.586419297976360500f, 0.809895199199404450f, -0.586574604218216170f, + 0.809782710039636530f, -0.586729888893400390f, 0.809670191106473090f, + -0.586885151996203950f, 0.809557642404051260f, -0.587040393520917970f, + 0.809445063936509170f, -0.587195613461834800f, 0.809332455707985950f, + -0.587350811813247660f, 0.809219817722621750f, -0.587505988569450020f, + 0.809107149984558240f, -0.587661143724736660f, 0.808994452497937670f, + -0.587816277273402910f, 0.808881725266903610f, -0.587971389209745010f, + 0.808768968295600850f, -0.588126479528059850f, 0.808656181588174980f, + -0.588281548222645220f, 0.808543365148773010f, -0.588436595287799790f, + 0.808430518981542720f, -0.588591620717822890f, 0.808317643090633250f, + -0.588746624507014540f, 0.808204737480194720f, -0.588901606649675720f, + 0.808091802154378370f, -0.589056567140108460f, 0.807978837117336310f, + -0.589211505972614960f, 0.807865842373222120f, -0.589366423141498790f, + 0.807752817926190360f, -0.589521318641063940f, 0.807639763780396480f, + -0.589676192465615420f, 0.807526679939997160f, -0.589831044609458790f, + 0.807413566409150190f, -0.589985875066900920f, 0.807300423192014450f, + -0.590140683832248820f, 0.807187250292749960f, -0.590295470899810830f, + 0.807074047715517610f, -0.590450236263895810f, 0.806960815464479730f, + -0.590604979918813330f, 0.806847553543799330f, -0.590759701858874160f, + 0.806734261957640860f, -0.590914402078389520f, 0.806620940710169650f, + -0.591069080571671400f, 0.806507589805552260f, -0.591223737333032910f, + 0.806394209247956240f, -0.591378372356787580f, 0.806280799041550480f, + -0.591532985637249990f, 0.806167359190504420f, -0.591687577168735430f, + 0.806053889698989060f, -0.591842146945560140f, 0.805940390571176280f, + -0.591996694962040990f, 0.805826861811239300f, -0.592151221212495530f, + 0.805713303423352230f, -0.592305725691242290f, 0.805599715411690060f, + -0.592460208392600830f, 0.805486097780429230f, -0.592614669310891130f, + 0.805372450533747060f, -0.592769108440434070f, 0.805258773675822210f, + -0.592923525775551300f, 0.805145067210834230f, -0.593077921310565470f, + 0.805031331142963660f, -0.593232295039799800f, 0.804917565476392260f, + -0.593386646957578480f, 0.804803770215302920f, -0.593540977058226390f, + 0.804689945363879500f, -0.593695285336069190f, 0.804576090926307110f, + -0.593849571785433630f, 0.804462206906771840f, -0.594003836400646690f, + 0.804348293309460780f, -0.594158079176036800f, 0.804234350138562260f, + -0.594312300105932830f, 0.804120377398265810f, -0.594466499184664430f, + 0.804006375092761520f, -0.594620676406562240f, 0.803892343226241260f, + -0.594774831765957580f, 0.803778281802897570f, -0.594928965257182420f, + 0.803664190826924090f, -0.595083076874569960f, 0.803550070302515680f, + -0.595237166612453850f, 0.803435920233868120f, -0.595391234465168730f, + 0.803321740625178580f, -0.595545280427049790f, 0.803207531480644940f, + -0.595699304492433360f, 0.803093292804466400f, -0.595853306655656280f, + 0.802979024600843250f, -0.596007286911056530f, 0.802864726873976700f, + -0.596161245252972540f, 0.802750399628069160f, -0.596315181675743710f, + 0.802636042867324150f, -0.596469096173710360f, 0.802521656595946430f, + -0.596622988741213220f, 0.802407240818141300f, -0.596776859372594390f, + 0.802292795538115720f, -0.596930708062196500f, 0.802178320760077450f, + -0.597084534804362740f, 0.802063816488235440f, -0.597238339593437420f, + 0.801949282726799770f, -0.597392122423765710f, 0.801834719479981310f, + -0.597545883289693160f, 0.801720126751992330f, -0.597699622185566830f, + 0.801605504547046150f, -0.597853339105733910f, 0.801490852869356950f, + -0.598007034044542700f, 0.801376171723140240f, -0.598160706996342270f, + 0.801261461112612540f, -0.598314357955482600f, 0.801146721041991360f, + -0.598467986916314310f, 0.801031951515495330f, -0.598621593873188920f, + 0.800917152537344300f, -0.598775178820458720f, 0.800802324111759110f, + -0.598928741752476900f, 0.800687466242961610f, -0.599082282663597310f, + 0.800572578935174860f, -0.599235801548174570f, 0.800457662192622820f, + -0.599389298400564540f, 0.800342716019530660f, -0.599542773215123390f, + 0.800227740420124790f, -0.599696225986208310f, 0.800112735398632370f, + -0.599849656708177250f, 0.799997700959281910f, -0.600003065375388940f, + 0.799882637106302810f, -0.600156451982203240f, 0.799767543843925680f, + -0.600309816522980430f, 0.799652421176382240f, -0.600463158992081580f, + 0.799537269107905010f, -0.600616479383868970f, 0.799422087642728040f, + -0.600769777692705230f, 0.799306876785086160f, -0.600923053912954090f, + 0.799191636539215210f, -0.601076308038980160f, 0.799076366909352350f, + -0.601229540065148500f, 0.798961067899735760f, -0.601382749985825420f, + 0.798845739514604580f, -0.601535937795377730f, 0.798730381758199210f, + -0.601689103488172950f, 0.798614994634760820f, -0.601842247058580030f, + 0.798499578148532120f, -0.601995368500968020f, 0.798384132303756380f, + -0.602148467809707210f, 0.798268657104678430f, -0.602301544979168550f, + 0.798153152555543750f, -0.602454600003723750f, 0.798037618660599410f, + -0.602607632877745440f, 0.797922055424093000f, -0.602760643595607220f, + 0.797806462850273570f, -0.602913632151683030f, 0.797690840943391160f, + -0.603066598540348160f, 0.797575189707696700f, -0.603219542755978440f, + 0.797459509147442460f, -0.603372464792950260f, 0.797343799266881700f, + -0.603525364645641550f, 0.797228060070268700f, -0.603678242308430370f, + 0.797112291561858920f, -0.603831097775695880f, 0.796996493745908750f, + -0.603983931041818020f, 0.796880666626675780f, -0.604136742101177520f, + 0.796764810208418830f, -0.604289530948155960f, 0.796648924495397260f, + -0.604442297577135860f, 0.796533009491872000f, -0.604595041982500360f, + 0.796417065202104980f, -0.604747764158633410f, 0.796301091630359110f, + -0.604900464099919820f, 0.796185088780898440f, -0.605053141800745320f, + 0.796069056657987990f, -0.605205797255496500f, 0.795952995265893910f, + -0.605358430458560530f, 0.795836904608883570f, -0.605511041404325550f, + 0.795720784691225090f, -0.605663630087180380f, 0.795604635517188070f, + -0.605816196501514970f, 0.795488457091042990f, -0.605968740641719680f, + 0.795372249417061310f, -0.606121262502186120f, 0.795256012499515610f, + -0.606273762077306430f, 0.795139746342679590f, -0.606426239361473550f, + 0.795023450950828050f, -0.606578694349081290f, 0.794907126328237010f, + -0.606731127034524480f, 0.794790772479183170f, -0.606883537412198470f, + 0.794674389407944550f, -0.607035925476499650f, 0.794557977118800380f, + -0.607188291221825160f, 0.794441535616030590f, -0.607340634642572930f, + 0.794325064903916520f, -0.607492955733141550f, 0.794208564986740640f, + -0.607645254487930830f, 0.794092035868785960f, -0.607797530901341140f, + 0.793975477554337170f, -0.607949784967773630f, 0.793858890047679730f, + -0.608102016681630440f, 0.793742273353100210f, -0.608254226037314490f, + 0.793625627474886300f, -0.608406413029229150f, 0.793508952417326660f, + -0.608558577651779450f, 0.793392248184711100f, -0.608710719899370310f, + 0.793275514781330630f, -0.608862839766408200f, 0.793158752211477140f, + -0.609014937247299830f, 0.793041960479443640f, -0.609167012336453210f, + 0.792925139589524260f, -0.609319065028276820f, 0.792808289546014120f, + -0.609471095317180240f, 0.792691410353209450f, -0.609623103197573730f, + 0.792574502015407690f, -0.609775088663868430f, 0.792457564536907080f, + -0.609927051710476120f, 0.792340597922007170f, -0.610078992331809620f, + 0.792223602175008310f, -0.610230910522282620f, 0.792106577300212390f, + -0.610382806276309480f, 0.791989523301921850f, -0.610534679588305320f, + 0.791872440184440470f, -0.610686530452686280f, 0.791755327952073150f, + -0.610838358863869170f, 0.791638186609125880f, -0.610990164816271660f, + 0.791521016159905220f, -0.611141948304312570f, 0.791403816608719500f, + -0.611293709322410890f, 0.791286587959877830f, -0.611445447864987000f, + 0.791169330217690200f, -0.611597163926461910f, 0.791052043386467950f, + -0.611748857501257290f, 0.790934727470523290f, -0.611900528583796070f, + 0.790817382474169770f, -0.612052177168501470f, 0.790700008401721610f, + -0.612203803249797950f, 0.790582605257494460f, -0.612355406822110650f, + 0.790465173045804880f, -0.612506987879865570f, 0.790347711770970520f, + -0.612658546417489290f, 0.790230221437310030f, -0.612810082429409710f, + 0.790112702049143300f, -0.612961595910055170f, 0.789995153610791090f, + -0.613113086853854910f, 0.789877576126575280f, -0.613264555255239040f, + 0.789759969600819070f, -0.613416001108638590f, 0.789642334037846340f, + -0.613567424408485330f, 0.789524669441982190f, -0.613718825149211720f, + 0.789406975817552930f, -0.613870203325251330f, 0.789289253168885650f, + -0.614021558931038380f, 0.789171501500308900f, -0.614172891961007990f, + 0.789053720816151880f, -0.614324202409595950f, 0.788935911120745240f, + -0.614475490271239040f, 0.788818072418420280f, -0.614626755540375050f, + 0.788700204713509660f, -0.614777998211442080f, 0.788582308010347120f, + -0.614929218278879590f, 0.788464382313267540f, -0.615080415737127460f, + 0.788346427626606340f, -0.615231590580626820f, 0.788228443954700490f, + -0.615382742803819220f, 0.788110431301888070f, -0.615533872401147320f, + 0.787992389672507950f, -0.615684979367054570f, 0.787874319070900220f, + -0.615836063695985090f, 0.787756219501406060f, -0.615987125382383760f, + 0.787638090968367450f, -0.616138164420696910f, 0.787519933476127810f, + -0.616289180805370980f, 0.787401747029031430f, -0.616440174530853650f, + 0.787283531631423620f, -0.616591145591593110f, 0.787165287287651010f, + -0.616742093982038720f, 0.787047014002060790f, -0.616893019696640680f, + 0.786928711779001810f, -0.617043922729849760f, 0.786810380622823490f, + -0.617194803076117630f, 0.786692020537876790f, -0.617345660729896830f, + 0.786573631528513230f, -0.617496495685640910f, 0.786455213599085770f, + -0.617647307937803870f, 0.786336766753948260f, -0.617798097480841020f, + 0.786218290997455660f, -0.617948864309208150f, 0.786099786333963930f, + -0.618099608417362000f, 0.785981252767830150f, -0.618250329799760250f, + 0.785862690303412600f, -0.618401028450860980f, 0.785744098945070360f, + -0.618551704365123740f, 0.785625478697163700f, -0.618702357537008530f, + 0.785506829564053930f, -0.618852987960976320f, 0.785388151550103550f, + -0.619003595631488660f, 0.785269444659675850f, -0.619154180543008410f, + 0.785150708897135560f, -0.619304742689998690f, 0.785031944266848080f, + -0.619455282066924020f, 0.784913150773180020f, -0.619605798668249270f, + 0.784794328420499230f, -0.619756292488440660f, 0.784675477213174320f, + -0.619906763521964720f, 0.784556597155575240f, -0.620057211763289100f, + 0.784437688252072830f, -0.620207637206882430f, 0.784318750507038920f, + -0.620358039847213720f, 0.784199783924846570f, -0.620508419678753360f, + 0.784080788509869950f, -0.620658776695972140f, 0.783961764266484120f, + -0.620809110893341900f, 0.783842711199065230f, -0.620959422265335180f, + 0.783723629311990470f, -0.621109710806425630f, 0.783604518609638200f, + -0.621259976511087550f, 0.783485379096387820f, -0.621410219373796150f, + 0.783366210776619720f, -0.621560439389027160f, 0.783247013654715380f, + -0.621710636551257690f, 0.783127787735057310f, -0.621860810854965360f, + 0.783008533022029110f, -0.622010962294628600f, 0.782889249520015480f, + -0.622161090864726820f, 0.782769937233402050f, -0.622311196559740320f, + 0.782650596166575730f, -0.622461279374149970f, 0.782531226323924240f, + -0.622611339302437730f, 0.782411827709836530f, -0.622761376339086350f, + 0.782292400328702400f, -0.622911390478579460f, 0.782172944184913010f, + -0.623061381715401260f, 0.782053459282860300f, -0.623211350044037270f, + 0.781933945626937630f, -0.623361295458973230f, 0.781814403221538830f, + -0.623511217954696440f, 0.781694832071059390f, -0.623661117525694530f, + 0.781575232179895550f, -0.623810994166456130f, 0.781455603552444590f, + -0.623960847871470660f, 0.781335946193104870f, -0.624110678635228510f, + 0.781216260106276090f, -0.624260486452220650f, 0.781096545296358520f, + -0.624410271316939270f, 0.780976801767753750f, -0.624560033223877210f, + 0.780857029524864580f, -0.624709772167528100f, 0.780737228572094490f, + -0.624859488142386340f, 0.780617398913848400f, -0.625009181142947460f, + 0.780497540554531910f, -0.625158851163707620f, 0.780377653498552040f, + -0.625308498199164010f, 0.780257737750316590f, -0.625458122243814360f, + 0.780137793314234610f, -0.625607723292157410f, 0.780017820194715990f, + -0.625757301338692900f, 0.779897818396172000f, -0.625906856377921090f, + 0.779777787923014550f, -0.626056388404343520f, 0.779657728779656890f, + -0.626205897412462130f, 0.779537640970513260f, -0.626355383396779990f, + 0.779417524499998900f, -0.626504846351800810f, 0.779297379372530300f, + -0.626654286272029350f, 0.779177205592524680f, -0.626803703151971200f, + 0.779057003164400630f, -0.626953096986132660f, 0.778936772092577500f, + -0.627102467769020900f, 0.778816512381475980f, -0.627251815495144080f, + 0.778696224035517530f, -0.627401140159011050f, 0.778575907059125050f, + -0.627550441755131530f, 0.778455561456721900f, -0.627699720278016240f, + 0.778335187232733210f, -0.627848975722176460f, 0.778214784391584540f, + -0.627998208082124700f, 0.778094352937702790f, -0.628147417352374000f, + 0.777973892875516100f, -0.628296603527438320f, 0.777853404209453150f, + -0.628445766601832710f, 0.777732886943944050f, -0.628594906570072550f, + 0.777612341083420030f, -0.628744023426674680f, 0.777491766632313010f, + -0.628893117166156480f, 0.777371163595056310f, -0.629042187783036000f, + 0.777250531976084070f, -0.629191235271832290f, 0.777129871779831620f, + -0.629340259627065630f, 0.777009183010735290f, -0.629489260843256630f, + 0.776888465673232440f, -0.629638238914926980f, 0.776767719771761510f, + -0.629787193836599200f, 0.776646945310762060f, -0.629936125602796440f, + 0.776526142294674430f, -0.630085034208043180f, 0.776405310727940390f, + -0.630233919646864370f, 0.776284450615002510f, -0.630382781913785940f, + 0.776163561960304340f, -0.630531621003334600f, 0.776042644768290770f, + -0.630680436910037940f, 0.775921699043407690f, -0.630829229628424470f, + 0.775800724790101650f, -0.630977999153023550f, 0.775679722012820650f, + -0.631126745478365340f, 0.775558690716013580f, -0.631275468598980760f, + 0.775437630904130540f, -0.631424168509401860f, 0.775316542581622530f, + -0.631572845204161020f, 0.775195425752941420f, -0.631721498677792260f, + 0.775074280422540450f, -0.631870128924829850f, 0.774953106594873930f, + -0.632018735939809060f, 0.774831904274396850f, -0.632167319717265920f, + 0.774710673465565550f, -0.632315880251737570f, 0.774589414172837550f, + -0.632464417537761840f, 0.774468126400670860f, -0.632612931569877410f, + 0.774346810153525130f, -0.632761422342624000f, 0.774225465435860680f, + -0.632909889850541750f, 0.774104092252139050f, -0.633058334088172140f, + 0.773982690606822900f, -0.633206755050057190f, 0.773861260504375540f, + -0.633355152730739950f, 0.773739801949261840f, -0.633503527124764320f, + 0.773618314945947460f, -0.633651878226674900f, 0.773496799498899050f, + -0.633800206031017280f, 0.773375255612584470f, -0.633948510532337810f, + 0.773253683291472590f, -0.634096791725183740f, 0.773132082540033070f, + -0.634245049604103330f, 0.773010453362736990f, -0.634393284163645490f, + 0.772888795764056220f, -0.634541495398360020f, 0.772767109748463850f, + -0.634689683302797740f, 0.772645395320433860f, -0.634837847871509990f, + 0.772523652484441330f, -0.634985989099049460f, 0.772401881244962450f, + -0.635134106979969190f, 0.772280081606474320f, -0.635282201508823420f, + 0.772158253573455240f, -0.635430272680167160f, 0.772036397150384520f, + -0.635578320488556110f, 0.771914512341742350f, -0.635726344928547070f, + 0.771792599152010150f, -0.635874345994697720f, 0.771670657585670330f, + -0.636022323681566300f, 0.771548687647206300f, -0.636170277983712170f, + 0.771426689341102590f, -0.636318208895695460f, 0.771304662671844830f, + -0.636466116412077180f, 0.771182607643919330f, -0.636614000527419120f, + 0.771060524261813820f, -0.636761861236284200f, 0.770938412530016940f, + -0.636909698533235870f, 0.770816272453018540f, -0.637057512412838590f, + 0.770694104035309140f, -0.637205302869657600f, 0.770571907281380810f, + -0.637353069898259130f, 0.770449682195725960f, -0.637500813493210190f, + 0.770327428782838890f, -0.637648533649078810f, 0.770205147047214210f, + -0.637796230360433540f, 0.770082836993347900f, -0.637943903621844060f, + 0.769960498625737230f, -0.638091553427880820f, 0.769838131948879840f, + -0.638239179773115280f, 0.769715736967275130f, -0.638386782652119570f, + 0.769593313685422940f, -0.638534362059466790f, 0.769470862107824670f, + -0.638681917989730730f, 0.769348382238982280f, -0.638829450437486290f, + 0.769225874083399260f, -0.638976959397309140f, 0.769103337645579700f, + -0.639124444863775730f, 0.768980772930028870f, -0.639271906831463510f, + 0.768858179941253270f, -0.639419345294950700f, 0.768735558683760310f, + -0.639566760248816310f, 0.768612909162058380f, -0.639714151687640450f, + 0.768490231380656860f, -0.639861519606003900f, 0.768367525344066270f, + -0.640008863998488440f, 0.768244791056798330f, -0.640156184859676510f, + 0.768122028523365420f, -0.640303482184151670f, 0.767999237748281270f, + -0.640450755966498140f, 0.767876418736060610f, -0.640598006201301030f, + 0.767753571491219030f, -0.640745232883146440f, 0.767630696018273380f, + -0.640892436006621380f, 0.767507792321741270f, -0.641039615566313390f, + 0.767384860406141730f, -0.641186771556811250f, 0.767261900275994500f, + -0.641333903972704290f, 0.767138911935820400f, -0.641481012808583160f, + 0.767015895390141480f, -0.641628098059038750f, 0.766892850643480670f, + -0.641775159718663500f, 0.766769777700361920f, -0.641922197782050170f, + 0.766646676565310380f, -0.642069212243792540f, 0.766523547242852210f, + -0.642216203098485370f, 0.766400389737514230f, -0.642363170340724320f, + 0.766277204053824710f, -0.642510113965105710f, 0.766153990196312920f, + -0.642657033966226860f, 0.766030748169509000f, -0.642803930338685990f, + 0.765907477977944340f, -0.642950803077082080f, 0.765784179626150970f, + -0.643097652176015110f, 0.765660853118662500f, -0.643244477630085850f, + 0.765537498460013070f, -0.643391279433895850f, 0.765414115654738270f, + -0.643538057582047740f, 0.765290704707374370f, -0.643684812069144850f, + 0.765167265622458960f, -0.643831542889791390f, 0.765043798404530520f, + -0.643978250038592660f, 0.764920303058128410f, -0.644124933510154540f, + 0.764796779587793460f, -0.644271593299083790f, 0.764673227998067140f, + -0.644418229399988380f, 0.764549648293492150f, -0.644564841807476640f, + 0.764426040478612070f, -0.644711430516158310f, 0.764302404557971720f, + -0.644857995520643710f, 0.764178740536116670f, -0.645004536815543930f, + 0.764055048417593970f, -0.645151054395471160f, 0.763931328206951090f, + -0.645297548255038380f, 0.763807579908737160f, -0.645444018388859230f, + 0.763683803527501870f, -0.645590464791548690f, 0.763559999067796150f, + -0.645736887457722290f, 0.763436166534172010f, -0.645883286381996320f, + 0.763312305931182380f, -0.646029661558988330f, 0.763188417263381270f, + -0.646176012983316280f, 0.763064500535323710f, -0.646322340649599480f, + 0.762940555751565720f, -0.646468644552457780f, 0.762816582916664430f, + -0.646614924686512050f, 0.762692582035177980f, -0.646761181046383920f, + 0.762568553111665380f, -0.646907413626696020f, 0.762444496150687210f, + -0.647053622422071540f, 0.762320411156804270f, -0.647199807427135230f, + 0.762196298134578900f, -0.647345968636512060f, 0.762072157088574560f, + -0.647492106044828100f, 0.761947988023355390f, -0.647638219646710310f, + 0.761823790943486960f, -0.647784309436786440f, 0.761699565853535380f, + -0.647930375409685340f, 0.761575312758068000f, -0.648076417560036530f, + 0.761451031661653620f, -0.648222435882470420f, 0.761326722568861360f, + -0.648368430371618290f, 0.761202385484261780f, -0.648514401022112440f, + 0.761078020412426560f, -0.648660347828585840f, 0.760953627357928150f, + -0.648806270785672550f, 0.760829206325340010f, -0.648952169888007300f, + 0.760704757319236920f, -0.649098045130225950f, 0.760580280344194450f, + -0.649243896506964900f, 0.760455775404789260f, -0.649389724012861660f, + 0.760331242505599030f, -0.649535527642554730f, 0.760206681651202420f, + -0.649681307390683190f, 0.760082092846179340f, -0.649827063251887100f, + 0.759957476095110330f, -0.649972795220807530f, 0.759832831402577400f, + -0.650118503292086200f, 0.759708158773163440f, -0.650264187460365850f, + 0.759583458211452010f, -0.650409847720290310f, 0.759458729722028210f, + -0.650555484066503880f, 0.759333973309477940f, -0.650701096493652040f, + 0.759209188978388070f, -0.650846684996380880f, 0.759084376733346610f, + -0.650992249569337660f, 0.758959536578942440f, -0.651137790207170330f, + 0.758834668519765660f, -0.651283306904527740f, 0.758709772560407390f, + -0.651428799656059820f, 0.758584848705459610f, -0.651574268456416970f, + 0.758459896959515430f, -0.651719713300250910f, 0.758334917327168960f, + -0.651865134182213920f, 0.758209909813015280f, -0.652010531096959500f, + 0.758084874421650730f, -0.652155904039141590f, 0.757959811157672300f, + -0.652301253003415460f, 0.757834720025678310f, -0.652446577984436730f, + 0.757709601030268080f, -0.652591878976862440f, 0.757584454176041810f, + -0.652737155975350310f, 0.757459279467600720f, -0.652882408974558850f, + 0.757334076909547130f, -0.653027637969147530f, 0.757208846506484570f, + -0.653172842953776760f, 0.757083588263017140f, -0.653318023923107670f, + 0.756958302183750490f, -0.653463180871802330f, 0.756832988273290820f, + -0.653608313794523890f, 0.756707646536245670f, -0.653753422685936060f, + 0.756582276977223470f, -0.653898507540703780f, 0.756456879600833740f, + -0.654043568353492640f, 0.756331454411686920f, -0.654188605118969040f, + 0.756206001414394540f, -0.654333617831800440f, 0.756080520613569120f, + -0.654478606486655350f, 0.755955012013824420f, -0.654623571078202680f, + 0.755829475619774760f, -0.654768511601112600f, 0.755703911436035880f, + -0.654913428050056030f, 0.755578319467224540f, -0.655058320419704910f, + 0.755452699717958250f, -0.655203188704731820f, 0.755327052192855670f, + -0.655348032899810470f, 0.755201376896536550f, -0.655492852999615350f, + 0.755075673833621620f, -0.655637648998821820f, 0.754949943008732640f, + -0.655782420892106030f, 0.754824184426492350f, -0.655927168674145360f, + 0.754698398091524500f, -0.656071892339617600f, 0.754572584008453840f, + -0.656216591883201920f, 0.754446742181906440f, -0.656361267299578000f, + 0.754320872616508820f, -0.656505918583426550f, 0.754194975316889170f, + -0.656650545729428940f, 0.754069050287676120f, -0.656795148732268070f, + 0.753943097533499640f, -0.656939727586627110f, 0.753817117058990790f, + -0.657084282287190180f, 0.753691108868781210f, -0.657228812828642540f, + 0.753565072967504300f, -0.657373319205670210f, 0.753439009359793580f, + -0.657517801412960120f, 0.753312918050284330f, -0.657662259445200070f, + 0.753186799043612520f, -0.657806693297078640f, 0.753060652344415100f, + -0.657951102963285520f, 0.752934477957330150f, -0.658095488438511180f, + 0.752808275886996950f, -0.658239849717446870f, 0.752682046138055340f, + -0.658384186794785050f, 0.752555788715146390f, -0.658528499665218650f, + 0.752429503622912390f, -0.658672788323441890f, 0.752303190865996400f, + -0.658817052764149480f, 0.752176850449042810f, -0.658961292982037320f, + 0.752050482376696360f, -0.659105508971802090f, 0.751924086653603550f, + -0.659249700728141490f, 0.751797663284411550f, -0.659393868245753860f, + 0.751671212273768430f, -0.659538011519338660f, 0.751544733626323680f, + -0.659682130543596150f, 0.751418227346727470f, -0.659826225313227320f, + 0.751291693439630870f, -0.659970295822934540f, 0.751165131909686480f, + -0.660114342067420480f, 0.751038542761547360f, -0.660258364041389050f, + 0.750911925999867890f, -0.660402361739545030f, 0.750785281629303690f, + -0.660546335156593890f, 0.750658609654510700f, -0.660690284287242300f, + 0.750531910080146410f, -0.660834209126197610f, 0.750405182910869330f, + -0.660978109668168060f, 0.750278428151338720f, -0.661121985907862860f, + 0.750151645806215070f, -0.661265837839992270f, 0.750024835880159780f, + -0.661409665459266940f, 0.749897998377835330f, -0.661553468760398890f, + 0.749771133303905100f, -0.661697247738101010f, 0.749644240663033480f, + -0.661841002387086870f, 0.749517320459886170f, -0.661984732702070920f, + 0.749390372699129560f, -0.662128438677768720f, 0.749263397385431130f, + -0.662272120308896590f, 0.749136394523459370f, -0.662415777590171780f, + 0.749009364117883880f, -0.662559410516312290f, 0.748882306173375150f, + -0.662703019082037440f, 0.748755220694604760f, -0.662846603282066900f, + 0.748628107686245440f, -0.662990163111121470f, 0.748500967152970430f, + -0.663133698563923010f, 0.748373799099454560f, -0.663277209635194100f, + 0.748246603530373420f, -0.663420696319658280f, 0.748119380450403600f, + -0.663564158612039770f, 0.747992129864222700f, -0.663707596507064010f, + 0.747864851776509410f, -0.663851009999457340f, 0.747737546191943330f, + -0.663994399083946640f, 0.747610213115205150f, -0.664137763755260010f, + 0.747482852550976570f, -0.664281104008126230f, 0.747355464503940190f, + -0.664424419837275180f, 0.747228048978779920f, -0.664567711237437520f, + 0.747100605980180130f, -0.664710978203344790f, 0.746973135512826850f, + -0.664854220729729660f, 0.746845637581406540f, -0.664997438811325340f, + 0.746718112190607130f, -0.665140632442866140f, 0.746590559345117310f, + -0.665283801619087180f, 0.746462979049626770f, -0.665426946334724660f, + 0.746335371308826320f, -0.665570066584515450f, 0.746207736127407760f, + -0.665713162363197550f, 0.746080073510063780f, -0.665856233665509720f, + 0.745952383461488290f, -0.665999280486191500f, 0.745824665986376090f, + -0.666142302819983540f, 0.745696921089422760f, -0.666285300661627280f, + 0.745569148775325430f, -0.666428274005865240f, 0.745441349048781680f, + -0.666571222847440640f, 0.745313521914490520f, -0.666714147181097670f, + 0.745185667377151640f, -0.666857047001581220f, 0.745057785441466060f, + -0.666999922303637470f, 0.744929876112135350f, -0.667142773082013310f, + 0.744801939393862630f, -0.667285599331456370f, 0.744673975291351710f, + -0.667428401046715520f, 0.744545983809307370f, -0.667571178222540310f, + 0.744417964952435620f, -0.667713930853681030f, 0.744289918725443260f, + -0.667856658934889320f, 0.744161845133038180f, -0.667999362460917400f, + 0.744033744179929290f, -0.668142041426518450f, 0.743905615870826490f, + -0.668284695826446670f, 0.743777460210440890f, -0.668427325655456820f, + 0.743649277203484060f, -0.668569930908304970f, 0.743521066854669120f, + -0.668712511579747980f, 0.743392829168709970f, -0.668855067664543610f, + 0.743264564150321600f, -0.668997599157450270f, 0.743136271804219820f, + -0.669140106053227600f, 0.743007952135121720f, -0.669282588346636010f, + 0.742879605147745200f, -0.669425046032436910f, 0.742751230846809050f, + -0.669567479105392490f, 0.742622829237033490f, -0.669709887560265840f, + 0.742494400323139180f, -0.669852271391821020f, 0.742365944109848460f, + -0.669994630594823000f, 0.742237460601884000f, -0.670136965164037650f, + 0.742108949803969910f, -0.670279275094231800f, 0.741980411720831070f, + -0.670421560380173090f, 0.741851846357193480f, -0.670563821016630040f, + 0.741723253717784140f, -0.670706056998372160f, 0.741594633807331150f, + -0.670848268320169640f, 0.741465986630563290f, -0.670990454976794220f, + 0.741337312192210660f, -0.671132616963017740f, 0.741208610497004260f, + -0.671274754273613490f, 0.741079881549676080f, -0.671416866903355450f, + 0.740951125354959110f, -0.671558954847018330f, 0.740822341917587330f, + -0.671701018099378320f, 0.740693531242295760f, -0.671843056655211930f, + 0.740564693333820250f, -0.671985070509296900f, 0.740435828196898020f, + -0.672127059656411730f, 0.740306935836266940f, -0.672269024091335930f, + 0.740178016256666240f, -0.672410963808849790f, 0.740049069462835550f, + -0.672552878803734710f, 0.739920095459516200f, -0.672694769070772860f, + 0.739791094251449950f, -0.672836634604747300f, 0.739662065843380010f, + -0.672978475400442090f, 0.739533010240050250f, -0.673120291452642070f, + 0.739403927446205760f, -0.673262082756132970f, 0.739274817466592520f, + -0.673403849305701740f, 0.739145680305957510f, -0.673545591096136100f, + 0.739016515969048720f, -0.673687308122224330f, 0.738887324460615110f, + -0.673829000378756040f, 0.738758105785406900f, -0.673970667860521620f, + 0.738628859948174840f, -0.674112310562312360f, 0.738499586953671130f, + -0.674253928478920410f, 0.738370286806648620f, -0.674395521605139050f, + 0.738240959511861310f, -0.674537089935762000f, 0.738111605074064260f, + -0.674678633465584540f, 0.737982223498013570f, -0.674820152189402170f, + 0.737852814788465980f, -0.674961646102011930f, 0.737723378950179700f, + -0.675103115198211420f, 0.737593915987913570f, -0.675244559472799270f, + 0.737464425906427580f, -0.675385978920574840f, 0.737334908710482910f, + -0.675527373536338520f, 0.737205364404841190f, -0.675668743314891910f, + 0.737075792994265730f, -0.675810088251036940f, 0.736946194483520280f, + -0.675951408339577010f, 0.736816568877369900f, -0.676092703575315920f, + 0.736686916180580460f, -0.676233973953058950f, 0.736557236397919150f, + -0.676375219467611590f, 0.736427529534153690f, -0.676516440113781090f, + 0.736297795594053170f, -0.676657635886374950f, 0.736168034582387330f, + -0.676798806780201770f, 0.736038246503927350f, -0.676939952790071130f, + 0.735908431363445190f, -0.677081073910793530f, 0.735778589165713590f, + -0.677222170137180330f, 0.735648719915506510f, -0.677363241464043920f, + 0.735518823617598900f, -0.677504287886197430f, 0.735388900276766730f, + -0.677645309398454910f, 0.735258949897786840f, -0.677786305995631500f, + 0.735128972485437180f, -0.677927277672543020f, 0.734998968044496710f, + -0.678068224424006600f, 0.734868936579745170f, -0.678209146244839860f, + 0.734738878095963500f, -0.678350043129861470f, 0.734608792597933550f, + -0.678490915073891140f, 0.734478680090438370f, -0.678631762071749360f, + 0.734348540578261600f, -0.678772584118257690f, 0.734218374066188280f, + -0.678913381208238410f, 0.734088180559004040f, -0.679054153336514870f, + 0.733957960061495940f, -0.679194900497911200f, 0.733827712578451700f, + -0.679335622687252560f, 0.733697438114660370f, -0.679476319899364970f, + 0.733567136674911360f, -0.679616992129075560f, 0.733436808263995710f, + -0.679757639371212030f, 0.733306452886705260f, -0.679898261620603290f, + 0.733176070547832740f, -0.680038858872078930f, 0.733045661252172080f, + -0.680179431120469750f, 0.732915225004517780f, -0.680319978360607200f, + 0.732784761809665790f, -0.680460500587323880f, 0.732654271672412820f, + -0.680600997795453020f, 0.732523754597556700f, -0.680741469979829090f, + 0.732393210589896040f, -0.680881917135287230f, 0.732262639654230770f, + -0.681022339256663670f, 0.732132041795361290f, -0.681162736338795430f, + 0.732001417018089630f, -0.681303108376520530f, 0.731870765327218290f, + -0.681443455364677870f, 0.731740086727550980f, -0.681583777298107480f, + 0.731609381223892630f, -0.681724074171649710f, 0.731478648821048520f, + -0.681864345980146670f, 0.731347889523825570f, -0.682004592718440830f, + 0.731217103337031270f, -0.682144814381375640f, 0.731086290265474340f, + -0.682285010963795570f, 0.730955450313964360f, -0.682425182460546060f, + 0.730824583487312160f, -0.682565328866473250f, 0.730693689790329000f, + -0.682705450176424590f, 0.730562769227827590f, -0.682845546385248080f, + 0.730431821804621520f, -0.682985617487792740f, 0.730300847525525490f, + -0.683125663478908680f, 0.730169846395354870f, -0.683265684353446700f, + 0.730038818418926260f, -0.683405680106258680f, 0.729907763601057140f, + -0.683545650732197530f, 0.729776681946566090f, -0.683685596226116580f, + 0.729645573460272480f, -0.683825516582870720f, 0.729514438146997010f, + -0.683965411797315400f, 0.729383276011561050f, -0.684105281864307080f, + 0.729252087058786970f, -0.684245126778703080f, 0.729120871293498230f, + -0.684384946535361750f, 0.728989628720519420f, -0.684524741129142300f, + 0.728858359344675800f, -0.684664510554904960f, 0.728727063170793830f, + -0.684804254807510620f, 0.728595740203700770f, -0.684943973881821490f, + 0.728464390448225200f, -0.685083667772700360f, 0.728333013909196360f, + -0.685223336475011210f, 0.728201610591444610f, -0.685362979983618730f, + 0.728070180499801210f, -0.685502598293388550f, 0.727938723639098620f, + -0.685642191399187470f, 0.727807240014169960f, -0.685781759295883030f, + 0.727675729629849610f, -0.685921301978343560f, 0.727544192490972800f, + -0.686060819441438710f, 0.727412628602375770f, -0.686200311680038590f, + 0.727281037968895870f, -0.686339778689014520f, 0.727149420595371020f, + -0.686479220463238950f, 0.727017776486640680f, -0.686618636997584630f, + 0.726886105647544970f, -0.686758028286925890f, 0.726754408082925020f, + -0.686897394326137610f, 0.726622683797622850f, -0.687036735110095660f, + 0.726490932796481910f, -0.687176050633676820f, 0.726359155084346010f, + -0.687315340891759050f, 0.726227350666060370f, -0.687454605879221030f, + 0.726095519546471000f, -0.687593845590942170f, 0.725963661730424930f, + -0.687733060021803230f, 0.725831777222770370f, -0.687872249166685550f, + 0.725699866028356120f, -0.688011413020471640f, 0.725567928152032300f, + -0.688150551578044830f, 0.725435963598649810f, -0.688289664834289330f, + 0.725303972373060770f, -0.688428752784090440f, 0.725171954480117950f, + -0.688567815422334250f, 0.725039909924675370f, -0.688706852743907750f, + 0.724907838711587820f, -0.688845864743699020f, 0.724775740845711280f, + -0.688984851416597040f, 0.724643616331902550f, -0.689123812757491570f, + 0.724511465175019630f, -0.689262748761273470f, 0.724379287379921190f, + -0.689401659422834270f, 0.724247082951467000f, -0.689540544737066830f, + 0.724114851894517850f, -0.689679404698864800f, 0.723982594213935520f, + -0.689818239303122470f, 0.723850309914582880f, -0.689957048544735390f, + 0.723717999001323500f, -0.690095832418599950f, 0.723585661479022150f, + -0.690234590919613370f, 0.723453297352544380f, -0.690373324042674040f, + 0.723320906626756970f, -0.690512031782681060f, 0.723188489306527460f, + -0.690650714134534600f, 0.723056045396724410f, -0.690789371093135650f, + 0.722923574902217700f, -0.690928002653386160f, 0.722791077827877550f, + -0.691066608810189220f, 0.722658554178575610f, -0.691205189558448450f, + 0.722526003959184540f, -0.691343744893068710f, 0.722393427174577550f, + -0.691482274808955850f, 0.722260823829629310f, -0.691620779301016290f, + 0.722128193929215350f, -0.691759258364157750f, 0.721995537478211880f, + -0.691897711993288760f, 0.721862854481496340f, -0.692036140183318720f, + 0.721730144943947160f, -0.692174542929158140f, 0.721597408870443770f, + -0.692312920225718220f, 0.721464646265866370f, -0.692451272067911130f, + 0.721331857135096290f, -0.692589598450650380f, 0.721199041483015720f, + -0.692727899368849820f, 0.721066199314508110f, -0.692866174817424630f, + 0.720933330634457530f, -0.693004424791290870f, 0.720800435447749190f, + -0.693142649285365400f, 0.720667513759269520f, -0.693280848294566040f, + 0.720534565573905270f, -0.693419021813811760f, 0.720401590896544760f, + -0.693557169838022290f, 0.720268589732077190f, -0.693695292362118240f, + 0.720135562085392420f, -0.693833389381021350f, 0.720002507961381650f, + -0.693971460889654000f, 0.719869427364936860f, -0.694109506882939820f, + 0.719736320300951030f, -0.694247527355803310f, 0.719603186774318120f, + -0.694385522303169740f, 0.719470026789932990f, -0.694523491719965520f, + 0.719336840352691740f, -0.694661435601117820f, 0.719203627467491220f, + -0.694799353941554900f, 0.719070388139229190f, -0.694937246736205830f, + 0.718937122372804490f, -0.695075113980000880f, 0.718803830173116890f, + -0.695212955667870780f, 0.718670511545067230f, -0.695350771794747690f, + 0.718537166493557370f, -0.695488562355564440f, 0.718403795023489830f, + -0.695626327345254870f, 0.718270397139768260f, -0.695764066758753690f, + 0.718136972847297490f, -0.695901780590996830f, 0.718003522150983180f, + -0.696039468836920690f, 0.717870045055731710f, -0.696177131491462990f, + 0.717736541566450950f, -0.696314768549562090f, 0.717603011688049080f, + -0.696452380006157830f, 0.717469455425435830f, -0.696589965856190370f, + 0.717335872783521730f, -0.696727526094601200f, 0.717202263767218070f, + -0.696865060716332470f, 0.717068628381437480f, -0.697002569716327460f, + 0.716934966631093130f, -0.697140053089530420f, 0.716801278521099540f, + -0.697277510830886520f, 0.716667564056371890f, -0.697414942935341790f, + 0.716533823241826680f, -0.697552349397843160f, 0.716400056082381000f, + -0.697689730213338800f, 0.716266262582953120f, -0.697827085376777290f, + 0.716132442748462330f, -0.697964414883108670f, 0.715998596583828690f, + -0.698101718727283770f, 0.715864724093973500f, -0.698238996904254280f, + 0.715730825283818590f, -0.698376249408972920f, 0.715596900158287470f, + -0.698513476236393040f, 0.715462948722303760f, -0.698650677381469460f, + 0.715328970980792620f, -0.698787852839157670f, 0.715194966938680120f, + -0.698925002604414150f, 0.715060936600893090f, -0.699062126672196140f, + 0.714926879972359490f, -0.699199225037462120f, 0.714792797058008240f, + -0.699336297695171140f, 0.714658687862769090f, -0.699473344640283770f, + 0.714524552391572860f, -0.699610365867761040f, 0.714390390649351390f, + -0.699747361372564990f, 0.714256202641037510f, -0.699884331149658760f, + 0.714121988371564820f, -0.700021275194006250f, 0.713987747845867830f, + -0.700158193500572730f, 0.713853481068882470f, -0.700295086064323780f, + 0.713719188045545240f, -0.700431952880226420f, 0.713584868780793640f, + -0.700568793943248340f, 0.713450523279566260f, -0.700705609248358450f, + 0.713316151546802610f, -0.700842398790526120f, 0.713181753587443180f, + -0.700979162564722370f, 0.713047329406429340f, -0.701115900565918660f, + 0.712912879008703480f, -0.701252612789087460f, 0.712778402399208980f, + -0.701389299229202230f, 0.712643899582890210f, -0.701525959881237340f, + 0.712509370564692320f, -0.701662594740168450f, 0.712374815349561710f, + -0.701799203800971720f, 0.712240233942445510f, -0.701935787058624360f, + 0.712105626348291890f, -0.702072344508104630f, 0.711970992572050100f, + -0.702208876144391870f, 0.711836332618670080f, -0.702345381962465880f, + 0.711701646493102970f, -0.702481861957308000f, 0.711566934200300700f, + -0.702618316123900130f, 0.711432195745216430f, -0.702754744457225300f, + 0.711297431132803970f, -0.702891146952267400f, 0.711162640368018350f, + -0.703027523604011220f, 0.711027823455815280f, -0.703163874407442770f, + 0.710892980401151680f, -0.703300199357548730f, 0.710758111208985350f, + -0.703436498449316660f, 0.710623215884275020f, -0.703572771677735580f, + 0.710488294431980470f, -0.703709019037794810f, 0.710353346857062420f, + -0.703845240524484940f, 0.710218373164482220f, -0.703981436132797620f, + 0.710083373359202800f, -0.704117605857725310f, 0.709948347446187400f, + -0.704253749694261470f, 0.709813295430400840f, -0.704389867637400410f, + 0.709678217316808580f, -0.704525959682137380f, 0.709543113110376770f, + -0.704662025823468820f, 0.709407982816072980f, -0.704798066056391950f, + 0.709272826438865690f, -0.704934080375904880f, 0.709137643983724030f, + -0.705070068777006840f, 0.709002435455618250f, -0.705206031254697830f, + 0.708867200859519820f, -0.705341967803978840f, 0.708731940200400650f, + -0.705477878419852100f, 0.708596653483234080f, -0.705613763097320490f, + 0.708461340712994160f, -0.705749621831387790f, 0.708326001894655890f, + -0.705885454617058980f, 0.708190637033195400f, -0.706021261449339740f, + 0.708055246133589500f, -0.706157042323237060f, 0.707919829200816310f, + -0.706292797233758480f, 0.707784386239854620f, -0.706428526175912790f, + 0.707648917255684350f, -0.706564229144709510f, 0.707513422253286280f, + -0.706699906135159430f, 0.707377901237642100f, -0.706835557142273750f, + 0.707242354213734710f, -0.706971182161065360f, 0.707106781186547570f, + -0.707106781186547460f, 0.706971182161065360f, -0.707242354213734600f, + 0.706835557142273860f, -0.707377901237642100f, 0.706699906135159430f, + -0.707513422253286170f, 0.706564229144709620f, -0.707648917255684350f, + 0.706428526175912790f, -0.707784386239854620f, 0.706292797233758480f, + -0.707919829200816310f, 0.706157042323237060f, -0.708055246133589500f, + 0.706021261449339740f, -0.708190637033195290f, 0.705885454617058980f, + -0.708326001894655780f, 0.705749621831387790f, -0.708461340712994050f, + 0.705613763097320490f, -0.708596653483234080f, 0.705477878419852210f, + -0.708731940200400650f, 0.705341967803978950f, -0.708867200859519820f, + 0.705206031254697830f, -0.709002435455618250f, 0.705070068777006840f, + -0.709137643983723920f, 0.704934080375904990f, -0.709272826438865580f, + 0.704798066056391950f, -0.709407982816072980f, 0.704662025823468930f, + -0.709543113110376770f, 0.704525959682137380f, -0.709678217316808470f, + 0.704389867637400410f, -0.709813295430400840f, 0.704253749694261580f, + -0.709948347446187400f, 0.704117605857725430f, -0.710083373359202690f, + 0.703981436132797730f, -0.710218373164482220f, 0.703845240524484940f, + -0.710353346857062310f, 0.703709019037794810f, -0.710488294431980470f, + 0.703572771677735580f, -0.710623215884275020f, 0.703436498449316770f, + -0.710758111208985350f, 0.703300199357548730f, -0.710892980401151680f, + 0.703163874407442770f, -0.711027823455815280f, 0.703027523604011220f, + -0.711162640368018350f, 0.702891146952267400f, -0.711297431132803970f, + 0.702754744457225300f, -0.711432195745216430f, 0.702618316123900130f, + -0.711566934200300700f, 0.702481861957308000f, -0.711701646493102970f, + 0.702345381962465880f, -0.711836332618670080f, 0.702208876144391870f, + -0.711970992572049990f, 0.702072344508104740f, -0.712105626348291890f, + 0.701935787058624360f, -0.712240233942445510f, 0.701799203800971720f, + -0.712374815349561710f, 0.701662594740168570f, -0.712509370564692320f, + 0.701525959881237450f, -0.712643899582890210f, 0.701389299229202230f, + -0.712778402399208870f, 0.701252612789087460f, -0.712912879008703370f, + 0.701115900565918660f, -0.713047329406429230f, 0.700979162564722480f, + -0.713181753587443070f, 0.700842398790526230f, -0.713316151546802610f, + 0.700705609248358450f, -0.713450523279566150f, 0.700568793943248450f, + -0.713584868780793520f, 0.700431952880226420f, -0.713719188045545130f, + 0.700295086064323780f, -0.713853481068882470f, 0.700158193500572730f, + -0.713987747845867830f, 0.700021275194006360f, -0.714121988371564710f, + 0.699884331149658760f, -0.714256202641037400f, 0.699747361372564990f, + -0.714390390649351390f, 0.699610365867761040f, -0.714524552391572860f, + 0.699473344640283770f, -0.714658687862768980f, 0.699336297695171250f, + -0.714792797058008130f, 0.699199225037462120f, -0.714926879972359370f, + 0.699062126672196140f, -0.715060936600892980f, 0.698925002604414150f, + -0.715194966938680010f, 0.698787852839157790f, -0.715328970980792620f, + 0.698650677381469580f, -0.715462948722303650f, 0.698513476236393040f, + -0.715596900158287360f, 0.698376249408972920f, -0.715730825283818590f, + 0.698238996904254390f, -0.715864724093973390f, 0.698101718727283880f, + -0.715998596583828690f, 0.697964414883108790f, -0.716132442748462330f, + 0.697827085376777290f, -0.716266262582953120f, 0.697689730213338800f, + -0.716400056082380890f, 0.697552349397843270f, -0.716533823241826570f, + 0.697414942935341790f, -0.716667564056371890f, 0.697277510830886630f, + -0.716801278521099540f, 0.697140053089530530f, -0.716934966631093130f, + 0.697002569716327460f, -0.717068628381437480f, 0.696865060716332470f, + -0.717202263767218070f, 0.696727526094601200f, -0.717335872783521730f, + 0.696589965856190370f, -0.717469455425435830f, 0.696452380006157830f, + -0.717603011688049080f, 0.696314768549562200f, -0.717736541566450840f, + 0.696177131491462990f, -0.717870045055731710f, 0.696039468836920690f, + -0.718003522150983060f, 0.695901780590996830f, -0.718136972847297490f, + 0.695764066758753800f, -0.718270397139768260f, 0.695626327345254870f, + -0.718403795023489720f, 0.695488562355564440f, -0.718537166493557370f, + 0.695350771794747800f, -0.718670511545067230f, 0.695212955667870890f, + -0.718803830173116890f, 0.695075113980000880f, -0.718937122372804380f, + 0.694937246736205940f, -0.719070388139229190f, 0.694799353941554900f, + -0.719203627467491220f, 0.694661435601117930f, -0.719336840352691740f, + 0.694523491719965520f, -0.719470026789932990f, 0.694385522303169860f, + -0.719603186774318000f, 0.694247527355803310f, -0.719736320300951030f, + 0.694109506882939820f, -0.719869427364936860f, 0.693971460889654000f, + -0.720002507961381650f, 0.693833389381021350f, -0.720135562085392310f, + 0.693695292362118350f, -0.720268589732077080f, 0.693557169838022400f, + -0.720401590896544760f, 0.693419021813811880f, -0.720534565573905270f, + 0.693280848294566150f, -0.720667513759269410f, 0.693142649285365510f, + -0.720800435447749190f, 0.693004424791290870f, -0.720933330634457530f, + 0.692866174817424740f, -0.721066199314508110f, 0.692727899368849820f, + -0.721199041483015720f, 0.692589598450650380f, -0.721331857135096180f, + 0.692451272067911240f, -0.721464646265866370f, 0.692312920225718220f, + -0.721597408870443660f, 0.692174542929158140f, -0.721730144943947160f, + 0.692036140183318830f, -0.721862854481496340f, 0.691897711993288760f, + -0.721995537478211880f, 0.691759258364157750f, -0.722128193929215350f, + 0.691620779301016400f, -0.722260823829629310f, 0.691482274808955850f, + -0.722393427174577550f, 0.691343744893068820f, -0.722526003959184430f, + 0.691205189558448450f, -0.722658554178575610f, 0.691066608810189220f, + -0.722791077827877550f, 0.690928002653386280f, -0.722923574902217700f, + 0.690789371093135760f, -0.723056045396724410f, 0.690650714134534720f, + -0.723188489306527350f, 0.690512031782681170f, -0.723320906626756850f, + 0.690373324042674040f, -0.723453297352544380f, 0.690234590919613370f, + -0.723585661479022040f, 0.690095832418599950f, -0.723717999001323390f, + 0.689957048544735390f, -0.723850309914582880f, 0.689818239303122470f, + -0.723982594213935520f, 0.689679404698864800f, -0.724114851894517850f, + 0.689540544737066940f, -0.724247082951466890f, 0.689401659422834380f, + -0.724379287379921080f, 0.689262748761273470f, -0.724511465175019520f, + 0.689123812757491680f, -0.724643616331902550f, 0.688984851416597150f, + -0.724775740845711280f, 0.688845864743699130f, -0.724907838711587820f, + 0.688706852743907750f, -0.725039909924675370f, 0.688567815422334360f, + -0.725171954480117840f, 0.688428752784090550f, -0.725303972373060660f, + 0.688289664834289440f, -0.725435963598649810f, 0.688150551578044830f, + -0.725567928152032300f, 0.688011413020471640f, -0.725699866028356120f, + 0.687872249166685550f, -0.725831777222770370f, 0.687733060021803230f, + -0.725963661730424930f, 0.687593845590942170f, -0.726095519546470890f, + 0.687454605879221030f, -0.726227350666060260f, 0.687315340891759160f, + -0.726359155084346010f, 0.687176050633676930f, -0.726490932796481910f, + 0.687036735110095660f, -0.726622683797622850f, 0.686897394326137610f, + -0.726754408082924910f, 0.686758028286925890f, -0.726886105647544970f, + 0.686618636997584740f, -0.727017776486640680f, 0.686479220463238950f, + -0.727149420595371020f, 0.686339778689014630f, -0.727281037968895760f, + 0.686200311680038700f, -0.727412628602375770f, 0.686060819441438710f, + -0.727544192490972800f, 0.685921301978343670f, -0.727675729629849610f, + 0.685781759295883030f, -0.727807240014169960f, 0.685642191399187470f, + -0.727938723639098620f, 0.685502598293388670f, -0.728070180499801210f, + 0.685362979983618730f, -0.728201610591444500f, 0.685223336475011210f, + -0.728333013909196360f, 0.685083667772700360f, -0.728464390448225200f, + 0.684943973881821490f, -0.728595740203700770f, 0.684804254807510620f, + -0.728727063170793720f, 0.684664510554904960f, -0.728858359344675690f, + 0.684524741129142300f, -0.728989628720519310f, 0.684384946535361750f, + -0.729120871293498230f, 0.684245126778703080f, -0.729252087058786970f, + 0.684105281864307080f, -0.729383276011561050f, 0.683965411797315510f, + -0.729514438146996900f, 0.683825516582870830f, -0.729645573460272480f, + 0.683685596226116690f, -0.729776681946565970f, 0.683545650732197530f, + -0.729907763601057140f, 0.683405680106258790f, -0.730038818418926150f, + 0.683265684353446700f, -0.730169846395354870f, 0.683125663478908800f, + -0.730300847525525380f, 0.682985617487792850f, -0.730431821804621520f, + 0.682845546385248080f, -0.730562769227827590f, 0.682705450176424590f, + -0.730693689790328890f, 0.682565328866473250f, -0.730824583487312050f, + 0.682425182460546060f, -0.730955450313964360f, 0.682285010963795570f, + -0.731086290265474230f, 0.682144814381375640f, -0.731217103337031160f, + 0.682004592718440830f, -0.731347889523825460f, 0.681864345980146780f, + -0.731478648821048520f, 0.681724074171649820f, -0.731609381223892520f, + 0.681583777298107480f, -0.731740086727550980f, 0.681443455364677990f, + -0.731870765327218290f, 0.681303108376520530f, -0.732001417018089520f, + 0.681162736338795430f, -0.732132041795361290f, 0.681022339256663670f, + -0.732262639654230660f, 0.680881917135287340f, -0.732393210589896040f, + 0.680741469979829090f, -0.732523754597556590f, 0.680600997795453130f, + -0.732654271672412820f, 0.680460500587323880f, -0.732784761809665790f, + 0.680319978360607200f, -0.732915225004517780f, 0.680179431120469750f, + -0.733045661252171970f, 0.680038858872079040f, -0.733176070547832740f, + 0.679898261620603290f, -0.733306452886705260f, 0.679757639371212030f, + -0.733436808263995710f, 0.679616992129075560f, -0.733567136674911360f, + 0.679476319899365080f, -0.733697438114660260f, 0.679335622687252670f, + -0.733827712578451700f, 0.679194900497911200f, -0.733957960061495940f, + 0.679054153336514870f, -0.734088180559004040f, 0.678913381208238410f, + -0.734218374066188170f, 0.678772584118257690f, -0.734348540578261600f, + 0.678631762071749470f, -0.734478680090438370f, 0.678490915073891250f, + -0.734608792597933550f, 0.678350043129861580f, -0.734738878095963390f, + 0.678209146244839860f, -0.734868936579745060f, 0.678068224424006600f, + -0.734998968044496600f, 0.677927277672543130f, -0.735128972485437180f, + 0.677786305995631500f, -0.735258949897786730f, 0.677645309398454910f, + -0.735388900276766620f, 0.677504287886197430f, -0.735518823617598900f, + 0.677363241464044030f, -0.735648719915506400f, 0.677222170137180450f, + -0.735778589165713480f, 0.677081073910793530f, -0.735908431363445190f, + 0.676939952790071240f, -0.736038246503927350f, 0.676798806780201770f, + -0.736168034582387330f, 0.676657635886374950f, -0.736297795594053060f, + 0.676516440113781090f, -0.736427529534153690f, 0.676375219467611700f, + -0.736557236397919150f, 0.676233973953058950f, -0.736686916180580460f, + 0.676092703575316030f, -0.736816568877369790f, 0.675951408339577010f, + -0.736946194483520170f, 0.675810088251037060f, -0.737075792994265620f, + 0.675668743314891910f, -0.737205364404841190f, 0.675527373536338630f, + -0.737334908710482790f, 0.675385978920574950f, -0.737464425906427580f, + 0.675244559472799270f, -0.737593915987913460f, 0.675103115198211530f, + -0.737723378950179590f, 0.674961646102012040f, -0.737852814788465980f, + 0.674820152189402280f, -0.737982223498013570f, 0.674678633465584540f, + -0.738111605074064260f, 0.674537089935762110f, -0.738240959511861310f, + 0.674395521605139050f, -0.738370286806648510f, 0.674253928478920520f, + -0.738499586953671130f, 0.674112310562312360f, -0.738628859948174840f, + 0.673970667860521620f, -0.738758105785406900f, 0.673829000378756150f, + -0.738887324460615110f, 0.673687308122224330f, -0.739016515969048600f, + 0.673545591096136100f, -0.739145680305957400f, 0.673403849305701850f, + -0.739274817466592520f, 0.673262082756132970f, -0.739403927446205760f, + 0.673120291452642070f, -0.739533010240050250f, 0.672978475400442090f, + -0.739662065843379900f, 0.672836634604747410f, -0.739791094251449950f, + 0.672694769070772970f, -0.739920095459516090f, 0.672552878803734820f, + -0.740049069462835550f, 0.672410963808849900f, -0.740178016256666240f, + 0.672269024091336040f, -0.740306935836266940f, 0.672127059656411840f, + -0.740435828196898020f, 0.671985070509296900f, -0.740564693333820250f, + 0.671843056655211930f, -0.740693531242295640f, 0.671701018099378320f, + -0.740822341917587330f, 0.671558954847018330f, -0.740951125354959110f, + 0.671416866903355450f, -0.741079881549676080f, 0.671274754273613490f, + -0.741208610497004260f, 0.671132616963017850f, -0.741337312192210660f, + 0.670990454976794220f, -0.741465986630563290f, 0.670848268320169750f, + -0.741594633807331150f, 0.670706056998372160f, -0.741723253717784140f, + 0.670563821016630040f, -0.741851846357193480f, 0.670421560380173090f, + -0.741980411720830960f, 0.670279275094231910f, -0.742108949803969800f, + 0.670136965164037760f, -0.742237460601884000f, 0.669994630594823000f, + -0.742365944109848460f, 0.669852271391821130f, -0.742494400323139180f, + 0.669709887560265840f, -0.742622829237033380f, 0.669567479105392490f, + -0.742751230846809050f, 0.669425046032436910f, -0.742879605147745090f, + 0.669282588346636010f, -0.743007952135121720f, 0.669140106053227710f, + -0.743136271804219820f, 0.668997599157450270f, -0.743264564150321490f, + 0.668855067664543610f, -0.743392829168709970f, 0.668712511579748090f, + -0.743521066854669120f, 0.668569930908305080f, -0.743649277203484060f, + 0.668427325655456820f, -0.743777460210440780f, 0.668284695826446670f, + -0.743905615870826490f, 0.668142041426518560f, -0.744033744179929180f, + 0.667999362460917510f, -0.744161845133038070f, 0.667856658934889440f, + -0.744289918725443140f, 0.667713930853681140f, -0.744417964952435620f, + 0.667571178222540310f, -0.744545983809307250f, 0.667428401046715640f, + -0.744673975291351600f, 0.667285599331456480f, -0.744801939393862630f, + 0.667142773082013310f, -0.744929876112135350f, 0.666999922303637470f, + -0.745057785441465950f, 0.666857047001581220f, -0.745185667377151640f, + 0.666714147181097670f, -0.745313521914490410f, 0.666571222847440750f, + -0.745441349048781680f, 0.666428274005865350f, -0.745569148775325430f, + 0.666285300661627390f, -0.745696921089422760f, 0.666142302819983540f, + -0.745824665986375980f, 0.665999280486191500f, -0.745952383461488180f, + 0.665856233665509720f, -0.746080073510063780f, 0.665713162363197660f, + -0.746207736127407650f, 0.665570066584515560f, -0.746335371308826320f, + 0.665426946334724660f, -0.746462979049626770f, 0.665283801619087180f, + -0.746590559345117310f, 0.665140632442866140f, -0.746718112190607020f, + 0.664997438811325340f, -0.746845637581406540f, 0.664854220729729660f, + -0.746973135512826740f, 0.664710978203344900f, -0.747100605980180130f, + 0.664567711237437520f, -0.747228048978779920f, 0.664424419837275180f, + -0.747355464503940190f, 0.664281104008126230f, -0.747482852550976570f, + 0.664137763755260010f, -0.747610213115205150f, 0.663994399083946640f, + -0.747737546191943330f, 0.663851009999457340f, -0.747864851776509410f, + 0.663707596507064120f, -0.747992129864222700f, 0.663564158612039880f, + -0.748119380450403490f, 0.663420696319658280f, -0.748246603530373420f, + 0.663277209635194100f, -0.748373799099454560f, 0.663133698563923010f, + -0.748500967152970430f, 0.662990163111121470f, -0.748628107686245330f, + 0.662846603282066900f, -0.748755220694604760f, 0.662703019082037440f, + -0.748882306173375030f, 0.662559410516312400f, -0.749009364117883770f, + 0.662415777590171780f, -0.749136394523459260f, 0.662272120308896590f, + -0.749263397385431020f, 0.662128438677768720f, -0.749390372699129560f, + 0.661984732702071030f, -0.749517320459886170f, 0.661841002387086870f, + -0.749644240663033480f, 0.661697247738101120f, -0.749771133303904990f, + 0.661553468760399000f, -0.749897998377835220f, 0.661409665459266940f, + -0.750024835880159780f, 0.661265837839992270f, -0.750151645806214960f, + 0.661121985907862970f, -0.750278428151338610f, 0.660978109668168060f, + -0.750405182910869220f, 0.660834209126197610f, -0.750531910080146410f, + 0.660690284287242300f, -0.750658609654510590f, 0.660546335156593890f, + -0.750785281629303580f, 0.660402361739545030f, -0.750911925999867890f, + 0.660258364041389050f, -0.751038542761547250f, 0.660114342067420480f, + -0.751165131909686370f, 0.659970295822934540f, -0.751291693439630870f, + 0.659826225313227430f, -0.751418227346727360f, 0.659682130543596150f, + -0.751544733626323570f, 0.659538011519338770f, -0.751671212273768430f, + 0.659393868245753970f, -0.751797663284411440f, 0.659249700728141490f, + -0.751924086653603550f, 0.659105508971802200f, -0.752050482376696360f, + 0.658961292982037320f, -0.752176850449042700f, 0.658817052764149480f, + -0.752303190865996400f, 0.658672788323441890f, -0.752429503622912390f, + 0.658528499665218760f, -0.752555788715146390f, 0.658384186794785050f, + -0.752682046138055230f, 0.658239849717446980f, -0.752808275886996950f, + 0.658095488438511290f, -0.752934477957330150f, 0.657951102963285630f, + -0.753060652344415100f, 0.657806693297078640f, -0.753186799043612410f, + 0.657662259445200070f, -0.753312918050284330f, 0.657517801412960120f, + -0.753439009359793580f, 0.657373319205670210f, -0.753565072967504190f, + 0.657228812828642650f, -0.753691108868781210f, 0.657084282287190180f, + -0.753817117058990680f, 0.656939727586627110f, -0.753943097533499640f, + 0.656795148732268070f, -0.754069050287676120f, 0.656650545729429050f, + -0.754194975316889170f, 0.656505918583426550f, -0.754320872616508820f, + 0.656361267299578000f, -0.754446742181906330f, 0.656216591883202030f, + -0.754572584008453840f, 0.656071892339617710f, -0.754698398091524390f, + 0.655927168674145360f, -0.754824184426492240f, 0.655782420892106030f, + -0.754949943008732640f, 0.655637648998821820f, -0.755075673833621510f, + 0.655492852999615460f, -0.755201376896536550f, 0.655348032899810580f, + -0.755327052192855560f, 0.655203188704731930f, -0.755452699717958140f, + 0.655058320419704910f, -0.755578319467224540f, 0.654913428050056150f, + -0.755703911436035880f, 0.654768511601112600f, -0.755829475619774760f, + 0.654623571078202680f, -0.755955012013824310f, 0.654478606486655350f, + -0.756080520613569120f, 0.654333617831800550f, -0.756206001414394540f, + 0.654188605118969040f, -0.756331454411686920f, 0.654043568353492640f, + -0.756456879600833630f, 0.653898507540703890f, -0.756582276977223470f, + 0.653753422685936170f, -0.756707646536245670f, 0.653608313794523890f, + -0.756832988273290820f, 0.653463180871802330f, -0.756958302183750490f, + 0.653318023923107670f, -0.757083588263017140f, 0.653172842953776760f, + -0.757208846506484460f, 0.653027637969147650f, -0.757334076909547130f, + 0.652882408974558960f, -0.757459279467600720f, 0.652737155975350420f, + -0.757584454176041810f, 0.652591878976862550f, -0.757709601030268080f, + 0.652446577984436840f, -0.757834720025678310f, 0.652301253003415460f, + -0.757959811157672300f, 0.652155904039141700f, -0.758084874421650620f, + 0.652010531096959500f, -0.758209909813015280f, 0.651865134182214030f, + -0.758334917327168960f, 0.651719713300251020f, -0.758459896959515320f, + 0.651574268456417080f, -0.758584848705459500f, 0.651428799656059820f, + -0.758709772560407390f, 0.651283306904527850f, -0.758834668519765660f, + 0.651137790207170330f, -0.758959536578942440f, 0.650992249569337660f, + -0.759084376733346500f, 0.650846684996380990f, -0.759209188978387960f, + 0.650701096493652040f, -0.759333973309477940f, 0.650555484066503990f, + -0.759458729722028210f, 0.650409847720290420f, -0.759583458211452010f, + 0.650264187460365960f, -0.759708158773163440f, 0.650118503292086200f, + -0.759832831402577400f, 0.649972795220807530f, -0.759957476095110330f, + 0.649827063251887100f, -0.760082092846179220f, 0.649681307390683190f, + -0.760206681651202420f, 0.649535527642554730f, -0.760331242505599030f, + 0.649389724012861770f, -0.760455775404789260f, 0.649243896506965010f, + -0.760580280344194340f, 0.649098045130226060f, -0.760704757319236920f, + 0.648952169888007410f, -0.760829206325340010f, 0.648806270785672550f, + -0.760953627357928040f, 0.648660347828585840f, -0.761078020412426560f, + 0.648514401022112550f, -0.761202385484261780f, 0.648368430371618400f, + -0.761326722568861250f, 0.648222435882470420f, -0.761451031661653510f, + 0.648076417560036530f, -0.761575312758068000f, 0.647930375409685460f, + -0.761699565853535270f, 0.647784309436786550f, -0.761823790943486840f, + 0.647638219646710420f, -0.761947988023355390f, 0.647492106044828100f, + -0.762072157088574560f, 0.647345968636512060f, -0.762196298134578900f, + 0.647199807427135230f, -0.762320411156804160f, 0.647053622422071650f, + -0.762444496150687100f, 0.646907413626696020f, -0.762568553111665380f, + 0.646761181046383920f, -0.762692582035177870f, 0.646614924686512050f, + -0.762816582916664320f, 0.646468644552457890f, -0.762940555751565720f, + 0.646322340649599590f, -0.763064500535323710f, 0.646176012983316390f, + -0.763188417263381270f, 0.646029661558988330f, -0.763312305931182380f, + 0.645883286381996440f, -0.763436166534172010f, 0.645736887457722290f, + -0.763559999067796150f, 0.645590464791548800f, -0.763683803527501870f, + 0.645444018388859230f, -0.763807579908737160f, 0.645297548255038380f, + -0.763931328206951090f, 0.645151054395471270f, -0.764055048417593860f, + 0.645004536815544040f, -0.764178740536116670f, 0.644857995520643710f, + -0.764302404557971720f, 0.644711430516158420f, -0.764426040478612070f, + 0.644564841807476750f, -0.764549648293492150f, 0.644418229399988380f, + -0.764673227998067140f, 0.644271593299083900f, -0.764796779587793460f, + 0.644124933510154540f, -0.764920303058128410f, 0.643978250038592660f, + -0.765043798404530410f, 0.643831542889791500f, -0.765167265622458960f, + 0.643684812069144960f, -0.765290704707374260f, 0.643538057582047850f, + -0.765414115654738160f, 0.643391279433895960f, -0.765537498460013070f, + 0.643244477630085850f, -0.765660853118662390f, 0.643097652176015110f, + -0.765784179626150970f, 0.642950803077082080f, -0.765907477977944230f, + 0.642803930338686100f, -0.766030748169509000f, 0.642657033966226860f, + -0.766153990196312810f, 0.642510113965105710f, -0.766277204053824710f, + 0.642363170340724320f, -0.766400389737514120f, 0.642216203098485370f, + -0.766523547242852100f, 0.642069212243792540f, -0.766646676565310380f, + 0.641922197782050170f, -0.766769777700361920f, 0.641775159718663500f, + -0.766892850643480670f, 0.641628098059038860f, -0.767015895390141480f, + 0.641481012808583160f, -0.767138911935820400f, 0.641333903972704290f, + -0.767261900275994390f, 0.641186771556811250f, -0.767384860406141620f, + 0.641039615566313390f, -0.767507792321741270f, 0.640892436006621380f, + -0.767630696018273270f, 0.640745232883146440f, -0.767753571491219030f, + 0.640598006201301030f, -0.767876418736060610f, 0.640450755966498140f, + -0.767999237748281270f, 0.640303482184151670f, -0.768122028523365310f, + 0.640156184859676620f, -0.768244791056798220f, 0.640008863998488440f, + -0.768367525344066270f, 0.639861519606004010f, -0.768490231380656750f, + 0.639714151687640450f, -0.768612909162058270f, 0.639566760248816420f, + -0.768735558683760310f, 0.639419345294950700f, -0.768858179941253270f, + 0.639271906831463510f, -0.768980772930028870f, 0.639124444863775730f, + -0.769103337645579590f, 0.638976959397309140f, -0.769225874083399260f, + 0.638829450437486400f, -0.769348382238982280f, 0.638681917989730840f, + -0.769470862107824560f, 0.638534362059466790f, -0.769593313685422940f, + 0.638386782652119680f, -0.769715736967275020f, 0.638239179773115390f, + -0.769838131948879840f, 0.638091553427880930f, -0.769960498625737230f, + 0.637943903621844170f, -0.770082836993347900f, 0.637796230360433540f, + -0.770205147047214100f, 0.637648533649078810f, -0.770327428782838770f, + 0.637500813493210310f, -0.770449682195725960f, 0.637353069898259130f, + -0.770571907281380700f, 0.637205302869657600f, -0.770694104035309140f, + 0.637057512412838590f, -0.770816272453018430f, 0.636909698533235870f, + -0.770938412530016940f, 0.636761861236284200f, -0.771060524261813710f, + 0.636614000527419230f, -0.771182607643919220f, 0.636466116412077180f, + -0.771304662671844720f, 0.636318208895695570f, -0.771426689341102590f, + 0.636170277983712170f, -0.771548687647206300f, 0.636022323681566300f, + -0.771670657585670330f, 0.635874345994697720f, -0.771792599152010150f, + 0.635726344928547180f, -0.771914512341742350f, 0.635578320488556230f, + -0.772036397150384410f, 0.635430272680167160f, -0.772158253573455240f, + 0.635282201508823530f, -0.772280081606474320f, 0.635134106979969300f, + -0.772401881244962340f, 0.634985989099049460f, -0.772523652484441330f, + 0.634837847871510100f, -0.772645395320433860f, 0.634689683302797850f, + -0.772767109748463740f, 0.634541495398360130f, -0.772888795764056220f, + 0.634393284163645490f, -0.773010453362736990f, 0.634245049604103330f, + -0.773132082540033070f, 0.634096791725183740f, -0.773253683291472590f, + 0.633948510532337810f, -0.773375255612584470f, 0.633800206031017280f, + -0.773496799498899050f, 0.633651878226674900f, -0.773618314945947460f, + 0.633503527124764320f, -0.773739801949261840f, 0.633355152730740060f, + -0.773861260504375540f, 0.633206755050057190f, -0.773982690606822790f, + 0.633058334088172250f, -0.774104092252138940f, 0.632909889850541860f, + -0.774225465435860570f, 0.632761422342624000f, -0.774346810153525020f, + 0.632612931569877520f, -0.774468126400670860f, 0.632464417537761840f, + -0.774589414172837550f, 0.632315880251737680f, -0.774710673465565550f, + 0.632167319717266030f, -0.774831904274396850f, 0.632018735939809060f, + -0.774953106594873820f, 0.631870128924829850f, -0.775074280422540450f, + 0.631721498677792370f, -0.775195425752941310f, 0.631572845204161130f, + -0.775316542581622410f, 0.631424168509401860f, -0.775437630904130430f, + 0.631275468598980870f, -0.775558690716013580f, 0.631126745478365340f, + -0.775679722012820540f, 0.630977999153023660f, -0.775800724790101540f, + 0.630829229628424470f, -0.775921699043407580f, 0.630680436910038060f, + -0.776042644768290770f, 0.630531621003334600f, -0.776163561960304340f, + 0.630382781913785940f, -0.776284450615002400f, 0.630233919646864480f, + -0.776405310727940390f, 0.630085034208043290f, -0.776526142294674430f, + 0.629936125602796550f, -0.776646945310762060f, 0.629787193836599200f, + -0.776767719771761510f, 0.629638238914927100f, -0.776888465673232440f, + 0.629489260843256740f, -0.777009183010735290f, 0.629340259627065750f, + -0.777129871779831620f, 0.629191235271832410f, -0.777250531976084070f, + 0.629042187783036000f, -0.777371163595056200f, 0.628893117166156480f, + -0.777491766632312900f, 0.628744023426674790f, -0.777612341083419920f, + 0.628594906570072660f, -0.777732886943944050f, 0.628445766601832710f, + -0.777853404209453040f, 0.628296603527438440f, -0.777973892875515990f, + 0.628147417352374120f, -0.778094352937702790f, 0.627998208082124810f, + -0.778214784391584420f, 0.627848975722176570f, -0.778335187232733090f, + 0.627699720278016240f, -0.778455561456721900f, 0.627550441755131530f, + -0.778575907059124940f, 0.627401140159011160f, -0.778696224035517530f, + 0.627251815495144190f, -0.778816512381475870f, 0.627102467769021010f, + -0.778936772092577500f, 0.626953096986132770f, -0.779057003164400630f, + 0.626803703151971310f, -0.779177205592524680f, 0.626654286272029460f, + -0.779297379372530300f, 0.626504846351800930f, -0.779417524499998900f, + 0.626355383396779990f, -0.779537640970513150f, 0.626205897412462130f, + -0.779657728779656780f, 0.626056388404343520f, -0.779777787923014440f, + 0.625906856377921210f, -0.779897818396171890f, 0.625757301338692900f, + -0.780017820194715990f, 0.625607723292157410f, -0.780137793314234500f, + 0.625458122243814360f, -0.780257737750316590f, 0.625308498199164010f, + -0.780377653498552040f, 0.625158851163707730f, -0.780497540554531910f, + 0.625009181142947460f, -0.780617398913848290f, 0.624859488142386450f, + -0.780737228572094380f, 0.624709772167528100f, -0.780857029524864470f, + 0.624560033223877320f, -0.780976801767753750f, 0.624410271316939380f, + -0.781096545296358410f, 0.624260486452220650f, -0.781216260106276090f, + 0.624110678635228510f, -0.781335946193104870f, 0.623960847871470770f, + -0.781455603552444480f, 0.623810994166456130f, -0.781575232179895550f, + 0.623661117525694640f, -0.781694832071059390f, 0.623511217954696550f, + -0.781814403221538830f, 0.623361295458973340f, -0.781933945626937630f, + 0.623211350044037270f, -0.782053459282860300f, 0.623061381715401370f, + -0.782172944184912900f, 0.622911390478579460f, -0.782292400328702400f, + 0.622761376339086460f, -0.782411827709836420f, 0.622611339302437730f, + -0.782531226323924240f, 0.622461279374150080f, -0.782650596166575730f, + 0.622311196559740320f, -0.782769937233402050f, 0.622161090864726930f, + -0.782889249520015480f, 0.622010962294628600f, -0.783008533022029110f, + 0.621860810854965360f, -0.783127787735057310f, 0.621710636551257690f, + -0.783247013654715380f, 0.621560439389027270f, -0.783366210776619720f, + 0.621410219373796150f, -0.783485379096387820f, 0.621259976511087660f, + -0.783604518609638200f, 0.621109710806425740f, -0.783723629311990470f, + 0.620959422265335180f, -0.783842711199065230f, 0.620809110893341900f, + -0.783961764266484010f, 0.620658776695972140f, -0.784080788509869950f, + 0.620508419678753360f, -0.784199783924846570f, 0.620358039847213830f, + -0.784318750507038920f, 0.620207637206882430f, -0.784437688252072720f, + 0.620057211763289210f, -0.784556597155575240f, 0.619906763521964830f, + -0.784675477213174320f, 0.619756292488440660f, -0.784794328420499230f, + 0.619605798668249390f, -0.784913150773180020f, 0.619455282066924020f, + -0.785031944266848080f, 0.619304742689998690f, -0.785150708897135560f, + 0.619154180543008410f, -0.785269444659675850f, 0.619003595631488770f, + -0.785388151550103550f, 0.618852987960976320f, -0.785506829564053930f, + 0.618702357537008640f, -0.785625478697163700f, 0.618551704365123860f, + -0.785744098945070360f, 0.618401028450860980f, -0.785862690303412600f, + 0.618250329799760250f, -0.785981252767830150f, 0.618099608417362110f, + -0.786099786333963820f, 0.617948864309208260f, -0.786218290997455550f, + 0.617798097480841140f, -0.786336766753948260f, 0.617647307937803980f, + -0.786455213599085770f, 0.617496495685640910f, -0.786573631528513230f, + 0.617345660729896940f, -0.786692020537876680f, 0.617194803076117630f, + -0.786810380622823490f, 0.617043922729849760f, -0.786928711779001700f, + 0.616893019696640790f, -0.787047014002060790f, 0.616742093982038830f, + -0.787165287287650890f, 0.616591145591593230f, -0.787283531631423620f, + 0.616440174530853650f, -0.787401747029031320f, 0.616289180805370980f, + -0.787519933476127810f, 0.616138164420696910f, -0.787638090968367450f, + 0.615987125382383870f, -0.787756219501405950f, 0.615836063695985090f, + -0.787874319070900110f, 0.615684979367054570f, -0.787992389672507950f, + 0.615533872401147430f, -0.788110431301888070f, 0.615382742803819330f, + -0.788228443954700490f, 0.615231590580626820f, -0.788346427626606230f, + 0.615080415737127460f, -0.788464382313267430f, 0.614929218278879590f, + -0.788582308010347120f, 0.614777998211442190f, -0.788700204713509660f, + 0.614626755540375050f, -0.788818072418420170f, 0.614475490271239160f, + -0.788935911120745130f, 0.614324202409595950f, -0.789053720816151880f, + 0.614172891961007990f, -0.789171501500308790f, 0.614021558931038490f, + -0.789289253168885650f, 0.613870203325251440f, -0.789406975817552810f, + 0.613718825149211830f, -0.789524669441982190f, 0.613567424408485330f, + -0.789642334037846340f, 0.613416001108638590f, -0.789759969600819070f, + 0.613264555255239150f, -0.789877576126575280f, 0.613113086853854910f, + -0.789995153610791090f, 0.612961595910055170f, -0.790112702049143300f, + 0.612810082429409710f, -0.790230221437310030f, 0.612658546417489290f, + -0.790347711770970520f, 0.612506987879865570f, -0.790465173045804880f, + 0.612355406822110760f, -0.790582605257494460f, 0.612203803249798060f, + -0.790700008401721610f, 0.612052177168501580f, -0.790817382474169660f, + 0.611900528583796070f, -0.790934727470523290f, 0.611748857501257400f, + -0.791052043386467950f, 0.611597163926462020f, -0.791169330217690090f, + 0.611445447864987110f, -0.791286587959877720f, 0.611293709322411010f, + -0.791403816608719500f, 0.611141948304312570f, -0.791521016159905220f, + 0.610990164816271770f, -0.791638186609125770f, 0.610838358863869280f, + -0.791755327952073150f, 0.610686530452686280f, -0.791872440184440470f, + 0.610534679588305320f, -0.791989523301921850f, 0.610382806276309480f, + -0.792106577300212390f, 0.610230910522282620f, -0.792223602175008310f, + 0.610078992331809620f, -0.792340597922007060f, 0.609927051710476230f, + -0.792457564536906970f, 0.609775088663868430f, -0.792574502015407580f, + 0.609623103197573730f, -0.792691410353209450f, 0.609471095317180240f, + -0.792808289546014120f, 0.609319065028276820f, -0.792925139589524260f, + 0.609167012336453210f, -0.793041960479443640f, 0.609014937247299940f, + -0.793158752211477140f, 0.608862839766408200f, -0.793275514781330630f, + 0.608710719899370420f, -0.793392248184711100f, 0.608558577651779450f, + -0.793508952417326660f, 0.608406413029229260f, -0.793625627474886190f, + 0.608254226037314490f, -0.793742273353100100f, 0.608102016681630550f, + -0.793858890047679620f, 0.607949784967773740f, -0.793975477554337170f, + 0.607797530901341140f, -0.794092035868785960f, 0.607645254487930830f, + -0.794208564986740640f, 0.607492955733141660f, -0.794325064903916520f, + 0.607340634642572930f, -0.794441535616030590f, 0.607188291221825160f, + -0.794557977118800270f, 0.607035925476499760f, -0.794674389407944550f, + 0.606883537412198580f, -0.794790772479183170f, 0.606731127034524480f, + -0.794907126328237010f, 0.606578694349081400f, -0.795023450950828050f, + 0.606426239361473550f, -0.795139746342679590f, 0.606273762077306430f, + -0.795256012499515500f, 0.606121262502186230f, -0.795372249417061190f, + 0.605968740641719790f, -0.795488457091042990f, 0.605816196501515080f, + -0.795604635517188070f, 0.605663630087180490f, -0.795720784691225090f, + 0.605511041404325550f, -0.795836904608883460f, 0.605358430458560530f, + -0.795952995265893910f, 0.605205797255496500f, -0.796069056657987990f, + 0.605053141800745430f, -0.796185088780898440f, 0.604900464099919930f, + -0.796301091630359110f, 0.604747764158633410f, -0.796417065202104980f, + 0.604595041982500360f, -0.796533009491872000f, 0.604442297577135970f, + -0.796648924495397150f, 0.604289530948156070f, -0.796764810208418720f, + 0.604136742101177630f, -0.796880666626675780f, 0.603983931041818020f, + -0.796996493745908750f, 0.603831097775695880f, -0.797112291561858920f, + 0.603678242308430370f, -0.797228060070268700f, 0.603525364645641550f, + -0.797343799266881700f, 0.603372464792950370f, -0.797459509147442460f, + 0.603219542755978440f, -0.797575189707696590f, 0.603066598540348280f, + -0.797690840943391040f, 0.602913632151683140f, -0.797806462850273570f, + 0.602760643595607220f, -0.797922055424093000f, 0.602607632877745550f, + -0.798037618660599410f, 0.602454600003723860f, -0.798153152555543750f, + 0.602301544979168550f, -0.798268657104678310f, 0.602148467809707320f, + -0.798384132303756380f, 0.601995368500968130f, -0.798499578148532010f, + 0.601842247058580030f, -0.798614994634760820f, 0.601689103488173060f, + -0.798730381758199210f, 0.601535937795377730f, -0.798845739514604580f, + 0.601382749985825420f, -0.798961067899735760f, 0.601229540065148620f, + -0.799076366909352350f, 0.601076308038980160f, -0.799191636539215210f, + 0.600923053912954090f, -0.799306876785086160f, 0.600769777692705230f, + -0.799422087642728040f, 0.600616479383868970f, -0.799537269107905010f, + 0.600463158992081690f, -0.799652421176382130f, 0.600309816522980430f, + -0.799767543843925680f, 0.600156451982203350f, -0.799882637106302810f, + 0.600003065375389060f, -0.799997700959281910f, 0.599849656708177360f, + -0.800112735398632370f, 0.599696225986208310f, -0.800227740420124790f, + 0.599542773215123390f, -0.800342716019530660f, 0.599389298400564540f, + -0.800457662192622710f, 0.599235801548174570f, -0.800572578935174750f, + 0.599082282663597310f, -0.800687466242961500f, 0.598928741752476900f, + -0.800802324111759110f, 0.598775178820458720f, -0.800917152537344300f, + 0.598621593873188920f, -0.801031951515495330f, 0.598467986916314310f, + -0.801146721041991250f, 0.598314357955482600f, -0.801261461112612540f, + 0.598160706996342380f, -0.801376171723140130f, 0.598007034044542700f, + -0.801490852869356840f, 0.597853339105733910f, -0.801605504547046040f, + 0.597699622185566830f, -0.801720126751992330f, 0.597545883289693270f, + -0.801834719479981310f, 0.597392122423765710f, -0.801949282726799660f, + 0.597238339593437530f, -0.802063816488235440f, 0.597084534804362740f, + -0.802178320760077450f, 0.596930708062196500f, -0.802292795538115720f, + 0.596776859372594500f, -0.802407240818141300f, 0.596622988741213330f, + -0.802521656595946320f, 0.596469096173710360f, -0.802636042867324150f, + 0.596315181675743820f, -0.802750399628069160f, 0.596161245252972540f, + -0.802864726873976590f, 0.596007286911056530f, -0.802979024600843140f, + 0.595853306655656390f, -0.803093292804466400f, 0.595699304492433470f, + -0.803207531480644830f, 0.595545280427049790f, -0.803321740625178470f, + 0.595391234465168730f, -0.803435920233868120f, 0.595237166612453850f, + -0.803550070302515570f, 0.595083076874569960f, -0.803664190826924090f, + 0.594928965257182420f, -0.803778281802897570f, 0.594774831765957580f, + -0.803892343226241260f, 0.594620676406562240f, -0.804006375092761520f, + 0.594466499184664540f, -0.804120377398265700f, 0.594312300105932830f, + -0.804234350138562260f, 0.594158079176036800f, -0.804348293309460780f, + 0.594003836400646690f, -0.804462206906771840f, 0.593849571785433630f, + -0.804576090926307000f, 0.593695285336069300f, -0.804689945363879500f, + 0.593540977058226390f, -0.804803770215302810f, 0.593386646957578480f, + -0.804917565476392150f, 0.593232295039799800f, -0.805031331142963660f, + 0.593077921310565580f, -0.805145067210834120f, 0.592923525775551410f, + -0.805258773675822210f, 0.592769108440434070f, -0.805372450533747060f, + 0.592614669310891130f, -0.805486097780429120f, 0.592460208392600940f, + -0.805599715411689950f, 0.592305725691242400f, -0.805713303423352120f, + 0.592151221212495640f, -0.805826861811239300f, 0.591996694962040990f, + -0.805940390571176280f, 0.591842146945560250f, -0.806053889698988950f, + 0.591687577168735550f, -0.806167359190504310f, 0.591532985637249990f, + -0.806280799041550370f, 0.591378372356787580f, -0.806394209247956240f, + 0.591223737333032910f, -0.806507589805552260f, 0.591069080571671510f, + -0.806620940710169650f, 0.590914402078389520f, -0.806734261957640750f, + 0.590759701858874280f, -0.806847553543799220f, 0.590604979918813440f, + -0.806960815464479620f, 0.590450236263895920f, -0.807074047715517610f, + 0.590295470899810940f, -0.807187250292749850f, 0.590140683832248940f, + -0.807300423192014450f, 0.589985875066900920f, -0.807413566409150190f, + 0.589831044609458900f, -0.807526679939997160f, 0.589676192465615420f, + -0.807639763780396370f, 0.589521318641063940f, -0.807752817926190360f, + 0.589366423141498790f, -0.807865842373222120f, 0.589211505972615070f, + -0.807978837117336310f, 0.589056567140108460f, -0.808091802154378260f, + 0.588901606649675840f, -0.808204737480194720f, 0.588746624507014650f, + -0.808317643090633250f, 0.588591620717822890f, -0.808430518981542720f, + 0.588436595287799900f, -0.808543365148773010f, 0.588281548222645330f, + -0.808656181588174980f, 0.588126479528059850f, -0.808768968295600850f, + 0.587971389209745120f, -0.808881725266903610f, 0.587816277273403020f, + -0.808994452497937560f, 0.587661143724736770f, -0.809107149984558130f, + 0.587505988569450020f, -0.809219817722621750f, 0.587350811813247660f, + -0.809332455707985840f, 0.587195613461834910f, -0.809445063936509170f, + 0.587040393520918080f, -0.809557642404051260f, 0.586885151996203950f, + -0.809670191106473090f, 0.586729888893400500f, -0.809782710039636420f, + 0.586574604218216280f, -0.809895199199404450f, 0.586419297976360500f, + -0.810007658581641140f, 0.586263970173543700f, -0.810120088182211600f, + 0.586108620815476430f, -0.810232487996982330f, 0.585953249907870680f, + -0.810344858021820550f, 0.585797857456438860f, -0.810457198252594770f, + 0.585642443466894420f, -0.810569508685174630f, 0.585487007944951450f, + -0.810681789315430670f, 0.585331550896324940f, -0.810794040139234730f, + 0.585176072326730410f, -0.810906261152459670f, 0.585020572241884530f, + -0.811018452350979470f, 0.584865050647504490f, -0.811130613730669190f, + 0.584709507549308500f, -0.811242745287404810f, 0.584553942953015330f, + -0.811354847017063730f, 0.584398356864344710f, -0.811466918915524250f, + 0.584242749289016980f, -0.811578960978665890f, 0.584087120232753550f, + -0.811690973202369050f, 0.583931469701276300f, -0.811802955582515360f, + 0.583775797700308070f, -0.811914908114987680f, 0.583620104235572760f, + -0.812026830795669730f, 0.583464389312794430f, -0.812138723620446480f, + 0.583308652937698290f, -0.812250586585203880f, 0.583152895116010540f, + -0.812362419685829120f, 0.582997115853457700f, -0.812474222918210480f, + 0.582841315155767650f, -0.812585996278237020f, 0.582685493028668460f, + -0.812697739761799490f, 0.582529649477889320f, -0.812809453364789160f, + 0.582373784509160220f, -0.812921137083098770f, 0.582217898128211790f, + -0.813032790912621930f, 0.582061990340775550f, -0.813144414849253590f, + 0.581906061152583920f, -0.813256008888889380f, 0.581750110569369760f, + -0.813367573027426570f, 0.581594138596866930f, -0.813479107260763220f, + 0.581438145240810280f, -0.813590611584798510f, 0.581282130506935110f, + -0.813702085995432700f, 0.581126094400977620f, -0.813813530488567190f, + 0.580970036928674880f, -0.813924945060104490f, 0.580813958095764530f, + -0.814036329705948300f, 0.580657857907985410f, -0.814147684422003360f, + 0.580501736371076600f, -0.814259009204175270f, 0.580345593490778300f, + -0.814370304048371070f, 0.580189429272831680f, -0.814481568950498610f, + 0.580033243722978150f, -0.814592803906467270f, 0.579877036846960350f, + -0.814704008912187080f, 0.579720808650521560f, -0.814815183963569330f, + 0.579564559139405740f, -0.814926329056526620f, 0.579408288319357980f, + -0.815037444186972220f, 0.579251996196123550f, -0.815148529350820830f, + 0.579095682775449210f, -0.815259584543988280f, 0.578939348063081890f, + -0.815370609762391290f, 0.578782992064769690f, -0.815481605001947770f, + 0.578626614786261430f, -0.815592570258576680f, 0.578470216233306740f, + -0.815703505528198260f, 0.578313796411655590f, -0.815814410806733780f, + 0.578157355327059360f, -0.815925286090105390f, 0.578000892985269910f, + -0.816036131374236700f, 0.577844409392039850f, -0.816146946655052160f, + 0.577687904553122800f, -0.816257731928477390f, 0.577531378474272830f, + -0.816368487190439200f, 0.577374831161244880f, -0.816479212436865390f, + 0.577218262619794920f, -0.816589907663684890f, 0.577061672855679550f, + -0.816700572866827850f, 0.576905061874655960f, -0.816811208042225290f, + 0.576748429682482520f, -0.816921813185809480f, 0.576591776284917870f, + -0.817032388293513880f, 0.576435101687721830f, -0.817142933361272970f, + 0.576278405896654910f, -0.817253448385022230f, 0.576121688917478390f, + -0.817363933360698460f, 0.575964950755954330f, -0.817474388284239240f, + 0.575808191417845340f, -0.817584813151583710f, 0.575651410908915250f, + -0.817695207958671680f, 0.575494609234928230f, -0.817805572701444270f, + 0.575337786401649560f, -0.817915907375843740f, 0.575180942414845190f, + -0.818026211977813440f, 0.575024077280281820f, -0.818136486503297620f, + 0.574867191003726740f, -0.818246730948241960f, 0.574710283590948450f, + -0.818356945308593150f, 0.574553355047715760f, -0.818467129580298660f, + 0.574396405379798750f, -0.818577283759307490f, 0.574239434592967890f, + -0.818687407841569570f, 0.574082442692994470f, -0.818797501823036010f, + 0.573925429685650750f, -0.818907565699658950f, 0.573768395576709560f, + -0.819017599467391500f, 0.573611340371944610f, -0.819127603122188240f, + 0.573454264077130400f, -0.819237576660004520f, 0.573297166698042320f, + -0.819347520076796900f, 0.573140048240456060f, -0.819457433368523280f, + 0.572982908710148680f, -0.819567316531142230f, 0.572825748112897550f, + -0.819677169560613760f, 0.572668566454481160f, -0.819786992452898990f, + 0.572511363740678790f, -0.819896785203959810f, 0.572354139977270030f, + -0.820006547809759680f, 0.572196895170035580f, -0.820116280266262710f, + 0.572039629324757050f, -0.820225982569434690f, 0.571882342447216590f, + -0.820335654715241840f, 0.571725034543197120f, -0.820445296699652050f, + 0.571567705618482580f, -0.820554908518633890f, 0.571410355678857340f, + -0.820664490168157460f, 0.571252984730106660f, -0.820774041644193650f, + 0.571095592778016690f, -0.820883562942714580f, 0.570938179828374360f, + -0.820993054059693470f, 0.570780745886967370f, -0.821102514991104650f, + 0.570623290959583860f, -0.821211945732923550f, 0.570465815052012990f, + -0.821321346281126740f, 0.570308318170045010f, -0.821430716631691760f, + 0.570150800319470300f, -0.821540056780597610f, 0.569993261506080650f, + -0.821649366723823830f, 0.569835701735668110f, -0.821758646457351640f, + 0.569678121014025710f, -0.821867895977163140f, 0.569520519346947250f, + -0.821977115279241550f, 0.569362896740227330f, -0.822086304359571090f, + 0.569205253199661200f, -0.822195463214137170f, 0.569047588731045220f, + -0.822304591838926350f, 0.568889903340175970f, -0.822413690229926390f, + 0.568732197032851160f, -0.822522758383125940f, 0.568574469814869250f, + -0.822631796294514990f, 0.568416721692029390f, -0.822740803960084420f, + 0.568258952670131490f, -0.822849781375826320f, 0.568101162754976570f, + -0.822958728537734000f, 0.567943351952365670f, -0.823067645441801670f, + 0.567785520268101250f, -0.823176532084024860f, 0.567627667707986230f, + -0.823285388460400110f, 0.567469794277824620f, -0.823394214566925080f, + 0.567311899983420800f, -0.823503010399598390f, 0.567153984830580100f, + -0.823611775954420260f, 0.566996048825108680f, -0.823720511227391320f, + 0.566838091972813320f, -0.823829216214513990f, 0.566680114279501710f, + -0.823937890911791370f, 0.566522115750982100f, -0.824046535315227760f, + 0.566364096393063950f, -0.824155149420828570f, 0.566206056211556840f, + -0.824263733224600450f, 0.566047995212271560f, -0.824372286722551250f, + 0.565889913401019570f, -0.824480809910689500f, 0.565731810783613230f, + -0.824589302785025290f, 0.565573687365865440f, -0.824697765341569470f, + 0.565415543153589770f, -0.824806197576334330f, 0.565257378152600910f, + -0.824914599485333080f, 0.565099192368714090f, -0.825022971064580220f, + 0.564940985807745320f, -0.825131312310090960f, 0.564782758475511400f, + -0.825239623217882130f, 0.564624510377830120f, -0.825347903783971380f, + 0.564466241520519500f, -0.825456154004377440f, 0.564307951909398750f, + -0.825564373875120490f, 0.564149641550287680f, -0.825672563392221390f, + 0.563991310449007080f, -0.825780722551702430f, 0.563832958611378170f, + -0.825888851349586780f, 0.563674586043223180f, -0.825996949781898970f, + 0.563516192750364910f, -0.826105017844664610f, 0.563357778738627020f, + -0.826213055533910110f, 0.563199344013834090f, -0.826321062845663420f, + 0.563040888581811230f, -0.826429039775953390f, 0.562882412448384550f, + -0.826536986320809960f, 0.562723915619380400f, -0.826644902476264210f, + 0.562565398100626560f, -0.826752788238348520f, 0.562406859897951140f, + -0.826860643603096080f, 0.562248301017183150f, -0.826968468566541490f, + 0.562089721464152480f, -0.827076263124720270f, 0.561931121244689470f, + -0.827184027273669020f, 0.561772500364625450f, -0.827291761009425810f, + 0.561613858829792420f, -0.827399464328029350f, 0.561455196646023280f, + -0.827507137225519830f, 0.561296513819151470f, -0.827614779697938400f, + 0.561137810355011530f, -0.827722391741327220f, 0.560979086259438260f, + -0.827829973351729810f, 0.560820341538267540f, -0.827937524525190870f, + 0.560661576197336030f, -0.828045045257755800f, 0.560502790242481060f, + -0.828152535545471410f, 0.560343983679540860f, -0.828259995384385550f, + 0.560185156514354080f, -0.828367424770547480f, 0.560026308752760380f, + -0.828474823700007130f, 0.559867440400600320f, -0.828582192168815790f, + 0.559708551463714790f, -0.828689530173025710f, 0.559549641947945870f, + -0.828796837708690610f, 0.559390711859136140f, -0.828904114771864870f, + 0.559231761203129010f, -0.829011361358604430f, 0.559072789985768480f, + -0.829118577464965980f, 0.558913798212899770f, -0.829225763087007570f, + 0.558754785890368310f, -0.829332918220788250f, 0.558595753024020760f, + -0.829440042862368170f, 0.558436699619704100f, -0.829547137007808800f, + 0.558277625683266330f, -0.829654200653172640f, 0.558118531220556100f, + -0.829761233794523050f, 0.557959416237422960f, -0.829868236427924840f, + 0.557800280739717100f, -0.829975208549443840f, 0.557641124733289420f, + -0.830082150155146970f, 0.557481948223991660f, -0.830189061241102370f, + 0.557322751217676160f, -0.830295941803379070f, 0.557163533720196340f, + -0.830402791838047550f, 0.557004295737406060f, -0.830509611341179070f, + 0.556845037275160100f, -0.830616400308846200f, 0.556685758339313890f, + -0.830723158737122880f, 0.556526458935723720f, -0.830829886622083570f, + 0.556367139070246490f, -0.830936583959804410f, 0.556207798748739930f, + -0.831043250746362320f, 0.556048437977062720f, -0.831149886977835430f, + 0.555889056761073920f, -0.831256492650303210f, 0.555729655106633520f, + -0.831363067759845920f, 0.555570233019602290f, -0.831469612302545240f, + 0.555410790505841740f, -0.831576126274483630f, 0.555251327571214090f, + -0.831682609671745120f, 0.555091844221582420f, -0.831789062490414400f, + 0.554932340462810370f, -0.831895484726577590f, 0.554772816300762580f, + -0.832001876376321840f, 0.554613271741304040f, -0.832108237435735480f, + 0.554453706790301040f, -0.832214567900907980f, 0.554294121453620110f, + -0.832320867767929680f, 0.554134515737128910f, -0.832427137032892280f, + 0.553974889646695610f, -0.832533375691888680f, 0.553815243188189090f, + -0.832639583741012770f, 0.553655576367479310f, -0.832745761176359460f, + 0.553495889190436570f, -0.832851907994024980f, 0.553336181662932410f, + -0.832958024190106670f, 0.553176453790838460f, -0.833064109760702890f, + 0.553016705580027580f, -0.833170164701913190f, 0.552856937036373290f, + -0.833276189009838240f, 0.552697148165749770f, -0.833382182680579730f, + 0.552537338974032120f, -0.833488145710240770f, 0.552377509467096070f, + -0.833594078094925140f, 0.552217659650817930f, -0.833699979830738290f, + 0.552057789531074980f, -0.833805850913786340f, 0.551897899113745320f, + -0.833911691340176730f, 0.551737988404707450f, -0.834017501106018130f, + 0.551578057409841000f, -0.834123280207419990f, 0.551418106135026060f, + -0.834229028640493420f, 0.551258134586143700f, -0.834334746401350080f, + 0.551098142769075430f, -0.834440433486103190f, 0.550938130689703880f, + -0.834546089890866760f, 0.550778098353912230f, -0.834651715611756330f, + 0.550618045767584330f, -0.834757310644888230f, 0.550457972936604810f, + -0.834862874986380010f, 0.550297879866859190f, -0.834968408632350450f, + 0.550137766564233630f, -0.835073911578919300f, 0.549977633034615000f, + -0.835179383822207580f, 0.549817479283891020f, -0.835284825358337370f, + 0.549657305317949980f, -0.835390236183431780f, 0.549497111142680960f, + -0.835495616293615350f, 0.549336896763974010f, -0.835600965685013410f, + 0.549176662187719770f, -0.835706284353752600f, 0.549016407419809390f, + -0.835811572295960590f, 0.548856132466135290f, -0.835916829507766360f, + 0.548695837332590090f, -0.836022055985299880f, 0.548535522025067390f, + -0.836127251724692160f, 0.548375186549461600f, -0.836232416722075600f, + 0.548214830911667780f, -0.836337550973583530f, 0.548054455117581880f, + -0.836442654475350380f, 0.547894059173100190f, -0.836547727223511890f, + 0.547733643084120200f, -0.836652769214204950f, 0.547573206856539870f, + -0.836757780443567190f, 0.547412750496257930f, -0.836862760907737810f, + 0.547252274009174090f, -0.836967710602857020f, 0.547091777401188530f, + -0.837072629525066000f, 0.546931260678202190f, -0.837177517670507190f, + 0.546770723846116800f, -0.837282375035324320f, 0.546610166910834860f, + -0.837387201615661940f, 0.546449589878259760f, -0.837491997407665890f, + 0.546288992754295210f, -0.837596762407483040f, 0.546128375544846060f, + -0.837701496611261700f, 0.545967738255817680f, -0.837806200015150940f, + 0.545807080893116140f, -0.837910872615301060f, 0.545646403462648590f, + -0.838015514407863700f, 0.545485705970322530f, -0.838120125388991500f, + 0.545324988422046460f, -0.838224705554837970f, 0.545164250823729320f, + -0.838329254901558300f, 0.545003493181281160f, -0.838433773425308340f, + 0.544842715500612470f, -0.838538261122245170f, 0.544681917787634530f, + -0.838642717988527300f, 0.544521100048259710f, -0.838747144020313920f, + 0.544360262288400400f, -0.838851539213765760f, 0.544199404513970420f, + -0.838955903565044350f, 0.544038526730883930f, -0.839060237070312630f, + 0.543877628945055980f, -0.839164539725734570f, 0.543716711162402390f, + -0.839268811527475230f, 0.543555773388839650f, -0.839373052471700690f, + 0.543394815630284800f, -0.839477262554578550f, 0.543233837892656000f, + -0.839581441772277120f, 0.543072840181871850f, -0.839685590120966110f, + 0.542911822503851730f, -0.839789707596816260f, 0.542750784864516000f, + -0.839893794195999410f, 0.542589727269785270f, -0.839997849914688730f, + 0.542428649725581360f, -0.840101874749058400f, 0.542267552237826520f, + -0.840205868695283580f, 0.542106434812444030f, -0.840309831749540770f, + 0.541945297455357470f, -0.840413763908007480f, 0.541784140172491660f, + -0.840517665166862440f, 0.541622962969771640f, -0.840621535522285690f, + 0.541461765853123560f, -0.840725374970458070f, 0.541300548828474120f, + -0.840829183507561640f, 0.541139311901750910f, -0.840932961129779670f, + 0.540978055078882190f, -0.841036707833296650f, 0.540816778365796670f, + -0.841140423614298080f, 0.540655481768424260f, -0.841244108468970580f, + 0.540494165292695230f, -0.841347762393501950f, 0.540332828944540820f, + -0.841451385384081260f, 0.540171472729892970f, -0.841554977436898330f, + 0.540010096654684020f, -0.841658538548144760f, 0.539848700724847700f, + -0.841762068714012490f, 0.539687284946317570f, -0.841865567930695340f, + 0.539525849325029010f, -0.841969036194387680f, 0.539364393866917150f, + -0.842072473501285450f, 0.539202918577918240f, -0.842175879847585570f, + 0.539041423463969550f, -0.842279255229485880f, 0.538879908531008420f, + -0.842382599643185960f, 0.538718373784973670f, -0.842485913084885630f, + 0.538556819231804210f, -0.842589195550786600f, 0.538395244877439950f, + -0.842692447037091560f, 0.538233650727821700f, -0.842795667540004120f, + 0.538072036788890600f, -0.842898857055729310f, 0.537910403066588990f, + -0.843002015580472830f, 0.537748749566859470f, -0.843105143110442050f, + 0.537587076295645510f, -0.843208239641845440f, 0.537425383258891660f, + -0.843311305170892030f, 0.537263670462542530f, -0.843414339693792760f, + 0.537101937912544240f, -0.843517343206759080f, 0.536940185614843020f, + -0.843620315706004040f, 0.536778413575385920f, -0.843723257187741550f, + 0.536616621800121150f, -0.843826167648186740f, 0.536454810294997090f, + -0.843929047083555870f, 0.536292979065963180f, -0.844031895490066410f, + 0.536131128118969350f, -0.844134712863936930f, 0.535969257459966710f, + -0.844237499201387020f, 0.535807367094906620f, -0.844340254498637590f, + 0.535645457029741090f, -0.844442978751910660f, 0.535483527270423370f, + -0.844545671957429240f, 0.535321577822907010f, -0.844648334111417820f, + 0.535159608693146720f, -0.844750965210101510f, 0.534997619887097260f, + -0.844853565249707010f, 0.534835611410714670f, -0.844956134226462100f, + 0.534673583269955510f, -0.845058672136595470f, 0.534511535470777010f, + -0.845161178976337140f, 0.534349468019137520f, -0.845263654741918220f, + 0.534187380920995600f, -0.845366099429570970f, 0.534025274182310380f, + -0.845468513035528830f, 0.533863147809042650f, -0.845570895556026270f, + 0.533701001807152960f, -0.845673246987299070f, 0.533538836182603120f, + -0.845775567325583900f, 0.533376650941355560f, -0.845877856567118890f, + 0.533214446089372960f, -0.845980114708143270f, 0.533052221632619670f, + -0.846082341744896940f, 0.532889977577059690f, -0.846184537673621670f, + 0.532727713928658810f, -0.846286702490559710f, 0.532565430693382580f, + -0.846388836191954930f, 0.532403127877198010f, -0.846490938774052020f, + 0.532240805486072330f, -0.846593010233097190f, 0.532078463525973540f, + -0.846695050565337450f, 0.531916102002870760f, -0.846797059767020910f, + 0.531753720922733320f, -0.846899037834397350f, 0.531591320291531780f, + -0.847000984763716880f, 0.531428900115236910f, -0.847102900551231500f, + 0.531266460399820390f, -0.847204785193193980f, 0.531104001151255000f, + -0.847306638685858320f, 0.530941522375513510f, -0.847408461025479730f, + 0.530779024078570250f, -0.847510252208314330f, 0.530616506266399450f, + -0.847612012230619660f, 0.530453968944976320f, -0.847713741088654270f, + 0.530291412120277420f, -0.847815438778677930f, 0.530128835798278850f, + -0.847917105296951410f, 0.529966239984958620f, -0.848018740639736810f, + 0.529803624686294830f, -0.848120344803297120f, 0.529640989908265910f, + -0.848221917783896990f, 0.529478335656852090f, -0.848323459577801530f, + 0.529315661938033140f, -0.848424970181277600f, 0.529152968757790720f, + -0.848526449590592650f, 0.528990256122106040f, -0.848627897802015860f, + 0.528827524036961980f, -0.848729314811817010f, 0.528664772508341540f, + -0.848830700616267530f, 0.528502001542228480f, -0.848932055211639610f, + 0.528339211144607690f, -0.849033378594206690f, 0.528176401321464370f, + -0.849134670760243630f, 0.528013572078784740f, -0.849235931706025960f, + 0.527850723422555460f, -0.849337161427830670f, 0.527687855358763720f, + -0.849438359921935950f, 0.527524967893398200f, -0.849539527184620890f, + 0.527362061032447430f, -0.849640663212165910f, 0.527199134781901390f, + -0.849741768000852440f, 0.527036189147750190f, -0.849842841546963210f, + 0.526873224135984700f, -0.849943883846782210f, 0.526710239752597010f, + -0.850044894896594070f, 0.526547236003579330f, -0.850145874692685210f, + 0.526384212894925210f, -0.850246823231342710f, 0.526221170432628170f, + -0.850347740508854980f, 0.526058108622682760f, -0.850448626521511650f, + 0.525895027471084740f, -0.850549481265603370f, 0.525731926983829640f, + -0.850650304737422200f, 0.525568807166914680f, -0.850751096933260790f, + 0.525405668026336810f, -0.850851857849413640f, 0.525242509568094710f, + -0.850952587482175730f, 0.525079331798186890f, -0.851053285827843790f, + 0.524916134722612890f, -0.851153952882715340f, 0.524752918347373360f, + -0.851254588643089120f, 0.524589682678468840f, -0.851355193105265200f, + 0.524426427721901510f, -0.851455766265544310f, 0.524263153483673470f, + -0.851556308120228870f, 0.524099859969787810f, -0.851656818665622370f, + 0.523936547186248600f, -0.851757297898029120f, 0.523773215139060170f, + -0.851857745813754840f, 0.523609863834228030f, -0.851958162409106380f, + 0.523446493277757940f, -0.852058547680391580f, 0.523283103475656430f, + -0.852158901623919830f, 0.523119694433931250f, -0.852259224236001090f, + 0.522956266158590140f, -0.852359515512947090f, 0.522792818655642200f, + -0.852459775451070100f, 0.522629351931096720f, -0.852560004046683970f, + 0.522465865990963900f, -0.852660201296103760f, 0.522302360841254700f, + -0.852760367195645300f, 0.522138836487980650f, -0.852860501741625860f, + 0.521975292937154390f, -0.852960604930363630f, 0.521811730194788550f, + -0.853060676758178320f, 0.521648148266897090f, -0.853160717221390420f, + 0.521484547159494550f, -0.853260726316321770f, 0.521320926878595550f, + -0.853360704039295430f, 0.521157287430216610f, -0.853460650386635320f, + 0.520993628820373810f, -0.853560565354666840f, 0.520829951055084780f, + -0.853660448939716270f, 0.520666254140367270f, -0.853760301138111300f, + 0.520502538082239790f, -0.853860121946180660f, 0.520338802886721960f, + -0.853959911360254060f, 0.520175048559833760f, -0.854059669376662780f, + 0.520011275107596040f, -0.854159395991738730f, 0.519847482536030300f, + -0.854259091201815420f, 0.519683670851158520f, -0.854358755003227440f, + 0.519519840059003870f, -0.854458387392310060f, 0.519355990165589530f, + -0.854557988365400530f, 0.519192121176940360f, -0.854657557918836460f, + 0.519028233099080970f, -0.854757096048957110f, 0.518864325938037000f, + -0.854856602752102850f, 0.518700399699835170f, -0.854956078024614820f, + 0.518536454390502110f, -0.855055521862835950f, 0.518372490016066220f, + -0.855154934263109620f, 0.518208506582555460f, -0.855254315221781080f, + 0.518044504095999340f, -0.855353664735196030f, 0.517880482562427800f, + -0.855452982799701830f, 0.517716441987871150f, -0.855552269411646970f, + 0.517552382378360990f, -0.855651524567380690f, 0.517388303739929060f, + -0.855750748263253920f, 0.517224206078608310f, -0.855849940495618240f, + 0.517060089400432130f, -0.855949101260826790f, 0.516895953711434260f, + -0.856048230555233820f, 0.516731799017649980f, -0.856147328375194470f, + 0.516567625325114350f, -0.856246394717065210f, 0.516403432639863990f, + -0.856345429577203610f, 0.516239220967935620f, -0.856444432951968480f, + 0.516074990315366630f, -0.856543404837719960f, 0.515910740688195650f, + -0.856642345230818720f, 0.515746472092461380f, -0.856741254127627470f, + 0.515582184534203790f, -0.856840131524509220f, 0.515417878019463150f, + -0.856938977417828650f, 0.515253552554280290f, -0.857037791803951680f, + 0.515089208144697270f, -0.857136574679244870f, 0.514924844796756490f, + -0.857235326040076460f, 0.514760462516501200f, -0.857334045882815590f, + 0.514596061309975040f, -0.857432734203832700f, 0.514431641183222930f, + -0.857531390999499040f, 0.514267202142289830f, -0.857630016266187620f, + 0.514102744193221660f, -0.857728610000272120f, 0.513938267342065490f, + -0.857827172198127320f, 0.513773771594868030f, -0.857925702856129790f, + 0.513609256957677900f, -0.858024201970656540f, 0.513444723436543570f, + -0.858122669538086020f, 0.513280171037514330f, -0.858221105554798250f, + 0.513115599766640560f, -0.858319510017173440f, 0.512951009629972860f, + -0.858417882921594040f, 0.512786400633563070f, -0.858516224264442740f, + 0.512621772783463100f, -0.858614534042104080f, 0.512457126085725800f, + -0.858712812250963520f, 0.512292460546404980f, -0.858811058887407500f, + 0.512127776171554690f, -0.858909273947823900f, 0.511963072967230200f, + -0.859007457428601410f, 0.511798350939487000f, -0.859105609326130340f, + 0.511633610094381350f, -0.859203729636801920f, 0.511468850437970520f, + -0.859301818357008360f, 0.511304071976311890f, -0.859399875483143450f, + 0.511139274715464390f, -0.859497901011601620f, 0.510974458661486720f, + -0.859595894938779080f, 0.510809623820439040f, -0.859693857261072610f, + 0.510644770198381730f, -0.859791787974880540f, 0.510479897801375700f, + -0.859889687076602290f, 0.510315006635483350f, -0.859987554562638200f, + 0.510150096706766700f, -0.860085390429390140f, 0.509985168021289570f, + -0.860183194673260880f, 0.509820220585115560f, -0.860280967290654510f, + 0.509655254404309250f, -0.860378708277976130f, 0.509490269484936360f, + -0.860476417631632070f, 0.509325265833062480f, -0.860574095348029980f, + 0.509160243454754750f, -0.860671741423578380f, 0.508995202356080310f, + -0.860769355854687060f, 0.508830142543106990f, -0.860866938637767310f, + 0.508665064021904260f, -0.860964489769230900f, 0.508499966798540810f, + -0.861062009245491480f, 0.508334850879087470f, -0.861159497062963350f, + 0.508169716269614710f, -0.861256953218062060f, 0.508004562976194010f, + -0.861354377707204800f, 0.507839391004897940f, -0.861451770526809210f, + 0.507674200361798890f, -0.861549131673294720f, 0.507508991052970870f, + -0.861646461143081300f, 0.507343763084487920f, -0.861743758932590700f, + 0.507178516462425290f, -0.861841025038245330f, 0.507013251192858340f, + -0.861938259456469180f, 0.506847967281863320f, -0.862035462183687210f, + 0.506682664735517600f, -0.862132633216325380f, 0.506517343559898530f, + -0.862229772550811240f, 0.506352003761084800f, -0.862326880183573060f, + 0.506186645345155450f, -0.862423956111040500f, 0.506021268318189830f, + -0.862521000329644520f, 0.505855872686268860f, -0.862618012835816740f, + 0.505690458455473340f, -0.862714993625990690f, 0.505525025631885510f, + -0.862811942696600330f, 0.505359574221587390f, -0.862908860044081290f, + 0.505194104230662240f, -0.863005745664870210f, 0.505028615665194300f, + -0.863102599555404800f, 0.504863108531267480f, -0.863199421712124160f, + 0.504697582834967680f, -0.863296212131468230f, 0.504532038582380380f, + -0.863392970809878310f, 0.504366475779592150f, -0.863489697743797140f, + 0.504200894432690560f, -0.863586392929667990f, 0.504035294547763080f, + -0.863683056363935940f, 0.503869676130898950f, -0.863779688043046610f, + 0.503704039188186960f, -0.863876287963447510f, 0.503538383725717580f, + -0.863972856121586700f, 0.503372709749581150f, -0.864069392513913680f, + 0.503207017265869030f, -0.864165897136879300f, 0.503041306280673450f, + -0.864262369986934950f, 0.502875576800086880f, -0.864358811060534030f, + 0.502709828830203100f, -0.864455220354130250f, 0.502544062377115800f, + -0.864551597864179230f, 0.502378277446919870f, -0.864647943587137480f, + 0.502212474045710900f, -0.864744257519462380f, 0.502046652179584660f, + -0.864840539657612980f, 0.501880811854638400f, -0.864936789998049020f, + 0.501714953076969230f, -0.865033008537231750f, 0.501549075852675390f, + -0.865129195271623690f, 0.501383180187855880f, -0.865225350197688090f, + 0.501217266088609950f, -0.865321473311889800f, 0.501051333561038040f, + -0.865417564610694410f, 0.500885382611240940f, -0.865513624090568980f, + 0.500719413245319880f, -0.865609651747981880f, 0.500553425469377640f, + -0.865705647579402270f, 0.500387419289516580f, -0.865801611581300760f, + 0.500221394711840680f, -0.865897543750148820f, 0.500055351742453860f, + -0.865993444082419520f, 0.499889290387461380f, -0.866089312574586770f, + 0.499723210652968710f, -0.866185149223125730f, 0.499557112545081890f, + -0.866280954024512990f, 0.499390996069908220f, -0.866376726975225830f, + 0.499224861233555030f, -0.866472468071743050f, 0.499058708042130930f, + -0.866568177310544360f, 0.498892536501744750f, -0.866663854688111020f, + 0.498726346618505960f, -0.866759500200925290f, 0.498560138398525200f, + -0.866855113845470320f, 0.498393911847913150f, -0.866950695618231020f, + 0.498227666972781870f, -0.867046245515692650f, 0.498061403779243520f, + -0.867141763534342360f, 0.497895122273410930f, -0.867237249670668400f, + 0.497728822461398100f, -0.867332703921159690f, 0.497562504349319090f, + -0.867428126282306920f, 0.497396167943289340f, -0.867523516750601460f, + 0.497229813249424340f, -0.867618875322536230f, 0.497063440273840310f, + -0.867714201994605140f, 0.496897049022654640f, -0.867809496763303210f, + 0.496730639501984710f, -0.867904759625126920f, 0.496564211717949340f, + -0.867999990576573400f, 0.496397765676667160f, -0.868095189614141670f, + 0.496231301384258310f, -0.868190356734331310f, 0.496064818846843060f, + -0.868285491933643240f, 0.495898318070542240f, -0.868380595208579800f, + 0.495731799061478020f, -0.868475666555644120f, 0.495565261825772490f, + -0.868570705971340900f, 0.495398706369549080f, -0.868665713452175580f, + 0.495232132698931350f, -0.868760688994655190f, 0.495065540820043610f, + -0.868855632595287750f, 0.494898930739011310f, -0.868950544250582380f, + 0.494732302461959820f, -0.869045423957049530f, 0.494565655995016010f, + -0.869140271711200560f, 0.494398991344306760f, -0.869235087509548250f, + 0.494232308515959730f, -0.869329871348606730f, 0.494065607516103730f, + -0.869424623224890780f, 0.493898888350867430f, -0.869519343134916970f, + 0.493732151026381070f, -0.869614031075202300f, 0.493565395548774880f, + -0.869708687042265560f, 0.493398621924179830f, -0.869803311032626650f, + 0.493231830158728070f, -0.869897903042806340f, 0.493065020258551650f, + -0.869992463069326870f, 0.492898192229784090f, -0.870086991108711350f, + 0.492731346078558840f, -0.870181487157484560f, 0.492564481811010650f, + -0.870275951212171830f, 0.492397599433274550f, -0.870370383269300160f, + 0.492230698951486080f, -0.870464783325397670f, 0.492063780371782060f, + -0.870559151376993250f, 0.491896843700299240f, -0.870653487420617540f, + 0.491729888943175820f, -0.870747791452801790f, 0.491562916106550060f, + -0.870842063470078860f, 0.491395925196560830f, -0.870936303468982760f, + 0.491228916219348330f, -0.871030511446048260f, 0.491061889181052590f, + -0.871124687397811900f, 0.490894844087815140f, -0.871218831320810900f, + 0.490727780945777570f, -0.871312943211583920f, 0.490560699761082080f, + -0.871407023066670950f, 0.490393600539872130f, -0.871501070882612530f, + 0.490226483288291100f, -0.871595086655951090f, 0.490059348012483910f, + -0.871689070383229740f, 0.489892194718595300f, -0.871783022060993010f, + 0.489725023412770970f, -0.871876941685786890f, 0.489557834101157550f, + -0.871970829254157700f, 0.489390626789901920f, -0.872064684762653970f, + 0.489223401485152030f, -0.872158508207824480f, 0.489056158193055980f, + -0.872252299586219860f, 0.488888896919763230f, -0.872346058894391540f, + 0.488721617671423250f, -0.872439786128892280f, 0.488554320454186230f, + -0.872533481286276060f, 0.488387005274203590f, -0.872627144363097960f, + 0.488219672137626740f, -0.872720775355914300f, 0.488052321050608310f, + -0.872814374261282390f, 0.487884952019301210f, -0.872907941075760970f, + 0.487717565049858860f, -0.873001475795909920f, 0.487550160148436050f, + -0.873094978418290090f, 0.487382737321187310f, -0.873188448939463790f, + 0.487215296574268820f, -0.873281887355994210f, 0.487047837913836550f, + -0.873375293664446000f, 0.486880361346047400f, -0.873468667861384880f, + 0.486712866877059340f, -0.873562009943377740f, 0.486545354513030270f, + -0.873655319906992630f, 0.486377824260119500f, -0.873748597748798870f, + 0.486210276124486530f, -0.873841843465366750f, 0.486042710112291390f, + -0.873935057053268130f, 0.485875126229695420f, -0.874028238509075630f, + 0.485707524482859750f, -0.874121387829363330f, 0.485539904877947020f, + -0.874214505010706300f, 0.485372267421119770f, -0.874307590049680950f, + 0.485204612118541880f, -0.874400642942864790f, 0.485036938976377450f, + -0.874493663686836450f, 0.484869248000791120f, -0.874586652278176110f, + 0.484701539197948730f, -0.874679608713464510f, 0.484533812574016120f, + -0.874772532989284150f, 0.484366068135160480f, -0.874865425102218210f, + 0.484198305887549140f, -0.874958285048851540f, 0.484030525837350010f, + -0.875051112825769970f, 0.483862727990732320f, -0.875143908429560250f, + 0.483694912353865080f, -0.875236671856810870f, 0.483527078932918740f, + -0.875329403104110780f, 0.483359227734063980f, -0.875422102168050830f, + 0.483191358763471910f, -0.875514769045222740f, 0.483023472027315050f, + -0.875607403732219240f, 0.482855567531765670f, -0.875700006225634600f, + 0.482687645282997510f, -0.875792576522063880f, 0.482519705287184520f, + -0.875885114618103700f, 0.482351747550501030f, -0.875977620510351660f, + 0.482183772079122830f, -0.876070094195406600f, 0.482015778879225530f, + -0.876162535669868460f, 0.481847767956986080f, -0.876254944930338400f, + 0.481679739318581490f, -0.876347321973419020f, 0.481511692970189920f, + -0.876439666795713610f, 0.481343628917989870f, -0.876531979393827100f, + 0.481175547168160360f, -0.876624259764365310f, 0.481007447726881640f, + -0.876716507903935400f, 0.480839330600333900f, -0.876808723809145760f, + 0.480671195794698690f, -0.876900907476605650f, 0.480503043316157670f, + -0.876993058902925780f, 0.480334873170893070f, -0.877085178084718310f, + 0.480166685365088440f, -0.877177265018595940f, 0.479998479904927220f, + -0.877269319701173170f, 0.479830256796594250f, -0.877361342129065140f, + 0.479662016046274340f, -0.877453332298888560f, 0.479493757660153060f, + -0.877545290207261240f, 0.479325481644417130f, -0.877637215850802120f, + 0.479157188005253310f, -0.877729109226131570f, 0.478988876748849550f, + -0.877820970329870500f, 0.478820547881394050f, -0.877912799158641730f, + 0.478652201409075550f, -0.878004595709069080f, 0.478483837338084080f, + -0.878096359977777130f, 0.478315455674609480f, -0.878188091961392250f, + 0.478147056424843120f, -0.878279791656541460f, 0.477978639594976110f, + -0.878371459059853590f, 0.477810205191201040f, -0.878463094167957870f, + 0.477641753219710590f, -0.878554696977485340f, 0.477473283686698060f, + -0.878646267485068130f, 0.477304796598358010f, -0.878737805687339280f, + 0.477136291960884750f, -0.878829311580933360f, 0.476967769780474230f, + -0.878920785162485840f, 0.476799230063322250f, -0.879012226428633410f, + 0.476630672815625380f, -0.879103635376014330f, 0.476462098043581310f, + -0.879195012001267370f, 0.476293505753387750f, -0.879286356301033250f, + 0.476124895951243630f, -0.879377668271953180f, 0.475956268643348220f, + -0.879468947910670100f, 0.475787623835901120f, -0.879560195213827890f, + 0.475618961535103410f, -0.879651410178071470f, 0.475450281747155870f, + -0.879742592800047410f, 0.475281584478260800f, -0.879833743076402940f, + 0.475112869734620470f, -0.879924861003786860f, 0.474944137522437860f, + -0.880015946578848960f, 0.474775387847917230f, -0.880106999798240360f, + 0.474606620717262560f, -0.880198020658613190f, 0.474437836136679340f, + -0.880289009156620890f, 0.474269034112372920f, -0.880379965288918260f, + 0.474100214650550020f, -0.880470889052160750f, 0.473931377757417560f, + -0.880561780443005590f, 0.473762523439182850f, -0.880652639458111010f, + 0.473593651702054640f, -0.880743466094136230f, 0.473424762552241530f, + -0.880834260347742040f, 0.473255855995953380f, -0.880925022215589880f, + 0.473086932039400220f, -0.881015751694342760f, 0.472917990688792760f, + -0.881106448780665130f, 0.472749031950342900f, -0.881197113471221980f, + 0.472580055830262250f, -0.881287745762680100f, 0.472411062334764100f, + -0.881378345651706810f, 0.472242051470061650f, -0.881468913134971330f, + 0.472073023242368660f, -0.881559448209143780f, 0.471903977657900320f, + -0.881649950870895260f, 0.471734914722871430f, -0.881740421116898320f, + 0.471565834443498480f, -0.881830858943826620f, 0.471396736825997810f, + -0.881921264348354940f, 0.471227621876586400f, -0.882011637327159590f, + 0.471058489601482610f, -0.882101977876917580f, 0.470889340006904520f, + -0.882192285994307430f, 0.470720173099071710f, -0.882282561676008600f, + 0.470550988884203490f, -0.882372804918702290f, 0.470381787368520710f, + -0.882463015719070040f, 0.470212568558244280f, -0.882553194073795400f, + 0.470043332459595620f, -0.882643339979562790f, 0.469874079078797470f, + -0.882733453433057540f, 0.469704808422072460f, -0.882823534430966730f, + 0.469535520495644510f, -0.882913582969978020f, 0.469366215305737630f, + -0.883003599046780720f, 0.469196892858576630f, -0.883093582658065370f, + 0.469027553160387240f, -0.883183533800523280f, 0.468858196217395330f, + -0.883273452470847430f, 0.468688822035827960f, -0.883363338665731580f, + 0.468519430621912420f, -0.883453192381870920f, 0.468350021981876530f, + -0.883543013615961880f, 0.468180596121949400f, -0.883632802364701760f, + 0.468011153048359830f, -0.883722558624789660f, 0.467841692767338220f, + -0.883812282392925090f, 0.467672215285114710f, -0.883901973665809470f, + 0.467502720607920920f, -0.883991632440144890f, 0.467333208741988530f, + -0.884081258712634990f, 0.467163679693549770f, -0.884170852479984500f, + 0.466994133468838110f, -0.884260413738899080f, 0.466824570074086950f, + -0.884349942486086120f, 0.466654989515530970f, -0.884439438718253700f, + 0.466485391799405010f, -0.884528902432111350f, 0.466315776931944480f, + -0.884618333624369920f, 0.466146144919386000f, -0.884707732291740930f, + 0.465976495767966130f, -0.884797098430937790f, 0.465806829483922770f, + -0.884886432038674560f, 0.465637146073493770f, -0.884975733111666660f, + 0.465467445542917800f, -0.885065001646630930f, 0.465297727898434650f, + -0.885154237640285110f, 0.465127993146283950f, -0.885243441089348270f, + 0.464958241292706740f, -0.885332611990540590f, 0.464788472343944160f, + -0.885421750340583570f, 0.464618686306237820f, -0.885510856136199950f, + 0.464448883185830770f, -0.885599929374113360f, 0.464279062988965760f, + -0.885688970051048960f, 0.464109225721887010f, -0.885777978163732940f, + 0.463939371390838460f, -0.885866953708892790f, 0.463769500002065680f, + -0.885955896683257030f, 0.463599611561814120f, -0.886044807083555490f, + 0.463429706076329880f, -0.886133684906519340f, 0.463259783551860260f, + -0.886222530148880640f, 0.463089843994652470f, -0.886311342807372890f, + 0.462919887410955130f, -0.886400122878730490f, 0.462749913807016850f, + -0.886488870359689600f, 0.462579923189086810f, -0.886577585246987040f, + 0.462409915563415540f, -0.886666267537360890f, 0.462239890936253280f, + -0.886754917227550950f, 0.462069849313851810f, -0.886843534314297300f, + 0.461899790702462840f, -0.886932118794342080f, 0.461729715108338770f, + -0.887020670664428360f, 0.461559622537733190f, -0.887109189921300060f, + 0.461389512996899450f, -0.887197676561702900f, 0.461219386492092430f, + -0.887286130582383150f, 0.461049243029567010f, -0.887374551980088740f, + 0.460879082615578690f, -0.887462940751568840f, 0.460708905256384190f, + -0.887551296893573370f, 0.460538710958240010f, -0.887639620402853930f, + 0.460368499727404070f, -0.887727911276163020f, 0.460198271570134270f, + -0.887816169510254550f, 0.460028026492689700f, -0.887904395101883240f, + 0.459857764501329650f, -0.887992588047805560f, 0.459687485602313870f, + -0.888080748344778900f, 0.459517189801903590f, -0.888168875989561620f, + 0.459346877106359570f, -0.888256970978913870f, 0.459176547521944150f, + -0.888345033309596240f, 0.459006201054919680f, -0.888433062978371320f, + 0.458835837711549120f, -0.888521059982002260f, 0.458665457498096670f, + -0.888609024317253750f, 0.458495060420826220f, -0.888696955980891710f, + 0.458324646486003300f, -0.888784854969682850f, 0.458154215699893230f, + -0.888872721280395520f, 0.457983768068762180f, -0.888960554909799310f, + 0.457813303598877290f, -0.889048355854664570f, 0.457642822296505770f, + -0.889136124111763240f, 0.457472324167916110f, -0.889223859677868210f, + 0.457301809219376800f, -0.889311562549753850f, 0.457131277457156980f, + -0.889399232724195520f, 0.456960728887527030f, -0.889486870197969790f, + 0.456790163516757220f, -0.889574474967854580f, 0.456619581351118960f, + -0.889662047030628790f, 0.456448982396883860f, -0.889749586383072890f, + 0.456278366660324670f, -0.889837093021967900f, 0.456107734147714220f, + -0.889924566944096720f, 0.455937084865326030f, -0.890012008146243260f, + 0.455766418819434750f, -0.890099416625192210f, 0.455595736016314920f, + -0.890186792377730240f, 0.455425036462242420f, -0.890274135400644480f, + 0.455254320163493210f, -0.890361445690723730f, 0.455083587126343840f, + -0.890448723244757880f, 0.454912837357072050f, -0.890535968059537830f, + 0.454742070861955450f, -0.890623180131855930f, 0.454571287647273000f, + -0.890710359458505520f, 0.454400487719303750f, -0.890797506036281490f, + 0.454229671084327320f, -0.890884619861979530f, 0.454058837748624540f, + -0.890971700932396750f, 0.453887987718476050f, -0.891058749244331590f, + 0.453717121000163930f, -0.891145764794583180f, 0.453546237599970260f, + -0.891232747579952520f, 0.453375337524177750f, -0.891319697597241390f, + 0.453204420779070300f, -0.891406614843252900f, 0.453033487370931580f, + -0.891493499314791380f, 0.452862537306046810f, -0.891580351008662290f, + 0.452691570590700860f, -0.891667169921672390f, 0.452520587231180100f, + -0.891753956050629460f, 0.452349587233771000f, -0.891840709392342720f, + 0.452178570604760410f, -0.891927429943622510f, 0.452007537350436530f, + -0.892014117701280360f, 0.451836487477087430f, -0.892100772662129170f, + 0.451665420991002540f, -0.892187394822982480f, 0.451494337898471210f, + -0.892273984180655730f, 0.451323238205783520f, -0.892360540731965360f, + 0.451152121919230710f, -0.892447064473728680f, 0.450980989045103810f, + -0.892533555402764690f, 0.450809839589695340f, -0.892620013515893040f, + 0.450638673559297760f, -0.892706438809935280f, 0.450467490960204110f, + -0.892792831281713610f, 0.450296291798708730f, -0.892879190928051680f, + 0.450125076081105750f, -0.892965517745774260f, 0.449953843813690580f, + -0.893051811731707450f, 0.449782595002758860f, -0.893138072882678210f, + 0.449611329654606600f, -0.893224301195515320f, 0.449440047775531260f, + -0.893310496667048090f, 0.449268749371829920f, -0.893396659294107610f, + 0.449097434449801100f, -0.893482789073525850f, 0.448926103015743260f, + -0.893568886002136020f, 0.448754755075956020f, -0.893654950076772430f, + 0.448583390636739300f, -0.893740981294271040f, 0.448412009704393430f, + -0.893826979651468620f, 0.448240612285220000f, -0.893912945145203250f, + 0.448069198385520340f, -0.893998877772314240f, 0.447897768011597310f, + -0.894084777529641990f, 0.447726321169753750f, -0.894170644414028270f, + 0.447554857866293010f, -0.894256478422316040f, 0.447383378107519710f, + -0.894342279551349480f, 0.447211881899738260f, -0.894428047797973800f, + 0.447040369249254500f, -0.894513783159035620f, 0.446868840162374330f, + -0.894599485631382580f, 0.446697294645404090f, -0.894685155211863980f, + 0.446525732704651400f, -0.894770791897329550f, 0.446354154346423840f, + -0.894856395684630930f, 0.446182559577030120f, -0.894941966570620750f, + 0.446010948402779110f, -0.895027504552152630f, 0.445839320829980350f, + -0.895113009626081760f, 0.445667676864944350f, -0.895198481789264200f, + 0.445496016513981740f, -0.895283921038557580f, 0.445324339783404240f, + -0.895369327370820310f, 0.445152646679523590f, -0.895454700782912450f, + 0.444980937208652780f, -0.895540041271694840f, 0.444809211377105000f, + -0.895625348834030000f, 0.444637469191193790f, -0.895710623466781320f, + 0.444465710657234110f, -0.895795865166813420f, 0.444293935781540580f, + -0.895881073930992370f, 0.444122144570429260f, -0.895966249756185110f, + 0.443950337030216250f, -0.896051392639260040f, 0.443778513167218220f, + -0.896136502577086770f, 0.443606672987753080f, -0.896221579566535920f, + 0.443434816498138430f, -0.896306623604479660f, 0.443262943704693380f, + -0.896391634687790820f, 0.443091054613736990f, -0.896476612813344010f, + 0.442919149231588980f, -0.896561557978014960f, 0.442747227564570130f, + -0.896646470178680150f, 0.442575289619001170f, -0.896731349412217880f, + 0.442403335401204130f, -0.896816195675507190f, 0.442231364917501090f, + -0.896901008965428680f, 0.442059378174214760f, -0.896985789278863970f, + 0.441887375177668960f, -0.897070536612695870f, 0.441715355934187310f, + -0.897155250963808550f, 0.441543320450094920f, -0.897239932329087050f, + 0.441371268731716620f, -0.897324580705418320f, 0.441199200785378660f, + -0.897409196089689720f, 0.441027116617407340f, -0.897493778478790190f, + 0.440855016234129430f, -0.897578327869610230f, 0.440682899641873020f, + -0.897662844259040750f, 0.440510766846965880f, -0.897747327643974690f, + 0.440338617855737300f, -0.897831778021305650f, 0.440166452674516480f, + -0.897916195387928550f, 0.439994271309633260f, -0.898000579740739880f, + 0.439822073767418610f, -0.898084931076636780f, 0.439649860054203420f, + -0.898169249392518080f, 0.439477630176319860f, -0.898253534685283570f, + 0.439305384140100060f, -0.898337786951834190f, 0.439133121951876930f, + -0.898422006189072530f, 0.438960843617984430f, -0.898506192393901840f, + 0.438788549144756290f, -0.898590345563227030f, 0.438616238538527710f, + -0.898674465693953820f, 0.438443911805633860f, -0.898758552782989440f, + 0.438271568952410480f, -0.898842606827242260f, 0.438099209985194580f, + -0.898926627823621870f, 0.437926834910322860f, -0.899010615769039070f, + 0.437754443734133470f, -0.899094570660405770f, 0.437582036462964340f, + -0.899178492494635330f, 0.437409613103154850f, -0.899262381268642000f, + 0.437237173661044200f, -0.899346236979341460f, 0.437064718142972370f, + -0.899430059623650860f, 0.436892246555280470f, -0.899513849198487870f, + 0.436719758904309310f, -0.899597605700772180f, 0.436547255196401250f, + -0.899681329127423930f, 0.436374735437898510f, -0.899765019475365020f, + 0.436202199635143950f, -0.899848676741518580f, 0.436029647794481670f, + -0.899932300922808400f, 0.435857079922255470f, -0.900015892016160280f, + 0.435684496024810520f, -0.900099450018500340f, 0.435511896108492170f, + -0.900182974926756700f, 0.435339280179646070f, -0.900266466737858480f, + 0.435166648244619370f, -0.900349925448735600f, 0.434994000309758710f, + -0.900433351056319830f, 0.434821336381412350f, -0.900516743557543520f, + 0.434648656465928430f, -0.900600102949340790f, 0.434475960569655710f, + -0.900683429228646860f, 0.434303248698944100f, -0.900766722392397860f, + 0.434130520860143310f, -0.900849982437531450f, 0.433957777059604480f, + -0.900933209360986200f, 0.433785017303678520f, -0.901016403159702330f, + 0.433612241598717640f, -0.901099563830620950f, 0.433439449951074200f, + -0.901182691370684410f, 0.433266642367100940f, -0.901265785776836580f, + 0.433093818853152010f, -0.901348847046022030f, 0.432920979415581220f, + -0.901431875175186970f, 0.432748124060743760f, -0.901514870161278630f, + 0.432575252794994810f, -0.901597832001245660f, 0.432402365624690140f, + -0.901680760692037730f, 0.432229462556186770f, -0.901763656230605610f, + 0.432056543595841450f, -0.901846518613901860f, 0.431883608750012300f, + -0.901929347838879350f, 0.431710658025057370f, -0.902012143902493070f, + 0.431537691427335500f, -0.902094906801698900f, 0.431364708963206440f, + -0.902177636533453510f, 0.431191710639030000f, -0.902260333094715540f, + 0.431018696461167080f, -0.902342996482444200f, 0.430845666435978820f, + -0.902425626693600270f, 0.430672620569826860f, -0.902508223725145830f, + 0.430499558869073930f, -0.902590787574043870f, 0.430326481340082610f, + -0.902673318237258830f, 0.430153387989216930f, -0.902755815711756120f, + 0.429980278822840570f, -0.902838279994502830f, 0.429807153847318770f, + -0.902920711082466630f, 0.429634013069016500f, -0.903003108972617040f, + 0.429460856494299490f, -0.903085473661924600f, 0.429287684129534720f, + -0.903167805147360610f, 0.429114495981088690f, -0.903250103425898400f, + 0.428941292055329550f, -0.903332368494511820f, 0.428768072358625240f, + -0.903414600350176290f, 0.428594836897344400f, -0.903496798989868450f, + 0.428421585677856760f, -0.903578964410565950f, 0.428248318706531910f, + -0.903661096609247980f, 0.428075035989740780f, -0.903743195582894620f, + 0.427901737533854240f, -0.903825261328487390f, 0.427728423345243860f, + -0.903907293843009050f, 0.427555093430282200f, -0.903989293123443340f, + 0.427381747795341770f, -0.904071259166775440f, 0.427208386446796370f, + -0.904153191969991670f, 0.427035009391019790f, -0.904235091530079750f, + 0.426861616634386490f, -0.904316957844028320f, 0.426688208183271970f, + -0.904398790908827350f, 0.426514784044051520f, -0.904480590721468250f, + 0.426341344223101880f, -0.904562357278943190f, 0.426167888726799620f, + -0.904644090578246240f, 0.425994417561522450f, -0.904725790616371930f, + 0.425820930733648300f, -0.904807457390316540f, 0.425647428249555590f, + -0.904889090897077470f, 0.425473910115623910f, -0.904970691133653250f, + 0.425300376338232590f, -0.905052258097043590f, 0.425126826923762410f, + -0.905133791784249580f, 0.424953261878594060f, -0.905215292192273480f, + 0.424779681209108810f, -0.905296759318118820f, 0.424606084921689220f, + -0.905378193158789980f, 0.424432473022717420f, -0.905459593711293250f, + 0.424258845518577010f, -0.905540960972635480f, 0.424085202415651670f, + -0.905622294939825160f, 0.423911543720325580f, -0.905703595609872010f, + 0.423737869438983950f, -0.905784862979786440f, 0.423564179578011960f, + -0.905866097046580940f, 0.423390474143796100f, -0.905947297807268460f, + 0.423216753142722780f, -0.906028465258863490f, 0.423043016581179100f, + -0.906109599398381980f, 0.422869264465553170f, -0.906190700222840540f, + 0.422695496802232950f, -0.906271767729257660f, 0.422521713597607870f, + -0.906352801914652280f, 0.422347914858067000f, -0.906433802776045460f, + 0.422174100590000820f, -0.906514770310458800f, 0.422000270799799790f, + -0.906595704514915330f, 0.421826425493854910f, -0.906676605386439460f, + 0.421652564678558380f, -0.906757472922056550f, 0.421478688360302220f, + -0.906838307118793540f, 0.421304796545479700f, -0.906919107973678030f, + 0.421130889240484140f, -0.906999875483739610f, 0.420956966451709440f, + -0.907080609646008450f, 0.420783028185550630f, -0.907161310457516250f, + 0.420609074448402510f, -0.907241977915295930f, 0.420435105246661220f, + -0.907322612016381310f, 0.420261120586723050f, -0.907403212757808000f, + 0.420087120474984590f, -0.907483780136612570f, 0.419913104917843730f, + -0.907564314149832520f, 0.419739073921698180f, -0.907644814794507090f, + 0.419565027492946940f, -0.907725282067676330f, 0.419390965637989050f, + -0.907805715966381820f, 0.419216888363223960f, -0.907886116487666150f, + 0.419042795675052480f, -0.907966483628573240f, 0.418868687579875110f, + -0.908046817386148340f, 0.418694564084093610f, -0.908127117757437600f, + 0.418520425194109700f, -0.908207384739488700f, 0.418346270916326310f, + -0.908287618329350450f, 0.418172101257146430f, -0.908367818524072780f, + 0.417997916222973550f, -0.908447985320707250f, 0.417823715820212380f, + -0.908528118716306120f, 0.417649500055267410f, -0.908608218707923190f, + 0.417475268934544340f, -0.908688285292613360f, 0.417301022464449060f, + -0.908768318467432780f, 0.417126760651387870f, -0.908848318229439120f, + 0.416952483501768280f, -0.908928284575690640f, 0.416778191021997590f, + -0.909008217503247450f, 0.416603883218484410f, -0.909088117009170580f, + 0.416429560097637320f, -0.909167983090522270f, 0.416255221665865480f, + -0.909247815744366310f, 0.416080867929579320f, -0.909327614967767260f, + 0.415906498895188770f, -0.909407380757791260f, 0.415732114569105420f, + -0.909487113111505430f, 0.415557714957740580f, -0.909566812025978220f, + 0.415383300067506290f, -0.909646477498279540f, 0.415208869904815650f, + -0.909726109525480160f, 0.415034424476081630f, -0.909805708104652220f, + 0.414859963787718390f, -0.909885273232869160f, 0.414685487846140010f, + -0.909964804907205660f, 0.414510996657761810f, -0.910044303124737390f, + 0.414336490228999210f, -0.910123767882541570f, 0.414161968566268080f, + -0.910203199177696540f, 0.413987431675985510f, -0.910282597007281760f, + 0.413812879564568300f, -0.910361961368377990f, 0.413638312238434560f, + -0.910441292258067140f, 0.413463729704002580f, -0.910520589673432630f, + 0.413289131967690960f, -0.910599853611558930f, 0.413114519035919560f, + -0.910679084069531570f, 0.412939890915108020f, -0.910758281044437570f, + 0.412765247611677320f, -0.910837444533365010f, 0.412590589132048380f, + -0.910916574533403240f, 0.412415915482642730f, -0.910995671041643140f, + 0.412241226669883000f, -0.911074734055176250f, 0.412066522700191560f, + -0.911153763571095900f, 0.411891803579992220f, -0.911232759586496190f, + 0.411717069315708670f, -0.911311722098472670f, 0.411542319913765280f, + -0.911390651104122320f, 0.411367555380587340f, -0.911469546600543020f, + 0.411192775722600160f, -0.911548408584833990f, 0.411017980946230270f, + -0.911627237054095650f, 0.410843171057903910f, -0.911706032005429880f, + 0.410668346064048780f, -0.911784793435939430f, 0.410493505971092520f, + -0.911863521342728520f, 0.410318650785463260f, -0.911942215722902570f, + 0.410143780513590350f, -0.912020876573568230f, 0.409968895161902820f, + -0.912099503891833470f, 0.409793994736831200f, -0.912178097674807060f, + 0.409619079244805840f, -0.912256657919599650f, 0.409444148692257590f, + -0.912335184623322750f, 0.409269203085618700f, -0.912413677783089020f, + 0.409094242431320920f, -0.912492137396012650f, 0.408919266735797480f, + -0.912570563459208730f, 0.408744276005481520f, -0.912648955969793900f, + 0.408569270246806780f, -0.912727314924885900f, 0.408394249466208110f, + -0.912805640321603500f, 0.408219213670120100f, -0.912883932157067200f, + 0.408044162864978740f, -0.912962190428398100f, 0.407869097057219960f, + -0.913040415132719160f, 0.407694016253280170f, -0.913118606267154130f, + 0.407518920459597030f, -0.913196763828828200f, 0.407343809682607970f, + -0.913274887814867760f, 0.407168683928751610f, -0.913352978222400250f, + 0.406993543204466460f, -0.913431035048554720f, 0.406818387516192370f, + -0.913509058290461140f, 0.406643216870369140f, -0.913587047945250810f, + 0.406468031273437000f, -0.913665004010056350f, 0.406292830731837470f, + -0.913742926482011390f, 0.406117615252011790f, -0.913820815358251100f, + 0.405942384840402570f, -0.913898670635911680f, 0.405767139503452220f, + -0.913976492312130520f, 0.405591879247603870f, -0.914054280384046460f, + 0.405416604079301750f, -0.914132034848799460f, 0.405241314004989860f, + -0.914209755703530690f, 0.405066009031113390f, -0.914287442945382440f, + 0.404890689164117750f, -0.914365096571498450f, 0.404715354410448650f, + -0.914442716579023870f, 0.404540004776553110f, -0.914520302965104450f, + 0.404364640268877810f, -0.914597855726887790f, 0.404189260893870750f, + -0.914675374861522390f, 0.404013866657980060f, -0.914752860366158100f, + 0.403838457567654130f, -0.914830312237946090f, 0.403663033629342750f, + -0.914907730474038620f, 0.403487594849495310f, -0.914985115071589310f, + 0.403312141234562660f, -0.915062466027752760f, 0.403136672790995240f, + -0.915139783339685260f, 0.402961189525244960f, -0.915217067004543750f, + 0.402785691443763640f, -0.915294317019487050f, 0.402610178553003680f, + -0.915371533381674760f, 0.402434650859418540f, -0.915448716088267830f, + 0.402259108369461440f, -0.915525865136428530f, 0.402083551089587040f, + -0.915602980523320230f, 0.401907979026249860f, -0.915680062246107650f, + 0.401732392185905010f, -0.915757110301956720f, 0.401556790575008650f, + -0.915834124688034710f, 0.401381174200016790f, -0.915911105401509880f, + 0.401205543067386760f, -0.915988052439551840f, 0.401029897183575790f, + -0.916064965799331610f, 0.400854236555041650f, -0.916141845478021350f, + 0.400678561188243350f, -0.916218691472794110f, 0.400502871089639500f, + -0.916295503780824800f, 0.400327166265690150f, -0.916372282399289140f, + 0.400151446722855300f, -0.916449027325364040f, 0.399975712467595390f, + -0.916525738556228100f, 0.399799963506372090f, -0.916602416089060680f, + 0.399624199845646790f, -0.916679059921042700f, 0.399448421491882260f, + -0.916755670049355990f, 0.399272628451540930f, -0.916832246471183890f, + 0.399096820731086600f, -0.916908789183710990f, 0.398920998336983020f, + -0.916985298184122890f, 0.398745161275694480f, -0.917061773469606820f, + 0.398569309553686360f, -0.917138215037350710f, 0.398393443177423920f, + -0.917214622884544250f, 0.398217562153373620f, -0.917290997008377910f, + 0.398041666488001930f, -0.917367337406043810f, 0.397865756187775750f, + -0.917443644074735220f, 0.397689831259163240f, -0.917519917011646260f, + 0.397513891708632330f, -0.917596156213972950f, 0.397337937542652120f, + -0.917672361678911750f, 0.397161968767691720f, -0.917748533403661250f, + 0.396985985390220900f, -0.917824671385420570f, 0.396809987416710420f, + -0.917900775621390390f, 0.396633974853630830f, -0.917976846108772730f, + 0.396457947707453960f, -0.918052882844770380f, 0.396281905984651680f, + -0.918128885826587910f, 0.396105849691696320f, -0.918204855051430900f, + 0.395929778835061360f, -0.918280790516506130f, 0.395753693421220080f, + -0.918356692219021720f, 0.395577593456646950f, -0.918432560156186790f, + 0.395401478947816300f, -0.918508394325212250f, 0.395225349901203730f, + -0.918584194723309540f, 0.395049206323284880f, -0.918659961347691900f, + 0.394873048220535760f, -0.918735694195573550f, 0.394696875599433670f, + -0.918811393264169940f, 0.394520688466455550f, -0.918887058550697970f, + 0.394344486828079650f, -0.918962690052375630f, 0.394168270690784250f, + -0.919038287766421940f, 0.393992040061048100f, -0.919113851690057770f, + 0.393815794945351130f, -0.919189381820504470f, 0.393639535350172880f, + -0.919264878154985250f, 0.393463261281994380f, -0.919340340690724230f, + 0.393286972747296570f, -0.919415769424946960f, 0.393110669752560760f, + -0.919491164354880100f, 0.392934352304269600f, -0.919566525477751530f, + 0.392758020408905280f, -0.919641852790790470f, 0.392581674072951530f, + -0.919717146291227360f, 0.392405313302891860f, -0.919792405976293750f, + 0.392228938105210370f, -0.919867631843222950f, 0.392052548486392200f, + -0.919942823889248640f, 0.391876144452922350f, -0.920017982111606570f, + 0.391699726011287050f, -0.920093106507533070f, 0.391523293167972350f, + -0.920168197074266450f, 0.391346845929465610f, -0.920243253809045370f, + 0.391170384302253980f, -0.920318276709110480f, 0.390993908292825380f, + -0.920393265771703550f, 0.390817417907668610f, -0.920468220994067110f, + 0.390640913153272370f, -0.920543142373445480f, 0.390464394036126650f, + -0.920618029907083860f, 0.390287860562721360f, -0.920692883592229010f, + 0.390111312739546910f, -0.920767703426128790f, 0.389934750573094790f, + -0.920842489406032080f, 0.389758174069856410f, -0.920917241529189520f, + 0.389581583236324360f, -0.920991959792852310f, 0.389404978078991100f, + -0.921066644194273530f, 0.389228358604349730f, -0.921141294730707270f, + 0.389051724818894500f, -0.921215911399408730f, 0.388875076729119250f, + -0.921290494197634540f, 0.388698414341519250f, -0.921365043122642340f, + 0.388521737662589740f, -0.921439558171691320f, 0.388345046698826300f, + -0.921514039342041900f, 0.388168341456725850f, -0.921588486630955380f, + 0.387991621942784910f, -0.921662900035694730f, 0.387814888163501290f, + -0.921737279553523800f, 0.387638140125372680f, -0.921811625181708120f, + 0.387461377834897920f, -0.921885936917513970f, 0.387284601298575890f, + -0.921960214758209110f, 0.387107810522905990f, -0.922034458701062820f, + 0.386931005514388690f, -0.922108668743345070f, 0.386754186279524130f, + -0.922182844882327600f, 0.386577352824813980f, -0.922256987115283030f, + 0.386400505156759610f, -0.922331095439485330f, 0.386223643281862980f, + -0.922405169852209880f, 0.386046767206627280f, -0.922479210350733100f, + 0.385869876937555310f, -0.922553216932332830f, 0.385692972481151200f, + -0.922627189594287800f, 0.385516053843919020f, -0.922701128333878520f, + 0.385339121032363340f, -0.922775033148386380f, 0.385162174052989970f, + -0.922848904035094120f, 0.384985212912304200f, -0.922922740991285680f, + 0.384808237616812930f, -0.922996544014246250f, 0.384631248173022740f, + -0.923070313101262420f, 0.384454244587440870f, -0.923144048249621820f, + 0.384277226866575620f, -0.923217749456613500f, 0.384100195016935040f, + -0.923291416719527640f, 0.383923149045028500f, -0.923365050035655610f, + 0.383746088957365010f, -0.923438649402290370f, 0.383569014760454960f, + -0.923512214816725520f, 0.383391926460808770f, -0.923585746276256560f, + 0.383214824064937180f, -0.923659243778179980f, 0.383037707579352130f, + -0.923732707319793180f, 0.382860577010565360f, -0.923806136898395410f, + 0.382683432365089840f, -0.923879532511286740f, 0.382506273649438400f, + -0.923952894155768640f, 0.382329100870124510f, -0.924026221829143850f, + 0.382151914033662720f, -0.924099515528716280f, 0.381974713146567220f, + -0.924172775251791200f, 0.381797498215353690f, -0.924246000995674890f, + 0.381620269246537520f, -0.924319192757675160f, 0.381443026246634730f, + -0.924392350535101050f, 0.381265769222162490f, -0.924465474325262600f, + 0.381088498179637520f, -0.924538564125471420f, 0.380911213125578130f, + -0.924611619933039970f, 0.380733914066502090f, -0.924684641745282530f, + 0.380556601008928570f, -0.924757629559513910f, 0.380379273959376710f, + -0.924830583373050800f, 0.380201932924366050f, -0.924903503183210910f, + 0.380024577910417380f, -0.924976388987313050f, 0.379847208924051110f, + -0.925049240782677580f, 0.379669825971789000f, -0.925122058566625770f, + 0.379492429060152740f, -0.925194842336480420f, 0.379315018195664430f, + -0.925267592089565550f, 0.379137593384847430f, -0.925340307823206200f, + 0.378960154634224720f, -0.925412989534729060f, 0.378782701950320600f, + -0.925485637221461490f, 0.378605235339659290f, -0.925558250880732620f, + 0.378427754808765620f, -0.925630830509872720f, 0.378250260364165310f, + -0.925703376106213120f, 0.378072752012383990f, -0.925775887667086740f, + 0.377895229759948550f, -0.925848365189827270f, 0.377717693613385810f, + -0.925920808671769960f, 0.377540143579222940f, -0.925993218110251480f, + 0.377362579663988450f, -0.926065593502609310f, 0.377185001874210450f, + -0.926137934846182560f, 0.377007410216418310f, -0.926210242138311270f, + 0.376829804697141220f, -0.926282515376337210f, 0.376652185322909620f, + -0.926354754557602860f, 0.376474552100253880f, -0.926426959679452100f, + 0.376296905035704790f, -0.926499130739230510f, 0.376119244135794390f, + -0.926571267734284220f, 0.375941569407054420f, -0.926643370661961230f, + 0.375763880856017750f, -0.926715439519610330f, 0.375586178489217330f, + -0.926787474304581750f, 0.375408462313186590f, -0.926859475014227160f, + 0.375230732334460030f, -0.926931441645899130f, 0.375052988559571860f, + -0.927003374196951670f, 0.374875230995057600f, -0.927075272664740100f, + 0.374697459647452770f, -0.927147137046620880f, 0.374519674523293210f, + -0.927218967339951790f, 0.374341875629116030f, -0.927290763542091720f, + 0.374164062971457990f, -0.927362525650401110f, 0.373986236556857090f, + -0.927434253662241300f, 0.373808396391851370f, -0.927505947574975180f, + 0.373630542482979280f, -0.927577607385966730f, 0.373452674836780410f, + -0.927649233092581180f, 0.373274793459794030f, -0.927720824692185200f, + 0.373096898358560690f, -0.927792382182146320f, 0.372918989539620770f, + -0.927863905559833780f, 0.372741067009515810f, -0.927935394822617890f, + 0.372563130774787370f, -0.928006849967869970f, 0.372385180841977360f, + -0.928078270992963140f, 0.372207217217628950f, -0.928149657895271150f, + 0.372029239908284960f, -0.928221010672169440f, 0.371851248920489540f, + -0.928292329321034560f, 0.371673244260786630f, -0.928363613839244370f, + 0.371495225935720760f, -0.928434864224177980f, 0.371317193951837600f, + -0.928506080473215480f, 0.371139148315682510f, -0.928577262583738850f, + 0.370961089033802040f, -0.928648410553130520f, 0.370783016112742720f, + -0.928719524378774700f, 0.370604929559051670f, -0.928790604058057020f, + 0.370426829379276900f, -0.928861649588363700f, 0.370248715579966360f, + -0.928932660967082820f, 0.370070588167669130f, -0.929003638191603360f, + 0.369892447148934270f, -0.929074581259315750f, 0.369714292530311240f, + -0.929145490167611720f, 0.369536124318350760f, -0.929216364913883930f, + 0.369357942519603190f, -0.929287205495526790f, 0.369179747140620070f, + -0.929358011909935500f, 0.369001538187952780f, -0.929428784154506800f, + 0.368823315668153960f, -0.929499522226638560f, 0.368645079587776150f, + -0.929570226123729860f, 0.368466829953372320f, -0.929640895843181330f, + 0.368288566771496680f, -0.929711531382394370f, 0.368110290048703050f, + -0.929782132738772190f, 0.367931999791546500f, -0.929852699909718750f, + 0.367753696006582090f, -0.929923232892639560f, 0.367575378700365330f, + -0.929993731684941480f, 0.367397047879452820f, -0.930064196284032360f, + 0.367218703550400930f, -0.930134626687321390f, 0.367040345719767240f, + -0.930205022892219070f, 0.366861974394109220f, -0.930275384896137040f, + 0.366683589579984930f, -0.930345712696488470f, 0.366505191283953480f, + -0.930416006290687550f, 0.366326779512573590f, -0.930486265676149780f, + 0.366148354272405390f, -0.930556490850291800f, 0.365969915570008910f, + -0.930626681810531650f, 0.365791463411944570f, -0.930696838554288860f, + 0.365612997804773960f, -0.930766961078983710f, 0.365434518755058390f, + -0.930837049382038150f, 0.365256026269360380f, -0.930907103460875020f, + 0.365077520354242180f, -0.930977123312918930f, 0.364899001016267380f, + -0.931047108935595170f, 0.364720468261999390f, -0.931117060326330790f, + 0.364541922098002180f, -0.931186977482553750f, 0.364363362530840730f, + -0.931256860401693420f, 0.364184789567079840f, -0.931326709081180430f, + 0.364006203213285530f, -0.931396523518446600f, 0.363827603476023610f, + -0.931466303710925090f, 0.363648990361860550f, -0.931536049656050300f, + 0.363470363877363870f, -0.931605761351257830f, 0.363291724029100700f, + -0.931675438793984620f, 0.363113070823639530f, -0.931745081981668720f, + 0.362934404267548750f, -0.931814690911749620f, 0.362755724367397230f, + -0.931884265581668150f, 0.362577031129754870f, -0.931953805988865900f, + 0.362398324561191310f, -0.932023312130786490f, 0.362219604668277570f, + -0.932092784004874050f, 0.362040871457584350f, -0.932162221608574320f, + 0.361862124935682980f, -0.932231624939334540f, 0.361683365109145950f, + -0.932300993994602640f, 0.361504591984545260f, -0.932370328771828460f, + 0.361325805568454340f, -0.932439629268462360f, 0.361147005867446190f, + -0.932508895481956700f, 0.360968192888095290f, -0.932578127409764420f, + 0.360789366636975690f, -0.932647325049340340f, 0.360610527120662270f, + -0.932716488398140250f, 0.360431674345730810f, -0.932785617453620990f, + 0.360252808318756830f, -0.932854712213241230f, 0.360073929046317080f, + -0.932923772674460140f, 0.359895036534988280f, -0.932992798834738850f, + 0.359716130791347570f, -0.933061790691539380f, 0.359537211821973180f, + -0.933130748242325110f, 0.359358279633443080f, -0.933199671484560730f, + 0.359179334232336560f, -0.933268560415712050f, 0.359000375625232630f, + -0.933337415033246080f, 0.358821403818710920f, -0.933406235334631520f, + 0.358642418819352100f, -0.933475021317337950f, 0.358463420633736540f, + -0.933543772978836170f, 0.358284409268445900f, -0.933612490316598540f, + 0.358105384730061760f, -0.933681173328098300f, 0.357926347025166070f, + -0.933749822010810580f, 0.357747296160342010f, -0.933818436362210960f, + 0.357568232142172260f, -0.933887016379776890f, 0.357389154977241000f, + -0.933955562060986730f, 0.357210064672131900f, -0.934024073403320500f, + 0.357030961233430030f, -0.934092550404258870f, 0.356851844667720410f, + -0.934160993061284420f, 0.356672714981588260f, -0.934229401371880820f, + 0.356493572181620200f, -0.934297775333532530f, 0.356314416274402360f, + -0.934366114943725900f, 0.356135247266522180f, -0.934434420199948050f, + 0.355956065164567010f, -0.934502691099687870f, 0.355776869975124640f, + -0.934570927640435030f, 0.355597661704783960f, -0.934639129819680780f, + 0.355418440360133590f, -0.934707297634917440f, 0.355239205947763370f, + -0.934775431083638700f, 0.355059958474263030f, -0.934843530163339430f, + 0.354880697946222790f, -0.934911594871516090f, 0.354701424370233940f, + -0.934979625205665800f, 0.354522137752887430f, -0.935047621163287430f, + 0.354342838100775600f, -0.935115582741880890f, 0.354163525420490510f, + -0.935183509938947500f, 0.353984199718624830f, -0.935251402751989810f, + 0.353804861001772160f, -0.935319261178511500f, 0.353625509276525970f, + -0.935387085216017770f, 0.353446144549480870f, -0.935454874862014620f, + 0.353266766827231180f, -0.935522630114009930f, 0.353087376116372530f, + -0.935590350969512370f, 0.352907972423500360f, -0.935658037426032040f, + 0.352728555755210730f, -0.935725689481080370f, 0.352549126118100580f, + -0.935793307132169900f, 0.352369683518766630f, -0.935860890376814640f, + 0.352190227963806890f, -0.935928439212529660f, 0.352010759459819240f, + -0.935995953636831300f, 0.351831278013402030f, -0.936063433647237540f, + 0.351651783631154680f, -0.936130879241266920f, 0.351472276319676260f, + -0.936198290416440090f, 0.351292756085567150f, -0.936265667170278260f, + 0.351113222935427630f, -0.936333009500304180f, 0.350933676875858360f, + -0.936400317404042060f, 0.350754117913461170f, -0.936467590879016880f, + 0.350574546054837570f, -0.936534829922755500f, 0.350394961306590200f, + -0.936602034532785570f, 0.350215363675321740f, -0.936669204706636060f, + 0.350035753167635300f, -0.936736340441837620f, 0.349856129790135030f, + -0.936803441735921560f, 0.349676493549424760f, -0.936870508586420960f, + 0.349496844452109600f, -0.936937540990869900f, 0.349317182504794320f, + -0.937004538946803690f, 0.349137507714085030f, -0.937071502451759190f, + 0.348957820086587600f, -0.937138431503274140f, 0.348778119628908420f, + -0.937205326098887960f, 0.348598406347655040f, -0.937272186236140950f, + 0.348418680249434510f, -0.937339011912574960f, 0.348238941340855310f, + -0.937405803125732850f, 0.348059189628525780f, -0.937472559873159140f, + 0.347879425119054510f, -0.937539282152399230f, 0.347699647819051490f, + -0.937605969960999990f, 0.347519857735126110f, -0.937672623296509470f, + 0.347340054873889190f, -0.937739242156476970f, 0.347160239241951330f, + -0.937805826538453010f, 0.346980410845923680f, -0.937872376439989890f, + 0.346800569692418400f, -0.937938891858640210f, 0.346620715788047320f, + -0.938005372791958840f, 0.346440849139423580f, -0.938071819237501160f, + 0.346260969753160170f, -0.938138231192824360f, 0.346081077635870480f, + -0.938204608655486490f, 0.345901172794169100f, -0.938270951623047080f, + 0.345721255234670120f, -0.938337260093066950f, 0.345541324963989150f, + -0.938403534063108060f, 0.345361381988741170f, -0.938469773530733800f, + 0.345181426315542610f, -0.938535978493508560f, 0.345001457951009780f, + -0.938602148948998290f, 0.344821476901759290f, -0.938668284894770170f, + 0.344641483174409070f, -0.938734386328392460f, 0.344461476775576480f, + -0.938800453247434770f, 0.344281457711880230f, -0.938866485649468060f, + 0.344101425989938980f, -0.938932483532064490f, 0.343921381616371700f, + -0.938998446892797540f, 0.343741324597798600f, -0.939064375729241950f, + 0.343561254940839330f, -0.939130270038973650f, 0.343381172652115100f, + -0.939196129819569900f, 0.343201077738246710f, -0.939261955068609100f, + 0.343020970205855540f, -0.939327745783671400f, 0.342840850061564060f, + -0.939393501962337510f, 0.342660717311994380f, -0.939459223602189920f, + 0.342480571963769850f, -0.939524910700812120f, 0.342300414023513690f, + -0.939590563255789160f, 0.342120243497849590f, -0.939656181264707070f, + 0.341940060393402300f, -0.939721764725153340f, 0.341759864716796310f, + -0.939787313634716570f, 0.341579656474657210f, -0.939852827990986680f, + 0.341399435673610360f, -0.939918307791555050f, 0.341219202320282410f, + -0.939983753034013940f, 0.341038956421299830f, -0.940049163715957370f, + 0.340858697983289440f, -0.940114539834980280f, 0.340678427012879310f, + -0.940179881388678810f, 0.340498143516697100f, -0.940245188374650880f, + 0.340317847501371730f, -0.940310460790495070f, 0.340137538973531880f, + -0.940375698633811540f, 0.339957217939806880f, -0.940440901902201750f, + 0.339776884406826960f, -0.940506070593268300f, 0.339596538381222060f, + -0.940571204704615190f, 0.339416179869623410f, -0.940636304233847590f, + 0.339235808878662120f, -0.940701369178571940f, 0.339055425414969640f, + -0.940766399536396070f, 0.338875029485178560f, -0.940831395304928870f, + 0.338694621095921190f, -0.940896356481780830f, 0.338514200253831000f, + -0.940961283064563280f, 0.338333766965541290f, -0.941026175050889260f, + 0.338153321237685990f, -0.941091032438372780f, 0.337972863076899830f, + -0.941155855224629190f, 0.337792392489817460f, -0.941220643407275180f, + 0.337611909483074680f, -0.941285396983928660f, 0.337431414063306790f, + -0.941350115952208970f, 0.337250906237150650f, -0.941414800309736230f, + 0.337070386011242730f, -0.941479450054132580f, 0.336889853392220050f, + -0.941544065183020810f, 0.336709308386720700f, -0.941608645694025140f, + 0.336528751001382350f, -0.941673191584771360f, 0.336348181242844100f, + -0.941737702852886160f, 0.336167599117744690f, -0.941802179495997650f, + 0.335987004632723350f, -0.941866621511735280f, 0.335806397794420560f, + -0.941931028897729510f, 0.335625778609476230f, -0.941995401651612550f, + 0.335445147084531660f, -0.942059739771017310f, 0.335264503226227970f, + -0.942124043253578460f, 0.335083847041206580f, -0.942188312096931770f, + 0.334903178536110290f, -0.942252546298714020f, 0.334722497717581220f, + -0.942316745856563780f, 0.334541804592262960f, -0.942380910768120470f, + 0.334361099166798900f, -0.942445041031024890f, 0.334180381447832740f, + -0.942509136642919240f, 0.333999651442009490f, -0.942573197601446870f, + 0.333818909155973620f, -0.942637223904252530f, 0.333638154596370920f, + -0.942701215548981900f, 0.333457387769846790f, -0.942765172533282510f, + 0.333276608683047980f, -0.942829094854802710f, 0.333095817342620890f, + -0.942892982511192130f, 0.332915013755212650f, -0.942956835500102120f, + 0.332734197927471160f, -0.943020653819184650f, 0.332553369866044220f, + -0.943084437466093490f, 0.332372529577580680f, -0.943148186438483420f, + 0.332191677068729320f, -0.943211900734010620f, 0.332010812346139380f, + -0.943275580350332540f, 0.331829935416461220f, -0.943339225285107720f, + 0.331649046286344620f, -0.943402835535996240f, 0.331468144962440920f, + -0.943466411100659320f, 0.331287231451400990f, -0.943529951976759370f, + 0.331106305759876430f, -0.943593458161960390f, 0.330925367894519650f, + -0.943656929653927110f, 0.330744417861982890f, -0.943720366450326200f, + 0.330563455668919590f, -0.943783768548825060f, 0.330382481321982950f, + -0.943847135947092690f, 0.330201494827826620f, -0.943910468642799150f, + 0.330020496193105530f, -0.943973766633615980f, 0.329839485424473940f, + -0.944037029917215830f, 0.329658462528587550f, -0.944100258491272660f, + 0.329477427512101680f, -0.944163452353461770f, 0.329296380381672800f, + -0.944226611501459810f, 0.329115321143957360f, -0.944289735932944410f, + 0.328934249805612200f, -0.944352825645594750f, 0.328753166373295100f, + -0.944415880637091250f, 0.328572070853663690f, -0.944478900905115550f, + 0.328390963253376630f, -0.944541886447350380f, 0.328209843579092660f, + -0.944604837261480260f, 0.328028711837470730f, -0.944667753345190490f, + 0.327847568035170960f, -0.944730634696167800f, 0.327666412178853060f, + -0.944793481312100280f, 0.327485244275178060f, -0.944856293190677210f, + 0.327304064330806830f, -0.944919070329589220f, 0.327122872352400510f, + -0.944981812726528150f, 0.326941668346621530f, -0.945044520379187070f, + 0.326760452320131790f, -0.945107193285260610f, 0.326579224279594460f, + -0.945169831442444150f, 0.326397984231672660f, -0.945232434848434890f, + 0.326216732183029770f, -0.945295003500931100f, 0.326035468140330350f, + -0.945357537397632290f, 0.325854192110238580f, -0.945420036536239070f, + 0.325672904099419900f, -0.945482500914453740f, 0.325491604114539260f, + -0.945544930529979680f, 0.325310292162262980f, -0.945607325380521280f, + 0.325128968249257190f, -0.945669685463784710f, 0.324947632382188430f, + -0.945732010777477150f, 0.324766284567724330f, -0.945794301319306860f, + 0.324584924812532150f, -0.945856557086983910f, 0.324403553123280290f, + -0.945918778078219110f, 0.324222169506637130f, -0.945980964290724760f, + 0.324040773969271450f, -0.946043115722214560f, 0.323859366517852960f, + -0.946105232370403340f, 0.323677947159051180f, -0.946167314233007370f, + 0.323496515899536760f, -0.946229361307743820f, 0.323315072745980150f, + -0.946291373592331510f, 0.323133617705052330f, -0.946353351084490590f, + 0.322952150783425370f, -0.946415293781942110f, 0.322770671987770710f, + -0.946477201682408680f, 0.322589181324761390f, -0.946539074783614100f, + 0.322407678801070020f, -0.946600913083283530f, 0.322226164423369650f, + -0.946662716579143360f, 0.322044638198334620f, -0.946724485268921170f, + 0.321863100132638580f, -0.946786219150346000f, 0.321681550232956640f, + -0.946847918221148000f, 0.321499988505963450f, -0.946909582479058760f, + 0.321318414958334910f, -0.946971211921810880f, 0.321136829596746780f, + -0.947032806547138620f, 0.320955232427875210f, -0.947094366352777220f, + 0.320773623458397440f, -0.947155891336463270f, 0.320592002694990330f, + -0.947217381495934820f, 0.320410370144331880f, -0.947278836828930880f, + 0.320228725813100020f, -0.947340257333191940f, 0.320047069707973140f, + -0.947401643006459900f, 0.319865401835630610f, -0.947462993846477700f, + 0.319683722202751370f, -0.947524309850989570f, 0.319502030816015750f, + -0.947585591017741090f, 0.319320327682103720f, -0.947646837344479190f, + 0.319138612807695900f, -0.947708048828952100f, 0.318956886199473770f, + -0.947769225468909180f, 0.318775147864118480f, -0.947830367262101010f, + 0.318593397808312470f, -0.947891474206279730f, 0.318411636038737960f, + -0.947952546299198560f, 0.318229862562077580f, -0.948013583538612200f, + 0.318048077385015060f, -0.948074585922276230f, 0.317866280514233660f, + -0.948135553447947980f, 0.317684471956418020f, -0.948196486113385580f, + 0.317502651718252260f, -0.948257383916349060f, 0.317320819806421790f, + -0.948318246854599090f, 0.317138976227611890f, -0.948379074925898120f, + 0.316957120988508150f, -0.948439868128009620f, 0.316775254095797380f, + -0.948500626458698260f, 0.316593375556165850f, -0.948561349915730270f, + 0.316411485376301090f, -0.948622038496872990f, 0.316229583562890490f, + -0.948682692199895090f, 0.316047670122621860f, -0.948743311022566480f, + 0.315865745062184070f, -0.948803894962658380f, 0.315683808388265600f, + -0.948864444017943340f, 0.315501860107556040f, -0.948924958186195160f, + 0.315319900226745050f, -0.948985437465188710f, 0.315137928752522440f, + -0.949045881852700560f, 0.314955945691579250f, -0.949106291346508260f, + 0.314773951050606070f, -0.949166665944390700f, 0.314591944836294710f, + -0.949227005644128210f, 0.314409927055336820f, -0.949287310443502010f, + 0.314227897714424500f, -0.949347580340295210f, 0.314045856820250820f, + -0.949407815332291460f, 0.313863804379508500f, -0.949468015417276550f, + 0.313681740398891570f, -0.949528180593036670f, 0.313499664885093450f, + -0.949588310857359950f, 0.313317577844809070f, -0.949648406208035480f, + 0.313135479284732950f, -0.949708466642853800f, 0.312953369211560200f, + -0.949768492159606680f, 0.312771247631986880f, -0.949828482756087000f, + 0.312589114552708660f, -0.949888438430089300f, 0.312406969980422500f, + -0.949948359179409010f, 0.312224813921825050f, -0.950008245001843000f, + 0.312042646383613510f, -0.950068095895189590f, 0.311860467372486130f, + -0.950127911857248100f, 0.311678276895140550f, -0.950187692885819280f, + 0.311496074958275970f, -0.950247438978705230f, 0.311313861568591090f, + -0.950307150133709140f, 0.311131636732785270f, -0.950366826348635780f, + 0.310949400457558760f, -0.950426467621290900f, 0.310767152749611470f, + -0.950486073949481700f, 0.310584893615644560f, -0.950545645331016600f, + 0.310402623062358880f, -0.950605181763705230f, 0.310220341096455910f, + -0.950664683245358910f, 0.310038047724638000f, -0.950724149773789610f, + 0.309855742953607130f, -0.950783581346811070f, 0.309673426790066490f, + -0.950842977962238160f, 0.309491099240719050f, -0.950902339617887060f, + 0.309308760312268780f, -0.950961666311575080f, 0.309126410011419550f, + -0.951020958041121080f, 0.308944048344875710f, -0.951080214804345010f, + 0.308761675319342570f, -0.951139436599068190f, 0.308579290941525030f, + -0.951198623423113230f, 0.308396895218129240f, -0.951257775274304000f, + 0.308214488155861220f, -0.951316892150465550f, 0.308032069761427330f, + -0.951375974049424420f, 0.307849640041534980f, -0.951435020969008340f, + 0.307667199002891190f, -0.951494032907046370f, 0.307484746652204160f, + -0.951553009861368590f, 0.307302282996181950f, -0.951611951829806730f, + 0.307119808041533100f, -0.951670858810193860f, 0.306937321794967020f, + -0.951729730800363720f, 0.306754824263192780f, -0.951788567798152130f, + 0.306572315452920800f, -0.951847369801395620f, 0.306389795370861080f, + -0.951906136807932230f, 0.306207264023724280f, -0.951964868815601380f, + 0.306024721418221900f, -0.952023565822243570f, 0.305842167561065080f, + -0.952082227825700620f, 0.305659602458966230f, -0.952140854823815830f, + 0.305477026118637360f, -0.952199446814433580f, 0.305294438546791720f, + -0.952258003795399600f, 0.305111839750142220f, -0.952316525764560830f, + 0.304929229735402430f, -0.952375012719765880f, 0.304746608509286640f, + -0.952433464658864030f, 0.304563976078509050f, -0.952491881579706320f, + 0.304381332449784940f, -0.952550263480144930f, 0.304198677629829270f, + -0.952608610358033240f, 0.304016011625357570f, -0.952666922211226170f, + 0.303833334443086470f, -0.952725199037579570f, 0.303650646089731910f, + -0.952783440834950920f, 0.303467946572011370f, -0.952841647601198720f, + 0.303285235896641910f, -0.952899819334182880f, 0.303102514070341060f, + -0.952957956031764700f, 0.302919781099827420f, -0.953016057691806530f, + 0.302737036991819140f, -0.953074124312172200f, 0.302554281753035670f, + -0.953132155890726750f, 0.302371515390196130f, -0.953190152425336560f, + 0.302188737910020040f, -0.953248113913869320f, 0.302005949319228200f, + -0.953306040354193750f, 0.301823149624540650f, -0.953363931744180330f, + 0.301640338832678880f, -0.953421788081700310f, 0.301457516950363940f, + -0.953479609364626610f, 0.301274683984318000f, -0.953537395590833280f, + 0.301091839941263210f, -0.953595146758195680f, 0.300908984827921890f, + -0.953652862864590500f, 0.300726118651017620f, -0.953710543907895560f, + 0.300543241417273400f, -0.953768189885990330f, 0.300360353133413580f, + -0.953825800796755050f, 0.300177453806162120f, -0.953883376638071770f, + 0.299994543442243580f, -0.953940917407823500f, 0.299811622048383460f, + -0.953998423103894490f, 0.299628689631306790f, -0.954055893724170660f, + 0.299445746197739950f, -0.954113329266538800f, 0.299262791754409010f, + -0.954170729728887280f, 0.299079826308040480f, -0.954228095109105670f, + 0.298896849865361910f, -0.954285425405084650f, 0.298713862433100390f, + -0.954342720614716480f, 0.298530864017984230f, -0.954399980735894490f, + 0.298347854626741570f, -0.954457205766513490f, 0.298164834266100910f, + -0.954514395704469500f, 0.297981802942791920f, -0.954571550547659630f, + 0.297798760663543550f, -0.954628670293982680f, 0.297615707435086310f, + -0.954685754941338340f, 0.297432643264150030f, -0.954742804487627940f, + 0.297249568157465890f, -0.954799818930753720f, 0.297066482121764840f, + -0.954856798268619580f, 0.296883385163778270f, -0.954913742499130520f, + 0.296700277290238460f, -0.954970651620192790f, 0.296517158507877410f, + -0.955027525629714160f, 0.296334028823428240f, -0.955084364525603410f, + 0.296150888243623960f, -0.955141168305770670f, 0.295967736775197890f, + -0.955197936968127710f, 0.295784574424884370f, -0.955254670510586990f, + 0.295601401199417360f, -0.955311368931062720f, 0.295418217105532070f, + -0.955368032227470240f, 0.295235022149963390f, -0.955424660397726330f, + 0.295051816339446720f, -0.955481253439748770f, 0.294868599680718380f, + -0.955537811351456770f, 0.294685372180514330f, -0.955594334130771110f, + 0.294502133845571720f, -0.955650821775613220f, 0.294318884682627570f, + -0.955707274283906560f, 0.294135624698419080f, -0.955763691653575440f, + 0.293952353899684770f, -0.955820073882545420f, 0.293769072293162400f, + -0.955876420968743590f, 0.293585779885591310f, -0.955932732910098170f, + 0.293402476683710060f, -0.955989009704538930f, 0.293219162694258680f, + -0.956045251349996410f, 0.293035837923976920f, -0.956101457844403040f, + 0.292852502379604810f, -0.956157629185692140f, 0.292669156067883570f, + -0.956213765371798470f, 0.292485798995553830f, -0.956269866400658140f, + 0.292302431169357610f, -0.956325932270208230f, 0.292119052596036540f, + -0.956381962978387620f, 0.291935663282332780f, -0.956437958523136180f, + 0.291752263234989370f, -0.956493918902394990f, 0.291568852460749040f, + -0.956549844114106820f, 0.291385430966355720f, -0.956605734156215080f, + 0.291201998758553020f, -0.956661589026664980f, 0.291018555844085090f, + -0.956717408723403050f, 0.290835102229696940f, -0.956773193244376930f, + 0.290651637922133220f, -0.956828942587535370f, 0.290468162928139870f, + -0.956884656750828900f, 0.290284677254462330f, -0.956940335732208940f, + 0.290101180907847140f, -0.956995979529628230f, 0.289917673895040860f, + -0.957051588141040970f, 0.289734156222790250f, -0.957107161564402790f, + 0.289550627897843140f, -0.957162699797670100f, 0.289367088926946960f, + -0.957218202838801210f, 0.289183539316850310f, -0.957273670685755200f, + 0.288999979074301530f, -0.957329103336492790f, 0.288816408206049480f, + -0.957384500788975860f, 0.288632826718843940f, -0.957439863041167570f, + 0.288449234619434170f, -0.957495190091032570f, 0.288265631914570830f, + -0.957550481936536470f, 0.288082018611004300f, -0.957605738575646240f, + 0.287898394715485170f, -0.957660960006330610f, 0.287714760234765280f, + -0.957716146226558870f, 0.287531115175595930f, -0.957771297234302320f, + 0.287347459544729570f, -0.957826413027532910f, 0.287163793348918560f, + -0.957881493604224250f, 0.286980116594915570f, -0.957936538962351420f, + 0.286796429289474190f, -0.957991549099890370f, 0.286612731439347790f, + -0.958046524014818600f, 0.286429023051290750f, -0.958101463705114620f, + 0.286245304132057120f, -0.958156368168758820f, 0.286061574688402100f, + -0.958211237403732260f, 0.285877834727080730f, -0.958266071408017670f, + 0.285694084254848320f, -0.958320870179598880f, 0.285510323278461380f, + -0.958375633716461170f, 0.285326551804675810f, -0.958430362016591040f, + 0.285142769840248720f, -0.958485055077976100f, 0.284958977391937150f, + -0.958539712898605730f, 0.284775174466498300f, -0.958594335476470220f, + 0.284591361070690550f, -0.958648922809561040f, 0.284407537211271820f, + -0.958703474895871600f, 0.284223702895001100f, -0.958757991733395710f, + 0.284039858128637360f, -0.958812473320129200f, 0.283856002918939750f, + -0.958866919654069010f, 0.283672137272668550f, -0.958921330733213060f, + 0.283488261196583550f, -0.958975706555561080f, 0.283304374697445790f, + -0.959030047119113550f, 0.283120477782015990f, -0.959084352421872730f, + 0.282936570457055390f, -0.959138622461841890f, 0.282752652729326040f, + -0.959192857237025740f, 0.282568724605589740f, -0.959247056745430090f, + 0.282384786092609420f, -0.959301220985062210f, 0.282200837197147500f, + -0.959355349953930790f, 0.282016877925967690f, -0.959409443650045550f, + 0.281832908285833460f, -0.959463502071417510f, 0.281648928283508680f, + -0.959517525216059260f, 0.281464937925758050f, -0.959571513081984520f, + 0.281280937219346110f, -0.959625465667208300f, 0.281096926171038320f, + -0.959679382969746750f, 0.280912904787600120f, -0.959733264987617680f, + 0.280728873075797190f, -0.959787111718839900f, 0.280544831042396360f, + -0.959840923161433660f, 0.280360778694163810f, -0.959894699313420530f, + 0.280176716037867040f, -0.959948440172823210f, 0.279992643080273380f, + -0.960002145737665850f, 0.279808559828150390f, -0.960055816005973890f, + 0.279624466288266700f, -0.960109450975773940f, 0.279440362467390510f, + -0.960163050645094000f, 0.279256248372291240f, -0.960216615011963430f, + 0.279072124009737970f, -0.960270144074412800f, 0.278887989386500280f, + -0.960323637830473920f, 0.278703844509348600f, -0.960377096278180130f, + 0.278519689385053060f, -0.960430519415565790f, 0.278335524020384970f, + -0.960483907240666790f, 0.278151348422115090f, -0.960537259751520050f, + 0.277967162597015430f, -0.960590576946164120f, 0.277782966551857800f, + -0.960643858822638470f, 0.277598760293414290f, -0.960697105378984450f, + 0.277414543828458200f, -0.960750316613243950f, 0.277230317163762120f, + -0.960803492523460760f, 0.277046080306099950f, -0.960856633107679660f, + 0.276861833262245390f, -0.960909738363946770f, 0.276677576038972420f, + -0.960962808290309780f, 0.276493308643056100f, -0.961015842884817230f, + 0.276309031081271030f, -0.961068842145519350f, 0.276124743360392890f, + -0.961121806070467380f, 0.275940445487197320f, -0.961174734657714080f, + 0.275756137468460120f, -0.961227627905313460f, 0.275571819310958250f, + -0.961280485811320640f, 0.275387491021468140f, -0.961333308373792270f, + 0.275203152606767370f, -0.961386095590786250f, 0.275018804073633380f, + -0.961438847460361570f, 0.274834445428843940f, -0.961491563980579000f, + 0.274650076679177790f, -0.961544245149499990f, 0.274465697831413220f, + -0.961596890965187860f, 0.274281308892329710f, -0.961649501425706820f, + 0.274096909868706330f, -0.961702076529122540f, 0.273912500767323320f, + -0.961754616273502010f, 0.273728081594960650f, -0.961807120656913540f, + 0.273543652358398730f, -0.961859589677426570f, 0.273359213064418790f, + -0.961912023333112100f, 0.273174763719801870f, -0.961964421622042320f, + 0.272990304331329980f, -0.962016784542290560f, 0.272805834905784920f, + -0.962069112091931580f, 0.272621355449948980f, -0.962121404269041580f, + 0.272436865970605350f, -0.962173661071697770f, 0.272252366474536660f, + -0.962225882497979020f, 0.272067856968526980f, -0.962278068545965090f, + 0.271883337459359890f, -0.962330219213737400f, 0.271698807953819510f, + -0.962382334499378380f, 0.271514268458690810f, -0.962434414400971990f, + 0.271329718980758420f, -0.962486458916603450f, 0.271145159526808070f, + -0.962538468044359160f, 0.270960590103625330f, -0.962590441782326780f, + 0.270776010717996010f, -0.962642380128595710f, 0.270591421376707050f, + -0.962694283081255930f, 0.270406822086544820f, -0.962746150638399410f, + 0.270222212854296930f, -0.962797982798119010f, 0.270037593686750510f, + -0.962849779558509030f, 0.269852964590693910f, -0.962901540917665000f, + 0.269668325572915200f, -0.962953266873683880f, 0.269483676640202840f, + -0.963004957424663850f, 0.269299017799346230f, -0.963056612568704340f, + 0.269114349057134330f, -0.963108232303906190f, 0.268929670420357310f, + -0.963159816628371360f, 0.268744981895805090f, -0.963211365540203480f, + 0.268560283490267890f, -0.963262879037507070f, 0.268375575210537010f, + -0.963314357118388090f, 0.268190857063403180f, -0.963365799780954050f, + 0.268006129055658350f, -0.963417207023313350f, 0.267821391194094320f, + -0.963468578843575950f, 0.267636643485503090f, -0.963519915239853140f, + 0.267451885936677740f, -0.963571216210257210f, 0.267267118554410930f, + -0.963622481752902220f, 0.267082341345496350f, -0.963673711865903230f, + 0.266897554316727510f, -0.963724906547376410f, 0.266712757474898420f, + -0.963776065795439840f, 0.266527950826803810f, -0.963827189608212340f, + 0.266343134379238180f, -0.963878277983814200f, 0.266158308138997050f, + -0.963929330920367140f, 0.265973472112875530f, -0.963980348415994110f, + 0.265788626307669970f, -0.964031330468819280f, 0.265603770730176440f, + -0.964082277076968140f, 0.265418905387191260f, -0.964133188238567640f, + 0.265234030285511900f, -0.964184063951745720f, 0.265049145431935200f, + -0.964234904214632200f, 0.264864250833259320f, -0.964285709025357370f, + 0.264679346496282050f, -0.964336478382053720f, 0.264494432427801630f, + -0.964387212282854290f, 0.264309508634617220f, -0.964437910725893910f, + 0.264124575123527490f, -0.964488573709308410f, 0.263939631901332410f, + -0.964539201231235150f, 0.263754678974831510f, -0.964589793289812650f, + 0.263569716350824880f, -0.964640349883180930f, 0.263384744036113390f, + -0.964690871009480920f, 0.263199762037497560f, -0.964741356666855340f, + 0.263014770361779060f, -0.964791806853447900f, 0.262829769015759330f, + -0.964842221567403510f, 0.262644758006240100f, -0.964892600806868890f, + 0.262459737340024090f, -0.964942944569991410f, 0.262274707023913590f, + -0.964993252854920320f, 0.262089667064712100f, -0.965043525659805890f, + 0.261904617469222560f, -0.965093762982799590f, 0.261719558244249080f, + -0.965143964822054450f, 0.261534489396595630f, -0.965194131175724720f, + 0.261349410933066350f, -0.965244262041965780f, 0.261164322860466590f, + -0.965294357418934660f, 0.260979225185601020f, -0.965344417304789370f, + 0.260794117915275570f, -0.965394441697689400f, 0.260609001056295920f, + -0.965444430595795430f, 0.260423874615468010f, -0.965494383997269500f, + 0.260238738599598950f, -0.965544301900275070f, 0.260053593015495130f, + -0.965594184302976830f, 0.259868437869964330f, -0.965644031203540590f, + 0.259683273169813930f, -0.965693842600133690f, 0.259498098921851660f, + -0.965743618490924830f, 0.259312915132886350f, -0.965793358874083570f, + 0.259127721809726150f, -0.965843063747781510f, 0.258942518959180580f, + -0.965892733110190860f, 0.258757306588058840f, -0.965942366959485540f, + 0.258572084703170390f, -0.965991965293840570f, 0.258386853311325710f, + -0.966041528111432400f, 0.258201612419334870f, -0.966091055410438830f, + 0.258016362034009070f, -0.966140547189038750f, 0.257831102162158930f, + -0.966190003445412620f, 0.257645832810596440f, -0.966239424177741890f, + 0.257460553986133210f, -0.966288809384209580f, 0.257275265695581120f, + -0.966338159063000130f, 0.257089967945753230f, -0.966387473212298790f, + 0.256904660743461850f, -0.966436751830292650f, 0.256719344095520720f, + -0.966485994915169840f, 0.256534018008743200f, -0.966535202465119700f, + 0.256348682489942910f, -0.966584374478333120f, 0.256163337545934570f, + -0.966633510953002100f, 0.255977983183532380f, -0.966682611887320190f, + 0.255792619409551670f, -0.966731677279481840f, 0.255607246230807550f, + -0.966780707127683270f, 0.255421863654115460f, -0.966829701430121810f, + 0.255236471686291820f, -0.966878660184995910f, 0.255051070334152530f, + -0.966927583390505660f, 0.254865659604514630f, -0.966976471044852070f, + 0.254680239504194990f, -0.967025323146237900f, 0.254494810040010790f, + -0.967074139692867040f, 0.254309371218780110f, -0.967122920682944360f, + 0.254123923047320620f, -0.967171666114676640f, 0.253938465532451140f, + -0.967220375986271310f, 0.253752998680989940f, -0.967269050295937790f, + 0.253567522499756610f, -0.967317689041886310f, 0.253382036995570270f, + -0.967366292222328510f, 0.253196542175250560f, -0.967414859835477480f, + 0.253011038045617980f, -0.967463391879547440f, 0.252825524613492610f, + -0.967511888352754150f, 0.252640001885695580f, -0.967560349253314360f, + 0.252454469869047900f, -0.967608774579446380f, 0.252268928570370810f, + -0.967657164329369880f, 0.252083377996486560f, -0.967705518501305480f, + 0.251897818154216910f, -0.967753837093475510f, 0.251712249050384750f, + -0.967802120104103270f, 0.251526670691812780f, -0.967850367531413620f, + 0.251341083085323880f, -0.967898579373632660f, 0.251155486237742030f, + -0.967946755628987800f, 0.250969880155890720f, -0.967994896295707670f, + 0.250784264846594550f, -0.968043001372022260f, 0.250598640316677830f, + -0.968091070856162970f, 0.250413006572965280f, -0.968139104746362330f, + 0.250227363622282540f, -0.968187103040854420f, 0.250041711471454650f, + -0.968235065737874320f, 0.249856050127308050f, -0.968282992835658660f, + 0.249670379596668520f, -0.968330884332445300f, 0.249484699886363010f, + -0.968378740226473300f, 0.249299011003218300f, -0.968426560515983190f, + 0.249113312954061360f, -0.968474345199216820f, 0.248927605745720260f, + -0.968522094274417270f, 0.248741889385022420f, -0.968569807739828930f, + 0.248556163878796620f, -0.968617485593697540f, 0.248370429233871150f, + -0.968665127834269950f, 0.248184685457074780f, -0.968712734459794780f, + 0.247998932555237220f, -0.968760305468521430f, 0.247813170535187620f, + -0.968807840858700970f, 0.247627399403756330f, -0.968855340628585580f, + 0.247441619167773440f, -0.968902804776428870f, 0.247255829834069320f, + -0.968950233300485800f, 0.247070031409475370f, -0.968997626199012310f, + 0.246884223900822430f, -0.969044983470266240f, 0.246698407314942500f, + -0.969092305112506100f, 0.246512581658667380f, -0.969139591123992280f, + 0.246326746938829060f, -0.969186841502985950f, 0.246140903162260640f, + -0.969234056247750050f, 0.245955050335794590f, -0.969281235356548530f, + 0.245769188466264670f, -0.969328378827646660f, 0.245583317560504000f, + -0.969375486659311280f, 0.245397437625346990f, -0.969422558849810320f, + 0.245211548667627680f, -0.969469595397412950f, 0.245025650694180470f, + -0.969516596300390000f, 0.244839743711840750f, -0.969563561557013180f, + 0.244653827727443320f, -0.969610491165555870f, 0.244467902747824210f, + -0.969657385124292450f, 0.244281968779819170f, -0.969704243431498750f, + 0.244096025830264210f, -0.969751066085452140f, 0.243910073905996370f, + -0.969797853084430890f, 0.243724113013852130f, -0.969844604426714830f, + 0.243538143160669180f, -0.969891320110585100f, 0.243352164353284880f, + -0.969938000134323960f, 0.243166176598536930f, -0.969984644496215240f, + 0.242980179903263980f, -0.970031253194543970f, 0.242794174274304190f, + -0.970077826227596420f, 0.242608159718496890f, -0.970124363593660280f, + 0.242422136242681050f, -0.970170865291024360f, 0.242236103853696040f, + -0.970217331317979160f, 0.242050062558382180f, -0.970263761672816140f, + 0.241864012363579210f, -0.970310156353828110f, 0.241677953276128090f, + -0.970356515359309450f, 0.241491885302869300f, -0.970402838687555500f, + 0.241305808450644390f, -0.970449126336863090f, 0.241119722726294730f, + -0.970495378305530450f, 0.240933628136661910f, -0.970541594591857070f, + 0.240747524688588540f, -0.970587775194143630f, 0.240561412388916620f, + -0.970633920110692160f, 0.240375291244489500f, -0.970680029339806130f, + 0.240189161262150040f, -0.970726102879790110f, 0.240003022448741500f, + -0.970772140728950350f, 0.239816874811108110f, -0.970818142885593870f, + 0.239630718356093560f, -0.970864109348029470f, 0.239444553090542720f, + -0.970910040114567050f, 0.239258379021300120f, -0.970955935183517970f, + 0.239072196155210660f, -0.971001794553194690f, 0.238886004499120170f, + -0.971047618221911100f, 0.238699804059873950f, -0.971093406187982460f, + 0.238513594844318500f, -0.971139158449725090f, 0.238327376859299970f, + -0.971184875005457030f, 0.238141150111664870f, -0.971230555853497380f, + 0.237954914608260650f, -0.971276200992166490f, 0.237768670355934210f, + -0.971321810419786160f, 0.237582417361533650f, -0.971367384134679490f, + 0.237396155631906550f, -0.971412922135170940f, 0.237209885173901620f, + -0.971458424419585960f, 0.237023605994367340f, -0.971503890986251780f, + 0.236837318100152380f, -0.971549321833496630f, 0.236651021498106460f, + -0.971594716959650160f, 0.236464716195078750f, -0.971640076363043390f, + 0.236278402197919620f, -0.971685400042008540f, 0.236092079513479050f, + -0.971730687994879160f, 0.235905748148607370f, -0.971775940219990140f, + 0.235719408110155930f, -0.971821156715677700f, 0.235533059404975460f, + -0.971866337480279400f, 0.235346702039917920f, -0.971911482512134000f, + 0.235160336021834860f, -0.971956591809581600f, 0.234973961357578310f, + -0.972001665370963890f, 0.234787578054001080f, -0.972046703194623380f, + 0.234601186117955550f, -0.972091705278904430f, 0.234414785556295250f, + -0.972136671622152120f, 0.234228376375873380f, -0.972181602222713440f, + 0.234041958583543460f, -0.972226497078936270f, 0.233855532186159950f, + -0.972271356189170040f, 0.233669097190576820f, -0.972316179551765300f, + 0.233482653603649170f, -0.972360967165074140f, 0.233296201432231560f, + -0.972405719027449770f, 0.233109740683179740f, -0.972450435137246830f, + 0.232923271363349120f, -0.972495115492821190f, 0.232736793479595420f, + -0.972539760092530180f, 0.232550307038775330f, -0.972584368934732210f, + 0.232363812047745010f, -0.972628942017787270f, 0.232177308513361770f, + -0.972673479340056430f, 0.231990796442482580f, -0.972717980899902250f, + 0.231804275841964780f, -0.972762446695688570f, 0.231617746718666580f, + -0.972806876725780370f, 0.231431209079445730f, -0.972851270988544180f, + 0.231244662931161110f, -0.972895629482347760f, 0.231058108280671280f, + -0.972939952205560070f, 0.230871545134835070f, -0.972984239156551740f, + 0.230684973500512310f, -0.973028490333694100f, 0.230498393384562320f, + -0.973072705735360530f, 0.230311804793845530f, -0.973116885359925130f, + 0.230125207735222020f, -0.973161029205763530f, 0.229938602215552260f, + -0.973205137271252800f, 0.229751988241697600f, -0.973249209554771120f, + 0.229565365820518870f, -0.973293246054698250f, 0.229378734958878120f, + -0.973337246769414800f, 0.229192095663636740f, -0.973381211697303290f, + 0.229005447941657390f, -0.973425140836747030f, 0.228818791799802360f, + -0.973469034186130950f, 0.228632127244934230f, -0.973512891743841370f, + 0.228445454283916550f, -0.973556713508265560f, 0.228258772923612350f, + -0.973600499477792370f, 0.228072083170885790f, -0.973644249650811870f, + 0.227885385032600700f, -0.973687964025715670f, 0.227698678515621170f, + -0.973731642600896400f, 0.227511963626812390f, -0.973775285374748000f, + 0.227325240373038830f, -0.973818892345666100f, 0.227138508761166260f, + -0.973862463512047300f, 0.226951768798059980f, -0.973905998872289460f, + 0.226765020490585720f, -0.973949498424792170f, 0.226578263845610110f, + -0.973992962167955830f, 0.226391498869999210f, -0.974036390100182610f, + 0.226204725570620270f, -0.974079782219875680f, 0.226017943954340190f, + -0.974123138525439520f, 0.225831154028026200f, -0.974166459015280320f, + 0.225644355798546440f, -0.974209743687805110f, 0.225457549272768540f, + -0.974252992541422500f, 0.225270734457561240f, -0.974296205574542330f, + 0.225083911359792780f, -0.974339382785575860f, 0.224897079986332540f, + -0.974382524172935470f, 0.224710240344049570f, -0.974425629735034990f, + 0.224523392439813170f, -0.974468699470289580f, 0.224336536280493690f, + -0.974511733377115720f, 0.224149671872960840f, -0.974554731453931230f, + 0.223962799224085520f, -0.974597693699155050f, 0.223775918340738290f, + -0.974640620111207560f, 0.223589029229790020f, -0.974683510688510670f, + 0.223402131898112480f, -0.974726365429487320f, 0.223215226352576960f, + -0.974769184332561770f, 0.223028312600055870f, -0.974811967396159830f, + 0.222841390647421280f, -0.974854714618708430f, 0.222654460501545550f, + -0.974897425998635820f, 0.222467522169301990f, -0.974940101534371720f, + 0.222280575657563370f, -0.974982741224347140f, 0.222093620973203590f, + -0.975025345066994120f, 0.221906658123096260f, -0.975067913060746360f, + 0.221719687114115240f, -0.975110445204038890f, 0.221532707953135340f, + -0.975152941495307620f, 0.221345720647030810f, -0.975195401932990370f, + 0.221158725202677100f, -0.975237826515525820f, 0.220971721626949060f, + -0.975280215241354220f, 0.220784709926722670f, -0.975322568108916930f, + 0.220597690108873650f, -0.975364885116656870f, 0.220410662180277940f, + -0.975407166263018270f, 0.220223626147812460f, -0.975449411546446380f, + 0.220036582018353550f, -0.975491620965388110f, 0.219849529798778750f, + -0.975533794518291360f, 0.219662469495965180f, -0.975575932203605610f, + 0.219475401116790340f, -0.975618034019781750f, 0.219288324668132580f, + -0.975660099965271590f, 0.219101240156869770f, -0.975702130038528570f, + 0.218914147589880900f, -0.975744124238007270f, 0.218727046974044600f, + -0.975786082562163930f, 0.218539938316239830f, -0.975828005009455550f, + 0.218352821623346430f, -0.975869891578341030f, 0.218165696902243770f, + -0.975911742267280170f, 0.217978564159812290f, -0.975953557074734300f, + 0.217791423402932120f, -0.975995335999165880f, 0.217604274638483670f, + -0.976037079039039020f, 0.217417117873348300f, -0.976078786192818850f, + 0.217229953114406790f, -0.976120457458971910f, 0.217042780368541080f, + -0.976162092835966110f, 0.216855599642632570f, -0.976203692322270560f, + 0.216668410943563790f, -0.976245255916355800f, 0.216481214278216900f, + -0.976286783616693630f, 0.216294009653474370f, -0.976328275421757260f, + 0.216106797076219600f, -0.976369731330021140f, 0.215919576553335460f, + -0.976411151339961040f, 0.215732348091705940f, -0.976452535450054060f, + 0.215545111698214660f, -0.976493883658778540f, 0.215357867379745550f, + -0.976535195964614470f, 0.215170615143183500f, -0.976576472366042610f, + 0.214983354995412820f, -0.976617712861545640f, 0.214796086943318920f, + -0.976658917449606980f, 0.214608810993786920f, -0.976700086128711840f, + 0.214421527153702190f, -0.976741218897346550f, 0.214234235429951100f, + -0.976782315753998650f, 0.214046935829419330f, -0.976823376697157240f, + 0.213859628358993830f, -0.976864401725312640f, 0.213672313025561140f, + -0.976905390836956490f, 0.213484989836008080f, -0.976946344030581560f, + 0.213297658797222430f, -0.976987261304682390f, 0.213110319916091360f, + -0.977028142657754390f, 0.212922973199503260f, -0.977068988088294450f, + 0.212735618654345870f, -0.977109797594800880f, 0.212548256287508120f, + -0.977150571175773200f, 0.212360886105878580f, -0.977191308829712280f, + 0.212173508116346080f, -0.977232010555120320f, 0.211986122325800410f, + -0.977272676350500860f, 0.211798728741130820f, -0.977313306214358750f, + 0.211611327369227610f, -0.977353900145199960f, 0.211423918216980810f, + -0.977394458141532250f, 0.211236501291280710f, -0.977434980201864260f, + 0.211049076599018500f, -0.977475466324706050f, 0.210861644147084830f, + -0.977515916508569280f, 0.210674203942371490f, -0.977556330751966460f, + 0.210486755991769890f, -0.977596709053411780f, 0.210299300302171750f, + -0.977637051411420770f, 0.210111836880469720f, -0.977677357824509930f, + 0.209924365733555860f, -0.977717628291197570f, 0.209736886868323370f, + -0.977757862810002760f, 0.209549400291665110f, -0.977798061379446360f, + 0.209361906010474190f, -0.977838223998050430f, 0.209174404031644700f, + -0.977878350664338150f, 0.208986894362070070f, -0.977918441376834370f, + 0.208799377008644980f, -0.977958496134064830f, 0.208611851978263460f, + -0.977998514934557140f, 0.208424319277820650f, -0.978038497776839600f, + 0.208236778914211470f, -0.978078444659442380f, 0.208049230894330940f, + -0.978118355580896660f, 0.207861675225075150f, -0.978158230539735050f, + 0.207674111913339540f, -0.978198069534491400f, 0.207486540966020700f, + -0.978237872563701090f, 0.207298962390014880f, -0.978277639625900420f, + 0.207111376192218560f, -0.978317370719627650f, 0.206923782379529210f, + -0.978357065843421640f, 0.206736180958843660f, -0.978396724995823090f, + 0.206548571937059940f, -0.978436348175373730f, 0.206360955321075680f, + -0.978475935380616830f, 0.206173331117788770f, -0.978515486610096910f, + 0.205985699334098050f, -0.978555001862359550f, 0.205798059976901760f, + -0.978594481135952270f, 0.205610413053099320f, -0.978633924429423100f, + 0.205422758569589780f, -0.978673331741322210f, 0.205235096533272380f, + -0.978712703070200420f, 0.205047426951047380f, -0.978752038414610340f, + 0.204859749829814420f, -0.978791337773105670f, 0.204672065176474290f, + -0.978830601144241470f, 0.204484372997927180f, -0.978869828526574120f, + 0.204296673301074430f, -0.978909019918661310f, 0.204108966092817010f, + -0.978948175319062200f, 0.203921251380056150f, -0.978987294726337050f, + 0.203733529169694010f, -0.979026378139047580f, 0.203545799468632190f, + -0.979065425555756930f, 0.203358062283773370f, -0.979104436975029250f, + 0.203170317622019920f, -0.979143412395430230f, 0.202982565490274460f, + -0.979182351815526930f, 0.202794805895440550f, -0.979221255233887700f, + 0.202607038844421110f, -0.979260122649082020f, 0.202419264344120220f, + -0.979298954059681040f, 0.202231482401441620f, -0.979337749464256780f, + 0.202043693023289280f, -0.979376508861383170f, 0.201855896216568160f, + -0.979415232249634780f, 0.201668091988182500f, -0.979453919627588210f, + 0.201480280345037820f, -0.979492570993820700f, 0.201292461294039190f, + -0.979531186346911390f, 0.201104634842091960f, -0.979569765685440520f, + 0.200916800996102370f, -0.979608309007989450f, 0.200728959762976140f, + -0.979646816313141210f, 0.200541111149620090f, -0.979685287599479930f, + 0.200353255162940420f, -0.979723722865591170f, 0.200165391809844500f, + -0.979762122110061640f, 0.199977521097239290f, -0.979800485331479680f, + 0.199789643032032120f, -0.979838812528434740f, 0.199601757621131050f, + -0.979877103699517640f, 0.199413864871443750f, -0.979915358843320480f, + 0.199225964789878890f, -0.979953577958436740f, 0.199038057383344820f, + -0.979991761043461200f, 0.198850142658750120f, -0.980029908096989980f, + 0.198662220623004320f, -0.980068019117620650f, 0.198474291283016360f, + -0.980106094103951770f, 0.198286354645696270f, -0.980144133054583590f, + 0.198098410717953730f, -0.980182135968117320f, 0.197910459506698720f, + -0.980220102843155970f, 0.197722501018842030f, -0.980258033678303550f, + 0.197534535261294000f, -0.980295928472165290f, 0.197346562240966000f, + -0.980333787223347960f, 0.197158581964769040f, -0.980371609930459690f, + 0.196970594439614370f, -0.980409396592109910f, 0.196782599672414240f, + -0.980447147206909060f, 0.196594597670080220f, -0.980484861773469380f, + 0.196406588439525050f, -0.980522540290404090f, 0.196218571987660850f, + -0.980560182756327950f, 0.196030548321400880f, -0.980597789169856850f, + 0.195842517447657990f, -0.980635359529608120f, 0.195654479373345370f, + -0.980672893834200530f, 0.195466434105377090f, -0.980710392082253970f, + 0.195278381650666520f, -0.980747854272389750f, 0.195090322016128330f, + -0.980785280403230430f, 0.194902255208676660f, -0.980822670473399990f, + 0.194714181235225990f, -0.980860024481523870f, 0.194526100102691720f, + -0.980897342426228390f, 0.194338011817988600f, -0.980934624306141640f, + 0.194149916388032530f, -0.980971870119892840f, 0.193961813819739010f, + -0.981009079866112630f, 0.193773704120023840f, -0.981046253543432780f, + 0.193585587295803750f, -0.981083391150486590f, 0.193397463353994740f, + -0.981120492685908730f, 0.193209332301514080f, -0.981157558148334830f, + 0.193021194145278320f, -0.981194587536402320f, 0.192833048892205290f, + -0.981231580848749730f, 0.192644896549212240f, -0.981268538084016710f, + 0.192456737123216840f, -0.981305459240844670f, 0.192268570621137590f, + -0.981342344317875930f, 0.192080397049892380f, -0.981379193313754560f, + 0.191892216416400310f, -0.981416006227125550f, 0.191704028727579940f, + -0.981452783056635520f, 0.191515833990350240f, -0.981489523800932130f, + 0.191327632211630990f, -0.981526228458664660f, 0.191139423398341420f, + -0.981562897028483650f, 0.190951207557401860f, -0.981599529509040720f, + 0.190762984695732250f, -0.981636125898989080f, 0.190574754820252800f, + -0.981672686196983110f, 0.190386517937884580f, -0.981709210401678800f, + 0.190198274055548120f, -0.981745698511732990f, 0.190010023180165050f, + -0.981782150525804310f, 0.189821765318656580f, -0.981818566442552500f, + 0.189633500477944220f, -0.981854946260638630f, 0.189445228664950340f, + -0.981891289978724990f, 0.189256949886596720f, -0.981927597595475540f, + 0.189068664149806280f, -0.981963869109555240f, 0.188880371461501330f, + -0.982000104519630490f, 0.188692071828605260f, -0.982036303824369020f, + 0.188503765258041080f, -0.982072467022439890f, 0.188315451756732120f, + -0.982108594112513610f, 0.188127131331602530f, -0.982144685093261580f, + 0.187938803989575850f, -0.982180739963357200f, 0.187750469737576840f, + -0.982216758721474510f, 0.187562128582529740f, -0.982252741366289370f, + 0.187373780531359110f, -0.982288687896478830f, 0.187185425590990440f, + -0.982324598310721160f, 0.186997063768348510f, -0.982360472607696210f, + 0.186808695070359330f, -0.982396310786084690f, 0.186620319503948420f, + -0.982432112844569110f, 0.186431937076041640f, -0.982467878781833170f, + 0.186243547793565670f, -0.982503608596561720f, 0.186055151663446630f, + -0.982539302287441240f, 0.185866748692611720f, -0.982574959853159240f, + 0.185678338887987790f, -0.982610581292404750f, 0.185489922256501900f, + -0.982646166603868050f, 0.185301498805082040f, -0.982681715786240860f, + 0.185113068540655510f, -0.982717228838215990f, 0.184924631470150870f, + -0.982752705758487830f, 0.184736187600495930f, -0.982788146545751970f, + 0.184547736938619640f, -0.982823551198705240f, 0.184359279491450640f, + -0.982858919716046110f, 0.184170815265917720f, -0.982894252096474070f, + 0.183982344268950600f, -0.982929548338690060f, 0.183793866507478390f, + -0.982964808441396440f, 0.183605381988431350f, -0.983000032403296590f, + 0.183416890718739230f, -0.983035220223095640f, 0.183228392705332140f, + -0.983070371899499640f, 0.183039887955141060f, -0.983105487431216290f, + 0.182851376475096310f, -0.983140566816954500f, 0.182662858272129360f, + -0.983175610055424420f, 0.182474333353171260f, -0.983210617145337640f, + 0.182285801725153320f, -0.983245588085407070f, 0.182097263395007760f, + -0.983280522874346970f, 0.181908718369666160f, -0.983315421510872810f, + 0.181720166656061170f, -0.983350283993701500f, 0.181531608261125130f, + -0.983385110321551180f, 0.181343043191790590f, -0.983419900493141540f, + 0.181154471454990920f, -0.983454654507193270f, 0.180965893057658980f, + -0.983489372362428730f, 0.180777308006728670f, -0.983524054057571260f, + 0.180588716309133280f, -0.983558699591345900f, 0.180400117971807270f, + -0.983593308962478650f, 0.180211513001684590f, -0.983627882169697210f, + 0.180022901405699510f, -0.983662419211730250f, 0.179834283190787180f, + -0.983696920087308020f, 0.179645658363882100f, -0.983731384795162090f, + 0.179457026931919950f, -0.983765813334025240f, 0.179268388901835880f, + -0.983800205702631490f, 0.179079744280565390f, -0.983834561899716630f, + 0.178891093075044830f, -0.983868881924017220f, 0.178702435292209940f, + -0.983903165774271500f, 0.178513770938997590f, -0.983937413449218920f, + 0.178325100022344140f, -0.983971624947600270f, 0.178136422549186320f, + -0.984005800268157870f, 0.177947738526461670f, -0.984039939409634970f, + 0.177759047961107140f, -0.984074042370776450f, 0.177570350860060790f, + -0.984108109150328540f, 0.177381647230260200f, -0.984142139747038570f, + 0.177192937078643310f, -0.984176134159655320f, 0.177004220412148860f, + -0.984210092386929030f, 0.176815497237715000f, -0.984244014427611110f, + 0.176626767562280960f, -0.984277900280454370f, 0.176438031392785350f, + -0.984311749944212780f, 0.176249288736167940f, -0.984345563417641900f, + 0.176060539599367960f, -0.984379340699498510f, 0.175871783989325040f, + -0.984413081788540700f, 0.175683021912979580f, -0.984446786683527920f, + 0.175494253377271400f, -0.984480455383220930f, 0.175305478389141370f, + -0.984514087886381840f, 0.175116696955530060f, -0.984547684191773960f, + 0.174927909083378160f, -0.984581244298162180f, 0.174739114779627310f, + -0.984614768204312600f, 0.174550314051218490f, -0.984648255908992630f, + 0.174361506905093830f, -0.984681707410970940f, 0.174172693348194960f, + -0.984715122709017620f, 0.173983873387463850f, -0.984748501801904210f, + 0.173795047029843270f, -0.984781844688403350f, 0.173606214282275410f, + -0.984815151367289140f, 0.173417375151703520f, -0.984848421837337010f, + 0.173228529645070490f, -0.984881656097323700f, 0.173039677769319390f, + -0.984914854146027200f, 0.172850819531394200f, -0.984948015982227030f, + 0.172661954938238270f, -0.984981141604703960f, 0.172473083996796030f, + -0.985014231012239840f, 0.172284206714011350f, -0.985047284203618200f, + 0.172095323096829040f, -0.985080301177623800f, 0.171906433152193700f, + -0.985113281933042590f, 0.171717536887049970f, -0.985146226468662230f, + 0.171528634308343500f, -0.985179134783271020f, 0.171339725423019260f, + -0.985212006875659460f, 0.171150810238023340f, -0.985244842744618540f, + 0.170961888760301360f, -0.985277642388941220f, 0.170772960996799230f, + -0.985310405807421570f, 0.170584026954463700f, -0.985343132998854790f, + 0.170395086640240920f, -0.985375823962037710f, 0.170206140061078120f, + -0.985408478695768420f, 0.170017187223922090f, -0.985441097198846210f, + 0.169828228135719880f, -0.985473679470071810f, 0.169639262803419400f, + -0.985506225508247290f, 0.169450291233967930f, -0.985538735312176060f, + 0.169261313434313890f, -0.985571208880662740f, 0.169072329411405180f, + -0.985603646212513400f, 0.168883339172190010f, -0.985636047306535420f, + 0.168694342723617440f, -0.985668412161537550f, 0.168505340072635900f, + -0.985700740776329850f, 0.168316331226194910f, -0.985733033149723490f, + 0.168127316191243350f, -0.985765289280531310f, 0.167938294974731230f, + -0.985797509167567370f, 0.167749267583608030f, -0.985829692809647050f, + 0.167560234024823590f, -0.985861840205586980f, 0.167371194305328540f, + -0.985893951354205210f, 0.167182148432072880f, -0.985926026254321130f, + 0.166993096412007770f, -0.985958064904755460f, 0.166804038252083870f, + -0.985990067304330030f, 0.166614973959252090f, -0.986022033451868560f, + 0.166425903540464220f, -0.986053963346195440f, 0.166236827002671390f, + -0.986085856986136820f, 0.166047744352825850f, -0.986117714370520090f, + 0.165858655597879430f, -0.986149535498173860f, 0.165669560744784140f, + -0.986181320367928270f, 0.165480459800492890f, -0.986213068978614490f, + 0.165291352771957970f, -0.986244781329065460f, 0.165102239666132720f, + -0.986276457418114980f, 0.164913120489970090f, -0.986308097244598670f, + 0.164723995250423190f, -0.986339700807353000f, 0.164534863954446110f, + -0.986371268105216030f, 0.164345726608992190f, -0.986402799137027220f, + 0.164156583221015890f, -0.986434293901627070f, 0.163967433797471110f, + -0.986465752397857940f, 0.163778278345312690f, -0.986497174624562880f, + 0.163589116871495160f, -0.986528560580586690f, 0.163399949382973230f, + -0.986559910264775410f, 0.163210775886702460f, -0.986591223675976400f, + 0.163021596389637810f, -0.986622500813038480f, 0.162832410898735260f, + -0.986653741674811350f, 0.162643219420950450f, -0.986684946260146690f, + 0.162454021963239190f, -0.986716114567897100f, 0.162264818532558110f, + -0.986747246596916480f, 0.162075609135863330f, -0.986778342346060430f, + 0.161886393780111910f, -0.986809401814185420f, 0.161697172472260540f, + -0.986840425000149680f, 0.161507945219266150f, -0.986871411902812470f, + 0.161318712028086540f, -0.986902362521034470f, 0.161129472905678780f, + -0.986933276853677710f, 0.160940227859001140f, -0.986964154899605650f, + 0.160750976895011390f, -0.986994996657682870f, 0.160561720020667510f, + -0.987025802126775600f, 0.160372457242928400f, -0.987056571305750970f, + 0.160183188568752240f, -0.987087304193477900f, 0.159993914005098350f, + -0.987118000788826280f, 0.159804633558925380f, -0.987148661090667570f, + 0.159615347237193090f, -0.987179285097874340f, 0.159426055046860750f, + -0.987209872809320820f, 0.159236756994887850f, -0.987240424223882250f, + 0.159047453088234840f, -0.987270939340435420f, 0.158858143333861390f, + -0.987301418157858430f, 0.158668827738728370f, -0.987331860675030430f, + 0.158479506309796100f, -0.987362266890832400f, 0.158290179054025180f, + -0.987392636804146240f, 0.158100845978377090f, -0.987422970413855410f, + 0.157911507089812640f, -0.987453267718844560f, 0.157722162395293690f, + -0.987483528717999710f, 0.157532811901781670f, -0.987513753410208420f, + 0.157343455616238280f, -0.987543941794359230f, 0.157154093545626010f, + -0.987574093869342360f, 0.156964725696906750f, -0.987604209634049160f, + 0.156775352077043430f, -0.987634289087372160f, 0.156585972692998590f, + -0.987664332228205710f, 0.156396587551734940f, -0.987694339055445130f, + 0.156207196660216040f, -0.987724309567986960f, 0.156017800025404830f, + -0.987754243764729530f, 0.155828397654265320f, -0.987784141644572180f, + 0.155638989553760850f, -0.987814003206415550f, 0.155449575730855880f, + -0.987843828449161740f, 0.155260156192514380f, -0.987873617371714200f, + 0.155070730945700510f, -0.987903369972977790f, 0.154881299997379400f, + -0.987933086251858380f, 0.154691863354515400f, -0.987962766207263420f, + 0.154502421024073990f, -0.987992409838101880f, 0.154312973013020240f, + -0.988022017143283530f, 0.154123519328319360f, -0.988051588121720110f, + 0.153934059976937460f, -0.988081122772324070f, 0.153744594965840000f, + -0.988110621094009820f, 0.153555124301993500f, -0.988140083085692570f, + 0.153365647992364020f, -0.988169508746289060f, 0.153176166043917870f, + -0.988198898074717610f, 0.152986678463622160f, -0.988228251069897420f, + 0.152797185258443410f, -0.988257567730749460f, 0.152607686435349140f, + -0.988286848056195710f, 0.152418182001306500f, -0.988316092045159690f, + 0.152228671963282770f, -0.988345299696566150f, 0.152039156328246160f, + -0.988374471009341280f, 0.151849635103164180f, -0.988403605982412390f, + 0.151660108295005400f, -0.988432704614708340f, 0.151470575910737760f, + -0.988461766905159300f, 0.151281037957330250f, -0.988490792852696590f, + 0.151091494441751430f, -0.988519782456253270f, 0.150901945370970040f, + -0.988548735714763200f, 0.150712390751955720f, -0.988577652627162020f, + 0.150522830591677370f, -0.988606533192386450f, 0.150333264897105050f, + -0.988635377409374790f, 0.150143693675208330f, -0.988664185277066230f, + 0.149954116932956990f, -0.988692956794401940f, 0.149764534677321620f, + -0.988721691960323780f, 0.149574946915272210f, -0.988750390773775360f, + 0.149385353653779810f, -0.988779053233701520f, 0.149195754899814960f, + -0.988807679339048340f, 0.149006150660348470f, -0.988836269088763540f, + 0.148816540942352030f, -0.988864822481795640f, 0.148626925752796540f, + -0.988893339517095130f, 0.148437305098654050f, -0.988921820193613190f, + 0.148247678986896200f, -0.988950264510302990f, 0.148058047424494740f, + -0.988978672466118480f, 0.147868410418422360f, -0.989007044060015270f, + 0.147678767975650970f, -0.989035379290950310f, 0.147489120103153680f, + -0.989063678157881540f, 0.147299466807902820f, -0.989091940659768800f, + 0.147109808096871850f, -0.989120166795572690f, 0.146920143977033760f, + -0.989148356564255590f, 0.146730474455361750f, -0.989176509964781010f, + 0.146540799538829870f, -0.989204626996113780f, 0.146351119234411440f, + -0.989232707657220050f, 0.146161433549080950f, -0.989260751947067640f, + 0.145971742489812370f, -0.989288759864625170f, 0.145782046063579860f, + -0.989316731408863000f, 0.145592344277358450f, -0.989344666578752640f, + 0.145402637138122540f, -0.989372565373267010f, 0.145212924652847520f, + -0.989400427791380380f, 0.145023206828508360f, -0.989428253832068230f, + 0.144833483672080240f, -0.989456043494307710f, 0.144643755190539150f, + -0.989483796777076760f, 0.144454021390860440f, -0.989511513679355190f, + 0.144264282280020530f, -0.989539194200123930f, 0.144074537864995330f, + -0.989566838338365120f, 0.143884788152761010f, -0.989594446093062460f, + 0.143695033150294580f, -0.989622017463200780f, 0.143505272864572290f, + -0.989649552447766530f, 0.143315507302571590f, -0.989677051045747210f, + 0.143125736471269140f, -0.989704513256131850f, 0.142935960377642700f, + -0.989731939077910570f, 0.142746179028669620f, -0.989759328510075200f, + 0.142556392431327340f, -0.989786681551618640f, 0.142366600592594260f, + -0.989813998201535260f, 0.142176803519448000f, -0.989841278458820530f, + 0.141987001218867340f, -0.989868522322471580f, 0.141797193697830530f, + -0.989895729791486660f, 0.141607380963316020f, -0.989922900864865450f, + 0.141417563022303130f, -0.989950035541608990f, 0.141227739881770480f, + -0.989977133820719610f, 0.141037911548697770f, -0.990004195701200910f, + 0.140848078030064220f, -0.990031221182058000f, 0.140658239332849240f, + -0.990058210262297120f, 0.140468395464033110f, -0.990085162940925970f, + 0.140278546430595420f, -0.990112079216953770f, 0.140088692239516780f, + -0.990138959089390650f, 0.139898832897777380f, -0.990165802557248400f, + 0.139708968412357580f, -0.990192609619540030f, 0.139519098790238600f, + -0.990219380275280000f, 0.139329224038400980f, -0.990246114523483990f, + 0.139139344163826280f, -0.990272812363169110f, 0.138949459173495440f, + -0.990299473793353590f, 0.138759569074390380f, -0.990326098813057330f, + 0.138569673873492640f, -0.990352687421301340f, 0.138379773577783890f, + -0.990379239617108160f, 0.138189868194246640f, -0.990405755399501260f, + 0.137999957729862760f, -0.990432234767505970f, 0.137810042191615130f, + -0.990458677720148620f, 0.137620121586486180f, -0.990485084256456980f, + 0.137430195921458550f, -0.990511454375460290f, 0.137240265203515700f, + -0.990537788076188750f, 0.137050329439640380f, -0.990564085357674370f, + 0.136860388636816430f, -0.990590346218950150f, 0.136670442802027230f, + -0.990616570659050620f, 0.136480491942256310f, -0.990642758677011570f, + 0.136290536064488070f, -0.990668910271869980f, 0.136100575175706200f, + -0.990695025442664630f, 0.135910609282895440f, -0.990721104188435180f, + 0.135720638393040080f, -0.990747146508222710f, 0.135530662513124620f, + -0.990773152401069780f, 0.135340681650134330f, -0.990799121866020370f, + 0.135150695811053850f, -0.990825054902119470f, 0.134960705002868830f, + -0.990850951508413620f, 0.134770709232564290f, -0.990876811683950810f, + 0.134580708507126220f, -0.990902635427780010f, 0.134390702833540240f, + -0.990928422738951990f, 0.134200692218792020f, -0.990954173616518500f, + 0.134010676669868210f, -0.990979888059532740f, 0.133820656193754690f, + -0.991005566067049370f, 0.133630630797438390f, -0.991031207638124130f, + 0.133440600487905820f, -0.991056812771814340f, 0.133250565272143570f, + -0.991082381467178640f, 0.133060525157139180f, -0.991107913723276780f, + 0.132870480149879400f, -0.991133409539170170f, 0.132680430257352130f, + -0.991158868913921350f, 0.132490375486544710f, -0.991184291846594180f, + 0.132300315844444680f, -0.991209678336254060f, 0.132110251338040470f, + -0.991235028381967420f, 0.131920181974319760f, -0.991260341982802440f, + 0.131730107760271280f, -0.991285619137828200f, 0.131540028702883280f, + -0.991310859846115440f, 0.131349944809144220f, -0.991336064106736140f, + 0.131159856086043410f, -0.991361231918763460f, 0.130969762540569380f, + -0.991386363281272280f, 0.130779664179711790f, -0.991411458193338540f, + 0.130589561010459600f, -0.991436516654039420f, 0.130399453039802740f, + -0.991461538662453790f, 0.130209340274730770f, -0.991486524217661480f, + 0.130019222722233350f, -0.991511473318743900f, 0.129829100389301010f, + -0.991536385964783880f, 0.129638973282923540f, -0.991561262154865290f, + 0.129448841410091830f, -0.991586101888073500f, 0.129258704777796270f, + -0.991610905163495370f, 0.129068563393027410f, -0.991635671980218740f, + 0.128878417262776660f, -0.991660402337333210f, 0.128688266394034690f, + -0.991685096233929530f, 0.128498110793793220f, -0.991709753669099530f, + 0.128307950469043590f, -0.991734374641936810f, 0.128117785426777150f, + -0.991758959151536110f, 0.127927615673986190f, -0.991783507196993490f, + 0.127737441217662280f, -0.991808018777406430f, 0.127547262064798050f, + -0.991832493891873780f, 0.127357078222385570f, -0.991856932539495360f, + 0.127166889697417180f, -0.991881334719373010f, 0.126976696496885980f, + -0.991905700430609330f, 0.126786498627784430f, -0.991930029672308480f, + 0.126596296097105960f, -0.991954322443575950f, 0.126406088911843320f, + -0.991978578743518580f, 0.126215877078990400f, -0.992002798571244520f, + 0.126025660605540460f, -0.992026981925863360f, 0.125835439498487020f, + -0.992051128806485720f, 0.125645213764824380f, -0.992075239212224070f, + 0.125454983411546210f, -0.992099313142191800f, 0.125264748445647110f, + -0.992123350595503720f, 0.125074508874121300f, -0.992147351571276090f, + 0.124884264703963150f, -0.992171316068626520f, 0.124694015942167770f, + -0.992195244086673920f, 0.124503762595729650f, -0.992219135624538450f, + 0.124313504671644300f, -0.992242990681341700f, 0.124123242176906760f, + -0.992266809256206580f, 0.123932975118512200f, -0.992290591348257370f, + 0.123742703503456630f, -0.992314336956619640f, 0.123552427338735370f, + -0.992338046080420420f, 0.123362146631344750f, -0.992361718718787870f, + 0.123171861388280650f, -0.992385354870851670f, 0.122981571616539080f, + -0.992408954535742850f, 0.122791277323116900f, -0.992432517712593550f, + 0.122600978515010240f, -0.992456044400537700f, 0.122410675199216280f, + -0.992479534598709970f, 0.122220367382731500f, -0.992502988306246950f, + 0.122030055072553410f, -0.992526405522286100f, 0.121839738275679020f, + -0.992549786245966570f, 0.121649416999105540f, -0.992573130476428810f, + 0.121459091249830950f, -0.992596438212814290f, 0.121268761034852550f, + -0.992619709454266140f, 0.121078426361168710f, -0.992642944199928820f, + 0.120888087235777220f, -0.992666142448948020f, 0.120697743665676120f, + -0.992689304200470750f, 0.120507395657864240f, -0.992712429453645460f, + 0.120317043219339670f, -0.992735518207621850f, 0.120126686357101580f, + -0.992758570461551140f, 0.119936325078148620f, -0.992781586214585570f, + 0.119745959389479630f, -0.992804565465879140f, 0.119555589298094230f, + -0.992827508214586760f, 0.119365214810991350f, -0.992850414459865100f, + 0.119174835935170960f, -0.992873284200871730f, 0.118984452677632520f, + -0.992896117436765980f, 0.118794065045375670f, -0.992918914166708300f, + 0.118603673045400840f, -0.992941674389860470f, 0.118413276684707770f, + -0.992964398105385610f, 0.118222875970297250f, -0.992987085312448390f, + 0.118032470909169300f, -0.993009736010214580f, 0.117842061508325020f, + -0.993032350197851410f, 0.117651647774765000f, -0.993054927874527320f, + 0.117461229715489990f, -0.993077469039412300f, 0.117270807337501560f, + -0.993099973691677570f, 0.117080380647800550f, -0.993122441830495580f, + 0.116889949653388850f, -0.993144873455040430f, 0.116699514361267840f, + -0.993167268564487230f, 0.116509074778439050f, -0.993189627158012620f, + 0.116318630911904880f, -0.993211949234794500f, 0.116128182768666920f, + -0.993234234794012290f, 0.115937730355727850f, -0.993256483834846440f, + 0.115747273680089870f, -0.993278696356479030f, 0.115556812748755290f, + -0.993300872358093280f, 0.115366347568727250f, -0.993323011838873950f, + 0.115175878147008180f, -0.993345114798006910f, 0.114985404490601530f, + -0.993367181234679600f, 0.114794926606510250f, -0.993389211148080650f, + 0.114604444501737460f, -0.993411204537400060f, 0.114413958183287050f, + -0.993433161401829360f, 0.114223467658162260f, -0.993455081740560960f, + 0.114032972933367300f, -0.993476965552789190f, 0.113842474015905660f, + -0.993498812837709360f, 0.113651970912781920f, -0.993520623594518090f, + 0.113461463631000080f, -0.993542397822413600f, 0.113270952177564360f, + -0.993564135520595300f, 0.113080436559479720f, -0.993585836688263950f, + 0.112889916783750470f, -0.993607501324621610f, 0.112699392857381910f, + -0.993629129428871720f, 0.112508864787378830f, -0.993650721000219120f, + 0.112318332580746190f, -0.993672276037870010f, 0.112127796244489750f, + -0.993693794541031680f, 0.111937255785614560f, -0.993715276508913230f, + 0.111746711211126660f, -0.993736721940724600f, 0.111556162528031630f, + -0.993758130835677430f, 0.111365609743335190f, -0.993779503192984580f, + 0.111175052864043830f, -0.993800839011860120f, 0.110984491897163380f, + -0.993822138291519660f, 0.110793926849700630f, -0.993843401031180180f, + 0.110603357728661910f, -0.993864627230059750f, 0.110412784541053660f, + -0.993885816887378090f, 0.110222207293883180f, -0.993906970002356060f, + 0.110031625994157000f, -0.993928086574215830f, 0.109841040648882680f, + -0.993949166602181130f, 0.109650451265067080f, -0.993970210085476920f, + 0.109459857849718030f, -0.993991217023329380f, 0.109269260409842920f, + -0.994012187414966220f, 0.109078658952449240f, -0.994033121259616400f, + 0.108888053484545310f, -0.994054018556510210f, 0.108697444013138670f, + -0.994074879304879370f, 0.108506830545237980f, -0.994095703503956930f, + 0.108316213087851300f, -0.994116491152977070f, 0.108125591647986880f, + -0.994137242251175720f, 0.107934966232653760f, -0.994157956797789730f, + 0.107744336848860260f, -0.994178634792057590f, 0.107553703503615710f, + -0.994199276233218910f, 0.107363066203928920f, -0.994219881120514850f, + 0.107172424956808870f, -0.994240449453187900f, 0.106981779769265340f, + -0.994260981230481790f, 0.106791130648307380f, -0.994281476451641550f, + 0.106600477600945030f, -0.994301935115913580f, 0.106409820634187840f, + -0.994322357222545810f, 0.106219159755045520f, -0.994342742770787270f, + 0.106028494970528530f, -0.994363091759888570f, 0.105837826287646670f, + -0.994383404189101430f, 0.105647153713410700f, -0.994403680057679100f, + 0.105456477254830660f, -0.994423919364875950f, 0.105265796918917650f, + -0.994444122109948040f, 0.105075112712682180f, -0.994464288292152390f, + 0.104884424643134970f, -0.994484417910747600f, 0.104693732717287500f, + -0.994504510964993590f, 0.104503036942150550f, -0.994524567454151740f, + 0.104312337324735870f, -0.994544587377484300f, 0.104121633872054730f, + -0.994564570734255420f, 0.103930926591118540f, -0.994584517523730340f, + 0.103740215488939480f, -0.994604427745175660f, 0.103549500572529040f, + -0.994624301397859400f, 0.103358781848899700f, -0.994644138481050710f, + 0.103168059325063390f, -0.994663938994020280f, 0.102977333008032250f, + -0.994683702936040250f, 0.102786602904819150f, -0.994703430306383860f, + 0.102595869022436280f, -0.994723121104325700f, 0.102405131367896790f, + -0.994742775329142010f, 0.102214389948213370f, -0.994762392980109930f, + 0.102023644770398800f, -0.994781974056508260f, 0.101832895841466670f, + -0.994801518557617110f, 0.101642143168429830f, -0.994821026482717860f, + 0.101451386758302160f, -0.994840497831093180f, 0.101260626618096800f, + -0.994859932602027320f, 0.101069862754827880f, -0.994879330794805620f, + 0.100879095175509010f, -0.994898692408714870f, 0.100688323887153970f, + -0.994918017443043200f, 0.100497548896777310f, -0.994937305897080070f, + 0.100306770211392820f, -0.994956557770116380f, 0.100115987838015370f, + -0.994975773061444140f, 0.099925201783659226f, -0.994994951770357020f, + 0.099734412055338839f, -0.995014093896149700f, 0.099543618660069444f, + -0.995033199438118630f, 0.099352821604865513f, -0.995052268395561160f, + 0.099162020896742573f, -0.995071300767776170f, 0.098971216542715582f, + -0.995090296554063890f, 0.098780408549799664f, -0.995109255753726110f, + 0.098589596925010708f, -0.995128178366065490f, 0.098398781675363881f, + -0.995147064390386470f, 0.098207962807875346f, -0.995165913825994620f, + 0.098017140329560770f, -0.995184726672196820f, 0.097826314247435903f, + -0.995203502928301510f, 0.097635484568517339f, -0.995222242593618240f, + 0.097444651299820870f, -0.995240945667458130f, 0.097253814448363354f, + -0.995259612149133390f, 0.097062974021160875f, -0.995278242037957670f, + 0.096872130025230527f, -0.995296835333246090f, 0.096681282467588864f, + -0.995315392034315070f, 0.096490431355252607f, -0.995333912140482280f, + 0.096299576695239225f, -0.995352395651066810f, 0.096108718494565468f, + -0.995370842565388990f, 0.095917856760249096f, -0.995389252882770690f, + 0.095726991499307315f, -0.995407626602534900f, 0.095536122718757485f, + -0.995425963724006160f, 0.095345250425617742f, -0.995444264246510340f, + 0.095154374626905472f, -0.995462528169374420f, 0.094963495329639061f, + -0.995480755491926940f, 0.094772612540836410f, -0.995498946213497770f, + 0.094581726267515473f, -0.995517100333418110f, 0.094390836516695067f, + -0.995535217851020390f, 0.094199943295393190f, -0.995553298765638470f, + 0.094009046610628907f, -0.995571343076607770f, 0.093818146469420494f, + -0.995589350783264600f, 0.093627242878787237f, -0.995607321884947050f, + 0.093436335845747912f, -0.995625256380994310f, 0.093245425377321389f, + -0.995643154270746900f, 0.093054511480527333f, -0.995661015553546910f, + 0.092863594162384697f, -0.995678840228737540f, 0.092672673429913366f, + -0.995696628295663520f, 0.092481749290132753f, -0.995714379753670610f, + 0.092290821750062355f, -0.995732094602106430f, 0.092099890816722485f, + -0.995749772840319400f, 0.091908956497132696f, -0.995767414467659820f, + 0.091718018798313525f, -0.995785019483478750f, 0.091527077727284981f, + -0.995802587887129160f, 0.091336133291067212f, -0.995820119677964910f, + 0.091145185496681130f, -0.995837614855341610f, 0.090954234351146898f, + -0.995855073418615790f, 0.090763279861485704f, -0.995872495367145730f, + 0.090572322034718156f, -0.995889880700290720f, 0.090381360877865011f, + -0.995907229417411720f, 0.090190396397947820f, -0.995924541517870690f, + 0.089999428601987341f, -0.995941817001031350f, 0.089808457497005362f, + -0.995959055866258320f, 0.089617483090022917f, -0.995976258112917790f, + 0.089426505388062016f, -0.995993423740377360f, 0.089235524398144139f, + -0.996010552748005870f, 0.089044540127290905f, -0.996027645135173610f, + 0.088853552582524684f, -0.996044700901251970f, 0.088662561770867121f, + -0.996061720045614000f, 0.088471567699340822f, -0.996078702567633980f, + 0.088280570374967879f, -0.996095648466687300f, 0.088089569804770507f, + -0.996112557742151130f, 0.087898565995771685f, -0.996129430393403740f, + 0.087707558954993645f, -0.996146266419824620f, 0.087516548689459586f, + -0.996163065820794950f, 0.087325535206192226f, -0.996179828595696870f, + 0.087134518512214321f, -0.996196554743914220f, 0.086943498614549489f, + -0.996213244264832040f, 0.086752475520220515f, -0.996229897157836500f, + 0.086561449236251239f, -0.996246513422315520f, 0.086370419769664919f, + -0.996263093057658030f, 0.086179387127484922f, -0.996279636063254650f, + 0.085988351316735448f, -0.996296142438496850f, 0.085797312344439880f, + -0.996312612182778000f, 0.085606270217622613f, -0.996329045295492380f, + 0.085415224943307277f, -0.996345441776035900f, 0.085224176528518519f, + -0.996361801623805720f, 0.085033124980280414f, -0.996378124838200210f, + 0.084842070305617148f, -0.996394411418619290f, 0.084651012511553700f, + -0.996410661364464100f, 0.084459951605114297f, -0.996426874675137240f, + 0.084268887593324127f, -0.996443051350042630f, 0.084077820483207846f, + -0.996459191388585410f, 0.083886750281790226f, -0.996475294790172160f, + 0.083695676996096827f, -0.996491361554210920f, 0.083504600633152404f, + -0.996507391680110820f, 0.083313521199982740f, -0.996523385167282450f, + 0.083122438703613077f, -0.996539342015137940f, 0.082931353151068726f, + -0.996555262223090540f, 0.082740264549375803f, -0.996571145790554840f, + 0.082549172905559659f, -0.996586992716946950f, 0.082358078226646619f, + -0.996602803001684130f, 0.082166980519662466f, -0.996618576644185070f, + 0.081975879791633108f, -0.996634313643869900f, 0.081784776049585201f, + -0.996650014000160070f, 0.081593669300544638f, -0.996665677712478160f, + 0.081402559551538328f, -0.996681304780248300f, 0.081211446809592386f, + -0.996696895202896060f, 0.081020331081733912f, -0.996712448979848010f, + 0.080829212374989468f, -0.996727966110532490f, 0.080638090696385709f, + -0.996743446594378860f, 0.080446966052950097f, -0.996758890430818000f, + 0.080255838451709291f, -0.996774297619282050f, 0.080064707899690932f, + -0.996789668159204560f, 0.079873574403922148f, -0.996805002050020320f, + 0.079682437971430126f, -0.996820299291165670f, 0.079491298609242866f, + -0.996835559882078170f, 0.079300156324387569f, -0.996850783822196610f, + 0.079109011123892431f, -0.996865971110961310f, 0.078917863014785095f, + -0.996881121747813850f, 0.078726712004093313f, -0.996896235732197210f, + 0.078535558098845590f, -0.996911313063555740f, 0.078344401306069678f, + -0.996926353741335090f, 0.078153241632794315f, -0.996941357764982160f, + 0.077962079086047645f, -0.996956325133945280f, 0.077770913672857989f, + -0.996971255847674320f, 0.077579745400254363f, -0.996986149905620180f, + 0.077388574275265049f, -0.997001007307235290f, 0.077197400304919297f, + -0.997015828051973310f, 0.077006223496245585f, -0.997030612139289450f, + 0.076815043856273399f, -0.997045359568640040f, 0.076623861392031617f, + -0.997060070339482960f, 0.076432676110549283f, -0.997074744451277310f, + 0.076241488018856149f, -0.997089381903483400f, 0.076050297123981231f, + -0.997103982695563330f, 0.075859103432954503f, -0.997118546826979980f, + 0.075667906952805383f, -0.997133074297198110f, 0.075476707690563416f, + -0.997147565105683480f, 0.075285505653258880f, -0.997162019251903290f, + 0.075094300847921291f, -0.997176436735326190f, 0.074903093281581137f, + -0.997190817555421940f, 0.074711882961268378f, -0.997205161711661850f, + 0.074520669894013014f, -0.997219469203518670f, 0.074329454086845867f, + -0.997233740030466160f, 0.074138235546796952f, -0.997247974191979860f, + 0.073947014280897269f, -0.997262171687536170f, 0.073755790296177265f, + -0.997276332516613180f, 0.073564563599667454f, -0.997290456678690210f, + 0.073373334198399157f, -0.997304544173247990f, 0.073182102099402888f, + -0.997318594999768600f, 0.072990867309710133f, -0.997332609157735470f, + 0.072799629836351618f, -0.997346586646633230f, 0.072608389686359048f, + -0.997360527465947940f, 0.072417146866763538f, -0.997374431615167030f, + 0.072225901384596336f, -0.997388299093779460f, 0.072034653246889416f, + -0.997402129901275300f, 0.071843402460674000f, -0.997415924037145960f, + 0.071652149032982254f, -0.997429681500884180f, 0.071460892970845832f, + -0.997443402291984360f, 0.071269634281296415f, -0.997457086409941910f, + 0.071078372971366502f, -0.997470733854253670f, 0.070887109048087787f, + -0.997484344624417930f, 0.070695842518492924f, -0.997497918719934210f, + 0.070504573389614009f, -0.997511456140303450f, 0.070313301668483263f, + -0.997524956885027960f, 0.070122027362133646f, -0.997538420953611230f, + 0.069930750477597295f, -0.997551848345558430f, 0.069739471021907376f, + -0.997565239060375750f, 0.069548189002096472f, -0.997578593097570800f, + 0.069356904425197236f, -0.997591910456652630f, 0.069165617298243109f, + -0.997605191137131640f, 0.068974327628266732f, -0.997618435138519550f, + 0.068783035422301728f, -0.997631642460329320f, 0.068591740687380900f, + -0.997644813102075420f, 0.068400443430538069f, -0.997657947063273710f, + 0.068209143658806454f, -0.997671044343441000f, 0.068017841379219388f, + -0.997684104942096030f, 0.067826536598810966f, -0.997697128858758500f, + 0.067635229324614451f, -0.997710116092949570f, 0.067443919563664106f, + -0.997723066644191640f, 0.067252607322993652f, -0.997735980512008620f, + 0.067061292609636836f, -0.997748857695925690f, 0.066869975430628226f, + -0.997761698195469560f, 0.066678655793001543f, -0.997774502010167820f, + 0.066487333703791507f, -0.997787269139549960f, 0.066296009170032283f, + -0.997799999583146470f, 0.066104682198758091f, -0.997812693340489280f, + 0.065913352797003930f, -0.997825350411111640f, 0.065722020971803977f, + -0.997837970794548280f, 0.065530686730193397f, -0.997850554490335110f, + 0.065339350079206798f, -0.997863101498009500f, 0.065148011025878860f, + -0.997875611817110150f, 0.064956669577245010f, -0.997888085447177110f, + 0.064765325740339871f, -0.997900522387751620f, 0.064573979522199065f, + -0.997912922638376610f, 0.064382630929857410f, -0.997925286198596000f, + 0.064191279970350679f, -0.997937613067955250f, 0.063999926650714078f, + -0.997949903246001190f, 0.063808570977982898f, -0.997962156732281950f, + 0.063617212959193190f, -0.997974373526346990f, 0.063425852601380200f, + -0.997986553627747020f, 0.063234489911580136f, -0.997998697036034390f, + 0.063043124896828631f, -0.998010803750762450f, 0.062851757564161420f, + -0.998022873771486240f, 0.062660387920614985f, -0.998034907097761770f, + 0.062469015973224969f, -0.998046903729146840f, 0.062277641729028041f, + -0.998058863665200250f, 0.062086265195060247f, -0.998070786905482340f, + 0.061894886378357744f, -0.998082673449554590f, 0.061703505285957416f, + -0.998094523296980010f, 0.061512121924895365f, -0.998106336447323050f, + 0.061320736302208648f, -0.998118112900149180f, 0.061129348424933755f, + -0.998129852655025520f, 0.060937958300107238f, -0.998141555711520520f, + 0.060746565934766412f, -0.998153222069203650f, 0.060555171335947781f, + -0.998164851727646240f, 0.060363774510688827f, -0.998176444686420530f, + 0.060172375466026218f, -0.998188000945100300f, 0.059980974208997596f, + -0.998199520503260660f, 0.059789570746640007f, -0.998211003360478190f, + 0.059598165085990598f, -0.998222449516330550f, 0.059406757234087247f, + -0.998233858970396850f, 0.059215347197967026f, -0.998245231722257880f, + 0.059023934984667986f, -0.998256567771495180f, 0.058832520601227581f, + -0.998267867117692110f, 0.058641104054683348f, -0.998279129760433200f, + 0.058449685352073573f, -0.998290355699304350f, 0.058258264500435732f, + -0.998301544933892890f, 0.058066841506808263f, -0.998312697463787260f, + 0.057875416378229017f, -0.998323813288577560f, 0.057683989121735932f, + -0.998334892407855000f, 0.057492559744367684f, -0.998345934821212370f, + 0.057301128253162144f, -0.998356940528243420f, 0.057109694655158132f, + -0.998367909528543820f, 0.056918258957393907f, -0.998378841821709990f, + 0.056726821166907783f, -0.998389737407340160f, 0.056535381290738825f, + -0.998400596285033640f, 0.056343939335925283f, -0.998411418454391300f, + 0.056152495309506383f, -0.998422203915015020f, 0.055961049218520520f, + -0.998432952666508440f, 0.055769601070007072f, -0.998443664708476340f, + 0.055578150871004817f, -0.998454340040524800f, 0.055386698628552604f, + -0.998464978662261250f, 0.055195244349690031f, -0.998475580573294770f, + 0.055003788041455885f, -0.998486145773235360f, 0.054812329710889909f, + -0.998496674261694640f, 0.054620869365031251f, -0.998507166038285490f, + 0.054429407010919147f, -0.998517621102622210f, 0.054237942655593556f, + -0.998528039454320230f, 0.054046476306093640f, -0.998538421092996730f, + 0.053855007969459509f, -0.998548766018269920f, 0.053663537652730679f, + -0.998559074229759310f, 0.053472065362946755f, -0.998569345727086110f, + 0.053280591107148056f, -0.998579580509872500f, 0.053089114892374119f, + -0.998589778577742230f, 0.052897636725665401f, -0.998599939930320370f, + 0.052706156614061798f, -0.998610064567233340f, 0.052514674564603257f, + -0.998620152488108870f, 0.052323190584330471f, -0.998630203692576050f, + 0.052131704680283317f, -0.998640218180265270f, 0.051940216859502626f, + -0.998650195950808280f, 0.051748727129028414f, -0.998660137003838490f, + 0.051557235495901653f, -0.998670041338990070f, 0.051365741967162731f, + -0.998679908955899090f, 0.051174246549852087f, -0.998689739854202620f, + 0.050982749251010900f, -0.998699534033539280f, 0.050791250077679546f, + -0.998709291493549030f, 0.050599749036899337f, -0.998719012233872940f, + 0.050408246135710995f, -0.998728696254153720f, 0.050216741381155325f, + -0.998738343554035230f, 0.050025234780273840f, -0.998747954133162860f, + 0.049833726340107257f, -0.998757527991183340f, 0.049642216067697226f, + -0.998767065127744380f, 0.049450703970084824f, -0.998776565542495610f, + 0.049259190054311168f, -0.998786029235087640f, 0.049067674327418126f, + -0.998795456205172410f, 0.048876156796446746f, -0.998804846452403420f, + 0.048684637468439020f, -0.998814199976435390f, 0.048493116350436342f, + -0.998823516776924380f, 0.048301593449480172f, -0.998832796853527990f, + 0.048110068772612716f, -0.998842040205904840f, 0.047918542326875327f, + -0.998851246833715180f, 0.047727014119310344f, -0.998860416736620520f, + 0.047535484156959261f, -0.998869549914283560f, 0.047343952446864526f, + -0.998878646366368690f, 0.047152418996068000f, -0.998887706092541290f, + 0.046960883811611599f, -0.998896729092468410f, 0.046769346900537960f, + -0.998905715365818290f, 0.046577808269888908f, -0.998914664912260440f, + 0.046386267926707213f, -0.998923577731465780f, 0.046194725878035046f, + -0.998932453823106690f, 0.046003182130914644f, -0.998941293186856870f, + 0.045811636692388955f, -0.998950095822391250f, 0.045620089569500123f, + -0.998958861729386080f, 0.045428540769291224f, -0.998967590907519300f, + 0.045236990298804750f, -0.998976283356469820f, 0.045045438165083225f, + -0.998984939075918010f, 0.044853884375169933f, -0.998993558065545680f, + 0.044662328936107311f, -0.999002140325035980f, 0.044470771854938744f, + -0.999010685854073380f, 0.044279213138707016f, -0.999019194652343460f, + 0.044087652794454979f, -0.999027666719533690f, 0.043896090829226200f, + -0.999036102055332330f, 0.043704527250063421f, -0.999044500659429290f, + 0.043512962064010327f, -0.999052862531515930f, 0.043321395278109784f, + -0.999061187671284600f, 0.043129826899405595f, -0.999069476078429330f, + 0.042938256934940959f, -0.999077727752645360f, 0.042746685391759139f, + -0.999085942693629270f, 0.042555112276904117f, -0.999094120901079070f, + 0.042363537597419038f, -0.999102262374694130f, 0.042171961360348002f, + -0.999110367114174890f, 0.041980383572734502f, -0.999118435119223490f, + 0.041788804241622082f, -0.999126466389543390f, 0.041597223374055005f, + -0.999134460924839150f, 0.041405640977076712f, -0.999142418724816910f, + 0.041214057057731589f, -0.999150339789184110f, 0.041022471623063397f, + -0.999158224117649430f, 0.040830884680115968f, -0.999166071709923000f, + 0.040639296235933854f, -0.999173882565716380f, 0.040447706297560768f, + -0.999181656684742350f, 0.040256114872041358f, -0.999189394066714920f, + 0.040064521966419686f, -0.999197094711349880f, 0.039872927587739845f, + -0.999204758618363890f, 0.039681331743046659f, -0.999212385787475290f, + 0.039489734439384118f, -0.999219976218403530f, 0.039298135683797149f, + -0.999227529910869610f, 0.039106535483329839f, -0.999235046864595850f, + 0.038914933845027241f, -0.999242527079305830f, 0.038723330775933762f, + -0.999249970554724420f, 0.038531726283093877f, -0.999257377290578060f, + 0.038340120373552791f, -0.999264747286594420f, 0.038148513054354856f, + -0.999272080542502610f, 0.037956904332545366f, -0.999279377058032710f, + 0.037765294215169005f, -0.999286636832916740f, 0.037573682709270514f, + -0.999293859866887790f, 0.037382069821895340f, -0.999301046159680070f, + 0.037190455560088091f, -0.999308195711029470f, 0.036998839930894332f, + -0.999315308520673070f, 0.036807222941358991f, -0.999322384588349540f, + 0.036615604598527057f, -0.999329423913798420f, 0.036423984909444228f, + -0.999336426496761240f, 0.036232363881155374f, -0.999343392336980220f, + 0.036040741520706299f, -0.999350321434199440f, 0.035849117835142184f, + -0.999357213788164000f, 0.035657492831508264f, -0.999364069398620550f, + 0.035465866516850478f, -0.999370888265317060f, 0.035274238898213947f, + -0.999377670388002850f, 0.035082609982644702f, -0.999384415766428560f, + 0.034890979777187955f, -0.999391124400346050f, 0.034699348288889847f, + -0.999397796289508640f, 0.034507715524795889f, -0.999404431433671300f, + 0.034316081491951658f, -0.999411029832589780f, 0.034124446197403423f, + -0.999417591486021720f, 0.033932809648196623f, -0.999424116393725640f, + 0.033741171851377642f, -0.999430604555461730f, 0.033549532813992221f, + -0.999437055970991530f, 0.033357892543086159f, -0.999443470640077770f, + 0.033166251045705968f, -0.999449848562484530f, 0.032974608328897315f, + -0.999456189737977340f, 0.032782964399706793f, -0.999462494166323160f, + 0.032591319265180385f, -0.999468761847290050f, 0.032399672932364114f, + -0.999474992780647780f, 0.032208025408304704f, -0.999481186966166950f, + 0.032016376700048046f, -0.999487344403620080f, 0.031824726814640963f, + -0.999493465092780590f, 0.031633075759129645f, -0.999499549033423640f, + 0.031441423540560343f, -0.999505596225325310f, 0.031249770165979990f, + -0.999511606668263440f, 0.031058115642434700f, -0.999517580362016990f, + 0.030866459976971503f, -0.999523517306366350f, 0.030674803176636581f, + -0.999529417501093140f, 0.030483145248477058f, -0.999535280945980540f, + 0.030291486199539423f, -0.999541107640812940f, 0.030099826036870208f, + -0.999546897585375960f, 0.029908164767516655f, -0.999552650779456990f, + 0.029716502398525156f, -0.999558367222844300f, 0.029524838936943035f, + -0.999564046915327740f, 0.029333174389816984f, -0.999569689856698580f, + 0.029141508764193740f, -0.999575296046749220f, 0.028949842067120746f, + -0.999580865485273700f, 0.028758174305644590f, -0.999586398172067070f, + 0.028566505486812797f, -0.999591894106925950f, 0.028374835617672258f, + -0.999597353289648380f, 0.028183164705269902f, -0.999602775720033530f, + 0.027991492756653365f, -0.999608161397882110f, 0.027799819778869434f, + -0.999613510322995950f, 0.027608145778965820f, -0.999618822495178640f, + 0.027416470763989606f, -0.999624097914234570f, 0.027224794740987910f, + -0.999629336579970110f, 0.027033117717008563f, -0.999634538492192300f, + 0.026841439699098527f, -0.999639703650710200f, 0.026649760694305708f, + -0.999644832055333610f, 0.026458080709677145f, -0.999649923705874240f, + 0.026266399752260809f, -0.999654978602144690f, 0.026074717829104040f, + -0.999659996743959220f, 0.025883034947254208f, -0.999664978131133310f, + 0.025691351113759395f, -0.999669922763483760f, 0.025499666335666818f, + -0.999674830640828740f, 0.025307980620024630f, -0.999679701762987930f, + 0.025116293973880335f, -0.999684536129782140f, 0.024924606404281485f, + -0.999689333741033640f, 0.024732917918276334f, -0.999694094596566000f, + 0.024541228522912264f, -0.999698818696204250f, 0.024349538225237600f, + -0.999703506039774650f, 0.024157847032300020f, -0.999708156627104880f, + 0.023966154951147241f, -0.999712770458023870f, 0.023774461988827676f, + -0.999717347532362190f, 0.023582768152388880f, -0.999721887849951310f, + 0.023391073448879338f, -0.999726391410624470f, 0.023199377885346890f, + -0.999730858214216030f, 0.023007681468839410f, -0.999735288260561680f, + 0.022815984206405477f, -0.999739681549498660f, 0.022624286105092803f, + -0.999744038080865430f, 0.022432587171950024f, -0.999748357854501780f, + 0.022240887414024919f, -0.999752640870248840f, 0.022049186838366180f, + -0.999756887127949080f, 0.021857485452021874f, -0.999761096627446610f, + 0.021665783262040089f, -0.999765269368586450f, 0.021474080275469605f, + -0.999769405351215280f, 0.021282376499358355f, -0.999773504575180990f, + 0.021090671940755180f, -0.999777567040332940f, 0.020898966606708289f, + -0.999781592746521670f, 0.020707260504265912f, -0.999785581693599210f, + 0.020515553640476986f, -0.999789533881418780f, 0.020323846022389572f, + -0.999793449309835270f, 0.020132137657052664f, -0.999797327978704690f, + 0.019940428551514598f, -0.999801169887884260f, 0.019748718712823757f, + -0.999804975037232870f, 0.019557008148029204f, -0.999808743426610520f, + 0.019365296864179146f, -0.999812475055878780f, 0.019173584868322699f, + -0.999816169924900410f, 0.018981872167508348f, -0.999819828033539420f, + 0.018790158768784596f, -0.999823449381661570f, 0.018598444679200642f, + -0.999827033969133420f, 0.018406729905804820f, -0.999830581795823400f, + 0.018215014455646376f, -0.999834092861600960f, 0.018023298335773701f, + -0.999837567166337090f, 0.017831581553236088f, -0.999841004709904000f, + 0.017639864115082195f, -0.999844405492175240f, 0.017448146028360704f, + -0.999847769513025900f, 0.017256427300120978f, -0.999851096772332190f, + 0.017064707937411529f, -0.999854387269971890f, 0.016872987947281773f, + -0.999857641005823860f, 0.016681267336780482f, -0.999860857979768540f, + 0.016489546112956454f, -0.999864038191687680f, 0.016297824282859176f, + -0.999867181641464380f, 0.016106101853537263f, -0.999870288328982950f, + 0.015914378832040249f, -0.999873358254129260f, 0.015722655225417017f, + -0.999876391416790410f, 0.015530931040716478f, -0.999879387816854930f, + 0.015339206284988220f, -0.999882347454212560f, 0.015147480965280975f, + -0.999885270328754520f, 0.014955755088644378f, -0.999888156440373320f, + 0.014764028662127416f, -0.999891005788962950f, 0.014572301692779104f, + -0.999893818374418490f, 0.014380574187649138f, -0.999896594196636680f, + 0.014188846153786343f, -0.999899333255515390f, 0.013997117598240459f, + -0.999902035550953920f, 0.013805388528060349f, -0.999904701082852900f, + 0.013613658950295789f, -0.999907329851114300f, 0.013421928871995907f, + -0.999909921855641540f, 0.013230198300209845f, -0.999912477096339240f, + 0.013038467241987433f, -0.999914995573113470f, 0.012846735704377631f, + -0.999917477285871770f, 0.012655003694430301f, -0.999919922234522750f, + 0.012463271219194662f, -0.999922330418976490f, 0.012271538285719944f, + -0.999924701839144500f, 0.012079804901056066f, -0.999927036494939640f, + 0.011888071072252072f, -0.999929334386276070f, 0.011696336806357907f, + -0.999931595513069200f, 0.011504602110422875f, -0.999933819875236000f, + 0.011312866991496287f, -0.999936007472694620f, 0.011121131456628141f, + -0.999938158305364590f, 0.010929395512867561f, -0.999940272373166960f, + 0.010737659167264572f, -0.999942349676023910f, 0.010545922426868548f, + -0.999944390213859060f, 0.010354185298728884f, -0.999946393986597460f, + 0.010162447789895645f, -0.999948360994165400f, 0.009970709907418029f, + -0.999950291236490480f, 0.009778971658346134f, -0.999952184713501780f, + 0.009587233049729183f, -0.999954041425129780f, 0.009395494088617302f, + -0.999955861371306100f, 0.009203754782059960f, -0.999957644551963900f, + 0.009012015137106642f, -0.999959390967037450f, 0.008820275160807512f, + -0.999961100616462820f, 0.008628534860211857f, -0.999962773500176930f, + 0.008436794242369860f, -0.999964409618118280f, 0.008245053314331058f, + -0.999966008970226920f, 0.008053312083144991f, -0.999967571556443780f, + 0.007861570555861883f, -0.999969097376711580f, 0.007669828739531077f, + -0.999970586430974140f, 0.007478086641202815f, -0.999972038719176730f, + 0.007286344267926684f, -0.999973454241265940f, 0.007094601626752279f, + -0.999974832997189810f, 0.006902858724729877f, -0.999976174986897610f, + 0.006711115568908869f, -0.999977480210339940f, 0.006519372166339549f, + -0.999978748667468830f, 0.006327628524071549f, -0.999979980358237650f, + 0.006135884649154515f, -0.999981175282601110f, 0.005944140548638765f, + -0.999982333440515350f, 0.005752396229573737f, -0.999983454831937730f, + 0.005560651699009764f, -0.999984539456826970f, 0.005368906963996303f, + -0.999985587315143200f, 0.005177162031583702f, -0.999986598406848000f, + 0.004985416908821652f, -0.999987572731904080f, 0.004793671602759852f, + -0.999988510290275690f, 0.004601926120448672f, -0.999989411081928400f, + 0.004410180468937601f, -0.999990275106828920f, 0.004218434655277024f, + -0.999991102364945590f, 0.004026688686516664f, -0.999991892856248010f, + 0.003834942569706248f, -0.999992646580707190f, 0.003643196311896179f, + -0.999993363538295150f, 0.003451449920135975f, -0.999994043728985820f, + 0.003259703401476044f, -0.999994687152754080f, 0.003067956762966138f, + -0.999995293809576190f, 0.002876210011656010f, -0.999995863699429940f, + 0.002684463154596083f, -0.999996396822294350f, 0.002492716198835898f, + -0.999996893178149880f, 0.002300969151425887f, -0.999997352766978210f, + 0.002109222019415816f, -0.999997775588762350f, 0.001917474809855460f, + -0.999998161643486980f, 0.001725727529795258f, -0.999998510931137790f, + 0.001533980186284766f, -0.999998823451701880f, 0.001342232786374430f, + -0.999999099205167830f, 0.001150485337113809f, -0.999999338191525530f, + 0.000958737845553352f, -0.999999540410766110f, 0.000766990318742846f, + -0.999999705862882230f, 0.000575242763732077f, -0.999999834547867670f, + 0.000383495187571497f, -0.999999926465717890f, 0.000191747597310674f, + -0.999999981616429330f}; /** @par - cosFactor tables are generated using the formula :
cos_factors[n] = 2 * cos((2n+1)*pi/(4*N))
+ cosFactor tables are generated using the formula :
cos_factors[n] = 2 *
+  cos((2n+1)*pi/(4*N))
@par C command to generate the table @par @@ -10472,5459 +7337,3644 @@ static const float32_t Weights_8192[16384] = { cos_factors[i]= 2 * cos((2*i+1)*c/2); }
@par - where N is the number of factors to generate and c is pi/(2*N) + where N is the number of factors to generate and c + is pi/(2*N) */ static const float32_t cos_factors_128[128] = { - 0.999981175282601110f, 0.999830581795823400f, 0.999529417501093140f, - 0.999077727752645360f, - 0.998475580573294770f, 0.997723066644191640f, 0.996820299291165670f, - 0.995767414467659820f, - 0.994564570734255420f, 0.993211949234794500f, 0.991709753669099530f, - 0.990058210262297120f, - 0.988257567730749460f, 0.986308097244598670f, 0.984210092386929030f, - 0.981963869109555240f, - 0.979569765685440520f, 0.977028142657754390f, 0.974339382785575860f, - 0.971503890986251780f, - 0.968522094274417380f, 0.965394441697689400f, 0.962121404269041580f, - 0.958703474895871600f, - 0.955141168305770780f, 0.951435020969008340f, 0.947585591017741090f, - 0.943593458161960390f, - 0.939459223602189920f, 0.935183509938947610f, 0.930766961078983710f, - 0.926210242138311380f, - 0.921514039342042010f, 0.916679059921042700f, 0.911706032005429880f, - 0.906595704514915330f, - 0.901348847046022030f, 0.895966249756185220f, 0.890448723244757880f, - 0.884797098430937790f, - 0.879012226428633530f, 0.873094978418290090f, 0.867046245515692650f, - 0.860866938637767310f, - 0.854557988365400530f, 0.848120344803297230f, 0.841554977436898440f, - 0.834862874986380010f, - 0.828045045257755800f, 0.821102514991104650f, 0.814036329705948410f, - 0.806847553543799330f, - 0.799537269107905010f, 0.792106577300212390f, 0.784556597155575240f, - 0.776888465673232440f, - 0.769103337645579700f, 0.761202385484261780f, 0.753186799043612520f, - 0.745057785441466060f, - 0.736816568877369900f, 0.728464390448225200f, 0.720002507961381650f, - 0.711432195745216430f, - 0.702754744457225300f, 0.693971460889654000f, 0.685083667772700360f, - 0.676092703575316030f, - 0.666999922303637470f, 0.657806693297078640f, 0.648514401022112550f, - 0.639124444863775730f, - 0.629638238914927100f, 0.620057211763289210f, 0.610382806276309480f, - 0.600616479383868970f, - 0.590759701858874280f, 0.580813958095764530f, 0.570780745886967370f, - 0.560661576197336030f, - 0.550457972936604810f, 0.540171472729892970f, 0.529803624686294830f, - 0.519355990165589530f, - 0.508830142543106990f, 0.498227666972781870f, 0.487550160148436050f, - 0.476799230063322250f, - 0.465976495767966130f, 0.455083587126343840f, 0.444122144570429260f, - 0.433093818853152010f, - 0.422000270799799790f, 0.410843171057903910f, 0.399624199845646790f, - 0.388345046698826300f, - 0.377007410216418310f, 0.365612997804773960f, 0.354163525420490510f, - 0.342660717311994380f, - 0.331106305759876430f, 0.319502030816015750f, 0.307849640041534980f, - 0.296150888243623960f, - 0.284407537211271820f, 0.272621355449948980f, 0.260794117915275570f, - 0.248927605745720260f, - 0.237023605994367340f, 0.225083911359792780f, 0.213110319916091360f, - 0.201104634842091960f, - 0.189068664149806280f, 0.177004220412148860f, 0.164913120489970090f, - 0.152797185258443410f, - 0.140658239332849240f, 0.128498110793793220f, 0.116318630911904880f, - 0.104121633872054730f, - 0.091908956497132696f, 0.079682437971430126f, 0.067443919563664106f, - 0.055195244349690031f, - 0.042938256934940959f, 0.030674803176636581f, 0.018406729905804820f, - 0.006135884649154515f -}; + 0.999981175282601110f, 0.999830581795823400f, 0.999529417501093140f, + 0.999077727752645360f, 0.998475580573294770f, 0.997723066644191640f, + 0.996820299291165670f, 0.995767414467659820f, 0.994564570734255420f, + 0.993211949234794500f, 0.991709753669099530f, 0.990058210262297120f, + 0.988257567730749460f, 0.986308097244598670f, 0.984210092386929030f, + 0.981963869109555240f, 0.979569765685440520f, 0.977028142657754390f, + 0.974339382785575860f, 0.971503890986251780f, 0.968522094274417380f, + 0.965394441697689400f, 0.962121404269041580f, 0.958703474895871600f, + 0.955141168305770780f, 0.951435020969008340f, 0.947585591017741090f, + 0.943593458161960390f, 0.939459223602189920f, 0.935183509938947610f, + 0.930766961078983710f, 0.926210242138311380f, 0.921514039342042010f, + 0.916679059921042700f, 0.911706032005429880f, 0.906595704514915330f, + 0.901348847046022030f, 0.895966249756185220f, 0.890448723244757880f, + 0.884797098430937790f, 0.879012226428633530f, 0.873094978418290090f, + 0.867046245515692650f, 0.860866938637767310f, 0.854557988365400530f, + 0.848120344803297230f, 0.841554977436898440f, 0.834862874986380010f, + 0.828045045257755800f, 0.821102514991104650f, 0.814036329705948410f, + 0.806847553543799330f, 0.799537269107905010f, 0.792106577300212390f, + 0.784556597155575240f, 0.776888465673232440f, 0.769103337645579700f, + 0.761202385484261780f, 0.753186799043612520f, 0.745057785441466060f, + 0.736816568877369900f, 0.728464390448225200f, 0.720002507961381650f, + 0.711432195745216430f, 0.702754744457225300f, 0.693971460889654000f, + 0.685083667772700360f, 0.676092703575316030f, 0.666999922303637470f, + 0.657806693297078640f, 0.648514401022112550f, 0.639124444863775730f, + 0.629638238914927100f, 0.620057211763289210f, 0.610382806276309480f, + 0.600616479383868970f, 0.590759701858874280f, 0.580813958095764530f, + 0.570780745886967370f, 0.560661576197336030f, 0.550457972936604810f, + 0.540171472729892970f, 0.529803624686294830f, 0.519355990165589530f, + 0.508830142543106990f, 0.498227666972781870f, 0.487550160148436050f, + 0.476799230063322250f, 0.465976495767966130f, 0.455083587126343840f, + 0.444122144570429260f, 0.433093818853152010f, 0.422000270799799790f, + 0.410843171057903910f, 0.399624199845646790f, 0.388345046698826300f, + 0.377007410216418310f, 0.365612997804773960f, 0.354163525420490510f, + 0.342660717311994380f, 0.331106305759876430f, 0.319502030816015750f, + 0.307849640041534980f, 0.296150888243623960f, 0.284407537211271820f, + 0.272621355449948980f, 0.260794117915275570f, 0.248927605745720260f, + 0.237023605994367340f, 0.225083911359792780f, 0.213110319916091360f, + 0.201104634842091960f, 0.189068664149806280f, 0.177004220412148860f, + 0.164913120489970090f, 0.152797185258443410f, 0.140658239332849240f, + 0.128498110793793220f, 0.116318630911904880f, 0.104121633872054730f, + 0.091908956497132696f, 0.079682437971430126f, 0.067443919563664106f, + 0.055195244349690031f, 0.042938256934940959f, 0.030674803176636581f, + 0.018406729905804820f, 0.006135884649154515f}; static const float32_t cos_factors_512[512] = { - 0.999998823451701880f, 0.999989411081928400f, 0.999970586430974140f, - 0.999942349676023910f, - 0.999904701082852900f, 0.999857641005823860f, 0.999801169887884260f, - 0.999735288260561680f, - 0.999659996743959220f, 0.999575296046749220f, 0.999481186966166950f, - 0.999377670388002850f, - 0.999264747286594420f, 0.999142418724816910f, 0.999010685854073380f, - 0.998869549914283560f, - 0.998719012233872940f, 0.998559074229759310f, 0.998389737407340160f, - 0.998211003360478190f, - 0.998022873771486240f, 0.997825350411111640f, 0.997618435138519550f, - 0.997402129901275300f, - 0.997176436735326190f, 0.996941357764982160f, 0.996696895202896060f, - 0.996443051350042630f, - 0.996179828595696980f, 0.995907229417411720f, 0.995625256380994310f, - 0.995333912140482280f, - 0.995033199438118630f, 0.994723121104325700f, 0.994403680057679100f, - 0.994074879304879370f, - 0.993736721940724600f, 0.993389211148080650f, 0.993032350197851410f, - 0.992666142448948020f, - 0.992290591348257370f, 0.991905700430609330f, 0.991511473318743900f, - 0.991107913723276890f, - 0.990695025442664630f, 0.990272812363169110f, 0.989841278458820530f, - 0.989400427791380380f, - 0.988950264510302990f, 0.988490792852696590f, 0.988022017143283530f, - 0.987543941794359230f, - 0.987056571305750970f, 0.986559910264775410f, 0.986053963346195440f, - 0.985538735312176060f, - 0.985014231012239840f, 0.984480455383220930f, 0.983937413449218920f, - 0.983385110321551180f, - 0.982823551198705240f, 0.982252741366289370f, 0.981672686196983110f, - 0.981083391150486710f, - 0.980484861773469380f, 0.979877103699517640f, 0.979260122649082020f, - 0.978633924429423210f, - 0.977998514934557140f, 0.977353900145199960f, 0.976700086128711840f, - 0.976037079039039020f, - 0.975364885116656980f, 0.974683510688510670f, 0.973992962167955830f, - 0.973293246054698250f, - 0.972584368934732210f, 0.971866337480279400f, 0.971139158449725090f, - 0.970402838687555500f, - 0.969657385124292450f, 0.968902804776428870f, 0.968139104746362440f, - 0.967366292222328510f, - 0.966584374478333120f, 0.965793358874083680f, 0.964993252854920320f, - 0.964184063951745830f, - 0.963365799780954050f, 0.962538468044359160f, 0.961702076529122540f, - 0.960856633107679660f, - 0.960002145737665960f, 0.959138622461841890f, 0.958266071408017670f, - 0.957384500788975860f, - 0.956493918902395100f, 0.955594334130771110f, 0.954685754941338340f, - 0.953768189885990330f, - 0.952841647601198720f, 0.951906136807932350f, 0.950961666311575080f, - 0.950008245001843000f, - 0.949045881852700560f, 0.948074585922276230f, 0.947094366352777220f, - 0.946105232370403450f, - 0.945107193285260610f, 0.944100258491272660f, 0.943084437466093490f, - 0.942059739771017310f, - 0.941026175050889260f, 0.939983753034014050f, 0.938932483532064600f, - 0.937872376439989890f, - 0.936803441735921560f, 0.935725689481080370f, 0.934639129819680780f, - 0.933543772978836170f, - 0.932439629268462360f, 0.931326709081180430f, 0.930205022892219070f, - 0.929074581259315860f, - 0.927935394822617890f, 0.926787474304581750f, 0.925630830509872720f, - 0.924465474325262600f, - 0.923291416719527640f, 0.922108668743345180f, 0.920917241529189520f, - 0.919717146291227360f, - 0.918508394325212250f, 0.917290997008377910f, 0.916064965799331720f, - 0.914830312237946200f, - 0.913587047945250810f, 0.912335184623322750f, 0.911074734055176360f, - 0.909805708104652220f, - 0.908528118716306120f, 0.907241977915295820f, 0.905947297807268460f, - 0.904644090578246240f, - 0.903332368494511820f, 0.902012143902493180f, 0.900683429228646970f, - 0.899346236979341570f, - 0.898000579740739880f, 0.896646470178680150f, 0.895283921038557580f, - 0.893912945145203250f, - 0.892533555402764580f, 0.891145764794583180f, 0.889749586383072780f, - 0.888345033309596350f, - 0.886932118794342190f, 0.885510856136199950f, 0.884081258712634990f, - 0.882643339979562790f, - 0.881197113471222090f, 0.879742592800047410f, 0.878279791656541580f, - 0.876808723809145650f, - 0.875329403104110890f, 0.873841843465366860f, 0.872346058894391540f, - 0.870842063470078980f, - 0.869329871348606840f, 0.867809496763303320f, 0.866280954024512990f, - 0.864744257519462380f, - 0.863199421712124160f, 0.861646461143081300f, 0.860085390429390140f, - 0.858516224264442740f, - 0.856938977417828760f, 0.855353664735196030f, 0.853760301138111410f, - 0.852158901623919830f, - 0.850549481265603480f, 0.848932055211639610f, 0.847306638685858320f, - 0.845673246987299070f, - 0.844031895490066410f, 0.842382599643185850f, 0.840725374970458070f, - 0.839060237070312740f, - 0.837387201615661940f, 0.835706284353752600f, 0.834017501106018130f, - 0.832320867767929680f, - 0.830616400308846310f, 0.828904114771864870f, 0.827184027273669130f, - 0.825456154004377550f, - 0.823720511227391430f, 0.821977115279241550f, 0.820225982569434690f, - 0.818467129580298660f, - 0.816700572866827850f, 0.814926329056526620f, 0.813144414849253590f, - 0.811354847017063730f, - 0.809557642404051260f, 0.807752817926190360f, 0.805940390571176280f, - 0.804120377398265810f, - 0.802292795538115720f, 0.800457662192622820f, 0.798614994634760820f, - 0.796764810208418830f, - 0.794907126328237010f, 0.793041960479443640f, 0.791169330217690200f, - 0.789289253168885650f, - 0.787401747029031430f, 0.785506829564053930f, 0.783604518609638200f, - 0.781694832071059390f, - 0.779777787923014550f, 0.777853404209453150f, 0.775921699043407690f, - 0.773982690606822900f, - 0.772036397150384520f, 0.770082836993347900f, 0.768122028523365420f, - 0.766153990196312920f, - 0.764178740536116670f, 0.762196298134578900f, 0.760206681651202420f, - 0.758209909813015280f, - 0.756206001414394540f, 0.754194975316889170f, 0.752176850449042810f, - 0.750151645806215070f, - 0.748119380450403600f, 0.746080073510063780f, 0.744033744179929290f, - 0.741980411720831070f, - 0.739920095459516200f, 0.737852814788465980f, 0.735778589165713590f, - 0.733697438114660370f, - 0.731609381223892630f, 0.729514438146997010f, 0.727412628602375770f, - 0.725303972373060770f, - 0.723188489306527460f, 0.721066199314508110f, 0.718937122372804490f, - 0.716801278521099540f, - 0.714658687862769090f, 0.712509370564692320f, 0.710353346857062420f, - 0.708190637033195400f, - 0.706021261449339740f, 0.703845240524484940f, 0.701662594740168570f, - 0.699473344640283770f, - 0.697277510830886630f, 0.695075113980000880f, 0.692866174817424740f, - 0.690650714134534720f, - 0.688428752784090550f, 0.686200311680038700f, 0.683965411797315510f, - 0.681724074171649820f, - 0.679476319899365080f, 0.677222170137180450f, 0.674961646102012040f, - 0.672694769070772970f, - 0.670421560380173090f, 0.668142041426518560f, 0.665856233665509720f, - 0.663564158612039880f, - 0.661265837839992270f, 0.658961292982037320f, 0.656650545729429050f, - 0.654333617831800550f, - 0.652010531096959500f, 0.649681307390683190f, 0.647345968636512060f, - 0.645004536815544040f, - 0.642657033966226860f, 0.640303482184151670f, 0.637943903621844170f, - 0.635578320488556230f, - 0.633206755050057190f, 0.630829229628424470f, 0.628445766601832710f, - 0.626056388404343520f, - 0.623661117525694640f, 0.621259976511087660f, 0.618852987960976320f, - 0.616440174530853650f, - 0.614021558931038490f, 0.611597163926462020f, 0.609167012336453210f, - 0.606731127034524480f, - 0.604289530948156070f, 0.601842247058580030f, 0.599389298400564540f, - 0.596930708062196500f, - 0.594466499184664540f, 0.591996694962040990f, 0.589521318641063940f, - 0.587040393520918080f, - 0.584553942953015330f, 0.582061990340775550f, 0.579564559139405740f, - 0.577061672855679550f, - 0.574553355047715760f, 0.572039629324757050f, 0.569520519346947250f, - 0.566996048825108680f, - 0.564466241520519500f, 0.561931121244689470f, 0.559390711859136140f, - 0.556845037275160100f, - 0.554294121453620110f, 0.551737988404707450f, 0.549176662187719770f, - 0.546610166910834860f, - 0.544038526730883930f, 0.541461765853123560f, 0.538879908531008420f, - 0.536292979065963180f, - 0.533701001807152960f, 0.531104001151255000f, 0.528502001542228480f, - 0.525895027471084740f, - 0.523283103475656430f, 0.520666254140367270f, 0.518044504095999340f, - 0.515417878019463150f, - 0.512786400633563070f, 0.510150096706766700f, 0.507508991052970870f, - 0.504863108531267480f, - 0.502212474045710900f, 0.499557112545081890f, 0.496897049022654640f, - 0.494232308515959730f, - 0.491562916106550060f, 0.488888896919763230f, 0.486210276124486530f, - 0.483527078932918740f, - 0.480839330600333900f, 0.478147056424843120f, 0.475450281747155870f, - 0.472749031950342900f, - 0.470043332459595620f, 0.467333208741988530f, 0.464618686306237820f, - 0.461899790702462840f, - 0.459176547521944150f, 0.456448982396883860f, 0.453717121000163930f, - 0.450980989045103810f, - 0.448240612285220000f, 0.445496016513981740f, 0.442747227564570130f, - 0.439994271309633260f, - 0.437237173661044200f, 0.434475960569655710f, 0.431710658025057370f, - 0.428941292055329550f, - 0.426167888726799620f, 0.423390474143796100f, 0.420609074448402510f, - 0.417823715820212380f, - 0.415034424476081630f, 0.412241226669883000f, 0.409444148692257590f, - 0.406643216870369140f, - 0.403838457567654130f, 0.401029897183575790f, 0.398217562153373620f, - 0.395401478947816300f, - 0.392581674072951530f, 0.389758174069856410f, 0.386931005514388690f, - 0.384100195016935040f, - 0.381265769222162490f, 0.378427754808765620f, 0.375586178489217330f, - 0.372741067009515810f, - 0.369892447148934270f, 0.367040345719767240f, 0.364184789567079840f, - 0.361325805568454340f, - 0.358463420633736540f, 0.355597661704783960f, 0.352728555755210730f, - 0.349856129790135030f, - 0.346980410845923680f, 0.344101425989938980f, 0.341219202320282410f, - 0.338333766965541290f, - 0.335445147084531660f, 0.332553369866044220f, 0.329658462528587550f, - 0.326760452320131790f, - 0.323859366517852960f, 0.320955232427875210f, 0.318048077385015060f, - 0.315137928752522440f, - 0.312224813921825050f, 0.309308760312268780f, 0.306389795370861080f, - 0.303467946572011370f, - 0.300543241417273400f, 0.297615707435086310f, 0.294685372180514330f, - 0.291752263234989370f, - 0.288816408206049480f, 0.285877834727080730f, 0.282936570457055390f, - 0.279992643080273380f, - 0.277046080306099950f, 0.274096909868706330f, 0.271145159526808070f, - 0.268190857063403180f, - 0.265234030285511900f, 0.262274707023913590f, 0.259312915132886350f, - 0.256348682489942910f, - 0.253382036995570270f, 0.250413006572965280f, 0.247441619167773440f, - 0.244467902747824210f, - 0.241491885302869300f, 0.238513594844318500f, 0.235533059404975460f, - 0.232550307038775330f, - 0.229565365820518870f, 0.226578263845610110f, 0.223589029229790020f, - 0.220597690108873650f, - 0.217604274638483670f, 0.214608810993786920f, 0.211611327369227610f, - 0.208611851978263460f, - 0.205610413053099320f, 0.202607038844421110f, 0.199601757621131050f, - 0.196594597670080220f, - 0.193585587295803750f, 0.190574754820252800f, 0.187562128582529740f, - 0.184547736938619640f, - 0.181531608261125130f, 0.178513770938997590f, 0.175494253377271400f, - 0.172473083996796030f, - 0.169450291233967930f, 0.166425903540464220f, 0.163399949382973230f, - 0.160372457242928400f, - 0.157343455616238280f, 0.154312973013020240f, 0.151281037957330250f, - 0.148247678986896200f, - 0.145212924652847520f, 0.142176803519448000f, 0.139139344163826280f, - 0.136100575175706200f, - 0.133060525157139180f, 0.130019222722233350f, 0.126976696496885980f, - 0.123932975118512200f, - 0.120888087235777220f, 0.117842061508325020f, 0.114794926606510250f, - 0.111746711211126660f, - 0.108697444013138670f, 0.105647153713410700f, 0.102595869022436280f, - 0.099543618660069444f, - 0.096490431355252607f, 0.093436335845747912f, 0.090381360877865011f, - 0.087325535206192226f, - 0.084268887593324127f, 0.081211446809592386f, 0.078153241632794315f, - 0.075094300847921291f, - 0.072034653246889416f, 0.068974327628266732f, 0.065913352797003930f, - 0.062851757564161420f, - 0.059789570746640007f, 0.056726821166907783f, 0.053663537652730679f, - 0.050599749036899337f, - 0.047535484156959261f, 0.044470771854938744f, 0.041405640977076712f, - 0.038340120373552791f, - 0.035274238898213947f, 0.032208025408304704f, 0.029141508764193740f, - 0.026074717829104040f, - 0.023007681468839410f, 0.019940428551514598f, 0.016872987947281773f, - 0.013805388528060349f, - 0.010737659167264572f, 0.007669828739531077f, 0.004601926120448672f, - 0.001533980186284766f -}; + 0.999998823451701880f, 0.999989411081928400f, 0.999970586430974140f, + 0.999942349676023910f, 0.999904701082852900f, 0.999857641005823860f, + 0.999801169887884260f, 0.999735288260561680f, 0.999659996743959220f, + 0.999575296046749220f, 0.999481186966166950f, 0.999377670388002850f, + 0.999264747286594420f, 0.999142418724816910f, 0.999010685854073380f, + 0.998869549914283560f, 0.998719012233872940f, 0.998559074229759310f, + 0.998389737407340160f, 0.998211003360478190f, 0.998022873771486240f, + 0.997825350411111640f, 0.997618435138519550f, 0.997402129901275300f, + 0.997176436735326190f, 0.996941357764982160f, 0.996696895202896060f, + 0.996443051350042630f, 0.996179828595696980f, 0.995907229417411720f, + 0.995625256380994310f, 0.995333912140482280f, 0.995033199438118630f, + 0.994723121104325700f, 0.994403680057679100f, 0.994074879304879370f, + 0.993736721940724600f, 0.993389211148080650f, 0.993032350197851410f, + 0.992666142448948020f, 0.992290591348257370f, 0.991905700430609330f, + 0.991511473318743900f, 0.991107913723276890f, 0.990695025442664630f, + 0.990272812363169110f, 0.989841278458820530f, 0.989400427791380380f, + 0.988950264510302990f, 0.988490792852696590f, 0.988022017143283530f, + 0.987543941794359230f, 0.987056571305750970f, 0.986559910264775410f, + 0.986053963346195440f, 0.985538735312176060f, 0.985014231012239840f, + 0.984480455383220930f, 0.983937413449218920f, 0.983385110321551180f, + 0.982823551198705240f, 0.982252741366289370f, 0.981672686196983110f, + 0.981083391150486710f, 0.980484861773469380f, 0.979877103699517640f, + 0.979260122649082020f, 0.978633924429423210f, 0.977998514934557140f, + 0.977353900145199960f, 0.976700086128711840f, 0.976037079039039020f, + 0.975364885116656980f, 0.974683510688510670f, 0.973992962167955830f, + 0.973293246054698250f, 0.972584368934732210f, 0.971866337480279400f, + 0.971139158449725090f, 0.970402838687555500f, 0.969657385124292450f, + 0.968902804776428870f, 0.968139104746362440f, 0.967366292222328510f, + 0.966584374478333120f, 0.965793358874083680f, 0.964993252854920320f, + 0.964184063951745830f, 0.963365799780954050f, 0.962538468044359160f, + 0.961702076529122540f, 0.960856633107679660f, 0.960002145737665960f, + 0.959138622461841890f, 0.958266071408017670f, 0.957384500788975860f, + 0.956493918902395100f, 0.955594334130771110f, 0.954685754941338340f, + 0.953768189885990330f, 0.952841647601198720f, 0.951906136807932350f, + 0.950961666311575080f, 0.950008245001843000f, 0.949045881852700560f, + 0.948074585922276230f, 0.947094366352777220f, 0.946105232370403450f, + 0.945107193285260610f, 0.944100258491272660f, 0.943084437466093490f, + 0.942059739771017310f, 0.941026175050889260f, 0.939983753034014050f, + 0.938932483532064600f, 0.937872376439989890f, 0.936803441735921560f, + 0.935725689481080370f, 0.934639129819680780f, 0.933543772978836170f, + 0.932439629268462360f, 0.931326709081180430f, 0.930205022892219070f, + 0.929074581259315860f, 0.927935394822617890f, 0.926787474304581750f, + 0.925630830509872720f, 0.924465474325262600f, 0.923291416719527640f, + 0.922108668743345180f, 0.920917241529189520f, 0.919717146291227360f, + 0.918508394325212250f, 0.917290997008377910f, 0.916064965799331720f, + 0.914830312237946200f, 0.913587047945250810f, 0.912335184623322750f, + 0.911074734055176360f, 0.909805708104652220f, 0.908528118716306120f, + 0.907241977915295820f, 0.905947297807268460f, 0.904644090578246240f, + 0.903332368494511820f, 0.902012143902493180f, 0.900683429228646970f, + 0.899346236979341570f, 0.898000579740739880f, 0.896646470178680150f, + 0.895283921038557580f, 0.893912945145203250f, 0.892533555402764580f, + 0.891145764794583180f, 0.889749586383072780f, 0.888345033309596350f, + 0.886932118794342190f, 0.885510856136199950f, 0.884081258712634990f, + 0.882643339979562790f, 0.881197113471222090f, 0.879742592800047410f, + 0.878279791656541580f, 0.876808723809145650f, 0.875329403104110890f, + 0.873841843465366860f, 0.872346058894391540f, 0.870842063470078980f, + 0.869329871348606840f, 0.867809496763303320f, 0.866280954024512990f, + 0.864744257519462380f, 0.863199421712124160f, 0.861646461143081300f, + 0.860085390429390140f, 0.858516224264442740f, 0.856938977417828760f, + 0.855353664735196030f, 0.853760301138111410f, 0.852158901623919830f, + 0.850549481265603480f, 0.848932055211639610f, 0.847306638685858320f, + 0.845673246987299070f, 0.844031895490066410f, 0.842382599643185850f, + 0.840725374970458070f, 0.839060237070312740f, 0.837387201615661940f, + 0.835706284353752600f, 0.834017501106018130f, 0.832320867767929680f, + 0.830616400308846310f, 0.828904114771864870f, 0.827184027273669130f, + 0.825456154004377550f, 0.823720511227391430f, 0.821977115279241550f, + 0.820225982569434690f, 0.818467129580298660f, 0.816700572866827850f, + 0.814926329056526620f, 0.813144414849253590f, 0.811354847017063730f, + 0.809557642404051260f, 0.807752817926190360f, 0.805940390571176280f, + 0.804120377398265810f, 0.802292795538115720f, 0.800457662192622820f, + 0.798614994634760820f, 0.796764810208418830f, 0.794907126328237010f, + 0.793041960479443640f, 0.791169330217690200f, 0.789289253168885650f, + 0.787401747029031430f, 0.785506829564053930f, 0.783604518609638200f, + 0.781694832071059390f, 0.779777787923014550f, 0.777853404209453150f, + 0.775921699043407690f, 0.773982690606822900f, 0.772036397150384520f, + 0.770082836993347900f, 0.768122028523365420f, 0.766153990196312920f, + 0.764178740536116670f, 0.762196298134578900f, 0.760206681651202420f, + 0.758209909813015280f, 0.756206001414394540f, 0.754194975316889170f, + 0.752176850449042810f, 0.750151645806215070f, 0.748119380450403600f, + 0.746080073510063780f, 0.744033744179929290f, 0.741980411720831070f, + 0.739920095459516200f, 0.737852814788465980f, 0.735778589165713590f, + 0.733697438114660370f, 0.731609381223892630f, 0.729514438146997010f, + 0.727412628602375770f, 0.725303972373060770f, 0.723188489306527460f, + 0.721066199314508110f, 0.718937122372804490f, 0.716801278521099540f, + 0.714658687862769090f, 0.712509370564692320f, 0.710353346857062420f, + 0.708190637033195400f, 0.706021261449339740f, 0.703845240524484940f, + 0.701662594740168570f, 0.699473344640283770f, 0.697277510830886630f, + 0.695075113980000880f, 0.692866174817424740f, 0.690650714134534720f, + 0.688428752784090550f, 0.686200311680038700f, 0.683965411797315510f, + 0.681724074171649820f, 0.679476319899365080f, 0.677222170137180450f, + 0.674961646102012040f, 0.672694769070772970f, 0.670421560380173090f, + 0.668142041426518560f, 0.665856233665509720f, 0.663564158612039880f, + 0.661265837839992270f, 0.658961292982037320f, 0.656650545729429050f, + 0.654333617831800550f, 0.652010531096959500f, 0.649681307390683190f, + 0.647345968636512060f, 0.645004536815544040f, 0.642657033966226860f, + 0.640303482184151670f, 0.637943903621844170f, 0.635578320488556230f, + 0.633206755050057190f, 0.630829229628424470f, 0.628445766601832710f, + 0.626056388404343520f, 0.623661117525694640f, 0.621259976511087660f, + 0.618852987960976320f, 0.616440174530853650f, 0.614021558931038490f, + 0.611597163926462020f, 0.609167012336453210f, 0.606731127034524480f, + 0.604289530948156070f, 0.601842247058580030f, 0.599389298400564540f, + 0.596930708062196500f, 0.594466499184664540f, 0.591996694962040990f, + 0.589521318641063940f, 0.587040393520918080f, 0.584553942953015330f, + 0.582061990340775550f, 0.579564559139405740f, 0.577061672855679550f, + 0.574553355047715760f, 0.572039629324757050f, 0.569520519346947250f, + 0.566996048825108680f, 0.564466241520519500f, 0.561931121244689470f, + 0.559390711859136140f, 0.556845037275160100f, 0.554294121453620110f, + 0.551737988404707450f, 0.549176662187719770f, 0.546610166910834860f, + 0.544038526730883930f, 0.541461765853123560f, 0.538879908531008420f, + 0.536292979065963180f, 0.533701001807152960f, 0.531104001151255000f, + 0.528502001542228480f, 0.525895027471084740f, 0.523283103475656430f, + 0.520666254140367270f, 0.518044504095999340f, 0.515417878019463150f, + 0.512786400633563070f, 0.510150096706766700f, 0.507508991052970870f, + 0.504863108531267480f, 0.502212474045710900f, 0.499557112545081890f, + 0.496897049022654640f, 0.494232308515959730f, 0.491562916106550060f, + 0.488888896919763230f, 0.486210276124486530f, 0.483527078932918740f, + 0.480839330600333900f, 0.478147056424843120f, 0.475450281747155870f, + 0.472749031950342900f, 0.470043332459595620f, 0.467333208741988530f, + 0.464618686306237820f, 0.461899790702462840f, 0.459176547521944150f, + 0.456448982396883860f, 0.453717121000163930f, 0.450980989045103810f, + 0.448240612285220000f, 0.445496016513981740f, 0.442747227564570130f, + 0.439994271309633260f, 0.437237173661044200f, 0.434475960569655710f, + 0.431710658025057370f, 0.428941292055329550f, 0.426167888726799620f, + 0.423390474143796100f, 0.420609074448402510f, 0.417823715820212380f, + 0.415034424476081630f, 0.412241226669883000f, 0.409444148692257590f, + 0.406643216870369140f, 0.403838457567654130f, 0.401029897183575790f, + 0.398217562153373620f, 0.395401478947816300f, 0.392581674072951530f, + 0.389758174069856410f, 0.386931005514388690f, 0.384100195016935040f, + 0.381265769222162490f, 0.378427754808765620f, 0.375586178489217330f, + 0.372741067009515810f, 0.369892447148934270f, 0.367040345719767240f, + 0.364184789567079840f, 0.361325805568454340f, 0.358463420633736540f, + 0.355597661704783960f, 0.352728555755210730f, 0.349856129790135030f, + 0.346980410845923680f, 0.344101425989938980f, 0.341219202320282410f, + 0.338333766965541290f, 0.335445147084531660f, 0.332553369866044220f, + 0.329658462528587550f, 0.326760452320131790f, 0.323859366517852960f, + 0.320955232427875210f, 0.318048077385015060f, 0.315137928752522440f, + 0.312224813921825050f, 0.309308760312268780f, 0.306389795370861080f, + 0.303467946572011370f, 0.300543241417273400f, 0.297615707435086310f, + 0.294685372180514330f, 0.291752263234989370f, 0.288816408206049480f, + 0.285877834727080730f, 0.282936570457055390f, 0.279992643080273380f, + 0.277046080306099950f, 0.274096909868706330f, 0.271145159526808070f, + 0.268190857063403180f, 0.265234030285511900f, 0.262274707023913590f, + 0.259312915132886350f, 0.256348682489942910f, 0.253382036995570270f, + 0.250413006572965280f, 0.247441619167773440f, 0.244467902747824210f, + 0.241491885302869300f, 0.238513594844318500f, 0.235533059404975460f, + 0.232550307038775330f, 0.229565365820518870f, 0.226578263845610110f, + 0.223589029229790020f, 0.220597690108873650f, 0.217604274638483670f, + 0.214608810993786920f, 0.211611327369227610f, 0.208611851978263460f, + 0.205610413053099320f, 0.202607038844421110f, 0.199601757621131050f, + 0.196594597670080220f, 0.193585587295803750f, 0.190574754820252800f, + 0.187562128582529740f, 0.184547736938619640f, 0.181531608261125130f, + 0.178513770938997590f, 0.175494253377271400f, 0.172473083996796030f, + 0.169450291233967930f, 0.166425903540464220f, 0.163399949382973230f, + 0.160372457242928400f, 0.157343455616238280f, 0.154312973013020240f, + 0.151281037957330250f, 0.148247678986896200f, 0.145212924652847520f, + 0.142176803519448000f, 0.139139344163826280f, 0.136100575175706200f, + 0.133060525157139180f, 0.130019222722233350f, 0.126976696496885980f, + 0.123932975118512200f, 0.120888087235777220f, 0.117842061508325020f, + 0.114794926606510250f, 0.111746711211126660f, 0.108697444013138670f, + 0.105647153713410700f, 0.102595869022436280f, 0.099543618660069444f, + 0.096490431355252607f, 0.093436335845747912f, 0.090381360877865011f, + 0.087325535206192226f, 0.084268887593324127f, 0.081211446809592386f, + 0.078153241632794315f, 0.075094300847921291f, 0.072034653246889416f, + 0.068974327628266732f, 0.065913352797003930f, 0.062851757564161420f, + 0.059789570746640007f, 0.056726821166907783f, 0.053663537652730679f, + 0.050599749036899337f, 0.047535484156959261f, 0.044470771854938744f, + 0.041405640977076712f, 0.038340120373552791f, 0.035274238898213947f, + 0.032208025408304704f, 0.029141508764193740f, 0.026074717829104040f, + 0.023007681468839410f, 0.019940428551514598f, 0.016872987947281773f, + 0.013805388528060349f, 0.010737659167264572f, 0.007669828739531077f, + 0.004601926120448672f, 0.001533980186284766f}; static const float32_t cos_factors_2048[2048] = { - 0.999999926465717890f, 0.999999338191525530f, 0.999998161643486980f, - 0.999996396822294350f, - 0.999994043728985820f, 0.999991102364945590f, 0.999987572731904080f, - 0.999983454831937730f, - 0.999978748667468830f, 0.999973454241265940f, 0.999967571556443780f, - 0.999961100616462820f, - 0.999954041425129780f, 0.999946393986597460f, 0.999938158305364590f, - 0.999929334386276070f, - 0.999919922234522750f, 0.999909921855641540f, 0.999899333255515390f, - 0.999888156440373320f, - 0.999876391416790410f, 0.999864038191687680f, 0.999851096772332190f, - 0.999837567166337090f, - 0.999823449381661570f, 0.999808743426610520f, 0.999793449309835270f, - 0.999777567040332940f, - 0.999761096627446610f, 0.999744038080865430f, 0.999726391410624470f, - 0.999708156627104880f, - 0.999689333741033640f, 0.999669922763483760f, 0.999649923705874240f, - 0.999629336579970110f, - 0.999608161397882110f, 0.999586398172067070f, 0.999564046915327740f, - 0.999541107640812940f, - 0.999517580362016990f, 0.999493465092780590f, 0.999468761847290050f, - 0.999443470640077770f, - 0.999417591486021720f, 0.999391124400346050f, 0.999364069398620550f, - 0.999336426496761240f, - 0.999308195711029470f, 0.999279377058032710f, 0.999249970554724420f, - 0.999219976218403530f, - 0.999189394066714920f, 0.999158224117649430f, 0.999126466389543390f, - 0.999094120901079070f, - 0.999061187671284600f, 0.999027666719533690f, 0.998993558065545680f, - 0.998958861729386080f, - 0.998923577731465780f, 0.998887706092541290f, 0.998851246833715180f, - 0.998814199976435390f, - 0.998776565542495610f, 0.998738343554035230f, 0.998699534033539280f, - 0.998660137003838490f, - 0.998620152488108870f, 0.998579580509872500f, 0.998538421092996730f, - 0.998496674261694640f, - 0.998454340040524800f, 0.998411418454391300f, 0.998367909528543820f, - 0.998323813288577560f, - 0.998279129760433200f, 0.998233858970396850f, 0.998188000945100300f, - 0.998141555711520520f, - 0.998094523296980010f, 0.998046903729146840f, 0.997998697036034390f, - 0.997949903246001190f, - 0.997900522387751620f, 0.997850554490335110f, 0.997799999583146470f, - 0.997748857695925690f, - 0.997697128858758500f, 0.997644813102075420f, 0.997591910456652630f, - 0.997538420953611340f, - 0.997484344624417930f, 0.997429681500884180f, 0.997374431615167150f, - 0.997318594999768600f, - 0.997262171687536170f, 0.997205161711661850f, 0.997147565105683480f, - 0.997089381903483400f, - 0.997030612139289450f, 0.996971255847674320f, 0.996911313063555740f, - 0.996850783822196610f, - 0.996789668159204560f, 0.996727966110532490f, 0.996665677712478160f, - 0.996602803001684130f, - 0.996539342015137940f, 0.996475294790172160f, 0.996410661364464100f, - 0.996345441776035900f, - 0.996279636063254650f, 0.996213244264832040f, 0.996146266419824620f, - 0.996078702567633980f, - 0.996010552748005870f, 0.995941817001031350f, 0.995872495367145730f, - 0.995802587887129160f, - 0.995732094602106430f, 0.995661015553546910f, 0.995589350783264600f, - 0.995517100333418110f, - 0.995444264246510340f, 0.995370842565388990f, 0.995296835333246090f, - 0.995222242593618360f, - 0.995147064390386470f, 0.995071300767776170f, 0.994994951770357020f, - 0.994918017443043200f, - 0.994840497831093180f, 0.994762392980109930f, 0.994683702936040250f, - 0.994604427745175660f, - 0.994524567454151740f, 0.994444122109948040f, 0.994363091759888570f, - 0.994281476451641550f, - 0.994199276233218910f, 0.994116491152977070f, 0.994033121259616400f, - 0.993949166602181130f, - 0.993864627230059750f, 0.993779503192984580f, 0.993693794541031790f, - 0.993607501324621610f, - 0.993520623594518090f, 0.993433161401829360f, 0.993345114798006910f, - 0.993256483834846440f, - 0.993167268564487230f, 0.993077469039412300f, 0.992987085312448390f, - 0.992896117436765980f, - 0.992804565465879140f, 0.992712429453645460f, 0.992619709454266140f, - 0.992526405522286100f, - 0.992432517712593660f, 0.992338046080420420f, 0.992242990681341700f, - 0.992147351571276090f, - 0.992051128806485720f, 0.991954322443575950f, 0.991856932539495470f, - 0.991758959151536110f, - 0.991660402337333210f, 0.991561262154865290f, 0.991461538662453790f, - 0.991361231918763460f, - 0.991260341982802440f, 0.991158868913921350f, 0.991056812771814340f, - 0.990954173616518500f, - 0.990850951508413620f, 0.990747146508222710f, 0.990642758677011570f, - 0.990537788076188750f, - 0.990432234767505970f, 0.990326098813057330f, 0.990219380275280000f, - 0.990112079216953770f, - 0.990004195701200910f, 0.989895729791486660f, 0.989786681551618640f, - 0.989677051045747210f, - 0.989566838338365120f, 0.989456043494307710f, 0.989344666578752640f, - 0.989232707657220050f, - 0.989120166795572690f, 0.989007044060015270f, 0.988893339517095130f, - 0.988779053233701520f, - 0.988664185277066230f, 0.988548735714763200f, 0.988432704614708340f, - 0.988316092045159690f, - 0.988198898074717610f, 0.988081122772324070f, 0.987962766207263420f, - 0.987843828449161740f, - 0.987724309567986960f, 0.987604209634049160f, 0.987483528717999710f, - 0.987362266890832400f, - 0.987240424223882250f, 0.987118000788826280f, 0.986994996657682980f, - 0.986871411902812470f, - 0.986747246596916590f, 0.986622500813038480f, 0.986497174624562880f, - 0.986371268105216030f, - 0.986244781329065460f, 0.986117714370520090f, 0.985990067304330140f, - 0.985861840205586980f, - 0.985733033149723490f, 0.985603646212513400f, 0.985473679470071810f, - 0.985343132998854790f, - 0.985212006875659350f, 0.985080301177623800f, 0.984948015982227030f, - 0.984815151367289140f, - 0.984681707410970940f, 0.984547684191773960f, 0.984413081788540700f, - 0.984277900280454370f, - 0.984142139747038570f, 0.984005800268157870f, 0.983868881924017220f, - 0.983731384795162090f, - 0.983593308962478650f, 0.983454654507193270f, 0.983315421510872810f, - 0.983175610055424420f, - 0.983035220223095640f, 0.982894252096474070f, 0.982752705758487830f, - 0.982610581292404750f, - 0.982467878781833170f, 0.982324598310721280f, 0.982180739963357090f, - 0.982036303824369020f, - 0.981891289978725100f, 0.981745698511732990f, 0.981599529509040720f, - 0.981452783056635520f, - 0.981305459240844670f, 0.981157558148334830f, 0.981009079866112630f, - 0.980860024481523870f, - 0.980710392082253970f, 0.980560182756327840f, 0.980409396592109910f, - 0.980258033678303550f, - 0.980106094103951770f, 0.979953577958436740f, 0.979800485331479790f, - 0.979646816313141210f, - 0.979492570993820810f, 0.979337749464256780f, 0.979182351815526930f, - 0.979026378139047580f, - 0.978869828526574120f, 0.978712703070200420f, 0.978555001862359550f, - 0.978396724995823090f, - 0.978237872563701090f, 0.978078444659442380f, 0.977918441376834370f, - 0.977757862810002760f, - 0.977596709053411890f, 0.977434980201864260f, 0.977272676350500860f, - 0.977109797594800880f, - 0.976946344030581670f, 0.976782315753998650f, 0.976617712861545640f, - 0.976452535450054060f, - 0.976286783616693630f, 0.976120457458971910f, 0.975953557074734300f, - 0.975786082562163930f, - 0.975618034019781750f, 0.975449411546446380f, 0.975280215241354220f, - 0.975110445204038890f, - 0.974940101534371830f, 0.974769184332561770f, 0.974597693699155050f, - 0.974425629735034990f, - 0.974252992541422500f, 0.974079782219875680f, 0.973905998872289570f, - 0.973731642600896400f, - 0.973556713508265560f, 0.973381211697303290f, 0.973205137271252800f, - 0.973028490333694210f, - 0.972851270988544180f, 0.972673479340056430f, 0.972495115492821190f, - 0.972316179551765300f, - 0.972136671622152230f, 0.971956591809581720f, 0.971775940219990140f, - 0.971594716959650160f, - 0.971412922135170940f, 0.971230555853497380f, 0.971047618221911100f, - 0.970864109348029470f, - 0.970680029339806130f, 0.970495378305530560f, 0.970310156353828110f, - 0.970124363593660280f, - 0.969938000134323960f, 0.969751066085452140f, 0.969563561557013180f, - 0.969375486659311280f, - 0.969186841502985950f, 0.968997626199012420f, 0.968807840858700970f, - 0.968617485593697540f, - 0.968426560515983190f, 0.968235065737874320f, 0.968043001372022260f, - 0.967850367531413620f, - 0.967657164329369880f, 0.967463391879547550f, 0.967269050295937790f, - 0.967074139692867040f, - 0.966878660184995910f, 0.966682611887320080f, 0.966485994915169840f, - 0.966288809384209690f, - 0.966091055410438830f, 0.965892733110190860f, 0.965693842600133690f, - 0.965494383997269500f, - 0.965294357418934660f, 0.965093762982799590f, 0.964892600806868890f, - 0.964690871009481030f, - 0.964488573709308410f, 0.964285709025357480f, 0.964082277076968140f, - 0.963878277983814200f, - 0.963673711865903230f, 0.963468578843575950f, 0.963262879037507070f, - 0.963056612568704340f, - 0.962849779558509030f, 0.962642380128595710f, 0.962434414400972100f, - 0.962225882497979020f, - 0.962016784542290560f, 0.961807120656913540f, 0.961596890965187860f, - 0.961386095590786250f, - 0.961174734657714080f, 0.960962808290309780f, 0.960750316613243950f, - 0.960537259751520050f, - 0.960323637830473920f, 0.960109450975773940f, 0.959894699313420530f, - 0.959679382969746750f, - 0.959463502071417510f, 0.959247056745430090f, 0.959030047119113660f, - 0.958812473320129310f, - 0.958594335476470220f, 0.958375633716461170f, 0.958156368168758820f, - 0.957936538962351420f, - 0.957716146226558870f, 0.957495190091032570f, 0.957273670685755200f, - 0.957051588141040970f, - 0.956828942587535370f, 0.956605734156215080f, 0.956381962978387730f, - 0.956157629185692140f, - 0.955932732910098280f, 0.955707274283906560f, 0.955481253439748770f, - 0.955254670510586990f, - 0.955027525629714160f, 0.954799818930753720f, 0.954571550547659630f, - 0.954342720614716480f, - 0.954113329266538800f, 0.953883376638071770f, 0.953652862864590500f, - 0.953421788081700310f, - 0.953190152425336670f, 0.952957956031764700f, 0.952725199037579570f, - 0.952491881579706320f, - 0.952258003795399600f, 0.952023565822243570f, 0.951788567798152130f, - 0.951553009861368590f, - 0.951316892150465550f, 0.951080214804345010f, 0.950842977962238160f, - 0.950605181763705340f, - 0.950366826348635780f, 0.950127911857248100f, 0.949888438430089300f, - 0.949648406208035480f, - 0.949407815332291570f, 0.949166665944390700f, 0.948924958186195160f, - 0.948682692199895090f, - 0.948439868128009620f, 0.948196486113385580f, 0.947952546299198670f, - 0.947708048828952100f, - 0.947462993846477700f, 0.947217381495934820f, 0.946971211921810880f, - 0.946724485268921170f, - 0.946477201682408680f, 0.946229361307743820f, 0.945980964290724760f, - 0.945732010777477150f, - 0.945482500914453740f, 0.945232434848435000f, 0.944981812726528150f, - 0.944730634696167800f, - 0.944478900905115550f, 0.944226611501459810f, 0.943973766633615980f, - 0.943720366450326200f, - 0.943466411100659320f, 0.943211900734010620f, 0.942956835500102120f, - 0.942701215548981900f, - 0.942445041031024890f, 0.942188312096931770f, 0.941931028897729620f, - 0.941673191584771360f, - 0.941414800309736340f, 0.941155855224629190f, 0.940896356481780830f, - 0.940636304233847590f, - 0.940375698633811540f, 0.940114539834980280f, 0.939852827990986680f, - 0.939590563255789270f, - 0.939327745783671400f, 0.939064375729241950f, 0.938800453247434770f, - 0.938535978493508560f, - 0.938270951623047190f, 0.938005372791958840f, 0.937739242156476970f, - 0.937472559873159250f, - 0.937205326098887960f, 0.936937540990869900f, 0.936669204706636170f, - 0.936400317404042060f, - 0.936130879241267030f, 0.935860890376814640f, 0.935590350969512370f, - 0.935319261178511610f, - 0.935047621163287430f, 0.934775431083638700f, 0.934502691099687870f, - 0.934229401371880820f, - 0.933955562060986730f, 0.933681173328098410f, 0.933406235334631520f, - 0.933130748242325230f, - 0.932854712213241120f, 0.932578127409764420f, 0.932300993994602760f, - 0.932023312130786490f, - 0.931745081981668720f, 0.931466303710925090f, 0.931186977482553750f, - 0.930907103460875130f, - 0.930626681810531760f, 0.930345712696488470f, 0.930064196284032360f, - 0.929782132738772190f, - 0.929499522226638560f, 0.929216364913884040f, 0.928932660967082820f, - 0.928648410553130520f, - 0.928363613839244370f, 0.928078270992963140f, 0.927792382182146320f, - 0.927505947574975180f, - 0.927218967339951790f, 0.926931441645899130f, 0.926643370661961230f, - 0.926354754557602860f, - 0.926065593502609310f, 0.925775887667086740f, 0.925485637221461490f, - 0.925194842336480530f, - 0.924903503183210910f, 0.924611619933039970f, 0.924319192757675160f, - 0.924026221829143850f, - 0.923732707319793290f, 0.923438649402290370f, 0.923144048249621930f, - 0.922848904035094120f, - 0.922553216932332830f, 0.922256987115283030f, 0.921960214758209220f, - 0.921662900035694730f, - 0.921365043122642340f, 0.921066644194273640f, 0.920767703426128790f, - 0.920468220994067110f, - 0.920168197074266340f, 0.919867631843222950f, 0.919566525477751530f, - 0.919264878154985370f, - 0.918962690052375630f, 0.918659961347691900f, 0.918356692219021720f, - 0.918052882844770380f, - 0.917748533403661250f, 0.917443644074735220f, 0.917138215037350710f, - 0.916832246471183890f, - 0.916525738556228210f, 0.916218691472794220f, 0.915911105401509880f, - 0.915602980523320230f, - 0.915294317019487050f, 0.914985115071589310f, 0.914675374861522390f, - 0.914365096571498560f, - 0.914054280384046570f, 0.913742926482011390f, 0.913431035048554720f, - 0.913118606267154240f, - 0.912805640321603500f, 0.912492137396012650f, 0.912178097674807180f, - 0.911863521342728520f, - 0.911548408584833990f, 0.911232759586496190f, 0.910916574533403360f, - 0.910599853611558930f, - 0.910282597007281760f, 0.909964804907205660f, 0.909646477498279540f, - 0.909327614967767260f, - 0.909008217503247450f, 0.908688285292613360f, 0.908367818524072890f, - 0.908046817386148340f, - 0.907725282067676440f, 0.907403212757808110f, 0.907080609646008450f, - 0.906757472922056550f, - 0.906433802776045460f, 0.906109599398381980f, 0.905784862979786550f, - 0.905459593711293250f, - 0.905133791784249690f, 0.904807457390316540f, 0.904480590721468250f, - 0.904153191969991780f, - 0.903825261328487510f, 0.903496798989868450f, 0.903167805147360720f, - 0.902838279994502830f, - 0.902508223725145940f, 0.902177636533453620f, 0.901846518613901750f, - 0.901514870161278740f, - 0.901182691370684520f, 0.900849982437531450f, 0.900516743557543520f, - 0.900182974926756810f, - 0.899848676741518580f, 0.899513849198487980f, 0.899178492494635330f, - 0.898842606827242370f, - 0.898506192393901950f, 0.898169249392518080f, 0.897831778021305650f, - 0.897493778478790310f, - 0.897155250963808550f, 0.896816195675507300f, 0.896476612813344120f, - 0.896136502577086770f, - 0.895795865166813530f, 0.895454700782912450f, 0.895113009626081760f, - 0.894770791897329550f, - 0.894428047797973800f, 0.894084777529641990f, 0.893740981294271040f, - 0.893396659294107720f, - 0.893051811731707450f, 0.892706438809935390f, 0.892360540731965360f, - 0.892014117701280470f, - 0.891667169921672280f, 0.891319697597241390f, 0.890971700932396860f, - 0.890623180131855930f, - 0.890274135400644600f, 0.889924566944096720f, 0.889574474967854580f, - 0.889223859677868210f, - 0.888872721280395630f, 0.888521059982002260f, 0.888168875989561730f, - 0.887816169510254440f, - 0.887462940751568840f, 0.887109189921300170f, 0.886754917227550840f, - 0.886400122878730600f, - 0.886044807083555600f, 0.885688970051048960f, 0.885332611990540590f, - 0.884975733111666660f, - 0.884618333624369920f, 0.884260413738899190f, 0.883901973665809470f, - 0.883543013615961880f, - 0.883183533800523390f, 0.882823534430966620f, 0.882463015719070150f, - 0.882101977876917580f, - 0.881740421116898320f, 0.881378345651706920f, 0.881015751694342870f, - 0.880652639458111010f, - 0.880289009156621010f, 0.879924861003786860f, 0.879560195213827890f, - 0.879195012001267480f, - 0.878829311580933360f, 0.878463094167957870f, 0.878096359977777130f, - 0.877729109226131570f, - 0.877361342129065140f, 0.876993058902925890f, 0.876624259764365310f, - 0.876254944930338510f, - 0.875885114618103810f, 0.875514769045222850f, 0.875143908429560360f, - 0.874772532989284150f, - 0.874400642942864790f, 0.874028238509075740f, 0.873655319906992630f, - 0.873281887355994210f, - 0.872907941075761080f, 0.872533481286276170f, 0.872158508207824480f, - 0.871783022060993120f, - 0.871407023066670950f, 0.871030511446048260f, 0.870653487420617430f, - 0.870275951212171940f, - 0.869897903042806340f, 0.869519343134916860f, 0.869140271711200560f, - 0.868760688994655310f, - 0.868380595208579800f, 0.867999990576573510f, 0.867618875322536230f, - 0.867237249670668400f, - 0.866855113845470430f, 0.866472468071743050f, 0.866089312574586770f, - 0.865705647579402380f, - 0.865321473311889800f, 0.864936789998049020f, 0.864551597864179340f, - 0.864165897136879300f, - 0.863779688043046720f, 0.863392970809878420f, 0.863005745664870320f, - 0.862618012835816740f, - 0.862229772550811240f, 0.861841025038245330f, 0.861451770526809320f, - 0.861062009245491480f, - 0.860671741423578380f, 0.860280967290654510f, 0.859889687076602290f, - 0.859497901011601730f, - 0.859105609326130450f, 0.858712812250963520f, 0.858319510017173440f, - 0.857925702856129790f, - 0.857531390999499150f, 0.857136574679244980f, 0.856741254127627470f, - 0.856345429577203610f, - 0.855949101260826910f, 0.855552269411646860f, 0.855154934263109620f, - 0.854757096048957220f, - 0.854358755003227440f, 0.853959911360254180f, 0.853560565354666840f, - 0.853160717221390420f, - 0.852760367195645300f, 0.852359515512947090f, 0.851958162409106380f, - 0.851556308120228980f, - 0.851153952882715340f, 0.850751096933260790f, 0.850347740508854980f, - 0.849943883846782210f, - 0.849539527184620890f, 0.849134670760243630f, 0.848729314811817130f, - 0.848323459577801640f, - 0.847917105296951410f, 0.847510252208314330f, 0.847102900551231500f, - 0.846695050565337450f, - 0.846286702490559710f, 0.845877856567119000f, 0.845468513035528830f, - 0.845058672136595470f, - 0.844648334111417820f, 0.844237499201387020f, 0.843826167648186740f, - 0.843414339693792760f, - 0.843002015580472940f, 0.842589195550786710f, 0.842175879847585570f, - 0.841762068714012490f, - 0.841347762393501950f, 0.840932961129779780f, 0.840517665166862550f, - 0.840101874749058400f, - 0.839685590120966110f, 0.839268811527475230f, 0.838851539213765760f, - 0.838433773425308340f, - 0.838015514407863820f, 0.837596762407483040f, 0.837177517670507300f, - 0.836757780443567190f, - 0.836337550973583530f, 0.835916829507766360f, 0.835495616293615350f, - 0.835073911578919410f, - 0.834651715611756440f, 0.834229028640493420f, 0.833805850913786340f, - 0.833382182680579730f, - 0.832958024190106670f, 0.832533375691888680f, 0.832108237435735590f, - 0.831682609671745120f, - 0.831256492650303210f, 0.830829886622083570f, 0.830402791838047550f, - 0.829975208549443950f, - 0.829547137007808910f, 0.829118577464965980f, 0.828689530173025820f, - 0.828259995384385660f, - 0.827829973351729920f, 0.827399464328029470f, 0.826968468566541600f, - 0.826536986320809960f, - 0.826105017844664610f, 0.825672563392221390f, 0.825239623217882250f, - 0.824806197576334330f, - 0.824372286722551250f, 0.823937890911791370f, 0.823503010399598500f, - 0.823067645441801670f, - 0.822631796294514990f, 0.822195463214137170f, 0.821758646457351750f, - 0.821321346281126740f, - 0.820883562942714580f, 0.820445296699652050f, 0.820006547809759680f, - 0.819567316531142230f, - 0.819127603122188240f, 0.818687407841569680f, 0.818246730948242070f, - 0.817805572701444270f, - 0.817363933360698460f, 0.816921813185809480f, 0.816479212436865390f, - 0.816036131374236810f, - 0.815592570258576790f, 0.815148529350820830f, 0.814704008912187080f, - 0.814259009204175270f, - 0.813813530488567190f, 0.813367573027426570f, 0.812921137083098770f, - 0.812474222918210480f, - 0.812026830795669730f, 0.811578960978665890f, 0.811130613730669190f, - 0.810681789315430780f, - 0.810232487996982330f, 0.809782710039636530f, 0.809332455707985950f, - 0.808881725266903610f, - 0.808430518981542720f, 0.807978837117336310f, 0.807526679939997160f, - 0.807074047715517610f, - 0.806620940710169650f, 0.806167359190504420f, 0.805713303423352230f, - 0.805258773675822210f, - 0.804803770215302920f, 0.804348293309460780f, 0.803892343226241260f, - 0.803435920233868120f, - 0.802979024600843250f, 0.802521656595946430f, 0.802063816488235440f, - 0.801605504547046150f, - 0.801146721041991360f, 0.800687466242961610f, 0.800227740420124790f, - 0.799767543843925680f, - 0.799306876785086160f, 0.798845739514604580f, 0.798384132303756380f, - 0.797922055424093000f, - 0.797459509147442460f, 0.796996493745908750f, 0.796533009491872000f, - 0.796069056657987990f, - 0.795604635517188070f, 0.795139746342679590f, 0.794674389407944550f, - 0.794208564986740640f, - 0.793742273353100210f, 0.793275514781330630f, 0.792808289546014120f, - 0.792340597922007170f, - 0.791872440184440470f, 0.791403816608719500f, 0.790934727470523290f, - 0.790465173045804880f, - 0.789995153610791090f, 0.789524669441982190f, 0.789053720816151880f, - 0.788582308010347120f, - 0.788110431301888070f, 0.787638090968367450f, 0.787165287287651010f, - 0.786692020537876790f, - 0.786218290997455660f, 0.785744098945070360f, 0.785269444659675850f, - 0.784794328420499230f, - 0.784318750507038920f, 0.783842711199065230f, 0.783366210776619720f, - 0.782889249520015480f, - 0.782411827709836530f, 0.781933945626937630f, 0.781455603552444590f, - 0.780976801767753750f, - 0.780497540554531910f, 0.780017820194715990f, 0.779537640970513260f, - 0.779057003164400630f, - 0.778575907059125050f, 0.778094352937702790f, 0.777612341083420030f, - 0.777129871779831620f, - 0.776646945310762060f, 0.776163561960304340f, 0.775679722012820650f, - 0.775195425752941420f, - 0.774710673465565550f, 0.774225465435860680f, 0.773739801949261840f, - 0.773253683291472590f, - 0.772767109748463850f, 0.772280081606474320f, 0.771792599152010150f, - 0.771304662671844830f, - 0.770816272453018540f, 0.770327428782838890f, 0.769838131948879840f, - 0.769348382238982280f, - 0.768858179941253270f, 0.768367525344066270f, 0.767876418736060610f, - 0.767384860406141730f, - 0.766892850643480670f, 0.766400389737514230f, 0.765907477977944340f, - 0.765414115654738270f, - 0.764920303058128410f, 0.764426040478612070f, 0.763931328206951090f, - 0.763436166534172010f, - 0.762940555751565720f, 0.762444496150687210f, 0.761947988023355390f, - 0.761451031661653620f, - 0.760953627357928150f, 0.760455775404789260f, 0.759957476095110330f, - 0.759458729722028210f, - 0.758959536578942440f, 0.758459896959515430f, 0.757959811157672300f, - 0.757459279467600720f, - 0.756958302183750490f, 0.756456879600833740f, 0.755955012013824420f, - 0.755452699717958250f, - 0.754949943008732640f, 0.754446742181906440f, 0.753943097533499640f, - 0.753439009359793580f, - 0.752934477957330150f, 0.752429503622912390f, 0.751924086653603550f, - 0.751418227346727470f, - 0.750911925999867890f, 0.750405182910869330f, 0.749897998377835330f, - 0.749390372699129560f, - 0.748882306173375150f, 0.748373799099454560f, 0.747864851776509410f, - 0.747355464503940190f, - 0.746845637581406540f, 0.746335371308826320f, 0.745824665986376090f, - 0.745313521914490520f, - 0.744801939393862630f, 0.744289918725443260f, 0.743777460210440890f, - 0.743264564150321600f, - 0.742751230846809050f, 0.742237460601884000f, 0.741723253717784140f, - 0.741208610497004260f, - 0.740693531242295760f, 0.740178016256666240f, 0.739662065843380010f, - 0.739145680305957510f, - 0.738628859948174840f, 0.738111605074064260f, 0.737593915987913570f, - 0.737075792994265730f, - 0.736557236397919150f, 0.736038246503927350f, 0.735518823617598900f, - 0.734998968044496710f, - 0.734478680090438370f, 0.733957960061495940f, 0.733436808263995710f, - 0.732915225004517780f, - 0.732393210589896040f, 0.731870765327218290f, 0.731347889523825570f, - 0.730824583487312160f, - 0.730300847525525490f, 0.729776681946566090f, 0.729252087058786970f, - 0.728727063170793830f, - 0.728201610591444610f, 0.727675729629849610f, 0.727149420595371020f, - 0.726622683797622850f, - 0.726095519546471000f, 0.725567928152032300f, 0.725039909924675370f, - 0.724511465175019630f, - 0.723982594213935520f, 0.723453297352544380f, 0.722923574902217700f, - 0.722393427174577550f, - 0.721862854481496340f, 0.721331857135096290f, 0.720800435447749190f, - 0.720268589732077190f, - 0.719736320300951030f, 0.719203627467491220f, 0.718670511545067230f, - 0.718136972847297490f, - 0.717603011688049080f, 0.717068628381437480f, 0.716533823241826680f, - 0.715998596583828690f, - 0.715462948722303760f, 0.714926879972359490f, 0.714390390649351390f, - 0.713853481068882470f, - 0.713316151546802610f, 0.712778402399208980f, 0.712240233942445510f, - 0.711701646493102970f, - 0.711162640368018350f, 0.710623215884275020f, 0.710083373359202800f, - 0.709543113110376770f, - 0.709002435455618250f, 0.708461340712994160f, 0.707919829200816310f, - 0.707377901237642100f, - 0.706835557142273860f, 0.706292797233758480f, 0.705749621831387790f, - 0.705206031254697830f, - 0.704662025823468930f, 0.704117605857725430f, 0.703572771677735580f, - 0.703027523604011220f, - 0.702481861957308000f, 0.701935787058624360f, 0.701389299229202230f, - 0.700842398790526230f, - 0.700295086064323780f, 0.699747361372564990f, 0.699199225037462120f, - 0.698650677381469580f, - 0.698101718727283880f, 0.697552349397843270f, 0.697002569716327460f, - 0.696452380006157830f, - 0.695901780590996830f, 0.695350771794747800f, 0.694799353941554900f, - 0.694247527355803310f, - 0.693695292362118350f, 0.693142649285365510f, 0.692589598450650380f, - 0.692036140183318830f, - 0.691482274808955850f, 0.690928002653386280f, 0.690373324042674040f, - 0.689818239303122470f, - 0.689262748761273470f, 0.688706852743907750f, 0.688150551578044830f, - 0.687593845590942170f, - 0.687036735110095660f, 0.686479220463238950f, 0.685921301978343670f, - 0.685362979983618730f, - 0.684804254807510620f, 0.684245126778703080f, 0.683685596226116690f, - 0.683125663478908800f, - 0.682565328866473250f, 0.682004592718440830f, 0.681443455364677990f, - 0.680881917135287340f, - 0.680319978360607200f, 0.679757639371212030f, 0.679194900497911200f, - 0.678631762071749470f, - 0.678068224424006600f, 0.677504287886197430f, 0.676939952790071240f, - 0.676375219467611700f, - 0.675810088251037060f, 0.675244559472799270f, 0.674678633465584540f, - 0.674112310562312360f, - 0.673545591096136100f, 0.672978475400442090f, 0.672410963808849900f, - 0.671843056655211930f, - 0.671274754273613490f, 0.670706056998372160f, 0.670136965164037760f, - 0.669567479105392490f, - 0.668997599157450270f, 0.668427325655456820f, 0.667856658934889440f, - 0.667285599331456480f, - 0.666714147181097670f, 0.666142302819983540f, 0.665570066584515560f, - 0.664997438811325340f, - 0.664424419837275180f, 0.663851009999457340f, 0.663277209635194100f, - 0.662703019082037440f, - 0.662128438677768720f, 0.661553468760399000f, 0.660978109668168060f, - 0.660402361739545030f, - 0.659826225313227430f, 0.659249700728141490f, 0.658672788323441890f, - 0.658095488438511290f, - 0.657517801412960120f, 0.656939727586627110f, 0.656361267299578000f, - 0.655782420892106030f, - 0.655203188704731930f, 0.654623571078202680f, 0.654043568353492640f, - 0.653463180871802330f, - 0.652882408974558960f, 0.652301253003415460f, 0.651719713300251020f, - 0.651137790207170330f, - 0.650555484066503990f, 0.649972795220807530f, 0.649389724012861770f, - 0.648806270785672550f, - 0.648222435882470420f, 0.647638219646710420f, 0.647053622422071650f, - 0.646468644552457890f, - 0.645883286381996440f, 0.645297548255038380f, 0.644711430516158420f, - 0.644124933510154540f, - 0.643538057582047850f, 0.642950803077082080f, 0.642363170340724320f, - 0.641775159718663500f, - 0.641186771556811250f, 0.640598006201301030f, 0.640008863998488440f, - 0.639419345294950700f, - 0.638829450437486400f, 0.638239179773115390f, 0.637648533649078810f, - 0.637057512412838590f, - 0.636466116412077180f, 0.635874345994697720f, 0.635282201508823530f, - 0.634689683302797850f, - 0.634096791725183740f, 0.633503527124764320f, 0.632909889850541860f, - 0.632315880251737680f, - 0.631721498677792370f, 0.631126745478365340f, 0.630531621003334600f, - 0.629936125602796550f, - 0.629340259627065750f, 0.628744023426674790f, 0.628147417352374120f, - 0.627550441755131530f, - 0.626953096986132770f, 0.626355383396779990f, 0.625757301338692900f, - 0.625158851163707730f, - 0.624560033223877320f, 0.623960847871470770f, 0.623361295458973340f, - 0.622761376339086460f, - 0.622161090864726930f, 0.621560439389027270f, 0.620959422265335180f, - 0.620358039847213830f, - 0.619756292488440660f, 0.619154180543008410f, 0.618551704365123860f, - 0.617948864309208260f, - 0.617345660729896940f, 0.616742093982038830f, 0.616138164420696910f, - 0.615533872401147430f, - 0.614929218278879590f, 0.614324202409595950f, 0.613718825149211830f, - 0.613113086853854910f, - 0.612506987879865570f, 0.611900528583796070f, 0.611293709322411010f, - 0.610686530452686280f, - 0.610078992331809620f, 0.609471095317180240f, 0.608862839766408200f, - 0.608254226037314490f, - 0.607645254487930830f, 0.607035925476499760f, 0.606426239361473550f, - 0.605816196501515080f, - 0.605205797255496500f, 0.604595041982500360f, 0.603983931041818020f, - 0.603372464792950370f, - 0.602760643595607220f, 0.602148467809707320f, 0.601535937795377730f, - 0.600923053912954090f, - 0.600309816522980430f, 0.599696225986208310f, 0.599082282663597310f, - 0.598467986916314310f, - 0.597853339105733910f, 0.597238339593437530f, 0.596622988741213330f, - 0.596007286911056530f, - 0.595391234465168730f, 0.594774831765957580f, 0.594158079176036800f, - 0.593540977058226390f, - 0.592923525775551410f, 0.592305725691242400f, 0.591687577168735550f, - 0.591069080571671510f, - 0.590450236263895920f, 0.589831044609458900f, 0.589211505972615070f, - 0.588591620717822890f, - 0.587971389209745120f, 0.587350811813247660f, 0.586729888893400500f, - 0.586108620815476430f, - 0.585487007944951450f, 0.584865050647504490f, 0.584242749289016980f, - 0.583620104235572760f, - 0.582997115853457700f, 0.582373784509160220f, 0.581750110569369760f, - 0.581126094400977620f, - 0.580501736371076600f, 0.579877036846960350f, 0.579251996196123550f, - 0.578626614786261430f, - 0.578000892985269910f, 0.577374831161244880f, 0.576748429682482520f, - 0.576121688917478390f, - 0.575494609234928230f, 0.574867191003726740f, 0.574239434592967890f, - 0.573611340371944610f, - 0.572982908710148680f, 0.572354139977270030f, 0.571725034543197120f, - 0.571095592778016690f, - 0.570465815052012990f, 0.569835701735668110f, 0.569205253199661200f, - 0.568574469814869250f, - 0.567943351952365670f, 0.567311899983420800f, 0.566680114279501710f, - 0.566047995212271560f, - 0.565415543153589770f, 0.564782758475511400f, 0.564149641550287680f, - 0.563516192750364910f, - 0.562882412448384550f, 0.562248301017183150f, 0.561613858829792420f, - 0.560979086259438260f, - 0.560343983679540860f, 0.559708551463714790f, 0.559072789985768480f, - 0.558436699619704100f, - 0.557800280739717100f, 0.557163533720196340f, 0.556526458935723720f, - 0.555889056761073920f, - 0.555251327571214090f, 0.554613271741304040f, 0.553974889646695610f, - 0.553336181662932410f, - 0.552697148165749770f, 0.552057789531074980f, 0.551418106135026060f, - 0.550778098353912230f, - 0.550137766564233630f, 0.549497111142680960f, 0.548856132466135290f, - 0.548214830911667780f, - 0.547573206856539870f, 0.546931260678202190f, 0.546288992754295210f, - 0.545646403462648590f, - 0.545003493181281160f, 0.544360262288400400f, 0.543716711162402390f, - 0.543072840181871850f, - 0.542428649725581360f, 0.541784140172491660f, 0.541139311901750910f, - 0.540494165292695230f, - 0.539848700724847700f, 0.539202918577918240f, 0.538556819231804210f, - 0.537910403066588990f, - 0.537263670462542530f, 0.536616621800121150f, 0.535969257459966710f, - 0.535321577822907010f, - 0.534673583269955510f, 0.534025274182310380f, 0.533376650941355560f, - 0.532727713928658810f, - 0.532078463525973540f, 0.531428900115236910f, 0.530779024078570250f, - 0.530128835798278850f, - 0.529478335656852090f, 0.528827524036961980f, 0.528176401321464370f, - 0.527524967893398200f, - 0.526873224135984700f, 0.526221170432628170f, 0.525568807166914680f, - 0.524916134722612890f, - 0.524263153483673470f, 0.523609863834228030f, 0.522956266158590140f, - 0.522302360841254700f, - 0.521648148266897090f, 0.520993628820373810f, 0.520338802886721960f, - 0.519683670851158520f, - 0.519028233099080970f, 0.518372490016066220f, 0.517716441987871150f, - 0.517060089400432130f, - 0.516403432639863990f, 0.515746472092461380f, 0.515089208144697270f, - 0.514431641183222930f, - 0.513773771594868030f, 0.513115599766640560f, 0.512457126085725800f, - 0.511798350939487000f, - 0.511139274715464390f, 0.510479897801375700f, 0.509820220585115560f, - 0.509160243454754750f, - 0.508499966798540810f, 0.507839391004897940f, 0.507178516462425290f, - 0.506517343559898530f, - 0.505855872686268860f, 0.505194104230662240f, 0.504532038582380380f, - 0.503869676130898950f, - 0.503207017265869030f, 0.502544062377115800f, 0.501880811854638400f, - 0.501217266088609950f, - 0.500553425469377640f, 0.499889290387461380f, 0.499224861233555030f, - 0.498560138398525200f, - 0.497895122273410930f, 0.497229813249424340f, 0.496564211717949340f, - 0.495898318070542240f, - 0.495232132698931350f, 0.494565655995016010f, 0.493898888350867430f, - 0.493231830158728070f, - 0.492564481811010650f, 0.491896843700299240f, 0.491228916219348330f, - 0.490560699761082080f, - 0.489892194718595300f, 0.489223401485152030f, 0.488554320454186230f, - 0.487884952019301210f, - 0.487215296574268820f, 0.486545354513030270f, 0.485875126229695420f, - 0.485204612118541880f, - 0.484533812574016120f, 0.483862727990732320f, 0.483191358763471910f, - 0.482519705287184520f, - 0.481847767956986080f, 0.481175547168160360f, 0.480503043316157670f, - 0.479830256796594250f, - 0.479157188005253310f, 0.478483837338084080f, 0.477810205191201040f, - 0.477136291960884750f, - 0.476462098043581310f, 0.475787623835901120f, 0.475112869734620470f, - 0.474437836136679340f, - 0.473762523439182850f, 0.473086932039400220f, 0.472411062334764100f, - 0.471734914722871430f, - 0.471058489601482610f, 0.470381787368520710f, 0.469704808422072460f, - 0.469027553160387240f, - 0.468350021981876530f, 0.467672215285114710f, 0.466994133468838110f, - 0.466315776931944480f, - 0.465637146073493770f, 0.464958241292706740f, 0.464279062988965760f, - 0.463599611561814120f, - 0.462919887410955130f, 0.462239890936253280f, 0.461559622537733190f, - 0.460879082615578690f, - 0.460198271570134270f, 0.459517189801903590f, 0.458835837711549120f, - 0.458154215699893230f, - 0.457472324167916110f, 0.456790163516757220f, 0.456107734147714220f, - 0.455425036462242420f, - 0.454742070861955450f, 0.454058837748624540f, 0.453375337524177750f, - 0.452691570590700860f, - 0.452007537350436530f, 0.451323238205783520f, 0.450638673559297760f, - 0.449953843813690580f, - 0.449268749371829920f, 0.448583390636739300f, 0.447897768011597360f, - 0.447211881899738260f, - 0.446525732704651400f, 0.445839320829980350f, 0.445152646679523590f, - 0.444465710657234110f, - 0.443778513167218280f, 0.443091054613736990f, 0.442403335401204130f, - 0.441715355934187310f, - 0.441027116617407340f, 0.440338617855737300f, 0.439649860054203420f, - 0.438960843617984430f, - 0.438271568952410480f, 0.437582036462964340f, 0.436892246555280470f, - 0.436202199635143950f, - 0.435511896108492170f, 0.434821336381412350f, 0.434130520860143310f, - 0.433439449951074200f, - 0.432748124060743760f, 0.432056543595841450f, 0.431364708963206440f, - 0.430672620569826860f, - 0.429980278822840570f, 0.429287684129534720f, 0.428594836897344400f, - 0.427901737533854240f, - 0.427208386446796370f, 0.426514784044051520f, 0.425820930733648350f, - 0.425126826923762410f, - 0.424432473022717420f, 0.423737869438983950f, 0.423043016581179100f, - 0.422347914858067000f, - 0.421652564678558380f, 0.420956966451709440f, 0.420261120586723050f, - 0.419565027492946940f, - 0.418868687579875110f, 0.418172101257146430f, 0.417475268934544340f, - 0.416778191021997590f, - 0.416080867929579320f, 0.415383300067506290f, 0.414685487846140010f, - 0.413987431675985510f, - 0.413289131967690960f, 0.412590589132048380f, 0.411891803579992220f, - 0.411192775722600160f, - 0.410493505971092520f, 0.409793994736831200f, 0.409094242431320920f, - 0.408394249466208110f, - 0.407694016253280170f, 0.406993543204466460f, 0.406292830731837470f, - 0.405591879247603870f, - 0.404890689164117750f, 0.404189260893870750f, 0.403487594849495310f, - 0.402785691443763640f, - 0.402083551089587040f, 0.401381174200016790f, 0.400678561188243350f, - 0.399975712467595390f, - 0.399272628451540930f, 0.398569309553686360f, 0.397865756187775750f, - 0.397161968767691720f, - 0.396457947707453960f, 0.395753693421220080f, 0.395049206323284880f, - 0.394344486828079650f, - 0.393639535350172880f, 0.392934352304269600f, 0.392228938105210370f, - 0.391523293167972350f, - 0.390817417907668610f, 0.390111312739546910f, 0.389404978078991100f, - 0.388698414341519250f, - 0.387991621942784910f, 0.387284601298575890f, 0.386577352824813980f, - 0.385869876937555310f, - 0.385162174052989970f, 0.384454244587440870f, 0.383746088957365010f, - 0.383037707579352130f, - 0.382329100870124510f, 0.381620269246537520f, 0.380911213125578130f, - 0.380201932924366050f, - 0.379492429060152740f, 0.378782701950320600f, 0.378072752012383990f, - 0.377362579663988450f, - 0.376652185322909620f, 0.375941569407054420f, 0.375230732334460030f, - 0.374519674523293210f, - 0.373808396391851370f, 0.373096898358560690f, 0.372385180841977360f, - 0.371673244260786630f, - 0.370961089033802040f, 0.370248715579966360f, 0.369536124318350760f, - 0.368823315668153960f, - 0.368110290048703050f, 0.367397047879452820f, 0.366683589579984930f, - 0.365969915570008910f, - 0.365256026269360380f, 0.364541922098002180f, 0.363827603476023610f, - 0.363113070823639530f, - 0.362398324561191310f, 0.361683365109145950f, 0.360968192888095290f, - 0.360252808318756830f, - 0.359537211821973180f, 0.358821403818710860f, 0.358105384730061760f, - 0.357389154977241000f, - 0.356672714981588260f, 0.355956065164567010f, 0.355239205947763370f, - 0.354522137752887430f, - 0.353804861001772160f, 0.353087376116372530f, 0.352369683518766630f, - 0.351651783631154680f, - 0.350933676875858360f, 0.350215363675321740f, 0.349496844452109600f, - 0.348778119628908420f, - 0.348059189628525780f, 0.347340054873889190f, 0.346620715788047320f, - 0.345901172794169100f, - 0.345181426315542610f, 0.344461476775576480f, 0.343741324597798600f, - 0.343020970205855540f, - 0.342300414023513690f, 0.341579656474657210f, 0.340858697983289440f, - 0.340137538973531880f, - 0.339416179869623410f, 0.338694621095921190f, 0.337972863076899830f, - 0.337250906237150650f, - 0.336528751001382350f, 0.335806397794420560f, 0.335083847041206580f, - 0.334361099166798900f, - 0.333638154596370920f, 0.332915013755212650f, 0.332191677068729320f, - 0.331468144962440920f, - 0.330744417861982890f, 0.330020496193105530f, 0.329296380381672800f, - 0.328572070853663690f, - 0.327847568035170960f, 0.327122872352400510f, 0.326397984231672660f, - 0.325672904099419900f, - 0.324947632382188430f, 0.324222169506637130f, 0.323496515899536760f, - 0.322770671987770710f, - 0.322044638198334620f, 0.321318414958334910f, 0.320592002694990330f, - 0.319865401835630610f, - 0.319138612807695900f, 0.318411636038737960f, 0.317684471956418020f, - 0.316957120988508150f, - 0.316229583562890490f, 0.315501860107556040f, 0.314773951050606070f, - 0.314045856820250820f, - 0.313317577844809070f, 0.312589114552708660f, 0.311860467372486130f, - 0.311131636732785270f, - 0.310402623062358880f, 0.309673426790066490f, 0.308944048344875710f, - 0.308214488155861220f, - 0.307484746652204160f, 0.306754824263192780f, 0.306024721418221900f, - 0.305294438546791720f, - 0.304563976078509050f, 0.303833334443086470f, 0.303102514070341060f, - 0.302371515390196130f, - 0.301640338832678880f, 0.300908984827921890f, 0.300177453806162120f, - 0.299445746197739950f, - 0.298713862433100390f, 0.297981802942791920f, 0.297249568157465890f, - 0.296517158507877410f, - 0.295784574424884370f, 0.295051816339446720f, 0.294318884682627570f, - 0.293585779885591310f, - 0.292852502379604810f, 0.292119052596036540f, 0.291385430966355720f, - 0.290651637922133220f, - 0.289917673895040860f, 0.289183539316850310f, 0.288449234619434170f, - 0.287714760234765280f, - 0.286980116594915570f, 0.286245304132057120f, 0.285510323278461380f, - 0.284775174466498300f, - 0.284039858128637360f, 0.283304374697445790f, 0.282568724605589740f, - 0.281832908285833460f, - 0.281096926171038320f, 0.280360778694163810f, 0.279624466288266700f, - 0.278887989386500280f, - 0.278151348422115090f, 0.277414543828458200f, 0.276677576038972420f, - 0.275940445487197320f, - 0.275203152606767370f, 0.274465697831413220f, 0.273728081594960650f, - 0.272990304331329980f, - 0.272252366474536660f, 0.271514268458690810f, 0.270776010717996010f, - 0.270037593686750510f, - 0.269299017799346230f, 0.268560283490267890f, 0.267821391194094320f, - 0.267082341345496350f, - 0.266343134379238180f, 0.265603770730176440f, 0.264864250833259320f, - 0.264124575123527490f, - 0.263384744036113390f, 0.262644758006240100f, 0.261904617469222560f, - 0.261164322860466590f, - 0.260423874615468010f, 0.259683273169813930f, 0.258942518959180580f, - 0.258201612419334870f, - 0.257460553986133210f, 0.256719344095520720f, 0.255977983183532380f, - 0.255236471686291820f, - 0.254494810040010790f, 0.253752998680989940f, 0.253011038045617980f, - 0.252268928570370810f, - 0.251526670691812780f, 0.250784264846594550f, 0.250041711471454650f, - 0.249299011003218300f, - 0.248556163878796620f, 0.247813170535187620f, 0.247070031409475370f, - 0.246326746938829060f, - 0.245583317560504000f, 0.244839743711840750f, 0.244096025830264210f, - 0.243352164353284880f, - 0.242608159718496890f, 0.241864012363579210f, 0.241119722726294730f, - 0.240375291244489500f, - 0.239630718356093560f, 0.238886004499120170f, 0.238141150111664870f, - 0.237396155631906550f, - 0.236651021498106460f, 0.235905748148607370f, 0.235160336021834860f, - 0.234414785556295250f, - 0.233669097190576820f, 0.232923271363349120f, 0.232177308513361770f, - 0.231431209079445730f, - 0.230684973500512310f, 0.229938602215552260f, 0.229192095663636740f, - 0.228445454283916550f, - 0.227698678515621170f, 0.226951768798059980f, 0.226204725570620270f, - 0.225457549272768540f, - 0.224710240344049570f, 0.223962799224085520f, 0.223215226352576960f, - 0.222467522169301990f, - 0.221719687114115240f, 0.220971721626949060f, 0.220223626147812460f, - 0.219475401116790340f, - 0.218727046974044600f, 0.217978564159812290f, 0.217229953114406790f, - 0.216481214278216900f, - 0.215732348091705940f, 0.214983354995412820f, 0.214234235429951100f, - 0.213484989836008080f, - 0.212735618654345870f, 0.211986122325800410f, 0.211236501291280710f, - 0.210486755991769890f, - 0.209736886868323370f, 0.208986894362070070f, 0.208236778914211470f, - 0.207486540966020700f, - 0.206736180958843660f, 0.205985699334098050f, 0.205235096533272380f, - 0.204484372997927180f, - 0.203733529169694010f, 0.202982565490274460f, 0.202231482401441620f, - 0.201480280345037820f, - 0.200728959762976140f, 0.199977521097239290f, 0.199225964789878890f, - 0.198474291283016360f, - 0.197722501018842030f, 0.196970594439614370f, 0.196218571987660850f, - 0.195466434105377090f, - 0.194714181235225990f, 0.193961813819739010f, 0.193209332301514080f, - 0.192456737123216840f, - 0.191704028727579940f, 0.190951207557401860f, 0.190198274055548120f, - 0.189445228664950340f, - 0.188692071828605260f, 0.187938803989575850f, 0.187185425590990440f, - 0.186431937076041640f, - 0.185678338887987790f, 0.184924631470150870f, 0.184170815265917720f, - 0.183416890718739230f, - 0.182662858272129360f, 0.181908718369666160f, 0.181154471454990920f, - 0.180400117971807270f, - 0.179645658363882100f, 0.178891093075044830f, 0.178136422549186320f, - 0.177381647230260200f, - 0.176626767562280960f, 0.175871783989325040f, 0.175116696955530060f, - 0.174361506905093830f, - 0.173606214282275410f, 0.172850819531394200f, 0.172095323096829040f, - 0.171339725423019260f, - 0.170584026954463700f, 0.169828228135719880f, 0.169072329411405180f, - 0.168316331226194910f, - 0.167560234024823590f, 0.166804038252083870f, 0.166047744352825850f, - 0.165291352771957970f, - 0.164534863954446110f, 0.163778278345312690f, 0.163021596389637810f, - 0.162264818532558110f, - 0.161507945219266150f, 0.160750976895011390f, 0.159993914005098350f, - 0.159236756994887850f, - 0.158479506309796100f, 0.157722162395293690f, 0.156964725696906750f, - 0.156207196660216040f, - 0.155449575730855880f, 0.154691863354515400f, 0.153934059976937460f, - 0.153176166043917870f, - 0.152418182001306500f, 0.151660108295005400f, 0.150901945370970040f, - 0.150143693675208330f, - 0.149385353653779810f, 0.148626925752796540f, 0.147868410418422360f, - 0.147109808096871850f, - 0.146351119234411440f, 0.145592344277358450f, 0.144833483672080240f, - 0.144074537864995330f, - 0.143315507302571590f, 0.142556392431327340f, 0.141797193697830530f, - 0.141037911548697770f, - 0.140278546430595420f, 0.139519098790238600f, 0.138759569074390380f, - 0.137999957729862760f, - 0.137240265203515700f, 0.136480491942256310f, 0.135720638393040080f, - 0.134960705002868830f, - 0.134200692218792020f, 0.133440600487905820f, 0.132680430257352130f, - 0.131920181974319760f, - 0.131159856086043410f, 0.130399453039802740f, 0.129638973282923540f, - 0.128878417262776660f, - 0.128117785426777150f, 0.127357078222385570f, 0.126596296097105960f, - 0.125835439498487020f, - 0.125074508874121300f, 0.124313504671644300f, 0.123552427338735370f, - 0.122791277323116900f, - 0.122030055072553410f, 0.121268761034852550f, 0.120507395657864240f, - 0.119745959389479630f, - 0.118984452677632520f, 0.118222875970297250f, 0.117461229715489990f, - 0.116699514361267840f, - 0.115937730355727850f, 0.115175878147008180f, 0.114413958183287050f, - 0.113651970912781920f, - 0.112889916783750470f, 0.112127796244489750f, 0.111365609743335190f, - 0.110603357728661910f, - 0.109841040648882680f, 0.109078658952449240f, 0.108316213087851300f, - 0.107553703503615710f, - 0.106791130648307380f, 0.106028494970528530f, 0.105265796918917650f, - 0.104503036942150550f, - 0.103740215488939480f, 0.102977333008032250f, 0.102214389948213370f, - 0.101451386758302160f, - 0.100688323887153970f, 0.099925201783659226f, 0.099162020896742573f, - 0.098398781675363881f, - 0.097635484568517339f, 0.096872130025230527f, 0.096108718494565468f, - 0.095345250425617742f, - 0.094581726267515473f, 0.093818146469420494f, 0.093054511480527333f, - 0.092290821750062355f, - 0.091527077727284981f, 0.090763279861485704f, 0.089999428601987341f, - 0.089235524398144139f, - 0.088471567699340822f, 0.087707558954993645f, 0.086943498614549489f, - 0.086179387127484922f, - 0.085415224943307277f, 0.084651012511553700f, 0.083886750281790226f, - 0.083122438703613077f, - 0.082358078226646619f, 0.081593669300544638f, 0.080829212374989468f, - 0.080064707899690932f, - 0.079300156324387569f, 0.078535558098845590f, 0.077770913672857989f, - 0.077006223496245585f, - 0.076241488018856149f, 0.075476707690563416f, 0.074711882961268378f, - 0.073947014280897269f, - 0.073182102099402888f, 0.072417146866763538f, 0.071652149032982254f, - 0.070887109048087787f, - 0.070122027362133646f, 0.069356904425197236f, 0.068591740687380900f, - 0.067826536598810966f, - 0.067061292609636836f, 0.066296009170032283f, 0.065530686730193397f, - 0.064765325740339871f, - 0.063999926650714078f, 0.063234489911580136f, 0.062469015973224969f, - 0.061703505285957416f, - 0.060937958300107238f, 0.060172375466026218f, 0.059406757234087247f, - 0.058641104054683348f, - 0.057875416378229017f, 0.057109694655158132f, 0.056343939335925283f, - 0.055578150871004817f, - 0.054812329710889909f, 0.054046476306093640f, 0.053280591107148056f, - 0.052514674564603257f, - 0.051748727129028414f, 0.050982749251010900f, 0.050216741381155325f, - 0.049450703970084824f, - 0.048684637468439020f, 0.047918542326875327f, 0.047152418996068000f, - 0.046386267926707213f, - 0.045620089569500123f, 0.044853884375169933f, 0.044087652794454979f, - 0.043321395278109784f, - 0.042555112276904117f, 0.041788804241622082f, 0.041022471623063397f, - 0.040256114872041358f, - 0.039489734439384118f, 0.038723330775933762f, 0.037956904332545366f, - 0.037190455560088091f, - 0.036423984909444228f, 0.035657492831508264f, 0.034890979777187955f, - 0.034124446197403423f, - 0.033357892543086159f, 0.032591319265180385f, 0.031824726814640963f, - 0.031058115642434700f, - 0.030291486199539423f, 0.029524838936943035f, 0.028758174305644590f, - 0.027991492756653365f, - 0.027224794740987910f, 0.026458080709677145f, 0.025691351113759395f, - 0.024924606404281485f, - 0.024157847032300020f, 0.023391073448879338f, 0.022624286105092803f, - 0.021857485452021874f, - 0.021090671940755180f, 0.020323846022389572f, 0.019557008148029204f, - 0.018790158768784596f, - 0.018023298335773701f, 0.017256427300120978f, 0.016489546112956454f, - 0.015722655225417017f, - 0.014955755088644378f, 0.014188846153786343f, 0.013421928871995907f, - 0.012655003694430301f, - 0.011888071072252072f, 0.011121131456628141f, 0.010354185298728884f, - 0.009587233049729183f, - 0.008820275160807512f, 0.008053312083144991f, 0.007286344267926684f, - 0.006519372166339549f, - 0.005752396229573737f, 0.004985416908821652f, 0.004218434655277024f, - 0.003451449920135975f, - 0.002684463154596083f, 0.001917474809855460f, 0.001150485337113809f, - 0.000383495187571497f -}; + 0.999999926465717890f, 0.999999338191525530f, 0.999998161643486980f, + 0.999996396822294350f, 0.999994043728985820f, 0.999991102364945590f, + 0.999987572731904080f, 0.999983454831937730f, 0.999978748667468830f, + 0.999973454241265940f, 0.999967571556443780f, 0.999961100616462820f, + 0.999954041425129780f, 0.999946393986597460f, 0.999938158305364590f, + 0.999929334386276070f, 0.999919922234522750f, 0.999909921855641540f, + 0.999899333255515390f, 0.999888156440373320f, 0.999876391416790410f, + 0.999864038191687680f, 0.999851096772332190f, 0.999837567166337090f, + 0.999823449381661570f, 0.999808743426610520f, 0.999793449309835270f, + 0.999777567040332940f, 0.999761096627446610f, 0.999744038080865430f, + 0.999726391410624470f, 0.999708156627104880f, 0.999689333741033640f, + 0.999669922763483760f, 0.999649923705874240f, 0.999629336579970110f, + 0.999608161397882110f, 0.999586398172067070f, 0.999564046915327740f, + 0.999541107640812940f, 0.999517580362016990f, 0.999493465092780590f, + 0.999468761847290050f, 0.999443470640077770f, 0.999417591486021720f, + 0.999391124400346050f, 0.999364069398620550f, 0.999336426496761240f, + 0.999308195711029470f, 0.999279377058032710f, 0.999249970554724420f, + 0.999219976218403530f, 0.999189394066714920f, 0.999158224117649430f, + 0.999126466389543390f, 0.999094120901079070f, 0.999061187671284600f, + 0.999027666719533690f, 0.998993558065545680f, 0.998958861729386080f, + 0.998923577731465780f, 0.998887706092541290f, 0.998851246833715180f, + 0.998814199976435390f, 0.998776565542495610f, 0.998738343554035230f, + 0.998699534033539280f, 0.998660137003838490f, 0.998620152488108870f, + 0.998579580509872500f, 0.998538421092996730f, 0.998496674261694640f, + 0.998454340040524800f, 0.998411418454391300f, 0.998367909528543820f, + 0.998323813288577560f, 0.998279129760433200f, 0.998233858970396850f, + 0.998188000945100300f, 0.998141555711520520f, 0.998094523296980010f, + 0.998046903729146840f, 0.997998697036034390f, 0.997949903246001190f, + 0.997900522387751620f, 0.997850554490335110f, 0.997799999583146470f, + 0.997748857695925690f, 0.997697128858758500f, 0.997644813102075420f, + 0.997591910456652630f, 0.997538420953611340f, 0.997484344624417930f, + 0.997429681500884180f, 0.997374431615167150f, 0.997318594999768600f, + 0.997262171687536170f, 0.997205161711661850f, 0.997147565105683480f, + 0.997089381903483400f, 0.997030612139289450f, 0.996971255847674320f, + 0.996911313063555740f, 0.996850783822196610f, 0.996789668159204560f, + 0.996727966110532490f, 0.996665677712478160f, 0.996602803001684130f, + 0.996539342015137940f, 0.996475294790172160f, 0.996410661364464100f, + 0.996345441776035900f, 0.996279636063254650f, 0.996213244264832040f, + 0.996146266419824620f, 0.996078702567633980f, 0.996010552748005870f, + 0.995941817001031350f, 0.995872495367145730f, 0.995802587887129160f, + 0.995732094602106430f, 0.995661015553546910f, 0.995589350783264600f, + 0.995517100333418110f, 0.995444264246510340f, 0.995370842565388990f, + 0.995296835333246090f, 0.995222242593618360f, 0.995147064390386470f, + 0.995071300767776170f, 0.994994951770357020f, 0.994918017443043200f, + 0.994840497831093180f, 0.994762392980109930f, 0.994683702936040250f, + 0.994604427745175660f, 0.994524567454151740f, 0.994444122109948040f, + 0.994363091759888570f, 0.994281476451641550f, 0.994199276233218910f, + 0.994116491152977070f, 0.994033121259616400f, 0.993949166602181130f, + 0.993864627230059750f, 0.993779503192984580f, 0.993693794541031790f, + 0.993607501324621610f, 0.993520623594518090f, 0.993433161401829360f, + 0.993345114798006910f, 0.993256483834846440f, 0.993167268564487230f, + 0.993077469039412300f, 0.992987085312448390f, 0.992896117436765980f, + 0.992804565465879140f, 0.992712429453645460f, 0.992619709454266140f, + 0.992526405522286100f, 0.992432517712593660f, 0.992338046080420420f, + 0.992242990681341700f, 0.992147351571276090f, 0.992051128806485720f, + 0.991954322443575950f, 0.991856932539495470f, 0.991758959151536110f, + 0.991660402337333210f, 0.991561262154865290f, 0.991461538662453790f, + 0.991361231918763460f, 0.991260341982802440f, 0.991158868913921350f, + 0.991056812771814340f, 0.990954173616518500f, 0.990850951508413620f, + 0.990747146508222710f, 0.990642758677011570f, 0.990537788076188750f, + 0.990432234767505970f, 0.990326098813057330f, 0.990219380275280000f, + 0.990112079216953770f, 0.990004195701200910f, 0.989895729791486660f, + 0.989786681551618640f, 0.989677051045747210f, 0.989566838338365120f, + 0.989456043494307710f, 0.989344666578752640f, 0.989232707657220050f, + 0.989120166795572690f, 0.989007044060015270f, 0.988893339517095130f, + 0.988779053233701520f, 0.988664185277066230f, 0.988548735714763200f, + 0.988432704614708340f, 0.988316092045159690f, 0.988198898074717610f, + 0.988081122772324070f, 0.987962766207263420f, 0.987843828449161740f, + 0.987724309567986960f, 0.987604209634049160f, 0.987483528717999710f, + 0.987362266890832400f, 0.987240424223882250f, 0.987118000788826280f, + 0.986994996657682980f, 0.986871411902812470f, 0.986747246596916590f, + 0.986622500813038480f, 0.986497174624562880f, 0.986371268105216030f, + 0.986244781329065460f, 0.986117714370520090f, 0.985990067304330140f, + 0.985861840205586980f, 0.985733033149723490f, 0.985603646212513400f, + 0.985473679470071810f, 0.985343132998854790f, 0.985212006875659350f, + 0.985080301177623800f, 0.984948015982227030f, 0.984815151367289140f, + 0.984681707410970940f, 0.984547684191773960f, 0.984413081788540700f, + 0.984277900280454370f, 0.984142139747038570f, 0.984005800268157870f, + 0.983868881924017220f, 0.983731384795162090f, 0.983593308962478650f, + 0.983454654507193270f, 0.983315421510872810f, 0.983175610055424420f, + 0.983035220223095640f, 0.982894252096474070f, 0.982752705758487830f, + 0.982610581292404750f, 0.982467878781833170f, 0.982324598310721280f, + 0.982180739963357090f, 0.982036303824369020f, 0.981891289978725100f, + 0.981745698511732990f, 0.981599529509040720f, 0.981452783056635520f, + 0.981305459240844670f, 0.981157558148334830f, 0.981009079866112630f, + 0.980860024481523870f, 0.980710392082253970f, 0.980560182756327840f, + 0.980409396592109910f, 0.980258033678303550f, 0.980106094103951770f, + 0.979953577958436740f, 0.979800485331479790f, 0.979646816313141210f, + 0.979492570993820810f, 0.979337749464256780f, 0.979182351815526930f, + 0.979026378139047580f, 0.978869828526574120f, 0.978712703070200420f, + 0.978555001862359550f, 0.978396724995823090f, 0.978237872563701090f, + 0.978078444659442380f, 0.977918441376834370f, 0.977757862810002760f, + 0.977596709053411890f, 0.977434980201864260f, 0.977272676350500860f, + 0.977109797594800880f, 0.976946344030581670f, 0.976782315753998650f, + 0.976617712861545640f, 0.976452535450054060f, 0.976286783616693630f, + 0.976120457458971910f, 0.975953557074734300f, 0.975786082562163930f, + 0.975618034019781750f, 0.975449411546446380f, 0.975280215241354220f, + 0.975110445204038890f, 0.974940101534371830f, 0.974769184332561770f, + 0.974597693699155050f, 0.974425629735034990f, 0.974252992541422500f, + 0.974079782219875680f, 0.973905998872289570f, 0.973731642600896400f, + 0.973556713508265560f, 0.973381211697303290f, 0.973205137271252800f, + 0.973028490333694210f, 0.972851270988544180f, 0.972673479340056430f, + 0.972495115492821190f, 0.972316179551765300f, 0.972136671622152230f, + 0.971956591809581720f, 0.971775940219990140f, 0.971594716959650160f, + 0.971412922135170940f, 0.971230555853497380f, 0.971047618221911100f, + 0.970864109348029470f, 0.970680029339806130f, 0.970495378305530560f, + 0.970310156353828110f, 0.970124363593660280f, 0.969938000134323960f, + 0.969751066085452140f, 0.969563561557013180f, 0.969375486659311280f, + 0.969186841502985950f, 0.968997626199012420f, 0.968807840858700970f, + 0.968617485593697540f, 0.968426560515983190f, 0.968235065737874320f, + 0.968043001372022260f, 0.967850367531413620f, 0.967657164329369880f, + 0.967463391879547550f, 0.967269050295937790f, 0.967074139692867040f, + 0.966878660184995910f, 0.966682611887320080f, 0.966485994915169840f, + 0.966288809384209690f, 0.966091055410438830f, 0.965892733110190860f, + 0.965693842600133690f, 0.965494383997269500f, 0.965294357418934660f, + 0.965093762982799590f, 0.964892600806868890f, 0.964690871009481030f, + 0.964488573709308410f, 0.964285709025357480f, 0.964082277076968140f, + 0.963878277983814200f, 0.963673711865903230f, 0.963468578843575950f, + 0.963262879037507070f, 0.963056612568704340f, 0.962849779558509030f, + 0.962642380128595710f, 0.962434414400972100f, 0.962225882497979020f, + 0.962016784542290560f, 0.961807120656913540f, 0.961596890965187860f, + 0.961386095590786250f, 0.961174734657714080f, 0.960962808290309780f, + 0.960750316613243950f, 0.960537259751520050f, 0.960323637830473920f, + 0.960109450975773940f, 0.959894699313420530f, 0.959679382969746750f, + 0.959463502071417510f, 0.959247056745430090f, 0.959030047119113660f, + 0.958812473320129310f, 0.958594335476470220f, 0.958375633716461170f, + 0.958156368168758820f, 0.957936538962351420f, 0.957716146226558870f, + 0.957495190091032570f, 0.957273670685755200f, 0.957051588141040970f, + 0.956828942587535370f, 0.956605734156215080f, 0.956381962978387730f, + 0.956157629185692140f, 0.955932732910098280f, 0.955707274283906560f, + 0.955481253439748770f, 0.955254670510586990f, 0.955027525629714160f, + 0.954799818930753720f, 0.954571550547659630f, 0.954342720614716480f, + 0.954113329266538800f, 0.953883376638071770f, 0.953652862864590500f, + 0.953421788081700310f, 0.953190152425336670f, 0.952957956031764700f, + 0.952725199037579570f, 0.952491881579706320f, 0.952258003795399600f, + 0.952023565822243570f, 0.951788567798152130f, 0.951553009861368590f, + 0.951316892150465550f, 0.951080214804345010f, 0.950842977962238160f, + 0.950605181763705340f, 0.950366826348635780f, 0.950127911857248100f, + 0.949888438430089300f, 0.949648406208035480f, 0.949407815332291570f, + 0.949166665944390700f, 0.948924958186195160f, 0.948682692199895090f, + 0.948439868128009620f, 0.948196486113385580f, 0.947952546299198670f, + 0.947708048828952100f, 0.947462993846477700f, 0.947217381495934820f, + 0.946971211921810880f, 0.946724485268921170f, 0.946477201682408680f, + 0.946229361307743820f, 0.945980964290724760f, 0.945732010777477150f, + 0.945482500914453740f, 0.945232434848435000f, 0.944981812726528150f, + 0.944730634696167800f, 0.944478900905115550f, 0.944226611501459810f, + 0.943973766633615980f, 0.943720366450326200f, 0.943466411100659320f, + 0.943211900734010620f, 0.942956835500102120f, 0.942701215548981900f, + 0.942445041031024890f, 0.942188312096931770f, 0.941931028897729620f, + 0.941673191584771360f, 0.941414800309736340f, 0.941155855224629190f, + 0.940896356481780830f, 0.940636304233847590f, 0.940375698633811540f, + 0.940114539834980280f, 0.939852827990986680f, 0.939590563255789270f, + 0.939327745783671400f, 0.939064375729241950f, 0.938800453247434770f, + 0.938535978493508560f, 0.938270951623047190f, 0.938005372791958840f, + 0.937739242156476970f, 0.937472559873159250f, 0.937205326098887960f, + 0.936937540990869900f, 0.936669204706636170f, 0.936400317404042060f, + 0.936130879241267030f, 0.935860890376814640f, 0.935590350969512370f, + 0.935319261178511610f, 0.935047621163287430f, 0.934775431083638700f, + 0.934502691099687870f, 0.934229401371880820f, 0.933955562060986730f, + 0.933681173328098410f, 0.933406235334631520f, 0.933130748242325230f, + 0.932854712213241120f, 0.932578127409764420f, 0.932300993994602760f, + 0.932023312130786490f, 0.931745081981668720f, 0.931466303710925090f, + 0.931186977482553750f, 0.930907103460875130f, 0.930626681810531760f, + 0.930345712696488470f, 0.930064196284032360f, 0.929782132738772190f, + 0.929499522226638560f, 0.929216364913884040f, 0.928932660967082820f, + 0.928648410553130520f, 0.928363613839244370f, 0.928078270992963140f, + 0.927792382182146320f, 0.927505947574975180f, 0.927218967339951790f, + 0.926931441645899130f, 0.926643370661961230f, 0.926354754557602860f, + 0.926065593502609310f, 0.925775887667086740f, 0.925485637221461490f, + 0.925194842336480530f, 0.924903503183210910f, 0.924611619933039970f, + 0.924319192757675160f, 0.924026221829143850f, 0.923732707319793290f, + 0.923438649402290370f, 0.923144048249621930f, 0.922848904035094120f, + 0.922553216932332830f, 0.922256987115283030f, 0.921960214758209220f, + 0.921662900035694730f, 0.921365043122642340f, 0.921066644194273640f, + 0.920767703426128790f, 0.920468220994067110f, 0.920168197074266340f, + 0.919867631843222950f, 0.919566525477751530f, 0.919264878154985370f, + 0.918962690052375630f, 0.918659961347691900f, 0.918356692219021720f, + 0.918052882844770380f, 0.917748533403661250f, 0.917443644074735220f, + 0.917138215037350710f, 0.916832246471183890f, 0.916525738556228210f, + 0.916218691472794220f, 0.915911105401509880f, 0.915602980523320230f, + 0.915294317019487050f, 0.914985115071589310f, 0.914675374861522390f, + 0.914365096571498560f, 0.914054280384046570f, 0.913742926482011390f, + 0.913431035048554720f, 0.913118606267154240f, 0.912805640321603500f, + 0.912492137396012650f, 0.912178097674807180f, 0.911863521342728520f, + 0.911548408584833990f, 0.911232759586496190f, 0.910916574533403360f, + 0.910599853611558930f, 0.910282597007281760f, 0.909964804907205660f, + 0.909646477498279540f, 0.909327614967767260f, 0.909008217503247450f, + 0.908688285292613360f, 0.908367818524072890f, 0.908046817386148340f, + 0.907725282067676440f, 0.907403212757808110f, 0.907080609646008450f, + 0.906757472922056550f, 0.906433802776045460f, 0.906109599398381980f, + 0.905784862979786550f, 0.905459593711293250f, 0.905133791784249690f, + 0.904807457390316540f, 0.904480590721468250f, 0.904153191969991780f, + 0.903825261328487510f, 0.903496798989868450f, 0.903167805147360720f, + 0.902838279994502830f, 0.902508223725145940f, 0.902177636533453620f, + 0.901846518613901750f, 0.901514870161278740f, 0.901182691370684520f, + 0.900849982437531450f, 0.900516743557543520f, 0.900182974926756810f, + 0.899848676741518580f, 0.899513849198487980f, 0.899178492494635330f, + 0.898842606827242370f, 0.898506192393901950f, 0.898169249392518080f, + 0.897831778021305650f, 0.897493778478790310f, 0.897155250963808550f, + 0.896816195675507300f, 0.896476612813344120f, 0.896136502577086770f, + 0.895795865166813530f, 0.895454700782912450f, 0.895113009626081760f, + 0.894770791897329550f, 0.894428047797973800f, 0.894084777529641990f, + 0.893740981294271040f, 0.893396659294107720f, 0.893051811731707450f, + 0.892706438809935390f, 0.892360540731965360f, 0.892014117701280470f, + 0.891667169921672280f, 0.891319697597241390f, 0.890971700932396860f, + 0.890623180131855930f, 0.890274135400644600f, 0.889924566944096720f, + 0.889574474967854580f, 0.889223859677868210f, 0.888872721280395630f, + 0.888521059982002260f, 0.888168875989561730f, 0.887816169510254440f, + 0.887462940751568840f, 0.887109189921300170f, 0.886754917227550840f, + 0.886400122878730600f, 0.886044807083555600f, 0.885688970051048960f, + 0.885332611990540590f, 0.884975733111666660f, 0.884618333624369920f, + 0.884260413738899190f, 0.883901973665809470f, 0.883543013615961880f, + 0.883183533800523390f, 0.882823534430966620f, 0.882463015719070150f, + 0.882101977876917580f, 0.881740421116898320f, 0.881378345651706920f, + 0.881015751694342870f, 0.880652639458111010f, 0.880289009156621010f, + 0.879924861003786860f, 0.879560195213827890f, 0.879195012001267480f, + 0.878829311580933360f, 0.878463094167957870f, 0.878096359977777130f, + 0.877729109226131570f, 0.877361342129065140f, 0.876993058902925890f, + 0.876624259764365310f, 0.876254944930338510f, 0.875885114618103810f, + 0.875514769045222850f, 0.875143908429560360f, 0.874772532989284150f, + 0.874400642942864790f, 0.874028238509075740f, 0.873655319906992630f, + 0.873281887355994210f, 0.872907941075761080f, 0.872533481286276170f, + 0.872158508207824480f, 0.871783022060993120f, 0.871407023066670950f, + 0.871030511446048260f, 0.870653487420617430f, 0.870275951212171940f, + 0.869897903042806340f, 0.869519343134916860f, 0.869140271711200560f, + 0.868760688994655310f, 0.868380595208579800f, 0.867999990576573510f, + 0.867618875322536230f, 0.867237249670668400f, 0.866855113845470430f, + 0.866472468071743050f, 0.866089312574586770f, 0.865705647579402380f, + 0.865321473311889800f, 0.864936789998049020f, 0.864551597864179340f, + 0.864165897136879300f, 0.863779688043046720f, 0.863392970809878420f, + 0.863005745664870320f, 0.862618012835816740f, 0.862229772550811240f, + 0.861841025038245330f, 0.861451770526809320f, 0.861062009245491480f, + 0.860671741423578380f, 0.860280967290654510f, 0.859889687076602290f, + 0.859497901011601730f, 0.859105609326130450f, 0.858712812250963520f, + 0.858319510017173440f, 0.857925702856129790f, 0.857531390999499150f, + 0.857136574679244980f, 0.856741254127627470f, 0.856345429577203610f, + 0.855949101260826910f, 0.855552269411646860f, 0.855154934263109620f, + 0.854757096048957220f, 0.854358755003227440f, 0.853959911360254180f, + 0.853560565354666840f, 0.853160717221390420f, 0.852760367195645300f, + 0.852359515512947090f, 0.851958162409106380f, 0.851556308120228980f, + 0.851153952882715340f, 0.850751096933260790f, 0.850347740508854980f, + 0.849943883846782210f, 0.849539527184620890f, 0.849134670760243630f, + 0.848729314811817130f, 0.848323459577801640f, 0.847917105296951410f, + 0.847510252208314330f, 0.847102900551231500f, 0.846695050565337450f, + 0.846286702490559710f, 0.845877856567119000f, 0.845468513035528830f, + 0.845058672136595470f, 0.844648334111417820f, 0.844237499201387020f, + 0.843826167648186740f, 0.843414339693792760f, 0.843002015580472940f, + 0.842589195550786710f, 0.842175879847585570f, 0.841762068714012490f, + 0.841347762393501950f, 0.840932961129779780f, 0.840517665166862550f, + 0.840101874749058400f, 0.839685590120966110f, 0.839268811527475230f, + 0.838851539213765760f, 0.838433773425308340f, 0.838015514407863820f, + 0.837596762407483040f, 0.837177517670507300f, 0.836757780443567190f, + 0.836337550973583530f, 0.835916829507766360f, 0.835495616293615350f, + 0.835073911578919410f, 0.834651715611756440f, 0.834229028640493420f, + 0.833805850913786340f, 0.833382182680579730f, 0.832958024190106670f, + 0.832533375691888680f, 0.832108237435735590f, 0.831682609671745120f, + 0.831256492650303210f, 0.830829886622083570f, 0.830402791838047550f, + 0.829975208549443950f, 0.829547137007808910f, 0.829118577464965980f, + 0.828689530173025820f, 0.828259995384385660f, 0.827829973351729920f, + 0.827399464328029470f, 0.826968468566541600f, 0.826536986320809960f, + 0.826105017844664610f, 0.825672563392221390f, 0.825239623217882250f, + 0.824806197576334330f, 0.824372286722551250f, 0.823937890911791370f, + 0.823503010399598500f, 0.823067645441801670f, 0.822631796294514990f, + 0.822195463214137170f, 0.821758646457351750f, 0.821321346281126740f, + 0.820883562942714580f, 0.820445296699652050f, 0.820006547809759680f, + 0.819567316531142230f, 0.819127603122188240f, 0.818687407841569680f, + 0.818246730948242070f, 0.817805572701444270f, 0.817363933360698460f, + 0.816921813185809480f, 0.816479212436865390f, 0.816036131374236810f, + 0.815592570258576790f, 0.815148529350820830f, 0.814704008912187080f, + 0.814259009204175270f, 0.813813530488567190f, 0.813367573027426570f, + 0.812921137083098770f, 0.812474222918210480f, 0.812026830795669730f, + 0.811578960978665890f, 0.811130613730669190f, 0.810681789315430780f, + 0.810232487996982330f, 0.809782710039636530f, 0.809332455707985950f, + 0.808881725266903610f, 0.808430518981542720f, 0.807978837117336310f, + 0.807526679939997160f, 0.807074047715517610f, 0.806620940710169650f, + 0.806167359190504420f, 0.805713303423352230f, 0.805258773675822210f, + 0.804803770215302920f, 0.804348293309460780f, 0.803892343226241260f, + 0.803435920233868120f, 0.802979024600843250f, 0.802521656595946430f, + 0.802063816488235440f, 0.801605504547046150f, 0.801146721041991360f, + 0.800687466242961610f, 0.800227740420124790f, 0.799767543843925680f, + 0.799306876785086160f, 0.798845739514604580f, 0.798384132303756380f, + 0.797922055424093000f, 0.797459509147442460f, 0.796996493745908750f, + 0.796533009491872000f, 0.796069056657987990f, 0.795604635517188070f, + 0.795139746342679590f, 0.794674389407944550f, 0.794208564986740640f, + 0.793742273353100210f, 0.793275514781330630f, 0.792808289546014120f, + 0.792340597922007170f, 0.791872440184440470f, 0.791403816608719500f, + 0.790934727470523290f, 0.790465173045804880f, 0.789995153610791090f, + 0.789524669441982190f, 0.789053720816151880f, 0.788582308010347120f, + 0.788110431301888070f, 0.787638090968367450f, 0.787165287287651010f, + 0.786692020537876790f, 0.786218290997455660f, 0.785744098945070360f, + 0.785269444659675850f, 0.784794328420499230f, 0.784318750507038920f, + 0.783842711199065230f, 0.783366210776619720f, 0.782889249520015480f, + 0.782411827709836530f, 0.781933945626937630f, 0.781455603552444590f, + 0.780976801767753750f, 0.780497540554531910f, 0.780017820194715990f, + 0.779537640970513260f, 0.779057003164400630f, 0.778575907059125050f, + 0.778094352937702790f, 0.777612341083420030f, 0.777129871779831620f, + 0.776646945310762060f, 0.776163561960304340f, 0.775679722012820650f, + 0.775195425752941420f, 0.774710673465565550f, 0.774225465435860680f, + 0.773739801949261840f, 0.773253683291472590f, 0.772767109748463850f, + 0.772280081606474320f, 0.771792599152010150f, 0.771304662671844830f, + 0.770816272453018540f, 0.770327428782838890f, 0.769838131948879840f, + 0.769348382238982280f, 0.768858179941253270f, 0.768367525344066270f, + 0.767876418736060610f, 0.767384860406141730f, 0.766892850643480670f, + 0.766400389737514230f, 0.765907477977944340f, 0.765414115654738270f, + 0.764920303058128410f, 0.764426040478612070f, 0.763931328206951090f, + 0.763436166534172010f, 0.762940555751565720f, 0.762444496150687210f, + 0.761947988023355390f, 0.761451031661653620f, 0.760953627357928150f, + 0.760455775404789260f, 0.759957476095110330f, 0.759458729722028210f, + 0.758959536578942440f, 0.758459896959515430f, 0.757959811157672300f, + 0.757459279467600720f, 0.756958302183750490f, 0.756456879600833740f, + 0.755955012013824420f, 0.755452699717958250f, 0.754949943008732640f, + 0.754446742181906440f, 0.753943097533499640f, 0.753439009359793580f, + 0.752934477957330150f, 0.752429503622912390f, 0.751924086653603550f, + 0.751418227346727470f, 0.750911925999867890f, 0.750405182910869330f, + 0.749897998377835330f, 0.749390372699129560f, 0.748882306173375150f, + 0.748373799099454560f, 0.747864851776509410f, 0.747355464503940190f, + 0.746845637581406540f, 0.746335371308826320f, 0.745824665986376090f, + 0.745313521914490520f, 0.744801939393862630f, 0.744289918725443260f, + 0.743777460210440890f, 0.743264564150321600f, 0.742751230846809050f, + 0.742237460601884000f, 0.741723253717784140f, 0.741208610497004260f, + 0.740693531242295760f, 0.740178016256666240f, 0.739662065843380010f, + 0.739145680305957510f, 0.738628859948174840f, 0.738111605074064260f, + 0.737593915987913570f, 0.737075792994265730f, 0.736557236397919150f, + 0.736038246503927350f, 0.735518823617598900f, 0.734998968044496710f, + 0.734478680090438370f, 0.733957960061495940f, 0.733436808263995710f, + 0.732915225004517780f, 0.732393210589896040f, 0.731870765327218290f, + 0.731347889523825570f, 0.730824583487312160f, 0.730300847525525490f, + 0.729776681946566090f, 0.729252087058786970f, 0.728727063170793830f, + 0.728201610591444610f, 0.727675729629849610f, 0.727149420595371020f, + 0.726622683797622850f, 0.726095519546471000f, 0.725567928152032300f, + 0.725039909924675370f, 0.724511465175019630f, 0.723982594213935520f, + 0.723453297352544380f, 0.722923574902217700f, 0.722393427174577550f, + 0.721862854481496340f, 0.721331857135096290f, 0.720800435447749190f, + 0.720268589732077190f, 0.719736320300951030f, 0.719203627467491220f, + 0.718670511545067230f, 0.718136972847297490f, 0.717603011688049080f, + 0.717068628381437480f, 0.716533823241826680f, 0.715998596583828690f, + 0.715462948722303760f, 0.714926879972359490f, 0.714390390649351390f, + 0.713853481068882470f, 0.713316151546802610f, 0.712778402399208980f, + 0.712240233942445510f, 0.711701646493102970f, 0.711162640368018350f, + 0.710623215884275020f, 0.710083373359202800f, 0.709543113110376770f, + 0.709002435455618250f, 0.708461340712994160f, 0.707919829200816310f, + 0.707377901237642100f, 0.706835557142273860f, 0.706292797233758480f, + 0.705749621831387790f, 0.705206031254697830f, 0.704662025823468930f, + 0.704117605857725430f, 0.703572771677735580f, 0.703027523604011220f, + 0.702481861957308000f, 0.701935787058624360f, 0.701389299229202230f, + 0.700842398790526230f, 0.700295086064323780f, 0.699747361372564990f, + 0.699199225037462120f, 0.698650677381469580f, 0.698101718727283880f, + 0.697552349397843270f, 0.697002569716327460f, 0.696452380006157830f, + 0.695901780590996830f, 0.695350771794747800f, 0.694799353941554900f, + 0.694247527355803310f, 0.693695292362118350f, 0.693142649285365510f, + 0.692589598450650380f, 0.692036140183318830f, 0.691482274808955850f, + 0.690928002653386280f, 0.690373324042674040f, 0.689818239303122470f, + 0.689262748761273470f, 0.688706852743907750f, 0.688150551578044830f, + 0.687593845590942170f, 0.687036735110095660f, 0.686479220463238950f, + 0.685921301978343670f, 0.685362979983618730f, 0.684804254807510620f, + 0.684245126778703080f, 0.683685596226116690f, 0.683125663478908800f, + 0.682565328866473250f, 0.682004592718440830f, 0.681443455364677990f, + 0.680881917135287340f, 0.680319978360607200f, 0.679757639371212030f, + 0.679194900497911200f, 0.678631762071749470f, 0.678068224424006600f, + 0.677504287886197430f, 0.676939952790071240f, 0.676375219467611700f, + 0.675810088251037060f, 0.675244559472799270f, 0.674678633465584540f, + 0.674112310562312360f, 0.673545591096136100f, 0.672978475400442090f, + 0.672410963808849900f, 0.671843056655211930f, 0.671274754273613490f, + 0.670706056998372160f, 0.670136965164037760f, 0.669567479105392490f, + 0.668997599157450270f, 0.668427325655456820f, 0.667856658934889440f, + 0.667285599331456480f, 0.666714147181097670f, 0.666142302819983540f, + 0.665570066584515560f, 0.664997438811325340f, 0.664424419837275180f, + 0.663851009999457340f, 0.663277209635194100f, 0.662703019082037440f, + 0.662128438677768720f, 0.661553468760399000f, 0.660978109668168060f, + 0.660402361739545030f, 0.659826225313227430f, 0.659249700728141490f, + 0.658672788323441890f, 0.658095488438511290f, 0.657517801412960120f, + 0.656939727586627110f, 0.656361267299578000f, 0.655782420892106030f, + 0.655203188704731930f, 0.654623571078202680f, 0.654043568353492640f, + 0.653463180871802330f, 0.652882408974558960f, 0.652301253003415460f, + 0.651719713300251020f, 0.651137790207170330f, 0.650555484066503990f, + 0.649972795220807530f, 0.649389724012861770f, 0.648806270785672550f, + 0.648222435882470420f, 0.647638219646710420f, 0.647053622422071650f, + 0.646468644552457890f, 0.645883286381996440f, 0.645297548255038380f, + 0.644711430516158420f, 0.644124933510154540f, 0.643538057582047850f, + 0.642950803077082080f, 0.642363170340724320f, 0.641775159718663500f, + 0.641186771556811250f, 0.640598006201301030f, 0.640008863998488440f, + 0.639419345294950700f, 0.638829450437486400f, 0.638239179773115390f, + 0.637648533649078810f, 0.637057512412838590f, 0.636466116412077180f, + 0.635874345994697720f, 0.635282201508823530f, 0.634689683302797850f, + 0.634096791725183740f, 0.633503527124764320f, 0.632909889850541860f, + 0.632315880251737680f, 0.631721498677792370f, 0.631126745478365340f, + 0.630531621003334600f, 0.629936125602796550f, 0.629340259627065750f, + 0.628744023426674790f, 0.628147417352374120f, 0.627550441755131530f, + 0.626953096986132770f, 0.626355383396779990f, 0.625757301338692900f, + 0.625158851163707730f, 0.624560033223877320f, 0.623960847871470770f, + 0.623361295458973340f, 0.622761376339086460f, 0.622161090864726930f, + 0.621560439389027270f, 0.620959422265335180f, 0.620358039847213830f, + 0.619756292488440660f, 0.619154180543008410f, 0.618551704365123860f, + 0.617948864309208260f, 0.617345660729896940f, 0.616742093982038830f, + 0.616138164420696910f, 0.615533872401147430f, 0.614929218278879590f, + 0.614324202409595950f, 0.613718825149211830f, 0.613113086853854910f, + 0.612506987879865570f, 0.611900528583796070f, 0.611293709322411010f, + 0.610686530452686280f, 0.610078992331809620f, 0.609471095317180240f, + 0.608862839766408200f, 0.608254226037314490f, 0.607645254487930830f, + 0.607035925476499760f, 0.606426239361473550f, 0.605816196501515080f, + 0.605205797255496500f, 0.604595041982500360f, 0.603983931041818020f, + 0.603372464792950370f, 0.602760643595607220f, 0.602148467809707320f, + 0.601535937795377730f, 0.600923053912954090f, 0.600309816522980430f, + 0.599696225986208310f, 0.599082282663597310f, 0.598467986916314310f, + 0.597853339105733910f, 0.597238339593437530f, 0.596622988741213330f, + 0.596007286911056530f, 0.595391234465168730f, 0.594774831765957580f, + 0.594158079176036800f, 0.593540977058226390f, 0.592923525775551410f, + 0.592305725691242400f, 0.591687577168735550f, 0.591069080571671510f, + 0.590450236263895920f, 0.589831044609458900f, 0.589211505972615070f, + 0.588591620717822890f, 0.587971389209745120f, 0.587350811813247660f, + 0.586729888893400500f, 0.586108620815476430f, 0.585487007944951450f, + 0.584865050647504490f, 0.584242749289016980f, 0.583620104235572760f, + 0.582997115853457700f, 0.582373784509160220f, 0.581750110569369760f, + 0.581126094400977620f, 0.580501736371076600f, 0.579877036846960350f, + 0.579251996196123550f, 0.578626614786261430f, 0.578000892985269910f, + 0.577374831161244880f, 0.576748429682482520f, 0.576121688917478390f, + 0.575494609234928230f, 0.574867191003726740f, 0.574239434592967890f, + 0.573611340371944610f, 0.572982908710148680f, 0.572354139977270030f, + 0.571725034543197120f, 0.571095592778016690f, 0.570465815052012990f, + 0.569835701735668110f, 0.569205253199661200f, 0.568574469814869250f, + 0.567943351952365670f, 0.567311899983420800f, 0.566680114279501710f, + 0.566047995212271560f, 0.565415543153589770f, 0.564782758475511400f, + 0.564149641550287680f, 0.563516192750364910f, 0.562882412448384550f, + 0.562248301017183150f, 0.561613858829792420f, 0.560979086259438260f, + 0.560343983679540860f, 0.559708551463714790f, 0.559072789985768480f, + 0.558436699619704100f, 0.557800280739717100f, 0.557163533720196340f, + 0.556526458935723720f, 0.555889056761073920f, 0.555251327571214090f, + 0.554613271741304040f, 0.553974889646695610f, 0.553336181662932410f, + 0.552697148165749770f, 0.552057789531074980f, 0.551418106135026060f, + 0.550778098353912230f, 0.550137766564233630f, 0.549497111142680960f, + 0.548856132466135290f, 0.548214830911667780f, 0.547573206856539870f, + 0.546931260678202190f, 0.546288992754295210f, 0.545646403462648590f, + 0.545003493181281160f, 0.544360262288400400f, 0.543716711162402390f, + 0.543072840181871850f, 0.542428649725581360f, 0.541784140172491660f, + 0.541139311901750910f, 0.540494165292695230f, 0.539848700724847700f, + 0.539202918577918240f, 0.538556819231804210f, 0.537910403066588990f, + 0.537263670462542530f, 0.536616621800121150f, 0.535969257459966710f, + 0.535321577822907010f, 0.534673583269955510f, 0.534025274182310380f, + 0.533376650941355560f, 0.532727713928658810f, 0.532078463525973540f, + 0.531428900115236910f, 0.530779024078570250f, 0.530128835798278850f, + 0.529478335656852090f, 0.528827524036961980f, 0.528176401321464370f, + 0.527524967893398200f, 0.526873224135984700f, 0.526221170432628170f, + 0.525568807166914680f, 0.524916134722612890f, 0.524263153483673470f, + 0.523609863834228030f, 0.522956266158590140f, 0.522302360841254700f, + 0.521648148266897090f, 0.520993628820373810f, 0.520338802886721960f, + 0.519683670851158520f, 0.519028233099080970f, 0.518372490016066220f, + 0.517716441987871150f, 0.517060089400432130f, 0.516403432639863990f, + 0.515746472092461380f, 0.515089208144697270f, 0.514431641183222930f, + 0.513773771594868030f, 0.513115599766640560f, 0.512457126085725800f, + 0.511798350939487000f, 0.511139274715464390f, 0.510479897801375700f, + 0.509820220585115560f, 0.509160243454754750f, 0.508499966798540810f, + 0.507839391004897940f, 0.507178516462425290f, 0.506517343559898530f, + 0.505855872686268860f, 0.505194104230662240f, 0.504532038582380380f, + 0.503869676130898950f, 0.503207017265869030f, 0.502544062377115800f, + 0.501880811854638400f, 0.501217266088609950f, 0.500553425469377640f, + 0.499889290387461380f, 0.499224861233555030f, 0.498560138398525200f, + 0.497895122273410930f, 0.497229813249424340f, 0.496564211717949340f, + 0.495898318070542240f, 0.495232132698931350f, 0.494565655995016010f, + 0.493898888350867430f, 0.493231830158728070f, 0.492564481811010650f, + 0.491896843700299240f, 0.491228916219348330f, 0.490560699761082080f, + 0.489892194718595300f, 0.489223401485152030f, 0.488554320454186230f, + 0.487884952019301210f, 0.487215296574268820f, 0.486545354513030270f, + 0.485875126229695420f, 0.485204612118541880f, 0.484533812574016120f, + 0.483862727990732320f, 0.483191358763471910f, 0.482519705287184520f, + 0.481847767956986080f, 0.481175547168160360f, 0.480503043316157670f, + 0.479830256796594250f, 0.479157188005253310f, 0.478483837338084080f, + 0.477810205191201040f, 0.477136291960884750f, 0.476462098043581310f, + 0.475787623835901120f, 0.475112869734620470f, 0.474437836136679340f, + 0.473762523439182850f, 0.473086932039400220f, 0.472411062334764100f, + 0.471734914722871430f, 0.471058489601482610f, 0.470381787368520710f, + 0.469704808422072460f, 0.469027553160387240f, 0.468350021981876530f, + 0.467672215285114710f, 0.466994133468838110f, 0.466315776931944480f, + 0.465637146073493770f, 0.464958241292706740f, 0.464279062988965760f, + 0.463599611561814120f, 0.462919887410955130f, 0.462239890936253280f, + 0.461559622537733190f, 0.460879082615578690f, 0.460198271570134270f, + 0.459517189801903590f, 0.458835837711549120f, 0.458154215699893230f, + 0.457472324167916110f, 0.456790163516757220f, 0.456107734147714220f, + 0.455425036462242420f, 0.454742070861955450f, 0.454058837748624540f, + 0.453375337524177750f, 0.452691570590700860f, 0.452007537350436530f, + 0.451323238205783520f, 0.450638673559297760f, 0.449953843813690580f, + 0.449268749371829920f, 0.448583390636739300f, 0.447897768011597360f, + 0.447211881899738260f, 0.446525732704651400f, 0.445839320829980350f, + 0.445152646679523590f, 0.444465710657234110f, 0.443778513167218280f, + 0.443091054613736990f, 0.442403335401204130f, 0.441715355934187310f, + 0.441027116617407340f, 0.440338617855737300f, 0.439649860054203420f, + 0.438960843617984430f, 0.438271568952410480f, 0.437582036462964340f, + 0.436892246555280470f, 0.436202199635143950f, 0.435511896108492170f, + 0.434821336381412350f, 0.434130520860143310f, 0.433439449951074200f, + 0.432748124060743760f, 0.432056543595841450f, 0.431364708963206440f, + 0.430672620569826860f, 0.429980278822840570f, 0.429287684129534720f, + 0.428594836897344400f, 0.427901737533854240f, 0.427208386446796370f, + 0.426514784044051520f, 0.425820930733648350f, 0.425126826923762410f, + 0.424432473022717420f, 0.423737869438983950f, 0.423043016581179100f, + 0.422347914858067000f, 0.421652564678558380f, 0.420956966451709440f, + 0.420261120586723050f, 0.419565027492946940f, 0.418868687579875110f, + 0.418172101257146430f, 0.417475268934544340f, 0.416778191021997590f, + 0.416080867929579320f, 0.415383300067506290f, 0.414685487846140010f, + 0.413987431675985510f, 0.413289131967690960f, 0.412590589132048380f, + 0.411891803579992220f, 0.411192775722600160f, 0.410493505971092520f, + 0.409793994736831200f, 0.409094242431320920f, 0.408394249466208110f, + 0.407694016253280170f, 0.406993543204466460f, 0.406292830731837470f, + 0.405591879247603870f, 0.404890689164117750f, 0.404189260893870750f, + 0.403487594849495310f, 0.402785691443763640f, 0.402083551089587040f, + 0.401381174200016790f, 0.400678561188243350f, 0.399975712467595390f, + 0.399272628451540930f, 0.398569309553686360f, 0.397865756187775750f, + 0.397161968767691720f, 0.396457947707453960f, 0.395753693421220080f, + 0.395049206323284880f, 0.394344486828079650f, 0.393639535350172880f, + 0.392934352304269600f, 0.392228938105210370f, 0.391523293167972350f, + 0.390817417907668610f, 0.390111312739546910f, 0.389404978078991100f, + 0.388698414341519250f, 0.387991621942784910f, 0.387284601298575890f, + 0.386577352824813980f, 0.385869876937555310f, 0.385162174052989970f, + 0.384454244587440870f, 0.383746088957365010f, 0.383037707579352130f, + 0.382329100870124510f, 0.381620269246537520f, 0.380911213125578130f, + 0.380201932924366050f, 0.379492429060152740f, 0.378782701950320600f, + 0.378072752012383990f, 0.377362579663988450f, 0.376652185322909620f, + 0.375941569407054420f, 0.375230732334460030f, 0.374519674523293210f, + 0.373808396391851370f, 0.373096898358560690f, 0.372385180841977360f, + 0.371673244260786630f, 0.370961089033802040f, 0.370248715579966360f, + 0.369536124318350760f, 0.368823315668153960f, 0.368110290048703050f, + 0.367397047879452820f, 0.366683589579984930f, 0.365969915570008910f, + 0.365256026269360380f, 0.364541922098002180f, 0.363827603476023610f, + 0.363113070823639530f, 0.362398324561191310f, 0.361683365109145950f, + 0.360968192888095290f, 0.360252808318756830f, 0.359537211821973180f, + 0.358821403818710860f, 0.358105384730061760f, 0.357389154977241000f, + 0.356672714981588260f, 0.355956065164567010f, 0.355239205947763370f, + 0.354522137752887430f, 0.353804861001772160f, 0.353087376116372530f, + 0.352369683518766630f, 0.351651783631154680f, 0.350933676875858360f, + 0.350215363675321740f, 0.349496844452109600f, 0.348778119628908420f, + 0.348059189628525780f, 0.347340054873889190f, 0.346620715788047320f, + 0.345901172794169100f, 0.345181426315542610f, 0.344461476775576480f, + 0.343741324597798600f, 0.343020970205855540f, 0.342300414023513690f, + 0.341579656474657210f, 0.340858697983289440f, 0.340137538973531880f, + 0.339416179869623410f, 0.338694621095921190f, 0.337972863076899830f, + 0.337250906237150650f, 0.336528751001382350f, 0.335806397794420560f, + 0.335083847041206580f, 0.334361099166798900f, 0.333638154596370920f, + 0.332915013755212650f, 0.332191677068729320f, 0.331468144962440920f, + 0.330744417861982890f, 0.330020496193105530f, 0.329296380381672800f, + 0.328572070853663690f, 0.327847568035170960f, 0.327122872352400510f, + 0.326397984231672660f, 0.325672904099419900f, 0.324947632382188430f, + 0.324222169506637130f, 0.323496515899536760f, 0.322770671987770710f, + 0.322044638198334620f, 0.321318414958334910f, 0.320592002694990330f, + 0.319865401835630610f, 0.319138612807695900f, 0.318411636038737960f, + 0.317684471956418020f, 0.316957120988508150f, 0.316229583562890490f, + 0.315501860107556040f, 0.314773951050606070f, 0.314045856820250820f, + 0.313317577844809070f, 0.312589114552708660f, 0.311860467372486130f, + 0.311131636732785270f, 0.310402623062358880f, 0.309673426790066490f, + 0.308944048344875710f, 0.308214488155861220f, 0.307484746652204160f, + 0.306754824263192780f, 0.306024721418221900f, 0.305294438546791720f, + 0.304563976078509050f, 0.303833334443086470f, 0.303102514070341060f, + 0.302371515390196130f, 0.301640338832678880f, 0.300908984827921890f, + 0.300177453806162120f, 0.299445746197739950f, 0.298713862433100390f, + 0.297981802942791920f, 0.297249568157465890f, 0.296517158507877410f, + 0.295784574424884370f, 0.295051816339446720f, 0.294318884682627570f, + 0.293585779885591310f, 0.292852502379604810f, 0.292119052596036540f, + 0.291385430966355720f, 0.290651637922133220f, 0.289917673895040860f, + 0.289183539316850310f, 0.288449234619434170f, 0.287714760234765280f, + 0.286980116594915570f, 0.286245304132057120f, 0.285510323278461380f, + 0.284775174466498300f, 0.284039858128637360f, 0.283304374697445790f, + 0.282568724605589740f, 0.281832908285833460f, 0.281096926171038320f, + 0.280360778694163810f, 0.279624466288266700f, 0.278887989386500280f, + 0.278151348422115090f, 0.277414543828458200f, 0.276677576038972420f, + 0.275940445487197320f, 0.275203152606767370f, 0.274465697831413220f, + 0.273728081594960650f, 0.272990304331329980f, 0.272252366474536660f, + 0.271514268458690810f, 0.270776010717996010f, 0.270037593686750510f, + 0.269299017799346230f, 0.268560283490267890f, 0.267821391194094320f, + 0.267082341345496350f, 0.266343134379238180f, 0.265603770730176440f, + 0.264864250833259320f, 0.264124575123527490f, 0.263384744036113390f, + 0.262644758006240100f, 0.261904617469222560f, 0.261164322860466590f, + 0.260423874615468010f, 0.259683273169813930f, 0.258942518959180580f, + 0.258201612419334870f, 0.257460553986133210f, 0.256719344095520720f, + 0.255977983183532380f, 0.255236471686291820f, 0.254494810040010790f, + 0.253752998680989940f, 0.253011038045617980f, 0.252268928570370810f, + 0.251526670691812780f, 0.250784264846594550f, 0.250041711471454650f, + 0.249299011003218300f, 0.248556163878796620f, 0.247813170535187620f, + 0.247070031409475370f, 0.246326746938829060f, 0.245583317560504000f, + 0.244839743711840750f, 0.244096025830264210f, 0.243352164353284880f, + 0.242608159718496890f, 0.241864012363579210f, 0.241119722726294730f, + 0.240375291244489500f, 0.239630718356093560f, 0.238886004499120170f, + 0.238141150111664870f, 0.237396155631906550f, 0.236651021498106460f, + 0.235905748148607370f, 0.235160336021834860f, 0.234414785556295250f, + 0.233669097190576820f, 0.232923271363349120f, 0.232177308513361770f, + 0.231431209079445730f, 0.230684973500512310f, 0.229938602215552260f, + 0.229192095663636740f, 0.228445454283916550f, 0.227698678515621170f, + 0.226951768798059980f, 0.226204725570620270f, 0.225457549272768540f, + 0.224710240344049570f, 0.223962799224085520f, 0.223215226352576960f, + 0.222467522169301990f, 0.221719687114115240f, 0.220971721626949060f, + 0.220223626147812460f, 0.219475401116790340f, 0.218727046974044600f, + 0.217978564159812290f, 0.217229953114406790f, 0.216481214278216900f, + 0.215732348091705940f, 0.214983354995412820f, 0.214234235429951100f, + 0.213484989836008080f, 0.212735618654345870f, 0.211986122325800410f, + 0.211236501291280710f, 0.210486755991769890f, 0.209736886868323370f, + 0.208986894362070070f, 0.208236778914211470f, 0.207486540966020700f, + 0.206736180958843660f, 0.205985699334098050f, 0.205235096533272380f, + 0.204484372997927180f, 0.203733529169694010f, 0.202982565490274460f, + 0.202231482401441620f, 0.201480280345037820f, 0.200728959762976140f, + 0.199977521097239290f, 0.199225964789878890f, 0.198474291283016360f, + 0.197722501018842030f, 0.196970594439614370f, 0.196218571987660850f, + 0.195466434105377090f, 0.194714181235225990f, 0.193961813819739010f, + 0.193209332301514080f, 0.192456737123216840f, 0.191704028727579940f, + 0.190951207557401860f, 0.190198274055548120f, 0.189445228664950340f, + 0.188692071828605260f, 0.187938803989575850f, 0.187185425590990440f, + 0.186431937076041640f, 0.185678338887987790f, 0.184924631470150870f, + 0.184170815265917720f, 0.183416890718739230f, 0.182662858272129360f, + 0.181908718369666160f, 0.181154471454990920f, 0.180400117971807270f, + 0.179645658363882100f, 0.178891093075044830f, 0.178136422549186320f, + 0.177381647230260200f, 0.176626767562280960f, 0.175871783989325040f, + 0.175116696955530060f, 0.174361506905093830f, 0.173606214282275410f, + 0.172850819531394200f, 0.172095323096829040f, 0.171339725423019260f, + 0.170584026954463700f, 0.169828228135719880f, 0.169072329411405180f, + 0.168316331226194910f, 0.167560234024823590f, 0.166804038252083870f, + 0.166047744352825850f, 0.165291352771957970f, 0.164534863954446110f, + 0.163778278345312690f, 0.163021596389637810f, 0.162264818532558110f, + 0.161507945219266150f, 0.160750976895011390f, 0.159993914005098350f, + 0.159236756994887850f, 0.158479506309796100f, 0.157722162395293690f, + 0.156964725696906750f, 0.156207196660216040f, 0.155449575730855880f, + 0.154691863354515400f, 0.153934059976937460f, 0.153176166043917870f, + 0.152418182001306500f, 0.151660108295005400f, 0.150901945370970040f, + 0.150143693675208330f, 0.149385353653779810f, 0.148626925752796540f, + 0.147868410418422360f, 0.147109808096871850f, 0.146351119234411440f, + 0.145592344277358450f, 0.144833483672080240f, 0.144074537864995330f, + 0.143315507302571590f, 0.142556392431327340f, 0.141797193697830530f, + 0.141037911548697770f, 0.140278546430595420f, 0.139519098790238600f, + 0.138759569074390380f, 0.137999957729862760f, 0.137240265203515700f, + 0.136480491942256310f, 0.135720638393040080f, 0.134960705002868830f, + 0.134200692218792020f, 0.133440600487905820f, 0.132680430257352130f, + 0.131920181974319760f, 0.131159856086043410f, 0.130399453039802740f, + 0.129638973282923540f, 0.128878417262776660f, 0.128117785426777150f, + 0.127357078222385570f, 0.126596296097105960f, 0.125835439498487020f, + 0.125074508874121300f, 0.124313504671644300f, 0.123552427338735370f, + 0.122791277323116900f, 0.122030055072553410f, 0.121268761034852550f, + 0.120507395657864240f, 0.119745959389479630f, 0.118984452677632520f, + 0.118222875970297250f, 0.117461229715489990f, 0.116699514361267840f, + 0.115937730355727850f, 0.115175878147008180f, 0.114413958183287050f, + 0.113651970912781920f, 0.112889916783750470f, 0.112127796244489750f, + 0.111365609743335190f, 0.110603357728661910f, 0.109841040648882680f, + 0.109078658952449240f, 0.108316213087851300f, 0.107553703503615710f, + 0.106791130648307380f, 0.106028494970528530f, 0.105265796918917650f, + 0.104503036942150550f, 0.103740215488939480f, 0.102977333008032250f, + 0.102214389948213370f, 0.101451386758302160f, 0.100688323887153970f, + 0.099925201783659226f, 0.099162020896742573f, 0.098398781675363881f, + 0.097635484568517339f, 0.096872130025230527f, 0.096108718494565468f, + 0.095345250425617742f, 0.094581726267515473f, 0.093818146469420494f, + 0.093054511480527333f, 0.092290821750062355f, 0.091527077727284981f, + 0.090763279861485704f, 0.089999428601987341f, 0.089235524398144139f, + 0.088471567699340822f, 0.087707558954993645f, 0.086943498614549489f, + 0.086179387127484922f, 0.085415224943307277f, 0.084651012511553700f, + 0.083886750281790226f, 0.083122438703613077f, 0.082358078226646619f, + 0.081593669300544638f, 0.080829212374989468f, 0.080064707899690932f, + 0.079300156324387569f, 0.078535558098845590f, 0.077770913672857989f, + 0.077006223496245585f, 0.076241488018856149f, 0.075476707690563416f, + 0.074711882961268378f, 0.073947014280897269f, 0.073182102099402888f, + 0.072417146866763538f, 0.071652149032982254f, 0.070887109048087787f, + 0.070122027362133646f, 0.069356904425197236f, 0.068591740687380900f, + 0.067826536598810966f, 0.067061292609636836f, 0.066296009170032283f, + 0.065530686730193397f, 0.064765325740339871f, 0.063999926650714078f, + 0.063234489911580136f, 0.062469015973224969f, 0.061703505285957416f, + 0.060937958300107238f, 0.060172375466026218f, 0.059406757234087247f, + 0.058641104054683348f, 0.057875416378229017f, 0.057109694655158132f, + 0.056343939335925283f, 0.055578150871004817f, 0.054812329710889909f, + 0.054046476306093640f, 0.053280591107148056f, 0.052514674564603257f, + 0.051748727129028414f, 0.050982749251010900f, 0.050216741381155325f, + 0.049450703970084824f, 0.048684637468439020f, 0.047918542326875327f, + 0.047152418996068000f, 0.046386267926707213f, 0.045620089569500123f, + 0.044853884375169933f, 0.044087652794454979f, 0.043321395278109784f, + 0.042555112276904117f, 0.041788804241622082f, 0.041022471623063397f, + 0.040256114872041358f, 0.039489734439384118f, 0.038723330775933762f, + 0.037956904332545366f, 0.037190455560088091f, 0.036423984909444228f, + 0.035657492831508264f, 0.034890979777187955f, 0.034124446197403423f, + 0.033357892543086159f, 0.032591319265180385f, 0.031824726814640963f, + 0.031058115642434700f, 0.030291486199539423f, 0.029524838936943035f, + 0.028758174305644590f, 0.027991492756653365f, 0.027224794740987910f, + 0.026458080709677145f, 0.025691351113759395f, 0.024924606404281485f, + 0.024157847032300020f, 0.023391073448879338f, 0.022624286105092803f, + 0.021857485452021874f, 0.021090671940755180f, 0.020323846022389572f, + 0.019557008148029204f, 0.018790158768784596f, 0.018023298335773701f, + 0.017256427300120978f, 0.016489546112956454f, 0.015722655225417017f, + 0.014955755088644378f, 0.014188846153786343f, 0.013421928871995907f, + 0.012655003694430301f, 0.011888071072252072f, 0.011121131456628141f, + 0.010354185298728884f, 0.009587233049729183f, 0.008820275160807512f, + 0.008053312083144991f, 0.007286344267926684f, 0.006519372166339549f, + 0.005752396229573737f, 0.004985416908821652f, 0.004218434655277024f, + 0.003451449920135975f, 0.002684463154596083f, 0.001917474809855460f, + 0.001150485337113809f, 0.000383495187571497f}; static const float32_t cos_factors_8192[8192] = { - 1.999999990808214700f, 1.999999917273932200f, 1.999999770205369800f, - 1.999999549602533100f, - 1.999999255465430200f, 1.999998887794072000f, 1.999998446588471700f, - 1.999997931848645600f, - 1.999997343574612800f, 1.999996681766395000f, 1.999995946424016200f, - 1.999995137547503600f, - 1.999994255136887000f, 1.999993299192198700f, 1.999992269713474200f, - 1.999991166700750800f, - 1.999989990154069600f, 1.999988740073473500f, 1.999987416459008600f, - 1.999986019310723500f, - 1.999984548628669600f, 1.999983004412901000f, 1.999981386663474400f, - 1.999979695380449400f, - 1.999977930563888100f, 1.999976092213855400f, 1.999974180330418700f, - 1.999972194913648900f, - 1.999970135963618400f, 1.999968003480403000f, 1.999965797464081200f, - 1.999963517914734100f, - 1.999961164832445800f, 1.999958738217302300f, 1.999956238069392900f, - 1.999953664388809800f, - 1.999951017175647600f, 1.999948296430003500f, 1.999945502151977600f, - 1.999942634341672600f, - 1.999939692999193900f, 1.999936678124649700f, 1.999933589718150700f, - 1.999930427779810900f, - 1.999927192309745900f, 1.999923883308075200f, 1.999920500774920300f, - 1.999917044710405500f, - 1.999913515114657900f, 1.999909911987807200f, 1.999906235329986100f, - 1.999902485141329400f, - 1.999898661421975400f, 1.999894764172064600f, 1.999890793391740000f, - 1.999886749081147800f, - 1.999882631240436700f, 1.999878439869758200f, 1.999874174969266300f, - 1.999869836539117700f, - 1.999865424579472000f, 1.999860939090491600f, 1.999856380072341000f, - 1.999851747525188200f, - 1.999847041449203300f, 1.999842261844559700f, 1.999837408711432600f, - 1.999832482050000900f, - 1.999827481860445300f, 1.999822408142949900f, 1.999817260897701400f, - 1.999812040124888700f, - 1.999806745824704000f, 1.999801377997341800f, 1.999795936642999600f, - 1.999790421761877400f, - 1.999784833354177900f, 1.999779171420106700f, 1.999773435959872000f, - 1.999767626973684400f, - 1.999761744461757700f, 1.999755788424308200f, 1.999749758861554900f, - 1.999743655773719400f, - 1.999737479161026100f, 1.999731229023702200f, 1.999724905361977200f, - 1.999718508176084000f, - 1.999712037466257600f, 1.999705493232735800f, 1.999698875475759600f, - 1.999692184195571900f, - 1.999685419392419000f, 1.999678581066549400f, 1.999671669218214600f, - 1.999664683847668800f, - 1.999657624955168700f, 1.999650492540973900f, 1.999643286605346800f, - 1.999636007148552400f, - 1.999628654170857900f, 1.999621227672533800f, 1.999613727653853500f, - 1.999606154115092500f, - 1.999598507056529000f, 1.999590786478444600f, 1.999582992381123000f, - 1.999575124764850800f, - 1.999567183629917100f, 1.999559168976613900f, 1.999551080805236100f, - 1.999542919116081000f, - 1.999534683909448600f, 1.999526375185641800f, 1.999517992944965800f, - 1.999509537187729200f, - 1.999501007914242600f, 1.999492405124819700f, 1.999483728819776900f, - 1.999474978999432800f, - 1.999466155664109600f, 1.999457258814131500f, 1.999448288449825500f, - 1.999439244571521700f, - 1.999430127179552500f, 1.999420936274252800f, 1.999411671855960900f, - 1.999402333925017300f, - 1.999392922481765500f, 1.999383437526551300f, 1.999373879059723500f, - 1.999364247081633500f, - 1.999354541592635500f, 1.999344762593086500f, 1.999334910083345700f, - 1.999324984063775700f, - 1.999314984534741100f, 1.999304911496609700f, 1.999294764949752100f, - 1.999284544894541100f, - 1.999274251331352400f, 1.999263884260564600f, 1.999253443682558900f, - 1.999242929597719200f, - 1.999232342006432000f, 1.999221680909086400f, 1.999210946306074500f, - 1.999200138197791100f, - 1.999189256584633600f, 1.999178301467001900f, 1.999167272845298900f, - 1.999156170719930100f, - 1.999144995091303600f, 1.999133745959830600f, 1.999122423325924200f, - 1.999111027190001000f, - 1.999099557552479900f, 1.999088014413782800f, 1.999076397774334000f, - 1.999064707634560700f, - 1.999052943994892300f, 1.999041106855761900f, 1.999029196217604100f, - 1.999017212080857400f, - 1.999005154445962200f, 1.998993023313361700f, 1.998980818683502100f, - 1.998968540556831800f, - 1.998956188933802800f, 1.998943763814868800f, 1.998931265200486900f, - 1.998918693091116200f, - 1.998906047487219600f, 1.998893328389261400f, 1.998880535797709700f, - 1.998867669713034500f, - 1.998854730135709400f, 1.998841717066209400f, 1.998828630505013400f, - 1.998815470452602400f, - 1.998802236909460500f, 1.998788929876074100f, 1.998775549352932400f, - 1.998762095340527400f, - 1.998748567839354000f, 1.998734966849909000f, 1.998721292372693100f, - 1.998707544408208700f, - 1.998693722956961500f, 1.998679828019459300f, 1.998665859596213500f, - 1.998651817687737300f, - 1.998637702294547000f, 1.998623513417161700f, 1.998609251056103100f, - 1.998594915211895600f, - 1.998580505885066100f, 1.998566023076144600f, 1.998551466785663400f, - 1.998536837014157900f, - 1.998522133762165900f, 1.998507357030227900f, 1.998492506818887200f, - 1.998477583128690100f, - 1.998462585960185000f, 1.998447515313923400f, 1.998432371190459500f, - 1.998417153590349900f, - 1.998401862514154200f, 1.998386497962434800f, 1.998371059935756300f, - 1.998355548434686400f, - 1.998339963459795400f, 1.998324305011656600f, 1.998308573090845200f, - 1.998292767697940100f, - 1.998276888833522300f, 1.998260936498175400f, 1.998244910692486000f, - 1.998228811417043700f, - 1.998212638672439900f, 1.998196392459269400f, 1.998180072778129600f, - 1.998163679629620500f, - 1.998147213014344900f, 1.998130672932908000f, 1.998114059385918400f, - 1.998097372373986300f, - 1.998080611897725700f, 1.998063777957752600f, 1.998046870554686100f, - 1.998029889689147700f, - 1.998012835361761900f, 1.997995707573155600f, 1.997978506323958600f, - 1.997961231614803200f, - 1.997943883446324800f, 1.997926461819161000f, 1.997908966733952500f, - 1.997891398191342400f, - 1.997873756191977000f, 1.997856040736504500f, 1.997838251825576400f, - 1.997820389459846700f, - 1.997802453639972300f, 1.997784444366612600f, 1.997766361640429800f, - 1.997748205462088500f, - 1.997729975832256600f, 1.997711672751604200f, 1.997693296220804000f, - 1.997674846240532000f, - 1.997656322811466500f, 1.997637725934288300f, 1.997619055609681600f, - 1.997600311838332500f, - 1.997581494620930300f, 1.997562603958166600f, 1.997543639850736200f, - 1.997524602299336500f, - 1.997505491304667000f, 1.997486306867430900f, 1.997467048988333000f, - 1.997447717668082000f, - 1.997428312907388200f, 1.997408834706965000f, 1.997389283067528800f, - 1.997369657989798400f, - 1.997349959474495200f, 1.997330187522343700f, 1.997310342134070800f, - 1.997290423310406100f, - 1.997270431052081900f, 1.997250365359833200f, 1.997230226234397900f, - 1.997210013676516700f, - 1.997189727686932400f, 1.997169368266390900f, 1.997148935415640600f, - 1.997128429135433400f, - 1.997107849426522600f, 1.997087196289665000f, 1.997066469725620200f, - 1.997045669735150000f, - 1.997024796319019300f, 1.997003849477995600f, 1.996982829212848900f, - 1.996961735524351900f, - 1.996940568413280600f, 1.996919327880412900f, 1.996898013926530000f, - 1.996876626552415400f, - 1.996855165758855600f, 1.996833631546639300f, 1.996812023916558800f, - 1.996790342869408000f, - 1.996768588405984300f, 1.996746760527087700f, 1.996724859233520500f, - 1.996702884526087900f, - 1.996680836405598100f, 1.996658714872861800f, 1.996636519928692000f, - 1.996614251573904900f, - 1.996591909809319400f, 1.996569494635756600f, 1.996547006054041100f, - 1.996524444064999400f, - 1.996501808669461000f, 1.996479099868258400f, 1.996456317662226300f, - 1.996433462052202600f, - 1.996410533039027400f, 1.996387530623543900f, 1.996364454806597500f, - 1.996341305589037100f, - 1.996318082971713500f, 1.996294786955480800f, 1.996271417541195300f, - 1.996247974729716200f, - 1.996224458521905600f, 1.996200868918628100f, 1.996177205920750800f, - 1.996153469529144100f, - 1.996129659744680300f, 1.996105776568235100f, 1.996081820000686500f, - 1.996057790042915500f, - 1.996033686695805300f, 1.996009509960242400f, 1.995985259837115500f, - 1.995960936327316300f, - 1.995936539431739000f, 1.995912069151280800f, 1.995887525486841300f, - 1.995862908439323100f, - 1.995838218009630800f, 1.995813454198672700f, 1.995788617007359100f, - 1.995763706436603200f, - 1.995738722487320600f, 1.995713665160430600f, 1.995688534456853800f, - 1.995663330377514400f, - 1.995638052923339300f, 1.995612702095257400f, 1.995587277894201400f, - 1.995561780321105600f, - 1.995536209376907600f, 1.995510565062547800f, 1.995484847378968600f, - 1.995459056327116000f, - 1.995433191907938000f, 1.995407254122385700f, 1.995381242971412600f, - 1.995355158455975200f, - 1.995329000577032800f, 1.995302769335546500f, 1.995276464732481200f, - 1.995250086768804100f, - 1.995223635445484900f, 1.995197110763496000f, 1.995170512723813100f, - 1.995143841327413400f, - 1.995117096575278200f, 1.995090278468390600f, 1.995063387007736600f, - 1.995036422194304700f, - 1.995009384029086800f, 1.994982272513076600f, 1.994955087647271000f, - 1.994927829432669800f, - 1.994900497870274900f, 1.994873092961091200f, 1.994845614706126400f, - 1.994818063106391000f, - 1.994790438162897600f, 1.994762739876662100f, 1.994734968248702800f, - 1.994707123280041100f, - 1.994679204971700100f, 1.994651213324707000f, 1.994623148340090700f, - 1.994595010018883000f, - 1.994566798362118300f, 1.994538513370834200f, 1.994510155046070700f, - 1.994481723388870100f, - 1.994453218400277900f, 1.994424640081342100f, 1.994395988433113700f, - 1.994367263456646100f, - 1.994338465152995000f, 1.994309593523219600f, 1.994280648568381500f, - 1.994251630289544600f, - 1.994222538687776100f, 1.994193373764145500f, 1.994164135519725000f, - 1.994134823955589800f, - 1.994105439072817700f, 1.994075980872488800f, 1.994046449355686200f, - 1.994016844523496000f, - 1.993987166377006600f, 1.993957414917308700f, 1.993927590145496900f, - 1.993897692062667200f, - 1.993867720669919400f, 1.993837675968354700f, 1.993807557959078600f, - 1.993777366643197900f, - 1.993747102021822900f, 1.993716764096066200f, 1.993686352867043200f, - 1.993655868335872300f, - 1.993625310503674100f, 1.993594679371572200f, 1.993563974940692800f, - 1.993533197212164800f, - 1.993502346187119700f, 1.993471421866692200f, 1.993440424252018900f, - 1.993409353344239600f, - 1.993378209144496700f, 1.993346991653935300f, 1.993315700873703200f, - 1.993284336804950900f, - 1.993252899448831400f, 1.993221388806500900f, 1.993189804879117500f, - 1.993158147667842800f, - 1.993126417173840500f, 1.993094613398277400f, 1.993062736342323000f, - 1.993030786007148800f, - 1.992998762393930000f, 1.992966665503844000f, 1.992934495338070800f, - 1.992902251897793000f, - 1.992869935184196300f, 1.992837545198469000f, 1.992805081941801700f, - 1.992772545415388200f, - 1.992739935620424700f, 1.992707252558110200f, 1.992674496229646500f, - 1.992641666636237700f, - 1.992608763779091000f, 1.992575787659416100f, 1.992542738278425300f, - 1.992509615637334100f, - 1.992476419737359900f, 1.992443150579723500f, 1.992409808165648100f, - 1.992376392496359300f, - 1.992342903573086000f, 1.992309341397059600f, 1.992275705969513800f, - 1.992241997291685400f, - 1.992208215364813700f, 1.992174360190140900f, 1.992140431768911500f, - 1.992106430102373400f, - 1.992072355191776300f, 1.992038207038373300f, 1.992003985643419700f, - 1.991969691008174100f, - 1.991935323133897000f, 1.991900882021852200f, 1.991866367673306200f, - 1.991831780089527500f, - 1.991797119271788300f, 1.991762385221362600f, 1.991727577939527600f, - 1.991692697427563300f, - 1.991657743686751700f, 1.991622716718378400f, 1.991587616523731000f, - 1.991552443104099800f, - 1.991517196460778500f, 1.991481876595062800f, 1.991446483508251500f, - 1.991411017201645500f, - 1.991375477676549100f, 1.991339864934268800f, 1.991304178976114100f, - 1.991268419803397200f, - 1.991232587417432600f, 1.991196681819537900f, 1.991160703011033200f, - 1.991124650993241400f, - 1.991088525767488200f, 1.991052327335101300f, 1.991016055697411900f, - 1.990979710855753900f, - 1.990943292811463000f, 1.990906801565878600f, 1.990870237120342400f, - 1.990833599476198800f, - 1.990796888634794400f, 1.990760104597479400f, 1.990723247365606200f, - 1.990686316940529800f, - 1.990649313323608100f, 1.990612236516201300f, 1.990575086519673200f, - 1.990537863335389400f, - 1.990500566964718400f, 1.990463197409031700f, 1.990425754669703100f, - 1.990388238748109100f, - 1.990350649645629600f, 1.990312987363646000f, 1.990275251903543600f, - 1.990237443266709400f, - 1.990199561454533600f, 1.990161606468409300f, 1.990123578309731700f, - 1.990085476979899000f, - 1.990047302480312300f, 1.990009054812374800f, 1.989970733977493000f, - 1.989932339977075900f, - 1.989893872812535000f, 1.989855332485284800f, 1.989816718996742200f, - 1.989778032348326700f, - 1.989739272541461100f, 1.989700439577570400f, 1.989661533458082100f, - 1.989622554184426800f, - 1.989583501758037700f, 1.989544376180350600f, 1.989505177452804100f, - 1.989465905576839600f, - 1.989426560553900500f, 1.989387142385433900f, 1.989347651072888900f, - 1.989308086617717500f, - 1.989268449021374300f, 1.989228738285316900f, 1.989188954411005100f, - 1.989149097399901500f, - 1.989109167253472000f, 1.989069163973184300f, 1.989029087560509700f, - 1.988988938016921000f, - 1.988948715343894900f, 1.988908419542910100f, 1.988868050615448100f, - 1.988827608562993200f, - 1.988787093387032600f, 1.988746505089055600f, 1.988705843670554500f, - 1.988665109133024500f, - 1.988624301477963200f, 1.988583420706871100f, 1.988542466821251000f, - 1.988501439822608900f, - 1.988460339712453200f, 1.988419166492295000f, 1.988377920163648000f, - 1.988336600728029000f, - 1.988295208186956700f, 1.988253742541953800f, 1.988212203794544000f, - 1.988170591946255100f, - 1.988128906998616800f, 1.988087148953161700f, 1.988045317811425700f, - 1.988003413574946000f, - 1.987961436245263800f, 1.987919385823922400f, 1.987877262312467600f, - 1.987835065712448600f, - 1.987792796025416500f, 1.987750453252925500f, 1.987708037396532800f, - 1.987665548457797400f, - 1.987622986438281700f, 1.987580351339550700f, 1.987537643163171700f, - 1.987494861910715100f, - 1.987452007583754100f, 1.987409080183863800f, 1.987366079712622900f, - 1.987323006171612500f, - 1.987279859562415900f, 1.987236639886619700f, 1.987193347145813000f, - 1.987149981341587400f, - 1.987106542475537400f, 1.987063030549260300f, 1.987019445564355700f, - 1.986975787522426100f, - 1.986932056425076800f, 1.986888252273915500f, 1.986844375070552900f, - 1.986800424816602200f, - 1.986756401513679400f, 1.986712305163403000f, 1.986668135767394300f, - 1.986623893327277500f, - 1.986579577844678900f, 1.986535189321228000f, 1.986490727758556800f, - 1.986446193158300400f, - 1.986401585522095600f, 1.986356904851583000f, 1.986312151148405200f, - 1.986267324414207500f, - 1.986222424650638400f, 1.986177451859348200f, 1.986132406041990900f, - 1.986087287200222700f, - 1.986042095335702300f, 1.985996830450091200f, 1.985951492545054100f, - 1.985906081622257300f, - 1.985860597683371000f, 1.985815040730067200f, 1.985769410764020900f, - 1.985723707786909900f, - 1.985677931800414500f, 1.985632082806217900f, 1.985586160806005700f, - 1.985540165801466200f, - 1.985494097794290800f, 1.985447956786173100f, 1.985401742778809500f, - 1.985355455773899500f, - 1.985309095773144500f, 1.985262662778249300f, 1.985216156790921000f, - 1.985169577812869500f, - 1.985122925845807400f, 1.985076200891450000f, 1.985029402951515200f, - 1.984982532027723700f, - 1.984935588121798700f, 1.984888571235466200f, 1.984841481370454900f, - 1.984794318528496200f, - 1.984747082711324100f, 1.984699773920675300f, 1.984652392158289500f, - 1.984604937425908300f, - 1.984557409725276700f, 1.984509809058142300f, 1.984462135426255000f, - 1.984414388831367900f, - 1.984366569275236400f, 1.984318676759618400f, 1.984270711286275200f, - 1.984222672856969800f, - 1.984174561473469200f, 1.984126377137541700f, 1.984078119850959200f, - 1.984029789615495900f, - 1.983981386432928800f, 1.983932910305037400f, 1.983884361233604100f, - 1.983835739220414000f, - 1.983787044267254700f, 1.983738276375916800f, 1.983689435548192900f, - 1.983640521785879200f, - 1.983591535090773800f, 1.983542475464678000f, 1.983493342909395500f, - 1.983444137426732600f, - 1.983394859018498900f, 1.983345507686505900f, 1.983296083432567900f, - 1.983246586258502700f, - 1.983197016166129400f, 1.983147373157271300f, 1.983097657233753100f, - 1.983047868397403100f, - 1.982998006650051400f, 1.982948071993531700f, 1.982898064429679900f, - 1.982847983960334600f, - 1.982797830587336800f, 1.982747604312531200f, 1.982697305137763700f, - 1.982646933064884200f, - 1.982596488095744300f, 1.982545970232199000f, 1.982495379476105800f, - 1.982444715829324600f, - 1.982393979293718200f, 1.982343169871152000f, 1.982292287563494300f, - 1.982241332372615600f, - 1.982190304300389400f, 1.982139203348692200f, 1.982088029519402300f, - 1.982036782814401900f, - 1.981985463235574700f, 1.981934070784807400f, 1.981882605463990200f, - 1.981831067275015000f, - 1.981779456219776600f, 1.981727772300172500f, 1.981676015518103500f, - 1.981624185875472000f, - 1.981572283374183800f, 1.981520308016147200f, 1.981468259803273300f, - 1.981416138737475800f, - 1.981363944820670800f, 1.981311678054777500f, 1.981259338441717400f, - 1.981206925983415300f, - 1.981154440681797800f, 1.981101882538794900f, 1.981049251556338900f, - 1.980996547736364900f, - 1.980943771080810700f, 1.980890921591616600f, 1.980837999270726100f, - 1.980785004120084700f, - 1.980731936141640900f, 1.980678795337345900f, 1.980625581709153600f, - 1.980572295259020600f, - 1.980518935988905700f, 1.980465503900771000f, 1.980411998996581200f, - 1.980358421278303200f, - 1.980304770747907300f, 1.980251047407365600f, 1.980197251258653900f, - 1.980143382303749500f, - 1.980089440544633600f, 1.980035425983289300f, 1.979981338621702200f, - 1.979927178461861500f, - 1.979872945505758000f, 1.979818639755386100f, 1.979764261212742400f, - 1.979709809879825800f, - 1.979655285758638900f, 1.979600688851186100f, 1.979546019159474900f, - 1.979491276685515300f, - 1.979436461431320000f, 1.979381573398904400f, 1.979326612590286400f, - 1.979271579007487100f, - 1.979216472652529900f, 1.979161293527440500f, 1.979106041634248100f, - 1.979050716974983800f, - 1.978995319551682100f, 1.978939849366379700f, 1.978884306421115900f, - 1.978828690717932900f, - 1.978773002258875600f, 1.978717241045991700f, 1.978661407081331100f, - 1.978605500366946700f, - 1.978549520904894000f, 1.978493468697231300f, 1.978437343746019600f, - 1.978381146053322000f, - 1.978324875621205300f, 1.978268532451738200f, 1.978212116546992100f, - 1.978155627909041300f, - 1.978099066539962900f, 1.978042432441836400f, 1.977985725616743900f, - 1.977928946066770600f, - 1.977872093794004200f, 1.977815168800534500f, 1.977758171088455100f, - 1.977701100659861300f, - 1.977643957516851400f, 1.977586741661526500f, 1.977529453095990200f, - 1.977472091822348700f, - 1.977414657842711200f, 1.977357151159189400f, 1.977299571773897700f, - 1.977241919688953000f, - 1.977184194906475000f, 1.977126397428586000f, 1.977068527257411300f, - 1.977010584395078300f, - 1.976952568843717700f, 1.976894480605462500f, 1.976836319682448300f, - 1.976778086076813600f, - 1.976719779790699500f, 1.976661400826249500f, 1.976602949185610500f, - 1.976544424870931400f, - 1.976485827884363800f, 1.976427158228062100f, 1.976368415904183900f, - 1.976309600914888400f, - 1.976250713262338600f, 1.976191752948699200f, 1.976132719976138000f, - 1.976073614346825800f, - 1.976014436062935700f, 1.975955185126643300f, 1.975895861540127200f, - 1.975836465305568400f, - 1.975776996425151000f, 1.975717454901061400f, 1.975657840735488800f, - 1.975598153930624900f, - 1.975538394488664200f, 1.975478562411804100f, 1.975418657702244300f, - 1.975358680362187400f, - 1.975298630393838500f, 1.975238507799405500f, 1.975178312581099100f, - 1.975118044741132300f, - 1.975057704281721000f, 1.974997291205083700f, 1.974936805513442000f, - 1.974876247209019100f, - 1.974815616294042200f, 1.974754912770740200f, 1.974694136641345300f, - 1.974633287908091500f, - 1.974572366573216400f, 1.974511372638960000f, 1.974450306107564900f, - 1.974389166981275900f, - 1.974327955262341400f, 1.974266670953011400f, 1.974205314055540000f, - 1.974143884572182400f, - 1.974082382505197400f, 1.974020807856846400f, 1.973959160629393100f, - 1.973897440825104200f, - 1.973835648446248900f, 1.973773783495099500f, 1.973711845973930000f, - 1.973649835885018100f, - 1.973587753230643400f, 1.973525598013088800f, 1.973463370234639600f, - 1.973401069897583200f, - 1.973338697004211100f, 1.973276251556815600f, 1.973213733557693400f, - 1.973151143009142800f, - 1.973088479913465100f, 1.973025744272964200f, 1.972962936089946800f, - 1.972900055366722000f, - 1.972837102105601900f, 1.972774076308901200f, 1.972710977978936900f, - 1.972647807118029300f, - 1.972584563728500700f, 1.972521247812676600f, 1.972457859372884500f, - 1.972394398411455800f, - 1.972330864930723200f, 1.972267258933022600f, 1.972203580420693000f, - 1.972139829396075200f, - 1.972076005861513700f, 1.972012109819354600f, 1.971948141271947500f, - 1.971884100221644300f, - 1.971819986670799500f, 1.971755800621770400f, 1.971691542076916800f, - 1.971627211038601500f, - 1.971562807509189800f, 1.971498331491049700f, 1.971433782986551400f, - 1.971369161998068400f, - 1.971304468527976800f, 1.971239702578655000f, 1.971174864152484400f, - 1.971109953251848600f, - 1.971044969879134600f, 1.970979914036731500f, 1.970914785727030800f, - 1.970849584952427900f, - 1.970784311715319400f, 1.970718966018105500f, 1.970653547863188600f, - 1.970588057252973900f, - 1.970522494189869800f, 1.970456858676286300f, 1.970391150714636800f, - 1.970325370307337100f, - 1.970259517456806100f, 1.970193592165464700f, 1.970127594435737000f, - 1.970061524270049400f, - 1.969995381670831100f, 1.969929166640514100f, 1.969862879181532700f, - 1.969796519296324300f, - 1.969730086987328900f, 1.969663582256988600f, 1.969597005107748900f, - 1.969530355542057800f, - 1.969463633562365400f, 1.969396839171125200f, 1.969329972370792700f, - 1.969263033163826800f, - 1.969196021552688500f, 1.969128937539841500f, 1.969061781127752400f, - 1.968994552318890300f, - 1.968927251115727200f, 1.968859877520737300f, 1.968792431536398000f, - 1.968724913165188900f, - 1.968657322409592500f, 1.968589659272094000f, 1.968521923755181000f, - 1.968454115861344000f, - 1.968386235593076300f, 1.968318282952873600f, 1.968250257943234200f, - 1.968182160566659000f, - 1.968113990825652200f, 1.968045748722719900f, 1.967977434260371300f, - 1.967909047441118100f, - 1.967840588267474500f, 1.967772056741957900f, 1.967703452867087800f, - 1.967634776645386600f, - 1.967566028079379200f, 1.967497207171593500f, 1.967428313924559600f, - 1.967359348340810700f, - 1.967290310422882700f, 1.967221200173313400f, 1.967152017594644200f, - 1.967082762689418500f, - 1.967013435460182700f, 1.966944035909485600f, 1.966874564039879300f, - 1.966805019853917500f, - 1.966735403354157500f, 1.966665714543159000f, 1.966595953423483800f, - 1.966526119997697100f, - 1.966456214268366600f, 1.966386236238062200f, 1.966316185909357200f, - 1.966246063284826700f, - 1.966175868367049400f, 1.966105601158605600f, 1.966035261662079300f, - 1.965964849880056600f, - 1.965894365815126000f, 1.965823809469879400f, 1.965753180846910900f, - 1.965682479948817100f, - 1.965611706778197700f, 1.965540861337654600f, 1.965469943629792700f, - 1.965398953657219600f, - 1.965327891422544900f, 1.965256756928382100f, 1.965185550177345900f, - 1.965114271172054800f, - 1.965042919915129400f, 1.964971496409193100f, 1.964900000656872000f, - 1.964828432660794500f, - 1.964756792423592200f, 1.964685079947899200f, 1.964613295236352000f, - 1.964541438291590000f, - 1.964469509116255000f, 1.964397507712991800f, 1.964325434084447600f, - 1.964253288233272400f, - 1.964181070162119000f, 1.964108779873642100f, 1.964036417370500300f, - 1.963963982655353400f, - 1.963891475730865400f, 1.963818896599701400f, 1.963746245264530700f, - 1.963673521728023900f, - 1.963600725992855200f, 1.963527858061700600f, 1.963454917937239800f, - 1.963381905622154400f, - 1.963308821119128700f, 1.963235664430850200f, 1.963162435560008100f, - 1.963089134509295300f, - 1.963015761281406800f, 1.962942315879040000f, 1.962868798304895400f, - 1.962795208561676200f, - 1.962721546652088200f, 1.962647812578839400f, 1.962574006344640900f, - 1.962500127952206300f, - 1.962426177404252200f, 1.962352154703497200f, 1.962278059852663000f, - 1.962203892854473800f, - 1.962129653711656800f, 1.962055342426941400f, 1.961980959003059500f, - 1.961906503442746300f, - 1.961831975748739200f, 1.961757375923778700f, 1.961682703970607100f, - 1.961607959891970200f, - 1.961533143690616000f, 1.961458255369295400f, 1.961383294930761700f, - 1.961308262377770900f, - 1.961233157713082200f, 1.961157980939456400f, 1.961082732059657800f, - 1.961007411076453000f, - 1.960932017992611500f, 1.960856552810905200f, 1.960781015534108800f, - 1.960705406164999300f, - 1.960629724706357100f, 1.960553971160964500f, 1.960478145531606700f, - 1.960402247821071900f, - 1.960326278032150200f, 1.960250236167635100f, 1.960174122230322400f, - 1.960097936223010400f, - 1.960021678148500500f, 1.959945348009596500f, 1.959868945809104500f, - 1.959792471549834000f, - 1.959715925234596600f, 1.959639306866206600f, 1.959562616447480900f, - 1.959485853981239600f, - 1.959409019470304700f, 1.959332112917501400f, 1.959255134325657000f, - 1.959178083697602300f, - 1.959100961036169800f, 1.959023766344195200f, 1.958946499624516700f, - 1.958869160879975500f, - 1.958791750113414700f, 1.958714267327680500f, 1.958636712525621900f, - 1.958559085710090500f, - 1.958481386883940100f, 1.958403616050027600f, 1.958325773211212300f, - 1.958247858370356400f, - 1.958169871530324600f, 1.958091812693984400f, 1.958013681864205500f, - 1.957935479043860600f, - 1.957857204235825100f, 1.957778857442976900f, 1.957700438668196700f, - 1.957621947914367500f, - 1.957543385184375300f, 1.957464750481108700f, 1.957386043807458800f, - 1.957307265166319500f, - 1.957228414560587200f, 1.957149491993160900f, 1.957070497466942400f, - 1.956991430984836400f, - 1.956912292549749500f, 1.956833082164591600f, 1.956753799832275300f, - 1.956674445555715000f, - 1.956595019337829000f, 1.956515521181537000f, 1.956435951089762200f, - 1.956356309065430100f, - 1.956276595111468900f, 1.956196809230809500f, 1.956116951426385600f, - 1.956037021701132900f, - 1.955957020057990500f, 1.955876946499899700f, 1.955796801029804800f, - 1.955716583650652000f, - 1.955636294365391300f, 1.955555933176974300f, 1.955475500088355900f, - 1.955394995102493100f, - 1.955314418222346100f, 1.955233769450877200f, 1.955153048791052000f, - 1.955072256245838000f, - 1.954991391818206000f, 1.954910455511129000f, 1.954829447327582900f, - 1.954748367270545900f, - 1.954667215342999600f, 1.954585991547927100f, 1.954504695888315000f, - 1.954423328367152600f, - 1.954341888987431100f, 1.954260377752145000f, 1.954178794664291200f, - 1.954097139726869600f, - 1.954015412942881900f, 1.953933614315333200f, 1.953851743847231100f, - 1.953769801541585400f, - 1.953687787401409400f, 1.953605701429718100f, 1.953523543629529700f, - 1.953441314003864900f, - 1.953359012555747200f, 1.953276639288202400f, 1.953194194204259200f, - 1.953111677306948800f, - 1.953029088599305100f, 1.952946428084364900f, 1.952863695765167100f, - 1.952780891644753500f, - 1.952698015726169100f, 1.952615068012460300f, 1.952532048506677300f, - 1.952448957211872200f, - 1.952365794131100300f, 1.952282559267419100f, 1.952199252623889200f, - 1.952115874203572900f, - 1.952032424009536600f, 1.951948902044847900f, 1.951865308312577900f, - 1.951781642815800100f, - 1.951697905557590700f, 1.951614096541028500f, 1.951530215769194700f, - 1.951446263245173500f, - 1.951362238972051500f, 1.951278142952918200f, 1.951193975190865600f, - 1.951109735688987900f, - 1.951025424450382900f, 1.950941041478150100f, 1.950856586775392200f, - 1.950772060345214300f, - 1.950687462190724200f, 1.950602792315032200f, 1.950518050721251600f, - 1.950433237412498000f, - 1.950348352391889600f, 1.950263395662547700f, 1.950178367227595900f, - 1.950093267090159800f, - 1.950008095253369200f, 1.949922851720355100f, 1.949837536494251700f, - 1.949752149578196000f, - 1.949666690975327100f, 1.949581160688787400f, 1.949495558721721500f, - 1.949409885077276500f, - 1.949324139758602700f, 1.949238322768852800f, 1.949152434111181700f, - 1.949066473788747300f, - 1.948980441804710300f, 1.948894338162233900f, 1.948808162864483600f, - 1.948721915914628100f, - 1.948635597315838200f, 1.948549207071288000f, 1.948462745184153400f, - 1.948376211657613500f, - 1.948289606494849800f, 1.948202929699046800f, 1.948116181273391100f, - 1.948029361221072400f, - 1.947942469545282500f, 1.947855506249216700f, 1.947768471336071700f, - 1.947681364809048100f, - 1.947594186671348000f, 1.947506936926177300f, 1.947419615576743600f, - 1.947332222626257500f, - 1.947244758077932200f, 1.947157221934983500f, 1.947069614200629900f, - 1.946981934878092300f, - 1.946894183970594900f, 1.946806361481363500f, 1.946718467413627300f, - 1.946630501770618000f, - 1.946542464555569800f, 1.946454355771719300f, 1.946366175422306500f, - 1.946277923510573200f, - 1.946189600039764300f, 1.946101205013127000f, 1.946012738433911600f, - 1.945924200305370700f, - 1.945835590630759400f, 1.945746909413335900f, 1.945658156656360700f, - 1.945569332363096700f, - 1.945480436536810100f, 1.945391469180769200f, 1.945302430298244900f, - 1.945213319892511200f, - 1.945124137966844200f, 1.945034884524523100f, 1.944945559568829200f, - 1.944856163103046800f, - 1.944766695130463000f, 1.944677155654366900f, 1.944587544678050900f, - 1.944497862204809900f, - 1.944408108237940700f, 1.944318282780743900f, 1.944228385836521700f, - 1.944138417408579400f, - 1.944048377500225100f, 1.943958266114769200f, 1.943868083255524800f, - 1.943777828925807600f, - 1.943687503128936200f, 1.943597105868231500f, 1.943506637147017300f, - 1.943416096968619400f, - 1.943325485336367300f, 1.943234802253592400f, 1.943144047723628400f, - 1.943053221749812400f, - 1.942962324335484100f, 1.942871355483985200f, 1.942780315198660200f, - 1.942689203482856900f, - 1.942598020339924700f, 1.942506765773216500f, 1.942415439786087300f, - 1.942324042381895000f, - 1.942232573564000000f, 1.942141033335765400f, 1.942049421700556600f, - 1.941957738661741900f, - 1.941865984222692900f, 1.941774158386782200f, 1.941682261157386700f, - 1.941590292537884700f, - 1.941498252531658200f, 1.941406141142090600f, 1.941313958372568900f, - 1.941221704226482500f, - 1.941129378707223000f, 1.941036981818185400f, 1.940944513562766300f, - 1.940851973944365900f, - 1.940759362966386600f, 1.940666680632233200f, 1.940573926945313700f, - 1.940481101909038200f, - 1.940388205526819600f, 1.940295237802073500f, 1.940202198738217900f, - 1.940109088338673600f, - 1.940015906606864300f, 1.939922653546215500f, 1.939829329160156500f, - 1.939735933452118000f, - 1.939642466425534300f, 1.939548928083841800f, 1.939455318430479500f, - 1.939361637468889100f, - 1.939267885202515400f, 1.939174061634805000f, 1.939080166769207700f, - 1.938986200609175600f, - 1.938892163158163700f, 1.938798054419629500f, 1.938703874397032800f, - 1.938609623093837000f, - 1.938515300513506700f, 1.938420906659510600f, 1.938326441535318500f, - 1.938231905144404400f, - 1.938137297490243500f, 1.938042618576314400f, 1.937947868406098500f, - 1.937853046983079300f, - 1.937758154310742900f, 1.937663190392578500f, 1.937568155232077600f, - 1.937473048832734500f, - 1.937377871198045600f, 1.937282622331510500f, 1.937187302236631500f, - 1.937091910916912900f, - 1.936996448375861900f, 1.936900914616988900f, 1.936805309643805800f, - 1.936709633459828200f, - 1.936613886068573500f, 1.936518067473562300f, 1.936422177678317300f, - 1.936326216686364400f, - 1.936230184501231500f, 1.936134081126449800f, 1.936037906565552400f, - 1.935941660822075600f, - 1.935845343899558000f, 1.935748955801540800f, 1.935652496531568000f, - 1.935555966093186300f, - 1.935459364489944500f, 1.935362691725394500f, 1.935265947803090900f, - 1.935169132726590500f, - 1.935072246499453000f, 1.934975289125240500f, 1.934878260607517900f, - 1.934781160949852600f, - 1.934683990155814800f, 1.934586748228977100f, 1.934489435172914900f, - 1.934392050991206300f, - 1.934294595687431300f, 1.934197069265173500f, 1.934099471728018700f, - 1.934001803079554700f, - 1.933904063323373300f, 1.933806252463067500f, 1.933708370502233800f, - 1.933610417444471000f, - 1.933512393293380600f, 1.933414298052566600f, 1.933316131725635800f, - 1.933217894316197300f, - 1.933119585827862900f, 1.933021206264247600f, 1.932922755628968100f, - 1.932824233925644300f, - 1.932725641157898600f, 1.932626977329356100f, 1.932528242443643900f, - 1.932429436504392800f, - 1.932330559515235100f, 1.932231611479806800f, 1.932132592401745400f, - 1.932033502284691700f, - 1.931934341132289100f, 1.931835108948183300f, 1.931735805736022800f, - 1.931636431499459000f, - 1.931536986242145200f, 1.931437469967737900f, 1.931337882679895900f, - 1.931238224382281000f, - 1.931138495078557300f, 1.931038694772391200f, 1.930938823467452500f, - 1.930838881167413100f, - 1.930738867875947400f, 1.930638783596732700f, 1.930538628333448900f, - 1.930438402089778200f, - 1.930338104869405900f, 1.930237736676019500f, 1.930137297513309300f, - 1.930036787384968200f, - 1.929936206294691400f, 1.929835554246177400f, 1.929734831243126600f, - 1.929634037289242400f, - 1.929533172388230700f, 1.929432236543799900f, 1.929331229759661200f, - 1.929230152039528500f, - 1.929129003387117800f, 1.929027783806148300f, 1.928926493300341400f, - 1.928825131873421500f, - 1.928723699529115000f, 1.928622196271151800f, 1.928520622103263400f, - 1.928418977029184600f, - 1.928317261052652700f, 1.928215474177407100f, 1.928113616407190600f, - 1.928011687745748300f, - 1.927909688196827400f, 1.927807617764178300f, 1.927705476451554000f, - 1.927603264262709900f, - 1.927500981201404100f, 1.927398627271397000f, 1.927296202476451900f, - 1.927193706820335100f, - 1.927091140306814500f, 1.926988502939661400f, 1.926885794722649600f, - 1.926783015659555300f, - 1.926680165754157500f, 1.926577245010237400f, 1.926474253431579500f, - 1.926371191021970100f, - 1.926268057785198700f, 1.926164853725057300f, 1.926061578845340600f, - 1.925958233149845000f, - 1.925854816642371000f, 1.925751329326720600f, 1.925647771206698600f, - 1.925544142286112800f, - 1.925440442568773000f, 1.925336672058492300f, 1.925232830759086000f, - 1.925128918674371900f, - 1.925024935808170600f, 1.924920882164305300f, 1.924816757746601800f, - 1.924712562558888100f, - 1.924608296604995800f, 1.924503959888757900f, 1.924399552414010700f, - 1.924295074184593000f, - 1.924190525204346300f, 1.924085905477114400f, 1.923981215006744100f, - 1.923876453797084300f, - 1.923771621851986700f, 1.923666719175306100f, 1.923561745770898900f, - 1.923456701642625200f, - 1.923351586794346900f, 1.923246401229928600f, 1.923141144953238300f, - 1.923035817968145300f, - 1.922930420278522500f, 1.922824951888245000f, 1.922719412801190600f, - 1.922613803021239600f, - 1.922508122552275100f, 1.922402371398182600f, 1.922296549562850100f, - 1.922190657050168800f, - 1.922084693864031700f, 1.921978660008334600f, 1.921872555486976700f, - 1.921766380303858500f, - 1.921660134462884100f, 1.921553817967959900f, 1.921447430822994500f, - 1.921340973031900000f, - 1.921234444598590100f, 1.921127845526981600f, 1.921021175820994100f, - 1.920914435484549100f, - 1.920807624521571700f, 1.920700742935988600f, 1.920593790731729600f, - 1.920486767912727300f, - 1.920379674482916500f, 1.920272510446234400f, 1.920165275806621400f, - 1.920057970568020100f, - 1.919950594734376000f, 1.919843148309637000f, 1.919735631297753400f, - 1.919628043702678300f, - 1.919520385528367300f, 1.919412656778779000f, 1.919304857457874200f, - 1.919196987569616200f, - 1.919089047117971100f, 1.918981036106907700f, 1.918872954540397300f, - 1.918764802422413500f, - 1.918656579756932800f, 1.918548286547934400f, 1.918439922799399800f, - 1.918331488515313300f, - 1.918222983699661600f, 1.918114408356434300f, 1.918005762489623400f, - 1.917897046103223200f, - 1.917788259201231200f, 1.917679401787647100f, 1.917570473866473200f, - 1.917461475441714500f, - 1.917352406517378600f, 1.917243267097475700f, 1.917134057186018300f, - 1.917024776787022100f, - 1.916915425904504700f, 1.916806004542486800f, 1.916696512704991500f, - 1.916586950396044400f, - 1.916477317619674100f, 1.916367614379911100f, 1.916257840680788900f, - 1.916147996526343700f, - 1.916038081920614400f, 1.915928096867641800f, 1.915818041371470000f, - 1.915707915436145200f, - 1.915597719065716700f, 1.915487452264236000f, 1.915377115035757200f, - 1.915266707384337200f, - 1.915156229314035200f, 1.915045680828913400f, 1.914935061933036300f, - 1.914824372630470800f, - 1.914713612925287100f, 1.914602782821557000f, 1.914491882323355700f, - 1.914380911434760500f, - 1.914269870159851700f, 1.914158758502712000f, 1.914047576467426500f, - 1.913936324058083100f, - 1.913825001278772100f, 1.913713608133586600f, 1.913602144626622500f, - 1.913490610761977600f, - 1.913379006543752800f, 1.913267331976051400f, 1.913155587062979500f, - 1.913043771808645700f, - 1.912931886217160900f, 1.912819930292639000f, 1.912707904039196300f, - 1.912595807460951500f, - 1.912483640562026200f, 1.912371403346544400f, 1.912259095818632700f, - 1.912146717982420500f, - 1.912034269842039600f, 1.911921751401624200f, 1.911809162665311500f, - 1.911696503637241100f, - 1.911583774321554700f, 1.911470974722397500f, 1.911358104843916500f, - 1.911245164690262000f, - 1.911132154265586100f, 1.911019073574044200f, 1.910905922619793800f, - 1.910792701406995000f, - 1.910679409939810600f, 1.910566048222406300f, 1.910452616258949900f, - 1.910339114053611900f, - 1.910225541610565800f, 1.910111898933986900f, 1.909998186028053700f, - 1.909884402896947100f, - 1.909770549544850500f, 1.909656625975950200f, 1.909542632194434700f, - 1.909428568204495100f, - 1.909314434010325400f, 1.909200229616121700f, 1.909085955026083200f, - 1.908971610244411600f, - 1.908857195275310800f, 1.908742710122987700f, 1.908628154791651300f, - 1.908513529285513500f, - 1.908398833608789100f, 1.908284067765694900f, 1.908169231760450400f, - 1.908054325597278200f, - 1.907939349280402400f, 1.907824302814050900f, 1.907709186202453600f, - 1.907593999449842800f, - 1.907478742560453600f, 1.907363415538523700f, 1.907248018388293400f, - 1.907132551114005600f, - 1.907017013719905600f, 1.906901406210241200f, 1.906785728589263300f, - 1.906669980861224900f, - 1.906554163030381500f, 1.906438275100991600f, 1.906322317077316300f, - 1.906206288963618700f, - 1.906090190764164700f, 1.905974022483223300f, 1.905857784125065500f, - 1.905741475693964800f, - 1.905625097194197900f, 1.905508648630043700f, 1.905392130005783400f, - 1.905275541325701400f, - 1.905158882594083900f, 1.905042153815220700f, 1.904925354993402900f, - 1.904808486132925300f, - 1.904691547238084800f, 1.904574538313180700f, 1.904457459362515200f, - 1.904340310390393100f, - 1.904223091401121600f, 1.904105802399010300f, 1.903988443388371600f, - 1.903871014373520700f, - 1.903753515358774800f, 1.903635946348454500f, 1.903518307346881800f, - 1.903400598358382600f, - 1.903282819387284200f, 1.903164970437917400f, 1.903047051514615000f, - 1.902929062621712600f, - 1.902811003763547900f, 1.902692874944462300f, 1.902574676168798700f, - 1.902456407440902700f, - 1.902338068765123200f, 1.902219660145810800f, 1.902101181587319000f, - 1.901982633094004200f, - 1.901864014670225000f, 1.901745326320342500f, 1.901626568048721000f, - 1.901507739859726200f, - 1.901388841757727600f, 1.901269873747096600f, 1.901150835832207100f, - 1.901031728017436300f, - 1.900912550307162700f, 1.900793302705768900f, 1.900673985217638900f, - 1.900554597847159400f, - 1.900435140598720500f, 1.900315613476714100f, 1.900196016485534700f, - 1.900076349629579600f, - 1.899956612913248800f, 1.899836806340944300f, 1.899716929917071500f, - 1.899596983646037600f, - 1.899476967532252900f, 1.899356881580129800f, 1.899236725794083600f, - 1.899116500178532200f, - 1.898996204737895900f, 1.898875839476597700f, 1.898755404399062900f, - 1.898634899509719500f, - 1.898514324812998300f, 1.898393680313332600f, 1.898272966015157800f, - 1.898152181922912600f, - 1.898031328041037700f, 1.897910404373976500f, 1.897789410926175000f, - 1.897668347702081900f, - 1.897547214706148300f, 1.897426011942827900f, 1.897304739416577200f, - 1.897183397131854600f, - 1.897061985093121800f, 1.896940503304842800f, 1.896818951771484000f, - 1.896697330497514800f, - 1.896575639487406300f, 1.896453878745633100f, 1.896332048276672100f, - 1.896210148085002400f, - 1.896088178175106200f, 1.895966138551467700f, 1.895844029218574100f, - 1.895721850180915000f, - 1.895599601442982600f, 1.895477283009271400f, 1.895354894884279100f, - 1.895232437072505300f, - 1.895109909578452500f, 1.894987312406625700f, 1.894864645561532100f, - 1.894741909047682500f, - 1.894619102869589100f, 1.894496227031767100f, 1.894373281538734400f, - 1.894250266395011600f, - 1.894127181605121100f, 1.894004027173588700f, 1.893880803104942600f, - 1.893757509403713100f, - 1.893634146074433500f, 1.893510713121639300f, 1.893387210549869000f, - 1.893263638363663400f, - 1.893139996567565900f, 1.893016285166122500f, 1.892892504163881600f, - 1.892768653565394300f, - 1.892644733375214300f, 1.892520743597897700f, 1.892396684238003300f, - 1.892272555300092300f, - 1.892148356788728700f, 1.892024088708479200f, 1.891899751063912200f, - 1.891775343859599400f, - 1.891650867100115300f, 1.891526320790036100f, 1.891401704933941100f, - 1.891277019536412400f, - 1.891152264602033800f, 1.891027440135392600f, 1.890902546141078000f, - 1.890777582623682300f, - 1.890652549587799700f, 1.890527447038027300f, 1.890402274978965100f, - 1.890277033415215200f, - 1.890151722351382200f, 1.890026341792073500f, 1.889900891741899100f, - 1.889775372205471300f, - 1.889649783187405100f, 1.889524124692318200f, 1.889398396724830500f, - 1.889272599289564900f, - 1.889146732391146400f, 1.889020796034202700f, 1.888894790223364600f, - 1.888768714963264400f, - 1.888642570258537700f, 1.888516356113822700f, 1.888390072533759700f, - 1.888263719522991900f, - 1.888137297086165000f, 1.888010805227927000f, 1.887884243952928600f, - 1.887757613265823400f, - 1.887630913171267000f, 1.887504143673917700f, 1.887377304778437000f, - 1.887250396489487800f, - 1.887123418811736500f, 1.886996371749851700f, 1.886869255308504200f, - 1.886742069492368000f, - 1.886614814306119400f, 1.886487489754437300f, 1.886360095842002600f, - 1.886232632573499700f, - 1.886105099953614900f, 1.885977497987037000f, 1.885849826678457800f, - 1.885722086032571200f, - 1.885594276054074300f, 1.885466396747665700f, 1.885338448118047700f, - 1.885210430169924200f, - 1.885082342908002400f, 1.884954186336991400f, 1.884825960461603100f, - 1.884697665286552400f, - 1.884569300816556000f, 1.884440867056333700f, 1.884312364010607600f, - 1.884183791684102400f, - 1.884055150081545200f, 1.883926439207665800f, 1.883797659067196800f, - 1.883668809664872600f, - 1.883539891005431100f, 1.883410903093611900f, 1.883281845934157800f, - 1.883152719531813800f, - 1.883023523891327300f, 1.882894259017448900f, 1.882764924914930700f, - 1.882635521588528400f, - 1.882506049042999700f, 1.882376507283104900f, 1.882246896313606800f, - 1.882117216139270700f, - 1.881987466764865100f, 1.881857648195159900f, 1.881727760434928500f, - 1.881597803488946500f, - 1.881467777361992100f, 1.881337682058845700f, 1.881207517584290600f, - 1.881077283943112900f, - 1.880946981140100500f, 1.880816609180044700f, 1.880686168067738500f, - 1.880555657807977800f, - 1.880425078405561600f, 1.880294429865290600f, 1.880163712191968300f, - 1.880032925390400900f, - 1.879902069465397200f, 1.879771144421768200f, 1.879640150264327600f, - 1.879509086997891900f, - 1.879377954627279700f, 1.879246753157312700f, 1.879115482592814500f, - 1.878984142938611600f, - 1.878852734199532900f, 1.878721256380410100f, 1.878589709486077300f, - 1.878458093521370800f, - 1.878326408491130200f, 1.878194654400196600f, 1.878062831253414900f, - 1.877930939055631100f, - 1.877798977811695200f, 1.877666947526458700f, 1.877534848204775800f, - 1.877402679851504000f, - 1.877270442471502100f, 1.877138136069632400f, 1.877005760650759500f, - 1.876873316219750200f, - 1.876740802781474500f, 1.876608220340804100f, 1.876475568902614000f, - 1.876342848471781200f, - 1.876210059053185600f, 1.876077200651709500f, 1.875944273272237800f, - 1.875811276919657500f, - 1.875678211598858800f, 1.875545077314734000f, 1.875411874072178100f, - 1.875278601876088700f, - 1.875145260731365700f, 1.875011850642911600f, 1.874878371615631900f, - 1.874744823654434000f, - 1.874611206764227800f, 1.874477520949926500f, 1.874343766216444800f, - 1.874209942568701100f, - 1.874076050011615400f, 1.873942088550110400f, 1.873808058189111700f, - 1.873673958933546900f, - 1.873539790788347100f, 1.873405553758444600f, 1.873271247848775400f, - 1.873136873064277000f, - 1.873002429409890600f, 1.872867916890558900f, 1.872733335511227700f, - 1.872598685276845000f, - 1.872463966192361900f, 1.872329178262731200f, 1.872194321492908700f, - 1.872059395887852900f, - 1.871924401452524700f, 1.871789338191887100f, 1.871654206110906500f, - 1.871519005214550700f, - 1.871383735507791100f, 1.871248396995601300f, 1.871112989682956800f, - 1.870977513574836500f, - 1.870841968676221400f, 1.870706354992095000f, 1.870570672527443600f, - 1.870434921287255700f, - 1.870299101276522400f, 1.870163212500237900f, 1.870027254963397800f, - 1.869891228671001200f, - 1.869755133628049600f, 1.869618969839546500f, 1.869482737310498100f, - 1.869346436045913800f, - 1.869210066050804600f, 1.869073627330184700f, 1.868937119889070300f, - 1.868800543732480600f, - 1.868663898865437200f, 1.868527185292963700f, 1.868390403020087100f, - 1.868253552051836200f, - 1.868116632393243000f, 1.867979644049341200f, 1.867842587025167800f, - 1.867705461325761800f, - 1.867568266956164800f, 1.867431003921421500f, 1.867293672226578300f, - 1.867156271876684500f, - 1.867018802876792200f, 1.866881265231955500f, 1.866743658947231300f, - 1.866605984027679000f, - 1.866468240478360600f, 1.866330428304340300f, 1.866192547510685300f, - 1.866054598102465000f, - 1.865916580084751500f, 1.865778493462619100f, 1.865640338241145100f, - 1.865502114425408900f, - 1.865363822020492700f, 1.865225461031480900f, 1.865087031463460900f, - 1.864948533321522300f, - 1.864809966610757400f, 1.864671331336260600f, 1.864532627503129100f, - 1.864393855116463200f, - 1.864255014181364500f, 1.864116104702938000f, 1.863977126686291200f, - 1.863838080136534000f, - 1.863698965058778300f, 1.863559781458139300f, 1.863420529339734100f, - 1.863281208708683000f, - 1.863141819570107900f, 1.863002361929134500f, 1.862862835790889400f, - 1.862723241160503300f, - 1.862583578043108100f, 1.862443846443839300f, 1.862304046367834200f, - 1.862164177820232700f, - 1.862024240806177800f, 1.861884235330814300f, 1.861744161399289600f, - 1.861604019016754200f, - 1.861463808188360500f, 1.861323528919263800f, 1.861183181214621600f, - 1.861042765079594200f, - 1.860902280519344500f, 1.860761727539037300f, 1.860621106143840500f, - 1.860480416338924600f, - 1.860339658129461800f, 1.860198831520627900f, 1.860057936517600700f, - 1.859916973125560000f, - 1.859775941349689000f, 1.859634841195173100f, 1.859493672667199800f, - 1.859352435770959900f, - 1.859211130511645900f, 1.859069756894453400f, 1.858928314924580300f, - 1.858786804607227100f, - 1.858645225947596300f, 1.858503578950893900f, 1.858361863622327400f, - 1.858220079967107600f, - 1.858078227990447300f, 1.857936307697561900f, 1.857794319093669900f, - 1.857652262183991000f, - 1.857510136973749000f, 1.857367943468169100f, 1.857225681672479300f, - 1.857083351591910300f, - 1.856940953231694900f, 1.856798486597069000f, 1.856655951693270600f, - 1.856513348525540300f, - 1.856370677099121100f, 1.856227937419258700f, 1.856085129491201100f, - 1.855942253320199200f, - 1.855799308911506100f, 1.855656296270377300f, 1.855513215402071000f, - 1.855370066311848000f, - 1.855226849004971500f, 1.855083563486706900f, 1.854940209762322700f, - 1.854796787837089500f, - 1.854653297716280400f, 1.854509739405171300f, 1.854366112909040300f, - 1.854222418233168400f, - 1.854078655382838300f, 1.853934824363336200f, 1.853790925179950500f, - 1.853646957837971500f, - 1.853502922342692600f, 1.853358818699409900f, 1.853214646913421200f, - 1.853070406990027500f, - 1.852926098934532200f, 1.852781722752241000f, 1.852637278448462200f, - 1.852492766028506400f, - 1.852348185497687300f, 1.852203536861320600f, 1.852058820124724300f, - 1.851914035293219700f, - 1.851769182372129600f, 1.851624261366780400f, 1.851479272282500000f, - 1.851334215124619300f, - 1.851189089898471800f, 1.851043896609393400f, 1.850898635262721900f, - 1.850753305863798800f, - 1.850607908417967200f, 1.850462442930572900f, 1.850316909406964200f, - 1.850171307852492200f, - 1.850025638272510000f, 1.849879900672373600f, 1.849734095057441200f, - 1.849588221433073700f, - 1.849442279804634600f, 1.849296270177489800f, 1.849150192557007300f, - 1.849004046948558200f, - 1.848857833357515900f, 1.848711551789256300f, 1.848565202249157400f, - 1.848418784742600400f, - 1.848272299274968500f, 1.848125745851647800f, 1.847979124478026100f, - 1.847832435159495000f, - 1.847685677901447200f, 1.847538852709279100f, 1.847391959588388300f, - 1.847244998544176300f, - 1.847097969582046200f, 1.846950872707404000f, 1.846803707925657600f, - 1.846656475242218300f, - 1.846509174662499300f, 1.846361806191916000f, 1.846214369835887500f, - 1.846066865599834000f, - 1.845919293489179000f, 1.845771653509348200f, 1.845623945665770100f, - 1.845476169963875500f, - 1.845328326409097400f, 1.845180415006871800f, 1.845032435762637100f, - 1.844884388681833800f, - 1.844736273769905300f, 1.844588091032297400f, 1.844439840474458200f, - 1.844291522101838800f, - 1.844143135919891900f, 1.843994681934073600f, 1.843846160149842200f, - 1.843697570572658200f, - 1.843548913207985000f, 1.843400188061288000f, 1.843251395138035800f, - 1.843102534443698900f, - 1.842953605983750400f, 1.842804609763666100f, 1.842655545788924000f, - 1.842506414065004900f, - 1.842357214597392100f, 1.842207947391570900f, 1.842058612453029600f, - 1.841909209787258900f, - 1.841759739399751800f, 1.841610201296003800f, 1.841460595481513100f, - 1.841310921961780500f, - 1.841161180742308500f, 1.841011371828603200f, 1.840861495226172600f, - 1.840711550940526700f, - 1.840561538977179200f, 1.840411459341645400f, 1.840261312039443100f, - 1.840111097076092800f, - 1.839960814457117600f, 1.839810464188043100f, 1.839660046274397100f, - 1.839509560721709800f, - 1.839359007535514400f, 1.839208386721346500f, 1.839057698284743500f, - 1.838906942231246100f, - 1.838756118566397200f, 1.838605227295741800f, 1.838454268424828400f, - 1.838303241959206700f, - 1.838152147904429800f, 1.838000986266052900f, 1.837849757049633900f, - 1.837698460260732900f, - 1.837547095904912700f, 1.837395663987738700f, 1.837244164514778600f, - 1.837092597491602100f, - 1.836940962923782700f, 1.836789260816895000f, 1.836637491176516600f, - 1.836485654008228200f, - 1.836333749317611700f, 1.836181777110252900f, 1.836029737391738700f, - 1.835877630167659800f, - 1.835725455443608200f, 1.835573213225179400f, 1.835420903517970500f, - 1.835268526327581900f, - 1.835116081659615700f, 1.834963569519677100f, 1.834810989913373500f, - 1.834658342846314800f, - 1.834505628324113200f, 1.834352846352383700f, 1.834199996936744000f, - 1.834047080082813300f, - 1.833894095796214400f, 1.833741044082571900f, 1.833587924947513100f, - 1.833434738396668000f, - 1.833281484435668400f, 1.833128163070149300f, 1.832974774305747600f, - 1.832821318148103500f, - 1.832667794602858400f, 1.832514203675657600f, 1.832360545372147900f, - 1.832206819697979000f, - 1.832053026658802700f, 1.831899166260273700f, 1.831745238508049300f, - 1.831591243407788300f, - 1.831437180965153100f, 1.831283051185808300f, 1.831128854075420500f, - 1.830974589639659000f, - 1.830820257884196100f, 1.830665858814705600f, 1.830511392436864800f, - 1.830356858756352800f, - 1.830202257778851300f, 1.830047589510044500f, 1.829892853955619200f, - 1.829738051121264600f, - 1.829583181012672400f, 1.829428243635536500f, 1.829273238995553700f, - 1.829118167098423100f, - 1.828963027949846100f, 1.828807821555527000f, 1.828652547921171900f, - 1.828497207052490100f, - 1.828341798955192900f, 1.828186323634994200f, 1.828030781097610400f, - 1.827875171348760400f, - 1.827719494394165500f, 1.827563750239549400f, 1.827407938890638600f, - 1.827252060353161500f, - 1.827096114632849700f, 1.826940101735436500f, 1.826784021666658400f, - 1.826627874432253700f, - 1.826471660037963800f, 1.826315378489531800f, 1.826159029792704400f, - 1.826002613953229500f, - 1.825846130976858100f, 1.825689580869344100f, 1.825532963636443000f, - 1.825376279283913200f, - 1.825219527817515800f, 1.825062709243013800f, 1.824905823566173000f, - 1.824748870792761900f, - 1.824591850928550800f, 1.824434763979313300f, 1.824277609950824700f, - 1.824120388848863300f, - 1.823963100679209600f, 1.823805745447646600f, 1.823648323159960100f, - 1.823490833821937600f, - 1.823333277439369600f, 1.823175654018049300f, 1.823017963563772000f, - 1.822860206082335300f, - 1.822702381579539800f, 1.822544490061187800f, 1.822386531533084900f, - 1.822228506001038800f, - 1.822070413470859600f, 1.821912253948359700f, 1.821754027439354400f, - 1.821595733949661100f, - 1.821437373485099900f, 1.821278946051493100f, 1.821120451654665700f, - 1.820961890300445400f, - 1.820803261994661500f, 1.820644566743146800f, 1.820485804551735800f, - 1.820326975426265600f, - 1.820168079372576300f, 1.820009116396509800f, 1.819850086503910700f, - 1.819690989700625900f, - 1.819531825992505500f, 1.819372595385401000f, 1.819213297885166900f, - 1.819053933497660300f, - 1.818894502228740600f, 1.818735004084269600f, 1.818575439070111200f, - 1.818415807192132600f, - 1.818256108456203000f, 1.818096342868193800f, 1.817936510433979300f, - 1.817776611159436000f, - 1.817616645050443000f, 1.817456612112881900f, 1.817296512352636300f, - 1.817136345775592900f, - 1.816976112387640700f, 1.816815812194670700f, 1.816655445202576700f, - 1.816495011417255300f, - 1.816334510844604700f, 1.816173943490526400f, 1.816013309360923900f, - 1.815852608461703300f, - 1.815691840798773000f, 1.815531006378043900f, 1.815370105205429600f, - 1.815209137286846200f, - 1.815048102628211500f, 1.814887001235446600f, 1.814725833114474700f, - 1.814564598271221300f, - 1.814403296711615000f, 1.814241928441585800f, 1.814080493467067300f, - 1.813918991793994900f, - 1.813757423428306000f, 1.813595788375941700f, 1.813434086642844400f, - 1.813272318234959700f, - 1.813110483158235400f, 1.812948581418621500f, 1.812786613022070700f, - 1.812624577974538000f, - 1.812462476281981200f, 1.812300307950360300f, 1.812138072985637800f, - 1.811975771393778300f, - 1.811813403180749300f, 1.811650968352521000f, 1.811488466915065000f, - 1.811325898874356800f, - 1.811163264236372900f, 1.811000563007093100f, 1.810837795192499400f, - 1.810674960798576600f, - 1.810512059831311400f, 1.810349092296693400f, 1.810186058200714100f, - 1.810022957549368000f, - 1.809859790348652200f, 1.809696556604565300f, 1.809533256323109200f, - 1.809369889510288100f, - 1.809206456172108200f, 1.809042956314578900f, 1.808879389943711200f, - 1.808715757065519200f, - 1.808552057686019200f, 1.808388291811230000f, 1.808224459447172800f, - 1.808060560599871200f, - 1.807896595275351200f, 1.807732563479641300f, 1.807568465218772900f, - 1.807404300498778800f, - 1.807240069325695400f, 1.807075771705560800f, 1.806911407644415700f, - 1.806746977148303300f, - 1.806582480223269500f, 1.806417916875362000f, 1.806253287110631600f, - 1.806088590935131000f, - 1.805923828354915900f, 1.805758999376044100f, 1.805594104004575800f, - 1.805429142246573600f, - 1.805264114108102900f, 1.805099019595231200f, 1.804933858714028700f, - 1.804768631470567500f, - 1.804603337870923000f, 1.804437977921172300f, 1.804272551627395400f, - 1.804107058995674500f, - 1.803941500032094200f, 1.803775874742741500f, 1.803610183133706400f, - 1.803444425211080400f, - 1.803278600980958300f, 1.803112710449436900f, 1.802946753622615400f, - 1.802780730506595700f, - 1.802614641107481900f, 1.802448485431380900f, 1.802282263484401300f, - 1.802115975272655000f, - 1.801949620802255600f, 1.801783200079319900f, 1.801616713109966300f, - 1.801450159900316300f, - 1.801283540456493700f, 1.801116854784624400f, 1.800950102890836800f, - 1.800783284781262200f, - 1.800616400462033800f, 1.800449449939287800f, 1.800282433219162000f, - 1.800115350307797600f, - 1.799948201211337500f, 1.799780985935927300f, 1.799613704487715200f, - 1.799446356872851400f, - 1.799278943097489100f, 1.799111463167783400f, 1.798943917089892000f, - 1.798776304869975200f, - 1.798608626514195800f, 1.798440882028718500f, 1.798273071419711000f, - 1.798105194693343500f, - 1.797937251855787700f, 1.797769242913218800f, 1.797601167871813800f, - 1.797433026737752700f, - 1.797264819517217200f, 1.797096546216391900f, 1.796928206841463800f, - 1.796759801398622100f, - 1.796591329894058800f, 1.796422792333968000f, 1.796254188724546500f, - 1.796085519071992900f, - 1.795916783382509200f, 1.795747981662299200f, 1.795579113917569200f, - 1.795410180154527900f, - 1.795241180379386800f, 1.795072114598359200f, 1.794902982817661500f, - 1.794733785043511900f, - 1.794564521282131300f, 1.794395191539743400f, 1.794225795822573600f, - 1.794056334136850300f, - 1.793886806488804100f, 1.793717212884667900f, 1.793547553330677300f, - 1.793377827833070100f, - 1.793208036398086900f, 1.793038179031970000f, 1.792868255740965000f, - 1.792698266531319400f, - 1.792528211409282900f, 1.792358090381108300f, 1.792187903453050100f, - 1.792017650631366100f, - 1.791847331922315600f, 1.791676947332161000f, 1.791506496867166600f, - 1.791335980533599300f, - 1.791165398337728900f, 1.790994750285827000f, 1.790824036384167900f, - 1.790653256639028100f, - 1.790482411056686800f, 1.790311499643425500f, 1.790140522405528200f, - 1.789969479349281100f, - 1.789798370480973000f, 1.789627195806895200f, 1.789455955333341100f, - 1.789284649066606800f, - 1.789113277012990900f, 1.788941839178794100f, 1.788770335570319700f, - 1.788598766193873600f, - 1.788427131055763600f, 1.788255430162300400f, 1.788083663519796800f, - 1.787911831134568300f, - 1.787739933012932900f, 1.787567969161210300f, 1.787395939585723500f, - 1.787223844292797500f, - 1.787051683288759500f, 1.786879456579939700f, 1.786707164172670200f, - 1.786534806073285700f, - 1.786362382288123400f, 1.786189892823522700f, 1.786017337685825700f, - 1.785844716881376700f, - 1.785672030416522300f, 1.785499278297612000f, 1.785326460530997300f, - 1.785153577123032000f, - 1.784980628080072900f, 1.784807613408478300f, 1.784634533114609800f, - 1.784461387204831400f, - 1.784288175685508700f, 1.784114898563010200f, 1.783941555843707100f, - 1.783768147533972200f, - 1.783594673640181800f, 1.783421134168713800f, 1.783247529125948900f, - 1.783073858518269700f, - 1.782900122352062000f, 1.782726320633713200f, 1.782552453369613800f, - 1.782378520566156200f, - 1.782204522229735600f, 1.782030458366749200f, 1.781856328983596900f, - 1.781682134086680900f, - 1.781507873682406200f, 1.781333547777179200f, 1.781159156377410100f, - 1.780984699489510200f, - 1.780810177119894100f, 1.780635589274978600f, 1.780460935961182300f, - 1.780286217184927000f, - 1.780111432952636600f, 1.779936583270737400f, 1.779761668145658300f, - 1.779586687583830200f, - 1.779411641591686500f, 1.779236530175663600f, 1.779061353342199500f, - 1.778886111097735000f, - 1.778710803448713400f, 1.778535430401580100f, 1.778359991962783000f, - 1.778184488138772900f, - 1.778008918936002000f, 1.777833284360925900f, 1.777657584420002000f, - 1.777481819119690200f, - 1.777305988466453000f, 1.777130092466755200f, 1.776954131127064200f, - 1.776778104453849100f, - 1.776602012453582400f, 1.776425855132738100f, 1.776249632497793200f, - 1.776073344555227000f, - 1.775896991311520800f, 1.775720572773158900f, 1.775544088946627600f, - 1.775367539838415700f, - 1.775190925455014400f, 1.775014245802917200f, 1.774837500888620400f, - 1.774660690718622000f, - 1.774483815299423100f, 1.774306874637527000f, 1.774129868739439100f, - 1.773952797611667100f, - 1.773775661260722100f, 1.773598459693116500f, 1.773421192915365400f, - 1.773243860933986400f, - 1.773066463755499800f, 1.772889001386427800f, 1.772711473833295200f, - 1.772533881102629000f, - 1.772356223200959100f, 1.772178500134817100f, 1.772000711910737700f, - 1.771822858535257600f, - 1.771644940014915700f, 1.771466956356254000f, 1.771288907565816000f, - 1.771110793650148500f, - 1.770932614615799800f, 1.770754370469321400f, 1.770576061217266500f, - 1.770397686866191300f, - 1.770219247422653700f, 1.770040742893215000f, 1.769862173284438000f, - 1.769683538602888000f, - 1.769504838855133100f, 1.769326074047743700f, 1.769147244187292200f, - 1.768968349280353800f, - 1.768789389333506000f, 1.768610364353328600f, 1.768431274346403900f, - 1.768252119319316400f, - 1.768072899278653200f, 1.767893614231003800f, 1.767714264182959500f, - 1.767534849141115100f, - 1.767355369112067100f, 1.767175824102414000f, 1.766996214118757800f, - 1.766816539167701800f, - 1.766636799255852300f, 1.766456994389817600f, 1.766277124576209000f, - 1.766097189821639300f, - 1.765917190132724600f, 1.765737125516083000f, 1.765556995978334800f, - 1.765376801526102700f, - 1.765196542166012100f, 1.765016217904690900f, 1.764835828748768400f, - 1.764655374704877700f, - 1.764474855779653200f, 1.764294271979732100f, 1.764113623311754000f, - 1.763932909782361100f, - 1.763752131398197200f, 1.763571288165909400f, 1.763390380092146400f, - 1.763209407183560200f, - 1.763028369446804500f, 1.762847266888535100f, 1.762666099515411100f, - 1.762484867334093400f, - 1.762303570351245300f, 1.762122208573532600f, 1.761940782007623600f, - 1.761759290660188400f, - 1.761577734537900500f, 1.761396113647435000f, 1.761214427995469100f, - 1.761032677588683800f, - 1.760850862433760700f, 1.760668982537384900f, 1.760487037906243600f, - 1.760305028547026500f, - 1.760122954466425600f, 1.759940815671135100f, 1.759758612167851700f, - 1.759576343963274600f, - 1.759394011064105100f, 1.759211613477047200f, 1.759029151208807400f, - 1.758846624266093800f, - 1.758664032655617500f, 1.758481376384092500f, 1.758298655458233600f, - 1.758115869884759700f, - 1.757933019670390800f, 1.757750104821850000f, 1.757567125345862700f, - 1.757384081249156100f, - 1.757200972538460700f, 1.757017799220508500f, 1.756834561302034400f, - 1.756651258789775800f, - 1.756467891690471700f, 1.756284460010864200f, 1.756100963757697900f, - 1.755917402937718900f, - 1.755733777557676500f, 1.755550087624322000f, 1.755366333144409200f, - 1.755182514124693900f, - 1.754998630571935200f, 1.754814682492893600f, 1.754630669894332600f, - 1.754446592783017500f, - 1.754262451165716300f, 1.754078245049199600f, 1.753893974440240000f, - 1.753709639345612600f, - 1.753525239772095100f, 1.753340775726466700f, 1.753156247215510400f, - 1.752971654246010300f, - 1.752786996824753600f, 1.752602274958529500f, 1.752417488654129700f, - 1.752232637918348200f, - 1.752047722757981600f, 1.751862743179828600f, 1.751677699190690400f, - 1.751492590797370600f, - 1.751307418006674800f, 1.751122180825411800f, 1.750936879260391700f, - 1.750751513318427700f, - 1.750566083006335600f, 1.750380588330932500f, 1.750195029299038900f, - 1.750009405917477100f, - 1.749823718193071800f, 1.749637966132650900f, 1.749452149743043100f, - 1.749266269031080700f, - 1.749080324003598100f, 1.748894314667431800f, 1.748708241029421000f, - 1.748522103096407300f, - 1.748335900875233900f, 1.748149634372747200f, 1.747963303595795500f, - 1.747776908551230000f, - 1.747590449245904000f, 1.747403925686672500f, 1.747217337880393900f, - 1.747030685833928200f, - 1.746843969554138200f, 1.746657189047889200f, 1.746470344322048200f, - 1.746283435383485100f, - 1.746096462239072000f, 1.745909424895683200f, 1.745722323360195900f, - 1.745535157639489100f, - 1.745347927740444200f, 1.745160633669945200f, 1.744973275434878300f, - 1.744785853042132300f, - 1.744598366498598200f, 1.744410815811169300f, 1.744223200986741100f, - 1.744035522032211900f, - 1.743847778954482000f, 1.743659971760454200f, 1.743472100457033700f, - 1.743284165051127700f, - 1.743096165549646400f, 1.742908101959502100f, 1.742719974287608900f, - 1.742531782540884100f, - 1.742343526726246800f, 1.742155206850618800f, 1.741966822920923800f, - 1.741778374944088000f, - 1.741589862927040800f, 1.741401286876712800f, 1.741212646800037300f, - 1.741023942703950200f, - 1.740835174595389600f, 1.740646342481295900f, 1.740457446368612000f, - 1.740268486264283200f, - 1.740079462175256900f, 1.739890374108482600f, 1.739701222070913200f, - 1.739512006069502800f, - 1.739322726111208500f, 1.739133382202989500f, 1.738943974351807600f, - 1.738754502564626700f, - 1.738564966848413100f, 1.738375367210135400f, 1.738185703656765200f, - 1.737995976195275000f, - 1.737806184832640900f, 1.737616329575841300f, 1.737426410431856200f, - 1.737236427407668800f, - 1.737046380510263800f, 1.736856269746629000f, 1.736666095123754000f, - 1.736475856648631400f, - 1.736285554328254900f, 1.736095188169622500f, 1.735904758179732400f, - 1.735714264365586700f, - 1.735523706734189100f, 1.735333085292545900f, 1.735142400047666100f, - 1.734951651006560100f, - 1.734760838176241400f, 1.734569961563725600f, 1.734379021176030600f, - 1.734188017020177100f, - 1.733996949103187500f, 1.733805817432086900f, 1.733614622013902600f, - 1.733423362855664100f, - 1.733232039964403900f, 1.733040653347156300f, 1.732849203010957900f, - 1.732657688962847600f, - 1.732466111209867200f, 1.732274469759060200f, 1.732082764617472800f, - 1.731890995792153600f, - 1.731699163290153100f, 1.731507267118524500f, 1.731315307284323700f, - 1.731123283794607800f, - 1.730931196656437600f, 1.730739045876875200f, 1.730546831462985500f, - 1.730354553421835600f, - 1.730162211760495300f, 1.729969806486036500f, 1.729777337605533000f, - 1.729584805126061400f, - 1.729392209054700900f, 1.729199549398532400f, 1.729006826164639400f, - 1.728814039360108100f, - 1.728621188992026400f, 1.728428275067485100f, 1.728235297593577100f, - 1.728042256577397200f, - 1.727849152026043500f, 1.727655983946615700f, 1.727462752346216000f, - 1.727269457231948900f, - 1.727076098610921500f, 1.726882676490243000f, 1.726689190877025000f, - 1.726495641778381200f, - 1.726302029201427900f, 1.726108353153283900f, 1.725914613641069900f, - 1.725720810671909300f, - 1.725526944252927700f, 1.725333014391252900f, 1.725139021094015200f, - 1.724944964368347000f, - 1.724750844221383500f, 1.724556660660261800f, 1.724362413692121400f, - 1.724168103324104300f, - 1.723973729563354600f, 1.723779292417019200f, 1.723584791892246700f, - 1.723390227996188600f, - 1.723195600735998100f, 1.723000910118831300f, 1.722806156151846400f, - 1.722611338842204000f, - 1.722416458197066900f, 1.722221514223600100f, 1.722026506928971500f, - 1.721831436320350800f, - 1.721636302404910200f, 1.721441105189824000f, 1.721245844682269600f, - 1.721050520889425600f, - 1.720855133818473900f, 1.720659683476597900f, 1.720464169870984200f, - 1.720268593008821100f, - 1.720072952897299100f, 1.719877249543611900f, 1.719681482954954500f, - 1.719485653138524800f, - 1.719289760101522900f, 1.719093803851151400f, 1.718897784394614900f, - 1.718701701739120400f, - 1.718505555891877400f, 1.718309346860097600f, 1.718113074650995200f, - 1.717916739271786500f, - 1.717720340729689700f, 1.717523879031926500f, 1.717327354185719900f, - 1.717130766198295700f, - 1.716934115076881800f, 1.716737400828708400f, 1.716540623461008100f, - 1.716343782981016200f, - 1.716146879395969500f, 1.715949912713108100f, 1.715752882939673300f, - 1.715555790082909900f, - 1.715358634150064000f, 1.715161415148384500f, 1.714964133085122900f, - 1.714766787967532600f, - 1.714569379802868900f, 1.714371908598390800f, 1.714174374361358000f, - 1.713976777099033700f, - 1.713779116818682900f, 1.713581393527573000f, 1.713383607232973600f, - 1.713185757942156800f, - 1.712987845662396800f, 1.712789870400970700f, 1.712591832165157200f, - 1.712393730962237500f, - 1.712195566799495500f, 1.711997339684216700f, 1.711799049623689900f, - 1.711600696625205300f, - 1.711402280696055800f, 1.711203801843536700f, 1.711005260074945200f, - 1.710806655397581600f, - 1.710607987818747700f, 1.710409257345748100f, 1.710210463985889500f, - 1.710011607746480600f, - 1.709812688634833300f, 1.709613706658261100f, 1.709414661824080000f, - 1.709215554139608400f, - 1.709016383612166600f, 1.708817150249077900f, 1.708617854057667300f, - 1.708418495045262300f, - 1.708219073219193300f, 1.708019588586791700f, 1.707820041155392500f, - 1.707620430932332400f, - 1.707420757924950300f, 1.707221022140587900f, 1.707021223586588700f, - 1.706821362270298600f, - 1.706621438199066300f, 1.706421451380242000f, 1.706221401821179200f, - 1.706021289529232800f, - 1.705821114511760300f, 1.705620876776121600f, 1.705420576329679000f, - 1.705220213179796900f, - 1.705019787333842200f, 1.704819298799183700f, 1.704618747583193100f, - 1.704418133693243800f, - 1.704217457136711900f, 1.704016717920976000f, 1.703815916053416300f, - 1.703615051541415900f, - 1.703414124392360000f, 1.703213134613636100f, 1.703012082212634000f, - 1.702810967196746000f, - 1.702609789573366300f, 1.702408549349891500f, 1.702207246533721000f, - 1.702005881132255800f, - 1.701804453152900000f, 1.701602962603059100f, 1.701401409490141300f, - 1.701199793821557300f, - 1.700998115604720000f, 1.700796374847044300f, 1.700594571555948100f, - 1.700392705738850400f, - 1.700190777403173700f, 1.699988786556342300f, 1.699786733205783000f, - 1.699584617358924400f, - 1.699382439023197700f, 1.699180198206036600f, 1.698977894914877100f, - 1.698775529157156700f, - 1.698573100940316400f, 1.698370610271798800f, 1.698168057159048700f, - 1.697965441609513300f, - 1.697762763630642700f, 1.697560023229888200f, 1.697357220414704500f, - 1.697154355192547900f, - 1.696951427570877000f, 1.696748437557152900f, 1.696545385158839200f, - 1.696342270383401200f, - 1.696139093238307400f, 1.695935853731027600f, 1.695732551869034300f, - 1.695529187659802400f, - 1.695325761110809200f, 1.695122272229534000f, 1.694918721023458600f, - 1.694715107500066800f, - 1.694511431666845000f, 1.694307693531282000f, 1.694103893100868100f, - 1.693900030383096900f, - 1.693696105385463800f, 1.693492118115466500f, 1.693288068580604900f, - 1.693083956788381500f, - 1.692879782746300700f, 1.692675546461869900f, 1.692471247942597600f, - 1.692266887195995600f, - 1.692062464229577600f, 1.691857979050859900f, 1.691653431667360600f, - 1.691448822086600400f, - 1.691244150316102000f, 1.691039416363390800f, 1.690834620235994300f, - 1.690629761941442100f, - 1.690424841487266700f, 1.690219858881001800f, 1.690014814130184300f, - 1.689809707242353200f, - 1.689604538225049700f, 1.689399307085817300f, 1.689194013832201500f, - 1.688988658471750600f, - 1.688783241012014700f, 1.688577761460546800f, 1.688372219824901400f, - 1.688166616112636100f, - 1.687960950331309800f, 1.687755222488484600f, 1.687549432591724400f, - 1.687343580648595700f, - 1.687137666666667100f, 1.686931690653509000f, 1.686725652616694900f, - 1.686519552563800400f, - 1.686313390502403000f, 1.686107166440082600f, 1.685900880384421800f, - 1.685694532343004600f, - 1.685488122323418400f, 1.685281650333251900f, 1.685075116380096800f, - 1.684868520471546600f, - 1.684661862615197000f, 1.684455142818646700f, 1.684248361089495800f, - 1.684041517435347400f, - 1.683834611863806100f, 1.683627644382479800f, 1.683420614998977900f, - 1.683213523720911800f, - 1.683006370555896400f, 1.682799155511547600f, 1.682591878595484300f, - 1.682384539815327400f, - 1.682177139178700400f, 1.681969676693228600f, 1.681762152366539600f, - 1.681554566206263900f, - 1.681346918220033800f, 1.681139208415483700f, 1.680931436800250600f, - 1.680723603381973500f, - 1.680515708168294200f, 1.680307751166856300f, 1.680099732385305300f, - 1.679891651831290100f, - 1.679683509512460900f, 1.679475305436470600f, 1.679267039610974300f, - 1.679058712043629300f, - 1.678850322742095200f, 1.678641871714033900f, 1.678433358967109400f, - 1.678224784508988400f, - 1.678016148347339300f, 1.677807450489833300f, 1.677598690944143400f, - 1.677389869717945000f, - 1.677180986818916300f, 1.676972042254736900f, 1.676763036033089600f, - 1.676553968161658600f, - 1.676344838648130600f, 1.676135647500194700f, 1.675926394725542700f, - 1.675717080331867900f, - 1.675507704326866200f, 1.675298266718235900f, 1.675088767513677200f, - 1.674879206720892900f, - 1.674669584347587800f, 1.674459900401469700f, 1.674250154890247300f, - 1.674040347821632800f, - 1.673830479203340000f, 1.673620549043085500f, 1.673410557348587600f, - 1.673200504127567000f, - 1.672990389387746700f, 1.672780213136852300f, 1.672569975382611300f, - 1.672359676132753500f, - 1.672149315395010900f, 1.671938893177118000f, 1.671728409486811500f, - 1.671517864331830000f, - 1.671307257719914800f, 1.671096589658809500f, 1.670885860156259300f, - 1.670675069220012500f, - 1.670464216857819200f, 1.670253303077431800f, 1.670042327886605200f, - 1.669831291293095900f, - 1.669620193304663500f, 1.669409033929069500f, 1.669197813174077200f, - 1.668986531047453000f, - 1.668775187556965000f, 1.668563782710383600f, 1.668352316515481700f, - 1.668140788980034400f, - 1.667929200111818400f, 1.667717549918614100f, 1.667505838408202700f, - 1.667294065588368100f, - 1.667082231466896900f, 1.666870336051577800f, 1.666658379350201000f, - 1.666446361370560000f, - 1.666234282120450100f, 1.666022141607668600f, 1.665809939840015500f, - 1.665597676825292700f, - 1.665385352571304500f, 1.665172967085857700f, 1.664960520376761000f, - 1.664748012451825200f, - 1.664535443318863900f, 1.664322812985692600f, 1.664110121460129000f, - 1.663897368749993400f, - 1.663684554863107800f, 1.663471679807296800f, 1.663258743590387400f, - 1.663045746220208600f, - 1.662832687704591800f, 1.662619568051370500f, 1.662406387268380100f, - 1.662193145363459100f, - 1.661979842344447600f, 1.661766478219188300f, 1.661553052995526000f, - 1.661339566681307600f, - 1.661126019284382200f, 1.660912410812601900f, 1.660698741273819700f, - 1.660485010675892400f, - 1.660271219026677700f, 1.660057366334036300f, 1.659843452605831200f, - 1.659629477849926800f, - 1.659415442074190900f, 1.659201345286492900f, 1.658987187494704200f, - 1.658772968706699000f, - 1.658558688930353400f, 1.658344348173546300f, 1.658129946444157700f, - 1.657915483750071100f, - 1.657700960099171200f, 1.657486375499345900f, 1.657271729958484500f, - 1.657057023484479000f, - 1.656842256085223800f, 1.656627427768615000f, 1.656412538542551200f, - 1.656197588414933600f, - 1.655982577393664700f, 1.655767505486650500f, 1.655552372701798200f, - 1.655337179047017700f, - 1.655121924530220900f, 1.654906609159322500f, 1.654691232942238500f, - 1.654475795886888300f, - 1.654260298001192200f, 1.654044739293073900f, 1.653829119770458900f, - 1.653613439441274500f, - 1.653397698313451300f, 1.653181896394921000f, 1.652966033693617800f, - 1.652750110217479100f, - 1.652534125974443000f, 1.652318080972451400f, 1.652101975219447200f, - 1.651885808723375900f, - 1.651669581492185300f, 1.651453293533826000f, 1.651236944856249600f, - 1.651020535467411200f, - 1.650804065375267400f, 1.650587534587776700f, 1.650370943112901000f, - 1.650154290958603300f, - 1.649937578132849400f, 1.649720804643607400f, 1.649503970498847200f, - 1.649287075706541200f, - 1.649070120274664000f, 1.648853104211192700f, 1.648636027524106100f, - 1.648418890221385400f, - 1.648201692311014300f, 1.647984433800978600f, 1.647767114699266100f, - 1.647549735013867000f, - 1.647332294752774200f, 1.647114793923981600f, 1.646897232535486500f, - 1.646679610595287900f, - 1.646461928111387300f, 1.646244185091788400f, 1.646026381544496400f, - 1.645808517477519700f, - 1.645590592898868600f, 1.645372607816555400f, 1.645154562238594800f, - 1.644936456173004000f, - 1.644718289627801600f, 1.644500062611009300f, 1.644281775130650900f, - 1.644063427194751600f, - 1.643845018811340300f, 1.643626549988446200f, 1.643408020734102600f, - 1.643189431056343700f, - 1.642970780963206800f, 1.642752070462730800f, 1.642533299562957100f, - 1.642314468271929300f, - 1.642095576597693200f, 1.641876624548297000f, 1.641657612131790500f, - 1.641438539356226500f, - 1.641219406229659700f, 1.641000212760146800f, 1.640780958955747200f, - 1.640561644824521700f, - 1.640342270374534500f, 1.640122835613851100f, 1.639903340550539200f, - 1.639683785192669600f, - 1.639464169548314100f, 1.639244493625547900f, 1.639024757432447500f, - 1.638804960977092100f, - 1.638585104267562800f, 1.638365187311943400f, 1.638145210118319400f, - 1.637925172694778800f, - 1.637705075049411800f, 1.637484917190310800f, 1.637264699125570200f, - 1.637044420863286600f, - 1.636824082411559600f, 1.636603683778490100f, 1.636383224972181500f, - 1.636162706000739300f, - 1.635942126872271800f, 1.635721487594888400f, 1.635500788176702100f, - 1.635280028625826900f, - 1.635059208950379700f, 1.634838329158479200f, 1.634617389258246700f, - 1.634396389257805700f, - 1.634175329165281400f, 1.633954208988801700f, 1.633733028736496400f, - 1.633511788416498000f, - 1.633290488036940500f, 1.633069127605960800f, 1.632847707131697600f, - 1.632626226622291700f, - 1.632404686085886300f, 1.632183085530627200f, 1.631961424964661700f, - 1.631739704396139900f, - 1.631517923833213400f, 1.631296083284036900f, 1.631074182756766300f, - 1.630852222259560700f, - 1.630630201800580900f, 1.630408121387990000f, 1.630185981029953000f, - 1.629963780734637400f, - 1.629741520510213000f, 1.629519200364851800f, 1.629296820306727700f, - 1.629074380344017100f, - 1.628851880484898200f, 1.628629320737551700f, 1.628406701110161100f, - 1.628184021610910700f, - 1.627961282247988300f, 1.627738483029583100f, 1.627515623963887000f, - 1.627292705059093700f, - 1.627069726323399500f, 1.626846687765002700f, 1.626623589392103500f, - 1.626400431212904800f, - 1.626177213235611400f, 1.625953935468430500f, 1.625730597919571300f, - 1.625507200597245500f, - 1.625283743509666300f, 1.625060226665050000f, 1.624836650071614500f, - 1.624613013737580000f, - 1.624389317671169500f, 1.624165561880607000f, 1.623941746374119500f, - 1.623717871159936300f, - 1.623493936246288300f, 1.623269941641409400f, 1.623045887353534900f, - 1.622821773390902700f, - 1.622597599761753000f, 1.622373366474327800f, 1.622149073536871800f, - 1.621924720957631300f, - 1.621700308744855200f, 1.621475836906794500f, 1.621251305451702400f, - 1.621026714387834300f, - 1.620802063723447700f, 1.620577353466802700f, 1.620352583626160500f, - 1.620127754209786100f, - 1.619902865225945300f, 1.619677916682906700f, 1.619452908588941300f, - 1.619227840952321800f, - 1.619002713781323200f, 1.618777527084222800f, 1.618552280869300300f, - 1.618326975144837000f, - 1.618101609919117200f, 1.617876185200426600f, 1.617650700997053500f, - 1.617425157317288200f, - 1.617199554169423500f, 1.616973891561754200f, 1.616748169502577200f, - 1.616522388000191500f, - 1.616296547062898500f, 1.616070646699001800f, 1.615844686916807300f, - 1.615618667724622700f, - 1.615392589130757900f, 1.615166451143525300f, 1.614940253771239400f, - 1.614713997022216900f, - 1.614487680904776600f, 1.614261305427239200f, 1.614034870597928400f, - 1.613808376425168900f, - 1.613581822917288900f, 1.613355210082617800f, 1.613128537929487500f, - 1.612901806466232200f, - 1.612675015701188000f, 1.612448165642693400f, 1.612221256299089200f, - 1.611994287678718100f, - 1.611767259789925100f, 1.611540172641057200f, 1.611313026240463800f, - 1.611085820596496600f, - 1.610858555717509200f, 1.610631231611857800f, 1.610403848287899700f, - 1.610176405753995800f, - 1.609948904018508200f, 1.609721343089801600f, 1.609493722976242900f, - 1.609266043686200700f, - 1.609038305228046400f, 1.608810507610153100f, 1.608582650840896200f, - 1.608354734928653800f, - 1.608126759881805400f, 1.607898725708732900f, 1.607670632417820500f, - 1.607442480017454700f, - 1.607214268516024000f, 1.606985997921919000f, 1.606757668243532500f, - 1.606529279489259600f, - 1.606300831667497600f, 1.606072324786645500f, 1.605843758855105300f, - 1.605615133881280700f, - 1.605386449873577300f, 1.605157706840403300f, 1.604928904790168700f, - 1.604700043731286200f, - 1.604471123672170500f, 1.604242144621237800f, 1.604013106586907400f, - 1.603784009577600100f, - 1.603554853601739700f, 1.603325638667751000f, 1.603096364784061900f, - 1.602867031959102100f, - 1.602637640201303400f, 1.602408189519099800f, 1.602178679920927900f, - 1.601949111415226000f, - 1.601719484010434300f, 1.601489797714996000f, 1.601260052537355700f, - 1.601030248485960900f, - 1.600800385569260300f, 1.600570463795705700f, 1.600340483173750400f, - 1.600110443711850300f, - 1.599880345418463100f, 1.599650188302049100f, 1.599419972371070500f, - 1.599189697633991400f, - 1.598959364099278700f, 1.598728971775401000f, 1.598498520670828900f, - 1.598268010794035900f, - 1.598037442153496900f, 1.597806814757689200f, 1.597576128615092200f, - 1.597345383734188000f, - 1.597114580123460100f, 1.596883717791394800f, 1.596652796746479600f, - 1.596421816997205500f, - 1.596190778552064800f, 1.595959681419551800f, 1.595728525608163700f, - 1.595497311126399300f, - 1.595266037982759500f, 1.595034706185747500f, 1.594803315743869000f, - 1.594571866665631700f, - 1.594340358959544800f, 1.594108792634120600f, 1.593877167697873100f, - 1.593645484159318200f, - 1.593413742026974500f, 1.593181941309362400f, 1.592950082015004700f, - 1.592718164152426000f, - 1.592486187730153300f, 1.592254152756715600f, 1.592022059240644400f, - 1.591789907190473100f, - 1.591557696614737100f, 1.591325427521974100f, 1.591093099920724200f, - 1.590860713819529400f, - 1.590628269226933600f, 1.590395766151483400f, 1.590163204601727100f, - 1.589930584586215500f, - 1.589697906113501000f, 1.589465169192139100f, 1.589232373830686400f, - 1.588999520037702300f, - 1.588766607821748200f, 1.588533637191387400f, 1.588300608155185600f, - 1.588067520721711000f, - 1.587834374899533400f, 1.587601170697224600f, 1.587367908123358900f, - 1.587134587186513000f, - 1.586901207895265300f, 1.586667770258196600f, 1.586434274283889500f, - 1.586200719980929200f, - 1.585967107357902700f, 1.585733436423399000f, 1.585499707186010200f, - 1.585265919654329300f, - 1.585032073836952100f, 1.584798169742476400f, 1.584564207379502500f, - 1.584330186756632200f, - 1.584096107882470000f, 1.583861970765622100f, 1.583627775414697000f, - 1.583393521838305700f, - 1.583159210045060900f, 1.582924840043577400f, 1.582690411842472700f, - 1.582455925450365600f, - 1.582221380875877800f, 1.581986778127632700f, 1.581752117214255900f, - 1.581517398144375800f, - 1.581282620926621300f, 1.581047785569625400f, 1.580812892082021900f, - 1.580577940472447200f, - 1.580342930749539800f, 1.580107862921940700f, 1.579872736998292100f, - 1.579637552987239100f, - 1.579402310897428900f, 1.579167010737510600f, 1.578931652516135700f, - 1.578696236241957200f, - 1.578460761923630800f, 1.578225229569814700f, 1.577989639189168100f, - 1.577753990790353500f, - 1.577518284382034800f, 1.577282519972878200f, 1.577046697571552000f, - 1.576810817186727000f, - 1.576574878827075700f, 1.576338882501273000f, 1.576102828217995600f, - 1.575866715985922500f, - 1.575630545813735200f, 1.575394317710116600f, 1.575158031683752300f, - 1.574921687743330300f, - 1.574685285897539800f, 1.574448826155072400f, 1.574212308524622500f, - 1.573975733014886000f, - 1.573739099634561500f, 1.573502408392348600f, 1.573265659296950300f, - 1.573028852357070800f, - 1.572791987581417100f, 1.572555064978698100f, 1.572318084557624800f, - 1.572081046326909900f, - 1.571843950295269000f, 1.571606796471419100f, 1.571369584864080100f, - 1.571132315481973200f, - 1.570894988333822400f, 1.570657603428353300f, 1.570420160774294000f, - 1.570182660380374600f, - 1.569945102255327200f, 1.569707486407886600f, 1.569469812846788500f, - 1.569232081580771900f, - 1.568994292618577400f, 1.568756445968948000f, 1.568518541640628400f, - 1.568280579642366000f, - 1.568042559982909500f, 1.567804482671010500f, 1.567566347715422500f, - 1.567328155124900800f, - 1.567089904908203200f, 1.566851597074089500f, 1.566613231631321500f, - 1.566374808588663300f, - 1.566136327954881000f, 1.565897789738742900f, 1.565659193949019400f, - 1.565420540594482800f, - 1.565181829683907700f, 1.564943061226071100f, 1.564704235229751500f, - 1.564465351703730400f, - 1.564226410656790000f, 1.563987412097716200f, 1.563748356035296000f, - 1.563509242478319000f, - 1.563270071435576500f, 1.563030842915862100f, 1.562791556927971800f, - 1.562552213480703300f, - 1.562312812582856500f, 1.562073354243233700f, 1.561833838470639200f, - 1.561594265273878800f, - 1.561354634661761300f, 1.561114946643096900f, 1.560875201226698900f, - 1.560635398421381400f, - 1.560395538235961800f, 1.560155620679258400f, 1.559915645760092900f, - 1.559675613487288200f, - 1.559435523869669500f, 1.559195376916064700f, 1.558955172635302800f, - 1.558714911036215700f, - 1.558474592127637100f, 1.558234215918402600f, 1.557993782417350400f, - 1.557753291633320500f, - 1.557512743575155000f, 1.557272138251698300f, 1.557031475671796400f, - 1.556790755844298400f, - 1.556549978778054300f, 1.556309144481917300f, 1.556068252964741600f, - 1.555827304235384500f, - 1.555586298302704900f, 1.555345235175563900f, 1.555104114862824600f, - 1.554862937373352500f, - 1.554621702716015000f, 1.554380410899681300f, 1.554139061933223200f, - 1.553897655825514600f, - 1.553656192585431100f, 1.553414672221850700f, 1.553173094743653300f, - 1.552931460159721100f, - 1.552689768478938500f, 1.552448019710191300f, 1.552206213862368500f, - 1.551964350944360100f, - 1.551722430965059000f, 1.551480453933359800f, 1.551238419858159700f, - 1.550996328748356800f, - 1.550754180612852900f, 1.550511975460550500f, 1.550269713300355100f, - 1.550027394141174000f, - 1.549785017991916400f, 1.549542584861493900f, 1.549300094758820000f, - 1.549057547692810600f, - 1.548814943672383300f, 1.548572282706457900f, 1.548329564803956300f, - 1.548086789973802700f, - 1.547843958224923000f, 1.547601069566245900f, 1.547358124006701400f, - 1.547115121555221700f, - 1.546872062220741700f, 1.546628946012197800f, 1.546385772938528600f, - 1.546142543008675300f, - 1.545899256231580300f, 1.545655912616188800f, 1.545412512171447700f, - 1.545169054906306200f, - 1.544925540829715600f, 1.544681969950629300f, 1.544438342278002600f, - 1.544194657820792800f, - 1.543950916587959700f, 1.543707118588464800f, 1.543463263831272000f, - 1.543219352325347200f, - 1.542975384079658300f, 1.542731359103175300f, 1.542487277404870100f, - 1.542243138993717000f, - 1.541998943878692300f, 1.541754692068774600f, 1.541510383572944000f, - 1.541266018400183200f, - 1.541021596559476700f, 1.540777118059811100f, 1.540532582910175500f, - 1.540287991119560600f, - 1.540043342696959100f, 1.539798637651366400f, 1.539553875991779300f, - 1.539309057727197300f, - 1.539064182866621400f, 1.538819251419055100f, 1.538574263393503800f, - 1.538329218798974800f, - 1.538084117644477900f, 1.537838959939025200f, 1.537593745691629500f, - 1.537348474911307300f, - 1.537103147607076200f, 1.536857763787956400f, 1.536612323462969800f, - 1.536366826641140800f, - 1.536121273331495300f, 1.535875663543061700f, 1.535629997284870400f, - 1.535384274565953600f, - 1.535138495395346400f, 1.534892659782085100f, 1.534646767735208000f, - 1.534400819263756400f, - 1.534154814376772700f, 1.533908753083302200f, 1.533662635392391700f, - 1.533416461313090100f, - 1.533170230854448400f, 1.532923944025520200f, 1.532677600835360600f, - 1.532431201293027000f, - 1.532184745407578500f, 1.531938233188077100f, 1.531691664643585900f, - 1.531445039783170500f, - 1.531198358615898800f, 1.530951621150840700f, 1.530704827397067800f, - 1.530457977363654000f, - 1.530211071059675200f, 1.529964108494209700f, 1.529717089676337500f, - 1.529470014615140800f, - 1.529222883319703700f, 1.528975695799112500f, 1.528728452062455600f, - 1.528481152118823700f, - 1.528233795977309400f, 1.527986383647006500f, 1.527738915137012400f, - 1.527491390456425600f, - 1.527243809614346600f, 1.526996172619878900f, 1.526748479482126700f, - 1.526500730210197200f, - 1.526252924813199500f, 1.526005063300244900f, 1.525757145680446200f, - 1.525509171962918800f, - 1.525261142156779900f, 1.525013056271149000f, 1.524764914315147200f, - 1.524516716297898300f, - 1.524268462228527900f, 1.524020152116163200f, 1.523771785969934000f, - 1.523523363798972000f, - 1.523274885612411200f, 1.523026351419387100f, 1.522777761229038100f, - 1.522529115050503600f, - 1.522280412892925900f, 1.522031654765448900f, 1.521782840677218700f, - 1.521533970637383800f, - 1.521285044655094300f, 1.521036062739502300f, 1.520787024899762100f, - 1.520537931145030400f, - 1.520288781484465700f, 1.520039575927228500f, 1.519790314482481100f, - 1.519540997159388300f, - 1.519291623967116600f, 1.519042194914835200f, 1.518792710011714500f, - 1.518543169266927600f, - 1.518293572689648900f, 1.518043920289055900f, 1.517794212074327500f, - 1.517544448054644500f, - 1.517294628239190400f, 1.517044752637150000f, 1.516794821257710500f, - 1.516544834110061600f, - 1.516294791203394200f, 1.516044692546901800f, 1.515794538149779700f, - 1.515544328021225500f, - 1.515294062170438700f, 1.515043740606620800f, 1.514793363338975600f, - 1.514542930376708600f, - 1.514292441729027300f, 1.514041897405141700f, 1.513791297414263800f, - 1.513540641765606800f, - 1.513289930468387300f, 1.513039163531823000f, 1.512788340965133500f, - 1.512537462777541200f, - 1.512286528978270300f, 1.512035539576546600f, 1.511784494581598600f, - 1.511533394002656100f, - 1.511282237848951400f, 1.511031026129719100f, 1.510779758854195400f, - 1.510528436031618900f, - 1.510277057671229400f, 1.510025623782270000f, 1.509774134373984800f, - 1.509522589455620600f, - 1.509270989036425800f, 1.509019333125651200f, 1.508767621732549400f, - 1.508515854866375100f, - 1.508264032536385000f, 1.508012154751837700f, 1.507760221521994700f, - 1.507508232856118200f, - 1.507256188763473200f, 1.507004089253327000f, 1.506751934334948000f, - 1.506499724017607900f, - 1.506247458310579400f, 1.505995137223137500f, 1.505742760764559300f, - 1.505490328944124200f, - 1.505237841771113200f, 1.504985299254809800f, 1.504732701404498900f, - 1.504480048229468000f, - 1.504227339739006500f, 1.503974575942405700f, 1.503721756848958700f, - 1.503468882467961600f, - 1.503215952808711500f, 1.502962967880507600f, 1.502709927692651900f, - 1.502456832254447600f, - 1.502203681575200700f, 1.501950475664218600f, 1.501697214530810700f, - 1.501443898184289200f, - 1.501190526633967600f, 1.500937099889161600f, 1.500683617959188900f, - 1.500430080853369500f, - 1.500176488581024900f, 1.499922841151479600f, 1.499669138574058800f, - 1.499415380858090800f, - 1.499161568012905300f, 1.498907700047834600f, 1.498653776972212600f, - 1.498399798795375000f, - 1.498145765526660300f, 1.497891677175408500f, 1.497637533750961300f, - 1.497383335262663300f, - 1.497129081719860400f, 1.496874773131900800f, 1.496620409508134800f, - 1.496365990857914600f, - 1.496111517190594300f, 1.495856988515530400f, 1.495602404842080800f, - 1.495347766179606400f, - 1.495093072537469100f, 1.494838323925033400f, 1.494583520351665500f, - 1.494328661826734200f, - 1.494073748359609600f, 1.493818779959664300f, 1.493563756636272500f, - 1.493308678398810800f, - 1.493053545256657800f, 1.492798357219194100f, 1.492543114295801900f, - 1.492287816495866200f, - 1.492032463828773200f, 1.491777056303911700f, 1.491521593930672100f, - 1.491266076718446900f, - 1.491010504676631500f, 1.490754877814621800f, 1.490499196141816600f, - 1.490243459667616600f, - 1.489987668401424800f, 1.489731822352645500f, 1.489475921530685900f, - 1.489219965944954300f, - 1.488963955604861500f, 1.488707890519820600f, 1.488451770699245900f, - 1.488195596152554800f, - 1.487939366889165600f, 1.487683082918499300f, 1.487426744249978400f, - 1.487170350893028500f, - 1.486913902857075700f, 1.486657400151549600f, 1.486400842785880100f, - 1.486144230769501000f, - 1.485887564111846500f, 1.485630842822354100f, 1.485374066910462500f, - 1.485117236385612200f, - 1.484860351257246500f, 1.484603411534810300f, 1.484346417227750700f, - 1.484089368345516300f, - 1.483832264897558400f, 1.483575106893329600f, 1.483317894342285100f, - 1.483060627253882000f, - 1.482803305637578900f, 1.482545929502837100f, 1.482288498859119400f, - 1.482031013715890700f, - 1.481773474082618300f, 1.481515879968770900f, 1.481258231383819800f, - 1.481000528337237800f, - 1.480742770838499900f, 1.480484958897083200f, 1.480227092522466500f, - 1.479969171724131200f, - 1.479711196511560100f, 1.479453166894238100f, 1.479195082881652200f, - 1.478936944483291600f, - 1.478678751708647000f, 1.478420504567211900f, 1.478162203068481100f, - 1.477903847221951400f, - 1.477645437037121900f, 1.477386972523493800f, 1.477128453690569800f, - 1.476869880547855300f, - 1.476611253104856700f, 1.476352571371083700f, 1.476093835356046700f, - 1.475835045069259000f, - 1.475576200520235500f, 1.475317301718493300f, 1.475058348673551100f, - 1.474799341394929900f, - 1.474540279892153000f, 1.474281164174744900f, 1.474021994252233000f, - 1.473762770134145800f, - 1.473503491830014300f, 1.473244159349371700f, 1.472984772701752900f, - 1.472725331896694400f, - 1.472465836943735600f, 1.472206287852416900f, 1.471946684632281500f, - 1.471687027292874400f, - 1.471427315843742100f, 1.471167550294433700f, 1.470907730654499800f, - 1.470647856933493300f, - 1.470387929140969200f, 1.470127947286484100f, 1.469867911379596900f, - 1.469607821429868500f, - 1.469347677446861500f, 1.469087479440140300f, 1.468827227419272200f, - 1.468566921393825700f, - 1.468306561373371900f, 1.468046147367482600f, 1.467785679385733300f, - 1.467525157437700200f, - 1.467264581532962100f, 1.467003951681099800f, 1.466743267891695800f, - 1.466482530174334500f, - 1.466221738538602500f, 1.465960892994088800f, 1.465699993550383400f, - 1.465439040217079400f, - 1.465178033003770700f, 1.464916971920054100f, 1.464655856975527900f, - 1.464394688179792900f, - 1.464133465542451200f, 1.463872189073107500f, 1.463610858781367900f, - 1.463349474676840700f, - 1.463088036769136600f, 1.462826545067867700f, 1.462564999582648600f, - 1.462303400323095000f, - 1.462041747298825900f, 1.461780040519460800f, 1.461518279994622200f, - 1.461256465733934400f, - 1.460994597747023600f, 1.460732676043517800f, 1.460470700633046800f, - 1.460208671525243400f, - 1.459946588729741100f, 1.459684452256176300f, 1.459422262114186800f, - 1.459160018313412400f, - 1.458897720863495500f, 1.458635369774079500f, 1.458372965054810700f, - 1.458110506715337000f, - 1.457847994765308200f, 1.457585429214375700f, 1.457322810072193800f, - 1.457060137348418000f, - 1.456797411052706200f, 1.456534631194717800f, 1.456271797784114900f, - 1.456008910830560500f, - 1.455745970343720800f, 1.455482976333263100f, 1.455219928808857200f, - 1.454956827780174100f, - 1.454693673256887600f, 1.454430465248673300f, 1.454167203765208000f, - 1.453903888816171900f, - 1.453640520411245900f, 1.453377098560113100f, 1.453113623272459100f, - 1.452850094557971000f, - 1.452586512426338000f, 1.452322876887251400f, 1.452059187950404100f, - 1.451795445625491300f, - 1.451531649922210200f, 1.451267800850259500f, 1.451003898419340500f, - 1.450739942639155800f, - 1.450475933519410400f, 1.450211871069811300f, 1.449947755300067500f, - 1.449683586219889400f, - 1.449419363838989800f, 1.449155088167083600f, 1.448890759213887100f, - 1.448626376989119400f, - 1.448361941502500900f, 1.448097452763754000f, 1.447832910782603100f, - 1.447568315568775100f, - 1.447303667131997900f, 1.447038965482002200f, 1.446774210628520200f, - 1.446509402581286400f, - 1.446244541350036700f, 1.445979626944509300f, 1.445714659374444500f, - 1.445449638649584500f, - 1.445184564779673500f, 1.444919437774456700f, 1.444654257643682900f, - 1.444389024397101600f, - 1.444123738044464900f, 1.443858398595526400f, 1.443593006060042100f, - 1.443327560447769600f, - 1.443062061768468400f, 1.442796510031900500f, 1.442530905247829200f, - 1.442265247426020200f, - 1.441999536576240800f, 1.441733772708260600f, 1.441467955831850800f, - 1.441202085956784900f, - 1.440936163092837900f, 1.440670187249787600f, 1.440404158437412500f, - 1.440138076665494100f, - 1.439871941943815300f, 1.439605754282161400f, 1.439339513690319100f, - 1.439073220178077400f, - 1.438806873755226900f, 1.438540474431560600f, 1.438274022216873500f, - 1.438007517120961900f, - 1.437740959153624500f, 1.437474348324662100f, 1.437207684643876800f, - 1.436940968121073600f, - 1.436674198766058500f, 1.436407376588640000f, 1.436140501598628400f, - 1.435873573805835900f, - 1.435606593220076600f, 1.435339559851166500f, 1.435072473708924000f, - 1.434805334803169100f, - 1.434538143143723200f, 1.434270898740410700f, 1.434003601603057300f, - 1.433736251741490700f, - 1.433468849165540500f, 1.433201393885038500f, 1.432933885909818000f, - 1.432666325249714700f, - 1.432398711914566200f, 1.432131045914211600f, 1.431863327258492400f, - 1.431595555957251700f, - 1.431327732020334800f, 1.431059855457588600f, 1.430791926278862400f, - 1.430523944494007400f, - 1.430255910112876000f, 1.429987823145323100f, 1.429719683601205800f, - 1.429451491490382900f, - 1.429183246822714800f, 1.428914949608064200f, 1.428646599856295400f, - 1.428378197577275100f, - 1.428109742780871800f, 1.427841235476955400f, 1.427572675675398600f, - 1.427304063386075200f, - 1.427035398618861500f, 1.426766681383635500f, 1.426497911690277000f, - 1.426229089548668200f, - 1.425960214968693000f, 1.425691287960236600f, 1.425422308533187200f, - 1.425153276697434000f, - 1.424884192462868800f, 1.424615055839385300f, 1.424345866836878200f, - 1.424076625465245500f, - 1.423807331734385800f, 1.423537985654200800f, 1.423268587234593400f, - 1.422999136485468600f, - 1.422729633416733200f, 1.422460078038296300f, 1.422190470360068300f, - 1.421920810391962500f, - 1.421651098143893000f, 1.421381333625776600f, 1.421111516847531700f, - 1.420841647819078600f, - 1.420571726550339700f, 1.420301753051239400f, 1.420031727331703800f, - 1.419761649401660500f, - 1.419491519271040000f, 1.419221336949774100f, 1.418951102447796800f, - 1.418680815775043500f, - 1.418410476941452100f, 1.418140085956961900f, 1.417869642831514700f, - 1.417599147575054000f, - 1.417328600197524900f, 1.417058000708874700f, 1.416787349119052600f, - 1.416516645438009600f, - 1.416245889675698900f, 1.415975081842075300f, 1.415704221947095700f, - 1.415433310000718600f, - 1.415162346012905000f, 1.414891329993617200f, 1.414620261952819600f, - 1.414349141900479000f, - 1.414077969846563500f, 1.413806745801043500f, 1.413535469773890700f, - 1.413264141775079300f, - 1.412992761814585400f, 1.412721329902386900f, 1.412449846048463600f, - 1.412178310262796900f, - 1.411906722555370500f, 1.411635082936170100f, 1.411363391415182900f, - 1.411091648002398500f, - 1.410819852707807700f, 1.410548005541404100f, 1.410276106513182400f, - 1.410004155633139500f, - 1.409732152911274500f, 1.409460098357588200f, 1.409187991982083100f, - 1.408915833794763800f, - 1.408643623805636800f, 1.408371362024710500f, 1.408099048461995300f, - 1.407826683127503000f, - 1.407554266031248100f, 1.407281797183246500f, 1.407009276593515800f, - 1.406736704272076400f, - 1.406464080228949600f, 1.406191404474159000f, 1.405918677017730100f, - 1.405645897869690400f, - 1.405373067040069300f, 1.405100184538898000f, 1.404827250376209400f, - 1.404554264562038400f, - 1.404281227106422400f, 1.404008138019399800f, 1.403734997311011600f, - 1.403461804991300100f, - 1.403188561070310100f, 1.402915265558087700f, 1.402641918464681400f, - 1.402368519800141200f, - 1.402095069574519800f, 1.401821567797870300f, 1.401548014480249000f, - 1.401274409631713600f, - 1.401000753262323900f, 1.400727045382141400f, 1.400453286001229800f, - 1.400179475129653700f, - 1.399905612777481200f, 1.399631698954780800f, 1.399357733671623900f, - 1.399083716938083600f, - 1.398809648764234100f, 1.398535529160152400f, 1.398261358135917300f, - 1.397987135701609200f, - 1.397712861867310300f, 1.397438536643105000f, 1.397164160039079200f, - 1.396889732065321300f, - 1.396615252731921100f, 1.396340722048970300f, 1.396066140026562800f, - 1.395791506674794100f, - 1.395516822003761700f, 1.395242086023564800f, 1.394967298744304900f, - 1.394692460176085300f, - 1.394417570329010700f, 1.394142629213188000f, 1.393867636838725900f, - 1.393592593215735600f, - 1.393317498354329300f, 1.393042352264621600f, 1.392767154956728400f, - 1.392491906440768600f, - 1.392216606726861800f, 1.391941255825130100f, 1.391665853745697400f, - 1.391390400498689700f, - 1.391114896094234100f, 1.390839340542460600f, 1.390563733853500200f, - 1.390288076037486500f, - 1.390012367104554600f, 1.389736607064841100f, 1.389460795928485500f, - 1.389184933705628300f, - 1.388909020406412100f, 1.388633056040981600f, 1.388357040619483200f, - 1.388080974152065200f, - 1.387804856648877600f, 1.387528688120072600f, 1.387252468575804100f, - 1.386976198026228100f, - 1.386699876481501900f, 1.386423503951785200f, 1.386147080447239600f, - 1.385870605978028100f, - 1.385594080554316100f, 1.385317504186270900f, 1.385040876884061000f, - 1.384764198657857200f, - 1.384487469517832200f, 1.384210689474160600f, 1.383933858537019100f, - 1.383656976716585600f, - 1.383380044023040400f, 1.383103060466565300f, 1.382826026057344600f, - 1.382548940805563800f, - 1.382271804721410600f, 1.381994617815074400f, 1.381717380096746800f, - 1.381440091576620700f, - 1.381162752264891500f, 1.380885362171756300f, 1.380607921307413400f, - 1.380330429682064000f, - 1.380052887305910400f, 1.379775294189157000f, 1.379497650342010400f, - 1.379219955774678700f, - 1.378942210497371600f, 1.378664414520301500f, 1.378386567853681700f, - 1.378108670507728300f, - 1.377830722492658500f, 1.377552723818691500f, 1.377274674496048700f, - 1.376996574534953300f, - 1.376718423945630000f, 1.376440222738305700f, 1.376161970923209400f, - 1.375883668510570900f, - 1.375605315510623200f, 1.375326911933600200f, 1.375048457789738400f, - 1.374769953089275400f, - 1.374491397842451100f, 1.374212792059507100f, 1.373934135750687100f, - 1.373655428926236400f, - 1.373376671596402400f, 1.373097863771434200f, 1.372819005461582500f, - 1.372540096677100200f, - 1.372261137428242300f, 1.371982127725264800f, 1.371703067578426700f, - 1.371423956997988000f, - 1.371144795994210500f, 1.370865584577358300f, 1.370586322757697500f, - 1.370307010545495500f, - 1.370027647951022100f, 1.369748234984548000f, 1.369468771656347200f, - 1.369189257976694200f, - 1.368909693955866000f, 1.368630079604142000f, 1.368350414931802000f, - 1.368070699949128800f, - 1.367790934666406600f, 1.367511119093921800f, 1.367231253241962200f, - 1.366951337120818000f, - 1.366671370740780500f, 1.366391354112143500f, 1.366111287245202400f, - 1.365831170150254300f, - 1.365551002837598600f, 1.365270785317536100f, 1.364990517600369400f, - 1.364710199696403300f, - 1.364429831615944200f, 1.364149413369300600f, 1.363868944966782900f, - 1.363588426418702600f, - 1.363307857735373900f, 1.363027238927112300f, 1.362746570004235400f, - 1.362465850977062900f, - 1.362185081855915600f, 1.361904262651116900f, 1.361623393372991300f, - 1.361342474031866000f, - 1.361061504638069400f, 1.360780485201932300f, 1.360499415733786400f, - 1.360218296243966200f, - 1.359937126742807300f, 1.359655907240648000f, 1.359374637747827700f, - 1.359093318274687800f, - 1.358811948831571500f, 1.358530529428824400f, 1.358249060076792900f, - 1.357967540785826300f, - 1.357685971566275200f, 1.357404352428492000f, 1.357122683382830900f, - 1.356840964439648200f, - 1.356559195609301700f, 1.356277376902151900f, 1.355995508328559500f, - 1.355713589898888800f, - 1.355431621623504700f, 1.355149603512774400f, 1.354867535577067200f, - 1.354585417826753800f, - 1.354303250272206500f, 1.354021032923800300f, 1.353738765791911100f, - 1.353456448886917200f, - 1.353174082219199100f, 1.352891665799137900f, 1.352609199637117500f, - 1.352326683743523300f, - 1.352044118128742600f, 1.351761502803164900f, 1.351478837777180700f, - 1.351196123061183100f, - 1.350913358665566400f, 1.350630544600727200f, 1.350347680877063800f, - 1.350064767504976400f, - 1.349781804494866600f, 1.349498791857138400f, 1.349215729602197400f, - 1.348932617740450600f, - 1.348649456282307700f, 1.348366245238179500f, 1.348082984618478800f, - 1.347799674433620500f, - 1.347516314694020800f, 1.347232905410098200f, 1.346949446592273100f, - 1.346665938250967100f, - 1.346382380396604000f, 1.346098773039609700f, 1.345815116190411300f, - 1.345531409859438200f, - 1.345247654057121700f, 1.344963848793894200f, 1.344679994080190800f, - 1.344396089926448000f, - 1.344112136343103900f, 1.343828133340598800f, 1.343544080929374800f, - 1.343259979119875600f, - 1.342975827922546600f, 1.342691627347835500f, 1.342407377406191500f, - 1.342123078108065700f, - 1.341838729463910900f, 1.341554331484181600f, 1.341269884179334700f, - 1.340985387559828100f, - 1.340700841636122400f, 1.340416246418678800f, 1.340131601917961900f, - 1.339846908144436600f, - 1.339562165108570700f, 1.339277372820833400f, 1.338992531291695500f, - 1.338707640531629800f, - 1.338422700551110900f, 1.338137711360615200f, 1.337852672970621300f, - 1.337567585391608900f, - 1.337282448634059800f, 1.336997262708457900f, 1.336712027625288600f, - 1.336426743395039000f, - 1.336141410028198500f, 1.335856027535258000f, 1.335570595926709700f, - 1.335285115213048500f, - 1.334999585404770700f, 1.334714006512374400f, 1.334428378546359500f, - 1.334142701517227600f, - 1.333856975435482300f, 1.333571200311629100f, 1.333285376156174700f, - 1.332999502979628700f, - 1.332713580792501500f, 1.332427609605305400f, 1.332141589428554900f, - 1.331855520272766200f, - 1.331569402148457400f, 1.331283235066148100f, 1.330997019036359800f, - 1.330710754069615700f, - 1.330424440176441300f, 1.330138077367363200f, 1.329851665652910500f, - 1.329565205043613800f, - 1.329278695550004700f, 1.328992137182618100f, 1.328705529951989400f, - 1.328418873868656900f, - 1.328132168943159800f, 1.327845415186039000f, 1.327558612607838500f, - 1.327271761219102500f, - 1.326984861030378000f, 1.326697912052213500f, 1.326410914295159400f, - 1.326123867769767500f, - 1.325836772486591800f, 1.325549628456188100f, 1.325262435689113600f, - 1.324975194195928000f, - 1.324687903987191900f, 1.324400565073468300f, 1.324113177465321900f, - 1.323825741173318700f, - 1.323538256208027800f, 1.323250722580018500f, 1.322963140299862500f, - 1.322675509378133900f, - 1.322387829825407700f, 1.322100101652261100f, 1.321812324869273500f, - 1.321524499487024800f, - 1.321236625516098100f, 1.320948702967077400f, 1.320660731850549000f, - 1.320372712177100700f, - 1.320084643957322400f, 1.319796527201805300f, 1.319508361921142500f, - 1.319220148125929100f, - 1.318931885826762000f, 1.318643575034239800f, 1.318355215758962900f, - 1.318066808011533200f, - 1.317778351802554800f, 1.317489847142633300f, 1.317201294042376300f, - 1.316912692512393300f, - 1.316624042563294900f, 1.316335344205694200f, 1.316046597450205800f, - 1.315757802307445900f, - 1.315468958788033000f, 1.315180066902586800f, 1.314891126661728900f, - 1.314602138076083300f, - 1.314313101156274800f, 1.314024015912930600f, 1.313734882356679900f, - 1.313445700498152800f, - 1.313156470347981900f, 1.312867191916801100f, 1.312577865215246900f, - 1.312288490253956900f, - 1.311999067043570200f, 1.311709595594728000f, 1.311420075918073900f, - 1.311130508024252400f, - 1.310840891923910100f, 1.310551227627695400f, 1.310261515146258200f, - 1.309971754490250700f, - 1.309681945670326400f, 1.309392088697140900f, 1.309102183581351200f, - 1.308812230333616500f, - 1.308522228964597500f, 1.308232179484956500f, 1.307942081905358000f, - 1.307651936236467800f, - 1.307361742488954300f, 1.307071500673486800f, 1.306781210800736200f, - 1.306490872881376200f, - 1.306200486926081700f, 1.305910052945529200f, 1.305619570950396800f, - 1.305329040951365100f, - 1.305038462959116100f, 1.304747836984333300f, 1.304457163037702200f, - 1.304166441129910300f, - 1.303875671271646400f, 1.303584853473601200f, 1.303293987746467300f, - 1.303003074100939100f, - 1.302712112547712800f, 1.302421103097485900f, 1.302130045760958100f, - 1.301838940548830600f, - 1.301547787471806900f, 1.301256586540591600f, 1.300965337765891600f, - 1.300674041158414800f, - 1.300382696728871400f, 1.300091304487973800f, 1.299799864446435200f, - 1.299508376614971500f, - 1.299216841004299200f, 1.298925257625137800f, 1.298633626488207500f, - 1.298341947604231300f, - 1.298050220983932900f, 1.297758446638038700f, 1.297466624577275900f, - 1.297174754812374400f, - 1.296882837354065100f, 1.296590872213081200f, 1.296298859400157700f, - 1.296006798926030200f, - 1.295714690801437600f, 1.295422535037119800f, 1.295130331643818500f, - 1.294838080632277000f, - 1.294545782013240900f, 1.294253435797456900f, 1.293961041995673700f, - 1.293668600618642000f, - 1.293376111677113900f, 1.293083575181843500f, 1.292790991143586200f, - 1.292498359573099700f, - 1.292205680481143500f, 1.291912953878477900f, 1.291620179775866400f, - 1.291327358184073200f, - 1.291034489113864100f, 1.290741572576007400f, 1.290448608581273000f, - 1.290155597140431700f, - 1.289862538264257700f, 1.289569431963524900f, 1.289276278249010600f, - 1.288983077131493000f, - 1.288689828621752300f, 1.288396532730570400f, 1.288103189468731400f, - 1.287809798847019800f, - 1.287516360876223500f, 1.287222875567130900f, 1.286929342930532800f, - 1.286635762977221800f, - 1.286342135717991600f, 1.286048461163638000f, 1.285754739324958900f, - 1.285460970212753500f, - 1.285167153837822900f, 1.284873290210969900f, 1.284579379342998700f, - 1.284285421244715900f, - 1.283991415926929400f, 1.283697363400448900f, 1.283403263676086100f, - 1.283109116764654000f, - 1.282814922676967400f, 1.282520681423843000f, 1.282226393016099500f, - 1.281932057464557000f, - 1.281637674780037100f, 1.281343244973363700f, 1.281048768055361900f, - 1.280754244036858900f, - 1.280459672928683500f, 1.280165054741666300f, 1.279870389486639400f, - 1.279575677174437100f, - 1.279280917815894600f, 1.278986111421849900f, 1.278691258003142000f, - 1.278396357570611900f, - 1.278101410135101800f, 1.277806415707456700f, 1.277511374298522200f, - 1.277216285919146500f, - 1.276921150580179200f, 1.276625968292471000f, 1.276330739066875400f, - 1.276035462914247000f, - 1.275740139845442400f, 1.275444769871319600f, 1.275149353002738700f, - 1.274853889250561200f, - 1.274558378625650200f, 1.274262821138871300f, 1.273967216801090900f, - 1.273671565623178100f, - 1.273375867616002300f, 1.273080122790436000f, 1.272784331157352800f, - 1.272488492727628100f, - 1.272192607512139300f, 1.271896675521764900f, 1.271600696767385400f, - 1.271304671259883200f, - 1.271008599010142500f, 1.270712480029048800f, 1.270416314327489800f, - 1.270120101916354600f, - 1.269823842806533800f, 1.269527537008920300f, 1.269231184534408200f, - 1.268934785393893700f, - 1.268638339598274500f, 1.268341847158450200f, 1.268045308085321800f, - 1.267748722389792100f, - 1.267452090082765900f, 1.267155411175149500f, 1.266858685677851000f, - 1.266561913601780100f, - 1.266265094957848000f, 1.265968229756968100f, 1.265671318010055400f, - 1.265374359728026500f, - 1.265077354921799300f, 1.264780303602294200f, 1.264483205780432700f, - 1.264186061467138500f, - 1.263888870673336400f, 1.263591633409954000f, 1.263294349687918800f, - 1.262997019518161700f, - 1.262699642911614600f, 1.262402219879211300f, 1.262104750431887000f, - 1.261807234580578900f, - 1.261509672336225600f, 1.261212063709767900f, 1.260914408712147800f, - 1.260616707354309500f, - 1.260318959647198400f, 1.260021165601761900f, 1.259723325228949000f, - 1.259425438539710300f, - 1.259127505544998600f, 1.258829526255768000f, 1.258531500682973800f, - 1.258233428837574300f, - 1.257935310730528000f, 1.257637146372796400f, 1.257338935775342200f, - 1.257040678949129500f, - 1.256742375905124400f, 1.256444026654294400f, 1.256145631207609400f, - 1.255847189576040100f, - 1.255548701770560000f, 1.255250167802143000f, 1.254951587681765600f, - 1.254652961420405600f, - 1.254354289029042900f, 1.254055570518658500f, 1.253756805900235700f, - 1.253457995184759300f, - 1.253159138383215200f, 1.252860235506592100f, 1.252561286565879300f, - 1.252262291572068900f, - 1.251963250536153500f, 1.251664163469128300f, 1.251365030381989700f, - 1.251065851285736200f, - 1.250766626191367500f, 1.250467355109885500f, 1.250168038052293500f, - 1.249868675029596200f, - 1.249569266052800800f, 1.249269811132915200f, 1.248970310280950200f, - 1.248670763507917100f, - 1.248371170824829300f, 1.248071532242702100f, 1.247771847772552300f, - 1.247472117425398700f, - 1.247172341212261500f, 1.246872519144162300f, 1.246572651232124700f, - 1.246272737487174300f, - 1.245972777920338000f, 1.245672772542644400f, 1.245372721365123600f, - 1.245072624398807900f, - 1.244772481654731000f, 1.244472293143928300f, 1.244172058877436800f, - 1.243871778866295400f, - 1.243571453121544000f, 1.243271081654225400f, 1.242970664475383100f, - 1.242670201596062700f, - 1.242369693027311200f, 1.242069138780177400f, 1.241768538865712000f, - 1.241467893294967200f, - 1.241167202078996800f, 1.240866465228856100f, 1.240565682755603100f, - 1.240264854670295900f, - 1.239963980983995300f, 1.239663061707763700f, 1.239362096852665300f, - 1.239061086429765300f, - 1.238760030450130900f, 1.238458928924831600f, 1.238157781864937400f, - 1.237856589281521000f, - 1.237555351185656500f, 1.237254067588419400f, 1.236952738500886900f, - 1.236651363934138300f, - 1.236349943899254000f, 1.236048478407316500f, 1.235746967469409900f, - 1.235445411096619500f, - 1.235143809300033300f, 1.234842162090739700f, 1.234540469479829900f, - 1.234238731478396000f, - 1.233936948097532400f, 1.233635119348334400f, 1.233333245241899200f, - 1.233031325789326400f, - 1.232729361001716500f, 1.232427350890172000f, 1.232125295465796600f, - 1.231823194739696300f, - 1.231521048722978200f, 1.231218857426751700f, 1.230916620862127400f, - 1.230614339040217800f, - 1.230312011972136500f, 1.230009639668999500f, 1.229707222141924100f, - 1.229404759402029400f, - 1.229102251460436400f, 1.228799698328266700f, 1.228497100016644900f, - 1.228194456536696500f, - 1.227891767899548700f, 1.227589034116330700f, 1.227286255198173100f, - 1.226983431156208200f, - 1.226680562001569900f, 1.226377647745394000f, 1.226074688398817600f, - 1.225771683972980200f, - 1.225468634479021500f, 1.225165539928084300f, 1.224862400331312400f, - 1.224559215699851500f, - 1.224255986044848500f, 1.223952711377453100f, 1.223649391708814700f, - 1.223346027050086400f, - 1.223042617412421600f, 1.222739162806975900f, 1.222435663244906700f, - 1.222132118737372400f, - 1.221828529295533800f, 1.221524894930552800f, 1.221221215653593100f, - 1.220917491475820500f, - 1.220613722408401900f, 1.220309908462505800f, 1.220006049649302800f, - 1.219702145979964600f, - 1.219398197465665400f, 1.219094204117580300f, 1.218790165946886100f, - 1.218486082964761500f, - 1.218181955182386500f, 1.217877782610943700f, 1.217573565261616000f, - 1.217269303145589000f, - 1.216964996274049400f, 1.216660644658185600f, 1.216356248309187600f, - 1.216051807238247800f, - 1.215747321456559300f, 1.215442790975316700f, 1.215138215805717300f, - 1.214833595958959300f, - 1.214528931446242600f, 1.214224222278769100f, 1.213919468467741900f, - 1.213614670024366000f, - 1.213309826959847700f, 1.213004939285395400f, 1.212700007012219100f, - 1.212395030151530300f, - 1.212090008714541600f, 1.211784942712468300f, 1.211479832156526800f, - 1.211174677057934800f, - 1.210869477427912300f, 1.210564233277680500f, 1.210258944618462200f, - 1.209953611461482200f, - 1.209648233817966600f, 1.209342811699143600f, 1.209037345116242400f, - 1.208731834080493800f, - 1.208426278603131200f, 1.208120678695388600f, 1.207815034368502100f, - 1.207509345633709600f, - 1.207203612502250300f, 1.206897834985365000f, 1.206592013094296200f, - 1.206286146840288300f, - 1.205980236234587100f, 1.205674281288440000f, 1.205368282013096200f, - 1.205062238419806200f, - 1.204756150519822300f, 1.204450018324398900f, 1.204143841844791200f, - 1.203837621092256800f, - 1.203531356078054100f, 1.203225046813444000f, 1.202918693309688300f, - 1.202612295578050900f, - 1.202305853629797500f, 1.201999367476194400f, 1.201692837128510700f, - 1.201386262598016500f, - 1.201079643895983700f, 1.200772981033685800f, 1.200466274022397900f, - 1.200159522873396800f, - 1.199852727597960700f, 1.199545888207369700f, 1.199239004712905300f, - 1.198932077125851100f, - 1.198625105457491700f, 1.198318089719113200f, 1.198011029922004400f, - 1.197703926077454200f, - 1.197396778196754700f, 1.197089586291198500f, 1.196782350372080300f, - 1.196475070450696100f, - 1.196167746538343600f, 1.195860378646322700f, 1.195552966785933900f, - 1.195245510968480300f, - 1.194938011205265900f, 1.194630467507596500f, 1.194322879886780000f, - 1.194015248354125100f, - 1.193707572920943000f, 1.193399853598545500f, 1.193092090398246900f, - 1.192784283331362700f, - 1.192476432409210100f, 1.192168537643107900f, 1.191860599044376500f, - 1.191552616624337800f, - 1.191244590394315400f, 1.190936520365635000f, 1.190628406549622900f, - 1.190320248957608100f, - 1.190012047600920200f, 1.189703802490891000f, 1.189395513638853900f, - 1.189087181056143900f, - 1.188778804754097300f, 1.188470384744052100f, 1.188161921037348400f, - 1.187853413645327100f, - 1.187544862579331500f, 1.187236267850706000f, 1.186927629470796900f, - 1.186618947450951600f, - 1.186310221802519900f, 1.186001452536852300f, 1.185692639665301600f, - 1.185383783199222000f, - 1.185074883149969100f, 1.184765939528900500f, 1.184456952347374900f, - 1.184147921616753200f, - 1.183838847348397400f, 1.183529729553671500f, 1.183220568243940300f, - 1.182911363430571200f, - 1.182602115124932900f, 1.182292823338395100f, 1.181983488082330300f, - 1.181674109368111300f, - 1.181364687207113100f, 1.181055221610712400f, 1.180745712590287400f, - 1.180436160157217800f, - 1.180126564322885100f, 1.179816925098671900f, 1.179507242495962900f, - 1.179197516526144600f, - 1.178887747200604300f, 1.178577934530731700f, 1.178268078527917200f, - 1.177958179203553800f, - 1.177648236569035300f, 1.177338250635757700f, 1.177028221415118200f, - 1.176718148918515700f, - 1.176408033157350300f, 1.176097874143024600f, 1.175787671886942000f, - 1.175477426400507700f, - 1.175167137695128900f, 1.174856805782213500f, 1.174546430673171900f, - 1.174236012379415600f, - 1.173925550912357800f, 1.173615046283413200f, 1.173304498503998400f, - 1.172993907585530900f, - 1.172683273539430800f, 1.172372596377118800f, 1.172061876110017700f, - 1.171751112749551900f, - 1.171440306307147200f, 1.171129456794231200f, 1.170818564222232800f, - 1.170507628602582800f, - 1.170196649946713100f, 1.169885628266057900f, 1.169574563572052300f, - 1.169263455876133200f, - 1.168952305189739200f, 1.168641111524310700f, 1.168329874891289400f, - 1.168018595302118000f, - 1.167707272768241800f, 1.167395907301107100f, 1.167084498912162300f, - 1.166773047612856400f, - 1.166461553414641000f, 1.166150016328968600f, 1.165838436367293800f, - 1.165526813541072100f, - 1.165215147861761400f, 1.164903439340820900f, 1.164591687989710500f, - 1.164279893819892800f, - 1.163968056842831700f, 1.163656177069992500f, 1.163344254512841800f, - 1.163032289182848800f, - 1.162720281091483000f, 1.162408230250216100f, 1.162096136670521600f, - 1.161784000363874000f, - 1.161471821341749900f, 1.161159599615627000f, 1.160847335196984800f, - 1.160535028097304600f, - 1.160222678328068700f, 1.159910285900761700f, 1.159597850826869200f, - 1.159285373117878500f, - 1.158972852785278500f, 1.158660289840559800f, 1.158347684295214300f, - 1.158035036160735900f, - 1.157722345448619400f, 1.157409612170361600f, 1.157096836337461000f, - 1.156784017961417500f, - 1.156471157053732300f, 1.156158253625908700f, 1.155845307689450800f, - 1.155532319255865300f, - 1.155219288336659400f, 1.154906214943342700f, 1.154593099087426000f, - 1.154279940780421400f, - 1.153966740033842900f, 1.153653496859206000f, 1.153340211268028000f, - 1.153026883271827300f, - 1.152713512882124400f, 1.152400100110440700f, 1.152086644968299400f, - 1.151773147467225300f, - 1.151459607618745300f, 1.151146025434387000f, 1.150832400925680100f, - 1.150518734104155400f, - 1.150205024981345800f, 1.149891273568785400f, 1.149577479878009800f, - 1.149263643920556800f, - 1.148949765707964600f, 1.148635845251773800f, 1.148321882563526400f, - 1.148007877654766200f, - 1.147693830537038100f, 1.147379741221888500f, 1.147065609720865600f, - 1.146751436045519300f, - 1.146437220207400700f, 1.146122962218062600f, 1.145808662089060000f, - 1.145494319831947800f, - 1.145179935458284100f, 1.144865508979627800f, 1.144551040407539400f, - 1.144236529753581000f, - 1.143921977029316500f, 1.143607382246310600f, 1.143292745416130600f, - 1.142978066550344400f, - 1.142663345660522000f, 1.142348582758234900f, 1.142033777855056000f, - 1.141718930962559500f, - 1.141404042092321500f, 1.141089111255919800f, 1.140774138464933700f, - 1.140459123730943200f, - 1.140144067065530700f, 1.139828968480280300f, 1.139513827986776900f, - 1.139198645596607400f, - 1.138883421321360600f, 1.138568155172625700f, 1.138252847161994400f, - 1.137937497301059600f, - 1.137622105601416000f, 1.137306672074659900f, 1.136991196732388200f, - 1.136675679586200500f, - 1.136360120647697200f, 1.136044519928480800f, 1.135728877440154800f, - 1.135413193194324800f, - 1.135097467202597100f, 1.134781699476580300f, 1.134465890027884300f, - 1.134150038868120500f, - 1.133834146008902100f, 1.133518211461843200f, 1.133202235238559800f, - 1.132886217350669500f, - 1.132570157809791500f, 1.132254056627546300f, 1.131937913815556300f, - 1.131621729385444900f, - 1.131305503348837300f, 1.130989235717360100f, 1.130672926502642100f, - 1.130356575716312500f, - 1.130040183370002900f, 1.129723749475346000f, 1.129407274043976200f, - 1.129090757087529500f, - 1.128774198617643200f, 1.128457598645956600f, 1.128140957184109700f, - 1.127824274243744500f, - 1.127507549836505000f, 1.127190783974035800f, 1.126873976667983800f, - 1.126557127929996800f, - 1.126240237771724700f, 1.125923306204818400f, 1.125606333240930700f, - 1.125289318891715900f, - 1.124972263168829500f, 1.124655166083928800f, 1.124338027648672500f, - 1.124020847874721100f, - 1.123703626773736100f, 1.123386364357381200f, 1.123069060637320600f, - 1.122751715625221400f, - 1.122434329332750800f, 1.122116901771578400f, 1.121799432953375600f, - 1.121481922889814300f, - 1.121164371592568300f, 1.120846779073313400f, 1.120529145343726500f, - 1.120211470415486200f, - 1.119893754300272300f, 1.119575997009766300f, 1.119258198555651300f, - 1.118940358949611900f, - 1.118622478203333800f, 1.118304556328505200f, 1.117986593336814700f, - 1.117668589239953200f, - 1.117350544049612300f, 1.117032457777486200f, 1.116714330435269600f, - 1.116396162034659600f, - 1.116077952587353600f, 1.115759702105052000f, 1.115441410599455500f, - 1.115123078082267000f, - 1.114804704565190500f, 1.114486290059931900f, 1.114167834578198200f, - 1.113849338131698300f, - 1.113530800732142100f, 1.113212222391241500f, 1.112893603120710000f, - 1.112574942932261600f, - 1.112256241837613000f, 1.111937499848481900f, 1.111618716976587700f, - 1.111299893233650600f, - 1.110981028631393700f, 1.110662123181539900f, 1.110343176895814500f, - 1.110024189785944900f, - 1.109705161863658600f, 1.109386093140686000f, 1.109066983628758100f, - 1.108747833339607200f, - 1.108428642284968100f, 1.108109410476576300f, 1.107790137926169200f, - 1.107470824645485600f, - 1.107151470646265300f, 1.106832075940250600f, 1.106512640539184100f, - 1.106193164454811100f, - 1.105873647698877300f, 1.105554090283131100f, 1.105234492219321100f, - 1.104914853519198400f, - 1.104595174194514800f, 1.104275454257024300f, 1.103955693718482200f, - 1.103635892590644900f, - 1.103316050885270600f, 1.102996168614119000f, 1.102676245788951400f, - 1.102356282421530300f, - 1.102036278523620000f, 1.101716234106985700f, 1.101396149183395000f, - 1.101076023764616400f, - 1.100755857862419700f, 1.100435651488577100f, 1.100115404654861100f, - 1.099795117373046200f, - 1.099474789654909100f, 1.099154421512226600f, 1.098834012956778200f, - 1.098513564000344300f, - 1.098193074654706800f, 1.097872544931649100f, 1.097551974842956500f, - 1.097231364400415000f, - 1.096910713615813200f, 1.096590022500939700f, 1.096269291067585700f, - 1.095948519327543800f, - 1.095627707292607700f, 1.095306854974572800f, 1.094985962385235800f, - 1.094665029536395100f, - 1.094344056439850600f, 1.094023043107403200f, 1.093701989550856000f, - 1.093380895782013000f, - 1.093059761812680100f, 1.092738587654664300f, 1.092417373319774200f, - 1.092096118819820200f, - 1.091774824166613600f, 1.091453489371968100f, 1.091132114447697300f, - 1.090810699405617900f, - 1.090489244257547300f, 1.090167749015304300f, 1.089846213690709900f, - 1.089524638295585400f, - 1.089203022841754400f, 1.088881367341041800f, 1.088559671805274100f, - 1.088237936246279100f, - 1.087916160675885800f, 1.087594345105925300f, 1.087272489548229700f, - 1.086950594014632700f, - 1.086628658516969500f, 1.086306683067076900f, 1.085984667676792600f, - 1.085662612357956500f, - 1.085340517122409800f, 1.085018381981994500f, 1.084696206948555300f, - 1.084373992033937000f, - 1.084051737249986900f, 1.083729442608553300f, 1.083407108121486000f, - 1.083084733800636200f, - 1.082762319657857100f, 1.082439865705002500f, 1.082117371953928300f, - 1.081794838416491700f, - 1.081472265104551200f, 1.081149652029967000f, 1.080826999204601100f, - 1.080504306640315500f, - 1.080181574348975500f, 1.079858802342446900f, 1.079535990632596800f, - 1.079213139231294500f, - 1.078890248150409700f, 1.078567317401815100f, 1.078244346997383300f, - 1.077921336948988600f, - 1.077598287268508400f, 1.077275197967819000f, 1.076952069058800400f, - 1.076628900553332700f, - 1.076305692463297900f, 1.075982444800579700f, 1.075659157577062200f, - 1.075335830804633000f, - 1.075012464495178800f, 1.074689058660589700f, 1.074365613312755900f, - 1.074042128463569500f, - 1.073718604124924500f, 1.073395040308715400f, 1.073071437026839500f, - 1.072747794291194300f, - 1.072424112113678600f, 1.072100390506194500f, 1.071776629480643500f, - 1.071452829048929800f, - 1.071128989222958500f, 1.070805110014635900f, 1.070481191435870500f, - 1.070157233498571600f, - 1.069833236214650800f, 1.069509199596019800f, 1.069185123654592600f, - 1.068861008402285200f, - 1.068536853851013600f, 1.068212660012696700f, 1.067888426899253500f, - 1.067564154522606000f, - 1.067239842894676100f, 1.066915492027387600f, 1.066591101932666800f, - 1.066266672622439700f, - 1.065942204108635300f, 1.065617696403183400f, 1.065293149518014500f, - 1.064968563465062100f, - 1.064643938256259400f, 1.064319273903543000f, 1.063994570418849400f, - 1.063669827814116300f, - 1.063345046101285000f, 1.063020225292295300f, 1.062695365399091200f, - 1.062370466433616400f, - 1.062045528407815900f, 1.061720551333637600f, 1.061395535223029500f, - 1.061070480087941800f, - 1.060745385940325500f, 1.060420252792134000f, 1.060095080655320900f, - 1.059769869541841800f, - 1.059444619463654400f, 1.059119330432716700f, 1.058794002460989000f, - 1.058468635560432500f, - 1.058143229743009600f, 1.057817785020685100f, 1.057492301405424500f, - 1.057166778909195000f, - 1.056841217543965200f, 1.056515617321704500f, 1.056189978254385100f, - 1.055864300353978900f, - 1.055538583632461100f, 1.055212828101807200f, 1.054887033773993300f, - 1.054561200660999200f, - 1.054235328774803900f, 1.053909418127389400f, 1.053583468730738200f, - 1.053257480596834700f, - 1.052931453737664600f, 1.052605388165214700f, 1.052279283891473600f, - 1.051953140928431100f, - 1.051626959288079100f, 1.051300738982409800f, 1.050974480023417500f, - 1.050648182423098000f, - 1.050321846193448000f, 1.049995471346466300f, 1.049669057894152800f, - 1.049342605848508200f, - 1.049016115221536000f, 1.048689586025239700f, 1.048363018271625300f, - 1.048036411972699500f, - 1.047709767140470500f, 1.047383083786948700f, 1.047056361924144400f, - 1.046729601564071200f, - 1.046402802718742400f, 1.046075965400174300f, 1.045749089620383200f, - 1.045422175391386800f, - 1.045095222725206200f, 1.044768231633861100f, 1.044441202129375200f, - 1.044114134223771900f, - 1.043787027929076000f, 1.043459883257315400f, 1.043132700220517300f, - 1.042805478830712200f, - 1.042478219099930400f, 1.042150921040204200f, 1.041823584663568200f, - 1.041496209982056600f, - 1.041168797007707000f, 1.040841345752557200f, 1.040513856228645800f, - 1.040186328448014800f, - 1.039858762422705600f, 1.039531158164762400f, 1.039203515686230000f, - 1.038875834999155100f, - 1.038548116115585800f, 1.038220359047570500f, 1.037892563807160800f, - 1.037564730406408200f, - 1.037236858857366600f, 1.036908949172090900f, 1.036581001362636600f, - 1.036253015441062700f, - 1.035924991419427100f, 1.035596929309791300f, 1.035268829124216700f, - 1.034940690874766300f, - 1.034612514573505700f, 1.034284300232500000f, 1.033956047863817500f, - 1.033627757479526700f, - 1.033299429091697700f, 1.032971062712402700f, 1.032642658353714300f, - 1.032314216027707700f, - 1.031985735746457900f, 1.031657217522042900f, 1.031328661366541300f, - 1.031000067292032300f, - 1.030671435310598600f, 1.030342765434322200f, 1.030014057675287900f, - 1.029685312045581100f, - 1.029356528557288300f, 1.029027707222499100f, 1.028698848053302100f, - 1.028369951061789600f, - 1.028041016260053500f, 1.027712043660187600f, 1.027383033274288400f, - 1.027053985114451100f, - 1.026724899192775300f, 1.026395775521359500f, 1.026066614112305600f, - 1.025737414977715200f, - 1.025408178129692000f, 1.025078903580341600f, 1.024749591341769700f, - 1.024420241426085200f, - 1.024090853845396800f, 1.023761428611814600f, 1.023431965737451800f, - 1.023102465234420700f, - 1.022772927114837100f, 1.022443351390816400f, 1.022113738074476300f, - 1.021784087177936000f, - 1.021454398713315600f, 1.021124672692737000f, 1.020794909128323000f, - 1.020465108032198300f, - 1.020135269416488700f, 1.019805393293321100f, 1.019475479674824900f, - 1.019145528573129000f, - 1.018815540000365800f, 1.018485513968667500f, 1.018155450490168000f, - 1.017825349577003300f, - 1.017495211241309800f, 1.017165035495226400f, 1.016834822350892300f, - 1.016504571820448000f, - 1.016174283916036800f, 1.015843958649801600f, 1.015513596033888400f, - 1.015183196080442900f, - 1.014852758801613200f, 1.014522284209548900f, 1.014191772316400000f, - 1.013861223134318900f, - 1.013530636675459100f, 1.013200012951974700f, 1.012869351976022300f, - 1.012538653759758900f, - 1.012207918315344300f, 1.011877145654937400f, 1.011546335790700600f, - 1.011215488734796800f, - 1.010884604499389800f, 1.010553683096645900f, 1.010222724538731600f, - 1.009891728837815700f, - 1.009560696006067900f, 1.009229626055658800f, 1.008898518998761800f, - 1.008567374847549900f, - 1.008236193614199000f, 1.007904975310885300f, 1.007573719949786700f, - 1.007242427543082900f, - 1.006911098102953900f, 1.006579731641582500f, 1.006248328171152100f, - 1.005916887703846500f, - 1.005585410251852700f, 1.005253895827357800f, 1.004922344442551000f, - 1.004590756109621900f, - 1.004259130840762700f, 1.003927468648166100f, 1.003595769544025900f, - 1.003264033540538500f, - 1.002932260649900000f, 1.002600450884309800f, 1.002268604255967200f, - 1.001936720777072400f, - 1.001604800459829000f, 1.001272843316440000f, 1.000940849359111000f, - 1.000608818600048100f, - 1.000276751051459200f, 0.999944646725553720f, 0.999612505634541740f, - 0.999280327790635690f, - 0.998948113206048590f, 0.998615861892994560f, 0.998283573863690270f, - 0.997951249130352380f, - 0.997618887705200020f, 0.997286489600452630f, 0.996954054828332210f, - 0.996621583401061110f, - 0.996289075330862860f, 0.995956530629963810f, 0.995623949310589620f, - 0.995291331384969390f, - 0.994958676865332010f, 0.994625985763907820f, 0.994293258092929790f, - 0.993960493864630480f, - 0.993627693091245660f, 0.993294855785010760f, 0.992961981958163210f, - 0.992629071622942340f, - 0.992296124791587690f, 0.991963141476341460f, 0.991630121689446090f, - 0.991297065443145440f, - 0.990963972749685840f, 0.990630843621313260f, 0.990297678070276800f, - 0.989964476108825210f, - 0.989631237749210020f, 0.989297963003683330f, 0.988964651884498000f, - 0.988631304403909890f, - 0.988297920574174430f, 0.987964500407549910f, 0.987631043916294970f, - 0.987297551112669370f, - 0.986964022008935520f, 0.986630456617355380f, 0.986296854950194260f, - 0.985963217019717120f, - 0.985629542838190490f, 0.985295832417883540f, 0.984962085771065030f, - 0.984628302910006580f, - 0.984294483846980150f, 0.983960628594258810f, 0.983626737164118190f, - 0.983292809568833910f, - 0.982958845820684270f, 0.982624845931947320f, 0.982290809914904140f, - 0.981956737781835790f, - 0.981622629545024770f, 0.981288485216756160f, 0.980954304809314670f, - 0.980620088334987930f, - 0.980285835806063770f, 0.979951547234831130f, 0.979617222633581860f, - 0.979282862014607240f, - 0.978948465390201530f, 0.978614032772659240f, 0.978279564174275860f, - 0.977945059607349900f, - 0.977610519084179290f, 0.977275942617064740f, 0.976941330218307540f, - 0.976606681900209830f, - 0.976271997675076550f, 0.975937277555212310f, 0.975602521552924600f, - 0.975267729680520560f, - 0.974932901950310350f, 0.974598038374604350f, 0.974263138965714040f, - 0.973928203735953460f, - 0.973593232697636530f, 0.973258225863079970f, 0.972923183244600480f, - 0.972588104854516410f, - 0.972252990705148370f, 0.971917840808816710f, 0.971582655177844700f, - 0.971247433824555920f, - 0.970912176761274950f, 0.970576884000329040f, 0.970241555554045230f, - 0.969906191434753320f, - 0.969570791654783330f, 0.969235356226466500f, 0.968899885162136650f, - 0.968564378474127350f, - 0.968228836174775060f, 0.967893258276415700f, 0.967557644791388500f, - 0.967221995732032490f, - 0.966886311110688230f, 0.966550590939698640f, 0.966214835231406500f, - 0.965879043998157160f, - 0.965543217252296420f, 0.965207355006171270f, 0.964871457272131190f, - 0.964535524062525410f, - 0.964199555389706030f, 0.963863551266025300f, 0.963527511703836660f, - 0.963191436715496120f, - 0.962855326313359350f, 0.962519180509785130f, 0.962182999317132030f, - 0.961846782747760140f, - 0.961510530814032040f, 0.961174243528309820f, 0.960837920902958720f, - 0.960501562950343390f, - 0.960165169682831830f, 0.959828741112791590f, 0.959492277252591900f, - 0.959155778114604400f, - 0.958819243711200310f, 0.958482674054753960f, 0.958146069157639560f, - 0.957809429032232760f, - 0.957472753690911670f, 0.957136043146054050f, 0.956799297410040440f, - 0.956462516495251940f, - 0.956125700414070300f, 0.955788849178880300f, 0.955451962802066120f, - 0.955115041296014880f, - 0.954778084673113870f, 0.954441092945751630f, 0.954104066126319150f, - 0.953767004227207060f, - 0.953429907260809120f, 0.953092775239518630f, 0.952755608175731570f, - 0.952418406081844360f, - 0.952081168970254520f, 0.951743896853362140f, 0.951406589743566950f, - 0.951069247653271500f, - 0.950731870594878510f, 0.950394458580791970f, 0.950057011623418380f, - 0.949719529735163940f, - 0.949382012928437600f, 0.949044461215648560f, 0.948706874609207220f, - 0.948369253121526420f, - 0.948031596765018910f, 0.947693905552099870f, 0.947356179495185020f, - 0.947018418606691230f, - 0.946680622899037650f, 0.946342792384643360f, 0.946004927075930090f, - 0.945667026985319680f, - 0.945329092125236190f, 0.944991122508104350f, 0.944653118146349890f, - 0.944315079052401090f, - 0.943977005238685770f, 0.943638896717634900f, 0.943300753501679190f, - 0.942962575603250920f, - 0.942624363034784580f, 0.942286115808714690f, 0.941947833937478270f, - 0.941609517433512730f, - 0.941271166309256450f, 0.940932780577150460f, 0.940594360249635500f, - 0.940255905339155150f, - 0.939917415858152920f, 0.939578891819073720f, 0.939240333234364950f, - 0.938901740116473540f, - 0.938563112477849630f, 0.938224450330942590f, 0.937885753688204820f, - 0.937547022562088990f, - 0.937208256965048840f, 0.936869456909540490f, 0.936530622408019990f, - 0.936191753472946030f, - 0.935852850116777430f, 0.935513912351974450f, 0.935174940190999560f, - 0.934835933646314900f, - 0.934496892730385720f, 0.934157817455677160f, 0.933818707834655590f, - 0.933479563879790030f, - 0.933140385603548840f, 0.932801173018403480f, 0.932461926136825660f, - 0.932122644971287830f, - 0.931783329534265240f, 0.931443979838232900f, 0.931104595895668410f, - 0.930765177719049210f, - 0.930425725320855430f, 0.930086238713567440f, 0.929746717909666790f, - 0.929407162921637610f, - 0.929067573761963250f, 0.928727950443130500f, 0.928388292977625930f, - 0.928048601377937210f, - 0.927708875656554800f, 0.927369115825968480f, 0.927029321898671270f, - 0.926689493887155820f, - 0.926349631803916270f, 0.926009735661449170f, 0.925669805472250860f, - 0.925329841248820340f, - 0.924989843003656610f, 0.924649810749260110f, 0.924309744498133750f, - 0.923969644262779830f, - 0.923629510055703820f, 0.923289341889410480f, 0.922949139776407800f, - 0.922608903729203570f, - 0.922268633760306990f, 0.921928329882229390f, 0.921587992107482210f, - 0.921247620448579440f, - 0.920907214918035070f, 0.920566775528364410f, 0.920226302292085460f, - 0.919885795221715540f, - 0.919545254329774850f, 0.919204679628783720f, 0.918864071131263780f, - 0.918523428849739030f, - 0.918182752796733110f, 0.917842042984772340f, 0.917501299426383480f, - 0.917160522134094160f, - 0.916819711120434700f, 0.916478866397934850f, 0.916137987979127270f, - 0.915797075876544350f, - 0.915456130102721200f, 0.915115150670193110f, 0.914774137591496510f, - 0.914433090879170130f, - 0.914092010545752620f, 0.913750896603785280f, 0.913409749065809520f, - 0.913068567944367970f, - 0.912727353252005710f, 0.912386105001267270f, 0.912044823204700370f, - 0.911703507874852440f, - 0.911362159024272310f, 0.911020776665511290f, 0.910679360811120000f, - 0.910337911473652390f, - 0.909996428665661990f, 0.909654912399703860f, 0.909313362688335290f, - 0.908971779544113350f, - 0.908630162979597760f, 0.908288513007348140f, 0.907946829639926790f, - 0.907605112889895870f, - 0.907263362769819000f, 0.906921579292262250f, 0.906579762469791110f, - 0.906237912314974080f, - 0.905896028840379560f, 0.905554112058577170f, 0.905212161982139160f, - 0.904870178623637170f, - 0.904528161995645670f, 0.904186112110739510f, 0.903844028981494190f, - 0.903501912620488070f, - 0.903159763040298880f, 0.902817580253507450f, 0.902475364272694370f, - 0.902133115110441470f, - 0.901790832779333250f, 0.901448517291953520f, 0.901106168660889110f, - 0.900763786898726380f, - 0.900421372018054500f, 0.900078924031462610f, 0.899736442951541320f, - 0.899393928790883420f, - 0.899051381562081310f, 0.898708801277730340f, 0.898366187950425780f, - 0.898023541592764210f, - 0.897680862217344440f, 0.897338149836764960f, 0.896995404463627350f, - 0.896652626110532870f, - 0.896309814790084090f, 0.895966970514885940f, 0.895624093297543110f, - 0.895281183150662960f, - 0.894938240086852970f, 0.894595264118721810f, 0.894252255258880410f, - 0.893909213519939460f, - 0.893566138914512420f, 0.893223031455212530f, 0.892879891154655380f, - 0.892536718025457090f, - 0.892193512080234670f, 0.891850273331607600f, 0.891507001792195000f, - 0.891163697474618880f, - 0.890820360391500920f, 0.890476990555464480f, 0.890133587979135000f, - 0.889790152675137610f, - 0.889446684656100330f, 0.889103183934650930f, 0.888759650523418650f, - 0.888416084435035060f, - 0.888072485682131150f, 0.887728854277341050f, 0.887385190233298650f, - 0.887041493562639060f, - 0.886697764277999840f, 0.886354002392018110f, 0.886010207917333760f, - 0.885666380866586560f, - 0.885322521252418610f, 0.884978629087472270f, 0.884634704384391180f, - 0.884290747155821230f, - 0.883946757414407980f, 0.883602735172799640f, 0.883258680443644530f, - 0.882914593239592320f, - 0.882570473573294660f, 0.882226321457403320f, 0.881882136904572400f, - 0.881537919927456340f, - 0.881193670538710450f, 0.880849388750992610f, 0.880505074576960370f, - 0.880160728029273920f, - 0.879816349120593590f, 0.879471937863580690f, 0.879127494270899090f, - 0.878783018355212220f, - 0.878438510129186170f, 0.878093969605486800f, 0.877749396796782770f, - 0.877404791715742370f, - 0.877060154375035710f, 0.876715484787334630f, 0.876370782965310900f, - 0.876026048921639160f, - 0.875681282668993700f, 0.875336484220050390f, 0.874991653587487090f, - 0.874646790783981660f, - 0.874301895822214290f, 0.873956968714865500f, 0.873612009474616810f, - 0.873267018114152300f, - 0.872921994646155390f, 0.872576939083312460f, 0.872231851438309840f, - 0.871886731723835020f, - 0.871541579952577750f, 0.871196396137227660f, 0.870851180290476810f, - 0.870505932425017060f, - 0.870160652553543020f, 0.869815340688749220f, 0.869469996843331370f, - 0.869124621029987670f, - 0.868779213261415610f, 0.868433773550315810f, 0.868088301909388680f, - 0.867742798351335720f, - 0.867397262888861100f, 0.867051695534668210f, 0.866706096301463340f, - 0.866360465201952980f, - 0.866014802248844420f, 0.865669107454847490f, 0.865323380832671800f, - 0.864977622395029290f, - 0.864631832154632240f, 0.864286010124194040f, 0.863940156316430170f, - 0.863594270744056040f, - 0.863248353419789670f, 0.862902404356348570f, 0.862556423566453230f, - 0.862210411062823810f, - 0.861864366858181910f, 0.861518290965251340f, 0.861172183396755500f, - 0.860826044165420630f, - 0.860479873283972910f, 0.860133670765139580f, 0.859787436621650360f, - 0.859441170866234390f, - 0.859094873511623840f, 0.858748544570550610f, 0.858402184055747750f, - 0.858055791979950740f, - 0.857709368355894840f, 0.857362913196317630f, 0.857016426513956930f, - 0.856669908321551650f, - 0.856323358631843170f, 0.855976777457572280f, 0.855630164811482460f, - 0.855283520706317080f, - 0.854936845154821930f, 0.854590138169742830f, 0.854243399763827020f, - 0.853896629949823630f, - 0.853549828740481690f, 0.853202996148552880f, 0.852856132186788910f, - 0.852509236867942440f, - 0.852162310204768740f, 0.851815352210022470f, 0.851468362896461110f, - 0.851121342276842110f, - 0.850774290363923820f, 0.850427207170467380f, 0.850080092709233130f, - 0.849732946992984290f, - 0.849385770034483680f, 0.849038561846496730f, 0.848691322441788910f, - 0.848344051833126780f, - 0.847996750033279350f, 0.847649417055015060f, 0.847302052911105160f, - 0.846954657614320980f, - 0.846607231177434640f, 0.846259773613221020f, 0.845912284934454140f, - 0.845564765153910990f, - 0.845217214284368690f, 0.844869632338605130f, 0.844522019329400630f, - 0.844174375269535320f, - 0.843826700171791620f, 0.843478994048952440f, 0.843131256913801420f, - 0.842783488779124570f, - 0.842435689657707650f, 0.842087859562339000f, 0.841739998505806610f, - 0.841392106500900900f, - 0.841044183560412770f, 0.840696229697133760f, 0.840348244923857960f, - 0.840000229253379030f, - 0.839652182698493290f, 0.839304105271996950f, 0.838955996986687550f, - 0.838607857855364740f, - 0.838259687890827830f, 0.837911487105878820f, 0.837563255513319780f, - 0.837214993125953600f, - 0.836866699956585690f, 0.836518376018021260f, 0.836170021323067610f, - 0.835821635884532730f, - 0.835473219715225040f, 0.835124772827955830f, 0.834776295235535540f, - 0.834427786950777460f, - 0.834079247986494690f, 0.833730678355502630f, 0.833382078070616820f, - 0.833033447144653880f, - 0.832684785590432690f, 0.832336093420771970f, 0.831987370648492710f, - 0.831638617286416190f, - 0.831289833347364620f, 0.830941018844162600f, 0.830592173789634240f, - 0.830243298196606360f, - 0.829894392077905720f, 0.829545455446360270f, 0.829196488314800080f, - 0.828847490696055010f, - 0.828498462602957340f, 0.828149404048339590f, 0.827800315045035150f, - 0.827451195605879990f, - 0.827102045743709160f, 0.826752865471360950f, 0.826403654801672770f, - 0.826054413747485010f, - 0.825705142321637720f, 0.825355840536972420f, 0.825006508406332490f, - 0.824657145942561230f, - 0.824307753158504460f, 0.823958330067008030f, 0.823608876680918760f, - 0.823259393013085820f, - 0.822909879076357930f, 0.822560334883586490f, 0.822210760447622980f, - 0.821861155781319800f, - 0.821511520897531660f, 0.821161855809112830f, 0.820812160528920360f, - 0.820462435069811090f, - 0.820112679444643060f, 0.819762893666276530f, 0.819413077747571440f, - 0.819063231701390170f, - 0.818713355540594880f, 0.818363449278050270f, 0.818013512926620940f, - 0.817663546499172720f, - 0.817313550008573640f, 0.816963523467691410f, 0.816613466889396070f, - 0.816263380286557980f, - 0.815913263672048310f, 0.815563117058740630f, 0.815212940459508210f, - 0.814862733887226740f, - 0.814512497354771830f, 0.814162230875020380f, 0.813811934460851430f, - 0.813461608125143560f, - 0.813111251880778150f, 0.812760865740636440f, 0.812410449717600570f, - 0.812060003824555230f, - 0.811709528074384460f, 0.811359022479975040f, 0.811008487054213360f, - 0.810657921809988410f, - 0.810307326760189020f, 0.809956701917705080f, 0.809606047295428950f, - 0.809255362906252440f, - 0.808904648763069890f, 0.808553904878775760f, 0.808203131266265420f, - 0.807852327938436750f, - 0.807501494908186900f, 0.807150632188415760f, 0.806799739792023240f, - 0.806448817731910130f, - 0.806097866020979660f, 0.805746884672134620f, 0.805395873698280360f, - 0.805044833112322000f, - 0.804693762927166100f, 0.804342663155721230f, 0.803991533810895500f, - 0.803640374905599810f, - 0.803289186452744390f, 0.802937968465242240f, 0.802586720956006250f, - 0.802235443937950320f, - 0.801884137423990890f, 0.801532801427043530f, 0.801181435960026780f, - 0.800830041035858750f, - 0.800478616667459010f, 0.800127162867749210f, 0.799775679649650460f, - 0.799424167026086540f, - 0.799072625009981330f, 0.798721053614259490f, 0.798369452851848020f, - 0.798017822735673680f, - 0.797666163278665570f, 0.797314474493752810f, 0.796962756393865600f, - 0.796611008991936490f, - 0.796259232300897350f, 0.795907426333682830f, 0.795555591103226930f, - 0.795203726622466520f, - 0.794851832904338360f, 0.794499909961779990f, 0.794147957807731400f, - 0.793795976455132220f, - 0.793443965916924570f, 0.793091926206050400f, 0.792739857335452710f, - 0.792387759318077150f, - 0.792035632166868230f, 0.791683475894773720f, 0.791331290514740830f, - 0.790979076039718180f, - 0.790626832482656310f, 0.790274559856505520f, 0.789922258174218570f, - 0.789569927448748320f, - 0.789217567693048520f, 0.788865178920075130f, 0.788512761142783790f, - 0.788160314374132590f, - 0.787807838627079260f, 0.787455333914584220f, 0.787102800249607550f, - 0.786750237645110430f, - 0.786397646114056490f, 0.786045025669408700f, 0.785692376324132690f, - 0.785339698091194080f, - 0.784986990983559170f, 0.784634255014197040f, 0.784281490196075850f, - 0.783928696542166680f, - 0.783575874065440270f, 0.783223022778868350f, 0.782870142695425320f, - 0.782517233828084580f, - 0.782164296189822530f, 0.781811329793615120f, 0.781458334652439630f, - 0.781105310779275470f, - 0.780752258187101480f, 0.780399176888899150f, 0.780046066897649550f, - 0.779692928226336290f, - 0.779339760887942880f, 0.778986564895453810f, 0.778633340261856040f, - 0.778280087000135730f, - 0.777926805123281830f, 0.777573494644283050f, 0.777220155576129220f, - 0.776866787931812410f, - 0.776513391724324210f, 0.776159966966658680f, 0.775806513671809860f, - 0.775453031852772920f, - 0.775099521522545020f, 0.774745982694123090f, 0.774392415380506400f, - 0.774038819594694230f, - 0.773685195349686940f, 0.773331542658487140f, 0.772977861534096640f, - 0.772624151989520280f, - 0.772270414037761980f, 0.771916647691828660f, 0.771562852964726710f, - 0.771209029869463940f, - 0.770855178419050050f, 0.770501298626494410f, 0.770147390504808960f, - 0.769793454067005500f, - 0.769439489326096850f, 0.769085496295098040f, 0.768731474987023660f, - 0.768377425414890850f, - 0.768023347591716640f, 0.767669241530518850f, 0.767315107244318060f, - 0.766960944746133740f, - 0.766606754048988260f, 0.766252535165903970f, 0.765898288109903900f, - 0.765544012894013530f, - 0.765189709531257760f, 0.764835378034664170f, 0.764481018417259680f, - 0.764126630692073870f, - 0.763772214872136200f, 0.763417770970477140f, 0.763063299000129260f, - 0.762708798974124800f, - 0.762354270905498450f, 0.761999714807284790f, 0.761645130692519490f, - 0.761290518574240350f, - 0.760935878465484720f, 0.760581210379292380f, 0.760226514328703140f, - 0.759871790326757670f, - 0.759517038386499090f, 0.759162258520969860f, 0.758807450743214760f, - 0.758452615066278920f, - 0.758097751503208020f, 0.757742860067050380f, 0.757387940770853360f, - 0.757032993627667290f, - 0.756678018650541630f, 0.756323015852528700f, 0.755967985246680520f, - 0.755612926846050080f, - 0.755257840663692730f, 0.754902726712663120f, 0.754547585006018600f, - 0.754192415556816380f, - 0.753837218378114460f, 0.753481993482973400f, 0.753126740884452970f, - 0.752771460595615500f, - 0.752416152629523330f, 0.752060816999239660f, 0.751705453717829930f, - 0.751350062798359140f, - 0.750994644253894730f, 0.750639198097504010f, 0.750283724342255320f, - 0.749928223001219310f, - 0.749572694087465850f, 0.749217137614067500f, 0.748861553594096340f, - 0.748505942040627040f, - 0.748150302966733790f, 0.747794636385492150f, 0.747438942309979870f, - 0.747083220753273820f, - 0.746727471728453770f, 0.746371695248599140f, 0.746015891326790470f, - 0.745660059976110400f, - 0.745304201209641030f, 0.744948315040467210f, 0.744592401481673270f, - 0.744236460546344850f, - 0.743880492247569580f, 0.743524496598434670f, 0.743168473612029980f, - 0.742812423301444810f, - 0.742456345679769810f, 0.742100240760097840f, 0.741744108555520860f, - 0.741387949079133860f, - 0.741031762344030790f, 0.740675548363308620f, 0.740319307150063780f, - 0.739963038717393880f, - 0.739606743078398690f, 0.739250420246177380f, 0.738894070233831800f, - 0.738537693054463370f, - 0.738181288721174830f, 0.737824857247070810f, 0.737468398645255490f, - 0.737111912928835710f, - 0.736755400110918000f, 0.736398860204609870f, 0.736042293223021060f, - 0.735685699179260850f, - 0.735329078086440880f, 0.734972429957672760f, 0.734615754806068890f, - 0.734259052644744230f, - 0.733902323486812610f, 0.733545567345390890f, 0.733188784233595240f, - 0.732831974164544150f, - 0.732475137151356370f, 0.732118273207151170f, 0.731761382345050280f, - 0.731404464578174760f, - 0.731047519919648340f, 0.730690548382594280f, 0.730333549980137110f, - 0.729976524725403530f, - 0.729619472631519270f, 0.729262393711613280f, 0.728905287978813600f, - 0.728548155446249730f, - 0.728190996127053180f, 0.727833810034354990f, 0.727476597181288540f, - 0.727119357580987220f, - 0.726762091246585200f, 0.726404798191218950f, 0.726047478428024420f, - 0.725690131970139980f, - 0.725332758830703360f, 0.724975359022855150f, 0.724617932559735390f, - 0.724260479454485130f, - 0.723902999720247850f, 0.723545493370166160f, 0.723187960417385530f, - 0.722830400875050790f, - 0.722472814756308090f, 0.722115202074305680f, 0.721757562842191060f, - 0.721399897073114470f, - 0.721042204780225960f, 0.720684485976676230f, 0.720326740675618530f, - 0.719968968890205230f, - 0.719611170633591480f, 0.719253345918932090f, 0.718895494759382860f, - 0.718537617168101610f, - 0.718179713158245800f, 0.717821782742975370f, 0.717463825935449550f, - 0.717105842748830160f, - 0.716747833196278770f, 0.716389797290958090f, 0.716031735046032900f, - 0.715673646474667140f, - 0.715315531590027700f, 0.714957390405280950f, 0.714599222933594240f, - 0.714241029188137260f, - 0.713882809182079030f, 0.713524562928591010f, 0.713166290440844450f, - 0.712807991732011590f, - 0.712449666815266890f, 0.712091315703784260f, 0.711732938410739810f, - 0.711374534949309800f, - 0.711016105332671340f, 0.710657649574003460f, 0.710299167686484930f, - 0.709940659683296890f, - 0.709582125577619790f, 0.709223565382636760f, 0.708864979111530680f, - 0.708506366777485130f, - 0.708147728393686340f, 0.707789063973319310f, 0.707430373529572170f, - 0.707071657075632460f, - 0.706712914624688770f, 0.706354146189931750f, 0.705995351784551530f, - 0.705636531421740880f, - 0.705277685114692020f, 0.704918812876598410f, 0.704559914720655490f, - 0.704200990660058150f, - 0.703842040708003820f, 0.703483064877689630f, 0.703124063182313690f, - 0.702765035635076310f, - 0.702405982249177160f, 0.702046903037818250f, 0.701687798014201110f, - 0.701328667191529980f, - 0.700969510583008600f, 0.700610328201841660f, 0.700251120061236020f, - 0.699891886174398130f, - 0.699532626554536630f, 0.699173341214860190f, 0.698814030168578240f, - 0.698454693428902320f, - 0.698095331009043640f, 0.697735942922215520f, 0.697376529181631400f, - 0.697017089800505250f, - 0.696657624792053730f, 0.696298134169492380f, 0.695938617946039510f, - 0.695579076134912990f, - 0.695219508749331800f, 0.694859915802517050f, 0.694500297307689140f, - 0.694140653278070950f, - 0.693780983726884790f, 0.693421288667355530f, 0.693061568112707690f, - 0.692701822076166820f, - 0.692342050570960430f, 0.691982253610315510f, 0.691622431207461700f, - 0.691262583375628180f, - 0.690902710128045050f, 0.690542811477944610f, 0.690182887438558710f, - 0.689822938023121220f, - 0.689462963244866330f, 0.689102963117028790f, 0.688742937652845550f, - 0.688382886865552930f, - 0.688022810768389670f, 0.687662709374594510f, 0.687302582697406850f, - 0.686942430750068330f, - 0.686582253545819920f, 0.686222051097905130f, 0.685861823419566700f, - 0.685501570524050140f, - 0.685141292424600310f, 0.684780989134463280f, 0.684420660666887120f, - 0.684060307035119440f, - 0.683699928252410110f, 0.683339524332008840f, 0.682979095287166160f, - 0.682618641131135020f, - 0.682258161877167370f, 0.681897657538517720f, 0.681537128128440470f, - 0.681176573660190910f, - 0.680815994147026320f, 0.680455389602203310f, 0.680094760038981280f, - 0.679734105470619080f, - 0.679373425910376310f, 0.679012721371515250f, 0.678651991867297080f, - 0.678291237410985510f, - 0.677930458015843620f, 0.677569653695137220f, 0.677208824462131490f, - 0.676847970330092700f, - 0.676487091312289350f, 0.676126187421989040f, 0.675765258672461950f, - 0.675404305076978020f, - 0.675043326648808170f, 0.674682323401225250f, 0.674321295347501510f, - 0.673960242500911690f, - 0.673599164874730370f, 0.673238062482232950f, 0.672876935336696900f, - 0.672515783451398950f, - 0.672154606839618470f, 0.671793405514634180f, 0.671432179489727110f, - 0.671070928778178090f, - 0.670709653393269050f, 0.670348353348283690f, 0.669987028656505170f, - 0.669625679331219300f, - 0.669264305385711360f, 0.668902906833267590f, 0.668541483687176590f, - 0.668180035960725840f, - 0.667818563667205600f, 0.667457066819905800f, 0.667095545432117240f, - 0.666733999517132860f, - 0.666372429088244790f, 0.666010834158747840f, 0.665649214741936390f, - 0.665287570851105680f, - 0.664925902499553190f, 0.664564209700575500f, 0.664202492467472090f, - 0.663840750813541210f, - 0.663478984752084110f, 0.663117194296401260f, 0.662755379459794350f, - 0.662393540255567070f, - 0.662031676697022450f, 0.661669788797465960f, 0.661307876570202740f, - 0.660945940028538900f, - 0.660583979185782600f, 0.660221994055241400f, 0.659859984650225110f, - 0.659497950984043510f, - 0.659135893070007080f, 0.658773810921428500f, 0.658411704551619570f, - 0.658049573973894850f, - 0.657687419201568260f, 0.657325240247955020f, 0.656963037126372160f, - 0.656600809850135910f, - 0.656238558432565400f, 0.655876282886978410f, 0.655513983226695960f, - 0.655151659465038060f, - 0.654789311615326050f, 0.654426939690883280f, 0.654064543705032310f, - 0.653702123671098150f, - 0.653339679602405470f, 0.652977211512280050f, 0.652614719414049580f, - 0.652252203321041060f, - 0.651889663246583930f, 0.651527099204007310f, 0.651164511206641320f, - 0.650801899267818060f, - 0.650439263400868990f, 0.650076603619127890f, 0.649713919935928420f, - 0.649351212364604910f, - 0.648988480918494040f, 0.648625725610931460f, 0.648262946455255510f, - 0.647900143464803730f, - 0.647537316652916140f, 0.647174466032932490f, 0.646811591618193350f, - 0.646448693422041360f, - 0.646085771457818310f, 0.645722825738868860f, 0.645359856278536980f, - 0.644996863090167570f, - 0.644633846187107620f, 0.644270805582703550f, 0.643907741290304040f, - 0.643544653323257610f, - 0.643181541694913480f, 0.642818406418622980f, 0.642455247507736860f, - 0.642092064975608220f, - 0.641728858835589830f, 0.641365629101035340f, 0.641002375785300500f, - 0.640639098901740200f, - 0.640275798463712080f, 0.639912474484572560f, 0.639549126977681070f, - 0.639185755956396480f, - 0.638822361434078330f, 0.638458943424088490f, 0.638095501939787920f, - 0.637732036994540290f, - 0.637368548601708660f, 0.637005036774657030f, 0.636641501526751590f, - 0.636277942871357530f, - 0.635914360821842830f, 0.635550755391574910f, 0.635187126593922070f, - 0.634823474442254840f, - 0.634459798949942640f, 0.634096100130357660f, 0.633732377996871770f, - 0.633368632562857470f, - 0.633004863841689520f, 0.632641071846741790f, 0.632277256591390780f, - 0.631913418089012020f, - 0.631549556352983710f, 0.631185671396683470f, 0.630821763233490040f, - 0.630457831876783950f, - 0.630093877339945260f, 0.629729899636356280f, 0.629365898779399080f, - 0.629001874782456500f, - 0.628637827658913300f, 0.628273757422153860f, 0.627909664085564810f, - 0.627545547662532230f, - 0.627181408166443410f, 0.626817245610687520f, 0.626453060008652860f, - 0.626088851373730380f, - 0.625724619719310480f, 0.625360365058784670f, 0.624996087405546350f, - 0.624631786772988030f, - 0.624267463174504880f, 0.623903116623491180f, 0.623538747133343780f, - 0.623174354717459190f, - 0.622809939389234460f, 0.622445501162069090f, 0.622081040049361490f, - 0.621716556064512820f, - 0.621352049220923570f, 0.620987519531995270f, 0.620622967011131400f, - 0.620258391671734690f, - 0.619893793527210410f, 0.619529172590963410f, 0.619164528876399280f, - 0.618799862396925750f, - 0.618435173165949760f, 0.618070461196880800f, 0.617705726503127720f, - 0.617340969098100430f, - 0.616976188995210780f, 0.616611386207870040f, 0.616246560749491690f, - 0.615881712633488340f, - 0.615516841873275490f, 0.615151948482267840f, 0.614787032473881110f, - 0.614422093861533010f, - 0.614057132658640590f, 0.613692148878623000f, 0.613327142534899510f, - 0.612962113640889710f, - 0.612597062210015750f, 0.612231988255698470f, 0.611866891791361560f, - 0.611501772830428060f, - 0.611136631386322020f, 0.610771467472469460f, 0.610406281102295440f, - 0.610041072289227990f, - 0.609675841046694030f, 0.609310587388121830f, 0.608945311326941520f, - 0.608580012876582370f, - 0.608214692050476290f, 0.607849348862054220f, 0.607483983324749510f, - 0.607118595451995420f, - 0.606753185257225550f, 0.606387752753876020f, 0.606022297955381760f, - 0.605656820875180360f, - 0.605291321526709060f, 0.604925799923405670f, 0.604560256078710220f, - 0.604194690006061960f, - 0.603829101718902580f, 0.603463491230673220f, 0.603097858554815790f, - 0.602732203704774650f, - 0.602366526693992930f, 0.602000827535916330f, 0.601635106243990190f, - 0.601269362831660550f, - 0.600903597312375640f, 0.600537809699582810f, 0.600172000006731770f, - 0.599806168247271620f, - 0.599440314434653620f, 0.599074438582328780f, 0.598708540703749010f, - 0.598342620812368000f, - 0.597976678921638860f, 0.597610715045016950f, 0.597244729195957500f, - 0.596878721387916090f, - 0.596512691634350830f, 0.596146639948718640f, 0.595780566344478960f, - 0.595414470835091030f, - 0.595048353434014630f, 0.594682214154711790f, 0.594316053010643270f, - 0.593949870015273000f, - 0.593583665182063740f, 0.593217438524479500f, 0.592851190055986300f, - 0.592484919790049140f, - 0.592118627740135460f, 0.591752313919712170f, 0.591385978342248260f, - 0.591019621021212420f, - 0.590653241970074180f, 0.590286841202305120f, 0.589920418731375800f, - 0.589553974570759530f, - 0.589187508733928890f, 0.588821021234357310f, 0.588454512085520460f, - 0.588087981300892900f, - 0.587721428893951850f, 0.587354854878173850f, 0.586988259267036350f, - 0.586621642074019120f, - 0.586255003312600500f, 0.585888342996261690f, 0.585521661138483250f, - 0.585154957752746730f, - 0.584788232852535560f, 0.584421486451332410f, 0.584054718562622140f, - 0.583687929199888990f, - 0.583321118376619710f, 0.582954286106300290f, 0.582587432402417840f, - 0.582220557278461340f, - 0.581853660747918780f, 0.581486742824280810f, 0.581119803521037650f, - 0.580752842851679940f, - 0.580385860829700780f, 0.580018857468592270f, 0.579651832781848730f, - 0.579284786782964360f, - 0.578917719485433800f, 0.578550630902754050f, 0.578183521048421080f, - 0.577816389935933090f, - 0.577449237578788300f, 0.577082063990485340f, 0.576714869184524860f, - 0.576347653174406840f, - 0.575980415973633590f, 0.575613157595706530f, 0.575245878054129520f, - 0.574878577362406000f, - 0.574511255534040030f, 0.574143912582537940f, 0.573776548521405030f, - 0.573409163364148930f, - 0.573041757124277180f, 0.572674329815297640f, 0.572306881450720390f, - 0.571939412044054740f, - 0.571571921608812320f, 0.571204410158504090f, 0.570836877706642270f, - 0.570469324266740570f, - 0.570101749852312100f, 0.569734154476872480f, 0.569366538153936560f, - 0.568998900897020210f, - 0.568631242719641270f, 0.568263563635316600f, 0.567895863657565500f, - 0.567528142799906490f, - 0.567160401075860410f, 0.566792638498947680f, 0.566424855082689470f, - 0.566057050840608870f, - 0.565689225786228160f, 0.565321379933072190f, 0.564953513294665140f, - 0.564585625884531870f, - 0.564217717716199550f, 0.563849788803194140f, 0.563481839159044150f, - 0.563113868797277870f, - 0.562745877731423820f, 0.562377865975012940f, 0.562009833541575080f, - 0.561641780444642640f, - 0.561273706697747450f, 0.560905612314422150f, 0.560537497308201240f, - 0.560169361692618440f, - 0.559801205481210040f, 0.559433028687510990f, 0.559064831325059240f, - 0.558696613407391630f, - 0.558328374948046320f, 0.557960115960563050f, 0.557591836458480870f, - 0.557223536455341280f, - 0.556855215964685120f, 0.556486875000054000f, 0.556118513574991650f, - 0.555750131703040880f, - 0.555381729397746880f, 0.555013306672654360f, 0.554644863541308600f, - 0.554276400017257090f, - 0.553907916114046440f, 0.553539411845225590f, 0.553170887224342820f, - 0.552802342264947400f, - 0.552433776980590490f, 0.552065191384822350f, 0.551696585491195710f, - 0.551327959313262280f, - 0.550959312864576220f, 0.550590646158691240f, 0.550221959209161620f, - 0.549853252029543830f, - 0.549484524633393480f, 0.549115777034268170f, 0.548747009245725500f, - 0.548378221281323520f, - 0.548009413154622370f, 0.547640584879181100f, 0.547271736468561530f, - 0.546902867936324590f, - 0.546533979296032200f, 0.546165070561248080f, 0.545796141745535150f, - 0.545427192862458780f, - 0.545058223925583670f, 0.544689234948475210f, 0.544320225944701200f, - 0.543951196927828010f, - 0.543582147911424560f, 0.543213078909059120f, 0.542843989934301940f, - 0.542474881000723050f, - 0.542105752121893050f, 0.541736603311384620f, 0.541367434582769480f, - 0.540998245949621760f, - 0.540629037425515050f, 0.540259809024023600f, 0.539890560758723770f, - 0.539521292643190930f, - 0.539152004691002770f, 0.538782696915736770f, 0.538413369330970610f, - 0.538044021950284450f, - 0.537674654787257180f, 0.537305267855470390f, 0.536935861168504670f, - 0.536566434739941920f, - 0.536196988583365510f, 0.535827522712358230f, 0.535458037140505110f, - 0.535088531881390050f, - 0.534719006948599860f, 0.534349462355720230f, 0.533979898116337950f, - 0.533610314244041710f, - 0.533240710752419080f, 0.532871087655060300f, 0.532501444965554960f, - 0.532131782697493170f, - 0.531762100864467290f, 0.531392399480068670f, 0.531022678557890980f, - 0.530652938111527360f, - 0.530283178154571710f, 0.529913398700619820f, 0.529543599763266700f, - 0.529173781356109600f, - 0.528803943492745180f, 0.528434086186771010f, 0.528064209451786560f, - 0.527694313301390160f, - 0.527324397749182720f, 0.526954462808764120f, 0.526584508493736840f, - 0.526214534817702310f, - 0.525844541794263210f, 0.525474529437023890f, 0.525104497759587900f, - 0.524734446775560910f, - 0.524364376498548390f, 0.523994286942156220f, 0.523624178119992400f, - 0.523254050045663940f, - 0.522883902732780290f, 0.522513736194950230f, 0.522143550445783310f, - 0.521773345498891090f, - 0.521403121367884030f, 0.521032878066375100f, 0.520662615607976660f, - 0.520292334006301820f, - 0.519922033274965560f, 0.519551713427582000f, 0.519181374477767470f, - 0.518811016439137520f, - 0.518440639325310040f, 0.518070243149902240f, 0.517699827926532130f, - 0.517329393668819580f, - 0.516958940390383700f, 0.516588468104845820f, 0.516217976825826600f, - 0.515847466566947580f, - 0.515476937341832310f, 0.515106389164103120f, 0.514735822047384990f, - 0.514365236005302040f, - 0.513994631051479240f, 0.513624007199543600f, 0.513253364463121090f, - 0.512882702855839920f, - 0.512512022391327980f, 0.512141323083213470f, 0.511770604945127050f, - 0.511399867990697920f, - 0.511029112233557960f, 0.510658337687338040f, 0.510287544365671140f, - 0.509916732282189920f, - 0.509545901450527690f, 0.509175051884319660f, 0.508804183597200140f, - 0.508433296602805670f, - 0.508062390914772230f, 0.507691466546736580f, 0.507320523512337470f, - 0.506949561825212450f, - 0.506578581499001590f, 0.506207582547344550f, 0.505836564983881190f, - 0.505465528822253710f, - 0.505094474076103310f, 0.504723400759073290f, 0.504352308884806750f, - 0.503981198466947000f, - 0.503610069519139780f, 0.503238922055029400f, 0.502867756088262840f, - 0.502496571632486070f, - 0.502125368701347050f, 0.501754147308493770f, 0.501382907467574190f, - 0.501011649192238950f, - 0.500640372496137020f, 0.500269077392920150f, 0.499897763896239410f, - 0.499526432019746450f, - 0.499155081777094940f, 0.498783713181937540f, 0.498412326247929250f, - 0.498040920988724490f, - 0.497669497417978280f, 0.497298055549347750f, 0.496926595396488870f, - 0.496555116973059980f, - 0.496183620292718900f, 0.495812105369124070f, 0.495440572215935850f, - 0.495069020846813650f, - 0.494697451275419140f, 0.494325863515413130f, 0.493954257580458580f, - 0.493582633484217940f, - 0.493210991240354450f, 0.492839330862533120f, 0.492467652364417970f, - 0.492095955759675460f, - 0.491724241061971320f, 0.491352508284972070f, 0.490980757442346090f, - 0.490608988547760690f, - 0.490237201614885710f, 0.489865396657390210f, 0.489493573688943970f, - 0.489121732723218740f, - 0.488749873773885120f, 0.488377996854616250f, 0.488006101979084450f, - 0.487634189160962910f, - 0.487262258413926560f, 0.486890309751649490f, 0.486518343187807900f, - 0.486146358736077200f, - 0.485774356410135000f, 0.485402336223658360f, 0.485030298190324950f, - 0.484658242323814380f, - 0.484286168637805270f, 0.483914077145978560f, 0.483541967862014480f, - 0.483169840799594130f, - 0.482797695972400300f, 0.482425533394114920f, 0.482053353078422120f, - 0.481681155039005550f, - 0.481308939289549380f, 0.480936705843739820f, 0.480564454715261990f, - 0.480192185917803270f, - 0.479819899465050160f, 0.479447595370691370f, 0.479075273648415010f, - 0.478702934311909910f, - 0.478330577374866780f, 0.477958202850975230f, 0.477585810753927250f, - 0.477213401097414220f, - 0.476840973895128200f, 0.476468529160763100f, 0.476096066908011760f, - 0.475723587150569390f, - 0.475351089902130650f, 0.474978575176390750f, 0.474606042987046840f, - 0.474233493347795020f, - 0.473860926272333670f, 0.473488341774360670f, 0.473115739867574380f, - 0.472743120565675250f, - 0.472370483882362520f, 0.471997829831337810f, 0.471625158426301700f, - 0.471252469680957190f, - 0.470879763609006460f, 0.470507040224152460f, 0.470134299540099940f, - 0.469761541570552780f, - 0.469388766329217000f, 0.469015973829798090f, 0.468643164086002100f, - 0.468270337111537040f, - 0.467897492920109850f, 0.467524631525429830f, 0.467151752941205530f, - 0.466778857181146260f, - 0.466405944258963200f, 0.466033014188366350f, 0.465660066983068220f, - 0.465287102656780530f, - 0.464914121223215740f, 0.464541122696088100f, 0.464168107089110940f, - 0.463795074415999760f, - 0.463422024690469060f, 0.463048957926235630f, 0.462675874137015720f, - 0.462302773336526080f, - 0.461929655538485470f, 0.461556520756611410f, 0.461183369004623920f, - 0.460810200296242310f, - 0.460437014645186440f, 0.460063812065178160f, 0.459690592569938270f, - 0.459317356173189750f, - 0.458944102888655060f, 0.458570832730057170f, 0.458197545711121090f, - 0.457824241845570630f, - 0.457450921147131930f, 0.457077583629530550f, 0.456704229306492570f, - 0.456330858191746010f, - 0.455957470299017840f, 0.455584065642037350f, 0.455210644234532610f, - 0.454837206090234200f, - 0.454463751222871910f, 0.454090279646176210f, 0.453716791373879380f, - 0.453343286419712720f, - 0.452969764797409750f, 0.452596226520703360f, 0.452222671603327130f, - 0.451849100059016350f, - 0.451475511901505420f, 0.451101907144530910f, 0.450728285801828830f, - 0.450354647887135640f, - 0.449980993414189900f, 0.449607322396728900f, 0.449233634848492320f, - 0.448859930783219170f, - 0.448486210214649020f, 0.448112473156523420f, 0.447738719622582710f, - 0.447364949626569590f, - 0.446991163182225700f, 0.446617360303294910f, 0.446243541003520480f, - 0.445869705296646270f, - 0.445495853196417930f, 0.445121984716580210f, 0.444748099870879880f, - 0.444374198673063330f, - 0.444000281136877280f, 0.443626347276070590f, 0.443252397104390790f, - 0.442878430635587910f, - 0.442504447883411090f, 0.442130448861610240f, 0.441756433583937120f, - 0.441382402064142250f, - 0.441008354315978680f, 0.440634290353198510f, 0.440260210189554690f, - 0.439886113838801880f, - 0.439512001314693700f, 0.439137872630986080f, 0.438763727801433690f, - 0.438389566839793740f, - 0.438015389759822630f, 0.437641196575277220f, 0.437266987299916590f, - 0.436892761947498260f, - 0.436518520531782470f, 0.436144263066528480f, 0.435769989565496290f, - 0.435395700042447710f, - 0.435021394511143410f, 0.434647072985346380f, 0.434272735478819010f, - 0.433898382005324050f, - 0.433524012578626440f, 0.433149627212489670f, 0.432775225920679740f, - 0.432400808716961900f, - 0.432026375615101930f, 0.431651926628867530f, 0.431277461772025310f, - 0.430902981058344070f, - 0.430528484501591540f, 0.430153972115537800f, 0.429779443913952170f, - 0.429404899910604490f, - 0.429030340119266550f, 0.428655764553708960f, 0.428281173227704760f, - 0.427906566155026040f, - 0.427531943349445720f, 0.427157304824738350f, 0.426782650594677570f, - 0.426407980673039090f, - 0.426033295073598160f, 0.425658593810130330f, 0.425283876896413280f, - 0.424909144346223290f, - 0.424534396173339160f, 0.424159632391538870f, 0.423784853014600950f, - 0.423410058056305830f, - 0.423035247530432810f, 0.422660421450763490f, 0.422285579831078230f, - 0.421910722685159720f, - 0.421535850026790060f, 0.421160961869751720f, 0.420786058227829220f, - 0.420411139114805770f, - 0.420036204544466940f, 0.419661254530597550f, 0.419286289086983070f, - 0.418911308227410740f, - 0.418536311965666650f, 0.418161300315539220f, 0.417786273290816130f, - 0.417411230905285650f, - 0.417036173172737830f, 0.416661100106961610f, 0.416286011721748230f, - 0.415910908030888200f, - 0.415535789048172620f, 0.415160654787394280f, 0.414785505262345030f, - 0.414410340486818910f, - 0.414035160474608700f, 0.413659965239509710f, 0.413284754795316230f, - 0.412909529155823300f, - 0.412534288334827750f, 0.412159032346125280f, 0.411783761203513790f, - 0.411408474920790520f, - 0.411033173511753220f, 0.410657856990201580f, 0.410282525369933980f, - 0.409907178664751180f, - 0.409531816888453190f, 0.409156440054840590f, 0.408781048177715660f, - 0.408405641270879690f, - 0.408030219348136270f, 0.407654782423288010f, 0.407279330510138260f, - 0.406903863622492260f, - 0.406528381774153900f, 0.406152884978929480f, 0.405777373250624070f, - 0.405401846603045010f, - 0.405026305049998980f, 0.404650748605293040f, 0.404275177282736260f, - 0.403899591096136380f, - 0.403523990059303620f, 0.403148374186047210f, 0.402772743490177110f, - 0.402397097985504990f, - 0.402021437685841480f, 0.401645762604999350f, 0.401270072756790610f, - 0.400894368155027990f, - 0.400518648813525830f, 0.400142914746097480f, 0.399767165966558420f, - 0.399391402488723400f, - 0.399015624326407800f, 0.398639831493428740f, 0.398264024003602220f, - 0.397888201870746420f, - 0.397512365108678430f, 0.397136513731217500f, 0.396760647752182230f, - 0.396384767185391620f, - 0.396008872044666730f, 0.395632962343827170f, 0.395257038096694990f, - 0.394881099317091370f, - 0.394505146018838130f, 0.394129178215758820f, 0.393753195921675850f, - 0.393377199150413860f, - 0.393001187915796750f, 0.392625162231649010f, 0.392249122111796800f, - 0.391873067570065240f, - 0.391496998620281590f, 0.391120915276272410f, 0.390744817551864850f, - 0.390368705460887750f, - 0.389992579017168830f, 0.389616438234538010f, 0.389240283126824070f, - 0.388864113707858060f, - 0.388487929991470140f, 0.388111731991491180f, 0.387735519721753690f, - 0.387359293196089140f, - 0.386983052428331030f, 0.386606797432312350f, 0.386230528221866430f, - 0.385854244810828530f, - 0.385477947213032580f, 0.385101635442314900f, 0.384725309512510880f, - 0.384348969437456610f, - 0.383972615230989860f, 0.383596246906947210f, 0.383219864479167560f, - 0.382843467961488940f, - 0.382467057367749940f, 0.382090632711791060f, 0.381714194007451380f, - 0.381337741268572390f, - 0.380961274508994250f, 0.380584793742559550f, 0.380208298983109930f, - 0.379831790244487540f, - 0.379455267540536490f, 0.379078730885099520f, 0.378702180292021630f, - 0.378325615775147170f, - 0.377949037348320800f, 0.377572445025389230f, 0.377195838820197690f, - 0.376819218746593910f, - 0.376442584818424570f, 0.376065937049537060f, 0.375689275453780500f, - 0.375312600045002780f, - 0.374935910837054080f, 0.374559207843783660f, 0.374182491079041500f, - 0.373805760556679190f, - 0.373429016290547200f, 0.373052258294498230f, 0.372675486582383640f, - 0.372298701168057190f, - 0.371921902065371730f, 0.371545089288180640f, 0.371168262850339210f, - 0.370791422765701320f, - 0.370414569048123140f, 0.370037701711460170f, 0.369660820769568240f, - 0.369283926236305070f, - 0.368907018125527120f, 0.368530096451093140f, 0.368153161226860980f, - 0.367776212466689010f, - 0.367399250184437480f, 0.367022274393965340f, 0.366645285109133750f, - 0.366268282343803150f, - 0.365891266111834370f, 0.365514236427090080f, 0.365137193303431750f, - 0.364760136754723020f, - 0.364383066794826350f, 0.364005983437606320f, 0.363628886696926890f, - 0.363251776586652310f, - 0.362874653120648700f, 0.362497516312780990f, 0.362120366176916230f, - 0.361743202726920790f, - 0.361366025976661450f, 0.360988835940006750f, 0.360611632630824020f, - 0.360234416062982840f, - 0.359857186250351960f, 0.359479943206800550f, 0.359102686946199680f, - 0.358725417482419150f, - 0.358348134829330870f, 0.357970839000806010f, 0.357593530010716310f, - 0.357216207872935120f, - 0.356838872601334680f, 0.356461524209789380f, 0.356084162712172360f, - 0.355706788122359060f, - 0.355329400454223950f, 0.354951999721642100f, 0.354574585938490280f, - 0.354197159118644080f, - 0.353819719275981330f, 0.353442266424378930f, 0.353064800577714280f, - 0.352687321749866610f, - 0.352309829954713830f, 0.351932325206136210f, 0.351554807518012990f, - 0.351177276904224070f, - 0.350799733378650890f, 0.350422176955173910f, 0.350044607647675640f, - 0.349667025470037810f, - 0.349289430436142520f, 0.348911822559873850f, 0.348534201855114360f, - 0.348156568335749040f, - 0.347778922015661520f, 0.347401262908737570f, 0.347023591028862320f, - 0.346645906389921150f, - 0.346268209005801410f, 0.345890498890388980f, 0.345512776057572080f, - 0.345135040521238170f, - 0.344757292295274910f, 0.344379531393571970f, 0.344001757830017680f, - 0.343623971618502560f, - 0.343246172772916250f, 0.342868361307148980f, 0.342490537235092600f, - 0.342112700570637750f, - 0.341734851327677280f, 0.341356989520103240f, 0.340979115161808070f, - 0.340601228266685980f, - 0.340223328848629880f, 0.339845416921535030f, 0.339467492499295200f, - 0.339089555595806560f, - 0.338711606224964210f, 0.338333644400663940f, 0.337955670136803170f, - 0.337577683447278010f, - 0.337199684345986910f, 0.336821672846827290f, 0.336443648963697160f, - 0.336065612710496290f, - 0.335687564101123050f, 0.335309503149478110f, 0.334931429869461230f, - 0.334553344274972690f, - 0.334175246379914470f, 0.333797136198187240f, 0.333419013743693980f, - 0.333040879030336690f, - 0.332662732072017800f, 0.332284572882641680f, 0.331906401476111280f, - 0.331528217866331690f, - 0.331150022067206780f, 0.330771814092642610f, 0.330393593956544440f, - 0.330015361672817750f, - 0.329637117255370090f, 0.329258860718107450f, 0.328880592074938190f, - 0.328502311339769700f, - 0.328124018526509800f, 0.327745713649068180f, 0.327367396721353070f, - 0.326989067757275040f, - 0.326610726770743760f, 0.326232373775669270f, 0.325854008785963320f, - 0.325475631815536570f, - 0.325097242878301660f, 0.324718841988170470f, 0.324340429159055250f, - 0.323962004404870050f, - 0.323583567739527570f, 0.323205119176942720f, 0.322826658731029110f, - 0.322448186415702550f, - 0.322069702244877910f, 0.321691206232470550f, 0.321312698392397570f, - 0.320934178738574720f, - 0.320555647284919980f, 0.320177104045350440f, 0.319798549033783570f, - 0.319419982264138650f, - 0.319041403750333630f, 0.318662813506288670f, 0.318284211545923010f, - 0.317905597883156250f, - 0.317526972531909870f, 0.317148335506103940f, 0.316769686819660780f, - 0.316391026486501690f, - 0.316012354520548600f, 0.315633670935725030f, 0.315254975745953180f, - 0.314876268965157470f, - 0.314497550607261090f, 0.314118820686189180f, 0.313740079215866160f, - 0.313361326210216840f, - 0.312982561683167790f, 0.312603785648644220f, 0.312224998120573420f, - 0.311846199112882030f, - 0.311467388639496860f, 0.311088566714346650f, 0.310709733351358600f, - 0.310330888564462340f, - 0.309952032367586390f, 0.309573164774659850f, 0.309194285799613390f, - 0.308815395456376430f, - 0.308436493758880660f, 0.308057580721056660f, 0.307678656356835560f, - 0.307299720680150270f, - 0.306920773704932260f, 0.306541815445115160f, 0.306162845914631390f, - 0.305783865127415400f, - 0.305404873097400780f, 0.305025869838521590f, 0.304646855364713530f, - 0.304267829689911010f, - 0.303888792828050650f, 0.303509744793068030f, 0.303130685598899270f, - 0.302751615259482190f, - 0.302372533788753170f, 0.301993441200650910f, 0.301614337509113100f, - 0.301235222728077840f, - 0.300856096871485010f, 0.300476959953273060f, 0.300097811987382670f, - 0.299718652987753580f, - 0.299339482968325970f, 0.298960301943041680f, 0.298581109925841300f, - 0.298201906930667390f, - 0.297822692971461410f, 0.297443468062166820f, 0.297064232216726120f, - 0.296684985449082390f, - 0.296305727773180260f, 0.295926459202963120f, 0.295547179752376430f, - 0.295167889435364820f, - 0.294788588265873170f, 0.294409276257848300f, 0.294029953425235520f, - 0.293650619781982260f, - 0.293271275342035120f, 0.292891920119341120f, 0.292512554127848930f, - 0.292133177381505850f, - 0.291753789894261320f, 0.291374391680063520f, 0.290994982752862730f, - 0.290615563126608250f, - 0.290236132815249790f, 0.289856691832738880f, 0.289477240193025510f, - 0.289097777910061970f, - 0.288718304997799550f, 0.288338821470189910f, 0.287959327341186510f, - 0.287579822624741350f, - 0.287200307334808670f, 0.286820781485341620f, 0.286441245090293950f, - 0.286061698163620930f, - 0.285682140719276560f, 0.285302572771216960f, 0.284922994333397350f, - 0.284543405419773240f, - 0.284163806044301910f, 0.283784196220939370f, 0.283404575963643550f, - 0.283024945286371230f, - 0.282645304203081090f, 0.282265652727731130f, 0.281885990874279570f, - 0.281506318656686290f, - 0.281126636088910030f, 0.280746943184911340f, 0.280367239958650150f, - 0.279987526424086530f, - 0.279607802595182420f, 0.279228068485898210f, 0.278848324110196550f, - 0.278468569482039130f, - 0.278088804615388040f, 0.277709029524206950f, 0.277329244222458250f, - 0.276949448724106480f, - 0.276569643043115150f, 0.276189827193448200f, 0.275810001189071290f, - 0.275430165043948570f, - 0.275050318772046500f, 0.274670462387330010f, 0.274290595903766200f, - 0.273910719335321300f, - 0.273530832695961790f, 0.273150935999655950f, 0.272771029260370560f, - 0.272391112492074590f, - 0.272011185708736060f, 0.271631248924323390f, 0.271251302152806570f, - 0.270871345408154380f, - 0.270491378704337540f, 0.270111402055325910f, 0.269731415475089780f, - 0.269351418977600950f, - 0.268971412576829990f, 0.268591396286749500f, 0.268211370121331170f, - 0.267831334094547010f, - 0.267451288220370730f, 0.267071232512774700f, 0.266691166985733360f, - 0.266311091653219700f, - 0.265931006529208920f, 0.265550911627675250f, 0.265170806962593210f, - 0.264790692547939020f, - 0.264410568397687560f, 0.264030434525815760f, 0.263650290946299660f, - 0.263270137673115630f, - 0.262889974720241610f, 0.262509802101654310f, 0.262129619831332370f, - 0.261749427923253670f, - 0.261369226391396310f, 0.260989015249740050f, 0.260608794512263380f, - 0.260228564192946710f, - 0.259848324305769600f, 0.259468074864711960f, 0.259087815883755400f, - 0.258707547376880010f, - 0.258327269358068100f, 0.257946981841300490f, 0.257566684840560170f, - 0.257186378369829110f, - 0.256806062443089680f, 0.256425737074325920f, 0.256045402277520320f, - 0.255665058066657680f, - 0.255284704455721660f, 0.254904341458696390f, 0.254523969089567590f, - 0.254143587362319620f, - 0.253763196290938850f, 0.253382795889410710f, 0.253002386171721110f, - 0.252621967151857420f, - 0.252241538843805680f, 0.251861101261554090f, 0.251480654419089730f, - 0.251100198330400150f, - 0.250719733009474530f, 0.250339258470300590f, 0.249958774726868170f, - 0.249578281793165680f, - 0.249197779683183660f, 0.248817268410911650f, 0.248436747990339490f, - 0.248056218435458720f, - 0.247675679760259450f, 0.247295131978733870f, 0.246914575104873220f, - 0.246534009152669040f, - 0.246153434136114490f, 0.245772850069201410f, 0.245392256965923620f, - 0.245011654840274010f, - 0.244631043706245800f, 0.244250423577833860f, 0.243869794469031620f, - 0.243489156393834590f, - 0.243108509366237320f, 0.242727853400234670f, 0.242347188509823150f, - 0.241966514708997830f, - 0.241585832011755900f, 0.241205140432093070f, 0.240824439984007180f, - 0.240443730681495050f, - 0.240063012538553830f, 0.239682285569182310f, 0.239301549787377890f, - 0.238920805207139960f, - 0.238540051842467020f, 0.238159289707357810f, 0.237778518815812740f, - 0.237397739181830820f, - 0.237016950819413100f, 0.236636153742559610f, 0.236255347965270780f, - 0.235874533501548580f, - 0.235493710365393630f, 0.235112878570808560f, 0.234732038131795020f, - 0.234351189062355030f, - 0.233970331376492150f, 0.233589465088208580f, 0.233208590211508550f, - 0.232827706760394850f, - 0.232446814748872410f, 0.232065914190945020f, 0.231685005100616930f, - 0.231304087491893930f, - 0.230923161378780380f, 0.230542226775282770f, 0.230161283695406500f, - 0.229780332153157300f, - 0.229399372162542610f, 0.229018403737568290f, 0.228637426892242400f, - 0.228256441640571880f, - 0.227875447996564060f, 0.227494445974227850f, 0.227113435587570770f, - 0.226732416850602300f, - 0.226351389777330990f, 0.225970354381765690f, 0.225589310677916880f, - 0.225208258679793520f, - 0.224827198401406690f, 0.224446129856766040f, 0.224065053059883250f, - 0.223683968024768950f, - 0.223302874765434120f, 0.222921773295891380f, 0.222540663630151820f, - 0.222159545782228660f, - 0.221778419766134050f, 0.221397285595880480f, 0.221016143285482050f, - 0.220634992848951380f, - 0.220253834300303180f, 0.219872667653551100f, 0.219491492922709110f, - 0.219110310121792800f, - 0.218729119264816280f, 0.218347920365795780f, 0.217966713438746380f, - 0.217585498497683580f, - 0.217204275556624420f, 0.216823044629584520f, 0.216441805730581500f, - 0.216060558873631570f, - 0.215679304072752960f, 0.215298041341962870f, 0.214916770695278810f, - 0.214535492146719880f, - 0.214154205710303750f, 0.213772911400050090f, 0.213391609229977570f, - 0.213010299214105140f, - 0.212628981366453330f, 0.212247655701041290f, 0.211866322231890090f, - 0.211484980973019880f, - 0.211103631938451000f, 0.210722275142205480f, 0.210340910598303870f, - 0.209959538320768660f, - 0.209578158323621420f, 0.209196770620883960f, 0.208815375226579670f, - 0.208433972154730530f, - 0.208052561419360520f, 0.207671143034492080f, 0.207289717014149830f, - 0.206908283372357230f, - 0.206526842123138070f, 0.206145393280517730f, 0.205763936858520150f, - 0.205382472871171230f, - 0.205001001332495910f, 0.204619522256519300f, 0.204238035657268250f, - 0.203856541548768030f, - 0.203475039945045950f, 0.203093530860128300f, 0.202712014308041620f, - 0.202330490302814110f, - 0.201948958858472420f, 0.201567419989045200f, 0.201185873708560170f, - 0.200804320031045230f, - 0.200422758970529910f, 0.200041190541042220f, 0.199659614756612230f, - 0.199278031631268500f, - 0.198896441179041650f, 0.198514843413961220f, 0.198133238350057030f, - 0.197751626001360480f, - 0.197370006381901520f, 0.196988379505712050f, 0.196606745386822960f, - 0.196225104039265410f, - 0.195843455477072190f, 0.195461799714274460f, 0.195080136764905570f, - 0.194698466642997730f, - 0.194316789362583340f, 0.193935104937696560f, 0.193553413382369890f, - 0.193171714710637930f, - 0.192790008936534220f, 0.192408296074092570f, 0.192026576137348330f, - 0.191644849140335360f, - 0.191263115097089540f, 0.190881374021645320f, 0.190499625928039040f, - 0.190117870830306100f, - 0.189736108742482030f, 0.189354339678604100f, 0.188972563652707950f, - 0.188590780678831250f, - 0.188208990771010640f, 0.187827193943283040f, 0.187445390209686870f, - 0.187063579584259070f, - 0.186681762081038650f, 0.186299937714063470f, 0.185918106497371700f, - 0.185536268445003070f, - 0.185154423570995760f, 0.184772571889390000f, 0.184390713414225000f, - 0.184008848159540110f, - 0.183626976139376310f, 0.183245097367773090f, 0.182863211858771880f, - 0.182481319626412670f, - 0.182099420684737420f, 0.181717515047787020f, 0.181335602729602590f, - 0.180953683744226880f, - 0.180571758105701030f, 0.180189825828068250f, 0.179807886925370670f, - 0.179425941411650660f, - 0.179043989300952110f, 0.178662030607317450f, 0.178280065344791100f, - 0.177898093527416370f, - 0.177516115169236820f, 0.177134130284297610f, 0.176752138886642350f, - 0.176370140990316640f, - 0.175988136609365020f, 0.175606125757832240f, 0.175224108449764660f, - 0.174842084699207030f, - 0.174460054520206240f, 0.174078017926807490f, 0.173695974933058080f, - 0.173313925553004180f, - 0.172931869800692250f, 0.172549807690170230f, 0.172167739235484620f, - 0.171785664450683800f, - 0.171403583349815180f, 0.171021495946926340f, 0.170639402256066410f, - 0.170257302291283000f, - 0.169875196066625710f, 0.169493083596143100f, 0.169110964893883830f, - 0.168728839973898290f, - 0.168346708850235140f, 0.167964571536945220f, 0.167582428048078130f, - 0.167200278397683750f, - 0.166818122599813570f, 0.166435960668517400f, 0.166053792617847200f, - 0.165671618461853270f, - 0.165289438214587970f, 0.164907251890102520f, 0.164525059502448390f, - 0.164142861065678550f, - 0.163760656593844480f, 0.163378446100999640f, 0.162996229601196390f, - 0.162614007108487250f, - 0.162231778636926370f, 0.161849544200566300f, 0.161467303813461580f, - 0.161085057489665670f, - 0.160702805243232240f, 0.160320547088216470f, 0.159938283038672050f, - 0.159556013108654580f, - 0.159173737312218650f, 0.158791455663418930f, 0.158409168176311760f, - 0.158026874864951870f, - 0.157644575743395960f, 0.157262270825699210f, 0.156879960125918730f, - 0.156497643658110590f, - 0.156115321436331000f, 0.155732993474637760f, 0.155350659787087090f, - 0.154968320387737170f, - 0.154585975290645110f, 0.154203624509868190f, 0.153821268059465250f, - 0.153438905953493550f, - 0.153056538206012340f, 0.152674164831079730f, 0.152291785842754070f, - 0.151909401255095250f, - 0.151527011082161540f, 0.151144615338013210f, 0.150762214036709470f, - 0.150379807192309620f, - 0.149997394818874590f, 0.149614976930463660f, 0.149232553541138180f, - 0.148850124664957870f, - 0.148467690315984390f, 0.148085250508278370f, 0.147702805255900570f, - 0.147320354572913260f, - 0.146937898473377210f, 0.146555436971355090f, 0.146172970080908520f, - 0.145790497816099230f, - 0.145408020190990560f, 0.145025537219644170f, 0.144643048916123810f, - 0.144260555294492000f, - 0.143878056368811510f, 0.143495552153146630f, 0.143113042661560050f, - 0.142730527908116440f, - 0.142348007906879320f, 0.141965482671912420f, 0.141582952217280980f, - 0.141200416557048680f, - 0.140817875705281120f, 0.140435329676042390f, 0.140052778483398480f, - 0.139670222141414250f, - 0.139287660664154770f, 0.138905094065686600f, 0.138522522360074780f, - 0.138139945561386200f, - 0.137757363683686740f, 0.137374776741042340f, 0.136992184747520560f, - 0.136609587717187310f, - 0.136226985664110460f, 0.135844378602356760f, 0.135461766545993150f, - 0.135079149509088060f, - 0.134696527505708320f, 0.134313900549922760f, 0.133931268655799020f, - 0.133548631837404950f, - 0.133165990108809860f, 0.132783343484081580f, 0.132400691977289760f, - 0.132018035602502530f, - 0.131635374373789940f, 0.131252708305220960f, 0.130870037410864640f, - 0.130487361704791580f, - 0.130104681201070800f, 0.129721995913773260f, 0.129339305856968730f, - 0.128956611044727220f, - 0.128573911491120210f, 0.128191207210217570f, 0.127808498216091110f, - 0.127425784522811530f, - 0.127043066144449680f, 0.126660343095077900f, 0.126277615388766920f, - 0.125894883039589430f, - 0.125512146061616980f, 0.125129404468921260f, 0.124746658275575490f, - 0.124363907495651240f, - 0.123981152143222060f, 0.123598392232359880f, 0.123215627777138580f, - 0.122832858791630880f, - 0.122450085289909640f, 0.122067307286049230f, 0.121684524794122440f, - 0.121301737828203960f, - 0.120918946402367330f, 0.120536150530686250f, 0.120153350227235940f, - 0.119770545506089950f, - 0.119387736381323830f, 0.119004922867011920f, 0.118622104977228730f, - 0.118239282726050290f, - 0.117856456127550970f, 0.117473625195807100f, 0.117090789944893860f, - 0.116707950388886520f, - 0.116325106541861910f, 0.115942258417895240f, 0.115559406031063570f, - 0.115176549395442460f, - 0.114793688525109290f, 0.114410823434140360f, 0.114027954136612060f, - 0.113645080646602280f, - 0.113262202978187320f, 0.112879321145445350f, 0.112496435162453430f, - 0.112113545043288730f, - 0.111730650802029900f, 0.111347752452754000f, 0.110964850009539970f, - 0.110581943486465610f, - 0.110199032897608850f, 0.109816118257049110f, 0.109433199578864170f, - 0.109050276877133770f, - 0.108667350165936400f, 0.108284419459350770f, 0.107901484771457020f, - 0.107518546116333660f, - 0.107135603508061170f, 0.106752656960718350f, 0.106369706488385940f, - 0.105986752105143480f, - 0.105603793825070680f, 0.105220831662248700f, 0.104837865630757090f, - 0.104454895744677270f, - 0.104071922018089540f, 0.103688944465074300f, 0.103305963099713400f, - 0.102922977936087120f, - 0.102539988988277600f, 0.102156996270365800f, 0.101773999796432830f, - 0.101390999580561250f, - 0.101007995636832020f, 0.100624987979327970f, 0.100241976622130760f, - 0.099858961579322170f, - 0.099475942864985456f, 0.099092920493202258f, 0.098709894478056073f, - 0.098326864833628791f, - 0.097943831574004214f, 0.097560794713264939f, 0.097177754265493674f, - 0.096794710244774623f, - 0.096411662665190329f, 0.096028611540825232f, 0.095645556885762609f, - 0.095262498714085819f, - 0.094879437039879722f, 0.094496371877227495f, 0.094113303240214247f, - 0.093730231142923864f, - 0.093347155599440373f, 0.092964076623849271f, 0.092580994230234359f, - 0.092197908432681386f, - 0.091814819245274432f, 0.091431726682099479f, 0.091048630757241303f, - 0.090665531484784803f, - 0.090282428878816323f, 0.089899322953420582f, 0.089516213722684160f, - 0.089133101200692441f, - 0.088749985401530951f, 0.088366866339286629f, 0.087983744028044805f, - 0.087600618481892656f, - 0.087217489714916191f, 0.086834357741201490f, 0.086451222574836131f, - 0.086068084229906014f, - 0.085684942720498897f, 0.085301798060701386f, 0.084918650264600160f, - 0.084535499346283349f, - 0.084152345319837438f, 0.083769188199350780f, 0.083386027998910095f, - 0.083002864732603973f, - 0.082619698414519799f, 0.082236529058745025f, 0.081853356679368619f, - 0.081470181290477811f, - 0.081087002906161790f, 0.080703821540508452f, 0.080320637207605849f, - 0.079937449921543474f, - 0.079554259696409127f, 0.079171066546292510f, 0.078787870485282088f, - 0.078404671527466441f, - 0.078021469686935602f, 0.077638264977777913f, 0.077255057414083589f, - 0.076871847009941652f, - 0.076488633779441206f, 0.076105417736672773f, 0.075722198895725248f, - 0.075338977270689375f, - 0.074955752875654230f, 0.074572525724710764f, 0.074189295831948693f, - 0.073806063211457842f, - 0.073422827877329483f, 0.073039589843653177f, 0.072656349124520389f, - 0.072273105734021334f, - 0.071889859686246352f, 0.071506610995287156f, 0.071123359675233852f, - 0.070740105740178361f, - 0.070356849204211397f, 0.069973590081423773f, 0.069590328385907715f, - 0.069207064131753759f, - 0.068823797333054326f, 0.068440528003900616f, 0.068057256158383886f, - 0.067673981810596848f, - 0.067290704974630494f, 0.066907425664577733f, 0.066524143894529736f, - 0.066140859678579578f, - 0.065757573030819083f, 0.065374283965340146f, 0.064990992496236119f, - 0.064607698637598646f, - 0.064224402403521202f, 0.063841103808096086f, 0.063457802865415636f, - 0.063074499589573618f, - 0.062691193994662109f, 0.062307886094775049f, 0.061924575904005130f, - 0.061541263436445129f, - 0.061157948706189229f, 0.060774631727329942f, 0.060391312513961619f, - 0.060007991080177375f, - 0.059624667440070382f, 0.059241341607735261f, 0.058858013597264912f, - 0.058474683422754095f, - 0.058091351098295878f, 0.057708016637985186f, 0.057324680055915692f, - 0.056941341366181127f, - 0.056558000582876661f, 0.056174657720095743f, 0.055791312791933681f, - 0.055407965812484541f, - 0.055024616795842439f, 0.054641265756102911f, 0.054257912707359794f, - 0.053874557663708772f, - 0.053491200639244271f, 0.053107841648060788f, 0.052724480704254229f, - 0.052341117821918783f, - 0.051957753015150501f, 0.051574386298044173f, 0.051191017684694640f, - 0.050807647189198162f, - 0.050424274825649297f, 0.050040900608144430f, 0.049657524550778251f, - 0.049274146667647289f, - 0.048890766972846805f, 0.048507385480472134f, 0.048124002204620014f, - 0.047740617159385448f, - 0.047357230358865306f, 0.046973841817155179f, 0.046590451548350717f, - 0.046207059566548990f, - 0.045823665885845313f, 0.045440270520336883f, 0.045056873484119603f, - 0.044673474791289434f, - 0.044290074455943754f, 0.043906672492178188f, 0.043523268914090238f, - 0.043139863735776100f, - 0.042756456971332048f, 0.042373048634855741f, 0.041989638740443119f, - 0.041606227302191955f, - 0.041222814334198304f, 0.040839399850560058f, 0.040455983865373815f, - 0.040072566392736257f, - 0.039689147446745419f, 0.039305727041497644f, 0.038922305191091085f, - 0.038538881909622631f, - 0.038155457211189216f, 0.037772031109889144f, 0.037388603619819022f, - 0.037005174755077273f, - 0.036621744529761024f, 0.036238312957967478f, 0.035854880053795196f, - 0.035471445831341021f, - 0.035088010304703626f, 0.034704573487980395f, 0.034321135395268765f, - 0.033937696040667535f, - 0.033554255438273790f, 0.033170813602186440f, 0.032787370546502645f, - 0.032403926285321405f, - 0.032020480832740429f, 0.031637034202857461f, 0.031253586409771626f, - 0.030870137467580314f, - 0.030486687390382738f, 0.030103236192276818f, 0.029719783887360508f, - 0.029336330489733147f, - 0.028952876013492331f, 0.028569420472737472f, 0.028185963881566689f, - 0.027802506254078142f, - 0.027419047604371360f, 0.027035587946544135f, 0.026652127294696067f, - 0.026268665662925468f, - 0.025885203065330677f, 0.025501739516011413f, 0.025118275029065638f, - 0.024734809618593138f, - 0.024351343298691951f, 0.023967876083461924f, 0.023584407987001611f, - 0.023200939023409587f, - 0.022817469206785804f, 0.022433998551228459f, 0.022050527070837558f, - 0.021667054779711814f, - 0.021283581691949955f, 0.020900107821652084f, 0.020516633182916549f, - 0.020133157789843505f, - 0.019749681656531803f, 0.019366204797080316f, 0.018982727225589285f, - 0.018599248956157190f, - 0.018215770002884327f, 0.017832290379869671f, 0.017448810101212228f, - 0.017065329181012358f, - 0.016681847633368677f, 0.016298365472381587f, 0.015914882712149747f, - 0.015531399366773606f, - 0.015147915450352307f, 0.014764430976985016f, 0.014380945960772247f, - 0.013997460415812761f, - 0.013613974356207112f, 0.013230487796054543f, 0.012847000749454314f, - 0.012463513230507034f, - 0.012080025253311559f, 0.011696536831968529f, 0.011313047980577277f, - 0.010929558713237145f, - 0.010546069044048827f, 0.010162578987111254f, 0.009779088556525145f, - 0.009395597766389905f, - 0.009012106630804949f, 0.008628615163871038f, 0.008245123379687167f, - 0.007861631292354124f, - 0.007478138915970929f, 0.007094646264638386f, 0.006711153352455981f, - 0.006327660193523208f, - 0.005944166801940901f, 0.005560673191808128f, 0.005177179377225743f, - 0.004793685372293270f, - 0.004410191191110246f, 0.004026696847777542f, 0.003643202356394263f, - 0.003259707731061291f, - 0.002876212985878184f, 0.002492718134944503f, 0.002109223192361147f, - 0.001725728172227238f, - 0.001342233088643682f, 0.000958737955710053f, 0.000575242787525925f, - 0.000191747598192208f -}; + 1.999999990808214700f, 1.999999917273932200f, 1.999999770205369800f, + 1.999999549602533100f, 1.999999255465430200f, 1.999998887794072000f, + 1.999998446588471700f, 1.999997931848645600f, 1.999997343574612800f, + 1.999996681766395000f, 1.999995946424016200f, 1.999995137547503600f, + 1.999994255136887000f, 1.999993299192198700f, 1.999992269713474200f, + 1.999991166700750800f, 1.999989990154069600f, 1.999988740073473500f, + 1.999987416459008600f, 1.999986019310723500f, 1.999984548628669600f, + 1.999983004412901000f, 1.999981386663474400f, 1.999979695380449400f, + 1.999977930563888100f, 1.999976092213855400f, 1.999974180330418700f, + 1.999972194913648900f, 1.999970135963618400f, 1.999968003480403000f, + 1.999965797464081200f, 1.999963517914734100f, 1.999961164832445800f, + 1.999958738217302300f, 1.999956238069392900f, 1.999953664388809800f, + 1.999951017175647600f, 1.999948296430003500f, 1.999945502151977600f, + 1.999942634341672600f, 1.999939692999193900f, 1.999936678124649700f, + 1.999933589718150700f, 1.999930427779810900f, 1.999927192309745900f, + 1.999923883308075200f, 1.999920500774920300f, 1.999917044710405500f, + 1.999913515114657900f, 1.999909911987807200f, 1.999906235329986100f, + 1.999902485141329400f, 1.999898661421975400f, 1.999894764172064600f, + 1.999890793391740000f, 1.999886749081147800f, 1.999882631240436700f, + 1.999878439869758200f, 1.999874174969266300f, 1.999869836539117700f, + 1.999865424579472000f, 1.999860939090491600f, 1.999856380072341000f, + 1.999851747525188200f, 1.999847041449203300f, 1.999842261844559700f, + 1.999837408711432600f, 1.999832482050000900f, 1.999827481860445300f, + 1.999822408142949900f, 1.999817260897701400f, 1.999812040124888700f, + 1.999806745824704000f, 1.999801377997341800f, 1.999795936642999600f, + 1.999790421761877400f, 1.999784833354177900f, 1.999779171420106700f, + 1.999773435959872000f, 1.999767626973684400f, 1.999761744461757700f, + 1.999755788424308200f, 1.999749758861554900f, 1.999743655773719400f, + 1.999737479161026100f, 1.999731229023702200f, 1.999724905361977200f, + 1.999718508176084000f, 1.999712037466257600f, 1.999705493232735800f, + 1.999698875475759600f, 1.999692184195571900f, 1.999685419392419000f, + 1.999678581066549400f, 1.999671669218214600f, 1.999664683847668800f, + 1.999657624955168700f, 1.999650492540973900f, 1.999643286605346800f, + 1.999636007148552400f, 1.999628654170857900f, 1.999621227672533800f, + 1.999613727653853500f, 1.999606154115092500f, 1.999598507056529000f, + 1.999590786478444600f, 1.999582992381123000f, 1.999575124764850800f, + 1.999567183629917100f, 1.999559168976613900f, 1.999551080805236100f, + 1.999542919116081000f, 1.999534683909448600f, 1.999526375185641800f, + 1.999517992944965800f, 1.999509537187729200f, 1.999501007914242600f, + 1.999492405124819700f, 1.999483728819776900f, 1.999474978999432800f, + 1.999466155664109600f, 1.999457258814131500f, 1.999448288449825500f, + 1.999439244571521700f, 1.999430127179552500f, 1.999420936274252800f, + 1.999411671855960900f, 1.999402333925017300f, 1.999392922481765500f, + 1.999383437526551300f, 1.999373879059723500f, 1.999364247081633500f, + 1.999354541592635500f, 1.999344762593086500f, 1.999334910083345700f, + 1.999324984063775700f, 1.999314984534741100f, 1.999304911496609700f, + 1.999294764949752100f, 1.999284544894541100f, 1.999274251331352400f, + 1.999263884260564600f, 1.999253443682558900f, 1.999242929597719200f, + 1.999232342006432000f, 1.999221680909086400f, 1.999210946306074500f, + 1.999200138197791100f, 1.999189256584633600f, 1.999178301467001900f, + 1.999167272845298900f, 1.999156170719930100f, 1.999144995091303600f, + 1.999133745959830600f, 1.999122423325924200f, 1.999111027190001000f, + 1.999099557552479900f, 1.999088014413782800f, 1.999076397774334000f, + 1.999064707634560700f, 1.999052943994892300f, 1.999041106855761900f, + 1.999029196217604100f, 1.999017212080857400f, 1.999005154445962200f, + 1.998993023313361700f, 1.998980818683502100f, 1.998968540556831800f, + 1.998956188933802800f, 1.998943763814868800f, 1.998931265200486900f, + 1.998918693091116200f, 1.998906047487219600f, 1.998893328389261400f, + 1.998880535797709700f, 1.998867669713034500f, 1.998854730135709400f, + 1.998841717066209400f, 1.998828630505013400f, 1.998815470452602400f, + 1.998802236909460500f, 1.998788929876074100f, 1.998775549352932400f, + 1.998762095340527400f, 1.998748567839354000f, 1.998734966849909000f, + 1.998721292372693100f, 1.998707544408208700f, 1.998693722956961500f, + 1.998679828019459300f, 1.998665859596213500f, 1.998651817687737300f, + 1.998637702294547000f, 1.998623513417161700f, 1.998609251056103100f, + 1.998594915211895600f, 1.998580505885066100f, 1.998566023076144600f, + 1.998551466785663400f, 1.998536837014157900f, 1.998522133762165900f, + 1.998507357030227900f, 1.998492506818887200f, 1.998477583128690100f, + 1.998462585960185000f, 1.998447515313923400f, 1.998432371190459500f, + 1.998417153590349900f, 1.998401862514154200f, 1.998386497962434800f, + 1.998371059935756300f, 1.998355548434686400f, 1.998339963459795400f, + 1.998324305011656600f, 1.998308573090845200f, 1.998292767697940100f, + 1.998276888833522300f, 1.998260936498175400f, 1.998244910692486000f, + 1.998228811417043700f, 1.998212638672439900f, 1.998196392459269400f, + 1.998180072778129600f, 1.998163679629620500f, 1.998147213014344900f, + 1.998130672932908000f, 1.998114059385918400f, 1.998097372373986300f, + 1.998080611897725700f, 1.998063777957752600f, 1.998046870554686100f, + 1.998029889689147700f, 1.998012835361761900f, 1.997995707573155600f, + 1.997978506323958600f, 1.997961231614803200f, 1.997943883446324800f, + 1.997926461819161000f, 1.997908966733952500f, 1.997891398191342400f, + 1.997873756191977000f, 1.997856040736504500f, 1.997838251825576400f, + 1.997820389459846700f, 1.997802453639972300f, 1.997784444366612600f, + 1.997766361640429800f, 1.997748205462088500f, 1.997729975832256600f, + 1.997711672751604200f, 1.997693296220804000f, 1.997674846240532000f, + 1.997656322811466500f, 1.997637725934288300f, 1.997619055609681600f, + 1.997600311838332500f, 1.997581494620930300f, 1.997562603958166600f, + 1.997543639850736200f, 1.997524602299336500f, 1.997505491304667000f, + 1.997486306867430900f, 1.997467048988333000f, 1.997447717668082000f, + 1.997428312907388200f, 1.997408834706965000f, 1.997389283067528800f, + 1.997369657989798400f, 1.997349959474495200f, 1.997330187522343700f, + 1.997310342134070800f, 1.997290423310406100f, 1.997270431052081900f, + 1.997250365359833200f, 1.997230226234397900f, 1.997210013676516700f, + 1.997189727686932400f, 1.997169368266390900f, 1.997148935415640600f, + 1.997128429135433400f, 1.997107849426522600f, 1.997087196289665000f, + 1.997066469725620200f, 1.997045669735150000f, 1.997024796319019300f, + 1.997003849477995600f, 1.996982829212848900f, 1.996961735524351900f, + 1.996940568413280600f, 1.996919327880412900f, 1.996898013926530000f, + 1.996876626552415400f, 1.996855165758855600f, 1.996833631546639300f, + 1.996812023916558800f, 1.996790342869408000f, 1.996768588405984300f, + 1.996746760527087700f, 1.996724859233520500f, 1.996702884526087900f, + 1.996680836405598100f, 1.996658714872861800f, 1.996636519928692000f, + 1.996614251573904900f, 1.996591909809319400f, 1.996569494635756600f, + 1.996547006054041100f, 1.996524444064999400f, 1.996501808669461000f, + 1.996479099868258400f, 1.996456317662226300f, 1.996433462052202600f, + 1.996410533039027400f, 1.996387530623543900f, 1.996364454806597500f, + 1.996341305589037100f, 1.996318082971713500f, 1.996294786955480800f, + 1.996271417541195300f, 1.996247974729716200f, 1.996224458521905600f, + 1.996200868918628100f, 1.996177205920750800f, 1.996153469529144100f, + 1.996129659744680300f, 1.996105776568235100f, 1.996081820000686500f, + 1.996057790042915500f, 1.996033686695805300f, 1.996009509960242400f, + 1.995985259837115500f, 1.995960936327316300f, 1.995936539431739000f, + 1.995912069151280800f, 1.995887525486841300f, 1.995862908439323100f, + 1.995838218009630800f, 1.995813454198672700f, 1.995788617007359100f, + 1.995763706436603200f, 1.995738722487320600f, 1.995713665160430600f, + 1.995688534456853800f, 1.995663330377514400f, 1.995638052923339300f, + 1.995612702095257400f, 1.995587277894201400f, 1.995561780321105600f, + 1.995536209376907600f, 1.995510565062547800f, 1.995484847378968600f, + 1.995459056327116000f, 1.995433191907938000f, 1.995407254122385700f, + 1.995381242971412600f, 1.995355158455975200f, 1.995329000577032800f, + 1.995302769335546500f, 1.995276464732481200f, 1.995250086768804100f, + 1.995223635445484900f, 1.995197110763496000f, 1.995170512723813100f, + 1.995143841327413400f, 1.995117096575278200f, 1.995090278468390600f, + 1.995063387007736600f, 1.995036422194304700f, 1.995009384029086800f, + 1.994982272513076600f, 1.994955087647271000f, 1.994927829432669800f, + 1.994900497870274900f, 1.994873092961091200f, 1.994845614706126400f, + 1.994818063106391000f, 1.994790438162897600f, 1.994762739876662100f, + 1.994734968248702800f, 1.994707123280041100f, 1.994679204971700100f, + 1.994651213324707000f, 1.994623148340090700f, 1.994595010018883000f, + 1.994566798362118300f, 1.994538513370834200f, 1.994510155046070700f, + 1.994481723388870100f, 1.994453218400277900f, 1.994424640081342100f, + 1.994395988433113700f, 1.994367263456646100f, 1.994338465152995000f, + 1.994309593523219600f, 1.994280648568381500f, 1.994251630289544600f, + 1.994222538687776100f, 1.994193373764145500f, 1.994164135519725000f, + 1.994134823955589800f, 1.994105439072817700f, 1.994075980872488800f, + 1.994046449355686200f, 1.994016844523496000f, 1.993987166377006600f, + 1.993957414917308700f, 1.993927590145496900f, 1.993897692062667200f, + 1.993867720669919400f, 1.993837675968354700f, 1.993807557959078600f, + 1.993777366643197900f, 1.993747102021822900f, 1.993716764096066200f, + 1.993686352867043200f, 1.993655868335872300f, 1.993625310503674100f, + 1.993594679371572200f, 1.993563974940692800f, 1.993533197212164800f, + 1.993502346187119700f, 1.993471421866692200f, 1.993440424252018900f, + 1.993409353344239600f, 1.993378209144496700f, 1.993346991653935300f, + 1.993315700873703200f, 1.993284336804950900f, 1.993252899448831400f, + 1.993221388806500900f, 1.993189804879117500f, 1.993158147667842800f, + 1.993126417173840500f, 1.993094613398277400f, 1.993062736342323000f, + 1.993030786007148800f, 1.992998762393930000f, 1.992966665503844000f, + 1.992934495338070800f, 1.992902251897793000f, 1.992869935184196300f, + 1.992837545198469000f, 1.992805081941801700f, 1.992772545415388200f, + 1.992739935620424700f, 1.992707252558110200f, 1.992674496229646500f, + 1.992641666636237700f, 1.992608763779091000f, 1.992575787659416100f, + 1.992542738278425300f, 1.992509615637334100f, 1.992476419737359900f, + 1.992443150579723500f, 1.992409808165648100f, 1.992376392496359300f, + 1.992342903573086000f, 1.992309341397059600f, 1.992275705969513800f, + 1.992241997291685400f, 1.992208215364813700f, 1.992174360190140900f, + 1.992140431768911500f, 1.992106430102373400f, 1.992072355191776300f, + 1.992038207038373300f, 1.992003985643419700f, 1.991969691008174100f, + 1.991935323133897000f, 1.991900882021852200f, 1.991866367673306200f, + 1.991831780089527500f, 1.991797119271788300f, 1.991762385221362600f, + 1.991727577939527600f, 1.991692697427563300f, 1.991657743686751700f, + 1.991622716718378400f, 1.991587616523731000f, 1.991552443104099800f, + 1.991517196460778500f, 1.991481876595062800f, 1.991446483508251500f, + 1.991411017201645500f, 1.991375477676549100f, 1.991339864934268800f, + 1.991304178976114100f, 1.991268419803397200f, 1.991232587417432600f, + 1.991196681819537900f, 1.991160703011033200f, 1.991124650993241400f, + 1.991088525767488200f, 1.991052327335101300f, 1.991016055697411900f, + 1.990979710855753900f, 1.990943292811463000f, 1.990906801565878600f, + 1.990870237120342400f, 1.990833599476198800f, 1.990796888634794400f, + 1.990760104597479400f, 1.990723247365606200f, 1.990686316940529800f, + 1.990649313323608100f, 1.990612236516201300f, 1.990575086519673200f, + 1.990537863335389400f, 1.990500566964718400f, 1.990463197409031700f, + 1.990425754669703100f, 1.990388238748109100f, 1.990350649645629600f, + 1.990312987363646000f, 1.990275251903543600f, 1.990237443266709400f, + 1.990199561454533600f, 1.990161606468409300f, 1.990123578309731700f, + 1.990085476979899000f, 1.990047302480312300f, 1.990009054812374800f, + 1.989970733977493000f, 1.989932339977075900f, 1.989893872812535000f, + 1.989855332485284800f, 1.989816718996742200f, 1.989778032348326700f, + 1.989739272541461100f, 1.989700439577570400f, 1.989661533458082100f, + 1.989622554184426800f, 1.989583501758037700f, 1.989544376180350600f, + 1.989505177452804100f, 1.989465905576839600f, 1.989426560553900500f, + 1.989387142385433900f, 1.989347651072888900f, 1.989308086617717500f, + 1.989268449021374300f, 1.989228738285316900f, 1.989188954411005100f, + 1.989149097399901500f, 1.989109167253472000f, 1.989069163973184300f, + 1.989029087560509700f, 1.988988938016921000f, 1.988948715343894900f, + 1.988908419542910100f, 1.988868050615448100f, 1.988827608562993200f, + 1.988787093387032600f, 1.988746505089055600f, 1.988705843670554500f, + 1.988665109133024500f, 1.988624301477963200f, 1.988583420706871100f, + 1.988542466821251000f, 1.988501439822608900f, 1.988460339712453200f, + 1.988419166492295000f, 1.988377920163648000f, 1.988336600728029000f, + 1.988295208186956700f, 1.988253742541953800f, 1.988212203794544000f, + 1.988170591946255100f, 1.988128906998616800f, 1.988087148953161700f, + 1.988045317811425700f, 1.988003413574946000f, 1.987961436245263800f, + 1.987919385823922400f, 1.987877262312467600f, 1.987835065712448600f, + 1.987792796025416500f, 1.987750453252925500f, 1.987708037396532800f, + 1.987665548457797400f, 1.987622986438281700f, 1.987580351339550700f, + 1.987537643163171700f, 1.987494861910715100f, 1.987452007583754100f, + 1.987409080183863800f, 1.987366079712622900f, 1.987323006171612500f, + 1.987279859562415900f, 1.987236639886619700f, 1.987193347145813000f, + 1.987149981341587400f, 1.987106542475537400f, 1.987063030549260300f, + 1.987019445564355700f, 1.986975787522426100f, 1.986932056425076800f, + 1.986888252273915500f, 1.986844375070552900f, 1.986800424816602200f, + 1.986756401513679400f, 1.986712305163403000f, 1.986668135767394300f, + 1.986623893327277500f, 1.986579577844678900f, 1.986535189321228000f, + 1.986490727758556800f, 1.986446193158300400f, 1.986401585522095600f, + 1.986356904851583000f, 1.986312151148405200f, 1.986267324414207500f, + 1.986222424650638400f, 1.986177451859348200f, 1.986132406041990900f, + 1.986087287200222700f, 1.986042095335702300f, 1.985996830450091200f, + 1.985951492545054100f, 1.985906081622257300f, 1.985860597683371000f, + 1.985815040730067200f, 1.985769410764020900f, 1.985723707786909900f, + 1.985677931800414500f, 1.985632082806217900f, 1.985586160806005700f, + 1.985540165801466200f, 1.985494097794290800f, 1.985447956786173100f, + 1.985401742778809500f, 1.985355455773899500f, 1.985309095773144500f, + 1.985262662778249300f, 1.985216156790921000f, 1.985169577812869500f, + 1.985122925845807400f, 1.985076200891450000f, 1.985029402951515200f, + 1.984982532027723700f, 1.984935588121798700f, 1.984888571235466200f, + 1.984841481370454900f, 1.984794318528496200f, 1.984747082711324100f, + 1.984699773920675300f, 1.984652392158289500f, 1.984604937425908300f, + 1.984557409725276700f, 1.984509809058142300f, 1.984462135426255000f, + 1.984414388831367900f, 1.984366569275236400f, 1.984318676759618400f, + 1.984270711286275200f, 1.984222672856969800f, 1.984174561473469200f, + 1.984126377137541700f, 1.984078119850959200f, 1.984029789615495900f, + 1.983981386432928800f, 1.983932910305037400f, 1.983884361233604100f, + 1.983835739220414000f, 1.983787044267254700f, 1.983738276375916800f, + 1.983689435548192900f, 1.983640521785879200f, 1.983591535090773800f, + 1.983542475464678000f, 1.983493342909395500f, 1.983444137426732600f, + 1.983394859018498900f, 1.983345507686505900f, 1.983296083432567900f, + 1.983246586258502700f, 1.983197016166129400f, 1.983147373157271300f, + 1.983097657233753100f, 1.983047868397403100f, 1.982998006650051400f, + 1.982948071993531700f, 1.982898064429679900f, 1.982847983960334600f, + 1.982797830587336800f, 1.982747604312531200f, 1.982697305137763700f, + 1.982646933064884200f, 1.982596488095744300f, 1.982545970232199000f, + 1.982495379476105800f, 1.982444715829324600f, 1.982393979293718200f, + 1.982343169871152000f, 1.982292287563494300f, 1.982241332372615600f, + 1.982190304300389400f, 1.982139203348692200f, 1.982088029519402300f, + 1.982036782814401900f, 1.981985463235574700f, 1.981934070784807400f, + 1.981882605463990200f, 1.981831067275015000f, 1.981779456219776600f, + 1.981727772300172500f, 1.981676015518103500f, 1.981624185875472000f, + 1.981572283374183800f, 1.981520308016147200f, 1.981468259803273300f, + 1.981416138737475800f, 1.981363944820670800f, 1.981311678054777500f, + 1.981259338441717400f, 1.981206925983415300f, 1.981154440681797800f, + 1.981101882538794900f, 1.981049251556338900f, 1.980996547736364900f, + 1.980943771080810700f, 1.980890921591616600f, 1.980837999270726100f, + 1.980785004120084700f, 1.980731936141640900f, 1.980678795337345900f, + 1.980625581709153600f, 1.980572295259020600f, 1.980518935988905700f, + 1.980465503900771000f, 1.980411998996581200f, 1.980358421278303200f, + 1.980304770747907300f, 1.980251047407365600f, 1.980197251258653900f, + 1.980143382303749500f, 1.980089440544633600f, 1.980035425983289300f, + 1.979981338621702200f, 1.979927178461861500f, 1.979872945505758000f, + 1.979818639755386100f, 1.979764261212742400f, 1.979709809879825800f, + 1.979655285758638900f, 1.979600688851186100f, 1.979546019159474900f, + 1.979491276685515300f, 1.979436461431320000f, 1.979381573398904400f, + 1.979326612590286400f, 1.979271579007487100f, 1.979216472652529900f, + 1.979161293527440500f, 1.979106041634248100f, 1.979050716974983800f, + 1.978995319551682100f, 1.978939849366379700f, 1.978884306421115900f, + 1.978828690717932900f, 1.978773002258875600f, 1.978717241045991700f, + 1.978661407081331100f, 1.978605500366946700f, 1.978549520904894000f, + 1.978493468697231300f, 1.978437343746019600f, 1.978381146053322000f, + 1.978324875621205300f, 1.978268532451738200f, 1.978212116546992100f, + 1.978155627909041300f, 1.978099066539962900f, 1.978042432441836400f, + 1.977985725616743900f, 1.977928946066770600f, 1.977872093794004200f, + 1.977815168800534500f, 1.977758171088455100f, 1.977701100659861300f, + 1.977643957516851400f, 1.977586741661526500f, 1.977529453095990200f, + 1.977472091822348700f, 1.977414657842711200f, 1.977357151159189400f, + 1.977299571773897700f, 1.977241919688953000f, 1.977184194906475000f, + 1.977126397428586000f, 1.977068527257411300f, 1.977010584395078300f, + 1.976952568843717700f, 1.976894480605462500f, 1.976836319682448300f, + 1.976778086076813600f, 1.976719779790699500f, 1.976661400826249500f, + 1.976602949185610500f, 1.976544424870931400f, 1.976485827884363800f, + 1.976427158228062100f, 1.976368415904183900f, 1.976309600914888400f, + 1.976250713262338600f, 1.976191752948699200f, 1.976132719976138000f, + 1.976073614346825800f, 1.976014436062935700f, 1.975955185126643300f, + 1.975895861540127200f, 1.975836465305568400f, 1.975776996425151000f, + 1.975717454901061400f, 1.975657840735488800f, 1.975598153930624900f, + 1.975538394488664200f, 1.975478562411804100f, 1.975418657702244300f, + 1.975358680362187400f, 1.975298630393838500f, 1.975238507799405500f, + 1.975178312581099100f, 1.975118044741132300f, 1.975057704281721000f, + 1.974997291205083700f, 1.974936805513442000f, 1.974876247209019100f, + 1.974815616294042200f, 1.974754912770740200f, 1.974694136641345300f, + 1.974633287908091500f, 1.974572366573216400f, 1.974511372638960000f, + 1.974450306107564900f, 1.974389166981275900f, 1.974327955262341400f, + 1.974266670953011400f, 1.974205314055540000f, 1.974143884572182400f, + 1.974082382505197400f, 1.974020807856846400f, 1.973959160629393100f, + 1.973897440825104200f, 1.973835648446248900f, 1.973773783495099500f, + 1.973711845973930000f, 1.973649835885018100f, 1.973587753230643400f, + 1.973525598013088800f, 1.973463370234639600f, 1.973401069897583200f, + 1.973338697004211100f, 1.973276251556815600f, 1.973213733557693400f, + 1.973151143009142800f, 1.973088479913465100f, 1.973025744272964200f, + 1.972962936089946800f, 1.972900055366722000f, 1.972837102105601900f, + 1.972774076308901200f, 1.972710977978936900f, 1.972647807118029300f, + 1.972584563728500700f, 1.972521247812676600f, 1.972457859372884500f, + 1.972394398411455800f, 1.972330864930723200f, 1.972267258933022600f, + 1.972203580420693000f, 1.972139829396075200f, 1.972076005861513700f, + 1.972012109819354600f, 1.971948141271947500f, 1.971884100221644300f, + 1.971819986670799500f, 1.971755800621770400f, 1.971691542076916800f, + 1.971627211038601500f, 1.971562807509189800f, 1.971498331491049700f, + 1.971433782986551400f, 1.971369161998068400f, 1.971304468527976800f, + 1.971239702578655000f, 1.971174864152484400f, 1.971109953251848600f, + 1.971044969879134600f, 1.970979914036731500f, 1.970914785727030800f, + 1.970849584952427900f, 1.970784311715319400f, 1.970718966018105500f, + 1.970653547863188600f, 1.970588057252973900f, 1.970522494189869800f, + 1.970456858676286300f, 1.970391150714636800f, 1.970325370307337100f, + 1.970259517456806100f, 1.970193592165464700f, 1.970127594435737000f, + 1.970061524270049400f, 1.969995381670831100f, 1.969929166640514100f, + 1.969862879181532700f, 1.969796519296324300f, 1.969730086987328900f, + 1.969663582256988600f, 1.969597005107748900f, 1.969530355542057800f, + 1.969463633562365400f, 1.969396839171125200f, 1.969329972370792700f, + 1.969263033163826800f, 1.969196021552688500f, 1.969128937539841500f, + 1.969061781127752400f, 1.968994552318890300f, 1.968927251115727200f, + 1.968859877520737300f, 1.968792431536398000f, 1.968724913165188900f, + 1.968657322409592500f, 1.968589659272094000f, 1.968521923755181000f, + 1.968454115861344000f, 1.968386235593076300f, 1.968318282952873600f, + 1.968250257943234200f, 1.968182160566659000f, 1.968113990825652200f, + 1.968045748722719900f, 1.967977434260371300f, 1.967909047441118100f, + 1.967840588267474500f, 1.967772056741957900f, 1.967703452867087800f, + 1.967634776645386600f, 1.967566028079379200f, 1.967497207171593500f, + 1.967428313924559600f, 1.967359348340810700f, 1.967290310422882700f, + 1.967221200173313400f, 1.967152017594644200f, 1.967082762689418500f, + 1.967013435460182700f, 1.966944035909485600f, 1.966874564039879300f, + 1.966805019853917500f, 1.966735403354157500f, 1.966665714543159000f, + 1.966595953423483800f, 1.966526119997697100f, 1.966456214268366600f, + 1.966386236238062200f, 1.966316185909357200f, 1.966246063284826700f, + 1.966175868367049400f, 1.966105601158605600f, 1.966035261662079300f, + 1.965964849880056600f, 1.965894365815126000f, 1.965823809469879400f, + 1.965753180846910900f, 1.965682479948817100f, 1.965611706778197700f, + 1.965540861337654600f, 1.965469943629792700f, 1.965398953657219600f, + 1.965327891422544900f, 1.965256756928382100f, 1.965185550177345900f, + 1.965114271172054800f, 1.965042919915129400f, 1.964971496409193100f, + 1.964900000656872000f, 1.964828432660794500f, 1.964756792423592200f, + 1.964685079947899200f, 1.964613295236352000f, 1.964541438291590000f, + 1.964469509116255000f, 1.964397507712991800f, 1.964325434084447600f, + 1.964253288233272400f, 1.964181070162119000f, 1.964108779873642100f, + 1.964036417370500300f, 1.963963982655353400f, 1.963891475730865400f, + 1.963818896599701400f, 1.963746245264530700f, 1.963673521728023900f, + 1.963600725992855200f, 1.963527858061700600f, 1.963454917937239800f, + 1.963381905622154400f, 1.963308821119128700f, 1.963235664430850200f, + 1.963162435560008100f, 1.963089134509295300f, 1.963015761281406800f, + 1.962942315879040000f, 1.962868798304895400f, 1.962795208561676200f, + 1.962721546652088200f, 1.962647812578839400f, 1.962574006344640900f, + 1.962500127952206300f, 1.962426177404252200f, 1.962352154703497200f, + 1.962278059852663000f, 1.962203892854473800f, 1.962129653711656800f, + 1.962055342426941400f, 1.961980959003059500f, 1.961906503442746300f, + 1.961831975748739200f, 1.961757375923778700f, 1.961682703970607100f, + 1.961607959891970200f, 1.961533143690616000f, 1.961458255369295400f, + 1.961383294930761700f, 1.961308262377770900f, 1.961233157713082200f, + 1.961157980939456400f, 1.961082732059657800f, 1.961007411076453000f, + 1.960932017992611500f, 1.960856552810905200f, 1.960781015534108800f, + 1.960705406164999300f, 1.960629724706357100f, 1.960553971160964500f, + 1.960478145531606700f, 1.960402247821071900f, 1.960326278032150200f, + 1.960250236167635100f, 1.960174122230322400f, 1.960097936223010400f, + 1.960021678148500500f, 1.959945348009596500f, 1.959868945809104500f, + 1.959792471549834000f, 1.959715925234596600f, 1.959639306866206600f, + 1.959562616447480900f, 1.959485853981239600f, 1.959409019470304700f, + 1.959332112917501400f, 1.959255134325657000f, 1.959178083697602300f, + 1.959100961036169800f, 1.959023766344195200f, 1.958946499624516700f, + 1.958869160879975500f, 1.958791750113414700f, 1.958714267327680500f, + 1.958636712525621900f, 1.958559085710090500f, 1.958481386883940100f, + 1.958403616050027600f, 1.958325773211212300f, 1.958247858370356400f, + 1.958169871530324600f, 1.958091812693984400f, 1.958013681864205500f, + 1.957935479043860600f, 1.957857204235825100f, 1.957778857442976900f, + 1.957700438668196700f, 1.957621947914367500f, 1.957543385184375300f, + 1.957464750481108700f, 1.957386043807458800f, 1.957307265166319500f, + 1.957228414560587200f, 1.957149491993160900f, 1.957070497466942400f, + 1.956991430984836400f, 1.956912292549749500f, 1.956833082164591600f, + 1.956753799832275300f, 1.956674445555715000f, 1.956595019337829000f, + 1.956515521181537000f, 1.956435951089762200f, 1.956356309065430100f, + 1.956276595111468900f, 1.956196809230809500f, 1.956116951426385600f, + 1.956037021701132900f, 1.955957020057990500f, 1.955876946499899700f, + 1.955796801029804800f, 1.955716583650652000f, 1.955636294365391300f, + 1.955555933176974300f, 1.955475500088355900f, 1.955394995102493100f, + 1.955314418222346100f, 1.955233769450877200f, 1.955153048791052000f, + 1.955072256245838000f, 1.954991391818206000f, 1.954910455511129000f, + 1.954829447327582900f, 1.954748367270545900f, 1.954667215342999600f, + 1.954585991547927100f, 1.954504695888315000f, 1.954423328367152600f, + 1.954341888987431100f, 1.954260377752145000f, 1.954178794664291200f, + 1.954097139726869600f, 1.954015412942881900f, 1.953933614315333200f, + 1.953851743847231100f, 1.953769801541585400f, 1.953687787401409400f, + 1.953605701429718100f, 1.953523543629529700f, 1.953441314003864900f, + 1.953359012555747200f, 1.953276639288202400f, 1.953194194204259200f, + 1.953111677306948800f, 1.953029088599305100f, 1.952946428084364900f, + 1.952863695765167100f, 1.952780891644753500f, 1.952698015726169100f, + 1.952615068012460300f, 1.952532048506677300f, 1.952448957211872200f, + 1.952365794131100300f, 1.952282559267419100f, 1.952199252623889200f, + 1.952115874203572900f, 1.952032424009536600f, 1.951948902044847900f, + 1.951865308312577900f, 1.951781642815800100f, 1.951697905557590700f, + 1.951614096541028500f, 1.951530215769194700f, 1.951446263245173500f, + 1.951362238972051500f, 1.951278142952918200f, 1.951193975190865600f, + 1.951109735688987900f, 1.951025424450382900f, 1.950941041478150100f, + 1.950856586775392200f, 1.950772060345214300f, 1.950687462190724200f, + 1.950602792315032200f, 1.950518050721251600f, 1.950433237412498000f, + 1.950348352391889600f, 1.950263395662547700f, 1.950178367227595900f, + 1.950093267090159800f, 1.950008095253369200f, 1.949922851720355100f, + 1.949837536494251700f, 1.949752149578196000f, 1.949666690975327100f, + 1.949581160688787400f, 1.949495558721721500f, 1.949409885077276500f, + 1.949324139758602700f, 1.949238322768852800f, 1.949152434111181700f, + 1.949066473788747300f, 1.948980441804710300f, 1.948894338162233900f, + 1.948808162864483600f, 1.948721915914628100f, 1.948635597315838200f, + 1.948549207071288000f, 1.948462745184153400f, 1.948376211657613500f, + 1.948289606494849800f, 1.948202929699046800f, 1.948116181273391100f, + 1.948029361221072400f, 1.947942469545282500f, 1.947855506249216700f, + 1.947768471336071700f, 1.947681364809048100f, 1.947594186671348000f, + 1.947506936926177300f, 1.947419615576743600f, 1.947332222626257500f, + 1.947244758077932200f, 1.947157221934983500f, 1.947069614200629900f, + 1.946981934878092300f, 1.946894183970594900f, 1.946806361481363500f, + 1.946718467413627300f, 1.946630501770618000f, 1.946542464555569800f, + 1.946454355771719300f, 1.946366175422306500f, 1.946277923510573200f, + 1.946189600039764300f, 1.946101205013127000f, 1.946012738433911600f, + 1.945924200305370700f, 1.945835590630759400f, 1.945746909413335900f, + 1.945658156656360700f, 1.945569332363096700f, 1.945480436536810100f, + 1.945391469180769200f, 1.945302430298244900f, 1.945213319892511200f, + 1.945124137966844200f, 1.945034884524523100f, 1.944945559568829200f, + 1.944856163103046800f, 1.944766695130463000f, 1.944677155654366900f, + 1.944587544678050900f, 1.944497862204809900f, 1.944408108237940700f, + 1.944318282780743900f, 1.944228385836521700f, 1.944138417408579400f, + 1.944048377500225100f, 1.943958266114769200f, 1.943868083255524800f, + 1.943777828925807600f, 1.943687503128936200f, 1.943597105868231500f, + 1.943506637147017300f, 1.943416096968619400f, 1.943325485336367300f, + 1.943234802253592400f, 1.943144047723628400f, 1.943053221749812400f, + 1.942962324335484100f, 1.942871355483985200f, 1.942780315198660200f, + 1.942689203482856900f, 1.942598020339924700f, 1.942506765773216500f, + 1.942415439786087300f, 1.942324042381895000f, 1.942232573564000000f, + 1.942141033335765400f, 1.942049421700556600f, 1.941957738661741900f, + 1.941865984222692900f, 1.941774158386782200f, 1.941682261157386700f, + 1.941590292537884700f, 1.941498252531658200f, 1.941406141142090600f, + 1.941313958372568900f, 1.941221704226482500f, 1.941129378707223000f, + 1.941036981818185400f, 1.940944513562766300f, 1.940851973944365900f, + 1.940759362966386600f, 1.940666680632233200f, 1.940573926945313700f, + 1.940481101909038200f, 1.940388205526819600f, 1.940295237802073500f, + 1.940202198738217900f, 1.940109088338673600f, 1.940015906606864300f, + 1.939922653546215500f, 1.939829329160156500f, 1.939735933452118000f, + 1.939642466425534300f, 1.939548928083841800f, 1.939455318430479500f, + 1.939361637468889100f, 1.939267885202515400f, 1.939174061634805000f, + 1.939080166769207700f, 1.938986200609175600f, 1.938892163158163700f, + 1.938798054419629500f, 1.938703874397032800f, 1.938609623093837000f, + 1.938515300513506700f, 1.938420906659510600f, 1.938326441535318500f, + 1.938231905144404400f, 1.938137297490243500f, 1.938042618576314400f, + 1.937947868406098500f, 1.937853046983079300f, 1.937758154310742900f, + 1.937663190392578500f, 1.937568155232077600f, 1.937473048832734500f, + 1.937377871198045600f, 1.937282622331510500f, 1.937187302236631500f, + 1.937091910916912900f, 1.936996448375861900f, 1.936900914616988900f, + 1.936805309643805800f, 1.936709633459828200f, 1.936613886068573500f, + 1.936518067473562300f, 1.936422177678317300f, 1.936326216686364400f, + 1.936230184501231500f, 1.936134081126449800f, 1.936037906565552400f, + 1.935941660822075600f, 1.935845343899558000f, 1.935748955801540800f, + 1.935652496531568000f, 1.935555966093186300f, 1.935459364489944500f, + 1.935362691725394500f, 1.935265947803090900f, 1.935169132726590500f, + 1.935072246499453000f, 1.934975289125240500f, 1.934878260607517900f, + 1.934781160949852600f, 1.934683990155814800f, 1.934586748228977100f, + 1.934489435172914900f, 1.934392050991206300f, 1.934294595687431300f, + 1.934197069265173500f, 1.934099471728018700f, 1.934001803079554700f, + 1.933904063323373300f, 1.933806252463067500f, 1.933708370502233800f, + 1.933610417444471000f, 1.933512393293380600f, 1.933414298052566600f, + 1.933316131725635800f, 1.933217894316197300f, 1.933119585827862900f, + 1.933021206264247600f, 1.932922755628968100f, 1.932824233925644300f, + 1.932725641157898600f, 1.932626977329356100f, 1.932528242443643900f, + 1.932429436504392800f, 1.932330559515235100f, 1.932231611479806800f, + 1.932132592401745400f, 1.932033502284691700f, 1.931934341132289100f, + 1.931835108948183300f, 1.931735805736022800f, 1.931636431499459000f, + 1.931536986242145200f, 1.931437469967737900f, 1.931337882679895900f, + 1.931238224382281000f, 1.931138495078557300f, 1.931038694772391200f, + 1.930938823467452500f, 1.930838881167413100f, 1.930738867875947400f, + 1.930638783596732700f, 1.930538628333448900f, 1.930438402089778200f, + 1.930338104869405900f, 1.930237736676019500f, 1.930137297513309300f, + 1.930036787384968200f, 1.929936206294691400f, 1.929835554246177400f, + 1.929734831243126600f, 1.929634037289242400f, 1.929533172388230700f, + 1.929432236543799900f, 1.929331229759661200f, 1.929230152039528500f, + 1.929129003387117800f, 1.929027783806148300f, 1.928926493300341400f, + 1.928825131873421500f, 1.928723699529115000f, 1.928622196271151800f, + 1.928520622103263400f, 1.928418977029184600f, 1.928317261052652700f, + 1.928215474177407100f, 1.928113616407190600f, 1.928011687745748300f, + 1.927909688196827400f, 1.927807617764178300f, 1.927705476451554000f, + 1.927603264262709900f, 1.927500981201404100f, 1.927398627271397000f, + 1.927296202476451900f, 1.927193706820335100f, 1.927091140306814500f, + 1.926988502939661400f, 1.926885794722649600f, 1.926783015659555300f, + 1.926680165754157500f, 1.926577245010237400f, 1.926474253431579500f, + 1.926371191021970100f, 1.926268057785198700f, 1.926164853725057300f, + 1.926061578845340600f, 1.925958233149845000f, 1.925854816642371000f, + 1.925751329326720600f, 1.925647771206698600f, 1.925544142286112800f, + 1.925440442568773000f, 1.925336672058492300f, 1.925232830759086000f, + 1.925128918674371900f, 1.925024935808170600f, 1.924920882164305300f, + 1.924816757746601800f, 1.924712562558888100f, 1.924608296604995800f, + 1.924503959888757900f, 1.924399552414010700f, 1.924295074184593000f, + 1.924190525204346300f, 1.924085905477114400f, 1.923981215006744100f, + 1.923876453797084300f, 1.923771621851986700f, 1.923666719175306100f, + 1.923561745770898900f, 1.923456701642625200f, 1.923351586794346900f, + 1.923246401229928600f, 1.923141144953238300f, 1.923035817968145300f, + 1.922930420278522500f, 1.922824951888245000f, 1.922719412801190600f, + 1.922613803021239600f, 1.922508122552275100f, 1.922402371398182600f, + 1.922296549562850100f, 1.922190657050168800f, 1.922084693864031700f, + 1.921978660008334600f, 1.921872555486976700f, 1.921766380303858500f, + 1.921660134462884100f, 1.921553817967959900f, 1.921447430822994500f, + 1.921340973031900000f, 1.921234444598590100f, 1.921127845526981600f, + 1.921021175820994100f, 1.920914435484549100f, 1.920807624521571700f, + 1.920700742935988600f, 1.920593790731729600f, 1.920486767912727300f, + 1.920379674482916500f, 1.920272510446234400f, 1.920165275806621400f, + 1.920057970568020100f, 1.919950594734376000f, 1.919843148309637000f, + 1.919735631297753400f, 1.919628043702678300f, 1.919520385528367300f, + 1.919412656778779000f, 1.919304857457874200f, 1.919196987569616200f, + 1.919089047117971100f, 1.918981036106907700f, 1.918872954540397300f, + 1.918764802422413500f, 1.918656579756932800f, 1.918548286547934400f, + 1.918439922799399800f, 1.918331488515313300f, 1.918222983699661600f, + 1.918114408356434300f, 1.918005762489623400f, 1.917897046103223200f, + 1.917788259201231200f, 1.917679401787647100f, 1.917570473866473200f, + 1.917461475441714500f, 1.917352406517378600f, 1.917243267097475700f, + 1.917134057186018300f, 1.917024776787022100f, 1.916915425904504700f, + 1.916806004542486800f, 1.916696512704991500f, 1.916586950396044400f, + 1.916477317619674100f, 1.916367614379911100f, 1.916257840680788900f, + 1.916147996526343700f, 1.916038081920614400f, 1.915928096867641800f, + 1.915818041371470000f, 1.915707915436145200f, 1.915597719065716700f, + 1.915487452264236000f, 1.915377115035757200f, 1.915266707384337200f, + 1.915156229314035200f, 1.915045680828913400f, 1.914935061933036300f, + 1.914824372630470800f, 1.914713612925287100f, 1.914602782821557000f, + 1.914491882323355700f, 1.914380911434760500f, 1.914269870159851700f, + 1.914158758502712000f, 1.914047576467426500f, 1.913936324058083100f, + 1.913825001278772100f, 1.913713608133586600f, 1.913602144626622500f, + 1.913490610761977600f, 1.913379006543752800f, 1.913267331976051400f, + 1.913155587062979500f, 1.913043771808645700f, 1.912931886217160900f, + 1.912819930292639000f, 1.912707904039196300f, 1.912595807460951500f, + 1.912483640562026200f, 1.912371403346544400f, 1.912259095818632700f, + 1.912146717982420500f, 1.912034269842039600f, 1.911921751401624200f, + 1.911809162665311500f, 1.911696503637241100f, 1.911583774321554700f, + 1.911470974722397500f, 1.911358104843916500f, 1.911245164690262000f, + 1.911132154265586100f, 1.911019073574044200f, 1.910905922619793800f, + 1.910792701406995000f, 1.910679409939810600f, 1.910566048222406300f, + 1.910452616258949900f, 1.910339114053611900f, 1.910225541610565800f, + 1.910111898933986900f, 1.909998186028053700f, 1.909884402896947100f, + 1.909770549544850500f, 1.909656625975950200f, 1.909542632194434700f, + 1.909428568204495100f, 1.909314434010325400f, 1.909200229616121700f, + 1.909085955026083200f, 1.908971610244411600f, 1.908857195275310800f, + 1.908742710122987700f, 1.908628154791651300f, 1.908513529285513500f, + 1.908398833608789100f, 1.908284067765694900f, 1.908169231760450400f, + 1.908054325597278200f, 1.907939349280402400f, 1.907824302814050900f, + 1.907709186202453600f, 1.907593999449842800f, 1.907478742560453600f, + 1.907363415538523700f, 1.907248018388293400f, 1.907132551114005600f, + 1.907017013719905600f, 1.906901406210241200f, 1.906785728589263300f, + 1.906669980861224900f, 1.906554163030381500f, 1.906438275100991600f, + 1.906322317077316300f, 1.906206288963618700f, 1.906090190764164700f, + 1.905974022483223300f, 1.905857784125065500f, 1.905741475693964800f, + 1.905625097194197900f, 1.905508648630043700f, 1.905392130005783400f, + 1.905275541325701400f, 1.905158882594083900f, 1.905042153815220700f, + 1.904925354993402900f, 1.904808486132925300f, 1.904691547238084800f, + 1.904574538313180700f, 1.904457459362515200f, 1.904340310390393100f, + 1.904223091401121600f, 1.904105802399010300f, 1.903988443388371600f, + 1.903871014373520700f, 1.903753515358774800f, 1.903635946348454500f, + 1.903518307346881800f, 1.903400598358382600f, 1.903282819387284200f, + 1.903164970437917400f, 1.903047051514615000f, 1.902929062621712600f, + 1.902811003763547900f, 1.902692874944462300f, 1.902574676168798700f, + 1.902456407440902700f, 1.902338068765123200f, 1.902219660145810800f, + 1.902101181587319000f, 1.901982633094004200f, 1.901864014670225000f, + 1.901745326320342500f, 1.901626568048721000f, 1.901507739859726200f, + 1.901388841757727600f, 1.901269873747096600f, 1.901150835832207100f, + 1.901031728017436300f, 1.900912550307162700f, 1.900793302705768900f, + 1.900673985217638900f, 1.900554597847159400f, 1.900435140598720500f, + 1.900315613476714100f, 1.900196016485534700f, 1.900076349629579600f, + 1.899956612913248800f, 1.899836806340944300f, 1.899716929917071500f, + 1.899596983646037600f, 1.899476967532252900f, 1.899356881580129800f, + 1.899236725794083600f, 1.899116500178532200f, 1.898996204737895900f, + 1.898875839476597700f, 1.898755404399062900f, 1.898634899509719500f, + 1.898514324812998300f, 1.898393680313332600f, 1.898272966015157800f, + 1.898152181922912600f, 1.898031328041037700f, 1.897910404373976500f, + 1.897789410926175000f, 1.897668347702081900f, 1.897547214706148300f, + 1.897426011942827900f, 1.897304739416577200f, 1.897183397131854600f, + 1.897061985093121800f, 1.896940503304842800f, 1.896818951771484000f, + 1.896697330497514800f, 1.896575639487406300f, 1.896453878745633100f, + 1.896332048276672100f, 1.896210148085002400f, 1.896088178175106200f, + 1.895966138551467700f, 1.895844029218574100f, 1.895721850180915000f, + 1.895599601442982600f, 1.895477283009271400f, 1.895354894884279100f, + 1.895232437072505300f, 1.895109909578452500f, 1.894987312406625700f, + 1.894864645561532100f, 1.894741909047682500f, 1.894619102869589100f, + 1.894496227031767100f, 1.894373281538734400f, 1.894250266395011600f, + 1.894127181605121100f, 1.894004027173588700f, 1.893880803104942600f, + 1.893757509403713100f, 1.893634146074433500f, 1.893510713121639300f, + 1.893387210549869000f, 1.893263638363663400f, 1.893139996567565900f, + 1.893016285166122500f, 1.892892504163881600f, 1.892768653565394300f, + 1.892644733375214300f, 1.892520743597897700f, 1.892396684238003300f, + 1.892272555300092300f, 1.892148356788728700f, 1.892024088708479200f, + 1.891899751063912200f, 1.891775343859599400f, 1.891650867100115300f, + 1.891526320790036100f, 1.891401704933941100f, 1.891277019536412400f, + 1.891152264602033800f, 1.891027440135392600f, 1.890902546141078000f, + 1.890777582623682300f, 1.890652549587799700f, 1.890527447038027300f, + 1.890402274978965100f, 1.890277033415215200f, 1.890151722351382200f, + 1.890026341792073500f, 1.889900891741899100f, 1.889775372205471300f, + 1.889649783187405100f, 1.889524124692318200f, 1.889398396724830500f, + 1.889272599289564900f, 1.889146732391146400f, 1.889020796034202700f, + 1.888894790223364600f, 1.888768714963264400f, 1.888642570258537700f, + 1.888516356113822700f, 1.888390072533759700f, 1.888263719522991900f, + 1.888137297086165000f, 1.888010805227927000f, 1.887884243952928600f, + 1.887757613265823400f, 1.887630913171267000f, 1.887504143673917700f, + 1.887377304778437000f, 1.887250396489487800f, 1.887123418811736500f, + 1.886996371749851700f, 1.886869255308504200f, 1.886742069492368000f, + 1.886614814306119400f, 1.886487489754437300f, 1.886360095842002600f, + 1.886232632573499700f, 1.886105099953614900f, 1.885977497987037000f, + 1.885849826678457800f, 1.885722086032571200f, 1.885594276054074300f, + 1.885466396747665700f, 1.885338448118047700f, 1.885210430169924200f, + 1.885082342908002400f, 1.884954186336991400f, 1.884825960461603100f, + 1.884697665286552400f, 1.884569300816556000f, 1.884440867056333700f, + 1.884312364010607600f, 1.884183791684102400f, 1.884055150081545200f, + 1.883926439207665800f, 1.883797659067196800f, 1.883668809664872600f, + 1.883539891005431100f, 1.883410903093611900f, 1.883281845934157800f, + 1.883152719531813800f, 1.883023523891327300f, 1.882894259017448900f, + 1.882764924914930700f, 1.882635521588528400f, 1.882506049042999700f, + 1.882376507283104900f, 1.882246896313606800f, 1.882117216139270700f, + 1.881987466764865100f, 1.881857648195159900f, 1.881727760434928500f, + 1.881597803488946500f, 1.881467777361992100f, 1.881337682058845700f, + 1.881207517584290600f, 1.881077283943112900f, 1.880946981140100500f, + 1.880816609180044700f, 1.880686168067738500f, 1.880555657807977800f, + 1.880425078405561600f, 1.880294429865290600f, 1.880163712191968300f, + 1.880032925390400900f, 1.879902069465397200f, 1.879771144421768200f, + 1.879640150264327600f, 1.879509086997891900f, 1.879377954627279700f, + 1.879246753157312700f, 1.879115482592814500f, 1.878984142938611600f, + 1.878852734199532900f, 1.878721256380410100f, 1.878589709486077300f, + 1.878458093521370800f, 1.878326408491130200f, 1.878194654400196600f, + 1.878062831253414900f, 1.877930939055631100f, 1.877798977811695200f, + 1.877666947526458700f, 1.877534848204775800f, 1.877402679851504000f, + 1.877270442471502100f, 1.877138136069632400f, 1.877005760650759500f, + 1.876873316219750200f, 1.876740802781474500f, 1.876608220340804100f, + 1.876475568902614000f, 1.876342848471781200f, 1.876210059053185600f, + 1.876077200651709500f, 1.875944273272237800f, 1.875811276919657500f, + 1.875678211598858800f, 1.875545077314734000f, 1.875411874072178100f, + 1.875278601876088700f, 1.875145260731365700f, 1.875011850642911600f, + 1.874878371615631900f, 1.874744823654434000f, 1.874611206764227800f, + 1.874477520949926500f, 1.874343766216444800f, 1.874209942568701100f, + 1.874076050011615400f, 1.873942088550110400f, 1.873808058189111700f, + 1.873673958933546900f, 1.873539790788347100f, 1.873405553758444600f, + 1.873271247848775400f, 1.873136873064277000f, 1.873002429409890600f, + 1.872867916890558900f, 1.872733335511227700f, 1.872598685276845000f, + 1.872463966192361900f, 1.872329178262731200f, 1.872194321492908700f, + 1.872059395887852900f, 1.871924401452524700f, 1.871789338191887100f, + 1.871654206110906500f, 1.871519005214550700f, 1.871383735507791100f, + 1.871248396995601300f, 1.871112989682956800f, 1.870977513574836500f, + 1.870841968676221400f, 1.870706354992095000f, 1.870570672527443600f, + 1.870434921287255700f, 1.870299101276522400f, 1.870163212500237900f, + 1.870027254963397800f, 1.869891228671001200f, 1.869755133628049600f, + 1.869618969839546500f, 1.869482737310498100f, 1.869346436045913800f, + 1.869210066050804600f, 1.869073627330184700f, 1.868937119889070300f, + 1.868800543732480600f, 1.868663898865437200f, 1.868527185292963700f, + 1.868390403020087100f, 1.868253552051836200f, 1.868116632393243000f, + 1.867979644049341200f, 1.867842587025167800f, 1.867705461325761800f, + 1.867568266956164800f, 1.867431003921421500f, 1.867293672226578300f, + 1.867156271876684500f, 1.867018802876792200f, 1.866881265231955500f, + 1.866743658947231300f, 1.866605984027679000f, 1.866468240478360600f, + 1.866330428304340300f, 1.866192547510685300f, 1.866054598102465000f, + 1.865916580084751500f, 1.865778493462619100f, 1.865640338241145100f, + 1.865502114425408900f, 1.865363822020492700f, 1.865225461031480900f, + 1.865087031463460900f, 1.864948533321522300f, 1.864809966610757400f, + 1.864671331336260600f, 1.864532627503129100f, 1.864393855116463200f, + 1.864255014181364500f, 1.864116104702938000f, 1.863977126686291200f, + 1.863838080136534000f, 1.863698965058778300f, 1.863559781458139300f, + 1.863420529339734100f, 1.863281208708683000f, 1.863141819570107900f, + 1.863002361929134500f, 1.862862835790889400f, 1.862723241160503300f, + 1.862583578043108100f, 1.862443846443839300f, 1.862304046367834200f, + 1.862164177820232700f, 1.862024240806177800f, 1.861884235330814300f, + 1.861744161399289600f, 1.861604019016754200f, 1.861463808188360500f, + 1.861323528919263800f, 1.861183181214621600f, 1.861042765079594200f, + 1.860902280519344500f, 1.860761727539037300f, 1.860621106143840500f, + 1.860480416338924600f, 1.860339658129461800f, 1.860198831520627900f, + 1.860057936517600700f, 1.859916973125560000f, 1.859775941349689000f, + 1.859634841195173100f, 1.859493672667199800f, 1.859352435770959900f, + 1.859211130511645900f, 1.859069756894453400f, 1.858928314924580300f, + 1.858786804607227100f, 1.858645225947596300f, 1.858503578950893900f, + 1.858361863622327400f, 1.858220079967107600f, 1.858078227990447300f, + 1.857936307697561900f, 1.857794319093669900f, 1.857652262183991000f, + 1.857510136973749000f, 1.857367943468169100f, 1.857225681672479300f, + 1.857083351591910300f, 1.856940953231694900f, 1.856798486597069000f, + 1.856655951693270600f, 1.856513348525540300f, 1.856370677099121100f, + 1.856227937419258700f, 1.856085129491201100f, 1.855942253320199200f, + 1.855799308911506100f, 1.855656296270377300f, 1.855513215402071000f, + 1.855370066311848000f, 1.855226849004971500f, 1.855083563486706900f, + 1.854940209762322700f, 1.854796787837089500f, 1.854653297716280400f, + 1.854509739405171300f, 1.854366112909040300f, 1.854222418233168400f, + 1.854078655382838300f, 1.853934824363336200f, 1.853790925179950500f, + 1.853646957837971500f, 1.853502922342692600f, 1.853358818699409900f, + 1.853214646913421200f, 1.853070406990027500f, 1.852926098934532200f, + 1.852781722752241000f, 1.852637278448462200f, 1.852492766028506400f, + 1.852348185497687300f, 1.852203536861320600f, 1.852058820124724300f, + 1.851914035293219700f, 1.851769182372129600f, 1.851624261366780400f, + 1.851479272282500000f, 1.851334215124619300f, 1.851189089898471800f, + 1.851043896609393400f, 1.850898635262721900f, 1.850753305863798800f, + 1.850607908417967200f, 1.850462442930572900f, 1.850316909406964200f, + 1.850171307852492200f, 1.850025638272510000f, 1.849879900672373600f, + 1.849734095057441200f, 1.849588221433073700f, 1.849442279804634600f, + 1.849296270177489800f, 1.849150192557007300f, 1.849004046948558200f, + 1.848857833357515900f, 1.848711551789256300f, 1.848565202249157400f, + 1.848418784742600400f, 1.848272299274968500f, 1.848125745851647800f, + 1.847979124478026100f, 1.847832435159495000f, 1.847685677901447200f, + 1.847538852709279100f, 1.847391959588388300f, 1.847244998544176300f, + 1.847097969582046200f, 1.846950872707404000f, 1.846803707925657600f, + 1.846656475242218300f, 1.846509174662499300f, 1.846361806191916000f, + 1.846214369835887500f, 1.846066865599834000f, 1.845919293489179000f, + 1.845771653509348200f, 1.845623945665770100f, 1.845476169963875500f, + 1.845328326409097400f, 1.845180415006871800f, 1.845032435762637100f, + 1.844884388681833800f, 1.844736273769905300f, 1.844588091032297400f, + 1.844439840474458200f, 1.844291522101838800f, 1.844143135919891900f, + 1.843994681934073600f, 1.843846160149842200f, 1.843697570572658200f, + 1.843548913207985000f, 1.843400188061288000f, 1.843251395138035800f, + 1.843102534443698900f, 1.842953605983750400f, 1.842804609763666100f, + 1.842655545788924000f, 1.842506414065004900f, 1.842357214597392100f, + 1.842207947391570900f, 1.842058612453029600f, 1.841909209787258900f, + 1.841759739399751800f, 1.841610201296003800f, 1.841460595481513100f, + 1.841310921961780500f, 1.841161180742308500f, 1.841011371828603200f, + 1.840861495226172600f, 1.840711550940526700f, 1.840561538977179200f, + 1.840411459341645400f, 1.840261312039443100f, 1.840111097076092800f, + 1.839960814457117600f, 1.839810464188043100f, 1.839660046274397100f, + 1.839509560721709800f, 1.839359007535514400f, 1.839208386721346500f, + 1.839057698284743500f, 1.838906942231246100f, 1.838756118566397200f, + 1.838605227295741800f, 1.838454268424828400f, 1.838303241959206700f, + 1.838152147904429800f, 1.838000986266052900f, 1.837849757049633900f, + 1.837698460260732900f, 1.837547095904912700f, 1.837395663987738700f, + 1.837244164514778600f, 1.837092597491602100f, 1.836940962923782700f, + 1.836789260816895000f, 1.836637491176516600f, 1.836485654008228200f, + 1.836333749317611700f, 1.836181777110252900f, 1.836029737391738700f, + 1.835877630167659800f, 1.835725455443608200f, 1.835573213225179400f, + 1.835420903517970500f, 1.835268526327581900f, 1.835116081659615700f, + 1.834963569519677100f, 1.834810989913373500f, 1.834658342846314800f, + 1.834505628324113200f, 1.834352846352383700f, 1.834199996936744000f, + 1.834047080082813300f, 1.833894095796214400f, 1.833741044082571900f, + 1.833587924947513100f, 1.833434738396668000f, 1.833281484435668400f, + 1.833128163070149300f, 1.832974774305747600f, 1.832821318148103500f, + 1.832667794602858400f, 1.832514203675657600f, 1.832360545372147900f, + 1.832206819697979000f, 1.832053026658802700f, 1.831899166260273700f, + 1.831745238508049300f, 1.831591243407788300f, 1.831437180965153100f, + 1.831283051185808300f, 1.831128854075420500f, 1.830974589639659000f, + 1.830820257884196100f, 1.830665858814705600f, 1.830511392436864800f, + 1.830356858756352800f, 1.830202257778851300f, 1.830047589510044500f, + 1.829892853955619200f, 1.829738051121264600f, 1.829583181012672400f, + 1.829428243635536500f, 1.829273238995553700f, 1.829118167098423100f, + 1.828963027949846100f, 1.828807821555527000f, 1.828652547921171900f, + 1.828497207052490100f, 1.828341798955192900f, 1.828186323634994200f, + 1.828030781097610400f, 1.827875171348760400f, 1.827719494394165500f, + 1.827563750239549400f, 1.827407938890638600f, 1.827252060353161500f, + 1.827096114632849700f, 1.826940101735436500f, 1.826784021666658400f, + 1.826627874432253700f, 1.826471660037963800f, 1.826315378489531800f, + 1.826159029792704400f, 1.826002613953229500f, 1.825846130976858100f, + 1.825689580869344100f, 1.825532963636443000f, 1.825376279283913200f, + 1.825219527817515800f, 1.825062709243013800f, 1.824905823566173000f, + 1.824748870792761900f, 1.824591850928550800f, 1.824434763979313300f, + 1.824277609950824700f, 1.824120388848863300f, 1.823963100679209600f, + 1.823805745447646600f, 1.823648323159960100f, 1.823490833821937600f, + 1.823333277439369600f, 1.823175654018049300f, 1.823017963563772000f, + 1.822860206082335300f, 1.822702381579539800f, 1.822544490061187800f, + 1.822386531533084900f, 1.822228506001038800f, 1.822070413470859600f, + 1.821912253948359700f, 1.821754027439354400f, 1.821595733949661100f, + 1.821437373485099900f, 1.821278946051493100f, 1.821120451654665700f, + 1.820961890300445400f, 1.820803261994661500f, 1.820644566743146800f, + 1.820485804551735800f, 1.820326975426265600f, 1.820168079372576300f, + 1.820009116396509800f, 1.819850086503910700f, 1.819690989700625900f, + 1.819531825992505500f, 1.819372595385401000f, 1.819213297885166900f, + 1.819053933497660300f, 1.818894502228740600f, 1.818735004084269600f, + 1.818575439070111200f, 1.818415807192132600f, 1.818256108456203000f, + 1.818096342868193800f, 1.817936510433979300f, 1.817776611159436000f, + 1.817616645050443000f, 1.817456612112881900f, 1.817296512352636300f, + 1.817136345775592900f, 1.816976112387640700f, 1.816815812194670700f, + 1.816655445202576700f, 1.816495011417255300f, 1.816334510844604700f, + 1.816173943490526400f, 1.816013309360923900f, 1.815852608461703300f, + 1.815691840798773000f, 1.815531006378043900f, 1.815370105205429600f, + 1.815209137286846200f, 1.815048102628211500f, 1.814887001235446600f, + 1.814725833114474700f, 1.814564598271221300f, 1.814403296711615000f, + 1.814241928441585800f, 1.814080493467067300f, 1.813918991793994900f, + 1.813757423428306000f, 1.813595788375941700f, 1.813434086642844400f, + 1.813272318234959700f, 1.813110483158235400f, 1.812948581418621500f, + 1.812786613022070700f, 1.812624577974538000f, 1.812462476281981200f, + 1.812300307950360300f, 1.812138072985637800f, 1.811975771393778300f, + 1.811813403180749300f, 1.811650968352521000f, 1.811488466915065000f, + 1.811325898874356800f, 1.811163264236372900f, 1.811000563007093100f, + 1.810837795192499400f, 1.810674960798576600f, 1.810512059831311400f, + 1.810349092296693400f, 1.810186058200714100f, 1.810022957549368000f, + 1.809859790348652200f, 1.809696556604565300f, 1.809533256323109200f, + 1.809369889510288100f, 1.809206456172108200f, 1.809042956314578900f, + 1.808879389943711200f, 1.808715757065519200f, 1.808552057686019200f, + 1.808388291811230000f, 1.808224459447172800f, 1.808060560599871200f, + 1.807896595275351200f, 1.807732563479641300f, 1.807568465218772900f, + 1.807404300498778800f, 1.807240069325695400f, 1.807075771705560800f, + 1.806911407644415700f, 1.806746977148303300f, 1.806582480223269500f, + 1.806417916875362000f, 1.806253287110631600f, 1.806088590935131000f, + 1.805923828354915900f, 1.805758999376044100f, 1.805594104004575800f, + 1.805429142246573600f, 1.805264114108102900f, 1.805099019595231200f, + 1.804933858714028700f, 1.804768631470567500f, 1.804603337870923000f, + 1.804437977921172300f, 1.804272551627395400f, 1.804107058995674500f, + 1.803941500032094200f, 1.803775874742741500f, 1.803610183133706400f, + 1.803444425211080400f, 1.803278600980958300f, 1.803112710449436900f, + 1.802946753622615400f, 1.802780730506595700f, 1.802614641107481900f, + 1.802448485431380900f, 1.802282263484401300f, 1.802115975272655000f, + 1.801949620802255600f, 1.801783200079319900f, 1.801616713109966300f, + 1.801450159900316300f, 1.801283540456493700f, 1.801116854784624400f, + 1.800950102890836800f, 1.800783284781262200f, 1.800616400462033800f, + 1.800449449939287800f, 1.800282433219162000f, 1.800115350307797600f, + 1.799948201211337500f, 1.799780985935927300f, 1.799613704487715200f, + 1.799446356872851400f, 1.799278943097489100f, 1.799111463167783400f, + 1.798943917089892000f, 1.798776304869975200f, 1.798608626514195800f, + 1.798440882028718500f, 1.798273071419711000f, 1.798105194693343500f, + 1.797937251855787700f, 1.797769242913218800f, 1.797601167871813800f, + 1.797433026737752700f, 1.797264819517217200f, 1.797096546216391900f, + 1.796928206841463800f, 1.796759801398622100f, 1.796591329894058800f, + 1.796422792333968000f, 1.796254188724546500f, 1.796085519071992900f, + 1.795916783382509200f, 1.795747981662299200f, 1.795579113917569200f, + 1.795410180154527900f, 1.795241180379386800f, 1.795072114598359200f, + 1.794902982817661500f, 1.794733785043511900f, 1.794564521282131300f, + 1.794395191539743400f, 1.794225795822573600f, 1.794056334136850300f, + 1.793886806488804100f, 1.793717212884667900f, 1.793547553330677300f, + 1.793377827833070100f, 1.793208036398086900f, 1.793038179031970000f, + 1.792868255740965000f, 1.792698266531319400f, 1.792528211409282900f, + 1.792358090381108300f, 1.792187903453050100f, 1.792017650631366100f, + 1.791847331922315600f, 1.791676947332161000f, 1.791506496867166600f, + 1.791335980533599300f, 1.791165398337728900f, 1.790994750285827000f, + 1.790824036384167900f, 1.790653256639028100f, 1.790482411056686800f, + 1.790311499643425500f, 1.790140522405528200f, 1.789969479349281100f, + 1.789798370480973000f, 1.789627195806895200f, 1.789455955333341100f, + 1.789284649066606800f, 1.789113277012990900f, 1.788941839178794100f, + 1.788770335570319700f, 1.788598766193873600f, 1.788427131055763600f, + 1.788255430162300400f, 1.788083663519796800f, 1.787911831134568300f, + 1.787739933012932900f, 1.787567969161210300f, 1.787395939585723500f, + 1.787223844292797500f, 1.787051683288759500f, 1.786879456579939700f, + 1.786707164172670200f, 1.786534806073285700f, 1.786362382288123400f, + 1.786189892823522700f, 1.786017337685825700f, 1.785844716881376700f, + 1.785672030416522300f, 1.785499278297612000f, 1.785326460530997300f, + 1.785153577123032000f, 1.784980628080072900f, 1.784807613408478300f, + 1.784634533114609800f, 1.784461387204831400f, 1.784288175685508700f, + 1.784114898563010200f, 1.783941555843707100f, 1.783768147533972200f, + 1.783594673640181800f, 1.783421134168713800f, 1.783247529125948900f, + 1.783073858518269700f, 1.782900122352062000f, 1.782726320633713200f, + 1.782552453369613800f, 1.782378520566156200f, 1.782204522229735600f, + 1.782030458366749200f, 1.781856328983596900f, 1.781682134086680900f, + 1.781507873682406200f, 1.781333547777179200f, 1.781159156377410100f, + 1.780984699489510200f, 1.780810177119894100f, 1.780635589274978600f, + 1.780460935961182300f, 1.780286217184927000f, 1.780111432952636600f, + 1.779936583270737400f, 1.779761668145658300f, 1.779586687583830200f, + 1.779411641591686500f, 1.779236530175663600f, 1.779061353342199500f, + 1.778886111097735000f, 1.778710803448713400f, 1.778535430401580100f, + 1.778359991962783000f, 1.778184488138772900f, 1.778008918936002000f, + 1.777833284360925900f, 1.777657584420002000f, 1.777481819119690200f, + 1.777305988466453000f, 1.777130092466755200f, 1.776954131127064200f, + 1.776778104453849100f, 1.776602012453582400f, 1.776425855132738100f, + 1.776249632497793200f, 1.776073344555227000f, 1.775896991311520800f, + 1.775720572773158900f, 1.775544088946627600f, 1.775367539838415700f, + 1.775190925455014400f, 1.775014245802917200f, 1.774837500888620400f, + 1.774660690718622000f, 1.774483815299423100f, 1.774306874637527000f, + 1.774129868739439100f, 1.773952797611667100f, 1.773775661260722100f, + 1.773598459693116500f, 1.773421192915365400f, 1.773243860933986400f, + 1.773066463755499800f, 1.772889001386427800f, 1.772711473833295200f, + 1.772533881102629000f, 1.772356223200959100f, 1.772178500134817100f, + 1.772000711910737700f, 1.771822858535257600f, 1.771644940014915700f, + 1.771466956356254000f, 1.771288907565816000f, 1.771110793650148500f, + 1.770932614615799800f, 1.770754370469321400f, 1.770576061217266500f, + 1.770397686866191300f, 1.770219247422653700f, 1.770040742893215000f, + 1.769862173284438000f, 1.769683538602888000f, 1.769504838855133100f, + 1.769326074047743700f, 1.769147244187292200f, 1.768968349280353800f, + 1.768789389333506000f, 1.768610364353328600f, 1.768431274346403900f, + 1.768252119319316400f, 1.768072899278653200f, 1.767893614231003800f, + 1.767714264182959500f, 1.767534849141115100f, 1.767355369112067100f, + 1.767175824102414000f, 1.766996214118757800f, 1.766816539167701800f, + 1.766636799255852300f, 1.766456994389817600f, 1.766277124576209000f, + 1.766097189821639300f, 1.765917190132724600f, 1.765737125516083000f, + 1.765556995978334800f, 1.765376801526102700f, 1.765196542166012100f, + 1.765016217904690900f, 1.764835828748768400f, 1.764655374704877700f, + 1.764474855779653200f, 1.764294271979732100f, 1.764113623311754000f, + 1.763932909782361100f, 1.763752131398197200f, 1.763571288165909400f, + 1.763390380092146400f, 1.763209407183560200f, 1.763028369446804500f, + 1.762847266888535100f, 1.762666099515411100f, 1.762484867334093400f, + 1.762303570351245300f, 1.762122208573532600f, 1.761940782007623600f, + 1.761759290660188400f, 1.761577734537900500f, 1.761396113647435000f, + 1.761214427995469100f, 1.761032677588683800f, 1.760850862433760700f, + 1.760668982537384900f, 1.760487037906243600f, 1.760305028547026500f, + 1.760122954466425600f, 1.759940815671135100f, 1.759758612167851700f, + 1.759576343963274600f, 1.759394011064105100f, 1.759211613477047200f, + 1.759029151208807400f, 1.758846624266093800f, 1.758664032655617500f, + 1.758481376384092500f, 1.758298655458233600f, 1.758115869884759700f, + 1.757933019670390800f, 1.757750104821850000f, 1.757567125345862700f, + 1.757384081249156100f, 1.757200972538460700f, 1.757017799220508500f, + 1.756834561302034400f, 1.756651258789775800f, 1.756467891690471700f, + 1.756284460010864200f, 1.756100963757697900f, 1.755917402937718900f, + 1.755733777557676500f, 1.755550087624322000f, 1.755366333144409200f, + 1.755182514124693900f, 1.754998630571935200f, 1.754814682492893600f, + 1.754630669894332600f, 1.754446592783017500f, 1.754262451165716300f, + 1.754078245049199600f, 1.753893974440240000f, 1.753709639345612600f, + 1.753525239772095100f, 1.753340775726466700f, 1.753156247215510400f, + 1.752971654246010300f, 1.752786996824753600f, 1.752602274958529500f, + 1.752417488654129700f, 1.752232637918348200f, 1.752047722757981600f, + 1.751862743179828600f, 1.751677699190690400f, 1.751492590797370600f, + 1.751307418006674800f, 1.751122180825411800f, 1.750936879260391700f, + 1.750751513318427700f, 1.750566083006335600f, 1.750380588330932500f, + 1.750195029299038900f, 1.750009405917477100f, 1.749823718193071800f, + 1.749637966132650900f, 1.749452149743043100f, 1.749266269031080700f, + 1.749080324003598100f, 1.748894314667431800f, 1.748708241029421000f, + 1.748522103096407300f, 1.748335900875233900f, 1.748149634372747200f, + 1.747963303595795500f, 1.747776908551230000f, 1.747590449245904000f, + 1.747403925686672500f, 1.747217337880393900f, 1.747030685833928200f, + 1.746843969554138200f, 1.746657189047889200f, 1.746470344322048200f, + 1.746283435383485100f, 1.746096462239072000f, 1.745909424895683200f, + 1.745722323360195900f, 1.745535157639489100f, 1.745347927740444200f, + 1.745160633669945200f, 1.744973275434878300f, 1.744785853042132300f, + 1.744598366498598200f, 1.744410815811169300f, 1.744223200986741100f, + 1.744035522032211900f, 1.743847778954482000f, 1.743659971760454200f, + 1.743472100457033700f, 1.743284165051127700f, 1.743096165549646400f, + 1.742908101959502100f, 1.742719974287608900f, 1.742531782540884100f, + 1.742343526726246800f, 1.742155206850618800f, 1.741966822920923800f, + 1.741778374944088000f, 1.741589862927040800f, 1.741401286876712800f, + 1.741212646800037300f, 1.741023942703950200f, 1.740835174595389600f, + 1.740646342481295900f, 1.740457446368612000f, 1.740268486264283200f, + 1.740079462175256900f, 1.739890374108482600f, 1.739701222070913200f, + 1.739512006069502800f, 1.739322726111208500f, 1.739133382202989500f, + 1.738943974351807600f, 1.738754502564626700f, 1.738564966848413100f, + 1.738375367210135400f, 1.738185703656765200f, 1.737995976195275000f, + 1.737806184832640900f, 1.737616329575841300f, 1.737426410431856200f, + 1.737236427407668800f, 1.737046380510263800f, 1.736856269746629000f, + 1.736666095123754000f, 1.736475856648631400f, 1.736285554328254900f, + 1.736095188169622500f, 1.735904758179732400f, 1.735714264365586700f, + 1.735523706734189100f, 1.735333085292545900f, 1.735142400047666100f, + 1.734951651006560100f, 1.734760838176241400f, 1.734569961563725600f, + 1.734379021176030600f, 1.734188017020177100f, 1.733996949103187500f, + 1.733805817432086900f, 1.733614622013902600f, 1.733423362855664100f, + 1.733232039964403900f, 1.733040653347156300f, 1.732849203010957900f, + 1.732657688962847600f, 1.732466111209867200f, 1.732274469759060200f, + 1.732082764617472800f, 1.731890995792153600f, 1.731699163290153100f, + 1.731507267118524500f, 1.731315307284323700f, 1.731123283794607800f, + 1.730931196656437600f, 1.730739045876875200f, 1.730546831462985500f, + 1.730354553421835600f, 1.730162211760495300f, 1.729969806486036500f, + 1.729777337605533000f, 1.729584805126061400f, 1.729392209054700900f, + 1.729199549398532400f, 1.729006826164639400f, 1.728814039360108100f, + 1.728621188992026400f, 1.728428275067485100f, 1.728235297593577100f, + 1.728042256577397200f, 1.727849152026043500f, 1.727655983946615700f, + 1.727462752346216000f, 1.727269457231948900f, 1.727076098610921500f, + 1.726882676490243000f, 1.726689190877025000f, 1.726495641778381200f, + 1.726302029201427900f, 1.726108353153283900f, 1.725914613641069900f, + 1.725720810671909300f, 1.725526944252927700f, 1.725333014391252900f, + 1.725139021094015200f, 1.724944964368347000f, 1.724750844221383500f, + 1.724556660660261800f, 1.724362413692121400f, 1.724168103324104300f, + 1.723973729563354600f, 1.723779292417019200f, 1.723584791892246700f, + 1.723390227996188600f, 1.723195600735998100f, 1.723000910118831300f, + 1.722806156151846400f, 1.722611338842204000f, 1.722416458197066900f, + 1.722221514223600100f, 1.722026506928971500f, 1.721831436320350800f, + 1.721636302404910200f, 1.721441105189824000f, 1.721245844682269600f, + 1.721050520889425600f, 1.720855133818473900f, 1.720659683476597900f, + 1.720464169870984200f, 1.720268593008821100f, 1.720072952897299100f, + 1.719877249543611900f, 1.719681482954954500f, 1.719485653138524800f, + 1.719289760101522900f, 1.719093803851151400f, 1.718897784394614900f, + 1.718701701739120400f, 1.718505555891877400f, 1.718309346860097600f, + 1.718113074650995200f, 1.717916739271786500f, 1.717720340729689700f, + 1.717523879031926500f, 1.717327354185719900f, 1.717130766198295700f, + 1.716934115076881800f, 1.716737400828708400f, 1.716540623461008100f, + 1.716343782981016200f, 1.716146879395969500f, 1.715949912713108100f, + 1.715752882939673300f, 1.715555790082909900f, 1.715358634150064000f, + 1.715161415148384500f, 1.714964133085122900f, 1.714766787967532600f, + 1.714569379802868900f, 1.714371908598390800f, 1.714174374361358000f, + 1.713976777099033700f, 1.713779116818682900f, 1.713581393527573000f, + 1.713383607232973600f, 1.713185757942156800f, 1.712987845662396800f, + 1.712789870400970700f, 1.712591832165157200f, 1.712393730962237500f, + 1.712195566799495500f, 1.711997339684216700f, 1.711799049623689900f, + 1.711600696625205300f, 1.711402280696055800f, 1.711203801843536700f, + 1.711005260074945200f, 1.710806655397581600f, 1.710607987818747700f, + 1.710409257345748100f, 1.710210463985889500f, 1.710011607746480600f, + 1.709812688634833300f, 1.709613706658261100f, 1.709414661824080000f, + 1.709215554139608400f, 1.709016383612166600f, 1.708817150249077900f, + 1.708617854057667300f, 1.708418495045262300f, 1.708219073219193300f, + 1.708019588586791700f, 1.707820041155392500f, 1.707620430932332400f, + 1.707420757924950300f, 1.707221022140587900f, 1.707021223586588700f, + 1.706821362270298600f, 1.706621438199066300f, 1.706421451380242000f, + 1.706221401821179200f, 1.706021289529232800f, 1.705821114511760300f, + 1.705620876776121600f, 1.705420576329679000f, 1.705220213179796900f, + 1.705019787333842200f, 1.704819298799183700f, 1.704618747583193100f, + 1.704418133693243800f, 1.704217457136711900f, 1.704016717920976000f, + 1.703815916053416300f, 1.703615051541415900f, 1.703414124392360000f, + 1.703213134613636100f, 1.703012082212634000f, 1.702810967196746000f, + 1.702609789573366300f, 1.702408549349891500f, 1.702207246533721000f, + 1.702005881132255800f, 1.701804453152900000f, 1.701602962603059100f, + 1.701401409490141300f, 1.701199793821557300f, 1.700998115604720000f, + 1.700796374847044300f, 1.700594571555948100f, 1.700392705738850400f, + 1.700190777403173700f, 1.699988786556342300f, 1.699786733205783000f, + 1.699584617358924400f, 1.699382439023197700f, 1.699180198206036600f, + 1.698977894914877100f, 1.698775529157156700f, 1.698573100940316400f, + 1.698370610271798800f, 1.698168057159048700f, 1.697965441609513300f, + 1.697762763630642700f, 1.697560023229888200f, 1.697357220414704500f, + 1.697154355192547900f, 1.696951427570877000f, 1.696748437557152900f, + 1.696545385158839200f, 1.696342270383401200f, 1.696139093238307400f, + 1.695935853731027600f, 1.695732551869034300f, 1.695529187659802400f, + 1.695325761110809200f, 1.695122272229534000f, 1.694918721023458600f, + 1.694715107500066800f, 1.694511431666845000f, 1.694307693531282000f, + 1.694103893100868100f, 1.693900030383096900f, 1.693696105385463800f, + 1.693492118115466500f, 1.693288068580604900f, 1.693083956788381500f, + 1.692879782746300700f, 1.692675546461869900f, 1.692471247942597600f, + 1.692266887195995600f, 1.692062464229577600f, 1.691857979050859900f, + 1.691653431667360600f, 1.691448822086600400f, 1.691244150316102000f, + 1.691039416363390800f, 1.690834620235994300f, 1.690629761941442100f, + 1.690424841487266700f, 1.690219858881001800f, 1.690014814130184300f, + 1.689809707242353200f, 1.689604538225049700f, 1.689399307085817300f, + 1.689194013832201500f, 1.688988658471750600f, 1.688783241012014700f, + 1.688577761460546800f, 1.688372219824901400f, 1.688166616112636100f, + 1.687960950331309800f, 1.687755222488484600f, 1.687549432591724400f, + 1.687343580648595700f, 1.687137666666667100f, 1.686931690653509000f, + 1.686725652616694900f, 1.686519552563800400f, 1.686313390502403000f, + 1.686107166440082600f, 1.685900880384421800f, 1.685694532343004600f, + 1.685488122323418400f, 1.685281650333251900f, 1.685075116380096800f, + 1.684868520471546600f, 1.684661862615197000f, 1.684455142818646700f, + 1.684248361089495800f, 1.684041517435347400f, 1.683834611863806100f, + 1.683627644382479800f, 1.683420614998977900f, 1.683213523720911800f, + 1.683006370555896400f, 1.682799155511547600f, 1.682591878595484300f, + 1.682384539815327400f, 1.682177139178700400f, 1.681969676693228600f, + 1.681762152366539600f, 1.681554566206263900f, 1.681346918220033800f, + 1.681139208415483700f, 1.680931436800250600f, 1.680723603381973500f, + 1.680515708168294200f, 1.680307751166856300f, 1.680099732385305300f, + 1.679891651831290100f, 1.679683509512460900f, 1.679475305436470600f, + 1.679267039610974300f, 1.679058712043629300f, 1.678850322742095200f, + 1.678641871714033900f, 1.678433358967109400f, 1.678224784508988400f, + 1.678016148347339300f, 1.677807450489833300f, 1.677598690944143400f, + 1.677389869717945000f, 1.677180986818916300f, 1.676972042254736900f, + 1.676763036033089600f, 1.676553968161658600f, 1.676344838648130600f, + 1.676135647500194700f, 1.675926394725542700f, 1.675717080331867900f, + 1.675507704326866200f, 1.675298266718235900f, 1.675088767513677200f, + 1.674879206720892900f, 1.674669584347587800f, 1.674459900401469700f, + 1.674250154890247300f, 1.674040347821632800f, 1.673830479203340000f, + 1.673620549043085500f, 1.673410557348587600f, 1.673200504127567000f, + 1.672990389387746700f, 1.672780213136852300f, 1.672569975382611300f, + 1.672359676132753500f, 1.672149315395010900f, 1.671938893177118000f, + 1.671728409486811500f, 1.671517864331830000f, 1.671307257719914800f, + 1.671096589658809500f, 1.670885860156259300f, 1.670675069220012500f, + 1.670464216857819200f, 1.670253303077431800f, 1.670042327886605200f, + 1.669831291293095900f, 1.669620193304663500f, 1.669409033929069500f, + 1.669197813174077200f, 1.668986531047453000f, 1.668775187556965000f, + 1.668563782710383600f, 1.668352316515481700f, 1.668140788980034400f, + 1.667929200111818400f, 1.667717549918614100f, 1.667505838408202700f, + 1.667294065588368100f, 1.667082231466896900f, 1.666870336051577800f, + 1.666658379350201000f, 1.666446361370560000f, 1.666234282120450100f, + 1.666022141607668600f, 1.665809939840015500f, 1.665597676825292700f, + 1.665385352571304500f, 1.665172967085857700f, 1.664960520376761000f, + 1.664748012451825200f, 1.664535443318863900f, 1.664322812985692600f, + 1.664110121460129000f, 1.663897368749993400f, 1.663684554863107800f, + 1.663471679807296800f, 1.663258743590387400f, 1.663045746220208600f, + 1.662832687704591800f, 1.662619568051370500f, 1.662406387268380100f, + 1.662193145363459100f, 1.661979842344447600f, 1.661766478219188300f, + 1.661553052995526000f, 1.661339566681307600f, 1.661126019284382200f, + 1.660912410812601900f, 1.660698741273819700f, 1.660485010675892400f, + 1.660271219026677700f, 1.660057366334036300f, 1.659843452605831200f, + 1.659629477849926800f, 1.659415442074190900f, 1.659201345286492900f, + 1.658987187494704200f, 1.658772968706699000f, 1.658558688930353400f, + 1.658344348173546300f, 1.658129946444157700f, 1.657915483750071100f, + 1.657700960099171200f, 1.657486375499345900f, 1.657271729958484500f, + 1.657057023484479000f, 1.656842256085223800f, 1.656627427768615000f, + 1.656412538542551200f, 1.656197588414933600f, 1.655982577393664700f, + 1.655767505486650500f, 1.655552372701798200f, 1.655337179047017700f, + 1.655121924530220900f, 1.654906609159322500f, 1.654691232942238500f, + 1.654475795886888300f, 1.654260298001192200f, 1.654044739293073900f, + 1.653829119770458900f, 1.653613439441274500f, 1.653397698313451300f, + 1.653181896394921000f, 1.652966033693617800f, 1.652750110217479100f, + 1.652534125974443000f, 1.652318080972451400f, 1.652101975219447200f, + 1.651885808723375900f, 1.651669581492185300f, 1.651453293533826000f, + 1.651236944856249600f, 1.651020535467411200f, 1.650804065375267400f, + 1.650587534587776700f, 1.650370943112901000f, 1.650154290958603300f, + 1.649937578132849400f, 1.649720804643607400f, 1.649503970498847200f, + 1.649287075706541200f, 1.649070120274664000f, 1.648853104211192700f, + 1.648636027524106100f, 1.648418890221385400f, 1.648201692311014300f, + 1.647984433800978600f, 1.647767114699266100f, 1.647549735013867000f, + 1.647332294752774200f, 1.647114793923981600f, 1.646897232535486500f, + 1.646679610595287900f, 1.646461928111387300f, 1.646244185091788400f, + 1.646026381544496400f, 1.645808517477519700f, 1.645590592898868600f, + 1.645372607816555400f, 1.645154562238594800f, 1.644936456173004000f, + 1.644718289627801600f, 1.644500062611009300f, 1.644281775130650900f, + 1.644063427194751600f, 1.643845018811340300f, 1.643626549988446200f, + 1.643408020734102600f, 1.643189431056343700f, 1.642970780963206800f, + 1.642752070462730800f, 1.642533299562957100f, 1.642314468271929300f, + 1.642095576597693200f, 1.641876624548297000f, 1.641657612131790500f, + 1.641438539356226500f, 1.641219406229659700f, 1.641000212760146800f, + 1.640780958955747200f, 1.640561644824521700f, 1.640342270374534500f, + 1.640122835613851100f, 1.639903340550539200f, 1.639683785192669600f, + 1.639464169548314100f, 1.639244493625547900f, 1.639024757432447500f, + 1.638804960977092100f, 1.638585104267562800f, 1.638365187311943400f, + 1.638145210118319400f, 1.637925172694778800f, 1.637705075049411800f, + 1.637484917190310800f, 1.637264699125570200f, 1.637044420863286600f, + 1.636824082411559600f, 1.636603683778490100f, 1.636383224972181500f, + 1.636162706000739300f, 1.635942126872271800f, 1.635721487594888400f, + 1.635500788176702100f, 1.635280028625826900f, 1.635059208950379700f, + 1.634838329158479200f, 1.634617389258246700f, 1.634396389257805700f, + 1.634175329165281400f, 1.633954208988801700f, 1.633733028736496400f, + 1.633511788416498000f, 1.633290488036940500f, 1.633069127605960800f, + 1.632847707131697600f, 1.632626226622291700f, 1.632404686085886300f, + 1.632183085530627200f, 1.631961424964661700f, 1.631739704396139900f, + 1.631517923833213400f, 1.631296083284036900f, 1.631074182756766300f, + 1.630852222259560700f, 1.630630201800580900f, 1.630408121387990000f, + 1.630185981029953000f, 1.629963780734637400f, 1.629741520510213000f, + 1.629519200364851800f, 1.629296820306727700f, 1.629074380344017100f, + 1.628851880484898200f, 1.628629320737551700f, 1.628406701110161100f, + 1.628184021610910700f, 1.627961282247988300f, 1.627738483029583100f, + 1.627515623963887000f, 1.627292705059093700f, 1.627069726323399500f, + 1.626846687765002700f, 1.626623589392103500f, 1.626400431212904800f, + 1.626177213235611400f, 1.625953935468430500f, 1.625730597919571300f, + 1.625507200597245500f, 1.625283743509666300f, 1.625060226665050000f, + 1.624836650071614500f, 1.624613013737580000f, 1.624389317671169500f, + 1.624165561880607000f, 1.623941746374119500f, 1.623717871159936300f, + 1.623493936246288300f, 1.623269941641409400f, 1.623045887353534900f, + 1.622821773390902700f, 1.622597599761753000f, 1.622373366474327800f, + 1.622149073536871800f, 1.621924720957631300f, 1.621700308744855200f, + 1.621475836906794500f, 1.621251305451702400f, 1.621026714387834300f, + 1.620802063723447700f, 1.620577353466802700f, 1.620352583626160500f, + 1.620127754209786100f, 1.619902865225945300f, 1.619677916682906700f, + 1.619452908588941300f, 1.619227840952321800f, 1.619002713781323200f, + 1.618777527084222800f, 1.618552280869300300f, 1.618326975144837000f, + 1.618101609919117200f, 1.617876185200426600f, 1.617650700997053500f, + 1.617425157317288200f, 1.617199554169423500f, 1.616973891561754200f, + 1.616748169502577200f, 1.616522388000191500f, 1.616296547062898500f, + 1.616070646699001800f, 1.615844686916807300f, 1.615618667724622700f, + 1.615392589130757900f, 1.615166451143525300f, 1.614940253771239400f, + 1.614713997022216900f, 1.614487680904776600f, 1.614261305427239200f, + 1.614034870597928400f, 1.613808376425168900f, 1.613581822917288900f, + 1.613355210082617800f, 1.613128537929487500f, 1.612901806466232200f, + 1.612675015701188000f, 1.612448165642693400f, 1.612221256299089200f, + 1.611994287678718100f, 1.611767259789925100f, 1.611540172641057200f, + 1.611313026240463800f, 1.611085820596496600f, 1.610858555717509200f, + 1.610631231611857800f, 1.610403848287899700f, 1.610176405753995800f, + 1.609948904018508200f, 1.609721343089801600f, 1.609493722976242900f, + 1.609266043686200700f, 1.609038305228046400f, 1.608810507610153100f, + 1.608582650840896200f, 1.608354734928653800f, 1.608126759881805400f, + 1.607898725708732900f, 1.607670632417820500f, 1.607442480017454700f, + 1.607214268516024000f, 1.606985997921919000f, 1.606757668243532500f, + 1.606529279489259600f, 1.606300831667497600f, 1.606072324786645500f, + 1.605843758855105300f, 1.605615133881280700f, 1.605386449873577300f, + 1.605157706840403300f, 1.604928904790168700f, 1.604700043731286200f, + 1.604471123672170500f, 1.604242144621237800f, 1.604013106586907400f, + 1.603784009577600100f, 1.603554853601739700f, 1.603325638667751000f, + 1.603096364784061900f, 1.602867031959102100f, 1.602637640201303400f, + 1.602408189519099800f, 1.602178679920927900f, 1.601949111415226000f, + 1.601719484010434300f, 1.601489797714996000f, 1.601260052537355700f, + 1.601030248485960900f, 1.600800385569260300f, 1.600570463795705700f, + 1.600340483173750400f, 1.600110443711850300f, 1.599880345418463100f, + 1.599650188302049100f, 1.599419972371070500f, 1.599189697633991400f, + 1.598959364099278700f, 1.598728971775401000f, 1.598498520670828900f, + 1.598268010794035900f, 1.598037442153496900f, 1.597806814757689200f, + 1.597576128615092200f, 1.597345383734188000f, 1.597114580123460100f, + 1.596883717791394800f, 1.596652796746479600f, 1.596421816997205500f, + 1.596190778552064800f, 1.595959681419551800f, 1.595728525608163700f, + 1.595497311126399300f, 1.595266037982759500f, 1.595034706185747500f, + 1.594803315743869000f, 1.594571866665631700f, 1.594340358959544800f, + 1.594108792634120600f, 1.593877167697873100f, 1.593645484159318200f, + 1.593413742026974500f, 1.593181941309362400f, 1.592950082015004700f, + 1.592718164152426000f, 1.592486187730153300f, 1.592254152756715600f, + 1.592022059240644400f, 1.591789907190473100f, 1.591557696614737100f, + 1.591325427521974100f, 1.591093099920724200f, 1.590860713819529400f, + 1.590628269226933600f, 1.590395766151483400f, 1.590163204601727100f, + 1.589930584586215500f, 1.589697906113501000f, 1.589465169192139100f, + 1.589232373830686400f, 1.588999520037702300f, 1.588766607821748200f, + 1.588533637191387400f, 1.588300608155185600f, 1.588067520721711000f, + 1.587834374899533400f, 1.587601170697224600f, 1.587367908123358900f, + 1.587134587186513000f, 1.586901207895265300f, 1.586667770258196600f, + 1.586434274283889500f, 1.586200719980929200f, 1.585967107357902700f, + 1.585733436423399000f, 1.585499707186010200f, 1.585265919654329300f, + 1.585032073836952100f, 1.584798169742476400f, 1.584564207379502500f, + 1.584330186756632200f, 1.584096107882470000f, 1.583861970765622100f, + 1.583627775414697000f, 1.583393521838305700f, 1.583159210045060900f, + 1.582924840043577400f, 1.582690411842472700f, 1.582455925450365600f, + 1.582221380875877800f, 1.581986778127632700f, 1.581752117214255900f, + 1.581517398144375800f, 1.581282620926621300f, 1.581047785569625400f, + 1.580812892082021900f, 1.580577940472447200f, 1.580342930749539800f, + 1.580107862921940700f, 1.579872736998292100f, 1.579637552987239100f, + 1.579402310897428900f, 1.579167010737510600f, 1.578931652516135700f, + 1.578696236241957200f, 1.578460761923630800f, 1.578225229569814700f, + 1.577989639189168100f, 1.577753990790353500f, 1.577518284382034800f, + 1.577282519972878200f, 1.577046697571552000f, 1.576810817186727000f, + 1.576574878827075700f, 1.576338882501273000f, 1.576102828217995600f, + 1.575866715985922500f, 1.575630545813735200f, 1.575394317710116600f, + 1.575158031683752300f, 1.574921687743330300f, 1.574685285897539800f, + 1.574448826155072400f, 1.574212308524622500f, 1.573975733014886000f, + 1.573739099634561500f, 1.573502408392348600f, 1.573265659296950300f, + 1.573028852357070800f, 1.572791987581417100f, 1.572555064978698100f, + 1.572318084557624800f, 1.572081046326909900f, 1.571843950295269000f, + 1.571606796471419100f, 1.571369584864080100f, 1.571132315481973200f, + 1.570894988333822400f, 1.570657603428353300f, 1.570420160774294000f, + 1.570182660380374600f, 1.569945102255327200f, 1.569707486407886600f, + 1.569469812846788500f, 1.569232081580771900f, 1.568994292618577400f, + 1.568756445968948000f, 1.568518541640628400f, 1.568280579642366000f, + 1.568042559982909500f, 1.567804482671010500f, 1.567566347715422500f, + 1.567328155124900800f, 1.567089904908203200f, 1.566851597074089500f, + 1.566613231631321500f, 1.566374808588663300f, 1.566136327954881000f, + 1.565897789738742900f, 1.565659193949019400f, 1.565420540594482800f, + 1.565181829683907700f, 1.564943061226071100f, 1.564704235229751500f, + 1.564465351703730400f, 1.564226410656790000f, 1.563987412097716200f, + 1.563748356035296000f, 1.563509242478319000f, 1.563270071435576500f, + 1.563030842915862100f, 1.562791556927971800f, 1.562552213480703300f, + 1.562312812582856500f, 1.562073354243233700f, 1.561833838470639200f, + 1.561594265273878800f, 1.561354634661761300f, 1.561114946643096900f, + 1.560875201226698900f, 1.560635398421381400f, 1.560395538235961800f, + 1.560155620679258400f, 1.559915645760092900f, 1.559675613487288200f, + 1.559435523869669500f, 1.559195376916064700f, 1.558955172635302800f, + 1.558714911036215700f, 1.558474592127637100f, 1.558234215918402600f, + 1.557993782417350400f, 1.557753291633320500f, 1.557512743575155000f, + 1.557272138251698300f, 1.557031475671796400f, 1.556790755844298400f, + 1.556549978778054300f, 1.556309144481917300f, 1.556068252964741600f, + 1.555827304235384500f, 1.555586298302704900f, 1.555345235175563900f, + 1.555104114862824600f, 1.554862937373352500f, 1.554621702716015000f, + 1.554380410899681300f, 1.554139061933223200f, 1.553897655825514600f, + 1.553656192585431100f, 1.553414672221850700f, 1.553173094743653300f, + 1.552931460159721100f, 1.552689768478938500f, 1.552448019710191300f, + 1.552206213862368500f, 1.551964350944360100f, 1.551722430965059000f, + 1.551480453933359800f, 1.551238419858159700f, 1.550996328748356800f, + 1.550754180612852900f, 1.550511975460550500f, 1.550269713300355100f, + 1.550027394141174000f, 1.549785017991916400f, 1.549542584861493900f, + 1.549300094758820000f, 1.549057547692810600f, 1.548814943672383300f, + 1.548572282706457900f, 1.548329564803956300f, 1.548086789973802700f, + 1.547843958224923000f, 1.547601069566245900f, 1.547358124006701400f, + 1.547115121555221700f, 1.546872062220741700f, 1.546628946012197800f, + 1.546385772938528600f, 1.546142543008675300f, 1.545899256231580300f, + 1.545655912616188800f, 1.545412512171447700f, 1.545169054906306200f, + 1.544925540829715600f, 1.544681969950629300f, 1.544438342278002600f, + 1.544194657820792800f, 1.543950916587959700f, 1.543707118588464800f, + 1.543463263831272000f, 1.543219352325347200f, 1.542975384079658300f, + 1.542731359103175300f, 1.542487277404870100f, 1.542243138993717000f, + 1.541998943878692300f, 1.541754692068774600f, 1.541510383572944000f, + 1.541266018400183200f, 1.541021596559476700f, 1.540777118059811100f, + 1.540532582910175500f, 1.540287991119560600f, 1.540043342696959100f, + 1.539798637651366400f, 1.539553875991779300f, 1.539309057727197300f, + 1.539064182866621400f, 1.538819251419055100f, 1.538574263393503800f, + 1.538329218798974800f, 1.538084117644477900f, 1.537838959939025200f, + 1.537593745691629500f, 1.537348474911307300f, 1.537103147607076200f, + 1.536857763787956400f, 1.536612323462969800f, 1.536366826641140800f, + 1.536121273331495300f, 1.535875663543061700f, 1.535629997284870400f, + 1.535384274565953600f, 1.535138495395346400f, 1.534892659782085100f, + 1.534646767735208000f, 1.534400819263756400f, 1.534154814376772700f, + 1.533908753083302200f, 1.533662635392391700f, 1.533416461313090100f, + 1.533170230854448400f, 1.532923944025520200f, 1.532677600835360600f, + 1.532431201293027000f, 1.532184745407578500f, 1.531938233188077100f, + 1.531691664643585900f, 1.531445039783170500f, 1.531198358615898800f, + 1.530951621150840700f, 1.530704827397067800f, 1.530457977363654000f, + 1.530211071059675200f, 1.529964108494209700f, 1.529717089676337500f, + 1.529470014615140800f, 1.529222883319703700f, 1.528975695799112500f, + 1.528728452062455600f, 1.528481152118823700f, 1.528233795977309400f, + 1.527986383647006500f, 1.527738915137012400f, 1.527491390456425600f, + 1.527243809614346600f, 1.526996172619878900f, 1.526748479482126700f, + 1.526500730210197200f, 1.526252924813199500f, 1.526005063300244900f, + 1.525757145680446200f, 1.525509171962918800f, 1.525261142156779900f, + 1.525013056271149000f, 1.524764914315147200f, 1.524516716297898300f, + 1.524268462228527900f, 1.524020152116163200f, 1.523771785969934000f, + 1.523523363798972000f, 1.523274885612411200f, 1.523026351419387100f, + 1.522777761229038100f, 1.522529115050503600f, 1.522280412892925900f, + 1.522031654765448900f, 1.521782840677218700f, 1.521533970637383800f, + 1.521285044655094300f, 1.521036062739502300f, 1.520787024899762100f, + 1.520537931145030400f, 1.520288781484465700f, 1.520039575927228500f, + 1.519790314482481100f, 1.519540997159388300f, 1.519291623967116600f, + 1.519042194914835200f, 1.518792710011714500f, 1.518543169266927600f, + 1.518293572689648900f, 1.518043920289055900f, 1.517794212074327500f, + 1.517544448054644500f, 1.517294628239190400f, 1.517044752637150000f, + 1.516794821257710500f, 1.516544834110061600f, 1.516294791203394200f, + 1.516044692546901800f, 1.515794538149779700f, 1.515544328021225500f, + 1.515294062170438700f, 1.515043740606620800f, 1.514793363338975600f, + 1.514542930376708600f, 1.514292441729027300f, 1.514041897405141700f, + 1.513791297414263800f, 1.513540641765606800f, 1.513289930468387300f, + 1.513039163531823000f, 1.512788340965133500f, 1.512537462777541200f, + 1.512286528978270300f, 1.512035539576546600f, 1.511784494581598600f, + 1.511533394002656100f, 1.511282237848951400f, 1.511031026129719100f, + 1.510779758854195400f, 1.510528436031618900f, 1.510277057671229400f, + 1.510025623782270000f, 1.509774134373984800f, 1.509522589455620600f, + 1.509270989036425800f, 1.509019333125651200f, 1.508767621732549400f, + 1.508515854866375100f, 1.508264032536385000f, 1.508012154751837700f, + 1.507760221521994700f, 1.507508232856118200f, 1.507256188763473200f, + 1.507004089253327000f, 1.506751934334948000f, 1.506499724017607900f, + 1.506247458310579400f, 1.505995137223137500f, 1.505742760764559300f, + 1.505490328944124200f, 1.505237841771113200f, 1.504985299254809800f, + 1.504732701404498900f, 1.504480048229468000f, 1.504227339739006500f, + 1.503974575942405700f, 1.503721756848958700f, 1.503468882467961600f, + 1.503215952808711500f, 1.502962967880507600f, 1.502709927692651900f, + 1.502456832254447600f, 1.502203681575200700f, 1.501950475664218600f, + 1.501697214530810700f, 1.501443898184289200f, 1.501190526633967600f, + 1.500937099889161600f, 1.500683617959188900f, 1.500430080853369500f, + 1.500176488581024900f, 1.499922841151479600f, 1.499669138574058800f, + 1.499415380858090800f, 1.499161568012905300f, 1.498907700047834600f, + 1.498653776972212600f, 1.498399798795375000f, 1.498145765526660300f, + 1.497891677175408500f, 1.497637533750961300f, 1.497383335262663300f, + 1.497129081719860400f, 1.496874773131900800f, 1.496620409508134800f, + 1.496365990857914600f, 1.496111517190594300f, 1.495856988515530400f, + 1.495602404842080800f, 1.495347766179606400f, 1.495093072537469100f, + 1.494838323925033400f, 1.494583520351665500f, 1.494328661826734200f, + 1.494073748359609600f, 1.493818779959664300f, 1.493563756636272500f, + 1.493308678398810800f, 1.493053545256657800f, 1.492798357219194100f, + 1.492543114295801900f, 1.492287816495866200f, 1.492032463828773200f, + 1.491777056303911700f, 1.491521593930672100f, 1.491266076718446900f, + 1.491010504676631500f, 1.490754877814621800f, 1.490499196141816600f, + 1.490243459667616600f, 1.489987668401424800f, 1.489731822352645500f, + 1.489475921530685900f, 1.489219965944954300f, 1.488963955604861500f, + 1.488707890519820600f, 1.488451770699245900f, 1.488195596152554800f, + 1.487939366889165600f, 1.487683082918499300f, 1.487426744249978400f, + 1.487170350893028500f, 1.486913902857075700f, 1.486657400151549600f, + 1.486400842785880100f, 1.486144230769501000f, 1.485887564111846500f, + 1.485630842822354100f, 1.485374066910462500f, 1.485117236385612200f, + 1.484860351257246500f, 1.484603411534810300f, 1.484346417227750700f, + 1.484089368345516300f, 1.483832264897558400f, 1.483575106893329600f, + 1.483317894342285100f, 1.483060627253882000f, 1.482803305637578900f, + 1.482545929502837100f, 1.482288498859119400f, 1.482031013715890700f, + 1.481773474082618300f, 1.481515879968770900f, 1.481258231383819800f, + 1.481000528337237800f, 1.480742770838499900f, 1.480484958897083200f, + 1.480227092522466500f, 1.479969171724131200f, 1.479711196511560100f, + 1.479453166894238100f, 1.479195082881652200f, 1.478936944483291600f, + 1.478678751708647000f, 1.478420504567211900f, 1.478162203068481100f, + 1.477903847221951400f, 1.477645437037121900f, 1.477386972523493800f, + 1.477128453690569800f, 1.476869880547855300f, 1.476611253104856700f, + 1.476352571371083700f, 1.476093835356046700f, 1.475835045069259000f, + 1.475576200520235500f, 1.475317301718493300f, 1.475058348673551100f, + 1.474799341394929900f, 1.474540279892153000f, 1.474281164174744900f, + 1.474021994252233000f, 1.473762770134145800f, 1.473503491830014300f, + 1.473244159349371700f, 1.472984772701752900f, 1.472725331896694400f, + 1.472465836943735600f, 1.472206287852416900f, 1.471946684632281500f, + 1.471687027292874400f, 1.471427315843742100f, 1.471167550294433700f, + 1.470907730654499800f, 1.470647856933493300f, 1.470387929140969200f, + 1.470127947286484100f, 1.469867911379596900f, 1.469607821429868500f, + 1.469347677446861500f, 1.469087479440140300f, 1.468827227419272200f, + 1.468566921393825700f, 1.468306561373371900f, 1.468046147367482600f, + 1.467785679385733300f, 1.467525157437700200f, 1.467264581532962100f, + 1.467003951681099800f, 1.466743267891695800f, 1.466482530174334500f, + 1.466221738538602500f, 1.465960892994088800f, 1.465699993550383400f, + 1.465439040217079400f, 1.465178033003770700f, 1.464916971920054100f, + 1.464655856975527900f, 1.464394688179792900f, 1.464133465542451200f, + 1.463872189073107500f, 1.463610858781367900f, 1.463349474676840700f, + 1.463088036769136600f, 1.462826545067867700f, 1.462564999582648600f, + 1.462303400323095000f, 1.462041747298825900f, 1.461780040519460800f, + 1.461518279994622200f, 1.461256465733934400f, 1.460994597747023600f, + 1.460732676043517800f, 1.460470700633046800f, 1.460208671525243400f, + 1.459946588729741100f, 1.459684452256176300f, 1.459422262114186800f, + 1.459160018313412400f, 1.458897720863495500f, 1.458635369774079500f, + 1.458372965054810700f, 1.458110506715337000f, 1.457847994765308200f, + 1.457585429214375700f, 1.457322810072193800f, 1.457060137348418000f, + 1.456797411052706200f, 1.456534631194717800f, 1.456271797784114900f, + 1.456008910830560500f, 1.455745970343720800f, 1.455482976333263100f, + 1.455219928808857200f, 1.454956827780174100f, 1.454693673256887600f, + 1.454430465248673300f, 1.454167203765208000f, 1.453903888816171900f, + 1.453640520411245900f, 1.453377098560113100f, 1.453113623272459100f, + 1.452850094557971000f, 1.452586512426338000f, 1.452322876887251400f, + 1.452059187950404100f, 1.451795445625491300f, 1.451531649922210200f, + 1.451267800850259500f, 1.451003898419340500f, 1.450739942639155800f, + 1.450475933519410400f, 1.450211871069811300f, 1.449947755300067500f, + 1.449683586219889400f, 1.449419363838989800f, 1.449155088167083600f, + 1.448890759213887100f, 1.448626376989119400f, 1.448361941502500900f, + 1.448097452763754000f, 1.447832910782603100f, 1.447568315568775100f, + 1.447303667131997900f, 1.447038965482002200f, 1.446774210628520200f, + 1.446509402581286400f, 1.446244541350036700f, 1.445979626944509300f, + 1.445714659374444500f, 1.445449638649584500f, 1.445184564779673500f, + 1.444919437774456700f, 1.444654257643682900f, 1.444389024397101600f, + 1.444123738044464900f, 1.443858398595526400f, 1.443593006060042100f, + 1.443327560447769600f, 1.443062061768468400f, 1.442796510031900500f, + 1.442530905247829200f, 1.442265247426020200f, 1.441999536576240800f, + 1.441733772708260600f, 1.441467955831850800f, 1.441202085956784900f, + 1.440936163092837900f, 1.440670187249787600f, 1.440404158437412500f, + 1.440138076665494100f, 1.439871941943815300f, 1.439605754282161400f, + 1.439339513690319100f, 1.439073220178077400f, 1.438806873755226900f, + 1.438540474431560600f, 1.438274022216873500f, 1.438007517120961900f, + 1.437740959153624500f, 1.437474348324662100f, 1.437207684643876800f, + 1.436940968121073600f, 1.436674198766058500f, 1.436407376588640000f, + 1.436140501598628400f, 1.435873573805835900f, 1.435606593220076600f, + 1.435339559851166500f, 1.435072473708924000f, 1.434805334803169100f, + 1.434538143143723200f, 1.434270898740410700f, 1.434003601603057300f, + 1.433736251741490700f, 1.433468849165540500f, 1.433201393885038500f, + 1.432933885909818000f, 1.432666325249714700f, 1.432398711914566200f, + 1.432131045914211600f, 1.431863327258492400f, 1.431595555957251700f, + 1.431327732020334800f, 1.431059855457588600f, 1.430791926278862400f, + 1.430523944494007400f, 1.430255910112876000f, 1.429987823145323100f, + 1.429719683601205800f, 1.429451491490382900f, 1.429183246822714800f, + 1.428914949608064200f, 1.428646599856295400f, 1.428378197577275100f, + 1.428109742780871800f, 1.427841235476955400f, 1.427572675675398600f, + 1.427304063386075200f, 1.427035398618861500f, 1.426766681383635500f, + 1.426497911690277000f, 1.426229089548668200f, 1.425960214968693000f, + 1.425691287960236600f, 1.425422308533187200f, 1.425153276697434000f, + 1.424884192462868800f, 1.424615055839385300f, 1.424345866836878200f, + 1.424076625465245500f, 1.423807331734385800f, 1.423537985654200800f, + 1.423268587234593400f, 1.422999136485468600f, 1.422729633416733200f, + 1.422460078038296300f, 1.422190470360068300f, 1.421920810391962500f, + 1.421651098143893000f, 1.421381333625776600f, 1.421111516847531700f, + 1.420841647819078600f, 1.420571726550339700f, 1.420301753051239400f, + 1.420031727331703800f, 1.419761649401660500f, 1.419491519271040000f, + 1.419221336949774100f, 1.418951102447796800f, 1.418680815775043500f, + 1.418410476941452100f, 1.418140085956961900f, 1.417869642831514700f, + 1.417599147575054000f, 1.417328600197524900f, 1.417058000708874700f, + 1.416787349119052600f, 1.416516645438009600f, 1.416245889675698900f, + 1.415975081842075300f, 1.415704221947095700f, 1.415433310000718600f, + 1.415162346012905000f, 1.414891329993617200f, 1.414620261952819600f, + 1.414349141900479000f, 1.414077969846563500f, 1.413806745801043500f, + 1.413535469773890700f, 1.413264141775079300f, 1.412992761814585400f, + 1.412721329902386900f, 1.412449846048463600f, 1.412178310262796900f, + 1.411906722555370500f, 1.411635082936170100f, 1.411363391415182900f, + 1.411091648002398500f, 1.410819852707807700f, 1.410548005541404100f, + 1.410276106513182400f, 1.410004155633139500f, 1.409732152911274500f, + 1.409460098357588200f, 1.409187991982083100f, 1.408915833794763800f, + 1.408643623805636800f, 1.408371362024710500f, 1.408099048461995300f, + 1.407826683127503000f, 1.407554266031248100f, 1.407281797183246500f, + 1.407009276593515800f, 1.406736704272076400f, 1.406464080228949600f, + 1.406191404474159000f, 1.405918677017730100f, 1.405645897869690400f, + 1.405373067040069300f, 1.405100184538898000f, 1.404827250376209400f, + 1.404554264562038400f, 1.404281227106422400f, 1.404008138019399800f, + 1.403734997311011600f, 1.403461804991300100f, 1.403188561070310100f, + 1.402915265558087700f, 1.402641918464681400f, 1.402368519800141200f, + 1.402095069574519800f, 1.401821567797870300f, 1.401548014480249000f, + 1.401274409631713600f, 1.401000753262323900f, 1.400727045382141400f, + 1.400453286001229800f, 1.400179475129653700f, 1.399905612777481200f, + 1.399631698954780800f, 1.399357733671623900f, 1.399083716938083600f, + 1.398809648764234100f, 1.398535529160152400f, 1.398261358135917300f, + 1.397987135701609200f, 1.397712861867310300f, 1.397438536643105000f, + 1.397164160039079200f, 1.396889732065321300f, 1.396615252731921100f, + 1.396340722048970300f, 1.396066140026562800f, 1.395791506674794100f, + 1.395516822003761700f, 1.395242086023564800f, 1.394967298744304900f, + 1.394692460176085300f, 1.394417570329010700f, 1.394142629213188000f, + 1.393867636838725900f, 1.393592593215735600f, 1.393317498354329300f, + 1.393042352264621600f, 1.392767154956728400f, 1.392491906440768600f, + 1.392216606726861800f, 1.391941255825130100f, 1.391665853745697400f, + 1.391390400498689700f, 1.391114896094234100f, 1.390839340542460600f, + 1.390563733853500200f, 1.390288076037486500f, 1.390012367104554600f, + 1.389736607064841100f, 1.389460795928485500f, 1.389184933705628300f, + 1.388909020406412100f, 1.388633056040981600f, 1.388357040619483200f, + 1.388080974152065200f, 1.387804856648877600f, 1.387528688120072600f, + 1.387252468575804100f, 1.386976198026228100f, 1.386699876481501900f, + 1.386423503951785200f, 1.386147080447239600f, 1.385870605978028100f, + 1.385594080554316100f, 1.385317504186270900f, 1.385040876884061000f, + 1.384764198657857200f, 1.384487469517832200f, 1.384210689474160600f, + 1.383933858537019100f, 1.383656976716585600f, 1.383380044023040400f, + 1.383103060466565300f, 1.382826026057344600f, 1.382548940805563800f, + 1.382271804721410600f, 1.381994617815074400f, 1.381717380096746800f, + 1.381440091576620700f, 1.381162752264891500f, 1.380885362171756300f, + 1.380607921307413400f, 1.380330429682064000f, 1.380052887305910400f, + 1.379775294189157000f, 1.379497650342010400f, 1.379219955774678700f, + 1.378942210497371600f, 1.378664414520301500f, 1.378386567853681700f, + 1.378108670507728300f, 1.377830722492658500f, 1.377552723818691500f, + 1.377274674496048700f, 1.376996574534953300f, 1.376718423945630000f, + 1.376440222738305700f, 1.376161970923209400f, 1.375883668510570900f, + 1.375605315510623200f, 1.375326911933600200f, 1.375048457789738400f, + 1.374769953089275400f, 1.374491397842451100f, 1.374212792059507100f, + 1.373934135750687100f, 1.373655428926236400f, 1.373376671596402400f, + 1.373097863771434200f, 1.372819005461582500f, 1.372540096677100200f, + 1.372261137428242300f, 1.371982127725264800f, 1.371703067578426700f, + 1.371423956997988000f, 1.371144795994210500f, 1.370865584577358300f, + 1.370586322757697500f, 1.370307010545495500f, 1.370027647951022100f, + 1.369748234984548000f, 1.369468771656347200f, 1.369189257976694200f, + 1.368909693955866000f, 1.368630079604142000f, 1.368350414931802000f, + 1.368070699949128800f, 1.367790934666406600f, 1.367511119093921800f, + 1.367231253241962200f, 1.366951337120818000f, 1.366671370740780500f, + 1.366391354112143500f, 1.366111287245202400f, 1.365831170150254300f, + 1.365551002837598600f, 1.365270785317536100f, 1.364990517600369400f, + 1.364710199696403300f, 1.364429831615944200f, 1.364149413369300600f, + 1.363868944966782900f, 1.363588426418702600f, 1.363307857735373900f, + 1.363027238927112300f, 1.362746570004235400f, 1.362465850977062900f, + 1.362185081855915600f, 1.361904262651116900f, 1.361623393372991300f, + 1.361342474031866000f, 1.361061504638069400f, 1.360780485201932300f, + 1.360499415733786400f, 1.360218296243966200f, 1.359937126742807300f, + 1.359655907240648000f, 1.359374637747827700f, 1.359093318274687800f, + 1.358811948831571500f, 1.358530529428824400f, 1.358249060076792900f, + 1.357967540785826300f, 1.357685971566275200f, 1.357404352428492000f, + 1.357122683382830900f, 1.356840964439648200f, 1.356559195609301700f, + 1.356277376902151900f, 1.355995508328559500f, 1.355713589898888800f, + 1.355431621623504700f, 1.355149603512774400f, 1.354867535577067200f, + 1.354585417826753800f, 1.354303250272206500f, 1.354021032923800300f, + 1.353738765791911100f, 1.353456448886917200f, 1.353174082219199100f, + 1.352891665799137900f, 1.352609199637117500f, 1.352326683743523300f, + 1.352044118128742600f, 1.351761502803164900f, 1.351478837777180700f, + 1.351196123061183100f, 1.350913358665566400f, 1.350630544600727200f, + 1.350347680877063800f, 1.350064767504976400f, 1.349781804494866600f, + 1.349498791857138400f, 1.349215729602197400f, 1.348932617740450600f, + 1.348649456282307700f, 1.348366245238179500f, 1.348082984618478800f, + 1.347799674433620500f, 1.347516314694020800f, 1.347232905410098200f, + 1.346949446592273100f, 1.346665938250967100f, 1.346382380396604000f, + 1.346098773039609700f, 1.345815116190411300f, 1.345531409859438200f, + 1.345247654057121700f, 1.344963848793894200f, 1.344679994080190800f, + 1.344396089926448000f, 1.344112136343103900f, 1.343828133340598800f, + 1.343544080929374800f, 1.343259979119875600f, 1.342975827922546600f, + 1.342691627347835500f, 1.342407377406191500f, 1.342123078108065700f, + 1.341838729463910900f, 1.341554331484181600f, 1.341269884179334700f, + 1.340985387559828100f, 1.340700841636122400f, 1.340416246418678800f, + 1.340131601917961900f, 1.339846908144436600f, 1.339562165108570700f, + 1.339277372820833400f, 1.338992531291695500f, 1.338707640531629800f, + 1.338422700551110900f, 1.338137711360615200f, 1.337852672970621300f, + 1.337567585391608900f, 1.337282448634059800f, 1.336997262708457900f, + 1.336712027625288600f, 1.336426743395039000f, 1.336141410028198500f, + 1.335856027535258000f, 1.335570595926709700f, 1.335285115213048500f, + 1.334999585404770700f, 1.334714006512374400f, 1.334428378546359500f, + 1.334142701517227600f, 1.333856975435482300f, 1.333571200311629100f, + 1.333285376156174700f, 1.332999502979628700f, 1.332713580792501500f, + 1.332427609605305400f, 1.332141589428554900f, 1.331855520272766200f, + 1.331569402148457400f, 1.331283235066148100f, 1.330997019036359800f, + 1.330710754069615700f, 1.330424440176441300f, 1.330138077367363200f, + 1.329851665652910500f, 1.329565205043613800f, 1.329278695550004700f, + 1.328992137182618100f, 1.328705529951989400f, 1.328418873868656900f, + 1.328132168943159800f, 1.327845415186039000f, 1.327558612607838500f, + 1.327271761219102500f, 1.326984861030378000f, 1.326697912052213500f, + 1.326410914295159400f, 1.326123867769767500f, 1.325836772486591800f, + 1.325549628456188100f, 1.325262435689113600f, 1.324975194195928000f, + 1.324687903987191900f, 1.324400565073468300f, 1.324113177465321900f, + 1.323825741173318700f, 1.323538256208027800f, 1.323250722580018500f, + 1.322963140299862500f, 1.322675509378133900f, 1.322387829825407700f, + 1.322100101652261100f, 1.321812324869273500f, 1.321524499487024800f, + 1.321236625516098100f, 1.320948702967077400f, 1.320660731850549000f, + 1.320372712177100700f, 1.320084643957322400f, 1.319796527201805300f, + 1.319508361921142500f, 1.319220148125929100f, 1.318931885826762000f, + 1.318643575034239800f, 1.318355215758962900f, 1.318066808011533200f, + 1.317778351802554800f, 1.317489847142633300f, 1.317201294042376300f, + 1.316912692512393300f, 1.316624042563294900f, 1.316335344205694200f, + 1.316046597450205800f, 1.315757802307445900f, 1.315468958788033000f, + 1.315180066902586800f, 1.314891126661728900f, 1.314602138076083300f, + 1.314313101156274800f, 1.314024015912930600f, 1.313734882356679900f, + 1.313445700498152800f, 1.313156470347981900f, 1.312867191916801100f, + 1.312577865215246900f, 1.312288490253956900f, 1.311999067043570200f, + 1.311709595594728000f, 1.311420075918073900f, 1.311130508024252400f, + 1.310840891923910100f, 1.310551227627695400f, 1.310261515146258200f, + 1.309971754490250700f, 1.309681945670326400f, 1.309392088697140900f, + 1.309102183581351200f, 1.308812230333616500f, 1.308522228964597500f, + 1.308232179484956500f, 1.307942081905358000f, 1.307651936236467800f, + 1.307361742488954300f, 1.307071500673486800f, 1.306781210800736200f, + 1.306490872881376200f, 1.306200486926081700f, 1.305910052945529200f, + 1.305619570950396800f, 1.305329040951365100f, 1.305038462959116100f, + 1.304747836984333300f, 1.304457163037702200f, 1.304166441129910300f, + 1.303875671271646400f, 1.303584853473601200f, 1.303293987746467300f, + 1.303003074100939100f, 1.302712112547712800f, 1.302421103097485900f, + 1.302130045760958100f, 1.301838940548830600f, 1.301547787471806900f, + 1.301256586540591600f, 1.300965337765891600f, 1.300674041158414800f, + 1.300382696728871400f, 1.300091304487973800f, 1.299799864446435200f, + 1.299508376614971500f, 1.299216841004299200f, 1.298925257625137800f, + 1.298633626488207500f, 1.298341947604231300f, 1.298050220983932900f, + 1.297758446638038700f, 1.297466624577275900f, 1.297174754812374400f, + 1.296882837354065100f, 1.296590872213081200f, 1.296298859400157700f, + 1.296006798926030200f, 1.295714690801437600f, 1.295422535037119800f, + 1.295130331643818500f, 1.294838080632277000f, 1.294545782013240900f, + 1.294253435797456900f, 1.293961041995673700f, 1.293668600618642000f, + 1.293376111677113900f, 1.293083575181843500f, 1.292790991143586200f, + 1.292498359573099700f, 1.292205680481143500f, 1.291912953878477900f, + 1.291620179775866400f, 1.291327358184073200f, 1.291034489113864100f, + 1.290741572576007400f, 1.290448608581273000f, 1.290155597140431700f, + 1.289862538264257700f, 1.289569431963524900f, 1.289276278249010600f, + 1.288983077131493000f, 1.288689828621752300f, 1.288396532730570400f, + 1.288103189468731400f, 1.287809798847019800f, 1.287516360876223500f, + 1.287222875567130900f, 1.286929342930532800f, 1.286635762977221800f, + 1.286342135717991600f, 1.286048461163638000f, 1.285754739324958900f, + 1.285460970212753500f, 1.285167153837822900f, 1.284873290210969900f, + 1.284579379342998700f, 1.284285421244715900f, 1.283991415926929400f, + 1.283697363400448900f, 1.283403263676086100f, 1.283109116764654000f, + 1.282814922676967400f, 1.282520681423843000f, 1.282226393016099500f, + 1.281932057464557000f, 1.281637674780037100f, 1.281343244973363700f, + 1.281048768055361900f, 1.280754244036858900f, 1.280459672928683500f, + 1.280165054741666300f, 1.279870389486639400f, 1.279575677174437100f, + 1.279280917815894600f, 1.278986111421849900f, 1.278691258003142000f, + 1.278396357570611900f, 1.278101410135101800f, 1.277806415707456700f, + 1.277511374298522200f, 1.277216285919146500f, 1.276921150580179200f, + 1.276625968292471000f, 1.276330739066875400f, 1.276035462914247000f, + 1.275740139845442400f, 1.275444769871319600f, 1.275149353002738700f, + 1.274853889250561200f, 1.274558378625650200f, 1.274262821138871300f, + 1.273967216801090900f, 1.273671565623178100f, 1.273375867616002300f, + 1.273080122790436000f, 1.272784331157352800f, 1.272488492727628100f, + 1.272192607512139300f, 1.271896675521764900f, 1.271600696767385400f, + 1.271304671259883200f, 1.271008599010142500f, 1.270712480029048800f, + 1.270416314327489800f, 1.270120101916354600f, 1.269823842806533800f, + 1.269527537008920300f, 1.269231184534408200f, 1.268934785393893700f, + 1.268638339598274500f, 1.268341847158450200f, 1.268045308085321800f, + 1.267748722389792100f, 1.267452090082765900f, 1.267155411175149500f, + 1.266858685677851000f, 1.266561913601780100f, 1.266265094957848000f, + 1.265968229756968100f, 1.265671318010055400f, 1.265374359728026500f, + 1.265077354921799300f, 1.264780303602294200f, 1.264483205780432700f, + 1.264186061467138500f, 1.263888870673336400f, 1.263591633409954000f, + 1.263294349687918800f, 1.262997019518161700f, 1.262699642911614600f, + 1.262402219879211300f, 1.262104750431887000f, 1.261807234580578900f, + 1.261509672336225600f, 1.261212063709767900f, 1.260914408712147800f, + 1.260616707354309500f, 1.260318959647198400f, 1.260021165601761900f, + 1.259723325228949000f, 1.259425438539710300f, 1.259127505544998600f, + 1.258829526255768000f, 1.258531500682973800f, 1.258233428837574300f, + 1.257935310730528000f, 1.257637146372796400f, 1.257338935775342200f, + 1.257040678949129500f, 1.256742375905124400f, 1.256444026654294400f, + 1.256145631207609400f, 1.255847189576040100f, 1.255548701770560000f, + 1.255250167802143000f, 1.254951587681765600f, 1.254652961420405600f, + 1.254354289029042900f, 1.254055570518658500f, 1.253756805900235700f, + 1.253457995184759300f, 1.253159138383215200f, 1.252860235506592100f, + 1.252561286565879300f, 1.252262291572068900f, 1.251963250536153500f, + 1.251664163469128300f, 1.251365030381989700f, 1.251065851285736200f, + 1.250766626191367500f, 1.250467355109885500f, 1.250168038052293500f, + 1.249868675029596200f, 1.249569266052800800f, 1.249269811132915200f, + 1.248970310280950200f, 1.248670763507917100f, 1.248371170824829300f, + 1.248071532242702100f, 1.247771847772552300f, 1.247472117425398700f, + 1.247172341212261500f, 1.246872519144162300f, 1.246572651232124700f, + 1.246272737487174300f, 1.245972777920338000f, 1.245672772542644400f, + 1.245372721365123600f, 1.245072624398807900f, 1.244772481654731000f, + 1.244472293143928300f, 1.244172058877436800f, 1.243871778866295400f, + 1.243571453121544000f, 1.243271081654225400f, 1.242970664475383100f, + 1.242670201596062700f, 1.242369693027311200f, 1.242069138780177400f, + 1.241768538865712000f, 1.241467893294967200f, 1.241167202078996800f, + 1.240866465228856100f, 1.240565682755603100f, 1.240264854670295900f, + 1.239963980983995300f, 1.239663061707763700f, 1.239362096852665300f, + 1.239061086429765300f, 1.238760030450130900f, 1.238458928924831600f, + 1.238157781864937400f, 1.237856589281521000f, 1.237555351185656500f, + 1.237254067588419400f, 1.236952738500886900f, 1.236651363934138300f, + 1.236349943899254000f, 1.236048478407316500f, 1.235746967469409900f, + 1.235445411096619500f, 1.235143809300033300f, 1.234842162090739700f, + 1.234540469479829900f, 1.234238731478396000f, 1.233936948097532400f, + 1.233635119348334400f, 1.233333245241899200f, 1.233031325789326400f, + 1.232729361001716500f, 1.232427350890172000f, 1.232125295465796600f, + 1.231823194739696300f, 1.231521048722978200f, 1.231218857426751700f, + 1.230916620862127400f, 1.230614339040217800f, 1.230312011972136500f, + 1.230009639668999500f, 1.229707222141924100f, 1.229404759402029400f, + 1.229102251460436400f, 1.228799698328266700f, 1.228497100016644900f, + 1.228194456536696500f, 1.227891767899548700f, 1.227589034116330700f, + 1.227286255198173100f, 1.226983431156208200f, 1.226680562001569900f, + 1.226377647745394000f, 1.226074688398817600f, 1.225771683972980200f, + 1.225468634479021500f, 1.225165539928084300f, 1.224862400331312400f, + 1.224559215699851500f, 1.224255986044848500f, 1.223952711377453100f, + 1.223649391708814700f, 1.223346027050086400f, 1.223042617412421600f, + 1.222739162806975900f, 1.222435663244906700f, 1.222132118737372400f, + 1.221828529295533800f, 1.221524894930552800f, 1.221221215653593100f, + 1.220917491475820500f, 1.220613722408401900f, 1.220309908462505800f, + 1.220006049649302800f, 1.219702145979964600f, 1.219398197465665400f, + 1.219094204117580300f, 1.218790165946886100f, 1.218486082964761500f, + 1.218181955182386500f, 1.217877782610943700f, 1.217573565261616000f, + 1.217269303145589000f, 1.216964996274049400f, 1.216660644658185600f, + 1.216356248309187600f, 1.216051807238247800f, 1.215747321456559300f, + 1.215442790975316700f, 1.215138215805717300f, 1.214833595958959300f, + 1.214528931446242600f, 1.214224222278769100f, 1.213919468467741900f, + 1.213614670024366000f, 1.213309826959847700f, 1.213004939285395400f, + 1.212700007012219100f, 1.212395030151530300f, 1.212090008714541600f, + 1.211784942712468300f, 1.211479832156526800f, 1.211174677057934800f, + 1.210869477427912300f, 1.210564233277680500f, 1.210258944618462200f, + 1.209953611461482200f, 1.209648233817966600f, 1.209342811699143600f, + 1.209037345116242400f, 1.208731834080493800f, 1.208426278603131200f, + 1.208120678695388600f, 1.207815034368502100f, 1.207509345633709600f, + 1.207203612502250300f, 1.206897834985365000f, 1.206592013094296200f, + 1.206286146840288300f, 1.205980236234587100f, 1.205674281288440000f, + 1.205368282013096200f, 1.205062238419806200f, 1.204756150519822300f, + 1.204450018324398900f, 1.204143841844791200f, 1.203837621092256800f, + 1.203531356078054100f, 1.203225046813444000f, 1.202918693309688300f, + 1.202612295578050900f, 1.202305853629797500f, 1.201999367476194400f, + 1.201692837128510700f, 1.201386262598016500f, 1.201079643895983700f, + 1.200772981033685800f, 1.200466274022397900f, 1.200159522873396800f, + 1.199852727597960700f, 1.199545888207369700f, 1.199239004712905300f, + 1.198932077125851100f, 1.198625105457491700f, 1.198318089719113200f, + 1.198011029922004400f, 1.197703926077454200f, 1.197396778196754700f, + 1.197089586291198500f, 1.196782350372080300f, 1.196475070450696100f, + 1.196167746538343600f, 1.195860378646322700f, 1.195552966785933900f, + 1.195245510968480300f, 1.194938011205265900f, 1.194630467507596500f, + 1.194322879886780000f, 1.194015248354125100f, 1.193707572920943000f, + 1.193399853598545500f, 1.193092090398246900f, 1.192784283331362700f, + 1.192476432409210100f, 1.192168537643107900f, 1.191860599044376500f, + 1.191552616624337800f, 1.191244590394315400f, 1.190936520365635000f, + 1.190628406549622900f, 1.190320248957608100f, 1.190012047600920200f, + 1.189703802490891000f, 1.189395513638853900f, 1.189087181056143900f, + 1.188778804754097300f, 1.188470384744052100f, 1.188161921037348400f, + 1.187853413645327100f, 1.187544862579331500f, 1.187236267850706000f, + 1.186927629470796900f, 1.186618947450951600f, 1.186310221802519900f, + 1.186001452536852300f, 1.185692639665301600f, 1.185383783199222000f, + 1.185074883149969100f, 1.184765939528900500f, 1.184456952347374900f, + 1.184147921616753200f, 1.183838847348397400f, 1.183529729553671500f, + 1.183220568243940300f, 1.182911363430571200f, 1.182602115124932900f, + 1.182292823338395100f, 1.181983488082330300f, 1.181674109368111300f, + 1.181364687207113100f, 1.181055221610712400f, 1.180745712590287400f, + 1.180436160157217800f, 1.180126564322885100f, 1.179816925098671900f, + 1.179507242495962900f, 1.179197516526144600f, 1.178887747200604300f, + 1.178577934530731700f, 1.178268078527917200f, 1.177958179203553800f, + 1.177648236569035300f, 1.177338250635757700f, 1.177028221415118200f, + 1.176718148918515700f, 1.176408033157350300f, 1.176097874143024600f, + 1.175787671886942000f, 1.175477426400507700f, 1.175167137695128900f, + 1.174856805782213500f, 1.174546430673171900f, 1.174236012379415600f, + 1.173925550912357800f, 1.173615046283413200f, 1.173304498503998400f, + 1.172993907585530900f, 1.172683273539430800f, 1.172372596377118800f, + 1.172061876110017700f, 1.171751112749551900f, 1.171440306307147200f, + 1.171129456794231200f, 1.170818564222232800f, 1.170507628602582800f, + 1.170196649946713100f, 1.169885628266057900f, 1.169574563572052300f, + 1.169263455876133200f, 1.168952305189739200f, 1.168641111524310700f, + 1.168329874891289400f, 1.168018595302118000f, 1.167707272768241800f, + 1.167395907301107100f, 1.167084498912162300f, 1.166773047612856400f, + 1.166461553414641000f, 1.166150016328968600f, 1.165838436367293800f, + 1.165526813541072100f, 1.165215147861761400f, 1.164903439340820900f, + 1.164591687989710500f, 1.164279893819892800f, 1.163968056842831700f, + 1.163656177069992500f, 1.163344254512841800f, 1.163032289182848800f, + 1.162720281091483000f, 1.162408230250216100f, 1.162096136670521600f, + 1.161784000363874000f, 1.161471821341749900f, 1.161159599615627000f, + 1.160847335196984800f, 1.160535028097304600f, 1.160222678328068700f, + 1.159910285900761700f, 1.159597850826869200f, 1.159285373117878500f, + 1.158972852785278500f, 1.158660289840559800f, 1.158347684295214300f, + 1.158035036160735900f, 1.157722345448619400f, 1.157409612170361600f, + 1.157096836337461000f, 1.156784017961417500f, 1.156471157053732300f, + 1.156158253625908700f, 1.155845307689450800f, 1.155532319255865300f, + 1.155219288336659400f, 1.154906214943342700f, 1.154593099087426000f, + 1.154279940780421400f, 1.153966740033842900f, 1.153653496859206000f, + 1.153340211268028000f, 1.153026883271827300f, 1.152713512882124400f, + 1.152400100110440700f, 1.152086644968299400f, 1.151773147467225300f, + 1.151459607618745300f, 1.151146025434387000f, 1.150832400925680100f, + 1.150518734104155400f, 1.150205024981345800f, 1.149891273568785400f, + 1.149577479878009800f, 1.149263643920556800f, 1.148949765707964600f, + 1.148635845251773800f, 1.148321882563526400f, 1.148007877654766200f, + 1.147693830537038100f, 1.147379741221888500f, 1.147065609720865600f, + 1.146751436045519300f, 1.146437220207400700f, 1.146122962218062600f, + 1.145808662089060000f, 1.145494319831947800f, 1.145179935458284100f, + 1.144865508979627800f, 1.144551040407539400f, 1.144236529753581000f, + 1.143921977029316500f, 1.143607382246310600f, 1.143292745416130600f, + 1.142978066550344400f, 1.142663345660522000f, 1.142348582758234900f, + 1.142033777855056000f, 1.141718930962559500f, 1.141404042092321500f, + 1.141089111255919800f, 1.140774138464933700f, 1.140459123730943200f, + 1.140144067065530700f, 1.139828968480280300f, 1.139513827986776900f, + 1.139198645596607400f, 1.138883421321360600f, 1.138568155172625700f, + 1.138252847161994400f, 1.137937497301059600f, 1.137622105601416000f, + 1.137306672074659900f, 1.136991196732388200f, 1.136675679586200500f, + 1.136360120647697200f, 1.136044519928480800f, 1.135728877440154800f, + 1.135413193194324800f, 1.135097467202597100f, 1.134781699476580300f, + 1.134465890027884300f, 1.134150038868120500f, 1.133834146008902100f, + 1.133518211461843200f, 1.133202235238559800f, 1.132886217350669500f, + 1.132570157809791500f, 1.132254056627546300f, 1.131937913815556300f, + 1.131621729385444900f, 1.131305503348837300f, 1.130989235717360100f, + 1.130672926502642100f, 1.130356575716312500f, 1.130040183370002900f, + 1.129723749475346000f, 1.129407274043976200f, 1.129090757087529500f, + 1.128774198617643200f, 1.128457598645956600f, 1.128140957184109700f, + 1.127824274243744500f, 1.127507549836505000f, 1.127190783974035800f, + 1.126873976667983800f, 1.126557127929996800f, 1.126240237771724700f, + 1.125923306204818400f, 1.125606333240930700f, 1.125289318891715900f, + 1.124972263168829500f, 1.124655166083928800f, 1.124338027648672500f, + 1.124020847874721100f, 1.123703626773736100f, 1.123386364357381200f, + 1.123069060637320600f, 1.122751715625221400f, 1.122434329332750800f, + 1.122116901771578400f, 1.121799432953375600f, 1.121481922889814300f, + 1.121164371592568300f, 1.120846779073313400f, 1.120529145343726500f, + 1.120211470415486200f, 1.119893754300272300f, 1.119575997009766300f, + 1.119258198555651300f, 1.118940358949611900f, 1.118622478203333800f, + 1.118304556328505200f, 1.117986593336814700f, 1.117668589239953200f, + 1.117350544049612300f, 1.117032457777486200f, 1.116714330435269600f, + 1.116396162034659600f, 1.116077952587353600f, 1.115759702105052000f, + 1.115441410599455500f, 1.115123078082267000f, 1.114804704565190500f, + 1.114486290059931900f, 1.114167834578198200f, 1.113849338131698300f, + 1.113530800732142100f, 1.113212222391241500f, 1.112893603120710000f, + 1.112574942932261600f, 1.112256241837613000f, 1.111937499848481900f, + 1.111618716976587700f, 1.111299893233650600f, 1.110981028631393700f, + 1.110662123181539900f, 1.110343176895814500f, 1.110024189785944900f, + 1.109705161863658600f, 1.109386093140686000f, 1.109066983628758100f, + 1.108747833339607200f, 1.108428642284968100f, 1.108109410476576300f, + 1.107790137926169200f, 1.107470824645485600f, 1.107151470646265300f, + 1.106832075940250600f, 1.106512640539184100f, 1.106193164454811100f, + 1.105873647698877300f, 1.105554090283131100f, 1.105234492219321100f, + 1.104914853519198400f, 1.104595174194514800f, 1.104275454257024300f, + 1.103955693718482200f, 1.103635892590644900f, 1.103316050885270600f, + 1.102996168614119000f, 1.102676245788951400f, 1.102356282421530300f, + 1.102036278523620000f, 1.101716234106985700f, 1.101396149183395000f, + 1.101076023764616400f, 1.100755857862419700f, 1.100435651488577100f, + 1.100115404654861100f, 1.099795117373046200f, 1.099474789654909100f, + 1.099154421512226600f, 1.098834012956778200f, 1.098513564000344300f, + 1.098193074654706800f, 1.097872544931649100f, 1.097551974842956500f, + 1.097231364400415000f, 1.096910713615813200f, 1.096590022500939700f, + 1.096269291067585700f, 1.095948519327543800f, 1.095627707292607700f, + 1.095306854974572800f, 1.094985962385235800f, 1.094665029536395100f, + 1.094344056439850600f, 1.094023043107403200f, 1.093701989550856000f, + 1.093380895782013000f, 1.093059761812680100f, 1.092738587654664300f, + 1.092417373319774200f, 1.092096118819820200f, 1.091774824166613600f, + 1.091453489371968100f, 1.091132114447697300f, 1.090810699405617900f, + 1.090489244257547300f, 1.090167749015304300f, 1.089846213690709900f, + 1.089524638295585400f, 1.089203022841754400f, 1.088881367341041800f, + 1.088559671805274100f, 1.088237936246279100f, 1.087916160675885800f, + 1.087594345105925300f, 1.087272489548229700f, 1.086950594014632700f, + 1.086628658516969500f, 1.086306683067076900f, 1.085984667676792600f, + 1.085662612357956500f, 1.085340517122409800f, 1.085018381981994500f, + 1.084696206948555300f, 1.084373992033937000f, 1.084051737249986900f, + 1.083729442608553300f, 1.083407108121486000f, 1.083084733800636200f, + 1.082762319657857100f, 1.082439865705002500f, 1.082117371953928300f, + 1.081794838416491700f, 1.081472265104551200f, 1.081149652029967000f, + 1.080826999204601100f, 1.080504306640315500f, 1.080181574348975500f, + 1.079858802342446900f, 1.079535990632596800f, 1.079213139231294500f, + 1.078890248150409700f, 1.078567317401815100f, 1.078244346997383300f, + 1.077921336948988600f, 1.077598287268508400f, 1.077275197967819000f, + 1.076952069058800400f, 1.076628900553332700f, 1.076305692463297900f, + 1.075982444800579700f, 1.075659157577062200f, 1.075335830804633000f, + 1.075012464495178800f, 1.074689058660589700f, 1.074365613312755900f, + 1.074042128463569500f, 1.073718604124924500f, 1.073395040308715400f, + 1.073071437026839500f, 1.072747794291194300f, 1.072424112113678600f, + 1.072100390506194500f, 1.071776629480643500f, 1.071452829048929800f, + 1.071128989222958500f, 1.070805110014635900f, 1.070481191435870500f, + 1.070157233498571600f, 1.069833236214650800f, 1.069509199596019800f, + 1.069185123654592600f, 1.068861008402285200f, 1.068536853851013600f, + 1.068212660012696700f, 1.067888426899253500f, 1.067564154522606000f, + 1.067239842894676100f, 1.066915492027387600f, 1.066591101932666800f, + 1.066266672622439700f, 1.065942204108635300f, 1.065617696403183400f, + 1.065293149518014500f, 1.064968563465062100f, 1.064643938256259400f, + 1.064319273903543000f, 1.063994570418849400f, 1.063669827814116300f, + 1.063345046101285000f, 1.063020225292295300f, 1.062695365399091200f, + 1.062370466433616400f, 1.062045528407815900f, 1.061720551333637600f, + 1.061395535223029500f, 1.061070480087941800f, 1.060745385940325500f, + 1.060420252792134000f, 1.060095080655320900f, 1.059769869541841800f, + 1.059444619463654400f, 1.059119330432716700f, 1.058794002460989000f, + 1.058468635560432500f, 1.058143229743009600f, 1.057817785020685100f, + 1.057492301405424500f, 1.057166778909195000f, 1.056841217543965200f, + 1.056515617321704500f, 1.056189978254385100f, 1.055864300353978900f, + 1.055538583632461100f, 1.055212828101807200f, 1.054887033773993300f, + 1.054561200660999200f, 1.054235328774803900f, 1.053909418127389400f, + 1.053583468730738200f, 1.053257480596834700f, 1.052931453737664600f, + 1.052605388165214700f, 1.052279283891473600f, 1.051953140928431100f, + 1.051626959288079100f, 1.051300738982409800f, 1.050974480023417500f, + 1.050648182423098000f, 1.050321846193448000f, 1.049995471346466300f, + 1.049669057894152800f, 1.049342605848508200f, 1.049016115221536000f, + 1.048689586025239700f, 1.048363018271625300f, 1.048036411972699500f, + 1.047709767140470500f, 1.047383083786948700f, 1.047056361924144400f, + 1.046729601564071200f, 1.046402802718742400f, 1.046075965400174300f, + 1.045749089620383200f, 1.045422175391386800f, 1.045095222725206200f, + 1.044768231633861100f, 1.044441202129375200f, 1.044114134223771900f, + 1.043787027929076000f, 1.043459883257315400f, 1.043132700220517300f, + 1.042805478830712200f, 1.042478219099930400f, 1.042150921040204200f, + 1.041823584663568200f, 1.041496209982056600f, 1.041168797007707000f, + 1.040841345752557200f, 1.040513856228645800f, 1.040186328448014800f, + 1.039858762422705600f, 1.039531158164762400f, 1.039203515686230000f, + 1.038875834999155100f, 1.038548116115585800f, 1.038220359047570500f, + 1.037892563807160800f, 1.037564730406408200f, 1.037236858857366600f, + 1.036908949172090900f, 1.036581001362636600f, 1.036253015441062700f, + 1.035924991419427100f, 1.035596929309791300f, 1.035268829124216700f, + 1.034940690874766300f, 1.034612514573505700f, 1.034284300232500000f, + 1.033956047863817500f, 1.033627757479526700f, 1.033299429091697700f, + 1.032971062712402700f, 1.032642658353714300f, 1.032314216027707700f, + 1.031985735746457900f, 1.031657217522042900f, 1.031328661366541300f, + 1.031000067292032300f, 1.030671435310598600f, 1.030342765434322200f, + 1.030014057675287900f, 1.029685312045581100f, 1.029356528557288300f, + 1.029027707222499100f, 1.028698848053302100f, 1.028369951061789600f, + 1.028041016260053500f, 1.027712043660187600f, 1.027383033274288400f, + 1.027053985114451100f, 1.026724899192775300f, 1.026395775521359500f, + 1.026066614112305600f, 1.025737414977715200f, 1.025408178129692000f, + 1.025078903580341600f, 1.024749591341769700f, 1.024420241426085200f, + 1.024090853845396800f, 1.023761428611814600f, 1.023431965737451800f, + 1.023102465234420700f, 1.022772927114837100f, 1.022443351390816400f, + 1.022113738074476300f, 1.021784087177936000f, 1.021454398713315600f, + 1.021124672692737000f, 1.020794909128323000f, 1.020465108032198300f, + 1.020135269416488700f, 1.019805393293321100f, 1.019475479674824900f, + 1.019145528573129000f, 1.018815540000365800f, 1.018485513968667500f, + 1.018155450490168000f, 1.017825349577003300f, 1.017495211241309800f, + 1.017165035495226400f, 1.016834822350892300f, 1.016504571820448000f, + 1.016174283916036800f, 1.015843958649801600f, 1.015513596033888400f, + 1.015183196080442900f, 1.014852758801613200f, 1.014522284209548900f, + 1.014191772316400000f, 1.013861223134318900f, 1.013530636675459100f, + 1.013200012951974700f, 1.012869351976022300f, 1.012538653759758900f, + 1.012207918315344300f, 1.011877145654937400f, 1.011546335790700600f, + 1.011215488734796800f, 1.010884604499389800f, 1.010553683096645900f, + 1.010222724538731600f, 1.009891728837815700f, 1.009560696006067900f, + 1.009229626055658800f, 1.008898518998761800f, 1.008567374847549900f, + 1.008236193614199000f, 1.007904975310885300f, 1.007573719949786700f, + 1.007242427543082900f, 1.006911098102953900f, 1.006579731641582500f, + 1.006248328171152100f, 1.005916887703846500f, 1.005585410251852700f, + 1.005253895827357800f, 1.004922344442551000f, 1.004590756109621900f, + 1.004259130840762700f, 1.003927468648166100f, 1.003595769544025900f, + 1.003264033540538500f, 1.002932260649900000f, 1.002600450884309800f, + 1.002268604255967200f, 1.001936720777072400f, 1.001604800459829000f, + 1.001272843316440000f, 1.000940849359111000f, 1.000608818600048100f, + 1.000276751051459200f, 0.999944646725553720f, 0.999612505634541740f, + 0.999280327790635690f, 0.998948113206048590f, 0.998615861892994560f, + 0.998283573863690270f, 0.997951249130352380f, 0.997618887705200020f, + 0.997286489600452630f, 0.996954054828332210f, 0.996621583401061110f, + 0.996289075330862860f, 0.995956530629963810f, 0.995623949310589620f, + 0.995291331384969390f, 0.994958676865332010f, 0.994625985763907820f, + 0.994293258092929790f, 0.993960493864630480f, 0.993627693091245660f, + 0.993294855785010760f, 0.992961981958163210f, 0.992629071622942340f, + 0.992296124791587690f, 0.991963141476341460f, 0.991630121689446090f, + 0.991297065443145440f, 0.990963972749685840f, 0.990630843621313260f, + 0.990297678070276800f, 0.989964476108825210f, 0.989631237749210020f, + 0.989297963003683330f, 0.988964651884498000f, 0.988631304403909890f, + 0.988297920574174430f, 0.987964500407549910f, 0.987631043916294970f, + 0.987297551112669370f, 0.986964022008935520f, 0.986630456617355380f, + 0.986296854950194260f, 0.985963217019717120f, 0.985629542838190490f, + 0.985295832417883540f, 0.984962085771065030f, 0.984628302910006580f, + 0.984294483846980150f, 0.983960628594258810f, 0.983626737164118190f, + 0.983292809568833910f, 0.982958845820684270f, 0.982624845931947320f, + 0.982290809914904140f, 0.981956737781835790f, 0.981622629545024770f, + 0.981288485216756160f, 0.980954304809314670f, 0.980620088334987930f, + 0.980285835806063770f, 0.979951547234831130f, 0.979617222633581860f, + 0.979282862014607240f, 0.978948465390201530f, 0.978614032772659240f, + 0.978279564174275860f, 0.977945059607349900f, 0.977610519084179290f, + 0.977275942617064740f, 0.976941330218307540f, 0.976606681900209830f, + 0.976271997675076550f, 0.975937277555212310f, 0.975602521552924600f, + 0.975267729680520560f, 0.974932901950310350f, 0.974598038374604350f, + 0.974263138965714040f, 0.973928203735953460f, 0.973593232697636530f, + 0.973258225863079970f, 0.972923183244600480f, 0.972588104854516410f, + 0.972252990705148370f, 0.971917840808816710f, 0.971582655177844700f, + 0.971247433824555920f, 0.970912176761274950f, 0.970576884000329040f, + 0.970241555554045230f, 0.969906191434753320f, 0.969570791654783330f, + 0.969235356226466500f, 0.968899885162136650f, 0.968564378474127350f, + 0.968228836174775060f, 0.967893258276415700f, 0.967557644791388500f, + 0.967221995732032490f, 0.966886311110688230f, 0.966550590939698640f, + 0.966214835231406500f, 0.965879043998157160f, 0.965543217252296420f, + 0.965207355006171270f, 0.964871457272131190f, 0.964535524062525410f, + 0.964199555389706030f, 0.963863551266025300f, 0.963527511703836660f, + 0.963191436715496120f, 0.962855326313359350f, 0.962519180509785130f, + 0.962182999317132030f, 0.961846782747760140f, 0.961510530814032040f, + 0.961174243528309820f, 0.960837920902958720f, 0.960501562950343390f, + 0.960165169682831830f, 0.959828741112791590f, 0.959492277252591900f, + 0.959155778114604400f, 0.958819243711200310f, 0.958482674054753960f, + 0.958146069157639560f, 0.957809429032232760f, 0.957472753690911670f, + 0.957136043146054050f, 0.956799297410040440f, 0.956462516495251940f, + 0.956125700414070300f, 0.955788849178880300f, 0.955451962802066120f, + 0.955115041296014880f, 0.954778084673113870f, 0.954441092945751630f, + 0.954104066126319150f, 0.953767004227207060f, 0.953429907260809120f, + 0.953092775239518630f, 0.952755608175731570f, 0.952418406081844360f, + 0.952081168970254520f, 0.951743896853362140f, 0.951406589743566950f, + 0.951069247653271500f, 0.950731870594878510f, 0.950394458580791970f, + 0.950057011623418380f, 0.949719529735163940f, 0.949382012928437600f, + 0.949044461215648560f, 0.948706874609207220f, 0.948369253121526420f, + 0.948031596765018910f, 0.947693905552099870f, 0.947356179495185020f, + 0.947018418606691230f, 0.946680622899037650f, 0.946342792384643360f, + 0.946004927075930090f, 0.945667026985319680f, 0.945329092125236190f, + 0.944991122508104350f, 0.944653118146349890f, 0.944315079052401090f, + 0.943977005238685770f, 0.943638896717634900f, 0.943300753501679190f, + 0.942962575603250920f, 0.942624363034784580f, 0.942286115808714690f, + 0.941947833937478270f, 0.941609517433512730f, 0.941271166309256450f, + 0.940932780577150460f, 0.940594360249635500f, 0.940255905339155150f, + 0.939917415858152920f, 0.939578891819073720f, 0.939240333234364950f, + 0.938901740116473540f, 0.938563112477849630f, 0.938224450330942590f, + 0.937885753688204820f, 0.937547022562088990f, 0.937208256965048840f, + 0.936869456909540490f, 0.936530622408019990f, 0.936191753472946030f, + 0.935852850116777430f, 0.935513912351974450f, 0.935174940190999560f, + 0.934835933646314900f, 0.934496892730385720f, 0.934157817455677160f, + 0.933818707834655590f, 0.933479563879790030f, 0.933140385603548840f, + 0.932801173018403480f, 0.932461926136825660f, 0.932122644971287830f, + 0.931783329534265240f, 0.931443979838232900f, 0.931104595895668410f, + 0.930765177719049210f, 0.930425725320855430f, 0.930086238713567440f, + 0.929746717909666790f, 0.929407162921637610f, 0.929067573761963250f, + 0.928727950443130500f, 0.928388292977625930f, 0.928048601377937210f, + 0.927708875656554800f, 0.927369115825968480f, 0.927029321898671270f, + 0.926689493887155820f, 0.926349631803916270f, 0.926009735661449170f, + 0.925669805472250860f, 0.925329841248820340f, 0.924989843003656610f, + 0.924649810749260110f, 0.924309744498133750f, 0.923969644262779830f, + 0.923629510055703820f, 0.923289341889410480f, 0.922949139776407800f, + 0.922608903729203570f, 0.922268633760306990f, 0.921928329882229390f, + 0.921587992107482210f, 0.921247620448579440f, 0.920907214918035070f, + 0.920566775528364410f, 0.920226302292085460f, 0.919885795221715540f, + 0.919545254329774850f, 0.919204679628783720f, 0.918864071131263780f, + 0.918523428849739030f, 0.918182752796733110f, 0.917842042984772340f, + 0.917501299426383480f, 0.917160522134094160f, 0.916819711120434700f, + 0.916478866397934850f, 0.916137987979127270f, 0.915797075876544350f, + 0.915456130102721200f, 0.915115150670193110f, 0.914774137591496510f, + 0.914433090879170130f, 0.914092010545752620f, 0.913750896603785280f, + 0.913409749065809520f, 0.913068567944367970f, 0.912727353252005710f, + 0.912386105001267270f, 0.912044823204700370f, 0.911703507874852440f, + 0.911362159024272310f, 0.911020776665511290f, 0.910679360811120000f, + 0.910337911473652390f, 0.909996428665661990f, 0.909654912399703860f, + 0.909313362688335290f, 0.908971779544113350f, 0.908630162979597760f, + 0.908288513007348140f, 0.907946829639926790f, 0.907605112889895870f, + 0.907263362769819000f, 0.906921579292262250f, 0.906579762469791110f, + 0.906237912314974080f, 0.905896028840379560f, 0.905554112058577170f, + 0.905212161982139160f, 0.904870178623637170f, 0.904528161995645670f, + 0.904186112110739510f, 0.903844028981494190f, 0.903501912620488070f, + 0.903159763040298880f, 0.902817580253507450f, 0.902475364272694370f, + 0.902133115110441470f, 0.901790832779333250f, 0.901448517291953520f, + 0.901106168660889110f, 0.900763786898726380f, 0.900421372018054500f, + 0.900078924031462610f, 0.899736442951541320f, 0.899393928790883420f, + 0.899051381562081310f, 0.898708801277730340f, 0.898366187950425780f, + 0.898023541592764210f, 0.897680862217344440f, 0.897338149836764960f, + 0.896995404463627350f, 0.896652626110532870f, 0.896309814790084090f, + 0.895966970514885940f, 0.895624093297543110f, 0.895281183150662960f, + 0.894938240086852970f, 0.894595264118721810f, 0.894252255258880410f, + 0.893909213519939460f, 0.893566138914512420f, 0.893223031455212530f, + 0.892879891154655380f, 0.892536718025457090f, 0.892193512080234670f, + 0.891850273331607600f, 0.891507001792195000f, 0.891163697474618880f, + 0.890820360391500920f, 0.890476990555464480f, 0.890133587979135000f, + 0.889790152675137610f, 0.889446684656100330f, 0.889103183934650930f, + 0.888759650523418650f, 0.888416084435035060f, 0.888072485682131150f, + 0.887728854277341050f, 0.887385190233298650f, 0.887041493562639060f, + 0.886697764277999840f, 0.886354002392018110f, 0.886010207917333760f, + 0.885666380866586560f, 0.885322521252418610f, 0.884978629087472270f, + 0.884634704384391180f, 0.884290747155821230f, 0.883946757414407980f, + 0.883602735172799640f, 0.883258680443644530f, 0.882914593239592320f, + 0.882570473573294660f, 0.882226321457403320f, 0.881882136904572400f, + 0.881537919927456340f, 0.881193670538710450f, 0.880849388750992610f, + 0.880505074576960370f, 0.880160728029273920f, 0.879816349120593590f, + 0.879471937863580690f, 0.879127494270899090f, 0.878783018355212220f, + 0.878438510129186170f, 0.878093969605486800f, 0.877749396796782770f, + 0.877404791715742370f, 0.877060154375035710f, 0.876715484787334630f, + 0.876370782965310900f, 0.876026048921639160f, 0.875681282668993700f, + 0.875336484220050390f, 0.874991653587487090f, 0.874646790783981660f, + 0.874301895822214290f, 0.873956968714865500f, 0.873612009474616810f, + 0.873267018114152300f, 0.872921994646155390f, 0.872576939083312460f, + 0.872231851438309840f, 0.871886731723835020f, 0.871541579952577750f, + 0.871196396137227660f, 0.870851180290476810f, 0.870505932425017060f, + 0.870160652553543020f, 0.869815340688749220f, 0.869469996843331370f, + 0.869124621029987670f, 0.868779213261415610f, 0.868433773550315810f, + 0.868088301909388680f, 0.867742798351335720f, 0.867397262888861100f, + 0.867051695534668210f, 0.866706096301463340f, 0.866360465201952980f, + 0.866014802248844420f, 0.865669107454847490f, 0.865323380832671800f, + 0.864977622395029290f, 0.864631832154632240f, 0.864286010124194040f, + 0.863940156316430170f, 0.863594270744056040f, 0.863248353419789670f, + 0.862902404356348570f, 0.862556423566453230f, 0.862210411062823810f, + 0.861864366858181910f, 0.861518290965251340f, 0.861172183396755500f, + 0.860826044165420630f, 0.860479873283972910f, 0.860133670765139580f, + 0.859787436621650360f, 0.859441170866234390f, 0.859094873511623840f, + 0.858748544570550610f, 0.858402184055747750f, 0.858055791979950740f, + 0.857709368355894840f, 0.857362913196317630f, 0.857016426513956930f, + 0.856669908321551650f, 0.856323358631843170f, 0.855976777457572280f, + 0.855630164811482460f, 0.855283520706317080f, 0.854936845154821930f, + 0.854590138169742830f, 0.854243399763827020f, 0.853896629949823630f, + 0.853549828740481690f, 0.853202996148552880f, 0.852856132186788910f, + 0.852509236867942440f, 0.852162310204768740f, 0.851815352210022470f, + 0.851468362896461110f, 0.851121342276842110f, 0.850774290363923820f, + 0.850427207170467380f, 0.850080092709233130f, 0.849732946992984290f, + 0.849385770034483680f, 0.849038561846496730f, 0.848691322441788910f, + 0.848344051833126780f, 0.847996750033279350f, 0.847649417055015060f, + 0.847302052911105160f, 0.846954657614320980f, 0.846607231177434640f, + 0.846259773613221020f, 0.845912284934454140f, 0.845564765153910990f, + 0.845217214284368690f, 0.844869632338605130f, 0.844522019329400630f, + 0.844174375269535320f, 0.843826700171791620f, 0.843478994048952440f, + 0.843131256913801420f, 0.842783488779124570f, 0.842435689657707650f, + 0.842087859562339000f, 0.841739998505806610f, 0.841392106500900900f, + 0.841044183560412770f, 0.840696229697133760f, 0.840348244923857960f, + 0.840000229253379030f, 0.839652182698493290f, 0.839304105271996950f, + 0.838955996986687550f, 0.838607857855364740f, 0.838259687890827830f, + 0.837911487105878820f, 0.837563255513319780f, 0.837214993125953600f, + 0.836866699956585690f, 0.836518376018021260f, 0.836170021323067610f, + 0.835821635884532730f, 0.835473219715225040f, 0.835124772827955830f, + 0.834776295235535540f, 0.834427786950777460f, 0.834079247986494690f, + 0.833730678355502630f, 0.833382078070616820f, 0.833033447144653880f, + 0.832684785590432690f, 0.832336093420771970f, 0.831987370648492710f, + 0.831638617286416190f, 0.831289833347364620f, 0.830941018844162600f, + 0.830592173789634240f, 0.830243298196606360f, 0.829894392077905720f, + 0.829545455446360270f, 0.829196488314800080f, 0.828847490696055010f, + 0.828498462602957340f, 0.828149404048339590f, 0.827800315045035150f, + 0.827451195605879990f, 0.827102045743709160f, 0.826752865471360950f, + 0.826403654801672770f, 0.826054413747485010f, 0.825705142321637720f, + 0.825355840536972420f, 0.825006508406332490f, 0.824657145942561230f, + 0.824307753158504460f, 0.823958330067008030f, 0.823608876680918760f, + 0.823259393013085820f, 0.822909879076357930f, 0.822560334883586490f, + 0.822210760447622980f, 0.821861155781319800f, 0.821511520897531660f, + 0.821161855809112830f, 0.820812160528920360f, 0.820462435069811090f, + 0.820112679444643060f, 0.819762893666276530f, 0.819413077747571440f, + 0.819063231701390170f, 0.818713355540594880f, 0.818363449278050270f, + 0.818013512926620940f, 0.817663546499172720f, 0.817313550008573640f, + 0.816963523467691410f, 0.816613466889396070f, 0.816263380286557980f, + 0.815913263672048310f, 0.815563117058740630f, 0.815212940459508210f, + 0.814862733887226740f, 0.814512497354771830f, 0.814162230875020380f, + 0.813811934460851430f, 0.813461608125143560f, 0.813111251880778150f, + 0.812760865740636440f, 0.812410449717600570f, 0.812060003824555230f, + 0.811709528074384460f, 0.811359022479975040f, 0.811008487054213360f, + 0.810657921809988410f, 0.810307326760189020f, 0.809956701917705080f, + 0.809606047295428950f, 0.809255362906252440f, 0.808904648763069890f, + 0.808553904878775760f, 0.808203131266265420f, 0.807852327938436750f, + 0.807501494908186900f, 0.807150632188415760f, 0.806799739792023240f, + 0.806448817731910130f, 0.806097866020979660f, 0.805746884672134620f, + 0.805395873698280360f, 0.805044833112322000f, 0.804693762927166100f, + 0.804342663155721230f, 0.803991533810895500f, 0.803640374905599810f, + 0.803289186452744390f, 0.802937968465242240f, 0.802586720956006250f, + 0.802235443937950320f, 0.801884137423990890f, 0.801532801427043530f, + 0.801181435960026780f, 0.800830041035858750f, 0.800478616667459010f, + 0.800127162867749210f, 0.799775679649650460f, 0.799424167026086540f, + 0.799072625009981330f, 0.798721053614259490f, 0.798369452851848020f, + 0.798017822735673680f, 0.797666163278665570f, 0.797314474493752810f, + 0.796962756393865600f, 0.796611008991936490f, 0.796259232300897350f, + 0.795907426333682830f, 0.795555591103226930f, 0.795203726622466520f, + 0.794851832904338360f, 0.794499909961779990f, 0.794147957807731400f, + 0.793795976455132220f, 0.793443965916924570f, 0.793091926206050400f, + 0.792739857335452710f, 0.792387759318077150f, 0.792035632166868230f, + 0.791683475894773720f, 0.791331290514740830f, 0.790979076039718180f, + 0.790626832482656310f, 0.790274559856505520f, 0.789922258174218570f, + 0.789569927448748320f, 0.789217567693048520f, 0.788865178920075130f, + 0.788512761142783790f, 0.788160314374132590f, 0.787807838627079260f, + 0.787455333914584220f, 0.787102800249607550f, 0.786750237645110430f, + 0.786397646114056490f, 0.786045025669408700f, 0.785692376324132690f, + 0.785339698091194080f, 0.784986990983559170f, 0.784634255014197040f, + 0.784281490196075850f, 0.783928696542166680f, 0.783575874065440270f, + 0.783223022778868350f, 0.782870142695425320f, 0.782517233828084580f, + 0.782164296189822530f, 0.781811329793615120f, 0.781458334652439630f, + 0.781105310779275470f, 0.780752258187101480f, 0.780399176888899150f, + 0.780046066897649550f, 0.779692928226336290f, 0.779339760887942880f, + 0.778986564895453810f, 0.778633340261856040f, 0.778280087000135730f, + 0.777926805123281830f, 0.777573494644283050f, 0.777220155576129220f, + 0.776866787931812410f, 0.776513391724324210f, 0.776159966966658680f, + 0.775806513671809860f, 0.775453031852772920f, 0.775099521522545020f, + 0.774745982694123090f, 0.774392415380506400f, 0.774038819594694230f, + 0.773685195349686940f, 0.773331542658487140f, 0.772977861534096640f, + 0.772624151989520280f, 0.772270414037761980f, 0.771916647691828660f, + 0.771562852964726710f, 0.771209029869463940f, 0.770855178419050050f, + 0.770501298626494410f, 0.770147390504808960f, 0.769793454067005500f, + 0.769439489326096850f, 0.769085496295098040f, 0.768731474987023660f, + 0.768377425414890850f, 0.768023347591716640f, 0.767669241530518850f, + 0.767315107244318060f, 0.766960944746133740f, 0.766606754048988260f, + 0.766252535165903970f, 0.765898288109903900f, 0.765544012894013530f, + 0.765189709531257760f, 0.764835378034664170f, 0.764481018417259680f, + 0.764126630692073870f, 0.763772214872136200f, 0.763417770970477140f, + 0.763063299000129260f, 0.762708798974124800f, 0.762354270905498450f, + 0.761999714807284790f, 0.761645130692519490f, 0.761290518574240350f, + 0.760935878465484720f, 0.760581210379292380f, 0.760226514328703140f, + 0.759871790326757670f, 0.759517038386499090f, 0.759162258520969860f, + 0.758807450743214760f, 0.758452615066278920f, 0.758097751503208020f, + 0.757742860067050380f, 0.757387940770853360f, 0.757032993627667290f, + 0.756678018650541630f, 0.756323015852528700f, 0.755967985246680520f, + 0.755612926846050080f, 0.755257840663692730f, 0.754902726712663120f, + 0.754547585006018600f, 0.754192415556816380f, 0.753837218378114460f, + 0.753481993482973400f, 0.753126740884452970f, 0.752771460595615500f, + 0.752416152629523330f, 0.752060816999239660f, 0.751705453717829930f, + 0.751350062798359140f, 0.750994644253894730f, 0.750639198097504010f, + 0.750283724342255320f, 0.749928223001219310f, 0.749572694087465850f, + 0.749217137614067500f, 0.748861553594096340f, 0.748505942040627040f, + 0.748150302966733790f, 0.747794636385492150f, 0.747438942309979870f, + 0.747083220753273820f, 0.746727471728453770f, 0.746371695248599140f, + 0.746015891326790470f, 0.745660059976110400f, 0.745304201209641030f, + 0.744948315040467210f, 0.744592401481673270f, 0.744236460546344850f, + 0.743880492247569580f, 0.743524496598434670f, 0.743168473612029980f, + 0.742812423301444810f, 0.742456345679769810f, 0.742100240760097840f, + 0.741744108555520860f, 0.741387949079133860f, 0.741031762344030790f, + 0.740675548363308620f, 0.740319307150063780f, 0.739963038717393880f, + 0.739606743078398690f, 0.739250420246177380f, 0.738894070233831800f, + 0.738537693054463370f, 0.738181288721174830f, 0.737824857247070810f, + 0.737468398645255490f, 0.737111912928835710f, 0.736755400110918000f, + 0.736398860204609870f, 0.736042293223021060f, 0.735685699179260850f, + 0.735329078086440880f, 0.734972429957672760f, 0.734615754806068890f, + 0.734259052644744230f, 0.733902323486812610f, 0.733545567345390890f, + 0.733188784233595240f, 0.732831974164544150f, 0.732475137151356370f, + 0.732118273207151170f, 0.731761382345050280f, 0.731404464578174760f, + 0.731047519919648340f, 0.730690548382594280f, 0.730333549980137110f, + 0.729976524725403530f, 0.729619472631519270f, 0.729262393711613280f, + 0.728905287978813600f, 0.728548155446249730f, 0.728190996127053180f, + 0.727833810034354990f, 0.727476597181288540f, 0.727119357580987220f, + 0.726762091246585200f, 0.726404798191218950f, 0.726047478428024420f, + 0.725690131970139980f, 0.725332758830703360f, 0.724975359022855150f, + 0.724617932559735390f, 0.724260479454485130f, 0.723902999720247850f, + 0.723545493370166160f, 0.723187960417385530f, 0.722830400875050790f, + 0.722472814756308090f, 0.722115202074305680f, 0.721757562842191060f, + 0.721399897073114470f, 0.721042204780225960f, 0.720684485976676230f, + 0.720326740675618530f, 0.719968968890205230f, 0.719611170633591480f, + 0.719253345918932090f, 0.718895494759382860f, 0.718537617168101610f, + 0.718179713158245800f, 0.717821782742975370f, 0.717463825935449550f, + 0.717105842748830160f, 0.716747833196278770f, 0.716389797290958090f, + 0.716031735046032900f, 0.715673646474667140f, 0.715315531590027700f, + 0.714957390405280950f, 0.714599222933594240f, 0.714241029188137260f, + 0.713882809182079030f, 0.713524562928591010f, 0.713166290440844450f, + 0.712807991732011590f, 0.712449666815266890f, 0.712091315703784260f, + 0.711732938410739810f, 0.711374534949309800f, 0.711016105332671340f, + 0.710657649574003460f, 0.710299167686484930f, 0.709940659683296890f, + 0.709582125577619790f, 0.709223565382636760f, 0.708864979111530680f, + 0.708506366777485130f, 0.708147728393686340f, 0.707789063973319310f, + 0.707430373529572170f, 0.707071657075632460f, 0.706712914624688770f, + 0.706354146189931750f, 0.705995351784551530f, 0.705636531421740880f, + 0.705277685114692020f, 0.704918812876598410f, 0.704559914720655490f, + 0.704200990660058150f, 0.703842040708003820f, 0.703483064877689630f, + 0.703124063182313690f, 0.702765035635076310f, 0.702405982249177160f, + 0.702046903037818250f, 0.701687798014201110f, 0.701328667191529980f, + 0.700969510583008600f, 0.700610328201841660f, 0.700251120061236020f, + 0.699891886174398130f, 0.699532626554536630f, 0.699173341214860190f, + 0.698814030168578240f, 0.698454693428902320f, 0.698095331009043640f, + 0.697735942922215520f, 0.697376529181631400f, 0.697017089800505250f, + 0.696657624792053730f, 0.696298134169492380f, 0.695938617946039510f, + 0.695579076134912990f, 0.695219508749331800f, 0.694859915802517050f, + 0.694500297307689140f, 0.694140653278070950f, 0.693780983726884790f, + 0.693421288667355530f, 0.693061568112707690f, 0.692701822076166820f, + 0.692342050570960430f, 0.691982253610315510f, 0.691622431207461700f, + 0.691262583375628180f, 0.690902710128045050f, 0.690542811477944610f, + 0.690182887438558710f, 0.689822938023121220f, 0.689462963244866330f, + 0.689102963117028790f, 0.688742937652845550f, 0.688382886865552930f, + 0.688022810768389670f, 0.687662709374594510f, 0.687302582697406850f, + 0.686942430750068330f, 0.686582253545819920f, 0.686222051097905130f, + 0.685861823419566700f, 0.685501570524050140f, 0.685141292424600310f, + 0.684780989134463280f, 0.684420660666887120f, 0.684060307035119440f, + 0.683699928252410110f, 0.683339524332008840f, 0.682979095287166160f, + 0.682618641131135020f, 0.682258161877167370f, 0.681897657538517720f, + 0.681537128128440470f, 0.681176573660190910f, 0.680815994147026320f, + 0.680455389602203310f, 0.680094760038981280f, 0.679734105470619080f, + 0.679373425910376310f, 0.679012721371515250f, 0.678651991867297080f, + 0.678291237410985510f, 0.677930458015843620f, 0.677569653695137220f, + 0.677208824462131490f, 0.676847970330092700f, 0.676487091312289350f, + 0.676126187421989040f, 0.675765258672461950f, 0.675404305076978020f, + 0.675043326648808170f, 0.674682323401225250f, 0.674321295347501510f, + 0.673960242500911690f, 0.673599164874730370f, 0.673238062482232950f, + 0.672876935336696900f, 0.672515783451398950f, 0.672154606839618470f, + 0.671793405514634180f, 0.671432179489727110f, 0.671070928778178090f, + 0.670709653393269050f, 0.670348353348283690f, 0.669987028656505170f, + 0.669625679331219300f, 0.669264305385711360f, 0.668902906833267590f, + 0.668541483687176590f, 0.668180035960725840f, 0.667818563667205600f, + 0.667457066819905800f, 0.667095545432117240f, 0.666733999517132860f, + 0.666372429088244790f, 0.666010834158747840f, 0.665649214741936390f, + 0.665287570851105680f, 0.664925902499553190f, 0.664564209700575500f, + 0.664202492467472090f, 0.663840750813541210f, 0.663478984752084110f, + 0.663117194296401260f, 0.662755379459794350f, 0.662393540255567070f, + 0.662031676697022450f, 0.661669788797465960f, 0.661307876570202740f, + 0.660945940028538900f, 0.660583979185782600f, 0.660221994055241400f, + 0.659859984650225110f, 0.659497950984043510f, 0.659135893070007080f, + 0.658773810921428500f, 0.658411704551619570f, 0.658049573973894850f, + 0.657687419201568260f, 0.657325240247955020f, 0.656963037126372160f, + 0.656600809850135910f, 0.656238558432565400f, 0.655876282886978410f, + 0.655513983226695960f, 0.655151659465038060f, 0.654789311615326050f, + 0.654426939690883280f, 0.654064543705032310f, 0.653702123671098150f, + 0.653339679602405470f, 0.652977211512280050f, 0.652614719414049580f, + 0.652252203321041060f, 0.651889663246583930f, 0.651527099204007310f, + 0.651164511206641320f, 0.650801899267818060f, 0.650439263400868990f, + 0.650076603619127890f, 0.649713919935928420f, 0.649351212364604910f, + 0.648988480918494040f, 0.648625725610931460f, 0.648262946455255510f, + 0.647900143464803730f, 0.647537316652916140f, 0.647174466032932490f, + 0.646811591618193350f, 0.646448693422041360f, 0.646085771457818310f, + 0.645722825738868860f, 0.645359856278536980f, 0.644996863090167570f, + 0.644633846187107620f, 0.644270805582703550f, 0.643907741290304040f, + 0.643544653323257610f, 0.643181541694913480f, 0.642818406418622980f, + 0.642455247507736860f, 0.642092064975608220f, 0.641728858835589830f, + 0.641365629101035340f, 0.641002375785300500f, 0.640639098901740200f, + 0.640275798463712080f, 0.639912474484572560f, 0.639549126977681070f, + 0.639185755956396480f, 0.638822361434078330f, 0.638458943424088490f, + 0.638095501939787920f, 0.637732036994540290f, 0.637368548601708660f, + 0.637005036774657030f, 0.636641501526751590f, 0.636277942871357530f, + 0.635914360821842830f, 0.635550755391574910f, 0.635187126593922070f, + 0.634823474442254840f, 0.634459798949942640f, 0.634096100130357660f, + 0.633732377996871770f, 0.633368632562857470f, 0.633004863841689520f, + 0.632641071846741790f, 0.632277256591390780f, 0.631913418089012020f, + 0.631549556352983710f, 0.631185671396683470f, 0.630821763233490040f, + 0.630457831876783950f, 0.630093877339945260f, 0.629729899636356280f, + 0.629365898779399080f, 0.629001874782456500f, 0.628637827658913300f, + 0.628273757422153860f, 0.627909664085564810f, 0.627545547662532230f, + 0.627181408166443410f, 0.626817245610687520f, 0.626453060008652860f, + 0.626088851373730380f, 0.625724619719310480f, 0.625360365058784670f, + 0.624996087405546350f, 0.624631786772988030f, 0.624267463174504880f, + 0.623903116623491180f, 0.623538747133343780f, 0.623174354717459190f, + 0.622809939389234460f, 0.622445501162069090f, 0.622081040049361490f, + 0.621716556064512820f, 0.621352049220923570f, 0.620987519531995270f, + 0.620622967011131400f, 0.620258391671734690f, 0.619893793527210410f, + 0.619529172590963410f, 0.619164528876399280f, 0.618799862396925750f, + 0.618435173165949760f, 0.618070461196880800f, 0.617705726503127720f, + 0.617340969098100430f, 0.616976188995210780f, 0.616611386207870040f, + 0.616246560749491690f, 0.615881712633488340f, 0.615516841873275490f, + 0.615151948482267840f, 0.614787032473881110f, 0.614422093861533010f, + 0.614057132658640590f, 0.613692148878623000f, 0.613327142534899510f, + 0.612962113640889710f, 0.612597062210015750f, 0.612231988255698470f, + 0.611866891791361560f, 0.611501772830428060f, 0.611136631386322020f, + 0.610771467472469460f, 0.610406281102295440f, 0.610041072289227990f, + 0.609675841046694030f, 0.609310587388121830f, 0.608945311326941520f, + 0.608580012876582370f, 0.608214692050476290f, 0.607849348862054220f, + 0.607483983324749510f, 0.607118595451995420f, 0.606753185257225550f, + 0.606387752753876020f, 0.606022297955381760f, 0.605656820875180360f, + 0.605291321526709060f, 0.604925799923405670f, 0.604560256078710220f, + 0.604194690006061960f, 0.603829101718902580f, 0.603463491230673220f, + 0.603097858554815790f, 0.602732203704774650f, 0.602366526693992930f, + 0.602000827535916330f, 0.601635106243990190f, 0.601269362831660550f, + 0.600903597312375640f, 0.600537809699582810f, 0.600172000006731770f, + 0.599806168247271620f, 0.599440314434653620f, 0.599074438582328780f, + 0.598708540703749010f, 0.598342620812368000f, 0.597976678921638860f, + 0.597610715045016950f, 0.597244729195957500f, 0.596878721387916090f, + 0.596512691634350830f, 0.596146639948718640f, 0.595780566344478960f, + 0.595414470835091030f, 0.595048353434014630f, 0.594682214154711790f, + 0.594316053010643270f, 0.593949870015273000f, 0.593583665182063740f, + 0.593217438524479500f, 0.592851190055986300f, 0.592484919790049140f, + 0.592118627740135460f, 0.591752313919712170f, 0.591385978342248260f, + 0.591019621021212420f, 0.590653241970074180f, 0.590286841202305120f, + 0.589920418731375800f, 0.589553974570759530f, 0.589187508733928890f, + 0.588821021234357310f, 0.588454512085520460f, 0.588087981300892900f, + 0.587721428893951850f, 0.587354854878173850f, 0.586988259267036350f, + 0.586621642074019120f, 0.586255003312600500f, 0.585888342996261690f, + 0.585521661138483250f, 0.585154957752746730f, 0.584788232852535560f, + 0.584421486451332410f, 0.584054718562622140f, 0.583687929199888990f, + 0.583321118376619710f, 0.582954286106300290f, 0.582587432402417840f, + 0.582220557278461340f, 0.581853660747918780f, 0.581486742824280810f, + 0.581119803521037650f, 0.580752842851679940f, 0.580385860829700780f, + 0.580018857468592270f, 0.579651832781848730f, 0.579284786782964360f, + 0.578917719485433800f, 0.578550630902754050f, 0.578183521048421080f, + 0.577816389935933090f, 0.577449237578788300f, 0.577082063990485340f, + 0.576714869184524860f, 0.576347653174406840f, 0.575980415973633590f, + 0.575613157595706530f, 0.575245878054129520f, 0.574878577362406000f, + 0.574511255534040030f, 0.574143912582537940f, 0.573776548521405030f, + 0.573409163364148930f, 0.573041757124277180f, 0.572674329815297640f, + 0.572306881450720390f, 0.571939412044054740f, 0.571571921608812320f, + 0.571204410158504090f, 0.570836877706642270f, 0.570469324266740570f, + 0.570101749852312100f, 0.569734154476872480f, 0.569366538153936560f, + 0.568998900897020210f, 0.568631242719641270f, 0.568263563635316600f, + 0.567895863657565500f, 0.567528142799906490f, 0.567160401075860410f, + 0.566792638498947680f, 0.566424855082689470f, 0.566057050840608870f, + 0.565689225786228160f, 0.565321379933072190f, 0.564953513294665140f, + 0.564585625884531870f, 0.564217717716199550f, 0.563849788803194140f, + 0.563481839159044150f, 0.563113868797277870f, 0.562745877731423820f, + 0.562377865975012940f, 0.562009833541575080f, 0.561641780444642640f, + 0.561273706697747450f, 0.560905612314422150f, 0.560537497308201240f, + 0.560169361692618440f, 0.559801205481210040f, 0.559433028687510990f, + 0.559064831325059240f, 0.558696613407391630f, 0.558328374948046320f, + 0.557960115960563050f, 0.557591836458480870f, 0.557223536455341280f, + 0.556855215964685120f, 0.556486875000054000f, 0.556118513574991650f, + 0.555750131703040880f, 0.555381729397746880f, 0.555013306672654360f, + 0.554644863541308600f, 0.554276400017257090f, 0.553907916114046440f, + 0.553539411845225590f, 0.553170887224342820f, 0.552802342264947400f, + 0.552433776980590490f, 0.552065191384822350f, 0.551696585491195710f, + 0.551327959313262280f, 0.550959312864576220f, 0.550590646158691240f, + 0.550221959209161620f, 0.549853252029543830f, 0.549484524633393480f, + 0.549115777034268170f, 0.548747009245725500f, 0.548378221281323520f, + 0.548009413154622370f, 0.547640584879181100f, 0.547271736468561530f, + 0.546902867936324590f, 0.546533979296032200f, 0.546165070561248080f, + 0.545796141745535150f, 0.545427192862458780f, 0.545058223925583670f, + 0.544689234948475210f, 0.544320225944701200f, 0.543951196927828010f, + 0.543582147911424560f, 0.543213078909059120f, 0.542843989934301940f, + 0.542474881000723050f, 0.542105752121893050f, 0.541736603311384620f, + 0.541367434582769480f, 0.540998245949621760f, 0.540629037425515050f, + 0.540259809024023600f, 0.539890560758723770f, 0.539521292643190930f, + 0.539152004691002770f, 0.538782696915736770f, 0.538413369330970610f, + 0.538044021950284450f, 0.537674654787257180f, 0.537305267855470390f, + 0.536935861168504670f, 0.536566434739941920f, 0.536196988583365510f, + 0.535827522712358230f, 0.535458037140505110f, 0.535088531881390050f, + 0.534719006948599860f, 0.534349462355720230f, 0.533979898116337950f, + 0.533610314244041710f, 0.533240710752419080f, 0.532871087655060300f, + 0.532501444965554960f, 0.532131782697493170f, 0.531762100864467290f, + 0.531392399480068670f, 0.531022678557890980f, 0.530652938111527360f, + 0.530283178154571710f, 0.529913398700619820f, 0.529543599763266700f, + 0.529173781356109600f, 0.528803943492745180f, 0.528434086186771010f, + 0.528064209451786560f, 0.527694313301390160f, 0.527324397749182720f, + 0.526954462808764120f, 0.526584508493736840f, 0.526214534817702310f, + 0.525844541794263210f, 0.525474529437023890f, 0.525104497759587900f, + 0.524734446775560910f, 0.524364376498548390f, 0.523994286942156220f, + 0.523624178119992400f, 0.523254050045663940f, 0.522883902732780290f, + 0.522513736194950230f, 0.522143550445783310f, 0.521773345498891090f, + 0.521403121367884030f, 0.521032878066375100f, 0.520662615607976660f, + 0.520292334006301820f, 0.519922033274965560f, 0.519551713427582000f, + 0.519181374477767470f, 0.518811016439137520f, 0.518440639325310040f, + 0.518070243149902240f, 0.517699827926532130f, 0.517329393668819580f, + 0.516958940390383700f, 0.516588468104845820f, 0.516217976825826600f, + 0.515847466566947580f, 0.515476937341832310f, 0.515106389164103120f, + 0.514735822047384990f, 0.514365236005302040f, 0.513994631051479240f, + 0.513624007199543600f, 0.513253364463121090f, 0.512882702855839920f, + 0.512512022391327980f, 0.512141323083213470f, 0.511770604945127050f, + 0.511399867990697920f, 0.511029112233557960f, 0.510658337687338040f, + 0.510287544365671140f, 0.509916732282189920f, 0.509545901450527690f, + 0.509175051884319660f, 0.508804183597200140f, 0.508433296602805670f, + 0.508062390914772230f, 0.507691466546736580f, 0.507320523512337470f, + 0.506949561825212450f, 0.506578581499001590f, 0.506207582547344550f, + 0.505836564983881190f, 0.505465528822253710f, 0.505094474076103310f, + 0.504723400759073290f, 0.504352308884806750f, 0.503981198466947000f, + 0.503610069519139780f, 0.503238922055029400f, 0.502867756088262840f, + 0.502496571632486070f, 0.502125368701347050f, 0.501754147308493770f, + 0.501382907467574190f, 0.501011649192238950f, 0.500640372496137020f, + 0.500269077392920150f, 0.499897763896239410f, 0.499526432019746450f, + 0.499155081777094940f, 0.498783713181937540f, 0.498412326247929250f, + 0.498040920988724490f, 0.497669497417978280f, 0.497298055549347750f, + 0.496926595396488870f, 0.496555116973059980f, 0.496183620292718900f, + 0.495812105369124070f, 0.495440572215935850f, 0.495069020846813650f, + 0.494697451275419140f, 0.494325863515413130f, 0.493954257580458580f, + 0.493582633484217940f, 0.493210991240354450f, 0.492839330862533120f, + 0.492467652364417970f, 0.492095955759675460f, 0.491724241061971320f, + 0.491352508284972070f, 0.490980757442346090f, 0.490608988547760690f, + 0.490237201614885710f, 0.489865396657390210f, 0.489493573688943970f, + 0.489121732723218740f, 0.488749873773885120f, 0.488377996854616250f, + 0.488006101979084450f, 0.487634189160962910f, 0.487262258413926560f, + 0.486890309751649490f, 0.486518343187807900f, 0.486146358736077200f, + 0.485774356410135000f, 0.485402336223658360f, 0.485030298190324950f, + 0.484658242323814380f, 0.484286168637805270f, 0.483914077145978560f, + 0.483541967862014480f, 0.483169840799594130f, 0.482797695972400300f, + 0.482425533394114920f, 0.482053353078422120f, 0.481681155039005550f, + 0.481308939289549380f, 0.480936705843739820f, 0.480564454715261990f, + 0.480192185917803270f, 0.479819899465050160f, 0.479447595370691370f, + 0.479075273648415010f, 0.478702934311909910f, 0.478330577374866780f, + 0.477958202850975230f, 0.477585810753927250f, 0.477213401097414220f, + 0.476840973895128200f, 0.476468529160763100f, 0.476096066908011760f, + 0.475723587150569390f, 0.475351089902130650f, 0.474978575176390750f, + 0.474606042987046840f, 0.474233493347795020f, 0.473860926272333670f, + 0.473488341774360670f, 0.473115739867574380f, 0.472743120565675250f, + 0.472370483882362520f, 0.471997829831337810f, 0.471625158426301700f, + 0.471252469680957190f, 0.470879763609006460f, 0.470507040224152460f, + 0.470134299540099940f, 0.469761541570552780f, 0.469388766329217000f, + 0.469015973829798090f, 0.468643164086002100f, 0.468270337111537040f, + 0.467897492920109850f, 0.467524631525429830f, 0.467151752941205530f, + 0.466778857181146260f, 0.466405944258963200f, 0.466033014188366350f, + 0.465660066983068220f, 0.465287102656780530f, 0.464914121223215740f, + 0.464541122696088100f, 0.464168107089110940f, 0.463795074415999760f, + 0.463422024690469060f, 0.463048957926235630f, 0.462675874137015720f, + 0.462302773336526080f, 0.461929655538485470f, 0.461556520756611410f, + 0.461183369004623920f, 0.460810200296242310f, 0.460437014645186440f, + 0.460063812065178160f, 0.459690592569938270f, 0.459317356173189750f, + 0.458944102888655060f, 0.458570832730057170f, 0.458197545711121090f, + 0.457824241845570630f, 0.457450921147131930f, 0.457077583629530550f, + 0.456704229306492570f, 0.456330858191746010f, 0.455957470299017840f, + 0.455584065642037350f, 0.455210644234532610f, 0.454837206090234200f, + 0.454463751222871910f, 0.454090279646176210f, 0.453716791373879380f, + 0.453343286419712720f, 0.452969764797409750f, 0.452596226520703360f, + 0.452222671603327130f, 0.451849100059016350f, 0.451475511901505420f, + 0.451101907144530910f, 0.450728285801828830f, 0.450354647887135640f, + 0.449980993414189900f, 0.449607322396728900f, 0.449233634848492320f, + 0.448859930783219170f, 0.448486210214649020f, 0.448112473156523420f, + 0.447738719622582710f, 0.447364949626569590f, 0.446991163182225700f, + 0.446617360303294910f, 0.446243541003520480f, 0.445869705296646270f, + 0.445495853196417930f, 0.445121984716580210f, 0.444748099870879880f, + 0.444374198673063330f, 0.444000281136877280f, 0.443626347276070590f, + 0.443252397104390790f, 0.442878430635587910f, 0.442504447883411090f, + 0.442130448861610240f, 0.441756433583937120f, 0.441382402064142250f, + 0.441008354315978680f, 0.440634290353198510f, 0.440260210189554690f, + 0.439886113838801880f, 0.439512001314693700f, 0.439137872630986080f, + 0.438763727801433690f, 0.438389566839793740f, 0.438015389759822630f, + 0.437641196575277220f, 0.437266987299916590f, 0.436892761947498260f, + 0.436518520531782470f, 0.436144263066528480f, 0.435769989565496290f, + 0.435395700042447710f, 0.435021394511143410f, 0.434647072985346380f, + 0.434272735478819010f, 0.433898382005324050f, 0.433524012578626440f, + 0.433149627212489670f, 0.432775225920679740f, 0.432400808716961900f, + 0.432026375615101930f, 0.431651926628867530f, 0.431277461772025310f, + 0.430902981058344070f, 0.430528484501591540f, 0.430153972115537800f, + 0.429779443913952170f, 0.429404899910604490f, 0.429030340119266550f, + 0.428655764553708960f, 0.428281173227704760f, 0.427906566155026040f, + 0.427531943349445720f, 0.427157304824738350f, 0.426782650594677570f, + 0.426407980673039090f, 0.426033295073598160f, 0.425658593810130330f, + 0.425283876896413280f, 0.424909144346223290f, 0.424534396173339160f, + 0.424159632391538870f, 0.423784853014600950f, 0.423410058056305830f, + 0.423035247530432810f, 0.422660421450763490f, 0.422285579831078230f, + 0.421910722685159720f, 0.421535850026790060f, 0.421160961869751720f, + 0.420786058227829220f, 0.420411139114805770f, 0.420036204544466940f, + 0.419661254530597550f, 0.419286289086983070f, 0.418911308227410740f, + 0.418536311965666650f, 0.418161300315539220f, 0.417786273290816130f, + 0.417411230905285650f, 0.417036173172737830f, 0.416661100106961610f, + 0.416286011721748230f, 0.415910908030888200f, 0.415535789048172620f, + 0.415160654787394280f, 0.414785505262345030f, 0.414410340486818910f, + 0.414035160474608700f, 0.413659965239509710f, 0.413284754795316230f, + 0.412909529155823300f, 0.412534288334827750f, 0.412159032346125280f, + 0.411783761203513790f, 0.411408474920790520f, 0.411033173511753220f, + 0.410657856990201580f, 0.410282525369933980f, 0.409907178664751180f, + 0.409531816888453190f, 0.409156440054840590f, 0.408781048177715660f, + 0.408405641270879690f, 0.408030219348136270f, 0.407654782423288010f, + 0.407279330510138260f, 0.406903863622492260f, 0.406528381774153900f, + 0.406152884978929480f, 0.405777373250624070f, 0.405401846603045010f, + 0.405026305049998980f, 0.404650748605293040f, 0.404275177282736260f, + 0.403899591096136380f, 0.403523990059303620f, 0.403148374186047210f, + 0.402772743490177110f, 0.402397097985504990f, 0.402021437685841480f, + 0.401645762604999350f, 0.401270072756790610f, 0.400894368155027990f, + 0.400518648813525830f, 0.400142914746097480f, 0.399767165966558420f, + 0.399391402488723400f, 0.399015624326407800f, 0.398639831493428740f, + 0.398264024003602220f, 0.397888201870746420f, 0.397512365108678430f, + 0.397136513731217500f, 0.396760647752182230f, 0.396384767185391620f, + 0.396008872044666730f, 0.395632962343827170f, 0.395257038096694990f, + 0.394881099317091370f, 0.394505146018838130f, 0.394129178215758820f, + 0.393753195921675850f, 0.393377199150413860f, 0.393001187915796750f, + 0.392625162231649010f, 0.392249122111796800f, 0.391873067570065240f, + 0.391496998620281590f, 0.391120915276272410f, 0.390744817551864850f, + 0.390368705460887750f, 0.389992579017168830f, 0.389616438234538010f, + 0.389240283126824070f, 0.388864113707858060f, 0.388487929991470140f, + 0.388111731991491180f, 0.387735519721753690f, 0.387359293196089140f, + 0.386983052428331030f, 0.386606797432312350f, 0.386230528221866430f, + 0.385854244810828530f, 0.385477947213032580f, 0.385101635442314900f, + 0.384725309512510880f, 0.384348969437456610f, 0.383972615230989860f, + 0.383596246906947210f, 0.383219864479167560f, 0.382843467961488940f, + 0.382467057367749940f, 0.382090632711791060f, 0.381714194007451380f, + 0.381337741268572390f, 0.380961274508994250f, 0.380584793742559550f, + 0.380208298983109930f, 0.379831790244487540f, 0.379455267540536490f, + 0.379078730885099520f, 0.378702180292021630f, 0.378325615775147170f, + 0.377949037348320800f, 0.377572445025389230f, 0.377195838820197690f, + 0.376819218746593910f, 0.376442584818424570f, 0.376065937049537060f, + 0.375689275453780500f, 0.375312600045002780f, 0.374935910837054080f, + 0.374559207843783660f, 0.374182491079041500f, 0.373805760556679190f, + 0.373429016290547200f, 0.373052258294498230f, 0.372675486582383640f, + 0.372298701168057190f, 0.371921902065371730f, 0.371545089288180640f, + 0.371168262850339210f, 0.370791422765701320f, 0.370414569048123140f, + 0.370037701711460170f, 0.369660820769568240f, 0.369283926236305070f, + 0.368907018125527120f, 0.368530096451093140f, 0.368153161226860980f, + 0.367776212466689010f, 0.367399250184437480f, 0.367022274393965340f, + 0.366645285109133750f, 0.366268282343803150f, 0.365891266111834370f, + 0.365514236427090080f, 0.365137193303431750f, 0.364760136754723020f, + 0.364383066794826350f, 0.364005983437606320f, 0.363628886696926890f, + 0.363251776586652310f, 0.362874653120648700f, 0.362497516312780990f, + 0.362120366176916230f, 0.361743202726920790f, 0.361366025976661450f, + 0.360988835940006750f, 0.360611632630824020f, 0.360234416062982840f, + 0.359857186250351960f, 0.359479943206800550f, 0.359102686946199680f, + 0.358725417482419150f, 0.358348134829330870f, 0.357970839000806010f, + 0.357593530010716310f, 0.357216207872935120f, 0.356838872601334680f, + 0.356461524209789380f, 0.356084162712172360f, 0.355706788122359060f, + 0.355329400454223950f, 0.354951999721642100f, 0.354574585938490280f, + 0.354197159118644080f, 0.353819719275981330f, 0.353442266424378930f, + 0.353064800577714280f, 0.352687321749866610f, 0.352309829954713830f, + 0.351932325206136210f, 0.351554807518012990f, 0.351177276904224070f, + 0.350799733378650890f, 0.350422176955173910f, 0.350044607647675640f, + 0.349667025470037810f, 0.349289430436142520f, 0.348911822559873850f, + 0.348534201855114360f, 0.348156568335749040f, 0.347778922015661520f, + 0.347401262908737570f, 0.347023591028862320f, 0.346645906389921150f, + 0.346268209005801410f, 0.345890498890388980f, 0.345512776057572080f, + 0.345135040521238170f, 0.344757292295274910f, 0.344379531393571970f, + 0.344001757830017680f, 0.343623971618502560f, 0.343246172772916250f, + 0.342868361307148980f, 0.342490537235092600f, 0.342112700570637750f, + 0.341734851327677280f, 0.341356989520103240f, 0.340979115161808070f, + 0.340601228266685980f, 0.340223328848629880f, 0.339845416921535030f, + 0.339467492499295200f, 0.339089555595806560f, 0.338711606224964210f, + 0.338333644400663940f, 0.337955670136803170f, 0.337577683447278010f, + 0.337199684345986910f, 0.336821672846827290f, 0.336443648963697160f, + 0.336065612710496290f, 0.335687564101123050f, 0.335309503149478110f, + 0.334931429869461230f, 0.334553344274972690f, 0.334175246379914470f, + 0.333797136198187240f, 0.333419013743693980f, 0.333040879030336690f, + 0.332662732072017800f, 0.332284572882641680f, 0.331906401476111280f, + 0.331528217866331690f, 0.331150022067206780f, 0.330771814092642610f, + 0.330393593956544440f, 0.330015361672817750f, 0.329637117255370090f, + 0.329258860718107450f, 0.328880592074938190f, 0.328502311339769700f, + 0.328124018526509800f, 0.327745713649068180f, 0.327367396721353070f, + 0.326989067757275040f, 0.326610726770743760f, 0.326232373775669270f, + 0.325854008785963320f, 0.325475631815536570f, 0.325097242878301660f, + 0.324718841988170470f, 0.324340429159055250f, 0.323962004404870050f, + 0.323583567739527570f, 0.323205119176942720f, 0.322826658731029110f, + 0.322448186415702550f, 0.322069702244877910f, 0.321691206232470550f, + 0.321312698392397570f, 0.320934178738574720f, 0.320555647284919980f, + 0.320177104045350440f, 0.319798549033783570f, 0.319419982264138650f, + 0.319041403750333630f, 0.318662813506288670f, 0.318284211545923010f, + 0.317905597883156250f, 0.317526972531909870f, 0.317148335506103940f, + 0.316769686819660780f, 0.316391026486501690f, 0.316012354520548600f, + 0.315633670935725030f, 0.315254975745953180f, 0.314876268965157470f, + 0.314497550607261090f, 0.314118820686189180f, 0.313740079215866160f, + 0.313361326210216840f, 0.312982561683167790f, 0.312603785648644220f, + 0.312224998120573420f, 0.311846199112882030f, 0.311467388639496860f, + 0.311088566714346650f, 0.310709733351358600f, 0.310330888564462340f, + 0.309952032367586390f, 0.309573164774659850f, 0.309194285799613390f, + 0.308815395456376430f, 0.308436493758880660f, 0.308057580721056660f, + 0.307678656356835560f, 0.307299720680150270f, 0.306920773704932260f, + 0.306541815445115160f, 0.306162845914631390f, 0.305783865127415400f, + 0.305404873097400780f, 0.305025869838521590f, 0.304646855364713530f, + 0.304267829689911010f, 0.303888792828050650f, 0.303509744793068030f, + 0.303130685598899270f, 0.302751615259482190f, 0.302372533788753170f, + 0.301993441200650910f, 0.301614337509113100f, 0.301235222728077840f, + 0.300856096871485010f, 0.300476959953273060f, 0.300097811987382670f, + 0.299718652987753580f, 0.299339482968325970f, 0.298960301943041680f, + 0.298581109925841300f, 0.298201906930667390f, 0.297822692971461410f, + 0.297443468062166820f, 0.297064232216726120f, 0.296684985449082390f, + 0.296305727773180260f, 0.295926459202963120f, 0.295547179752376430f, + 0.295167889435364820f, 0.294788588265873170f, 0.294409276257848300f, + 0.294029953425235520f, 0.293650619781982260f, 0.293271275342035120f, + 0.292891920119341120f, 0.292512554127848930f, 0.292133177381505850f, + 0.291753789894261320f, 0.291374391680063520f, 0.290994982752862730f, + 0.290615563126608250f, 0.290236132815249790f, 0.289856691832738880f, + 0.289477240193025510f, 0.289097777910061970f, 0.288718304997799550f, + 0.288338821470189910f, 0.287959327341186510f, 0.287579822624741350f, + 0.287200307334808670f, 0.286820781485341620f, 0.286441245090293950f, + 0.286061698163620930f, 0.285682140719276560f, 0.285302572771216960f, + 0.284922994333397350f, 0.284543405419773240f, 0.284163806044301910f, + 0.283784196220939370f, 0.283404575963643550f, 0.283024945286371230f, + 0.282645304203081090f, 0.282265652727731130f, 0.281885990874279570f, + 0.281506318656686290f, 0.281126636088910030f, 0.280746943184911340f, + 0.280367239958650150f, 0.279987526424086530f, 0.279607802595182420f, + 0.279228068485898210f, 0.278848324110196550f, 0.278468569482039130f, + 0.278088804615388040f, 0.277709029524206950f, 0.277329244222458250f, + 0.276949448724106480f, 0.276569643043115150f, 0.276189827193448200f, + 0.275810001189071290f, 0.275430165043948570f, 0.275050318772046500f, + 0.274670462387330010f, 0.274290595903766200f, 0.273910719335321300f, + 0.273530832695961790f, 0.273150935999655950f, 0.272771029260370560f, + 0.272391112492074590f, 0.272011185708736060f, 0.271631248924323390f, + 0.271251302152806570f, 0.270871345408154380f, 0.270491378704337540f, + 0.270111402055325910f, 0.269731415475089780f, 0.269351418977600950f, + 0.268971412576829990f, 0.268591396286749500f, 0.268211370121331170f, + 0.267831334094547010f, 0.267451288220370730f, 0.267071232512774700f, + 0.266691166985733360f, 0.266311091653219700f, 0.265931006529208920f, + 0.265550911627675250f, 0.265170806962593210f, 0.264790692547939020f, + 0.264410568397687560f, 0.264030434525815760f, 0.263650290946299660f, + 0.263270137673115630f, 0.262889974720241610f, 0.262509802101654310f, + 0.262129619831332370f, 0.261749427923253670f, 0.261369226391396310f, + 0.260989015249740050f, 0.260608794512263380f, 0.260228564192946710f, + 0.259848324305769600f, 0.259468074864711960f, 0.259087815883755400f, + 0.258707547376880010f, 0.258327269358068100f, 0.257946981841300490f, + 0.257566684840560170f, 0.257186378369829110f, 0.256806062443089680f, + 0.256425737074325920f, 0.256045402277520320f, 0.255665058066657680f, + 0.255284704455721660f, 0.254904341458696390f, 0.254523969089567590f, + 0.254143587362319620f, 0.253763196290938850f, 0.253382795889410710f, + 0.253002386171721110f, 0.252621967151857420f, 0.252241538843805680f, + 0.251861101261554090f, 0.251480654419089730f, 0.251100198330400150f, + 0.250719733009474530f, 0.250339258470300590f, 0.249958774726868170f, + 0.249578281793165680f, 0.249197779683183660f, 0.248817268410911650f, + 0.248436747990339490f, 0.248056218435458720f, 0.247675679760259450f, + 0.247295131978733870f, 0.246914575104873220f, 0.246534009152669040f, + 0.246153434136114490f, 0.245772850069201410f, 0.245392256965923620f, + 0.245011654840274010f, 0.244631043706245800f, 0.244250423577833860f, + 0.243869794469031620f, 0.243489156393834590f, 0.243108509366237320f, + 0.242727853400234670f, 0.242347188509823150f, 0.241966514708997830f, + 0.241585832011755900f, 0.241205140432093070f, 0.240824439984007180f, + 0.240443730681495050f, 0.240063012538553830f, 0.239682285569182310f, + 0.239301549787377890f, 0.238920805207139960f, 0.238540051842467020f, + 0.238159289707357810f, 0.237778518815812740f, 0.237397739181830820f, + 0.237016950819413100f, 0.236636153742559610f, 0.236255347965270780f, + 0.235874533501548580f, 0.235493710365393630f, 0.235112878570808560f, + 0.234732038131795020f, 0.234351189062355030f, 0.233970331376492150f, + 0.233589465088208580f, 0.233208590211508550f, 0.232827706760394850f, + 0.232446814748872410f, 0.232065914190945020f, 0.231685005100616930f, + 0.231304087491893930f, 0.230923161378780380f, 0.230542226775282770f, + 0.230161283695406500f, 0.229780332153157300f, 0.229399372162542610f, + 0.229018403737568290f, 0.228637426892242400f, 0.228256441640571880f, + 0.227875447996564060f, 0.227494445974227850f, 0.227113435587570770f, + 0.226732416850602300f, 0.226351389777330990f, 0.225970354381765690f, + 0.225589310677916880f, 0.225208258679793520f, 0.224827198401406690f, + 0.224446129856766040f, 0.224065053059883250f, 0.223683968024768950f, + 0.223302874765434120f, 0.222921773295891380f, 0.222540663630151820f, + 0.222159545782228660f, 0.221778419766134050f, 0.221397285595880480f, + 0.221016143285482050f, 0.220634992848951380f, 0.220253834300303180f, + 0.219872667653551100f, 0.219491492922709110f, 0.219110310121792800f, + 0.218729119264816280f, 0.218347920365795780f, 0.217966713438746380f, + 0.217585498497683580f, 0.217204275556624420f, 0.216823044629584520f, + 0.216441805730581500f, 0.216060558873631570f, 0.215679304072752960f, + 0.215298041341962870f, 0.214916770695278810f, 0.214535492146719880f, + 0.214154205710303750f, 0.213772911400050090f, 0.213391609229977570f, + 0.213010299214105140f, 0.212628981366453330f, 0.212247655701041290f, + 0.211866322231890090f, 0.211484980973019880f, 0.211103631938451000f, + 0.210722275142205480f, 0.210340910598303870f, 0.209959538320768660f, + 0.209578158323621420f, 0.209196770620883960f, 0.208815375226579670f, + 0.208433972154730530f, 0.208052561419360520f, 0.207671143034492080f, + 0.207289717014149830f, 0.206908283372357230f, 0.206526842123138070f, + 0.206145393280517730f, 0.205763936858520150f, 0.205382472871171230f, + 0.205001001332495910f, 0.204619522256519300f, 0.204238035657268250f, + 0.203856541548768030f, 0.203475039945045950f, 0.203093530860128300f, + 0.202712014308041620f, 0.202330490302814110f, 0.201948958858472420f, + 0.201567419989045200f, 0.201185873708560170f, 0.200804320031045230f, + 0.200422758970529910f, 0.200041190541042220f, 0.199659614756612230f, + 0.199278031631268500f, 0.198896441179041650f, 0.198514843413961220f, + 0.198133238350057030f, 0.197751626001360480f, 0.197370006381901520f, + 0.196988379505712050f, 0.196606745386822960f, 0.196225104039265410f, + 0.195843455477072190f, 0.195461799714274460f, 0.195080136764905570f, + 0.194698466642997730f, 0.194316789362583340f, 0.193935104937696560f, + 0.193553413382369890f, 0.193171714710637930f, 0.192790008936534220f, + 0.192408296074092570f, 0.192026576137348330f, 0.191644849140335360f, + 0.191263115097089540f, 0.190881374021645320f, 0.190499625928039040f, + 0.190117870830306100f, 0.189736108742482030f, 0.189354339678604100f, + 0.188972563652707950f, 0.188590780678831250f, 0.188208990771010640f, + 0.187827193943283040f, 0.187445390209686870f, 0.187063579584259070f, + 0.186681762081038650f, 0.186299937714063470f, 0.185918106497371700f, + 0.185536268445003070f, 0.185154423570995760f, 0.184772571889390000f, + 0.184390713414225000f, 0.184008848159540110f, 0.183626976139376310f, + 0.183245097367773090f, 0.182863211858771880f, 0.182481319626412670f, + 0.182099420684737420f, 0.181717515047787020f, 0.181335602729602590f, + 0.180953683744226880f, 0.180571758105701030f, 0.180189825828068250f, + 0.179807886925370670f, 0.179425941411650660f, 0.179043989300952110f, + 0.178662030607317450f, 0.178280065344791100f, 0.177898093527416370f, + 0.177516115169236820f, 0.177134130284297610f, 0.176752138886642350f, + 0.176370140990316640f, 0.175988136609365020f, 0.175606125757832240f, + 0.175224108449764660f, 0.174842084699207030f, 0.174460054520206240f, + 0.174078017926807490f, 0.173695974933058080f, 0.173313925553004180f, + 0.172931869800692250f, 0.172549807690170230f, 0.172167739235484620f, + 0.171785664450683800f, 0.171403583349815180f, 0.171021495946926340f, + 0.170639402256066410f, 0.170257302291283000f, 0.169875196066625710f, + 0.169493083596143100f, 0.169110964893883830f, 0.168728839973898290f, + 0.168346708850235140f, 0.167964571536945220f, 0.167582428048078130f, + 0.167200278397683750f, 0.166818122599813570f, 0.166435960668517400f, + 0.166053792617847200f, 0.165671618461853270f, 0.165289438214587970f, + 0.164907251890102520f, 0.164525059502448390f, 0.164142861065678550f, + 0.163760656593844480f, 0.163378446100999640f, 0.162996229601196390f, + 0.162614007108487250f, 0.162231778636926370f, 0.161849544200566300f, + 0.161467303813461580f, 0.161085057489665670f, 0.160702805243232240f, + 0.160320547088216470f, 0.159938283038672050f, 0.159556013108654580f, + 0.159173737312218650f, 0.158791455663418930f, 0.158409168176311760f, + 0.158026874864951870f, 0.157644575743395960f, 0.157262270825699210f, + 0.156879960125918730f, 0.156497643658110590f, 0.156115321436331000f, + 0.155732993474637760f, 0.155350659787087090f, 0.154968320387737170f, + 0.154585975290645110f, 0.154203624509868190f, 0.153821268059465250f, + 0.153438905953493550f, 0.153056538206012340f, 0.152674164831079730f, + 0.152291785842754070f, 0.151909401255095250f, 0.151527011082161540f, + 0.151144615338013210f, 0.150762214036709470f, 0.150379807192309620f, + 0.149997394818874590f, 0.149614976930463660f, 0.149232553541138180f, + 0.148850124664957870f, 0.148467690315984390f, 0.148085250508278370f, + 0.147702805255900570f, 0.147320354572913260f, 0.146937898473377210f, + 0.146555436971355090f, 0.146172970080908520f, 0.145790497816099230f, + 0.145408020190990560f, 0.145025537219644170f, 0.144643048916123810f, + 0.144260555294492000f, 0.143878056368811510f, 0.143495552153146630f, + 0.143113042661560050f, 0.142730527908116440f, 0.142348007906879320f, + 0.141965482671912420f, 0.141582952217280980f, 0.141200416557048680f, + 0.140817875705281120f, 0.140435329676042390f, 0.140052778483398480f, + 0.139670222141414250f, 0.139287660664154770f, 0.138905094065686600f, + 0.138522522360074780f, 0.138139945561386200f, 0.137757363683686740f, + 0.137374776741042340f, 0.136992184747520560f, 0.136609587717187310f, + 0.136226985664110460f, 0.135844378602356760f, 0.135461766545993150f, + 0.135079149509088060f, 0.134696527505708320f, 0.134313900549922760f, + 0.133931268655799020f, 0.133548631837404950f, 0.133165990108809860f, + 0.132783343484081580f, 0.132400691977289760f, 0.132018035602502530f, + 0.131635374373789940f, 0.131252708305220960f, 0.130870037410864640f, + 0.130487361704791580f, 0.130104681201070800f, 0.129721995913773260f, + 0.129339305856968730f, 0.128956611044727220f, 0.128573911491120210f, + 0.128191207210217570f, 0.127808498216091110f, 0.127425784522811530f, + 0.127043066144449680f, 0.126660343095077900f, 0.126277615388766920f, + 0.125894883039589430f, 0.125512146061616980f, 0.125129404468921260f, + 0.124746658275575490f, 0.124363907495651240f, 0.123981152143222060f, + 0.123598392232359880f, 0.123215627777138580f, 0.122832858791630880f, + 0.122450085289909640f, 0.122067307286049230f, 0.121684524794122440f, + 0.121301737828203960f, 0.120918946402367330f, 0.120536150530686250f, + 0.120153350227235940f, 0.119770545506089950f, 0.119387736381323830f, + 0.119004922867011920f, 0.118622104977228730f, 0.118239282726050290f, + 0.117856456127550970f, 0.117473625195807100f, 0.117090789944893860f, + 0.116707950388886520f, 0.116325106541861910f, 0.115942258417895240f, + 0.115559406031063570f, 0.115176549395442460f, 0.114793688525109290f, + 0.114410823434140360f, 0.114027954136612060f, 0.113645080646602280f, + 0.113262202978187320f, 0.112879321145445350f, 0.112496435162453430f, + 0.112113545043288730f, 0.111730650802029900f, 0.111347752452754000f, + 0.110964850009539970f, 0.110581943486465610f, 0.110199032897608850f, + 0.109816118257049110f, 0.109433199578864170f, 0.109050276877133770f, + 0.108667350165936400f, 0.108284419459350770f, 0.107901484771457020f, + 0.107518546116333660f, 0.107135603508061170f, 0.106752656960718350f, + 0.106369706488385940f, 0.105986752105143480f, 0.105603793825070680f, + 0.105220831662248700f, 0.104837865630757090f, 0.104454895744677270f, + 0.104071922018089540f, 0.103688944465074300f, 0.103305963099713400f, + 0.102922977936087120f, 0.102539988988277600f, 0.102156996270365800f, + 0.101773999796432830f, 0.101390999580561250f, 0.101007995636832020f, + 0.100624987979327970f, 0.100241976622130760f, 0.099858961579322170f, + 0.099475942864985456f, 0.099092920493202258f, 0.098709894478056073f, + 0.098326864833628791f, 0.097943831574004214f, 0.097560794713264939f, + 0.097177754265493674f, 0.096794710244774623f, 0.096411662665190329f, + 0.096028611540825232f, 0.095645556885762609f, 0.095262498714085819f, + 0.094879437039879722f, 0.094496371877227495f, 0.094113303240214247f, + 0.093730231142923864f, 0.093347155599440373f, 0.092964076623849271f, + 0.092580994230234359f, 0.092197908432681386f, 0.091814819245274432f, + 0.091431726682099479f, 0.091048630757241303f, 0.090665531484784803f, + 0.090282428878816323f, 0.089899322953420582f, 0.089516213722684160f, + 0.089133101200692441f, 0.088749985401530951f, 0.088366866339286629f, + 0.087983744028044805f, 0.087600618481892656f, 0.087217489714916191f, + 0.086834357741201490f, 0.086451222574836131f, 0.086068084229906014f, + 0.085684942720498897f, 0.085301798060701386f, 0.084918650264600160f, + 0.084535499346283349f, 0.084152345319837438f, 0.083769188199350780f, + 0.083386027998910095f, 0.083002864732603973f, 0.082619698414519799f, + 0.082236529058745025f, 0.081853356679368619f, 0.081470181290477811f, + 0.081087002906161790f, 0.080703821540508452f, 0.080320637207605849f, + 0.079937449921543474f, 0.079554259696409127f, 0.079171066546292510f, + 0.078787870485282088f, 0.078404671527466441f, 0.078021469686935602f, + 0.077638264977777913f, 0.077255057414083589f, 0.076871847009941652f, + 0.076488633779441206f, 0.076105417736672773f, 0.075722198895725248f, + 0.075338977270689375f, 0.074955752875654230f, 0.074572525724710764f, + 0.074189295831948693f, 0.073806063211457842f, 0.073422827877329483f, + 0.073039589843653177f, 0.072656349124520389f, 0.072273105734021334f, + 0.071889859686246352f, 0.071506610995287156f, 0.071123359675233852f, + 0.070740105740178361f, 0.070356849204211397f, 0.069973590081423773f, + 0.069590328385907715f, 0.069207064131753759f, 0.068823797333054326f, + 0.068440528003900616f, 0.068057256158383886f, 0.067673981810596848f, + 0.067290704974630494f, 0.066907425664577733f, 0.066524143894529736f, + 0.066140859678579578f, 0.065757573030819083f, 0.065374283965340146f, + 0.064990992496236119f, 0.064607698637598646f, 0.064224402403521202f, + 0.063841103808096086f, 0.063457802865415636f, 0.063074499589573618f, + 0.062691193994662109f, 0.062307886094775049f, 0.061924575904005130f, + 0.061541263436445129f, 0.061157948706189229f, 0.060774631727329942f, + 0.060391312513961619f, 0.060007991080177375f, 0.059624667440070382f, + 0.059241341607735261f, 0.058858013597264912f, 0.058474683422754095f, + 0.058091351098295878f, 0.057708016637985186f, 0.057324680055915692f, + 0.056941341366181127f, 0.056558000582876661f, 0.056174657720095743f, + 0.055791312791933681f, 0.055407965812484541f, 0.055024616795842439f, + 0.054641265756102911f, 0.054257912707359794f, 0.053874557663708772f, + 0.053491200639244271f, 0.053107841648060788f, 0.052724480704254229f, + 0.052341117821918783f, 0.051957753015150501f, 0.051574386298044173f, + 0.051191017684694640f, 0.050807647189198162f, 0.050424274825649297f, + 0.050040900608144430f, 0.049657524550778251f, 0.049274146667647289f, + 0.048890766972846805f, 0.048507385480472134f, 0.048124002204620014f, + 0.047740617159385448f, 0.047357230358865306f, 0.046973841817155179f, + 0.046590451548350717f, 0.046207059566548990f, 0.045823665885845313f, + 0.045440270520336883f, 0.045056873484119603f, 0.044673474791289434f, + 0.044290074455943754f, 0.043906672492178188f, 0.043523268914090238f, + 0.043139863735776100f, 0.042756456971332048f, 0.042373048634855741f, + 0.041989638740443119f, 0.041606227302191955f, 0.041222814334198304f, + 0.040839399850560058f, 0.040455983865373815f, 0.040072566392736257f, + 0.039689147446745419f, 0.039305727041497644f, 0.038922305191091085f, + 0.038538881909622631f, 0.038155457211189216f, 0.037772031109889144f, + 0.037388603619819022f, 0.037005174755077273f, 0.036621744529761024f, + 0.036238312957967478f, 0.035854880053795196f, 0.035471445831341021f, + 0.035088010304703626f, 0.034704573487980395f, 0.034321135395268765f, + 0.033937696040667535f, 0.033554255438273790f, 0.033170813602186440f, + 0.032787370546502645f, 0.032403926285321405f, 0.032020480832740429f, + 0.031637034202857461f, 0.031253586409771626f, 0.030870137467580314f, + 0.030486687390382738f, 0.030103236192276818f, 0.029719783887360508f, + 0.029336330489733147f, 0.028952876013492331f, 0.028569420472737472f, + 0.028185963881566689f, 0.027802506254078142f, 0.027419047604371360f, + 0.027035587946544135f, 0.026652127294696067f, 0.026268665662925468f, + 0.025885203065330677f, 0.025501739516011413f, 0.025118275029065638f, + 0.024734809618593138f, 0.024351343298691951f, 0.023967876083461924f, + 0.023584407987001611f, 0.023200939023409587f, 0.022817469206785804f, + 0.022433998551228459f, 0.022050527070837558f, 0.021667054779711814f, + 0.021283581691949955f, 0.020900107821652084f, 0.020516633182916549f, + 0.020133157789843505f, 0.019749681656531803f, 0.019366204797080316f, + 0.018982727225589285f, 0.018599248956157190f, 0.018215770002884327f, + 0.017832290379869671f, 0.017448810101212228f, 0.017065329181012358f, + 0.016681847633368677f, 0.016298365472381587f, 0.015914882712149747f, + 0.015531399366773606f, 0.015147915450352307f, 0.014764430976985016f, + 0.014380945960772247f, 0.013997460415812761f, 0.013613974356207112f, + 0.013230487796054543f, 0.012847000749454314f, 0.012463513230507034f, + 0.012080025253311559f, 0.011696536831968529f, 0.011313047980577277f, + 0.010929558713237145f, 0.010546069044048827f, 0.010162578987111254f, + 0.009779088556525145f, 0.009395597766389905f, 0.009012106630804949f, + 0.008628615163871038f, 0.008245123379687167f, 0.007861631292354124f, + 0.007478138915970929f, 0.007094646264638386f, 0.006711153352455981f, + 0.006327660193523208f, 0.005944166801940901f, 0.005560673191808128f, + 0.005177179377225743f, 0.004793685372293270f, 0.004410191191110246f, + 0.004026696847777542f, 0.003643202356394263f, 0.003259707731061291f, + 0.002876212985878184f, 0.002492718134944503f, 0.002109223192361147f, + 0.001725728172227238f, 0.001342233088643682f, 0.000958737955710053f, + 0.000575242787525925f, 0.000191747598192208f}; /** @} end of DCT4_IDCT4_Table group @@ -15937,45 +10987,46 @@ static const float32_t cos_factors_8192[8192] = { /** @brief Initialization function for the floating-point DCT4/IDCT4. - @param[in,out] S points to an instance of floating-point DCT4/IDCT4 structure - @param[in] S_RFFT points to an instance of floating-point RFFT/RIFFT structure - @param[in] S_CFFT points to an instance of floating-point CFFT/CIFFT structure + @param[in,out] S points to an instance of floating-point DCT4/IDCT4 + structure + @param[in] S_RFFT points to an instance of floating-point RFFT/RIFFT + structure + @param[in] S_CFFT points to an instance of floating-point CFFT/CIFFT + structure @param[in] N length of the DCT4 @param[in] Nby2 half of the length of the DCT4 @param[in] normalize normalizing factor. @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : N is not a supported transform length + - \ref ARM_MATH_ARGUMENT_ERROR : N is not a + supported transform length @par Normalizing factor - The normalizing factor is sqrt(2/N), which depends on the size of transform N. - Floating-point normalizing factors are mentioned in the table below for different DCT sizes: + The normalizing factor is sqrt(2/N), which + depends on the size of transform N. Floating-point normalizing + factors are mentioned in the table below for different DCT sizes: \image html dct4NormalizingF32Table.gif */ -arm_status arm_dct4_init_f32( - arm_dct4_instance_f32 * S, - arm_rfft_instance_f32 * S_RFFT, - arm_cfft_radix4_instance_f32 * S_CFFT, - uint16_t N, - uint16_t Nby2, - float32_t normalize) -{ +arm_status arm_dct4_init_f32(arm_dct4_instance_f32 *S, + arm_rfft_instance_f32 *S_RFFT, + arm_cfft_radix4_instance_f32 *S_CFFT, uint16_t N, + uint16_t Nby2, float32_t normalize) { /* Initialize the default arm status */ arm_status status = ARM_MATH_SUCCESS; - /* Initializing the pointer array with the weight table base addresses of different lengths */ - float32_t *twiddlePtr[4] = - { (float32_t *) Weights_128, (float32_t *) Weights_512, - (float32_t *) Weights_2048, (float32_t *) Weights_8192 - }; + /* Initializing the pointer array with the weight table base addresses of + * different lengths */ + float32_t *twiddlePtr[4] = { + (float32_t *)Weights_128, (float32_t *)Weights_512, + (float32_t *)Weights_2048, (float32_t *)Weights_8192}; - /* Initializing the pointer array with the cos factor table base addresses of different lengths */ - float32_t *pCosFactor[4] = - { (float32_t *) cos_factors_128, (float32_t *) cos_factors_512, - (float32_t *) cos_factors_2048, (float32_t *) cos_factors_8192 - }; + /* Initializing the pointer array with the cos factor table base addresses of + * different lengths */ + float32_t *pCosFactor[4] = { + (float32_t *)cos_factors_128, (float32_t *)cos_factors_512, + (float32_t *)cos_factors_2048, (float32_t *)cos_factors_8192}; /* Initialize the DCT4 length */ S->N = N; @@ -15992,8 +11043,7 @@ arm_status arm_dct4_init_f32( /* Initialize Complex FFT Instance */ S->pCfft = S_CFFT; - switch (N) - { + switch (N) { /* Initialize the table modifier values */ case 8192U: S->pTwiddle = twiddlePtr[3]; diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_init_q15.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_init_q15.c index 78f63d4..abddb33 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_init_q15.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_init_q15.c @@ -43,2760 +43,4393 @@ /** @par - Weights tables are generated using the formula :
weights[n] = e^(-j*n*pi/(2*N))
+ Weights tables are generated using the formula :
weights[n] =
+  e^(-j*n*pi/(2*N))
@par C command to generate the table
   for(i = 0; i< N; i++)
-  { 
+  {
     weights[(2*i)]   =  cos(i*c);
     weights[(2*i)+1] = -sin(i*c);
   } 
@par - where N is the Number of weights to be calculated and c is pi/(2*N) + where N is the Number of weights to be calculated and + c is pi/(2*N) @par - Converted the output to q15 format by multiplying with 2^31 and saturated if required. + Converted the output to q15 format by multiplying with 2^31 and saturated if + required. @par - In the tables below the real and imaginary values are placed alternatively, hence the - array length is 2*N. + In the tables below the real and imaginary values are placed alternatively, + hence the array length is 2*N. */ static const q15_t __ALIGNED(4) WeightsQ15_128[256] = { - (q15_t)0x7fff, (q15_t)0x0, (q15_t)0x7ffd, (q15_t)0xfe6e, (q15_t)0x7ff6, (q15_t)0xfcdc, (q15_t)0x7fe9, (q15_t)0xfb4a, - (q15_t)0x7fd8, (q15_t)0xf9b9, (q15_t)0x7fc2, (q15_t)0xf827, (q15_t)0x7fa7, (q15_t)0xf696, (q15_t)0x7f87, (q15_t)0xf505, - (q15_t)0x7f62, (q15_t)0xf375, (q15_t)0x7f38, (q15_t)0xf1e5, (q15_t)0x7f09, (q15_t)0xf055, (q15_t)0x7ed5, (q15_t)0xeec7, - (q15_t)0x7e9d, (q15_t)0xed38, (q15_t)0x7e5f, (q15_t)0xebab, (q15_t)0x7e1d, (q15_t)0xea1e, (q15_t)0x7dd6, (q15_t)0xe893, - (q15_t)0x7d8a, (q15_t)0xe708, (q15_t)0x7d39, (q15_t)0xe57e, (q15_t)0x7ce3, (q15_t)0xe3f5, (q15_t)0x7c89, (q15_t)0xe26d, - (q15_t)0x7c29, (q15_t)0xe0e7, (q15_t)0x7bc5, (q15_t)0xdf61, (q15_t)0x7b5d, (q15_t)0xdddd, (q15_t)0x7aef, (q15_t)0xdc5a, - (q15_t)0x7a7d, (q15_t)0xdad8, (q15_t)0x7a05, (q15_t)0xd958, (q15_t)0x798a, (q15_t)0xd7da, (q15_t)0x7909, (q15_t)0xd65d, - (q15_t)0x7884, (q15_t)0xd4e1, (q15_t)0x77fa, (q15_t)0xd368, (q15_t)0x776c, (q15_t)0xd1ef, (q15_t)0x76d9, (q15_t)0xd079, - (q15_t)0x7641, (q15_t)0xcf05, (q15_t)0x75a5, (q15_t)0xcd92, (q15_t)0x7504, (q15_t)0xcc22, (q15_t)0x745f, (q15_t)0xcab3, - (q15_t)0x73b5, (q15_t)0xc946, (q15_t)0x7307, (q15_t)0xc7dc, (q15_t)0x7255, (q15_t)0xc674, (q15_t)0x719e, (q15_t)0xc50e, - (q15_t)0x70e2, (q15_t)0xc3aa, (q15_t)0x7023, (q15_t)0xc248, (q15_t)0x6f5f, (q15_t)0xc0e9, (q15_t)0x6e96, (q15_t)0xbf8d, - (q15_t)0x6dca, (q15_t)0xbe32, (q15_t)0x6cf9, (q15_t)0xbcdb, (q15_t)0x6c24, (q15_t)0xbb86, (q15_t)0x6b4a, (q15_t)0xba33, - (q15_t)0x6a6d, (q15_t)0xb8e4, (q15_t)0x698c, (q15_t)0xb797, (q15_t)0x68a6, (q15_t)0xb64c, (q15_t)0x67bd, (q15_t)0xb505, - (q15_t)0x66cf, (q15_t)0xb3c1, (q15_t)0x65dd, (q15_t)0xb27f, (q15_t)0x64e8, (q15_t)0xb141, (q15_t)0x63ef, (q15_t)0xb005, - (q15_t)0x62f2, (q15_t)0xaecd, (q15_t)0x61f1, (q15_t)0xad97, (q15_t)0x60ec, (q15_t)0xac65, (q15_t)0x5fe3, (q15_t)0xab36, - (q15_t)0x5ed7, (q15_t)0xaa0b, (q15_t)0x5dc7, (q15_t)0xa8e3, (q15_t)0x5cb4, (q15_t)0xa7be, (q15_t)0x5b9d, (q15_t)0xa69c, - (q15_t)0x5a82, (q15_t)0xa57e, (q15_t)0x5964, (q15_t)0xa463, (q15_t)0x5842, (q15_t)0xa34c, (q15_t)0x571d, (q15_t)0xa239, - (q15_t)0x55f5, (q15_t)0xa129, (q15_t)0x54ca, (q15_t)0xa01d, (q15_t)0x539b, (q15_t)0x9f14, (q15_t)0x5269, (q15_t)0x9e0f, - (q15_t)0x5133, (q15_t)0x9d0e, (q15_t)0x4ffb, (q15_t)0x9c11, (q15_t)0x4ebf, (q15_t)0x9b18, (q15_t)0x4d81, (q15_t)0x9a23, - (q15_t)0x4c3f, (q15_t)0x9931, (q15_t)0x4afb, (q15_t)0x9843, (q15_t)0x49b4, (q15_t)0x975a, (q15_t)0x4869, (q15_t)0x9674, - (q15_t)0x471c, (q15_t)0x9593, (q15_t)0x45cd, (q15_t)0x94b6, (q15_t)0x447a, (q15_t)0x93dc, (q15_t)0x4325, (q15_t)0x9307, - (q15_t)0x41ce, (q15_t)0x9236, (q15_t)0x4073, (q15_t)0x916a, (q15_t)0x3f17, (q15_t)0x90a1, (q15_t)0x3db8, (q15_t)0x8fdd, - (q15_t)0x3c56, (q15_t)0x8f1e, (q15_t)0x3af2, (q15_t)0x8e62, (q15_t)0x398c, (q15_t)0x8dab, (q15_t)0x3824, (q15_t)0x8cf9, - (q15_t)0x36ba, (q15_t)0x8c4b, (q15_t)0x354d, (q15_t)0x8ba1, (q15_t)0x33de, (q15_t)0x8afc, (q15_t)0x326e, (q15_t)0x8a5b, - (q15_t)0x30fb, (q15_t)0x89bf, (q15_t)0x2f87, (q15_t)0x8927, (q15_t)0x2e11, (q15_t)0x8894, (q15_t)0x2c98, (q15_t)0x8806, - (q15_t)0x2b1f, (q15_t)0x877c, (q15_t)0x29a3, (q15_t)0x86f7, (q15_t)0x2826, (q15_t)0x8676, (q15_t)0x26a8, (q15_t)0x85fb, - (q15_t)0x2528, (q15_t)0x8583, (q15_t)0x23a6, (q15_t)0x8511, (q15_t)0x2223, (q15_t)0x84a3, (q15_t)0x209f, (q15_t)0x843b, - (q15_t)0x1f19, (q15_t)0x83d7, (q15_t)0x1d93, (q15_t)0x8377, (q15_t)0x1c0b, (q15_t)0x831d, (q15_t)0x1a82, (q15_t)0x82c7, - (q15_t)0x18f8, (q15_t)0x8276, (q15_t)0x176d, (q15_t)0x822a, (q15_t)0x15e2, (q15_t)0x81e3, (q15_t)0x1455, (q15_t)0x81a1, - (q15_t)0x12c8, (q15_t)0x8163, (q15_t)0x1139, (q15_t)0x812b, (q15_t)0xfab, (q15_t)0x80f7, (q15_t)0xe1b, (q15_t)0x80c8, - (q15_t)0xc8b, (q15_t)0x809e, (q15_t)0xafb, (q15_t)0x8079, (q15_t)0x96a, (q15_t)0x8059, (q15_t)0x7d9, (q15_t)0x803e, - (q15_t)0x647, (q15_t)0x8028, (q15_t)0x4b6, (q15_t)0x8017, (q15_t)0x324, (q15_t)0x800a, (q15_t)0x192, (q15_t)0x8003 -}; + (q15_t)0x7fff, (q15_t)0x0, (q15_t)0x7ffd, (q15_t)0xfe6e, (q15_t)0x7ff6, + (q15_t)0xfcdc, (q15_t)0x7fe9, (q15_t)0xfb4a, (q15_t)0x7fd8, (q15_t)0xf9b9, + (q15_t)0x7fc2, (q15_t)0xf827, (q15_t)0x7fa7, (q15_t)0xf696, (q15_t)0x7f87, + (q15_t)0xf505, (q15_t)0x7f62, (q15_t)0xf375, (q15_t)0x7f38, (q15_t)0xf1e5, + (q15_t)0x7f09, (q15_t)0xf055, (q15_t)0x7ed5, (q15_t)0xeec7, (q15_t)0x7e9d, + (q15_t)0xed38, (q15_t)0x7e5f, (q15_t)0xebab, (q15_t)0x7e1d, (q15_t)0xea1e, + (q15_t)0x7dd6, (q15_t)0xe893, (q15_t)0x7d8a, (q15_t)0xe708, (q15_t)0x7d39, + (q15_t)0xe57e, (q15_t)0x7ce3, (q15_t)0xe3f5, (q15_t)0x7c89, (q15_t)0xe26d, + (q15_t)0x7c29, (q15_t)0xe0e7, (q15_t)0x7bc5, (q15_t)0xdf61, (q15_t)0x7b5d, + (q15_t)0xdddd, (q15_t)0x7aef, (q15_t)0xdc5a, (q15_t)0x7a7d, (q15_t)0xdad8, + (q15_t)0x7a05, (q15_t)0xd958, (q15_t)0x798a, (q15_t)0xd7da, (q15_t)0x7909, + (q15_t)0xd65d, (q15_t)0x7884, (q15_t)0xd4e1, (q15_t)0x77fa, (q15_t)0xd368, + (q15_t)0x776c, (q15_t)0xd1ef, (q15_t)0x76d9, (q15_t)0xd079, (q15_t)0x7641, + (q15_t)0xcf05, (q15_t)0x75a5, (q15_t)0xcd92, (q15_t)0x7504, (q15_t)0xcc22, + (q15_t)0x745f, (q15_t)0xcab3, (q15_t)0x73b5, (q15_t)0xc946, (q15_t)0x7307, + (q15_t)0xc7dc, (q15_t)0x7255, (q15_t)0xc674, (q15_t)0x719e, (q15_t)0xc50e, + (q15_t)0x70e2, (q15_t)0xc3aa, (q15_t)0x7023, (q15_t)0xc248, (q15_t)0x6f5f, + (q15_t)0xc0e9, (q15_t)0x6e96, (q15_t)0xbf8d, (q15_t)0x6dca, (q15_t)0xbe32, + (q15_t)0x6cf9, (q15_t)0xbcdb, (q15_t)0x6c24, (q15_t)0xbb86, (q15_t)0x6b4a, + (q15_t)0xba33, (q15_t)0x6a6d, (q15_t)0xb8e4, (q15_t)0x698c, (q15_t)0xb797, + (q15_t)0x68a6, (q15_t)0xb64c, (q15_t)0x67bd, (q15_t)0xb505, (q15_t)0x66cf, + (q15_t)0xb3c1, (q15_t)0x65dd, (q15_t)0xb27f, (q15_t)0x64e8, (q15_t)0xb141, + (q15_t)0x63ef, (q15_t)0xb005, (q15_t)0x62f2, (q15_t)0xaecd, (q15_t)0x61f1, + (q15_t)0xad97, (q15_t)0x60ec, (q15_t)0xac65, (q15_t)0x5fe3, (q15_t)0xab36, + (q15_t)0x5ed7, (q15_t)0xaa0b, (q15_t)0x5dc7, (q15_t)0xa8e3, (q15_t)0x5cb4, + (q15_t)0xa7be, (q15_t)0x5b9d, (q15_t)0xa69c, (q15_t)0x5a82, (q15_t)0xa57e, + (q15_t)0x5964, (q15_t)0xa463, (q15_t)0x5842, (q15_t)0xa34c, (q15_t)0x571d, + (q15_t)0xa239, (q15_t)0x55f5, (q15_t)0xa129, (q15_t)0x54ca, (q15_t)0xa01d, + (q15_t)0x539b, (q15_t)0x9f14, (q15_t)0x5269, (q15_t)0x9e0f, (q15_t)0x5133, + (q15_t)0x9d0e, (q15_t)0x4ffb, (q15_t)0x9c11, (q15_t)0x4ebf, (q15_t)0x9b18, + (q15_t)0x4d81, (q15_t)0x9a23, (q15_t)0x4c3f, (q15_t)0x9931, (q15_t)0x4afb, + (q15_t)0x9843, (q15_t)0x49b4, (q15_t)0x975a, (q15_t)0x4869, (q15_t)0x9674, + (q15_t)0x471c, (q15_t)0x9593, (q15_t)0x45cd, (q15_t)0x94b6, (q15_t)0x447a, + (q15_t)0x93dc, (q15_t)0x4325, (q15_t)0x9307, (q15_t)0x41ce, (q15_t)0x9236, + (q15_t)0x4073, (q15_t)0x916a, (q15_t)0x3f17, (q15_t)0x90a1, (q15_t)0x3db8, + (q15_t)0x8fdd, (q15_t)0x3c56, (q15_t)0x8f1e, (q15_t)0x3af2, (q15_t)0x8e62, + (q15_t)0x398c, (q15_t)0x8dab, (q15_t)0x3824, (q15_t)0x8cf9, (q15_t)0x36ba, + (q15_t)0x8c4b, (q15_t)0x354d, (q15_t)0x8ba1, (q15_t)0x33de, (q15_t)0x8afc, + (q15_t)0x326e, (q15_t)0x8a5b, (q15_t)0x30fb, (q15_t)0x89bf, (q15_t)0x2f87, + (q15_t)0x8927, (q15_t)0x2e11, (q15_t)0x8894, (q15_t)0x2c98, (q15_t)0x8806, + (q15_t)0x2b1f, (q15_t)0x877c, (q15_t)0x29a3, (q15_t)0x86f7, (q15_t)0x2826, + (q15_t)0x8676, (q15_t)0x26a8, (q15_t)0x85fb, (q15_t)0x2528, (q15_t)0x8583, + (q15_t)0x23a6, (q15_t)0x8511, (q15_t)0x2223, (q15_t)0x84a3, (q15_t)0x209f, + (q15_t)0x843b, (q15_t)0x1f19, (q15_t)0x83d7, (q15_t)0x1d93, (q15_t)0x8377, + (q15_t)0x1c0b, (q15_t)0x831d, (q15_t)0x1a82, (q15_t)0x82c7, (q15_t)0x18f8, + (q15_t)0x8276, (q15_t)0x176d, (q15_t)0x822a, (q15_t)0x15e2, (q15_t)0x81e3, + (q15_t)0x1455, (q15_t)0x81a1, (q15_t)0x12c8, (q15_t)0x8163, (q15_t)0x1139, + (q15_t)0x812b, (q15_t)0xfab, (q15_t)0x80f7, (q15_t)0xe1b, (q15_t)0x80c8, + (q15_t)0xc8b, (q15_t)0x809e, (q15_t)0xafb, (q15_t)0x8079, (q15_t)0x96a, + (q15_t)0x8059, (q15_t)0x7d9, (q15_t)0x803e, (q15_t)0x647, (q15_t)0x8028, + (q15_t)0x4b6, (q15_t)0x8017, (q15_t)0x324, (q15_t)0x800a, (q15_t)0x192, + (q15_t)0x8003}; static const q15_t __ALIGNED(4) WeightsQ15_512[1024] = { - (q15_t)0x7fff, (q15_t)0x0, (q15_t)0x7fff, (q15_t)0xff9c, (q15_t)0x7fff, (q15_t)0xff37, (q15_t)0x7ffe, (q15_t)0xfed3, - (q15_t)0x7ffd, (q15_t)0xfe6e, (q15_t)0x7ffc, (q15_t)0xfe0a, (q15_t)0x7ffa, (q15_t)0xfda5, (q15_t)0x7ff8, (q15_t)0xfd41, - (q15_t)0x7ff6, (q15_t)0xfcdc, (q15_t)0x7ff3, (q15_t)0xfc78, (q15_t)0x7ff0, (q15_t)0xfc13, (q15_t)0x7fed, (q15_t)0xfbaf, - (q15_t)0x7fe9, (q15_t)0xfb4a, (q15_t)0x7fe5, (q15_t)0xfae6, (q15_t)0x7fe1, (q15_t)0xfa81, (q15_t)0x7fdd, (q15_t)0xfa1d, - (q15_t)0x7fd8, (q15_t)0xf9b9, (q15_t)0x7fd3, (q15_t)0xf954, (q15_t)0x7fce, (q15_t)0xf8f0, (q15_t)0x7fc8, (q15_t)0xf88b, - (q15_t)0x7fc2, (q15_t)0xf827, (q15_t)0x7fbc, (q15_t)0xf7c3, (q15_t)0x7fb5, (q15_t)0xf75e, (q15_t)0x7fae, (q15_t)0xf6fa, - (q15_t)0x7fa7, (q15_t)0xf696, (q15_t)0x7f9f, (q15_t)0xf632, (q15_t)0x7f97, (q15_t)0xf5cd, (q15_t)0x7f8f, (q15_t)0xf569, - (q15_t)0x7f87, (q15_t)0xf505, (q15_t)0x7f7e, (q15_t)0xf4a1, (q15_t)0x7f75, (q15_t)0xf43d, (q15_t)0x7f6b, (q15_t)0xf3d9, - (q15_t)0x7f62, (q15_t)0xf375, (q15_t)0x7f58, (q15_t)0xf311, (q15_t)0x7f4d, (q15_t)0xf2ad, (q15_t)0x7f43, (q15_t)0xf249, - (q15_t)0x7f38, (q15_t)0xf1e5, (q15_t)0x7f2d, (q15_t)0xf181, (q15_t)0x7f21, (q15_t)0xf11d, (q15_t)0x7f15, (q15_t)0xf0b9, - (q15_t)0x7f09, (q15_t)0xf055, (q15_t)0x7efd, (q15_t)0xeff2, (q15_t)0x7ef0, (q15_t)0xef8e, (q15_t)0x7ee3, (q15_t)0xef2a, - (q15_t)0x7ed5, (q15_t)0xeec7, (q15_t)0x7ec8, (q15_t)0xee63, (q15_t)0x7eba, (q15_t)0xedff, (q15_t)0x7eab, (q15_t)0xed9c, - (q15_t)0x7e9d, (q15_t)0xed38, (q15_t)0x7e8e, (q15_t)0xecd5, (q15_t)0x7e7f, (q15_t)0xec72, (q15_t)0x7e6f, (q15_t)0xec0e, - (q15_t)0x7e5f, (q15_t)0xebab, (q15_t)0x7e4f, (q15_t)0xeb48, (q15_t)0x7e3f, (q15_t)0xeae5, (q15_t)0x7e2e, (q15_t)0xea81, - (q15_t)0x7e1d, (q15_t)0xea1e, (q15_t)0x7e0c, (q15_t)0xe9bb, (q15_t)0x7dfa, (q15_t)0xe958, (q15_t)0x7de8, (q15_t)0xe8f6, - (q15_t)0x7dd6, (q15_t)0xe893, (q15_t)0x7dc3, (q15_t)0xe830, (q15_t)0x7db0, (q15_t)0xe7cd, (q15_t)0x7d9d, (q15_t)0xe76a, - (q15_t)0x7d8a, (q15_t)0xe708, (q15_t)0x7d76, (q15_t)0xe6a5, (q15_t)0x7d62, (q15_t)0xe643, (q15_t)0x7d4e, (q15_t)0xe5e0, - (q15_t)0x7d39, (q15_t)0xe57e, (q15_t)0x7d24, (q15_t)0xe51c, (q15_t)0x7d0f, (q15_t)0xe4b9, (q15_t)0x7cf9, (q15_t)0xe457, - (q15_t)0x7ce3, (q15_t)0xe3f5, (q15_t)0x7ccd, (q15_t)0xe393, (q15_t)0x7cb7, (q15_t)0xe331, (q15_t)0x7ca0, (q15_t)0xe2cf, - (q15_t)0x7c89, (q15_t)0xe26d, (q15_t)0x7c71, (q15_t)0xe20b, (q15_t)0x7c5a, (q15_t)0xe1aa, (q15_t)0x7c42, (q15_t)0xe148, - (q15_t)0x7c29, (q15_t)0xe0e7, (q15_t)0x7c11, (q15_t)0xe085, (q15_t)0x7bf8, (q15_t)0xe024, (q15_t)0x7bdf, (q15_t)0xdfc2, - (q15_t)0x7bc5, (q15_t)0xdf61, (q15_t)0x7bac, (q15_t)0xdf00, (q15_t)0x7b92, (q15_t)0xde9f, (q15_t)0x7b77, (q15_t)0xde3e, - (q15_t)0x7b5d, (q15_t)0xdddd, (q15_t)0x7b42, (q15_t)0xdd7c, (q15_t)0x7b26, (q15_t)0xdd1b, (q15_t)0x7b0b, (q15_t)0xdcbb, - (q15_t)0x7aef, (q15_t)0xdc5a, (q15_t)0x7ad3, (q15_t)0xdbf9, (q15_t)0x7ab6, (q15_t)0xdb99, (q15_t)0x7a9a, (q15_t)0xdb39, - (q15_t)0x7a7d, (q15_t)0xdad8, (q15_t)0x7a5f, (q15_t)0xda78, (q15_t)0x7a42, (q15_t)0xda18, (q15_t)0x7a24, (q15_t)0xd9b8, - (q15_t)0x7a05, (q15_t)0xd958, (q15_t)0x79e7, (q15_t)0xd8f9, (q15_t)0x79c8, (q15_t)0xd899, (q15_t)0x79a9, (q15_t)0xd839, - (q15_t)0x798a, (q15_t)0xd7da, (q15_t)0x796a, (q15_t)0xd77a, (q15_t)0x794a, (q15_t)0xd71b, (q15_t)0x792a, (q15_t)0xd6bc, - (q15_t)0x7909, (q15_t)0xd65d, (q15_t)0x78e8, (q15_t)0xd5fe, (q15_t)0x78c7, (q15_t)0xd59f, (q15_t)0x78a6, (q15_t)0xd540, - (q15_t)0x7884, (q15_t)0xd4e1, (q15_t)0x7862, (q15_t)0xd483, (q15_t)0x7840, (q15_t)0xd424, (q15_t)0x781d, (q15_t)0xd3c6, - (q15_t)0x77fa, (q15_t)0xd368, (q15_t)0x77d7, (q15_t)0xd309, (q15_t)0x77b4, (q15_t)0xd2ab, (q15_t)0x7790, (q15_t)0xd24d, - (q15_t)0x776c, (q15_t)0xd1ef, (q15_t)0x7747, (q15_t)0xd192, (q15_t)0x7723, (q15_t)0xd134, (q15_t)0x76fe, (q15_t)0xd0d7, - (q15_t)0x76d9, (q15_t)0xd079, (q15_t)0x76b3, (q15_t)0xd01c, (q15_t)0x768e, (q15_t)0xcfbf, (q15_t)0x7668, (q15_t)0xcf62, - (q15_t)0x7641, (q15_t)0xcf05, (q15_t)0x761b, (q15_t)0xcea8, (q15_t)0x75f4, (q15_t)0xce4b, (q15_t)0x75cc, (q15_t)0xcdef, - (q15_t)0x75a5, (q15_t)0xcd92, (q15_t)0x757d, (q15_t)0xcd36, (q15_t)0x7555, (q15_t)0xccda, (q15_t)0x752d, (q15_t)0xcc7e, - (q15_t)0x7504, (q15_t)0xcc22, (q15_t)0x74db, (q15_t)0xcbc6, (q15_t)0x74b2, (q15_t)0xcb6a, (q15_t)0x7489, (q15_t)0xcb0e, - (q15_t)0x745f, (q15_t)0xcab3, (q15_t)0x7435, (q15_t)0xca58, (q15_t)0x740b, (q15_t)0xc9fc, (q15_t)0x73e0, (q15_t)0xc9a1, - (q15_t)0x73b5, (q15_t)0xc946, (q15_t)0x738a, (q15_t)0xc8ec, (q15_t)0x735f, (q15_t)0xc891, (q15_t)0x7333, (q15_t)0xc836, - (q15_t)0x7307, (q15_t)0xc7dc, (q15_t)0x72db, (q15_t)0xc782, (q15_t)0x72af, (q15_t)0xc728, (q15_t)0x7282, (q15_t)0xc6ce, - (q15_t)0x7255, (q15_t)0xc674, (q15_t)0x7227, (q15_t)0xc61a, (q15_t)0x71fa, (q15_t)0xc5c0, (q15_t)0x71cc, (q15_t)0xc567, - (q15_t)0x719e, (q15_t)0xc50e, (q15_t)0x716f, (q15_t)0xc4b4, (q15_t)0x7141, (q15_t)0xc45b, (q15_t)0x7112, (q15_t)0xc403, - (q15_t)0x70e2, (q15_t)0xc3aa, (q15_t)0x70b3, (q15_t)0xc351, (q15_t)0x7083, (q15_t)0xc2f9, (q15_t)0x7053, (q15_t)0xc2a0, - (q15_t)0x7023, (q15_t)0xc248, (q15_t)0x6ff2, (q15_t)0xc1f0, (q15_t)0x6fc1, (q15_t)0xc198, (q15_t)0x6f90, (q15_t)0xc141, - (q15_t)0x6f5f, (q15_t)0xc0e9, (q15_t)0x6f2d, (q15_t)0xc092, (q15_t)0x6efb, (q15_t)0xc03b, (q15_t)0x6ec9, (q15_t)0xbfe3, - (q15_t)0x6e96, (q15_t)0xbf8d, (q15_t)0x6e63, (q15_t)0xbf36, (q15_t)0x6e30, (q15_t)0xbedf, (q15_t)0x6dfd, (q15_t)0xbe89, - (q15_t)0x6dca, (q15_t)0xbe32, (q15_t)0x6d96, (q15_t)0xbddc, (q15_t)0x6d62, (q15_t)0xbd86, (q15_t)0x6d2d, (q15_t)0xbd30, - (q15_t)0x6cf9, (q15_t)0xbcdb, (q15_t)0x6cc4, (q15_t)0xbc85, (q15_t)0x6c8f, (q15_t)0xbc30, (q15_t)0x6c59, (q15_t)0xbbdb, - (q15_t)0x6c24, (q15_t)0xbb86, (q15_t)0x6bee, (q15_t)0xbb31, (q15_t)0x6bb8, (q15_t)0xbadc, (q15_t)0x6b81, (q15_t)0xba88, - (q15_t)0x6b4a, (q15_t)0xba33, (q15_t)0x6b13, (q15_t)0xb9df, (q15_t)0x6adc, (q15_t)0xb98b, (q15_t)0x6aa5, (q15_t)0xb937, - (q15_t)0x6a6d, (q15_t)0xb8e4, (q15_t)0x6a35, (q15_t)0xb890, (q15_t)0x69fd, (q15_t)0xb83d, (q15_t)0x69c4, (q15_t)0xb7ea, - (q15_t)0x698c, (q15_t)0xb797, (q15_t)0x6953, (q15_t)0xb744, (q15_t)0x6919, (q15_t)0xb6f1, (q15_t)0x68e0, (q15_t)0xb69f, - (q15_t)0x68a6, (q15_t)0xb64c, (q15_t)0x686c, (q15_t)0xb5fa, (q15_t)0x6832, (q15_t)0xb5a8, (q15_t)0x67f7, (q15_t)0xb557, - (q15_t)0x67bd, (q15_t)0xb505, (q15_t)0x6782, (q15_t)0xb4b4, (q15_t)0x6746, (q15_t)0xb462, (q15_t)0x670b, (q15_t)0xb411, - (q15_t)0x66cf, (q15_t)0xb3c1, (q15_t)0x6693, (q15_t)0xb370, (q15_t)0x6657, (q15_t)0xb31f, (q15_t)0x661a, (q15_t)0xb2cf, - (q15_t)0x65dd, (q15_t)0xb27f, (q15_t)0x65a0, (q15_t)0xb22f, (q15_t)0x6563, (q15_t)0xb1df, (q15_t)0x6526, (q15_t)0xb190, - (q15_t)0x64e8, (q15_t)0xb141, (q15_t)0x64aa, (q15_t)0xb0f1, (q15_t)0x646c, (q15_t)0xb0a2, (q15_t)0x642d, (q15_t)0xb054, - (q15_t)0x63ef, (q15_t)0xb005, (q15_t)0x63b0, (q15_t)0xafb7, (q15_t)0x6371, (q15_t)0xaf69, (q15_t)0x6331, (q15_t)0xaf1b, - (q15_t)0x62f2, (q15_t)0xaecd, (q15_t)0x62b2, (q15_t)0xae7f, (q15_t)0x6271, (q15_t)0xae32, (q15_t)0x6231, (q15_t)0xade4, - (q15_t)0x61f1, (q15_t)0xad97, (q15_t)0x61b0, (q15_t)0xad4b, (q15_t)0x616f, (q15_t)0xacfe, (q15_t)0x612d, (q15_t)0xacb2, - (q15_t)0x60ec, (q15_t)0xac65, (q15_t)0x60aa, (q15_t)0xac19, (q15_t)0x6068, (q15_t)0xabcd, (q15_t)0x6026, (q15_t)0xab82, - (q15_t)0x5fe3, (q15_t)0xab36, (q15_t)0x5fa0, (q15_t)0xaaeb, (q15_t)0x5f5e, (q15_t)0xaaa0, (q15_t)0x5f1a, (q15_t)0xaa55, - (q15_t)0x5ed7, (q15_t)0xaa0b, (q15_t)0x5e93, (q15_t)0xa9c0, (q15_t)0x5e50, (q15_t)0xa976, (q15_t)0x5e0b, (q15_t)0xa92c, - (q15_t)0x5dc7, (q15_t)0xa8e3, (q15_t)0x5d83, (q15_t)0xa899, (q15_t)0x5d3e, (q15_t)0xa850, (q15_t)0x5cf9, (q15_t)0xa807, - (q15_t)0x5cb4, (q15_t)0xa7be, (q15_t)0x5c6e, (q15_t)0xa775, (q15_t)0x5c29, (q15_t)0xa72c, (q15_t)0x5be3, (q15_t)0xa6e4, - (q15_t)0x5b9d, (q15_t)0xa69c, (q15_t)0x5b56, (q15_t)0xa654, (q15_t)0x5b10, (q15_t)0xa60d, (q15_t)0x5ac9, (q15_t)0xa5c5, - (q15_t)0x5a82, (q15_t)0xa57e, (q15_t)0x5a3b, (q15_t)0xa537, (q15_t)0x59f3, (q15_t)0xa4f0, (q15_t)0x59ac, (q15_t)0xa4aa, - (q15_t)0x5964, (q15_t)0xa463, (q15_t)0x591c, (q15_t)0xa41d, (q15_t)0x58d4, (q15_t)0xa3d7, (q15_t)0x588b, (q15_t)0xa392, - (q15_t)0x5842, (q15_t)0xa34c, (q15_t)0x57f9, (q15_t)0xa307, (q15_t)0x57b0, (q15_t)0xa2c2, (q15_t)0x5767, (q15_t)0xa27d, - (q15_t)0x571d, (q15_t)0xa239, (q15_t)0x56d4, (q15_t)0xa1f5, (q15_t)0x568a, (q15_t)0xa1b0, (q15_t)0x5640, (q15_t)0xa16d, - (q15_t)0x55f5, (q15_t)0xa129, (q15_t)0x55ab, (q15_t)0xa0e6, (q15_t)0x5560, (q15_t)0xa0a2, (q15_t)0x5515, (q15_t)0xa060, - (q15_t)0x54ca, (q15_t)0xa01d, (q15_t)0x547e, (q15_t)0x9fda, (q15_t)0x5433, (q15_t)0x9f98, (q15_t)0x53e7, (q15_t)0x9f56, - (q15_t)0x539b, (q15_t)0x9f14, (q15_t)0x534e, (q15_t)0x9ed3, (q15_t)0x5302, (q15_t)0x9e91, (q15_t)0x52b5, (q15_t)0x9e50, - (q15_t)0x5269, (q15_t)0x9e0f, (q15_t)0x521c, (q15_t)0x9dcf, (q15_t)0x51ce, (q15_t)0x9d8f, (q15_t)0x5181, (q15_t)0x9d4e, - (q15_t)0x5133, (q15_t)0x9d0e, (q15_t)0x50e5, (q15_t)0x9ccf, (q15_t)0x5097, (q15_t)0x9c8f, (q15_t)0x5049, (q15_t)0x9c50, - (q15_t)0x4ffb, (q15_t)0x9c11, (q15_t)0x4fac, (q15_t)0x9bd3, (q15_t)0x4f5e, (q15_t)0x9b94, (q15_t)0x4f0f, (q15_t)0x9b56, - (q15_t)0x4ebf, (q15_t)0x9b18, (q15_t)0x4e70, (q15_t)0x9ada, (q15_t)0x4e21, (q15_t)0x9a9d, (q15_t)0x4dd1, (q15_t)0x9a60, - (q15_t)0x4d81, (q15_t)0x9a23, (q15_t)0x4d31, (q15_t)0x99e6, (q15_t)0x4ce1, (q15_t)0x99a9, (q15_t)0x4c90, (q15_t)0x996d, - (q15_t)0x4c3f, (q15_t)0x9931, (q15_t)0x4bef, (q15_t)0x98f5, (q15_t)0x4b9e, (q15_t)0x98ba, (q15_t)0x4b4c, (q15_t)0x987e, - (q15_t)0x4afb, (q15_t)0x9843, (q15_t)0x4aa9, (q15_t)0x9809, (q15_t)0x4a58, (q15_t)0x97ce, (q15_t)0x4a06, (q15_t)0x9794, - (q15_t)0x49b4, (q15_t)0x975a, (q15_t)0x4961, (q15_t)0x9720, (q15_t)0x490f, (q15_t)0x96e7, (q15_t)0x48bc, (q15_t)0x96ad, - (q15_t)0x4869, (q15_t)0x9674, (q15_t)0x4816, (q15_t)0x963c, (q15_t)0x47c3, (q15_t)0x9603, (q15_t)0x4770, (q15_t)0x95cb, - (q15_t)0x471c, (q15_t)0x9593, (q15_t)0x46c9, (q15_t)0x955b, (q15_t)0x4675, (q15_t)0x9524, (q15_t)0x4621, (q15_t)0x94ed, - (q15_t)0x45cd, (q15_t)0x94b6, (q15_t)0x4578, (q15_t)0x947f, (q15_t)0x4524, (q15_t)0x9448, (q15_t)0x44cf, (q15_t)0x9412, - (q15_t)0x447a, (q15_t)0x93dc, (q15_t)0x4425, (q15_t)0x93a7, (q15_t)0x43d0, (q15_t)0x9371, (q15_t)0x437b, (q15_t)0x933c, - (q15_t)0x4325, (q15_t)0x9307, (q15_t)0x42d0, (q15_t)0x92d3, (q15_t)0x427a, (q15_t)0x929e, (q15_t)0x4224, (q15_t)0x926a, - (q15_t)0x41ce, (q15_t)0x9236, (q15_t)0x4177, (q15_t)0x9203, (q15_t)0x4121, (q15_t)0x91d0, (q15_t)0x40ca, (q15_t)0x919d, - (q15_t)0x4073, (q15_t)0x916a, (q15_t)0x401d, (q15_t)0x9137, (q15_t)0x3fc5, (q15_t)0x9105, (q15_t)0x3f6e, (q15_t)0x90d3, - (q15_t)0x3f17, (q15_t)0x90a1, (q15_t)0x3ebf, (q15_t)0x9070, (q15_t)0x3e68, (q15_t)0x903f, (q15_t)0x3e10, (q15_t)0x900e, - (q15_t)0x3db8, (q15_t)0x8fdd, (q15_t)0x3d60, (q15_t)0x8fad, (q15_t)0x3d07, (q15_t)0x8f7d, (q15_t)0x3caf, (q15_t)0x8f4d, - (q15_t)0x3c56, (q15_t)0x8f1e, (q15_t)0x3bfd, (q15_t)0x8eee, (q15_t)0x3ba5, (q15_t)0x8ebf, (q15_t)0x3b4c, (q15_t)0x8e91, - (q15_t)0x3af2, (q15_t)0x8e62, (q15_t)0x3a99, (q15_t)0x8e34, (q15_t)0x3a40, (q15_t)0x8e06, (q15_t)0x39e6, (q15_t)0x8dd9, - (q15_t)0x398c, (q15_t)0x8dab, (q15_t)0x3932, (q15_t)0x8d7e, (q15_t)0x38d8, (q15_t)0x8d51, (q15_t)0x387e, (q15_t)0x8d25, - (q15_t)0x3824, (q15_t)0x8cf9, (q15_t)0x37ca, (q15_t)0x8ccd, (q15_t)0x376f, (q15_t)0x8ca1, (q15_t)0x3714, (q15_t)0x8c76, - (q15_t)0x36ba, (q15_t)0x8c4b, (q15_t)0x365f, (q15_t)0x8c20, (q15_t)0x3604, (q15_t)0x8bf5, (q15_t)0x35a8, (q15_t)0x8bcb, - (q15_t)0x354d, (q15_t)0x8ba1, (q15_t)0x34f2, (q15_t)0x8b77, (q15_t)0x3496, (q15_t)0x8b4e, (q15_t)0x343a, (q15_t)0x8b25, - (q15_t)0x33de, (q15_t)0x8afc, (q15_t)0x3382, (q15_t)0x8ad3, (q15_t)0x3326, (q15_t)0x8aab, (q15_t)0x32ca, (q15_t)0x8a83, - (q15_t)0x326e, (q15_t)0x8a5b, (q15_t)0x3211, (q15_t)0x8a34, (q15_t)0x31b5, (q15_t)0x8a0c, (q15_t)0x3158, (q15_t)0x89e5, - (q15_t)0x30fb, (q15_t)0x89bf, (q15_t)0x309e, (q15_t)0x8998, (q15_t)0x3041, (q15_t)0x8972, (q15_t)0x2fe4, (q15_t)0x894d, - (q15_t)0x2f87, (q15_t)0x8927, (q15_t)0x2f29, (q15_t)0x8902, (q15_t)0x2ecc, (q15_t)0x88dd, (q15_t)0x2e6e, (q15_t)0x88b9, - (q15_t)0x2e11, (q15_t)0x8894, (q15_t)0x2db3, (q15_t)0x8870, (q15_t)0x2d55, (q15_t)0x884c, (q15_t)0x2cf7, (q15_t)0x8829, - (q15_t)0x2c98, (q15_t)0x8806, (q15_t)0x2c3a, (q15_t)0x87e3, (q15_t)0x2bdc, (q15_t)0x87c0, (q15_t)0x2b7d, (q15_t)0x879e, - (q15_t)0x2b1f, (q15_t)0x877c, (q15_t)0x2ac0, (q15_t)0x875a, (q15_t)0x2a61, (q15_t)0x8739, (q15_t)0x2a02, (q15_t)0x8718, - (q15_t)0x29a3, (q15_t)0x86f7, (q15_t)0x2944, (q15_t)0x86d6, (q15_t)0x28e5, (q15_t)0x86b6, (q15_t)0x2886, (q15_t)0x8696, - (q15_t)0x2826, (q15_t)0x8676, (q15_t)0x27c7, (q15_t)0x8657, (q15_t)0x2767, (q15_t)0x8638, (q15_t)0x2707, (q15_t)0x8619, - (q15_t)0x26a8, (q15_t)0x85fb, (q15_t)0x2648, (q15_t)0x85dc, (q15_t)0x25e8, (q15_t)0x85be, (q15_t)0x2588, (q15_t)0x85a1, - (q15_t)0x2528, (q15_t)0x8583, (q15_t)0x24c7, (q15_t)0x8566, (q15_t)0x2467, (q15_t)0x854a, (q15_t)0x2407, (q15_t)0x852d, - (q15_t)0x23a6, (q15_t)0x8511, (q15_t)0x2345, (q15_t)0x84f5, (q15_t)0x22e5, (q15_t)0x84da, (q15_t)0x2284, (q15_t)0x84be, - (q15_t)0x2223, (q15_t)0x84a3, (q15_t)0x21c2, (q15_t)0x8489, (q15_t)0x2161, (q15_t)0x846e, (q15_t)0x2100, (q15_t)0x8454, - (q15_t)0x209f, (q15_t)0x843b, (q15_t)0x203e, (q15_t)0x8421, (q15_t)0x1fdc, (q15_t)0x8408, (q15_t)0x1f7b, (q15_t)0x83ef, - (q15_t)0x1f19, (q15_t)0x83d7, (q15_t)0x1eb8, (q15_t)0x83be, (q15_t)0x1e56, (q15_t)0x83a6, (q15_t)0x1df5, (q15_t)0x838f, - (q15_t)0x1d93, (q15_t)0x8377, (q15_t)0x1d31, (q15_t)0x8360, (q15_t)0x1ccf, (q15_t)0x8349, (q15_t)0x1c6d, (q15_t)0x8333, - (q15_t)0x1c0b, (q15_t)0x831d, (q15_t)0x1ba9, (q15_t)0x8307, (q15_t)0x1b47, (q15_t)0x82f1, (q15_t)0x1ae4, (q15_t)0x82dc, - (q15_t)0x1a82, (q15_t)0x82c7, (q15_t)0x1a20, (q15_t)0x82b2, (q15_t)0x19bd, (q15_t)0x829e, (q15_t)0x195b, (q15_t)0x828a, - (q15_t)0x18f8, (q15_t)0x8276, (q15_t)0x1896, (q15_t)0x8263, (q15_t)0x1833, (q15_t)0x8250, (q15_t)0x17d0, (q15_t)0x823d, - (q15_t)0x176d, (q15_t)0x822a, (q15_t)0x170a, (q15_t)0x8218, (q15_t)0x16a8, (q15_t)0x8206, (q15_t)0x1645, (q15_t)0x81f4, - (q15_t)0x15e2, (q15_t)0x81e3, (q15_t)0x157f, (q15_t)0x81d2, (q15_t)0x151b, (q15_t)0x81c1, (q15_t)0x14b8, (q15_t)0x81b1, - (q15_t)0x1455, (q15_t)0x81a1, (q15_t)0x13f2, (q15_t)0x8191, (q15_t)0x138e, (q15_t)0x8181, (q15_t)0x132b, (q15_t)0x8172, - (q15_t)0x12c8, (q15_t)0x8163, (q15_t)0x1264, (q15_t)0x8155, (q15_t)0x1201, (q15_t)0x8146, (q15_t)0x119d, (q15_t)0x8138, - (q15_t)0x1139, (q15_t)0x812b, (q15_t)0x10d6, (q15_t)0x811d, (q15_t)0x1072, (q15_t)0x8110, (q15_t)0x100e, (q15_t)0x8103, - (q15_t)0xfab, (q15_t)0x80f7, (q15_t)0xf47, (q15_t)0x80eb, (q15_t)0xee3, (q15_t)0x80df, (q15_t)0xe7f, (q15_t)0x80d3, - (q15_t)0xe1b, (q15_t)0x80c8, (q15_t)0xdb7, (q15_t)0x80bd, (q15_t)0xd53, (q15_t)0x80b3, (q15_t)0xcef, (q15_t)0x80a8, - (q15_t)0xc8b, (q15_t)0x809e, (q15_t)0xc27, (q15_t)0x8095, (q15_t)0xbc3, (q15_t)0x808b, (q15_t)0xb5f, (q15_t)0x8082, - (q15_t)0xafb, (q15_t)0x8079, (q15_t)0xa97, (q15_t)0x8071, (q15_t)0xa33, (q15_t)0x8069, (q15_t)0x9ce, (q15_t)0x8061, - (q15_t)0x96a, (q15_t)0x8059, (q15_t)0x906, (q15_t)0x8052, (q15_t)0x8a2, (q15_t)0x804b, (q15_t)0x83d, (q15_t)0x8044, - (q15_t)0x7d9, (q15_t)0x803e, (q15_t)0x775, (q15_t)0x8038, (q15_t)0x710, (q15_t)0x8032, (q15_t)0x6ac, (q15_t)0x802d, - (q15_t)0x647, (q15_t)0x8028, (q15_t)0x5e3, (q15_t)0x8023, (q15_t)0x57f, (q15_t)0x801f, (q15_t)0x51a, (q15_t)0x801b, - (q15_t)0x4b6, (q15_t)0x8017, (q15_t)0x451, (q15_t)0x8013, (q15_t)0x3ed, (q15_t)0x8010, (q15_t)0x388, (q15_t)0x800d, - (q15_t)0x324, (q15_t)0x800a, (q15_t)0x2bf, (q15_t)0x8008, (q15_t)0x25b, (q15_t)0x8006, (q15_t)0x1f6, (q15_t)0x8004, - (q15_t)0x192, (q15_t)0x8003, (q15_t)0x12d, (q15_t)0x8002, (q15_t)0xc9, (q15_t)0x8001, (q15_t)0x64, (q15_t)0x8001 -}; + (q15_t)0x7fff, (q15_t)0x0, (q15_t)0x7fff, (q15_t)0xff9c, (q15_t)0x7fff, + (q15_t)0xff37, (q15_t)0x7ffe, (q15_t)0xfed3, (q15_t)0x7ffd, (q15_t)0xfe6e, + (q15_t)0x7ffc, (q15_t)0xfe0a, (q15_t)0x7ffa, (q15_t)0xfda5, (q15_t)0x7ff8, + (q15_t)0xfd41, (q15_t)0x7ff6, (q15_t)0xfcdc, (q15_t)0x7ff3, (q15_t)0xfc78, + (q15_t)0x7ff0, (q15_t)0xfc13, (q15_t)0x7fed, (q15_t)0xfbaf, (q15_t)0x7fe9, + (q15_t)0xfb4a, (q15_t)0x7fe5, (q15_t)0xfae6, (q15_t)0x7fe1, (q15_t)0xfa81, + (q15_t)0x7fdd, (q15_t)0xfa1d, (q15_t)0x7fd8, (q15_t)0xf9b9, (q15_t)0x7fd3, + (q15_t)0xf954, (q15_t)0x7fce, (q15_t)0xf8f0, (q15_t)0x7fc8, (q15_t)0xf88b, + (q15_t)0x7fc2, (q15_t)0xf827, (q15_t)0x7fbc, (q15_t)0xf7c3, (q15_t)0x7fb5, + (q15_t)0xf75e, (q15_t)0x7fae, (q15_t)0xf6fa, (q15_t)0x7fa7, (q15_t)0xf696, + (q15_t)0x7f9f, (q15_t)0xf632, (q15_t)0x7f97, (q15_t)0xf5cd, (q15_t)0x7f8f, + (q15_t)0xf569, (q15_t)0x7f87, (q15_t)0xf505, (q15_t)0x7f7e, (q15_t)0xf4a1, + (q15_t)0x7f75, (q15_t)0xf43d, (q15_t)0x7f6b, (q15_t)0xf3d9, (q15_t)0x7f62, + (q15_t)0xf375, (q15_t)0x7f58, (q15_t)0xf311, (q15_t)0x7f4d, (q15_t)0xf2ad, + (q15_t)0x7f43, (q15_t)0xf249, (q15_t)0x7f38, (q15_t)0xf1e5, (q15_t)0x7f2d, + (q15_t)0xf181, (q15_t)0x7f21, (q15_t)0xf11d, (q15_t)0x7f15, (q15_t)0xf0b9, + (q15_t)0x7f09, (q15_t)0xf055, (q15_t)0x7efd, (q15_t)0xeff2, (q15_t)0x7ef0, + (q15_t)0xef8e, (q15_t)0x7ee3, (q15_t)0xef2a, (q15_t)0x7ed5, (q15_t)0xeec7, + (q15_t)0x7ec8, (q15_t)0xee63, (q15_t)0x7eba, (q15_t)0xedff, (q15_t)0x7eab, + (q15_t)0xed9c, (q15_t)0x7e9d, (q15_t)0xed38, (q15_t)0x7e8e, (q15_t)0xecd5, + (q15_t)0x7e7f, (q15_t)0xec72, (q15_t)0x7e6f, (q15_t)0xec0e, (q15_t)0x7e5f, + (q15_t)0xebab, (q15_t)0x7e4f, (q15_t)0xeb48, (q15_t)0x7e3f, (q15_t)0xeae5, + (q15_t)0x7e2e, (q15_t)0xea81, (q15_t)0x7e1d, (q15_t)0xea1e, (q15_t)0x7e0c, + (q15_t)0xe9bb, (q15_t)0x7dfa, (q15_t)0xe958, (q15_t)0x7de8, (q15_t)0xe8f6, + (q15_t)0x7dd6, (q15_t)0xe893, (q15_t)0x7dc3, (q15_t)0xe830, (q15_t)0x7db0, + (q15_t)0xe7cd, (q15_t)0x7d9d, (q15_t)0xe76a, (q15_t)0x7d8a, (q15_t)0xe708, + (q15_t)0x7d76, (q15_t)0xe6a5, (q15_t)0x7d62, (q15_t)0xe643, (q15_t)0x7d4e, + (q15_t)0xe5e0, (q15_t)0x7d39, (q15_t)0xe57e, (q15_t)0x7d24, (q15_t)0xe51c, + (q15_t)0x7d0f, (q15_t)0xe4b9, (q15_t)0x7cf9, (q15_t)0xe457, (q15_t)0x7ce3, + (q15_t)0xe3f5, (q15_t)0x7ccd, (q15_t)0xe393, (q15_t)0x7cb7, (q15_t)0xe331, + (q15_t)0x7ca0, (q15_t)0xe2cf, (q15_t)0x7c89, (q15_t)0xe26d, (q15_t)0x7c71, + (q15_t)0xe20b, (q15_t)0x7c5a, (q15_t)0xe1aa, (q15_t)0x7c42, (q15_t)0xe148, + (q15_t)0x7c29, (q15_t)0xe0e7, (q15_t)0x7c11, (q15_t)0xe085, (q15_t)0x7bf8, + (q15_t)0xe024, (q15_t)0x7bdf, (q15_t)0xdfc2, (q15_t)0x7bc5, (q15_t)0xdf61, + (q15_t)0x7bac, (q15_t)0xdf00, (q15_t)0x7b92, (q15_t)0xde9f, (q15_t)0x7b77, + (q15_t)0xde3e, (q15_t)0x7b5d, (q15_t)0xdddd, (q15_t)0x7b42, (q15_t)0xdd7c, + (q15_t)0x7b26, (q15_t)0xdd1b, (q15_t)0x7b0b, (q15_t)0xdcbb, (q15_t)0x7aef, + (q15_t)0xdc5a, (q15_t)0x7ad3, (q15_t)0xdbf9, (q15_t)0x7ab6, (q15_t)0xdb99, + (q15_t)0x7a9a, (q15_t)0xdb39, (q15_t)0x7a7d, (q15_t)0xdad8, (q15_t)0x7a5f, + (q15_t)0xda78, (q15_t)0x7a42, (q15_t)0xda18, (q15_t)0x7a24, (q15_t)0xd9b8, + (q15_t)0x7a05, (q15_t)0xd958, (q15_t)0x79e7, (q15_t)0xd8f9, (q15_t)0x79c8, + (q15_t)0xd899, (q15_t)0x79a9, (q15_t)0xd839, (q15_t)0x798a, (q15_t)0xd7da, + (q15_t)0x796a, (q15_t)0xd77a, (q15_t)0x794a, (q15_t)0xd71b, (q15_t)0x792a, + (q15_t)0xd6bc, (q15_t)0x7909, (q15_t)0xd65d, (q15_t)0x78e8, (q15_t)0xd5fe, + (q15_t)0x78c7, (q15_t)0xd59f, (q15_t)0x78a6, (q15_t)0xd540, (q15_t)0x7884, + (q15_t)0xd4e1, (q15_t)0x7862, (q15_t)0xd483, (q15_t)0x7840, (q15_t)0xd424, + (q15_t)0x781d, (q15_t)0xd3c6, (q15_t)0x77fa, (q15_t)0xd368, (q15_t)0x77d7, + (q15_t)0xd309, (q15_t)0x77b4, (q15_t)0xd2ab, (q15_t)0x7790, (q15_t)0xd24d, + (q15_t)0x776c, (q15_t)0xd1ef, (q15_t)0x7747, (q15_t)0xd192, (q15_t)0x7723, + (q15_t)0xd134, (q15_t)0x76fe, (q15_t)0xd0d7, (q15_t)0x76d9, (q15_t)0xd079, + (q15_t)0x76b3, (q15_t)0xd01c, (q15_t)0x768e, (q15_t)0xcfbf, (q15_t)0x7668, + (q15_t)0xcf62, (q15_t)0x7641, (q15_t)0xcf05, (q15_t)0x761b, (q15_t)0xcea8, + (q15_t)0x75f4, (q15_t)0xce4b, (q15_t)0x75cc, (q15_t)0xcdef, (q15_t)0x75a5, + (q15_t)0xcd92, (q15_t)0x757d, (q15_t)0xcd36, (q15_t)0x7555, (q15_t)0xccda, + (q15_t)0x752d, (q15_t)0xcc7e, (q15_t)0x7504, (q15_t)0xcc22, (q15_t)0x74db, + (q15_t)0xcbc6, (q15_t)0x74b2, (q15_t)0xcb6a, (q15_t)0x7489, (q15_t)0xcb0e, + (q15_t)0x745f, (q15_t)0xcab3, (q15_t)0x7435, (q15_t)0xca58, (q15_t)0x740b, + (q15_t)0xc9fc, (q15_t)0x73e0, (q15_t)0xc9a1, (q15_t)0x73b5, (q15_t)0xc946, + (q15_t)0x738a, (q15_t)0xc8ec, (q15_t)0x735f, (q15_t)0xc891, (q15_t)0x7333, + (q15_t)0xc836, (q15_t)0x7307, (q15_t)0xc7dc, (q15_t)0x72db, (q15_t)0xc782, + (q15_t)0x72af, (q15_t)0xc728, (q15_t)0x7282, (q15_t)0xc6ce, (q15_t)0x7255, + (q15_t)0xc674, (q15_t)0x7227, (q15_t)0xc61a, (q15_t)0x71fa, (q15_t)0xc5c0, + (q15_t)0x71cc, (q15_t)0xc567, (q15_t)0x719e, (q15_t)0xc50e, (q15_t)0x716f, + (q15_t)0xc4b4, (q15_t)0x7141, (q15_t)0xc45b, (q15_t)0x7112, (q15_t)0xc403, + (q15_t)0x70e2, (q15_t)0xc3aa, (q15_t)0x70b3, (q15_t)0xc351, (q15_t)0x7083, + (q15_t)0xc2f9, (q15_t)0x7053, (q15_t)0xc2a0, (q15_t)0x7023, (q15_t)0xc248, + (q15_t)0x6ff2, (q15_t)0xc1f0, (q15_t)0x6fc1, (q15_t)0xc198, (q15_t)0x6f90, + (q15_t)0xc141, (q15_t)0x6f5f, (q15_t)0xc0e9, (q15_t)0x6f2d, (q15_t)0xc092, + (q15_t)0x6efb, (q15_t)0xc03b, (q15_t)0x6ec9, (q15_t)0xbfe3, (q15_t)0x6e96, + (q15_t)0xbf8d, (q15_t)0x6e63, (q15_t)0xbf36, (q15_t)0x6e30, (q15_t)0xbedf, + (q15_t)0x6dfd, (q15_t)0xbe89, (q15_t)0x6dca, (q15_t)0xbe32, (q15_t)0x6d96, + (q15_t)0xbddc, (q15_t)0x6d62, (q15_t)0xbd86, (q15_t)0x6d2d, (q15_t)0xbd30, + (q15_t)0x6cf9, (q15_t)0xbcdb, (q15_t)0x6cc4, (q15_t)0xbc85, (q15_t)0x6c8f, + (q15_t)0xbc30, (q15_t)0x6c59, (q15_t)0xbbdb, (q15_t)0x6c24, (q15_t)0xbb86, + (q15_t)0x6bee, (q15_t)0xbb31, (q15_t)0x6bb8, (q15_t)0xbadc, (q15_t)0x6b81, + (q15_t)0xba88, (q15_t)0x6b4a, (q15_t)0xba33, (q15_t)0x6b13, (q15_t)0xb9df, + (q15_t)0x6adc, (q15_t)0xb98b, (q15_t)0x6aa5, (q15_t)0xb937, (q15_t)0x6a6d, + (q15_t)0xb8e4, (q15_t)0x6a35, (q15_t)0xb890, (q15_t)0x69fd, (q15_t)0xb83d, + (q15_t)0x69c4, (q15_t)0xb7ea, (q15_t)0x698c, (q15_t)0xb797, (q15_t)0x6953, + (q15_t)0xb744, (q15_t)0x6919, (q15_t)0xb6f1, (q15_t)0x68e0, (q15_t)0xb69f, + (q15_t)0x68a6, (q15_t)0xb64c, (q15_t)0x686c, (q15_t)0xb5fa, (q15_t)0x6832, + (q15_t)0xb5a8, (q15_t)0x67f7, (q15_t)0xb557, (q15_t)0x67bd, (q15_t)0xb505, + (q15_t)0x6782, (q15_t)0xb4b4, (q15_t)0x6746, (q15_t)0xb462, (q15_t)0x670b, + (q15_t)0xb411, (q15_t)0x66cf, (q15_t)0xb3c1, (q15_t)0x6693, (q15_t)0xb370, + (q15_t)0x6657, (q15_t)0xb31f, (q15_t)0x661a, (q15_t)0xb2cf, (q15_t)0x65dd, + (q15_t)0xb27f, (q15_t)0x65a0, (q15_t)0xb22f, (q15_t)0x6563, (q15_t)0xb1df, + (q15_t)0x6526, (q15_t)0xb190, (q15_t)0x64e8, (q15_t)0xb141, (q15_t)0x64aa, + (q15_t)0xb0f1, (q15_t)0x646c, (q15_t)0xb0a2, (q15_t)0x642d, (q15_t)0xb054, + (q15_t)0x63ef, (q15_t)0xb005, (q15_t)0x63b0, (q15_t)0xafb7, (q15_t)0x6371, + (q15_t)0xaf69, (q15_t)0x6331, (q15_t)0xaf1b, (q15_t)0x62f2, (q15_t)0xaecd, + (q15_t)0x62b2, (q15_t)0xae7f, (q15_t)0x6271, (q15_t)0xae32, (q15_t)0x6231, + (q15_t)0xade4, (q15_t)0x61f1, (q15_t)0xad97, (q15_t)0x61b0, (q15_t)0xad4b, + (q15_t)0x616f, (q15_t)0xacfe, (q15_t)0x612d, (q15_t)0xacb2, (q15_t)0x60ec, + (q15_t)0xac65, (q15_t)0x60aa, (q15_t)0xac19, (q15_t)0x6068, (q15_t)0xabcd, + (q15_t)0x6026, (q15_t)0xab82, (q15_t)0x5fe3, (q15_t)0xab36, (q15_t)0x5fa0, + (q15_t)0xaaeb, (q15_t)0x5f5e, (q15_t)0xaaa0, (q15_t)0x5f1a, (q15_t)0xaa55, + (q15_t)0x5ed7, (q15_t)0xaa0b, (q15_t)0x5e93, (q15_t)0xa9c0, (q15_t)0x5e50, + (q15_t)0xa976, (q15_t)0x5e0b, (q15_t)0xa92c, (q15_t)0x5dc7, (q15_t)0xa8e3, + (q15_t)0x5d83, (q15_t)0xa899, (q15_t)0x5d3e, (q15_t)0xa850, (q15_t)0x5cf9, + (q15_t)0xa807, (q15_t)0x5cb4, (q15_t)0xa7be, (q15_t)0x5c6e, (q15_t)0xa775, + (q15_t)0x5c29, (q15_t)0xa72c, (q15_t)0x5be3, (q15_t)0xa6e4, (q15_t)0x5b9d, + (q15_t)0xa69c, (q15_t)0x5b56, (q15_t)0xa654, (q15_t)0x5b10, (q15_t)0xa60d, + (q15_t)0x5ac9, (q15_t)0xa5c5, (q15_t)0x5a82, (q15_t)0xa57e, (q15_t)0x5a3b, + (q15_t)0xa537, (q15_t)0x59f3, (q15_t)0xa4f0, (q15_t)0x59ac, (q15_t)0xa4aa, + (q15_t)0x5964, (q15_t)0xa463, (q15_t)0x591c, (q15_t)0xa41d, (q15_t)0x58d4, + (q15_t)0xa3d7, (q15_t)0x588b, (q15_t)0xa392, (q15_t)0x5842, (q15_t)0xa34c, + (q15_t)0x57f9, (q15_t)0xa307, (q15_t)0x57b0, (q15_t)0xa2c2, (q15_t)0x5767, + (q15_t)0xa27d, (q15_t)0x571d, (q15_t)0xa239, (q15_t)0x56d4, (q15_t)0xa1f5, + (q15_t)0x568a, (q15_t)0xa1b0, (q15_t)0x5640, (q15_t)0xa16d, (q15_t)0x55f5, + (q15_t)0xa129, (q15_t)0x55ab, (q15_t)0xa0e6, (q15_t)0x5560, (q15_t)0xa0a2, + (q15_t)0x5515, (q15_t)0xa060, (q15_t)0x54ca, (q15_t)0xa01d, (q15_t)0x547e, + (q15_t)0x9fda, (q15_t)0x5433, (q15_t)0x9f98, (q15_t)0x53e7, (q15_t)0x9f56, + (q15_t)0x539b, (q15_t)0x9f14, (q15_t)0x534e, (q15_t)0x9ed3, (q15_t)0x5302, + (q15_t)0x9e91, (q15_t)0x52b5, (q15_t)0x9e50, (q15_t)0x5269, (q15_t)0x9e0f, + (q15_t)0x521c, (q15_t)0x9dcf, (q15_t)0x51ce, (q15_t)0x9d8f, (q15_t)0x5181, + (q15_t)0x9d4e, (q15_t)0x5133, (q15_t)0x9d0e, (q15_t)0x50e5, (q15_t)0x9ccf, + (q15_t)0x5097, (q15_t)0x9c8f, (q15_t)0x5049, (q15_t)0x9c50, (q15_t)0x4ffb, + (q15_t)0x9c11, (q15_t)0x4fac, (q15_t)0x9bd3, (q15_t)0x4f5e, (q15_t)0x9b94, + (q15_t)0x4f0f, (q15_t)0x9b56, (q15_t)0x4ebf, (q15_t)0x9b18, (q15_t)0x4e70, + (q15_t)0x9ada, (q15_t)0x4e21, (q15_t)0x9a9d, (q15_t)0x4dd1, (q15_t)0x9a60, + (q15_t)0x4d81, (q15_t)0x9a23, (q15_t)0x4d31, (q15_t)0x99e6, (q15_t)0x4ce1, + (q15_t)0x99a9, (q15_t)0x4c90, (q15_t)0x996d, (q15_t)0x4c3f, (q15_t)0x9931, + (q15_t)0x4bef, (q15_t)0x98f5, (q15_t)0x4b9e, (q15_t)0x98ba, (q15_t)0x4b4c, + (q15_t)0x987e, (q15_t)0x4afb, (q15_t)0x9843, (q15_t)0x4aa9, (q15_t)0x9809, + (q15_t)0x4a58, (q15_t)0x97ce, (q15_t)0x4a06, (q15_t)0x9794, (q15_t)0x49b4, + (q15_t)0x975a, (q15_t)0x4961, (q15_t)0x9720, (q15_t)0x490f, (q15_t)0x96e7, + (q15_t)0x48bc, (q15_t)0x96ad, (q15_t)0x4869, (q15_t)0x9674, (q15_t)0x4816, + (q15_t)0x963c, (q15_t)0x47c3, (q15_t)0x9603, (q15_t)0x4770, (q15_t)0x95cb, + (q15_t)0x471c, (q15_t)0x9593, (q15_t)0x46c9, (q15_t)0x955b, (q15_t)0x4675, + (q15_t)0x9524, (q15_t)0x4621, (q15_t)0x94ed, (q15_t)0x45cd, (q15_t)0x94b6, + (q15_t)0x4578, (q15_t)0x947f, (q15_t)0x4524, (q15_t)0x9448, (q15_t)0x44cf, + (q15_t)0x9412, (q15_t)0x447a, (q15_t)0x93dc, (q15_t)0x4425, (q15_t)0x93a7, + (q15_t)0x43d0, (q15_t)0x9371, (q15_t)0x437b, (q15_t)0x933c, (q15_t)0x4325, + (q15_t)0x9307, (q15_t)0x42d0, (q15_t)0x92d3, (q15_t)0x427a, (q15_t)0x929e, + (q15_t)0x4224, (q15_t)0x926a, (q15_t)0x41ce, (q15_t)0x9236, (q15_t)0x4177, + (q15_t)0x9203, (q15_t)0x4121, (q15_t)0x91d0, (q15_t)0x40ca, (q15_t)0x919d, + (q15_t)0x4073, (q15_t)0x916a, (q15_t)0x401d, (q15_t)0x9137, (q15_t)0x3fc5, + (q15_t)0x9105, (q15_t)0x3f6e, (q15_t)0x90d3, (q15_t)0x3f17, (q15_t)0x90a1, + (q15_t)0x3ebf, (q15_t)0x9070, (q15_t)0x3e68, (q15_t)0x903f, (q15_t)0x3e10, + (q15_t)0x900e, (q15_t)0x3db8, (q15_t)0x8fdd, (q15_t)0x3d60, (q15_t)0x8fad, + (q15_t)0x3d07, (q15_t)0x8f7d, (q15_t)0x3caf, (q15_t)0x8f4d, (q15_t)0x3c56, + (q15_t)0x8f1e, (q15_t)0x3bfd, (q15_t)0x8eee, (q15_t)0x3ba5, (q15_t)0x8ebf, + (q15_t)0x3b4c, (q15_t)0x8e91, (q15_t)0x3af2, (q15_t)0x8e62, (q15_t)0x3a99, + (q15_t)0x8e34, (q15_t)0x3a40, (q15_t)0x8e06, (q15_t)0x39e6, (q15_t)0x8dd9, + (q15_t)0x398c, (q15_t)0x8dab, (q15_t)0x3932, (q15_t)0x8d7e, (q15_t)0x38d8, + (q15_t)0x8d51, (q15_t)0x387e, (q15_t)0x8d25, (q15_t)0x3824, (q15_t)0x8cf9, + (q15_t)0x37ca, (q15_t)0x8ccd, (q15_t)0x376f, (q15_t)0x8ca1, (q15_t)0x3714, + (q15_t)0x8c76, (q15_t)0x36ba, (q15_t)0x8c4b, (q15_t)0x365f, (q15_t)0x8c20, + (q15_t)0x3604, (q15_t)0x8bf5, (q15_t)0x35a8, (q15_t)0x8bcb, (q15_t)0x354d, + (q15_t)0x8ba1, (q15_t)0x34f2, (q15_t)0x8b77, (q15_t)0x3496, (q15_t)0x8b4e, + (q15_t)0x343a, (q15_t)0x8b25, (q15_t)0x33de, (q15_t)0x8afc, (q15_t)0x3382, + (q15_t)0x8ad3, (q15_t)0x3326, (q15_t)0x8aab, (q15_t)0x32ca, (q15_t)0x8a83, + (q15_t)0x326e, (q15_t)0x8a5b, (q15_t)0x3211, (q15_t)0x8a34, (q15_t)0x31b5, + (q15_t)0x8a0c, (q15_t)0x3158, (q15_t)0x89e5, (q15_t)0x30fb, (q15_t)0x89bf, + (q15_t)0x309e, (q15_t)0x8998, (q15_t)0x3041, (q15_t)0x8972, (q15_t)0x2fe4, + (q15_t)0x894d, (q15_t)0x2f87, (q15_t)0x8927, (q15_t)0x2f29, (q15_t)0x8902, + (q15_t)0x2ecc, (q15_t)0x88dd, (q15_t)0x2e6e, (q15_t)0x88b9, (q15_t)0x2e11, + (q15_t)0x8894, (q15_t)0x2db3, (q15_t)0x8870, (q15_t)0x2d55, (q15_t)0x884c, + (q15_t)0x2cf7, (q15_t)0x8829, (q15_t)0x2c98, (q15_t)0x8806, (q15_t)0x2c3a, + (q15_t)0x87e3, (q15_t)0x2bdc, (q15_t)0x87c0, (q15_t)0x2b7d, (q15_t)0x879e, + (q15_t)0x2b1f, (q15_t)0x877c, (q15_t)0x2ac0, (q15_t)0x875a, (q15_t)0x2a61, + (q15_t)0x8739, (q15_t)0x2a02, (q15_t)0x8718, (q15_t)0x29a3, (q15_t)0x86f7, + (q15_t)0x2944, (q15_t)0x86d6, (q15_t)0x28e5, (q15_t)0x86b6, (q15_t)0x2886, + (q15_t)0x8696, (q15_t)0x2826, (q15_t)0x8676, (q15_t)0x27c7, (q15_t)0x8657, + (q15_t)0x2767, (q15_t)0x8638, (q15_t)0x2707, (q15_t)0x8619, (q15_t)0x26a8, + (q15_t)0x85fb, (q15_t)0x2648, (q15_t)0x85dc, (q15_t)0x25e8, (q15_t)0x85be, + (q15_t)0x2588, (q15_t)0x85a1, (q15_t)0x2528, (q15_t)0x8583, (q15_t)0x24c7, + (q15_t)0x8566, (q15_t)0x2467, (q15_t)0x854a, (q15_t)0x2407, (q15_t)0x852d, + (q15_t)0x23a6, (q15_t)0x8511, (q15_t)0x2345, (q15_t)0x84f5, (q15_t)0x22e5, + (q15_t)0x84da, (q15_t)0x2284, (q15_t)0x84be, (q15_t)0x2223, (q15_t)0x84a3, + (q15_t)0x21c2, (q15_t)0x8489, (q15_t)0x2161, (q15_t)0x846e, (q15_t)0x2100, + (q15_t)0x8454, (q15_t)0x209f, (q15_t)0x843b, (q15_t)0x203e, (q15_t)0x8421, + (q15_t)0x1fdc, (q15_t)0x8408, (q15_t)0x1f7b, (q15_t)0x83ef, (q15_t)0x1f19, + (q15_t)0x83d7, (q15_t)0x1eb8, (q15_t)0x83be, (q15_t)0x1e56, (q15_t)0x83a6, + (q15_t)0x1df5, (q15_t)0x838f, (q15_t)0x1d93, (q15_t)0x8377, (q15_t)0x1d31, + (q15_t)0x8360, (q15_t)0x1ccf, (q15_t)0x8349, (q15_t)0x1c6d, (q15_t)0x8333, + (q15_t)0x1c0b, (q15_t)0x831d, (q15_t)0x1ba9, (q15_t)0x8307, (q15_t)0x1b47, + (q15_t)0x82f1, (q15_t)0x1ae4, (q15_t)0x82dc, (q15_t)0x1a82, (q15_t)0x82c7, + (q15_t)0x1a20, (q15_t)0x82b2, (q15_t)0x19bd, (q15_t)0x829e, (q15_t)0x195b, + (q15_t)0x828a, (q15_t)0x18f8, (q15_t)0x8276, (q15_t)0x1896, (q15_t)0x8263, + (q15_t)0x1833, (q15_t)0x8250, (q15_t)0x17d0, (q15_t)0x823d, (q15_t)0x176d, + (q15_t)0x822a, (q15_t)0x170a, (q15_t)0x8218, (q15_t)0x16a8, (q15_t)0x8206, + (q15_t)0x1645, (q15_t)0x81f4, (q15_t)0x15e2, (q15_t)0x81e3, (q15_t)0x157f, + (q15_t)0x81d2, (q15_t)0x151b, (q15_t)0x81c1, (q15_t)0x14b8, (q15_t)0x81b1, + (q15_t)0x1455, (q15_t)0x81a1, (q15_t)0x13f2, (q15_t)0x8191, (q15_t)0x138e, + (q15_t)0x8181, (q15_t)0x132b, (q15_t)0x8172, (q15_t)0x12c8, (q15_t)0x8163, + (q15_t)0x1264, (q15_t)0x8155, (q15_t)0x1201, (q15_t)0x8146, (q15_t)0x119d, + (q15_t)0x8138, (q15_t)0x1139, (q15_t)0x812b, (q15_t)0x10d6, (q15_t)0x811d, + (q15_t)0x1072, (q15_t)0x8110, (q15_t)0x100e, (q15_t)0x8103, (q15_t)0xfab, + (q15_t)0x80f7, (q15_t)0xf47, (q15_t)0x80eb, (q15_t)0xee3, (q15_t)0x80df, + (q15_t)0xe7f, (q15_t)0x80d3, (q15_t)0xe1b, (q15_t)0x80c8, (q15_t)0xdb7, + (q15_t)0x80bd, (q15_t)0xd53, (q15_t)0x80b3, (q15_t)0xcef, (q15_t)0x80a8, + (q15_t)0xc8b, (q15_t)0x809e, (q15_t)0xc27, (q15_t)0x8095, (q15_t)0xbc3, + (q15_t)0x808b, (q15_t)0xb5f, (q15_t)0x8082, (q15_t)0xafb, (q15_t)0x8079, + (q15_t)0xa97, (q15_t)0x8071, (q15_t)0xa33, (q15_t)0x8069, (q15_t)0x9ce, + (q15_t)0x8061, (q15_t)0x96a, (q15_t)0x8059, (q15_t)0x906, (q15_t)0x8052, + (q15_t)0x8a2, (q15_t)0x804b, (q15_t)0x83d, (q15_t)0x8044, (q15_t)0x7d9, + (q15_t)0x803e, (q15_t)0x775, (q15_t)0x8038, (q15_t)0x710, (q15_t)0x8032, + (q15_t)0x6ac, (q15_t)0x802d, (q15_t)0x647, (q15_t)0x8028, (q15_t)0x5e3, + (q15_t)0x8023, (q15_t)0x57f, (q15_t)0x801f, (q15_t)0x51a, (q15_t)0x801b, + (q15_t)0x4b6, (q15_t)0x8017, (q15_t)0x451, (q15_t)0x8013, (q15_t)0x3ed, + (q15_t)0x8010, (q15_t)0x388, (q15_t)0x800d, (q15_t)0x324, (q15_t)0x800a, + (q15_t)0x2bf, (q15_t)0x8008, (q15_t)0x25b, (q15_t)0x8006, (q15_t)0x1f6, + (q15_t)0x8004, (q15_t)0x192, (q15_t)0x8003, (q15_t)0x12d, (q15_t)0x8002, + (q15_t)0xc9, (q15_t)0x8001, (q15_t)0x64, (q15_t)0x8001}; static const q15_t __ALIGNED(4) WeightsQ15_2048[4096] = { - (q15_t)0x7fff, (q15_t)0x0, (q15_t)0x7fff, (q15_t)0xffe7, (q15_t)0x7fff, (q15_t)0xffce, (q15_t)0x7fff, (q15_t)0xffb5, - (q15_t)0x7fff, (q15_t)0xff9c, (q15_t)0x7fff, (q15_t)0xff83, (q15_t)0x7fff, (q15_t)0xff6a, (q15_t)0x7fff, (q15_t)0xff51, - (q15_t)0x7fff, (q15_t)0xff37, (q15_t)0x7fff, (q15_t)0xff1e, (q15_t)0x7fff, (q15_t)0xff05, (q15_t)0x7ffe, (q15_t)0xfeec, - (q15_t)0x7ffe, (q15_t)0xfed3, (q15_t)0x7ffe, (q15_t)0xfeba, (q15_t)0x7ffe, (q15_t)0xfea1, (q15_t)0x7ffd, (q15_t)0xfe88, - (q15_t)0x7ffd, (q15_t)0xfe6e, (q15_t)0x7ffd, (q15_t)0xfe55, (q15_t)0x7ffc, (q15_t)0xfe3c, (q15_t)0x7ffc, (q15_t)0xfe23, - (q15_t)0x7ffc, (q15_t)0xfe0a, (q15_t)0x7ffb, (q15_t)0xfdf1, (q15_t)0x7ffb, (q15_t)0xfdd8, (q15_t)0x7ffa, (q15_t)0xfdbe, - (q15_t)0x7ffa, (q15_t)0xfda5, (q15_t)0x7ff9, (q15_t)0xfd8c, (q15_t)0x7ff9, (q15_t)0xfd73, (q15_t)0x7ff8, (q15_t)0xfd5a, - (q15_t)0x7ff8, (q15_t)0xfd41, (q15_t)0x7ff7, (q15_t)0xfd28, (q15_t)0x7ff7, (q15_t)0xfd0f, (q15_t)0x7ff6, (q15_t)0xfcf5, - (q15_t)0x7ff6, (q15_t)0xfcdc, (q15_t)0x7ff5, (q15_t)0xfcc3, (q15_t)0x7ff4, (q15_t)0xfcaa, (q15_t)0x7ff4, (q15_t)0xfc91, - (q15_t)0x7ff3, (q15_t)0xfc78, (q15_t)0x7ff2, (q15_t)0xfc5f, (q15_t)0x7ff2, (q15_t)0xfc46, (q15_t)0x7ff1, (q15_t)0xfc2c, - (q15_t)0x7ff0, (q15_t)0xfc13, (q15_t)0x7fef, (q15_t)0xfbfa, (q15_t)0x7fee, (q15_t)0xfbe1, (q15_t)0x7fee, (q15_t)0xfbc8, - (q15_t)0x7fed, (q15_t)0xfbaf, (q15_t)0x7fec, (q15_t)0xfb96, (q15_t)0x7feb, (q15_t)0xfb7d, (q15_t)0x7fea, (q15_t)0xfb64, - (q15_t)0x7fe9, (q15_t)0xfb4a, (q15_t)0x7fe8, (q15_t)0xfb31, (q15_t)0x7fe7, (q15_t)0xfb18, (q15_t)0x7fe6, (q15_t)0xfaff, - (q15_t)0x7fe5, (q15_t)0xfae6, (q15_t)0x7fe4, (q15_t)0xfacd, (q15_t)0x7fe3, (q15_t)0xfab4, (q15_t)0x7fe2, (q15_t)0xfa9b, - (q15_t)0x7fe1, (q15_t)0xfa81, (q15_t)0x7fe0, (q15_t)0xfa68, (q15_t)0x7fdf, (q15_t)0xfa4f, (q15_t)0x7fde, (q15_t)0xfa36, - (q15_t)0x7fdd, (q15_t)0xfa1d, (q15_t)0x7fdc, (q15_t)0xfa04, (q15_t)0x7fda, (q15_t)0xf9eb, (q15_t)0x7fd9, (q15_t)0xf9d2, - (q15_t)0x7fd8, (q15_t)0xf9b9, (q15_t)0x7fd7, (q15_t)0xf9a0, (q15_t)0x7fd6, (q15_t)0xf986, (q15_t)0x7fd4, (q15_t)0xf96d, - (q15_t)0x7fd3, (q15_t)0xf954, (q15_t)0x7fd2, (q15_t)0xf93b, (q15_t)0x7fd0, (q15_t)0xf922, (q15_t)0x7fcf, (q15_t)0xf909, - (q15_t)0x7fce, (q15_t)0xf8f0, (q15_t)0x7fcc, (q15_t)0xf8d7, (q15_t)0x7fcb, (q15_t)0xf8be, (q15_t)0x7fc9, (q15_t)0xf8a5, - (q15_t)0x7fc8, (q15_t)0xf88b, (q15_t)0x7fc6, (q15_t)0xf872, (q15_t)0x7fc5, (q15_t)0xf859, (q15_t)0x7fc3, (q15_t)0xf840, - (q15_t)0x7fc2, (q15_t)0xf827, (q15_t)0x7fc0, (q15_t)0xf80e, (q15_t)0x7fbf, (q15_t)0xf7f5, (q15_t)0x7fbd, (q15_t)0xf7dc, - (q15_t)0x7fbc, (q15_t)0xf7c3, (q15_t)0x7fba, (q15_t)0xf7aa, (q15_t)0x7fb8, (q15_t)0xf791, (q15_t)0x7fb7, (q15_t)0xf778, - (q15_t)0x7fb5, (q15_t)0xf75e, (q15_t)0x7fb3, (q15_t)0xf745, (q15_t)0x7fb1, (q15_t)0xf72c, (q15_t)0x7fb0, (q15_t)0xf713, - (q15_t)0x7fae, (q15_t)0xf6fa, (q15_t)0x7fac, (q15_t)0xf6e1, (q15_t)0x7faa, (q15_t)0xf6c8, (q15_t)0x7fa9, (q15_t)0xf6af, - (q15_t)0x7fa7, (q15_t)0xf696, (q15_t)0x7fa5, (q15_t)0xf67d, (q15_t)0x7fa3, (q15_t)0xf664, (q15_t)0x7fa1, (q15_t)0xf64b, - (q15_t)0x7f9f, (q15_t)0xf632, (q15_t)0x7f9d, (q15_t)0xf619, (q15_t)0x7f9b, (q15_t)0xf600, (q15_t)0x7f99, (q15_t)0xf5e7, - (q15_t)0x7f97, (q15_t)0xf5cd, (q15_t)0x7f95, (q15_t)0xf5b4, (q15_t)0x7f93, (q15_t)0xf59b, (q15_t)0x7f91, (q15_t)0xf582, - (q15_t)0x7f8f, (q15_t)0xf569, (q15_t)0x7f8d, (q15_t)0xf550, (q15_t)0x7f8b, (q15_t)0xf537, (q15_t)0x7f89, (q15_t)0xf51e, - (q15_t)0x7f87, (q15_t)0xf505, (q15_t)0x7f85, (q15_t)0xf4ec, (q15_t)0x7f82, (q15_t)0xf4d3, (q15_t)0x7f80, (q15_t)0xf4ba, - (q15_t)0x7f7e, (q15_t)0xf4a1, (q15_t)0x7f7c, (q15_t)0xf488, (q15_t)0x7f79, (q15_t)0xf46f, (q15_t)0x7f77, (q15_t)0xf456, - (q15_t)0x7f75, (q15_t)0xf43d, (q15_t)0x7f72, (q15_t)0xf424, (q15_t)0x7f70, (q15_t)0xf40b, (q15_t)0x7f6e, (q15_t)0xf3f2, - (q15_t)0x7f6b, (q15_t)0xf3d9, (q15_t)0x7f69, (q15_t)0xf3c0, (q15_t)0x7f67, (q15_t)0xf3a7, (q15_t)0x7f64, (q15_t)0xf38e, - (q15_t)0x7f62, (q15_t)0xf375, (q15_t)0x7f5f, (q15_t)0xf35c, (q15_t)0x7f5d, (q15_t)0xf343, (q15_t)0x7f5a, (q15_t)0xf32a, - (q15_t)0x7f58, (q15_t)0xf311, (q15_t)0x7f55, (q15_t)0xf2f8, (q15_t)0x7f53, (q15_t)0xf2df, (q15_t)0x7f50, (q15_t)0xf2c6, - (q15_t)0x7f4d, (q15_t)0xf2ad, (q15_t)0x7f4b, (q15_t)0xf294, (q15_t)0x7f48, (q15_t)0xf27b, (q15_t)0x7f45, (q15_t)0xf262, - (q15_t)0x7f43, (q15_t)0xf249, (q15_t)0x7f40, (q15_t)0xf230, (q15_t)0x7f3d, (q15_t)0xf217, (q15_t)0x7f3b, (q15_t)0xf1fe, - (q15_t)0x7f38, (q15_t)0xf1e5, (q15_t)0x7f35, (q15_t)0xf1cc, (q15_t)0x7f32, (q15_t)0xf1b3, (q15_t)0x7f2f, (q15_t)0xf19a, - (q15_t)0x7f2d, (q15_t)0xf181, (q15_t)0x7f2a, (q15_t)0xf168, (q15_t)0x7f27, (q15_t)0xf14f, (q15_t)0x7f24, (q15_t)0xf136, - (q15_t)0x7f21, (q15_t)0xf11d, (q15_t)0x7f1e, (q15_t)0xf104, (q15_t)0x7f1b, (q15_t)0xf0eb, (q15_t)0x7f18, (q15_t)0xf0d2, - (q15_t)0x7f15, (q15_t)0xf0b9, (q15_t)0x7f12, (q15_t)0xf0a0, (q15_t)0x7f0f, (q15_t)0xf087, (q15_t)0x7f0c, (q15_t)0xf06e, - (q15_t)0x7f09, (q15_t)0xf055, (q15_t)0x7f06, (q15_t)0xf03c, (q15_t)0x7f03, (q15_t)0xf023, (q15_t)0x7f00, (q15_t)0xf00b, - (q15_t)0x7efd, (q15_t)0xeff2, (q15_t)0x7ef9, (q15_t)0xefd9, (q15_t)0x7ef6, (q15_t)0xefc0, (q15_t)0x7ef3, (q15_t)0xefa7, - (q15_t)0x7ef0, (q15_t)0xef8e, (q15_t)0x7eed, (q15_t)0xef75, (q15_t)0x7ee9, (q15_t)0xef5c, (q15_t)0x7ee6, (q15_t)0xef43, - (q15_t)0x7ee3, (q15_t)0xef2a, (q15_t)0x7edf, (q15_t)0xef11, (q15_t)0x7edc, (q15_t)0xeef8, (q15_t)0x7ed9, (q15_t)0xeedf, - (q15_t)0x7ed5, (q15_t)0xeec7, (q15_t)0x7ed2, (q15_t)0xeeae, (q15_t)0x7ecf, (q15_t)0xee95, (q15_t)0x7ecb, (q15_t)0xee7c, - (q15_t)0x7ec8, (q15_t)0xee63, (q15_t)0x7ec4, (q15_t)0xee4a, (q15_t)0x7ec1, (q15_t)0xee31, (q15_t)0x7ebd, (q15_t)0xee18, - (q15_t)0x7eba, (q15_t)0xedff, (q15_t)0x7eb6, (q15_t)0xede7, (q15_t)0x7eb3, (q15_t)0xedce, (q15_t)0x7eaf, (q15_t)0xedb5, - (q15_t)0x7eab, (q15_t)0xed9c, (q15_t)0x7ea8, (q15_t)0xed83, (q15_t)0x7ea4, (q15_t)0xed6a, (q15_t)0x7ea1, (q15_t)0xed51, - (q15_t)0x7e9d, (q15_t)0xed38, (q15_t)0x7e99, (q15_t)0xed20, (q15_t)0x7e95, (q15_t)0xed07, (q15_t)0x7e92, (q15_t)0xecee, - (q15_t)0x7e8e, (q15_t)0xecd5, (q15_t)0x7e8a, (q15_t)0xecbc, (q15_t)0x7e86, (q15_t)0xeca3, (q15_t)0x7e83, (q15_t)0xec8a, - (q15_t)0x7e7f, (q15_t)0xec72, (q15_t)0x7e7b, (q15_t)0xec59, (q15_t)0x7e77, (q15_t)0xec40, (q15_t)0x7e73, (q15_t)0xec27, - (q15_t)0x7e6f, (q15_t)0xec0e, (q15_t)0x7e6b, (q15_t)0xebf5, (q15_t)0x7e67, (q15_t)0xebdd, (q15_t)0x7e63, (q15_t)0xebc4, - (q15_t)0x7e5f, (q15_t)0xebab, (q15_t)0x7e5b, (q15_t)0xeb92, (q15_t)0x7e57, (q15_t)0xeb79, (q15_t)0x7e53, (q15_t)0xeb61, - (q15_t)0x7e4f, (q15_t)0xeb48, (q15_t)0x7e4b, (q15_t)0xeb2f, (q15_t)0x7e47, (q15_t)0xeb16, (q15_t)0x7e43, (q15_t)0xeafd, - (q15_t)0x7e3f, (q15_t)0xeae5, (q15_t)0x7e3b, (q15_t)0xeacc, (q15_t)0x7e37, (q15_t)0xeab3, (q15_t)0x7e32, (q15_t)0xea9a, - (q15_t)0x7e2e, (q15_t)0xea81, (q15_t)0x7e2a, (q15_t)0xea69, (q15_t)0x7e26, (q15_t)0xea50, (q15_t)0x7e21, (q15_t)0xea37, - (q15_t)0x7e1d, (q15_t)0xea1e, (q15_t)0x7e19, (q15_t)0xea06, (q15_t)0x7e14, (q15_t)0xe9ed, (q15_t)0x7e10, (q15_t)0xe9d4, - (q15_t)0x7e0c, (q15_t)0xe9bb, (q15_t)0x7e07, (q15_t)0xe9a3, (q15_t)0x7e03, (q15_t)0xe98a, (q15_t)0x7dff, (q15_t)0xe971, - (q15_t)0x7dfa, (q15_t)0xe958, (q15_t)0x7df6, (q15_t)0xe940, (q15_t)0x7df1, (q15_t)0xe927, (q15_t)0x7ded, (q15_t)0xe90e, - (q15_t)0x7de8, (q15_t)0xe8f6, (q15_t)0x7de4, (q15_t)0xe8dd, (q15_t)0x7ddf, (q15_t)0xe8c4, (q15_t)0x7dda, (q15_t)0xe8ab, - (q15_t)0x7dd6, (q15_t)0xe893, (q15_t)0x7dd1, (q15_t)0xe87a, (q15_t)0x7dcd, (q15_t)0xe861, (q15_t)0x7dc8, (q15_t)0xe849, - (q15_t)0x7dc3, (q15_t)0xe830, (q15_t)0x7dbf, (q15_t)0xe817, (q15_t)0x7dba, (q15_t)0xe7fe, (q15_t)0x7db5, (q15_t)0xe7e6, - (q15_t)0x7db0, (q15_t)0xe7cd, (q15_t)0x7dac, (q15_t)0xe7b4, (q15_t)0x7da7, (q15_t)0xe79c, (q15_t)0x7da2, (q15_t)0xe783, - (q15_t)0x7d9d, (q15_t)0xe76a, (q15_t)0x7d98, (q15_t)0xe752, (q15_t)0x7d94, (q15_t)0xe739, (q15_t)0x7d8f, (q15_t)0xe720, - (q15_t)0x7d8a, (q15_t)0xe708, (q15_t)0x7d85, (q15_t)0xe6ef, (q15_t)0x7d80, (q15_t)0xe6d6, (q15_t)0x7d7b, (q15_t)0xe6be, - (q15_t)0x7d76, (q15_t)0xe6a5, (q15_t)0x7d71, (q15_t)0xe68d, (q15_t)0x7d6c, (q15_t)0xe674, (q15_t)0x7d67, (q15_t)0xe65b, - (q15_t)0x7d62, (q15_t)0xe643, (q15_t)0x7d5d, (q15_t)0xe62a, (q15_t)0x7d58, (q15_t)0xe611, (q15_t)0x7d53, (q15_t)0xe5f9, - (q15_t)0x7d4e, (q15_t)0xe5e0, (q15_t)0x7d49, (q15_t)0xe5c8, (q15_t)0x7d43, (q15_t)0xe5af, (q15_t)0x7d3e, (q15_t)0xe596, - (q15_t)0x7d39, (q15_t)0xe57e, (q15_t)0x7d34, (q15_t)0xe565, (q15_t)0x7d2f, (q15_t)0xe54d, (q15_t)0x7d29, (q15_t)0xe534, - (q15_t)0x7d24, (q15_t)0xe51c, (q15_t)0x7d1f, (q15_t)0xe503, (q15_t)0x7d19, (q15_t)0xe4ea, (q15_t)0x7d14, (q15_t)0xe4d2, - (q15_t)0x7d0f, (q15_t)0xe4b9, (q15_t)0x7d09, (q15_t)0xe4a1, (q15_t)0x7d04, (q15_t)0xe488, (q15_t)0x7cff, (q15_t)0xe470, - (q15_t)0x7cf9, (q15_t)0xe457, (q15_t)0x7cf4, (q15_t)0xe43f, (q15_t)0x7cee, (q15_t)0xe426, (q15_t)0x7ce9, (q15_t)0xe40e, - (q15_t)0x7ce3, (q15_t)0xe3f5, (q15_t)0x7cde, (q15_t)0xe3dc, (q15_t)0x7cd8, (q15_t)0xe3c4, (q15_t)0x7cd3, (q15_t)0xe3ab, - (q15_t)0x7ccd, (q15_t)0xe393, (q15_t)0x7cc8, (q15_t)0xe37a, (q15_t)0x7cc2, (q15_t)0xe362, (q15_t)0x7cbc, (q15_t)0xe349, - (q15_t)0x7cb7, (q15_t)0xe331, (q15_t)0x7cb1, (q15_t)0xe318, (q15_t)0x7cab, (q15_t)0xe300, (q15_t)0x7ca6, (q15_t)0xe2e8, - (q15_t)0x7ca0, (q15_t)0xe2cf, (q15_t)0x7c9a, (q15_t)0xe2b7, (q15_t)0x7c94, (q15_t)0xe29e, (q15_t)0x7c8f, (q15_t)0xe286, - (q15_t)0x7c89, (q15_t)0xe26d, (q15_t)0x7c83, (q15_t)0xe255, (q15_t)0x7c7d, (q15_t)0xe23c, (q15_t)0x7c77, (q15_t)0xe224, - (q15_t)0x7c71, (q15_t)0xe20b, (q15_t)0x7c6c, (q15_t)0xe1f3, (q15_t)0x7c66, (q15_t)0xe1db, (q15_t)0x7c60, (q15_t)0xe1c2, - (q15_t)0x7c5a, (q15_t)0xe1aa, (q15_t)0x7c54, (q15_t)0xe191, (q15_t)0x7c4e, (q15_t)0xe179, (q15_t)0x7c48, (q15_t)0xe160, - (q15_t)0x7c42, (q15_t)0xe148, (q15_t)0x7c3c, (q15_t)0xe130, (q15_t)0x7c36, (q15_t)0xe117, (q15_t)0x7c30, (q15_t)0xe0ff, - (q15_t)0x7c29, (q15_t)0xe0e7, (q15_t)0x7c23, (q15_t)0xe0ce, (q15_t)0x7c1d, (q15_t)0xe0b6, (q15_t)0x7c17, (q15_t)0xe09d, - (q15_t)0x7c11, (q15_t)0xe085, (q15_t)0x7c0b, (q15_t)0xe06d, (q15_t)0x7c05, (q15_t)0xe054, (q15_t)0x7bfe, (q15_t)0xe03c, - (q15_t)0x7bf8, (q15_t)0xe024, (q15_t)0x7bf2, (q15_t)0xe00b, (q15_t)0x7beb, (q15_t)0xdff3, (q15_t)0x7be5, (q15_t)0xdfdb, - (q15_t)0x7bdf, (q15_t)0xdfc2, (q15_t)0x7bd9, (q15_t)0xdfaa, (q15_t)0x7bd2, (q15_t)0xdf92, (q15_t)0x7bcc, (q15_t)0xdf79, - (q15_t)0x7bc5, (q15_t)0xdf61, (q15_t)0x7bbf, (q15_t)0xdf49, (q15_t)0x7bb9, (q15_t)0xdf30, (q15_t)0x7bb2, (q15_t)0xdf18, - (q15_t)0x7bac, (q15_t)0xdf00, (q15_t)0x7ba5, (q15_t)0xdee8, (q15_t)0x7b9f, (q15_t)0xdecf, (q15_t)0x7b98, (q15_t)0xdeb7, - (q15_t)0x7b92, (q15_t)0xde9f, (q15_t)0x7b8b, (q15_t)0xde87, (q15_t)0x7b84, (q15_t)0xde6e, (q15_t)0x7b7e, (q15_t)0xde56, - (q15_t)0x7b77, (q15_t)0xde3e, (q15_t)0x7b71, (q15_t)0xde26, (q15_t)0x7b6a, (q15_t)0xde0d, (q15_t)0x7b63, (q15_t)0xddf5, - (q15_t)0x7b5d, (q15_t)0xdddd, (q15_t)0x7b56, (q15_t)0xddc5, (q15_t)0x7b4f, (q15_t)0xddac, (q15_t)0x7b48, (q15_t)0xdd94, - (q15_t)0x7b42, (q15_t)0xdd7c, (q15_t)0x7b3b, (q15_t)0xdd64, (q15_t)0x7b34, (q15_t)0xdd4c, (q15_t)0x7b2d, (q15_t)0xdd33, - (q15_t)0x7b26, (q15_t)0xdd1b, (q15_t)0x7b1f, (q15_t)0xdd03, (q15_t)0x7b19, (q15_t)0xdceb, (q15_t)0x7b12, (q15_t)0xdcd3, - (q15_t)0x7b0b, (q15_t)0xdcbb, (q15_t)0x7b04, (q15_t)0xdca2, (q15_t)0x7afd, (q15_t)0xdc8a, (q15_t)0x7af6, (q15_t)0xdc72, - (q15_t)0x7aef, (q15_t)0xdc5a, (q15_t)0x7ae8, (q15_t)0xdc42, (q15_t)0x7ae1, (q15_t)0xdc2a, (q15_t)0x7ada, (q15_t)0xdc12, - (q15_t)0x7ad3, (q15_t)0xdbf9, (q15_t)0x7acc, (q15_t)0xdbe1, (q15_t)0x7ac5, (q15_t)0xdbc9, (q15_t)0x7abd, (q15_t)0xdbb1, - (q15_t)0x7ab6, (q15_t)0xdb99, (q15_t)0x7aaf, (q15_t)0xdb81, (q15_t)0x7aa8, (q15_t)0xdb69, (q15_t)0x7aa1, (q15_t)0xdb51, - (q15_t)0x7a9a, (q15_t)0xdb39, (q15_t)0x7a92, (q15_t)0xdb21, (q15_t)0x7a8b, (q15_t)0xdb09, (q15_t)0x7a84, (q15_t)0xdaf1, - (q15_t)0x7a7d, (q15_t)0xdad8, (q15_t)0x7a75, (q15_t)0xdac0, (q15_t)0x7a6e, (q15_t)0xdaa8, (q15_t)0x7a67, (q15_t)0xda90, - (q15_t)0x7a5f, (q15_t)0xda78, (q15_t)0x7a58, (q15_t)0xda60, (q15_t)0x7a50, (q15_t)0xda48, (q15_t)0x7a49, (q15_t)0xda30, - (q15_t)0x7a42, (q15_t)0xda18, (q15_t)0x7a3a, (q15_t)0xda00, (q15_t)0x7a33, (q15_t)0xd9e8, (q15_t)0x7a2b, (q15_t)0xd9d0, - (q15_t)0x7a24, (q15_t)0xd9b8, (q15_t)0x7a1c, (q15_t)0xd9a0, (q15_t)0x7a15, (q15_t)0xd988, (q15_t)0x7a0d, (q15_t)0xd970, - (q15_t)0x7a05, (q15_t)0xd958, (q15_t)0x79fe, (q15_t)0xd940, (q15_t)0x79f6, (q15_t)0xd928, (q15_t)0x79ef, (q15_t)0xd911, - (q15_t)0x79e7, (q15_t)0xd8f9, (q15_t)0x79df, (q15_t)0xd8e1, (q15_t)0x79d8, (q15_t)0xd8c9, (q15_t)0x79d0, (q15_t)0xd8b1, - (q15_t)0x79c8, (q15_t)0xd899, (q15_t)0x79c0, (q15_t)0xd881, (q15_t)0x79b9, (q15_t)0xd869, (q15_t)0x79b1, (q15_t)0xd851, - (q15_t)0x79a9, (q15_t)0xd839, (q15_t)0x79a1, (q15_t)0xd821, (q15_t)0x7999, (q15_t)0xd80a, (q15_t)0x7992, (q15_t)0xd7f2, - (q15_t)0x798a, (q15_t)0xd7da, (q15_t)0x7982, (q15_t)0xd7c2, (q15_t)0x797a, (q15_t)0xd7aa, (q15_t)0x7972, (q15_t)0xd792, - (q15_t)0x796a, (q15_t)0xd77a, (q15_t)0x7962, (q15_t)0xd763, (q15_t)0x795a, (q15_t)0xd74b, (q15_t)0x7952, (q15_t)0xd733, - (q15_t)0x794a, (q15_t)0xd71b, (q15_t)0x7942, (q15_t)0xd703, (q15_t)0x793a, (q15_t)0xd6eb, (q15_t)0x7932, (q15_t)0xd6d4, - (q15_t)0x792a, (q15_t)0xd6bc, (q15_t)0x7922, (q15_t)0xd6a4, (q15_t)0x7919, (q15_t)0xd68c, (q15_t)0x7911, (q15_t)0xd675, - (q15_t)0x7909, (q15_t)0xd65d, (q15_t)0x7901, (q15_t)0xd645, (q15_t)0x78f9, (q15_t)0xd62d, (q15_t)0x78f1, (q15_t)0xd615, - (q15_t)0x78e8, (q15_t)0xd5fe, (q15_t)0x78e0, (q15_t)0xd5e6, (q15_t)0x78d8, (q15_t)0xd5ce, (q15_t)0x78cf, (q15_t)0xd5b7, - (q15_t)0x78c7, (q15_t)0xd59f, (q15_t)0x78bf, (q15_t)0xd587, (q15_t)0x78b6, (q15_t)0xd56f, (q15_t)0x78ae, (q15_t)0xd558, - (q15_t)0x78a6, (q15_t)0xd540, (q15_t)0x789d, (q15_t)0xd528, (q15_t)0x7895, (q15_t)0xd511, (q15_t)0x788c, (q15_t)0xd4f9, - (q15_t)0x7884, (q15_t)0xd4e1, (q15_t)0x787c, (q15_t)0xd4ca, (q15_t)0x7873, (q15_t)0xd4b2, (q15_t)0x786b, (q15_t)0xd49a, - (q15_t)0x7862, (q15_t)0xd483, (q15_t)0x7859, (q15_t)0xd46b, (q15_t)0x7851, (q15_t)0xd453, (q15_t)0x7848, (q15_t)0xd43c, - (q15_t)0x7840, (q15_t)0xd424, (q15_t)0x7837, (q15_t)0xd40d, (q15_t)0x782e, (q15_t)0xd3f5, (q15_t)0x7826, (q15_t)0xd3dd, - (q15_t)0x781d, (q15_t)0xd3c6, (q15_t)0x7814, (q15_t)0xd3ae, (q15_t)0x780c, (q15_t)0xd397, (q15_t)0x7803, (q15_t)0xd37f, - (q15_t)0x77fa, (q15_t)0xd368, (q15_t)0x77f1, (q15_t)0xd350, (q15_t)0x77e9, (q15_t)0xd338, (q15_t)0x77e0, (q15_t)0xd321, - (q15_t)0x77d7, (q15_t)0xd309, (q15_t)0x77ce, (q15_t)0xd2f2, (q15_t)0x77c5, (q15_t)0xd2da, (q15_t)0x77bc, (q15_t)0xd2c3, - (q15_t)0x77b4, (q15_t)0xd2ab, (q15_t)0x77ab, (q15_t)0xd294, (q15_t)0x77a2, (q15_t)0xd27c, (q15_t)0x7799, (q15_t)0xd265, - (q15_t)0x7790, (q15_t)0xd24d, (q15_t)0x7787, (q15_t)0xd236, (q15_t)0x777e, (q15_t)0xd21e, (q15_t)0x7775, (q15_t)0xd207, - (q15_t)0x776c, (q15_t)0xd1ef, (q15_t)0x7763, (q15_t)0xd1d8, (q15_t)0x775a, (q15_t)0xd1c1, (q15_t)0x7751, (q15_t)0xd1a9, - (q15_t)0x7747, (q15_t)0xd192, (q15_t)0x773e, (q15_t)0xd17a, (q15_t)0x7735, (q15_t)0xd163, (q15_t)0x772c, (q15_t)0xd14b, - (q15_t)0x7723, (q15_t)0xd134, (q15_t)0x771a, (q15_t)0xd11d, (q15_t)0x7710, (q15_t)0xd105, (q15_t)0x7707, (q15_t)0xd0ee, - (q15_t)0x76fe, (q15_t)0xd0d7, (q15_t)0x76f5, (q15_t)0xd0bf, (q15_t)0x76eb, (q15_t)0xd0a8, (q15_t)0x76e2, (q15_t)0xd091, - (q15_t)0x76d9, (q15_t)0xd079, (q15_t)0x76cf, (q15_t)0xd062, (q15_t)0x76c6, (q15_t)0xd04b, (q15_t)0x76bd, (q15_t)0xd033, - (q15_t)0x76b3, (q15_t)0xd01c, (q15_t)0x76aa, (q15_t)0xd005, (q15_t)0x76a0, (q15_t)0xcfed, (q15_t)0x7697, (q15_t)0xcfd6, - (q15_t)0x768e, (q15_t)0xcfbf, (q15_t)0x7684, (q15_t)0xcfa7, (q15_t)0x767b, (q15_t)0xcf90, (q15_t)0x7671, (q15_t)0xcf79, - (q15_t)0x7668, (q15_t)0xcf62, (q15_t)0x765e, (q15_t)0xcf4a, (q15_t)0x7654, (q15_t)0xcf33, (q15_t)0x764b, (q15_t)0xcf1c, - (q15_t)0x7641, (q15_t)0xcf05, (q15_t)0x7638, (q15_t)0xceee, (q15_t)0x762e, (q15_t)0xced6, (q15_t)0x7624, (q15_t)0xcebf, - (q15_t)0x761b, (q15_t)0xcea8, (q15_t)0x7611, (q15_t)0xce91, (q15_t)0x7607, (q15_t)0xce7a, (q15_t)0x75fd, (q15_t)0xce62, - (q15_t)0x75f4, (q15_t)0xce4b, (q15_t)0x75ea, (q15_t)0xce34, (q15_t)0x75e0, (q15_t)0xce1d, (q15_t)0x75d6, (q15_t)0xce06, - (q15_t)0x75cc, (q15_t)0xcdef, (q15_t)0x75c3, (q15_t)0xcdd8, (q15_t)0x75b9, (q15_t)0xcdc0, (q15_t)0x75af, (q15_t)0xcda9, - (q15_t)0x75a5, (q15_t)0xcd92, (q15_t)0x759b, (q15_t)0xcd7b, (q15_t)0x7591, (q15_t)0xcd64, (q15_t)0x7587, (q15_t)0xcd4d, - (q15_t)0x757d, (q15_t)0xcd36, (q15_t)0x7573, (q15_t)0xcd1f, (q15_t)0x7569, (q15_t)0xcd08, (q15_t)0x755f, (q15_t)0xccf1, - (q15_t)0x7555, (q15_t)0xccda, (q15_t)0x754b, (q15_t)0xccc3, (q15_t)0x7541, (q15_t)0xccac, (q15_t)0x7537, (q15_t)0xcc95, - (q15_t)0x752d, (q15_t)0xcc7e, (q15_t)0x7523, (q15_t)0xcc67, (q15_t)0x7519, (q15_t)0xcc50, (q15_t)0x750f, (q15_t)0xcc39, - (q15_t)0x7504, (q15_t)0xcc22, (q15_t)0x74fa, (q15_t)0xcc0b, (q15_t)0x74f0, (q15_t)0xcbf4, (q15_t)0x74e6, (q15_t)0xcbdd, - (q15_t)0x74db, (q15_t)0xcbc6, (q15_t)0x74d1, (q15_t)0xcbaf, (q15_t)0x74c7, (q15_t)0xcb98, (q15_t)0x74bd, (q15_t)0xcb81, - (q15_t)0x74b2, (q15_t)0xcb6a, (q15_t)0x74a8, (q15_t)0xcb53, (q15_t)0x749e, (q15_t)0xcb3c, (q15_t)0x7493, (q15_t)0xcb25, - (q15_t)0x7489, (q15_t)0xcb0e, (q15_t)0x747e, (q15_t)0xcaf8, (q15_t)0x7474, (q15_t)0xcae1, (q15_t)0x746a, (q15_t)0xcaca, - (q15_t)0x745f, (q15_t)0xcab3, (q15_t)0x7455, (q15_t)0xca9c, (q15_t)0x744a, (q15_t)0xca85, (q15_t)0x7440, (q15_t)0xca6e, - (q15_t)0x7435, (q15_t)0xca58, (q15_t)0x742b, (q15_t)0xca41, (q15_t)0x7420, (q15_t)0xca2a, (q15_t)0x7415, (q15_t)0xca13, - (q15_t)0x740b, (q15_t)0xc9fc, (q15_t)0x7400, (q15_t)0xc9e6, (q15_t)0x73f6, (q15_t)0xc9cf, (q15_t)0x73eb, (q15_t)0xc9b8, - (q15_t)0x73e0, (q15_t)0xc9a1, (q15_t)0x73d6, (q15_t)0xc98b, (q15_t)0x73cb, (q15_t)0xc974, (q15_t)0x73c0, (q15_t)0xc95d, - (q15_t)0x73b5, (q15_t)0xc946, (q15_t)0x73ab, (q15_t)0xc930, (q15_t)0x73a0, (q15_t)0xc919, (q15_t)0x7395, (q15_t)0xc902, - (q15_t)0x738a, (q15_t)0xc8ec, (q15_t)0x737f, (q15_t)0xc8d5, (q15_t)0x7375, (q15_t)0xc8be, (q15_t)0x736a, (q15_t)0xc8a8, - (q15_t)0x735f, (q15_t)0xc891, (q15_t)0x7354, (q15_t)0xc87a, (q15_t)0x7349, (q15_t)0xc864, (q15_t)0x733e, (q15_t)0xc84d, - (q15_t)0x7333, (q15_t)0xc836, (q15_t)0x7328, (q15_t)0xc820, (q15_t)0x731d, (q15_t)0xc809, (q15_t)0x7312, (q15_t)0xc7f3, - (q15_t)0x7307, (q15_t)0xc7dc, (q15_t)0x72fc, (q15_t)0xc7c5, (q15_t)0x72f1, (q15_t)0xc7af, (q15_t)0x72e6, (q15_t)0xc798, - (q15_t)0x72db, (q15_t)0xc782, (q15_t)0x72d0, (q15_t)0xc76b, (q15_t)0x72c5, (q15_t)0xc755, (q15_t)0x72ba, (q15_t)0xc73e, - (q15_t)0x72af, (q15_t)0xc728, (q15_t)0x72a3, (q15_t)0xc711, (q15_t)0x7298, (q15_t)0xc6fa, (q15_t)0x728d, (q15_t)0xc6e4, - (q15_t)0x7282, (q15_t)0xc6ce, (q15_t)0x7276, (q15_t)0xc6b7, (q15_t)0x726b, (q15_t)0xc6a1, (q15_t)0x7260, (q15_t)0xc68a, - (q15_t)0x7255, (q15_t)0xc674, (q15_t)0x7249, (q15_t)0xc65d, (q15_t)0x723e, (q15_t)0xc647, (q15_t)0x7233, (q15_t)0xc630, - (q15_t)0x7227, (q15_t)0xc61a, (q15_t)0x721c, (q15_t)0xc603, (q15_t)0x7211, (q15_t)0xc5ed, (q15_t)0x7205, (q15_t)0xc5d7, - (q15_t)0x71fa, (q15_t)0xc5c0, (q15_t)0x71ee, (q15_t)0xc5aa, (q15_t)0x71e3, (q15_t)0xc594, (q15_t)0x71d7, (q15_t)0xc57d, - (q15_t)0x71cc, (q15_t)0xc567, (q15_t)0x71c0, (q15_t)0xc551, (q15_t)0x71b5, (q15_t)0xc53a, (q15_t)0x71a9, (q15_t)0xc524, - (q15_t)0x719e, (q15_t)0xc50e, (q15_t)0x7192, (q15_t)0xc4f7, (q15_t)0x7186, (q15_t)0xc4e1, (q15_t)0x717b, (q15_t)0xc4cb, - (q15_t)0x716f, (q15_t)0xc4b4, (q15_t)0x7164, (q15_t)0xc49e, (q15_t)0x7158, (q15_t)0xc488, (q15_t)0x714c, (q15_t)0xc472, - (q15_t)0x7141, (q15_t)0xc45b, (q15_t)0x7135, (q15_t)0xc445, (q15_t)0x7129, (q15_t)0xc42f, (q15_t)0x711d, (q15_t)0xc419, - (q15_t)0x7112, (q15_t)0xc403, (q15_t)0x7106, (q15_t)0xc3ec, (q15_t)0x70fa, (q15_t)0xc3d6, (q15_t)0x70ee, (q15_t)0xc3c0, - (q15_t)0x70e2, (q15_t)0xc3aa, (q15_t)0x70d6, (q15_t)0xc394, (q15_t)0x70cb, (q15_t)0xc37d, (q15_t)0x70bf, (q15_t)0xc367, - (q15_t)0x70b3, (q15_t)0xc351, (q15_t)0x70a7, (q15_t)0xc33b, (q15_t)0x709b, (q15_t)0xc325, (q15_t)0x708f, (q15_t)0xc30f, - (q15_t)0x7083, (q15_t)0xc2f9, (q15_t)0x7077, (q15_t)0xc2e3, (q15_t)0x706b, (q15_t)0xc2cd, (q15_t)0x705f, (q15_t)0xc2b7, - (q15_t)0x7053, (q15_t)0xc2a0, (q15_t)0x7047, (q15_t)0xc28a, (q15_t)0x703b, (q15_t)0xc274, (q15_t)0x702f, (q15_t)0xc25e, - (q15_t)0x7023, (q15_t)0xc248, (q15_t)0x7016, (q15_t)0xc232, (q15_t)0x700a, (q15_t)0xc21c, (q15_t)0x6ffe, (q15_t)0xc206, - (q15_t)0x6ff2, (q15_t)0xc1f0, (q15_t)0x6fe6, (q15_t)0xc1da, (q15_t)0x6fda, (q15_t)0xc1c4, (q15_t)0x6fcd, (q15_t)0xc1ae, - (q15_t)0x6fc1, (q15_t)0xc198, (q15_t)0x6fb5, (q15_t)0xc183, (q15_t)0x6fa9, (q15_t)0xc16d, (q15_t)0x6f9c, (q15_t)0xc157, - (q15_t)0x6f90, (q15_t)0xc141, (q15_t)0x6f84, (q15_t)0xc12b, (q15_t)0x6f77, (q15_t)0xc115, (q15_t)0x6f6b, (q15_t)0xc0ff, - (q15_t)0x6f5f, (q15_t)0xc0e9, (q15_t)0x6f52, (q15_t)0xc0d3, (q15_t)0x6f46, (q15_t)0xc0bd, (q15_t)0x6f39, (q15_t)0xc0a8, - (q15_t)0x6f2d, (q15_t)0xc092, (q15_t)0x6f20, (q15_t)0xc07c, (q15_t)0x6f14, (q15_t)0xc066, (q15_t)0x6f07, (q15_t)0xc050, - (q15_t)0x6efb, (q15_t)0xc03b, (q15_t)0x6eee, (q15_t)0xc025, (q15_t)0x6ee2, (q15_t)0xc00f, (q15_t)0x6ed5, (q15_t)0xbff9, - (q15_t)0x6ec9, (q15_t)0xbfe3, (q15_t)0x6ebc, (q15_t)0xbfce, (q15_t)0x6eaf, (q15_t)0xbfb8, (q15_t)0x6ea3, (q15_t)0xbfa2, - (q15_t)0x6e96, (q15_t)0xbf8d, (q15_t)0x6e89, (q15_t)0xbf77, (q15_t)0x6e7d, (q15_t)0xbf61, (q15_t)0x6e70, (q15_t)0xbf4b, - (q15_t)0x6e63, (q15_t)0xbf36, (q15_t)0x6e57, (q15_t)0xbf20, (q15_t)0x6e4a, (q15_t)0xbf0a, (q15_t)0x6e3d, (q15_t)0xbef5, - (q15_t)0x6e30, (q15_t)0xbedf, (q15_t)0x6e24, (q15_t)0xbeca, (q15_t)0x6e17, (q15_t)0xbeb4, (q15_t)0x6e0a, (q15_t)0xbe9e, - (q15_t)0x6dfd, (q15_t)0xbe89, (q15_t)0x6df0, (q15_t)0xbe73, (q15_t)0x6de3, (q15_t)0xbe5e, (q15_t)0x6dd6, (q15_t)0xbe48, - (q15_t)0x6dca, (q15_t)0xbe32, (q15_t)0x6dbd, (q15_t)0xbe1d, (q15_t)0x6db0, (q15_t)0xbe07, (q15_t)0x6da3, (q15_t)0xbdf2, - (q15_t)0x6d96, (q15_t)0xbddc, (q15_t)0x6d89, (q15_t)0xbdc7, (q15_t)0x6d7c, (q15_t)0xbdb1, (q15_t)0x6d6f, (q15_t)0xbd9c, - (q15_t)0x6d62, (q15_t)0xbd86, (q15_t)0x6d55, (q15_t)0xbd71, (q15_t)0x6d48, (q15_t)0xbd5b, (q15_t)0x6d3a, (q15_t)0xbd46, - (q15_t)0x6d2d, (q15_t)0xbd30, (q15_t)0x6d20, (q15_t)0xbd1b, (q15_t)0x6d13, (q15_t)0xbd06, (q15_t)0x6d06, (q15_t)0xbcf0, - (q15_t)0x6cf9, (q15_t)0xbcdb, (q15_t)0x6cec, (q15_t)0xbcc5, (q15_t)0x6cde, (q15_t)0xbcb0, (q15_t)0x6cd1, (q15_t)0xbc9b, - (q15_t)0x6cc4, (q15_t)0xbc85, (q15_t)0x6cb7, (q15_t)0xbc70, (q15_t)0x6ca9, (q15_t)0xbc5b, (q15_t)0x6c9c, (q15_t)0xbc45, - (q15_t)0x6c8f, (q15_t)0xbc30, (q15_t)0x6c81, (q15_t)0xbc1b, (q15_t)0x6c74, (q15_t)0xbc05, (q15_t)0x6c67, (q15_t)0xbbf0, - (q15_t)0x6c59, (q15_t)0xbbdb, (q15_t)0x6c4c, (q15_t)0xbbc5, (q15_t)0x6c3f, (q15_t)0xbbb0, (q15_t)0x6c31, (q15_t)0xbb9b, - (q15_t)0x6c24, (q15_t)0xbb86, (q15_t)0x6c16, (q15_t)0xbb70, (q15_t)0x6c09, (q15_t)0xbb5b, (q15_t)0x6bfb, (q15_t)0xbb46, - (q15_t)0x6bee, (q15_t)0xbb31, (q15_t)0x6be0, (q15_t)0xbb1c, (q15_t)0x6bd3, (q15_t)0xbb06, (q15_t)0x6bc5, (q15_t)0xbaf1, - (q15_t)0x6bb8, (q15_t)0xbadc, (q15_t)0x6baa, (q15_t)0xbac7, (q15_t)0x6b9c, (q15_t)0xbab2, (q15_t)0x6b8f, (q15_t)0xba9d, - (q15_t)0x6b81, (q15_t)0xba88, (q15_t)0x6b73, (q15_t)0xba73, (q15_t)0x6b66, (q15_t)0xba5d, (q15_t)0x6b58, (q15_t)0xba48, - (q15_t)0x6b4a, (q15_t)0xba33, (q15_t)0x6b3d, (q15_t)0xba1e, (q15_t)0x6b2f, (q15_t)0xba09, (q15_t)0x6b21, (q15_t)0xb9f4, - (q15_t)0x6b13, (q15_t)0xb9df, (q15_t)0x6b06, (q15_t)0xb9ca, (q15_t)0x6af8, (q15_t)0xb9b5, (q15_t)0x6aea, (q15_t)0xb9a0, - (q15_t)0x6adc, (q15_t)0xb98b, (q15_t)0x6ace, (q15_t)0xb976, (q15_t)0x6ac1, (q15_t)0xb961, (q15_t)0x6ab3, (q15_t)0xb94c, - (q15_t)0x6aa5, (q15_t)0xb937, (q15_t)0x6a97, (q15_t)0xb922, (q15_t)0x6a89, (q15_t)0xb90d, (q15_t)0x6a7b, (q15_t)0xb8f8, - (q15_t)0x6a6d, (q15_t)0xb8e4, (q15_t)0x6a5f, (q15_t)0xb8cf, (q15_t)0x6a51, (q15_t)0xb8ba, (q15_t)0x6a43, (q15_t)0xb8a5, - (q15_t)0x6a35, (q15_t)0xb890, (q15_t)0x6a27, (q15_t)0xb87b, (q15_t)0x6a19, (q15_t)0xb866, (q15_t)0x6a0b, (q15_t)0xb852, - (q15_t)0x69fd, (q15_t)0xb83d, (q15_t)0x69ef, (q15_t)0xb828, (q15_t)0x69e1, (q15_t)0xb813, (q15_t)0x69d3, (q15_t)0xb7fe, - (q15_t)0x69c4, (q15_t)0xb7ea, (q15_t)0x69b6, (q15_t)0xb7d5, (q15_t)0x69a8, (q15_t)0xb7c0, (q15_t)0x699a, (q15_t)0xb7ab, - (q15_t)0x698c, (q15_t)0xb797, (q15_t)0x697d, (q15_t)0xb782, (q15_t)0x696f, (q15_t)0xb76d, (q15_t)0x6961, (q15_t)0xb758, - (q15_t)0x6953, (q15_t)0xb744, (q15_t)0x6944, (q15_t)0xb72f, (q15_t)0x6936, (q15_t)0xb71a, (q15_t)0x6928, (q15_t)0xb706, - (q15_t)0x6919, (q15_t)0xb6f1, (q15_t)0x690b, (q15_t)0xb6dd, (q15_t)0x68fd, (q15_t)0xb6c8, (q15_t)0x68ee, (q15_t)0xb6b3, - (q15_t)0x68e0, (q15_t)0xb69f, (q15_t)0x68d1, (q15_t)0xb68a, (q15_t)0x68c3, (q15_t)0xb676, (q15_t)0x68b5, (q15_t)0xb661, - (q15_t)0x68a6, (q15_t)0xb64c, (q15_t)0x6898, (q15_t)0xb638, (q15_t)0x6889, (q15_t)0xb623, (q15_t)0x687b, (q15_t)0xb60f, - (q15_t)0x686c, (q15_t)0xb5fa, (q15_t)0x685e, (q15_t)0xb5e6, (q15_t)0x684f, (q15_t)0xb5d1, (q15_t)0x6840, (q15_t)0xb5bd, - (q15_t)0x6832, (q15_t)0xb5a8, (q15_t)0x6823, (q15_t)0xb594, (q15_t)0x6815, (q15_t)0xb57f, (q15_t)0x6806, (q15_t)0xb56b, - (q15_t)0x67f7, (q15_t)0xb557, (q15_t)0x67e9, (q15_t)0xb542, (q15_t)0x67da, (q15_t)0xb52e, (q15_t)0x67cb, (q15_t)0xb519, - (q15_t)0x67bd, (q15_t)0xb505, (q15_t)0x67ae, (q15_t)0xb4f1, (q15_t)0x679f, (q15_t)0xb4dc, (q15_t)0x6790, (q15_t)0xb4c8, - (q15_t)0x6782, (q15_t)0xb4b4, (q15_t)0x6773, (q15_t)0xb49f, (q15_t)0x6764, (q15_t)0xb48b, (q15_t)0x6755, (q15_t)0xb477, - (q15_t)0x6746, (q15_t)0xb462, (q15_t)0x6737, (q15_t)0xb44e, (q15_t)0x6729, (q15_t)0xb43a, (q15_t)0x671a, (q15_t)0xb426, - (q15_t)0x670b, (q15_t)0xb411, (q15_t)0x66fc, (q15_t)0xb3fd, (q15_t)0x66ed, (q15_t)0xb3e9, (q15_t)0x66de, (q15_t)0xb3d5, - (q15_t)0x66cf, (q15_t)0xb3c1, (q15_t)0x66c0, (q15_t)0xb3ac, (q15_t)0x66b1, (q15_t)0xb398, (q15_t)0x66a2, (q15_t)0xb384, - (q15_t)0x6693, (q15_t)0xb370, (q15_t)0x6684, (q15_t)0xb35c, (q15_t)0x6675, (q15_t)0xb348, (q15_t)0x6666, (q15_t)0xb334, - (q15_t)0x6657, (q15_t)0xb31f, (q15_t)0x6648, (q15_t)0xb30b, (q15_t)0x6639, (q15_t)0xb2f7, (q15_t)0x6629, (q15_t)0xb2e3, - (q15_t)0x661a, (q15_t)0xb2cf, (q15_t)0x660b, (q15_t)0xb2bb, (q15_t)0x65fc, (q15_t)0xb2a7, (q15_t)0x65ed, (q15_t)0xb293, - (q15_t)0x65dd, (q15_t)0xb27f, (q15_t)0x65ce, (q15_t)0xb26b, (q15_t)0x65bf, (q15_t)0xb257, (q15_t)0x65b0, (q15_t)0xb243, - (q15_t)0x65a0, (q15_t)0xb22f, (q15_t)0x6591, (q15_t)0xb21b, (q15_t)0x6582, (q15_t)0xb207, (q15_t)0x6573, (q15_t)0xb1f3, - (q15_t)0x6563, (q15_t)0xb1df, (q15_t)0x6554, (q15_t)0xb1cc, (q15_t)0x6545, (q15_t)0xb1b8, (q15_t)0x6535, (q15_t)0xb1a4, - (q15_t)0x6526, (q15_t)0xb190, (q15_t)0x6516, (q15_t)0xb17c, (q15_t)0x6507, (q15_t)0xb168, (q15_t)0x64f7, (q15_t)0xb154, - (q15_t)0x64e8, (q15_t)0xb141, (q15_t)0x64d9, (q15_t)0xb12d, (q15_t)0x64c9, (q15_t)0xb119, (q15_t)0x64ba, (q15_t)0xb105, - (q15_t)0x64aa, (q15_t)0xb0f1, (q15_t)0x649b, (q15_t)0xb0de, (q15_t)0x648b, (q15_t)0xb0ca, (q15_t)0x647b, (q15_t)0xb0b6, - (q15_t)0x646c, (q15_t)0xb0a2, (q15_t)0x645c, (q15_t)0xb08f, (q15_t)0x644d, (q15_t)0xb07b, (q15_t)0x643d, (q15_t)0xb067, - (q15_t)0x642d, (q15_t)0xb054, (q15_t)0x641e, (q15_t)0xb040, (q15_t)0x640e, (q15_t)0xb02c, (q15_t)0x63fe, (q15_t)0xb019, - (q15_t)0x63ef, (q15_t)0xb005, (q15_t)0x63df, (q15_t)0xaff1, (q15_t)0x63cf, (q15_t)0xafde, (q15_t)0x63c0, (q15_t)0xafca, - (q15_t)0x63b0, (q15_t)0xafb7, (q15_t)0x63a0, (q15_t)0xafa3, (q15_t)0x6390, (q15_t)0xaf90, (q15_t)0x6380, (q15_t)0xaf7c, - (q15_t)0x6371, (q15_t)0xaf69, (q15_t)0x6361, (q15_t)0xaf55, (q15_t)0x6351, (q15_t)0xaf41, (q15_t)0x6341, (q15_t)0xaf2e, - (q15_t)0x6331, (q15_t)0xaf1b, (q15_t)0x6321, (q15_t)0xaf07, (q15_t)0x6311, (q15_t)0xaef4, (q15_t)0x6301, (q15_t)0xaee0, - (q15_t)0x62f2, (q15_t)0xaecd, (q15_t)0x62e2, (q15_t)0xaeb9, (q15_t)0x62d2, (q15_t)0xaea6, (q15_t)0x62c2, (q15_t)0xae92, - (q15_t)0x62b2, (q15_t)0xae7f, (q15_t)0x62a2, (q15_t)0xae6c, (q15_t)0x6292, (q15_t)0xae58, (q15_t)0x6282, (q15_t)0xae45, - (q15_t)0x6271, (q15_t)0xae32, (q15_t)0x6261, (q15_t)0xae1e, (q15_t)0x6251, (q15_t)0xae0b, (q15_t)0x6241, (q15_t)0xadf8, - (q15_t)0x6231, (q15_t)0xade4, (q15_t)0x6221, (q15_t)0xadd1, (q15_t)0x6211, (q15_t)0xadbe, (q15_t)0x6201, (q15_t)0xadab, - (q15_t)0x61f1, (q15_t)0xad97, (q15_t)0x61e0, (q15_t)0xad84, (q15_t)0x61d0, (q15_t)0xad71, (q15_t)0x61c0, (q15_t)0xad5e, - (q15_t)0x61b0, (q15_t)0xad4b, (q15_t)0x619f, (q15_t)0xad37, (q15_t)0x618f, (q15_t)0xad24, (q15_t)0x617f, (q15_t)0xad11, - (q15_t)0x616f, (q15_t)0xacfe, (q15_t)0x615e, (q15_t)0xaceb, (q15_t)0x614e, (q15_t)0xacd8, (q15_t)0x613e, (q15_t)0xacc5, - (q15_t)0x612d, (q15_t)0xacb2, (q15_t)0x611d, (q15_t)0xac9e, (q15_t)0x610d, (q15_t)0xac8b, (q15_t)0x60fc, (q15_t)0xac78, - (q15_t)0x60ec, (q15_t)0xac65, (q15_t)0x60db, (q15_t)0xac52, (q15_t)0x60cb, (q15_t)0xac3f, (q15_t)0x60ba, (q15_t)0xac2c, - (q15_t)0x60aa, (q15_t)0xac19, (q15_t)0x6099, (q15_t)0xac06, (q15_t)0x6089, (q15_t)0xabf3, (q15_t)0x6078, (q15_t)0xabe0, - (q15_t)0x6068, (q15_t)0xabcd, (q15_t)0x6057, (q15_t)0xabbb, (q15_t)0x6047, (q15_t)0xaba8, (q15_t)0x6036, (q15_t)0xab95, - (q15_t)0x6026, (q15_t)0xab82, (q15_t)0x6015, (q15_t)0xab6f, (q15_t)0x6004, (q15_t)0xab5c, (q15_t)0x5ff4, (q15_t)0xab49, - (q15_t)0x5fe3, (q15_t)0xab36, (q15_t)0x5fd3, (q15_t)0xab24, (q15_t)0x5fc2, (q15_t)0xab11, (q15_t)0x5fb1, (q15_t)0xaafe, - (q15_t)0x5fa0, (q15_t)0xaaeb, (q15_t)0x5f90, (q15_t)0xaad8, (q15_t)0x5f7f, (q15_t)0xaac6, (q15_t)0x5f6e, (q15_t)0xaab3, - (q15_t)0x5f5e, (q15_t)0xaaa0, (q15_t)0x5f4d, (q15_t)0xaa8e, (q15_t)0x5f3c, (q15_t)0xaa7b, (q15_t)0x5f2b, (q15_t)0xaa68, - (q15_t)0x5f1a, (q15_t)0xaa55, (q15_t)0x5f0a, (q15_t)0xaa43, (q15_t)0x5ef9, (q15_t)0xaa30, (q15_t)0x5ee8, (q15_t)0xaa1d, - (q15_t)0x5ed7, (q15_t)0xaa0b, (q15_t)0x5ec6, (q15_t)0xa9f8, (q15_t)0x5eb5, (q15_t)0xa9e6, (q15_t)0x5ea4, (q15_t)0xa9d3, - (q15_t)0x5e93, (q15_t)0xa9c0, (q15_t)0x5e82, (q15_t)0xa9ae, (q15_t)0x5e71, (q15_t)0xa99b, (q15_t)0x5e60, (q15_t)0xa989, - (q15_t)0x5e50, (q15_t)0xa976, (q15_t)0x5e3f, (q15_t)0xa964, (q15_t)0x5e2d, (q15_t)0xa951, (q15_t)0x5e1c, (q15_t)0xa93f, - (q15_t)0x5e0b, (q15_t)0xa92c, (q15_t)0x5dfa, (q15_t)0xa91a, (q15_t)0x5de9, (q15_t)0xa907, (q15_t)0x5dd8, (q15_t)0xa8f5, - (q15_t)0x5dc7, (q15_t)0xa8e3, (q15_t)0x5db6, (q15_t)0xa8d0, (q15_t)0x5da5, (q15_t)0xa8be, (q15_t)0x5d94, (q15_t)0xa8ab, - (q15_t)0x5d83, (q15_t)0xa899, (q15_t)0x5d71, (q15_t)0xa887, (q15_t)0x5d60, (q15_t)0xa874, (q15_t)0x5d4f, (q15_t)0xa862, - (q15_t)0x5d3e, (q15_t)0xa850, (q15_t)0x5d2d, (q15_t)0xa83d, (q15_t)0x5d1b, (q15_t)0xa82b, (q15_t)0x5d0a, (q15_t)0xa819, - (q15_t)0x5cf9, (q15_t)0xa807, (q15_t)0x5ce8, (q15_t)0xa7f4, (q15_t)0x5cd6, (q15_t)0xa7e2, (q15_t)0x5cc5, (q15_t)0xa7d0, - (q15_t)0x5cb4, (q15_t)0xa7be, (q15_t)0x5ca2, (q15_t)0xa7ab, (q15_t)0x5c91, (q15_t)0xa799, (q15_t)0x5c80, (q15_t)0xa787, - (q15_t)0x5c6e, (q15_t)0xa775, (q15_t)0x5c5d, (q15_t)0xa763, (q15_t)0x5c4b, (q15_t)0xa751, (q15_t)0x5c3a, (q15_t)0xa73f, - (q15_t)0x5c29, (q15_t)0xa72c, (q15_t)0x5c17, (q15_t)0xa71a, (q15_t)0x5c06, (q15_t)0xa708, (q15_t)0x5bf4, (q15_t)0xa6f6, - (q15_t)0x5be3, (q15_t)0xa6e4, (q15_t)0x5bd1, (q15_t)0xa6d2, (q15_t)0x5bc0, (q15_t)0xa6c0, (q15_t)0x5bae, (q15_t)0xa6ae, - (q15_t)0x5b9d, (q15_t)0xa69c, (q15_t)0x5b8b, (q15_t)0xa68a, (q15_t)0x5b79, (q15_t)0xa678, (q15_t)0x5b68, (q15_t)0xa666, - (q15_t)0x5b56, (q15_t)0xa654, (q15_t)0x5b45, (q15_t)0xa642, (q15_t)0x5b33, (q15_t)0xa630, (q15_t)0x5b21, (q15_t)0xa61f, - (q15_t)0x5b10, (q15_t)0xa60d, (q15_t)0x5afe, (q15_t)0xa5fb, (q15_t)0x5aec, (q15_t)0xa5e9, (q15_t)0x5adb, (q15_t)0xa5d7, - (q15_t)0x5ac9, (q15_t)0xa5c5, (q15_t)0x5ab7, (q15_t)0xa5b3, (q15_t)0x5aa5, (q15_t)0xa5a2, (q15_t)0x5a94, (q15_t)0xa590, - (q15_t)0x5a82, (q15_t)0xa57e, (q15_t)0x5a70, (q15_t)0xa56c, (q15_t)0x5a5e, (q15_t)0xa55b, (q15_t)0x5a4d, (q15_t)0xa549, - (q15_t)0x5a3b, (q15_t)0xa537, (q15_t)0x5a29, (q15_t)0xa525, (q15_t)0x5a17, (q15_t)0xa514, (q15_t)0x5a05, (q15_t)0xa502, - (q15_t)0x59f3, (q15_t)0xa4f0, (q15_t)0x59e1, (q15_t)0xa4df, (q15_t)0x59d0, (q15_t)0xa4cd, (q15_t)0x59be, (q15_t)0xa4bb, - (q15_t)0x59ac, (q15_t)0xa4aa, (q15_t)0x599a, (q15_t)0xa498, (q15_t)0x5988, (q15_t)0xa487, (q15_t)0x5976, (q15_t)0xa475, - (q15_t)0x5964, (q15_t)0xa463, (q15_t)0x5952, (q15_t)0xa452, (q15_t)0x5940, (q15_t)0xa440, (q15_t)0x592e, (q15_t)0xa42f, - (q15_t)0x591c, (q15_t)0xa41d, (q15_t)0x590a, (q15_t)0xa40c, (q15_t)0x58f8, (q15_t)0xa3fa, (q15_t)0x58e6, (q15_t)0xa3e9, - (q15_t)0x58d4, (q15_t)0xa3d7, (q15_t)0x58c1, (q15_t)0xa3c6, (q15_t)0x58af, (q15_t)0xa3b5, (q15_t)0x589d, (q15_t)0xa3a3, - (q15_t)0x588b, (q15_t)0xa392, (q15_t)0x5879, (q15_t)0xa380, (q15_t)0x5867, (q15_t)0xa36f, (q15_t)0x5855, (q15_t)0xa35e, - (q15_t)0x5842, (q15_t)0xa34c, (q15_t)0x5830, (q15_t)0xa33b, (q15_t)0x581e, (q15_t)0xa32a, (q15_t)0x580c, (q15_t)0xa318, - (q15_t)0x57f9, (q15_t)0xa307, (q15_t)0x57e7, (q15_t)0xa2f6, (q15_t)0x57d5, (q15_t)0xa2e5, (q15_t)0x57c3, (q15_t)0xa2d3, - (q15_t)0x57b0, (q15_t)0xa2c2, (q15_t)0x579e, (q15_t)0xa2b1, (q15_t)0x578c, (q15_t)0xa2a0, (q15_t)0x5779, (q15_t)0xa28f, - (q15_t)0x5767, (q15_t)0xa27d, (q15_t)0x5755, (q15_t)0xa26c, (q15_t)0x5742, (q15_t)0xa25b, (q15_t)0x5730, (q15_t)0xa24a, - (q15_t)0x571d, (q15_t)0xa239, (q15_t)0x570b, (q15_t)0xa228, (q15_t)0x56f9, (q15_t)0xa217, (q15_t)0x56e6, (q15_t)0xa206, - (q15_t)0x56d4, (q15_t)0xa1f5, (q15_t)0x56c1, (q15_t)0xa1e4, (q15_t)0x56af, (q15_t)0xa1d3, (q15_t)0x569c, (q15_t)0xa1c1, - (q15_t)0x568a, (q15_t)0xa1b0, (q15_t)0x5677, (q15_t)0xa1a0, (q15_t)0x5665, (q15_t)0xa18f, (q15_t)0x5652, (q15_t)0xa17e, - (q15_t)0x5640, (q15_t)0xa16d, (q15_t)0x562d, (q15_t)0xa15c, (q15_t)0x561a, (q15_t)0xa14b, (q15_t)0x5608, (q15_t)0xa13a, - (q15_t)0x55f5, (q15_t)0xa129, (q15_t)0x55e3, (q15_t)0xa118, (q15_t)0x55d0, (q15_t)0xa107, (q15_t)0x55bd, (q15_t)0xa0f6, - (q15_t)0x55ab, (q15_t)0xa0e6, (q15_t)0x5598, (q15_t)0xa0d5, (q15_t)0x5585, (q15_t)0xa0c4, (q15_t)0x5572, (q15_t)0xa0b3, - (q15_t)0x5560, (q15_t)0xa0a2, (q15_t)0x554d, (q15_t)0xa092, (q15_t)0x553a, (q15_t)0xa081, (q15_t)0x5528, (q15_t)0xa070, - (q15_t)0x5515, (q15_t)0xa060, (q15_t)0x5502, (q15_t)0xa04f, (q15_t)0x54ef, (q15_t)0xa03e, (q15_t)0x54dc, (q15_t)0xa02d, - (q15_t)0x54ca, (q15_t)0xa01d, (q15_t)0x54b7, (q15_t)0xa00c, (q15_t)0x54a4, (q15_t)0x9ffc, (q15_t)0x5491, (q15_t)0x9feb, - (q15_t)0x547e, (q15_t)0x9fda, (q15_t)0x546b, (q15_t)0x9fca, (q15_t)0x5458, (q15_t)0x9fb9, (q15_t)0x5445, (q15_t)0x9fa9, - (q15_t)0x5433, (q15_t)0x9f98, (q15_t)0x5420, (q15_t)0x9f88, (q15_t)0x540d, (q15_t)0x9f77, (q15_t)0x53fa, (q15_t)0x9f67, - (q15_t)0x53e7, (q15_t)0x9f56, (q15_t)0x53d4, (q15_t)0x9f46, (q15_t)0x53c1, (q15_t)0x9f35, (q15_t)0x53ae, (q15_t)0x9f25, - (q15_t)0x539b, (q15_t)0x9f14, (q15_t)0x5388, (q15_t)0x9f04, (q15_t)0x5375, (q15_t)0x9ef3, (q15_t)0x5362, (q15_t)0x9ee3, - (q15_t)0x534e, (q15_t)0x9ed3, (q15_t)0x533b, (q15_t)0x9ec2, (q15_t)0x5328, (q15_t)0x9eb2, (q15_t)0x5315, (q15_t)0x9ea2, - (q15_t)0x5302, (q15_t)0x9e91, (q15_t)0x52ef, (q15_t)0x9e81, (q15_t)0x52dc, (q15_t)0x9e71, (q15_t)0x52c9, (q15_t)0x9e61, - (q15_t)0x52b5, (q15_t)0x9e50, (q15_t)0x52a2, (q15_t)0x9e40, (q15_t)0x528f, (q15_t)0x9e30, (q15_t)0x527c, (q15_t)0x9e20, - (q15_t)0x5269, (q15_t)0x9e0f, (q15_t)0x5255, (q15_t)0x9dff, (q15_t)0x5242, (q15_t)0x9def, (q15_t)0x522f, (q15_t)0x9ddf, - (q15_t)0x521c, (q15_t)0x9dcf, (q15_t)0x5208, (q15_t)0x9dbf, (q15_t)0x51f5, (q15_t)0x9daf, (q15_t)0x51e2, (q15_t)0x9d9f, - (q15_t)0x51ce, (q15_t)0x9d8f, (q15_t)0x51bb, (q15_t)0x9d7e, (q15_t)0x51a8, (q15_t)0x9d6e, (q15_t)0x5194, (q15_t)0x9d5e, - (q15_t)0x5181, (q15_t)0x9d4e, (q15_t)0x516e, (q15_t)0x9d3e, (q15_t)0x515a, (q15_t)0x9d2e, (q15_t)0x5147, (q15_t)0x9d1e, - (q15_t)0x5133, (q15_t)0x9d0e, (q15_t)0x5120, (q15_t)0x9cff, (q15_t)0x510c, (q15_t)0x9cef, (q15_t)0x50f9, (q15_t)0x9cdf, - (q15_t)0x50e5, (q15_t)0x9ccf, (q15_t)0x50d2, (q15_t)0x9cbf, (q15_t)0x50bf, (q15_t)0x9caf, (q15_t)0x50ab, (q15_t)0x9c9f, - (q15_t)0x5097, (q15_t)0x9c8f, (q15_t)0x5084, (q15_t)0x9c80, (q15_t)0x5070, (q15_t)0x9c70, (q15_t)0x505d, (q15_t)0x9c60, - (q15_t)0x5049, (q15_t)0x9c50, (q15_t)0x5036, (q15_t)0x9c40, (q15_t)0x5022, (q15_t)0x9c31, (q15_t)0x500f, (q15_t)0x9c21, - (q15_t)0x4ffb, (q15_t)0x9c11, (q15_t)0x4fe7, (q15_t)0x9c02, (q15_t)0x4fd4, (q15_t)0x9bf2, (q15_t)0x4fc0, (q15_t)0x9be2, - (q15_t)0x4fac, (q15_t)0x9bd3, (q15_t)0x4f99, (q15_t)0x9bc3, (q15_t)0x4f85, (q15_t)0x9bb3, (q15_t)0x4f71, (q15_t)0x9ba4, - (q15_t)0x4f5e, (q15_t)0x9b94, (q15_t)0x4f4a, (q15_t)0x9b85, (q15_t)0x4f36, (q15_t)0x9b75, (q15_t)0x4f22, (q15_t)0x9b65, - (q15_t)0x4f0f, (q15_t)0x9b56, (q15_t)0x4efb, (q15_t)0x9b46, (q15_t)0x4ee7, (q15_t)0x9b37, (q15_t)0x4ed3, (q15_t)0x9b27, - (q15_t)0x4ebf, (q15_t)0x9b18, (q15_t)0x4eac, (q15_t)0x9b09, (q15_t)0x4e98, (q15_t)0x9af9, (q15_t)0x4e84, (q15_t)0x9aea, - (q15_t)0x4e70, (q15_t)0x9ada, (q15_t)0x4e5c, (q15_t)0x9acb, (q15_t)0x4e48, (q15_t)0x9abb, (q15_t)0x4e34, (q15_t)0x9aac, - (q15_t)0x4e21, (q15_t)0x9a9d, (q15_t)0x4e0d, (q15_t)0x9a8d, (q15_t)0x4df9, (q15_t)0x9a7e, (q15_t)0x4de5, (q15_t)0x9a6f, - (q15_t)0x4dd1, (q15_t)0x9a60, (q15_t)0x4dbd, (q15_t)0x9a50, (q15_t)0x4da9, (q15_t)0x9a41, (q15_t)0x4d95, (q15_t)0x9a32, - (q15_t)0x4d81, (q15_t)0x9a23, (q15_t)0x4d6d, (q15_t)0x9a13, (q15_t)0x4d59, (q15_t)0x9a04, (q15_t)0x4d45, (q15_t)0x99f5, - (q15_t)0x4d31, (q15_t)0x99e6, (q15_t)0x4d1d, (q15_t)0x99d7, (q15_t)0x4d09, (q15_t)0x99c7, (q15_t)0x4cf5, (q15_t)0x99b8, - (q15_t)0x4ce1, (q15_t)0x99a9, (q15_t)0x4ccc, (q15_t)0x999a, (q15_t)0x4cb8, (q15_t)0x998b, (q15_t)0x4ca4, (q15_t)0x997c, - (q15_t)0x4c90, (q15_t)0x996d, (q15_t)0x4c7c, (q15_t)0x995e, (q15_t)0x4c68, (q15_t)0x994f, (q15_t)0x4c54, (q15_t)0x9940, - (q15_t)0x4c3f, (q15_t)0x9931, (q15_t)0x4c2b, (q15_t)0x9922, (q15_t)0x4c17, (q15_t)0x9913, (q15_t)0x4c03, (q15_t)0x9904, - (q15_t)0x4bef, (q15_t)0x98f5, (q15_t)0x4bda, (q15_t)0x98e6, (q15_t)0x4bc6, (q15_t)0x98d7, (q15_t)0x4bb2, (q15_t)0x98c9, - (q15_t)0x4b9e, (q15_t)0x98ba, (q15_t)0x4b89, (q15_t)0x98ab, (q15_t)0x4b75, (q15_t)0x989c, (q15_t)0x4b61, (q15_t)0x988d, - (q15_t)0x4b4c, (q15_t)0x987e, (q15_t)0x4b38, (q15_t)0x9870, (q15_t)0x4b24, (q15_t)0x9861, (q15_t)0x4b0f, (q15_t)0x9852, - (q15_t)0x4afb, (q15_t)0x9843, (q15_t)0x4ae7, (q15_t)0x9835, (q15_t)0x4ad2, (q15_t)0x9826, (q15_t)0x4abe, (q15_t)0x9817, - (q15_t)0x4aa9, (q15_t)0x9809, (q15_t)0x4a95, (q15_t)0x97fa, (q15_t)0x4a81, (q15_t)0x97eb, (q15_t)0x4a6c, (q15_t)0x97dd, - (q15_t)0x4a58, (q15_t)0x97ce, (q15_t)0x4a43, (q15_t)0x97c0, (q15_t)0x4a2f, (q15_t)0x97b1, (q15_t)0x4a1a, (q15_t)0x97a2, - (q15_t)0x4a06, (q15_t)0x9794, (q15_t)0x49f1, (q15_t)0x9785, (q15_t)0x49dd, (q15_t)0x9777, (q15_t)0x49c8, (q15_t)0x9768, - (q15_t)0x49b4, (q15_t)0x975a, (q15_t)0x499f, (q15_t)0x974b, (q15_t)0x498a, (q15_t)0x973d, (q15_t)0x4976, (q15_t)0x972f, - (q15_t)0x4961, (q15_t)0x9720, (q15_t)0x494d, (q15_t)0x9712, (q15_t)0x4938, (q15_t)0x9703, (q15_t)0x4923, (q15_t)0x96f5, - (q15_t)0x490f, (q15_t)0x96e7, (q15_t)0x48fa, (q15_t)0x96d8, (q15_t)0x48e6, (q15_t)0x96ca, (q15_t)0x48d1, (q15_t)0x96bc, - (q15_t)0x48bc, (q15_t)0x96ad, (q15_t)0x48a8, (q15_t)0x969f, (q15_t)0x4893, (q15_t)0x9691, (q15_t)0x487e, (q15_t)0x9683, - (q15_t)0x4869, (q15_t)0x9674, (q15_t)0x4855, (q15_t)0x9666, (q15_t)0x4840, (q15_t)0x9658, (q15_t)0x482b, (q15_t)0x964a, - (q15_t)0x4816, (q15_t)0x963c, (q15_t)0x4802, (q15_t)0x962d, (q15_t)0x47ed, (q15_t)0x961f, (q15_t)0x47d8, (q15_t)0x9611, - (q15_t)0x47c3, (q15_t)0x9603, (q15_t)0x47ae, (q15_t)0x95f5, (q15_t)0x479a, (q15_t)0x95e7, (q15_t)0x4785, (q15_t)0x95d9, - (q15_t)0x4770, (q15_t)0x95cb, (q15_t)0x475b, (q15_t)0x95bd, (q15_t)0x4746, (q15_t)0x95af, (q15_t)0x4731, (q15_t)0x95a1, - (q15_t)0x471c, (q15_t)0x9593, (q15_t)0x4708, (q15_t)0x9585, (q15_t)0x46f3, (q15_t)0x9577, (q15_t)0x46de, (q15_t)0x9569, - (q15_t)0x46c9, (q15_t)0x955b, (q15_t)0x46b4, (q15_t)0x954d, (q15_t)0x469f, (q15_t)0x953f, (q15_t)0x468a, (q15_t)0x9532, - (q15_t)0x4675, (q15_t)0x9524, (q15_t)0x4660, (q15_t)0x9516, (q15_t)0x464b, (q15_t)0x9508, (q15_t)0x4636, (q15_t)0x94fa, - (q15_t)0x4621, (q15_t)0x94ed, (q15_t)0x460c, (q15_t)0x94df, (q15_t)0x45f7, (q15_t)0x94d1, (q15_t)0x45e2, (q15_t)0x94c3, - (q15_t)0x45cd, (q15_t)0x94b6, (q15_t)0x45b8, (q15_t)0x94a8, (q15_t)0x45a3, (q15_t)0x949a, (q15_t)0x458d, (q15_t)0x948d, - (q15_t)0x4578, (q15_t)0x947f, (q15_t)0x4563, (q15_t)0x9471, (q15_t)0x454e, (q15_t)0x9464, (q15_t)0x4539, (q15_t)0x9456, - (q15_t)0x4524, (q15_t)0x9448, (q15_t)0x450f, (q15_t)0x943b, (q15_t)0x44fa, (q15_t)0x942d, (q15_t)0x44e4, (q15_t)0x9420, - (q15_t)0x44cf, (q15_t)0x9412, (q15_t)0x44ba, (q15_t)0x9405, (q15_t)0x44a5, (q15_t)0x93f7, (q15_t)0x4490, (q15_t)0x93ea, - (q15_t)0x447a, (q15_t)0x93dc, (q15_t)0x4465, (q15_t)0x93cf, (q15_t)0x4450, (q15_t)0x93c1, (q15_t)0x443b, (q15_t)0x93b4, - (q15_t)0x4425, (q15_t)0x93a7, (q15_t)0x4410, (q15_t)0x9399, (q15_t)0x43fb, (q15_t)0x938c, (q15_t)0x43e5, (q15_t)0x937f, - (q15_t)0x43d0, (q15_t)0x9371, (q15_t)0x43bb, (q15_t)0x9364, (q15_t)0x43a5, (q15_t)0x9357, (q15_t)0x4390, (q15_t)0x9349, - (q15_t)0x437b, (q15_t)0x933c, (q15_t)0x4365, (q15_t)0x932f, (q15_t)0x4350, (q15_t)0x9322, (q15_t)0x433b, (q15_t)0x9314, - (q15_t)0x4325, (q15_t)0x9307, (q15_t)0x4310, (q15_t)0x92fa, (q15_t)0x42fa, (q15_t)0x92ed, (q15_t)0x42e5, (q15_t)0x92e0, - (q15_t)0x42d0, (q15_t)0x92d3, (q15_t)0x42ba, (q15_t)0x92c6, (q15_t)0x42a5, (q15_t)0x92b8, (q15_t)0x428f, (q15_t)0x92ab, - (q15_t)0x427a, (q15_t)0x929e, (q15_t)0x4264, (q15_t)0x9291, (q15_t)0x424f, (q15_t)0x9284, (q15_t)0x4239, (q15_t)0x9277, - (q15_t)0x4224, (q15_t)0x926a, (q15_t)0x420e, (q15_t)0x925d, (q15_t)0x41f9, (q15_t)0x9250, (q15_t)0x41e3, (q15_t)0x9243, - (q15_t)0x41ce, (q15_t)0x9236, (q15_t)0x41b8, (q15_t)0x922a, (q15_t)0x41a2, (q15_t)0x921d, (q15_t)0x418d, (q15_t)0x9210, - (q15_t)0x4177, (q15_t)0x9203, (q15_t)0x4162, (q15_t)0x91f6, (q15_t)0x414c, (q15_t)0x91e9, (q15_t)0x4136, (q15_t)0x91dc, - (q15_t)0x4121, (q15_t)0x91d0, (q15_t)0x410b, (q15_t)0x91c3, (q15_t)0x40f6, (q15_t)0x91b6, (q15_t)0x40e0, (q15_t)0x91a9, - (q15_t)0x40ca, (q15_t)0x919d, (q15_t)0x40b5, (q15_t)0x9190, (q15_t)0x409f, (q15_t)0x9183, (q15_t)0x4089, (q15_t)0x9177, - (q15_t)0x4073, (q15_t)0x916a, (q15_t)0x405e, (q15_t)0x915d, (q15_t)0x4048, (q15_t)0x9151, (q15_t)0x4032, (q15_t)0x9144, - (q15_t)0x401d, (q15_t)0x9137, (q15_t)0x4007, (q15_t)0x912b, (q15_t)0x3ff1, (q15_t)0x911e, (q15_t)0x3fdb, (q15_t)0x9112, - (q15_t)0x3fc5, (q15_t)0x9105, (q15_t)0x3fb0, (q15_t)0x90f9, (q15_t)0x3f9a, (q15_t)0x90ec, (q15_t)0x3f84, (q15_t)0x90e0, - (q15_t)0x3f6e, (q15_t)0x90d3, (q15_t)0x3f58, (q15_t)0x90c7, (q15_t)0x3f43, (q15_t)0x90ba, (q15_t)0x3f2d, (q15_t)0x90ae, - (q15_t)0x3f17, (q15_t)0x90a1, (q15_t)0x3f01, (q15_t)0x9095, (q15_t)0x3eeb, (q15_t)0x9089, (q15_t)0x3ed5, (q15_t)0x907c, - (q15_t)0x3ebf, (q15_t)0x9070, (q15_t)0x3ea9, (q15_t)0x9064, (q15_t)0x3e93, (q15_t)0x9057, (q15_t)0x3e7d, (q15_t)0x904b, - (q15_t)0x3e68, (q15_t)0x903f, (q15_t)0x3e52, (q15_t)0x9033, (q15_t)0x3e3c, (q15_t)0x9026, (q15_t)0x3e26, (q15_t)0x901a, - (q15_t)0x3e10, (q15_t)0x900e, (q15_t)0x3dfa, (q15_t)0x9002, (q15_t)0x3de4, (q15_t)0x8ff6, (q15_t)0x3dce, (q15_t)0x8fea, - (q15_t)0x3db8, (q15_t)0x8fdd, (q15_t)0x3da2, (q15_t)0x8fd1, (q15_t)0x3d8c, (q15_t)0x8fc5, (q15_t)0x3d76, (q15_t)0x8fb9, - (q15_t)0x3d60, (q15_t)0x8fad, (q15_t)0x3d49, (q15_t)0x8fa1, (q15_t)0x3d33, (q15_t)0x8f95, (q15_t)0x3d1d, (q15_t)0x8f89, - (q15_t)0x3d07, (q15_t)0x8f7d, (q15_t)0x3cf1, (q15_t)0x8f71, (q15_t)0x3cdb, (q15_t)0x8f65, (q15_t)0x3cc5, (q15_t)0x8f59, - (q15_t)0x3caf, (q15_t)0x8f4d, (q15_t)0x3c99, (q15_t)0x8f41, (q15_t)0x3c83, (q15_t)0x8f35, (q15_t)0x3c6c, (q15_t)0x8f2a, - (q15_t)0x3c56, (q15_t)0x8f1e, (q15_t)0x3c40, (q15_t)0x8f12, (q15_t)0x3c2a, (q15_t)0x8f06, (q15_t)0x3c14, (q15_t)0x8efa, - (q15_t)0x3bfd, (q15_t)0x8eee, (q15_t)0x3be7, (q15_t)0x8ee3, (q15_t)0x3bd1, (q15_t)0x8ed7, (q15_t)0x3bbb, (q15_t)0x8ecb, - (q15_t)0x3ba5, (q15_t)0x8ebf, (q15_t)0x3b8e, (q15_t)0x8eb4, (q15_t)0x3b78, (q15_t)0x8ea8, (q15_t)0x3b62, (q15_t)0x8e9c, - (q15_t)0x3b4c, (q15_t)0x8e91, (q15_t)0x3b35, (q15_t)0x8e85, (q15_t)0x3b1f, (q15_t)0x8e7a, (q15_t)0x3b09, (q15_t)0x8e6e, - (q15_t)0x3af2, (q15_t)0x8e62, (q15_t)0x3adc, (q15_t)0x8e57, (q15_t)0x3ac6, (q15_t)0x8e4b, (q15_t)0x3aaf, (q15_t)0x8e40, - (q15_t)0x3a99, (q15_t)0x8e34, (q15_t)0x3a83, (q15_t)0x8e29, (q15_t)0x3a6c, (q15_t)0x8e1d, (q15_t)0x3a56, (q15_t)0x8e12, - (q15_t)0x3a40, (q15_t)0x8e06, (q15_t)0x3a29, (q15_t)0x8dfb, (q15_t)0x3a13, (q15_t)0x8def, (q15_t)0x39fd, (q15_t)0x8de4, - (q15_t)0x39e6, (q15_t)0x8dd9, (q15_t)0x39d0, (q15_t)0x8dcd, (q15_t)0x39b9, (q15_t)0x8dc2, (q15_t)0x39a3, (q15_t)0x8db7, - (q15_t)0x398c, (q15_t)0x8dab, (q15_t)0x3976, (q15_t)0x8da0, (q15_t)0x395f, (q15_t)0x8d95, (q15_t)0x3949, (q15_t)0x8d8a, - (q15_t)0x3932, (q15_t)0x8d7e, (q15_t)0x391c, (q15_t)0x8d73, (q15_t)0x3906, (q15_t)0x8d68, (q15_t)0x38ef, (q15_t)0x8d5d, - (q15_t)0x38d8, (q15_t)0x8d51, (q15_t)0x38c2, (q15_t)0x8d46, (q15_t)0x38ab, (q15_t)0x8d3b, (q15_t)0x3895, (q15_t)0x8d30, - (q15_t)0x387e, (q15_t)0x8d25, (q15_t)0x3868, (q15_t)0x8d1a, (q15_t)0x3851, (q15_t)0x8d0f, (q15_t)0x383b, (q15_t)0x8d04, - (q15_t)0x3824, (q15_t)0x8cf9, (q15_t)0x380d, (q15_t)0x8cee, (q15_t)0x37f7, (q15_t)0x8ce3, (q15_t)0x37e0, (q15_t)0x8cd8, - (q15_t)0x37ca, (q15_t)0x8ccd, (q15_t)0x37b3, (q15_t)0x8cc2, (q15_t)0x379c, (q15_t)0x8cb7, (q15_t)0x3786, (q15_t)0x8cac, - (q15_t)0x376f, (q15_t)0x8ca1, (q15_t)0x3758, (q15_t)0x8c96, (q15_t)0x3742, (q15_t)0x8c8b, (q15_t)0x372b, (q15_t)0x8c81, - (q15_t)0x3714, (q15_t)0x8c76, (q15_t)0x36fe, (q15_t)0x8c6b, (q15_t)0x36e7, (q15_t)0x8c60, (q15_t)0x36d0, (q15_t)0x8c55, - (q15_t)0x36ba, (q15_t)0x8c4b, (q15_t)0x36a3, (q15_t)0x8c40, (q15_t)0x368c, (q15_t)0x8c35, (q15_t)0x3675, (q15_t)0x8c2a, - (q15_t)0x365f, (q15_t)0x8c20, (q15_t)0x3648, (q15_t)0x8c15, (q15_t)0x3631, (q15_t)0x8c0a, (q15_t)0x361a, (q15_t)0x8c00, - (q15_t)0x3604, (q15_t)0x8bf5, (q15_t)0x35ed, (q15_t)0x8beb, (q15_t)0x35d6, (q15_t)0x8be0, (q15_t)0x35bf, (q15_t)0x8bd5, - (q15_t)0x35a8, (q15_t)0x8bcb, (q15_t)0x3592, (q15_t)0x8bc0, (q15_t)0x357b, (q15_t)0x8bb6, (q15_t)0x3564, (q15_t)0x8bab, - (q15_t)0x354d, (q15_t)0x8ba1, (q15_t)0x3536, (q15_t)0x8b96, (q15_t)0x351f, (q15_t)0x8b8c, (q15_t)0x3508, (q15_t)0x8b82, - (q15_t)0x34f2, (q15_t)0x8b77, (q15_t)0x34db, (q15_t)0x8b6d, (q15_t)0x34c4, (q15_t)0x8b62, (q15_t)0x34ad, (q15_t)0x8b58, - (q15_t)0x3496, (q15_t)0x8b4e, (q15_t)0x347f, (q15_t)0x8b43, (q15_t)0x3468, (q15_t)0x8b39, (q15_t)0x3451, (q15_t)0x8b2f, - (q15_t)0x343a, (q15_t)0x8b25, (q15_t)0x3423, (q15_t)0x8b1a, (q15_t)0x340c, (q15_t)0x8b10, (q15_t)0x33f5, (q15_t)0x8b06, - (q15_t)0x33de, (q15_t)0x8afc, (q15_t)0x33c7, (q15_t)0x8af1, (q15_t)0x33b0, (q15_t)0x8ae7, (q15_t)0x3399, (q15_t)0x8add, - (q15_t)0x3382, (q15_t)0x8ad3, (q15_t)0x336b, (q15_t)0x8ac9, (q15_t)0x3354, (q15_t)0x8abf, (q15_t)0x333d, (q15_t)0x8ab5, - (q15_t)0x3326, (q15_t)0x8aab, (q15_t)0x330f, (q15_t)0x8aa1, (q15_t)0x32f8, (q15_t)0x8a97, (q15_t)0x32e1, (q15_t)0x8a8d, - (q15_t)0x32ca, (q15_t)0x8a83, (q15_t)0x32b3, (q15_t)0x8a79, (q15_t)0x329c, (q15_t)0x8a6f, (q15_t)0x3285, (q15_t)0x8a65, - (q15_t)0x326e, (q15_t)0x8a5b, (q15_t)0x3257, (q15_t)0x8a51, (q15_t)0x3240, (q15_t)0x8a47, (q15_t)0x3228, (q15_t)0x8a3d, - (q15_t)0x3211, (q15_t)0x8a34, (q15_t)0x31fa, (q15_t)0x8a2a, (q15_t)0x31e3, (q15_t)0x8a20, (q15_t)0x31cc, (q15_t)0x8a16, - (q15_t)0x31b5, (q15_t)0x8a0c, (q15_t)0x319e, (q15_t)0x8a03, (q15_t)0x3186, (q15_t)0x89f9, (q15_t)0x316f, (q15_t)0x89ef, - (q15_t)0x3158, (q15_t)0x89e5, (q15_t)0x3141, (q15_t)0x89dc, (q15_t)0x312a, (q15_t)0x89d2, (q15_t)0x3112, (q15_t)0x89c8, - (q15_t)0x30fb, (q15_t)0x89bf, (q15_t)0x30e4, (q15_t)0x89b5, (q15_t)0x30cd, (q15_t)0x89ac, (q15_t)0x30b6, (q15_t)0x89a2, - (q15_t)0x309e, (q15_t)0x8998, (q15_t)0x3087, (q15_t)0x898f, (q15_t)0x3070, (q15_t)0x8985, (q15_t)0x3059, (q15_t)0x897c, - (q15_t)0x3041, (q15_t)0x8972, (q15_t)0x302a, (q15_t)0x8969, (q15_t)0x3013, (q15_t)0x8960, (q15_t)0x2ffb, (q15_t)0x8956, - (q15_t)0x2fe4, (q15_t)0x894d, (q15_t)0x2fcd, (q15_t)0x8943, (q15_t)0x2fb5, (q15_t)0x893a, (q15_t)0x2f9e, (q15_t)0x8931, - (q15_t)0x2f87, (q15_t)0x8927, (q15_t)0x2f6f, (q15_t)0x891e, (q15_t)0x2f58, (q15_t)0x8915, (q15_t)0x2f41, (q15_t)0x890b, - (q15_t)0x2f29, (q15_t)0x8902, (q15_t)0x2f12, (q15_t)0x88f9, (q15_t)0x2efb, (q15_t)0x88f0, (q15_t)0x2ee3, (q15_t)0x88e6, - (q15_t)0x2ecc, (q15_t)0x88dd, (q15_t)0x2eb5, (q15_t)0x88d4, (q15_t)0x2e9d, (q15_t)0x88cb, (q15_t)0x2e86, (q15_t)0x88c2, - (q15_t)0x2e6e, (q15_t)0x88b9, (q15_t)0x2e57, (q15_t)0x88af, (q15_t)0x2e3f, (q15_t)0x88a6, (q15_t)0x2e28, (q15_t)0x889d, - (q15_t)0x2e11, (q15_t)0x8894, (q15_t)0x2df9, (q15_t)0x888b, (q15_t)0x2de2, (q15_t)0x8882, (q15_t)0x2dca, (q15_t)0x8879, - (q15_t)0x2db3, (q15_t)0x8870, (q15_t)0x2d9b, (q15_t)0x8867, (q15_t)0x2d84, (q15_t)0x885e, (q15_t)0x2d6c, (q15_t)0x8855, - (q15_t)0x2d55, (q15_t)0x884c, (q15_t)0x2d3d, (q15_t)0x8844, (q15_t)0x2d26, (q15_t)0x883b, (q15_t)0x2d0e, (q15_t)0x8832, - (q15_t)0x2cf7, (q15_t)0x8829, (q15_t)0x2cdf, (q15_t)0x8820, (q15_t)0x2cc8, (q15_t)0x8817, (q15_t)0x2cb0, (q15_t)0x880f, - (q15_t)0x2c98, (q15_t)0x8806, (q15_t)0x2c81, (q15_t)0x87fd, (q15_t)0x2c69, (q15_t)0x87f4, (q15_t)0x2c52, (q15_t)0x87ec, - (q15_t)0x2c3a, (q15_t)0x87e3, (q15_t)0x2c23, (q15_t)0x87da, (q15_t)0x2c0b, (q15_t)0x87d2, (q15_t)0x2bf3, (q15_t)0x87c9, - (q15_t)0x2bdc, (q15_t)0x87c0, (q15_t)0x2bc4, (q15_t)0x87b8, (q15_t)0x2bad, (q15_t)0x87af, (q15_t)0x2b95, (q15_t)0x87a7, - (q15_t)0x2b7d, (q15_t)0x879e, (q15_t)0x2b66, (q15_t)0x8795, (q15_t)0x2b4e, (q15_t)0x878d, (q15_t)0x2b36, (q15_t)0x8784, - (q15_t)0x2b1f, (q15_t)0x877c, (q15_t)0x2b07, (q15_t)0x8774, (q15_t)0x2aef, (q15_t)0x876b, (q15_t)0x2ad8, (q15_t)0x8763, - (q15_t)0x2ac0, (q15_t)0x875a, (q15_t)0x2aa8, (q15_t)0x8752, (q15_t)0x2a91, (q15_t)0x874a, (q15_t)0x2a79, (q15_t)0x8741, - (q15_t)0x2a61, (q15_t)0x8739, (q15_t)0x2a49, (q15_t)0x8731, (q15_t)0x2a32, (q15_t)0x8728, (q15_t)0x2a1a, (q15_t)0x8720, - (q15_t)0x2a02, (q15_t)0x8718, (q15_t)0x29eb, (q15_t)0x870f, (q15_t)0x29d3, (q15_t)0x8707, (q15_t)0x29bb, (q15_t)0x86ff, - (q15_t)0x29a3, (q15_t)0x86f7, (q15_t)0x298b, (q15_t)0x86ef, (q15_t)0x2974, (q15_t)0x86e7, (q15_t)0x295c, (q15_t)0x86de, - (q15_t)0x2944, (q15_t)0x86d6, (q15_t)0x292c, (q15_t)0x86ce, (q15_t)0x2915, (q15_t)0x86c6, (q15_t)0x28fd, (q15_t)0x86be, - (q15_t)0x28e5, (q15_t)0x86b6, (q15_t)0x28cd, (q15_t)0x86ae, (q15_t)0x28b5, (q15_t)0x86a6, (q15_t)0x289d, (q15_t)0x869e, - (q15_t)0x2886, (q15_t)0x8696, (q15_t)0x286e, (q15_t)0x868e, (q15_t)0x2856, (q15_t)0x8686, (q15_t)0x283e, (q15_t)0x867e, - (q15_t)0x2826, (q15_t)0x8676, (q15_t)0x280e, (q15_t)0x866e, (q15_t)0x27f6, (q15_t)0x8667, (q15_t)0x27df, (q15_t)0x865f, - (q15_t)0x27c7, (q15_t)0x8657, (q15_t)0x27af, (q15_t)0x864f, (q15_t)0x2797, (q15_t)0x8647, (q15_t)0x277f, (q15_t)0x8640, - (q15_t)0x2767, (q15_t)0x8638, (q15_t)0x274f, (q15_t)0x8630, (q15_t)0x2737, (q15_t)0x8628, (q15_t)0x271f, (q15_t)0x8621, - (q15_t)0x2707, (q15_t)0x8619, (q15_t)0x26ef, (q15_t)0x8611, (q15_t)0x26d8, (q15_t)0x860a, (q15_t)0x26c0, (q15_t)0x8602, - (q15_t)0x26a8, (q15_t)0x85fb, (q15_t)0x2690, (q15_t)0x85f3, (q15_t)0x2678, (q15_t)0x85eb, (q15_t)0x2660, (q15_t)0x85e4, - (q15_t)0x2648, (q15_t)0x85dc, (q15_t)0x2630, (q15_t)0x85d5, (q15_t)0x2618, (q15_t)0x85cd, (q15_t)0x2600, (q15_t)0x85c6, - (q15_t)0x25e8, (q15_t)0x85be, (q15_t)0x25d0, (q15_t)0x85b7, (q15_t)0x25b8, (q15_t)0x85b0, (q15_t)0x25a0, (q15_t)0x85a8, - (q15_t)0x2588, (q15_t)0x85a1, (q15_t)0x2570, (q15_t)0x8599, (q15_t)0x2558, (q15_t)0x8592, (q15_t)0x2540, (q15_t)0x858b, - (q15_t)0x2528, (q15_t)0x8583, (q15_t)0x250f, (q15_t)0x857c, (q15_t)0x24f7, (q15_t)0x8575, (q15_t)0x24df, (q15_t)0x856e, - (q15_t)0x24c7, (q15_t)0x8566, (q15_t)0x24af, (q15_t)0x855f, (q15_t)0x2497, (q15_t)0x8558, (q15_t)0x247f, (q15_t)0x8551, - (q15_t)0x2467, (q15_t)0x854a, (q15_t)0x244f, (q15_t)0x8543, (q15_t)0x2437, (q15_t)0x853b, (q15_t)0x241f, (q15_t)0x8534, - (q15_t)0x2407, (q15_t)0x852d, (q15_t)0x23ee, (q15_t)0x8526, (q15_t)0x23d6, (q15_t)0x851f, (q15_t)0x23be, (q15_t)0x8518, - (q15_t)0x23a6, (q15_t)0x8511, (q15_t)0x238e, (q15_t)0x850a, (q15_t)0x2376, (q15_t)0x8503, (q15_t)0x235e, (q15_t)0x84fc, - (q15_t)0x2345, (q15_t)0x84f5, (q15_t)0x232d, (q15_t)0x84ee, (q15_t)0x2315, (q15_t)0x84e7, (q15_t)0x22fd, (q15_t)0x84e1, - (q15_t)0x22e5, (q15_t)0x84da, (q15_t)0x22cd, (q15_t)0x84d3, (q15_t)0x22b4, (q15_t)0x84cc, (q15_t)0x229c, (q15_t)0x84c5, - (q15_t)0x2284, (q15_t)0x84be, (q15_t)0x226c, (q15_t)0x84b8, (q15_t)0x2254, (q15_t)0x84b1, (q15_t)0x223b, (q15_t)0x84aa, - (q15_t)0x2223, (q15_t)0x84a3, (q15_t)0x220b, (q15_t)0x849d, (q15_t)0x21f3, (q15_t)0x8496, (q15_t)0x21da, (q15_t)0x848f, - (q15_t)0x21c2, (q15_t)0x8489, (q15_t)0x21aa, (q15_t)0x8482, (q15_t)0x2192, (q15_t)0x847c, (q15_t)0x2179, (q15_t)0x8475, - (q15_t)0x2161, (q15_t)0x846e, (q15_t)0x2149, (q15_t)0x8468, (q15_t)0x2131, (q15_t)0x8461, (q15_t)0x2118, (q15_t)0x845b, - (q15_t)0x2100, (q15_t)0x8454, (q15_t)0x20e8, (q15_t)0x844e, (q15_t)0x20d0, (q15_t)0x8447, (q15_t)0x20b7, (q15_t)0x8441, - (q15_t)0x209f, (q15_t)0x843b, (q15_t)0x2087, (q15_t)0x8434, (q15_t)0x206e, (q15_t)0x842e, (q15_t)0x2056, (q15_t)0x8427, - (q15_t)0x203e, (q15_t)0x8421, (q15_t)0x2025, (q15_t)0x841b, (q15_t)0x200d, (q15_t)0x8415, (q15_t)0x1ff5, (q15_t)0x840e, - (q15_t)0x1fdc, (q15_t)0x8408, (q15_t)0x1fc4, (q15_t)0x8402, (q15_t)0x1fac, (q15_t)0x83fb, (q15_t)0x1f93, (q15_t)0x83f5, - (q15_t)0x1f7b, (q15_t)0x83ef, (q15_t)0x1f63, (q15_t)0x83e9, (q15_t)0x1f4a, (q15_t)0x83e3, (q15_t)0x1f32, (q15_t)0x83dd, - (q15_t)0x1f19, (q15_t)0x83d7, (q15_t)0x1f01, (q15_t)0x83d0, (q15_t)0x1ee9, (q15_t)0x83ca, (q15_t)0x1ed0, (q15_t)0x83c4, - (q15_t)0x1eb8, (q15_t)0x83be, (q15_t)0x1ea0, (q15_t)0x83b8, (q15_t)0x1e87, (q15_t)0x83b2, (q15_t)0x1e6f, (q15_t)0x83ac, - (q15_t)0x1e56, (q15_t)0x83a6, (q15_t)0x1e3e, (q15_t)0x83a0, (q15_t)0x1e25, (q15_t)0x839a, (q15_t)0x1e0d, (q15_t)0x8394, - (q15_t)0x1df5, (q15_t)0x838f, (q15_t)0x1ddc, (q15_t)0x8389, (q15_t)0x1dc4, (q15_t)0x8383, (q15_t)0x1dab, (q15_t)0x837d, - (q15_t)0x1d93, (q15_t)0x8377, (q15_t)0x1d7a, (q15_t)0x8371, (q15_t)0x1d62, (q15_t)0x836c, (q15_t)0x1d49, (q15_t)0x8366, - (q15_t)0x1d31, (q15_t)0x8360, (q15_t)0x1d18, (q15_t)0x835a, (q15_t)0x1d00, (q15_t)0x8355, (q15_t)0x1ce8, (q15_t)0x834f, - (q15_t)0x1ccf, (q15_t)0x8349, (q15_t)0x1cb7, (q15_t)0x8344, (q15_t)0x1c9e, (q15_t)0x833e, (q15_t)0x1c86, (q15_t)0x8338, - (q15_t)0x1c6d, (q15_t)0x8333, (q15_t)0x1c55, (q15_t)0x832d, (q15_t)0x1c3c, (q15_t)0x8328, (q15_t)0x1c24, (q15_t)0x8322, - (q15_t)0x1c0b, (q15_t)0x831d, (q15_t)0x1bf2, (q15_t)0x8317, (q15_t)0x1bda, (q15_t)0x8312, (q15_t)0x1bc1, (q15_t)0x830c, - (q15_t)0x1ba9, (q15_t)0x8307, (q15_t)0x1b90, (q15_t)0x8301, (q15_t)0x1b78, (q15_t)0x82fc, (q15_t)0x1b5f, (q15_t)0x82f7, - (q15_t)0x1b47, (q15_t)0x82f1, (q15_t)0x1b2e, (q15_t)0x82ec, (q15_t)0x1b16, (q15_t)0x82e7, (q15_t)0x1afd, (q15_t)0x82e1, - (q15_t)0x1ae4, (q15_t)0x82dc, (q15_t)0x1acc, (q15_t)0x82d7, (q15_t)0x1ab3, (q15_t)0x82d1, (q15_t)0x1a9b, (q15_t)0x82cc, - (q15_t)0x1a82, (q15_t)0x82c7, (q15_t)0x1a6a, (q15_t)0x82c2, (q15_t)0x1a51, (q15_t)0x82bd, (q15_t)0x1a38, (q15_t)0x82b7, - (q15_t)0x1a20, (q15_t)0x82b2, (q15_t)0x1a07, (q15_t)0x82ad, (q15_t)0x19ef, (q15_t)0x82a8, (q15_t)0x19d6, (q15_t)0x82a3, - (q15_t)0x19bd, (q15_t)0x829e, (q15_t)0x19a5, (q15_t)0x8299, (q15_t)0x198c, (q15_t)0x8294, (q15_t)0x1973, (q15_t)0x828f, - (q15_t)0x195b, (q15_t)0x828a, (q15_t)0x1942, (q15_t)0x8285, (q15_t)0x192a, (q15_t)0x8280, (q15_t)0x1911, (q15_t)0x827b, - (q15_t)0x18f8, (q15_t)0x8276, (q15_t)0x18e0, (q15_t)0x8271, (q15_t)0x18c7, (q15_t)0x826c, (q15_t)0x18ae, (q15_t)0x8268, - (q15_t)0x1896, (q15_t)0x8263, (q15_t)0x187d, (q15_t)0x825e, (q15_t)0x1864, (q15_t)0x8259, (q15_t)0x184c, (q15_t)0x8254, - (q15_t)0x1833, (q15_t)0x8250, (q15_t)0x181a, (q15_t)0x824b, (q15_t)0x1802, (q15_t)0x8246, (q15_t)0x17e9, (q15_t)0x8241, - (q15_t)0x17d0, (q15_t)0x823d, (q15_t)0x17b7, (q15_t)0x8238, (q15_t)0x179f, (q15_t)0x8233, (q15_t)0x1786, (q15_t)0x822f, - (q15_t)0x176d, (q15_t)0x822a, (q15_t)0x1755, (q15_t)0x8226, (q15_t)0x173c, (q15_t)0x8221, (q15_t)0x1723, (q15_t)0x821c, - (q15_t)0x170a, (q15_t)0x8218, (q15_t)0x16f2, (q15_t)0x8213, (q15_t)0x16d9, (q15_t)0x820f, (q15_t)0x16c0, (q15_t)0x820a, - (q15_t)0x16a8, (q15_t)0x8206, (q15_t)0x168f, (q15_t)0x8201, (q15_t)0x1676, (q15_t)0x81fd, (q15_t)0x165d, (q15_t)0x81f9, - (q15_t)0x1645, (q15_t)0x81f4, (q15_t)0x162c, (q15_t)0x81f0, (q15_t)0x1613, (q15_t)0x81ec, (q15_t)0x15fa, (q15_t)0x81e7, - (q15_t)0x15e2, (q15_t)0x81e3, (q15_t)0x15c9, (q15_t)0x81df, (q15_t)0x15b0, (q15_t)0x81da, (q15_t)0x1597, (q15_t)0x81d6, - (q15_t)0x157f, (q15_t)0x81d2, (q15_t)0x1566, (q15_t)0x81ce, (q15_t)0x154d, (q15_t)0x81c9, (q15_t)0x1534, (q15_t)0x81c5, - (q15_t)0x151b, (q15_t)0x81c1, (q15_t)0x1503, (q15_t)0x81bd, (q15_t)0x14ea, (q15_t)0x81b9, (q15_t)0x14d1, (q15_t)0x81b5, - (q15_t)0x14b8, (q15_t)0x81b1, (q15_t)0x149f, (q15_t)0x81ad, (q15_t)0x1487, (q15_t)0x81a9, (q15_t)0x146e, (q15_t)0x81a5, - (q15_t)0x1455, (q15_t)0x81a1, (q15_t)0x143c, (q15_t)0x819d, (q15_t)0x1423, (q15_t)0x8199, (q15_t)0x140b, (q15_t)0x8195, - (q15_t)0x13f2, (q15_t)0x8191, (q15_t)0x13d9, (q15_t)0x818d, (q15_t)0x13c0, (q15_t)0x8189, (q15_t)0x13a7, (q15_t)0x8185, - (q15_t)0x138e, (q15_t)0x8181, (q15_t)0x1376, (q15_t)0x817d, (q15_t)0x135d, (q15_t)0x817a, (q15_t)0x1344, (q15_t)0x8176, - (q15_t)0x132b, (q15_t)0x8172, (q15_t)0x1312, (q15_t)0x816e, (q15_t)0x12f9, (q15_t)0x816b, (q15_t)0x12e0, (q15_t)0x8167, - (q15_t)0x12c8, (q15_t)0x8163, (q15_t)0x12af, (q15_t)0x815f, (q15_t)0x1296, (q15_t)0x815c, (q15_t)0x127d, (q15_t)0x8158, - (q15_t)0x1264, (q15_t)0x8155, (q15_t)0x124b, (q15_t)0x8151, (q15_t)0x1232, (q15_t)0x814d, (q15_t)0x1219, (q15_t)0x814a, - (q15_t)0x1201, (q15_t)0x8146, (q15_t)0x11e8, (q15_t)0x8143, (q15_t)0x11cf, (q15_t)0x813f, (q15_t)0x11b6, (q15_t)0x813c, - (q15_t)0x119d, (q15_t)0x8138, (q15_t)0x1184, (q15_t)0x8135, (q15_t)0x116b, (q15_t)0x8131, (q15_t)0x1152, (q15_t)0x812e, - (q15_t)0x1139, (q15_t)0x812b, (q15_t)0x1121, (q15_t)0x8127, (q15_t)0x1108, (q15_t)0x8124, (q15_t)0x10ef, (q15_t)0x8121, - (q15_t)0x10d6, (q15_t)0x811d, (q15_t)0x10bd, (q15_t)0x811a, (q15_t)0x10a4, (q15_t)0x8117, (q15_t)0x108b, (q15_t)0x8113, - (q15_t)0x1072, (q15_t)0x8110, (q15_t)0x1059, (q15_t)0x810d, (q15_t)0x1040, (q15_t)0x810a, (q15_t)0x1027, (q15_t)0x8107, - (q15_t)0x100e, (q15_t)0x8103, (q15_t)0xff5, (q15_t)0x8100, (q15_t)0xfdd, (q15_t)0x80fd, (q15_t)0xfc4, (q15_t)0x80fa, - (q15_t)0xfab, (q15_t)0x80f7, (q15_t)0xf92, (q15_t)0x80f4, (q15_t)0xf79, (q15_t)0x80f1, (q15_t)0xf60, (q15_t)0x80ee, - (q15_t)0xf47, (q15_t)0x80eb, (q15_t)0xf2e, (q15_t)0x80e8, (q15_t)0xf15, (q15_t)0x80e5, (q15_t)0xefc, (q15_t)0x80e2, - (q15_t)0xee3, (q15_t)0x80df, (q15_t)0xeca, (q15_t)0x80dc, (q15_t)0xeb1, (q15_t)0x80d9, (q15_t)0xe98, (q15_t)0x80d6, - (q15_t)0xe7f, (q15_t)0x80d3, (q15_t)0xe66, (q15_t)0x80d1, (q15_t)0xe4d, (q15_t)0x80ce, (q15_t)0xe34, (q15_t)0x80cb, - (q15_t)0xe1b, (q15_t)0x80c8, (q15_t)0xe02, (q15_t)0x80c5, (q15_t)0xde9, (q15_t)0x80c3, (q15_t)0xdd0, (q15_t)0x80c0, - (q15_t)0xdb7, (q15_t)0x80bd, (q15_t)0xd9e, (q15_t)0x80bb, (q15_t)0xd85, (q15_t)0x80b8, (q15_t)0xd6c, (q15_t)0x80b5, - (q15_t)0xd53, (q15_t)0x80b3, (q15_t)0xd3a, (q15_t)0x80b0, (q15_t)0xd21, (q15_t)0x80ad, (q15_t)0xd08, (q15_t)0x80ab, - (q15_t)0xcef, (q15_t)0x80a8, (q15_t)0xcd6, (q15_t)0x80a6, (q15_t)0xcbd, (q15_t)0x80a3, (q15_t)0xca4, (q15_t)0x80a1, - (q15_t)0xc8b, (q15_t)0x809e, (q15_t)0xc72, (q15_t)0x809c, (q15_t)0xc59, (q15_t)0x8099, (q15_t)0xc40, (q15_t)0x8097, - (q15_t)0xc27, (q15_t)0x8095, (q15_t)0xc0e, (q15_t)0x8092, (q15_t)0xbf5, (q15_t)0x8090, (q15_t)0xbdc, (q15_t)0x808e, - (q15_t)0xbc3, (q15_t)0x808b, (q15_t)0xbaa, (q15_t)0x8089, (q15_t)0xb91, (q15_t)0x8087, (q15_t)0xb78, (q15_t)0x8084, - (q15_t)0xb5f, (q15_t)0x8082, (q15_t)0xb46, (q15_t)0x8080, (q15_t)0xb2d, (q15_t)0x807e, (q15_t)0xb14, (q15_t)0x807b, - (q15_t)0xafb, (q15_t)0x8079, (q15_t)0xae2, (q15_t)0x8077, (q15_t)0xac9, (q15_t)0x8075, (q15_t)0xab0, (q15_t)0x8073, - (q15_t)0xa97, (q15_t)0x8071, (q15_t)0xa7e, (q15_t)0x806f, (q15_t)0xa65, (q15_t)0x806d, (q15_t)0xa4c, (q15_t)0x806b, - (q15_t)0xa33, (q15_t)0x8069, (q15_t)0xa19, (q15_t)0x8067, (q15_t)0xa00, (q15_t)0x8065, (q15_t)0x9e7, (q15_t)0x8063, - (q15_t)0x9ce, (q15_t)0x8061, (q15_t)0x9b5, (q15_t)0x805f, (q15_t)0x99c, (q15_t)0x805d, (q15_t)0x983, (q15_t)0x805b, - (q15_t)0x96a, (q15_t)0x8059, (q15_t)0x951, (q15_t)0x8057, (q15_t)0x938, (q15_t)0x8056, (q15_t)0x91f, (q15_t)0x8054, - (q15_t)0x906, (q15_t)0x8052, (q15_t)0x8ed, (q15_t)0x8050, (q15_t)0x8d4, (q15_t)0x804f, (q15_t)0x8bb, (q15_t)0x804d, - (q15_t)0x8a2, (q15_t)0x804b, (q15_t)0x888, (q15_t)0x8049, (q15_t)0x86f, (q15_t)0x8048, (q15_t)0x856, (q15_t)0x8046, - (q15_t)0x83d, (q15_t)0x8044, (q15_t)0x824, (q15_t)0x8043, (q15_t)0x80b, (q15_t)0x8041, (q15_t)0x7f2, (q15_t)0x8040, - (q15_t)0x7d9, (q15_t)0x803e, (q15_t)0x7c0, (q15_t)0x803d, (q15_t)0x7a7, (q15_t)0x803b, (q15_t)0x78e, (q15_t)0x803a, - (q15_t)0x775, (q15_t)0x8038, (q15_t)0x75b, (q15_t)0x8037, (q15_t)0x742, (q15_t)0x8035, (q15_t)0x729, (q15_t)0x8034, - (q15_t)0x710, (q15_t)0x8032, (q15_t)0x6f7, (q15_t)0x8031, (q15_t)0x6de, (q15_t)0x8030, (q15_t)0x6c5, (q15_t)0x802e, - (q15_t)0x6ac, (q15_t)0x802d, (q15_t)0x693, (q15_t)0x802c, (q15_t)0x67a, (q15_t)0x802a, (q15_t)0x660, (q15_t)0x8029, - (q15_t)0x647, (q15_t)0x8028, (q15_t)0x62e, (q15_t)0x8027, (q15_t)0x615, (q15_t)0x8026, (q15_t)0x5fc, (q15_t)0x8024, - (q15_t)0x5e3, (q15_t)0x8023, (q15_t)0x5ca, (q15_t)0x8022, (q15_t)0x5b1, (q15_t)0x8021, (q15_t)0x598, (q15_t)0x8020, - (q15_t)0x57f, (q15_t)0x801f, (q15_t)0x565, (q15_t)0x801e, (q15_t)0x54c, (q15_t)0x801d, (q15_t)0x533, (q15_t)0x801c, - (q15_t)0x51a, (q15_t)0x801b, (q15_t)0x501, (q15_t)0x801a, (q15_t)0x4e8, (q15_t)0x8019, (q15_t)0x4cf, (q15_t)0x8018, - (q15_t)0x4b6, (q15_t)0x8017, (q15_t)0x49c, (q15_t)0x8016, (q15_t)0x483, (q15_t)0x8015, (q15_t)0x46a, (q15_t)0x8014, - (q15_t)0x451, (q15_t)0x8013, (q15_t)0x438, (q15_t)0x8012, (q15_t)0x41f, (q15_t)0x8012, (q15_t)0x406, (q15_t)0x8011, - (q15_t)0x3ed, (q15_t)0x8010, (q15_t)0x3d4, (q15_t)0x800f, (q15_t)0x3ba, (q15_t)0x800e, (q15_t)0x3a1, (q15_t)0x800e, - (q15_t)0x388, (q15_t)0x800d, (q15_t)0x36f, (q15_t)0x800c, (q15_t)0x356, (q15_t)0x800c, (q15_t)0x33d, (q15_t)0x800b, - (q15_t)0x324, (q15_t)0x800a, (q15_t)0x30b, (q15_t)0x800a, (q15_t)0x2f1, (q15_t)0x8009, (q15_t)0x2d8, (q15_t)0x8009, - (q15_t)0x2bf, (q15_t)0x8008, (q15_t)0x2a6, (q15_t)0x8008, (q15_t)0x28d, (q15_t)0x8007, (q15_t)0x274, (q15_t)0x8007, - (q15_t)0x25b, (q15_t)0x8006, (q15_t)0x242, (q15_t)0x8006, (q15_t)0x228, (q15_t)0x8005, (q15_t)0x20f, (q15_t)0x8005, - (q15_t)0x1f6, (q15_t)0x8004, (q15_t)0x1dd, (q15_t)0x8004, (q15_t)0x1c4, (q15_t)0x8004, (q15_t)0x1ab, (q15_t)0x8003, - (q15_t)0x192, (q15_t)0x8003, (q15_t)0x178, (q15_t)0x8003, (q15_t)0x15f, (q15_t)0x8002, (q15_t)0x146, (q15_t)0x8002, - (q15_t)0x12d, (q15_t)0x8002, (q15_t)0x114, (q15_t)0x8002, (q15_t)0xfb, (q15_t)0x8001, (q15_t)0xe2, (q15_t)0x8001, - (q15_t)0xc9, (q15_t)0x8001, (q15_t)0xaf, (q15_t)0x8001, (q15_t)0x96, (q15_t)0x8001, (q15_t)0x7d, (q15_t)0x8001, - (q15_t)0x64, (q15_t)0x8001, (q15_t)0x4b, (q15_t)0x8001, (q15_t)0x32, (q15_t)0x8001, (q15_t)0x19, (q15_t)0x8001 -}; + (q15_t)0x7fff, (q15_t)0x0, (q15_t)0x7fff, (q15_t)0xffe7, (q15_t)0x7fff, + (q15_t)0xffce, (q15_t)0x7fff, (q15_t)0xffb5, (q15_t)0x7fff, (q15_t)0xff9c, + (q15_t)0x7fff, (q15_t)0xff83, (q15_t)0x7fff, (q15_t)0xff6a, (q15_t)0x7fff, + (q15_t)0xff51, (q15_t)0x7fff, (q15_t)0xff37, (q15_t)0x7fff, (q15_t)0xff1e, + (q15_t)0x7fff, (q15_t)0xff05, (q15_t)0x7ffe, (q15_t)0xfeec, (q15_t)0x7ffe, + (q15_t)0xfed3, (q15_t)0x7ffe, (q15_t)0xfeba, (q15_t)0x7ffe, (q15_t)0xfea1, + (q15_t)0x7ffd, (q15_t)0xfe88, (q15_t)0x7ffd, (q15_t)0xfe6e, (q15_t)0x7ffd, + (q15_t)0xfe55, (q15_t)0x7ffc, (q15_t)0xfe3c, (q15_t)0x7ffc, (q15_t)0xfe23, + (q15_t)0x7ffc, (q15_t)0xfe0a, (q15_t)0x7ffb, (q15_t)0xfdf1, (q15_t)0x7ffb, + (q15_t)0xfdd8, (q15_t)0x7ffa, (q15_t)0xfdbe, (q15_t)0x7ffa, (q15_t)0xfda5, + (q15_t)0x7ff9, (q15_t)0xfd8c, (q15_t)0x7ff9, (q15_t)0xfd73, (q15_t)0x7ff8, + (q15_t)0xfd5a, (q15_t)0x7ff8, (q15_t)0xfd41, (q15_t)0x7ff7, (q15_t)0xfd28, + (q15_t)0x7ff7, (q15_t)0xfd0f, (q15_t)0x7ff6, (q15_t)0xfcf5, (q15_t)0x7ff6, + (q15_t)0xfcdc, (q15_t)0x7ff5, (q15_t)0xfcc3, (q15_t)0x7ff4, (q15_t)0xfcaa, + (q15_t)0x7ff4, (q15_t)0xfc91, (q15_t)0x7ff3, (q15_t)0xfc78, (q15_t)0x7ff2, + (q15_t)0xfc5f, (q15_t)0x7ff2, (q15_t)0xfc46, (q15_t)0x7ff1, (q15_t)0xfc2c, + (q15_t)0x7ff0, (q15_t)0xfc13, (q15_t)0x7fef, (q15_t)0xfbfa, (q15_t)0x7fee, + (q15_t)0xfbe1, (q15_t)0x7fee, (q15_t)0xfbc8, (q15_t)0x7fed, (q15_t)0xfbaf, + (q15_t)0x7fec, (q15_t)0xfb96, (q15_t)0x7feb, (q15_t)0xfb7d, (q15_t)0x7fea, + (q15_t)0xfb64, (q15_t)0x7fe9, (q15_t)0xfb4a, (q15_t)0x7fe8, (q15_t)0xfb31, + (q15_t)0x7fe7, (q15_t)0xfb18, (q15_t)0x7fe6, (q15_t)0xfaff, (q15_t)0x7fe5, + (q15_t)0xfae6, (q15_t)0x7fe4, (q15_t)0xfacd, (q15_t)0x7fe3, (q15_t)0xfab4, + (q15_t)0x7fe2, (q15_t)0xfa9b, (q15_t)0x7fe1, (q15_t)0xfa81, (q15_t)0x7fe0, + (q15_t)0xfa68, (q15_t)0x7fdf, (q15_t)0xfa4f, (q15_t)0x7fde, (q15_t)0xfa36, + (q15_t)0x7fdd, (q15_t)0xfa1d, (q15_t)0x7fdc, (q15_t)0xfa04, (q15_t)0x7fda, + (q15_t)0xf9eb, (q15_t)0x7fd9, (q15_t)0xf9d2, (q15_t)0x7fd8, (q15_t)0xf9b9, + (q15_t)0x7fd7, (q15_t)0xf9a0, (q15_t)0x7fd6, (q15_t)0xf986, (q15_t)0x7fd4, + (q15_t)0xf96d, (q15_t)0x7fd3, (q15_t)0xf954, (q15_t)0x7fd2, (q15_t)0xf93b, + (q15_t)0x7fd0, (q15_t)0xf922, (q15_t)0x7fcf, (q15_t)0xf909, (q15_t)0x7fce, + (q15_t)0xf8f0, (q15_t)0x7fcc, (q15_t)0xf8d7, (q15_t)0x7fcb, (q15_t)0xf8be, + (q15_t)0x7fc9, (q15_t)0xf8a5, (q15_t)0x7fc8, (q15_t)0xf88b, (q15_t)0x7fc6, + (q15_t)0xf872, (q15_t)0x7fc5, (q15_t)0xf859, (q15_t)0x7fc3, (q15_t)0xf840, + (q15_t)0x7fc2, (q15_t)0xf827, (q15_t)0x7fc0, (q15_t)0xf80e, (q15_t)0x7fbf, + (q15_t)0xf7f5, (q15_t)0x7fbd, (q15_t)0xf7dc, (q15_t)0x7fbc, (q15_t)0xf7c3, + (q15_t)0x7fba, (q15_t)0xf7aa, (q15_t)0x7fb8, (q15_t)0xf791, (q15_t)0x7fb7, + (q15_t)0xf778, (q15_t)0x7fb5, (q15_t)0xf75e, (q15_t)0x7fb3, (q15_t)0xf745, + (q15_t)0x7fb1, (q15_t)0xf72c, (q15_t)0x7fb0, (q15_t)0xf713, (q15_t)0x7fae, + (q15_t)0xf6fa, (q15_t)0x7fac, (q15_t)0xf6e1, (q15_t)0x7faa, (q15_t)0xf6c8, + (q15_t)0x7fa9, (q15_t)0xf6af, (q15_t)0x7fa7, (q15_t)0xf696, (q15_t)0x7fa5, + (q15_t)0xf67d, (q15_t)0x7fa3, (q15_t)0xf664, (q15_t)0x7fa1, (q15_t)0xf64b, + (q15_t)0x7f9f, (q15_t)0xf632, (q15_t)0x7f9d, (q15_t)0xf619, (q15_t)0x7f9b, + (q15_t)0xf600, (q15_t)0x7f99, (q15_t)0xf5e7, (q15_t)0x7f97, (q15_t)0xf5cd, + (q15_t)0x7f95, (q15_t)0xf5b4, (q15_t)0x7f93, (q15_t)0xf59b, (q15_t)0x7f91, + (q15_t)0xf582, (q15_t)0x7f8f, (q15_t)0xf569, (q15_t)0x7f8d, (q15_t)0xf550, + (q15_t)0x7f8b, (q15_t)0xf537, (q15_t)0x7f89, (q15_t)0xf51e, (q15_t)0x7f87, + (q15_t)0xf505, (q15_t)0x7f85, (q15_t)0xf4ec, (q15_t)0x7f82, (q15_t)0xf4d3, + (q15_t)0x7f80, (q15_t)0xf4ba, (q15_t)0x7f7e, (q15_t)0xf4a1, (q15_t)0x7f7c, + (q15_t)0xf488, (q15_t)0x7f79, (q15_t)0xf46f, (q15_t)0x7f77, (q15_t)0xf456, + (q15_t)0x7f75, (q15_t)0xf43d, (q15_t)0x7f72, (q15_t)0xf424, (q15_t)0x7f70, + (q15_t)0xf40b, (q15_t)0x7f6e, (q15_t)0xf3f2, (q15_t)0x7f6b, (q15_t)0xf3d9, + (q15_t)0x7f69, (q15_t)0xf3c0, (q15_t)0x7f67, (q15_t)0xf3a7, (q15_t)0x7f64, + (q15_t)0xf38e, (q15_t)0x7f62, (q15_t)0xf375, (q15_t)0x7f5f, (q15_t)0xf35c, + (q15_t)0x7f5d, (q15_t)0xf343, (q15_t)0x7f5a, (q15_t)0xf32a, (q15_t)0x7f58, + (q15_t)0xf311, (q15_t)0x7f55, (q15_t)0xf2f8, (q15_t)0x7f53, (q15_t)0xf2df, + (q15_t)0x7f50, (q15_t)0xf2c6, (q15_t)0x7f4d, (q15_t)0xf2ad, (q15_t)0x7f4b, + (q15_t)0xf294, (q15_t)0x7f48, (q15_t)0xf27b, (q15_t)0x7f45, (q15_t)0xf262, + (q15_t)0x7f43, (q15_t)0xf249, (q15_t)0x7f40, (q15_t)0xf230, (q15_t)0x7f3d, + (q15_t)0xf217, (q15_t)0x7f3b, (q15_t)0xf1fe, (q15_t)0x7f38, (q15_t)0xf1e5, + (q15_t)0x7f35, (q15_t)0xf1cc, (q15_t)0x7f32, (q15_t)0xf1b3, (q15_t)0x7f2f, + (q15_t)0xf19a, (q15_t)0x7f2d, (q15_t)0xf181, (q15_t)0x7f2a, (q15_t)0xf168, + (q15_t)0x7f27, (q15_t)0xf14f, (q15_t)0x7f24, (q15_t)0xf136, (q15_t)0x7f21, + (q15_t)0xf11d, (q15_t)0x7f1e, (q15_t)0xf104, (q15_t)0x7f1b, (q15_t)0xf0eb, + (q15_t)0x7f18, (q15_t)0xf0d2, (q15_t)0x7f15, (q15_t)0xf0b9, (q15_t)0x7f12, + (q15_t)0xf0a0, (q15_t)0x7f0f, (q15_t)0xf087, (q15_t)0x7f0c, (q15_t)0xf06e, + (q15_t)0x7f09, (q15_t)0xf055, (q15_t)0x7f06, (q15_t)0xf03c, (q15_t)0x7f03, + (q15_t)0xf023, (q15_t)0x7f00, (q15_t)0xf00b, (q15_t)0x7efd, (q15_t)0xeff2, + (q15_t)0x7ef9, (q15_t)0xefd9, (q15_t)0x7ef6, (q15_t)0xefc0, (q15_t)0x7ef3, + (q15_t)0xefa7, (q15_t)0x7ef0, (q15_t)0xef8e, (q15_t)0x7eed, (q15_t)0xef75, + (q15_t)0x7ee9, (q15_t)0xef5c, (q15_t)0x7ee6, (q15_t)0xef43, (q15_t)0x7ee3, + (q15_t)0xef2a, (q15_t)0x7edf, (q15_t)0xef11, (q15_t)0x7edc, (q15_t)0xeef8, + (q15_t)0x7ed9, (q15_t)0xeedf, (q15_t)0x7ed5, (q15_t)0xeec7, (q15_t)0x7ed2, + (q15_t)0xeeae, (q15_t)0x7ecf, (q15_t)0xee95, (q15_t)0x7ecb, (q15_t)0xee7c, + (q15_t)0x7ec8, (q15_t)0xee63, (q15_t)0x7ec4, (q15_t)0xee4a, (q15_t)0x7ec1, + (q15_t)0xee31, (q15_t)0x7ebd, (q15_t)0xee18, (q15_t)0x7eba, (q15_t)0xedff, + (q15_t)0x7eb6, (q15_t)0xede7, (q15_t)0x7eb3, (q15_t)0xedce, (q15_t)0x7eaf, + (q15_t)0xedb5, (q15_t)0x7eab, (q15_t)0xed9c, (q15_t)0x7ea8, (q15_t)0xed83, + (q15_t)0x7ea4, (q15_t)0xed6a, (q15_t)0x7ea1, (q15_t)0xed51, (q15_t)0x7e9d, + (q15_t)0xed38, (q15_t)0x7e99, (q15_t)0xed20, (q15_t)0x7e95, (q15_t)0xed07, + (q15_t)0x7e92, (q15_t)0xecee, (q15_t)0x7e8e, (q15_t)0xecd5, (q15_t)0x7e8a, + (q15_t)0xecbc, (q15_t)0x7e86, (q15_t)0xeca3, (q15_t)0x7e83, (q15_t)0xec8a, + (q15_t)0x7e7f, (q15_t)0xec72, (q15_t)0x7e7b, (q15_t)0xec59, (q15_t)0x7e77, + (q15_t)0xec40, (q15_t)0x7e73, (q15_t)0xec27, (q15_t)0x7e6f, (q15_t)0xec0e, + (q15_t)0x7e6b, (q15_t)0xebf5, (q15_t)0x7e67, (q15_t)0xebdd, (q15_t)0x7e63, + (q15_t)0xebc4, (q15_t)0x7e5f, (q15_t)0xebab, (q15_t)0x7e5b, (q15_t)0xeb92, + (q15_t)0x7e57, (q15_t)0xeb79, (q15_t)0x7e53, (q15_t)0xeb61, (q15_t)0x7e4f, + (q15_t)0xeb48, (q15_t)0x7e4b, (q15_t)0xeb2f, (q15_t)0x7e47, (q15_t)0xeb16, + (q15_t)0x7e43, (q15_t)0xeafd, (q15_t)0x7e3f, (q15_t)0xeae5, (q15_t)0x7e3b, + (q15_t)0xeacc, (q15_t)0x7e37, (q15_t)0xeab3, (q15_t)0x7e32, (q15_t)0xea9a, + (q15_t)0x7e2e, (q15_t)0xea81, (q15_t)0x7e2a, (q15_t)0xea69, (q15_t)0x7e26, + (q15_t)0xea50, (q15_t)0x7e21, (q15_t)0xea37, (q15_t)0x7e1d, (q15_t)0xea1e, + (q15_t)0x7e19, (q15_t)0xea06, (q15_t)0x7e14, (q15_t)0xe9ed, (q15_t)0x7e10, + (q15_t)0xe9d4, (q15_t)0x7e0c, (q15_t)0xe9bb, (q15_t)0x7e07, (q15_t)0xe9a3, + (q15_t)0x7e03, (q15_t)0xe98a, (q15_t)0x7dff, (q15_t)0xe971, (q15_t)0x7dfa, + (q15_t)0xe958, (q15_t)0x7df6, (q15_t)0xe940, (q15_t)0x7df1, (q15_t)0xe927, + (q15_t)0x7ded, (q15_t)0xe90e, (q15_t)0x7de8, (q15_t)0xe8f6, (q15_t)0x7de4, + (q15_t)0xe8dd, (q15_t)0x7ddf, (q15_t)0xe8c4, (q15_t)0x7dda, (q15_t)0xe8ab, + (q15_t)0x7dd6, (q15_t)0xe893, (q15_t)0x7dd1, (q15_t)0xe87a, (q15_t)0x7dcd, + (q15_t)0xe861, (q15_t)0x7dc8, (q15_t)0xe849, (q15_t)0x7dc3, (q15_t)0xe830, + (q15_t)0x7dbf, (q15_t)0xe817, (q15_t)0x7dba, (q15_t)0xe7fe, (q15_t)0x7db5, + (q15_t)0xe7e6, (q15_t)0x7db0, (q15_t)0xe7cd, (q15_t)0x7dac, (q15_t)0xe7b4, + (q15_t)0x7da7, (q15_t)0xe79c, (q15_t)0x7da2, (q15_t)0xe783, (q15_t)0x7d9d, + (q15_t)0xe76a, (q15_t)0x7d98, (q15_t)0xe752, (q15_t)0x7d94, (q15_t)0xe739, + (q15_t)0x7d8f, (q15_t)0xe720, (q15_t)0x7d8a, (q15_t)0xe708, (q15_t)0x7d85, + (q15_t)0xe6ef, (q15_t)0x7d80, (q15_t)0xe6d6, (q15_t)0x7d7b, (q15_t)0xe6be, + (q15_t)0x7d76, (q15_t)0xe6a5, (q15_t)0x7d71, (q15_t)0xe68d, (q15_t)0x7d6c, + (q15_t)0xe674, (q15_t)0x7d67, (q15_t)0xe65b, (q15_t)0x7d62, (q15_t)0xe643, + (q15_t)0x7d5d, (q15_t)0xe62a, (q15_t)0x7d58, (q15_t)0xe611, (q15_t)0x7d53, + (q15_t)0xe5f9, (q15_t)0x7d4e, (q15_t)0xe5e0, (q15_t)0x7d49, (q15_t)0xe5c8, + (q15_t)0x7d43, (q15_t)0xe5af, (q15_t)0x7d3e, (q15_t)0xe596, (q15_t)0x7d39, + (q15_t)0xe57e, (q15_t)0x7d34, (q15_t)0xe565, (q15_t)0x7d2f, (q15_t)0xe54d, + (q15_t)0x7d29, (q15_t)0xe534, (q15_t)0x7d24, (q15_t)0xe51c, (q15_t)0x7d1f, + (q15_t)0xe503, (q15_t)0x7d19, (q15_t)0xe4ea, (q15_t)0x7d14, (q15_t)0xe4d2, + (q15_t)0x7d0f, (q15_t)0xe4b9, (q15_t)0x7d09, (q15_t)0xe4a1, (q15_t)0x7d04, + (q15_t)0xe488, (q15_t)0x7cff, (q15_t)0xe470, (q15_t)0x7cf9, (q15_t)0xe457, + (q15_t)0x7cf4, (q15_t)0xe43f, (q15_t)0x7cee, (q15_t)0xe426, (q15_t)0x7ce9, + (q15_t)0xe40e, (q15_t)0x7ce3, (q15_t)0xe3f5, (q15_t)0x7cde, (q15_t)0xe3dc, + (q15_t)0x7cd8, (q15_t)0xe3c4, (q15_t)0x7cd3, (q15_t)0xe3ab, (q15_t)0x7ccd, + (q15_t)0xe393, (q15_t)0x7cc8, (q15_t)0xe37a, (q15_t)0x7cc2, (q15_t)0xe362, + (q15_t)0x7cbc, (q15_t)0xe349, (q15_t)0x7cb7, (q15_t)0xe331, (q15_t)0x7cb1, + (q15_t)0xe318, (q15_t)0x7cab, (q15_t)0xe300, (q15_t)0x7ca6, (q15_t)0xe2e8, + (q15_t)0x7ca0, (q15_t)0xe2cf, (q15_t)0x7c9a, (q15_t)0xe2b7, (q15_t)0x7c94, + (q15_t)0xe29e, (q15_t)0x7c8f, (q15_t)0xe286, (q15_t)0x7c89, (q15_t)0xe26d, + (q15_t)0x7c83, (q15_t)0xe255, (q15_t)0x7c7d, (q15_t)0xe23c, (q15_t)0x7c77, + (q15_t)0xe224, (q15_t)0x7c71, (q15_t)0xe20b, (q15_t)0x7c6c, (q15_t)0xe1f3, + (q15_t)0x7c66, (q15_t)0xe1db, (q15_t)0x7c60, (q15_t)0xe1c2, (q15_t)0x7c5a, + (q15_t)0xe1aa, (q15_t)0x7c54, (q15_t)0xe191, (q15_t)0x7c4e, (q15_t)0xe179, + (q15_t)0x7c48, (q15_t)0xe160, (q15_t)0x7c42, (q15_t)0xe148, (q15_t)0x7c3c, + (q15_t)0xe130, (q15_t)0x7c36, (q15_t)0xe117, (q15_t)0x7c30, (q15_t)0xe0ff, + (q15_t)0x7c29, (q15_t)0xe0e7, (q15_t)0x7c23, (q15_t)0xe0ce, (q15_t)0x7c1d, + (q15_t)0xe0b6, (q15_t)0x7c17, (q15_t)0xe09d, (q15_t)0x7c11, (q15_t)0xe085, + (q15_t)0x7c0b, (q15_t)0xe06d, (q15_t)0x7c05, (q15_t)0xe054, (q15_t)0x7bfe, + (q15_t)0xe03c, (q15_t)0x7bf8, (q15_t)0xe024, (q15_t)0x7bf2, (q15_t)0xe00b, + (q15_t)0x7beb, (q15_t)0xdff3, (q15_t)0x7be5, (q15_t)0xdfdb, (q15_t)0x7bdf, + (q15_t)0xdfc2, (q15_t)0x7bd9, (q15_t)0xdfaa, (q15_t)0x7bd2, (q15_t)0xdf92, + (q15_t)0x7bcc, (q15_t)0xdf79, (q15_t)0x7bc5, (q15_t)0xdf61, (q15_t)0x7bbf, + (q15_t)0xdf49, (q15_t)0x7bb9, (q15_t)0xdf30, (q15_t)0x7bb2, (q15_t)0xdf18, + (q15_t)0x7bac, (q15_t)0xdf00, (q15_t)0x7ba5, (q15_t)0xdee8, (q15_t)0x7b9f, + (q15_t)0xdecf, (q15_t)0x7b98, (q15_t)0xdeb7, (q15_t)0x7b92, (q15_t)0xde9f, + (q15_t)0x7b8b, (q15_t)0xde87, (q15_t)0x7b84, (q15_t)0xde6e, (q15_t)0x7b7e, + (q15_t)0xde56, (q15_t)0x7b77, (q15_t)0xde3e, (q15_t)0x7b71, (q15_t)0xde26, + (q15_t)0x7b6a, (q15_t)0xde0d, (q15_t)0x7b63, (q15_t)0xddf5, (q15_t)0x7b5d, + (q15_t)0xdddd, (q15_t)0x7b56, (q15_t)0xddc5, (q15_t)0x7b4f, (q15_t)0xddac, + (q15_t)0x7b48, (q15_t)0xdd94, (q15_t)0x7b42, (q15_t)0xdd7c, (q15_t)0x7b3b, + (q15_t)0xdd64, (q15_t)0x7b34, (q15_t)0xdd4c, (q15_t)0x7b2d, (q15_t)0xdd33, + (q15_t)0x7b26, (q15_t)0xdd1b, (q15_t)0x7b1f, (q15_t)0xdd03, (q15_t)0x7b19, + (q15_t)0xdceb, (q15_t)0x7b12, (q15_t)0xdcd3, (q15_t)0x7b0b, (q15_t)0xdcbb, + (q15_t)0x7b04, (q15_t)0xdca2, (q15_t)0x7afd, (q15_t)0xdc8a, (q15_t)0x7af6, + (q15_t)0xdc72, (q15_t)0x7aef, (q15_t)0xdc5a, (q15_t)0x7ae8, (q15_t)0xdc42, + (q15_t)0x7ae1, (q15_t)0xdc2a, (q15_t)0x7ada, (q15_t)0xdc12, (q15_t)0x7ad3, + (q15_t)0xdbf9, (q15_t)0x7acc, (q15_t)0xdbe1, (q15_t)0x7ac5, (q15_t)0xdbc9, + (q15_t)0x7abd, (q15_t)0xdbb1, (q15_t)0x7ab6, (q15_t)0xdb99, (q15_t)0x7aaf, + (q15_t)0xdb81, (q15_t)0x7aa8, (q15_t)0xdb69, (q15_t)0x7aa1, (q15_t)0xdb51, + (q15_t)0x7a9a, (q15_t)0xdb39, (q15_t)0x7a92, (q15_t)0xdb21, (q15_t)0x7a8b, + (q15_t)0xdb09, (q15_t)0x7a84, (q15_t)0xdaf1, (q15_t)0x7a7d, (q15_t)0xdad8, + (q15_t)0x7a75, (q15_t)0xdac0, (q15_t)0x7a6e, (q15_t)0xdaa8, (q15_t)0x7a67, + (q15_t)0xda90, (q15_t)0x7a5f, (q15_t)0xda78, (q15_t)0x7a58, (q15_t)0xda60, + (q15_t)0x7a50, (q15_t)0xda48, (q15_t)0x7a49, (q15_t)0xda30, (q15_t)0x7a42, + (q15_t)0xda18, (q15_t)0x7a3a, (q15_t)0xda00, (q15_t)0x7a33, (q15_t)0xd9e8, + (q15_t)0x7a2b, (q15_t)0xd9d0, (q15_t)0x7a24, (q15_t)0xd9b8, (q15_t)0x7a1c, + (q15_t)0xd9a0, (q15_t)0x7a15, (q15_t)0xd988, (q15_t)0x7a0d, (q15_t)0xd970, + (q15_t)0x7a05, (q15_t)0xd958, (q15_t)0x79fe, (q15_t)0xd940, (q15_t)0x79f6, + (q15_t)0xd928, (q15_t)0x79ef, (q15_t)0xd911, (q15_t)0x79e7, (q15_t)0xd8f9, + (q15_t)0x79df, (q15_t)0xd8e1, (q15_t)0x79d8, (q15_t)0xd8c9, (q15_t)0x79d0, + (q15_t)0xd8b1, (q15_t)0x79c8, (q15_t)0xd899, (q15_t)0x79c0, (q15_t)0xd881, + (q15_t)0x79b9, (q15_t)0xd869, (q15_t)0x79b1, (q15_t)0xd851, (q15_t)0x79a9, + (q15_t)0xd839, (q15_t)0x79a1, (q15_t)0xd821, (q15_t)0x7999, (q15_t)0xd80a, + (q15_t)0x7992, (q15_t)0xd7f2, (q15_t)0x798a, (q15_t)0xd7da, (q15_t)0x7982, + (q15_t)0xd7c2, (q15_t)0x797a, (q15_t)0xd7aa, (q15_t)0x7972, (q15_t)0xd792, + (q15_t)0x796a, (q15_t)0xd77a, (q15_t)0x7962, (q15_t)0xd763, (q15_t)0x795a, + (q15_t)0xd74b, (q15_t)0x7952, (q15_t)0xd733, (q15_t)0x794a, (q15_t)0xd71b, + (q15_t)0x7942, (q15_t)0xd703, (q15_t)0x793a, (q15_t)0xd6eb, (q15_t)0x7932, + (q15_t)0xd6d4, (q15_t)0x792a, (q15_t)0xd6bc, (q15_t)0x7922, (q15_t)0xd6a4, + (q15_t)0x7919, (q15_t)0xd68c, (q15_t)0x7911, (q15_t)0xd675, (q15_t)0x7909, + (q15_t)0xd65d, (q15_t)0x7901, (q15_t)0xd645, (q15_t)0x78f9, (q15_t)0xd62d, + (q15_t)0x78f1, (q15_t)0xd615, (q15_t)0x78e8, (q15_t)0xd5fe, (q15_t)0x78e0, + (q15_t)0xd5e6, (q15_t)0x78d8, (q15_t)0xd5ce, (q15_t)0x78cf, (q15_t)0xd5b7, + (q15_t)0x78c7, (q15_t)0xd59f, (q15_t)0x78bf, (q15_t)0xd587, (q15_t)0x78b6, + (q15_t)0xd56f, (q15_t)0x78ae, (q15_t)0xd558, (q15_t)0x78a6, (q15_t)0xd540, + (q15_t)0x789d, (q15_t)0xd528, (q15_t)0x7895, (q15_t)0xd511, (q15_t)0x788c, + (q15_t)0xd4f9, (q15_t)0x7884, (q15_t)0xd4e1, (q15_t)0x787c, (q15_t)0xd4ca, + (q15_t)0x7873, (q15_t)0xd4b2, (q15_t)0x786b, (q15_t)0xd49a, (q15_t)0x7862, + (q15_t)0xd483, (q15_t)0x7859, (q15_t)0xd46b, (q15_t)0x7851, (q15_t)0xd453, + (q15_t)0x7848, (q15_t)0xd43c, (q15_t)0x7840, (q15_t)0xd424, (q15_t)0x7837, + (q15_t)0xd40d, (q15_t)0x782e, (q15_t)0xd3f5, (q15_t)0x7826, (q15_t)0xd3dd, + (q15_t)0x781d, (q15_t)0xd3c6, (q15_t)0x7814, (q15_t)0xd3ae, (q15_t)0x780c, + (q15_t)0xd397, (q15_t)0x7803, (q15_t)0xd37f, (q15_t)0x77fa, (q15_t)0xd368, + (q15_t)0x77f1, (q15_t)0xd350, (q15_t)0x77e9, (q15_t)0xd338, (q15_t)0x77e0, + (q15_t)0xd321, (q15_t)0x77d7, (q15_t)0xd309, (q15_t)0x77ce, (q15_t)0xd2f2, + (q15_t)0x77c5, (q15_t)0xd2da, (q15_t)0x77bc, (q15_t)0xd2c3, (q15_t)0x77b4, + (q15_t)0xd2ab, (q15_t)0x77ab, (q15_t)0xd294, (q15_t)0x77a2, (q15_t)0xd27c, + (q15_t)0x7799, (q15_t)0xd265, (q15_t)0x7790, (q15_t)0xd24d, (q15_t)0x7787, + (q15_t)0xd236, (q15_t)0x777e, (q15_t)0xd21e, (q15_t)0x7775, (q15_t)0xd207, + (q15_t)0x776c, (q15_t)0xd1ef, (q15_t)0x7763, (q15_t)0xd1d8, (q15_t)0x775a, + (q15_t)0xd1c1, (q15_t)0x7751, (q15_t)0xd1a9, (q15_t)0x7747, (q15_t)0xd192, + (q15_t)0x773e, (q15_t)0xd17a, (q15_t)0x7735, (q15_t)0xd163, (q15_t)0x772c, + (q15_t)0xd14b, (q15_t)0x7723, (q15_t)0xd134, (q15_t)0x771a, (q15_t)0xd11d, + (q15_t)0x7710, (q15_t)0xd105, (q15_t)0x7707, (q15_t)0xd0ee, (q15_t)0x76fe, + (q15_t)0xd0d7, (q15_t)0x76f5, (q15_t)0xd0bf, (q15_t)0x76eb, (q15_t)0xd0a8, + (q15_t)0x76e2, (q15_t)0xd091, (q15_t)0x76d9, (q15_t)0xd079, (q15_t)0x76cf, + (q15_t)0xd062, (q15_t)0x76c6, (q15_t)0xd04b, (q15_t)0x76bd, (q15_t)0xd033, + (q15_t)0x76b3, (q15_t)0xd01c, (q15_t)0x76aa, (q15_t)0xd005, (q15_t)0x76a0, + (q15_t)0xcfed, (q15_t)0x7697, (q15_t)0xcfd6, (q15_t)0x768e, (q15_t)0xcfbf, + (q15_t)0x7684, (q15_t)0xcfa7, (q15_t)0x767b, (q15_t)0xcf90, (q15_t)0x7671, + (q15_t)0xcf79, (q15_t)0x7668, (q15_t)0xcf62, (q15_t)0x765e, (q15_t)0xcf4a, + (q15_t)0x7654, (q15_t)0xcf33, (q15_t)0x764b, (q15_t)0xcf1c, (q15_t)0x7641, + (q15_t)0xcf05, (q15_t)0x7638, (q15_t)0xceee, (q15_t)0x762e, (q15_t)0xced6, + (q15_t)0x7624, (q15_t)0xcebf, (q15_t)0x761b, (q15_t)0xcea8, (q15_t)0x7611, + (q15_t)0xce91, (q15_t)0x7607, (q15_t)0xce7a, (q15_t)0x75fd, (q15_t)0xce62, + (q15_t)0x75f4, (q15_t)0xce4b, (q15_t)0x75ea, (q15_t)0xce34, (q15_t)0x75e0, + (q15_t)0xce1d, (q15_t)0x75d6, (q15_t)0xce06, (q15_t)0x75cc, (q15_t)0xcdef, + (q15_t)0x75c3, (q15_t)0xcdd8, (q15_t)0x75b9, (q15_t)0xcdc0, (q15_t)0x75af, + (q15_t)0xcda9, (q15_t)0x75a5, (q15_t)0xcd92, (q15_t)0x759b, (q15_t)0xcd7b, + (q15_t)0x7591, (q15_t)0xcd64, (q15_t)0x7587, (q15_t)0xcd4d, (q15_t)0x757d, + (q15_t)0xcd36, (q15_t)0x7573, (q15_t)0xcd1f, (q15_t)0x7569, (q15_t)0xcd08, + (q15_t)0x755f, (q15_t)0xccf1, (q15_t)0x7555, (q15_t)0xccda, (q15_t)0x754b, + (q15_t)0xccc3, (q15_t)0x7541, (q15_t)0xccac, (q15_t)0x7537, (q15_t)0xcc95, + (q15_t)0x752d, (q15_t)0xcc7e, (q15_t)0x7523, (q15_t)0xcc67, (q15_t)0x7519, + (q15_t)0xcc50, (q15_t)0x750f, (q15_t)0xcc39, (q15_t)0x7504, (q15_t)0xcc22, + (q15_t)0x74fa, (q15_t)0xcc0b, (q15_t)0x74f0, (q15_t)0xcbf4, (q15_t)0x74e6, + (q15_t)0xcbdd, (q15_t)0x74db, (q15_t)0xcbc6, (q15_t)0x74d1, (q15_t)0xcbaf, + (q15_t)0x74c7, (q15_t)0xcb98, (q15_t)0x74bd, (q15_t)0xcb81, (q15_t)0x74b2, + (q15_t)0xcb6a, (q15_t)0x74a8, (q15_t)0xcb53, (q15_t)0x749e, (q15_t)0xcb3c, + (q15_t)0x7493, (q15_t)0xcb25, (q15_t)0x7489, (q15_t)0xcb0e, (q15_t)0x747e, + (q15_t)0xcaf8, (q15_t)0x7474, (q15_t)0xcae1, (q15_t)0x746a, (q15_t)0xcaca, + (q15_t)0x745f, (q15_t)0xcab3, (q15_t)0x7455, (q15_t)0xca9c, (q15_t)0x744a, + (q15_t)0xca85, (q15_t)0x7440, (q15_t)0xca6e, (q15_t)0x7435, (q15_t)0xca58, + (q15_t)0x742b, (q15_t)0xca41, (q15_t)0x7420, (q15_t)0xca2a, (q15_t)0x7415, + (q15_t)0xca13, (q15_t)0x740b, (q15_t)0xc9fc, (q15_t)0x7400, (q15_t)0xc9e6, + (q15_t)0x73f6, (q15_t)0xc9cf, (q15_t)0x73eb, (q15_t)0xc9b8, (q15_t)0x73e0, + (q15_t)0xc9a1, (q15_t)0x73d6, (q15_t)0xc98b, (q15_t)0x73cb, (q15_t)0xc974, + (q15_t)0x73c0, (q15_t)0xc95d, (q15_t)0x73b5, (q15_t)0xc946, (q15_t)0x73ab, + (q15_t)0xc930, (q15_t)0x73a0, (q15_t)0xc919, (q15_t)0x7395, (q15_t)0xc902, + (q15_t)0x738a, (q15_t)0xc8ec, (q15_t)0x737f, (q15_t)0xc8d5, (q15_t)0x7375, + (q15_t)0xc8be, (q15_t)0x736a, (q15_t)0xc8a8, (q15_t)0x735f, (q15_t)0xc891, + (q15_t)0x7354, (q15_t)0xc87a, (q15_t)0x7349, (q15_t)0xc864, (q15_t)0x733e, + (q15_t)0xc84d, (q15_t)0x7333, (q15_t)0xc836, (q15_t)0x7328, (q15_t)0xc820, + (q15_t)0x731d, (q15_t)0xc809, (q15_t)0x7312, (q15_t)0xc7f3, (q15_t)0x7307, + (q15_t)0xc7dc, (q15_t)0x72fc, (q15_t)0xc7c5, (q15_t)0x72f1, (q15_t)0xc7af, + (q15_t)0x72e6, (q15_t)0xc798, (q15_t)0x72db, (q15_t)0xc782, (q15_t)0x72d0, + (q15_t)0xc76b, (q15_t)0x72c5, (q15_t)0xc755, (q15_t)0x72ba, (q15_t)0xc73e, + (q15_t)0x72af, (q15_t)0xc728, (q15_t)0x72a3, (q15_t)0xc711, (q15_t)0x7298, + (q15_t)0xc6fa, (q15_t)0x728d, (q15_t)0xc6e4, (q15_t)0x7282, (q15_t)0xc6ce, + (q15_t)0x7276, (q15_t)0xc6b7, (q15_t)0x726b, (q15_t)0xc6a1, (q15_t)0x7260, + (q15_t)0xc68a, (q15_t)0x7255, (q15_t)0xc674, (q15_t)0x7249, (q15_t)0xc65d, + (q15_t)0x723e, (q15_t)0xc647, (q15_t)0x7233, (q15_t)0xc630, (q15_t)0x7227, + (q15_t)0xc61a, (q15_t)0x721c, (q15_t)0xc603, (q15_t)0x7211, (q15_t)0xc5ed, + (q15_t)0x7205, (q15_t)0xc5d7, (q15_t)0x71fa, (q15_t)0xc5c0, (q15_t)0x71ee, + (q15_t)0xc5aa, (q15_t)0x71e3, (q15_t)0xc594, (q15_t)0x71d7, (q15_t)0xc57d, + (q15_t)0x71cc, (q15_t)0xc567, (q15_t)0x71c0, (q15_t)0xc551, (q15_t)0x71b5, + (q15_t)0xc53a, (q15_t)0x71a9, (q15_t)0xc524, (q15_t)0x719e, (q15_t)0xc50e, + (q15_t)0x7192, (q15_t)0xc4f7, (q15_t)0x7186, (q15_t)0xc4e1, (q15_t)0x717b, + (q15_t)0xc4cb, (q15_t)0x716f, (q15_t)0xc4b4, (q15_t)0x7164, (q15_t)0xc49e, + (q15_t)0x7158, (q15_t)0xc488, (q15_t)0x714c, (q15_t)0xc472, (q15_t)0x7141, + (q15_t)0xc45b, (q15_t)0x7135, (q15_t)0xc445, (q15_t)0x7129, (q15_t)0xc42f, + (q15_t)0x711d, (q15_t)0xc419, (q15_t)0x7112, (q15_t)0xc403, (q15_t)0x7106, + (q15_t)0xc3ec, (q15_t)0x70fa, (q15_t)0xc3d6, (q15_t)0x70ee, (q15_t)0xc3c0, + (q15_t)0x70e2, (q15_t)0xc3aa, (q15_t)0x70d6, (q15_t)0xc394, (q15_t)0x70cb, + (q15_t)0xc37d, (q15_t)0x70bf, (q15_t)0xc367, (q15_t)0x70b3, (q15_t)0xc351, + (q15_t)0x70a7, (q15_t)0xc33b, (q15_t)0x709b, (q15_t)0xc325, (q15_t)0x708f, + (q15_t)0xc30f, (q15_t)0x7083, (q15_t)0xc2f9, (q15_t)0x7077, (q15_t)0xc2e3, + (q15_t)0x706b, (q15_t)0xc2cd, (q15_t)0x705f, (q15_t)0xc2b7, (q15_t)0x7053, + (q15_t)0xc2a0, (q15_t)0x7047, (q15_t)0xc28a, (q15_t)0x703b, (q15_t)0xc274, + (q15_t)0x702f, (q15_t)0xc25e, (q15_t)0x7023, (q15_t)0xc248, (q15_t)0x7016, + (q15_t)0xc232, (q15_t)0x700a, (q15_t)0xc21c, (q15_t)0x6ffe, (q15_t)0xc206, + (q15_t)0x6ff2, (q15_t)0xc1f0, (q15_t)0x6fe6, (q15_t)0xc1da, (q15_t)0x6fda, + (q15_t)0xc1c4, (q15_t)0x6fcd, (q15_t)0xc1ae, (q15_t)0x6fc1, (q15_t)0xc198, + (q15_t)0x6fb5, (q15_t)0xc183, (q15_t)0x6fa9, (q15_t)0xc16d, (q15_t)0x6f9c, + (q15_t)0xc157, (q15_t)0x6f90, (q15_t)0xc141, (q15_t)0x6f84, (q15_t)0xc12b, + (q15_t)0x6f77, (q15_t)0xc115, (q15_t)0x6f6b, (q15_t)0xc0ff, (q15_t)0x6f5f, + (q15_t)0xc0e9, (q15_t)0x6f52, (q15_t)0xc0d3, (q15_t)0x6f46, (q15_t)0xc0bd, + (q15_t)0x6f39, (q15_t)0xc0a8, (q15_t)0x6f2d, (q15_t)0xc092, (q15_t)0x6f20, + (q15_t)0xc07c, (q15_t)0x6f14, (q15_t)0xc066, (q15_t)0x6f07, (q15_t)0xc050, + (q15_t)0x6efb, (q15_t)0xc03b, (q15_t)0x6eee, (q15_t)0xc025, (q15_t)0x6ee2, + (q15_t)0xc00f, (q15_t)0x6ed5, (q15_t)0xbff9, (q15_t)0x6ec9, (q15_t)0xbfe3, + (q15_t)0x6ebc, (q15_t)0xbfce, (q15_t)0x6eaf, (q15_t)0xbfb8, (q15_t)0x6ea3, + (q15_t)0xbfa2, (q15_t)0x6e96, (q15_t)0xbf8d, (q15_t)0x6e89, (q15_t)0xbf77, + (q15_t)0x6e7d, (q15_t)0xbf61, (q15_t)0x6e70, (q15_t)0xbf4b, (q15_t)0x6e63, + (q15_t)0xbf36, (q15_t)0x6e57, (q15_t)0xbf20, (q15_t)0x6e4a, (q15_t)0xbf0a, + (q15_t)0x6e3d, (q15_t)0xbef5, (q15_t)0x6e30, (q15_t)0xbedf, (q15_t)0x6e24, + (q15_t)0xbeca, (q15_t)0x6e17, (q15_t)0xbeb4, (q15_t)0x6e0a, (q15_t)0xbe9e, + (q15_t)0x6dfd, (q15_t)0xbe89, (q15_t)0x6df0, (q15_t)0xbe73, (q15_t)0x6de3, + (q15_t)0xbe5e, (q15_t)0x6dd6, (q15_t)0xbe48, (q15_t)0x6dca, (q15_t)0xbe32, + (q15_t)0x6dbd, (q15_t)0xbe1d, (q15_t)0x6db0, (q15_t)0xbe07, (q15_t)0x6da3, + (q15_t)0xbdf2, (q15_t)0x6d96, (q15_t)0xbddc, (q15_t)0x6d89, (q15_t)0xbdc7, + (q15_t)0x6d7c, (q15_t)0xbdb1, (q15_t)0x6d6f, (q15_t)0xbd9c, (q15_t)0x6d62, + (q15_t)0xbd86, (q15_t)0x6d55, (q15_t)0xbd71, (q15_t)0x6d48, (q15_t)0xbd5b, + (q15_t)0x6d3a, (q15_t)0xbd46, (q15_t)0x6d2d, (q15_t)0xbd30, (q15_t)0x6d20, + (q15_t)0xbd1b, (q15_t)0x6d13, (q15_t)0xbd06, (q15_t)0x6d06, (q15_t)0xbcf0, + (q15_t)0x6cf9, (q15_t)0xbcdb, (q15_t)0x6cec, (q15_t)0xbcc5, (q15_t)0x6cde, + (q15_t)0xbcb0, (q15_t)0x6cd1, (q15_t)0xbc9b, (q15_t)0x6cc4, (q15_t)0xbc85, + (q15_t)0x6cb7, (q15_t)0xbc70, (q15_t)0x6ca9, (q15_t)0xbc5b, (q15_t)0x6c9c, + (q15_t)0xbc45, (q15_t)0x6c8f, (q15_t)0xbc30, (q15_t)0x6c81, (q15_t)0xbc1b, + (q15_t)0x6c74, (q15_t)0xbc05, (q15_t)0x6c67, (q15_t)0xbbf0, (q15_t)0x6c59, + (q15_t)0xbbdb, (q15_t)0x6c4c, (q15_t)0xbbc5, (q15_t)0x6c3f, (q15_t)0xbbb0, + (q15_t)0x6c31, (q15_t)0xbb9b, (q15_t)0x6c24, (q15_t)0xbb86, (q15_t)0x6c16, + (q15_t)0xbb70, (q15_t)0x6c09, (q15_t)0xbb5b, (q15_t)0x6bfb, (q15_t)0xbb46, + (q15_t)0x6bee, (q15_t)0xbb31, (q15_t)0x6be0, (q15_t)0xbb1c, (q15_t)0x6bd3, + (q15_t)0xbb06, (q15_t)0x6bc5, (q15_t)0xbaf1, (q15_t)0x6bb8, (q15_t)0xbadc, + (q15_t)0x6baa, (q15_t)0xbac7, (q15_t)0x6b9c, (q15_t)0xbab2, (q15_t)0x6b8f, + (q15_t)0xba9d, (q15_t)0x6b81, (q15_t)0xba88, (q15_t)0x6b73, (q15_t)0xba73, + (q15_t)0x6b66, (q15_t)0xba5d, (q15_t)0x6b58, (q15_t)0xba48, (q15_t)0x6b4a, + (q15_t)0xba33, (q15_t)0x6b3d, (q15_t)0xba1e, (q15_t)0x6b2f, (q15_t)0xba09, + (q15_t)0x6b21, (q15_t)0xb9f4, (q15_t)0x6b13, (q15_t)0xb9df, (q15_t)0x6b06, + (q15_t)0xb9ca, (q15_t)0x6af8, (q15_t)0xb9b5, (q15_t)0x6aea, (q15_t)0xb9a0, + (q15_t)0x6adc, (q15_t)0xb98b, (q15_t)0x6ace, (q15_t)0xb976, (q15_t)0x6ac1, + (q15_t)0xb961, (q15_t)0x6ab3, (q15_t)0xb94c, (q15_t)0x6aa5, (q15_t)0xb937, + (q15_t)0x6a97, (q15_t)0xb922, (q15_t)0x6a89, (q15_t)0xb90d, (q15_t)0x6a7b, + (q15_t)0xb8f8, (q15_t)0x6a6d, (q15_t)0xb8e4, (q15_t)0x6a5f, (q15_t)0xb8cf, + (q15_t)0x6a51, (q15_t)0xb8ba, (q15_t)0x6a43, (q15_t)0xb8a5, (q15_t)0x6a35, + (q15_t)0xb890, (q15_t)0x6a27, (q15_t)0xb87b, (q15_t)0x6a19, (q15_t)0xb866, + (q15_t)0x6a0b, (q15_t)0xb852, (q15_t)0x69fd, (q15_t)0xb83d, (q15_t)0x69ef, + (q15_t)0xb828, (q15_t)0x69e1, (q15_t)0xb813, (q15_t)0x69d3, (q15_t)0xb7fe, + (q15_t)0x69c4, (q15_t)0xb7ea, (q15_t)0x69b6, (q15_t)0xb7d5, (q15_t)0x69a8, + (q15_t)0xb7c0, (q15_t)0x699a, (q15_t)0xb7ab, (q15_t)0x698c, (q15_t)0xb797, + (q15_t)0x697d, (q15_t)0xb782, (q15_t)0x696f, (q15_t)0xb76d, (q15_t)0x6961, + (q15_t)0xb758, (q15_t)0x6953, (q15_t)0xb744, (q15_t)0x6944, (q15_t)0xb72f, + (q15_t)0x6936, (q15_t)0xb71a, (q15_t)0x6928, (q15_t)0xb706, (q15_t)0x6919, + (q15_t)0xb6f1, (q15_t)0x690b, (q15_t)0xb6dd, (q15_t)0x68fd, (q15_t)0xb6c8, + (q15_t)0x68ee, (q15_t)0xb6b3, (q15_t)0x68e0, (q15_t)0xb69f, (q15_t)0x68d1, + (q15_t)0xb68a, (q15_t)0x68c3, (q15_t)0xb676, (q15_t)0x68b5, (q15_t)0xb661, + (q15_t)0x68a6, (q15_t)0xb64c, (q15_t)0x6898, (q15_t)0xb638, (q15_t)0x6889, + (q15_t)0xb623, (q15_t)0x687b, (q15_t)0xb60f, (q15_t)0x686c, (q15_t)0xb5fa, + (q15_t)0x685e, (q15_t)0xb5e6, (q15_t)0x684f, (q15_t)0xb5d1, (q15_t)0x6840, + (q15_t)0xb5bd, (q15_t)0x6832, (q15_t)0xb5a8, (q15_t)0x6823, (q15_t)0xb594, + (q15_t)0x6815, (q15_t)0xb57f, (q15_t)0x6806, (q15_t)0xb56b, (q15_t)0x67f7, + (q15_t)0xb557, (q15_t)0x67e9, (q15_t)0xb542, (q15_t)0x67da, (q15_t)0xb52e, + (q15_t)0x67cb, (q15_t)0xb519, (q15_t)0x67bd, (q15_t)0xb505, (q15_t)0x67ae, + (q15_t)0xb4f1, (q15_t)0x679f, (q15_t)0xb4dc, (q15_t)0x6790, (q15_t)0xb4c8, + (q15_t)0x6782, (q15_t)0xb4b4, (q15_t)0x6773, (q15_t)0xb49f, (q15_t)0x6764, + (q15_t)0xb48b, (q15_t)0x6755, (q15_t)0xb477, (q15_t)0x6746, (q15_t)0xb462, + (q15_t)0x6737, (q15_t)0xb44e, (q15_t)0x6729, (q15_t)0xb43a, (q15_t)0x671a, + (q15_t)0xb426, (q15_t)0x670b, (q15_t)0xb411, (q15_t)0x66fc, (q15_t)0xb3fd, + (q15_t)0x66ed, (q15_t)0xb3e9, (q15_t)0x66de, (q15_t)0xb3d5, (q15_t)0x66cf, + (q15_t)0xb3c1, (q15_t)0x66c0, (q15_t)0xb3ac, (q15_t)0x66b1, (q15_t)0xb398, + (q15_t)0x66a2, (q15_t)0xb384, (q15_t)0x6693, (q15_t)0xb370, (q15_t)0x6684, + (q15_t)0xb35c, (q15_t)0x6675, (q15_t)0xb348, (q15_t)0x6666, (q15_t)0xb334, + (q15_t)0x6657, (q15_t)0xb31f, (q15_t)0x6648, (q15_t)0xb30b, (q15_t)0x6639, + (q15_t)0xb2f7, (q15_t)0x6629, (q15_t)0xb2e3, (q15_t)0x661a, (q15_t)0xb2cf, + (q15_t)0x660b, (q15_t)0xb2bb, (q15_t)0x65fc, (q15_t)0xb2a7, (q15_t)0x65ed, + (q15_t)0xb293, (q15_t)0x65dd, (q15_t)0xb27f, (q15_t)0x65ce, (q15_t)0xb26b, + (q15_t)0x65bf, (q15_t)0xb257, (q15_t)0x65b0, (q15_t)0xb243, (q15_t)0x65a0, + (q15_t)0xb22f, (q15_t)0x6591, (q15_t)0xb21b, (q15_t)0x6582, (q15_t)0xb207, + (q15_t)0x6573, (q15_t)0xb1f3, (q15_t)0x6563, (q15_t)0xb1df, (q15_t)0x6554, + (q15_t)0xb1cc, (q15_t)0x6545, (q15_t)0xb1b8, (q15_t)0x6535, (q15_t)0xb1a4, + (q15_t)0x6526, (q15_t)0xb190, (q15_t)0x6516, (q15_t)0xb17c, (q15_t)0x6507, + (q15_t)0xb168, (q15_t)0x64f7, (q15_t)0xb154, (q15_t)0x64e8, (q15_t)0xb141, + (q15_t)0x64d9, (q15_t)0xb12d, (q15_t)0x64c9, (q15_t)0xb119, (q15_t)0x64ba, + (q15_t)0xb105, (q15_t)0x64aa, (q15_t)0xb0f1, (q15_t)0x649b, (q15_t)0xb0de, + (q15_t)0x648b, (q15_t)0xb0ca, (q15_t)0x647b, (q15_t)0xb0b6, (q15_t)0x646c, + (q15_t)0xb0a2, (q15_t)0x645c, (q15_t)0xb08f, (q15_t)0x644d, (q15_t)0xb07b, + (q15_t)0x643d, (q15_t)0xb067, (q15_t)0x642d, (q15_t)0xb054, (q15_t)0x641e, + (q15_t)0xb040, (q15_t)0x640e, (q15_t)0xb02c, (q15_t)0x63fe, (q15_t)0xb019, + (q15_t)0x63ef, (q15_t)0xb005, (q15_t)0x63df, (q15_t)0xaff1, (q15_t)0x63cf, + (q15_t)0xafde, (q15_t)0x63c0, (q15_t)0xafca, (q15_t)0x63b0, (q15_t)0xafb7, + (q15_t)0x63a0, (q15_t)0xafa3, (q15_t)0x6390, (q15_t)0xaf90, (q15_t)0x6380, + (q15_t)0xaf7c, (q15_t)0x6371, (q15_t)0xaf69, (q15_t)0x6361, (q15_t)0xaf55, + (q15_t)0x6351, (q15_t)0xaf41, (q15_t)0x6341, (q15_t)0xaf2e, (q15_t)0x6331, + (q15_t)0xaf1b, (q15_t)0x6321, (q15_t)0xaf07, (q15_t)0x6311, (q15_t)0xaef4, + (q15_t)0x6301, (q15_t)0xaee0, (q15_t)0x62f2, (q15_t)0xaecd, (q15_t)0x62e2, + (q15_t)0xaeb9, (q15_t)0x62d2, (q15_t)0xaea6, (q15_t)0x62c2, (q15_t)0xae92, + (q15_t)0x62b2, (q15_t)0xae7f, (q15_t)0x62a2, (q15_t)0xae6c, (q15_t)0x6292, + (q15_t)0xae58, (q15_t)0x6282, (q15_t)0xae45, (q15_t)0x6271, (q15_t)0xae32, + (q15_t)0x6261, (q15_t)0xae1e, (q15_t)0x6251, (q15_t)0xae0b, (q15_t)0x6241, + (q15_t)0xadf8, (q15_t)0x6231, (q15_t)0xade4, (q15_t)0x6221, (q15_t)0xadd1, + (q15_t)0x6211, (q15_t)0xadbe, (q15_t)0x6201, (q15_t)0xadab, (q15_t)0x61f1, + (q15_t)0xad97, (q15_t)0x61e0, (q15_t)0xad84, (q15_t)0x61d0, (q15_t)0xad71, + (q15_t)0x61c0, (q15_t)0xad5e, (q15_t)0x61b0, (q15_t)0xad4b, (q15_t)0x619f, + (q15_t)0xad37, (q15_t)0x618f, (q15_t)0xad24, (q15_t)0x617f, (q15_t)0xad11, + (q15_t)0x616f, (q15_t)0xacfe, (q15_t)0x615e, (q15_t)0xaceb, (q15_t)0x614e, + (q15_t)0xacd8, (q15_t)0x613e, (q15_t)0xacc5, (q15_t)0x612d, (q15_t)0xacb2, + (q15_t)0x611d, (q15_t)0xac9e, (q15_t)0x610d, (q15_t)0xac8b, (q15_t)0x60fc, + (q15_t)0xac78, (q15_t)0x60ec, (q15_t)0xac65, (q15_t)0x60db, (q15_t)0xac52, + (q15_t)0x60cb, (q15_t)0xac3f, (q15_t)0x60ba, (q15_t)0xac2c, (q15_t)0x60aa, + (q15_t)0xac19, (q15_t)0x6099, (q15_t)0xac06, (q15_t)0x6089, (q15_t)0xabf3, + (q15_t)0x6078, (q15_t)0xabe0, (q15_t)0x6068, (q15_t)0xabcd, (q15_t)0x6057, + (q15_t)0xabbb, (q15_t)0x6047, (q15_t)0xaba8, (q15_t)0x6036, (q15_t)0xab95, + (q15_t)0x6026, (q15_t)0xab82, (q15_t)0x6015, (q15_t)0xab6f, (q15_t)0x6004, + (q15_t)0xab5c, (q15_t)0x5ff4, (q15_t)0xab49, (q15_t)0x5fe3, (q15_t)0xab36, + (q15_t)0x5fd3, (q15_t)0xab24, (q15_t)0x5fc2, (q15_t)0xab11, (q15_t)0x5fb1, + (q15_t)0xaafe, (q15_t)0x5fa0, (q15_t)0xaaeb, (q15_t)0x5f90, (q15_t)0xaad8, + (q15_t)0x5f7f, (q15_t)0xaac6, (q15_t)0x5f6e, (q15_t)0xaab3, (q15_t)0x5f5e, + (q15_t)0xaaa0, (q15_t)0x5f4d, (q15_t)0xaa8e, (q15_t)0x5f3c, (q15_t)0xaa7b, + (q15_t)0x5f2b, (q15_t)0xaa68, (q15_t)0x5f1a, (q15_t)0xaa55, (q15_t)0x5f0a, + (q15_t)0xaa43, (q15_t)0x5ef9, (q15_t)0xaa30, (q15_t)0x5ee8, (q15_t)0xaa1d, + (q15_t)0x5ed7, (q15_t)0xaa0b, (q15_t)0x5ec6, (q15_t)0xa9f8, (q15_t)0x5eb5, + (q15_t)0xa9e6, (q15_t)0x5ea4, (q15_t)0xa9d3, (q15_t)0x5e93, (q15_t)0xa9c0, + (q15_t)0x5e82, (q15_t)0xa9ae, (q15_t)0x5e71, (q15_t)0xa99b, (q15_t)0x5e60, + (q15_t)0xa989, (q15_t)0x5e50, (q15_t)0xa976, (q15_t)0x5e3f, (q15_t)0xa964, + (q15_t)0x5e2d, (q15_t)0xa951, (q15_t)0x5e1c, (q15_t)0xa93f, (q15_t)0x5e0b, + (q15_t)0xa92c, (q15_t)0x5dfa, (q15_t)0xa91a, (q15_t)0x5de9, (q15_t)0xa907, + (q15_t)0x5dd8, (q15_t)0xa8f5, (q15_t)0x5dc7, (q15_t)0xa8e3, (q15_t)0x5db6, + (q15_t)0xa8d0, (q15_t)0x5da5, (q15_t)0xa8be, (q15_t)0x5d94, (q15_t)0xa8ab, + (q15_t)0x5d83, (q15_t)0xa899, (q15_t)0x5d71, (q15_t)0xa887, (q15_t)0x5d60, + (q15_t)0xa874, (q15_t)0x5d4f, (q15_t)0xa862, (q15_t)0x5d3e, (q15_t)0xa850, + (q15_t)0x5d2d, (q15_t)0xa83d, (q15_t)0x5d1b, (q15_t)0xa82b, (q15_t)0x5d0a, + (q15_t)0xa819, (q15_t)0x5cf9, (q15_t)0xa807, (q15_t)0x5ce8, (q15_t)0xa7f4, + (q15_t)0x5cd6, (q15_t)0xa7e2, (q15_t)0x5cc5, (q15_t)0xa7d0, (q15_t)0x5cb4, + (q15_t)0xa7be, (q15_t)0x5ca2, (q15_t)0xa7ab, (q15_t)0x5c91, (q15_t)0xa799, + (q15_t)0x5c80, (q15_t)0xa787, (q15_t)0x5c6e, (q15_t)0xa775, (q15_t)0x5c5d, + (q15_t)0xa763, (q15_t)0x5c4b, (q15_t)0xa751, (q15_t)0x5c3a, (q15_t)0xa73f, + (q15_t)0x5c29, (q15_t)0xa72c, (q15_t)0x5c17, (q15_t)0xa71a, (q15_t)0x5c06, + (q15_t)0xa708, (q15_t)0x5bf4, (q15_t)0xa6f6, (q15_t)0x5be3, (q15_t)0xa6e4, + (q15_t)0x5bd1, (q15_t)0xa6d2, (q15_t)0x5bc0, (q15_t)0xa6c0, (q15_t)0x5bae, + (q15_t)0xa6ae, (q15_t)0x5b9d, (q15_t)0xa69c, (q15_t)0x5b8b, (q15_t)0xa68a, + (q15_t)0x5b79, (q15_t)0xa678, (q15_t)0x5b68, (q15_t)0xa666, (q15_t)0x5b56, + (q15_t)0xa654, (q15_t)0x5b45, (q15_t)0xa642, (q15_t)0x5b33, (q15_t)0xa630, + (q15_t)0x5b21, (q15_t)0xa61f, (q15_t)0x5b10, (q15_t)0xa60d, (q15_t)0x5afe, + (q15_t)0xa5fb, (q15_t)0x5aec, (q15_t)0xa5e9, (q15_t)0x5adb, (q15_t)0xa5d7, + (q15_t)0x5ac9, (q15_t)0xa5c5, (q15_t)0x5ab7, (q15_t)0xa5b3, (q15_t)0x5aa5, + (q15_t)0xa5a2, (q15_t)0x5a94, (q15_t)0xa590, (q15_t)0x5a82, (q15_t)0xa57e, + (q15_t)0x5a70, (q15_t)0xa56c, (q15_t)0x5a5e, (q15_t)0xa55b, (q15_t)0x5a4d, + (q15_t)0xa549, (q15_t)0x5a3b, (q15_t)0xa537, (q15_t)0x5a29, (q15_t)0xa525, + (q15_t)0x5a17, (q15_t)0xa514, (q15_t)0x5a05, (q15_t)0xa502, (q15_t)0x59f3, + (q15_t)0xa4f0, (q15_t)0x59e1, (q15_t)0xa4df, (q15_t)0x59d0, (q15_t)0xa4cd, + (q15_t)0x59be, (q15_t)0xa4bb, (q15_t)0x59ac, (q15_t)0xa4aa, (q15_t)0x599a, + (q15_t)0xa498, (q15_t)0x5988, (q15_t)0xa487, (q15_t)0x5976, (q15_t)0xa475, + (q15_t)0x5964, (q15_t)0xa463, (q15_t)0x5952, (q15_t)0xa452, (q15_t)0x5940, + (q15_t)0xa440, (q15_t)0x592e, (q15_t)0xa42f, (q15_t)0x591c, (q15_t)0xa41d, + (q15_t)0x590a, (q15_t)0xa40c, (q15_t)0x58f8, (q15_t)0xa3fa, (q15_t)0x58e6, + (q15_t)0xa3e9, (q15_t)0x58d4, (q15_t)0xa3d7, (q15_t)0x58c1, (q15_t)0xa3c6, + (q15_t)0x58af, (q15_t)0xa3b5, (q15_t)0x589d, (q15_t)0xa3a3, (q15_t)0x588b, + (q15_t)0xa392, (q15_t)0x5879, (q15_t)0xa380, (q15_t)0x5867, (q15_t)0xa36f, + (q15_t)0x5855, (q15_t)0xa35e, (q15_t)0x5842, (q15_t)0xa34c, (q15_t)0x5830, + (q15_t)0xa33b, (q15_t)0x581e, (q15_t)0xa32a, (q15_t)0x580c, (q15_t)0xa318, + (q15_t)0x57f9, (q15_t)0xa307, (q15_t)0x57e7, (q15_t)0xa2f6, (q15_t)0x57d5, + (q15_t)0xa2e5, (q15_t)0x57c3, (q15_t)0xa2d3, (q15_t)0x57b0, (q15_t)0xa2c2, + (q15_t)0x579e, (q15_t)0xa2b1, (q15_t)0x578c, (q15_t)0xa2a0, (q15_t)0x5779, + (q15_t)0xa28f, (q15_t)0x5767, (q15_t)0xa27d, (q15_t)0x5755, (q15_t)0xa26c, + (q15_t)0x5742, (q15_t)0xa25b, (q15_t)0x5730, (q15_t)0xa24a, (q15_t)0x571d, + (q15_t)0xa239, (q15_t)0x570b, (q15_t)0xa228, (q15_t)0x56f9, (q15_t)0xa217, + (q15_t)0x56e6, (q15_t)0xa206, (q15_t)0x56d4, (q15_t)0xa1f5, (q15_t)0x56c1, + (q15_t)0xa1e4, (q15_t)0x56af, (q15_t)0xa1d3, (q15_t)0x569c, (q15_t)0xa1c1, + (q15_t)0x568a, (q15_t)0xa1b0, (q15_t)0x5677, (q15_t)0xa1a0, (q15_t)0x5665, + (q15_t)0xa18f, (q15_t)0x5652, (q15_t)0xa17e, (q15_t)0x5640, (q15_t)0xa16d, + (q15_t)0x562d, (q15_t)0xa15c, (q15_t)0x561a, (q15_t)0xa14b, (q15_t)0x5608, + (q15_t)0xa13a, (q15_t)0x55f5, (q15_t)0xa129, (q15_t)0x55e3, (q15_t)0xa118, + (q15_t)0x55d0, (q15_t)0xa107, (q15_t)0x55bd, (q15_t)0xa0f6, (q15_t)0x55ab, + (q15_t)0xa0e6, (q15_t)0x5598, (q15_t)0xa0d5, (q15_t)0x5585, (q15_t)0xa0c4, + (q15_t)0x5572, (q15_t)0xa0b3, (q15_t)0x5560, (q15_t)0xa0a2, (q15_t)0x554d, + (q15_t)0xa092, (q15_t)0x553a, (q15_t)0xa081, (q15_t)0x5528, (q15_t)0xa070, + (q15_t)0x5515, (q15_t)0xa060, (q15_t)0x5502, (q15_t)0xa04f, (q15_t)0x54ef, + (q15_t)0xa03e, (q15_t)0x54dc, (q15_t)0xa02d, (q15_t)0x54ca, (q15_t)0xa01d, + (q15_t)0x54b7, (q15_t)0xa00c, (q15_t)0x54a4, (q15_t)0x9ffc, (q15_t)0x5491, + (q15_t)0x9feb, (q15_t)0x547e, (q15_t)0x9fda, (q15_t)0x546b, (q15_t)0x9fca, + (q15_t)0x5458, (q15_t)0x9fb9, (q15_t)0x5445, (q15_t)0x9fa9, (q15_t)0x5433, + (q15_t)0x9f98, (q15_t)0x5420, (q15_t)0x9f88, (q15_t)0x540d, (q15_t)0x9f77, + (q15_t)0x53fa, (q15_t)0x9f67, (q15_t)0x53e7, (q15_t)0x9f56, (q15_t)0x53d4, + (q15_t)0x9f46, (q15_t)0x53c1, (q15_t)0x9f35, (q15_t)0x53ae, (q15_t)0x9f25, + (q15_t)0x539b, (q15_t)0x9f14, (q15_t)0x5388, (q15_t)0x9f04, (q15_t)0x5375, + (q15_t)0x9ef3, (q15_t)0x5362, (q15_t)0x9ee3, (q15_t)0x534e, (q15_t)0x9ed3, + (q15_t)0x533b, (q15_t)0x9ec2, (q15_t)0x5328, (q15_t)0x9eb2, (q15_t)0x5315, + (q15_t)0x9ea2, (q15_t)0x5302, (q15_t)0x9e91, (q15_t)0x52ef, (q15_t)0x9e81, + (q15_t)0x52dc, (q15_t)0x9e71, (q15_t)0x52c9, (q15_t)0x9e61, (q15_t)0x52b5, + (q15_t)0x9e50, (q15_t)0x52a2, (q15_t)0x9e40, (q15_t)0x528f, (q15_t)0x9e30, + (q15_t)0x527c, (q15_t)0x9e20, (q15_t)0x5269, (q15_t)0x9e0f, (q15_t)0x5255, + (q15_t)0x9dff, (q15_t)0x5242, (q15_t)0x9def, (q15_t)0x522f, (q15_t)0x9ddf, + (q15_t)0x521c, (q15_t)0x9dcf, (q15_t)0x5208, (q15_t)0x9dbf, (q15_t)0x51f5, + (q15_t)0x9daf, (q15_t)0x51e2, (q15_t)0x9d9f, (q15_t)0x51ce, (q15_t)0x9d8f, + (q15_t)0x51bb, (q15_t)0x9d7e, (q15_t)0x51a8, (q15_t)0x9d6e, (q15_t)0x5194, + (q15_t)0x9d5e, (q15_t)0x5181, (q15_t)0x9d4e, (q15_t)0x516e, (q15_t)0x9d3e, + (q15_t)0x515a, (q15_t)0x9d2e, (q15_t)0x5147, (q15_t)0x9d1e, (q15_t)0x5133, + (q15_t)0x9d0e, (q15_t)0x5120, (q15_t)0x9cff, (q15_t)0x510c, (q15_t)0x9cef, + (q15_t)0x50f9, (q15_t)0x9cdf, (q15_t)0x50e5, (q15_t)0x9ccf, (q15_t)0x50d2, + (q15_t)0x9cbf, (q15_t)0x50bf, (q15_t)0x9caf, (q15_t)0x50ab, (q15_t)0x9c9f, + (q15_t)0x5097, (q15_t)0x9c8f, (q15_t)0x5084, (q15_t)0x9c80, (q15_t)0x5070, + (q15_t)0x9c70, (q15_t)0x505d, (q15_t)0x9c60, (q15_t)0x5049, (q15_t)0x9c50, + (q15_t)0x5036, (q15_t)0x9c40, (q15_t)0x5022, (q15_t)0x9c31, (q15_t)0x500f, + (q15_t)0x9c21, (q15_t)0x4ffb, (q15_t)0x9c11, (q15_t)0x4fe7, (q15_t)0x9c02, + (q15_t)0x4fd4, (q15_t)0x9bf2, (q15_t)0x4fc0, (q15_t)0x9be2, (q15_t)0x4fac, + (q15_t)0x9bd3, (q15_t)0x4f99, (q15_t)0x9bc3, (q15_t)0x4f85, (q15_t)0x9bb3, + (q15_t)0x4f71, (q15_t)0x9ba4, (q15_t)0x4f5e, (q15_t)0x9b94, (q15_t)0x4f4a, + (q15_t)0x9b85, (q15_t)0x4f36, (q15_t)0x9b75, (q15_t)0x4f22, (q15_t)0x9b65, + (q15_t)0x4f0f, (q15_t)0x9b56, (q15_t)0x4efb, (q15_t)0x9b46, (q15_t)0x4ee7, + (q15_t)0x9b37, (q15_t)0x4ed3, (q15_t)0x9b27, (q15_t)0x4ebf, (q15_t)0x9b18, + (q15_t)0x4eac, (q15_t)0x9b09, (q15_t)0x4e98, (q15_t)0x9af9, (q15_t)0x4e84, + (q15_t)0x9aea, (q15_t)0x4e70, (q15_t)0x9ada, (q15_t)0x4e5c, (q15_t)0x9acb, + (q15_t)0x4e48, (q15_t)0x9abb, (q15_t)0x4e34, (q15_t)0x9aac, (q15_t)0x4e21, + (q15_t)0x9a9d, (q15_t)0x4e0d, (q15_t)0x9a8d, (q15_t)0x4df9, (q15_t)0x9a7e, + (q15_t)0x4de5, (q15_t)0x9a6f, (q15_t)0x4dd1, (q15_t)0x9a60, (q15_t)0x4dbd, + (q15_t)0x9a50, (q15_t)0x4da9, (q15_t)0x9a41, (q15_t)0x4d95, (q15_t)0x9a32, + (q15_t)0x4d81, (q15_t)0x9a23, (q15_t)0x4d6d, (q15_t)0x9a13, (q15_t)0x4d59, + (q15_t)0x9a04, (q15_t)0x4d45, (q15_t)0x99f5, (q15_t)0x4d31, (q15_t)0x99e6, + (q15_t)0x4d1d, (q15_t)0x99d7, (q15_t)0x4d09, (q15_t)0x99c7, (q15_t)0x4cf5, + (q15_t)0x99b8, (q15_t)0x4ce1, (q15_t)0x99a9, (q15_t)0x4ccc, (q15_t)0x999a, + (q15_t)0x4cb8, (q15_t)0x998b, (q15_t)0x4ca4, (q15_t)0x997c, (q15_t)0x4c90, + (q15_t)0x996d, (q15_t)0x4c7c, (q15_t)0x995e, (q15_t)0x4c68, (q15_t)0x994f, + (q15_t)0x4c54, (q15_t)0x9940, (q15_t)0x4c3f, (q15_t)0x9931, (q15_t)0x4c2b, + (q15_t)0x9922, (q15_t)0x4c17, (q15_t)0x9913, (q15_t)0x4c03, (q15_t)0x9904, + (q15_t)0x4bef, (q15_t)0x98f5, (q15_t)0x4bda, (q15_t)0x98e6, (q15_t)0x4bc6, + (q15_t)0x98d7, (q15_t)0x4bb2, (q15_t)0x98c9, (q15_t)0x4b9e, (q15_t)0x98ba, + (q15_t)0x4b89, (q15_t)0x98ab, (q15_t)0x4b75, (q15_t)0x989c, (q15_t)0x4b61, + (q15_t)0x988d, (q15_t)0x4b4c, (q15_t)0x987e, (q15_t)0x4b38, (q15_t)0x9870, + (q15_t)0x4b24, (q15_t)0x9861, (q15_t)0x4b0f, (q15_t)0x9852, (q15_t)0x4afb, + (q15_t)0x9843, (q15_t)0x4ae7, (q15_t)0x9835, (q15_t)0x4ad2, (q15_t)0x9826, + (q15_t)0x4abe, (q15_t)0x9817, (q15_t)0x4aa9, (q15_t)0x9809, (q15_t)0x4a95, + (q15_t)0x97fa, (q15_t)0x4a81, (q15_t)0x97eb, (q15_t)0x4a6c, (q15_t)0x97dd, + (q15_t)0x4a58, (q15_t)0x97ce, (q15_t)0x4a43, (q15_t)0x97c0, (q15_t)0x4a2f, + (q15_t)0x97b1, (q15_t)0x4a1a, (q15_t)0x97a2, (q15_t)0x4a06, (q15_t)0x9794, + (q15_t)0x49f1, (q15_t)0x9785, (q15_t)0x49dd, (q15_t)0x9777, (q15_t)0x49c8, + (q15_t)0x9768, (q15_t)0x49b4, (q15_t)0x975a, (q15_t)0x499f, (q15_t)0x974b, + (q15_t)0x498a, (q15_t)0x973d, (q15_t)0x4976, (q15_t)0x972f, (q15_t)0x4961, + (q15_t)0x9720, (q15_t)0x494d, (q15_t)0x9712, (q15_t)0x4938, (q15_t)0x9703, + (q15_t)0x4923, (q15_t)0x96f5, (q15_t)0x490f, (q15_t)0x96e7, (q15_t)0x48fa, + (q15_t)0x96d8, (q15_t)0x48e6, (q15_t)0x96ca, (q15_t)0x48d1, (q15_t)0x96bc, + (q15_t)0x48bc, (q15_t)0x96ad, (q15_t)0x48a8, (q15_t)0x969f, (q15_t)0x4893, + (q15_t)0x9691, (q15_t)0x487e, (q15_t)0x9683, (q15_t)0x4869, (q15_t)0x9674, + (q15_t)0x4855, (q15_t)0x9666, (q15_t)0x4840, (q15_t)0x9658, (q15_t)0x482b, + (q15_t)0x964a, (q15_t)0x4816, (q15_t)0x963c, (q15_t)0x4802, (q15_t)0x962d, + (q15_t)0x47ed, (q15_t)0x961f, (q15_t)0x47d8, (q15_t)0x9611, (q15_t)0x47c3, + (q15_t)0x9603, (q15_t)0x47ae, (q15_t)0x95f5, (q15_t)0x479a, (q15_t)0x95e7, + (q15_t)0x4785, (q15_t)0x95d9, (q15_t)0x4770, (q15_t)0x95cb, (q15_t)0x475b, + (q15_t)0x95bd, (q15_t)0x4746, (q15_t)0x95af, (q15_t)0x4731, (q15_t)0x95a1, + (q15_t)0x471c, (q15_t)0x9593, (q15_t)0x4708, (q15_t)0x9585, (q15_t)0x46f3, + (q15_t)0x9577, (q15_t)0x46de, (q15_t)0x9569, (q15_t)0x46c9, (q15_t)0x955b, + (q15_t)0x46b4, (q15_t)0x954d, (q15_t)0x469f, (q15_t)0x953f, (q15_t)0x468a, + (q15_t)0x9532, (q15_t)0x4675, (q15_t)0x9524, (q15_t)0x4660, (q15_t)0x9516, + (q15_t)0x464b, (q15_t)0x9508, (q15_t)0x4636, (q15_t)0x94fa, (q15_t)0x4621, + (q15_t)0x94ed, (q15_t)0x460c, (q15_t)0x94df, (q15_t)0x45f7, (q15_t)0x94d1, + (q15_t)0x45e2, (q15_t)0x94c3, (q15_t)0x45cd, (q15_t)0x94b6, (q15_t)0x45b8, + (q15_t)0x94a8, (q15_t)0x45a3, (q15_t)0x949a, (q15_t)0x458d, (q15_t)0x948d, + (q15_t)0x4578, (q15_t)0x947f, (q15_t)0x4563, (q15_t)0x9471, (q15_t)0x454e, + (q15_t)0x9464, (q15_t)0x4539, (q15_t)0x9456, (q15_t)0x4524, (q15_t)0x9448, + (q15_t)0x450f, (q15_t)0x943b, (q15_t)0x44fa, (q15_t)0x942d, (q15_t)0x44e4, + (q15_t)0x9420, (q15_t)0x44cf, (q15_t)0x9412, (q15_t)0x44ba, (q15_t)0x9405, + (q15_t)0x44a5, (q15_t)0x93f7, (q15_t)0x4490, (q15_t)0x93ea, (q15_t)0x447a, + (q15_t)0x93dc, (q15_t)0x4465, (q15_t)0x93cf, (q15_t)0x4450, (q15_t)0x93c1, + (q15_t)0x443b, (q15_t)0x93b4, (q15_t)0x4425, (q15_t)0x93a7, (q15_t)0x4410, + (q15_t)0x9399, (q15_t)0x43fb, (q15_t)0x938c, (q15_t)0x43e5, (q15_t)0x937f, + (q15_t)0x43d0, (q15_t)0x9371, (q15_t)0x43bb, (q15_t)0x9364, (q15_t)0x43a5, + (q15_t)0x9357, (q15_t)0x4390, (q15_t)0x9349, (q15_t)0x437b, (q15_t)0x933c, + (q15_t)0x4365, (q15_t)0x932f, (q15_t)0x4350, (q15_t)0x9322, (q15_t)0x433b, + (q15_t)0x9314, (q15_t)0x4325, (q15_t)0x9307, (q15_t)0x4310, (q15_t)0x92fa, + (q15_t)0x42fa, (q15_t)0x92ed, (q15_t)0x42e5, (q15_t)0x92e0, (q15_t)0x42d0, + (q15_t)0x92d3, (q15_t)0x42ba, (q15_t)0x92c6, (q15_t)0x42a5, (q15_t)0x92b8, + (q15_t)0x428f, (q15_t)0x92ab, (q15_t)0x427a, (q15_t)0x929e, (q15_t)0x4264, + (q15_t)0x9291, (q15_t)0x424f, (q15_t)0x9284, (q15_t)0x4239, (q15_t)0x9277, + (q15_t)0x4224, (q15_t)0x926a, (q15_t)0x420e, (q15_t)0x925d, (q15_t)0x41f9, + (q15_t)0x9250, (q15_t)0x41e3, (q15_t)0x9243, (q15_t)0x41ce, (q15_t)0x9236, + (q15_t)0x41b8, (q15_t)0x922a, (q15_t)0x41a2, (q15_t)0x921d, (q15_t)0x418d, + (q15_t)0x9210, (q15_t)0x4177, (q15_t)0x9203, (q15_t)0x4162, (q15_t)0x91f6, + (q15_t)0x414c, (q15_t)0x91e9, (q15_t)0x4136, (q15_t)0x91dc, (q15_t)0x4121, + (q15_t)0x91d0, (q15_t)0x410b, (q15_t)0x91c3, (q15_t)0x40f6, (q15_t)0x91b6, + (q15_t)0x40e0, (q15_t)0x91a9, (q15_t)0x40ca, (q15_t)0x919d, (q15_t)0x40b5, + (q15_t)0x9190, (q15_t)0x409f, (q15_t)0x9183, (q15_t)0x4089, (q15_t)0x9177, + (q15_t)0x4073, (q15_t)0x916a, (q15_t)0x405e, (q15_t)0x915d, (q15_t)0x4048, + (q15_t)0x9151, (q15_t)0x4032, (q15_t)0x9144, (q15_t)0x401d, (q15_t)0x9137, + (q15_t)0x4007, (q15_t)0x912b, (q15_t)0x3ff1, (q15_t)0x911e, (q15_t)0x3fdb, + (q15_t)0x9112, (q15_t)0x3fc5, (q15_t)0x9105, (q15_t)0x3fb0, (q15_t)0x90f9, + (q15_t)0x3f9a, (q15_t)0x90ec, (q15_t)0x3f84, (q15_t)0x90e0, (q15_t)0x3f6e, + (q15_t)0x90d3, (q15_t)0x3f58, (q15_t)0x90c7, (q15_t)0x3f43, (q15_t)0x90ba, + (q15_t)0x3f2d, (q15_t)0x90ae, (q15_t)0x3f17, (q15_t)0x90a1, (q15_t)0x3f01, + (q15_t)0x9095, (q15_t)0x3eeb, (q15_t)0x9089, (q15_t)0x3ed5, (q15_t)0x907c, + (q15_t)0x3ebf, (q15_t)0x9070, (q15_t)0x3ea9, (q15_t)0x9064, (q15_t)0x3e93, + (q15_t)0x9057, (q15_t)0x3e7d, (q15_t)0x904b, (q15_t)0x3e68, (q15_t)0x903f, + (q15_t)0x3e52, (q15_t)0x9033, (q15_t)0x3e3c, (q15_t)0x9026, (q15_t)0x3e26, + (q15_t)0x901a, (q15_t)0x3e10, (q15_t)0x900e, (q15_t)0x3dfa, (q15_t)0x9002, + (q15_t)0x3de4, (q15_t)0x8ff6, (q15_t)0x3dce, (q15_t)0x8fea, (q15_t)0x3db8, + (q15_t)0x8fdd, (q15_t)0x3da2, (q15_t)0x8fd1, (q15_t)0x3d8c, (q15_t)0x8fc5, + (q15_t)0x3d76, (q15_t)0x8fb9, (q15_t)0x3d60, (q15_t)0x8fad, (q15_t)0x3d49, + (q15_t)0x8fa1, (q15_t)0x3d33, (q15_t)0x8f95, (q15_t)0x3d1d, (q15_t)0x8f89, + (q15_t)0x3d07, (q15_t)0x8f7d, (q15_t)0x3cf1, (q15_t)0x8f71, (q15_t)0x3cdb, + (q15_t)0x8f65, (q15_t)0x3cc5, (q15_t)0x8f59, (q15_t)0x3caf, (q15_t)0x8f4d, + (q15_t)0x3c99, (q15_t)0x8f41, (q15_t)0x3c83, (q15_t)0x8f35, (q15_t)0x3c6c, + (q15_t)0x8f2a, (q15_t)0x3c56, (q15_t)0x8f1e, (q15_t)0x3c40, (q15_t)0x8f12, + (q15_t)0x3c2a, (q15_t)0x8f06, (q15_t)0x3c14, (q15_t)0x8efa, (q15_t)0x3bfd, + (q15_t)0x8eee, (q15_t)0x3be7, (q15_t)0x8ee3, (q15_t)0x3bd1, (q15_t)0x8ed7, + (q15_t)0x3bbb, (q15_t)0x8ecb, (q15_t)0x3ba5, (q15_t)0x8ebf, (q15_t)0x3b8e, + (q15_t)0x8eb4, (q15_t)0x3b78, (q15_t)0x8ea8, (q15_t)0x3b62, (q15_t)0x8e9c, + (q15_t)0x3b4c, (q15_t)0x8e91, (q15_t)0x3b35, (q15_t)0x8e85, (q15_t)0x3b1f, + (q15_t)0x8e7a, (q15_t)0x3b09, (q15_t)0x8e6e, (q15_t)0x3af2, (q15_t)0x8e62, + (q15_t)0x3adc, (q15_t)0x8e57, (q15_t)0x3ac6, (q15_t)0x8e4b, (q15_t)0x3aaf, + (q15_t)0x8e40, (q15_t)0x3a99, (q15_t)0x8e34, (q15_t)0x3a83, (q15_t)0x8e29, + (q15_t)0x3a6c, (q15_t)0x8e1d, (q15_t)0x3a56, (q15_t)0x8e12, (q15_t)0x3a40, + (q15_t)0x8e06, (q15_t)0x3a29, (q15_t)0x8dfb, (q15_t)0x3a13, (q15_t)0x8def, + (q15_t)0x39fd, (q15_t)0x8de4, (q15_t)0x39e6, (q15_t)0x8dd9, (q15_t)0x39d0, + (q15_t)0x8dcd, (q15_t)0x39b9, (q15_t)0x8dc2, (q15_t)0x39a3, (q15_t)0x8db7, + (q15_t)0x398c, (q15_t)0x8dab, (q15_t)0x3976, (q15_t)0x8da0, (q15_t)0x395f, + (q15_t)0x8d95, (q15_t)0x3949, (q15_t)0x8d8a, (q15_t)0x3932, (q15_t)0x8d7e, + (q15_t)0x391c, (q15_t)0x8d73, (q15_t)0x3906, (q15_t)0x8d68, (q15_t)0x38ef, + (q15_t)0x8d5d, (q15_t)0x38d8, (q15_t)0x8d51, (q15_t)0x38c2, (q15_t)0x8d46, + (q15_t)0x38ab, (q15_t)0x8d3b, (q15_t)0x3895, (q15_t)0x8d30, (q15_t)0x387e, + (q15_t)0x8d25, (q15_t)0x3868, (q15_t)0x8d1a, (q15_t)0x3851, (q15_t)0x8d0f, + (q15_t)0x383b, (q15_t)0x8d04, (q15_t)0x3824, (q15_t)0x8cf9, (q15_t)0x380d, + (q15_t)0x8cee, (q15_t)0x37f7, (q15_t)0x8ce3, (q15_t)0x37e0, (q15_t)0x8cd8, + (q15_t)0x37ca, (q15_t)0x8ccd, (q15_t)0x37b3, (q15_t)0x8cc2, (q15_t)0x379c, + (q15_t)0x8cb7, (q15_t)0x3786, (q15_t)0x8cac, (q15_t)0x376f, (q15_t)0x8ca1, + (q15_t)0x3758, (q15_t)0x8c96, (q15_t)0x3742, (q15_t)0x8c8b, (q15_t)0x372b, + (q15_t)0x8c81, (q15_t)0x3714, (q15_t)0x8c76, (q15_t)0x36fe, (q15_t)0x8c6b, + (q15_t)0x36e7, (q15_t)0x8c60, (q15_t)0x36d0, (q15_t)0x8c55, (q15_t)0x36ba, + (q15_t)0x8c4b, (q15_t)0x36a3, (q15_t)0x8c40, (q15_t)0x368c, (q15_t)0x8c35, + (q15_t)0x3675, (q15_t)0x8c2a, (q15_t)0x365f, (q15_t)0x8c20, (q15_t)0x3648, + (q15_t)0x8c15, (q15_t)0x3631, (q15_t)0x8c0a, (q15_t)0x361a, (q15_t)0x8c00, + (q15_t)0x3604, (q15_t)0x8bf5, (q15_t)0x35ed, (q15_t)0x8beb, (q15_t)0x35d6, + (q15_t)0x8be0, (q15_t)0x35bf, (q15_t)0x8bd5, (q15_t)0x35a8, (q15_t)0x8bcb, + (q15_t)0x3592, (q15_t)0x8bc0, (q15_t)0x357b, (q15_t)0x8bb6, (q15_t)0x3564, + (q15_t)0x8bab, (q15_t)0x354d, (q15_t)0x8ba1, (q15_t)0x3536, (q15_t)0x8b96, + (q15_t)0x351f, (q15_t)0x8b8c, (q15_t)0x3508, (q15_t)0x8b82, (q15_t)0x34f2, + (q15_t)0x8b77, (q15_t)0x34db, (q15_t)0x8b6d, (q15_t)0x34c4, (q15_t)0x8b62, + (q15_t)0x34ad, (q15_t)0x8b58, (q15_t)0x3496, (q15_t)0x8b4e, (q15_t)0x347f, + (q15_t)0x8b43, (q15_t)0x3468, (q15_t)0x8b39, (q15_t)0x3451, (q15_t)0x8b2f, + (q15_t)0x343a, (q15_t)0x8b25, (q15_t)0x3423, (q15_t)0x8b1a, (q15_t)0x340c, + (q15_t)0x8b10, (q15_t)0x33f5, (q15_t)0x8b06, (q15_t)0x33de, (q15_t)0x8afc, + (q15_t)0x33c7, (q15_t)0x8af1, (q15_t)0x33b0, (q15_t)0x8ae7, (q15_t)0x3399, + (q15_t)0x8add, (q15_t)0x3382, (q15_t)0x8ad3, (q15_t)0x336b, (q15_t)0x8ac9, + (q15_t)0x3354, (q15_t)0x8abf, (q15_t)0x333d, (q15_t)0x8ab5, (q15_t)0x3326, + (q15_t)0x8aab, (q15_t)0x330f, (q15_t)0x8aa1, (q15_t)0x32f8, (q15_t)0x8a97, + (q15_t)0x32e1, (q15_t)0x8a8d, (q15_t)0x32ca, (q15_t)0x8a83, (q15_t)0x32b3, + (q15_t)0x8a79, (q15_t)0x329c, (q15_t)0x8a6f, (q15_t)0x3285, (q15_t)0x8a65, + (q15_t)0x326e, (q15_t)0x8a5b, (q15_t)0x3257, (q15_t)0x8a51, (q15_t)0x3240, + (q15_t)0x8a47, (q15_t)0x3228, (q15_t)0x8a3d, (q15_t)0x3211, (q15_t)0x8a34, + (q15_t)0x31fa, (q15_t)0x8a2a, (q15_t)0x31e3, (q15_t)0x8a20, (q15_t)0x31cc, + (q15_t)0x8a16, (q15_t)0x31b5, (q15_t)0x8a0c, (q15_t)0x319e, (q15_t)0x8a03, + (q15_t)0x3186, (q15_t)0x89f9, (q15_t)0x316f, (q15_t)0x89ef, (q15_t)0x3158, + (q15_t)0x89e5, (q15_t)0x3141, (q15_t)0x89dc, (q15_t)0x312a, (q15_t)0x89d2, + (q15_t)0x3112, (q15_t)0x89c8, (q15_t)0x30fb, (q15_t)0x89bf, (q15_t)0x30e4, + (q15_t)0x89b5, (q15_t)0x30cd, (q15_t)0x89ac, (q15_t)0x30b6, (q15_t)0x89a2, + (q15_t)0x309e, (q15_t)0x8998, (q15_t)0x3087, (q15_t)0x898f, (q15_t)0x3070, + (q15_t)0x8985, (q15_t)0x3059, (q15_t)0x897c, (q15_t)0x3041, (q15_t)0x8972, + (q15_t)0x302a, (q15_t)0x8969, (q15_t)0x3013, (q15_t)0x8960, (q15_t)0x2ffb, + (q15_t)0x8956, (q15_t)0x2fe4, (q15_t)0x894d, (q15_t)0x2fcd, (q15_t)0x8943, + (q15_t)0x2fb5, (q15_t)0x893a, (q15_t)0x2f9e, (q15_t)0x8931, (q15_t)0x2f87, + (q15_t)0x8927, (q15_t)0x2f6f, (q15_t)0x891e, (q15_t)0x2f58, (q15_t)0x8915, + (q15_t)0x2f41, (q15_t)0x890b, (q15_t)0x2f29, (q15_t)0x8902, (q15_t)0x2f12, + (q15_t)0x88f9, (q15_t)0x2efb, (q15_t)0x88f0, (q15_t)0x2ee3, (q15_t)0x88e6, + (q15_t)0x2ecc, (q15_t)0x88dd, (q15_t)0x2eb5, (q15_t)0x88d4, (q15_t)0x2e9d, + (q15_t)0x88cb, (q15_t)0x2e86, (q15_t)0x88c2, (q15_t)0x2e6e, (q15_t)0x88b9, + (q15_t)0x2e57, (q15_t)0x88af, (q15_t)0x2e3f, (q15_t)0x88a6, (q15_t)0x2e28, + (q15_t)0x889d, (q15_t)0x2e11, (q15_t)0x8894, (q15_t)0x2df9, (q15_t)0x888b, + (q15_t)0x2de2, (q15_t)0x8882, (q15_t)0x2dca, (q15_t)0x8879, (q15_t)0x2db3, + (q15_t)0x8870, (q15_t)0x2d9b, (q15_t)0x8867, (q15_t)0x2d84, (q15_t)0x885e, + (q15_t)0x2d6c, (q15_t)0x8855, (q15_t)0x2d55, (q15_t)0x884c, (q15_t)0x2d3d, + (q15_t)0x8844, (q15_t)0x2d26, (q15_t)0x883b, (q15_t)0x2d0e, (q15_t)0x8832, + (q15_t)0x2cf7, (q15_t)0x8829, (q15_t)0x2cdf, (q15_t)0x8820, (q15_t)0x2cc8, + (q15_t)0x8817, (q15_t)0x2cb0, (q15_t)0x880f, (q15_t)0x2c98, (q15_t)0x8806, + (q15_t)0x2c81, (q15_t)0x87fd, (q15_t)0x2c69, (q15_t)0x87f4, (q15_t)0x2c52, + (q15_t)0x87ec, (q15_t)0x2c3a, (q15_t)0x87e3, (q15_t)0x2c23, (q15_t)0x87da, + (q15_t)0x2c0b, (q15_t)0x87d2, (q15_t)0x2bf3, (q15_t)0x87c9, (q15_t)0x2bdc, + (q15_t)0x87c0, (q15_t)0x2bc4, (q15_t)0x87b8, (q15_t)0x2bad, (q15_t)0x87af, + (q15_t)0x2b95, (q15_t)0x87a7, (q15_t)0x2b7d, (q15_t)0x879e, (q15_t)0x2b66, + (q15_t)0x8795, (q15_t)0x2b4e, (q15_t)0x878d, (q15_t)0x2b36, (q15_t)0x8784, + (q15_t)0x2b1f, (q15_t)0x877c, (q15_t)0x2b07, (q15_t)0x8774, (q15_t)0x2aef, + (q15_t)0x876b, (q15_t)0x2ad8, (q15_t)0x8763, (q15_t)0x2ac0, (q15_t)0x875a, + (q15_t)0x2aa8, (q15_t)0x8752, (q15_t)0x2a91, (q15_t)0x874a, (q15_t)0x2a79, + (q15_t)0x8741, (q15_t)0x2a61, (q15_t)0x8739, (q15_t)0x2a49, (q15_t)0x8731, + (q15_t)0x2a32, (q15_t)0x8728, (q15_t)0x2a1a, (q15_t)0x8720, (q15_t)0x2a02, + (q15_t)0x8718, (q15_t)0x29eb, (q15_t)0x870f, (q15_t)0x29d3, (q15_t)0x8707, + (q15_t)0x29bb, (q15_t)0x86ff, (q15_t)0x29a3, (q15_t)0x86f7, (q15_t)0x298b, + (q15_t)0x86ef, (q15_t)0x2974, (q15_t)0x86e7, (q15_t)0x295c, (q15_t)0x86de, + (q15_t)0x2944, (q15_t)0x86d6, (q15_t)0x292c, (q15_t)0x86ce, (q15_t)0x2915, + (q15_t)0x86c6, (q15_t)0x28fd, (q15_t)0x86be, (q15_t)0x28e5, (q15_t)0x86b6, + (q15_t)0x28cd, (q15_t)0x86ae, (q15_t)0x28b5, (q15_t)0x86a6, (q15_t)0x289d, + (q15_t)0x869e, (q15_t)0x2886, (q15_t)0x8696, (q15_t)0x286e, (q15_t)0x868e, + (q15_t)0x2856, (q15_t)0x8686, (q15_t)0x283e, (q15_t)0x867e, (q15_t)0x2826, + (q15_t)0x8676, (q15_t)0x280e, (q15_t)0x866e, (q15_t)0x27f6, (q15_t)0x8667, + (q15_t)0x27df, (q15_t)0x865f, (q15_t)0x27c7, (q15_t)0x8657, (q15_t)0x27af, + (q15_t)0x864f, (q15_t)0x2797, (q15_t)0x8647, (q15_t)0x277f, (q15_t)0x8640, + (q15_t)0x2767, (q15_t)0x8638, (q15_t)0x274f, (q15_t)0x8630, (q15_t)0x2737, + (q15_t)0x8628, (q15_t)0x271f, (q15_t)0x8621, (q15_t)0x2707, (q15_t)0x8619, + (q15_t)0x26ef, (q15_t)0x8611, (q15_t)0x26d8, (q15_t)0x860a, (q15_t)0x26c0, + (q15_t)0x8602, (q15_t)0x26a8, (q15_t)0x85fb, (q15_t)0x2690, (q15_t)0x85f3, + (q15_t)0x2678, (q15_t)0x85eb, (q15_t)0x2660, (q15_t)0x85e4, (q15_t)0x2648, + (q15_t)0x85dc, (q15_t)0x2630, (q15_t)0x85d5, (q15_t)0x2618, (q15_t)0x85cd, + (q15_t)0x2600, (q15_t)0x85c6, (q15_t)0x25e8, (q15_t)0x85be, (q15_t)0x25d0, + (q15_t)0x85b7, (q15_t)0x25b8, (q15_t)0x85b0, (q15_t)0x25a0, (q15_t)0x85a8, + (q15_t)0x2588, (q15_t)0x85a1, (q15_t)0x2570, (q15_t)0x8599, (q15_t)0x2558, + (q15_t)0x8592, (q15_t)0x2540, (q15_t)0x858b, (q15_t)0x2528, (q15_t)0x8583, + (q15_t)0x250f, (q15_t)0x857c, (q15_t)0x24f7, (q15_t)0x8575, (q15_t)0x24df, + (q15_t)0x856e, (q15_t)0x24c7, (q15_t)0x8566, (q15_t)0x24af, (q15_t)0x855f, + (q15_t)0x2497, (q15_t)0x8558, (q15_t)0x247f, (q15_t)0x8551, (q15_t)0x2467, + (q15_t)0x854a, (q15_t)0x244f, (q15_t)0x8543, (q15_t)0x2437, (q15_t)0x853b, + (q15_t)0x241f, (q15_t)0x8534, (q15_t)0x2407, (q15_t)0x852d, (q15_t)0x23ee, + (q15_t)0x8526, (q15_t)0x23d6, (q15_t)0x851f, (q15_t)0x23be, (q15_t)0x8518, + (q15_t)0x23a6, (q15_t)0x8511, (q15_t)0x238e, (q15_t)0x850a, (q15_t)0x2376, + (q15_t)0x8503, (q15_t)0x235e, (q15_t)0x84fc, (q15_t)0x2345, (q15_t)0x84f5, + (q15_t)0x232d, (q15_t)0x84ee, (q15_t)0x2315, (q15_t)0x84e7, (q15_t)0x22fd, + (q15_t)0x84e1, (q15_t)0x22e5, (q15_t)0x84da, (q15_t)0x22cd, (q15_t)0x84d3, + (q15_t)0x22b4, (q15_t)0x84cc, (q15_t)0x229c, (q15_t)0x84c5, (q15_t)0x2284, + (q15_t)0x84be, (q15_t)0x226c, (q15_t)0x84b8, (q15_t)0x2254, (q15_t)0x84b1, + (q15_t)0x223b, (q15_t)0x84aa, (q15_t)0x2223, (q15_t)0x84a3, (q15_t)0x220b, + (q15_t)0x849d, (q15_t)0x21f3, (q15_t)0x8496, (q15_t)0x21da, (q15_t)0x848f, + (q15_t)0x21c2, (q15_t)0x8489, (q15_t)0x21aa, (q15_t)0x8482, (q15_t)0x2192, + (q15_t)0x847c, (q15_t)0x2179, (q15_t)0x8475, (q15_t)0x2161, (q15_t)0x846e, + (q15_t)0x2149, (q15_t)0x8468, (q15_t)0x2131, (q15_t)0x8461, (q15_t)0x2118, + (q15_t)0x845b, (q15_t)0x2100, (q15_t)0x8454, (q15_t)0x20e8, (q15_t)0x844e, + (q15_t)0x20d0, (q15_t)0x8447, (q15_t)0x20b7, (q15_t)0x8441, (q15_t)0x209f, + (q15_t)0x843b, (q15_t)0x2087, (q15_t)0x8434, (q15_t)0x206e, (q15_t)0x842e, + (q15_t)0x2056, (q15_t)0x8427, (q15_t)0x203e, (q15_t)0x8421, (q15_t)0x2025, + (q15_t)0x841b, (q15_t)0x200d, (q15_t)0x8415, (q15_t)0x1ff5, (q15_t)0x840e, + (q15_t)0x1fdc, (q15_t)0x8408, (q15_t)0x1fc4, (q15_t)0x8402, (q15_t)0x1fac, + (q15_t)0x83fb, (q15_t)0x1f93, (q15_t)0x83f5, (q15_t)0x1f7b, (q15_t)0x83ef, + (q15_t)0x1f63, (q15_t)0x83e9, (q15_t)0x1f4a, (q15_t)0x83e3, (q15_t)0x1f32, + (q15_t)0x83dd, (q15_t)0x1f19, (q15_t)0x83d7, (q15_t)0x1f01, (q15_t)0x83d0, + (q15_t)0x1ee9, (q15_t)0x83ca, (q15_t)0x1ed0, (q15_t)0x83c4, (q15_t)0x1eb8, + (q15_t)0x83be, (q15_t)0x1ea0, (q15_t)0x83b8, (q15_t)0x1e87, (q15_t)0x83b2, + (q15_t)0x1e6f, (q15_t)0x83ac, (q15_t)0x1e56, (q15_t)0x83a6, (q15_t)0x1e3e, + (q15_t)0x83a0, (q15_t)0x1e25, (q15_t)0x839a, (q15_t)0x1e0d, (q15_t)0x8394, + (q15_t)0x1df5, (q15_t)0x838f, (q15_t)0x1ddc, (q15_t)0x8389, (q15_t)0x1dc4, + (q15_t)0x8383, (q15_t)0x1dab, (q15_t)0x837d, (q15_t)0x1d93, (q15_t)0x8377, + (q15_t)0x1d7a, (q15_t)0x8371, (q15_t)0x1d62, (q15_t)0x836c, (q15_t)0x1d49, + (q15_t)0x8366, (q15_t)0x1d31, (q15_t)0x8360, (q15_t)0x1d18, (q15_t)0x835a, + (q15_t)0x1d00, (q15_t)0x8355, (q15_t)0x1ce8, (q15_t)0x834f, (q15_t)0x1ccf, + (q15_t)0x8349, (q15_t)0x1cb7, (q15_t)0x8344, (q15_t)0x1c9e, (q15_t)0x833e, + (q15_t)0x1c86, (q15_t)0x8338, (q15_t)0x1c6d, (q15_t)0x8333, (q15_t)0x1c55, + (q15_t)0x832d, (q15_t)0x1c3c, (q15_t)0x8328, (q15_t)0x1c24, (q15_t)0x8322, + (q15_t)0x1c0b, (q15_t)0x831d, (q15_t)0x1bf2, (q15_t)0x8317, (q15_t)0x1bda, + (q15_t)0x8312, (q15_t)0x1bc1, (q15_t)0x830c, (q15_t)0x1ba9, (q15_t)0x8307, + (q15_t)0x1b90, (q15_t)0x8301, (q15_t)0x1b78, (q15_t)0x82fc, (q15_t)0x1b5f, + (q15_t)0x82f7, (q15_t)0x1b47, (q15_t)0x82f1, (q15_t)0x1b2e, (q15_t)0x82ec, + (q15_t)0x1b16, (q15_t)0x82e7, (q15_t)0x1afd, (q15_t)0x82e1, (q15_t)0x1ae4, + (q15_t)0x82dc, (q15_t)0x1acc, (q15_t)0x82d7, (q15_t)0x1ab3, (q15_t)0x82d1, + (q15_t)0x1a9b, (q15_t)0x82cc, (q15_t)0x1a82, (q15_t)0x82c7, (q15_t)0x1a6a, + (q15_t)0x82c2, (q15_t)0x1a51, (q15_t)0x82bd, (q15_t)0x1a38, (q15_t)0x82b7, + (q15_t)0x1a20, (q15_t)0x82b2, (q15_t)0x1a07, (q15_t)0x82ad, (q15_t)0x19ef, + (q15_t)0x82a8, (q15_t)0x19d6, (q15_t)0x82a3, (q15_t)0x19bd, (q15_t)0x829e, + (q15_t)0x19a5, (q15_t)0x8299, (q15_t)0x198c, (q15_t)0x8294, (q15_t)0x1973, + (q15_t)0x828f, (q15_t)0x195b, (q15_t)0x828a, (q15_t)0x1942, (q15_t)0x8285, + (q15_t)0x192a, (q15_t)0x8280, (q15_t)0x1911, (q15_t)0x827b, (q15_t)0x18f8, + (q15_t)0x8276, (q15_t)0x18e0, (q15_t)0x8271, (q15_t)0x18c7, (q15_t)0x826c, + (q15_t)0x18ae, (q15_t)0x8268, (q15_t)0x1896, (q15_t)0x8263, (q15_t)0x187d, + (q15_t)0x825e, (q15_t)0x1864, (q15_t)0x8259, (q15_t)0x184c, (q15_t)0x8254, + (q15_t)0x1833, (q15_t)0x8250, (q15_t)0x181a, (q15_t)0x824b, (q15_t)0x1802, + (q15_t)0x8246, (q15_t)0x17e9, (q15_t)0x8241, (q15_t)0x17d0, (q15_t)0x823d, + (q15_t)0x17b7, (q15_t)0x8238, (q15_t)0x179f, (q15_t)0x8233, (q15_t)0x1786, + (q15_t)0x822f, (q15_t)0x176d, (q15_t)0x822a, (q15_t)0x1755, (q15_t)0x8226, + (q15_t)0x173c, (q15_t)0x8221, (q15_t)0x1723, (q15_t)0x821c, (q15_t)0x170a, + (q15_t)0x8218, (q15_t)0x16f2, (q15_t)0x8213, (q15_t)0x16d9, (q15_t)0x820f, + (q15_t)0x16c0, (q15_t)0x820a, (q15_t)0x16a8, (q15_t)0x8206, (q15_t)0x168f, + (q15_t)0x8201, (q15_t)0x1676, (q15_t)0x81fd, (q15_t)0x165d, (q15_t)0x81f9, + (q15_t)0x1645, (q15_t)0x81f4, (q15_t)0x162c, (q15_t)0x81f0, (q15_t)0x1613, + (q15_t)0x81ec, (q15_t)0x15fa, (q15_t)0x81e7, (q15_t)0x15e2, (q15_t)0x81e3, + (q15_t)0x15c9, (q15_t)0x81df, (q15_t)0x15b0, (q15_t)0x81da, (q15_t)0x1597, + (q15_t)0x81d6, (q15_t)0x157f, (q15_t)0x81d2, (q15_t)0x1566, (q15_t)0x81ce, + (q15_t)0x154d, (q15_t)0x81c9, (q15_t)0x1534, (q15_t)0x81c5, (q15_t)0x151b, + (q15_t)0x81c1, (q15_t)0x1503, (q15_t)0x81bd, (q15_t)0x14ea, (q15_t)0x81b9, + (q15_t)0x14d1, (q15_t)0x81b5, (q15_t)0x14b8, (q15_t)0x81b1, (q15_t)0x149f, + (q15_t)0x81ad, (q15_t)0x1487, (q15_t)0x81a9, (q15_t)0x146e, (q15_t)0x81a5, + (q15_t)0x1455, (q15_t)0x81a1, (q15_t)0x143c, (q15_t)0x819d, (q15_t)0x1423, + (q15_t)0x8199, (q15_t)0x140b, (q15_t)0x8195, (q15_t)0x13f2, (q15_t)0x8191, + (q15_t)0x13d9, (q15_t)0x818d, (q15_t)0x13c0, (q15_t)0x8189, (q15_t)0x13a7, + (q15_t)0x8185, (q15_t)0x138e, (q15_t)0x8181, (q15_t)0x1376, (q15_t)0x817d, + (q15_t)0x135d, (q15_t)0x817a, (q15_t)0x1344, (q15_t)0x8176, (q15_t)0x132b, + (q15_t)0x8172, (q15_t)0x1312, (q15_t)0x816e, (q15_t)0x12f9, (q15_t)0x816b, + (q15_t)0x12e0, (q15_t)0x8167, (q15_t)0x12c8, (q15_t)0x8163, (q15_t)0x12af, + (q15_t)0x815f, (q15_t)0x1296, (q15_t)0x815c, (q15_t)0x127d, (q15_t)0x8158, + (q15_t)0x1264, (q15_t)0x8155, (q15_t)0x124b, (q15_t)0x8151, (q15_t)0x1232, + (q15_t)0x814d, (q15_t)0x1219, (q15_t)0x814a, (q15_t)0x1201, (q15_t)0x8146, + (q15_t)0x11e8, (q15_t)0x8143, (q15_t)0x11cf, (q15_t)0x813f, (q15_t)0x11b6, + (q15_t)0x813c, (q15_t)0x119d, (q15_t)0x8138, (q15_t)0x1184, (q15_t)0x8135, + (q15_t)0x116b, (q15_t)0x8131, (q15_t)0x1152, (q15_t)0x812e, (q15_t)0x1139, + (q15_t)0x812b, (q15_t)0x1121, (q15_t)0x8127, (q15_t)0x1108, (q15_t)0x8124, + (q15_t)0x10ef, (q15_t)0x8121, (q15_t)0x10d6, (q15_t)0x811d, (q15_t)0x10bd, + (q15_t)0x811a, (q15_t)0x10a4, (q15_t)0x8117, (q15_t)0x108b, (q15_t)0x8113, + (q15_t)0x1072, (q15_t)0x8110, (q15_t)0x1059, (q15_t)0x810d, (q15_t)0x1040, + (q15_t)0x810a, (q15_t)0x1027, (q15_t)0x8107, (q15_t)0x100e, (q15_t)0x8103, + (q15_t)0xff5, (q15_t)0x8100, (q15_t)0xfdd, (q15_t)0x80fd, (q15_t)0xfc4, + (q15_t)0x80fa, (q15_t)0xfab, (q15_t)0x80f7, (q15_t)0xf92, (q15_t)0x80f4, + (q15_t)0xf79, (q15_t)0x80f1, (q15_t)0xf60, (q15_t)0x80ee, (q15_t)0xf47, + (q15_t)0x80eb, (q15_t)0xf2e, (q15_t)0x80e8, (q15_t)0xf15, (q15_t)0x80e5, + (q15_t)0xefc, (q15_t)0x80e2, (q15_t)0xee3, (q15_t)0x80df, (q15_t)0xeca, + (q15_t)0x80dc, (q15_t)0xeb1, (q15_t)0x80d9, (q15_t)0xe98, (q15_t)0x80d6, + (q15_t)0xe7f, (q15_t)0x80d3, (q15_t)0xe66, (q15_t)0x80d1, (q15_t)0xe4d, + (q15_t)0x80ce, (q15_t)0xe34, (q15_t)0x80cb, (q15_t)0xe1b, (q15_t)0x80c8, + (q15_t)0xe02, (q15_t)0x80c5, (q15_t)0xde9, (q15_t)0x80c3, (q15_t)0xdd0, + (q15_t)0x80c0, (q15_t)0xdb7, (q15_t)0x80bd, (q15_t)0xd9e, (q15_t)0x80bb, + (q15_t)0xd85, (q15_t)0x80b8, (q15_t)0xd6c, (q15_t)0x80b5, (q15_t)0xd53, + (q15_t)0x80b3, (q15_t)0xd3a, (q15_t)0x80b0, (q15_t)0xd21, (q15_t)0x80ad, + (q15_t)0xd08, (q15_t)0x80ab, (q15_t)0xcef, (q15_t)0x80a8, (q15_t)0xcd6, + (q15_t)0x80a6, (q15_t)0xcbd, (q15_t)0x80a3, (q15_t)0xca4, (q15_t)0x80a1, + (q15_t)0xc8b, (q15_t)0x809e, (q15_t)0xc72, (q15_t)0x809c, (q15_t)0xc59, + (q15_t)0x8099, (q15_t)0xc40, (q15_t)0x8097, (q15_t)0xc27, (q15_t)0x8095, + (q15_t)0xc0e, (q15_t)0x8092, (q15_t)0xbf5, (q15_t)0x8090, (q15_t)0xbdc, + (q15_t)0x808e, (q15_t)0xbc3, (q15_t)0x808b, (q15_t)0xbaa, (q15_t)0x8089, + (q15_t)0xb91, (q15_t)0x8087, (q15_t)0xb78, (q15_t)0x8084, (q15_t)0xb5f, + (q15_t)0x8082, (q15_t)0xb46, (q15_t)0x8080, (q15_t)0xb2d, (q15_t)0x807e, + (q15_t)0xb14, (q15_t)0x807b, (q15_t)0xafb, (q15_t)0x8079, (q15_t)0xae2, + (q15_t)0x8077, (q15_t)0xac9, (q15_t)0x8075, (q15_t)0xab0, (q15_t)0x8073, + (q15_t)0xa97, (q15_t)0x8071, (q15_t)0xa7e, (q15_t)0x806f, (q15_t)0xa65, + (q15_t)0x806d, (q15_t)0xa4c, (q15_t)0x806b, (q15_t)0xa33, (q15_t)0x8069, + (q15_t)0xa19, (q15_t)0x8067, (q15_t)0xa00, (q15_t)0x8065, (q15_t)0x9e7, + (q15_t)0x8063, (q15_t)0x9ce, (q15_t)0x8061, (q15_t)0x9b5, (q15_t)0x805f, + (q15_t)0x99c, (q15_t)0x805d, (q15_t)0x983, (q15_t)0x805b, (q15_t)0x96a, + (q15_t)0x8059, (q15_t)0x951, (q15_t)0x8057, (q15_t)0x938, (q15_t)0x8056, + (q15_t)0x91f, (q15_t)0x8054, (q15_t)0x906, (q15_t)0x8052, (q15_t)0x8ed, + (q15_t)0x8050, (q15_t)0x8d4, (q15_t)0x804f, (q15_t)0x8bb, (q15_t)0x804d, + (q15_t)0x8a2, (q15_t)0x804b, (q15_t)0x888, (q15_t)0x8049, (q15_t)0x86f, + (q15_t)0x8048, (q15_t)0x856, (q15_t)0x8046, (q15_t)0x83d, (q15_t)0x8044, + (q15_t)0x824, (q15_t)0x8043, (q15_t)0x80b, (q15_t)0x8041, (q15_t)0x7f2, + (q15_t)0x8040, (q15_t)0x7d9, (q15_t)0x803e, (q15_t)0x7c0, (q15_t)0x803d, + (q15_t)0x7a7, (q15_t)0x803b, (q15_t)0x78e, (q15_t)0x803a, (q15_t)0x775, + (q15_t)0x8038, (q15_t)0x75b, (q15_t)0x8037, (q15_t)0x742, (q15_t)0x8035, + (q15_t)0x729, (q15_t)0x8034, (q15_t)0x710, (q15_t)0x8032, (q15_t)0x6f7, + (q15_t)0x8031, (q15_t)0x6de, (q15_t)0x8030, (q15_t)0x6c5, (q15_t)0x802e, + (q15_t)0x6ac, (q15_t)0x802d, (q15_t)0x693, (q15_t)0x802c, (q15_t)0x67a, + (q15_t)0x802a, (q15_t)0x660, (q15_t)0x8029, (q15_t)0x647, (q15_t)0x8028, + (q15_t)0x62e, (q15_t)0x8027, (q15_t)0x615, (q15_t)0x8026, (q15_t)0x5fc, + (q15_t)0x8024, (q15_t)0x5e3, (q15_t)0x8023, (q15_t)0x5ca, (q15_t)0x8022, + (q15_t)0x5b1, (q15_t)0x8021, (q15_t)0x598, (q15_t)0x8020, (q15_t)0x57f, + (q15_t)0x801f, (q15_t)0x565, (q15_t)0x801e, (q15_t)0x54c, (q15_t)0x801d, + (q15_t)0x533, (q15_t)0x801c, (q15_t)0x51a, (q15_t)0x801b, (q15_t)0x501, + (q15_t)0x801a, (q15_t)0x4e8, (q15_t)0x8019, (q15_t)0x4cf, (q15_t)0x8018, + (q15_t)0x4b6, (q15_t)0x8017, (q15_t)0x49c, (q15_t)0x8016, (q15_t)0x483, + (q15_t)0x8015, (q15_t)0x46a, (q15_t)0x8014, (q15_t)0x451, (q15_t)0x8013, + (q15_t)0x438, (q15_t)0x8012, (q15_t)0x41f, (q15_t)0x8012, (q15_t)0x406, + (q15_t)0x8011, (q15_t)0x3ed, (q15_t)0x8010, (q15_t)0x3d4, (q15_t)0x800f, + (q15_t)0x3ba, (q15_t)0x800e, (q15_t)0x3a1, (q15_t)0x800e, (q15_t)0x388, + (q15_t)0x800d, (q15_t)0x36f, (q15_t)0x800c, (q15_t)0x356, (q15_t)0x800c, + (q15_t)0x33d, (q15_t)0x800b, (q15_t)0x324, (q15_t)0x800a, (q15_t)0x30b, + (q15_t)0x800a, (q15_t)0x2f1, (q15_t)0x8009, (q15_t)0x2d8, (q15_t)0x8009, + (q15_t)0x2bf, (q15_t)0x8008, (q15_t)0x2a6, (q15_t)0x8008, (q15_t)0x28d, + (q15_t)0x8007, (q15_t)0x274, (q15_t)0x8007, (q15_t)0x25b, (q15_t)0x8006, + (q15_t)0x242, (q15_t)0x8006, (q15_t)0x228, (q15_t)0x8005, (q15_t)0x20f, + (q15_t)0x8005, (q15_t)0x1f6, (q15_t)0x8004, (q15_t)0x1dd, (q15_t)0x8004, + (q15_t)0x1c4, (q15_t)0x8004, (q15_t)0x1ab, (q15_t)0x8003, (q15_t)0x192, + (q15_t)0x8003, (q15_t)0x178, (q15_t)0x8003, (q15_t)0x15f, (q15_t)0x8002, + (q15_t)0x146, (q15_t)0x8002, (q15_t)0x12d, (q15_t)0x8002, (q15_t)0x114, + (q15_t)0x8002, (q15_t)0xfb, (q15_t)0x8001, (q15_t)0xe2, (q15_t)0x8001, + (q15_t)0xc9, (q15_t)0x8001, (q15_t)0xaf, (q15_t)0x8001, (q15_t)0x96, + (q15_t)0x8001, (q15_t)0x7d, (q15_t)0x8001, (q15_t)0x64, (q15_t)0x8001, + (q15_t)0x4b, (q15_t)0x8001, (q15_t)0x32, (q15_t)0x8001, (q15_t)0x19, + (q15_t)0x8001}; static const q15_t __ALIGNED(4) WeightsQ15_8192[16384] = { - (q15_t)0x7fff, (q15_t)0x0, (q15_t)0x7fff, (q15_t)0xfffa, (q15_t)0x7fff, (q15_t)0xfff4, (q15_t)0x7fff, (q15_t)0xffee, - (q15_t)0x7fff, (q15_t)0xffe7, (q15_t)0x7fff, (q15_t)0xffe1, (q15_t)0x7fff, (q15_t)0xffdb, (q15_t)0x7fff, (q15_t)0xffd5, - (q15_t)0x7fff, (q15_t)0xffce, (q15_t)0x7fff, (q15_t)0xffc8, (q15_t)0x7fff, (q15_t)0xffc2, (q15_t)0x7fff, (q15_t)0xffbb, - (q15_t)0x7fff, (q15_t)0xffb5, (q15_t)0x7fff, (q15_t)0xffaf, (q15_t)0x7fff, (q15_t)0xffa9, (q15_t)0x7fff, (q15_t)0xffa2, - (q15_t)0x7fff, (q15_t)0xff9c, (q15_t)0x7fff, (q15_t)0xff96, (q15_t)0x7fff, (q15_t)0xff8f, (q15_t)0x7fff, (q15_t)0xff89, - (q15_t)0x7fff, (q15_t)0xff83, (q15_t)0x7fff, (q15_t)0xff7d, (q15_t)0x7fff, (q15_t)0xff76, (q15_t)0x7fff, (q15_t)0xff70, - (q15_t)0x7fff, (q15_t)0xff6a, (q15_t)0x7fff, (q15_t)0xff63, (q15_t)0x7fff, (q15_t)0xff5d, (q15_t)0x7fff, (q15_t)0xff57, - (q15_t)0x7fff, (q15_t)0xff51, (q15_t)0x7fff, (q15_t)0xff4a, (q15_t)0x7fff, (q15_t)0xff44, (q15_t)0x7fff, (q15_t)0xff3e, - (q15_t)0x7fff, (q15_t)0xff37, (q15_t)0x7fff, (q15_t)0xff31, (q15_t)0x7fff, (q15_t)0xff2b, (q15_t)0x7fff, (q15_t)0xff25, - (q15_t)0x7fff, (q15_t)0xff1e, (q15_t)0x7fff, (q15_t)0xff18, (q15_t)0x7fff, (q15_t)0xff12, (q15_t)0x7fff, (q15_t)0xff0b, - (q15_t)0x7fff, (q15_t)0xff05, (q15_t)0x7ffe, (q15_t)0xfeff, (q15_t)0x7ffe, (q15_t)0xfef9, (q15_t)0x7ffe, (q15_t)0xfef2, - (q15_t)0x7ffe, (q15_t)0xfeec, (q15_t)0x7ffe, (q15_t)0xfee6, (q15_t)0x7ffe, (q15_t)0xfedf, (q15_t)0x7ffe, (q15_t)0xfed9, - (q15_t)0x7ffe, (q15_t)0xfed3, (q15_t)0x7ffe, (q15_t)0xfecd, (q15_t)0x7ffe, (q15_t)0xfec6, (q15_t)0x7ffe, (q15_t)0xfec0, - (q15_t)0x7ffe, (q15_t)0xfeba, (q15_t)0x7ffe, (q15_t)0xfeb3, (q15_t)0x7ffe, (q15_t)0xfead, (q15_t)0x7ffe, (q15_t)0xfea7, - (q15_t)0x7ffe, (q15_t)0xfea1, (q15_t)0x7ffe, (q15_t)0xfe9a, (q15_t)0x7ffd, (q15_t)0xfe94, (q15_t)0x7ffd, (q15_t)0xfe8e, - (q15_t)0x7ffd, (q15_t)0xfe88, (q15_t)0x7ffd, (q15_t)0xfe81, (q15_t)0x7ffd, (q15_t)0xfe7b, (q15_t)0x7ffd, (q15_t)0xfe75, - (q15_t)0x7ffd, (q15_t)0xfe6e, (q15_t)0x7ffd, (q15_t)0xfe68, (q15_t)0x7ffd, (q15_t)0xfe62, (q15_t)0x7ffd, (q15_t)0xfe5c, - (q15_t)0x7ffd, (q15_t)0xfe55, (q15_t)0x7ffd, (q15_t)0xfe4f, (q15_t)0x7ffd, (q15_t)0xfe49, (q15_t)0x7ffc, (q15_t)0xfe42, - (q15_t)0x7ffc, (q15_t)0xfe3c, (q15_t)0x7ffc, (q15_t)0xfe36, (q15_t)0x7ffc, (q15_t)0xfe30, (q15_t)0x7ffc, (q15_t)0xfe29, - (q15_t)0x7ffc, (q15_t)0xfe23, (q15_t)0x7ffc, (q15_t)0xfe1d, (q15_t)0x7ffc, (q15_t)0xfe16, (q15_t)0x7ffc, (q15_t)0xfe10, - (q15_t)0x7ffc, (q15_t)0xfe0a, (q15_t)0x7ffc, (q15_t)0xfe04, (q15_t)0x7ffb, (q15_t)0xfdfd, (q15_t)0x7ffb, (q15_t)0xfdf7, - (q15_t)0x7ffb, (q15_t)0xfdf1, (q15_t)0x7ffb, (q15_t)0xfdea, (q15_t)0x7ffb, (q15_t)0xfde4, (q15_t)0x7ffb, (q15_t)0xfdde, - (q15_t)0x7ffb, (q15_t)0xfdd8, (q15_t)0x7ffb, (q15_t)0xfdd1, (q15_t)0x7ffb, (q15_t)0xfdcb, (q15_t)0x7ffb, (q15_t)0xfdc5, - (q15_t)0x7ffa, (q15_t)0xfdbe, (q15_t)0x7ffa, (q15_t)0xfdb8, (q15_t)0x7ffa, (q15_t)0xfdb2, (q15_t)0x7ffa, (q15_t)0xfdac, - (q15_t)0x7ffa, (q15_t)0xfda5, (q15_t)0x7ffa, (q15_t)0xfd9f, (q15_t)0x7ffa, (q15_t)0xfd99, (q15_t)0x7ffa, (q15_t)0xfd93, - (q15_t)0x7ff9, (q15_t)0xfd8c, (q15_t)0x7ff9, (q15_t)0xfd86, (q15_t)0x7ff9, (q15_t)0xfd80, (q15_t)0x7ff9, (q15_t)0xfd79, - (q15_t)0x7ff9, (q15_t)0xfd73, (q15_t)0x7ff9, (q15_t)0xfd6d, (q15_t)0x7ff9, (q15_t)0xfd67, (q15_t)0x7ff9, (q15_t)0xfd60, - (q15_t)0x7ff8, (q15_t)0xfd5a, (q15_t)0x7ff8, (q15_t)0xfd54, (q15_t)0x7ff8, (q15_t)0xfd4d, (q15_t)0x7ff8, (q15_t)0xfd47, - (q15_t)0x7ff8, (q15_t)0xfd41, (q15_t)0x7ff8, (q15_t)0xfd3b, (q15_t)0x7ff8, (q15_t)0xfd34, (q15_t)0x7ff8, (q15_t)0xfd2e, - (q15_t)0x7ff7, (q15_t)0xfd28, (q15_t)0x7ff7, (q15_t)0xfd21, (q15_t)0x7ff7, (q15_t)0xfd1b, (q15_t)0x7ff7, (q15_t)0xfd15, - (q15_t)0x7ff7, (q15_t)0xfd0f, (q15_t)0x7ff7, (q15_t)0xfd08, (q15_t)0x7ff7, (q15_t)0xfd02, (q15_t)0x7ff6, (q15_t)0xfcfc, - (q15_t)0x7ff6, (q15_t)0xfcf5, (q15_t)0x7ff6, (q15_t)0xfcef, (q15_t)0x7ff6, (q15_t)0xfce9, (q15_t)0x7ff6, (q15_t)0xfce3, - (q15_t)0x7ff6, (q15_t)0xfcdc, (q15_t)0x7ff5, (q15_t)0xfcd6, (q15_t)0x7ff5, (q15_t)0xfcd0, (q15_t)0x7ff5, (q15_t)0xfcc9, - (q15_t)0x7ff5, (q15_t)0xfcc3, (q15_t)0x7ff5, (q15_t)0xfcbd, (q15_t)0x7ff5, (q15_t)0xfcb7, (q15_t)0x7ff5, (q15_t)0xfcb0, - (q15_t)0x7ff4, (q15_t)0xfcaa, (q15_t)0x7ff4, (q15_t)0xfca4, (q15_t)0x7ff4, (q15_t)0xfc9e, (q15_t)0x7ff4, (q15_t)0xfc97, - (q15_t)0x7ff4, (q15_t)0xfc91, (q15_t)0x7ff4, (q15_t)0xfc8b, (q15_t)0x7ff3, (q15_t)0xfc84, (q15_t)0x7ff3, (q15_t)0xfc7e, - (q15_t)0x7ff3, (q15_t)0xfc78, (q15_t)0x7ff3, (q15_t)0xfc72, (q15_t)0x7ff3, (q15_t)0xfc6b, (q15_t)0x7ff2, (q15_t)0xfc65, - (q15_t)0x7ff2, (q15_t)0xfc5f, (q15_t)0x7ff2, (q15_t)0xfc58, (q15_t)0x7ff2, (q15_t)0xfc52, (q15_t)0x7ff2, (q15_t)0xfc4c, - (q15_t)0x7ff2, (q15_t)0xfc46, (q15_t)0x7ff1, (q15_t)0xfc3f, (q15_t)0x7ff1, (q15_t)0xfc39, (q15_t)0x7ff1, (q15_t)0xfc33, - (q15_t)0x7ff1, (q15_t)0xfc2c, (q15_t)0x7ff1, (q15_t)0xfc26, (q15_t)0x7ff0, (q15_t)0xfc20, (q15_t)0x7ff0, (q15_t)0xfc1a, - (q15_t)0x7ff0, (q15_t)0xfc13, (q15_t)0x7ff0, (q15_t)0xfc0d, (q15_t)0x7ff0, (q15_t)0xfc07, (q15_t)0x7fef, (q15_t)0xfc01, - (q15_t)0x7fef, (q15_t)0xfbfa, (q15_t)0x7fef, (q15_t)0xfbf4, (q15_t)0x7fef, (q15_t)0xfbee, (q15_t)0x7fef, (q15_t)0xfbe7, - (q15_t)0x7fee, (q15_t)0xfbe1, (q15_t)0x7fee, (q15_t)0xfbdb, (q15_t)0x7fee, (q15_t)0xfbd5, (q15_t)0x7fee, (q15_t)0xfbce, - (q15_t)0x7fee, (q15_t)0xfbc8, (q15_t)0x7fed, (q15_t)0xfbc2, (q15_t)0x7fed, (q15_t)0xfbbb, (q15_t)0x7fed, (q15_t)0xfbb5, - (q15_t)0x7fed, (q15_t)0xfbaf, (q15_t)0x7fed, (q15_t)0xfba9, (q15_t)0x7fec, (q15_t)0xfba2, (q15_t)0x7fec, (q15_t)0xfb9c, - (q15_t)0x7fec, (q15_t)0xfb96, (q15_t)0x7fec, (q15_t)0xfb8f, (q15_t)0x7fec, (q15_t)0xfb89, (q15_t)0x7feb, (q15_t)0xfb83, - (q15_t)0x7feb, (q15_t)0xfb7d, (q15_t)0x7feb, (q15_t)0xfb76, (q15_t)0x7feb, (q15_t)0xfb70, (q15_t)0x7fea, (q15_t)0xfb6a, - (q15_t)0x7fea, (q15_t)0xfb64, (q15_t)0x7fea, (q15_t)0xfb5d, (q15_t)0x7fea, (q15_t)0xfb57, (q15_t)0x7fea, (q15_t)0xfb51, - (q15_t)0x7fe9, (q15_t)0xfb4a, (q15_t)0x7fe9, (q15_t)0xfb44, (q15_t)0x7fe9, (q15_t)0xfb3e, (q15_t)0x7fe9, (q15_t)0xfb38, - (q15_t)0x7fe8, (q15_t)0xfb31, (q15_t)0x7fe8, (q15_t)0xfb2b, (q15_t)0x7fe8, (q15_t)0xfb25, (q15_t)0x7fe8, (q15_t)0xfb1e, - (q15_t)0x7fe7, (q15_t)0xfb18, (q15_t)0x7fe7, (q15_t)0xfb12, (q15_t)0x7fe7, (q15_t)0xfb0c, (q15_t)0x7fe7, (q15_t)0xfb05, - (q15_t)0x7fe6, (q15_t)0xfaff, (q15_t)0x7fe6, (q15_t)0xfaf9, (q15_t)0x7fe6, (q15_t)0xfaf3, (q15_t)0x7fe6, (q15_t)0xfaec, - (q15_t)0x7fe5, (q15_t)0xfae6, (q15_t)0x7fe5, (q15_t)0xfae0, (q15_t)0x7fe5, (q15_t)0xfad9, (q15_t)0x7fe5, (q15_t)0xfad3, - (q15_t)0x7fe4, (q15_t)0xfacd, (q15_t)0x7fe4, (q15_t)0xfac7, (q15_t)0x7fe4, (q15_t)0xfac0, (q15_t)0x7fe4, (q15_t)0xfaba, - (q15_t)0x7fe3, (q15_t)0xfab4, (q15_t)0x7fe3, (q15_t)0xfaad, (q15_t)0x7fe3, (q15_t)0xfaa7, (q15_t)0x7fe3, (q15_t)0xfaa1, - (q15_t)0x7fe2, (q15_t)0xfa9b, (q15_t)0x7fe2, (q15_t)0xfa94, (q15_t)0x7fe2, (q15_t)0xfa8e, (q15_t)0x7fe2, (q15_t)0xfa88, - (q15_t)0x7fe1, (q15_t)0xfa81, (q15_t)0x7fe1, (q15_t)0xfa7b, (q15_t)0x7fe1, (q15_t)0xfa75, (q15_t)0x7fe0, (q15_t)0xfa6f, - (q15_t)0x7fe0, (q15_t)0xfa68, (q15_t)0x7fe0, (q15_t)0xfa62, (q15_t)0x7fe0, (q15_t)0xfa5c, (q15_t)0x7fdf, (q15_t)0xfa56, - (q15_t)0x7fdf, (q15_t)0xfa4f, (q15_t)0x7fdf, (q15_t)0xfa49, (q15_t)0x7fdf, (q15_t)0xfa43, (q15_t)0x7fde, (q15_t)0xfa3c, - (q15_t)0x7fde, (q15_t)0xfa36, (q15_t)0x7fde, (q15_t)0xfa30, (q15_t)0x7fdd, (q15_t)0xfa2a, (q15_t)0x7fdd, (q15_t)0xfa23, - (q15_t)0x7fdd, (q15_t)0xfa1d, (q15_t)0x7fdd, (q15_t)0xfa17, (q15_t)0x7fdc, (q15_t)0xfa11, (q15_t)0x7fdc, (q15_t)0xfa0a, - (q15_t)0x7fdc, (q15_t)0xfa04, (q15_t)0x7fdb, (q15_t)0xf9fe, (q15_t)0x7fdb, (q15_t)0xf9f7, (q15_t)0x7fdb, (q15_t)0xf9f1, - (q15_t)0x7fda, (q15_t)0xf9eb, (q15_t)0x7fda, (q15_t)0xf9e5, (q15_t)0x7fda, (q15_t)0xf9de, (q15_t)0x7fda, (q15_t)0xf9d8, - (q15_t)0x7fd9, (q15_t)0xf9d2, (q15_t)0x7fd9, (q15_t)0xf9cb, (q15_t)0x7fd9, (q15_t)0xf9c5, (q15_t)0x7fd8, (q15_t)0xf9bf, - (q15_t)0x7fd8, (q15_t)0xf9b9, (q15_t)0x7fd8, (q15_t)0xf9b2, (q15_t)0x7fd7, (q15_t)0xf9ac, (q15_t)0x7fd7, (q15_t)0xf9a6, - (q15_t)0x7fd7, (q15_t)0xf9a0, (q15_t)0x7fd6, (q15_t)0xf999, (q15_t)0x7fd6, (q15_t)0xf993, (q15_t)0x7fd6, (q15_t)0xf98d, - (q15_t)0x7fd6, (q15_t)0xf986, (q15_t)0x7fd5, (q15_t)0xf980, (q15_t)0x7fd5, (q15_t)0xf97a, (q15_t)0x7fd5, (q15_t)0xf974, - (q15_t)0x7fd4, (q15_t)0xf96d, (q15_t)0x7fd4, (q15_t)0xf967, (q15_t)0x7fd4, (q15_t)0xf961, (q15_t)0x7fd3, (q15_t)0xf95b, - (q15_t)0x7fd3, (q15_t)0xf954, (q15_t)0x7fd3, (q15_t)0xf94e, (q15_t)0x7fd2, (q15_t)0xf948, (q15_t)0x7fd2, (q15_t)0xf941, - (q15_t)0x7fd2, (q15_t)0xf93b, (q15_t)0x7fd1, (q15_t)0xf935, (q15_t)0x7fd1, (q15_t)0xf92f, (q15_t)0x7fd1, (q15_t)0xf928, - (q15_t)0x7fd0, (q15_t)0xf922, (q15_t)0x7fd0, (q15_t)0xf91c, (q15_t)0x7fd0, (q15_t)0xf916, (q15_t)0x7fcf, (q15_t)0xf90f, - (q15_t)0x7fcf, (q15_t)0xf909, (q15_t)0x7fcf, (q15_t)0xf903, (q15_t)0x7fce, (q15_t)0xf8fc, (q15_t)0x7fce, (q15_t)0xf8f6, - (q15_t)0x7fce, (q15_t)0xf8f0, (q15_t)0x7fcd, (q15_t)0xf8ea, (q15_t)0x7fcd, (q15_t)0xf8e3, (q15_t)0x7fcd, (q15_t)0xf8dd, - (q15_t)0x7fcc, (q15_t)0xf8d7, (q15_t)0x7fcc, (q15_t)0xf8d0, (q15_t)0x7fcb, (q15_t)0xf8ca, (q15_t)0x7fcb, (q15_t)0xf8c4, - (q15_t)0x7fcb, (q15_t)0xf8be, (q15_t)0x7fca, (q15_t)0xf8b7, (q15_t)0x7fca, (q15_t)0xf8b1, (q15_t)0x7fca, (q15_t)0xf8ab, - (q15_t)0x7fc9, (q15_t)0xf8a5, (q15_t)0x7fc9, (q15_t)0xf89e, (q15_t)0x7fc9, (q15_t)0xf898, (q15_t)0x7fc8, (q15_t)0xf892, - (q15_t)0x7fc8, (q15_t)0xf88b, (q15_t)0x7fc7, (q15_t)0xf885, (q15_t)0x7fc7, (q15_t)0xf87f, (q15_t)0x7fc7, (q15_t)0xf879, - (q15_t)0x7fc6, (q15_t)0xf872, (q15_t)0x7fc6, (q15_t)0xf86c, (q15_t)0x7fc6, (q15_t)0xf866, (q15_t)0x7fc5, (q15_t)0xf860, - (q15_t)0x7fc5, (q15_t)0xf859, (q15_t)0x7fc5, (q15_t)0xf853, (q15_t)0x7fc4, (q15_t)0xf84d, (q15_t)0x7fc4, (q15_t)0xf846, - (q15_t)0x7fc3, (q15_t)0xf840, (q15_t)0x7fc3, (q15_t)0xf83a, (q15_t)0x7fc3, (q15_t)0xf834, (q15_t)0x7fc2, (q15_t)0xf82d, - (q15_t)0x7fc2, (q15_t)0xf827, (q15_t)0x7fc1, (q15_t)0xf821, (q15_t)0x7fc1, (q15_t)0xf81b, (q15_t)0x7fc1, (q15_t)0xf814, - (q15_t)0x7fc0, (q15_t)0xf80e, (q15_t)0x7fc0, (q15_t)0xf808, (q15_t)0x7fc0, (q15_t)0xf802, (q15_t)0x7fbf, (q15_t)0xf7fb, - (q15_t)0x7fbf, (q15_t)0xf7f5, (q15_t)0x7fbe, (q15_t)0xf7ef, (q15_t)0x7fbe, (q15_t)0xf7e8, (q15_t)0x7fbe, (q15_t)0xf7e2, - (q15_t)0x7fbd, (q15_t)0xf7dc, (q15_t)0x7fbd, (q15_t)0xf7d6, (q15_t)0x7fbc, (q15_t)0xf7cf, (q15_t)0x7fbc, (q15_t)0xf7c9, - (q15_t)0x7fbc, (q15_t)0xf7c3, (q15_t)0x7fbb, (q15_t)0xf7bd, (q15_t)0x7fbb, (q15_t)0xf7b6, (q15_t)0x7fba, (q15_t)0xf7b0, - (q15_t)0x7fba, (q15_t)0xf7aa, (q15_t)0x7fb9, (q15_t)0xf7a3, (q15_t)0x7fb9, (q15_t)0xf79d, (q15_t)0x7fb9, (q15_t)0xf797, - (q15_t)0x7fb8, (q15_t)0xf791, (q15_t)0x7fb8, (q15_t)0xf78a, (q15_t)0x7fb7, (q15_t)0xf784, (q15_t)0x7fb7, (q15_t)0xf77e, - (q15_t)0x7fb7, (q15_t)0xf778, (q15_t)0x7fb6, (q15_t)0xf771, (q15_t)0x7fb6, (q15_t)0xf76b, (q15_t)0x7fb5, (q15_t)0xf765, - (q15_t)0x7fb5, (q15_t)0xf75e, (q15_t)0x7fb4, (q15_t)0xf758, (q15_t)0x7fb4, (q15_t)0xf752, (q15_t)0x7fb4, (q15_t)0xf74c, - (q15_t)0x7fb3, (q15_t)0xf745, (q15_t)0x7fb3, (q15_t)0xf73f, (q15_t)0x7fb2, (q15_t)0xf739, (q15_t)0x7fb2, (q15_t)0xf733, - (q15_t)0x7fb1, (q15_t)0xf72c, (q15_t)0x7fb1, (q15_t)0xf726, (q15_t)0x7fb1, (q15_t)0xf720, (q15_t)0x7fb0, (q15_t)0xf71a, - (q15_t)0x7fb0, (q15_t)0xf713, (q15_t)0x7faf, (q15_t)0xf70d, (q15_t)0x7faf, (q15_t)0xf707, (q15_t)0x7fae, (q15_t)0xf700, - (q15_t)0x7fae, (q15_t)0xf6fa, (q15_t)0x7fae, (q15_t)0xf6f4, (q15_t)0x7fad, (q15_t)0xf6ee, (q15_t)0x7fad, (q15_t)0xf6e7, - (q15_t)0x7fac, (q15_t)0xf6e1, (q15_t)0x7fac, (q15_t)0xf6db, (q15_t)0x7fab, (q15_t)0xf6d5, (q15_t)0x7fab, (q15_t)0xf6ce, - (q15_t)0x7faa, (q15_t)0xf6c8, (q15_t)0x7faa, (q15_t)0xf6c2, (q15_t)0x7fa9, (q15_t)0xf6bc, (q15_t)0x7fa9, (q15_t)0xf6b5, - (q15_t)0x7fa9, (q15_t)0xf6af, (q15_t)0x7fa8, (q15_t)0xf6a9, (q15_t)0x7fa8, (q15_t)0xf6a2, (q15_t)0x7fa7, (q15_t)0xf69c, - (q15_t)0x7fa7, (q15_t)0xf696, (q15_t)0x7fa6, (q15_t)0xf690, (q15_t)0x7fa6, (q15_t)0xf689, (q15_t)0x7fa5, (q15_t)0xf683, - (q15_t)0x7fa5, (q15_t)0xf67d, (q15_t)0x7fa4, (q15_t)0xf677, (q15_t)0x7fa4, (q15_t)0xf670, (q15_t)0x7fa3, (q15_t)0xf66a, - (q15_t)0x7fa3, (q15_t)0xf664, (q15_t)0x7fa3, (q15_t)0xf65e, (q15_t)0x7fa2, (q15_t)0xf657, (q15_t)0x7fa2, (q15_t)0xf651, - (q15_t)0x7fa1, (q15_t)0xf64b, (q15_t)0x7fa1, (q15_t)0xf644, (q15_t)0x7fa0, (q15_t)0xf63e, (q15_t)0x7fa0, (q15_t)0xf638, - (q15_t)0x7f9f, (q15_t)0xf632, (q15_t)0x7f9f, (q15_t)0xf62b, (q15_t)0x7f9e, (q15_t)0xf625, (q15_t)0x7f9e, (q15_t)0xf61f, - (q15_t)0x7f9d, (q15_t)0xf619, (q15_t)0x7f9d, (q15_t)0xf612, (q15_t)0x7f9c, (q15_t)0xf60c, (q15_t)0x7f9c, (q15_t)0xf606, - (q15_t)0x7f9b, (q15_t)0xf600, (q15_t)0x7f9b, (q15_t)0xf5f9, (q15_t)0x7f9a, (q15_t)0xf5f3, (q15_t)0x7f9a, (q15_t)0xf5ed, - (q15_t)0x7f99, (q15_t)0xf5e7, (q15_t)0x7f99, (q15_t)0xf5e0, (q15_t)0x7f98, (q15_t)0xf5da, (q15_t)0x7f98, (q15_t)0xf5d4, - (q15_t)0x7f97, (q15_t)0xf5cd, (q15_t)0x7f97, (q15_t)0xf5c7, (q15_t)0x7f96, (q15_t)0xf5c1, (q15_t)0x7f96, (q15_t)0xf5bb, - (q15_t)0x7f95, (q15_t)0xf5b4, (q15_t)0x7f95, (q15_t)0xf5ae, (q15_t)0x7f94, (q15_t)0xf5a8, (q15_t)0x7f94, (q15_t)0xf5a2, - (q15_t)0x7f93, (q15_t)0xf59b, (q15_t)0x7f93, (q15_t)0xf595, (q15_t)0x7f92, (q15_t)0xf58f, (q15_t)0x7f92, (q15_t)0xf589, - (q15_t)0x7f91, (q15_t)0xf582, (q15_t)0x7f91, (q15_t)0xf57c, (q15_t)0x7f90, (q15_t)0xf576, (q15_t)0x7f90, (q15_t)0xf570, - (q15_t)0x7f8f, (q15_t)0xf569, (q15_t)0x7f8f, (q15_t)0xf563, (q15_t)0x7f8e, (q15_t)0xf55d, (q15_t)0x7f8e, (q15_t)0xf556, - (q15_t)0x7f8d, (q15_t)0xf550, (q15_t)0x7f8d, (q15_t)0xf54a, (q15_t)0x7f8c, (q15_t)0xf544, (q15_t)0x7f8b, (q15_t)0xf53d, - (q15_t)0x7f8b, (q15_t)0xf537, (q15_t)0x7f8a, (q15_t)0xf531, (q15_t)0x7f8a, (q15_t)0xf52b, (q15_t)0x7f89, (q15_t)0xf524, - (q15_t)0x7f89, (q15_t)0xf51e, (q15_t)0x7f88, (q15_t)0xf518, (q15_t)0x7f88, (q15_t)0xf512, (q15_t)0x7f87, (q15_t)0xf50b, - (q15_t)0x7f87, (q15_t)0xf505, (q15_t)0x7f86, (q15_t)0xf4ff, (q15_t)0x7f86, (q15_t)0xf4f9, (q15_t)0x7f85, (q15_t)0xf4f2, - (q15_t)0x7f85, (q15_t)0xf4ec, (q15_t)0x7f84, (q15_t)0xf4e6, (q15_t)0x7f83, (q15_t)0xf4e0, (q15_t)0x7f83, (q15_t)0xf4d9, - (q15_t)0x7f82, (q15_t)0xf4d3, (q15_t)0x7f82, (q15_t)0xf4cd, (q15_t)0x7f81, (q15_t)0xf4c6, (q15_t)0x7f81, (q15_t)0xf4c0, - (q15_t)0x7f80, (q15_t)0xf4ba, (q15_t)0x7f80, (q15_t)0xf4b4, (q15_t)0x7f7f, (q15_t)0xf4ad, (q15_t)0x7f7e, (q15_t)0xf4a7, - (q15_t)0x7f7e, (q15_t)0xf4a1, (q15_t)0x7f7d, (q15_t)0xf49b, (q15_t)0x7f7d, (q15_t)0xf494, (q15_t)0x7f7c, (q15_t)0xf48e, - (q15_t)0x7f7c, (q15_t)0xf488, (q15_t)0x7f7b, (q15_t)0xf482, (q15_t)0x7f7b, (q15_t)0xf47b, (q15_t)0x7f7a, (q15_t)0xf475, - (q15_t)0x7f79, (q15_t)0xf46f, (q15_t)0x7f79, (q15_t)0xf469, (q15_t)0x7f78, (q15_t)0xf462, (q15_t)0x7f78, (q15_t)0xf45c, - (q15_t)0x7f77, (q15_t)0xf456, (q15_t)0x7f77, (q15_t)0xf450, (q15_t)0x7f76, (q15_t)0xf449, (q15_t)0x7f75, (q15_t)0xf443, - (q15_t)0x7f75, (q15_t)0xf43d, (q15_t)0x7f74, (q15_t)0xf437, (q15_t)0x7f74, (q15_t)0xf430, (q15_t)0x7f73, (q15_t)0xf42a, - (q15_t)0x7f72, (q15_t)0xf424, (q15_t)0x7f72, (q15_t)0xf41e, (q15_t)0x7f71, (q15_t)0xf417, (q15_t)0x7f71, (q15_t)0xf411, - (q15_t)0x7f70, (q15_t)0xf40b, (q15_t)0x7f70, (q15_t)0xf405, (q15_t)0x7f6f, (q15_t)0xf3fe, (q15_t)0x7f6e, (q15_t)0xf3f8, - (q15_t)0x7f6e, (q15_t)0xf3f2, (q15_t)0x7f6d, (q15_t)0xf3ec, (q15_t)0x7f6d, (q15_t)0xf3e5, (q15_t)0x7f6c, (q15_t)0xf3df, - (q15_t)0x7f6b, (q15_t)0xf3d9, (q15_t)0x7f6b, (q15_t)0xf3d2, (q15_t)0x7f6a, (q15_t)0xf3cc, (q15_t)0x7f6a, (q15_t)0xf3c6, - (q15_t)0x7f69, (q15_t)0xf3c0, (q15_t)0x7f68, (q15_t)0xf3b9, (q15_t)0x7f68, (q15_t)0xf3b3, (q15_t)0x7f67, (q15_t)0xf3ad, - (q15_t)0x7f67, (q15_t)0xf3a7, (q15_t)0x7f66, (q15_t)0xf3a0, (q15_t)0x7f65, (q15_t)0xf39a, (q15_t)0x7f65, (q15_t)0xf394, - (q15_t)0x7f64, (q15_t)0xf38e, (q15_t)0x7f64, (q15_t)0xf387, (q15_t)0x7f63, (q15_t)0xf381, (q15_t)0x7f62, (q15_t)0xf37b, - (q15_t)0x7f62, (q15_t)0xf375, (q15_t)0x7f61, (q15_t)0xf36e, (q15_t)0x7f60, (q15_t)0xf368, (q15_t)0x7f60, (q15_t)0xf362, - (q15_t)0x7f5f, (q15_t)0xf35c, (q15_t)0x7f5f, (q15_t)0xf355, (q15_t)0x7f5e, (q15_t)0xf34f, (q15_t)0x7f5d, (q15_t)0xf349, - (q15_t)0x7f5d, (q15_t)0xf343, (q15_t)0x7f5c, (q15_t)0xf33c, (q15_t)0x7f5b, (q15_t)0xf336, (q15_t)0x7f5b, (q15_t)0xf330, - (q15_t)0x7f5a, (q15_t)0xf32a, (q15_t)0x7f5a, (q15_t)0xf323, (q15_t)0x7f59, (q15_t)0xf31d, (q15_t)0x7f58, (q15_t)0xf317, - (q15_t)0x7f58, (q15_t)0xf311, (q15_t)0x7f57, (q15_t)0xf30a, (q15_t)0x7f56, (q15_t)0xf304, (q15_t)0x7f56, (q15_t)0xf2fe, - (q15_t)0x7f55, (q15_t)0xf2f8, (q15_t)0x7f55, (q15_t)0xf2f1, (q15_t)0x7f54, (q15_t)0xf2eb, (q15_t)0x7f53, (q15_t)0xf2e5, - (q15_t)0x7f53, (q15_t)0xf2df, (q15_t)0x7f52, (q15_t)0xf2d8, (q15_t)0x7f51, (q15_t)0xf2d2, (q15_t)0x7f51, (q15_t)0xf2cc, - (q15_t)0x7f50, (q15_t)0xf2c6, (q15_t)0x7f4f, (q15_t)0xf2bf, (q15_t)0x7f4f, (q15_t)0xf2b9, (q15_t)0x7f4e, (q15_t)0xf2b3, - (q15_t)0x7f4d, (q15_t)0xf2ad, (q15_t)0x7f4d, (q15_t)0xf2a6, (q15_t)0x7f4c, (q15_t)0xf2a0, (q15_t)0x7f4b, (q15_t)0xf29a, - (q15_t)0x7f4b, (q15_t)0xf294, (q15_t)0x7f4a, (q15_t)0xf28d, (q15_t)0x7f49, (q15_t)0xf287, (q15_t)0x7f49, (q15_t)0xf281, - (q15_t)0x7f48, (q15_t)0xf27b, (q15_t)0x7f47, (q15_t)0xf274, (q15_t)0x7f47, (q15_t)0xf26e, (q15_t)0x7f46, (q15_t)0xf268, - (q15_t)0x7f45, (q15_t)0xf262, (q15_t)0x7f45, (q15_t)0xf25b, (q15_t)0x7f44, (q15_t)0xf255, (q15_t)0x7f43, (q15_t)0xf24f, - (q15_t)0x7f43, (q15_t)0xf249, (q15_t)0x7f42, (q15_t)0xf242, (q15_t)0x7f41, (q15_t)0xf23c, (q15_t)0x7f41, (q15_t)0xf236, - (q15_t)0x7f40, (q15_t)0xf230, (q15_t)0x7f3f, (q15_t)0xf229, (q15_t)0x7f3f, (q15_t)0xf223, (q15_t)0x7f3e, (q15_t)0xf21d, - (q15_t)0x7f3d, (q15_t)0xf217, (q15_t)0x7f3d, (q15_t)0xf210, (q15_t)0x7f3c, (q15_t)0xf20a, (q15_t)0x7f3b, (q15_t)0xf204, - (q15_t)0x7f3b, (q15_t)0xf1fe, (q15_t)0x7f3a, (q15_t)0xf1f7, (q15_t)0x7f39, (q15_t)0xf1f1, (q15_t)0x7f39, (q15_t)0xf1eb, - (q15_t)0x7f38, (q15_t)0xf1e5, (q15_t)0x7f37, (q15_t)0xf1de, (q15_t)0x7f36, (q15_t)0xf1d8, (q15_t)0x7f36, (q15_t)0xf1d2, - (q15_t)0x7f35, (q15_t)0xf1cc, (q15_t)0x7f34, (q15_t)0xf1c6, (q15_t)0x7f34, (q15_t)0xf1bf, (q15_t)0x7f33, (q15_t)0xf1b9, - (q15_t)0x7f32, (q15_t)0xf1b3, (q15_t)0x7f32, (q15_t)0xf1ad, (q15_t)0x7f31, (q15_t)0xf1a6, (q15_t)0x7f30, (q15_t)0xf1a0, - (q15_t)0x7f2f, (q15_t)0xf19a, (q15_t)0x7f2f, (q15_t)0xf194, (q15_t)0x7f2e, (q15_t)0xf18d, (q15_t)0x7f2d, (q15_t)0xf187, - (q15_t)0x7f2d, (q15_t)0xf181, (q15_t)0x7f2c, (q15_t)0xf17b, (q15_t)0x7f2b, (q15_t)0xf174, (q15_t)0x7f2a, (q15_t)0xf16e, - (q15_t)0x7f2a, (q15_t)0xf168, (q15_t)0x7f29, (q15_t)0xf162, (q15_t)0x7f28, (q15_t)0xf15b, (q15_t)0x7f28, (q15_t)0xf155, - (q15_t)0x7f27, (q15_t)0xf14f, (q15_t)0x7f26, (q15_t)0xf149, (q15_t)0x7f25, (q15_t)0xf142, (q15_t)0x7f25, (q15_t)0xf13c, - (q15_t)0x7f24, (q15_t)0xf136, (q15_t)0x7f23, (q15_t)0xf130, (q15_t)0x7f23, (q15_t)0xf129, (q15_t)0x7f22, (q15_t)0xf123, - (q15_t)0x7f21, (q15_t)0xf11d, (q15_t)0x7f20, (q15_t)0xf117, (q15_t)0x7f20, (q15_t)0xf110, (q15_t)0x7f1f, (q15_t)0xf10a, - (q15_t)0x7f1e, (q15_t)0xf104, (q15_t)0x7f1d, (q15_t)0xf0fe, (q15_t)0x7f1d, (q15_t)0xf0f8, (q15_t)0x7f1c, (q15_t)0xf0f1, - (q15_t)0x7f1b, (q15_t)0xf0eb, (q15_t)0x7f1a, (q15_t)0xf0e5, (q15_t)0x7f1a, (q15_t)0xf0df, (q15_t)0x7f19, (q15_t)0xf0d8, - (q15_t)0x7f18, (q15_t)0xf0d2, (q15_t)0x7f17, (q15_t)0xf0cc, (q15_t)0x7f17, (q15_t)0xf0c6, (q15_t)0x7f16, (q15_t)0xf0bf, - (q15_t)0x7f15, (q15_t)0xf0b9, (q15_t)0x7f14, (q15_t)0xf0b3, (q15_t)0x7f14, (q15_t)0xf0ad, (q15_t)0x7f13, (q15_t)0xf0a6, - (q15_t)0x7f12, (q15_t)0xf0a0, (q15_t)0x7f11, (q15_t)0xf09a, (q15_t)0x7f11, (q15_t)0xf094, (q15_t)0x7f10, (q15_t)0xf08d, - (q15_t)0x7f0f, (q15_t)0xf087, (q15_t)0x7f0e, (q15_t)0xf081, (q15_t)0x7f0e, (q15_t)0xf07b, (q15_t)0x7f0d, (q15_t)0xf075, - (q15_t)0x7f0c, (q15_t)0xf06e, (q15_t)0x7f0b, (q15_t)0xf068, (q15_t)0x7f0b, (q15_t)0xf062, (q15_t)0x7f0a, (q15_t)0xf05c, - (q15_t)0x7f09, (q15_t)0xf055, (q15_t)0x7f08, (q15_t)0xf04f, (q15_t)0x7f08, (q15_t)0xf049, (q15_t)0x7f07, (q15_t)0xf043, - (q15_t)0x7f06, (q15_t)0xf03c, (q15_t)0x7f05, (q15_t)0xf036, (q15_t)0x7f04, (q15_t)0xf030, (q15_t)0x7f04, (q15_t)0xf02a, - (q15_t)0x7f03, (q15_t)0xf023, (q15_t)0x7f02, (q15_t)0xf01d, (q15_t)0x7f01, (q15_t)0xf017, (q15_t)0x7f01, (q15_t)0xf011, - (q15_t)0x7f00, (q15_t)0xf00b, (q15_t)0x7eff, (q15_t)0xf004, (q15_t)0x7efe, (q15_t)0xeffe, (q15_t)0x7efd, (q15_t)0xeff8, - (q15_t)0x7efd, (q15_t)0xeff2, (q15_t)0x7efc, (q15_t)0xefeb, (q15_t)0x7efb, (q15_t)0xefe5, (q15_t)0x7efa, (q15_t)0xefdf, - (q15_t)0x7ef9, (q15_t)0xefd9, (q15_t)0x7ef9, (q15_t)0xefd2, (q15_t)0x7ef8, (q15_t)0xefcc, (q15_t)0x7ef7, (q15_t)0xefc6, - (q15_t)0x7ef6, (q15_t)0xefc0, (q15_t)0x7ef5, (q15_t)0xefb9, (q15_t)0x7ef5, (q15_t)0xefb3, (q15_t)0x7ef4, (q15_t)0xefad, - (q15_t)0x7ef3, (q15_t)0xefa7, (q15_t)0x7ef2, (q15_t)0xefa1, (q15_t)0x7ef1, (q15_t)0xef9a, (q15_t)0x7ef1, (q15_t)0xef94, - (q15_t)0x7ef0, (q15_t)0xef8e, (q15_t)0x7eef, (q15_t)0xef88, (q15_t)0x7eee, (q15_t)0xef81, (q15_t)0x7eed, (q15_t)0xef7b, - (q15_t)0x7eed, (q15_t)0xef75, (q15_t)0x7eec, (q15_t)0xef6f, (q15_t)0x7eeb, (q15_t)0xef68, (q15_t)0x7eea, (q15_t)0xef62, - (q15_t)0x7ee9, (q15_t)0xef5c, (q15_t)0x7ee9, (q15_t)0xef56, (q15_t)0x7ee8, (q15_t)0xef50, (q15_t)0x7ee7, (q15_t)0xef49, - (q15_t)0x7ee6, (q15_t)0xef43, (q15_t)0x7ee5, (q15_t)0xef3d, (q15_t)0x7ee4, (q15_t)0xef37, (q15_t)0x7ee4, (q15_t)0xef30, - (q15_t)0x7ee3, (q15_t)0xef2a, (q15_t)0x7ee2, (q15_t)0xef24, (q15_t)0x7ee1, (q15_t)0xef1e, (q15_t)0x7ee0, (q15_t)0xef18, - (q15_t)0x7edf, (q15_t)0xef11, (q15_t)0x7edf, (q15_t)0xef0b, (q15_t)0x7ede, (q15_t)0xef05, (q15_t)0x7edd, (q15_t)0xeeff, - (q15_t)0x7edc, (q15_t)0xeef8, (q15_t)0x7edb, (q15_t)0xeef2, (q15_t)0x7eda, (q15_t)0xeeec, (q15_t)0x7eda, (q15_t)0xeee6, - (q15_t)0x7ed9, (q15_t)0xeedf, (q15_t)0x7ed8, (q15_t)0xeed9, (q15_t)0x7ed7, (q15_t)0xeed3, (q15_t)0x7ed6, (q15_t)0xeecd, - (q15_t)0x7ed5, (q15_t)0xeec7, (q15_t)0x7ed5, (q15_t)0xeec0, (q15_t)0x7ed4, (q15_t)0xeeba, (q15_t)0x7ed3, (q15_t)0xeeb4, - (q15_t)0x7ed2, (q15_t)0xeeae, (q15_t)0x7ed1, (q15_t)0xeea7, (q15_t)0x7ed0, (q15_t)0xeea1, (q15_t)0x7ecf, (q15_t)0xee9b, - (q15_t)0x7ecf, (q15_t)0xee95, (q15_t)0x7ece, (q15_t)0xee8f, (q15_t)0x7ecd, (q15_t)0xee88, (q15_t)0x7ecc, (q15_t)0xee82, - (q15_t)0x7ecb, (q15_t)0xee7c, (q15_t)0x7eca, (q15_t)0xee76, (q15_t)0x7ec9, (q15_t)0xee6f, (q15_t)0x7ec9, (q15_t)0xee69, - (q15_t)0x7ec8, (q15_t)0xee63, (q15_t)0x7ec7, (q15_t)0xee5d, (q15_t)0x7ec6, (q15_t)0xee57, (q15_t)0x7ec5, (q15_t)0xee50, - (q15_t)0x7ec4, (q15_t)0xee4a, (q15_t)0x7ec3, (q15_t)0xee44, (q15_t)0x7ec3, (q15_t)0xee3e, (q15_t)0x7ec2, (q15_t)0xee37, - (q15_t)0x7ec1, (q15_t)0xee31, (q15_t)0x7ec0, (q15_t)0xee2b, (q15_t)0x7ebf, (q15_t)0xee25, (q15_t)0x7ebe, (q15_t)0xee1f, - (q15_t)0x7ebd, (q15_t)0xee18, (q15_t)0x7ebc, (q15_t)0xee12, (q15_t)0x7ebb, (q15_t)0xee0c, (q15_t)0x7ebb, (q15_t)0xee06, - (q15_t)0x7eba, (q15_t)0xedff, (q15_t)0x7eb9, (q15_t)0xedf9, (q15_t)0x7eb8, (q15_t)0xedf3, (q15_t)0x7eb7, (q15_t)0xeded, - (q15_t)0x7eb6, (q15_t)0xede7, (q15_t)0x7eb5, (q15_t)0xede0, (q15_t)0x7eb4, (q15_t)0xedda, (q15_t)0x7eb4, (q15_t)0xedd4, - (q15_t)0x7eb3, (q15_t)0xedce, (q15_t)0x7eb2, (q15_t)0xedc7, (q15_t)0x7eb1, (q15_t)0xedc1, (q15_t)0x7eb0, (q15_t)0xedbb, - (q15_t)0x7eaf, (q15_t)0xedb5, (q15_t)0x7eae, (q15_t)0xedaf, (q15_t)0x7ead, (q15_t)0xeda8, (q15_t)0x7eac, (q15_t)0xeda2, - (q15_t)0x7eab, (q15_t)0xed9c, (q15_t)0x7eab, (q15_t)0xed96, (q15_t)0x7eaa, (q15_t)0xed8f, (q15_t)0x7ea9, (q15_t)0xed89, - (q15_t)0x7ea8, (q15_t)0xed83, (q15_t)0x7ea7, (q15_t)0xed7d, (q15_t)0x7ea6, (q15_t)0xed77, (q15_t)0x7ea5, (q15_t)0xed70, - (q15_t)0x7ea4, (q15_t)0xed6a, (q15_t)0x7ea3, (q15_t)0xed64, (q15_t)0x7ea2, (q15_t)0xed5e, (q15_t)0x7ea1, (q15_t)0xed58, - (q15_t)0x7ea1, (q15_t)0xed51, (q15_t)0x7ea0, (q15_t)0xed4b, (q15_t)0x7e9f, (q15_t)0xed45, (q15_t)0x7e9e, (q15_t)0xed3f, - (q15_t)0x7e9d, (q15_t)0xed38, (q15_t)0x7e9c, (q15_t)0xed32, (q15_t)0x7e9b, (q15_t)0xed2c, (q15_t)0x7e9a, (q15_t)0xed26, - (q15_t)0x7e99, (q15_t)0xed20, (q15_t)0x7e98, (q15_t)0xed19, (q15_t)0x7e97, (q15_t)0xed13, (q15_t)0x7e96, (q15_t)0xed0d, - (q15_t)0x7e95, (q15_t)0xed07, (q15_t)0x7e94, (q15_t)0xed01, (q15_t)0x7e94, (q15_t)0xecfa, (q15_t)0x7e93, (q15_t)0xecf4, - (q15_t)0x7e92, (q15_t)0xecee, (q15_t)0x7e91, (q15_t)0xece8, (q15_t)0x7e90, (q15_t)0xece1, (q15_t)0x7e8f, (q15_t)0xecdb, - (q15_t)0x7e8e, (q15_t)0xecd5, (q15_t)0x7e8d, (q15_t)0xeccf, (q15_t)0x7e8c, (q15_t)0xecc9, (q15_t)0x7e8b, (q15_t)0xecc2, - (q15_t)0x7e8a, (q15_t)0xecbc, (q15_t)0x7e89, (q15_t)0xecb6, (q15_t)0x7e88, (q15_t)0xecb0, (q15_t)0x7e87, (q15_t)0xecaa, - (q15_t)0x7e86, (q15_t)0xeca3, (q15_t)0x7e85, (q15_t)0xec9d, (q15_t)0x7e84, (q15_t)0xec97, (q15_t)0x7e84, (q15_t)0xec91, - (q15_t)0x7e83, (q15_t)0xec8a, (q15_t)0x7e82, (q15_t)0xec84, (q15_t)0x7e81, (q15_t)0xec7e, (q15_t)0x7e80, (q15_t)0xec78, - (q15_t)0x7e7f, (q15_t)0xec72, (q15_t)0x7e7e, (q15_t)0xec6b, (q15_t)0x7e7d, (q15_t)0xec65, (q15_t)0x7e7c, (q15_t)0xec5f, - (q15_t)0x7e7b, (q15_t)0xec59, (q15_t)0x7e7a, (q15_t)0xec53, (q15_t)0x7e79, (q15_t)0xec4c, (q15_t)0x7e78, (q15_t)0xec46, - (q15_t)0x7e77, (q15_t)0xec40, (q15_t)0x7e76, (q15_t)0xec3a, (q15_t)0x7e75, (q15_t)0xec34, (q15_t)0x7e74, (q15_t)0xec2d, - (q15_t)0x7e73, (q15_t)0xec27, (q15_t)0x7e72, (q15_t)0xec21, (q15_t)0x7e71, (q15_t)0xec1b, (q15_t)0x7e70, (q15_t)0xec15, - (q15_t)0x7e6f, (q15_t)0xec0e, (q15_t)0x7e6e, (q15_t)0xec08, (q15_t)0x7e6d, (q15_t)0xec02, (q15_t)0x7e6c, (q15_t)0xebfc, - (q15_t)0x7e6b, (q15_t)0xebf5, (q15_t)0x7e6a, (q15_t)0xebef, (q15_t)0x7e69, (q15_t)0xebe9, (q15_t)0x7e68, (q15_t)0xebe3, - (q15_t)0x7e67, (q15_t)0xebdd, (q15_t)0x7e66, (q15_t)0xebd6, (q15_t)0x7e65, (q15_t)0xebd0, (q15_t)0x7e64, (q15_t)0xebca, - (q15_t)0x7e63, (q15_t)0xebc4, (q15_t)0x7e62, (q15_t)0xebbe, (q15_t)0x7e61, (q15_t)0xebb7, (q15_t)0x7e60, (q15_t)0xebb1, - (q15_t)0x7e5f, (q15_t)0xebab, (q15_t)0x7e5e, (q15_t)0xeba5, (q15_t)0x7e5d, (q15_t)0xeb9f, (q15_t)0x7e5c, (q15_t)0xeb98, - (q15_t)0x7e5b, (q15_t)0xeb92, (q15_t)0x7e5a, (q15_t)0xeb8c, (q15_t)0x7e59, (q15_t)0xeb86, (q15_t)0x7e58, (q15_t)0xeb80, - (q15_t)0x7e57, (q15_t)0xeb79, (q15_t)0x7e56, (q15_t)0xeb73, (q15_t)0x7e55, (q15_t)0xeb6d, (q15_t)0x7e54, (q15_t)0xeb67, - (q15_t)0x7e53, (q15_t)0xeb61, (q15_t)0x7e52, (q15_t)0xeb5a, (q15_t)0x7e51, (q15_t)0xeb54, (q15_t)0x7e50, (q15_t)0xeb4e, - (q15_t)0x7e4f, (q15_t)0xeb48, (q15_t)0x7e4e, (q15_t)0xeb42, (q15_t)0x7e4d, (q15_t)0xeb3b, (q15_t)0x7e4c, (q15_t)0xeb35, - (q15_t)0x7e4b, (q15_t)0xeb2f, (q15_t)0x7e4a, (q15_t)0xeb29, (q15_t)0x7e49, (q15_t)0xeb23, (q15_t)0x7e48, (q15_t)0xeb1c, - (q15_t)0x7e47, (q15_t)0xeb16, (q15_t)0x7e46, (q15_t)0xeb10, (q15_t)0x7e45, (q15_t)0xeb0a, (q15_t)0x7e44, (q15_t)0xeb04, - (q15_t)0x7e43, (q15_t)0xeafd, (q15_t)0x7e42, (q15_t)0xeaf7, (q15_t)0x7e41, (q15_t)0xeaf1, (q15_t)0x7e40, (q15_t)0xeaeb, - (q15_t)0x7e3f, (q15_t)0xeae5, (q15_t)0x7e3e, (q15_t)0xeade, (q15_t)0x7e3d, (q15_t)0xead8, (q15_t)0x7e3c, (q15_t)0xead2, - (q15_t)0x7e3b, (q15_t)0xeacc, (q15_t)0x7e3a, (q15_t)0xeac6, (q15_t)0x7e39, (q15_t)0xeabf, (q15_t)0x7e38, (q15_t)0xeab9, - (q15_t)0x7e37, (q15_t)0xeab3, (q15_t)0x7e35, (q15_t)0xeaad, (q15_t)0x7e34, (q15_t)0xeaa7, (q15_t)0x7e33, (q15_t)0xeaa0, - (q15_t)0x7e32, (q15_t)0xea9a, (q15_t)0x7e31, (q15_t)0xea94, (q15_t)0x7e30, (q15_t)0xea8e, (q15_t)0x7e2f, (q15_t)0xea88, - (q15_t)0x7e2e, (q15_t)0xea81, (q15_t)0x7e2d, (q15_t)0xea7b, (q15_t)0x7e2c, (q15_t)0xea75, (q15_t)0x7e2b, (q15_t)0xea6f, - (q15_t)0x7e2a, (q15_t)0xea69, (q15_t)0x7e29, (q15_t)0xea63, (q15_t)0x7e28, (q15_t)0xea5c, (q15_t)0x7e27, (q15_t)0xea56, - (q15_t)0x7e26, (q15_t)0xea50, (q15_t)0x7e25, (q15_t)0xea4a, (q15_t)0x7e24, (q15_t)0xea44, (q15_t)0x7e22, (q15_t)0xea3d, - (q15_t)0x7e21, (q15_t)0xea37, (q15_t)0x7e20, (q15_t)0xea31, (q15_t)0x7e1f, (q15_t)0xea2b, (q15_t)0x7e1e, (q15_t)0xea25, - (q15_t)0x7e1d, (q15_t)0xea1e, (q15_t)0x7e1c, (q15_t)0xea18, (q15_t)0x7e1b, (q15_t)0xea12, (q15_t)0x7e1a, (q15_t)0xea0c, - (q15_t)0x7e19, (q15_t)0xea06, (q15_t)0x7e18, (q15_t)0xe9ff, (q15_t)0x7e17, (q15_t)0xe9f9, (q15_t)0x7e16, (q15_t)0xe9f3, - (q15_t)0x7e14, (q15_t)0xe9ed, (q15_t)0x7e13, (q15_t)0xe9e7, (q15_t)0x7e12, (q15_t)0xe9e1, (q15_t)0x7e11, (q15_t)0xe9da, - (q15_t)0x7e10, (q15_t)0xe9d4, (q15_t)0x7e0f, (q15_t)0xe9ce, (q15_t)0x7e0e, (q15_t)0xe9c8, (q15_t)0x7e0d, (q15_t)0xe9c2, - (q15_t)0x7e0c, (q15_t)0xe9bb, (q15_t)0x7e0b, (q15_t)0xe9b5, (q15_t)0x7e0a, (q15_t)0xe9af, (q15_t)0x7e08, (q15_t)0xe9a9, - (q15_t)0x7e07, (q15_t)0xe9a3, (q15_t)0x7e06, (q15_t)0xe99c, (q15_t)0x7e05, (q15_t)0xe996, (q15_t)0x7e04, (q15_t)0xe990, - (q15_t)0x7e03, (q15_t)0xe98a, (q15_t)0x7e02, (q15_t)0xe984, (q15_t)0x7e01, (q15_t)0xe97e, (q15_t)0x7e00, (q15_t)0xe977, - (q15_t)0x7dff, (q15_t)0xe971, (q15_t)0x7dfd, (q15_t)0xe96b, (q15_t)0x7dfc, (q15_t)0xe965, (q15_t)0x7dfb, (q15_t)0xe95f, - (q15_t)0x7dfa, (q15_t)0xe958, (q15_t)0x7df9, (q15_t)0xe952, (q15_t)0x7df8, (q15_t)0xe94c, (q15_t)0x7df7, (q15_t)0xe946, - (q15_t)0x7df6, (q15_t)0xe940, (q15_t)0x7df5, (q15_t)0xe93a, (q15_t)0x7df3, (q15_t)0xe933, (q15_t)0x7df2, (q15_t)0xe92d, - (q15_t)0x7df1, (q15_t)0xe927, (q15_t)0x7df0, (q15_t)0xe921, (q15_t)0x7def, (q15_t)0xe91b, (q15_t)0x7dee, (q15_t)0xe914, - (q15_t)0x7ded, (q15_t)0xe90e, (q15_t)0x7dec, (q15_t)0xe908, (q15_t)0x7dea, (q15_t)0xe902, (q15_t)0x7de9, (q15_t)0xe8fc, - (q15_t)0x7de8, (q15_t)0xe8f6, (q15_t)0x7de7, (q15_t)0xe8ef, (q15_t)0x7de6, (q15_t)0xe8e9, (q15_t)0x7de5, (q15_t)0xe8e3, - (q15_t)0x7de4, (q15_t)0xe8dd, (q15_t)0x7de2, (q15_t)0xe8d7, (q15_t)0x7de1, (q15_t)0xe8d0, (q15_t)0x7de0, (q15_t)0xe8ca, - (q15_t)0x7ddf, (q15_t)0xe8c4, (q15_t)0x7dde, (q15_t)0xe8be, (q15_t)0x7ddd, (q15_t)0xe8b8, (q15_t)0x7ddc, (q15_t)0xe8b2, - (q15_t)0x7dda, (q15_t)0xe8ab, (q15_t)0x7dd9, (q15_t)0xe8a5, (q15_t)0x7dd8, (q15_t)0xe89f, (q15_t)0x7dd7, (q15_t)0xe899, - (q15_t)0x7dd6, (q15_t)0xe893, (q15_t)0x7dd5, (q15_t)0xe88c, (q15_t)0x7dd4, (q15_t)0xe886, (q15_t)0x7dd2, (q15_t)0xe880, - (q15_t)0x7dd1, (q15_t)0xe87a, (q15_t)0x7dd0, (q15_t)0xe874, (q15_t)0x7dcf, (q15_t)0xe86e, (q15_t)0x7dce, (q15_t)0xe867, - (q15_t)0x7dcd, (q15_t)0xe861, (q15_t)0x7dcc, (q15_t)0xe85b, (q15_t)0x7dca, (q15_t)0xe855, (q15_t)0x7dc9, (q15_t)0xe84f, - (q15_t)0x7dc8, (q15_t)0xe849, (q15_t)0x7dc7, (q15_t)0xe842, (q15_t)0x7dc6, (q15_t)0xe83c, (q15_t)0x7dc5, (q15_t)0xe836, - (q15_t)0x7dc3, (q15_t)0xe830, (q15_t)0x7dc2, (q15_t)0xe82a, (q15_t)0x7dc1, (q15_t)0xe823, (q15_t)0x7dc0, (q15_t)0xe81d, - (q15_t)0x7dbf, (q15_t)0xe817, (q15_t)0x7dbd, (q15_t)0xe811, (q15_t)0x7dbc, (q15_t)0xe80b, (q15_t)0x7dbb, (q15_t)0xe805, - (q15_t)0x7dba, (q15_t)0xe7fe, (q15_t)0x7db9, (q15_t)0xe7f8, (q15_t)0x7db8, (q15_t)0xe7f2, (q15_t)0x7db6, (q15_t)0xe7ec, - (q15_t)0x7db5, (q15_t)0xe7e6, (q15_t)0x7db4, (q15_t)0xe7e0, (q15_t)0x7db3, (q15_t)0xe7d9, (q15_t)0x7db2, (q15_t)0xe7d3, - (q15_t)0x7db0, (q15_t)0xe7cd, (q15_t)0x7daf, (q15_t)0xe7c7, (q15_t)0x7dae, (q15_t)0xe7c1, (q15_t)0x7dad, (q15_t)0xe7bb, - (q15_t)0x7dac, (q15_t)0xe7b4, (q15_t)0x7dab, (q15_t)0xe7ae, (q15_t)0x7da9, (q15_t)0xe7a8, (q15_t)0x7da8, (q15_t)0xe7a2, - (q15_t)0x7da7, (q15_t)0xe79c, (q15_t)0x7da6, (q15_t)0xe796, (q15_t)0x7da5, (q15_t)0xe78f, (q15_t)0x7da3, (q15_t)0xe789, - (q15_t)0x7da2, (q15_t)0xe783, (q15_t)0x7da1, (q15_t)0xe77d, (q15_t)0x7da0, (q15_t)0xe777, (q15_t)0x7d9f, (q15_t)0xe771, - (q15_t)0x7d9d, (q15_t)0xe76a, (q15_t)0x7d9c, (q15_t)0xe764, (q15_t)0x7d9b, (q15_t)0xe75e, (q15_t)0x7d9a, (q15_t)0xe758, - (q15_t)0x7d98, (q15_t)0xe752, (q15_t)0x7d97, (q15_t)0xe74c, (q15_t)0x7d96, (q15_t)0xe745, (q15_t)0x7d95, (q15_t)0xe73f, - (q15_t)0x7d94, (q15_t)0xe739, (q15_t)0x7d92, (q15_t)0xe733, (q15_t)0x7d91, (q15_t)0xe72d, (q15_t)0x7d90, (q15_t)0xe727, - (q15_t)0x7d8f, (q15_t)0xe720, (q15_t)0x7d8e, (q15_t)0xe71a, (q15_t)0x7d8c, (q15_t)0xe714, (q15_t)0x7d8b, (q15_t)0xe70e, - (q15_t)0x7d8a, (q15_t)0xe708, (q15_t)0x7d89, (q15_t)0xe702, (q15_t)0x7d87, (q15_t)0xe6fb, (q15_t)0x7d86, (q15_t)0xe6f5, - (q15_t)0x7d85, (q15_t)0xe6ef, (q15_t)0x7d84, (q15_t)0xe6e9, (q15_t)0x7d82, (q15_t)0xe6e3, (q15_t)0x7d81, (q15_t)0xe6dd, - (q15_t)0x7d80, (q15_t)0xe6d6, (q15_t)0x7d7f, (q15_t)0xe6d0, (q15_t)0x7d7e, (q15_t)0xe6ca, (q15_t)0x7d7c, (q15_t)0xe6c4, - (q15_t)0x7d7b, (q15_t)0xe6be, (q15_t)0x7d7a, (q15_t)0xe6b8, (q15_t)0x7d79, (q15_t)0xe6b2, (q15_t)0x7d77, (q15_t)0xe6ab, - (q15_t)0x7d76, (q15_t)0xe6a5, (q15_t)0x7d75, (q15_t)0xe69f, (q15_t)0x7d74, (q15_t)0xe699, (q15_t)0x7d72, (q15_t)0xe693, - (q15_t)0x7d71, (q15_t)0xe68d, (q15_t)0x7d70, (q15_t)0xe686, (q15_t)0x7d6f, (q15_t)0xe680, (q15_t)0x7d6d, (q15_t)0xe67a, - (q15_t)0x7d6c, (q15_t)0xe674, (q15_t)0x7d6b, (q15_t)0xe66e, (q15_t)0x7d6a, (q15_t)0xe668, (q15_t)0x7d68, (q15_t)0xe661, - (q15_t)0x7d67, (q15_t)0xe65b, (q15_t)0x7d66, (q15_t)0xe655, (q15_t)0x7d65, (q15_t)0xe64f, (q15_t)0x7d63, (q15_t)0xe649, - (q15_t)0x7d62, (q15_t)0xe643, (q15_t)0x7d61, (q15_t)0xe63d, (q15_t)0x7d60, (q15_t)0xe636, (q15_t)0x7d5e, (q15_t)0xe630, - (q15_t)0x7d5d, (q15_t)0xe62a, (q15_t)0x7d5c, (q15_t)0xe624, (q15_t)0x7d5a, (q15_t)0xe61e, (q15_t)0x7d59, (q15_t)0xe618, - (q15_t)0x7d58, (q15_t)0xe611, (q15_t)0x7d57, (q15_t)0xe60b, (q15_t)0x7d55, (q15_t)0xe605, (q15_t)0x7d54, (q15_t)0xe5ff, - (q15_t)0x7d53, (q15_t)0xe5f9, (q15_t)0x7d52, (q15_t)0xe5f3, (q15_t)0x7d50, (q15_t)0xe5ed, (q15_t)0x7d4f, (q15_t)0xe5e6, - (q15_t)0x7d4e, (q15_t)0xe5e0, (q15_t)0x7d4c, (q15_t)0xe5da, (q15_t)0x7d4b, (q15_t)0xe5d4, (q15_t)0x7d4a, (q15_t)0xe5ce, - (q15_t)0x7d49, (q15_t)0xe5c8, (q15_t)0x7d47, (q15_t)0xe5c2, (q15_t)0x7d46, (q15_t)0xe5bb, (q15_t)0x7d45, (q15_t)0xe5b5, - (q15_t)0x7d43, (q15_t)0xe5af, (q15_t)0x7d42, (q15_t)0xe5a9, (q15_t)0x7d41, (q15_t)0xe5a3, (q15_t)0x7d3f, (q15_t)0xe59d, - (q15_t)0x7d3e, (q15_t)0xe596, (q15_t)0x7d3d, (q15_t)0xe590, (q15_t)0x7d3c, (q15_t)0xe58a, (q15_t)0x7d3a, (q15_t)0xe584, - (q15_t)0x7d39, (q15_t)0xe57e, (q15_t)0x7d38, (q15_t)0xe578, (q15_t)0x7d36, (q15_t)0xe572, (q15_t)0x7d35, (q15_t)0xe56b, - (q15_t)0x7d34, (q15_t)0xe565, (q15_t)0x7d32, (q15_t)0xe55f, (q15_t)0x7d31, (q15_t)0xe559, (q15_t)0x7d30, (q15_t)0xe553, - (q15_t)0x7d2f, (q15_t)0xe54d, (q15_t)0x7d2d, (q15_t)0xe547, (q15_t)0x7d2c, (q15_t)0xe540, (q15_t)0x7d2b, (q15_t)0xe53a, - (q15_t)0x7d29, (q15_t)0xe534, (q15_t)0x7d28, (q15_t)0xe52e, (q15_t)0x7d27, (q15_t)0xe528, (q15_t)0x7d25, (q15_t)0xe522, - (q15_t)0x7d24, (q15_t)0xe51c, (q15_t)0x7d23, (q15_t)0xe515, (q15_t)0x7d21, (q15_t)0xe50f, (q15_t)0x7d20, (q15_t)0xe509, - (q15_t)0x7d1f, (q15_t)0xe503, (q15_t)0x7d1d, (q15_t)0xe4fd, (q15_t)0x7d1c, (q15_t)0xe4f7, (q15_t)0x7d1b, (q15_t)0xe4f1, - (q15_t)0x7d19, (q15_t)0xe4ea, (q15_t)0x7d18, (q15_t)0xe4e4, (q15_t)0x7d17, (q15_t)0xe4de, (q15_t)0x7d15, (q15_t)0xe4d8, - (q15_t)0x7d14, (q15_t)0xe4d2, (q15_t)0x7d13, (q15_t)0xe4cc, (q15_t)0x7d11, (q15_t)0xe4c6, (q15_t)0x7d10, (q15_t)0xe4bf, - (q15_t)0x7d0f, (q15_t)0xe4b9, (q15_t)0x7d0d, (q15_t)0xe4b3, (q15_t)0x7d0c, (q15_t)0xe4ad, (q15_t)0x7d0b, (q15_t)0xe4a7, - (q15_t)0x7d09, (q15_t)0xe4a1, (q15_t)0x7d08, (q15_t)0xe49b, (q15_t)0x7d07, (q15_t)0xe494, (q15_t)0x7d05, (q15_t)0xe48e, - (q15_t)0x7d04, (q15_t)0xe488, (q15_t)0x7d03, (q15_t)0xe482, (q15_t)0x7d01, (q15_t)0xe47c, (q15_t)0x7d00, (q15_t)0xe476, - (q15_t)0x7cff, (q15_t)0xe470, (q15_t)0x7cfd, (q15_t)0xe46a, (q15_t)0x7cfc, (q15_t)0xe463, (q15_t)0x7cfb, (q15_t)0xe45d, - (q15_t)0x7cf9, (q15_t)0xe457, (q15_t)0x7cf8, (q15_t)0xe451, (q15_t)0x7cf6, (q15_t)0xe44b, (q15_t)0x7cf5, (q15_t)0xe445, - (q15_t)0x7cf4, (q15_t)0xe43f, (q15_t)0x7cf2, (q15_t)0xe438, (q15_t)0x7cf1, (q15_t)0xe432, (q15_t)0x7cf0, (q15_t)0xe42c, - (q15_t)0x7cee, (q15_t)0xe426, (q15_t)0x7ced, (q15_t)0xe420, (q15_t)0x7cec, (q15_t)0xe41a, (q15_t)0x7cea, (q15_t)0xe414, - (q15_t)0x7ce9, (q15_t)0xe40e, (q15_t)0x7ce7, (q15_t)0xe407, (q15_t)0x7ce6, (q15_t)0xe401, (q15_t)0x7ce5, (q15_t)0xe3fb, - (q15_t)0x7ce3, (q15_t)0xe3f5, (q15_t)0x7ce2, (q15_t)0xe3ef, (q15_t)0x7ce1, (q15_t)0xe3e9, (q15_t)0x7cdf, (q15_t)0xe3e3, - (q15_t)0x7cde, (q15_t)0xe3dc, (q15_t)0x7cdc, (q15_t)0xe3d6, (q15_t)0x7cdb, (q15_t)0xe3d0, (q15_t)0x7cda, (q15_t)0xe3ca, - (q15_t)0x7cd8, (q15_t)0xe3c4, (q15_t)0x7cd7, (q15_t)0xe3be, (q15_t)0x7cd5, (q15_t)0xe3b8, (q15_t)0x7cd4, (q15_t)0xe3b2, - (q15_t)0x7cd3, (q15_t)0xe3ab, (q15_t)0x7cd1, (q15_t)0xe3a5, (q15_t)0x7cd0, (q15_t)0xe39f, (q15_t)0x7ccf, (q15_t)0xe399, - (q15_t)0x7ccd, (q15_t)0xe393, (q15_t)0x7ccc, (q15_t)0xe38d, (q15_t)0x7cca, (q15_t)0xe387, (q15_t)0x7cc9, (q15_t)0xe381, - (q15_t)0x7cc8, (q15_t)0xe37a, (q15_t)0x7cc6, (q15_t)0xe374, (q15_t)0x7cc5, (q15_t)0xe36e, (q15_t)0x7cc3, (q15_t)0xe368, - (q15_t)0x7cc2, (q15_t)0xe362, (q15_t)0x7cc1, (q15_t)0xe35c, (q15_t)0x7cbf, (q15_t)0xe356, (q15_t)0x7cbe, (q15_t)0xe350, - (q15_t)0x7cbc, (q15_t)0xe349, (q15_t)0x7cbb, (q15_t)0xe343, (q15_t)0x7cb9, (q15_t)0xe33d, (q15_t)0x7cb8, (q15_t)0xe337, - (q15_t)0x7cb7, (q15_t)0xe331, (q15_t)0x7cb5, (q15_t)0xe32b, (q15_t)0x7cb4, (q15_t)0xe325, (q15_t)0x7cb2, (q15_t)0xe31f, - (q15_t)0x7cb1, (q15_t)0xe318, (q15_t)0x7cb0, (q15_t)0xe312, (q15_t)0x7cae, (q15_t)0xe30c, (q15_t)0x7cad, (q15_t)0xe306, - (q15_t)0x7cab, (q15_t)0xe300, (q15_t)0x7caa, (q15_t)0xe2fa, (q15_t)0x7ca8, (q15_t)0xe2f4, (q15_t)0x7ca7, (q15_t)0xe2ee, - (q15_t)0x7ca6, (q15_t)0xe2e8, (q15_t)0x7ca4, (q15_t)0xe2e1, (q15_t)0x7ca3, (q15_t)0xe2db, (q15_t)0x7ca1, (q15_t)0xe2d5, - (q15_t)0x7ca0, (q15_t)0xe2cf, (q15_t)0x7c9e, (q15_t)0xe2c9, (q15_t)0x7c9d, (q15_t)0xe2c3, (q15_t)0x7c9c, (q15_t)0xe2bd, - (q15_t)0x7c9a, (q15_t)0xe2b7, (q15_t)0x7c99, (q15_t)0xe2b0, (q15_t)0x7c97, (q15_t)0xe2aa, (q15_t)0x7c96, (q15_t)0xe2a4, - (q15_t)0x7c94, (q15_t)0xe29e, (q15_t)0x7c93, (q15_t)0xe298, (q15_t)0x7c91, (q15_t)0xe292, (q15_t)0x7c90, (q15_t)0xe28c, - (q15_t)0x7c8f, (q15_t)0xe286, (q15_t)0x7c8d, (q15_t)0xe280, (q15_t)0x7c8c, (q15_t)0xe279, (q15_t)0x7c8a, (q15_t)0xe273, - (q15_t)0x7c89, (q15_t)0xe26d, (q15_t)0x7c87, (q15_t)0xe267, (q15_t)0x7c86, (q15_t)0xe261, (q15_t)0x7c84, (q15_t)0xe25b, - (q15_t)0x7c83, (q15_t)0xe255, (q15_t)0x7c82, (q15_t)0xe24f, (q15_t)0x7c80, (q15_t)0xe249, (q15_t)0x7c7f, (q15_t)0xe242, - (q15_t)0x7c7d, (q15_t)0xe23c, (q15_t)0x7c7c, (q15_t)0xe236, (q15_t)0x7c7a, (q15_t)0xe230, (q15_t)0x7c79, (q15_t)0xe22a, - (q15_t)0x7c77, (q15_t)0xe224, (q15_t)0x7c76, (q15_t)0xe21e, (q15_t)0x7c74, (q15_t)0xe218, (q15_t)0x7c73, (q15_t)0xe212, - (q15_t)0x7c71, (q15_t)0xe20b, (q15_t)0x7c70, (q15_t)0xe205, (q15_t)0x7c6e, (q15_t)0xe1ff, (q15_t)0x7c6d, (q15_t)0xe1f9, - (q15_t)0x7c6c, (q15_t)0xe1f3, (q15_t)0x7c6a, (q15_t)0xe1ed, (q15_t)0x7c69, (q15_t)0xe1e7, (q15_t)0x7c67, (q15_t)0xe1e1, - (q15_t)0x7c66, (q15_t)0xe1db, (q15_t)0x7c64, (q15_t)0xe1d4, (q15_t)0x7c63, (q15_t)0xe1ce, (q15_t)0x7c61, (q15_t)0xe1c8, - (q15_t)0x7c60, (q15_t)0xe1c2, (q15_t)0x7c5e, (q15_t)0xe1bc, (q15_t)0x7c5d, (q15_t)0xe1b6, (q15_t)0x7c5b, (q15_t)0xe1b0, - (q15_t)0x7c5a, (q15_t)0xe1aa, (q15_t)0x7c58, (q15_t)0xe1a4, (q15_t)0x7c57, (q15_t)0xe19e, (q15_t)0x7c55, (q15_t)0xe197, - (q15_t)0x7c54, (q15_t)0xe191, (q15_t)0x7c52, (q15_t)0xe18b, (q15_t)0x7c51, (q15_t)0xe185, (q15_t)0x7c4f, (q15_t)0xe17f, - (q15_t)0x7c4e, (q15_t)0xe179, (q15_t)0x7c4c, (q15_t)0xe173, (q15_t)0x7c4b, (q15_t)0xe16d, (q15_t)0x7c49, (q15_t)0xe167, - (q15_t)0x7c48, (q15_t)0xe160, (q15_t)0x7c46, (q15_t)0xe15a, (q15_t)0x7c45, (q15_t)0xe154, (q15_t)0x7c43, (q15_t)0xe14e, - (q15_t)0x7c42, (q15_t)0xe148, (q15_t)0x7c40, (q15_t)0xe142, (q15_t)0x7c3f, (q15_t)0xe13c, (q15_t)0x7c3d, (q15_t)0xe136, - (q15_t)0x7c3c, (q15_t)0xe130, (q15_t)0x7c3a, (q15_t)0xe12a, (q15_t)0x7c39, (q15_t)0xe123, (q15_t)0x7c37, (q15_t)0xe11d, - (q15_t)0x7c36, (q15_t)0xe117, (q15_t)0x7c34, (q15_t)0xe111, (q15_t)0x7c33, (q15_t)0xe10b, (q15_t)0x7c31, (q15_t)0xe105, - (q15_t)0x7c30, (q15_t)0xe0ff, (q15_t)0x7c2e, (q15_t)0xe0f9, (q15_t)0x7c2d, (q15_t)0xe0f3, (q15_t)0x7c2b, (q15_t)0xe0ed, - (q15_t)0x7c29, (q15_t)0xe0e7, (q15_t)0x7c28, (q15_t)0xe0e0, (q15_t)0x7c26, (q15_t)0xe0da, (q15_t)0x7c25, (q15_t)0xe0d4, - (q15_t)0x7c23, (q15_t)0xe0ce, (q15_t)0x7c22, (q15_t)0xe0c8, (q15_t)0x7c20, (q15_t)0xe0c2, (q15_t)0x7c1f, (q15_t)0xe0bc, - (q15_t)0x7c1d, (q15_t)0xe0b6, (q15_t)0x7c1c, (q15_t)0xe0b0, (q15_t)0x7c1a, (q15_t)0xe0aa, (q15_t)0x7c19, (q15_t)0xe0a3, - (q15_t)0x7c17, (q15_t)0xe09d, (q15_t)0x7c16, (q15_t)0xe097, (q15_t)0x7c14, (q15_t)0xe091, (q15_t)0x7c12, (q15_t)0xe08b, - (q15_t)0x7c11, (q15_t)0xe085, (q15_t)0x7c0f, (q15_t)0xe07f, (q15_t)0x7c0e, (q15_t)0xe079, (q15_t)0x7c0c, (q15_t)0xe073, - (q15_t)0x7c0b, (q15_t)0xe06d, (q15_t)0x7c09, (q15_t)0xe067, (q15_t)0x7c08, (q15_t)0xe061, (q15_t)0x7c06, (q15_t)0xe05a, - (q15_t)0x7c05, (q15_t)0xe054, (q15_t)0x7c03, (q15_t)0xe04e, (q15_t)0x7c01, (q15_t)0xe048, (q15_t)0x7c00, (q15_t)0xe042, - (q15_t)0x7bfe, (q15_t)0xe03c, (q15_t)0x7bfd, (q15_t)0xe036, (q15_t)0x7bfb, (q15_t)0xe030, (q15_t)0x7bfa, (q15_t)0xe02a, - (q15_t)0x7bf8, (q15_t)0xe024, (q15_t)0x7bf6, (q15_t)0xe01e, (q15_t)0x7bf5, (q15_t)0xe017, (q15_t)0x7bf3, (q15_t)0xe011, - (q15_t)0x7bf2, (q15_t)0xe00b, (q15_t)0x7bf0, (q15_t)0xe005, (q15_t)0x7bef, (q15_t)0xdfff, (q15_t)0x7bed, (q15_t)0xdff9, - (q15_t)0x7beb, (q15_t)0xdff3, (q15_t)0x7bea, (q15_t)0xdfed, (q15_t)0x7be8, (q15_t)0xdfe7, (q15_t)0x7be7, (q15_t)0xdfe1, - (q15_t)0x7be5, (q15_t)0xdfdb, (q15_t)0x7be4, (q15_t)0xdfd5, (q15_t)0x7be2, (q15_t)0xdfce, (q15_t)0x7be0, (q15_t)0xdfc8, - (q15_t)0x7bdf, (q15_t)0xdfc2, (q15_t)0x7bdd, (q15_t)0xdfbc, (q15_t)0x7bdc, (q15_t)0xdfb6, (q15_t)0x7bda, (q15_t)0xdfb0, - (q15_t)0x7bd9, (q15_t)0xdfaa, (q15_t)0x7bd7, (q15_t)0xdfa4, (q15_t)0x7bd5, (q15_t)0xdf9e, (q15_t)0x7bd4, (q15_t)0xdf98, - (q15_t)0x7bd2, (q15_t)0xdf92, (q15_t)0x7bd1, (q15_t)0xdf8c, (q15_t)0x7bcf, (q15_t)0xdf86, (q15_t)0x7bcd, (q15_t)0xdf7f, - (q15_t)0x7bcc, (q15_t)0xdf79, (q15_t)0x7bca, (q15_t)0xdf73, (q15_t)0x7bc9, (q15_t)0xdf6d, (q15_t)0x7bc7, (q15_t)0xdf67, - (q15_t)0x7bc5, (q15_t)0xdf61, (q15_t)0x7bc4, (q15_t)0xdf5b, (q15_t)0x7bc2, (q15_t)0xdf55, (q15_t)0x7bc1, (q15_t)0xdf4f, - (q15_t)0x7bbf, (q15_t)0xdf49, (q15_t)0x7bbd, (q15_t)0xdf43, (q15_t)0x7bbc, (q15_t)0xdf3d, (q15_t)0x7bba, (q15_t)0xdf37, - (q15_t)0x7bb9, (q15_t)0xdf30, (q15_t)0x7bb7, (q15_t)0xdf2a, (q15_t)0x7bb5, (q15_t)0xdf24, (q15_t)0x7bb4, (q15_t)0xdf1e, - (q15_t)0x7bb2, (q15_t)0xdf18, (q15_t)0x7bb0, (q15_t)0xdf12, (q15_t)0x7baf, (q15_t)0xdf0c, (q15_t)0x7bad, (q15_t)0xdf06, - (q15_t)0x7bac, (q15_t)0xdf00, (q15_t)0x7baa, (q15_t)0xdefa, (q15_t)0x7ba8, (q15_t)0xdef4, (q15_t)0x7ba7, (q15_t)0xdeee, - (q15_t)0x7ba5, (q15_t)0xdee8, (q15_t)0x7ba3, (q15_t)0xdee2, (q15_t)0x7ba2, (q15_t)0xdedb, (q15_t)0x7ba0, (q15_t)0xded5, - (q15_t)0x7b9f, (q15_t)0xdecf, (q15_t)0x7b9d, (q15_t)0xdec9, (q15_t)0x7b9b, (q15_t)0xdec3, (q15_t)0x7b9a, (q15_t)0xdebd, - (q15_t)0x7b98, (q15_t)0xdeb7, (q15_t)0x7b96, (q15_t)0xdeb1, (q15_t)0x7b95, (q15_t)0xdeab, (q15_t)0x7b93, (q15_t)0xdea5, - (q15_t)0x7b92, (q15_t)0xde9f, (q15_t)0x7b90, (q15_t)0xde99, (q15_t)0x7b8e, (q15_t)0xde93, (q15_t)0x7b8d, (q15_t)0xde8d, - (q15_t)0x7b8b, (q15_t)0xde87, (q15_t)0x7b89, (q15_t)0xde80, (q15_t)0x7b88, (q15_t)0xde7a, (q15_t)0x7b86, (q15_t)0xde74, - (q15_t)0x7b84, (q15_t)0xde6e, (q15_t)0x7b83, (q15_t)0xde68, (q15_t)0x7b81, (q15_t)0xde62, (q15_t)0x7b7f, (q15_t)0xde5c, - (q15_t)0x7b7e, (q15_t)0xde56, (q15_t)0x7b7c, (q15_t)0xde50, (q15_t)0x7b7a, (q15_t)0xde4a, (q15_t)0x7b79, (q15_t)0xde44, - (q15_t)0x7b77, (q15_t)0xde3e, (q15_t)0x7b76, (q15_t)0xde38, (q15_t)0x7b74, (q15_t)0xde32, (q15_t)0x7b72, (q15_t)0xde2c, - (q15_t)0x7b71, (q15_t)0xde26, (q15_t)0x7b6f, (q15_t)0xde1f, (q15_t)0x7b6d, (q15_t)0xde19, (q15_t)0x7b6c, (q15_t)0xde13, - (q15_t)0x7b6a, (q15_t)0xde0d, (q15_t)0x7b68, (q15_t)0xde07, (q15_t)0x7b67, (q15_t)0xde01, (q15_t)0x7b65, (q15_t)0xddfb, - (q15_t)0x7b63, (q15_t)0xddf5, (q15_t)0x7b62, (q15_t)0xddef, (q15_t)0x7b60, (q15_t)0xdde9, (q15_t)0x7b5e, (q15_t)0xdde3, - (q15_t)0x7b5d, (q15_t)0xdddd, (q15_t)0x7b5b, (q15_t)0xddd7, (q15_t)0x7b59, (q15_t)0xddd1, (q15_t)0x7b57, (q15_t)0xddcb, - (q15_t)0x7b56, (q15_t)0xddc5, (q15_t)0x7b54, (q15_t)0xddbf, (q15_t)0x7b52, (q15_t)0xddb9, (q15_t)0x7b51, (q15_t)0xddb2, - (q15_t)0x7b4f, (q15_t)0xddac, (q15_t)0x7b4d, (q15_t)0xdda6, (q15_t)0x7b4c, (q15_t)0xdda0, (q15_t)0x7b4a, (q15_t)0xdd9a, - (q15_t)0x7b48, (q15_t)0xdd94, (q15_t)0x7b47, (q15_t)0xdd8e, (q15_t)0x7b45, (q15_t)0xdd88, (q15_t)0x7b43, (q15_t)0xdd82, - (q15_t)0x7b42, (q15_t)0xdd7c, (q15_t)0x7b40, (q15_t)0xdd76, (q15_t)0x7b3e, (q15_t)0xdd70, (q15_t)0x7b3c, (q15_t)0xdd6a, - (q15_t)0x7b3b, (q15_t)0xdd64, (q15_t)0x7b39, (q15_t)0xdd5e, (q15_t)0x7b37, (q15_t)0xdd58, (q15_t)0x7b36, (q15_t)0xdd52, - (q15_t)0x7b34, (q15_t)0xdd4c, (q15_t)0x7b32, (q15_t)0xdd46, (q15_t)0x7b31, (q15_t)0xdd40, (q15_t)0x7b2f, (q15_t)0xdd39, - (q15_t)0x7b2d, (q15_t)0xdd33, (q15_t)0x7b2b, (q15_t)0xdd2d, (q15_t)0x7b2a, (q15_t)0xdd27, (q15_t)0x7b28, (q15_t)0xdd21, - (q15_t)0x7b26, (q15_t)0xdd1b, (q15_t)0x7b25, (q15_t)0xdd15, (q15_t)0x7b23, (q15_t)0xdd0f, (q15_t)0x7b21, (q15_t)0xdd09, - (q15_t)0x7b1f, (q15_t)0xdd03, (q15_t)0x7b1e, (q15_t)0xdcfd, (q15_t)0x7b1c, (q15_t)0xdcf7, (q15_t)0x7b1a, (q15_t)0xdcf1, - (q15_t)0x7b19, (q15_t)0xdceb, (q15_t)0x7b17, (q15_t)0xdce5, (q15_t)0x7b15, (q15_t)0xdcdf, (q15_t)0x7b13, (q15_t)0xdcd9, - (q15_t)0x7b12, (q15_t)0xdcd3, (q15_t)0x7b10, (q15_t)0xdccd, (q15_t)0x7b0e, (q15_t)0xdcc7, (q15_t)0x7b0c, (q15_t)0xdcc1, - (q15_t)0x7b0b, (q15_t)0xdcbb, (q15_t)0x7b09, (q15_t)0xdcb5, (q15_t)0x7b07, (q15_t)0xdcae, (q15_t)0x7b06, (q15_t)0xdca8, - (q15_t)0x7b04, (q15_t)0xdca2, (q15_t)0x7b02, (q15_t)0xdc9c, (q15_t)0x7b00, (q15_t)0xdc96, (q15_t)0x7aff, (q15_t)0xdc90, - (q15_t)0x7afd, (q15_t)0xdc8a, (q15_t)0x7afb, (q15_t)0xdc84, (q15_t)0x7af9, (q15_t)0xdc7e, (q15_t)0x7af8, (q15_t)0xdc78, - (q15_t)0x7af6, (q15_t)0xdc72, (q15_t)0x7af4, (q15_t)0xdc6c, (q15_t)0x7af2, (q15_t)0xdc66, (q15_t)0x7af1, (q15_t)0xdc60, - (q15_t)0x7aef, (q15_t)0xdc5a, (q15_t)0x7aed, (q15_t)0xdc54, (q15_t)0x7aeb, (q15_t)0xdc4e, (q15_t)0x7aea, (q15_t)0xdc48, - (q15_t)0x7ae8, (q15_t)0xdc42, (q15_t)0x7ae6, (q15_t)0xdc3c, (q15_t)0x7ae4, (q15_t)0xdc36, (q15_t)0x7ae3, (q15_t)0xdc30, - (q15_t)0x7ae1, (q15_t)0xdc2a, (q15_t)0x7adf, (q15_t)0xdc24, (q15_t)0x7add, (q15_t)0xdc1e, (q15_t)0x7adc, (q15_t)0xdc18, - (q15_t)0x7ada, (q15_t)0xdc12, (q15_t)0x7ad8, (q15_t)0xdc0c, (q15_t)0x7ad6, (q15_t)0xdc06, (q15_t)0x7ad5, (q15_t)0xdbff, - (q15_t)0x7ad3, (q15_t)0xdbf9, (q15_t)0x7ad1, (q15_t)0xdbf3, (q15_t)0x7acf, (q15_t)0xdbed, (q15_t)0x7acd, (q15_t)0xdbe7, - (q15_t)0x7acc, (q15_t)0xdbe1, (q15_t)0x7aca, (q15_t)0xdbdb, (q15_t)0x7ac8, (q15_t)0xdbd5, (q15_t)0x7ac6, (q15_t)0xdbcf, - (q15_t)0x7ac5, (q15_t)0xdbc9, (q15_t)0x7ac3, (q15_t)0xdbc3, (q15_t)0x7ac1, (q15_t)0xdbbd, (q15_t)0x7abf, (q15_t)0xdbb7, - (q15_t)0x7abd, (q15_t)0xdbb1, (q15_t)0x7abc, (q15_t)0xdbab, (q15_t)0x7aba, (q15_t)0xdba5, (q15_t)0x7ab8, (q15_t)0xdb9f, - (q15_t)0x7ab6, (q15_t)0xdb99, (q15_t)0x7ab5, (q15_t)0xdb93, (q15_t)0x7ab3, (q15_t)0xdb8d, (q15_t)0x7ab1, (q15_t)0xdb87, - (q15_t)0x7aaf, (q15_t)0xdb81, (q15_t)0x7aad, (q15_t)0xdb7b, (q15_t)0x7aac, (q15_t)0xdb75, (q15_t)0x7aaa, (q15_t)0xdb6f, - (q15_t)0x7aa8, (q15_t)0xdb69, (q15_t)0x7aa6, (q15_t)0xdb63, (q15_t)0x7aa4, (q15_t)0xdb5d, (q15_t)0x7aa3, (q15_t)0xdb57, - (q15_t)0x7aa1, (q15_t)0xdb51, (q15_t)0x7a9f, (q15_t)0xdb4b, (q15_t)0x7a9d, (q15_t)0xdb45, (q15_t)0x7a9b, (q15_t)0xdb3f, - (q15_t)0x7a9a, (q15_t)0xdb39, (q15_t)0x7a98, (q15_t)0xdb33, (q15_t)0x7a96, (q15_t)0xdb2d, (q15_t)0x7a94, (q15_t)0xdb27, - (q15_t)0x7a92, (q15_t)0xdb21, (q15_t)0x7a91, (q15_t)0xdb1b, (q15_t)0x7a8f, (q15_t)0xdb15, (q15_t)0x7a8d, (q15_t)0xdb0f, - (q15_t)0x7a8b, (q15_t)0xdb09, (q15_t)0x7a89, (q15_t)0xdb03, (q15_t)0x7a87, (q15_t)0xdafd, (q15_t)0x7a86, (q15_t)0xdaf7, - (q15_t)0x7a84, (q15_t)0xdaf1, (q15_t)0x7a82, (q15_t)0xdaea, (q15_t)0x7a80, (q15_t)0xdae4, (q15_t)0x7a7e, (q15_t)0xdade, - (q15_t)0x7a7d, (q15_t)0xdad8, (q15_t)0x7a7b, (q15_t)0xdad2, (q15_t)0x7a79, (q15_t)0xdacc, (q15_t)0x7a77, (q15_t)0xdac6, - (q15_t)0x7a75, (q15_t)0xdac0, (q15_t)0x7a73, (q15_t)0xdaba, (q15_t)0x7a72, (q15_t)0xdab4, (q15_t)0x7a70, (q15_t)0xdaae, - (q15_t)0x7a6e, (q15_t)0xdaa8, (q15_t)0x7a6c, (q15_t)0xdaa2, (q15_t)0x7a6a, (q15_t)0xda9c, (q15_t)0x7a68, (q15_t)0xda96, - (q15_t)0x7a67, (q15_t)0xda90, (q15_t)0x7a65, (q15_t)0xda8a, (q15_t)0x7a63, (q15_t)0xda84, (q15_t)0x7a61, (q15_t)0xda7e, - (q15_t)0x7a5f, (q15_t)0xda78, (q15_t)0x7a5d, (q15_t)0xda72, (q15_t)0x7a5c, (q15_t)0xda6c, (q15_t)0x7a5a, (q15_t)0xda66, - (q15_t)0x7a58, (q15_t)0xda60, (q15_t)0x7a56, (q15_t)0xda5a, (q15_t)0x7a54, (q15_t)0xda54, (q15_t)0x7a52, (q15_t)0xda4e, - (q15_t)0x7a50, (q15_t)0xda48, (q15_t)0x7a4f, (q15_t)0xda42, (q15_t)0x7a4d, (q15_t)0xda3c, (q15_t)0x7a4b, (q15_t)0xda36, - (q15_t)0x7a49, (q15_t)0xda30, (q15_t)0x7a47, (q15_t)0xda2a, (q15_t)0x7a45, (q15_t)0xda24, (q15_t)0x7a43, (q15_t)0xda1e, - (q15_t)0x7a42, (q15_t)0xda18, (q15_t)0x7a40, (q15_t)0xda12, (q15_t)0x7a3e, (q15_t)0xda0c, (q15_t)0x7a3c, (q15_t)0xda06, - (q15_t)0x7a3a, (q15_t)0xda00, (q15_t)0x7a38, (q15_t)0xd9fa, (q15_t)0x7a36, (q15_t)0xd9f4, (q15_t)0x7a35, (q15_t)0xd9ee, - (q15_t)0x7a33, (q15_t)0xd9e8, (q15_t)0x7a31, (q15_t)0xd9e2, (q15_t)0x7a2f, (q15_t)0xd9dc, (q15_t)0x7a2d, (q15_t)0xd9d6, - (q15_t)0x7a2b, (q15_t)0xd9d0, (q15_t)0x7a29, (q15_t)0xd9ca, (q15_t)0x7a27, (q15_t)0xd9c4, (q15_t)0x7a26, (q15_t)0xd9be, - (q15_t)0x7a24, (q15_t)0xd9b8, (q15_t)0x7a22, (q15_t)0xd9b2, (q15_t)0x7a20, (q15_t)0xd9ac, (q15_t)0x7a1e, (q15_t)0xd9a6, - (q15_t)0x7a1c, (q15_t)0xd9a0, (q15_t)0x7a1a, (q15_t)0xd99a, (q15_t)0x7a18, (q15_t)0xd994, (q15_t)0x7a16, (q15_t)0xd98e, - (q15_t)0x7a15, (q15_t)0xd988, (q15_t)0x7a13, (q15_t)0xd982, (q15_t)0x7a11, (q15_t)0xd97c, (q15_t)0x7a0f, (q15_t)0xd976, - (q15_t)0x7a0d, (q15_t)0xd970, (q15_t)0x7a0b, (q15_t)0xd96a, (q15_t)0x7a09, (q15_t)0xd964, (q15_t)0x7a07, (q15_t)0xd95e, - (q15_t)0x7a05, (q15_t)0xd958, (q15_t)0x7a04, (q15_t)0xd952, (q15_t)0x7a02, (q15_t)0xd94c, (q15_t)0x7a00, (q15_t)0xd946, - (q15_t)0x79fe, (q15_t)0xd940, (q15_t)0x79fc, (q15_t)0xd93a, (q15_t)0x79fa, (q15_t)0xd934, (q15_t)0x79f8, (q15_t)0xd92e, - (q15_t)0x79f6, (q15_t)0xd928, (q15_t)0x79f4, (q15_t)0xd922, (q15_t)0x79f2, (q15_t)0xd91c, (q15_t)0x79f0, (q15_t)0xd917, - (q15_t)0x79ef, (q15_t)0xd911, (q15_t)0x79ed, (q15_t)0xd90b, (q15_t)0x79eb, (q15_t)0xd905, (q15_t)0x79e9, (q15_t)0xd8ff, - (q15_t)0x79e7, (q15_t)0xd8f9, (q15_t)0x79e5, (q15_t)0xd8f3, (q15_t)0x79e3, (q15_t)0xd8ed, (q15_t)0x79e1, (q15_t)0xd8e7, - (q15_t)0x79df, (q15_t)0xd8e1, (q15_t)0x79dd, (q15_t)0xd8db, (q15_t)0x79db, (q15_t)0xd8d5, (q15_t)0x79d9, (q15_t)0xd8cf, - (q15_t)0x79d8, (q15_t)0xd8c9, (q15_t)0x79d6, (q15_t)0xd8c3, (q15_t)0x79d4, (q15_t)0xd8bd, (q15_t)0x79d2, (q15_t)0xd8b7, - (q15_t)0x79d0, (q15_t)0xd8b1, (q15_t)0x79ce, (q15_t)0xd8ab, (q15_t)0x79cc, (q15_t)0xd8a5, (q15_t)0x79ca, (q15_t)0xd89f, - (q15_t)0x79c8, (q15_t)0xd899, (q15_t)0x79c6, (q15_t)0xd893, (q15_t)0x79c4, (q15_t)0xd88d, (q15_t)0x79c2, (q15_t)0xd887, - (q15_t)0x79c0, (q15_t)0xd881, (q15_t)0x79be, (q15_t)0xd87b, (q15_t)0x79bc, (q15_t)0xd875, (q15_t)0x79bb, (q15_t)0xd86f, - (q15_t)0x79b9, (q15_t)0xd869, (q15_t)0x79b7, (q15_t)0xd863, (q15_t)0x79b5, (q15_t)0xd85d, (q15_t)0x79b3, (q15_t)0xd857, - (q15_t)0x79b1, (q15_t)0xd851, (q15_t)0x79af, (q15_t)0xd84b, (q15_t)0x79ad, (q15_t)0xd845, (q15_t)0x79ab, (q15_t)0xd83f, - (q15_t)0x79a9, (q15_t)0xd839, (q15_t)0x79a7, (q15_t)0xd833, (q15_t)0x79a5, (q15_t)0xd82d, (q15_t)0x79a3, (q15_t)0xd827, - (q15_t)0x79a1, (q15_t)0xd821, (q15_t)0x799f, (q15_t)0xd81b, (q15_t)0x799d, (q15_t)0xd815, (q15_t)0x799b, (q15_t)0xd80f, - (q15_t)0x7999, (q15_t)0xd80a, (q15_t)0x7997, (q15_t)0xd804, (q15_t)0x7995, (q15_t)0xd7fe, (q15_t)0x7993, (q15_t)0xd7f8, - (q15_t)0x7992, (q15_t)0xd7f2, (q15_t)0x7990, (q15_t)0xd7ec, (q15_t)0x798e, (q15_t)0xd7e6, (q15_t)0x798c, (q15_t)0xd7e0, - (q15_t)0x798a, (q15_t)0xd7da, (q15_t)0x7988, (q15_t)0xd7d4, (q15_t)0x7986, (q15_t)0xd7ce, (q15_t)0x7984, (q15_t)0xd7c8, - (q15_t)0x7982, (q15_t)0xd7c2, (q15_t)0x7980, (q15_t)0xd7bc, (q15_t)0x797e, (q15_t)0xd7b6, (q15_t)0x797c, (q15_t)0xd7b0, - (q15_t)0x797a, (q15_t)0xd7aa, (q15_t)0x7978, (q15_t)0xd7a4, (q15_t)0x7976, (q15_t)0xd79e, (q15_t)0x7974, (q15_t)0xd798, - (q15_t)0x7972, (q15_t)0xd792, (q15_t)0x7970, (q15_t)0xd78c, (q15_t)0x796e, (q15_t)0xd786, (q15_t)0x796c, (q15_t)0xd780, - (q15_t)0x796a, (q15_t)0xd77a, (q15_t)0x7968, (q15_t)0xd774, (q15_t)0x7966, (q15_t)0xd76e, (q15_t)0x7964, (q15_t)0xd768, - (q15_t)0x7962, (q15_t)0xd763, (q15_t)0x7960, (q15_t)0xd75d, (q15_t)0x795e, (q15_t)0xd757, (q15_t)0x795c, (q15_t)0xd751, - (q15_t)0x795a, (q15_t)0xd74b, (q15_t)0x7958, (q15_t)0xd745, (q15_t)0x7956, (q15_t)0xd73f, (q15_t)0x7954, (q15_t)0xd739, - (q15_t)0x7952, (q15_t)0xd733, (q15_t)0x7950, (q15_t)0xd72d, (q15_t)0x794e, (q15_t)0xd727, (q15_t)0x794c, (q15_t)0xd721, - (q15_t)0x794a, (q15_t)0xd71b, (q15_t)0x7948, (q15_t)0xd715, (q15_t)0x7946, (q15_t)0xd70f, (q15_t)0x7944, (q15_t)0xd709, - (q15_t)0x7942, (q15_t)0xd703, (q15_t)0x7940, (q15_t)0xd6fd, (q15_t)0x793e, (q15_t)0xd6f7, (q15_t)0x793c, (q15_t)0xd6f1, - (q15_t)0x793a, (q15_t)0xd6eb, (q15_t)0x7938, (q15_t)0xd6e5, (q15_t)0x7936, (q15_t)0xd6e0, (q15_t)0x7934, (q15_t)0xd6da, - (q15_t)0x7932, (q15_t)0xd6d4, (q15_t)0x7930, (q15_t)0xd6ce, (q15_t)0x792e, (q15_t)0xd6c8, (q15_t)0x792c, (q15_t)0xd6c2, - (q15_t)0x792a, (q15_t)0xd6bc, (q15_t)0x7928, (q15_t)0xd6b6, (q15_t)0x7926, (q15_t)0xd6b0, (q15_t)0x7924, (q15_t)0xd6aa, - (q15_t)0x7922, (q15_t)0xd6a4, (q15_t)0x7920, (q15_t)0xd69e, (q15_t)0x791e, (q15_t)0xd698, (q15_t)0x791c, (q15_t)0xd692, - (q15_t)0x7919, (q15_t)0xd68c, (q15_t)0x7917, (q15_t)0xd686, (q15_t)0x7915, (q15_t)0xd680, (q15_t)0x7913, (q15_t)0xd67a, - (q15_t)0x7911, (q15_t)0xd675, (q15_t)0x790f, (q15_t)0xd66f, (q15_t)0x790d, (q15_t)0xd669, (q15_t)0x790b, (q15_t)0xd663, - (q15_t)0x7909, (q15_t)0xd65d, (q15_t)0x7907, (q15_t)0xd657, (q15_t)0x7905, (q15_t)0xd651, (q15_t)0x7903, (q15_t)0xd64b, - (q15_t)0x7901, (q15_t)0xd645, (q15_t)0x78ff, (q15_t)0xd63f, (q15_t)0x78fd, (q15_t)0xd639, (q15_t)0x78fb, (q15_t)0xd633, - (q15_t)0x78f9, (q15_t)0xd62d, (q15_t)0x78f7, (q15_t)0xd627, (q15_t)0x78f5, (q15_t)0xd621, (q15_t)0x78f3, (q15_t)0xd61b, - (q15_t)0x78f1, (q15_t)0xd615, (q15_t)0x78ee, (q15_t)0xd610, (q15_t)0x78ec, (q15_t)0xd60a, (q15_t)0x78ea, (q15_t)0xd604, - (q15_t)0x78e8, (q15_t)0xd5fe, (q15_t)0x78e6, (q15_t)0xd5f8, (q15_t)0x78e4, (q15_t)0xd5f2, (q15_t)0x78e2, (q15_t)0xd5ec, - (q15_t)0x78e0, (q15_t)0xd5e6, (q15_t)0x78de, (q15_t)0xd5e0, (q15_t)0x78dc, (q15_t)0xd5da, (q15_t)0x78da, (q15_t)0xd5d4, - (q15_t)0x78d8, (q15_t)0xd5ce, (q15_t)0x78d6, (q15_t)0xd5c8, (q15_t)0x78d4, (q15_t)0xd5c2, (q15_t)0x78d2, (q15_t)0xd5bc, - (q15_t)0x78cf, (q15_t)0xd5b7, (q15_t)0x78cd, (q15_t)0xd5b1, (q15_t)0x78cb, (q15_t)0xd5ab, (q15_t)0x78c9, (q15_t)0xd5a5, - (q15_t)0x78c7, (q15_t)0xd59f, (q15_t)0x78c5, (q15_t)0xd599, (q15_t)0x78c3, (q15_t)0xd593, (q15_t)0x78c1, (q15_t)0xd58d, - (q15_t)0x78bf, (q15_t)0xd587, (q15_t)0x78bd, (q15_t)0xd581, (q15_t)0x78bb, (q15_t)0xd57b, (q15_t)0x78b9, (q15_t)0xd575, - (q15_t)0x78b6, (q15_t)0xd56f, (q15_t)0x78b4, (q15_t)0xd569, (q15_t)0x78b2, (q15_t)0xd564, (q15_t)0x78b0, (q15_t)0xd55e, - (q15_t)0x78ae, (q15_t)0xd558, (q15_t)0x78ac, (q15_t)0xd552, (q15_t)0x78aa, (q15_t)0xd54c, (q15_t)0x78a8, (q15_t)0xd546, - (q15_t)0x78a6, (q15_t)0xd540, (q15_t)0x78a4, (q15_t)0xd53a, (q15_t)0x78a2, (q15_t)0xd534, (q15_t)0x789f, (q15_t)0xd52e, - (q15_t)0x789d, (q15_t)0xd528, (q15_t)0x789b, (q15_t)0xd522, (q15_t)0x7899, (q15_t)0xd51c, (q15_t)0x7897, (q15_t)0xd517, - (q15_t)0x7895, (q15_t)0xd511, (q15_t)0x7893, (q15_t)0xd50b, (q15_t)0x7891, (q15_t)0xd505, (q15_t)0x788f, (q15_t)0xd4ff, - (q15_t)0x788c, (q15_t)0xd4f9, (q15_t)0x788a, (q15_t)0xd4f3, (q15_t)0x7888, (q15_t)0xd4ed, (q15_t)0x7886, (q15_t)0xd4e7, - (q15_t)0x7884, (q15_t)0xd4e1, (q15_t)0x7882, (q15_t)0xd4db, (q15_t)0x7880, (q15_t)0xd4d5, (q15_t)0x787e, (q15_t)0xd4d0, - (q15_t)0x787c, (q15_t)0xd4ca, (q15_t)0x7879, (q15_t)0xd4c4, (q15_t)0x7877, (q15_t)0xd4be, (q15_t)0x7875, (q15_t)0xd4b8, - (q15_t)0x7873, (q15_t)0xd4b2, (q15_t)0x7871, (q15_t)0xd4ac, (q15_t)0x786f, (q15_t)0xd4a6, (q15_t)0x786d, (q15_t)0xd4a0, - (q15_t)0x786b, (q15_t)0xd49a, (q15_t)0x7868, (q15_t)0xd494, (q15_t)0x7866, (q15_t)0xd48f, (q15_t)0x7864, (q15_t)0xd489, - (q15_t)0x7862, (q15_t)0xd483, (q15_t)0x7860, (q15_t)0xd47d, (q15_t)0x785e, (q15_t)0xd477, (q15_t)0x785c, (q15_t)0xd471, - (q15_t)0x7859, (q15_t)0xd46b, (q15_t)0x7857, (q15_t)0xd465, (q15_t)0x7855, (q15_t)0xd45f, (q15_t)0x7853, (q15_t)0xd459, - (q15_t)0x7851, (q15_t)0xd453, (q15_t)0x784f, (q15_t)0xd44e, (q15_t)0x784d, (q15_t)0xd448, (q15_t)0x784a, (q15_t)0xd442, - (q15_t)0x7848, (q15_t)0xd43c, (q15_t)0x7846, (q15_t)0xd436, (q15_t)0x7844, (q15_t)0xd430, (q15_t)0x7842, (q15_t)0xd42a, - (q15_t)0x7840, (q15_t)0xd424, (q15_t)0x783e, (q15_t)0xd41e, (q15_t)0x783b, (q15_t)0xd418, (q15_t)0x7839, (q15_t)0xd412, - (q15_t)0x7837, (q15_t)0xd40d, (q15_t)0x7835, (q15_t)0xd407, (q15_t)0x7833, (q15_t)0xd401, (q15_t)0x7831, (q15_t)0xd3fb, - (q15_t)0x782e, (q15_t)0xd3f5, (q15_t)0x782c, (q15_t)0xd3ef, (q15_t)0x782a, (q15_t)0xd3e9, (q15_t)0x7828, (q15_t)0xd3e3, - (q15_t)0x7826, (q15_t)0xd3dd, (q15_t)0x7824, (q15_t)0xd3d7, (q15_t)0x7821, (q15_t)0xd3d2, (q15_t)0x781f, (q15_t)0xd3cc, - (q15_t)0x781d, (q15_t)0xd3c6, (q15_t)0x781b, (q15_t)0xd3c0, (q15_t)0x7819, (q15_t)0xd3ba, (q15_t)0x7817, (q15_t)0xd3b4, - (q15_t)0x7814, (q15_t)0xd3ae, (q15_t)0x7812, (q15_t)0xd3a8, (q15_t)0x7810, (q15_t)0xd3a2, (q15_t)0x780e, (q15_t)0xd39d, - (q15_t)0x780c, (q15_t)0xd397, (q15_t)0x780a, (q15_t)0xd391, (q15_t)0x7807, (q15_t)0xd38b, (q15_t)0x7805, (q15_t)0xd385, - (q15_t)0x7803, (q15_t)0xd37f, (q15_t)0x7801, (q15_t)0xd379, (q15_t)0x77ff, (q15_t)0xd373, (q15_t)0x77fc, (q15_t)0xd36d, - (q15_t)0x77fa, (q15_t)0xd368, (q15_t)0x77f8, (q15_t)0xd362, (q15_t)0x77f6, (q15_t)0xd35c, (q15_t)0x77f4, (q15_t)0xd356, - (q15_t)0x77f1, (q15_t)0xd350, (q15_t)0x77ef, (q15_t)0xd34a, (q15_t)0x77ed, (q15_t)0xd344, (q15_t)0x77eb, (q15_t)0xd33e, - (q15_t)0x77e9, (q15_t)0xd338, (q15_t)0x77e6, (q15_t)0xd333, (q15_t)0x77e4, (q15_t)0xd32d, (q15_t)0x77e2, (q15_t)0xd327, - (q15_t)0x77e0, (q15_t)0xd321, (q15_t)0x77de, (q15_t)0xd31b, (q15_t)0x77db, (q15_t)0xd315, (q15_t)0x77d9, (q15_t)0xd30f, - (q15_t)0x77d7, (q15_t)0xd309, (q15_t)0x77d5, (q15_t)0xd303, (q15_t)0x77d3, (q15_t)0xd2fe, (q15_t)0x77d0, (q15_t)0xd2f8, - (q15_t)0x77ce, (q15_t)0xd2f2, (q15_t)0x77cc, (q15_t)0xd2ec, (q15_t)0x77ca, (q15_t)0xd2e6, (q15_t)0x77c8, (q15_t)0xd2e0, - (q15_t)0x77c5, (q15_t)0xd2da, (q15_t)0x77c3, (q15_t)0xd2d4, (q15_t)0x77c1, (q15_t)0xd2cf, (q15_t)0x77bf, (q15_t)0xd2c9, - (q15_t)0x77bc, (q15_t)0xd2c3, (q15_t)0x77ba, (q15_t)0xd2bd, (q15_t)0x77b8, (q15_t)0xd2b7, (q15_t)0x77b6, (q15_t)0xd2b1, - (q15_t)0x77b4, (q15_t)0xd2ab, (q15_t)0x77b1, (q15_t)0xd2a5, (q15_t)0x77af, (q15_t)0xd2a0, (q15_t)0x77ad, (q15_t)0xd29a, - (q15_t)0x77ab, (q15_t)0xd294, (q15_t)0x77a8, (q15_t)0xd28e, (q15_t)0x77a6, (q15_t)0xd288, (q15_t)0x77a4, (q15_t)0xd282, - (q15_t)0x77a2, (q15_t)0xd27c, (q15_t)0x77a0, (q15_t)0xd276, (q15_t)0x779d, (q15_t)0xd271, (q15_t)0x779b, (q15_t)0xd26b, - (q15_t)0x7799, (q15_t)0xd265, (q15_t)0x7797, (q15_t)0xd25f, (q15_t)0x7794, (q15_t)0xd259, (q15_t)0x7792, (q15_t)0xd253, - (q15_t)0x7790, (q15_t)0xd24d, (q15_t)0x778e, (q15_t)0xd247, (q15_t)0x778b, (q15_t)0xd242, (q15_t)0x7789, (q15_t)0xd23c, - (q15_t)0x7787, (q15_t)0xd236, (q15_t)0x7785, (q15_t)0xd230, (q15_t)0x7782, (q15_t)0xd22a, (q15_t)0x7780, (q15_t)0xd224, - (q15_t)0x777e, (q15_t)0xd21e, (q15_t)0x777c, (q15_t)0xd219, (q15_t)0x7779, (q15_t)0xd213, (q15_t)0x7777, (q15_t)0xd20d, - (q15_t)0x7775, (q15_t)0xd207, (q15_t)0x7773, (q15_t)0xd201, (q15_t)0x7770, (q15_t)0xd1fb, (q15_t)0x776e, (q15_t)0xd1f5, - (q15_t)0x776c, (q15_t)0xd1ef, (q15_t)0x776a, (q15_t)0xd1ea, (q15_t)0x7767, (q15_t)0xd1e4, (q15_t)0x7765, (q15_t)0xd1de, - (q15_t)0x7763, (q15_t)0xd1d8, (q15_t)0x7760, (q15_t)0xd1d2, (q15_t)0x775e, (q15_t)0xd1cc, (q15_t)0x775c, (q15_t)0xd1c6, - (q15_t)0x775a, (q15_t)0xd1c1, (q15_t)0x7757, (q15_t)0xd1bb, (q15_t)0x7755, (q15_t)0xd1b5, (q15_t)0x7753, (q15_t)0xd1af, - (q15_t)0x7751, (q15_t)0xd1a9, (q15_t)0x774e, (q15_t)0xd1a3, (q15_t)0x774c, (q15_t)0xd19d, (q15_t)0x774a, (q15_t)0xd198, - (q15_t)0x7747, (q15_t)0xd192, (q15_t)0x7745, (q15_t)0xd18c, (q15_t)0x7743, (q15_t)0xd186, (q15_t)0x7741, (q15_t)0xd180, - (q15_t)0x773e, (q15_t)0xd17a, (q15_t)0x773c, (q15_t)0xd174, (q15_t)0x773a, (q15_t)0xd16f, (q15_t)0x7738, (q15_t)0xd169, - (q15_t)0x7735, (q15_t)0xd163, (q15_t)0x7733, (q15_t)0xd15d, (q15_t)0x7731, (q15_t)0xd157, (q15_t)0x772e, (q15_t)0xd151, - (q15_t)0x772c, (q15_t)0xd14b, (q15_t)0x772a, (q15_t)0xd146, (q15_t)0x7727, (q15_t)0xd140, (q15_t)0x7725, (q15_t)0xd13a, - (q15_t)0x7723, (q15_t)0xd134, (q15_t)0x7721, (q15_t)0xd12e, (q15_t)0x771e, (q15_t)0xd128, (q15_t)0x771c, (q15_t)0xd123, - (q15_t)0x771a, (q15_t)0xd11d, (q15_t)0x7717, (q15_t)0xd117, (q15_t)0x7715, (q15_t)0xd111, (q15_t)0x7713, (q15_t)0xd10b, - (q15_t)0x7710, (q15_t)0xd105, (q15_t)0x770e, (q15_t)0xd0ff, (q15_t)0x770c, (q15_t)0xd0fa, (q15_t)0x770a, (q15_t)0xd0f4, - (q15_t)0x7707, (q15_t)0xd0ee, (q15_t)0x7705, (q15_t)0xd0e8, (q15_t)0x7703, (q15_t)0xd0e2, (q15_t)0x7700, (q15_t)0xd0dc, - (q15_t)0x76fe, (q15_t)0xd0d7, (q15_t)0x76fc, (q15_t)0xd0d1, (q15_t)0x76f9, (q15_t)0xd0cb, (q15_t)0x76f7, (q15_t)0xd0c5, - (q15_t)0x76f5, (q15_t)0xd0bf, (q15_t)0x76f2, (q15_t)0xd0b9, (q15_t)0x76f0, (q15_t)0xd0b4, (q15_t)0x76ee, (q15_t)0xd0ae, - (q15_t)0x76eb, (q15_t)0xd0a8, (q15_t)0x76e9, (q15_t)0xd0a2, (q15_t)0x76e7, (q15_t)0xd09c, (q15_t)0x76e4, (q15_t)0xd096, - (q15_t)0x76e2, (q15_t)0xd091, (q15_t)0x76e0, (q15_t)0xd08b, (q15_t)0x76dd, (q15_t)0xd085, (q15_t)0x76db, (q15_t)0xd07f, - (q15_t)0x76d9, (q15_t)0xd079, (q15_t)0x76d6, (q15_t)0xd073, (q15_t)0x76d4, (q15_t)0xd06e, (q15_t)0x76d2, (q15_t)0xd068, - (q15_t)0x76cf, (q15_t)0xd062, (q15_t)0x76cd, (q15_t)0xd05c, (q15_t)0x76cb, (q15_t)0xd056, (q15_t)0x76c8, (q15_t)0xd050, - (q15_t)0x76c6, (q15_t)0xd04b, (q15_t)0x76c4, (q15_t)0xd045, (q15_t)0x76c1, (q15_t)0xd03f, (q15_t)0x76bf, (q15_t)0xd039, - (q15_t)0x76bd, (q15_t)0xd033, (q15_t)0x76ba, (q15_t)0xd02d, (q15_t)0x76b8, (q15_t)0xd028, (q15_t)0x76b6, (q15_t)0xd022, - (q15_t)0x76b3, (q15_t)0xd01c, (q15_t)0x76b1, (q15_t)0xd016, (q15_t)0x76af, (q15_t)0xd010, (q15_t)0x76ac, (q15_t)0xd00a, - (q15_t)0x76aa, (q15_t)0xd005, (q15_t)0x76a8, (q15_t)0xcfff, (q15_t)0x76a5, (q15_t)0xcff9, (q15_t)0x76a3, (q15_t)0xcff3, - (q15_t)0x76a0, (q15_t)0xcfed, (q15_t)0x769e, (q15_t)0xcfe7, (q15_t)0x769c, (q15_t)0xcfe2, (q15_t)0x7699, (q15_t)0xcfdc, - (q15_t)0x7697, (q15_t)0xcfd6, (q15_t)0x7695, (q15_t)0xcfd0, (q15_t)0x7692, (q15_t)0xcfca, (q15_t)0x7690, (q15_t)0xcfc5, - (q15_t)0x768e, (q15_t)0xcfbf, (q15_t)0x768b, (q15_t)0xcfb9, (q15_t)0x7689, (q15_t)0xcfb3, (q15_t)0x7686, (q15_t)0xcfad, - (q15_t)0x7684, (q15_t)0xcfa7, (q15_t)0x7682, (q15_t)0xcfa2, (q15_t)0x767f, (q15_t)0xcf9c, (q15_t)0x767d, (q15_t)0xcf96, - (q15_t)0x767b, (q15_t)0xcf90, (q15_t)0x7678, (q15_t)0xcf8a, (q15_t)0x7676, (q15_t)0xcf85, (q15_t)0x7673, (q15_t)0xcf7f, - (q15_t)0x7671, (q15_t)0xcf79, (q15_t)0x766f, (q15_t)0xcf73, (q15_t)0x766c, (q15_t)0xcf6d, (q15_t)0x766a, (q15_t)0xcf67, - (q15_t)0x7668, (q15_t)0xcf62, (q15_t)0x7665, (q15_t)0xcf5c, (q15_t)0x7663, (q15_t)0xcf56, (q15_t)0x7660, (q15_t)0xcf50, - (q15_t)0x765e, (q15_t)0xcf4a, (q15_t)0x765c, (q15_t)0xcf45, (q15_t)0x7659, (q15_t)0xcf3f, (q15_t)0x7657, (q15_t)0xcf39, - (q15_t)0x7654, (q15_t)0xcf33, (q15_t)0x7652, (q15_t)0xcf2d, (q15_t)0x7650, (q15_t)0xcf28, (q15_t)0x764d, (q15_t)0xcf22, - (q15_t)0x764b, (q15_t)0xcf1c, (q15_t)0x7648, (q15_t)0xcf16, (q15_t)0x7646, (q15_t)0xcf10, (q15_t)0x7644, (q15_t)0xcf0b, - (q15_t)0x7641, (q15_t)0xcf05, (q15_t)0x763f, (q15_t)0xceff, (q15_t)0x763c, (q15_t)0xcef9, (q15_t)0x763a, (q15_t)0xcef3, - (q15_t)0x7638, (q15_t)0xceee, (q15_t)0x7635, (q15_t)0xcee8, (q15_t)0x7633, (q15_t)0xcee2, (q15_t)0x7630, (q15_t)0xcedc, - (q15_t)0x762e, (q15_t)0xced6, (q15_t)0x762b, (q15_t)0xced1, (q15_t)0x7629, (q15_t)0xcecb, (q15_t)0x7627, (q15_t)0xcec5, - (q15_t)0x7624, (q15_t)0xcebf, (q15_t)0x7622, (q15_t)0xceb9, (q15_t)0x761f, (q15_t)0xceb4, (q15_t)0x761d, (q15_t)0xceae, - (q15_t)0x761b, (q15_t)0xcea8, (q15_t)0x7618, (q15_t)0xcea2, (q15_t)0x7616, (q15_t)0xce9c, (q15_t)0x7613, (q15_t)0xce97, - (q15_t)0x7611, (q15_t)0xce91, (q15_t)0x760e, (q15_t)0xce8b, (q15_t)0x760c, (q15_t)0xce85, (q15_t)0x760a, (q15_t)0xce7f, - (q15_t)0x7607, (q15_t)0xce7a, (q15_t)0x7605, (q15_t)0xce74, (q15_t)0x7602, (q15_t)0xce6e, (q15_t)0x7600, (q15_t)0xce68, - (q15_t)0x75fd, (q15_t)0xce62, (q15_t)0x75fb, (q15_t)0xce5d, (q15_t)0x75f9, (q15_t)0xce57, (q15_t)0x75f6, (q15_t)0xce51, - (q15_t)0x75f4, (q15_t)0xce4b, (q15_t)0x75f1, (q15_t)0xce45, (q15_t)0x75ef, (q15_t)0xce40, (q15_t)0x75ec, (q15_t)0xce3a, - (q15_t)0x75ea, (q15_t)0xce34, (q15_t)0x75e7, (q15_t)0xce2e, (q15_t)0x75e5, (q15_t)0xce28, (q15_t)0x75e3, (q15_t)0xce23, - (q15_t)0x75e0, (q15_t)0xce1d, (q15_t)0x75de, (q15_t)0xce17, (q15_t)0x75db, (q15_t)0xce11, (q15_t)0x75d9, (q15_t)0xce0c, - (q15_t)0x75d6, (q15_t)0xce06, (q15_t)0x75d4, (q15_t)0xce00, (q15_t)0x75d1, (q15_t)0xcdfa, (q15_t)0x75cf, (q15_t)0xcdf4, - (q15_t)0x75cc, (q15_t)0xcdef, (q15_t)0x75ca, (q15_t)0xcde9, (q15_t)0x75c8, (q15_t)0xcde3, (q15_t)0x75c5, (q15_t)0xcddd, - (q15_t)0x75c3, (q15_t)0xcdd8, (q15_t)0x75c0, (q15_t)0xcdd2, (q15_t)0x75be, (q15_t)0xcdcc, (q15_t)0x75bb, (q15_t)0xcdc6, - (q15_t)0x75b9, (q15_t)0xcdc0, (q15_t)0x75b6, (q15_t)0xcdbb, (q15_t)0x75b4, (q15_t)0xcdb5, (q15_t)0x75b1, (q15_t)0xcdaf, - (q15_t)0x75af, (q15_t)0xcda9, (q15_t)0x75ac, (q15_t)0xcda3, (q15_t)0x75aa, (q15_t)0xcd9e, (q15_t)0x75a7, (q15_t)0xcd98, - (q15_t)0x75a5, (q15_t)0xcd92, (q15_t)0x75a3, (q15_t)0xcd8c, (q15_t)0x75a0, (q15_t)0xcd87, (q15_t)0x759e, (q15_t)0xcd81, - (q15_t)0x759b, (q15_t)0xcd7b, (q15_t)0x7599, (q15_t)0xcd75, (q15_t)0x7596, (q15_t)0xcd70, (q15_t)0x7594, (q15_t)0xcd6a, - (q15_t)0x7591, (q15_t)0xcd64, (q15_t)0x758f, (q15_t)0xcd5e, (q15_t)0x758c, (q15_t)0xcd58, (q15_t)0x758a, (q15_t)0xcd53, - (q15_t)0x7587, (q15_t)0xcd4d, (q15_t)0x7585, (q15_t)0xcd47, (q15_t)0x7582, (q15_t)0xcd41, (q15_t)0x7580, (q15_t)0xcd3c, - (q15_t)0x757d, (q15_t)0xcd36, (q15_t)0x757b, (q15_t)0xcd30, (q15_t)0x7578, (q15_t)0xcd2a, (q15_t)0x7576, (q15_t)0xcd25, - (q15_t)0x7573, (q15_t)0xcd1f, (q15_t)0x7571, (q15_t)0xcd19, (q15_t)0x756e, (q15_t)0xcd13, (q15_t)0x756c, (q15_t)0xcd0d, - (q15_t)0x7569, (q15_t)0xcd08, (q15_t)0x7567, (q15_t)0xcd02, (q15_t)0x7564, (q15_t)0xccfc, (q15_t)0x7562, (q15_t)0xccf6, - (q15_t)0x755f, (q15_t)0xccf1, (q15_t)0x755d, (q15_t)0xcceb, (q15_t)0x755a, (q15_t)0xcce5, (q15_t)0x7558, (q15_t)0xccdf, - (q15_t)0x7555, (q15_t)0xccda, (q15_t)0x7553, (q15_t)0xccd4, (q15_t)0x7550, (q15_t)0xccce, (q15_t)0x754e, (q15_t)0xccc8, - (q15_t)0x754b, (q15_t)0xccc3, (q15_t)0x7549, (q15_t)0xccbd, (q15_t)0x7546, (q15_t)0xccb7, (q15_t)0x7544, (q15_t)0xccb1, - (q15_t)0x7541, (q15_t)0xccac, (q15_t)0x753f, (q15_t)0xcca6, (q15_t)0x753c, (q15_t)0xcca0, (q15_t)0x753a, (q15_t)0xcc9a, - (q15_t)0x7537, (q15_t)0xcc95, (q15_t)0x7535, (q15_t)0xcc8f, (q15_t)0x7532, (q15_t)0xcc89, (q15_t)0x752f, (q15_t)0xcc83, - (q15_t)0x752d, (q15_t)0xcc7e, (q15_t)0x752a, (q15_t)0xcc78, (q15_t)0x7528, (q15_t)0xcc72, (q15_t)0x7525, (q15_t)0xcc6c, - (q15_t)0x7523, (q15_t)0xcc67, (q15_t)0x7520, (q15_t)0xcc61, (q15_t)0x751e, (q15_t)0xcc5b, (q15_t)0x751b, (q15_t)0xcc55, - (q15_t)0x7519, (q15_t)0xcc50, (q15_t)0x7516, (q15_t)0xcc4a, (q15_t)0x7514, (q15_t)0xcc44, (q15_t)0x7511, (q15_t)0xcc3e, - (q15_t)0x750f, (q15_t)0xcc39, (q15_t)0x750c, (q15_t)0xcc33, (q15_t)0x7509, (q15_t)0xcc2d, (q15_t)0x7507, (q15_t)0xcc27, - (q15_t)0x7504, (q15_t)0xcc22, (q15_t)0x7502, (q15_t)0xcc1c, (q15_t)0x74ff, (q15_t)0xcc16, (q15_t)0x74fd, (q15_t)0xcc10, - (q15_t)0x74fa, (q15_t)0xcc0b, (q15_t)0x74f8, (q15_t)0xcc05, (q15_t)0x74f5, (q15_t)0xcbff, (q15_t)0x74f2, (q15_t)0xcbf9, - (q15_t)0x74f0, (q15_t)0xcbf4, (q15_t)0x74ed, (q15_t)0xcbee, (q15_t)0x74eb, (q15_t)0xcbe8, (q15_t)0x74e8, (q15_t)0xcbe2, - (q15_t)0x74e6, (q15_t)0xcbdd, (q15_t)0x74e3, (q15_t)0xcbd7, (q15_t)0x74e1, (q15_t)0xcbd1, (q15_t)0x74de, (q15_t)0xcbcb, - (q15_t)0x74db, (q15_t)0xcbc6, (q15_t)0x74d9, (q15_t)0xcbc0, (q15_t)0x74d6, (q15_t)0xcbba, (q15_t)0x74d4, (q15_t)0xcbb5, - (q15_t)0x74d1, (q15_t)0xcbaf, (q15_t)0x74cf, (q15_t)0xcba9, (q15_t)0x74cc, (q15_t)0xcba3, (q15_t)0x74c9, (q15_t)0xcb9e, - (q15_t)0x74c7, (q15_t)0xcb98, (q15_t)0x74c4, (q15_t)0xcb92, (q15_t)0x74c2, (q15_t)0xcb8c, (q15_t)0x74bf, (q15_t)0xcb87, - (q15_t)0x74bd, (q15_t)0xcb81, (q15_t)0x74ba, (q15_t)0xcb7b, (q15_t)0x74b7, (q15_t)0xcb75, (q15_t)0x74b5, (q15_t)0xcb70, - (q15_t)0x74b2, (q15_t)0xcb6a, (q15_t)0x74b0, (q15_t)0xcb64, (q15_t)0x74ad, (q15_t)0xcb5f, (q15_t)0x74ab, (q15_t)0xcb59, - (q15_t)0x74a8, (q15_t)0xcb53, (q15_t)0x74a5, (q15_t)0xcb4d, (q15_t)0x74a3, (q15_t)0xcb48, (q15_t)0x74a0, (q15_t)0xcb42, - (q15_t)0x749e, (q15_t)0xcb3c, (q15_t)0x749b, (q15_t)0xcb36, (q15_t)0x7498, (q15_t)0xcb31, (q15_t)0x7496, (q15_t)0xcb2b, - (q15_t)0x7493, (q15_t)0xcb25, (q15_t)0x7491, (q15_t)0xcb20, (q15_t)0x748e, (q15_t)0xcb1a, (q15_t)0x748b, (q15_t)0xcb14, - (q15_t)0x7489, (q15_t)0xcb0e, (q15_t)0x7486, (q15_t)0xcb09, (q15_t)0x7484, (q15_t)0xcb03, (q15_t)0x7481, (q15_t)0xcafd, - (q15_t)0x747e, (q15_t)0xcaf8, (q15_t)0x747c, (q15_t)0xcaf2, (q15_t)0x7479, (q15_t)0xcaec, (q15_t)0x7477, (q15_t)0xcae6, - (q15_t)0x7474, (q15_t)0xcae1, (q15_t)0x7471, (q15_t)0xcadb, (q15_t)0x746f, (q15_t)0xcad5, (q15_t)0x746c, (q15_t)0xcad0, - (q15_t)0x746a, (q15_t)0xcaca, (q15_t)0x7467, (q15_t)0xcac4, (q15_t)0x7464, (q15_t)0xcabe, (q15_t)0x7462, (q15_t)0xcab9, - (q15_t)0x745f, (q15_t)0xcab3, (q15_t)0x745c, (q15_t)0xcaad, (q15_t)0x745a, (q15_t)0xcaa8, (q15_t)0x7457, (q15_t)0xcaa2, - (q15_t)0x7455, (q15_t)0xca9c, (q15_t)0x7452, (q15_t)0xca96, (q15_t)0x744f, (q15_t)0xca91, (q15_t)0x744d, (q15_t)0xca8b, - (q15_t)0x744a, (q15_t)0xca85, (q15_t)0x7448, (q15_t)0xca80, (q15_t)0x7445, (q15_t)0xca7a, (q15_t)0x7442, (q15_t)0xca74, - (q15_t)0x7440, (q15_t)0xca6e, (q15_t)0x743d, (q15_t)0xca69, (q15_t)0x743a, (q15_t)0xca63, (q15_t)0x7438, (q15_t)0xca5d, - (q15_t)0x7435, (q15_t)0xca58, (q15_t)0x7432, (q15_t)0xca52, (q15_t)0x7430, (q15_t)0xca4c, (q15_t)0x742d, (q15_t)0xca46, - (q15_t)0x742b, (q15_t)0xca41, (q15_t)0x7428, (q15_t)0xca3b, (q15_t)0x7425, (q15_t)0xca35, (q15_t)0x7423, (q15_t)0xca30, - (q15_t)0x7420, (q15_t)0xca2a, (q15_t)0x741d, (q15_t)0xca24, (q15_t)0x741b, (q15_t)0xca1f, (q15_t)0x7418, (q15_t)0xca19, - (q15_t)0x7415, (q15_t)0xca13, (q15_t)0x7413, (q15_t)0xca0d, (q15_t)0x7410, (q15_t)0xca08, (q15_t)0x740d, (q15_t)0xca02, - (q15_t)0x740b, (q15_t)0xc9fc, (q15_t)0x7408, (q15_t)0xc9f7, (q15_t)0x7406, (q15_t)0xc9f1, (q15_t)0x7403, (q15_t)0xc9eb, - (q15_t)0x7400, (q15_t)0xc9e6, (q15_t)0x73fe, (q15_t)0xc9e0, (q15_t)0x73fb, (q15_t)0xc9da, (q15_t)0x73f8, (q15_t)0xc9d5, - (q15_t)0x73f6, (q15_t)0xc9cf, (q15_t)0x73f3, (q15_t)0xc9c9, (q15_t)0x73f0, (q15_t)0xc9c3, (q15_t)0x73ee, (q15_t)0xc9be, - (q15_t)0x73eb, (q15_t)0xc9b8, (q15_t)0x73e8, (q15_t)0xc9b2, (q15_t)0x73e6, (q15_t)0xc9ad, (q15_t)0x73e3, (q15_t)0xc9a7, - (q15_t)0x73e0, (q15_t)0xc9a1, (q15_t)0x73de, (q15_t)0xc99c, (q15_t)0x73db, (q15_t)0xc996, (q15_t)0x73d8, (q15_t)0xc990, - (q15_t)0x73d6, (q15_t)0xc98b, (q15_t)0x73d3, (q15_t)0xc985, (q15_t)0x73d0, (q15_t)0xc97f, (q15_t)0x73ce, (q15_t)0xc97a, - (q15_t)0x73cb, (q15_t)0xc974, (q15_t)0x73c8, (q15_t)0xc96e, (q15_t)0x73c6, (q15_t)0xc968, (q15_t)0x73c3, (q15_t)0xc963, - (q15_t)0x73c0, (q15_t)0xc95d, (q15_t)0x73bd, (q15_t)0xc957, (q15_t)0x73bb, (q15_t)0xc952, (q15_t)0x73b8, (q15_t)0xc94c, - (q15_t)0x73b5, (q15_t)0xc946, (q15_t)0x73b3, (q15_t)0xc941, (q15_t)0x73b0, (q15_t)0xc93b, (q15_t)0x73ad, (q15_t)0xc935, - (q15_t)0x73ab, (q15_t)0xc930, (q15_t)0x73a8, (q15_t)0xc92a, (q15_t)0x73a5, (q15_t)0xc924, (q15_t)0x73a3, (q15_t)0xc91f, - (q15_t)0x73a0, (q15_t)0xc919, (q15_t)0x739d, (q15_t)0xc913, (q15_t)0x739b, (q15_t)0xc90e, (q15_t)0x7398, (q15_t)0xc908, - (q15_t)0x7395, (q15_t)0xc902, (q15_t)0x7392, (q15_t)0xc8fd, (q15_t)0x7390, (q15_t)0xc8f7, (q15_t)0x738d, (q15_t)0xc8f1, - (q15_t)0x738a, (q15_t)0xc8ec, (q15_t)0x7388, (q15_t)0xc8e6, (q15_t)0x7385, (q15_t)0xc8e0, (q15_t)0x7382, (q15_t)0xc8db, - (q15_t)0x737f, (q15_t)0xc8d5, (q15_t)0x737d, (q15_t)0xc8cf, (q15_t)0x737a, (q15_t)0xc8ca, (q15_t)0x7377, (q15_t)0xc8c4, - (q15_t)0x7375, (q15_t)0xc8be, (q15_t)0x7372, (q15_t)0xc8b9, (q15_t)0x736f, (q15_t)0xc8b3, (q15_t)0x736c, (q15_t)0xc8ad, - (q15_t)0x736a, (q15_t)0xc8a8, (q15_t)0x7367, (q15_t)0xc8a2, (q15_t)0x7364, (q15_t)0xc89c, (q15_t)0x7362, (q15_t)0xc897, - (q15_t)0x735f, (q15_t)0xc891, (q15_t)0x735c, (q15_t)0xc88b, (q15_t)0x7359, (q15_t)0xc886, (q15_t)0x7357, (q15_t)0xc880, - (q15_t)0x7354, (q15_t)0xc87a, (q15_t)0x7351, (q15_t)0xc875, (q15_t)0x734f, (q15_t)0xc86f, (q15_t)0x734c, (q15_t)0xc869, - (q15_t)0x7349, (q15_t)0xc864, (q15_t)0x7346, (q15_t)0xc85e, (q15_t)0x7344, (q15_t)0xc858, (q15_t)0x7341, (q15_t)0xc853, - (q15_t)0x733e, (q15_t)0xc84d, (q15_t)0x733b, (q15_t)0xc847, (q15_t)0x7339, (q15_t)0xc842, (q15_t)0x7336, (q15_t)0xc83c, - (q15_t)0x7333, (q15_t)0xc836, (q15_t)0x7330, (q15_t)0xc831, (q15_t)0x732e, (q15_t)0xc82b, (q15_t)0x732b, (q15_t)0xc825, - (q15_t)0x7328, (q15_t)0xc820, (q15_t)0x7326, (q15_t)0xc81a, (q15_t)0x7323, (q15_t)0xc814, (q15_t)0x7320, (q15_t)0xc80f, - (q15_t)0x731d, (q15_t)0xc809, (q15_t)0x731b, (q15_t)0xc803, (q15_t)0x7318, (q15_t)0xc7fe, (q15_t)0x7315, (q15_t)0xc7f8, - (q15_t)0x7312, (q15_t)0xc7f3, (q15_t)0x7310, (q15_t)0xc7ed, (q15_t)0x730d, (q15_t)0xc7e7, (q15_t)0x730a, (q15_t)0xc7e2, - (q15_t)0x7307, (q15_t)0xc7dc, (q15_t)0x7305, (q15_t)0xc7d6, (q15_t)0x7302, (q15_t)0xc7d1, (q15_t)0x72ff, (q15_t)0xc7cb, - (q15_t)0x72fc, (q15_t)0xc7c5, (q15_t)0x72f9, (q15_t)0xc7c0, (q15_t)0x72f7, (q15_t)0xc7ba, (q15_t)0x72f4, (q15_t)0xc7b4, - (q15_t)0x72f1, (q15_t)0xc7af, (q15_t)0x72ee, (q15_t)0xc7a9, (q15_t)0x72ec, (q15_t)0xc7a3, (q15_t)0x72e9, (q15_t)0xc79e, - (q15_t)0x72e6, (q15_t)0xc798, (q15_t)0x72e3, (q15_t)0xc793, (q15_t)0x72e1, (q15_t)0xc78d, (q15_t)0x72de, (q15_t)0xc787, - (q15_t)0x72db, (q15_t)0xc782, (q15_t)0x72d8, (q15_t)0xc77c, (q15_t)0x72d5, (q15_t)0xc776, (q15_t)0x72d3, (q15_t)0xc771, - (q15_t)0x72d0, (q15_t)0xc76b, (q15_t)0x72cd, (q15_t)0xc765, (q15_t)0x72ca, (q15_t)0xc760, (q15_t)0x72c8, (q15_t)0xc75a, - (q15_t)0x72c5, (q15_t)0xc755, (q15_t)0x72c2, (q15_t)0xc74f, (q15_t)0x72bf, (q15_t)0xc749, (q15_t)0x72bc, (q15_t)0xc744, - (q15_t)0x72ba, (q15_t)0xc73e, (q15_t)0x72b7, (q15_t)0xc738, (q15_t)0x72b4, (q15_t)0xc733, (q15_t)0x72b1, (q15_t)0xc72d, - (q15_t)0x72af, (q15_t)0xc728, (q15_t)0x72ac, (q15_t)0xc722, (q15_t)0x72a9, (q15_t)0xc71c, (q15_t)0x72a6, (q15_t)0xc717, - (q15_t)0x72a3, (q15_t)0xc711, (q15_t)0x72a1, (q15_t)0xc70b, (q15_t)0x729e, (q15_t)0xc706, (q15_t)0x729b, (q15_t)0xc700, - (q15_t)0x7298, (q15_t)0xc6fa, (q15_t)0x7295, (q15_t)0xc6f5, (q15_t)0x7293, (q15_t)0xc6ef, (q15_t)0x7290, (q15_t)0xc6ea, - (q15_t)0x728d, (q15_t)0xc6e4, (q15_t)0x728a, (q15_t)0xc6de, (q15_t)0x7287, (q15_t)0xc6d9, (q15_t)0x7285, (q15_t)0xc6d3, - (q15_t)0x7282, (q15_t)0xc6ce, (q15_t)0x727f, (q15_t)0xc6c8, (q15_t)0x727c, (q15_t)0xc6c2, (q15_t)0x7279, (q15_t)0xc6bd, - (q15_t)0x7276, (q15_t)0xc6b7, (q15_t)0x7274, (q15_t)0xc6b1, (q15_t)0x7271, (q15_t)0xc6ac, (q15_t)0x726e, (q15_t)0xc6a6, - (q15_t)0x726b, (q15_t)0xc6a1, (q15_t)0x7268, (q15_t)0xc69b, (q15_t)0x7266, (q15_t)0xc695, (q15_t)0x7263, (q15_t)0xc690, - (q15_t)0x7260, (q15_t)0xc68a, (q15_t)0x725d, (q15_t)0xc684, (q15_t)0x725a, (q15_t)0xc67f, (q15_t)0x7257, (q15_t)0xc679, - (q15_t)0x7255, (q15_t)0xc674, (q15_t)0x7252, (q15_t)0xc66e, (q15_t)0x724f, (q15_t)0xc668, (q15_t)0x724c, (q15_t)0xc663, - (q15_t)0x7249, (q15_t)0xc65d, (q15_t)0x7247, (q15_t)0xc658, (q15_t)0x7244, (q15_t)0xc652, (q15_t)0x7241, (q15_t)0xc64c, - (q15_t)0x723e, (q15_t)0xc647, (q15_t)0x723b, (q15_t)0xc641, (q15_t)0x7238, (q15_t)0xc63c, (q15_t)0x7236, (q15_t)0xc636, - (q15_t)0x7233, (q15_t)0xc630, (q15_t)0x7230, (q15_t)0xc62b, (q15_t)0x722d, (q15_t)0xc625, (q15_t)0x722a, (q15_t)0xc620, - (q15_t)0x7227, (q15_t)0xc61a, (q15_t)0x7224, (q15_t)0xc614, (q15_t)0x7222, (q15_t)0xc60f, (q15_t)0x721f, (q15_t)0xc609, - (q15_t)0x721c, (q15_t)0xc603, (q15_t)0x7219, (q15_t)0xc5fe, (q15_t)0x7216, (q15_t)0xc5f8, (q15_t)0x7213, (q15_t)0xc5f3, - (q15_t)0x7211, (q15_t)0xc5ed, (q15_t)0x720e, (q15_t)0xc5e7, (q15_t)0x720b, (q15_t)0xc5e2, (q15_t)0x7208, (q15_t)0xc5dc, - (q15_t)0x7205, (q15_t)0xc5d7, (q15_t)0x7202, (q15_t)0xc5d1, (q15_t)0x71ff, (q15_t)0xc5cc, (q15_t)0x71fd, (q15_t)0xc5c6, - (q15_t)0x71fa, (q15_t)0xc5c0, (q15_t)0x71f7, (q15_t)0xc5bb, (q15_t)0x71f4, (q15_t)0xc5b5, (q15_t)0x71f1, (q15_t)0xc5b0, - (q15_t)0x71ee, (q15_t)0xc5aa, (q15_t)0x71eb, (q15_t)0xc5a4, (q15_t)0x71e9, (q15_t)0xc59f, (q15_t)0x71e6, (q15_t)0xc599, - (q15_t)0x71e3, (q15_t)0xc594, (q15_t)0x71e0, (q15_t)0xc58e, (q15_t)0x71dd, (q15_t)0xc588, (q15_t)0x71da, (q15_t)0xc583, - (q15_t)0x71d7, (q15_t)0xc57d, (q15_t)0x71d4, (q15_t)0xc578, (q15_t)0x71d2, (q15_t)0xc572, (q15_t)0x71cf, (q15_t)0xc56c, - (q15_t)0x71cc, (q15_t)0xc567, (q15_t)0x71c9, (q15_t)0xc561, (q15_t)0x71c6, (q15_t)0xc55c, (q15_t)0x71c3, (q15_t)0xc556, - (q15_t)0x71c0, (q15_t)0xc551, (q15_t)0x71bd, (q15_t)0xc54b, (q15_t)0x71bb, (q15_t)0xc545, (q15_t)0x71b8, (q15_t)0xc540, - (q15_t)0x71b5, (q15_t)0xc53a, (q15_t)0x71b2, (q15_t)0xc535, (q15_t)0x71af, (q15_t)0xc52f, (q15_t)0x71ac, (q15_t)0xc529, - (q15_t)0x71a9, (q15_t)0xc524, (q15_t)0x71a6, (q15_t)0xc51e, (q15_t)0x71a3, (q15_t)0xc519, (q15_t)0x71a1, (q15_t)0xc513, - (q15_t)0x719e, (q15_t)0xc50e, (q15_t)0x719b, (q15_t)0xc508, (q15_t)0x7198, (q15_t)0xc502, (q15_t)0x7195, (q15_t)0xc4fd, - (q15_t)0x7192, (q15_t)0xc4f7, (q15_t)0x718f, (q15_t)0xc4f2, (q15_t)0x718c, (q15_t)0xc4ec, (q15_t)0x7189, (q15_t)0xc4e7, - (q15_t)0x7186, (q15_t)0xc4e1, (q15_t)0x7184, (q15_t)0xc4db, (q15_t)0x7181, (q15_t)0xc4d6, (q15_t)0x717e, (q15_t)0xc4d0, - (q15_t)0x717b, (q15_t)0xc4cb, (q15_t)0x7178, (q15_t)0xc4c5, (q15_t)0x7175, (q15_t)0xc4c0, (q15_t)0x7172, (q15_t)0xc4ba, - (q15_t)0x716f, (q15_t)0xc4b4, (q15_t)0x716c, (q15_t)0xc4af, (q15_t)0x7169, (q15_t)0xc4a9, (q15_t)0x7167, (q15_t)0xc4a4, - (q15_t)0x7164, (q15_t)0xc49e, (q15_t)0x7161, (q15_t)0xc499, (q15_t)0x715e, (q15_t)0xc493, (q15_t)0x715b, (q15_t)0xc48d, - (q15_t)0x7158, (q15_t)0xc488, (q15_t)0x7155, (q15_t)0xc482, (q15_t)0x7152, (q15_t)0xc47d, (q15_t)0x714f, (q15_t)0xc477, - (q15_t)0x714c, (q15_t)0xc472, (q15_t)0x7149, (q15_t)0xc46c, (q15_t)0x7146, (q15_t)0xc467, (q15_t)0x7143, (q15_t)0xc461, - (q15_t)0x7141, (q15_t)0xc45b, (q15_t)0x713e, (q15_t)0xc456, (q15_t)0x713b, (q15_t)0xc450, (q15_t)0x7138, (q15_t)0xc44b, - (q15_t)0x7135, (q15_t)0xc445, (q15_t)0x7132, (q15_t)0xc440, (q15_t)0x712f, (q15_t)0xc43a, (q15_t)0x712c, (q15_t)0xc434, - (q15_t)0x7129, (q15_t)0xc42f, (q15_t)0x7126, (q15_t)0xc429, (q15_t)0x7123, (q15_t)0xc424, (q15_t)0x7120, (q15_t)0xc41e, - (q15_t)0x711d, (q15_t)0xc419, (q15_t)0x711a, (q15_t)0xc413, (q15_t)0x7117, (q15_t)0xc40e, (q15_t)0x7114, (q15_t)0xc408, - (q15_t)0x7112, (q15_t)0xc403, (q15_t)0x710f, (q15_t)0xc3fd, (q15_t)0x710c, (q15_t)0xc3f7, (q15_t)0x7109, (q15_t)0xc3f2, - (q15_t)0x7106, (q15_t)0xc3ec, (q15_t)0x7103, (q15_t)0xc3e7, (q15_t)0x7100, (q15_t)0xc3e1, (q15_t)0x70fd, (q15_t)0xc3dc, - (q15_t)0x70fa, (q15_t)0xc3d6, (q15_t)0x70f7, (q15_t)0xc3d1, (q15_t)0x70f4, (q15_t)0xc3cb, (q15_t)0x70f1, (q15_t)0xc3c5, - (q15_t)0x70ee, (q15_t)0xc3c0, (q15_t)0x70eb, (q15_t)0xc3ba, (q15_t)0x70e8, (q15_t)0xc3b5, (q15_t)0x70e5, (q15_t)0xc3af, - (q15_t)0x70e2, (q15_t)0xc3aa, (q15_t)0x70df, (q15_t)0xc3a4, (q15_t)0x70dc, (q15_t)0xc39f, (q15_t)0x70d9, (q15_t)0xc399, - (q15_t)0x70d6, (q15_t)0xc394, (q15_t)0x70d3, (q15_t)0xc38e, (q15_t)0x70d1, (q15_t)0xc389, (q15_t)0x70ce, (q15_t)0xc383, - (q15_t)0x70cb, (q15_t)0xc37d, (q15_t)0x70c8, (q15_t)0xc378, (q15_t)0x70c5, (q15_t)0xc372, (q15_t)0x70c2, (q15_t)0xc36d, - (q15_t)0x70bf, (q15_t)0xc367, (q15_t)0x70bc, (q15_t)0xc362, (q15_t)0x70b9, (q15_t)0xc35c, (q15_t)0x70b6, (q15_t)0xc357, - (q15_t)0x70b3, (q15_t)0xc351, (q15_t)0x70b0, (q15_t)0xc34c, (q15_t)0x70ad, (q15_t)0xc346, (q15_t)0x70aa, (q15_t)0xc341, - (q15_t)0x70a7, (q15_t)0xc33b, (q15_t)0x70a4, (q15_t)0xc336, (q15_t)0x70a1, (q15_t)0xc330, (q15_t)0x709e, (q15_t)0xc32a, - (q15_t)0x709b, (q15_t)0xc325, (q15_t)0x7098, (q15_t)0xc31f, (q15_t)0x7095, (q15_t)0xc31a, (q15_t)0x7092, (q15_t)0xc314, - (q15_t)0x708f, (q15_t)0xc30f, (q15_t)0x708c, (q15_t)0xc309, (q15_t)0x7089, (q15_t)0xc304, (q15_t)0x7086, (q15_t)0xc2fe, - (q15_t)0x7083, (q15_t)0xc2f9, (q15_t)0x7080, (q15_t)0xc2f3, (q15_t)0x707d, (q15_t)0xc2ee, (q15_t)0x707a, (q15_t)0xc2e8, - (q15_t)0x7077, (q15_t)0xc2e3, (q15_t)0x7074, (q15_t)0xc2dd, (q15_t)0x7071, (q15_t)0xc2d8, (q15_t)0x706e, (q15_t)0xc2d2, - (q15_t)0x706b, (q15_t)0xc2cd, (q15_t)0x7068, (q15_t)0xc2c7, (q15_t)0x7065, (q15_t)0xc2c2, (q15_t)0x7062, (q15_t)0xc2bc, - (q15_t)0x705f, (q15_t)0xc2b7, (q15_t)0x705c, (q15_t)0xc2b1, (q15_t)0x7059, (q15_t)0xc2ab, (q15_t)0x7056, (q15_t)0xc2a6, - (q15_t)0x7053, (q15_t)0xc2a0, (q15_t)0x7050, (q15_t)0xc29b, (q15_t)0x704d, (q15_t)0xc295, (q15_t)0x704a, (q15_t)0xc290, - (q15_t)0x7047, (q15_t)0xc28a, (q15_t)0x7044, (q15_t)0xc285, (q15_t)0x7041, (q15_t)0xc27f, (q15_t)0x703e, (q15_t)0xc27a, - (q15_t)0x703b, (q15_t)0xc274, (q15_t)0x7038, (q15_t)0xc26f, (q15_t)0x7035, (q15_t)0xc269, (q15_t)0x7032, (q15_t)0xc264, - (q15_t)0x702f, (q15_t)0xc25e, (q15_t)0x702c, (q15_t)0xc259, (q15_t)0x7029, (q15_t)0xc253, (q15_t)0x7026, (q15_t)0xc24e, - (q15_t)0x7023, (q15_t)0xc248, (q15_t)0x7020, (q15_t)0xc243, (q15_t)0x701d, (q15_t)0xc23d, (q15_t)0x7019, (q15_t)0xc238, - (q15_t)0x7016, (q15_t)0xc232, (q15_t)0x7013, (q15_t)0xc22d, (q15_t)0x7010, (q15_t)0xc227, (q15_t)0x700d, (q15_t)0xc222, - (q15_t)0x700a, (q15_t)0xc21c, (q15_t)0x7007, (q15_t)0xc217, (q15_t)0x7004, (q15_t)0xc211, (q15_t)0x7001, (q15_t)0xc20c, - (q15_t)0x6ffe, (q15_t)0xc206, (q15_t)0x6ffb, (q15_t)0xc201, (q15_t)0x6ff8, (q15_t)0xc1fb, (q15_t)0x6ff5, (q15_t)0xc1f6, - (q15_t)0x6ff2, (q15_t)0xc1f0, (q15_t)0x6fef, (q15_t)0xc1eb, (q15_t)0x6fec, (q15_t)0xc1e5, (q15_t)0x6fe9, (q15_t)0xc1e0, - (q15_t)0x6fe6, (q15_t)0xc1da, (q15_t)0x6fe3, (q15_t)0xc1d5, (q15_t)0x6fe0, (q15_t)0xc1cf, (q15_t)0x6fdd, (q15_t)0xc1ca, - (q15_t)0x6fda, (q15_t)0xc1c4, (q15_t)0x6fd6, (q15_t)0xc1bf, (q15_t)0x6fd3, (q15_t)0xc1b9, (q15_t)0x6fd0, (q15_t)0xc1b4, - (q15_t)0x6fcd, (q15_t)0xc1ae, (q15_t)0x6fca, (q15_t)0xc1a9, (q15_t)0x6fc7, (q15_t)0xc1a3, (q15_t)0x6fc4, (q15_t)0xc19e, - (q15_t)0x6fc1, (q15_t)0xc198, (q15_t)0x6fbe, (q15_t)0xc193, (q15_t)0x6fbb, (q15_t)0xc18d, (q15_t)0x6fb8, (q15_t)0xc188, - (q15_t)0x6fb5, (q15_t)0xc183, (q15_t)0x6fb2, (q15_t)0xc17d, (q15_t)0x6faf, (q15_t)0xc178, (q15_t)0x6fac, (q15_t)0xc172, - (q15_t)0x6fa9, (q15_t)0xc16d, (q15_t)0x6fa5, (q15_t)0xc167, (q15_t)0x6fa2, (q15_t)0xc162, (q15_t)0x6f9f, (q15_t)0xc15c, - (q15_t)0x6f9c, (q15_t)0xc157, (q15_t)0x6f99, (q15_t)0xc151, (q15_t)0x6f96, (q15_t)0xc14c, (q15_t)0x6f93, (q15_t)0xc146, - (q15_t)0x6f90, (q15_t)0xc141, (q15_t)0x6f8d, (q15_t)0xc13b, (q15_t)0x6f8a, (q15_t)0xc136, (q15_t)0x6f87, (q15_t)0xc130, - (q15_t)0x6f84, (q15_t)0xc12b, (q15_t)0x6f81, (q15_t)0xc125, (q15_t)0x6f7d, (q15_t)0xc120, (q15_t)0x6f7a, (q15_t)0xc11a, - (q15_t)0x6f77, (q15_t)0xc115, (q15_t)0x6f74, (q15_t)0xc10f, (q15_t)0x6f71, (q15_t)0xc10a, (q15_t)0x6f6e, (q15_t)0xc105, - (q15_t)0x6f6b, (q15_t)0xc0ff, (q15_t)0x6f68, (q15_t)0xc0fa, (q15_t)0x6f65, (q15_t)0xc0f4, (q15_t)0x6f62, (q15_t)0xc0ef, - (q15_t)0x6f5f, (q15_t)0xc0e9, (q15_t)0x6f5b, (q15_t)0xc0e4, (q15_t)0x6f58, (q15_t)0xc0de, (q15_t)0x6f55, (q15_t)0xc0d9, - (q15_t)0x6f52, (q15_t)0xc0d3, (q15_t)0x6f4f, (q15_t)0xc0ce, (q15_t)0x6f4c, (q15_t)0xc0c8, (q15_t)0x6f49, (q15_t)0xc0c3, - (q15_t)0x6f46, (q15_t)0xc0bd, (q15_t)0x6f43, (q15_t)0xc0b8, (q15_t)0x6f3f, (q15_t)0xc0b3, (q15_t)0x6f3c, (q15_t)0xc0ad, - (q15_t)0x6f39, (q15_t)0xc0a8, (q15_t)0x6f36, (q15_t)0xc0a2, (q15_t)0x6f33, (q15_t)0xc09d, (q15_t)0x6f30, (q15_t)0xc097, - (q15_t)0x6f2d, (q15_t)0xc092, (q15_t)0x6f2a, (q15_t)0xc08c, (q15_t)0x6f27, (q15_t)0xc087, (q15_t)0x6f23, (q15_t)0xc081, - (q15_t)0x6f20, (q15_t)0xc07c, (q15_t)0x6f1d, (q15_t)0xc077, (q15_t)0x6f1a, (q15_t)0xc071, (q15_t)0x6f17, (q15_t)0xc06c, - (q15_t)0x6f14, (q15_t)0xc066, (q15_t)0x6f11, (q15_t)0xc061, (q15_t)0x6f0e, (q15_t)0xc05b, (q15_t)0x6f0b, (q15_t)0xc056, - (q15_t)0x6f07, (q15_t)0xc050, (q15_t)0x6f04, (q15_t)0xc04b, (q15_t)0x6f01, (q15_t)0xc045, (q15_t)0x6efe, (q15_t)0xc040, - (q15_t)0x6efb, (q15_t)0xc03b, (q15_t)0x6ef8, (q15_t)0xc035, (q15_t)0x6ef5, (q15_t)0xc030, (q15_t)0x6ef1, (q15_t)0xc02a, - (q15_t)0x6eee, (q15_t)0xc025, (q15_t)0x6eeb, (q15_t)0xc01f, (q15_t)0x6ee8, (q15_t)0xc01a, (q15_t)0x6ee5, (q15_t)0xc014, - (q15_t)0x6ee2, (q15_t)0xc00f, (q15_t)0x6edf, (q15_t)0xc00a, (q15_t)0x6edc, (q15_t)0xc004, (q15_t)0x6ed8, (q15_t)0xbfff, - (q15_t)0x6ed5, (q15_t)0xbff9, (q15_t)0x6ed2, (q15_t)0xbff4, (q15_t)0x6ecf, (q15_t)0xbfee, (q15_t)0x6ecc, (q15_t)0xbfe9, - (q15_t)0x6ec9, (q15_t)0xbfe3, (q15_t)0x6ec6, (q15_t)0xbfde, (q15_t)0x6ec2, (q15_t)0xbfd9, (q15_t)0x6ebf, (q15_t)0xbfd3, - (q15_t)0x6ebc, (q15_t)0xbfce, (q15_t)0x6eb9, (q15_t)0xbfc8, (q15_t)0x6eb6, (q15_t)0xbfc3, (q15_t)0x6eb3, (q15_t)0xbfbd, - (q15_t)0x6eaf, (q15_t)0xbfb8, (q15_t)0x6eac, (q15_t)0xbfb3, (q15_t)0x6ea9, (q15_t)0xbfad, (q15_t)0x6ea6, (q15_t)0xbfa8, - (q15_t)0x6ea3, (q15_t)0xbfa2, (q15_t)0x6ea0, (q15_t)0xbf9d, (q15_t)0x6e9c, (q15_t)0xbf97, (q15_t)0x6e99, (q15_t)0xbf92, - (q15_t)0x6e96, (q15_t)0xbf8d, (q15_t)0x6e93, (q15_t)0xbf87, (q15_t)0x6e90, (q15_t)0xbf82, (q15_t)0x6e8d, (q15_t)0xbf7c, - (q15_t)0x6e89, (q15_t)0xbf77, (q15_t)0x6e86, (q15_t)0xbf71, (q15_t)0x6e83, (q15_t)0xbf6c, (q15_t)0x6e80, (q15_t)0xbf67, - (q15_t)0x6e7d, (q15_t)0xbf61, (q15_t)0x6e7a, (q15_t)0xbf5c, (q15_t)0x6e76, (q15_t)0xbf56, (q15_t)0x6e73, (q15_t)0xbf51, - (q15_t)0x6e70, (q15_t)0xbf4b, (q15_t)0x6e6d, (q15_t)0xbf46, (q15_t)0x6e6a, (q15_t)0xbf41, (q15_t)0x6e67, (q15_t)0xbf3b, - (q15_t)0x6e63, (q15_t)0xbf36, (q15_t)0x6e60, (q15_t)0xbf30, (q15_t)0x6e5d, (q15_t)0xbf2b, (q15_t)0x6e5a, (q15_t)0xbf26, - (q15_t)0x6e57, (q15_t)0xbf20, (q15_t)0x6e53, (q15_t)0xbf1b, (q15_t)0x6e50, (q15_t)0xbf15, (q15_t)0x6e4d, (q15_t)0xbf10, - (q15_t)0x6e4a, (q15_t)0xbf0a, (q15_t)0x6e47, (q15_t)0xbf05, (q15_t)0x6e44, (q15_t)0xbf00, (q15_t)0x6e40, (q15_t)0xbefa, - (q15_t)0x6e3d, (q15_t)0xbef5, (q15_t)0x6e3a, (q15_t)0xbeef, (q15_t)0x6e37, (q15_t)0xbeea, (q15_t)0x6e34, (q15_t)0xbee5, - (q15_t)0x6e30, (q15_t)0xbedf, (q15_t)0x6e2d, (q15_t)0xbeda, (q15_t)0x6e2a, (q15_t)0xbed4, (q15_t)0x6e27, (q15_t)0xbecf, - (q15_t)0x6e24, (q15_t)0xbeca, (q15_t)0x6e20, (q15_t)0xbec4, (q15_t)0x6e1d, (q15_t)0xbebf, (q15_t)0x6e1a, (q15_t)0xbeb9, - (q15_t)0x6e17, (q15_t)0xbeb4, (q15_t)0x6e14, (q15_t)0xbeae, (q15_t)0x6e10, (q15_t)0xbea9, (q15_t)0x6e0d, (q15_t)0xbea4, - (q15_t)0x6e0a, (q15_t)0xbe9e, (q15_t)0x6e07, (q15_t)0xbe99, (q15_t)0x6e04, (q15_t)0xbe93, (q15_t)0x6e00, (q15_t)0xbe8e, - (q15_t)0x6dfd, (q15_t)0xbe89, (q15_t)0x6dfa, (q15_t)0xbe83, (q15_t)0x6df7, (q15_t)0xbe7e, (q15_t)0x6df3, (q15_t)0xbe78, - (q15_t)0x6df0, (q15_t)0xbe73, (q15_t)0x6ded, (q15_t)0xbe6e, (q15_t)0x6dea, (q15_t)0xbe68, (q15_t)0x6de7, (q15_t)0xbe63, - (q15_t)0x6de3, (q15_t)0xbe5e, (q15_t)0x6de0, (q15_t)0xbe58, (q15_t)0x6ddd, (q15_t)0xbe53, (q15_t)0x6dda, (q15_t)0xbe4d, - (q15_t)0x6dd6, (q15_t)0xbe48, (q15_t)0x6dd3, (q15_t)0xbe43, (q15_t)0x6dd0, (q15_t)0xbe3d, (q15_t)0x6dcd, (q15_t)0xbe38, - (q15_t)0x6dca, (q15_t)0xbe32, (q15_t)0x6dc6, (q15_t)0xbe2d, (q15_t)0x6dc3, (q15_t)0xbe28, (q15_t)0x6dc0, (q15_t)0xbe22, - (q15_t)0x6dbd, (q15_t)0xbe1d, (q15_t)0x6db9, (q15_t)0xbe17, (q15_t)0x6db6, (q15_t)0xbe12, (q15_t)0x6db3, (q15_t)0xbe0d, - (q15_t)0x6db0, (q15_t)0xbe07, (q15_t)0x6dac, (q15_t)0xbe02, (q15_t)0x6da9, (q15_t)0xbdfd, (q15_t)0x6da6, (q15_t)0xbdf7, - (q15_t)0x6da3, (q15_t)0xbdf2, (q15_t)0x6d9f, (q15_t)0xbdec, (q15_t)0x6d9c, (q15_t)0xbde7, (q15_t)0x6d99, (q15_t)0xbde2, - (q15_t)0x6d96, (q15_t)0xbddc, (q15_t)0x6d92, (q15_t)0xbdd7, (q15_t)0x6d8f, (q15_t)0xbdd1, (q15_t)0x6d8c, (q15_t)0xbdcc, - (q15_t)0x6d89, (q15_t)0xbdc7, (q15_t)0x6d85, (q15_t)0xbdc1, (q15_t)0x6d82, (q15_t)0xbdbc, (q15_t)0x6d7f, (q15_t)0xbdb7, - (q15_t)0x6d7c, (q15_t)0xbdb1, (q15_t)0x6d78, (q15_t)0xbdac, (q15_t)0x6d75, (q15_t)0xbda6, (q15_t)0x6d72, (q15_t)0xbda1, - (q15_t)0x6d6f, (q15_t)0xbd9c, (q15_t)0x6d6b, (q15_t)0xbd96, (q15_t)0x6d68, (q15_t)0xbd91, (q15_t)0x6d65, (q15_t)0xbd8c, - (q15_t)0x6d62, (q15_t)0xbd86, (q15_t)0x6d5e, (q15_t)0xbd81, (q15_t)0x6d5b, (q15_t)0xbd7c, (q15_t)0x6d58, (q15_t)0xbd76, - (q15_t)0x6d55, (q15_t)0xbd71, (q15_t)0x6d51, (q15_t)0xbd6b, (q15_t)0x6d4e, (q15_t)0xbd66, (q15_t)0x6d4b, (q15_t)0xbd61, - (q15_t)0x6d48, (q15_t)0xbd5b, (q15_t)0x6d44, (q15_t)0xbd56, (q15_t)0x6d41, (q15_t)0xbd51, (q15_t)0x6d3e, (q15_t)0xbd4b, - (q15_t)0x6d3a, (q15_t)0xbd46, (q15_t)0x6d37, (q15_t)0xbd40, (q15_t)0x6d34, (q15_t)0xbd3b, (q15_t)0x6d31, (q15_t)0xbd36, - (q15_t)0x6d2d, (q15_t)0xbd30, (q15_t)0x6d2a, (q15_t)0xbd2b, (q15_t)0x6d27, (q15_t)0xbd26, (q15_t)0x6d23, (q15_t)0xbd20, - (q15_t)0x6d20, (q15_t)0xbd1b, (q15_t)0x6d1d, (q15_t)0xbd16, (q15_t)0x6d1a, (q15_t)0xbd10, (q15_t)0x6d16, (q15_t)0xbd0b, - (q15_t)0x6d13, (q15_t)0xbd06, (q15_t)0x6d10, (q15_t)0xbd00, (q15_t)0x6d0c, (q15_t)0xbcfb, (q15_t)0x6d09, (q15_t)0xbcf5, - (q15_t)0x6d06, (q15_t)0xbcf0, (q15_t)0x6d03, (q15_t)0xbceb, (q15_t)0x6cff, (q15_t)0xbce5, (q15_t)0x6cfc, (q15_t)0xbce0, - (q15_t)0x6cf9, (q15_t)0xbcdb, (q15_t)0x6cf5, (q15_t)0xbcd5, (q15_t)0x6cf2, (q15_t)0xbcd0, (q15_t)0x6cef, (q15_t)0xbccb, - (q15_t)0x6cec, (q15_t)0xbcc5, (q15_t)0x6ce8, (q15_t)0xbcc0, (q15_t)0x6ce5, (q15_t)0xbcbb, (q15_t)0x6ce2, (q15_t)0xbcb5, - (q15_t)0x6cde, (q15_t)0xbcb0, (q15_t)0x6cdb, (q15_t)0xbcab, (q15_t)0x6cd8, (q15_t)0xbca5, (q15_t)0x6cd4, (q15_t)0xbca0, - (q15_t)0x6cd1, (q15_t)0xbc9b, (q15_t)0x6cce, (q15_t)0xbc95, (q15_t)0x6cca, (q15_t)0xbc90, (q15_t)0x6cc7, (q15_t)0xbc8b, - (q15_t)0x6cc4, (q15_t)0xbc85, (q15_t)0x6cc1, (q15_t)0xbc80, (q15_t)0x6cbd, (q15_t)0xbc7b, (q15_t)0x6cba, (q15_t)0xbc75, - (q15_t)0x6cb7, (q15_t)0xbc70, (q15_t)0x6cb3, (q15_t)0xbc6b, (q15_t)0x6cb0, (q15_t)0xbc65, (q15_t)0x6cad, (q15_t)0xbc60, - (q15_t)0x6ca9, (q15_t)0xbc5b, (q15_t)0x6ca6, (q15_t)0xbc55, (q15_t)0x6ca3, (q15_t)0xbc50, (q15_t)0x6c9f, (q15_t)0xbc4b, - (q15_t)0x6c9c, (q15_t)0xbc45, (q15_t)0x6c99, (q15_t)0xbc40, (q15_t)0x6c95, (q15_t)0xbc3b, (q15_t)0x6c92, (q15_t)0xbc35, - (q15_t)0x6c8f, (q15_t)0xbc30, (q15_t)0x6c8b, (q15_t)0xbc2b, (q15_t)0x6c88, (q15_t)0xbc25, (q15_t)0x6c85, (q15_t)0xbc20, - (q15_t)0x6c81, (q15_t)0xbc1b, (q15_t)0x6c7e, (q15_t)0xbc15, (q15_t)0x6c7b, (q15_t)0xbc10, (q15_t)0x6c77, (q15_t)0xbc0b, - (q15_t)0x6c74, (q15_t)0xbc05, (q15_t)0x6c71, (q15_t)0xbc00, (q15_t)0x6c6d, (q15_t)0xbbfb, (q15_t)0x6c6a, (q15_t)0xbbf5, - (q15_t)0x6c67, (q15_t)0xbbf0, (q15_t)0x6c63, (q15_t)0xbbeb, (q15_t)0x6c60, (q15_t)0xbbe5, (q15_t)0x6c5d, (q15_t)0xbbe0, - (q15_t)0x6c59, (q15_t)0xbbdb, (q15_t)0x6c56, (q15_t)0xbbd5, (q15_t)0x6c53, (q15_t)0xbbd0, (q15_t)0x6c4f, (q15_t)0xbbcb, - (q15_t)0x6c4c, (q15_t)0xbbc5, (q15_t)0x6c49, (q15_t)0xbbc0, (q15_t)0x6c45, (q15_t)0xbbbb, (q15_t)0x6c42, (q15_t)0xbbb5, - (q15_t)0x6c3f, (q15_t)0xbbb0, (q15_t)0x6c3b, (q15_t)0xbbab, (q15_t)0x6c38, (q15_t)0xbba6, (q15_t)0x6c34, (q15_t)0xbba0, - (q15_t)0x6c31, (q15_t)0xbb9b, (q15_t)0x6c2e, (q15_t)0xbb96, (q15_t)0x6c2a, (q15_t)0xbb90, (q15_t)0x6c27, (q15_t)0xbb8b, - (q15_t)0x6c24, (q15_t)0xbb86, (q15_t)0x6c20, (q15_t)0xbb80, (q15_t)0x6c1d, (q15_t)0xbb7b, (q15_t)0x6c1a, (q15_t)0xbb76, - (q15_t)0x6c16, (q15_t)0xbb70, (q15_t)0x6c13, (q15_t)0xbb6b, (q15_t)0x6c0f, (q15_t)0xbb66, (q15_t)0x6c0c, (q15_t)0xbb61, - (q15_t)0x6c09, (q15_t)0xbb5b, (q15_t)0x6c05, (q15_t)0xbb56, (q15_t)0x6c02, (q15_t)0xbb51, (q15_t)0x6bff, (q15_t)0xbb4b, - (q15_t)0x6bfb, (q15_t)0xbb46, (q15_t)0x6bf8, (q15_t)0xbb41, (q15_t)0x6bf5, (q15_t)0xbb3b, (q15_t)0x6bf1, (q15_t)0xbb36, - (q15_t)0x6bee, (q15_t)0xbb31, (q15_t)0x6bea, (q15_t)0xbb2c, (q15_t)0x6be7, (q15_t)0xbb26, (q15_t)0x6be4, (q15_t)0xbb21, - (q15_t)0x6be0, (q15_t)0xbb1c, (q15_t)0x6bdd, (q15_t)0xbb16, (q15_t)0x6bd9, (q15_t)0xbb11, (q15_t)0x6bd6, (q15_t)0xbb0c, - (q15_t)0x6bd3, (q15_t)0xbb06, (q15_t)0x6bcf, (q15_t)0xbb01, (q15_t)0x6bcc, (q15_t)0xbafc, (q15_t)0x6bc9, (q15_t)0xbaf7, - (q15_t)0x6bc5, (q15_t)0xbaf1, (q15_t)0x6bc2, (q15_t)0xbaec, (q15_t)0x6bbe, (q15_t)0xbae7, (q15_t)0x6bbb, (q15_t)0xbae1, - (q15_t)0x6bb8, (q15_t)0xbadc, (q15_t)0x6bb4, (q15_t)0xbad7, (q15_t)0x6bb1, (q15_t)0xbad2, (q15_t)0x6bad, (q15_t)0xbacc, - (q15_t)0x6baa, (q15_t)0xbac7, (q15_t)0x6ba7, (q15_t)0xbac2, (q15_t)0x6ba3, (q15_t)0xbabc, (q15_t)0x6ba0, (q15_t)0xbab7, - (q15_t)0x6b9c, (q15_t)0xbab2, (q15_t)0x6b99, (q15_t)0xbaad, (q15_t)0x6b96, (q15_t)0xbaa7, (q15_t)0x6b92, (q15_t)0xbaa2, - (q15_t)0x6b8f, (q15_t)0xba9d, (q15_t)0x6b8b, (q15_t)0xba97, (q15_t)0x6b88, (q15_t)0xba92, (q15_t)0x6b85, (q15_t)0xba8d, - (q15_t)0x6b81, (q15_t)0xba88, (q15_t)0x6b7e, (q15_t)0xba82, (q15_t)0x6b7a, (q15_t)0xba7d, (q15_t)0x6b77, (q15_t)0xba78, - (q15_t)0x6b73, (q15_t)0xba73, (q15_t)0x6b70, (q15_t)0xba6d, (q15_t)0x6b6d, (q15_t)0xba68, (q15_t)0x6b69, (q15_t)0xba63, - (q15_t)0x6b66, (q15_t)0xba5d, (q15_t)0x6b62, (q15_t)0xba58, (q15_t)0x6b5f, (q15_t)0xba53, (q15_t)0x6b5c, (q15_t)0xba4e, - (q15_t)0x6b58, (q15_t)0xba48, (q15_t)0x6b55, (q15_t)0xba43, (q15_t)0x6b51, (q15_t)0xba3e, (q15_t)0x6b4e, (q15_t)0xba39, - (q15_t)0x6b4a, (q15_t)0xba33, (q15_t)0x6b47, (q15_t)0xba2e, (q15_t)0x6b44, (q15_t)0xba29, (q15_t)0x6b40, (q15_t)0xba23, - (q15_t)0x6b3d, (q15_t)0xba1e, (q15_t)0x6b39, (q15_t)0xba19, (q15_t)0x6b36, (q15_t)0xba14, (q15_t)0x6b32, (q15_t)0xba0e, - (q15_t)0x6b2f, (q15_t)0xba09, (q15_t)0x6b2c, (q15_t)0xba04, (q15_t)0x6b28, (q15_t)0xb9ff, (q15_t)0x6b25, (q15_t)0xb9f9, - (q15_t)0x6b21, (q15_t)0xb9f4, (q15_t)0x6b1e, (q15_t)0xb9ef, (q15_t)0x6b1a, (q15_t)0xb9ea, (q15_t)0x6b17, (q15_t)0xb9e4, - (q15_t)0x6b13, (q15_t)0xb9df, (q15_t)0x6b10, (q15_t)0xb9da, (q15_t)0x6b0d, (q15_t)0xb9d5, (q15_t)0x6b09, (q15_t)0xb9cf, - (q15_t)0x6b06, (q15_t)0xb9ca, (q15_t)0x6b02, (q15_t)0xb9c5, (q15_t)0x6aff, (q15_t)0xb9c0, (q15_t)0x6afb, (q15_t)0xb9ba, - (q15_t)0x6af8, (q15_t)0xb9b5, (q15_t)0x6af4, (q15_t)0xb9b0, (q15_t)0x6af1, (q15_t)0xb9ab, (q15_t)0x6aee, (q15_t)0xb9a5, - (q15_t)0x6aea, (q15_t)0xb9a0, (q15_t)0x6ae7, (q15_t)0xb99b, (q15_t)0x6ae3, (q15_t)0xb996, (q15_t)0x6ae0, (q15_t)0xb990, - (q15_t)0x6adc, (q15_t)0xb98b, (q15_t)0x6ad9, (q15_t)0xb986, (q15_t)0x6ad5, (q15_t)0xb981, (q15_t)0x6ad2, (q15_t)0xb97b, - (q15_t)0x6ace, (q15_t)0xb976, (q15_t)0x6acb, (q15_t)0xb971, (q15_t)0x6ac8, (q15_t)0xb96c, (q15_t)0x6ac4, (q15_t)0xb966, - (q15_t)0x6ac1, (q15_t)0xb961, (q15_t)0x6abd, (q15_t)0xb95c, (q15_t)0x6aba, (q15_t)0xb957, (q15_t)0x6ab6, (q15_t)0xb951, - (q15_t)0x6ab3, (q15_t)0xb94c, (q15_t)0x6aaf, (q15_t)0xb947, (q15_t)0x6aac, (q15_t)0xb942, (q15_t)0x6aa8, (q15_t)0xb93c, - (q15_t)0x6aa5, (q15_t)0xb937, (q15_t)0x6aa1, (q15_t)0xb932, (q15_t)0x6a9e, (q15_t)0xb92d, (q15_t)0x6a9a, (q15_t)0xb928, - (q15_t)0x6a97, (q15_t)0xb922, (q15_t)0x6a93, (q15_t)0xb91d, (q15_t)0x6a90, (q15_t)0xb918, (q15_t)0x6a8c, (q15_t)0xb913, - (q15_t)0x6a89, (q15_t)0xb90d, (q15_t)0x6a86, (q15_t)0xb908, (q15_t)0x6a82, (q15_t)0xb903, (q15_t)0x6a7f, (q15_t)0xb8fe, - (q15_t)0x6a7b, (q15_t)0xb8f8, (q15_t)0x6a78, (q15_t)0xb8f3, (q15_t)0x6a74, (q15_t)0xb8ee, (q15_t)0x6a71, (q15_t)0xb8e9, - (q15_t)0x6a6d, (q15_t)0xb8e4, (q15_t)0x6a6a, (q15_t)0xb8de, (q15_t)0x6a66, (q15_t)0xb8d9, (q15_t)0x6a63, (q15_t)0xb8d4, - (q15_t)0x6a5f, (q15_t)0xb8cf, (q15_t)0x6a5c, (q15_t)0xb8c9, (q15_t)0x6a58, (q15_t)0xb8c4, (q15_t)0x6a55, (q15_t)0xb8bf, - (q15_t)0x6a51, (q15_t)0xb8ba, (q15_t)0x6a4e, (q15_t)0xb8b5, (q15_t)0x6a4a, (q15_t)0xb8af, (q15_t)0x6a47, (q15_t)0xb8aa, - (q15_t)0x6a43, (q15_t)0xb8a5, (q15_t)0x6a40, (q15_t)0xb8a0, (q15_t)0x6a3c, (q15_t)0xb89b, (q15_t)0x6a39, (q15_t)0xb895, - (q15_t)0x6a35, (q15_t)0xb890, (q15_t)0x6a32, (q15_t)0xb88b, (q15_t)0x6a2e, (q15_t)0xb886, (q15_t)0x6a2b, (q15_t)0xb880, - (q15_t)0x6a27, (q15_t)0xb87b, (q15_t)0x6a24, (q15_t)0xb876, (q15_t)0x6a20, (q15_t)0xb871, (q15_t)0x6a1d, (q15_t)0xb86c, - (q15_t)0x6a19, (q15_t)0xb866, (q15_t)0x6a16, (q15_t)0xb861, (q15_t)0x6a12, (q15_t)0xb85c, (q15_t)0x6a0e, (q15_t)0xb857, - (q15_t)0x6a0b, (q15_t)0xb852, (q15_t)0x6a07, (q15_t)0xb84c, (q15_t)0x6a04, (q15_t)0xb847, (q15_t)0x6a00, (q15_t)0xb842, - (q15_t)0x69fd, (q15_t)0xb83d, (q15_t)0x69f9, (q15_t)0xb838, (q15_t)0x69f6, (q15_t)0xb832, (q15_t)0x69f2, (q15_t)0xb82d, - (q15_t)0x69ef, (q15_t)0xb828, (q15_t)0x69eb, (q15_t)0xb823, (q15_t)0x69e8, (q15_t)0xb81e, (q15_t)0x69e4, (q15_t)0xb818, - (q15_t)0x69e1, (q15_t)0xb813, (q15_t)0x69dd, (q15_t)0xb80e, (q15_t)0x69da, (q15_t)0xb809, (q15_t)0x69d6, (q15_t)0xb804, - (q15_t)0x69d3, (q15_t)0xb7fe, (q15_t)0x69cf, (q15_t)0xb7f9, (q15_t)0x69cb, (q15_t)0xb7f4, (q15_t)0x69c8, (q15_t)0xb7ef, - (q15_t)0x69c4, (q15_t)0xb7ea, (q15_t)0x69c1, (q15_t)0xb7e4, (q15_t)0x69bd, (q15_t)0xb7df, (q15_t)0x69ba, (q15_t)0xb7da, - (q15_t)0x69b6, (q15_t)0xb7d5, (q15_t)0x69b3, (q15_t)0xb7d0, (q15_t)0x69af, (q15_t)0xb7ca, (q15_t)0x69ac, (q15_t)0xb7c5, - (q15_t)0x69a8, (q15_t)0xb7c0, (q15_t)0x69a5, (q15_t)0xb7bb, (q15_t)0x69a1, (q15_t)0xb7b6, (q15_t)0x699d, (q15_t)0xb7b1, - (q15_t)0x699a, (q15_t)0xb7ab, (q15_t)0x6996, (q15_t)0xb7a6, (q15_t)0x6993, (q15_t)0xb7a1, (q15_t)0x698f, (q15_t)0xb79c, - (q15_t)0x698c, (q15_t)0xb797, (q15_t)0x6988, (q15_t)0xb791, (q15_t)0x6985, (q15_t)0xb78c, (q15_t)0x6981, (q15_t)0xb787, - (q15_t)0x697d, (q15_t)0xb782, (q15_t)0x697a, (q15_t)0xb77d, (q15_t)0x6976, (q15_t)0xb778, (q15_t)0x6973, (q15_t)0xb772, - (q15_t)0x696f, (q15_t)0xb76d, (q15_t)0x696c, (q15_t)0xb768, (q15_t)0x6968, (q15_t)0xb763, (q15_t)0x6964, (q15_t)0xb75e, - (q15_t)0x6961, (q15_t)0xb758, (q15_t)0x695d, (q15_t)0xb753, (q15_t)0x695a, (q15_t)0xb74e, (q15_t)0x6956, (q15_t)0xb749, - (q15_t)0x6953, (q15_t)0xb744, (q15_t)0x694f, (q15_t)0xb73f, (q15_t)0x694b, (q15_t)0xb739, (q15_t)0x6948, (q15_t)0xb734, - (q15_t)0x6944, (q15_t)0xb72f, (q15_t)0x6941, (q15_t)0xb72a, (q15_t)0x693d, (q15_t)0xb725, (q15_t)0x693a, (q15_t)0xb720, - (q15_t)0x6936, (q15_t)0xb71a, (q15_t)0x6932, (q15_t)0xb715, (q15_t)0x692f, (q15_t)0xb710, (q15_t)0x692b, (q15_t)0xb70b, - (q15_t)0x6928, (q15_t)0xb706, (q15_t)0x6924, (q15_t)0xb701, (q15_t)0x6921, (q15_t)0xb6fb, (q15_t)0x691d, (q15_t)0xb6f6, - (q15_t)0x6919, (q15_t)0xb6f1, (q15_t)0x6916, (q15_t)0xb6ec, (q15_t)0x6912, (q15_t)0xb6e7, (q15_t)0x690f, (q15_t)0xb6e2, - (q15_t)0x690b, (q15_t)0xb6dd, (q15_t)0x6907, (q15_t)0xb6d7, (q15_t)0x6904, (q15_t)0xb6d2, (q15_t)0x6900, (q15_t)0xb6cd, - (q15_t)0x68fd, (q15_t)0xb6c8, (q15_t)0x68f9, (q15_t)0xb6c3, (q15_t)0x68f5, (q15_t)0xb6be, (q15_t)0x68f2, (q15_t)0xb6b8, - (q15_t)0x68ee, (q15_t)0xb6b3, (q15_t)0x68eb, (q15_t)0xb6ae, (q15_t)0x68e7, (q15_t)0xb6a9, (q15_t)0x68e3, (q15_t)0xb6a4, - (q15_t)0x68e0, (q15_t)0xb69f, (q15_t)0x68dc, (q15_t)0xb69a, (q15_t)0x68d9, (q15_t)0xb694, (q15_t)0x68d5, (q15_t)0xb68f, - (q15_t)0x68d1, (q15_t)0xb68a, (q15_t)0x68ce, (q15_t)0xb685, (q15_t)0x68ca, (q15_t)0xb680, (q15_t)0x68c7, (q15_t)0xb67b, - (q15_t)0x68c3, (q15_t)0xb676, (q15_t)0x68bf, (q15_t)0xb670, (q15_t)0x68bc, (q15_t)0xb66b, (q15_t)0x68b8, (q15_t)0xb666, - (q15_t)0x68b5, (q15_t)0xb661, (q15_t)0x68b1, (q15_t)0xb65c, (q15_t)0x68ad, (q15_t)0xb657, (q15_t)0x68aa, (q15_t)0xb652, - (q15_t)0x68a6, (q15_t)0xb64c, (q15_t)0x68a3, (q15_t)0xb647, (q15_t)0x689f, (q15_t)0xb642, (q15_t)0x689b, (q15_t)0xb63d, - (q15_t)0x6898, (q15_t)0xb638, (q15_t)0x6894, (q15_t)0xb633, (q15_t)0x6890, (q15_t)0xb62e, (q15_t)0x688d, (q15_t)0xb628, - (q15_t)0x6889, (q15_t)0xb623, (q15_t)0x6886, (q15_t)0xb61e, (q15_t)0x6882, (q15_t)0xb619, (q15_t)0x687e, (q15_t)0xb614, - (q15_t)0x687b, (q15_t)0xb60f, (q15_t)0x6877, (q15_t)0xb60a, (q15_t)0x6873, (q15_t)0xb605, (q15_t)0x6870, (q15_t)0xb5ff, - (q15_t)0x686c, (q15_t)0xb5fa, (q15_t)0x6868, (q15_t)0xb5f5, (q15_t)0x6865, (q15_t)0xb5f0, (q15_t)0x6861, (q15_t)0xb5eb, - (q15_t)0x685e, (q15_t)0xb5e6, (q15_t)0x685a, (q15_t)0xb5e1, (q15_t)0x6856, (q15_t)0xb5dc, (q15_t)0x6853, (q15_t)0xb5d6, - (q15_t)0x684f, (q15_t)0xb5d1, (q15_t)0x684b, (q15_t)0xb5cc, (q15_t)0x6848, (q15_t)0xb5c7, (q15_t)0x6844, (q15_t)0xb5c2, - (q15_t)0x6840, (q15_t)0xb5bd, (q15_t)0x683d, (q15_t)0xb5b8, (q15_t)0x6839, (q15_t)0xb5b3, (q15_t)0x6835, (q15_t)0xb5ae, - (q15_t)0x6832, (q15_t)0xb5a8, (q15_t)0x682e, (q15_t)0xb5a3, (q15_t)0x682b, (q15_t)0xb59e, (q15_t)0x6827, (q15_t)0xb599, - (q15_t)0x6823, (q15_t)0xb594, (q15_t)0x6820, (q15_t)0xb58f, (q15_t)0x681c, (q15_t)0xb58a, (q15_t)0x6818, (q15_t)0xb585, - (q15_t)0x6815, (q15_t)0xb57f, (q15_t)0x6811, (q15_t)0xb57a, (q15_t)0x680d, (q15_t)0xb575, (q15_t)0x680a, (q15_t)0xb570, - (q15_t)0x6806, (q15_t)0xb56b, (q15_t)0x6802, (q15_t)0xb566, (q15_t)0x67ff, (q15_t)0xb561, (q15_t)0x67fb, (q15_t)0xb55c, - (q15_t)0x67f7, (q15_t)0xb557, (q15_t)0x67f4, (q15_t)0xb552, (q15_t)0x67f0, (q15_t)0xb54c, (q15_t)0x67ec, (q15_t)0xb547, - (q15_t)0x67e9, (q15_t)0xb542, (q15_t)0x67e5, (q15_t)0xb53d, (q15_t)0x67e1, (q15_t)0xb538, (q15_t)0x67de, (q15_t)0xb533, - (q15_t)0x67da, (q15_t)0xb52e, (q15_t)0x67d6, (q15_t)0xb529, (q15_t)0x67d3, (q15_t)0xb524, (q15_t)0x67cf, (q15_t)0xb51f, - (q15_t)0x67cb, (q15_t)0xb519, (q15_t)0x67c8, (q15_t)0xb514, (q15_t)0x67c4, (q15_t)0xb50f, (q15_t)0x67c0, (q15_t)0xb50a, - (q15_t)0x67bd, (q15_t)0xb505, (q15_t)0x67b9, (q15_t)0xb500, (q15_t)0x67b5, (q15_t)0xb4fb, (q15_t)0x67b2, (q15_t)0xb4f6, - (q15_t)0x67ae, (q15_t)0xb4f1, (q15_t)0x67aa, (q15_t)0xb4ec, (q15_t)0x67a6, (q15_t)0xb4e7, (q15_t)0x67a3, (q15_t)0xb4e1, - (q15_t)0x679f, (q15_t)0xb4dc, (q15_t)0x679b, (q15_t)0xb4d7, (q15_t)0x6798, (q15_t)0xb4d2, (q15_t)0x6794, (q15_t)0xb4cd, - (q15_t)0x6790, (q15_t)0xb4c8, (q15_t)0x678d, (q15_t)0xb4c3, (q15_t)0x6789, (q15_t)0xb4be, (q15_t)0x6785, (q15_t)0xb4b9, - (q15_t)0x6782, (q15_t)0xb4b4, (q15_t)0x677e, (q15_t)0xb4af, (q15_t)0x677a, (q15_t)0xb4aa, (q15_t)0x6776, (q15_t)0xb4a4, - (q15_t)0x6773, (q15_t)0xb49f, (q15_t)0x676f, (q15_t)0xb49a, (q15_t)0x676b, (q15_t)0xb495, (q15_t)0x6768, (q15_t)0xb490, - (q15_t)0x6764, (q15_t)0xb48b, (q15_t)0x6760, (q15_t)0xb486, (q15_t)0x675d, (q15_t)0xb481, (q15_t)0x6759, (q15_t)0xb47c, - (q15_t)0x6755, (q15_t)0xb477, (q15_t)0x6751, (q15_t)0xb472, (q15_t)0x674e, (q15_t)0xb46d, (q15_t)0x674a, (q15_t)0xb468, - (q15_t)0x6746, (q15_t)0xb462, (q15_t)0x6743, (q15_t)0xb45d, (q15_t)0x673f, (q15_t)0xb458, (q15_t)0x673b, (q15_t)0xb453, - (q15_t)0x6737, (q15_t)0xb44e, (q15_t)0x6734, (q15_t)0xb449, (q15_t)0x6730, (q15_t)0xb444, (q15_t)0x672c, (q15_t)0xb43f, - (q15_t)0x6729, (q15_t)0xb43a, (q15_t)0x6725, (q15_t)0xb435, (q15_t)0x6721, (q15_t)0xb430, (q15_t)0x671d, (q15_t)0xb42b, - (q15_t)0x671a, (q15_t)0xb426, (q15_t)0x6716, (q15_t)0xb421, (q15_t)0x6712, (q15_t)0xb41c, (q15_t)0x670e, (q15_t)0xb417, - (q15_t)0x670b, (q15_t)0xb411, (q15_t)0x6707, (q15_t)0xb40c, (q15_t)0x6703, (q15_t)0xb407, (q15_t)0x6700, (q15_t)0xb402, - (q15_t)0x66fc, (q15_t)0xb3fd, (q15_t)0x66f8, (q15_t)0xb3f8, (q15_t)0x66f4, (q15_t)0xb3f3, (q15_t)0x66f1, (q15_t)0xb3ee, - (q15_t)0x66ed, (q15_t)0xb3e9, (q15_t)0x66e9, (q15_t)0xb3e4, (q15_t)0x66e5, (q15_t)0xb3df, (q15_t)0x66e2, (q15_t)0xb3da, - (q15_t)0x66de, (q15_t)0xb3d5, (q15_t)0x66da, (q15_t)0xb3d0, (q15_t)0x66d6, (q15_t)0xb3cb, (q15_t)0x66d3, (q15_t)0xb3c6, - (q15_t)0x66cf, (q15_t)0xb3c1, (q15_t)0x66cb, (q15_t)0xb3bc, (q15_t)0x66c8, (q15_t)0xb3b7, (q15_t)0x66c4, (q15_t)0xb3b1, - (q15_t)0x66c0, (q15_t)0xb3ac, (q15_t)0x66bc, (q15_t)0xb3a7, (q15_t)0x66b9, (q15_t)0xb3a2, (q15_t)0x66b5, (q15_t)0xb39d, - (q15_t)0x66b1, (q15_t)0xb398, (q15_t)0x66ad, (q15_t)0xb393, (q15_t)0x66aa, (q15_t)0xb38e, (q15_t)0x66a6, (q15_t)0xb389, - (q15_t)0x66a2, (q15_t)0xb384, (q15_t)0x669e, (q15_t)0xb37f, (q15_t)0x669b, (q15_t)0xb37a, (q15_t)0x6697, (q15_t)0xb375, - (q15_t)0x6693, (q15_t)0xb370, (q15_t)0x668f, (q15_t)0xb36b, (q15_t)0x668b, (q15_t)0xb366, (q15_t)0x6688, (q15_t)0xb361, - (q15_t)0x6684, (q15_t)0xb35c, (q15_t)0x6680, (q15_t)0xb357, (q15_t)0x667c, (q15_t)0xb352, (q15_t)0x6679, (q15_t)0xb34d, - (q15_t)0x6675, (q15_t)0xb348, (q15_t)0x6671, (q15_t)0xb343, (q15_t)0x666d, (q15_t)0xb33e, (q15_t)0x666a, (q15_t)0xb339, - (q15_t)0x6666, (q15_t)0xb334, (q15_t)0x6662, (q15_t)0xb32f, (q15_t)0x665e, (q15_t)0xb32a, (q15_t)0x665b, (q15_t)0xb325, - (q15_t)0x6657, (q15_t)0xb31f, (q15_t)0x6653, (q15_t)0xb31a, (q15_t)0x664f, (q15_t)0xb315, (q15_t)0x664b, (q15_t)0xb310, - (q15_t)0x6648, (q15_t)0xb30b, (q15_t)0x6644, (q15_t)0xb306, (q15_t)0x6640, (q15_t)0xb301, (q15_t)0x663c, (q15_t)0xb2fc, - (q15_t)0x6639, (q15_t)0xb2f7, (q15_t)0x6635, (q15_t)0xb2f2, (q15_t)0x6631, (q15_t)0xb2ed, (q15_t)0x662d, (q15_t)0xb2e8, - (q15_t)0x6629, (q15_t)0xb2e3, (q15_t)0x6626, (q15_t)0xb2de, (q15_t)0x6622, (q15_t)0xb2d9, (q15_t)0x661e, (q15_t)0xb2d4, - (q15_t)0x661a, (q15_t)0xb2cf, (q15_t)0x6616, (q15_t)0xb2ca, (q15_t)0x6613, (q15_t)0xb2c5, (q15_t)0x660f, (q15_t)0xb2c0, - (q15_t)0x660b, (q15_t)0xb2bb, (q15_t)0x6607, (q15_t)0xb2b6, (q15_t)0x6603, (q15_t)0xb2b1, (q15_t)0x6600, (q15_t)0xb2ac, - (q15_t)0x65fc, (q15_t)0xb2a7, (q15_t)0x65f8, (q15_t)0xb2a2, (q15_t)0x65f4, (q15_t)0xb29d, (q15_t)0x65f0, (q15_t)0xb298, - (q15_t)0x65ed, (q15_t)0xb293, (q15_t)0x65e9, (q15_t)0xb28e, (q15_t)0x65e5, (q15_t)0xb289, (q15_t)0x65e1, (q15_t)0xb284, - (q15_t)0x65dd, (q15_t)0xb27f, (q15_t)0x65da, (q15_t)0xb27a, (q15_t)0x65d6, (q15_t)0xb275, (q15_t)0x65d2, (q15_t)0xb270, - (q15_t)0x65ce, (q15_t)0xb26b, (q15_t)0x65ca, (q15_t)0xb266, (q15_t)0x65c7, (q15_t)0xb261, (q15_t)0x65c3, (q15_t)0xb25c, - (q15_t)0x65bf, (q15_t)0xb257, (q15_t)0x65bb, (q15_t)0xb252, (q15_t)0x65b7, (q15_t)0xb24d, (q15_t)0x65b4, (q15_t)0xb248, - (q15_t)0x65b0, (q15_t)0xb243, (q15_t)0x65ac, (q15_t)0xb23e, (q15_t)0x65a8, (q15_t)0xb239, (q15_t)0x65a4, (q15_t)0xb234, - (q15_t)0x65a0, (q15_t)0xb22f, (q15_t)0x659d, (q15_t)0xb22a, (q15_t)0x6599, (q15_t)0xb225, (q15_t)0x6595, (q15_t)0xb220, - (q15_t)0x6591, (q15_t)0xb21b, (q15_t)0x658d, (q15_t)0xb216, (q15_t)0x658a, (q15_t)0xb211, (q15_t)0x6586, (q15_t)0xb20c, - (q15_t)0x6582, (q15_t)0xb207, (q15_t)0x657e, (q15_t)0xb202, (q15_t)0x657a, (q15_t)0xb1fd, (q15_t)0x6576, (q15_t)0xb1f8, - (q15_t)0x6573, (q15_t)0xb1f3, (q15_t)0x656f, (q15_t)0xb1ee, (q15_t)0x656b, (q15_t)0xb1e9, (q15_t)0x6567, (q15_t)0xb1e4, - (q15_t)0x6563, (q15_t)0xb1df, (q15_t)0x655f, (q15_t)0xb1da, (q15_t)0x655c, (q15_t)0xb1d6, (q15_t)0x6558, (q15_t)0xb1d1, - (q15_t)0x6554, (q15_t)0xb1cc, (q15_t)0x6550, (q15_t)0xb1c7, (q15_t)0x654c, (q15_t)0xb1c2, (q15_t)0x6548, (q15_t)0xb1bd, - (q15_t)0x6545, (q15_t)0xb1b8, (q15_t)0x6541, (q15_t)0xb1b3, (q15_t)0x653d, (q15_t)0xb1ae, (q15_t)0x6539, (q15_t)0xb1a9, - (q15_t)0x6535, (q15_t)0xb1a4, (q15_t)0x6531, (q15_t)0xb19f, (q15_t)0x652d, (q15_t)0xb19a, (q15_t)0x652a, (q15_t)0xb195, - (q15_t)0x6526, (q15_t)0xb190, (q15_t)0x6522, (q15_t)0xb18b, (q15_t)0x651e, (q15_t)0xb186, (q15_t)0x651a, (q15_t)0xb181, - (q15_t)0x6516, (q15_t)0xb17c, (q15_t)0x6513, (q15_t)0xb177, (q15_t)0x650f, (q15_t)0xb172, (q15_t)0x650b, (q15_t)0xb16d, - (q15_t)0x6507, (q15_t)0xb168, (q15_t)0x6503, (q15_t)0xb163, (q15_t)0x64ff, (q15_t)0xb15e, (q15_t)0x64fb, (q15_t)0xb159, - (q15_t)0x64f7, (q15_t)0xb154, (q15_t)0x64f4, (q15_t)0xb14f, (q15_t)0x64f0, (q15_t)0xb14a, (q15_t)0x64ec, (q15_t)0xb146, - (q15_t)0x64e8, (q15_t)0xb141, (q15_t)0x64e4, (q15_t)0xb13c, (q15_t)0x64e0, (q15_t)0xb137, (q15_t)0x64dc, (q15_t)0xb132, - (q15_t)0x64d9, (q15_t)0xb12d, (q15_t)0x64d5, (q15_t)0xb128, (q15_t)0x64d1, (q15_t)0xb123, (q15_t)0x64cd, (q15_t)0xb11e, - (q15_t)0x64c9, (q15_t)0xb119, (q15_t)0x64c5, (q15_t)0xb114, (q15_t)0x64c1, (q15_t)0xb10f, (q15_t)0x64bd, (q15_t)0xb10a, - (q15_t)0x64ba, (q15_t)0xb105, (q15_t)0x64b6, (q15_t)0xb100, (q15_t)0x64b2, (q15_t)0xb0fb, (q15_t)0x64ae, (q15_t)0xb0f6, - (q15_t)0x64aa, (q15_t)0xb0f1, (q15_t)0x64a6, (q15_t)0xb0ec, (q15_t)0x64a2, (q15_t)0xb0e8, (q15_t)0x649e, (q15_t)0xb0e3, - (q15_t)0x649b, (q15_t)0xb0de, (q15_t)0x6497, (q15_t)0xb0d9, (q15_t)0x6493, (q15_t)0xb0d4, (q15_t)0x648f, (q15_t)0xb0cf, - (q15_t)0x648b, (q15_t)0xb0ca, (q15_t)0x6487, (q15_t)0xb0c5, (q15_t)0x6483, (q15_t)0xb0c0, (q15_t)0x647f, (q15_t)0xb0bb, - (q15_t)0x647b, (q15_t)0xb0b6, (q15_t)0x6478, (q15_t)0xb0b1, (q15_t)0x6474, (q15_t)0xb0ac, (q15_t)0x6470, (q15_t)0xb0a7, - (q15_t)0x646c, (q15_t)0xb0a2, (q15_t)0x6468, (q15_t)0xb09e, (q15_t)0x6464, (q15_t)0xb099, (q15_t)0x6460, (q15_t)0xb094, - (q15_t)0x645c, (q15_t)0xb08f, (q15_t)0x6458, (q15_t)0xb08a, (q15_t)0x6454, (q15_t)0xb085, (q15_t)0x6451, (q15_t)0xb080, - (q15_t)0x644d, (q15_t)0xb07b, (q15_t)0x6449, (q15_t)0xb076, (q15_t)0x6445, (q15_t)0xb071, (q15_t)0x6441, (q15_t)0xb06c, - (q15_t)0x643d, (q15_t)0xb067, (q15_t)0x6439, (q15_t)0xb062, (q15_t)0x6435, (q15_t)0xb05e, (q15_t)0x6431, (q15_t)0xb059, - (q15_t)0x642d, (q15_t)0xb054, (q15_t)0x6429, (q15_t)0xb04f, (q15_t)0x6426, (q15_t)0xb04a, (q15_t)0x6422, (q15_t)0xb045, - (q15_t)0x641e, (q15_t)0xb040, (q15_t)0x641a, (q15_t)0xb03b, (q15_t)0x6416, (q15_t)0xb036, (q15_t)0x6412, (q15_t)0xb031, - (q15_t)0x640e, (q15_t)0xb02c, (q15_t)0x640a, (q15_t)0xb027, (q15_t)0x6406, (q15_t)0xb023, (q15_t)0x6402, (q15_t)0xb01e, - (q15_t)0x63fe, (q15_t)0xb019, (q15_t)0x63fa, (q15_t)0xb014, (q15_t)0x63f7, (q15_t)0xb00f, (q15_t)0x63f3, (q15_t)0xb00a, - (q15_t)0x63ef, (q15_t)0xb005, (q15_t)0x63eb, (q15_t)0xb000, (q15_t)0x63e7, (q15_t)0xaffb, (q15_t)0x63e3, (q15_t)0xaff6, - (q15_t)0x63df, (q15_t)0xaff1, (q15_t)0x63db, (q15_t)0xafed, (q15_t)0x63d7, (q15_t)0xafe8, (q15_t)0x63d3, (q15_t)0xafe3, - (q15_t)0x63cf, (q15_t)0xafde, (q15_t)0x63cb, (q15_t)0xafd9, (q15_t)0x63c7, (q15_t)0xafd4, (q15_t)0x63c3, (q15_t)0xafcf, - (q15_t)0x63c0, (q15_t)0xafca, (q15_t)0x63bc, (q15_t)0xafc5, (q15_t)0x63b8, (q15_t)0xafc1, (q15_t)0x63b4, (q15_t)0xafbc, - (q15_t)0x63b0, (q15_t)0xafb7, (q15_t)0x63ac, (q15_t)0xafb2, (q15_t)0x63a8, (q15_t)0xafad, (q15_t)0x63a4, (q15_t)0xafa8, - (q15_t)0x63a0, (q15_t)0xafa3, (q15_t)0x639c, (q15_t)0xaf9e, (q15_t)0x6398, (q15_t)0xaf99, (q15_t)0x6394, (q15_t)0xaf94, - (q15_t)0x6390, (q15_t)0xaf90, (q15_t)0x638c, (q15_t)0xaf8b, (q15_t)0x6388, (q15_t)0xaf86, (q15_t)0x6384, (q15_t)0xaf81, - (q15_t)0x6380, (q15_t)0xaf7c, (q15_t)0x637c, (q15_t)0xaf77, (q15_t)0x6378, (q15_t)0xaf72, (q15_t)0x6375, (q15_t)0xaf6d, - (q15_t)0x6371, (q15_t)0xaf69, (q15_t)0x636d, (q15_t)0xaf64, (q15_t)0x6369, (q15_t)0xaf5f, (q15_t)0x6365, (q15_t)0xaf5a, - (q15_t)0x6361, (q15_t)0xaf55, (q15_t)0x635d, (q15_t)0xaf50, (q15_t)0x6359, (q15_t)0xaf4b, (q15_t)0x6355, (q15_t)0xaf46, - (q15_t)0x6351, (q15_t)0xaf41, (q15_t)0x634d, (q15_t)0xaf3d, (q15_t)0x6349, (q15_t)0xaf38, (q15_t)0x6345, (q15_t)0xaf33, - (q15_t)0x6341, (q15_t)0xaf2e, (q15_t)0x633d, (q15_t)0xaf29, (q15_t)0x6339, (q15_t)0xaf24, (q15_t)0x6335, (q15_t)0xaf1f, - (q15_t)0x6331, (q15_t)0xaf1b, (q15_t)0x632d, (q15_t)0xaf16, (q15_t)0x6329, (q15_t)0xaf11, (q15_t)0x6325, (q15_t)0xaf0c, - (q15_t)0x6321, (q15_t)0xaf07, (q15_t)0x631d, (q15_t)0xaf02, (q15_t)0x6319, (q15_t)0xaefd, (q15_t)0x6315, (q15_t)0xaef8, - (q15_t)0x6311, (q15_t)0xaef4, (q15_t)0x630d, (q15_t)0xaeef, (q15_t)0x6309, (q15_t)0xaeea, (q15_t)0x6305, (q15_t)0xaee5, - (q15_t)0x6301, (q15_t)0xaee0, (q15_t)0x62fd, (q15_t)0xaedb, (q15_t)0x62f9, (q15_t)0xaed6, (q15_t)0x62f5, (q15_t)0xaed2, - (q15_t)0x62f2, (q15_t)0xaecd, (q15_t)0x62ee, (q15_t)0xaec8, (q15_t)0x62ea, (q15_t)0xaec3, (q15_t)0x62e6, (q15_t)0xaebe, - (q15_t)0x62e2, (q15_t)0xaeb9, (q15_t)0x62de, (q15_t)0xaeb4, (q15_t)0x62da, (q15_t)0xaeb0, (q15_t)0x62d6, (q15_t)0xaeab, - (q15_t)0x62d2, (q15_t)0xaea6, (q15_t)0x62ce, (q15_t)0xaea1, (q15_t)0x62ca, (q15_t)0xae9c, (q15_t)0x62c6, (q15_t)0xae97, - (q15_t)0x62c2, (q15_t)0xae92, (q15_t)0x62be, (q15_t)0xae8e, (q15_t)0x62ba, (q15_t)0xae89, (q15_t)0x62b6, (q15_t)0xae84, - (q15_t)0x62b2, (q15_t)0xae7f, (q15_t)0x62ae, (q15_t)0xae7a, (q15_t)0x62aa, (q15_t)0xae75, (q15_t)0x62a6, (q15_t)0xae71, - (q15_t)0x62a2, (q15_t)0xae6c, (q15_t)0x629e, (q15_t)0xae67, (q15_t)0x629a, (q15_t)0xae62, (q15_t)0x6296, (q15_t)0xae5d, - (q15_t)0x6292, (q15_t)0xae58, (q15_t)0x628e, (q15_t)0xae54, (q15_t)0x628a, (q15_t)0xae4f, (q15_t)0x6286, (q15_t)0xae4a, - (q15_t)0x6282, (q15_t)0xae45, (q15_t)0x627e, (q15_t)0xae40, (q15_t)0x627a, (q15_t)0xae3b, (q15_t)0x6275, (q15_t)0xae37, - (q15_t)0x6271, (q15_t)0xae32, (q15_t)0x626d, (q15_t)0xae2d, (q15_t)0x6269, (q15_t)0xae28, (q15_t)0x6265, (q15_t)0xae23, - (q15_t)0x6261, (q15_t)0xae1e, (q15_t)0x625d, (q15_t)0xae1a, (q15_t)0x6259, (q15_t)0xae15, (q15_t)0x6255, (q15_t)0xae10, - (q15_t)0x6251, (q15_t)0xae0b, (q15_t)0x624d, (q15_t)0xae06, (q15_t)0x6249, (q15_t)0xae01, (q15_t)0x6245, (q15_t)0xadfd, - (q15_t)0x6241, (q15_t)0xadf8, (q15_t)0x623d, (q15_t)0xadf3, (q15_t)0x6239, (q15_t)0xadee, (q15_t)0x6235, (q15_t)0xade9, - (q15_t)0x6231, (q15_t)0xade4, (q15_t)0x622d, (q15_t)0xade0, (q15_t)0x6229, (q15_t)0xaddb, (q15_t)0x6225, (q15_t)0xadd6, - (q15_t)0x6221, (q15_t)0xadd1, (q15_t)0x621d, (q15_t)0xadcc, (q15_t)0x6219, (q15_t)0xadc8, (q15_t)0x6215, (q15_t)0xadc3, - (q15_t)0x6211, (q15_t)0xadbe, (q15_t)0x620d, (q15_t)0xadb9, (q15_t)0x6209, (q15_t)0xadb4, (q15_t)0x6205, (q15_t)0xadaf, - (q15_t)0x6201, (q15_t)0xadab, (q15_t)0x61fd, (q15_t)0xada6, (q15_t)0x61f9, (q15_t)0xada1, (q15_t)0x61f5, (q15_t)0xad9c, - (q15_t)0x61f1, (q15_t)0xad97, (q15_t)0x61ec, (q15_t)0xad93, (q15_t)0x61e8, (q15_t)0xad8e, (q15_t)0x61e4, (q15_t)0xad89, - (q15_t)0x61e0, (q15_t)0xad84, (q15_t)0x61dc, (q15_t)0xad7f, (q15_t)0x61d8, (q15_t)0xad7b, (q15_t)0x61d4, (q15_t)0xad76, - (q15_t)0x61d0, (q15_t)0xad71, (q15_t)0x61cc, (q15_t)0xad6c, (q15_t)0x61c8, (q15_t)0xad67, (q15_t)0x61c4, (q15_t)0xad63, - (q15_t)0x61c0, (q15_t)0xad5e, (q15_t)0x61bc, (q15_t)0xad59, (q15_t)0x61b8, (q15_t)0xad54, (q15_t)0x61b4, (q15_t)0xad4f, - (q15_t)0x61b0, (q15_t)0xad4b, (q15_t)0x61ac, (q15_t)0xad46, (q15_t)0x61a8, (q15_t)0xad41, (q15_t)0x61a3, (q15_t)0xad3c, - (q15_t)0x619f, (q15_t)0xad37, (q15_t)0x619b, (q15_t)0xad33, (q15_t)0x6197, (q15_t)0xad2e, (q15_t)0x6193, (q15_t)0xad29, - (q15_t)0x618f, (q15_t)0xad24, (q15_t)0x618b, (q15_t)0xad1f, (q15_t)0x6187, (q15_t)0xad1b, (q15_t)0x6183, (q15_t)0xad16, - (q15_t)0x617f, (q15_t)0xad11, (q15_t)0x617b, (q15_t)0xad0c, (q15_t)0x6177, (q15_t)0xad08, (q15_t)0x6173, (q15_t)0xad03, - (q15_t)0x616f, (q15_t)0xacfe, (q15_t)0x616b, (q15_t)0xacf9, (q15_t)0x6166, (q15_t)0xacf4, (q15_t)0x6162, (q15_t)0xacf0, - (q15_t)0x615e, (q15_t)0xaceb, (q15_t)0x615a, (q15_t)0xace6, (q15_t)0x6156, (q15_t)0xace1, (q15_t)0x6152, (q15_t)0xacdd, - (q15_t)0x614e, (q15_t)0xacd8, (q15_t)0x614a, (q15_t)0xacd3, (q15_t)0x6146, (q15_t)0xacce, (q15_t)0x6142, (q15_t)0xacc9, - (q15_t)0x613e, (q15_t)0xacc5, (q15_t)0x613a, (q15_t)0xacc0, (q15_t)0x6135, (q15_t)0xacbb, (q15_t)0x6131, (q15_t)0xacb6, - (q15_t)0x612d, (q15_t)0xacb2, (q15_t)0x6129, (q15_t)0xacad, (q15_t)0x6125, (q15_t)0xaca8, (q15_t)0x6121, (q15_t)0xaca3, - (q15_t)0x611d, (q15_t)0xac9e, (q15_t)0x6119, (q15_t)0xac9a, (q15_t)0x6115, (q15_t)0xac95, (q15_t)0x6111, (q15_t)0xac90, - (q15_t)0x610d, (q15_t)0xac8b, (q15_t)0x6108, (q15_t)0xac87, (q15_t)0x6104, (q15_t)0xac82, (q15_t)0x6100, (q15_t)0xac7d, - (q15_t)0x60fc, (q15_t)0xac78, (q15_t)0x60f8, (q15_t)0xac74, (q15_t)0x60f4, (q15_t)0xac6f, (q15_t)0x60f0, (q15_t)0xac6a, - (q15_t)0x60ec, (q15_t)0xac65, (q15_t)0x60e8, (q15_t)0xac61, (q15_t)0x60e4, (q15_t)0xac5c, (q15_t)0x60df, (q15_t)0xac57, - (q15_t)0x60db, (q15_t)0xac52, (q15_t)0x60d7, (q15_t)0xac4e, (q15_t)0x60d3, (q15_t)0xac49, (q15_t)0x60cf, (q15_t)0xac44, - (q15_t)0x60cb, (q15_t)0xac3f, (q15_t)0x60c7, (q15_t)0xac3b, (q15_t)0x60c3, (q15_t)0xac36, (q15_t)0x60bf, (q15_t)0xac31, - (q15_t)0x60ba, (q15_t)0xac2c, (q15_t)0x60b6, (q15_t)0xac28, (q15_t)0x60b2, (q15_t)0xac23, (q15_t)0x60ae, (q15_t)0xac1e, - (q15_t)0x60aa, (q15_t)0xac19, (q15_t)0x60a6, (q15_t)0xac15, (q15_t)0x60a2, (q15_t)0xac10, (q15_t)0x609e, (q15_t)0xac0b, - (q15_t)0x6099, (q15_t)0xac06, (q15_t)0x6095, (q15_t)0xac02, (q15_t)0x6091, (q15_t)0xabfd, (q15_t)0x608d, (q15_t)0xabf8, - (q15_t)0x6089, (q15_t)0xabf3, (q15_t)0x6085, (q15_t)0xabef, (q15_t)0x6081, (q15_t)0xabea, (q15_t)0x607d, (q15_t)0xabe5, - (q15_t)0x6078, (q15_t)0xabe0, (q15_t)0x6074, (q15_t)0xabdc, (q15_t)0x6070, (q15_t)0xabd7, (q15_t)0x606c, (q15_t)0xabd2, - (q15_t)0x6068, (q15_t)0xabcd, (q15_t)0x6064, (q15_t)0xabc9, (q15_t)0x6060, (q15_t)0xabc4, (q15_t)0x605c, (q15_t)0xabbf, - (q15_t)0x6057, (q15_t)0xabbb, (q15_t)0x6053, (q15_t)0xabb6, (q15_t)0x604f, (q15_t)0xabb1, (q15_t)0x604b, (q15_t)0xabac, - (q15_t)0x6047, (q15_t)0xaba8, (q15_t)0x6043, (q15_t)0xaba3, (q15_t)0x603f, (q15_t)0xab9e, (q15_t)0x603a, (q15_t)0xab99, - (q15_t)0x6036, (q15_t)0xab95, (q15_t)0x6032, (q15_t)0xab90, (q15_t)0x602e, (q15_t)0xab8b, (q15_t)0x602a, (q15_t)0xab87, - (q15_t)0x6026, (q15_t)0xab82, (q15_t)0x6022, (q15_t)0xab7d, (q15_t)0x601d, (q15_t)0xab78, (q15_t)0x6019, (q15_t)0xab74, - (q15_t)0x6015, (q15_t)0xab6f, (q15_t)0x6011, (q15_t)0xab6a, (q15_t)0x600d, (q15_t)0xab66, (q15_t)0x6009, (q15_t)0xab61, - (q15_t)0x6004, (q15_t)0xab5c, (q15_t)0x6000, (q15_t)0xab57, (q15_t)0x5ffc, (q15_t)0xab53, (q15_t)0x5ff8, (q15_t)0xab4e, - (q15_t)0x5ff4, (q15_t)0xab49, (q15_t)0x5ff0, (q15_t)0xab45, (q15_t)0x5fec, (q15_t)0xab40, (q15_t)0x5fe7, (q15_t)0xab3b, - (q15_t)0x5fe3, (q15_t)0xab36, (q15_t)0x5fdf, (q15_t)0xab32, (q15_t)0x5fdb, (q15_t)0xab2d, (q15_t)0x5fd7, (q15_t)0xab28, - (q15_t)0x5fd3, (q15_t)0xab24, (q15_t)0x5fce, (q15_t)0xab1f, (q15_t)0x5fca, (q15_t)0xab1a, (q15_t)0x5fc6, (q15_t)0xab16, - (q15_t)0x5fc2, (q15_t)0xab11, (q15_t)0x5fbe, (q15_t)0xab0c, (q15_t)0x5fba, (q15_t)0xab07, (q15_t)0x5fb5, (q15_t)0xab03, - (q15_t)0x5fb1, (q15_t)0xaafe, (q15_t)0x5fad, (q15_t)0xaaf9, (q15_t)0x5fa9, (q15_t)0xaaf5, (q15_t)0x5fa5, (q15_t)0xaaf0, - (q15_t)0x5fa0, (q15_t)0xaaeb, (q15_t)0x5f9c, (q15_t)0xaae7, (q15_t)0x5f98, (q15_t)0xaae2, (q15_t)0x5f94, (q15_t)0xaadd, - (q15_t)0x5f90, (q15_t)0xaad8, (q15_t)0x5f8c, (q15_t)0xaad4, (q15_t)0x5f87, (q15_t)0xaacf, (q15_t)0x5f83, (q15_t)0xaaca, - (q15_t)0x5f7f, (q15_t)0xaac6, (q15_t)0x5f7b, (q15_t)0xaac1, (q15_t)0x5f77, (q15_t)0xaabc, (q15_t)0x5f72, (q15_t)0xaab8, - (q15_t)0x5f6e, (q15_t)0xaab3, (q15_t)0x5f6a, (q15_t)0xaaae, (q15_t)0x5f66, (q15_t)0xaaaa, (q15_t)0x5f62, (q15_t)0xaaa5, - (q15_t)0x5f5e, (q15_t)0xaaa0, (q15_t)0x5f59, (q15_t)0xaa9c, (q15_t)0x5f55, (q15_t)0xaa97, (q15_t)0x5f51, (q15_t)0xaa92, - (q15_t)0x5f4d, (q15_t)0xaa8e, (q15_t)0x5f49, (q15_t)0xaa89, (q15_t)0x5f44, (q15_t)0xaa84, (q15_t)0x5f40, (q15_t)0xaa7f, - (q15_t)0x5f3c, (q15_t)0xaa7b, (q15_t)0x5f38, (q15_t)0xaa76, (q15_t)0x5f34, (q15_t)0xaa71, (q15_t)0x5f2f, (q15_t)0xaa6d, - (q15_t)0x5f2b, (q15_t)0xaa68, (q15_t)0x5f27, (q15_t)0xaa63, (q15_t)0x5f23, (q15_t)0xaa5f, (q15_t)0x5f1f, (q15_t)0xaa5a, - (q15_t)0x5f1a, (q15_t)0xaa55, (q15_t)0x5f16, (q15_t)0xaa51, (q15_t)0x5f12, (q15_t)0xaa4c, (q15_t)0x5f0e, (q15_t)0xaa47, - (q15_t)0x5f0a, (q15_t)0xaa43, (q15_t)0x5f05, (q15_t)0xaa3e, (q15_t)0x5f01, (q15_t)0xaa39, (q15_t)0x5efd, (q15_t)0xaa35, - (q15_t)0x5ef9, (q15_t)0xaa30, (q15_t)0x5ef5, (q15_t)0xaa2b, (q15_t)0x5ef0, (q15_t)0xaa27, (q15_t)0x5eec, (q15_t)0xaa22, - (q15_t)0x5ee8, (q15_t)0xaa1d, (q15_t)0x5ee4, (q15_t)0xaa19, (q15_t)0x5edf, (q15_t)0xaa14, (q15_t)0x5edb, (q15_t)0xaa10, - (q15_t)0x5ed7, (q15_t)0xaa0b, (q15_t)0x5ed3, (q15_t)0xaa06, (q15_t)0x5ecf, (q15_t)0xaa02, (q15_t)0x5eca, (q15_t)0xa9fd, - (q15_t)0x5ec6, (q15_t)0xa9f8, (q15_t)0x5ec2, (q15_t)0xa9f4, (q15_t)0x5ebe, (q15_t)0xa9ef, (q15_t)0x5eb9, (q15_t)0xa9ea, - (q15_t)0x5eb5, (q15_t)0xa9e6, (q15_t)0x5eb1, (q15_t)0xa9e1, (q15_t)0x5ead, (q15_t)0xa9dc, (q15_t)0x5ea9, (q15_t)0xa9d8, - (q15_t)0x5ea4, (q15_t)0xa9d3, (q15_t)0x5ea0, (q15_t)0xa9ce, (q15_t)0x5e9c, (q15_t)0xa9ca, (q15_t)0x5e98, (q15_t)0xa9c5, - (q15_t)0x5e93, (q15_t)0xa9c0, (q15_t)0x5e8f, (q15_t)0xa9bc, (q15_t)0x5e8b, (q15_t)0xa9b7, (q15_t)0x5e87, (q15_t)0xa9b3, - (q15_t)0x5e82, (q15_t)0xa9ae, (q15_t)0x5e7e, (q15_t)0xa9a9, (q15_t)0x5e7a, (q15_t)0xa9a5, (q15_t)0x5e76, (q15_t)0xa9a0, - (q15_t)0x5e71, (q15_t)0xa99b, (q15_t)0x5e6d, (q15_t)0xa997, (q15_t)0x5e69, (q15_t)0xa992, (q15_t)0x5e65, (q15_t)0xa98d, - (q15_t)0x5e60, (q15_t)0xa989, (q15_t)0x5e5c, (q15_t)0xa984, (q15_t)0x5e58, (q15_t)0xa980, (q15_t)0x5e54, (q15_t)0xa97b, - (q15_t)0x5e50, (q15_t)0xa976, (q15_t)0x5e4b, (q15_t)0xa972, (q15_t)0x5e47, (q15_t)0xa96d, (q15_t)0x5e43, (q15_t)0xa968, - (q15_t)0x5e3f, (q15_t)0xa964, (q15_t)0x5e3a, (q15_t)0xa95f, (q15_t)0x5e36, (q15_t)0xa95b, (q15_t)0x5e32, (q15_t)0xa956, - (q15_t)0x5e2d, (q15_t)0xa951, (q15_t)0x5e29, (q15_t)0xa94d, (q15_t)0x5e25, (q15_t)0xa948, (q15_t)0x5e21, (q15_t)0xa943, - (q15_t)0x5e1c, (q15_t)0xa93f, (q15_t)0x5e18, (q15_t)0xa93a, (q15_t)0x5e14, (q15_t)0xa936, (q15_t)0x5e10, (q15_t)0xa931, - (q15_t)0x5e0b, (q15_t)0xa92c, (q15_t)0x5e07, (q15_t)0xa928, (q15_t)0x5e03, (q15_t)0xa923, (q15_t)0x5dff, (q15_t)0xa91e, - (q15_t)0x5dfa, (q15_t)0xa91a, (q15_t)0x5df6, (q15_t)0xa915, (q15_t)0x5df2, (q15_t)0xa911, (q15_t)0x5dee, (q15_t)0xa90c, - (q15_t)0x5de9, (q15_t)0xa907, (q15_t)0x5de5, (q15_t)0xa903, (q15_t)0x5de1, (q15_t)0xa8fe, (q15_t)0x5ddc, (q15_t)0xa8fa, - (q15_t)0x5dd8, (q15_t)0xa8f5, (q15_t)0x5dd4, (q15_t)0xa8f0, (q15_t)0x5dd0, (q15_t)0xa8ec, (q15_t)0x5dcb, (q15_t)0xa8e7, - (q15_t)0x5dc7, (q15_t)0xa8e3, (q15_t)0x5dc3, (q15_t)0xa8de, (q15_t)0x5dbf, (q15_t)0xa8d9, (q15_t)0x5dba, (q15_t)0xa8d5, - (q15_t)0x5db6, (q15_t)0xa8d0, (q15_t)0x5db2, (q15_t)0xa8cc, (q15_t)0x5dad, (q15_t)0xa8c7, (q15_t)0x5da9, (q15_t)0xa8c2, - (q15_t)0x5da5, (q15_t)0xa8be, (q15_t)0x5da1, (q15_t)0xa8b9, (q15_t)0x5d9c, (q15_t)0xa8b5, (q15_t)0x5d98, (q15_t)0xa8b0, - (q15_t)0x5d94, (q15_t)0xa8ab, (q15_t)0x5d8f, (q15_t)0xa8a7, (q15_t)0x5d8b, (q15_t)0xa8a2, (q15_t)0x5d87, (q15_t)0xa89e, - (q15_t)0x5d83, (q15_t)0xa899, (q15_t)0x5d7e, (q15_t)0xa894, (q15_t)0x5d7a, (q15_t)0xa890, (q15_t)0x5d76, (q15_t)0xa88b, - (q15_t)0x5d71, (q15_t)0xa887, (q15_t)0x5d6d, (q15_t)0xa882, (q15_t)0x5d69, (q15_t)0xa87d, (q15_t)0x5d65, (q15_t)0xa879, - (q15_t)0x5d60, (q15_t)0xa874, (q15_t)0x5d5c, (q15_t)0xa870, (q15_t)0x5d58, (q15_t)0xa86b, (q15_t)0x5d53, (q15_t)0xa867, - (q15_t)0x5d4f, (q15_t)0xa862, (q15_t)0x5d4b, (q15_t)0xa85d, (q15_t)0x5d46, (q15_t)0xa859, (q15_t)0x5d42, (q15_t)0xa854, - (q15_t)0x5d3e, (q15_t)0xa850, (q15_t)0x5d3a, (q15_t)0xa84b, (q15_t)0x5d35, (q15_t)0xa847, (q15_t)0x5d31, (q15_t)0xa842, - (q15_t)0x5d2d, (q15_t)0xa83d, (q15_t)0x5d28, (q15_t)0xa839, (q15_t)0x5d24, (q15_t)0xa834, (q15_t)0x5d20, (q15_t)0xa830, - (q15_t)0x5d1b, (q15_t)0xa82b, (q15_t)0x5d17, (q15_t)0xa827, (q15_t)0x5d13, (q15_t)0xa822, (q15_t)0x5d0e, (q15_t)0xa81d, - (q15_t)0x5d0a, (q15_t)0xa819, (q15_t)0x5d06, (q15_t)0xa814, (q15_t)0x5d01, (q15_t)0xa810, (q15_t)0x5cfd, (q15_t)0xa80b, - (q15_t)0x5cf9, (q15_t)0xa807, (q15_t)0x5cf5, (q15_t)0xa802, (q15_t)0x5cf0, (q15_t)0xa7fd, (q15_t)0x5cec, (q15_t)0xa7f9, - (q15_t)0x5ce8, (q15_t)0xa7f4, (q15_t)0x5ce3, (q15_t)0xa7f0, (q15_t)0x5cdf, (q15_t)0xa7eb, (q15_t)0x5cdb, (q15_t)0xa7e7, - (q15_t)0x5cd6, (q15_t)0xa7e2, (q15_t)0x5cd2, (q15_t)0xa7de, (q15_t)0x5cce, (q15_t)0xa7d9, (q15_t)0x5cc9, (q15_t)0xa7d4, - (q15_t)0x5cc5, (q15_t)0xa7d0, (q15_t)0x5cc1, (q15_t)0xa7cb, (q15_t)0x5cbc, (q15_t)0xa7c7, (q15_t)0x5cb8, (q15_t)0xa7c2, - (q15_t)0x5cb4, (q15_t)0xa7be, (q15_t)0x5caf, (q15_t)0xa7b9, (q15_t)0x5cab, (q15_t)0xa7b5, (q15_t)0x5ca7, (q15_t)0xa7b0, - (q15_t)0x5ca2, (q15_t)0xa7ab, (q15_t)0x5c9e, (q15_t)0xa7a7, (q15_t)0x5c9a, (q15_t)0xa7a2, (q15_t)0x5c95, (q15_t)0xa79e, - (q15_t)0x5c91, (q15_t)0xa799, (q15_t)0x5c8d, (q15_t)0xa795, (q15_t)0x5c88, (q15_t)0xa790, (q15_t)0x5c84, (q15_t)0xa78c, - (q15_t)0x5c80, (q15_t)0xa787, (q15_t)0x5c7b, (q15_t)0xa783, (q15_t)0x5c77, (q15_t)0xa77e, (q15_t)0x5c73, (q15_t)0xa779, - (q15_t)0x5c6e, (q15_t)0xa775, (q15_t)0x5c6a, (q15_t)0xa770, (q15_t)0x5c66, (q15_t)0xa76c, (q15_t)0x5c61, (q15_t)0xa767, - (q15_t)0x5c5d, (q15_t)0xa763, (q15_t)0x5c58, (q15_t)0xa75e, (q15_t)0x5c54, (q15_t)0xa75a, (q15_t)0x5c50, (q15_t)0xa755, - (q15_t)0x5c4b, (q15_t)0xa751, (q15_t)0x5c47, (q15_t)0xa74c, (q15_t)0x5c43, (q15_t)0xa748, (q15_t)0x5c3e, (q15_t)0xa743, - (q15_t)0x5c3a, (q15_t)0xa73f, (q15_t)0x5c36, (q15_t)0xa73a, (q15_t)0x5c31, (q15_t)0xa735, (q15_t)0x5c2d, (q15_t)0xa731, - (q15_t)0x5c29, (q15_t)0xa72c, (q15_t)0x5c24, (q15_t)0xa728, (q15_t)0x5c20, (q15_t)0xa723, (q15_t)0x5c1b, (q15_t)0xa71f, - (q15_t)0x5c17, (q15_t)0xa71a, (q15_t)0x5c13, (q15_t)0xa716, (q15_t)0x5c0e, (q15_t)0xa711, (q15_t)0x5c0a, (q15_t)0xa70d, - (q15_t)0x5c06, (q15_t)0xa708, (q15_t)0x5c01, (q15_t)0xa704, (q15_t)0x5bfd, (q15_t)0xa6ff, (q15_t)0x5bf9, (q15_t)0xa6fb, - (q15_t)0x5bf4, (q15_t)0xa6f6, (q15_t)0x5bf0, (q15_t)0xa6f2, (q15_t)0x5beb, (q15_t)0xa6ed, (q15_t)0x5be7, (q15_t)0xa6e9, - (q15_t)0x5be3, (q15_t)0xa6e4, (q15_t)0x5bde, (q15_t)0xa6e0, (q15_t)0x5bda, (q15_t)0xa6db, (q15_t)0x5bd6, (q15_t)0xa6d7, - (q15_t)0x5bd1, (q15_t)0xa6d2, (q15_t)0x5bcd, (q15_t)0xa6ce, (q15_t)0x5bc8, (q15_t)0xa6c9, (q15_t)0x5bc4, (q15_t)0xa6c5, - (q15_t)0x5bc0, (q15_t)0xa6c0, (q15_t)0x5bbb, (q15_t)0xa6bc, (q15_t)0x5bb7, (q15_t)0xa6b7, (q15_t)0x5bb2, (q15_t)0xa6b3, - (q15_t)0x5bae, (q15_t)0xa6ae, (q15_t)0x5baa, (q15_t)0xa6aa, (q15_t)0x5ba5, (q15_t)0xa6a5, (q15_t)0x5ba1, (q15_t)0xa6a1, - (q15_t)0x5b9d, (q15_t)0xa69c, (q15_t)0x5b98, (q15_t)0xa698, (q15_t)0x5b94, (q15_t)0xa693, (q15_t)0x5b8f, (q15_t)0xa68f, - (q15_t)0x5b8b, (q15_t)0xa68a, (q15_t)0x5b87, (q15_t)0xa686, (q15_t)0x5b82, (q15_t)0xa681, (q15_t)0x5b7e, (q15_t)0xa67d, - (q15_t)0x5b79, (q15_t)0xa678, (q15_t)0x5b75, (q15_t)0xa674, (q15_t)0x5b71, (q15_t)0xa66f, (q15_t)0x5b6c, (q15_t)0xa66b, - (q15_t)0x5b68, (q15_t)0xa666, (q15_t)0x5b63, (q15_t)0xa662, (q15_t)0x5b5f, (q15_t)0xa65d, (q15_t)0x5b5b, (q15_t)0xa659, - (q15_t)0x5b56, (q15_t)0xa654, (q15_t)0x5b52, (q15_t)0xa650, (q15_t)0x5b4d, (q15_t)0xa64b, (q15_t)0x5b49, (q15_t)0xa647, - (q15_t)0x5b45, (q15_t)0xa642, (q15_t)0x5b40, (q15_t)0xa63e, (q15_t)0x5b3c, (q15_t)0xa639, (q15_t)0x5b37, (q15_t)0xa635, - (q15_t)0x5b33, (q15_t)0xa630, (q15_t)0x5b2f, (q15_t)0xa62c, (q15_t)0x5b2a, (q15_t)0xa627, (q15_t)0x5b26, (q15_t)0xa623, - (q15_t)0x5b21, (q15_t)0xa61f, (q15_t)0x5b1d, (q15_t)0xa61a, (q15_t)0x5b19, (q15_t)0xa616, (q15_t)0x5b14, (q15_t)0xa611, - (q15_t)0x5b10, (q15_t)0xa60d, (q15_t)0x5b0b, (q15_t)0xa608, (q15_t)0x5b07, (q15_t)0xa604, (q15_t)0x5b02, (q15_t)0xa5ff, - (q15_t)0x5afe, (q15_t)0xa5fb, (q15_t)0x5afa, (q15_t)0xa5f6, (q15_t)0x5af5, (q15_t)0xa5f2, (q15_t)0x5af1, (q15_t)0xa5ed, - (q15_t)0x5aec, (q15_t)0xa5e9, (q15_t)0x5ae8, (q15_t)0xa5e4, (q15_t)0x5ae4, (q15_t)0xa5e0, (q15_t)0x5adf, (q15_t)0xa5dc, - (q15_t)0x5adb, (q15_t)0xa5d7, (q15_t)0x5ad6, (q15_t)0xa5d3, (q15_t)0x5ad2, (q15_t)0xa5ce, (q15_t)0x5acd, (q15_t)0xa5ca, - (q15_t)0x5ac9, (q15_t)0xa5c5, (q15_t)0x5ac5, (q15_t)0xa5c1, (q15_t)0x5ac0, (q15_t)0xa5bc, (q15_t)0x5abc, (q15_t)0xa5b8, - (q15_t)0x5ab7, (q15_t)0xa5b3, (q15_t)0x5ab3, (q15_t)0xa5af, (q15_t)0x5aae, (q15_t)0xa5aa, (q15_t)0x5aaa, (q15_t)0xa5a6, - (q15_t)0x5aa5, (q15_t)0xa5a2, (q15_t)0x5aa1, (q15_t)0xa59d, (q15_t)0x5a9d, (q15_t)0xa599, (q15_t)0x5a98, (q15_t)0xa594, - (q15_t)0x5a94, (q15_t)0xa590, (q15_t)0x5a8f, (q15_t)0xa58b, (q15_t)0x5a8b, (q15_t)0xa587, (q15_t)0x5a86, (q15_t)0xa582, - (q15_t)0x5a82, (q15_t)0xa57e, (q15_t)0x5a7e, (q15_t)0xa57a, (q15_t)0x5a79, (q15_t)0xa575, (q15_t)0x5a75, (q15_t)0xa571, - (q15_t)0x5a70, (q15_t)0xa56c, (q15_t)0x5a6c, (q15_t)0xa568, (q15_t)0x5a67, (q15_t)0xa563, (q15_t)0x5a63, (q15_t)0xa55f, - (q15_t)0x5a5e, (q15_t)0xa55b, (q15_t)0x5a5a, (q15_t)0xa556, (q15_t)0x5a56, (q15_t)0xa552, (q15_t)0x5a51, (q15_t)0xa54d, - (q15_t)0x5a4d, (q15_t)0xa549, (q15_t)0x5a48, (q15_t)0xa544, (q15_t)0x5a44, (q15_t)0xa540, (q15_t)0x5a3f, (q15_t)0xa53b, - (q15_t)0x5a3b, (q15_t)0xa537, (q15_t)0x5a36, (q15_t)0xa533, (q15_t)0x5a32, (q15_t)0xa52e, (q15_t)0x5a2d, (q15_t)0xa52a, - (q15_t)0x5a29, (q15_t)0xa525, (q15_t)0x5a24, (q15_t)0xa521, (q15_t)0x5a20, (q15_t)0xa51c, (q15_t)0x5a1c, (q15_t)0xa518, - (q15_t)0x5a17, (q15_t)0xa514, (q15_t)0x5a13, (q15_t)0xa50f, (q15_t)0x5a0e, (q15_t)0xa50b, (q15_t)0x5a0a, (q15_t)0xa506, - (q15_t)0x5a05, (q15_t)0xa502, (q15_t)0x5a01, (q15_t)0xa4fe, (q15_t)0x59fc, (q15_t)0xa4f9, (q15_t)0x59f8, (q15_t)0xa4f5, - (q15_t)0x59f3, (q15_t)0xa4f0, (q15_t)0x59ef, (q15_t)0xa4ec, (q15_t)0x59ea, (q15_t)0xa4e7, (q15_t)0x59e6, (q15_t)0xa4e3, - (q15_t)0x59e1, (q15_t)0xa4df, (q15_t)0x59dd, (q15_t)0xa4da, (q15_t)0x59d9, (q15_t)0xa4d6, (q15_t)0x59d4, (q15_t)0xa4d1, - (q15_t)0x59d0, (q15_t)0xa4cd, (q15_t)0x59cb, (q15_t)0xa4c9, (q15_t)0x59c7, (q15_t)0xa4c4, (q15_t)0x59c2, (q15_t)0xa4c0, - (q15_t)0x59be, (q15_t)0xa4bb, (q15_t)0x59b9, (q15_t)0xa4b7, (q15_t)0x59b5, (q15_t)0xa4b3, (q15_t)0x59b0, (q15_t)0xa4ae, - (q15_t)0x59ac, (q15_t)0xa4aa, (q15_t)0x59a7, (q15_t)0xa4a5, (q15_t)0x59a3, (q15_t)0xa4a1, (q15_t)0x599e, (q15_t)0xa49d, - (q15_t)0x599a, (q15_t)0xa498, (q15_t)0x5995, (q15_t)0xa494, (q15_t)0x5991, (q15_t)0xa48f, (q15_t)0x598c, (q15_t)0xa48b, - (q15_t)0x5988, (q15_t)0xa487, (q15_t)0x5983, (q15_t)0xa482, (q15_t)0x597f, (q15_t)0xa47e, (q15_t)0x597a, (q15_t)0xa479, - (q15_t)0x5976, (q15_t)0xa475, (q15_t)0x5971, (q15_t)0xa471, (q15_t)0x596d, (q15_t)0xa46c, (q15_t)0x5968, (q15_t)0xa468, - (q15_t)0x5964, (q15_t)0xa463, (q15_t)0x595f, (q15_t)0xa45f, (q15_t)0x595b, (q15_t)0xa45b, (q15_t)0x5956, (q15_t)0xa456, - (q15_t)0x5952, (q15_t)0xa452, (q15_t)0x594d, (q15_t)0xa44e, (q15_t)0x5949, (q15_t)0xa449, (q15_t)0x5944, (q15_t)0xa445, - (q15_t)0x5940, (q15_t)0xa440, (q15_t)0x593b, (q15_t)0xa43c, (q15_t)0x5937, (q15_t)0xa438, (q15_t)0x5932, (q15_t)0xa433, - (q15_t)0x592e, (q15_t)0xa42f, (q15_t)0x5929, (q15_t)0xa42a, (q15_t)0x5925, (q15_t)0xa426, (q15_t)0x5920, (q15_t)0xa422, - (q15_t)0x591c, (q15_t)0xa41d, (q15_t)0x5917, (q15_t)0xa419, (q15_t)0x5913, (q15_t)0xa415, (q15_t)0x590e, (q15_t)0xa410, - (q15_t)0x590a, (q15_t)0xa40c, (q15_t)0x5905, (q15_t)0xa407, (q15_t)0x5901, (q15_t)0xa403, (q15_t)0x58fc, (q15_t)0xa3ff, - (q15_t)0x58f8, (q15_t)0xa3fa, (q15_t)0x58f3, (q15_t)0xa3f6, (q15_t)0x58ef, (q15_t)0xa3f2, (q15_t)0x58ea, (q15_t)0xa3ed, - (q15_t)0x58e6, (q15_t)0xa3e9, (q15_t)0x58e1, (q15_t)0xa3e5, (q15_t)0x58dd, (q15_t)0xa3e0, (q15_t)0x58d8, (q15_t)0xa3dc, - (q15_t)0x58d4, (q15_t)0xa3d7, (q15_t)0x58cf, (q15_t)0xa3d3, (q15_t)0x58cb, (q15_t)0xa3cf, (q15_t)0x58c6, (q15_t)0xa3ca, - (q15_t)0x58c1, (q15_t)0xa3c6, (q15_t)0x58bd, (q15_t)0xa3c2, (q15_t)0x58b8, (q15_t)0xa3bd, (q15_t)0x58b4, (q15_t)0xa3b9, - (q15_t)0x58af, (q15_t)0xa3b5, (q15_t)0x58ab, (q15_t)0xa3b0, (q15_t)0x58a6, (q15_t)0xa3ac, (q15_t)0x58a2, (q15_t)0xa3a8, - (q15_t)0x589d, (q15_t)0xa3a3, (q15_t)0x5899, (q15_t)0xa39f, (q15_t)0x5894, (q15_t)0xa39a, (q15_t)0x5890, (q15_t)0xa396, - (q15_t)0x588b, (q15_t)0xa392, (q15_t)0x5887, (q15_t)0xa38d, (q15_t)0x5882, (q15_t)0xa389, (q15_t)0x587d, (q15_t)0xa385, - (q15_t)0x5879, (q15_t)0xa380, (q15_t)0x5874, (q15_t)0xa37c, (q15_t)0x5870, (q15_t)0xa378, (q15_t)0x586b, (q15_t)0xa373, - (q15_t)0x5867, (q15_t)0xa36f, (q15_t)0x5862, (q15_t)0xa36b, (q15_t)0x585e, (q15_t)0xa366, (q15_t)0x5859, (q15_t)0xa362, - (q15_t)0x5855, (q15_t)0xa35e, (q15_t)0x5850, (q15_t)0xa359, (q15_t)0x584b, (q15_t)0xa355, (q15_t)0x5847, (q15_t)0xa351, - (q15_t)0x5842, (q15_t)0xa34c, (q15_t)0x583e, (q15_t)0xa348, (q15_t)0x5839, (q15_t)0xa344, (q15_t)0x5835, (q15_t)0xa33f, - (q15_t)0x5830, (q15_t)0xa33b, (q15_t)0x582c, (q15_t)0xa337, (q15_t)0x5827, (q15_t)0xa332, (q15_t)0x5822, (q15_t)0xa32e, - (q15_t)0x581e, (q15_t)0xa32a, (q15_t)0x5819, (q15_t)0xa325, (q15_t)0x5815, (q15_t)0xa321, (q15_t)0x5810, (q15_t)0xa31d, - (q15_t)0x580c, (q15_t)0xa318, (q15_t)0x5807, (q15_t)0xa314, (q15_t)0x5803, (q15_t)0xa310, (q15_t)0x57fe, (q15_t)0xa30b, - (q15_t)0x57f9, (q15_t)0xa307, (q15_t)0x57f5, (q15_t)0xa303, (q15_t)0x57f0, (q15_t)0xa2ff, (q15_t)0x57ec, (q15_t)0xa2fa, - (q15_t)0x57e7, (q15_t)0xa2f6, (q15_t)0x57e3, (q15_t)0xa2f2, (q15_t)0x57de, (q15_t)0xa2ed, (q15_t)0x57d9, (q15_t)0xa2e9, - (q15_t)0x57d5, (q15_t)0xa2e5, (q15_t)0x57d0, (q15_t)0xa2e0, (q15_t)0x57cc, (q15_t)0xa2dc, (q15_t)0x57c7, (q15_t)0xa2d8, - (q15_t)0x57c3, (q15_t)0xa2d3, (q15_t)0x57be, (q15_t)0xa2cf, (q15_t)0x57b9, (q15_t)0xa2cb, (q15_t)0x57b5, (q15_t)0xa2c6, - (q15_t)0x57b0, (q15_t)0xa2c2, (q15_t)0x57ac, (q15_t)0xa2be, (q15_t)0x57a7, (q15_t)0xa2ba, (q15_t)0x57a3, (q15_t)0xa2b5, - (q15_t)0x579e, (q15_t)0xa2b1, (q15_t)0x5799, (q15_t)0xa2ad, (q15_t)0x5795, (q15_t)0xa2a8, (q15_t)0x5790, (q15_t)0xa2a4, - (q15_t)0x578c, (q15_t)0xa2a0, (q15_t)0x5787, (q15_t)0xa29b, (q15_t)0x5783, (q15_t)0xa297, (q15_t)0x577e, (q15_t)0xa293, - (q15_t)0x5779, (q15_t)0xa28f, (q15_t)0x5775, (q15_t)0xa28a, (q15_t)0x5770, (q15_t)0xa286, (q15_t)0x576c, (q15_t)0xa282, - (q15_t)0x5767, (q15_t)0xa27d, (q15_t)0x5762, (q15_t)0xa279, (q15_t)0x575e, (q15_t)0xa275, (q15_t)0x5759, (q15_t)0xa271, - (q15_t)0x5755, (q15_t)0xa26c, (q15_t)0x5750, (q15_t)0xa268, (q15_t)0x574b, (q15_t)0xa264, (q15_t)0x5747, (q15_t)0xa25f, - (q15_t)0x5742, (q15_t)0xa25b, (q15_t)0x573e, (q15_t)0xa257, (q15_t)0x5739, (q15_t)0xa253, (q15_t)0x5734, (q15_t)0xa24e, - (q15_t)0x5730, (q15_t)0xa24a, (q15_t)0x572b, (q15_t)0xa246, (q15_t)0x5727, (q15_t)0xa241, (q15_t)0x5722, (q15_t)0xa23d, - (q15_t)0x571d, (q15_t)0xa239, (q15_t)0x5719, (q15_t)0xa235, (q15_t)0x5714, (q15_t)0xa230, (q15_t)0x5710, (q15_t)0xa22c, - (q15_t)0x570b, (q15_t)0xa228, (q15_t)0x5706, (q15_t)0xa224, (q15_t)0x5702, (q15_t)0xa21f, (q15_t)0x56fd, (q15_t)0xa21b, - (q15_t)0x56f9, (q15_t)0xa217, (q15_t)0x56f4, (q15_t)0xa212, (q15_t)0x56ef, (q15_t)0xa20e, (q15_t)0x56eb, (q15_t)0xa20a, - (q15_t)0x56e6, (q15_t)0xa206, (q15_t)0x56e2, (q15_t)0xa201, (q15_t)0x56dd, (q15_t)0xa1fd, (q15_t)0x56d8, (q15_t)0xa1f9, - (q15_t)0x56d4, (q15_t)0xa1f5, (q15_t)0x56cf, (q15_t)0xa1f0, (q15_t)0x56ca, (q15_t)0xa1ec, (q15_t)0x56c6, (q15_t)0xa1e8, - (q15_t)0x56c1, (q15_t)0xa1e4, (q15_t)0x56bd, (q15_t)0xa1df, (q15_t)0x56b8, (q15_t)0xa1db, (q15_t)0x56b3, (q15_t)0xa1d7, - (q15_t)0x56af, (q15_t)0xa1d3, (q15_t)0x56aa, (q15_t)0xa1ce, (q15_t)0x56a5, (q15_t)0xa1ca, (q15_t)0x56a1, (q15_t)0xa1c6, - (q15_t)0x569c, (q15_t)0xa1c1, (q15_t)0x5698, (q15_t)0xa1bd, (q15_t)0x5693, (q15_t)0xa1b9, (q15_t)0x568e, (q15_t)0xa1b5, - (q15_t)0x568a, (q15_t)0xa1b0, (q15_t)0x5685, (q15_t)0xa1ac, (q15_t)0x5680, (q15_t)0xa1a8, (q15_t)0x567c, (q15_t)0xa1a4, - (q15_t)0x5677, (q15_t)0xa1a0, (q15_t)0x5673, (q15_t)0xa19b, (q15_t)0x566e, (q15_t)0xa197, (q15_t)0x5669, (q15_t)0xa193, - (q15_t)0x5665, (q15_t)0xa18f, (q15_t)0x5660, (q15_t)0xa18a, (q15_t)0x565b, (q15_t)0xa186, (q15_t)0x5657, (q15_t)0xa182, - (q15_t)0x5652, (q15_t)0xa17e, (q15_t)0x564d, (q15_t)0xa179, (q15_t)0x5649, (q15_t)0xa175, (q15_t)0x5644, (q15_t)0xa171, - (q15_t)0x5640, (q15_t)0xa16d, (q15_t)0x563b, (q15_t)0xa168, (q15_t)0x5636, (q15_t)0xa164, (q15_t)0x5632, (q15_t)0xa160, - (q15_t)0x562d, (q15_t)0xa15c, (q15_t)0x5628, (q15_t)0xa157, (q15_t)0x5624, (q15_t)0xa153, (q15_t)0x561f, (q15_t)0xa14f, - (q15_t)0x561a, (q15_t)0xa14b, (q15_t)0x5616, (q15_t)0xa147, (q15_t)0x5611, (q15_t)0xa142, (q15_t)0x560c, (q15_t)0xa13e, - (q15_t)0x5608, (q15_t)0xa13a, (q15_t)0x5603, (q15_t)0xa136, (q15_t)0x55fe, (q15_t)0xa131, (q15_t)0x55fa, (q15_t)0xa12d, - (q15_t)0x55f5, (q15_t)0xa129, (q15_t)0x55f0, (q15_t)0xa125, (q15_t)0x55ec, (q15_t)0xa121, (q15_t)0x55e7, (q15_t)0xa11c, - (q15_t)0x55e3, (q15_t)0xa118, (q15_t)0x55de, (q15_t)0xa114, (q15_t)0x55d9, (q15_t)0xa110, (q15_t)0x55d5, (q15_t)0xa10b, - (q15_t)0x55d0, (q15_t)0xa107, (q15_t)0x55cb, (q15_t)0xa103, (q15_t)0x55c7, (q15_t)0xa0ff, (q15_t)0x55c2, (q15_t)0xa0fb, - (q15_t)0x55bd, (q15_t)0xa0f6, (q15_t)0x55b9, (q15_t)0xa0f2, (q15_t)0x55b4, (q15_t)0xa0ee, (q15_t)0x55af, (q15_t)0xa0ea, - (q15_t)0x55ab, (q15_t)0xa0e6, (q15_t)0x55a6, (q15_t)0xa0e1, (q15_t)0x55a1, (q15_t)0xa0dd, (q15_t)0x559d, (q15_t)0xa0d9, - (q15_t)0x5598, (q15_t)0xa0d5, (q15_t)0x5593, (q15_t)0xa0d1, (q15_t)0x558f, (q15_t)0xa0cc, (q15_t)0x558a, (q15_t)0xa0c8, - (q15_t)0x5585, (q15_t)0xa0c4, (q15_t)0x5581, (q15_t)0xa0c0, (q15_t)0x557c, (q15_t)0xa0bc, (q15_t)0x5577, (q15_t)0xa0b7, - (q15_t)0x5572, (q15_t)0xa0b3, (q15_t)0x556e, (q15_t)0xa0af, (q15_t)0x5569, (q15_t)0xa0ab, (q15_t)0x5564, (q15_t)0xa0a7, - (q15_t)0x5560, (q15_t)0xa0a2, (q15_t)0x555b, (q15_t)0xa09e, (q15_t)0x5556, (q15_t)0xa09a, (q15_t)0x5552, (q15_t)0xa096, - (q15_t)0x554d, (q15_t)0xa092, (q15_t)0x5548, (q15_t)0xa08e, (q15_t)0x5544, (q15_t)0xa089, (q15_t)0x553f, (q15_t)0xa085, - (q15_t)0x553a, (q15_t)0xa081, (q15_t)0x5536, (q15_t)0xa07d, (q15_t)0x5531, (q15_t)0xa079, (q15_t)0x552c, (q15_t)0xa074, - (q15_t)0x5528, (q15_t)0xa070, (q15_t)0x5523, (q15_t)0xa06c, (q15_t)0x551e, (q15_t)0xa068, (q15_t)0x5519, (q15_t)0xa064, - (q15_t)0x5515, (q15_t)0xa060, (q15_t)0x5510, (q15_t)0xa05b, (q15_t)0x550b, (q15_t)0xa057, (q15_t)0x5507, (q15_t)0xa053, - (q15_t)0x5502, (q15_t)0xa04f, (q15_t)0x54fd, (q15_t)0xa04b, (q15_t)0x54f9, (q15_t)0xa046, (q15_t)0x54f4, (q15_t)0xa042, - (q15_t)0x54ef, (q15_t)0xa03e, (q15_t)0x54ea, (q15_t)0xa03a, (q15_t)0x54e6, (q15_t)0xa036, (q15_t)0x54e1, (q15_t)0xa032, - (q15_t)0x54dc, (q15_t)0xa02d, (q15_t)0x54d8, (q15_t)0xa029, (q15_t)0x54d3, (q15_t)0xa025, (q15_t)0x54ce, (q15_t)0xa021, - (q15_t)0x54ca, (q15_t)0xa01d, (q15_t)0x54c5, (q15_t)0xa019, (q15_t)0x54c0, (q15_t)0xa014, (q15_t)0x54bb, (q15_t)0xa010, - (q15_t)0x54b7, (q15_t)0xa00c, (q15_t)0x54b2, (q15_t)0xa008, (q15_t)0x54ad, (q15_t)0xa004, (q15_t)0x54a9, (q15_t)0xa000, - (q15_t)0x54a4, (q15_t)0x9ffc, (q15_t)0x549f, (q15_t)0x9ff7, (q15_t)0x549a, (q15_t)0x9ff3, (q15_t)0x5496, (q15_t)0x9fef, - (q15_t)0x5491, (q15_t)0x9feb, (q15_t)0x548c, (q15_t)0x9fe7, (q15_t)0x5488, (q15_t)0x9fe3, (q15_t)0x5483, (q15_t)0x9fde, - (q15_t)0x547e, (q15_t)0x9fda, (q15_t)0x5479, (q15_t)0x9fd6, (q15_t)0x5475, (q15_t)0x9fd2, (q15_t)0x5470, (q15_t)0x9fce, - (q15_t)0x546b, (q15_t)0x9fca, (q15_t)0x5467, (q15_t)0x9fc6, (q15_t)0x5462, (q15_t)0x9fc1, (q15_t)0x545d, (q15_t)0x9fbd, - (q15_t)0x5458, (q15_t)0x9fb9, (q15_t)0x5454, (q15_t)0x9fb5, (q15_t)0x544f, (q15_t)0x9fb1, (q15_t)0x544a, (q15_t)0x9fad, - (q15_t)0x5445, (q15_t)0x9fa9, (q15_t)0x5441, (q15_t)0x9fa4, (q15_t)0x543c, (q15_t)0x9fa0, (q15_t)0x5437, (q15_t)0x9f9c, - (q15_t)0x5433, (q15_t)0x9f98, (q15_t)0x542e, (q15_t)0x9f94, (q15_t)0x5429, (q15_t)0x9f90, (q15_t)0x5424, (q15_t)0x9f8c, - (q15_t)0x5420, (q15_t)0x9f88, (q15_t)0x541b, (q15_t)0x9f83, (q15_t)0x5416, (q15_t)0x9f7f, (q15_t)0x5411, (q15_t)0x9f7b, - (q15_t)0x540d, (q15_t)0x9f77, (q15_t)0x5408, (q15_t)0x9f73, (q15_t)0x5403, (q15_t)0x9f6f, (q15_t)0x53fe, (q15_t)0x9f6b, - (q15_t)0x53fa, (q15_t)0x9f67, (q15_t)0x53f5, (q15_t)0x9f62, (q15_t)0x53f0, (q15_t)0x9f5e, (q15_t)0x53eb, (q15_t)0x9f5a, - (q15_t)0x53e7, (q15_t)0x9f56, (q15_t)0x53e2, (q15_t)0x9f52, (q15_t)0x53dd, (q15_t)0x9f4e, (q15_t)0x53d8, (q15_t)0x9f4a, - (q15_t)0x53d4, (q15_t)0x9f46, (q15_t)0x53cf, (q15_t)0x9f41, (q15_t)0x53ca, (q15_t)0x9f3d, (q15_t)0x53c5, (q15_t)0x9f39, - (q15_t)0x53c1, (q15_t)0x9f35, (q15_t)0x53bc, (q15_t)0x9f31, (q15_t)0x53b7, (q15_t)0x9f2d, (q15_t)0x53b2, (q15_t)0x9f29, - (q15_t)0x53ae, (q15_t)0x9f25, (q15_t)0x53a9, (q15_t)0x9f21, (q15_t)0x53a4, (q15_t)0x9f1c, (q15_t)0x539f, (q15_t)0x9f18, - (q15_t)0x539b, (q15_t)0x9f14, (q15_t)0x5396, (q15_t)0x9f10, (q15_t)0x5391, (q15_t)0x9f0c, (q15_t)0x538c, (q15_t)0x9f08, - (q15_t)0x5388, (q15_t)0x9f04, (q15_t)0x5383, (q15_t)0x9f00, (q15_t)0x537e, (q15_t)0x9efc, (q15_t)0x5379, (q15_t)0x9ef8, - (q15_t)0x5375, (q15_t)0x9ef3, (q15_t)0x5370, (q15_t)0x9eef, (q15_t)0x536b, (q15_t)0x9eeb, (q15_t)0x5366, (q15_t)0x9ee7, - (q15_t)0x5362, (q15_t)0x9ee3, (q15_t)0x535d, (q15_t)0x9edf, (q15_t)0x5358, (q15_t)0x9edb, (q15_t)0x5353, (q15_t)0x9ed7, - (q15_t)0x534e, (q15_t)0x9ed3, (q15_t)0x534a, (q15_t)0x9ecf, (q15_t)0x5345, (q15_t)0x9ecb, (q15_t)0x5340, (q15_t)0x9ec6, - (q15_t)0x533b, (q15_t)0x9ec2, (q15_t)0x5337, (q15_t)0x9ebe, (q15_t)0x5332, (q15_t)0x9eba, (q15_t)0x532d, (q15_t)0x9eb6, - (q15_t)0x5328, (q15_t)0x9eb2, (q15_t)0x5323, (q15_t)0x9eae, (q15_t)0x531f, (q15_t)0x9eaa, (q15_t)0x531a, (q15_t)0x9ea6, - (q15_t)0x5315, (q15_t)0x9ea2, (q15_t)0x5310, (q15_t)0x9e9e, (q15_t)0x530c, (q15_t)0x9e9a, (q15_t)0x5307, (q15_t)0x9e95, - (q15_t)0x5302, (q15_t)0x9e91, (q15_t)0x52fd, (q15_t)0x9e8d, (q15_t)0x52f8, (q15_t)0x9e89, (q15_t)0x52f4, (q15_t)0x9e85, - (q15_t)0x52ef, (q15_t)0x9e81, (q15_t)0x52ea, (q15_t)0x9e7d, (q15_t)0x52e5, (q15_t)0x9e79, (q15_t)0x52e1, (q15_t)0x9e75, - (q15_t)0x52dc, (q15_t)0x9e71, (q15_t)0x52d7, (q15_t)0x9e6d, (q15_t)0x52d2, (q15_t)0x9e69, (q15_t)0x52cd, (q15_t)0x9e65, - (q15_t)0x52c9, (q15_t)0x9e61, (q15_t)0x52c4, (q15_t)0x9e5d, (q15_t)0x52bf, (q15_t)0x9e58, (q15_t)0x52ba, (q15_t)0x9e54, - (q15_t)0x52b5, (q15_t)0x9e50, (q15_t)0x52b1, (q15_t)0x9e4c, (q15_t)0x52ac, (q15_t)0x9e48, (q15_t)0x52a7, (q15_t)0x9e44, - (q15_t)0x52a2, (q15_t)0x9e40, (q15_t)0x529d, (q15_t)0x9e3c, (q15_t)0x5299, (q15_t)0x9e38, (q15_t)0x5294, (q15_t)0x9e34, - (q15_t)0x528f, (q15_t)0x9e30, (q15_t)0x528a, (q15_t)0x9e2c, (q15_t)0x5285, (q15_t)0x9e28, (q15_t)0x5281, (q15_t)0x9e24, - (q15_t)0x527c, (q15_t)0x9e20, (q15_t)0x5277, (q15_t)0x9e1c, (q15_t)0x5272, (q15_t)0x9e18, (q15_t)0x526d, (q15_t)0x9e14, - (q15_t)0x5269, (q15_t)0x9e0f, (q15_t)0x5264, (q15_t)0x9e0b, (q15_t)0x525f, (q15_t)0x9e07, (q15_t)0x525a, (q15_t)0x9e03, - (q15_t)0x5255, (q15_t)0x9dff, (q15_t)0x5251, (q15_t)0x9dfb, (q15_t)0x524c, (q15_t)0x9df7, (q15_t)0x5247, (q15_t)0x9df3, - (q15_t)0x5242, (q15_t)0x9def, (q15_t)0x523d, (q15_t)0x9deb, (q15_t)0x5238, (q15_t)0x9de7, (q15_t)0x5234, (q15_t)0x9de3, - (q15_t)0x522f, (q15_t)0x9ddf, (q15_t)0x522a, (q15_t)0x9ddb, (q15_t)0x5225, (q15_t)0x9dd7, (q15_t)0x5220, (q15_t)0x9dd3, - (q15_t)0x521c, (q15_t)0x9dcf, (q15_t)0x5217, (q15_t)0x9dcb, (q15_t)0x5212, (q15_t)0x9dc7, (q15_t)0x520d, (q15_t)0x9dc3, - (q15_t)0x5208, (q15_t)0x9dbf, (q15_t)0x5203, (q15_t)0x9dbb, (q15_t)0x51ff, (q15_t)0x9db7, (q15_t)0x51fa, (q15_t)0x9db3, - (q15_t)0x51f5, (q15_t)0x9daf, (q15_t)0x51f0, (q15_t)0x9dab, (q15_t)0x51eb, (q15_t)0x9da7, (q15_t)0x51e6, (q15_t)0x9da3, - (q15_t)0x51e2, (q15_t)0x9d9f, (q15_t)0x51dd, (q15_t)0x9d9b, (q15_t)0x51d8, (q15_t)0x9d97, (q15_t)0x51d3, (q15_t)0x9d93, - (q15_t)0x51ce, (q15_t)0x9d8f, (q15_t)0x51c9, (q15_t)0x9d8b, (q15_t)0x51c5, (q15_t)0x9d86, (q15_t)0x51c0, (q15_t)0x9d82, - (q15_t)0x51bb, (q15_t)0x9d7e, (q15_t)0x51b6, (q15_t)0x9d7a, (q15_t)0x51b1, (q15_t)0x9d76, (q15_t)0x51ac, (q15_t)0x9d72, - (q15_t)0x51a8, (q15_t)0x9d6e, (q15_t)0x51a3, (q15_t)0x9d6a, (q15_t)0x519e, (q15_t)0x9d66, (q15_t)0x5199, (q15_t)0x9d62, - (q15_t)0x5194, (q15_t)0x9d5e, (q15_t)0x518f, (q15_t)0x9d5a, (q15_t)0x518b, (q15_t)0x9d56, (q15_t)0x5186, (q15_t)0x9d52, - (q15_t)0x5181, (q15_t)0x9d4e, (q15_t)0x517c, (q15_t)0x9d4a, (q15_t)0x5177, (q15_t)0x9d46, (q15_t)0x5172, (q15_t)0x9d42, - (q15_t)0x516e, (q15_t)0x9d3e, (q15_t)0x5169, (q15_t)0x9d3a, (q15_t)0x5164, (q15_t)0x9d36, (q15_t)0x515f, (q15_t)0x9d32, - (q15_t)0x515a, (q15_t)0x9d2e, (q15_t)0x5155, (q15_t)0x9d2a, (q15_t)0x5150, (q15_t)0x9d26, (q15_t)0x514c, (q15_t)0x9d22, - (q15_t)0x5147, (q15_t)0x9d1e, (q15_t)0x5142, (q15_t)0x9d1a, (q15_t)0x513d, (q15_t)0x9d16, (q15_t)0x5138, (q15_t)0x9d12, - (q15_t)0x5133, (q15_t)0x9d0e, (q15_t)0x512e, (q15_t)0x9d0b, (q15_t)0x512a, (q15_t)0x9d07, (q15_t)0x5125, (q15_t)0x9d03, - (q15_t)0x5120, (q15_t)0x9cff, (q15_t)0x511b, (q15_t)0x9cfb, (q15_t)0x5116, (q15_t)0x9cf7, (q15_t)0x5111, (q15_t)0x9cf3, - (q15_t)0x510c, (q15_t)0x9cef, (q15_t)0x5108, (q15_t)0x9ceb, (q15_t)0x5103, (q15_t)0x9ce7, (q15_t)0x50fe, (q15_t)0x9ce3, - (q15_t)0x50f9, (q15_t)0x9cdf, (q15_t)0x50f4, (q15_t)0x9cdb, (q15_t)0x50ef, (q15_t)0x9cd7, (q15_t)0x50ea, (q15_t)0x9cd3, - (q15_t)0x50e5, (q15_t)0x9ccf, (q15_t)0x50e1, (q15_t)0x9ccb, (q15_t)0x50dc, (q15_t)0x9cc7, (q15_t)0x50d7, (q15_t)0x9cc3, - (q15_t)0x50d2, (q15_t)0x9cbf, (q15_t)0x50cd, (q15_t)0x9cbb, (q15_t)0x50c8, (q15_t)0x9cb7, (q15_t)0x50c3, (q15_t)0x9cb3, - (q15_t)0x50bf, (q15_t)0x9caf, (q15_t)0x50ba, (q15_t)0x9cab, (q15_t)0x50b5, (q15_t)0x9ca7, (q15_t)0x50b0, (q15_t)0x9ca3, - (q15_t)0x50ab, (q15_t)0x9c9f, (q15_t)0x50a6, (q15_t)0x9c9b, (q15_t)0x50a1, (q15_t)0x9c97, (q15_t)0x509c, (q15_t)0x9c93, - (q15_t)0x5097, (q15_t)0x9c8f, (q15_t)0x5093, (q15_t)0x9c8b, (q15_t)0x508e, (q15_t)0x9c88, (q15_t)0x5089, (q15_t)0x9c84, - (q15_t)0x5084, (q15_t)0x9c80, (q15_t)0x507f, (q15_t)0x9c7c, (q15_t)0x507a, (q15_t)0x9c78, (q15_t)0x5075, (q15_t)0x9c74, - (q15_t)0x5070, (q15_t)0x9c70, (q15_t)0x506c, (q15_t)0x9c6c, (q15_t)0x5067, (q15_t)0x9c68, (q15_t)0x5062, (q15_t)0x9c64, - (q15_t)0x505d, (q15_t)0x9c60, (q15_t)0x5058, (q15_t)0x9c5c, (q15_t)0x5053, (q15_t)0x9c58, (q15_t)0x504e, (q15_t)0x9c54, - (q15_t)0x5049, (q15_t)0x9c50, (q15_t)0x5044, (q15_t)0x9c4c, (q15_t)0x503f, (q15_t)0x9c48, (q15_t)0x503b, (q15_t)0x9c44, - (q15_t)0x5036, (q15_t)0x9c40, (q15_t)0x5031, (q15_t)0x9c3d, (q15_t)0x502c, (q15_t)0x9c39, (q15_t)0x5027, (q15_t)0x9c35, - (q15_t)0x5022, (q15_t)0x9c31, (q15_t)0x501d, (q15_t)0x9c2d, (q15_t)0x5018, (q15_t)0x9c29, (q15_t)0x5013, (q15_t)0x9c25, - (q15_t)0x500f, (q15_t)0x9c21, (q15_t)0x500a, (q15_t)0x9c1d, (q15_t)0x5005, (q15_t)0x9c19, (q15_t)0x5000, (q15_t)0x9c15, - (q15_t)0x4ffb, (q15_t)0x9c11, (q15_t)0x4ff6, (q15_t)0x9c0d, (q15_t)0x4ff1, (q15_t)0x9c09, (q15_t)0x4fec, (q15_t)0x9c06, - (q15_t)0x4fe7, (q15_t)0x9c02, (q15_t)0x4fe2, (q15_t)0x9bfe, (q15_t)0x4fdd, (q15_t)0x9bfa, (q15_t)0x4fd9, (q15_t)0x9bf6, - (q15_t)0x4fd4, (q15_t)0x9bf2, (q15_t)0x4fcf, (q15_t)0x9bee, (q15_t)0x4fca, (q15_t)0x9bea, (q15_t)0x4fc5, (q15_t)0x9be6, - (q15_t)0x4fc0, (q15_t)0x9be2, (q15_t)0x4fbb, (q15_t)0x9bde, (q15_t)0x4fb6, (q15_t)0x9bda, (q15_t)0x4fb1, (q15_t)0x9bd7, - (q15_t)0x4fac, (q15_t)0x9bd3, (q15_t)0x4fa7, (q15_t)0x9bcf, (q15_t)0x4fa2, (q15_t)0x9bcb, (q15_t)0x4f9e, (q15_t)0x9bc7, - (q15_t)0x4f99, (q15_t)0x9bc3, (q15_t)0x4f94, (q15_t)0x9bbf, (q15_t)0x4f8f, (q15_t)0x9bbb, (q15_t)0x4f8a, (q15_t)0x9bb7, - (q15_t)0x4f85, (q15_t)0x9bb3, (q15_t)0x4f80, (q15_t)0x9baf, (q15_t)0x4f7b, (q15_t)0x9bac, (q15_t)0x4f76, (q15_t)0x9ba8, - (q15_t)0x4f71, (q15_t)0x9ba4, (q15_t)0x4f6c, (q15_t)0x9ba0, (q15_t)0x4f67, (q15_t)0x9b9c, (q15_t)0x4f62, (q15_t)0x9b98, - (q15_t)0x4f5e, (q15_t)0x9b94, (q15_t)0x4f59, (q15_t)0x9b90, (q15_t)0x4f54, (q15_t)0x9b8c, (q15_t)0x4f4f, (q15_t)0x9b88, - (q15_t)0x4f4a, (q15_t)0x9b85, (q15_t)0x4f45, (q15_t)0x9b81, (q15_t)0x4f40, (q15_t)0x9b7d, (q15_t)0x4f3b, (q15_t)0x9b79, - (q15_t)0x4f36, (q15_t)0x9b75, (q15_t)0x4f31, (q15_t)0x9b71, (q15_t)0x4f2c, (q15_t)0x9b6d, (q15_t)0x4f27, (q15_t)0x9b69, - (q15_t)0x4f22, (q15_t)0x9b65, (q15_t)0x4f1d, (q15_t)0x9b62, (q15_t)0x4f18, (q15_t)0x9b5e, (q15_t)0x4f14, (q15_t)0x9b5a, - (q15_t)0x4f0f, (q15_t)0x9b56, (q15_t)0x4f0a, (q15_t)0x9b52, (q15_t)0x4f05, (q15_t)0x9b4e, (q15_t)0x4f00, (q15_t)0x9b4a, - (q15_t)0x4efb, (q15_t)0x9b46, (q15_t)0x4ef6, (q15_t)0x9b43, (q15_t)0x4ef1, (q15_t)0x9b3f, (q15_t)0x4eec, (q15_t)0x9b3b, - (q15_t)0x4ee7, (q15_t)0x9b37, (q15_t)0x4ee2, (q15_t)0x9b33, (q15_t)0x4edd, (q15_t)0x9b2f, (q15_t)0x4ed8, (q15_t)0x9b2b, - (q15_t)0x4ed3, (q15_t)0x9b27, (q15_t)0x4ece, (q15_t)0x9b24, (q15_t)0x4ec9, (q15_t)0x9b20, (q15_t)0x4ec4, (q15_t)0x9b1c, - (q15_t)0x4ebf, (q15_t)0x9b18, (q15_t)0x4eba, (q15_t)0x9b14, (q15_t)0x4eb6, (q15_t)0x9b10, (q15_t)0x4eb1, (q15_t)0x9b0c, - (q15_t)0x4eac, (q15_t)0x9b09, (q15_t)0x4ea7, (q15_t)0x9b05, (q15_t)0x4ea2, (q15_t)0x9b01, (q15_t)0x4e9d, (q15_t)0x9afd, - (q15_t)0x4e98, (q15_t)0x9af9, (q15_t)0x4e93, (q15_t)0x9af5, (q15_t)0x4e8e, (q15_t)0x9af1, (q15_t)0x4e89, (q15_t)0x9aed, - (q15_t)0x4e84, (q15_t)0x9aea, (q15_t)0x4e7f, (q15_t)0x9ae6, (q15_t)0x4e7a, (q15_t)0x9ae2, (q15_t)0x4e75, (q15_t)0x9ade, - (q15_t)0x4e70, (q15_t)0x9ada, (q15_t)0x4e6b, (q15_t)0x9ad6, (q15_t)0x4e66, (q15_t)0x9ad3, (q15_t)0x4e61, (q15_t)0x9acf, - (q15_t)0x4e5c, (q15_t)0x9acb, (q15_t)0x4e57, (q15_t)0x9ac7, (q15_t)0x4e52, (q15_t)0x9ac3, (q15_t)0x4e4d, (q15_t)0x9abf, - (q15_t)0x4e48, (q15_t)0x9abb, (q15_t)0x4e43, (q15_t)0x9ab8, (q15_t)0x4e3e, (q15_t)0x9ab4, (q15_t)0x4e39, (q15_t)0x9ab0, - (q15_t)0x4e34, (q15_t)0x9aac, (q15_t)0x4e2f, (q15_t)0x9aa8, (q15_t)0x4e2a, (q15_t)0x9aa4, (q15_t)0x4e26, (q15_t)0x9aa1, - (q15_t)0x4e21, (q15_t)0x9a9d, (q15_t)0x4e1c, (q15_t)0x9a99, (q15_t)0x4e17, (q15_t)0x9a95, (q15_t)0x4e12, (q15_t)0x9a91, - (q15_t)0x4e0d, (q15_t)0x9a8d, (q15_t)0x4e08, (q15_t)0x9a8a, (q15_t)0x4e03, (q15_t)0x9a86, (q15_t)0x4dfe, (q15_t)0x9a82, - (q15_t)0x4df9, (q15_t)0x9a7e, (q15_t)0x4df4, (q15_t)0x9a7a, (q15_t)0x4def, (q15_t)0x9a76, (q15_t)0x4dea, (q15_t)0x9a73, - (q15_t)0x4de5, (q15_t)0x9a6f, (q15_t)0x4de0, (q15_t)0x9a6b, (q15_t)0x4ddb, (q15_t)0x9a67, (q15_t)0x4dd6, (q15_t)0x9a63, - (q15_t)0x4dd1, (q15_t)0x9a60, (q15_t)0x4dcc, (q15_t)0x9a5c, (q15_t)0x4dc7, (q15_t)0x9a58, (q15_t)0x4dc2, (q15_t)0x9a54, - (q15_t)0x4dbd, (q15_t)0x9a50, (q15_t)0x4db8, (q15_t)0x9a4c, (q15_t)0x4db3, (q15_t)0x9a49, (q15_t)0x4dae, (q15_t)0x9a45, - (q15_t)0x4da9, (q15_t)0x9a41, (q15_t)0x4da4, (q15_t)0x9a3d, (q15_t)0x4d9f, (q15_t)0x9a39, (q15_t)0x4d9a, (q15_t)0x9a36, - (q15_t)0x4d95, (q15_t)0x9a32, (q15_t)0x4d90, (q15_t)0x9a2e, (q15_t)0x4d8b, (q15_t)0x9a2a, (q15_t)0x4d86, (q15_t)0x9a26, - (q15_t)0x4d81, (q15_t)0x9a23, (q15_t)0x4d7c, (q15_t)0x9a1f, (q15_t)0x4d77, (q15_t)0x9a1b, (q15_t)0x4d72, (q15_t)0x9a17, - (q15_t)0x4d6d, (q15_t)0x9a13, (q15_t)0x4d68, (q15_t)0x9a10, (q15_t)0x4d63, (q15_t)0x9a0c, (q15_t)0x4d5e, (q15_t)0x9a08, - (q15_t)0x4d59, (q15_t)0x9a04, (q15_t)0x4d54, (q15_t)0x9a00, (q15_t)0x4d4f, (q15_t)0x99fd, (q15_t)0x4d4a, (q15_t)0x99f9, - (q15_t)0x4d45, (q15_t)0x99f5, (q15_t)0x4d40, (q15_t)0x99f1, (q15_t)0x4d3b, (q15_t)0x99ed, (q15_t)0x4d36, (q15_t)0x99ea, - (q15_t)0x4d31, (q15_t)0x99e6, (q15_t)0x4d2c, (q15_t)0x99e2, (q15_t)0x4d27, (q15_t)0x99de, (q15_t)0x4d22, (q15_t)0x99da, - (q15_t)0x4d1d, (q15_t)0x99d7, (q15_t)0x4d18, (q15_t)0x99d3, (q15_t)0x4d13, (q15_t)0x99cf, (q15_t)0x4d0e, (q15_t)0x99cb, - (q15_t)0x4d09, (q15_t)0x99c7, (q15_t)0x4d04, (q15_t)0x99c4, (q15_t)0x4cff, (q15_t)0x99c0, (q15_t)0x4cfa, (q15_t)0x99bc, - (q15_t)0x4cf5, (q15_t)0x99b8, (q15_t)0x4cf0, (q15_t)0x99b5, (q15_t)0x4ceb, (q15_t)0x99b1, (q15_t)0x4ce6, (q15_t)0x99ad, - (q15_t)0x4ce1, (q15_t)0x99a9, (q15_t)0x4cdb, (q15_t)0x99a5, (q15_t)0x4cd6, (q15_t)0x99a2, (q15_t)0x4cd1, (q15_t)0x999e, - (q15_t)0x4ccc, (q15_t)0x999a, (q15_t)0x4cc7, (q15_t)0x9996, (q15_t)0x4cc2, (q15_t)0x9993, (q15_t)0x4cbd, (q15_t)0x998f, - (q15_t)0x4cb8, (q15_t)0x998b, (q15_t)0x4cb3, (q15_t)0x9987, (q15_t)0x4cae, (q15_t)0x9984, (q15_t)0x4ca9, (q15_t)0x9980, - (q15_t)0x4ca4, (q15_t)0x997c, (q15_t)0x4c9f, (q15_t)0x9978, (q15_t)0x4c9a, (q15_t)0x9975, (q15_t)0x4c95, (q15_t)0x9971, - (q15_t)0x4c90, (q15_t)0x996d, (q15_t)0x4c8b, (q15_t)0x9969, (q15_t)0x4c86, (q15_t)0x9965, (q15_t)0x4c81, (q15_t)0x9962, - (q15_t)0x4c7c, (q15_t)0x995e, (q15_t)0x4c77, (q15_t)0x995a, (q15_t)0x4c72, (q15_t)0x9956, (q15_t)0x4c6d, (q15_t)0x9953, - (q15_t)0x4c68, (q15_t)0x994f, (q15_t)0x4c63, (q15_t)0x994b, (q15_t)0x4c5e, (q15_t)0x9947, (q15_t)0x4c59, (q15_t)0x9944, - (q15_t)0x4c54, (q15_t)0x9940, (q15_t)0x4c4f, (q15_t)0x993c, (q15_t)0x4c49, (q15_t)0x9938, (q15_t)0x4c44, (q15_t)0x9935, - (q15_t)0x4c3f, (q15_t)0x9931, (q15_t)0x4c3a, (q15_t)0x992d, (q15_t)0x4c35, (q15_t)0x992a, (q15_t)0x4c30, (q15_t)0x9926, - (q15_t)0x4c2b, (q15_t)0x9922, (q15_t)0x4c26, (q15_t)0x991e, (q15_t)0x4c21, (q15_t)0x991b, (q15_t)0x4c1c, (q15_t)0x9917, - (q15_t)0x4c17, (q15_t)0x9913, (q15_t)0x4c12, (q15_t)0x990f, (q15_t)0x4c0d, (q15_t)0x990c, (q15_t)0x4c08, (q15_t)0x9908, - (q15_t)0x4c03, (q15_t)0x9904, (q15_t)0x4bfe, (q15_t)0x9900, (q15_t)0x4bf9, (q15_t)0x98fd, (q15_t)0x4bf4, (q15_t)0x98f9, - (q15_t)0x4bef, (q15_t)0x98f5, (q15_t)0x4be9, (q15_t)0x98f2, (q15_t)0x4be4, (q15_t)0x98ee, (q15_t)0x4bdf, (q15_t)0x98ea, - (q15_t)0x4bda, (q15_t)0x98e6, (q15_t)0x4bd5, (q15_t)0x98e3, (q15_t)0x4bd0, (q15_t)0x98df, (q15_t)0x4bcb, (q15_t)0x98db, - (q15_t)0x4bc6, (q15_t)0x98d7, (q15_t)0x4bc1, (q15_t)0x98d4, (q15_t)0x4bbc, (q15_t)0x98d0, (q15_t)0x4bb7, (q15_t)0x98cc, - (q15_t)0x4bb2, (q15_t)0x98c9, (q15_t)0x4bad, (q15_t)0x98c5, (q15_t)0x4ba8, (q15_t)0x98c1, (q15_t)0x4ba3, (q15_t)0x98bd, - (q15_t)0x4b9e, (q15_t)0x98ba, (q15_t)0x4b98, (q15_t)0x98b6, (q15_t)0x4b93, (q15_t)0x98b2, (q15_t)0x4b8e, (q15_t)0x98af, - (q15_t)0x4b89, (q15_t)0x98ab, (q15_t)0x4b84, (q15_t)0x98a7, (q15_t)0x4b7f, (q15_t)0x98a3, (q15_t)0x4b7a, (q15_t)0x98a0, - (q15_t)0x4b75, (q15_t)0x989c, (q15_t)0x4b70, (q15_t)0x9898, (q15_t)0x4b6b, (q15_t)0x9895, (q15_t)0x4b66, (q15_t)0x9891, - (q15_t)0x4b61, (q15_t)0x988d, (q15_t)0x4b5c, (q15_t)0x988a, (q15_t)0x4b56, (q15_t)0x9886, (q15_t)0x4b51, (q15_t)0x9882, - (q15_t)0x4b4c, (q15_t)0x987e, (q15_t)0x4b47, (q15_t)0x987b, (q15_t)0x4b42, (q15_t)0x9877, (q15_t)0x4b3d, (q15_t)0x9873, - (q15_t)0x4b38, (q15_t)0x9870, (q15_t)0x4b33, (q15_t)0x986c, (q15_t)0x4b2e, (q15_t)0x9868, (q15_t)0x4b29, (q15_t)0x9865, - (q15_t)0x4b24, (q15_t)0x9861, (q15_t)0x4b1f, (q15_t)0x985d, (q15_t)0x4b19, (q15_t)0x985a, (q15_t)0x4b14, (q15_t)0x9856, - (q15_t)0x4b0f, (q15_t)0x9852, (q15_t)0x4b0a, (q15_t)0x984e, (q15_t)0x4b05, (q15_t)0x984b, (q15_t)0x4b00, (q15_t)0x9847, - (q15_t)0x4afb, (q15_t)0x9843, (q15_t)0x4af6, (q15_t)0x9840, (q15_t)0x4af1, (q15_t)0x983c, (q15_t)0x4aec, (q15_t)0x9838, - (q15_t)0x4ae7, (q15_t)0x9835, (q15_t)0x4ae1, (q15_t)0x9831, (q15_t)0x4adc, (q15_t)0x982d, (q15_t)0x4ad7, (q15_t)0x982a, - (q15_t)0x4ad2, (q15_t)0x9826, (q15_t)0x4acd, (q15_t)0x9822, (q15_t)0x4ac8, (q15_t)0x981f, (q15_t)0x4ac3, (q15_t)0x981b, - (q15_t)0x4abe, (q15_t)0x9817, (q15_t)0x4ab9, (q15_t)0x9814, (q15_t)0x4ab4, (q15_t)0x9810, (q15_t)0x4aae, (q15_t)0x980c, - (q15_t)0x4aa9, (q15_t)0x9809, (q15_t)0x4aa4, (q15_t)0x9805, (q15_t)0x4a9f, (q15_t)0x9801, (q15_t)0x4a9a, (q15_t)0x97fe, - (q15_t)0x4a95, (q15_t)0x97fa, (q15_t)0x4a90, (q15_t)0x97f6, (q15_t)0x4a8b, (q15_t)0x97f3, (q15_t)0x4a86, (q15_t)0x97ef, - (q15_t)0x4a81, (q15_t)0x97eb, (q15_t)0x4a7b, (q15_t)0x97e8, (q15_t)0x4a76, (q15_t)0x97e4, (q15_t)0x4a71, (q15_t)0x97e0, - (q15_t)0x4a6c, (q15_t)0x97dd, (q15_t)0x4a67, (q15_t)0x97d9, (q15_t)0x4a62, (q15_t)0x97d5, (q15_t)0x4a5d, (q15_t)0x97d2, - (q15_t)0x4a58, (q15_t)0x97ce, (q15_t)0x4a52, (q15_t)0x97cb, (q15_t)0x4a4d, (q15_t)0x97c7, (q15_t)0x4a48, (q15_t)0x97c3, - (q15_t)0x4a43, (q15_t)0x97c0, (q15_t)0x4a3e, (q15_t)0x97bc, (q15_t)0x4a39, (q15_t)0x97b8, (q15_t)0x4a34, (q15_t)0x97b5, - (q15_t)0x4a2f, (q15_t)0x97b1, (q15_t)0x4a2a, (q15_t)0x97ad, (q15_t)0x4a24, (q15_t)0x97aa, (q15_t)0x4a1f, (q15_t)0x97a6, - (q15_t)0x4a1a, (q15_t)0x97a2, (q15_t)0x4a15, (q15_t)0x979f, (q15_t)0x4a10, (q15_t)0x979b, (q15_t)0x4a0b, (q15_t)0x9798, - (q15_t)0x4a06, (q15_t)0x9794, (q15_t)0x4a01, (q15_t)0x9790, (q15_t)0x49fb, (q15_t)0x978d, (q15_t)0x49f6, (q15_t)0x9789, - (q15_t)0x49f1, (q15_t)0x9785, (q15_t)0x49ec, (q15_t)0x9782, (q15_t)0x49e7, (q15_t)0x977e, (q15_t)0x49e2, (q15_t)0x977a, - (q15_t)0x49dd, (q15_t)0x9777, (q15_t)0x49d8, (q15_t)0x9773, (q15_t)0x49d2, (q15_t)0x9770, (q15_t)0x49cd, (q15_t)0x976c, - (q15_t)0x49c8, (q15_t)0x9768, (q15_t)0x49c3, (q15_t)0x9765, (q15_t)0x49be, (q15_t)0x9761, (q15_t)0x49b9, (q15_t)0x975d, - (q15_t)0x49b4, (q15_t)0x975a, (q15_t)0x49ae, (q15_t)0x9756, (q15_t)0x49a9, (q15_t)0x9753, (q15_t)0x49a4, (q15_t)0x974f, - (q15_t)0x499f, (q15_t)0x974b, (q15_t)0x499a, (q15_t)0x9748, (q15_t)0x4995, (q15_t)0x9744, (q15_t)0x4990, (q15_t)0x9741, - (q15_t)0x498a, (q15_t)0x973d, (q15_t)0x4985, (q15_t)0x9739, (q15_t)0x4980, (q15_t)0x9736, (q15_t)0x497b, (q15_t)0x9732, - (q15_t)0x4976, (q15_t)0x972f, (q15_t)0x4971, (q15_t)0x972b, (q15_t)0x496c, (q15_t)0x9727, (q15_t)0x4966, (q15_t)0x9724, - (q15_t)0x4961, (q15_t)0x9720, (q15_t)0x495c, (q15_t)0x971d, (q15_t)0x4957, (q15_t)0x9719, (q15_t)0x4952, (q15_t)0x9715, - (q15_t)0x494d, (q15_t)0x9712, (q15_t)0x4948, (q15_t)0x970e, (q15_t)0x4942, (q15_t)0x970b, (q15_t)0x493d, (q15_t)0x9707, - (q15_t)0x4938, (q15_t)0x9703, (q15_t)0x4933, (q15_t)0x9700, (q15_t)0x492e, (q15_t)0x96fc, (q15_t)0x4929, (q15_t)0x96f9, - (q15_t)0x4923, (q15_t)0x96f5, (q15_t)0x491e, (q15_t)0x96f1, (q15_t)0x4919, (q15_t)0x96ee, (q15_t)0x4914, (q15_t)0x96ea, - (q15_t)0x490f, (q15_t)0x96e7, (q15_t)0x490a, (q15_t)0x96e3, (q15_t)0x4905, (q15_t)0x96df, (q15_t)0x48ff, (q15_t)0x96dc, - (q15_t)0x48fa, (q15_t)0x96d8, (q15_t)0x48f5, (q15_t)0x96d5, (q15_t)0x48f0, (q15_t)0x96d1, (q15_t)0x48eb, (q15_t)0x96ce, - (q15_t)0x48e6, (q15_t)0x96ca, (q15_t)0x48e0, (q15_t)0x96c6, (q15_t)0x48db, (q15_t)0x96c3, (q15_t)0x48d6, (q15_t)0x96bf, - (q15_t)0x48d1, (q15_t)0x96bc, (q15_t)0x48cc, (q15_t)0x96b8, (q15_t)0x48c7, (q15_t)0x96b5, (q15_t)0x48c1, (q15_t)0x96b1, - (q15_t)0x48bc, (q15_t)0x96ad, (q15_t)0x48b7, (q15_t)0x96aa, (q15_t)0x48b2, (q15_t)0x96a6, (q15_t)0x48ad, (q15_t)0x96a3, - (q15_t)0x48a8, (q15_t)0x969f, (q15_t)0x48a2, (q15_t)0x969c, (q15_t)0x489d, (q15_t)0x9698, (q15_t)0x4898, (q15_t)0x9694, - (q15_t)0x4893, (q15_t)0x9691, (q15_t)0x488e, (q15_t)0x968d, (q15_t)0x4888, (q15_t)0x968a, (q15_t)0x4883, (q15_t)0x9686, - (q15_t)0x487e, (q15_t)0x9683, (q15_t)0x4879, (q15_t)0x967f, (q15_t)0x4874, (q15_t)0x967b, (q15_t)0x486f, (q15_t)0x9678, - (q15_t)0x4869, (q15_t)0x9674, (q15_t)0x4864, (q15_t)0x9671, (q15_t)0x485f, (q15_t)0x966d, (q15_t)0x485a, (q15_t)0x966a, - (q15_t)0x4855, (q15_t)0x9666, (q15_t)0x484f, (q15_t)0x9663, (q15_t)0x484a, (q15_t)0x965f, (q15_t)0x4845, (q15_t)0x965b, - (q15_t)0x4840, (q15_t)0x9658, (q15_t)0x483b, (q15_t)0x9654, (q15_t)0x4836, (q15_t)0x9651, (q15_t)0x4830, (q15_t)0x964d, - (q15_t)0x482b, (q15_t)0x964a, (q15_t)0x4826, (q15_t)0x9646, (q15_t)0x4821, (q15_t)0x9643, (q15_t)0x481c, (q15_t)0x963f, - (q15_t)0x4816, (q15_t)0x963c, (q15_t)0x4811, (q15_t)0x9638, (q15_t)0x480c, (q15_t)0x9635, (q15_t)0x4807, (q15_t)0x9631, - (q15_t)0x4802, (q15_t)0x962d, (q15_t)0x47fc, (q15_t)0x962a, (q15_t)0x47f7, (q15_t)0x9626, (q15_t)0x47f2, (q15_t)0x9623, - (q15_t)0x47ed, (q15_t)0x961f, (q15_t)0x47e8, (q15_t)0x961c, (q15_t)0x47e2, (q15_t)0x9618, (q15_t)0x47dd, (q15_t)0x9615, - (q15_t)0x47d8, (q15_t)0x9611, (q15_t)0x47d3, (q15_t)0x960e, (q15_t)0x47ce, (q15_t)0x960a, (q15_t)0x47c8, (q15_t)0x9607, - (q15_t)0x47c3, (q15_t)0x9603, (q15_t)0x47be, (q15_t)0x9600, (q15_t)0x47b9, (q15_t)0x95fc, (q15_t)0x47b4, (q15_t)0x95f9, - (q15_t)0x47ae, (q15_t)0x95f5, (q15_t)0x47a9, (q15_t)0x95f2, (q15_t)0x47a4, (q15_t)0x95ee, (q15_t)0x479f, (q15_t)0x95ea, - (q15_t)0x479a, (q15_t)0x95e7, (q15_t)0x4794, (q15_t)0x95e3, (q15_t)0x478f, (q15_t)0x95e0, (q15_t)0x478a, (q15_t)0x95dc, - (q15_t)0x4785, (q15_t)0x95d9, (q15_t)0x4780, (q15_t)0x95d5, (q15_t)0x477a, (q15_t)0x95d2, (q15_t)0x4775, (q15_t)0x95ce, - (q15_t)0x4770, (q15_t)0x95cb, (q15_t)0x476b, (q15_t)0x95c7, (q15_t)0x4765, (q15_t)0x95c4, (q15_t)0x4760, (q15_t)0x95c0, - (q15_t)0x475b, (q15_t)0x95bd, (q15_t)0x4756, (q15_t)0x95b9, (q15_t)0x4751, (q15_t)0x95b6, (q15_t)0x474b, (q15_t)0x95b2, - (q15_t)0x4746, (q15_t)0x95af, (q15_t)0x4741, (q15_t)0x95ab, (q15_t)0x473c, (q15_t)0x95a8, (q15_t)0x4737, (q15_t)0x95a4, - (q15_t)0x4731, (q15_t)0x95a1, (q15_t)0x472c, (q15_t)0x959d, (q15_t)0x4727, (q15_t)0x959a, (q15_t)0x4722, (q15_t)0x9596, - (q15_t)0x471c, (q15_t)0x9593, (q15_t)0x4717, (q15_t)0x958f, (q15_t)0x4712, (q15_t)0x958c, (q15_t)0x470d, (q15_t)0x9588, - (q15_t)0x4708, (q15_t)0x9585, (q15_t)0x4702, (q15_t)0x9581, (q15_t)0x46fd, (q15_t)0x957e, (q15_t)0x46f8, (q15_t)0x957a, - (q15_t)0x46f3, (q15_t)0x9577, (q15_t)0x46ed, (q15_t)0x9574, (q15_t)0x46e8, (q15_t)0x9570, (q15_t)0x46e3, (q15_t)0x956d, - (q15_t)0x46de, (q15_t)0x9569, (q15_t)0x46d8, (q15_t)0x9566, (q15_t)0x46d3, (q15_t)0x9562, (q15_t)0x46ce, (q15_t)0x955f, - (q15_t)0x46c9, (q15_t)0x955b, (q15_t)0x46c4, (q15_t)0x9558, (q15_t)0x46be, (q15_t)0x9554, (q15_t)0x46b9, (q15_t)0x9551, - (q15_t)0x46b4, (q15_t)0x954d, (q15_t)0x46af, (q15_t)0x954a, (q15_t)0x46a9, (q15_t)0x9546, (q15_t)0x46a4, (q15_t)0x9543, - (q15_t)0x469f, (q15_t)0x953f, (q15_t)0x469a, (q15_t)0x953c, (q15_t)0x4694, (q15_t)0x9538, (q15_t)0x468f, (q15_t)0x9535, - (q15_t)0x468a, (q15_t)0x9532, (q15_t)0x4685, (q15_t)0x952e, (q15_t)0x467f, (q15_t)0x952b, (q15_t)0x467a, (q15_t)0x9527, - (q15_t)0x4675, (q15_t)0x9524, (q15_t)0x4670, (q15_t)0x9520, (q15_t)0x466a, (q15_t)0x951d, (q15_t)0x4665, (q15_t)0x9519, - (q15_t)0x4660, (q15_t)0x9516, (q15_t)0x465b, (q15_t)0x9512, (q15_t)0x4655, (q15_t)0x950f, (q15_t)0x4650, (q15_t)0x950c, - (q15_t)0x464b, (q15_t)0x9508, (q15_t)0x4646, (q15_t)0x9505, (q15_t)0x4640, (q15_t)0x9501, (q15_t)0x463b, (q15_t)0x94fe, - (q15_t)0x4636, (q15_t)0x94fa, (q15_t)0x4631, (q15_t)0x94f7, (q15_t)0x462b, (q15_t)0x94f3, (q15_t)0x4626, (q15_t)0x94f0, - (q15_t)0x4621, (q15_t)0x94ed, (q15_t)0x461c, (q15_t)0x94e9, (q15_t)0x4616, (q15_t)0x94e6, (q15_t)0x4611, (q15_t)0x94e2, - (q15_t)0x460c, (q15_t)0x94df, (q15_t)0x4607, (q15_t)0x94db, (q15_t)0x4601, (q15_t)0x94d8, (q15_t)0x45fc, (q15_t)0x94d4, - (q15_t)0x45f7, (q15_t)0x94d1, (q15_t)0x45f2, (q15_t)0x94ce, (q15_t)0x45ec, (q15_t)0x94ca, (q15_t)0x45e7, (q15_t)0x94c7, - (q15_t)0x45e2, (q15_t)0x94c3, (q15_t)0x45dd, (q15_t)0x94c0, (q15_t)0x45d7, (q15_t)0x94bc, (q15_t)0x45d2, (q15_t)0x94b9, - (q15_t)0x45cd, (q15_t)0x94b6, (q15_t)0x45c7, (q15_t)0x94b2, (q15_t)0x45c2, (q15_t)0x94af, (q15_t)0x45bd, (q15_t)0x94ab, - (q15_t)0x45b8, (q15_t)0x94a8, (q15_t)0x45b2, (q15_t)0x94a4, (q15_t)0x45ad, (q15_t)0x94a1, (q15_t)0x45a8, (q15_t)0x949e, - (q15_t)0x45a3, (q15_t)0x949a, (q15_t)0x459d, (q15_t)0x9497, (q15_t)0x4598, (q15_t)0x9493, (q15_t)0x4593, (q15_t)0x9490, - (q15_t)0x458d, (q15_t)0x948d, (q15_t)0x4588, (q15_t)0x9489, (q15_t)0x4583, (q15_t)0x9486, (q15_t)0x457e, (q15_t)0x9482, - (q15_t)0x4578, (q15_t)0x947f, (q15_t)0x4573, (q15_t)0x947b, (q15_t)0x456e, (q15_t)0x9478, (q15_t)0x4569, (q15_t)0x9475, - (q15_t)0x4563, (q15_t)0x9471, (q15_t)0x455e, (q15_t)0x946e, (q15_t)0x4559, (q15_t)0x946a, (q15_t)0x4553, (q15_t)0x9467, - (q15_t)0x454e, (q15_t)0x9464, (q15_t)0x4549, (q15_t)0x9460, (q15_t)0x4544, (q15_t)0x945d, (q15_t)0x453e, (q15_t)0x9459, - (q15_t)0x4539, (q15_t)0x9456, (q15_t)0x4534, (q15_t)0x9453, (q15_t)0x452e, (q15_t)0x944f, (q15_t)0x4529, (q15_t)0x944c, - (q15_t)0x4524, (q15_t)0x9448, (q15_t)0x451f, (q15_t)0x9445, (q15_t)0x4519, (q15_t)0x9442, (q15_t)0x4514, (q15_t)0x943e, - (q15_t)0x450f, (q15_t)0x943b, (q15_t)0x4509, (q15_t)0x9437, (q15_t)0x4504, (q15_t)0x9434, (q15_t)0x44ff, (q15_t)0x9431, - (q15_t)0x44fa, (q15_t)0x942d, (q15_t)0x44f4, (q15_t)0x942a, (q15_t)0x44ef, (q15_t)0x9427, (q15_t)0x44ea, (q15_t)0x9423, - (q15_t)0x44e4, (q15_t)0x9420, (q15_t)0x44df, (q15_t)0x941c, (q15_t)0x44da, (q15_t)0x9419, (q15_t)0x44d4, (q15_t)0x9416, - (q15_t)0x44cf, (q15_t)0x9412, (q15_t)0x44ca, (q15_t)0x940f, (q15_t)0x44c5, (q15_t)0x940b, (q15_t)0x44bf, (q15_t)0x9408, - (q15_t)0x44ba, (q15_t)0x9405, (q15_t)0x44b5, (q15_t)0x9401, (q15_t)0x44af, (q15_t)0x93fe, (q15_t)0x44aa, (q15_t)0x93fb, - (q15_t)0x44a5, (q15_t)0x93f7, (q15_t)0x449f, (q15_t)0x93f4, (q15_t)0x449a, (q15_t)0x93f1, (q15_t)0x4495, (q15_t)0x93ed, - (q15_t)0x4490, (q15_t)0x93ea, (q15_t)0x448a, (q15_t)0x93e6, (q15_t)0x4485, (q15_t)0x93e3, (q15_t)0x4480, (q15_t)0x93e0, - (q15_t)0x447a, (q15_t)0x93dc, (q15_t)0x4475, (q15_t)0x93d9, (q15_t)0x4470, (q15_t)0x93d6, (q15_t)0x446a, (q15_t)0x93d2, - (q15_t)0x4465, (q15_t)0x93cf, (q15_t)0x4460, (q15_t)0x93cc, (q15_t)0x445a, (q15_t)0x93c8, (q15_t)0x4455, (q15_t)0x93c5, - (q15_t)0x4450, (q15_t)0x93c1, (q15_t)0x444b, (q15_t)0x93be, (q15_t)0x4445, (q15_t)0x93bb, (q15_t)0x4440, (q15_t)0x93b7, - (q15_t)0x443b, (q15_t)0x93b4, (q15_t)0x4435, (q15_t)0x93b1, (q15_t)0x4430, (q15_t)0x93ad, (q15_t)0x442b, (q15_t)0x93aa, - (q15_t)0x4425, (q15_t)0x93a7, (q15_t)0x4420, (q15_t)0x93a3, (q15_t)0x441b, (q15_t)0x93a0, (q15_t)0x4415, (q15_t)0x939d, - (q15_t)0x4410, (q15_t)0x9399, (q15_t)0x440b, (q15_t)0x9396, (q15_t)0x4405, (q15_t)0x9393, (q15_t)0x4400, (q15_t)0x938f, - (q15_t)0x43fb, (q15_t)0x938c, (q15_t)0x43f5, (q15_t)0x9389, (q15_t)0x43f0, (q15_t)0x9385, (q15_t)0x43eb, (q15_t)0x9382, - (q15_t)0x43e5, (q15_t)0x937f, (q15_t)0x43e0, (q15_t)0x937b, (q15_t)0x43db, (q15_t)0x9378, (q15_t)0x43d5, (q15_t)0x9375, - (q15_t)0x43d0, (q15_t)0x9371, (q15_t)0x43cb, (q15_t)0x936e, (q15_t)0x43c5, (q15_t)0x936b, (q15_t)0x43c0, (q15_t)0x9367, - (q15_t)0x43bb, (q15_t)0x9364, (q15_t)0x43b5, (q15_t)0x9361, (q15_t)0x43b0, (q15_t)0x935d, (q15_t)0x43ab, (q15_t)0x935a, - (q15_t)0x43a5, (q15_t)0x9357, (q15_t)0x43a0, (q15_t)0x9353, (q15_t)0x439b, (q15_t)0x9350, (q15_t)0x4395, (q15_t)0x934d, - (q15_t)0x4390, (q15_t)0x9349, (q15_t)0x438b, (q15_t)0x9346, (q15_t)0x4385, (q15_t)0x9343, (q15_t)0x4380, (q15_t)0x933f, - (q15_t)0x437b, (q15_t)0x933c, (q15_t)0x4375, (q15_t)0x9339, (q15_t)0x4370, (q15_t)0x9336, (q15_t)0x436b, (q15_t)0x9332, - (q15_t)0x4365, (q15_t)0x932f, (q15_t)0x4360, (q15_t)0x932c, (q15_t)0x435b, (q15_t)0x9328, (q15_t)0x4355, (q15_t)0x9325, - (q15_t)0x4350, (q15_t)0x9322, (q15_t)0x434b, (q15_t)0x931e, (q15_t)0x4345, (q15_t)0x931b, (q15_t)0x4340, (q15_t)0x9318, - (q15_t)0x433b, (q15_t)0x9314, (q15_t)0x4335, (q15_t)0x9311, (q15_t)0x4330, (q15_t)0x930e, (q15_t)0x432b, (q15_t)0x930b, - (q15_t)0x4325, (q15_t)0x9307, (q15_t)0x4320, (q15_t)0x9304, (q15_t)0x431b, (q15_t)0x9301, (q15_t)0x4315, (q15_t)0x92fd, - (q15_t)0x4310, (q15_t)0x92fa, (q15_t)0x430b, (q15_t)0x92f7, (q15_t)0x4305, (q15_t)0x92f4, (q15_t)0x4300, (q15_t)0x92f0, - (q15_t)0x42fa, (q15_t)0x92ed, (q15_t)0x42f5, (q15_t)0x92ea, (q15_t)0x42f0, (q15_t)0x92e6, (q15_t)0x42ea, (q15_t)0x92e3, - (q15_t)0x42e5, (q15_t)0x92e0, (q15_t)0x42e0, (q15_t)0x92dd, (q15_t)0x42da, (q15_t)0x92d9, (q15_t)0x42d5, (q15_t)0x92d6, - (q15_t)0x42d0, (q15_t)0x92d3, (q15_t)0x42ca, (q15_t)0x92cf, (q15_t)0x42c5, (q15_t)0x92cc, (q15_t)0x42c0, (q15_t)0x92c9, - (q15_t)0x42ba, (q15_t)0x92c6, (q15_t)0x42b5, (q15_t)0x92c2, (q15_t)0x42af, (q15_t)0x92bf, (q15_t)0x42aa, (q15_t)0x92bc, - (q15_t)0x42a5, (q15_t)0x92b8, (q15_t)0x429f, (q15_t)0x92b5, (q15_t)0x429a, (q15_t)0x92b2, (q15_t)0x4295, (q15_t)0x92af, - (q15_t)0x428f, (q15_t)0x92ab, (q15_t)0x428a, (q15_t)0x92a8, (q15_t)0x4284, (q15_t)0x92a5, (q15_t)0x427f, (q15_t)0x92a2, - (q15_t)0x427a, (q15_t)0x929e, (q15_t)0x4274, (q15_t)0x929b, (q15_t)0x426f, (q15_t)0x9298, (q15_t)0x426a, (q15_t)0x9295, - (q15_t)0x4264, (q15_t)0x9291, (q15_t)0x425f, (q15_t)0x928e, (q15_t)0x425a, (q15_t)0x928b, (q15_t)0x4254, (q15_t)0x9288, - (q15_t)0x424f, (q15_t)0x9284, (q15_t)0x4249, (q15_t)0x9281, (q15_t)0x4244, (q15_t)0x927e, (q15_t)0x423f, (q15_t)0x927b, - (q15_t)0x4239, (q15_t)0x9277, (q15_t)0x4234, (q15_t)0x9274, (q15_t)0x422f, (q15_t)0x9271, (q15_t)0x4229, (q15_t)0x926e, - (q15_t)0x4224, (q15_t)0x926a, (q15_t)0x421e, (q15_t)0x9267, (q15_t)0x4219, (q15_t)0x9264, (q15_t)0x4214, (q15_t)0x9261, - (q15_t)0x420e, (q15_t)0x925d, (q15_t)0x4209, (q15_t)0x925a, (q15_t)0x4203, (q15_t)0x9257, (q15_t)0x41fe, (q15_t)0x9254, - (q15_t)0x41f9, (q15_t)0x9250, (q15_t)0x41f3, (q15_t)0x924d, (q15_t)0x41ee, (q15_t)0x924a, (q15_t)0x41e9, (q15_t)0x9247, - (q15_t)0x41e3, (q15_t)0x9243, (q15_t)0x41de, (q15_t)0x9240, (q15_t)0x41d8, (q15_t)0x923d, (q15_t)0x41d3, (q15_t)0x923a, - (q15_t)0x41ce, (q15_t)0x9236, (q15_t)0x41c8, (q15_t)0x9233, (q15_t)0x41c3, (q15_t)0x9230, (q15_t)0x41bd, (q15_t)0x922d, - (q15_t)0x41b8, (q15_t)0x922a, (q15_t)0x41b3, (q15_t)0x9226, (q15_t)0x41ad, (q15_t)0x9223, (q15_t)0x41a8, (q15_t)0x9220, - (q15_t)0x41a2, (q15_t)0x921d, (q15_t)0x419d, (q15_t)0x9219, (q15_t)0x4198, (q15_t)0x9216, (q15_t)0x4192, (q15_t)0x9213, - (q15_t)0x418d, (q15_t)0x9210, (q15_t)0x4188, (q15_t)0x920d, (q15_t)0x4182, (q15_t)0x9209, (q15_t)0x417d, (q15_t)0x9206, - (q15_t)0x4177, (q15_t)0x9203, (q15_t)0x4172, (q15_t)0x9200, (q15_t)0x416d, (q15_t)0x91fc, (q15_t)0x4167, (q15_t)0x91f9, - (q15_t)0x4162, (q15_t)0x91f6, (q15_t)0x415c, (q15_t)0x91f3, (q15_t)0x4157, (q15_t)0x91f0, (q15_t)0x4152, (q15_t)0x91ec, - (q15_t)0x414c, (q15_t)0x91e9, (q15_t)0x4147, (q15_t)0x91e6, (q15_t)0x4141, (q15_t)0x91e3, (q15_t)0x413c, (q15_t)0x91e0, - (q15_t)0x4136, (q15_t)0x91dc, (q15_t)0x4131, (q15_t)0x91d9, (q15_t)0x412c, (q15_t)0x91d6, (q15_t)0x4126, (q15_t)0x91d3, - (q15_t)0x4121, (q15_t)0x91d0, (q15_t)0x411b, (q15_t)0x91cc, (q15_t)0x4116, (q15_t)0x91c9, (q15_t)0x4111, (q15_t)0x91c6, - (q15_t)0x410b, (q15_t)0x91c3, (q15_t)0x4106, (q15_t)0x91c0, (q15_t)0x4100, (q15_t)0x91bc, (q15_t)0x40fb, (q15_t)0x91b9, - (q15_t)0x40f6, (q15_t)0x91b6, (q15_t)0x40f0, (q15_t)0x91b3, (q15_t)0x40eb, (q15_t)0x91b0, (q15_t)0x40e5, (q15_t)0x91ad, - (q15_t)0x40e0, (q15_t)0x91a9, (q15_t)0x40da, (q15_t)0x91a6, (q15_t)0x40d5, (q15_t)0x91a3, (q15_t)0x40d0, (q15_t)0x91a0, - (q15_t)0x40ca, (q15_t)0x919d, (q15_t)0x40c5, (q15_t)0x9199, (q15_t)0x40bf, (q15_t)0x9196, (q15_t)0x40ba, (q15_t)0x9193, - (q15_t)0x40b5, (q15_t)0x9190, (q15_t)0x40af, (q15_t)0x918d, (q15_t)0x40aa, (q15_t)0x918a, (q15_t)0x40a4, (q15_t)0x9186, - (q15_t)0x409f, (q15_t)0x9183, (q15_t)0x4099, (q15_t)0x9180, (q15_t)0x4094, (q15_t)0x917d, (q15_t)0x408f, (q15_t)0x917a, - (q15_t)0x4089, (q15_t)0x9177, (q15_t)0x4084, (q15_t)0x9173, (q15_t)0x407e, (q15_t)0x9170, (q15_t)0x4079, (q15_t)0x916d, - (q15_t)0x4073, (q15_t)0x916a, (q15_t)0x406e, (q15_t)0x9167, (q15_t)0x4069, (q15_t)0x9164, (q15_t)0x4063, (q15_t)0x9160, - (q15_t)0x405e, (q15_t)0x915d, (q15_t)0x4058, (q15_t)0x915a, (q15_t)0x4053, (q15_t)0x9157, (q15_t)0x404d, (q15_t)0x9154, - (q15_t)0x4048, (q15_t)0x9151, (q15_t)0x4043, (q15_t)0x914d, (q15_t)0x403d, (q15_t)0x914a, (q15_t)0x4038, (q15_t)0x9147, - (q15_t)0x4032, (q15_t)0x9144, (q15_t)0x402d, (q15_t)0x9141, (q15_t)0x4027, (q15_t)0x913e, (q15_t)0x4022, (q15_t)0x913a, - (q15_t)0x401d, (q15_t)0x9137, (q15_t)0x4017, (q15_t)0x9134, (q15_t)0x4012, (q15_t)0x9131, (q15_t)0x400c, (q15_t)0x912e, - (q15_t)0x4007, (q15_t)0x912b, (q15_t)0x4001, (q15_t)0x9128, (q15_t)0x3ffc, (q15_t)0x9124, (q15_t)0x3ff6, (q15_t)0x9121, - (q15_t)0x3ff1, (q15_t)0x911e, (q15_t)0x3fec, (q15_t)0x911b, (q15_t)0x3fe6, (q15_t)0x9118, (q15_t)0x3fe1, (q15_t)0x9115, - (q15_t)0x3fdb, (q15_t)0x9112, (q15_t)0x3fd6, (q15_t)0x910f, (q15_t)0x3fd0, (q15_t)0x910b, (q15_t)0x3fcb, (q15_t)0x9108, - (q15_t)0x3fc5, (q15_t)0x9105, (q15_t)0x3fc0, (q15_t)0x9102, (q15_t)0x3fbb, (q15_t)0x90ff, (q15_t)0x3fb5, (q15_t)0x90fc, - (q15_t)0x3fb0, (q15_t)0x90f9, (q15_t)0x3faa, (q15_t)0x90f5, (q15_t)0x3fa5, (q15_t)0x90f2, (q15_t)0x3f9f, (q15_t)0x90ef, - (q15_t)0x3f9a, (q15_t)0x90ec, (q15_t)0x3f94, (q15_t)0x90e9, (q15_t)0x3f8f, (q15_t)0x90e6, (q15_t)0x3f89, (q15_t)0x90e3, - (q15_t)0x3f84, (q15_t)0x90e0, (q15_t)0x3f7f, (q15_t)0x90dd, (q15_t)0x3f79, (q15_t)0x90d9, (q15_t)0x3f74, (q15_t)0x90d6, - (q15_t)0x3f6e, (q15_t)0x90d3, (q15_t)0x3f69, (q15_t)0x90d0, (q15_t)0x3f63, (q15_t)0x90cd, (q15_t)0x3f5e, (q15_t)0x90ca, - (q15_t)0x3f58, (q15_t)0x90c7, (q15_t)0x3f53, (q15_t)0x90c4, (q15_t)0x3f4d, (q15_t)0x90c1, (q15_t)0x3f48, (q15_t)0x90bd, - (q15_t)0x3f43, (q15_t)0x90ba, (q15_t)0x3f3d, (q15_t)0x90b7, (q15_t)0x3f38, (q15_t)0x90b4, (q15_t)0x3f32, (q15_t)0x90b1, - (q15_t)0x3f2d, (q15_t)0x90ae, (q15_t)0x3f27, (q15_t)0x90ab, (q15_t)0x3f22, (q15_t)0x90a8, (q15_t)0x3f1c, (q15_t)0x90a5, - (q15_t)0x3f17, (q15_t)0x90a1, (q15_t)0x3f11, (q15_t)0x909e, (q15_t)0x3f0c, (q15_t)0x909b, (q15_t)0x3f06, (q15_t)0x9098, - (q15_t)0x3f01, (q15_t)0x9095, (q15_t)0x3efb, (q15_t)0x9092, (q15_t)0x3ef6, (q15_t)0x908f, (q15_t)0x3ef1, (q15_t)0x908c, - (q15_t)0x3eeb, (q15_t)0x9089, (q15_t)0x3ee6, (q15_t)0x9086, (q15_t)0x3ee0, (q15_t)0x9083, (q15_t)0x3edb, (q15_t)0x907f, - (q15_t)0x3ed5, (q15_t)0x907c, (q15_t)0x3ed0, (q15_t)0x9079, (q15_t)0x3eca, (q15_t)0x9076, (q15_t)0x3ec5, (q15_t)0x9073, - (q15_t)0x3ebf, (q15_t)0x9070, (q15_t)0x3eba, (q15_t)0x906d, (q15_t)0x3eb4, (q15_t)0x906a, (q15_t)0x3eaf, (q15_t)0x9067, - (q15_t)0x3ea9, (q15_t)0x9064, (q15_t)0x3ea4, (q15_t)0x9061, (q15_t)0x3e9e, (q15_t)0x905e, (q15_t)0x3e99, (q15_t)0x905b, - (q15_t)0x3e93, (q15_t)0x9057, (q15_t)0x3e8e, (q15_t)0x9054, (q15_t)0x3e88, (q15_t)0x9051, (q15_t)0x3e83, (q15_t)0x904e, - (q15_t)0x3e7d, (q15_t)0x904b, (q15_t)0x3e78, (q15_t)0x9048, (q15_t)0x3e73, (q15_t)0x9045, (q15_t)0x3e6d, (q15_t)0x9042, - (q15_t)0x3e68, (q15_t)0x903f, (q15_t)0x3e62, (q15_t)0x903c, (q15_t)0x3e5d, (q15_t)0x9039, (q15_t)0x3e57, (q15_t)0x9036, - (q15_t)0x3e52, (q15_t)0x9033, (q15_t)0x3e4c, (q15_t)0x9030, (q15_t)0x3e47, (q15_t)0x902d, (q15_t)0x3e41, (q15_t)0x902a, - (q15_t)0x3e3c, (q15_t)0x9026, (q15_t)0x3e36, (q15_t)0x9023, (q15_t)0x3e31, (q15_t)0x9020, (q15_t)0x3e2b, (q15_t)0x901d, - (q15_t)0x3e26, (q15_t)0x901a, (q15_t)0x3e20, (q15_t)0x9017, (q15_t)0x3e1b, (q15_t)0x9014, (q15_t)0x3e15, (q15_t)0x9011, - (q15_t)0x3e10, (q15_t)0x900e, (q15_t)0x3e0a, (q15_t)0x900b, (q15_t)0x3e05, (q15_t)0x9008, (q15_t)0x3dff, (q15_t)0x9005, - (q15_t)0x3dfa, (q15_t)0x9002, (q15_t)0x3df4, (q15_t)0x8fff, (q15_t)0x3def, (q15_t)0x8ffc, (q15_t)0x3de9, (q15_t)0x8ff9, - (q15_t)0x3de4, (q15_t)0x8ff6, (q15_t)0x3dde, (q15_t)0x8ff3, (q15_t)0x3dd9, (q15_t)0x8ff0, (q15_t)0x3dd3, (q15_t)0x8fed, - (q15_t)0x3dce, (q15_t)0x8fea, (q15_t)0x3dc8, (q15_t)0x8fe7, (q15_t)0x3dc3, (q15_t)0x8fe3, (q15_t)0x3dbd, (q15_t)0x8fe0, - (q15_t)0x3db8, (q15_t)0x8fdd, (q15_t)0x3db2, (q15_t)0x8fda, (q15_t)0x3dad, (q15_t)0x8fd7, (q15_t)0x3da7, (q15_t)0x8fd4, - (q15_t)0x3da2, (q15_t)0x8fd1, (q15_t)0x3d9c, (q15_t)0x8fce, (q15_t)0x3d97, (q15_t)0x8fcb, (q15_t)0x3d91, (q15_t)0x8fc8, - (q15_t)0x3d8c, (q15_t)0x8fc5, (q15_t)0x3d86, (q15_t)0x8fc2, (q15_t)0x3d81, (q15_t)0x8fbf, (q15_t)0x3d7b, (q15_t)0x8fbc, - (q15_t)0x3d76, (q15_t)0x8fb9, (q15_t)0x3d70, (q15_t)0x8fb6, (q15_t)0x3d6b, (q15_t)0x8fb3, (q15_t)0x3d65, (q15_t)0x8fb0, - (q15_t)0x3d60, (q15_t)0x8fad, (q15_t)0x3d5a, (q15_t)0x8faa, (q15_t)0x3d55, (q15_t)0x8fa7, (q15_t)0x3d4f, (q15_t)0x8fa4, - (q15_t)0x3d49, (q15_t)0x8fa1, (q15_t)0x3d44, (q15_t)0x8f9e, (q15_t)0x3d3e, (q15_t)0x8f9b, (q15_t)0x3d39, (q15_t)0x8f98, - (q15_t)0x3d33, (q15_t)0x8f95, (q15_t)0x3d2e, (q15_t)0x8f92, (q15_t)0x3d28, (q15_t)0x8f8f, (q15_t)0x3d23, (q15_t)0x8f8c, - (q15_t)0x3d1d, (q15_t)0x8f89, (q15_t)0x3d18, (q15_t)0x8f86, (q15_t)0x3d12, (q15_t)0x8f83, (q15_t)0x3d0d, (q15_t)0x8f80, - (q15_t)0x3d07, (q15_t)0x8f7d, (q15_t)0x3d02, (q15_t)0x8f7a, (q15_t)0x3cfc, (q15_t)0x8f77, (q15_t)0x3cf7, (q15_t)0x8f74, - (q15_t)0x3cf1, (q15_t)0x8f71, (q15_t)0x3cec, (q15_t)0x8f6e, (q15_t)0x3ce6, (q15_t)0x8f6b, (q15_t)0x3ce1, (q15_t)0x8f68, - (q15_t)0x3cdb, (q15_t)0x8f65, (q15_t)0x3cd6, (q15_t)0x8f62, (q15_t)0x3cd0, (q15_t)0x8f5f, (q15_t)0x3cca, (q15_t)0x8f5c, - (q15_t)0x3cc5, (q15_t)0x8f59, (q15_t)0x3cbf, (q15_t)0x8f56, (q15_t)0x3cba, (q15_t)0x8f53, (q15_t)0x3cb4, (q15_t)0x8f50, - (q15_t)0x3caf, (q15_t)0x8f4d, (q15_t)0x3ca9, (q15_t)0x8f4a, (q15_t)0x3ca4, (q15_t)0x8f47, (q15_t)0x3c9e, (q15_t)0x8f44, - (q15_t)0x3c99, (q15_t)0x8f41, (q15_t)0x3c93, (q15_t)0x8f3e, (q15_t)0x3c8e, (q15_t)0x8f3b, (q15_t)0x3c88, (q15_t)0x8f38, - (q15_t)0x3c83, (q15_t)0x8f35, (q15_t)0x3c7d, (q15_t)0x8f32, (q15_t)0x3c77, (q15_t)0x8f2f, (q15_t)0x3c72, (q15_t)0x8f2d, - (q15_t)0x3c6c, (q15_t)0x8f2a, (q15_t)0x3c67, (q15_t)0x8f27, (q15_t)0x3c61, (q15_t)0x8f24, (q15_t)0x3c5c, (q15_t)0x8f21, - (q15_t)0x3c56, (q15_t)0x8f1e, (q15_t)0x3c51, (q15_t)0x8f1b, (q15_t)0x3c4b, (q15_t)0x8f18, (q15_t)0x3c46, (q15_t)0x8f15, - (q15_t)0x3c40, (q15_t)0x8f12, (q15_t)0x3c3b, (q15_t)0x8f0f, (q15_t)0x3c35, (q15_t)0x8f0c, (q15_t)0x3c2f, (q15_t)0x8f09, - (q15_t)0x3c2a, (q15_t)0x8f06, (q15_t)0x3c24, (q15_t)0x8f03, (q15_t)0x3c1f, (q15_t)0x8f00, (q15_t)0x3c19, (q15_t)0x8efd, - (q15_t)0x3c14, (q15_t)0x8efa, (q15_t)0x3c0e, (q15_t)0x8ef7, (q15_t)0x3c09, (q15_t)0x8ef4, (q15_t)0x3c03, (q15_t)0x8ef1, - (q15_t)0x3bfd, (q15_t)0x8eee, (q15_t)0x3bf8, (q15_t)0x8eec, (q15_t)0x3bf2, (q15_t)0x8ee9, (q15_t)0x3bed, (q15_t)0x8ee6, - (q15_t)0x3be7, (q15_t)0x8ee3, (q15_t)0x3be2, (q15_t)0x8ee0, (q15_t)0x3bdc, (q15_t)0x8edd, (q15_t)0x3bd7, (q15_t)0x8eda, - (q15_t)0x3bd1, (q15_t)0x8ed7, (q15_t)0x3bcc, (q15_t)0x8ed4, (q15_t)0x3bc6, (q15_t)0x8ed1, (q15_t)0x3bc0, (q15_t)0x8ece, - (q15_t)0x3bbb, (q15_t)0x8ecb, (q15_t)0x3bb5, (q15_t)0x8ec8, (q15_t)0x3bb0, (q15_t)0x8ec5, (q15_t)0x3baa, (q15_t)0x8ec2, - (q15_t)0x3ba5, (q15_t)0x8ebf, (q15_t)0x3b9f, (q15_t)0x8ebd, (q15_t)0x3b99, (q15_t)0x8eba, (q15_t)0x3b94, (q15_t)0x8eb7, - (q15_t)0x3b8e, (q15_t)0x8eb4, (q15_t)0x3b89, (q15_t)0x8eb1, (q15_t)0x3b83, (q15_t)0x8eae, (q15_t)0x3b7e, (q15_t)0x8eab, - (q15_t)0x3b78, (q15_t)0x8ea8, (q15_t)0x3b73, (q15_t)0x8ea5, (q15_t)0x3b6d, (q15_t)0x8ea2, (q15_t)0x3b67, (q15_t)0x8e9f, - (q15_t)0x3b62, (q15_t)0x8e9c, (q15_t)0x3b5c, (q15_t)0x8e99, (q15_t)0x3b57, (q15_t)0x8e97, (q15_t)0x3b51, (q15_t)0x8e94, - (q15_t)0x3b4c, (q15_t)0x8e91, (q15_t)0x3b46, (q15_t)0x8e8e, (q15_t)0x3b40, (q15_t)0x8e8b, (q15_t)0x3b3b, (q15_t)0x8e88, - (q15_t)0x3b35, (q15_t)0x8e85, (q15_t)0x3b30, (q15_t)0x8e82, (q15_t)0x3b2a, (q15_t)0x8e7f, (q15_t)0x3b25, (q15_t)0x8e7c, - (q15_t)0x3b1f, (q15_t)0x8e7a, (q15_t)0x3b19, (q15_t)0x8e77, (q15_t)0x3b14, (q15_t)0x8e74, (q15_t)0x3b0e, (q15_t)0x8e71, - (q15_t)0x3b09, (q15_t)0x8e6e, (q15_t)0x3b03, (q15_t)0x8e6b, (q15_t)0x3afe, (q15_t)0x8e68, (q15_t)0x3af8, (q15_t)0x8e65, - (q15_t)0x3af2, (q15_t)0x8e62, (q15_t)0x3aed, (q15_t)0x8e5f, (q15_t)0x3ae7, (q15_t)0x8e5d, (q15_t)0x3ae2, (q15_t)0x8e5a, - (q15_t)0x3adc, (q15_t)0x8e57, (q15_t)0x3ad7, (q15_t)0x8e54, (q15_t)0x3ad1, (q15_t)0x8e51, (q15_t)0x3acb, (q15_t)0x8e4e, - (q15_t)0x3ac6, (q15_t)0x8e4b, (q15_t)0x3ac0, (q15_t)0x8e48, (q15_t)0x3abb, (q15_t)0x8e45, (q15_t)0x3ab5, (q15_t)0x8e43, - (q15_t)0x3aaf, (q15_t)0x8e40, (q15_t)0x3aaa, (q15_t)0x8e3d, (q15_t)0x3aa4, (q15_t)0x8e3a, (q15_t)0x3a9f, (q15_t)0x8e37, - (q15_t)0x3a99, (q15_t)0x8e34, (q15_t)0x3a94, (q15_t)0x8e31, (q15_t)0x3a8e, (q15_t)0x8e2e, (q15_t)0x3a88, (q15_t)0x8e2c, - (q15_t)0x3a83, (q15_t)0x8e29, (q15_t)0x3a7d, (q15_t)0x8e26, (q15_t)0x3a78, (q15_t)0x8e23, (q15_t)0x3a72, (q15_t)0x8e20, - (q15_t)0x3a6c, (q15_t)0x8e1d, (q15_t)0x3a67, (q15_t)0x8e1a, (q15_t)0x3a61, (q15_t)0x8e17, (q15_t)0x3a5c, (q15_t)0x8e15, - (q15_t)0x3a56, (q15_t)0x8e12, (q15_t)0x3a50, (q15_t)0x8e0f, (q15_t)0x3a4b, (q15_t)0x8e0c, (q15_t)0x3a45, (q15_t)0x8e09, - (q15_t)0x3a40, (q15_t)0x8e06, (q15_t)0x3a3a, (q15_t)0x8e03, (q15_t)0x3a34, (q15_t)0x8e01, (q15_t)0x3a2f, (q15_t)0x8dfe, - (q15_t)0x3a29, (q15_t)0x8dfb, (q15_t)0x3a24, (q15_t)0x8df8, (q15_t)0x3a1e, (q15_t)0x8df5, (q15_t)0x3a19, (q15_t)0x8df2, - (q15_t)0x3a13, (q15_t)0x8def, (q15_t)0x3a0d, (q15_t)0x8ded, (q15_t)0x3a08, (q15_t)0x8dea, (q15_t)0x3a02, (q15_t)0x8de7, - (q15_t)0x39fd, (q15_t)0x8de4, (q15_t)0x39f7, (q15_t)0x8de1, (q15_t)0x39f1, (q15_t)0x8dde, (q15_t)0x39ec, (q15_t)0x8ddc, - (q15_t)0x39e6, (q15_t)0x8dd9, (q15_t)0x39e0, (q15_t)0x8dd6, (q15_t)0x39db, (q15_t)0x8dd3, (q15_t)0x39d5, (q15_t)0x8dd0, - (q15_t)0x39d0, (q15_t)0x8dcd, (q15_t)0x39ca, (q15_t)0x8dca, (q15_t)0x39c4, (q15_t)0x8dc8, (q15_t)0x39bf, (q15_t)0x8dc5, - (q15_t)0x39b9, (q15_t)0x8dc2, (q15_t)0x39b4, (q15_t)0x8dbf, (q15_t)0x39ae, (q15_t)0x8dbc, (q15_t)0x39a8, (q15_t)0x8db9, - (q15_t)0x39a3, (q15_t)0x8db7, (q15_t)0x399d, (q15_t)0x8db4, (q15_t)0x3998, (q15_t)0x8db1, (q15_t)0x3992, (q15_t)0x8dae, - (q15_t)0x398c, (q15_t)0x8dab, (q15_t)0x3987, (q15_t)0x8da9, (q15_t)0x3981, (q15_t)0x8da6, (q15_t)0x397c, (q15_t)0x8da3, - (q15_t)0x3976, (q15_t)0x8da0, (q15_t)0x3970, (q15_t)0x8d9d, (q15_t)0x396b, (q15_t)0x8d9a, (q15_t)0x3965, (q15_t)0x8d98, - (q15_t)0x395f, (q15_t)0x8d95, (q15_t)0x395a, (q15_t)0x8d92, (q15_t)0x3954, (q15_t)0x8d8f, (q15_t)0x394f, (q15_t)0x8d8c, - (q15_t)0x3949, (q15_t)0x8d8a, (q15_t)0x3943, (q15_t)0x8d87, (q15_t)0x393e, (q15_t)0x8d84, (q15_t)0x3938, (q15_t)0x8d81, - (q15_t)0x3932, (q15_t)0x8d7e, (q15_t)0x392d, (q15_t)0x8d7b, (q15_t)0x3927, (q15_t)0x8d79, (q15_t)0x3922, (q15_t)0x8d76, - (q15_t)0x391c, (q15_t)0x8d73, (q15_t)0x3916, (q15_t)0x8d70, (q15_t)0x3911, (q15_t)0x8d6d, (q15_t)0x390b, (q15_t)0x8d6b, - (q15_t)0x3906, (q15_t)0x8d68, (q15_t)0x3900, (q15_t)0x8d65, (q15_t)0x38fa, (q15_t)0x8d62, (q15_t)0x38f5, (q15_t)0x8d5f, - (q15_t)0x38ef, (q15_t)0x8d5d, (q15_t)0x38e9, (q15_t)0x8d5a, (q15_t)0x38e4, (q15_t)0x8d57, (q15_t)0x38de, (q15_t)0x8d54, - (q15_t)0x38d8, (q15_t)0x8d51, (q15_t)0x38d3, (q15_t)0x8d4f, (q15_t)0x38cd, (q15_t)0x8d4c, (q15_t)0x38c8, (q15_t)0x8d49, - (q15_t)0x38c2, (q15_t)0x8d46, (q15_t)0x38bc, (q15_t)0x8d44, (q15_t)0x38b7, (q15_t)0x8d41, (q15_t)0x38b1, (q15_t)0x8d3e, - (q15_t)0x38ab, (q15_t)0x8d3b, (q15_t)0x38a6, (q15_t)0x8d38, (q15_t)0x38a0, (q15_t)0x8d36, (q15_t)0x389b, (q15_t)0x8d33, - (q15_t)0x3895, (q15_t)0x8d30, (q15_t)0x388f, (q15_t)0x8d2d, (q15_t)0x388a, (q15_t)0x8d2b, (q15_t)0x3884, (q15_t)0x8d28, - (q15_t)0x387e, (q15_t)0x8d25, (q15_t)0x3879, (q15_t)0x8d22, (q15_t)0x3873, (q15_t)0x8d1f, (q15_t)0x386d, (q15_t)0x8d1d, - (q15_t)0x3868, (q15_t)0x8d1a, (q15_t)0x3862, (q15_t)0x8d17, (q15_t)0x385d, (q15_t)0x8d14, (q15_t)0x3857, (q15_t)0x8d12, - (q15_t)0x3851, (q15_t)0x8d0f, (q15_t)0x384c, (q15_t)0x8d0c, (q15_t)0x3846, (q15_t)0x8d09, (q15_t)0x3840, (q15_t)0x8d07, - (q15_t)0x383b, (q15_t)0x8d04, (q15_t)0x3835, (q15_t)0x8d01, (q15_t)0x382f, (q15_t)0x8cfe, (q15_t)0x382a, (q15_t)0x8cfb, - (q15_t)0x3824, (q15_t)0x8cf9, (q15_t)0x381e, (q15_t)0x8cf6, (q15_t)0x3819, (q15_t)0x8cf3, (q15_t)0x3813, (q15_t)0x8cf0, - (q15_t)0x380d, (q15_t)0x8cee, (q15_t)0x3808, (q15_t)0x8ceb, (q15_t)0x3802, (q15_t)0x8ce8, (q15_t)0x37fd, (q15_t)0x8ce5, - (q15_t)0x37f7, (q15_t)0x8ce3, (q15_t)0x37f1, (q15_t)0x8ce0, (q15_t)0x37ec, (q15_t)0x8cdd, (q15_t)0x37e6, (q15_t)0x8cda, - (q15_t)0x37e0, (q15_t)0x8cd8, (q15_t)0x37db, (q15_t)0x8cd5, (q15_t)0x37d5, (q15_t)0x8cd2, (q15_t)0x37cf, (q15_t)0x8cd0, - (q15_t)0x37ca, (q15_t)0x8ccd, (q15_t)0x37c4, (q15_t)0x8cca, (q15_t)0x37be, (q15_t)0x8cc7, (q15_t)0x37b9, (q15_t)0x8cc5, - (q15_t)0x37b3, (q15_t)0x8cc2, (q15_t)0x37ad, (q15_t)0x8cbf, (q15_t)0x37a8, (q15_t)0x8cbc, (q15_t)0x37a2, (q15_t)0x8cba, - (q15_t)0x379c, (q15_t)0x8cb7, (q15_t)0x3797, (q15_t)0x8cb4, (q15_t)0x3791, (q15_t)0x8cb1, (q15_t)0x378b, (q15_t)0x8caf, - (q15_t)0x3786, (q15_t)0x8cac, (q15_t)0x3780, (q15_t)0x8ca9, (q15_t)0x377a, (q15_t)0x8ca7, (q15_t)0x3775, (q15_t)0x8ca4, - (q15_t)0x376f, (q15_t)0x8ca1, (q15_t)0x3769, (q15_t)0x8c9e, (q15_t)0x3764, (q15_t)0x8c9c, (q15_t)0x375e, (q15_t)0x8c99, - (q15_t)0x3758, (q15_t)0x8c96, (q15_t)0x3753, (q15_t)0x8c94, (q15_t)0x374d, (q15_t)0x8c91, (q15_t)0x3747, (q15_t)0x8c8e, - (q15_t)0x3742, (q15_t)0x8c8b, (q15_t)0x373c, (q15_t)0x8c89, (q15_t)0x3736, (q15_t)0x8c86, (q15_t)0x3731, (q15_t)0x8c83, - (q15_t)0x372b, (q15_t)0x8c81, (q15_t)0x3725, (q15_t)0x8c7e, (q15_t)0x3720, (q15_t)0x8c7b, (q15_t)0x371a, (q15_t)0x8c78, - (q15_t)0x3714, (q15_t)0x8c76, (q15_t)0x370f, (q15_t)0x8c73, (q15_t)0x3709, (q15_t)0x8c70, (q15_t)0x3703, (q15_t)0x8c6e, - (q15_t)0x36fe, (q15_t)0x8c6b, (q15_t)0x36f8, (q15_t)0x8c68, (q15_t)0x36f2, (q15_t)0x8c65, (q15_t)0x36ed, (q15_t)0x8c63, - (q15_t)0x36e7, (q15_t)0x8c60, (q15_t)0x36e1, (q15_t)0x8c5d, (q15_t)0x36dc, (q15_t)0x8c5b, (q15_t)0x36d6, (q15_t)0x8c58, - (q15_t)0x36d0, (q15_t)0x8c55, (q15_t)0x36cb, (q15_t)0x8c53, (q15_t)0x36c5, (q15_t)0x8c50, (q15_t)0x36bf, (q15_t)0x8c4d, - (q15_t)0x36ba, (q15_t)0x8c4b, (q15_t)0x36b4, (q15_t)0x8c48, (q15_t)0x36ae, (q15_t)0x8c45, (q15_t)0x36a9, (q15_t)0x8c43, - (q15_t)0x36a3, (q15_t)0x8c40, (q15_t)0x369d, (q15_t)0x8c3d, (q15_t)0x3698, (q15_t)0x8c3a, (q15_t)0x3692, (q15_t)0x8c38, - (q15_t)0x368c, (q15_t)0x8c35, (q15_t)0x3686, (q15_t)0x8c32, (q15_t)0x3681, (q15_t)0x8c30, (q15_t)0x367b, (q15_t)0x8c2d, - (q15_t)0x3675, (q15_t)0x8c2a, (q15_t)0x3670, (q15_t)0x8c28, (q15_t)0x366a, (q15_t)0x8c25, (q15_t)0x3664, (q15_t)0x8c22, - (q15_t)0x365f, (q15_t)0x8c20, (q15_t)0x3659, (q15_t)0x8c1d, (q15_t)0x3653, (q15_t)0x8c1a, (q15_t)0x364e, (q15_t)0x8c18, - (q15_t)0x3648, (q15_t)0x8c15, (q15_t)0x3642, (q15_t)0x8c12, (q15_t)0x363d, (q15_t)0x8c10, (q15_t)0x3637, (q15_t)0x8c0d, - (q15_t)0x3631, (q15_t)0x8c0a, (q15_t)0x362b, (q15_t)0x8c08, (q15_t)0x3626, (q15_t)0x8c05, (q15_t)0x3620, (q15_t)0x8c02, - (q15_t)0x361a, (q15_t)0x8c00, (q15_t)0x3615, (q15_t)0x8bfd, (q15_t)0x360f, (q15_t)0x8bfa, (q15_t)0x3609, (q15_t)0x8bf8, - (q15_t)0x3604, (q15_t)0x8bf5, (q15_t)0x35fe, (q15_t)0x8bf3, (q15_t)0x35f8, (q15_t)0x8bf0, (q15_t)0x35f3, (q15_t)0x8bed, - (q15_t)0x35ed, (q15_t)0x8beb, (q15_t)0x35e7, (q15_t)0x8be8, (q15_t)0x35e1, (q15_t)0x8be5, (q15_t)0x35dc, (q15_t)0x8be3, - (q15_t)0x35d6, (q15_t)0x8be0, (q15_t)0x35d0, (q15_t)0x8bdd, (q15_t)0x35cb, (q15_t)0x8bdb, (q15_t)0x35c5, (q15_t)0x8bd8, - (q15_t)0x35bf, (q15_t)0x8bd5, (q15_t)0x35ba, (q15_t)0x8bd3, (q15_t)0x35b4, (q15_t)0x8bd0, (q15_t)0x35ae, (q15_t)0x8bce, - (q15_t)0x35a8, (q15_t)0x8bcb, (q15_t)0x35a3, (q15_t)0x8bc8, (q15_t)0x359d, (q15_t)0x8bc6, (q15_t)0x3597, (q15_t)0x8bc3, - (q15_t)0x3592, (q15_t)0x8bc0, (q15_t)0x358c, (q15_t)0x8bbe, (q15_t)0x3586, (q15_t)0x8bbb, (q15_t)0x3580, (q15_t)0x8bb8, - (q15_t)0x357b, (q15_t)0x8bb6, (q15_t)0x3575, (q15_t)0x8bb3, (q15_t)0x356f, (q15_t)0x8bb1, (q15_t)0x356a, (q15_t)0x8bae, - (q15_t)0x3564, (q15_t)0x8bab, (q15_t)0x355e, (q15_t)0x8ba9, (q15_t)0x3558, (q15_t)0x8ba6, (q15_t)0x3553, (q15_t)0x8ba4, - (q15_t)0x354d, (q15_t)0x8ba1, (q15_t)0x3547, (q15_t)0x8b9e, (q15_t)0x3542, (q15_t)0x8b9c, (q15_t)0x353c, (q15_t)0x8b99, - (q15_t)0x3536, (q15_t)0x8b96, (q15_t)0x3530, (q15_t)0x8b94, (q15_t)0x352b, (q15_t)0x8b91, (q15_t)0x3525, (q15_t)0x8b8f, - (q15_t)0x351f, (q15_t)0x8b8c, (q15_t)0x351a, (q15_t)0x8b89, (q15_t)0x3514, (q15_t)0x8b87, (q15_t)0x350e, (q15_t)0x8b84, - (q15_t)0x3508, (q15_t)0x8b82, (q15_t)0x3503, (q15_t)0x8b7f, (q15_t)0x34fd, (q15_t)0x8b7c, (q15_t)0x34f7, (q15_t)0x8b7a, - (q15_t)0x34f2, (q15_t)0x8b77, (q15_t)0x34ec, (q15_t)0x8b75, (q15_t)0x34e6, (q15_t)0x8b72, (q15_t)0x34e0, (q15_t)0x8b6f, - (q15_t)0x34db, (q15_t)0x8b6d, (q15_t)0x34d5, (q15_t)0x8b6a, (q15_t)0x34cf, (q15_t)0x8b68, (q15_t)0x34ca, (q15_t)0x8b65, - (q15_t)0x34c4, (q15_t)0x8b62, (q15_t)0x34be, (q15_t)0x8b60, (q15_t)0x34b8, (q15_t)0x8b5d, (q15_t)0x34b3, (q15_t)0x8b5b, - (q15_t)0x34ad, (q15_t)0x8b58, (q15_t)0x34a7, (q15_t)0x8b55, (q15_t)0x34a1, (q15_t)0x8b53, (q15_t)0x349c, (q15_t)0x8b50, - (q15_t)0x3496, (q15_t)0x8b4e, (q15_t)0x3490, (q15_t)0x8b4b, (q15_t)0x348b, (q15_t)0x8b49, (q15_t)0x3485, (q15_t)0x8b46, - (q15_t)0x347f, (q15_t)0x8b43, (q15_t)0x3479, (q15_t)0x8b41, (q15_t)0x3474, (q15_t)0x8b3e, (q15_t)0x346e, (q15_t)0x8b3c, - (q15_t)0x3468, (q15_t)0x8b39, (q15_t)0x3462, (q15_t)0x8b37, (q15_t)0x345d, (q15_t)0x8b34, (q15_t)0x3457, (q15_t)0x8b31, - (q15_t)0x3451, (q15_t)0x8b2f, (q15_t)0x344b, (q15_t)0x8b2c, (q15_t)0x3446, (q15_t)0x8b2a, (q15_t)0x3440, (q15_t)0x8b27, - (q15_t)0x343a, (q15_t)0x8b25, (q15_t)0x3435, (q15_t)0x8b22, (q15_t)0x342f, (q15_t)0x8b1f, (q15_t)0x3429, (q15_t)0x8b1d, - (q15_t)0x3423, (q15_t)0x8b1a, (q15_t)0x341e, (q15_t)0x8b18, (q15_t)0x3418, (q15_t)0x8b15, (q15_t)0x3412, (q15_t)0x8b13, - (q15_t)0x340c, (q15_t)0x8b10, (q15_t)0x3407, (q15_t)0x8b0e, (q15_t)0x3401, (q15_t)0x8b0b, (q15_t)0x33fb, (q15_t)0x8b08, - (q15_t)0x33f5, (q15_t)0x8b06, (q15_t)0x33f0, (q15_t)0x8b03, (q15_t)0x33ea, (q15_t)0x8b01, (q15_t)0x33e4, (q15_t)0x8afe, - (q15_t)0x33de, (q15_t)0x8afc, (q15_t)0x33d9, (q15_t)0x8af9, (q15_t)0x33d3, (q15_t)0x8af7, (q15_t)0x33cd, (q15_t)0x8af4, - (q15_t)0x33c7, (q15_t)0x8af1, (q15_t)0x33c2, (q15_t)0x8aef, (q15_t)0x33bc, (q15_t)0x8aec, (q15_t)0x33b6, (q15_t)0x8aea, - (q15_t)0x33b0, (q15_t)0x8ae7, (q15_t)0x33ab, (q15_t)0x8ae5, (q15_t)0x33a5, (q15_t)0x8ae2, (q15_t)0x339f, (q15_t)0x8ae0, - (q15_t)0x3399, (q15_t)0x8add, (q15_t)0x3394, (q15_t)0x8adb, (q15_t)0x338e, (q15_t)0x8ad8, (q15_t)0x3388, (q15_t)0x8ad6, - (q15_t)0x3382, (q15_t)0x8ad3, (q15_t)0x337d, (q15_t)0x8ad1, (q15_t)0x3377, (q15_t)0x8ace, (q15_t)0x3371, (q15_t)0x8acb, - (q15_t)0x336b, (q15_t)0x8ac9, (q15_t)0x3366, (q15_t)0x8ac6, (q15_t)0x3360, (q15_t)0x8ac4, (q15_t)0x335a, (q15_t)0x8ac1, - (q15_t)0x3354, (q15_t)0x8abf, (q15_t)0x334f, (q15_t)0x8abc, (q15_t)0x3349, (q15_t)0x8aba, (q15_t)0x3343, (q15_t)0x8ab7, - (q15_t)0x333d, (q15_t)0x8ab5, (q15_t)0x3338, (q15_t)0x8ab2, (q15_t)0x3332, (q15_t)0x8ab0, (q15_t)0x332c, (q15_t)0x8aad, - (q15_t)0x3326, (q15_t)0x8aab, (q15_t)0x3321, (q15_t)0x8aa8, (q15_t)0x331b, (q15_t)0x8aa6, (q15_t)0x3315, (q15_t)0x8aa3, - (q15_t)0x330f, (q15_t)0x8aa1, (q15_t)0x330a, (q15_t)0x8a9e, (q15_t)0x3304, (q15_t)0x8a9c, (q15_t)0x32fe, (q15_t)0x8a99, - (q15_t)0x32f8, (q15_t)0x8a97, (q15_t)0x32f3, (q15_t)0x8a94, (q15_t)0x32ed, (q15_t)0x8a92, (q15_t)0x32e7, (q15_t)0x8a8f, - (q15_t)0x32e1, (q15_t)0x8a8d, (q15_t)0x32db, (q15_t)0x8a8a, (q15_t)0x32d6, (q15_t)0x8a88, (q15_t)0x32d0, (q15_t)0x8a85, - (q15_t)0x32ca, (q15_t)0x8a83, (q15_t)0x32c4, (q15_t)0x8a80, (q15_t)0x32bf, (q15_t)0x8a7e, (q15_t)0x32b9, (q15_t)0x8a7b, - (q15_t)0x32b3, (q15_t)0x8a79, (q15_t)0x32ad, (q15_t)0x8a76, (q15_t)0x32a8, (q15_t)0x8a74, (q15_t)0x32a2, (q15_t)0x8a71, - (q15_t)0x329c, (q15_t)0x8a6f, (q15_t)0x3296, (q15_t)0x8a6c, (q15_t)0x3290, (q15_t)0x8a6a, (q15_t)0x328b, (q15_t)0x8a67, - (q15_t)0x3285, (q15_t)0x8a65, (q15_t)0x327f, (q15_t)0x8a62, (q15_t)0x3279, (q15_t)0x8a60, (q15_t)0x3274, (q15_t)0x8a5d, - (q15_t)0x326e, (q15_t)0x8a5b, (q15_t)0x3268, (q15_t)0x8a59, (q15_t)0x3262, (q15_t)0x8a56, (q15_t)0x325d, (q15_t)0x8a54, - (q15_t)0x3257, (q15_t)0x8a51, (q15_t)0x3251, (q15_t)0x8a4f, (q15_t)0x324b, (q15_t)0x8a4c, (q15_t)0x3245, (q15_t)0x8a4a, - (q15_t)0x3240, (q15_t)0x8a47, (q15_t)0x323a, (q15_t)0x8a45, (q15_t)0x3234, (q15_t)0x8a42, (q15_t)0x322e, (q15_t)0x8a40, - (q15_t)0x3228, (q15_t)0x8a3d, (q15_t)0x3223, (q15_t)0x8a3b, (q15_t)0x321d, (q15_t)0x8a38, (q15_t)0x3217, (q15_t)0x8a36, - (q15_t)0x3211, (q15_t)0x8a34, (q15_t)0x320c, (q15_t)0x8a31, (q15_t)0x3206, (q15_t)0x8a2f, (q15_t)0x3200, (q15_t)0x8a2c, - (q15_t)0x31fa, (q15_t)0x8a2a, (q15_t)0x31f4, (q15_t)0x8a27, (q15_t)0x31ef, (q15_t)0x8a25, (q15_t)0x31e9, (q15_t)0x8a22, - (q15_t)0x31e3, (q15_t)0x8a20, (q15_t)0x31dd, (q15_t)0x8a1d, (q15_t)0x31d8, (q15_t)0x8a1b, (q15_t)0x31d2, (q15_t)0x8a19, - (q15_t)0x31cc, (q15_t)0x8a16, (q15_t)0x31c6, (q15_t)0x8a14, (q15_t)0x31c0, (q15_t)0x8a11, (q15_t)0x31bb, (q15_t)0x8a0f, - (q15_t)0x31b5, (q15_t)0x8a0c, (q15_t)0x31af, (q15_t)0x8a0a, (q15_t)0x31a9, (q15_t)0x8a07, (q15_t)0x31a3, (q15_t)0x8a05, - (q15_t)0x319e, (q15_t)0x8a03, (q15_t)0x3198, (q15_t)0x8a00, (q15_t)0x3192, (q15_t)0x89fe, (q15_t)0x318c, (q15_t)0x89fb, - (q15_t)0x3186, (q15_t)0x89f9, (q15_t)0x3181, (q15_t)0x89f6, (q15_t)0x317b, (q15_t)0x89f4, (q15_t)0x3175, (q15_t)0x89f2, - (q15_t)0x316f, (q15_t)0x89ef, (q15_t)0x3169, (q15_t)0x89ed, (q15_t)0x3164, (q15_t)0x89ea, (q15_t)0x315e, (q15_t)0x89e8, - (q15_t)0x3158, (q15_t)0x89e5, (q15_t)0x3152, (q15_t)0x89e3, (q15_t)0x314c, (q15_t)0x89e1, (q15_t)0x3147, (q15_t)0x89de, - (q15_t)0x3141, (q15_t)0x89dc, (q15_t)0x313b, (q15_t)0x89d9, (q15_t)0x3135, (q15_t)0x89d7, (q15_t)0x312f, (q15_t)0x89d5, - (q15_t)0x312a, (q15_t)0x89d2, (q15_t)0x3124, (q15_t)0x89d0, (q15_t)0x311e, (q15_t)0x89cd, (q15_t)0x3118, (q15_t)0x89cb, - (q15_t)0x3112, (q15_t)0x89c8, (q15_t)0x310d, (q15_t)0x89c6, (q15_t)0x3107, (q15_t)0x89c4, (q15_t)0x3101, (q15_t)0x89c1, - (q15_t)0x30fb, (q15_t)0x89bf, (q15_t)0x30f5, (q15_t)0x89bc, (q15_t)0x30f0, (q15_t)0x89ba, (q15_t)0x30ea, (q15_t)0x89b8, - (q15_t)0x30e4, (q15_t)0x89b5, (q15_t)0x30de, (q15_t)0x89b3, (q15_t)0x30d8, (q15_t)0x89b0, (q15_t)0x30d3, (q15_t)0x89ae, - (q15_t)0x30cd, (q15_t)0x89ac, (q15_t)0x30c7, (q15_t)0x89a9, (q15_t)0x30c1, (q15_t)0x89a7, (q15_t)0x30bb, (q15_t)0x89a4, - (q15_t)0x30b6, (q15_t)0x89a2, (q15_t)0x30b0, (q15_t)0x89a0, (q15_t)0x30aa, (q15_t)0x899d, (q15_t)0x30a4, (q15_t)0x899b, - (q15_t)0x309e, (q15_t)0x8998, (q15_t)0x3099, (q15_t)0x8996, (q15_t)0x3093, (q15_t)0x8994, (q15_t)0x308d, (q15_t)0x8991, - (q15_t)0x3087, (q15_t)0x898f, (q15_t)0x3081, (q15_t)0x898d, (q15_t)0x307b, (q15_t)0x898a, (q15_t)0x3076, (q15_t)0x8988, - (q15_t)0x3070, (q15_t)0x8985, (q15_t)0x306a, (q15_t)0x8983, (q15_t)0x3064, (q15_t)0x8981, (q15_t)0x305e, (q15_t)0x897e, - (q15_t)0x3059, (q15_t)0x897c, (q15_t)0x3053, (q15_t)0x897a, (q15_t)0x304d, (q15_t)0x8977, (q15_t)0x3047, (q15_t)0x8975, - (q15_t)0x3041, (q15_t)0x8972, (q15_t)0x303b, (q15_t)0x8970, (q15_t)0x3036, (q15_t)0x896e, (q15_t)0x3030, (q15_t)0x896b, - (q15_t)0x302a, (q15_t)0x8969, (q15_t)0x3024, (q15_t)0x8967, (q15_t)0x301e, (q15_t)0x8964, (q15_t)0x3019, (q15_t)0x8962, - (q15_t)0x3013, (q15_t)0x8960, (q15_t)0x300d, (q15_t)0x895d, (q15_t)0x3007, (q15_t)0x895b, (q15_t)0x3001, (q15_t)0x8958, - (q15_t)0x2ffb, (q15_t)0x8956, (q15_t)0x2ff6, (q15_t)0x8954, (q15_t)0x2ff0, (q15_t)0x8951, (q15_t)0x2fea, (q15_t)0x894f, - (q15_t)0x2fe4, (q15_t)0x894d, (q15_t)0x2fde, (q15_t)0x894a, (q15_t)0x2fd8, (q15_t)0x8948, (q15_t)0x2fd3, (q15_t)0x8946, - (q15_t)0x2fcd, (q15_t)0x8943, (q15_t)0x2fc7, (q15_t)0x8941, (q15_t)0x2fc1, (q15_t)0x893f, (q15_t)0x2fbb, (q15_t)0x893c, - (q15_t)0x2fb5, (q15_t)0x893a, (q15_t)0x2fb0, (q15_t)0x8938, (q15_t)0x2faa, (q15_t)0x8935, (q15_t)0x2fa4, (q15_t)0x8933, - (q15_t)0x2f9e, (q15_t)0x8931, (q15_t)0x2f98, (q15_t)0x892e, (q15_t)0x2f92, (q15_t)0x892c, (q15_t)0x2f8d, (q15_t)0x892a, - (q15_t)0x2f87, (q15_t)0x8927, (q15_t)0x2f81, (q15_t)0x8925, (q15_t)0x2f7b, (q15_t)0x8923, (q15_t)0x2f75, (q15_t)0x8920, - (q15_t)0x2f6f, (q15_t)0x891e, (q15_t)0x2f6a, (q15_t)0x891c, (q15_t)0x2f64, (q15_t)0x8919, (q15_t)0x2f5e, (q15_t)0x8917, - (q15_t)0x2f58, (q15_t)0x8915, (q15_t)0x2f52, (q15_t)0x8912, (q15_t)0x2f4c, (q15_t)0x8910, (q15_t)0x2f47, (q15_t)0x890e, - (q15_t)0x2f41, (q15_t)0x890b, (q15_t)0x2f3b, (q15_t)0x8909, (q15_t)0x2f35, (q15_t)0x8907, (q15_t)0x2f2f, (q15_t)0x8904, - (q15_t)0x2f29, (q15_t)0x8902, (q15_t)0x2f24, (q15_t)0x8900, (q15_t)0x2f1e, (q15_t)0x88fd, (q15_t)0x2f18, (q15_t)0x88fb, - (q15_t)0x2f12, (q15_t)0x88f9, (q15_t)0x2f0c, (q15_t)0x88f6, (q15_t)0x2f06, (q15_t)0x88f4, (q15_t)0x2f01, (q15_t)0x88f2, - (q15_t)0x2efb, (q15_t)0x88f0, (q15_t)0x2ef5, (q15_t)0x88ed, (q15_t)0x2eef, (q15_t)0x88eb, (q15_t)0x2ee9, (q15_t)0x88e9, - (q15_t)0x2ee3, (q15_t)0x88e6, (q15_t)0x2edd, (q15_t)0x88e4, (q15_t)0x2ed8, (q15_t)0x88e2, (q15_t)0x2ed2, (q15_t)0x88df, - (q15_t)0x2ecc, (q15_t)0x88dd, (q15_t)0x2ec6, (q15_t)0x88db, (q15_t)0x2ec0, (q15_t)0x88d9, (q15_t)0x2eba, (q15_t)0x88d6, - (q15_t)0x2eb5, (q15_t)0x88d4, (q15_t)0x2eaf, (q15_t)0x88d2, (q15_t)0x2ea9, (q15_t)0x88cf, (q15_t)0x2ea3, (q15_t)0x88cd, - (q15_t)0x2e9d, (q15_t)0x88cb, (q15_t)0x2e97, (q15_t)0x88c8, (q15_t)0x2e91, (q15_t)0x88c6, (q15_t)0x2e8c, (q15_t)0x88c4, - (q15_t)0x2e86, (q15_t)0x88c2, (q15_t)0x2e80, (q15_t)0x88bf, (q15_t)0x2e7a, (q15_t)0x88bd, (q15_t)0x2e74, (q15_t)0x88bb, - (q15_t)0x2e6e, (q15_t)0x88b9, (q15_t)0x2e68, (q15_t)0x88b6, (q15_t)0x2e63, (q15_t)0x88b4, (q15_t)0x2e5d, (q15_t)0x88b2, - (q15_t)0x2e57, (q15_t)0x88af, (q15_t)0x2e51, (q15_t)0x88ad, (q15_t)0x2e4b, (q15_t)0x88ab, (q15_t)0x2e45, (q15_t)0x88a9, - (q15_t)0x2e3f, (q15_t)0x88a6, (q15_t)0x2e3a, (q15_t)0x88a4, (q15_t)0x2e34, (q15_t)0x88a2, (q15_t)0x2e2e, (q15_t)0x88a0, - (q15_t)0x2e28, (q15_t)0x889d, (q15_t)0x2e22, (q15_t)0x889b, (q15_t)0x2e1c, (q15_t)0x8899, (q15_t)0x2e16, (q15_t)0x8896, - (q15_t)0x2e11, (q15_t)0x8894, (q15_t)0x2e0b, (q15_t)0x8892, (q15_t)0x2e05, (q15_t)0x8890, (q15_t)0x2dff, (q15_t)0x888d, - (q15_t)0x2df9, (q15_t)0x888b, (q15_t)0x2df3, (q15_t)0x8889, (q15_t)0x2ded, (q15_t)0x8887, (q15_t)0x2de7, (q15_t)0x8884, - (q15_t)0x2de2, (q15_t)0x8882, (q15_t)0x2ddc, (q15_t)0x8880, (q15_t)0x2dd6, (q15_t)0x887e, (q15_t)0x2dd0, (q15_t)0x887b, - (q15_t)0x2dca, (q15_t)0x8879, (q15_t)0x2dc4, (q15_t)0x8877, (q15_t)0x2dbe, (q15_t)0x8875, (q15_t)0x2db9, (q15_t)0x8872, - (q15_t)0x2db3, (q15_t)0x8870, (q15_t)0x2dad, (q15_t)0x886e, (q15_t)0x2da7, (q15_t)0x886c, (q15_t)0x2da1, (q15_t)0x8869, - (q15_t)0x2d9b, (q15_t)0x8867, (q15_t)0x2d95, (q15_t)0x8865, (q15_t)0x2d8f, (q15_t)0x8863, (q15_t)0x2d8a, (q15_t)0x8860, - (q15_t)0x2d84, (q15_t)0x885e, (q15_t)0x2d7e, (q15_t)0x885c, (q15_t)0x2d78, (q15_t)0x885a, (q15_t)0x2d72, (q15_t)0x8858, - (q15_t)0x2d6c, (q15_t)0x8855, (q15_t)0x2d66, (q15_t)0x8853, (q15_t)0x2d60, (q15_t)0x8851, (q15_t)0x2d5b, (q15_t)0x884f, - (q15_t)0x2d55, (q15_t)0x884c, (q15_t)0x2d4f, (q15_t)0x884a, (q15_t)0x2d49, (q15_t)0x8848, (q15_t)0x2d43, (q15_t)0x8846, - (q15_t)0x2d3d, (q15_t)0x8844, (q15_t)0x2d37, (q15_t)0x8841, (q15_t)0x2d31, (q15_t)0x883f, (q15_t)0x2d2c, (q15_t)0x883d, - (q15_t)0x2d26, (q15_t)0x883b, (q15_t)0x2d20, (q15_t)0x8838, (q15_t)0x2d1a, (q15_t)0x8836, (q15_t)0x2d14, (q15_t)0x8834, - (q15_t)0x2d0e, (q15_t)0x8832, (q15_t)0x2d08, (q15_t)0x8830, (q15_t)0x2d02, (q15_t)0x882d, (q15_t)0x2cfd, (q15_t)0x882b, - (q15_t)0x2cf7, (q15_t)0x8829, (q15_t)0x2cf1, (q15_t)0x8827, (q15_t)0x2ceb, (q15_t)0x8825, (q15_t)0x2ce5, (q15_t)0x8822, - (q15_t)0x2cdf, (q15_t)0x8820, (q15_t)0x2cd9, (q15_t)0x881e, (q15_t)0x2cd3, (q15_t)0x881c, (q15_t)0x2ccd, (q15_t)0x881a, - (q15_t)0x2cc8, (q15_t)0x8817, (q15_t)0x2cc2, (q15_t)0x8815, (q15_t)0x2cbc, (q15_t)0x8813, (q15_t)0x2cb6, (q15_t)0x8811, - (q15_t)0x2cb0, (q15_t)0x880f, (q15_t)0x2caa, (q15_t)0x880c, (q15_t)0x2ca4, (q15_t)0x880a, (q15_t)0x2c9e, (q15_t)0x8808, - (q15_t)0x2c98, (q15_t)0x8806, (q15_t)0x2c93, (q15_t)0x8804, (q15_t)0x2c8d, (q15_t)0x8801, (q15_t)0x2c87, (q15_t)0x87ff, - (q15_t)0x2c81, (q15_t)0x87fd, (q15_t)0x2c7b, (q15_t)0x87fb, (q15_t)0x2c75, (q15_t)0x87f9, (q15_t)0x2c6f, (q15_t)0x87f6, - (q15_t)0x2c69, (q15_t)0x87f4, (q15_t)0x2c63, (q15_t)0x87f2, (q15_t)0x2c5e, (q15_t)0x87f0, (q15_t)0x2c58, (q15_t)0x87ee, - (q15_t)0x2c52, (q15_t)0x87ec, (q15_t)0x2c4c, (q15_t)0x87e9, (q15_t)0x2c46, (q15_t)0x87e7, (q15_t)0x2c40, (q15_t)0x87e5, - (q15_t)0x2c3a, (q15_t)0x87e3, (q15_t)0x2c34, (q15_t)0x87e1, (q15_t)0x2c2e, (q15_t)0x87df, (q15_t)0x2c29, (q15_t)0x87dc, - (q15_t)0x2c23, (q15_t)0x87da, (q15_t)0x2c1d, (q15_t)0x87d8, (q15_t)0x2c17, (q15_t)0x87d6, (q15_t)0x2c11, (q15_t)0x87d4, - (q15_t)0x2c0b, (q15_t)0x87d2, (q15_t)0x2c05, (q15_t)0x87cf, (q15_t)0x2bff, (q15_t)0x87cd, (q15_t)0x2bf9, (q15_t)0x87cb, - (q15_t)0x2bf3, (q15_t)0x87c9, (q15_t)0x2bee, (q15_t)0x87c7, (q15_t)0x2be8, (q15_t)0x87c5, (q15_t)0x2be2, (q15_t)0x87c2, - (q15_t)0x2bdc, (q15_t)0x87c0, (q15_t)0x2bd6, (q15_t)0x87be, (q15_t)0x2bd0, (q15_t)0x87bc, (q15_t)0x2bca, (q15_t)0x87ba, - (q15_t)0x2bc4, (q15_t)0x87b8, (q15_t)0x2bbe, (q15_t)0x87b6, (q15_t)0x2bb8, (q15_t)0x87b3, (q15_t)0x2bb2, (q15_t)0x87b1, - (q15_t)0x2bad, (q15_t)0x87af, (q15_t)0x2ba7, (q15_t)0x87ad, (q15_t)0x2ba1, (q15_t)0x87ab, (q15_t)0x2b9b, (q15_t)0x87a9, - (q15_t)0x2b95, (q15_t)0x87a7, (q15_t)0x2b8f, (q15_t)0x87a4, (q15_t)0x2b89, (q15_t)0x87a2, (q15_t)0x2b83, (q15_t)0x87a0, - (q15_t)0x2b7d, (q15_t)0x879e, (q15_t)0x2b77, (q15_t)0x879c, (q15_t)0x2b71, (q15_t)0x879a, (q15_t)0x2b6c, (q15_t)0x8798, - (q15_t)0x2b66, (q15_t)0x8795, (q15_t)0x2b60, (q15_t)0x8793, (q15_t)0x2b5a, (q15_t)0x8791, (q15_t)0x2b54, (q15_t)0x878f, - (q15_t)0x2b4e, (q15_t)0x878d, (q15_t)0x2b48, (q15_t)0x878b, (q15_t)0x2b42, (q15_t)0x8789, (q15_t)0x2b3c, (q15_t)0x8787, - (q15_t)0x2b36, (q15_t)0x8784, (q15_t)0x2b30, (q15_t)0x8782, (q15_t)0x2b2b, (q15_t)0x8780, (q15_t)0x2b25, (q15_t)0x877e, - (q15_t)0x2b1f, (q15_t)0x877c, (q15_t)0x2b19, (q15_t)0x877a, (q15_t)0x2b13, (q15_t)0x8778, (q15_t)0x2b0d, (q15_t)0x8776, - (q15_t)0x2b07, (q15_t)0x8774, (q15_t)0x2b01, (q15_t)0x8771, (q15_t)0x2afb, (q15_t)0x876f, (q15_t)0x2af5, (q15_t)0x876d, - (q15_t)0x2aef, (q15_t)0x876b, (q15_t)0x2ae9, (q15_t)0x8769, (q15_t)0x2ae4, (q15_t)0x8767, (q15_t)0x2ade, (q15_t)0x8765, - (q15_t)0x2ad8, (q15_t)0x8763, (q15_t)0x2ad2, (q15_t)0x8761, (q15_t)0x2acc, (q15_t)0x875e, (q15_t)0x2ac6, (q15_t)0x875c, - (q15_t)0x2ac0, (q15_t)0x875a, (q15_t)0x2aba, (q15_t)0x8758, (q15_t)0x2ab4, (q15_t)0x8756, (q15_t)0x2aae, (q15_t)0x8754, - (q15_t)0x2aa8, (q15_t)0x8752, (q15_t)0x2aa2, (q15_t)0x8750, (q15_t)0x2a9c, (q15_t)0x874e, (q15_t)0x2a97, (q15_t)0x874c, - (q15_t)0x2a91, (q15_t)0x874a, (q15_t)0x2a8b, (q15_t)0x8747, (q15_t)0x2a85, (q15_t)0x8745, (q15_t)0x2a7f, (q15_t)0x8743, - (q15_t)0x2a79, (q15_t)0x8741, (q15_t)0x2a73, (q15_t)0x873f, (q15_t)0x2a6d, (q15_t)0x873d, (q15_t)0x2a67, (q15_t)0x873b, - (q15_t)0x2a61, (q15_t)0x8739, (q15_t)0x2a5b, (q15_t)0x8737, (q15_t)0x2a55, (q15_t)0x8735, (q15_t)0x2a4f, (q15_t)0x8733, - (q15_t)0x2a49, (q15_t)0x8731, (q15_t)0x2a44, (q15_t)0x872e, (q15_t)0x2a3e, (q15_t)0x872c, (q15_t)0x2a38, (q15_t)0x872a, - (q15_t)0x2a32, (q15_t)0x8728, (q15_t)0x2a2c, (q15_t)0x8726, (q15_t)0x2a26, (q15_t)0x8724, (q15_t)0x2a20, (q15_t)0x8722, - (q15_t)0x2a1a, (q15_t)0x8720, (q15_t)0x2a14, (q15_t)0x871e, (q15_t)0x2a0e, (q15_t)0x871c, (q15_t)0x2a08, (q15_t)0x871a, - (q15_t)0x2a02, (q15_t)0x8718, (q15_t)0x29fc, (q15_t)0x8716, (q15_t)0x29f6, (q15_t)0x8714, (q15_t)0x29f0, (q15_t)0x8712, - (q15_t)0x29eb, (q15_t)0x870f, (q15_t)0x29e5, (q15_t)0x870d, (q15_t)0x29df, (q15_t)0x870b, (q15_t)0x29d9, (q15_t)0x8709, - (q15_t)0x29d3, (q15_t)0x8707, (q15_t)0x29cd, (q15_t)0x8705, (q15_t)0x29c7, (q15_t)0x8703, (q15_t)0x29c1, (q15_t)0x8701, - (q15_t)0x29bb, (q15_t)0x86ff, (q15_t)0x29b5, (q15_t)0x86fd, (q15_t)0x29af, (q15_t)0x86fb, (q15_t)0x29a9, (q15_t)0x86f9, - (q15_t)0x29a3, (q15_t)0x86f7, (q15_t)0x299d, (q15_t)0x86f5, (q15_t)0x2997, (q15_t)0x86f3, (q15_t)0x2991, (q15_t)0x86f1, - (q15_t)0x298b, (q15_t)0x86ef, (q15_t)0x2986, (q15_t)0x86ed, (q15_t)0x2980, (q15_t)0x86eb, (q15_t)0x297a, (q15_t)0x86e9, - (q15_t)0x2974, (q15_t)0x86e7, (q15_t)0x296e, (q15_t)0x86e4, (q15_t)0x2968, (q15_t)0x86e2, (q15_t)0x2962, (q15_t)0x86e0, - (q15_t)0x295c, (q15_t)0x86de, (q15_t)0x2956, (q15_t)0x86dc, (q15_t)0x2950, (q15_t)0x86da, (q15_t)0x294a, (q15_t)0x86d8, - (q15_t)0x2944, (q15_t)0x86d6, (q15_t)0x293e, (q15_t)0x86d4, (q15_t)0x2938, (q15_t)0x86d2, (q15_t)0x2932, (q15_t)0x86d0, - (q15_t)0x292c, (q15_t)0x86ce, (q15_t)0x2926, (q15_t)0x86cc, (q15_t)0x2920, (q15_t)0x86ca, (q15_t)0x291b, (q15_t)0x86c8, - (q15_t)0x2915, (q15_t)0x86c6, (q15_t)0x290f, (q15_t)0x86c4, (q15_t)0x2909, (q15_t)0x86c2, (q15_t)0x2903, (q15_t)0x86c0, - (q15_t)0x28fd, (q15_t)0x86be, (q15_t)0x28f7, (q15_t)0x86bc, (q15_t)0x28f1, (q15_t)0x86ba, (q15_t)0x28eb, (q15_t)0x86b8, - (q15_t)0x28e5, (q15_t)0x86b6, (q15_t)0x28df, (q15_t)0x86b4, (q15_t)0x28d9, (q15_t)0x86b2, (q15_t)0x28d3, (q15_t)0x86b0, - (q15_t)0x28cd, (q15_t)0x86ae, (q15_t)0x28c7, (q15_t)0x86ac, (q15_t)0x28c1, (q15_t)0x86aa, (q15_t)0x28bb, (q15_t)0x86a8, - (q15_t)0x28b5, (q15_t)0x86a6, (q15_t)0x28af, (q15_t)0x86a4, (q15_t)0x28a9, (q15_t)0x86a2, (q15_t)0x28a3, (q15_t)0x86a0, - (q15_t)0x289d, (q15_t)0x869e, (q15_t)0x2898, (q15_t)0x869c, (q15_t)0x2892, (q15_t)0x869a, (q15_t)0x288c, (q15_t)0x8698, - (q15_t)0x2886, (q15_t)0x8696, (q15_t)0x2880, (q15_t)0x8694, (q15_t)0x287a, (q15_t)0x8692, (q15_t)0x2874, (q15_t)0x8690, - (q15_t)0x286e, (q15_t)0x868e, (q15_t)0x2868, (q15_t)0x868c, (q15_t)0x2862, (q15_t)0x868a, (q15_t)0x285c, (q15_t)0x8688, - (q15_t)0x2856, (q15_t)0x8686, (q15_t)0x2850, (q15_t)0x8684, (q15_t)0x284a, (q15_t)0x8682, (q15_t)0x2844, (q15_t)0x8680, - (q15_t)0x283e, (q15_t)0x867e, (q15_t)0x2838, (q15_t)0x867c, (q15_t)0x2832, (q15_t)0x867a, (q15_t)0x282c, (q15_t)0x8678, - (q15_t)0x2826, (q15_t)0x8676, (q15_t)0x2820, (q15_t)0x8674, (q15_t)0x281a, (q15_t)0x8672, (q15_t)0x2814, (q15_t)0x8670, - (q15_t)0x280e, (q15_t)0x866e, (q15_t)0x2808, (q15_t)0x866d, (q15_t)0x2802, (q15_t)0x866b, (q15_t)0x27fc, (q15_t)0x8669, - (q15_t)0x27f6, (q15_t)0x8667, (q15_t)0x27f1, (q15_t)0x8665, (q15_t)0x27eb, (q15_t)0x8663, (q15_t)0x27e5, (q15_t)0x8661, - (q15_t)0x27df, (q15_t)0x865f, (q15_t)0x27d9, (q15_t)0x865d, (q15_t)0x27d3, (q15_t)0x865b, (q15_t)0x27cd, (q15_t)0x8659, - (q15_t)0x27c7, (q15_t)0x8657, (q15_t)0x27c1, (q15_t)0x8655, (q15_t)0x27bb, (q15_t)0x8653, (q15_t)0x27b5, (q15_t)0x8651, - (q15_t)0x27af, (q15_t)0x864f, (q15_t)0x27a9, (q15_t)0x864d, (q15_t)0x27a3, (q15_t)0x864b, (q15_t)0x279d, (q15_t)0x8649, - (q15_t)0x2797, (q15_t)0x8647, (q15_t)0x2791, (q15_t)0x8645, (q15_t)0x278b, (q15_t)0x8644, (q15_t)0x2785, (q15_t)0x8642, - (q15_t)0x277f, (q15_t)0x8640, (q15_t)0x2779, (q15_t)0x863e, (q15_t)0x2773, (q15_t)0x863c, (q15_t)0x276d, (q15_t)0x863a, - (q15_t)0x2767, (q15_t)0x8638, (q15_t)0x2761, (q15_t)0x8636, (q15_t)0x275b, (q15_t)0x8634, (q15_t)0x2755, (q15_t)0x8632, - (q15_t)0x274f, (q15_t)0x8630, (q15_t)0x2749, (q15_t)0x862e, (q15_t)0x2743, (q15_t)0x862c, (q15_t)0x273d, (q15_t)0x862a, - (q15_t)0x2737, (q15_t)0x8628, (q15_t)0x2731, (q15_t)0x8627, (q15_t)0x272b, (q15_t)0x8625, (q15_t)0x2725, (q15_t)0x8623, - (q15_t)0x271f, (q15_t)0x8621, (q15_t)0x2719, (q15_t)0x861f, (q15_t)0x2713, (q15_t)0x861d, (q15_t)0x270d, (q15_t)0x861b, - (q15_t)0x2707, (q15_t)0x8619, (q15_t)0x2701, (q15_t)0x8617, (q15_t)0x26fb, (q15_t)0x8615, (q15_t)0x26f5, (q15_t)0x8613, - (q15_t)0x26ef, (q15_t)0x8611, (q15_t)0x26e9, (q15_t)0x8610, (q15_t)0x26e4, (q15_t)0x860e, (q15_t)0x26de, (q15_t)0x860c, - (q15_t)0x26d8, (q15_t)0x860a, (q15_t)0x26d2, (q15_t)0x8608, (q15_t)0x26cc, (q15_t)0x8606, (q15_t)0x26c6, (q15_t)0x8604, - (q15_t)0x26c0, (q15_t)0x8602, (q15_t)0x26ba, (q15_t)0x8600, (q15_t)0x26b4, (q15_t)0x85fe, (q15_t)0x26ae, (q15_t)0x85fc, - (q15_t)0x26a8, (q15_t)0x85fb, (q15_t)0x26a2, (q15_t)0x85f9, (q15_t)0x269c, (q15_t)0x85f7, (q15_t)0x2696, (q15_t)0x85f5, - (q15_t)0x2690, (q15_t)0x85f3, (q15_t)0x268a, (q15_t)0x85f1, (q15_t)0x2684, (q15_t)0x85ef, (q15_t)0x267e, (q15_t)0x85ed, - (q15_t)0x2678, (q15_t)0x85eb, (q15_t)0x2672, (q15_t)0x85ea, (q15_t)0x266c, (q15_t)0x85e8, (q15_t)0x2666, (q15_t)0x85e6, - (q15_t)0x2660, (q15_t)0x85e4, (q15_t)0x265a, (q15_t)0x85e2, (q15_t)0x2654, (q15_t)0x85e0, (q15_t)0x264e, (q15_t)0x85de, - (q15_t)0x2648, (q15_t)0x85dc, (q15_t)0x2642, (q15_t)0x85da, (q15_t)0x263c, (q15_t)0x85d9, (q15_t)0x2636, (q15_t)0x85d7, - (q15_t)0x2630, (q15_t)0x85d5, (q15_t)0x262a, (q15_t)0x85d3, (q15_t)0x2624, (q15_t)0x85d1, (q15_t)0x261e, (q15_t)0x85cf, - (q15_t)0x2618, (q15_t)0x85cd, (q15_t)0x2612, (q15_t)0x85cb, (q15_t)0x260c, (q15_t)0x85ca, (q15_t)0x2606, (q15_t)0x85c8, - (q15_t)0x2600, (q15_t)0x85c6, (q15_t)0x25fa, (q15_t)0x85c4, (q15_t)0x25f4, (q15_t)0x85c2, (q15_t)0x25ee, (q15_t)0x85c0, - (q15_t)0x25e8, (q15_t)0x85be, (q15_t)0x25e2, (q15_t)0x85bd, (q15_t)0x25dc, (q15_t)0x85bb, (q15_t)0x25d6, (q15_t)0x85b9, - (q15_t)0x25d0, (q15_t)0x85b7, (q15_t)0x25ca, (q15_t)0x85b5, (q15_t)0x25c4, (q15_t)0x85b3, (q15_t)0x25be, (q15_t)0x85b1, - (q15_t)0x25b8, (q15_t)0x85b0, (q15_t)0x25b2, (q15_t)0x85ae, (q15_t)0x25ac, (q15_t)0x85ac, (q15_t)0x25a6, (q15_t)0x85aa, - (q15_t)0x25a0, (q15_t)0x85a8, (q15_t)0x259a, (q15_t)0x85a6, (q15_t)0x2594, (q15_t)0x85a4, (q15_t)0x258e, (q15_t)0x85a3, - (q15_t)0x2588, (q15_t)0x85a1, (q15_t)0x2582, (q15_t)0x859f, (q15_t)0x257c, (q15_t)0x859d, (q15_t)0x2576, (q15_t)0x859b, - (q15_t)0x2570, (q15_t)0x8599, (q15_t)0x256a, (q15_t)0x8598, (q15_t)0x2564, (q15_t)0x8596, (q15_t)0x255e, (q15_t)0x8594, - (q15_t)0x2558, (q15_t)0x8592, (q15_t)0x2552, (q15_t)0x8590, (q15_t)0x254c, (q15_t)0x858e, (q15_t)0x2546, (q15_t)0x858d, - (q15_t)0x2540, (q15_t)0x858b, (q15_t)0x253a, (q15_t)0x8589, (q15_t)0x2534, (q15_t)0x8587, (q15_t)0x252e, (q15_t)0x8585, - (q15_t)0x2528, (q15_t)0x8583, (q15_t)0x2522, (q15_t)0x8582, (q15_t)0x251c, (q15_t)0x8580, (q15_t)0x2516, (q15_t)0x857e, - (q15_t)0x250f, (q15_t)0x857c, (q15_t)0x2509, (q15_t)0x857a, (q15_t)0x2503, (q15_t)0x8579, (q15_t)0x24fd, (q15_t)0x8577, - (q15_t)0x24f7, (q15_t)0x8575, (q15_t)0x24f1, (q15_t)0x8573, (q15_t)0x24eb, (q15_t)0x8571, (q15_t)0x24e5, (q15_t)0x856f, - (q15_t)0x24df, (q15_t)0x856e, (q15_t)0x24d9, (q15_t)0x856c, (q15_t)0x24d3, (q15_t)0x856a, (q15_t)0x24cd, (q15_t)0x8568, - (q15_t)0x24c7, (q15_t)0x8566, (q15_t)0x24c1, (q15_t)0x8565, (q15_t)0x24bb, (q15_t)0x8563, (q15_t)0x24b5, (q15_t)0x8561, - (q15_t)0x24af, (q15_t)0x855f, (q15_t)0x24a9, (q15_t)0x855d, (q15_t)0x24a3, (q15_t)0x855c, (q15_t)0x249d, (q15_t)0x855a, - (q15_t)0x2497, (q15_t)0x8558, (q15_t)0x2491, (q15_t)0x8556, (q15_t)0x248b, (q15_t)0x8554, (q15_t)0x2485, (q15_t)0x8553, - (q15_t)0x247f, (q15_t)0x8551, (q15_t)0x2479, (q15_t)0x854f, (q15_t)0x2473, (q15_t)0x854d, (q15_t)0x246d, (q15_t)0x854b, - (q15_t)0x2467, (q15_t)0x854a, (q15_t)0x2461, (q15_t)0x8548, (q15_t)0x245b, (q15_t)0x8546, (q15_t)0x2455, (q15_t)0x8544, - (q15_t)0x244f, (q15_t)0x8543, (q15_t)0x2449, (q15_t)0x8541, (q15_t)0x2443, (q15_t)0x853f, (q15_t)0x243d, (q15_t)0x853d, - (q15_t)0x2437, (q15_t)0x853b, (q15_t)0x2431, (q15_t)0x853a, (q15_t)0x242b, (q15_t)0x8538, (q15_t)0x2425, (q15_t)0x8536, - (q15_t)0x241f, (q15_t)0x8534, (q15_t)0x2419, (q15_t)0x8533, (q15_t)0x2413, (q15_t)0x8531, (q15_t)0x240d, (q15_t)0x852f, - (q15_t)0x2407, (q15_t)0x852d, (q15_t)0x2401, (q15_t)0x852b, (q15_t)0x23fa, (q15_t)0x852a, (q15_t)0x23f4, (q15_t)0x8528, - (q15_t)0x23ee, (q15_t)0x8526, (q15_t)0x23e8, (q15_t)0x8524, (q15_t)0x23e2, (q15_t)0x8523, (q15_t)0x23dc, (q15_t)0x8521, - (q15_t)0x23d6, (q15_t)0x851f, (q15_t)0x23d0, (q15_t)0x851d, (q15_t)0x23ca, (q15_t)0x851c, (q15_t)0x23c4, (q15_t)0x851a, - (q15_t)0x23be, (q15_t)0x8518, (q15_t)0x23b8, (q15_t)0x8516, (q15_t)0x23b2, (q15_t)0x8515, (q15_t)0x23ac, (q15_t)0x8513, - (q15_t)0x23a6, (q15_t)0x8511, (q15_t)0x23a0, (q15_t)0x850f, (q15_t)0x239a, (q15_t)0x850e, (q15_t)0x2394, (q15_t)0x850c, - (q15_t)0x238e, (q15_t)0x850a, (q15_t)0x2388, (q15_t)0x8508, (q15_t)0x2382, (q15_t)0x8507, (q15_t)0x237c, (q15_t)0x8505, - (q15_t)0x2376, (q15_t)0x8503, (q15_t)0x2370, (q15_t)0x8501, (q15_t)0x236a, (q15_t)0x8500, (q15_t)0x2364, (q15_t)0x84fe, - (q15_t)0x235e, (q15_t)0x84fc, (q15_t)0x2358, (q15_t)0x84fa, (q15_t)0x2352, (q15_t)0x84f9, (q15_t)0x234b, (q15_t)0x84f7, - (q15_t)0x2345, (q15_t)0x84f5, (q15_t)0x233f, (q15_t)0x84f4, (q15_t)0x2339, (q15_t)0x84f2, (q15_t)0x2333, (q15_t)0x84f0, - (q15_t)0x232d, (q15_t)0x84ee, (q15_t)0x2327, (q15_t)0x84ed, (q15_t)0x2321, (q15_t)0x84eb, (q15_t)0x231b, (q15_t)0x84e9, - (q15_t)0x2315, (q15_t)0x84e7, (q15_t)0x230f, (q15_t)0x84e6, (q15_t)0x2309, (q15_t)0x84e4, (q15_t)0x2303, (q15_t)0x84e2, - (q15_t)0x22fd, (q15_t)0x84e1, (q15_t)0x22f7, (q15_t)0x84df, (q15_t)0x22f1, (q15_t)0x84dd, (q15_t)0x22eb, (q15_t)0x84db, - (q15_t)0x22e5, (q15_t)0x84da, (q15_t)0x22df, (q15_t)0x84d8, (q15_t)0x22d9, (q15_t)0x84d6, (q15_t)0x22d3, (q15_t)0x84d5, - (q15_t)0x22cd, (q15_t)0x84d3, (q15_t)0x22c7, (q15_t)0x84d1, (q15_t)0x22c0, (q15_t)0x84cf, (q15_t)0x22ba, (q15_t)0x84ce, - (q15_t)0x22b4, (q15_t)0x84cc, (q15_t)0x22ae, (q15_t)0x84ca, (q15_t)0x22a8, (q15_t)0x84c9, (q15_t)0x22a2, (q15_t)0x84c7, - (q15_t)0x229c, (q15_t)0x84c5, (q15_t)0x2296, (q15_t)0x84c4, (q15_t)0x2290, (q15_t)0x84c2, (q15_t)0x228a, (q15_t)0x84c0, - (q15_t)0x2284, (q15_t)0x84be, (q15_t)0x227e, (q15_t)0x84bd, (q15_t)0x2278, (q15_t)0x84bb, (q15_t)0x2272, (q15_t)0x84b9, - (q15_t)0x226c, (q15_t)0x84b8, (q15_t)0x2266, (q15_t)0x84b6, (q15_t)0x2260, (q15_t)0x84b4, (q15_t)0x225a, (q15_t)0x84b3, - (q15_t)0x2254, (q15_t)0x84b1, (q15_t)0x224e, (q15_t)0x84af, (q15_t)0x2247, (q15_t)0x84ae, (q15_t)0x2241, (q15_t)0x84ac, - (q15_t)0x223b, (q15_t)0x84aa, (q15_t)0x2235, (q15_t)0x84a9, (q15_t)0x222f, (q15_t)0x84a7, (q15_t)0x2229, (q15_t)0x84a5, - (q15_t)0x2223, (q15_t)0x84a3, (q15_t)0x221d, (q15_t)0x84a2, (q15_t)0x2217, (q15_t)0x84a0, (q15_t)0x2211, (q15_t)0x849e, - (q15_t)0x220b, (q15_t)0x849d, (q15_t)0x2205, (q15_t)0x849b, (q15_t)0x21ff, (q15_t)0x8499, (q15_t)0x21f9, (q15_t)0x8498, - (q15_t)0x21f3, (q15_t)0x8496, (q15_t)0x21ed, (q15_t)0x8494, (q15_t)0x21e7, (q15_t)0x8493, (q15_t)0x21e1, (q15_t)0x8491, - (q15_t)0x21da, (q15_t)0x848f, (q15_t)0x21d4, (q15_t)0x848e, (q15_t)0x21ce, (q15_t)0x848c, (q15_t)0x21c8, (q15_t)0x848a, - (q15_t)0x21c2, (q15_t)0x8489, (q15_t)0x21bc, (q15_t)0x8487, (q15_t)0x21b6, (q15_t)0x8486, (q15_t)0x21b0, (q15_t)0x8484, - (q15_t)0x21aa, (q15_t)0x8482, (q15_t)0x21a4, (q15_t)0x8481, (q15_t)0x219e, (q15_t)0x847f, (q15_t)0x2198, (q15_t)0x847d, - (q15_t)0x2192, (q15_t)0x847c, (q15_t)0x218c, (q15_t)0x847a, (q15_t)0x2186, (q15_t)0x8478, (q15_t)0x2180, (q15_t)0x8477, - (q15_t)0x2179, (q15_t)0x8475, (q15_t)0x2173, (q15_t)0x8473, (q15_t)0x216d, (q15_t)0x8472, (q15_t)0x2167, (q15_t)0x8470, - (q15_t)0x2161, (q15_t)0x846e, (q15_t)0x215b, (q15_t)0x846d, (q15_t)0x2155, (q15_t)0x846b, (q15_t)0x214f, (q15_t)0x846a, - (q15_t)0x2149, (q15_t)0x8468, (q15_t)0x2143, (q15_t)0x8466, (q15_t)0x213d, (q15_t)0x8465, (q15_t)0x2137, (q15_t)0x8463, - (q15_t)0x2131, (q15_t)0x8461, (q15_t)0x212b, (q15_t)0x8460, (q15_t)0x2125, (q15_t)0x845e, (q15_t)0x211e, (q15_t)0x845d, - (q15_t)0x2118, (q15_t)0x845b, (q15_t)0x2112, (q15_t)0x8459, (q15_t)0x210c, (q15_t)0x8458, (q15_t)0x2106, (q15_t)0x8456, - (q15_t)0x2100, (q15_t)0x8454, (q15_t)0x20fa, (q15_t)0x8453, (q15_t)0x20f4, (q15_t)0x8451, (q15_t)0x20ee, (q15_t)0x8450, - (q15_t)0x20e8, (q15_t)0x844e, (q15_t)0x20e2, (q15_t)0x844c, (q15_t)0x20dc, (q15_t)0x844b, (q15_t)0x20d6, (q15_t)0x8449, - (q15_t)0x20d0, (q15_t)0x8447, (q15_t)0x20c9, (q15_t)0x8446, (q15_t)0x20c3, (q15_t)0x8444, (q15_t)0x20bd, (q15_t)0x8443, - (q15_t)0x20b7, (q15_t)0x8441, (q15_t)0x20b1, (q15_t)0x843f, (q15_t)0x20ab, (q15_t)0x843e, (q15_t)0x20a5, (q15_t)0x843c, - (q15_t)0x209f, (q15_t)0x843b, (q15_t)0x2099, (q15_t)0x8439, (q15_t)0x2093, (q15_t)0x8437, (q15_t)0x208d, (q15_t)0x8436, - (q15_t)0x2087, (q15_t)0x8434, (q15_t)0x2081, (q15_t)0x8433, (q15_t)0x207a, (q15_t)0x8431, (q15_t)0x2074, (q15_t)0x842f, - (q15_t)0x206e, (q15_t)0x842e, (q15_t)0x2068, (q15_t)0x842c, (q15_t)0x2062, (q15_t)0x842b, (q15_t)0x205c, (q15_t)0x8429, - (q15_t)0x2056, (q15_t)0x8427, (q15_t)0x2050, (q15_t)0x8426, (q15_t)0x204a, (q15_t)0x8424, (q15_t)0x2044, (q15_t)0x8423, - (q15_t)0x203e, (q15_t)0x8421, (q15_t)0x2038, (q15_t)0x8420, (q15_t)0x2032, (q15_t)0x841e, (q15_t)0x202b, (q15_t)0x841c, - (q15_t)0x2025, (q15_t)0x841b, (q15_t)0x201f, (q15_t)0x8419, (q15_t)0x2019, (q15_t)0x8418, (q15_t)0x2013, (q15_t)0x8416, - (q15_t)0x200d, (q15_t)0x8415, (q15_t)0x2007, (q15_t)0x8413, (q15_t)0x2001, (q15_t)0x8411, (q15_t)0x1ffb, (q15_t)0x8410, - (q15_t)0x1ff5, (q15_t)0x840e, (q15_t)0x1fef, (q15_t)0x840d, (q15_t)0x1fe9, (q15_t)0x840b, (q15_t)0x1fe2, (q15_t)0x840a, - (q15_t)0x1fdc, (q15_t)0x8408, (q15_t)0x1fd6, (q15_t)0x8406, (q15_t)0x1fd0, (q15_t)0x8405, (q15_t)0x1fca, (q15_t)0x8403, - (q15_t)0x1fc4, (q15_t)0x8402, (q15_t)0x1fbe, (q15_t)0x8400, (q15_t)0x1fb8, (q15_t)0x83ff, (q15_t)0x1fb2, (q15_t)0x83fd, - (q15_t)0x1fac, (q15_t)0x83fb, (q15_t)0x1fa6, (q15_t)0x83fa, (q15_t)0x1f9f, (q15_t)0x83f8, (q15_t)0x1f99, (q15_t)0x83f7, - (q15_t)0x1f93, (q15_t)0x83f5, (q15_t)0x1f8d, (q15_t)0x83f4, (q15_t)0x1f87, (q15_t)0x83f2, (q15_t)0x1f81, (q15_t)0x83f1, - (q15_t)0x1f7b, (q15_t)0x83ef, (q15_t)0x1f75, (q15_t)0x83ee, (q15_t)0x1f6f, (q15_t)0x83ec, (q15_t)0x1f69, (q15_t)0x83ea, - (q15_t)0x1f63, (q15_t)0x83e9, (q15_t)0x1f5d, (q15_t)0x83e7, (q15_t)0x1f56, (q15_t)0x83e6, (q15_t)0x1f50, (q15_t)0x83e4, - (q15_t)0x1f4a, (q15_t)0x83e3, (q15_t)0x1f44, (q15_t)0x83e1, (q15_t)0x1f3e, (q15_t)0x83e0, (q15_t)0x1f38, (q15_t)0x83de, - (q15_t)0x1f32, (q15_t)0x83dd, (q15_t)0x1f2c, (q15_t)0x83db, (q15_t)0x1f26, (q15_t)0x83da, (q15_t)0x1f20, (q15_t)0x83d8, - (q15_t)0x1f19, (q15_t)0x83d7, (q15_t)0x1f13, (q15_t)0x83d5, (q15_t)0x1f0d, (q15_t)0x83d3, (q15_t)0x1f07, (q15_t)0x83d2, - (q15_t)0x1f01, (q15_t)0x83d0, (q15_t)0x1efb, (q15_t)0x83cf, (q15_t)0x1ef5, (q15_t)0x83cd, (q15_t)0x1eef, (q15_t)0x83cc, - (q15_t)0x1ee9, (q15_t)0x83ca, (q15_t)0x1ee3, (q15_t)0x83c9, (q15_t)0x1edd, (q15_t)0x83c7, (q15_t)0x1ed6, (q15_t)0x83c6, - (q15_t)0x1ed0, (q15_t)0x83c4, (q15_t)0x1eca, (q15_t)0x83c3, (q15_t)0x1ec4, (q15_t)0x83c1, (q15_t)0x1ebe, (q15_t)0x83c0, - (q15_t)0x1eb8, (q15_t)0x83be, (q15_t)0x1eb2, (q15_t)0x83bd, (q15_t)0x1eac, (q15_t)0x83bb, (q15_t)0x1ea6, (q15_t)0x83ba, - (q15_t)0x1ea0, (q15_t)0x83b8, (q15_t)0x1e99, (q15_t)0x83b7, (q15_t)0x1e93, (q15_t)0x83b5, (q15_t)0x1e8d, (q15_t)0x83b4, - (q15_t)0x1e87, (q15_t)0x83b2, (q15_t)0x1e81, (q15_t)0x83b1, (q15_t)0x1e7b, (q15_t)0x83af, (q15_t)0x1e75, (q15_t)0x83ae, - (q15_t)0x1e6f, (q15_t)0x83ac, (q15_t)0x1e69, (q15_t)0x83ab, (q15_t)0x1e62, (q15_t)0x83a9, (q15_t)0x1e5c, (q15_t)0x83a8, - (q15_t)0x1e56, (q15_t)0x83a6, (q15_t)0x1e50, (q15_t)0x83a5, (q15_t)0x1e4a, (q15_t)0x83a3, (q15_t)0x1e44, (q15_t)0x83a2, - (q15_t)0x1e3e, (q15_t)0x83a0, (q15_t)0x1e38, (q15_t)0x839f, (q15_t)0x1e32, (q15_t)0x839d, (q15_t)0x1e2c, (q15_t)0x839c, - (q15_t)0x1e25, (q15_t)0x839a, (q15_t)0x1e1f, (q15_t)0x8399, (q15_t)0x1e19, (q15_t)0x8397, (q15_t)0x1e13, (q15_t)0x8396, - (q15_t)0x1e0d, (q15_t)0x8394, (q15_t)0x1e07, (q15_t)0x8393, (q15_t)0x1e01, (q15_t)0x8392, (q15_t)0x1dfb, (q15_t)0x8390, - (q15_t)0x1df5, (q15_t)0x838f, (q15_t)0x1dee, (q15_t)0x838d, (q15_t)0x1de8, (q15_t)0x838c, (q15_t)0x1de2, (q15_t)0x838a, - (q15_t)0x1ddc, (q15_t)0x8389, (q15_t)0x1dd6, (q15_t)0x8387, (q15_t)0x1dd0, (q15_t)0x8386, (q15_t)0x1dca, (q15_t)0x8384, - (q15_t)0x1dc4, (q15_t)0x8383, (q15_t)0x1dbe, (q15_t)0x8381, (q15_t)0x1db7, (q15_t)0x8380, (q15_t)0x1db1, (q15_t)0x837e, - (q15_t)0x1dab, (q15_t)0x837d, (q15_t)0x1da5, (q15_t)0x837c, (q15_t)0x1d9f, (q15_t)0x837a, (q15_t)0x1d99, (q15_t)0x8379, - (q15_t)0x1d93, (q15_t)0x8377, (q15_t)0x1d8d, (q15_t)0x8376, (q15_t)0x1d87, (q15_t)0x8374, (q15_t)0x1d80, (q15_t)0x8373, - (q15_t)0x1d7a, (q15_t)0x8371, (q15_t)0x1d74, (q15_t)0x8370, (q15_t)0x1d6e, (q15_t)0x836f, (q15_t)0x1d68, (q15_t)0x836d, - (q15_t)0x1d62, (q15_t)0x836c, (q15_t)0x1d5c, (q15_t)0x836a, (q15_t)0x1d56, (q15_t)0x8369, (q15_t)0x1d50, (q15_t)0x8367, - (q15_t)0x1d49, (q15_t)0x8366, (q15_t)0x1d43, (q15_t)0x8364, (q15_t)0x1d3d, (q15_t)0x8363, (q15_t)0x1d37, (q15_t)0x8362, - (q15_t)0x1d31, (q15_t)0x8360, (q15_t)0x1d2b, (q15_t)0x835f, (q15_t)0x1d25, (q15_t)0x835d, (q15_t)0x1d1f, (q15_t)0x835c, - (q15_t)0x1d18, (q15_t)0x835a, (q15_t)0x1d12, (q15_t)0x8359, (q15_t)0x1d0c, (q15_t)0x8358, (q15_t)0x1d06, (q15_t)0x8356, - (q15_t)0x1d00, (q15_t)0x8355, (q15_t)0x1cfa, (q15_t)0x8353, (q15_t)0x1cf4, (q15_t)0x8352, (q15_t)0x1cee, (q15_t)0x8350, - (q15_t)0x1ce8, (q15_t)0x834f, (q15_t)0x1ce1, (q15_t)0x834e, (q15_t)0x1cdb, (q15_t)0x834c, (q15_t)0x1cd5, (q15_t)0x834b, - (q15_t)0x1ccf, (q15_t)0x8349, (q15_t)0x1cc9, (q15_t)0x8348, (q15_t)0x1cc3, (q15_t)0x8347, (q15_t)0x1cbd, (q15_t)0x8345, - (q15_t)0x1cb7, (q15_t)0x8344, (q15_t)0x1cb0, (q15_t)0x8342, (q15_t)0x1caa, (q15_t)0x8341, (q15_t)0x1ca4, (q15_t)0x833f, - (q15_t)0x1c9e, (q15_t)0x833e, (q15_t)0x1c98, (q15_t)0x833d, (q15_t)0x1c92, (q15_t)0x833b, (q15_t)0x1c8c, (q15_t)0x833a, - (q15_t)0x1c86, (q15_t)0x8338, (q15_t)0x1c7f, (q15_t)0x8337, (q15_t)0x1c79, (q15_t)0x8336, (q15_t)0x1c73, (q15_t)0x8334, - (q15_t)0x1c6d, (q15_t)0x8333, (q15_t)0x1c67, (q15_t)0x8331, (q15_t)0x1c61, (q15_t)0x8330, (q15_t)0x1c5b, (q15_t)0x832f, - (q15_t)0x1c55, (q15_t)0x832d, (q15_t)0x1c4e, (q15_t)0x832c, (q15_t)0x1c48, (q15_t)0x832b, (q15_t)0x1c42, (q15_t)0x8329, - (q15_t)0x1c3c, (q15_t)0x8328, (q15_t)0x1c36, (q15_t)0x8326, (q15_t)0x1c30, (q15_t)0x8325, (q15_t)0x1c2a, (q15_t)0x8324, - (q15_t)0x1c24, (q15_t)0x8322, (q15_t)0x1c1d, (q15_t)0x8321, (q15_t)0x1c17, (q15_t)0x831f, (q15_t)0x1c11, (q15_t)0x831e, - (q15_t)0x1c0b, (q15_t)0x831d, (q15_t)0x1c05, (q15_t)0x831b, (q15_t)0x1bff, (q15_t)0x831a, (q15_t)0x1bf9, (q15_t)0x8319, - (q15_t)0x1bf2, (q15_t)0x8317, (q15_t)0x1bec, (q15_t)0x8316, (q15_t)0x1be6, (q15_t)0x8314, (q15_t)0x1be0, (q15_t)0x8313, - (q15_t)0x1bda, (q15_t)0x8312, (q15_t)0x1bd4, (q15_t)0x8310, (q15_t)0x1bce, (q15_t)0x830f, (q15_t)0x1bc8, (q15_t)0x830e, - (q15_t)0x1bc1, (q15_t)0x830c, (q15_t)0x1bbb, (q15_t)0x830b, (q15_t)0x1bb5, (q15_t)0x830a, (q15_t)0x1baf, (q15_t)0x8308, - (q15_t)0x1ba9, (q15_t)0x8307, (q15_t)0x1ba3, (q15_t)0x8305, (q15_t)0x1b9d, (q15_t)0x8304, (q15_t)0x1b96, (q15_t)0x8303, - (q15_t)0x1b90, (q15_t)0x8301, (q15_t)0x1b8a, (q15_t)0x8300, (q15_t)0x1b84, (q15_t)0x82ff, (q15_t)0x1b7e, (q15_t)0x82fd, - (q15_t)0x1b78, (q15_t)0x82fc, (q15_t)0x1b72, (q15_t)0x82fb, (q15_t)0x1b6c, (q15_t)0x82f9, (q15_t)0x1b65, (q15_t)0x82f8, - (q15_t)0x1b5f, (q15_t)0x82f7, (q15_t)0x1b59, (q15_t)0x82f5, (q15_t)0x1b53, (q15_t)0x82f4, (q15_t)0x1b4d, (q15_t)0x82f3, - (q15_t)0x1b47, (q15_t)0x82f1, (q15_t)0x1b41, (q15_t)0x82f0, (q15_t)0x1b3a, (q15_t)0x82ef, (q15_t)0x1b34, (q15_t)0x82ed, - (q15_t)0x1b2e, (q15_t)0x82ec, (q15_t)0x1b28, (q15_t)0x82eb, (q15_t)0x1b22, (q15_t)0x82e9, (q15_t)0x1b1c, (q15_t)0x82e8, - (q15_t)0x1b16, (q15_t)0x82e7, (q15_t)0x1b0f, (q15_t)0x82e5, (q15_t)0x1b09, (q15_t)0x82e4, (q15_t)0x1b03, (q15_t)0x82e3, - (q15_t)0x1afd, (q15_t)0x82e1, (q15_t)0x1af7, (q15_t)0x82e0, (q15_t)0x1af1, (q15_t)0x82df, (q15_t)0x1aeb, (q15_t)0x82dd, - (q15_t)0x1ae4, (q15_t)0x82dc, (q15_t)0x1ade, (q15_t)0x82db, (q15_t)0x1ad8, (q15_t)0x82d9, (q15_t)0x1ad2, (q15_t)0x82d8, - (q15_t)0x1acc, (q15_t)0x82d7, (q15_t)0x1ac6, (q15_t)0x82d5, (q15_t)0x1ac0, (q15_t)0x82d4, (q15_t)0x1ab9, (q15_t)0x82d3, - (q15_t)0x1ab3, (q15_t)0x82d1, (q15_t)0x1aad, (q15_t)0x82d0, (q15_t)0x1aa7, (q15_t)0x82cf, (q15_t)0x1aa1, (q15_t)0x82ce, - (q15_t)0x1a9b, (q15_t)0x82cc, (q15_t)0x1a95, (q15_t)0x82cb, (q15_t)0x1a8e, (q15_t)0x82ca, (q15_t)0x1a88, (q15_t)0x82c8, - (q15_t)0x1a82, (q15_t)0x82c7, (q15_t)0x1a7c, (q15_t)0x82c6, (q15_t)0x1a76, (q15_t)0x82c4, (q15_t)0x1a70, (q15_t)0x82c3, - (q15_t)0x1a6a, (q15_t)0x82c2, (q15_t)0x1a63, (q15_t)0x82c1, (q15_t)0x1a5d, (q15_t)0x82bf, (q15_t)0x1a57, (q15_t)0x82be, - (q15_t)0x1a51, (q15_t)0x82bd, (q15_t)0x1a4b, (q15_t)0x82bb, (q15_t)0x1a45, (q15_t)0x82ba, (q15_t)0x1a3e, (q15_t)0x82b9, - (q15_t)0x1a38, (q15_t)0x82b7, (q15_t)0x1a32, (q15_t)0x82b6, (q15_t)0x1a2c, (q15_t)0x82b5, (q15_t)0x1a26, (q15_t)0x82b4, - (q15_t)0x1a20, (q15_t)0x82b2, (q15_t)0x1a1a, (q15_t)0x82b1, (q15_t)0x1a13, (q15_t)0x82b0, (q15_t)0x1a0d, (q15_t)0x82ae, - (q15_t)0x1a07, (q15_t)0x82ad, (q15_t)0x1a01, (q15_t)0x82ac, (q15_t)0x19fb, (q15_t)0x82ab, (q15_t)0x19f5, (q15_t)0x82a9, - (q15_t)0x19ef, (q15_t)0x82a8, (q15_t)0x19e8, (q15_t)0x82a7, (q15_t)0x19e2, (q15_t)0x82a6, (q15_t)0x19dc, (q15_t)0x82a4, - (q15_t)0x19d6, (q15_t)0x82a3, (q15_t)0x19d0, (q15_t)0x82a2, (q15_t)0x19ca, (q15_t)0x82a0, (q15_t)0x19c3, (q15_t)0x829f, - (q15_t)0x19bd, (q15_t)0x829e, (q15_t)0x19b7, (q15_t)0x829d, (q15_t)0x19b1, (q15_t)0x829b, (q15_t)0x19ab, (q15_t)0x829a, - (q15_t)0x19a5, (q15_t)0x8299, (q15_t)0x199f, (q15_t)0x8298, (q15_t)0x1998, (q15_t)0x8296, (q15_t)0x1992, (q15_t)0x8295, - (q15_t)0x198c, (q15_t)0x8294, (q15_t)0x1986, (q15_t)0x8293, (q15_t)0x1980, (q15_t)0x8291, (q15_t)0x197a, (q15_t)0x8290, - (q15_t)0x1973, (q15_t)0x828f, (q15_t)0x196d, (q15_t)0x828e, (q15_t)0x1967, (q15_t)0x828c, (q15_t)0x1961, (q15_t)0x828b, - (q15_t)0x195b, (q15_t)0x828a, (q15_t)0x1955, (q15_t)0x8289, (q15_t)0x194e, (q15_t)0x8287, (q15_t)0x1948, (q15_t)0x8286, - (q15_t)0x1942, (q15_t)0x8285, (q15_t)0x193c, (q15_t)0x8284, (q15_t)0x1936, (q15_t)0x8282, (q15_t)0x1930, (q15_t)0x8281, - (q15_t)0x192a, (q15_t)0x8280, (q15_t)0x1923, (q15_t)0x827f, (q15_t)0x191d, (q15_t)0x827e, (q15_t)0x1917, (q15_t)0x827c, - (q15_t)0x1911, (q15_t)0x827b, (q15_t)0x190b, (q15_t)0x827a, (q15_t)0x1905, (q15_t)0x8279, (q15_t)0x18fe, (q15_t)0x8277, - (q15_t)0x18f8, (q15_t)0x8276, (q15_t)0x18f2, (q15_t)0x8275, (q15_t)0x18ec, (q15_t)0x8274, (q15_t)0x18e6, (q15_t)0x8272, - (q15_t)0x18e0, (q15_t)0x8271, (q15_t)0x18d9, (q15_t)0x8270, (q15_t)0x18d3, (q15_t)0x826f, (q15_t)0x18cd, (q15_t)0x826e, - (q15_t)0x18c7, (q15_t)0x826c, (q15_t)0x18c1, (q15_t)0x826b, (q15_t)0x18bb, (q15_t)0x826a, (q15_t)0x18b4, (q15_t)0x8269, - (q15_t)0x18ae, (q15_t)0x8268, (q15_t)0x18a8, (q15_t)0x8266, (q15_t)0x18a2, (q15_t)0x8265, (q15_t)0x189c, (q15_t)0x8264, - (q15_t)0x1896, (q15_t)0x8263, (q15_t)0x188f, (q15_t)0x8261, (q15_t)0x1889, (q15_t)0x8260, (q15_t)0x1883, (q15_t)0x825f, - (q15_t)0x187d, (q15_t)0x825e, (q15_t)0x1877, (q15_t)0x825d, (q15_t)0x1871, (q15_t)0x825b, (q15_t)0x186a, (q15_t)0x825a, - (q15_t)0x1864, (q15_t)0x8259, (q15_t)0x185e, (q15_t)0x8258, (q15_t)0x1858, (q15_t)0x8257, (q15_t)0x1852, (q15_t)0x8255, - (q15_t)0x184c, (q15_t)0x8254, (q15_t)0x1845, (q15_t)0x8253, (q15_t)0x183f, (q15_t)0x8252, (q15_t)0x1839, (q15_t)0x8251, - (q15_t)0x1833, (q15_t)0x8250, (q15_t)0x182d, (q15_t)0x824e, (q15_t)0x1827, (q15_t)0x824d, (q15_t)0x1820, (q15_t)0x824c, - (q15_t)0x181a, (q15_t)0x824b, (q15_t)0x1814, (q15_t)0x824a, (q15_t)0x180e, (q15_t)0x8248, (q15_t)0x1808, (q15_t)0x8247, - (q15_t)0x1802, (q15_t)0x8246, (q15_t)0x17fb, (q15_t)0x8245, (q15_t)0x17f5, (q15_t)0x8244, (q15_t)0x17ef, (q15_t)0x8243, - (q15_t)0x17e9, (q15_t)0x8241, (q15_t)0x17e3, (q15_t)0x8240, (q15_t)0x17dd, (q15_t)0x823f, (q15_t)0x17d6, (q15_t)0x823e, - (q15_t)0x17d0, (q15_t)0x823d, (q15_t)0x17ca, (q15_t)0x823b, (q15_t)0x17c4, (q15_t)0x823a, (q15_t)0x17be, (q15_t)0x8239, - (q15_t)0x17b7, (q15_t)0x8238, (q15_t)0x17b1, (q15_t)0x8237, (q15_t)0x17ab, (q15_t)0x8236, (q15_t)0x17a5, (q15_t)0x8234, - (q15_t)0x179f, (q15_t)0x8233, (q15_t)0x1799, (q15_t)0x8232, (q15_t)0x1792, (q15_t)0x8231, (q15_t)0x178c, (q15_t)0x8230, - (q15_t)0x1786, (q15_t)0x822f, (q15_t)0x1780, (q15_t)0x822e, (q15_t)0x177a, (q15_t)0x822c, (q15_t)0x1774, (q15_t)0x822b, - (q15_t)0x176d, (q15_t)0x822a, (q15_t)0x1767, (q15_t)0x8229, (q15_t)0x1761, (q15_t)0x8228, (q15_t)0x175b, (q15_t)0x8227, - (q15_t)0x1755, (q15_t)0x8226, (q15_t)0x174e, (q15_t)0x8224, (q15_t)0x1748, (q15_t)0x8223, (q15_t)0x1742, (q15_t)0x8222, - (q15_t)0x173c, (q15_t)0x8221, (q15_t)0x1736, (q15_t)0x8220, (q15_t)0x1730, (q15_t)0x821f, (q15_t)0x1729, (q15_t)0x821e, - (q15_t)0x1723, (q15_t)0x821c, (q15_t)0x171d, (q15_t)0x821b, (q15_t)0x1717, (q15_t)0x821a, (q15_t)0x1711, (q15_t)0x8219, - (q15_t)0x170a, (q15_t)0x8218, (q15_t)0x1704, (q15_t)0x8217, (q15_t)0x16fe, (q15_t)0x8216, (q15_t)0x16f8, (q15_t)0x8214, - (q15_t)0x16f2, (q15_t)0x8213, (q15_t)0x16ec, (q15_t)0x8212, (q15_t)0x16e5, (q15_t)0x8211, (q15_t)0x16df, (q15_t)0x8210, - (q15_t)0x16d9, (q15_t)0x820f, (q15_t)0x16d3, (q15_t)0x820e, (q15_t)0x16cd, (q15_t)0x820d, (q15_t)0x16c6, (q15_t)0x820b, - (q15_t)0x16c0, (q15_t)0x820a, (q15_t)0x16ba, (q15_t)0x8209, (q15_t)0x16b4, (q15_t)0x8208, (q15_t)0x16ae, (q15_t)0x8207, - (q15_t)0x16a8, (q15_t)0x8206, (q15_t)0x16a1, (q15_t)0x8205, (q15_t)0x169b, (q15_t)0x8204, (q15_t)0x1695, (q15_t)0x8203, - (q15_t)0x168f, (q15_t)0x8201, (q15_t)0x1689, (q15_t)0x8200, (q15_t)0x1682, (q15_t)0x81ff, (q15_t)0x167c, (q15_t)0x81fe, - (q15_t)0x1676, (q15_t)0x81fd, (q15_t)0x1670, (q15_t)0x81fc, (q15_t)0x166a, (q15_t)0x81fb, (q15_t)0x1664, (q15_t)0x81fa, - (q15_t)0x165d, (q15_t)0x81f9, (q15_t)0x1657, (q15_t)0x81f8, (q15_t)0x1651, (q15_t)0x81f6, (q15_t)0x164b, (q15_t)0x81f5, - (q15_t)0x1645, (q15_t)0x81f4, (q15_t)0x163e, (q15_t)0x81f3, (q15_t)0x1638, (q15_t)0x81f2, (q15_t)0x1632, (q15_t)0x81f1, - (q15_t)0x162c, (q15_t)0x81f0, (q15_t)0x1626, (q15_t)0x81ef, (q15_t)0x161f, (q15_t)0x81ee, (q15_t)0x1619, (q15_t)0x81ed, - (q15_t)0x1613, (q15_t)0x81ec, (q15_t)0x160d, (q15_t)0x81ea, (q15_t)0x1607, (q15_t)0x81e9, (q15_t)0x1601, (q15_t)0x81e8, - (q15_t)0x15fa, (q15_t)0x81e7, (q15_t)0x15f4, (q15_t)0x81e6, (q15_t)0x15ee, (q15_t)0x81e5, (q15_t)0x15e8, (q15_t)0x81e4, - (q15_t)0x15e2, (q15_t)0x81e3, (q15_t)0x15db, (q15_t)0x81e2, (q15_t)0x15d5, (q15_t)0x81e1, (q15_t)0x15cf, (q15_t)0x81e0, - (q15_t)0x15c9, (q15_t)0x81df, (q15_t)0x15c3, (q15_t)0x81de, (q15_t)0x15bc, (q15_t)0x81dc, (q15_t)0x15b6, (q15_t)0x81db, - (q15_t)0x15b0, (q15_t)0x81da, (q15_t)0x15aa, (q15_t)0x81d9, (q15_t)0x15a4, (q15_t)0x81d8, (q15_t)0x159d, (q15_t)0x81d7, - (q15_t)0x1597, (q15_t)0x81d6, (q15_t)0x1591, (q15_t)0x81d5, (q15_t)0x158b, (q15_t)0x81d4, (q15_t)0x1585, (q15_t)0x81d3, - (q15_t)0x157f, (q15_t)0x81d2, (q15_t)0x1578, (q15_t)0x81d1, (q15_t)0x1572, (q15_t)0x81d0, (q15_t)0x156c, (q15_t)0x81cf, - (q15_t)0x1566, (q15_t)0x81ce, (q15_t)0x1560, (q15_t)0x81cd, (q15_t)0x1559, (q15_t)0x81cc, (q15_t)0x1553, (q15_t)0x81cb, - (q15_t)0x154d, (q15_t)0x81c9, (q15_t)0x1547, (q15_t)0x81c8, (q15_t)0x1541, (q15_t)0x81c7, (q15_t)0x153a, (q15_t)0x81c6, - (q15_t)0x1534, (q15_t)0x81c5, (q15_t)0x152e, (q15_t)0x81c4, (q15_t)0x1528, (q15_t)0x81c3, (q15_t)0x1522, (q15_t)0x81c2, - (q15_t)0x151b, (q15_t)0x81c1, (q15_t)0x1515, (q15_t)0x81c0, (q15_t)0x150f, (q15_t)0x81bf, (q15_t)0x1509, (q15_t)0x81be, - (q15_t)0x1503, (q15_t)0x81bd, (q15_t)0x14fc, (q15_t)0x81bc, (q15_t)0x14f6, (q15_t)0x81bb, (q15_t)0x14f0, (q15_t)0x81ba, - (q15_t)0x14ea, (q15_t)0x81b9, (q15_t)0x14e4, (q15_t)0x81b8, (q15_t)0x14dd, (q15_t)0x81b7, (q15_t)0x14d7, (q15_t)0x81b6, - (q15_t)0x14d1, (q15_t)0x81b5, (q15_t)0x14cb, (q15_t)0x81b4, (q15_t)0x14c5, (q15_t)0x81b3, (q15_t)0x14be, (q15_t)0x81b2, - (q15_t)0x14b8, (q15_t)0x81b1, (q15_t)0x14b2, (q15_t)0x81b0, (q15_t)0x14ac, (q15_t)0x81af, (q15_t)0x14a6, (q15_t)0x81ae, - (q15_t)0x149f, (q15_t)0x81ad, (q15_t)0x1499, (q15_t)0x81ac, (q15_t)0x1493, (q15_t)0x81ab, (q15_t)0x148d, (q15_t)0x81aa, - (q15_t)0x1487, (q15_t)0x81a9, (q15_t)0x1480, (q15_t)0x81a8, (q15_t)0x147a, (q15_t)0x81a7, (q15_t)0x1474, (q15_t)0x81a6, - (q15_t)0x146e, (q15_t)0x81a5, (q15_t)0x1468, (q15_t)0x81a4, (q15_t)0x1461, (q15_t)0x81a3, (q15_t)0x145b, (q15_t)0x81a2, - (q15_t)0x1455, (q15_t)0x81a1, (q15_t)0x144f, (q15_t)0x81a0, (q15_t)0x1449, (q15_t)0x819f, (q15_t)0x1442, (q15_t)0x819e, - (q15_t)0x143c, (q15_t)0x819d, (q15_t)0x1436, (q15_t)0x819c, (q15_t)0x1430, (q15_t)0x819b, (q15_t)0x142a, (q15_t)0x819a, - (q15_t)0x1423, (q15_t)0x8199, (q15_t)0x141d, (q15_t)0x8198, (q15_t)0x1417, (q15_t)0x8197, (q15_t)0x1411, (q15_t)0x8196, - (q15_t)0x140b, (q15_t)0x8195, (q15_t)0x1404, (q15_t)0x8194, (q15_t)0x13fe, (q15_t)0x8193, (q15_t)0x13f8, (q15_t)0x8192, - (q15_t)0x13f2, (q15_t)0x8191, (q15_t)0x13eb, (q15_t)0x8190, (q15_t)0x13e5, (q15_t)0x818f, (q15_t)0x13df, (q15_t)0x818e, - (q15_t)0x13d9, (q15_t)0x818d, (q15_t)0x13d3, (q15_t)0x818c, (q15_t)0x13cc, (q15_t)0x818b, (q15_t)0x13c6, (q15_t)0x818a, - (q15_t)0x13c0, (q15_t)0x8189, (q15_t)0x13ba, (q15_t)0x8188, (q15_t)0x13b4, (q15_t)0x8187, (q15_t)0x13ad, (q15_t)0x8186, - (q15_t)0x13a7, (q15_t)0x8185, (q15_t)0x13a1, (q15_t)0x8184, (q15_t)0x139b, (q15_t)0x8183, (q15_t)0x1395, (q15_t)0x8182, - (q15_t)0x138e, (q15_t)0x8181, (q15_t)0x1388, (q15_t)0x8180, (q15_t)0x1382, (q15_t)0x817f, (q15_t)0x137c, (q15_t)0x817e, - (q15_t)0x1376, (q15_t)0x817d, (q15_t)0x136f, (q15_t)0x817c, (q15_t)0x1369, (q15_t)0x817c, (q15_t)0x1363, (q15_t)0x817b, - (q15_t)0x135d, (q15_t)0x817a, (q15_t)0x1356, (q15_t)0x8179, (q15_t)0x1350, (q15_t)0x8178, (q15_t)0x134a, (q15_t)0x8177, - (q15_t)0x1344, (q15_t)0x8176, (q15_t)0x133e, (q15_t)0x8175, (q15_t)0x1337, (q15_t)0x8174, (q15_t)0x1331, (q15_t)0x8173, - (q15_t)0x132b, (q15_t)0x8172, (q15_t)0x1325, (q15_t)0x8171, (q15_t)0x131f, (q15_t)0x8170, (q15_t)0x1318, (q15_t)0x816f, - (q15_t)0x1312, (q15_t)0x816e, (q15_t)0x130c, (q15_t)0x816d, (q15_t)0x1306, (q15_t)0x816c, (q15_t)0x12ff, (q15_t)0x816c, - (q15_t)0x12f9, (q15_t)0x816b, (q15_t)0x12f3, (q15_t)0x816a, (q15_t)0x12ed, (q15_t)0x8169, (q15_t)0x12e7, (q15_t)0x8168, - (q15_t)0x12e0, (q15_t)0x8167, (q15_t)0x12da, (q15_t)0x8166, (q15_t)0x12d4, (q15_t)0x8165, (q15_t)0x12ce, (q15_t)0x8164, - (q15_t)0x12c8, (q15_t)0x8163, (q15_t)0x12c1, (q15_t)0x8162, (q15_t)0x12bb, (q15_t)0x8161, (q15_t)0x12b5, (q15_t)0x8160, - (q15_t)0x12af, (q15_t)0x815f, (q15_t)0x12a8, (q15_t)0x815f, (q15_t)0x12a2, (q15_t)0x815e, (q15_t)0x129c, (q15_t)0x815d, - (q15_t)0x1296, (q15_t)0x815c, (q15_t)0x1290, (q15_t)0x815b, (q15_t)0x1289, (q15_t)0x815a, (q15_t)0x1283, (q15_t)0x8159, - (q15_t)0x127d, (q15_t)0x8158, (q15_t)0x1277, (q15_t)0x8157, (q15_t)0x1271, (q15_t)0x8156, (q15_t)0x126a, (q15_t)0x8155, - (q15_t)0x1264, (q15_t)0x8155, (q15_t)0x125e, (q15_t)0x8154, (q15_t)0x1258, (q15_t)0x8153, (q15_t)0x1251, (q15_t)0x8152, - (q15_t)0x124b, (q15_t)0x8151, (q15_t)0x1245, (q15_t)0x8150, (q15_t)0x123f, (q15_t)0x814f, (q15_t)0x1239, (q15_t)0x814e, - (q15_t)0x1232, (q15_t)0x814d, (q15_t)0x122c, (q15_t)0x814c, (q15_t)0x1226, (q15_t)0x814c, (q15_t)0x1220, (q15_t)0x814b, - (q15_t)0x1219, (q15_t)0x814a, (q15_t)0x1213, (q15_t)0x8149, (q15_t)0x120d, (q15_t)0x8148, (q15_t)0x1207, (q15_t)0x8147, - (q15_t)0x1201, (q15_t)0x8146, (q15_t)0x11fa, (q15_t)0x8145, (q15_t)0x11f4, (q15_t)0x8145, (q15_t)0x11ee, (q15_t)0x8144, - (q15_t)0x11e8, (q15_t)0x8143, (q15_t)0x11e1, (q15_t)0x8142, (q15_t)0x11db, (q15_t)0x8141, (q15_t)0x11d5, (q15_t)0x8140, - (q15_t)0x11cf, (q15_t)0x813f, (q15_t)0x11c9, (q15_t)0x813e, (q15_t)0x11c2, (q15_t)0x813d, (q15_t)0x11bc, (q15_t)0x813d, - (q15_t)0x11b6, (q15_t)0x813c, (q15_t)0x11b0, (q15_t)0x813b, (q15_t)0x11a9, (q15_t)0x813a, (q15_t)0x11a3, (q15_t)0x8139, - (q15_t)0x119d, (q15_t)0x8138, (q15_t)0x1197, (q15_t)0x8137, (q15_t)0x1191, (q15_t)0x8137, (q15_t)0x118a, (q15_t)0x8136, - (q15_t)0x1184, (q15_t)0x8135, (q15_t)0x117e, (q15_t)0x8134, (q15_t)0x1178, (q15_t)0x8133, (q15_t)0x1171, (q15_t)0x8132, - (q15_t)0x116b, (q15_t)0x8131, (q15_t)0x1165, (q15_t)0x8131, (q15_t)0x115f, (q15_t)0x8130, (q15_t)0x1159, (q15_t)0x812f, - (q15_t)0x1152, (q15_t)0x812e, (q15_t)0x114c, (q15_t)0x812d, (q15_t)0x1146, (q15_t)0x812c, (q15_t)0x1140, (q15_t)0x812b, - (q15_t)0x1139, (q15_t)0x812b, (q15_t)0x1133, (q15_t)0x812a, (q15_t)0x112d, (q15_t)0x8129, (q15_t)0x1127, (q15_t)0x8128, - (q15_t)0x1121, (q15_t)0x8127, (q15_t)0x111a, (q15_t)0x8126, (q15_t)0x1114, (q15_t)0x8126, (q15_t)0x110e, (q15_t)0x8125, - (q15_t)0x1108, (q15_t)0x8124, (q15_t)0x1101, (q15_t)0x8123, (q15_t)0x10fb, (q15_t)0x8122, (q15_t)0x10f5, (q15_t)0x8121, - (q15_t)0x10ef, (q15_t)0x8121, (q15_t)0x10e8, (q15_t)0x8120, (q15_t)0x10e2, (q15_t)0x811f, (q15_t)0x10dc, (q15_t)0x811e, - (q15_t)0x10d6, (q15_t)0x811d, (q15_t)0x10d0, (q15_t)0x811c, (q15_t)0x10c9, (q15_t)0x811c, (q15_t)0x10c3, (q15_t)0x811b, - (q15_t)0x10bd, (q15_t)0x811a, (q15_t)0x10b7, (q15_t)0x8119, (q15_t)0x10b0, (q15_t)0x8118, (q15_t)0x10aa, (q15_t)0x8117, - (q15_t)0x10a4, (q15_t)0x8117, (q15_t)0x109e, (q15_t)0x8116, (q15_t)0x1098, (q15_t)0x8115, (q15_t)0x1091, (q15_t)0x8114, - (q15_t)0x108b, (q15_t)0x8113, (q15_t)0x1085, (q15_t)0x8113, (q15_t)0x107f, (q15_t)0x8112, (q15_t)0x1078, (q15_t)0x8111, - (q15_t)0x1072, (q15_t)0x8110, (q15_t)0x106c, (q15_t)0x810f, (q15_t)0x1066, (q15_t)0x810f, (q15_t)0x105f, (q15_t)0x810e, - (q15_t)0x1059, (q15_t)0x810d, (q15_t)0x1053, (q15_t)0x810c, (q15_t)0x104d, (q15_t)0x810b, (q15_t)0x1047, (q15_t)0x810b, - (q15_t)0x1040, (q15_t)0x810a, (q15_t)0x103a, (q15_t)0x8109, (q15_t)0x1034, (q15_t)0x8108, (q15_t)0x102e, (q15_t)0x8107, - (q15_t)0x1027, (q15_t)0x8107, (q15_t)0x1021, (q15_t)0x8106, (q15_t)0x101b, (q15_t)0x8105, (q15_t)0x1015, (q15_t)0x8104, - (q15_t)0x100e, (q15_t)0x8103, (q15_t)0x1008, (q15_t)0x8103, (q15_t)0x1002, (q15_t)0x8102, (q15_t)0xffc, (q15_t)0x8101, - (q15_t)0xff5, (q15_t)0x8100, (q15_t)0xfef, (q15_t)0x80ff, (q15_t)0xfe9, (q15_t)0x80ff, (q15_t)0xfe3, (q15_t)0x80fe, - (q15_t)0xfdd, (q15_t)0x80fd, (q15_t)0xfd6, (q15_t)0x80fc, (q15_t)0xfd0, (q15_t)0x80fc, (q15_t)0xfca, (q15_t)0x80fb, - (q15_t)0xfc4, (q15_t)0x80fa, (q15_t)0xfbd, (q15_t)0x80f9, (q15_t)0xfb7, (q15_t)0x80f8, (q15_t)0xfb1, (q15_t)0x80f8, - (q15_t)0xfab, (q15_t)0x80f7, (q15_t)0xfa4, (q15_t)0x80f6, (q15_t)0xf9e, (q15_t)0x80f5, (q15_t)0xf98, (q15_t)0x80f5, - (q15_t)0xf92, (q15_t)0x80f4, (q15_t)0xf8b, (q15_t)0x80f3, (q15_t)0xf85, (q15_t)0x80f2, (q15_t)0xf7f, (q15_t)0x80f2, - (q15_t)0xf79, (q15_t)0x80f1, (q15_t)0xf73, (q15_t)0x80f0, (q15_t)0xf6c, (q15_t)0x80ef, (q15_t)0xf66, (q15_t)0x80ef, - (q15_t)0xf60, (q15_t)0x80ee, (q15_t)0xf5a, (q15_t)0x80ed, (q15_t)0xf53, (q15_t)0x80ec, (q15_t)0xf4d, (q15_t)0x80ec, - (q15_t)0xf47, (q15_t)0x80eb, (q15_t)0xf41, (q15_t)0x80ea, (q15_t)0xf3a, (q15_t)0x80e9, (q15_t)0xf34, (q15_t)0x80e9, - (q15_t)0xf2e, (q15_t)0x80e8, (q15_t)0xf28, (q15_t)0x80e7, (q15_t)0xf21, (q15_t)0x80e6, (q15_t)0xf1b, (q15_t)0x80e6, - (q15_t)0xf15, (q15_t)0x80e5, (q15_t)0xf0f, (q15_t)0x80e4, (q15_t)0xf08, (q15_t)0x80e3, (q15_t)0xf02, (q15_t)0x80e3, - (q15_t)0xefc, (q15_t)0x80e2, (q15_t)0xef6, (q15_t)0x80e1, (q15_t)0xef0, (q15_t)0x80e0, (q15_t)0xee9, (q15_t)0x80e0, - (q15_t)0xee3, (q15_t)0x80df, (q15_t)0xedd, (q15_t)0x80de, (q15_t)0xed7, (q15_t)0x80dd, (q15_t)0xed0, (q15_t)0x80dd, - (q15_t)0xeca, (q15_t)0x80dc, (q15_t)0xec4, (q15_t)0x80db, (q15_t)0xebe, (q15_t)0x80db, (q15_t)0xeb7, (q15_t)0x80da, - (q15_t)0xeb1, (q15_t)0x80d9, (q15_t)0xeab, (q15_t)0x80d8, (q15_t)0xea5, (q15_t)0x80d8, (q15_t)0xe9e, (q15_t)0x80d7, - (q15_t)0xe98, (q15_t)0x80d6, (q15_t)0xe92, (q15_t)0x80d6, (q15_t)0xe8c, (q15_t)0x80d5, (q15_t)0xe85, (q15_t)0x80d4, - (q15_t)0xe7f, (q15_t)0x80d3, (q15_t)0xe79, (q15_t)0x80d3, (q15_t)0xe73, (q15_t)0x80d2, (q15_t)0xe6c, (q15_t)0x80d1, - (q15_t)0xe66, (q15_t)0x80d1, (q15_t)0xe60, (q15_t)0x80d0, (q15_t)0xe5a, (q15_t)0x80cf, (q15_t)0xe53, (q15_t)0x80ce, - (q15_t)0xe4d, (q15_t)0x80ce, (q15_t)0xe47, (q15_t)0x80cd, (q15_t)0xe41, (q15_t)0x80cc, (q15_t)0xe3a, (q15_t)0x80cc, - (q15_t)0xe34, (q15_t)0x80cb, (q15_t)0xe2e, (q15_t)0x80ca, (q15_t)0xe28, (q15_t)0x80ca, (q15_t)0xe22, (q15_t)0x80c9, - (q15_t)0xe1b, (q15_t)0x80c8, (q15_t)0xe15, (q15_t)0x80c7, (q15_t)0xe0f, (q15_t)0x80c7, (q15_t)0xe09, (q15_t)0x80c6, - (q15_t)0xe02, (q15_t)0x80c5, (q15_t)0xdfc, (q15_t)0x80c5, (q15_t)0xdf6, (q15_t)0x80c4, (q15_t)0xdf0, (q15_t)0x80c3, - (q15_t)0xde9, (q15_t)0x80c3, (q15_t)0xde3, (q15_t)0x80c2, (q15_t)0xddd, (q15_t)0x80c1, (q15_t)0xdd7, (q15_t)0x80c1, - (q15_t)0xdd0, (q15_t)0x80c0, (q15_t)0xdca, (q15_t)0x80bf, (q15_t)0xdc4, (q15_t)0x80bf, (q15_t)0xdbe, (q15_t)0x80be, - (q15_t)0xdb7, (q15_t)0x80bd, (q15_t)0xdb1, (q15_t)0x80bd, (q15_t)0xdab, (q15_t)0x80bc, (q15_t)0xda5, (q15_t)0x80bb, - (q15_t)0xd9e, (q15_t)0x80bb, (q15_t)0xd98, (q15_t)0x80ba, (q15_t)0xd92, (q15_t)0x80b9, (q15_t)0xd8c, (q15_t)0x80b9, - (q15_t)0xd85, (q15_t)0x80b8, (q15_t)0xd7f, (q15_t)0x80b7, (q15_t)0xd79, (q15_t)0x80b7, (q15_t)0xd73, (q15_t)0x80b6, - (q15_t)0xd6c, (q15_t)0x80b5, (q15_t)0xd66, (q15_t)0x80b5, (q15_t)0xd60, (q15_t)0x80b4, (q15_t)0xd5a, (q15_t)0x80b3, - (q15_t)0xd53, (q15_t)0x80b3, (q15_t)0xd4d, (q15_t)0x80b2, (q15_t)0xd47, (q15_t)0x80b1, (q15_t)0xd41, (q15_t)0x80b1, - (q15_t)0xd3a, (q15_t)0x80b0, (q15_t)0xd34, (q15_t)0x80af, (q15_t)0xd2e, (q15_t)0x80af, (q15_t)0xd28, (q15_t)0x80ae, - (q15_t)0xd21, (q15_t)0x80ad, (q15_t)0xd1b, (q15_t)0x80ad, (q15_t)0xd15, (q15_t)0x80ac, (q15_t)0xd0f, (q15_t)0x80ab, - (q15_t)0xd08, (q15_t)0x80ab, (q15_t)0xd02, (q15_t)0x80aa, (q15_t)0xcfc, (q15_t)0x80aa, (q15_t)0xcf6, (q15_t)0x80a9, - (q15_t)0xcef, (q15_t)0x80a8, (q15_t)0xce9, (q15_t)0x80a8, (q15_t)0xce3, (q15_t)0x80a7, (q15_t)0xcdd, (q15_t)0x80a6, - (q15_t)0xcd6, (q15_t)0x80a6, (q15_t)0xcd0, (q15_t)0x80a5, (q15_t)0xcca, (q15_t)0x80a5, (q15_t)0xcc4, (q15_t)0x80a4, - (q15_t)0xcbd, (q15_t)0x80a3, (q15_t)0xcb7, (q15_t)0x80a3, (q15_t)0xcb1, (q15_t)0x80a2, (q15_t)0xcab, (q15_t)0x80a1, - (q15_t)0xca4, (q15_t)0x80a1, (q15_t)0xc9e, (q15_t)0x80a0, (q15_t)0xc98, (q15_t)0x80a0, (q15_t)0xc92, (q15_t)0x809f, - (q15_t)0xc8b, (q15_t)0x809e, (q15_t)0xc85, (q15_t)0x809e, (q15_t)0xc7f, (q15_t)0x809d, (q15_t)0xc79, (q15_t)0x809c, - (q15_t)0xc72, (q15_t)0x809c, (q15_t)0xc6c, (q15_t)0x809b, (q15_t)0xc66, (q15_t)0x809b, (q15_t)0xc60, (q15_t)0x809a, - (q15_t)0xc59, (q15_t)0x8099, (q15_t)0xc53, (q15_t)0x8099, (q15_t)0xc4d, (q15_t)0x8098, (q15_t)0xc47, (q15_t)0x8098, - (q15_t)0xc40, (q15_t)0x8097, (q15_t)0xc3a, (q15_t)0x8096, (q15_t)0xc34, (q15_t)0x8096, (q15_t)0xc2e, (q15_t)0x8095, - (q15_t)0xc27, (q15_t)0x8095, (q15_t)0xc21, (q15_t)0x8094, (q15_t)0xc1b, (q15_t)0x8093, (q15_t)0xc14, (q15_t)0x8093, - (q15_t)0xc0e, (q15_t)0x8092, (q15_t)0xc08, (q15_t)0x8092, (q15_t)0xc02, (q15_t)0x8091, (q15_t)0xbfb, (q15_t)0x8090, - (q15_t)0xbf5, (q15_t)0x8090, (q15_t)0xbef, (q15_t)0x808f, (q15_t)0xbe9, (q15_t)0x808f, (q15_t)0xbe2, (q15_t)0x808e, - (q15_t)0xbdc, (q15_t)0x808e, (q15_t)0xbd6, (q15_t)0x808d, (q15_t)0xbd0, (q15_t)0x808c, (q15_t)0xbc9, (q15_t)0x808c, - (q15_t)0xbc3, (q15_t)0x808b, (q15_t)0xbbd, (q15_t)0x808b, (q15_t)0xbb7, (q15_t)0x808a, (q15_t)0xbb0, (q15_t)0x8089, - (q15_t)0xbaa, (q15_t)0x8089, (q15_t)0xba4, (q15_t)0x8088, (q15_t)0xb9e, (q15_t)0x8088, (q15_t)0xb97, (q15_t)0x8087, - (q15_t)0xb91, (q15_t)0x8087, (q15_t)0xb8b, (q15_t)0x8086, (q15_t)0xb85, (q15_t)0x8085, (q15_t)0xb7e, (q15_t)0x8085, - (q15_t)0xb78, (q15_t)0x8084, (q15_t)0xb72, (q15_t)0x8084, (q15_t)0xb6c, (q15_t)0x8083, (q15_t)0xb65, (q15_t)0x8083, - (q15_t)0xb5f, (q15_t)0x8082, (q15_t)0xb59, (q15_t)0x8082, (q15_t)0xb53, (q15_t)0x8081, (q15_t)0xb4c, (q15_t)0x8080, - (q15_t)0xb46, (q15_t)0x8080, (q15_t)0xb40, (q15_t)0x807f, (q15_t)0xb3a, (q15_t)0x807f, (q15_t)0xb33, (q15_t)0x807e, - (q15_t)0xb2d, (q15_t)0x807e, (q15_t)0xb27, (q15_t)0x807d, (q15_t)0xb20, (q15_t)0x807d, (q15_t)0xb1a, (q15_t)0x807c, - (q15_t)0xb14, (q15_t)0x807b, (q15_t)0xb0e, (q15_t)0x807b, (q15_t)0xb07, (q15_t)0x807a, (q15_t)0xb01, (q15_t)0x807a, - (q15_t)0xafb, (q15_t)0x8079, (q15_t)0xaf5, (q15_t)0x8079, (q15_t)0xaee, (q15_t)0x8078, (q15_t)0xae8, (q15_t)0x8078, - (q15_t)0xae2, (q15_t)0x8077, (q15_t)0xadc, (q15_t)0x8077, (q15_t)0xad5, (q15_t)0x8076, (q15_t)0xacf, (q15_t)0x8076, - (q15_t)0xac9, (q15_t)0x8075, (q15_t)0xac3, (q15_t)0x8075, (q15_t)0xabc, (q15_t)0x8074, (q15_t)0xab6, (q15_t)0x8073, - (q15_t)0xab0, (q15_t)0x8073, (q15_t)0xaaa, (q15_t)0x8072, (q15_t)0xaa3, (q15_t)0x8072, (q15_t)0xa9d, (q15_t)0x8071, - (q15_t)0xa97, (q15_t)0x8071, (q15_t)0xa90, (q15_t)0x8070, (q15_t)0xa8a, (q15_t)0x8070, (q15_t)0xa84, (q15_t)0x806f, - (q15_t)0xa7e, (q15_t)0x806f, (q15_t)0xa77, (q15_t)0x806e, (q15_t)0xa71, (q15_t)0x806e, (q15_t)0xa6b, (q15_t)0x806d, - (q15_t)0xa65, (q15_t)0x806d, (q15_t)0xa5e, (q15_t)0x806c, (q15_t)0xa58, (q15_t)0x806c, (q15_t)0xa52, (q15_t)0x806b, - (q15_t)0xa4c, (q15_t)0x806b, (q15_t)0xa45, (q15_t)0x806a, (q15_t)0xa3f, (q15_t)0x806a, (q15_t)0xa39, (q15_t)0x8069, - (q15_t)0xa33, (q15_t)0x8069, (q15_t)0xa2c, (q15_t)0x8068, (q15_t)0xa26, (q15_t)0x8068, (q15_t)0xa20, (q15_t)0x8067, - (q15_t)0xa19, (q15_t)0x8067, (q15_t)0xa13, (q15_t)0x8066, (q15_t)0xa0d, (q15_t)0x8066, (q15_t)0xa07, (q15_t)0x8065, - (q15_t)0xa00, (q15_t)0x8065, (q15_t)0x9fa, (q15_t)0x8064, (q15_t)0x9f4, (q15_t)0x8064, (q15_t)0x9ee, (q15_t)0x8063, - (q15_t)0x9e7, (q15_t)0x8063, (q15_t)0x9e1, (q15_t)0x8062, (q15_t)0x9db, (q15_t)0x8062, (q15_t)0x9d5, (q15_t)0x8061, - (q15_t)0x9ce, (q15_t)0x8061, (q15_t)0x9c8, (q15_t)0x8060, (q15_t)0x9c2, (q15_t)0x8060, (q15_t)0x9bc, (q15_t)0x805f, - (q15_t)0x9b5, (q15_t)0x805f, (q15_t)0x9af, (q15_t)0x805e, (q15_t)0x9a9, (q15_t)0x805e, (q15_t)0x9a2, (q15_t)0x805d, - (q15_t)0x99c, (q15_t)0x805d, (q15_t)0x996, (q15_t)0x805d, (q15_t)0x990, (q15_t)0x805c, (q15_t)0x989, (q15_t)0x805c, - (q15_t)0x983, (q15_t)0x805b, (q15_t)0x97d, (q15_t)0x805b, (q15_t)0x977, (q15_t)0x805a, (q15_t)0x970, (q15_t)0x805a, - (q15_t)0x96a, (q15_t)0x8059, (q15_t)0x964, (q15_t)0x8059, (q15_t)0x95e, (q15_t)0x8058, (q15_t)0x957, (q15_t)0x8058, - (q15_t)0x951, (q15_t)0x8057, (q15_t)0x94b, (q15_t)0x8057, (q15_t)0x944, (q15_t)0x8057, (q15_t)0x93e, (q15_t)0x8056, - (q15_t)0x938, (q15_t)0x8056, (q15_t)0x932, (q15_t)0x8055, (q15_t)0x92b, (q15_t)0x8055, (q15_t)0x925, (q15_t)0x8054, - (q15_t)0x91f, (q15_t)0x8054, (q15_t)0x919, (q15_t)0x8053, (q15_t)0x912, (q15_t)0x8053, (q15_t)0x90c, (q15_t)0x8052, - (q15_t)0x906, (q15_t)0x8052, (q15_t)0x900, (q15_t)0x8052, (q15_t)0x8f9, (q15_t)0x8051, (q15_t)0x8f3, (q15_t)0x8051, - (q15_t)0x8ed, (q15_t)0x8050, (q15_t)0x8e6, (q15_t)0x8050, (q15_t)0x8e0, (q15_t)0x804f, (q15_t)0x8da, (q15_t)0x804f, - (q15_t)0x8d4, (q15_t)0x804f, (q15_t)0x8cd, (q15_t)0x804e, (q15_t)0x8c7, (q15_t)0x804e, (q15_t)0x8c1, (q15_t)0x804d, - (q15_t)0x8bb, (q15_t)0x804d, (q15_t)0x8b4, (q15_t)0x804c, (q15_t)0x8ae, (q15_t)0x804c, (q15_t)0x8a8, (q15_t)0x804c, - (q15_t)0x8a2, (q15_t)0x804b, (q15_t)0x89b, (q15_t)0x804b, (q15_t)0x895, (q15_t)0x804a, (q15_t)0x88f, (q15_t)0x804a, - (q15_t)0x888, (q15_t)0x8049, (q15_t)0x882, (q15_t)0x8049, (q15_t)0x87c, (q15_t)0x8049, (q15_t)0x876, (q15_t)0x8048, - (q15_t)0x86f, (q15_t)0x8048, (q15_t)0x869, (q15_t)0x8047, (q15_t)0x863, (q15_t)0x8047, (q15_t)0x85d, (q15_t)0x8047, - (q15_t)0x856, (q15_t)0x8046, (q15_t)0x850, (q15_t)0x8046, (q15_t)0x84a, (q15_t)0x8045, (q15_t)0x843, (q15_t)0x8045, - (q15_t)0x83d, (q15_t)0x8044, (q15_t)0x837, (q15_t)0x8044, (q15_t)0x831, (q15_t)0x8044, (q15_t)0x82a, (q15_t)0x8043, - (q15_t)0x824, (q15_t)0x8043, (q15_t)0x81e, (q15_t)0x8042, (q15_t)0x818, (q15_t)0x8042, (q15_t)0x811, (q15_t)0x8042, - (q15_t)0x80b, (q15_t)0x8041, (q15_t)0x805, (q15_t)0x8041, (q15_t)0x7fe, (q15_t)0x8040, (q15_t)0x7f8, (q15_t)0x8040, - (q15_t)0x7f2, (q15_t)0x8040, (q15_t)0x7ec, (q15_t)0x803f, (q15_t)0x7e5, (q15_t)0x803f, (q15_t)0x7df, (q15_t)0x803f, - (q15_t)0x7d9, (q15_t)0x803e, (q15_t)0x7d3, (q15_t)0x803e, (q15_t)0x7cc, (q15_t)0x803d, (q15_t)0x7c6, (q15_t)0x803d, - (q15_t)0x7c0, (q15_t)0x803d, (q15_t)0x7ba, (q15_t)0x803c, (q15_t)0x7b3, (q15_t)0x803c, (q15_t)0x7ad, (q15_t)0x803b, - (q15_t)0x7a7, (q15_t)0x803b, (q15_t)0x7a0, (q15_t)0x803b, (q15_t)0x79a, (q15_t)0x803a, (q15_t)0x794, (q15_t)0x803a, - (q15_t)0x78e, (q15_t)0x803a, (q15_t)0x787, (q15_t)0x8039, (q15_t)0x781, (q15_t)0x8039, (q15_t)0x77b, (q15_t)0x8039, - (q15_t)0x775, (q15_t)0x8038, (q15_t)0x76e, (q15_t)0x8038, (q15_t)0x768, (q15_t)0x8037, (q15_t)0x762, (q15_t)0x8037, - (q15_t)0x75b, (q15_t)0x8037, (q15_t)0x755, (q15_t)0x8036, (q15_t)0x74f, (q15_t)0x8036, (q15_t)0x749, (q15_t)0x8036, - (q15_t)0x742, (q15_t)0x8035, (q15_t)0x73c, (q15_t)0x8035, (q15_t)0x736, (q15_t)0x8035, (q15_t)0x730, (q15_t)0x8034, - (q15_t)0x729, (q15_t)0x8034, (q15_t)0x723, (q15_t)0x8033, (q15_t)0x71d, (q15_t)0x8033, (q15_t)0x716, (q15_t)0x8033, - (q15_t)0x710, (q15_t)0x8032, (q15_t)0x70a, (q15_t)0x8032, (q15_t)0x704, (q15_t)0x8032, (q15_t)0x6fd, (q15_t)0x8031, - (q15_t)0x6f7, (q15_t)0x8031, (q15_t)0x6f1, (q15_t)0x8031, (q15_t)0x6ea, (q15_t)0x8030, (q15_t)0x6e4, (q15_t)0x8030, - (q15_t)0x6de, (q15_t)0x8030, (q15_t)0x6d8, (q15_t)0x802f, (q15_t)0x6d1, (q15_t)0x802f, (q15_t)0x6cb, (q15_t)0x802f, - (q15_t)0x6c5, (q15_t)0x802e, (q15_t)0x6bf, (q15_t)0x802e, (q15_t)0x6b8, (q15_t)0x802e, (q15_t)0x6b2, (q15_t)0x802d, - (q15_t)0x6ac, (q15_t)0x802d, (q15_t)0x6a5, (q15_t)0x802d, (q15_t)0x69f, (q15_t)0x802c, (q15_t)0x699, (q15_t)0x802c, - (q15_t)0x693, (q15_t)0x802c, (q15_t)0x68c, (q15_t)0x802b, (q15_t)0x686, (q15_t)0x802b, (q15_t)0x680, (q15_t)0x802b, - (q15_t)0x67a, (q15_t)0x802a, (q15_t)0x673, (q15_t)0x802a, (q15_t)0x66d, (q15_t)0x802a, (q15_t)0x667, (q15_t)0x802a, - (q15_t)0x660, (q15_t)0x8029, (q15_t)0x65a, (q15_t)0x8029, (q15_t)0x654, (q15_t)0x8029, (q15_t)0x64e, (q15_t)0x8028, - (q15_t)0x647, (q15_t)0x8028, (q15_t)0x641, (q15_t)0x8028, (q15_t)0x63b, (q15_t)0x8027, (q15_t)0x635, (q15_t)0x8027, - (q15_t)0x62e, (q15_t)0x8027, (q15_t)0x628, (q15_t)0x8026, (q15_t)0x622, (q15_t)0x8026, (q15_t)0x61b, (q15_t)0x8026, - (q15_t)0x615, (q15_t)0x8026, (q15_t)0x60f, (q15_t)0x8025, (q15_t)0x609, (q15_t)0x8025, (q15_t)0x602, (q15_t)0x8025, - (q15_t)0x5fc, (q15_t)0x8024, (q15_t)0x5f6, (q15_t)0x8024, (q15_t)0x5ef, (q15_t)0x8024, (q15_t)0x5e9, (q15_t)0x8023, - (q15_t)0x5e3, (q15_t)0x8023, (q15_t)0x5dd, (q15_t)0x8023, (q15_t)0x5d6, (q15_t)0x8023, (q15_t)0x5d0, (q15_t)0x8022, - (q15_t)0x5ca, (q15_t)0x8022, (q15_t)0x5c4, (q15_t)0x8022, (q15_t)0x5bd, (q15_t)0x8021, (q15_t)0x5b7, (q15_t)0x8021, - (q15_t)0x5b1, (q15_t)0x8021, (q15_t)0x5aa, (q15_t)0x8021, (q15_t)0x5a4, (q15_t)0x8020, (q15_t)0x59e, (q15_t)0x8020, - (q15_t)0x598, (q15_t)0x8020, (q15_t)0x591, (q15_t)0x8020, (q15_t)0x58b, (q15_t)0x801f, (q15_t)0x585, (q15_t)0x801f, - (q15_t)0x57f, (q15_t)0x801f, (q15_t)0x578, (q15_t)0x801e, (q15_t)0x572, (q15_t)0x801e, (q15_t)0x56c, (q15_t)0x801e, - (q15_t)0x565, (q15_t)0x801e, (q15_t)0x55f, (q15_t)0x801d, (q15_t)0x559, (q15_t)0x801d, (q15_t)0x553, (q15_t)0x801d, - (q15_t)0x54c, (q15_t)0x801d, (q15_t)0x546, (q15_t)0x801c, (q15_t)0x540, (q15_t)0x801c, (q15_t)0x539, (q15_t)0x801c, - (q15_t)0x533, (q15_t)0x801c, (q15_t)0x52d, (q15_t)0x801b, (q15_t)0x527, (q15_t)0x801b, (q15_t)0x520, (q15_t)0x801b, - (q15_t)0x51a, (q15_t)0x801b, (q15_t)0x514, (q15_t)0x801a, (q15_t)0x50d, (q15_t)0x801a, (q15_t)0x507, (q15_t)0x801a, - (q15_t)0x501, (q15_t)0x801a, (q15_t)0x4fb, (q15_t)0x8019, (q15_t)0x4f4, (q15_t)0x8019, (q15_t)0x4ee, (q15_t)0x8019, - (q15_t)0x4e8, (q15_t)0x8019, (q15_t)0x4e2, (q15_t)0x8018, (q15_t)0x4db, (q15_t)0x8018, (q15_t)0x4d5, (q15_t)0x8018, - (q15_t)0x4cf, (q15_t)0x8018, (q15_t)0x4c8, (q15_t)0x8017, (q15_t)0x4c2, (q15_t)0x8017, (q15_t)0x4bc, (q15_t)0x8017, - (q15_t)0x4b6, (q15_t)0x8017, (q15_t)0x4af, (q15_t)0x8016, (q15_t)0x4a9, (q15_t)0x8016, (q15_t)0x4a3, (q15_t)0x8016, - (q15_t)0x49c, (q15_t)0x8016, (q15_t)0x496, (q15_t)0x8016, (q15_t)0x490, (q15_t)0x8015, (q15_t)0x48a, (q15_t)0x8015, - (q15_t)0x483, (q15_t)0x8015, (q15_t)0x47d, (q15_t)0x8015, (q15_t)0x477, (q15_t)0x8014, (q15_t)0x471, (q15_t)0x8014, - (q15_t)0x46a, (q15_t)0x8014, (q15_t)0x464, (q15_t)0x8014, (q15_t)0x45e, (q15_t)0x8014, (q15_t)0x457, (q15_t)0x8013, - (q15_t)0x451, (q15_t)0x8013, (q15_t)0x44b, (q15_t)0x8013, (q15_t)0x445, (q15_t)0x8013, (q15_t)0x43e, (q15_t)0x8013, - (q15_t)0x438, (q15_t)0x8012, (q15_t)0x432, (q15_t)0x8012, (q15_t)0x42b, (q15_t)0x8012, (q15_t)0x425, (q15_t)0x8012, - (q15_t)0x41f, (q15_t)0x8012, (q15_t)0x419, (q15_t)0x8011, (q15_t)0x412, (q15_t)0x8011, (q15_t)0x40c, (q15_t)0x8011, - (q15_t)0x406, (q15_t)0x8011, (q15_t)0x3ff, (q15_t)0x8011, (q15_t)0x3f9, (q15_t)0x8010, (q15_t)0x3f3, (q15_t)0x8010, - (q15_t)0x3ed, (q15_t)0x8010, (q15_t)0x3e6, (q15_t)0x8010, (q15_t)0x3e0, (q15_t)0x8010, (q15_t)0x3da, (q15_t)0x800f, - (q15_t)0x3d4, (q15_t)0x800f, (q15_t)0x3cd, (q15_t)0x800f, (q15_t)0x3c7, (q15_t)0x800f, (q15_t)0x3c1, (q15_t)0x800f, - (q15_t)0x3ba, (q15_t)0x800e, (q15_t)0x3b4, (q15_t)0x800e, (q15_t)0x3ae, (q15_t)0x800e, (q15_t)0x3a8, (q15_t)0x800e, - (q15_t)0x3a1, (q15_t)0x800e, (q15_t)0x39b, (q15_t)0x800e, (q15_t)0x395, (q15_t)0x800d, (q15_t)0x38e, (q15_t)0x800d, - (q15_t)0x388, (q15_t)0x800d, (q15_t)0x382, (q15_t)0x800d, (q15_t)0x37c, (q15_t)0x800d, (q15_t)0x375, (q15_t)0x800c, - (q15_t)0x36f, (q15_t)0x800c, (q15_t)0x369, (q15_t)0x800c, (q15_t)0x362, (q15_t)0x800c, (q15_t)0x35c, (q15_t)0x800c, - (q15_t)0x356, (q15_t)0x800c, (q15_t)0x350, (q15_t)0x800b, (q15_t)0x349, (q15_t)0x800b, (q15_t)0x343, (q15_t)0x800b, - (q15_t)0x33d, (q15_t)0x800b, (q15_t)0x337, (q15_t)0x800b, (q15_t)0x330, (q15_t)0x800b, (q15_t)0x32a, (q15_t)0x800b, - (q15_t)0x324, (q15_t)0x800a, (q15_t)0x31d, (q15_t)0x800a, (q15_t)0x317, (q15_t)0x800a, (q15_t)0x311, (q15_t)0x800a, - (q15_t)0x30b, (q15_t)0x800a, (q15_t)0x304, (q15_t)0x800a, (q15_t)0x2fe, (q15_t)0x8009, (q15_t)0x2f8, (q15_t)0x8009, - (q15_t)0x2f1, (q15_t)0x8009, (q15_t)0x2eb, (q15_t)0x8009, (q15_t)0x2e5, (q15_t)0x8009, (q15_t)0x2df, (q15_t)0x8009, - (q15_t)0x2d8, (q15_t)0x8009, (q15_t)0x2d2, (q15_t)0x8008, (q15_t)0x2cc, (q15_t)0x8008, (q15_t)0x2c5, (q15_t)0x8008, - (q15_t)0x2bf, (q15_t)0x8008, (q15_t)0x2b9, (q15_t)0x8008, (q15_t)0x2b3, (q15_t)0x8008, (q15_t)0x2ac, (q15_t)0x8008, - (q15_t)0x2a6, (q15_t)0x8008, (q15_t)0x2a0, (q15_t)0x8007, (q15_t)0x299, (q15_t)0x8007, (q15_t)0x293, (q15_t)0x8007, - (q15_t)0x28d, (q15_t)0x8007, (q15_t)0x287, (q15_t)0x8007, (q15_t)0x280, (q15_t)0x8007, (q15_t)0x27a, (q15_t)0x8007, - (q15_t)0x274, (q15_t)0x8007, (q15_t)0x26d, (q15_t)0x8006, (q15_t)0x267, (q15_t)0x8006, (q15_t)0x261, (q15_t)0x8006, - (q15_t)0x25b, (q15_t)0x8006, (q15_t)0x254, (q15_t)0x8006, (q15_t)0x24e, (q15_t)0x8006, (q15_t)0x248, (q15_t)0x8006, - (q15_t)0x242, (q15_t)0x8006, (q15_t)0x23b, (q15_t)0x8005, (q15_t)0x235, (q15_t)0x8005, (q15_t)0x22f, (q15_t)0x8005, - (q15_t)0x228, (q15_t)0x8005, (q15_t)0x222, (q15_t)0x8005, (q15_t)0x21c, (q15_t)0x8005, (q15_t)0x216, (q15_t)0x8005, - (q15_t)0x20f, (q15_t)0x8005, (q15_t)0x209, (q15_t)0x8005, (q15_t)0x203, (q15_t)0x8005, (q15_t)0x1fc, (q15_t)0x8004, - (q15_t)0x1f6, (q15_t)0x8004, (q15_t)0x1f0, (q15_t)0x8004, (q15_t)0x1ea, (q15_t)0x8004, (q15_t)0x1e3, (q15_t)0x8004, - (q15_t)0x1dd, (q15_t)0x8004, (q15_t)0x1d7, (q15_t)0x8004, (q15_t)0x1d0, (q15_t)0x8004, (q15_t)0x1ca, (q15_t)0x8004, - (q15_t)0x1c4, (q15_t)0x8004, (q15_t)0x1be, (q15_t)0x8004, (q15_t)0x1b7, (q15_t)0x8003, (q15_t)0x1b1, (q15_t)0x8003, - (q15_t)0x1ab, (q15_t)0x8003, (q15_t)0x1a4, (q15_t)0x8003, (q15_t)0x19e, (q15_t)0x8003, (q15_t)0x198, (q15_t)0x8003, - (q15_t)0x192, (q15_t)0x8003, (q15_t)0x18b, (q15_t)0x8003, (q15_t)0x185, (q15_t)0x8003, (q15_t)0x17f, (q15_t)0x8003, - (q15_t)0x178, (q15_t)0x8003, (q15_t)0x172, (q15_t)0x8003, (q15_t)0x16c, (q15_t)0x8003, (q15_t)0x166, (q15_t)0x8002, - (q15_t)0x15f, (q15_t)0x8002, (q15_t)0x159, (q15_t)0x8002, (q15_t)0x153, (q15_t)0x8002, (q15_t)0x14d, (q15_t)0x8002, - (q15_t)0x146, (q15_t)0x8002, (q15_t)0x140, (q15_t)0x8002, (q15_t)0x13a, (q15_t)0x8002, (q15_t)0x133, (q15_t)0x8002, - (q15_t)0x12d, (q15_t)0x8002, (q15_t)0x127, (q15_t)0x8002, (q15_t)0x121, (q15_t)0x8002, (q15_t)0x11a, (q15_t)0x8002, - (q15_t)0x114, (q15_t)0x8002, (q15_t)0x10e, (q15_t)0x8002, (q15_t)0x107, (q15_t)0x8002, (q15_t)0x101, (q15_t)0x8002, - (q15_t)0xfb, (q15_t)0x8001, (q15_t)0xf5, (q15_t)0x8001, (q15_t)0xee, (q15_t)0x8001, (q15_t)0xe8, (q15_t)0x8001, - (q15_t)0xe2, (q15_t)0x8001, (q15_t)0xdb, (q15_t)0x8001, (q15_t)0xd5, (q15_t)0x8001, (q15_t)0xcf, (q15_t)0x8001, - (q15_t)0xc9, (q15_t)0x8001, (q15_t)0xc2, (q15_t)0x8001, (q15_t)0xbc, (q15_t)0x8001, (q15_t)0xb6, (q15_t)0x8001, - (q15_t)0xaf, (q15_t)0x8001, (q15_t)0xa9, (q15_t)0x8001, (q15_t)0xa3, (q15_t)0x8001, (q15_t)0x9d, (q15_t)0x8001, - (q15_t)0x96, (q15_t)0x8001, (q15_t)0x90, (q15_t)0x8001, (q15_t)0x8a, (q15_t)0x8001, (q15_t)0x83, (q15_t)0x8001, - (q15_t)0x7d, (q15_t)0x8001, (q15_t)0x77, (q15_t)0x8001, (q15_t)0x71, (q15_t)0x8001, (q15_t)0x6a, (q15_t)0x8001, - (q15_t)0x64, (q15_t)0x8001, (q15_t)0x5e, (q15_t)0x8001, (q15_t)0x57, (q15_t)0x8001, (q15_t)0x51, (q15_t)0x8001, - (q15_t)0x4b, (q15_t)0x8001, (q15_t)0x45, (q15_t)0x8001, (q15_t)0x3e, (q15_t)0x8001, (q15_t)0x38, (q15_t)0x8001, - (q15_t)0x32, (q15_t)0x8001, (q15_t)0x2b, (q15_t)0x8001, (q15_t)0x25, (q15_t)0x8001, (q15_t)0x1f, (q15_t)0x8001, - (q15_t)0x19, (q15_t)0x8001, (q15_t)0x12, (q15_t)0x8001, (q15_t)0xc, (q15_t)0x8001, (q15_t)0x6, (q15_t)0x8001 -}; - + (q15_t)0x7fff, (q15_t)0x0, (q15_t)0x7fff, (q15_t)0xfffa, (q15_t)0x7fff, + (q15_t)0xfff4, (q15_t)0x7fff, (q15_t)0xffee, (q15_t)0x7fff, (q15_t)0xffe7, + (q15_t)0x7fff, (q15_t)0xffe1, (q15_t)0x7fff, (q15_t)0xffdb, (q15_t)0x7fff, + (q15_t)0xffd5, (q15_t)0x7fff, (q15_t)0xffce, (q15_t)0x7fff, (q15_t)0xffc8, + (q15_t)0x7fff, (q15_t)0xffc2, (q15_t)0x7fff, (q15_t)0xffbb, (q15_t)0x7fff, + (q15_t)0xffb5, (q15_t)0x7fff, (q15_t)0xffaf, (q15_t)0x7fff, (q15_t)0xffa9, + (q15_t)0x7fff, (q15_t)0xffa2, (q15_t)0x7fff, (q15_t)0xff9c, (q15_t)0x7fff, + (q15_t)0xff96, (q15_t)0x7fff, (q15_t)0xff8f, (q15_t)0x7fff, (q15_t)0xff89, + (q15_t)0x7fff, (q15_t)0xff83, (q15_t)0x7fff, (q15_t)0xff7d, (q15_t)0x7fff, + (q15_t)0xff76, (q15_t)0x7fff, (q15_t)0xff70, (q15_t)0x7fff, (q15_t)0xff6a, + (q15_t)0x7fff, (q15_t)0xff63, (q15_t)0x7fff, (q15_t)0xff5d, (q15_t)0x7fff, + (q15_t)0xff57, (q15_t)0x7fff, (q15_t)0xff51, (q15_t)0x7fff, (q15_t)0xff4a, + (q15_t)0x7fff, (q15_t)0xff44, (q15_t)0x7fff, (q15_t)0xff3e, (q15_t)0x7fff, + (q15_t)0xff37, (q15_t)0x7fff, (q15_t)0xff31, (q15_t)0x7fff, (q15_t)0xff2b, + (q15_t)0x7fff, (q15_t)0xff25, (q15_t)0x7fff, (q15_t)0xff1e, (q15_t)0x7fff, + (q15_t)0xff18, (q15_t)0x7fff, (q15_t)0xff12, (q15_t)0x7fff, (q15_t)0xff0b, + (q15_t)0x7fff, (q15_t)0xff05, (q15_t)0x7ffe, (q15_t)0xfeff, (q15_t)0x7ffe, + (q15_t)0xfef9, (q15_t)0x7ffe, (q15_t)0xfef2, (q15_t)0x7ffe, (q15_t)0xfeec, + (q15_t)0x7ffe, (q15_t)0xfee6, (q15_t)0x7ffe, (q15_t)0xfedf, (q15_t)0x7ffe, + (q15_t)0xfed9, (q15_t)0x7ffe, (q15_t)0xfed3, (q15_t)0x7ffe, (q15_t)0xfecd, + (q15_t)0x7ffe, (q15_t)0xfec6, (q15_t)0x7ffe, (q15_t)0xfec0, (q15_t)0x7ffe, + (q15_t)0xfeba, (q15_t)0x7ffe, (q15_t)0xfeb3, (q15_t)0x7ffe, (q15_t)0xfead, + (q15_t)0x7ffe, (q15_t)0xfea7, (q15_t)0x7ffe, (q15_t)0xfea1, (q15_t)0x7ffe, + (q15_t)0xfe9a, (q15_t)0x7ffd, (q15_t)0xfe94, (q15_t)0x7ffd, (q15_t)0xfe8e, + (q15_t)0x7ffd, (q15_t)0xfe88, (q15_t)0x7ffd, (q15_t)0xfe81, (q15_t)0x7ffd, + (q15_t)0xfe7b, (q15_t)0x7ffd, (q15_t)0xfe75, (q15_t)0x7ffd, (q15_t)0xfe6e, + (q15_t)0x7ffd, (q15_t)0xfe68, (q15_t)0x7ffd, (q15_t)0xfe62, (q15_t)0x7ffd, + (q15_t)0xfe5c, (q15_t)0x7ffd, (q15_t)0xfe55, (q15_t)0x7ffd, (q15_t)0xfe4f, + (q15_t)0x7ffd, (q15_t)0xfe49, (q15_t)0x7ffc, (q15_t)0xfe42, (q15_t)0x7ffc, + (q15_t)0xfe3c, (q15_t)0x7ffc, (q15_t)0xfe36, (q15_t)0x7ffc, (q15_t)0xfe30, + (q15_t)0x7ffc, (q15_t)0xfe29, (q15_t)0x7ffc, (q15_t)0xfe23, (q15_t)0x7ffc, + (q15_t)0xfe1d, (q15_t)0x7ffc, (q15_t)0xfe16, (q15_t)0x7ffc, (q15_t)0xfe10, + (q15_t)0x7ffc, (q15_t)0xfe0a, (q15_t)0x7ffc, (q15_t)0xfe04, (q15_t)0x7ffb, + (q15_t)0xfdfd, (q15_t)0x7ffb, (q15_t)0xfdf7, (q15_t)0x7ffb, (q15_t)0xfdf1, + (q15_t)0x7ffb, (q15_t)0xfdea, (q15_t)0x7ffb, (q15_t)0xfde4, (q15_t)0x7ffb, + (q15_t)0xfdde, (q15_t)0x7ffb, (q15_t)0xfdd8, (q15_t)0x7ffb, (q15_t)0xfdd1, + (q15_t)0x7ffb, (q15_t)0xfdcb, (q15_t)0x7ffb, (q15_t)0xfdc5, (q15_t)0x7ffa, + (q15_t)0xfdbe, (q15_t)0x7ffa, (q15_t)0xfdb8, (q15_t)0x7ffa, (q15_t)0xfdb2, + (q15_t)0x7ffa, (q15_t)0xfdac, (q15_t)0x7ffa, (q15_t)0xfda5, (q15_t)0x7ffa, + (q15_t)0xfd9f, (q15_t)0x7ffa, (q15_t)0xfd99, (q15_t)0x7ffa, (q15_t)0xfd93, + (q15_t)0x7ff9, (q15_t)0xfd8c, (q15_t)0x7ff9, (q15_t)0xfd86, (q15_t)0x7ff9, + (q15_t)0xfd80, (q15_t)0x7ff9, (q15_t)0xfd79, (q15_t)0x7ff9, (q15_t)0xfd73, + (q15_t)0x7ff9, (q15_t)0xfd6d, (q15_t)0x7ff9, (q15_t)0xfd67, (q15_t)0x7ff9, + (q15_t)0xfd60, (q15_t)0x7ff8, (q15_t)0xfd5a, (q15_t)0x7ff8, (q15_t)0xfd54, + (q15_t)0x7ff8, (q15_t)0xfd4d, (q15_t)0x7ff8, (q15_t)0xfd47, (q15_t)0x7ff8, + (q15_t)0xfd41, (q15_t)0x7ff8, (q15_t)0xfd3b, (q15_t)0x7ff8, (q15_t)0xfd34, + (q15_t)0x7ff8, (q15_t)0xfd2e, (q15_t)0x7ff7, (q15_t)0xfd28, (q15_t)0x7ff7, + (q15_t)0xfd21, (q15_t)0x7ff7, (q15_t)0xfd1b, (q15_t)0x7ff7, (q15_t)0xfd15, + (q15_t)0x7ff7, (q15_t)0xfd0f, (q15_t)0x7ff7, (q15_t)0xfd08, (q15_t)0x7ff7, + (q15_t)0xfd02, (q15_t)0x7ff6, (q15_t)0xfcfc, (q15_t)0x7ff6, (q15_t)0xfcf5, + (q15_t)0x7ff6, (q15_t)0xfcef, (q15_t)0x7ff6, (q15_t)0xfce9, (q15_t)0x7ff6, + (q15_t)0xfce3, (q15_t)0x7ff6, (q15_t)0xfcdc, (q15_t)0x7ff5, (q15_t)0xfcd6, + (q15_t)0x7ff5, (q15_t)0xfcd0, (q15_t)0x7ff5, (q15_t)0xfcc9, (q15_t)0x7ff5, + (q15_t)0xfcc3, (q15_t)0x7ff5, (q15_t)0xfcbd, (q15_t)0x7ff5, (q15_t)0xfcb7, + (q15_t)0x7ff5, (q15_t)0xfcb0, (q15_t)0x7ff4, (q15_t)0xfcaa, (q15_t)0x7ff4, + (q15_t)0xfca4, (q15_t)0x7ff4, (q15_t)0xfc9e, (q15_t)0x7ff4, (q15_t)0xfc97, + (q15_t)0x7ff4, (q15_t)0xfc91, (q15_t)0x7ff4, (q15_t)0xfc8b, (q15_t)0x7ff3, + (q15_t)0xfc84, (q15_t)0x7ff3, (q15_t)0xfc7e, (q15_t)0x7ff3, (q15_t)0xfc78, + (q15_t)0x7ff3, (q15_t)0xfc72, (q15_t)0x7ff3, (q15_t)0xfc6b, (q15_t)0x7ff2, + (q15_t)0xfc65, (q15_t)0x7ff2, (q15_t)0xfc5f, (q15_t)0x7ff2, (q15_t)0xfc58, + (q15_t)0x7ff2, (q15_t)0xfc52, (q15_t)0x7ff2, (q15_t)0xfc4c, (q15_t)0x7ff2, + (q15_t)0xfc46, (q15_t)0x7ff1, (q15_t)0xfc3f, (q15_t)0x7ff1, (q15_t)0xfc39, + (q15_t)0x7ff1, (q15_t)0xfc33, (q15_t)0x7ff1, (q15_t)0xfc2c, (q15_t)0x7ff1, + (q15_t)0xfc26, (q15_t)0x7ff0, (q15_t)0xfc20, (q15_t)0x7ff0, (q15_t)0xfc1a, + (q15_t)0x7ff0, (q15_t)0xfc13, (q15_t)0x7ff0, (q15_t)0xfc0d, (q15_t)0x7ff0, + (q15_t)0xfc07, (q15_t)0x7fef, (q15_t)0xfc01, (q15_t)0x7fef, (q15_t)0xfbfa, + (q15_t)0x7fef, (q15_t)0xfbf4, (q15_t)0x7fef, (q15_t)0xfbee, (q15_t)0x7fef, + (q15_t)0xfbe7, (q15_t)0x7fee, (q15_t)0xfbe1, (q15_t)0x7fee, (q15_t)0xfbdb, + (q15_t)0x7fee, (q15_t)0xfbd5, (q15_t)0x7fee, (q15_t)0xfbce, (q15_t)0x7fee, + (q15_t)0xfbc8, (q15_t)0x7fed, (q15_t)0xfbc2, (q15_t)0x7fed, (q15_t)0xfbbb, + (q15_t)0x7fed, (q15_t)0xfbb5, (q15_t)0x7fed, (q15_t)0xfbaf, (q15_t)0x7fed, + (q15_t)0xfba9, (q15_t)0x7fec, (q15_t)0xfba2, (q15_t)0x7fec, (q15_t)0xfb9c, + (q15_t)0x7fec, (q15_t)0xfb96, (q15_t)0x7fec, (q15_t)0xfb8f, (q15_t)0x7fec, + (q15_t)0xfb89, (q15_t)0x7feb, (q15_t)0xfb83, (q15_t)0x7feb, (q15_t)0xfb7d, + (q15_t)0x7feb, (q15_t)0xfb76, (q15_t)0x7feb, (q15_t)0xfb70, (q15_t)0x7fea, + (q15_t)0xfb6a, (q15_t)0x7fea, (q15_t)0xfb64, (q15_t)0x7fea, (q15_t)0xfb5d, + (q15_t)0x7fea, (q15_t)0xfb57, (q15_t)0x7fea, (q15_t)0xfb51, (q15_t)0x7fe9, + (q15_t)0xfb4a, (q15_t)0x7fe9, (q15_t)0xfb44, (q15_t)0x7fe9, (q15_t)0xfb3e, + (q15_t)0x7fe9, (q15_t)0xfb38, (q15_t)0x7fe8, (q15_t)0xfb31, (q15_t)0x7fe8, + (q15_t)0xfb2b, (q15_t)0x7fe8, (q15_t)0xfb25, (q15_t)0x7fe8, (q15_t)0xfb1e, + (q15_t)0x7fe7, (q15_t)0xfb18, (q15_t)0x7fe7, (q15_t)0xfb12, (q15_t)0x7fe7, + (q15_t)0xfb0c, (q15_t)0x7fe7, (q15_t)0xfb05, (q15_t)0x7fe6, (q15_t)0xfaff, + (q15_t)0x7fe6, (q15_t)0xfaf9, (q15_t)0x7fe6, (q15_t)0xfaf3, (q15_t)0x7fe6, + (q15_t)0xfaec, (q15_t)0x7fe5, (q15_t)0xfae6, (q15_t)0x7fe5, (q15_t)0xfae0, + (q15_t)0x7fe5, (q15_t)0xfad9, (q15_t)0x7fe5, (q15_t)0xfad3, (q15_t)0x7fe4, + (q15_t)0xfacd, (q15_t)0x7fe4, (q15_t)0xfac7, (q15_t)0x7fe4, (q15_t)0xfac0, + (q15_t)0x7fe4, (q15_t)0xfaba, (q15_t)0x7fe3, (q15_t)0xfab4, (q15_t)0x7fe3, + (q15_t)0xfaad, (q15_t)0x7fe3, (q15_t)0xfaa7, (q15_t)0x7fe3, (q15_t)0xfaa1, + (q15_t)0x7fe2, (q15_t)0xfa9b, (q15_t)0x7fe2, (q15_t)0xfa94, (q15_t)0x7fe2, + (q15_t)0xfa8e, (q15_t)0x7fe2, (q15_t)0xfa88, (q15_t)0x7fe1, (q15_t)0xfa81, + (q15_t)0x7fe1, (q15_t)0xfa7b, (q15_t)0x7fe1, (q15_t)0xfa75, (q15_t)0x7fe0, + (q15_t)0xfa6f, (q15_t)0x7fe0, (q15_t)0xfa68, (q15_t)0x7fe0, (q15_t)0xfa62, + (q15_t)0x7fe0, (q15_t)0xfa5c, (q15_t)0x7fdf, (q15_t)0xfa56, (q15_t)0x7fdf, + (q15_t)0xfa4f, (q15_t)0x7fdf, (q15_t)0xfa49, (q15_t)0x7fdf, (q15_t)0xfa43, + (q15_t)0x7fde, (q15_t)0xfa3c, (q15_t)0x7fde, (q15_t)0xfa36, (q15_t)0x7fde, + (q15_t)0xfa30, (q15_t)0x7fdd, (q15_t)0xfa2a, (q15_t)0x7fdd, (q15_t)0xfa23, + (q15_t)0x7fdd, (q15_t)0xfa1d, (q15_t)0x7fdd, (q15_t)0xfa17, (q15_t)0x7fdc, + (q15_t)0xfa11, (q15_t)0x7fdc, (q15_t)0xfa0a, (q15_t)0x7fdc, (q15_t)0xfa04, + (q15_t)0x7fdb, (q15_t)0xf9fe, (q15_t)0x7fdb, (q15_t)0xf9f7, (q15_t)0x7fdb, + (q15_t)0xf9f1, (q15_t)0x7fda, (q15_t)0xf9eb, (q15_t)0x7fda, (q15_t)0xf9e5, + (q15_t)0x7fda, (q15_t)0xf9de, (q15_t)0x7fda, (q15_t)0xf9d8, (q15_t)0x7fd9, + (q15_t)0xf9d2, (q15_t)0x7fd9, (q15_t)0xf9cb, (q15_t)0x7fd9, (q15_t)0xf9c5, + (q15_t)0x7fd8, (q15_t)0xf9bf, (q15_t)0x7fd8, (q15_t)0xf9b9, (q15_t)0x7fd8, + (q15_t)0xf9b2, (q15_t)0x7fd7, (q15_t)0xf9ac, (q15_t)0x7fd7, (q15_t)0xf9a6, + (q15_t)0x7fd7, (q15_t)0xf9a0, (q15_t)0x7fd6, (q15_t)0xf999, (q15_t)0x7fd6, + (q15_t)0xf993, (q15_t)0x7fd6, (q15_t)0xf98d, (q15_t)0x7fd6, (q15_t)0xf986, + (q15_t)0x7fd5, (q15_t)0xf980, (q15_t)0x7fd5, (q15_t)0xf97a, (q15_t)0x7fd5, + (q15_t)0xf974, (q15_t)0x7fd4, (q15_t)0xf96d, (q15_t)0x7fd4, (q15_t)0xf967, + (q15_t)0x7fd4, (q15_t)0xf961, (q15_t)0x7fd3, (q15_t)0xf95b, (q15_t)0x7fd3, + (q15_t)0xf954, (q15_t)0x7fd3, (q15_t)0xf94e, (q15_t)0x7fd2, (q15_t)0xf948, + (q15_t)0x7fd2, (q15_t)0xf941, (q15_t)0x7fd2, (q15_t)0xf93b, (q15_t)0x7fd1, + (q15_t)0xf935, (q15_t)0x7fd1, (q15_t)0xf92f, (q15_t)0x7fd1, (q15_t)0xf928, + (q15_t)0x7fd0, (q15_t)0xf922, (q15_t)0x7fd0, (q15_t)0xf91c, (q15_t)0x7fd0, + (q15_t)0xf916, (q15_t)0x7fcf, (q15_t)0xf90f, (q15_t)0x7fcf, (q15_t)0xf909, + (q15_t)0x7fcf, (q15_t)0xf903, (q15_t)0x7fce, (q15_t)0xf8fc, (q15_t)0x7fce, + (q15_t)0xf8f6, (q15_t)0x7fce, (q15_t)0xf8f0, (q15_t)0x7fcd, (q15_t)0xf8ea, + (q15_t)0x7fcd, (q15_t)0xf8e3, (q15_t)0x7fcd, (q15_t)0xf8dd, (q15_t)0x7fcc, + (q15_t)0xf8d7, (q15_t)0x7fcc, (q15_t)0xf8d0, (q15_t)0x7fcb, (q15_t)0xf8ca, + (q15_t)0x7fcb, (q15_t)0xf8c4, (q15_t)0x7fcb, (q15_t)0xf8be, (q15_t)0x7fca, + (q15_t)0xf8b7, (q15_t)0x7fca, (q15_t)0xf8b1, (q15_t)0x7fca, (q15_t)0xf8ab, + (q15_t)0x7fc9, (q15_t)0xf8a5, (q15_t)0x7fc9, (q15_t)0xf89e, (q15_t)0x7fc9, + (q15_t)0xf898, (q15_t)0x7fc8, (q15_t)0xf892, (q15_t)0x7fc8, (q15_t)0xf88b, + (q15_t)0x7fc7, (q15_t)0xf885, (q15_t)0x7fc7, (q15_t)0xf87f, (q15_t)0x7fc7, + (q15_t)0xf879, (q15_t)0x7fc6, (q15_t)0xf872, (q15_t)0x7fc6, (q15_t)0xf86c, + (q15_t)0x7fc6, (q15_t)0xf866, (q15_t)0x7fc5, (q15_t)0xf860, (q15_t)0x7fc5, + (q15_t)0xf859, (q15_t)0x7fc5, (q15_t)0xf853, (q15_t)0x7fc4, (q15_t)0xf84d, + (q15_t)0x7fc4, (q15_t)0xf846, (q15_t)0x7fc3, (q15_t)0xf840, (q15_t)0x7fc3, + (q15_t)0xf83a, (q15_t)0x7fc3, (q15_t)0xf834, (q15_t)0x7fc2, (q15_t)0xf82d, + (q15_t)0x7fc2, (q15_t)0xf827, (q15_t)0x7fc1, (q15_t)0xf821, (q15_t)0x7fc1, + (q15_t)0xf81b, (q15_t)0x7fc1, (q15_t)0xf814, (q15_t)0x7fc0, (q15_t)0xf80e, + (q15_t)0x7fc0, (q15_t)0xf808, (q15_t)0x7fc0, (q15_t)0xf802, (q15_t)0x7fbf, + (q15_t)0xf7fb, (q15_t)0x7fbf, (q15_t)0xf7f5, (q15_t)0x7fbe, (q15_t)0xf7ef, + (q15_t)0x7fbe, (q15_t)0xf7e8, (q15_t)0x7fbe, (q15_t)0xf7e2, (q15_t)0x7fbd, + (q15_t)0xf7dc, (q15_t)0x7fbd, (q15_t)0xf7d6, (q15_t)0x7fbc, (q15_t)0xf7cf, + (q15_t)0x7fbc, (q15_t)0xf7c9, (q15_t)0x7fbc, (q15_t)0xf7c3, (q15_t)0x7fbb, + (q15_t)0xf7bd, (q15_t)0x7fbb, (q15_t)0xf7b6, (q15_t)0x7fba, (q15_t)0xf7b0, + (q15_t)0x7fba, (q15_t)0xf7aa, (q15_t)0x7fb9, (q15_t)0xf7a3, (q15_t)0x7fb9, + (q15_t)0xf79d, (q15_t)0x7fb9, (q15_t)0xf797, (q15_t)0x7fb8, (q15_t)0xf791, + (q15_t)0x7fb8, (q15_t)0xf78a, (q15_t)0x7fb7, (q15_t)0xf784, (q15_t)0x7fb7, + (q15_t)0xf77e, (q15_t)0x7fb7, (q15_t)0xf778, (q15_t)0x7fb6, (q15_t)0xf771, + (q15_t)0x7fb6, (q15_t)0xf76b, (q15_t)0x7fb5, (q15_t)0xf765, (q15_t)0x7fb5, + (q15_t)0xf75e, (q15_t)0x7fb4, (q15_t)0xf758, (q15_t)0x7fb4, (q15_t)0xf752, + (q15_t)0x7fb4, (q15_t)0xf74c, (q15_t)0x7fb3, (q15_t)0xf745, (q15_t)0x7fb3, + (q15_t)0xf73f, (q15_t)0x7fb2, (q15_t)0xf739, (q15_t)0x7fb2, (q15_t)0xf733, + (q15_t)0x7fb1, (q15_t)0xf72c, (q15_t)0x7fb1, (q15_t)0xf726, (q15_t)0x7fb1, + (q15_t)0xf720, (q15_t)0x7fb0, (q15_t)0xf71a, (q15_t)0x7fb0, (q15_t)0xf713, + (q15_t)0x7faf, (q15_t)0xf70d, (q15_t)0x7faf, (q15_t)0xf707, (q15_t)0x7fae, + (q15_t)0xf700, (q15_t)0x7fae, (q15_t)0xf6fa, (q15_t)0x7fae, (q15_t)0xf6f4, + (q15_t)0x7fad, (q15_t)0xf6ee, (q15_t)0x7fad, (q15_t)0xf6e7, (q15_t)0x7fac, + (q15_t)0xf6e1, (q15_t)0x7fac, (q15_t)0xf6db, (q15_t)0x7fab, (q15_t)0xf6d5, + (q15_t)0x7fab, (q15_t)0xf6ce, (q15_t)0x7faa, (q15_t)0xf6c8, (q15_t)0x7faa, + (q15_t)0xf6c2, (q15_t)0x7fa9, (q15_t)0xf6bc, (q15_t)0x7fa9, (q15_t)0xf6b5, + (q15_t)0x7fa9, (q15_t)0xf6af, (q15_t)0x7fa8, (q15_t)0xf6a9, (q15_t)0x7fa8, + (q15_t)0xf6a2, (q15_t)0x7fa7, (q15_t)0xf69c, (q15_t)0x7fa7, (q15_t)0xf696, + (q15_t)0x7fa6, (q15_t)0xf690, (q15_t)0x7fa6, (q15_t)0xf689, (q15_t)0x7fa5, + (q15_t)0xf683, (q15_t)0x7fa5, (q15_t)0xf67d, (q15_t)0x7fa4, (q15_t)0xf677, + (q15_t)0x7fa4, (q15_t)0xf670, (q15_t)0x7fa3, (q15_t)0xf66a, (q15_t)0x7fa3, + (q15_t)0xf664, (q15_t)0x7fa3, (q15_t)0xf65e, (q15_t)0x7fa2, (q15_t)0xf657, + (q15_t)0x7fa2, (q15_t)0xf651, (q15_t)0x7fa1, (q15_t)0xf64b, (q15_t)0x7fa1, + (q15_t)0xf644, (q15_t)0x7fa0, (q15_t)0xf63e, (q15_t)0x7fa0, (q15_t)0xf638, + (q15_t)0x7f9f, (q15_t)0xf632, (q15_t)0x7f9f, (q15_t)0xf62b, (q15_t)0x7f9e, + (q15_t)0xf625, (q15_t)0x7f9e, (q15_t)0xf61f, (q15_t)0x7f9d, (q15_t)0xf619, + (q15_t)0x7f9d, (q15_t)0xf612, (q15_t)0x7f9c, (q15_t)0xf60c, (q15_t)0x7f9c, + (q15_t)0xf606, (q15_t)0x7f9b, (q15_t)0xf600, (q15_t)0x7f9b, (q15_t)0xf5f9, + (q15_t)0x7f9a, (q15_t)0xf5f3, (q15_t)0x7f9a, (q15_t)0xf5ed, (q15_t)0x7f99, + (q15_t)0xf5e7, (q15_t)0x7f99, (q15_t)0xf5e0, (q15_t)0x7f98, (q15_t)0xf5da, + (q15_t)0x7f98, (q15_t)0xf5d4, (q15_t)0x7f97, (q15_t)0xf5cd, (q15_t)0x7f97, + (q15_t)0xf5c7, (q15_t)0x7f96, (q15_t)0xf5c1, (q15_t)0x7f96, (q15_t)0xf5bb, + (q15_t)0x7f95, (q15_t)0xf5b4, (q15_t)0x7f95, (q15_t)0xf5ae, (q15_t)0x7f94, + (q15_t)0xf5a8, (q15_t)0x7f94, (q15_t)0xf5a2, (q15_t)0x7f93, (q15_t)0xf59b, + (q15_t)0x7f93, (q15_t)0xf595, (q15_t)0x7f92, (q15_t)0xf58f, (q15_t)0x7f92, + (q15_t)0xf589, (q15_t)0x7f91, (q15_t)0xf582, (q15_t)0x7f91, (q15_t)0xf57c, + (q15_t)0x7f90, (q15_t)0xf576, (q15_t)0x7f90, (q15_t)0xf570, (q15_t)0x7f8f, + (q15_t)0xf569, (q15_t)0x7f8f, (q15_t)0xf563, (q15_t)0x7f8e, (q15_t)0xf55d, + (q15_t)0x7f8e, (q15_t)0xf556, (q15_t)0x7f8d, (q15_t)0xf550, (q15_t)0x7f8d, + (q15_t)0xf54a, (q15_t)0x7f8c, (q15_t)0xf544, (q15_t)0x7f8b, (q15_t)0xf53d, + (q15_t)0x7f8b, (q15_t)0xf537, (q15_t)0x7f8a, (q15_t)0xf531, (q15_t)0x7f8a, + (q15_t)0xf52b, (q15_t)0x7f89, (q15_t)0xf524, (q15_t)0x7f89, (q15_t)0xf51e, + (q15_t)0x7f88, (q15_t)0xf518, (q15_t)0x7f88, (q15_t)0xf512, (q15_t)0x7f87, + (q15_t)0xf50b, (q15_t)0x7f87, (q15_t)0xf505, (q15_t)0x7f86, (q15_t)0xf4ff, + (q15_t)0x7f86, (q15_t)0xf4f9, (q15_t)0x7f85, (q15_t)0xf4f2, (q15_t)0x7f85, + (q15_t)0xf4ec, (q15_t)0x7f84, (q15_t)0xf4e6, (q15_t)0x7f83, (q15_t)0xf4e0, + (q15_t)0x7f83, (q15_t)0xf4d9, (q15_t)0x7f82, (q15_t)0xf4d3, (q15_t)0x7f82, + (q15_t)0xf4cd, (q15_t)0x7f81, (q15_t)0xf4c6, (q15_t)0x7f81, (q15_t)0xf4c0, + (q15_t)0x7f80, (q15_t)0xf4ba, (q15_t)0x7f80, (q15_t)0xf4b4, (q15_t)0x7f7f, + (q15_t)0xf4ad, (q15_t)0x7f7e, (q15_t)0xf4a7, (q15_t)0x7f7e, (q15_t)0xf4a1, + (q15_t)0x7f7d, (q15_t)0xf49b, (q15_t)0x7f7d, (q15_t)0xf494, (q15_t)0x7f7c, + (q15_t)0xf48e, (q15_t)0x7f7c, (q15_t)0xf488, (q15_t)0x7f7b, (q15_t)0xf482, + (q15_t)0x7f7b, (q15_t)0xf47b, (q15_t)0x7f7a, (q15_t)0xf475, (q15_t)0x7f79, + (q15_t)0xf46f, (q15_t)0x7f79, (q15_t)0xf469, (q15_t)0x7f78, (q15_t)0xf462, + (q15_t)0x7f78, (q15_t)0xf45c, (q15_t)0x7f77, (q15_t)0xf456, (q15_t)0x7f77, + (q15_t)0xf450, (q15_t)0x7f76, (q15_t)0xf449, (q15_t)0x7f75, (q15_t)0xf443, + (q15_t)0x7f75, (q15_t)0xf43d, (q15_t)0x7f74, (q15_t)0xf437, (q15_t)0x7f74, + (q15_t)0xf430, (q15_t)0x7f73, (q15_t)0xf42a, (q15_t)0x7f72, (q15_t)0xf424, + (q15_t)0x7f72, (q15_t)0xf41e, (q15_t)0x7f71, (q15_t)0xf417, (q15_t)0x7f71, + (q15_t)0xf411, (q15_t)0x7f70, (q15_t)0xf40b, (q15_t)0x7f70, (q15_t)0xf405, + (q15_t)0x7f6f, (q15_t)0xf3fe, (q15_t)0x7f6e, (q15_t)0xf3f8, (q15_t)0x7f6e, + (q15_t)0xf3f2, (q15_t)0x7f6d, (q15_t)0xf3ec, (q15_t)0x7f6d, (q15_t)0xf3e5, + (q15_t)0x7f6c, (q15_t)0xf3df, (q15_t)0x7f6b, (q15_t)0xf3d9, (q15_t)0x7f6b, + (q15_t)0xf3d2, (q15_t)0x7f6a, (q15_t)0xf3cc, (q15_t)0x7f6a, (q15_t)0xf3c6, + (q15_t)0x7f69, (q15_t)0xf3c0, (q15_t)0x7f68, (q15_t)0xf3b9, (q15_t)0x7f68, + (q15_t)0xf3b3, (q15_t)0x7f67, (q15_t)0xf3ad, (q15_t)0x7f67, (q15_t)0xf3a7, + (q15_t)0x7f66, (q15_t)0xf3a0, (q15_t)0x7f65, (q15_t)0xf39a, (q15_t)0x7f65, + (q15_t)0xf394, (q15_t)0x7f64, (q15_t)0xf38e, (q15_t)0x7f64, (q15_t)0xf387, + (q15_t)0x7f63, (q15_t)0xf381, (q15_t)0x7f62, (q15_t)0xf37b, (q15_t)0x7f62, + (q15_t)0xf375, (q15_t)0x7f61, (q15_t)0xf36e, (q15_t)0x7f60, (q15_t)0xf368, + (q15_t)0x7f60, (q15_t)0xf362, (q15_t)0x7f5f, (q15_t)0xf35c, (q15_t)0x7f5f, + (q15_t)0xf355, (q15_t)0x7f5e, (q15_t)0xf34f, (q15_t)0x7f5d, (q15_t)0xf349, + (q15_t)0x7f5d, (q15_t)0xf343, (q15_t)0x7f5c, (q15_t)0xf33c, (q15_t)0x7f5b, + (q15_t)0xf336, (q15_t)0x7f5b, (q15_t)0xf330, (q15_t)0x7f5a, (q15_t)0xf32a, + (q15_t)0x7f5a, (q15_t)0xf323, (q15_t)0x7f59, (q15_t)0xf31d, (q15_t)0x7f58, + (q15_t)0xf317, (q15_t)0x7f58, (q15_t)0xf311, (q15_t)0x7f57, (q15_t)0xf30a, + (q15_t)0x7f56, (q15_t)0xf304, (q15_t)0x7f56, (q15_t)0xf2fe, (q15_t)0x7f55, + (q15_t)0xf2f8, (q15_t)0x7f55, (q15_t)0xf2f1, (q15_t)0x7f54, (q15_t)0xf2eb, + (q15_t)0x7f53, (q15_t)0xf2e5, (q15_t)0x7f53, (q15_t)0xf2df, (q15_t)0x7f52, + (q15_t)0xf2d8, (q15_t)0x7f51, (q15_t)0xf2d2, (q15_t)0x7f51, (q15_t)0xf2cc, + (q15_t)0x7f50, (q15_t)0xf2c6, (q15_t)0x7f4f, (q15_t)0xf2bf, (q15_t)0x7f4f, + (q15_t)0xf2b9, (q15_t)0x7f4e, (q15_t)0xf2b3, (q15_t)0x7f4d, (q15_t)0xf2ad, + (q15_t)0x7f4d, (q15_t)0xf2a6, (q15_t)0x7f4c, (q15_t)0xf2a0, (q15_t)0x7f4b, + (q15_t)0xf29a, (q15_t)0x7f4b, (q15_t)0xf294, (q15_t)0x7f4a, (q15_t)0xf28d, + (q15_t)0x7f49, (q15_t)0xf287, (q15_t)0x7f49, (q15_t)0xf281, (q15_t)0x7f48, + (q15_t)0xf27b, (q15_t)0x7f47, (q15_t)0xf274, (q15_t)0x7f47, (q15_t)0xf26e, + (q15_t)0x7f46, (q15_t)0xf268, (q15_t)0x7f45, (q15_t)0xf262, (q15_t)0x7f45, + (q15_t)0xf25b, (q15_t)0x7f44, (q15_t)0xf255, (q15_t)0x7f43, (q15_t)0xf24f, + (q15_t)0x7f43, (q15_t)0xf249, (q15_t)0x7f42, (q15_t)0xf242, (q15_t)0x7f41, + (q15_t)0xf23c, (q15_t)0x7f41, (q15_t)0xf236, (q15_t)0x7f40, (q15_t)0xf230, + (q15_t)0x7f3f, (q15_t)0xf229, (q15_t)0x7f3f, (q15_t)0xf223, (q15_t)0x7f3e, + (q15_t)0xf21d, (q15_t)0x7f3d, (q15_t)0xf217, (q15_t)0x7f3d, (q15_t)0xf210, + (q15_t)0x7f3c, (q15_t)0xf20a, (q15_t)0x7f3b, (q15_t)0xf204, (q15_t)0x7f3b, + (q15_t)0xf1fe, (q15_t)0x7f3a, (q15_t)0xf1f7, (q15_t)0x7f39, (q15_t)0xf1f1, + (q15_t)0x7f39, (q15_t)0xf1eb, (q15_t)0x7f38, (q15_t)0xf1e5, (q15_t)0x7f37, + (q15_t)0xf1de, (q15_t)0x7f36, (q15_t)0xf1d8, (q15_t)0x7f36, (q15_t)0xf1d2, + (q15_t)0x7f35, (q15_t)0xf1cc, (q15_t)0x7f34, (q15_t)0xf1c6, (q15_t)0x7f34, + (q15_t)0xf1bf, (q15_t)0x7f33, (q15_t)0xf1b9, (q15_t)0x7f32, (q15_t)0xf1b3, + (q15_t)0x7f32, (q15_t)0xf1ad, (q15_t)0x7f31, (q15_t)0xf1a6, (q15_t)0x7f30, + (q15_t)0xf1a0, (q15_t)0x7f2f, (q15_t)0xf19a, (q15_t)0x7f2f, (q15_t)0xf194, + (q15_t)0x7f2e, (q15_t)0xf18d, (q15_t)0x7f2d, (q15_t)0xf187, (q15_t)0x7f2d, + (q15_t)0xf181, (q15_t)0x7f2c, (q15_t)0xf17b, (q15_t)0x7f2b, (q15_t)0xf174, + (q15_t)0x7f2a, (q15_t)0xf16e, (q15_t)0x7f2a, (q15_t)0xf168, (q15_t)0x7f29, + (q15_t)0xf162, (q15_t)0x7f28, (q15_t)0xf15b, (q15_t)0x7f28, (q15_t)0xf155, + (q15_t)0x7f27, (q15_t)0xf14f, (q15_t)0x7f26, (q15_t)0xf149, (q15_t)0x7f25, + (q15_t)0xf142, (q15_t)0x7f25, (q15_t)0xf13c, (q15_t)0x7f24, (q15_t)0xf136, + (q15_t)0x7f23, (q15_t)0xf130, (q15_t)0x7f23, (q15_t)0xf129, (q15_t)0x7f22, + (q15_t)0xf123, (q15_t)0x7f21, (q15_t)0xf11d, (q15_t)0x7f20, (q15_t)0xf117, + (q15_t)0x7f20, (q15_t)0xf110, (q15_t)0x7f1f, (q15_t)0xf10a, (q15_t)0x7f1e, + (q15_t)0xf104, (q15_t)0x7f1d, (q15_t)0xf0fe, (q15_t)0x7f1d, (q15_t)0xf0f8, + (q15_t)0x7f1c, (q15_t)0xf0f1, (q15_t)0x7f1b, (q15_t)0xf0eb, (q15_t)0x7f1a, + (q15_t)0xf0e5, (q15_t)0x7f1a, (q15_t)0xf0df, (q15_t)0x7f19, (q15_t)0xf0d8, + (q15_t)0x7f18, (q15_t)0xf0d2, (q15_t)0x7f17, (q15_t)0xf0cc, (q15_t)0x7f17, + (q15_t)0xf0c6, (q15_t)0x7f16, (q15_t)0xf0bf, (q15_t)0x7f15, (q15_t)0xf0b9, + (q15_t)0x7f14, (q15_t)0xf0b3, (q15_t)0x7f14, (q15_t)0xf0ad, (q15_t)0x7f13, + (q15_t)0xf0a6, (q15_t)0x7f12, (q15_t)0xf0a0, (q15_t)0x7f11, (q15_t)0xf09a, + (q15_t)0x7f11, (q15_t)0xf094, (q15_t)0x7f10, (q15_t)0xf08d, (q15_t)0x7f0f, + (q15_t)0xf087, (q15_t)0x7f0e, (q15_t)0xf081, (q15_t)0x7f0e, (q15_t)0xf07b, + (q15_t)0x7f0d, (q15_t)0xf075, (q15_t)0x7f0c, (q15_t)0xf06e, (q15_t)0x7f0b, + (q15_t)0xf068, (q15_t)0x7f0b, (q15_t)0xf062, (q15_t)0x7f0a, (q15_t)0xf05c, + (q15_t)0x7f09, (q15_t)0xf055, (q15_t)0x7f08, (q15_t)0xf04f, (q15_t)0x7f08, + (q15_t)0xf049, (q15_t)0x7f07, (q15_t)0xf043, (q15_t)0x7f06, (q15_t)0xf03c, + (q15_t)0x7f05, (q15_t)0xf036, (q15_t)0x7f04, (q15_t)0xf030, (q15_t)0x7f04, + (q15_t)0xf02a, (q15_t)0x7f03, (q15_t)0xf023, (q15_t)0x7f02, (q15_t)0xf01d, + (q15_t)0x7f01, (q15_t)0xf017, (q15_t)0x7f01, (q15_t)0xf011, (q15_t)0x7f00, + (q15_t)0xf00b, (q15_t)0x7eff, (q15_t)0xf004, (q15_t)0x7efe, (q15_t)0xeffe, + (q15_t)0x7efd, (q15_t)0xeff8, (q15_t)0x7efd, (q15_t)0xeff2, (q15_t)0x7efc, + (q15_t)0xefeb, (q15_t)0x7efb, (q15_t)0xefe5, (q15_t)0x7efa, (q15_t)0xefdf, + (q15_t)0x7ef9, (q15_t)0xefd9, (q15_t)0x7ef9, (q15_t)0xefd2, (q15_t)0x7ef8, + (q15_t)0xefcc, (q15_t)0x7ef7, (q15_t)0xefc6, (q15_t)0x7ef6, (q15_t)0xefc0, + (q15_t)0x7ef5, (q15_t)0xefb9, (q15_t)0x7ef5, (q15_t)0xefb3, (q15_t)0x7ef4, + (q15_t)0xefad, (q15_t)0x7ef3, (q15_t)0xefa7, (q15_t)0x7ef2, (q15_t)0xefa1, + (q15_t)0x7ef1, (q15_t)0xef9a, (q15_t)0x7ef1, (q15_t)0xef94, (q15_t)0x7ef0, + (q15_t)0xef8e, (q15_t)0x7eef, (q15_t)0xef88, (q15_t)0x7eee, (q15_t)0xef81, + (q15_t)0x7eed, (q15_t)0xef7b, (q15_t)0x7eed, (q15_t)0xef75, (q15_t)0x7eec, + (q15_t)0xef6f, (q15_t)0x7eeb, (q15_t)0xef68, (q15_t)0x7eea, (q15_t)0xef62, + (q15_t)0x7ee9, (q15_t)0xef5c, (q15_t)0x7ee9, (q15_t)0xef56, (q15_t)0x7ee8, + (q15_t)0xef50, (q15_t)0x7ee7, (q15_t)0xef49, (q15_t)0x7ee6, (q15_t)0xef43, + (q15_t)0x7ee5, (q15_t)0xef3d, (q15_t)0x7ee4, (q15_t)0xef37, (q15_t)0x7ee4, + (q15_t)0xef30, (q15_t)0x7ee3, (q15_t)0xef2a, (q15_t)0x7ee2, (q15_t)0xef24, + (q15_t)0x7ee1, (q15_t)0xef1e, (q15_t)0x7ee0, (q15_t)0xef18, (q15_t)0x7edf, + (q15_t)0xef11, (q15_t)0x7edf, (q15_t)0xef0b, (q15_t)0x7ede, (q15_t)0xef05, + (q15_t)0x7edd, (q15_t)0xeeff, (q15_t)0x7edc, (q15_t)0xeef8, (q15_t)0x7edb, + (q15_t)0xeef2, (q15_t)0x7eda, (q15_t)0xeeec, (q15_t)0x7eda, (q15_t)0xeee6, + (q15_t)0x7ed9, (q15_t)0xeedf, (q15_t)0x7ed8, (q15_t)0xeed9, (q15_t)0x7ed7, + (q15_t)0xeed3, (q15_t)0x7ed6, (q15_t)0xeecd, (q15_t)0x7ed5, (q15_t)0xeec7, + (q15_t)0x7ed5, (q15_t)0xeec0, (q15_t)0x7ed4, (q15_t)0xeeba, (q15_t)0x7ed3, + (q15_t)0xeeb4, (q15_t)0x7ed2, (q15_t)0xeeae, (q15_t)0x7ed1, (q15_t)0xeea7, + (q15_t)0x7ed0, (q15_t)0xeea1, (q15_t)0x7ecf, (q15_t)0xee9b, (q15_t)0x7ecf, + (q15_t)0xee95, (q15_t)0x7ece, (q15_t)0xee8f, (q15_t)0x7ecd, (q15_t)0xee88, + (q15_t)0x7ecc, (q15_t)0xee82, (q15_t)0x7ecb, (q15_t)0xee7c, (q15_t)0x7eca, + (q15_t)0xee76, (q15_t)0x7ec9, (q15_t)0xee6f, (q15_t)0x7ec9, (q15_t)0xee69, + (q15_t)0x7ec8, (q15_t)0xee63, (q15_t)0x7ec7, (q15_t)0xee5d, (q15_t)0x7ec6, + (q15_t)0xee57, (q15_t)0x7ec5, (q15_t)0xee50, (q15_t)0x7ec4, (q15_t)0xee4a, + (q15_t)0x7ec3, (q15_t)0xee44, (q15_t)0x7ec3, (q15_t)0xee3e, (q15_t)0x7ec2, + (q15_t)0xee37, (q15_t)0x7ec1, (q15_t)0xee31, (q15_t)0x7ec0, (q15_t)0xee2b, + (q15_t)0x7ebf, (q15_t)0xee25, (q15_t)0x7ebe, (q15_t)0xee1f, (q15_t)0x7ebd, + (q15_t)0xee18, (q15_t)0x7ebc, (q15_t)0xee12, (q15_t)0x7ebb, (q15_t)0xee0c, + (q15_t)0x7ebb, (q15_t)0xee06, (q15_t)0x7eba, (q15_t)0xedff, (q15_t)0x7eb9, + (q15_t)0xedf9, (q15_t)0x7eb8, (q15_t)0xedf3, (q15_t)0x7eb7, (q15_t)0xeded, + (q15_t)0x7eb6, (q15_t)0xede7, (q15_t)0x7eb5, (q15_t)0xede0, (q15_t)0x7eb4, + (q15_t)0xedda, (q15_t)0x7eb4, (q15_t)0xedd4, (q15_t)0x7eb3, (q15_t)0xedce, + (q15_t)0x7eb2, (q15_t)0xedc7, (q15_t)0x7eb1, (q15_t)0xedc1, (q15_t)0x7eb0, + (q15_t)0xedbb, (q15_t)0x7eaf, (q15_t)0xedb5, (q15_t)0x7eae, (q15_t)0xedaf, + (q15_t)0x7ead, (q15_t)0xeda8, (q15_t)0x7eac, (q15_t)0xeda2, (q15_t)0x7eab, + (q15_t)0xed9c, (q15_t)0x7eab, (q15_t)0xed96, (q15_t)0x7eaa, (q15_t)0xed8f, + (q15_t)0x7ea9, (q15_t)0xed89, (q15_t)0x7ea8, (q15_t)0xed83, (q15_t)0x7ea7, + (q15_t)0xed7d, (q15_t)0x7ea6, (q15_t)0xed77, (q15_t)0x7ea5, (q15_t)0xed70, + (q15_t)0x7ea4, (q15_t)0xed6a, (q15_t)0x7ea3, (q15_t)0xed64, (q15_t)0x7ea2, + (q15_t)0xed5e, (q15_t)0x7ea1, (q15_t)0xed58, (q15_t)0x7ea1, (q15_t)0xed51, + (q15_t)0x7ea0, (q15_t)0xed4b, (q15_t)0x7e9f, (q15_t)0xed45, (q15_t)0x7e9e, + (q15_t)0xed3f, (q15_t)0x7e9d, (q15_t)0xed38, (q15_t)0x7e9c, (q15_t)0xed32, + (q15_t)0x7e9b, (q15_t)0xed2c, (q15_t)0x7e9a, (q15_t)0xed26, (q15_t)0x7e99, + (q15_t)0xed20, (q15_t)0x7e98, (q15_t)0xed19, (q15_t)0x7e97, (q15_t)0xed13, + (q15_t)0x7e96, (q15_t)0xed0d, (q15_t)0x7e95, (q15_t)0xed07, (q15_t)0x7e94, + (q15_t)0xed01, (q15_t)0x7e94, (q15_t)0xecfa, (q15_t)0x7e93, (q15_t)0xecf4, + (q15_t)0x7e92, (q15_t)0xecee, (q15_t)0x7e91, (q15_t)0xece8, (q15_t)0x7e90, + (q15_t)0xece1, (q15_t)0x7e8f, (q15_t)0xecdb, (q15_t)0x7e8e, (q15_t)0xecd5, + (q15_t)0x7e8d, (q15_t)0xeccf, (q15_t)0x7e8c, (q15_t)0xecc9, (q15_t)0x7e8b, + (q15_t)0xecc2, (q15_t)0x7e8a, (q15_t)0xecbc, (q15_t)0x7e89, (q15_t)0xecb6, + (q15_t)0x7e88, (q15_t)0xecb0, (q15_t)0x7e87, (q15_t)0xecaa, (q15_t)0x7e86, + (q15_t)0xeca3, (q15_t)0x7e85, (q15_t)0xec9d, (q15_t)0x7e84, (q15_t)0xec97, + (q15_t)0x7e84, (q15_t)0xec91, (q15_t)0x7e83, (q15_t)0xec8a, (q15_t)0x7e82, + (q15_t)0xec84, (q15_t)0x7e81, (q15_t)0xec7e, (q15_t)0x7e80, (q15_t)0xec78, + (q15_t)0x7e7f, (q15_t)0xec72, (q15_t)0x7e7e, (q15_t)0xec6b, (q15_t)0x7e7d, + (q15_t)0xec65, (q15_t)0x7e7c, (q15_t)0xec5f, (q15_t)0x7e7b, (q15_t)0xec59, + (q15_t)0x7e7a, (q15_t)0xec53, (q15_t)0x7e79, (q15_t)0xec4c, (q15_t)0x7e78, + (q15_t)0xec46, (q15_t)0x7e77, (q15_t)0xec40, (q15_t)0x7e76, (q15_t)0xec3a, + (q15_t)0x7e75, (q15_t)0xec34, (q15_t)0x7e74, (q15_t)0xec2d, (q15_t)0x7e73, + (q15_t)0xec27, (q15_t)0x7e72, (q15_t)0xec21, (q15_t)0x7e71, (q15_t)0xec1b, + (q15_t)0x7e70, (q15_t)0xec15, (q15_t)0x7e6f, (q15_t)0xec0e, (q15_t)0x7e6e, + (q15_t)0xec08, (q15_t)0x7e6d, (q15_t)0xec02, (q15_t)0x7e6c, (q15_t)0xebfc, + (q15_t)0x7e6b, (q15_t)0xebf5, (q15_t)0x7e6a, (q15_t)0xebef, (q15_t)0x7e69, + (q15_t)0xebe9, (q15_t)0x7e68, (q15_t)0xebe3, (q15_t)0x7e67, (q15_t)0xebdd, + (q15_t)0x7e66, (q15_t)0xebd6, (q15_t)0x7e65, (q15_t)0xebd0, (q15_t)0x7e64, + (q15_t)0xebca, (q15_t)0x7e63, (q15_t)0xebc4, (q15_t)0x7e62, (q15_t)0xebbe, + (q15_t)0x7e61, (q15_t)0xebb7, (q15_t)0x7e60, (q15_t)0xebb1, (q15_t)0x7e5f, + (q15_t)0xebab, (q15_t)0x7e5e, (q15_t)0xeba5, (q15_t)0x7e5d, (q15_t)0xeb9f, + (q15_t)0x7e5c, (q15_t)0xeb98, (q15_t)0x7e5b, (q15_t)0xeb92, (q15_t)0x7e5a, + (q15_t)0xeb8c, (q15_t)0x7e59, (q15_t)0xeb86, (q15_t)0x7e58, (q15_t)0xeb80, + (q15_t)0x7e57, (q15_t)0xeb79, (q15_t)0x7e56, (q15_t)0xeb73, (q15_t)0x7e55, + (q15_t)0xeb6d, (q15_t)0x7e54, (q15_t)0xeb67, (q15_t)0x7e53, (q15_t)0xeb61, + (q15_t)0x7e52, (q15_t)0xeb5a, (q15_t)0x7e51, (q15_t)0xeb54, (q15_t)0x7e50, + (q15_t)0xeb4e, (q15_t)0x7e4f, (q15_t)0xeb48, (q15_t)0x7e4e, (q15_t)0xeb42, + (q15_t)0x7e4d, (q15_t)0xeb3b, (q15_t)0x7e4c, (q15_t)0xeb35, (q15_t)0x7e4b, + (q15_t)0xeb2f, (q15_t)0x7e4a, (q15_t)0xeb29, (q15_t)0x7e49, (q15_t)0xeb23, + (q15_t)0x7e48, (q15_t)0xeb1c, (q15_t)0x7e47, (q15_t)0xeb16, (q15_t)0x7e46, + (q15_t)0xeb10, (q15_t)0x7e45, (q15_t)0xeb0a, (q15_t)0x7e44, (q15_t)0xeb04, + (q15_t)0x7e43, (q15_t)0xeafd, (q15_t)0x7e42, (q15_t)0xeaf7, (q15_t)0x7e41, + (q15_t)0xeaf1, (q15_t)0x7e40, (q15_t)0xeaeb, (q15_t)0x7e3f, (q15_t)0xeae5, + (q15_t)0x7e3e, (q15_t)0xeade, (q15_t)0x7e3d, (q15_t)0xead8, (q15_t)0x7e3c, + (q15_t)0xead2, (q15_t)0x7e3b, (q15_t)0xeacc, (q15_t)0x7e3a, (q15_t)0xeac6, + (q15_t)0x7e39, (q15_t)0xeabf, (q15_t)0x7e38, (q15_t)0xeab9, (q15_t)0x7e37, + (q15_t)0xeab3, (q15_t)0x7e35, (q15_t)0xeaad, (q15_t)0x7e34, (q15_t)0xeaa7, + (q15_t)0x7e33, (q15_t)0xeaa0, (q15_t)0x7e32, (q15_t)0xea9a, (q15_t)0x7e31, + (q15_t)0xea94, (q15_t)0x7e30, (q15_t)0xea8e, (q15_t)0x7e2f, (q15_t)0xea88, + (q15_t)0x7e2e, (q15_t)0xea81, (q15_t)0x7e2d, (q15_t)0xea7b, (q15_t)0x7e2c, + (q15_t)0xea75, (q15_t)0x7e2b, (q15_t)0xea6f, (q15_t)0x7e2a, (q15_t)0xea69, + (q15_t)0x7e29, (q15_t)0xea63, (q15_t)0x7e28, (q15_t)0xea5c, (q15_t)0x7e27, + (q15_t)0xea56, (q15_t)0x7e26, (q15_t)0xea50, (q15_t)0x7e25, (q15_t)0xea4a, + (q15_t)0x7e24, (q15_t)0xea44, (q15_t)0x7e22, (q15_t)0xea3d, (q15_t)0x7e21, + (q15_t)0xea37, (q15_t)0x7e20, (q15_t)0xea31, (q15_t)0x7e1f, (q15_t)0xea2b, + (q15_t)0x7e1e, (q15_t)0xea25, (q15_t)0x7e1d, (q15_t)0xea1e, (q15_t)0x7e1c, + (q15_t)0xea18, (q15_t)0x7e1b, (q15_t)0xea12, (q15_t)0x7e1a, (q15_t)0xea0c, + (q15_t)0x7e19, (q15_t)0xea06, (q15_t)0x7e18, (q15_t)0xe9ff, (q15_t)0x7e17, + (q15_t)0xe9f9, (q15_t)0x7e16, (q15_t)0xe9f3, (q15_t)0x7e14, (q15_t)0xe9ed, + (q15_t)0x7e13, (q15_t)0xe9e7, (q15_t)0x7e12, (q15_t)0xe9e1, (q15_t)0x7e11, + (q15_t)0xe9da, (q15_t)0x7e10, (q15_t)0xe9d4, (q15_t)0x7e0f, (q15_t)0xe9ce, + (q15_t)0x7e0e, (q15_t)0xe9c8, (q15_t)0x7e0d, (q15_t)0xe9c2, (q15_t)0x7e0c, + (q15_t)0xe9bb, (q15_t)0x7e0b, (q15_t)0xe9b5, (q15_t)0x7e0a, (q15_t)0xe9af, + (q15_t)0x7e08, (q15_t)0xe9a9, (q15_t)0x7e07, (q15_t)0xe9a3, (q15_t)0x7e06, + (q15_t)0xe99c, (q15_t)0x7e05, (q15_t)0xe996, (q15_t)0x7e04, (q15_t)0xe990, + (q15_t)0x7e03, (q15_t)0xe98a, (q15_t)0x7e02, (q15_t)0xe984, (q15_t)0x7e01, + (q15_t)0xe97e, (q15_t)0x7e00, (q15_t)0xe977, (q15_t)0x7dff, (q15_t)0xe971, + (q15_t)0x7dfd, (q15_t)0xe96b, (q15_t)0x7dfc, (q15_t)0xe965, (q15_t)0x7dfb, + (q15_t)0xe95f, (q15_t)0x7dfa, (q15_t)0xe958, (q15_t)0x7df9, (q15_t)0xe952, + (q15_t)0x7df8, (q15_t)0xe94c, (q15_t)0x7df7, (q15_t)0xe946, (q15_t)0x7df6, + (q15_t)0xe940, (q15_t)0x7df5, (q15_t)0xe93a, (q15_t)0x7df3, (q15_t)0xe933, + (q15_t)0x7df2, (q15_t)0xe92d, (q15_t)0x7df1, (q15_t)0xe927, (q15_t)0x7df0, + (q15_t)0xe921, (q15_t)0x7def, (q15_t)0xe91b, (q15_t)0x7dee, (q15_t)0xe914, + (q15_t)0x7ded, (q15_t)0xe90e, (q15_t)0x7dec, (q15_t)0xe908, (q15_t)0x7dea, + (q15_t)0xe902, (q15_t)0x7de9, (q15_t)0xe8fc, (q15_t)0x7de8, (q15_t)0xe8f6, + (q15_t)0x7de7, (q15_t)0xe8ef, (q15_t)0x7de6, (q15_t)0xe8e9, (q15_t)0x7de5, + (q15_t)0xe8e3, (q15_t)0x7de4, (q15_t)0xe8dd, (q15_t)0x7de2, (q15_t)0xe8d7, + (q15_t)0x7de1, (q15_t)0xe8d0, (q15_t)0x7de0, (q15_t)0xe8ca, (q15_t)0x7ddf, + (q15_t)0xe8c4, (q15_t)0x7dde, (q15_t)0xe8be, (q15_t)0x7ddd, (q15_t)0xe8b8, + (q15_t)0x7ddc, (q15_t)0xe8b2, (q15_t)0x7dda, (q15_t)0xe8ab, (q15_t)0x7dd9, + (q15_t)0xe8a5, (q15_t)0x7dd8, (q15_t)0xe89f, (q15_t)0x7dd7, (q15_t)0xe899, + (q15_t)0x7dd6, (q15_t)0xe893, (q15_t)0x7dd5, (q15_t)0xe88c, (q15_t)0x7dd4, + (q15_t)0xe886, (q15_t)0x7dd2, (q15_t)0xe880, (q15_t)0x7dd1, (q15_t)0xe87a, + (q15_t)0x7dd0, (q15_t)0xe874, (q15_t)0x7dcf, (q15_t)0xe86e, (q15_t)0x7dce, + (q15_t)0xe867, (q15_t)0x7dcd, (q15_t)0xe861, (q15_t)0x7dcc, (q15_t)0xe85b, + (q15_t)0x7dca, (q15_t)0xe855, (q15_t)0x7dc9, (q15_t)0xe84f, (q15_t)0x7dc8, + (q15_t)0xe849, (q15_t)0x7dc7, (q15_t)0xe842, (q15_t)0x7dc6, (q15_t)0xe83c, + (q15_t)0x7dc5, (q15_t)0xe836, (q15_t)0x7dc3, (q15_t)0xe830, (q15_t)0x7dc2, + (q15_t)0xe82a, (q15_t)0x7dc1, (q15_t)0xe823, (q15_t)0x7dc0, (q15_t)0xe81d, + (q15_t)0x7dbf, (q15_t)0xe817, (q15_t)0x7dbd, (q15_t)0xe811, (q15_t)0x7dbc, + (q15_t)0xe80b, (q15_t)0x7dbb, (q15_t)0xe805, (q15_t)0x7dba, (q15_t)0xe7fe, + (q15_t)0x7db9, (q15_t)0xe7f8, (q15_t)0x7db8, (q15_t)0xe7f2, (q15_t)0x7db6, + (q15_t)0xe7ec, (q15_t)0x7db5, (q15_t)0xe7e6, (q15_t)0x7db4, (q15_t)0xe7e0, + (q15_t)0x7db3, (q15_t)0xe7d9, (q15_t)0x7db2, (q15_t)0xe7d3, (q15_t)0x7db0, + (q15_t)0xe7cd, (q15_t)0x7daf, (q15_t)0xe7c7, (q15_t)0x7dae, (q15_t)0xe7c1, + (q15_t)0x7dad, (q15_t)0xe7bb, (q15_t)0x7dac, (q15_t)0xe7b4, (q15_t)0x7dab, + (q15_t)0xe7ae, (q15_t)0x7da9, (q15_t)0xe7a8, (q15_t)0x7da8, (q15_t)0xe7a2, + (q15_t)0x7da7, (q15_t)0xe79c, (q15_t)0x7da6, (q15_t)0xe796, (q15_t)0x7da5, + (q15_t)0xe78f, (q15_t)0x7da3, (q15_t)0xe789, (q15_t)0x7da2, (q15_t)0xe783, + (q15_t)0x7da1, (q15_t)0xe77d, (q15_t)0x7da0, (q15_t)0xe777, (q15_t)0x7d9f, + (q15_t)0xe771, (q15_t)0x7d9d, (q15_t)0xe76a, (q15_t)0x7d9c, (q15_t)0xe764, + (q15_t)0x7d9b, (q15_t)0xe75e, (q15_t)0x7d9a, (q15_t)0xe758, (q15_t)0x7d98, + (q15_t)0xe752, (q15_t)0x7d97, (q15_t)0xe74c, (q15_t)0x7d96, (q15_t)0xe745, + (q15_t)0x7d95, (q15_t)0xe73f, (q15_t)0x7d94, (q15_t)0xe739, (q15_t)0x7d92, + (q15_t)0xe733, (q15_t)0x7d91, (q15_t)0xe72d, (q15_t)0x7d90, (q15_t)0xe727, + (q15_t)0x7d8f, (q15_t)0xe720, (q15_t)0x7d8e, (q15_t)0xe71a, (q15_t)0x7d8c, + (q15_t)0xe714, (q15_t)0x7d8b, (q15_t)0xe70e, (q15_t)0x7d8a, (q15_t)0xe708, + (q15_t)0x7d89, (q15_t)0xe702, (q15_t)0x7d87, (q15_t)0xe6fb, (q15_t)0x7d86, + (q15_t)0xe6f5, (q15_t)0x7d85, (q15_t)0xe6ef, (q15_t)0x7d84, (q15_t)0xe6e9, + (q15_t)0x7d82, (q15_t)0xe6e3, (q15_t)0x7d81, (q15_t)0xe6dd, (q15_t)0x7d80, + (q15_t)0xe6d6, (q15_t)0x7d7f, (q15_t)0xe6d0, (q15_t)0x7d7e, (q15_t)0xe6ca, + (q15_t)0x7d7c, (q15_t)0xe6c4, (q15_t)0x7d7b, (q15_t)0xe6be, (q15_t)0x7d7a, + (q15_t)0xe6b8, (q15_t)0x7d79, (q15_t)0xe6b2, (q15_t)0x7d77, (q15_t)0xe6ab, + (q15_t)0x7d76, (q15_t)0xe6a5, (q15_t)0x7d75, (q15_t)0xe69f, (q15_t)0x7d74, + (q15_t)0xe699, (q15_t)0x7d72, (q15_t)0xe693, (q15_t)0x7d71, (q15_t)0xe68d, + (q15_t)0x7d70, (q15_t)0xe686, (q15_t)0x7d6f, (q15_t)0xe680, (q15_t)0x7d6d, + (q15_t)0xe67a, (q15_t)0x7d6c, (q15_t)0xe674, (q15_t)0x7d6b, (q15_t)0xe66e, + (q15_t)0x7d6a, (q15_t)0xe668, (q15_t)0x7d68, (q15_t)0xe661, (q15_t)0x7d67, + (q15_t)0xe65b, (q15_t)0x7d66, (q15_t)0xe655, (q15_t)0x7d65, (q15_t)0xe64f, + (q15_t)0x7d63, (q15_t)0xe649, (q15_t)0x7d62, (q15_t)0xe643, (q15_t)0x7d61, + (q15_t)0xe63d, (q15_t)0x7d60, (q15_t)0xe636, (q15_t)0x7d5e, (q15_t)0xe630, + (q15_t)0x7d5d, (q15_t)0xe62a, (q15_t)0x7d5c, (q15_t)0xe624, (q15_t)0x7d5a, + (q15_t)0xe61e, (q15_t)0x7d59, (q15_t)0xe618, (q15_t)0x7d58, (q15_t)0xe611, + (q15_t)0x7d57, (q15_t)0xe60b, (q15_t)0x7d55, (q15_t)0xe605, (q15_t)0x7d54, + (q15_t)0xe5ff, (q15_t)0x7d53, (q15_t)0xe5f9, (q15_t)0x7d52, (q15_t)0xe5f3, + (q15_t)0x7d50, (q15_t)0xe5ed, (q15_t)0x7d4f, (q15_t)0xe5e6, (q15_t)0x7d4e, + (q15_t)0xe5e0, (q15_t)0x7d4c, (q15_t)0xe5da, (q15_t)0x7d4b, (q15_t)0xe5d4, + (q15_t)0x7d4a, (q15_t)0xe5ce, (q15_t)0x7d49, (q15_t)0xe5c8, (q15_t)0x7d47, + (q15_t)0xe5c2, (q15_t)0x7d46, (q15_t)0xe5bb, (q15_t)0x7d45, (q15_t)0xe5b5, + (q15_t)0x7d43, (q15_t)0xe5af, (q15_t)0x7d42, (q15_t)0xe5a9, (q15_t)0x7d41, + (q15_t)0xe5a3, (q15_t)0x7d3f, (q15_t)0xe59d, (q15_t)0x7d3e, (q15_t)0xe596, + (q15_t)0x7d3d, (q15_t)0xe590, (q15_t)0x7d3c, (q15_t)0xe58a, (q15_t)0x7d3a, + (q15_t)0xe584, (q15_t)0x7d39, (q15_t)0xe57e, (q15_t)0x7d38, (q15_t)0xe578, + (q15_t)0x7d36, (q15_t)0xe572, (q15_t)0x7d35, (q15_t)0xe56b, (q15_t)0x7d34, + (q15_t)0xe565, (q15_t)0x7d32, (q15_t)0xe55f, (q15_t)0x7d31, (q15_t)0xe559, + (q15_t)0x7d30, (q15_t)0xe553, (q15_t)0x7d2f, (q15_t)0xe54d, (q15_t)0x7d2d, + (q15_t)0xe547, (q15_t)0x7d2c, (q15_t)0xe540, (q15_t)0x7d2b, (q15_t)0xe53a, + (q15_t)0x7d29, (q15_t)0xe534, (q15_t)0x7d28, (q15_t)0xe52e, (q15_t)0x7d27, + (q15_t)0xe528, (q15_t)0x7d25, (q15_t)0xe522, (q15_t)0x7d24, (q15_t)0xe51c, + (q15_t)0x7d23, (q15_t)0xe515, (q15_t)0x7d21, (q15_t)0xe50f, (q15_t)0x7d20, + (q15_t)0xe509, (q15_t)0x7d1f, (q15_t)0xe503, (q15_t)0x7d1d, (q15_t)0xe4fd, + (q15_t)0x7d1c, (q15_t)0xe4f7, (q15_t)0x7d1b, (q15_t)0xe4f1, (q15_t)0x7d19, + (q15_t)0xe4ea, (q15_t)0x7d18, (q15_t)0xe4e4, (q15_t)0x7d17, (q15_t)0xe4de, + (q15_t)0x7d15, (q15_t)0xe4d8, (q15_t)0x7d14, (q15_t)0xe4d2, (q15_t)0x7d13, + (q15_t)0xe4cc, (q15_t)0x7d11, (q15_t)0xe4c6, (q15_t)0x7d10, (q15_t)0xe4bf, + (q15_t)0x7d0f, (q15_t)0xe4b9, (q15_t)0x7d0d, (q15_t)0xe4b3, (q15_t)0x7d0c, + (q15_t)0xe4ad, (q15_t)0x7d0b, (q15_t)0xe4a7, (q15_t)0x7d09, (q15_t)0xe4a1, + (q15_t)0x7d08, (q15_t)0xe49b, (q15_t)0x7d07, (q15_t)0xe494, (q15_t)0x7d05, + (q15_t)0xe48e, (q15_t)0x7d04, (q15_t)0xe488, (q15_t)0x7d03, (q15_t)0xe482, + (q15_t)0x7d01, (q15_t)0xe47c, (q15_t)0x7d00, (q15_t)0xe476, (q15_t)0x7cff, + (q15_t)0xe470, (q15_t)0x7cfd, (q15_t)0xe46a, (q15_t)0x7cfc, (q15_t)0xe463, + (q15_t)0x7cfb, (q15_t)0xe45d, (q15_t)0x7cf9, (q15_t)0xe457, (q15_t)0x7cf8, + (q15_t)0xe451, (q15_t)0x7cf6, (q15_t)0xe44b, (q15_t)0x7cf5, (q15_t)0xe445, + (q15_t)0x7cf4, (q15_t)0xe43f, (q15_t)0x7cf2, (q15_t)0xe438, (q15_t)0x7cf1, + (q15_t)0xe432, (q15_t)0x7cf0, (q15_t)0xe42c, (q15_t)0x7cee, (q15_t)0xe426, + (q15_t)0x7ced, (q15_t)0xe420, (q15_t)0x7cec, (q15_t)0xe41a, (q15_t)0x7cea, + (q15_t)0xe414, (q15_t)0x7ce9, (q15_t)0xe40e, (q15_t)0x7ce7, (q15_t)0xe407, + (q15_t)0x7ce6, (q15_t)0xe401, (q15_t)0x7ce5, (q15_t)0xe3fb, (q15_t)0x7ce3, + (q15_t)0xe3f5, (q15_t)0x7ce2, (q15_t)0xe3ef, (q15_t)0x7ce1, (q15_t)0xe3e9, + (q15_t)0x7cdf, (q15_t)0xe3e3, (q15_t)0x7cde, (q15_t)0xe3dc, (q15_t)0x7cdc, + (q15_t)0xe3d6, (q15_t)0x7cdb, (q15_t)0xe3d0, (q15_t)0x7cda, (q15_t)0xe3ca, + (q15_t)0x7cd8, (q15_t)0xe3c4, (q15_t)0x7cd7, (q15_t)0xe3be, (q15_t)0x7cd5, + (q15_t)0xe3b8, (q15_t)0x7cd4, (q15_t)0xe3b2, (q15_t)0x7cd3, (q15_t)0xe3ab, + (q15_t)0x7cd1, (q15_t)0xe3a5, (q15_t)0x7cd0, (q15_t)0xe39f, (q15_t)0x7ccf, + (q15_t)0xe399, (q15_t)0x7ccd, (q15_t)0xe393, (q15_t)0x7ccc, (q15_t)0xe38d, + (q15_t)0x7cca, (q15_t)0xe387, (q15_t)0x7cc9, (q15_t)0xe381, (q15_t)0x7cc8, + (q15_t)0xe37a, (q15_t)0x7cc6, (q15_t)0xe374, (q15_t)0x7cc5, (q15_t)0xe36e, + (q15_t)0x7cc3, (q15_t)0xe368, (q15_t)0x7cc2, (q15_t)0xe362, (q15_t)0x7cc1, + (q15_t)0xe35c, (q15_t)0x7cbf, (q15_t)0xe356, (q15_t)0x7cbe, (q15_t)0xe350, + (q15_t)0x7cbc, (q15_t)0xe349, (q15_t)0x7cbb, (q15_t)0xe343, (q15_t)0x7cb9, + (q15_t)0xe33d, (q15_t)0x7cb8, (q15_t)0xe337, (q15_t)0x7cb7, (q15_t)0xe331, + (q15_t)0x7cb5, (q15_t)0xe32b, (q15_t)0x7cb4, (q15_t)0xe325, (q15_t)0x7cb2, + (q15_t)0xe31f, (q15_t)0x7cb1, (q15_t)0xe318, (q15_t)0x7cb0, (q15_t)0xe312, + (q15_t)0x7cae, (q15_t)0xe30c, (q15_t)0x7cad, (q15_t)0xe306, (q15_t)0x7cab, + (q15_t)0xe300, (q15_t)0x7caa, (q15_t)0xe2fa, (q15_t)0x7ca8, (q15_t)0xe2f4, + (q15_t)0x7ca7, (q15_t)0xe2ee, (q15_t)0x7ca6, (q15_t)0xe2e8, (q15_t)0x7ca4, + (q15_t)0xe2e1, (q15_t)0x7ca3, (q15_t)0xe2db, (q15_t)0x7ca1, (q15_t)0xe2d5, + (q15_t)0x7ca0, (q15_t)0xe2cf, (q15_t)0x7c9e, (q15_t)0xe2c9, (q15_t)0x7c9d, + (q15_t)0xe2c3, (q15_t)0x7c9c, (q15_t)0xe2bd, (q15_t)0x7c9a, (q15_t)0xe2b7, + (q15_t)0x7c99, (q15_t)0xe2b0, (q15_t)0x7c97, (q15_t)0xe2aa, (q15_t)0x7c96, + (q15_t)0xe2a4, (q15_t)0x7c94, (q15_t)0xe29e, (q15_t)0x7c93, (q15_t)0xe298, + (q15_t)0x7c91, (q15_t)0xe292, (q15_t)0x7c90, (q15_t)0xe28c, (q15_t)0x7c8f, + (q15_t)0xe286, (q15_t)0x7c8d, (q15_t)0xe280, (q15_t)0x7c8c, (q15_t)0xe279, + (q15_t)0x7c8a, (q15_t)0xe273, (q15_t)0x7c89, (q15_t)0xe26d, (q15_t)0x7c87, + (q15_t)0xe267, (q15_t)0x7c86, (q15_t)0xe261, (q15_t)0x7c84, (q15_t)0xe25b, + (q15_t)0x7c83, (q15_t)0xe255, (q15_t)0x7c82, (q15_t)0xe24f, (q15_t)0x7c80, + (q15_t)0xe249, (q15_t)0x7c7f, (q15_t)0xe242, (q15_t)0x7c7d, (q15_t)0xe23c, + (q15_t)0x7c7c, (q15_t)0xe236, (q15_t)0x7c7a, (q15_t)0xe230, (q15_t)0x7c79, + (q15_t)0xe22a, (q15_t)0x7c77, (q15_t)0xe224, (q15_t)0x7c76, (q15_t)0xe21e, + (q15_t)0x7c74, (q15_t)0xe218, (q15_t)0x7c73, (q15_t)0xe212, (q15_t)0x7c71, + (q15_t)0xe20b, (q15_t)0x7c70, (q15_t)0xe205, (q15_t)0x7c6e, (q15_t)0xe1ff, + (q15_t)0x7c6d, (q15_t)0xe1f9, (q15_t)0x7c6c, (q15_t)0xe1f3, (q15_t)0x7c6a, + (q15_t)0xe1ed, (q15_t)0x7c69, (q15_t)0xe1e7, (q15_t)0x7c67, (q15_t)0xe1e1, + (q15_t)0x7c66, (q15_t)0xe1db, (q15_t)0x7c64, (q15_t)0xe1d4, (q15_t)0x7c63, + (q15_t)0xe1ce, (q15_t)0x7c61, (q15_t)0xe1c8, (q15_t)0x7c60, (q15_t)0xe1c2, + (q15_t)0x7c5e, (q15_t)0xe1bc, (q15_t)0x7c5d, (q15_t)0xe1b6, (q15_t)0x7c5b, + (q15_t)0xe1b0, (q15_t)0x7c5a, (q15_t)0xe1aa, (q15_t)0x7c58, (q15_t)0xe1a4, + (q15_t)0x7c57, (q15_t)0xe19e, (q15_t)0x7c55, (q15_t)0xe197, (q15_t)0x7c54, + (q15_t)0xe191, (q15_t)0x7c52, (q15_t)0xe18b, (q15_t)0x7c51, (q15_t)0xe185, + (q15_t)0x7c4f, (q15_t)0xe17f, (q15_t)0x7c4e, (q15_t)0xe179, (q15_t)0x7c4c, + (q15_t)0xe173, (q15_t)0x7c4b, (q15_t)0xe16d, (q15_t)0x7c49, (q15_t)0xe167, + (q15_t)0x7c48, (q15_t)0xe160, (q15_t)0x7c46, (q15_t)0xe15a, (q15_t)0x7c45, + (q15_t)0xe154, (q15_t)0x7c43, (q15_t)0xe14e, (q15_t)0x7c42, (q15_t)0xe148, + (q15_t)0x7c40, (q15_t)0xe142, (q15_t)0x7c3f, (q15_t)0xe13c, (q15_t)0x7c3d, + (q15_t)0xe136, (q15_t)0x7c3c, (q15_t)0xe130, (q15_t)0x7c3a, (q15_t)0xe12a, + (q15_t)0x7c39, (q15_t)0xe123, (q15_t)0x7c37, (q15_t)0xe11d, (q15_t)0x7c36, + (q15_t)0xe117, (q15_t)0x7c34, (q15_t)0xe111, (q15_t)0x7c33, (q15_t)0xe10b, + (q15_t)0x7c31, (q15_t)0xe105, (q15_t)0x7c30, (q15_t)0xe0ff, (q15_t)0x7c2e, + (q15_t)0xe0f9, (q15_t)0x7c2d, (q15_t)0xe0f3, (q15_t)0x7c2b, (q15_t)0xe0ed, + (q15_t)0x7c29, (q15_t)0xe0e7, (q15_t)0x7c28, (q15_t)0xe0e0, (q15_t)0x7c26, + (q15_t)0xe0da, (q15_t)0x7c25, (q15_t)0xe0d4, (q15_t)0x7c23, (q15_t)0xe0ce, + (q15_t)0x7c22, (q15_t)0xe0c8, (q15_t)0x7c20, (q15_t)0xe0c2, (q15_t)0x7c1f, + (q15_t)0xe0bc, (q15_t)0x7c1d, (q15_t)0xe0b6, (q15_t)0x7c1c, (q15_t)0xe0b0, + (q15_t)0x7c1a, (q15_t)0xe0aa, (q15_t)0x7c19, (q15_t)0xe0a3, (q15_t)0x7c17, + (q15_t)0xe09d, (q15_t)0x7c16, (q15_t)0xe097, (q15_t)0x7c14, (q15_t)0xe091, + (q15_t)0x7c12, (q15_t)0xe08b, (q15_t)0x7c11, (q15_t)0xe085, (q15_t)0x7c0f, + (q15_t)0xe07f, (q15_t)0x7c0e, (q15_t)0xe079, (q15_t)0x7c0c, (q15_t)0xe073, + (q15_t)0x7c0b, (q15_t)0xe06d, (q15_t)0x7c09, (q15_t)0xe067, (q15_t)0x7c08, + (q15_t)0xe061, (q15_t)0x7c06, (q15_t)0xe05a, (q15_t)0x7c05, (q15_t)0xe054, + (q15_t)0x7c03, (q15_t)0xe04e, (q15_t)0x7c01, (q15_t)0xe048, (q15_t)0x7c00, + (q15_t)0xe042, (q15_t)0x7bfe, (q15_t)0xe03c, (q15_t)0x7bfd, (q15_t)0xe036, + (q15_t)0x7bfb, (q15_t)0xe030, (q15_t)0x7bfa, (q15_t)0xe02a, (q15_t)0x7bf8, + (q15_t)0xe024, (q15_t)0x7bf6, (q15_t)0xe01e, (q15_t)0x7bf5, (q15_t)0xe017, + (q15_t)0x7bf3, (q15_t)0xe011, (q15_t)0x7bf2, (q15_t)0xe00b, (q15_t)0x7bf0, + (q15_t)0xe005, (q15_t)0x7bef, (q15_t)0xdfff, (q15_t)0x7bed, (q15_t)0xdff9, + (q15_t)0x7beb, (q15_t)0xdff3, (q15_t)0x7bea, (q15_t)0xdfed, (q15_t)0x7be8, + (q15_t)0xdfe7, (q15_t)0x7be7, (q15_t)0xdfe1, (q15_t)0x7be5, (q15_t)0xdfdb, + (q15_t)0x7be4, (q15_t)0xdfd5, (q15_t)0x7be2, (q15_t)0xdfce, (q15_t)0x7be0, + (q15_t)0xdfc8, (q15_t)0x7bdf, (q15_t)0xdfc2, (q15_t)0x7bdd, (q15_t)0xdfbc, + (q15_t)0x7bdc, (q15_t)0xdfb6, (q15_t)0x7bda, (q15_t)0xdfb0, (q15_t)0x7bd9, + (q15_t)0xdfaa, (q15_t)0x7bd7, (q15_t)0xdfa4, (q15_t)0x7bd5, (q15_t)0xdf9e, + (q15_t)0x7bd4, (q15_t)0xdf98, (q15_t)0x7bd2, (q15_t)0xdf92, (q15_t)0x7bd1, + (q15_t)0xdf8c, (q15_t)0x7bcf, (q15_t)0xdf86, (q15_t)0x7bcd, (q15_t)0xdf7f, + (q15_t)0x7bcc, (q15_t)0xdf79, (q15_t)0x7bca, (q15_t)0xdf73, (q15_t)0x7bc9, + (q15_t)0xdf6d, (q15_t)0x7bc7, (q15_t)0xdf67, (q15_t)0x7bc5, (q15_t)0xdf61, + (q15_t)0x7bc4, (q15_t)0xdf5b, (q15_t)0x7bc2, (q15_t)0xdf55, (q15_t)0x7bc1, + (q15_t)0xdf4f, (q15_t)0x7bbf, (q15_t)0xdf49, (q15_t)0x7bbd, (q15_t)0xdf43, + (q15_t)0x7bbc, (q15_t)0xdf3d, (q15_t)0x7bba, (q15_t)0xdf37, (q15_t)0x7bb9, + (q15_t)0xdf30, (q15_t)0x7bb7, (q15_t)0xdf2a, (q15_t)0x7bb5, (q15_t)0xdf24, + (q15_t)0x7bb4, (q15_t)0xdf1e, (q15_t)0x7bb2, (q15_t)0xdf18, (q15_t)0x7bb0, + (q15_t)0xdf12, (q15_t)0x7baf, (q15_t)0xdf0c, (q15_t)0x7bad, (q15_t)0xdf06, + (q15_t)0x7bac, (q15_t)0xdf00, (q15_t)0x7baa, (q15_t)0xdefa, (q15_t)0x7ba8, + (q15_t)0xdef4, (q15_t)0x7ba7, (q15_t)0xdeee, (q15_t)0x7ba5, (q15_t)0xdee8, + (q15_t)0x7ba3, (q15_t)0xdee2, (q15_t)0x7ba2, (q15_t)0xdedb, (q15_t)0x7ba0, + (q15_t)0xded5, (q15_t)0x7b9f, (q15_t)0xdecf, (q15_t)0x7b9d, (q15_t)0xdec9, + (q15_t)0x7b9b, (q15_t)0xdec3, (q15_t)0x7b9a, (q15_t)0xdebd, (q15_t)0x7b98, + (q15_t)0xdeb7, (q15_t)0x7b96, (q15_t)0xdeb1, (q15_t)0x7b95, (q15_t)0xdeab, + (q15_t)0x7b93, (q15_t)0xdea5, (q15_t)0x7b92, (q15_t)0xde9f, (q15_t)0x7b90, + (q15_t)0xde99, (q15_t)0x7b8e, (q15_t)0xde93, (q15_t)0x7b8d, (q15_t)0xde8d, + (q15_t)0x7b8b, (q15_t)0xde87, (q15_t)0x7b89, (q15_t)0xde80, (q15_t)0x7b88, + (q15_t)0xde7a, (q15_t)0x7b86, (q15_t)0xde74, (q15_t)0x7b84, (q15_t)0xde6e, + (q15_t)0x7b83, (q15_t)0xde68, (q15_t)0x7b81, (q15_t)0xde62, (q15_t)0x7b7f, + (q15_t)0xde5c, (q15_t)0x7b7e, (q15_t)0xde56, (q15_t)0x7b7c, (q15_t)0xde50, + (q15_t)0x7b7a, (q15_t)0xde4a, (q15_t)0x7b79, (q15_t)0xde44, (q15_t)0x7b77, + (q15_t)0xde3e, (q15_t)0x7b76, (q15_t)0xde38, (q15_t)0x7b74, (q15_t)0xde32, + (q15_t)0x7b72, (q15_t)0xde2c, (q15_t)0x7b71, (q15_t)0xde26, (q15_t)0x7b6f, + (q15_t)0xde1f, (q15_t)0x7b6d, (q15_t)0xde19, (q15_t)0x7b6c, (q15_t)0xde13, + (q15_t)0x7b6a, (q15_t)0xde0d, (q15_t)0x7b68, (q15_t)0xde07, (q15_t)0x7b67, + (q15_t)0xde01, (q15_t)0x7b65, (q15_t)0xddfb, (q15_t)0x7b63, (q15_t)0xddf5, + (q15_t)0x7b62, (q15_t)0xddef, (q15_t)0x7b60, (q15_t)0xdde9, (q15_t)0x7b5e, + (q15_t)0xdde3, (q15_t)0x7b5d, (q15_t)0xdddd, (q15_t)0x7b5b, (q15_t)0xddd7, + (q15_t)0x7b59, (q15_t)0xddd1, (q15_t)0x7b57, (q15_t)0xddcb, (q15_t)0x7b56, + (q15_t)0xddc5, (q15_t)0x7b54, (q15_t)0xddbf, (q15_t)0x7b52, (q15_t)0xddb9, + (q15_t)0x7b51, (q15_t)0xddb2, (q15_t)0x7b4f, (q15_t)0xddac, (q15_t)0x7b4d, + (q15_t)0xdda6, (q15_t)0x7b4c, (q15_t)0xdda0, (q15_t)0x7b4a, (q15_t)0xdd9a, + (q15_t)0x7b48, (q15_t)0xdd94, (q15_t)0x7b47, (q15_t)0xdd8e, (q15_t)0x7b45, + (q15_t)0xdd88, (q15_t)0x7b43, (q15_t)0xdd82, (q15_t)0x7b42, (q15_t)0xdd7c, + (q15_t)0x7b40, (q15_t)0xdd76, (q15_t)0x7b3e, (q15_t)0xdd70, (q15_t)0x7b3c, + (q15_t)0xdd6a, (q15_t)0x7b3b, (q15_t)0xdd64, (q15_t)0x7b39, (q15_t)0xdd5e, + (q15_t)0x7b37, (q15_t)0xdd58, (q15_t)0x7b36, (q15_t)0xdd52, (q15_t)0x7b34, + (q15_t)0xdd4c, (q15_t)0x7b32, (q15_t)0xdd46, (q15_t)0x7b31, (q15_t)0xdd40, + (q15_t)0x7b2f, (q15_t)0xdd39, (q15_t)0x7b2d, (q15_t)0xdd33, (q15_t)0x7b2b, + (q15_t)0xdd2d, (q15_t)0x7b2a, (q15_t)0xdd27, (q15_t)0x7b28, (q15_t)0xdd21, + (q15_t)0x7b26, (q15_t)0xdd1b, (q15_t)0x7b25, (q15_t)0xdd15, (q15_t)0x7b23, + (q15_t)0xdd0f, (q15_t)0x7b21, (q15_t)0xdd09, (q15_t)0x7b1f, (q15_t)0xdd03, + (q15_t)0x7b1e, (q15_t)0xdcfd, (q15_t)0x7b1c, (q15_t)0xdcf7, (q15_t)0x7b1a, + (q15_t)0xdcf1, (q15_t)0x7b19, (q15_t)0xdceb, (q15_t)0x7b17, (q15_t)0xdce5, + (q15_t)0x7b15, (q15_t)0xdcdf, (q15_t)0x7b13, (q15_t)0xdcd9, (q15_t)0x7b12, + (q15_t)0xdcd3, (q15_t)0x7b10, (q15_t)0xdccd, (q15_t)0x7b0e, (q15_t)0xdcc7, + (q15_t)0x7b0c, (q15_t)0xdcc1, (q15_t)0x7b0b, (q15_t)0xdcbb, (q15_t)0x7b09, + (q15_t)0xdcb5, (q15_t)0x7b07, (q15_t)0xdcae, (q15_t)0x7b06, (q15_t)0xdca8, + (q15_t)0x7b04, (q15_t)0xdca2, (q15_t)0x7b02, (q15_t)0xdc9c, (q15_t)0x7b00, + (q15_t)0xdc96, (q15_t)0x7aff, (q15_t)0xdc90, (q15_t)0x7afd, (q15_t)0xdc8a, + (q15_t)0x7afb, (q15_t)0xdc84, (q15_t)0x7af9, (q15_t)0xdc7e, (q15_t)0x7af8, + (q15_t)0xdc78, (q15_t)0x7af6, (q15_t)0xdc72, (q15_t)0x7af4, (q15_t)0xdc6c, + (q15_t)0x7af2, (q15_t)0xdc66, (q15_t)0x7af1, (q15_t)0xdc60, (q15_t)0x7aef, + (q15_t)0xdc5a, (q15_t)0x7aed, (q15_t)0xdc54, (q15_t)0x7aeb, (q15_t)0xdc4e, + (q15_t)0x7aea, (q15_t)0xdc48, (q15_t)0x7ae8, (q15_t)0xdc42, (q15_t)0x7ae6, + (q15_t)0xdc3c, (q15_t)0x7ae4, (q15_t)0xdc36, (q15_t)0x7ae3, (q15_t)0xdc30, + (q15_t)0x7ae1, (q15_t)0xdc2a, (q15_t)0x7adf, (q15_t)0xdc24, (q15_t)0x7add, + (q15_t)0xdc1e, (q15_t)0x7adc, (q15_t)0xdc18, (q15_t)0x7ada, (q15_t)0xdc12, + (q15_t)0x7ad8, (q15_t)0xdc0c, (q15_t)0x7ad6, (q15_t)0xdc06, (q15_t)0x7ad5, + (q15_t)0xdbff, (q15_t)0x7ad3, (q15_t)0xdbf9, (q15_t)0x7ad1, (q15_t)0xdbf3, + (q15_t)0x7acf, (q15_t)0xdbed, (q15_t)0x7acd, (q15_t)0xdbe7, (q15_t)0x7acc, + (q15_t)0xdbe1, (q15_t)0x7aca, (q15_t)0xdbdb, (q15_t)0x7ac8, (q15_t)0xdbd5, + (q15_t)0x7ac6, (q15_t)0xdbcf, (q15_t)0x7ac5, (q15_t)0xdbc9, (q15_t)0x7ac3, + (q15_t)0xdbc3, (q15_t)0x7ac1, (q15_t)0xdbbd, (q15_t)0x7abf, (q15_t)0xdbb7, + (q15_t)0x7abd, (q15_t)0xdbb1, (q15_t)0x7abc, (q15_t)0xdbab, (q15_t)0x7aba, + (q15_t)0xdba5, (q15_t)0x7ab8, (q15_t)0xdb9f, (q15_t)0x7ab6, (q15_t)0xdb99, + (q15_t)0x7ab5, (q15_t)0xdb93, (q15_t)0x7ab3, (q15_t)0xdb8d, (q15_t)0x7ab1, + (q15_t)0xdb87, (q15_t)0x7aaf, (q15_t)0xdb81, (q15_t)0x7aad, (q15_t)0xdb7b, + (q15_t)0x7aac, (q15_t)0xdb75, (q15_t)0x7aaa, (q15_t)0xdb6f, (q15_t)0x7aa8, + (q15_t)0xdb69, (q15_t)0x7aa6, (q15_t)0xdb63, (q15_t)0x7aa4, (q15_t)0xdb5d, + (q15_t)0x7aa3, (q15_t)0xdb57, (q15_t)0x7aa1, (q15_t)0xdb51, (q15_t)0x7a9f, + (q15_t)0xdb4b, (q15_t)0x7a9d, (q15_t)0xdb45, (q15_t)0x7a9b, (q15_t)0xdb3f, + (q15_t)0x7a9a, (q15_t)0xdb39, (q15_t)0x7a98, (q15_t)0xdb33, (q15_t)0x7a96, + (q15_t)0xdb2d, (q15_t)0x7a94, (q15_t)0xdb27, (q15_t)0x7a92, (q15_t)0xdb21, + (q15_t)0x7a91, (q15_t)0xdb1b, (q15_t)0x7a8f, (q15_t)0xdb15, (q15_t)0x7a8d, + (q15_t)0xdb0f, (q15_t)0x7a8b, (q15_t)0xdb09, (q15_t)0x7a89, (q15_t)0xdb03, + (q15_t)0x7a87, (q15_t)0xdafd, (q15_t)0x7a86, (q15_t)0xdaf7, (q15_t)0x7a84, + (q15_t)0xdaf1, (q15_t)0x7a82, (q15_t)0xdaea, (q15_t)0x7a80, (q15_t)0xdae4, + (q15_t)0x7a7e, (q15_t)0xdade, (q15_t)0x7a7d, (q15_t)0xdad8, (q15_t)0x7a7b, + (q15_t)0xdad2, (q15_t)0x7a79, (q15_t)0xdacc, (q15_t)0x7a77, (q15_t)0xdac6, + (q15_t)0x7a75, (q15_t)0xdac0, (q15_t)0x7a73, (q15_t)0xdaba, (q15_t)0x7a72, + (q15_t)0xdab4, (q15_t)0x7a70, (q15_t)0xdaae, (q15_t)0x7a6e, (q15_t)0xdaa8, + (q15_t)0x7a6c, (q15_t)0xdaa2, (q15_t)0x7a6a, (q15_t)0xda9c, (q15_t)0x7a68, + (q15_t)0xda96, (q15_t)0x7a67, (q15_t)0xda90, (q15_t)0x7a65, (q15_t)0xda8a, + (q15_t)0x7a63, (q15_t)0xda84, (q15_t)0x7a61, (q15_t)0xda7e, (q15_t)0x7a5f, + (q15_t)0xda78, (q15_t)0x7a5d, (q15_t)0xda72, (q15_t)0x7a5c, (q15_t)0xda6c, + (q15_t)0x7a5a, (q15_t)0xda66, (q15_t)0x7a58, (q15_t)0xda60, (q15_t)0x7a56, + (q15_t)0xda5a, (q15_t)0x7a54, (q15_t)0xda54, (q15_t)0x7a52, (q15_t)0xda4e, + (q15_t)0x7a50, (q15_t)0xda48, (q15_t)0x7a4f, (q15_t)0xda42, (q15_t)0x7a4d, + (q15_t)0xda3c, (q15_t)0x7a4b, (q15_t)0xda36, (q15_t)0x7a49, (q15_t)0xda30, + (q15_t)0x7a47, (q15_t)0xda2a, (q15_t)0x7a45, (q15_t)0xda24, (q15_t)0x7a43, + (q15_t)0xda1e, (q15_t)0x7a42, (q15_t)0xda18, (q15_t)0x7a40, (q15_t)0xda12, + (q15_t)0x7a3e, (q15_t)0xda0c, (q15_t)0x7a3c, (q15_t)0xda06, (q15_t)0x7a3a, + (q15_t)0xda00, (q15_t)0x7a38, (q15_t)0xd9fa, (q15_t)0x7a36, (q15_t)0xd9f4, + (q15_t)0x7a35, (q15_t)0xd9ee, (q15_t)0x7a33, (q15_t)0xd9e8, (q15_t)0x7a31, + (q15_t)0xd9e2, (q15_t)0x7a2f, (q15_t)0xd9dc, (q15_t)0x7a2d, (q15_t)0xd9d6, + (q15_t)0x7a2b, (q15_t)0xd9d0, (q15_t)0x7a29, (q15_t)0xd9ca, (q15_t)0x7a27, + (q15_t)0xd9c4, (q15_t)0x7a26, (q15_t)0xd9be, (q15_t)0x7a24, (q15_t)0xd9b8, + (q15_t)0x7a22, (q15_t)0xd9b2, (q15_t)0x7a20, (q15_t)0xd9ac, (q15_t)0x7a1e, + (q15_t)0xd9a6, (q15_t)0x7a1c, (q15_t)0xd9a0, (q15_t)0x7a1a, (q15_t)0xd99a, + (q15_t)0x7a18, (q15_t)0xd994, (q15_t)0x7a16, (q15_t)0xd98e, (q15_t)0x7a15, + (q15_t)0xd988, (q15_t)0x7a13, (q15_t)0xd982, (q15_t)0x7a11, (q15_t)0xd97c, + (q15_t)0x7a0f, (q15_t)0xd976, (q15_t)0x7a0d, (q15_t)0xd970, (q15_t)0x7a0b, + (q15_t)0xd96a, (q15_t)0x7a09, (q15_t)0xd964, (q15_t)0x7a07, (q15_t)0xd95e, + (q15_t)0x7a05, (q15_t)0xd958, (q15_t)0x7a04, (q15_t)0xd952, (q15_t)0x7a02, + (q15_t)0xd94c, (q15_t)0x7a00, (q15_t)0xd946, (q15_t)0x79fe, (q15_t)0xd940, + (q15_t)0x79fc, (q15_t)0xd93a, (q15_t)0x79fa, (q15_t)0xd934, (q15_t)0x79f8, + (q15_t)0xd92e, (q15_t)0x79f6, (q15_t)0xd928, (q15_t)0x79f4, (q15_t)0xd922, + (q15_t)0x79f2, (q15_t)0xd91c, (q15_t)0x79f0, (q15_t)0xd917, (q15_t)0x79ef, + (q15_t)0xd911, (q15_t)0x79ed, (q15_t)0xd90b, (q15_t)0x79eb, (q15_t)0xd905, + (q15_t)0x79e9, (q15_t)0xd8ff, (q15_t)0x79e7, (q15_t)0xd8f9, (q15_t)0x79e5, + (q15_t)0xd8f3, (q15_t)0x79e3, (q15_t)0xd8ed, (q15_t)0x79e1, (q15_t)0xd8e7, + (q15_t)0x79df, (q15_t)0xd8e1, (q15_t)0x79dd, (q15_t)0xd8db, (q15_t)0x79db, + (q15_t)0xd8d5, (q15_t)0x79d9, (q15_t)0xd8cf, (q15_t)0x79d8, (q15_t)0xd8c9, + (q15_t)0x79d6, (q15_t)0xd8c3, (q15_t)0x79d4, (q15_t)0xd8bd, (q15_t)0x79d2, + (q15_t)0xd8b7, (q15_t)0x79d0, (q15_t)0xd8b1, (q15_t)0x79ce, (q15_t)0xd8ab, + (q15_t)0x79cc, (q15_t)0xd8a5, (q15_t)0x79ca, (q15_t)0xd89f, (q15_t)0x79c8, + (q15_t)0xd899, (q15_t)0x79c6, (q15_t)0xd893, (q15_t)0x79c4, (q15_t)0xd88d, + (q15_t)0x79c2, (q15_t)0xd887, (q15_t)0x79c0, (q15_t)0xd881, (q15_t)0x79be, + (q15_t)0xd87b, (q15_t)0x79bc, (q15_t)0xd875, (q15_t)0x79bb, (q15_t)0xd86f, + (q15_t)0x79b9, (q15_t)0xd869, (q15_t)0x79b7, (q15_t)0xd863, (q15_t)0x79b5, + (q15_t)0xd85d, (q15_t)0x79b3, (q15_t)0xd857, (q15_t)0x79b1, (q15_t)0xd851, + (q15_t)0x79af, (q15_t)0xd84b, (q15_t)0x79ad, (q15_t)0xd845, (q15_t)0x79ab, + (q15_t)0xd83f, (q15_t)0x79a9, (q15_t)0xd839, (q15_t)0x79a7, (q15_t)0xd833, + (q15_t)0x79a5, (q15_t)0xd82d, (q15_t)0x79a3, (q15_t)0xd827, (q15_t)0x79a1, + (q15_t)0xd821, (q15_t)0x799f, (q15_t)0xd81b, (q15_t)0x799d, (q15_t)0xd815, + (q15_t)0x799b, (q15_t)0xd80f, (q15_t)0x7999, (q15_t)0xd80a, (q15_t)0x7997, + (q15_t)0xd804, (q15_t)0x7995, (q15_t)0xd7fe, (q15_t)0x7993, (q15_t)0xd7f8, + (q15_t)0x7992, (q15_t)0xd7f2, (q15_t)0x7990, (q15_t)0xd7ec, (q15_t)0x798e, + (q15_t)0xd7e6, (q15_t)0x798c, (q15_t)0xd7e0, (q15_t)0x798a, (q15_t)0xd7da, + (q15_t)0x7988, (q15_t)0xd7d4, (q15_t)0x7986, (q15_t)0xd7ce, (q15_t)0x7984, + (q15_t)0xd7c8, (q15_t)0x7982, (q15_t)0xd7c2, (q15_t)0x7980, (q15_t)0xd7bc, + (q15_t)0x797e, (q15_t)0xd7b6, (q15_t)0x797c, (q15_t)0xd7b0, (q15_t)0x797a, + (q15_t)0xd7aa, (q15_t)0x7978, (q15_t)0xd7a4, (q15_t)0x7976, (q15_t)0xd79e, + (q15_t)0x7974, (q15_t)0xd798, (q15_t)0x7972, (q15_t)0xd792, (q15_t)0x7970, + (q15_t)0xd78c, (q15_t)0x796e, (q15_t)0xd786, (q15_t)0x796c, (q15_t)0xd780, + (q15_t)0x796a, (q15_t)0xd77a, (q15_t)0x7968, (q15_t)0xd774, (q15_t)0x7966, + (q15_t)0xd76e, (q15_t)0x7964, (q15_t)0xd768, (q15_t)0x7962, (q15_t)0xd763, + (q15_t)0x7960, (q15_t)0xd75d, (q15_t)0x795e, (q15_t)0xd757, (q15_t)0x795c, + (q15_t)0xd751, (q15_t)0x795a, (q15_t)0xd74b, (q15_t)0x7958, (q15_t)0xd745, + (q15_t)0x7956, (q15_t)0xd73f, (q15_t)0x7954, (q15_t)0xd739, (q15_t)0x7952, + (q15_t)0xd733, (q15_t)0x7950, (q15_t)0xd72d, (q15_t)0x794e, (q15_t)0xd727, + (q15_t)0x794c, (q15_t)0xd721, (q15_t)0x794a, (q15_t)0xd71b, (q15_t)0x7948, + (q15_t)0xd715, (q15_t)0x7946, (q15_t)0xd70f, (q15_t)0x7944, (q15_t)0xd709, + (q15_t)0x7942, (q15_t)0xd703, (q15_t)0x7940, (q15_t)0xd6fd, (q15_t)0x793e, + (q15_t)0xd6f7, (q15_t)0x793c, (q15_t)0xd6f1, (q15_t)0x793a, (q15_t)0xd6eb, + (q15_t)0x7938, (q15_t)0xd6e5, (q15_t)0x7936, (q15_t)0xd6e0, (q15_t)0x7934, + (q15_t)0xd6da, (q15_t)0x7932, (q15_t)0xd6d4, (q15_t)0x7930, (q15_t)0xd6ce, + (q15_t)0x792e, (q15_t)0xd6c8, (q15_t)0x792c, (q15_t)0xd6c2, (q15_t)0x792a, + (q15_t)0xd6bc, (q15_t)0x7928, (q15_t)0xd6b6, (q15_t)0x7926, (q15_t)0xd6b0, + (q15_t)0x7924, (q15_t)0xd6aa, (q15_t)0x7922, (q15_t)0xd6a4, (q15_t)0x7920, + (q15_t)0xd69e, (q15_t)0x791e, (q15_t)0xd698, (q15_t)0x791c, (q15_t)0xd692, + (q15_t)0x7919, (q15_t)0xd68c, (q15_t)0x7917, (q15_t)0xd686, (q15_t)0x7915, + (q15_t)0xd680, (q15_t)0x7913, (q15_t)0xd67a, (q15_t)0x7911, (q15_t)0xd675, + (q15_t)0x790f, (q15_t)0xd66f, (q15_t)0x790d, (q15_t)0xd669, (q15_t)0x790b, + (q15_t)0xd663, (q15_t)0x7909, (q15_t)0xd65d, (q15_t)0x7907, (q15_t)0xd657, + (q15_t)0x7905, (q15_t)0xd651, (q15_t)0x7903, (q15_t)0xd64b, (q15_t)0x7901, + (q15_t)0xd645, (q15_t)0x78ff, (q15_t)0xd63f, (q15_t)0x78fd, (q15_t)0xd639, + (q15_t)0x78fb, (q15_t)0xd633, (q15_t)0x78f9, (q15_t)0xd62d, (q15_t)0x78f7, + (q15_t)0xd627, (q15_t)0x78f5, (q15_t)0xd621, (q15_t)0x78f3, (q15_t)0xd61b, + (q15_t)0x78f1, (q15_t)0xd615, (q15_t)0x78ee, (q15_t)0xd610, (q15_t)0x78ec, + (q15_t)0xd60a, (q15_t)0x78ea, (q15_t)0xd604, (q15_t)0x78e8, (q15_t)0xd5fe, + (q15_t)0x78e6, (q15_t)0xd5f8, (q15_t)0x78e4, (q15_t)0xd5f2, (q15_t)0x78e2, + (q15_t)0xd5ec, (q15_t)0x78e0, (q15_t)0xd5e6, (q15_t)0x78de, (q15_t)0xd5e0, + (q15_t)0x78dc, (q15_t)0xd5da, (q15_t)0x78da, (q15_t)0xd5d4, (q15_t)0x78d8, + (q15_t)0xd5ce, (q15_t)0x78d6, (q15_t)0xd5c8, (q15_t)0x78d4, (q15_t)0xd5c2, + (q15_t)0x78d2, (q15_t)0xd5bc, (q15_t)0x78cf, (q15_t)0xd5b7, (q15_t)0x78cd, + (q15_t)0xd5b1, (q15_t)0x78cb, (q15_t)0xd5ab, (q15_t)0x78c9, (q15_t)0xd5a5, + (q15_t)0x78c7, (q15_t)0xd59f, (q15_t)0x78c5, (q15_t)0xd599, (q15_t)0x78c3, + (q15_t)0xd593, (q15_t)0x78c1, (q15_t)0xd58d, (q15_t)0x78bf, (q15_t)0xd587, + (q15_t)0x78bd, (q15_t)0xd581, (q15_t)0x78bb, (q15_t)0xd57b, (q15_t)0x78b9, + (q15_t)0xd575, (q15_t)0x78b6, (q15_t)0xd56f, (q15_t)0x78b4, (q15_t)0xd569, + (q15_t)0x78b2, (q15_t)0xd564, (q15_t)0x78b0, (q15_t)0xd55e, (q15_t)0x78ae, + (q15_t)0xd558, (q15_t)0x78ac, (q15_t)0xd552, (q15_t)0x78aa, (q15_t)0xd54c, + (q15_t)0x78a8, (q15_t)0xd546, (q15_t)0x78a6, (q15_t)0xd540, (q15_t)0x78a4, + (q15_t)0xd53a, (q15_t)0x78a2, (q15_t)0xd534, (q15_t)0x789f, (q15_t)0xd52e, + (q15_t)0x789d, (q15_t)0xd528, (q15_t)0x789b, (q15_t)0xd522, (q15_t)0x7899, + (q15_t)0xd51c, (q15_t)0x7897, (q15_t)0xd517, (q15_t)0x7895, (q15_t)0xd511, + (q15_t)0x7893, (q15_t)0xd50b, (q15_t)0x7891, (q15_t)0xd505, (q15_t)0x788f, + (q15_t)0xd4ff, (q15_t)0x788c, (q15_t)0xd4f9, (q15_t)0x788a, (q15_t)0xd4f3, + (q15_t)0x7888, (q15_t)0xd4ed, (q15_t)0x7886, (q15_t)0xd4e7, (q15_t)0x7884, + (q15_t)0xd4e1, (q15_t)0x7882, (q15_t)0xd4db, (q15_t)0x7880, (q15_t)0xd4d5, + (q15_t)0x787e, (q15_t)0xd4d0, (q15_t)0x787c, (q15_t)0xd4ca, (q15_t)0x7879, + (q15_t)0xd4c4, (q15_t)0x7877, (q15_t)0xd4be, (q15_t)0x7875, (q15_t)0xd4b8, + (q15_t)0x7873, (q15_t)0xd4b2, (q15_t)0x7871, (q15_t)0xd4ac, (q15_t)0x786f, + (q15_t)0xd4a6, (q15_t)0x786d, (q15_t)0xd4a0, (q15_t)0x786b, (q15_t)0xd49a, + (q15_t)0x7868, (q15_t)0xd494, (q15_t)0x7866, (q15_t)0xd48f, (q15_t)0x7864, + (q15_t)0xd489, (q15_t)0x7862, (q15_t)0xd483, (q15_t)0x7860, (q15_t)0xd47d, + (q15_t)0x785e, (q15_t)0xd477, (q15_t)0x785c, (q15_t)0xd471, (q15_t)0x7859, + (q15_t)0xd46b, (q15_t)0x7857, (q15_t)0xd465, (q15_t)0x7855, (q15_t)0xd45f, + (q15_t)0x7853, (q15_t)0xd459, (q15_t)0x7851, (q15_t)0xd453, (q15_t)0x784f, + (q15_t)0xd44e, (q15_t)0x784d, (q15_t)0xd448, (q15_t)0x784a, (q15_t)0xd442, + (q15_t)0x7848, (q15_t)0xd43c, (q15_t)0x7846, (q15_t)0xd436, (q15_t)0x7844, + (q15_t)0xd430, (q15_t)0x7842, (q15_t)0xd42a, (q15_t)0x7840, (q15_t)0xd424, + (q15_t)0x783e, (q15_t)0xd41e, (q15_t)0x783b, (q15_t)0xd418, (q15_t)0x7839, + (q15_t)0xd412, (q15_t)0x7837, (q15_t)0xd40d, (q15_t)0x7835, (q15_t)0xd407, + (q15_t)0x7833, (q15_t)0xd401, (q15_t)0x7831, (q15_t)0xd3fb, (q15_t)0x782e, + (q15_t)0xd3f5, (q15_t)0x782c, (q15_t)0xd3ef, (q15_t)0x782a, (q15_t)0xd3e9, + (q15_t)0x7828, (q15_t)0xd3e3, (q15_t)0x7826, (q15_t)0xd3dd, (q15_t)0x7824, + (q15_t)0xd3d7, (q15_t)0x7821, (q15_t)0xd3d2, (q15_t)0x781f, (q15_t)0xd3cc, + (q15_t)0x781d, (q15_t)0xd3c6, (q15_t)0x781b, (q15_t)0xd3c0, (q15_t)0x7819, + (q15_t)0xd3ba, (q15_t)0x7817, (q15_t)0xd3b4, (q15_t)0x7814, (q15_t)0xd3ae, + (q15_t)0x7812, (q15_t)0xd3a8, (q15_t)0x7810, (q15_t)0xd3a2, (q15_t)0x780e, + (q15_t)0xd39d, (q15_t)0x780c, (q15_t)0xd397, (q15_t)0x780a, (q15_t)0xd391, + (q15_t)0x7807, (q15_t)0xd38b, (q15_t)0x7805, (q15_t)0xd385, (q15_t)0x7803, + (q15_t)0xd37f, (q15_t)0x7801, (q15_t)0xd379, (q15_t)0x77ff, (q15_t)0xd373, + (q15_t)0x77fc, (q15_t)0xd36d, (q15_t)0x77fa, (q15_t)0xd368, (q15_t)0x77f8, + (q15_t)0xd362, (q15_t)0x77f6, (q15_t)0xd35c, (q15_t)0x77f4, (q15_t)0xd356, + (q15_t)0x77f1, (q15_t)0xd350, (q15_t)0x77ef, (q15_t)0xd34a, (q15_t)0x77ed, + (q15_t)0xd344, (q15_t)0x77eb, (q15_t)0xd33e, (q15_t)0x77e9, (q15_t)0xd338, + (q15_t)0x77e6, (q15_t)0xd333, (q15_t)0x77e4, (q15_t)0xd32d, (q15_t)0x77e2, + (q15_t)0xd327, (q15_t)0x77e0, (q15_t)0xd321, (q15_t)0x77de, (q15_t)0xd31b, + (q15_t)0x77db, (q15_t)0xd315, (q15_t)0x77d9, (q15_t)0xd30f, (q15_t)0x77d7, + (q15_t)0xd309, (q15_t)0x77d5, (q15_t)0xd303, (q15_t)0x77d3, (q15_t)0xd2fe, + (q15_t)0x77d0, (q15_t)0xd2f8, (q15_t)0x77ce, (q15_t)0xd2f2, (q15_t)0x77cc, + (q15_t)0xd2ec, (q15_t)0x77ca, (q15_t)0xd2e6, (q15_t)0x77c8, (q15_t)0xd2e0, + (q15_t)0x77c5, (q15_t)0xd2da, (q15_t)0x77c3, (q15_t)0xd2d4, (q15_t)0x77c1, + (q15_t)0xd2cf, (q15_t)0x77bf, (q15_t)0xd2c9, (q15_t)0x77bc, (q15_t)0xd2c3, + (q15_t)0x77ba, (q15_t)0xd2bd, (q15_t)0x77b8, (q15_t)0xd2b7, (q15_t)0x77b6, + (q15_t)0xd2b1, (q15_t)0x77b4, (q15_t)0xd2ab, (q15_t)0x77b1, (q15_t)0xd2a5, + (q15_t)0x77af, (q15_t)0xd2a0, (q15_t)0x77ad, (q15_t)0xd29a, (q15_t)0x77ab, + (q15_t)0xd294, (q15_t)0x77a8, (q15_t)0xd28e, (q15_t)0x77a6, (q15_t)0xd288, + (q15_t)0x77a4, (q15_t)0xd282, (q15_t)0x77a2, (q15_t)0xd27c, (q15_t)0x77a0, + (q15_t)0xd276, (q15_t)0x779d, (q15_t)0xd271, (q15_t)0x779b, (q15_t)0xd26b, + (q15_t)0x7799, (q15_t)0xd265, (q15_t)0x7797, (q15_t)0xd25f, (q15_t)0x7794, + (q15_t)0xd259, (q15_t)0x7792, (q15_t)0xd253, (q15_t)0x7790, (q15_t)0xd24d, + (q15_t)0x778e, (q15_t)0xd247, (q15_t)0x778b, (q15_t)0xd242, (q15_t)0x7789, + (q15_t)0xd23c, (q15_t)0x7787, (q15_t)0xd236, (q15_t)0x7785, (q15_t)0xd230, + (q15_t)0x7782, (q15_t)0xd22a, (q15_t)0x7780, (q15_t)0xd224, (q15_t)0x777e, + (q15_t)0xd21e, (q15_t)0x777c, (q15_t)0xd219, (q15_t)0x7779, (q15_t)0xd213, + (q15_t)0x7777, (q15_t)0xd20d, (q15_t)0x7775, (q15_t)0xd207, (q15_t)0x7773, + (q15_t)0xd201, (q15_t)0x7770, (q15_t)0xd1fb, (q15_t)0x776e, (q15_t)0xd1f5, + (q15_t)0x776c, (q15_t)0xd1ef, (q15_t)0x776a, (q15_t)0xd1ea, (q15_t)0x7767, + (q15_t)0xd1e4, (q15_t)0x7765, (q15_t)0xd1de, (q15_t)0x7763, (q15_t)0xd1d8, + (q15_t)0x7760, (q15_t)0xd1d2, (q15_t)0x775e, (q15_t)0xd1cc, (q15_t)0x775c, + (q15_t)0xd1c6, (q15_t)0x775a, (q15_t)0xd1c1, (q15_t)0x7757, (q15_t)0xd1bb, + (q15_t)0x7755, (q15_t)0xd1b5, (q15_t)0x7753, (q15_t)0xd1af, (q15_t)0x7751, + (q15_t)0xd1a9, (q15_t)0x774e, (q15_t)0xd1a3, (q15_t)0x774c, (q15_t)0xd19d, + (q15_t)0x774a, (q15_t)0xd198, (q15_t)0x7747, (q15_t)0xd192, (q15_t)0x7745, + (q15_t)0xd18c, (q15_t)0x7743, (q15_t)0xd186, (q15_t)0x7741, (q15_t)0xd180, + (q15_t)0x773e, (q15_t)0xd17a, (q15_t)0x773c, (q15_t)0xd174, (q15_t)0x773a, + (q15_t)0xd16f, (q15_t)0x7738, (q15_t)0xd169, (q15_t)0x7735, (q15_t)0xd163, + (q15_t)0x7733, (q15_t)0xd15d, (q15_t)0x7731, (q15_t)0xd157, (q15_t)0x772e, + (q15_t)0xd151, (q15_t)0x772c, (q15_t)0xd14b, (q15_t)0x772a, (q15_t)0xd146, + (q15_t)0x7727, (q15_t)0xd140, (q15_t)0x7725, (q15_t)0xd13a, (q15_t)0x7723, + (q15_t)0xd134, (q15_t)0x7721, (q15_t)0xd12e, (q15_t)0x771e, (q15_t)0xd128, + (q15_t)0x771c, (q15_t)0xd123, (q15_t)0x771a, (q15_t)0xd11d, (q15_t)0x7717, + (q15_t)0xd117, (q15_t)0x7715, (q15_t)0xd111, (q15_t)0x7713, (q15_t)0xd10b, + (q15_t)0x7710, (q15_t)0xd105, (q15_t)0x770e, (q15_t)0xd0ff, (q15_t)0x770c, + (q15_t)0xd0fa, (q15_t)0x770a, (q15_t)0xd0f4, (q15_t)0x7707, (q15_t)0xd0ee, + (q15_t)0x7705, (q15_t)0xd0e8, (q15_t)0x7703, (q15_t)0xd0e2, (q15_t)0x7700, + (q15_t)0xd0dc, (q15_t)0x76fe, (q15_t)0xd0d7, (q15_t)0x76fc, (q15_t)0xd0d1, + (q15_t)0x76f9, (q15_t)0xd0cb, (q15_t)0x76f7, (q15_t)0xd0c5, (q15_t)0x76f5, + (q15_t)0xd0bf, (q15_t)0x76f2, (q15_t)0xd0b9, (q15_t)0x76f0, (q15_t)0xd0b4, + (q15_t)0x76ee, (q15_t)0xd0ae, (q15_t)0x76eb, (q15_t)0xd0a8, (q15_t)0x76e9, + (q15_t)0xd0a2, (q15_t)0x76e7, (q15_t)0xd09c, (q15_t)0x76e4, (q15_t)0xd096, + (q15_t)0x76e2, (q15_t)0xd091, (q15_t)0x76e0, (q15_t)0xd08b, (q15_t)0x76dd, + (q15_t)0xd085, (q15_t)0x76db, (q15_t)0xd07f, (q15_t)0x76d9, (q15_t)0xd079, + (q15_t)0x76d6, (q15_t)0xd073, (q15_t)0x76d4, (q15_t)0xd06e, (q15_t)0x76d2, + (q15_t)0xd068, (q15_t)0x76cf, (q15_t)0xd062, (q15_t)0x76cd, (q15_t)0xd05c, + (q15_t)0x76cb, (q15_t)0xd056, (q15_t)0x76c8, (q15_t)0xd050, (q15_t)0x76c6, + (q15_t)0xd04b, (q15_t)0x76c4, (q15_t)0xd045, (q15_t)0x76c1, (q15_t)0xd03f, + (q15_t)0x76bf, (q15_t)0xd039, (q15_t)0x76bd, (q15_t)0xd033, (q15_t)0x76ba, + (q15_t)0xd02d, (q15_t)0x76b8, (q15_t)0xd028, (q15_t)0x76b6, (q15_t)0xd022, + (q15_t)0x76b3, (q15_t)0xd01c, (q15_t)0x76b1, (q15_t)0xd016, (q15_t)0x76af, + (q15_t)0xd010, (q15_t)0x76ac, (q15_t)0xd00a, (q15_t)0x76aa, (q15_t)0xd005, + (q15_t)0x76a8, (q15_t)0xcfff, (q15_t)0x76a5, (q15_t)0xcff9, (q15_t)0x76a3, + (q15_t)0xcff3, (q15_t)0x76a0, (q15_t)0xcfed, (q15_t)0x769e, (q15_t)0xcfe7, + (q15_t)0x769c, (q15_t)0xcfe2, (q15_t)0x7699, (q15_t)0xcfdc, (q15_t)0x7697, + (q15_t)0xcfd6, (q15_t)0x7695, (q15_t)0xcfd0, (q15_t)0x7692, (q15_t)0xcfca, + (q15_t)0x7690, (q15_t)0xcfc5, (q15_t)0x768e, (q15_t)0xcfbf, (q15_t)0x768b, + (q15_t)0xcfb9, (q15_t)0x7689, (q15_t)0xcfb3, (q15_t)0x7686, (q15_t)0xcfad, + (q15_t)0x7684, (q15_t)0xcfa7, (q15_t)0x7682, (q15_t)0xcfa2, (q15_t)0x767f, + (q15_t)0xcf9c, (q15_t)0x767d, (q15_t)0xcf96, (q15_t)0x767b, (q15_t)0xcf90, + (q15_t)0x7678, (q15_t)0xcf8a, (q15_t)0x7676, (q15_t)0xcf85, (q15_t)0x7673, + (q15_t)0xcf7f, (q15_t)0x7671, (q15_t)0xcf79, (q15_t)0x766f, (q15_t)0xcf73, + (q15_t)0x766c, (q15_t)0xcf6d, (q15_t)0x766a, (q15_t)0xcf67, (q15_t)0x7668, + (q15_t)0xcf62, (q15_t)0x7665, (q15_t)0xcf5c, (q15_t)0x7663, (q15_t)0xcf56, + (q15_t)0x7660, (q15_t)0xcf50, (q15_t)0x765e, (q15_t)0xcf4a, (q15_t)0x765c, + (q15_t)0xcf45, (q15_t)0x7659, (q15_t)0xcf3f, (q15_t)0x7657, (q15_t)0xcf39, + (q15_t)0x7654, (q15_t)0xcf33, (q15_t)0x7652, (q15_t)0xcf2d, (q15_t)0x7650, + (q15_t)0xcf28, (q15_t)0x764d, (q15_t)0xcf22, (q15_t)0x764b, (q15_t)0xcf1c, + (q15_t)0x7648, (q15_t)0xcf16, (q15_t)0x7646, (q15_t)0xcf10, (q15_t)0x7644, + (q15_t)0xcf0b, (q15_t)0x7641, (q15_t)0xcf05, (q15_t)0x763f, (q15_t)0xceff, + (q15_t)0x763c, (q15_t)0xcef9, (q15_t)0x763a, (q15_t)0xcef3, (q15_t)0x7638, + (q15_t)0xceee, (q15_t)0x7635, (q15_t)0xcee8, (q15_t)0x7633, (q15_t)0xcee2, + (q15_t)0x7630, (q15_t)0xcedc, (q15_t)0x762e, (q15_t)0xced6, (q15_t)0x762b, + (q15_t)0xced1, (q15_t)0x7629, (q15_t)0xcecb, (q15_t)0x7627, (q15_t)0xcec5, + (q15_t)0x7624, (q15_t)0xcebf, (q15_t)0x7622, (q15_t)0xceb9, (q15_t)0x761f, + (q15_t)0xceb4, (q15_t)0x761d, (q15_t)0xceae, (q15_t)0x761b, (q15_t)0xcea8, + (q15_t)0x7618, (q15_t)0xcea2, (q15_t)0x7616, (q15_t)0xce9c, (q15_t)0x7613, + (q15_t)0xce97, (q15_t)0x7611, (q15_t)0xce91, (q15_t)0x760e, (q15_t)0xce8b, + (q15_t)0x760c, (q15_t)0xce85, (q15_t)0x760a, (q15_t)0xce7f, (q15_t)0x7607, + (q15_t)0xce7a, (q15_t)0x7605, (q15_t)0xce74, (q15_t)0x7602, (q15_t)0xce6e, + (q15_t)0x7600, (q15_t)0xce68, (q15_t)0x75fd, (q15_t)0xce62, (q15_t)0x75fb, + (q15_t)0xce5d, (q15_t)0x75f9, (q15_t)0xce57, (q15_t)0x75f6, (q15_t)0xce51, + (q15_t)0x75f4, (q15_t)0xce4b, (q15_t)0x75f1, (q15_t)0xce45, (q15_t)0x75ef, + (q15_t)0xce40, (q15_t)0x75ec, (q15_t)0xce3a, (q15_t)0x75ea, (q15_t)0xce34, + (q15_t)0x75e7, (q15_t)0xce2e, (q15_t)0x75e5, (q15_t)0xce28, (q15_t)0x75e3, + (q15_t)0xce23, (q15_t)0x75e0, (q15_t)0xce1d, (q15_t)0x75de, (q15_t)0xce17, + (q15_t)0x75db, (q15_t)0xce11, (q15_t)0x75d9, (q15_t)0xce0c, (q15_t)0x75d6, + (q15_t)0xce06, (q15_t)0x75d4, (q15_t)0xce00, (q15_t)0x75d1, (q15_t)0xcdfa, + (q15_t)0x75cf, (q15_t)0xcdf4, (q15_t)0x75cc, (q15_t)0xcdef, (q15_t)0x75ca, + (q15_t)0xcde9, (q15_t)0x75c8, (q15_t)0xcde3, (q15_t)0x75c5, (q15_t)0xcddd, + (q15_t)0x75c3, (q15_t)0xcdd8, (q15_t)0x75c0, (q15_t)0xcdd2, (q15_t)0x75be, + (q15_t)0xcdcc, (q15_t)0x75bb, (q15_t)0xcdc6, (q15_t)0x75b9, (q15_t)0xcdc0, + (q15_t)0x75b6, (q15_t)0xcdbb, (q15_t)0x75b4, (q15_t)0xcdb5, (q15_t)0x75b1, + (q15_t)0xcdaf, (q15_t)0x75af, (q15_t)0xcda9, (q15_t)0x75ac, (q15_t)0xcda3, + (q15_t)0x75aa, (q15_t)0xcd9e, (q15_t)0x75a7, (q15_t)0xcd98, (q15_t)0x75a5, + (q15_t)0xcd92, (q15_t)0x75a3, (q15_t)0xcd8c, (q15_t)0x75a0, (q15_t)0xcd87, + (q15_t)0x759e, (q15_t)0xcd81, (q15_t)0x759b, (q15_t)0xcd7b, (q15_t)0x7599, + (q15_t)0xcd75, (q15_t)0x7596, (q15_t)0xcd70, (q15_t)0x7594, (q15_t)0xcd6a, + (q15_t)0x7591, (q15_t)0xcd64, (q15_t)0x758f, (q15_t)0xcd5e, (q15_t)0x758c, + (q15_t)0xcd58, (q15_t)0x758a, (q15_t)0xcd53, (q15_t)0x7587, (q15_t)0xcd4d, + (q15_t)0x7585, (q15_t)0xcd47, (q15_t)0x7582, (q15_t)0xcd41, (q15_t)0x7580, + (q15_t)0xcd3c, (q15_t)0x757d, (q15_t)0xcd36, (q15_t)0x757b, (q15_t)0xcd30, + (q15_t)0x7578, (q15_t)0xcd2a, (q15_t)0x7576, (q15_t)0xcd25, (q15_t)0x7573, + (q15_t)0xcd1f, (q15_t)0x7571, (q15_t)0xcd19, (q15_t)0x756e, (q15_t)0xcd13, + (q15_t)0x756c, (q15_t)0xcd0d, (q15_t)0x7569, (q15_t)0xcd08, (q15_t)0x7567, + (q15_t)0xcd02, (q15_t)0x7564, (q15_t)0xccfc, (q15_t)0x7562, (q15_t)0xccf6, + (q15_t)0x755f, (q15_t)0xccf1, (q15_t)0x755d, (q15_t)0xcceb, (q15_t)0x755a, + (q15_t)0xcce5, (q15_t)0x7558, (q15_t)0xccdf, (q15_t)0x7555, (q15_t)0xccda, + (q15_t)0x7553, (q15_t)0xccd4, (q15_t)0x7550, (q15_t)0xccce, (q15_t)0x754e, + (q15_t)0xccc8, (q15_t)0x754b, (q15_t)0xccc3, (q15_t)0x7549, (q15_t)0xccbd, + (q15_t)0x7546, (q15_t)0xccb7, (q15_t)0x7544, (q15_t)0xccb1, (q15_t)0x7541, + (q15_t)0xccac, (q15_t)0x753f, (q15_t)0xcca6, (q15_t)0x753c, (q15_t)0xcca0, + (q15_t)0x753a, (q15_t)0xcc9a, (q15_t)0x7537, (q15_t)0xcc95, (q15_t)0x7535, + (q15_t)0xcc8f, (q15_t)0x7532, (q15_t)0xcc89, (q15_t)0x752f, (q15_t)0xcc83, + (q15_t)0x752d, (q15_t)0xcc7e, (q15_t)0x752a, (q15_t)0xcc78, (q15_t)0x7528, + (q15_t)0xcc72, (q15_t)0x7525, (q15_t)0xcc6c, (q15_t)0x7523, (q15_t)0xcc67, + (q15_t)0x7520, (q15_t)0xcc61, (q15_t)0x751e, (q15_t)0xcc5b, (q15_t)0x751b, + (q15_t)0xcc55, (q15_t)0x7519, (q15_t)0xcc50, (q15_t)0x7516, (q15_t)0xcc4a, + (q15_t)0x7514, (q15_t)0xcc44, (q15_t)0x7511, (q15_t)0xcc3e, (q15_t)0x750f, + (q15_t)0xcc39, (q15_t)0x750c, (q15_t)0xcc33, (q15_t)0x7509, (q15_t)0xcc2d, + (q15_t)0x7507, (q15_t)0xcc27, (q15_t)0x7504, (q15_t)0xcc22, (q15_t)0x7502, + (q15_t)0xcc1c, (q15_t)0x74ff, (q15_t)0xcc16, (q15_t)0x74fd, (q15_t)0xcc10, + (q15_t)0x74fa, (q15_t)0xcc0b, (q15_t)0x74f8, (q15_t)0xcc05, (q15_t)0x74f5, + (q15_t)0xcbff, (q15_t)0x74f2, (q15_t)0xcbf9, (q15_t)0x74f0, (q15_t)0xcbf4, + (q15_t)0x74ed, (q15_t)0xcbee, (q15_t)0x74eb, (q15_t)0xcbe8, (q15_t)0x74e8, + (q15_t)0xcbe2, (q15_t)0x74e6, (q15_t)0xcbdd, (q15_t)0x74e3, (q15_t)0xcbd7, + (q15_t)0x74e1, (q15_t)0xcbd1, (q15_t)0x74de, (q15_t)0xcbcb, (q15_t)0x74db, + (q15_t)0xcbc6, (q15_t)0x74d9, (q15_t)0xcbc0, (q15_t)0x74d6, (q15_t)0xcbba, + (q15_t)0x74d4, (q15_t)0xcbb5, (q15_t)0x74d1, (q15_t)0xcbaf, (q15_t)0x74cf, + (q15_t)0xcba9, (q15_t)0x74cc, (q15_t)0xcba3, (q15_t)0x74c9, (q15_t)0xcb9e, + (q15_t)0x74c7, (q15_t)0xcb98, (q15_t)0x74c4, (q15_t)0xcb92, (q15_t)0x74c2, + (q15_t)0xcb8c, (q15_t)0x74bf, (q15_t)0xcb87, (q15_t)0x74bd, (q15_t)0xcb81, + (q15_t)0x74ba, (q15_t)0xcb7b, (q15_t)0x74b7, (q15_t)0xcb75, (q15_t)0x74b5, + (q15_t)0xcb70, (q15_t)0x74b2, (q15_t)0xcb6a, (q15_t)0x74b0, (q15_t)0xcb64, + (q15_t)0x74ad, (q15_t)0xcb5f, (q15_t)0x74ab, (q15_t)0xcb59, (q15_t)0x74a8, + (q15_t)0xcb53, (q15_t)0x74a5, (q15_t)0xcb4d, (q15_t)0x74a3, (q15_t)0xcb48, + (q15_t)0x74a0, (q15_t)0xcb42, (q15_t)0x749e, (q15_t)0xcb3c, (q15_t)0x749b, + (q15_t)0xcb36, (q15_t)0x7498, (q15_t)0xcb31, (q15_t)0x7496, (q15_t)0xcb2b, + (q15_t)0x7493, (q15_t)0xcb25, (q15_t)0x7491, (q15_t)0xcb20, (q15_t)0x748e, + (q15_t)0xcb1a, (q15_t)0x748b, (q15_t)0xcb14, (q15_t)0x7489, (q15_t)0xcb0e, + (q15_t)0x7486, (q15_t)0xcb09, (q15_t)0x7484, (q15_t)0xcb03, (q15_t)0x7481, + (q15_t)0xcafd, (q15_t)0x747e, (q15_t)0xcaf8, (q15_t)0x747c, (q15_t)0xcaf2, + (q15_t)0x7479, (q15_t)0xcaec, (q15_t)0x7477, (q15_t)0xcae6, (q15_t)0x7474, + (q15_t)0xcae1, (q15_t)0x7471, (q15_t)0xcadb, (q15_t)0x746f, (q15_t)0xcad5, + (q15_t)0x746c, (q15_t)0xcad0, (q15_t)0x746a, (q15_t)0xcaca, (q15_t)0x7467, + (q15_t)0xcac4, (q15_t)0x7464, (q15_t)0xcabe, (q15_t)0x7462, (q15_t)0xcab9, + (q15_t)0x745f, (q15_t)0xcab3, (q15_t)0x745c, (q15_t)0xcaad, (q15_t)0x745a, + (q15_t)0xcaa8, (q15_t)0x7457, (q15_t)0xcaa2, (q15_t)0x7455, (q15_t)0xca9c, + (q15_t)0x7452, (q15_t)0xca96, (q15_t)0x744f, (q15_t)0xca91, (q15_t)0x744d, + (q15_t)0xca8b, (q15_t)0x744a, (q15_t)0xca85, (q15_t)0x7448, (q15_t)0xca80, + (q15_t)0x7445, (q15_t)0xca7a, (q15_t)0x7442, (q15_t)0xca74, (q15_t)0x7440, + (q15_t)0xca6e, (q15_t)0x743d, (q15_t)0xca69, (q15_t)0x743a, (q15_t)0xca63, + (q15_t)0x7438, (q15_t)0xca5d, (q15_t)0x7435, (q15_t)0xca58, (q15_t)0x7432, + (q15_t)0xca52, (q15_t)0x7430, (q15_t)0xca4c, (q15_t)0x742d, (q15_t)0xca46, + (q15_t)0x742b, (q15_t)0xca41, (q15_t)0x7428, (q15_t)0xca3b, (q15_t)0x7425, + (q15_t)0xca35, (q15_t)0x7423, (q15_t)0xca30, (q15_t)0x7420, (q15_t)0xca2a, + (q15_t)0x741d, (q15_t)0xca24, (q15_t)0x741b, (q15_t)0xca1f, (q15_t)0x7418, + (q15_t)0xca19, (q15_t)0x7415, (q15_t)0xca13, (q15_t)0x7413, (q15_t)0xca0d, + (q15_t)0x7410, (q15_t)0xca08, (q15_t)0x740d, (q15_t)0xca02, (q15_t)0x740b, + (q15_t)0xc9fc, (q15_t)0x7408, (q15_t)0xc9f7, (q15_t)0x7406, (q15_t)0xc9f1, + (q15_t)0x7403, (q15_t)0xc9eb, (q15_t)0x7400, (q15_t)0xc9e6, (q15_t)0x73fe, + (q15_t)0xc9e0, (q15_t)0x73fb, (q15_t)0xc9da, (q15_t)0x73f8, (q15_t)0xc9d5, + (q15_t)0x73f6, (q15_t)0xc9cf, (q15_t)0x73f3, (q15_t)0xc9c9, (q15_t)0x73f0, + (q15_t)0xc9c3, (q15_t)0x73ee, (q15_t)0xc9be, (q15_t)0x73eb, (q15_t)0xc9b8, + (q15_t)0x73e8, (q15_t)0xc9b2, (q15_t)0x73e6, (q15_t)0xc9ad, (q15_t)0x73e3, + (q15_t)0xc9a7, (q15_t)0x73e0, (q15_t)0xc9a1, (q15_t)0x73de, (q15_t)0xc99c, + (q15_t)0x73db, (q15_t)0xc996, (q15_t)0x73d8, (q15_t)0xc990, (q15_t)0x73d6, + (q15_t)0xc98b, (q15_t)0x73d3, (q15_t)0xc985, (q15_t)0x73d0, (q15_t)0xc97f, + (q15_t)0x73ce, (q15_t)0xc97a, (q15_t)0x73cb, (q15_t)0xc974, (q15_t)0x73c8, + (q15_t)0xc96e, (q15_t)0x73c6, (q15_t)0xc968, (q15_t)0x73c3, (q15_t)0xc963, + (q15_t)0x73c0, (q15_t)0xc95d, (q15_t)0x73bd, (q15_t)0xc957, (q15_t)0x73bb, + (q15_t)0xc952, (q15_t)0x73b8, (q15_t)0xc94c, (q15_t)0x73b5, (q15_t)0xc946, + (q15_t)0x73b3, (q15_t)0xc941, (q15_t)0x73b0, (q15_t)0xc93b, (q15_t)0x73ad, + (q15_t)0xc935, (q15_t)0x73ab, (q15_t)0xc930, (q15_t)0x73a8, (q15_t)0xc92a, + (q15_t)0x73a5, (q15_t)0xc924, (q15_t)0x73a3, (q15_t)0xc91f, (q15_t)0x73a0, + (q15_t)0xc919, (q15_t)0x739d, (q15_t)0xc913, (q15_t)0x739b, (q15_t)0xc90e, + (q15_t)0x7398, (q15_t)0xc908, (q15_t)0x7395, (q15_t)0xc902, (q15_t)0x7392, + (q15_t)0xc8fd, (q15_t)0x7390, (q15_t)0xc8f7, (q15_t)0x738d, (q15_t)0xc8f1, + (q15_t)0x738a, (q15_t)0xc8ec, (q15_t)0x7388, (q15_t)0xc8e6, (q15_t)0x7385, + (q15_t)0xc8e0, (q15_t)0x7382, (q15_t)0xc8db, (q15_t)0x737f, (q15_t)0xc8d5, + (q15_t)0x737d, (q15_t)0xc8cf, (q15_t)0x737a, (q15_t)0xc8ca, (q15_t)0x7377, + (q15_t)0xc8c4, (q15_t)0x7375, (q15_t)0xc8be, (q15_t)0x7372, (q15_t)0xc8b9, + (q15_t)0x736f, (q15_t)0xc8b3, (q15_t)0x736c, (q15_t)0xc8ad, (q15_t)0x736a, + (q15_t)0xc8a8, (q15_t)0x7367, (q15_t)0xc8a2, (q15_t)0x7364, (q15_t)0xc89c, + (q15_t)0x7362, (q15_t)0xc897, (q15_t)0x735f, (q15_t)0xc891, (q15_t)0x735c, + (q15_t)0xc88b, (q15_t)0x7359, (q15_t)0xc886, (q15_t)0x7357, (q15_t)0xc880, + (q15_t)0x7354, (q15_t)0xc87a, (q15_t)0x7351, (q15_t)0xc875, (q15_t)0x734f, + (q15_t)0xc86f, (q15_t)0x734c, (q15_t)0xc869, (q15_t)0x7349, (q15_t)0xc864, + (q15_t)0x7346, (q15_t)0xc85e, (q15_t)0x7344, (q15_t)0xc858, (q15_t)0x7341, + (q15_t)0xc853, (q15_t)0x733e, (q15_t)0xc84d, (q15_t)0x733b, (q15_t)0xc847, + (q15_t)0x7339, (q15_t)0xc842, (q15_t)0x7336, (q15_t)0xc83c, (q15_t)0x7333, + (q15_t)0xc836, (q15_t)0x7330, (q15_t)0xc831, (q15_t)0x732e, (q15_t)0xc82b, + (q15_t)0x732b, (q15_t)0xc825, (q15_t)0x7328, (q15_t)0xc820, (q15_t)0x7326, + (q15_t)0xc81a, (q15_t)0x7323, (q15_t)0xc814, (q15_t)0x7320, (q15_t)0xc80f, + (q15_t)0x731d, (q15_t)0xc809, (q15_t)0x731b, (q15_t)0xc803, (q15_t)0x7318, + (q15_t)0xc7fe, (q15_t)0x7315, (q15_t)0xc7f8, (q15_t)0x7312, (q15_t)0xc7f3, + (q15_t)0x7310, (q15_t)0xc7ed, (q15_t)0x730d, (q15_t)0xc7e7, (q15_t)0x730a, + (q15_t)0xc7e2, (q15_t)0x7307, (q15_t)0xc7dc, (q15_t)0x7305, (q15_t)0xc7d6, + (q15_t)0x7302, (q15_t)0xc7d1, (q15_t)0x72ff, (q15_t)0xc7cb, (q15_t)0x72fc, + (q15_t)0xc7c5, (q15_t)0x72f9, (q15_t)0xc7c0, (q15_t)0x72f7, (q15_t)0xc7ba, + (q15_t)0x72f4, (q15_t)0xc7b4, (q15_t)0x72f1, (q15_t)0xc7af, (q15_t)0x72ee, + (q15_t)0xc7a9, (q15_t)0x72ec, (q15_t)0xc7a3, (q15_t)0x72e9, (q15_t)0xc79e, + (q15_t)0x72e6, (q15_t)0xc798, (q15_t)0x72e3, (q15_t)0xc793, (q15_t)0x72e1, + (q15_t)0xc78d, (q15_t)0x72de, (q15_t)0xc787, (q15_t)0x72db, (q15_t)0xc782, + (q15_t)0x72d8, (q15_t)0xc77c, (q15_t)0x72d5, (q15_t)0xc776, (q15_t)0x72d3, + (q15_t)0xc771, (q15_t)0x72d0, (q15_t)0xc76b, (q15_t)0x72cd, (q15_t)0xc765, + (q15_t)0x72ca, (q15_t)0xc760, (q15_t)0x72c8, (q15_t)0xc75a, (q15_t)0x72c5, + (q15_t)0xc755, (q15_t)0x72c2, (q15_t)0xc74f, (q15_t)0x72bf, (q15_t)0xc749, + (q15_t)0x72bc, (q15_t)0xc744, (q15_t)0x72ba, (q15_t)0xc73e, (q15_t)0x72b7, + (q15_t)0xc738, (q15_t)0x72b4, (q15_t)0xc733, (q15_t)0x72b1, (q15_t)0xc72d, + (q15_t)0x72af, (q15_t)0xc728, (q15_t)0x72ac, (q15_t)0xc722, (q15_t)0x72a9, + (q15_t)0xc71c, (q15_t)0x72a6, (q15_t)0xc717, (q15_t)0x72a3, (q15_t)0xc711, + (q15_t)0x72a1, (q15_t)0xc70b, (q15_t)0x729e, (q15_t)0xc706, (q15_t)0x729b, + (q15_t)0xc700, (q15_t)0x7298, (q15_t)0xc6fa, (q15_t)0x7295, (q15_t)0xc6f5, + (q15_t)0x7293, (q15_t)0xc6ef, (q15_t)0x7290, (q15_t)0xc6ea, (q15_t)0x728d, + (q15_t)0xc6e4, (q15_t)0x728a, (q15_t)0xc6de, (q15_t)0x7287, (q15_t)0xc6d9, + (q15_t)0x7285, (q15_t)0xc6d3, (q15_t)0x7282, (q15_t)0xc6ce, (q15_t)0x727f, + (q15_t)0xc6c8, (q15_t)0x727c, (q15_t)0xc6c2, (q15_t)0x7279, (q15_t)0xc6bd, + (q15_t)0x7276, (q15_t)0xc6b7, (q15_t)0x7274, (q15_t)0xc6b1, (q15_t)0x7271, + (q15_t)0xc6ac, (q15_t)0x726e, (q15_t)0xc6a6, (q15_t)0x726b, (q15_t)0xc6a1, + (q15_t)0x7268, (q15_t)0xc69b, (q15_t)0x7266, (q15_t)0xc695, (q15_t)0x7263, + (q15_t)0xc690, (q15_t)0x7260, (q15_t)0xc68a, (q15_t)0x725d, (q15_t)0xc684, + (q15_t)0x725a, (q15_t)0xc67f, (q15_t)0x7257, (q15_t)0xc679, (q15_t)0x7255, + (q15_t)0xc674, (q15_t)0x7252, (q15_t)0xc66e, (q15_t)0x724f, (q15_t)0xc668, + (q15_t)0x724c, (q15_t)0xc663, (q15_t)0x7249, (q15_t)0xc65d, (q15_t)0x7247, + (q15_t)0xc658, (q15_t)0x7244, (q15_t)0xc652, (q15_t)0x7241, (q15_t)0xc64c, + (q15_t)0x723e, (q15_t)0xc647, (q15_t)0x723b, (q15_t)0xc641, (q15_t)0x7238, + (q15_t)0xc63c, (q15_t)0x7236, (q15_t)0xc636, (q15_t)0x7233, (q15_t)0xc630, + (q15_t)0x7230, (q15_t)0xc62b, (q15_t)0x722d, (q15_t)0xc625, (q15_t)0x722a, + (q15_t)0xc620, (q15_t)0x7227, (q15_t)0xc61a, (q15_t)0x7224, (q15_t)0xc614, + (q15_t)0x7222, (q15_t)0xc60f, (q15_t)0x721f, (q15_t)0xc609, (q15_t)0x721c, + (q15_t)0xc603, (q15_t)0x7219, (q15_t)0xc5fe, (q15_t)0x7216, (q15_t)0xc5f8, + (q15_t)0x7213, (q15_t)0xc5f3, (q15_t)0x7211, (q15_t)0xc5ed, (q15_t)0x720e, + (q15_t)0xc5e7, (q15_t)0x720b, (q15_t)0xc5e2, (q15_t)0x7208, (q15_t)0xc5dc, + (q15_t)0x7205, (q15_t)0xc5d7, (q15_t)0x7202, (q15_t)0xc5d1, (q15_t)0x71ff, + (q15_t)0xc5cc, (q15_t)0x71fd, (q15_t)0xc5c6, (q15_t)0x71fa, (q15_t)0xc5c0, + (q15_t)0x71f7, (q15_t)0xc5bb, (q15_t)0x71f4, (q15_t)0xc5b5, (q15_t)0x71f1, + (q15_t)0xc5b0, (q15_t)0x71ee, (q15_t)0xc5aa, (q15_t)0x71eb, (q15_t)0xc5a4, + (q15_t)0x71e9, (q15_t)0xc59f, (q15_t)0x71e6, (q15_t)0xc599, (q15_t)0x71e3, + (q15_t)0xc594, (q15_t)0x71e0, (q15_t)0xc58e, (q15_t)0x71dd, (q15_t)0xc588, + (q15_t)0x71da, (q15_t)0xc583, (q15_t)0x71d7, (q15_t)0xc57d, (q15_t)0x71d4, + (q15_t)0xc578, (q15_t)0x71d2, (q15_t)0xc572, (q15_t)0x71cf, (q15_t)0xc56c, + (q15_t)0x71cc, (q15_t)0xc567, (q15_t)0x71c9, (q15_t)0xc561, (q15_t)0x71c6, + (q15_t)0xc55c, (q15_t)0x71c3, (q15_t)0xc556, (q15_t)0x71c0, (q15_t)0xc551, + (q15_t)0x71bd, (q15_t)0xc54b, (q15_t)0x71bb, (q15_t)0xc545, (q15_t)0x71b8, + (q15_t)0xc540, (q15_t)0x71b5, (q15_t)0xc53a, (q15_t)0x71b2, (q15_t)0xc535, + (q15_t)0x71af, (q15_t)0xc52f, (q15_t)0x71ac, (q15_t)0xc529, (q15_t)0x71a9, + (q15_t)0xc524, (q15_t)0x71a6, (q15_t)0xc51e, (q15_t)0x71a3, (q15_t)0xc519, + (q15_t)0x71a1, (q15_t)0xc513, (q15_t)0x719e, (q15_t)0xc50e, (q15_t)0x719b, + (q15_t)0xc508, (q15_t)0x7198, (q15_t)0xc502, (q15_t)0x7195, (q15_t)0xc4fd, + (q15_t)0x7192, (q15_t)0xc4f7, (q15_t)0x718f, (q15_t)0xc4f2, (q15_t)0x718c, + (q15_t)0xc4ec, (q15_t)0x7189, (q15_t)0xc4e7, (q15_t)0x7186, (q15_t)0xc4e1, + (q15_t)0x7184, (q15_t)0xc4db, (q15_t)0x7181, (q15_t)0xc4d6, (q15_t)0x717e, + (q15_t)0xc4d0, (q15_t)0x717b, (q15_t)0xc4cb, (q15_t)0x7178, (q15_t)0xc4c5, + (q15_t)0x7175, (q15_t)0xc4c0, (q15_t)0x7172, (q15_t)0xc4ba, (q15_t)0x716f, + (q15_t)0xc4b4, (q15_t)0x716c, (q15_t)0xc4af, (q15_t)0x7169, (q15_t)0xc4a9, + (q15_t)0x7167, (q15_t)0xc4a4, (q15_t)0x7164, (q15_t)0xc49e, (q15_t)0x7161, + (q15_t)0xc499, (q15_t)0x715e, (q15_t)0xc493, (q15_t)0x715b, (q15_t)0xc48d, + (q15_t)0x7158, (q15_t)0xc488, (q15_t)0x7155, (q15_t)0xc482, (q15_t)0x7152, + (q15_t)0xc47d, (q15_t)0x714f, (q15_t)0xc477, (q15_t)0x714c, (q15_t)0xc472, + (q15_t)0x7149, (q15_t)0xc46c, (q15_t)0x7146, (q15_t)0xc467, (q15_t)0x7143, + (q15_t)0xc461, (q15_t)0x7141, (q15_t)0xc45b, (q15_t)0x713e, (q15_t)0xc456, + (q15_t)0x713b, (q15_t)0xc450, (q15_t)0x7138, (q15_t)0xc44b, (q15_t)0x7135, + (q15_t)0xc445, (q15_t)0x7132, (q15_t)0xc440, (q15_t)0x712f, (q15_t)0xc43a, + (q15_t)0x712c, (q15_t)0xc434, (q15_t)0x7129, (q15_t)0xc42f, (q15_t)0x7126, + (q15_t)0xc429, (q15_t)0x7123, (q15_t)0xc424, (q15_t)0x7120, (q15_t)0xc41e, + (q15_t)0x711d, (q15_t)0xc419, (q15_t)0x711a, (q15_t)0xc413, (q15_t)0x7117, + (q15_t)0xc40e, (q15_t)0x7114, (q15_t)0xc408, (q15_t)0x7112, (q15_t)0xc403, + (q15_t)0x710f, (q15_t)0xc3fd, (q15_t)0x710c, (q15_t)0xc3f7, (q15_t)0x7109, + (q15_t)0xc3f2, (q15_t)0x7106, (q15_t)0xc3ec, (q15_t)0x7103, (q15_t)0xc3e7, + (q15_t)0x7100, (q15_t)0xc3e1, (q15_t)0x70fd, (q15_t)0xc3dc, (q15_t)0x70fa, + (q15_t)0xc3d6, (q15_t)0x70f7, (q15_t)0xc3d1, (q15_t)0x70f4, (q15_t)0xc3cb, + (q15_t)0x70f1, (q15_t)0xc3c5, (q15_t)0x70ee, (q15_t)0xc3c0, (q15_t)0x70eb, + (q15_t)0xc3ba, (q15_t)0x70e8, (q15_t)0xc3b5, (q15_t)0x70e5, (q15_t)0xc3af, + (q15_t)0x70e2, (q15_t)0xc3aa, (q15_t)0x70df, (q15_t)0xc3a4, (q15_t)0x70dc, + (q15_t)0xc39f, (q15_t)0x70d9, (q15_t)0xc399, (q15_t)0x70d6, (q15_t)0xc394, + (q15_t)0x70d3, (q15_t)0xc38e, (q15_t)0x70d1, (q15_t)0xc389, (q15_t)0x70ce, + (q15_t)0xc383, (q15_t)0x70cb, (q15_t)0xc37d, (q15_t)0x70c8, (q15_t)0xc378, + (q15_t)0x70c5, (q15_t)0xc372, (q15_t)0x70c2, (q15_t)0xc36d, (q15_t)0x70bf, + (q15_t)0xc367, (q15_t)0x70bc, (q15_t)0xc362, (q15_t)0x70b9, (q15_t)0xc35c, + (q15_t)0x70b6, (q15_t)0xc357, (q15_t)0x70b3, (q15_t)0xc351, (q15_t)0x70b0, + (q15_t)0xc34c, (q15_t)0x70ad, (q15_t)0xc346, (q15_t)0x70aa, (q15_t)0xc341, + (q15_t)0x70a7, (q15_t)0xc33b, (q15_t)0x70a4, (q15_t)0xc336, (q15_t)0x70a1, + (q15_t)0xc330, (q15_t)0x709e, (q15_t)0xc32a, (q15_t)0x709b, (q15_t)0xc325, + (q15_t)0x7098, (q15_t)0xc31f, (q15_t)0x7095, (q15_t)0xc31a, (q15_t)0x7092, + (q15_t)0xc314, (q15_t)0x708f, (q15_t)0xc30f, (q15_t)0x708c, (q15_t)0xc309, + (q15_t)0x7089, (q15_t)0xc304, (q15_t)0x7086, (q15_t)0xc2fe, (q15_t)0x7083, + (q15_t)0xc2f9, (q15_t)0x7080, (q15_t)0xc2f3, (q15_t)0x707d, (q15_t)0xc2ee, + (q15_t)0x707a, (q15_t)0xc2e8, (q15_t)0x7077, (q15_t)0xc2e3, (q15_t)0x7074, + (q15_t)0xc2dd, (q15_t)0x7071, (q15_t)0xc2d8, (q15_t)0x706e, (q15_t)0xc2d2, + (q15_t)0x706b, (q15_t)0xc2cd, (q15_t)0x7068, (q15_t)0xc2c7, (q15_t)0x7065, + (q15_t)0xc2c2, (q15_t)0x7062, (q15_t)0xc2bc, (q15_t)0x705f, (q15_t)0xc2b7, + (q15_t)0x705c, (q15_t)0xc2b1, (q15_t)0x7059, (q15_t)0xc2ab, (q15_t)0x7056, + (q15_t)0xc2a6, (q15_t)0x7053, (q15_t)0xc2a0, (q15_t)0x7050, (q15_t)0xc29b, + (q15_t)0x704d, (q15_t)0xc295, (q15_t)0x704a, (q15_t)0xc290, (q15_t)0x7047, + (q15_t)0xc28a, (q15_t)0x7044, (q15_t)0xc285, (q15_t)0x7041, (q15_t)0xc27f, + (q15_t)0x703e, (q15_t)0xc27a, (q15_t)0x703b, (q15_t)0xc274, (q15_t)0x7038, + (q15_t)0xc26f, (q15_t)0x7035, (q15_t)0xc269, (q15_t)0x7032, (q15_t)0xc264, + (q15_t)0x702f, (q15_t)0xc25e, (q15_t)0x702c, (q15_t)0xc259, (q15_t)0x7029, + (q15_t)0xc253, (q15_t)0x7026, (q15_t)0xc24e, (q15_t)0x7023, (q15_t)0xc248, + (q15_t)0x7020, (q15_t)0xc243, (q15_t)0x701d, (q15_t)0xc23d, (q15_t)0x7019, + (q15_t)0xc238, (q15_t)0x7016, (q15_t)0xc232, (q15_t)0x7013, (q15_t)0xc22d, + (q15_t)0x7010, (q15_t)0xc227, (q15_t)0x700d, (q15_t)0xc222, (q15_t)0x700a, + (q15_t)0xc21c, (q15_t)0x7007, (q15_t)0xc217, (q15_t)0x7004, (q15_t)0xc211, + (q15_t)0x7001, (q15_t)0xc20c, (q15_t)0x6ffe, (q15_t)0xc206, (q15_t)0x6ffb, + (q15_t)0xc201, (q15_t)0x6ff8, (q15_t)0xc1fb, (q15_t)0x6ff5, (q15_t)0xc1f6, + (q15_t)0x6ff2, (q15_t)0xc1f0, (q15_t)0x6fef, (q15_t)0xc1eb, (q15_t)0x6fec, + (q15_t)0xc1e5, (q15_t)0x6fe9, (q15_t)0xc1e0, (q15_t)0x6fe6, (q15_t)0xc1da, + (q15_t)0x6fe3, (q15_t)0xc1d5, (q15_t)0x6fe0, (q15_t)0xc1cf, (q15_t)0x6fdd, + (q15_t)0xc1ca, (q15_t)0x6fda, (q15_t)0xc1c4, (q15_t)0x6fd6, (q15_t)0xc1bf, + (q15_t)0x6fd3, (q15_t)0xc1b9, (q15_t)0x6fd0, (q15_t)0xc1b4, (q15_t)0x6fcd, + (q15_t)0xc1ae, (q15_t)0x6fca, (q15_t)0xc1a9, (q15_t)0x6fc7, (q15_t)0xc1a3, + (q15_t)0x6fc4, (q15_t)0xc19e, (q15_t)0x6fc1, (q15_t)0xc198, (q15_t)0x6fbe, + (q15_t)0xc193, (q15_t)0x6fbb, (q15_t)0xc18d, (q15_t)0x6fb8, (q15_t)0xc188, + (q15_t)0x6fb5, (q15_t)0xc183, (q15_t)0x6fb2, (q15_t)0xc17d, (q15_t)0x6faf, + (q15_t)0xc178, (q15_t)0x6fac, (q15_t)0xc172, (q15_t)0x6fa9, (q15_t)0xc16d, + (q15_t)0x6fa5, (q15_t)0xc167, (q15_t)0x6fa2, (q15_t)0xc162, (q15_t)0x6f9f, + (q15_t)0xc15c, (q15_t)0x6f9c, (q15_t)0xc157, (q15_t)0x6f99, (q15_t)0xc151, + (q15_t)0x6f96, (q15_t)0xc14c, (q15_t)0x6f93, (q15_t)0xc146, (q15_t)0x6f90, + (q15_t)0xc141, (q15_t)0x6f8d, (q15_t)0xc13b, (q15_t)0x6f8a, (q15_t)0xc136, + (q15_t)0x6f87, (q15_t)0xc130, (q15_t)0x6f84, (q15_t)0xc12b, (q15_t)0x6f81, + (q15_t)0xc125, (q15_t)0x6f7d, (q15_t)0xc120, (q15_t)0x6f7a, (q15_t)0xc11a, + (q15_t)0x6f77, (q15_t)0xc115, (q15_t)0x6f74, (q15_t)0xc10f, (q15_t)0x6f71, + (q15_t)0xc10a, (q15_t)0x6f6e, (q15_t)0xc105, (q15_t)0x6f6b, (q15_t)0xc0ff, + (q15_t)0x6f68, (q15_t)0xc0fa, (q15_t)0x6f65, (q15_t)0xc0f4, (q15_t)0x6f62, + (q15_t)0xc0ef, (q15_t)0x6f5f, (q15_t)0xc0e9, (q15_t)0x6f5b, (q15_t)0xc0e4, + (q15_t)0x6f58, (q15_t)0xc0de, (q15_t)0x6f55, (q15_t)0xc0d9, (q15_t)0x6f52, + (q15_t)0xc0d3, (q15_t)0x6f4f, (q15_t)0xc0ce, (q15_t)0x6f4c, (q15_t)0xc0c8, + (q15_t)0x6f49, (q15_t)0xc0c3, (q15_t)0x6f46, (q15_t)0xc0bd, (q15_t)0x6f43, + (q15_t)0xc0b8, (q15_t)0x6f3f, (q15_t)0xc0b3, (q15_t)0x6f3c, (q15_t)0xc0ad, + (q15_t)0x6f39, (q15_t)0xc0a8, (q15_t)0x6f36, (q15_t)0xc0a2, (q15_t)0x6f33, + (q15_t)0xc09d, (q15_t)0x6f30, (q15_t)0xc097, (q15_t)0x6f2d, (q15_t)0xc092, + (q15_t)0x6f2a, (q15_t)0xc08c, (q15_t)0x6f27, (q15_t)0xc087, (q15_t)0x6f23, + (q15_t)0xc081, (q15_t)0x6f20, (q15_t)0xc07c, (q15_t)0x6f1d, (q15_t)0xc077, + (q15_t)0x6f1a, (q15_t)0xc071, (q15_t)0x6f17, (q15_t)0xc06c, (q15_t)0x6f14, + (q15_t)0xc066, (q15_t)0x6f11, (q15_t)0xc061, (q15_t)0x6f0e, (q15_t)0xc05b, + (q15_t)0x6f0b, (q15_t)0xc056, (q15_t)0x6f07, (q15_t)0xc050, (q15_t)0x6f04, + (q15_t)0xc04b, (q15_t)0x6f01, (q15_t)0xc045, (q15_t)0x6efe, (q15_t)0xc040, + (q15_t)0x6efb, (q15_t)0xc03b, (q15_t)0x6ef8, (q15_t)0xc035, (q15_t)0x6ef5, + (q15_t)0xc030, (q15_t)0x6ef1, (q15_t)0xc02a, (q15_t)0x6eee, (q15_t)0xc025, + (q15_t)0x6eeb, (q15_t)0xc01f, (q15_t)0x6ee8, (q15_t)0xc01a, (q15_t)0x6ee5, + (q15_t)0xc014, (q15_t)0x6ee2, (q15_t)0xc00f, (q15_t)0x6edf, (q15_t)0xc00a, + (q15_t)0x6edc, (q15_t)0xc004, (q15_t)0x6ed8, (q15_t)0xbfff, (q15_t)0x6ed5, + (q15_t)0xbff9, (q15_t)0x6ed2, (q15_t)0xbff4, (q15_t)0x6ecf, (q15_t)0xbfee, + (q15_t)0x6ecc, (q15_t)0xbfe9, (q15_t)0x6ec9, (q15_t)0xbfe3, (q15_t)0x6ec6, + (q15_t)0xbfde, (q15_t)0x6ec2, (q15_t)0xbfd9, (q15_t)0x6ebf, (q15_t)0xbfd3, + (q15_t)0x6ebc, (q15_t)0xbfce, (q15_t)0x6eb9, (q15_t)0xbfc8, (q15_t)0x6eb6, + (q15_t)0xbfc3, (q15_t)0x6eb3, (q15_t)0xbfbd, (q15_t)0x6eaf, (q15_t)0xbfb8, + (q15_t)0x6eac, (q15_t)0xbfb3, (q15_t)0x6ea9, (q15_t)0xbfad, (q15_t)0x6ea6, + (q15_t)0xbfa8, (q15_t)0x6ea3, (q15_t)0xbfa2, (q15_t)0x6ea0, (q15_t)0xbf9d, + (q15_t)0x6e9c, (q15_t)0xbf97, (q15_t)0x6e99, (q15_t)0xbf92, (q15_t)0x6e96, + (q15_t)0xbf8d, (q15_t)0x6e93, (q15_t)0xbf87, (q15_t)0x6e90, (q15_t)0xbf82, + (q15_t)0x6e8d, (q15_t)0xbf7c, (q15_t)0x6e89, (q15_t)0xbf77, (q15_t)0x6e86, + (q15_t)0xbf71, (q15_t)0x6e83, (q15_t)0xbf6c, (q15_t)0x6e80, (q15_t)0xbf67, + (q15_t)0x6e7d, (q15_t)0xbf61, (q15_t)0x6e7a, (q15_t)0xbf5c, (q15_t)0x6e76, + (q15_t)0xbf56, (q15_t)0x6e73, (q15_t)0xbf51, (q15_t)0x6e70, (q15_t)0xbf4b, + (q15_t)0x6e6d, (q15_t)0xbf46, (q15_t)0x6e6a, (q15_t)0xbf41, (q15_t)0x6e67, + (q15_t)0xbf3b, (q15_t)0x6e63, (q15_t)0xbf36, (q15_t)0x6e60, (q15_t)0xbf30, + (q15_t)0x6e5d, (q15_t)0xbf2b, (q15_t)0x6e5a, (q15_t)0xbf26, (q15_t)0x6e57, + (q15_t)0xbf20, (q15_t)0x6e53, (q15_t)0xbf1b, (q15_t)0x6e50, (q15_t)0xbf15, + (q15_t)0x6e4d, (q15_t)0xbf10, (q15_t)0x6e4a, (q15_t)0xbf0a, (q15_t)0x6e47, + (q15_t)0xbf05, (q15_t)0x6e44, (q15_t)0xbf00, (q15_t)0x6e40, (q15_t)0xbefa, + (q15_t)0x6e3d, (q15_t)0xbef5, (q15_t)0x6e3a, (q15_t)0xbeef, (q15_t)0x6e37, + (q15_t)0xbeea, (q15_t)0x6e34, (q15_t)0xbee5, (q15_t)0x6e30, (q15_t)0xbedf, + (q15_t)0x6e2d, (q15_t)0xbeda, (q15_t)0x6e2a, (q15_t)0xbed4, (q15_t)0x6e27, + (q15_t)0xbecf, (q15_t)0x6e24, (q15_t)0xbeca, (q15_t)0x6e20, (q15_t)0xbec4, + (q15_t)0x6e1d, (q15_t)0xbebf, (q15_t)0x6e1a, (q15_t)0xbeb9, (q15_t)0x6e17, + (q15_t)0xbeb4, (q15_t)0x6e14, (q15_t)0xbeae, (q15_t)0x6e10, (q15_t)0xbea9, + (q15_t)0x6e0d, (q15_t)0xbea4, (q15_t)0x6e0a, (q15_t)0xbe9e, (q15_t)0x6e07, + (q15_t)0xbe99, (q15_t)0x6e04, (q15_t)0xbe93, (q15_t)0x6e00, (q15_t)0xbe8e, + (q15_t)0x6dfd, (q15_t)0xbe89, (q15_t)0x6dfa, (q15_t)0xbe83, (q15_t)0x6df7, + (q15_t)0xbe7e, (q15_t)0x6df3, (q15_t)0xbe78, (q15_t)0x6df0, (q15_t)0xbe73, + (q15_t)0x6ded, (q15_t)0xbe6e, (q15_t)0x6dea, (q15_t)0xbe68, (q15_t)0x6de7, + (q15_t)0xbe63, (q15_t)0x6de3, (q15_t)0xbe5e, (q15_t)0x6de0, (q15_t)0xbe58, + (q15_t)0x6ddd, (q15_t)0xbe53, (q15_t)0x6dda, (q15_t)0xbe4d, (q15_t)0x6dd6, + (q15_t)0xbe48, (q15_t)0x6dd3, (q15_t)0xbe43, (q15_t)0x6dd0, (q15_t)0xbe3d, + (q15_t)0x6dcd, (q15_t)0xbe38, (q15_t)0x6dca, (q15_t)0xbe32, (q15_t)0x6dc6, + (q15_t)0xbe2d, (q15_t)0x6dc3, (q15_t)0xbe28, (q15_t)0x6dc0, (q15_t)0xbe22, + (q15_t)0x6dbd, (q15_t)0xbe1d, (q15_t)0x6db9, (q15_t)0xbe17, (q15_t)0x6db6, + (q15_t)0xbe12, (q15_t)0x6db3, (q15_t)0xbe0d, (q15_t)0x6db0, (q15_t)0xbe07, + (q15_t)0x6dac, (q15_t)0xbe02, (q15_t)0x6da9, (q15_t)0xbdfd, (q15_t)0x6da6, + (q15_t)0xbdf7, (q15_t)0x6da3, (q15_t)0xbdf2, (q15_t)0x6d9f, (q15_t)0xbdec, + (q15_t)0x6d9c, (q15_t)0xbde7, (q15_t)0x6d99, (q15_t)0xbde2, (q15_t)0x6d96, + (q15_t)0xbddc, (q15_t)0x6d92, (q15_t)0xbdd7, (q15_t)0x6d8f, (q15_t)0xbdd1, + (q15_t)0x6d8c, (q15_t)0xbdcc, (q15_t)0x6d89, (q15_t)0xbdc7, (q15_t)0x6d85, + (q15_t)0xbdc1, (q15_t)0x6d82, (q15_t)0xbdbc, (q15_t)0x6d7f, (q15_t)0xbdb7, + (q15_t)0x6d7c, (q15_t)0xbdb1, (q15_t)0x6d78, (q15_t)0xbdac, (q15_t)0x6d75, + (q15_t)0xbda6, (q15_t)0x6d72, (q15_t)0xbda1, (q15_t)0x6d6f, (q15_t)0xbd9c, + (q15_t)0x6d6b, (q15_t)0xbd96, (q15_t)0x6d68, (q15_t)0xbd91, (q15_t)0x6d65, + (q15_t)0xbd8c, (q15_t)0x6d62, (q15_t)0xbd86, (q15_t)0x6d5e, (q15_t)0xbd81, + (q15_t)0x6d5b, (q15_t)0xbd7c, (q15_t)0x6d58, (q15_t)0xbd76, (q15_t)0x6d55, + (q15_t)0xbd71, (q15_t)0x6d51, (q15_t)0xbd6b, (q15_t)0x6d4e, (q15_t)0xbd66, + (q15_t)0x6d4b, (q15_t)0xbd61, (q15_t)0x6d48, (q15_t)0xbd5b, (q15_t)0x6d44, + (q15_t)0xbd56, (q15_t)0x6d41, (q15_t)0xbd51, (q15_t)0x6d3e, (q15_t)0xbd4b, + (q15_t)0x6d3a, (q15_t)0xbd46, (q15_t)0x6d37, (q15_t)0xbd40, (q15_t)0x6d34, + (q15_t)0xbd3b, (q15_t)0x6d31, (q15_t)0xbd36, (q15_t)0x6d2d, (q15_t)0xbd30, + (q15_t)0x6d2a, (q15_t)0xbd2b, (q15_t)0x6d27, (q15_t)0xbd26, (q15_t)0x6d23, + (q15_t)0xbd20, (q15_t)0x6d20, (q15_t)0xbd1b, (q15_t)0x6d1d, (q15_t)0xbd16, + (q15_t)0x6d1a, (q15_t)0xbd10, (q15_t)0x6d16, (q15_t)0xbd0b, (q15_t)0x6d13, + (q15_t)0xbd06, (q15_t)0x6d10, (q15_t)0xbd00, (q15_t)0x6d0c, (q15_t)0xbcfb, + (q15_t)0x6d09, (q15_t)0xbcf5, (q15_t)0x6d06, (q15_t)0xbcf0, (q15_t)0x6d03, + (q15_t)0xbceb, (q15_t)0x6cff, (q15_t)0xbce5, (q15_t)0x6cfc, (q15_t)0xbce0, + (q15_t)0x6cf9, (q15_t)0xbcdb, (q15_t)0x6cf5, (q15_t)0xbcd5, (q15_t)0x6cf2, + (q15_t)0xbcd0, (q15_t)0x6cef, (q15_t)0xbccb, (q15_t)0x6cec, (q15_t)0xbcc5, + (q15_t)0x6ce8, (q15_t)0xbcc0, (q15_t)0x6ce5, (q15_t)0xbcbb, (q15_t)0x6ce2, + (q15_t)0xbcb5, (q15_t)0x6cde, (q15_t)0xbcb0, (q15_t)0x6cdb, (q15_t)0xbcab, + (q15_t)0x6cd8, (q15_t)0xbca5, (q15_t)0x6cd4, (q15_t)0xbca0, (q15_t)0x6cd1, + (q15_t)0xbc9b, (q15_t)0x6cce, (q15_t)0xbc95, (q15_t)0x6cca, (q15_t)0xbc90, + (q15_t)0x6cc7, (q15_t)0xbc8b, (q15_t)0x6cc4, (q15_t)0xbc85, (q15_t)0x6cc1, + (q15_t)0xbc80, (q15_t)0x6cbd, (q15_t)0xbc7b, (q15_t)0x6cba, (q15_t)0xbc75, + (q15_t)0x6cb7, (q15_t)0xbc70, (q15_t)0x6cb3, (q15_t)0xbc6b, (q15_t)0x6cb0, + (q15_t)0xbc65, (q15_t)0x6cad, (q15_t)0xbc60, (q15_t)0x6ca9, (q15_t)0xbc5b, + (q15_t)0x6ca6, (q15_t)0xbc55, (q15_t)0x6ca3, (q15_t)0xbc50, (q15_t)0x6c9f, + (q15_t)0xbc4b, (q15_t)0x6c9c, (q15_t)0xbc45, (q15_t)0x6c99, (q15_t)0xbc40, + (q15_t)0x6c95, (q15_t)0xbc3b, (q15_t)0x6c92, (q15_t)0xbc35, (q15_t)0x6c8f, + (q15_t)0xbc30, (q15_t)0x6c8b, (q15_t)0xbc2b, (q15_t)0x6c88, (q15_t)0xbc25, + (q15_t)0x6c85, (q15_t)0xbc20, (q15_t)0x6c81, (q15_t)0xbc1b, (q15_t)0x6c7e, + (q15_t)0xbc15, (q15_t)0x6c7b, (q15_t)0xbc10, (q15_t)0x6c77, (q15_t)0xbc0b, + (q15_t)0x6c74, (q15_t)0xbc05, (q15_t)0x6c71, (q15_t)0xbc00, (q15_t)0x6c6d, + (q15_t)0xbbfb, (q15_t)0x6c6a, (q15_t)0xbbf5, (q15_t)0x6c67, (q15_t)0xbbf0, + (q15_t)0x6c63, (q15_t)0xbbeb, (q15_t)0x6c60, (q15_t)0xbbe5, (q15_t)0x6c5d, + (q15_t)0xbbe0, (q15_t)0x6c59, (q15_t)0xbbdb, (q15_t)0x6c56, (q15_t)0xbbd5, + (q15_t)0x6c53, (q15_t)0xbbd0, (q15_t)0x6c4f, (q15_t)0xbbcb, (q15_t)0x6c4c, + (q15_t)0xbbc5, (q15_t)0x6c49, (q15_t)0xbbc0, (q15_t)0x6c45, (q15_t)0xbbbb, + (q15_t)0x6c42, (q15_t)0xbbb5, (q15_t)0x6c3f, (q15_t)0xbbb0, (q15_t)0x6c3b, + (q15_t)0xbbab, (q15_t)0x6c38, (q15_t)0xbba6, (q15_t)0x6c34, (q15_t)0xbba0, + (q15_t)0x6c31, (q15_t)0xbb9b, (q15_t)0x6c2e, (q15_t)0xbb96, (q15_t)0x6c2a, + (q15_t)0xbb90, (q15_t)0x6c27, (q15_t)0xbb8b, (q15_t)0x6c24, (q15_t)0xbb86, + (q15_t)0x6c20, (q15_t)0xbb80, (q15_t)0x6c1d, (q15_t)0xbb7b, (q15_t)0x6c1a, + (q15_t)0xbb76, (q15_t)0x6c16, (q15_t)0xbb70, (q15_t)0x6c13, (q15_t)0xbb6b, + (q15_t)0x6c0f, (q15_t)0xbb66, (q15_t)0x6c0c, (q15_t)0xbb61, (q15_t)0x6c09, + (q15_t)0xbb5b, (q15_t)0x6c05, (q15_t)0xbb56, (q15_t)0x6c02, (q15_t)0xbb51, + (q15_t)0x6bff, (q15_t)0xbb4b, (q15_t)0x6bfb, (q15_t)0xbb46, (q15_t)0x6bf8, + (q15_t)0xbb41, (q15_t)0x6bf5, (q15_t)0xbb3b, (q15_t)0x6bf1, (q15_t)0xbb36, + (q15_t)0x6bee, (q15_t)0xbb31, (q15_t)0x6bea, (q15_t)0xbb2c, (q15_t)0x6be7, + (q15_t)0xbb26, (q15_t)0x6be4, (q15_t)0xbb21, (q15_t)0x6be0, (q15_t)0xbb1c, + (q15_t)0x6bdd, (q15_t)0xbb16, (q15_t)0x6bd9, (q15_t)0xbb11, (q15_t)0x6bd6, + (q15_t)0xbb0c, (q15_t)0x6bd3, (q15_t)0xbb06, (q15_t)0x6bcf, (q15_t)0xbb01, + (q15_t)0x6bcc, (q15_t)0xbafc, (q15_t)0x6bc9, (q15_t)0xbaf7, (q15_t)0x6bc5, + (q15_t)0xbaf1, (q15_t)0x6bc2, (q15_t)0xbaec, (q15_t)0x6bbe, (q15_t)0xbae7, + (q15_t)0x6bbb, (q15_t)0xbae1, (q15_t)0x6bb8, (q15_t)0xbadc, (q15_t)0x6bb4, + (q15_t)0xbad7, (q15_t)0x6bb1, (q15_t)0xbad2, (q15_t)0x6bad, (q15_t)0xbacc, + (q15_t)0x6baa, (q15_t)0xbac7, (q15_t)0x6ba7, (q15_t)0xbac2, (q15_t)0x6ba3, + (q15_t)0xbabc, (q15_t)0x6ba0, (q15_t)0xbab7, (q15_t)0x6b9c, (q15_t)0xbab2, + (q15_t)0x6b99, (q15_t)0xbaad, (q15_t)0x6b96, (q15_t)0xbaa7, (q15_t)0x6b92, + (q15_t)0xbaa2, (q15_t)0x6b8f, (q15_t)0xba9d, (q15_t)0x6b8b, (q15_t)0xba97, + (q15_t)0x6b88, (q15_t)0xba92, (q15_t)0x6b85, (q15_t)0xba8d, (q15_t)0x6b81, + (q15_t)0xba88, (q15_t)0x6b7e, (q15_t)0xba82, (q15_t)0x6b7a, (q15_t)0xba7d, + (q15_t)0x6b77, (q15_t)0xba78, (q15_t)0x6b73, (q15_t)0xba73, (q15_t)0x6b70, + (q15_t)0xba6d, (q15_t)0x6b6d, (q15_t)0xba68, (q15_t)0x6b69, (q15_t)0xba63, + (q15_t)0x6b66, (q15_t)0xba5d, (q15_t)0x6b62, (q15_t)0xba58, (q15_t)0x6b5f, + (q15_t)0xba53, (q15_t)0x6b5c, (q15_t)0xba4e, (q15_t)0x6b58, (q15_t)0xba48, + (q15_t)0x6b55, (q15_t)0xba43, (q15_t)0x6b51, (q15_t)0xba3e, (q15_t)0x6b4e, + (q15_t)0xba39, (q15_t)0x6b4a, (q15_t)0xba33, (q15_t)0x6b47, (q15_t)0xba2e, + (q15_t)0x6b44, (q15_t)0xba29, (q15_t)0x6b40, (q15_t)0xba23, (q15_t)0x6b3d, + (q15_t)0xba1e, (q15_t)0x6b39, (q15_t)0xba19, (q15_t)0x6b36, (q15_t)0xba14, + (q15_t)0x6b32, (q15_t)0xba0e, (q15_t)0x6b2f, (q15_t)0xba09, (q15_t)0x6b2c, + (q15_t)0xba04, (q15_t)0x6b28, (q15_t)0xb9ff, (q15_t)0x6b25, (q15_t)0xb9f9, + (q15_t)0x6b21, (q15_t)0xb9f4, (q15_t)0x6b1e, (q15_t)0xb9ef, (q15_t)0x6b1a, + (q15_t)0xb9ea, (q15_t)0x6b17, (q15_t)0xb9e4, (q15_t)0x6b13, (q15_t)0xb9df, + (q15_t)0x6b10, (q15_t)0xb9da, (q15_t)0x6b0d, (q15_t)0xb9d5, (q15_t)0x6b09, + (q15_t)0xb9cf, (q15_t)0x6b06, (q15_t)0xb9ca, (q15_t)0x6b02, (q15_t)0xb9c5, + (q15_t)0x6aff, (q15_t)0xb9c0, (q15_t)0x6afb, (q15_t)0xb9ba, (q15_t)0x6af8, + (q15_t)0xb9b5, (q15_t)0x6af4, (q15_t)0xb9b0, (q15_t)0x6af1, (q15_t)0xb9ab, + (q15_t)0x6aee, (q15_t)0xb9a5, (q15_t)0x6aea, (q15_t)0xb9a0, (q15_t)0x6ae7, + (q15_t)0xb99b, (q15_t)0x6ae3, (q15_t)0xb996, (q15_t)0x6ae0, (q15_t)0xb990, + (q15_t)0x6adc, (q15_t)0xb98b, (q15_t)0x6ad9, (q15_t)0xb986, (q15_t)0x6ad5, + (q15_t)0xb981, (q15_t)0x6ad2, (q15_t)0xb97b, (q15_t)0x6ace, (q15_t)0xb976, + (q15_t)0x6acb, (q15_t)0xb971, (q15_t)0x6ac8, (q15_t)0xb96c, (q15_t)0x6ac4, + (q15_t)0xb966, (q15_t)0x6ac1, (q15_t)0xb961, (q15_t)0x6abd, (q15_t)0xb95c, + (q15_t)0x6aba, (q15_t)0xb957, (q15_t)0x6ab6, (q15_t)0xb951, (q15_t)0x6ab3, + (q15_t)0xb94c, (q15_t)0x6aaf, (q15_t)0xb947, (q15_t)0x6aac, (q15_t)0xb942, + (q15_t)0x6aa8, (q15_t)0xb93c, (q15_t)0x6aa5, (q15_t)0xb937, (q15_t)0x6aa1, + (q15_t)0xb932, (q15_t)0x6a9e, (q15_t)0xb92d, (q15_t)0x6a9a, (q15_t)0xb928, + (q15_t)0x6a97, (q15_t)0xb922, (q15_t)0x6a93, (q15_t)0xb91d, (q15_t)0x6a90, + (q15_t)0xb918, (q15_t)0x6a8c, (q15_t)0xb913, (q15_t)0x6a89, (q15_t)0xb90d, + (q15_t)0x6a86, (q15_t)0xb908, (q15_t)0x6a82, (q15_t)0xb903, (q15_t)0x6a7f, + (q15_t)0xb8fe, (q15_t)0x6a7b, (q15_t)0xb8f8, (q15_t)0x6a78, (q15_t)0xb8f3, + (q15_t)0x6a74, (q15_t)0xb8ee, (q15_t)0x6a71, (q15_t)0xb8e9, (q15_t)0x6a6d, + (q15_t)0xb8e4, (q15_t)0x6a6a, (q15_t)0xb8de, (q15_t)0x6a66, (q15_t)0xb8d9, + (q15_t)0x6a63, (q15_t)0xb8d4, (q15_t)0x6a5f, (q15_t)0xb8cf, (q15_t)0x6a5c, + (q15_t)0xb8c9, (q15_t)0x6a58, (q15_t)0xb8c4, (q15_t)0x6a55, (q15_t)0xb8bf, + (q15_t)0x6a51, (q15_t)0xb8ba, (q15_t)0x6a4e, (q15_t)0xb8b5, (q15_t)0x6a4a, + (q15_t)0xb8af, (q15_t)0x6a47, (q15_t)0xb8aa, (q15_t)0x6a43, (q15_t)0xb8a5, + (q15_t)0x6a40, (q15_t)0xb8a0, (q15_t)0x6a3c, (q15_t)0xb89b, (q15_t)0x6a39, + (q15_t)0xb895, (q15_t)0x6a35, (q15_t)0xb890, (q15_t)0x6a32, (q15_t)0xb88b, + (q15_t)0x6a2e, (q15_t)0xb886, (q15_t)0x6a2b, (q15_t)0xb880, (q15_t)0x6a27, + (q15_t)0xb87b, (q15_t)0x6a24, (q15_t)0xb876, (q15_t)0x6a20, (q15_t)0xb871, + (q15_t)0x6a1d, (q15_t)0xb86c, (q15_t)0x6a19, (q15_t)0xb866, (q15_t)0x6a16, + (q15_t)0xb861, (q15_t)0x6a12, (q15_t)0xb85c, (q15_t)0x6a0e, (q15_t)0xb857, + (q15_t)0x6a0b, (q15_t)0xb852, (q15_t)0x6a07, (q15_t)0xb84c, (q15_t)0x6a04, + (q15_t)0xb847, (q15_t)0x6a00, (q15_t)0xb842, (q15_t)0x69fd, (q15_t)0xb83d, + (q15_t)0x69f9, (q15_t)0xb838, (q15_t)0x69f6, (q15_t)0xb832, (q15_t)0x69f2, + (q15_t)0xb82d, (q15_t)0x69ef, (q15_t)0xb828, (q15_t)0x69eb, (q15_t)0xb823, + (q15_t)0x69e8, (q15_t)0xb81e, (q15_t)0x69e4, (q15_t)0xb818, (q15_t)0x69e1, + (q15_t)0xb813, (q15_t)0x69dd, (q15_t)0xb80e, (q15_t)0x69da, (q15_t)0xb809, + (q15_t)0x69d6, (q15_t)0xb804, (q15_t)0x69d3, (q15_t)0xb7fe, (q15_t)0x69cf, + (q15_t)0xb7f9, (q15_t)0x69cb, (q15_t)0xb7f4, (q15_t)0x69c8, (q15_t)0xb7ef, + (q15_t)0x69c4, (q15_t)0xb7ea, (q15_t)0x69c1, (q15_t)0xb7e4, (q15_t)0x69bd, + (q15_t)0xb7df, (q15_t)0x69ba, (q15_t)0xb7da, (q15_t)0x69b6, (q15_t)0xb7d5, + (q15_t)0x69b3, (q15_t)0xb7d0, (q15_t)0x69af, (q15_t)0xb7ca, (q15_t)0x69ac, + (q15_t)0xb7c5, (q15_t)0x69a8, (q15_t)0xb7c0, (q15_t)0x69a5, (q15_t)0xb7bb, + (q15_t)0x69a1, (q15_t)0xb7b6, (q15_t)0x699d, (q15_t)0xb7b1, (q15_t)0x699a, + (q15_t)0xb7ab, (q15_t)0x6996, (q15_t)0xb7a6, (q15_t)0x6993, (q15_t)0xb7a1, + (q15_t)0x698f, (q15_t)0xb79c, (q15_t)0x698c, (q15_t)0xb797, (q15_t)0x6988, + (q15_t)0xb791, (q15_t)0x6985, (q15_t)0xb78c, (q15_t)0x6981, (q15_t)0xb787, + (q15_t)0x697d, (q15_t)0xb782, (q15_t)0x697a, (q15_t)0xb77d, (q15_t)0x6976, + (q15_t)0xb778, (q15_t)0x6973, (q15_t)0xb772, (q15_t)0x696f, (q15_t)0xb76d, + (q15_t)0x696c, (q15_t)0xb768, (q15_t)0x6968, (q15_t)0xb763, (q15_t)0x6964, + (q15_t)0xb75e, (q15_t)0x6961, (q15_t)0xb758, (q15_t)0x695d, (q15_t)0xb753, + (q15_t)0x695a, (q15_t)0xb74e, (q15_t)0x6956, (q15_t)0xb749, (q15_t)0x6953, + (q15_t)0xb744, (q15_t)0x694f, (q15_t)0xb73f, (q15_t)0x694b, (q15_t)0xb739, + (q15_t)0x6948, (q15_t)0xb734, (q15_t)0x6944, (q15_t)0xb72f, (q15_t)0x6941, + (q15_t)0xb72a, (q15_t)0x693d, (q15_t)0xb725, (q15_t)0x693a, (q15_t)0xb720, + (q15_t)0x6936, (q15_t)0xb71a, (q15_t)0x6932, (q15_t)0xb715, (q15_t)0x692f, + (q15_t)0xb710, (q15_t)0x692b, (q15_t)0xb70b, (q15_t)0x6928, (q15_t)0xb706, + (q15_t)0x6924, (q15_t)0xb701, (q15_t)0x6921, (q15_t)0xb6fb, (q15_t)0x691d, + (q15_t)0xb6f6, (q15_t)0x6919, (q15_t)0xb6f1, (q15_t)0x6916, (q15_t)0xb6ec, + (q15_t)0x6912, (q15_t)0xb6e7, (q15_t)0x690f, (q15_t)0xb6e2, (q15_t)0x690b, + (q15_t)0xb6dd, (q15_t)0x6907, (q15_t)0xb6d7, (q15_t)0x6904, (q15_t)0xb6d2, + (q15_t)0x6900, (q15_t)0xb6cd, (q15_t)0x68fd, (q15_t)0xb6c8, (q15_t)0x68f9, + (q15_t)0xb6c3, (q15_t)0x68f5, (q15_t)0xb6be, (q15_t)0x68f2, (q15_t)0xb6b8, + (q15_t)0x68ee, (q15_t)0xb6b3, (q15_t)0x68eb, (q15_t)0xb6ae, (q15_t)0x68e7, + (q15_t)0xb6a9, (q15_t)0x68e3, (q15_t)0xb6a4, (q15_t)0x68e0, (q15_t)0xb69f, + (q15_t)0x68dc, (q15_t)0xb69a, (q15_t)0x68d9, (q15_t)0xb694, (q15_t)0x68d5, + (q15_t)0xb68f, (q15_t)0x68d1, (q15_t)0xb68a, (q15_t)0x68ce, (q15_t)0xb685, + (q15_t)0x68ca, (q15_t)0xb680, (q15_t)0x68c7, (q15_t)0xb67b, (q15_t)0x68c3, + (q15_t)0xb676, (q15_t)0x68bf, (q15_t)0xb670, (q15_t)0x68bc, (q15_t)0xb66b, + (q15_t)0x68b8, (q15_t)0xb666, (q15_t)0x68b5, (q15_t)0xb661, (q15_t)0x68b1, + (q15_t)0xb65c, (q15_t)0x68ad, (q15_t)0xb657, (q15_t)0x68aa, (q15_t)0xb652, + (q15_t)0x68a6, (q15_t)0xb64c, (q15_t)0x68a3, (q15_t)0xb647, (q15_t)0x689f, + (q15_t)0xb642, (q15_t)0x689b, (q15_t)0xb63d, (q15_t)0x6898, (q15_t)0xb638, + (q15_t)0x6894, (q15_t)0xb633, (q15_t)0x6890, (q15_t)0xb62e, (q15_t)0x688d, + (q15_t)0xb628, (q15_t)0x6889, (q15_t)0xb623, (q15_t)0x6886, (q15_t)0xb61e, + (q15_t)0x6882, (q15_t)0xb619, (q15_t)0x687e, (q15_t)0xb614, (q15_t)0x687b, + (q15_t)0xb60f, (q15_t)0x6877, (q15_t)0xb60a, (q15_t)0x6873, (q15_t)0xb605, + (q15_t)0x6870, (q15_t)0xb5ff, (q15_t)0x686c, (q15_t)0xb5fa, (q15_t)0x6868, + (q15_t)0xb5f5, (q15_t)0x6865, (q15_t)0xb5f0, (q15_t)0x6861, (q15_t)0xb5eb, + (q15_t)0x685e, (q15_t)0xb5e6, (q15_t)0x685a, (q15_t)0xb5e1, (q15_t)0x6856, + (q15_t)0xb5dc, (q15_t)0x6853, (q15_t)0xb5d6, (q15_t)0x684f, (q15_t)0xb5d1, + (q15_t)0x684b, (q15_t)0xb5cc, (q15_t)0x6848, (q15_t)0xb5c7, (q15_t)0x6844, + (q15_t)0xb5c2, (q15_t)0x6840, (q15_t)0xb5bd, (q15_t)0x683d, (q15_t)0xb5b8, + (q15_t)0x6839, (q15_t)0xb5b3, (q15_t)0x6835, (q15_t)0xb5ae, (q15_t)0x6832, + (q15_t)0xb5a8, (q15_t)0x682e, (q15_t)0xb5a3, (q15_t)0x682b, (q15_t)0xb59e, + (q15_t)0x6827, (q15_t)0xb599, (q15_t)0x6823, (q15_t)0xb594, (q15_t)0x6820, + (q15_t)0xb58f, (q15_t)0x681c, (q15_t)0xb58a, (q15_t)0x6818, (q15_t)0xb585, + (q15_t)0x6815, (q15_t)0xb57f, (q15_t)0x6811, (q15_t)0xb57a, (q15_t)0x680d, + (q15_t)0xb575, (q15_t)0x680a, (q15_t)0xb570, (q15_t)0x6806, (q15_t)0xb56b, + (q15_t)0x6802, (q15_t)0xb566, (q15_t)0x67ff, (q15_t)0xb561, (q15_t)0x67fb, + (q15_t)0xb55c, (q15_t)0x67f7, (q15_t)0xb557, (q15_t)0x67f4, (q15_t)0xb552, + (q15_t)0x67f0, (q15_t)0xb54c, (q15_t)0x67ec, (q15_t)0xb547, (q15_t)0x67e9, + (q15_t)0xb542, (q15_t)0x67e5, (q15_t)0xb53d, (q15_t)0x67e1, (q15_t)0xb538, + (q15_t)0x67de, (q15_t)0xb533, (q15_t)0x67da, (q15_t)0xb52e, (q15_t)0x67d6, + (q15_t)0xb529, (q15_t)0x67d3, (q15_t)0xb524, (q15_t)0x67cf, (q15_t)0xb51f, + (q15_t)0x67cb, (q15_t)0xb519, (q15_t)0x67c8, (q15_t)0xb514, (q15_t)0x67c4, + (q15_t)0xb50f, (q15_t)0x67c0, (q15_t)0xb50a, (q15_t)0x67bd, (q15_t)0xb505, + (q15_t)0x67b9, (q15_t)0xb500, (q15_t)0x67b5, (q15_t)0xb4fb, (q15_t)0x67b2, + (q15_t)0xb4f6, (q15_t)0x67ae, (q15_t)0xb4f1, (q15_t)0x67aa, (q15_t)0xb4ec, + (q15_t)0x67a6, (q15_t)0xb4e7, (q15_t)0x67a3, (q15_t)0xb4e1, (q15_t)0x679f, + (q15_t)0xb4dc, (q15_t)0x679b, (q15_t)0xb4d7, (q15_t)0x6798, (q15_t)0xb4d2, + (q15_t)0x6794, (q15_t)0xb4cd, (q15_t)0x6790, (q15_t)0xb4c8, (q15_t)0x678d, + (q15_t)0xb4c3, (q15_t)0x6789, (q15_t)0xb4be, (q15_t)0x6785, (q15_t)0xb4b9, + (q15_t)0x6782, (q15_t)0xb4b4, (q15_t)0x677e, (q15_t)0xb4af, (q15_t)0x677a, + (q15_t)0xb4aa, (q15_t)0x6776, (q15_t)0xb4a4, (q15_t)0x6773, (q15_t)0xb49f, + (q15_t)0x676f, (q15_t)0xb49a, (q15_t)0x676b, (q15_t)0xb495, (q15_t)0x6768, + (q15_t)0xb490, (q15_t)0x6764, (q15_t)0xb48b, (q15_t)0x6760, (q15_t)0xb486, + (q15_t)0x675d, (q15_t)0xb481, (q15_t)0x6759, (q15_t)0xb47c, (q15_t)0x6755, + (q15_t)0xb477, (q15_t)0x6751, (q15_t)0xb472, (q15_t)0x674e, (q15_t)0xb46d, + (q15_t)0x674a, (q15_t)0xb468, (q15_t)0x6746, (q15_t)0xb462, (q15_t)0x6743, + (q15_t)0xb45d, (q15_t)0x673f, (q15_t)0xb458, (q15_t)0x673b, (q15_t)0xb453, + (q15_t)0x6737, (q15_t)0xb44e, (q15_t)0x6734, (q15_t)0xb449, (q15_t)0x6730, + (q15_t)0xb444, (q15_t)0x672c, (q15_t)0xb43f, (q15_t)0x6729, (q15_t)0xb43a, + (q15_t)0x6725, (q15_t)0xb435, (q15_t)0x6721, (q15_t)0xb430, (q15_t)0x671d, + (q15_t)0xb42b, (q15_t)0x671a, (q15_t)0xb426, (q15_t)0x6716, (q15_t)0xb421, + (q15_t)0x6712, (q15_t)0xb41c, (q15_t)0x670e, (q15_t)0xb417, (q15_t)0x670b, + (q15_t)0xb411, (q15_t)0x6707, (q15_t)0xb40c, (q15_t)0x6703, (q15_t)0xb407, + (q15_t)0x6700, (q15_t)0xb402, (q15_t)0x66fc, (q15_t)0xb3fd, (q15_t)0x66f8, + (q15_t)0xb3f8, (q15_t)0x66f4, (q15_t)0xb3f3, (q15_t)0x66f1, (q15_t)0xb3ee, + (q15_t)0x66ed, (q15_t)0xb3e9, (q15_t)0x66e9, (q15_t)0xb3e4, (q15_t)0x66e5, + (q15_t)0xb3df, (q15_t)0x66e2, (q15_t)0xb3da, (q15_t)0x66de, (q15_t)0xb3d5, + (q15_t)0x66da, (q15_t)0xb3d0, (q15_t)0x66d6, (q15_t)0xb3cb, (q15_t)0x66d3, + (q15_t)0xb3c6, (q15_t)0x66cf, (q15_t)0xb3c1, (q15_t)0x66cb, (q15_t)0xb3bc, + (q15_t)0x66c8, (q15_t)0xb3b7, (q15_t)0x66c4, (q15_t)0xb3b1, (q15_t)0x66c0, + (q15_t)0xb3ac, (q15_t)0x66bc, (q15_t)0xb3a7, (q15_t)0x66b9, (q15_t)0xb3a2, + (q15_t)0x66b5, (q15_t)0xb39d, (q15_t)0x66b1, (q15_t)0xb398, (q15_t)0x66ad, + (q15_t)0xb393, (q15_t)0x66aa, (q15_t)0xb38e, (q15_t)0x66a6, (q15_t)0xb389, + (q15_t)0x66a2, (q15_t)0xb384, (q15_t)0x669e, (q15_t)0xb37f, (q15_t)0x669b, + (q15_t)0xb37a, (q15_t)0x6697, (q15_t)0xb375, (q15_t)0x6693, (q15_t)0xb370, + (q15_t)0x668f, (q15_t)0xb36b, (q15_t)0x668b, (q15_t)0xb366, (q15_t)0x6688, + (q15_t)0xb361, (q15_t)0x6684, (q15_t)0xb35c, (q15_t)0x6680, (q15_t)0xb357, + (q15_t)0x667c, (q15_t)0xb352, (q15_t)0x6679, (q15_t)0xb34d, (q15_t)0x6675, + (q15_t)0xb348, (q15_t)0x6671, (q15_t)0xb343, (q15_t)0x666d, (q15_t)0xb33e, + (q15_t)0x666a, (q15_t)0xb339, (q15_t)0x6666, (q15_t)0xb334, (q15_t)0x6662, + (q15_t)0xb32f, (q15_t)0x665e, (q15_t)0xb32a, (q15_t)0x665b, (q15_t)0xb325, + (q15_t)0x6657, (q15_t)0xb31f, (q15_t)0x6653, (q15_t)0xb31a, (q15_t)0x664f, + (q15_t)0xb315, (q15_t)0x664b, (q15_t)0xb310, (q15_t)0x6648, (q15_t)0xb30b, + (q15_t)0x6644, (q15_t)0xb306, (q15_t)0x6640, (q15_t)0xb301, (q15_t)0x663c, + (q15_t)0xb2fc, (q15_t)0x6639, (q15_t)0xb2f7, (q15_t)0x6635, (q15_t)0xb2f2, + (q15_t)0x6631, (q15_t)0xb2ed, (q15_t)0x662d, (q15_t)0xb2e8, (q15_t)0x6629, + (q15_t)0xb2e3, (q15_t)0x6626, (q15_t)0xb2de, (q15_t)0x6622, (q15_t)0xb2d9, + (q15_t)0x661e, (q15_t)0xb2d4, (q15_t)0x661a, (q15_t)0xb2cf, (q15_t)0x6616, + (q15_t)0xb2ca, (q15_t)0x6613, (q15_t)0xb2c5, (q15_t)0x660f, (q15_t)0xb2c0, + (q15_t)0x660b, (q15_t)0xb2bb, (q15_t)0x6607, (q15_t)0xb2b6, (q15_t)0x6603, + (q15_t)0xb2b1, (q15_t)0x6600, (q15_t)0xb2ac, (q15_t)0x65fc, (q15_t)0xb2a7, + (q15_t)0x65f8, (q15_t)0xb2a2, (q15_t)0x65f4, (q15_t)0xb29d, (q15_t)0x65f0, + (q15_t)0xb298, (q15_t)0x65ed, (q15_t)0xb293, (q15_t)0x65e9, (q15_t)0xb28e, + (q15_t)0x65e5, (q15_t)0xb289, (q15_t)0x65e1, (q15_t)0xb284, (q15_t)0x65dd, + (q15_t)0xb27f, (q15_t)0x65da, (q15_t)0xb27a, (q15_t)0x65d6, (q15_t)0xb275, + (q15_t)0x65d2, (q15_t)0xb270, (q15_t)0x65ce, (q15_t)0xb26b, (q15_t)0x65ca, + (q15_t)0xb266, (q15_t)0x65c7, (q15_t)0xb261, (q15_t)0x65c3, (q15_t)0xb25c, + (q15_t)0x65bf, (q15_t)0xb257, (q15_t)0x65bb, (q15_t)0xb252, (q15_t)0x65b7, + (q15_t)0xb24d, (q15_t)0x65b4, (q15_t)0xb248, (q15_t)0x65b0, (q15_t)0xb243, + (q15_t)0x65ac, (q15_t)0xb23e, (q15_t)0x65a8, (q15_t)0xb239, (q15_t)0x65a4, + (q15_t)0xb234, (q15_t)0x65a0, (q15_t)0xb22f, (q15_t)0x659d, (q15_t)0xb22a, + (q15_t)0x6599, (q15_t)0xb225, (q15_t)0x6595, (q15_t)0xb220, (q15_t)0x6591, + (q15_t)0xb21b, (q15_t)0x658d, (q15_t)0xb216, (q15_t)0x658a, (q15_t)0xb211, + (q15_t)0x6586, (q15_t)0xb20c, (q15_t)0x6582, (q15_t)0xb207, (q15_t)0x657e, + (q15_t)0xb202, (q15_t)0x657a, (q15_t)0xb1fd, (q15_t)0x6576, (q15_t)0xb1f8, + (q15_t)0x6573, (q15_t)0xb1f3, (q15_t)0x656f, (q15_t)0xb1ee, (q15_t)0x656b, + (q15_t)0xb1e9, (q15_t)0x6567, (q15_t)0xb1e4, (q15_t)0x6563, (q15_t)0xb1df, + (q15_t)0x655f, (q15_t)0xb1da, (q15_t)0x655c, (q15_t)0xb1d6, (q15_t)0x6558, + (q15_t)0xb1d1, (q15_t)0x6554, (q15_t)0xb1cc, (q15_t)0x6550, (q15_t)0xb1c7, + (q15_t)0x654c, (q15_t)0xb1c2, (q15_t)0x6548, (q15_t)0xb1bd, (q15_t)0x6545, + (q15_t)0xb1b8, (q15_t)0x6541, (q15_t)0xb1b3, (q15_t)0x653d, (q15_t)0xb1ae, + (q15_t)0x6539, (q15_t)0xb1a9, (q15_t)0x6535, (q15_t)0xb1a4, (q15_t)0x6531, + (q15_t)0xb19f, (q15_t)0x652d, (q15_t)0xb19a, (q15_t)0x652a, (q15_t)0xb195, + (q15_t)0x6526, (q15_t)0xb190, (q15_t)0x6522, (q15_t)0xb18b, (q15_t)0x651e, + (q15_t)0xb186, (q15_t)0x651a, (q15_t)0xb181, (q15_t)0x6516, (q15_t)0xb17c, + (q15_t)0x6513, (q15_t)0xb177, (q15_t)0x650f, (q15_t)0xb172, (q15_t)0x650b, + (q15_t)0xb16d, (q15_t)0x6507, (q15_t)0xb168, (q15_t)0x6503, (q15_t)0xb163, + (q15_t)0x64ff, (q15_t)0xb15e, (q15_t)0x64fb, (q15_t)0xb159, (q15_t)0x64f7, + (q15_t)0xb154, (q15_t)0x64f4, (q15_t)0xb14f, (q15_t)0x64f0, (q15_t)0xb14a, + (q15_t)0x64ec, (q15_t)0xb146, (q15_t)0x64e8, (q15_t)0xb141, (q15_t)0x64e4, + (q15_t)0xb13c, (q15_t)0x64e0, (q15_t)0xb137, (q15_t)0x64dc, (q15_t)0xb132, + (q15_t)0x64d9, (q15_t)0xb12d, (q15_t)0x64d5, (q15_t)0xb128, (q15_t)0x64d1, + (q15_t)0xb123, (q15_t)0x64cd, (q15_t)0xb11e, (q15_t)0x64c9, (q15_t)0xb119, + (q15_t)0x64c5, (q15_t)0xb114, (q15_t)0x64c1, (q15_t)0xb10f, (q15_t)0x64bd, + (q15_t)0xb10a, (q15_t)0x64ba, (q15_t)0xb105, (q15_t)0x64b6, (q15_t)0xb100, + (q15_t)0x64b2, (q15_t)0xb0fb, (q15_t)0x64ae, (q15_t)0xb0f6, (q15_t)0x64aa, + (q15_t)0xb0f1, (q15_t)0x64a6, (q15_t)0xb0ec, (q15_t)0x64a2, (q15_t)0xb0e8, + (q15_t)0x649e, (q15_t)0xb0e3, (q15_t)0x649b, (q15_t)0xb0de, (q15_t)0x6497, + (q15_t)0xb0d9, (q15_t)0x6493, (q15_t)0xb0d4, (q15_t)0x648f, (q15_t)0xb0cf, + (q15_t)0x648b, (q15_t)0xb0ca, (q15_t)0x6487, (q15_t)0xb0c5, (q15_t)0x6483, + (q15_t)0xb0c0, (q15_t)0x647f, (q15_t)0xb0bb, (q15_t)0x647b, (q15_t)0xb0b6, + (q15_t)0x6478, (q15_t)0xb0b1, (q15_t)0x6474, (q15_t)0xb0ac, (q15_t)0x6470, + (q15_t)0xb0a7, (q15_t)0x646c, (q15_t)0xb0a2, (q15_t)0x6468, (q15_t)0xb09e, + (q15_t)0x6464, (q15_t)0xb099, (q15_t)0x6460, (q15_t)0xb094, (q15_t)0x645c, + (q15_t)0xb08f, (q15_t)0x6458, (q15_t)0xb08a, (q15_t)0x6454, (q15_t)0xb085, + (q15_t)0x6451, (q15_t)0xb080, (q15_t)0x644d, (q15_t)0xb07b, (q15_t)0x6449, + (q15_t)0xb076, (q15_t)0x6445, (q15_t)0xb071, (q15_t)0x6441, (q15_t)0xb06c, + (q15_t)0x643d, (q15_t)0xb067, (q15_t)0x6439, (q15_t)0xb062, (q15_t)0x6435, + (q15_t)0xb05e, (q15_t)0x6431, (q15_t)0xb059, (q15_t)0x642d, (q15_t)0xb054, + (q15_t)0x6429, (q15_t)0xb04f, (q15_t)0x6426, (q15_t)0xb04a, (q15_t)0x6422, + (q15_t)0xb045, (q15_t)0x641e, (q15_t)0xb040, (q15_t)0x641a, (q15_t)0xb03b, + (q15_t)0x6416, (q15_t)0xb036, (q15_t)0x6412, (q15_t)0xb031, (q15_t)0x640e, + (q15_t)0xb02c, (q15_t)0x640a, (q15_t)0xb027, (q15_t)0x6406, (q15_t)0xb023, + (q15_t)0x6402, (q15_t)0xb01e, (q15_t)0x63fe, (q15_t)0xb019, (q15_t)0x63fa, + (q15_t)0xb014, (q15_t)0x63f7, (q15_t)0xb00f, (q15_t)0x63f3, (q15_t)0xb00a, + (q15_t)0x63ef, (q15_t)0xb005, (q15_t)0x63eb, (q15_t)0xb000, (q15_t)0x63e7, + (q15_t)0xaffb, (q15_t)0x63e3, (q15_t)0xaff6, (q15_t)0x63df, (q15_t)0xaff1, + (q15_t)0x63db, (q15_t)0xafed, (q15_t)0x63d7, (q15_t)0xafe8, (q15_t)0x63d3, + (q15_t)0xafe3, (q15_t)0x63cf, (q15_t)0xafde, (q15_t)0x63cb, (q15_t)0xafd9, + (q15_t)0x63c7, (q15_t)0xafd4, (q15_t)0x63c3, (q15_t)0xafcf, (q15_t)0x63c0, + (q15_t)0xafca, (q15_t)0x63bc, (q15_t)0xafc5, (q15_t)0x63b8, (q15_t)0xafc1, + (q15_t)0x63b4, (q15_t)0xafbc, (q15_t)0x63b0, (q15_t)0xafb7, (q15_t)0x63ac, + (q15_t)0xafb2, (q15_t)0x63a8, (q15_t)0xafad, (q15_t)0x63a4, (q15_t)0xafa8, + (q15_t)0x63a0, (q15_t)0xafa3, (q15_t)0x639c, (q15_t)0xaf9e, (q15_t)0x6398, + (q15_t)0xaf99, (q15_t)0x6394, (q15_t)0xaf94, (q15_t)0x6390, (q15_t)0xaf90, + (q15_t)0x638c, (q15_t)0xaf8b, (q15_t)0x6388, (q15_t)0xaf86, (q15_t)0x6384, + (q15_t)0xaf81, (q15_t)0x6380, (q15_t)0xaf7c, (q15_t)0x637c, (q15_t)0xaf77, + (q15_t)0x6378, (q15_t)0xaf72, (q15_t)0x6375, (q15_t)0xaf6d, (q15_t)0x6371, + (q15_t)0xaf69, (q15_t)0x636d, (q15_t)0xaf64, (q15_t)0x6369, (q15_t)0xaf5f, + (q15_t)0x6365, (q15_t)0xaf5a, (q15_t)0x6361, (q15_t)0xaf55, (q15_t)0x635d, + (q15_t)0xaf50, (q15_t)0x6359, (q15_t)0xaf4b, (q15_t)0x6355, (q15_t)0xaf46, + (q15_t)0x6351, (q15_t)0xaf41, (q15_t)0x634d, (q15_t)0xaf3d, (q15_t)0x6349, + (q15_t)0xaf38, (q15_t)0x6345, (q15_t)0xaf33, (q15_t)0x6341, (q15_t)0xaf2e, + (q15_t)0x633d, (q15_t)0xaf29, (q15_t)0x6339, (q15_t)0xaf24, (q15_t)0x6335, + (q15_t)0xaf1f, (q15_t)0x6331, (q15_t)0xaf1b, (q15_t)0x632d, (q15_t)0xaf16, + (q15_t)0x6329, (q15_t)0xaf11, (q15_t)0x6325, (q15_t)0xaf0c, (q15_t)0x6321, + (q15_t)0xaf07, (q15_t)0x631d, (q15_t)0xaf02, (q15_t)0x6319, (q15_t)0xaefd, + (q15_t)0x6315, (q15_t)0xaef8, (q15_t)0x6311, (q15_t)0xaef4, (q15_t)0x630d, + (q15_t)0xaeef, (q15_t)0x6309, (q15_t)0xaeea, (q15_t)0x6305, (q15_t)0xaee5, + (q15_t)0x6301, (q15_t)0xaee0, (q15_t)0x62fd, (q15_t)0xaedb, (q15_t)0x62f9, + (q15_t)0xaed6, (q15_t)0x62f5, (q15_t)0xaed2, (q15_t)0x62f2, (q15_t)0xaecd, + (q15_t)0x62ee, (q15_t)0xaec8, (q15_t)0x62ea, (q15_t)0xaec3, (q15_t)0x62e6, + (q15_t)0xaebe, (q15_t)0x62e2, (q15_t)0xaeb9, (q15_t)0x62de, (q15_t)0xaeb4, + (q15_t)0x62da, (q15_t)0xaeb0, (q15_t)0x62d6, (q15_t)0xaeab, (q15_t)0x62d2, + (q15_t)0xaea6, (q15_t)0x62ce, (q15_t)0xaea1, (q15_t)0x62ca, (q15_t)0xae9c, + (q15_t)0x62c6, (q15_t)0xae97, (q15_t)0x62c2, (q15_t)0xae92, (q15_t)0x62be, + (q15_t)0xae8e, (q15_t)0x62ba, (q15_t)0xae89, (q15_t)0x62b6, (q15_t)0xae84, + (q15_t)0x62b2, (q15_t)0xae7f, (q15_t)0x62ae, (q15_t)0xae7a, (q15_t)0x62aa, + (q15_t)0xae75, (q15_t)0x62a6, (q15_t)0xae71, (q15_t)0x62a2, (q15_t)0xae6c, + (q15_t)0x629e, (q15_t)0xae67, (q15_t)0x629a, (q15_t)0xae62, (q15_t)0x6296, + (q15_t)0xae5d, (q15_t)0x6292, (q15_t)0xae58, (q15_t)0x628e, (q15_t)0xae54, + (q15_t)0x628a, (q15_t)0xae4f, (q15_t)0x6286, (q15_t)0xae4a, (q15_t)0x6282, + (q15_t)0xae45, (q15_t)0x627e, (q15_t)0xae40, (q15_t)0x627a, (q15_t)0xae3b, + (q15_t)0x6275, (q15_t)0xae37, (q15_t)0x6271, (q15_t)0xae32, (q15_t)0x626d, + (q15_t)0xae2d, (q15_t)0x6269, (q15_t)0xae28, (q15_t)0x6265, (q15_t)0xae23, + (q15_t)0x6261, (q15_t)0xae1e, (q15_t)0x625d, (q15_t)0xae1a, (q15_t)0x6259, + (q15_t)0xae15, (q15_t)0x6255, (q15_t)0xae10, (q15_t)0x6251, (q15_t)0xae0b, + (q15_t)0x624d, (q15_t)0xae06, (q15_t)0x6249, (q15_t)0xae01, (q15_t)0x6245, + (q15_t)0xadfd, (q15_t)0x6241, (q15_t)0xadf8, (q15_t)0x623d, (q15_t)0xadf3, + (q15_t)0x6239, (q15_t)0xadee, (q15_t)0x6235, (q15_t)0xade9, (q15_t)0x6231, + (q15_t)0xade4, (q15_t)0x622d, (q15_t)0xade0, (q15_t)0x6229, (q15_t)0xaddb, + (q15_t)0x6225, (q15_t)0xadd6, (q15_t)0x6221, (q15_t)0xadd1, (q15_t)0x621d, + (q15_t)0xadcc, (q15_t)0x6219, (q15_t)0xadc8, (q15_t)0x6215, (q15_t)0xadc3, + (q15_t)0x6211, (q15_t)0xadbe, (q15_t)0x620d, (q15_t)0xadb9, (q15_t)0x6209, + (q15_t)0xadb4, (q15_t)0x6205, (q15_t)0xadaf, (q15_t)0x6201, (q15_t)0xadab, + (q15_t)0x61fd, (q15_t)0xada6, (q15_t)0x61f9, (q15_t)0xada1, (q15_t)0x61f5, + (q15_t)0xad9c, (q15_t)0x61f1, (q15_t)0xad97, (q15_t)0x61ec, (q15_t)0xad93, + (q15_t)0x61e8, (q15_t)0xad8e, (q15_t)0x61e4, (q15_t)0xad89, (q15_t)0x61e0, + (q15_t)0xad84, (q15_t)0x61dc, (q15_t)0xad7f, (q15_t)0x61d8, (q15_t)0xad7b, + (q15_t)0x61d4, (q15_t)0xad76, (q15_t)0x61d0, (q15_t)0xad71, (q15_t)0x61cc, + (q15_t)0xad6c, (q15_t)0x61c8, (q15_t)0xad67, (q15_t)0x61c4, (q15_t)0xad63, + (q15_t)0x61c0, (q15_t)0xad5e, (q15_t)0x61bc, (q15_t)0xad59, (q15_t)0x61b8, + (q15_t)0xad54, (q15_t)0x61b4, (q15_t)0xad4f, (q15_t)0x61b0, (q15_t)0xad4b, + (q15_t)0x61ac, (q15_t)0xad46, (q15_t)0x61a8, (q15_t)0xad41, (q15_t)0x61a3, + (q15_t)0xad3c, (q15_t)0x619f, (q15_t)0xad37, (q15_t)0x619b, (q15_t)0xad33, + (q15_t)0x6197, (q15_t)0xad2e, (q15_t)0x6193, (q15_t)0xad29, (q15_t)0x618f, + (q15_t)0xad24, (q15_t)0x618b, (q15_t)0xad1f, (q15_t)0x6187, (q15_t)0xad1b, + (q15_t)0x6183, (q15_t)0xad16, (q15_t)0x617f, (q15_t)0xad11, (q15_t)0x617b, + (q15_t)0xad0c, (q15_t)0x6177, (q15_t)0xad08, (q15_t)0x6173, (q15_t)0xad03, + (q15_t)0x616f, (q15_t)0xacfe, (q15_t)0x616b, (q15_t)0xacf9, (q15_t)0x6166, + (q15_t)0xacf4, (q15_t)0x6162, (q15_t)0xacf0, (q15_t)0x615e, (q15_t)0xaceb, + (q15_t)0x615a, (q15_t)0xace6, (q15_t)0x6156, (q15_t)0xace1, (q15_t)0x6152, + (q15_t)0xacdd, (q15_t)0x614e, (q15_t)0xacd8, (q15_t)0x614a, (q15_t)0xacd3, + (q15_t)0x6146, (q15_t)0xacce, (q15_t)0x6142, (q15_t)0xacc9, (q15_t)0x613e, + (q15_t)0xacc5, (q15_t)0x613a, (q15_t)0xacc0, (q15_t)0x6135, (q15_t)0xacbb, + (q15_t)0x6131, (q15_t)0xacb6, (q15_t)0x612d, (q15_t)0xacb2, (q15_t)0x6129, + (q15_t)0xacad, (q15_t)0x6125, (q15_t)0xaca8, (q15_t)0x6121, (q15_t)0xaca3, + (q15_t)0x611d, (q15_t)0xac9e, (q15_t)0x6119, (q15_t)0xac9a, (q15_t)0x6115, + (q15_t)0xac95, (q15_t)0x6111, (q15_t)0xac90, (q15_t)0x610d, (q15_t)0xac8b, + (q15_t)0x6108, (q15_t)0xac87, (q15_t)0x6104, (q15_t)0xac82, (q15_t)0x6100, + (q15_t)0xac7d, (q15_t)0x60fc, (q15_t)0xac78, (q15_t)0x60f8, (q15_t)0xac74, + (q15_t)0x60f4, (q15_t)0xac6f, (q15_t)0x60f0, (q15_t)0xac6a, (q15_t)0x60ec, + (q15_t)0xac65, (q15_t)0x60e8, (q15_t)0xac61, (q15_t)0x60e4, (q15_t)0xac5c, + (q15_t)0x60df, (q15_t)0xac57, (q15_t)0x60db, (q15_t)0xac52, (q15_t)0x60d7, + (q15_t)0xac4e, (q15_t)0x60d3, (q15_t)0xac49, (q15_t)0x60cf, (q15_t)0xac44, + (q15_t)0x60cb, (q15_t)0xac3f, (q15_t)0x60c7, (q15_t)0xac3b, (q15_t)0x60c3, + (q15_t)0xac36, (q15_t)0x60bf, (q15_t)0xac31, (q15_t)0x60ba, (q15_t)0xac2c, + (q15_t)0x60b6, (q15_t)0xac28, (q15_t)0x60b2, (q15_t)0xac23, (q15_t)0x60ae, + (q15_t)0xac1e, (q15_t)0x60aa, (q15_t)0xac19, (q15_t)0x60a6, (q15_t)0xac15, + (q15_t)0x60a2, (q15_t)0xac10, (q15_t)0x609e, (q15_t)0xac0b, (q15_t)0x6099, + (q15_t)0xac06, (q15_t)0x6095, (q15_t)0xac02, (q15_t)0x6091, (q15_t)0xabfd, + (q15_t)0x608d, (q15_t)0xabf8, (q15_t)0x6089, (q15_t)0xabf3, (q15_t)0x6085, + (q15_t)0xabef, (q15_t)0x6081, (q15_t)0xabea, (q15_t)0x607d, (q15_t)0xabe5, + (q15_t)0x6078, (q15_t)0xabe0, (q15_t)0x6074, (q15_t)0xabdc, (q15_t)0x6070, + (q15_t)0xabd7, (q15_t)0x606c, (q15_t)0xabd2, (q15_t)0x6068, (q15_t)0xabcd, + (q15_t)0x6064, (q15_t)0xabc9, (q15_t)0x6060, (q15_t)0xabc4, (q15_t)0x605c, + (q15_t)0xabbf, (q15_t)0x6057, (q15_t)0xabbb, (q15_t)0x6053, (q15_t)0xabb6, + (q15_t)0x604f, (q15_t)0xabb1, (q15_t)0x604b, (q15_t)0xabac, (q15_t)0x6047, + (q15_t)0xaba8, (q15_t)0x6043, (q15_t)0xaba3, (q15_t)0x603f, (q15_t)0xab9e, + (q15_t)0x603a, (q15_t)0xab99, (q15_t)0x6036, (q15_t)0xab95, (q15_t)0x6032, + (q15_t)0xab90, (q15_t)0x602e, (q15_t)0xab8b, (q15_t)0x602a, (q15_t)0xab87, + (q15_t)0x6026, (q15_t)0xab82, (q15_t)0x6022, (q15_t)0xab7d, (q15_t)0x601d, + (q15_t)0xab78, (q15_t)0x6019, (q15_t)0xab74, (q15_t)0x6015, (q15_t)0xab6f, + (q15_t)0x6011, (q15_t)0xab6a, (q15_t)0x600d, (q15_t)0xab66, (q15_t)0x6009, + (q15_t)0xab61, (q15_t)0x6004, (q15_t)0xab5c, (q15_t)0x6000, (q15_t)0xab57, + (q15_t)0x5ffc, (q15_t)0xab53, (q15_t)0x5ff8, (q15_t)0xab4e, (q15_t)0x5ff4, + (q15_t)0xab49, (q15_t)0x5ff0, (q15_t)0xab45, (q15_t)0x5fec, (q15_t)0xab40, + (q15_t)0x5fe7, (q15_t)0xab3b, (q15_t)0x5fe3, (q15_t)0xab36, (q15_t)0x5fdf, + (q15_t)0xab32, (q15_t)0x5fdb, (q15_t)0xab2d, (q15_t)0x5fd7, (q15_t)0xab28, + (q15_t)0x5fd3, (q15_t)0xab24, (q15_t)0x5fce, (q15_t)0xab1f, (q15_t)0x5fca, + (q15_t)0xab1a, (q15_t)0x5fc6, (q15_t)0xab16, (q15_t)0x5fc2, (q15_t)0xab11, + (q15_t)0x5fbe, (q15_t)0xab0c, (q15_t)0x5fba, (q15_t)0xab07, (q15_t)0x5fb5, + (q15_t)0xab03, (q15_t)0x5fb1, (q15_t)0xaafe, (q15_t)0x5fad, (q15_t)0xaaf9, + (q15_t)0x5fa9, (q15_t)0xaaf5, (q15_t)0x5fa5, (q15_t)0xaaf0, (q15_t)0x5fa0, + (q15_t)0xaaeb, (q15_t)0x5f9c, (q15_t)0xaae7, (q15_t)0x5f98, (q15_t)0xaae2, + (q15_t)0x5f94, (q15_t)0xaadd, (q15_t)0x5f90, (q15_t)0xaad8, (q15_t)0x5f8c, + (q15_t)0xaad4, (q15_t)0x5f87, (q15_t)0xaacf, (q15_t)0x5f83, (q15_t)0xaaca, + (q15_t)0x5f7f, (q15_t)0xaac6, (q15_t)0x5f7b, (q15_t)0xaac1, (q15_t)0x5f77, + (q15_t)0xaabc, (q15_t)0x5f72, (q15_t)0xaab8, (q15_t)0x5f6e, (q15_t)0xaab3, + (q15_t)0x5f6a, (q15_t)0xaaae, (q15_t)0x5f66, (q15_t)0xaaaa, (q15_t)0x5f62, + (q15_t)0xaaa5, (q15_t)0x5f5e, (q15_t)0xaaa0, (q15_t)0x5f59, (q15_t)0xaa9c, + (q15_t)0x5f55, (q15_t)0xaa97, (q15_t)0x5f51, (q15_t)0xaa92, (q15_t)0x5f4d, + (q15_t)0xaa8e, (q15_t)0x5f49, (q15_t)0xaa89, (q15_t)0x5f44, (q15_t)0xaa84, + (q15_t)0x5f40, (q15_t)0xaa7f, (q15_t)0x5f3c, (q15_t)0xaa7b, (q15_t)0x5f38, + (q15_t)0xaa76, (q15_t)0x5f34, (q15_t)0xaa71, (q15_t)0x5f2f, (q15_t)0xaa6d, + (q15_t)0x5f2b, (q15_t)0xaa68, (q15_t)0x5f27, (q15_t)0xaa63, (q15_t)0x5f23, + (q15_t)0xaa5f, (q15_t)0x5f1f, (q15_t)0xaa5a, (q15_t)0x5f1a, (q15_t)0xaa55, + (q15_t)0x5f16, (q15_t)0xaa51, (q15_t)0x5f12, (q15_t)0xaa4c, (q15_t)0x5f0e, + (q15_t)0xaa47, (q15_t)0x5f0a, (q15_t)0xaa43, (q15_t)0x5f05, (q15_t)0xaa3e, + (q15_t)0x5f01, (q15_t)0xaa39, (q15_t)0x5efd, (q15_t)0xaa35, (q15_t)0x5ef9, + (q15_t)0xaa30, (q15_t)0x5ef5, (q15_t)0xaa2b, (q15_t)0x5ef0, (q15_t)0xaa27, + (q15_t)0x5eec, (q15_t)0xaa22, (q15_t)0x5ee8, (q15_t)0xaa1d, (q15_t)0x5ee4, + (q15_t)0xaa19, (q15_t)0x5edf, (q15_t)0xaa14, (q15_t)0x5edb, (q15_t)0xaa10, + (q15_t)0x5ed7, (q15_t)0xaa0b, (q15_t)0x5ed3, (q15_t)0xaa06, (q15_t)0x5ecf, + (q15_t)0xaa02, (q15_t)0x5eca, (q15_t)0xa9fd, (q15_t)0x5ec6, (q15_t)0xa9f8, + (q15_t)0x5ec2, (q15_t)0xa9f4, (q15_t)0x5ebe, (q15_t)0xa9ef, (q15_t)0x5eb9, + (q15_t)0xa9ea, (q15_t)0x5eb5, (q15_t)0xa9e6, (q15_t)0x5eb1, (q15_t)0xa9e1, + (q15_t)0x5ead, (q15_t)0xa9dc, (q15_t)0x5ea9, (q15_t)0xa9d8, (q15_t)0x5ea4, + (q15_t)0xa9d3, (q15_t)0x5ea0, (q15_t)0xa9ce, (q15_t)0x5e9c, (q15_t)0xa9ca, + (q15_t)0x5e98, (q15_t)0xa9c5, (q15_t)0x5e93, (q15_t)0xa9c0, (q15_t)0x5e8f, + (q15_t)0xa9bc, (q15_t)0x5e8b, (q15_t)0xa9b7, (q15_t)0x5e87, (q15_t)0xa9b3, + (q15_t)0x5e82, (q15_t)0xa9ae, (q15_t)0x5e7e, (q15_t)0xa9a9, (q15_t)0x5e7a, + (q15_t)0xa9a5, (q15_t)0x5e76, (q15_t)0xa9a0, (q15_t)0x5e71, (q15_t)0xa99b, + (q15_t)0x5e6d, (q15_t)0xa997, (q15_t)0x5e69, (q15_t)0xa992, (q15_t)0x5e65, + (q15_t)0xa98d, (q15_t)0x5e60, (q15_t)0xa989, (q15_t)0x5e5c, (q15_t)0xa984, + (q15_t)0x5e58, (q15_t)0xa980, (q15_t)0x5e54, (q15_t)0xa97b, (q15_t)0x5e50, + (q15_t)0xa976, (q15_t)0x5e4b, (q15_t)0xa972, (q15_t)0x5e47, (q15_t)0xa96d, + (q15_t)0x5e43, (q15_t)0xa968, (q15_t)0x5e3f, (q15_t)0xa964, (q15_t)0x5e3a, + (q15_t)0xa95f, (q15_t)0x5e36, (q15_t)0xa95b, (q15_t)0x5e32, (q15_t)0xa956, + (q15_t)0x5e2d, (q15_t)0xa951, (q15_t)0x5e29, (q15_t)0xa94d, (q15_t)0x5e25, + (q15_t)0xa948, (q15_t)0x5e21, (q15_t)0xa943, (q15_t)0x5e1c, (q15_t)0xa93f, + (q15_t)0x5e18, (q15_t)0xa93a, (q15_t)0x5e14, (q15_t)0xa936, (q15_t)0x5e10, + (q15_t)0xa931, (q15_t)0x5e0b, (q15_t)0xa92c, (q15_t)0x5e07, (q15_t)0xa928, + (q15_t)0x5e03, (q15_t)0xa923, (q15_t)0x5dff, (q15_t)0xa91e, (q15_t)0x5dfa, + (q15_t)0xa91a, (q15_t)0x5df6, (q15_t)0xa915, (q15_t)0x5df2, (q15_t)0xa911, + (q15_t)0x5dee, (q15_t)0xa90c, (q15_t)0x5de9, (q15_t)0xa907, (q15_t)0x5de5, + (q15_t)0xa903, (q15_t)0x5de1, (q15_t)0xa8fe, (q15_t)0x5ddc, (q15_t)0xa8fa, + (q15_t)0x5dd8, (q15_t)0xa8f5, (q15_t)0x5dd4, (q15_t)0xa8f0, (q15_t)0x5dd0, + (q15_t)0xa8ec, (q15_t)0x5dcb, (q15_t)0xa8e7, (q15_t)0x5dc7, (q15_t)0xa8e3, + (q15_t)0x5dc3, (q15_t)0xa8de, (q15_t)0x5dbf, (q15_t)0xa8d9, (q15_t)0x5dba, + (q15_t)0xa8d5, (q15_t)0x5db6, (q15_t)0xa8d0, (q15_t)0x5db2, (q15_t)0xa8cc, + (q15_t)0x5dad, (q15_t)0xa8c7, (q15_t)0x5da9, (q15_t)0xa8c2, (q15_t)0x5da5, + (q15_t)0xa8be, (q15_t)0x5da1, (q15_t)0xa8b9, (q15_t)0x5d9c, (q15_t)0xa8b5, + (q15_t)0x5d98, (q15_t)0xa8b0, (q15_t)0x5d94, (q15_t)0xa8ab, (q15_t)0x5d8f, + (q15_t)0xa8a7, (q15_t)0x5d8b, (q15_t)0xa8a2, (q15_t)0x5d87, (q15_t)0xa89e, + (q15_t)0x5d83, (q15_t)0xa899, (q15_t)0x5d7e, (q15_t)0xa894, (q15_t)0x5d7a, + (q15_t)0xa890, (q15_t)0x5d76, (q15_t)0xa88b, (q15_t)0x5d71, (q15_t)0xa887, + (q15_t)0x5d6d, (q15_t)0xa882, (q15_t)0x5d69, (q15_t)0xa87d, (q15_t)0x5d65, + (q15_t)0xa879, (q15_t)0x5d60, (q15_t)0xa874, (q15_t)0x5d5c, (q15_t)0xa870, + (q15_t)0x5d58, (q15_t)0xa86b, (q15_t)0x5d53, (q15_t)0xa867, (q15_t)0x5d4f, + (q15_t)0xa862, (q15_t)0x5d4b, (q15_t)0xa85d, (q15_t)0x5d46, (q15_t)0xa859, + (q15_t)0x5d42, (q15_t)0xa854, (q15_t)0x5d3e, (q15_t)0xa850, (q15_t)0x5d3a, + (q15_t)0xa84b, (q15_t)0x5d35, (q15_t)0xa847, (q15_t)0x5d31, (q15_t)0xa842, + (q15_t)0x5d2d, (q15_t)0xa83d, (q15_t)0x5d28, (q15_t)0xa839, (q15_t)0x5d24, + (q15_t)0xa834, (q15_t)0x5d20, (q15_t)0xa830, (q15_t)0x5d1b, (q15_t)0xa82b, + (q15_t)0x5d17, (q15_t)0xa827, (q15_t)0x5d13, (q15_t)0xa822, (q15_t)0x5d0e, + (q15_t)0xa81d, (q15_t)0x5d0a, (q15_t)0xa819, (q15_t)0x5d06, (q15_t)0xa814, + (q15_t)0x5d01, (q15_t)0xa810, (q15_t)0x5cfd, (q15_t)0xa80b, (q15_t)0x5cf9, + (q15_t)0xa807, (q15_t)0x5cf5, (q15_t)0xa802, (q15_t)0x5cf0, (q15_t)0xa7fd, + (q15_t)0x5cec, (q15_t)0xa7f9, (q15_t)0x5ce8, (q15_t)0xa7f4, (q15_t)0x5ce3, + (q15_t)0xa7f0, (q15_t)0x5cdf, (q15_t)0xa7eb, (q15_t)0x5cdb, (q15_t)0xa7e7, + (q15_t)0x5cd6, (q15_t)0xa7e2, (q15_t)0x5cd2, (q15_t)0xa7de, (q15_t)0x5cce, + (q15_t)0xa7d9, (q15_t)0x5cc9, (q15_t)0xa7d4, (q15_t)0x5cc5, (q15_t)0xa7d0, + (q15_t)0x5cc1, (q15_t)0xa7cb, (q15_t)0x5cbc, (q15_t)0xa7c7, (q15_t)0x5cb8, + (q15_t)0xa7c2, (q15_t)0x5cb4, (q15_t)0xa7be, (q15_t)0x5caf, (q15_t)0xa7b9, + (q15_t)0x5cab, (q15_t)0xa7b5, (q15_t)0x5ca7, (q15_t)0xa7b0, (q15_t)0x5ca2, + (q15_t)0xa7ab, (q15_t)0x5c9e, (q15_t)0xa7a7, (q15_t)0x5c9a, (q15_t)0xa7a2, + (q15_t)0x5c95, (q15_t)0xa79e, (q15_t)0x5c91, (q15_t)0xa799, (q15_t)0x5c8d, + (q15_t)0xa795, (q15_t)0x5c88, (q15_t)0xa790, (q15_t)0x5c84, (q15_t)0xa78c, + (q15_t)0x5c80, (q15_t)0xa787, (q15_t)0x5c7b, (q15_t)0xa783, (q15_t)0x5c77, + (q15_t)0xa77e, (q15_t)0x5c73, (q15_t)0xa779, (q15_t)0x5c6e, (q15_t)0xa775, + (q15_t)0x5c6a, (q15_t)0xa770, (q15_t)0x5c66, (q15_t)0xa76c, (q15_t)0x5c61, + (q15_t)0xa767, (q15_t)0x5c5d, (q15_t)0xa763, (q15_t)0x5c58, (q15_t)0xa75e, + (q15_t)0x5c54, (q15_t)0xa75a, (q15_t)0x5c50, (q15_t)0xa755, (q15_t)0x5c4b, + (q15_t)0xa751, (q15_t)0x5c47, (q15_t)0xa74c, (q15_t)0x5c43, (q15_t)0xa748, + (q15_t)0x5c3e, (q15_t)0xa743, (q15_t)0x5c3a, (q15_t)0xa73f, (q15_t)0x5c36, + (q15_t)0xa73a, (q15_t)0x5c31, (q15_t)0xa735, (q15_t)0x5c2d, (q15_t)0xa731, + (q15_t)0x5c29, (q15_t)0xa72c, (q15_t)0x5c24, (q15_t)0xa728, (q15_t)0x5c20, + (q15_t)0xa723, (q15_t)0x5c1b, (q15_t)0xa71f, (q15_t)0x5c17, (q15_t)0xa71a, + (q15_t)0x5c13, (q15_t)0xa716, (q15_t)0x5c0e, (q15_t)0xa711, (q15_t)0x5c0a, + (q15_t)0xa70d, (q15_t)0x5c06, (q15_t)0xa708, (q15_t)0x5c01, (q15_t)0xa704, + (q15_t)0x5bfd, (q15_t)0xa6ff, (q15_t)0x5bf9, (q15_t)0xa6fb, (q15_t)0x5bf4, + (q15_t)0xa6f6, (q15_t)0x5bf0, (q15_t)0xa6f2, (q15_t)0x5beb, (q15_t)0xa6ed, + (q15_t)0x5be7, (q15_t)0xa6e9, (q15_t)0x5be3, (q15_t)0xa6e4, (q15_t)0x5bde, + (q15_t)0xa6e0, (q15_t)0x5bda, (q15_t)0xa6db, (q15_t)0x5bd6, (q15_t)0xa6d7, + (q15_t)0x5bd1, (q15_t)0xa6d2, (q15_t)0x5bcd, (q15_t)0xa6ce, (q15_t)0x5bc8, + (q15_t)0xa6c9, (q15_t)0x5bc4, (q15_t)0xa6c5, (q15_t)0x5bc0, (q15_t)0xa6c0, + (q15_t)0x5bbb, (q15_t)0xa6bc, (q15_t)0x5bb7, (q15_t)0xa6b7, (q15_t)0x5bb2, + (q15_t)0xa6b3, (q15_t)0x5bae, (q15_t)0xa6ae, (q15_t)0x5baa, (q15_t)0xa6aa, + (q15_t)0x5ba5, (q15_t)0xa6a5, (q15_t)0x5ba1, (q15_t)0xa6a1, (q15_t)0x5b9d, + (q15_t)0xa69c, (q15_t)0x5b98, (q15_t)0xa698, (q15_t)0x5b94, (q15_t)0xa693, + (q15_t)0x5b8f, (q15_t)0xa68f, (q15_t)0x5b8b, (q15_t)0xa68a, (q15_t)0x5b87, + (q15_t)0xa686, (q15_t)0x5b82, (q15_t)0xa681, (q15_t)0x5b7e, (q15_t)0xa67d, + (q15_t)0x5b79, (q15_t)0xa678, (q15_t)0x5b75, (q15_t)0xa674, (q15_t)0x5b71, + (q15_t)0xa66f, (q15_t)0x5b6c, (q15_t)0xa66b, (q15_t)0x5b68, (q15_t)0xa666, + (q15_t)0x5b63, (q15_t)0xa662, (q15_t)0x5b5f, (q15_t)0xa65d, (q15_t)0x5b5b, + (q15_t)0xa659, (q15_t)0x5b56, (q15_t)0xa654, (q15_t)0x5b52, (q15_t)0xa650, + (q15_t)0x5b4d, (q15_t)0xa64b, (q15_t)0x5b49, (q15_t)0xa647, (q15_t)0x5b45, + (q15_t)0xa642, (q15_t)0x5b40, (q15_t)0xa63e, (q15_t)0x5b3c, (q15_t)0xa639, + (q15_t)0x5b37, (q15_t)0xa635, (q15_t)0x5b33, (q15_t)0xa630, (q15_t)0x5b2f, + (q15_t)0xa62c, (q15_t)0x5b2a, (q15_t)0xa627, (q15_t)0x5b26, (q15_t)0xa623, + (q15_t)0x5b21, (q15_t)0xa61f, (q15_t)0x5b1d, (q15_t)0xa61a, (q15_t)0x5b19, + (q15_t)0xa616, (q15_t)0x5b14, (q15_t)0xa611, (q15_t)0x5b10, (q15_t)0xa60d, + (q15_t)0x5b0b, (q15_t)0xa608, (q15_t)0x5b07, (q15_t)0xa604, (q15_t)0x5b02, + (q15_t)0xa5ff, (q15_t)0x5afe, (q15_t)0xa5fb, (q15_t)0x5afa, (q15_t)0xa5f6, + (q15_t)0x5af5, (q15_t)0xa5f2, (q15_t)0x5af1, (q15_t)0xa5ed, (q15_t)0x5aec, + (q15_t)0xa5e9, (q15_t)0x5ae8, (q15_t)0xa5e4, (q15_t)0x5ae4, (q15_t)0xa5e0, + (q15_t)0x5adf, (q15_t)0xa5dc, (q15_t)0x5adb, (q15_t)0xa5d7, (q15_t)0x5ad6, + (q15_t)0xa5d3, (q15_t)0x5ad2, (q15_t)0xa5ce, (q15_t)0x5acd, (q15_t)0xa5ca, + (q15_t)0x5ac9, (q15_t)0xa5c5, (q15_t)0x5ac5, (q15_t)0xa5c1, (q15_t)0x5ac0, + (q15_t)0xa5bc, (q15_t)0x5abc, (q15_t)0xa5b8, (q15_t)0x5ab7, (q15_t)0xa5b3, + (q15_t)0x5ab3, (q15_t)0xa5af, (q15_t)0x5aae, (q15_t)0xa5aa, (q15_t)0x5aaa, + (q15_t)0xa5a6, (q15_t)0x5aa5, (q15_t)0xa5a2, (q15_t)0x5aa1, (q15_t)0xa59d, + (q15_t)0x5a9d, (q15_t)0xa599, (q15_t)0x5a98, (q15_t)0xa594, (q15_t)0x5a94, + (q15_t)0xa590, (q15_t)0x5a8f, (q15_t)0xa58b, (q15_t)0x5a8b, (q15_t)0xa587, + (q15_t)0x5a86, (q15_t)0xa582, (q15_t)0x5a82, (q15_t)0xa57e, (q15_t)0x5a7e, + (q15_t)0xa57a, (q15_t)0x5a79, (q15_t)0xa575, (q15_t)0x5a75, (q15_t)0xa571, + (q15_t)0x5a70, (q15_t)0xa56c, (q15_t)0x5a6c, (q15_t)0xa568, (q15_t)0x5a67, + (q15_t)0xa563, (q15_t)0x5a63, (q15_t)0xa55f, (q15_t)0x5a5e, (q15_t)0xa55b, + (q15_t)0x5a5a, (q15_t)0xa556, (q15_t)0x5a56, (q15_t)0xa552, (q15_t)0x5a51, + (q15_t)0xa54d, (q15_t)0x5a4d, (q15_t)0xa549, (q15_t)0x5a48, (q15_t)0xa544, + (q15_t)0x5a44, (q15_t)0xa540, (q15_t)0x5a3f, (q15_t)0xa53b, (q15_t)0x5a3b, + (q15_t)0xa537, (q15_t)0x5a36, (q15_t)0xa533, (q15_t)0x5a32, (q15_t)0xa52e, + (q15_t)0x5a2d, (q15_t)0xa52a, (q15_t)0x5a29, (q15_t)0xa525, (q15_t)0x5a24, + (q15_t)0xa521, (q15_t)0x5a20, (q15_t)0xa51c, (q15_t)0x5a1c, (q15_t)0xa518, + (q15_t)0x5a17, (q15_t)0xa514, (q15_t)0x5a13, (q15_t)0xa50f, (q15_t)0x5a0e, + (q15_t)0xa50b, (q15_t)0x5a0a, (q15_t)0xa506, (q15_t)0x5a05, (q15_t)0xa502, + (q15_t)0x5a01, (q15_t)0xa4fe, (q15_t)0x59fc, (q15_t)0xa4f9, (q15_t)0x59f8, + (q15_t)0xa4f5, (q15_t)0x59f3, (q15_t)0xa4f0, (q15_t)0x59ef, (q15_t)0xa4ec, + (q15_t)0x59ea, (q15_t)0xa4e7, (q15_t)0x59e6, (q15_t)0xa4e3, (q15_t)0x59e1, + (q15_t)0xa4df, (q15_t)0x59dd, (q15_t)0xa4da, (q15_t)0x59d9, (q15_t)0xa4d6, + (q15_t)0x59d4, (q15_t)0xa4d1, (q15_t)0x59d0, (q15_t)0xa4cd, (q15_t)0x59cb, + (q15_t)0xa4c9, (q15_t)0x59c7, (q15_t)0xa4c4, (q15_t)0x59c2, (q15_t)0xa4c0, + (q15_t)0x59be, (q15_t)0xa4bb, (q15_t)0x59b9, (q15_t)0xa4b7, (q15_t)0x59b5, + (q15_t)0xa4b3, (q15_t)0x59b0, (q15_t)0xa4ae, (q15_t)0x59ac, (q15_t)0xa4aa, + (q15_t)0x59a7, (q15_t)0xa4a5, (q15_t)0x59a3, (q15_t)0xa4a1, (q15_t)0x599e, + (q15_t)0xa49d, (q15_t)0x599a, (q15_t)0xa498, (q15_t)0x5995, (q15_t)0xa494, + (q15_t)0x5991, (q15_t)0xa48f, (q15_t)0x598c, (q15_t)0xa48b, (q15_t)0x5988, + (q15_t)0xa487, (q15_t)0x5983, (q15_t)0xa482, (q15_t)0x597f, (q15_t)0xa47e, + (q15_t)0x597a, (q15_t)0xa479, (q15_t)0x5976, (q15_t)0xa475, (q15_t)0x5971, + (q15_t)0xa471, (q15_t)0x596d, (q15_t)0xa46c, (q15_t)0x5968, (q15_t)0xa468, + (q15_t)0x5964, (q15_t)0xa463, (q15_t)0x595f, (q15_t)0xa45f, (q15_t)0x595b, + (q15_t)0xa45b, (q15_t)0x5956, (q15_t)0xa456, (q15_t)0x5952, (q15_t)0xa452, + (q15_t)0x594d, (q15_t)0xa44e, (q15_t)0x5949, (q15_t)0xa449, (q15_t)0x5944, + (q15_t)0xa445, (q15_t)0x5940, (q15_t)0xa440, (q15_t)0x593b, (q15_t)0xa43c, + (q15_t)0x5937, (q15_t)0xa438, (q15_t)0x5932, (q15_t)0xa433, (q15_t)0x592e, + (q15_t)0xa42f, (q15_t)0x5929, (q15_t)0xa42a, (q15_t)0x5925, (q15_t)0xa426, + (q15_t)0x5920, (q15_t)0xa422, (q15_t)0x591c, (q15_t)0xa41d, (q15_t)0x5917, + (q15_t)0xa419, (q15_t)0x5913, (q15_t)0xa415, (q15_t)0x590e, (q15_t)0xa410, + (q15_t)0x590a, (q15_t)0xa40c, (q15_t)0x5905, (q15_t)0xa407, (q15_t)0x5901, + (q15_t)0xa403, (q15_t)0x58fc, (q15_t)0xa3ff, (q15_t)0x58f8, (q15_t)0xa3fa, + (q15_t)0x58f3, (q15_t)0xa3f6, (q15_t)0x58ef, (q15_t)0xa3f2, (q15_t)0x58ea, + (q15_t)0xa3ed, (q15_t)0x58e6, (q15_t)0xa3e9, (q15_t)0x58e1, (q15_t)0xa3e5, + (q15_t)0x58dd, (q15_t)0xa3e0, (q15_t)0x58d8, (q15_t)0xa3dc, (q15_t)0x58d4, + (q15_t)0xa3d7, (q15_t)0x58cf, (q15_t)0xa3d3, (q15_t)0x58cb, (q15_t)0xa3cf, + (q15_t)0x58c6, (q15_t)0xa3ca, (q15_t)0x58c1, (q15_t)0xa3c6, (q15_t)0x58bd, + (q15_t)0xa3c2, (q15_t)0x58b8, (q15_t)0xa3bd, (q15_t)0x58b4, (q15_t)0xa3b9, + (q15_t)0x58af, (q15_t)0xa3b5, (q15_t)0x58ab, (q15_t)0xa3b0, (q15_t)0x58a6, + (q15_t)0xa3ac, (q15_t)0x58a2, (q15_t)0xa3a8, (q15_t)0x589d, (q15_t)0xa3a3, + (q15_t)0x5899, (q15_t)0xa39f, (q15_t)0x5894, (q15_t)0xa39a, (q15_t)0x5890, + (q15_t)0xa396, (q15_t)0x588b, (q15_t)0xa392, (q15_t)0x5887, (q15_t)0xa38d, + (q15_t)0x5882, (q15_t)0xa389, (q15_t)0x587d, (q15_t)0xa385, (q15_t)0x5879, + (q15_t)0xa380, (q15_t)0x5874, (q15_t)0xa37c, (q15_t)0x5870, (q15_t)0xa378, + (q15_t)0x586b, (q15_t)0xa373, (q15_t)0x5867, (q15_t)0xa36f, (q15_t)0x5862, + (q15_t)0xa36b, (q15_t)0x585e, (q15_t)0xa366, (q15_t)0x5859, (q15_t)0xa362, + (q15_t)0x5855, (q15_t)0xa35e, (q15_t)0x5850, (q15_t)0xa359, (q15_t)0x584b, + (q15_t)0xa355, (q15_t)0x5847, (q15_t)0xa351, (q15_t)0x5842, (q15_t)0xa34c, + (q15_t)0x583e, (q15_t)0xa348, (q15_t)0x5839, (q15_t)0xa344, (q15_t)0x5835, + (q15_t)0xa33f, (q15_t)0x5830, (q15_t)0xa33b, (q15_t)0x582c, (q15_t)0xa337, + (q15_t)0x5827, (q15_t)0xa332, (q15_t)0x5822, (q15_t)0xa32e, (q15_t)0x581e, + (q15_t)0xa32a, (q15_t)0x5819, (q15_t)0xa325, (q15_t)0x5815, (q15_t)0xa321, + (q15_t)0x5810, (q15_t)0xa31d, (q15_t)0x580c, (q15_t)0xa318, (q15_t)0x5807, + (q15_t)0xa314, (q15_t)0x5803, (q15_t)0xa310, (q15_t)0x57fe, (q15_t)0xa30b, + (q15_t)0x57f9, (q15_t)0xa307, (q15_t)0x57f5, (q15_t)0xa303, (q15_t)0x57f0, + (q15_t)0xa2ff, (q15_t)0x57ec, (q15_t)0xa2fa, (q15_t)0x57e7, (q15_t)0xa2f6, + (q15_t)0x57e3, (q15_t)0xa2f2, (q15_t)0x57de, (q15_t)0xa2ed, (q15_t)0x57d9, + (q15_t)0xa2e9, (q15_t)0x57d5, (q15_t)0xa2e5, (q15_t)0x57d0, (q15_t)0xa2e0, + (q15_t)0x57cc, (q15_t)0xa2dc, (q15_t)0x57c7, (q15_t)0xa2d8, (q15_t)0x57c3, + (q15_t)0xa2d3, (q15_t)0x57be, (q15_t)0xa2cf, (q15_t)0x57b9, (q15_t)0xa2cb, + (q15_t)0x57b5, (q15_t)0xa2c6, (q15_t)0x57b0, (q15_t)0xa2c2, (q15_t)0x57ac, + (q15_t)0xa2be, (q15_t)0x57a7, (q15_t)0xa2ba, (q15_t)0x57a3, (q15_t)0xa2b5, + (q15_t)0x579e, (q15_t)0xa2b1, (q15_t)0x5799, (q15_t)0xa2ad, (q15_t)0x5795, + (q15_t)0xa2a8, (q15_t)0x5790, (q15_t)0xa2a4, (q15_t)0x578c, (q15_t)0xa2a0, + (q15_t)0x5787, (q15_t)0xa29b, (q15_t)0x5783, (q15_t)0xa297, (q15_t)0x577e, + (q15_t)0xa293, (q15_t)0x5779, (q15_t)0xa28f, (q15_t)0x5775, (q15_t)0xa28a, + (q15_t)0x5770, (q15_t)0xa286, (q15_t)0x576c, (q15_t)0xa282, (q15_t)0x5767, + (q15_t)0xa27d, (q15_t)0x5762, (q15_t)0xa279, (q15_t)0x575e, (q15_t)0xa275, + (q15_t)0x5759, (q15_t)0xa271, (q15_t)0x5755, (q15_t)0xa26c, (q15_t)0x5750, + (q15_t)0xa268, (q15_t)0x574b, (q15_t)0xa264, (q15_t)0x5747, (q15_t)0xa25f, + (q15_t)0x5742, (q15_t)0xa25b, (q15_t)0x573e, (q15_t)0xa257, (q15_t)0x5739, + (q15_t)0xa253, (q15_t)0x5734, (q15_t)0xa24e, (q15_t)0x5730, (q15_t)0xa24a, + (q15_t)0x572b, (q15_t)0xa246, (q15_t)0x5727, (q15_t)0xa241, (q15_t)0x5722, + (q15_t)0xa23d, (q15_t)0x571d, (q15_t)0xa239, (q15_t)0x5719, (q15_t)0xa235, + (q15_t)0x5714, (q15_t)0xa230, (q15_t)0x5710, (q15_t)0xa22c, (q15_t)0x570b, + (q15_t)0xa228, (q15_t)0x5706, (q15_t)0xa224, (q15_t)0x5702, (q15_t)0xa21f, + (q15_t)0x56fd, (q15_t)0xa21b, (q15_t)0x56f9, (q15_t)0xa217, (q15_t)0x56f4, + (q15_t)0xa212, (q15_t)0x56ef, (q15_t)0xa20e, (q15_t)0x56eb, (q15_t)0xa20a, + (q15_t)0x56e6, (q15_t)0xa206, (q15_t)0x56e2, (q15_t)0xa201, (q15_t)0x56dd, + (q15_t)0xa1fd, (q15_t)0x56d8, (q15_t)0xa1f9, (q15_t)0x56d4, (q15_t)0xa1f5, + (q15_t)0x56cf, (q15_t)0xa1f0, (q15_t)0x56ca, (q15_t)0xa1ec, (q15_t)0x56c6, + (q15_t)0xa1e8, (q15_t)0x56c1, (q15_t)0xa1e4, (q15_t)0x56bd, (q15_t)0xa1df, + (q15_t)0x56b8, (q15_t)0xa1db, (q15_t)0x56b3, (q15_t)0xa1d7, (q15_t)0x56af, + (q15_t)0xa1d3, (q15_t)0x56aa, (q15_t)0xa1ce, (q15_t)0x56a5, (q15_t)0xa1ca, + (q15_t)0x56a1, (q15_t)0xa1c6, (q15_t)0x569c, (q15_t)0xa1c1, (q15_t)0x5698, + (q15_t)0xa1bd, (q15_t)0x5693, (q15_t)0xa1b9, (q15_t)0x568e, (q15_t)0xa1b5, + (q15_t)0x568a, (q15_t)0xa1b0, (q15_t)0x5685, (q15_t)0xa1ac, (q15_t)0x5680, + (q15_t)0xa1a8, (q15_t)0x567c, (q15_t)0xa1a4, (q15_t)0x5677, (q15_t)0xa1a0, + (q15_t)0x5673, (q15_t)0xa19b, (q15_t)0x566e, (q15_t)0xa197, (q15_t)0x5669, + (q15_t)0xa193, (q15_t)0x5665, (q15_t)0xa18f, (q15_t)0x5660, (q15_t)0xa18a, + (q15_t)0x565b, (q15_t)0xa186, (q15_t)0x5657, (q15_t)0xa182, (q15_t)0x5652, + (q15_t)0xa17e, (q15_t)0x564d, (q15_t)0xa179, (q15_t)0x5649, (q15_t)0xa175, + (q15_t)0x5644, (q15_t)0xa171, (q15_t)0x5640, (q15_t)0xa16d, (q15_t)0x563b, + (q15_t)0xa168, (q15_t)0x5636, (q15_t)0xa164, (q15_t)0x5632, (q15_t)0xa160, + (q15_t)0x562d, (q15_t)0xa15c, (q15_t)0x5628, (q15_t)0xa157, (q15_t)0x5624, + (q15_t)0xa153, (q15_t)0x561f, (q15_t)0xa14f, (q15_t)0x561a, (q15_t)0xa14b, + (q15_t)0x5616, (q15_t)0xa147, (q15_t)0x5611, (q15_t)0xa142, (q15_t)0x560c, + (q15_t)0xa13e, (q15_t)0x5608, (q15_t)0xa13a, (q15_t)0x5603, (q15_t)0xa136, + (q15_t)0x55fe, (q15_t)0xa131, (q15_t)0x55fa, (q15_t)0xa12d, (q15_t)0x55f5, + (q15_t)0xa129, (q15_t)0x55f0, (q15_t)0xa125, (q15_t)0x55ec, (q15_t)0xa121, + (q15_t)0x55e7, (q15_t)0xa11c, (q15_t)0x55e3, (q15_t)0xa118, (q15_t)0x55de, + (q15_t)0xa114, (q15_t)0x55d9, (q15_t)0xa110, (q15_t)0x55d5, (q15_t)0xa10b, + (q15_t)0x55d0, (q15_t)0xa107, (q15_t)0x55cb, (q15_t)0xa103, (q15_t)0x55c7, + (q15_t)0xa0ff, (q15_t)0x55c2, (q15_t)0xa0fb, (q15_t)0x55bd, (q15_t)0xa0f6, + (q15_t)0x55b9, (q15_t)0xa0f2, (q15_t)0x55b4, (q15_t)0xa0ee, (q15_t)0x55af, + (q15_t)0xa0ea, (q15_t)0x55ab, (q15_t)0xa0e6, (q15_t)0x55a6, (q15_t)0xa0e1, + (q15_t)0x55a1, (q15_t)0xa0dd, (q15_t)0x559d, (q15_t)0xa0d9, (q15_t)0x5598, + (q15_t)0xa0d5, (q15_t)0x5593, (q15_t)0xa0d1, (q15_t)0x558f, (q15_t)0xa0cc, + (q15_t)0x558a, (q15_t)0xa0c8, (q15_t)0x5585, (q15_t)0xa0c4, (q15_t)0x5581, + (q15_t)0xa0c0, (q15_t)0x557c, (q15_t)0xa0bc, (q15_t)0x5577, (q15_t)0xa0b7, + (q15_t)0x5572, (q15_t)0xa0b3, (q15_t)0x556e, (q15_t)0xa0af, (q15_t)0x5569, + (q15_t)0xa0ab, (q15_t)0x5564, (q15_t)0xa0a7, (q15_t)0x5560, (q15_t)0xa0a2, + (q15_t)0x555b, (q15_t)0xa09e, (q15_t)0x5556, (q15_t)0xa09a, (q15_t)0x5552, + (q15_t)0xa096, (q15_t)0x554d, (q15_t)0xa092, (q15_t)0x5548, (q15_t)0xa08e, + (q15_t)0x5544, (q15_t)0xa089, (q15_t)0x553f, (q15_t)0xa085, (q15_t)0x553a, + (q15_t)0xa081, (q15_t)0x5536, (q15_t)0xa07d, (q15_t)0x5531, (q15_t)0xa079, + (q15_t)0x552c, (q15_t)0xa074, (q15_t)0x5528, (q15_t)0xa070, (q15_t)0x5523, + (q15_t)0xa06c, (q15_t)0x551e, (q15_t)0xa068, (q15_t)0x5519, (q15_t)0xa064, + (q15_t)0x5515, (q15_t)0xa060, (q15_t)0x5510, (q15_t)0xa05b, (q15_t)0x550b, + (q15_t)0xa057, (q15_t)0x5507, (q15_t)0xa053, (q15_t)0x5502, (q15_t)0xa04f, + (q15_t)0x54fd, (q15_t)0xa04b, (q15_t)0x54f9, (q15_t)0xa046, (q15_t)0x54f4, + (q15_t)0xa042, (q15_t)0x54ef, (q15_t)0xa03e, (q15_t)0x54ea, (q15_t)0xa03a, + (q15_t)0x54e6, (q15_t)0xa036, (q15_t)0x54e1, (q15_t)0xa032, (q15_t)0x54dc, + (q15_t)0xa02d, (q15_t)0x54d8, (q15_t)0xa029, (q15_t)0x54d3, (q15_t)0xa025, + (q15_t)0x54ce, (q15_t)0xa021, (q15_t)0x54ca, (q15_t)0xa01d, (q15_t)0x54c5, + (q15_t)0xa019, (q15_t)0x54c0, (q15_t)0xa014, (q15_t)0x54bb, (q15_t)0xa010, + (q15_t)0x54b7, (q15_t)0xa00c, (q15_t)0x54b2, (q15_t)0xa008, (q15_t)0x54ad, + (q15_t)0xa004, (q15_t)0x54a9, (q15_t)0xa000, (q15_t)0x54a4, (q15_t)0x9ffc, + (q15_t)0x549f, (q15_t)0x9ff7, (q15_t)0x549a, (q15_t)0x9ff3, (q15_t)0x5496, + (q15_t)0x9fef, (q15_t)0x5491, (q15_t)0x9feb, (q15_t)0x548c, (q15_t)0x9fe7, + (q15_t)0x5488, (q15_t)0x9fe3, (q15_t)0x5483, (q15_t)0x9fde, (q15_t)0x547e, + (q15_t)0x9fda, (q15_t)0x5479, (q15_t)0x9fd6, (q15_t)0x5475, (q15_t)0x9fd2, + (q15_t)0x5470, (q15_t)0x9fce, (q15_t)0x546b, (q15_t)0x9fca, (q15_t)0x5467, + (q15_t)0x9fc6, (q15_t)0x5462, (q15_t)0x9fc1, (q15_t)0x545d, (q15_t)0x9fbd, + (q15_t)0x5458, (q15_t)0x9fb9, (q15_t)0x5454, (q15_t)0x9fb5, (q15_t)0x544f, + (q15_t)0x9fb1, (q15_t)0x544a, (q15_t)0x9fad, (q15_t)0x5445, (q15_t)0x9fa9, + (q15_t)0x5441, (q15_t)0x9fa4, (q15_t)0x543c, (q15_t)0x9fa0, (q15_t)0x5437, + (q15_t)0x9f9c, (q15_t)0x5433, (q15_t)0x9f98, (q15_t)0x542e, (q15_t)0x9f94, + (q15_t)0x5429, (q15_t)0x9f90, (q15_t)0x5424, (q15_t)0x9f8c, (q15_t)0x5420, + (q15_t)0x9f88, (q15_t)0x541b, (q15_t)0x9f83, (q15_t)0x5416, (q15_t)0x9f7f, + (q15_t)0x5411, (q15_t)0x9f7b, (q15_t)0x540d, (q15_t)0x9f77, (q15_t)0x5408, + (q15_t)0x9f73, (q15_t)0x5403, (q15_t)0x9f6f, (q15_t)0x53fe, (q15_t)0x9f6b, + (q15_t)0x53fa, (q15_t)0x9f67, (q15_t)0x53f5, (q15_t)0x9f62, (q15_t)0x53f0, + (q15_t)0x9f5e, (q15_t)0x53eb, (q15_t)0x9f5a, (q15_t)0x53e7, (q15_t)0x9f56, + (q15_t)0x53e2, (q15_t)0x9f52, (q15_t)0x53dd, (q15_t)0x9f4e, (q15_t)0x53d8, + (q15_t)0x9f4a, (q15_t)0x53d4, (q15_t)0x9f46, (q15_t)0x53cf, (q15_t)0x9f41, + (q15_t)0x53ca, (q15_t)0x9f3d, (q15_t)0x53c5, (q15_t)0x9f39, (q15_t)0x53c1, + (q15_t)0x9f35, (q15_t)0x53bc, (q15_t)0x9f31, (q15_t)0x53b7, (q15_t)0x9f2d, + (q15_t)0x53b2, (q15_t)0x9f29, (q15_t)0x53ae, (q15_t)0x9f25, (q15_t)0x53a9, + (q15_t)0x9f21, (q15_t)0x53a4, (q15_t)0x9f1c, (q15_t)0x539f, (q15_t)0x9f18, + (q15_t)0x539b, (q15_t)0x9f14, (q15_t)0x5396, (q15_t)0x9f10, (q15_t)0x5391, + (q15_t)0x9f0c, (q15_t)0x538c, (q15_t)0x9f08, (q15_t)0x5388, (q15_t)0x9f04, + (q15_t)0x5383, (q15_t)0x9f00, (q15_t)0x537e, (q15_t)0x9efc, (q15_t)0x5379, + (q15_t)0x9ef8, (q15_t)0x5375, (q15_t)0x9ef3, (q15_t)0x5370, (q15_t)0x9eef, + (q15_t)0x536b, (q15_t)0x9eeb, (q15_t)0x5366, (q15_t)0x9ee7, (q15_t)0x5362, + (q15_t)0x9ee3, (q15_t)0x535d, (q15_t)0x9edf, (q15_t)0x5358, (q15_t)0x9edb, + (q15_t)0x5353, (q15_t)0x9ed7, (q15_t)0x534e, (q15_t)0x9ed3, (q15_t)0x534a, + (q15_t)0x9ecf, (q15_t)0x5345, (q15_t)0x9ecb, (q15_t)0x5340, (q15_t)0x9ec6, + (q15_t)0x533b, (q15_t)0x9ec2, (q15_t)0x5337, (q15_t)0x9ebe, (q15_t)0x5332, + (q15_t)0x9eba, (q15_t)0x532d, (q15_t)0x9eb6, (q15_t)0x5328, (q15_t)0x9eb2, + (q15_t)0x5323, (q15_t)0x9eae, (q15_t)0x531f, (q15_t)0x9eaa, (q15_t)0x531a, + (q15_t)0x9ea6, (q15_t)0x5315, (q15_t)0x9ea2, (q15_t)0x5310, (q15_t)0x9e9e, + (q15_t)0x530c, (q15_t)0x9e9a, (q15_t)0x5307, (q15_t)0x9e95, (q15_t)0x5302, + (q15_t)0x9e91, (q15_t)0x52fd, (q15_t)0x9e8d, (q15_t)0x52f8, (q15_t)0x9e89, + (q15_t)0x52f4, (q15_t)0x9e85, (q15_t)0x52ef, (q15_t)0x9e81, (q15_t)0x52ea, + (q15_t)0x9e7d, (q15_t)0x52e5, (q15_t)0x9e79, (q15_t)0x52e1, (q15_t)0x9e75, + (q15_t)0x52dc, (q15_t)0x9e71, (q15_t)0x52d7, (q15_t)0x9e6d, (q15_t)0x52d2, + (q15_t)0x9e69, (q15_t)0x52cd, (q15_t)0x9e65, (q15_t)0x52c9, (q15_t)0x9e61, + (q15_t)0x52c4, (q15_t)0x9e5d, (q15_t)0x52bf, (q15_t)0x9e58, (q15_t)0x52ba, + (q15_t)0x9e54, (q15_t)0x52b5, (q15_t)0x9e50, (q15_t)0x52b1, (q15_t)0x9e4c, + (q15_t)0x52ac, (q15_t)0x9e48, (q15_t)0x52a7, (q15_t)0x9e44, (q15_t)0x52a2, + (q15_t)0x9e40, (q15_t)0x529d, (q15_t)0x9e3c, (q15_t)0x5299, (q15_t)0x9e38, + (q15_t)0x5294, (q15_t)0x9e34, (q15_t)0x528f, (q15_t)0x9e30, (q15_t)0x528a, + (q15_t)0x9e2c, (q15_t)0x5285, (q15_t)0x9e28, (q15_t)0x5281, (q15_t)0x9e24, + (q15_t)0x527c, (q15_t)0x9e20, (q15_t)0x5277, (q15_t)0x9e1c, (q15_t)0x5272, + (q15_t)0x9e18, (q15_t)0x526d, (q15_t)0x9e14, (q15_t)0x5269, (q15_t)0x9e0f, + (q15_t)0x5264, (q15_t)0x9e0b, (q15_t)0x525f, (q15_t)0x9e07, (q15_t)0x525a, + (q15_t)0x9e03, (q15_t)0x5255, (q15_t)0x9dff, (q15_t)0x5251, (q15_t)0x9dfb, + (q15_t)0x524c, (q15_t)0x9df7, (q15_t)0x5247, (q15_t)0x9df3, (q15_t)0x5242, + (q15_t)0x9def, (q15_t)0x523d, (q15_t)0x9deb, (q15_t)0x5238, (q15_t)0x9de7, + (q15_t)0x5234, (q15_t)0x9de3, (q15_t)0x522f, (q15_t)0x9ddf, (q15_t)0x522a, + (q15_t)0x9ddb, (q15_t)0x5225, (q15_t)0x9dd7, (q15_t)0x5220, (q15_t)0x9dd3, + (q15_t)0x521c, (q15_t)0x9dcf, (q15_t)0x5217, (q15_t)0x9dcb, (q15_t)0x5212, + (q15_t)0x9dc7, (q15_t)0x520d, (q15_t)0x9dc3, (q15_t)0x5208, (q15_t)0x9dbf, + (q15_t)0x5203, (q15_t)0x9dbb, (q15_t)0x51ff, (q15_t)0x9db7, (q15_t)0x51fa, + (q15_t)0x9db3, (q15_t)0x51f5, (q15_t)0x9daf, (q15_t)0x51f0, (q15_t)0x9dab, + (q15_t)0x51eb, (q15_t)0x9da7, (q15_t)0x51e6, (q15_t)0x9da3, (q15_t)0x51e2, + (q15_t)0x9d9f, (q15_t)0x51dd, (q15_t)0x9d9b, (q15_t)0x51d8, (q15_t)0x9d97, + (q15_t)0x51d3, (q15_t)0x9d93, (q15_t)0x51ce, (q15_t)0x9d8f, (q15_t)0x51c9, + (q15_t)0x9d8b, (q15_t)0x51c5, (q15_t)0x9d86, (q15_t)0x51c0, (q15_t)0x9d82, + (q15_t)0x51bb, (q15_t)0x9d7e, (q15_t)0x51b6, (q15_t)0x9d7a, (q15_t)0x51b1, + (q15_t)0x9d76, (q15_t)0x51ac, (q15_t)0x9d72, (q15_t)0x51a8, (q15_t)0x9d6e, + (q15_t)0x51a3, (q15_t)0x9d6a, (q15_t)0x519e, (q15_t)0x9d66, (q15_t)0x5199, + (q15_t)0x9d62, (q15_t)0x5194, (q15_t)0x9d5e, (q15_t)0x518f, (q15_t)0x9d5a, + (q15_t)0x518b, (q15_t)0x9d56, (q15_t)0x5186, (q15_t)0x9d52, (q15_t)0x5181, + (q15_t)0x9d4e, (q15_t)0x517c, (q15_t)0x9d4a, (q15_t)0x5177, (q15_t)0x9d46, + (q15_t)0x5172, (q15_t)0x9d42, (q15_t)0x516e, (q15_t)0x9d3e, (q15_t)0x5169, + (q15_t)0x9d3a, (q15_t)0x5164, (q15_t)0x9d36, (q15_t)0x515f, (q15_t)0x9d32, + (q15_t)0x515a, (q15_t)0x9d2e, (q15_t)0x5155, (q15_t)0x9d2a, (q15_t)0x5150, + (q15_t)0x9d26, (q15_t)0x514c, (q15_t)0x9d22, (q15_t)0x5147, (q15_t)0x9d1e, + (q15_t)0x5142, (q15_t)0x9d1a, (q15_t)0x513d, (q15_t)0x9d16, (q15_t)0x5138, + (q15_t)0x9d12, (q15_t)0x5133, (q15_t)0x9d0e, (q15_t)0x512e, (q15_t)0x9d0b, + (q15_t)0x512a, (q15_t)0x9d07, (q15_t)0x5125, (q15_t)0x9d03, (q15_t)0x5120, + (q15_t)0x9cff, (q15_t)0x511b, (q15_t)0x9cfb, (q15_t)0x5116, (q15_t)0x9cf7, + (q15_t)0x5111, (q15_t)0x9cf3, (q15_t)0x510c, (q15_t)0x9cef, (q15_t)0x5108, + (q15_t)0x9ceb, (q15_t)0x5103, (q15_t)0x9ce7, (q15_t)0x50fe, (q15_t)0x9ce3, + (q15_t)0x50f9, (q15_t)0x9cdf, (q15_t)0x50f4, (q15_t)0x9cdb, (q15_t)0x50ef, + (q15_t)0x9cd7, (q15_t)0x50ea, (q15_t)0x9cd3, (q15_t)0x50e5, (q15_t)0x9ccf, + (q15_t)0x50e1, (q15_t)0x9ccb, (q15_t)0x50dc, (q15_t)0x9cc7, (q15_t)0x50d7, + (q15_t)0x9cc3, (q15_t)0x50d2, (q15_t)0x9cbf, (q15_t)0x50cd, (q15_t)0x9cbb, + (q15_t)0x50c8, (q15_t)0x9cb7, (q15_t)0x50c3, (q15_t)0x9cb3, (q15_t)0x50bf, + (q15_t)0x9caf, (q15_t)0x50ba, (q15_t)0x9cab, (q15_t)0x50b5, (q15_t)0x9ca7, + (q15_t)0x50b0, (q15_t)0x9ca3, (q15_t)0x50ab, (q15_t)0x9c9f, (q15_t)0x50a6, + (q15_t)0x9c9b, (q15_t)0x50a1, (q15_t)0x9c97, (q15_t)0x509c, (q15_t)0x9c93, + (q15_t)0x5097, (q15_t)0x9c8f, (q15_t)0x5093, (q15_t)0x9c8b, (q15_t)0x508e, + (q15_t)0x9c88, (q15_t)0x5089, (q15_t)0x9c84, (q15_t)0x5084, (q15_t)0x9c80, + (q15_t)0x507f, (q15_t)0x9c7c, (q15_t)0x507a, (q15_t)0x9c78, (q15_t)0x5075, + (q15_t)0x9c74, (q15_t)0x5070, (q15_t)0x9c70, (q15_t)0x506c, (q15_t)0x9c6c, + (q15_t)0x5067, (q15_t)0x9c68, (q15_t)0x5062, (q15_t)0x9c64, (q15_t)0x505d, + (q15_t)0x9c60, (q15_t)0x5058, (q15_t)0x9c5c, (q15_t)0x5053, (q15_t)0x9c58, + (q15_t)0x504e, (q15_t)0x9c54, (q15_t)0x5049, (q15_t)0x9c50, (q15_t)0x5044, + (q15_t)0x9c4c, (q15_t)0x503f, (q15_t)0x9c48, (q15_t)0x503b, (q15_t)0x9c44, + (q15_t)0x5036, (q15_t)0x9c40, (q15_t)0x5031, (q15_t)0x9c3d, (q15_t)0x502c, + (q15_t)0x9c39, (q15_t)0x5027, (q15_t)0x9c35, (q15_t)0x5022, (q15_t)0x9c31, + (q15_t)0x501d, (q15_t)0x9c2d, (q15_t)0x5018, (q15_t)0x9c29, (q15_t)0x5013, + (q15_t)0x9c25, (q15_t)0x500f, (q15_t)0x9c21, (q15_t)0x500a, (q15_t)0x9c1d, + (q15_t)0x5005, (q15_t)0x9c19, (q15_t)0x5000, (q15_t)0x9c15, (q15_t)0x4ffb, + (q15_t)0x9c11, (q15_t)0x4ff6, (q15_t)0x9c0d, (q15_t)0x4ff1, (q15_t)0x9c09, + (q15_t)0x4fec, (q15_t)0x9c06, (q15_t)0x4fe7, (q15_t)0x9c02, (q15_t)0x4fe2, + (q15_t)0x9bfe, (q15_t)0x4fdd, (q15_t)0x9bfa, (q15_t)0x4fd9, (q15_t)0x9bf6, + (q15_t)0x4fd4, (q15_t)0x9bf2, (q15_t)0x4fcf, (q15_t)0x9bee, (q15_t)0x4fca, + (q15_t)0x9bea, (q15_t)0x4fc5, (q15_t)0x9be6, (q15_t)0x4fc0, (q15_t)0x9be2, + (q15_t)0x4fbb, (q15_t)0x9bde, (q15_t)0x4fb6, (q15_t)0x9bda, (q15_t)0x4fb1, + (q15_t)0x9bd7, (q15_t)0x4fac, (q15_t)0x9bd3, (q15_t)0x4fa7, (q15_t)0x9bcf, + (q15_t)0x4fa2, (q15_t)0x9bcb, (q15_t)0x4f9e, (q15_t)0x9bc7, (q15_t)0x4f99, + (q15_t)0x9bc3, (q15_t)0x4f94, (q15_t)0x9bbf, (q15_t)0x4f8f, (q15_t)0x9bbb, + (q15_t)0x4f8a, (q15_t)0x9bb7, (q15_t)0x4f85, (q15_t)0x9bb3, (q15_t)0x4f80, + (q15_t)0x9baf, (q15_t)0x4f7b, (q15_t)0x9bac, (q15_t)0x4f76, (q15_t)0x9ba8, + (q15_t)0x4f71, (q15_t)0x9ba4, (q15_t)0x4f6c, (q15_t)0x9ba0, (q15_t)0x4f67, + (q15_t)0x9b9c, (q15_t)0x4f62, (q15_t)0x9b98, (q15_t)0x4f5e, (q15_t)0x9b94, + (q15_t)0x4f59, (q15_t)0x9b90, (q15_t)0x4f54, (q15_t)0x9b8c, (q15_t)0x4f4f, + (q15_t)0x9b88, (q15_t)0x4f4a, (q15_t)0x9b85, (q15_t)0x4f45, (q15_t)0x9b81, + (q15_t)0x4f40, (q15_t)0x9b7d, (q15_t)0x4f3b, (q15_t)0x9b79, (q15_t)0x4f36, + (q15_t)0x9b75, (q15_t)0x4f31, (q15_t)0x9b71, (q15_t)0x4f2c, (q15_t)0x9b6d, + (q15_t)0x4f27, (q15_t)0x9b69, (q15_t)0x4f22, (q15_t)0x9b65, (q15_t)0x4f1d, + (q15_t)0x9b62, (q15_t)0x4f18, (q15_t)0x9b5e, (q15_t)0x4f14, (q15_t)0x9b5a, + (q15_t)0x4f0f, (q15_t)0x9b56, (q15_t)0x4f0a, (q15_t)0x9b52, (q15_t)0x4f05, + (q15_t)0x9b4e, (q15_t)0x4f00, (q15_t)0x9b4a, (q15_t)0x4efb, (q15_t)0x9b46, + (q15_t)0x4ef6, (q15_t)0x9b43, (q15_t)0x4ef1, (q15_t)0x9b3f, (q15_t)0x4eec, + (q15_t)0x9b3b, (q15_t)0x4ee7, (q15_t)0x9b37, (q15_t)0x4ee2, (q15_t)0x9b33, + (q15_t)0x4edd, (q15_t)0x9b2f, (q15_t)0x4ed8, (q15_t)0x9b2b, (q15_t)0x4ed3, + (q15_t)0x9b27, (q15_t)0x4ece, (q15_t)0x9b24, (q15_t)0x4ec9, (q15_t)0x9b20, + (q15_t)0x4ec4, (q15_t)0x9b1c, (q15_t)0x4ebf, (q15_t)0x9b18, (q15_t)0x4eba, + (q15_t)0x9b14, (q15_t)0x4eb6, (q15_t)0x9b10, (q15_t)0x4eb1, (q15_t)0x9b0c, + (q15_t)0x4eac, (q15_t)0x9b09, (q15_t)0x4ea7, (q15_t)0x9b05, (q15_t)0x4ea2, + (q15_t)0x9b01, (q15_t)0x4e9d, (q15_t)0x9afd, (q15_t)0x4e98, (q15_t)0x9af9, + (q15_t)0x4e93, (q15_t)0x9af5, (q15_t)0x4e8e, (q15_t)0x9af1, (q15_t)0x4e89, + (q15_t)0x9aed, (q15_t)0x4e84, (q15_t)0x9aea, (q15_t)0x4e7f, (q15_t)0x9ae6, + (q15_t)0x4e7a, (q15_t)0x9ae2, (q15_t)0x4e75, (q15_t)0x9ade, (q15_t)0x4e70, + (q15_t)0x9ada, (q15_t)0x4e6b, (q15_t)0x9ad6, (q15_t)0x4e66, (q15_t)0x9ad3, + (q15_t)0x4e61, (q15_t)0x9acf, (q15_t)0x4e5c, (q15_t)0x9acb, (q15_t)0x4e57, + (q15_t)0x9ac7, (q15_t)0x4e52, (q15_t)0x9ac3, (q15_t)0x4e4d, (q15_t)0x9abf, + (q15_t)0x4e48, (q15_t)0x9abb, (q15_t)0x4e43, (q15_t)0x9ab8, (q15_t)0x4e3e, + (q15_t)0x9ab4, (q15_t)0x4e39, (q15_t)0x9ab0, (q15_t)0x4e34, (q15_t)0x9aac, + (q15_t)0x4e2f, (q15_t)0x9aa8, (q15_t)0x4e2a, (q15_t)0x9aa4, (q15_t)0x4e26, + (q15_t)0x9aa1, (q15_t)0x4e21, (q15_t)0x9a9d, (q15_t)0x4e1c, (q15_t)0x9a99, + (q15_t)0x4e17, (q15_t)0x9a95, (q15_t)0x4e12, (q15_t)0x9a91, (q15_t)0x4e0d, + (q15_t)0x9a8d, (q15_t)0x4e08, (q15_t)0x9a8a, (q15_t)0x4e03, (q15_t)0x9a86, + (q15_t)0x4dfe, (q15_t)0x9a82, (q15_t)0x4df9, (q15_t)0x9a7e, (q15_t)0x4df4, + (q15_t)0x9a7a, (q15_t)0x4def, (q15_t)0x9a76, (q15_t)0x4dea, (q15_t)0x9a73, + (q15_t)0x4de5, (q15_t)0x9a6f, (q15_t)0x4de0, (q15_t)0x9a6b, (q15_t)0x4ddb, + (q15_t)0x9a67, (q15_t)0x4dd6, (q15_t)0x9a63, (q15_t)0x4dd1, (q15_t)0x9a60, + (q15_t)0x4dcc, (q15_t)0x9a5c, (q15_t)0x4dc7, (q15_t)0x9a58, (q15_t)0x4dc2, + (q15_t)0x9a54, (q15_t)0x4dbd, (q15_t)0x9a50, (q15_t)0x4db8, (q15_t)0x9a4c, + (q15_t)0x4db3, (q15_t)0x9a49, (q15_t)0x4dae, (q15_t)0x9a45, (q15_t)0x4da9, + (q15_t)0x9a41, (q15_t)0x4da4, (q15_t)0x9a3d, (q15_t)0x4d9f, (q15_t)0x9a39, + (q15_t)0x4d9a, (q15_t)0x9a36, (q15_t)0x4d95, (q15_t)0x9a32, (q15_t)0x4d90, + (q15_t)0x9a2e, (q15_t)0x4d8b, (q15_t)0x9a2a, (q15_t)0x4d86, (q15_t)0x9a26, + (q15_t)0x4d81, (q15_t)0x9a23, (q15_t)0x4d7c, (q15_t)0x9a1f, (q15_t)0x4d77, + (q15_t)0x9a1b, (q15_t)0x4d72, (q15_t)0x9a17, (q15_t)0x4d6d, (q15_t)0x9a13, + (q15_t)0x4d68, (q15_t)0x9a10, (q15_t)0x4d63, (q15_t)0x9a0c, (q15_t)0x4d5e, + (q15_t)0x9a08, (q15_t)0x4d59, (q15_t)0x9a04, (q15_t)0x4d54, (q15_t)0x9a00, + (q15_t)0x4d4f, (q15_t)0x99fd, (q15_t)0x4d4a, (q15_t)0x99f9, (q15_t)0x4d45, + (q15_t)0x99f5, (q15_t)0x4d40, (q15_t)0x99f1, (q15_t)0x4d3b, (q15_t)0x99ed, + (q15_t)0x4d36, (q15_t)0x99ea, (q15_t)0x4d31, (q15_t)0x99e6, (q15_t)0x4d2c, + (q15_t)0x99e2, (q15_t)0x4d27, (q15_t)0x99de, (q15_t)0x4d22, (q15_t)0x99da, + (q15_t)0x4d1d, (q15_t)0x99d7, (q15_t)0x4d18, (q15_t)0x99d3, (q15_t)0x4d13, + (q15_t)0x99cf, (q15_t)0x4d0e, (q15_t)0x99cb, (q15_t)0x4d09, (q15_t)0x99c7, + (q15_t)0x4d04, (q15_t)0x99c4, (q15_t)0x4cff, (q15_t)0x99c0, (q15_t)0x4cfa, + (q15_t)0x99bc, (q15_t)0x4cf5, (q15_t)0x99b8, (q15_t)0x4cf0, (q15_t)0x99b5, + (q15_t)0x4ceb, (q15_t)0x99b1, (q15_t)0x4ce6, (q15_t)0x99ad, (q15_t)0x4ce1, + (q15_t)0x99a9, (q15_t)0x4cdb, (q15_t)0x99a5, (q15_t)0x4cd6, (q15_t)0x99a2, + (q15_t)0x4cd1, (q15_t)0x999e, (q15_t)0x4ccc, (q15_t)0x999a, (q15_t)0x4cc7, + (q15_t)0x9996, (q15_t)0x4cc2, (q15_t)0x9993, (q15_t)0x4cbd, (q15_t)0x998f, + (q15_t)0x4cb8, (q15_t)0x998b, (q15_t)0x4cb3, (q15_t)0x9987, (q15_t)0x4cae, + (q15_t)0x9984, (q15_t)0x4ca9, (q15_t)0x9980, (q15_t)0x4ca4, (q15_t)0x997c, + (q15_t)0x4c9f, (q15_t)0x9978, (q15_t)0x4c9a, (q15_t)0x9975, (q15_t)0x4c95, + (q15_t)0x9971, (q15_t)0x4c90, (q15_t)0x996d, (q15_t)0x4c8b, (q15_t)0x9969, + (q15_t)0x4c86, (q15_t)0x9965, (q15_t)0x4c81, (q15_t)0x9962, (q15_t)0x4c7c, + (q15_t)0x995e, (q15_t)0x4c77, (q15_t)0x995a, (q15_t)0x4c72, (q15_t)0x9956, + (q15_t)0x4c6d, (q15_t)0x9953, (q15_t)0x4c68, (q15_t)0x994f, (q15_t)0x4c63, + (q15_t)0x994b, (q15_t)0x4c5e, (q15_t)0x9947, (q15_t)0x4c59, (q15_t)0x9944, + (q15_t)0x4c54, (q15_t)0x9940, (q15_t)0x4c4f, (q15_t)0x993c, (q15_t)0x4c49, + (q15_t)0x9938, (q15_t)0x4c44, (q15_t)0x9935, (q15_t)0x4c3f, (q15_t)0x9931, + (q15_t)0x4c3a, (q15_t)0x992d, (q15_t)0x4c35, (q15_t)0x992a, (q15_t)0x4c30, + (q15_t)0x9926, (q15_t)0x4c2b, (q15_t)0x9922, (q15_t)0x4c26, (q15_t)0x991e, + (q15_t)0x4c21, (q15_t)0x991b, (q15_t)0x4c1c, (q15_t)0x9917, (q15_t)0x4c17, + (q15_t)0x9913, (q15_t)0x4c12, (q15_t)0x990f, (q15_t)0x4c0d, (q15_t)0x990c, + (q15_t)0x4c08, (q15_t)0x9908, (q15_t)0x4c03, (q15_t)0x9904, (q15_t)0x4bfe, + (q15_t)0x9900, (q15_t)0x4bf9, (q15_t)0x98fd, (q15_t)0x4bf4, (q15_t)0x98f9, + (q15_t)0x4bef, (q15_t)0x98f5, (q15_t)0x4be9, (q15_t)0x98f2, (q15_t)0x4be4, + (q15_t)0x98ee, (q15_t)0x4bdf, (q15_t)0x98ea, (q15_t)0x4bda, (q15_t)0x98e6, + (q15_t)0x4bd5, (q15_t)0x98e3, (q15_t)0x4bd0, (q15_t)0x98df, (q15_t)0x4bcb, + (q15_t)0x98db, (q15_t)0x4bc6, (q15_t)0x98d7, (q15_t)0x4bc1, (q15_t)0x98d4, + (q15_t)0x4bbc, (q15_t)0x98d0, (q15_t)0x4bb7, (q15_t)0x98cc, (q15_t)0x4bb2, + (q15_t)0x98c9, (q15_t)0x4bad, (q15_t)0x98c5, (q15_t)0x4ba8, (q15_t)0x98c1, + (q15_t)0x4ba3, (q15_t)0x98bd, (q15_t)0x4b9e, (q15_t)0x98ba, (q15_t)0x4b98, + (q15_t)0x98b6, (q15_t)0x4b93, (q15_t)0x98b2, (q15_t)0x4b8e, (q15_t)0x98af, + (q15_t)0x4b89, (q15_t)0x98ab, (q15_t)0x4b84, (q15_t)0x98a7, (q15_t)0x4b7f, + (q15_t)0x98a3, (q15_t)0x4b7a, (q15_t)0x98a0, (q15_t)0x4b75, (q15_t)0x989c, + (q15_t)0x4b70, (q15_t)0x9898, (q15_t)0x4b6b, (q15_t)0x9895, (q15_t)0x4b66, + (q15_t)0x9891, (q15_t)0x4b61, (q15_t)0x988d, (q15_t)0x4b5c, (q15_t)0x988a, + (q15_t)0x4b56, (q15_t)0x9886, (q15_t)0x4b51, (q15_t)0x9882, (q15_t)0x4b4c, + (q15_t)0x987e, (q15_t)0x4b47, (q15_t)0x987b, (q15_t)0x4b42, (q15_t)0x9877, + (q15_t)0x4b3d, (q15_t)0x9873, (q15_t)0x4b38, (q15_t)0x9870, (q15_t)0x4b33, + (q15_t)0x986c, (q15_t)0x4b2e, (q15_t)0x9868, (q15_t)0x4b29, (q15_t)0x9865, + (q15_t)0x4b24, (q15_t)0x9861, (q15_t)0x4b1f, (q15_t)0x985d, (q15_t)0x4b19, + (q15_t)0x985a, (q15_t)0x4b14, (q15_t)0x9856, (q15_t)0x4b0f, (q15_t)0x9852, + (q15_t)0x4b0a, (q15_t)0x984e, (q15_t)0x4b05, (q15_t)0x984b, (q15_t)0x4b00, + (q15_t)0x9847, (q15_t)0x4afb, (q15_t)0x9843, (q15_t)0x4af6, (q15_t)0x9840, + (q15_t)0x4af1, (q15_t)0x983c, (q15_t)0x4aec, (q15_t)0x9838, (q15_t)0x4ae7, + (q15_t)0x9835, (q15_t)0x4ae1, (q15_t)0x9831, (q15_t)0x4adc, (q15_t)0x982d, + (q15_t)0x4ad7, (q15_t)0x982a, (q15_t)0x4ad2, (q15_t)0x9826, (q15_t)0x4acd, + (q15_t)0x9822, (q15_t)0x4ac8, (q15_t)0x981f, (q15_t)0x4ac3, (q15_t)0x981b, + (q15_t)0x4abe, (q15_t)0x9817, (q15_t)0x4ab9, (q15_t)0x9814, (q15_t)0x4ab4, + (q15_t)0x9810, (q15_t)0x4aae, (q15_t)0x980c, (q15_t)0x4aa9, (q15_t)0x9809, + (q15_t)0x4aa4, (q15_t)0x9805, (q15_t)0x4a9f, (q15_t)0x9801, (q15_t)0x4a9a, + (q15_t)0x97fe, (q15_t)0x4a95, (q15_t)0x97fa, (q15_t)0x4a90, (q15_t)0x97f6, + (q15_t)0x4a8b, (q15_t)0x97f3, (q15_t)0x4a86, (q15_t)0x97ef, (q15_t)0x4a81, + (q15_t)0x97eb, (q15_t)0x4a7b, (q15_t)0x97e8, (q15_t)0x4a76, (q15_t)0x97e4, + (q15_t)0x4a71, (q15_t)0x97e0, (q15_t)0x4a6c, (q15_t)0x97dd, (q15_t)0x4a67, + (q15_t)0x97d9, (q15_t)0x4a62, (q15_t)0x97d5, (q15_t)0x4a5d, (q15_t)0x97d2, + (q15_t)0x4a58, (q15_t)0x97ce, (q15_t)0x4a52, (q15_t)0x97cb, (q15_t)0x4a4d, + (q15_t)0x97c7, (q15_t)0x4a48, (q15_t)0x97c3, (q15_t)0x4a43, (q15_t)0x97c0, + (q15_t)0x4a3e, (q15_t)0x97bc, (q15_t)0x4a39, (q15_t)0x97b8, (q15_t)0x4a34, + (q15_t)0x97b5, (q15_t)0x4a2f, (q15_t)0x97b1, (q15_t)0x4a2a, (q15_t)0x97ad, + (q15_t)0x4a24, (q15_t)0x97aa, (q15_t)0x4a1f, (q15_t)0x97a6, (q15_t)0x4a1a, + (q15_t)0x97a2, (q15_t)0x4a15, (q15_t)0x979f, (q15_t)0x4a10, (q15_t)0x979b, + (q15_t)0x4a0b, (q15_t)0x9798, (q15_t)0x4a06, (q15_t)0x9794, (q15_t)0x4a01, + (q15_t)0x9790, (q15_t)0x49fb, (q15_t)0x978d, (q15_t)0x49f6, (q15_t)0x9789, + (q15_t)0x49f1, (q15_t)0x9785, (q15_t)0x49ec, (q15_t)0x9782, (q15_t)0x49e7, + (q15_t)0x977e, (q15_t)0x49e2, (q15_t)0x977a, (q15_t)0x49dd, (q15_t)0x9777, + (q15_t)0x49d8, (q15_t)0x9773, (q15_t)0x49d2, (q15_t)0x9770, (q15_t)0x49cd, + (q15_t)0x976c, (q15_t)0x49c8, (q15_t)0x9768, (q15_t)0x49c3, (q15_t)0x9765, + (q15_t)0x49be, (q15_t)0x9761, (q15_t)0x49b9, (q15_t)0x975d, (q15_t)0x49b4, + (q15_t)0x975a, (q15_t)0x49ae, (q15_t)0x9756, (q15_t)0x49a9, (q15_t)0x9753, + (q15_t)0x49a4, (q15_t)0x974f, (q15_t)0x499f, (q15_t)0x974b, (q15_t)0x499a, + (q15_t)0x9748, (q15_t)0x4995, (q15_t)0x9744, (q15_t)0x4990, (q15_t)0x9741, + (q15_t)0x498a, (q15_t)0x973d, (q15_t)0x4985, (q15_t)0x9739, (q15_t)0x4980, + (q15_t)0x9736, (q15_t)0x497b, (q15_t)0x9732, (q15_t)0x4976, (q15_t)0x972f, + (q15_t)0x4971, (q15_t)0x972b, (q15_t)0x496c, (q15_t)0x9727, (q15_t)0x4966, + (q15_t)0x9724, (q15_t)0x4961, (q15_t)0x9720, (q15_t)0x495c, (q15_t)0x971d, + (q15_t)0x4957, (q15_t)0x9719, (q15_t)0x4952, (q15_t)0x9715, (q15_t)0x494d, + (q15_t)0x9712, (q15_t)0x4948, (q15_t)0x970e, (q15_t)0x4942, (q15_t)0x970b, + (q15_t)0x493d, (q15_t)0x9707, (q15_t)0x4938, (q15_t)0x9703, (q15_t)0x4933, + (q15_t)0x9700, (q15_t)0x492e, (q15_t)0x96fc, (q15_t)0x4929, (q15_t)0x96f9, + (q15_t)0x4923, (q15_t)0x96f5, (q15_t)0x491e, (q15_t)0x96f1, (q15_t)0x4919, + (q15_t)0x96ee, (q15_t)0x4914, (q15_t)0x96ea, (q15_t)0x490f, (q15_t)0x96e7, + (q15_t)0x490a, (q15_t)0x96e3, (q15_t)0x4905, (q15_t)0x96df, (q15_t)0x48ff, + (q15_t)0x96dc, (q15_t)0x48fa, (q15_t)0x96d8, (q15_t)0x48f5, (q15_t)0x96d5, + (q15_t)0x48f0, (q15_t)0x96d1, (q15_t)0x48eb, (q15_t)0x96ce, (q15_t)0x48e6, + (q15_t)0x96ca, (q15_t)0x48e0, (q15_t)0x96c6, (q15_t)0x48db, (q15_t)0x96c3, + (q15_t)0x48d6, (q15_t)0x96bf, (q15_t)0x48d1, (q15_t)0x96bc, (q15_t)0x48cc, + (q15_t)0x96b8, (q15_t)0x48c7, (q15_t)0x96b5, (q15_t)0x48c1, (q15_t)0x96b1, + (q15_t)0x48bc, (q15_t)0x96ad, (q15_t)0x48b7, (q15_t)0x96aa, (q15_t)0x48b2, + (q15_t)0x96a6, (q15_t)0x48ad, (q15_t)0x96a3, (q15_t)0x48a8, (q15_t)0x969f, + (q15_t)0x48a2, (q15_t)0x969c, (q15_t)0x489d, (q15_t)0x9698, (q15_t)0x4898, + (q15_t)0x9694, (q15_t)0x4893, (q15_t)0x9691, (q15_t)0x488e, (q15_t)0x968d, + (q15_t)0x4888, (q15_t)0x968a, (q15_t)0x4883, (q15_t)0x9686, (q15_t)0x487e, + (q15_t)0x9683, (q15_t)0x4879, (q15_t)0x967f, (q15_t)0x4874, (q15_t)0x967b, + (q15_t)0x486f, (q15_t)0x9678, (q15_t)0x4869, (q15_t)0x9674, (q15_t)0x4864, + (q15_t)0x9671, (q15_t)0x485f, (q15_t)0x966d, (q15_t)0x485a, (q15_t)0x966a, + (q15_t)0x4855, (q15_t)0x9666, (q15_t)0x484f, (q15_t)0x9663, (q15_t)0x484a, + (q15_t)0x965f, (q15_t)0x4845, (q15_t)0x965b, (q15_t)0x4840, (q15_t)0x9658, + (q15_t)0x483b, (q15_t)0x9654, (q15_t)0x4836, (q15_t)0x9651, (q15_t)0x4830, + (q15_t)0x964d, (q15_t)0x482b, (q15_t)0x964a, (q15_t)0x4826, (q15_t)0x9646, + (q15_t)0x4821, (q15_t)0x9643, (q15_t)0x481c, (q15_t)0x963f, (q15_t)0x4816, + (q15_t)0x963c, (q15_t)0x4811, (q15_t)0x9638, (q15_t)0x480c, (q15_t)0x9635, + (q15_t)0x4807, (q15_t)0x9631, (q15_t)0x4802, (q15_t)0x962d, (q15_t)0x47fc, + (q15_t)0x962a, (q15_t)0x47f7, (q15_t)0x9626, (q15_t)0x47f2, (q15_t)0x9623, + (q15_t)0x47ed, (q15_t)0x961f, (q15_t)0x47e8, (q15_t)0x961c, (q15_t)0x47e2, + (q15_t)0x9618, (q15_t)0x47dd, (q15_t)0x9615, (q15_t)0x47d8, (q15_t)0x9611, + (q15_t)0x47d3, (q15_t)0x960e, (q15_t)0x47ce, (q15_t)0x960a, (q15_t)0x47c8, + (q15_t)0x9607, (q15_t)0x47c3, (q15_t)0x9603, (q15_t)0x47be, (q15_t)0x9600, + (q15_t)0x47b9, (q15_t)0x95fc, (q15_t)0x47b4, (q15_t)0x95f9, (q15_t)0x47ae, + (q15_t)0x95f5, (q15_t)0x47a9, (q15_t)0x95f2, (q15_t)0x47a4, (q15_t)0x95ee, + (q15_t)0x479f, (q15_t)0x95ea, (q15_t)0x479a, (q15_t)0x95e7, (q15_t)0x4794, + (q15_t)0x95e3, (q15_t)0x478f, (q15_t)0x95e0, (q15_t)0x478a, (q15_t)0x95dc, + (q15_t)0x4785, (q15_t)0x95d9, (q15_t)0x4780, (q15_t)0x95d5, (q15_t)0x477a, + (q15_t)0x95d2, (q15_t)0x4775, (q15_t)0x95ce, (q15_t)0x4770, (q15_t)0x95cb, + (q15_t)0x476b, (q15_t)0x95c7, (q15_t)0x4765, (q15_t)0x95c4, (q15_t)0x4760, + (q15_t)0x95c0, (q15_t)0x475b, (q15_t)0x95bd, (q15_t)0x4756, (q15_t)0x95b9, + (q15_t)0x4751, (q15_t)0x95b6, (q15_t)0x474b, (q15_t)0x95b2, (q15_t)0x4746, + (q15_t)0x95af, (q15_t)0x4741, (q15_t)0x95ab, (q15_t)0x473c, (q15_t)0x95a8, + (q15_t)0x4737, (q15_t)0x95a4, (q15_t)0x4731, (q15_t)0x95a1, (q15_t)0x472c, + (q15_t)0x959d, (q15_t)0x4727, (q15_t)0x959a, (q15_t)0x4722, (q15_t)0x9596, + (q15_t)0x471c, (q15_t)0x9593, (q15_t)0x4717, (q15_t)0x958f, (q15_t)0x4712, + (q15_t)0x958c, (q15_t)0x470d, (q15_t)0x9588, (q15_t)0x4708, (q15_t)0x9585, + (q15_t)0x4702, (q15_t)0x9581, (q15_t)0x46fd, (q15_t)0x957e, (q15_t)0x46f8, + (q15_t)0x957a, (q15_t)0x46f3, (q15_t)0x9577, (q15_t)0x46ed, (q15_t)0x9574, + (q15_t)0x46e8, (q15_t)0x9570, (q15_t)0x46e3, (q15_t)0x956d, (q15_t)0x46de, + (q15_t)0x9569, (q15_t)0x46d8, (q15_t)0x9566, (q15_t)0x46d3, (q15_t)0x9562, + (q15_t)0x46ce, (q15_t)0x955f, (q15_t)0x46c9, (q15_t)0x955b, (q15_t)0x46c4, + (q15_t)0x9558, (q15_t)0x46be, (q15_t)0x9554, (q15_t)0x46b9, (q15_t)0x9551, + (q15_t)0x46b4, (q15_t)0x954d, (q15_t)0x46af, (q15_t)0x954a, (q15_t)0x46a9, + (q15_t)0x9546, (q15_t)0x46a4, (q15_t)0x9543, (q15_t)0x469f, (q15_t)0x953f, + (q15_t)0x469a, (q15_t)0x953c, (q15_t)0x4694, (q15_t)0x9538, (q15_t)0x468f, + (q15_t)0x9535, (q15_t)0x468a, (q15_t)0x9532, (q15_t)0x4685, (q15_t)0x952e, + (q15_t)0x467f, (q15_t)0x952b, (q15_t)0x467a, (q15_t)0x9527, (q15_t)0x4675, + (q15_t)0x9524, (q15_t)0x4670, (q15_t)0x9520, (q15_t)0x466a, (q15_t)0x951d, + (q15_t)0x4665, (q15_t)0x9519, (q15_t)0x4660, (q15_t)0x9516, (q15_t)0x465b, + (q15_t)0x9512, (q15_t)0x4655, (q15_t)0x950f, (q15_t)0x4650, (q15_t)0x950c, + (q15_t)0x464b, (q15_t)0x9508, (q15_t)0x4646, (q15_t)0x9505, (q15_t)0x4640, + (q15_t)0x9501, (q15_t)0x463b, (q15_t)0x94fe, (q15_t)0x4636, (q15_t)0x94fa, + (q15_t)0x4631, (q15_t)0x94f7, (q15_t)0x462b, (q15_t)0x94f3, (q15_t)0x4626, + (q15_t)0x94f0, (q15_t)0x4621, (q15_t)0x94ed, (q15_t)0x461c, (q15_t)0x94e9, + (q15_t)0x4616, (q15_t)0x94e6, (q15_t)0x4611, (q15_t)0x94e2, (q15_t)0x460c, + (q15_t)0x94df, (q15_t)0x4607, (q15_t)0x94db, (q15_t)0x4601, (q15_t)0x94d8, + (q15_t)0x45fc, (q15_t)0x94d4, (q15_t)0x45f7, (q15_t)0x94d1, (q15_t)0x45f2, + (q15_t)0x94ce, (q15_t)0x45ec, (q15_t)0x94ca, (q15_t)0x45e7, (q15_t)0x94c7, + (q15_t)0x45e2, (q15_t)0x94c3, (q15_t)0x45dd, (q15_t)0x94c0, (q15_t)0x45d7, + (q15_t)0x94bc, (q15_t)0x45d2, (q15_t)0x94b9, (q15_t)0x45cd, (q15_t)0x94b6, + (q15_t)0x45c7, (q15_t)0x94b2, (q15_t)0x45c2, (q15_t)0x94af, (q15_t)0x45bd, + (q15_t)0x94ab, (q15_t)0x45b8, (q15_t)0x94a8, (q15_t)0x45b2, (q15_t)0x94a4, + (q15_t)0x45ad, (q15_t)0x94a1, (q15_t)0x45a8, (q15_t)0x949e, (q15_t)0x45a3, + (q15_t)0x949a, (q15_t)0x459d, (q15_t)0x9497, (q15_t)0x4598, (q15_t)0x9493, + (q15_t)0x4593, (q15_t)0x9490, (q15_t)0x458d, (q15_t)0x948d, (q15_t)0x4588, + (q15_t)0x9489, (q15_t)0x4583, (q15_t)0x9486, (q15_t)0x457e, (q15_t)0x9482, + (q15_t)0x4578, (q15_t)0x947f, (q15_t)0x4573, (q15_t)0x947b, (q15_t)0x456e, + (q15_t)0x9478, (q15_t)0x4569, (q15_t)0x9475, (q15_t)0x4563, (q15_t)0x9471, + (q15_t)0x455e, (q15_t)0x946e, (q15_t)0x4559, (q15_t)0x946a, (q15_t)0x4553, + (q15_t)0x9467, (q15_t)0x454e, (q15_t)0x9464, (q15_t)0x4549, (q15_t)0x9460, + (q15_t)0x4544, (q15_t)0x945d, (q15_t)0x453e, (q15_t)0x9459, (q15_t)0x4539, + (q15_t)0x9456, (q15_t)0x4534, (q15_t)0x9453, (q15_t)0x452e, (q15_t)0x944f, + (q15_t)0x4529, (q15_t)0x944c, (q15_t)0x4524, (q15_t)0x9448, (q15_t)0x451f, + (q15_t)0x9445, (q15_t)0x4519, (q15_t)0x9442, (q15_t)0x4514, (q15_t)0x943e, + (q15_t)0x450f, (q15_t)0x943b, (q15_t)0x4509, (q15_t)0x9437, (q15_t)0x4504, + (q15_t)0x9434, (q15_t)0x44ff, (q15_t)0x9431, (q15_t)0x44fa, (q15_t)0x942d, + (q15_t)0x44f4, (q15_t)0x942a, (q15_t)0x44ef, (q15_t)0x9427, (q15_t)0x44ea, + (q15_t)0x9423, (q15_t)0x44e4, (q15_t)0x9420, (q15_t)0x44df, (q15_t)0x941c, + (q15_t)0x44da, (q15_t)0x9419, (q15_t)0x44d4, (q15_t)0x9416, (q15_t)0x44cf, + (q15_t)0x9412, (q15_t)0x44ca, (q15_t)0x940f, (q15_t)0x44c5, (q15_t)0x940b, + (q15_t)0x44bf, (q15_t)0x9408, (q15_t)0x44ba, (q15_t)0x9405, (q15_t)0x44b5, + (q15_t)0x9401, (q15_t)0x44af, (q15_t)0x93fe, (q15_t)0x44aa, (q15_t)0x93fb, + (q15_t)0x44a5, (q15_t)0x93f7, (q15_t)0x449f, (q15_t)0x93f4, (q15_t)0x449a, + (q15_t)0x93f1, (q15_t)0x4495, (q15_t)0x93ed, (q15_t)0x4490, (q15_t)0x93ea, + (q15_t)0x448a, (q15_t)0x93e6, (q15_t)0x4485, (q15_t)0x93e3, (q15_t)0x4480, + (q15_t)0x93e0, (q15_t)0x447a, (q15_t)0x93dc, (q15_t)0x4475, (q15_t)0x93d9, + (q15_t)0x4470, (q15_t)0x93d6, (q15_t)0x446a, (q15_t)0x93d2, (q15_t)0x4465, + (q15_t)0x93cf, (q15_t)0x4460, (q15_t)0x93cc, (q15_t)0x445a, (q15_t)0x93c8, + (q15_t)0x4455, (q15_t)0x93c5, (q15_t)0x4450, (q15_t)0x93c1, (q15_t)0x444b, + (q15_t)0x93be, (q15_t)0x4445, (q15_t)0x93bb, (q15_t)0x4440, (q15_t)0x93b7, + (q15_t)0x443b, (q15_t)0x93b4, (q15_t)0x4435, (q15_t)0x93b1, (q15_t)0x4430, + (q15_t)0x93ad, (q15_t)0x442b, (q15_t)0x93aa, (q15_t)0x4425, (q15_t)0x93a7, + (q15_t)0x4420, (q15_t)0x93a3, (q15_t)0x441b, (q15_t)0x93a0, (q15_t)0x4415, + (q15_t)0x939d, (q15_t)0x4410, (q15_t)0x9399, (q15_t)0x440b, (q15_t)0x9396, + (q15_t)0x4405, (q15_t)0x9393, (q15_t)0x4400, (q15_t)0x938f, (q15_t)0x43fb, + (q15_t)0x938c, (q15_t)0x43f5, (q15_t)0x9389, (q15_t)0x43f0, (q15_t)0x9385, + (q15_t)0x43eb, (q15_t)0x9382, (q15_t)0x43e5, (q15_t)0x937f, (q15_t)0x43e0, + (q15_t)0x937b, (q15_t)0x43db, (q15_t)0x9378, (q15_t)0x43d5, (q15_t)0x9375, + (q15_t)0x43d0, (q15_t)0x9371, (q15_t)0x43cb, (q15_t)0x936e, (q15_t)0x43c5, + (q15_t)0x936b, (q15_t)0x43c0, (q15_t)0x9367, (q15_t)0x43bb, (q15_t)0x9364, + (q15_t)0x43b5, (q15_t)0x9361, (q15_t)0x43b0, (q15_t)0x935d, (q15_t)0x43ab, + (q15_t)0x935a, (q15_t)0x43a5, (q15_t)0x9357, (q15_t)0x43a0, (q15_t)0x9353, + (q15_t)0x439b, (q15_t)0x9350, (q15_t)0x4395, (q15_t)0x934d, (q15_t)0x4390, + (q15_t)0x9349, (q15_t)0x438b, (q15_t)0x9346, (q15_t)0x4385, (q15_t)0x9343, + (q15_t)0x4380, (q15_t)0x933f, (q15_t)0x437b, (q15_t)0x933c, (q15_t)0x4375, + (q15_t)0x9339, (q15_t)0x4370, (q15_t)0x9336, (q15_t)0x436b, (q15_t)0x9332, + (q15_t)0x4365, (q15_t)0x932f, (q15_t)0x4360, (q15_t)0x932c, (q15_t)0x435b, + (q15_t)0x9328, (q15_t)0x4355, (q15_t)0x9325, (q15_t)0x4350, (q15_t)0x9322, + (q15_t)0x434b, (q15_t)0x931e, (q15_t)0x4345, (q15_t)0x931b, (q15_t)0x4340, + (q15_t)0x9318, (q15_t)0x433b, (q15_t)0x9314, (q15_t)0x4335, (q15_t)0x9311, + (q15_t)0x4330, (q15_t)0x930e, (q15_t)0x432b, (q15_t)0x930b, (q15_t)0x4325, + (q15_t)0x9307, (q15_t)0x4320, (q15_t)0x9304, (q15_t)0x431b, (q15_t)0x9301, + (q15_t)0x4315, (q15_t)0x92fd, (q15_t)0x4310, (q15_t)0x92fa, (q15_t)0x430b, + (q15_t)0x92f7, (q15_t)0x4305, (q15_t)0x92f4, (q15_t)0x4300, (q15_t)0x92f0, + (q15_t)0x42fa, (q15_t)0x92ed, (q15_t)0x42f5, (q15_t)0x92ea, (q15_t)0x42f0, + (q15_t)0x92e6, (q15_t)0x42ea, (q15_t)0x92e3, (q15_t)0x42e5, (q15_t)0x92e0, + (q15_t)0x42e0, (q15_t)0x92dd, (q15_t)0x42da, (q15_t)0x92d9, (q15_t)0x42d5, + (q15_t)0x92d6, (q15_t)0x42d0, (q15_t)0x92d3, (q15_t)0x42ca, (q15_t)0x92cf, + (q15_t)0x42c5, (q15_t)0x92cc, (q15_t)0x42c0, (q15_t)0x92c9, (q15_t)0x42ba, + (q15_t)0x92c6, (q15_t)0x42b5, (q15_t)0x92c2, (q15_t)0x42af, (q15_t)0x92bf, + (q15_t)0x42aa, (q15_t)0x92bc, (q15_t)0x42a5, (q15_t)0x92b8, (q15_t)0x429f, + (q15_t)0x92b5, (q15_t)0x429a, (q15_t)0x92b2, (q15_t)0x4295, (q15_t)0x92af, + (q15_t)0x428f, (q15_t)0x92ab, (q15_t)0x428a, (q15_t)0x92a8, (q15_t)0x4284, + (q15_t)0x92a5, (q15_t)0x427f, (q15_t)0x92a2, (q15_t)0x427a, (q15_t)0x929e, + (q15_t)0x4274, (q15_t)0x929b, (q15_t)0x426f, (q15_t)0x9298, (q15_t)0x426a, + (q15_t)0x9295, (q15_t)0x4264, (q15_t)0x9291, (q15_t)0x425f, (q15_t)0x928e, + (q15_t)0x425a, (q15_t)0x928b, (q15_t)0x4254, (q15_t)0x9288, (q15_t)0x424f, + (q15_t)0x9284, (q15_t)0x4249, (q15_t)0x9281, (q15_t)0x4244, (q15_t)0x927e, + (q15_t)0x423f, (q15_t)0x927b, (q15_t)0x4239, (q15_t)0x9277, (q15_t)0x4234, + (q15_t)0x9274, (q15_t)0x422f, (q15_t)0x9271, (q15_t)0x4229, (q15_t)0x926e, + (q15_t)0x4224, (q15_t)0x926a, (q15_t)0x421e, (q15_t)0x9267, (q15_t)0x4219, + (q15_t)0x9264, (q15_t)0x4214, (q15_t)0x9261, (q15_t)0x420e, (q15_t)0x925d, + (q15_t)0x4209, (q15_t)0x925a, (q15_t)0x4203, (q15_t)0x9257, (q15_t)0x41fe, + (q15_t)0x9254, (q15_t)0x41f9, (q15_t)0x9250, (q15_t)0x41f3, (q15_t)0x924d, + (q15_t)0x41ee, (q15_t)0x924a, (q15_t)0x41e9, (q15_t)0x9247, (q15_t)0x41e3, + (q15_t)0x9243, (q15_t)0x41de, (q15_t)0x9240, (q15_t)0x41d8, (q15_t)0x923d, + (q15_t)0x41d3, (q15_t)0x923a, (q15_t)0x41ce, (q15_t)0x9236, (q15_t)0x41c8, + (q15_t)0x9233, (q15_t)0x41c3, (q15_t)0x9230, (q15_t)0x41bd, (q15_t)0x922d, + (q15_t)0x41b8, (q15_t)0x922a, (q15_t)0x41b3, (q15_t)0x9226, (q15_t)0x41ad, + (q15_t)0x9223, (q15_t)0x41a8, (q15_t)0x9220, (q15_t)0x41a2, (q15_t)0x921d, + (q15_t)0x419d, (q15_t)0x9219, (q15_t)0x4198, (q15_t)0x9216, (q15_t)0x4192, + (q15_t)0x9213, (q15_t)0x418d, (q15_t)0x9210, (q15_t)0x4188, (q15_t)0x920d, + (q15_t)0x4182, (q15_t)0x9209, (q15_t)0x417d, (q15_t)0x9206, (q15_t)0x4177, + (q15_t)0x9203, (q15_t)0x4172, (q15_t)0x9200, (q15_t)0x416d, (q15_t)0x91fc, + (q15_t)0x4167, (q15_t)0x91f9, (q15_t)0x4162, (q15_t)0x91f6, (q15_t)0x415c, + (q15_t)0x91f3, (q15_t)0x4157, (q15_t)0x91f0, (q15_t)0x4152, (q15_t)0x91ec, + (q15_t)0x414c, (q15_t)0x91e9, (q15_t)0x4147, (q15_t)0x91e6, (q15_t)0x4141, + (q15_t)0x91e3, (q15_t)0x413c, (q15_t)0x91e0, (q15_t)0x4136, (q15_t)0x91dc, + (q15_t)0x4131, (q15_t)0x91d9, (q15_t)0x412c, (q15_t)0x91d6, (q15_t)0x4126, + (q15_t)0x91d3, (q15_t)0x4121, (q15_t)0x91d0, (q15_t)0x411b, (q15_t)0x91cc, + (q15_t)0x4116, (q15_t)0x91c9, (q15_t)0x4111, (q15_t)0x91c6, (q15_t)0x410b, + (q15_t)0x91c3, (q15_t)0x4106, (q15_t)0x91c0, (q15_t)0x4100, (q15_t)0x91bc, + (q15_t)0x40fb, (q15_t)0x91b9, (q15_t)0x40f6, (q15_t)0x91b6, (q15_t)0x40f0, + (q15_t)0x91b3, (q15_t)0x40eb, (q15_t)0x91b0, (q15_t)0x40e5, (q15_t)0x91ad, + (q15_t)0x40e0, (q15_t)0x91a9, (q15_t)0x40da, (q15_t)0x91a6, (q15_t)0x40d5, + (q15_t)0x91a3, (q15_t)0x40d0, (q15_t)0x91a0, (q15_t)0x40ca, (q15_t)0x919d, + (q15_t)0x40c5, (q15_t)0x9199, (q15_t)0x40bf, (q15_t)0x9196, (q15_t)0x40ba, + (q15_t)0x9193, (q15_t)0x40b5, (q15_t)0x9190, (q15_t)0x40af, (q15_t)0x918d, + (q15_t)0x40aa, (q15_t)0x918a, (q15_t)0x40a4, (q15_t)0x9186, (q15_t)0x409f, + (q15_t)0x9183, (q15_t)0x4099, (q15_t)0x9180, (q15_t)0x4094, (q15_t)0x917d, + (q15_t)0x408f, (q15_t)0x917a, (q15_t)0x4089, (q15_t)0x9177, (q15_t)0x4084, + (q15_t)0x9173, (q15_t)0x407e, (q15_t)0x9170, (q15_t)0x4079, (q15_t)0x916d, + (q15_t)0x4073, (q15_t)0x916a, (q15_t)0x406e, (q15_t)0x9167, (q15_t)0x4069, + (q15_t)0x9164, (q15_t)0x4063, (q15_t)0x9160, (q15_t)0x405e, (q15_t)0x915d, + (q15_t)0x4058, (q15_t)0x915a, (q15_t)0x4053, (q15_t)0x9157, (q15_t)0x404d, + (q15_t)0x9154, (q15_t)0x4048, (q15_t)0x9151, (q15_t)0x4043, (q15_t)0x914d, + (q15_t)0x403d, (q15_t)0x914a, (q15_t)0x4038, (q15_t)0x9147, (q15_t)0x4032, + (q15_t)0x9144, (q15_t)0x402d, (q15_t)0x9141, (q15_t)0x4027, (q15_t)0x913e, + (q15_t)0x4022, (q15_t)0x913a, (q15_t)0x401d, (q15_t)0x9137, (q15_t)0x4017, + (q15_t)0x9134, (q15_t)0x4012, (q15_t)0x9131, (q15_t)0x400c, (q15_t)0x912e, + (q15_t)0x4007, (q15_t)0x912b, (q15_t)0x4001, (q15_t)0x9128, (q15_t)0x3ffc, + (q15_t)0x9124, (q15_t)0x3ff6, (q15_t)0x9121, (q15_t)0x3ff1, (q15_t)0x911e, + (q15_t)0x3fec, (q15_t)0x911b, (q15_t)0x3fe6, (q15_t)0x9118, (q15_t)0x3fe1, + (q15_t)0x9115, (q15_t)0x3fdb, (q15_t)0x9112, (q15_t)0x3fd6, (q15_t)0x910f, + (q15_t)0x3fd0, (q15_t)0x910b, (q15_t)0x3fcb, (q15_t)0x9108, (q15_t)0x3fc5, + (q15_t)0x9105, (q15_t)0x3fc0, (q15_t)0x9102, (q15_t)0x3fbb, (q15_t)0x90ff, + (q15_t)0x3fb5, (q15_t)0x90fc, (q15_t)0x3fb0, (q15_t)0x90f9, (q15_t)0x3faa, + (q15_t)0x90f5, (q15_t)0x3fa5, (q15_t)0x90f2, (q15_t)0x3f9f, (q15_t)0x90ef, + (q15_t)0x3f9a, (q15_t)0x90ec, (q15_t)0x3f94, (q15_t)0x90e9, (q15_t)0x3f8f, + (q15_t)0x90e6, (q15_t)0x3f89, (q15_t)0x90e3, (q15_t)0x3f84, (q15_t)0x90e0, + (q15_t)0x3f7f, (q15_t)0x90dd, (q15_t)0x3f79, (q15_t)0x90d9, (q15_t)0x3f74, + (q15_t)0x90d6, (q15_t)0x3f6e, (q15_t)0x90d3, (q15_t)0x3f69, (q15_t)0x90d0, + (q15_t)0x3f63, (q15_t)0x90cd, (q15_t)0x3f5e, (q15_t)0x90ca, (q15_t)0x3f58, + (q15_t)0x90c7, (q15_t)0x3f53, (q15_t)0x90c4, (q15_t)0x3f4d, (q15_t)0x90c1, + (q15_t)0x3f48, (q15_t)0x90bd, (q15_t)0x3f43, (q15_t)0x90ba, (q15_t)0x3f3d, + (q15_t)0x90b7, (q15_t)0x3f38, (q15_t)0x90b4, (q15_t)0x3f32, (q15_t)0x90b1, + (q15_t)0x3f2d, (q15_t)0x90ae, (q15_t)0x3f27, (q15_t)0x90ab, (q15_t)0x3f22, + (q15_t)0x90a8, (q15_t)0x3f1c, (q15_t)0x90a5, (q15_t)0x3f17, (q15_t)0x90a1, + (q15_t)0x3f11, (q15_t)0x909e, (q15_t)0x3f0c, (q15_t)0x909b, (q15_t)0x3f06, + (q15_t)0x9098, (q15_t)0x3f01, (q15_t)0x9095, (q15_t)0x3efb, (q15_t)0x9092, + (q15_t)0x3ef6, (q15_t)0x908f, (q15_t)0x3ef1, (q15_t)0x908c, (q15_t)0x3eeb, + (q15_t)0x9089, (q15_t)0x3ee6, (q15_t)0x9086, (q15_t)0x3ee0, (q15_t)0x9083, + (q15_t)0x3edb, (q15_t)0x907f, (q15_t)0x3ed5, (q15_t)0x907c, (q15_t)0x3ed0, + (q15_t)0x9079, (q15_t)0x3eca, (q15_t)0x9076, (q15_t)0x3ec5, (q15_t)0x9073, + (q15_t)0x3ebf, (q15_t)0x9070, (q15_t)0x3eba, (q15_t)0x906d, (q15_t)0x3eb4, + (q15_t)0x906a, (q15_t)0x3eaf, (q15_t)0x9067, (q15_t)0x3ea9, (q15_t)0x9064, + (q15_t)0x3ea4, (q15_t)0x9061, (q15_t)0x3e9e, (q15_t)0x905e, (q15_t)0x3e99, + (q15_t)0x905b, (q15_t)0x3e93, (q15_t)0x9057, (q15_t)0x3e8e, (q15_t)0x9054, + (q15_t)0x3e88, (q15_t)0x9051, (q15_t)0x3e83, (q15_t)0x904e, (q15_t)0x3e7d, + (q15_t)0x904b, (q15_t)0x3e78, (q15_t)0x9048, (q15_t)0x3e73, (q15_t)0x9045, + (q15_t)0x3e6d, (q15_t)0x9042, (q15_t)0x3e68, (q15_t)0x903f, (q15_t)0x3e62, + (q15_t)0x903c, (q15_t)0x3e5d, (q15_t)0x9039, (q15_t)0x3e57, (q15_t)0x9036, + (q15_t)0x3e52, (q15_t)0x9033, (q15_t)0x3e4c, (q15_t)0x9030, (q15_t)0x3e47, + (q15_t)0x902d, (q15_t)0x3e41, (q15_t)0x902a, (q15_t)0x3e3c, (q15_t)0x9026, + (q15_t)0x3e36, (q15_t)0x9023, (q15_t)0x3e31, (q15_t)0x9020, (q15_t)0x3e2b, + (q15_t)0x901d, (q15_t)0x3e26, (q15_t)0x901a, (q15_t)0x3e20, (q15_t)0x9017, + (q15_t)0x3e1b, (q15_t)0x9014, (q15_t)0x3e15, (q15_t)0x9011, (q15_t)0x3e10, + (q15_t)0x900e, (q15_t)0x3e0a, (q15_t)0x900b, (q15_t)0x3e05, (q15_t)0x9008, + (q15_t)0x3dff, (q15_t)0x9005, (q15_t)0x3dfa, (q15_t)0x9002, (q15_t)0x3df4, + (q15_t)0x8fff, (q15_t)0x3def, (q15_t)0x8ffc, (q15_t)0x3de9, (q15_t)0x8ff9, + (q15_t)0x3de4, (q15_t)0x8ff6, (q15_t)0x3dde, (q15_t)0x8ff3, (q15_t)0x3dd9, + (q15_t)0x8ff0, (q15_t)0x3dd3, (q15_t)0x8fed, (q15_t)0x3dce, (q15_t)0x8fea, + (q15_t)0x3dc8, (q15_t)0x8fe7, (q15_t)0x3dc3, (q15_t)0x8fe3, (q15_t)0x3dbd, + (q15_t)0x8fe0, (q15_t)0x3db8, (q15_t)0x8fdd, (q15_t)0x3db2, (q15_t)0x8fda, + (q15_t)0x3dad, (q15_t)0x8fd7, (q15_t)0x3da7, (q15_t)0x8fd4, (q15_t)0x3da2, + (q15_t)0x8fd1, (q15_t)0x3d9c, (q15_t)0x8fce, (q15_t)0x3d97, (q15_t)0x8fcb, + (q15_t)0x3d91, (q15_t)0x8fc8, (q15_t)0x3d8c, (q15_t)0x8fc5, (q15_t)0x3d86, + (q15_t)0x8fc2, (q15_t)0x3d81, (q15_t)0x8fbf, (q15_t)0x3d7b, (q15_t)0x8fbc, + (q15_t)0x3d76, (q15_t)0x8fb9, (q15_t)0x3d70, (q15_t)0x8fb6, (q15_t)0x3d6b, + (q15_t)0x8fb3, (q15_t)0x3d65, (q15_t)0x8fb0, (q15_t)0x3d60, (q15_t)0x8fad, + (q15_t)0x3d5a, (q15_t)0x8faa, (q15_t)0x3d55, (q15_t)0x8fa7, (q15_t)0x3d4f, + (q15_t)0x8fa4, (q15_t)0x3d49, (q15_t)0x8fa1, (q15_t)0x3d44, (q15_t)0x8f9e, + (q15_t)0x3d3e, (q15_t)0x8f9b, (q15_t)0x3d39, (q15_t)0x8f98, (q15_t)0x3d33, + (q15_t)0x8f95, (q15_t)0x3d2e, (q15_t)0x8f92, (q15_t)0x3d28, (q15_t)0x8f8f, + (q15_t)0x3d23, (q15_t)0x8f8c, (q15_t)0x3d1d, (q15_t)0x8f89, (q15_t)0x3d18, + (q15_t)0x8f86, (q15_t)0x3d12, (q15_t)0x8f83, (q15_t)0x3d0d, (q15_t)0x8f80, + (q15_t)0x3d07, (q15_t)0x8f7d, (q15_t)0x3d02, (q15_t)0x8f7a, (q15_t)0x3cfc, + (q15_t)0x8f77, (q15_t)0x3cf7, (q15_t)0x8f74, (q15_t)0x3cf1, (q15_t)0x8f71, + (q15_t)0x3cec, (q15_t)0x8f6e, (q15_t)0x3ce6, (q15_t)0x8f6b, (q15_t)0x3ce1, + (q15_t)0x8f68, (q15_t)0x3cdb, (q15_t)0x8f65, (q15_t)0x3cd6, (q15_t)0x8f62, + (q15_t)0x3cd0, (q15_t)0x8f5f, (q15_t)0x3cca, (q15_t)0x8f5c, (q15_t)0x3cc5, + (q15_t)0x8f59, (q15_t)0x3cbf, (q15_t)0x8f56, (q15_t)0x3cba, (q15_t)0x8f53, + (q15_t)0x3cb4, (q15_t)0x8f50, (q15_t)0x3caf, (q15_t)0x8f4d, (q15_t)0x3ca9, + (q15_t)0x8f4a, (q15_t)0x3ca4, (q15_t)0x8f47, (q15_t)0x3c9e, (q15_t)0x8f44, + (q15_t)0x3c99, (q15_t)0x8f41, (q15_t)0x3c93, (q15_t)0x8f3e, (q15_t)0x3c8e, + (q15_t)0x8f3b, (q15_t)0x3c88, (q15_t)0x8f38, (q15_t)0x3c83, (q15_t)0x8f35, + (q15_t)0x3c7d, (q15_t)0x8f32, (q15_t)0x3c77, (q15_t)0x8f2f, (q15_t)0x3c72, + (q15_t)0x8f2d, (q15_t)0x3c6c, (q15_t)0x8f2a, (q15_t)0x3c67, (q15_t)0x8f27, + (q15_t)0x3c61, (q15_t)0x8f24, (q15_t)0x3c5c, (q15_t)0x8f21, (q15_t)0x3c56, + (q15_t)0x8f1e, (q15_t)0x3c51, (q15_t)0x8f1b, (q15_t)0x3c4b, (q15_t)0x8f18, + (q15_t)0x3c46, (q15_t)0x8f15, (q15_t)0x3c40, (q15_t)0x8f12, (q15_t)0x3c3b, + (q15_t)0x8f0f, (q15_t)0x3c35, (q15_t)0x8f0c, (q15_t)0x3c2f, (q15_t)0x8f09, + (q15_t)0x3c2a, (q15_t)0x8f06, (q15_t)0x3c24, (q15_t)0x8f03, (q15_t)0x3c1f, + (q15_t)0x8f00, (q15_t)0x3c19, (q15_t)0x8efd, (q15_t)0x3c14, (q15_t)0x8efa, + (q15_t)0x3c0e, (q15_t)0x8ef7, (q15_t)0x3c09, (q15_t)0x8ef4, (q15_t)0x3c03, + (q15_t)0x8ef1, (q15_t)0x3bfd, (q15_t)0x8eee, (q15_t)0x3bf8, (q15_t)0x8eec, + (q15_t)0x3bf2, (q15_t)0x8ee9, (q15_t)0x3bed, (q15_t)0x8ee6, (q15_t)0x3be7, + (q15_t)0x8ee3, (q15_t)0x3be2, (q15_t)0x8ee0, (q15_t)0x3bdc, (q15_t)0x8edd, + (q15_t)0x3bd7, (q15_t)0x8eda, (q15_t)0x3bd1, (q15_t)0x8ed7, (q15_t)0x3bcc, + (q15_t)0x8ed4, (q15_t)0x3bc6, (q15_t)0x8ed1, (q15_t)0x3bc0, (q15_t)0x8ece, + (q15_t)0x3bbb, (q15_t)0x8ecb, (q15_t)0x3bb5, (q15_t)0x8ec8, (q15_t)0x3bb0, + (q15_t)0x8ec5, (q15_t)0x3baa, (q15_t)0x8ec2, (q15_t)0x3ba5, (q15_t)0x8ebf, + (q15_t)0x3b9f, (q15_t)0x8ebd, (q15_t)0x3b99, (q15_t)0x8eba, (q15_t)0x3b94, + (q15_t)0x8eb7, (q15_t)0x3b8e, (q15_t)0x8eb4, (q15_t)0x3b89, (q15_t)0x8eb1, + (q15_t)0x3b83, (q15_t)0x8eae, (q15_t)0x3b7e, (q15_t)0x8eab, (q15_t)0x3b78, + (q15_t)0x8ea8, (q15_t)0x3b73, (q15_t)0x8ea5, (q15_t)0x3b6d, (q15_t)0x8ea2, + (q15_t)0x3b67, (q15_t)0x8e9f, (q15_t)0x3b62, (q15_t)0x8e9c, (q15_t)0x3b5c, + (q15_t)0x8e99, (q15_t)0x3b57, (q15_t)0x8e97, (q15_t)0x3b51, (q15_t)0x8e94, + (q15_t)0x3b4c, (q15_t)0x8e91, (q15_t)0x3b46, (q15_t)0x8e8e, (q15_t)0x3b40, + (q15_t)0x8e8b, (q15_t)0x3b3b, (q15_t)0x8e88, (q15_t)0x3b35, (q15_t)0x8e85, + (q15_t)0x3b30, (q15_t)0x8e82, (q15_t)0x3b2a, (q15_t)0x8e7f, (q15_t)0x3b25, + (q15_t)0x8e7c, (q15_t)0x3b1f, (q15_t)0x8e7a, (q15_t)0x3b19, (q15_t)0x8e77, + (q15_t)0x3b14, (q15_t)0x8e74, (q15_t)0x3b0e, (q15_t)0x8e71, (q15_t)0x3b09, + (q15_t)0x8e6e, (q15_t)0x3b03, (q15_t)0x8e6b, (q15_t)0x3afe, (q15_t)0x8e68, + (q15_t)0x3af8, (q15_t)0x8e65, (q15_t)0x3af2, (q15_t)0x8e62, (q15_t)0x3aed, + (q15_t)0x8e5f, (q15_t)0x3ae7, (q15_t)0x8e5d, (q15_t)0x3ae2, (q15_t)0x8e5a, + (q15_t)0x3adc, (q15_t)0x8e57, (q15_t)0x3ad7, (q15_t)0x8e54, (q15_t)0x3ad1, + (q15_t)0x8e51, (q15_t)0x3acb, (q15_t)0x8e4e, (q15_t)0x3ac6, (q15_t)0x8e4b, + (q15_t)0x3ac0, (q15_t)0x8e48, (q15_t)0x3abb, (q15_t)0x8e45, (q15_t)0x3ab5, + (q15_t)0x8e43, (q15_t)0x3aaf, (q15_t)0x8e40, (q15_t)0x3aaa, (q15_t)0x8e3d, + (q15_t)0x3aa4, (q15_t)0x8e3a, (q15_t)0x3a9f, (q15_t)0x8e37, (q15_t)0x3a99, + (q15_t)0x8e34, (q15_t)0x3a94, (q15_t)0x8e31, (q15_t)0x3a8e, (q15_t)0x8e2e, + (q15_t)0x3a88, (q15_t)0x8e2c, (q15_t)0x3a83, (q15_t)0x8e29, (q15_t)0x3a7d, + (q15_t)0x8e26, (q15_t)0x3a78, (q15_t)0x8e23, (q15_t)0x3a72, (q15_t)0x8e20, + (q15_t)0x3a6c, (q15_t)0x8e1d, (q15_t)0x3a67, (q15_t)0x8e1a, (q15_t)0x3a61, + (q15_t)0x8e17, (q15_t)0x3a5c, (q15_t)0x8e15, (q15_t)0x3a56, (q15_t)0x8e12, + (q15_t)0x3a50, (q15_t)0x8e0f, (q15_t)0x3a4b, (q15_t)0x8e0c, (q15_t)0x3a45, + (q15_t)0x8e09, (q15_t)0x3a40, (q15_t)0x8e06, (q15_t)0x3a3a, (q15_t)0x8e03, + (q15_t)0x3a34, (q15_t)0x8e01, (q15_t)0x3a2f, (q15_t)0x8dfe, (q15_t)0x3a29, + (q15_t)0x8dfb, (q15_t)0x3a24, (q15_t)0x8df8, (q15_t)0x3a1e, (q15_t)0x8df5, + (q15_t)0x3a19, (q15_t)0x8df2, (q15_t)0x3a13, (q15_t)0x8def, (q15_t)0x3a0d, + (q15_t)0x8ded, (q15_t)0x3a08, (q15_t)0x8dea, (q15_t)0x3a02, (q15_t)0x8de7, + (q15_t)0x39fd, (q15_t)0x8de4, (q15_t)0x39f7, (q15_t)0x8de1, (q15_t)0x39f1, + (q15_t)0x8dde, (q15_t)0x39ec, (q15_t)0x8ddc, (q15_t)0x39e6, (q15_t)0x8dd9, + (q15_t)0x39e0, (q15_t)0x8dd6, (q15_t)0x39db, (q15_t)0x8dd3, (q15_t)0x39d5, + (q15_t)0x8dd0, (q15_t)0x39d0, (q15_t)0x8dcd, (q15_t)0x39ca, (q15_t)0x8dca, + (q15_t)0x39c4, (q15_t)0x8dc8, (q15_t)0x39bf, (q15_t)0x8dc5, (q15_t)0x39b9, + (q15_t)0x8dc2, (q15_t)0x39b4, (q15_t)0x8dbf, (q15_t)0x39ae, (q15_t)0x8dbc, + (q15_t)0x39a8, (q15_t)0x8db9, (q15_t)0x39a3, (q15_t)0x8db7, (q15_t)0x399d, + (q15_t)0x8db4, (q15_t)0x3998, (q15_t)0x8db1, (q15_t)0x3992, (q15_t)0x8dae, + (q15_t)0x398c, (q15_t)0x8dab, (q15_t)0x3987, (q15_t)0x8da9, (q15_t)0x3981, + (q15_t)0x8da6, (q15_t)0x397c, (q15_t)0x8da3, (q15_t)0x3976, (q15_t)0x8da0, + (q15_t)0x3970, (q15_t)0x8d9d, (q15_t)0x396b, (q15_t)0x8d9a, (q15_t)0x3965, + (q15_t)0x8d98, (q15_t)0x395f, (q15_t)0x8d95, (q15_t)0x395a, (q15_t)0x8d92, + (q15_t)0x3954, (q15_t)0x8d8f, (q15_t)0x394f, (q15_t)0x8d8c, (q15_t)0x3949, + (q15_t)0x8d8a, (q15_t)0x3943, (q15_t)0x8d87, (q15_t)0x393e, (q15_t)0x8d84, + (q15_t)0x3938, (q15_t)0x8d81, (q15_t)0x3932, (q15_t)0x8d7e, (q15_t)0x392d, + (q15_t)0x8d7b, (q15_t)0x3927, (q15_t)0x8d79, (q15_t)0x3922, (q15_t)0x8d76, + (q15_t)0x391c, (q15_t)0x8d73, (q15_t)0x3916, (q15_t)0x8d70, (q15_t)0x3911, + (q15_t)0x8d6d, (q15_t)0x390b, (q15_t)0x8d6b, (q15_t)0x3906, (q15_t)0x8d68, + (q15_t)0x3900, (q15_t)0x8d65, (q15_t)0x38fa, (q15_t)0x8d62, (q15_t)0x38f5, + (q15_t)0x8d5f, (q15_t)0x38ef, (q15_t)0x8d5d, (q15_t)0x38e9, (q15_t)0x8d5a, + (q15_t)0x38e4, (q15_t)0x8d57, (q15_t)0x38de, (q15_t)0x8d54, (q15_t)0x38d8, + (q15_t)0x8d51, (q15_t)0x38d3, (q15_t)0x8d4f, (q15_t)0x38cd, (q15_t)0x8d4c, + (q15_t)0x38c8, (q15_t)0x8d49, (q15_t)0x38c2, (q15_t)0x8d46, (q15_t)0x38bc, + (q15_t)0x8d44, (q15_t)0x38b7, (q15_t)0x8d41, (q15_t)0x38b1, (q15_t)0x8d3e, + (q15_t)0x38ab, (q15_t)0x8d3b, (q15_t)0x38a6, (q15_t)0x8d38, (q15_t)0x38a0, + (q15_t)0x8d36, (q15_t)0x389b, (q15_t)0x8d33, (q15_t)0x3895, (q15_t)0x8d30, + (q15_t)0x388f, (q15_t)0x8d2d, (q15_t)0x388a, (q15_t)0x8d2b, (q15_t)0x3884, + (q15_t)0x8d28, (q15_t)0x387e, (q15_t)0x8d25, (q15_t)0x3879, (q15_t)0x8d22, + (q15_t)0x3873, (q15_t)0x8d1f, (q15_t)0x386d, (q15_t)0x8d1d, (q15_t)0x3868, + (q15_t)0x8d1a, (q15_t)0x3862, (q15_t)0x8d17, (q15_t)0x385d, (q15_t)0x8d14, + (q15_t)0x3857, (q15_t)0x8d12, (q15_t)0x3851, (q15_t)0x8d0f, (q15_t)0x384c, + (q15_t)0x8d0c, (q15_t)0x3846, (q15_t)0x8d09, (q15_t)0x3840, (q15_t)0x8d07, + (q15_t)0x383b, (q15_t)0x8d04, (q15_t)0x3835, (q15_t)0x8d01, (q15_t)0x382f, + (q15_t)0x8cfe, (q15_t)0x382a, (q15_t)0x8cfb, (q15_t)0x3824, (q15_t)0x8cf9, + (q15_t)0x381e, (q15_t)0x8cf6, (q15_t)0x3819, (q15_t)0x8cf3, (q15_t)0x3813, + (q15_t)0x8cf0, (q15_t)0x380d, (q15_t)0x8cee, (q15_t)0x3808, (q15_t)0x8ceb, + (q15_t)0x3802, (q15_t)0x8ce8, (q15_t)0x37fd, (q15_t)0x8ce5, (q15_t)0x37f7, + (q15_t)0x8ce3, (q15_t)0x37f1, (q15_t)0x8ce0, (q15_t)0x37ec, (q15_t)0x8cdd, + (q15_t)0x37e6, (q15_t)0x8cda, (q15_t)0x37e0, (q15_t)0x8cd8, (q15_t)0x37db, + (q15_t)0x8cd5, (q15_t)0x37d5, (q15_t)0x8cd2, (q15_t)0x37cf, (q15_t)0x8cd0, + (q15_t)0x37ca, (q15_t)0x8ccd, (q15_t)0x37c4, (q15_t)0x8cca, (q15_t)0x37be, + (q15_t)0x8cc7, (q15_t)0x37b9, (q15_t)0x8cc5, (q15_t)0x37b3, (q15_t)0x8cc2, + (q15_t)0x37ad, (q15_t)0x8cbf, (q15_t)0x37a8, (q15_t)0x8cbc, (q15_t)0x37a2, + (q15_t)0x8cba, (q15_t)0x379c, (q15_t)0x8cb7, (q15_t)0x3797, (q15_t)0x8cb4, + (q15_t)0x3791, (q15_t)0x8cb1, (q15_t)0x378b, (q15_t)0x8caf, (q15_t)0x3786, + (q15_t)0x8cac, (q15_t)0x3780, (q15_t)0x8ca9, (q15_t)0x377a, (q15_t)0x8ca7, + (q15_t)0x3775, (q15_t)0x8ca4, (q15_t)0x376f, (q15_t)0x8ca1, (q15_t)0x3769, + (q15_t)0x8c9e, (q15_t)0x3764, (q15_t)0x8c9c, (q15_t)0x375e, (q15_t)0x8c99, + (q15_t)0x3758, (q15_t)0x8c96, (q15_t)0x3753, (q15_t)0x8c94, (q15_t)0x374d, + (q15_t)0x8c91, (q15_t)0x3747, (q15_t)0x8c8e, (q15_t)0x3742, (q15_t)0x8c8b, + (q15_t)0x373c, (q15_t)0x8c89, (q15_t)0x3736, (q15_t)0x8c86, (q15_t)0x3731, + (q15_t)0x8c83, (q15_t)0x372b, (q15_t)0x8c81, (q15_t)0x3725, (q15_t)0x8c7e, + (q15_t)0x3720, (q15_t)0x8c7b, (q15_t)0x371a, (q15_t)0x8c78, (q15_t)0x3714, + (q15_t)0x8c76, (q15_t)0x370f, (q15_t)0x8c73, (q15_t)0x3709, (q15_t)0x8c70, + (q15_t)0x3703, (q15_t)0x8c6e, (q15_t)0x36fe, (q15_t)0x8c6b, (q15_t)0x36f8, + (q15_t)0x8c68, (q15_t)0x36f2, (q15_t)0x8c65, (q15_t)0x36ed, (q15_t)0x8c63, + (q15_t)0x36e7, (q15_t)0x8c60, (q15_t)0x36e1, (q15_t)0x8c5d, (q15_t)0x36dc, + (q15_t)0x8c5b, (q15_t)0x36d6, (q15_t)0x8c58, (q15_t)0x36d0, (q15_t)0x8c55, + (q15_t)0x36cb, (q15_t)0x8c53, (q15_t)0x36c5, (q15_t)0x8c50, (q15_t)0x36bf, + (q15_t)0x8c4d, (q15_t)0x36ba, (q15_t)0x8c4b, (q15_t)0x36b4, (q15_t)0x8c48, + (q15_t)0x36ae, (q15_t)0x8c45, (q15_t)0x36a9, (q15_t)0x8c43, (q15_t)0x36a3, + (q15_t)0x8c40, (q15_t)0x369d, (q15_t)0x8c3d, (q15_t)0x3698, (q15_t)0x8c3a, + (q15_t)0x3692, (q15_t)0x8c38, (q15_t)0x368c, (q15_t)0x8c35, (q15_t)0x3686, + (q15_t)0x8c32, (q15_t)0x3681, (q15_t)0x8c30, (q15_t)0x367b, (q15_t)0x8c2d, + (q15_t)0x3675, (q15_t)0x8c2a, (q15_t)0x3670, (q15_t)0x8c28, (q15_t)0x366a, + (q15_t)0x8c25, (q15_t)0x3664, (q15_t)0x8c22, (q15_t)0x365f, (q15_t)0x8c20, + (q15_t)0x3659, (q15_t)0x8c1d, (q15_t)0x3653, (q15_t)0x8c1a, (q15_t)0x364e, + (q15_t)0x8c18, (q15_t)0x3648, (q15_t)0x8c15, (q15_t)0x3642, (q15_t)0x8c12, + (q15_t)0x363d, (q15_t)0x8c10, (q15_t)0x3637, (q15_t)0x8c0d, (q15_t)0x3631, + (q15_t)0x8c0a, (q15_t)0x362b, (q15_t)0x8c08, (q15_t)0x3626, (q15_t)0x8c05, + (q15_t)0x3620, (q15_t)0x8c02, (q15_t)0x361a, (q15_t)0x8c00, (q15_t)0x3615, + (q15_t)0x8bfd, (q15_t)0x360f, (q15_t)0x8bfa, (q15_t)0x3609, (q15_t)0x8bf8, + (q15_t)0x3604, (q15_t)0x8bf5, (q15_t)0x35fe, (q15_t)0x8bf3, (q15_t)0x35f8, + (q15_t)0x8bf0, (q15_t)0x35f3, (q15_t)0x8bed, (q15_t)0x35ed, (q15_t)0x8beb, + (q15_t)0x35e7, (q15_t)0x8be8, (q15_t)0x35e1, (q15_t)0x8be5, (q15_t)0x35dc, + (q15_t)0x8be3, (q15_t)0x35d6, (q15_t)0x8be0, (q15_t)0x35d0, (q15_t)0x8bdd, + (q15_t)0x35cb, (q15_t)0x8bdb, (q15_t)0x35c5, (q15_t)0x8bd8, (q15_t)0x35bf, + (q15_t)0x8bd5, (q15_t)0x35ba, (q15_t)0x8bd3, (q15_t)0x35b4, (q15_t)0x8bd0, + (q15_t)0x35ae, (q15_t)0x8bce, (q15_t)0x35a8, (q15_t)0x8bcb, (q15_t)0x35a3, + (q15_t)0x8bc8, (q15_t)0x359d, (q15_t)0x8bc6, (q15_t)0x3597, (q15_t)0x8bc3, + (q15_t)0x3592, (q15_t)0x8bc0, (q15_t)0x358c, (q15_t)0x8bbe, (q15_t)0x3586, + (q15_t)0x8bbb, (q15_t)0x3580, (q15_t)0x8bb8, (q15_t)0x357b, (q15_t)0x8bb6, + (q15_t)0x3575, (q15_t)0x8bb3, (q15_t)0x356f, (q15_t)0x8bb1, (q15_t)0x356a, + (q15_t)0x8bae, (q15_t)0x3564, (q15_t)0x8bab, (q15_t)0x355e, (q15_t)0x8ba9, + (q15_t)0x3558, (q15_t)0x8ba6, (q15_t)0x3553, (q15_t)0x8ba4, (q15_t)0x354d, + (q15_t)0x8ba1, (q15_t)0x3547, (q15_t)0x8b9e, (q15_t)0x3542, (q15_t)0x8b9c, + (q15_t)0x353c, (q15_t)0x8b99, (q15_t)0x3536, (q15_t)0x8b96, (q15_t)0x3530, + (q15_t)0x8b94, (q15_t)0x352b, (q15_t)0x8b91, (q15_t)0x3525, (q15_t)0x8b8f, + (q15_t)0x351f, (q15_t)0x8b8c, (q15_t)0x351a, (q15_t)0x8b89, (q15_t)0x3514, + (q15_t)0x8b87, (q15_t)0x350e, (q15_t)0x8b84, (q15_t)0x3508, (q15_t)0x8b82, + (q15_t)0x3503, (q15_t)0x8b7f, (q15_t)0x34fd, (q15_t)0x8b7c, (q15_t)0x34f7, + (q15_t)0x8b7a, (q15_t)0x34f2, (q15_t)0x8b77, (q15_t)0x34ec, (q15_t)0x8b75, + (q15_t)0x34e6, (q15_t)0x8b72, (q15_t)0x34e0, (q15_t)0x8b6f, (q15_t)0x34db, + (q15_t)0x8b6d, (q15_t)0x34d5, (q15_t)0x8b6a, (q15_t)0x34cf, (q15_t)0x8b68, + (q15_t)0x34ca, (q15_t)0x8b65, (q15_t)0x34c4, (q15_t)0x8b62, (q15_t)0x34be, + (q15_t)0x8b60, (q15_t)0x34b8, (q15_t)0x8b5d, (q15_t)0x34b3, (q15_t)0x8b5b, + (q15_t)0x34ad, (q15_t)0x8b58, (q15_t)0x34a7, (q15_t)0x8b55, (q15_t)0x34a1, + (q15_t)0x8b53, (q15_t)0x349c, (q15_t)0x8b50, (q15_t)0x3496, (q15_t)0x8b4e, + (q15_t)0x3490, (q15_t)0x8b4b, (q15_t)0x348b, (q15_t)0x8b49, (q15_t)0x3485, + (q15_t)0x8b46, (q15_t)0x347f, (q15_t)0x8b43, (q15_t)0x3479, (q15_t)0x8b41, + (q15_t)0x3474, (q15_t)0x8b3e, (q15_t)0x346e, (q15_t)0x8b3c, (q15_t)0x3468, + (q15_t)0x8b39, (q15_t)0x3462, (q15_t)0x8b37, (q15_t)0x345d, (q15_t)0x8b34, + (q15_t)0x3457, (q15_t)0x8b31, (q15_t)0x3451, (q15_t)0x8b2f, (q15_t)0x344b, + (q15_t)0x8b2c, (q15_t)0x3446, (q15_t)0x8b2a, (q15_t)0x3440, (q15_t)0x8b27, + (q15_t)0x343a, (q15_t)0x8b25, (q15_t)0x3435, (q15_t)0x8b22, (q15_t)0x342f, + (q15_t)0x8b1f, (q15_t)0x3429, (q15_t)0x8b1d, (q15_t)0x3423, (q15_t)0x8b1a, + (q15_t)0x341e, (q15_t)0x8b18, (q15_t)0x3418, (q15_t)0x8b15, (q15_t)0x3412, + (q15_t)0x8b13, (q15_t)0x340c, (q15_t)0x8b10, (q15_t)0x3407, (q15_t)0x8b0e, + (q15_t)0x3401, (q15_t)0x8b0b, (q15_t)0x33fb, (q15_t)0x8b08, (q15_t)0x33f5, + (q15_t)0x8b06, (q15_t)0x33f0, (q15_t)0x8b03, (q15_t)0x33ea, (q15_t)0x8b01, + (q15_t)0x33e4, (q15_t)0x8afe, (q15_t)0x33de, (q15_t)0x8afc, (q15_t)0x33d9, + (q15_t)0x8af9, (q15_t)0x33d3, (q15_t)0x8af7, (q15_t)0x33cd, (q15_t)0x8af4, + (q15_t)0x33c7, (q15_t)0x8af1, (q15_t)0x33c2, (q15_t)0x8aef, (q15_t)0x33bc, + (q15_t)0x8aec, (q15_t)0x33b6, (q15_t)0x8aea, (q15_t)0x33b0, (q15_t)0x8ae7, + (q15_t)0x33ab, (q15_t)0x8ae5, (q15_t)0x33a5, (q15_t)0x8ae2, (q15_t)0x339f, + (q15_t)0x8ae0, (q15_t)0x3399, (q15_t)0x8add, (q15_t)0x3394, (q15_t)0x8adb, + (q15_t)0x338e, (q15_t)0x8ad8, (q15_t)0x3388, (q15_t)0x8ad6, (q15_t)0x3382, + (q15_t)0x8ad3, (q15_t)0x337d, (q15_t)0x8ad1, (q15_t)0x3377, (q15_t)0x8ace, + (q15_t)0x3371, (q15_t)0x8acb, (q15_t)0x336b, (q15_t)0x8ac9, (q15_t)0x3366, + (q15_t)0x8ac6, (q15_t)0x3360, (q15_t)0x8ac4, (q15_t)0x335a, (q15_t)0x8ac1, + (q15_t)0x3354, (q15_t)0x8abf, (q15_t)0x334f, (q15_t)0x8abc, (q15_t)0x3349, + (q15_t)0x8aba, (q15_t)0x3343, (q15_t)0x8ab7, (q15_t)0x333d, (q15_t)0x8ab5, + (q15_t)0x3338, (q15_t)0x8ab2, (q15_t)0x3332, (q15_t)0x8ab0, (q15_t)0x332c, + (q15_t)0x8aad, (q15_t)0x3326, (q15_t)0x8aab, (q15_t)0x3321, (q15_t)0x8aa8, + (q15_t)0x331b, (q15_t)0x8aa6, (q15_t)0x3315, (q15_t)0x8aa3, (q15_t)0x330f, + (q15_t)0x8aa1, (q15_t)0x330a, (q15_t)0x8a9e, (q15_t)0x3304, (q15_t)0x8a9c, + (q15_t)0x32fe, (q15_t)0x8a99, (q15_t)0x32f8, (q15_t)0x8a97, (q15_t)0x32f3, + (q15_t)0x8a94, (q15_t)0x32ed, (q15_t)0x8a92, (q15_t)0x32e7, (q15_t)0x8a8f, + (q15_t)0x32e1, (q15_t)0x8a8d, (q15_t)0x32db, (q15_t)0x8a8a, (q15_t)0x32d6, + (q15_t)0x8a88, (q15_t)0x32d0, (q15_t)0x8a85, (q15_t)0x32ca, (q15_t)0x8a83, + (q15_t)0x32c4, (q15_t)0x8a80, (q15_t)0x32bf, (q15_t)0x8a7e, (q15_t)0x32b9, + (q15_t)0x8a7b, (q15_t)0x32b3, (q15_t)0x8a79, (q15_t)0x32ad, (q15_t)0x8a76, + (q15_t)0x32a8, (q15_t)0x8a74, (q15_t)0x32a2, (q15_t)0x8a71, (q15_t)0x329c, + (q15_t)0x8a6f, (q15_t)0x3296, (q15_t)0x8a6c, (q15_t)0x3290, (q15_t)0x8a6a, + (q15_t)0x328b, (q15_t)0x8a67, (q15_t)0x3285, (q15_t)0x8a65, (q15_t)0x327f, + (q15_t)0x8a62, (q15_t)0x3279, (q15_t)0x8a60, (q15_t)0x3274, (q15_t)0x8a5d, + (q15_t)0x326e, (q15_t)0x8a5b, (q15_t)0x3268, (q15_t)0x8a59, (q15_t)0x3262, + (q15_t)0x8a56, (q15_t)0x325d, (q15_t)0x8a54, (q15_t)0x3257, (q15_t)0x8a51, + (q15_t)0x3251, (q15_t)0x8a4f, (q15_t)0x324b, (q15_t)0x8a4c, (q15_t)0x3245, + (q15_t)0x8a4a, (q15_t)0x3240, (q15_t)0x8a47, (q15_t)0x323a, (q15_t)0x8a45, + (q15_t)0x3234, (q15_t)0x8a42, (q15_t)0x322e, (q15_t)0x8a40, (q15_t)0x3228, + (q15_t)0x8a3d, (q15_t)0x3223, (q15_t)0x8a3b, (q15_t)0x321d, (q15_t)0x8a38, + (q15_t)0x3217, (q15_t)0x8a36, (q15_t)0x3211, (q15_t)0x8a34, (q15_t)0x320c, + (q15_t)0x8a31, (q15_t)0x3206, (q15_t)0x8a2f, (q15_t)0x3200, (q15_t)0x8a2c, + (q15_t)0x31fa, (q15_t)0x8a2a, (q15_t)0x31f4, (q15_t)0x8a27, (q15_t)0x31ef, + (q15_t)0x8a25, (q15_t)0x31e9, (q15_t)0x8a22, (q15_t)0x31e3, (q15_t)0x8a20, + (q15_t)0x31dd, (q15_t)0x8a1d, (q15_t)0x31d8, (q15_t)0x8a1b, (q15_t)0x31d2, + (q15_t)0x8a19, (q15_t)0x31cc, (q15_t)0x8a16, (q15_t)0x31c6, (q15_t)0x8a14, + (q15_t)0x31c0, (q15_t)0x8a11, (q15_t)0x31bb, (q15_t)0x8a0f, (q15_t)0x31b5, + (q15_t)0x8a0c, (q15_t)0x31af, (q15_t)0x8a0a, (q15_t)0x31a9, (q15_t)0x8a07, + (q15_t)0x31a3, (q15_t)0x8a05, (q15_t)0x319e, (q15_t)0x8a03, (q15_t)0x3198, + (q15_t)0x8a00, (q15_t)0x3192, (q15_t)0x89fe, (q15_t)0x318c, (q15_t)0x89fb, + (q15_t)0x3186, (q15_t)0x89f9, (q15_t)0x3181, (q15_t)0x89f6, (q15_t)0x317b, + (q15_t)0x89f4, (q15_t)0x3175, (q15_t)0x89f2, (q15_t)0x316f, (q15_t)0x89ef, + (q15_t)0x3169, (q15_t)0x89ed, (q15_t)0x3164, (q15_t)0x89ea, (q15_t)0x315e, + (q15_t)0x89e8, (q15_t)0x3158, (q15_t)0x89e5, (q15_t)0x3152, (q15_t)0x89e3, + (q15_t)0x314c, (q15_t)0x89e1, (q15_t)0x3147, (q15_t)0x89de, (q15_t)0x3141, + (q15_t)0x89dc, (q15_t)0x313b, (q15_t)0x89d9, (q15_t)0x3135, (q15_t)0x89d7, + (q15_t)0x312f, (q15_t)0x89d5, (q15_t)0x312a, (q15_t)0x89d2, (q15_t)0x3124, + (q15_t)0x89d0, (q15_t)0x311e, (q15_t)0x89cd, (q15_t)0x3118, (q15_t)0x89cb, + (q15_t)0x3112, (q15_t)0x89c8, (q15_t)0x310d, (q15_t)0x89c6, (q15_t)0x3107, + (q15_t)0x89c4, (q15_t)0x3101, (q15_t)0x89c1, (q15_t)0x30fb, (q15_t)0x89bf, + (q15_t)0x30f5, (q15_t)0x89bc, (q15_t)0x30f0, (q15_t)0x89ba, (q15_t)0x30ea, + (q15_t)0x89b8, (q15_t)0x30e4, (q15_t)0x89b5, (q15_t)0x30de, (q15_t)0x89b3, + (q15_t)0x30d8, (q15_t)0x89b0, (q15_t)0x30d3, (q15_t)0x89ae, (q15_t)0x30cd, + (q15_t)0x89ac, (q15_t)0x30c7, (q15_t)0x89a9, (q15_t)0x30c1, (q15_t)0x89a7, + (q15_t)0x30bb, (q15_t)0x89a4, (q15_t)0x30b6, (q15_t)0x89a2, (q15_t)0x30b0, + (q15_t)0x89a0, (q15_t)0x30aa, (q15_t)0x899d, (q15_t)0x30a4, (q15_t)0x899b, + (q15_t)0x309e, (q15_t)0x8998, (q15_t)0x3099, (q15_t)0x8996, (q15_t)0x3093, + (q15_t)0x8994, (q15_t)0x308d, (q15_t)0x8991, (q15_t)0x3087, (q15_t)0x898f, + (q15_t)0x3081, (q15_t)0x898d, (q15_t)0x307b, (q15_t)0x898a, (q15_t)0x3076, + (q15_t)0x8988, (q15_t)0x3070, (q15_t)0x8985, (q15_t)0x306a, (q15_t)0x8983, + (q15_t)0x3064, (q15_t)0x8981, (q15_t)0x305e, (q15_t)0x897e, (q15_t)0x3059, + (q15_t)0x897c, (q15_t)0x3053, (q15_t)0x897a, (q15_t)0x304d, (q15_t)0x8977, + (q15_t)0x3047, (q15_t)0x8975, (q15_t)0x3041, (q15_t)0x8972, (q15_t)0x303b, + (q15_t)0x8970, (q15_t)0x3036, (q15_t)0x896e, (q15_t)0x3030, (q15_t)0x896b, + (q15_t)0x302a, (q15_t)0x8969, (q15_t)0x3024, (q15_t)0x8967, (q15_t)0x301e, + (q15_t)0x8964, (q15_t)0x3019, (q15_t)0x8962, (q15_t)0x3013, (q15_t)0x8960, + (q15_t)0x300d, (q15_t)0x895d, (q15_t)0x3007, (q15_t)0x895b, (q15_t)0x3001, + (q15_t)0x8958, (q15_t)0x2ffb, (q15_t)0x8956, (q15_t)0x2ff6, (q15_t)0x8954, + (q15_t)0x2ff0, (q15_t)0x8951, (q15_t)0x2fea, (q15_t)0x894f, (q15_t)0x2fe4, + (q15_t)0x894d, (q15_t)0x2fde, (q15_t)0x894a, (q15_t)0x2fd8, (q15_t)0x8948, + (q15_t)0x2fd3, (q15_t)0x8946, (q15_t)0x2fcd, (q15_t)0x8943, (q15_t)0x2fc7, + (q15_t)0x8941, (q15_t)0x2fc1, (q15_t)0x893f, (q15_t)0x2fbb, (q15_t)0x893c, + (q15_t)0x2fb5, (q15_t)0x893a, (q15_t)0x2fb0, (q15_t)0x8938, (q15_t)0x2faa, + (q15_t)0x8935, (q15_t)0x2fa4, (q15_t)0x8933, (q15_t)0x2f9e, (q15_t)0x8931, + (q15_t)0x2f98, (q15_t)0x892e, (q15_t)0x2f92, (q15_t)0x892c, (q15_t)0x2f8d, + (q15_t)0x892a, (q15_t)0x2f87, (q15_t)0x8927, (q15_t)0x2f81, (q15_t)0x8925, + (q15_t)0x2f7b, (q15_t)0x8923, (q15_t)0x2f75, (q15_t)0x8920, (q15_t)0x2f6f, + (q15_t)0x891e, (q15_t)0x2f6a, (q15_t)0x891c, (q15_t)0x2f64, (q15_t)0x8919, + (q15_t)0x2f5e, (q15_t)0x8917, (q15_t)0x2f58, (q15_t)0x8915, (q15_t)0x2f52, + (q15_t)0x8912, (q15_t)0x2f4c, (q15_t)0x8910, (q15_t)0x2f47, (q15_t)0x890e, + (q15_t)0x2f41, (q15_t)0x890b, (q15_t)0x2f3b, (q15_t)0x8909, (q15_t)0x2f35, + (q15_t)0x8907, (q15_t)0x2f2f, (q15_t)0x8904, (q15_t)0x2f29, (q15_t)0x8902, + (q15_t)0x2f24, (q15_t)0x8900, (q15_t)0x2f1e, (q15_t)0x88fd, (q15_t)0x2f18, + (q15_t)0x88fb, (q15_t)0x2f12, (q15_t)0x88f9, (q15_t)0x2f0c, (q15_t)0x88f6, + (q15_t)0x2f06, (q15_t)0x88f4, (q15_t)0x2f01, (q15_t)0x88f2, (q15_t)0x2efb, + (q15_t)0x88f0, (q15_t)0x2ef5, (q15_t)0x88ed, (q15_t)0x2eef, (q15_t)0x88eb, + (q15_t)0x2ee9, (q15_t)0x88e9, (q15_t)0x2ee3, (q15_t)0x88e6, (q15_t)0x2edd, + (q15_t)0x88e4, (q15_t)0x2ed8, (q15_t)0x88e2, (q15_t)0x2ed2, (q15_t)0x88df, + (q15_t)0x2ecc, (q15_t)0x88dd, (q15_t)0x2ec6, (q15_t)0x88db, (q15_t)0x2ec0, + (q15_t)0x88d9, (q15_t)0x2eba, (q15_t)0x88d6, (q15_t)0x2eb5, (q15_t)0x88d4, + (q15_t)0x2eaf, (q15_t)0x88d2, (q15_t)0x2ea9, (q15_t)0x88cf, (q15_t)0x2ea3, + (q15_t)0x88cd, (q15_t)0x2e9d, (q15_t)0x88cb, (q15_t)0x2e97, (q15_t)0x88c8, + (q15_t)0x2e91, (q15_t)0x88c6, (q15_t)0x2e8c, (q15_t)0x88c4, (q15_t)0x2e86, + (q15_t)0x88c2, (q15_t)0x2e80, (q15_t)0x88bf, (q15_t)0x2e7a, (q15_t)0x88bd, + (q15_t)0x2e74, (q15_t)0x88bb, (q15_t)0x2e6e, (q15_t)0x88b9, (q15_t)0x2e68, + (q15_t)0x88b6, (q15_t)0x2e63, (q15_t)0x88b4, (q15_t)0x2e5d, (q15_t)0x88b2, + (q15_t)0x2e57, (q15_t)0x88af, (q15_t)0x2e51, (q15_t)0x88ad, (q15_t)0x2e4b, + (q15_t)0x88ab, (q15_t)0x2e45, (q15_t)0x88a9, (q15_t)0x2e3f, (q15_t)0x88a6, + (q15_t)0x2e3a, (q15_t)0x88a4, (q15_t)0x2e34, (q15_t)0x88a2, (q15_t)0x2e2e, + (q15_t)0x88a0, (q15_t)0x2e28, (q15_t)0x889d, (q15_t)0x2e22, (q15_t)0x889b, + (q15_t)0x2e1c, (q15_t)0x8899, (q15_t)0x2e16, (q15_t)0x8896, (q15_t)0x2e11, + (q15_t)0x8894, (q15_t)0x2e0b, (q15_t)0x8892, (q15_t)0x2e05, (q15_t)0x8890, + (q15_t)0x2dff, (q15_t)0x888d, (q15_t)0x2df9, (q15_t)0x888b, (q15_t)0x2df3, + (q15_t)0x8889, (q15_t)0x2ded, (q15_t)0x8887, (q15_t)0x2de7, (q15_t)0x8884, + (q15_t)0x2de2, (q15_t)0x8882, (q15_t)0x2ddc, (q15_t)0x8880, (q15_t)0x2dd6, + (q15_t)0x887e, (q15_t)0x2dd0, (q15_t)0x887b, (q15_t)0x2dca, (q15_t)0x8879, + (q15_t)0x2dc4, (q15_t)0x8877, (q15_t)0x2dbe, (q15_t)0x8875, (q15_t)0x2db9, + (q15_t)0x8872, (q15_t)0x2db3, (q15_t)0x8870, (q15_t)0x2dad, (q15_t)0x886e, + (q15_t)0x2da7, (q15_t)0x886c, (q15_t)0x2da1, (q15_t)0x8869, (q15_t)0x2d9b, + (q15_t)0x8867, (q15_t)0x2d95, (q15_t)0x8865, (q15_t)0x2d8f, (q15_t)0x8863, + (q15_t)0x2d8a, (q15_t)0x8860, (q15_t)0x2d84, (q15_t)0x885e, (q15_t)0x2d7e, + (q15_t)0x885c, (q15_t)0x2d78, (q15_t)0x885a, (q15_t)0x2d72, (q15_t)0x8858, + (q15_t)0x2d6c, (q15_t)0x8855, (q15_t)0x2d66, (q15_t)0x8853, (q15_t)0x2d60, + (q15_t)0x8851, (q15_t)0x2d5b, (q15_t)0x884f, (q15_t)0x2d55, (q15_t)0x884c, + (q15_t)0x2d4f, (q15_t)0x884a, (q15_t)0x2d49, (q15_t)0x8848, (q15_t)0x2d43, + (q15_t)0x8846, (q15_t)0x2d3d, (q15_t)0x8844, (q15_t)0x2d37, (q15_t)0x8841, + (q15_t)0x2d31, (q15_t)0x883f, (q15_t)0x2d2c, (q15_t)0x883d, (q15_t)0x2d26, + (q15_t)0x883b, (q15_t)0x2d20, (q15_t)0x8838, (q15_t)0x2d1a, (q15_t)0x8836, + (q15_t)0x2d14, (q15_t)0x8834, (q15_t)0x2d0e, (q15_t)0x8832, (q15_t)0x2d08, + (q15_t)0x8830, (q15_t)0x2d02, (q15_t)0x882d, (q15_t)0x2cfd, (q15_t)0x882b, + (q15_t)0x2cf7, (q15_t)0x8829, (q15_t)0x2cf1, (q15_t)0x8827, (q15_t)0x2ceb, + (q15_t)0x8825, (q15_t)0x2ce5, (q15_t)0x8822, (q15_t)0x2cdf, (q15_t)0x8820, + (q15_t)0x2cd9, (q15_t)0x881e, (q15_t)0x2cd3, (q15_t)0x881c, (q15_t)0x2ccd, + (q15_t)0x881a, (q15_t)0x2cc8, (q15_t)0x8817, (q15_t)0x2cc2, (q15_t)0x8815, + (q15_t)0x2cbc, (q15_t)0x8813, (q15_t)0x2cb6, (q15_t)0x8811, (q15_t)0x2cb0, + (q15_t)0x880f, (q15_t)0x2caa, (q15_t)0x880c, (q15_t)0x2ca4, (q15_t)0x880a, + (q15_t)0x2c9e, (q15_t)0x8808, (q15_t)0x2c98, (q15_t)0x8806, (q15_t)0x2c93, + (q15_t)0x8804, (q15_t)0x2c8d, (q15_t)0x8801, (q15_t)0x2c87, (q15_t)0x87ff, + (q15_t)0x2c81, (q15_t)0x87fd, (q15_t)0x2c7b, (q15_t)0x87fb, (q15_t)0x2c75, + (q15_t)0x87f9, (q15_t)0x2c6f, (q15_t)0x87f6, (q15_t)0x2c69, (q15_t)0x87f4, + (q15_t)0x2c63, (q15_t)0x87f2, (q15_t)0x2c5e, (q15_t)0x87f0, (q15_t)0x2c58, + (q15_t)0x87ee, (q15_t)0x2c52, (q15_t)0x87ec, (q15_t)0x2c4c, (q15_t)0x87e9, + (q15_t)0x2c46, (q15_t)0x87e7, (q15_t)0x2c40, (q15_t)0x87e5, (q15_t)0x2c3a, + (q15_t)0x87e3, (q15_t)0x2c34, (q15_t)0x87e1, (q15_t)0x2c2e, (q15_t)0x87df, + (q15_t)0x2c29, (q15_t)0x87dc, (q15_t)0x2c23, (q15_t)0x87da, (q15_t)0x2c1d, + (q15_t)0x87d8, (q15_t)0x2c17, (q15_t)0x87d6, (q15_t)0x2c11, (q15_t)0x87d4, + (q15_t)0x2c0b, (q15_t)0x87d2, (q15_t)0x2c05, (q15_t)0x87cf, (q15_t)0x2bff, + (q15_t)0x87cd, (q15_t)0x2bf9, (q15_t)0x87cb, (q15_t)0x2bf3, (q15_t)0x87c9, + (q15_t)0x2bee, (q15_t)0x87c7, (q15_t)0x2be8, (q15_t)0x87c5, (q15_t)0x2be2, + (q15_t)0x87c2, (q15_t)0x2bdc, (q15_t)0x87c0, (q15_t)0x2bd6, (q15_t)0x87be, + (q15_t)0x2bd0, (q15_t)0x87bc, (q15_t)0x2bca, (q15_t)0x87ba, (q15_t)0x2bc4, + (q15_t)0x87b8, (q15_t)0x2bbe, (q15_t)0x87b6, (q15_t)0x2bb8, (q15_t)0x87b3, + (q15_t)0x2bb2, (q15_t)0x87b1, (q15_t)0x2bad, (q15_t)0x87af, (q15_t)0x2ba7, + (q15_t)0x87ad, (q15_t)0x2ba1, (q15_t)0x87ab, (q15_t)0x2b9b, (q15_t)0x87a9, + (q15_t)0x2b95, (q15_t)0x87a7, (q15_t)0x2b8f, (q15_t)0x87a4, (q15_t)0x2b89, + (q15_t)0x87a2, (q15_t)0x2b83, (q15_t)0x87a0, (q15_t)0x2b7d, (q15_t)0x879e, + (q15_t)0x2b77, (q15_t)0x879c, (q15_t)0x2b71, (q15_t)0x879a, (q15_t)0x2b6c, + (q15_t)0x8798, (q15_t)0x2b66, (q15_t)0x8795, (q15_t)0x2b60, (q15_t)0x8793, + (q15_t)0x2b5a, (q15_t)0x8791, (q15_t)0x2b54, (q15_t)0x878f, (q15_t)0x2b4e, + (q15_t)0x878d, (q15_t)0x2b48, (q15_t)0x878b, (q15_t)0x2b42, (q15_t)0x8789, + (q15_t)0x2b3c, (q15_t)0x8787, (q15_t)0x2b36, (q15_t)0x8784, (q15_t)0x2b30, + (q15_t)0x8782, (q15_t)0x2b2b, (q15_t)0x8780, (q15_t)0x2b25, (q15_t)0x877e, + (q15_t)0x2b1f, (q15_t)0x877c, (q15_t)0x2b19, (q15_t)0x877a, (q15_t)0x2b13, + (q15_t)0x8778, (q15_t)0x2b0d, (q15_t)0x8776, (q15_t)0x2b07, (q15_t)0x8774, + (q15_t)0x2b01, (q15_t)0x8771, (q15_t)0x2afb, (q15_t)0x876f, (q15_t)0x2af5, + (q15_t)0x876d, (q15_t)0x2aef, (q15_t)0x876b, (q15_t)0x2ae9, (q15_t)0x8769, + (q15_t)0x2ae4, (q15_t)0x8767, (q15_t)0x2ade, (q15_t)0x8765, (q15_t)0x2ad8, + (q15_t)0x8763, (q15_t)0x2ad2, (q15_t)0x8761, (q15_t)0x2acc, (q15_t)0x875e, + (q15_t)0x2ac6, (q15_t)0x875c, (q15_t)0x2ac0, (q15_t)0x875a, (q15_t)0x2aba, + (q15_t)0x8758, (q15_t)0x2ab4, (q15_t)0x8756, (q15_t)0x2aae, (q15_t)0x8754, + (q15_t)0x2aa8, (q15_t)0x8752, (q15_t)0x2aa2, (q15_t)0x8750, (q15_t)0x2a9c, + (q15_t)0x874e, (q15_t)0x2a97, (q15_t)0x874c, (q15_t)0x2a91, (q15_t)0x874a, + (q15_t)0x2a8b, (q15_t)0x8747, (q15_t)0x2a85, (q15_t)0x8745, (q15_t)0x2a7f, + (q15_t)0x8743, (q15_t)0x2a79, (q15_t)0x8741, (q15_t)0x2a73, (q15_t)0x873f, + (q15_t)0x2a6d, (q15_t)0x873d, (q15_t)0x2a67, (q15_t)0x873b, (q15_t)0x2a61, + (q15_t)0x8739, (q15_t)0x2a5b, (q15_t)0x8737, (q15_t)0x2a55, (q15_t)0x8735, + (q15_t)0x2a4f, (q15_t)0x8733, (q15_t)0x2a49, (q15_t)0x8731, (q15_t)0x2a44, + (q15_t)0x872e, (q15_t)0x2a3e, (q15_t)0x872c, (q15_t)0x2a38, (q15_t)0x872a, + (q15_t)0x2a32, (q15_t)0x8728, (q15_t)0x2a2c, (q15_t)0x8726, (q15_t)0x2a26, + (q15_t)0x8724, (q15_t)0x2a20, (q15_t)0x8722, (q15_t)0x2a1a, (q15_t)0x8720, + (q15_t)0x2a14, (q15_t)0x871e, (q15_t)0x2a0e, (q15_t)0x871c, (q15_t)0x2a08, + (q15_t)0x871a, (q15_t)0x2a02, (q15_t)0x8718, (q15_t)0x29fc, (q15_t)0x8716, + (q15_t)0x29f6, (q15_t)0x8714, (q15_t)0x29f0, (q15_t)0x8712, (q15_t)0x29eb, + (q15_t)0x870f, (q15_t)0x29e5, (q15_t)0x870d, (q15_t)0x29df, (q15_t)0x870b, + (q15_t)0x29d9, (q15_t)0x8709, (q15_t)0x29d3, (q15_t)0x8707, (q15_t)0x29cd, + (q15_t)0x8705, (q15_t)0x29c7, (q15_t)0x8703, (q15_t)0x29c1, (q15_t)0x8701, + (q15_t)0x29bb, (q15_t)0x86ff, (q15_t)0x29b5, (q15_t)0x86fd, (q15_t)0x29af, + (q15_t)0x86fb, (q15_t)0x29a9, (q15_t)0x86f9, (q15_t)0x29a3, (q15_t)0x86f7, + (q15_t)0x299d, (q15_t)0x86f5, (q15_t)0x2997, (q15_t)0x86f3, (q15_t)0x2991, + (q15_t)0x86f1, (q15_t)0x298b, (q15_t)0x86ef, (q15_t)0x2986, (q15_t)0x86ed, + (q15_t)0x2980, (q15_t)0x86eb, (q15_t)0x297a, (q15_t)0x86e9, (q15_t)0x2974, + (q15_t)0x86e7, (q15_t)0x296e, (q15_t)0x86e4, (q15_t)0x2968, (q15_t)0x86e2, + (q15_t)0x2962, (q15_t)0x86e0, (q15_t)0x295c, (q15_t)0x86de, (q15_t)0x2956, + (q15_t)0x86dc, (q15_t)0x2950, (q15_t)0x86da, (q15_t)0x294a, (q15_t)0x86d8, + (q15_t)0x2944, (q15_t)0x86d6, (q15_t)0x293e, (q15_t)0x86d4, (q15_t)0x2938, + (q15_t)0x86d2, (q15_t)0x2932, (q15_t)0x86d0, (q15_t)0x292c, (q15_t)0x86ce, + (q15_t)0x2926, (q15_t)0x86cc, (q15_t)0x2920, (q15_t)0x86ca, (q15_t)0x291b, + (q15_t)0x86c8, (q15_t)0x2915, (q15_t)0x86c6, (q15_t)0x290f, (q15_t)0x86c4, + (q15_t)0x2909, (q15_t)0x86c2, (q15_t)0x2903, (q15_t)0x86c0, (q15_t)0x28fd, + (q15_t)0x86be, (q15_t)0x28f7, (q15_t)0x86bc, (q15_t)0x28f1, (q15_t)0x86ba, + (q15_t)0x28eb, (q15_t)0x86b8, (q15_t)0x28e5, (q15_t)0x86b6, (q15_t)0x28df, + (q15_t)0x86b4, (q15_t)0x28d9, (q15_t)0x86b2, (q15_t)0x28d3, (q15_t)0x86b0, + (q15_t)0x28cd, (q15_t)0x86ae, (q15_t)0x28c7, (q15_t)0x86ac, (q15_t)0x28c1, + (q15_t)0x86aa, (q15_t)0x28bb, (q15_t)0x86a8, (q15_t)0x28b5, (q15_t)0x86a6, + (q15_t)0x28af, (q15_t)0x86a4, (q15_t)0x28a9, (q15_t)0x86a2, (q15_t)0x28a3, + (q15_t)0x86a0, (q15_t)0x289d, (q15_t)0x869e, (q15_t)0x2898, (q15_t)0x869c, + (q15_t)0x2892, (q15_t)0x869a, (q15_t)0x288c, (q15_t)0x8698, (q15_t)0x2886, + (q15_t)0x8696, (q15_t)0x2880, (q15_t)0x8694, (q15_t)0x287a, (q15_t)0x8692, + (q15_t)0x2874, (q15_t)0x8690, (q15_t)0x286e, (q15_t)0x868e, (q15_t)0x2868, + (q15_t)0x868c, (q15_t)0x2862, (q15_t)0x868a, (q15_t)0x285c, (q15_t)0x8688, + (q15_t)0x2856, (q15_t)0x8686, (q15_t)0x2850, (q15_t)0x8684, (q15_t)0x284a, + (q15_t)0x8682, (q15_t)0x2844, (q15_t)0x8680, (q15_t)0x283e, (q15_t)0x867e, + (q15_t)0x2838, (q15_t)0x867c, (q15_t)0x2832, (q15_t)0x867a, (q15_t)0x282c, + (q15_t)0x8678, (q15_t)0x2826, (q15_t)0x8676, (q15_t)0x2820, (q15_t)0x8674, + (q15_t)0x281a, (q15_t)0x8672, (q15_t)0x2814, (q15_t)0x8670, (q15_t)0x280e, + (q15_t)0x866e, (q15_t)0x2808, (q15_t)0x866d, (q15_t)0x2802, (q15_t)0x866b, + (q15_t)0x27fc, (q15_t)0x8669, (q15_t)0x27f6, (q15_t)0x8667, (q15_t)0x27f1, + (q15_t)0x8665, (q15_t)0x27eb, (q15_t)0x8663, (q15_t)0x27e5, (q15_t)0x8661, + (q15_t)0x27df, (q15_t)0x865f, (q15_t)0x27d9, (q15_t)0x865d, (q15_t)0x27d3, + (q15_t)0x865b, (q15_t)0x27cd, (q15_t)0x8659, (q15_t)0x27c7, (q15_t)0x8657, + (q15_t)0x27c1, (q15_t)0x8655, (q15_t)0x27bb, (q15_t)0x8653, (q15_t)0x27b5, + (q15_t)0x8651, (q15_t)0x27af, (q15_t)0x864f, (q15_t)0x27a9, (q15_t)0x864d, + (q15_t)0x27a3, (q15_t)0x864b, (q15_t)0x279d, (q15_t)0x8649, (q15_t)0x2797, + (q15_t)0x8647, (q15_t)0x2791, (q15_t)0x8645, (q15_t)0x278b, (q15_t)0x8644, + (q15_t)0x2785, (q15_t)0x8642, (q15_t)0x277f, (q15_t)0x8640, (q15_t)0x2779, + (q15_t)0x863e, (q15_t)0x2773, (q15_t)0x863c, (q15_t)0x276d, (q15_t)0x863a, + (q15_t)0x2767, (q15_t)0x8638, (q15_t)0x2761, (q15_t)0x8636, (q15_t)0x275b, + (q15_t)0x8634, (q15_t)0x2755, (q15_t)0x8632, (q15_t)0x274f, (q15_t)0x8630, + (q15_t)0x2749, (q15_t)0x862e, (q15_t)0x2743, (q15_t)0x862c, (q15_t)0x273d, + (q15_t)0x862a, (q15_t)0x2737, (q15_t)0x8628, (q15_t)0x2731, (q15_t)0x8627, + (q15_t)0x272b, (q15_t)0x8625, (q15_t)0x2725, (q15_t)0x8623, (q15_t)0x271f, + (q15_t)0x8621, (q15_t)0x2719, (q15_t)0x861f, (q15_t)0x2713, (q15_t)0x861d, + (q15_t)0x270d, (q15_t)0x861b, (q15_t)0x2707, (q15_t)0x8619, (q15_t)0x2701, + (q15_t)0x8617, (q15_t)0x26fb, (q15_t)0x8615, (q15_t)0x26f5, (q15_t)0x8613, + (q15_t)0x26ef, (q15_t)0x8611, (q15_t)0x26e9, (q15_t)0x8610, (q15_t)0x26e4, + (q15_t)0x860e, (q15_t)0x26de, (q15_t)0x860c, (q15_t)0x26d8, (q15_t)0x860a, + (q15_t)0x26d2, (q15_t)0x8608, (q15_t)0x26cc, (q15_t)0x8606, (q15_t)0x26c6, + (q15_t)0x8604, (q15_t)0x26c0, (q15_t)0x8602, (q15_t)0x26ba, (q15_t)0x8600, + (q15_t)0x26b4, (q15_t)0x85fe, (q15_t)0x26ae, (q15_t)0x85fc, (q15_t)0x26a8, + (q15_t)0x85fb, (q15_t)0x26a2, (q15_t)0x85f9, (q15_t)0x269c, (q15_t)0x85f7, + (q15_t)0x2696, (q15_t)0x85f5, (q15_t)0x2690, (q15_t)0x85f3, (q15_t)0x268a, + (q15_t)0x85f1, (q15_t)0x2684, (q15_t)0x85ef, (q15_t)0x267e, (q15_t)0x85ed, + (q15_t)0x2678, (q15_t)0x85eb, (q15_t)0x2672, (q15_t)0x85ea, (q15_t)0x266c, + (q15_t)0x85e8, (q15_t)0x2666, (q15_t)0x85e6, (q15_t)0x2660, (q15_t)0x85e4, + (q15_t)0x265a, (q15_t)0x85e2, (q15_t)0x2654, (q15_t)0x85e0, (q15_t)0x264e, + (q15_t)0x85de, (q15_t)0x2648, (q15_t)0x85dc, (q15_t)0x2642, (q15_t)0x85da, + (q15_t)0x263c, (q15_t)0x85d9, (q15_t)0x2636, (q15_t)0x85d7, (q15_t)0x2630, + (q15_t)0x85d5, (q15_t)0x262a, (q15_t)0x85d3, (q15_t)0x2624, (q15_t)0x85d1, + (q15_t)0x261e, (q15_t)0x85cf, (q15_t)0x2618, (q15_t)0x85cd, (q15_t)0x2612, + (q15_t)0x85cb, (q15_t)0x260c, (q15_t)0x85ca, (q15_t)0x2606, (q15_t)0x85c8, + (q15_t)0x2600, (q15_t)0x85c6, (q15_t)0x25fa, (q15_t)0x85c4, (q15_t)0x25f4, + (q15_t)0x85c2, (q15_t)0x25ee, (q15_t)0x85c0, (q15_t)0x25e8, (q15_t)0x85be, + (q15_t)0x25e2, (q15_t)0x85bd, (q15_t)0x25dc, (q15_t)0x85bb, (q15_t)0x25d6, + (q15_t)0x85b9, (q15_t)0x25d0, (q15_t)0x85b7, (q15_t)0x25ca, (q15_t)0x85b5, + (q15_t)0x25c4, (q15_t)0x85b3, (q15_t)0x25be, (q15_t)0x85b1, (q15_t)0x25b8, + (q15_t)0x85b0, (q15_t)0x25b2, (q15_t)0x85ae, (q15_t)0x25ac, (q15_t)0x85ac, + (q15_t)0x25a6, (q15_t)0x85aa, (q15_t)0x25a0, (q15_t)0x85a8, (q15_t)0x259a, + (q15_t)0x85a6, (q15_t)0x2594, (q15_t)0x85a4, (q15_t)0x258e, (q15_t)0x85a3, + (q15_t)0x2588, (q15_t)0x85a1, (q15_t)0x2582, (q15_t)0x859f, (q15_t)0x257c, + (q15_t)0x859d, (q15_t)0x2576, (q15_t)0x859b, (q15_t)0x2570, (q15_t)0x8599, + (q15_t)0x256a, (q15_t)0x8598, (q15_t)0x2564, (q15_t)0x8596, (q15_t)0x255e, + (q15_t)0x8594, (q15_t)0x2558, (q15_t)0x8592, (q15_t)0x2552, (q15_t)0x8590, + (q15_t)0x254c, (q15_t)0x858e, (q15_t)0x2546, (q15_t)0x858d, (q15_t)0x2540, + (q15_t)0x858b, (q15_t)0x253a, (q15_t)0x8589, (q15_t)0x2534, (q15_t)0x8587, + (q15_t)0x252e, (q15_t)0x8585, (q15_t)0x2528, (q15_t)0x8583, (q15_t)0x2522, + (q15_t)0x8582, (q15_t)0x251c, (q15_t)0x8580, (q15_t)0x2516, (q15_t)0x857e, + (q15_t)0x250f, (q15_t)0x857c, (q15_t)0x2509, (q15_t)0x857a, (q15_t)0x2503, + (q15_t)0x8579, (q15_t)0x24fd, (q15_t)0x8577, (q15_t)0x24f7, (q15_t)0x8575, + (q15_t)0x24f1, (q15_t)0x8573, (q15_t)0x24eb, (q15_t)0x8571, (q15_t)0x24e5, + (q15_t)0x856f, (q15_t)0x24df, (q15_t)0x856e, (q15_t)0x24d9, (q15_t)0x856c, + (q15_t)0x24d3, (q15_t)0x856a, (q15_t)0x24cd, (q15_t)0x8568, (q15_t)0x24c7, + (q15_t)0x8566, (q15_t)0x24c1, (q15_t)0x8565, (q15_t)0x24bb, (q15_t)0x8563, + (q15_t)0x24b5, (q15_t)0x8561, (q15_t)0x24af, (q15_t)0x855f, (q15_t)0x24a9, + (q15_t)0x855d, (q15_t)0x24a3, (q15_t)0x855c, (q15_t)0x249d, (q15_t)0x855a, + (q15_t)0x2497, (q15_t)0x8558, (q15_t)0x2491, (q15_t)0x8556, (q15_t)0x248b, + (q15_t)0x8554, (q15_t)0x2485, (q15_t)0x8553, (q15_t)0x247f, (q15_t)0x8551, + (q15_t)0x2479, (q15_t)0x854f, (q15_t)0x2473, (q15_t)0x854d, (q15_t)0x246d, + (q15_t)0x854b, (q15_t)0x2467, (q15_t)0x854a, (q15_t)0x2461, (q15_t)0x8548, + (q15_t)0x245b, (q15_t)0x8546, (q15_t)0x2455, (q15_t)0x8544, (q15_t)0x244f, + (q15_t)0x8543, (q15_t)0x2449, (q15_t)0x8541, (q15_t)0x2443, (q15_t)0x853f, + (q15_t)0x243d, (q15_t)0x853d, (q15_t)0x2437, (q15_t)0x853b, (q15_t)0x2431, + (q15_t)0x853a, (q15_t)0x242b, (q15_t)0x8538, (q15_t)0x2425, (q15_t)0x8536, + (q15_t)0x241f, (q15_t)0x8534, (q15_t)0x2419, (q15_t)0x8533, (q15_t)0x2413, + (q15_t)0x8531, (q15_t)0x240d, (q15_t)0x852f, (q15_t)0x2407, (q15_t)0x852d, + (q15_t)0x2401, (q15_t)0x852b, (q15_t)0x23fa, (q15_t)0x852a, (q15_t)0x23f4, + (q15_t)0x8528, (q15_t)0x23ee, (q15_t)0x8526, (q15_t)0x23e8, (q15_t)0x8524, + (q15_t)0x23e2, (q15_t)0x8523, (q15_t)0x23dc, (q15_t)0x8521, (q15_t)0x23d6, + (q15_t)0x851f, (q15_t)0x23d0, (q15_t)0x851d, (q15_t)0x23ca, (q15_t)0x851c, + (q15_t)0x23c4, (q15_t)0x851a, (q15_t)0x23be, (q15_t)0x8518, (q15_t)0x23b8, + (q15_t)0x8516, (q15_t)0x23b2, (q15_t)0x8515, (q15_t)0x23ac, (q15_t)0x8513, + (q15_t)0x23a6, (q15_t)0x8511, (q15_t)0x23a0, (q15_t)0x850f, (q15_t)0x239a, + (q15_t)0x850e, (q15_t)0x2394, (q15_t)0x850c, (q15_t)0x238e, (q15_t)0x850a, + (q15_t)0x2388, (q15_t)0x8508, (q15_t)0x2382, (q15_t)0x8507, (q15_t)0x237c, + (q15_t)0x8505, (q15_t)0x2376, (q15_t)0x8503, (q15_t)0x2370, (q15_t)0x8501, + (q15_t)0x236a, (q15_t)0x8500, (q15_t)0x2364, (q15_t)0x84fe, (q15_t)0x235e, + (q15_t)0x84fc, (q15_t)0x2358, (q15_t)0x84fa, (q15_t)0x2352, (q15_t)0x84f9, + (q15_t)0x234b, (q15_t)0x84f7, (q15_t)0x2345, (q15_t)0x84f5, (q15_t)0x233f, + (q15_t)0x84f4, (q15_t)0x2339, (q15_t)0x84f2, (q15_t)0x2333, (q15_t)0x84f0, + (q15_t)0x232d, (q15_t)0x84ee, (q15_t)0x2327, (q15_t)0x84ed, (q15_t)0x2321, + (q15_t)0x84eb, (q15_t)0x231b, (q15_t)0x84e9, (q15_t)0x2315, (q15_t)0x84e7, + (q15_t)0x230f, (q15_t)0x84e6, (q15_t)0x2309, (q15_t)0x84e4, (q15_t)0x2303, + (q15_t)0x84e2, (q15_t)0x22fd, (q15_t)0x84e1, (q15_t)0x22f7, (q15_t)0x84df, + (q15_t)0x22f1, (q15_t)0x84dd, (q15_t)0x22eb, (q15_t)0x84db, (q15_t)0x22e5, + (q15_t)0x84da, (q15_t)0x22df, (q15_t)0x84d8, (q15_t)0x22d9, (q15_t)0x84d6, + (q15_t)0x22d3, (q15_t)0x84d5, (q15_t)0x22cd, (q15_t)0x84d3, (q15_t)0x22c7, + (q15_t)0x84d1, (q15_t)0x22c0, (q15_t)0x84cf, (q15_t)0x22ba, (q15_t)0x84ce, + (q15_t)0x22b4, (q15_t)0x84cc, (q15_t)0x22ae, (q15_t)0x84ca, (q15_t)0x22a8, + (q15_t)0x84c9, (q15_t)0x22a2, (q15_t)0x84c7, (q15_t)0x229c, (q15_t)0x84c5, + (q15_t)0x2296, (q15_t)0x84c4, (q15_t)0x2290, (q15_t)0x84c2, (q15_t)0x228a, + (q15_t)0x84c0, (q15_t)0x2284, (q15_t)0x84be, (q15_t)0x227e, (q15_t)0x84bd, + (q15_t)0x2278, (q15_t)0x84bb, (q15_t)0x2272, (q15_t)0x84b9, (q15_t)0x226c, + (q15_t)0x84b8, (q15_t)0x2266, (q15_t)0x84b6, (q15_t)0x2260, (q15_t)0x84b4, + (q15_t)0x225a, (q15_t)0x84b3, (q15_t)0x2254, (q15_t)0x84b1, (q15_t)0x224e, + (q15_t)0x84af, (q15_t)0x2247, (q15_t)0x84ae, (q15_t)0x2241, (q15_t)0x84ac, + (q15_t)0x223b, (q15_t)0x84aa, (q15_t)0x2235, (q15_t)0x84a9, (q15_t)0x222f, + (q15_t)0x84a7, (q15_t)0x2229, (q15_t)0x84a5, (q15_t)0x2223, (q15_t)0x84a3, + (q15_t)0x221d, (q15_t)0x84a2, (q15_t)0x2217, (q15_t)0x84a0, (q15_t)0x2211, + (q15_t)0x849e, (q15_t)0x220b, (q15_t)0x849d, (q15_t)0x2205, (q15_t)0x849b, + (q15_t)0x21ff, (q15_t)0x8499, (q15_t)0x21f9, (q15_t)0x8498, (q15_t)0x21f3, + (q15_t)0x8496, (q15_t)0x21ed, (q15_t)0x8494, (q15_t)0x21e7, (q15_t)0x8493, + (q15_t)0x21e1, (q15_t)0x8491, (q15_t)0x21da, (q15_t)0x848f, (q15_t)0x21d4, + (q15_t)0x848e, (q15_t)0x21ce, (q15_t)0x848c, (q15_t)0x21c8, (q15_t)0x848a, + (q15_t)0x21c2, (q15_t)0x8489, (q15_t)0x21bc, (q15_t)0x8487, (q15_t)0x21b6, + (q15_t)0x8486, (q15_t)0x21b0, (q15_t)0x8484, (q15_t)0x21aa, (q15_t)0x8482, + (q15_t)0x21a4, (q15_t)0x8481, (q15_t)0x219e, (q15_t)0x847f, (q15_t)0x2198, + (q15_t)0x847d, (q15_t)0x2192, (q15_t)0x847c, (q15_t)0x218c, (q15_t)0x847a, + (q15_t)0x2186, (q15_t)0x8478, (q15_t)0x2180, (q15_t)0x8477, (q15_t)0x2179, + (q15_t)0x8475, (q15_t)0x2173, (q15_t)0x8473, (q15_t)0x216d, (q15_t)0x8472, + (q15_t)0x2167, (q15_t)0x8470, (q15_t)0x2161, (q15_t)0x846e, (q15_t)0x215b, + (q15_t)0x846d, (q15_t)0x2155, (q15_t)0x846b, (q15_t)0x214f, (q15_t)0x846a, + (q15_t)0x2149, (q15_t)0x8468, (q15_t)0x2143, (q15_t)0x8466, (q15_t)0x213d, + (q15_t)0x8465, (q15_t)0x2137, (q15_t)0x8463, (q15_t)0x2131, (q15_t)0x8461, + (q15_t)0x212b, (q15_t)0x8460, (q15_t)0x2125, (q15_t)0x845e, (q15_t)0x211e, + (q15_t)0x845d, (q15_t)0x2118, (q15_t)0x845b, (q15_t)0x2112, (q15_t)0x8459, + (q15_t)0x210c, (q15_t)0x8458, (q15_t)0x2106, (q15_t)0x8456, (q15_t)0x2100, + (q15_t)0x8454, (q15_t)0x20fa, (q15_t)0x8453, (q15_t)0x20f4, (q15_t)0x8451, + (q15_t)0x20ee, (q15_t)0x8450, (q15_t)0x20e8, (q15_t)0x844e, (q15_t)0x20e2, + (q15_t)0x844c, (q15_t)0x20dc, (q15_t)0x844b, (q15_t)0x20d6, (q15_t)0x8449, + (q15_t)0x20d0, (q15_t)0x8447, (q15_t)0x20c9, (q15_t)0x8446, (q15_t)0x20c3, + (q15_t)0x8444, (q15_t)0x20bd, (q15_t)0x8443, (q15_t)0x20b7, (q15_t)0x8441, + (q15_t)0x20b1, (q15_t)0x843f, (q15_t)0x20ab, (q15_t)0x843e, (q15_t)0x20a5, + (q15_t)0x843c, (q15_t)0x209f, (q15_t)0x843b, (q15_t)0x2099, (q15_t)0x8439, + (q15_t)0x2093, (q15_t)0x8437, (q15_t)0x208d, (q15_t)0x8436, (q15_t)0x2087, + (q15_t)0x8434, (q15_t)0x2081, (q15_t)0x8433, (q15_t)0x207a, (q15_t)0x8431, + (q15_t)0x2074, (q15_t)0x842f, (q15_t)0x206e, (q15_t)0x842e, (q15_t)0x2068, + (q15_t)0x842c, (q15_t)0x2062, (q15_t)0x842b, (q15_t)0x205c, (q15_t)0x8429, + (q15_t)0x2056, (q15_t)0x8427, (q15_t)0x2050, (q15_t)0x8426, (q15_t)0x204a, + (q15_t)0x8424, (q15_t)0x2044, (q15_t)0x8423, (q15_t)0x203e, (q15_t)0x8421, + (q15_t)0x2038, (q15_t)0x8420, (q15_t)0x2032, (q15_t)0x841e, (q15_t)0x202b, + (q15_t)0x841c, (q15_t)0x2025, (q15_t)0x841b, (q15_t)0x201f, (q15_t)0x8419, + (q15_t)0x2019, (q15_t)0x8418, (q15_t)0x2013, (q15_t)0x8416, (q15_t)0x200d, + (q15_t)0x8415, (q15_t)0x2007, (q15_t)0x8413, (q15_t)0x2001, (q15_t)0x8411, + (q15_t)0x1ffb, (q15_t)0x8410, (q15_t)0x1ff5, (q15_t)0x840e, (q15_t)0x1fef, + (q15_t)0x840d, (q15_t)0x1fe9, (q15_t)0x840b, (q15_t)0x1fe2, (q15_t)0x840a, + (q15_t)0x1fdc, (q15_t)0x8408, (q15_t)0x1fd6, (q15_t)0x8406, (q15_t)0x1fd0, + (q15_t)0x8405, (q15_t)0x1fca, (q15_t)0x8403, (q15_t)0x1fc4, (q15_t)0x8402, + (q15_t)0x1fbe, (q15_t)0x8400, (q15_t)0x1fb8, (q15_t)0x83ff, (q15_t)0x1fb2, + (q15_t)0x83fd, (q15_t)0x1fac, (q15_t)0x83fb, (q15_t)0x1fa6, (q15_t)0x83fa, + (q15_t)0x1f9f, (q15_t)0x83f8, (q15_t)0x1f99, (q15_t)0x83f7, (q15_t)0x1f93, + (q15_t)0x83f5, (q15_t)0x1f8d, (q15_t)0x83f4, (q15_t)0x1f87, (q15_t)0x83f2, + (q15_t)0x1f81, (q15_t)0x83f1, (q15_t)0x1f7b, (q15_t)0x83ef, (q15_t)0x1f75, + (q15_t)0x83ee, (q15_t)0x1f6f, (q15_t)0x83ec, (q15_t)0x1f69, (q15_t)0x83ea, + (q15_t)0x1f63, (q15_t)0x83e9, (q15_t)0x1f5d, (q15_t)0x83e7, (q15_t)0x1f56, + (q15_t)0x83e6, (q15_t)0x1f50, (q15_t)0x83e4, (q15_t)0x1f4a, (q15_t)0x83e3, + (q15_t)0x1f44, (q15_t)0x83e1, (q15_t)0x1f3e, (q15_t)0x83e0, (q15_t)0x1f38, + (q15_t)0x83de, (q15_t)0x1f32, (q15_t)0x83dd, (q15_t)0x1f2c, (q15_t)0x83db, + (q15_t)0x1f26, (q15_t)0x83da, (q15_t)0x1f20, (q15_t)0x83d8, (q15_t)0x1f19, + (q15_t)0x83d7, (q15_t)0x1f13, (q15_t)0x83d5, (q15_t)0x1f0d, (q15_t)0x83d3, + (q15_t)0x1f07, (q15_t)0x83d2, (q15_t)0x1f01, (q15_t)0x83d0, (q15_t)0x1efb, + (q15_t)0x83cf, (q15_t)0x1ef5, (q15_t)0x83cd, (q15_t)0x1eef, (q15_t)0x83cc, + (q15_t)0x1ee9, (q15_t)0x83ca, (q15_t)0x1ee3, (q15_t)0x83c9, (q15_t)0x1edd, + (q15_t)0x83c7, (q15_t)0x1ed6, (q15_t)0x83c6, (q15_t)0x1ed0, (q15_t)0x83c4, + (q15_t)0x1eca, (q15_t)0x83c3, (q15_t)0x1ec4, (q15_t)0x83c1, (q15_t)0x1ebe, + (q15_t)0x83c0, (q15_t)0x1eb8, (q15_t)0x83be, (q15_t)0x1eb2, (q15_t)0x83bd, + (q15_t)0x1eac, (q15_t)0x83bb, (q15_t)0x1ea6, (q15_t)0x83ba, (q15_t)0x1ea0, + (q15_t)0x83b8, (q15_t)0x1e99, (q15_t)0x83b7, (q15_t)0x1e93, (q15_t)0x83b5, + (q15_t)0x1e8d, (q15_t)0x83b4, (q15_t)0x1e87, (q15_t)0x83b2, (q15_t)0x1e81, + (q15_t)0x83b1, (q15_t)0x1e7b, (q15_t)0x83af, (q15_t)0x1e75, (q15_t)0x83ae, + (q15_t)0x1e6f, (q15_t)0x83ac, (q15_t)0x1e69, (q15_t)0x83ab, (q15_t)0x1e62, + (q15_t)0x83a9, (q15_t)0x1e5c, (q15_t)0x83a8, (q15_t)0x1e56, (q15_t)0x83a6, + (q15_t)0x1e50, (q15_t)0x83a5, (q15_t)0x1e4a, (q15_t)0x83a3, (q15_t)0x1e44, + (q15_t)0x83a2, (q15_t)0x1e3e, (q15_t)0x83a0, (q15_t)0x1e38, (q15_t)0x839f, + (q15_t)0x1e32, (q15_t)0x839d, (q15_t)0x1e2c, (q15_t)0x839c, (q15_t)0x1e25, + (q15_t)0x839a, (q15_t)0x1e1f, (q15_t)0x8399, (q15_t)0x1e19, (q15_t)0x8397, + (q15_t)0x1e13, (q15_t)0x8396, (q15_t)0x1e0d, (q15_t)0x8394, (q15_t)0x1e07, + (q15_t)0x8393, (q15_t)0x1e01, (q15_t)0x8392, (q15_t)0x1dfb, (q15_t)0x8390, + (q15_t)0x1df5, (q15_t)0x838f, (q15_t)0x1dee, (q15_t)0x838d, (q15_t)0x1de8, + (q15_t)0x838c, (q15_t)0x1de2, (q15_t)0x838a, (q15_t)0x1ddc, (q15_t)0x8389, + (q15_t)0x1dd6, (q15_t)0x8387, (q15_t)0x1dd0, (q15_t)0x8386, (q15_t)0x1dca, + (q15_t)0x8384, (q15_t)0x1dc4, (q15_t)0x8383, (q15_t)0x1dbe, (q15_t)0x8381, + (q15_t)0x1db7, (q15_t)0x8380, (q15_t)0x1db1, (q15_t)0x837e, (q15_t)0x1dab, + (q15_t)0x837d, (q15_t)0x1da5, (q15_t)0x837c, (q15_t)0x1d9f, (q15_t)0x837a, + (q15_t)0x1d99, (q15_t)0x8379, (q15_t)0x1d93, (q15_t)0x8377, (q15_t)0x1d8d, + (q15_t)0x8376, (q15_t)0x1d87, (q15_t)0x8374, (q15_t)0x1d80, (q15_t)0x8373, + (q15_t)0x1d7a, (q15_t)0x8371, (q15_t)0x1d74, (q15_t)0x8370, (q15_t)0x1d6e, + (q15_t)0x836f, (q15_t)0x1d68, (q15_t)0x836d, (q15_t)0x1d62, (q15_t)0x836c, + (q15_t)0x1d5c, (q15_t)0x836a, (q15_t)0x1d56, (q15_t)0x8369, (q15_t)0x1d50, + (q15_t)0x8367, (q15_t)0x1d49, (q15_t)0x8366, (q15_t)0x1d43, (q15_t)0x8364, + (q15_t)0x1d3d, (q15_t)0x8363, (q15_t)0x1d37, (q15_t)0x8362, (q15_t)0x1d31, + (q15_t)0x8360, (q15_t)0x1d2b, (q15_t)0x835f, (q15_t)0x1d25, (q15_t)0x835d, + (q15_t)0x1d1f, (q15_t)0x835c, (q15_t)0x1d18, (q15_t)0x835a, (q15_t)0x1d12, + (q15_t)0x8359, (q15_t)0x1d0c, (q15_t)0x8358, (q15_t)0x1d06, (q15_t)0x8356, + (q15_t)0x1d00, (q15_t)0x8355, (q15_t)0x1cfa, (q15_t)0x8353, (q15_t)0x1cf4, + (q15_t)0x8352, (q15_t)0x1cee, (q15_t)0x8350, (q15_t)0x1ce8, (q15_t)0x834f, + (q15_t)0x1ce1, (q15_t)0x834e, (q15_t)0x1cdb, (q15_t)0x834c, (q15_t)0x1cd5, + (q15_t)0x834b, (q15_t)0x1ccf, (q15_t)0x8349, (q15_t)0x1cc9, (q15_t)0x8348, + (q15_t)0x1cc3, (q15_t)0x8347, (q15_t)0x1cbd, (q15_t)0x8345, (q15_t)0x1cb7, + (q15_t)0x8344, (q15_t)0x1cb0, (q15_t)0x8342, (q15_t)0x1caa, (q15_t)0x8341, + (q15_t)0x1ca4, (q15_t)0x833f, (q15_t)0x1c9e, (q15_t)0x833e, (q15_t)0x1c98, + (q15_t)0x833d, (q15_t)0x1c92, (q15_t)0x833b, (q15_t)0x1c8c, (q15_t)0x833a, + (q15_t)0x1c86, (q15_t)0x8338, (q15_t)0x1c7f, (q15_t)0x8337, (q15_t)0x1c79, + (q15_t)0x8336, (q15_t)0x1c73, (q15_t)0x8334, (q15_t)0x1c6d, (q15_t)0x8333, + (q15_t)0x1c67, (q15_t)0x8331, (q15_t)0x1c61, (q15_t)0x8330, (q15_t)0x1c5b, + (q15_t)0x832f, (q15_t)0x1c55, (q15_t)0x832d, (q15_t)0x1c4e, (q15_t)0x832c, + (q15_t)0x1c48, (q15_t)0x832b, (q15_t)0x1c42, (q15_t)0x8329, (q15_t)0x1c3c, + (q15_t)0x8328, (q15_t)0x1c36, (q15_t)0x8326, (q15_t)0x1c30, (q15_t)0x8325, + (q15_t)0x1c2a, (q15_t)0x8324, (q15_t)0x1c24, (q15_t)0x8322, (q15_t)0x1c1d, + (q15_t)0x8321, (q15_t)0x1c17, (q15_t)0x831f, (q15_t)0x1c11, (q15_t)0x831e, + (q15_t)0x1c0b, (q15_t)0x831d, (q15_t)0x1c05, (q15_t)0x831b, (q15_t)0x1bff, + (q15_t)0x831a, (q15_t)0x1bf9, (q15_t)0x8319, (q15_t)0x1bf2, (q15_t)0x8317, + (q15_t)0x1bec, (q15_t)0x8316, (q15_t)0x1be6, (q15_t)0x8314, (q15_t)0x1be0, + (q15_t)0x8313, (q15_t)0x1bda, (q15_t)0x8312, (q15_t)0x1bd4, (q15_t)0x8310, + (q15_t)0x1bce, (q15_t)0x830f, (q15_t)0x1bc8, (q15_t)0x830e, (q15_t)0x1bc1, + (q15_t)0x830c, (q15_t)0x1bbb, (q15_t)0x830b, (q15_t)0x1bb5, (q15_t)0x830a, + (q15_t)0x1baf, (q15_t)0x8308, (q15_t)0x1ba9, (q15_t)0x8307, (q15_t)0x1ba3, + (q15_t)0x8305, (q15_t)0x1b9d, (q15_t)0x8304, (q15_t)0x1b96, (q15_t)0x8303, + (q15_t)0x1b90, (q15_t)0x8301, (q15_t)0x1b8a, (q15_t)0x8300, (q15_t)0x1b84, + (q15_t)0x82ff, (q15_t)0x1b7e, (q15_t)0x82fd, (q15_t)0x1b78, (q15_t)0x82fc, + (q15_t)0x1b72, (q15_t)0x82fb, (q15_t)0x1b6c, (q15_t)0x82f9, (q15_t)0x1b65, + (q15_t)0x82f8, (q15_t)0x1b5f, (q15_t)0x82f7, (q15_t)0x1b59, (q15_t)0x82f5, + (q15_t)0x1b53, (q15_t)0x82f4, (q15_t)0x1b4d, (q15_t)0x82f3, (q15_t)0x1b47, + (q15_t)0x82f1, (q15_t)0x1b41, (q15_t)0x82f0, (q15_t)0x1b3a, (q15_t)0x82ef, + (q15_t)0x1b34, (q15_t)0x82ed, (q15_t)0x1b2e, (q15_t)0x82ec, (q15_t)0x1b28, + (q15_t)0x82eb, (q15_t)0x1b22, (q15_t)0x82e9, (q15_t)0x1b1c, (q15_t)0x82e8, + (q15_t)0x1b16, (q15_t)0x82e7, (q15_t)0x1b0f, (q15_t)0x82e5, (q15_t)0x1b09, + (q15_t)0x82e4, (q15_t)0x1b03, (q15_t)0x82e3, (q15_t)0x1afd, (q15_t)0x82e1, + (q15_t)0x1af7, (q15_t)0x82e0, (q15_t)0x1af1, (q15_t)0x82df, (q15_t)0x1aeb, + (q15_t)0x82dd, (q15_t)0x1ae4, (q15_t)0x82dc, (q15_t)0x1ade, (q15_t)0x82db, + (q15_t)0x1ad8, (q15_t)0x82d9, (q15_t)0x1ad2, (q15_t)0x82d8, (q15_t)0x1acc, + (q15_t)0x82d7, (q15_t)0x1ac6, (q15_t)0x82d5, (q15_t)0x1ac0, (q15_t)0x82d4, + (q15_t)0x1ab9, (q15_t)0x82d3, (q15_t)0x1ab3, (q15_t)0x82d1, (q15_t)0x1aad, + (q15_t)0x82d0, (q15_t)0x1aa7, (q15_t)0x82cf, (q15_t)0x1aa1, (q15_t)0x82ce, + (q15_t)0x1a9b, (q15_t)0x82cc, (q15_t)0x1a95, (q15_t)0x82cb, (q15_t)0x1a8e, + (q15_t)0x82ca, (q15_t)0x1a88, (q15_t)0x82c8, (q15_t)0x1a82, (q15_t)0x82c7, + (q15_t)0x1a7c, (q15_t)0x82c6, (q15_t)0x1a76, (q15_t)0x82c4, (q15_t)0x1a70, + (q15_t)0x82c3, (q15_t)0x1a6a, (q15_t)0x82c2, (q15_t)0x1a63, (q15_t)0x82c1, + (q15_t)0x1a5d, (q15_t)0x82bf, (q15_t)0x1a57, (q15_t)0x82be, (q15_t)0x1a51, + (q15_t)0x82bd, (q15_t)0x1a4b, (q15_t)0x82bb, (q15_t)0x1a45, (q15_t)0x82ba, + (q15_t)0x1a3e, (q15_t)0x82b9, (q15_t)0x1a38, (q15_t)0x82b7, (q15_t)0x1a32, + (q15_t)0x82b6, (q15_t)0x1a2c, (q15_t)0x82b5, (q15_t)0x1a26, (q15_t)0x82b4, + (q15_t)0x1a20, (q15_t)0x82b2, (q15_t)0x1a1a, (q15_t)0x82b1, (q15_t)0x1a13, + (q15_t)0x82b0, (q15_t)0x1a0d, (q15_t)0x82ae, (q15_t)0x1a07, (q15_t)0x82ad, + (q15_t)0x1a01, (q15_t)0x82ac, (q15_t)0x19fb, (q15_t)0x82ab, (q15_t)0x19f5, + (q15_t)0x82a9, (q15_t)0x19ef, (q15_t)0x82a8, (q15_t)0x19e8, (q15_t)0x82a7, + (q15_t)0x19e2, (q15_t)0x82a6, (q15_t)0x19dc, (q15_t)0x82a4, (q15_t)0x19d6, + (q15_t)0x82a3, (q15_t)0x19d0, (q15_t)0x82a2, (q15_t)0x19ca, (q15_t)0x82a0, + (q15_t)0x19c3, (q15_t)0x829f, (q15_t)0x19bd, (q15_t)0x829e, (q15_t)0x19b7, + (q15_t)0x829d, (q15_t)0x19b1, (q15_t)0x829b, (q15_t)0x19ab, (q15_t)0x829a, + (q15_t)0x19a5, (q15_t)0x8299, (q15_t)0x199f, (q15_t)0x8298, (q15_t)0x1998, + (q15_t)0x8296, (q15_t)0x1992, (q15_t)0x8295, (q15_t)0x198c, (q15_t)0x8294, + (q15_t)0x1986, (q15_t)0x8293, (q15_t)0x1980, (q15_t)0x8291, (q15_t)0x197a, + (q15_t)0x8290, (q15_t)0x1973, (q15_t)0x828f, (q15_t)0x196d, (q15_t)0x828e, + (q15_t)0x1967, (q15_t)0x828c, (q15_t)0x1961, (q15_t)0x828b, (q15_t)0x195b, + (q15_t)0x828a, (q15_t)0x1955, (q15_t)0x8289, (q15_t)0x194e, (q15_t)0x8287, + (q15_t)0x1948, (q15_t)0x8286, (q15_t)0x1942, (q15_t)0x8285, (q15_t)0x193c, + (q15_t)0x8284, (q15_t)0x1936, (q15_t)0x8282, (q15_t)0x1930, (q15_t)0x8281, + (q15_t)0x192a, (q15_t)0x8280, (q15_t)0x1923, (q15_t)0x827f, (q15_t)0x191d, + (q15_t)0x827e, (q15_t)0x1917, (q15_t)0x827c, (q15_t)0x1911, (q15_t)0x827b, + (q15_t)0x190b, (q15_t)0x827a, (q15_t)0x1905, (q15_t)0x8279, (q15_t)0x18fe, + (q15_t)0x8277, (q15_t)0x18f8, (q15_t)0x8276, (q15_t)0x18f2, (q15_t)0x8275, + (q15_t)0x18ec, (q15_t)0x8274, (q15_t)0x18e6, (q15_t)0x8272, (q15_t)0x18e0, + (q15_t)0x8271, (q15_t)0x18d9, (q15_t)0x8270, (q15_t)0x18d3, (q15_t)0x826f, + (q15_t)0x18cd, (q15_t)0x826e, (q15_t)0x18c7, (q15_t)0x826c, (q15_t)0x18c1, + (q15_t)0x826b, (q15_t)0x18bb, (q15_t)0x826a, (q15_t)0x18b4, (q15_t)0x8269, + (q15_t)0x18ae, (q15_t)0x8268, (q15_t)0x18a8, (q15_t)0x8266, (q15_t)0x18a2, + (q15_t)0x8265, (q15_t)0x189c, (q15_t)0x8264, (q15_t)0x1896, (q15_t)0x8263, + (q15_t)0x188f, (q15_t)0x8261, (q15_t)0x1889, (q15_t)0x8260, (q15_t)0x1883, + (q15_t)0x825f, (q15_t)0x187d, (q15_t)0x825e, (q15_t)0x1877, (q15_t)0x825d, + (q15_t)0x1871, (q15_t)0x825b, (q15_t)0x186a, (q15_t)0x825a, (q15_t)0x1864, + (q15_t)0x8259, (q15_t)0x185e, (q15_t)0x8258, (q15_t)0x1858, (q15_t)0x8257, + (q15_t)0x1852, (q15_t)0x8255, (q15_t)0x184c, (q15_t)0x8254, (q15_t)0x1845, + (q15_t)0x8253, (q15_t)0x183f, (q15_t)0x8252, (q15_t)0x1839, (q15_t)0x8251, + (q15_t)0x1833, (q15_t)0x8250, (q15_t)0x182d, (q15_t)0x824e, (q15_t)0x1827, + (q15_t)0x824d, (q15_t)0x1820, (q15_t)0x824c, (q15_t)0x181a, (q15_t)0x824b, + (q15_t)0x1814, (q15_t)0x824a, (q15_t)0x180e, (q15_t)0x8248, (q15_t)0x1808, + (q15_t)0x8247, (q15_t)0x1802, (q15_t)0x8246, (q15_t)0x17fb, (q15_t)0x8245, + (q15_t)0x17f5, (q15_t)0x8244, (q15_t)0x17ef, (q15_t)0x8243, (q15_t)0x17e9, + (q15_t)0x8241, (q15_t)0x17e3, (q15_t)0x8240, (q15_t)0x17dd, (q15_t)0x823f, + (q15_t)0x17d6, (q15_t)0x823e, (q15_t)0x17d0, (q15_t)0x823d, (q15_t)0x17ca, + (q15_t)0x823b, (q15_t)0x17c4, (q15_t)0x823a, (q15_t)0x17be, (q15_t)0x8239, + (q15_t)0x17b7, (q15_t)0x8238, (q15_t)0x17b1, (q15_t)0x8237, (q15_t)0x17ab, + (q15_t)0x8236, (q15_t)0x17a5, (q15_t)0x8234, (q15_t)0x179f, (q15_t)0x8233, + (q15_t)0x1799, (q15_t)0x8232, (q15_t)0x1792, (q15_t)0x8231, (q15_t)0x178c, + (q15_t)0x8230, (q15_t)0x1786, (q15_t)0x822f, (q15_t)0x1780, (q15_t)0x822e, + (q15_t)0x177a, (q15_t)0x822c, (q15_t)0x1774, (q15_t)0x822b, (q15_t)0x176d, + (q15_t)0x822a, (q15_t)0x1767, (q15_t)0x8229, (q15_t)0x1761, (q15_t)0x8228, + (q15_t)0x175b, (q15_t)0x8227, (q15_t)0x1755, (q15_t)0x8226, (q15_t)0x174e, + (q15_t)0x8224, (q15_t)0x1748, (q15_t)0x8223, (q15_t)0x1742, (q15_t)0x8222, + (q15_t)0x173c, (q15_t)0x8221, (q15_t)0x1736, (q15_t)0x8220, (q15_t)0x1730, + (q15_t)0x821f, (q15_t)0x1729, (q15_t)0x821e, (q15_t)0x1723, (q15_t)0x821c, + (q15_t)0x171d, (q15_t)0x821b, (q15_t)0x1717, (q15_t)0x821a, (q15_t)0x1711, + (q15_t)0x8219, (q15_t)0x170a, (q15_t)0x8218, (q15_t)0x1704, (q15_t)0x8217, + (q15_t)0x16fe, (q15_t)0x8216, (q15_t)0x16f8, (q15_t)0x8214, (q15_t)0x16f2, + (q15_t)0x8213, (q15_t)0x16ec, (q15_t)0x8212, (q15_t)0x16e5, (q15_t)0x8211, + (q15_t)0x16df, (q15_t)0x8210, (q15_t)0x16d9, (q15_t)0x820f, (q15_t)0x16d3, + (q15_t)0x820e, (q15_t)0x16cd, (q15_t)0x820d, (q15_t)0x16c6, (q15_t)0x820b, + (q15_t)0x16c0, (q15_t)0x820a, (q15_t)0x16ba, (q15_t)0x8209, (q15_t)0x16b4, + (q15_t)0x8208, (q15_t)0x16ae, (q15_t)0x8207, (q15_t)0x16a8, (q15_t)0x8206, + (q15_t)0x16a1, (q15_t)0x8205, (q15_t)0x169b, (q15_t)0x8204, (q15_t)0x1695, + (q15_t)0x8203, (q15_t)0x168f, (q15_t)0x8201, (q15_t)0x1689, (q15_t)0x8200, + (q15_t)0x1682, (q15_t)0x81ff, (q15_t)0x167c, (q15_t)0x81fe, (q15_t)0x1676, + (q15_t)0x81fd, (q15_t)0x1670, (q15_t)0x81fc, (q15_t)0x166a, (q15_t)0x81fb, + (q15_t)0x1664, (q15_t)0x81fa, (q15_t)0x165d, (q15_t)0x81f9, (q15_t)0x1657, + (q15_t)0x81f8, (q15_t)0x1651, (q15_t)0x81f6, (q15_t)0x164b, (q15_t)0x81f5, + (q15_t)0x1645, (q15_t)0x81f4, (q15_t)0x163e, (q15_t)0x81f3, (q15_t)0x1638, + (q15_t)0x81f2, (q15_t)0x1632, (q15_t)0x81f1, (q15_t)0x162c, (q15_t)0x81f0, + (q15_t)0x1626, (q15_t)0x81ef, (q15_t)0x161f, (q15_t)0x81ee, (q15_t)0x1619, + (q15_t)0x81ed, (q15_t)0x1613, (q15_t)0x81ec, (q15_t)0x160d, (q15_t)0x81ea, + (q15_t)0x1607, (q15_t)0x81e9, (q15_t)0x1601, (q15_t)0x81e8, (q15_t)0x15fa, + (q15_t)0x81e7, (q15_t)0x15f4, (q15_t)0x81e6, (q15_t)0x15ee, (q15_t)0x81e5, + (q15_t)0x15e8, (q15_t)0x81e4, (q15_t)0x15e2, (q15_t)0x81e3, (q15_t)0x15db, + (q15_t)0x81e2, (q15_t)0x15d5, (q15_t)0x81e1, (q15_t)0x15cf, (q15_t)0x81e0, + (q15_t)0x15c9, (q15_t)0x81df, (q15_t)0x15c3, (q15_t)0x81de, (q15_t)0x15bc, + (q15_t)0x81dc, (q15_t)0x15b6, (q15_t)0x81db, (q15_t)0x15b0, (q15_t)0x81da, + (q15_t)0x15aa, (q15_t)0x81d9, (q15_t)0x15a4, (q15_t)0x81d8, (q15_t)0x159d, + (q15_t)0x81d7, (q15_t)0x1597, (q15_t)0x81d6, (q15_t)0x1591, (q15_t)0x81d5, + (q15_t)0x158b, (q15_t)0x81d4, (q15_t)0x1585, (q15_t)0x81d3, (q15_t)0x157f, + (q15_t)0x81d2, (q15_t)0x1578, (q15_t)0x81d1, (q15_t)0x1572, (q15_t)0x81d0, + (q15_t)0x156c, (q15_t)0x81cf, (q15_t)0x1566, (q15_t)0x81ce, (q15_t)0x1560, + (q15_t)0x81cd, (q15_t)0x1559, (q15_t)0x81cc, (q15_t)0x1553, (q15_t)0x81cb, + (q15_t)0x154d, (q15_t)0x81c9, (q15_t)0x1547, (q15_t)0x81c8, (q15_t)0x1541, + (q15_t)0x81c7, (q15_t)0x153a, (q15_t)0x81c6, (q15_t)0x1534, (q15_t)0x81c5, + (q15_t)0x152e, (q15_t)0x81c4, (q15_t)0x1528, (q15_t)0x81c3, (q15_t)0x1522, + (q15_t)0x81c2, (q15_t)0x151b, (q15_t)0x81c1, (q15_t)0x1515, (q15_t)0x81c0, + (q15_t)0x150f, (q15_t)0x81bf, (q15_t)0x1509, (q15_t)0x81be, (q15_t)0x1503, + (q15_t)0x81bd, (q15_t)0x14fc, (q15_t)0x81bc, (q15_t)0x14f6, (q15_t)0x81bb, + (q15_t)0x14f0, (q15_t)0x81ba, (q15_t)0x14ea, (q15_t)0x81b9, (q15_t)0x14e4, + (q15_t)0x81b8, (q15_t)0x14dd, (q15_t)0x81b7, (q15_t)0x14d7, (q15_t)0x81b6, + (q15_t)0x14d1, (q15_t)0x81b5, (q15_t)0x14cb, (q15_t)0x81b4, (q15_t)0x14c5, + (q15_t)0x81b3, (q15_t)0x14be, (q15_t)0x81b2, (q15_t)0x14b8, (q15_t)0x81b1, + (q15_t)0x14b2, (q15_t)0x81b0, (q15_t)0x14ac, (q15_t)0x81af, (q15_t)0x14a6, + (q15_t)0x81ae, (q15_t)0x149f, (q15_t)0x81ad, (q15_t)0x1499, (q15_t)0x81ac, + (q15_t)0x1493, (q15_t)0x81ab, (q15_t)0x148d, (q15_t)0x81aa, (q15_t)0x1487, + (q15_t)0x81a9, (q15_t)0x1480, (q15_t)0x81a8, (q15_t)0x147a, (q15_t)0x81a7, + (q15_t)0x1474, (q15_t)0x81a6, (q15_t)0x146e, (q15_t)0x81a5, (q15_t)0x1468, + (q15_t)0x81a4, (q15_t)0x1461, (q15_t)0x81a3, (q15_t)0x145b, (q15_t)0x81a2, + (q15_t)0x1455, (q15_t)0x81a1, (q15_t)0x144f, (q15_t)0x81a0, (q15_t)0x1449, + (q15_t)0x819f, (q15_t)0x1442, (q15_t)0x819e, (q15_t)0x143c, (q15_t)0x819d, + (q15_t)0x1436, (q15_t)0x819c, (q15_t)0x1430, (q15_t)0x819b, (q15_t)0x142a, + (q15_t)0x819a, (q15_t)0x1423, (q15_t)0x8199, (q15_t)0x141d, (q15_t)0x8198, + (q15_t)0x1417, (q15_t)0x8197, (q15_t)0x1411, (q15_t)0x8196, (q15_t)0x140b, + (q15_t)0x8195, (q15_t)0x1404, (q15_t)0x8194, (q15_t)0x13fe, (q15_t)0x8193, + (q15_t)0x13f8, (q15_t)0x8192, (q15_t)0x13f2, (q15_t)0x8191, (q15_t)0x13eb, + (q15_t)0x8190, (q15_t)0x13e5, (q15_t)0x818f, (q15_t)0x13df, (q15_t)0x818e, + (q15_t)0x13d9, (q15_t)0x818d, (q15_t)0x13d3, (q15_t)0x818c, (q15_t)0x13cc, + (q15_t)0x818b, (q15_t)0x13c6, (q15_t)0x818a, (q15_t)0x13c0, (q15_t)0x8189, + (q15_t)0x13ba, (q15_t)0x8188, (q15_t)0x13b4, (q15_t)0x8187, (q15_t)0x13ad, + (q15_t)0x8186, (q15_t)0x13a7, (q15_t)0x8185, (q15_t)0x13a1, (q15_t)0x8184, + (q15_t)0x139b, (q15_t)0x8183, (q15_t)0x1395, (q15_t)0x8182, (q15_t)0x138e, + (q15_t)0x8181, (q15_t)0x1388, (q15_t)0x8180, (q15_t)0x1382, (q15_t)0x817f, + (q15_t)0x137c, (q15_t)0x817e, (q15_t)0x1376, (q15_t)0x817d, (q15_t)0x136f, + (q15_t)0x817c, (q15_t)0x1369, (q15_t)0x817c, (q15_t)0x1363, (q15_t)0x817b, + (q15_t)0x135d, (q15_t)0x817a, (q15_t)0x1356, (q15_t)0x8179, (q15_t)0x1350, + (q15_t)0x8178, (q15_t)0x134a, (q15_t)0x8177, (q15_t)0x1344, (q15_t)0x8176, + (q15_t)0x133e, (q15_t)0x8175, (q15_t)0x1337, (q15_t)0x8174, (q15_t)0x1331, + (q15_t)0x8173, (q15_t)0x132b, (q15_t)0x8172, (q15_t)0x1325, (q15_t)0x8171, + (q15_t)0x131f, (q15_t)0x8170, (q15_t)0x1318, (q15_t)0x816f, (q15_t)0x1312, + (q15_t)0x816e, (q15_t)0x130c, (q15_t)0x816d, (q15_t)0x1306, (q15_t)0x816c, + (q15_t)0x12ff, (q15_t)0x816c, (q15_t)0x12f9, (q15_t)0x816b, (q15_t)0x12f3, + (q15_t)0x816a, (q15_t)0x12ed, (q15_t)0x8169, (q15_t)0x12e7, (q15_t)0x8168, + (q15_t)0x12e0, (q15_t)0x8167, (q15_t)0x12da, (q15_t)0x8166, (q15_t)0x12d4, + (q15_t)0x8165, (q15_t)0x12ce, (q15_t)0x8164, (q15_t)0x12c8, (q15_t)0x8163, + (q15_t)0x12c1, (q15_t)0x8162, (q15_t)0x12bb, (q15_t)0x8161, (q15_t)0x12b5, + (q15_t)0x8160, (q15_t)0x12af, (q15_t)0x815f, (q15_t)0x12a8, (q15_t)0x815f, + (q15_t)0x12a2, (q15_t)0x815e, (q15_t)0x129c, (q15_t)0x815d, (q15_t)0x1296, + (q15_t)0x815c, (q15_t)0x1290, (q15_t)0x815b, (q15_t)0x1289, (q15_t)0x815a, + (q15_t)0x1283, (q15_t)0x8159, (q15_t)0x127d, (q15_t)0x8158, (q15_t)0x1277, + (q15_t)0x8157, (q15_t)0x1271, (q15_t)0x8156, (q15_t)0x126a, (q15_t)0x8155, + (q15_t)0x1264, (q15_t)0x8155, (q15_t)0x125e, (q15_t)0x8154, (q15_t)0x1258, + (q15_t)0x8153, (q15_t)0x1251, (q15_t)0x8152, (q15_t)0x124b, (q15_t)0x8151, + (q15_t)0x1245, (q15_t)0x8150, (q15_t)0x123f, (q15_t)0x814f, (q15_t)0x1239, + (q15_t)0x814e, (q15_t)0x1232, (q15_t)0x814d, (q15_t)0x122c, (q15_t)0x814c, + (q15_t)0x1226, (q15_t)0x814c, (q15_t)0x1220, (q15_t)0x814b, (q15_t)0x1219, + (q15_t)0x814a, (q15_t)0x1213, (q15_t)0x8149, (q15_t)0x120d, (q15_t)0x8148, + (q15_t)0x1207, (q15_t)0x8147, (q15_t)0x1201, (q15_t)0x8146, (q15_t)0x11fa, + (q15_t)0x8145, (q15_t)0x11f4, (q15_t)0x8145, (q15_t)0x11ee, (q15_t)0x8144, + (q15_t)0x11e8, (q15_t)0x8143, (q15_t)0x11e1, (q15_t)0x8142, (q15_t)0x11db, + (q15_t)0x8141, (q15_t)0x11d5, (q15_t)0x8140, (q15_t)0x11cf, (q15_t)0x813f, + (q15_t)0x11c9, (q15_t)0x813e, (q15_t)0x11c2, (q15_t)0x813d, (q15_t)0x11bc, + (q15_t)0x813d, (q15_t)0x11b6, (q15_t)0x813c, (q15_t)0x11b0, (q15_t)0x813b, + (q15_t)0x11a9, (q15_t)0x813a, (q15_t)0x11a3, (q15_t)0x8139, (q15_t)0x119d, + (q15_t)0x8138, (q15_t)0x1197, (q15_t)0x8137, (q15_t)0x1191, (q15_t)0x8137, + (q15_t)0x118a, (q15_t)0x8136, (q15_t)0x1184, (q15_t)0x8135, (q15_t)0x117e, + (q15_t)0x8134, (q15_t)0x1178, (q15_t)0x8133, (q15_t)0x1171, (q15_t)0x8132, + (q15_t)0x116b, (q15_t)0x8131, (q15_t)0x1165, (q15_t)0x8131, (q15_t)0x115f, + (q15_t)0x8130, (q15_t)0x1159, (q15_t)0x812f, (q15_t)0x1152, (q15_t)0x812e, + (q15_t)0x114c, (q15_t)0x812d, (q15_t)0x1146, (q15_t)0x812c, (q15_t)0x1140, + (q15_t)0x812b, (q15_t)0x1139, (q15_t)0x812b, (q15_t)0x1133, (q15_t)0x812a, + (q15_t)0x112d, (q15_t)0x8129, (q15_t)0x1127, (q15_t)0x8128, (q15_t)0x1121, + (q15_t)0x8127, (q15_t)0x111a, (q15_t)0x8126, (q15_t)0x1114, (q15_t)0x8126, + (q15_t)0x110e, (q15_t)0x8125, (q15_t)0x1108, (q15_t)0x8124, (q15_t)0x1101, + (q15_t)0x8123, (q15_t)0x10fb, (q15_t)0x8122, (q15_t)0x10f5, (q15_t)0x8121, + (q15_t)0x10ef, (q15_t)0x8121, (q15_t)0x10e8, (q15_t)0x8120, (q15_t)0x10e2, + (q15_t)0x811f, (q15_t)0x10dc, (q15_t)0x811e, (q15_t)0x10d6, (q15_t)0x811d, + (q15_t)0x10d0, (q15_t)0x811c, (q15_t)0x10c9, (q15_t)0x811c, (q15_t)0x10c3, + (q15_t)0x811b, (q15_t)0x10bd, (q15_t)0x811a, (q15_t)0x10b7, (q15_t)0x8119, + (q15_t)0x10b0, (q15_t)0x8118, (q15_t)0x10aa, (q15_t)0x8117, (q15_t)0x10a4, + (q15_t)0x8117, (q15_t)0x109e, (q15_t)0x8116, (q15_t)0x1098, (q15_t)0x8115, + (q15_t)0x1091, (q15_t)0x8114, (q15_t)0x108b, (q15_t)0x8113, (q15_t)0x1085, + (q15_t)0x8113, (q15_t)0x107f, (q15_t)0x8112, (q15_t)0x1078, (q15_t)0x8111, + (q15_t)0x1072, (q15_t)0x8110, (q15_t)0x106c, (q15_t)0x810f, (q15_t)0x1066, + (q15_t)0x810f, (q15_t)0x105f, (q15_t)0x810e, (q15_t)0x1059, (q15_t)0x810d, + (q15_t)0x1053, (q15_t)0x810c, (q15_t)0x104d, (q15_t)0x810b, (q15_t)0x1047, + (q15_t)0x810b, (q15_t)0x1040, (q15_t)0x810a, (q15_t)0x103a, (q15_t)0x8109, + (q15_t)0x1034, (q15_t)0x8108, (q15_t)0x102e, (q15_t)0x8107, (q15_t)0x1027, + (q15_t)0x8107, (q15_t)0x1021, (q15_t)0x8106, (q15_t)0x101b, (q15_t)0x8105, + (q15_t)0x1015, (q15_t)0x8104, (q15_t)0x100e, (q15_t)0x8103, (q15_t)0x1008, + (q15_t)0x8103, (q15_t)0x1002, (q15_t)0x8102, (q15_t)0xffc, (q15_t)0x8101, + (q15_t)0xff5, (q15_t)0x8100, (q15_t)0xfef, (q15_t)0x80ff, (q15_t)0xfe9, + (q15_t)0x80ff, (q15_t)0xfe3, (q15_t)0x80fe, (q15_t)0xfdd, (q15_t)0x80fd, + (q15_t)0xfd6, (q15_t)0x80fc, (q15_t)0xfd0, (q15_t)0x80fc, (q15_t)0xfca, + (q15_t)0x80fb, (q15_t)0xfc4, (q15_t)0x80fa, (q15_t)0xfbd, (q15_t)0x80f9, + (q15_t)0xfb7, (q15_t)0x80f8, (q15_t)0xfb1, (q15_t)0x80f8, (q15_t)0xfab, + (q15_t)0x80f7, (q15_t)0xfa4, (q15_t)0x80f6, (q15_t)0xf9e, (q15_t)0x80f5, + (q15_t)0xf98, (q15_t)0x80f5, (q15_t)0xf92, (q15_t)0x80f4, (q15_t)0xf8b, + (q15_t)0x80f3, (q15_t)0xf85, (q15_t)0x80f2, (q15_t)0xf7f, (q15_t)0x80f2, + (q15_t)0xf79, (q15_t)0x80f1, (q15_t)0xf73, (q15_t)0x80f0, (q15_t)0xf6c, + (q15_t)0x80ef, (q15_t)0xf66, (q15_t)0x80ef, (q15_t)0xf60, (q15_t)0x80ee, + (q15_t)0xf5a, (q15_t)0x80ed, (q15_t)0xf53, (q15_t)0x80ec, (q15_t)0xf4d, + (q15_t)0x80ec, (q15_t)0xf47, (q15_t)0x80eb, (q15_t)0xf41, (q15_t)0x80ea, + (q15_t)0xf3a, (q15_t)0x80e9, (q15_t)0xf34, (q15_t)0x80e9, (q15_t)0xf2e, + (q15_t)0x80e8, (q15_t)0xf28, (q15_t)0x80e7, (q15_t)0xf21, (q15_t)0x80e6, + (q15_t)0xf1b, (q15_t)0x80e6, (q15_t)0xf15, (q15_t)0x80e5, (q15_t)0xf0f, + (q15_t)0x80e4, (q15_t)0xf08, (q15_t)0x80e3, (q15_t)0xf02, (q15_t)0x80e3, + (q15_t)0xefc, (q15_t)0x80e2, (q15_t)0xef6, (q15_t)0x80e1, (q15_t)0xef0, + (q15_t)0x80e0, (q15_t)0xee9, (q15_t)0x80e0, (q15_t)0xee3, (q15_t)0x80df, + (q15_t)0xedd, (q15_t)0x80de, (q15_t)0xed7, (q15_t)0x80dd, (q15_t)0xed0, + (q15_t)0x80dd, (q15_t)0xeca, (q15_t)0x80dc, (q15_t)0xec4, (q15_t)0x80db, + (q15_t)0xebe, (q15_t)0x80db, (q15_t)0xeb7, (q15_t)0x80da, (q15_t)0xeb1, + (q15_t)0x80d9, (q15_t)0xeab, (q15_t)0x80d8, (q15_t)0xea5, (q15_t)0x80d8, + (q15_t)0xe9e, (q15_t)0x80d7, (q15_t)0xe98, (q15_t)0x80d6, (q15_t)0xe92, + (q15_t)0x80d6, (q15_t)0xe8c, (q15_t)0x80d5, (q15_t)0xe85, (q15_t)0x80d4, + (q15_t)0xe7f, (q15_t)0x80d3, (q15_t)0xe79, (q15_t)0x80d3, (q15_t)0xe73, + (q15_t)0x80d2, (q15_t)0xe6c, (q15_t)0x80d1, (q15_t)0xe66, (q15_t)0x80d1, + (q15_t)0xe60, (q15_t)0x80d0, (q15_t)0xe5a, (q15_t)0x80cf, (q15_t)0xe53, + (q15_t)0x80ce, (q15_t)0xe4d, (q15_t)0x80ce, (q15_t)0xe47, (q15_t)0x80cd, + (q15_t)0xe41, (q15_t)0x80cc, (q15_t)0xe3a, (q15_t)0x80cc, (q15_t)0xe34, + (q15_t)0x80cb, (q15_t)0xe2e, (q15_t)0x80ca, (q15_t)0xe28, (q15_t)0x80ca, + (q15_t)0xe22, (q15_t)0x80c9, (q15_t)0xe1b, (q15_t)0x80c8, (q15_t)0xe15, + (q15_t)0x80c7, (q15_t)0xe0f, (q15_t)0x80c7, (q15_t)0xe09, (q15_t)0x80c6, + (q15_t)0xe02, (q15_t)0x80c5, (q15_t)0xdfc, (q15_t)0x80c5, (q15_t)0xdf6, + (q15_t)0x80c4, (q15_t)0xdf0, (q15_t)0x80c3, (q15_t)0xde9, (q15_t)0x80c3, + (q15_t)0xde3, (q15_t)0x80c2, (q15_t)0xddd, (q15_t)0x80c1, (q15_t)0xdd7, + (q15_t)0x80c1, (q15_t)0xdd0, (q15_t)0x80c0, (q15_t)0xdca, (q15_t)0x80bf, + (q15_t)0xdc4, (q15_t)0x80bf, (q15_t)0xdbe, (q15_t)0x80be, (q15_t)0xdb7, + (q15_t)0x80bd, (q15_t)0xdb1, (q15_t)0x80bd, (q15_t)0xdab, (q15_t)0x80bc, + (q15_t)0xda5, (q15_t)0x80bb, (q15_t)0xd9e, (q15_t)0x80bb, (q15_t)0xd98, + (q15_t)0x80ba, (q15_t)0xd92, (q15_t)0x80b9, (q15_t)0xd8c, (q15_t)0x80b9, + (q15_t)0xd85, (q15_t)0x80b8, (q15_t)0xd7f, (q15_t)0x80b7, (q15_t)0xd79, + (q15_t)0x80b7, (q15_t)0xd73, (q15_t)0x80b6, (q15_t)0xd6c, (q15_t)0x80b5, + (q15_t)0xd66, (q15_t)0x80b5, (q15_t)0xd60, (q15_t)0x80b4, (q15_t)0xd5a, + (q15_t)0x80b3, (q15_t)0xd53, (q15_t)0x80b3, (q15_t)0xd4d, (q15_t)0x80b2, + (q15_t)0xd47, (q15_t)0x80b1, (q15_t)0xd41, (q15_t)0x80b1, (q15_t)0xd3a, + (q15_t)0x80b0, (q15_t)0xd34, (q15_t)0x80af, (q15_t)0xd2e, (q15_t)0x80af, + (q15_t)0xd28, (q15_t)0x80ae, (q15_t)0xd21, (q15_t)0x80ad, (q15_t)0xd1b, + (q15_t)0x80ad, (q15_t)0xd15, (q15_t)0x80ac, (q15_t)0xd0f, (q15_t)0x80ab, + (q15_t)0xd08, (q15_t)0x80ab, (q15_t)0xd02, (q15_t)0x80aa, (q15_t)0xcfc, + (q15_t)0x80aa, (q15_t)0xcf6, (q15_t)0x80a9, (q15_t)0xcef, (q15_t)0x80a8, + (q15_t)0xce9, (q15_t)0x80a8, (q15_t)0xce3, (q15_t)0x80a7, (q15_t)0xcdd, + (q15_t)0x80a6, (q15_t)0xcd6, (q15_t)0x80a6, (q15_t)0xcd0, (q15_t)0x80a5, + (q15_t)0xcca, (q15_t)0x80a5, (q15_t)0xcc4, (q15_t)0x80a4, (q15_t)0xcbd, + (q15_t)0x80a3, (q15_t)0xcb7, (q15_t)0x80a3, (q15_t)0xcb1, (q15_t)0x80a2, + (q15_t)0xcab, (q15_t)0x80a1, (q15_t)0xca4, (q15_t)0x80a1, (q15_t)0xc9e, + (q15_t)0x80a0, (q15_t)0xc98, (q15_t)0x80a0, (q15_t)0xc92, (q15_t)0x809f, + (q15_t)0xc8b, (q15_t)0x809e, (q15_t)0xc85, (q15_t)0x809e, (q15_t)0xc7f, + (q15_t)0x809d, (q15_t)0xc79, (q15_t)0x809c, (q15_t)0xc72, (q15_t)0x809c, + (q15_t)0xc6c, (q15_t)0x809b, (q15_t)0xc66, (q15_t)0x809b, (q15_t)0xc60, + (q15_t)0x809a, (q15_t)0xc59, (q15_t)0x8099, (q15_t)0xc53, (q15_t)0x8099, + (q15_t)0xc4d, (q15_t)0x8098, (q15_t)0xc47, (q15_t)0x8098, (q15_t)0xc40, + (q15_t)0x8097, (q15_t)0xc3a, (q15_t)0x8096, (q15_t)0xc34, (q15_t)0x8096, + (q15_t)0xc2e, (q15_t)0x8095, (q15_t)0xc27, (q15_t)0x8095, (q15_t)0xc21, + (q15_t)0x8094, (q15_t)0xc1b, (q15_t)0x8093, (q15_t)0xc14, (q15_t)0x8093, + (q15_t)0xc0e, (q15_t)0x8092, (q15_t)0xc08, (q15_t)0x8092, (q15_t)0xc02, + (q15_t)0x8091, (q15_t)0xbfb, (q15_t)0x8090, (q15_t)0xbf5, (q15_t)0x8090, + (q15_t)0xbef, (q15_t)0x808f, (q15_t)0xbe9, (q15_t)0x808f, (q15_t)0xbe2, + (q15_t)0x808e, (q15_t)0xbdc, (q15_t)0x808e, (q15_t)0xbd6, (q15_t)0x808d, + (q15_t)0xbd0, (q15_t)0x808c, (q15_t)0xbc9, (q15_t)0x808c, (q15_t)0xbc3, + (q15_t)0x808b, (q15_t)0xbbd, (q15_t)0x808b, (q15_t)0xbb7, (q15_t)0x808a, + (q15_t)0xbb0, (q15_t)0x8089, (q15_t)0xbaa, (q15_t)0x8089, (q15_t)0xba4, + (q15_t)0x8088, (q15_t)0xb9e, (q15_t)0x8088, (q15_t)0xb97, (q15_t)0x8087, + (q15_t)0xb91, (q15_t)0x8087, (q15_t)0xb8b, (q15_t)0x8086, (q15_t)0xb85, + (q15_t)0x8085, (q15_t)0xb7e, (q15_t)0x8085, (q15_t)0xb78, (q15_t)0x8084, + (q15_t)0xb72, (q15_t)0x8084, (q15_t)0xb6c, (q15_t)0x8083, (q15_t)0xb65, + (q15_t)0x8083, (q15_t)0xb5f, (q15_t)0x8082, (q15_t)0xb59, (q15_t)0x8082, + (q15_t)0xb53, (q15_t)0x8081, (q15_t)0xb4c, (q15_t)0x8080, (q15_t)0xb46, + (q15_t)0x8080, (q15_t)0xb40, (q15_t)0x807f, (q15_t)0xb3a, (q15_t)0x807f, + (q15_t)0xb33, (q15_t)0x807e, (q15_t)0xb2d, (q15_t)0x807e, (q15_t)0xb27, + (q15_t)0x807d, (q15_t)0xb20, (q15_t)0x807d, (q15_t)0xb1a, (q15_t)0x807c, + (q15_t)0xb14, (q15_t)0x807b, (q15_t)0xb0e, (q15_t)0x807b, (q15_t)0xb07, + (q15_t)0x807a, (q15_t)0xb01, (q15_t)0x807a, (q15_t)0xafb, (q15_t)0x8079, + (q15_t)0xaf5, (q15_t)0x8079, (q15_t)0xaee, (q15_t)0x8078, (q15_t)0xae8, + (q15_t)0x8078, (q15_t)0xae2, (q15_t)0x8077, (q15_t)0xadc, (q15_t)0x8077, + (q15_t)0xad5, (q15_t)0x8076, (q15_t)0xacf, (q15_t)0x8076, (q15_t)0xac9, + (q15_t)0x8075, (q15_t)0xac3, (q15_t)0x8075, (q15_t)0xabc, (q15_t)0x8074, + (q15_t)0xab6, (q15_t)0x8073, (q15_t)0xab0, (q15_t)0x8073, (q15_t)0xaaa, + (q15_t)0x8072, (q15_t)0xaa3, (q15_t)0x8072, (q15_t)0xa9d, (q15_t)0x8071, + (q15_t)0xa97, (q15_t)0x8071, (q15_t)0xa90, (q15_t)0x8070, (q15_t)0xa8a, + (q15_t)0x8070, (q15_t)0xa84, (q15_t)0x806f, (q15_t)0xa7e, (q15_t)0x806f, + (q15_t)0xa77, (q15_t)0x806e, (q15_t)0xa71, (q15_t)0x806e, (q15_t)0xa6b, + (q15_t)0x806d, (q15_t)0xa65, (q15_t)0x806d, (q15_t)0xa5e, (q15_t)0x806c, + (q15_t)0xa58, (q15_t)0x806c, (q15_t)0xa52, (q15_t)0x806b, (q15_t)0xa4c, + (q15_t)0x806b, (q15_t)0xa45, (q15_t)0x806a, (q15_t)0xa3f, (q15_t)0x806a, + (q15_t)0xa39, (q15_t)0x8069, (q15_t)0xa33, (q15_t)0x8069, (q15_t)0xa2c, + (q15_t)0x8068, (q15_t)0xa26, (q15_t)0x8068, (q15_t)0xa20, (q15_t)0x8067, + (q15_t)0xa19, (q15_t)0x8067, (q15_t)0xa13, (q15_t)0x8066, (q15_t)0xa0d, + (q15_t)0x8066, (q15_t)0xa07, (q15_t)0x8065, (q15_t)0xa00, (q15_t)0x8065, + (q15_t)0x9fa, (q15_t)0x8064, (q15_t)0x9f4, (q15_t)0x8064, (q15_t)0x9ee, + (q15_t)0x8063, (q15_t)0x9e7, (q15_t)0x8063, (q15_t)0x9e1, (q15_t)0x8062, + (q15_t)0x9db, (q15_t)0x8062, (q15_t)0x9d5, (q15_t)0x8061, (q15_t)0x9ce, + (q15_t)0x8061, (q15_t)0x9c8, (q15_t)0x8060, (q15_t)0x9c2, (q15_t)0x8060, + (q15_t)0x9bc, (q15_t)0x805f, (q15_t)0x9b5, (q15_t)0x805f, (q15_t)0x9af, + (q15_t)0x805e, (q15_t)0x9a9, (q15_t)0x805e, (q15_t)0x9a2, (q15_t)0x805d, + (q15_t)0x99c, (q15_t)0x805d, (q15_t)0x996, (q15_t)0x805d, (q15_t)0x990, + (q15_t)0x805c, (q15_t)0x989, (q15_t)0x805c, (q15_t)0x983, (q15_t)0x805b, + (q15_t)0x97d, (q15_t)0x805b, (q15_t)0x977, (q15_t)0x805a, (q15_t)0x970, + (q15_t)0x805a, (q15_t)0x96a, (q15_t)0x8059, (q15_t)0x964, (q15_t)0x8059, + (q15_t)0x95e, (q15_t)0x8058, (q15_t)0x957, (q15_t)0x8058, (q15_t)0x951, + (q15_t)0x8057, (q15_t)0x94b, (q15_t)0x8057, (q15_t)0x944, (q15_t)0x8057, + (q15_t)0x93e, (q15_t)0x8056, (q15_t)0x938, (q15_t)0x8056, (q15_t)0x932, + (q15_t)0x8055, (q15_t)0x92b, (q15_t)0x8055, (q15_t)0x925, (q15_t)0x8054, + (q15_t)0x91f, (q15_t)0x8054, (q15_t)0x919, (q15_t)0x8053, (q15_t)0x912, + (q15_t)0x8053, (q15_t)0x90c, (q15_t)0x8052, (q15_t)0x906, (q15_t)0x8052, + (q15_t)0x900, (q15_t)0x8052, (q15_t)0x8f9, (q15_t)0x8051, (q15_t)0x8f3, + (q15_t)0x8051, (q15_t)0x8ed, (q15_t)0x8050, (q15_t)0x8e6, (q15_t)0x8050, + (q15_t)0x8e0, (q15_t)0x804f, (q15_t)0x8da, (q15_t)0x804f, (q15_t)0x8d4, + (q15_t)0x804f, (q15_t)0x8cd, (q15_t)0x804e, (q15_t)0x8c7, (q15_t)0x804e, + (q15_t)0x8c1, (q15_t)0x804d, (q15_t)0x8bb, (q15_t)0x804d, (q15_t)0x8b4, + (q15_t)0x804c, (q15_t)0x8ae, (q15_t)0x804c, (q15_t)0x8a8, (q15_t)0x804c, + (q15_t)0x8a2, (q15_t)0x804b, (q15_t)0x89b, (q15_t)0x804b, (q15_t)0x895, + (q15_t)0x804a, (q15_t)0x88f, (q15_t)0x804a, (q15_t)0x888, (q15_t)0x8049, + (q15_t)0x882, (q15_t)0x8049, (q15_t)0x87c, (q15_t)0x8049, (q15_t)0x876, + (q15_t)0x8048, (q15_t)0x86f, (q15_t)0x8048, (q15_t)0x869, (q15_t)0x8047, + (q15_t)0x863, (q15_t)0x8047, (q15_t)0x85d, (q15_t)0x8047, (q15_t)0x856, + (q15_t)0x8046, (q15_t)0x850, (q15_t)0x8046, (q15_t)0x84a, (q15_t)0x8045, + (q15_t)0x843, (q15_t)0x8045, (q15_t)0x83d, (q15_t)0x8044, (q15_t)0x837, + (q15_t)0x8044, (q15_t)0x831, (q15_t)0x8044, (q15_t)0x82a, (q15_t)0x8043, + (q15_t)0x824, (q15_t)0x8043, (q15_t)0x81e, (q15_t)0x8042, (q15_t)0x818, + (q15_t)0x8042, (q15_t)0x811, (q15_t)0x8042, (q15_t)0x80b, (q15_t)0x8041, + (q15_t)0x805, (q15_t)0x8041, (q15_t)0x7fe, (q15_t)0x8040, (q15_t)0x7f8, + (q15_t)0x8040, (q15_t)0x7f2, (q15_t)0x8040, (q15_t)0x7ec, (q15_t)0x803f, + (q15_t)0x7e5, (q15_t)0x803f, (q15_t)0x7df, (q15_t)0x803f, (q15_t)0x7d9, + (q15_t)0x803e, (q15_t)0x7d3, (q15_t)0x803e, (q15_t)0x7cc, (q15_t)0x803d, + (q15_t)0x7c6, (q15_t)0x803d, (q15_t)0x7c0, (q15_t)0x803d, (q15_t)0x7ba, + (q15_t)0x803c, (q15_t)0x7b3, (q15_t)0x803c, (q15_t)0x7ad, (q15_t)0x803b, + (q15_t)0x7a7, (q15_t)0x803b, (q15_t)0x7a0, (q15_t)0x803b, (q15_t)0x79a, + (q15_t)0x803a, (q15_t)0x794, (q15_t)0x803a, (q15_t)0x78e, (q15_t)0x803a, + (q15_t)0x787, (q15_t)0x8039, (q15_t)0x781, (q15_t)0x8039, (q15_t)0x77b, + (q15_t)0x8039, (q15_t)0x775, (q15_t)0x8038, (q15_t)0x76e, (q15_t)0x8038, + (q15_t)0x768, (q15_t)0x8037, (q15_t)0x762, (q15_t)0x8037, (q15_t)0x75b, + (q15_t)0x8037, (q15_t)0x755, (q15_t)0x8036, (q15_t)0x74f, (q15_t)0x8036, + (q15_t)0x749, (q15_t)0x8036, (q15_t)0x742, (q15_t)0x8035, (q15_t)0x73c, + (q15_t)0x8035, (q15_t)0x736, (q15_t)0x8035, (q15_t)0x730, (q15_t)0x8034, + (q15_t)0x729, (q15_t)0x8034, (q15_t)0x723, (q15_t)0x8033, (q15_t)0x71d, + (q15_t)0x8033, (q15_t)0x716, (q15_t)0x8033, (q15_t)0x710, (q15_t)0x8032, + (q15_t)0x70a, (q15_t)0x8032, (q15_t)0x704, (q15_t)0x8032, (q15_t)0x6fd, + (q15_t)0x8031, (q15_t)0x6f7, (q15_t)0x8031, (q15_t)0x6f1, (q15_t)0x8031, + (q15_t)0x6ea, (q15_t)0x8030, (q15_t)0x6e4, (q15_t)0x8030, (q15_t)0x6de, + (q15_t)0x8030, (q15_t)0x6d8, (q15_t)0x802f, (q15_t)0x6d1, (q15_t)0x802f, + (q15_t)0x6cb, (q15_t)0x802f, (q15_t)0x6c5, (q15_t)0x802e, (q15_t)0x6bf, + (q15_t)0x802e, (q15_t)0x6b8, (q15_t)0x802e, (q15_t)0x6b2, (q15_t)0x802d, + (q15_t)0x6ac, (q15_t)0x802d, (q15_t)0x6a5, (q15_t)0x802d, (q15_t)0x69f, + (q15_t)0x802c, (q15_t)0x699, (q15_t)0x802c, (q15_t)0x693, (q15_t)0x802c, + (q15_t)0x68c, (q15_t)0x802b, (q15_t)0x686, (q15_t)0x802b, (q15_t)0x680, + (q15_t)0x802b, (q15_t)0x67a, (q15_t)0x802a, (q15_t)0x673, (q15_t)0x802a, + (q15_t)0x66d, (q15_t)0x802a, (q15_t)0x667, (q15_t)0x802a, (q15_t)0x660, + (q15_t)0x8029, (q15_t)0x65a, (q15_t)0x8029, (q15_t)0x654, (q15_t)0x8029, + (q15_t)0x64e, (q15_t)0x8028, (q15_t)0x647, (q15_t)0x8028, (q15_t)0x641, + (q15_t)0x8028, (q15_t)0x63b, (q15_t)0x8027, (q15_t)0x635, (q15_t)0x8027, + (q15_t)0x62e, (q15_t)0x8027, (q15_t)0x628, (q15_t)0x8026, (q15_t)0x622, + (q15_t)0x8026, (q15_t)0x61b, (q15_t)0x8026, (q15_t)0x615, (q15_t)0x8026, + (q15_t)0x60f, (q15_t)0x8025, (q15_t)0x609, (q15_t)0x8025, (q15_t)0x602, + (q15_t)0x8025, (q15_t)0x5fc, (q15_t)0x8024, (q15_t)0x5f6, (q15_t)0x8024, + (q15_t)0x5ef, (q15_t)0x8024, (q15_t)0x5e9, (q15_t)0x8023, (q15_t)0x5e3, + (q15_t)0x8023, (q15_t)0x5dd, (q15_t)0x8023, (q15_t)0x5d6, (q15_t)0x8023, + (q15_t)0x5d0, (q15_t)0x8022, (q15_t)0x5ca, (q15_t)0x8022, (q15_t)0x5c4, + (q15_t)0x8022, (q15_t)0x5bd, (q15_t)0x8021, (q15_t)0x5b7, (q15_t)0x8021, + (q15_t)0x5b1, (q15_t)0x8021, (q15_t)0x5aa, (q15_t)0x8021, (q15_t)0x5a4, + (q15_t)0x8020, (q15_t)0x59e, (q15_t)0x8020, (q15_t)0x598, (q15_t)0x8020, + (q15_t)0x591, (q15_t)0x8020, (q15_t)0x58b, (q15_t)0x801f, (q15_t)0x585, + (q15_t)0x801f, (q15_t)0x57f, (q15_t)0x801f, (q15_t)0x578, (q15_t)0x801e, + (q15_t)0x572, (q15_t)0x801e, (q15_t)0x56c, (q15_t)0x801e, (q15_t)0x565, + (q15_t)0x801e, (q15_t)0x55f, (q15_t)0x801d, (q15_t)0x559, (q15_t)0x801d, + (q15_t)0x553, (q15_t)0x801d, (q15_t)0x54c, (q15_t)0x801d, (q15_t)0x546, + (q15_t)0x801c, (q15_t)0x540, (q15_t)0x801c, (q15_t)0x539, (q15_t)0x801c, + (q15_t)0x533, (q15_t)0x801c, (q15_t)0x52d, (q15_t)0x801b, (q15_t)0x527, + (q15_t)0x801b, (q15_t)0x520, (q15_t)0x801b, (q15_t)0x51a, (q15_t)0x801b, + (q15_t)0x514, (q15_t)0x801a, (q15_t)0x50d, (q15_t)0x801a, (q15_t)0x507, + (q15_t)0x801a, (q15_t)0x501, (q15_t)0x801a, (q15_t)0x4fb, (q15_t)0x8019, + (q15_t)0x4f4, (q15_t)0x8019, (q15_t)0x4ee, (q15_t)0x8019, (q15_t)0x4e8, + (q15_t)0x8019, (q15_t)0x4e2, (q15_t)0x8018, (q15_t)0x4db, (q15_t)0x8018, + (q15_t)0x4d5, (q15_t)0x8018, (q15_t)0x4cf, (q15_t)0x8018, (q15_t)0x4c8, + (q15_t)0x8017, (q15_t)0x4c2, (q15_t)0x8017, (q15_t)0x4bc, (q15_t)0x8017, + (q15_t)0x4b6, (q15_t)0x8017, (q15_t)0x4af, (q15_t)0x8016, (q15_t)0x4a9, + (q15_t)0x8016, (q15_t)0x4a3, (q15_t)0x8016, (q15_t)0x49c, (q15_t)0x8016, + (q15_t)0x496, (q15_t)0x8016, (q15_t)0x490, (q15_t)0x8015, (q15_t)0x48a, + (q15_t)0x8015, (q15_t)0x483, (q15_t)0x8015, (q15_t)0x47d, (q15_t)0x8015, + (q15_t)0x477, (q15_t)0x8014, (q15_t)0x471, (q15_t)0x8014, (q15_t)0x46a, + (q15_t)0x8014, (q15_t)0x464, (q15_t)0x8014, (q15_t)0x45e, (q15_t)0x8014, + (q15_t)0x457, (q15_t)0x8013, (q15_t)0x451, (q15_t)0x8013, (q15_t)0x44b, + (q15_t)0x8013, (q15_t)0x445, (q15_t)0x8013, (q15_t)0x43e, (q15_t)0x8013, + (q15_t)0x438, (q15_t)0x8012, (q15_t)0x432, (q15_t)0x8012, (q15_t)0x42b, + (q15_t)0x8012, (q15_t)0x425, (q15_t)0x8012, (q15_t)0x41f, (q15_t)0x8012, + (q15_t)0x419, (q15_t)0x8011, (q15_t)0x412, (q15_t)0x8011, (q15_t)0x40c, + (q15_t)0x8011, (q15_t)0x406, (q15_t)0x8011, (q15_t)0x3ff, (q15_t)0x8011, + (q15_t)0x3f9, (q15_t)0x8010, (q15_t)0x3f3, (q15_t)0x8010, (q15_t)0x3ed, + (q15_t)0x8010, (q15_t)0x3e6, (q15_t)0x8010, (q15_t)0x3e0, (q15_t)0x8010, + (q15_t)0x3da, (q15_t)0x800f, (q15_t)0x3d4, (q15_t)0x800f, (q15_t)0x3cd, + (q15_t)0x800f, (q15_t)0x3c7, (q15_t)0x800f, (q15_t)0x3c1, (q15_t)0x800f, + (q15_t)0x3ba, (q15_t)0x800e, (q15_t)0x3b4, (q15_t)0x800e, (q15_t)0x3ae, + (q15_t)0x800e, (q15_t)0x3a8, (q15_t)0x800e, (q15_t)0x3a1, (q15_t)0x800e, + (q15_t)0x39b, (q15_t)0x800e, (q15_t)0x395, (q15_t)0x800d, (q15_t)0x38e, + (q15_t)0x800d, (q15_t)0x388, (q15_t)0x800d, (q15_t)0x382, (q15_t)0x800d, + (q15_t)0x37c, (q15_t)0x800d, (q15_t)0x375, (q15_t)0x800c, (q15_t)0x36f, + (q15_t)0x800c, (q15_t)0x369, (q15_t)0x800c, (q15_t)0x362, (q15_t)0x800c, + (q15_t)0x35c, (q15_t)0x800c, (q15_t)0x356, (q15_t)0x800c, (q15_t)0x350, + (q15_t)0x800b, (q15_t)0x349, (q15_t)0x800b, (q15_t)0x343, (q15_t)0x800b, + (q15_t)0x33d, (q15_t)0x800b, (q15_t)0x337, (q15_t)0x800b, (q15_t)0x330, + (q15_t)0x800b, (q15_t)0x32a, (q15_t)0x800b, (q15_t)0x324, (q15_t)0x800a, + (q15_t)0x31d, (q15_t)0x800a, (q15_t)0x317, (q15_t)0x800a, (q15_t)0x311, + (q15_t)0x800a, (q15_t)0x30b, (q15_t)0x800a, (q15_t)0x304, (q15_t)0x800a, + (q15_t)0x2fe, (q15_t)0x8009, (q15_t)0x2f8, (q15_t)0x8009, (q15_t)0x2f1, + (q15_t)0x8009, (q15_t)0x2eb, (q15_t)0x8009, (q15_t)0x2e5, (q15_t)0x8009, + (q15_t)0x2df, (q15_t)0x8009, (q15_t)0x2d8, (q15_t)0x8009, (q15_t)0x2d2, + (q15_t)0x8008, (q15_t)0x2cc, (q15_t)0x8008, (q15_t)0x2c5, (q15_t)0x8008, + (q15_t)0x2bf, (q15_t)0x8008, (q15_t)0x2b9, (q15_t)0x8008, (q15_t)0x2b3, + (q15_t)0x8008, (q15_t)0x2ac, (q15_t)0x8008, (q15_t)0x2a6, (q15_t)0x8008, + (q15_t)0x2a0, (q15_t)0x8007, (q15_t)0x299, (q15_t)0x8007, (q15_t)0x293, + (q15_t)0x8007, (q15_t)0x28d, (q15_t)0x8007, (q15_t)0x287, (q15_t)0x8007, + (q15_t)0x280, (q15_t)0x8007, (q15_t)0x27a, (q15_t)0x8007, (q15_t)0x274, + (q15_t)0x8007, (q15_t)0x26d, (q15_t)0x8006, (q15_t)0x267, (q15_t)0x8006, + (q15_t)0x261, (q15_t)0x8006, (q15_t)0x25b, (q15_t)0x8006, (q15_t)0x254, + (q15_t)0x8006, (q15_t)0x24e, (q15_t)0x8006, (q15_t)0x248, (q15_t)0x8006, + (q15_t)0x242, (q15_t)0x8006, (q15_t)0x23b, (q15_t)0x8005, (q15_t)0x235, + (q15_t)0x8005, (q15_t)0x22f, (q15_t)0x8005, (q15_t)0x228, (q15_t)0x8005, + (q15_t)0x222, (q15_t)0x8005, (q15_t)0x21c, (q15_t)0x8005, (q15_t)0x216, + (q15_t)0x8005, (q15_t)0x20f, (q15_t)0x8005, (q15_t)0x209, (q15_t)0x8005, + (q15_t)0x203, (q15_t)0x8005, (q15_t)0x1fc, (q15_t)0x8004, (q15_t)0x1f6, + (q15_t)0x8004, (q15_t)0x1f0, (q15_t)0x8004, (q15_t)0x1ea, (q15_t)0x8004, + (q15_t)0x1e3, (q15_t)0x8004, (q15_t)0x1dd, (q15_t)0x8004, (q15_t)0x1d7, + (q15_t)0x8004, (q15_t)0x1d0, (q15_t)0x8004, (q15_t)0x1ca, (q15_t)0x8004, + (q15_t)0x1c4, (q15_t)0x8004, (q15_t)0x1be, (q15_t)0x8004, (q15_t)0x1b7, + (q15_t)0x8003, (q15_t)0x1b1, (q15_t)0x8003, (q15_t)0x1ab, (q15_t)0x8003, + (q15_t)0x1a4, (q15_t)0x8003, (q15_t)0x19e, (q15_t)0x8003, (q15_t)0x198, + (q15_t)0x8003, (q15_t)0x192, (q15_t)0x8003, (q15_t)0x18b, (q15_t)0x8003, + (q15_t)0x185, (q15_t)0x8003, (q15_t)0x17f, (q15_t)0x8003, (q15_t)0x178, + (q15_t)0x8003, (q15_t)0x172, (q15_t)0x8003, (q15_t)0x16c, (q15_t)0x8003, + (q15_t)0x166, (q15_t)0x8002, (q15_t)0x15f, (q15_t)0x8002, (q15_t)0x159, + (q15_t)0x8002, (q15_t)0x153, (q15_t)0x8002, (q15_t)0x14d, (q15_t)0x8002, + (q15_t)0x146, (q15_t)0x8002, (q15_t)0x140, (q15_t)0x8002, (q15_t)0x13a, + (q15_t)0x8002, (q15_t)0x133, (q15_t)0x8002, (q15_t)0x12d, (q15_t)0x8002, + (q15_t)0x127, (q15_t)0x8002, (q15_t)0x121, (q15_t)0x8002, (q15_t)0x11a, + (q15_t)0x8002, (q15_t)0x114, (q15_t)0x8002, (q15_t)0x10e, (q15_t)0x8002, + (q15_t)0x107, (q15_t)0x8002, (q15_t)0x101, (q15_t)0x8002, (q15_t)0xfb, + (q15_t)0x8001, (q15_t)0xf5, (q15_t)0x8001, (q15_t)0xee, (q15_t)0x8001, + (q15_t)0xe8, (q15_t)0x8001, (q15_t)0xe2, (q15_t)0x8001, (q15_t)0xdb, + (q15_t)0x8001, (q15_t)0xd5, (q15_t)0x8001, (q15_t)0xcf, (q15_t)0x8001, + (q15_t)0xc9, (q15_t)0x8001, (q15_t)0xc2, (q15_t)0x8001, (q15_t)0xbc, + (q15_t)0x8001, (q15_t)0xb6, (q15_t)0x8001, (q15_t)0xaf, (q15_t)0x8001, + (q15_t)0xa9, (q15_t)0x8001, (q15_t)0xa3, (q15_t)0x8001, (q15_t)0x9d, + (q15_t)0x8001, (q15_t)0x96, (q15_t)0x8001, (q15_t)0x90, (q15_t)0x8001, + (q15_t)0x8a, (q15_t)0x8001, (q15_t)0x83, (q15_t)0x8001, (q15_t)0x7d, + (q15_t)0x8001, (q15_t)0x77, (q15_t)0x8001, (q15_t)0x71, (q15_t)0x8001, + (q15_t)0x6a, (q15_t)0x8001, (q15_t)0x64, (q15_t)0x8001, (q15_t)0x5e, + (q15_t)0x8001, (q15_t)0x57, (q15_t)0x8001, (q15_t)0x51, (q15_t)0x8001, + (q15_t)0x4b, (q15_t)0x8001, (q15_t)0x45, (q15_t)0x8001, (q15_t)0x3e, + (q15_t)0x8001, (q15_t)0x38, (q15_t)0x8001, (q15_t)0x32, (q15_t)0x8001, + (q15_t)0x2b, (q15_t)0x8001, (q15_t)0x25, (q15_t)0x8001, (q15_t)0x1f, + (q15_t)0x8001, (q15_t)0x19, (q15_t)0x8001, (q15_t)0x12, (q15_t)0x8001, + (q15_t)0xc, (q15_t)0x8001, (q15_t)0x6, (q15_t)0x8001}; /** @par - cosFactor tables are generated using the formula :
 cos_factors[n] = 2 * cos((2n+1)*pi/(4*N)) 
+ cosFactor tables are generated using the formula :
 cos_factors[n] = 2 *
+  cos((2n+1)*pi/(4*N)) 
@par C command to generate the table
@@ -2805,1383 +4438,2200 @@ static const q15_t __ALIGNED(4) WeightsQ15_8192[16384] = {
     cos_factors[i] = 2 * cos((2*i+1)*c/2);
   } 
@par - where N is the number of factors to generate and c is pi/(2*N) + where N is the number of factors to generate and c + is pi/(2*N) @par - Then converted to q15 format by multiplying with 2^31 and saturated if required. + Then converted to q15 format by multiplying with 2^31 and saturated if + required. */ static const q15_t __ALIGNED(4) cos_factorsQ15_128[128] = { - (q15_t)0x7fff, (q15_t)0x7ffa, (q15_t)0x7ff0, (q15_t)0x7fe1, (q15_t)0x7fce, (q15_t)0x7fb5, (q15_t)0x7f97, (q15_t)0x7f75, - (q15_t)0x7f4d, (q15_t)0x7f21, (q15_t)0x7ef0, (q15_t)0x7eba, (q15_t)0x7e7f, (q15_t)0x7e3f, (q15_t)0x7dfa, (q15_t)0x7db0, - (q15_t)0x7d62, (q15_t)0x7d0f, (q15_t)0x7cb7, (q15_t)0x7c5a, (q15_t)0x7bf8, (q15_t)0x7b92, (q15_t)0x7b26, (q15_t)0x7ab6, - (q15_t)0x7a42, (q15_t)0x79c8, (q15_t)0x794a, (q15_t)0x78c7, (q15_t)0x7840, (q15_t)0x77b4, (q15_t)0x7723, (q15_t)0x768e, - (q15_t)0x75f4, (q15_t)0x7555, (q15_t)0x74b2, (q15_t)0x740b, (q15_t)0x735f, (q15_t)0x72af, (q15_t)0x71fa, (q15_t)0x7141, - (q15_t)0x7083, (q15_t)0x6fc1, (q15_t)0x6efb, (q15_t)0x6e30, (q15_t)0x6d62, (q15_t)0x6c8f, (q15_t)0x6bb8, (q15_t)0x6adc, - (q15_t)0x69fd, (q15_t)0x6919, (q15_t)0x6832, (q15_t)0x6746, (q15_t)0x6657, (q15_t)0x6563, (q15_t)0x646c, (q15_t)0x6371, - (q15_t)0x6271, (q15_t)0x616f, (q15_t)0x6068, (q15_t)0x5f5e, (q15_t)0x5e50, (q15_t)0x5d3e, (q15_t)0x5c29, (q15_t)0x5b10, - (q15_t)0x59f3, (q15_t)0x58d4, (q15_t)0x57b0, (q15_t)0x568a, (q15_t)0x5560, (q15_t)0x5433, (q15_t)0x5302, (q15_t)0x51ce, - (q15_t)0x5097, (q15_t)0x4f5e, (q15_t)0x4e21, (q15_t)0x4ce1, (q15_t)0x4b9e, (q15_t)0x4a58, (q15_t)0x490f, (q15_t)0x47c3, - (q15_t)0x4675, (q15_t)0x4524, (q15_t)0x43d0, (q15_t)0x427a, (q15_t)0x4121, (q15_t)0x3fc5, (q15_t)0x3e68, (q15_t)0x3d07, - (q15_t)0x3ba5, (q15_t)0x3a40, (q15_t)0x38d8, (q15_t)0x376f, (q15_t)0x3604, (q15_t)0x3496, (q15_t)0x3326, (q15_t)0x31b5, - (q15_t)0x3041, (q15_t)0x2ecc, (q15_t)0x2d55, (q15_t)0x2bdc, (q15_t)0x2a61, (q15_t)0x28e5, (q15_t)0x2767, (q15_t)0x25e8, - (q15_t)0x2467, (q15_t)0x22e5, (q15_t)0x2161, (q15_t)0x1fdc, (q15_t)0x1e56, (q15_t)0x1ccf, (q15_t)0x1b47, (q15_t)0x19bd, - (q15_t)0x1833, (q15_t)0x16a8, (q15_t)0x151b, (q15_t)0x138e, (q15_t)0x1201, (q15_t)0x1072, (q15_t)0xee3, (q15_t)0xd53, - (q15_t)0xbc3, (q15_t)0xa33, (q15_t)0x8a2, (q15_t)0x710, (q15_t)0x57f, (q15_t)0x3ed, (q15_t)0x25b, (q15_t)0xc9 -}; + (q15_t)0x7fff, (q15_t)0x7ffa, (q15_t)0x7ff0, (q15_t)0x7fe1, (q15_t)0x7fce, + (q15_t)0x7fb5, (q15_t)0x7f97, (q15_t)0x7f75, (q15_t)0x7f4d, (q15_t)0x7f21, + (q15_t)0x7ef0, (q15_t)0x7eba, (q15_t)0x7e7f, (q15_t)0x7e3f, (q15_t)0x7dfa, + (q15_t)0x7db0, (q15_t)0x7d62, (q15_t)0x7d0f, (q15_t)0x7cb7, (q15_t)0x7c5a, + (q15_t)0x7bf8, (q15_t)0x7b92, (q15_t)0x7b26, (q15_t)0x7ab6, (q15_t)0x7a42, + (q15_t)0x79c8, (q15_t)0x794a, (q15_t)0x78c7, (q15_t)0x7840, (q15_t)0x77b4, + (q15_t)0x7723, (q15_t)0x768e, (q15_t)0x75f4, (q15_t)0x7555, (q15_t)0x74b2, + (q15_t)0x740b, (q15_t)0x735f, (q15_t)0x72af, (q15_t)0x71fa, (q15_t)0x7141, + (q15_t)0x7083, (q15_t)0x6fc1, (q15_t)0x6efb, (q15_t)0x6e30, (q15_t)0x6d62, + (q15_t)0x6c8f, (q15_t)0x6bb8, (q15_t)0x6adc, (q15_t)0x69fd, (q15_t)0x6919, + (q15_t)0x6832, (q15_t)0x6746, (q15_t)0x6657, (q15_t)0x6563, (q15_t)0x646c, + (q15_t)0x6371, (q15_t)0x6271, (q15_t)0x616f, (q15_t)0x6068, (q15_t)0x5f5e, + (q15_t)0x5e50, (q15_t)0x5d3e, (q15_t)0x5c29, (q15_t)0x5b10, (q15_t)0x59f3, + (q15_t)0x58d4, (q15_t)0x57b0, (q15_t)0x568a, (q15_t)0x5560, (q15_t)0x5433, + (q15_t)0x5302, (q15_t)0x51ce, (q15_t)0x5097, (q15_t)0x4f5e, (q15_t)0x4e21, + (q15_t)0x4ce1, (q15_t)0x4b9e, (q15_t)0x4a58, (q15_t)0x490f, (q15_t)0x47c3, + (q15_t)0x4675, (q15_t)0x4524, (q15_t)0x43d0, (q15_t)0x427a, (q15_t)0x4121, + (q15_t)0x3fc5, (q15_t)0x3e68, (q15_t)0x3d07, (q15_t)0x3ba5, (q15_t)0x3a40, + (q15_t)0x38d8, (q15_t)0x376f, (q15_t)0x3604, (q15_t)0x3496, (q15_t)0x3326, + (q15_t)0x31b5, (q15_t)0x3041, (q15_t)0x2ecc, (q15_t)0x2d55, (q15_t)0x2bdc, + (q15_t)0x2a61, (q15_t)0x28e5, (q15_t)0x2767, (q15_t)0x25e8, (q15_t)0x2467, + (q15_t)0x22e5, (q15_t)0x2161, (q15_t)0x1fdc, (q15_t)0x1e56, (q15_t)0x1ccf, + (q15_t)0x1b47, (q15_t)0x19bd, (q15_t)0x1833, (q15_t)0x16a8, (q15_t)0x151b, + (q15_t)0x138e, (q15_t)0x1201, (q15_t)0x1072, (q15_t)0xee3, (q15_t)0xd53, + (q15_t)0xbc3, (q15_t)0xa33, (q15_t)0x8a2, (q15_t)0x710, (q15_t)0x57f, + (q15_t)0x3ed, (q15_t)0x25b, (q15_t)0xc9}; static const q15_t __ALIGNED(4) cos_factorsQ15_512[512] = { - (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7ffe, (q15_t)0x7ffc, (q15_t)0x7ffb, (q15_t)0x7ff9, (q15_t)0x7ff7, - (q15_t)0x7ff4, (q15_t)0x7ff2, (q15_t)0x7fee, (q15_t)0x7feb, (q15_t)0x7fe7, (q15_t)0x7fe3, (q15_t)0x7fdf, (q15_t)0x7fda, - (q15_t)0x7fd6, (q15_t)0x7fd0, (q15_t)0x7fcb, (q15_t)0x7fc5, (q15_t)0x7fbf, (q15_t)0x7fb8, (q15_t)0x7fb1, (q15_t)0x7faa, - (q15_t)0x7fa3, (q15_t)0x7f9b, (q15_t)0x7f93, (q15_t)0x7f8b, (q15_t)0x7f82, (q15_t)0x7f79, (q15_t)0x7f70, (q15_t)0x7f67, - (q15_t)0x7f5d, (q15_t)0x7f53, (q15_t)0x7f48, (q15_t)0x7f3d, (q15_t)0x7f32, (q15_t)0x7f27, (q15_t)0x7f1b, (q15_t)0x7f0f, - (q15_t)0x7f03, (q15_t)0x7ef6, (q15_t)0x7ee9, (q15_t)0x7edc, (q15_t)0x7ecf, (q15_t)0x7ec1, (q15_t)0x7eb3, (q15_t)0x7ea4, - (q15_t)0x7e95, (q15_t)0x7e86, (q15_t)0x7e77, (q15_t)0x7e67, (q15_t)0x7e57, (q15_t)0x7e47, (q15_t)0x7e37, (q15_t)0x7e26, - (q15_t)0x7e14, (q15_t)0x7e03, (q15_t)0x7df1, (q15_t)0x7ddf, (q15_t)0x7dcd, (q15_t)0x7dba, (q15_t)0x7da7, (q15_t)0x7d94, - (q15_t)0x7d80, (q15_t)0x7d6c, (q15_t)0x7d58, (q15_t)0x7d43, (q15_t)0x7d2f, (q15_t)0x7d19, (q15_t)0x7d04, (q15_t)0x7cee, - (q15_t)0x7cd8, (q15_t)0x7cc2, (q15_t)0x7cab, (q15_t)0x7c94, (q15_t)0x7c7d, (q15_t)0x7c66, (q15_t)0x7c4e, (q15_t)0x7c36, - (q15_t)0x7c1d, (q15_t)0x7c05, (q15_t)0x7beb, (q15_t)0x7bd2, (q15_t)0x7bb9, (q15_t)0x7b9f, (q15_t)0x7b84, (q15_t)0x7b6a, - (q15_t)0x7b4f, (q15_t)0x7b34, (q15_t)0x7b19, (q15_t)0x7afd, (q15_t)0x7ae1, (q15_t)0x7ac5, (q15_t)0x7aa8, (q15_t)0x7a8b, - (q15_t)0x7a6e, (q15_t)0x7a50, (q15_t)0x7a33, (q15_t)0x7a15, (q15_t)0x79f6, (q15_t)0x79d8, (q15_t)0x79b9, (q15_t)0x7999, - (q15_t)0x797a, (q15_t)0x795a, (q15_t)0x793a, (q15_t)0x7919, (q15_t)0x78f9, (q15_t)0x78d8, (q15_t)0x78b6, (q15_t)0x7895, - (q15_t)0x7873, (q15_t)0x7851, (q15_t)0x782e, (q15_t)0x780c, (q15_t)0x77e9, (q15_t)0x77c5, (q15_t)0x77a2, (q15_t)0x777e, - (q15_t)0x775a, (q15_t)0x7735, (q15_t)0x7710, (q15_t)0x76eb, (q15_t)0x76c6, (q15_t)0x76a0, (q15_t)0x767b, (q15_t)0x7654, - (q15_t)0x762e, (q15_t)0x7607, (q15_t)0x75e0, (q15_t)0x75b9, (q15_t)0x7591, (q15_t)0x7569, (q15_t)0x7541, (q15_t)0x7519, - (q15_t)0x74f0, (q15_t)0x74c7, (q15_t)0x749e, (q15_t)0x7474, (q15_t)0x744a, (q15_t)0x7420, (q15_t)0x73f6, (q15_t)0x73cb, - (q15_t)0x73a0, (q15_t)0x7375, (q15_t)0x7349, (q15_t)0x731d, (q15_t)0x72f1, (q15_t)0x72c5, (q15_t)0x7298, (q15_t)0x726b, - (q15_t)0x723e, (q15_t)0x7211, (q15_t)0x71e3, (q15_t)0x71b5, (q15_t)0x7186, (q15_t)0x7158, (q15_t)0x7129, (q15_t)0x70fa, - (q15_t)0x70cb, (q15_t)0x709b, (q15_t)0x706b, (q15_t)0x703b, (q15_t)0x700a, (q15_t)0x6fda, (q15_t)0x6fa9, (q15_t)0x6f77, - (q15_t)0x6f46, (q15_t)0x6f14, (q15_t)0x6ee2, (q15_t)0x6eaf, (q15_t)0x6e7d, (q15_t)0x6e4a, (q15_t)0x6e17, (q15_t)0x6de3, - (q15_t)0x6db0, (q15_t)0x6d7c, (q15_t)0x6d48, (q15_t)0x6d13, (q15_t)0x6cde, (q15_t)0x6ca9, (q15_t)0x6c74, (q15_t)0x6c3f, - (q15_t)0x6c09, (q15_t)0x6bd3, (q15_t)0x6b9c, (q15_t)0x6b66, (q15_t)0x6b2f, (q15_t)0x6af8, (q15_t)0x6ac1, (q15_t)0x6a89, - (q15_t)0x6a51, (q15_t)0x6a19, (q15_t)0x69e1, (q15_t)0x69a8, (q15_t)0x696f, (q15_t)0x6936, (q15_t)0x68fd, (q15_t)0x68c3, - (q15_t)0x6889, (q15_t)0x684f, (q15_t)0x6815, (q15_t)0x67da, (q15_t)0x679f, (q15_t)0x6764, (q15_t)0x6729, (q15_t)0x66ed, - (q15_t)0x66b1, (q15_t)0x6675, (q15_t)0x6639, (q15_t)0x65fc, (q15_t)0x65bf, (q15_t)0x6582, (q15_t)0x6545, (q15_t)0x6507, - (q15_t)0x64c9, (q15_t)0x648b, (q15_t)0x644d, (q15_t)0x640e, (q15_t)0x63cf, (q15_t)0x6390, (q15_t)0x6351, (q15_t)0x6311, - (q15_t)0x62d2, (q15_t)0x6292, (q15_t)0x6251, (q15_t)0x6211, (q15_t)0x61d0, (q15_t)0x618f, (q15_t)0x614e, (q15_t)0x610d, - (q15_t)0x60cb, (q15_t)0x6089, (q15_t)0x6047, (q15_t)0x6004, (q15_t)0x5fc2, (q15_t)0x5f7f, (q15_t)0x5f3c, (q15_t)0x5ef9, - (q15_t)0x5eb5, (q15_t)0x5e71, (q15_t)0x5e2d, (q15_t)0x5de9, (q15_t)0x5da5, (q15_t)0x5d60, (q15_t)0x5d1b, (q15_t)0x5cd6, - (q15_t)0x5c91, (q15_t)0x5c4b, (q15_t)0x5c06, (q15_t)0x5bc0, (q15_t)0x5b79, (q15_t)0x5b33, (q15_t)0x5aec, (q15_t)0x5aa5, - (q15_t)0x5a5e, (q15_t)0x5a17, (q15_t)0x59d0, (q15_t)0x5988, (q15_t)0x5940, (q15_t)0x58f8, (q15_t)0x58af, (q15_t)0x5867, - (q15_t)0x581e, (q15_t)0x57d5, (q15_t)0x578c, (q15_t)0x5742, (q15_t)0x56f9, (q15_t)0x56af, (q15_t)0x5665, (q15_t)0x561a, - (q15_t)0x55d0, (q15_t)0x5585, (q15_t)0x553a, (q15_t)0x54ef, (q15_t)0x54a4, (q15_t)0x5458, (q15_t)0x540d, (q15_t)0x53c1, - (q15_t)0x5375, (q15_t)0x5328, (q15_t)0x52dc, (q15_t)0x528f, (q15_t)0x5242, (q15_t)0x51f5, (q15_t)0x51a8, (q15_t)0x515a, - (q15_t)0x510c, (q15_t)0x50bf, (q15_t)0x5070, (q15_t)0x5022, (q15_t)0x4fd4, (q15_t)0x4f85, (q15_t)0x4f36, (q15_t)0x4ee7, - (q15_t)0x4e98, (q15_t)0x4e48, (q15_t)0x4df9, (q15_t)0x4da9, (q15_t)0x4d59, (q15_t)0x4d09, (q15_t)0x4cb8, (q15_t)0x4c68, - (q15_t)0x4c17, (q15_t)0x4bc6, (q15_t)0x4b75, (q15_t)0x4b24, (q15_t)0x4ad2, (q15_t)0x4a81, (q15_t)0x4a2f, (q15_t)0x49dd, - (q15_t)0x498a, (q15_t)0x4938, (q15_t)0x48e6, (q15_t)0x4893, (q15_t)0x4840, (q15_t)0x47ed, (q15_t)0x479a, (q15_t)0x4746, - (q15_t)0x46f3, (q15_t)0x469f, (q15_t)0x464b, (q15_t)0x45f7, (q15_t)0x45a3, (q15_t)0x454e, (q15_t)0x44fa, (q15_t)0x44a5, - (q15_t)0x4450, (q15_t)0x43fb, (q15_t)0x43a5, (q15_t)0x4350, (q15_t)0x42fa, (q15_t)0x42a5, (q15_t)0x424f, (q15_t)0x41f9, - (q15_t)0x41a2, (q15_t)0x414c, (q15_t)0x40f6, (q15_t)0x409f, (q15_t)0x4048, (q15_t)0x3ff1, (q15_t)0x3f9a, (q15_t)0x3f43, - (q15_t)0x3eeb, (q15_t)0x3e93, (q15_t)0x3e3c, (q15_t)0x3de4, (q15_t)0x3d8c, (q15_t)0x3d33, (q15_t)0x3cdb, (q15_t)0x3c83, - (q15_t)0x3c2a, (q15_t)0x3bd1, (q15_t)0x3b78, (q15_t)0x3b1f, (q15_t)0x3ac6, (q15_t)0x3a6c, (q15_t)0x3a13, (q15_t)0x39b9, - (q15_t)0x395f, (q15_t)0x3906, (q15_t)0x38ab, (q15_t)0x3851, (q15_t)0x37f7, (q15_t)0x379c, (q15_t)0x3742, (q15_t)0x36e7, - (q15_t)0x368c, (q15_t)0x3631, (q15_t)0x35d6, (q15_t)0x357b, (q15_t)0x351f, (q15_t)0x34c4, (q15_t)0x3468, (q15_t)0x340c, - (q15_t)0x33b0, (q15_t)0x3354, (q15_t)0x32f8, (q15_t)0x329c, (q15_t)0x3240, (q15_t)0x31e3, (q15_t)0x3186, (q15_t)0x312a, - (q15_t)0x30cd, (q15_t)0x3070, (q15_t)0x3013, (q15_t)0x2fb5, (q15_t)0x2f58, (q15_t)0x2efb, (q15_t)0x2e9d, (q15_t)0x2e3f, - (q15_t)0x2de2, (q15_t)0x2d84, (q15_t)0x2d26, (q15_t)0x2cc8, (q15_t)0x2c69, (q15_t)0x2c0b, (q15_t)0x2bad, (q15_t)0x2b4e, - (q15_t)0x2aef, (q15_t)0x2a91, (q15_t)0x2a32, (q15_t)0x29d3, (q15_t)0x2974, (q15_t)0x2915, (q15_t)0x28b5, (q15_t)0x2856, - (q15_t)0x27f6, (q15_t)0x2797, (q15_t)0x2737, (q15_t)0x26d8, (q15_t)0x2678, (q15_t)0x2618, (q15_t)0x25b8, (q15_t)0x2558, - (q15_t)0x24f7, (q15_t)0x2497, (q15_t)0x2437, (q15_t)0x23d6, (q15_t)0x2376, (q15_t)0x2315, (q15_t)0x22b4, (q15_t)0x2254, - (q15_t)0x21f3, (q15_t)0x2192, (q15_t)0x2131, (q15_t)0x20d0, (q15_t)0x206e, (q15_t)0x200d, (q15_t)0x1fac, (q15_t)0x1f4a, - (q15_t)0x1ee9, (q15_t)0x1e87, (q15_t)0x1e25, (q15_t)0x1dc4, (q15_t)0x1d62, (q15_t)0x1d00, (q15_t)0x1c9e, (q15_t)0x1c3c, - (q15_t)0x1bda, (q15_t)0x1b78, (q15_t)0x1b16, (q15_t)0x1ab3, (q15_t)0x1a51, (q15_t)0x19ef, (q15_t)0x198c, (q15_t)0x192a, - (q15_t)0x18c7, (q15_t)0x1864, (q15_t)0x1802, (q15_t)0x179f, (q15_t)0x173c, (q15_t)0x16d9, (q15_t)0x1676, (q15_t)0x1613, - (q15_t)0x15b0, (q15_t)0x154d, (q15_t)0x14ea, (q15_t)0x1487, (q15_t)0x1423, (q15_t)0x13c0, (q15_t)0x135d, (q15_t)0x12f9, - (q15_t)0x1296, (q15_t)0x1232, (q15_t)0x11cf, (q15_t)0x116b, (q15_t)0x1108, (q15_t)0x10a4, (q15_t)0x1040, (q15_t)0xfdd, - (q15_t)0xf79, (q15_t)0xf15, (q15_t)0xeb1, (q15_t)0xe4d, (q15_t)0xde9, (q15_t)0xd85, (q15_t)0xd21, (q15_t)0xcbd, - (q15_t)0xc59, (q15_t)0xbf5, (q15_t)0xb91, (q15_t)0xb2d, (q15_t)0xac9, (q15_t)0xa65, (q15_t)0xa00, (q15_t)0x99c, - (q15_t)0x938, (q15_t)0x8d4, (q15_t)0x86f, (q15_t)0x80b, (q15_t)0x7a7, (q15_t)0x742, (q15_t)0x6de, (q15_t)0x67a, - (q15_t)0x615, (q15_t)0x5b1, (q15_t)0x54c, (q15_t)0x4e8, (q15_t)0x483, (q15_t)0x41f, (q15_t)0x3ba, (q15_t)0x356, - (q15_t)0x2f1, (q15_t)0x28d, (q15_t)0x228, (q15_t)0x1c4, (q15_t)0x15f, (q15_t)0xfb, (q15_t)0x96, (q15_t)0x32 -}; + (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7ffe, (q15_t)0x7ffc, + (q15_t)0x7ffb, (q15_t)0x7ff9, (q15_t)0x7ff7, (q15_t)0x7ff4, (q15_t)0x7ff2, + (q15_t)0x7fee, (q15_t)0x7feb, (q15_t)0x7fe7, (q15_t)0x7fe3, (q15_t)0x7fdf, + (q15_t)0x7fda, (q15_t)0x7fd6, (q15_t)0x7fd0, (q15_t)0x7fcb, (q15_t)0x7fc5, + (q15_t)0x7fbf, (q15_t)0x7fb8, (q15_t)0x7fb1, (q15_t)0x7faa, (q15_t)0x7fa3, + (q15_t)0x7f9b, (q15_t)0x7f93, (q15_t)0x7f8b, (q15_t)0x7f82, (q15_t)0x7f79, + (q15_t)0x7f70, (q15_t)0x7f67, (q15_t)0x7f5d, (q15_t)0x7f53, (q15_t)0x7f48, + (q15_t)0x7f3d, (q15_t)0x7f32, (q15_t)0x7f27, (q15_t)0x7f1b, (q15_t)0x7f0f, + (q15_t)0x7f03, (q15_t)0x7ef6, (q15_t)0x7ee9, (q15_t)0x7edc, (q15_t)0x7ecf, + (q15_t)0x7ec1, (q15_t)0x7eb3, (q15_t)0x7ea4, (q15_t)0x7e95, (q15_t)0x7e86, + (q15_t)0x7e77, (q15_t)0x7e67, (q15_t)0x7e57, (q15_t)0x7e47, (q15_t)0x7e37, + (q15_t)0x7e26, (q15_t)0x7e14, (q15_t)0x7e03, (q15_t)0x7df1, (q15_t)0x7ddf, + (q15_t)0x7dcd, (q15_t)0x7dba, (q15_t)0x7da7, (q15_t)0x7d94, (q15_t)0x7d80, + (q15_t)0x7d6c, (q15_t)0x7d58, (q15_t)0x7d43, (q15_t)0x7d2f, (q15_t)0x7d19, + (q15_t)0x7d04, (q15_t)0x7cee, (q15_t)0x7cd8, (q15_t)0x7cc2, (q15_t)0x7cab, + (q15_t)0x7c94, (q15_t)0x7c7d, (q15_t)0x7c66, (q15_t)0x7c4e, (q15_t)0x7c36, + (q15_t)0x7c1d, (q15_t)0x7c05, (q15_t)0x7beb, (q15_t)0x7bd2, (q15_t)0x7bb9, + (q15_t)0x7b9f, (q15_t)0x7b84, (q15_t)0x7b6a, (q15_t)0x7b4f, (q15_t)0x7b34, + (q15_t)0x7b19, (q15_t)0x7afd, (q15_t)0x7ae1, (q15_t)0x7ac5, (q15_t)0x7aa8, + (q15_t)0x7a8b, (q15_t)0x7a6e, (q15_t)0x7a50, (q15_t)0x7a33, (q15_t)0x7a15, + (q15_t)0x79f6, (q15_t)0x79d8, (q15_t)0x79b9, (q15_t)0x7999, (q15_t)0x797a, + (q15_t)0x795a, (q15_t)0x793a, (q15_t)0x7919, (q15_t)0x78f9, (q15_t)0x78d8, + (q15_t)0x78b6, (q15_t)0x7895, (q15_t)0x7873, (q15_t)0x7851, (q15_t)0x782e, + (q15_t)0x780c, (q15_t)0x77e9, (q15_t)0x77c5, (q15_t)0x77a2, (q15_t)0x777e, + (q15_t)0x775a, (q15_t)0x7735, (q15_t)0x7710, (q15_t)0x76eb, (q15_t)0x76c6, + (q15_t)0x76a0, (q15_t)0x767b, (q15_t)0x7654, (q15_t)0x762e, (q15_t)0x7607, + (q15_t)0x75e0, (q15_t)0x75b9, (q15_t)0x7591, (q15_t)0x7569, (q15_t)0x7541, + (q15_t)0x7519, (q15_t)0x74f0, (q15_t)0x74c7, (q15_t)0x749e, (q15_t)0x7474, + (q15_t)0x744a, (q15_t)0x7420, (q15_t)0x73f6, (q15_t)0x73cb, (q15_t)0x73a0, + (q15_t)0x7375, (q15_t)0x7349, (q15_t)0x731d, (q15_t)0x72f1, (q15_t)0x72c5, + (q15_t)0x7298, (q15_t)0x726b, (q15_t)0x723e, (q15_t)0x7211, (q15_t)0x71e3, + (q15_t)0x71b5, (q15_t)0x7186, (q15_t)0x7158, (q15_t)0x7129, (q15_t)0x70fa, + (q15_t)0x70cb, (q15_t)0x709b, (q15_t)0x706b, (q15_t)0x703b, (q15_t)0x700a, + (q15_t)0x6fda, (q15_t)0x6fa9, (q15_t)0x6f77, (q15_t)0x6f46, (q15_t)0x6f14, + (q15_t)0x6ee2, (q15_t)0x6eaf, (q15_t)0x6e7d, (q15_t)0x6e4a, (q15_t)0x6e17, + (q15_t)0x6de3, (q15_t)0x6db0, (q15_t)0x6d7c, (q15_t)0x6d48, (q15_t)0x6d13, + (q15_t)0x6cde, (q15_t)0x6ca9, (q15_t)0x6c74, (q15_t)0x6c3f, (q15_t)0x6c09, + (q15_t)0x6bd3, (q15_t)0x6b9c, (q15_t)0x6b66, (q15_t)0x6b2f, (q15_t)0x6af8, + (q15_t)0x6ac1, (q15_t)0x6a89, (q15_t)0x6a51, (q15_t)0x6a19, (q15_t)0x69e1, + (q15_t)0x69a8, (q15_t)0x696f, (q15_t)0x6936, (q15_t)0x68fd, (q15_t)0x68c3, + (q15_t)0x6889, (q15_t)0x684f, (q15_t)0x6815, (q15_t)0x67da, (q15_t)0x679f, + (q15_t)0x6764, (q15_t)0x6729, (q15_t)0x66ed, (q15_t)0x66b1, (q15_t)0x6675, + (q15_t)0x6639, (q15_t)0x65fc, (q15_t)0x65bf, (q15_t)0x6582, (q15_t)0x6545, + (q15_t)0x6507, (q15_t)0x64c9, (q15_t)0x648b, (q15_t)0x644d, (q15_t)0x640e, + (q15_t)0x63cf, (q15_t)0x6390, (q15_t)0x6351, (q15_t)0x6311, (q15_t)0x62d2, + (q15_t)0x6292, (q15_t)0x6251, (q15_t)0x6211, (q15_t)0x61d0, (q15_t)0x618f, + (q15_t)0x614e, (q15_t)0x610d, (q15_t)0x60cb, (q15_t)0x6089, (q15_t)0x6047, + (q15_t)0x6004, (q15_t)0x5fc2, (q15_t)0x5f7f, (q15_t)0x5f3c, (q15_t)0x5ef9, + (q15_t)0x5eb5, (q15_t)0x5e71, (q15_t)0x5e2d, (q15_t)0x5de9, (q15_t)0x5da5, + (q15_t)0x5d60, (q15_t)0x5d1b, (q15_t)0x5cd6, (q15_t)0x5c91, (q15_t)0x5c4b, + (q15_t)0x5c06, (q15_t)0x5bc0, (q15_t)0x5b79, (q15_t)0x5b33, (q15_t)0x5aec, + (q15_t)0x5aa5, (q15_t)0x5a5e, (q15_t)0x5a17, (q15_t)0x59d0, (q15_t)0x5988, + (q15_t)0x5940, (q15_t)0x58f8, (q15_t)0x58af, (q15_t)0x5867, (q15_t)0x581e, + (q15_t)0x57d5, (q15_t)0x578c, (q15_t)0x5742, (q15_t)0x56f9, (q15_t)0x56af, + (q15_t)0x5665, (q15_t)0x561a, (q15_t)0x55d0, (q15_t)0x5585, (q15_t)0x553a, + (q15_t)0x54ef, (q15_t)0x54a4, (q15_t)0x5458, (q15_t)0x540d, (q15_t)0x53c1, + (q15_t)0x5375, (q15_t)0x5328, (q15_t)0x52dc, (q15_t)0x528f, (q15_t)0x5242, + (q15_t)0x51f5, (q15_t)0x51a8, (q15_t)0x515a, (q15_t)0x510c, (q15_t)0x50bf, + (q15_t)0x5070, (q15_t)0x5022, (q15_t)0x4fd4, (q15_t)0x4f85, (q15_t)0x4f36, + (q15_t)0x4ee7, (q15_t)0x4e98, (q15_t)0x4e48, (q15_t)0x4df9, (q15_t)0x4da9, + (q15_t)0x4d59, (q15_t)0x4d09, (q15_t)0x4cb8, (q15_t)0x4c68, (q15_t)0x4c17, + (q15_t)0x4bc6, (q15_t)0x4b75, (q15_t)0x4b24, (q15_t)0x4ad2, (q15_t)0x4a81, + (q15_t)0x4a2f, (q15_t)0x49dd, (q15_t)0x498a, (q15_t)0x4938, (q15_t)0x48e6, + (q15_t)0x4893, (q15_t)0x4840, (q15_t)0x47ed, (q15_t)0x479a, (q15_t)0x4746, + (q15_t)0x46f3, (q15_t)0x469f, (q15_t)0x464b, (q15_t)0x45f7, (q15_t)0x45a3, + (q15_t)0x454e, (q15_t)0x44fa, (q15_t)0x44a5, (q15_t)0x4450, (q15_t)0x43fb, + (q15_t)0x43a5, (q15_t)0x4350, (q15_t)0x42fa, (q15_t)0x42a5, (q15_t)0x424f, + (q15_t)0x41f9, (q15_t)0x41a2, (q15_t)0x414c, (q15_t)0x40f6, (q15_t)0x409f, + (q15_t)0x4048, (q15_t)0x3ff1, (q15_t)0x3f9a, (q15_t)0x3f43, (q15_t)0x3eeb, + (q15_t)0x3e93, (q15_t)0x3e3c, (q15_t)0x3de4, (q15_t)0x3d8c, (q15_t)0x3d33, + (q15_t)0x3cdb, (q15_t)0x3c83, (q15_t)0x3c2a, (q15_t)0x3bd1, (q15_t)0x3b78, + (q15_t)0x3b1f, (q15_t)0x3ac6, (q15_t)0x3a6c, (q15_t)0x3a13, (q15_t)0x39b9, + (q15_t)0x395f, (q15_t)0x3906, (q15_t)0x38ab, (q15_t)0x3851, (q15_t)0x37f7, + (q15_t)0x379c, (q15_t)0x3742, (q15_t)0x36e7, (q15_t)0x368c, (q15_t)0x3631, + (q15_t)0x35d6, (q15_t)0x357b, (q15_t)0x351f, (q15_t)0x34c4, (q15_t)0x3468, + (q15_t)0x340c, (q15_t)0x33b0, (q15_t)0x3354, (q15_t)0x32f8, (q15_t)0x329c, + (q15_t)0x3240, (q15_t)0x31e3, (q15_t)0x3186, (q15_t)0x312a, (q15_t)0x30cd, + (q15_t)0x3070, (q15_t)0x3013, (q15_t)0x2fb5, (q15_t)0x2f58, (q15_t)0x2efb, + (q15_t)0x2e9d, (q15_t)0x2e3f, (q15_t)0x2de2, (q15_t)0x2d84, (q15_t)0x2d26, + (q15_t)0x2cc8, (q15_t)0x2c69, (q15_t)0x2c0b, (q15_t)0x2bad, (q15_t)0x2b4e, + (q15_t)0x2aef, (q15_t)0x2a91, (q15_t)0x2a32, (q15_t)0x29d3, (q15_t)0x2974, + (q15_t)0x2915, (q15_t)0x28b5, (q15_t)0x2856, (q15_t)0x27f6, (q15_t)0x2797, + (q15_t)0x2737, (q15_t)0x26d8, (q15_t)0x2678, (q15_t)0x2618, (q15_t)0x25b8, + (q15_t)0x2558, (q15_t)0x24f7, (q15_t)0x2497, (q15_t)0x2437, (q15_t)0x23d6, + (q15_t)0x2376, (q15_t)0x2315, (q15_t)0x22b4, (q15_t)0x2254, (q15_t)0x21f3, + (q15_t)0x2192, (q15_t)0x2131, (q15_t)0x20d0, (q15_t)0x206e, (q15_t)0x200d, + (q15_t)0x1fac, (q15_t)0x1f4a, (q15_t)0x1ee9, (q15_t)0x1e87, (q15_t)0x1e25, + (q15_t)0x1dc4, (q15_t)0x1d62, (q15_t)0x1d00, (q15_t)0x1c9e, (q15_t)0x1c3c, + (q15_t)0x1bda, (q15_t)0x1b78, (q15_t)0x1b16, (q15_t)0x1ab3, (q15_t)0x1a51, + (q15_t)0x19ef, (q15_t)0x198c, (q15_t)0x192a, (q15_t)0x18c7, (q15_t)0x1864, + (q15_t)0x1802, (q15_t)0x179f, (q15_t)0x173c, (q15_t)0x16d9, (q15_t)0x1676, + (q15_t)0x1613, (q15_t)0x15b0, (q15_t)0x154d, (q15_t)0x14ea, (q15_t)0x1487, + (q15_t)0x1423, (q15_t)0x13c0, (q15_t)0x135d, (q15_t)0x12f9, (q15_t)0x1296, + (q15_t)0x1232, (q15_t)0x11cf, (q15_t)0x116b, (q15_t)0x1108, (q15_t)0x10a4, + (q15_t)0x1040, (q15_t)0xfdd, (q15_t)0xf79, (q15_t)0xf15, (q15_t)0xeb1, + (q15_t)0xe4d, (q15_t)0xde9, (q15_t)0xd85, (q15_t)0xd21, (q15_t)0xcbd, + (q15_t)0xc59, (q15_t)0xbf5, (q15_t)0xb91, (q15_t)0xb2d, (q15_t)0xac9, + (q15_t)0xa65, (q15_t)0xa00, (q15_t)0x99c, (q15_t)0x938, (q15_t)0x8d4, + (q15_t)0x86f, (q15_t)0x80b, (q15_t)0x7a7, (q15_t)0x742, (q15_t)0x6de, + (q15_t)0x67a, (q15_t)0x615, (q15_t)0x5b1, (q15_t)0x54c, (q15_t)0x4e8, + (q15_t)0x483, (q15_t)0x41f, (q15_t)0x3ba, (q15_t)0x356, (q15_t)0x2f1, + (q15_t)0x28d, (q15_t)0x228, (q15_t)0x1c4, (q15_t)0x15f, (q15_t)0xfb, + (q15_t)0x96, (q15_t)0x32}; static const q15_t __ALIGNED(4) cos_factorsQ15_2048[2048] = { - (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, - (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffd, (q15_t)0x7ffd, - (q15_t)0x7ffd, (q15_t)0x7ffd, (q15_t)0x7ffc, (q15_t)0x7ffc, (q15_t)0x7ffb, (q15_t)0x7ffb, (q15_t)0x7ffb, (q15_t)0x7ffa, - (q15_t)0x7ffa, (q15_t)0x7ff9, (q15_t)0x7ff9, (q15_t)0x7ff8, (q15_t)0x7ff8, (q15_t)0x7ff7, (q15_t)0x7ff7, (q15_t)0x7ff6, - (q15_t)0x7ff5, (q15_t)0x7ff5, (q15_t)0x7ff4, (q15_t)0x7ff3, (q15_t)0x7ff3, (q15_t)0x7ff2, (q15_t)0x7ff1, (q15_t)0x7ff0, - (q15_t)0x7ff0, (q15_t)0x7fef, (q15_t)0x7fee, (q15_t)0x7fed, (q15_t)0x7fec, (q15_t)0x7fec, (q15_t)0x7feb, (q15_t)0x7fea, - (q15_t)0x7fe9, (q15_t)0x7fe8, (q15_t)0x7fe7, (q15_t)0x7fe6, (q15_t)0x7fe5, (q15_t)0x7fe4, (q15_t)0x7fe3, (q15_t)0x7fe2, - (q15_t)0x7fe1, (q15_t)0x7fe0, (q15_t)0x7fdf, (q15_t)0x7fdd, (q15_t)0x7fdc, (q15_t)0x7fdb, (q15_t)0x7fda, (q15_t)0x7fd9, - (q15_t)0x7fd7, (q15_t)0x7fd6, (q15_t)0x7fd5, (q15_t)0x7fd4, (q15_t)0x7fd2, (q15_t)0x7fd1, (q15_t)0x7fd0, (q15_t)0x7fce, - (q15_t)0x7fcd, (q15_t)0x7fcb, (q15_t)0x7fca, (q15_t)0x7fc9, (q15_t)0x7fc7, (q15_t)0x7fc6, (q15_t)0x7fc4, (q15_t)0x7fc3, - (q15_t)0x7fc1, (q15_t)0x7fc0, (q15_t)0x7fbe, (q15_t)0x7fbc, (q15_t)0x7fbb, (q15_t)0x7fb9, (q15_t)0x7fb7, (q15_t)0x7fb6, - (q15_t)0x7fb4, (q15_t)0x7fb2, (q15_t)0x7fb1, (q15_t)0x7faf, (q15_t)0x7fad, (q15_t)0x7fab, (q15_t)0x7fa9, (q15_t)0x7fa8, - (q15_t)0x7fa6, (q15_t)0x7fa4, (q15_t)0x7fa2, (q15_t)0x7fa0, (q15_t)0x7f9e, (q15_t)0x7f9c, (q15_t)0x7f9a, (q15_t)0x7f98, - (q15_t)0x7f96, (q15_t)0x7f94, (q15_t)0x7f92, (q15_t)0x7f90, (q15_t)0x7f8e, (q15_t)0x7f8c, (q15_t)0x7f8a, (q15_t)0x7f88, - (q15_t)0x7f86, (q15_t)0x7f83, (q15_t)0x7f81, (q15_t)0x7f7f, (q15_t)0x7f7d, (q15_t)0x7f7b, (q15_t)0x7f78, (q15_t)0x7f76, - (q15_t)0x7f74, (q15_t)0x7f71, (q15_t)0x7f6f, (q15_t)0x7f6d, (q15_t)0x7f6a, (q15_t)0x7f68, (q15_t)0x7f65, (q15_t)0x7f63, - (q15_t)0x7f60, (q15_t)0x7f5e, (q15_t)0x7f5b, (q15_t)0x7f59, (q15_t)0x7f56, (q15_t)0x7f54, (q15_t)0x7f51, (q15_t)0x7f4f, - (q15_t)0x7f4c, (q15_t)0x7f49, (q15_t)0x7f47, (q15_t)0x7f44, (q15_t)0x7f41, (q15_t)0x7f3f, (q15_t)0x7f3c, (q15_t)0x7f39, - (q15_t)0x7f36, (q15_t)0x7f34, (q15_t)0x7f31, (q15_t)0x7f2e, (q15_t)0x7f2b, (q15_t)0x7f28, (q15_t)0x7f25, (q15_t)0x7f23, - (q15_t)0x7f20, (q15_t)0x7f1d, (q15_t)0x7f1a, (q15_t)0x7f17, (q15_t)0x7f14, (q15_t)0x7f11, (q15_t)0x7f0e, (q15_t)0x7f0b, - (q15_t)0x7f08, (q15_t)0x7f04, (q15_t)0x7f01, (q15_t)0x7efe, (q15_t)0x7efb, (q15_t)0x7ef8, (q15_t)0x7ef5, (q15_t)0x7ef1, - (q15_t)0x7eee, (q15_t)0x7eeb, (q15_t)0x7ee8, (q15_t)0x7ee4, (q15_t)0x7ee1, (q15_t)0x7ede, (q15_t)0x7eda, (q15_t)0x7ed7, - (q15_t)0x7ed4, (q15_t)0x7ed0, (q15_t)0x7ecd, (q15_t)0x7ec9, (q15_t)0x7ec6, (q15_t)0x7ec3, (q15_t)0x7ebf, (q15_t)0x7ebb, - (q15_t)0x7eb8, (q15_t)0x7eb4, (q15_t)0x7eb1, (q15_t)0x7ead, (q15_t)0x7eaa, (q15_t)0x7ea6, (q15_t)0x7ea2, (q15_t)0x7e9f, - (q15_t)0x7e9b, (q15_t)0x7e97, (q15_t)0x7e94, (q15_t)0x7e90, (q15_t)0x7e8c, (q15_t)0x7e88, (q15_t)0x7e84, (q15_t)0x7e81, - (q15_t)0x7e7d, (q15_t)0x7e79, (q15_t)0x7e75, (q15_t)0x7e71, (q15_t)0x7e6d, (q15_t)0x7e69, (q15_t)0x7e65, (q15_t)0x7e61, - (q15_t)0x7e5d, (q15_t)0x7e59, (q15_t)0x7e55, (q15_t)0x7e51, (q15_t)0x7e4d, (q15_t)0x7e49, (q15_t)0x7e45, (q15_t)0x7e41, - (q15_t)0x7e3d, (q15_t)0x7e39, (q15_t)0x7e34, (q15_t)0x7e30, (q15_t)0x7e2c, (q15_t)0x7e28, (q15_t)0x7e24, (q15_t)0x7e1f, - (q15_t)0x7e1b, (q15_t)0x7e17, (q15_t)0x7e12, (q15_t)0x7e0e, (q15_t)0x7e0a, (q15_t)0x7e05, (q15_t)0x7e01, (q15_t)0x7dfc, - (q15_t)0x7df8, (q15_t)0x7df3, (q15_t)0x7def, (q15_t)0x7dea, (q15_t)0x7de6, (q15_t)0x7de1, (q15_t)0x7ddd, (q15_t)0x7dd8, - (q15_t)0x7dd4, (q15_t)0x7dcf, (q15_t)0x7dca, (q15_t)0x7dc6, (q15_t)0x7dc1, (q15_t)0x7dbc, (q15_t)0x7db8, (q15_t)0x7db3, - (q15_t)0x7dae, (q15_t)0x7da9, (q15_t)0x7da5, (q15_t)0x7da0, (q15_t)0x7d9b, (q15_t)0x7d96, (q15_t)0x7d91, (q15_t)0x7d8c, - (q15_t)0x7d87, (q15_t)0x7d82, (q15_t)0x7d7e, (q15_t)0x7d79, (q15_t)0x7d74, (q15_t)0x7d6f, (q15_t)0x7d6a, (q15_t)0x7d65, - (q15_t)0x7d60, (q15_t)0x7d5a, (q15_t)0x7d55, (q15_t)0x7d50, (q15_t)0x7d4b, (q15_t)0x7d46, (q15_t)0x7d41, (q15_t)0x7d3c, - (q15_t)0x7d36, (q15_t)0x7d31, (q15_t)0x7d2c, (q15_t)0x7d27, (q15_t)0x7d21, (q15_t)0x7d1c, (q15_t)0x7d17, (q15_t)0x7d11, - (q15_t)0x7d0c, (q15_t)0x7d07, (q15_t)0x7d01, (q15_t)0x7cfc, (q15_t)0x7cf6, (q15_t)0x7cf1, (q15_t)0x7cec, (q15_t)0x7ce6, - (q15_t)0x7ce1, (q15_t)0x7cdb, (q15_t)0x7cd5, (q15_t)0x7cd0, (q15_t)0x7cca, (q15_t)0x7cc5, (q15_t)0x7cbf, (q15_t)0x7cb9, - (q15_t)0x7cb4, (q15_t)0x7cae, (q15_t)0x7ca8, (q15_t)0x7ca3, (q15_t)0x7c9d, (q15_t)0x7c97, (q15_t)0x7c91, (q15_t)0x7c8c, - (q15_t)0x7c86, (q15_t)0x7c80, (q15_t)0x7c7a, (q15_t)0x7c74, (q15_t)0x7c6e, (q15_t)0x7c69, (q15_t)0x7c63, (q15_t)0x7c5d, - (q15_t)0x7c57, (q15_t)0x7c51, (q15_t)0x7c4b, (q15_t)0x7c45, (q15_t)0x7c3f, (q15_t)0x7c39, (q15_t)0x7c33, (q15_t)0x7c2d, - (q15_t)0x7c26, (q15_t)0x7c20, (q15_t)0x7c1a, (q15_t)0x7c14, (q15_t)0x7c0e, (q15_t)0x7c08, (q15_t)0x7c01, (q15_t)0x7bfb, - (q15_t)0x7bf5, (q15_t)0x7bef, (q15_t)0x7be8, (q15_t)0x7be2, (q15_t)0x7bdc, (q15_t)0x7bd5, (q15_t)0x7bcf, (q15_t)0x7bc9, - (q15_t)0x7bc2, (q15_t)0x7bbc, (q15_t)0x7bb5, (q15_t)0x7baf, (q15_t)0x7ba8, (q15_t)0x7ba2, (q15_t)0x7b9b, (q15_t)0x7b95, - (q15_t)0x7b8e, (q15_t)0x7b88, (q15_t)0x7b81, (q15_t)0x7b7a, (q15_t)0x7b74, (q15_t)0x7b6d, (q15_t)0x7b67, (q15_t)0x7b60, - (q15_t)0x7b59, (q15_t)0x7b52, (q15_t)0x7b4c, (q15_t)0x7b45, (q15_t)0x7b3e, (q15_t)0x7b37, (q15_t)0x7b31, (q15_t)0x7b2a, - (q15_t)0x7b23, (q15_t)0x7b1c, (q15_t)0x7b15, (q15_t)0x7b0e, (q15_t)0x7b07, (q15_t)0x7b00, (q15_t)0x7af9, (q15_t)0x7af2, - (q15_t)0x7aeb, (q15_t)0x7ae4, (q15_t)0x7add, (q15_t)0x7ad6, (q15_t)0x7acf, (q15_t)0x7ac8, (q15_t)0x7ac1, (q15_t)0x7aba, - (q15_t)0x7ab3, (q15_t)0x7aac, (q15_t)0x7aa4, (q15_t)0x7a9d, (q15_t)0x7a96, (q15_t)0x7a8f, (q15_t)0x7a87, (q15_t)0x7a80, - (q15_t)0x7a79, (q15_t)0x7a72, (q15_t)0x7a6a, (q15_t)0x7a63, (q15_t)0x7a5c, (q15_t)0x7a54, (q15_t)0x7a4d, (q15_t)0x7a45, - (q15_t)0x7a3e, (q15_t)0x7a36, (q15_t)0x7a2f, (q15_t)0x7a27, (q15_t)0x7a20, (q15_t)0x7a18, (q15_t)0x7a11, (q15_t)0x7a09, - (q15_t)0x7a02, (q15_t)0x79fa, (q15_t)0x79f2, (q15_t)0x79eb, (q15_t)0x79e3, (q15_t)0x79db, (q15_t)0x79d4, (q15_t)0x79cc, - (q15_t)0x79c4, (q15_t)0x79bc, (q15_t)0x79b5, (q15_t)0x79ad, (q15_t)0x79a5, (q15_t)0x799d, (q15_t)0x7995, (q15_t)0x798e, - (q15_t)0x7986, (q15_t)0x797e, (q15_t)0x7976, (q15_t)0x796e, (q15_t)0x7966, (q15_t)0x795e, (q15_t)0x7956, (q15_t)0x794e, - (q15_t)0x7946, (q15_t)0x793e, (q15_t)0x7936, (q15_t)0x792e, (q15_t)0x7926, (q15_t)0x791e, (q15_t)0x7915, (q15_t)0x790d, - (q15_t)0x7905, (q15_t)0x78fd, (q15_t)0x78f5, (q15_t)0x78ec, (q15_t)0x78e4, (q15_t)0x78dc, (q15_t)0x78d4, (q15_t)0x78cb, - (q15_t)0x78c3, (q15_t)0x78bb, (q15_t)0x78b2, (q15_t)0x78aa, (q15_t)0x78a2, (q15_t)0x7899, (q15_t)0x7891, (q15_t)0x7888, - (q15_t)0x7880, (q15_t)0x7877, (q15_t)0x786f, (q15_t)0x7866, (q15_t)0x785e, (q15_t)0x7855, (q15_t)0x784d, (q15_t)0x7844, - (q15_t)0x783b, (q15_t)0x7833, (q15_t)0x782a, (q15_t)0x7821, (q15_t)0x7819, (q15_t)0x7810, (q15_t)0x7807, (q15_t)0x77ff, - (q15_t)0x77f6, (q15_t)0x77ed, (q15_t)0x77e4, (q15_t)0x77db, (q15_t)0x77d3, (q15_t)0x77ca, (q15_t)0x77c1, (q15_t)0x77b8, - (q15_t)0x77af, (q15_t)0x77a6, (q15_t)0x779d, (q15_t)0x7794, (q15_t)0x778b, (q15_t)0x7782, (q15_t)0x7779, (q15_t)0x7770, - (q15_t)0x7767, (q15_t)0x775e, (q15_t)0x7755, (q15_t)0x774c, (q15_t)0x7743, (q15_t)0x773a, (q15_t)0x7731, (q15_t)0x7727, - (q15_t)0x771e, (q15_t)0x7715, (q15_t)0x770c, (q15_t)0x7703, (q15_t)0x76f9, (q15_t)0x76f0, (q15_t)0x76e7, (q15_t)0x76dd, - (q15_t)0x76d4, (q15_t)0x76cb, (q15_t)0x76c1, (q15_t)0x76b8, (q15_t)0x76af, (q15_t)0x76a5, (q15_t)0x769c, (q15_t)0x7692, - (q15_t)0x7689, (q15_t)0x767f, (q15_t)0x7676, (q15_t)0x766c, (q15_t)0x7663, (q15_t)0x7659, (q15_t)0x7650, (q15_t)0x7646, - (q15_t)0x763c, (q15_t)0x7633, (q15_t)0x7629, (q15_t)0x761f, (q15_t)0x7616, (q15_t)0x760c, (q15_t)0x7602, (q15_t)0x75f9, - (q15_t)0x75ef, (q15_t)0x75e5, (q15_t)0x75db, (q15_t)0x75d1, (q15_t)0x75c8, (q15_t)0x75be, (q15_t)0x75b4, (q15_t)0x75aa, - (q15_t)0x75a0, (q15_t)0x7596, (q15_t)0x758c, (q15_t)0x7582, (q15_t)0x7578, (q15_t)0x756e, (q15_t)0x7564, (q15_t)0x755a, - (q15_t)0x7550, (q15_t)0x7546, (q15_t)0x753c, (q15_t)0x7532, (q15_t)0x7528, (q15_t)0x751e, (q15_t)0x7514, (q15_t)0x7509, - (q15_t)0x74ff, (q15_t)0x74f5, (q15_t)0x74eb, (q15_t)0x74e1, (q15_t)0x74d6, (q15_t)0x74cc, (q15_t)0x74c2, (q15_t)0x74b7, - (q15_t)0x74ad, (q15_t)0x74a3, (q15_t)0x7498, (q15_t)0x748e, (q15_t)0x7484, (q15_t)0x7479, (q15_t)0x746f, (q15_t)0x7464, - (q15_t)0x745a, (q15_t)0x744f, (q15_t)0x7445, (q15_t)0x743a, (q15_t)0x7430, (q15_t)0x7425, (q15_t)0x741b, (q15_t)0x7410, - (q15_t)0x7406, (q15_t)0x73fb, (q15_t)0x73f0, (q15_t)0x73e6, (q15_t)0x73db, (q15_t)0x73d0, (q15_t)0x73c6, (q15_t)0x73bb, - (q15_t)0x73b0, (q15_t)0x73a5, (q15_t)0x739b, (q15_t)0x7390, (q15_t)0x7385, (q15_t)0x737a, (q15_t)0x736f, (q15_t)0x7364, - (q15_t)0x7359, (q15_t)0x734f, (q15_t)0x7344, (q15_t)0x7339, (q15_t)0x732e, (q15_t)0x7323, (q15_t)0x7318, (q15_t)0x730d, - (q15_t)0x7302, (q15_t)0x72f7, (q15_t)0x72ec, (q15_t)0x72e1, (q15_t)0x72d5, (q15_t)0x72ca, (q15_t)0x72bf, (q15_t)0x72b4, - (q15_t)0x72a9, (q15_t)0x729e, (q15_t)0x7293, (q15_t)0x7287, (q15_t)0x727c, (q15_t)0x7271, (q15_t)0x7266, (q15_t)0x725a, - (q15_t)0x724f, (q15_t)0x7244, (q15_t)0x7238, (q15_t)0x722d, (q15_t)0x7222, (q15_t)0x7216, (q15_t)0x720b, (q15_t)0x71ff, - (q15_t)0x71f4, (q15_t)0x71e9, (q15_t)0x71dd, (q15_t)0x71d2, (q15_t)0x71c6, (q15_t)0x71bb, (q15_t)0x71af, (q15_t)0x71a3, - (q15_t)0x7198, (q15_t)0x718c, (q15_t)0x7181, (q15_t)0x7175, (q15_t)0x7169, (q15_t)0x715e, (q15_t)0x7152, (q15_t)0x7146, - (q15_t)0x713b, (q15_t)0x712f, (q15_t)0x7123, (q15_t)0x7117, (q15_t)0x710c, (q15_t)0x7100, (q15_t)0x70f4, (q15_t)0x70e8, - (q15_t)0x70dc, (q15_t)0x70d1, (q15_t)0x70c5, (q15_t)0x70b9, (q15_t)0x70ad, (q15_t)0x70a1, (q15_t)0x7095, (q15_t)0x7089, - (q15_t)0x707d, (q15_t)0x7071, (q15_t)0x7065, (q15_t)0x7059, (q15_t)0x704d, (q15_t)0x7041, (q15_t)0x7035, (q15_t)0x7029, - (q15_t)0x701d, (q15_t)0x7010, (q15_t)0x7004, (q15_t)0x6ff8, (q15_t)0x6fec, (q15_t)0x6fe0, (q15_t)0x6fd3, (q15_t)0x6fc7, - (q15_t)0x6fbb, (q15_t)0x6faf, (q15_t)0x6fa2, (q15_t)0x6f96, (q15_t)0x6f8a, (q15_t)0x6f7d, (q15_t)0x6f71, (q15_t)0x6f65, - (q15_t)0x6f58, (q15_t)0x6f4c, (q15_t)0x6f3f, (q15_t)0x6f33, (q15_t)0x6f27, (q15_t)0x6f1a, (q15_t)0x6f0e, (q15_t)0x6f01, - (q15_t)0x6ef5, (q15_t)0x6ee8, (q15_t)0x6edc, (q15_t)0x6ecf, (q15_t)0x6ec2, (q15_t)0x6eb6, (q15_t)0x6ea9, (q15_t)0x6e9c, - (q15_t)0x6e90, (q15_t)0x6e83, (q15_t)0x6e76, (q15_t)0x6e6a, (q15_t)0x6e5d, (q15_t)0x6e50, (q15_t)0x6e44, (q15_t)0x6e37, - (q15_t)0x6e2a, (q15_t)0x6e1d, (q15_t)0x6e10, (q15_t)0x6e04, (q15_t)0x6df7, (q15_t)0x6dea, (q15_t)0x6ddd, (q15_t)0x6dd0, - (q15_t)0x6dc3, (q15_t)0x6db6, (q15_t)0x6da9, (q15_t)0x6d9c, (q15_t)0x6d8f, (q15_t)0x6d82, (q15_t)0x6d75, (q15_t)0x6d68, - (q15_t)0x6d5b, (q15_t)0x6d4e, (q15_t)0x6d41, (q15_t)0x6d34, (q15_t)0x6d27, (q15_t)0x6d1a, (q15_t)0x6d0c, (q15_t)0x6cff, - (q15_t)0x6cf2, (q15_t)0x6ce5, (q15_t)0x6cd8, (q15_t)0x6cca, (q15_t)0x6cbd, (q15_t)0x6cb0, (q15_t)0x6ca3, (q15_t)0x6c95, - (q15_t)0x6c88, (q15_t)0x6c7b, (q15_t)0x6c6d, (q15_t)0x6c60, (q15_t)0x6c53, (q15_t)0x6c45, (q15_t)0x6c38, (q15_t)0x6c2a, - (q15_t)0x6c1d, (q15_t)0x6c0f, (q15_t)0x6c02, (q15_t)0x6bf5, (q15_t)0x6be7, (q15_t)0x6bd9, (q15_t)0x6bcc, (q15_t)0x6bbe, - (q15_t)0x6bb1, (q15_t)0x6ba3, (q15_t)0x6b96, (q15_t)0x6b88, (q15_t)0x6b7a, (q15_t)0x6b6d, (q15_t)0x6b5f, (q15_t)0x6b51, - (q15_t)0x6b44, (q15_t)0x6b36, (q15_t)0x6b28, (q15_t)0x6b1a, (q15_t)0x6b0d, (q15_t)0x6aff, (q15_t)0x6af1, (q15_t)0x6ae3, - (q15_t)0x6ad5, (q15_t)0x6ac8, (q15_t)0x6aba, (q15_t)0x6aac, (q15_t)0x6a9e, (q15_t)0x6a90, (q15_t)0x6a82, (q15_t)0x6a74, - (q15_t)0x6a66, (q15_t)0x6a58, (q15_t)0x6a4a, (q15_t)0x6a3c, (q15_t)0x6a2e, (q15_t)0x6a20, (q15_t)0x6a12, (q15_t)0x6a04, - (q15_t)0x69f6, (q15_t)0x69e8, (q15_t)0x69da, (q15_t)0x69cb, (q15_t)0x69bd, (q15_t)0x69af, (q15_t)0x69a1, (q15_t)0x6993, - (q15_t)0x6985, (q15_t)0x6976, (q15_t)0x6968, (q15_t)0x695a, (q15_t)0x694b, (q15_t)0x693d, (q15_t)0x692f, (q15_t)0x6921, - (q15_t)0x6912, (q15_t)0x6904, (q15_t)0x68f5, (q15_t)0x68e7, (q15_t)0x68d9, (q15_t)0x68ca, (q15_t)0x68bc, (q15_t)0x68ad, - (q15_t)0x689f, (q15_t)0x6890, (q15_t)0x6882, (q15_t)0x6873, (q15_t)0x6865, (q15_t)0x6856, (q15_t)0x6848, (q15_t)0x6839, - (q15_t)0x682b, (q15_t)0x681c, (q15_t)0x680d, (q15_t)0x67ff, (q15_t)0x67f0, (q15_t)0x67e1, (q15_t)0x67d3, (q15_t)0x67c4, - (q15_t)0x67b5, (q15_t)0x67a6, (q15_t)0x6798, (q15_t)0x6789, (q15_t)0x677a, (q15_t)0x676b, (q15_t)0x675d, (q15_t)0x674e, - (q15_t)0x673f, (q15_t)0x6730, (q15_t)0x6721, (q15_t)0x6712, (q15_t)0x6703, (q15_t)0x66f4, (q15_t)0x66e5, (q15_t)0x66d6, - (q15_t)0x66c8, (q15_t)0x66b9, (q15_t)0x66aa, (q15_t)0x669b, (q15_t)0x668b, (q15_t)0x667c, (q15_t)0x666d, (q15_t)0x665e, - (q15_t)0x664f, (q15_t)0x6640, (q15_t)0x6631, (q15_t)0x6622, (q15_t)0x6613, (q15_t)0x6603, (q15_t)0x65f4, (q15_t)0x65e5, - (q15_t)0x65d6, (q15_t)0x65c7, (q15_t)0x65b7, (q15_t)0x65a8, (q15_t)0x6599, (q15_t)0x658a, (q15_t)0x657a, (q15_t)0x656b, - (q15_t)0x655c, (q15_t)0x654c, (q15_t)0x653d, (q15_t)0x652d, (q15_t)0x651e, (q15_t)0x650f, (q15_t)0x64ff, (q15_t)0x64f0, - (q15_t)0x64e0, (q15_t)0x64d1, (q15_t)0x64c1, (q15_t)0x64b2, (q15_t)0x64a2, (q15_t)0x6493, (q15_t)0x6483, (q15_t)0x6474, - (q15_t)0x6464, (q15_t)0x6454, (q15_t)0x6445, (q15_t)0x6435, (q15_t)0x6426, (q15_t)0x6416, (q15_t)0x6406, (q15_t)0x63f7, - (q15_t)0x63e7, (q15_t)0x63d7, (q15_t)0x63c7, (q15_t)0x63b8, (q15_t)0x63a8, (q15_t)0x6398, (q15_t)0x6388, (q15_t)0x6378, - (q15_t)0x6369, (q15_t)0x6359, (q15_t)0x6349, (q15_t)0x6339, (q15_t)0x6329, (q15_t)0x6319, (q15_t)0x6309, (q15_t)0x62f9, - (q15_t)0x62ea, (q15_t)0x62da, (q15_t)0x62ca, (q15_t)0x62ba, (q15_t)0x62aa, (q15_t)0x629a, (q15_t)0x628a, (q15_t)0x627a, - (q15_t)0x6269, (q15_t)0x6259, (q15_t)0x6249, (q15_t)0x6239, (q15_t)0x6229, (q15_t)0x6219, (q15_t)0x6209, (q15_t)0x61f9, - (q15_t)0x61e8, (q15_t)0x61d8, (q15_t)0x61c8, (q15_t)0x61b8, (q15_t)0x61a8, (q15_t)0x6197, (q15_t)0x6187, (q15_t)0x6177, - (q15_t)0x6166, (q15_t)0x6156, (q15_t)0x6146, (q15_t)0x6135, (q15_t)0x6125, (q15_t)0x6115, (q15_t)0x6104, (q15_t)0x60f4, - (q15_t)0x60e4, (q15_t)0x60d3, (q15_t)0x60c3, (q15_t)0x60b2, (q15_t)0x60a2, (q15_t)0x6091, (q15_t)0x6081, (q15_t)0x6070, - (q15_t)0x6060, (q15_t)0x604f, (q15_t)0x603f, (q15_t)0x602e, (q15_t)0x601d, (q15_t)0x600d, (q15_t)0x5ffc, (q15_t)0x5fec, - (q15_t)0x5fdb, (q15_t)0x5fca, (q15_t)0x5fba, (q15_t)0x5fa9, (q15_t)0x5f98, (q15_t)0x5f87, (q15_t)0x5f77, (q15_t)0x5f66, - (q15_t)0x5f55, (q15_t)0x5f44, (q15_t)0x5f34, (q15_t)0x5f23, (q15_t)0x5f12, (q15_t)0x5f01, (q15_t)0x5ef0, (q15_t)0x5edf, - (q15_t)0x5ecf, (q15_t)0x5ebe, (q15_t)0x5ead, (q15_t)0x5e9c, (q15_t)0x5e8b, (q15_t)0x5e7a, (q15_t)0x5e69, (q15_t)0x5e58, - (q15_t)0x5e47, (q15_t)0x5e36, (q15_t)0x5e25, (q15_t)0x5e14, (q15_t)0x5e03, (q15_t)0x5df2, (q15_t)0x5de1, (q15_t)0x5dd0, - (q15_t)0x5dbf, (q15_t)0x5dad, (q15_t)0x5d9c, (q15_t)0x5d8b, (q15_t)0x5d7a, (q15_t)0x5d69, (q15_t)0x5d58, (q15_t)0x5d46, - (q15_t)0x5d35, (q15_t)0x5d24, (q15_t)0x5d13, (q15_t)0x5d01, (q15_t)0x5cf0, (q15_t)0x5cdf, (q15_t)0x5cce, (q15_t)0x5cbc, - (q15_t)0x5cab, (q15_t)0x5c9a, (q15_t)0x5c88, (q15_t)0x5c77, (q15_t)0x5c66, (q15_t)0x5c54, (q15_t)0x5c43, (q15_t)0x5c31, - (q15_t)0x5c20, (q15_t)0x5c0e, (q15_t)0x5bfd, (q15_t)0x5beb, (q15_t)0x5bda, (q15_t)0x5bc8, (q15_t)0x5bb7, (q15_t)0x5ba5, - (q15_t)0x5b94, (q15_t)0x5b82, (q15_t)0x5b71, (q15_t)0x5b5f, (q15_t)0x5b4d, (q15_t)0x5b3c, (q15_t)0x5b2a, (q15_t)0x5b19, - (q15_t)0x5b07, (q15_t)0x5af5, (q15_t)0x5ae4, (q15_t)0x5ad2, (q15_t)0x5ac0, (q15_t)0x5aae, (q15_t)0x5a9d, (q15_t)0x5a8b, - (q15_t)0x5a79, (q15_t)0x5a67, (q15_t)0x5a56, (q15_t)0x5a44, (q15_t)0x5a32, (q15_t)0x5a20, (q15_t)0x5a0e, (q15_t)0x59fc, - (q15_t)0x59ea, (q15_t)0x59d9, (q15_t)0x59c7, (q15_t)0x59b5, (q15_t)0x59a3, (q15_t)0x5991, (q15_t)0x597f, (q15_t)0x596d, - (q15_t)0x595b, (q15_t)0x5949, (q15_t)0x5937, (q15_t)0x5925, (q15_t)0x5913, (q15_t)0x5901, (q15_t)0x58ef, (q15_t)0x58dd, - (q15_t)0x58cb, (q15_t)0x58b8, (q15_t)0x58a6, (q15_t)0x5894, (q15_t)0x5882, (q15_t)0x5870, (q15_t)0x585e, (q15_t)0x584b, - (q15_t)0x5839, (q15_t)0x5827, (q15_t)0x5815, (q15_t)0x5803, (q15_t)0x57f0, (q15_t)0x57de, (q15_t)0x57cc, (q15_t)0x57b9, - (q15_t)0x57a7, (q15_t)0x5795, (q15_t)0x5783, (q15_t)0x5770, (q15_t)0x575e, (q15_t)0x574b, (q15_t)0x5739, (q15_t)0x5727, - (q15_t)0x5714, (q15_t)0x5702, (q15_t)0x56ef, (q15_t)0x56dd, (q15_t)0x56ca, (q15_t)0x56b8, (q15_t)0x56a5, (q15_t)0x5693, - (q15_t)0x5680, (q15_t)0x566e, (q15_t)0x565b, (q15_t)0x5649, (q15_t)0x5636, (q15_t)0x5624, (q15_t)0x5611, (q15_t)0x55fe, - (q15_t)0x55ec, (q15_t)0x55d9, (q15_t)0x55c7, (q15_t)0x55b4, (q15_t)0x55a1, (q15_t)0x558f, (q15_t)0x557c, (q15_t)0x5569, - (q15_t)0x5556, (q15_t)0x5544, (q15_t)0x5531, (q15_t)0x551e, (q15_t)0x550b, (q15_t)0x54f9, (q15_t)0x54e6, (q15_t)0x54d3, - (q15_t)0x54c0, (q15_t)0x54ad, (q15_t)0x549a, (q15_t)0x5488, (q15_t)0x5475, (q15_t)0x5462, (q15_t)0x544f, (q15_t)0x543c, - (q15_t)0x5429, (q15_t)0x5416, (q15_t)0x5403, (q15_t)0x53f0, (q15_t)0x53dd, (q15_t)0x53ca, (q15_t)0x53b7, (q15_t)0x53a4, - (q15_t)0x5391, (q15_t)0x537e, (q15_t)0x536b, (q15_t)0x5358, (q15_t)0x5345, (q15_t)0x5332, (q15_t)0x531f, (q15_t)0x530c, - (q15_t)0x52f8, (q15_t)0x52e5, (q15_t)0x52d2, (q15_t)0x52bf, (q15_t)0x52ac, (q15_t)0x5299, (q15_t)0x5285, (q15_t)0x5272, - (q15_t)0x525f, (q15_t)0x524c, (q15_t)0x5238, (q15_t)0x5225, (q15_t)0x5212, (q15_t)0x51ff, (q15_t)0x51eb, (q15_t)0x51d8, - (q15_t)0x51c5, (q15_t)0x51b1, (q15_t)0x519e, (q15_t)0x518b, (q15_t)0x5177, (q15_t)0x5164, (q15_t)0x5150, (q15_t)0x513d, - (q15_t)0x512a, (q15_t)0x5116, (q15_t)0x5103, (q15_t)0x50ef, (q15_t)0x50dc, (q15_t)0x50c8, (q15_t)0x50b5, (q15_t)0x50a1, - (q15_t)0x508e, (q15_t)0x507a, (q15_t)0x5067, (q15_t)0x5053, (q15_t)0x503f, (q15_t)0x502c, (q15_t)0x5018, (q15_t)0x5005, - (q15_t)0x4ff1, (q15_t)0x4fdd, (q15_t)0x4fca, (q15_t)0x4fb6, (q15_t)0x4fa2, (q15_t)0x4f8f, (q15_t)0x4f7b, (q15_t)0x4f67, - (q15_t)0x4f54, (q15_t)0x4f40, (q15_t)0x4f2c, (q15_t)0x4f18, (q15_t)0x4f05, (q15_t)0x4ef1, (q15_t)0x4edd, (q15_t)0x4ec9, - (q15_t)0x4eb6, (q15_t)0x4ea2, (q15_t)0x4e8e, (q15_t)0x4e7a, (q15_t)0x4e66, (q15_t)0x4e52, (q15_t)0x4e3e, (q15_t)0x4e2a, - (q15_t)0x4e17, (q15_t)0x4e03, (q15_t)0x4def, (q15_t)0x4ddb, (q15_t)0x4dc7, (q15_t)0x4db3, (q15_t)0x4d9f, (q15_t)0x4d8b, - (q15_t)0x4d77, (q15_t)0x4d63, (q15_t)0x4d4f, (q15_t)0x4d3b, (q15_t)0x4d27, (q15_t)0x4d13, (q15_t)0x4cff, (q15_t)0x4ceb, - (q15_t)0x4cd6, (q15_t)0x4cc2, (q15_t)0x4cae, (q15_t)0x4c9a, (q15_t)0x4c86, (q15_t)0x4c72, (q15_t)0x4c5e, (q15_t)0x4c49, - (q15_t)0x4c35, (q15_t)0x4c21, (q15_t)0x4c0d, (q15_t)0x4bf9, (q15_t)0x4be4, (q15_t)0x4bd0, (q15_t)0x4bbc, (q15_t)0x4ba8, - (q15_t)0x4b93, (q15_t)0x4b7f, (q15_t)0x4b6b, (q15_t)0x4b56, (q15_t)0x4b42, (q15_t)0x4b2e, (q15_t)0x4b19, (q15_t)0x4b05, - (q15_t)0x4af1, (q15_t)0x4adc, (q15_t)0x4ac8, (q15_t)0x4ab4, (q15_t)0x4a9f, (q15_t)0x4a8b, (q15_t)0x4a76, (q15_t)0x4a62, - (q15_t)0x4a4d, (q15_t)0x4a39, (q15_t)0x4a24, (q15_t)0x4a10, (q15_t)0x49fb, (q15_t)0x49e7, (q15_t)0x49d2, (q15_t)0x49be, - (q15_t)0x49a9, (q15_t)0x4995, (q15_t)0x4980, (q15_t)0x496c, (q15_t)0x4957, (q15_t)0x4942, (q15_t)0x492e, (q15_t)0x4919, - (q15_t)0x4905, (q15_t)0x48f0, (q15_t)0x48db, (q15_t)0x48c7, (q15_t)0x48b2, (q15_t)0x489d, (q15_t)0x4888, (q15_t)0x4874, - (q15_t)0x485f, (q15_t)0x484a, (q15_t)0x4836, (q15_t)0x4821, (q15_t)0x480c, (q15_t)0x47f7, (q15_t)0x47e2, (q15_t)0x47ce, - (q15_t)0x47b9, (q15_t)0x47a4, (q15_t)0x478f, (q15_t)0x477a, (q15_t)0x4765, (q15_t)0x4751, (q15_t)0x473c, (q15_t)0x4727, - (q15_t)0x4712, (q15_t)0x46fd, (q15_t)0x46e8, (q15_t)0x46d3, (q15_t)0x46be, (q15_t)0x46a9, (q15_t)0x4694, (q15_t)0x467f, - (q15_t)0x466a, (q15_t)0x4655, (q15_t)0x4640, (q15_t)0x462b, (q15_t)0x4616, (q15_t)0x4601, (q15_t)0x45ec, (q15_t)0x45d7, - (q15_t)0x45c2, (q15_t)0x45ad, (q15_t)0x4598, (q15_t)0x4583, (q15_t)0x456e, (q15_t)0x4559, (q15_t)0x4544, (q15_t)0x452e, - (q15_t)0x4519, (q15_t)0x4504, (q15_t)0x44ef, (q15_t)0x44da, (q15_t)0x44c5, (q15_t)0x44af, (q15_t)0x449a, (q15_t)0x4485, - (q15_t)0x4470, (q15_t)0x445a, (q15_t)0x4445, (q15_t)0x4430, (q15_t)0x441b, (q15_t)0x4405, (q15_t)0x43f0, (q15_t)0x43db, - (q15_t)0x43c5, (q15_t)0x43b0, (q15_t)0x439b, (q15_t)0x4385, (q15_t)0x4370, (q15_t)0x435b, (q15_t)0x4345, (q15_t)0x4330, - (q15_t)0x431b, (q15_t)0x4305, (q15_t)0x42f0, (q15_t)0x42da, (q15_t)0x42c5, (q15_t)0x42af, (q15_t)0x429a, (q15_t)0x4284, - (q15_t)0x426f, (q15_t)0x425a, (q15_t)0x4244, (q15_t)0x422f, (q15_t)0x4219, (q15_t)0x4203, (q15_t)0x41ee, (q15_t)0x41d8, - (q15_t)0x41c3, (q15_t)0x41ad, (q15_t)0x4198, (q15_t)0x4182, (q15_t)0x416d, (q15_t)0x4157, (q15_t)0x4141, (q15_t)0x412c, - (q15_t)0x4116, (q15_t)0x4100, (q15_t)0x40eb, (q15_t)0x40d5, (q15_t)0x40bf, (q15_t)0x40aa, (q15_t)0x4094, (q15_t)0x407e, - (q15_t)0x4069, (q15_t)0x4053, (q15_t)0x403d, (q15_t)0x4027, (q15_t)0x4012, (q15_t)0x3ffc, (q15_t)0x3fe6, (q15_t)0x3fd0, - (q15_t)0x3fbb, (q15_t)0x3fa5, (q15_t)0x3f8f, (q15_t)0x3f79, (q15_t)0x3f63, (q15_t)0x3f4d, (q15_t)0x3f38, (q15_t)0x3f22, - (q15_t)0x3f0c, (q15_t)0x3ef6, (q15_t)0x3ee0, (q15_t)0x3eca, (q15_t)0x3eb4, (q15_t)0x3e9e, (q15_t)0x3e88, (q15_t)0x3e73, - (q15_t)0x3e5d, (q15_t)0x3e47, (q15_t)0x3e31, (q15_t)0x3e1b, (q15_t)0x3e05, (q15_t)0x3def, (q15_t)0x3dd9, (q15_t)0x3dc3, - (q15_t)0x3dad, (q15_t)0x3d97, (q15_t)0x3d81, (q15_t)0x3d6b, (q15_t)0x3d55, (q15_t)0x3d3e, (q15_t)0x3d28, (q15_t)0x3d12, - (q15_t)0x3cfc, (q15_t)0x3ce6, (q15_t)0x3cd0, (q15_t)0x3cba, (q15_t)0x3ca4, (q15_t)0x3c8e, (q15_t)0x3c77, (q15_t)0x3c61, - (q15_t)0x3c4b, (q15_t)0x3c35, (q15_t)0x3c1f, (q15_t)0x3c09, (q15_t)0x3bf2, (q15_t)0x3bdc, (q15_t)0x3bc6, (q15_t)0x3bb0, - (q15_t)0x3b99, (q15_t)0x3b83, (q15_t)0x3b6d, (q15_t)0x3b57, (q15_t)0x3b40, (q15_t)0x3b2a, (q15_t)0x3b14, (q15_t)0x3afe, - (q15_t)0x3ae7, (q15_t)0x3ad1, (q15_t)0x3abb, (q15_t)0x3aa4, (q15_t)0x3a8e, (q15_t)0x3a78, (q15_t)0x3a61, (q15_t)0x3a4b, - (q15_t)0x3a34, (q15_t)0x3a1e, (q15_t)0x3a08, (q15_t)0x39f1, (q15_t)0x39db, (q15_t)0x39c4, (q15_t)0x39ae, (q15_t)0x3998, - (q15_t)0x3981, (q15_t)0x396b, (q15_t)0x3954, (q15_t)0x393e, (q15_t)0x3927, (q15_t)0x3911, (q15_t)0x38fa, (q15_t)0x38e4, - (q15_t)0x38cd, (q15_t)0x38b7, (q15_t)0x38a0, (q15_t)0x388a, (q15_t)0x3873, (q15_t)0x385d, (q15_t)0x3846, (q15_t)0x382f, - (q15_t)0x3819, (q15_t)0x3802, (q15_t)0x37ec, (q15_t)0x37d5, (q15_t)0x37be, (q15_t)0x37a8, (q15_t)0x3791, (q15_t)0x377a, - (q15_t)0x3764, (q15_t)0x374d, (q15_t)0x3736, (q15_t)0x3720, (q15_t)0x3709, (q15_t)0x36f2, (q15_t)0x36dc, (q15_t)0x36c5, - (q15_t)0x36ae, (q15_t)0x3698, (q15_t)0x3681, (q15_t)0x366a, (q15_t)0x3653, (q15_t)0x363d, (q15_t)0x3626, (q15_t)0x360f, - (q15_t)0x35f8, (q15_t)0x35e1, (q15_t)0x35cb, (q15_t)0x35b4, (q15_t)0x359d, (q15_t)0x3586, (q15_t)0x356f, (q15_t)0x3558, - (q15_t)0x3542, (q15_t)0x352b, (q15_t)0x3514, (q15_t)0x34fd, (q15_t)0x34e6, (q15_t)0x34cf, (q15_t)0x34b8, (q15_t)0x34a1, - (q15_t)0x348b, (q15_t)0x3474, (q15_t)0x345d, (q15_t)0x3446, (q15_t)0x342f, (q15_t)0x3418, (q15_t)0x3401, (q15_t)0x33ea, - (q15_t)0x33d3, (q15_t)0x33bc, (q15_t)0x33a5, (q15_t)0x338e, (q15_t)0x3377, (q15_t)0x3360, (q15_t)0x3349, (q15_t)0x3332, - (q15_t)0x331b, (q15_t)0x3304, (q15_t)0x32ed, (q15_t)0x32d6, (q15_t)0x32bf, (q15_t)0x32a8, (q15_t)0x3290, (q15_t)0x3279, - (q15_t)0x3262, (q15_t)0x324b, (q15_t)0x3234, (q15_t)0x321d, (q15_t)0x3206, (q15_t)0x31ef, (q15_t)0x31d8, (q15_t)0x31c0, - (q15_t)0x31a9, (q15_t)0x3192, (q15_t)0x317b, (q15_t)0x3164, (q15_t)0x314c, (q15_t)0x3135, (q15_t)0x311e, (q15_t)0x3107, - (q15_t)0x30f0, (q15_t)0x30d8, (q15_t)0x30c1, (q15_t)0x30aa, (q15_t)0x3093, (q15_t)0x307b, (q15_t)0x3064, (q15_t)0x304d, - (q15_t)0x3036, (q15_t)0x301e, (q15_t)0x3007, (q15_t)0x2ff0, (q15_t)0x2fd8, (q15_t)0x2fc1, (q15_t)0x2faa, (q15_t)0x2f92, - (q15_t)0x2f7b, (q15_t)0x2f64, (q15_t)0x2f4c, (q15_t)0x2f35, (q15_t)0x2f1e, (q15_t)0x2f06, (q15_t)0x2eef, (q15_t)0x2ed8, - (q15_t)0x2ec0, (q15_t)0x2ea9, (q15_t)0x2e91, (q15_t)0x2e7a, (q15_t)0x2e63, (q15_t)0x2e4b, (q15_t)0x2e34, (q15_t)0x2e1c, - (q15_t)0x2e05, (q15_t)0x2ded, (q15_t)0x2dd6, (q15_t)0x2dbe, (q15_t)0x2da7, (q15_t)0x2d8f, (q15_t)0x2d78, (q15_t)0x2d60, - (q15_t)0x2d49, (q15_t)0x2d31, (q15_t)0x2d1a, (q15_t)0x2d02, (q15_t)0x2ceb, (q15_t)0x2cd3, (q15_t)0x2cbc, (q15_t)0x2ca4, - (q15_t)0x2c8d, (q15_t)0x2c75, (q15_t)0x2c5e, (q15_t)0x2c46, (q15_t)0x2c2e, (q15_t)0x2c17, (q15_t)0x2bff, (q15_t)0x2be8, - (q15_t)0x2bd0, (q15_t)0x2bb8, (q15_t)0x2ba1, (q15_t)0x2b89, (q15_t)0x2b71, (q15_t)0x2b5a, (q15_t)0x2b42, (q15_t)0x2b2b, - (q15_t)0x2b13, (q15_t)0x2afb, (q15_t)0x2ae4, (q15_t)0x2acc, (q15_t)0x2ab4, (q15_t)0x2a9c, (q15_t)0x2a85, (q15_t)0x2a6d, - (q15_t)0x2a55, (q15_t)0x2a3e, (q15_t)0x2a26, (q15_t)0x2a0e, (q15_t)0x29f6, (q15_t)0x29df, (q15_t)0x29c7, (q15_t)0x29af, - (q15_t)0x2997, (q15_t)0x2980, (q15_t)0x2968, (q15_t)0x2950, (q15_t)0x2938, (q15_t)0x2920, (q15_t)0x2909, (q15_t)0x28f1, - (q15_t)0x28d9, (q15_t)0x28c1, (q15_t)0x28a9, (q15_t)0x2892, (q15_t)0x287a, (q15_t)0x2862, (q15_t)0x284a, (q15_t)0x2832, - (q15_t)0x281a, (q15_t)0x2802, (q15_t)0x27eb, (q15_t)0x27d3, (q15_t)0x27bb, (q15_t)0x27a3, (q15_t)0x278b, (q15_t)0x2773, - (q15_t)0x275b, (q15_t)0x2743, (q15_t)0x272b, (q15_t)0x2713, (q15_t)0x26fb, (q15_t)0x26e4, (q15_t)0x26cc, (q15_t)0x26b4, - (q15_t)0x269c, (q15_t)0x2684, (q15_t)0x266c, (q15_t)0x2654, (q15_t)0x263c, (q15_t)0x2624, (q15_t)0x260c, (q15_t)0x25f4, - (q15_t)0x25dc, (q15_t)0x25c4, (q15_t)0x25ac, (q15_t)0x2594, (q15_t)0x257c, (q15_t)0x2564, (q15_t)0x254c, (q15_t)0x2534, - (q15_t)0x251c, (q15_t)0x2503, (q15_t)0x24eb, (q15_t)0x24d3, (q15_t)0x24bb, (q15_t)0x24a3, (q15_t)0x248b, (q15_t)0x2473, - (q15_t)0x245b, (q15_t)0x2443, (q15_t)0x242b, (q15_t)0x2413, (q15_t)0x23fa, (q15_t)0x23e2, (q15_t)0x23ca, (q15_t)0x23b2, - (q15_t)0x239a, (q15_t)0x2382, (q15_t)0x236a, (q15_t)0x2352, (q15_t)0x2339, (q15_t)0x2321, (q15_t)0x2309, (q15_t)0x22f1, - (q15_t)0x22d9, (q15_t)0x22c0, (q15_t)0x22a8, (q15_t)0x2290, (q15_t)0x2278, (q15_t)0x2260, (q15_t)0x2247, (q15_t)0x222f, - (q15_t)0x2217, (q15_t)0x21ff, (q15_t)0x21e7, (q15_t)0x21ce, (q15_t)0x21b6, (q15_t)0x219e, (q15_t)0x2186, (q15_t)0x216d, - (q15_t)0x2155, (q15_t)0x213d, (q15_t)0x2125, (q15_t)0x210c, (q15_t)0x20f4, (q15_t)0x20dc, (q15_t)0x20c3, (q15_t)0x20ab, - (q15_t)0x2093, (q15_t)0x207a, (q15_t)0x2062, (q15_t)0x204a, (q15_t)0x2032, (q15_t)0x2019, (q15_t)0x2001, (q15_t)0x1fe9, - (q15_t)0x1fd0, (q15_t)0x1fb8, (q15_t)0x1f9f, (q15_t)0x1f87, (q15_t)0x1f6f, (q15_t)0x1f56, (q15_t)0x1f3e, (q15_t)0x1f26, - (q15_t)0x1f0d, (q15_t)0x1ef5, (q15_t)0x1edd, (q15_t)0x1ec4, (q15_t)0x1eac, (q15_t)0x1e93, (q15_t)0x1e7b, (q15_t)0x1e62, - (q15_t)0x1e4a, (q15_t)0x1e32, (q15_t)0x1e19, (q15_t)0x1e01, (q15_t)0x1de8, (q15_t)0x1dd0, (q15_t)0x1db7, (q15_t)0x1d9f, - (q15_t)0x1d87, (q15_t)0x1d6e, (q15_t)0x1d56, (q15_t)0x1d3d, (q15_t)0x1d25, (q15_t)0x1d0c, (q15_t)0x1cf4, (q15_t)0x1cdb, - (q15_t)0x1cc3, (q15_t)0x1caa, (q15_t)0x1c92, (q15_t)0x1c79, (q15_t)0x1c61, (q15_t)0x1c48, (q15_t)0x1c30, (q15_t)0x1c17, - (q15_t)0x1bff, (q15_t)0x1be6, (q15_t)0x1bce, (q15_t)0x1bb5, (q15_t)0x1b9d, (q15_t)0x1b84, (q15_t)0x1b6c, (q15_t)0x1b53, - (q15_t)0x1b3a, (q15_t)0x1b22, (q15_t)0x1b09, (q15_t)0x1af1, (q15_t)0x1ad8, (q15_t)0x1ac0, (q15_t)0x1aa7, (q15_t)0x1a8e, - (q15_t)0x1a76, (q15_t)0x1a5d, (q15_t)0x1a45, (q15_t)0x1a2c, (q15_t)0x1a13, (q15_t)0x19fb, (q15_t)0x19e2, (q15_t)0x19ca, - (q15_t)0x19b1, (q15_t)0x1998, (q15_t)0x1980, (q15_t)0x1967, (q15_t)0x194e, (q15_t)0x1936, (q15_t)0x191d, (q15_t)0x1905, - (q15_t)0x18ec, (q15_t)0x18d3, (q15_t)0x18bb, (q15_t)0x18a2, (q15_t)0x1889, (q15_t)0x1871, (q15_t)0x1858, (q15_t)0x183f, - (q15_t)0x1827, (q15_t)0x180e, (q15_t)0x17f5, (q15_t)0x17dd, (q15_t)0x17c4, (q15_t)0x17ab, (q15_t)0x1792, (q15_t)0x177a, - (q15_t)0x1761, (q15_t)0x1748, (q15_t)0x1730, (q15_t)0x1717, (q15_t)0x16fe, (q15_t)0x16e5, (q15_t)0x16cd, (q15_t)0x16b4, - (q15_t)0x169b, (q15_t)0x1682, (q15_t)0x166a, (q15_t)0x1651, (q15_t)0x1638, (q15_t)0x161f, (q15_t)0x1607, (q15_t)0x15ee, - (q15_t)0x15d5, (q15_t)0x15bc, (q15_t)0x15a4, (q15_t)0x158b, (q15_t)0x1572, (q15_t)0x1559, (q15_t)0x1541, (q15_t)0x1528, - (q15_t)0x150f, (q15_t)0x14f6, (q15_t)0x14dd, (q15_t)0x14c5, (q15_t)0x14ac, (q15_t)0x1493, (q15_t)0x147a, (q15_t)0x1461, - (q15_t)0x1449, (q15_t)0x1430, (q15_t)0x1417, (q15_t)0x13fe, (q15_t)0x13e5, (q15_t)0x13cc, (q15_t)0x13b4, (q15_t)0x139b, - (q15_t)0x1382, (q15_t)0x1369, (q15_t)0x1350, (q15_t)0x1337, (q15_t)0x131f, (q15_t)0x1306, (q15_t)0x12ed, (q15_t)0x12d4, - (q15_t)0x12bb, (q15_t)0x12a2, (q15_t)0x1289, (q15_t)0x1271, (q15_t)0x1258, (q15_t)0x123f, (q15_t)0x1226, (q15_t)0x120d, - (q15_t)0x11f4, (q15_t)0x11db, (q15_t)0x11c2, (q15_t)0x11a9, (q15_t)0x1191, (q15_t)0x1178, (q15_t)0x115f, (q15_t)0x1146, - (q15_t)0x112d, (q15_t)0x1114, (q15_t)0x10fb, (q15_t)0x10e2, (q15_t)0x10c9, (q15_t)0x10b0, (q15_t)0x1098, (q15_t)0x107f, - (q15_t)0x1066, (q15_t)0x104d, (q15_t)0x1034, (q15_t)0x101b, (q15_t)0x1002, (q15_t)0xfe9, (q15_t)0xfd0, (q15_t)0xfb7, - (q15_t)0xf9e, (q15_t)0xf85, (q15_t)0xf6c, (q15_t)0xf53, (q15_t)0xf3a, (q15_t)0xf21, (q15_t)0xf08, (q15_t)0xef0, - (q15_t)0xed7, (q15_t)0xebe, (q15_t)0xea5, (q15_t)0xe8c, (q15_t)0xe73, (q15_t)0xe5a, (q15_t)0xe41, (q15_t)0xe28, - (q15_t)0xe0f, (q15_t)0xdf6, (q15_t)0xddd, (q15_t)0xdc4, (q15_t)0xdab, (q15_t)0xd92, (q15_t)0xd79, (q15_t)0xd60, - (q15_t)0xd47, (q15_t)0xd2e, (q15_t)0xd15, (q15_t)0xcfc, (q15_t)0xce3, (q15_t)0xcca, (q15_t)0xcb1, (q15_t)0xc98, - (q15_t)0xc7f, (q15_t)0xc66, (q15_t)0xc4d, (q15_t)0xc34, (q15_t)0xc1b, (q15_t)0xc02, (q15_t)0xbe9, (q15_t)0xbd0, - (q15_t)0xbb7, (q15_t)0xb9e, (q15_t)0xb85, (q15_t)0xb6c, (q15_t)0xb53, (q15_t)0xb3a, (q15_t)0xb20, (q15_t)0xb07, - (q15_t)0xaee, (q15_t)0xad5, (q15_t)0xabc, (q15_t)0xaa3, (q15_t)0xa8a, (q15_t)0xa71, (q15_t)0xa58, (q15_t)0xa3f, - (q15_t)0xa26, (q15_t)0xa0d, (q15_t)0x9f4, (q15_t)0x9db, (q15_t)0x9c2, (q15_t)0x9a9, (q15_t)0x990, (q15_t)0x977, - (q15_t)0x95e, (q15_t)0x944, (q15_t)0x92b, (q15_t)0x912, (q15_t)0x8f9, (q15_t)0x8e0, (q15_t)0x8c7, (q15_t)0x8ae, - (q15_t)0x895, (q15_t)0x87c, (q15_t)0x863, (q15_t)0x84a, (q15_t)0x831, (q15_t)0x818, (q15_t)0x7fe, (q15_t)0x7e5, - (q15_t)0x7cc, (q15_t)0x7b3, (q15_t)0x79a, (q15_t)0x781, (q15_t)0x768, (q15_t)0x74f, (q15_t)0x736, (q15_t)0x71d, - (q15_t)0x704, (q15_t)0x6ea, (q15_t)0x6d1, (q15_t)0x6b8, (q15_t)0x69f, (q15_t)0x686, (q15_t)0x66d, (q15_t)0x654, - (q15_t)0x63b, (q15_t)0x622, (q15_t)0x609, (q15_t)0x5ef, (q15_t)0x5d6, (q15_t)0x5bd, (q15_t)0x5a4, (q15_t)0x58b, - (q15_t)0x572, (q15_t)0x559, (q15_t)0x540, (q15_t)0x527, (q15_t)0x50d, (q15_t)0x4f4, (q15_t)0x4db, (q15_t)0x4c2, - (q15_t)0x4a9, (q15_t)0x490, (q15_t)0x477, (q15_t)0x45e, (q15_t)0x445, (q15_t)0x42b, (q15_t)0x412, (q15_t)0x3f9, - (q15_t)0x3e0, (q15_t)0x3c7, (q15_t)0x3ae, (q15_t)0x395, (q15_t)0x37c, (q15_t)0x362, (q15_t)0x349, (q15_t)0x330, - (q15_t)0x317, (q15_t)0x2fe, (q15_t)0x2e5, (q15_t)0x2cc, (q15_t)0x2b3, (q15_t)0x299, (q15_t)0x280, (q15_t)0x267, - (q15_t)0x24e, (q15_t)0x235, (q15_t)0x21c, (q15_t)0x203, (q15_t)0x1ea, (q15_t)0x1d0, (q15_t)0x1b7, (q15_t)0x19e, - (q15_t)0x185, (q15_t)0x16c, (q15_t)0x153, (q15_t)0x13a, (q15_t)0x121, (q15_t)0x107, (q15_t)0xee, (q15_t)0xd5, - (q15_t)0xbc, (q15_t)0xa3, (q15_t)0x8a, (q15_t)0x71, (q15_t)0x57, (q15_t)0x3e, (q15_t)0x25, (q15_t)0xc + (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, + (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, + (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffd, + (q15_t)0x7ffd, (q15_t)0x7ffd, (q15_t)0x7ffd, (q15_t)0x7ffc, (q15_t)0x7ffc, + (q15_t)0x7ffb, (q15_t)0x7ffb, (q15_t)0x7ffb, (q15_t)0x7ffa, (q15_t)0x7ffa, + (q15_t)0x7ff9, (q15_t)0x7ff9, (q15_t)0x7ff8, (q15_t)0x7ff8, (q15_t)0x7ff7, + (q15_t)0x7ff7, (q15_t)0x7ff6, (q15_t)0x7ff5, (q15_t)0x7ff5, (q15_t)0x7ff4, + (q15_t)0x7ff3, (q15_t)0x7ff3, (q15_t)0x7ff2, (q15_t)0x7ff1, (q15_t)0x7ff0, + (q15_t)0x7ff0, (q15_t)0x7fef, (q15_t)0x7fee, (q15_t)0x7fed, (q15_t)0x7fec, + (q15_t)0x7fec, (q15_t)0x7feb, (q15_t)0x7fea, (q15_t)0x7fe9, (q15_t)0x7fe8, + (q15_t)0x7fe7, (q15_t)0x7fe6, (q15_t)0x7fe5, (q15_t)0x7fe4, (q15_t)0x7fe3, + (q15_t)0x7fe2, (q15_t)0x7fe1, (q15_t)0x7fe0, (q15_t)0x7fdf, (q15_t)0x7fdd, + (q15_t)0x7fdc, (q15_t)0x7fdb, (q15_t)0x7fda, (q15_t)0x7fd9, (q15_t)0x7fd7, + (q15_t)0x7fd6, (q15_t)0x7fd5, (q15_t)0x7fd4, (q15_t)0x7fd2, (q15_t)0x7fd1, + (q15_t)0x7fd0, (q15_t)0x7fce, (q15_t)0x7fcd, (q15_t)0x7fcb, (q15_t)0x7fca, + (q15_t)0x7fc9, (q15_t)0x7fc7, (q15_t)0x7fc6, (q15_t)0x7fc4, (q15_t)0x7fc3, + (q15_t)0x7fc1, (q15_t)0x7fc0, (q15_t)0x7fbe, (q15_t)0x7fbc, (q15_t)0x7fbb, + (q15_t)0x7fb9, (q15_t)0x7fb7, (q15_t)0x7fb6, (q15_t)0x7fb4, (q15_t)0x7fb2, + (q15_t)0x7fb1, (q15_t)0x7faf, (q15_t)0x7fad, (q15_t)0x7fab, (q15_t)0x7fa9, + (q15_t)0x7fa8, (q15_t)0x7fa6, (q15_t)0x7fa4, (q15_t)0x7fa2, (q15_t)0x7fa0, + (q15_t)0x7f9e, (q15_t)0x7f9c, (q15_t)0x7f9a, (q15_t)0x7f98, (q15_t)0x7f96, + (q15_t)0x7f94, (q15_t)0x7f92, (q15_t)0x7f90, (q15_t)0x7f8e, (q15_t)0x7f8c, + (q15_t)0x7f8a, (q15_t)0x7f88, (q15_t)0x7f86, (q15_t)0x7f83, (q15_t)0x7f81, + (q15_t)0x7f7f, (q15_t)0x7f7d, (q15_t)0x7f7b, (q15_t)0x7f78, (q15_t)0x7f76, + (q15_t)0x7f74, (q15_t)0x7f71, (q15_t)0x7f6f, (q15_t)0x7f6d, (q15_t)0x7f6a, + (q15_t)0x7f68, (q15_t)0x7f65, (q15_t)0x7f63, (q15_t)0x7f60, (q15_t)0x7f5e, + (q15_t)0x7f5b, (q15_t)0x7f59, (q15_t)0x7f56, (q15_t)0x7f54, (q15_t)0x7f51, + (q15_t)0x7f4f, (q15_t)0x7f4c, (q15_t)0x7f49, (q15_t)0x7f47, (q15_t)0x7f44, + (q15_t)0x7f41, (q15_t)0x7f3f, (q15_t)0x7f3c, (q15_t)0x7f39, (q15_t)0x7f36, + (q15_t)0x7f34, (q15_t)0x7f31, (q15_t)0x7f2e, (q15_t)0x7f2b, (q15_t)0x7f28, + (q15_t)0x7f25, (q15_t)0x7f23, (q15_t)0x7f20, (q15_t)0x7f1d, (q15_t)0x7f1a, + (q15_t)0x7f17, (q15_t)0x7f14, (q15_t)0x7f11, (q15_t)0x7f0e, (q15_t)0x7f0b, + (q15_t)0x7f08, (q15_t)0x7f04, (q15_t)0x7f01, (q15_t)0x7efe, (q15_t)0x7efb, + (q15_t)0x7ef8, (q15_t)0x7ef5, (q15_t)0x7ef1, (q15_t)0x7eee, (q15_t)0x7eeb, + (q15_t)0x7ee8, (q15_t)0x7ee4, (q15_t)0x7ee1, (q15_t)0x7ede, (q15_t)0x7eda, + (q15_t)0x7ed7, (q15_t)0x7ed4, (q15_t)0x7ed0, (q15_t)0x7ecd, (q15_t)0x7ec9, + (q15_t)0x7ec6, (q15_t)0x7ec3, (q15_t)0x7ebf, (q15_t)0x7ebb, (q15_t)0x7eb8, + (q15_t)0x7eb4, (q15_t)0x7eb1, (q15_t)0x7ead, (q15_t)0x7eaa, (q15_t)0x7ea6, + (q15_t)0x7ea2, (q15_t)0x7e9f, (q15_t)0x7e9b, (q15_t)0x7e97, (q15_t)0x7e94, + (q15_t)0x7e90, (q15_t)0x7e8c, (q15_t)0x7e88, (q15_t)0x7e84, (q15_t)0x7e81, + (q15_t)0x7e7d, (q15_t)0x7e79, (q15_t)0x7e75, (q15_t)0x7e71, (q15_t)0x7e6d, + (q15_t)0x7e69, (q15_t)0x7e65, (q15_t)0x7e61, (q15_t)0x7e5d, (q15_t)0x7e59, + (q15_t)0x7e55, (q15_t)0x7e51, (q15_t)0x7e4d, (q15_t)0x7e49, (q15_t)0x7e45, + (q15_t)0x7e41, (q15_t)0x7e3d, (q15_t)0x7e39, (q15_t)0x7e34, (q15_t)0x7e30, + (q15_t)0x7e2c, (q15_t)0x7e28, (q15_t)0x7e24, (q15_t)0x7e1f, (q15_t)0x7e1b, + (q15_t)0x7e17, (q15_t)0x7e12, (q15_t)0x7e0e, (q15_t)0x7e0a, (q15_t)0x7e05, + (q15_t)0x7e01, (q15_t)0x7dfc, (q15_t)0x7df8, (q15_t)0x7df3, (q15_t)0x7def, + (q15_t)0x7dea, (q15_t)0x7de6, (q15_t)0x7de1, (q15_t)0x7ddd, (q15_t)0x7dd8, + (q15_t)0x7dd4, (q15_t)0x7dcf, (q15_t)0x7dca, (q15_t)0x7dc6, (q15_t)0x7dc1, + (q15_t)0x7dbc, (q15_t)0x7db8, (q15_t)0x7db3, (q15_t)0x7dae, (q15_t)0x7da9, + (q15_t)0x7da5, (q15_t)0x7da0, (q15_t)0x7d9b, (q15_t)0x7d96, (q15_t)0x7d91, + (q15_t)0x7d8c, (q15_t)0x7d87, (q15_t)0x7d82, (q15_t)0x7d7e, (q15_t)0x7d79, + (q15_t)0x7d74, (q15_t)0x7d6f, (q15_t)0x7d6a, (q15_t)0x7d65, (q15_t)0x7d60, + (q15_t)0x7d5a, (q15_t)0x7d55, (q15_t)0x7d50, (q15_t)0x7d4b, (q15_t)0x7d46, + (q15_t)0x7d41, (q15_t)0x7d3c, (q15_t)0x7d36, (q15_t)0x7d31, (q15_t)0x7d2c, + (q15_t)0x7d27, (q15_t)0x7d21, (q15_t)0x7d1c, (q15_t)0x7d17, (q15_t)0x7d11, + (q15_t)0x7d0c, (q15_t)0x7d07, (q15_t)0x7d01, (q15_t)0x7cfc, (q15_t)0x7cf6, + (q15_t)0x7cf1, (q15_t)0x7cec, (q15_t)0x7ce6, (q15_t)0x7ce1, (q15_t)0x7cdb, + (q15_t)0x7cd5, (q15_t)0x7cd0, (q15_t)0x7cca, (q15_t)0x7cc5, (q15_t)0x7cbf, + (q15_t)0x7cb9, (q15_t)0x7cb4, (q15_t)0x7cae, (q15_t)0x7ca8, (q15_t)0x7ca3, + (q15_t)0x7c9d, (q15_t)0x7c97, (q15_t)0x7c91, (q15_t)0x7c8c, (q15_t)0x7c86, + (q15_t)0x7c80, (q15_t)0x7c7a, (q15_t)0x7c74, (q15_t)0x7c6e, (q15_t)0x7c69, + (q15_t)0x7c63, (q15_t)0x7c5d, (q15_t)0x7c57, (q15_t)0x7c51, (q15_t)0x7c4b, + (q15_t)0x7c45, (q15_t)0x7c3f, (q15_t)0x7c39, (q15_t)0x7c33, (q15_t)0x7c2d, + (q15_t)0x7c26, (q15_t)0x7c20, (q15_t)0x7c1a, (q15_t)0x7c14, (q15_t)0x7c0e, + (q15_t)0x7c08, (q15_t)0x7c01, (q15_t)0x7bfb, (q15_t)0x7bf5, (q15_t)0x7bef, + (q15_t)0x7be8, (q15_t)0x7be2, (q15_t)0x7bdc, (q15_t)0x7bd5, (q15_t)0x7bcf, + (q15_t)0x7bc9, (q15_t)0x7bc2, (q15_t)0x7bbc, (q15_t)0x7bb5, (q15_t)0x7baf, + (q15_t)0x7ba8, (q15_t)0x7ba2, (q15_t)0x7b9b, (q15_t)0x7b95, (q15_t)0x7b8e, + (q15_t)0x7b88, (q15_t)0x7b81, (q15_t)0x7b7a, (q15_t)0x7b74, (q15_t)0x7b6d, + (q15_t)0x7b67, (q15_t)0x7b60, (q15_t)0x7b59, (q15_t)0x7b52, (q15_t)0x7b4c, + (q15_t)0x7b45, (q15_t)0x7b3e, (q15_t)0x7b37, (q15_t)0x7b31, (q15_t)0x7b2a, + (q15_t)0x7b23, (q15_t)0x7b1c, (q15_t)0x7b15, (q15_t)0x7b0e, (q15_t)0x7b07, + (q15_t)0x7b00, (q15_t)0x7af9, (q15_t)0x7af2, (q15_t)0x7aeb, (q15_t)0x7ae4, + (q15_t)0x7add, (q15_t)0x7ad6, (q15_t)0x7acf, (q15_t)0x7ac8, (q15_t)0x7ac1, + (q15_t)0x7aba, (q15_t)0x7ab3, (q15_t)0x7aac, (q15_t)0x7aa4, (q15_t)0x7a9d, + (q15_t)0x7a96, (q15_t)0x7a8f, (q15_t)0x7a87, (q15_t)0x7a80, (q15_t)0x7a79, + (q15_t)0x7a72, (q15_t)0x7a6a, (q15_t)0x7a63, (q15_t)0x7a5c, (q15_t)0x7a54, + (q15_t)0x7a4d, (q15_t)0x7a45, (q15_t)0x7a3e, (q15_t)0x7a36, (q15_t)0x7a2f, + (q15_t)0x7a27, (q15_t)0x7a20, (q15_t)0x7a18, (q15_t)0x7a11, (q15_t)0x7a09, + (q15_t)0x7a02, (q15_t)0x79fa, (q15_t)0x79f2, (q15_t)0x79eb, (q15_t)0x79e3, + (q15_t)0x79db, (q15_t)0x79d4, (q15_t)0x79cc, (q15_t)0x79c4, (q15_t)0x79bc, + (q15_t)0x79b5, (q15_t)0x79ad, (q15_t)0x79a5, (q15_t)0x799d, (q15_t)0x7995, + (q15_t)0x798e, (q15_t)0x7986, (q15_t)0x797e, (q15_t)0x7976, (q15_t)0x796e, + (q15_t)0x7966, (q15_t)0x795e, (q15_t)0x7956, (q15_t)0x794e, (q15_t)0x7946, + (q15_t)0x793e, (q15_t)0x7936, (q15_t)0x792e, (q15_t)0x7926, (q15_t)0x791e, + (q15_t)0x7915, (q15_t)0x790d, (q15_t)0x7905, (q15_t)0x78fd, (q15_t)0x78f5, + (q15_t)0x78ec, (q15_t)0x78e4, (q15_t)0x78dc, (q15_t)0x78d4, (q15_t)0x78cb, + (q15_t)0x78c3, (q15_t)0x78bb, (q15_t)0x78b2, (q15_t)0x78aa, (q15_t)0x78a2, + (q15_t)0x7899, (q15_t)0x7891, (q15_t)0x7888, (q15_t)0x7880, (q15_t)0x7877, + (q15_t)0x786f, (q15_t)0x7866, (q15_t)0x785e, (q15_t)0x7855, (q15_t)0x784d, + (q15_t)0x7844, (q15_t)0x783b, (q15_t)0x7833, (q15_t)0x782a, (q15_t)0x7821, + (q15_t)0x7819, (q15_t)0x7810, (q15_t)0x7807, (q15_t)0x77ff, (q15_t)0x77f6, + (q15_t)0x77ed, (q15_t)0x77e4, (q15_t)0x77db, (q15_t)0x77d3, (q15_t)0x77ca, + (q15_t)0x77c1, (q15_t)0x77b8, (q15_t)0x77af, (q15_t)0x77a6, (q15_t)0x779d, + (q15_t)0x7794, (q15_t)0x778b, (q15_t)0x7782, (q15_t)0x7779, (q15_t)0x7770, + (q15_t)0x7767, (q15_t)0x775e, (q15_t)0x7755, (q15_t)0x774c, (q15_t)0x7743, + (q15_t)0x773a, (q15_t)0x7731, (q15_t)0x7727, (q15_t)0x771e, (q15_t)0x7715, + (q15_t)0x770c, (q15_t)0x7703, (q15_t)0x76f9, (q15_t)0x76f0, (q15_t)0x76e7, + (q15_t)0x76dd, (q15_t)0x76d4, (q15_t)0x76cb, (q15_t)0x76c1, (q15_t)0x76b8, + (q15_t)0x76af, (q15_t)0x76a5, (q15_t)0x769c, (q15_t)0x7692, (q15_t)0x7689, + (q15_t)0x767f, (q15_t)0x7676, (q15_t)0x766c, (q15_t)0x7663, (q15_t)0x7659, + (q15_t)0x7650, (q15_t)0x7646, (q15_t)0x763c, (q15_t)0x7633, (q15_t)0x7629, + (q15_t)0x761f, (q15_t)0x7616, (q15_t)0x760c, (q15_t)0x7602, (q15_t)0x75f9, + (q15_t)0x75ef, (q15_t)0x75e5, (q15_t)0x75db, (q15_t)0x75d1, (q15_t)0x75c8, + (q15_t)0x75be, (q15_t)0x75b4, (q15_t)0x75aa, (q15_t)0x75a0, (q15_t)0x7596, + (q15_t)0x758c, (q15_t)0x7582, (q15_t)0x7578, (q15_t)0x756e, (q15_t)0x7564, + (q15_t)0x755a, (q15_t)0x7550, (q15_t)0x7546, (q15_t)0x753c, (q15_t)0x7532, + (q15_t)0x7528, (q15_t)0x751e, (q15_t)0x7514, (q15_t)0x7509, (q15_t)0x74ff, + (q15_t)0x74f5, (q15_t)0x74eb, (q15_t)0x74e1, (q15_t)0x74d6, (q15_t)0x74cc, + (q15_t)0x74c2, (q15_t)0x74b7, (q15_t)0x74ad, (q15_t)0x74a3, (q15_t)0x7498, + (q15_t)0x748e, (q15_t)0x7484, (q15_t)0x7479, (q15_t)0x746f, (q15_t)0x7464, + (q15_t)0x745a, (q15_t)0x744f, (q15_t)0x7445, (q15_t)0x743a, (q15_t)0x7430, + (q15_t)0x7425, (q15_t)0x741b, (q15_t)0x7410, (q15_t)0x7406, (q15_t)0x73fb, + (q15_t)0x73f0, (q15_t)0x73e6, (q15_t)0x73db, (q15_t)0x73d0, (q15_t)0x73c6, + (q15_t)0x73bb, (q15_t)0x73b0, (q15_t)0x73a5, (q15_t)0x739b, (q15_t)0x7390, + (q15_t)0x7385, (q15_t)0x737a, (q15_t)0x736f, (q15_t)0x7364, (q15_t)0x7359, + (q15_t)0x734f, (q15_t)0x7344, (q15_t)0x7339, (q15_t)0x732e, (q15_t)0x7323, + (q15_t)0x7318, (q15_t)0x730d, (q15_t)0x7302, (q15_t)0x72f7, (q15_t)0x72ec, + (q15_t)0x72e1, (q15_t)0x72d5, (q15_t)0x72ca, (q15_t)0x72bf, (q15_t)0x72b4, + (q15_t)0x72a9, (q15_t)0x729e, (q15_t)0x7293, (q15_t)0x7287, (q15_t)0x727c, + (q15_t)0x7271, (q15_t)0x7266, (q15_t)0x725a, (q15_t)0x724f, (q15_t)0x7244, + (q15_t)0x7238, (q15_t)0x722d, (q15_t)0x7222, (q15_t)0x7216, (q15_t)0x720b, + (q15_t)0x71ff, (q15_t)0x71f4, (q15_t)0x71e9, (q15_t)0x71dd, (q15_t)0x71d2, + (q15_t)0x71c6, (q15_t)0x71bb, (q15_t)0x71af, (q15_t)0x71a3, (q15_t)0x7198, + (q15_t)0x718c, (q15_t)0x7181, (q15_t)0x7175, (q15_t)0x7169, (q15_t)0x715e, + (q15_t)0x7152, (q15_t)0x7146, (q15_t)0x713b, (q15_t)0x712f, (q15_t)0x7123, + (q15_t)0x7117, (q15_t)0x710c, (q15_t)0x7100, (q15_t)0x70f4, (q15_t)0x70e8, + (q15_t)0x70dc, (q15_t)0x70d1, (q15_t)0x70c5, (q15_t)0x70b9, (q15_t)0x70ad, + (q15_t)0x70a1, (q15_t)0x7095, (q15_t)0x7089, (q15_t)0x707d, (q15_t)0x7071, + (q15_t)0x7065, (q15_t)0x7059, (q15_t)0x704d, (q15_t)0x7041, (q15_t)0x7035, + (q15_t)0x7029, (q15_t)0x701d, (q15_t)0x7010, (q15_t)0x7004, (q15_t)0x6ff8, + (q15_t)0x6fec, (q15_t)0x6fe0, (q15_t)0x6fd3, (q15_t)0x6fc7, (q15_t)0x6fbb, + (q15_t)0x6faf, (q15_t)0x6fa2, (q15_t)0x6f96, (q15_t)0x6f8a, (q15_t)0x6f7d, + (q15_t)0x6f71, (q15_t)0x6f65, (q15_t)0x6f58, (q15_t)0x6f4c, (q15_t)0x6f3f, + (q15_t)0x6f33, (q15_t)0x6f27, (q15_t)0x6f1a, (q15_t)0x6f0e, (q15_t)0x6f01, + (q15_t)0x6ef5, (q15_t)0x6ee8, (q15_t)0x6edc, (q15_t)0x6ecf, (q15_t)0x6ec2, + (q15_t)0x6eb6, (q15_t)0x6ea9, (q15_t)0x6e9c, (q15_t)0x6e90, (q15_t)0x6e83, + (q15_t)0x6e76, (q15_t)0x6e6a, (q15_t)0x6e5d, (q15_t)0x6e50, (q15_t)0x6e44, + (q15_t)0x6e37, (q15_t)0x6e2a, (q15_t)0x6e1d, (q15_t)0x6e10, (q15_t)0x6e04, + (q15_t)0x6df7, (q15_t)0x6dea, (q15_t)0x6ddd, (q15_t)0x6dd0, (q15_t)0x6dc3, + (q15_t)0x6db6, (q15_t)0x6da9, (q15_t)0x6d9c, (q15_t)0x6d8f, (q15_t)0x6d82, + (q15_t)0x6d75, (q15_t)0x6d68, (q15_t)0x6d5b, (q15_t)0x6d4e, (q15_t)0x6d41, + (q15_t)0x6d34, (q15_t)0x6d27, (q15_t)0x6d1a, (q15_t)0x6d0c, (q15_t)0x6cff, + (q15_t)0x6cf2, (q15_t)0x6ce5, (q15_t)0x6cd8, (q15_t)0x6cca, (q15_t)0x6cbd, + (q15_t)0x6cb0, (q15_t)0x6ca3, (q15_t)0x6c95, (q15_t)0x6c88, (q15_t)0x6c7b, + (q15_t)0x6c6d, (q15_t)0x6c60, (q15_t)0x6c53, (q15_t)0x6c45, (q15_t)0x6c38, + (q15_t)0x6c2a, (q15_t)0x6c1d, (q15_t)0x6c0f, (q15_t)0x6c02, (q15_t)0x6bf5, + (q15_t)0x6be7, (q15_t)0x6bd9, (q15_t)0x6bcc, (q15_t)0x6bbe, (q15_t)0x6bb1, + (q15_t)0x6ba3, (q15_t)0x6b96, (q15_t)0x6b88, (q15_t)0x6b7a, (q15_t)0x6b6d, + (q15_t)0x6b5f, (q15_t)0x6b51, (q15_t)0x6b44, (q15_t)0x6b36, (q15_t)0x6b28, + (q15_t)0x6b1a, (q15_t)0x6b0d, (q15_t)0x6aff, (q15_t)0x6af1, (q15_t)0x6ae3, + (q15_t)0x6ad5, (q15_t)0x6ac8, (q15_t)0x6aba, (q15_t)0x6aac, (q15_t)0x6a9e, + (q15_t)0x6a90, (q15_t)0x6a82, (q15_t)0x6a74, (q15_t)0x6a66, (q15_t)0x6a58, + (q15_t)0x6a4a, (q15_t)0x6a3c, (q15_t)0x6a2e, (q15_t)0x6a20, (q15_t)0x6a12, + (q15_t)0x6a04, (q15_t)0x69f6, (q15_t)0x69e8, (q15_t)0x69da, (q15_t)0x69cb, + (q15_t)0x69bd, (q15_t)0x69af, (q15_t)0x69a1, (q15_t)0x6993, (q15_t)0x6985, + (q15_t)0x6976, (q15_t)0x6968, (q15_t)0x695a, (q15_t)0x694b, (q15_t)0x693d, + (q15_t)0x692f, (q15_t)0x6921, (q15_t)0x6912, (q15_t)0x6904, (q15_t)0x68f5, + (q15_t)0x68e7, (q15_t)0x68d9, (q15_t)0x68ca, (q15_t)0x68bc, (q15_t)0x68ad, + (q15_t)0x689f, (q15_t)0x6890, (q15_t)0x6882, (q15_t)0x6873, (q15_t)0x6865, + (q15_t)0x6856, (q15_t)0x6848, (q15_t)0x6839, (q15_t)0x682b, (q15_t)0x681c, + (q15_t)0x680d, (q15_t)0x67ff, (q15_t)0x67f0, (q15_t)0x67e1, (q15_t)0x67d3, + (q15_t)0x67c4, (q15_t)0x67b5, (q15_t)0x67a6, (q15_t)0x6798, (q15_t)0x6789, + (q15_t)0x677a, (q15_t)0x676b, (q15_t)0x675d, (q15_t)0x674e, (q15_t)0x673f, + (q15_t)0x6730, (q15_t)0x6721, (q15_t)0x6712, (q15_t)0x6703, (q15_t)0x66f4, + (q15_t)0x66e5, (q15_t)0x66d6, (q15_t)0x66c8, (q15_t)0x66b9, (q15_t)0x66aa, + (q15_t)0x669b, (q15_t)0x668b, (q15_t)0x667c, (q15_t)0x666d, (q15_t)0x665e, + (q15_t)0x664f, (q15_t)0x6640, (q15_t)0x6631, (q15_t)0x6622, (q15_t)0x6613, + (q15_t)0x6603, (q15_t)0x65f4, (q15_t)0x65e5, (q15_t)0x65d6, (q15_t)0x65c7, + (q15_t)0x65b7, (q15_t)0x65a8, (q15_t)0x6599, (q15_t)0x658a, (q15_t)0x657a, + (q15_t)0x656b, (q15_t)0x655c, (q15_t)0x654c, (q15_t)0x653d, (q15_t)0x652d, + (q15_t)0x651e, (q15_t)0x650f, (q15_t)0x64ff, (q15_t)0x64f0, (q15_t)0x64e0, + (q15_t)0x64d1, (q15_t)0x64c1, (q15_t)0x64b2, (q15_t)0x64a2, (q15_t)0x6493, + (q15_t)0x6483, (q15_t)0x6474, (q15_t)0x6464, (q15_t)0x6454, (q15_t)0x6445, + (q15_t)0x6435, (q15_t)0x6426, (q15_t)0x6416, (q15_t)0x6406, (q15_t)0x63f7, + (q15_t)0x63e7, (q15_t)0x63d7, (q15_t)0x63c7, (q15_t)0x63b8, (q15_t)0x63a8, + (q15_t)0x6398, (q15_t)0x6388, (q15_t)0x6378, (q15_t)0x6369, (q15_t)0x6359, + (q15_t)0x6349, (q15_t)0x6339, (q15_t)0x6329, (q15_t)0x6319, (q15_t)0x6309, + (q15_t)0x62f9, (q15_t)0x62ea, (q15_t)0x62da, (q15_t)0x62ca, (q15_t)0x62ba, + (q15_t)0x62aa, (q15_t)0x629a, (q15_t)0x628a, (q15_t)0x627a, (q15_t)0x6269, + (q15_t)0x6259, (q15_t)0x6249, (q15_t)0x6239, (q15_t)0x6229, (q15_t)0x6219, + (q15_t)0x6209, (q15_t)0x61f9, (q15_t)0x61e8, (q15_t)0x61d8, (q15_t)0x61c8, + (q15_t)0x61b8, (q15_t)0x61a8, (q15_t)0x6197, (q15_t)0x6187, (q15_t)0x6177, + (q15_t)0x6166, (q15_t)0x6156, (q15_t)0x6146, (q15_t)0x6135, (q15_t)0x6125, + (q15_t)0x6115, (q15_t)0x6104, (q15_t)0x60f4, (q15_t)0x60e4, (q15_t)0x60d3, + (q15_t)0x60c3, (q15_t)0x60b2, (q15_t)0x60a2, (q15_t)0x6091, (q15_t)0x6081, + (q15_t)0x6070, (q15_t)0x6060, (q15_t)0x604f, (q15_t)0x603f, (q15_t)0x602e, + (q15_t)0x601d, (q15_t)0x600d, (q15_t)0x5ffc, (q15_t)0x5fec, (q15_t)0x5fdb, + (q15_t)0x5fca, (q15_t)0x5fba, (q15_t)0x5fa9, (q15_t)0x5f98, (q15_t)0x5f87, + (q15_t)0x5f77, (q15_t)0x5f66, (q15_t)0x5f55, (q15_t)0x5f44, (q15_t)0x5f34, + (q15_t)0x5f23, (q15_t)0x5f12, (q15_t)0x5f01, (q15_t)0x5ef0, (q15_t)0x5edf, + (q15_t)0x5ecf, (q15_t)0x5ebe, (q15_t)0x5ead, (q15_t)0x5e9c, (q15_t)0x5e8b, + (q15_t)0x5e7a, (q15_t)0x5e69, (q15_t)0x5e58, (q15_t)0x5e47, (q15_t)0x5e36, + (q15_t)0x5e25, (q15_t)0x5e14, (q15_t)0x5e03, (q15_t)0x5df2, (q15_t)0x5de1, + (q15_t)0x5dd0, (q15_t)0x5dbf, (q15_t)0x5dad, (q15_t)0x5d9c, (q15_t)0x5d8b, + (q15_t)0x5d7a, (q15_t)0x5d69, (q15_t)0x5d58, (q15_t)0x5d46, (q15_t)0x5d35, + (q15_t)0x5d24, (q15_t)0x5d13, (q15_t)0x5d01, (q15_t)0x5cf0, (q15_t)0x5cdf, + (q15_t)0x5cce, (q15_t)0x5cbc, (q15_t)0x5cab, (q15_t)0x5c9a, (q15_t)0x5c88, + (q15_t)0x5c77, (q15_t)0x5c66, (q15_t)0x5c54, (q15_t)0x5c43, (q15_t)0x5c31, + (q15_t)0x5c20, (q15_t)0x5c0e, (q15_t)0x5bfd, (q15_t)0x5beb, (q15_t)0x5bda, + (q15_t)0x5bc8, (q15_t)0x5bb7, (q15_t)0x5ba5, (q15_t)0x5b94, (q15_t)0x5b82, + (q15_t)0x5b71, (q15_t)0x5b5f, (q15_t)0x5b4d, (q15_t)0x5b3c, (q15_t)0x5b2a, + (q15_t)0x5b19, (q15_t)0x5b07, (q15_t)0x5af5, (q15_t)0x5ae4, (q15_t)0x5ad2, + (q15_t)0x5ac0, (q15_t)0x5aae, (q15_t)0x5a9d, (q15_t)0x5a8b, (q15_t)0x5a79, + (q15_t)0x5a67, (q15_t)0x5a56, (q15_t)0x5a44, (q15_t)0x5a32, (q15_t)0x5a20, + (q15_t)0x5a0e, (q15_t)0x59fc, (q15_t)0x59ea, (q15_t)0x59d9, (q15_t)0x59c7, + (q15_t)0x59b5, (q15_t)0x59a3, (q15_t)0x5991, (q15_t)0x597f, (q15_t)0x596d, + (q15_t)0x595b, (q15_t)0x5949, (q15_t)0x5937, (q15_t)0x5925, (q15_t)0x5913, + (q15_t)0x5901, (q15_t)0x58ef, (q15_t)0x58dd, (q15_t)0x58cb, (q15_t)0x58b8, + (q15_t)0x58a6, (q15_t)0x5894, (q15_t)0x5882, (q15_t)0x5870, (q15_t)0x585e, + (q15_t)0x584b, (q15_t)0x5839, (q15_t)0x5827, (q15_t)0x5815, (q15_t)0x5803, + (q15_t)0x57f0, (q15_t)0x57de, (q15_t)0x57cc, (q15_t)0x57b9, (q15_t)0x57a7, + (q15_t)0x5795, (q15_t)0x5783, (q15_t)0x5770, (q15_t)0x575e, (q15_t)0x574b, + (q15_t)0x5739, (q15_t)0x5727, (q15_t)0x5714, (q15_t)0x5702, (q15_t)0x56ef, + (q15_t)0x56dd, (q15_t)0x56ca, (q15_t)0x56b8, (q15_t)0x56a5, (q15_t)0x5693, + (q15_t)0x5680, (q15_t)0x566e, (q15_t)0x565b, (q15_t)0x5649, (q15_t)0x5636, + (q15_t)0x5624, (q15_t)0x5611, (q15_t)0x55fe, (q15_t)0x55ec, (q15_t)0x55d9, + (q15_t)0x55c7, (q15_t)0x55b4, (q15_t)0x55a1, (q15_t)0x558f, (q15_t)0x557c, + (q15_t)0x5569, (q15_t)0x5556, (q15_t)0x5544, (q15_t)0x5531, (q15_t)0x551e, + (q15_t)0x550b, (q15_t)0x54f9, (q15_t)0x54e6, (q15_t)0x54d3, (q15_t)0x54c0, + (q15_t)0x54ad, (q15_t)0x549a, (q15_t)0x5488, (q15_t)0x5475, (q15_t)0x5462, + (q15_t)0x544f, (q15_t)0x543c, (q15_t)0x5429, (q15_t)0x5416, (q15_t)0x5403, + (q15_t)0x53f0, (q15_t)0x53dd, (q15_t)0x53ca, (q15_t)0x53b7, (q15_t)0x53a4, + (q15_t)0x5391, (q15_t)0x537e, (q15_t)0x536b, (q15_t)0x5358, (q15_t)0x5345, + (q15_t)0x5332, (q15_t)0x531f, (q15_t)0x530c, (q15_t)0x52f8, (q15_t)0x52e5, + (q15_t)0x52d2, (q15_t)0x52bf, (q15_t)0x52ac, (q15_t)0x5299, (q15_t)0x5285, + (q15_t)0x5272, (q15_t)0x525f, (q15_t)0x524c, (q15_t)0x5238, (q15_t)0x5225, + (q15_t)0x5212, (q15_t)0x51ff, (q15_t)0x51eb, (q15_t)0x51d8, (q15_t)0x51c5, + (q15_t)0x51b1, (q15_t)0x519e, (q15_t)0x518b, (q15_t)0x5177, (q15_t)0x5164, + (q15_t)0x5150, (q15_t)0x513d, (q15_t)0x512a, (q15_t)0x5116, (q15_t)0x5103, + (q15_t)0x50ef, (q15_t)0x50dc, (q15_t)0x50c8, (q15_t)0x50b5, (q15_t)0x50a1, + (q15_t)0x508e, (q15_t)0x507a, (q15_t)0x5067, (q15_t)0x5053, (q15_t)0x503f, + (q15_t)0x502c, (q15_t)0x5018, (q15_t)0x5005, (q15_t)0x4ff1, (q15_t)0x4fdd, + (q15_t)0x4fca, (q15_t)0x4fb6, (q15_t)0x4fa2, (q15_t)0x4f8f, (q15_t)0x4f7b, + (q15_t)0x4f67, (q15_t)0x4f54, (q15_t)0x4f40, (q15_t)0x4f2c, (q15_t)0x4f18, + (q15_t)0x4f05, (q15_t)0x4ef1, (q15_t)0x4edd, (q15_t)0x4ec9, (q15_t)0x4eb6, + (q15_t)0x4ea2, (q15_t)0x4e8e, (q15_t)0x4e7a, (q15_t)0x4e66, (q15_t)0x4e52, + (q15_t)0x4e3e, (q15_t)0x4e2a, (q15_t)0x4e17, (q15_t)0x4e03, (q15_t)0x4def, + (q15_t)0x4ddb, (q15_t)0x4dc7, (q15_t)0x4db3, (q15_t)0x4d9f, (q15_t)0x4d8b, + (q15_t)0x4d77, (q15_t)0x4d63, (q15_t)0x4d4f, (q15_t)0x4d3b, (q15_t)0x4d27, + (q15_t)0x4d13, (q15_t)0x4cff, (q15_t)0x4ceb, (q15_t)0x4cd6, (q15_t)0x4cc2, + (q15_t)0x4cae, (q15_t)0x4c9a, (q15_t)0x4c86, (q15_t)0x4c72, (q15_t)0x4c5e, + (q15_t)0x4c49, (q15_t)0x4c35, (q15_t)0x4c21, (q15_t)0x4c0d, (q15_t)0x4bf9, + (q15_t)0x4be4, (q15_t)0x4bd0, (q15_t)0x4bbc, (q15_t)0x4ba8, (q15_t)0x4b93, + (q15_t)0x4b7f, (q15_t)0x4b6b, (q15_t)0x4b56, (q15_t)0x4b42, (q15_t)0x4b2e, + (q15_t)0x4b19, (q15_t)0x4b05, (q15_t)0x4af1, (q15_t)0x4adc, (q15_t)0x4ac8, + (q15_t)0x4ab4, (q15_t)0x4a9f, (q15_t)0x4a8b, (q15_t)0x4a76, (q15_t)0x4a62, + (q15_t)0x4a4d, (q15_t)0x4a39, (q15_t)0x4a24, (q15_t)0x4a10, (q15_t)0x49fb, + (q15_t)0x49e7, (q15_t)0x49d2, (q15_t)0x49be, (q15_t)0x49a9, (q15_t)0x4995, + (q15_t)0x4980, (q15_t)0x496c, (q15_t)0x4957, (q15_t)0x4942, (q15_t)0x492e, + (q15_t)0x4919, (q15_t)0x4905, (q15_t)0x48f0, (q15_t)0x48db, (q15_t)0x48c7, + (q15_t)0x48b2, (q15_t)0x489d, (q15_t)0x4888, (q15_t)0x4874, (q15_t)0x485f, + (q15_t)0x484a, (q15_t)0x4836, (q15_t)0x4821, (q15_t)0x480c, (q15_t)0x47f7, + (q15_t)0x47e2, (q15_t)0x47ce, (q15_t)0x47b9, (q15_t)0x47a4, (q15_t)0x478f, + (q15_t)0x477a, (q15_t)0x4765, (q15_t)0x4751, (q15_t)0x473c, (q15_t)0x4727, + (q15_t)0x4712, (q15_t)0x46fd, (q15_t)0x46e8, (q15_t)0x46d3, (q15_t)0x46be, + (q15_t)0x46a9, (q15_t)0x4694, (q15_t)0x467f, (q15_t)0x466a, (q15_t)0x4655, + (q15_t)0x4640, (q15_t)0x462b, (q15_t)0x4616, (q15_t)0x4601, (q15_t)0x45ec, + (q15_t)0x45d7, (q15_t)0x45c2, (q15_t)0x45ad, (q15_t)0x4598, (q15_t)0x4583, + (q15_t)0x456e, (q15_t)0x4559, (q15_t)0x4544, (q15_t)0x452e, (q15_t)0x4519, + (q15_t)0x4504, (q15_t)0x44ef, (q15_t)0x44da, (q15_t)0x44c5, (q15_t)0x44af, + (q15_t)0x449a, (q15_t)0x4485, (q15_t)0x4470, (q15_t)0x445a, (q15_t)0x4445, + (q15_t)0x4430, (q15_t)0x441b, (q15_t)0x4405, (q15_t)0x43f0, (q15_t)0x43db, + (q15_t)0x43c5, (q15_t)0x43b0, (q15_t)0x439b, (q15_t)0x4385, (q15_t)0x4370, + (q15_t)0x435b, (q15_t)0x4345, (q15_t)0x4330, (q15_t)0x431b, (q15_t)0x4305, + (q15_t)0x42f0, (q15_t)0x42da, (q15_t)0x42c5, (q15_t)0x42af, (q15_t)0x429a, + (q15_t)0x4284, (q15_t)0x426f, (q15_t)0x425a, (q15_t)0x4244, (q15_t)0x422f, + (q15_t)0x4219, (q15_t)0x4203, (q15_t)0x41ee, (q15_t)0x41d8, (q15_t)0x41c3, + (q15_t)0x41ad, (q15_t)0x4198, (q15_t)0x4182, (q15_t)0x416d, (q15_t)0x4157, + (q15_t)0x4141, (q15_t)0x412c, (q15_t)0x4116, (q15_t)0x4100, (q15_t)0x40eb, + (q15_t)0x40d5, (q15_t)0x40bf, (q15_t)0x40aa, (q15_t)0x4094, (q15_t)0x407e, + (q15_t)0x4069, (q15_t)0x4053, (q15_t)0x403d, (q15_t)0x4027, (q15_t)0x4012, + (q15_t)0x3ffc, (q15_t)0x3fe6, (q15_t)0x3fd0, (q15_t)0x3fbb, (q15_t)0x3fa5, + (q15_t)0x3f8f, (q15_t)0x3f79, (q15_t)0x3f63, (q15_t)0x3f4d, (q15_t)0x3f38, + (q15_t)0x3f22, (q15_t)0x3f0c, (q15_t)0x3ef6, (q15_t)0x3ee0, (q15_t)0x3eca, + (q15_t)0x3eb4, (q15_t)0x3e9e, (q15_t)0x3e88, (q15_t)0x3e73, (q15_t)0x3e5d, + (q15_t)0x3e47, (q15_t)0x3e31, (q15_t)0x3e1b, (q15_t)0x3e05, (q15_t)0x3def, + (q15_t)0x3dd9, (q15_t)0x3dc3, (q15_t)0x3dad, (q15_t)0x3d97, (q15_t)0x3d81, + (q15_t)0x3d6b, (q15_t)0x3d55, (q15_t)0x3d3e, (q15_t)0x3d28, (q15_t)0x3d12, + (q15_t)0x3cfc, (q15_t)0x3ce6, (q15_t)0x3cd0, (q15_t)0x3cba, (q15_t)0x3ca4, + (q15_t)0x3c8e, (q15_t)0x3c77, (q15_t)0x3c61, (q15_t)0x3c4b, (q15_t)0x3c35, + (q15_t)0x3c1f, (q15_t)0x3c09, (q15_t)0x3bf2, (q15_t)0x3bdc, (q15_t)0x3bc6, + (q15_t)0x3bb0, (q15_t)0x3b99, (q15_t)0x3b83, (q15_t)0x3b6d, (q15_t)0x3b57, + (q15_t)0x3b40, (q15_t)0x3b2a, (q15_t)0x3b14, (q15_t)0x3afe, (q15_t)0x3ae7, + (q15_t)0x3ad1, (q15_t)0x3abb, (q15_t)0x3aa4, (q15_t)0x3a8e, (q15_t)0x3a78, + (q15_t)0x3a61, (q15_t)0x3a4b, (q15_t)0x3a34, (q15_t)0x3a1e, (q15_t)0x3a08, + (q15_t)0x39f1, (q15_t)0x39db, (q15_t)0x39c4, (q15_t)0x39ae, (q15_t)0x3998, + (q15_t)0x3981, (q15_t)0x396b, (q15_t)0x3954, (q15_t)0x393e, (q15_t)0x3927, + (q15_t)0x3911, (q15_t)0x38fa, (q15_t)0x38e4, (q15_t)0x38cd, (q15_t)0x38b7, + (q15_t)0x38a0, (q15_t)0x388a, (q15_t)0x3873, (q15_t)0x385d, (q15_t)0x3846, + (q15_t)0x382f, (q15_t)0x3819, (q15_t)0x3802, (q15_t)0x37ec, (q15_t)0x37d5, + (q15_t)0x37be, (q15_t)0x37a8, (q15_t)0x3791, (q15_t)0x377a, (q15_t)0x3764, + (q15_t)0x374d, (q15_t)0x3736, (q15_t)0x3720, (q15_t)0x3709, (q15_t)0x36f2, + (q15_t)0x36dc, (q15_t)0x36c5, (q15_t)0x36ae, (q15_t)0x3698, (q15_t)0x3681, + (q15_t)0x366a, (q15_t)0x3653, (q15_t)0x363d, (q15_t)0x3626, (q15_t)0x360f, + (q15_t)0x35f8, (q15_t)0x35e1, (q15_t)0x35cb, (q15_t)0x35b4, (q15_t)0x359d, + (q15_t)0x3586, (q15_t)0x356f, (q15_t)0x3558, (q15_t)0x3542, (q15_t)0x352b, + (q15_t)0x3514, (q15_t)0x34fd, (q15_t)0x34e6, (q15_t)0x34cf, (q15_t)0x34b8, + (q15_t)0x34a1, (q15_t)0x348b, (q15_t)0x3474, (q15_t)0x345d, (q15_t)0x3446, + (q15_t)0x342f, (q15_t)0x3418, (q15_t)0x3401, (q15_t)0x33ea, (q15_t)0x33d3, + (q15_t)0x33bc, (q15_t)0x33a5, (q15_t)0x338e, (q15_t)0x3377, (q15_t)0x3360, + (q15_t)0x3349, (q15_t)0x3332, (q15_t)0x331b, (q15_t)0x3304, (q15_t)0x32ed, + (q15_t)0x32d6, (q15_t)0x32bf, (q15_t)0x32a8, (q15_t)0x3290, (q15_t)0x3279, + (q15_t)0x3262, (q15_t)0x324b, (q15_t)0x3234, (q15_t)0x321d, (q15_t)0x3206, + (q15_t)0x31ef, (q15_t)0x31d8, (q15_t)0x31c0, (q15_t)0x31a9, (q15_t)0x3192, + (q15_t)0x317b, (q15_t)0x3164, (q15_t)0x314c, (q15_t)0x3135, (q15_t)0x311e, + (q15_t)0x3107, (q15_t)0x30f0, (q15_t)0x30d8, (q15_t)0x30c1, (q15_t)0x30aa, + (q15_t)0x3093, (q15_t)0x307b, (q15_t)0x3064, (q15_t)0x304d, (q15_t)0x3036, + (q15_t)0x301e, (q15_t)0x3007, (q15_t)0x2ff0, (q15_t)0x2fd8, (q15_t)0x2fc1, + (q15_t)0x2faa, (q15_t)0x2f92, (q15_t)0x2f7b, (q15_t)0x2f64, (q15_t)0x2f4c, + (q15_t)0x2f35, (q15_t)0x2f1e, (q15_t)0x2f06, (q15_t)0x2eef, (q15_t)0x2ed8, + (q15_t)0x2ec0, (q15_t)0x2ea9, (q15_t)0x2e91, (q15_t)0x2e7a, (q15_t)0x2e63, + (q15_t)0x2e4b, (q15_t)0x2e34, (q15_t)0x2e1c, (q15_t)0x2e05, (q15_t)0x2ded, + (q15_t)0x2dd6, (q15_t)0x2dbe, (q15_t)0x2da7, (q15_t)0x2d8f, (q15_t)0x2d78, + (q15_t)0x2d60, (q15_t)0x2d49, (q15_t)0x2d31, (q15_t)0x2d1a, (q15_t)0x2d02, + (q15_t)0x2ceb, (q15_t)0x2cd3, (q15_t)0x2cbc, (q15_t)0x2ca4, (q15_t)0x2c8d, + (q15_t)0x2c75, (q15_t)0x2c5e, (q15_t)0x2c46, (q15_t)0x2c2e, (q15_t)0x2c17, + (q15_t)0x2bff, (q15_t)0x2be8, (q15_t)0x2bd0, (q15_t)0x2bb8, (q15_t)0x2ba1, + (q15_t)0x2b89, (q15_t)0x2b71, (q15_t)0x2b5a, (q15_t)0x2b42, (q15_t)0x2b2b, + (q15_t)0x2b13, (q15_t)0x2afb, (q15_t)0x2ae4, (q15_t)0x2acc, (q15_t)0x2ab4, + (q15_t)0x2a9c, (q15_t)0x2a85, (q15_t)0x2a6d, (q15_t)0x2a55, (q15_t)0x2a3e, + (q15_t)0x2a26, (q15_t)0x2a0e, (q15_t)0x29f6, (q15_t)0x29df, (q15_t)0x29c7, + (q15_t)0x29af, (q15_t)0x2997, (q15_t)0x2980, (q15_t)0x2968, (q15_t)0x2950, + (q15_t)0x2938, (q15_t)0x2920, (q15_t)0x2909, (q15_t)0x28f1, (q15_t)0x28d9, + (q15_t)0x28c1, (q15_t)0x28a9, (q15_t)0x2892, (q15_t)0x287a, (q15_t)0x2862, + (q15_t)0x284a, (q15_t)0x2832, (q15_t)0x281a, (q15_t)0x2802, (q15_t)0x27eb, + (q15_t)0x27d3, (q15_t)0x27bb, (q15_t)0x27a3, (q15_t)0x278b, (q15_t)0x2773, + (q15_t)0x275b, (q15_t)0x2743, (q15_t)0x272b, (q15_t)0x2713, (q15_t)0x26fb, + (q15_t)0x26e4, (q15_t)0x26cc, (q15_t)0x26b4, (q15_t)0x269c, (q15_t)0x2684, + (q15_t)0x266c, (q15_t)0x2654, (q15_t)0x263c, (q15_t)0x2624, (q15_t)0x260c, + (q15_t)0x25f4, (q15_t)0x25dc, (q15_t)0x25c4, (q15_t)0x25ac, (q15_t)0x2594, + (q15_t)0x257c, (q15_t)0x2564, (q15_t)0x254c, (q15_t)0x2534, (q15_t)0x251c, + (q15_t)0x2503, (q15_t)0x24eb, (q15_t)0x24d3, (q15_t)0x24bb, (q15_t)0x24a3, + (q15_t)0x248b, (q15_t)0x2473, (q15_t)0x245b, (q15_t)0x2443, (q15_t)0x242b, + (q15_t)0x2413, (q15_t)0x23fa, (q15_t)0x23e2, (q15_t)0x23ca, (q15_t)0x23b2, + (q15_t)0x239a, (q15_t)0x2382, (q15_t)0x236a, (q15_t)0x2352, (q15_t)0x2339, + (q15_t)0x2321, (q15_t)0x2309, (q15_t)0x22f1, (q15_t)0x22d9, (q15_t)0x22c0, + (q15_t)0x22a8, (q15_t)0x2290, (q15_t)0x2278, (q15_t)0x2260, (q15_t)0x2247, + (q15_t)0x222f, (q15_t)0x2217, (q15_t)0x21ff, (q15_t)0x21e7, (q15_t)0x21ce, + (q15_t)0x21b6, (q15_t)0x219e, (q15_t)0x2186, (q15_t)0x216d, (q15_t)0x2155, + (q15_t)0x213d, (q15_t)0x2125, (q15_t)0x210c, (q15_t)0x20f4, (q15_t)0x20dc, + (q15_t)0x20c3, (q15_t)0x20ab, (q15_t)0x2093, (q15_t)0x207a, (q15_t)0x2062, + (q15_t)0x204a, (q15_t)0x2032, (q15_t)0x2019, (q15_t)0x2001, (q15_t)0x1fe9, + (q15_t)0x1fd0, (q15_t)0x1fb8, (q15_t)0x1f9f, (q15_t)0x1f87, (q15_t)0x1f6f, + (q15_t)0x1f56, (q15_t)0x1f3e, (q15_t)0x1f26, (q15_t)0x1f0d, (q15_t)0x1ef5, + (q15_t)0x1edd, (q15_t)0x1ec4, (q15_t)0x1eac, (q15_t)0x1e93, (q15_t)0x1e7b, + (q15_t)0x1e62, (q15_t)0x1e4a, (q15_t)0x1e32, (q15_t)0x1e19, (q15_t)0x1e01, + (q15_t)0x1de8, (q15_t)0x1dd0, (q15_t)0x1db7, (q15_t)0x1d9f, (q15_t)0x1d87, + (q15_t)0x1d6e, (q15_t)0x1d56, (q15_t)0x1d3d, (q15_t)0x1d25, (q15_t)0x1d0c, + (q15_t)0x1cf4, (q15_t)0x1cdb, (q15_t)0x1cc3, (q15_t)0x1caa, (q15_t)0x1c92, + (q15_t)0x1c79, (q15_t)0x1c61, (q15_t)0x1c48, (q15_t)0x1c30, (q15_t)0x1c17, + (q15_t)0x1bff, (q15_t)0x1be6, (q15_t)0x1bce, (q15_t)0x1bb5, (q15_t)0x1b9d, + (q15_t)0x1b84, (q15_t)0x1b6c, (q15_t)0x1b53, (q15_t)0x1b3a, (q15_t)0x1b22, + (q15_t)0x1b09, (q15_t)0x1af1, (q15_t)0x1ad8, (q15_t)0x1ac0, (q15_t)0x1aa7, + (q15_t)0x1a8e, (q15_t)0x1a76, (q15_t)0x1a5d, (q15_t)0x1a45, (q15_t)0x1a2c, + (q15_t)0x1a13, (q15_t)0x19fb, (q15_t)0x19e2, (q15_t)0x19ca, (q15_t)0x19b1, + (q15_t)0x1998, (q15_t)0x1980, (q15_t)0x1967, (q15_t)0x194e, (q15_t)0x1936, + (q15_t)0x191d, (q15_t)0x1905, (q15_t)0x18ec, (q15_t)0x18d3, (q15_t)0x18bb, + (q15_t)0x18a2, (q15_t)0x1889, (q15_t)0x1871, (q15_t)0x1858, (q15_t)0x183f, + (q15_t)0x1827, (q15_t)0x180e, (q15_t)0x17f5, (q15_t)0x17dd, (q15_t)0x17c4, + (q15_t)0x17ab, (q15_t)0x1792, (q15_t)0x177a, (q15_t)0x1761, (q15_t)0x1748, + (q15_t)0x1730, (q15_t)0x1717, (q15_t)0x16fe, (q15_t)0x16e5, (q15_t)0x16cd, + (q15_t)0x16b4, (q15_t)0x169b, (q15_t)0x1682, (q15_t)0x166a, (q15_t)0x1651, + (q15_t)0x1638, (q15_t)0x161f, (q15_t)0x1607, (q15_t)0x15ee, (q15_t)0x15d5, + (q15_t)0x15bc, (q15_t)0x15a4, (q15_t)0x158b, (q15_t)0x1572, (q15_t)0x1559, + (q15_t)0x1541, (q15_t)0x1528, (q15_t)0x150f, (q15_t)0x14f6, (q15_t)0x14dd, + (q15_t)0x14c5, (q15_t)0x14ac, (q15_t)0x1493, (q15_t)0x147a, (q15_t)0x1461, + (q15_t)0x1449, (q15_t)0x1430, (q15_t)0x1417, (q15_t)0x13fe, (q15_t)0x13e5, + (q15_t)0x13cc, (q15_t)0x13b4, (q15_t)0x139b, (q15_t)0x1382, (q15_t)0x1369, + (q15_t)0x1350, (q15_t)0x1337, (q15_t)0x131f, (q15_t)0x1306, (q15_t)0x12ed, + (q15_t)0x12d4, (q15_t)0x12bb, (q15_t)0x12a2, (q15_t)0x1289, (q15_t)0x1271, + (q15_t)0x1258, (q15_t)0x123f, (q15_t)0x1226, (q15_t)0x120d, (q15_t)0x11f4, + (q15_t)0x11db, (q15_t)0x11c2, (q15_t)0x11a9, (q15_t)0x1191, (q15_t)0x1178, + (q15_t)0x115f, (q15_t)0x1146, (q15_t)0x112d, (q15_t)0x1114, (q15_t)0x10fb, + (q15_t)0x10e2, (q15_t)0x10c9, (q15_t)0x10b0, (q15_t)0x1098, (q15_t)0x107f, + (q15_t)0x1066, (q15_t)0x104d, (q15_t)0x1034, (q15_t)0x101b, (q15_t)0x1002, + (q15_t)0xfe9, (q15_t)0xfd0, (q15_t)0xfb7, (q15_t)0xf9e, (q15_t)0xf85, + (q15_t)0xf6c, (q15_t)0xf53, (q15_t)0xf3a, (q15_t)0xf21, (q15_t)0xf08, + (q15_t)0xef0, (q15_t)0xed7, (q15_t)0xebe, (q15_t)0xea5, (q15_t)0xe8c, + (q15_t)0xe73, (q15_t)0xe5a, (q15_t)0xe41, (q15_t)0xe28, (q15_t)0xe0f, + (q15_t)0xdf6, (q15_t)0xddd, (q15_t)0xdc4, (q15_t)0xdab, (q15_t)0xd92, + (q15_t)0xd79, (q15_t)0xd60, (q15_t)0xd47, (q15_t)0xd2e, (q15_t)0xd15, + (q15_t)0xcfc, (q15_t)0xce3, (q15_t)0xcca, (q15_t)0xcb1, (q15_t)0xc98, + (q15_t)0xc7f, (q15_t)0xc66, (q15_t)0xc4d, (q15_t)0xc34, (q15_t)0xc1b, + (q15_t)0xc02, (q15_t)0xbe9, (q15_t)0xbd0, (q15_t)0xbb7, (q15_t)0xb9e, + (q15_t)0xb85, (q15_t)0xb6c, (q15_t)0xb53, (q15_t)0xb3a, (q15_t)0xb20, + (q15_t)0xb07, (q15_t)0xaee, (q15_t)0xad5, (q15_t)0xabc, (q15_t)0xaa3, + (q15_t)0xa8a, (q15_t)0xa71, (q15_t)0xa58, (q15_t)0xa3f, (q15_t)0xa26, + (q15_t)0xa0d, (q15_t)0x9f4, (q15_t)0x9db, (q15_t)0x9c2, (q15_t)0x9a9, + (q15_t)0x990, (q15_t)0x977, (q15_t)0x95e, (q15_t)0x944, (q15_t)0x92b, + (q15_t)0x912, (q15_t)0x8f9, (q15_t)0x8e0, (q15_t)0x8c7, (q15_t)0x8ae, + (q15_t)0x895, (q15_t)0x87c, (q15_t)0x863, (q15_t)0x84a, (q15_t)0x831, + (q15_t)0x818, (q15_t)0x7fe, (q15_t)0x7e5, (q15_t)0x7cc, (q15_t)0x7b3, + (q15_t)0x79a, (q15_t)0x781, (q15_t)0x768, (q15_t)0x74f, (q15_t)0x736, + (q15_t)0x71d, (q15_t)0x704, (q15_t)0x6ea, (q15_t)0x6d1, (q15_t)0x6b8, + (q15_t)0x69f, (q15_t)0x686, (q15_t)0x66d, (q15_t)0x654, (q15_t)0x63b, + (q15_t)0x622, (q15_t)0x609, (q15_t)0x5ef, (q15_t)0x5d6, (q15_t)0x5bd, + (q15_t)0x5a4, (q15_t)0x58b, (q15_t)0x572, (q15_t)0x559, (q15_t)0x540, + (q15_t)0x527, (q15_t)0x50d, (q15_t)0x4f4, (q15_t)0x4db, (q15_t)0x4c2, + (q15_t)0x4a9, (q15_t)0x490, (q15_t)0x477, (q15_t)0x45e, (q15_t)0x445, + (q15_t)0x42b, (q15_t)0x412, (q15_t)0x3f9, (q15_t)0x3e0, (q15_t)0x3c7, + (q15_t)0x3ae, (q15_t)0x395, (q15_t)0x37c, (q15_t)0x362, (q15_t)0x349, + (q15_t)0x330, (q15_t)0x317, (q15_t)0x2fe, (q15_t)0x2e5, (q15_t)0x2cc, + (q15_t)0x2b3, (q15_t)0x299, (q15_t)0x280, (q15_t)0x267, (q15_t)0x24e, + (q15_t)0x235, (q15_t)0x21c, (q15_t)0x203, (q15_t)0x1ea, (q15_t)0x1d0, + (q15_t)0x1b7, (q15_t)0x19e, (q15_t)0x185, (q15_t)0x16c, (q15_t)0x153, + (q15_t)0x13a, (q15_t)0x121, (q15_t)0x107, (q15_t)0xee, (q15_t)0xd5, + (q15_t)0xbc, (q15_t)0xa3, (q15_t)0x8a, (q15_t)0x71, (q15_t)0x57, + (q15_t)0x3e, (q15_t)0x25, (q15_t)0xc }; static const q15_t __ALIGNED(4) cos_factorsQ15_8192[8192] = { - (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, - (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, - (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, - (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, - (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, - (q15_t)0x7fff, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, - (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, - (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffd, (q15_t)0x7ffd, (q15_t)0x7ffd, (q15_t)0x7ffd, (q15_t)0x7ffd, (q15_t)0x7ffd, - (q15_t)0x7ffd, (q15_t)0x7ffd, (q15_t)0x7ffd, (q15_t)0x7ffd, (q15_t)0x7ffd, (q15_t)0x7ffd, (q15_t)0x7ffd, (q15_t)0x7ffc, - (q15_t)0x7ffc, (q15_t)0x7ffc, (q15_t)0x7ffc, (q15_t)0x7ffc, (q15_t)0x7ffc, (q15_t)0x7ffc, (q15_t)0x7ffc, (q15_t)0x7ffc, - (q15_t)0x7ffc, (q15_t)0x7ffb, (q15_t)0x7ffb, (q15_t)0x7ffb, (q15_t)0x7ffb, (q15_t)0x7ffb, (q15_t)0x7ffb, (q15_t)0x7ffb, - (q15_t)0x7ffb, (q15_t)0x7ffb, (q15_t)0x7ffb, (q15_t)0x7ffa, (q15_t)0x7ffa, (q15_t)0x7ffa, (q15_t)0x7ffa, (q15_t)0x7ffa, - (q15_t)0x7ffa, (q15_t)0x7ffa, (q15_t)0x7ffa, (q15_t)0x7ffa, (q15_t)0x7ff9, (q15_t)0x7ff9, (q15_t)0x7ff9, (q15_t)0x7ff9, - (q15_t)0x7ff9, (q15_t)0x7ff9, (q15_t)0x7ff9, (q15_t)0x7ff9, (q15_t)0x7ff8, (q15_t)0x7ff8, (q15_t)0x7ff8, (q15_t)0x7ff8, - (q15_t)0x7ff8, (q15_t)0x7ff8, (q15_t)0x7ff8, (q15_t)0x7ff7, (q15_t)0x7ff7, (q15_t)0x7ff7, (q15_t)0x7ff7, (q15_t)0x7ff7, - (q15_t)0x7ff7, (q15_t)0x7ff7, (q15_t)0x7ff6, (q15_t)0x7ff6, (q15_t)0x7ff6, (q15_t)0x7ff6, (q15_t)0x7ff6, (q15_t)0x7ff6, - (q15_t)0x7ff6, (q15_t)0x7ff5, (q15_t)0x7ff5, (q15_t)0x7ff5, (q15_t)0x7ff5, (q15_t)0x7ff5, (q15_t)0x7ff5, (q15_t)0x7ff4, - (q15_t)0x7ff4, (q15_t)0x7ff4, (q15_t)0x7ff4, (q15_t)0x7ff4, (q15_t)0x7ff4, (q15_t)0x7ff3, (q15_t)0x7ff3, (q15_t)0x7ff3, - (q15_t)0x7ff3, (q15_t)0x7ff3, (q15_t)0x7ff3, (q15_t)0x7ff2, (q15_t)0x7ff2, (q15_t)0x7ff2, (q15_t)0x7ff2, (q15_t)0x7ff2, - (q15_t)0x7ff1, (q15_t)0x7ff1, (q15_t)0x7ff1, (q15_t)0x7ff1, (q15_t)0x7ff1, (q15_t)0x7ff1, (q15_t)0x7ff0, (q15_t)0x7ff0, - (q15_t)0x7ff0, (q15_t)0x7ff0, (q15_t)0x7ff0, (q15_t)0x7fef, (q15_t)0x7fef, (q15_t)0x7fef, (q15_t)0x7fef, (q15_t)0x7fef, - (q15_t)0x7fee, (q15_t)0x7fee, (q15_t)0x7fee, (q15_t)0x7fee, (q15_t)0x7fee, (q15_t)0x7fed, (q15_t)0x7fed, (q15_t)0x7fed, - (q15_t)0x7fed, (q15_t)0x7fed, (q15_t)0x7fec, (q15_t)0x7fec, (q15_t)0x7fec, (q15_t)0x7fec, (q15_t)0x7feb, (q15_t)0x7feb, - (q15_t)0x7feb, (q15_t)0x7feb, (q15_t)0x7feb, (q15_t)0x7fea, (q15_t)0x7fea, (q15_t)0x7fea, (q15_t)0x7fea, (q15_t)0x7fe9, - (q15_t)0x7fe9, (q15_t)0x7fe9, (q15_t)0x7fe9, (q15_t)0x7fe8, (q15_t)0x7fe8, (q15_t)0x7fe8, (q15_t)0x7fe8, (q15_t)0x7fe8, - (q15_t)0x7fe7, (q15_t)0x7fe7, (q15_t)0x7fe7, (q15_t)0x7fe7, (q15_t)0x7fe6, (q15_t)0x7fe6, (q15_t)0x7fe6, (q15_t)0x7fe6, - (q15_t)0x7fe5, (q15_t)0x7fe5, (q15_t)0x7fe5, (q15_t)0x7fe5, (q15_t)0x7fe4, (q15_t)0x7fe4, (q15_t)0x7fe4, (q15_t)0x7fe4, - (q15_t)0x7fe3, (q15_t)0x7fe3, (q15_t)0x7fe3, (q15_t)0x7fe2, (q15_t)0x7fe2, (q15_t)0x7fe2, (q15_t)0x7fe2, (q15_t)0x7fe1, - (q15_t)0x7fe1, (q15_t)0x7fe1, (q15_t)0x7fe1, (q15_t)0x7fe0, (q15_t)0x7fe0, (q15_t)0x7fe0, (q15_t)0x7fdf, (q15_t)0x7fdf, - (q15_t)0x7fdf, (q15_t)0x7fdf, (q15_t)0x7fde, (q15_t)0x7fde, (q15_t)0x7fde, (q15_t)0x7fde, (q15_t)0x7fdd, (q15_t)0x7fdd, - (q15_t)0x7fdd, (q15_t)0x7fdc, (q15_t)0x7fdc, (q15_t)0x7fdc, (q15_t)0x7fdb, (q15_t)0x7fdb, (q15_t)0x7fdb, (q15_t)0x7fdb, - (q15_t)0x7fda, (q15_t)0x7fda, (q15_t)0x7fda, (q15_t)0x7fd9, (q15_t)0x7fd9, (q15_t)0x7fd9, (q15_t)0x7fd8, (q15_t)0x7fd8, - (q15_t)0x7fd8, (q15_t)0x7fd8, (q15_t)0x7fd7, (q15_t)0x7fd7, (q15_t)0x7fd7, (q15_t)0x7fd6, (q15_t)0x7fd6, (q15_t)0x7fd6, - (q15_t)0x7fd5, (q15_t)0x7fd5, (q15_t)0x7fd5, (q15_t)0x7fd4, (q15_t)0x7fd4, (q15_t)0x7fd4, (q15_t)0x7fd3, (q15_t)0x7fd3, - (q15_t)0x7fd3, (q15_t)0x7fd2, (q15_t)0x7fd2, (q15_t)0x7fd2, (q15_t)0x7fd1, (q15_t)0x7fd1, (q15_t)0x7fd1, (q15_t)0x7fd0, - (q15_t)0x7fd0, (q15_t)0x7fd0, (q15_t)0x7fcf, (q15_t)0x7fcf, (q15_t)0x7fcf, (q15_t)0x7fce, (q15_t)0x7fce, (q15_t)0x7fce, - (q15_t)0x7fcd, (q15_t)0x7fcd, (q15_t)0x7fcd, (q15_t)0x7fcc, (q15_t)0x7fcc, (q15_t)0x7fcc, (q15_t)0x7fcb, (q15_t)0x7fcb, - (q15_t)0x7fcb, (q15_t)0x7fca, (q15_t)0x7fca, (q15_t)0x7fc9, (q15_t)0x7fc9, (q15_t)0x7fc9, (q15_t)0x7fc8, (q15_t)0x7fc8, - (q15_t)0x7fc8, (q15_t)0x7fc7, (q15_t)0x7fc7, (q15_t)0x7fc7, (q15_t)0x7fc6, (q15_t)0x7fc6, (q15_t)0x7fc5, (q15_t)0x7fc5, - (q15_t)0x7fc5, (q15_t)0x7fc4, (q15_t)0x7fc4, (q15_t)0x7fc4, (q15_t)0x7fc3, (q15_t)0x7fc3, (q15_t)0x7fc2, (q15_t)0x7fc2, - (q15_t)0x7fc2, (q15_t)0x7fc1, (q15_t)0x7fc1, (q15_t)0x7fc0, (q15_t)0x7fc0, (q15_t)0x7fc0, (q15_t)0x7fbf, (q15_t)0x7fbf, - (q15_t)0x7fbf, (q15_t)0x7fbe, (q15_t)0x7fbe, (q15_t)0x7fbd, (q15_t)0x7fbd, (q15_t)0x7fbd, (q15_t)0x7fbc, (q15_t)0x7fbc, - (q15_t)0x7fbb, (q15_t)0x7fbb, (q15_t)0x7fbb, (q15_t)0x7fba, (q15_t)0x7fba, (q15_t)0x7fb9, (q15_t)0x7fb9, (q15_t)0x7fb8, - (q15_t)0x7fb8, (q15_t)0x7fb8, (q15_t)0x7fb7, (q15_t)0x7fb7, (q15_t)0x7fb6, (q15_t)0x7fb6, (q15_t)0x7fb6, (q15_t)0x7fb5, - (q15_t)0x7fb5, (q15_t)0x7fb4, (q15_t)0x7fb4, (q15_t)0x7fb3, (q15_t)0x7fb3, (q15_t)0x7fb3, (q15_t)0x7fb2, (q15_t)0x7fb2, - (q15_t)0x7fb1, (q15_t)0x7fb1, (q15_t)0x7fb0, (q15_t)0x7fb0, (q15_t)0x7faf, (q15_t)0x7faf, (q15_t)0x7faf, (q15_t)0x7fae, - (q15_t)0x7fae, (q15_t)0x7fad, (q15_t)0x7fad, (q15_t)0x7fac, (q15_t)0x7fac, (q15_t)0x7fac, (q15_t)0x7fab, (q15_t)0x7fab, - (q15_t)0x7faa, (q15_t)0x7faa, (q15_t)0x7fa9, (q15_t)0x7fa9, (q15_t)0x7fa8, (q15_t)0x7fa8, (q15_t)0x7fa7, (q15_t)0x7fa7, - (q15_t)0x7fa6, (q15_t)0x7fa6, (q15_t)0x7fa6, (q15_t)0x7fa5, (q15_t)0x7fa5, (q15_t)0x7fa4, (q15_t)0x7fa4, (q15_t)0x7fa3, - (q15_t)0x7fa3, (q15_t)0x7fa2, (q15_t)0x7fa2, (q15_t)0x7fa1, (q15_t)0x7fa1, (q15_t)0x7fa0, (q15_t)0x7fa0, (q15_t)0x7f9f, - (q15_t)0x7f9f, (q15_t)0x7f9e, (q15_t)0x7f9e, (q15_t)0x7f9d, (q15_t)0x7f9d, (q15_t)0x7f9c, (q15_t)0x7f9c, (q15_t)0x7f9c, - (q15_t)0x7f9b, (q15_t)0x7f9b, (q15_t)0x7f9a, (q15_t)0x7f9a, (q15_t)0x7f99, (q15_t)0x7f99, (q15_t)0x7f98, (q15_t)0x7f98, - (q15_t)0x7f97, (q15_t)0x7f97, (q15_t)0x7f96, (q15_t)0x7f96, (q15_t)0x7f95, (q15_t)0x7f95, (q15_t)0x7f94, (q15_t)0x7f94, - (q15_t)0x7f93, (q15_t)0x7f92, (q15_t)0x7f92, (q15_t)0x7f91, (q15_t)0x7f91, (q15_t)0x7f90, (q15_t)0x7f90, (q15_t)0x7f8f, - (q15_t)0x7f8f, (q15_t)0x7f8e, (q15_t)0x7f8e, (q15_t)0x7f8d, (q15_t)0x7f8d, (q15_t)0x7f8c, (q15_t)0x7f8c, (q15_t)0x7f8b, - (q15_t)0x7f8b, (q15_t)0x7f8a, (q15_t)0x7f8a, (q15_t)0x7f89, (q15_t)0x7f89, (q15_t)0x7f88, (q15_t)0x7f87, (q15_t)0x7f87, - (q15_t)0x7f86, (q15_t)0x7f86, (q15_t)0x7f85, (q15_t)0x7f85, (q15_t)0x7f84, (q15_t)0x7f84, (q15_t)0x7f83, (q15_t)0x7f83, - (q15_t)0x7f82, (q15_t)0x7f81, (q15_t)0x7f81, (q15_t)0x7f80, (q15_t)0x7f80, (q15_t)0x7f7f, (q15_t)0x7f7f, (q15_t)0x7f7e, - (q15_t)0x7f7e, (q15_t)0x7f7d, (q15_t)0x7f7c, (q15_t)0x7f7c, (q15_t)0x7f7b, (q15_t)0x7f7b, (q15_t)0x7f7a, (q15_t)0x7f7a, - (q15_t)0x7f79, (q15_t)0x7f79, (q15_t)0x7f78, (q15_t)0x7f77, (q15_t)0x7f77, (q15_t)0x7f76, (q15_t)0x7f76, (q15_t)0x7f75, - (q15_t)0x7f75, (q15_t)0x7f74, (q15_t)0x7f73, (q15_t)0x7f73, (q15_t)0x7f72, (q15_t)0x7f72, (q15_t)0x7f71, (q15_t)0x7f70, - (q15_t)0x7f70, (q15_t)0x7f6f, (q15_t)0x7f6f, (q15_t)0x7f6e, (q15_t)0x7f6d, (q15_t)0x7f6d, (q15_t)0x7f6c, (q15_t)0x7f6c, - (q15_t)0x7f6b, (q15_t)0x7f6b, (q15_t)0x7f6a, (q15_t)0x7f69, (q15_t)0x7f69, (q15_t)0x7f68, (q15_t)0x7f68, (q15_t)0x7f67, - (q15_t)0x7f66, (q15_t)0x7f66, (q15_t)0x7f65, (q15_t)0x7f64, (q15_t)0x7f64, (q15_t)0x7f63, (q15_t)0x7f63, (q15_t)0x7f62, - (q15_t)0x7f61, (q15_t)0x7f61, (q15_t)0x7f60, (q15_t)0x7f60, (q15_t)0x7f5f, (q15_t)0x7f5e, (q15_t)0x7f5e, (q15_t)0x7f5d, - (q15_t)0x7f5c, (q15_t)0x7f5c, (q15_t)0x7f5b, (q15_t)0x7f5b, (q15_t)0x7f5a, (q15_t)0x7f59, (q15_t)0x7f59, (q15_t)0x7f58, - (q15_t)0x7f57, (q15_t)0x7f57, (q15_t)0x7f56, (q15_t)0x7f55, (q15_t)0x7f55, (q15_t)0x7f54, (q15_t)0x7f54, (q15_t)0x7f53, - (q15_t)0x7f52, (q15_t)0x7f52, (q15_t)0x7f51, (q15_t)0x7f50, (q15_t)0x7f50, (q15_t)0x7f4f, (q15_t)0x7f4e, (q15_t)0x7f4e, - (q15_t)0x7f4d, (q15_t)0x7f4c, (q15_t)0x7f4c, (q15_t)0x7f4b, (q15_t)0x7f4a, (q15_t)0x7f4a, (q15_t)0x7f49, (q15_t)0x7f48, - (q15_t)0x7f48, (q15_t)0x7f47, (q15_t)0x7f46, (q15_t)0x7f46, (q15_t)0x7f45, (q15_t)0x7f44, (q15_t)0x7f44, (q15_t)0x7f43, - (q15_t)0x7f42, (q15_t)0x7f42, (q15_t)0x7f41, (q15_t)0x7f40, (q15_t)0x7f40, (q15_t)0x7f3f, (q15_t)0x7f3e, (q15_t)0x7f3e, - (q15_t)0x7f3d, (q15_t)0x7f3c, (q15_t)0x7f3c, (q15_t)0x7f3b, (q15_t)0x7f3a, (q15_t)0x7f3a, (q15_t)0x7f39, (q15_t)0x7f38, - (q15_t)0x7f37, (q15_t)0x7f37, (q15_t)0x7f36, (q15_t)0x7f35, (q15_t)0x7f35, (q15_t)0x7f34, (q15_t)0x7f33, (q15_t)0x7f33, - (q15_t)0x7f32, (q15_t)0x7f31, (q15_t)0x7f31, (q15_t)0x7f30, (q15_t)0x7f2f, (q15_t)0x7f2e, (q15_t)0x7f2e, (q15_t)0x7f2d, - (q15_t)0x7f2c, (q15_t)0x7f2c, (q15_t)0x7f2b, (q15_t)0x7f2a, (q15_t)0x7f29, (q15_t)0x7f29, (q15_t)0x7f28, (q15_t)0x7f27, - (q15_t)0x7f27, (q15_t)0x7f26, (q15_t)0x7f25, (q15_t)0x7f24, (q15_t)0x7f24, (q15_t)0x7f23, (q15_t)0x7f22, (q15_t)0x7f21, - (q15_t)0x7f21, (q15_t)0x7f20, (q15_t)0x7f1f, (q15_t)0x7f1f, (q15_t)0x7f1e, (q15_t)0x7f1d, (q15_t)0x7f1c, (q15_t)0x7f1c, - (q15_t)0x7f1b, (q15_t)0x7f1a, (q15_t)0x7f19, (q15_t)0x7f19, (q15_t)0x7f18, (q15_t)0x7f17, (q15_t)0x7f16, (q15_t)0x7f16, - (q15_t)0x7f15, (q15_t)0x7f14, (q15_t)0x7f13, (q15_t)0x7f13, (q15_t)0x7f12, (q15_t)0x7f11, (q15_t)0x7f10, (q15_t)0x7f10, - (q15_t)0x7f0f, (q15_t)0x7f0e, (q15_t)0x7f0d, (q15_t)0x7f0d, (q15_t)0x7f0c, (q15_t)0x7f0b, (q15_t)0x7f0a, (q15_t)0x7f09, - (q15_t)0x7f09, (q15_t)0x7f08, (q15_t)0x7f07, (q15_t)0x7f06, (q15_t)0x7f06, (q15_t)0x7f05, (q15_t)0x7f04, (q15_t)0x7f03, - (q15_t)0x7f02, (q15_t)0x7f02, (q15_t)0x7f01, (q15_t)0x7f00, (q15_t)0x7eff, (q15_t)0x7eff, (q15_t)0x7efe, (q15_t)0x7efd, - (q15_t)0x7efc, (q15_t)0x7efb, (q15_t)0x7efb, (q15_t)0x7efa, (q15_t)0x7ef9, (q15_t)0x7ef8, (q15_t)0x7ef7, (q15_t)0x7ef7, - (q15_t)0x7ef6, (q15_t)0x7ef5, (q15_t)0x7ef4, (q15_t)0x7ef3, (q15_t)0x7ef3, (q15_t)0x7ef2, (q15_t)0x7ef1, (q15_t)0x7ef0, - (q15_t)0x7eef, (q15_t)0x7eef, (q15_t)0x7eee, (q15_t)0x7eed, (q15_t)0x7eec, (q15_t)0x7eeb, (q15_t)0x7eeb, (q15_t)0x7eea, - (q15_t)0x7ee9, (q15_t)0x7ee8, (q15_t)0x7ee7, (q15_t)0x7ee6, (q15_t)0x7ee6, (q15_t)0x7ee5, (q15_t)0x7ee4, (q15_t)0x7ee3, - (q15_t)0x7ee2, (q15_t)0x7ee2, (q15_t)0x7ee1, (q15_t)0x7ee0, (q15_t)0x7edf, (q15_t)0x7ede, (q15_t)0x7edd, (q15_t)0x7edd, - (q15_t)0x7edc, (q15_t)0x7edb, (q15_t)0x7eda, (q15_t)0x7ed9, (q15_t)0x7ed8, (q15_t)0x7ed8, (q15_t)0x7ed7, (q15_t)0x7ed6, - (q15_t)0x7ed5, (q15_t)0x7ed4, (q15_t)0x7ed3, (q15_t)0x7ed2, (q15_t)0x7ed2, (q15_t)0x7ed1, (q15_t)0x7ed0, (q15_t)0x7ecf, - (q15_t)0x7ece, (q15_t)0x7ecd, (q15_t)0x7ecc, (q15_t)0x7ecc, (q15_t)0x7ecb, (q15_t)0x7eca, (q15_t)0x7ec9, (q15_t)0x7ec8, - (q15_t)0x7ec7, (q15_t)0x7ec6, (q15_t)0x7ec6, (q15_t)0x7ec5, (q15_t)0x7ec4, (q15_t)0x7ec3, (q15_t)0x7ec2, (q15_t)0x7ec1, - (q15_t)0x7ec0, (q15_t)0x7ebf, (q15_t)0x7ebf, (q15_t)0x7ebe, (q15_t)0x7ebd, (q15_t)0x7ebc, (q15_t)0x7ebb, (q15_t)0x7eba, - (q15_t)0x7eb9, (q15_t)0x7eb8, (q15_t)0x7eb8, (q15_t)0x7eb7, (q15_t)0x7eb6, (q15_t)0x7eb5, (q15_t)0x7eb4, (q15_t)0x7eb3, - (q15_t)0x7eb2, (q15_t)0x7eb1, (q15_t)0x7eb0, (q15_t)0x7eaf, (q15_t)0x7eaf, (q15_t)0x7eae, (q15_t)0x7ead, (q15_t)0x7eac, - (q15_t)0x7eab, (q15_t)0x7eaa, (q15_t)0x7ea9, (q15_t)0x7ea8, (q15_t)0x7ea7, (q15_t)0x7ea6, (q15_t)0x7ea6, (q15_t)0x7ea5, - (q15_t)0x7ea4, (q15_t)0x7ea3, (q15_t)0x7ea2, (q15_t)0x7ea1, (q15_t)0x7ea0, (q15_t)0x7e9f, (q15_t)0x7e9e, (q15_t)0x7e9d, - (q15_t)0x7e9c, (q15_t)0x7e9b, (q15_t)0x7e9b, (q15_t)0x7e9a, (q15_t)0x7e99, (q15_t)0x7e98, (q15_t)0x7e97, (q15_t)0x7e96, - (q15_t)0x7e95, (q15_t)0x7e94, (q15_t)0x7e93, (q15_t)0x7e92, (q15_t)0x7e91, (q15_t)0x7e90, (q15_t)0x7e8f, (q15_t)0x7e8e, - (q15_t)0x7e8d, (q15_t)0x7e8d, (q15_t)0x7e8c, (q15_t)0x7e8b, (q15_t)0x7e8a, (q15_t)0x7e89, (q15_t)0x7e88, (q15_t)0x7e87, - (q15_t)0x7e86, (q15_t)0x7e85, (q15_t)0x7e84, (q15_t)0x7e83, (q15_t)0x7e82, (q15_t)0x7e81, (q15_t)0x7e80, (q15_t)0x7e7f, - (q15_t)0x7e7e, (q15_t)0x7e7d, (q15_t)0x7e7c, (q15_t)0x7e7b, (q15_t)0x7e7a, (q15_t)0x7e79, (q15_t)0x7e78, (q15_t)0x7e77, - (q15_t)0x7e77, (q15_t)0x7e76, (q15_t)0x7e75, (q15_t)0x7e74, (q15_t)0x7e73, (q15_t)0x7e72, (q15_t)0x7e71, (q15_t)0x7e70, - (q15_t)0x7e6f, (q15_t)0x7e6e, (q15_t)0x7e6d, (q15_t)0x7e6c, (q15_t)0x7e6b, (q15_t)0x7e6a, (q15_t)0x7e69, (q15_t)0x7e68, - (q15_t)0x7e67, (q15_t)0x7e66, (q15_t)0x7e65, (q15_t)0x7e64, (q15_t)0x7e63, (q15_t)0x7e62, (q15_t)0x7e61, (q15_t)0x7e60, - (q15_t)0x7e5f, (q15_t)0x7e5e, (q15_t)0x7e5d, (q15_t)0x7e5c, (q15_t)0x7e5b, (q15_t)0x7e5a, (q15_t)0x7e59, (q15_t)0x7e58, - (q15_t)0x7e57, (q15_t)0x7e56, (q15_t)0x7e55, (q15_t)0x7e54, (q15_t)0x7e53, (q15_t)0x7e52, (q15_t)0x7e51, (q15_t)0x7e50, - (q15_t)0x7e4f, (q15_t)0x7e4e, (q15_t)0x7e4d, (q15_t)0x7e4c, (q15_t)0x7e4b, (q15_t)0x7e4a, (q15_t)0x7e49, (q15_t)0x7e48, - (q15_t)0x7e47, (q15_t)0x7e46, (q15_t)0x7e45, (q15_t)0x7e43, (q15_t)0x7e42, (q15_t)0x7e41, (q15_t)0x7e40, (q15_t)0x7e3f, - (q15_t)0x7e3e, (q15_t)0x7e3d, (q15_t)0x7e3c, (q15_t)0x7e3b, (q15_t)0x7e3a, (q15_t)0x7e39, (q15_t)0x7e38, (q15_t)0x7e37, - (q15_t)0x7e36, (q15_t)0x7e35, (q15_t)0x7e34, (q15_t)0x7e33, (q15_t)0x7e32, (q15_t)0x7e31, (q15_t)0x7e30, (q15_t)0x7e2f, - (q15_t)0x7e2e, (q15_t)0x7e2d, (q15_t)0x7e2b, (q15_t)0x7e2a, (q15_t)0x7e29, (q15_t)0x7e28, (q15_t)0x7e27, (q15_t)0x7e26, - (q15_t)0x7e25, (q15_t)0x7e24, (q15_t)0x7e23, (q15_t)0x7e22, (q15_t)0x7e21, (q15_t)0x7e20, (q15_t)0x7e1f, (q15_t)0x7e1e, - (q15_t)0x7e1d, (q15_t)0x7e1b, (q15_t)0x7e1a, (q15_t)0x7e19, (q15_t)0x7e18, (q15_t)0x7e17, (q15_t)0x7e16, (q15_t)0x7e15, - (q15_t)0x7e14, (q15_t)0x7e13, (q15_t)0x7e12, (q15_t)0x7e11, (q15_t)0x7e10, (q15_t)0x7e0e, (q15_t)0x7e0d, (q15_t)0x7e0c, - (q15_t)0x7e0b, (q15_t)0x7e0a, (q15_t)0x7e09, (q15_t)0x7e08, (q15_t)0x7e07, (q15_t)0x7e06, (q15_t)0x7e05, (q15_t)0x7e04, - (q15_t)0x7e02, (q15_t)0x7e01, (q15_t)0x7e00, (q15_t)0x7dff, (q15_t)0x7dfe, (q15_t)0x7dfd, (q15_t)0x7dfc, (q15_t)0x7dfb, - (q15_t)0x7dfa, (q15_t)0x7df8, (q15_t)0x7df7, (q15_t)0x7df6, (q15_t)0x7df5, (q15_t)0x7df4, (q15_t)0x7df3, (q15_t)0x7df2, - (q15_t)0x7df1, (q15_t)0x7def, (q15_t)0x7dee, (q15_t)0x7ded, (q15_t)0x7dec, (q15_t)0x7deb, (q15_t)0x7dea, (q15_t)0x7de9, - (q15_t)0x7de8, (q15_t)0x7de6, (q15_t)0x7de5, (q15_t)0x7de4, (q15_t)0x7de3, (q15_t)0x7de2, (q15_t)0x7de1, (q15_t)0x7de0, - (q15_t)0x7dde, (q15_t)0x7ddd, (q15_t)0x7ddc, (q15_t)0x7ddb, (q15_t)0x7dda, (q15_t)0x7dd9, (q15_t)0x7dd8, (q15_t)0x7dd6, - (q15_t)0x7dd5, (q15_t)0x7dd4, (q15_t)0x7dd3, (q15_t)0x7dd2, (q15_t)0x7dd1, (q15_t)0x7dd0, (q15_t)0x7dce, (q15_t)0x7dcd, - (q15_t)0x7dcc, (q15_t)0x7dcb, (q15_t)0x7dca, (q15_t)0x7dc9, (q15_t)0x7dc7, (q15_t)0x7dc6, (q15_t)0x7dc5, (q15_t)0x7dc4, - (q15_t)0x7dc3, (q15_t)0x7dc2, (q15_t)0x7dc0, (q15_t)0x7dbf, (q15_t)0x7dbe, (q15_t)0x7dbd, (q15_t)0x7dbc, (q15_t)0x7dbb, - (q15_t)0x7db9, (q15_t)0x7db8, (q15_t)0x7db7, (q15_t)0x7db6, (q15_t)0x7db5, (q15_t)0x7db3, (q15_t)0x7db2, (q15_t)0x7db1, - (q15_t)0x7db0, (q15_t)0x7daf, (q15_t)0x7dae, (q15_t)0x7dac, (q15_t)0x7dab, (q15_t)0x7daa, (q15_t)0x7da9, (q15_t)0x7da8, - (q15_t)0x7da6, (q15_t)0x7da5, (q15_t)0x7da4, (q15_t)0x7da3, (q15_t)0x7da2, (q15_t)0x7da0, (q15_t)0x7d9f, (q15_t)0x7d9e, - (q15_t)0x7d9d, (q15_t)0x7d9c, (q15_t)0x7d9a, (q15_t)0x7d99, (q15_t)0x7d98, (q15_t)0x7d97, (q15_t)0x7d95, (q15_t)0x7d94, - (q15_t)0x7d93, (q15_t)0x7d92, (q15_t)0x7d91, (q15_t)0x7d8f, (q15_t)0x7d8e, (q15_t)0x7d8d, (q15_t)0x7d8c, (q15_t)0x7d8a, - (q15_t)0x7d89, (q15_t)0x7d88, (q15_t)0x7d87, (q15_t)0x7d86, (q15_t)0x7d84, (q15_t)0x7d83, (q15_t)0x7d82, (q15_t)0x7d81, - (q15_t)0x7d7f, (q15_t)0x7d7e, (q15_t)0x7d7d, (q15_t)0x7d7c, (q15_t)0x7d7a, (q15_t)0x7d79, (q15_t)0x7d78, (q15_t)0x7d77, - (q15_t)0x7d75, (q15_t)0x7d74, (q15_t)0x7d73, (q15_t)0x7d72, (q15_t)0x7d70, (q15_t)0x7d6f, (q15_t)0x7d6e, (q15_t)0x7d6d, - (q15_t)0x7d6b, (q15_t)0x7d6a, (q15_t)0x7d69, (q15_t)0x7d68, (q15_t)0x7d66, (q15_t)0x7d65, (q15_t)0x7d64, (q15_t)0x7d63, - (q15_t)0x7d61, (q15_t)0x7d60, (q15_t)0x7d5f, (q15_t)0x7d5e, (q15_t)0x7d5c, (q15_t)0x7d5b, (q15_t)0x7d5a, (q15_t)0x7d59, - (q15_t)0x7d57, (q15_t)0x7d56, (q15_t)0x7d55, (q15_t)0x7d53, (q15_t)0x7d52, (q15_t)0x7d51, (q15_t)0x7d50, (q15_t)0x7d4e, - (q15_t)0x7d4d, (q15_t)0x7d4c, (q15_t)0x7d4a, (q15_t)0x7d49, (q15_t)0x7d48, (q15_t)0x7d47, (q15_t)0x7d45, (q15_t)0x7d44, - (q15_t)0x7d43, (q15_t)0x7d41, (q15_t)0x7d40, (q15_t)0x7d3f, (q15_t)0x7d3e, (q15_t)0x7d3c, (q15_t)0x7d3b, (q15_t)0x7d3a, - (q15_t)0x7d38, (q15_t)0x7d37, (q15_t)0x7d36, (q15_t)0x7d34, (q15_t)0x7d33, (q15_t)0x7d32, (q15_t)0x7d31, (q15_t)0x7d2f, - (q15_t)0x7d2e, (q15_t)0x7d2d, (q15_t)0x7d2b, (q15_t)0x7d2a, (q15_t)0x7d29, (q15_t)0x7d27, (q15_t)0x7d26, (q15_t)0x7d25, - (q15_t)0x7d23, (q15_t)0x7d22, (q15_t)0x7d21, (q15_t)0x7d1f, (q15_t)0x7d1e, (q15_t)0x7d1d, (q15_t)0x7d1b, (q15_t)0x7d1a, - (q15_t)0x7d19, (q15_t)0x7d17, (q15_t)0x7d16, (q15_t)0x7d15, (q15_t)0x7d13, (q15_t)0x7d12, (q15_t)0x7d11, (q15_t)0x7d0f, - (q15_t)0x7d0e, (q15_t)0x7d0d, (q15_t)0x7d0b, (q15_t)0x7d0a, (q15_t)0x7d09, (q15_t)0x7d07, (q15_t)0x7d06, (q15_t)0x7d05, - (q15_t)0x7d03, (q15_t)0x7d02, (q15_t)0x7d01, (q15_t)0x7cff, (q15_t)0x7cfe, (q15_t)0x7cfd, (q15_t)0x7cfb, (q15_t)0x7cfa, - (q15_t)0x7cf9, (q15_t)0x7cf7, (q15_t)0x7cf6, (q15_t)0x7cf4, (q15_t)0x7cf3, (q15_t)0x7cf2, (q15_t)0x7cf0, (q15_t)0x7cef, - (q15_t)0x7cee, (q15_t)0x7cec, (q15_t)0x7ceb, (q15_t)0x7ce9, (q15_t)0x7ce8, (q15_t)0x7ce7, (q15_t)0x7ce5, (q15_t)0x7ce4, - (q15_t)0x7ce3, (q15_t)0x7ce1, (q15_t)0x7ce0, (q15_t)0x7cde, (q15_t)0x7cdd, (q15_t)0x7cdc, (q15_t)0x7cda, (q15_t)0x7cd9, - (q15_t)0x7cd8, (q15_t)0x7cd6, (q15_t)0x7cd5, (q15_t)0x7cd3, (q15_t)0x7cd2, (q15_t)0x7cd1, (q15_t)0x7ccf, (q15_t)0x7cce, - (q15_t)0x7ccc, (q15_t)0x7ccb, (q15_t)0x7cca, (q15_t)0x7cc8, (q15_t)0x7cc7, (q15_t)0x7cc5, (q15_t)0x7cc4, (q15_t)0x7cc3, - (q15_t)0x7cc1, (q15_t)0x7cc0, (q15_t)0x7cbe, (q15_t)0x7cbd, (q15_t)0x7cbc, (q15_t)0x7cba, (q15_t)0x7cb9, (q15_t)0x7cb7, - (q15_t)0x7cb6, (q15_t)0x7cb5, (q15_t)0x7cb3, (q15_t)0x7cb2, (q15_t)0x7cb0, (q15_t)0x7caf, (q15_t)0x7cad, (q15_t)0x7cac, - (q15_t)0x7cab, (q15_t)0x7ca9, (q15_t)0x7ca8, (q15_t)0x7ca6, (q15_t)0x7ca5, (q15_t)0x7ca3, (q15_t)0x7ca2, (q15_t)0x7ca1, - (q15_t)0x7c9f, (q15_t)0x7c9e, (q15_t)0x7c9c, (q15_t)0x7c9b, (q15_t)0x7c99, (q15_t)0x7c98, (q15_t)0x7c97, (q15_t)0x7c95, - (q15_t)0x7c94, (q15_t)0x7c92, (q15_t)0x7c91, (q15_t)0x7c8f, (q15_t)0x7c8e, (q15_t)0x7c8c, (q15_t)0x7c8b, (q15_t)0x7c8a, - (q15_t)0x7c88, (q15_t)0x7c87, (q15_t)0x7c85, (q15_t)0x7c84, (q15_t)0x7c82, (q15_t)0x7c81, (q15_t)0x7c7f, (q15_t)0x7c7e, - (q15_t)0x7c7c, (q15_t)0x7c7b, (q15_t)0x7c79, (q15_t)0x7c78, (q15_t)0x7c77, (q15_t)0x7c75, (q15_t)0x7c74, (q15_t)0x7c72, - (q15_t)0x7c71, (q15_t)0x7c6f, (q15_t)0x7c6e, (q15_t)0x7c6c, (q15_t)0x7c6b, (q15_t)0x7c69, (q15_t)0x7c68, (q15_t)0x7c66, - (q15_t)0x7c65, (q15_t)0x7c63, (q15_t)0x7c62, (q15_t)0x7c60, (q15_t)0x7c5f, (q15_t)0x7c5d, (q15_t)0x7c5c, (q15_t)0x7c5a, - (q15_t)0x7c59, (q15_t)0x7c58, (q15_t)0x7c56, (q15_t)0x7c55, (q15_t)0x7c53, (q15_t)0x7c52, (q15_t)0x7c50, (q15_t)0x7c4f, - (q15_t)0x7c4d, (q15_t)0x7c4c, (q15_t)0x7c4a, (q15_t)0x7c49, (q15_t)0x7c47, (q15_t)0x7c46, (q15_t)0x7c44, (q15_t)0x7c43, - (q15_t)0x7c41, (q15_t)0x7c3f, (q15_t)0x7c3e, (q15_t)0x7c3c, (q15_t)0x7c3b, (q15_t)0x7c39, (q15_t)0x7c38, (q15_t)0x7c36, - (q15_t)0x7c35, (q15_t)0x7c33, (q15_t)0x7c32, (q15_t)0x7c30, (q15_t)0x7c2f, (q15_t)0x7c2d, (q15_t)0x7c2c, (q15_t)0x7c2a, - (q15_t)0x7c29, (q15_t)0x7c27, (q15_t)0x7c26, (q15_t)0x7c24, (q15_t)0x7c23, (q15_t)0x7c21, (q15_t)0x7c20, (q15_t)0x7c1e, - (q15_t)0x7c1c, (q15_t)0x7c1b, (q15_t)0x7c19, (q15_t)0x7c18, (q15_t)0x7c16, (q15_t)0x7c15, (q15_t)0x7c13, (q15_t)0x7c12, - (q15_t)0x7c10, (q15_t)0x7c0f, (q15_t)0x7c0d, (q15_t)0x7c0b, (q15_t)0x7c0a, (q15_t)0x7c08, (q15_t)0x7c07, (q15_t)0x7c05, - (q15_t)0x7c04, (q15_t)0x7c02, (q15_t)0x7c01, (q15_t)0x7bff, (q15_t)0x7bfd, (q15_t)0x7bfc, (q15_t)0x7bfa, (q15_t)0x7bf9, - (q15_t)0x7bf7, (q15_t)0x7bf6, (q15_t)0x7bf4, (q15_t)0x7bf3, (q15_t)0x7bf1, (q15_t)0x7bef, (q15_t)0x7bee, (q15_t)0x7bec, - (q15_t)0x7beb, (q15_t)0x7be9, (q15_t)0x7be8, (q15_t)0x7be6, (q15_t)0x7be4, (q15_t)0x7be3, (q15_t)0x7be1, (q15_t)0x7be0, - (q15_t)0x7bde, (q15_t)0x7bdc, (q15_t)0x7bdb, (q15_t)0x7bd9, (q15_t)0x7bd8, (q15_t)0x7bd6, (q15_t)0x7bd5, (q15_t)0x7bd3, - (q15_t)0x7bd1, (q15_t)0x7bd0, (q15_t)0x7bce, (q15_t)0x7bcd, (q15_t)0x7bcb, (q15_t)0x7bc9, (q15_t)0x7bc8, (q15_t)0x7bc6, - (q15_t)0x7bc5, (q15_t)0x7bc3, (q15_t)0x7bc1, (q15_t)0x7bc0, (q15_t)0x7bbe, (q15_t)0x7bbd, (q15_t)0x7bbb, (q15_t)0x7bb9, - (q15_t)0x7bb8, (q15_t)0x7bb6, (q15_t)0x7bb5, (q15_t)0x7bb3, (q15_t)0x7bb1, (q15_t)0x7bb0, (q15_t)0x7bae, (q15_t)0x7bac, - (q15_t)0x7bab, (q15_t)0x7ba9, (q15_t)0x7ba8, (q15_t)0x7ba6, (q15_t)0x7ba4, (q15_t)0x7ba3, (q15_t)0x7ba1, (q15_t)0x7b9f, - (q15_t)0x7b9e, (q15_t)0x7b9c, (q15_t)0x7b9b, (q15_t)0x7b99, (q15_t)0x7b97, (q15_t)0x7b96, (q15_t)0x7b94, (q15_t)0x7b92, - (q15_t)0x7b91, (q15_t)0x7b8f, (q15_t)0x7b8d, (q15_t)0x7b8c, (q15_t)0x7b8a, (q15_t)0x7b89, (q15_t)0x7b87, (q15_t)0x7b85, - (q15_t)0x7b84, (q15_t)0x7b82, (q15_t)0x7b80, (q15_t)0x7b7f, (q15_t)0x7b7d, (q15_t)0x7b7b, (q15_t)0x7b7a, (q15_t)0x7b78, - (q15_t)0x7b76, (q15_t)0x7b75, (q15_t)0x7b73, (q15_t)0x7b71, (q15_t)0x7b70, (q15_t)0x7b6e, (q15_t)0x7b6c, (q15_t)0x7b6b, - (q15_t)0x7b69, (q15_t)0x7b67, (q15_t)0x7b66, (q15_t)0x7b64, (q15_t)0x7b62, (q15_t)0x7b61, (q15_t)0x7b5f, (q15_t)0x7b5d, - (q15_t)0x7b5c, (q15_t)0x7b5a, (q15_t)0x7b58, (q15_t)0x7b57, (q15_t)0x7b55, (q15_t)0x7b53, (q15_t)0x7b52, (q15_t)0x7b50, - (q15_t)0x7b4e, (q15_t)0x7b4d, (q15_t)0x7b4b, (q15_t)0x7b49, (q15_t)0x7b47, (q15_t)0x7b46, (q15_t)0x7b44, (q15_t)0x7b42, - (q15_t)0x7b41, (q15_t)0x7b3f, (q15_t)0x7b3d, (q15_t)0x7b3c, (q15_t)0x7b3a, (q15_t)0x7b38, (q15_t)0x7b37, (q15_t)0x7b35, - (q15_t)0x7b33, (q15_t)0x7b31, (q15_t)0x7b30, (q15_t)0x7b2e, (q15_t)0x7b2c, (q15_t)0x7b2b, (q15_t)0x7b29, (q15_t)0x7b27, - (q15_t)0x7b25, (q15_t)0x7b24, (q15_t)0x7b22, (q15_t)0x7b20, (q15_t)0x7b1f, (q15_t)0x7b1d, (q15_t)0x7b1b, (q15_t)0x7b19, - (q15_t)0x7b18, (q15_t)0x7b16, (q15_t)0x7b14, (q15_t)0x7b13, (q15_t)0x7b11, (q15_t)0x7b0f, (q15_t)0x7b0d, (q15_t)0x7b0c, - (q15_t)0x7b0a, (q15_t)0x7b08, (q15_t)0x7b06, (q15_t)0x7b05, (q15_t)0x7b03, (q15_t)0x7b01, (q15_t)0x7aff, (q15_t)0x7afe, - (q15_t)0x7afc, (q15_t)0x7afa, (q15_t)0x7af8, (q15_t)0x7af7, (q15_t)0x7af5, (q15_t)0x7af3, (q15_t)0x7af2, (q15_t)0x7af0, - (q15_t)0x7aee, (q15_t)0x7aec, (q15_t)0x7aeb, (q15_t)0x7ae9, (q15_t)0x7ae7, (q15_t)0x7ae5, (q15_t)0x7ae3, (q15_t)0x7ae2, - (q15_t)0x7ae0, (q15_t)0x7ade, (q15_t)0x7adc, (q15_t)0x7adb, (q15_t)0x7ad9, (q15_t)0x7ad7, (q15_t)0x7ad5, (q15_t)0x7ad4, - (q15_t)0x7ad2, (q15_t)0x7ad0, (q15_t)0x7ace, (q15_t)0x7acd, (q15_t)0x7acb, (q15_t)0x7ac9, (q15_t)0x7ac7, (q15_t)0x7ac5, - (q15_t)0x7ac4, (q15_t)0x7ac2, (q15_t)0x7ac0, (q15_t)0x7abe, (q15_t)0x7abd, (q15_t)0x7abb, (q15_t)0x7ab9, (q15_t)0x7ab7, - (q15_t)0x7ab5, (q15_t)0x7ab4, (q15_t)0x7ab2, (q15_t)0x7ab0, (q15_t)0x7aae, (q15_t)0x7aac, (q15_t)0x7aab, (q15_t)0x7aa9, - (q15_t)0x7aa7, (q15_t)0x7aa5, (q15_t)0x7aa3, (q15_t)0x7aa2, (q15_t)0x7aa0, (q15_t)0x7a9e, (q15_t)0x7a9c, (q15_t)0x7a9a, - (q15_t)0x7a99, (q15_t)0x7a97, (q15_t)0x7a95, (q15_t)0x7a93, (q15_t)0x7a91, (q15_t)0x7a90, (q15_t)0x7a8e, (q15_t)0x7a8c, - (q15_t)0x7a8a, (q15_t)0x7a88, (q15_t)0x7a87, (q15_t)0x7a85, (q15_t)0x7a83, (q15_t)0x7a81, (q15_t)0x7a7f, (q15_t)0x7a7d, - (q15_t)0x7a7c, (q15_t)0x7a7a, (q15_t)0x7a78, (q15_t)0x7a76, (q15_t)0x7a74, (q15_t)0x7a72, (q15_t)0x7a71, (q15_t)0x7a6f, - (q15_t)0x7a6d, (q15_t)0x7a6b, (q15_t)0x7a69, (q15_t)0x7a67, (q15_t)0x7a66, (q15_t)0x7a64, (q15_t)0x7a62, (q15_t)0x7a60, - (q15_t)0x7a5e, (q15_t)0x7a5c, (q15_t)0x7a5b, (q15_t)0x7a59, (q15_t)0x7a57, (q15_t)0x7a55, (q15_t)0x7a53, (q15_t)0x7a51, - (q15_t)0x7a4f, (q15_t)0x7a4e, (q15_t)0x7a4c, (q15_t)0x7a4a, (q15_t)0x7a48, (q15_t)0x7a46, (q15_t)0x7a44, (q15_t)0x7a42, - (q15_t)0x7a41, (q15_t)0x7a3f, (q15_t)0x7a3d, (q15_t)0x7a3b, (q15_t)0x7a39, (q15_t)0x7a37, (q15_t)0x7a35, (q15_t)0x7a34, - (q15_t)0x7a32, (q15_t)0x7a30, (q15_t)0x7a2e, (q15_t)0x7a2c, (q15_t)0x7a2a, (q15_t)0x7a28, (q15_t)0x7a26, (q15_t)0x7a25, - (q15_t)0x7a23, (q15_t)0x7a21, (q15_t)0x7a1f, (q15_t)0x7a1d, (q15_t)0x7a1b, (q15_t)0x7a19, (q15_t)0x7a17, (q15_t)0x7a16, - (q15_t)0x7a14, (q15_t)0x7a12, (q15_t)0x7a10, (q15_t)0x7a0e, (q15_t)0x7a0c, (q15_t)0x7a0a, (q15_t)0x7a08, (q15_t)0x7a06, - (q15_t)0x7a04, (q15_t)0x7a03, (q15_t)0x7a01, (q15_t)0x79ff, (q15_t)0x79fd, (q15_t)0x79fb, (q15_t)0x79f9, (q15_t)0x79f7, - (q15_t)0x79f5, (q15_t)0x79f3, (q15_t)0x79f1, (q15_t)0x79f0, (q15_t)0x79ee, (q15_t)0x79ec, (q15_t)0x79ea, (q15_t)0x79e8, - (q15_t)0x79e6, (q15_t)0x79e4, (q15_t)0x79e2, (q15_t)0x79e0, (q15_t)0x79de, (q15_t)0x79dc, (q15_t)0x79da, (q15_t)0x79d9, - (q15_t)0x79d7, (q15_t)0x79d5, (q15_t)0x79d3, (q15_t)0x79d1, (q15_t)0x79cf, (q15_t)0x79cd, (q15_t)0x79cb, (q15_t)0x79c9, - (q15_t)0x79c7, (q15_t)0x79c5, (q15_t)0x79c3, (q15_t)0x79c1, (q15_t)0x79bf, (q15_t)0x79bd, (q15_t)0x79bc, (q15_t)0x79ba, - (q15_t)0x79b8, (q15_t)0x79b6, (q15_t)0x79b4, (q15_t)0x79b2, (q15_t)0x79b0, (q15_t)0x79ae, (q15_t)0x79ac, (q15_t)0x79aa, - (q15_t)0x79a8, (q15_t)0x79a6, (q15_t)0x79a4, (q15_t)0x79a2, (q15_t)0x79a0, (q15_t)0x799e, (q15_t)0x799c, (q15_t)0x799a, - (q15_t)0x7998, (q15_t)0x7996, (q15_t)0x7994, (q15_t)0x7992, (q15_t)0x7991, (q15_t)0x798f, (q15_t)0x798d, (q15_t)0x798b, - (q15_t)0x7989, (q15_t)0x7987, (q15_t)0x7985, (q15_t)0x7983, (q15_t)0x7981, (q15_t)0x797f, (q15_t)0x797d, (q15_t)0x797b, - (q15_t)0x7979, (q15_t)0x7977, (q15_t)0x7975, (q15_t)0x7973, (q15_t)0x7971, (q15_t)0x796f, (q15_t)0x796d, (q15_t)0x796b, - (q15_t)0x7969, (q15_t)0x7967, (q15_t)0x7965, (q15_t)0x7963, (q15_t)0x7961, (q15_t)0x795f, (q15_t)0x795d, (q15_t)0x795b, - (q15_t)0x7959, (q15_t)0x7957, (q15_t)0x7955, (q15_t)0x7953, (q15_t)0x7951, (q15_t)0x794f, (q15_t)0x794d, (q15_t)0x794b, - (q15_t)0x7949, (q15_t)0x7947, (q15_t)0x7945, (q15_t)0x7943, (q15_t)0x7941, (q15_t)0x793f, (q15_t)0x793d, (q15_t)0x793b, - (q15_t)0x7939, (q15_t)0x7937, (q15_t)0x7935, (q15_t)0x7933, (q15_t)0x7931, (q15_t)0x792f, (q15_t)0x792d, (q15_t)0x792b, - (q15_t)0x7929, (q15_t)0x7927, (q15_t)0x7925, (q15_t)0x7923, (q15_t)0x7921, (q15_t)0x791f, (q15_t)0x791d, (q15_t)0x791a, - (q15_t)0x7918, (q15_t)0x7916, (q15_t)0x7914, (q15_t)0x7912, (q15_t)0x7910, (q15_t)0x790e, (q15_t)0x790c, (q15_t)0x790a, - (q15_t)0x7908, (q15_t)0x7906, (q15_t)0x7904, (q15_t)0x7902, (q15_t)0x7900, (q15_t)0x78fe, (q15_t)0x78fc, (q15_t)0x78fa, - (q15_t)0x78f8, (q15_t)0x78f6, (q15_t)0x78f4, (q15_t)0x78f2, (q15_t)0x78f0, (q15_t)0x78ed, (q15_t)0x78eb, (q15_t)0x78e9, - (q15_t)0x78e7, (q15_t)0x78e5, (q15_t)0x78e3, (q15_t)0x78e1, (q15_t)0x78df, (q15_t)0x78dd, (q15_t)0x78db, (q15_t)0x78d9, - (q15_t)0x78d7, (q15_t)0x78d5, (q15_t)0x78d3, (q15_t)0x78d1, (q15_t)0x78ce, (q15_t)0x78cc, (q15_t)0x78ca, (q15_t)0x78c8, - (q15_t)0x78c6, (q15_t)0x78c4, (q15_t)0x78c2, (q15_t)0x78c0, (q15_t)0x78be, (q15_t)0x78bc, (q15_t)0x78ba, (q15_t)0x78b8, - (q15_t)0x78b5, (q15_t)0x78b3, (q15_t)0x78b1, (q15_t)0x78af, (q15_t)0x78ad, (q15_t)0x78ab, (q15_t)0x78a9, (q15_t)0x78a7, - (q15_t)0x78a5, (q15_t)0x78a3, (q15_t)0x78a0, (q15_t)0x789e, (q15_t)0x789c, (q15_t)0x789a, (q15_t)0x7898, (q15_t)0x7896, - (q15_t)0x7894, (q15_t)0x7892, (q15_t)0x7890, (q15_t)0x788e, (q15_t)0x788b, (q15_t)0x7889, (q15_t)0x7887, (q15_t)0x7885, - (q15_t)0x7883, (q15_t)0x7881, (q15_t)0x787f, (q15_t)0x787d, (q15_t)0x787a, (q15_t)0x7878, (q15_t)0x7876, (q15_t)0x7874, - (q15_t)0x7872, (q15_t)0x7870, (q15_t)0x786e, (q15_t)0x786c, (q15_t)0x7869, (q15_t)0x7867, (q15_t)0x7865, (q15_t)0x7863, - (q15_t)0x7861, (q15_t)0x785f, (q15_t)0x785d, (q15_t)0x785b, (q15_t)0x7858, (q15_t)0x7856, (q15_t)0x7854, (q15_t)0x7852, - (q15_t)0x7850, (q15_t)0x784e, (q15_t)0x784c, (q15_t)0x7849, (q15_t)0x7847, (q15_t)0x7845, (q15_t)0x7843, (q15_t)0x7841, - (q15_t)0x783f, (q15_t)0x783c, (q15_t)0x783a, (q15_t)0x7838, (q15_t)0x7836, (q15_t)0x7834, (q15_t)0x7832, (q15_t)0x7830, - (q15_t)0x782d, (q15_t)0x782b, (q15_t)0x7829, (q15_t)0x7827, (q15_t)0x7825, (q15_t)0x7823, (q15_t)0x7820, (q15_t)0x781e, - (q15_t)0x781c, (q15_t)0x781a, (q15_t)0x7818, (q15_t)0x7816, (q15_t)0x7813, (q15_t)0x7811, (q15_t)0x780f, (q15_t)0x780d, - (q15_t)0x780b, (q15_t)0x7808, (q15_t)0x7806, (q15_t)0x7804, (q15_t)0x7802, (q15_t)0x7800, (q15_t)0x77fe, (q15_t)0x77fb, - (q15_t)0x77f9, (q15_t)0x77f7, (q15_t)0x77f5, (q15_t)0x77f3, (q15_t)0x77f0, (q15_t)0x77ee, (q15_t)0x77ec, (q15_t)0x77ea, - (q15_t)0x77e8, (q15_t)0x77e5, (q15_t)0x77e3, (q15_t)0x77e1, (q15_t)0x77df, (q15_t)0x77dd, (q15_t)0x77da, (q15_t)0x77d8, - (q15_t)0x77d6, (q15_t)0x77d4, (q15_t)0x77d2, (q15_t)0x77cf, (q15_t)0x77cd, (q15_t)0x77cb, (q15_t)0x77c9, (q15_t)0x77c6, - (q15_t)0x77c4, (q15_t)0x77c2, (q15_t)0x77c0, (q15_t)0x77be, (q15_t)0x77bb, (q15_t)0x77b9, (q15_t)0x77b7, (q15_t)0x77b5, - (q15_t)0x77b2, (q15_t)0x77b0, (q15_t)0x77ae, (q15_t)0x77ac, (q15_t)0x77aa, (q15_t)0x77a7, (q15_t)0x77a5, (q15_t)0x77a3, - (q15_t)0x77a1, (q15_t)0x779e, (q15_t)0x779c, (q15_t)0x779a, (q15_t)0x7798, (q15_t)0x7795, (q15_t)0x7793, (q15_t)0x7791, - (q15_t)0x778f, (q15_t)0x778c, (q15_t)0x778a, (q15_t)0x7788, (q15_t)0x7786, (q15_t)0x7783, (q15_t)0x7781, (q15_t)0x777f, - (q15_t)0x777d, (q15_t)0x777a, (q15_t)0x7778, (q15_t)0x7776, (q15_t)0x7774, (q15_t)0x7771, (q15_t)0x776f, (q15_t)0x776d, - (q15_t)0x776b, (q15_t)0x7768, (q15_t)0x7766, (q15_t)0x7764, (q15_t)0x7762, (q15_t)0x775f, (q15_t)0x775d, (q15_t)0x775b, - (q15_t)0x7759, (q15_t)0x7756, (q15_t)0x7754, (q15_t)0x7752, (q15_t)0x774f, (q15_t)0x774d, (q15_t)0x774b, (q15_t)0x7749, - (q15_t)0x7746, (q15_t)0x7744, (q15_t)0x7742, (q15_t)0x773f, (q15_t)0x773d, (q15_t)0x773b, (q15_t)0x7739, (q15_t)0x7736, - (q15_t)0x7734, (q15_t)0x7732, (q15_t)0x772f, (q15_t)0x772d, (q15_t)0x772b, (q15_t)0x7729, (q15_t)0x7726, (q15_t)0x7724, - (q15_t)0x7722, (q15_t)0x771f, (q15_t)0x771d, (q15_t)0x771b, (q15_t)0x7719, (q15_t)0x7716, (q15_t)0x7714, (q15_t)0x7712, - (q15_t)0x770f, (q15_t)0x770d, (q15_t)0x770b, (q15_t)0x7708, (q15_t)0x7706, (q15_t)0x7704, (q15_t)0x7701, (q15_t)0x76ff, - (q15_t)0x76fd, (q15_t)0x76fa, (q15_t)0x76f8, (q15_t)0x76f6, (q15_t)0x76f4, (q15_t)0x76f1, (q15_t)0x76ef, (q15_t)0x76ed, - (q15_t)0x76ea, (q15_t)0x76e8, (q15_t)0x76e6, (q15_t)0x76e3, (q15_t)0x76e1, (q15_t)0x76df, (q15_t)0x76dc, (q15_t)0x76da, - (q15_t)0x76d8, (q15_t)0x76d5, (q15_t)0x76d3, (q15_t)0x76d1, (q15_t)0x76ce, (q15_t)0x76cc, (q15_t)0x76ca, (q15_t)0x76c7, - (q15_t)0x76c5, (q15_t)0x76c3, (q15_t)0x76c0, (q15_t)0x76be, (q15_t)0x76bc, (q15_t)0x76b9, (q15_t)0x76b7, (q15_t)0x76b4, - (q15_t)0x76b2, (q15_t)0x76b0, (q15_t)0x76ad, (q15_t)0x76ab, (q15_t)0x76a9, (q15_t)0x76a6, (q15_t)0x76a4, (q15_t)0x76a2, - (q15_t)0x769f, (q15_t)0x769d, (q15_t)0x769b, (q15_t)0x7698, (q15_t)0x7696, (q15_t)0x7693, (q15_t)0x7691, (q15_t)0x768f, - (q15_t)0x768c, (q15_t)0x768a, (q15_t)0x7688, (q15_t)0x7685, (q15_t)0x7683, (q15_t)0x7681, (q15_t)0x767e, (q15_t)0x767c, - (q15_t)0x7679, (q15_t)0x7677, (q15_t)0x7675, (q15_t)0x7672, (q15_t)0x7670, (q15_t)0x766d, (q15_t)0x766b, (q15_t)0x7669, - (q15_t)0x7666, (q15_t)0x7664, (q15_t)0x7662, (q15_t)0x765f, (q15_t)0x765d, (q15_t)0x765a, (q15_t)0x7658, (q15_t)0x7656, - (q15_t)0x7653, (q15_t)0x7651, (q15_t)0x764e, (q15_t)0x764c, (q15_t)0x764a, (q15_t)0x7647, (q15_t)0x7645, (q15_t)0x7642, - (q15_t)0x7640, (q15_t)0x763e, (q15_t)0x763b, (q15_t)0x7639, (q15_t)0x7636, (q15_t)0x7634, (q15_t)0x7632, (q15_t)0x762f, - (q15_t)0x762d, (q15_t)0x762a, (q15_t)0x7628, (q15_t)0x7625, (q15_t)0x7623, (q15_t)0x7621, (q15_t)0x761e, (q15_t)0x761c, - (q15_t)0x7619, (q15_t)0x7617, (q15_t)0x7615, (q15_t)0x7612, (q15_t)0x7610, (q15_t)0x760d, (q15_t)0x760b, (q15_t)0x7608, - (q15_t)0x7606, (q15_t)0x7604, (q15_t)0x7601, (q15_t)0x75ff, (q15_t)0x75fc, (q15_t)0x75fa, (q15_t)0x75f7, (q15_t)0x75f5, - (q15_t)0x75f2, (q15_t)0x75f0, (q15_t)0x75ee, (q15_t)0x75eb, (q15_t)0x75e9, (q15_t)0x75e6, (q15_t)0x75e4, (q15_t)0x75e1, - (q15_t)0x75df, (q15_t)0x75dc, (q15_t)0x75da, (q15_t)0x75d8, (q15_t)0x75d5, (q15_t)0x75d3, (q15_t)0x75d0, (q15_t)0x75ce, - (q15_t)0x75cb, (q15_t)0x75c9, (q15_t)0x75c6, (q15_t)0x75c4, (q15_t)0x75c1, (q15_t)0x75bf, (q15_t)0x75bc, (q15_t)0x75ba, - (q15_t)0x75b8, (q15_t)0x75b5, (q15_t)0x75b3, (q15_t)0x75b0, (q15_t)0x75ae, (q15_t)0x75ab, (q15_t)0x75a9, (q15_t)0x75a6, - (q15_t)0x75a4, (q15_t)0x75a1, (q15_t)0x759f, (q15_t)0x759c, (q15_t)0x759a, (q15_t)0x7597, (q15_t)0x7595, (q15_t)0x7592, - (q15_t)0x7590, (q15_t)0x758d, (q15_t)0x758b, (q15_t)0x7588, (q15_t)0x7586, (q15_t)0x7584, (q15_t)0x7581, (q15_t)0x757f, - (q15_t)0x757c, (q15_t)0x757a, (q15_t)0x7577, (q15_t)0x7575, (q15_t)0x7572, (q15_t)0x7570, (q15_t)0x756d, (q15_t)0x756b, - (q15_t)0x7568, (q15_t)0x7566, (q15_t)0x7563, (q15_t)0x7561, (q15_t)0x755e, (q15_t)0x755c, (q15_t)0x7559, (q15_t)0x7556, - (q15_t)0x7554, (q15_t)0x7551, (q15_t)0x754f, (q15_t)0x754c, (q15_t)0x754a, (q15_t)0x7547, (q15_t)0x7545, (q15_t)0x7542, - (q15_t)0x7540, (q15_t)0x753d, (q15_t)0x753b, (q15_t)0x7538, (q15_t)0x7536, (q15_t)0x7533, (q15_t)0x7531, (q15_t)0x752e, - (q15_t)0x752c, (q15_t)0x7529, (q15_t)0x7527, (q15_t)0x7524, (q15_t)0x7522, (q15_t)0x751f, (q15_t)0x751c, (q15_t)0x751a, - (q15_t)0x7517, (q15_t)0x7515, (q15_t)0x7512, (q15_t)0x7510, (q15_t)0x750d, (q15_t)0x750b, (q15_t)0x7508, (q15_t)0x7506, - (q15_t)0x7503, (q15_t)0x7501, (q15_t)0x74fe, (q15_t)0x74fb, (q15_t)0x74f9, (q15_t)0x74f6, (q15_t)0x74f4, (q15_t)0x74f1, - (q15_t)0x74ef, (q15_t)0x74ec, (q15_t)0x74ea, (q15_t)0x74e7, (q15_t)0x74e4, (q15_t)0x74e2, (q15_t)0x74df, (q15_t)0x74dd, - (q15_t)0x74da, (q15_t)0x74d8, (q15_t)0x74d5, (q15_t)0x74d2, (q15_t)0x74d0, (q15_t)0x74cd, (q15_t)0x74cb, (q15_t)0x74c8, - (q15_t)0x74c6, (q15_t)0x74c3, (q15_t)0x74c0, (q15_t)0x74be, (q15_t)0x74bb, (q15_t)0x74b9, (q15_t)0x74b6, (q15_t)0x74b4, - (q15_t)0x74b1, (q15_t)0x74ae, (q15_t)0x74ac, (q15_t)0x74a9, (q15_t)0x74a7, (q15_t)0x74a4, (q15_t)0x74a1, (q15_t)0x749f, - (q15_t)0x749c, (q15_t)0x749a, (q15_t)0x7497, (q15_t)0x7495, (q15_t)0x7492, (q15_t)0x748f, (q15_t)0x748d, (q15_t)0x748a, - (q15_t)0x7488, (q15_t)0x7485, (q15_t)0x7482, (q15_t)0x7480, (q15_t)0x747d, (q15_t)0x747b, (q15_t)0x7478, (q15_t)0x7475, - (q15_t)0x7473, (q15_t)0x7470, (q15_t)0x746d, (q15_t)0x746b, (q15_t)0x7468, (q15_t)0x7466, (q15_t)0x7463, (q15_t)0x7460, - (q15_t)0x745e, (q15_t)0x745b, (q15_t)0x7459, (q15_t)0x7456, (q15_t)0x7453, (q15_t)0x7451, (q15_t)0x744e, (q15_t)0x744b, - (q15_t)0x7449, (q15_t)0x7446, (q15_t)0x7444, (q15_t)0x7441, (q15_t)0x743e, (q15_t)0x743c, (q15_t)0x7439, (q15_t)0x7436, - (q15_t)0x7434, (q15_t)0x7431, (q15_t)0x742f, (q15_t)0x742c, (q15_t)0x7429, (q15_t)0x7427, (q15_t)0x7424, (q15_t)0x7421, - (q15_t)0x741f, (q15_t)0x741c, (q15_t)0x7419, (q15_t)0x7417, (q15_t)0x7414, (q15_t)0x7411, (q15_t)0x740f, (q15_t)0x740c, - (q15_t)0x740a, (q15_t)0x7407, (q15_t)0x7404, (q15_t)0x7402, (q15_t)0x73ff, (q15_t)0x73fc, (q15_t)0x73fa, (q15_t)0x73f7, - (q15_t)0x73f4, (q15_t)0x73f2, (q15_t)0x73ef, (q15_t)0x73ec, (q15_t)0x73ea, (q15_t)0x73e7, (q15_t)0x73e4, (q15_t)0x73e2, - (q15_t)0x73df, (q15_t)0x73dc, (q15_t)0x73da, (q15_t)0x73d7, (q15_t)0x73d4, (q15_t)0x73d2, (q15_t)0x73cf, (q15_t)0x73cc, - (q15_t)0x73ca, (q15_t)0x73c7, (q15_t)0x73c4, (q15_t)0x73c1, (q15_t)0x73bf, (q15_t)0x73bc, (q15_t)0x73b9, (q15_t)0x73b7, - (q15_t)0x73b4, (q15_t)0x73b1, (q15_t)0x73af, (q15_t)0x73ac, (q15_t)0x73a9, (q15_t)0x73a7, (q15_t)0x73a4, (q15_t)0x73a1, - (q15_t)0x739f, (q15_t)0x739c, (q15_t)0x7399, (q15_t)0x7396, (q15_t)0x7394, (q15_t)0x7391, (q15_t)0x738e, (q15_t)0x738c, - (q15_t)0x7389, (q15_t)0x7386, (q15_t)0x7384, (q15_t)0x7381, (q15_t)0x737e, (q15_t)0x737b, (q15_t)0x7379, (q15_t)0x7376, - (q15_t)0x7373, (q15_t)0x7371, (q15_t)0x736e, (q15_t)0x736b, (q15_t)0x7368, (q15_t)0x7366, (q15_t)0x7363, (q15_t)0x7360, - (q15_t)0x735e, (q15_t)0x735b, (q15_t)0x7358, (q15_t)0x7355, (q15_t)0x7353, (q15_t)0x7350, (q15_t)0x734d, (q15_t)0x734a, - (q15_t)0x7348, (q15_t)0x7345, (q15_t)0x7342, (q15_t)0x7340, (q15_t)0x733d, (q15_t)0x733a, (q15_t)0x7337, (q15_t)0x7335, - (q15_t)0x7332, (q15_t)0x732f, (q15_t)0x732c, (q15_t)0x732a, (q15_t)0x7327, (q15_t)0x7324, (q15_t)0x7321, (q15_t)0x731f, - (q15_t)0x731c, (q15_t)0x7319, (q15_t)0x7316, (q15_t)0x7314, (q15_t)0x7311, (q15_t)0x730e, (q15_t)0x730b, (q15_t)0x7309, - (q15_t)0x7306, (q15_t)0x7303, (q15_t)0x7300, (q15_t)0x72fe, (q15_t)0x72fb, (q15_t)0x72f8, (q15_t)0x72f5, (q15_t)0x72f3, - (q15_t)0x72f0, (q15_t)0x72ed, (q15_t)0x72ea, (q15_t)0x72e8, (q15_t)0x72e5, (q15_t)0x72e2, (q15_t)0x72df, (q15_t)0x72dc, - (q15_t)0x72da, (q15_t)0x72d7, (q15_t)0x72d4, (q15_t)0x72d1, (q15_t)0x72cf, (q15_t)0x72cc, (q15_t)0x72c9, (q15_t)0x72c6, - (q15_t)0x72c3, (q15_t)0x72c1, (q15_t)0x72be, (q15_t)0x72bb, (q15_t)0x72b8, (q15_t)0x72b5, (q15_t)0x72b3, (q15_t)0x72b0, - (q15_t)0x72ad, (q15_t)0x72aa, (q15_t)0x72a8, (q15_t)0x72a5, (q15_t)0x72a2, (q15_t)0x729f, (q15_t)0x729c, (q15_t)0x729a, - (q15_t)0x7297, (q15_t)0x7294, (q15_t)0x7291, (q15_t)0x728e, (q15_t)0x728c, (q15_t)0x7289, (q15_t)0x7286, (q15_t)0x7283, - (q15_t)0x7280, (q15_t)0x727e, (q15_t)0x727b, (q15_t)0x7278, (q15_t)0x7275, (q15_t)0x7272, (q15_t)0x726f, (q15_t)0x726d, - (q15_t)0x726a, (q15_t)0x7267, (q15_t)0x7264, (q15_t)0x7261, (q15_t)0x725f, (q15_t)0x725c, (q15_t)0x7259, (q15_t)0x7256, - (q15_t)0x7253, (q15_t)0x7250, (q15_t)0x724e, (q15_t)0x724b, (q15_t)0x7248, (q15_t)0x7245, (q15_t)0x7242, (q15_t)0x723f, - (q15_t)0x723d, (q15_t)0x723a, (q15_t)0x7237, (q15_t)0x7234, (q15_t)0x7231, (q15_t)0x722e, (q15_t)0x722c, (q15_t)0x7229, - (q15_t)0x7226, (q15_t)0x7223, (q15_t)0x7220, (q15_t)0x721d, (q15_t)0x721b, (q15_t)0x7218, (q15_t)0x7215, (q15_t)0x7212, - (q15_t)0x720f, (q15_t)0x720c, (q15_t)0x7209, (q15_t)0x7207, (q15_t)0x7204, (q15_t)0x7201, (q15_t)0x71fe, (q15_t)0x71fb, - (q15_t)0x71f8, (q15_t)0x71f5, (q15_t)0x71f3, (q15_t)0x71f0, (q15_t)0x71ed, (q15_t)0x71ea, (q15_t)0x71e7, (q15_t)0x71e4, - (q15_t)0x71e1, (q15_t)0x71df, (q15_t)0x71dc, (q15_t)0x71d9, (q15_t)0x71d6, (q15_t)0x71d3, (q15_t)0x71d0, (q15_t)0x71cd, - (q15_t)0x71ca, (q15_t)0x71c8, (q15_t)0x71c5, (q15_t)0x71c2, (q15_t)0x71bf, (q15_t)0x71bc, (q15_t)0x71b9, (q15_t)0x71b6, - (q15_t)0x71b3, (q15_t)0x71b0, (q15_t)0x71ae, (q15_t)0x71ab, (q15_t)0x71a8, (q15_t)0x71a5, (q15_t)0x71a2, (q15_t)0x719f, - (q15_t)0x719c, (q15_t)0x7199, (q15_t)0x7196, (q15_t)0x7194, (q15_t)0x7191, (q15_t)0x718e, (q15_t)0x718b, (q15_t)0x7188, - (q15_t)0x7185, (q15_t)0x7182, (q15_t)0x717f, (q15_t)0x717c, (q15_t)0x7179, (q15_t)0x7177, (q15_t)0x7174, (q15_t)0x7171, - (q15_t)0x716e, (q15_t)0x716b, (q15_t)0x7168, (q15_t)0x7165, (q15_t)0x7162, (q15_t)0x715f, (q15_t)0x715c, (q15_t)0x7159, - (q15_t)0x7156, (q15_t)0x7154, (q15_t)0x7151, (q15_t)0x714e, (q15_t)0x714b, (q15_t)0x7148, (q15_t)0x7145, (q15_t)0x7142, - (q15_t)0x713f, (q15_t)0x713c, (q15_t)0x7139, (q15_t)0x7136, (q15_t)0x7133, (q15_t)0x7130, (q15_t)0x712d, (q15_t)0x712b, - (q15_t)0x7128, (q15_t)0x7125, (q15_t)0x7122, (q15_t)0x711f, (q15_t)0x711c, (q15_t)0x7119, (q15_t)0x7116, (q15_t)0x7113, - (q15_t)0x7110, (q15_t)0x710d, (q15_t)0x710a, (q15_t)0x7107, (q15_t)0x7104, (q15_t)0x7101, (q15_t)0x70fe, (q15_t)0x70fb, - (q15_t)0x70f8, (q15_t)0x70f6, (q15_t)0x70f3, (q15_t)0x70f0, (q15_t)0x70ed, (q15_t)0x70ea, (q15_t)0x70e7, (q15_t)0x70e4, - (q15_t)0x70e1, (q15_t)0x70de, (q15_t)0x70db, (q15_t)0x70d8, (q15_t)0x70d5, (q15_t)0x70d2, (q15_t)0x70cf, (q15_t)0x70cc, - (q15_t)0x70c9, (q15_t)0x70c6, (q15_t)0x70c3, (q15_t)0x70c0, (q15_t)0x70bd, (q15_t)0x70ba, (q15_t)0x70b7, (q15_t)0x70b4, - (q15_t)0x70b1, (q15_t)0x70ae, (q15_t)0x70ab, (q15_t)0x70a8, (q15_t)0x70a5, (q15_t)0x70a2, (q15_t)0x709f, (q15_t)0x709c, - (q15_t)0x7099, (q15_t)0x7096, (q15_t)0x7093, (q15_t)0x7090, (q15_t)0x708d, (q15_t)0x708a, (q15_t)0x7087, (q15_t)0x7084, - (q15_t)0x7081, (q15_t)0x707e, (q15_t)0x707b, (q15_t)0x7078, (q15_t)0x7075, (q15_t)0x7072, (q15_t)0x706f, (q15_t)0x706c, - (q15_t)0x7069, (q15_t)0x7066, (q15_t)0x7063, (q15_t)0x7060, (q15_t)0x705d, (q15_t)0x705a, (q15_t)0x7057, (q15_t)0x7054, - (q15_t)0x7051, (q15_t)0x704e, (q15_t)0x704b, (q15_t)0x7048, (q15_t)0x7045, (q15_t)0x7042, (q15_t)0x703f, (q15_t)0x703c, - (q15_t)0x7039, (q15_t)0x7036, (q15_t)0x7033, (q15_t)0x7030, (q15_t)0x702d, (q15_t)0x702a, (q15_t)0x7027, (q15_t)0x7024, - (q15_t)0x7021, (q15_t)0x701e, (q15_t)0x701b, (q15_t)0x7018, (q15_t)0x7015, (q15_t)0x7012, (q15_t)0x700f, (q15_t)0x700c, - (q15_t)0x7009, (q15_t)0x7006, (q15_t)0x7003, (q15_t)0x7000, (q15_t)0x6ffd, (q15_t)0x6ffa, (q15_t)0x6ff7, (q15_t)0x6ff3, - (q15_t)0x6ff0, (q15_t)0x6fed, (q15_t)0x6fea, (q15_t)0x6fe7, (q15_t)0x6fe4, (q15_t)0x6fe1, (q15_t)0x6fde, (q15_t)0x6fdb, - (q15_t)0x6fd8, (q15_t)0x6fd5, (q15_t)0x6fd2, (q15_t)0x6fcf, (q15_t)0x6fcc, (q15_t)0x6fc9, (q15_t)0x6fc6, (q15_t)0x6fc3, - (q15_t)0x6fc0, (q15_t)0x6fbc, (q15_t)0x6fb9, (q15_t)0x6fb6, (q15_t)0x6fb3, (q15_t)0x6fb0, (q15_t)0x6fad, (q15_t)0x6faa, - (q15_t)0x6fa7, (q15_t)0x6fa4, (q15_t)0x6fa1, (q15_t)0x6f9e, (q15_t)0x6f9b, (q15_t)0x6f98, (q15_t)0x6f95, (q15_t)0x6f91, - (q15_t)0x6f8e, (q15_t)0x6f8b, (q15_t)0x6f88, (q15_t)0x6f85, (q15_t)0x6f82, (q15_t)0x6f7f, (q15_t)0x6f7c, (q15_t)0x6f79, - (q15_t)0x6f76, (q15_t)0x6f73, (q15_t)0x6f70, (q15_t)0x6f6c, (q15_t)0x6f69, (q15_t)0x6f66, (q15_t)0x6f63, (q15_t)0x6f60, - (q15_t)0x6f5d, (q15_t)0x6f5a, (q15_t)0x6f57, (q15_t)0x6f54, (q15_t)0x6f51, (q15_t)0x6f4d, (q15_t)0x6f4a, (q15_t)0x6f47, - (q15_t)0x6f44, (q15_t)0x6f41, (q15_t)0x6f3e, (q15_t)0x6f3b, (q15_t)0x6f38, (q15_t)0x6f35, (q15_t)0x6f31, (q15_t)0x6f2e, - (q15_t)0x6f2b, (q15_t)0x6f28, (q15_t)0x6f25, (q15_t)0x6f22, (q15_t)0x6f1f, (q15_t)0x6f1c, (q15_t)0x6f19, (q15_t)0x6f15, - (q15_t)0x6f12, (q15_t)0x6f0f, (q15_t)0x6f0c, (q15_t)0x6f09, (q15_t)0x6f06, (q15_t)0x6f03, (q15_t)0x6f00, (q15_t)0x6efc, - (q15_t)0x6ef9, (q15_t)0x6ef6, (q15_t)0x6ef3, (q15_t)0x6ef0, (q15_t)0x6eed, (q15_t)0x6eea, (q15_t)0x6ee7, (q15_t)0x6ee3, - (q15_t)0x6ee0, (q15_t)0x6edd, (q15_t)0x6eda, (q15_t)0x6ed7, (q15_t)0x6ed4, (q15_t)0x6ed1, (q15_t)0x6ecd, (q15_t)0x6eca, - (q15_t)0x6ec7, (q15_t)0x6ec4, (q15_t)0x6ec1, (q15_t)0x6ebe, (q15_t)0x6eba, (q15_t)0x6eb7, (q15_t)0x6eb4, (q15_t)0x6eb1, - (q15_t)0x6eae, (q15_t)0x6eab, (q15_t)0x6ea8, (q15_t)0x6ea4, (q15_t)0x6ea1, (q15_t)0x6e9e, (q15_t)0x6e9b, (q15_t)0x6e98, - (q15_t)0x6e95, (q15_t)0x6e91, (q15_t)0x6e8e, (q15_t)0x6e8b, (q15_t)0x6e88, (q15_t)0x6e85, (q15_t)0x6e82, (q15_t)0x6e7e, - (q15_t)0x6e7b, (q15_t)0x6e78, (q15_t)0x6e75, (q15_t)0x6e72, (q15_t)0x6e6f, (q15_t)0x6e6b, (q15_t)0x6e68, (q15_t)0x6e65, - (q15_t)0x6e62, (q15_t)0x6e5f, (q15_t)0x6e5b, (q15_t)0x6e58, (q15_t)0x6e55, (q15_t)0x6e52, (q15_t)0x6e4f, (q15_t)0x6e4c, - (q15_t)0x6e48, (q15_t)0x6e45, (q15_t)0x6e42, (q15_t)0x6e3f, (q15_t)0x6e3c, (q15_t)0x6e38, (q15_t)0x6e35, (q15_t)0x6e32, - (q15_t)0x6e2f, (q15_t)0x6e2c, (q15_t)0x6e28, (q15_t)0x6e25, (q15_t)0x6e22, (q15_t)0x6e1f, (q15_t)0x6e1c, (q15_t)0x6e18, - (q15_t)0x6e15, (q15_t)0x6e12, (q15_t)0x6e0f, (q15_t)0x6e0c, (q15_t)0x6e08, (q15_t)0x6e05, (q15_t)0x6e02, (q15_t)0x6dff, - (q15_t)0x6dfb, (q15_t)0x6df8, (q15_t)0x6df5, (q15_t)0x6df2, (q15_t)0x6def, (q15_t)0x6deb, (q15_t)0x6de8, (q15_t)0x6de5, - (q15_t)0x6de2, (q15_t)0x6ddf, (q15_t)0x6ddb, (q15_t)0x6dd8, (q15_t)0x6dd5, (q15_t)0x6dd2, (q15_t)0x6dce, (q15_t)0x6dcb, - (q15_t)0x6dc8, (q15_t)0x6dc5, (q15_t)0x6dc1, (q15_t)0x6dbe, (q15_t)0x6dbb, (q15_t)0x6db8, (q15_t)0x6db5, (q15_t)0x6db1, - (q15_t)0x6dae, (q15_t)0x6dab, (q15_t)0x6da8, (q15_t)0x6da4, (q15_t)0x6da1, (q15_t)0x6d9e, (q15_t)0x6d9b, (q15_t)0x6d97, - (q15_t)0x6d94, (q15_t)0x6d91, (q15_t)0x6d8e, (q15_t)0x6d8a, (q15_t)0x6d87, (q15_t)0x6d84, (q15_t)0x6d81, (q15_t)0x6d7d, - (q15_t)0x6d7a, (q15_t)0x6d77, (q15_t)0x6d74, (q15_t)0x6d70, (q15_t)0x6d6d, (q15_t)0x6d6a, (q15_t)0x6d67, (q15_t)0x6d63, - (q15_t)0x6d60, (q15_t)0x6d5d, (q15_t)0x6d59, (q15_t)0x6d56, (q15_t)0x6d53, (q15_t)0x6d50, (q15_t)0x6d4c, (q15_t)0x6d49, - (q15_t)0x6d46, (q15_t)0x6d43, (q15_t)0x6d3f, (q15_t)0x6d3c, (q15_t)0x6d39, (q15_t)0x6d36, (q15_t)0x6d32, (q15_t)0x6d2f, - (q15_t)0x6d2c, (q15_t)0x6d28, (q15_t)0x6d25, (q15_t)0x6d22, (q15_t)0x6d1f, (q15_t)0x6d1b, (q15_t)0x6d18, (q15_t)0x6d15, - (q15_t)0x6d11, (q15_t)0x6d0e, (q15_t)0x6d0b, (q15_t)0x6d08, (q15_t)0x6d04, (q15_t)0x6d01, (q15_t)0x6cfe, (q15_t)0x6cfa, - (q15_t)0x6cf7, (q15_t)0x6cf4, (q15_t)0x6cf0, (q15_t)0x6ced, (q15_t)0x6cea, (q15_t)0x6ce7, (q15_t)0x6ce3, (q15_t)0x6ce0, - (q15_t)0x6cdd, (q15_t)0x6cd9, (q15_t)0x6cd6, (q15_t)0x6cd3, (q15_t)0x6ccf, (q15_t)0x6ccc, (q15_t)0x6cc9, (q15_t)0x6cc5, - (q15_t)0x6cc2, (q15_t)0x6cbf, (q15_t)0x6cbc, (q15_t)0x6cb8, (q15_t)0x6cb5, (q15_t)0x6cb2, (q15_t)0x6cae, (q15_t)0x6cab, - (q15_t)0x6ca8, (q15_t)0x6ca4, (q15_t)0x6ca1, (q15_t)0x6c9e, (q15_t)0x6c9a, (q15_t)0x6c97, (q15_t)0x6c94, (q15_t)0x6c90, - (q15_t)0x6c8d, (q15_t)0x6c8a, (q15_t)0x6c86, (q15_t)0x6c83, (q15_t)0x6c80, (q15_t)0x6c7c, (q15_t)0x6c79, (q15_t)0x6c76, - (q15_t)0x6c72, (q15_t)0x6c6f, (q15_t)0x6c6c, (q15_t)0x6c68, (q15_t)0x6c65, (q15_t)0x6c62, (q15_t)0x6c5e, (q15_t)0x6c5b, - (q15_t)0x6c58, (q15_t)0x6c54, (q15_t)0x6c51, (q15_t)0x6c4e, (q15_t)0x6c4a, (q15_t)0x6c47, (q15_t)0x6c44, (q15_t)0x6c40, - (q15_t)0x6c3d, (q15_t)0x6c39, (q15_t)0x6c36, (q15_t)0x6c33, (q15_t)0x6c2f, (q15_t)0x6c2c, (q15_t)0x6c29, (q15_t)0x6c25, - (q15_t)0x6c22, (q15_t)0x6c1f, (q15_t)0x6c1b, (q15_t)0x6c18, (q15_t)0x6c15, (q15_t)0x6c11, (q15_t)0x6c0e, (q15_t)0x6c0a, - (q15_t)0x6c07, (q15_t)0x6c04, (q15_t)0x6c00, (q15_t)0x6bfd, (q15_t)0x6bfa, (q15_t)0x6bf6, (q15_t)0x6bf3, (q15_t)0x6bef, - (q15_t)0x6bec, (q15_t)0x6be9, (q15_t)0x6be5, (q15_t)0x6be2, (q15_t)0x6bdf, (q15_t)0x6bdb, (q15_t)0x6bd8, (q15_t)0x6bd4, - (q15_t)0x6bd1, (q15_t)0x6bce, (q15_t)0x6bca, (q15_t)0x6bc7, (q15_t)0x6bc3, (q15_t)0x6bc0, (q15_t)0x6bbd, (q15_t)0x6bb9, - (q15_t)0x6bb6, (q15_t)0x6bb2, (q15_t)0x6baf, (q15_t)0x6bac, (q15_t)0x6ba8, (q15_t)0x6ba5, (q15_t)0x6ba1, (q15_t)0x6b9e, - (q15_t)0x6b9b, (q15_t)0x6b97, (q15_t)0x6b94, (q15_t)0x6b90, (q15_t)0x6b8d, (q15_t)0x6b8a, (q15_t)0x6b86, (q15_t)0x6b83, - (q15_t)0x6b7f, (q15_t)0x6b7c, (q15_t)0x6b79, (q15_t)0x6b75, (q15_t)0x6b72, (q15_t)0x6b6e, (q15_t)0x6b6b, (q15_t)0x6b68, - (q15_t)0x6b64, (q15_t)0x6b61, (q15_t)0x6b5d, (q15_t)0x6b5a, (q15_t)0x6b56, (q15_t)0x6b53, (q15_t)0x6b50, (q15_t)0x6b4c, - (q15_t)0x6b49, (q15_t)0x6b45, (q15_t)0x6b42, (q15_t)0x6b3e, (q15_t)0x6b3b, (q15_t)0x6b38, (q15_t)0x6b34, (q15_t)0x6b31, - (q15_t)0x6b2d, (q15_t)0x6b2a, (q15_t)0x6b26, (q15_t)0x6b23, (q15_t)0x6b20, (q15_t)0x6b1c, (q15_t)0x6b19, (q15_t)0x6b15, - (q15_t)0x6b12, (q15_t)0x6b0e, (q15_t)0x6b0b, (q15_t)0x6b07, (q15_t)0x6b04, (q15_t)0x6b01, (q15_t)0x6afd, (q15_t)0x6afa, - (q15_t)0x6af6, (q15_t)0x6af3, (q15_t)0x6aef, (q15_t)0x6aec, (q15_t)0x6ae8, (q15_t)0x6ae5, (q15_t)0x6ae1, (q15_t)0x6ade, - (q15_t)0x6adb, (q15_t)0x6ad7, (q15_t)0x6ad4, (q15_t)0x6ad0, (q15_t)0x6acd, (q15_t)0x6ac9, (q15_t)0x6ac6, (q15_t)0x6ac2, - (q15_t)0x6abf, (q15_t)0x6abb, (q15_t)0x6ab8, (q15_t)0x6ab4, (q15_t)0x6ab1, (q15_t)0x6aae, (q15_t)0x6aaa, (q15_t)0x6aa7, - (q15_t)0x6aa3, (q15_t)0x6aa0, (q15_t)0x6a9c, (q15_t)0x6a99, (q15_t)0x6a95, (q15_t)0x6a92, (q15_t)0x6a8e, (q15_t)0x6a8b, - (q15_t)0x6a87, (q15_t)0x6a84, (q15_t)0x6a80, (q15_t)0x6a7d, (q15_t)0x6a79, (q15_t)0x6a76, (q15_t)0x6a72, (q15_t)0x6a6f, - (q15_t)0x6a6b, (q15_t)0x6a68, (q15_t)0x6a64, (q15_t)0x6a61, (q15_t)0x6a5d, (q15_t)0x6a5a, (q15_t)0x6a56, (q15_t)0x6a53, - (q15_t)0x6a4f, (q15_t)0x6a4c, (q15_t)0x6a48, (q15_t)0x6a45, (q15_t)0x6a41, (q15_t)0x6a3e, (q15_t)0x6a3a, (q15_t)0x6a37, - (q15_t)0x6a33, (q15_t)0x6a30, (q15_t)0x6a2c, (q15_t)0x6a29, (q15_t)0x6a25, (q15_t)0x6a22, (q15_t)0x6a1e, (q15_t)0x6a1b, - (q15_t)0x6a17, (q15_t)0x6a14, (q15_t)0x6a10, (q15_t)0x6a0d, (q15_t)0x6a09, (q15_t)0x6a06, (q15_t)0x6a02, (q15_t)0x69ff, - (q15_t)0x69fb, (q15_t)0x69f8, (q15_t)0x69f4, (q15_t)0x69f1, (q15_t)0x69ed, (q15_t)0x69e9, (q15_t)0x69e6, (q15_t)0x69e2, - (q15_t)0x69df, (q15_t)0x69db, (q15_t)0x69d8, (q15_t)0x69d4, (q15_t)0x69d1, (q15_t)0x69cd, (q15_t)0x69ca, (q15_t)0x69c6, - (q15_t)0x69c3, (q15_t)0x69bf, (q15_t)0x69bc, (q15_t)0x69b8, (q15_t)0x69b4, (q15_t)0x69b1, (q15_t)0x69ad, (q15_t)0x69aa, - (q15_t)0x69a6, (q15_t)0x69a3, (q15_t)0x699f, (q15_t)0x699c, (q15_t)0x6998, (q15_t)0x6995, (q15_t)0x6991, (q15_t)0x698d, - (q15_t)0x698a, (q15_t)0x6986, (q15_t)0x6983, (q15_t)0x697f, (q15_t)0x697c, (q15_t)0x6978, (q15_t)0x6975, (q15_t)0x6971, - (q15_t)0x696d, (q15_t)0x696a, (q15_t)0x6966, (q15_t)0x6963, (q15_t)0x695f, (q15_t)0x695c, (q15_t)0x6958, (q15_t)0x6954, - (q15_t)0x6951, (q15_t)0x694d, (q15_t)0x694a, (q15_t)0x6946, (q15_t)0x6943, (q15_t)0x693f, (q15_t)0x693b, (q15_t)0x6938, - (q15_t)0x6934, (q15_t)0x6931, (q15_t)0x692d, (q15_t)0x692a, (q15_t)0x6926, (q15_t)0x6922, (q15_t)0x691f, (q15_t)0x691b, - (q15_t)0x6918, (q15_t)0x6914, (q15_t)0x6910, (q15_t)0x690d, (q15_t)0x6909, (q15_t)0x6906, (q15_t)0x6902, (q15_t)0x68fe, - (q15_t)0x68fb, (q15_t)0x68f7, (q15_t)0x68f4, (q15_t)0x68f0, (q15_t)0x68ec, (q15_t)0x68e9, (q15_t)0x68e5, (q15_t)0x68e2, - (q15_t)0x68de, (q15_t)0x68da, (q15_t)0x68d7, (q15_t)0x68d3, (q15_t)0x68d0, (q15_t)0x68cc, (q15_t)0x68c8, (q15_t)0x68c5, - (q15_t)0x68c1, (q15_t)0x68be, (q15_t)0x68ba, (q15_t)0x68b6, (q15_t)0x68b3, (q15_t)0x68af, (q15_t)0x68ac, (q15_t)0x68a8, - (q15_t)0x68a4, (q15_t)0x68a1, (q15_t)0x689d, (q15_t)0x6899, (q15_t)0x6896, (q15_t)0x6892, (q15_t)0x688f, (q15_t)0x688b, - (q15_t)0x6887, (q15_t)0x6884, (q15_t)0x6880, (q15_t)0x687c, (q15_t)0x6879, (q15_t)0x6875, (q15_t)0x6872, (q15_t)0x686e, - (q15_t)0x686a, (q15_t)0x6867, (q15_t)0x6863, (q15_t)0x685f, (q15_t)0x685c, (q15_t)0x6858, (q15_t)0x6854, (q15_t)0x6851, - (q15_t)0x684d, (q15_t)0x684a, (q15_t)0x6846, (q15_t)0x6842, (q15_t)0x683f, (q15_t)0x683b, (q15_t)0x6837, (q15_t)0x6834, - (q15_t)0x6830, (q15_t)0x682c, (q15_t)0x6829, (q15_t)0x6825, (q15_t)0x6821, (q15_t)0x681e, (q15_t)0x681a, (q15_t)0x6816, - (q15_t)0x6813, (q15_t)0x680f, (q15_t)0x680b, (q15_t)0x6808, (q15_t)0x6804, (q15_t)0x6800, (q15_t)0x67fd, (q15_t)0x67f9, - (q15_t)0x67f5, (q15_t)0x67f2, (q15_t)0x67ee, (q15_t)0x67ea, (q15_t)0x67e7, (q15_t)0x67e3, (q15_t)0x67df, (q15_t)0x67dc, - (q15_t)0x67d8, (q15_t)0x67d4, (q15_t)0x67d1, (q15_t)0x67cd, (q15_t)0x67c9, (q15_t)0x67c6, (q15_t)0x67c2, (q15_t)0x67be, - (q15_t)0x67bb, (q15_t)0x67b7, (q15_t)0x67b3, (q15_t)0x67b0, (q15_t)0x67ac, (q15_t)0x67a8, (q15_t)0x67a5, (q15_t)0x67a1, - (q15_t)0x679d, (q15_t)0x679a, (q15_t)0x6796, (q15_t)0x6792, (q15_t)0x678e, (q15_t)0x678b, (q15_t)0x6787, (q15_t)0x6783, - (q15_t)0x6780, (q15_t)0x677c, (q15_t)0x6778, (q15_t)0x6775, (q15_t)0x6771, (q15_t)0x676d, (q15_t)0x6769, (q15_t)0x6766, - (q15_t)0x6762, (q15_t)0x675e, (q15_t)0x675b, (q15_t)0x6757, (q15_t)0x6753, (q15_t)0x6750, (q15_t)0x674c, (q15_t)0x6748, - (q15_t)0x6744, (q15_t)0x6741, (q15_t)0x673d, (q15_t)0x6739, (q15_t)0x6736, (q15_t)0x6732, (q15_t)0x672e, (q15_t)0x672a, - (q15_t)0x6727, (q15_t)0x6723, (q15_t)0x671f, (q15_t)0x671c, (q15_t)0x6718, (q15_t)0x6714, (q15_t)0x6710, (q15_t)0x670d, - (q15_t)0x6709, (q15_t)0x6705, (q15_t)0x6701, (q15_t)0x66fe, (q15_t)0x66fa, (q15_t)0x66f6, (q15_t)0x66f3, (q15_t)0x66ef, - (q15_t)0x66eb, (q15_t)0x66e7, (q15_t)0x66e4, (q15_t)0x66e0, (q15_t)0x66dc, (q15_t)0x66d8, (q15_t)0x66d5, (q15_t)0x66d1, - (q15_t)0x66cd, (q15_t)0x66c9, (q15_t)0x66c6, (q15_t)0x66c2, (q15_t)0x66be, (q15_t)0x66ba, (q15_t)0x66b7, (q15_t)0x66b3, - (q15_t)0x66af, (q15_t)0x66ab, (q15_t)0x66a8, (q15_t)0x66a4, (q15_t)0x66a0, (q15_t)0x669c, (q15_t)0x6699, (q15_t)0x6695, - (q15_t)0x6691, (q15_t)0x668d, (q15_t)0x668a, (q15_t)0x6686, (q15_t)0x6682, (q15_t)0x667e, (q15_t)0x667b, (q15_t)0x6677, - (q15_t)0x6673, (q15_t)0x666f, (q15_t)0x666b, (q15_t)0x6668, (q15_t)0x6664, (q15_t)0x6660, (q15_t)0x665c, (q15_t)0x6659, - (q15_t)0x6655, (q15_t)0x6651, (q15_t)0x664d, (q15_t)0x664a, (q15_t)0x6646, (q15_t)0x6642, (q15_t)0x663e, (q15_t)0x663a, - (q15_t)0x6637, (q15_t)0x6633, (q15_t)0x662f, (q15_t)0x662b, (q15_t)0x6627, (q15_t)0x6624, (q15_t)0x6620, (q15_t)0x661c, - (q15_t)0x6618, (q15_t)0x6615, (q15_t)0x6611, (q15_t)0x660d, (q15_t)0x6609, (q15_t)0x6605, (q15_t)0x6602, (q15_t)0x65fe, - (q15_t)0x65fa, (q15_t)0x65f6, (q15_t)0x65f2, (q15_t)0x65ef, (q15_t)0x65eb, (q15_t)0x65e7, (q15_t)0x65e3, (q15_t)0x65df, - (q15_t)0x65dc, (q15_t)0x65d8, (q15_t)0x65d4, (q15_t)0x65d0, (q15_t)0x65cc, (q15_t)0x65c9, (q15_t)0x65c5, (q15_t)0x65c1, - (q15_t)0x65bd, (q15_t)0x65b9, (q15_t)0x65b5, (q15_t)0x65b2, (q15_t)0x65ae, (q15_t)0x65aa, (q15_t)0x65a6, (q15_t)0x65a2, - (q15_t)0x659f, (q15_t)0x659b, (q15_t)0x6597, (q15_t)0x6593, (q15_t)0x658f, (q15_t)0x658b, (q15_t)0x6588, (q15_t)0x6584, - (q15_t)0x6580, (q15_t)0x657c, (q15_t)0x6578, (q15_t)0x6574, (q15_t)0x6571, (q15_t)0x656d, (q15_t)0x6569, (q15_t)0x6565, - (q15_t)0x6561, (q15_t)0x655d, (q15_t)0x655a, (q15_t)0x6556, (q15_t)0x6552, (q15_t)0x654e, (q15_t)0x654a, (q15_t)0x6546, - (q15_t)0x6543, (q15_t)0x653f, (q15_t)0x653b, (q15_t)0x6537, (q15_t)0x6533, (q15_t)0x652f, (q15_t)0x652c, (q15_t)0x6528, - (q15_t)0x6524, (q15_t)0x6520, (q15_t)0x651c, (q15_t)0x6518, (q15_t)0x6514, (q15_t)0x6511, (q15_t)0x650d, (q15_t)0x6509, - (q15_t)0x6505, (q15_t)0x6501, (q15_t)0x64fd, (q15_t)0x64f9, (q15_t)0x64f6, (q15_t)0x64f2, (q15_t)0x64ee, (q15_t)0x64ea, - (q15_t)0x64e6, (q15_t)0x64e2, (q15_t)0x64de, (q15_t)0x64db, (q15_t)0x64d7, (q15_t)0x64d3, (q15_t)0x64cf, (q15_t)0x64cb, - (q15_t)0x64c7, (q15_t)0x64c3, (q15_t)0x64bf, (q15_t)0x64bc, (q15_t)0x64b8, (q15_t)0x64b4, (q15_t)0x64b0, (q15_t)0x64ac, - (q15_t)0x64a8, (q15_t)0x64a4, (q15_t)0x64a0, (q15_t)0x649c, (q15_t)0x6499, (q15_t)0x6495, (q15_t)0x6491, (q15_t)0x648d, - (q15_t)0x6489, (q15_t)0x6485, (q15_t)0x6481, (q15_t)0x647d, (q15_t)0x6479, (q15_t)0x6476, (q15_t)0x6472, (q15_t)0x646e, - (q15_t)0x646a, (q15_t)0x6466, (q15_t)0x6462, (q15_t)0x645e, (q15_t)0x645a, (q15_t)0x6456, (q15_t)0x6453, (q15_t)0x644f, - (q15_t)0x644b, (q15_t)0x6447, (q15_t)0x6443, (q15_t)0x643f, (q15_t)0x643b, (q15_t)0x6437, (q15_t)0x6433, (q15_t)0x642f, - (q15_t)0x642b, (q15_t)0x6428, (q15_t)0x6424, (q15_t)0x6420, (q15_t)0x641c, (q15_t)0x6418, (q15_t)0x6414, (q15_t)0x6410, - (q15_t)0x640c, (q15_t)0x6408, (q15_t)0x6404, (q15_t)0x6400, (q15_t)0x63fc, (q15_t)0x63f9, (q15_t)0x63f5, (q15_t)0x63f1, - (q15_t)0x63ed, (q15_t)0x63e9, (q15_t)0x63e5, (q15_t)0x63e1, (q15_t)0x63dd, (q15_t)0x63d9, (q15_t)0x63d5, (q15_t)0x63d1, - (q15_t)0x63cd, (q15_t)0x63c9, (q15_t)0x63c5, (q15_t)0x63c1, (q15_t)0x63be, (q15_t)0x63ba, (q15_t)0x63b6, (q15_t)0x63b2, - (q15_t)0x63ae, (q15_t)0x63aa, (q15_t)0x63a6, (q15_t)0x63a2, (q15_t)0x639e, (q15_t)0x639a, (q15_t)0x6396, (q15_t)0x6392, - (q15_t)0x638e, (q15_t)0x638a, (q15_t)0x6386, (q15_t)0x6382, (q15_t)0x637e, (q15_t)0x637a, (q15_t)0x6377, (q15_t)0x6373, - (q15_t)0x636f, (q15_t)0x636b, (q15_t)0x6367, (q15_t)0x6363, (q15_t)0x635f, (q15_t)0x635b, (q15_t)0x6357, (q15_t)0x6353, - (q15_t)0x634f, (q15_t)0x634b, (q15_t)0x6347, (q15_t)0x6343, (q15_t)0x633f, (q15_t)0x633b, (q15_t)0x6337, (q15_t)0x6333, - (q15_t)0x632f, (q15_t)0x632b, (q15_t)0x6327, (q15_t)0x6323, (q15_t)0x631f, (q15_t)0x631b, (q15_t)0x6317, (q15_t)0x6313, - (q15_t)0x630f, (q15_t)0x630b, (q15_t)0x6307, (q15_t)0x6303, (q15_t)0x62ff, (q15_t)0x62fb, (q15_t)0x62f7, (q15_t)0x62f3, - (q15_t)0x62f0, (q15_t)0x62ec, (q15_t)0x62e8, (q15_t)0x62e4, (q15_t)0x62e0, (q15_t)0x62dc, (q15_t)0x62d8, (q15_t)0x62d4, - (q15_t)0x62d0, (q15_t)0x62cc, (q15_t)0x62c8, (q15_t)0x62c4, (q15_t)0x62c0, (q15_t)0x62bc, (q15_t)0x62b8, (q15_t)0x62b4, - (q15_t)0x62b0, (q15_t)0x62ac, (q15_t)0x62a8, (q15_t)0x62a4, (q15_t)0x62a0, (q15_t)0x629c, (q15_t)0x6298, (q15_t)0x6294, - (q15_t)0x6290, (q15_t)0x628c, (q15_t)0x6288, (q15_t)0x6284, (q15_t)0x6280, (q15_t)0x627c, (q15_t)0x6278, (q15_t)0x6273, - (q15_t)0x626f, (q15_t)0x626b, (q15_t)0x6267, (q15_t)0x6263, (q15_t)0x625f, (q15_t)0x625b, (q15_t)0x6257, (q15_t)0x6253, - (q15_t)0x624f, (q15_t)0x624b, (q15_t)0x6247, (q15_t)0x6243, (q15_t)0x623f, (q15_t)0x623b, (q15_t)0x6237, (q15_t)0x6233, - (q15_t)0x622f, (q15_t)0x622b, (q15_t)0x6227, (q15_t)0x6223, (q15_t)0x621f, (q15_t)0x621b, (q15_t)0x6217, (q15_t)0x6213, - (q15_t)0x620f, (q15_t)0x620b, (q15_t)0x6207, (q15_t)0x6203, (q15_t)0x61ff, (q15_t)0x61fb, (q15_t)0x61f7, (q15_t)0x61f3, - (q15_t)0x61ee, (q15_t)0x61ea, (q15_t)0x61e6, (q15_t)0x61e2, (q15_t)0x61de, (q15_t)0x61da, (q15_t)0x61d6, (q15_t)0x61d2, - (q15_t)0x61ce, (q15_t)0x61ca, (q15_t)0x61c6, (q15_t)0x61c2, (q15_t)0x61be, (q15_t)0x61ba, (q15_t)0x61b6, (q15_t)0x61b2, - (q15_t)0x61ae, (q15_t)0x61aa, (q15_t)0x61a6, (q15_t)0x61a1, (q15_t)0x619d, (q15_t)0x6199, (q15_t)0x6195, (q15_t)0x6191, - (q15_t)0x618d, (q15_t)0x6189, (q15_t)0x6185, (q15_t)0x6181, (q15_t)0x617d, (q15_t)0x6179, (q15_t)0x6175, (q15_t)0x6171, - (q15_t)0x616d, (q15_t)0x6168, (q15_t)0x6164, (q15_t)0x6160, (q15_t)0x615c, (q15_t)0x6158, (q15_t)0x6154, (q15_t)0x6150, - (q15_t)0x614c, (q15_t)0x6148, (q15_t)0x6144, (q15_t)0x6140, (q15_t)0x613c, (q15_t)0x6137, (q15_t)0x6133, (q15_t)0x612f, - (q15_t)0x612b, (q15_t)0x6127, (q15_t)0x6123, (q15_t)0x611f, (q15_t)0x611b, (q15_t)0x6117, (q15_t)0x6113, (q15_t)0x610f, - (q15_t)0x610a, (q15_t)0x6106, (q15_t)0x6102, (q15_t)0x60fe, (q15_t)0x60fa, (q15_t)0x60f6, (q15_t)0x60f2, (q15_t)0x60ee, - (q15_t)0x60ea, (q15_t)0x60e6, (q15_t)0x60e1, (q15_t)0x60dd, (q15_t)0x60d9, (q15_t)0x60d5, (q15_t)0x60d1, (q15_t)0x60cd, - (q15_t)0x60c9, (q15_t)0x60c5, (q15_t)0x60c1, (q15_t)0x60bc, (q15_t)0x60b8, (q15_t)0x60b4, (q15_t)0x60b0, (q15_t)0x60ac, - (q15_t)0x60a8, (q15_t)0x60a4, (q15_t)0x60a0, (q15_t)0x609c, (q15_t)0x6097, (q15_t)0x6093, (q15_t)0x608f, (q15_t)0x608b, - (q15_t)0x6087, (q15_t)0x6083, (q15_t)0x607f, (q15_t)0x607b, (q15_t)0x6076, (q15_t)0x6072, (q15_t)0x606e, (q15_t)0x606a, - (q15_t)0x6066, (q15_t)0x6062, (q15_t)0x605e, (q15_t)0x6059, (q15_t)0x6055, (q15_t)0x6051, (q15_t)0x604d, (q15_t)0x6049, - (q15_t)0x6045, (q15_t)0x6041, (q15_t)0x603c, (q15_t)0x6038, (q15_t)0x6034, (q15_t)0x6030, (q15_t)0x602c, (q15_t)0x6028, - (q15_t)0x6024, (q15_t)0x601f, (q15_t)0x601b, (q15_t)0x6017, (q15_t)0x6013, (q15_t)0x600f, (q15_t)0x600b, (q15_t)0x6007, - (q15_t)0x6002, (q15_t)0x5ffe, (q15_t)0x5ffa, (q15_t)0x5ff6, (q15_t)0x5ff2, (q15_t)0x5fee, (q15_t)0x5fe9, (q15_t)0x5fe5, - (q15_t)0x5fe1, (q15_t)0x5fdd, (q15_t)0x5fd9, (q15_t)0x5fd5, (q15_t)0x5fd0, (q15_t)0x5fcc, (q15_t)0x5fc8, (q15_t)0x5fc4, - (q15_t)0x5fc0, (q15_t)0x5fbc, (q15_t)0x5fb7, (q15_t)0x5fb3, (q15_t)0x5faf, (q15_t)0x5fab, (q15_t)0x5fa7, (q15_t)0x5fa3, - (q15_t)0x5f9e, (q15_t)0x5f9a, (q15_t)0x5f96, (q15_t)0x5f92, (q15_t)0x5f8e, (q15_t)0x5f8a, (q15_t)0x5f85, (q15_t)0x5f81, - (q15_t)0x5f7d, (q15_t)0x5f79, (q15_t)0x5f75, (q15_t)0x5f70, (q15_t)0x5f6c, (q15_t)0x5f68, (q15_t)0x5f64, (q15_t)0x5f60, - (q15_t)0x5f5b, (q15_t)0x5f57, (q15_t)0x5f53, (q15_t)0x5f4f, (q15_t)0x5f4b, (q15_t)0x5f46, (q15_t)0x5f42, (q15_t)0x5f3e, - (q15_t)0x5f3a, (q15_t)0x5f36, (q15_t)0x5f31, (q15_t)0x5f2d, (q15_t)0x5f29, (q15_t)0x5f25, (q15_t)0x5f21, (q15_t)0x5f1c, - (q15_t)0x5f18, (q15_t)0x5f14, (q15_t)0x5f10, (q15_t)0x5f0c, (q15_t)0x5f07, (q15_t)0x5f03, (q15_t)0x5eff, (q15_t)0x5efb, - (q15_t)0x5ef7, (q15_t)0x5ef2, (q15_t)0x5eee, (q15_t)0x5eea, (q15_t)0x5ee6, (q15_t)0x5ee2, (q15_t)0x5edd, (q15_t)0x5ed9, - (q15_t)0x5ed5, (q15_t)0x5ed1, (q15_t)0x5ecc, (q15_t)0x5ec8, (q15_t)0x5ec4, (q15_t)0x5ec0, (q15_t)0x5ebc, (q15_t)0x5eb7, - (q15_t)0x5eb3, (q15_t)0x5eaf, (q15_t)0x5eab, (q15_t)0x5ea6, (q15_t)0x5ea2, (q15_t)0x5e9e, (q15_t)0x5e9a, (q15_t)0x5e95, - (q15_t)0x5e91, (q15_t)0x5e8d, (q15_t)0x5e89, (q15_t)0x5e85, (q15_t)0x5e80, (q15_t)0x5e7c, (q15_t)0x5e78, (q15_t)0x5e74, - (q15_t)0x5e6f, (q15_t)0x5e6b, (q15_t)0x5e67, (q15_t)0x5e63, (q15_t)0x5e5e, (q15_t)0x5e5a, (q15_t)0x5e56, (q15_t)0x5e52, - (q15_t)0x5e4d, (q15_t)0x5e49, (q15_t)0x5e45, (q15_t)0x5e41, (q15_t)0x5e3c, (q15_t)0x5e38, (q15_t)0x5e34, (q15_t)0x5e30, - (q15_t)0x5e2b, (q15_t)0x5e27, (q15_t)0x5e23, (q15_t)0x5e1f, (q15_t)0x5e1a, (q15_t)0x5e16, (q15_t)0x5e12, (q15_t)0x5e0e, - (q15_t)0x5e09, (q15_t)0x5e05, (q15_t)0x5e01, (q15_t)0x5dfd, (q15_t)0x5df8, (q15_t)0x5df4, (q15_t)0x5df0, (q15_t)0x5deb, - (q15_t)0x5de7, (q15_t)0x5de3, (q15_t)0x5ddf, (q15_t)0x5dda, (q15_t)0x5dd6, (q15_t)0x5dd2, (q15_t)0x5dce, (q15_t)0x5dc9, - (q15_t)0x5dc5, (q15_t)0x5dc1, (q15_t)0x5dbc, (q15_t)0x5db8, (q15_t)0x5db4, (q15_t)0x5db0, (q15_t)0x5dab, (q15_t)0x5da7, - (q15_t)0x5da3, (q15_t)0x5d9e, (q15_t)0x5d9a, (q15_t)0x5d96, (q15_t)0x5d92, (q15_t)0x5d8d, (q15_t)0x5d89, (q15_t)0x5d85, - (q15_t)0x5d80, (q15_t)0x5d7c, (q15_t)0x5d78, (q15_t)0x5d74, (q15_t)0x5d6f, (q15_t)0x5d6b, (q15_t)0x5d67, (q15_t)0x5d62, - (q15_t)0x5d5e, (q15_t)0x5d5a, (q15_t)0x5d55, (q15_t)0x5d51, (q15_t)0x5d4d, (q15_t)0x5d49, (q15_t)0x5d44, (q15_t)0x5d40, - (q15_t)0x5d3c, (q15_t)0x5d37, (q15_t)0x5d33, (q15_t)0x5d2f, (q15_t)0x5d2a, (q15_t)0x5d26, (q15_t)0x5d22, (q15_t)0x5d1e, - (q15_t)0x5d19, (q15_t)0x5d15, (q15_t)0x5d11, (q15_t)0x5d0c, (q15_t)0x5d08, (q15_t)0x5d04, (q15_t)0x5cff, (q15_t)0x5cfb, - (q15_t)0x5cf7, (q15_t)0x5cf2, (q15_t)0x5cee, (q15_t)0x5cea, (q15_t)0x5ce5, (q15_t)0x5ce1, (q15_t)0x5cdd, (q15_t)0x5cd8, - (q15_t)0x5cd4, (q15_t)0x5cd0, (q15_t)0x5ccb, (q15_t)0x5cc7, (q15_t)0x5cc3, (q15_t)0x5cbe, (q15_t)0x5cba, (q15_t)0x5cb6, - (q15_t)0x5cb1, (q15_t)0x5cad, (q15_t)0x5ca9, (q15_t)0x5ca4, (q15_t)0x5ca0, (q15_t)0x5c9c, (q15_t)0x5c97, (q15_t)0x5c93, - (q15_t)0x5c8f, (q15_t)0x5c8a, (q15_t)0x5c86, (q15_t)0x5c82, (q15_t)0x5c7d, (q15_t)0x5c79, (q15_t)0x5c75, (q15_t)0x5c70, - (q15_t)0x5c6c, (q15_t)0x5c68, (q15_t)0x5c63, (q15_t)0x5c5f, (q15_t)0x5c5b, (q15_t)0x5c56, (q15_t)0x5c52, (q15_t)0x5c4e, - (q15_t)0x5c49, (q15_t)0x5c45, (q15_t)0x5c41, (q15_t)0x5c3c, (q15_t)0x5c38, (q15_t)0x5c33, (q15_t)0x5c2f, (q15_t)0x5c2b, - (q15_t)0x5c26, (q15_t)0x5c22, (q15_t)0x5c1e, (q15_t)0x5c19, (q15_t)0x5c15, (q15_t)0x5c11, (q15_t)0x5c0c, (q15_t)0x5c08, - (q15_t)0x5c03, (q15_t)0x5bff, (q15_t)0x5bfb, (q15_t)0x5bf6, (q15_t)0x5bf2, (q15_t)0x5bee, (q15_t)0x5be9, (q15_t)0x5be5, - (q15_t)0x5be0, (q15_t)0x5bdc, (q15_t)0x5bd8, (q15_t)0x5bd3, (q15_t)0x5bcf, (q15_t)0x5bcb, (q15_t)0x5bc6, (q15_t)0x5bc2, - (q15_t)0x5bbd, (q15_t)0x5bb9, (q15_t)0x5bb5, (q15_t)0x5bb0, (q15_t)0x5bac, (q15_t)0x5ba8, (q15_t)0x5ba3, (q15_t)0x5b9f, - (q15_t)0x5b9a, (q15_t)0x5b96, (q15_t)0x5b92, (q15_t)0x5b8d, (q15_t)0x5b89, (q15_t)0x5b84, (q15_t)0x5b80, (q15_t)0x5b7c, - (q15_t)0x5b77, (q15_t)0x5b73, (q15_t)0x5b6e, (q15_t)0x5b6a, (q15_t)0x5b66, (q15_t)0x5b61, (q15_t)0x5b5d, (q15_t)0x5b58, - (q15_t)0x5b54, (q15_t)0x5b50, (q15_t)0x5b4b, (q15_t)0x5b47, (q15_t)0x5b42, (q15_t)0x5b3e, (q15_t)0x5b3a, (q15_t)0x5b35, - (q15_t)0x5b31, (q15_t)0x5b2c, (q15_t)0x5b28, (q15_t)0x5b24, (q15_t)0x5b1f, (q15_t)0x5b1b, (q15_t)0x5b16, (q15_t)0x5b12, - (q15_t)0x5b0e, (q15_t)0x5b09, (q15_t)0x5b05, (q15_t)0x5b00, (q15_t)0x5afc, (q15_t)0x5af7, (q15_t)0x5af3, (q15_t)0x5aef, - (q15_t)0x5aea, (q15_t)0x5ae6, (q15_t)0x5ae1, (q15_t)0x5add, (q15_t)0x5ad8, (q15_t)0x5ad4, (q15_t)0x5ad0, (q15_t)0x5acb, - (q15_t)0x5ac7, (q15_t)0x5ac2, (q15_t)0x5abe, (q15_t)0x5ab9, (q15_t)0x5ab5, (q15_t)0x5ab1, (q15_t)0x5aac, (q15_t)0x5aa8, - (q15_t)0x5aa3, (q15_t)0x5a9f, (q15_t)0x5a9a, (q15_t)0x5a96, (q15_t)0x5a92, (q15_t)0x5a8d, (q15_t)0x5a89, (q15_t)0x5a84, - (q15_t)0x5a80, (q15_t)0x5a7b, (q15_t)0x5a77, (q15_t)0x5a72, (q15_t)0x5a6e, (q15_t)0x5a6a, (q15_t)0x5a65, (q15_t)0x5a61, - (q15_t)0x5a5c, (q15_t)0x5a58, (q15_t)0x5a53, (q15_t)0x5a4f, (q15_t)0x5a4a, (q15_t)0x5a46, (q15_t)0x5a41, (q15_t)0x5a3d, - (q15_t)0x5a39, (q15_t)0x5a34, (q15_t)0x5a30, (q15_t)0x5a2b, (q15_t)0x5a27, (q15_t)0x5a22, (q15_t)0x5a1e, (q15_t)0x5a19, - (q15_t)0x5a15, (q15_t)0x5a10, (q15_t)0x5a0c, (q15_t)0x5a07, (q15_t)0x5a03, (q15_t)0x59ff, (q15_t)0x59fa, (q15_t)0x59f6, - (q15_t)0x59f1, (q15_t)0x59ed, (q15_t)0x59e8, (q15_t)0x59e4, (q15_t)0x59df, (q15_t)0x59db, (q15_t)0x59d6, (q15_t)0x59d2, - (q15_t)0x59cd, (q15_t)0x59c9, (q15_t)0x59c4, (q15_t)0x59c0, (q15_t)0x59bb, (q15_t)0x59b7, (q15_t)0x59b2, (q15_t)0x59ae, - (q15_t)0x59a9, (q15_t)0x59a5, (q15_t)0x59a1, (q15_t)0x599c, (q15_t)0x5998, (q15_t)0x5993, (q15_t)0x598f, (q15_t)0x598a, - (q15_t)0x5986, (q15_t)0x5981, (q15_t)0x597d, (q15_t)0x5978, (q15_t)0x5974, (q15_t)0x596f, (q15_t)0x596b, (q15_t)0x5966, - (q15_t)0x5962, (q15_t)0x595d, (q15_t)0x5959, (q15_t)0x5954, (q15_t)0x5950, (q15_t)0x594b, (q15_t)0x5947, (q15_t)0x5942, - (q15_t)0x593e, (q15_t)0x5939, (q15_t)0x5935, (q15_t)0x5930, (q15_t)0x592c, (q15_t)0x5927, (q15_t)0x5923, (q15_t)0x591e, - (q15_t)0x591a, (q15_t)0x5915, (q15_t)0x5911, (q15_t)0x590c, (q15_t)0x5908, (q15_t)0x5903, (q15_t)0x58fe, (q15_t)0x58fa, - (q15_t)0x58f5, (q15_t)0x58f1, (q15_t)0x58ec, (q15_t)0x58e8, (q15_t)0x58e3, (q15_t)0x58df, (q15_t)0x58da, (q15_t)0x58d6, - (q15_t)0x58d1, (q15_t)0x58cd, (q15_t)0x58c8, (q15_t)0x58c4, (q15_t)0x58bf, (q15_t)0x58bb, (q15_t)0x58b6, (q15_t)0x58b2, - (q15_t)0x58ad, (q15_t)0x58a9, (q15_t)0x58a4, (q15_t)0x589f, (q15_t)0x589b, (q15_t)0x5896, (q15_t)0x5892, (q15_t)0x588d, - (q15_t)0x5889, (q15_t)0x5884, (q15_t)0x5880, (q15_t)0x587b, (q15_t)0x5877, (q15_t)0x5872, (q15_t)0x586e, (q15_t)0x5869, - (q15_t)0x5864, (q15_t)0x5860, (q15_t)0x585b, (q15_t)0x5857, (q15_t)0x5852, (q15_t)0x584e, (q15_t)0x5849, (q15_t)0x5845, - (q15_t)0x5840, (q15_t)0x583c, (q15_t)0x5837, (q15_t)0x5832, (q15_t)0x582e, (q15_t)0x5829, (q15_t)0x5825, (q15_t)0x5820, - (q15_t)0x581c, (q15_t)0x5817, (q15_t)0x5813, (q15_t)0x580e, (q15_t)0x5809, (q15_t)0x5805, (q15_t)0x5800, (q15_t)0x57fc, - (q15_t)0x57f7, (q15_t)0x57f3, (q15_t)0x57ee, (q15_t)0x57e9, (q15_t)0x57e5, (q15_t)0x57e0, (q15_t)0x57dc, (q15_t)0x57d7, - (q15_t)0x57d3, (q15_t)0x57ce, (q15_t)0x57c9, (q15_t)0x57c5, (q15_t)0x57c0, (q15_t)0x57bc, (q15_t)0x57b7, (q15_t)0x57b3, - (q15_t)0x57ae, (q15_t)0x57a9, (q15_t)0x57a5, (q15_t)0x57a0, (q15_t)0x579c, (q15_t)0x5797, (q15_t)0x5793, (q15_t)0x578e, - (q15_t)0x5789, (q15_t)0x5785, (q15_t)0x5780, (q15_t)0x577c, (q15_t)0x5777, (q15_t)0x5772, (q15_t)0x576e, (q15_t)0x5769, - (q15_t)0x5765, (q15_t)0x5760, (q15_t)0x575c, (q15_t)0x5757, (q15_t)0x5752, (q15_t)0x574e, (q15_t)0x5749, (q15_t)0x5745, - (q15_t)0x5740, (q15_t)0x573b, (q15_t)0x5737, (q15_t)0x5732, (q15_t)0x572e, (q15_t)0x5729, (q15_t)0x5724, (q15_t)0x5720, - (q15_t)0x571b, (q15_t)0x5717, (q15_t)0x5712, (q15_t)0x570d, (q15_t)0x5709, (q15_t)0x5704, (q15_t)0x56ff, (q15_t)0x56fb, - (q15_t)0x56f6, (q15_t)0x56f2, (q15_t)0x56ed, (q15_t)0x56e8, (q15_t)0x56e4, (q15_t)0x56df, (q15_t)0x56db, (q15_t)0x56d6, - (q15_t)0x56d1, (q15_t)0x56cd, (q15_t)0x56c8, (q15_t)0x56c4, (q15_t)0x56bf, (q15_t)0x56ba, (q15_t)0x56b6, (q15_t)0x56b1, - (q15_t)0x56ac, (q15_t)0x56a8, (q15_t)0x56a3, (q15_t)0x569f, (q15_t)0x569a, (q15_t)0x5695, (q15_t)0x5691, (q15_t)0x568c, - (q15_t)0x5687, (q15_t)0x5683, (q15_t)0x567e, (q15_t)0x5679, (q15_t)0x5675, (q15_t)0x5670, (q15_t)0x566c, (q15_t)0x5667, - (q15_t)0x5662, (q15_t)0x565e, (q15_t)0x5659, (q15_t)0x5654, (q15_t)0x5650, (q15_t)0x564b, (q15_t)0x5646, (q15_t)0x5642, - (q15_t)0x563d, (q15_t)0x5639, (q15_t)0x5634, (q15_t)0x562f, (q15_t)0x562b, (q15_t)0x5626, (q15_t)0x5621, (q15_t)0x561d, - (q15_t)0x5618, (q15_t)0x5613, (q15_t)0x560f, (q15_t)0x560a, (q15_t)0x5605, (q15_t)0x5601, (q15_t)0x55fc, (q15_t)0x55f7, - (q15_t)0x55f3, (q15_t)0x55ee, (q15_t)0x55ea, (q15_t)0x55e5, (q15_t)0x55e0, (q15_t)0x55dc, (q15_t)0x55d7, (q15_t)0x55d2, - (q15_t)0x55ce, (q15_t)0x55c9, (q15_t)0x55c4, (q15_t)0x55c0, (q15_t)0x55bb, (q15_t)0x55b6, (q15_t)0x55b2, (q15_t)0x55ad, - (q15_t)0x55a8, (q15_t)0x55a4, (q15_t)0x559f, (q15_t)0x559a, (q15_t)0x5596, (q15_t)0x5591, (q15_t)0x558c, (q15_t)0x5588, - (q15_t)0x5583, (q15_t)0x557e, (q15_t)0x5579, (q15_t)0x5575, (q15_t)0x5570, (q15_t)0x556b, (q15_t)0x5567, (q15_t)0x5562, - (q15_t)0x555d, (q15_t)0x5559, (q15_t)0x5554, (q15_t)0x554f, (q15_t)0x554b, (q15_t)0x5546, (q15_t)0x5541, (q15_t)0x553d, - (q15_t)0x5538, (q15_t)0x5533, (q15_t)0x552f, (q15_t)0x552a, (q15_t)0x5525, (q15_t)0x5520, (q15_t)0x551c, (q15_t)0x5517, - (q15_t)0x5512, (q15_t)0x550e, (q15_t)0x5509, (q15_t)0x5504, (q15_t)0x5500, (q15_t)0x54fb, (q15_t)0x54f6, (q15_t)0x54f2, - (q15_t)0x54ed, (q15_t)0x54e8, (q15_t)0x54e3, (q15_t)0x54df, (q15_t)0x54da, (q15_t)0x54d5, (q15_t)0x54d1, (q15_t)0x54cc, - (q15_t)0x54c7, (q15_t)0x54c2, (q15_t)0x54be, (q15_t)0x54b9, (q15_t)0x54b4, (q15_t)0x54b0, (q15_t)0x54ab, (q15_t)0x54a6, - (q15_t)0x54a2, (q15_t)0x549d, (q15_t)0x5498, (q15_t)0x5493, (q15_t)0x548f, (q15_t)0x548a, (q15_t)0x5485, (q15_t)0x5480, - (q15_t)0x547c, (q15_t)0x5477, (q15_t)0x5472, (q15_t)0x546e, (q15_t)0x5469, (q15_t)0x5464, (q15_t)0x545f, (q15_t)0x545b, - (q15_t)0x5456, (q15_t)0x5451, (q15_t)0x544d, (q15_t)0x5448, (q15_t)0x5443, (q15_t)0x543e, (q15_t)0x543a, (q15_t)0x5435, - (q15_t)0x5430, (q15_t)0x542b, (q15_t)0x5427, (q15_t)0x5422, (q15_t)0x541d, (q15_t)0x5418, (q15_t)0x5414, (q15_t)0x540f, - (q15_t)0x540a, (q15_t)0x5406, (q15_t)0x5401, (q15_t)0x53fc, (q15_t)0x53f7, (q15_t)0x53f3, (q15_t)0x53ee, (q15_t)0x53e9, - (q15_t)0x53e4, (q15_t)0x53e0, (q15_t)0x53db, (q15_t)0x53d6, (q15_t)0x53d1, (q15_t)0x53cd, (q15_t)0x53c8, (q15_t)0x53c3, - (q15_t)0x53be, (q15_t)0x53ba, (q15_t)0x53b5, (q15_t)0x53b0, (q15_t)0x53ab, (q15_t)0x53a7, (q15_t)0x53a2, (q15_t)0x539d, - (q15_t)0x5398, (q15_t)0x5394, (q15_t)0x538f, (q15_t)0x538a, (q15_t)0x5385, (q15_t)0x5380, (q15_t)0x537c, (q15_t)0x5377, - (q15_t)0x5372, (q15_t)0x536d, (q15_t)0x5369, (q15_t)0x5364, (q15_t)0x535f, (q15_t)0x535a, (q15_t)0x5356, (q15_t)0x5351, - (q15_t)0x534c, (q15_t)0x5347, (q15_t)0x5343, (q15_t)0x533e, (q15_t)0x5339, (q15_t)0x5334, (q15_t)0x532f, (q15_t)0x532b, - (q15_t)0x5326, (q15_t)0x5321, (q15_t)0x531c, (q15_t)0x5318, (q15_t)0x5313, (q15_t)0x530e, (q15_t)0x5309, (q15_t)0x5304, - (q15_t)0x5300, (q15_t)0x52fb, (q15_t)0x52f6, (q15_t)0x52f1, (q15_t)0x52ec, (q15_t)0x52e8, (q15_t)0x52e3, (q15_t)0x52de, - (q15_t)0x52d9, (q15_t)0x52d5, (q15_t)0x52d0, (q15_t)0x52cb, (q15_t)0x52c6, (q15_t)0x52c1, (q15_t)0x52bd, (q15_t)0x52b8, - (q15_t)0x52b3, (q15_t)0x52ae, (q15_t)0x52a9, (q15_t)0x52a5, (q15_t)0x52a0, (q15_t)0x529b, (q15_t)0x5296, (q15_t)0x5291, - (q15_t)0x528d, (q15_t)0x5288, (q15_t)0x5283, (q15_t)0x527e, (q15_t)0x5279, (q15_t)0x5275, (q15_t)0x5270, (q15_t)0x526b, - (q15_t)0x5266, (q15_t)0x5261, (q15_t)0x525d, (q15_t)0x5258, (q15_t)0x5253, (q15_t)0x524e, (q15_t)0x5249, (q15_t)0x5244, - (q15_t)0x5240, (q15_t)0x523b, (q15_t)0x5236, (q15_t)0x5231, (q15_t)0x522c, (q15_t)0x5228, (q15_t)0x5223, (q15_t)0x521e, - (q15_t)0x5219, (q15_t)0x5214, (q15_t)0x520f, (q15_t)0x520b, (q15_t)0x5206, (q15_t)0x5201, (q15_t)0x51fc, (q15_t)0x51f7, - (q15_t)0x51f3, (q15_t)0x51ee, (q15_t)0x51e9, (q15_t)0x51e4, (q15_t)0x51df, (q15_t)0x51da, (q15_t)0x51d6, (q15_t)0x51d1, - (q15_t)0x51cc, (q15_t)0x51c7, (q15_t)0x51c2, (q15_t)0x51bd, (q15_t)0x51b9, (q15_t)0x51b4, (q15_t)0x51af, (q15_t)0x51aa, - (q15_t)0x51a5, (q15_t)0x51a0, (q15_t)0x519c, (q15_t)0x5197, (q15_t)0x5192, (q15_t)0x518d, (q15_t)0x5188, (q15_t)0x5183, - (q15_t)0x517e, (q15_t)0x517a, (q15_t)0x5175, (q15_t)0x5170, (q15_t)0x516b, (q15_t)0x5166, (q15_t)0x5161, (q15_t)0x515d, - (q15_t)0x5158, (q15_t)0x5153, (q15_t)0x514e, (q15_t)0x5149, (q15_t)0x5144, (q15_t)0x513f, (q15_t)0x513b, (q15_t)0x5136, - (q15_t)0x5131, (q15_t)0x512c, (q15_t)0x5127, (q15_t)0x5122, (q15_t)0x511d, (q15_t)0x5119, (q15_t)0x5114, (q15_t)0x510f, - (q15_t)0x510a, (q15_t)0x5105, (q15_t)0x5100, (q15_t)0x50fb, (q15_t)0x50f7, (q15_t)0x50f2, (q15_t)0x50ed, (q15_t)0x50e8, - (q15_t)0x50e3, (q15_t)0x50de, (q15_t)0x50d9, (q15_t)0x50d4, (q15_t)0x50d0, (q15_t)0x50cb, (q15_t)0x50c6, (q15_t)0x50c1, - (q15_t)0x50bc, (q15_t)0x50b7, (q15_t)0x50b2, (q15_t)0x50ad, (q15_t)0x50a9, (q15_t)0x50a4, (q15_t)0x509f, (q15_t)0x509a, - (q15_t)0x5095, (q15_t)0x5090, (q15_t)0x508b, (q15_t)0x5086, (q15_t)0x5082, (q15_t)0x507d, (q15_t)0x5078, (q15_t)0x5073, - (q15_t)0x506e, (q15_t)0x5069, (q15_t)0x5064, (q15_t)0x505f, (q15_t)0x505a, (q15_t)0x5056, (q15_t)0x5051, (q15_t)0x504c, - (q15_t)0x5047, (q15_t)0x5042, (q15_t)0x503d, (q15_t)0x5038, (q15_t)0x5033, (q15_t)0x502e, (q15_t)0x5029, (q15_t)0x5025, - (q15_t)0x5020, (q15_t)0x501b, (q15_t)0x5016, (q15_t)0x5011, (q15_t)0x500c, (q15_t)0x5007, (q15_t)0x5002, (q15_t)0x4ffd, - (q15_t)0x4ff8, (q15_t)0x4ff4, (q15_t)0x4fef, (q15_t)0x4fea, (q15_t)0x4fe5, (q15_t)0x4fe0, (q15_t)0x4fdb, (q15_t)0x4fd6, - (q15_t)0x4fd1, (q15_t)0x4fcc, (q15_t)0x4fc7, (q15_t)0x4fc2, (q15_t)0x4fbe, (q15_t)0x4fb9, (q15_t)0x4fb4, (q15_t)0x4faf, - (q15_t)0x4faa, (q15_t)0x4fa5, (q15_t)0x4fa0, (q15_t)0x4f9b, (q15_t)0x4f96, (q15_t)0x4f91, (q15_t)0x4f8c, (q15_t)0x4f87, - (q15_t)0x4f82, (q15_t)0x4f7e, (q15_t)0x4f79, (q15_t)0x4f74, (q15_t)0x4f6f, (q15_t)0x4f6a, (q15_t)0x4f65, (q15_t)0x4f60, - (q15_t)0x4f5b, (q15_t)0x4f56, (q15_t)0x4f51, (q15_t)0x4f4c, (q15_t)0x4f47, (q15_t)0x4f42, (q15_t)0x4f3d, (q15_t)0x4f39, - (q15_t)0x4f34, (q15_t)0x4f2f, (q15_t)0x4f2a, (q15_t)0x4f25, (q15_t)0x4f20, (q15_t)0x4f1b, (q15_t)0x4f16, (q15_t)0x4f11, - (q15_t)0x4f0c, (q15_t)0x4f07, (q15_t)0x4f02, (q15_t)0x4efd, (q15_t)0x4ef8, (q15_t)0x4ef3, (q15_t)0x4eee, (q15_t)0x4ee9, - (q15_t)0x4ee5, (q15_t)0x4ee0, (q15_t)0x4edb, (q15_t)0x4ed6, (q15_t)0x4ed1, (q15_t)0x4ecc, (q15_t)0x4ec7, (q15_t)0x4ec2, - (q15_t)0x4ebd, (q15_t)0x4eb8, (q15_t)0x4eb3, (q15_t)0x4eae, (q15_t)0x4ea9, (q15_t)0x4ea4, (q15_t)0x4e9f, (q15_t)0x4e9a, - (q15_t)0x4e95, (q15_t)0x4e90, (q15_t)0x4e8b, (q15_t)0x4e86, (q15_t)0x4e81, (q15_t)0x4e7c, (q15_t)0x4e78, (q15_t)0x4e73, - (q15_t)0x4e6e, (q15_t)0x4e69, (q15_t)0x4e64, (q15_t)0x4e5f, (q15_t)0x4e5a, (q15_t)0x4e55, (q15_t)0x4e50, (q15_t)0x4e4b, - (q15_t)0x4e46, (q15_t)0x4e41, (q15_t)0x4e3c, (q15_t)0x4e37, (q15_t)0x4e32, (q15_t)0x4e2d, (q15_t)0x4e28, (q15_t)0x4e23, - (q15_t)0x4e1e, (q15_t)0x4e19, (q15_t)0x4e14, (q15_t)0x4e0f, (q15_t)0x4e0a, (q15_t)0x4e05, (q15_t)0x4e00, (q15_t)0x4dfb, - (q15_t)0x4df6, (q15_t)0x4df1, (q15_t)0x4dec, (q15_t)0x4de7, (q15_t)0x4de2, (q15_t)0x4ddd, (q15_t)0x4dd8, (q15_t)0x4dd3, - (q15_t)0x4dce, (q15_t)0x4dc9, (q15_t)0x4dc4, (q15_t)0x4dbf, (q15_t)0x4dba, (q15_t)0x4db5, (q15_t)0x4db0, (q15_t)0x4dab, - (q15_t)0x4da6, (q15_t)0x4da1, (q15_t)0x4d9c, (q15_t)0x4d97, (q15_t)0x4d92, (q15_t)0x4d8d, (q15_t)0x4d88, (q15_t)0x4d83, - (q15_t)0x4d7e, (q15_t)0x4d79, (q15_t)0x4d74, (q15_t)0x4d6f, (q15_t)0x4d6a, (q15_t)0x4d65, (q15_t)0x4d60, (q15_t)0x4d5b, - (q15_t)0x4d56, (q15_t)0x4d51, (q15_t)0x4d4c, (q15_t)0x4d47, (q15_t)0x4d42, (q15_t)0x4d3d, (q15_t)0x4d38, (q15_t)0x4d33, - (q15_t)0x4d2e, (q15_t)0x4d29, (q15_t)0x4d24, (q15_t)0x4d1f, (q15_t)0x4d1a, (q15_t)0x4d15, (q15_t)0x4d10, (q15_t)0x4d0b, - (q15_t)0x4d06, (q15_t)0x4d01, (q15_t)0x4cfc, (q15_t)0x4cf7, (q15_t)0x4cf2, (q15_t)0x4ced, (q15_t)0x4ce8, (q15_t)0x4ce3, - (q15_t)0x4cde, (q15_t)0x4cd9, (q15_t)0x4cd4, (q15_t)0x4ccf, (q15_t)0x4cca, (q15_t)0x4cc5, (q15_t)0x4cc0, (q15_t)0x4cbb, - (q15_t)0x4cb6, (q15_t)0x4cb1, (q15_t)0x4cac, (q15_t)0x4ca7, (q15_t)0x4ca2, (q15_t)0x4c9d, (q15_t)0x4c98, (q15_t)0x4c93, - (q15_t)0x4c8e, (q15_t)0x4c88, (q15_t)0x4c83, (q15_t)0x4c7e, (q15_t)0x4c79, (q15_t)0x4c74, (q15_t)0x4c6f, (q15_t)0x4c6a, - (q15_t)0x4c65, (q15_t)0x4c60, (q15_t)0x4c5b, (q15_t)0x4c56, (q15_t)0x4c51, (q15_t)0x4c4c, (q15_t)0x4c47, (q15_t)0x4c42, - (q15_t)0x4c3d, (q15_t)0x4c38, (q15_t)0x4c33, (q15_t)0x4c2e, (q15_t)0x4c29, (q15_t)0x4c24, (q15_t)0x4c1f, (q15_t)0x4c1a, - (q15_t)0x4c14, (q15_t)0x4c0f, (q15_t)0x4c0a, (q15_t)0x4c05, (q15_t)0x4c00, (q15_t)0x4bfb, (q15_t)0x4bf6, (q15_t)0x4bf1, - (q15_t)0x4bec, (q15_t)0x4be7, (q15_t)0x4be2, (q15_t)0x4bdd, (q15_t)0x4bd8, (q15_t)0x4bd3, (q15_t)0x4bce, (q15_t)0x4bc9, - (q15_t)0x4bc4, (q15_t)0x4bbe, (q15_t)0x4bb9, (q15_t)0x4bb4, (q15_t)0x4baf, (q15_t)0x4baa, (q15_t)0x4ba5, (q15_t)0x4ba0, - (q15_t)0x4b9b, (q15_t)0x4b96, (q15_t)0x4b91, (q15_t)0x4b8c, (q15_t)0x4b87, (q15_t)0x4b82, (q15_t)0x4b7d, (q15_t)0x4b77, - (q15_t)0x4b72, (q15_t)0x4b6d, (q15_t)0x4b68, (q15_t)0x4b63, (q15_t)0x4b5e, (q15_t)0x4b59, (q15_t)0x4b54, (q15_t)0x4b4f, - (q15_t)0x4b4a, (q15_t)0x4b45, (q15_t)0x4b40, (q15_t)0x4b3b, (q15_t)0x4b35, (q15_t)0x4b30, (q15_t)0x4b2b, (q15_t)0x4b26, - (q15_t)0x4b21, (q15_t)0x4b1c, (q15_t)0x4b17, (q15_t)0x4b12, (q15_t)0x4b0d, (q15_t)0x4b08, (q15_t)0x4b03, (q15_t)0x4afd, - (q15_t)0x4af8, (q15_t)0x4af3, (q15_t)0x4aee, (q15_t)0x4ae9, (q15_t)0x4ae4, (q15_t)0x4adf, (q15_t)0x4ada, (q15_t)0x4ad5, - (q15_t)0x4ad0, (q15_t)0x4acb, (q15_t)0x4ac5, (q15_t)0x4ac0, (q15_t)0x4abb, (q15_t)0x4ab6, (q15_t)0x4ab1, (q15_t)0x4aac, - (q15_t)0x4aa7, (q15_t)0x4aa2, (q15_t)0x4a9d, (q15_t)0x4a97, (q15_t)0x4a92, (q15_t)0x4a8d, (q15_t)0x4a88, (q15_t)0x4a83, - (q15_t)0x4a7e, (q15_t)0x4a79, (q15_t)0x4a74, (q15_t)0x4a6f, (q15_t)0x4a6a, (q15_t)0x4a64, (q15_t)0x4a5f, (q15_t)0x4a5a, - (q15_t)0x4a55, (q15_t)0x4a50, (q15_t)0x4a4b, (q15_t)0x4a46, (q15_t)0x4a41, (q15_t)0x4a3b, (q15_t)0x4a36, (q15_t)0x4a31, - (q15_t)0x4a2c, (q15_t)0x4a27, (q15_t)0x4a22, (q15_t)0x4a1d, (q15_t)0x4a18, (q15_t)0x4a12, (q15_t)0x4a0d, (q15_t)0x4a08, - (q15_t)0x4a03, (q15_t)0x49fe, (q15_t)0x49f9, (q15_t)0x49f4, (q15_t)0x49ef, (q15_t)0x49e9, (q15_t)0x49e4, (q15_t)0x49df, - (q15_t)0x49da, (q15_t)0x49d5, (q15_t)0x49d0, (q15_t)0x49cb, (q15_t)0x49c6, (q15_t)0x49c0, (q15_t)0x49bb, (q15_t)0x49b6, - (q15_t)0x49b1, (q15_t)0x49ac, (q15_t)0x49a7, (q15_t)0x49a2, (q15_t)0x499c, (q15_t)0x4997, (q15_t)0x4992, (q15_t)0x498d, - (q15_t)0x4988, (q15_t)0x4983, (q15_t)0x497e, (q15_t)0x4978, (q15_t)0x4973, (q15_t)0x496e, (q15_t)0x4969, (q15_t)0x4964, - (q15_t)0x495f, (q15_t)0x495a, (q15_t)0x4954, (q15_t)0x494f, (q15_t)0x494a, (q15_t)0x4945, (q15_t)0x4940, (q15_t)0x493b, - (q15_t)0x4936, (q15_t)0x4930, (q15_t)0x492b, (q15_t)0x4926, (q15_t)0x4921, (q15_t)0x491c, (q15_t)0x4917, (q15_t)0x4911, - (q15_t)0x490c, (q15_t)0x4907, (q15_t)0x4902, (q15_t)0x48fd, (q15_t)0x48f8, (q15_t)0x48f2, (q15_t)0x48ed, (q15_t)0x48e8, - (q15_t)0x48e3, (q15_t)0x48de, (q15_t)0x48d9, (q15_t)0x48d3, (q15_t)0x48ce, (q15_t)0x48c9, (q15_t)0x48c4, (q15_t)0x48bf, - (q15_t)0x48ba, (q15_t)0x48b4, (q15_t)0x48af, (q15_t)0x48aa, (q15_t)0x48a5, (q15_t)0x48a0, (q15_t)0x489b, (q15_t)0x4895, - (q15_t)0x4890, (q15_t)0x488b, (q15_t)0x4886, (q15_t)0x4881, (q15_t)0x487c, (q15_t)0x4876, (q15_t)0x4871, (q15_t)0x486c, - (q15_t)0x4867, (q15_t)0x4862, (q15_t)0x485c, (q15_t)0x4857, (q15_t)0x4852, (q15_t)0x484d, (q15_t)0x4848, (q15_t)0x4843, - (q15_t)0x483d, (q15_t)0x4838, (q15_t)0x4833, (q15_t)0x482e, (q15_t)0x4829, (q15_t)0x4823, (q15_t)0x481e, (q15_t)0x4819, - (q15_t)0x4814, (q15_t)0x480f, (q15_t)0x4809, (q15_t)0x4804, (q15_t)0x47ff, (q15_t)0x47fa, (q15_t)0x47f5, (q15_t)0x47ef, - (q15_t)0x47ea, (q15_t)0x47e5, (q15_t)0x47e0, (q15_t)0x47db, (q15_t)0x47d5, (q15_t)0x47d0, (q15_t)0x47cb, (q15_t)0x47c6, - (q15_t)0x47c1, (q15_t)0x47bb, (q15_t)0x47b6, (q15_t)0x47b1, (q15_t)0x47ac, (q15_t)0x47a7, (q15_t)0x47a1, (q15_t)0x479c, - (q15_t)0x4797, (q15_t)0x4792, (q15_t)0x478d, (q15_t)0x4787, (q15_t)0x4782, (q15_t)0x477d, (q15_t)0x4778, (q15_t)0x4773, - (q15_t)0x476d, (q15_t)0x4768, (q15_t)0x4763, (q15_t)0x475e, (q15_t)0x4758, (q15_t)0x4753, (q15_t)0x474e, (q15_t)0x4749, - (q15_t)0x4744, (q15_t)0x473e, (q15_t)0x4739, (q15_t)0x4734, (q15_t)0x472f, (q15_t)0x4729, (q15_t)0x4724, (q15_t)0x471f, - (q15_t)0x471a, (q15_t)0x4715, (q15_t)0x470f, (q15_t)0x470a, (q15_t)0x4705, (q15_t)0x4700, (q15_t)0x46fa, (q15_t)0x46f5, - (q15_t)0x46f0, (q15_t)0x46eb, (q15_t)0x46e6, (q15_t)0x46e0, (q15_t)0x46db, (q15_t)0x46d6, (q15_t)0x46d1, (q15_t)0x46cb, - (q15_t)0x46c6, (q15_t)0x46c1, (q15_t)0x46bc, (q15_t)0x46b6, (q15_t)0x46b1, (q15_t)0x46ac, (q15_t)0x46a7, (q15_t)0x46a1, - (q15_t)0x469c, (q15_t)0x4697, (q15_t)0x4692, (q15_t)0x468d, (q15_t)0x4687, (q15_t)0x4682, (q15_t)0x467d, (q15_t)0x4678, - (q15_t)0x4672, (q15_t)0x466d, (q15_t)0x4668, (q15_t)0x4663, (q15_t)0x465d, (q15_t)0x4658, (q15_t)0x4653, (q15_t)0x464e, - (q15_t)0x4648, (q15_t)0x4643, (q15_t)0x463e, (q15_t)0x4639, (q15_t)0x4633, (q15_t)0x462e, (q15_t)0x4629, (q15_t)0x4624, - (q15_t)0x461e, (q15_t)0x4619, (q15_t)0x4614, (q15_t)0x460e, (q15_t)0x4609, (q15_t)0x4604, (q15_t)0x45ff, (q15_t)0x45f9, - (q15_t)0x45f4, (q15_t)0x45ef, (q15_t)0x45ea, (q15_t)0x45e4, (q15_t)0x45df, (q15_t)0x45da, (q15_t)0x45d5, (q15_t)0x45cf, - (q15_t)0x45ca, (q15_t)0x45c5, (q15_t)0x45c0, (q15_t)0x45ba, (q15_t)0x45b5, (q15_t)0x45b0, (q15_t)0x45aa, (q15_t)0x45a5, - (q15_t)0x45a0, (q15_t)0x459b, (q15_t)0x4595, (q15_t)0x4590, (q15_t)0x458b, (q15_t)0x4586, (q15_t)0x4580, (q15_t)0x457b, - (q15_t)0x4576, (q15_t)0x4570, (q15_t)0x456b, (q15_t)0x4566, (q15_t)0x4561, (q15_t)0x455b, (q15_t)0x4556, (q15_t)0x4551, - (q15_t)0x454b, (q15_t)0x4546, (q15_t)0x4541, (q15_t)0x453c, (q15_t)0x4536, (q15_t)0x4531, (q15_t)0x452c, (q15_t)0x4526, - (q15_t)0x4521, (q15_t)0x451c, (q15_t)0x4517, (q15_t)0x4511, (q15_t)0x450c, (q15_t)0x4507, (q15_t)0x4501, (q15_t)0x44fc, - (q15_t)0x44f7, (q15_t)0x44f2, (q15_t)0x44ec, (q15_t)0x44e7, (q15_t)0x44e2, (q15_t)0x44dc, (q15_t)0x44d7, (q15_t)0x44d2, - (q15_t)0x44cd, (q15_t)0x44c7, (q15_t)0x44c2, (q15_t)0x44bd, (q15_t)0x44b7, (q15_t)0x44b2, (q15_t)0x44ad, (q15_t)0x44a7, - (q15_t)0x44a2, (q15_t)0x449d, (q15_t)0x4497, (q15_t)0x4492, (q15_t)0x448d, (q15_t)0x4488, (q15_t)0x4482, (q15_t)0x447d, - (q15_t)0x4478, (q15_t)0x4472, (q15_t)0x446d, (q15_t)0x4468, (q15_t)0x4462, (q15_t)0x445d, (q15_t)0x4458, (q15_t)0x4452, - (q15_t)0x444d, (q15_t)0x4448, (q15_t)0x4443, (q15_t)0x443d, (q15_t)0x4438, (q15_t)0x4433, (q15_t)0x442d, (q15_t)0x4428, - (q15_t)0x4423, (q15_t)0x441d, (q15_t)0x4418, (q15_t)0x4413, (q15_t)0x440d, (q15_t)0x4408, (q15_t)0x4403, (q15_t)0x43fd, - (q15_t)0x43f8, (q15_t)0x43f3, (q15_t)0x43ed, (q15_t)0x43e8, (q15_t)0x43e3, (q15_t)0x43dd, (q15_t)0x43d8, (q15_t)0x43d3, - (q15_t)0x43cd, (q15_t)0x43c8, (q15_t)0x43c3, (q15_t)0x43bd, (q15_t)0x43b8, (q15_t)0x43b3, (q15_t)0x43ad, (q15_t)0x43a8, - (q15_t)0x43a3, (q15_t)0x439d, (q15_t)0x4398, (q15_t)0x4393, (q15_t)0x438d, (q15_t)0x4388, (q15_t)0x4383, (q15_t)0x437d, - (q15_t)0x4378, (q15_t)0x4373, (q15_t)0x436d, (q15_t)0x4368, (q15_t)0x4363, (q15_t)0x435d, (q15_t)0x4358, (q15_t)0x4353, - (q15_t)0x434d, (q15_t)0x4348, (q15_t)0x4343, (q15_t)0x433d, (q15_t)0x4338, (q15_t)0x4333, (q15_t)0x432d, (q15_t)0x4328, - (q15_t)0x4323, (q15_t)0x431d, (q15_t)0x4318, (q15_t)0x4313, (q15_t)0x430d, (q15_t)0x4308, (q15_t)0x4302, (q15_t)0x42fd, - (q15_t)0x42f8, (q15_t)0x42f2, (q15_t)0x42ed, (q15_t)0x42e8, (q15_t)0x42e2, (q15_t)0x42dd, (q15_t)0x42d8, (q15_t)0x42d2, - (q15_t)0x42cd, (q15_t)0x42c8, (q15_t)0x42c2, (q15_t)0x42bd, (q15_t)0x42b7, (q15_t)0x42b2, (q15_t)0x42ad, (q15_t)0x42a7, - (q15_t)0x42a2, (q15_t)0x429d, (q15_t)0x4297, (q15_t)0x4292, (q15_t)0x428d, (q15_t)0x4287, (q15_t)0x4282, (q15_t)0x427c, - (q15_t)0x4277, (q15_t)0x4272, (q15_t)0x426c, (q15_t)0x4267, (q15_t)0x4262, (q15_t)0x425c, (q15_t)0x4257, (q15_t)0x4251, - (q15_t)0x424c, (q15_t)0x4247, (q15_t)0x4241, (q15_t)0x423c, (q15_t)0x4237, (q15_t)0x4231, (q15_t)0x422c, (q15_t)0x4226, - (q15_t)0x4221, (q15_t)0x421c, (q15_t)0x4216, (q15_t)0x4211, (q15_t)0x420c, (q15_t)0x4206, (q15_t)0x4201, (q15_t)0x41fb, - (q15_t)0x41f6, (q15_t)0x41f1, (q15_t)0x41eb, (q15_t)0x41e6, (q15_t)0x41e0, (q15_t)0x41db, (q15_t)0x41d6, (q15_t)0x41d0, - (q15_t)0x41cb, (q15_t)0x41c6, (q15_t)0x41c0, (q15_t)0x41bb, (q15_t)0x41b5, (q15_t)0x41b0, (q15_t)0x41ab, (q15_t)0x41a5, - (q15_t)0x41a0, (q15_t)0x419a, (q15_t)0x4195, (q15_t)0x4190, (q15_t)0x418a, (q15_t)0x4185, (q15_t)0x417f, (q15_t)0x417a, - (q15_t)0x4175, (q15_t)0x416f, (q15_t)0x416a, (q15_t)0x4164, (q15_t)0x415f, (q15_t)0x415a, (q15_t)0x4154, (q15_t)0x414f, - (q15_t)0x4149, (q15_t)0x4144, (q15_t)0x413f, (q15_t)0x4139, (q15_t)0x4134, (q15_t)0x412e, (q15_t)0x4129, (q15_t)0x4124, - (q15_t)0x411e, (q15_t)0x4119, (q15_t)0x4113, (q15_t)0x410e, (q15_t)0x4108, (q15_t)0x4103, (q15_t)0x40fe, (q15_t)0x40f8, - (q15_t)0x40f3, (q15_t)0x40ed, (q15_t)0x40e8, (q15_t)0x40e3, (q15_t)0x40dd, (q15_t)0x40d8, (q15_t)0x40d2, (q15_t)0x40cd, - (q15_t)0x40c8, (q15_t)0x40c2, (q15_t)0x40bd, (q15_t)0x40b7, (q15_t)0x40b2, (q15_t)0x40ac, (q15_t)0x40a7, (q15_t)0x40a2, - (q15_t)0x409c, (q15_t)0x4097, (q15_t)0x4091, (q15_t)0x408c, (q15_t)0x4086, (q15_t)0x4081, (q15_t)0x407c, (q15_t)0x4076, - (q15_t)0x4071, (q15_t)0x406b, (q15_t)0x4066, (q15_t)0x4060, (q15_t)0x405b, (q15_t)0x4056, (q15_t)0x4050, (q15_t)0x404b, - (q15_t)0x4045, (q15_t)0x4040, (q15_t)0x403a, (q15_t)0x4035, (q15_t)0x4030, (q15_t)0x402a, (q15_t)0x4025, (q15_t)0x401f, - (q15_t)0x401a, (q15_t)0x4014, (q15_t)0x400f, (q15_t)0x4009, (q15_t)0x4004, (q15_t)0x3fff, (q15_t)0x3ff9, (q15_t)0x3ff4, - (q15_t)0x3fee, (q15_t)0x3fe9, (q15_t)0x3fe3, (q15_t)0x3fde, (q15_t)0x3fd8, (q15_t)0x3fd3, (q15_t)0x3fce, (q15_t)0x3fc8, - (q15_t)0x3fc3, (q15_t)0x3fbd, (q15_t)0x3fb8, (q15_t)0x3fb2, (q15_t)0x3fad, (q15_t)0x3fa7, (q15_t)0x3fa2, (q15_t)0x3f9d, - (q15_t)0x3f97, (q15_t)0x3f92, (q15_t)0x3f8c, (q15_t)0x3f87, (q15_t)0x3f81, (q15_t)0x3f7c, (q15_t)0x3f76, (q15_t)0x3f71, - (q15_t)0x3f6b, (q15_t)0x3f66, (q15_t)0x3f61, (q15_t)0x3f5b, (q15_t)0x3f56, (q15_t)0x3f50, (q15_t)0x3f4b, (q15_t)0x3f45, - (q15_t)0x3f40, (q15_t)0x3f3a, (q15_t)0x3f35, (q15_t)0x3f2f, (q15_t)0x3f2a, (q15_t)0x3f24, (q15_t)0x3f1f, (q15_t)0x3f1a, - (q15_t)0x3f14, (q15_t)0x3f0f, (q15_t)0x3f09, (q15_t)0x3f04, (q15_t)0x3efe, (q15_t)0x3ef9, (q15_t)0x3ef3, (q15_t)0x3eee, - (q15_t)0x3ee8, (q15_t)0x3ee3, (q15_t)0x3edd, (q15_t)0x3ed8, (q15_t)0x3ed2, (q15_t)0x3ecd, (q15_t)0x3ec7, (q15_t)0x3ec2, - (q15_t)0x3ebd, (q15_t)0x3eb7, (q15_t)0x3eb2, (q15_t)0x3eac, (q15_t)0x3ea7, (q15_t)0x3ea1, (q15_t)0x3e9c, (q15_t)0x3e96, - (q15_t)0x3e91, (q15_t)0x3e8b, (q15_t)0x3e86, (q15_t)0x3e80, (q15_t)0x3e7b, (q15_t)0x3e75, (q15_t)0x3e70, (q15_t)0x3e6a, - (q15_t)0x3e65, (q15_t)0x3e5f, (q15_t)0x3e5a, (q15_t)0x3e54, (q15_t)0x3e4f, (q15_t)0x3e49, (q15_t)0x3e44, (q15_t)0x3e3e, - (q15_t)0x3e39, (q15_t)0x3e33, (q15_t)0x3e2e, (q15_t)0x3e28, (q15_t)0x3e23, (q15_t)0x3e1d, (q15_t)0x3e18, (q15_t)0x3e12, - (q15_t)0x3e0d, (q15_t)0x3e07, (q15_t)0x3e02, (q15_t)0x3dfc, (q15_t)0x3df7, (q15_t)0x3df1, (q15_t)0x3dec, (q15_t)0x3de6, - (q15_t)0x3de1, (q15_t)0x3ddb, (q15_t)0x3dd6, (q15_t)0x3dd0, (q15_t)0x3dcb, (q15_t)0x3dc5, (q15_t)0x3dc0, (q15_t)0x3dba, - (q15_t)0x3db5, (q15_t)0x3daf, (q15_t)0x3daa, (q15_t)0x3da4, (q15_t)0x3d9f, (q15_t)0x3d99, (q15_t)0x3d94, (q15_t)0x3d8e, - (q15_t)0x3d89, (q15_t)0x3d83, (q15_t)0x3d7e, (q15_t)0x3d78, (q15_t)0x3d73, (q15_t)0x3d6d, (q15_t)0x3d68, (q15_t)0x3d62, - (q15_t)0x3d5d, (q15_t)0x3d57, (q15_t)0x3d52, (q15_t)0x3d4c, (q15_t)0x3d47, (q15_t)0x3d41, (q15_t)0x3d3c, (q15_t)0x3d36, - (q15_t)0x3d31, (q15_t)0x3d2b, (q15_t)0x3d26, (q15_t)0x3d20, (q15_t)0x3d1b, (q15_t)0x3d15, (q15_t)0x3d10, (q15_t)0x3d0a, - (q15_t)0x3d04, (q15_t)0x3cff, (q15_t)0x3cf9, (q15_t)0x3cf4, (q15_t)0x3cee, (q15_t)0x3ce9, (q15_t)0x3ce3, (q15_t)0x3cde, - (q15_t)0x3cd8, (q15_t)0x3cd3, (q15_t)0x3ccd, (q15_t)0x3cc8, (q15_t)0x3cc2, (q15_t)0x3cbd, (q15_t)0x3cb7, (q15_t)0x3cb2, - (q15_t)0x3cac, (q15_t)0x3ca7, (q15_t)0x3ca1, (q15_t)0x3c9b, (q15_t)0x3c96, (q15_t)0x3c90, (q15_t)0x3c8b, (q15_t)0x3c85, - (q15_t)0x3c80, (q15_t)0x3c7a, (q15_t)0x3c75, (q15_t)0x3c6f, (q15_t)0x3c6a, (q15_t)0x3c64, (q15_t)0x3c5f, (q15_t)0x3c59, - (q15_t)0x3c53, (q15_t)0x3c4e, (q15_t)0x3c48, (q15_t)0x3c43, (q15_t)0x3c3d, (q15_t)0x3c38, (q15_t)0x3c32, (q15_t)0x3c2d, - (q15_t)0x3c27, (q15_t)0x3c22, (q15_t)0x3c1c, (q15_t)0x3c16, (q15_t)0x3c11, (q15_t)0x3c0b, (q15_t)0x3c06, (q15_t)0x3c00, - (q15_t)0x3bfb, (q15_t)0x3bf5, (q15_t)0x3bf0, (q15_t)0x3bea, (q15_t)0x3be5, (q15_t)0x3bdf, (q15_t)0x3bd9, (q15_t)0x3bd4, - (q15_t)0x3bce, (q15_t)0x3bc9, (q15_t)0x3bc3, (q15_t)0x3bbe, (q15_t)0x3bb8, (q15_t)0x3bb3, (q15_t)0x3bad, (q15_t)0x3ba7, - (q15_t)0x3ba2, (q15_t)0x3b9c, (q15_t)0x3b97, (q15_t)0x3b91, (q15_t)0x3b8c, (q15_t)0x3b86, (q15_t)0x3b80, (q15_t)0x3b7b, - (q15_t)0x3b75, (q15_t)0x3b70, (q15_t)0x3b6a, (q15_t)0x3b65, (q15_t)0x3b5f, (q15_t)0x3b5a, (q15_t)0x3b54, (q15_t)0x3b4e, - (q15_t)0x3b49, (q15_t)0x3b43, (q15_t)0x3b3e, (q15_t)0x3b38, (q15_t)0x3b33, (q15_t)0x3b2d, (q15_t)0x3b27, (q15_t)0x3b22, - (q15_t)0x3b1c, (q15_t)0x3b17, (q15_t)0x3b11, (q15_t)0x3b0c, (q15_t)0x3b06, (q15_t)0x3b00, (q15_t)0x3afb, (q15_t)0x3af5, - (q15_t)0x3af0, (q15_t)0x3aea, (q15_t)0x3ae4, (q15_t)0x3adf, (q15_t)0x3ad9, (q15_t)0x3ad4, (q15_t)0x3ace, (q15_t)0x3ac9, - (q15_t)0x3ac3, (q15_t)0x3abd, (q15_t)0x3ab8, (q15_t)0x3ab2, (q15_t)0x3aad, (q15_t)0x3aa7, (q15_t)0x3aa2, (q15_t)0x3a9c, - (q15_t)0x3a96, (q15_t)0x3a91, (q15_t)0x3a8b, (q15_t)0x3a86, (q15_t)0x3a80, (q15_t)0x3a7a, (q15_t)0x3a75, (q15_t)0x3a6f, - (q15_t)0x3a6a, (q15_t)0x3a64, (q15_t)0x3a5e, (q15_t)0x3a59, (q15_t)0x3a53, (q15_t)0x3a4e, (q15_t)0x3a48, (q15_t)0x3a42, - (q15_t)0x3a3d, (q15_t)0x3a37, (q15_t)0x3a32, (q15_t)0x3a2c, (q15_t)0x3a26, (q15_t)0x3a21, (q15_t)0x3a1b, (q15_t)0x3a16, - (q15_t)0x3a10, (q15_t)0x3a0b, (q15_t)0x3a05, (q15_t)0x39ff, (q15_t)0x39fa, (q15_t)0x39f4, (q15_t)0x39ee, (q15_t)0x39e9, - (q15_t)0x39e3, (q15_t)0x39de, (q15_t)0x39d8, (q15_t)0x39d2, (q15_t)0x39cd, (q15_t)0x39c7, (q15_t)0x39c2, (q15_t)0x39bc, - (q15_t)0x39b6, (q15_t)0x39b1, (q15_t)0x39ab, (q15_t)0x39a6, (q15_t)0x39a0, (q15_t)0x399a, (q15_t)0x3995, (q15_t)0x398f, - (q15_t)0x398a, (q15_t)0x3984, (q15_t)0x397e, (q15_t)0x3979, (q15_t)0x3973, (q15_t)0x396d, (q15_t)0x3968, (q15_t)0x3962, - (q15_t)0x395d, (q15_t)0x3957, (q15_t)0x3951, (q15_t)0x394c, (q15_t)0x3946, (q15_t)0x3941, (q15_t)0x393b, (q15_t)0x3935, - (q15_t)0x3930, (q15_t)0x392a, (q15_t)0x3924, (q15_t)0x391f, (q15_t)0x3919, (q15_t)0x3914, (q15_t)0x390e, (q15_t)0x3908, - (q15_t)0x3903, (q15_t)0x38fd, (q15_t)0x38f7, (q15_t)0x38f2, (q15_t)0x38ec, (q15_t)0x38e7, (q15_t)0x38e1, (q15_t)0x38db, - (q15_t)0x38d6, (q15_t)0x38d0, (q15_t)0x38ca, (q15_t)0x38c5, (q15_t)0x38bf, (q15_t)0x38ba, (q15_t)0x38b4, (q15_t)0x38ae, - (q15_t)0x38a9, (q15_t)0x38a3, (q15_t)0x389d, (q15_t)0x3898, (q15_t)0x3892, (q15_t)0x388c, (q15_t)0x3887, (q15_t)0x3881, - (q15_t)0x387c, (q15_t)0x3876, (q15_t)0x3870, (q15_t)0x386b, (q15_t)0x3865, (q15_t)0x385f, (q15_t)0x385a, (q15_t)0x3854, - (q15_t)0x384e, (q15_t)0x3849, (q15_t)0x3843, (q15_t)0x383d, (q15_t)0x3838, (q15_t)0x3832, (q15_t)0x382d, (q15_t)0x3827, - (q15_t)0x3821, (q15_t)0x381c, (q15_t)0x3816, (q15_t)0x3810, (q15_t)0x380b, (q15_t)0x3805, (q15_t)0x37ff, (q15_t)0x37fa, - (q15_t)0x37f4, (q15_t)0x37ee, (q15_t)0x37e9, (q15_t)0x37e3, (q15_t)0x37dd, (q15_t)0x37d8, (q15_t)0x37d2, (q15_t)0x37cc, - (q15_t)0x37c7, (q15_t)0x37c1, (q15_t)0x37bc, (q15_t)0x37b6, (q15_t)0x37b0, (q15_t)0x37ab, (q15_t)0x37a5, (q15_t)0x379f, - (q15_t)0x379a, (q15_t)0x3794, (q15_t)0x378e, (q15_t)0x3789, (q15_t)0x3783, (q15_t)0x377d, (q15_t)0x3778, (q15_t)0x3772, - (q15_t)0x376c, (q15_t)0x3767, (q15_t)0x3761, (q15_t)0x375b, (q15_t)0x3756, (q15_t)0x3750, (q15_t)0x374a, (q15_t)0x3745, - (q15_t)0x373f, (q15_t)0x3739, (q15_t)0x3734, (q15_t)0x372e, (q15_t)0x3728, (q15_t)0x3723, (q15_t)0x371d, (q15_t)0x3717, - (q15_t)0x3712, (q15_t)0x370c, (q15_t)0x3706, (q15_t)0x3701, (q15_t)0x36fb, (q15_t)0x36f5, (q15_t)0x36f0, (q15_t)0x36ea, - (q15_t)0x36e4, (q15_t)0x36df, (q15_t)0x36d9, (q15_t)0x36d3, (q15_t)0x36ce, (q15_t)0x36c8, (q15_t)0x36c2, (q15_t)0x36bc, - (q15_t)0x36b7, (q15_t)0x36b1, (q15_t)0x36ab, (q15_t)0x36a6, (q15_t)0x36a0, (q15_t)0x369a, (q15_t)0x3695, (q15_t)0x368f, - (q15_t)0x3689, (q15_t)0x3684, (q15_t)0x367e, (q15_t)0x3678, (q15_t)0x3673, (q15_t)0x366d, (q15_t)0x3667, (q15_t)0x3662, - (q15_t)0x365c, (q15_t)0x3656, (q15_t)0x3650, (q15_t)0x364b, (q15_t)0x3645, (q15_t)0x363f, (q15_t)0x363a, (q15_t)0x3634, - (q15_t)0x362e, (q15_t)0x3629, (q15_t)0x3623, (q15_t)0x361d, (q15_t)0x3618, (q15_t)0x3612, (q15_t)0x360c, (q15_t)0x3606, - (q15_t)0x3601, (q15_t)0x35fb, (q15_t)0x35f5, (q15_t)0x35f0, (q15_t)0x35ea, (q15_t)0x35e4, (q15_t)0x35df, (q15_t)0x35d9, - (q15_t)0x35d3, (q15_t)0x35cd, (q15_t)0x35c8, (q15_t)0x35c2, (q15_t)0x35bc, (q15_t)0x35b7, (q15_t)0x35b1, (q15_t)0x35ab, - (q15_t)0x35a6, (q15_t)0x35a0, (q15_t)0x359a, (q15_t)0x3594, (q15_t)0x358f, (q15_t)0x3589, (q15_t)0x3583, (q15_t)0x357e, - (q15_t)0x3578, (q15_t)0x3572, (q15_t)0x356c, (q15_t)0x3567, (q15_t)0x3561, (q15_t)0x355b, (q15_t)0x3556, (q15_t)0x3550, - (q15_t)0x354a, (q15_t)0x3544, (q15_t)0x353f, (q15_t)0x3539, (q15_t)0x3533, (q15_t)0x352e, (q15_t)0x3528, (q15_t)0x3522, - (q15_t)0x351c, (q15_t)0x3517, (q15_t)0x3511, (q15_t)0x350b, (q15_t)0x3506, (q15_t)0x3500, (q15_t)0x34fa, (q15_t)0x34f4, - (q15_t)0x34ef, (q15_t)0x34e9, (q15_t)0x34e3, (q15_t)0x34de, (q15_t)0x34d8, (q15_t)0x34d2, (q15_t)0x34cc, (q15_t)0x34c7, - (q15_t)0x34c1, (q15_t)0x34bb, (q15_t)0x34b6, (q15_t)0x34b0, (q15_t)0x34aa, (q15_t)0x34a4, (q15_t)0x349f, (q15_t)0x3499, - (q15_t)0x3493, (q15_t)0x348d, (q15_t)0x3488, (q15_t)0x3482, (q15_t)0x347c, (q15_t)0x3476, (q15_t)0x3471, (q15_t)0x346b, - (q15_t)0x3465, (q15_t)0x3460, (q15_t)0x345a, (q15_t)0x3454, (q15_t)0x344e, (q15_t)0x3449, (q15_t)0x3443, (q15_t)0x343d, - (q15_t)0x3437, (q15_t)0x3432, (q15_t)0x342c, (q15_t)0x3426, (q15_t)0x3420, (q15_t)0x341b, (q15_t)0x3415, (q15_t)0x340f, - (q15_t)0x340a, (q15_t)0x3404, (q15_t)0x33fe, (q15_t)0x33f8, (q15_t)0x33f3, (q15_t)0x33ed, (q15_t)0x33e7, (q15_t)0x33e1, - (q15_t)0x33dc, (q15_t)0x33d6, (q15_t)0x33d0, (q15_t)0x33ca, (q15_t)0x33c5, (q15_t)0x33bf, (q15_t)0x33b9, (q15_t)0x33b3, - (q15_t)0x33ae, (q15_t)0x33a8, (q15_t)0x33a2, (q15_t)0x339c, (q15_t)0x3397, (q15_t)0x3391, (q15_t)0x338b, (q15_t)0x3385, - (q15_t)0x3380, (q15_t)0x337a, (q15_t)0x3374, (q15_t)0x336e, (q15_t)0x3369, (q15_t)0x3363, (q15_t)0x335d, (q15_t)0x3357, - (q15_t)0x3352, (q15_t)0x334c, (q15_t)0x3346, (q15_t)0x3340, (q15_t)0x333b, (q15_t)0x3335, (q15_t)0x332f, (q15_t)0x3329, - (q15_t)0x3324, (q15_t)0x331e, (q15_t)0x3318, (q15_t)0x3312, (q15_t)0x330c, (q15_t)0x3307, (q15_t)0x3301, (q15_t)0x32fb, - (q15_t)0x32f5, (q15_t)0x32f0, (q15_t)0x32ea, (q15_t)0x32e4, (q15_t)0x32de, (q15_t)0x32d9, (q15_t)0x32d3, (q15_t)0x32cd, - (q15_t)0x32c7, (q15_t)0x32c2, (q15_t)0x32bc, (q15_t)0x32b6, (q15_t)0x32b0, (q15_t)0x32aa, (q15_t)0x32a5, (q15_t)0x329f, - (q15_t)0x3299, (q15_t)0x3293, (q15_t)0x328e, (q15_t)0x3288, (q15_t)0x3282, (q15_t)0x327c, (q15_t)0x3276, (q15_t)0x3271, - (q15_t)0x326b, (q15_t)0x3265, (q15_t)0x325f, (q15_t)0x325a, (q15_t)0x3254, (q15_t)0x324e, (q15_t)0x3248, (q15_t)0x3243, - (q15_t)0x323d, (q15_t)0x3237, (q15_t)0x3231, (q15_t)0x322b, (q15_t)0x3226, (q15_t)0x3220, (q15_t)0x321a, (q15_t)0x3214, - (q15_t)0x320e, (q15_t)0x3209, (q15_t)0x3203, (q15_t)0x31fd, (q15_t)0x31f7, (q15_t)0x31f2, (q15_t)0x31ec, (q15_t)0x31e6, - (q15_t)0x31e0, (q15_t)0x31da, (q15_t)0x31d5, (q15_t)0x31cf, (q15_t)0x31c9, (q15_t)0x31c3, (q15_t)0x31bd, (q15_t)0x31b8, - (q15_t)0x31b2, (q15_t)0x31ac, (q15_t)0x31a6, (q15_t)0x31a1, (q15_t)0x319b, (q15_t)0x3195, (q15_t)0x318f, (q15_t)0x3189, - (q15_t)0x3184, (q15_t)0x317e, (q15_t)0x3178, (q15_t)0x3172, (q15_t)0x316c, (q15_t)0x3167, (q15_t)0x3161, (q15_t)0x315b, - (q15_t)0x3155, (q15_t)0x314f, (q15_t)0x314a, (q15_t)0x3144, (q15_t)0x313e, (q15_t)0x3138, (q15_t)0x3132, (q15_t)0x312d, - (q15_t)0x3127, (q15_t)0x3121, (q15_t)0x311b, (q15_t)0x3115, (q15_t)0x3110, (q15_t)0x310a, (q15_t)0x3104, (q15_t)0x30fe, - (q15_t)0x30f8, (q15_t)0x30f3, (q15_t)0x30ed, (q15_t)0x30e7, (q15_t)0x30e1, (q15_t)0x30db, (q15_t)0x30d6, (q15_t)0x30d0, - (q15_t)0x30ca, (q15_t)0x30c4, (q15_t)0x30be, (q15_t)0x30b8, (q15_t)0x30b3, (q15_t)0x30ad, (q15_t)0x30a7, (q15_t)0x30a1, - (q15_t)0x309b, (q15_t)0x3096, (q15_t)0x3090, (q15_t)0x308a, (q15_t)0x3084, (q15_t)0x307e, (q15_t)0x3079, (q15_t)0x3073, - (q15_t)0x306d, (q15_t)0x3067, (q15_t)0x3061, (q15_t)0x305b, (q15_t)0x3056, (q15_t)0x3050, (q15_t)0x304a, (q15_t)0x3044, - (q15_t)0x303e, (q15_t)0x3039, (q15_t)0x3033, (q15_t)0x302d, (q15_t)0x3027, (q15_t)0x3021, (q15_t)0x301b, (q15_t)0x3016, - (q15_t)0x3010, (q15_t)0x300a, (q15_t)0x3004, (q15_t)0x2ffe, (q15_t)0x2ff8, (q15_t)0x2ff3, (q15_t)0x2fed, (q15_t)0x2fe7, - (q15_t)0x2fe1, (q15_t)0x2fdb, (q15_t)0x2fd6, (q15_t)0x2fd0, (q15_t)0x2fca, (q15_t)0x2fc4, (q15_t)0x2fbe, (q15_t)0x2fb8, - (q15_t)0x2fb3, (q15_t)0x2fad, (q15_t)0x2fa7, (q15_t)0x2fa1, (q15_t)0x2f9b, (q15_t)0x2f95, (q15_t)0x2f90, (q15_t)0x2f8a, - (q15_t)0x2f84, (q15_t)0x2f7e, (q15_t)0x2f78, (q15_t)0x2f72, (q15_t)0x2f6d, (q15_t)0x2f67, (q15_t)0x2f61, (q15_t)0x2f5b, - (q15_t)0x2f55, (q15_t)0x2f4f, (q15_t)0x2f4a, (q15_t)0x2f44, (q15_t)0x2f3e, (q15_t)0x2f38, (q15_t)0x2f32, (q15_t)0x2f2c, - (q15_t)0x2f27, (q15_t)0x2f21, (q15_t)0x2f1b, (q15_t)0x2f15, (q15_t)0x2f0f, (q15_t)0x2f09, (q15_t)0x2f03, (q15_t)0x2efe, - (q15_t)0x2ef8, (q15_t)0x2ef2, (q15_t)0x2eec, (q15_t)0x2ee6, (q15_t)0x2ee0, (q15_t)0x2edb, (q15_t)0x2ed5, (q15_t)0x2ecf, - (q15_t)0x2ec9, (q15_t)0x2ec3, (q15_t)0x2ebd, (q15_t)0x2eb7, (q15_t)0x2eb2, (q15_t)0x2eac, (q15_t)0x2ea6, (q15_t)0x2ea0, - (q15_t)0x2e9a, (q15_t)0x2e94, (q15_t)0x2e8e, (q15_t)0x2e89, (q15_t)0x2e83, (q15_t)0x2e7d, (q15_t)0x2e77, (q15_t)0x2e71, - (q15_t)0x2e6b, (q15_t)0x2e65, (q15_t)0x2e60, (q15_t)0x2e5a, (q15_t)0x2e54, (q15_t)0x2e4e, (q15_t)0x2e48, (q15_t)0x2e42, - (q15_t)0x2e3c, (q15_t)0x2e37, (q15_t)0x2e31, (q15_t)0x2e2b, (q15_t)0x2e25, (q15_t)0x2e1f, (q15_t)0x2e19, (q15_t)0x2e13, - (q15_t)0x2e0e, (q15_t)0x2e08, (q15_t)0x2e02, (q15_t)0x2dfc, (q15_t)0x2df6, (q15_t)0x2df0, (q15_t)0x2dea, (q15_t)0x2de5, - (q15_t)0x2ddf, (q15_t)0x2dd9, (q15_t)0x2dd3, (q15_t)0x2dcd, (q15_t)0x2dc7, (q15_t)0x2dc1, (q15_t)0x2dbb, (q15_t)0x2db6, - (q15_t)0x2db0, (q15_t)0x2daa, (q15_t)0x2da4, (q15_t)0x2d9e, (q15_t)0x2d98, (q15_t)0x2d92, (q15_t)0x2d8d, (q15_t)0x2d87, - (q15_t)0x2d81, (q15_t)0x2d7b, (q15_t)0x2d75, (q15_t)0x2d6f, (q15_t)0x2d69, (q15_t)0x2d63, (q15_t)0x2d5e, (q15_t)0x2d58, - (q15_t)0x2d52, (q15_t)0x2d4c, (q15_t)0x2d46, (q15_t)0x2d40, (q15_t)0x2d3a, (q15_t)0x2d34, (q15_t)0x2d2f, (q15_t)0x2d29, - (q15_t)0x2d23, (q15_t)0x2d1d, (q15_t)0x2d17, (q15_t)0x2d11, (q15_t)0x2d0b, (q15_t)0x2d05, (q15_t)0x2cff, (q15_t)0x2cfa, - (q15_t)0x2cf4, (q15_t)0x2cee, (q15_t)0x2ce8, (q15_t)0x2ce2, (q15_t)0x2cdc, (q15_t)0x2cd6, (q15_t)0x2cd0, (q15_t)0x2ccb, - (q15_t)0x2cc5, (q15_t)0x2cbf, (q15_t)0x2cb9, (q15_t)0x2cb3, (q15_t)0x2cad, (q15_t)0x2ca7, (q15_t)0x2ca1, (q15_t)0x2c9b, - (q15_t)0x2c96, (q15_t)0x2c90, (q15_t)0x2c8a, (q15_t)0x2c84, (q15_t)0x2c7e, (q15_t)0x2c78, (q15_t)0x2c72, (q15_t)0x2c6c, - (q15_t)0x2c66, (q15_t)0x2c61, (q15_t)0x2c5b, (q15_t)0x2c55, (q15_t)0x2c4f, (q15_t)0x2c49, (q15_t)0x2c43, (q15_t)0x2c3d, - (q15_t)0x2c37, (q15_t)0x2c31, (q15_t)0x2c2b, (q15_t)0x2c26, (q15_t)0x2c20, (q15_t)0x2c1a, (q15_t)0x2c14, (q15_t)0x2c0e, - (q15_t)0x2c08, (q15_t)0x2c02, (q15_t)0x2bfc, (q15_t)0x2bf6, (q15_t)0x2bf0, (q15_t)0x2beb, (q15_t)0x2be5, (q15_t)0x2bdf, - (q15_t)0x2bd9, (q15_t)0x2bd3, (q15_t)0x2bcd, (q15_t)0x2bc7, (q15_t)0x2bc1, (q15_t)0x2bbb, (q15_t)0x2bb5, (q15_t)0x2bb0, - (q15_t)0x2baa, (q15_t)0x2ba4, (q15_t)0x2b9e, (q15_t)0x2b98, (q15_t)0x2b92, (q15_t)0x2b8c, (q15_t)0x2b86, (q15_t)0x2b80, - (q15_t)0x2b7a, (q15_t)0x2b74, (q15_t)0x2b6f, (q15_t)0x2b69, (q15_t)0x2b63, (q15_t)0x2b5d, (q15_t)0x2b57, (q15_t)0x2b51, - (q15_t)0x2b4b, (q15_t)0x2b45, (q15_t)0x2b3f, (q15_t)0x2b39, (q15_t)0x2b33, (q15_t)0x2b2d, (q15_t)0x2b28, (q15_t)0x2b22, - (q15_t)0x2b1c, (q15_t)0x2b16, (q15_t)0x2b10, (q15_t)0x2b0a, (q15_t)0x2b04, (q15_t)0x2afe, (q15_t)0x2af8, (q15_t)0x2af2, - (q15_t)0x2aec, (q15_t)0x2ae6, (q15_t)0x2ae1, (q15_t)0x2adb, (q15_t)0x2ad5, (q15_t)0x2acf, (q15_t)0x2ac9, (q15_t)0x2ac3, - (q15_t)0x2abd, (q15_t)0x2ab7, (q15_t)0x2ab1, (q15_t)0x2aab, (q15_t)0x2aa5, (q15_t)0x2a9f, (q15_t)0x2a99, (q15_t)0x2a94, - (q15_t)0x2a8e, (q15_t)0x2a88, (q15_t)0x2a82, (q15_t)0x2a7c, (q15_t)0x2a76, (q15_t)0x2a70, (q15_t)0x2a6a, (q15_t)0x2a64, - (q15_t)0x2a5e, (q15_t)0x2a58, (q15_t)0x2a52, (q15_t)0x2a4c, (q15_t)0x2a47, (q15_t)0x2a41, (q15_t)0x2a3b, (q15_t)0x2a35, - (q15_t)0x2a2f, (q15_t)0x2a29, (q15_t)0x2a23, (q15_t)0x2a1d, (q15_t)0x2a17, (q15_t)0x2a11, (q15_t)0x2a0b, (q15_t)0x2a05, - (q15_t)0x29ff, (q15_t)0x29f9, (q15_t)0x29f3, (q15_t)0x29ee, (q15_t)0x29e8, (q15_t)0x29e2, (q15_t)0x29dc, (q15_t)0x29d6, - (q15_t)0x29d0, (q15_t)0x29ca, (q15_t)0x29c4, (q15_t)0x29be, (q15_t)0x29b8, (q15_t)0x29b2, (q15_t)0x29ac, (q15_t)0x29a6, - (q15_t)0x29a0, (q15_t)0x299a, (q15_t)0x2994, (q15_t)0x298e, (q15_t)0x2989, (q15_t)0x2983, (q15_t)0x297d, (q15_t)0x2977, - (q15_t)0x2971, (q15_t)0x296b, (q15_t)0x2965, (q15_t)0x295f, (q15_t)0x2959, (q15_t)0x2953, (q15_t)0x294d, (q15_t)0x2947, - (q15_t)0x2941, (q15_t)0x293b, (q15_t)0x2935, (q15_t)0x292f, (q15_t)0x2929, (q15_t)0x2923, (q15_t)0x291d, (q15_t)0x2918, - (q15_t)0x2912, (q15_t)0x290c, (q15_t)0x2906, (q15_t)0x2900, (q15_t)0x28fa, (q15_t)0x28f4, (q15_t)0x28ee, (q15_t)0x28e8, - (q15_t)0x28e2, (q15_t)0x28dc, (q15_t)0x28d6, (q15_t)0x28d0, (q15_t)0x28ca, (q15_t)0x28c4, (q15_t)0x28be, (q15_t)0x28b8, - (q15_t)0x28b2, (q15_t)0x28ac, (q15_t)0x28a6, (q15_t)0x28a0, (q15_t)0x289a, (q15_t)0x2895, (q15_t)0x288f, (q15_t)0x2889, - (q15_t)0x2883, (q15_t)0x287d, (q15_t)0x2877, (q15_t)0x2871, (q15_t)0x286b, (q15_t)0x2865, (q15_t)0x285f, (q15_t)0x2859, - (q15_t)0x2853, (q15_t)0x284d, (q15_t)0x2847, (q15_t)0x2841, (q15_t)0x283b, (q15_t)0x2835, (q15_t)0x282f, (q15_t)0x2829, - (q15_t)0x2823, (q15_t)0x281d, (q15_t)0x2817, (q15_t)0x2811, (q15_t)0x280b, (q15_t)0x2805, (q15_t)0x27ff, (q15_t)0x27f9, - (q15_t)0x27f3, (q15_t)0x27ee, (q15_t)0x27e8, (q15_t)0x27e2, (q15_t)0x27dc, (q15_t)0x27d6, (q15_t)0x27d0, (q15_t)0x27ca, - (q15_t)0x27c4, (q15_t)0x27be, (q15_t)0x27b8, (q15_t)0x27b2, (q15_t)0x27ac, (q15_t)0x27a6, (q15_t)0x27a0, (q15_t)0x279a, - (q15_t)0x2794, (q15_t)0x278e, (q15_t)0x2788, (q15_t)0x2782, (q15_t)0x277c, (q15_t)0x2776, (q15_t)0x2770, (q15_t)0x276a, - (q15_t)0x2764, (q15_t)0x275e, (q15_t)0x2758, (q15_t)0x2752, (q15_t)0x274c, (q15_t)0x2746, (q15_t)0x2740, (q15_t)0x273a, - (q15_t)0x2734, (q15_t)0x272e, (q15_t)0x2728, (q15_t)0x2722, (q15_t)0x271c, (q15_t)0x2716, (q15_t)0x2710, (q15_t)0x270a, - (q15_t)0x2704, (q15_t)0x26fe, (q15_t)0x26f8, (q15_t)0x26f2, (q15_t)0x26ec, (q15_t)0x26e7, (q15_t)0x26e1, (q15_t)0x26db, - (q15_t)0x26d5, (q15_t)0x26cf, (q15_t)0x26c9, (q15_t)0x26c3, (q15_t)0x26bd, (q15_t)0x26b7, (q15_t)0x26b1, (q15_t)0x26ab, - (q15_t)0x26a5, (q15_t)0x269f, (q15_t)0x2699, (q15_t)0x2693, (q15_t)0x268d, (q15_t)0x2687, (q15_t)0x2681, (q15_t)0x267b, - (q15_t)0x2675, (q15_t)0x266f, (q15_t)0x2669, (q15_t)0x2663, (q15_t)0x265d, (q15_t)0x2657, (q15_t)0x2651, (q15_t)0x264b, - (q15_t)0x2645, (q15_t)0x263f, (q15_t)0x2639, (q15_t)0x2633, (q15_t)0x262d, (q15_t)0x2627, (q15_t)0x2621, (q15_t)0x261b, - (q15_t)0x2615, (q15_t)0x260f, (q15_t)0x2609, (q15_t)0x2603, (q15_t)0x25fd, (q15_t)0x25f7, (q15_t)0x25f1, (q15_t)0x25eb, - (q15_t)0x25e5, (q15_t)0x25df, (q15_t)0x25d9, (q15_t)0x25d3, (q15_t)0x25cd, (q15_t)0x25c7, (q15_t)0x25c1, (q15_t)0x25bb, - (q15_t)0x25b5, (q15_t)0x25af, (q15_t)0x25a9, (q15_t)0x25a3, (q15_t)0x259d, (q15_t)0x2597, (q15_t)0x2591, (q15_t)0x258b, - (q15_t)0x2585, (q15_t)0x257f, (q15_t)0x2579, (q15_t)0x2573, (q15_t)0x256d, (q15_t)0x2567, (q15_t)0x2561, (q15_t)0x255b, - (q15_t)0x2555, (q15_t)0x254f, (q15_t)0x2549, (q15_t)0x2543, (q15_t)0x253d, (q15_t)0x2537, (q15_t)0x2531, (q15_t)0x252b, - (q15_t)0x2525, (q15_t)0x251f, (q15_t)0x2519, (q15_t)0x2513, (q15_t)0x250c, (q15_t)0x2506, (q15_t)0x2500, (q15_t)0x24fa, - (q15_t)0x24f4, (q15_t)0x24ee, (q15_t)0x24e8, (q15_t)0x24e2, (q15_t)0x24dc, (q15_t)0x24d6, (q15_t)0x24d0, (q15_t)0x24ca, - (q15_t)0x24c4, (q15_t)0x24be, (q15_t)0x24b8, (q15_t)0x24b2, (q15_t)0x24ac, (q15_t)0x24a6, (q15_t)0x24a0, (q15_t)0x249a, - (q15_t)0x2494, (q15_t)0x248e, (q15_t)0x2488, (q15_t)0x2482, (q15_t)0x247c, (q15_t)0x2476, (q15_t)0x2470, (q15_t)0x246a, - (q15_t)0x2464, (q15_t)0x245e, (q15_t)0x2458, (q15_t)0x2452, (q15_t)0x244c, (q15_t)0x2446, (q15_t)0x2440, (q15_t)0x243a, - (q15_t)0x2434, (q15_t)0x242e, (q15_t)0x2428, (q15_t)0x2422, (q15_t)0x241c, (q15_t)0x2416, (q15_t)0x2410, (q15_t)0x240a, - (q15_t)0x2404, (q15_t)0x23fd, (q15_t)0x23f7, (q15_t)0x23f1, (q15_t)0x23eb, (q15_t)0x23e5, (q15_t)0x23df, (q15_t)0x23d9, - (q15_t)0x23d3, (q15_t)0x23cd, (q15_t)0x23c7, (q15_t)0x23c1, (q15_t)0x23bb, (q15_t)0x23b5, (q15_t)0x23af, (q15_t)0x23a9, - (q15_t)0x23a3, (q15_t)0x239d, (q15_t)0x2397, (q15_t)0x2391, (q15_t)0x238b, (q15_t)0x2385, (q15_t)0x237f, (q15_t)0x2379, - (q15_t)0x2373, (q15_t)0x236d, (q15_t)0x2367, (q15_t)0x2361, (q15_t)0x235b, (q15_t)0x2355, (q15_t)0x234e, (q15_t)0x2348, - (q15_t)0x2342, (q15_t)0x233c, (q15_t)0x2336, (q15_t)0x2330, (q15_t)0x232a, (q15_t)0x2324, (q15_t)0x231e, (q15_t)0x2318, - (q15_t)0x2312, (q15_t)0x230c, (q15_t)0x2306, (q15_t)0x2300, (q15_t)0x22fa, (q15_t)0x22f4, (q15_t)0x22ee, (q15_t)0x22e8, - (q15_t)0x22e2, (q15_t)0x22dc, (q15_t)0x22d6, (q15_t)0x22d0, (q15_t)0x22ca, (q15_t)0x22c4, (q15_t)0x22bd, (q15_t)0x22b7, - (q15_t)0x22b1, (q15_t)0x22ab, (q15_t)0x22a5, (q15_t)0x229f, (q15_t)0x2299, (q15_t)0x2293, (q15_t)0x228d, (q15_t)0x2287, - (q15_t)0x2281, (q15_t)0x227b, (q15_t)0x2275, (q15_t)0x226f, (q15_t)0x2269, (q15_t)0x2263, (q15_t)0x225d, (q15_t)0x2257, - (q15_t)0x2251, (q15_t)0x224a, (q15_t)0x2244, (q15_t)0x223e, (q15_t)0x2238, (q15_t)0x2232, (q15_t)0x222c, (q15_t)0x2226, - (q15_t)0x2220, (q15_t)0x221a, (q15_t)0x2214, (q15_t)0x220e, (q15_t)0x2208, (q15_t)0x2202, (q15_t)0x21fc, (q15_t)0x21f6, - (q15_t)0x21f0, (q15_t)0x21ea, (q15_t)0x21e4, (q15_t)0x21dd, (q15_t)0x21d7, (q15_t)0x21d1, (q15_t)0x21cb, (q15_t)0x21c5, - (q15_t)0x21bf, (q15_t)0x21b9, (q15_t)0x21b3, (q15_t)0x21ad, (q15_t)0x21a7, (q15_t)0x21a1, (q15_t)0x219b, (q15_t)0x2195, - (q15_t)0x218f, (q15_t)0x2189, (q15_t)0x2183, (q15_t)0x217c, (q15_t)0x2176, (q15_t)0x2170, (q15_t)0x216a, (q15_t)0x2164, - (q15_t)0x215e, (q15_t)0x2158, (q15_t)0x2152, (q15_t)0x214c, (q15_t)0x2146, (q15_t)0x2140, (q15_t)0x213a, (q15_t)0x2134, - (q15_t)0x212e, (q15_t)0x2128, (q15_t)0x2121, (q15_t)0x211b, (q15_t)0x2115, (q15_t)0x210f, (q15_t)0x2109, (q15_t)0x2103, - (q15_t)0x20fd, (q15_t)0x20f7, (q15_t)0x20f1, (q15_t)0x20eb, (q15_t)0x20e5, (q15_t)0x20df, (q15_t)0x20d9, (q15_t)0x20d3, - (q15_t)0x20cc, (q15_t)0x20c6, (q15_t)0x20c0, (q15_t)0x20ba, (q15_t)0x20b4, (q15_t)0x20ae, (q15_t)0x20a8, (q15_t)0x20a2, - (q15_t)0x209c, (q15_t)0x2096, (q15_t)0x2090, (q15_t)0x208a, (q15_t)0x2084, (q15_t)0x207e, (q15_t)0x2077, (q15_t)0x2071, - (q15_t)0x206b, (q15_t)0x2065, (q15_t)0x205f, (q15_t)0x2059, (q15_t)0x2053, (q15_t)0x204d, (q15_t)0x2047, (q15_t)0x2041, - (q15_t)0x203b, (q15_t)0x2035, (q15_t)0x202e, (q15_t)0x2028, (q15_t)0x2022, (q15_t)0x201c, (q15_t)0x2016, (q15_t)0x2010, - (q15_t)0x200a, (q15_t)0x2004, (q15_t)0x1ffe, (q15_t)0x1ff8, (q15_t)0x1ff2, (q15_t)0x1fec, (q15_t)0x1fe5, (q15_t)0x1fdf, - (q15_t)0x1fd9, (q15_t)0x1fd3, (q15_t)0x1fcd, (q15_t)0x1fc7, (q15_t)0x1fc1, (q15_t)0x1fbb, (q15_t)0x1fb5, (q15_t)0x1faf, - (q15_t)0x1fa9, (q15_t)0x1fa3, (q15_t)0x1f9c, (q15_t)0x1f96, (q15_t)0x1f90, (q15_t)0x1f8a, (q15_t)0x1f84, (q15_t)0x1f7e, - (q15_t)0x1f78, (q15_t)0x1f72, (q15_t)0x1f6c, (q15_t)0x1f66, (q15_t)0x1f60, (q15_t)0x1f59, (q15_t)0x1f53, (q15_t)0x1f4d, - (q15_t)0x1f47, (q15_t)0x1f41, (q15_t)0x1f3b, (q15_t)0x1f35, (q15_t)0x1f2f, (q15_t)0x1f29, (q15_t)0x1f23, (q15_t)0x1f1d, - (q15_t)0x1f16, (q15_t)0x1f10, (q15_t)0x1f0a, (q15_t)0x1f04, (q15_t)0x1efe, (q15_t)0x1ef8, (q15_t)0x1ef2, (q15_t)0x1eec, - (q15_t)0x1ee6, (q15_t)0x1ee0, (q15_t)0x1ed9, (q15_t)0x1ed3, (q15_t)0x1ecd, (q15_t)0x1ec7, (q15_t)0x1ec1, (q15_t)0x1ebb, - (q15_t)0x1eb5, (q15_t)0x1eaf, (q15_t)0x1ea9, (q15_t)0x1ea3, (q15_t)0x1e9c, (q15_t)0x1e96, (q15_t)0x1e90, (q15_t)0x1e8a, - (q15_t)0x1e84, (q15_t)0x1e7e, (q15_t)0x1e78, (q15_t)0x1e72, (q15_t)0x1e6c, (q15_t)0x1e66, (q15_t)0x1e5f, (q15_t)0x1e59, - (q15_t)0x1e53, (q15_t)0x1e4d, (q15_t)0x1e47, (q15_t)0x1e41, (q15_t)0x1e3b, (q15_t)0x1e35, (q15_t)0x1e2f, (q15_t)0x1e29, - (q15_t)0x1e22, (q15_t)0x1e1c, (q15_t)0x1e16, (q15_t)0x1e10, (q15_t)0x1e0a, (q15_t)0x1e04, (q15_t)0x1dfe, (q15_t)0x1df8, - (q15_t)0x1df2, (q15_t)0x1deb, (q15_t)0x1de5, (q15_t)0x1ddf, (q15_t)0x1dd9, (q15_t)0x1dd3, (q15_t)0x1dcd, (q15_t)0x1dc7, - (q15_t)0x1dc1, (q15_t)0x1dbb, (q15_t)0x1db4, (q15_t)0x1dae, (q15_t)0x1da8, (q15_t)0x1da2, (q15_t)0x1d9c, (q15_t)0x1d96, - (q15_t)0x1d90, (q15_t)0x1d8a, (q15_t)0x1d84, (q15_t)0x1d7d, (q15_t)0x1d77, (q15_t)0x1d71, (q15_t)0x1d6b, (q15_t)0x1d65, - (q15_t)0x1d5f, (q15_t)0x1d59, (q15_t)0x1d53, (q15_t)0x1d4c, (q15_t)0x1d46, (q15_t)0x1d40, (q15_t)0x1d3a, (q15_t)0x1d34, - (q15_t)0x1d2e, (q15_t)0x1d28, (q15_t)0x1d22, (q15_t)0x1d1c, (q15_t)0x1d15, (q15_t)0x1d0f, (q15_t)0x1d09, (q15_t)0x1d03, - (q15_t)0x1cfd, (q15_t)0x1cf7, (q15_t)0x1cf1, (q15_t)0x1ceb, (q15_t)0x1ce4, (q15_t)0x1cde, (q15_t)0x1cd8, (q15_t)0x1cd2, - (q15_t)0x1ccc, (q15_t)0x1cc6, (q15_t)0x1cc0, (q15_t)0x1cba, (q15_t)0x1cb3, (q15_t)0x1cad, (q15_t)0x1ca7, (q15_t)0x1ca1, - (q15_t)0x1c9b, (q15_t)0x1c95, (q15_t)0x1c8f, (q15_t)0x1c89, (q15_t)0x1c83, (q15_t)0x1c7c, (q15_t)0x1c76, (q15_t)0x1c70, - (q15_t)0x1c6a, (q15_t)0x1c64, (q15_t)0x1c5e, (q15_t)0x1c58, (q15_t)0x1c51, (q15_t)0x1c4b, (q15_t)0x1c45, (q15_t)0x1c3f, - (q15_t)0x1c39, (q15_t)0x1c33, (q15_t)0x1c2d, (q15_t)0x1c27, (q15_t)0x1c20, (q15_t)0x1c1a, (q15_t)0x1c14, (q15_t)0x1c0e, - (q15_t)0x1c08, (q15_t)0x1c02, (q15_t)0x1bfc, (q15_t)0x1bf6, (q15_t)0x1bef, (q15_t)0x1be9, (q15_t)0x1be3, (q15_t)0x1bdd, - (q15_t)0x1bd7, (q15_t)0x1bd1, (q15_t)0x1bcb, (q15_t)0x1bc4, (q15_t)0x1bbe, (q15_t)0x1bb8, (q15_t)0x1bb2, (q15_t)0x1bac, - (q15_t)0x1ba6, (q15_t)0x1ba0, (q15_t)0x1b9a, (q15_t)0x1b93, (q15_t)0x1b8d, (q15_t)0x1b87, (q15_t)0x1b81, (q15_t)0x1b7b, - (q15_t)0x1b75, (q15_t)0x1b6f, (q15_t)0x1b68, (q15_t)0x1b62, (q15_t)0x1b5c, (q15_t)0x1b56, (q15_t)0x1b50, (q15_t)0x1b4a, - (q15_t)0x1b44, (q15_t)0x1b3d, (q15_t)0x1b37, (q15_t)0x1b31, (q15_t)0x1b2b, (q15_t)0x1b25, (q15_t)0x1b1f, (q15_t)0x1b19, - (q15_t)0x1b13, (q15_t)0x1b0c, (q15_t)0x1b06, (q15_t)0x1b00, (q15_t)0x1afa, (q15_t)0x1af4, (q15_t)0x1aee, (q15_t)0x1ae8, - (q15_t)0x1ae1, (q15_t)0x1adb, (q15_t)0x1ad5, (q15_t)0x1acf, (q15_t)0x1ac9, (q15_t)0x1ac3, (q15_t)0x1abd, (q15_t)0x1ab6, - (q15_t)0x1ab0, (q15_t)0x1aaa, (q15_t)0x1aa4, (q15_t)0x1a9e, (q15_t)0x1a98, (q15_t)0x1a91, (q15_t)0x1a8b, (q15_t)0x1a85, - (q15_t)0x1a7f, (q15_t)0x1a79, (q15_t)0x1a73, (q15_t)0x1a6d, (q15_t)0x1a66, (q15_t)0x1a60, (q15_t)0x1a5a, (q15_t)0x1a54, - (q15_t)0x1a4e, (q15_t)0x1a48, (q15_t)0x1a42, (q15_t)0x1a3b, (q15_t)0x1a35, (q15_t)0x1a2f, (q15_t)0x1a29, (q15_t)0x1a23, - (q15_t)0x1a1d, (q15_t)0x1a17, (q15_t)0x1a10, (q15_t)0x1a0a, (q15_t)0x1a04, (q15_t)0x19fe, (q15_t)0x19f8, (q15_t)0x19f2, - (q15_t)0x19eb, (q15_t)0x19e5, (q15_t)0x19df, (q15_t)0x19d9, (q15_t)0x19d3, (q15_t)0x19cd, (q15_t)0x19c7, (q15_t)0x19c0, - (q15_t)0x19ba, (q15_t)0x19b4, (q15_t)0x19ae, (q15_t)0x19a8, (q15_t)0x19a2, (q15_t)0x199b, (q15_t)0x1995, (q15_t)0x198f, - (q15_t)0x1989, (q15_t)0x1983, (q15_t)0x197d, (q15_t)0x1977, (q15_t)0x1970, (q15_t)0x196a, (q15_t)0x1964, (q15_t)0x195e, - (q15_t)0x1958, (q15_t)0x1952, (q15_t)0x194b, (q15_t)0x1945, (q15_t)0x193f, (q15_t)0x1939, (q15_t)0x1933, (q15_t)0x192d, - (q15_t)0x1926, (q15_t)0x1920, (q15_t)0x191a, (q15_t)0x1914, (q15_t)0x190e, (q15_t)0x1908, (q15_t)0x1901, (q15_t)0x18fb, - (q15_t)0x18f5, (q15_t)0x18ef, (q15_t)0x18e9, (q15_t)0x18e3, (q15_t)0x18dc, (q15_t)0x18d6, (q15_t)0x18d0, (q15_t)0x18ca, - (q15_t)0x18c4, (q15_t)0x18be, (q15_t)0x18b8, (q15_t)0x18b1, (q15_t)0x18ab, (q15_t)0x18a5, (q15_t)0x189f, (q15_t)0x1899, - (q15_t)0x1893, (q15_t)0x188c, (q15_t)0x1886, (q15_t)0x1880, (q15_t)0x187a, (q15_t)0x1874, (q15_t)0x186e, (q15_t)0x1867, - (q15_t)0x1861, (q15_t)0x185b, (q15_t)0x1855, (q15_t)0x184f, (q15_t)0x1848, (q15_t)0x1842, (q15_t)0x183c, (q15_t)0x1836, - (q15_t)0x1830, (q15_t)0x182a, (q15_t)0x1823, (q15_t)0x181d, (q15_t)0x1817, (q15_t)0x1811, (q15_t)0x180b, (q15_t)0x1805, - (q15_t)0x17fe, (q15_t)0x17f8, (q15_t)0x17f2, (q15_t)0x17ec, (q15_t)0x17e6, (q15_t)0x17e0, (q15_t)0x17d9, (q15_t)0x17d3, - (q15_t)0x17cd, (q15_t)0x17c7, (q15_t)0x17c1, (q15_t)0x17bb, (q15_t)0x17b4, (q15_t)0x17ae, (q15_t)0x17a8, (q15_t)0x17a2, - (q15_t)0x179c, (q15_t)0x1795, (q15_t)0x178f, (q15_t)0x1789, (q15_t)0x1783, (q15_t)0x177d, (q15_t)0x1777, (q15_t)0x1770, - (q15_t)0x176a, (q15_t)0x1764, (q15_t)0x175e, (q15_t)0x1758, (q15_t)0x1752, (q15_t)0x174b, (q15_t)0x1745, (q15_t)0x173f, - (q15_t)0x1739, (q15_t)0x1733, (q15_t)0x172c, (q15_t)0x1726, (q15_t)0x1720, (q15_t)0x171a, (q15_t)0x1714, (q15_t)0x170e, - (q15_t)0x1707, (q15_t)0x1701, (q15_t)0x16fb, (q15_t)0x16f5, (q15_t)0x16ef, (q15_t)0x16e8, (q15_t)0x16e2, (q15_t)0x16dc, - (q15_t)0x16d6, (q15_t)0x16d0, (q15_t)0x16ca, (q15_t)0x16c3, (q15_t)0x16bd, (q15_t)0x16b7, (q15_t)0x16b1, (q15_t)0x16ab, - (q15_t)0x16a4, (q15_t)0x169e, (q15_t)0x1698, (q15_t)0x1692, (q15_t)0x168c, (q15_t)0x1686, (q15_t)0x167f, (q15_t)0x1679, - (q15_t)0x1673, (q15_t)0x166d, (q15_t)0x1667, (q15_t)0x1660, (q15_t)0x165a, (q15_t)0x1654, (q15_t)0x164e, (q15_t)0x1648, - (q15_t)0x1642, (q15_t)0x163b, (q15_t)0x1635, (q15_t)0x162f, (q15_t)0x1629, (q15_t)0x1623, (q15_t)0x161c, (q15_t)0x1616, - (q15_t)0x1610, (q15_t)0x160a, (q15_t)0x1604, (q15_t)0x15fd, (q15_t)0x15f7, (q15_t)0x15f1, (q15_t)0x15eb, (q15_t)0x15e5, - (q15_t)0x15de, (q15_t)0x15d8, (q15_t)0x15d2, (q15_t)0x15cc, (q15_t)0x15c6, (q15_t)0x15c0, (q15_t)0x15b9, (q15_t)0x15b3, - (q15_t)0x15ad, (q15_t)0x15a7, (q15_t)0x15a1, (q15_t)0x159a, (q15_t)0x1594, (q15_t)0x158e, (q15_t)0x1588, (q15_t)0x1582, - (q15_t)0x157b, (q15_t)0x1575, (q15_t)0x156f, (q15_t)0x1569, (q15_t)0x1563, (q15_t)0x155c, (q15_t)0x1556, (q15_t)0x1550, - (q15_t)0x154a, (q15_t)0x1544, (q15_t)0x153d, (q15_t)0x1537, (q15_t)0x1531, (q15_t)0x152b, (q15_t)0x1525, (q15_t)0x151e, - (q15_t)0x1518, (q15_t)0x1512, (q15_t)0x150c, (q15_t)0x1506, (q15_t)0x14ff, (q15_t)0x14f9, (q15_t)0x14f3, (q15_t)0x14ed, - (q15_t)0x14e7, (q15_t)0x14e0, (q15_t)0x14da, (q15_t)0x14d4, (q15_t)0x14ce, (q15_t)0x14c8, (q15_t)0x14c1, (q15_t)0x14bb, - (q15_t)0x14b5, (q15_t)0x14af, (q15_t)0x14a9, (q15_t)0x14a2, (q15_t)0x149c, (q15_t)0x1496, (q15_t)0x1490, (q15_t)0x148a, - (q15_t)0x1483, (q15_t)0x147d, (q15_t)0x1477, (q15_t)0x1471, (q15_t)0x146b, (q15_t)0x1464, (q15_t)0x145e, (q15_t)0x1458, - (q15_t)0x1452, (q15_t)0x144c, (q15_t)0x1445, (q15_t)0x143f, (q15_t)0x1439, (q15_t)0x1433, (q15_t)0x142d, (q15_t)0x1426, - (q15_t)0x1420, (q15_t)0x141a, (q15_t)0x1414, (q15_t)0x140e, (q15_t)0x1407, (q15_t)0x1401, (q15_t)0x13fb, (q15_t)0x13f5, - (q15_t)0x13ef, (q15_t)0x13e8, (q15_t)0x13e2, (q15_t)0x13dc, (q15_t)0x13d6, (q15_t)0x13d0, (q15_t)0x13c9, (q15_t)0x13c3, - (q15_t)0x13bd, (q15_t)0x13b7, (q15_t)0x13b1, (q15_t)0x13aa, (q15_t)0x13a4, (q15_t)0x139e, (q15_t)0x1398, (q15_t)0x1391, - (q15_t)0x138b, (q15_t)0x1385, (q15_t)0x137f, (q15_t)0x1379, (q15_t)0x1372, (q15_t)0x136c, (q15_t)0x1366, (q15_t)0x1360, - (q15_t)0x135a, (q15_t)0x1353, (q15_t)0x134d, (q15_t)0x1347, (q15_t)0x1341, (q15_t)0x133b, (q15_t)0x1334, (q15_t)0x132e, - (q15_t)0x1328, (q15_t)0x1322, (q15_t)0x131b, (q15_t)0x1315, (q15_t)0x130f, (q15_t)0x1309, (q15_t)0x1303, (q15_t)0x12fc, - (q15_t)0x12f6, (q15_t)0x12f0, (q15_t)0x12ea, (q15_t)0x12e4, (q15_t)0x12dd, (q15_t)0x12d7, (q15_t)0x12d1, (q15_t)0x12cb, - (q15_t)0x12c4, (q15_t)0x12be, (q15_t)0x12b8, (q15_t)0x12b2, (q15_t)0x12ac, (q15_t)0x12a5, (q15_t)0x129f, (q15_t)0x1299, - (q15_t)0x1293, (q15_t)0x128d, (q15_t)0x1286, (q15_t)0x1280, (q15_t)0x127a, (q15_t)0x1274, (q15_t)0x126d, (q15_t)0x1267, - (q15_t)0x1261, (q15_t)0x125b, (q15_t)0x1255, (q15_t)0x124e, (q15_t)0x1248, (q15_t)0x1242, (q15_t)0x123c, (q15_t)0x1235, - (q15_t)0x122f, (q15_t)0x1229, (q15_t)0x1223, (q15_t)0x121d, (q15_t)0x1216, (q15_t)0x1210, (q15_t)0x120a, (q15_t)0x1204, - (q15_t)0x11fd, (q15_t)0x11f7, (q15_t)0x11f1, (q15_t)0x11eb, (q15_t)0x11e5, (q15_t)0x11de, (q15_t)0x11d8, (q15_t)0x11d2, - (q15_t)0x11cc, (q15_t)0x11c5, (q15_t)0x11bf, (q15_t)0x11b9, (q15_t)0x11b3, (q15_t)0x11ad, (q15_t)0x11a6, (q15_t)0x11a0, - (q15_t)0x119a, (q15_t)0x1194, (q15_t)0x118d, (q15_t)0x1187, (q15_t)0x1181, (q15_t)0x117b, (q15_t)0x1175, (q15_t)0x116e, - (q15_t)0x1168, (q15_t)0x1162, (q15_t)0x115c, (q15_t)0x1155, (q15_t)0x114f, (q15_t)0x1149, (q15_t)0x1143, (q15_t)0x113d, - (q15_t)0x1136, (q15_t)0x1130, (q15_t)0x112a, (q15_t)0x1124, (q15_t)0x111d, (q15_t)0x1117, (q15_t)0x1111, (q15_t)0x110b, - (q15_t)0x1105, (q15_t)0x10fe, (q15_t)0x10f8, (q15_t)0x10f2, (q15_t)0x10ec, (q15_t)0x10e5, (q15_t)0x10df, (q15_t)0x10d9, - (q15_t)0x10d3, (q15_t)0x10cc, (q15_t)0x10c6, (q15_t)0x10c0, (q15_t)0x10ba, (q15_t)0x10b4, (q15_t)0x10ad, (q15_t)0x10a7, - (q15_t)0x10a1, (q15_t)0x109b, (q15_t)0x1094, (q15_t)0x108e, (q15_t)0x1088, (q15_t)0x1082, (q15_t)0x107b, (q15_t)0x1075, - (q15_t)0x106f, (q15_t)0x1069, (q15_t)0x1063, (q15_t)0x105c, (q15_t)0x1056, (q15_t)0x1050, (q15_t)0x104a, (q15_t)0x1043, - (q15_t)0x103d, (q15_t)0x1037, (q15_t)0x1031, (q15_t)0x102a, (q15_t)0x1024, (q15_t)0x101e, (q15_t)0x1018, (q15_t)0x1012, - (q15_t)0x100b, (q15_t)0x1005, (q15_t)0xfff, (q15_t)0xff9, (q15_t)0xff2, (q15_t)0xfec, (q15_t)0xfe6, (q15_t)0xfe0, - (q15_t)0xfd9, (q15_t)0xfd3, (q15_t)0xfcd, (q15_t)0xfc7, (q15_t)0xfc0, (q15_t)0xfba, (q15_t)0xfb4, (q15_t)0xfae, - (q15_t)0xfa8, (q15_t)0xfa1, (q15_t)0xf9b, (q15_t)0xf95, (q15_t)0xf8f, (q15_t)0xf88, (q15_t)0xf82, (q15_t)0xf7c, - (q15_t)0xf76, (q15_t)0xf6f, (q15_t)0xf69, (q15_t)0xf63, (q15_t)0xf5d, (q15_t)0xf56, (q15_t)0xf50, (q15_t)0xf4a, - (q15_t)0xf44, (q15_t)0xf3e, (q15_t)0xf37, (q15_t)0xf31, (q15_t)0xf2b, (q15_t)0xf25, (q15_t)0xf1e, (q15_t)0xf18, - (q15_t)0xf12, (q15_t)0xf0c, (q15_t)0xf05, (q15_t)0xeff, (q15_t)0xef9, (q15_t)0xef3, (q15_t)0xeec, (q15_t)0xee6, - (q15_t)0xee0, (q15_t)0xeda, (q15_t)0xed3, (q15_t)0xecd, (q15_t)0xec7, (q15_t)0xec1, (q15_t)0xeba, (q15_t)0xeb4, - (q15_t)0xeae, (q15_t)0xea8, (q15_t)0xea1, (q15_t)0xe9b, (q15_t)0xe95, (q15_t)0xe8f, (q15_t)0xe89, (q15_t)0xe82, - (q15_t)0xe7c, (q15_t)0xe76, (q15_t)0xe70, (q15_t)0xe69, (q15_t)0xe63, (q15_t)0xe5d, (q15_t)0xe57, (q15_t)0xe50, - (q15_t)0xe4a, (q15_t)0xe44, (q15_t)0xe3e, (q15_t)0xe37, (q15_t)0xe31, (q15_t)0xe2b, (q15_t)0xe25, (q15_t)0xe1e, - (q15_t)0xe18, (q15_t)0xe12, (q15_t)0xe0c, (q15_t)0xe05, (q15_t)0xdff, (q15_t)0xdf9, (q15_t)0xdf3, (q15_t)0xdec, - (q15_t)0xde6, (q15_t)0xde0, (q15_t)0xdda, (q15_t)0xdd3, (q15_t)0xdcd, (q15_t)0xdc7, (q15_t)0xdc1, (q15_t)0xdba, - (q15_t)0xdb4, (q15_t)0xdae, (q15_t)0xda8, (q15_t)0xda1, (q15_t)0xd9b, (q15_t)0xd95, (q15_t)0xd8f, (q15_t)0xd88, - (q15_t)0xd82, (q15_t)0xd7c, (q15_t)0xd76, (q15_t)0xd6f, (q15_t)0xd69, (q15_t)0xd63, (q15_t)0xd5d, (q15_t)0xd56, - (q15_t)0xd50, (q15_t)0xd4a, (q15_t)0xd44, (q15_t)0xd3d, (q15_t)0xd37, (q15_t)0xd31, (q15_t)0xd2b, (q15_t)0xd24, - (q15_t)0xd1e, (q15_t)0xd18, (q15_t)0xd12, (q15_t)0xd0b, (q15_t)0xd05, (q15_t)0xcff, (q15_t)0xcf9, (q15_t)0xcf2, - (q15_t)0xcec, (q15_t)0xce6, (q15_t)0xce0, (q15_t)0xcd9, (q15_t)0xcd3, (q15_t)0xccd, (q15_t)0xcc7, (q15_t)0xcc0, - (q15_t)0xcba, (q15_t)0xcb4, (q15_t)0xcae, (q15_t)0xca7, (q15_t)0xca1, (q15_t)0xc9b, (q15_t)0xc95, (q15_t)0xc8e, - (q15_t)0xc88, (q15_t)0xc82, (q15_t)0xc7c, (q15_t)0xc75, (q15_t)0xc6f, (q15_t)0xc69, (q15_t)0xc63, (q15_t)0xc5c, - (q15_t)0xc56, (q15_t)0xc50, (q15_t)0xc4a, (q15_t)0xc43, (q15_t)0xc3d, (q15_t)0xc37, (q15_t)0xc31, (q15_t)0xc2a, - (q15_t)0xc24, (q15_t)0xc1e, (q15_t)0xc18, (q15_t)0xc11, (q15_t)0xc0b, (q15_t)0xc05, (q15_t)0xbff, (q15_t)0xbf8, - (q15_t)0xbf2, (q15_t)0xbec, (q15_t)0xbe6, (q15_t)0xbdf, (q15_t)0xbd9, (q15_t)0xbd3, (q15_t)0xbcd, (q15_t)0xbc6, - (q15_t)0xbc0, (q15_t)0xbba, (q15_t)0xbb4, (q15_t)0xbad, (q15_t)0xba7, (q15_t)0xba1, (q15_t)0xb9b, (q15_t)0xb94, - (q15_t)0xb8e, (q15_t)0xb88, (q15_t)0xb81, (q15_t)0xb7b, (q15_t)0xb75, (q15_t)0xb6f, (q15_t)0xb68, (q15_t)0xb62, - (q15_t)0xb5c, (q15_t)0xb56, (q15_t)0xb4f, (q15_t)0xb49, (q15_t)0xb43, (q15_t)0xb3d, (q15_t)0xb36, (q15_t)0xb30, - (q15_t)0xb2a, (q15_t)0xb24, (q15_t)0xb1d, (q15_t)0xb17, (q15_t)0xb11, (q15_t)0xb0b, (q15_t)0xb04, (q15_t)0xafe, - (q15_t)0xaf8, (q15_t)0xaf2, (q15_t)0xaeb, (q15_t)0xae5, (q15_t)0xadf, (q15_t)0xad8, (q15_t)0xad2, (q15_t)0xacc, - (q15_t)0xac6, (q15_t)0xabf, (q15_t)0xab9, (q15_t)0xab3, (q15_t)0xaad, (q15_t)0xaa6, (q15_t)0xaa0, (q15_t)0xa9a, - (q15_t)0xa94, (q15_t)0xa8d, (q15_t)0xa87, (q15_t)0xa81, (q15_t)0xa7b, (q15_t)0xa74, (q15_t)0xa6e, (q15_t)0xa68, - (q15_t)0xa62, (q15_t)0xa5b, (q15_t)0xa55, (q15_t)0xa4f, (q15_t)0xa48, (q15_t)0xa42, (q15_t)0xa3c, (q15_t)0xa36, - (q15_t)0xa2f, (q15_t)0xa29, (q15_t)0xa23, (q15_t)0xa1d, (q15_t)0xa16, (q15_t)0xa10, (q15_t)0xa0a, (q15_t)0xa04, - (q15_t)0x9fd, (q15_t)0x9f7, (q15_t)0x9f1, (q15_t)0x9eb, (q15_t)0x9e4, (q15_t)0x9de, (q15_t)0x9d8, (q15_t)0x9d1, - (q15_t)0x9cb, (q15_t)0x9c5, (q15_t)0x9bf, (q15_t)0x9b8, (q15_t)0x9b2, (q15_t)0x9ac, (q15_t)0x9a6, (q15_t)0x99f, - (q15_t)0x999, (q15_t)0x993, (q15_t)0x98d, (q15_t)0x986, (q15_t)0x980, (q15_t)0x97a, (q15_t)0x973, (q15_t)0x96d, - (q15_t)0x967, (q15_t)0x961, (q15_t)0x95a, (q15_t)0x954, (q15_t)0x94e, (q15_t)0x948, (q15_t)0x941, (q15_t)0x93b, - (q15_t)0x935, (q15_t)0x92f, (q15_t)0x928, (q15_t)0x922, (q15_t)0x91c, (q15_t)0x915, (q15_t)0x90f, (q15_t)0x909, - (q15_t)0x903, (q15_t)0x8fc, (q15_t)0x8f6, (q15_t)0x8f0, (q15_t)0x8ea, (q15_t)0x8e3, (q15_t)0x8dd, (q15_t)0x8d7, - (q15_t)0x8d1, (q15_t)0x8ca, (q15_t)0x8c4, (q15_t)0x8be, (q15_t)0x8b7, (q15_t)0x8b1, (q15_t)0x8ab, (q15_t)0x8a5, - (q15_t)0x89e, (q15_t)0x898, (q15_t)0x892, (q15_t)0x88c, (q15_t)0x885, (q15_t)0x87f, (q15_t)0x879, (q15_t)0x872, - (q15_t)0x86c, (q15_t)0x866, (q15_t)0x860, (q15_t)0x859, (q15_t)0x853, (q15_t)0x84d, (q15_t)0x847, (q15_t)0x840, - (q15_t)0x83a, (q15_t)0x834, (q15_t)0x82e, (q15_t)0x827, (q15_t)0x821, (q15_t)0x81b, (q15_t)0x814, (q15_t)0x80e, - (q15_t)0x808, (q15_t)0x802, (q15_t)0x7fb, (q15_t)0x7f5, (q15_t)0x7ef, (q15_t)0x7e9, (q15_t)0x7e2, (q15_t)0x7dc, - (q15_t)0x7d6, (q15_t)0x7cf, (q15_t)0x7c9, (q15_t)0x7c3, (q15_t)0x7bd, (q15_t)0x7b6, (q15_t)0x7b0, (q15_t)0x7aa, - (q15_t)0x7a4, (q15_t)0x79d, (q15_t)0x797, (q15_t)0x791, (q15_t)0x78a, (q15_t)0x784, (q15_t)0x77e, (q15_t)0x778, - (q15_t)0x771, (q15_t)0x76b, (q15_t)0x765, (q15_t)0x75f, (q15_t)0x758, (q15_t)0x752, (q15_t)0x74c, (q15_t)0x745, - (q15_t)0x73f, (q15_t)0x739, (q15_t)0x733, (q15_t)0x72c, (q15_t)0x726, (q15_t)0x720, (q15_t)0x71a, (q15_t)0x713, - (q15_t)0x70d, (q15_t)0x707, (q15_t)0x700, (q15_t)0x6fa, (q15_t)0x6f4, (q15_t)0x6ee, (q15_t)0x6e7, (q15_t)0x6e1, - (q15_t)0x6db, (q15_t)0x6d5, (q15_t)0x6ce, (q15_t)0x6c8, (q15_t)0x6c2, (q15_t)0x6bb, (q15_t)0x6b5, (q15_t)0x6af, - (q15_t)0x6a9, (q15_t)0x6a2, (q15_t)0x69c, (q15_t)0x696, (q15_t)0x690, (q15_t)0x689, (q15_t)0x683, (q15_t)0x67d, - (q15_t)0x676, (q15_t)0x670, (q15_t)0x66a, (q15_t)0x664, (q15_t)0x65d, (q15_t)0x657, (q15_t)0x651, (q15_t)0x64a, - (q15_t)0x644, (q15_t)0x63e, (q15_t)0x638, (q15_t)0x631, (q15_t)0x62b, (q15_t)0x625, (q15_t)0x61f, (q15_t)0x618, - (q15_t)0x612, (q15_t)0x60c, (q15_t)0x605, (q15_t)0x5ff, (q15_t)0x5f9, (q15_t)0x5f3, (q15_t)0x5ec, (q15_t)0x5e6, - (q15_t)0x5e0, (q15_t)0x5da, (q15_t)0x5d3, (q15_t)0x5cd, (q15_t)0x5c7, (q15_t)0x5c0, (q15_t)0x5ba, (q15_t)0x5b4, - (q15_t)0x5ae, (q15_t)0x5a7, (q15_t)0x5a1, (q15_t)0x59b, (q15_t)0x594, (q15_t)0x58e, (q15_t)0x588, (q15_t)0x582, - (q15_t)0x57b, (q15_t)0x575, (q15_t)0x56f, (q15_t)0x569, (q15_t)0x562, (q15_t)0x55c, (q15_t)0x556, (q15_t)0x54f, - (q15_t)0x549, (q15_t)0x543, (q15_t)0x53d, (q15_t)0x536, (q15_t)0x530, (q15_t)0x52a, (q15_t)0x523, (q15_t)0x51d, - (q15_t)0x517, (q15_t)0x511, (q15_t)0x50a, (q15_t)0x504, (q15_t)0x4fe, (q15_t)0x4f8, (q15_t)0x4f1, (q15_t)0x4eb, - (q15_t)0x4e5, (q15_t)0x4de, (q15_t)0x4d8, (q15_t)0x4d2, (q15_t)0x4cc, (q15_t)0x4c5, (q15_t)0x4bf, (q15_t)0x4b9, - (q15_t)0x4b2, (q15_t)0x4ac, (q15_t)0x4a6, (q15_t)0x4a0, (q15_t)0x499, (q15_t)0x493, (q15_t)0x48d, (q15_t)0x487, - (q15_t)0x480, (q15_t)0x47a, (q15_t)0x474, (q15_t)0x46d, (q15_t)0x467, (q15_t)0x461, (q15_t)0x45b, (q15_t)0x454, - (q15_t)0x44e, (q15_t)0x448, (q15_t)0x441, (q15_t)0x43b, (q15_t)0x435, (q15_t)0x42f, (q15_t)0x428, (q15_t)0x422, - (q15_t)0x41c, (q15_t)0x415, (q15_t)0x40f, (q15_t)0x409, (q15_t)0x403, (q15_t)0x3fc, (q15_t)0x3f6, (q15_t)0x3f0, - (q15_t)0x3ea, (q15_t)0x3e3, (q15_t)0x3dd, (q15_t)0x3d7, (q15_t)0x3d0, (q15_t)0x3ca, (q15_t)0x3c4, (q15_t)0x3be, - (q15_t)0x3b7, (q15_t)0x3b1, (q15_t)0x3ab, (q15_t)0x3a4, (q15_t)0x39e, (q15_t)0x398, (q15_t)0x392, (q15_t)0x38b, - (q15_t)0x385, (q15_t)0x37f, (q15_t)0x378, (q15_t)0x372, (q15_t)0x36c, (q15_t)0x366, (q15_t)0x35f, (q15_t)0x359, - (q15_t)0x353, (q15_t)0x34c, (q15_t)0x346, (q15_t)0x340, (q15_t)0x33a, (q15_t)0x333, (q15_t)0x32d, (q15_t)0x327, - (q15_t)0x321, (q15_t)0x31a, (q15_t)0x314, (q15_t)0x30e, (q15_t)0x307, (q15_t)0x301, (q15_t)0x2fb, (q15_t)0x2f5, - (q15_t)0x2ee, (q15_t)0x2e8, (q15_t)0x2e2, (q15_t)0x2db, (q15_t)0x2d5, (q15_t)0x2cf, (q15_t)0x2c9, (q15_t)0x2c2, - (q15_t)0x2bc, (q15_t)0x2b6, (q15_t)0x2af, (q15_t)0x2a9, (q15_t)0x2a3, (q15_t)0x29d, (q15_t)0x296, (q15_t)0x290, - (q15_t)0x28a, (q15_t)0x283, (q15_t)0x27d, (q15_t)0x277, (q15_t)0x271, (q15_t)0x26a, (q15_t)0x264, (q15_t)0x25e, - (q15_t)0x258, (q15_t)0x251, (q15_t)0x24b, (q15_t)0x245, (q15_t)0x23e, (q15_t)0x238, (q15_t)0x232, (q15_t)0x22c, - (q15_t)0x225, (q15_t)0x21f, (q15_t)0x219, (q15_t)0x212, (q15_t)0x20c, (q15_t)0x206, (q15_t)0x200, (q15_t)0x1f9, - (q15_t)0x1f3, (q15_t)0x1ed, (q15_t)0x1e6, (q15_t)0x1e0, (q15_t)0x1da, (q15_t)0x1d4, (q15_t)0x1cd, (q15_t)0x1c7, - (q15_t)0x1c1, (q15_t)0x1ba, (q15_t)0x1b4, (q15_t)0x1ae, (q15_t)0x1a8, (q15_t)0x1a1, (q15_t)0x19b, (q15_t)0x195, - (q15_t)0x18e, (q15_t)0x188, (q15_t)0x182, (q15_t)0x17c, (q15_t)0x175, (q15_t)0x16f, (q15_t)0x169, (q15_t)0x162, - (q15_t)0x15c, (q15_t)0x156, (q15_t)0x150, (q15_t)0x149, (q15_t)0x143, (q15_t)0x13d, (q15_t)0x137, (q15_t)0x130, - (q15_t)0x12a, (q15_t)0x124, (q15_t)0x11d, (q15_t)0x117, (q15_t)0x111, (q15_t)0x10b, (q15_t)0x104, (q15_t)0xfe, - (q15_t)0xf8, (q15_t)0xf1, (q15_t)0xeb, (q15_t)0xe5, (q15_t)0xdf, (q15_t)0xd8, (q15_t)0xd2, (q15_t)0xcc, - (q15_t)0xc5, (q15_t)0xbf, (q15_t)0xb9, (q15_t)0xb3, (q15_t)0xac, (q15_t)0xa6, (q15_t)0xa0, (q15_t)0x99, - (q15_t)0x93, (q15_t)0x8d, (q15_t)0x87, (q15_t)0x80, (q15_t)0x7a, (q15_t)0x74, (q15_t)0x6d, (q15_t)0x67, - (q15_t)0x61, (q15_t)0x5b, (q15_t)0x54, (q15_t)0x4e, (q15_t)0x48, (q15_t)0x41, (q15_t)0x3b, (q15_t)0x35, - (q15_t)0x2f, (q15_t)0x28, (q15_t)0x22, (q15_t)0x1c, (q15_t)0x15, (q15_t)0xf, (q15_t)0x9, (q15_t)0x3 -}; + (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, + (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, + (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, + (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, + (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, + (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, + (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, + (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, (q15_t)0x7fff, + (q15_t)0x7fff, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, + (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, + (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, + (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffe, (q15_t)0x7ffd, (q15_t)0x7ffd, + (q15_t)0x7ffd, (q15_t)0x7ffd, (q15_t)0x7ffd, (q15_t)0x7ffd, (q15_t)0x7ffd, + (q15_t)0x7ffd, (q15_t)0x7ffd, (q15_t)0x7ffd, (q15_t)0x7ffd, (q15_t)0x7ffd, + (q15_t)0x7ffd, (q15_t)0x7ffc, (q15_t)0x7ffc, (q15_t)0x7ffc, (q15_t)0x7ffc, + (q15_t)0x7ffc, (q15_t)0x7ffc, (q15_t)0x7ffc, (q15_t)0x7ffc, (q15_t)0x7ffc, + (q15_t)0x7ffc, (q15_t)0x7ffb, (q15_t)0x7ffb, (q15_t)0x7ffb, (q15_t)0x7ffb, + (q15_t)0x7ffb, (q15_t)0x7ffb, (q15_t)0x7ffb, (q15_t)0x7ffb, (q15_t)0x7ffb, + (q15_t)0x7ffb, (q15_t)0x7ffa, (q15_t)0x7ffa, (q15_t)0x7ffa, (q15_t)0x7ffa, + (q15_t)0x7ffa, (q15_t)0x7ffa, (q15_t)0x7ffa, (q15_t)0x7ffa, (q15_t)0x7ffa, + (q15_t)0x7ff9, (q15_t)0x7ff9, (q15_t)0x7ff9, (q15_t)0x7ff9, (q15_t)0x7ff9, + (q15_t)0x7ff9, (q15_t)0x7ff9, (q15_t)0x7ff9, (q15_t)0x7ff8, (q15_t)0x7ff8, + (q15_t)0x7ff8, (q15_t)0x7ff8, (q15_t)0x7ff8, (q15_t)0x7ff8, (q15_t)0x7ff8, + (q15_t)0x7ff7, (q15_t)0x7ff7, (q15_t)0x7ff7, (q15_t)0x7ff7, (q15_t)0x7ff7, + (q15_t)0x7ff7, (q15_t)0x7ff7, (q15_t)0x7ff6, (q15_t)0x7ff6, (q15_t)0x7ff6, + (q15_t)0x7ff6, (q15_t)0x7ff6, (q15_t)0x7ff6, (q15_t)0x7ff6, (q15_t)0x7ff5, + (q15_t)0x7ff5, (q15_t)0x7ff5, (q15_t)0x7ff5, (q15_t)0x7ff5, (q15_t)0x7ff5, + (q15_t)0x7ff4, (q15_t)0x7ff4, (q15_t)0x7ff4, (q15_t)0x7ff4, (q15_t)0x7ff4, + (q15_t)0x7ff4, (q15_t)0x7ff3, (q15_t)0x7ff3, (q15_t)0x7ff3, (q15_t)0x7ff3, + (q15_t)0x7ff3, (q15_t)0x7ff3, (q15_t)0x7ff2, (q15_t)0x7ff2, (q15_t)0x7ff2, + (q15_t)0x7ff2, (q15_t)0x7ff2, (q15_t)0x7ff1, (q15_t)0x7ff1, (q15_t)0x7ff1, + (q15_t)0x7ff1, (q15_t)0x7ff1, (q15_t)0x7ff1, (q15_t)0x7ff0, (q15_t)0x7ff0, + (q15_t)0x7ff0, (q15_t)0x7ff0, (q15_t)0x7ff0, (q15_t)0x7fef, (q15_t)0x7fef, + (q15_t)0x7fef, (q15_t)0x7fef, (q15_t)0x7fef, (q15_t)0x7fee, (q15_t)0x7fee, + (q15_t)0x7fee, (q15_t)0x7fee, (q15_t)0x7fee, (q15_t)0x7fed, (q15_t)0x7fed, + (q15_t)0x7fed, (q15_t)0x7fed, (q15_t)0x7fed, (q15_t)0x7fec, (q15_t)0x7fec, + (q15_t)0x7fec, (q15_t)0x7fec, (q15_t)0x7feb, (q15_t)0x7feb, (q15_t)0x7feb, + (q15_t)0x7feb, (q15_t)0x7feb, (q15_t)0x7fea, (q15_t)0x7fea, (q15_t)0x7fea, + (q15_t)0x7fea, (q15_t)0x7fe9, (q15_t)0x7fe9, (q15_t)0x7fe9, (q15_t)0x7fe9, + (q15_t)0x7fe8, (q15_t)0x7fe8, (q15_t)0x7fe8, (q15_t)0x7fe8, (q15_t)0x7fe8, + (q15_t)0x7fe7, (q15_t)0x7fe7, (q15_t)0x7fe7, (q15_t)0x7fe7, (q15_t)0x7fe6, + (q15_t)0x7fe6, (q15_t)0x7fe6, (q15_t)0x7fe6, (q15_t)0x7fe5, (q15_t)0x7fe5, + (q15_t)0x7fe5, (q15_t)0x7fe5, (q15_t)0x7fe4, (q15_t)0x7fe4, (q15_t)0x7fe4, + (q15_t)0x7fe4, (q15_t)0x7fe3, (q15_t)0x7fe3, (q15_t)0x7fe3, (q15_t)0x7fe2, + (q15_t)0x7fe2, (q15_t)0x7fe2, (q15_t)0x7fe2, (q15_t)0x7fe1, (q15_t)0x7fe1, + (q15_t)0x7fe1, (q15_t)0x7fe1, (q15_t)0x7fe0, (q15_t)0x7fe0, (q15_t)0x7fe0, + (q15_t)0x7fdf, (q15_t)0x7fdf, (q15_t)0x7fdf, (q15_t)0x7fdf, (q15_t)0x7fde, + (q15_t)0x7fde, (q15_t)0x7fde, (q15_t)0x7fde, (q15_t)0x7fdd, (q15_t)0x7fdd, + (q15_t)0x7fdd, (q15_t)0x7fdc, (q15_t)0x7fdc, (q15_t)0x7fdc, (q15_t)0x7fdb, + (q15_t)0x7fdb, (q15_t)0x7fdb, (q15_t)0x7fdb, (q15_t)0x7fda, (q15_t)0x7fda, + (q15_t)0x7fda, (q15_t)0x7fd9, (q15_t)0x7fd9, (q15_t)0x7fd9, (q15_t)0x7fd8, + (q15_t)0x7fd8, (q15_t)0x7fd8, (q15_t)0x7fd8, (q15_t)0x7fd7, (q15_t)0x7fd7, + (q15_t)0x7fd7, (q15_t)0x7fd6, (q15_t)0x7fd6, (q15_t)0x7fd6, (q15_t)0x7fd5, + (q15_t)0x7fd5, (q15_t)0x7fd5, (q15_t)0x7fd4, (q15_t)0x7fd4, (q15_t)0x7fd4, + (q15_t)0x7fd3, (q15_t)0x7fd3, (q15_t)0x7fd3, (q15_t)0x7fd2, (q15_t)0x7fd2, + (q15_t)0x7fd2, (q15_t)0x7fd1, (q15_t)0x7fd1, (q15_t)0x7fd1, (q15_t)0x7fd0, + (q15_t)0x7fd0, (q15_t)0x7fd0, (q15_t)0x7fcf, (q15_t)0x7fcf, (q15_t)0x7fcf, + (q15_t)0x7fce, (q15_t)0x7fce, (q15_t)0x7fce, (q15_t)0x7fcd, (q15_t)0x7fcd, + (q15_t)0x7fcd, (q15_t)0x7fcc, (q15_t)0x7fcc, (q15_t)0x7fcc, (q15_t)0x7fcb, + (q15_t)0x7fcb, (q15_t)0x7fcb, (q15_t)0x7fca, (q15_t)0x7fca, (q15_t)0x7fc9, + (q15_t)0x7fc9, (q15_t)0x7fc9, (q15_t)0x7fc8, (q15_t)0x7fc8, (q15_t)0x7fc8, + (q15_t)0x7fc7, (q15_t)0x7fc7, (q15_t)0x7fc7, (q15_t)0x7fc6, (q15_t)0x7fc6, + (q15_t)0x7fc5, (q15_t)0x7fc5, (q15_t)0x7fc5, (q15_t)0x7fc4, (q15_t)0x7fc4, + (q15_t)0x7fc4, (q15_t)0x7fc3, (q15_t)0x7fc3, (q15_t)0x7fc2, (q15_t)0x7fc2, + (q15_t)0x7fc2, (q15_t)0x7fc1, (q15_t)0x7fc1, (q15_t)0x7fc0, (q15_t)0x7fc0, + (q15_t)0x7fc0, (q15_t)0x7fbf, (q15_t)0x7fbf, (q15_t)0x7fbf, (q15_t)0x7fbe, + (q15_t)0x7fbe, (q15_t)0x7fbd, (q15_t)0x7fbd, (q15_t)0x7fbd, (q15_t)0x7fbc, + (q15_t)0x7fbc, (q15_t)0x7fbb, (q15_t)0x7fbb, (q15_t)0x7fbb, (q15_t)0x7fba, + (q15_t)0x7fba, (q15_t)0x7fb9, (q15_t)0x7fb9, (q15_t)0x7fb8, (q15_t)0x7fb8, + (q15_t)0x7fb8, (q15_t)0x7fb7, (q15_t)0x7fb7, (q15_t)0x7fb6, (q15_t)0x7fb6, + (q15_t)0x7fb6, (q15_t)0x7fb5, (q15_t)0x7fb5, (q15_t)0x7fb4, (q15_t)0x7fb4, + (q15_t)0x7fb3, (q15_t)0x7fb3, (q15_t)0x7fb3, (q15_t)0x7fb2, (q15_t)0x7fb2, + (q15_t)0x7fb1, (q15_t)0x7fb1, (q15_t)0x7fb0, (q15_t)0x7fb0, (q15_t)0x7faf, + (q15_t)0x7faf, (q15_t)0x7faf, (q15_t)0x7fae, (q15_t)0x7fae, (q15_t)0x7fad, + (q15_t)0x7fad, (q15_t)0x7fac, (q15_t)0x7fac, (q15_t)0x7fac, (q15_t)0x7fab, + (q15_t)0x7fab, (q15_t)0x7faa, (q15_t)0x7faa, (q15_t)0x7fa9, (q15_t)0x7fa9, + (q15_t)0x7fa8, (q15_t)0x7fa8, (q15_t)0x7fa7, (q15_t)0x7fa7, (q15_t)0x7fa6, + (q15_t)0x7fa6, (q15_t)0x7fa6, (q15_t)0x7fa5, (q15_t)0x7fa5, (q15_t)0x7fa4, + (q15_t)0x7fa4, (q15_t)0x7fa3, (q15_t)0x7fa3, (q15_t)0x7fa2, (q15_t)0x7fa2, + (q15_t)0x7fa1, (q15_t)0x7fa1, (q15_t)0x7fa0, (q15_t)0x7fa0, (q15_t)0x7f9f, + (q15_t)0x7f9f, (q15_t)0x7f9e, (q15_t)0x7f9e, (q15_t)0x7f9d, (q15_t)0x7f9d, + (q15_t)0x7f9c, (q15_t)0x7f9c, (q15_t)0x7f9c, (q15_t)0x7f9b, (q15_t)0x7f9b, + (q15_t)0x7f9a, (q15_t)0x7f9a, (q15_t)0x7f99, (q15_t)0x7f99, (q15_t)0x7f98, + (q15_t)0x7f98, (q15_t)0x7f97, (q15_t)0x7f97, (q15_t)0x7f96, (q15_t)0x7f96, + (q15_t)0x7f95, (q15_t)0x7f95, (q15_t)0x7f94, (q15_t)0x7f94, (q15_t)0x7f93, + (q15_t)0x7f92, (q15_t)0x7f92, (q15_t)0x7f91, (q15_t)0x7f91, (q15_t)0x7f90, + (q15_t)0x7f90, (q15_t)0x7f8f, (q15_t)0x7f8f, (q15_t)0x7f8e, (q15_t)0x7f8e, + (q15_t)0x7f8d, (q15_t)0x7f8d, (q15_t)0x7f8c, (q15_t)0x7f8c, (q15_t)0x7f8b, + (q15_t)0x7f8b, (q15_t)0x7f8a, (q15_t)0x7f8a, (q15_t)0x7f89, (q15_t)0x7f89, + (q15_t)0x7f88, (q15_t)0x7f87, (q15_t)0x7f87, (q15_t)0x7f86, (q15_t)0x7f86, + (q15_t)0x7f85, (q15_t)0x7f85, (q15_t)0x7f84, (q15_t)0x7f84, (q15_t)0x7f83, + (q15_t)0x7f83, (q15_t)0x7f82, (q15_t)0x7f81, (q15_t)0x7f81, (q15_t)0x7f80, + (q15_t)0x7f80, (q15_t)0x7f7f, (q15_t)0x7f7f, (q15_t)0x7f7e, (q15_t)0x7f7e, + (q15_t)0x7f7d, (q15_t)0x7f7c, (q15_t)0x7f7c, (q15_t)0x7f7b, (q15_t)0x7f7b, + (q15_t)0x7f7a, (q15_t)0x7f7a, (q15_t)0x7f79, (q15_t)0x7f79, (q15_t)0x7f78, + (q15_t)0x7f77, (q15_t)0x7f77, (q15_t)0x7f76, (q15_t)0x7f76, (q15_t)0x7f75, + (q15_t)0x7f75, (q15_t)0x7f74, (q15_t)0x7f73, (q15_t)0x7f73, (q15_t)0x7f72, + (q15_t)0x7f72, (q15_t)0x7f71, (q15_t)0x7f70, (q15_t)0x7f70, (q15_t)0x7f6f, + (q15_t)0x7f6f, (q15_t)0x7f6e, (q15_t)0x7f6d, (q15_t)0x7f6d, (q15_t)0x7f6c, + (q15_t)0x7f6c, (q15_t)0x7f6b, (q15_t)0x7f6b, (q15_t)0x7f6a, (q15_t)0x7f69, + (q15_t)0x7f69, (q15_t)0x7f68, (q15_t)0x7f68, (q15_t)0x7f67, (q15_t)0x7f66, + (q15_t)0x7f66, (q15_t)0x7f65, (q15_t)0x7f64, (q15_t)0x7f64, (q15_t)0x7f63, + (q15_t)0x7f63, (q15_t)0x7f62, (q15_t)0x7f61, (q15_t)0x7f61, (q15_t)0x7f60, + (q15_t)0x7f60, (q15_t)0x7f5f, (q15_t)0x7f5e, (q15_t)0x7f5e, (q15_t)0x7f5d, + (q15_t)0x7f5c, (q15_t)0x7f5c, (q15_t)0x7f5b, (q15_t)0x7f5b, (q15_t)0x7f5a, + (q15_t)0x7f59, (q15_t)0x7f59, (q15_t)0x7f58, (q15_t)0x7f57, (q15_t)0x7f57, + (q15_t)0x7f56, (q15_t)0x7f55, (q15_t)0x7f55, (q15_t)0x7f54, (q15_t)0x7f54, + (q15_t)0x7f53, (q15_t)0x7f52, (q15_t)0x7f52, (q15_t)0x7f51, (q15_t)0x7f50, + (q15_t)0x7f50, (q15_t)0x7f4f, (q15_t)0x7f4e, (q15_t)0x7f4e, (q15_t)0x7f4d, + (q15_t)0x7f4c, (q15_t)0x7f4c, (q15_t)0x7f4b, (q15_t)0x7f4a, (q15_t)0x7f4a, + (q15_t)0x7f49, (q15_t)0x7f48, (q15_t)0x7f48, (q15_t)0x7f47, (q15_t)0x7f46, + (q15_t)0x7f46, (q15_t)0x7f45, (q15_t)0x7f44, (q15_t)0x7f44, (q15_t)0x7f43, + (q15_t)0x7f42, (q15_t)0x7f42, (q15_t)0x7f41, (q15_t)0x7f40, (q15_t)0x7f40, + (q15_t)0x7f3f, (q15_t)0x7f3e, (q15_t)0x7f3e, (q15_t)0x7f3d, (q15_t)0x7f3c, + (q15_t)0x7f3c, (q15_t)0x7f3b, (q15_t)0x7f3a, (q15_t)0x7f3a, (q15_t)0x7f39, + (q15_t)0x7f38, (q15_t)0x7f37, (q15_t)0x7f37, (q15_t)0x7f36, (q15_t)0x7f35, + (q15_t)0x7f35, (q15_t)0x7f34, (q15_t)0x7f33, (q15_t)0x7f33, (q15_t)0x7f32, + (q15_t)0x7f31, (q15_t)0x7f31, (q15_t)0x7f30, (q15_t)0x7f2f, (q15_t)0x7f2e, + (q15_t)0x7f2e, (q15_t)0x7f2d, (q15_t)0x7f2c, (q15_t)0x7f2c, (q15_t)0x7f2b, + (q15_t)0x7f2a, (q15_t)0x7f29, (q15_t)0x7f29, (q15_t)0x7f28, (q15_t)0x7f27, + (q15_t)0x7f27, (q15_t)0x7f26, (q15_t)0x7f25, (q15_t)0x7f24, (q15_t)0x7f24, + (q15_t)0x7f23, (q15_t)0x7f22, (q15_t)0x7f21, (q15_t)0x7f21, (q15_t)0x7f20, + (q15_t)0x7f1f, (q15_t)0x7f1f, (q15_t)0x7f1e, (q15_t)0x7f1d, (q15_t)0x7f1c, + (q15_t)0x7f1c, (q15_t)0x7f1b, (q15_t)0x7f1a, (q15_t)0x7f19, (q15_t)0x7f19, + (q15_t)0x7f18, (q15_t)0x7f17, (q15_t)0x7f16, (q15_t)0x7f16, (q15_t)0x7f15, + (q15_t)0x7f14, (q15_t)0x7f13, (q15_t)0x7f13, (q15_t)0x7f12, (q15_t)0x7f11, + (q15_t)0x7f10, (q15_t)0x7f10, (q15_t)0x7f0f, (q15_t)0x7f0e, (q15_t)0x7f0d, + (q15_t)0x7f0d, (q15_t)0x7f0c, (q15_t)0x7f0b, (q15_t)0x7f0a, (q15_t)0x7f09, + (q15_t)0x7f09, (q15_t)0x7f08, (q15_t)0x7f07, (q15_t)0x7f06, (q15_t)0x7f06, + (q15_t)0x7f05, (q15_t)0x7f04, (q15_t)0x7f03, (q15_t)0x7f02, (q15_t)0x7f02, + (q15_t)0x7f01, (q15_t)0x7f00, (q15_t)0x7eff, (q15_t)0x7eff, (q15_t)0x7efe, + (q15_t)0x7efd, (q15_t)0x7efc, (q15_t)0x7efb, (q15_t)0x7efb, (q15_t)0x7efa, + (q15_t)0x7ef9, (q15_t)0x7ef8, (q15_t)0x7ef7, (q15_t)0x7ef7, (q15_t)0x7ef6, + (q15_t)0x7ef5, (q15_t)0x7ef4, (q15_t)0x7ef3, (q15_t)0x7ef3, (q15_t)0x7ef2, + (q15_t)0x7ef1, (q15_t)0x7ef0, (q15_t)0x7eef, (q15_t)0x7eef, (q15_t)0x7eee, + (q15_t)0x7eed, (q15_t)0x7eec, (q15_t)0x7eeb, (q15_t)0x7eeb, (q15_t)0x7eea, + (q15_t)0x7ee9, (q15_t)0x7ee8, (q15_t)0x7ee7, (q15_t)0x7ee6, (q15_t)0x7ee6, + (q15_t)0x7ee5, (q15_t)0x7ee4, (q15_t)0x7ee3, (q15_t)0x7ee2, (q15_t)0x7ee2, + (q15_t)0x7ee1, (q15_t)0x7ee0, (q15_t)0x7edf, (q15_t)0x7ede, (q15_t)0x7edd, + (q15_t)0x7edd, (q15_t)0x7edc, (q15_t)0x7edb, (q15_t)0x7eda, (q15_t)0x7ed9, + (q15_t)0x7ed8, (q15_t)0x7ed8, (q15_t)0x7ed7, (q15_t)0x7ed6, (q15_t)0x7ed5, + (q15_t)0x7ed4, (q15_t)0x7ed3, (q15_t)0x7ed2, (q15_t)0x7ed2, (q15_t)0x7ed1, + (q15_t)0x7ed0, (q15_t)0x7ecf, (q15_t)0x7ece, (q15_t)0x7ecd, (q15_t)0x7ecc, + (q15_t)0x7ecc, (q15_t)0x7ecb, (q15_t)0x7eca, (q15_t)0x7ec9, (q15_t)0x7ec8, + (q15_t)0x7ec7, (q15_t)0x7ec6, (q15_t)0x7ec6, (q15_t)0x7ec5, (q15_t)0x7ec4, + (q15_t)0x7ec3, (q15_t)0x7ec2, (q15_t)0x7ec1, (q15_t)0x7ec0, (q15_t)0x7ebf, + (q15_t)0x7ebf, (q15_t)0x7ebe, (q15_t)0x7ebd, (q15_t)0x7ebc, (q15_t)0x7ebb, + (q15_t)0x7eba, (q15_t)0x7eb9, (q15_t)0x7eb8, (q15_t)0x7eb8, (q15_t)0x7eb7, + (q15_t)0x7eb6, (q15_t)0x7eb5, (q15_t)0x7eb4, (q15_t)0x7eb3, (q15_t)0x7eb2, + (q15_t)0x7eb1, (q15_t)0x7eb0, (q15_t)0x7eaf, (q15_t)0x7eaf, (q15_t)0x7eae, + (q15_t)0x7ead, (q15_t)0x7eac, (q15_t)0x7eab, (q15_t)0x7eaa, (q15_t)0x7ea9, + (q15_t)0x7ea8, (q15_t)0x7ea7, (q15_t)0x7ea6, (q15_t)0x7ea6, (q15_t)0x7ea5, + (q15_t)0x7ea4, (q15_t)0x7ea3, (q15_t)0x7ea2, (q15_t)0x7ea1, (q15_t)0x7ea0, + (q15_t)0x7e9f, (q15_t)0x7e9e, (q15_t)0x7e9d, (q15_t)0x7e9c, (q15_t)0x7e9b, + (q15_t)0x7e9b, (q15_t)0x7e9a, (q15_t)0x7e99, (q15_t)0x7e98, (q15_t)0x7e97, + (q15_t)0x7e96, (q15_t)0x7e95, (q15_t)0x7e94, (q15_t)0x7e93, (q15_t)0x7e92, + (q15_t)0x7e91, (q15_t)0x7e90, (q15_t)0x7e8f, (q15_t)0x7e8e, (q15_t)0x7e8d, + (q15_t)0x7e8d, (q15_t)0x7e8c, (q15_t)0x7e8b, (q15_t)0x7e8a, (q15_t)0x7e89, + (q15_t)0x7e88, (q15_t)0x7e87, (q15_t)0x7e86, (q15_t)0x7e85, (q15_t)0x7e84, + (q15_t)0x7e83, (q15_t)0x7e82, (q15_t)0x7e81, (q15_t)0x7e80, (q15_t)0x7e7f, + (q15_t)0x7e7e, (q15_t)0x7e7d, (q15_t)0x7e7c, (q15_t)0x7e7b, (q15_t)0x7e7a, + (q15_t)0x7e79, (q15_t)0x7e78, (q15_t)0x7e77, (q15_t)0x7e77, (q15_t)0x7e76, + (q15_t)0x7e75, (q15_t)0x7e74, (q15_t)0x7e73, (q15_t)0x7e72, (q15_t)0x7e71, + (q15_t)0x7e70, (q15_t)0x7e6f, (q15_t)0x7e6e, (q15_t)0x7e6d, (q15_t)0x7e6c, + (q15_t)0x7e6b, (q15_t)0x7e6a, (q15_t)0x7e69, (q15_t)0x7e68, (q15_t)0x7e67, + (q15_t)0x7e66, (q15_t)0x7e65, (q15_t)0x7e64, (q15_t)0x7e63, (q15_t)0x7e62, + (q15_t)0x7e61, (q15_t)0x7e60, (q15_t)0x7e5f, (q15_t)0x7e5e, (q15_t)0x7e5d, + (q15_t)0x7e5c, (q15_t)0x7e5b, (q15_t)0x7e5a, (q15_t)0x7e59, (q15_t)0x7e58, + (q15_t)0x7e57, (q15_t)0x7e56, (q15_t)0x7e55, (q15_t)0x7e54, (q15_t)0x7e53, + (q15_t)0x7e52, (q15_t)0x7e51, (q15_t)0x7e50, (q15_t)0x7e4f, (q15_t)0x7e4e, + (q15_t)0x7e4d, (q15_t)0x7e4c, (q15_t)0x7e4b, (q15_t)0x7e4a, (q15_t)0x7e49, + (q15_t)0x7e48, (q15_t)0x7e47, (q15_t)0x7e46, (q15_t)0x7e45, (q15_t)0x7e43, + (q15_t)0x7e42, (q15_t)0x7e41, (q15_t)0x7e40, (q15_t)0x7e3f, (q15_t)0x7e3e, + (q15_t)0x7e3d, (q15_t)0x7e3c, (q15_t)0x7e3b, (q15_t)0x7e3a, (q15_t)0x7e39, + (q15_t)0x7e38, (q15_t)0x7e37, (q15_t)0x7e36, (q15_t)0x7e35, (q15_t)0x7e34, + (q15_t)0x7e33, (q15_t)0x7e32, (q15_t)0x7e31, (q15_t)0x7e30, (q15_t)0x7e2f, + (q15_t)0x7e2e, (q15_t)0x7e2d, (q15_t)0x7e2b, (q15_t)0x7e2a, (q15_t)0x7e29, + (q15_t)0x7e28, (q15_t)0x7e27, (q15_t)0x7e26, (q15_t)0x7e25, (q15_t)0x7e24, + (q15_t)0x7e23, (q15_t)0x7e22, (q15_t)0x7e21, (q15_t)0x7e20, (q15_t)0x7e1f, + (q15_t)0x7e1e, (q15_t)0x7e1d, (q15_t)0x7e1b, (q15_t)0x7e1a, (q15_t)0x7e19, + (q15_t)0x7e18, (q15_t)0x7e17, (q15_t)0x7e16, (q15_t)0x7e15, (q15_t)0x7e14, + (q15_t)0x7e13, (q15_t)0x7e12, (q15_t)0x7e11, (q15_t)0x7e10, (q15_t)0x7e0e, + (q15_t)0x7e0d, (q15_t)0x7e0c, (q15_t)0x7e0b, (q15_t)0x7e0a, (q15_t)0x7e09, + (q15_t)0x7e08, (q15_t)0x7e07, (q15_t)0x7e06, (q15_t)0x7e05, (q15_t)0x7e04, + (q15_t)0x7e02, (q15_t)0x7e01, (q15_t)0x7e00, (q15_t)0x7dff, (q15_t)0x7dfe, + (q15_t)0x7dfd, (q15_t)0x7dfc, (q15_t)0x7dfb, (q15_t)0x7dfa, (q15_t)0x7df8, + (q15_t)0x7df7, (q15_t)0x7df6, (q15_t)0x7df5, (q15_t)0x7df4, (q15_t)0x7df3, + (q15_t)0x7df2, (q15_t)0x7df1, (q15_t)0x7def, (q15_t)0x7dee, (q15_t)0x7ded, + (q15_t)0x7dec, (q15_t)0x7deb, (q15_t)0x7dea, (q15_t)0x7de9, (q15_t)0x7de8, + (q15_t)0x7de6, (q15_t)0x7de5, (q15_t)0x7de4, (q15_t)0x7de3, (q15_t)0x7de2, + (q15_t)0x7de1, (q15_t)0x7de0, (q15_t)0x7dde, (q15_t)0x7ddd, (q15_t)0x7ddc, + (q15_t)0x7ddb, (q15_t)0x7dda, (q15_t)0x7dd9, (q15_t)0x7dd8, (q15_t)0x7dd6, + (q15_t)0x7dd5, (q15_t)0x7dd4, (q15_t)0x7dd3, (q15_t)0x7dd2, (q15_t)0x7dd1, + (q15_t)0x7dd0, (q15_t)0x7dce, (q15_t)0x7dcd, (q15_t)0x7dcc, (q15_t)0x7dcb, + (q15_t)0x7dca, (q15_t)0x7dc9, (q15_t)0x7dc7, (q15_t)0x7dc6, (q15_t)0x7dc5, + (q15_t)0x7dc4, (q15_t)0x7dc3, (q15_t)0x7dc2, (q15_t)0x7dc0, (q15_t)0x7dbf, + (q15_t)0x7dbe, (q15_t)0x7dbd, (q15_t)0x7dbc, (q15_t)0x7dbb, (q15_t)0x7db9, + (q15_t)0x7db8, (q15_t)0x7db7, (q15_t)0x7db6, (q15_t)0x7db5, (q15_t)0x7db3, + (q15_t)0x7db2, (q15_t)0x7db1, (q15_t)0x7db0, (q15_t)0x7daf, (q15_t)0x7dae, + (q15_t)0x7dac, (q15_t)0x7dab, (q15_t)0x7daa, (q15_t)0x7da9, (q15_t)0x7da8, + (q15_t)0x7da6, (q15_t)0x7da5, (q15_t)0x7da4, (q15_t)0x7da3, (q15_t)0x7da2, + (q15_t)0x7da0, (q15_t)0x7d9f, (q15_t)0x7d9e, (q15_t)0x7d9d, (q15_t)0x7d9c, + (q15_t)0x7d9a, (q15_t)0x7d99, (q15_t)0x7d98, (q15_t)0x7d97, (q15_t)0x7d95, + (q15_t)0x7d94, (q15_t)0x7d93, (q15_t)0x7d92, (q15_t)0x7d91, (q15_t)0x7d8f, + (q15_t)0x7d8e, (q15_t)0x7d8d, (q15_t)0x7d8c, (q15_t)0x7d8a, (q15_t)0x7d89, + (q15_t)0x7d88, (q15_t)0x7d87, (q15_t)0x7d86, (q15_t)0x7d84, (q15_t)0x7d83, + (q15_t)0x7d82, (q15_t)0x7d81, (q15_t)0x7d7f, (q15_t)0x7d7e, (q15_t)0x7d7d, + (q15_t)0x7d7c, (q15_t)0x7d7a, (q15_t)0x7d79, (q15_t)0x7d78, (q15_t)0x7d77, + (q15_t)0x7d75, (q15_t)0x7d74, (q15_t)0x7d73, (q15_t)0x7d72, (q15_t)0x7d70, + (q15_t)0x7d6f, (q15_t)0x7d6e, (q15_t)0x7d6d, (q15_t)0x7d6b, (q15_t)0x7d6a, + (q15_t)0x7d69, (q15_t)0x7d68, (q15_t)0x7d66, (q15_t)0x7d65, (q15_t)0x7d64, + (q15_t)0x7d63, (q15_t)0x7d61, (q15_t)0x7d60, (q15_t)0x7d5f, (q15_t)0x7d5e, + (q15_t)0x7d5c, (q15_t)0x7d5b, (q15_t)0x7d5a, (q15_t)0x7d59, (q15_t)0x7d57, + (q15_t)0x7d56, (q15_t)0x7d55, (q15_t)0x7d53, (q15_t)0x7d52, (q15_t)0x7d51, + (q15_t)0x7d50, (q15_t)0x7d4e, (q15_t)0x7d4d, (q15_t)0x7d4c, (q15_t)0x7d4a, + (q15_t)0x7d49, (q15_t)0x7d48, (q15_t)0x7d47, (q15_t)0x7d45, (q15_t)0x7d44, + (q15_t)0x7d43, (q15_t)0x7d41, (q15_t)0x7d40, (q15_t)0x7d3f, (q15_t)0x7d3e, + (q15_t)0x7d3c, (q15_t)0x7d3b, (q15_t)0x7d3a, (q15_t)0x7d38, (q15_t)0x7d37, + (q15_t)0x7d36, (q15_t)0x7d34, (q15_t)0x7d33, (q15_t)0x7d32, (q15_t)0x7d31, + (q15_t)0x7d2f, (q15_t)0x7d2e, (q15_t)0x7d2d, (q15_t)0x7d2b, (q15_t)0x7d2a, + (q15_t)0x7d29, (q15_t)0x7d27, (q15_t)0x7d26, (q15_t)0x7d25, (q15_t)0x7d23, + (q15_t)0x7d22, (q15_t)0x7d21, (q15_t)0x7d1f, (q15_t)0x7d1e, (q15_t)0x7d1d, + (q15_t)0x7d1b, (q15_t)0x7d1a, (q15_t)0x7d19, (q15_t)0x7d17, (q15_t)0x7d16, + (q15_t)0x7d15, (q15_t)0x7d13, (q15_t)0x7d12, (q15_t)0x7d11, (q15_t)0x7d0f, + (q15_t)0x7d0e, (q15_t)0x7d0d, (q15_t)0x7d0b, (q15_t)0x7d0a, (q15_t)0x7d09, + (q15_t)0x7d07, (q15_t)0x7d06, (q15_t)0x7d05, (q15_t)0x7d03, (q15_t)0x7d02, + (q15_t)0x7d01, (q15_t)0x7cff, (q15_t)0x7cfe, (q15_t)0x7cfd, (q15_t)0x7cfb, + (q15_t)0x7cfa, (q15_t)0x7cf9, (q15_t)0x7cf7, (q15_t)0x7cf6, (q15_t)0x7cf4, + (q15_t)0x7cf3, (q15_t)0x7cf2, (q15_t)0x7cf0, (q15_t)0x7cef, (q15_t)0x7cee, + (q15_t)0x7cec, (q15_t)0x7ceb, (q15_t)0x7ce9, (q15_t)0x7ce8, (q15_t)0x7ce7, + (q15_t)0x7ce5, (q15_t)0x7ce4, (q15_t)0x7ce3, (q15_t)0x7ce1, (q15_t)0x7ce0, + (q15_t)0x7cde, (q15_t)0x7cdd, (q15_t)0x7cdc, (q15_t)0x7cda, (q15_t)0x7cd9, + (q15_t)0x7cd8, (q15_t)0x7cd6, (q15_t)0x7cd5, (q15_t)0x7cd3, (q15_t)0x7cd2, + (q15_t)0x7cd1, (q15_t)0x7ccf, (q15_t)0x7cce, (q15_t)0x7ccc, (q15_t)0x7ccb, + (q15_t)0x7cca, (q15_t)0x7cc8, (q15_t)0x7cc7, (q15_t)0x7cc5, (q15_t)0x7cc4, + (q15_t)0x7cc3, (q15_t)0x7cc1, (q15_t)0x7cc0, (q15_t)0x7cbe, (q15_t)0x7cbd, + (q15_t)0x7cbc, (q15_t)0x7cba, (q15_t)0x7cb9, (q15_t)0x7cb7, (q15_t)0x7cb6, + (q15_t)0x7cb5, (q15_t)0x7cb3, (q15_t)0x7cb2, (q15_t)0x7cb0, (q15_t)0x7caf, + (q15_t)0x7cad, (q15_t)0x7cac, (q15_t)0x7cab, (q15_t)0x7ca9, (q15_t)0x7ca8, + (q15_t)0x7ca6, (q15_t)0x7ca5, (q15_t)0x7ca3, (q15_t)0x7ca2, (q15_t)0x7ca1, + (q15_t)0x7c9f, (q15_t)0x7c9e, (q15_t)0x7c9c, (q15_t)0x7c9b, (q15_t)0x7c99, + (q15_t)0x7c98, (q15_t)0x7c97, (q15_t)0x7c95, (q15_t)0x7c94, (q15_t)0x7c92, + (q15_t)0x7c91, (q15_t)0x7c8f, (q15_t)0x7c8e, (q15_t)0x7c8c, (q15_t)0x7c8b, + (q15_t)0x7c8a, (q15_t)0x7c88, (q15_t)0x7c87, (q15_t)0x7c85, (q15_t)0x7c84, + (q15_t)0x7c82, (q15_t)0x7c81, (q15_t)0x7c7f, (q15_t)0x7c7e, (q15_t)0x7c7c, + (q15_t)0x7c7b, (q15_t)0x7c79, (q15_t)0x7c78, (q15_t)0x7c77, (q15_t)0x7c75, + (q15_t)0x7c74, (q15_t)0x7c72, (q15_t)0x7c71, (q15_t)0x7c6f, (q15_t)0x7c6e, + (q15_t)0x7c6c, (q15_t)0x7c6b, (q15_t)0x7c69, (q15_t)0x7c68, (q15_t)0x7c66, + (q15_t)0x7c65, (q15_t)0x7c63, (q15_t)0x7c62, (q15_t)0x7c60, (q15_t)0x7c5f, + (q15_t)0x7c5d, (q15_t)0x7c5c, (q15_t)0x7c5a, (q15_t)0x7c59, (q15_t)0x7c58, + (q15_t)0x7c56, (q15_t)0x7c55, (q15_t)0x7c53, (q15_t)0x7c52, (q15_t)0x7c50, + (q15_t)0x7c4f, (q15_t)0x7c4d, (q15_t)0x7c4c, (q15_t)0x7c4a, (q15_t)0x7c49, + (q15_t)0x7c47, (q15_t)0x7c46, (q15_t)0x7c44, (q15_t)0x7c43, (q15_t)0x7c41, + (q15_t)0x7c3f, (q15_t)0x7c3e, (q15_t)0x7c3c, (q15_t)0x7c3b, (q15_t)0x7c39, + (q15_t)0x7c38, (q15_t)0x7c36, (q15_t)0x7c35, (q15_t)0x7c33, (q15_t)0x7c32, + (q15_t)0x7c30, (q15_t)0x7c2f, (q15_t)0x7c2d, (q15_t)0x7c2c, (q15_t)0x7c2a, + (q15_t)0x7c29, (q15_t)0x7c27, (q15_t)0x7c26, (q15_t)0x7c24, (q15_t)0x7c23, + (q15_t)0x7c21, (q15_t)0x7c20, (q15_t)0x7c1e, (q15_t)0x7c1c, (q15_t)0x7c1b, + (q15_t)0x7c19, (q15_t)0x7c18, (q15_t)0x7c16, (q15_t)0x7c15, (q15_t)0x7c13, + (q15_t)0x7c12, (q15_t)0x7c10, (q15_t)0x7c0f, (q15_t)0x7c0d, (q15_t)0x7c0b, + (q15_t)0x7c0a, (q15_t)0x7c08, (q15_t)0x7c07, (q15_t)0x7c05, (q15_t)0x7c04, + (q15_t)0x7c02, (q15_t)0x7c01, (q15_t)0x7bff, (q15_t)0x7bfd, (q15_t)0x7bfc, + (q15_t)0x7bfa, (q15_t)0x7bf9, (q15_t)0x7bf7, (q15_t)0x7bf6, (q15_t)0x7bf4, + (q15_t)0x7bf3, (q15_t)0x7bf1, (q15_t)0x7bef, (q15_t)0x7bee, (q15_t)0x7bec, + (q15_t)0x7beb, (q15_t)0x7be9, (q15_t)0x7be8, (q15_t)0x7be6, (q15_t)0x7be4, + (q15_t)0x7be3, (q15_t)0x7be1, (q15_t)0x7be0, (q15_t)0x7bde, (q15_t)0x7bdc, + (q15_t)0x7bdb, (q15_t)0x7bd9, (q15_t)0x7bd8, (q15_t)0x7bd6, (q15_t)0x7bd5, + (q15_t)0x7bd3, (q15_t)0x7bd1, (q15_t)0x7bd0, (q15_t)0x7bce, (q15_t)0x7bcd, + (q15_t)0x7bcb, (q15_t)0x7bc9, (q15_t)0x7bc8, (q15_t)0x7bc6, (q15_t)0x7bc5, + (q15_t)0x7bc3, (q15_t)0x7bc1, (q15_t)0x7bc0, (q15_t)0x7bbe, (q15_t)0x7bbd, + (q15_t)0x7bbb, (q15_t)0x7bb9, (q15_t)0x7bb8, (q15_t)0x7bb6, (q15_t)0x7bb5, + (q15_t)0x7bb3, (q15_t)0x7bb1, (q15_t)0x7bb0, (q15_t)0x7bae, (q15_t)0x7bac, + (q15_t)0x7bab, (q15_t)0x7ba9, (q15_t)0x7ba8, (q15_t)0x7ba6, (q15_t)0x7ba4, + (q15_t)0x7ba3, (q15_t)0x7ba1, (q15_t)0x7b9f, (q15_t)0x7b9e, (q15_t)0x7b9c, + (q15_t)0x7b9b, (q15_t)0x7b99, (q15_t)0x7b97, (q15_t)0x7b96, (q15_t)0x7b94, + (q15_t)0x7b92, (q15_t)0x7b91, (q15_t)0x7b8f, (q15_t)0x7b8d, (q15_t)0x7b8c, + (q15_t)0x7b8a, (q15_t)0x7b89, (q15_t)0x7b87, (q15_t)0x7b85, (q15_t)0x7b84, + (q15_t)0x7b82, (q15_t)0x7b80, (q15_t)0x7b7f, (q15_t)0x7b7d, (q15_t)0x7b7b, + (q15_t)0x7b7a, (q15_t)0x7b78, (q15_t)0x7b76, (q15_t)0x7b75, (q15_t)0x7b73, + (q15_t)0x7b71, (q15_t)0x7b70, (q15_t)0x7b6e, (q15_t)0x7b6c, (q15_t)0x7b6b, + (q15_t)0x7b69, (q15_t)0x7b67, (q15_t)0x7b66, (q15_t)0x7b64, (q15_t)0x7b62, + (q15_t)0x7b61, (q15_t)0x7b5f, (q15_t)0x7b5d, (q15_t)0x7b5c, (q15_t)0x7b5a, + (q15_t)0x7b58, (q15_t)0x7b57, (q15_t)0x7b55, (q15_t)0x7b53, (q15_t)0x7b52, + (q15_t)0x7b50, (q15_t)0x7b4e, (q15_t)0x7b4d, (q15_t)0x7b4b, (q15_t)0x7b49, + (q15_t)0x7b47, (q15_t)0x7b46, (q15_t)0x7b44, (q15_t)0x7b42, (q15_t)0x7b41, + (q15_t)0x7b3f, (q15_t)0x7b3d, (q15_t)0x7b3c, (q15_t)0x7b3a, (q15_t)0x7b38, + (q15_t)0x7b37, (q15_t)0x7b35, (q15_t)0x7b33, (q15_t)0x7b31, (q15_t)0x7b30, + (q15_t)0x7b2e, (q15_t)0x7b2c, (q15_t)0x7b2b, (q15_t)0x7b29, (q15_t)0x7b27, + (q15_t)0x7b25, (q15_t)0x7b24, (q15_t)0x7b22, (q15_t)0x7b20, (q15_t)0x7b1f, + (q15_t)0x7b1d, (q15_t)0x7b1b, (q15_t)0x7b19, (q15_t)0x7b18, (q15_t)0x7b16, + (q15_t)0x7b14, (q15_t)0x7b13, (q15_t)0x7b11, (q15_t)0x7b0f, (q15_t)0x7b0d, + (q15_t)0x7b0c, (q15_t)0x7b0a, (q15_t)0x7b08, (q15_t)0x7b06, (q15_t)0x7b05, + (q15_t)0x7b03, (q15_t)0x7b01, (q15_t)0x7aff, (q15_t)0x7afe, (q15_t)0x7afc, + (q15_t)0x7afa, (q15_t)0x7af8, (q15_t)0x7af7, (q15_t)0x7af5, (q15_t)0x7af3, + (q15_t)0x7af2, (q15_t)0x7af0, (q15_t)0x7aee, (q15_t)0x7aec, (q15_t)0x7aeb, + (q15_t)0x7ae9, (q15_t)0x7ae7, (q15_t)0x7ae5, (q15_t)0x7ae3, (q15_t)0x7ae2, + (q15_t)0x7ae0, (q15_t)0x7ade, (q15_t)0x7adc, (q15_t)0x7adb, (q15_t)0x7ad9, + (q15_t)0x7ad7, (q15_t)0x7ad5, (q15_t)0x7ad4, (q15_t)0x7ad2, (q15_t)0x7ad0, + (q15_t)0x7ace, (q15_t)0x7acd, (q15_t)0x7acb, (q15_t)0x7ac9, (q15_t)0x7ac7, + (q15_t)0x7ac5, (q15_t)0x7ac4, (q15_t)0x7ac2, (q15_t)0x7ac0, (q15_t)0x7abe, + (q15_t)0x7abd, (q15_t)0x7abb, (q15_t)0x7ab9, (q15_t)0x7ab7, (q15_t)0x7ab5, + (q15_t)0x7ab4, (q15_t)0x7ab2, (q15_t)0x7ab0, (q15_t)0x7aae, (q15_t)0x7aac, + (q15_t)0x7aab, (q15_t)0x7aa9, (q15_t)0x7aa7, (q15_t)0x7aa5, (q15_t)0x7aa3, + (q15_t)0x7aa2, (q15_t)0x7aa0, (q15_t)0x7a9e, (q15_t)0x7a9c, (q15_t)0x7a9a, + (q15_t)0x7a99, (q15_t)0x7a97, (q15_t)0x7a95, (q15_t)0x7a93, (q15_t)0x7a91, + (q15_t)0x7a90, (q15_t)0x7a8e, (q15_t)0x7a8c, (q15_t)0x7a8a, (q15_t)0x7a88, + (q15_t)0x7a87, (q15_t)0x7a85, (q15_t)0x7a83, (q15_t)0x7a81, (q15_t)0x7a7f, + (q15_t)0x7a7d, (q15_t)0x7a7c, (q15_t)0x7a7a, (q15_t)0x7a78, (q15_t)0x7a76, + (q15_t)0x7a74, (q15_t)0x7a72, (q15_t)0x7a71, (q15_t)0x7a6f, (q15_t)0x7a6d, + (q15_t)0x7a6b, (q15_t)0x7a69, (q15_t)0x7a67, (q15_t)0x7a66, (q15_t)0x7a64, + (q15_t)0x7a62, (q15_t)0x7a60, (q15_t)0x7a5e, (q15_t)0x7a5c, (q15_t)0x7a5b, + (q15_t)0x7a59, (q15_t)0x7a57, (q15_t)0x7a55, (q15_t)0x7a53, (q15_t)0x7a51, + (q15_t)0x7a4f, (q15_t)0x7a4e, (q15_t)0x7a4c, (q15_t)0x7a4a, (q15_t)0x7a48, + (q15_t)0x7a46, (q15_t)0x7a44, (q15_t)0x7a42, (q15_t)0x7a41, (q15_t)0x7a3f, + (q15_t)0x7a3d, (q15_t)0x7a3b, (q15_t)0x7a39, (q15_t)0x7a37, (q15_t)0x7a35, + (q15_t)0x7a34, (q15_t)0x7a32, (q15_t)0x7a30, (q15_t)0x7a2e, (q15_t)0x7a2c, + (q15_t)0x7a2a, (q15_t)0x7a28, (q15_t)0x7a26, (q15_t)0x7a25, (q15_t)0x7a23, + (q15_t)0x7a21, (q15_t)0x7a1f, (q15_t)0x7a1d, (q15_t)0x7a1b, (q15_t)0x7a19, + (q15_t)0x7a17, (q15_t)0x7a16, (q15_t)0x7a14, (q15_t)0x7a12, (q15_t)0x7a10, + (q15_t)0x7a0e, (q15_t)0x7a0c, (q15_t)0x7a0a, (q15_t)0x7a08, (q15_t)0x7a06, + (q15_t)0x7a04, (q15_t)0x7a03, (q15_t)0x7a01, (q15_t)0x79ff, (q15_t)0x79fd, + (q15_t)0x79fb, (q15_t)0x79f9, (q15_t)0x79f7, (q15_t)0x79f5, (q15_t)0x79f3, + (q15_t)0x79f1, (q15_t)0x79f0, (q15_t)0x79ee, (q15_t)0x79ec, (q15_t)0x79ea, + (q15_t)0x79e8, (q15_t)0x79e6, (q15_t)0x79e4, (q15_t)0x79e2, (q15_t)0x79e0, + (q15_t)0x79de, (q15_t)0x79dc, (q15_t)0x79da, (q15_t)0x79d9, (q15_t)0x79d7, + (q15_t)0x79d5, (q15_t)0x79d3, (q15_t)0x79d1, (q15_t)0x79cf, (q15_t)0x79cd, + (q15_t)0x79cb, (q15_t)0x79c9, (q15_t)0x79c7, (q15_t)0x79c5, (q15_t)0x79c3, + (q15_t)0x79c1, (q15_t)0x79bf, (q15_t)0x79bd, (q15_t)0x79bc, (q15_t)0x79ba, + (q15_t)0x79b8, (q15_t)0x79b6, (q15_t)0x79b4, (q15_t)0x79b2, (q15_t)0x79b0, + (q15_t)0x79ae, (q15_t)0x79ac, (q15_t)0x79aa, (q15_t)0x79a8, (q15_t)0x79a6, + (q15_t)0x79a4, (q15_t)0x79a2, (q15_t)0x79a0, (q15_t)0x799e, (q15_t)0x799c, + (q15_t)0x799a, (q15_t)0x7998, (q15_t)0x7996, (q15_t)0x7994, (q15_t)0x7992, + (q15_t)0x7991, (q15_t)0x798f, (q15_t)0x798d, (q15_t)0x798b, (q15_t)0x7989, + (q15_t)0x7987, (q15_t)0x7985, (q15_t)0x7983, (q15_t)0x7981, (q15_t)0x797f, + (q15_t)0x797d, (q15_t)0x797b, (q15_t)0x7979, (q15_t)0x7977, (q15_t)0x7975, + (q15_t)0x7973, (q15_t)0x7971, (q15_t)0x796f, (q15_t)0x796d, (q15_t)0x796b, + (q15_t)0x7969, (q15_t)0x7967, (q15_t)0x7965, (q15_t)0x7963, (q15_t)0x7961, + (q15_t)0x795f, (q15_t)0x795d, (q15_t)0x795b, (q15_t)0x7959, (q15_t)0x7957, + (q15_t)0x7955, (q15_t)0x7953, (q15_t)0x7951, (q15_t)0x794f, (q15_t)0x794d, + (q15_t)0x794b, (q15_t)0x7949, (q15_t)0x7947, (q15_t)0x7945, (q15_t)0x7943, + (q15_t)0x7941, (q15_t)0x793f, (q15_t)0x793d, (q15_t)0x793b, (q15_t)0x7939, + (q15_t)0x7937, (q15_t)0x7935, (q15_t)0x7933, (q15_t)0x7931, (q15_t)0x792f, + (q15_t)0x792d, (q15_t)0x792b, (q15_t)0x7929, (q15_t)0x7927, (q15_t)0x7925, + (q15_t)0x7923, (q15_t)0x7921, (q15_t)0x791f, (q15_t)0x791d, (q15_t)0x791a, + (q15_t)0x7918, (q15_t)0x7916, (q15_t)0x7914, (q15_t)0x7912, (q15_t)0x7910, + (q15_t)0x790e, (q15_t)0x790c, (q15_t)0x790a, (q15_t)0x7908, (q15_t)0x7906, + (q15_t)0x7904, (q15_t)0x7902, (q15_t)0x7900, (q15_t)0x78fe, (q15_t)0x78fc, + (q15_t)0x78fa, (q15_t)0x78f8, (q15_t)0x78f6, (q15_t)0x78f4, (q15_t)0x78f2, + (q15_t)0x78f0, (q15_t)0x78ed, (q15_t)0x78eb, (q15_t)0x78e9, (q15_t)0x78e7, + (q15_t)0x78e5, (q15_t)0x78e3, (q15_t)0x78e1, (q15_t)0x78df, (q15_t)0x78dd, + (q15_t)0x78db, (q15_t)0x78d9, (q15_t)0x78d7, (q15_t)0x78d5, (q15_t)0x78d3, + (q15_t)0x78d1, (q15_t)0x78ce, (q15_t)0x78cc, (q15_t)0x78ca, (q15_t)0x78c8, + (q15_t)0x78c6, (q15_t)0x78c4, (q15_t)0x78c2, (q15_t)0x78c0, (q15_t)0x78be, + (q15_t)0x78bc, (q15_t)0x78ba, (q15_t)0x78b8, (q15_t)0x78b5, (q15_t)0x78b3, + (q15_t)0x78b1, (q15_t)0x78af, (q15_t)0x78ad, (q15_t)0x78ab, (q15_t)0x78a9, + (q15_t)0x78a7, (q15_t)0x78a5, (q15_t)0x78a3, (q15_t)0x78a0, (q15_t)0x789e, + (q15_t)0x789c, (q15_t)0x789a, (q15_t)0x7898, (q15_t)0x7896, (q15_t)0x7894, + (q15_t)0x7892, (q15_t)0x7890, (q15_t)0x788e, (q15_t)0x788b, (q15_t)0x7889, + (q15_t)0x7887, (q15_t)0x7885, (q15_t)0x7883, (q15_t)0x7881, (q15_t)0x787f, + (q15_t)0x787d, (q15_t)0x787a, (q15_t)0x7878, (q15_t)0x7876, (q15_t)0x7874, + (q15_t)0x7872, (q15_t)0x7870, (q15_t)0x786e, (q15_t)0x786c, (q15_t)0x7869, + (q15_t)0x7867, (q15_t)0x7865, (q15_t)0x7863, (q15_t)0x7861, (q15_t)0x785f, + (q15_t)0x785d, (q15_t)0x785b, (q15_t)0x7858, (q15_t)0x7856, (q15_t)0x7854, + (q15_t)0x7852, (q15_t)0x7850, (q15_t)0x784e, (q15_t)0x784c, (q15_t)0x7849, + (q15_t)0x7847, (q15_t)0x7845, (q15_t)0x7843, (q15_t)0x7841, (q15_t)0x783f, + (q15_t)0x783c, (q15_t)0x783a, (q15_t)0x7838, (q15_t)0x7836, (q15_t)0x7834, + (q15_t)0x7832, (q15_t)0x7830, (q15_t)0x782d, (q15_t)0x782b, (q15_t)0x7829, + (q15_t)0x7827, (q15_t)0x7825, (q15_t)0x7823, (q15_t)0x7820, (q15_t)0x781e, + (q15_t)0x781c, (q15_t)0x781a, (q15_t)0x7818, (q15_t)0x7816, (q15_t)0x7813, + (q15_t)0x7811, (q15_t)0x780f, (q15_t)0x780d, (q15_t)0x780b, (q15_t)0x7808, + (q15_t)0x7806, (q15_t)0x7804, (q15_t)0x7802, (q15_t)0x7800, (q15_t)0x77fe, + (q15_t)0x77fb, (q15_t)0x77f9, (q15_t)0x77f7, (q15_t)0x77f5, (q15_t)0x77f3, + (q15_t)0x77f0, (q15_t)0x77ee, (q15_t)0x77ec, (q15_t)0x77ea, (q15_t)0x77e8, + (q15_t)0x77e5, (q15_t)0x77e3, (q15_t)0x77e1, (q15_t)0x77df, (q15_t)0x77dd, + (q15_t)0x77da, (q15_t)0x77d8, (q15_t)0x77d6, (q15_t)0x77d4, (q15_t)0x77d2, + (q15_t)0x77cf, (q15_t)0x77cd, (q15_t)0x77cb, (q15_t)0x77c9, (q15_t)0x77c6, + (q15_t)0x77c4, (q15_t)0x77c2, (q15_t)0x77c0, (q15_t)0x77be, (q15_t)0x77bb, + (q15_t)0x77b9, (q15_t)0x77b7, (q15_t)0x77b5, (q15_t)0x77b2, (q15_t)0x77b0, + (q15_t)0x77ae, (q15_t)0x77ac, (q15_t)0x77aa, (q15_t)0x77a7, (q15_t)0x77a5, + (q15_t)0x77a3, (q15_t)0x77a1, (q15_t)0x779e, (q15_t)0x779c, (q15_t)0x779a, + (q15_t)0x7798, (q15_t)0x7795, (q15_t)0x7793, (q15_t)0x7791, (q15_t)0x778f, + (q15_t)0x778c, (q15_t)0x778a, (q15_t)0x7788, (q15_t)0x7786, (q15_t)0x7783, + (q15_t)0x7781, (q15_t)0x777f, (q15_t)0x777d, (q15_t)0x777a, (q15_t)0x7778, + (q15_t)0x7776, (q15_t)0x7774, (q15_t)0x7771, (q15_t)0x776f, (q15_t)0x776d, + (q15_t)0x776b, (q15_t)0x7768, (q15_t)0x7766, (q15_t)0x7764, (q15_t)0x7762, + (q15_t)0x775f, (q15_t)0x775d, (q15_t)0x775b, (q15_t)0x7759, (q15_t)0x7756, + (q15_t)0x7754, (q15_t)0x7752, (q15_t)0x774f, (q15_t)0x774d, (q15_t)0x774b, + (q15_t)0x7749, (q15_t)0x7746, (q15_t)0x7744, (q15_t)0x7742, (q15_t)0x773f, + (q15_t)0x773d, (q15_t)0x773b, (q15_t)0x7739, (q15_t)0x7736, (q15_t)0x7734, + (q15_t)0x7732, (q15_t)0x772f, (q15_t)0x772d, (q15_t)0x772b, (q15_t)0x7729, + (q15_t)0x7726, (q15_t)0x7724, (q15_t)0x7722, (q15_t)0x771f, (q15_t)0x771d, + (q15_t)0x771b, (q15_t)0x7719, (q15_t)0x7716, (q15_t)0x7714, (q15_t)0x7712, + (q15_t)0x770f, (q15_t)0x770d, (q15_t)0x770b, (q15_t)0x7708, (q15_t)0x7706, + (q15_t)0x7704, (q15_t)0x7701, (q15_t)0x76ff, (q15_t)0x76fd, (q15_t)0x76fa, + (q15_t)0x76f8, (q15_t)0x76f6, (q15_t)0x76f4, (q15_t)0x76f1, (q15_t)0x76ef, + (q15_t)0x76ed, (q15_t)0x76ea, (q15_t)0x76e8, (q15_t)0x76e6, (q15_t)0x76e3, + (q15_t)0x76e1, (q15_t)0x76df, (q15_t)0x76dc, (q15_t)0x76da, (q15_t)0x76d8, + (q15_t)0x76d5, (q15_t)0x76d3, (q15_t)0x76d1, (q15_t)0x76ce, (q15_t)0x76cc, + (q15_t)0x76ca, (q15_t)0x76c7, (q15_t)0x76c5, (q15_t)0x76c3, (q15_t)0x76c0, + (q15_t)0x76be, (q15_t)0x76bc, (q15_t)0x76b9, (q15_t)0x76b7, (q15_t)0x76b4, + (q15_t)0x76b2, (q15_t)0x76b0, (q15_t)0x76ad, (q15_t)0x76ab, (q15_t)0x76a9, + (q15_t)0x76a6, (q15_t)0x76a4, (q15_t)0x76a2, (q15_t)0x769f, (q15_t)0x769d, + (q15_t)0x769b, (q15_t)0x7698, (q15_t)0x7696, (q15_t)0x7693, (q15_t)0x7691, + (q15_t)0x768f, (q15_t)0x768c, (q15_t)0x768a, (q15_t)0x7688, (q15_t)0x7685, + (q15_t)0x7683, (q15_t)0x7681, (q15_t)0x767e, (q15_t)0x767c, (q15_t)0x7679, + (q15_t)0x7677, (q15_t)0x7675, (q15_t)0x7672, (q15_t)0x7670, (q15_t)0x766d, + (q15_t)0x766b, (q15_t)0x7669, (q15_t)0x7666, (q15_t)0x7664, (q15_t)0x7662, + (q15_t)0x765f, (q15_t)0x765d, (q15_t)0x765a, (q15_t)0x7658, (q15_t)0x7656, + (q15_t)0x7653, (q15_t)0x7651, (q15_t)0x764e, (q15_t)0x764c, (q15_t)0x764a, + (q15_t)0x7647, (q15_t)0x7645, (q15_t)0x7642, (q15_t)0x7640, (q15_t)0x763e, + (q15_t)0x763b, (q15_t)0x7639, (q15_t)0x7636, (q15_t)0x7634, (q15_t)0x7632, + (q15_t)0x762f, (q15_t)0x762d, (q15_t)0x762a, (q15_t)0x7628, (q15_t)0x7625, + (q15_t)0x7623, (q15_t)0x7621, (q15_t)0x761e, (q15_t)0x761c, (q15_t)0x7619, + (q15_t)0x7617, (q15_t)0x7615, (q15_t)0x7612, (q15_t)0x7610, (q15_t)0x760d, + (q15_t)0x760b, (q15_t)0x7608, (q15_t)0x7606, (q15_t)0x7604, (q15_t)0x7601, + (q15_t)0x75ff, (q15_t)0x75fc, (q15_t)0x75fa, (q15_t)0x75f7, (q15_t)0x75f5, + (q15_t)0x75f2, (q15_t)0x75f0, (q15_t)0x75ee, (q15_t)0x75eb, (q15_t)0x75e9, + (q15_t)0x75e6, (q15_t)0x75e4, (q15_t)0x75e1, (q15_t)0x75df, (q15_t)0x75dc, + (q15_t)0x75da, (q15_t)0x75d8, (q15_t)0x75d5, (q15_t)0x75d3, (q15_t)0x75d0, + (q15_t)0x75ce, (q15_t)0x75cb, (q15_t)0x75c9, (q15_t)0x75c6, (q15_t)0x75c4, + (q15_t)0x75c1, (q15_t)0x75bf, (q15_t)0x75bc, (q15_t)0x75ba, (q15_t)0x75b8, + (q15_t)0x75b5, (q15_t)0x75b3, (q15_t)0x75b0, (q15_t)0x75ae, (q15_t)0x75ab, + (q15_t)0x75a9, (q15_t)0x75a6, (q15_t)0x75a4, (q15_t)0x75a1, (q15_t)0x759f, + (q15_t)0x759c, (q15_t)0x759a, (q15_t)0x7597, (q15_t)0x7595, (q15_t)0x7592, + (q15_t)0x7590, (q15_t)0x758d, (q15_t)0x758b, (q15_t)0x7588, (q15_t)0x7586, + (q15_t)0x7584, (q15_t)0x7581, (q15_t)0x757f, (q15_t)0x757c, (q15_t)0x757a, + (q15_t)0x7577, (q15_t)0x7575, (q15_t)0x7572, (q15_t)0x7570, (q15_t)0x756d, + (q15_t)0x756b, (q15_t)0x7568, (q15_t)0x7566, (q15_t)0x7563, (q15_t)0x7561, + (q15_t)0x755e, (q15_t)0x755c, (q15_t)0x7559, (q15_t)0x7556, (q15_t)0x7554, + (q15_t)0x7551, (q15_t)0x754f, (q15_t)0x754c, (q15_t)0x754a, (q15_t)0x7547, + (q15_t)0x7545, (q15_t)0x7542, (q15_t)0x7540, (q15_t)0x753d, (q15_t)0x753b, + (q15_t)0x7538, (q15_t)0x7536, (q15_t)0x7533, (q15_t)0x7531, (q15_t)0x752e, + (q15_t)0x752c, (q15_t)0x7529, (q15_t)0x7527, (q15_t)0x7524, (q15_t)0x7522, + (q15_t)0x751f, (q15_t)0x751c, (q15_t)0x751a, (q15_t)0x7517, (q15_t)0x7515, + (q15_t)0x7512, (q15_t)0x7510, (q15_t)0x750d, (q15_t)0x750b, (q15_t)0x7508, + (q15_t)0x7506, (q15_t)0x7503, (q15_t)0x7501, (q15_t)0x74fe, (q15_t)0x74fb, + (q15_t)0x74f9, (q15_t)0x74f6, (q15_t)0x74f4, (q15_t)0x74f1, (q15_t)0x74ef, + (q15_t)0x74ec, (q15_t)0x74ea, (q15_t)0x74e7, (q15_t)0x74e4, (q15_t)0x74e2, + (q15_t)0x74df, (q15_t)0x74dd, (q15_t)0x74da, (q15_t)0x74d8, (q15_t)0x74d5, + (q15_t)0x74d2, (q15_t)0x74d0, (q15_t)0x74cd, (q15_t)0x74cb, (q15_t)0x74c8, + (q15_t)0x74c6, (q15_t)0x74c3, (q15_t)0x74c0, (q15_t)0x74be, (q15_t)0x74bb, + (q15_t)0x74b9, (q15_t)0x74b6, (q15_t)0x74b4, (q15_t)0x74b1, (q15_t)0x74ae, + (q15_t)0x74ac, (q15_t)0x74a9, (q15_t)0x74a7, (q15_t)0x74a4, (q15_t)0x74a1, + (q15_t)0x749f, (q15_t)0x749c, (q15_t)0x749a, (q15_t)0x7497, (q15_t)0x7495, + (q15_t)0x7492, (q15_t)0x748f, (q15_t)0x748d, (q15_t)0x748a, (q15_t)0x7488, + (q15_t)0x7485, (q15_t)0x7482, (q15_t)0x7480, (q15_t)0x747d, (q15_t)0x747b, + (q15_t)0x7478, (q15_t)0x7475, (q15_t)0x7473, (q15_t)0x7470, (q15_t)0x746d, + (q15_t)0x746b, (q15_t)0x7468, (q15_t)0x7466, (q15_t)0x7463, (q15_t)0x7460, + (q15_t)0x745e, (q15_t)0x745b, (q15_t)0x7459, (q15_t)0x7456, (q15_t)0x7453, + (q15_t)0x7451, (q15_t)0x744e, (q15_t)0x744b, (q15_t)0x7449, (q15_t)0x7446, + (q15_t)0x7444, (q15_t)0x7441, (q15_t)0x743e, (q15_t)0x743c, (q15_t)0x7439, + (q15_t)0x7436, (q15_t)0x7434, (q15_t)0x7431, (q15_t)0x742f, (q15_t)0x742c, + (q15_t)0x7429, (q15_t)0x7427, (q15_t)0x7424, (q15_t)0x7421, (q15_t)0x741f, + (q15_t)0x741c, (q15_t)0x7419, (q15_t)0x7417, (q15_t)0x7414, (q15_t)0x7411, + (q15_t)0x740f, (q15_t)0x740c, (q15_t)0x740a, (q15_t)0x7407, (q15_t)0x7404, + (q15_t)0x7402, (q15_t)0x73ff, (q15_t)0x73fc, (q15_t)0x73fa, (q15_t)0x73f7, + (q15_t)0x73f4, (q15_t)0x73f2, (q15_t)0x73ef, (q15_t)0x73ec, (q15_t)0x73ea, + (q15_t)0x73e7, (q15_t)0x73e4, (q15_t)0x73e2, (q15_t)0x73df, (q15_t)0x73dc, + (q15_t)0x73da, (q15_t)0x73d7, (q15_t)0x73d4, (q15_t)0x73d2, (q15_t)0x73cf, + (q15_t)0x73cc, (q15_t)0x73ca, (q15_t)0x73c7, (q15_t)0x73c4, (q15_t)0x73c1, + (q15_t)0x73bf, (q15_t)0x73bc, (q15_t)0x73b9, (q15_t)0x73b7, (q15_t)0x73b4, + (q15_t)0x73b1, (q15_t)0x73af, (q15_t)0x73ac, (q15_t)0x73a9, (q15_t)0x73a7, + (q15_t)0x73a4, (q15_t)0x73a1, (q15_t)0x739f, (q15_t)0x739c, (q15_t)0x7399, + (q15_t)0x7396, (q15_t)0x7394, (q15_t)0x7391, (q15_t)0x738e, (q15_t)0x738c, + (q15_t)0x7389, (q15_t)0x7386, (q15_t)0x7384, (q15_t)0x7381, (q15_t)0x737e, + (q15_t)0x737b, (q15_t)0x7379, (q15_t)0x7376, (q15_t)0x7373, (q15_t)0x7371, + (q15_t)0x736e, (q15_t)0x736b, (q15_t)0x7368, (q15_t)0x7366, (q15_t)0x7363, + (q15_t)0x7360, (q15_t)0x735e, (q15_t)0x735b, (q15_t)0x7358, (q15_t)0x7355, + (q15_t)0x7353, (q15_t)0x7350, (q15_t)0x734d, (q15_t)0x734a, (q15_t)0x7348, + (q15_t)0x7345, (q15_t)0x7342, (q15_t)0x7340, (q15_t)0x733d, (q15_t)0x733a, + (q15_t)0x7337, (q15_t)0x7335, (q15_t)0x7332, (q15_t)0x732f, (q15_t)0x732c, + (q15_t)0x732a, (q15_t)0x7327, (q15_t)0x7324, (q15_t)0x7321, (q15_t)0x731f, + (q15_t)0x731c, (q15_t)0x7319, (q15_t)0x7316, (q15_t)0x7314, (q15_t)0x7311, + (q15_t)0x730e, (q15_t)0x730b, (q15_t)0x7309, (q15_t)0x7306, (q15_t)0x7303, + (q15_t)0x7300, (q15_t)0x72fe, (q15_t)0x72fb, (q15_t)0x72f8, (q15_t)0x72f5, + (q15_t)0x72f3, (q15_t)0x72f0, (q15_t)0x72ed, (q15_t)0x72ea, (q15_t)0x72e8, + (q15_t)0x72e5, (q15_t)0x72e2, (q15_t)0x72df, (q15_t)0x72dc, (q15_t)0x72da, + (q15_t)0x72d7, (q15_t)0x72d4, (q15_t)0x72d1, (q15_t)0x72cf, (q15_t)0x72cc, + (q15_t)0x72c9, (q15_t)0x72c6, (q15_t)0x72c3, (q15_t)0x72c1, (q15_t)0x72be, + (q15_t)0x72bb, (q15_t)0x72b8, (q15_t)0x72b5, (q15_t)0x72b3, (q15_t)0x72b0, + (q15_t)0x72ad, (q15_t)0x72aa, (q15_t)0x72a8, (q15_t)0x72a5, (q15_t)0x72a2, + (q15_t)0x729f, (q15_t)0x729c, (q15_t)0x729a, (q15_t)0x7297, (q15_t)0x7294, + (q15_t)0x7291, (q15_t)0x728e, (q15_t)0x728c, (q15_t)0x7289, (q15_t)0x7286, + (q15_t)0x7283, (q15_t)0x7280, (q15_t)0x727e, (q15_t)0x727b, (q15_t)0x7278, + (q15_t)0x7275, (q15_t)0x7272, (q15_t)0x726f, (q15_t)0x726d, (q15_t)0x726a, + (q15_t)0x7267, (q15_t)0x7264, (q15_t)0x7261, (q15_t)0x725f, (q15_t)0x725c, + (q15_t)0x7259, (q15_t)0x7256, (q15_t)0x7253, (q15_t)0x7250, (q15_t)0x724e, + (q15_t)0x724b, (q15_t)0x7248, (q15_t)0x7245, (q15_t)0x7242, (q15_t)0x723f, + (q15_t)0x723d, (q15_t)0x723a, (q15_t)0x7237, (q15_t)0x7234, (q15_t)0x7231, + (q15_t)0x722e, (q15_t)0x722c, (q15_t)0x7229, (q15_t)0x7226, (q15_t)0x7223, + (q15_t)0x7220, (q15_t)0x721d, (q15_t)0x721b, (q15_t)0x7218, (q15_t)0x7215, + (q15_t)0x7212, (q15_t)0x720f, (q15_t)0x720c, (q15_t)0x7209, (q15_t)0x7207, + (q15_t)0x7204, (q15_t)0x7201, (q15_t)0x71fe, (q15_t)0x71fb, (q15_t)0x71f8, + (q15_t)0x71f5, (q15_t)0x71f3, (q15_t)0x71f0, (q15_t)0x71ed, (q15_t)0x71ea, + (q15_t)0x71e7, (q15_t)0x71e4, (q15_t)0x71e1, (q15_t)0x71df, (q15_t)0x71dc, + (q15_t)0x71d9, (q15_t)0x71d6, (q15_t)0x71d3, (q15_t)0x71d0, (q15_t)0x71cd, + (q15_t)0x71ca, (q15_t)0x71c8, (q15_t)0x71c5, (q15_t)0x71c2, (q15_t)0x71bf, + (q15_t)0x71bc, (q15_t)0x71b9, (q15_t)0x71b6, (q15_t)0x71b3, (q15_t)0x71b0, + (q15_t)0x71ae, (q15_t)0x71ab, (q15_t)0x71a8, (q15_t)0x71a5, (q15_t)0x71a2, + (q15_t)0x719f, (q15_t)0x719c, (q15_t)0x7199, (q15_t)0x7196, (q15_t)0x7194, + (q15_t)0x7191, (q15_t)0x718e, (q15_t)0x718b, (q15_t)0x7188, (q15_t)0x7185, + (q15_t)0x7182, (q15_t)0x717f, (q15_t)0x717c, (q15_t)0x7179, (q15_t)0x7177, + (q15_t)0x7174, (q15_t)0x7171, (q15_t)0x716e, (q15_t)0x716b, (q15_t)0x7168, + (q15_t)0x7165, (q15_t)0x7162, (q15_t)0x715f, (q15_t)0x715c, (q15_t)0x7159, + (q15_t)0x7156, (q15_t)0x7154, (q15_t)0x7151, (q15_t)0x714e, (q15_t)0x714b, + (q15_t)0x7148, (q15_t)0x7145, (q15_t)0x7142, (q15_t)0x713f, (q15_t)0x713c, + (q15_t)0x7139, (q15_t)0x7136, (q15_t)0x7133, (q15_t)0x7130, (q15_t)0x712d, + (q15_t)0x712b, (q15_t)0x7128, (q15_t)0x7125, (q15_t)0x7122, (q15_t)0x711f, + (q15_t)0x711c, (q15_t)0x7119, (q15_t)0x7116, (q15_t)0x7113, (q15_t)0x7110, + (q15_t)0x710d, (q15_t)0x710a, (q15_t)0x7107, (q15_t)0x7104, (q15_t)0x7101, + (q15_t)0x70fe, (q15_t)0x70fb, (q15_t)0x70f8, (q15_t)0x70f6, (q15_t)0x70f3, + (q15_t)0x70f0, (q15_t)0x70ed, (q15_t)0x70ea, (q15_t)0x70e7, (q15_t)0x70e4, + (q15_t)0x70e1, (q15_t)0x70de, (q15_t)0x70db, (q15_t)0x70d8, (q15_t)0x70d5, + (q15_t)0x70d2, (q15_t)0x70cf, (q15_t)0x70cc, (q15_t)0x70c9, (q15_t)0x70c6, + (q15_t)0x70c3, (q15_t)0x70c0, (q15_t)0x70bd, (q15_t)0x70ba, (q15_t)0x70b7, + (q15_t)0x70b4, (q15_t)0x70b1, (q15_t)0x70ae, (q15_t)0x70ab, (q15_t)0x70a8, + (q15_t)0x70a5, (q15_t)0x70a2, (q15_t)0x709f, (q15_t)0x709c, (q15_t)0x7099, + (q15_t)0x7096, (q15_t)0x7093, (q15_t)0x7090, (q15_t)0x708d, (q15_t)0x708a, + (q15_t)0x7087, (q15_t)0x7084, (q15_t)0x7081, (q15_t)0x707e, (q15_t)0x707b, + (q15_t)0x7078, (q15_t)0x7075, (q15_t)0x7072, (q15_t)0x706f, (q15_t)0x706c, + (q15_t)0x7069, (q15_t)0x7066, (q15_t)0x7063, (q15_t)0x7060, (q15_t)0x705d, + (q15_t)0x705a, (q15_t)0x7057, (q15_t)0x7054, (q15_t)0x7051, (q15_t)0x704e, + (q15_t)0x704b, (q15_t)0x7048, (q15_t)0x7045, (q15_t)0x7042, (q15_t)0x703f, + (q15_t)0x703c, (q15_t)0x7039, (q15_t)0x7036, (q15_t)0x7033, (q15_t)0x7030, + (q15_t)0x702d, (q15_t)0x702a, (q15_t)0x7027, (q15_t)0x7024, (q15_t)0x7021, + (q15_t)0x701e, (q15_t)0x701b, (q15_t)0x7018, (q15_t)0x7015, (q15_t)0x7012, + (q15_t)0x700f, (q15_t)0x700c, (q15_t)0x7009, (q15_t)0x7006, (q15_t)0x7003, + (q15_t)0x7000, (q15_t)0x6ffd, (q15_t)0x6ffa, (q15_t)0x6ff7, (q15_t)0x6ff3, + (q15_t)0x6ff0, (q15_t)0x6fed, (q15_t)0x6fea, (q15_t)0x6fe7, (q15_t)0x6fe4, + (q15_t)0x6fe1, (q15_t)0x6fde, (q15_t)0x6fdb, (q15_t)0x6fd8, (q15_t)0x6fd5, + (q15_t)0x6fd2, (q15_t)0x6fcf, (q15_t)0x6fcc, (q15_t)0x6fc9, (q15_t)0x6fc6, + (q15_t)0x6fc3, (q15_t)0x6fc0, (q15_t)0x6fbc, (q15_t)0x6fb9, (q15_t)0x6fb6, + (q15_t)0x6fb3, (q15_t)0x6fb0, (q15_t)0x6fad, (q15_t)0x6faa, (q15_t)0x6fa7, + (q15_t)0x6fa4, (q15_t)0x6fa1, (q15_t)0x6f9e, (q15_t)0x6f9b, (q15_t)0x6f98, + (q15_t)0x6f95, (q15_t)0x6f91, (q15_t)0x6f8e, (q15_t)0x6f8b, (q15_t)0x6f88, + (q15_t)0x6f85, (q15_t)0x6f82, (q15_t)0x6f7f, (q15_t)0x6f7c, (q15_t)0x6f79, + (q15_t)0x6f76, (q15_t)0x6f73, (q15_t)0x6f70, (q15_t)0x6f6c, (q15_t)0x6f69, + (q15_t)0x6f66, (q15_t)0x6f63, (q15_t)0x6f60, (q15_t)0x6f5d, (q15_t)0x6f5a, + (q15_t)0x6f57, (q15_t)0x6f54, (q15_t)0x6f51, (q15_t)0x6f4d, (q15_t)0x6f4a, + (q15_t)0x6f47, (q15_t)0x6f44, (q15_t)0x6f41, (q15_t)0x6f3e, (q15_t)0x6f3b, + (q15_t)0x6f38, (q15_t)0x6f35, (q15_t)0x6f31, (q15_t)0x6f2e, (q15_t)0x6f2b, + (q15_t)0x6f28, (q15_t)0x6f25, (q15_t)0x6f22, (q15_t)0x6f1f, (q15_t)0x6f1c, + (q15_t)0x6f19, (q15_t)0x6f15, (q15_t)0x6f12, (q15_t)0x6f0f, (q15_t)0x6f0c, + (q15_t)0x6f09, (q15_t)0x6f06, (q15_t)0x6f03, (q15_t)0x6f00, (q15_t)0x6efc, + (q15_t)0x6ef9, (q15_t)0x6ef6, (q15_t)0x6ef3, (q15_t)0x6ef0, (q15_t)0x6eed, + (q15_t)0x6eea, (q15_t)0x6ee7, (q15_t)0x6ee3, (q15_t)0x6ee0, (q15_t)0x6edd, + (q15_t)0x6eda, (q15_t)0x6ed7, (q15_t)0x6ed4, (q15_t)0x6ed1, (q15_t)0x6ecd, + (q15_t)0x6eca, (q15_t)0x6ec7, (q15_t)0x6ec4, (q15_t)0x6ec1, (q15_t)0x6ebe, + (q15_t)0x6eba, (q15_t)0x6eb7, (q15_t)0x6eb4, (q15_t)0x6eb1, (q15_t)0x6eae, + (q15_t)0x6eab, (q15_t)0x6ea8, (q15_t)0x6ea4, (q15_t)0x6ea1, (q15_t)0x6e9e, + (q15_t)0x6e9b, (q15_t)0x6e98, (q15_t)0x6e95, (q15_t)0x6e91, (q15_t)0x6e8e, + (q15_t)0x6e8b, (q15_t)0x6e88, (q15_t)0x6e85, (q15_t)0x6e82, (q15_t)0x6e7e, + (q15_t)0x6e7b, (q15_t)0x6e78, (q15_t)0x6e75, (q15_t)0x6e72, (q15_t)0x6e6f, + (q15_t)0x6e6b, (q15_t)0x6e68, (q15_t)0x6e65, (q15_t)0x6e62, (q15_t)0x6e5f, + (q15_t)0x6e5b, (q15_t)0x6e58, (q15_t)0x6e55, (q15_t)0x6e52, (q15_t)0x6e4f, + (q15_t)0x6e4c, (q15_t)0x6e48, (q15_t)0x6e45, (q15_t)0x6e42, (q15_t)0x6e3f, + (q15_t)0x6e3c, (q15_t)0x6e38, (q15_t)0x6e35, (q15_t)0x6e32, (q15_t)0x6e2f, + (q15_t)0x6e2c, (q15_t)0x6e28, (q15_t)0x6e25, (q15_t)0x6e22, (q15_t)0x6e1f, + (q15_t)0x6e1c, (q15_t)0x6e18, (q15_t)0x6e15, (q15_t)0x6e12, (q15_t)0x6e0f, + (q15_t)0x6e0c, (q15_t)0x6e08, (q15_t)0x6e05, (q15_t)0x6e02, (q15_t)0x6dff, + (q15_t)0x6dfb, (q15_t)0x6df8, (q15_t)0x6df5, (q15_t)0x6df2, (q15_t)0x6def, + (q15_t)0x6deb, (q15_t)0x6de8, (q15_t)0x6de5, (q15_t)0x6de2, (q15_t)0x6ddf, + (q15_t)0x6ddb, (q15_t)0x6dd8, (q15_t)0x6dd5, (q15_t)0x6dd2, (q15_t)0x6dce, + (q15_t)0x6dcb, (q15_t)0x6dc8, (q15_t)0x6dc5, (q15_t)0x6dc1, (q15_t)0x6dbe, + (q15_t)0x6dbb, (q15_t)0x6db8, (q15_t)0x6db5, (q15_t)0x6db1, (q15_t)0x6dae, + (q15_t)0x6dab, (q15_t)0x6da8, (q15_t)0x6da4, (q15_t)0x6da1, (q15_t)0x6d9e, + (q15_t)0x6d9b, (q15_t)0x6d97, (q15_t)0x6d94, (q15_t)0x6d91, (q15_t)0x6d8e, + (q15_t)0x6d8a, (q15_t)0x6d87, (q15_t)0x6d84, (q15_t)0x6d81, (q15_t)0x6d7d, + (q15_t)0x6d7a, (q15_t)0x6d77, (q15_t)0x6d74, (q15_t)0x6d70, (q15_t)0x6d6d, + (q15_t)0x6d6a, (q15_t)0x6d67, (q15_t)0x6d63, (q15_t)0x6d60, (q15_t)0x6d5d, + (q15_t)0x6d59, (q15_t)0x6d56, (q15_t)0x6d53, (q15_t)0x6d50, (q15_t)0x6d4c, + (q15_t)0x6d49, (q15_t)0x6d46, (q15_t)0x6d43, (q15_t)0x6d3f, (q15_t)0x6d3c, + (q15_t)0x6d39, (q15_t)0x6d36, (q15_t)0x6d32, (q15_t)0x6d2f, (q15_t)0x6d2c, + (q15_t)0x6d28, (q15_t)0x6d25, (q15_t)0x6d22, (q15_t)0x6d1f, (q15_t)0x6d1b, + (q15_t)0x6d18, (q15_t)0x6d15, (q15_t)0x6d11, (q15_t)0x6d0e, (q15_t)0x6d0b, + (q15_t)0x6d08, (q15_t)0x6d04, (q15_t)0x6d01, (q15_t)0x6cfe, (q15_t)0x6cfa, + (q15_t)0x6cf7, (q15_t)0x6cf4, (q15_t)0x6cf0, (q15_t)0x6ced, (q15_t)0x6cea, + (q15_t)0x6ce7, (q15_t)0x6ce3, (q15_t)0x6ce0, (q15_t)0x6cdd, (q15_t)0x6cd9, + (q15_t)0x6cd6, (q15_t)0x6cd3, (q15_t)0x6ccf, (q15_t)0x6ccc, (q15_t)0x6cc9, + (q15_t)0x6cc5, (q15_t)0x6cc2, (q15_t)0x6cbf, (q15_t)0x6cbc, (q15_t)0x6cb8, + (q15_t)0x6cb5, (q15_t)0x6cb2, (q15_t)0x6cae, (q15_t)0x6cab, (q15_t)0x6ca8, + (q15_t)0x6ca4, (q15_t)0x6ca1, (q15_t)0x6c9e, (q15_t)0x6c9a, (q15_t)0x6c97, + (q15_t)0x6c94, (q15_t)0x6c90, (q15_t)0x6c8d, (q15_t)0x6c8a, (q15_t)0x6c86, + (q15_t)0x6c83, (q15_t)0x6c80, (q15_t)0x6c7c, (q15_t)0x6c79, (q15_t)0x6c76, + (q15_t)0x6c72, (q15_t)0x6c6f, (q15_t)0x6c6c, (q15_t)0x6c68, (q15_t)0x6c65, + (q15_t)0x6c62, (q15_t)0x6c5e, (q15_t)0x6c5b, (q15_t)0x6c58, (q15_t)0x6c54, + (q15_t)0x6c51, (q15_t)0x6c4e, (q15_t)0x6c4a, (q15_t)0x6c47, (q15_t)0x6c44, + (q15_t)0x6c40, (q15_t)0x6c3d, (q15_t)0x6c39, (q15_t)0x6c36, (q15_t)0x6c33, + (q15_t)0x6c2f, (q15_t)0x6c2c, (q15_t)0x6c29, (q15_t)0x6c25, (q15_t)0x6c22, + (q15_t)0x6c1f, (q15_t)0x6c1b, (q15_t)0x6c18, (q15_t)0x6c15, (q15_t)0x6c11, + (q15_t)0x6c0e, (q15_t)0x6c0a, (q15_t)0x6c07, (q15_t)0x6c04, (q15_t)0x6c00, + (q15_t)0x6bfd, (q15_t)0x6bfa, (q15_t)0x6bf6, (q15_t)0x6bf3, (q15_t)0x6bef, + (q15_t)0x6bec, (q15_t)0x6be9, (q15_t)0x6be5, (q15_t)0x6be2, (q15_t)0x6bdf, + (q15_t)0x6bdb, (q15_t)0x6bd8, (q15_t)0x6bd4, (q15_t)0x6bd1, (q15_t)0x6bce, + (q15_t)0x6bca, (q15_t)0x6bc7, (q15_t)0x6bc3, (q15_t)0x6bc0, (q15_t)0x6bbd, + (q15_t)0x6bb9, (q15_t)0x6bb6, (q15_t)0x6bb2, (q15_t)0x6baf, (q15_t)0x6bac, + (q15_t)0x6ba8, (q15_t)0x6ba5, (q15_t)0x6ba1, (q15_t)0x6b9e, (q15_t)0x6b9b, + (q15_t)0x6b97, (q15_t)0x6b94, (q15_t)0x6b90, (q15_t)0x6b8d, (q15_t)0x6b8a, + (q15_t)0x6b86, (q15_t)0x6b83, (q15_t)0x6b7f, (q15_t)0x6b7c, (q15_t)0x6b79, + (q15_t)0x6b75, (q15_t)0x6b72, (q15_t)0x6b6e, (q15_t)0x6b6b, (q15_t)0x6b68, + (q15_t)0x6b64, (q15_t)0x6b61, (q15_t)0x6b5d, (q15_t)0x6b5a, (q15_t)0x6b56, + (q15_t)0x6b53, (q15_t)0x6b50, (q15_t)0x6b4c, (q15_t)0x6b49, (q15_t)0x6b45, + (q15_t)0x6b42, (q15_t)0x6b3e, (q15_t)0x6b3b, (q15_t)0x6b38, (q15_t)0x6b34, + (q15_t)0x6b31, (q15_t)0x6b2d, (q15_t)0x6b2a, (q15_t)0x6b26, (q15_t)0x6b23, + (q15_t)0x6b20, (q15_t)0x6b1c, (q15_t)0x6b19, (q15_t)0x6b15, (q15_t)0x6b12, + (q15_t)0x6b0e, (q15_t)0x6b0b, (q15_t)0x6b07, (q15_t)0x6b04, (q15_t)0x6b01, + (q15_t)0x6afd, (q15_t)0x6afa, (q15_t)0x6af6, (q15_t)0x6af3, (q15_t)0x6aef, + (q15_t)0x6aec, (q15_t)0x6ae8, (q15_t)0x6ae5, (q15_t)0x6ae1, (q15_t)0x6ade, + (q15_t)0x6adb, (q15_t)0x6ad7, (q15_t)0x6ad4, (q15_t)0x6ad0, (q15_t)0x6acd, + (q15_t)0x6ac9, (q15_t)0x6ac6, (q15_t)0x6ac2, (q15_t)0x6abf, (q15_t)0x6abb, + (q15_t)0x6ab8, (q15_t)0x6ab4, (q15_t)0x6ab1, (q15_t)0x6aae, (q15_t)0x6aaa, + (q15_t)0x6aa7, (q15_t)0x6aa3, (q15_t)0x6aa0, (q15_t)0x6a9c, (q15_t)0x6a99, + (q15_t)0x6a95, (q15_t)0x6a92, (q15_t)0x6a8e, (q15_t)0x6a8b, (q15_t)0x6a87, + (q15_t)0x6a84, (q15_t)0x6a80, (q15_t)0x6a7d, (q15_t)0x6a79, (q15_t)0x6a76, + (q15_t)0x6a72, (q15_t)0x6a6f, (q15_t)0x6a6b, (q15_t)0x6a68, (q15_t)0x6a64, + (q15_t)0x6a61, (q15_t)0x6a5d, (q15_t)0x6a5a, (q15_t)0x6a56, (q15_t)0x6a53, + (q15_t)0x6a4f, (q15_t)0x6a4c, (q15_t)0x6a48, (q15_t)0x6a45, (q15_t)0x6a41, + (q15_t)0x6a3e, (q15_t)0x6a3a, (q15_t)0x6a37, (q15_t)0x6a33, (q15_t)0x6a30, + (q15_t)0x6a2c, (q15_t)0x6a29, (q15_t)0x6a25, (q15_t)0x6a22, (q15_t)0x6a1e, + (q15_t)0x6a1b, (q15_t)0x6a17, (q15_t)0x6a14, (q15_t)0x6a10, (q15_t)0x6a0d, + (q15_t)0x6a09, (q15_t)0x6a06, (q15_t)0x6a02, (q15_t)0x69ff, (q15_t)0x69fb, + (q15_t)0x69f8, (q15_t)0x69f4, (q15_t)0x69f1, (q15_t)0x69ed, (q15_t)0x69e9, + (q15_t)0x69e6, (q15_t)0x69e2, (q15_t)0x69df, (q15_t)0x69db, (q15_t)0x69d8, + (q15_t)0x69d4, (q15_t)0x69d1, (q15_t)0x69cd, (q15_t)0x69ca, (q15_t)0x69c6, + (q15_t)0x69c3, (q15_t)0x69bf, (q15_t)0x69bc, (q15_t)0x69b8, (q15_t)0x69b4, + (q15_t)0x69b1, (q15_t)0x69ad, (q15_t)0x69aa, (q15_t)0x69a6, (q15_t)0x69a3, + (q15_t)0x699f, (q15_t)0x699c, (q15_t)0x6998, (q15_t)0x6995, (q15_t)0x6991, + (q15_t)0x698d, (q15_t)0x698a, (q15_t)0x6986, (q15_t)0x6983, (q15_t)0x697f, + (q15_t)0x697c, (q15_t)0x6978, (q15_t)0x6975, (q15_t)0x6971, (q15_t)0x696d, + (q15_t)0x696a, (q15_t)0x6966, (q15_t)0x6963, (q15_t)0x695f, (q15_t)0x695c, + (q15_t)0x6958, (q15_t)0x6954, (q15_t)0x6951, (q15_t)0x694d, (q15_t)0x694a, + (q15_t)0x6946, (q15_t)0x6943, (q15_t)0x693f, (q15_t)0x693b, (q15_t)0x6938, + (q15_t)0x6934, (q15_t)0x6931, (q15_t)0x692d, (q15_t)0x692a, (q15_t)0x6926, + (q15_t)0x6922, (q15_t)0x691f, (q15_t)0x691b, (q15_t)0x6918, (q15_t)0x6914, + (q15_t)0x6910, (q15_t)0x690d, (q15_t)0x6909, (q15_t)0x6906, (q15_t)0x6902, + (q15_t)0x68fe, (q15_t)0x68fb, (q15_t)0x68f7, (q15_t)0x68f4, (q15_t)0x68f0, + (q15_t)0x68ec, (q15_t)0x68e9, (q15_t)0x68e5, (q15_t)0x68e2, (q15_t)0x68de, + (q15_t)0x68da, (q15_t)0x68d7, (q15_t)0x68d3, (q15_t)0x68d0, (q15_t)0x68cc, + (q15_t)0x68c8, (q15_t)0x68c5, (q15_t)0x68c1, (q15_t)0x68be, (q15_t)0x68ba, + (q15_t)0x68b6, (q15_t)0x68b3, (q15_t)0x68af, (q15_t)0x68ac, (q15_t)0x68a8, + (q15_t)0x68a4, (q15_t)0x68a1, (q15_t)0x689d, (q15_t)0x6899, (q15_t)0x6896, + (q15_t)0x6892, (q15_t)0x688f, (q15_t)0x688b, (q15_t)0x6887, (q15_t)0x6884, + (q15_t)0x6880, (q15_t)0x687c, (q15_t)0x6879, (q15_t)0x6875, (q15_t)0x6872, + (q15_t)0x686e, (q15_t)0x686a, (q15_t)0x6867, (q15_t)0x6863, (q15_t)0x685f, + (q15_t)0x685c, (q15_t)0x6858, (q15_t)0x6854, (q15_t)0x6851, (q15_t)0x684d, + (q15_t)0x684a, (q15_t)0x6846, (q15_t)0x6842, (q15_t)0x683f, (q15_t)0x683b, + (q15_t)0x6837, (q15_t)0x6834, (q15_t)0x6830, (q15_t)0x682c, (q15_t)0x6829, + (q15_t)0x6825, (q15_t)0x6821, (q15_t)0x681e, (q15_t)0x681a, (q15_t)0x6816, + (q15_t)0x6813, (q15_t)0x680f, (q15_t)0x680b, (q15_t)0x6808, (q15_t)0x6804, + (q15_t)0x6800, (q15_t)0x67fd, (q15_t)0x67f9, (q15_t)0x67f5, (q15_t)0x67f2, + (q15_t)0x67ee, (q15_t)0x67ea, (q15_t)0x67e7, (q15_t)0x67e3, (q15_t)0x67df, + (q15_t)0x67dc, (q15_t)0x67d8, (q15_t)0x67d4, (q15_t)0x67d1, (q15_t)0x67cd, + (q15_t)0x67c9, (q15_t)0x67c6, (q15_t)0x67c2, (q15_t)0x67be, (q15_t)0x67bb, + (q15_t)0x67b7, (q15_t)0x67b3, (q15_t)0x67b0, (q15_t)0x67ac, (q15_t)0x67a8, + (q15_t)0x67a5, (q15_t)0x67a1, (q15_t)0x679d, (q15_t)0x679a, (q15_t)0x6796, + (q15_t)0x6792, (q15_t)0x678e, (q15_t)0x678b, (q15_t)0x6787, (q15_t)0x6783, + (q15_t)0x6780, (q15_t)0x677c, (q15_t)0x6778, (q15_t)0x6775, (q15_t)0x6771, + (q15_t)0x676d, (q15_t)0x6769, (q15_t)0x6766, (q15_t)0x6762, (q15_t)0x675e, + (q15_t)0x675b, (q15_t)0x6757, (q15_t)0x6753, (q15_t)0x6750, (q15_t)0x674c, + (q15_t)0x6748, (q15_t)0x6744, (q15_t)0x6741, (q15_t)0x673d, (q15_t)0x6739, + (q15_t)0x6736, (q15_t)0x6732, (q15_t)0x672e, (q15_t)0x672a, (q15_t)0x6727, + (q15_t)0x6723, (q15_t)0x671f, (q15_t)0x671c, (q15_t)0x6718, (q15_t)0x6714, + (q15_t)0x6710, (q15_t)0x670d, (q15_t)0x6709, (q15_t)0x6705, (q15_t)0x6701, + (q15_t)0x66fe, (q15_t)0x66fa, (q15_t)0x66f6, (q15_t)0x66f3, (q15_t)0x66ef, + (q15_t)0x66eb, (q15_t)0x66e7, (q15_t)0x66e4, (q15_t)0x66e0, (q15_t)0x66dc, + (q15_t)0x66d8, (q15_t)0x66d5, (q15_t)0x66d1, (q15_t)0x66cd, (q15_t)0x66c9, + (q15_t)0x66c6, (q15_t)0x66c2, (q15_t)0x66be, (q15_t)0x66ba, (q15_t)0x66b7, + (q15_t)0x66b3, (q15_t)0x66af, (q15_t)0x66ab, (q15_t)0x66a8, (q15_t)0x66a4, + (q15_t)0x66a0, (q15_t)0x669c, (q15_t)0x6699, (q15_t)0x6695, (q15_t)0x6691, + (q15_t)0x668d, (q15_t)0x668a, (q15_t)0x6686, (q15_t)0x6682, (q15_t)0x667e, + (q15_t)0x667b, (q15_t)0x6677, (q15_t)0x6673, (q15_t)0x666f, (q15_t)0x666b, + (q15_t)0x6668, (q15_t)0x6664, (q15_t)0x6660, (q15_t)0x665c, (q15_t)0x6659, + (q15_t)0x6655, (q15_t)0x6651, (q15_t)0x664d, (q15_t)0x664a, (q15_t)0x6646, + (q15_t)0x6642, (q15_t)0x663e, (q15_t)0x663a, (q15_t)0x6637, (q15_t)0x6633, + (q15_t)0x662f, (q15_t)0x662b, (q15_t)0x6627, (q15_t)0x6624, (q15_t)0x6620, + (q15_t)0x661c, (q15_t)0x6618, (q15_t)0x6615, (q15_t)0x6611, (q15_t)0x660d, + (q15_t)0x6609, (q15_t)0x6605, (q15_t)0x6602, (q15_t)0x65fe, (q15_t)0x65fa, + (q15_t)0x65f6, (q15_t)0x65f2, (q15_t)0x65ef, (q15_t)0x65eb, (q15_t)0x65e7, + (q15_t)0x65e3, (q15_t)0x65df, (q15_t)0x65dc, (q15_t)0x65d8, (q15_t)0x65d4, + (q15_t)0x65d0, (q15_t)0x65cc, (q15_t)0x65c9, (q15_t)0x65c5, (q15_t)0x65c1, + (q15_t)0x65bd, (q15_t)0x65b9, (q15_t)0x65b5, (q15_t)0x65b2, (q15_t)0x65ae, + (q15_t)0x65aa, (q15_t)0x65a6, (q15_t)0x65a2, (q15_t)0x659f, (q15_t)0x659b, + (q15_t)0x6597, (q15_t)0x6593, (q15_t)0x658f, (q15_t)0x658b, (q15_t)0x6588, + (q15_t)0x6584, (q15_t)0x6580, (q15_t)0x657c, (q15_t)0x6578, (q15_t)0x6574, + (q15_t)0x6571, (q15_t)0x656d, (q15_t)0x6569, (q15_t)0x6565, (q15_t)0x6561, + (q15_t)0x655d, (q15_t)0x655a, (q15_t)0x6556, (q15_t)0x6552, (q15_t)0x654e, + (q15_t)0x654a, (q15_t)0x6546, (q15_t)0x6543, (q15_t)0x653f, (q15_t)0x653b, + (q15_t)0x6537, (q15_t)0x6533, (q15_t)0x652f, (q15_t)0x652c, (q15_t)0x6528, + (q15_t)0x6524, (q15_t)0x6520, (q15_t)0x651c, (q15_t)0x6518, (q15_t)0x6514, + (q15_t)0x6511, (q15_t)0x650d, (q15_t)0x6509, (q15_t)0x6505, (q15_t)0x6501, + (q15_t)0x64fd, (q15_t)0x64f9, (q15_t)0x64f6, (q15_t)0x64f2, (q15_t)0x64ee, + (q15_t)0x64ea, (q15_t)0x64e6, (q15_t)0x64e2, (q15_t)0x64de, (q15_t)0x64db, + (q15_t)0x64d7, (q15_t)0x64d3, (q15_t)0x64cf, (q15_t)0x64cb, (q15_t)0x64c7, + (q15_t)0x64c3, (q15_t)0x64bf, (q15_t)0x64bc, (q15_t)0x64b8, (q15_t)0x64b4, + (q15_t)0x64b0, (q15_t)0x64ac, (q15_t)0x64a8, (q15_t)0x64a4, (q15_t)0x64a0, + (q15_t)0x649c, (q15_t)0x6499, (q15_t)0x6495, (q15_t)0x6491, (q15_t)0x648d, + (q15_t)0x6489, (q15_t)0x6485, (q15_t)0x6481, (q15_t)0x647d, (q15_t)0x6479, + (q15_t)0x6476, (q15_t)0x6472, (q15_t)0x646e, (q15_t)0x646a, (q15_t)0x6466, + (q15_t)0x6462, (q15_t)0x645e, (q15_t)0x645a, (q15_t)0x6456, (q15_t)0x6453, + (q15_t)0x644f, (q15_t)0x644b, (q15_t)0x6447, (q15_t)0x6443, (q15_t)0x643f, + (q15_t)0x643b, (q15_t)0x6437, (q15_t)0x6433, (q15_t)0x642f, (q15_t)0x642b, + (q15_t)0x6428, (q15_t)0x6424, (q15_t)0x6420, (q15_t)0x641c, (q15_t)0x6418, + (q15_t)0x6414, (q15_t)0x6410, (q15_t)0x640c, (q15_t)0x6408, (q15_t)0x6404, + (q15_t)0x6400, (q15_t)0x63fc, (q15_t)0x63f9, (q15_t)0x63f5, (q15_t)0x63f1, + (q15_t)0x63ed, (q15_t)0x63e9, (q15_t)0x63e5, (q15_t)0x63e1, (q15_t)0x63dd, + (q15_t)0x63d9, (q15_t)0x63d5, (q15_t)0x63d1, (q15_t)0x63cd, (q15_t)0x63c9, + (q15_t)0x63c5, (q15_t)0x63c1, (q15_t)0x63be, (q15_t)0x63ba, (q15_t)0x63b6, + (q15_t)0x63b2, (q15_t)0x63ae, (q15_t)0x63aa, (q15_t)0x63a6, (q15_t)0x63a2, + (q15_t)0x639e, (q15_t)0x639a, (q15_t)0x6396, (q15_t)0x6392, (q15_t)0x638e, + (q15_t)0x638a, (q15_t)0x6386, (q15_t)0x6382, (q15_t)0x637e, (q15_t)0x637a, + (q15_t)0x6377, (q15_t)0x6373, (q15_t)0x636f, (q15_t)0x636b, (q15_t)0x6367, + (q15_t)0x6363, (q15_t)0x635f, (q15_t)0x635b, (q15_t)0x6357, (q15_t)0x6353, + (q15_t)0x634f, (q15_t)0x634b, (q15_t)0x6347, (q15_t)0x6343, (q15_t)0x633f, + (q15_t)0x633b, (q15_t)0x6337, (q15_t)0x6333, (q15_t)0x632f, (q15_t)0x632b, + (q15_t)0x6327, (q15_t)0x6323, (q15_t)0x631f, (q15_t)0x631b, (q15_t)0x6317, + (q15_t)0x6313, (q15_t)0x630f, (q15_t)0x630b, (q15_t)0x6307, (q15_t)0x6303, + (q15_t)0x62ff, (q15_t)0x62fb, (q15_t)0x62f7, (q15_t)0x62f3, (q15_t)0x62f0, + (q15_t)0x62ec, (q15_t)0x62e8, (q15_t)0x62e4, (q15_t)0x62e0, (q15_t)0x62dc, + (q15_t)0x62d8, (q15_t)0x62d4, (q15_t)0x62d0, (q15_t)0x62cc, (q15_t)0x62c8, + (q15_t)0x62c4, (q15_t)0x62c0, (q15_t)0x62bc, (q15_t)0x62b8, (q15_t)0x62b4, + (q15_t)0x62b0, (q15_t)0x62ac, (q15_t)0x62a8, (q15_t)0x62a4, (q15_t)0x62a0, + (q15_t)0x629c, (q15_t)0x6298, (q15_t)0x6294, (q15_t)0x6290, (q15_t)0x628c, + (q15_t)0x6288, (q15_t)0x6284, (q15_t)0x6280, (q15_t)0x627c, (q15_t)0x6278, + (q15_t)0x6273, (q15_t)0x626f, (q15_t)0x626b, (q15_t)0x6267, (q15_t)0x6263, + (q15_t)0x625f, (q15_t)0x625b, (q15_t)0x6257, (q15_t)0x6253, (q15_t)0x624f, + (q15_t)0x624b, (q15_t)0x6247, (q15_t)0x6243, (q15_t)0x623f, (q15_t)0x623b, + (q15_t)0x6237, (q15_t)0x6233, (q15_t)0x622f, (q15_t)0x622b, (q15_t)0x6227, + (q15_t)0x6223, (q15_t)0x621f, (q15_t)0x621b, (q15_t)0x6217, (q15_t)0x6213, + (q15_t)0x620f, (q15_t)0x620b, (q15_t)0x6207, (q15_t)0x6203, (q15_t)0x61ff, + (q15_t)0x61fb, (q15_t)0x61f7, (q15_t)0x61f3, (q15_t)0x61ee, (q15_t)0x61ea, + (q15_t)0x61e6, (q15_t)0x61e2, (q15_t)0x61de, (q15_t)0x61da, (q15_t)0x61d6, + (q15_t)0x61d2, (q15_t)0x61ce, (q15_t)0x61ca, (q15_t)0x61c6, (q15_t)0x61c2, + (q15_t)0x61be, (q15_t)0x61ba, (q15_t)0x61b6, (q15_t)0x61b2, (q15_t)0x61ae, + (q15_t)0x61aa, (q15_t)0x61a6, (q15_t)0x61a1, (q15_t)0x619d, (q15_t)0x6199, + (q15_t)0x6195, (q15_t)0x6191, (q15_t)0x618d, (q15_t)0x6189, (q15_t)0x6185, + (q15_t)0x6181, (q15_t)0x617d, (q15_t)0x6179, (q15_t)0x6175, (q15_t)0x6171, + (q15_t)0x616d, (q15_t)0x6168, (q15_t)0x6164, (q15_t)0x6160, (q15_t)0x615c, + (q15_t)0x6158, (q15_t)0x6154, (q15_t)0x6150, (q15_t)0x614c, (q15_t)0x6148, + (q15_t)0x6144, (q15_t)0x6140, (q15_t)0x613c, (q15_t)0x6137, (q15_t)0x6133, + (q15_t)0x612f, (q15_t)0x612b, (q15_t)0x6127, (q15_t)0x6123, (q15_t)0x611f, + (q15_t)0x611b, (q15_t)0x6117, (q15_t)0x6113, (q15_t)0x610f, (q15_t)0x610a, + (q15_t)0x6106, (q15_t)0x6102, (q15_t)0x60fe, (q15_t)0x60fa, (q15_t)0x60f6, + (q15_t)0x60f2, (q15_t)0x60ee, (q15_t)0x60ea, (q15_t)0x60e6, (q15_t)0x60e1, + (q15_t)0x60dd, (q15_t)0x60d9, (q15_t)0x60d5, (q15_t)0x60d1, (q15_t)0x60cd, + (q15_t)0x60c9, (q15_t)0x60c5, (q15_t)0x60c1, (q15_t)0x60bc, (q15_t)0x60b8, + (q15_t)0x60b4, (q15_t)0x60b0, (q15_t)0x60ac, (q15_t)0x60a8, (q15_t)0x60a4, + (q15_t)0x60a0, (q15_t)0x609c, (q15_t)0x6097, (q15_t)0x6093, (q15_t)0x608f, + (q15_t)0x608b, (q15_t)0x6087, (q15_t)0x6083, (q15_t)0x607f, (q15_t)0x607b, + (q15_t)0x6076, (q15_t)0x6072, (q15_t)0x606e, (q15_t)0x606a, (q15_t)0x6066, + (q15_t)0x6062, (q15_t)0x605e, (q15_t)0x6059, (q15_t)0x6055, (q15_t)0x6051, + (q15_t)0x604d, (q15_t)0x6049, (q15_t)0x6045, (q15_t)0x6041, (q15_t)0x603c, + (q15_t)0x6038, (q15_t)0x6034, (q15_t)0x6030, (q15_t)0x602c, (q15_t)0x6028, + (q15_t)0x6024, (q15_t)0x601f, (q15_t)0x601b, (q15_t)0x6017, (q15_t)0x6013, + (q15_t)0x600f, (q15_t)0x600b, (q15_t)0x6007, (q15_t)0x6002, (q15_t)0x5ffe, + (q15_t)0x5ffa, (q15_t)0x5ff6, (q15_t)0x5ff2, (q15_t)0x5fee, (q15_t)0x5fe9, + (q15_t)0x5fe5, (q15_t)0x5fe1, (q15_t)0x5fdd, (q15_t)0x5fd9, (q15_t)0x5fd5, + (q15_t)0x5fd0, (q15_t)0x5fcc, (q15_t)0x5fc8, (q15_t)0x5fc4, (q15_t)0x5fc0, + (q15_t)0x5fbc, (q15_t)0x5fb7, (q15_t)0x5fb3, (q15_t)0x5faf, (q15_t)0x5fab, + (q15_t)0x5fa7, (q15_t)0x5fa3, (q15_t)0x5f9e, (q15_t)0x5f9a, (q15_t)0x5f96, + (q15_t)0x5f92, (q15_t)0x5f8e, (q15_t)0x5f8a, (q15_t)0x5f85, (q15_t)0x5f81, + (q15_t)0x5f7d, (q15_t)0x5f79, (q15_t)0x5f75, (q15_t)0x5f70, (q15_t)0x5f6c, + (q15_t)0x5f68, (q15_t)0x5f64, (q15_t)0x5f60, (q15_t)0x5f5b, (q15_t)0x5f57, + (q15_t)0x5f53, (q15_t)0x5f4f, (q15_t)0x5f4b, (q15_t)0x5f46, (q15_t)0x5f42, + (q15_t)0x5f3e, (q15_t)0x5f3a, (q15_t)0x5f36, (q15_t)0x5f31, (q15_t)0x5f2d, + (q15_t)0x5f29, (q15_t)0x5f25, (q15_t)0x5f21, (q15_t)0x5f1c, (q15_t)0x5f18, + (q15_t)0x5f14, (q15_t)0x5f10, (q15_t)0x5f0c, (q15_t)0x5f07, (q15_t)0x5f03, + (q15_t)0x5eff, (q15_t)0x5efb, (q15_t)0x5ef7, (q15_t)0x5ef2, (q15_t)0x5eee, + (q15_t)0x5eea, (q15_t)0x5ee6, (q15_t)0x5ee2, (q15_t)0x5edd, (q15_t)0x5ed9, + (q15_t)0x5ed5, (q15_t)0x5ed1, (q15_t)0x5ecc, (q15_t)0x5ec8, (q15_t)0x5ec4, + (q15_t)0x5ec0, (q15_t)0x5ebc, (q15_t)0x5eb7, (q15_t)0x5eb3, (q15_t)0x5eaf, + (q15_t)0x5eab, (q15_t)0x5ea6, (q15_t)0x5ea2, (q15_t)0x5e9e, (q15_t)0x5e9a, + (q15_t)0x5e95, (q15_t)0x5e91, (q15_t)0x5e8d, (q15_t)0x5e89, (q15_t)0x5e85, + (q15_t)0x5e80, (q15_t)0x5e7c, (q15_t)0x5e78, (q15_t)0x5e74, (q15_t)0x5e6f, + (q15_t)0x5e6b, (q15_t)0x5e67, (q15_t)0x5e63, (q15_t)0x5e5e, (q15_t)0x5e5a, + (q15_t)0x5e56, (q15_t)0x5e52, (q15_t)0x5e4d, (q15_t)0x5e49, (q15_t)0x5e45, + (q15_t)0x5e41, (q15_t)0x5e3c, (q15_t)0x5e38, (q15_t)0x5e34, (q15_t)0x5e30, + (q15_t)0x5e2b, (q15_t)0x5e27, (q15_t)0x5e23, (q15_t)0x5e1f, (q15_t)0x5e1a, + (q15_t)0x5e16, (q15_t)0x5e12, (q15_t)0x5e0e, (q15_t)0x5e09, (q15_t)0x5e05, + (q15_t)0x5e01, (q15_t)0x5dfd, (q15_t)0x5df8, (q15_t)0x5df4, (q15_t)0x5df0, + (q15_t)0x5deb, (q15_t)0x5de7, (q15_t)0x5de3, (q15_t)0x5ddf, (q15_t)0x5dda, + (q15_t)0x5dd6, (q15_t)0x5dd2, (q15_t)0x5dce, (q15_t)0x5dc9, (q15_t)0x5dc5, + (q15_t)0x5dc1, (q15_t)0x5dbc, (q15_t)0x5db8, (q15_t)0x5db4, (q15_t)0x5db0, + (q15_t)0x5dab, (q15_t)0x5da7, (q15_t)0x5da3, (q15_t)0x5d9e, (q15_t)0x5d9a, + (q15_t)0x5d96, (q15_t)0x5d92, (q15_t)0x5d8d, (q15_t)0x5d89, (q15_t)0x5d85, + (q15_t)0x5d80, (q15_t)0x5d7c, (q15_t)0x5d78, (q15_t)0x5d74, (q15_t)0x5d6f, + (q15_t)0x5d6b, (q15_t)0x5d67, (q15_t)0x5d62, (q15_t)0x5d5e, (q15_t)0x5d5a, + (q15_t)0x5d55, (q15_t)0x5d51, (q15_t)0x5d4d, (q15_t)0x5d49, (q15_t)0x5d44, + (q15_t)0x5d40, (q15_t)0x5d3c, (q15_t)0x5d37, (q15_t)0x5d33, (q15_t)0x5d2f, + (q15_t)0x5d2a, (q15_t)0x5d26, (q15_t)0x5d22, (q15_t)0x5d1e, (q15_t)0x5d19, + (q15_t)0x5d15, (q15_t)0x5d11, (q15_t)0x5d0c, (q15_t)0x5d08, (q15_t)0x5d04, + (q15_t)0x5cff, (q15_t)0x5cfb, (q15_t)0x5cf7, (q15_t)0x5cf2, (q15_t)0x5cee, + (q15_t)0x5cea, (q15_t)0x5ce5, (q15_t)0x5ce1, (q15_t)0x5cdd, (q15_t)0x5cd8, + (q15_t)0x5cd4, (q15_t)0x5cd0, (q15_t)0x5ccb, (q15_t)0x5cc7, (q15_t)0x5cc3, + (q15_t)0x5cbe, (q15_t)0x5cba, (q15_t)0x5cb6, (q15_t)0x5cb1, (q15_t)0x5cad, + (q15_t)0x5ca9, (q15_t)0x5ca4, (q15_t)0x5ca0, (q15_t)0x5c9c, (q15_t)0x5c97, + (q15_t)0x5c93, (q15_t)0x5c8f, (q15_t)0x5c8a, (q15_t)0x5c86, (q15_t)0x5c82, + (q15_t)0x5c7d, (q15_t)0x5c79, (q15_t)0x5c75, (q15_t)0x5c70, (q15_t)0x5c6c, + (q15_t)0x5c68, (q15_t)0x5c63, (q15_t)0x5c5f, (q15_t)0x5c5b, (q15_t)0x5c56, + (q15_t)0x5c52, (q15_t)0x5c4e, (q15_t)0x5c49, (q15_t)0x5c45, (q15_t)0x5c41, + (q15_t)0x5c3c, (q15_t)0x5c38, (q15_t)0x5c33, (q15_t)0x5c2f, (q15_t)0x5c2b, + (q15_t)0x5c26, (q15_t)0x5c22, (q15_t)0x5c1e, (q15_t)0x5c19, (q15_t)0x5c15, + (q15_t)0x5c11, (q15_t)0x5c0c, (q15_t)0x5c08, (q15_t)0x5c03, (q15_t)0x5bff, + (q15_t)0x5bfb, (q15_t)0x5bf6, (q15_t)0x5bf2, (q15_t)0x5bee, (q15_t)0x5be9, + (q15_t)0x5be5, (q15_t)0x5be0, (q15_t)0x5bdc, (q15_t)0x5bd8, (q15_t)0x5bd3, + (q15_t)0x5bcf, (q15_t)0x5bcb, (q15_t)0x5bc6, (q15_t)0x5bc2, (q15_t)0x5bbd, + (q15_t)0x5bb9, (q15_t)0x5bb5, (q15_t)0x5bb0, (q15_t)0x5bac, (q15_t)0x5ba8, + (q15_t)0x5ba3, (q15_t)0x5b9f, (q15_t)0x5b9a, (q15_t)0x5b96, (q15_t)0x5b92, + (q15_t)0x5b8d, (q15_t)0x5b89, (q15_t)0x5b84, (q15_t)0x5b80, (q15_t)0x5b7c, + (q15_t)0x5b77, (q15_t)0x5b73, (q15_t)0x5b6e, (q15_t)0x5b6a, (q15_t)0x5b66, + (q15_t)0x5b61, (q15_t)0x5b5d, (q15_t)0x5b58, (q15_t)0x5b54, (q15_t)0x5b50, + (q15_t)0x5b4b, (q15_t)0x5b47, (q15_t)0x5b42, (q15_t)0x5b3e, (q15_t)0x5b3a, + (q15_t)0x5b35, (q15_t)0x5b31, (q15_t)0x5b2c, (q15_t)0x5b28, (q15_t)0x5b24, + (q15_t)0x5b1f, (q15_t)0x5b1b, (q15_t)0x5b16, (q15_t)0x5b12, (q15_t)0x5b0e, + (q15_t)0x5b09, (q15_t)0x5b05, (q15_t)0x5b00, (q15_t)0x5afc, (q15_t)0x5af7, + (q15_t)0x5af3, (q15_t)0x5aef, (q15_t)0x5aea, (q15_t)0x5ae6, (q15_t)0x5ae1, + (q15_t)0x5add, (q15_t)0x5ad8, (q15_t)0x5ad4, (q15_t)0x5ad0, (q15_t)0x5acb, + (q15_t)0x5ac7, (q15_t)0x5ac2, (q15_t)0x5abe, (q15_t)0x5ab9, (q15_t)0x5ab5, + (q15_t)0x5ab1, (q15_t)0x5aac, (q15_t)0x5aa8, (q15_t)0x5aa3, (q15_t)0x5a9f, + (q15_t)0x5a9a, (q15_t)0x5a96, (q15_t)0x5a92, (q15_t)0x5a8d, (q15_t)0x5a89, + (q15_t)0x5a84, (q15_t)0x5a80, (q15_t)0x5a7b, (q15_t)0x5a77, (q15_t)0x5a72, + (q15_t)0x5a6e, (q15_t)0x5a6a, (q15_t)0x5a65, (q15_t)0x5a61, (q15_t)0x5a5c, + (q15_t)0x5a58, (q15_t)0x5a53, (q15_t)0x5a4f, (q15_t)0x5a4a, (q15_t)0x5a46, + (q15_t)0x5a41, (q15_t)0x5a3d, (q15_t)0x5a39, (q15_t)0x5a34, (q15_t)0x5a30, + (q15_t)0x5a2b, (q15_t)0x5a27, (q15_t)0x5a22, (q15_t)0x5a1e, (q15_t)0x5a19, + (q15_t)0x5a15, (q15_t)0x5a10, (q15_t)0x5a0c, (q15_t)0x5a07, (q15_t)0x5a03, + (q15_t)0x59ff, (q15_t)0x59fa, (q15_t)0x59f6, (q15_t)0x59f1, (q15_t)0x59ed, + (q15_t)0x59e8, (q15_t)0x59e4, (q15_t)0x59df, (q15_t)0x59db, (q15_t)0x59d6, + (q15_t)0x59d2, (q15_t)0x59cd, (q15_t)0x59c9, (q15_t)0x59c4, (q15_t)0x59c0, + (q15_t)0x59bb, (q15_t)0x59b7, (q15_t)0x59b2, (q15_t)0x59ae, (q15_t)0x59a9, + (q15_t)0x59a5, (q15_t)0x59a1, (q15_t)0x599c, (q15_t)0x5998, (q15_t)0x5993, + (q15_t)0x598f, (q15_t)0x598a, (q15_t)0x5986, (q15_t)0x5981, (q15_t)0x597d, + (q15_t)0x5978, (q15_t)0x5974, (q15_t)0x596f, (q15_t)0x596b, (q15_t)0x5966, + (q15_t)0x5962, (q15_t)0x595d, (q15_t)0x5959, (q15_t)0x5954, (q15_t)0x5950, + (q15_t)0x594b, (q15_t)0x5947, (q15_t)0x5942, (q15_t)0x593e, (q15_t)0x5939, + (q15_t)0x5935, (q15_t)0x5930, (q15_t)0x592c, (q15_t)0x5927, (q15_t)0x5923, + (q15_t)0x591e, (q15_t)0x591a, (q15_t)0x5915, (q15_t)0x5911, (q15_t)0x590c, + (q15_t)0x5908, (q15_t)0x5903, (q15_t)0x58fe, (q15_t)0x58fa, (q15_t)0x58f5, + (q15_t)0x58f1, (q15_t)0x58ec, (q15_t)0x58e8, (q15_t)0x58e3, (q15_t)0x58df, + (q15_t)0x58da, (q15_t)0x58d6, (q15_t)0x58d1, (q15_t)0x58cd, (q15_t)0x58c8, + (q15_t)0x58c4, (q15_t)0x58bf, (q15_t)0x58bb, (q15_t)0x58b6, (q15_t)0x58b2, + (q15_t)0x58ad, (q15_t)0x58a9, (q15_t)0x58a4, (q15_t)0x589f, (q15_t)0x589b, + (q15_t)0x5896, (q15_t)0x5892, (q15_t)0x588d, (q15_t)0x5889, (q15_t)0x5884, + (q15_t)0x5880, (q15_t)0x587b, (q15_t)0x5877, (q15_t)0x5872, (q15_t)0x586e, + (q15_t)0x5869, (q15_t)0x5864, (q15_t)0x5860, (q15_t)0x585b, (q15_t)0x5857, + (q15_t)0x5852, (q15_t)0x584e, (q15_t)0x5849, (q15_t)0x5845, (q15_t)0x5840, + (q15_t)0x583c, (q15_t)0x5837, (q15_t)0x5832, (q15_t)0x582e, (q15_t)0x5829, + (q15_t)0x5825, (q15_t)0x5820, (q15_t)0x581c, (q15_t)0x5817, (q15_t)0x5813, + (q15_t)0x580e, (q15_t)0x5809, (q15_t)0x5805, (q15_t)0x5800, (q15_t)0x57fc, + (q15_t)0x57f7, (q15_t)0x57f3, (q15_t)0x57ee, (q15_t)0x57e9, (q15_t)0x57e5, + (q15_t)0x57e0, (q15_t)0x57dc, (q15_t)0x57d7, (q15_t)0x57d3, (q15_t)0x57ce, + (q15_t)0x57c9, (q15_t)0x57c5, (q15_t)0x57c0, (q15_t)0x57bc, (q15_t)0x57b7, + (q15_t)0x57b3, (q15_t)0x57ae, (q15_t)0x57a9, (q15_t)0x57a5, (q15_t)0x57a0, + (q15_t)0x579c, (q15_t)0x5797, (q15_t)0x5793, (q15_t)0x578e, (q15_t)0x5789, + (q15_t)0x5785, (q15_t)0x5780, (q15_t)0x577c, (q15_t)0x5777, (q15_t)0x5772, + (q15_t)0x576e, (q15_t)0x5769, (q15_t)0x5765, (q15_t)0x5760, (q15_t)0x575c, + (q15_t)0x5757, (q15_t)0x5752, (q15_t)0x574e, (q15_t)0x5749, (q15_t)0x5745, + (q15_t)0x5740, (q15_t)0x573b, (q15_t)0x5737, (q15_t)0x5732, (q15_t)0x572e, + (q15_t)0x5729, (q15_t)0x5724, (q15_t)0x5720, (q15_t)0x571b, (q15_t)0x5717, + (q15_t)0x5712, (q15_t)0x570d, (q15_t)0x5709, (q15_t)0x5704, (q15_t)0x56ff, + (q15_t)0x56fb, (q15_t)0x56f6, (q15_t)0x56f2, (q15_t)0x56ed, (q15_t)0x56e8, + (q15_t)0x56e4, (q15_t)0x56df, (q15_t)0x56db, (q15_t)0x56d6, (q15_t)0x56d1, + (q15_t)0x56cd, (q15_t)0x56c8, (q15_t)0x56c4, (q15_t)0x56bf, (q15_t)0x56ba, + (q15_t)0x56b6, (q15_t)0x56b1, (q15_t)0x56ac, (q15_t)0x56a8, (q15_t)0x56a3, + (q15_t)0x569f, (q15_t)0x569a, (q15_t)0x5695, (q15_t)0x5691, (q15_t)0x568c, + (q15_t)0x5687, (q15_t)0x5683, (q15_t)0x567e, (q15_t)0x5679, (q15_t)0x5675, + (q15_t)0x5670, (q15_t)0x566c, (q15_t)0x5667, (q15_t)0x5662, (q15_t)0x565e, + (q15_t)0x5659, (q15_t)0x5654, (q15_t)0x5650, (q15_t)0x564b, (q15_t)0x5646, + (q15_t)0x5642, (q15_t)0x563d, (q15_t)0x5639, (q15_t)0x5634, (q15_t)0x562f, + (q15_t)0x562b, (q15_t)0x5626, (q15_t)0x5621, (q15_t)0x561d, (q15_t)0x5618, + (q15_t)0x5613, (q15_t)0x560f, (q15_t)0x560a, (q15_t)0x5605, (q15_t)0x5601, + (q15_t)0x55fc, (q15_t)0x55f7, (q15_t)0x55f3, (q15_t)0x55ee, (q15_t)0x55ea, + (q15_t)0x55e5, (q15_t)0x55e0, (q15_t)0x55dc, (q15_t)0x55d7, (q15_t)0x55d2, + (q15_t)0x55ce, (q15_t)0x55c9, (q15_t)0x55c4, (q15_t)0x55c0, (q15_t)0x55bb, + (q15_t)0x55b6, (q15_t)0x55b2, (q15_t)0x55ad, (q15_t)0x55a8, (q15_t)0x55a4, + (q15_t)0x559f, (q15_t)0x559a, (q15_t)0x5596, (q15_t)0x5591, (q15_t)0x558c, + (q15_t)0x5588, (q15_t)0x5583, (q15_t)0x557e, (q15_t)0x5579, (q15_t)0x5575, + (q15_t)0x5570, (q15_t)0x556b, (q15_t)0x5567, (q15_t)0x5562, (q15_t)0x555d, + (q15_t)0x5559, (q15_t)0x5554, (q15_t)0x554f, (q15_t)0x554b, (q15_t)0x5546, + (q15_t)0x5541, (q15_t)0x553d, (q15_t)0x5538, (q15_t)0x5533, (q15_t)0x552f, + (q15_t)0x552a, (q15_t)0x5525, (q15_t)0x5520, (q15_t)0x551c, (q15_t)0x5517, + (q15_t)0x5512, (q15_t)0x550e, (q15_t)0x5509, (q15_t)0x5504, (q15_t)0x5500, + (q15_t)0x54fb, (q15_t)0x54f6, (q15_t)0x54f2, (q15_t)0x54ed, (q15_t)0x54e8, + (q15_t)0x54e3, (q15_t)0x54df, (q15_t)0x54da, (q15_t)0x54d5, (q15_t)0x54d1, + (q15_t)0x54cc, (q15_t)0x54c7, (q15_t)0x54c2, (q15_t)0x54be, (q15_t)0x54b9, + (q15_t)0x54b4, (q15_t)0x54b0, (q15_t)0x54ab, (q15_t)0x54a6, (q15_t)0x54a2, + (q15_t)0x549d, (q15_t)0x5498, (q15_t)0x5493, (q15_t)0x548f, (q15_t)0x548a, + (q15_t)0x5485, (q15_t)0x5480, (q15_t)0x547c, (q15_t)0x5477, (q15_t)0x5472, + (q15_t)0x546e, (q15_t)0x5469, (q15_t)0x5464, (q15_t)0x545f, (q15_t)0x545b, + (q15_t)0x5456, (q15_t)0x5451, (q15_t)0x544d, (q15_t)0x5448, (q15_t)0x5443, + (q15_t)0x543e, (q15_t)0x543a, (q15_t)0x5435, (q15_t)0x5430, (q15_t)0x542b, + (q15_t)0x5427, (q15_t)0x5422, (q15_t)0x541d, (q15_t)0x5418, (q15_t)0x5414, + (q15_t)0x540f, (q15_t)0x540a, (q15_t)0x5406, (q15_t)0x5401, (q15_t)0x53fc, + (q15_t)0x53f7, (q15_t)0x53f3, (q15_t)0x53ee, (q15_t)0x53e9, (q15_t)0x53e4, + (q15_t)0x53e0, (q15_t)0x53db, (q15_t)0x53d6, (q15_t)0x53d1, (q15_t)0x53cd, + (q15_t)0x53c8, (q15_t)0x53c3, (q15_t)0x53be, (q15_t)0x53ba, (q15_t)0x53b5, + (q15_t)0x53b0, (q15_t)0x53ab, (q15_t)0x53a7, (q15_t)0x53a2, (q15_t)0x539d, + (q15_t)0x5398, (q15_t)0x5394, (q15_t)0x538f, (q15_t)0x538a, (q15_t)0x5385, + (q15_t)0x5380, (q15_t)0x537c, (q15_t)0x5377, (q15_t)0x5372, (q15_t)0x536d, + (q15_t)0x5369, (q15_t)0x5364, (q15_t)0x535f, (q15_t)0x535a, (q15_t)0x5356, + (q15_t)0x5351, (q15_t)0x534c, (q15_t)0x5347, (q15_t)0x5343, (q15_t)0x533e, + (q15_t)0x5339, (q15_t)0x5334, (q15_t)0x532f, (q15_t)0x532b, (q15_t)0x5326, + (q15_t)0x5321, (q15_t)0x531c, (q15_t)0x5318, (q15_t)0x5313, (q15_t)0x530e, + (q15_t)0x5309, (q15_t)0x5304, (q15_t)0x5300, (q15_t)0x52fb, (q15_t)0x52f6, + (q15_t)0x52f1, (q15_t)0x52ec, (q15_t)0x52e8, (q15_t)0x52e3, (q15_t)0x52de, + (q15_t)0x52d9, (q15_t)0x52d5, (q15_t)0x52d0, (q15_t)0x52cb, (q15_t)0x52c6, + (q15_t)0x52c1, (q15_t)0x52bd, (q15_t)0x52b8, (q15_t)0x52b3, (q15_t)0x52ae, + (q15_t)0x52a9, (q15_t)0x52a5, (q15_t)0x52a0, (q15_t)0x529b, (q15_t)0x5296, + (q15_t)0x5291, (q15_t)0x528d, (q15_t)0x5288, (q15_t)0x5283, (q15_t)0x527e, + (q15_t)0x5279, (q15_t)0x5275, (q15_t)0x5270, (q15_t)0x526b, (q15_t)0x5266, + (q15_t)0x5261, (q15_t)0x525d, (q15_t)0x5258, (q15_t)0x5253, (q15_t)0x524e, + (q15_t)0x5249, (q15_t)0x5244, (q15_t)0x5240, (q15_t)0x523b, (q15_t)0x5236, + (q15_t)0x5231, (q15_t)0x522c, (q15_t)0x5228, (q15_t)0x5223, (q15_t)0x521e, + (q15_t)0x5219, (q15_t)0x5214, (q15_t)0x520f, (q15_t)0x520b, (q15_t)0x5206, + (q15_t)0x5201, (q15_t)0x51fc, (q15_t)0x51f7, (q15_t)0x51f3, (q15_t)0x51ee, + (q15_t)0x51e9, (q15_t)0x51e4, (q15_t)0x51df, (q15_t)0x51da, (q15_t)0x51d6, + (q15_t)0x51d1, (q15_t)0x51cc, (q15_t)0x51c7, (q15_t)0x51c2, (q15_t)0x51bd, + (q15_t)0x51b9, (q15_t)0x51b4, (q15_t)0x51af, (q15_t)0x51aa, (q15_t)0x51a5, + (q15_t)0x51a0, (q15_t)0x519c, (q15_t)0x5197, (q15_t)0x5192, (q15_t)0x518d, + (q15_t)0x5188, (q15_t)0x5183, (q15_t)0x517e, (q15_t)0x517a, (q15_t)0x5175, + (q15_t)0x5170, (q15_t)0x516b, (q15_t)0x5166, (q15_t)0x5161, (q15_t)0x515d, + (q15_t)0x5158, (q15_t)0x5153, (q15_t)0x514e, (q15_t)0x5149, (q15_t)0x5144, + (q15_t)0x513f, (q15_t)0x513b, (q15_t)0x5136, (q15_t)0x5131, (q15_t)0x512c, + (q15_t)0x5127, (q15_t)0x5122, (q15_t)0x511d, (q15_t)0x5119, (q15_t)0x5114, + (q15_t)0x510f, (q15_t)0x510a, (q15_t)0x5105, (q15_t)0x5100, (q15_t)0x50fb, + (q15_t)0x50f7, (q15_t)0x50f2, (q15_t)0x50ed, (q15_t)0x50e8, (q15_t)0x50e3, + (q15_t)0x50de, (q15_t)0x50d9, (q15_t)0x50d4, (q15_t)0x50d0, (q15_t)0x50cb, + (q15_t)0x50c6, (q15_t)0x50c1, (q15_t)0x50bc, (q15_t)0x50b7, (q15_t)0x50b2, + (q15_t)0x50ad, (q15_t)0x50a9, (q15_t)0x50a4, (q15_t)0x509f, (q15_t)0x509a, + (q15_t)0x5095, (q15_t)0x5090, (q15_t)0x508b, (q15_t)0x5086, (q15_t)0x5082, + (q15_t)0x507d, (q15_t)0x5078, (q15_t)0x5073, (q15_t)0x506e, (q15_t)0x5069, + (q15_t)0x5064, (q15_t)0x505f, (q15_t)0x505a, (q15_t)0x5056, (q15_t)0x5051, + (q15_t)0x504c, (q15_t)0x5047, (q15_t)0x5042, (q15_t)0x503d, (q15_t)0x5038, + (q15_t)0x5033, (q15_t)0x502e, (q15_t)0x5029, (q15_t)0x5025, (q15_t)0x5020, + (q15_t)0x501b, (q15_t)0x5016, (q15_t)0x5011, (q15_t)0x500c, (q15_t)0x5007, + (q15_t)0x5002, (q15_t)0x4ffd, (q15_t)0x4ff8, (q15_t)0x4ff4, (q15_t)0x4fef, + (q15_t)0x4fea, (q15_t)0x4fe5, (q15_t)0x4fe0, (q15_t)0x4fdb, (q15_t)0x4fd6, + (q15_t)0x4fd1, (q15_t)0x4fcc, (q15_t)0x4fc7, (q15_t)0x4fc2, (q15_t)0x4fbe, + (q15_t)0x4fb9, (q15_t)0x4fb4, (q15_t)0x4faf, (q15_t)0x4faa, (q15_t)0x4fa5, + (q15_t)0x4fa0, (q15_t)0x4f9b, (q15_t)0x4f96, (q15_t)0x4f91, (q15_t)0x4f8c, + (q15_t)0x4f87, (q15_t)0x4f82, (q15_t)0x4f7e, (q15_t)0x4f79, (q15_t)0x4f74, + (q15_t)0x4f6f, (q15_t)0x4f6a, (q15_t)0x4f65, (q15_t)0x4f60, (q15_t)0x4f5b, + (q15_t)0x4f56, (q15_t)0x4f51, (q15_t)0x4f4c, (q15_t)0x4f47, (q15_t)0x4f42, + (q15_t)0x4f3d, (q15_t)0x4f39, (q15_t)0x4f34, (q15_t)0x4f2f, (q15_t)0x4f2a, + (q15_t)0x4f25, (q15_t)0x4f20, (q15_t)0x4f1b, (q15_t)0x4f16, (q15_t)0x4f11, + (q15_t)0x4f0c, (q15_t)0x4f07, (q15_t)0x4f02, (q15_t)0x4efd, (q15_t)0x4ef8, + (q15_t)0x4ef3, (q15_t)0x4eee, (q15_t)0x4ee9, (q15_t)0x4ee5, (q15_t)0x4ee0, + (q15_t)0x4edb, (q15_t)0x4ed6, (q15_t)0x4ed1, (q15_t)0x4ecc, (q15_t)0x4ec7, + (q15_t)0x4ec2, (q15_t)0x4ebd, (q15_t)0x4eb8, (q15_t)0x4eb3, (q15_t)0x4eae, + (q15_t)0x4ea9, (q15_t)0x4ea4, (q15_t)0x4e9f, (q15_t)0x4e9a, (q15_t)0x4e95, + (q15_t)0x4e90, (q15_t)0x4e8b, (q15_t)0x4e86, (q15_t)0x4e81, (q15_t)0x4e7c, + (q15_t)0x4e78, (q15_t)0x4e73, (q15_t)0x4e6e, (q15_t)0x4e69, (q15_t)0x4e64, + (q15_t)0x4e5f, (q15_t)0x4e5a, (q15_t)0x4e55, (q15_t)0x4e50, (q15_t)0x4e4b, + (q15_t)0x4e46, (q15_t)0x4e41, (q15_t)0x4e3c, (q15_t)0x4e37, (q15_t)0x4e32, + (q15_t)0x4e2d, (q15_t)0x4e28, (q15_t)0x4e23, (q15_t)0x4e1e, (q15_t)0x4e19, + (q15_t)0x4e14, (q15_t)0x4e0f, (q15_t)0x4e0a, (q15_t)0x4e05, (q15_t)0x4e00, + (q15_t)0x4dfb, (q15_t)0x4df6, (q15_t)0x4df1, (q15_t)0x4dec, (q15_t)0x4de7, + (q15_t)0x4de2, (q15_t)0x4ddd, (q15_t)0x4dd8, (q15_t)0x4dd3, (q15_t)0x4dce, + (q15_t)0x4dc9, (q15_t)0x4dc4, (q15_t)0x4dbf, (q15_t)0x4dba, (q15_t)0x4db5, + (q15_t)0x4db0, (q15_t)0x4dab, (q15_t)0x4da6, (q15_t)0x4da1, (q15_t)0x4d9c, + (q15_t)0x4d97, (q15_t)0x4d92, (q15_t)0x4d8d, (q15_t)0x4d88, (q15_t)0x4d83, + (q15_t)0x4d7e, (q15_t)0x4d79, (q15_t)0x4d74, (q15_t)0x4d6f, (q15_t)0x4d6a, + (q15_t)0x4d65, (q15_t)0x4d60, (q15_t)0x4d5b, (q15_t)0x4d56, (q15_t)0x4d51, + (q15_t)0x4d4c, (q15_t)0x4d47, (q15_t)0x4d42, (q15_t)0x4d3d, (q15_t)0x4d38, + (q15_t)0x4d33, (q15_t)0x4d2e, (q15_t)0x4d29, (q15_t)0x4d24, (q15_t)0x4d1f, + (q15_t)0x4d1a, (q15_t)0x4d15, (q15_t)0x4d10, (q15_t)0x4d0b, (q15_t)0x4d06, + (q15_t)0x4d01, (q15_t)0x4cfc, (q15_t)0x4cf7, (q15_t)0x4cf2, (q15_t)0x4ced, + (q15_t)0x4ce8, (q15_t)0x4ce3, (q15_t)0x4cde, (q15_t)0x4cd9, (q15_t)0x4cd4, + (q15_t)0x4ccf, (q15_t)0x4cca, (q15_t)0x4cc5, (q15_t)0x4cc0, (q15_t)0x4cbb, + (q15_t)0x4cb6, (q15_t)0x4cb1, (q15_t)0x4cac, (q15_t)0x4ca7, (q15_t)0x4ca2, + (q15_t)0x4c9d, (q15_t)0x4c98, (q15_t)0x4c93, (q15_t)0x4c8e, (q15_t)0x4c88, + (q15_t)0x4c83, (q15_t)0x4c7e, (q15_t)0x4c79, (q15_t)0x4c74, (q15_t)0x4c6f, + (q15_t)0x4c6a, (q15_t)0x4c65, (q15_t)0x4c60, (q15_t)0x4c5b, (q15_t)0x4c56, + (q15_t)0x4c51, (q15_t)0x4c4c, (q15_t)0x4c47, (q15_t)0x4c42, (q15_t)0x4c3d, + (q15_t)0x4c38, (q15_t)0x4c33, (q15_t)0x4c2e, (q15_t)0x4c29, (q15_t)0x4c24, + (q15_t)0x4c1f, (q15_t)0x4c1a, (q15_t)0x4c14, (q15_t)0x4c0f, (q15_t)0x4c0a, + (q15_t)0x4c05, (q15_t)0x4c00, (q15_t)0x4bfb, (q15_t)0x4bf6, (q15_t)0x4bf1, + (q15_t)0x4bec, (q15_t)0x4be7, (q15_t)0x4be2, (q15_t)0x4bdd, (q15_t)0x4bd8, + (q15_t)0x4bd3, (q15_t)0x4bce, (q15_t)0x4bc9, (q15_t)0x4bc4, (q15_t)0x4bbe, + (q15_t)0x4bb9, (q15_t)0x4bb4, (q15_t)0x4baf, (q15_t)0x4baa, (q15_t)0x4ba5, + (q15_t)0x4ba0, (q15_t)0x4b9b, (q15_t)0x4b96, (q15_t)0x4b91, (q15_t)0x4b8c, + (q15_t)0x4b87, (q15_t)0x4b82, (q15_t)0x4b7d, (q15_t)0x4b77, (q15_t)0x4b72, + (q15_t)0x4b6d, (q15_t)0x4b68, (q15_t)0x4b63, (q15_t)0x4b5e, (q15_t)0x4b59, + (q15_t)0x4b54, (q15_t)0x4b4f, (q15_t)0x4b4a, (q15_t)0x4b45, (q15_t)0x4b40, + (q15_t)0x4b3b, (q15_t)0x4b35, (q15_t)0x4b30, (q15_t)0x4b2b, (q15_t)0x4b26, + (q15_t)0x4b21, (q15_t)0x4b1c, (q15_t)0x4b17, (q15_t)0x4b12, (q15_t)0x4b0d, + (q15_t)0x4b08, (q15_t)0x4b03, (q15_t)0x4afd, (q15_t)0x4af8, (q15_t)0x4af3, + (q15_t)0x4aee, (q15_t)0x4ae9, (q15_t)0x4ae4, (q15_t)0x4adf, (q15_t)0x4ada, + (q15_t)0x4ad5, (q15_t)0x4ad0, (q15_t)0x4acb, (q15_t)0x4ac5, (q15_t)0x4ac0, + (q15_t)0x4abb, (q15_t)0x4ab6, (q15_t)0x4ab1, (q15_t)0x4aac, (q15_t)0x4aa7, + (q15_t)0x4aa2, (q15_t)0x4a9d, (q15_t)0x4a97, (q15_t)0x4a92, (q15_t)0x4a8d, + (q15_t)0x4a88, (q15_t)0x4a83, (q15_t)0x4a7e, (q15_t)0x4a79, (q15_t)0x4a74, + (q15_t)0x4a6f, (q15_t)0x4a6a, (q15_t)0x4a64, (q15_t)0x4a5f, (q15_t)0x4a5a, + (q15_t)0x4a55, (q15_t)0x4a50, (q15_t)0x4a4b, (q15_t)0x4a46, (q15_t)0x4a41, + (q15_t)0x4a3b, (q15_t)0x4a36, (q15_t)0x4a31, (q15_t)0x4a2c, (q15_t)0x4a27, + (q15_t)0x4a22, (q15_t)0x4a1d, (q15_t)0x4a18, (q15_t)0x4a12, (q15_t)0x4a0d, + (q15_t)0x4a08, (q15_t)0x4a03, (q15_t)0x49fe, (q15_t)0x49f9, (q15_t)0x49f4, + (q15_t)0x49ef, (q15_t)0x49e9, (q15_t)0x49e4, (q15_t)0x49df, (q15_t)0x49da, + (q15_t)0x49d5, (q15_t)0x49d0, (q15_t)0x49cb, (q15_t)0x49c6, (q15_t)0x49c0, + (q15_t)0x49bb, (q15_t)0x49b6, (q15_t)0x49b1, (q15_t)0x49ac, (q15_t)0x49a7, + (q15_t)0x49a2, (q15_t)0x499c, (q15_t)0x4997, (q15_t)0x4992, (q15_t)0x498d, + (q15_t)0x4988, (q15_t)0x4983, (q15_t)0x497e, (q15_t)0x4978, (q15_t)0x4973, + (q15_t)0x496e, (q15_t)0x4969, (q15_t)0x4964, (q15_t)0x495f, (q15_t)0x495a, + (q15_t)0x4954, (q15_t)0x494f, (q15_t)0x494a, (q15_t)0x4945, (q15_t)0x4940, + (q15_t)0x493b, (q15_t)0x4936, (q15_t)0x4930, (q15_t)0x492b, (q15_t)0x4926, + (q15_t)0x4921, (q15_t)0x491c, (q15_t)0x4917, (q15_t)0x4911, (q15_t)0x490c, + (q15_t)0x4907, (q15_t)0x4902, (q15_t)0x48fd, (q15_t)0x48f8, (q15_t)0x48f2, + (q15_t)0x48ed, (q15_t)0x48e8, (q15_t)0x48e3, (q15_t)0x48de, (q15_t)0x48d9, + (q15_t)0x48d3, (q15_t)0x48ce, (q15_t)0x48c9, (q15_t)0x48c4, (q15_t)0x48bf, + (q15_t)0x48ba, (q15_t)0x48b4, (q15_t)0x48af, (q15_t)0x48aa, (q15_t)0x48a5, + (q15_t)0x48a0, (q15_t)0x489b, (q15_t)0x4895, (q15_t)0x4890, (q15_t)0x488b, + (q15_t)0x4886, (q15_t)0x4881, (q15_t)0x487c, (q15_t)0x4876, (q15_t)0x4871, + (q15_t)0x486c, (q15_t)0x4867, (q15_t)0x4862, (q15_t)0x485c, (q15_t)0x4857, + (q15_t)0x4852, (q15_t)0x484d, (q15_t)0x4848, (q15_t)0x4843, (q15_t)0x483d, + (q15_t)0x4838, (q15_t)0x4833, (q15_t)0x482e, (q15_t)0x4829, (q15_t)0x4823, + (q15_t)0x481e, (q15_t)0x4819, (q15_t)0x4814, (q15_t)0x480f, (q15_t)0x4809, + (q15_t)0x4804, (q15_t)0x47ff, (q15_t)0x47fa, (q15_t)0x47f5, (q15_t)0x47ef, + (q15_t)0x47ea, (q15_t)0x47e5, (q15_t)0x47e0, (q15_t)0x47db, (q15_t)0x47d5, + (q15_t)0x47d0, (q15_t)0x47cb, (q15_t)0x47c6, (q15_t)0x47c1, (q15_t)0x47bb, + (q15_t)0x47b6, (q15_t)0x47b1, (q15_t)0x47ac, (q15_t)0x47a7, (q15_t)0x47a1, + (q15_t)0x479c, (q15_t)0x4797, (q15_t)0x4792, (q15_t)0x478d, (q15_t)0x4787, + (q15_t)0x4782, (q15_t)0x477d, (q15_t)0x4778, (q15_t)0x4773, (q15_t)0x476d, + (q15_t)0x4768, (q15_t)0x4763, (q15_t)0x475e, (q15_t)0x4758, (q15_t)0x4753, + (q15_t)0x474e, (q15_t)0x4749, (q15_t)0x4744, (q15_t)0x473e, (q15_t)0x4739, + (q15_t)0x4734, (q15_t)0x472f, (q15_t)0x4729, (q15_t)0x4724, (q15_t)0x471f, + (q15_t)0x471a, (q15_t)0x4715, (q15_t)0x470f, (q15_t)0x470a, (q15_t)0x4705, + (q15_t)0x4700, (q15_t)0x46fa, (q15_t)0x46f5, (q15_t)0x46f0, (q15_t)0x46eb, + (q15_t)0x46e6, (q15_t)0x46e0, (q15_t)0x46db, (q15_t)0x46d6, (q15_t)0x46d1, + (q15_t)0x46cb, (q15_t)0x46c6, (q15_t)0x46c1, (q15_t)0x46bc, (q15_t)0x46b6, + (q15_t)0x46b1, (q15_t)0x46ac, (q15_t)0x46a7, (q15_t)0x46a1, (q15_t)0x469c, + (q15_t)0x4697, (q15_t)0x4692, (q15_t)0x468d, (q15_t)0x4687, (q15_t)0x4682, + (q15_t)0x467d, (q15_t)0x4678, (q15_t)0x4672, (q15_t)0x466d, (q15_t)0x4668, + (q15_t)0x4663, (q15_t)0x465d, (q15_t)0x4658, (q15_t)0x4653, (q15_t)0x464e, + (q15_t)0x4648, (q15_t)0x4643, (q15_t)0x463e, (q15_t)0x4639, (q15_t)0x4633, + (q15_t)0x462e, (q15_t)0x4629, (q15_t)0x4624, (q15_t)0x461e, (q15_t)0x4619, + (q15_t)0x4614, (q15_t)0x460e, (q15_t)0x4609, (q15_t)0x4604, (q15_t)0x45ff, + (q15_t)0x45f9, (q15_t)0x45f4, (q15_t)0x45ef, (q15_t)0x45ea, (q15_t)0x45e4, + (q15_t)0x45df, (q15_t)0x45da, (q15_t)0x45d5, (q15_t)0x45cf, (q15_t)0x45ca, + (q15_t)0x45c5, (q15_t)0x45c0, (q15_t)0x45ba, (q15_t)0x45b5, (q15_t)0x45b0, + (q15_t)0x45aa, (q15_t)0x45a5, (q15_t)0x45a0, (q15_t)0x459b, (q15_t)0x4595, + (q15_t)0x4590, (q15_t)0x458b, (q15_t)0x4586, (q15_t)0x4580, (q15_t)0x457b, + (q15_t)0x4576, (q15_t)0x4570, (q15_t)0x456b, (q15_t)0x4566, (q15_t)0x4561, + (q15_t)0x455b, (q15_t)0x4556, (q15_t)0x4551, (q15_t)0x454b, (q15_t)0x4546, + (q15_t)0x4541, (q15_t)0x453c, (q15_t)0x4536, (q15_t)0x4531, (q15_t)0x452c, + (q15_t)0x4526, (q15_t)0x4521, (q15_t)0x451c, (q15_t)0x4517, (q15_t)0x4511, + (q15_t)0x450c, (q15_t)0x4507, (q15_t)0x4501, (q15_t)0x44fc, (q15_t)0x44f7, + (q15_t)0x44f2, (q15_t)0x44ec, (q15_t)0x44e7, (q15_t)0x44e2, (q15_t)0x44dc, + (q15_t)0x44d7, (q15_t)0x44d2, (q15_t)0x44cd, (q15_t)0x44c7, (q15_t)0x44c2, + (q15_t)0x44bd, (q15_t)0x44b7, (q15_t)0x44b2, (q15_t)0x44ad, (q15_t)0x44a7, + (q15_t)0x44a2, (q15_t)0x449d, (q15_t)0x4497, (q15_t)0x4492, (q15_t)0x448d, + (q15_t)0x4488, (q15_t)0x4482, (q15_t)0x447d, (q15_t)0x4478, (q15_t)0x4472, + (q15_t)0x446d, (q15_t)0x4468, (q15_t)0x4462, (q15_t)0x445d, (q15_t)0x4458, + (q15_t)0x4452, (q15_t)0x444d, (q15_t)0x4448, (q15_t)0x4443, (q15_t)0x443d, + (q15_t)0x4438, (q15_t)0x4433, (q15_t)0x442d, (q15_t)0x4428, (q15_t)0x4423, + (q15_t)0x441d, (q15_t)0x4418, (q15_t)0x4413, (q15_t)0x440d, (q15_t)0x4408, + (q15_t)0x4403, (q15_t)0x43fd, (q15_t)0x43f8, (q15_t)0x43f3, (q15_t)0x43ed, + (q15_t)0x43e8, (q15_t)0x43e3, (q15_t)0x43dd, (q15_t)0x43d8, (q15_t)0x43d3, + (q15_t)0x43cd, (q15_t)0x43c8, (q15_t)0x43c3, (q15_t)0x43bd, (q15_t)0x43b8, + (q15_t)0x43b3, (q15_t)0x43ad, (q15_t)0x43a8, (q15_t)0x43a3, (q15_t)0x439d, + (q15_t)0x4398, (q15_t)0x4393, (q15_t)0x438d, (q15_t)0x4388, (q15_t)0x4383, + (q15_t)0x437d, (q15_t)0x4378, (q15_t)0x4373, (q15_t)0x436d, (q15_t)0x4368, + (q15_t)0x4363, (q15_t)0x435d, (q15_t)0x4358, (q15_t)0x4353, (q15_t)0x434d, + (q15_t)0x4348, (q15_t)0x4343, (q15_t)0x433d, (q15_t)0x4338, (q15_t)0x4333, + (q15_t)0x432d, (q15_t)0x4328, (q15_t)0x4323, (q15_t)0x431d, (q15_t)0x4318, + (q15_t)0x4313, (q15_t)0x430d, (q15_t)0x4308, (q15_t)0x4302, (q15_t)0x42fd, + (q15_t)0x42f8, (q15_t)0x42f2, (q15_t)0x42ed, (q15_t)0x42e8, (q15_t)0x42e2, + (q15_t)0x42dd, (q15_t)0x42d8, (q15_t)0x42d2, (q15_t)0x42cd, (q15_t)0x42c8, + (q15_t)0x42c2, (q15_t)0x42bd, (q15_t)0x42b7, (q15_t)0x42b2, (q15_t)0x42ad, + (q15_t)0x42a7, (q15_t)0x42a2, (q15_t)0x429d, (q15_t)0x4297, (q15_t)0x4292, + (q15_t)0x428d, (q15_t)0x4287, (q15_t)0x4282, (q15_t)0x427c, (q15_t)0x4277, + (q15_t)0x4272, (q15_t)0x426c, (q15_t)0x4267, (q15_t)0x4262, (q15_t)0x425c, + (q15_t)0x4257, (q15_t)0x4251, (q15_t)0x424c, (q15_t)0x4247, (q15_t)0x4241, + (q15_t)0x423c, (q15_t)0x4237, (q15_t)0x4231, (q15_t)0x422c, (q15_t)0x4226, + (q15_t)0x4221, (q15_t)0x421c, (q15_t)0x4216, (q15_t)0x4211, (q15_t)0x420c, + (q15_t)0x4206, (q15_t)0x4201, (q15_t)0x41fb, (q15_t)0x41f6, (q15_t)0x41f1, + (q15_t)0x41eb, (q15_t)0x41e6, (q15_t)0x41e0, (q15_t)0x41db, (q15_t)0x41d6, + (q15_t)0x41d0, (q15_t)0x41cb, (q15_t)0x41c6, (q15_t)0x41c0, (q15_t)0x41bb, + (q15_t)0x41b5, (q15_t)0x41b0, (q15_t)0x41ab, (q15_t)0x41a5, (q15_t)0x41a0, + (q15_t)0x419a, (q15_t)0x4195, (q15_t)0x4190, (q15_t)0x418a, (q15_t)0x4185, + (q15_t)0x417f, (q15_t)0x417a, (q15_t)0x4175, (q15_t)0x416f, (q15_t)0x416a, + (q15_t)0x4164, (q15_t)0x415f, (q15_t)0x415a, (q15_t)0x4154, (q15_t)0x414f, + (q15_t)0x4149, (q15_t)0x4144, (q15_t)0x413f, (q15_t)0x4139, (q15_t)0x4134, + (q15_t)0x412e, (q15_t)0x4129, (q15_t)0x4124, (q15_t)0x411e, (q15_t)0x4119, + (q15_t)0x4113, (q15_t)0x410e, (q15_t)0x4108, (q15_t)0x4103, (q15_t)0x40fe, + (q15_t)0x40f8, (q15_t)0x40f3, (q15_t)0x40ed, (q15_t)0x40e8, (q15_t)0x40e3, + (q15_t)0x40dd, (q15_t)0x40d8, (q15_t)0x40d2, (q15_t)0x40cd, (q15_t)0x40c8, + (q15_t)0x40c2, (q15_t)0x40bd, (q15_t)0x40b7, (q15_t)0x40b2, (q15_t)0x40ac, + (q15_t)0x40a7, (q15_t)0x40a2, (q15_t)0x409c, (q15_t)0x4097, (q15_t)0x4091, + (q15_t)0x408c, (q15_t)0x4086, (q15_t)0x4081, (q15_t)0x407c, (q15_t)0x4076, + (q15_t)0x4071, (q15_t)0x406b, (q15_t)0x4066, (q15_t)0x4060, (q15_t)0x405b, + (q15_t)0x4056, (q15_t)0x4050, (q15_t)0x404b, (q15_t)0x4045, (q15_t)0x4040, + (q15_t)0x403a, (q15_t)0x4035, (q15_t)0x4030, (q15_t)0x402a, (q15_t)0x4025, + (q15_t)0x401f, (q15_t)0x401a, (q15_t)0x4014, (q15_t)0x400f, (q15_t)0x4009, + (q15_t)0x4004, (q15_t)0x3fff, (q15_t)0x3ff9, (q15_t)0x3ff4, (q15_t)0x3fee, + (q15_t)0x3fe9, (q15_t)0x3fe3, (q15_t)0x3fde, (q15_t)0x3fd8, (q15_t)0x3fd3, + (q15_t)0x3fce, (q15_t)0x3fc8, (q15_t)0x3fc3, (q15_t)0x3fbd, (q15_t)0x3fb8, + (q15_t)0x3fb2, (q15_t)0x3fad, (q15_t)0x3fa7, (q15_t)0x3fa2, (q15_t)0x3f9d, + (q15_t)0x3f97, (q15_t)0x3f92, (q15_t)0x3f8c, (q15_t)0x3f87, (q15_t)0x3f81, + (q15_t)0x3f7c, (q15_t)0x3f76, (q15_t)0x3f71, (q15_t)0x3f6b, (q15_t)0x3f66, + (q15_t)0x3f61, (q15_t)0x3f5b, (q15_t)0x3f56, (q15_t)0x3f50, (q15_t)0x3f4b, + (q15_t)0x3f45, (q15_t)0x3f40, (q15_t)0x3f3a, (q15_t)0x3f35, (q15_t)0x3f2f, + (q15_t)0x3f2a, (q15_t)0x3f24, (q15_t)0x3f1f, (q15_t)0x3f1a, (q15_t)0x3f14, + (q15_t)0x3f0f, (q15_t)0x3f09, (q15_t)0x3f04, (q15_t)0x3efe, (q15_t)0x3ef9, + (q15_t)0x3ef3, (q15_t)0x3eee, (q15_t)0x3ee8, (q15_t)0x3ee3, (q15_t)0x3edd, + (q15_t)0x3ed8, (q15_t)0x3ed2, (q15_t)0x3ecd, (q15_t)0x3ec7, (q15_t)0x3ec2, + (q15_t)0x3ebd, (q15_t)0x3eb7, (q15_t)0x3eb2, (q15_t)0x3eac, (q15_t)0x3ea7, + (q15_t)0x3ea1, (q15_t)0x3e9c, (q15_t)0x3e96, (q15_t)0x3e91, (q15_t)0x3e8b, + (q15_t)0x3e86, (q15_t)0x3e80, (q15_t)0x3e7b, (q15_t)0x3e75, (q15_t)0x3e70, + (q15_t)0x3e6a, (q15_t)0x3e65, (q15_t)0x3e5f, (q15_t)0x3e5a, (q15_t)0x3e54, + (q15_t)0x3e4f, (q15_t)0x3e49, (q15_t)0x3e44, (q15_t)0x3e3e, (q15_t)0x3e39, + (q15_t)0x3e33, (q15_t)0x3e2e, (q15_t)0x3e28, (q15_t)0x3e23, (q15_t)0x3e1d, + (q15_t)0x3e18, (q15_t)0x3e12, (q15_t)0x3e0d, (q15_t)0x3e07, (q15_t)0x3e02, + (q15_t)0x3dfc, (q15_t)0x3df7, (q15_t)0x3df1, (q15_t)0x3dec, (q15_t)0x3de6, + (q15_t)0x3de1, (q15_t)0x3ddb, (q15_t)0x3dd6, (q15_t)0x3dd0, (q15_t)0x3dcb, + (q15_t)0x3dc5, (q15_t)0x3dc0, (q15_t)0x3dba, (q15_t)0x3db5, (q15_t)0x3daf, + (q15_t)0x3daa, (q15_t)0x3da4, (q15_t)0x3d9f, (q15_t)0x3d99, (q15_t)0x3d94, + (q15_t)0x3d8e, (q15_t)0x3d89, (q15_t)0x3d83, (q15_t)0x3d7e, (q15_t)0x3d78, + (q15_t)0x3d73, (q15_t)0x3d6d, (q15_t)0x3d68, (q15_t)0x3d62, (q15_t)0x3d5d, + (q15_t)0x3d57, (q15_t)0x3d52, (q15_t)0x3d4c, (q15_t)0x3d47, (q15_t)0x3d41, + (q15_t)0x3d3c, (q15_t)0x3d36, (q15_t)0x3d31, (q15_t)0x3d2b, (q15_t)0x3d26, + (q15_t)0x3d20, (q15_t)0x3d1b, (q15_t)0x3d15, (q15_t)0x3d10, (q15_t)0x3d0a, + (q15_t)0x3d04, (q15_t)0x3cff, (q15_t)0x3cf9, (q15_t)0x3cf4, (q15_t)0x3cee, + (q15_t)0x3ce9, (q15_t)0x3ce3, (q15_t)0x3cde, (q15_t)0x3cd8, (q15_t)0x3cd3, + (q15_t)0x3ccd, (q15_t)0x3cc8, (q15_t)0x3cc2, (q15_t)0x3cbd, (q15_t)0x3cb7, + (q15_t)0x3cb2, (q15_t)0x3cac, (q15_t)0x3ca7, (q15_t)0x3ca1, (q15_t)0x3c9b, + (q15_t)0x3c96, (q15_t)0x3c90, (q15_t)0x3c8b, (q15_t)0x3c85, (q15_t)0x3c80, + (q15_t)0x3c7a, (q15_t)0x3c75, (q15_t)0x3c6f, (q15_t)0x3c6a, (q15_t)0x3c64, + (q15_t)0x3c5f, (q15_t)0x3c59, (q15_t)0x3c53, (q15_t)0x3c4e, (q15_t)0x3c48, + (q15_t)0x3c43, (q15_t)0x3c3d, (q15_t)0x3c38, (q15_t)0x3c32, (q15_t)0x3c2d, + (q15_t)0x3c27, (q15_t)0x3c22, (q15_t)0x3c1c, (q15_t)0x3c16, (q15_t)0x3c11, + (q15_t)0x3c0b, (q15_t)0x3c06, (q15_t)0x3c00, (q15_t)0x3bfb, (q15_t)0x3bf5, + (q15_t)0x3bf0, (q15_t)0x3bea, (q15_t)0x3be5, (q15_t)0x3bdf, (q15_t)0x3bd9, + (q15_t)0x3bd4, (q15_t)0x3bce, (q15_t)0x3bc9, (q15_t)0x3bc3, (q15_t)0x3bbe, + (q15_t)0x3bb8, (q15_t)0x3bb3, (q15_t)0x3bad, (q15_t)0x3ba7, (q15_t)0x3ba2, + (q15_t)0x3b9c, (q15_t)0x3b97, (q15_t)0x3b91, (q15_t)0x3b8c, (q15_t)0x3b86, + (q15_t)0x3b80, (q15_t)0x3b7b, (q15_t)0x3b75, (q15_t)0x3b70, (q15_t)0x3b6a, + (q15_t)0x3b65, (q15_t)0x3b5f, (q15_t)0x3b5a, (q15_t)0x3b54, (q15_t)0x3b4e, + (q15_t)0x3b49, (q15_t)0x3b43, (q15_t)0x3b3e, (q15_t)0x3b38, (q15_t)0x3b33, + (q15_t)0x3b2d, (q15_t)0x3b27, (q15_t)0x3b22, (q15_t)0x3b1c, (q15_t)0x3b17, + (q15_t)0x3b11, (q15_t)0x3b0c, (q15_t)0x3b06, (q15_t)0x3b00, (q15_t)0x3afb, + (q15_t)0x3af5, (q15_t)0x3af0, (q15_t)0x3aea, (q15_t)0x3ae4, (q15_t)0x3adf, + (q15_t)0x3ad9, (q15_t)0x3ad4, (q15_t)0x3ace, (q15_t)0x3ac9, (q15_t)0x3ac3, + (q15_t)0x3abd, (q15_t)0x3ab8, (q15_t)0x3ab2, (q15_t)0x3aad, (q15_t)0x3aa7, + (q15_t)0x3aa2, (q15_t)0x3a9c, (q15_t)0x3a96, (q15_t)0x3a91, (q15_t)0x3a8b, + (q15_t)0x3a86, (q15_t)0x3a80, (q15_t)0x3a7a, (q15_t)0x3a75, (q15_t)0x3a6f, + (q15_t)0x3a6a, (q15_t)0x3a64, (q15_t)0x3a5e, (q15_t)0x3a59, (q15_t)0x3a53, + (q15_t)0x3a4e, (q15_t)0x3a48, (q15_t)0x3a42, (q15_t)0x3a3d, (q15_t)0x3a37, + (q15_t)0x3a32, (q15_t)0x3a2c, (q15_t)0x3a26, (q15_t)0x3a21, (q15_t)0x3a1b, + (q15_t)0x3a16, (q15_t)0x3a10, (q15_t)0x3a0b, (q15_t)0x3a05, (q15_t)0x39ff, + (q15_t)0x39fa, (q15_t)0x39f4, (q15_t)0x39ee, (q15_t)0x39e9, (q15_t)0x39e3, + (q15_t)0x39de, (q15_t)0x39d8, (q15_t)0x39d2, (q15_t)0x39cd, (q15_t)0x39c7, + (q15_t)0x39c2, (q15_t)0x39bc, (q15_t)0x39b6, (q15_t)0x39b1, (q15_t)0x39ab, + (q15_t)0x39a6, (q15_t)0x39a0, (q15_t)0x399a, (q15_t)0x3995, (q15_t)0x398f, + (q15_t)0x398a, (q15_t)0x3984, (q15_t)0x397e, (q15_t)0x3979, (q15_t)0x3973, + (q15_t)0x396d, (q15_t)0x3968, (q15_t)0x3962, (q15_t)0x395d, (q15_t)0x3957, + (q15_t)0x3951, (q15_t)0x394c, (q15_t)0x3946, (q15_t)0x3941, (q15_t)0x393b, + (q15_t)0x3935, (q15_t)0x3930, (q15_t)0x392a, (q15_t)0x3924, (q15_t)0x391f, + (q15_t)0x3919, (q15_t)0x3914, (q15_t)0x390e, (q15_t)0x3908, (q15_t)0x3903, + (q15_t)0x38fd, (q15_t)0x38f7, (q15_t)0x38f2, (q15_t)0x38ec, (q15_t)0x38e7, + (q15_t)0x38e1, (q15_t)0x38db, (q15_t)0x38d6, (q15_t)0x38d0, (q15_t)0x38ca, + (q15_t)0x38c5, (q15_t)0x38bf, (q15_t)0x38ba, (q15_t)0x38b4, (q15_t)0x38ae, + (q15_t)0x38a9, (q15_t)0x38a3, (q15_t)0x389d, (q15_t)0x3898, (q15_t)0x3892, + (q15_t)0x388c, (q15_t)0x3887, (q15_t)0x3881, (q15_t)0x387c, (q15_t)0x3876, + (q15_t)0x3870, (q15_t)0x386b, (q15_t)0x3865, (q15_t)0x385f, (q15_t)0x385a, + (q15_t)0x3854, (q15_t)0x384e, (q15_t)0x3849, (q15_t)0x3843, (q15_t)0x383d, + (q15_t)0x3838, (q15_t)0x3832, (q15_t)0x382d, (q15_t)0x3827, (q15_t)0x3821, + (q15_t)0x381c, (q15_t)0x3816, (q15_t)0x3810, (q15_t)0x380b, (q15_t)0x3805, + (q15_t)0x37ff, (q15_t)0x37fa, (q15_t)0x37f4, (q15_t)0x37ee, (q15_t)0x37e9, + (q15_t)0x37e3, (q15_t)0x37dd, (q15_t)0x37d8, (q15_t)0x37d2, (q15_t)0x37cc, + (q15_t)0x37c7, (q15_t)0x37c1, (q15_t)0x37bc, (q15_t)0x37b6, (q15_t)0x37b0, + (q15_t)0x37ab, (q15_t)0x37a5, (q15_t)0x379f, (q15_t)0x379a, (q15_t)0x3794, + (q15_t)0x378e, (q15_t)0x3789, (q15_t)0x3783, (q15_t)0x377d, (q15_t)0x3778, + (q15_t)0x3772, (q15_t)0x376c, (q15_t)0x3767, (q15_t)0x3761, (q15_t)0x375b, + (q15_t)0x3756, (q15_t)0x3750, (q15_t)0x374a, (q15_t)0x3745, (q15_t)0x373f, + (q15_t)0x3739, (q15_t)0x3734, (q15_t)0x372e, (q15_t)0x3728, (q15_t)0x3723, + (q15_t)0x371d, (q15_t)0x3717, (q15_t)0x3712, (q15_t)0x370c, (q15_t)0x3706, + (q15_t)0x3701, (q15_t)0x36fb, (q15_t)0x36f5, (q15_t)0x36f0, (q15_t)0x36ea, + (q15_t)0x36e4, (q15_t)0x36df, (q15_t)0x36d9, (q15_t)0x36d3, (q15_t)0x36ce, + (q15_t)0x36c8, (q15_t)0x36c2, (q15_t)0x36bc, (q15_t)0x36b7, (q15_t)0x36b1, + (q15_t)0x36ab, (q15_t)0x36a6, (q15_t)0x36a0, (q15_t)0x369a, (q15_t)0x3695, + (q15_t)0x368f, (q15_t)0x3689, (q15_t)0x3684, (q15_t)0x367e, (q15_t)0x3678, + (q15_t)0x3673, (q15_t)0x366d, (q15_t)0x3667, (q15_t)0x3662, (q15_t)0x365c, + (q15_t)0x3656, (q15_t)0x3650, (q15_t)0x364b, (q15_t)0x3645, (q15_t)0x363f, + (q15_t)0x363a, (q15_t)0x3634, (q15_t)0x362e, (q15_t)0x3629, (q15_t)0x3623, + (q15_t)0x361d, (q15_t)0x3618, (q15_t)0x3612, (q15_t)0x360c, (q15_t)0x3606, + (q15_t)0x3601, (q15_t)0x35fb, (q15_t)0x35f5, (q15_t)0x35f0, (q15_t)0x35ea, + (q15_t)0x35e4, (q15_t)0x35df, (q15_t)0x35d9, (q15_t)0x35d3, (q15_t)0x35cd, + (q15_t)0x35c8, (q15_t)0x35c2, (q15_t)0x35bc, (q15_t)0x35b7, (q15_t)0x35b1, + (q15_t)0x35ab, (q15_t)0x35a6, (q15_t)0x35a0, (q15_t)0x359a, (q15_t)0x3594, + (q15_t)0x358f, (q15_t)0x3589, (q15_t)0x3583, (q15_t)0x357e, (q15_t)0x3578, + (q15_t)0x3572, (q15_t)0x356c, (q15_t)0x3567, (q15_t)0x3561, (q15_t)0x355b, + (q15_t)0x3556, (q15_t)0x3550, (q15_t)0x354a, (q15_t)0x3544, (q15_t)0x353f, + (q15_t)0x3539, (q15_t)0x3533, (q15_t)0x352e, (q15_t)0x3528, (q15_t)0x3522, + (q15_t)0x351c, (q15_t)0x3517, (q15_t)0x3511, (q15_t)0x350b, (q15_t)0x3506, + (q15_t)0x3500, (q15_t)0x34fa, (q15_t)0x34f4, (q15_t)0x34ef, (q15_t)0x34e9, + (q15_t)0x34e3, (q15_t)0x34de, (q15_t)0x34d8, (q15_t)0x34d2, (q15_t)0x34cc, + (q15_t)0x34c7, (q15_t)0x34c1, (q15_t)0x34bb, (q15_t)0x34b6, (q15_t)0x34b0, + (q15_t)0x34aa, (q15_t)0x34a4, (q15_t)0x349f, (q15_t)0x3499, (q15_t)0x3493, + (q15_t)0x348d, (q15_t)0x3488, (q15_t)0x3482, (q15_t)0x347c, (q15_t)0x3476, + (q15_t)0x3471, (q15_t)0x346b, (q15_t)0x3465, (q15_t)0x3460, (q15_t)0x345a, + (q15_t)0x3454, (q15_t)0x344e, (q15_t)0x3449, (q15_t)0x3443, (q15_t)0x343d, + (q15_t)0x3437, (q15_t)0x3432, (q15_t)0x342c, (q15_t)0x3426, (q15_t)0x3420, + (q15_t)0x341b, (q15_t)0x3415, (q15_t)0x340f, (q15_t)0x340a, (q15_t)0x3404, + (q15_t)0x33fe, (q15_t)0x33f8, (q15_t)0x33f3, (q15_t)0x33ed, (q15_t)0x33e7, + (q15_t)0x33e1, (q15_t)0x33dc, (q15_t)0x33d6, (q15_t)0x33d0, (q15_t)0x33ca, + (q15_t)0x33c5, (q15_t)0x33bf, (q15_t)0x33b9, (q15_t)0x33b3, (q15_t)0x33ae, + (q15_t)0x33a8, (q15_t)0x33a2, (q15_t)0x339c, (q15_t)0x3397, (q15_t)0x3391, + (q15_t)0x338b, (q15_t)0x3385, (q15_t)0x3380, (q15_t)0x337a, (q15_t)0x3374, + (q15_t)0x336e, (q15_t)0x3369, (q15_t)0x3363, (q15_t)0x335d, (q15_t)0x3357, + (q15_t)0x3352, (q15_t)0x334c, (q15_t)0x3346, (q15_t)0x3340, (q15_t)0x333b, + (q15_t)0x3335, (q15_t)0x332f, (q15_t)0x3329, (q15_t)0x3324, (q15_t)0x331e, + (q15_t)0x3318, (q15_t)0x3312, (q15_t)0x330c, (q15_t)0x3307, (q15_t)0x3301, + (q15_t)0x32fb, (q15_t)0x32f5, (q15_t)0x32f0, (q15_t)0x32ea, (q15_t)0x32e4, + (q15_t)0x32de, (q15_t)0x32d9, (q15_t)0x32d3, (q15_t)0x32cd, (q15_t)0x32c7, + (q15_t)0x32c2, (q15_t)0x32bc, (q15_t)0x32b6, (q15_t)0x32b0, (q15_t)0x32aa, + (q15_t)0x32a5, (q15_t)0x329f, (q15_t)0x3299, (q15_t)0x3293, (q15_t)0x328e, + (q15_t)0x3288, (q15_t)0x3282, (q15_t)0x327c, (q15_t)0x3276, (q15_t)0x3271, + (q15_t)0x326b, (q15_t)0x3265, (q15_t)0x325f, (q15_t)0x325a, (q15_t)0x3254, + (q15_t)0x324e, (q15_t)0x3248, (q15_t)0x3243, (q15_t)0x323d, (q15_t)0x3237, + (q15_t)0x3231, (q15_t)0x322b, (q15_t)0x3226, (q15_t)0x3220, (q15_t)0x321a, + (q15_t)0x3214, (q15_t)0x320e, (q15_t)0x3209, (q15_t)0x3203, (q15_t)0x31fd, + (q15_t)0x31f7, (q15_t)0x31f2, (q15_t)0x31ec, (q15_t)0x31e6, (q15_t)0x31e0, + (q15_t)0x31da, (q15_t)0x31d5, (q15_t)0x31cf, (q15_t)0x31c9, (q15_t)0x31c3, + (q15_t)0x31bd, (q15_t)0x31b8, (q15_t)0x31b2, (q15_t)0x31ac, (q15_t)0x31a6, + (q15_t)0x31a1, (q15_t)0x319b, (q15_t)0x3195, (q15_t)0x318f, (q15_t)0x3189, + (q15_t)0x3184, (q15_t)0x317e, (q15_t)0x3178, (q15_t)0x3172, (q15_t)0x316c, + (q15_t)0x3167, (q15_t)0x3161, (q15_t)0x315b, (q15_t)0x3155, (q15_t)0x314f, + (q15_t)0x314a, (q15_t)0x3144, (q15_t)0x313e, (q15_t)0x3138, (q15_t)0x3132, + (q15_t)0x312d, (q15_t)0x3127, (q15_t)0x3121, (q15_t)0x311b, (q15_t)0x3115, + (q15_t)0x3110, (q15_t)0x310a, (q15_t)0x3104, (q15_t)0x30fe, (q15_t)0x30f8, + (q15_t)0x30f3, (q15_t)0x30ed, (q15_t)0x30e7, (q15_t)0x30e1, (q15_t)0x30db, + (q15_t)0x30d6, (q15_t)0x30d0, (q15_t)0x30ca, (q15_t)0x30c4, (q15_t)0x30be, + (q15_t)0x30b8, (q15_t)0x30b3, (q15_t)0x30ad, (q15_t)0x30a7, (q15_t)0x30a1, + (q15_t)0x309b, (q15_t)0x3096, (q15_t)0x3090, (q15_t)0x308a, (q15_t)0x3084, + (q15_t)0x307e, (q15_t)0x3079, (q15_t)0x3073, (q15_t)0x306d, (q15_t)0x3067, + (q15_t)0x3061, (q15_t)0x305b, (q15_t)0x3056, (q15_t)0x3050, (q15_t)0x304a, + (q15_t)0x3044, (q15_t)0x303e, (q15_t)0x3039, (q15_t)0x3033, (q15_t)0x302d, + (q15_t)0x3027, (q15_t)0x3021, (q15_t)0x301b, (q15_t)0x3016, (q15_t)0x3010, + (q15_t)0x300a, (q15_t)0x3004, (q15_t)0x2ffe, (q15_t)0x2ff8, (q15_t)0x2ff3, + (q15_t)0x2fed, (q15_t)0x2fe7, (q15_t)0x2fe1, (q15_t)0x2fdb, (q15_t)0x2fd6, + (q15_t)0x2fd0, (q15_t)0x2fca, (q15_t)0x2fc4, (q15_t)0x2fbe, (q15_t)0x2fb8, + (q15_t)0x2fb3, (q15_t)0x2fad, (q15_t)0x2fa7, (q15_t)0x2fa1, (q15_t)0x2f9b, + (q15_t)0x2f95, (q15_t)0x2f90, (q15_t)0x2f8a, (q15_t)0x2f84, (q15_t)0x2f7e, + (q15_t)0x2f78, (q15_t)0x2f72, (q15_t)0x2f6d, (q15_t)0x2f67, (q15_t)0x2f61, + (q15_t)0x2f5b, (q15_t)0x2f55, (q15_t)0x2f4f, (q15_t)0x2f4a, (q15_t)0x2f44, + (q15_t)0x2f3e, (q15_t)0x2f38, (q15_t)0x2f32, (q15_t)0x2f2c, (q15_t)0x2f27, + (q15_t)0x2f21, (q15_t)0x2f1b, (q15_t)0x2f15, (q15_t)0x2f0f, (q15_t)0x2f09, + (q15_t)0x2f03, (q15_t)0x2efe, (q15_t)0x2ef8, (q15_t)0x2ef2, (q15_t)0x2eec, + (q15_t)0x2ee6, (q15_t)0x2ee0, (q15_t)0x2edb, (q15_t)0x2ed5, (q15_t)0x2ecf, + (q15_t)0x2ec9, (q15_t)0x2ec3, (q15_t)0x2ebd, (q15_t)0x2eb7, (q15_t)0x2eb2, + (q15_t)0x2eac, (q15_t)0x2ea6, (q15_t)0x2ea0, (q15_t)0x2e9a, (q15_t)0x2e94, + (q15_t)0x2e8e, (q15_t)0x2e89, (q15_t)0x2e83, (q15_t)0x2e7d, (q15_t)0x2e77, + (q15_t)0x2e71, (q15_t)0x2e6b, (q15_t)0x2e65, (q15_t)0x2e60, (q15_t)0x2e5a, + (q15_t)0x2e54, (q15_t)0x2e4e, (q15_t)0x2e48, (q15_t)0x2e42, (q15_t)0x2e3c, + (q15_t)0x2e37, (q15_t)0x2e31, (q15_t)0x2e2b, (q15_t)0x2e25, (q15_t)0x2e1f, + (q15_t)0x2e19, (q15_t)0x2e13, (q15_t)0x2e0e, (q15_t)0x2e08, (q15_t)0x2e02, + (q15_t)0x2dfc, (q15_t)0x2df6, (q15_t)0x2df0, (q15_t)0x2dea, (q15_t)0x2de5, + (q15_t)0x2ddf, (q15_t)0x2dd9, (q15_t)0x2dd3, (q15_t)0x2dcd, (q15_t)0x2dc7, + (q15_t)0x2dc1, (q15_t)0x2dbb, (q15_t)0x2db6, (q15_t)0x2db0, (q15_t)0x2daa, + (q15_t)0x2da4, (q15_t)0x2d9e, (q15_t)0x2d98, (q15_t)0x2d92, (q15_t)0x2d8d, + (q15_t)0x2d87, (q15_t)0x2d81, (q15_t)0x2d7b, (q15_t)0x2d75, (q15_t)0x2d6f, + (q15_t)0x2d69, (q15_t)0x2d63, (q15_t)0x2d5e, (q15_t)0x2d58, (q15_t)0x2d52, + (q15_t)0x2d4c, (q15_t)0x2d46, (q15_t)0x2d40, (q15_t)0x2d3a, (q15_t)0x2d34, + (q15_t)0x2d2f, (q15_t)0x2d29, (q15_t)0x2d23, (q15_t)0x2d1d, (q15_t)0x2d17, + (q15_t)0x2d11, (q15_t)0x2d0b, (q15_t)0x2d05, (q15_t)0x2cff, (q15_t)0x2cfa, + (q15_t)0x2cf4, (q15_t)0x2cee, (q15_t)0x2ce8, (q15_t)0x2ce2, (q15_t)0x2cdc, + (q15_t)0x2cd6, (q15_t)0x2cd0, (q15_t)0x2ccb, (q15_t)0x2cc5, (q15_t)0x2cbf, + (q15_t)0x2cb9, (q15_t)0x2cb3, (q15_t)0x2cad, (q15_t)0x2ca7, (q15_t)0x2ca1, + (q15_t)0x2c9b, (q15_t)0x2c96, (q15_t)0x2c90, (q15_t)0x2c8a, (q15_t)0x2c84, + (q15_t)0x2c7e, (q15_t)0x2c78, (q15_t)0x2c72, (q15_t)0x2c6c, (q15_t)0x2c66, + (q15_t)0x2c61, (q15_t)0x2c5b, (q15_t)0x2c55, (q15_t)0x2c4f, (q15_t)0x2c49, + (q15_t)0x2c43, (q15_t)0x2c3d, (q15_t)0x2c37, (q15_t)0x2c31, (q15_t)0x2c2b, + (q15_t)0x2c26, (q15_t)0x2c20, (q15_t)0x2c1a, (q15_t)0x2c14, (q15_t)0x2c0e, + (q15_t)0x2c08, (q15_t)0x2c02, (q15_t)0x2bfc, (q15_t)0x2bf6, (q15_t)0x2bf0, + (q15_t)0x2beb, (q15_t)0x2be5, (q15_t)0x2bdf, (q15_t)0x2bd9, (q15_t)0x2bd3, + (q15_t)0x2bcd, (q15_t)0x2bc7, (q15_t)0x2bc1, (q15_t)0x2bbb, (q15_t)0x2bb5, + (q15_t)0x2bb0, (q15_t)0x2baa, (q15_t)0x2ba4, (q15_t)0x2b9e, (q15_t)0x2b98, + (q15_t)0x2b92, (q15_t)0x2b8c, (q15_t)0x2b86, (q15_t)0x2b80, (q15_t)0x2b7a, + (q15_t)0x2b74, (q15_t)0x2b6f, (q15_t)0x2b69, (q15_t)0x2b63, (q15_t)0x2b5d, + (q15_t)0x2b57, (q15_t)0x2b51, (q15_t)0x2b4b, (q15_t)0x2b45, (q15_t)0x2b3f, + (q15_t)0x2b39, (q15_t)0x2b33, (q15_t)0x2b2d, (q15_t)0x2b28, (q15_t)0x2b22, + (q15_t)0x2b1c, (q15_t)0x2b16, (q15_t)0x2b10, (q15_t)0x2b0a, (q15_t)0x2b04, + (q15_t)0x2afe, (q15_t)0x2af8, (q15_t)0x2af2, (q15_t)0x2aec, (q15_t)0x2ae6, + (q15_t)0x2ae1, (q15_t)0x2adb, (q15_t)0x2ad5, (q15_t)0x2acf, (q15_t)0x2ac9, + (q15_t)0x2ac3, (q15_t)0x2abd, (q15_t)0x2ab7, (q15_t)0x2ab1, (q15_t)0x2aab, + (q15_t)0x2aa5, (q15_t)0x2a9f, (q15_t)0x2a99, (q15_t)0x2a94, (q15_t)0x2a8e, + (q15_t)0x2a88, (q15_t)0x2a82, (q15_t)0x2a7c, (q15_t)0x2a76, (q15_t)0x2a70, + (q15_t)0x2a6a, (q15_t)0x2a64, (q15_t)0x2a5e, (q15_t)0x2a58, (q15_t)0x2a52, + (q15_t)0x2a4c, (q15_t)0x2a47, (q15_t)0x2a41, (q15_t)0x2a3b, (q15_t)0x2a35, + (q15_t)0x2a2f, (q15_t)0x2a29, (q15_t)0x2a23, (q15_t)0x2a1d, (q15_t)0x2a17, + (q15_t)0x2a11, (q15_t)0x2a0b, (q15_t)0x2a05, (q15_t)0x29ff, (q15_t)0x29f9, + (q15_t)0x29f3, (q15_t)0x29ee, (q15_t)0x29e8, (q15_t)0x29e2, (q15_t)0x29dc, + (q15_t)0x29d6, (q15_t)0x29d0, (q15_t)0x29ca, (q15_t)0x29c4, (q15_t)0x29be, + (q15_t)0x29b8, (q15_t)0x29b2, (q15_t)0x29ac, (q15_t)0x29a6, (q15_t)0x29a0, + (q15_t)0x299a, (q15_t)0x2994, (q15_t)0x298e, (q15_t)0x2989, (q15_t)0x2983, + (q15_t)0x297d, (q15_t)0x2977, (q15_t)0x2971, (q15_t)0x296b, (q15_t)0x2965, + (q15_t)0x295f, (q15_t)0x2959, (q15_t)0x2953, (q15_t)0x294d, (q15_t)0x2947, + (q15_t)0x2941, (q15_t)0x293b, (q15_t)0x2935, (q15_t)0x292f, (q15_t)0x2929, + (q15_t)0x2923, (q15_t)0x291d, (q15_t)0x2918, (q15_t)0x2912, (q15_t)0x290c, + (q15_t)0x2906, (q15_t)0x2900, (q15_t)0x28fa, (q15_t)0x28f4, (q15_t)0x28ee, + (q15_t)0x28e8, (q15_t)0x28e2, (q15_t)0x28dc, (q15_t)0x28d6, (q15_t)0x28d0, + (q15_t)0x28ca, (q15_t)0x28c4, (q15_t)0x28be, (q15_t)0x28b8, (q15_t)0x28b2, + (q15_t)0x28ac, (q15_t)0x28a6, (q15_t)0x28a0, (q15_t)0x289a, (q15_t)0x2895, + (q15_t)0x288f, (q15_t)0x2889, (q15_t)0x2883, (q15_t)0x287d, (q15_t)0x2877, + (q15_t)0x2871, (q15_t)0x286b, (q15_t)0x2865, (q15_t)0x285f, (q15_t)0x2859, + (q15_t)0x2853, (q15_t)0x284d, (q15_t)0x2847, (q15_t)0x2841, (q15_t)0x283b, + (q15_t)0x2835, (q15_t)0x282f, (q15_t)0x2829, (q15_t)0x2823, (q15_t)0x281d, + (q15_t)0x2817, (q15_t)0x2811, (q15_t)0x280b, (q15_t)0x2805, (q15_t)0x27ff, + (q15_t)0x27f9, (q15_t)0x27f3, (q15_t)0x27ee, (q15_t)0x27e8, (q15_t)0x27e2, + (q15_t)0x27dc, (q15_t)0x27d6, (q15_t)0x27d0, (q15_t)0x27ca, (q15_t)0x27c4, + (q15_t)0x27be, (q15_t)0x27b8, (q15_t)0x27b2, (q15_t)0x27ac, (q15_t)0x27a6, + (q15_t)0x27a0, (q15_t)0x279a, (q15_t)0x2794, (q15_t)0x278e, (q15_t)0x2788, + (q15_t)0x2782, (q15_t)0x277c, (q15_t)0x2776, (q15_t)0x2770, (q15_t)0x276a, + (q15_t)0x2764, (q15_t)0x275e, (q15_t)0x2758, (q15_t)0x2752, (q15_t)0x274c, + (q15_t)0x2746, (q15_t)0x2740, (q15_t)0x273a, (q15_t)0x2734, (q15_t)0x272e, + (q15_t)0x2728, (q15_t)0x2722, (q15_t)0x271c, (q15_t)0x2716, (q15_t)0x2710, + (q15_t)0x270a, (q15_t)0x2704, (q15_t)0x26fe, (q15_t)0x26f8, (q15_t)0x26f2, + (q15_t)0x26ec, (q15_t)0x26e7, (q15_t)0x26e1, (q15_t)0x26db, (q15_t)0x26d5, + (q15_t)0x26cf, (q15_t)0x26c9, (q15_t)0x26c3, (q15_t)0x26bd, (q15_t)0x26b7, + (q15_t)0x26b1, (q15_t)0x26ab, (q15_t)0x26a5, (q15_t)0x269f, (q15_t)0x2699, + (q15_t)0x2693, (q15_t)0x268d, (q15_t)0x2687, (q15_t)0x2681, (q15_t)0x267b, + (q15_t)0x2675, (q15_t)0x266f, (q15_t)0x2669, (q15_t)0x2663, (q15_t)0x265d, + (q15_t)0x2657, (q15_t)0x2651, (q15_t)0x264b, (q15_t)0x2645, (q15_t)0x263f, + (q15_t)0x2639, (q15_t)0x2633, (q15_t)0x262d, (q15_t)0x2627, (q15_t)0x2621, + (q15_t)0x261b, (q15_t)0x2615, (q15_t)0x260f, (q15_t)0x2609, (q15_t)0x2603, + (q15_t)0x25fd, (q15_t)0x25f7, (q15_t)0x25f1, (q15_t)0x25eb, (q15_t)0x25e5, + (q15_t)0x25df, (q15_t)0x25d9, (q15_t)0x25d3, (q15_t)0x25cd, (q15_t)0x25c7, + (q15_t)0x25c1, (q15_t)0x25bb, (q15_t)0x25b5, (q15_t)0x25af, (q15_t)0x25a9, + (q15_t)0x25a3, (q15_t)0x259d, (q15_t)0x2597, (q15_t)0x2591, (q15_t)0x258b, + (q15_t)0x2585, (q15_t)0x257f, (q15_t)0x2579, (q15_t)0x2573, (q15_t)0x256d, + (q15_t)0x2567, (q15_t)0x2561, (q15_t)0x255b, (q15_t)0x2555, (q15_t)0x254f, + (q15_t)0x2549, (q15_t)0x2543, (q15_t)0x253d, (q15_t)0x2537, (q15_t)0x2531, + (q15_t)0x252b, (q15_t)0x2525, (q15_t)0x251f, (q15_t)0x2519, (q15_t)0x2513, + (q15_t)0x250c, (q15_t)0x2506, (q15_t)0x2500, (q15_t)0x24fa, (q15_t)0x24f4, + (q15_t)0x24ee, (q15_t)0x24e8, (q15_t)0x24e2, (q15_t)0x24dc, (q15_t)0x24d6, + (q15_t)0x24d0, (q15_t)0x24ca, (q15_t)0x24c4, (q15_t)0x24be, (q15_t)0x24b8, + (q15_t)0x24b2, (q15_t)0x24ac, (q15_t)0x24a6, (q15_t)0x24a0, (q15_t)0x249a, + (q15_t)0x2494, (q15_t)0x248e, (q15_t)0x2488, (q15_t)0x2482, (q15_t)0x247c, + (q15_t)0x2476, (q15_t)0x2470, (q15_t)0x246a, (q15_t)0x2464, (q15_t)0x245e, + (q15_t)0x2458, (q15_t)0x2452, (q15_t)0x244c, (q15_t)0x2446, (q15_t)0x2440, + (q15_t)0x243a, (q15_t)0x2434, (q15_t)0x242e, (q15_t)0x2428, (q15_t)0x2422, + (q15_t)0x241c, (q15_t)0x2416, (q15_t)0x2410, (q15_t)0x240a, (q15_t)0x2404, + (q15_t)0x23fd, (q15_t)0x23f7, (q15_t)0x23f1, (q15_t)0x23eb, (q15_t)0x23e5, + (q15_t)0x23df, (q15_t)0x23d9, (q15_t)0x23d3, (q15_t)0x23cd, (q15_t)0x23c7, + (q15_t)0x23c1, (q15_t)0x23bb, (q15_t)0x23b5, (q15_t)0x23af, (q15_t)0x23a9, + (q15_t)0x23a3, (q15_t)0x239d, (q15_t)0x2397, (q15_t)0x2391, (q15_t)0x238b, + (q15_t)0x2385, (q15_t)0x237f, (q15_t)0x2379, (q15_t)0x2373, (q15_t)0x236d, + (q15_t)0x2367, (q15_t)0x2361, (q15_t)0x235b, (q15_t)0x2355, (q15_t)0x234e, + (q15_t)0x2348, (q15_t)0x2342, (q15_t)0x233c, (q15_t)0x2336, (q15_t)0x2330, + (q15_t)0x232a, (q15_t)0x2324, (q15_t)0x231e, (q15_t)0x2318, (q15_t)0x2312, + (q15_t)0x230c, (q15_t)0x2306, (q15_t)0x2300, (q15_t)0x22fa, (q15_t)0x22f4, + (q15_t)0x22ee, (q15_t)0x22e8, (q15_t)0x22e2, (q15_t)0x22dc, (q15_t)0x22d6, + (q15_t)0x22d0, (q15_t)0x22ca, (q15_t)0x22c4, (q15_t)0x22bd, (q15_t)0x22b7, + (q15_t)0x22b1, (q15_t)0x22ab, (q15_t)0x22a5, (q15_t)0x229f, (q15_t)0x2299, + (q15_t)0x2293, (q15_t)0x228d, (q15_t)0x2287, (q15_t)0x2281, (q15_t)0x227b, + (q15_t)0x2275, (q15_t)0x226f, (q15_t)0x2269, (q15_t)0x2263, (q15_t)0x225d, + (q15_t)0x2257, (q15_t)0x2251, (q15_t)0x224a, (q15_t)0x2244, (q15_t)0x223e, + (q15_t)0x2238, (q15_t)0x2232, (q15_t)0x222c, (q15_t)0x2226, (q15_t)0x2220, + (q15_t)0x221a, (q15_t)0x2214, (q15_t)0x220e, (q15_t)0x2208, (q15_t)0x2202, + (q15_t)0x21fc, (q15_t)0x21f6, (q15_t)0x21f0, (q15_t)0x21ea, (q15_t)0x21e4, + (q15_t)0x21dd, (q15_t)0x21d7, (q15_t)0x21d1, (q15_t)0x21cb, (q15_t)0x21c5, + (q15_t)0x21bf, (q15_t)0x21b9, (q15_t)0x21b3, (q15_t)0x21ad, (q15_t)0x21a7, + (q15_t)0x21a1, (q15_t)0x219b, (q15_t)0x2195, (q15_t)0x218f, (q15_t)0x2189, + (q15_t)0x2183, (q15_t)0x217c, (q15_t)0x2176, (q15_t)0x2170, (q15_t)0x216a, + (q15_t)0x2164, (q15_t)0x215e, (q15_t)0x2158, (q15_t)0x2152, (q15_t)0x214c, + (q15_t)0x2146, (q15_t)0x2140, (q15_t)0x213a, (q15_t)0x2134, (q15_t)0x212e, + (q15_t)0x2128, (q15_t)0x2121, (q15_t)0x211b, (q15_t)0x2115, (q15_t)0x210f, + (q15_t)0x2109, (q15_t)0x2103, (q15_t)0x20fd, (q15_t)0x20f7, (q15_t)0x20f1, + (q15_t)0x20eb, (q15_t)0x20e5, (q15_t)0x20df, (q15_t)0x20d9, (q15_t)0x20d3, + (q15_t)0x20cc, (q15_t)0x20c6, (q15_t)0x20c0, (q15_t)0x20ba, (q15_t)0x20b4, + (q15_t)0x20ae, (q15_t)0x20a8, (q15_t)0x20a2, (q15_t)0x209c, (q15_t)0x2096, + (q15_t)0x2090, (q15_t)0x208a, (q15_t)0x2084, (q15_t)0x207e, (q15_t)0x2077, + (q15_t)0x2071, (q15_t)0x206b, (q15_t)0x2065, (q15_t)0x205f, (q15_t)0x2059, + (q15_t)0x2053, (q15_t)0x204d, (q15_t)0x2047, (q15_t)0x2041, (q15_t)0x203b, + (q15_t)0x2035, (q15_t)0x202e, (q15_t)0x2028, (q15_t)0x2022, (q15_t)0x201c, + (q15_t)0x2016, (q15_t)0x2010, (q15_t)0x200a, (q15_t)0x2004, (q15_t)0x1ffe, + (q15_t)0x1ff8, (q15_t)0x1ff2, (q15_t)0x1fec, (q15_t)0x1fe5, (q15_t)0x1fdf, + (q15_t)0x1fd9, (q15_t)0x1fd3, (q15_t)0x1fcd, (q15_t)0x1fc7, (q15_t)0x1fc1, + (q15_t)0x1fbb, (q15_t)0x1fb5, (q15_t)0x1faf, (q15_t)0x1fa9, (q15_t)0x1fa3, + (q15_t)0x1f9c, (q15_t)0x1f96, (q15_t)0x1f90, (q15_t)0x1f8a, (q15_t)0x1f84, + (q15_t)0x1f7e, (q15_t)0x1f78, (q15_t)0x1f72, (q15_t)0x1f6c, (q15_t)0x1f66, + (q15_t)0x1f60, (q15_t)0x1f59, (q15_t)0x1f53, (q15_t)0x1f4d, (q15_t)0x1f47, + (q15_t)0x1f41, (q15_t)0x1f3b, (q15_t)0x1f35, (q15_t)0x1f2f, (q15_t)0x1f29, + (q15_t)0x1f23, (q15_t)0x1f1d, (q15_t)0x1f16, (q15_t)0x1f10, (q15_t)0x1f0a, + (q15_t)0x1f04, (q15_t)0x1efe, (q15_t)0x1ef8, (q15_t)0x1ef2, (q15_t)0x1eec, + (q15_t)0x1ee6, (q15_t)0x1ee0, (q15_t)0x1ed9, (q15_t)0x1ed3, (q15_t)0x1ecd, + (q15_t)0x1ec7, (q15_t)0x1ec1, (q15_t)0x1ebb, (q15_t)0x1eb5, (q15_t)0x1eaf, + (q15_t)0x1ea9, (q15_t)0x1ea3, (q15_t)0x1e9c, (q15_t)0x1e96, (q15_t)0x1e90, + (q15_t)0x1e8a, (q15_t)0x1e84, (q15_t)0x1e7e, (q15_t)0x1e78, (q15_t)0x1e72, + (q15_t)0x1e6c, (q15_t)0x1e66, (q15_t)0x1e5f, (q15_t)0x1e59, (q15_t)0x1e53, + (q15_t)0x1e4d, (q15_t)0x1e47, (q15_t)0x1e41, (q15_t)0x1e3b, (q15_t)0x1e35, + (q15_t)0x1e2f, (q15_t)0x1e29, (q15_t)0x1e22, (q15_t)0x1e1c, (q15_t)0x1e16, + (q15_t)0x1e10, (q15_t)0x1e0a, (q15_t)0x1e04, (q15_t)0x1dfe, (q15_t)0x1df8, + (q15_t)0x1df2, (q15_t)0x1deb, (q15_t)0x1de5, (q15_t)0x1ddf, (q15_t)0x1dd9, + (q15_t)0x1dd3, (q15_t)0x1dcd, (q15_t)0x1dc7, (q15_t)0x1dc1, (q15_t)0x1dbb, + (q15_t)0x1db4, (q15_t)0x1dae, (q15_t)0x1da8, (q15_t)0x1da2, (q15_t)0x1d9c, + (q15_t)0x1d96, (q15_t)0x1d90, (q15_t)0x1d8a, (q15_t)0x1d84, (q15_t)0x1d7d, + (q15_t)0x1d77, (q15_t)0x1d71, (q15_t)0x1d6b, (q15_t)0x1d65, (q15_t)0x1d5f, + (q15_t)0x1d59, (q15_t)0x1d53, (q15_t)0x1d4c, (q15_t)0x1d46, (q15_t)0x1d40, + (q15_t)0x1d3a, (q15_t)0x1d34, (q15_t)0x1d2e, (q15_t)0x1d28, (q15_t)0x1d22, + (q15_t)0x1d1c, (q15_t)0x1d15, (q15_t)0x1d0f, (q15_t)0x1d09, (q15_t)0x1d03, + (q15_t)0x1cfd, (q15_t)0x1cf7, (q15_t)0x1cf1, (q15_t)0x1ceb, (q15_t)0x1ce4, + (q15_t)0x1cde, (q15_t)0x1cd8, (q15_t)0x1cd2, (q15_t)0x1ccc, (q15_t)0x1cc6, + (q15_t)0x1cc0, (q15_t)0x1cba, (q15_t)0x1cb3, (q15_t)0x1cad, (q15_t)0x1ca7, + (q15_t)0x1ca1, (q15_t)0x1c9b, (q15_t)0x1c95, (q15_t)0x1c8f, (q15_t)0x1c89, + (q15_t)0x1c83, (q15_t)0x1c7c, (q15_t)0x1c76, (q15_t)0x1c70, (q15_t)0x1c6a, + (q15_t)0x1c64, (q15_t)0x1c5e, (q15_t)0x1c58, (q15_t)0x1c51, (q15_t)0x1c4b, + (q15_t)0x1c45, (q15_t)0x1c3f, (q15_t)0x1c39, (q15_t)0x1c33, (q15_t)0x1c2d, + (q15_t)0x1c27, (q15_t)0x1c20, (q15_t)0x1c1a, (q15_t)0x1c14, (q15_t)0x1c0e, + (q15_t)0x1c08, (q15_t)0x1c02, (q15_t)0x1bfc, (q15_t)0x1bf6, (q15_t)0x1bef, + (q15_t)0x1be9, (q15_t)0x1be3, (q15_t)0x1bdd, (q15_t)0x1bd7, (q15_t)0x1bd1, + (q15_t)0x1bcb, (q15_t)0x1bc4, (q15_t)0x1bbe, (q15_t)0x1bb8, (q15_t)0x1bb2, + (q15_t)0x1bac, (q15_t)0x1ba6, (q15_t)0x1ba0, (q15_t)0x1b9a, (q15_t)0x1b93, + (q15_t)0x1b8d, (q15_t)0x1b87, (q15_t)0x1b81, (q15_t)0x1b7b, (q15_t)0x1b75, + (q15_t)0x1b6f, (q15_t)0x1b68, (q15_t)0x1b62, (q15_t)0x1b5c, (q15_t)0x1b56, + (q15_t)0x1b50, (q15_t)0x1b4a, (q15_t)0x1b44, (q15_t)0x1b3d, (q15_t)0x1b37, + (q15_t)0x1b31, (q15_t)0x1b2b, (q15_t)0x1b25, (q15_t)0x1b1f, (q15_t)0x1b19, + (q15_t)0x1b13, (q15_t)0x1b0c, (q15_t)0x1b06, (q15_t)0x1b00, (q15_t)0x1afa, + (q15_t)0x1af4, (q15_t)0x1aee, (q15_t)0x1ae8, (q15_t)0x1ae1, (q15_t)0x1adb, + (q15_t)0x1ad5, (q15_t)0x1acf, (q15_t)0x1ac9, (q15_t)0x1ac3, (q15_t)0x1abd, + (q15_t)0x1ab6, (q15_t)0x1ab0, (q15_t)0x1aaa, (q15_t)0x1aa4, (q15_t)0x1a9e, + (q15_t)0x1a98, (q15_t)0x1a91, (q15_t)0x1a8b, (q15_t)0x1a85, (q15_t)0x1a7f, + (q15_t)0x1a79, (q15_t)0x1a73, (q15_t)0x1a6d, (q15_t)0x1a66, (q15_t)0x1a60, + (q15_t)0x1a5a, (q15_t)0x1a54, (q15_t)0x1a4e, (q15_t)0x1a48, (q15_t)0x1a42, + (q15_t)0x1a3b, (q15_t)0x1a35, (q15_t)0x1a2f, (q15_t)0x1a29, (q15_t)0x1a23, + (q15_t)0x1a1d, (q15_t)0x1a17, (q15_t)0x1a10, (q15_t)0x1a0a, (q15_t)0x1a04, + (q15_t)0x19fe, (q15_t)0x19f8, (q15_t)0x19f2, (q15_t)0x19eb, (q15_t)0x19e5, + (q15_t)0x19df, (q15_t)0x19d9, (q15_t)0x19d3, (q15_t)0x19cd, (q15_t)0x19c7, + (q15_t)0x19c0, (q15_t)0x19ba, (q15_t)0x19b4, (q15_t)0x19ae, (q15_t)0x19a8, + (q15_t)0x19a2, (q15_t)0x199b, (q15_t)0x1995, (q15_t)0x198f, (q15_t)0x1989, + (q15_t)0x1983, (q15_t)0x197d, (q15_t)0x1977, (q15_t)0x1970, (q15_t)0x196a, + (q15_t)0x1964, (q15_t)0x195e, (q15_t)0x1958, (q15_t)0x1952, (q15_t)0x194b, + (q15_t)0x1945, (q15_t)0x193f, (q15_t)0x1939, (q15_t)0x1933, (q15_t)0x192d, + (q15_t)0x1926, (q15_t)0x1920, (q15_t)0x191a, (q15_t)0x1914, (q15_t)0x190e, + (q15_t)0x1908, (q15_t)0x1901, (q15_t)0x18fb, (q15_t)0x18f5, (q15_t)0x18ef, + (q15_t)0x18e9, (q15_t)0x18e3, (q15_t)0x18dc, (q15_t)0x18d6, (q15_t)0x18d0, + (q15_t)0x18ca, (q15_t)0x18c4, (q15_t)0x18be, (q15_t)0x18b8, (q15_t)0x18b1, + (q15_t)0x18ab, (q15_t)0x18a5, (q15_t)0x189f, (q15_t)0x1899, (q15_t)0x1893, + (q15_t)0x188c, (q15_t)0x1886, (q15_t)0x1880, (q15_t)0x187a, (q15_t)0x1874, + (q15_t)0x186e, (q15_t)0x1867, (q15_t)0x1861, (q15_t)0x185b, (q15_t)0x1855, + (q15_t)0x184f, (q15_t)0x1848, (q15_t)0x1842, (q15_t)0x183c, (q15_t)0x1836, + (q15_t)0x1830, (q15_t)0x182a, (q15_t)0x1823, (q15_t)0x181d, (q15_t)0x1817, + (q15_t)0x1811, (q15_t)0x180b, (q15_t)0x1805, (q15_t)0x17fe, (q15_t)0x17f8, + (q15_t)0x17f2, (q15_t)0x17ec, (q15_t)0x17e6, (q15_t)0x17e0, (q15_t)0x17d9, + (q15_t)0x17d3, (q15_t)0x17cd, (q15_t)0x17c7, (q15_t)0x17c1, (q15_t)0x17bb, + (q15_t)0x17b4, (q15_t)0x17ae, (q15_t)0x17a8, (q15_t)0x17a2, (q15_t)0x179c, + (q15_t)0x1795, (q15_t)0x178f, (q15_t)0x1789, (q15_t)0x1783, (q15_t)0x177d, + (q15_t)0x1777, (q15_t)0x1770, (q15_t)0x176a, (q15_t)0x1764, (q15_t)0x175e, + (q15_t)0x1758, (q15_t)0x1752, (q15_t)0x174b, (q15_t)0x1745, (q15_t)0x173f, + (q15_t)0x1739, (q15_t)0x1733, (q15_t)0x172c, (q15_t)0x1726, (q15_t)0x1720, + (q15_t)0x171a, (q15_t)0x1714, (q15_t)0x170e, (q15_t)0x1707, (q15_t)0x1701, + (q15_t)0x16fb, (q15_t)0x16f5, (q15_t)0x16ef, (q15_t)0x16e8, (q15_t)0x16e2, + (q15_t)0x16dc, (q15_t)0x16d6, (q15_t)0x16d0, (q15_t)0x16ca, (q15_t)0x16c3, + (q15_t)0x16bd, (q15_t)0x16b7, (q15_t)0x16b1, (q15_t)0x16ab, (q15_t)0x16a4, + (q15_t)0x169e, (q15_t)0x1698, (q15_t)0x1692, (q15_t)0x168c, (q15_t)0x1686, + (q15_t)0x167f, (q15_t)0x1679, (q15_t)0x1673, (q15_t)0x166d, (q15_t)0x1667, + (q15_t)0x1660, (q15_t)0x165a, (q15_t)0x1654, (q15_t)0x164e, (q15_t)0x1648, + (q15_t)0x1642, (q15_t)0x163b, (q15_t)0x1635, (q15_t)0x162f, (q15_t)0x1629, + (q15_t)0x1623, (q15_t)0x161c, (q15_t)0x1616, (q15_t)0x1610, (q15_t)0x160a, + (q15_t)0x1604, (q15_t)0x15fd, (q15_t)0x15f7, (q15_t)0x15f1, (q15_t)0x15eb, + (q15_t)0x15e5, (q15_t)0x15de, (q15_t)0x15d8, (q15_t)0x15d2, (q15_t)0x15cc, + (q15_t)0x15c6, (q15_t)0x15c0, (q15_t)0x15b9, (q15_t)0x15b3, (q15_t)0x15ad, + (q15_t)0x15a7, (q15_t)0x15a1, (q15_t)0x159a, (q15_t)0x1594, (q15_t)0x158e, + (q15_t)0x1588, (q15_t)0x1582, (q15_t)0x157b, (q15_t)0x1575, (q15_t)0x156f, + (q15_t)0x1569, (q15_t)0x1563, (q15_t)0x155c, (q15_t)0x1556, (q15_t)0x1550, + (q15_t)0x154a, (q15_t)0x1544, (q15_t)0x153d, (q15_t)0x1537, (q15_t)0x1531, + (q15_t)0x152b, (q15_t)0x1525, (q15_t)0x151e, (q15_t)0x1518, (q15_t)0x1512, + (q15_t)0x150c, (q15_t)0x1506, (q15_t)0x14ff, (q15_t)0x14f9, (q15_t)0x14f3, + (q15_t)0x14ed, (q15_t)0x14e7, (q15_t)0x14e0, (q15_t)0x14da, (q15_t)0x14d4, + (q15_t)0x14ce, (q15_t)0x14c8, (q15_t)0x14c1, (q15_t)0x14bb, (q15_t)0x14b5, + (q15_t)0x14af, (q15_t)0x14a9, (q15_t)0x14a2, (q15_t)0x149c, (q15_t)0x1496, + (q15_t)0x1490, (q15_t)0x148a, (q15_t)0x1483, (q15_t)0x147d, (q15_t)0x1477, + (q15_t)0x1471, (q15_t)0x146b, (q15_t)0x1464, (q15_t)0x145e, (q15_t)0x1458, + (q15_t)0x1452, (q15_t)0x144c, (q15_t)0x1445, (q15_t)0x143f, (q15_t)0x1439, + (q15_t)0x1433, (q15_t)0x142d, (q15_t)0x1426, (q15_t)0x1420, (q15_t)0x141a, + (q15_t)0x1414, (q15_t)0x140e, (q15_t)0x1407, (q15_t)0x1401, (q15_t)0x13fb, + (q15_t)0x13f5, (q15_t)0x13ef, (q15_t)0x13e8, (q15_t)0x13e2, (q15_t)0x13dc, + (q15_t)0x13d6, (q15_t)0x13d0, (q15_t)0x13c9, (q15_t)0x13c3, (q15_t)0x13bd, + (q15_t)0x13b7, (q15_t)0x13b1, (q15_t)0x13aa, (q15_t)0x13a4, (q15_t)0x139e, + (q15_t)0x1398, (q15_t)0x1391, (q15_t)0x138b, (q15_t)0x1385, (q15_t)0x137f, + (q15_t)0x1379, (q15_t)0x1372, (q15_t)0x136c, (q15_t)0x1366, (q15_t)0x1360, + (q15_t)0x135a, (q15_t)0x1353, (q15_t)0x134d, (q15_t)0x1347, (q15_t)0x1341, + (q15_t)0x133b, (q15_t)0x1334, (q15_t)0x132e, (q15_t)0x1328, (q15_t)0x1322, + (q15_t)0x131b, (q15_t)0x1315, (q15_t)0x130f, (q15_t)0x1309, (q15_t)0x1303, + (q15_t)0x12fc, (q15_t)0x12f6, (q15_t)0x12f0, (q15_t)0x12ea, (q15_t)0x12e4, + (q15_t)0x12dd, (q15_t)0x12d7, (q15_t)0x12d1, (q15_t)0x12cb, (q15_t)0x12c4, + (q15_t)0x12be, (q15_t)0x12b8, (q15_t)0x12b2, (q15_t)0x12ac, (q15_t)0x12a5, + (q15_t)0x129f, (q15_t)0x1299, (q15_t)0x1293, (q15_t)0x128d, (q15_t)0x1286, + (q15_t)0x1280, (q15_t)0x127a, (q15_t)0x1274, (q15_t)0x126d, (q15_t)0x1267, + (q15_t)0x1261, (q15_t)0x125b, (q15_t)0x1255, (q15_t)0x124e, (q15_t)0x1248, + (q15_t)0x1242, (q15_t)0x123c, (q15_t)0x1235, (q15_t)0x122f, (q15_t)0x1229, + (q15_t)0x1223, (q15_t)0x121d, (q15_t)0x1216, (q15_t)0x1210, (q15_t)0x120a, + (q15_t)0x1204, (q15_t)0x11fd, (q15_t)0x11f7, (q15_t)0x11f1, (q15_t)0x11eb, + (q15_t)0x11e5, (q15_t)0x11de, (q15_t)0x11d8, (q15_t)0x11d2, (q15_t)0x11cc, + (q15_t)0x11c5, (q15_t)0x11bf, (q15_t)0x11b9, (q15_t)0x11b3, (q15_t)0x11ad, + (q15_t)0x11a6, (q15_t)0x11a0, (q15_t)0x119a, (q15_t)0x1194, (q15_t)0x118d, + (q15_t)0x1187, (q15_t)0x1181, (q15_t)0x117b, (q15_t)0x1175, (q15_t)0x116e, + (q15_t)0x1168, (q15_t)0x1162, (q15_t)0x115c, (q15_t)0x1155, (q15_t)0x114f, + (q15_t)0x1149, (q15_t)0x1143, (q15_t)0x113d, (q15_t)0x1136, (q15_t)0x1130, + (q15_t)0x112a, (q15_t)0x1124, (q15_t)0x111d, (q15_t)0x1117, (q15_t)0x1111, + (q15_t)0x110b, (q15_t)0x1105, (q15_t)0x10fe, (q15_t)0x10f8, (q15_t)0x10f2, + (q15_t)0x10ec, (q15_t)0x10e5, (q15_t)0x10df, (q15_t)0x10d9, (q15_t)0x10d3, + (q15_t)0x10cc, (q15_t)0x10c6, (q15_t)0x10c0, (q15_t)0x10ba, (q15_t)0x10b4, + (q15_t)0x10ad, (q15_t)0x10a7, (q15_t)0x10a1, (q15_t)0x109b, (q15_t)0x1094, + (q15_t)0x108e, (q15_t)0x1088, (q15_t)0x1082, (q15_t)0x107b, (q15_t)0x1075, + (q15_t)0x106f, (q15_t)0x1069, (q15_t)0x1063, (q15_t)0x105c, (q15_t)0x1056, + (q15_t)0x1050, (q15_t)0x104a, (q15_t)0x1043, (q15_t)0x103d, (q15_t)0x1037, + (q15_t)0x1031, (q15_t)0x102a, (q15_t)0x1024, (q15_t)0x101e, (q15_t)0x1018, + (q15_t)0x1012, (q15_t)0x100b, (q15_t)0x1005, (q15_t)0xfff, (q15_t)0xff9, + (q15_t)0xff2, (q15_t)0xfec, (q15_t)0xfe6, (q15_t)0xfe0, (q15_t)0xfd9, + (q15_t)0xfd3, (q15_t)0xfcd, (q15_t)0xfc7, (q15_t)0xfc0, (q15_t)0xfba, + (q15_t)0xfb4, (q15_t)0xfae, (q15_t)0xfa8, (q15_t)0xfa1, (q15_t)0xf9b, + (q15_t)0xf95, (q15_t)0xf8f, (q15_t)0xf88, (q15_t)0xf82, (q15_t)0xf7c, + (q15_t)0xf76, (q15_t)0xf6f, (q15_t)0xf69, (q15_t)0xf63, (q15_t)0xf5d, + (q15_t)0xf56, (q15_t)0xf50, (q15_t)0xf4a, (q15_t)0xf44, (q15_t)0xf3e, + (q15_t)0xf37, (q15_t)0xf31, (q15_t)0xf2b, (q15_t)0xf25, (q15_t)0xf1e, + (q15_t)0xf18, (q15_t)0xf12, (q15_t)0xf0c, (q15_t)0xf05, (q15_t)0xeff, + (q15_t)0xef9, (q15_t)0xef3, (q15_t)0xeec, (q15_t)0xee6, (q15_t)0xee0, + (q15_t)0xeda, (q15_t)0xed3, (q15_t)0xecd, (q15_t)0xec7, (q15_t)0xec1, + (q15_t)0xeba, (q15_t)0xeb4, (q15_t)0xeae, (q15_t)0xea8, (q15_t)0xea1, + (q15_t)0xe9b, (q15_t)0xe95, (q15_t)0xe8f, (q15_t)0xe89, (q15_t)0xe82, + (q15_t)0xe7c, (q15_t)0xe76, (q15_t)0xe70, (q15_t)0xe69, (q15_t)0xe63, + (q15_t)0xe5d, (q15_t)0xe57, (q15_t)0xe50, (q15_t)0xe4a, (q15_t)0xe44, + (q15_t)0xe3e, (q15_t)0xe37, (q15_t)0xe31, (q15_t)0xe2b, (q15_t)0xe25, + (q15_t)0xe1e, (q15_t)0xe18, (q15_t)0xe12, (q15_t)0xe0c, (q15_t)0xe05, + (q15_t)0xdff, (q15_t)0xdf9, (q15_t)0xdf3, (q15_t)0xdec, (q15_t)0xde6, + (q15_t)0xde0, (q15_t)0xdda, (q15_t)0xdd3, (q15_t)0xdcd, (q15_t)0xdc7, + (q15_t)0xdc1, (q15_t)0xdba, (q15_t)0xdb4, (q15_t)0xdae, (q15_t)0xda8, + (q15_t)0xda1, (q15_t)0xd9b, (q15_t)0xd95, (q15_t)0xd8f, (q15_t)0xd88, + (q15_t)0xd82, (q15_t)0xd7c, (q15_t)0xd76, (q15_t)0xd6f, (q15_t)0xd69, + (q15_t)0xd63, (q15_t)0xd5d, (q15_t)0xd56, (q15_t)0xd50, (q15_t)0xd4a, + (q15_t)0xd44, (q15_t)0xd3d, (q15_t)0xd37, (q15_t)0xd31, (q15_t)0xd2b, + (q15_t)0xd24, (q15_t)0xd1e, (q15_t)0xd18, (q15_t)0xd12, (q15_t)0xd0b, + (q15_t)0xd05, (q15_t)0xcff, (q15_t)0xcf9, (q15_t)0xcf2, (q15_t)0xcec, + (q15_t)0xce6, (q15_t)0xce0, (q15_t)0xcd9, (q15_t)0xcd3, (q15_t)0xccd, + (q15_t)0xcc7, (q15_t)0xcc0, (q15_t)0xcba, (q15_t)0xcb4, (q15_t)0xcae, + (q15_t)0xca7, (q15_t)0xca1, (q15_t)0xc9b, (q15_t)0xc95, (q15_t)0xc8e, + (q15_t)0xc88, (q15_t)0xc82, (q15_t)0xc7c, (q15_t)0xc75, (q15_t)0xc6f, + (q15_t)0xc69, (q15_t)0xc63, (q15_t)0xc5c, (q15_t)0xc56, (q15_t)0xc50, + (q15_t)0xc4a, (q15_t)0xc43, (q15_t)0xc3d, (q15_t)0xc37, (q15_t)0xc31, + (q15_t)0xc2a, (q15_t)0xc24, (q15_t)0xc1e, (q15_t)0xc18, (q15_t)0xc11, + (q15_t)0xc0b, (q15_t)0xc05, (q15_t)0xbff, (q15_t)0xbf8, (q15_t)0xbf2, + (q15_t)0xbec, (q15_t)0xbe6, (q15_t)0xbdf, (q15_t)0xbd9, (q15_t)0xbd3, + (q15_t)0xbcd, (q15_t)0xbc6, (q15_t)0xbc0, (q15_t)0xbba, (q15_t)0xbb4, + (q15_t)0xbad, (q15_t)0xba7, (q15_t)0xba1, (q15_t)0xb9b, (q15_t)0xb94, + (q15_t)0xb8e, (q15_t)0xb88, (q15_t)0xb81, (q15_t)0xb7b, (q15_t)0xb75, + (q15_t)0xb6f, (q15_t)0xb68, (q15_t)0xb62, (q15_t)0xb5c, (q15_t)0xb56, + (q15_t)0xb4f, (q15_t)0xb49, (q15_t)0xb43, (q15_t)0xb3d, (q15_t)0xb36, + (q15_t)0xb30, (q15_t)0xb2a, (q15_t)0xb24, (q15_t)0xb1d, (q15_t)0xb17, + (q15_t)0xb11, (q15_t)0xb0b, (q15_t)0xb04, (q15_t)0xafe, (q15_t)0xaf8, + (q15_t)0xaf2, (q15_t)0xaeb, (q15_t)0xae5, (q15_t)0xadf, (q15_t)0xad8, + (q15_t)0xad2, (q15_t)0xacc, (q15_t)0xac6, (q15_t)0xabf, (q15_t)0xab9, + (q15_t)0xab3, (q15_t)0xaad, (q15_t)0xaa6, (q15_t)0xaa0, (q15_t)0xa9a, + (q15_t)0xa94, (q15_t)0xa8d, (q15_t)0xa87, (q15_t)0xa81, (q15_t)0xa7b, + (q15_t)0xa74, (q15_t)0xa6e, (q15_t)0xa68, (q15_t)0xa62, (q15_t)0xa5b, + (q15_t)0xa55, (q15_t)0xa4f, (q15_t)0xa48, (q15_t)0xa42, (q15_t)0xa3c, + (q15_t)0xa36, (q15_t)0xa2f, (q15_t)0xa29, (q15_t)0xa23, (q15_t)0xa1d, + (q15_t)0xa16, (q15_t)0xa10, (q15_t)0xa0a, (q15_t)0xa04, (q15_t)0x9fd, + (q15_t)0x9f7, (q15_t)0x9f1, (q15_t)0x9eb, (q15_t)0x9e4, (q15_t)0x9de, + (q15_t)0x9d8, (q15_t)0x9d1, (q15_t)0x9cb, (q15_t)0x9c5, (q15_t)0x9bf, + (q15_t)0x9b8, (q15_t)0x9b2, (q15_t)0x9ac, (q15_t)0x9a6, (q15_t)0x99f, + (q15_t)0x999, (q15_t)0x993, (q15_t)0x98d, (q15_t)0x986, (q15_t)0x980, + (q15_t)0x97a, (q15_t)0x973, (q15_t)0x96d, (q15_t)0x967, (q15_t)0x961, + (q15_t)0x95a, (q15_t)0x954, (q15_t)0x94e, (q15_t)0x948, (q15_t)0x941, + (q15_t)0x93b, (q15_t)0x935, (q15_t)0x92f, (q15_t)0x928, (q15_t)0x922, + (q15_t)0x91c, (q15_t)0x915, (q15_t)0x90f, (q15_t)0x909, (q15_t)0x903, + (q15_t)0x8fc, (q15_t)0x8f6, (q15_t)0x8f0, (q15_t)0x8ea, (q15_t)0x8e3, + (q15_t)0x8dd, (q15_t)0x8d7, (q15_t)0x8d1, (q15_t)0x8ca, (q15_t)0x8c4, + (q15_t)0x8be, (q15_t)0x8b7, (q15_t)0x8b1, (q15_t)0x8ab, (q15_t)0x8a5, + (q15_t)0x89e, (q15_t)0x898, (q15_t)0x892, (q15_t)0x88c, (q15_t)0x885, + (q15_t)0x87f, (q15_t)0x879, (q15_t)0x872, (q15_t)0x86c, (q15_t)0x866, + (q15_t)0x860, (q15_t)0x859, (q15_t)0x853, (q15_t)0x84d, (q15_t)0x847, + (q15_t)0x840, (q15_t)0x83a, (q15_t)0x834, (q15_t)0x82e, (q15_t)0x827, + (q15_t)0x821, (q15_t)0x81b, (q15_t)0x814, (q15_t)0x80e, (q15_t)0x808, + (q15_t)0x802, (q15_t)0x7fb, (q15_t)0x7f5, (q15_t)0x7ef, (q15_t)0x7e9, + (q15_t)0x7e2, (q15_t)0x7dc, (q15_t)0x7d6, (q15_t)0x7cf, (q15_t)0x7c9, + (q15_t)0x7c3, (q15_t)0x7bd, (q15_t)0x7b6, (q15_t)0x7b0, (q15_t)0x7aa, + (q15_t)0x7a4, (q15_t)0x79d, (q15_t)0x797, (q15_t)0x791, (q15_t)0x78a, + (q15_t)0x784, (q15_t)0x77e, (q15_t)0x778, (q15_t)0x771, (q15_t)0x76b, + (q15_t)0x765, (q15_t)0x75f, (q15_t)0x758, (q15_t)0x752, (q15_t)0x74c, + (q15_t)0x745, (q15_t)0x73f, (q15_t)0x739, (q15_t)0x733, (q15_t)0x72c, + (q15_t)0x726, (q15_t)0x720, (q15_t)0x71a, (q15_t)0x713, (q15_t)0x70d, + (q15_t)0x707, (q15_t)0x700, (q15_t)0x6fa, (q15_t)0x6f4, (q15_t)0x6ee, + (q15_t)0x6e7, (q15_t)0x6e1, (q15_t)0x6db, (q15_t)0x6d5, (q15_t)0x6ce, + (q15_t)0x6c8, (q15_t)0x6c2, (q15_t)0x6bb, (q15_t)0x6b5, (q15_t)0x6af, + (q15_t)0x6a9, (q15_t)0x6a2, (q15_t)0x69c, (q15_t)0x696, (q15_t)0x690, + (q15_t)0x689, (q15_t)0x683, (q15_t)0x67d, (q15_t)0x676, (q15_t)0x670, + (q15_t)0x66a, (q15_t)0x664, (q15_t)0x65d, (q15_t)0x657, (q15_t)0x651, + (q15_t)0x64a, (q15_t)0x644, (q15_t)0x63e, (q15_t)0x638, (q15_t)0x631, + (q15_t)0x62b, (q15_t)0x625, (q15_t)0x61f, (q15_t)0x618, (q15_t)0x612, + (q15_t)0x60c, (q15_t)0x605, (q15_t)0x5ff, (q15_t)0x5f9, (q15_t)0x5f3, + (q15_t)0x5ec, (q15_t)0x5e6, (q15_t)0x5e0, (q15_t)0x5da, (q15_t)0x5d3, + (q15_t)0x5cd, (q15_t)0x5c7, (q15_t)0x5c0, (q15_t)0x5ba, (q15_t)0x5b4, + (q15_t)0x5ae, (q15_t)0x5a7, (q15_t)0x5a1, (q15_t)0x59b, (q15_t)0x594, + (q15_t)0x58e, (q15_t)0x588, (q15_t)0x582, (q15_t)0x57b, (q15_t)0x575, + (q15_t)0x56f, (q15_t)0x569, (q15_t)0x562, (q15_t)0x55c, (q15_t)0x556, + (q15_t)0x54f, (q15_t)0x549, (q15_t)0x543, (q15_t)0x53d, (q15_t)0x536, + (q15_t)0x530, (q15_t)0x52a, (q15_t)0x523, (q15_t)0x51d, (q15_t)0x517, + (q15_t)0x511, (q15_t)0x50a, (q15_t)0x504, (q15_t)0x4fe, (q15_t)0x4f8, + (q15_t)0x4f1, (q15_t)0x4eb, (q15_t)0x4e5, (q15_t)0x4de, (q15_t)0x4d8, + (q15_t)0x4d2, (q15_t)0x4cc, (q15_t)0x4c5, (q15_t)0x4bf, (q15_t)0x4b9, + (q15_t)0x4b2, (q15_t)0x4ac, (q15_t)0x4a6, (q15_t)0x4a0, (q15_t)0x499, + (q15_t)0x493, (q15_t)0x48d, (q15_t)0x487, (q15_t)0x480, (q15_t)0x47a, + (q15_t)0x474, (q15_t)0x46d, (q15_t)0x467, (q15_t)0x461, (q15_t)0x45b, + (q15_t)0x454, (q15_t)0x44e, (q15_t)0x448, (q15_t)0x441, (q15_t)0x43b, + (q15_t)0x435, (q15_t)0x42f, (q15_t)0x428, (q15_t)0x422, (q15_t)0x41c, + (q15_t)0x415, (q15_t)0x40f, (q15_t)0x409, (q15_t)0x403, (q15_t)0x3fc, + (q15_t)0x3f6, (q15_t)0x3f0, (q15_t)0x3ea, (q15_t)0x3e3, (q15_t)0x3dd, + (q15_t)0x3d7, (q15_t)0x3d0, (q15_t)0x3ca, (q15_t)0x3c4, (q15_t)0x3be, + (q15_t)0x3b7, (q15_t)0x3b1, (q15_t)0x3ab, (q15_t)0x3a4, (q15_t)0x39e, + (q15_t)0x398, (q15_t)0x392, (q15_t)0x38b, (q15_t)0x385, (q15_t)0x37f, + (q15_t)0x378, (q15_t)0x372, (q15_t)0x36c, (q15_t)0x366, (q15_t)0x35f, + (q15_t)0x359, (q15_t)0x353, (q15_t)0x34c, (q15_t)0x346, (q15_t)0x340, + (q15_t)0x33a, (q15_t)0x333, (q15_t)0x32d, (q15_t)0x327, (q15_t)0x321, + (q15_t)0x31a, (q15_t)0x314, (q15_t)0x30e, (q15_t)0x307, (q15_t)0x301, + (q15_t)0x2fb, (q15_t)0x2f5, (q15_t)0x2ee, (q15_t)0x2e8, (q15_t)0x2e2, + (q15_t)0x2db, (q15_t)0x2d5, (q15_t)0x2cf, (q15_t)0x2c9, (q15_t)0x2c2, + (q15_t)0x2bc, (q15_t)0x2b6, (q15_t)0x2af, (q15_t)0x2a9, (q15_t)0x2a3, + (q15_t)0x29d, (q15_t)0x296, (q15_t)0x290, (q15_t)0x28a, (q15_t)0x283, + (q15_t)0x27d, (q15_t)0x277, (q15_t)0x271, (q15_t)0x26a, (q15_t)0x264, + (q15_t)0x25e, (q15_t)0x258, (q15_t)0x251, (q15_t)0x24b, (q15_t)0x245, + (q15_t)0x23e, (q15_t)0x238, (q15_t)0x232, (q15_t)0x22c, (q15_t)0x225, + (q15_t)0x21f, (q15_t)0x219, (q15_t)0x212, (q15_t)0x20c, (q15_t)0x206, + (q15_t)0x200, (q15_t)0x1f9, (q15_t)0x1f3, (q15_t)0x1ed, (q15_t)0x1e6, + (q15_t)0x1e0, (q15_t)0x1da, (q15_t)0x1d4, (q15_t)0x1cd, (q15_t)0x1c7, + (q15_t)0x1c1, (q15_t)0x1ba, (q15_t)0x1b4, (q15_t)0x1ae, (q15_t)0x1a8, + (q15_t)0x1a1, (q15_t)0x19b, (q15_t)0x195, (q15_t)0x18e, (q15_t)0x188, + (q15_t)0x182, (q15_t)0x17c, (q15_t)0x175, (q15_t)0x16f, (q15_t)0x169, + (q15_t)0x162, (q15_t)0x15c, (q15_t)0x156, (q15_t)0x150, (q15_t)0x149, + (q15_t)0x143, (q15_t)0x13d, (q15_t)0x137, (q15_t)0x130, (q15_t)0x12a, + (q15_t)0x124, (q15_t)0x11d, (q15_t)0x117, (q15_t)0x111, (q15_t)0x10b, + (q15_t)0x104, (q15_t)0xfe, (q15_t)0xf8, (q15_t)0xf1, (q15_t)0xeb, + (q15_t)0xe5, (q15_t)0xdf, (q15_t)0xd8, (q15_t)0xd2, (q15_t)0xcc, + (q15_t)0xc5, (q15_t)0xbf, (q15_t)0xb9, (q15_t)0xb3, (q15_t)0xac, + (q15_t)0xa6, (q15_t)0xa0, (q15_t)0x99, (q15_t)0x93, (q15_t)0x8d, + (q15_t)0x87, (q15_t)0x80, (q15_t)0x7a, (q15_t)0x74, (q15_t)0x6d, + (q15_t)0x67, (q15_t)0x61, (q15_t)0x5b, (q15_t)0x54, (q15_t)0x4e, + (q15_t)0x48, (q15_t)0x41, (q15_t)0x3b, (q15_t)0x35, (q15_t)0x2f, + (q15_t)0x28, (q15_t)0x22, (q15_t)0x1c, (q15_t)0x15, (q15_t)0xf, + (q15_t)0x9, (q15_t)0x3}; /** @} end of DCT4_IDCT4_Table group @@ -4202,36 +6652,34 @@ static const q15_t __ALIGNED(4) cos_factorsQ15_8192[8192] = { @param[in] normalize normalizing factor @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : N is not a supported transform length + - \ref ARM_MATH_ARGUMENT_ERROR : N is not a + supported transform length @par Normalizing factor - The normalizing factor is sqrt(2/N), which depends on the size of transform N. - Normalizing factors in 1.15 format are mentioned in the table below for different DCT sizes: + The normalizing factor is sqrt(2/N), which + depends on the size of transform N. Normalizing factors in 1.15 + format are mentioned in the table below for different DCT sizes: \image html dct4NormalizingQ15Table.gif */ -arm_status arm_dct4_init_q15( - arm_dct4_instance_q15 * S, - arm_rfft_instance_q15 * S_RFFT, - arm_cfft_radix4_instance_q15 * S_CFFT, - uint16_t N, - uint16_t Nby2, - q15_t normalize) -{ +arm_status arm_dct4_init_q15(arm_dct4_instance_q15 *S, + arm_rfft_instance_q15 *S_RFFT, + arm_cfft_radix4_instance_q15 *S_CFFT, uint16_t N, + uint16_t Nby2, q15_t normalize) { /* Initialise the default arm status */ arm_status status = ARM_MATH_SUCCESS; - /* Initializing the pointer array with the weight table base addresses of different lengths */ - q15_t *twiddlePtr[4] = { (q15_t *) WeightsQ15_128, (q15_t *) WeightsQ15_512, - (q15_t *) WeightsQ15_2048, (q15_t *) WeightsQ15_8192 - }; + /* Initializing the pointer array with the weight table base addresses of + * different lengths */ + q15_t *twiddlePtr[4] = {(q15_t *)WeightsQ15_128, (q15_t *)WeightsQ15_512, + (q15_t *)WeightsQ15_2048, (q15_t *)WeightsQ15_8192}; - /* Initializing the pointer array with the cos factor table base addresses of different lengths */ - q15_t *pCosFactor[4] = - { (q15_t *) cos_factorsQ15_128, (q15_t *) cos_factorsQ15_512, - (q15_t *) cos_factorsQ15_2048, (q15_t *) cos_factorsQ15_8192 - }; + /* Initializing the pointer array with the cos factor table base addresses of + * different lengths */ + q15_t *pCosFactor[4] = { + (q15_t *)cos_factorsQ15_128, (q15_t *)cos_factorsQ15_512, + (q15_t *)cos_factorsQ15_2048, (q15_t *)cos_factorsQ15_8192}; /* Initialize the DCT4 length */ S->N = N; @@ -4248,8 +6696,7 @@ arm_status arm_dct4_init_q15( /* Initialize Complex FFT Instance */ S->pCfft = S_CFFT; - switch (N) - { + switch (N) { /* Initialize the table modifier values */ case 8192U: S->pTwiddle = twiddlePtr[3]; diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_init_q31.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_init_q31.c index 44fe1d1..b4df441 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_init_q31.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_init_q31.c @@ -43,7 +43,8 @@ /** @par - Weights tables are generated using the formula :
weights[n] = e^(-j*n*pi/(2*N))
+ Weights tables are generated using the formula :
weights[n] =
+  e^(-j*n*pi/(2*N))
@par C command to generate the table
@@ -53,2749 +54,5468 @@
     weights[(2*i)+1] = -sin(i*c);
   } 
@par - where N is the Number of weights to be calculated and c is pi/(2*N) + where N is the Number of weights to be calculated and + c is pi/(2*N) @par - Convert the output to q31 format by multiplying with 2^31 and saturated if required. + Convert the output to q31 format by multiplying with 2^31 and saturated if + required. @par - In the tables below the real and imaginary values are placed alternatively, hence the - array length is 2*N. + In the tables below the real and imaginary values are placed alternatively, + hence the array length is 2*N. */ static const q31_t WeightsQ31_128[256] = { - (q31_t)0x7fffffff, (q31_t)0x00000000, (q31_t)0x7ffd885a, (q31_t)0xfe6de2e0, (q31_t)0x7ff62182, (q31_t)0xfcdbd541, (q31_t)0x7fe9cbc0, (q31_t)0xfb49e6a3, - (q31_t)0x7fd8878e, (q31_t)0xf9b82684, (q31_t)0x7fc25596, (q31_t)0xf826a462, (q31_t)0x7fa736b4, (q31_t)0xf6956fb7, (q31_t)0x7f872bf3, (q31_t)0xf50497fb, - (q31_t)0x7f62368f, (q31_t)0xf3742ca2, (q31_t)0x7f3857f6, (q31_t)0xf1e43d1c, (q31_t)0x7f0991c4, (q31_t)0xf054d8d5, (q31_t)0x7ed5e5c6, (q31_t)0xeec60f31, - (q31_t)0x7e9d55fc, (q31_t)0xed37ef91, (q31_t)0x7e5fe493, (q31_t)0xebaa894f, (q31_t)0x7e1d93ea, (q31_t)0xea1debbb, (q31_t)0x7dd6668f, (q31_t)0xe8922622, - (q31_t)0x7d8a5f40, (q31_t)0xe70747c4, (q31_t)0x7d3980ec, (q31_t)0xe57d5fda, (q31_t)0x7ce3ceb2, (q31_t)0xe3f47d96, (q31_t)0x7c894bde, (q31_t)0xe26cb01b, - (q31_t)0x7c29fbee, (q31_t)0xe0e60685, (q31_t)0x7bc5e290, (q31_t)0xdf608fe4, (q31_t)0x7b5d039e, (q31_t)0xdddc5b3b, (q31_t)0x7aef6323, (q31_t)0xdc597781, - (q31_t)0x7a7d055b, (q31_t)0xdad7f3a2, (q31_t)0x7a05eead, (q31_t)0xd957de7a, (q31_t)0x798a23b1, (q31_t)0xd7d946d8, (q31_t)0x7909a92d, (q31_t)0xd65c3b7b, - (q31_t)0x78848414, (q31_t)0xd4e0cb15, (q31_t)0x77fab989, (q31_t)0xd3670446, (q31_t)0x776c4edb, (q31_t)0xd1eef59e, (q31_t)0x76d94989, (q31_t)0xd078ad9e, - (q31_t)0x7641af3d, (q31_t)0xcf043ab3, (q31_t)0x75a585cf, (q31_t)0xcd91ab39, (q31_t)0x7504d345, (q31_t)0xcc210d79, (q31_t)0x745f9dd1, (q31_t)0xcab26fa9, - (q31_t)0x73b5ebd1, (q31_t)0xc945dfec, (q31_t)0x7307c3d0, (q31_t)0xc7db6c50, (q31_t)0x72552c85, (q31_t)0xc67322ce, (q31_t)0x719e2cd2, (q31_t)0xc50d1149, - (q31_t)0x70e2cbc6, (q31_t)0xc3a94590, (q31_t)0x7023109a, (q31_t)0xc247cd5a, (q31_t)0x6f5f02b2, (q31_t)0xc0e8b648, (q31_t)0x6e96a99d, (q31_t)0xbf8c0de3, - (q31_t)0x6dca0d14, (q31_t)0xbe31e19b, (q31_t)0x6cf934fc, (q31_t)0xbcda3ecb, (q31_t)0x6c242960, (q31_t)0xbb8532b0, (q31_t)0x6b4af279, (q31_t)0xba32ca71, - (q31_t)0x6a6d98a4, (q31_t)0xb8e31319, (q31_t)0x698c246c, (q31_t)0xb796199b, (q31_t)0x68a69e81, (q31_t)0xb64beacd, (q31_t)0x67bd0fbd, (q31_t)0xb5049368, - (q31_t)0x66cf8120, (q31_t)0xb3c0200c, (q31_t)0x65ddfbd3, (q31_t)0xb27e9d3c, (q31_t)0x64e88926, (q31_t)0xb140175b, (q31_t)0x63ef3290, (q31_t)0xb0049ab3, - (q31_t)0x62f201ac, (q31_t)0xaecc336c, (q31_t)0x61f1003f, (q31_t)0xad96ed92, (q31_t)0x60ec3830, (q31_t)0xac64d510, (q31_t)0x5fe3b38d, (q31_t)0xab35f5b5, - (q31_t)0x5ed77c8a, (q31_t)0xaa0a5b2e, (q31_t)0x5dc79d7c, (q31_t)0xa8e21106, (q31_t)0x5cb420e0, (q31_t)0xa7bd22ac, (q31_t)0x5b9d1154, (q31_t)0xa69b9b68, - (q31_t)0x5a82799a, (q31_t)0xa57d8666, (q31_t)0x59646498, (q31_t)0xa462eeac, (q31_t)0x5842dd54, (q31_t)0xa34bdf20, (q31_t)0x571deefa, (q31_t)0xa2386284, - (q31_t)0x55f5a4d2, (q31_t)0xa1288376, (q31_t)0x54ca0a4b, (q31_t)0xa01c4c73, (q31_t)0x539b2af0, (q31_t)0x9f13c7d0, (q31_t)0x5269126e, (q31_t)0x9e0effc1, - (q31_t)0x5133cc94, (q31_t)0x9d0dfe54, (q31_t)0x4ffb654d, (q31_t)0x9c10cd70, (q31_t)0x4ebfe8a5, (q31_t)0x9b1776da, (q31_t)0x4d8162c4, (q31_t)0x9a22042d, - (q31_t)0x4c3fdff4, (q31_t)0x99307ee0, (q31_t)0x4afb6c98, (q31_t)0x9842f043, (q31_t)0x49b41533, (q31_t)0x9759617f, (q31_t)0x4869e665, (q31_t)0x9673db94, - (q31_t)0x471cece7, (q31_t)0x9592675c, (q31_t)0x45cd358f, (q31_t)0x94b50d87, (q31_t)0x447acd50, (q31_t)0x93dbd6a0, (q31_t)0x4325c135, (q31_t)0x9306cb04, - (q31_t)0x41ce1e65, (q31_t)0x9235f2ec, (q31_t)0x4073f21d, (q31_t)0x91695663, (q31_t)0x3f1749b8, (q31_t)0x90a0fd4e, (q31_t)0x3db832a6, (q31_t)0x8fdcef66, - (q31_t)0x3c56ba70, (q31_t)0x8f1d343a, (q31_t)0x3af2eeb7, (q31_t)0x8e61d32e, (q31_t)0x398cdd32, (q31_t)0x8daad37b, (q31_t)0x382493b0, (q31_t)0x8cf83c30, - (q31_t)0x36ba2014, (q31_t)0x8c4a142f, (q31_t)0x354d9057, (q31_t)0x8ba0622f, (q31_t)0x33def287, (q31_t)0x8afb2cbb, (q31_t)0x326e54c7, (q31_t)0x8a5a7a31, - (q31_t)0x30fbc54d, (q31_t)0x89be50c3, (q31_t)0x2f875262, (q31_t)0x8926b677, (q31_t)0x2e110a62, (q31_t)0x8893b125, (q31_t)0x2c98fbba, (q31_t)0x88054677, - (q31_t)0x2b1f34eb, (q31_t)0x877b7bec, (q31_t)0x29a3c485, (q31_t)0x86f656d3, (q31_t)0x2826b928, (q31_t)0x8675dc4f, (q31_t)0x26a82186, (q31_t)0x85fa1153, - (q31_t)0x25280c5e, (q31_t)0x8582faa5, (q31_t)0x23a6887f, (q31_t)0x85109cdd, (q31_t)0x2223a4c5, (q31_t)0x84a2fc62, (q31_t)0x209f701c, (q31_t)0x843a1d70, - (q31_t)0x1f19f97b, (q31_t)0x83d60412, (q31_t)0x1d934fe5, (q31_t)0x8376b422, (q31_t)0x1c0b826a, (q31_t)0x831c314e, (q31_t)0x1a82a026, (q31_t)0x82c67f14, - (q31_t)0x18f8b83c, (q31_t)0x8275a0c0, (q31_t)0x176dd9de, (q31_t)0x82299971, (q31_t)0x15e21445, (q31_t)0x81e26c16, (q31_t)0x145576b1, (q31_t)0x81a01b6d, - (q31_t)0x12c8106f, (q31_t)0x8162aa04, (q31_t)0x1139f0cf, (q31_t)0x812a1a3a, (q31_t)0x0fab272b, (q31_t)0x80f66e3c, (q31_t)0x0e1bc2e4, (q31_t)0x80c7a80a, - (q31_t)0x0c8bd35e, (q31_t)0x809dc971, (q31_t)0x0afb6805, (q31_t)0x8078d40d, (q31_t)0x096a9049, (q31_t)0x8058c94c, (q31_t)0x07d95b9e, (q31_t)0x803daa6a, - (q31_t)0x0647d97c, (q31_t)0x80277872, (q31_t)0x04b6195d, (q31_t)0x80163440, (q31_t)0x03242abf, (q31_t)0x8009de7e, (q31_t)0x01921d20, (q31_t)0x800277a6 -}; + (q31_t)0x7fffffff, (q31_t)0x00000000, (q31_t)0x7ffd885a, (q31_t)0xfe6de2e0, + (q31_t)0x7ff62182, (q31_t)0xfcdbd541, (q31_t)0x7fe9cbc0, (q31_t)0xfb49e6a3, + (q31_t)0x7fd8878e, (q31_t)0xf9b82684, (q31_t)0x7fc25596, (q31_t)0xf826a462, + (q31_t)0x7fa736b4, (q31_t)0xf6956fb7, (q31_t)0x7f872bf3, (q31_t)0xf50497fb, + (q31_t)0x7f62368f, (q31_t)0xf3742ca2, (q31_t)0x7f3857f6, (q31_t)0xf1e43d1c, + (q31_t)0x7f0991c4, (q31_t)0xf054d8d5, (q31_t)0x7ed5e5c6, (q31_t)0xeec60f31, + (q31_t)0x7e9d55fc, (q31_t)0xed37ef91, (q31_t)0x7e5fe493, (q31_t)0xebaa894f, + (q31_t)0x7e1d93ea, (q31_t)0xea1debbb, (q31_t)0x7dd6668f, (q31_t)0xe8922622, + (q31_t)0x7d8a5f40, (q31_t)0xe70747c4, (q31_t)0x7d3980ec, (q31_t)0xe57d5fda, + (q31_t)0x7ce3ceb2, (q31_t)0xe3f47d96, (q31_t)0x7c894bde, (q31_t)0xe26cb01b, + (q31_t)0x7c29fbee, (q31_t)0xe0e60685, (q31_t)0x7bc5e290, (q31_t)0xdf608fe4, + (q31_t)0x7b5d039e, (q31_t)0xdddc5b3b, (q31_t)0x7aef6323, (q31_t)0xdc597781, + (q31_t)0x7a7d055b, (q31_t)0xdad7f3a2, (q31_t)0x7a05eead, (q31_t)0xd957de7a, + (q31_t)0x798a23b1, (q31_t)0xd7d946d8, (q31_t)0x7909a92d, (q31_t)0xd65c3b7b, + (q31_t)0x78848414, (q31_t)0xd4e0cb15, (q31_t)0x77fab989, (q31_t)0xd3670446, + (q31_t)0x776c4edb, (q31_t)0xd1eef59e, (q31_t)0x76d94989, (q31_t)0xd078ad9e, + (q31_t)0x7641af3d, (q31_t)0xcf043ab3, (q31_t)0x75a585cf, (q31_t)0xcd91ab39, + (q31_t)0x7504d345, (q31_t)0xcc210d79, (q31_t)0x745f9dd1, (q31_t)0xcab26fa9, + (q31_t)0x73b5ebd1, (q31_t)0xc945dfec, (q31_t)0x7307c3d0, (q31_t)0xc7db6c50, + (q31_t)0x72552c85, (q31_t)0xc67322ce, (q31_t)0x719e2cd2, (q31_t)0xc50d1149, + (q31_t)0x70e2cbc6, (q31_t)0xc3a94590, (q31_t)0x7023109a, (q31_t)0xc247cd5a, + (q31_t)0x6f5f02b2, (q31_t)0xc0e8b648, (q31_t)0x6e96a99d, (q31_t)0xbf8c0de3, + (q31_t)0x6dca0d14, (q31_t)0xbe31e19b, (q31_t)0x6cf934fc, (q31_t)0xbcda3ecb, + (q31_t)0x6c242960, (q31_t)0xbb8532b0, (q31_t)0x6b4af279, (q31_t)0xba32ca71, + (q31_t)0x6a6d98a4, (q31_t)0xb8e31319, (q31_t)0x698c246c, (q31_t)0xb796199b, + (q31_t)0x68a69e81, (q31_t)0xb64beacd, (q31_t)0x67bd0fbd, (q31_t)0xb5049368, + (q31_t)0x66cf8120, (q31_t)0xb3c0200c, (q31_t)0x65ddfbd3, (q31_t)0xb27e9d3c, + (q31_t)0x64e88926, (q31_t)0xb140175b, (q31_t)0x63ef3290, (q31_t)0xb0049ab3, + (q31_t)0x62f201ac, (q31_t)0xaecc336c, (q31_t)0x61f1003f, (q31_t)0xad96ed92, + (q31_t)0x60ec3830, (q31_t)0xac64d510, (q31_t)0x5fe3b38d, (q31_t)0xab35f5b5, + (q31_t)0x5ed77c8a, (q31_t)0xaa0a5b2e, (q31_t)0x5dc79d7c, (q31_t)0xa8e21106, + (q31_t)0x5cb420e0, (q31_t)0xa7bd22ac, (q31_t)0x5b9d1154, (q31_t)0xa69b9b68, + (q31_t)0x5a82799a, (q31_t)0xa57d8666, (q31_t)0x59646498, (q31_t)0xa462eeac, + (q31_t)0x5842dd54, (q31_t)0xa34bdf20, (q31_t)0x571deefa, (q31_t)0xa2386284, + (q31_t)0x55f5a4d2, (q31_t)0xa1288376, (q31_t)0x54ca0a4b, (q31_t)0xa01c4c73, + (q31_t)0x539b2af0, (q31_t)0x9f13c7d0, (q31_t)0x5269126e, (q31_t)0x9e0effc1, + (q31_t)0x5133cc94, (q31_t)0x9d0dfe54, (q31_t)0x4ffb654d, (q31_t)0x9c10cd70, + (q31_t)0x4ebfe8a5, (q31_t)0x9b1776da, (q31_t)0x4d8162c4, (q31_t)0x9a22042d, + (q31_t)0x4c3fdff4, (q31_t)0x99307ee0, (q31_t)0x4afb6c98, (q31_t)0x9842f043, + (q31_t)0x49b41533, (q31_t)0x9759617f, (q31_t)0x4869e665, (q31_t)0x9673db94, + (q31_t)0x471cece7, (q31_t)0x9592675c, (q31_t)0x45cd358f, (q31_t)0x94b50d87, + (q31_t)0x447acd50, (q31_t)0x93dbd6a0, (q31_t)0x4325c135, (q31_t)0x9306cb04, + (q31_t)0x41ce1e65, (q31_t)0x9235f2ec, (q31_t)0x4073f21d, (q31_t)0x91695663, + (q31_t)0x3f1749b8, (q31_t)0x90a0fd4e, (q31_t)0x3db832a6, (q31_t)0x8fdcef66, + (q31_t)0x3c56ba70, (q31_t)0x8f1d343a, (q31_t)0x3af2eeb7, (q31_t)0x8e61d32e, + (q31_t)0x398cdd32, (q31_t)0x8daad37b, (q31_t)0x382493b0, (q31_t)0x8cf83c30, + (q31_t)0x36ba2014, (q31_t)0x8c4a142f, (q31_t)0x354d9057, (q31_t)0x8ba0622f, + (q31_t)0x33def287, (q31_t)0x8afb2cbb, (q31_t)0x326e54c7, (q31_t)0x8a5a7a31, + (q31_t)0x30fbc54d, (q31_t)0x89be50c3, (q31_t)0x2f875262, (q31_t)0x8926b677, + (q31_t)0x2e110a62, (q31_t)0x8893b125, (q31_t)0x2c98fbba, (q31_t)0x88054677, + (q31_t)0x2b1f34eb, (q31_t)0x877b7bec, (q31_t)0x29a3c485, (q31_t)0x86f656d3, + (q31_t)0x2826b928, (q31_t)0x8675dc4f, (q31_t)0x26a82186, (q31_t)0x85fa1153, + (q31_t)0x25280c5e, (q31_t)0x8582faa5, (q31_t)0x23a6887f, (q31_t)0x85109cdd, + (q31_t)0x2223a4c5, (q31_t)0x84a2fc62, (q31_t)0x209f701c, (q31_t)0x843a1d70, + (q31_t)0x1f19f97b, (q31_t)0x83d60412, (q31_t)0x1d934fe5, (q31_t)0x8376b422, + (q31_t)0x1c0b826a, (q31_t)0x831c314e, (q31_t)0x1a82a026, (q31_t)0x82c67f14, + (q31_t)0x18f8b83c, (q31_t)0x8275a0c0, (q31_t)0x176dd9de, (q31_t)0x82299971, + (q31_t)0x15e21445, (q31_t)0x81e26c16, (q31_t)0x145576b1, (q31_t)0x81a01b6d, + (q31_t)0x12c8106f, (q31_t)0x8162aa04, (q31_t)0x1139f0cf, (q31_t)0x812a1a3a, + (q31_t)0x0fab272b, (q31_t)0x80f66e3c, (q31_t)0x0e1bc2e4, (q31_t)0x80c7a80a, + (q31_t)0x0c8bd35e, (q31_t)0x809dc971, (q31_t)0x0afb6805, (q31_t)0x8078d40d, + (q31_t)0x096a9049, (q31_t)0x8058c94c, (q31_t)0x07d95b9e, (q31_t)0x803daa6a, + (q31_t)0x0647d97c, (q31_t)0x80277872, (q31_t)0x04b6195d, (q31_t)0x80163440, + (q31_t)0x03242abf, (q31_t)0x8009de7e, (q31_t)0x01921d20, (q31_t)0x800277a6}; static const q31_t WeightsQ31_512[1024] = { - (q31_t)0x7fffffff, (q31_t)0x00000000, (q31_t)0x7fffd886, (q31_t)0xff9b781d, (q31_t)0x7fff6216, (q31_t)0xff36f078, (q31_t)0x7ffe9cb2, (q31_t)0xfed2694f, - (q31_t)0x7ffd885a, (q31_t)0xfe6de2e0, (q31_t)0x7ffc250f, (q31_t)0xfe095d69, (q31_t)0x7ffa72d1, (q31_t)0xfda4d929, (q31_t)0x7ff871a2, (q31_t)0xfd40565c, - (q31_t)0x7ff62182, (q31_t)0xfcdbd541, (q31_t)0x7ff38274, (q31_t)0xfc775616, (q31_t)0x7ff09478, (q31_t)0xfc12d91a, (q31_t)0x7fed5791, (q31_t)0xfbae5e89, - (q31_t)0x7fe9cbc0, (q31_t)0xfb49e6a3, (q31_t)0x7fe5f108, (q31_t)0xfae571a4, (q31_t)0x7fe1c76b, (q31_t)0xfa80ffcb, (q31_t)0x7fdd4eec, (q31_t)0xfa1c9157, - (q31_t)0x7fd8878e, (q31_t)0xf9b82684, (q31_t)0x7fd37153, (q31_t)0xf953bf91, (q31_t)0x7fce0c3e, (q31_t)0xf8ef5cbb, (q31_t)0x7fc85854, (q31_t)0xf88afe42, - (q31_t)0x7fc25596, (q31_t)0xf826a462, (q31_t)0x7fbc040a, (q31_t)0xf7c24f59, (q31_t)0x7fb563b3, (q31_t)0xf75dff66, (q31_t)0x7fae7495, (q31_t)0xf6f9b4c6, - (q31_t)0x7fa736b4, (q31_t)0xf6956fb7, (q31_t)0x7f9faa15, (q31_t)0xf6313077, (q31_t)0x7f97cebd, (q31_t)0xf5ccf743, (q31_t)0x7f8fa4b0, (q31_t)0xf568c45b, - (q31_t)0x7f872bf3, (q31_t)0xf50497fb, (q31_t)0x7f7e648c, (q31_t)0xf4a07261, (q31_t)0x7f754e80, (q31_t)0xf43c53cb, (q31_t)0x7f6be9d4, (q31_t)0xf3d83c77, - (q31_t)0x7f62368f, (q31_t)0xf3742ca2, (q31_t)0x7f5834b7, (q31_t)0xf310248a, (q31_t)0x7f4de451, (q31_t)0xf2ac246e, (q31_t)0x7f434563, (q31_t)0xf2482c8a, - (q31_t)0x7f3857f6, (q31_t)0xf1e43d1c, (q31_t)0x7f2d1c0e, (q31_t)0xf1805662, (q31_t)0x7f2191b4, (q31_t)0xf11c789a, (q31_t)0x7f15b8ee, (q31_t)0xf0b8a401, - (q31_t)0x7f0991c4, (q31_t)0xf054d8d5, (q31_t)0x7efd1c3c, (q31_t)0xeff11753, (q31_t)0x7ef05860, (q31_t)0xef8d5fb8, (q31_t)0x7ee34636, (q31_t)0xef29b243, - (q31_t)0x7ed5e5c6, (q31_t)0xeec60f31, (q31_t)0x7ec8371a, (q31_t)0xee6276bf, (q31_t)0x7eba3a39, (q31_t)0xedfee92b, (q31_t)0x7eabef2c, (q31_t)0xed9b66b2, - (q31_t)0x7e9d55fc, (q31_t)0xed37ef91, (q31_t)0x7e8e6eb2, (q31_t)0xecd48407, (q31_t)0x7e7f3957, (q31_t)0xec71244f, (q31_t)0x7e6fb5f4, (q31_t)0xec0dd0a8, - (q31_t)0x7e5fe493, (q31_t)0xebaa894f, (q31_t)0x7e4fc53e, (q31_t)0xeb474e81, (q31_t)0x7e3f57ff, (q31_t)0xeae4207a, (q31_t)0x7e2e9cdf, (q31_t)0xea80ff7a, - (q31_t)0x7e1d93ea, (q31_t)0xea1debbb, (q31_t)0x7e0c3d29, (q31_t)0xe9bae57d, (q31_t)0x7dfa98a8, (q31_t)0xe957ecfb, (q31_t)0x7de8a670, (q31_t)0xe8f50273, - (q31_t)0x7dd6668f, (q31_t)0xe8922622, (q31_t)0x7dc3d90d, (q31_t)0xe82f5844, (q31_t)0x7db0fdf8, (q31_t)0xe7cc9917, (q31_t)0x7d9dd55a, (q31_t)0xe769e8d8, - (q31_t)0x7d8a5f40, (q31_t)0xe70747c4, (q31_t)0x7d769bb5, (q31_t)0xe6a4b616, (q31_t)0x7d628ac6, (q31_t)0xe642340d, (q31_t)0x7d4e2c7f, (q31_t)0xe5dfc1e5, - (q31_t)0x7d3980ec, (q31_t)0xe57d5fda, (q31_t)0x7d24881b, (q31_t)0xe51b0e2a, (q31_t)0x7d0f4218, (q31_t)0xe4b8cd11, (q31_t)0x7cf9aef0, (q31_t)0xe4569ccb, - (q31_t)0x7ce3ceb2, (q31_t)0xe3f47d96, (q31_t)0x7ccda169, (q31_t)0xe3926fad, (q31_t)0x7cb72724, (q31_t)0xe330734d, (q31_t)0x7ca05ff1, (q31_t)0xe2ce88b3, - (q31_t)0x7c894bde, (q31_t)0xe26cb01b, (q31_t)0x7c71eaf9, (q31_t)0xe20ae9c1, (q31_t)0x7c5a3d50, (q31_t)0xe1a935e2, (q31_t)0x7c4242f2, (q31_t)0xe14794ba, - (q31_t)0x7c29fbee, (q31_t)0xe0e60685, (q31_t)0x7c116853, (q31_t)0xe0848b7f, (q31_t)0x7bf88830, (q31_t)0xe02323e5, (q31_t)0x7bdf5b94, (q31_t)0xdfc1cff3, - (q31_t)0x7bc5e290, (q31_t)0xdf608fe4, (q31_t)0x7bac1d31, (q31_t)0xdeff63f4, (q31_t)0x7b920b89, (q31_t)0xde9e4c60, (q31_t)0x7b77ada8, (q31_t)0xde3d4964, - (q31_t)0x7b5d039e, (q31_t)0xdddc5b3b, (q31_t)0x7b420d7a, (q31_t)0xdd7b8220, (q31_t)0x7b26cb4f, (q31_t)0xdd1abe51, (q31_t)0x7b0b3d2c, (q31_t)0xdcba1008, - (q31_t)0x7aef6323, (q31_t)0xdc597781, (q31_t)0x7ad33d45, (q31_t)0xdbf8f4f8, (q31_t)0x7ab6cba4, (q31_t)0xdb9888a8, (q31_t)0x7a9a0e50, (q31_t)0xdb3832cd, - (q31_t)0x7a7d055b, (q31_t)0xdad7f3a2, (q31_t)0x7a5fb0d8, (q31_t)0xda77cb63, (q31_t)0x7a4210d8, (q31_t)0xda17ba4a, (q31_t)0x7a24256f, (q31_t)0xd9b7c094, - (q31_t)0x7a05eead, (q31_t)0xd957de7a, (q31_t)0x79e76ca7, (q31_t)0xd8f81439, (q31_t)0x79c89f6e, (q31_t)0xd898620c, (q31_t)0x79a98715, (q31_t)0xd838c82d, - (q31_t)0x798a23b1, (q31_t)0xd7d946d8, (q31_t)0x796a7554, (q31_t)0xd779de47, (q31_t)0x794a7c12, (q31_t)0xd71a8eb5, (q31_t)0x792a37fe, (q31_t)0xd6bb585e, - (q31_t)0x7909a92d, (q31_t)0xd65c3b7b, (q31_t)0x78e8cfb2, (q31_t)0xd5fd3848, (q31_t)0x78c7aba2, (q31_t)0xd59e4eff, (q31_t)0x78a63d11, (q31_t)0xd53f7fda, - (q31_t)0x78848414, (q31_t)0xd4e0cb15, (q31_t)0x786280bf, (q31_t)0xd48230e9, (q31_t)0x78403329, (q31_t)0xd423b191, (q31_t)0x781d9b65, (q31_t)0xd3c54d47, - (q31_t)0x77fab989, (q31_t)0xd3670446, (q31_t)0x77d78daa, (q31_t)0xd308d6c7, (q31_t)0x77b417df, (q31_t)0xd2aac504, (q31_t)0x7790583e, (q31_t)0xd24ccf39, - (q31_t)0x776c4edb, (q31_t)0xd1eef59e, (q31_t)0x7747fbce, (q31_t)0xd191386e, (q31_t)0x77235f2d, (q31_t)0xd13397e2, (q31_t)0x76fe790e, (q31_t)0xd0d61434, - (q31_t)0x76d94989, (q31_t)0xd078ad9e, (q31_t)0x76b3d0b4, (q31_t)0xd01b6459, (q31_t)0x768e0ea6, (q31_t)0xcfbe389f, (q31_t)0x76680376, (q31_t)0xcf612aaa, - (q31_t)0x7641af3d, (q31_t)0xcf043ab3, (q31_t)0x761b1211, (q31_t)0xcea768f2, (q31_t)0x75f42c0b, (q31_t)0xce4ab5a2, (q31_t)0x75ccfd42, (q31_t)0xcdee20fc, - (q31_t)0x75a585cf, (q31_t)0xcd91ab39, (q31_t)0x757dc5ca, (q31_t)0xcd355491, (q31_t)0x7555bd4c, (q31_t)0xccd91d3d, (q31_t)0x752d6c6c, (q31_t)0xcc7d0578, - (q31_t)0x7504d345, (q31_t)0xcc210d79, (q31_t)0x74dbf1ef, (q31_t)0xcbc53579, (q31_t)0x74b2c884, (q31_t)0xcb697db0, (q31_t)0x7489571c, (q31_t)0xcb0de658, - (q31_t)0x745f9dd1, (q31_t)0xcab26fa9, (q31_t)0x74359cbd, (q31_t)0xca5719db, (q31_t)0x740b53fb, (q31_t)0xc9fbe527, (q31_t)0x73e0c3a3, (q31_t)0xc9a0d1c5, - (q31_t)0x73b5ebd1, (q31_t)0xc945dfec, (q31_t)0x738acc9e, (q31_t)0xc8eb0fd6, (q31_t)0x735f6626, (q31_t)0xc89061ba, (q31_t)0x7333b883, (q31_t)0xc835d5d0, - (q31_t)0x7307c3d0, (q31_t)0xc7db6c50, (q31_t)0x72db8828, (q31_t)0xc7812572, (q31_t)0x72af05a7, (q31_t)0xc727016d, (q31_t)0x72823c67, (q31_t)0xc6cd0079, - (q31_t)0x72552c85, (q31_t)0xc67322ce, (q31_t)0x7227d61c, (q31_t)0xc61968a2, (q31_t)0x71fa3949, (q31_t)0xc5bfd22e, (q31_t)0x71cc5626, (q31_t)0xc5665fa9, - (q31_t)0x719e2cd2, (q31_t)0xc50d1149, (q31_t)0x716fbd68, (q31_t)0xc4b3e746, (q31_t)0x71410805, (q31_t)0xc45ae1d7, (q31_t)0x71120cc5, (q31_t)0xc4020133, - (q31_t)0x70e2cbc6, (q31_t)0xc3a94590, (q31_t)0x70b34525, (q31_t)0xc350af26, (q31_t)0x708378ff, (q31_t)0xc2f83e2a, (q31_t)0x70536771, (q31_t)0xc29ff2d4, - (q31_t)0x7023109a, (q31_t)0xc247cd5a, (q31_t)0x6ff27497, (q31_t)0xc1efcdf3, (q31_t)0x6fc19385, (q31_t)0xc197f4d4, (q31_t)0x6f906d84, (q31_t)0xc1404233, - (q31_t)0x6f5f02b2, (q31_t)0xc0e8b648, (q31_t)0x6f2d532c, (q31_t)0xc0915148, (q31_t)0x6efb5f12, (q31_t)0xc03a1368, (q31_t)0x6ec92683, (q31_t)0xbfe2fcdf, - (q31_t)0x6e96a99d, (q31_t)0xbf8c0de3, (q31_t)0x6e63e87f, (q31_t)0xbf3546a8, (q31_t)0x6e30e34a, (q31_t)0xbedea765, (q31_t)0x6dfd9a1c, (q31_t)0xbe88304f, - (q31_t)0x6dca0d14, (q31_t)0xbe31e19b, (q31_t)0x6d963c54, (q31_t)0xbddbbb7f, (q31_t)0x6d6227fa, (q31_t)0xbd85be30, (q31_t)0x6d2dd027, (q31_t)0xbd2fe9e2, - (q31_t)0x6cf934fc, (q31_t)0xbcda3ecb, (q31_t)0x6cc45698, (q31_t)0xbc84bd1f, (q31_t)0x6c8f351c, (q31_t)0xbc2f6513, (q31_t)0x6c59d0a9, (q31_t)0xbbda36dd, - (q31_t)0x6c242960, (q31_t)0xbb8532b0, (q31_t)0x6bee3f62, (q31_t)0xbb3058c0, (q31_t)0x6bb812d1, (q31_t)0xbadba943, (q31_t)0x6b81a3cd, (q31_t)0xba87246d, - (q31_t)0x6b4af279, (q31_t)0xba32ca71, (q31_t)0x6b13fef5, (q31_t)0xb9de9b83, (q31_t)0x6adcc964, (q31_t)0xb98a97d8, (q31_t)0x6aa551e9, (q31_t)0xb936bfa4, - (q31_t)0x6a6d98a4, (q31_t)0xb8e31319, (q31_t)0x6a359db9, (q31_t)0xb88f926d, (q31_t)0x69fd614a, (q31_t)0xb83c3dd1, (q31_t)0x69c4e37a, (q31_t)0xb7e9157a, - (q31_t)0x698c246c, (q31_t)0xb796199b, (q31_t)0x69532442, (q31_t)0xb7434a67, (q31_t)0x6919e320, (q31_t)0xb6f0a812, (q31_t)0x68e06129, (q31_t)0xb69e32cd, - (q31_t)0x68a69e81, (q31_t)0xb64beacd, (q31_t)0x686c9b4b, (q31_t)0xb5f9d043, (q31_t)0x683257ab, (q31_t)0xb5a7e362, (q31_t)0x67f7d3c5, (q31_t)0xb556245e, - (q31_t)0x67bd0fbd, (q31_t)0xb5049368, (q31_t)0x67820bb7, (q31_t)0xb4b330b3, (q31_t)0x6746c7d8, (q31_t)0xb461fc70, (q31_t)0x670b4444, (q31_t)0xb410f6d3, - (q31_t)0x66cf8120, (q31_t)0xb3c0200c, (q31_t)0x66937e91, (q31_t)0xb36f784f, (q31_t)0x66573cbb, (q31_t)0xb31effcc, (q31_t)0x661abbc5, (q31_t)0xb2ceb6b5, - (q31_t)0x65ddfbd3, (q31_t)0xb27e9d3c, (q31_t)0x65a0fd0b, (q31_t)0xb22eb392, (q31_t)0x6563bf92, (q31_t)0xb1def9e9, (q31_t)0x6526438f, (q31_t)0xb18f7071, - (q31_t)0x64e88926, (q31_t)0xb140175b, (q31_t)0x64aa907f, (q31_t)0xb0f0eeda, (q31_t)0x646c59bf, (q31_t)0xb0a1f71d, (q31_t)0x642de50d, (q31_t)0xb0533055, - (q31_t)0x63ef3290, (q31_t)0xb0049ab3, (q31_t)0x63b0426d, (q31_t)0xafb63667, (q31_t)0x637114cc, (q31_t)0xaf6803a2, (q31_t)0x6331a9d4, (q31_t)0xaf1a0293, - (q31_t)0x62f201ac, (q31_t)0xaecc336c, (q31_t)0x62b21c7b, (q31_t)0xae7e965b, (q31_t)0x6271fa69, (q31_t)0xae312b92, (q31_t)0x62319b9d, (q31_t)0xade3f33e, - (q31_t)0x61f1003f, (q31_t)0xad96ed92, (q31_t)0x61b02876, (q31_t)0xad4a1aba, (q31_t)0x616f146c, (q31_t)0xacfd7ae8, (q31_t)0x612dc447, (q31_t)0xacb10e4b, - (q31_t)0x60ec3830, (q31_t)0xac64d510, (q31_t)0x60aa7050, (q31_t)0xac18cf69, (q31_t)0x60686ccf, (q31_t)0xabccfd83, (q31_t)0x60262dd6, (q31_t)0xab815f8d, - (q31_t)0x5fe3b38d, (q31_t)0xab35f5b5, (q31_t)0x5fa0fe1f, (q31_t)0xaaeac02c, (q31_t)0x5f5e0db3, (q31_t)0xaa9fbf1e, (q31_t)0x5f1ae274, (q31_t)0xaa54f2ba, - (q31_t)0x5ed77c8a, (q31_t)0xaa0a5b2e, (q31_t)0x5e93dc1f, (q31_t)0xa9bff8a8, (q31_t)0x5e50015d, (q31_t)0xa975cb57, (q31_t)0x5e0bec6e, (q31_t)0xa92bd367, - (q31_t)0x5dc79d7c, (q31_t)0xa8e21106, (q31_t)0x5d8314b1, (q31_t)0xa8988463, (q31_t)0x5d3e5237, (q31_t)0xa84f2daa, (q31_t)0x5cf95638, (q31_t)0xa8060d08, - (q31_t)0x5cb420e0, (q31_t)0xa7bd22ac, (q31_t)0x5c6eb258, (q31_t)0xa7746ec0, (q31_t)0x5c290acc, (q31_t)0xa72bf174, (q31_t)0x5be32a67, (q31_t)0xa6e3aaf2, - (q31_t)0x5b9d1154, (q31_t)0xa69b9b68, (q31_t)0x5b56bfbd, (q31_t)0xa653c303, (q31_t)0x5b1035cf, (q31_t)0xa60c21ee, (q31_t)0x5ac973b5, (q31_t)0xa5c4b855, - (q31_t)0x5a82799a, (q31_t)0xa57d8666, (q31_t)0x5a3b47ab, (q31_t)0xa5368c4b, (q31_t)0x59f3de12, (q31_t)0xa4efca31, (q31_t)0x59ac3cfd, (q31_t)0xa4a94043, - (q31_t)0x59646498, (q31_t)0xa462eeac, (q31_t)0x591c550e, (q31_t)0xa41cd599, (q31_t)0x58d40e8c, (q31_t)0xa3d6f534, (q31_t)0x588b9140, (q31_t)0xa3914da8, - (q31_t)0x5842dd54, (q31_t)0xa34bdf20, (q31_t)0x57f9f2f8, (q31_t)0xa306a9c8, (q31_t)0x57b0d256, (q31_t)0xa2c1adc9, (q31_t)0x57677b9d, (q31_t)0xa27ceb4f, - (q31_t)0x571deefa, (q31_t)0xa2386284, (q31_t)0x56d42c99, (q31_t)0xa1f41392, (q31_t)0x568a34a9, (q31_t)0xa1affea3, (q31_t)0x56400758, (q31_t)0xa16c23e1, - (q31_t)0x55f5a4d2, (q31_t)0xa1288376, (q31_t)0x55ab0d46, (q31_t)0xa0e51d8c, (q31_t)0x556040e2, (q31_t)0xa0a1f24d, (q31_t)0x55153fd4, (q31_t)0xa05f01e1, - (q31_t)0x54ca0a4b, (q31_t)0xa01c4c73, (q31_t)0x547ea073, (q31_t)0x9fd9d22a, (q31_t)0x5433027d, (q31_t)0x9f979331, (q31_t)0x53e73097, (q31_t)0x9f558fb0, - (q31_t)0x539b2af0, (q31_t)0x9f13c7d0, (q31_t)0x534ef1b5, (q31_t)0x9ed23bb9, (q31_t)0x53028518, (q31_t)0x9e90eb94, (q31_t)0x52b5e546, (q31_t)0x9e4fd78a, - (q31_t)0x5269126e, (q31_t)0x9e0effc1, (q31_t)0x521c0cc2, (q31_t)0x9dce6463, (q31_t)0x51ced46e, (q31_t)0x9d8e0597, (q31_t)0x518169a5, (q31_t)0x9d4de385, - (q31_t)0x5133cc94, (q31_t)0x9d0dfe54, (q31_t)0x50e5fd6d, (q31_t)0x9cce562c, (q31_t)0x5097fc5e, (q31_t)0x9c8eeb34, (q31_t)0x5049c999, (q31_t)0x9c4fbd93, - (q31_t)0x4ffb654d, (q31_t)0x9c10cd70, (q31_t)0x4faccfab, (q31_t)0x9bd21af3, (q31_t)0x4f5e08e3, (q31_t)0x9b93a641, (q31_t)0x4f0f1126, (q31_t)0x9b556f81, - (q31_t)0x4ebfe8a5, (q31_t)0x9b1776da, (q31_t)0x4e708f8f, (q31_t)0x9ad9bc71, (q31_t)0x4e210617, (q31_t)0x9a9c406e, (q31_t)0x4dd14c6e, (q31_t)0x9a5f02f5, - (q31_t)0x4d8162c4, (q31_t)0x9a22042d, (q31_t)0x4d31494b, (q31_t)0x99e5443b, (q31_t)0x4ce10034, (q31_t)0x99a8c345, (q31_t)0x4c9087b1, (q31_t)0x996c816f, - (q31_t)0x4c3fdff4, (q31_t)0x99307ee0, (q31_t)0x4bef092d, (q31_t)0x98f4bbbc, (q31_t)0x4b9e0390, (q31_t)0x98b93828, (q31_t)0x4b4ccf4d, (q31_t)0x987df449, - (q31_t)0x4afb6c98, (q31_t)0x9842f043, (q31_t)0x4aa9dba2, (q31_t)0x98082c3b, (q31_t)0x4a581c9e, (q31_t)0x97cda855, (q31_t)0x4a062fbd, (q31_t)0x979364b5, - (q31_t)0x49b41533, (q31_t)0x9759617f, (q31_t)0x4961cd33, (q31_t)0x971f9ed7, (q31_t)0x490f57ee, (q31_t)0x96e61ce0, (q31_t)0x48bcb599, (q31_t)0x96acdbbe, - (q31_t)0x4869e665, (q31_t)0x9673db94, (q31_t)0x4816ea86, (q31_t)0x963b1c86, (q31_t)0x47c3c22f, (q31_t)0x96029eb6, (q31_t)0x47706d93, (q31_t)0x95ca6247, - (q31_t)0x471cece7, (q31_t)0x9592675c, (q31_t)0x46c9405c, (q31_t)0x955aae17, (q31_t)0x46756828, (q31_t)0x9523369c, (q31_t)0x4621647d, (q31_t)0x94ec010b, - (q31_t)0x45cd358f, (q31_t)0x94b50d87, (q31_t)0x4578db93, (q31_t)0x947e5c33, (q31_t)0x452456bd, (q31_t)0x9447ed2f, (q31_t)0x44cfa740, (q31_t)0x9411c09e, - (q31_t)0x447acd50, (q31_t)0x93dbd6a0, (q31_t)0x4425c923, (q31_t)0x93a62f57, (q31_t)0x43d09aed, (q31_t)0x9370cae4, (q31_t)0x437b42e1, (q31_t)0x933ba968, - (q31_t)0x4325c135, (q31_t)0x9306cb04, (q31_t)0x42d0161e, (q31_t)0x92d22fd9, (q31_t)0x427a41d0, (q31_t)0x929dd806, (q31_t)0x42244481, (q31_t)0x9269c3ac, - (q31_t)0x41ce1e65, (q31_t)0x9235f2ec, (q31_t)0x4177cfb1, (q31_t)0x920265e4, (q31_t)0x4121589b, (q31_t)0x91cf1cb6, (q31_t)0x40cab958, (q31_t)0x919c1781, - (q31_t)0x4073f21d, (q31_t)0x91695663, (q31_t)0x401d0321, (q31_t)0x9136d97d, (q31_t)0x3fc5ec98, (q31_t)0x9104a0ee, (q31_t)0x3f6eaeb8, (q31_t)0x90d2acd4, - (q31_t)0x3f1749b8, (q31_t)0x90a0fd4e, (q31_t)0x3ebfbdcd, (q31_t)0x906f927c, (q31_t)0x3e680b2c, (q31_t)0x903e6c7b, (q31_t)0x3e10320d, (q31_t)0x900d8b69, - (q31_t)0x3db832a6, (q31_t)0x8fdcef66, (q31_t)0x3d600d2c, (q31_t)0x8fac988f, (q31_t)0x3d07c1d6, (q31_t)0x8f7c8701, (q31_t)0x3caf50da, (q31_t)0x8f4cbadb, - (q31_t)0x3c56ba70, (q31_t)0x8f1d343a, (q31_t)0x3bfdfecd, (q31_t)0x8eedf33b, (q31_t)0x3ba51e29, (q31_t)0x8ebef7fb, (q31_t)0x3b4c18ba, (q31_t)0x8e904298, - (q31_t)0x3af2eeb7, (q31_t)0x8e61d32e, (q31_t)0x3a99a057, (q31_t)0x8e33a9da, (q31_t)0x3a402dd2, (q31_t)0x8e05c6b7, (q31_t)0x39e6975e, (q31_t)0x8dd829e4, - (q31_t)0x398cdd32, (q31_t)0x8daad37b, (q31_t)0x3932ff87, (q31_t)0x8d7dc399, (q31_t)0x38d8fe93, (q31_t)0x8d50fa59, (q31_t)0x387eda8e, (q31_t)0x8d2477d8, - (q31_t)0x382493b0, (q31_t)0x8cf83c30, (q31_t)0x37ca2a30, (q31_t)0x8ccc477d, (q31_t)0x376f9e46, (q31_t)0x8ca099da, (q31_t)0x3714f02a, (q31_t)0x8c753362, - (q31_t)0x36ba2014, (q31_t)0x8c4a142f, (q31_t)0x365f2e3b, (q31_t)0x8c1f3c5d, (q31_t)0x36041ad9, (q31_t)0x8bf4ac05, (q31_t)0x35a8e625, (q31_t)0x8bca6343, - (q31_t)0x354d9057, (q31_t)0x8ba0622f, (q31_t)0x34f219a8, (q31_t)0x8b76a8e4, (q31_t)0x34968250, (q31_t)0x8b4d377c, (q31_t)0x343aca87, (q31_t)0x8b240e11, - (q31_t)0x33def287, (q31_t)0x8afb2cbb, (q31_t)0x3382fa88, (q31_t)0x8ad29394, (q31_t)0x3326e2c3, (q31_t)0x8aaa42b4, (q31_t)0x32caab6f, (q31_t)0x8a823a36, - (q31_t)0x326e54c7, (q31_t)0x8a5a7a31, (q31_t)0x3211df04, (q31_t)0x8a3302be, (q31_t)0x31b54a5e, (q31_t)0x8a0bd3f5, (q31_t)0x3158970e, (q31_t)0x89e4edef, - (q31_t)0x30fbc54d, (q31_t)0x89be50c3, (q31_t)0x309ed556, (q31_t)0x8997fc8a, (q31_t)0x3041c761, (q31_t)0x8971f15a, (q31_t)0x2fe49ba7, (q31_t)0x894c2f4c, - (q31_t)0x2f875262, (q31_t)0x8926b677, (q31_t)0x2f29ebcc, (q31_t)0x890186f2, (q31_t)0x2ecc681e, (q31_t)0x88dca0d3, (q31_t)0x2e6ec792, (q31_t)0x88b80432, - (q31_t)0x2e110a62, (q31_t)0x8893b125, (q31_t)0x2db330c7, (q31_t)0x886fa7c2, (q31_t)0x2d553afc, (q31_t)0x884be821, (q31_t)0x2cf72939, (q31_t)0x88287256, - (q31_t)0x2c98fbba, (q31_t)0x88054677, (q31_t)0x2c3ab2b9, (q31_t)0x87e2649b, (q31_t)0x2bdc4e6f, (q31_t)0x87bfccd7, (q31_t)0x2b7dcf17, (q31_t)0x879d7f41, - (q31_t)0x2b1f34eb, (q31_t)0x877b7bec, (q31_t)0x2ac08026, (q31_t)0x8759c2ef, (q31_t)0x2a61b101, (q31_t)0x8738545e, (q31_t)0x2a02c7b8, (q31_t)0x8717304e, - (q31_t)0x29a3c485, (q31_t)0x86f656d3, (q31_t)0x2944a7a2, (q31_t)0x86d5c802, (q31_t)0x28e5714b, (q31_t)0x86b583ee, (q31_t)0x288621b9, (q31_t)0x86958aac, - (q31_t)0x2826b928, (q31_t)0x8675dc4f, (q31_t)0x27c737d3, (q31_t)0x865678eb, (q31_t)0x27679df4, (q31_t)0x86376092, (q31_t)0x2707ebc7, (q31_t)0x86189359, - (q31_t)0x26a82186, (q31_t)0x85fa1153, (q31_t)0x26483f6c, (q31_t)0x85dbda91, (q31_t)0x25e845b6, (q31_t)0x85bdef28, (q31_t)0x2588349d, (q31_t)0x85a04f28, - (q31_t)0x25280c5e, (q31_t)0x8582faa5, (q31_t)0x24c7cd33, (q31_t)0x8565f1b0, (q31_t)0x24677758, (q31_t)0x8549345c, (q31_t)0x24070b08, (q31_t)0x852cc2bb, - (q31_t)0x23a6887f, (q31_t)0x85109cdd, (q31_t)0x2345eff8, (q31_t)0x84f4c2d4, (q31_t)0x22e541af, (q31_t)0x84d934b1, (q31_t)0x22847de0, (q31_t)0x84bdf286, - (q31_t)0x2223a4c5, (q31_t)0x84a2fc62, (q31_t)0x21c2b69c, (q31_t)0x84885258, (q31_t)0x2161b3a0, (q31_t)0x846df477, (q31_t)0x21009c0c, (q31_t)0x8453e2cf, - (q31_t)0x209f701c, (q31_t)0x843a1d70, (q31_t)0x203e300d, (q31_t)0x8420a46c, (q31_t)0x1fdcdc1b, (q31_t)0x840777d0, (q31_t)0x1f7b7481, (q31_t)0x83ee97ad, - (q31_t)0x1f19f97b, (q31_t)0x83d60412, (q31_t)0x1eb86b46, (q31_t)0x83bdbd0e, (q31_t)0x1e56ca1e, (q31_t)0x83a5c2b0, (q31_t)0x1df5163f, (q31_t)0x838e1507, - (q31_t)0x1d934fe5, (q31_t)0x8376b422, (q31_t)0x1d31774d, (q31_t)0x835fa00f, (q31_t)0x1ccf8cb3, (q31_t)0x8348d8dc, (q31_t)0x1c6d9053, (q31_t)0x83325e97, - (q31_t)0x1c0b826a, (q31_t)0x831c314e, (q31_t)0x1ba96335, (q31_t)0x83065110, (q31_t)0x1b4732ef, (q31_t)0x82f0bde8, (q31_t)0x1ae4f1d6, (q31_t)0x82db77e5, - (q31_t)0x1a82a026, (q31_t)0x82c67f14, (q31_t)0x1a203e1b, (q31_t)0x82b1d381, (q31_t)0x19bdcbf3, (q31_t)0x829d753a, (q31_t)0x195b49ea, (q31_t)0x8289644b, - (q31_t)0x18f8b83c, (q31_t)0x8275a0c0, (q31_t)0x18961728, (q31_t)0x82622aa6, (q31_t)0x183366e9, (q31_t)0x824f0208, (q31_t)0x17d0a7bc, (q31_t)0x823c26f3, - (q31_t)0x176dd9de, (q31_t)0x82299971, (q31_t)0x170afd8d, (q31_t)0x82175990, (q31_t)0x16a81305, (q31_t)0x82056758, (q31_t)0x16451a83, (q31_t)0x81f3c2d7, - (q31_t)0x15e21445, (q31_t)0x81e26c16, (q31_t)0x157f0086, (q31_t)0x81d16321, (q31_t)0x151bdf86, (q31_t)0x81c0a801, (q31_t)0x14b8b17f, (q31_t)0x81b03ac2, - (q31_t)0x145576b1, (q31_t)0x81a01b6d, (q31_t)0x13f22f58, (q31_t)0x81904a0c, (q31_t)0x138edbb1, (q31_t)0x8180c6a9, (q31_t)0x132b7bf9, (q31_t)0x8171914e, - (q31_t)0x12c8106f, (q31_t)0x8162aa04, (q31_t)0x1264994e, (q31_t)0x815410d4, (q31_t)0x120116d5, (q31_t)0x8145c5c7, (q31_t)0x119d8941, (q31_t)0x8137c8e6, - (q31_t)0x1139f0cf, (q31_t)0x812a1a3a, (q31_t)0x10d64dbd, (q31_t)0x811cb9ca, (q31_t)0x1072a048, (q31_t)0x810fa7a0, (q31_t)0x100ee8ad, (q31_t)0x8102e3c4, - (q31_t)0x0fab272b, (q31_t)0x80f66e3c, (q31_t)0x0f475bff, (q31_t)0x80ea4712, (q31_t)0x0ee38766, (q31_t)0x80de6e4c, (q31_t)0x0e7fa99e, (q31_t)0x80d2e3f2, - (q31_t)0x0e1bc2e4, (q31_t)0x80c7a80a, (q31_t)0x0db7d376, (q31_t)0x80bcba9d, (q31_t)0x0d53db92, (q31_t)0x80b21baf, (q31_t)0x0cefdb76, (q31_t)0x80a7cb49, - (q31_t)0x0c8bd35e, (q31_t)0x809dc971, (q31_t)0x0c27c389, (q31_t)0x8094162c, (q31_t)0x0bc3ac35, (q31_t)0x808ab180, (q31_t)0x0b5f8d9f, (q31_t)0x80819b74, - (q31_t)0x0afb6805, (q31_t)0x8078d40d, (q31_t)0x0a973ba5, (q31_t)0x80705b50, (q31_t)0x0a3308bd, (q31_t)0x80683143, (q31_t)0x09cecf89, (q31_t)0x806055eb, - (q31_t)0x096a9049, (q31_t)0x8058c94c, (q31_t)0x09064b3a, (q31_t)0x80518b6b, (q31_t)0x08a2009a, (q31_t)0x804a9c4d, (q31_t)0x083db0a7, (q31_t)0x8043fbf6, - (q31_t)0x07d95b9e, (q31_t)0x803daa6a, (q31_t)0x077501be, (q31_t)0x8037a7ac, (q31_t)0x0710a345, (q31_t)0x8031f3c2, (q31_t)0x06ac406f, (q31_t)0x802c8ead, - (q31_t)0x0647d97c, (q31_t)0x80277872, (q31_t)0x05e36ea9, (q31_t)0x8022b114, (q31_t)0x057f0035, (q31_t)0x801e3895, (q31_t)0x051a8e5c, (q31_t)0x801a0ef8, - (q31_t)0x04b6195d, (q31_t)0x80163440, (q31_t)0x0451a177, (q31_t)0x8012a86f, (q31_t)0x03ed26e6, (q31_t)0x800f6b88, (q31_t)0x0388a9ea, (q31_t)0x800c7d8c, - (q31_t)0x03242abf, (q31_t)0x8009de7e, (q31_t)0x02bfa9a4, (q31_t)0x80078e5e, (q31_t)0x025b26d7, (q31_t)0x80058d2f, (q31_t)0x01f6a297, (q31_t)0x8003daf1, - (q31_t)0x01921d20, (q31_t)0x800277a6, (q31_t)0x012d96b1, (q31_t)0x8001634e, (q31_t)0x00c90f88, (q31_t)0x80009dea, (q31_t)0x006487e3, (q31_t)0x8000277a -}; + (q31_t)0x7fffffff, (q31_t)0x00000000, (q31_t)0x7fffd886, (q31_t)0xff9b781d, + (q31_t)0x7fff6216, (q31_t)0xff36f078, (q31_t)0x7ffe9cb2, (q31_t)0xfed2694f, + (q31_t)0x7ffd885a, (q31_t)0xfe6de2e0, (q31_t)0x7ffc250f, (q31_t)0xfe095d69, + (q31_t)0x7ffa72d1, (q31_t)0xfda4d929, (q31_t)0x7ff871a2, (q31_t)0xfd40565c, + (q31_t)0x7ff62182, (q31_t)0xfcdbd541, (q31_t)0x7ff38274, (q31_t)0xfc775616, + (q31_t)0x7ff09478, (q31_t)0xfc12d91a, (q31_t)0x7fed5791, (q31_t)0xfbae5e89, + (q31_t)0x7fe9cbc0, (q31_t)0xfb49e6a3, (q31_t)0x7fe5f108, (q31_t)0xfae571a4, + (q31_t)0x7fe1c76b, (q31_t)0xfa80ffcb, (q31_t)0x7fdd4eec, (q31_t)0xfa1c9157, + (q31_t)0x7fd8878e, (q31_t)0xf9b82684, (q31_t)0x7fd37153, (q31_t)0xf953bf91, + (q31_t)0x7fce0c3e, (q31_t)0xf8ef5cbb, (q31_t)0x7fc85854, (q31_t)0xf88afe42, + (q31_t)0x7fc25596, (q31_t)0xf826a462, (q31_t)0x7fbc040a, (q31_t)0xf7c24f59, + (q31_t)0x7fb563b3, (q31_t)0xf75dff66, (q31_t)0x7fae7495, (q31_t)0xf6f9b4c6, + (q31_t)0x7fa736b4, (q31_t)0xf6956fb7, (q31_t)0x7f9faa15, (q31_t)0xf6313077, + (q31_t)0x7f97cebd, (q31_t)0xf5ccf743, (q31_t)0x7f8fa4b0, (q31_t)0xf568c45b, + (q31_t)0x7f872bf3, (q31_t)0xf50497fb, (q31_t)0x7f7e648c, (q31_t)0xf4a07261, + (q31_t)0x7f754e80, (q31_t)0xf43c53cb, (q31_t)0x7f6be9d4, (q31_t)0xf3d83c77, + (q31_t)0x7f62368f, (q31_t)0xf3742ca2, (q31_t)0x7f5834b7, (q31_t)0xf310248a, + (q31_t)0x7f4de451, (q31_t)0xf2ac246e, (q31_t)0x7f434563, (q31_t)0xf2482c8a, + (q31_t)0x7f3857f6, (q31_t)0xf1e43d1c, (q31_t)0x7f2d1c0e, (q31_t)0xf1805662, + (q31_t)0x7f2191b4, (q31_t)0xf11c789a, (q31_t)0x7f15b8ee, (q31_t)0xf0b8a401, + (q31_t)0x7f0991c4, (q31_t)0xf054d8d5, (q31_t)0x7efd1c3c, (q31_t)0xeff11753, + (q31_t)0x7ef05860, (q31_t)0xef8d5fb8, (q31_t)0x7ee34636, (q31_t)0xef29b243, + (q31_t)0x7ed5e5c6, (q31_t)0xeec60f31, (q31_t)0x7ec8371a, (q31_t)0xee6276bf, + (q31_t)0x7eba3a39, (q31_t)0xedfee92b, (q31_t)0x7eabef2c, (q31_t)0xed9b66b2, + (q31_t)0x7e9d55fc, (q31_t)0xed37ef91, (q31_t)0x7e8e6eb2, (q31_t)0xecd48407, + (q31_t)0x7e7f3957, (q31_t)0xec71244f, (q31_t)0x7e6fb5f4, (q31_t)0xec0dd0a8, + (q31_t)0x7e5fe493, (q31_t)0xebaa894f, (q31_t)0x7e4fc53e, (q31_t)0xeb474e81, + (q31_t)0x7e3f57ff, (q31_t)0xeae4207a, (q31_t)0x7e2e9cdf, (q31_t)0xea80ff7a, + (q31_t)0x7e1d93ea, (q31_t)0xea1debbb, (q31_t)0x7e0c3d29, (q31_t)0xe9bae57d, + (q31_t)0x7dfa98a8, (q31_t)0xe957ecfb, (q31_t)0x7de8a670, (q31_t)0xe8f50273, + (q31_t)0x7dd6668f, (q31_t)0xe8922622, (q31_t)0x7dc3d90d, (q31_t)0xe82f5844, + (q31_t)0x7db0fdf8, (q31_t)0xe7cc9917, (q31_t)0x7d9dd55a, (q31_t)0xe769e8d8, + (q31_t)0x7d8a5f40, (q31_t)0xe70747c4, (q31_t)0x7d769bb5, (q31_t)0xe6a4b616, + (q31_t)0x7d628ac6, (q31_t)0xe642340d, (q31_t)0x7d4e2c7f, (q31_t)0xe5dfc1e5, + (q31_t)0x7d3980ec, (q31_t)0xe57d5fda, (q31_t)0x7d24881b, (q31_t)0xe51b0e2a, + (q31_t)0x7d0f4218, (q31_t)0xe4b8cd11, (q31_t)0x7cf9aef0, (q31_t)0xe4569ccb, + (q31_t)0x7ce3ceb2, (q31_t)0xe3f47d96, (q31_t)0x7ccda169, (q31_t)0xe3926fad, + (q31_t)0x7cb72724, (q31_t)0xe330734d, (q31_t)0x7ca05ff1, (q31_t)0xe2ce88b3, + (q31_t)0x7c894bde, (q31_t)0xe26cb01b, (q31_t)0x7c71eaf9, (q31_t)0xe20ae9c1, + (q31_t)0x7c5a3d50, (q31_t)0xe1a935e2, (q31_t)0x7c4242f2, (q31_t)0xe14794ba, + (q31_t)0x7c29fbee, (q31_t)0xe0e60685, (q31_t)0x7c116853, (q31_t)0xe0848b7f, + (q31_t)0x7bf88830, (q31_t)0xe02323e5, (q31_t)0x7bdf5b94, (q31_t)0xdfc1cff3, + (q31_t)0x7bc5e290, (q31_t)0xdf608fe4, (q31_t)0x7bac1d31, (q31_t)0xdeff63f4, + (q31_t)0x7b920b89, (q31_t)0xde9e4c60, (q31_t)0x7b77ada8, (q31_t)0xde3d4964, + (q31_t)0x7b5d039e, (q31_t)0xdddc5b3b, (q31_t)0x7b420d7a, (q31_t)0xdd7b8220, + (q31_t)0x7b26cb4f, (q31_t)0xdd1abe51, (q31_t)0x7b0b3d2c, (q31_t)0xdcba1008, + (q31_t)0x7aef6323, (q31_t)0xdc597781, (q31_t)0x7ad33d45, (q31_t)0xdbf8f4f8, + (q31_t)0x7ab6cba4, (q31_t)0xdb9888a8, (q31_t)0x7a9a0e50, (q31_t)0xdb3832cd, + (q31_t)0x7a7d055b, (q31_t)0xdad7f3a2, (q31_t)0x7a5fb0d8, (q31_t)0xda77cb63, + (q31_t)0x7a4210d8, (q31_t)0xda17ba4a, (q31_t)0x7a24256f, (q31_t)0xd9b7c094, + (q31_t)0x7a05eead, (q31_t)0xd957de7a, (q31_t)0x79e76ca7, (q31_t)0xd8f81439, + (q31_t)0x79c89f6e, (q31_t)0xd898620c, (q31_t)0x79a98715, (q31_t)0xd838c82d, + (q31_t)0x798a23b1, (q31_t)0xd7d946d8, (q31_t)0x796a7554, (q31_t)0xd779de47, + (q31_t)0x794a7c12, (q31_t)0xd71a8eb5, (q31_t)0x792a37fe, (q31_t)0xd6bb585e, + (q31_t)0x7909a92d, (q31_t)0xd65c3b7b, (q31_t)0x78e8cfb2, (q31_t)0xd5fd3848, + (q31_t)0x78c7aba2, (q31_t)0xd59e4eff, (q31_t)0x78a63d11, (q31_t)0xd53f7fda, + (q31_t)0x78848414, (q31_t)0xd4e0cb15, (q31_t)0x786280bf, (q31_t)0xd48230e9, + (q31_t)0x78403329, (q31_t)0xd423b191, (q31_t)0x781d9b65, (q31_t)0xd3c54d47, + (q31_t)0x77fab989, (q31_t)0xd3670446, (q31_t)0x77d78daa, (q31_t)0xd308d6c7, + (q31_t)0x77b417df, (q31_t)0xd2aac504, (q31_t)0x7790583e, (q31_t)0xd24ccf39, + (q31_t)0x776c4edb, (q31_t)0xd1eef59e, (q31_t)0x7747fbce, (q31_t)0xd191386e, + (q31_t)0x77235f2d, (q31_t)0xd13397e2, (q31_t)0x76fe790e, (q31_t)0xd0d61434, + (q31_t)0x76d94989, (q31_t)0xd078ad9e, (q31_t)0x76b3d0b4, (q31_t)0xd01b6459, + (q31_t)0x768e0ea6, (q31_t)0xcfbe389f, (q31_t)0x76680376, (q31_t)0xcf612aaa, + (q31_t)0x7641af3d, (q31_t)0xcf043ab3, (q31_t)0x761b1211, (q31_t)0xcea768f2, + (q31_t)0x75f42c0b, (q31_t)0xce4ab5a2, (q31_t)0x75ccfd42, (q31_t)0xcdee20fc, + (q31_t)0x75a585cf, (q31_t)0xcd91ab39, (q31_t)0x757dc5ca, (q31_t)0xcd355491, + (q31_t)0x7555bd4c, (q31_t)0xccd91d3d, (q31_t)0x752d6c6c, (q31_t)0xcc7d0578, + (q31_t)0x7504d345, (q31_t)0xcc210d79, (q31_t)0x74dbf1ef, (q31_t)0xcbc53579, + (q31_t)0x74b2c884, (q31_t)0xcb697db0, (q31_t)0x7489571c, (q31_t)0xcb0de658, + (q31_t)0x745f9dd1, (q31_t)0xcab26fa9, (q31_t)0x74359cbd, (q31_t)0xca5719db, + (q31_t)0x740b53fb, (q31_t)0xc9fbe527, (q31_t)0x73e0c3a3, (q31_t)0xc9a0d1c5, + (q31_t)0x73b5ebd1, (q31_t)0xc945dfec, (q31_t)0x738acc9e, (q31_t)0xc8eb0fd6, + (q31_t)0x735f6626, (q31_t)0xc89061ba, (q31_t)0x7333b883, (q31_t)0xc835d5d0, + (q31_t)0x7307c3d0, (q31_t)0xc7db6c50, (q31_t)0x72db8828, (q31_t)0xc7812572, + (q31_t)0x72af05a7, (q31_t)0xc727016d, (q31_t)0x72823c67, (q31_t)0xc6cd0079, + (q31_t)0x72552c85, (q31_t)0xc67322ce, (q31_t)0x7227d61c, (q31_t)0xc61968a2, + (q31_t)0x71fa3949, (q31_t)0xc5bfd22e, (q31_t)0x71cc5626, (q31_t)0xc5665fa9, + (q31_t)0x719e2cd2, (q31_t)0xc50d1149, (q31_t)0x716fbd68, (q31_t)0xc4b3e746, + (q31_t)0x71410805, (q31_t)0xc45ae1d7, (q31_t)0x71120cc5, (q31_t)0xc4020133, + (q31_t)0x70e2cbc6, (q31_t)0xc3a94590, (q31_t)0x70b34525, (q31_t)0xc350af26, + (q31_t)0x708378ff, (q31_t)0xc2f83e2a, (q31_t)0x70536771, (q31_t)0xc29ff2d4, + (q31_t)0x7023109a, (q31_t)0xc247cd5a, (q31_t)0x6ff27497, (q31_t)0xc1efcdf3, + (q31_t)0x6fc19385, (q31_t)0xc197f4d4, (q31_t)0x6f906d84, (q31_t)0xc1404233, + (q31_t)0x6f5f02b2, (q31_t)0xc0e8b648, (q31_t)0x6f2d532c, (q31_t)0xc0915148, + (q31_t)0x6efb5f12, (q31_t)0xc03a1368, (q31_t)0x6ec92683, (q31_t)0xbfe2fcdf, + (q31_t)0x6e96a99d, (q31_t)0xbf8c0de3, (q31_t)0x6e63e87f, (q31_t)0xbf3546a8, + (q31_t)0x6e30e34a, (q31_t)0xbedea765, (q31_t)0x6dfd9a1c, (q31_t)0xbe88304f, + (q31_t)0x6dca0d14, (q31_t)0xbe31e19b, (q31_t)0x6d963c54, (q31_t)0xbddbbb7f, + (q31_t)0x6d6227fa, (q31_t)0xbd85be30, (q31_t)0x6d2dd027, (q31_t)0xbd2fe9e2, + (q31_t)0x6cf934fc, (q31_t)0xbcda3ecb, (q31_t)0x6cc45698, (q31_t)0xbc84bd1f, + (q31_t)0x6c8f351c, (q31_t)0xbc2f6513, (q31_t)0x6c59d0a9, (q31_t)0xbbda36dd, + (q31_t)0x6c242960, (q31_t)0xbb8532b0, (q31_t)0x6bee3f62, (q31_t)0xbb3058c0, + (q31_t)0x6bb812d1, (q31_t)0xbadba943, (q31_t)0x6b81a3cd, (q31_t)0xba87246d, + (q31_t)0x6b4af279, (q31_t)0xba32ca71, (q31_t)0x6b13fef5, (q31_t)0xb9de9b83, + (q31_t)0x6adcc964, (q31_t)0xb98a97d8, (q31_t)0x6aa551e9, (q31_t)0xb936bfa4, + (q31_t)0x6a6d98a4, (q31_t)0xb8e31319, (q31_t)0x6a359db9, (q31_t)0xb88f926d, + (q31_t)0x69fd614a, (q31_t)0xb83c3dd1, (q31_t)0x69c4e37a, (q31_t)0xb7e9157a, + (q31_t)0x698c246c, (q31_t)0xb796199b, (q31_t)0x69532442, (q31_t)0xb7434a67, + (q31_t)0x6919e320, (q31_t)0xb6f0a812, (q31_t)0x68e06129, (q31_t)0xb69e32cd, + (q31_t)0x68a69e81, (q31_t)0xb64beacd, (q31_t)0x686c9b4b, (q31_t)0xb5f9d043, + (q31_t)0x683257ab, (q31_t)0xb5a7e362, (q31_t)0x67f7d3c5, (q31_t)0xb556245e, + (q31_t)0x67bd0fbd, (q31_t)0xb5049368, (q31_t)0x67820bb7, (q31_t)0xb4b330b3, + (q31_t)0x6746c7d8, (q31_t)0xb461fc70, (q31_t)0x670b4444, (q31_t)0xb410f6d3, + (q31_t)0x66cf8120, (q31_t)0xb3c0200c, (q31_t)0x66937e91, (q31_t)0xb36f784f, + (q31_t)0x66573cbb, (q31_t)0xb31effcc, (q31_t)0x661abbc5, (q31_t)0xb2ceb6b5, + (q31_t)0x65ddfbd3, (q31_t)0xb27e9d3c, (q31_t)0x65a0fd0b, (q31_t)0xb22eb392, + (q31_t)0x6563bf92, (q31_t)0xb1def9e9, (q31_t)0x6526438f, (q31_t)0xb18f7071, + (q31_t)0x64e88926, (q31_t)0xb140175b, (q31_t)0x64aa907f, (q31_t)0xb0f0eeda, + (q31_t)0x646c59bf, (q31_t)0xb0a1f71d, (q31_t)0x642de50d, (q31_t)0xb0533055, + (q31_t)0x63ef3290, (q31_t)0xb0049ab3, (q31_t)0x63b0426d, (q31_t)0xafb63667, + (q31_t)0x637114cc, (q31_t)0xaf6803a2, (q31_t)0x6331a9d4, (q31_t)0xaf1a0293, + (q31_t)0x62f201ac, (q31_t)0xaecc336c, (q31_t)0x62b21c7b, (q31_t)0xae7e965b, + (q31_t)0x6271fa69, (q31_t)0xae312b92, (q31_t)0x62319b9d, (q31_t)0xade3f33e, + (q31_t)0x61f1003f, (q31_t)0xad96ed92, (q31_t)0x61b02876, (q31_t)0xad4a1aba, + (q31_t)0x616f146c, (q31_t)0xacfd7ae8, (q31_t)0x612dc447, (q31_t)0xacb10e4b, + (q31_t)0x60ec3830, (q31_t)0xac64d510, (q31_t)0x60aa7050, (q31_t)0xac18cf69, + (q31_t)0x60686ccf, (q31_t)0xabccfd83, (q31_t)0x60262dd6, (q31_t)0xab815f8d, + (q31_t)0x5fe3b38d, (q31_t)0xab35f5b5, (q31_t)0x5fa0fe1f, (q31_t)0xaaeac02c, + (q31_t)0x5f5e0db3, (q31_t)0xaa9fbf1e, (q31_t)0x5f1ae274, (q31_t)0xaa54f2ba, + (q31_t)0x5ed77c8a, (q31_t)0xaa0a5b2e, (q31_t)0x5e93dc1f, (q31_t)0xa9bff8a8, + (q31_t)0x5e50015d, (q31_t)0xa975cb57, (q31_t)0x5e0bec6e, (q31_t)0xa92bd367, + (q31_t)0x5dc79d7c, (q31_t)0xa8e21106, (q31_t)0x5d8314b1, (q31_t)0xa8988463, + (q31_t)0x5d3e5237, (q31_t)0xa84f2daa, (q31_t)0x5cf95638, (q31_t)0xa8060d08, + (q31_t)0x5cb420e0, (q31_t)0xa7bd22ac, (q31_t)0x5c6eb258, (q31_t)0xa7746ec0, + (q31_t)0x5c290acc, (q31_t)0xa72bf174, (q31_t)0x5be32a67, (q31_t)0xa6e3aaf2, + (q31_t)0x5b9d1154, (q31_t)0xa69b9b68, (q31_t)0x5b56bfbd, (q31_t)0xa653c303, + (q31_t)0x5b1035cf, (q31_t)0xa60c21ee, (q31_t)0x5ac973b5, (q31_t)0xa5c4b855, + (q31_t)0x5a82799a, (q31_t)0xa57d8666, (q31_t)0x5a3b47ab, (q31_t)0xa5368c4b, + (q31_t)0x59f3de12, (q31_t)0xa4efca31, (q31_t)0x59ac3cfd, (q31_t)0xa4a94043, + (q31_t)0x59646498, (q31_t)0xa462eeac, (q31_t)0x591c550e, (q31_t)0xa41cd599, + (q31_t)0x58d40e8c, (q31_t)0xa3d6f534, (q31_t)0x588b9140, (q31_t)0xa3914da8, + (q31_t)0x5842dd54, (q31_t)0xa34bdf20, (q31_t)0x57f9f2f8, (q31_t)0xa306a9c8, + (q31_t)0x57b0d256, (q31_t)0xa2c1adc9, (q31_t)0x57677b9d, (q31_t)0xa27ceb4f, + (q31_t)0x571deefa, (q31_t)0xa2386284, (q31_t)0x56d42c99, (q31_t)0xa1f41392, + (q31_t)0x568a34a9, (q31_t)0xa1affea3, (q31_t)0x56400758, (q31_t)0xa16c23e1, + (q31_t)0x55f5a4d2, (q31_t)0xa1288376, (q31_t)0x55ab0d46, (q31_t)0xa0e51d8c, + (q31_t)0x556040e2, (q31_t)0xa0a1f24d, (q31_t)0x55153fd4, (q31_t)0xa05f01e1, + (q31_t)0x54ca0a4b, (q31_t)0xa01c4c73, (q31_t)0x547ea073, (q31_t)0x9fd9d22a, + (q31_t)0x5433027d, (q31_t)0x9f979331, (q31_t)0x53e73097, (q31_t)0x9f558fb0, + (q31_t)0x539b2af0, (q31_t)0x9f13c7d0, (q31_t)0x534ef1b5, (q31_t)0x9ed23bb9, + (q31_t)0x53028518, (q31_t)0x9e90eb94, (q31_t)0x52b5e546, (q31_t)0x9e4fd78a, + (q31_t)0x5269126e, (q31_t)0x9e0effc1, (q31_t)0x521c0cc2, (q31_t)0x9dce6463, + (q31_t)0x51ced46e, (q31_t)0x9d8e0597, (q31_t)0x518169a5, (q31_t)0x9d4de385, + (q31_t)0x5133cc94, (q31_t)0x9d0dfe54, (q31_t)0x50e5fd6d, (q31_t)0x9cce562c, + (q31_t)0x5097fc5e, (q31_t)0x9c8eeb34, (q31_t)0x5049c999, (q31_t)0x9c4fbd93, + (q31_t)0x4ffb654d, (q31_t)0x9c10cd70, (q31_t)0x4faccfab, (q31_t)0x9bd21af3, + (q31_t)0x4f5e08e3, (q31_t)0x9b93a641, (q31_t)0x4f0f1126, (q31_t)0x9b556f81, + (q31_t)0x4ebfe8a5, (q31_t)0x9b1776da, (q31_t)0x4e708f8f, (q31_t)0x9ad9bc71, + (q31_t)0x4e210617, (q31_t)0x9a9c406e, (q31_t)0x4dd14c6e, (q31_t)0x9a5f02f5, + (q31_t)0x4d8162c4, (q31_t)0x9a22042d, (q31_t)0x4d31494b, (q31_t)0x99e5443b, + (q31_t)0x4ce10034, (q31_t)0x99a8c345, (q31_t)0x4c9087b1, (q31_t)0x996c816f, + (q31_t)0x4c3fdff4, (q31_t)0x99307ee0, (q31_t)0x4bef092d, (q31_t)0x98f4bbbc, + (q31_t)0x4b9e0390, (q31_t)0x98b93828, (q31_t)0x4b4ccf4d, (q31_t)0x987df449, + (q31_t)0x4afb6c98, (q31_t)0x9842f043, (q31_t)0x4aa9dba2, (q31_t)0x98082c3b, + (q31_t)0x4a581c9e, (q31_t)0x97cda855, (q31_t)0x4a062fbd, (q31_t)0x979364b5, + (q31_t)0x49b41533, (q31_t)0x9759617f, (q31_t)0x4961cd33, (q31_t)0x971f9ed7, + (q31_t)0x490f57ee, (q31_t)0x96e61ce0, (q31_t)0x48bcb599, (q31_t)0x96acdbbe, + (q31_t)0x4869e665, (q31_t)0x9673db94, (q31_t)0x4816ea86, (q31_t)0x963b1c86, + (q31_t)0x47c3c22f, (q31_t)0x96029eb6, (q31_t)0x47706d93, (q31_t)0x95ca6247, + (q31_t)0x471cece7, (q31_t)0x9592675c, (q31_t)0x46c9405c, (q31_t)0x955aae17, + (q31_t)0x46756828, (q31_t)0x9523369c, (q31_t)0x4621647d, (q31_t)0x94ec010b, + (q31_t)0x45cd358f, (q31_t)0x94b50d87, (q31_t)0x4578db93, (q31_t)0x947e5c33, + (q31_t)0x452456bd, (q31_t)0x9447ed2f, (q31_t)0x44cfa740, (q31_t)0x9411c09e, + (q31_t)0x447acd50, (q31_t)0x93dbd6a0, (q31_t)0x4425c923, (q31_t)0x93a62f57, + (q31_t)0x43d09aed, (q31_t)0x9370cae4, (q31_t)0x437b42e1, (q31_t)0x933ba968, + (q31_t)0x4325c135, (q31_t)0x9306cb04, (q31_t)0x42d0161e, (q31_t)0x92d22fd9, + (q31_t)0x427a41d0, (q31_t)0x929dd806, (q31_t)0x42244481, (q31_t)0x9269c3ac, + (q31_t)0x41ce1e65, (q31_t)0x9235f2ec, (q31_t)0x4177cfb1, (q31_t)0x920265e4, + (q31_t)0x4121589b, (q31_t)0x91cf1cb6, (q31_t)0x40cab958, (q31_t)0x919c1781, + (q31_t)0x4073f21d, (q31_t)0x91695663, (q31_t)0x401d0321, (q31_t)0x9136d97d, + (q31_t)0x3fc5ec98, (q31_t)0x9104a0ee, (q31_t)0x3f6eaeb8, (q31_t)0x90d2acd4, + (q31_t)0x3f1749b8, (q31_t)0x90a0fd4e, (q31_t)0x3ebfbdcd, (q31_t)0x906f927c, + (q31_t)0x3e680b2c, (q31_t)0x903e6c7b, (q31_t)0x3e10320d, (q31_t)0x900d8b69, + (q31_t)0x3db832a6, (q31_t)0x8fdcef66, (q31_t)0x3d600d2c, (q31_t)0x8fac988f, + (q31_t)0x3d07c1d6, (q31_t)0x8f7c8701, (q31_t)0x3caf50da, (q31_t)0x8f4cbadb, + (q31_t)0x3c56ba70, (q31_t)0x8f1d343a, (q31_t)0x3bfdfecd, (q31_t)0x8eedf33b, + (q31_t)0x3ba51e29, (q31_t)0x8ebef7fb, (q31_t)0x3b4c18ba, (q31_t)0x8e904298, + (q31_t)0x3af2eeb7, (q31_t)0x8e61d32e, (q31_t)0x3a99a057, (q31_t)0x8e33a9da, + (q31_t)0x3a402dd2, (q31_t)0x8e05c6b7, (q31_t)0x39e6975e, (q31_t)0x8dd829e4, + (q31_t)0x398cdd32, (q31_t)0x8daad37b, (q31_t)0x3932ff87, (q31_t)0x8d7dc399, + (q31_t)0x38d8fe93, (q31_t)0x8d50fa59, (q31_t)0x387eda8e, (q31_t)0x8d2477d8, + (q31_t)0x382493b0, (q31_t)0x8cf83c30, (q31_t)0x37ca2a30, (q31_t)0x8ccc477d, + (q31_t)0x376f9e46, (q31_t)0x8ca099da, (q31_t)0x3714f02a, (q31_t)0x8c753362, + (q31_t)0x36ba2014, (q31_t)0x8c4a142f, (q31_t)0x365f2e3b, (q31_t)0x8c1f3c5d, + (q31_t)0x36041ad9, (q31_t)0x8bf4ac05, (q31_t)0x35a8e625, (q31_t)0x8bca6343, + (q31_t)0x354d9057, (q31_t)0x8ba0622f, (q31_t)0x34f219a8, (q31_t)0x8b76a8e4, + (q31_t)0x34968250, (q31_t)0x8b4d377c, (q31_t)0x343aca87, (q31_t)0x8b240e11, + (q31_t)0x33def287, (q31_t)0x8afb2cbb, (q31_t)0x3382fa88, (q31_t)0x8ad29394, + (q31_t)0x3326e2c3, (q31_t)0x8aaa42b4, (q31_t)0x32caab6f, (q31_t)0x8a823a36, + (q31_t)0x326e54c7, (q31_t)0x8a5a7a31, (q31_t)0x3211df04, (q31_t)0x8a3302be, + (q31_t)0x31b54a5e, (q31_t)0x8a0bd3f5, (q31_t)0x3158970e, (q31_t)0x89e4edef, + (q31_t)0x30fbc54d, (q31_t)0x89be50c3, (q31_t)0x309ed556, (q31_t)0x8997fc8a, + (q31_t)0x3041c761, (q31_t)0x8971f15a, (q31_t)0x2fe49ba7, (q31_t)0x894c2f4c, + (q31_t)0x2f875262, (q31_t)0x8926b677, (q31_t)0x2f29ebcc, (q31_t)0x890186f2, + (q31_t)0x2ecc681e, (q31_t)0x88dca0d3, (q31_t)0x2e6ec792, (q31_t)0x88b80432, + (q31_t)0x2e110a62, (q31_t)0x8893b125, (q31_t)0x2db330c7, (q31_t)0x886fa7c2, + (q31_t)0x2d553afc, (q31_t)0x884be821, (q31_t)0x2cf72939, (q31_t)0x88287256, + (q31_t)0x2c98fbba, (q31_t)0x88054677, (q31_t)0x2c3ab2b9, (q31_t)0x87e2649b, + (q31_t)0x2bdc4e6f, (q31_t)0x87bfccd7, (q31_t)0x2b7dcf17, (q31_t)0x879d7f41, + (q31_t)0x2b1f34eb, (q31_t)0x877b7bec, (q31_t)0x2ac08026, (q31_t)0x8759c2ef, + (q31_t)0x2a61b101, (q31_t)0x8738545e, (q31_t)0x2a02c7b8, (q31_t)0x8717304e, + (q31_t)0x29a3c485, (q31_t)0x86f656d3, (q31_t)0x2944a7a2, (q31_t)0x86d5c802, + (q31_t)0x28e5714b, (q31_t)0x86b583ee, (q31_t)0x288621b9, (q31_t)0x86958aac, + (q31_t)0x2826b928, (q31_t)0x8675dc4f, (q31_t)0x27c737d3, (q31_t)0x865678eb, + (q31_t)0x27679df4, (q31_t)0x86376092, (q31_t)0x2707ebc7, (q31_t)0x86189359, + (q31_t)0x26a82186, (q31_t)0x85fa1153, (q31_t)0x26483f6c, (q31_t)0x85dbda91, + (q31_t)0x25e845b6, (q31_t)0x85bdef28, (q31_t)0x2588349d, (q31_t)0x85a04f28, + (q31_t)0x25280c5e, (q31_t)0x8582faa5, (q31_t)0x24c7cd33, (q31_t)0x8565f1b0, + (q31_t)0x24677758, (q31_t)0x8549345c, (q31_t)0x24070b08, (q31_t)0x852cc2bb, + (q31_t)0x23a6887f, (q31_t)0x85109cdd, (q31_t)0x2345eff8, (q31_t)0x84f4c2d4, + (q31_t)0x22e541af, (q31_t)0x84d934b1, (q31_t)0x22847de0, (q31_t)0x84bdf286, + (q31_t)0x2223a4c5, (q31_t)0x84a2fc62, (q31_t)0x21c2b69c, (q31_t)0x84885258, + (q31_t)0x2161b3a0, (q31_t)0x846df477, (q31_t)0x21009c0c, (q31_t)0x8453e2cf, + (q31_t)0x209f701c, (q31_t)0x843a1d70, (q31_t)0x203e300d, (q31_t)0x8420a46c, + (q31_t)0x1fdcdc1b, (q31_t)0x840777d0, (q31_t)0x1f7b7481, (q31_t)0x83ee97ad, + (q31_t)0x1f19f97b, (q31_t)0x83d60412, (q31_t)0x1eb86b46, (q31_t)0x83bdbd0e, + (q31_t)0x1e56ca1e, (q31_t)0x83a5c2b0, (q31_t)0x1df5163f, (q31_t)0x838e1507, + (q31_t)0x1d934fe5, (q31_t)0x8376b422, (q31_t)0x1d31774d, (q31_t)0x835fa00f, + (q31_t)0x1ccf8cb3, (q31_t)0x8348d8dc, (q31_t)0x1c6d9053, (q31_t)0x83325e97, + (q31_t)0x1c0b826a, (q31_t)0x831c314e, (q31_t)0x1ba96335, (q31_t)0x83065110, + (q31_t)0x1b4732ef, (q31_t)0x82f0bde8, (q31_t)0x1ae4f1d6, (q31_t)0x82db77e5, + (q31_t)0x1a82a026, (q31_t)0x82c67f14, (q31_t)0x1a203e1b, (q31_t)0x82b1d381, + (q31_t)0x19bdcbf3, (q31_t)0x829d753a, (q31_t)0x195b49ea, (q31_t)0x8289644b, + (q31_t)0x18f8b83c, (q31_t)0x8275a0c0, (q31_t)0x18961728, (q31_t)0x82622aa6, + (q31_t)0x183366e9, (q31_t)0x824f0208, (q31_t)0x17d0a7bc, (q31_t)0x823c26f3, + (q31_t)0x176dd9de, (q31_t)0x82299971, (q31_t)0x170afd8d, (q31_t)0x82175990, + (q31_t)0x16a81305, (q31_t)0x82056758, (q31_t)0x16451a83, (q31_t)0x81f3c2d7, + (q31_t)0x15e21445, (q31_t)0x81e26c16, (q31_t)0x157f0086, (q31_t)0x81d16321, + (q31_t)0x151bdf86, (q31_t)0x81c0a801, (q31_t)0x14b8b17f, (q31_t)0x81b03ac2, + (q31_t)0x145576b1, (q31_t)0x81a01b6d, (q31_t)0x13f22f58, (q31_t)0x81904a0c, + (q31_t)0x138edbb1, (q31_t)0x8180c6a9, (q31_t)0x132b7bf9, (q31_t)0x8171914e, + (q31_t)0x12c8106f, (q31_t)0x8162aa04, (q31_t)0x1264994e, (q31_t)0x815410d4, + (q31_t)0x120116d5, (q31_t)0x8145c5c7, (q31_t)0x119d8941, (q31_t)0x8137c8e6, + (q31_t)0x1139f0cf, (q31_t)0x812a1a3a, (q31_t)0x10d64dbd, (q31_t)0x811cb9ca, + (q31_t)0x1072a048, (q31_t)0x810fa7a0, (q31_t)0x100ee8ad, (q31_t)0x8102e3c4, + (q31_t)0x0fab272b, (q31_t)0x80f66e3c, (q31_t)0x0f475bff, (q31_t)0x80ea4712, + (q31_t)0x0ee38766, (q31_t)0x80de6e4c, (q31_t)0x0e7fa99e, (q31_t)0x80d2e3f2, + (q31_t)0x0e1bc2e4, (q31_t)0x80c7a80a, (q31_t)0x0db7d376, (q31_t)0x80bcba9d, + (q31_t)0x0d53db92, (q31_t)0x80b21baf, (q31_t)0x0cefdb76, (q31_t)0x80a7cb49, + (q31_t)0x0c8bd35e, (q31_t)0x809dc971, (q31_t)0x0c27c389, (q31_t)0x8094162c, + (q31_t)0x0bc3ac35, (q31_t)0x808ab180, (q31_t)0x0b5f8d9f, (q31_t)0x80819b74, + (q31_t)0x0afb6805, (q31_t)0x8078d40d, (q31_t)0x0a973ba5, (q31_t)0x80705b50, + (q31_t)0x0a3308bd, (q31_t)0x80683143, (q31_t)0x09cecf89, (q31_t)0x806055eb, + (q31_t)0x096a9049, (q31_t)0x8058c94c, (q31_t)0x09064b3a, (q31_t)0x80518b6b, + (q31_t)0x08a2009a, (q31_t)0x804a9c4d, (q31_t)0x083db0a7, (q31_t)0x8043fbf6, + (q31_t)0x07d95b9e, (q31_t)0x803daa6a, (q31_t)0x077501be, (q31_t)0x8037a7ac, + (q31_t)0x0710a345, (q31_t)0x8031f3c2, (q31_t)0x06ac406f, (q31_t)0x802c8ead, + (q31_t)0x0647d97c, (q31_t)0x80277872, (q31_t)0x05e36ea9, (q31_t)0x8022b114, + (q31_t)0x057f0035, (q31_t)0x801e3895, (q31_t)0x051a8e5c, (q31_t)0x801a0ef8, + (q31_t)0x04b6195d, (q31_t)0x80163440, (q31_t)0x0451a177, (q31_t)0x8012a86f, + (q31_t)0x03ed26e6, (q31_t)0x800f6b88, (q31_t)0x0388a9ea, (q31_t)0x800c7d8c, + (q31_t)0x03242abf, (q31_t)0x8009de7e, (q31_t)0x02bfa9a4, (q31_t)0x80078e5e, + (q31_t)0x025b26d7, (q31_t)0x80058d2f, (q31_t)0x01f6a297, (q31_t)0x8003daf1, + (q31_t)0x01921d20, (q31_t)0x800277a6, (q31_t)0x012d96b1, (q31_t)0x8001634e, + (q31_t)0x00c90f88, (q31_t)0x80009dea, (q31_t)0x006487e3, (q31_t)0x8000277a}; static const q31_t WeightsQ31_2048[4096] = { - (q31_t)0x7fffffff, (q31_t)0x00000000, (q31_t)0x7ffffd88, (q31_t)0xffe6de05, (q31_t)0x7ffff621, (q31_t)0xffcdbc0b, (q31_t)0x7fffe9cb, (q31_t)0xffb49a12, - (q31_t)0x7fffd886, (q31_t)0xff9b781d, (q31_t)0x7fffc251, (q31_t)0xff82562c, (q31_t)0x7fffa72c, (q31_t)0xff69343f, (q31_t)0x7fff8719, (q31_t)0xff501258, - (q31_t)0x7fff6216, (q31_t)0xff36f078, (q31_t)0x7fff3824, (q31_t)0xff1dcea0, (q31_t)0x7fff0943, (q31_t)0xff04acd0, (q31_t)0x7ffed572, (q31_t)0xfeeb8b0a, - (q31_t)0x7ffe9cb2, (q31_t)0xfed2694f, (q31_t)0x7ffe5f03, (q31_t)0xfeb947a0, (q31_t)0x7ffe1c65, (q31_t)0xfea025fd, (q31_t)0x7ffdd4d7, (q31_t)0xfe870467, - (q31_t)0x7ffd885a, (q31_t)0xfe6de2e0, (q31_t)0x7ffd36ee, (q31_t)0xfe54c169, (q31_t)0x7ffce093, (q31_t)0xfe3ba002, (q31_t)0x7ffc8549, (q31_t)0xfe227eac, - (q31_t)0x7ffc250f, (q31_t)0xfe095d69, (q31_t)0x7ffbbfe6, (q31_t)0xfdf03c3a, (q31_t)0x7ffb55ce, (q31_t)0xfdd71b1e, (q31_t)0x7ffae6c7, (q31_t)0xfdbdfa18, - (q31_t)0x7ffa72d1, (q31_t)0xfda4d929, (q31_t)0x7ff9f9ec, (q31_t)0xfd8bb850, (q31_t)0x7ff97c18, (q31_t)0xfd729790, (q31_t)0x7ff8f954, (q31_t)0xfd5976e9, - (q31_t)0x7ff871a2, (q31_t)0xfd40565c, (q31_t)0x7ff7e500, (q31_t)0xfd2735ea, (q31_t)0x7ff75370, (q31_t)0xfd0e1594, (q31_t)0x7ff6bcf0, (q31_t)0xfcf4f55c, - (q31_t)0x7ff62182, (q31_t)0xfcdbd541, (q31_t)0x7ff58125, (q31_t)0xfcc2b545, (q31_t)0x7ff4dbd9, (q31_t)0xfca9956a, (q31_t)0x7ff4319d, (q31_t)0xfc9075af, - (q31_t)0x7ff38274, (q31_t)0xfc775616, (q31_t)0x7ff2ce5b, (q31_t)0xfc5e36a0, (q31_t)0x7ff21553, (q31_t)0xfc45174e, (q31_t)0x7ff1575d, (q31_t)0xfc2bf821, - (q31_t)0x7ff09478, (q31_t)0xfc12d91a, (q31_t)0x7fefcca4, (q31_t)0xfbf9ba39, (q31_t)0x7feeffe1, (q31_t)0xfbe09b80, (q31_t)0x7fee2e30, (q31_t)0xfbc77cf0, - (q31_t)0x7fed5791, (q31_t)0xfbae5e89, (q31_t)0x7fec7c02, (q31_t)0xfb95404d, (q31_t)0x7feb9b85, (q31_t)0xfb7c223d, (q31_t)0x7feab61a, (q31_t)0xfb630459, - (q31_t)0x7fe9cbc0, (q31_t)0xfb49e6a3, (q31_t)0x7fe8dc78, (q31_t)0xfb30c91b, (q31_t)0x7fe7e841, (q31_t)0xfb17abc2, (q31_t)0x7fe6ef1c, (q31_t)0xfafe8e9b, - (q31_t)0x7fe5f108, (q31_t)0xfae571a4, (q31_t)0x7fe4ee06, (q31_t)0xfacc54e0, (q31_t)0x7fe3e616, (q31_t)0xfab3384f, (q31_t)0x7fe2d938, (q31_t)0xfa9a1bf3, - (q31_t)0x7fe1c76b, (q31_t)0xfa80ffcb, (q31_t)0x7fe0b0b1, (q31_t)0xfa67e3da, (q31_t)0x7fdf9508, (q31_t)0xfa4ec821, (q31_t)0x7fde7471, (q31_t)0xfa35ac9f, - (q31_t)0x7fdd4eec, (q31_t)0xfa1c9157, (q31_t)0x7fdc247a, (q31_t)0xfa037648, (q31_t)0x7fdaf519, (q31_t)0xf9ea5b75, (q31_t)0x7fd9c0ca, (q31_t)0xf9d140de, - (q31_t)0x7fd8878e, (q31_t)0xf9b82684, (q31_t)0x7fd74964, (q31_t)0xf99f0c68, (q31_t)0x7fd6064c, (q31_t)0xf985f28a, (q31_t)0x7fd4be46, (q31_t)0xf96cd8ed, - (q31_t)0x7fd37153, (q31_t)0xf953bf91, (q31_t)0x7fd21f72, (q31_t)0xf93aa676, (q31_t)0x7fd0c8a3, (q31_t)0xf9218d9e, (q31_t)0x7fcf6ce8, (q31_t)0xf908750a, - (q31_t)0x7fce0c3e, (q31_t)0xf8ef5cbb, (q31_t)0x7fcca6a7, (q31_t)0xf8d644b2, (q31_t)0x7fcb3c23, (q31_t)0xf8bd2cef, (q31_t)0x7fc9ccb2, (q31_t)0xf8a41574, - (q31_t)0x7fc85854, (q31_t)0xf88afe42, (q31_t)0x7fc6df08, (q31_t)0xf871e759, (q31_t)0x7fc560cf, (q31_t)0xf858d0bb, (q31_t)0x7fc3dda9, (q31_t)0xf83fba68, - (q31_t)0x7fc25596, (q31_t)0xf826a462, (q31_t)0x7fc0c896, (q31_t)0xf80d8ea9, (q31_t)0x7fbf36aa, (q31_t)0xf7f4793e, (q31_t)0x7fbd9fd0, (q31_t)0xf7db6423, - (q31_t)0x7fbc040a, (q31_t)0xf7c24f59, (q31_t)0x7fba6357, (q31_t)0xf7a93ae0, (q31_t)0x7fb8bdb8, (q31_t)0xf79026b9, (q31_t)0x7fb7132b, (q31_t)0xf77712e5, - (q31_t)0x7fb563b3, (q31_t)0xf75dff66, (q31_t)0x7fb3af4e, (q31_t)0xf744ec3b, (q31_t)0x7fb1f5fc, (q31_t)0xf72bd967, (q31_t)0x7fb037bf, (q31_t)0xf712c6ea, - (q31_t)0x7fae7495, (q31_t)0xf6f9b4c6, (q31_t)0x7facac7f, (q31_t)0xf6e0a2fa, (q31_t)0x7faadf7c, (q31_t)0xf6c79188, (q31_t)0x7fa90d8e, (q31_t)0xf6ae8071, - (q31_t)0x7fa736b4, (q31_t)0xf6956fb7, (q31_t)0x7fa55aee, (q31_t)0xf67c5f59, (q31_t)0x7fa37a3c, (q31_t)0xf6634f59, (q31_t)0x7fa1949e, (q31_t)0xf64a3fb8, - (q31_t)0x7f9faa15, (q31_t)0xf6313077, (q31_t)0x7f9dbaa0, (q31_t)0xf6182196, (q31_t)0x7f9bc640, (q31_t)0xf5ff1318, (q31_t)0x7f99ccf4, (q31_t)0xf5e604fc, - (q31_t)0x7f97cebd, (q31_t)0xf5ccf743, (q31_t)0x7f95cb9a, (q31_t)0xf5b3e9f0, (q31_t)0x7f93c38c, (q31_t)0xf59add02, (q31_t)0x7f91b694, (q31_t)0xf581d07b, - (q31_t)0x7f8fa4b0, (q31_t)0xf568c45b, (q31_t)0x7f8d8de1, (q31_t)0xf54fb8a4, (q31_t)0x7f8b7227, (q31_t)0xf536ad56, (q31_t)0x7f895182, (q31_t)0xf51da273, - (q31_t)0x7f872bf3, (q31_t)0xf50497fb, (q31_t)0x7f850179, (q31_t)0xf4eb8def, (q31_t)0x7f82d214, (q31_t)0xf4d28451, (q31_t)0x7f809dc5, (q31_t)0xf4b97b21, - (q31_t)0x7f7e648c, (q31_t)0xf4a07261, (q31_t)0x7f7c2668, (q31_t)0xf4876a10, (q31_t)0x7f79e35a, (q31_t)0xf46e6231, (q31_t)0x7f779b62, (q31_t)0xf4555ac5, - (q31_t)0x7f754e80, (q31_t)0xf43c53cb, (q31_t)0x7f72fcb4, (q31_t)0xf4234d45, (q31_t)0x7f70a5fe, (q31_t)0xf40a4735, (q31_t)0x7f6e4a5e, (q31_t)0xf3f1419a, - (q31_t)0x7f6be9d4, (q31_t)0xf3d83c77, (q31_t)0x7f698461, (q31_t)0xf3bf37cb, (q31_t)0x7f671a05, (q31_t)0xf3a63398, (q31_t)0x7f64aabf, (q31_t)0xf38d2fe0, - (q31_t)0x7f62368f, (q31_t)0xf3742ca2, (q31_t)0x7f5fbd77, (q31_t)0xf35b29e0, (q31_t)0x7f5d3f75, (q31_t)0xf342279b, (q31_t)0x7f5abc8a, (q31_t)0xf32925d3, - (q31_t)0x7f5834b7, (q31_t)0xf310248a, (q31_t)0x7f55a7fa, (q31_t)0xf2f723c1, (q31_t)0x7f531655, (q31_t)0xf2de2379, (q31_t)0x7f507fc7, (q31_t)0xf2c523b2, - (q31_t)0x7f4de451, (q31_t)0xf2ac246e, (q31_t)0x7f4b43f2, (q31_t)0xf29325ad, (q31_t)0x7f489eaa, (q31_t)0xf27a2771, (q31_t)0x7f45f47b, (q31_t)0xf26129ba, - (q31_t)0x7f434563, (q31_t)0xf2482c8a, (q31_t)0x7f409164, (q31_t)0xf22f2fe1, (q31_t)0x7f3dd87c, (q31_t)0xf21633c0, (q31_t)0x7f3b1aad, (q31_t)0xf1fd3829, - (q31_t)0x7f3857f6, (q31_t)0xf1e43d1c, (q31_t)0x7f359057, (q31_t)0xf1cb429a, (q31_t)0x7f32c3d1, (q31_t)0xf1b248a5, (q31_t)0x7f2ff263, (q31_t)0xf1994f3d, - (q31_t)0x7f2d1c0e, (q31_t)0xf1805662, (q31_t)0x7f2a40d2, (q31_t)0xf1675e17, (q31_t)0x7f2760af, (q31_t)0xf14e665c, (q31_t)0x7f247ba5, (q31_t)0xf1356f32, - (q31_t)0x7f2191b4, (q31_t)0xf11c789a, (q31_t)0x7f1ea2dc, (q31_t)0xf1038295, (q31_t)0x7f1baf1e, (q31_t)0xf0ea8d24, (q31_t)0x7f18b679, (q31_t)0xf0d19848, - (q31_t)0x7f15b8ee, (q31_t)0xf0b8a401, (q31_t)0x7f12b67c, (q31_t)0xf09fb051, (q31_t)0x7f0faf25, (q31_t)0xf086bd39, (q31_t)0x7f0ca2e7, (q31_t)0xf06dcaba, - (q31_t)0x7f0991c4, (q31_t)0xf054d8d5, (q31_t)0x7f067bba, (q31_t)0xf03be78a, (q31_t)0x7f0360cb, (q31_t)0xf022f6da, (q31_t)0x7f0040f6, (q31_t)0xf00a06c8, - (q31_t)0x7efd1c3c, (q31_t)0xeff11753, (q31_t)0x7ef9f29d, (q31_t)0xefd8287c, (q31_t)0x7ef6c418, (q31_t)0xefbf3a45, (q31_t)0x7ef390ae, (q31_t)0xefa64cae, - (q31_t)0x7ef05860, (q31_t)0xef8d5fb8, (q31_t)0x7eed1b2c, (q31_t)0xef747365, (q31_t)0x7ee9d914, (q31_t)0xef5b87b5, (q31_t)0x7ee69217, (q31_t)0xef429caa, - (q31_t)0x7ee34636, (q31_t)0xef29b243, (q31_t)0x7edff570, (q31_t)0xef10c883, (q31_t)0x7edc9fc6, (q31_t)0xeef7df6a, (q31_t)0x7ed94538, (q31_t)0xeedef6f9, - (q31_t)0x7ed5e5c6, (q31_t)0xeec60f31, (q31_t)0x7ed28171, (q31_t)0xeead2813, (q31_t)0x7ecf1837, (q31_t)0xee9441a0, (q31_t)0x7ecbaa1a, (q31_t)0xee7b5bd9, - (q31_t)0x7ec8371a, (q31_t)0xee6276bf, (q31_t)0x7ec4bf36, (q31_t)0xee499253, (q31_t)0x7ec14270, (q31_t)0xee30ae96, (q31_t)0x7ebdc0c6, (q31_t)0xee17cb88, - (q31_t)0x7eba3a39, (q31_t)0xedfee92b, (q31_t)0x7eb6aeca, (q31_t)0xede60780, (q31_t)0x7eb31e78, (q31_t)0xedcd2687, (q31_t)0x7eaf8943, (q31_t)0xedb44642, - (q31_t)0x7eabef2c, (q31_t)0xed9b66b2, (q31_t)0x7ea85033, (q31_t)0xed8287d7, (q31_t)0x7ea4ac58, (q31_t)0xed69a9b3, (q31_t)0x7ea1039b, (q31_t)0xed50cc46, - (q31_t)0x7e9d55fc, (q31_t)0xed37ef91, (q31_t)0x7e99a37c, (q31_t)0xed1f1396, (q31_t)0x7e95ec1a, (q31_t)0xed063856, (q31_t)0x7e922fd6, (q31_t)0xeced5dd0, - (q31_t)0x7e8e6eb2, (q31_t)0xecd48407, (q31_t)0x7e8aa8ac, (q31_t)0xecbbaafb, (q31_t)0x7e86ddc6, (q31_t)0xeca2d2ad, (q31_t)0x7e830dff, (q31_t)0xec89fb1e, - (q31_t)0x7e7f3957, (q31_t)0xec71244f, (q31_t)0x7e7b5fce, (q31_t)0xec584e41, (q31_t)0x7e778166, (q31_t)0xec3f78f6, (q31_t)0x7e739e1d, (q31_t)0xec26a46d, - (q31_t)0x7e6fb5f4, (q31_t)0xec0dd0a8, (q31_t)0x7e6bc8eb, (q31_t)0xebf4fda8, (q31_t)0x7e67d703, (q31_t)0xebdc2b6e, (q31_t)0x7e63e03b, (q31_t)0xebc359fb, - (q31_t)0x7e5fe493, (q31_t)0xebaa894f, (q31_t)0x7e5be40c, (q31_t)0xeb91b96c, (q31_t)0x7e57dea7, (q31_t)0xeb78ea52, (q31_t)0x7e53d462, (q31_t)0xeb601c04, - (q31_t)0x7e4fc53e, (q31_t)0xeb474e81, (q31_t)0x7e4bb13c, (q31_t)0xeb2e81ca, (q31_t)0x7e47985b, (q31_t)0xeb15b5e1, (q31_t)0x7e437a9c, (q31_t)0xeafceac6, - (q31_t)0x7e3f57ff, (q31_t)0xeae4207a, (q31_t)0x7e3b3083, (q31_t)0xeacb56ff, (q31_t)0x7e37042a, (q31_t)0xeab28e56, (q31_t)0x7e32d2f4, (q31_t)0xea99c67e, - (q31_t)0x7e2e9cdf, (q31_t)0xea80ff7a, (q31_t)0x7e2a61ed, (q31_t)0xea683949, (q31_t)0x7e26221f, (q31_t)0xea4f73ee, (q31_t)0x7e21dd73, (q31_t)0xea36af69, - (q31_t)0x7e1d93ea, (q31_t)0xea1debbb, (q31_t)0x7e194584, (q31_t)0xea0528e5, (q31_t)0x7e14f242, (q31_t)0xe9ec66e8, (q31_t)0x7e109a24, (q31_t)0xe9d3a5c5, - (q31_t)0x7e0c3d29, (q31_t)0xe9bae57d, (q31_t)0x7e07db52, (q31_t)0xe9a22610, (q31_t)0x7e0374a0, (q31_t)0xe9896781, (q31_t)0x7dff0911, (q31_t)0xe970a9ce, - (q31_t)0x7dfa98a8, (q31_t)0xe957ecfb, (q31_t)0x7df62362, (q31_t)0xe93f3107, (q31_t)0x7df1a942, (q31_t)0xe92675f4, (q31_t)0x7ded2a47, (q31_t)0xe90dbbc2, - (q31_t)0x7de8a670, (q31_t)0xe8f50273, (q31_t)0x7de41dc0, (q31_t)0xe8dc4a07, (q31_t)0x7ddf9034, (q31_t)0xe8c39280, (q31_t)0x7ddafdce, (q31_t)0xe8aadbde, - (q31_t)0x7dd6668f, (q31_t)0xe8922622, (q31_t)0x7dd1ca75, (q31_t)0xe879714d, (q31_t)0x7dcd2981, (q31_t)0xe860bd61, (q31_t)0x7dc883b4, (q31_t)0xe8480a5d, - (q31_t)0x7dc3d90d, (q31_t)0xe82f5844, (q31_t)0x7dbf298d, (q31_t)0xe816a716, (q31_t)0x7dba7534, (q31_t)0xe7fdf6d4, (q31_t)0x7db5bc02, (q31_t)0xe7e5477f, - (q31_t)0x7db0fdf8, (q31_t)0xe7cc9917, (q31_t)0x7dac3b15, (q31_t)0xe7b3eb9f, (q31_t)0x7da77359, (q31_t)0xe79b3f16, (q31_t)0x7da2a6c6, (q31_t)0xe782937e, - (q31_t)0x7d9dd55a, (q31_t)0xe769e8d8, (q31_t)0x7d98ff17, (q31_t)0xe7513f25, (q31_t)0x7d9423fc, (q31_t)0xe7389665, (q31_t)0x7d8f4409, (q31_t)0xe71fee99, - (q31_t)0x7d8a5f40, (q31_t)0xe70747c4, (q31_t)0x7d85759f, (q31_t)0xe6eea1e4, (q31_t)0x7d808728, (q31_t)0xe6d5fcfc, (q31_t)0x7d7b93da, (q31_t)0xe6bd590d, - (q31_t)0x7d769bb5, (q31_t)0xe6a4b616, (q31_t)0x7d719eba, (q31_t)0xe68c141a, (q31_t)0x7d6c9ce9, (q31_t)0xe6737319, (q31_t)0x7d679642, (q31_t)0xe65ad315, - (q31_t)0x7d628ac6, (q31_t)0xe642340d, (q31_t)0x7d5d7a74, (q31_t)0xe6299604, (q31_t)0x7d58654d, (q31_t)0xe610f8f9, (q31_t)0x7d534b50, (q31_t)0xe5f85cef, - (q31_t)0x7d4e2c7f, (q31_t)0xe5dfc1e5, (q31_t)0x7d4908d9, (q31_t)0xe5c727dd, (q31_t)0x7d43e05e, (q31_t)0xe5ae8ed8, (q31_t)0x7d3eb30f, (q31_t)0xe595f6d7, - (q31_t)0x7d3980ec, (q31_t)0xe57d5fda, (q31_t)0x7d3449f5, (q31_t)0xe564c9e3, (q31_t)0x7d2f0e2b, (q31_t)0xe54c34f3, (q31_t)0x7d29cd8c, (q31_t)0xe533a10a, - (q31_t)0x7d24881b, (q31_t)0xe51b0e2a, (q31_t)0x7d1f3dd6, (q31_t)0xe5027c53, (q31_t)0x7d19eebf, (q31_t)0xe4e9eb87, (q31_t)0x7d149ad5, (q31_t)0xe4d15bc6, - (q31_t)0x7d0f4218, (q31_t)0xe4b8cd11, (q31_t)0x7d09e489, (q31_t)0xe4a03f69, (q31_t)0x7d048228, (q31_t)0xe487b2d0, (q31_t)0x7cff1af5, (q31_t)0xe46f2745, - (q31_t)0x7cf9aef0, (q31_t)0xe4569ccb, (q31_t)0x7cf43e1a, (q31_t)0xe43e1362, (q31_t)0x7ceec873, (q31_t)0xe4258b0a, (q31_t)0x7ce94dfb, (q31_t)0xe40d03c6, - (q31_t)0x7ce3ceb2, (q31_t)0xe3f47d96, (q31_t)0x7cde4a98, (q31_t)0xe3dbf87a, (q31_t)0x7cd8c1ae, (q31_t)0xe3c37474, (q31_t)0x7cd333f3, (q31_t)0xe3aaf184, - (q31_t)0x7ccda169, (q31_t)0xe3926fad, (q31_t)0x7cc80a0f, (q31_t)0xe379eeed, (q31_t)0x7cc26de5, (q31_t)0xe3616f48, (q31_t)0x7cbcccec, (q31_t)0xe348f0bd, - (q31_t)0x7cb72724, (q31_t)0xe330734d, (q31_t)0x7cb17c8d, (q31_t)0xe317f6fa, (q31_t)0x7cabcd28, (q31_t)0xe2ff7bc3, (q31_t)0x7ca618f3, (q31_t)0xe2e701ac, - (q31_t)0x7ca05ff1, (q31_t)0xe2ce88b3, (q31_t)0x7c9aa221, (q31_t)0xe2b610da, (q31_t)0x7c94df83, (q31_t)0xe29d9a23, (q31_t)0x7c8f1817, (q31_t)0xe285248d, - (q31_t)0x7c894bde, (q31_t)0xe26cb01b, (q31_t)0x7c837ad8, (q31_t)0xe2543ccc, (q31_t)0x7c7da505, (q31_t)0xe23bcaa2, (q31_t)0x7c77ca65, (q31_t)0xe223599e, - (q31_t)0x7c71eaf9, (q31_t)0xe20ae9c1, (q31_t)0x7c6c06c0, (q31_t)0xe1f27b0b, (q31_t)0x7c661dbc, (q31_t)0xe1da0d7e, (q31_t)0x7c602fec, (q31_t)0xe1c1a11b, - (q31_t)0x7c5a3d50, (q31_t)0xe1a935e2, (q31_t)0x7c5445e9, (q31_t)0xe190cbd4, (q31_t)0x7c4e49b7, (q31_t)0xe17862f3, (q31_t)0x7c4848ba, (q31_t)0xe15ffb3f, - (q31_t)0x7c4242f2, (q31_t)0xe14794ba, (q31_t)0x7c3c3860, (q31_t)0xe12f2f63, (q31_t)0x7c362904, (q31_t)0xe116cb3d, (q31_t)0x7c3014de, (q31_t)0xe0fe6848, - (q31_t)0x7c29fbee, (q31_t)0xe0e60685, (q31_t)0x7c23de35, (q31_t)0xe0cda5f5, (q31_t)0x7c1dbbb3, (q31_t)0xe0b54698, (q31_t)0x7c179467, (q31_t)0xe09ce871, - (q31_t)0x7c116853, (q31_t)0xe0848b7f, (q31_t)0x7c0b3777, (q31_t)0xe06c2fc4, (q31_t)0x7c0501d2, (q31_t)0xe053d541, (q31_t)0x7bfec765, (q31_t)0xe03b7bf6, - (q31_t)0x7bf88830, (q31_t)0xe02323e5, (q31_t)0x7bf24434, (q31_t)0xe00acd0e, (q31_t)0x7bebfb70, (q31_t)0xdff27773, (q31_t)0x7be5ade6, (q31_t)0xdfda2314, - (q31_t)0x7bdf5b94, (q31_t)0xdfc1cff3, (q31_t)0x7bd9047c, (q31_t)0xdfa97e0f, (q31_t)0x7bd2a89e, (q31_t)0xdf912d6b, (q31_t)0x7bcc47fa, (q31_t)0xdf78de07, - (q31_t)0x7bc5e290, (q31_t)0xdf608fe4, (q31_t)0x7bbf7860, (q31_t)0xdf484302, (q31_t)0x7bb9096b, (q31_t)0xdf2ff764, (q31_t)0x7bb295b0, (q31_t)0xdf17ad0a, - (q31_t)0x7bac1d31, (q31_t)0xdeff63f4, (q31_t)0x7ba59fee, (q31_t)0xdee71c24, (q31_t)0x7b9f1de6, (q31_t)0xdeced59b, (q31_t)0x7b989719, (q31_t)0xdeb69059, - (q31_t)0x7b920b89, (q31_t)0xde9e4c60, (q31_t)0x7b8b7b36, (q31_t)0xde8609b1, (q31_t)0x7b84e61f, (q31_t)0xde6dc84b, (q31_t)0x7b7e4c45, (q31_t)0xde558831, - (q31_t)0x7b77ada8, (q31_t)0xde3d4964, (q31_t)0x7b710a49, (q31_t)0xde250be3, (q31_t)0x7b6a6227, (q31_t)0xde0ccfb1, (q31_t)0x7b63b543, (q31_t)0xddf494ce, - (q31_t)0x7b5d039e, (q31_t)0xdddc5b3b, (q31_t)0x7b564d36, (q31_t)0xddc422f8, (q31_t)0x7b4f920e, (q31_t)0xddabec08, (q31_t)0x7b48d225, (q31_t)0xdd93b66a, - (q31_t)0x7b420d7a, (q31_t)0xdd7b8220, (q31_t)0x7b3b4410, (q31_t)0xdd634f2b, (q31_t)0x7b3475e5, (q31_t)0xdd4b1d8c, (q31_t)0x7b2da2fa, (q31_t)0xdd32ed43, - (q31_t)0x7b26cb4f, (q31_t)0xdd1abe51, (q31_t)0x7b1feee5, (q31_t)0xdd0290b8, (q31_t)0x7b190dbc, (q31_t)0xdcea6478, (q31_t)0x7b1227d3, (q31_t)0xdcd23993, - (q31_t)0x7b0b3d2c, (q31_t)0xdcba1008, (q31_t)0x7b044dc7, (q31_t)0xdca1e7da, (q31_t)0x7afd59a4, (q31_t)0xdc89c109, (q31_t)0x7af660c2, (q31_t)0xdc719b96, - (q31_t)0x7aef6323, (q31_t)0xdc597781, (q31_t)0x7ae860c7, (q31_t)0xdc4154cd, (q31_t)0x7ae159ae, (q31_t)0xdc293379, (q31_t)0x7ada4dd8, (q31_t)0xdc111388, - (q31_t)0x7ad33d45, (q31_t)0xdbf8f4f8, (q31_t)0x7acc27f7, (q31_t)0xdbe0d7cd, (q31_t)0x7ac50dec, (q31_t)0xdbc8bc06, (q31_t)0x7abdef25, (q31_t)0xdbb0a1a4, - (q31_t)0x7ab6cba4, (q31_t)0xdb9888a8, (q31_t)0x7aafa367, (q31_t)0xdb807114, (q31_t)0x7aa8766f, (q31_t)0xdb685ae9, (q31_t)0x7aa144bc, (q31_t)0xdb504626, - (q31_t)0x7a9a0e50, (q31_t)0xdb3832cd, (q31_t)0x7a92d329, (q31_t)0xdb2020e0, (q31_t)0x7a8b9348, (q31_t)0xdb08105e, (q31_t)0x7a844eae, (q31_t)0xdaf00149, - (q31_t)0x7a7d055b, (q31_t)0xdad7f3a2, (q31_t)0x7a75b74f, (q31_t)0xdabfe76a, (q31_t)0x7a6e648a, (q31_t)0xdaa7dca1, (q31_t)0x7a670d0d, (q31_t)0xda8fd349, - (q31_t)0x7a5fb0d8, (q31_t)0xda77cb63, (q31_t)0x7a584feb, (q31_t)0xda5fc4ef, (q31_t)0x7a50ea47, (q31_t)0xda47bfee, (q31_t)0x7a497feb, (q31_t)0xda2fbc61, - (q31_t)0x7a4210d8, (q31_t)0xda17ba4a, (q31_t)0x7a3a9d0f, (q31_t)0xd9ffb9a9, (q31_t)0x7a332490, (q31_t)0xd9e7ba7f, (q31_t)0x7a2ba75a, (q31_t)0xd9cfbccd, - (q31_t)0x7a24256f, (q31_t)0xd9b7c094, (q31_t)0x7a1c9ece, (q31_t)0xd99fc5d4, (q31_t)0x7a151378, (q31_t)0xd987cc90, (q31_t)0x7a0d836d, (q31_t)0xd96fd4c7, - (q31_t)0x7a05eead, (q31_t)0xd957de7a, (q31_t)0x79fe5539, (q31_t)0xd93fe9ab, (q31_t)0x79f6b711, (q31_t)0xd927f65b, (q31_t)0x79ef1436, (q31_t)0xd910048a, - (q31_t)0x79e76ca7, (q31_t)0xd8f81439, (q31_t)0x79dfc064, (q31_t)0xd8e0256a, (q31_t)0x79d80f6f, (q31_t)0xd8c8381d, (q31_t)0x79d059c8, (q31_t)0xd8b04c52, - (q31_t)0x79c89f6e, (q31_t)0xd898620c, (q31_t)0x79c0e062, (q31_t)0xd880794b, (q31_t)0x79b91ca4, (q31_t)0xd868920f, (q31_t)0x79b15435, (q31_t)0xd850ac5a, - (q31_t)0x79a98715, (q31_t)0xd838c82d, (q31_t)0x79a1b545, (q31_t)0xd820e589, (q31_t)0x7999dec4, (q31_t)0xd809046e, (q31_t)0x79920392, (q31_t)0xd7f124dd, - (q31_t)0x798a23b1, (q31_t)0xd7d946d8, (q31_t)0x79823f20, (q31_t)0xd7c16a5f, (q31_t)0x797a55e0, (q31_t)0xd7a98f73, (q31_t)0x797267f2, (q31_t)0xd791b616, - (q31_t)0x796a7554, (q31_t)0xd779de47, (q31_t)0x79627e08, (q31_t)0xd7620808, (q31_t)0x795a820e, (q31_t)0xd74a335b, (q31_t)0x79528167, (q31_t)0xd732603f, - (q31_t)0x794a7c12, (q31_t)0xd71a8eb5, (q31_t)0x79427210, (q31_t)0xd702bec0, (q31_t)0x793a6361, (q31_t)0xd6eaf05f, (q31_t)0x79325006, (q31_t)0xd6d32393, - (q31_t)0x792a37fe, (q31_t)0xd6bb585e, (q31_t)0x79221b4b, (q31_t)0xd6a38ec0, (q31_t)0x7919f9ec, (q31_t)0xd68bc6ba, (q31_t)0x7911d3e2, (q31_t)0xd674004e, - (q31_t)0x7909a92d, (q31_t)0xd65c3b7b, (q31_t)0x790179cd, (q31_t)0xd6447844, (q31_t)0x78f945c3, (q31_t)0xd62cb6a8, (q31_t)0x78f10d0f, (q31_t)0xd614f6a9, - (q31_t)0x78e8cfb2, (q31_t)0xd5fd3848, (q31_t)0x78e08dab, (q31_t)0xd5e57b85, (q31_t)0x78d846fb, (q31_t)0xd5cdc062, (q31_t)0x78cffba3, (q31_t)0xd5b606e0, - (q31_t)0x78c7aba2, (q31_t)0xd59e4eff, (q31_t)0x78bf56f9, (q31_t)0xd58698c0, (q31_t)0x78b6fda8, (q31_t)0xd56ee424, (q31_t)0x78ae9fb0, (q31_t)0xd557312d, - (q31_t)0x78a63d11, (q31_t)0xd53f7fda, (q31_t)0x789dd5cb, (q31_t)0xd527d02e, (q31_t)0x789569df, (q31_t)0xd5102228, (q31_t)0x788cf94c, (q31_t)0xd4f875ca, - (q31_t)0x78848414, (q31_t)0xd4e0cb15, (q31_t)0x787c0a36, (q31_t)0xd4c92209, (q31_t)0x78738bb3, (q31_t)0xd4b17aa8, (q31_t)0x786b088c, (q31_t)0xd499d4f2, - (q31_t)0x786280bf, (q31_t)0xd48230e9, (q31_t)0x7859f44f, (q31_t)0xd46a8e8d, (q31_t)0x7851633b, (q31_t)0xd452eddf, (q31_t)0x7848cd83, (q31_t)0xd43b4ee0, - (q31_t)0x78403329, (q31_t)0xd423b191, (q31_t)0x7837942b, (q31_t)0xd40c15f3, (q31_t)0x782ef08b, (q31_t)0xd3f47c06, (q31_t)0x78264849, (q31_t)0xd3dce3cd, - (q31_t)0x781d9b65, (q31_t)0xd3c54d47, (q31_t)0x7814e9df, (q31_t)0xd3adb876, (q31_t)0x780c33b8, (q31_t)0xd396255a, (q31_t)0x780378f1, (q31_t)0xd37e93f4, - (q31_t)0x77fab989, (q31_t)0xd3670446, (q31_t)0x77f1f581, (q31_t)0xd34f764f, (q31_t)0x77e92cd9, (q31_t)0xd337ea12, (q31_t)0x77e05f91, (q31_t)0xd3205f8f, - (q31_t)0x77d78daa, (q31_t)0xd308d6c7, (q31_t)0x77ceb725, (q31_t)0xd2f14fba, (q31_t)0x77c5dc01, (q31_t)0xd2d9ca6a, (q31_t)0x77bcfc3f, (q31_t)0xd2c246d8, - (q31_t)0x77b417df, (q31_t)0xd2aac504, (q31_t)0x77ab2ee2, (q31_t)0xd29344f0, (q31_t)0x77a24148, (q31_t)0xd27bc69c, (q31_t)0x77994f11, (q31_t)0xd2644a0a, - (q31_t)0x7790583e, (q31_t)0xd24ccf39, (q31_t)0x77875cce, (q31_t)0xd235562b, (q31_t)0x777e5cc3, (q31_t)0xd21ddee2, (q31_t)0x7775581d, (q31_t)0xd206695d, - (q31_t)0x776c4edb, (q31_t)0xd1eef59e, (q31_t)0x776340ff, (q31_t)0xd1d783a6, (q31_t)0x775a2e89, (q31_t)0xd1c01375, (q31_t)0x77511778, (q31_t)0xd1a8a50d, - (q31_t)0x7747fbce, (q31_t)0xd191386e, (q31_t)0x773edb8b, (q31_t)0xd179cd99, (q31_t)0x7735b6af, (q31_t)0xd1626490, (q31_t)0x772c8d3a, (q31_t)0xd14afd52, - (q31_t)0x77235f2d, (q31_t)0xd13397e2, (q31_t)0x771a2c88, (q31_t)0xd11c343f, (q31_t)0x7710f54c, (q31_t)0xd104d26b, (q31_t)0x7707b979, (q31_t)0xd0ed7267, - (q31_t)0x76fe790e, (q31_t)0xd0d61434, (q31_t)0x76f5340e, (q31_t)0xd0beb7d2, (q31_t)0x76ebea77, (q31_t)0xd0a75d42, (q31_t)0x76e29c4b, (q31_t)0xd0900486, - (q31_t)0x76d94989, (q31_t)0xd078ad9e, (q31_t)0x76cff232, (q31_t)0xd061588b, (q31_t)0x76c69647, (q31_t)0xd04a054e, (q31_t)0x76bd35c7, (q31_t)0xd032b3e7, - (q31_t)0x76b3d0b4, (q31_t)0xd01b6459, (q31_t)0x76aa670d, (q31_t)0xd00416a3, (q31_t)0x76a0f8d2, (q31_t)0xcfeccac7, (q31_t)0x76978605, (q31_t)0xcfd580c6, - (q31_t)0x768e0ea6, (q31_t)0xcfbe389f, (q31_t)0x768492b4, (q31_t)0xcfa6f255, (q31_t)0x767b1231, (q31_t)0xcf8fade9, (q31_t)0x76718d1c, (q31_t)0xcf786b5a, - (q31_t)0x76680376, (q31_t)0xcf612aaa, (q31_t)0x765e7540, (q31_t)0xcf49ebda, (q31_t)0x7654e279, (q31_t)0xcf32aeeb, (q31_t)0x764b4b23, (q31_t)0xcf1b73de, - (q31_t)0x7641af3d, (q31_t)0xcf043ab3, (q31_t)0x76380ec8, (q31_t)0xceed036b, (q31_t)0x762e69c4, (q31_t)0xced5ce08, (q31_t)0x7624c031, (q31_t)0xcebe9a8a, - (q31_t)0x761b1211, (q31_t)0xcea768f2, (q31_t)0x76115f63, (q31_t)0xce903942, (q31_t)0x7607a828, (q31_t)0xce790b79, (q31_t)0x75fdec60, (q31_t)0xce61df99, - (q31_t)0x75f42c0b, (q31_t)0xce4ab5a2, (q31_t)0x75ea672a, (q31_t)0xce338d97, (q31_t)0x75e09dbd, (q31_t)0xce1c6777, (q31_t)0x75d6cfc5, (q31_t)0xce054343, - (q31_t)0x75ccfd42, (q31_t)0xcdee20fc, (q31_t)0x75c32634, (q31_t)0xcdd700a4, (q31_t)0x75b94a9c, (q31_t)0xcdbfe23a, (q31_t)0x75af6a7b, (q31_t)0xcda8c5c1, - (q31_t)0x75a585cf, (q31_t)0xcd91ab39, (q31_t)0x759b9c9b, (q31_t)0xcd7a92a2, (q31_t)0x7591aedd, (q31_t)0xcd637bfe, (q31_t)0x7587bc98, (q31_t)0xcd4c674d, - (q31_t)0x757dc5ca, (q31_t)0xcd355491, (q31_t)0x7573ca75, (q31_t)0xcd1e43ca, (q31_t)0x7569ca99, (q31_t)0xcd0734f9, (q31_t)0x755fc635, (q31_t)0xccf0281f, - (q31_t)0x7555bd4c, (q31_t)0xccd91d3d, (q31_t)0x754bafdc, (q31_t)0xccc21455, (q31_t)0x75419de7, (q31_t)0xccab0d65, (q31_t)0x7537876c, (q31_t)0xcc940871, - (q31_t)0x752d6c6c, (q31_t)0xcc7d0578, (q31_t)0x75234ce8, (q31_t)0xcc66047b, (q31_t)0x751928e0, (q31_t)0xcc4f057c, (q31_t)0x750f0054, (q31_t)0xcc38087b, - (q31_t)0x7504d345, (q31_t)0xcc210d79, (q31_t)0x74faa1b3, (q31_t)0xcc0a1477, (q31_t)0x74f06b9e, (q31_t)0xcbf31d75, (q31_t)0x74e63108, (q31_t)0xcbdc2876, - (q31_t)0x74dbf1ef, (q31_t)0xcbc53579, (q31_t)0x74d1ae55, (q31_t)0xcbae447f, (q31_t)0x74c7663a, (q31_t)0xcb97558a, (q31_t)0x74bd199f, (q31_t)0xcb80689a, - (q31_t)0x74b2c884, (q31_t)0xcb697db0, (q31_t)0x74a872e8, (q31_t)0xcb5294ce, (q31_t)0x749e18cd, (q31_t)0xcb3badf3, (q31_t)0x7493ba34, (q31_t)0xcb24c921, - (q31_t)0x7489571c, (q31_t)0xcb0de658, (q31_t)0x747eef85, (q31_t)0xcaf7059a, (q31_t)0x74748371, (q31_t)0xcae026e8, (q31_t)0x746a12df, (q31_t)0xcac94a42, - (q31_t)0x745f9dd1, (q31_t)0xcab26fa9, (q31_t)0x74552446, (q31_t)0xca9b971e, (q31_t)0x744aa63f, (q31_t)0xca84c0a3, (q31_t)0x744023bc, (q31_t)0xca6dec37, - (q31_t)0x74359cbd, (q31_t)0xca5719db, (q31_t)0x742b1144, (q31_t)0xca404992, (q31_t)0x74208150, (q31_t)0xca297b5a, (q31_t)0x7415ece2, (q31_t)0xca12af37, - (q31_t)0x740b53fb, (q31_t)0xc9fbe527, (q31_t)0x7400b69a, (q31_t)0xc9e51d2d, (q31_t)0x73f614c0, (q31_t)0xc9ce5748, (q31_t)0x73eb6e6e, (q31_t)0xc9b7937a, - (q31_t)0x73e0c3a3, (q31_t)0xc9a0d1c5, (q31_t)0x73d61461, (q31_t)0xc98a1227, (q31_t)0x73cb60a8, (q31_t)0xc97354a4, (q31_t)0x73c0a878, (q31_t)0xc95c993a, - (q31_t)0x73b5ebd1, (q31_t)0xc945dfec, (q31_t)0x73ab2ab4, (q31_t)0xc92f28ba, (q31_t)0x73a06522, (q31_t)0xc91873a5, (q31_t)0x73959b1b, (q31_t)0xc901c0ae, - (q31_t)0x738acc9e, (q31_t)0xc8eb0fd6, (q31_t)0x737ff9ae, (q31_t)0xc8d4611d, (q31_t)0x73752249, (q31_t)0xc8bdb485, (q31_t)0x736a4671, (q31_t)0xc8a70a0e, - (q31_t)0x735f6626, (q31_t)0xc89061ba, (q31_t)0x73548168, (q31_t)0xc879bb89, (q31_t)0x73499838, (q31_t)0xc863177b, (q31_t)0x733eaa96, (q31_t)0xc84c7593, - (q31_t)0x7333b883, (q31_t)0xc835d5d0, (q31_t)0x7328c1ff, (q31_t)0xc81f3834, (q31_t)0x731dc70a, (q31_t)0xc8089cbf, (q31_t)0x7312c7a5, (q31_t)0xc7f20373, - (q31_t)0x7307c3d0, (q31_t)0xc7db6c50, (q31_t)0x72fcbb8c, (q31_t)0xc7c4d757, (q31_t)0x72f1aed9, (q31_t)0xc7ae4489, (q31_t)0x72e69db7, (q31_t)0xc797b3e7, - (q31_t)0x72db8828, (q31_t)0xc7812572, (q31_t)0x72d06e2b, (q31_t)0xc76a992a, (q31_t)0x72c54fc1, (q31_t)0xc7540f11, (q31_t)0x72ba2cea, (q31_t)0xc73d8727, - (q31_t)0x72af05a7, (q31_t)0xc727016d, (q31_t)0x72a3d9f7, (q31_t)0xc7107de4, (q31_t)0x7298a9dd, (q31_t)0xc6f9fc8d, (q31_t)0x728d7557, (q31_t)0xc6e37d69, - (q31_t)0x72823c67, (q31_t)0xc6cd0079, (q31_t)0x7276ff0d, (q31_t)0xc6b685bd, (q31_t)0x726bbd48, (q31_t)0xc6a00d37, (q31_t)0x7260771b, (q31_t)0xc68996e7, - (q31_t)0x72552c85, (q31_t)0xc67322ce, (q31_t)0x7249dd86, (q31_t)0xc65cb0ed, (q31_t)0x723e8a20, (q31_t)0xc6464144, (q31_t)0x72333251, (q31_t)0xc62fd3d6, - (q31_t)0x7227d61c, (q31_t)0xc61968a2, (q31_t)0x721c7580, (q31_t)0xc602ffaa, (q31_t)0x7211107e, (q31_t)0xc5ec98ee, (q31_t)0x7205a716, (q31_t)0xc5d6346f, - (q31_t)0x71fa3949, (q31_t)0xc5bfd22e, (q31_t)0x71eec716, (q31_t)0xc5a9722c, (q31_t)0x71e35080, (q31_t)0xc593146a, (q31_t)0x71d7d585, (q31_t)0xc57cb8e9, - (q31_t)0x71cc5626, (q31_t)0xc5665fa9, (q31_t)0x71c0d265, (q31_t)0xc55008ab, (q31_t)0x71b54a41, (q31_t)0xc539b3f1, (q31_t)0x71a9bdba, (q31_t)0xc523617a, - (q31_t)0x719e2cd2, (q31_t)0xc50d1149, (q31_t)0x71929789, (q31_t)0xc4f6c35d, (q31_t)0x7186fdde, (q31_t)0xc4e077b8, (q31_t)0x717b5fd3, (q31_t)0xc4ca2e5b, - (q31_t)0x716fbd68, (q31_t)0xc4b3e746, (q31_t)0x7164169d, (q31_t)0xc49da27a, (q31_t)0x71586b74, (q31_t)0xc4875ff9, (q31_t)0x714cbbeb, (q31_t)0xc4711fc2, - (q31_t)0x71410805, (q31_t)0xc45ae1d7, (q31_t)0x71354fc0, (q31_t)0xc444a639, (q31_t)0x7129931f, (q31_t)0xc42e6ce8, (q31_t)0x711dd220, (q31_t)0xc41835e6, - (q31_t)0x71120cc5, (q31_t)0xc4020133, (q31_t)0x7106430e, (q31_t)0xc3ebced0, (q31_t)0x70fa74fc, (q31_t)0xc3d59ebe, (q31_t)0x70eea28e, (q31_t)0xc3bf70fd, - (q31_t)0x70e2cbc6, (q31_t)0xc3a94590, (q31_t)0x70d6f0a4, (q31_t)0xc3931c76, (q31_t)0x70cb1128, (q31_t)0xc37cf5b0, (q31_t)0x70bf2d53, (q31_t)0xc366d140, - (q31_t)0x70b34525, (q31_t)0xc350af26, (q31_t)0x70a7589f, (q31_t)0xc33a8f62, (q31_t)0x709b67c0, (q31_t)0xc32471f7, (q31_t)0x708f728b, (q31_t)0xc30e56e4, - (q31_t)0x708378ff, (q31_t)0xc2f83e2a, (q31_t)0x70777b1c, (q31_t)0xc2e227cb, (q31_t)0x706b78e3, (q31_t)0xc2cc13c7, (q31_t)0x705f7255, (q31_t)0xc2b6021f, - (q31_t)0x70536771, (q31_t)0xc29ff2d4, (q31_t)0x70475839, (q31_t)0xc289e5e7, (q31_t)0x703b44ad, (q31_t)0xc273db58, (q31_t)0x702f2ccd, (q31_t)0xc25dd329, - (q31_t)0x7023109a, (q31_t)0xc247cd5a, (q31_t)0x7016f014, (q31_t)0xc231c9ec, (q31_t)0x700acb3c, (q31_t)0xc21bc8e1, (q31_t)0x6ffea212, (q31_t)0xc205ca38, - (q31_t)0x6ff27497, (q31_t)0xc1efcdf3, (q31_t)0x6fe642ca, (q31_t)0xc1d9d412, (q31_t)0x6fda0cae, (q31_t)0xc1c3dc97, (q31_t)0x6fcdd241, (q31_t)0xc1ade781, - (q31_t)0x6fc19385, (q31_t)0xc197f4d4, (q31_t)0x6fb5507a, (q31_t)0xc182048d, (q31_t)0x6fa90921, (q31_t)0xc16c16b0, (q31_t)0x6f9cbd79, (q31_t)0xc1562b3d, - (q31_t)0x6f906d84, (q31_t)0xc1404233, (q31_t)0x6f841942, (q31_t)0xc12a5b95, (q31_t)0x6f77c0b3, (q31_t)0xc1147764, (q31_t)0x6f6b63d8, (q31_t)0xc0fe959f, - (q31_t)0x6f5f02b2, (q31_t)0xc0e8b648, (q31_t)0x6f529d40, (q31_t)0xc0d2d960, (q31_t)0x6f463383, (q31_t)0xc0bcfee7, (q31_t)0x6f39c57d, (q31_t)0xc0a726df, - (q31_t)0x6f2d532c, (q31_t)0xc0915148, (q31_t)0x6f20dc92, (q31_t)0xc07b7e23, (q31_t)0x6f1461b0, (q31_t)0xc065ad70, (q31_t)0x6f07e285, (q31_t)0xc04fdf32, - (q31_t)0x6efb5f12, (q31_t)0xc03a1368, (q31_t)0x6eeed758, (q31_t)0xc0244a14, (q31_t)0x6ee24b57, (q31_t)0xc00e8336, (q31_t)0x6ed5bb10, (q31_t)0xbff8bece, - (q31_t)0x6ec92683, (q31_t)0xbfe2fcdf, (q31_t)0x6ebc8db0, (q31_t)0xbfcd3d69, (q31_t)0x6eaff099, (q31_t)0xbfb7806c, (q31_t)0x6ea34f3d, (q31_t)0xbfa1c5ea, - (q31_t)0x6e96a99d, (q31_t)0xbf8c0de3, (q31_t)0x6e89ffb9, (q31_t)0xbf765858, (q31_t)0x6e7d5193, (q31_t)0xbf60a54a, (q31_t)0x6e709f2a, (q31_t)0xbf4af4ba, - (q31_t)0x6e63e87f, (q31_t)0xbf3546a8, (q31_t)0x6e572d93, (q31_t)0xbf1f9b16, (q31_t)0x6e4a6e66, (q31_t)0xbf09f205, (q31_t)0x6e3daaf8, (q31_t)0xbef44b74, - (q31_t)0x6e30e34a, (q31_t)0xbedea765, (q31_t)0x6e24175c, (q31_t)0xbec905d9, (q31_t)0x6e174730, (q31_t)0xbeb366d1, (q31_t)0x6e0a72c5, (q31_t)0xbe9dca4e, - (q31_t)0x6dfd9a1c, (q31_t)0xbe88304f, (q31_t)0x6df0bd35, (q31_t)0xbe7298d7, (q31_t)0x6de3dc11, (q31_t)0xbe5d03e6, (q31_t)0x6dd6f6b1, (q31_t)0xbe47717c, - (q31_t)0x6dca0d14, (q31_t)0xbe31e19b, (q31_t)0x6dbd1f3c, (q31_t)0xbe1c5444, (q31_t)0x6db02d29, (q31_t)0xbe06c977, (q31_t)0x6da336dc, (q31_t)0xbdf14135, - (q31_t)0x6d963c54, (q31_t)0xbddbbb7f, (q31_t)0x6d893d93, (q31_t)0xbdc63856, (q31_t)0x6d7c3a98, (q31_t)0xbdb0b7bb, (q31_t)0x6d6f3365, (q31_t)0xbd9b39ad, - (q31_t)0x6d6227fa, (q31_t)0xbd85be30, (q31_t)0x6d551858, (q31_t)0xbd704542, (q31_t)0x6d48047e, (q31_t)0xbd5acee5, (q31_t)0x6d3aec6e, (q31_t)0xbd455b1a, - (q31_t)0x6d2dd027, (q31_t)0xbd2fe9e2, (q31_t)0x6d20afac, (q31_t)0xbd1a7b3d, (q31_t)0x6d138afb, (q31_t)0xbd050f2c, (q31_t)0x6d066215, (q31_t)0xbcefa5b0, - (q31_t)0x6cf934fc, (q31_t)0xbcda3ecb, (q31_t)0x6cec03af, (q31_t)0xbcc4da7b, (q31_t)0x6cdece2f, (q31_t)0xbcaf78c4, (q31_t)0x6cd1947c, (q31_t)0xbc9a19a5, - (q31_t)0x6cc45698, (q31_t)0xbc84bd1f, (q31_t)0x6cb71482, (q31_t)0xbc6f6333, (q31_t)0x6ca9ce3b, (q31_t)0xbc5a0be2, (q31_t)0x6c9c83c3, (q31_t)0xbc44b72c, - (q31_t)0x6c8f351c, (q31_t)0xbc2f6513, (q31_t)0x6c81e245, (q31_t)0xbc1a1598, (q31_t)0x6c748b3f, (q31_t)0xbc04c8ba, (q31_t)0x6c67300b, (q31_t)0xbbef7e7c, - (q31_t)0x6c59d0a9, (q31_t)0xbbda36dd, (q31_t)0x6c4c6d1a, (q31_t)0xbbc4f1df, (q31_t)0x6c3f055d, (q31_t)0xbbafaf82, (q31_t)0x6c319975, (q31_t)0xbb9a6fc7, - (q31_t)0x6c242960, (q31_t)0xbb8532b0, (q31_t)0x6c16b521, (q31_t)0xbb6ff83c, (q31_t)0x6c093cb6, (q31_t)0xbb5ac06d, (q31_t)0x6bfbc021, (q31_t)0xbb458b43, - (q31_t)0x6bee3f62, (q31_t)0xbb3058c0, (q31_t)0x6be0ba7b, (q31_t)0xbb1b28e4, (q31_t)0x6bd3316a, (q31_t)0xbb05fbb0, (q31_t)0x6bc5a431, (q31_t)0xbaf0d125, - (q31_t)0x6bb812d1, (q31_t)0xbadba943, (q31_t)0x6baa7d49, (q31_t)0xbac6840c, (q31_t)0x6b9ce39b, (q31_t)0xbab16180, (q31_t)0x6b8f45c7, (q31_t)0xba9c41a0, - (q31_t)0x6b81a3cd, (q31_t)0xba87246d, (q31_t)0x6b73fdae, (q31_t)0xba7209e7, (q31_t)0x6b66536b, (q31_t)0xba5cf210, (q31_t)0x6b58a503, (q31_t)0xba47dce8, - (q31_t)0x6b4af279, (q31_t)0xba32ca71, (q31_t)0x6b3d3bcb, (q31_t)0xba1dbaaa, (q31_t)0x6b2f80fb, (q31_t)0xba08ad95, (q31_t)0x6b21c208, (q31_t)0xb9f3a332, - (q31_t)0x6b13fef5, (q31_t)0xb9de9b83, (q31_t)0x6b0637c1, (q31_t)0xb9c99688, (q31_t)0x6af86c6c, (q31_t)0xb9b49442, (q31_t)0x6aea9cf8, (q31_t)0xb99f94b2, - (q31_t)0x6adcc964, (q31_t)0xb98a97d8, (q31_t)0x6acef1b2, (q31_t)0xb9759db6, (q31_t)0x6ac115e2, (q31_t)0xb960a64c, (q31_t)0x6ab335f4, (q31_t)0xb94bb19b, - (q31_t)0x6aa551e9, (q31_t)0xb936bfa4, (q31_t)0x6a9769c1, (q31_t)0xb921d067, (q31_t)0x6a897d7d, (q31_t)0xb90ce3e6, (q31_t)0x6a7b8d1e, (q31_t)0xb8f7fa21, - (q31_t)0x6a6d98a4, (q31_t)0xb8e31319, (q31_t)0x6a5fa010, (q31_t)0xb8ce2ecf, (q31_t)0x6a51a361, (q31_t)0xb8b94d44, (q31_t)0x6a43a29a, (q31_t)0xb8a46e78, - (q31_t)0x6a359db9, (q31_t)0xb88f926d, (q31_t)0x6a2794c1, (q31_t)0xb87ab922, (q31_t)0x6a1987b0, (q31_t)0xb865e299, (q31_t)0x6a0b7689, (q31_t)0xb8510ed4, - (q31_t)0x69fd614a, (q31_t)0xb83c3dd1, (q31_t)0x69ef47f6, (q31_t)0xb8276f93, (q31_t)0x69e12a8c, (q31_t)0xb812a41a, (q31_t)0x69d3090e, (q31_t)0xb7fddb67, - (q31_t)0x69c4e37a, (q31_t)0xb7e9157a, (q31_t)0x69b6b9d3, (q31_t)0xb7d45255, (q31_t)0x69a88c19, (q31_t)0xb7bf91f8, (q31_t)0x699a5a4c, (q31_t)0xb7aad465, - (q31_t)0x698c246c, (q31_t)0xb796199b, (q31_t)0x697dea7b, (q31_t)0xb781619c, (q31_t)0x696fac78, (q31_t)0xb76cac69, (q31_t)0x69616a65, (q31_t)0xb757fa01, - (q31_t)0x69532442, (q31_t)0xb7434a67, (q31_t)0x6944da10, (q31_t)0xb72e9d9b, (q31_t)0x69368bce, (q31_t)0xb719f39e, (q31_t)0x6928397e, (q31_t)0xb7054c6f, - (q31_t)0x6919e320, (q31_t)0xb6f0a812, (q31_t)0x690b88b5, (q31_t)0xb6dc0685, (q31_t)0x68fd2a3d, (q31_t)0xb6c767ca, (q31_t)0x68eec7b9, (q31_t)0xb6b2cbe2, - (q31_t)0x68e06129, (q31_t)0xb69e32cd, (q31_t)0x68d1f68f, (q31_t)0xb6899c8d, (q31_t)0x68c387e9, (q31_t)0xb6750921, (q31_t)0x68b5153a, (q31_t)0xb660788c, - (q31_t)0x68a69e81, (q31_t)0xb64beacd, (q31_t)0x689823bf, (q31_t)0xb6375fe5, (q31_t)0x6889a4f6, (q31_t)0xb622d7d6, (q31_t)0x687b2224, (q31_t)0xb60e529f, - (q31_t)0x686c9b4b, (q31_t)0xb5f9d043, (q31_t)0x685e106c, (q31_t)0xb5e550c1, (q31_t)0x684f8186, (q31_t)0xb5d0d41a, (q31_t)0x6840ee9b, (q31_t)0xb5bc5a50, - (q31_t)0x683257ab, (q31_t)0xb5a7e362, (q31_t)0x6823bcb7, (q31_t)0xb5936f53, (q31_t)0x68151dbe, (q31_t)0xb57efe22, (q31_t)0x68067ac3, (q31_t)0xb56a8fd0, - (q31_t)0x67f7d3c5, (q31_t)0xb556245e, (q31_t)0x67e928c5, (q31_t)0xb541bbcd, (q31_t)0x67da79c3, (q31_t)0xb52d561e, (q31_t)0x67cbc6c0, (q31_t)0xb518f351, - (q31_t)0x67bd0fbd, (q31_t)0xb5049368, (q31_t)0x67ae54ba, (q31_t)0xb4f03663, (q31_t)0x679f95b7, (q31_t)0xb4dbdc42, (q31_t)0x6790d2b6, (q31_t)0xb4c78507, - (q31_t)0x67820bb7, (q31_t)0xb4b330b3, (q31_t)0x677340ba, (q31_t)0xb49edf45, (q31_t)0x676471c0, (q31_t)0xb48a90c0, (q31_t)0x67559eca, (q31_t)0xb4764523, - (q31_t)0x6746c7d8, (q31_t)0xb461fc70, (q31_t)0x6737ecea, (q31_t)0xb44db6a8, (q31_t)0x67290e02, (q31_t)0xb43973ca, (q31_t)0x671a2b20, (q31_t)0xb42533d8, - (q31_t)0x670b4444, (q31_t)0xb410f6d3, (q31_t)0x66fc596f, (q31_t)0xb3fcbcbb, (q31_t)0x66ed6aa1, (q31_t)0xb3e88592, (q31_t)0x66de77dc, (q31_t)0xb3d45157, - (q31_t)0x66cf8120, (q31_t)0xb3c0200c, (q31_t)0x66c0866d, (q31_t)0xb3abf1b2, (q31_t)0x66b187c3, (q31_t)0xb397c649, (q31_t)0x66a28524, (q31_t)0xb3839dd3, - (q31_t)0x66937e91, (q31_t)0xb36f784f, (q31_t)0x66847408, (q31_t)0xb35b55bf, (q31_t)0x6675658c, (q31_t)0xb3473623, (q31_t)0x6666531d, (q31_t)0xb333197c, - (q31_t)0x66573cbb, (q31_t)0xb31effcc, (q31_t)0x66482267, (q31_t)0xb30ae912, (q31_t)0x66390422, (q31_t)0xb2f6d550, (q31_t)0x6629e1ec, (q31_t)0xb2e2c486, - (q31_t)0x661abbc5, (q31_t)0xb2ceb6b5, (q31_t)0x660b91af, (q31_t)0xb2baabde, (q31_t)0x65fc63a9, (q31_t)0xb2a6a402, (q31_t)0x65ed31b5, (q31_t)0xb2929f21, - (q31_t)0x65ddfbd3, (q31_t)0xb27e9d3c, (q31_t)0x65cec204, (q31_t)0xb26a9e54, (q31_t)0x65bf8447, (q31_t)0xb256a26a, (q31_t)0x65b0429f, (q31_t)0xb242a97e, - (q31_t)0x65a0fd0b, (q31_t)0xb22eb392, (q31_t)0x6591b38c, (q31_t)0xb21ac0a6, (q31_t)0x65826622, (q31_t)0xb206d0ba, (q31_t)0x657314cf, (q31_t)0xb1f2e3d0, - (q31_t)0x6563bf92, (q31_t)0xb1def9e9, (q31_t)0x6554666d, (q31_t)0xb1cb1304, (q31_t)0x6545095f, (q31_t)0xb1b72f23, (q31_t)0x6535a86b, (q31_t)0xb1a34e47, - (q31_t)0x6526438f, (q31_t)0xb18f7071, (q31_t)0x6516dacd, (q31_t)0xb17b95a0, (q31_t)0x65076e25, (q31_t)0xb167bdd7, (q31_t)0x64f7fd98, (q31_t)0xb153e915, - (q31_t)0x64e88926, (q31_t)0xb140175b, (q31_t)0x64d910d1, (q31_t)0xb12c48ab, (q31_t)0x64c99498, (q31_t)0xb1187d05, (q31_t)0x64ba147d, (q31_t)0xb104b46a, - (q31_t)0x64aa907f, (q31_t)0xb0f0eeda, (q31_t)0x649b08a0, (q31_t)0xb0dd2c56, (q31_t)0x648b7ce0, (q31_t)0xb0c96ce0, (q31_t)0x647bed3f, (q31_t)0xb0b5b077, - (q31_t)0x646c59bf, (q31_t)0xb0a1f71d, (q31_t)0x645cc260, (q31_t)0xb08e40d2, (q31_t)0x644d2722, (q31_t)0xb07a8d97, (q31_t)0x643d8806, (q31_t)0xb066dd6d, - (q31_t)0x642de50d, (q31_t)0xb0533055, (q31_t)0x641e3e38, (q31_t)0xb03f864f, (q31_t)0x640e9386, (q31_t)0xb02bdf5c, (q31_t)0x63fee4f8, (q31_t)0xb0183b7d, - (q31_t)0x63ef3290, (q31_t)0xb0049ab3, (q31_t)0x63df7c4d, (q31_t)0xaff0fcfe, (q31_t)0x63cfc231, (q31_t)0xafdd625f, (q31_t)0x63c0043b, (q31_t)0xafc9cad7, - (q31_t)0x63b0426d, (q31_t)0xafb63667, (q31_t)0x63a07cc7, (q31_t)0xafa2a50f, (q31_t)0x6390b34a, (q31_t)0xaf8f16d1, (q31_t)0x6380e5f6, (q31_t)0xaf7b8bac, - (q31_t)0x637114cc, (q31_t)0xaf6803a2, (q31_t)0x63613fcd, (q31_t)0xaf547eb3, (q31_t)0x635166f9, (q31_t)0xaf40fce1, (q31_t)0x63418a50, (q31_t)0xaf2d7e2b, - (q31_t)0x6331a9d4, (q31_t)0xaf1a0293, (q31_t)0x6321c585, (q31_t)0xaf068a1a, (q31_t)0x6311dd64, (q31_t)0xaef314c0, (q31_t)0x6301f171, (q31_t)0xaedfa285, - (q31_t)0x62f201ac, (q31_t)0xaecc336c, (q31_t)0x62e20e17, (q31_t)0xaeb8c774, (q31_t)0x62d216b3, (q31_t)0xaea55e9e, (q31_t)0x62c21b7e, (q31_t)0xae91f8eb, - (q31_t)0x62b21c7b, (q31_t)0xae7e965b, (q31_t)0x62a219aa, (q31_t)0xae6b36f0, (q31_t)0x6292130c, (q31_t)0xae57daab, (q31_t)0x628208a1, (q31_t)0xae44818b, - (q31_t)0x6271fa69, (q31_t)0xae312b92, (q31_t)0x6261e866, (q31_t)0xae1dd8c0, (q31_t)0x6251d298, (q31_t)0xae0a8916, (q31_t)0x6241b8ff, (q31_t)0xadf73c96, - (q31_t)0x62319b9d, (q31_t)0xade3f33e, (q31_t)0x62217a72, (q31_t)0xadd0ad12, (q31_t)0x6211557e, (q31_t)0xadbd6a10, (q31_t)0x62012cc2, (q31_t)0xadaa2a3b, - (q31_t)0x61f1003f, (q31_t)0xad96ed92, (q31_t)0x61e0cff5, (q31_t)0xad83b416, (q31_t)0x61d09be5, (q31_t)0xad707dc8, (q31_t)0x61c06410, (q31_t)0xad5d4aaa, - (q31_t)0x61b02876, (q31_t)0xad4a1aba, (q31_t)0x619fe918, (q31_t)0xad36edfc, (q31_t)0x618fa5f7, (q31_t)0xad23c46e, (q31_t)0x617f5f12, (q31_t)0xad109e12, - (q31_t)0x616f146c, (q31_t)0xacfd7ae8, (q31_t)0x615ec603, (q31_t)0xacea5af2, (q31_t)0x614e73da, (q31_t)0xacd73e30, (q31_t)0x613e1df0, (q31_t)0xacc424a3, - (q31_t)0x612dc447, (q31_t)0xacb10e4b, (q31_t)0x611d66de, (q31_t)0xac9dfb29, (q31_t)0x610d05b7, (q31_t)0xac8aeb3e, (q31_t)0x60fca0d2, (q31_t)0xac77de8b, - (q31_t)0x60ec3830, (q31_t)0xac64d510, (q31_t)0x60dbcbd1, (q31_t)0xac51cecf, (q31_t)0x60cb5bb7, (q31_t)0xac3ecbc7, (q31_t)0x60bae7e1, (q31_t)0xac2bcbfa, - (q31_t)0x60aa7050, (q31_t)0xac18cf69, (q31_t)0x6099f505, (q31_t)0xac05d613, (q31_t)0x60897601, (q31_t)0xabf2dffb, (q31_t)0x6078f344, (q31_t)0xabdfed1f, - (q31_t)0x60686ccf, (q31_t)0xabccfd83, (q31_t)0x6057e2a2, (q31_t)0xabba1125, (q31_t)0x604754bf, (q31_t)0xaba72807, (q31_t)0x6036c325, (q31_t)0xab944229, - (q31_t)0x60262dd6, (q31_t)0xab815f8d, (q31_t)0x601594d1, (q31_t)0xab6e8032, (q31_t)0x6004f819, (q31_t)0xab5ba41a, (q31_t)0x5ff457ad, (q31_t)0xab48cb46, - (q31_t)0x5fe3b38d, (q31_t)0xab35f5b5, (q31_t)0x5fd30bbc, (q31_t)0xab23236a, (q31_t)0x5fc26038, (q31_t)0xab105464, (q31_t)0x5fb1b104, (q31_t)0xaafd88a4, - (q31_t)0x5fa0fe1f, (q31_t)0xaaeac02c, (q31_t)0x5f90478a, (q31_t)0xaad7fafb, (q31_t)0x5f7f8d46, (q31_t)0xaac53912, (q31_t)0x5f6ecf53, (q31_t)0xaab27a73, - (q31_t)0x5f5e0db3, (q31_t)0xaa9fbf1e, (q31_t)0x5f4d4865, (q31_t)0xaa8d0713, (q31_t)0x5f3c7f6b, (q31_t)0xaa7a5253, (q31_t)0x5f2bb2c5, (q31_t)0xaa67a0e0, - (q31_t)0x5f1ae274, (q31_t)0xaa54f2ba, (q31_t)0x5f0a0e77, (q31_t)0xaa4247e1, (q31_t)0x5ef936d1, (q31_t)0xaa2fa056, (q31_t)0x5ee85b82, (q31_t)0xaa1cfc1a, - (q31_t)0x5ed77c8a, (q31_t)0xaa0a5b2e, (q31_t)0x5ec699e9, (q31_t)0xa9f7bd92, (q31_t)0x5eb5b3a2, (q31_t)0xa9e52347, (q31_t)0x5ea4c9b3, (q31_t)0xa9d28c4e, - (q31_t)0x5e93dc1f, (q31_t)0xa9bff8a8, (q31_t)0x5e82eae5, (q31_t)0xa9ad6855, (q31_t)0x5e71f606, (q31_t)0xa99adb56, (q31_t)0x5e60fd84, (q31_t)0xa98851ac, - (q31_t)0x5e50015d, (q31_t)0xa975cb57, (q31_t)0x5e3f0194, (q31_t)0xa9634858, (q31_t)0x5e2dfe29, (q31_t)0xa950c8b0, (q31_t)0x5e1cf71c, (q31_t)0xa93e4c5f, - (q31_t)0x5e0bec6e, (q31_t)0xa92bd367, (q31_t)0x5dfade20, (q31_t)0xa9195dc7, (q31_t)0x5de9cc33, (q31_t)0xa906eb82, (q31_t)0x5dd8b6a7, (q31_t)0xa8f47c97, - (q31_t)0x5dc79d7c, (q31_t)0xa8e21106, (q31_t)0x5db680b4, (q31_t)0xa8cfa8d2, (q31_t)0x5da5604f, (q31_t)0xa8bd43fa, (q31_t)0x5d943c4e, (q31_t)0xa8aae280, - (q31_t)0x5d8314b1, (q31_t)0xa8988463, (q31_t)0x5d71e979, (q31_t)0xa88629a5, (q31_t)0x5d60baa7, (q31_t)0xa873d246, (q31_t)0x5d4f883b, (q31_t)0xa8617e48, - (q31_t)0x5d3e5237, (q31_t)0xa84f2daa, (q31_t)0x5d2d189a, (q31_t)0xa83ce06e, (q31_t)0x5d1bdb65, (q31_t)0xa82a9693, (q31_t)0x5d0a9a9a, (q31_t)0xa818501c, - (q31_t)0x5cf95638, (q31_t)0xa8060d08, (q31_t)0x5ce80e41, (q31_t)0xa7f3cd59, (q31_t)0x5cd6c2b5, (q31_t)0xa7e1910f, (q31_t)0x5cc57394, (q31_t)0xa7cf582a, - (q31_t)0x5cb420e0, (q31_t)0xa7bd22ac, (q31_t)0x5ca2ca99, (q31_t)0xa7aaf094, (q31_t)0x5c9170bf, (q31_t)0xa798c1e5, (q31_t)0x5c801354, (q31_t)0xa786969e, - (q31_t)0x5c6eb258, (q31_t)0xa7746ec0, (q31_t)0x5c5d4dcc, (q31_t)0xa7624a4d, (q31_t)0x5c4be5b0, (q31_t)0xa7502943, (q31_t)0x5c3a7a05, (q31_t)0xa73e0ba5, - (q31_t)0x5c290acc, (q31_t)0xa72bf174, (q31_t)0x5c179806, (q31_t)0xa719daae, (q31_t)0x5c0621b2, (q31_t)0xa707c757, (q31_t)0x5bf4a7d2, (q31_t)0xa6f5b76d, - (q31_t)0x5be32a67, (q31_t)0xa6e3aaf2, (q31_t)0x5bd1a971, (q31_t)0xa6d1a1e7, (q31_t)0x5bc024f0, (q31_t)0xa6bf9c4b, (q31_t)0x5bae9ce7, (q31_t)0xa6ad9a21, - (q31_t)0x5b9d1154, (q31_t)0xa69b9b68, (q31_t)0x5b8b8239, (q31_t)0xa689a022, (q31_t)0x5b79ef96, (q31_t)0xa677a84e, (q31_t)0x5b68596d, (q31_t)0xa665b3ee, - (q31_t)0x5b56bfbd, (q31_t)0xa653c303, (q31_t)0x5b452288, (q31_t)0xa641d58c, (q31_t)0x5b3381ce, (q31_t)0xa62feb8b, (q31_t)0x5b21dd90, (q31_t)0xa61e0501, - (q31_t)0x5b1035cf, (q31_t)0xa60c21ee, (q31_t)0x5afe8a8b, (q31_t)0xa5fa4252, (q31_t)0x5aecdbc5, (q31_t)0xa5e8662f, (q31_t)0x5adb297d, (q31_t)0xa5d68d85, - (q31_t)0x5ac973b5, (q31_t)0xa5c4b855, (q31_t)0x5ab7ba6c, (q31_t)0xa5b2e6a0, (q31_t)0x5aa5fda5, (q31_t)0xa5a11866, (q31_t)0x5a943d5e, (q31_t)0xa58f4da8, - (q31_t)0x5a82799a, (q31_t)0xa57d8666, (q31_t)0x5a70b258, (q31_t)0xa56bc2a2, (q31_t)0x5a5ee79a, (q31_t)0xa55a025b, (q31_t)0x5a4d1960, (q31_t)0xa5484594, - (q31_t)0x5a3b47ab, (q31_t)0xa5368c4b, (q31_t)0x5a29727b, (q31_t)0xa524d683, (q31_t)0x5a1799d1, (q31_t)0xa513243b, (q31_t)0x5a05bdae, (q31_t)0xa5017575, - (q31_t)0x59f3de12, (q31_t)0xa4efca31, (q31_t)0x59e1faff, (q31_t)0xa4de2270, (q31_t)0x59d01475, (q31_t)0xa4cc7e32, (q31_t)0x59be2a74, (q31_t)0xa4badd78, - (q31_t)0x59ac3cfd, (q31_t)0xa4a94043, (q31_t)0x599a4c12, (q31_t)0xa497a693, (q31_t)0x598857b2, (q31_t)0xa486106a, (q31_t)0x59765fde, (q31_t)0xa4747dc7, - (q31_t)0x59646498, (q31_t)0xa462eeac, (q31_t)0x595265df, (q31_t)0xa4516319, (q31_t)0x594063b5, (q31_t)0xa43fdb10, (q31_t)0x592e5e19, (q31_t)0xa42e568f, - (q31_t)0x591c550e, (q31_t)0xa41cd599, (q31_t)0x590a4893, (q31_t)0xa40b582e, (q31_t)0x58f838a9, (q31_t)0xa3f9de4e, (q31_t)0x58e62552, (q31_t)0xa3e867fa, - (q31_t)0x58d40e8c, (q31_t)0xa3d6f534, (q31_t)0x58c1f45b, (q31_t)0xa3c585fb, (q31_t)0x58afd6bd, (q31_t)0xa3b41a50, (q31_t)0x589db5b3, (q31_t)0xa3a2b234, - (q31_t)0x588b9140, (q31_t)0xa3914da8, (q31_t)0x58796962, (q31_t)0xa37fecac, (q31_t)0x58673e1b, (q31_t)0xa36e8f41, (q31_t)0x58550f6c, (q31_t)0xa35d3567, - (q31_t)0x5842dd54, (q31_t)0xa34bdf20, (q31_t)0x5830a7d6, (q31_t)0xa33a8c6c, (q31_t)0x581e6ef1, (q31_t)0xa3293d4b, (q31_t)0x580c32a7, (q31_t)0xa317f1bf, - (q31_t)0x57f9f2f8, (q31_t)0xa306a9c8, (q31_t)0x57e7afe4, (q31_t)0xa2f56566, (q31_t)0x57d5696d, (q31_t)0xa2e4249b, (q31_t)0x57c31f92, (q31_t)0xa2d2e766, - (q31_t)0x57b0d256, (q31_t)0xa2c1adc9, (q31_t)0x579e81b8, (q31_t)0xa2b077c5, (q31_t)0x578c2dba, (q31_t)0xa29f4559, (q31_t)0x5779d65b, (q31_t)0xa28e1687, - (q31_t)0x57677b9d, (q31_t)0xa27ceb4f, (q31_t)0x57551d80, (q31_t)0xa26bc3b2, (q31_t)0x5742bc06, (q31_t)0xa25a9fb1, (q31_t)0x5730572e, (q31_t)0xa2497f4c, - (q31_t)0x571deefa, (q31_t)0xa2386284, (q31_t)0x570b8369, (q31_t)0xa2274959, (q31_t)0x56f9147e, (q31_t)0xa21633cd, (q31_t)0x56e6a239, (q31_t)0xa20521e0, - (q31_t)0x56d42c99, (q31_t)0xa1f41392, (q31_t)0x56c1b3a1, (q31_t)0xa1e308e4, (q31_t)0x56af3750, (q31_t)0xa1d201d7, (q31_t)0x569cb7a8, (q31_t)0xa1c0fe6c, - (q31_t)0x568a34a9, (q31_t)0xa1affea3, (q31_t)0x5677ae54, (q31_t)0xa19f027c, (q31_t)0x566524aa, (q31_t)0xa18e09fa, (q31_t)0x565297ab, (q31_t)0xa17d151b, - (q31_t)0x56400758, (q31_t)0xa16c23e1, (q31_t)0x562d73b2, (q31_t)0xa15b364d, (q31_t)0x561adcb9, (q31_t)0xa14a4c5e, (q31_t)0x5608426e, (q31_t)0xa1396617, - (q31_t)0x55f5a4d2, (q31_t)0xa1288376, (q31_t)0x55e303e6, (q31_t)0xa117a47e, (q31_t)0x55d05faa, (q31_t)0xa106c92f, (q31_t)0x55bdb81f, (q31_t)0xa0f5f189, - (q31_t)0x55ab0d46, (q31_t)0xa0e51d8c, (q31_t)0x55985f20, (q31_t)0xa0d44d3b, (q31_t)0x5585adad, (q31_t)0xa0c38095, (q31_t)0x5572f8ed, (q31_t)0xa0b2b79b, - (q31_t)0x556040e2, (q31_t)0xa0a1f24d, (q31_t)0x554d858d, (q31_t)0xa09130ad, (q31_t)0x553ac6ee, (q31_t)0xa08072ba, (q31_t)0x55280505, (q31_t)0xa06fb876, - (q31_t)0x55153fd4, (q31_t)0xa05f01e1, (q31_t)0x5502775c, (q31_t)0xa04e4efc, (q31_t)0x54efab9c, (q31_t)0xa03d9fc8, (q31_t)0x54dcdc96, (q31_t)0xa02cf444, - (q31_t)0x54ca0a4b, (q31_t)0xa01c4c73, (q31_t)0x54b734ba, (q31_t)0xa00ba853, (q31_t)0x54a45be6, (q31_t)0x9ffb07e7, (q31_t)0x54917fce, (q31_t)0x9fea6b2f, - (q31_t)0x547ea073, (q31_t)0x9fd9d22a, (q31_t)0x546bbdd7, (q31_t)0x9fc93cdb, (q31_t)0x5458d7f9, (q31_t)0x9fb8ab41, (q31_t)0x5445eedb, (q31_t)0x9fa81d5e, - (q31_t)0x5433027d, (q31_t)0x9f979331, (q31_t)0x542012e1, (q31_t)0x9f870cbc, (q31_t)0x540d2005, (q31_t)0x9f7689ff, (q31_t)0x53fa29ed, (q31_t)0x9f660afb, - (q31_t)0x53e73097, (q31_t)0x9f558fb0, (q31_t)0x53d43406, (q31_t)0x9f45181f, (q31_t)0x53c13439, (q31_t)0x9f34a449, (q31_t)0x53ae3131, (q31_t)0x9f24342f, - (q31_t)0x539b2af0, (q31_t)0x9f13c7d0, (q31_t)0x53882175, (q31_t)0x9f035f2e, (q31_t)0x537514c2, (q31_t)0x9ef2fa49, (q31_t)0x536204d7, (q31_t)0x9ee29922, - (q31_t)0x534ef1b5, (q31_t)0x9ed23bb9, (q31_t)0x533bdb5d, (q31_t)0x9ec1e210, (q31_t)0x5328c1d0, (q31_t)0x9eb18c26, (q31_t)0x5315a50e, (q31_t)0x9ea139fd, - (q31_t)0x53028518, (q31_t)0x9e90eb94, (q31_t)0x52ef61ee, (q31_t)0x9e80a0ee, (q31_t)0x52dc3b92, (q31_t)0x9e705a09, (q31_t)0x52c91204, (q31_t)0x9e6016e8, - (q31_t)0x52b5e546, (q31_t)0x9e4fd78a, (q31_t)0x52a2b556, (q31_t)0x9e3f9bf0, (q31_t)0x528f8238, (q31_t)0x9e2f641b, (q31_t)0x527c4bea, (q31_t)0x9e1f300b, - (q31_t)0x5269126e, (q31_t)0x9e0effc1, (q31_t)0x5255d5c5, (q31_t)0x9dfed33e, (q31_t)0x524295f0, (q31_t)0x9deeaa82, (q31_t)0x522f52ee, (q31_t)0x9dde858e, - (q31_t)0x521c0cc2, (q31_t)0x9dce6463, (q31_t)0x5208c36a, (q31_t)0x9dbe4701, (q31_t)0x51f576ea, (q31_t)0x9dae2d68, (q31_t)0x51e22740, (q31_t)0x9d9e179a, - (q31_t)0x51ced46e, (q31_t)0x9d8e0597, (q31_t)0x51bb7e75, (q31_t)0x9d7df75f, (q31_t)0x51a82555, (q31_t)0x9d6decf4, (q31_t)0x5194c910, (q31_t)0x9d5de656, - (q31_t)0x518169a5, (q31_t)0x9d4de385, (q31_t)0x516e0715, (q31_t)0x9d3de482, (q31_t)0x515aa162, (q31_t)0x9d2de94d, (q31_t)0x5147388c, (q31_t)0x9d1df1e9, - (q31_t)0x5133cc94, (q31_t)0x9d0dfe54, (q31_t)0x51205d7b, (q31_t)0x9cfe0e8f, (q31_t)0x510ceb40, (q31_t)0x9cee229c, (q31_t)0x50f975e6, (q31_t)0x9cde3a7b, - (q31_t)0x50e5fd6d, (q31_t)0x9cce562c, (q31_t)0x50d281d5, (q31_t)0x9cbe75b0, (q31_t)0x50bf031f, (q31_t)0x9cae9907, (q31_t)0x50ab814d, (q31_t)0x9c9ec033, - (q31_t)0x5097fc5e, (q31_t)0x9c8eeb34, (q31_t)0x50847454, (q31_t)0x9c7f1a0a, (q31_t)0x5070e92f, (q31_t)0x9c6f4cb6, (q31_t)0x505d5af1, (q31_t)0x9c5f8339, - (q31_t)0x5049c999, (q31_t)0x9c4fbd93, (q31_t)0x50363529, (q31_t)0x9c3ffbc5, (q31_t)0x50229da1, (q31_t)0x9c303dcf, (q31_t)0x500f0302, (q31_t)0x9c2083b3, - (q31_t)0x4ffb654d, (q31_t)0x9c10cd70, (q31_t)0x4fe7c483, (q31_t)0x9c011b08, (q31_t)0x4fd420a4, (q31_t)0x9bf16c7a, (q31_t)0x4fc079b1, (q31_t)0x9be1c1c8, - (q31_t)0x4faccfab, (q31_t)0x9bd21af3, (q31_t)0x4f992293, (q31_t)0x9bc277fa, (q31_t)0x4f857269, (q31_t)0x9bb2d8de, (q31_t)0x4f71bf2e, (q31_t)0x9ba33da0, - (q31_t)0x4f5e08e3, (q31_t)0x9b93a641, (q31_t)0x4f4a4f89, (q31_t)0x9b8412c1, (q31_t)0x4f369320, (q31_t)0x9b748320, (q31_t)0x4f22d3aa, (q31_t)0x9b64f760, - (q31_t)0x4f0f1126, (q31_t)0x9b556f81, (q31_t)0x4efb4b96, (q31_t)0x9b45eb83, (q31_t)0x4ee782fb, (q31_t)0x9b366b68, (q31_t)0x4ed3b755, (q31_t)0x9b26ef2f, - (q31_t)0x4ebfe8a5, (q31_t)0x9b1776da, (q31_t)0x4eac16eb, (q31_t)0x9b080268, (q31_t)0x4e984229, (q31_t)0x9af891db, (q31_t)0x4e846a60, (q31_t)0x9ae92533, - (q31_t)0x4e708f8f, (q31_t)0x9ad9bc71, (q31_t)0x4e5cb1b9, (q31_t)0x9aca5795, (q31_t)0x4e48d0dd, (q31_t)0x9abaf6a1, (q31_t)0x4e34ecfc, (q31_t)0x9aab9993, - (q31_t)0x4e210617, (q31_t)0x9a9c406e, (q31_t)0x4e0d1c30, (q31_t)0x9a8ceb31, (q31_t)0x4df92f46, (q31_t)0x9a7d99de, (q31_t)0x4de53f5a, (q31_t)0x9a6e4c74, - (q31_t)0x4dd14c6e, (q31_t)0x9a5f02f5, (q31_t)0x4dbd5682, (q31_t)0x9a4fbd61, (q31_t)0x4da95d96, (q31_t)0x9a407bb9, (q31_t)0x4d9561ac, (q31_t)0x9a313dfc, - (q31_t)0x4d8162c4, (q31_t)0x9a22042d, (q31_t)0x4d6d60df, (q31_t)0x9a12ce4b, (q31_t)0x4d595bfe, (q31_t)0x9a039c57, (q31_t)0x4d455422, (q31_t)0x99f46e51, - (q31_t)0x4d31494b, (q31_t)0x99e5443b, (q31_t)0x4d1d3b7a, (q31_t)0x99d61e14, (q31_t)0x4d092ab0, (q31_t)0x99c6fbde, (q31_t)0x4cf516ee, (q31_t)0x99b7dd99, - (q31_t)0x4ce10034, (q31_t)0x99a8c345, (q31_t)0x4ccce684, (q31_t)0x9999ace3, (q31_t)0x4cb8c9dd, (q31_t)0x998a9a74, (q31_t)0x4ca4aa41, (q31_t)0x997b8bf8, - (q31_t)0x4c9087b1, (q31_t)0x996c816f, (q31_t)0x4c7c622d, (q31_t)0x995d7adc, (q31_t)0x4c6839b7, (q31_t)0x994e783d, (q31_t)0x4c540e4e, (q31_t)0x993f7993, - (q31_t)0x4c3fdff4, (q31_t)0x99307ee0, (q31_t)0x4c2baea9, (q31_t)0x99218824, (q31_t)0x4c177a6e, (q31_t)0x9912955f, (q31_t)0x4c034345, (q31_t)0x9903a691, - (q31_t)0x4bef092d, (q31_t)0x98f4bbbc, (q31_t)0x4bdacc28, (q31_t)0x98e5d4e0, (q31_t)0x4bc68c36, (q31_t)0x98d6f1fe, (q31_t)0x4bb24958, (q31_t)0x98c81316, - (q31_t)0x4b9e0390, (q31_t)0x98b93828, (q31_t)0x4b89badd, (q31_t)0x98aa6136, (q31_t)0x4b756f40, (q31_t)0x989b8e40, (q31_t)0x4b6120bb, (q31_t)0x988cbf46, - (q31_t)0x4b4ccf4d, (q31_t)0x987df449, (q31_t)0x4b387af9, (q31_t)0x986f2d4a, (q31_t)0x4b2423be, (q31_t)0x98606a49, (q31_t)0x4b0fc99d, (q31_t)0x9851ab46, - (q31_t)0x4afb6c98, (q31_t)0x9842f043, (q31_t)0x4ae70caf, (q31_t)0x98343940, (q31_t)0x4ad2a9e2, (q31_t)0x9825863d, (q31_t)0x4abe4433, (q31_t)0x9816d73b, - (q31_t)0x4aa9dba2, (q31_t)0x98082c3b, (q31_t)0x4a957030, (q31_t)0x97f9853d, (q31_t)0x4a8101de, (q31_t)0x97eae242, (q31_t)0x4a6c90ad, (q31_t)0x97dc4349, - (q31_t)0x4a581c9e, (q31_t)0x97cda855, (q31_t)0x4a43a5b0, (q31_t)0x97bf1165, (q31_t)0x4a2f2be6, (q31_t)0x97b07e7a, (q31_t)0x4a1aaf3f, (q31_t)0x97a1ef94, - (q31_t)0x4a062fbd, (q31_t)0x979364b5, (q31_t)0x49f1ad61, (q31_t)0x9784dddc, (q31_t)0x49dd282a, (q31_t)0x97765b0a, (q31_t)0x49c8a01b, (q31_t)0x9767dc41, - (q31_t)0x49b41533, (q31_t)0x9759617f, (q31_t)0x499f8774, (q31_t)0x974aeac6, (q31_t)0x498af6df, (q31_t)0x973c7817, (q31_t)0x49766373, (q31_t)0x972e0971, - (q31_t)0x4961cd33, (q31_t)0x971f9ed7, (q31_t)0x494d341e, (q31_t)0x97113847, (q31_t)0x49389836, (q31_t)0x9702d5c3, (q31_t)0x4923f97b, (q31_t)0x96f4774b, - (q31_t)0x490f57ee, (q31_t)0x96e61ce0, (q31_t)0x48fab391, (q31_t)0x96d7c682, (q31_t)0x48e60c62, (q31_t)0x96c97432, (q31_t)0x48d16265, (q31_t)0x96bb25f0, - (q31_t)0x48bcb599, (q31_t)0x96acdbbe, (q31_t)0x48a805ff, (q31_t)0x969e959b, (q31_t)0x48935397, (q31_t)0x96905388, (q31_t)0x487e9e64, (q31_t)0x96821585, - (q31_t)0x4869e665, (q31_t)0x9673db94, (q31_t)0x48552b9b, (q31_t)0x9665a5b4, (q31_t)0x48406e08, (q31_t)0x965773e7, (q31_t)0x482badab, (q31_t)0x9649462d, - (q31_t)0x4816ea86, (q31_t)0x963b1c86, (q31_t)0x48022499, (q31_t)0x962cf6f2, (q31_t)0x47ed5be6, (q31_t)0x961ed574, (q31_t)0x47d8906d, (q31_t)0x9610b80a, - (q31_t)0x47c3c22f, (q31_t)0x96029eb6, (q31_t)0x47aef12c, (q31_t)0x95f48977, (q31_t)0x479a1d67, (q31_t)0x95e67850, (q31_t)0x478546de, (q31_t)0x95d86b3f, - (q31_t)0x47706d93, (q31_t)0x95ca6247, (q31_t)0x475b9188, (q31_t)0x95bc5d66, (q31_t)0x4746b2bc, (q31_t)0x95ae5c9f, (q31_t)0x4731d131, (q31_t)0x95a05ff0, - (q31_t)0x471cece7, (q31_t)0x9592675c, (q31_t)0x470805df, (q31_t)0x958472e2, (q31_t)0x46f31c1a, (q31_t)0x95768283, (q31_t)0x46de2f99, (q31_t)0x9568963f, - (q31_t)0x46c9405c, (q31_t)0x955aae17, (q31_t)0x46b44e65, (q31_t)0x954cca0c, (q31_t)0x469f59b4, (q31_t)0x953eea1e, (q31_t)0x468a624a, (q31_t)0x95310e4e, - (q31_t)0x46756828, (q31_t)0x9523369c, (q31_t)0x46606b4e, (q31_t)0x95156308, (q31_t)0x464b6bbe, (q31_t)0x95079394, (q31_t)0x46366978, (q31_t)0x94f9c83f, - (q31_t)0x4621647d, (q31_t)0x94ec010b, (q31_t)0x460c5cce, (q31_t)0x94de3df8, (q31_t)0x45f7526b, (q31_t)0x94d07f05, (q31_t)0x45e24556, (q31_t)0x94c2c435, - (q31_t)0x45cd358f, (q31_t)0x94b50d87, (q31_t)0x45b82318, (q31_t)0x94a75afd, (q31_t)0x45a30df0, (q31_t)0x9499ac95, (q31_t)0x458df619, (q31_t)0x948c0252, - (q31_t)0x4578db93, (q31_t)0x947e5c33, (q31_t)0x4563be60, (q31_t)0x9470ba39, (q31_t)0x454e9e80, (q31_t)0x94631c65, (q31_t)0x45397bf4, (q31_t)0x945582b7, - (q31_t)0x452456bd, (q31_t)0x9447ed2f, (q31_t)0x450f2edb, (q31_t)0x943a5bcf, (q31_t)0x44fa0450, (q31_t)0x942cce96, (q31_t)0x44e4d71c, (q31_t)0x941f4585, - (q31_t)0x44cfa740, (q31_t)0x9411c09e, (q31_t)0x44ba74bd, (q31_t)0x94043fdf, (q31_t)0x44a53f93, (q31_t)0x93f6c34a, (q31_t)0x449007c4, (q31_t)0x93e94adf, - (q31_t)0x447acd50, (q31_t)0x93dbd6a0, (q31_t)0x44659039, (q31_t)0x93ce668b, (q31_t)0x4450507e, (q31_t)0x93c0faa3, (q31_t)0x443b0e21, (q31_t)0x93b392e6, - (q31_t)0x4425c923, (q31_t)0x93a62f57, (q31_t)0x44108184, (q31_t)0x9398cff5, (q31_t)0x43fb3746, (q31_t)0x938b74c1, (q31_t)0x43e5ea68, (q31_t)0x937e1dbb, - (q31_t)0x43d09aed, (q31_t)0x9370cae4, (q31_t)0x43bb48d4, (q31_t)0x93637c3d, (q31_t)0x43a5f41e, (q31_t)0x935631c5, (q31_t)0x43909ccd, (q31_t)0x9348eb7e, - (q31_t)0x437b42e1, (q31_t)0x933ba968, (q31_t)0x4365e65b, (q31_t)0x932e6b84, (q31_t)0x4350873c, (q31_t)0x932131d1, (q31_t)0x433b2585, (q31_t)0x9313fc51, - (q31_t)0x4325c135, (q31_t)0x9306cb04, (q31_t)0x43105a50, (q31_t)0x92f99deb, (q31_t)0x42faf0d4, (q31_t)0x92ec7505, (q31_t)0x42e584c3, (q31_t)0x92df5054, - (q31_t)0x42d0161e, (q31_t)0x92d22fd9, (q31_t)0x42baa4e6, (q31_t)0x92c51392, (q31_t)0x42a5311b, (q31_t)0x92b7fb82, (q31_t)0x428fbabe, (q31_t)0x92aae7a8, - (q31_t)0x427a41d0, (q31_t)0x929dd806, (q31_t)0x4264c653, (q31_t)0x9290cc9b, (q31_t)0x424f4845, (q31_t)0x9283c568, (q31_t)0x4239c7aa, (q31_t)0x9276c26d, - (q31_t)0x42244481, (q31_t)0x9269c3ac, (q31_t)0x420ebecb, (q31_t)0x925cc924, (q31_t)0x41f93689, (q31_t)0x924fd2d7, (q31_t)0x41e3abbc, (q31_t)0x9242e0c4, - (q31_t)0x41ce1e65, (q31_t)0x9235f2ec, (q31_t)0x41b88e84, (q31_t)0x9229094f, (q31_t)0x41a2fc1a, (q31_t)0x921c23ef, (q31_t)0x418d6729, (q31_t)0x920f42cb, - (q31_t)0x4177cfb1, (q31_t)0x920265e4, (q31_t)0x416235b2, (q31_t)0x91f58d3b, (q31_t)0x414c992f, (q31_t)0x91e8b8d0, (q31_t)0x4136fa27, (q31_t)0x91dbe8a4, - (q31_t)0x4121589b, (q31_t)0x91cf1cb6, (q31_t)0x410bb48c, (q31_t)0x91c25508, (q31_t)0x40f60dfb, (q31_t)0x91b5919a, (q31_t)0x40e064ea, (q31_t)0x91a8d26d, - (q31_t)0x40cab958, (q31_t)0x919c1781, (q31_t)0x40b50b46, (q31_t)0x918f60d6, (q31_t)0x409f5ab6, (q31_t)0x9182ae6d, (q31_t)0x4089a7a8, (q31_t)0x91760047, - (q31_t)0x4073f21d, (q31_t)0x91695663, (q31_t)0x405e3a16, (q31_t)0x915cb0c3, (q31_t)0x40487f94, (q31_t)0x91500f67, (q31_t)0x4032c297, (q31_t)0x91437250, - (q31_t)0x401d0321, (q31_t)0x9136d97d, (q31_t)0x40074132, (q31_t)0x912a44f0, (q31_t)0x3ff17cca, (q31_t)0x911db4a9, (q31_t)0x3fdbb5ec, (q31_t)0x911128a8, - (q31_t)0x3fc5ec98, (q31_t)0x9104a0ee, (q31_t)0x3fb020ce, (q31_t)0x90f81d7b, (q31_t)0x3f9a5290, (q31_t)0x90eb9e50, (q31_t)0x3f8481dd, (q31_t)0x90df236e, - (q31_t)0x3f6eaeb8, (q31_t)0x90d2acd4, (q31_t)0x3f58d921, (q31_t)0x90c63a83, (q31_t)0x3f430119, (q31_t)0x90b9cc7d, (q31_t)0x3f2d26a0, (q31_t)0x90ad62c0, - (q31_t)0x3f1749b8, (q31_t)0x90a0fd4e, (q31_t)0x3f016a61, (q31_t)0x90949c28, (q31_t)0x3eeb889c, (q31_t)0x90883f4d, (q31_t)0x3ed5a46b, (q31_t)0x907be6be, - (q31_t)0x3ebfbdcd, (q31_t)0x906f927c, (q31_t)0x3ea9d4c3, (q31_t)0x90634287, (q31_t)0x3e93e950, (q31_t)0x9056f6df, (q31_t)0x3e7dfb73, (q31_t)0x904aaf86, - (q31_t)0x3e680b2c, (q31_t)0x903e6c7b, (q31_t)0x3e52187f, (q31_t)0x90322dbf, (q31_t)0x3e3c2369, (q31_t)0x9025f352, (q31_t)0x3e262bee, (q31_t)0x9019bd36, - (q31_t)0x3e10320d, (q31_t)0x900d8b69, (q31_t)0x3dfa35c8, (q31_t)0x90015dee, (q31_t)0x3de4371f, (q31_t)0x8ff534c4, (q31_t)0x3dce3614, (q31_t)0x8fe90fec, - (q31_t)0x3db832a6, (q31_t)0x8fdcef66, (q31_t)0x3da22cd7, (q31_t)0x8fd0d333, (q31_t)0x3d8c24a8, (q31_t)0x8fc4bb53, (q31_t)0x3d761a19, (q31_t)0x8fb8a7c7, - (q31_t)0x3d600d2c, (q31_t)0x8fac988f, (q31_t)0x3d49fde1, (q31_t)0x8fa08dab, (q31_t)0x3d33ec39, (q31_t)0x8f94871d, (q31_t)0x3d1dd835, (q31_t)0x8f8884e4, - (q31_t)0x3d07c1d6, (q31_t)0x8f7c8701, (q31_t)0x3cf1a91c, (q31_t)0x8f708d75, (q31_t)0x3cdb8e09, (q31_t)0x8f649840, (q31_t)0x3cc5709e, (q31_t)0x8f58a761, - (q31_t)0x3caf50da, (q31_t)0x8f4cbadb, (q31_t)0x3c992ec0, (q31_t)0x8f40d2ad, (q31_t)0x3c830a50, (q31_t)0x8f34eed8, (q31_t)0x3c6ce38a, (q31_t)0x8f290f5c, - (q31_t)0x3c56ba70, (q31_t)0x8f1d343a, (q31_t)0x3c408f03, (q31_t)0x8f115d72, (q31_t)0x3c2a6142, (q31_t)0x8f058b04, (q31_t)0x3c143130, (q31_t)0x8ef9bcf2, - (q31_t)0x3bfdfecd, (q31_t)0x8eedf33b, (q31_t)0x3be7ca1a, (q31_t)0x8ee22de0, (q31_t)0x3bd19318, (q31_t)0x8ed66ce1, (q31_t)0x3bbb59c7, (q31_t)0x8ecab040, - (q31_t)0x3ba51e29, (q31_t)0x8ebef7fb, (q31_t)0x3b8ee03e, (q31_t)0x8eb34415, (q31_t)0x3b78a007, (q31_t)0x8ea7948c, (q31_t)0x3b625d86, (q31_t)0x8e9be963, - (q31_t)0x3b4c18ba, (q31_t)0x8e904298, (q31_t)0x3b35d1a5, (q31_t)0x8e84a02d, (q31_t)0x3b1f8848, (q31_t)0x8e790222, (q31_t)0x3b093ca3, (q31_t)0x8e6d6877, - (q31_t)0x3af2eeb7, (q31_t)0x8e61d32e, (q31_t)0x3adc9e86, (q31_t)0x8e564246, (q31_t)0x3ac64c0f, (q31_t)0x8e4ab5bf, (q31_t)0x3aaff755, (q31_t)0x8e3f2d9b, - (q31_t)0x3a99a057, (q31_t)0x8e33a9da, (q31_t)0x3a834717, (q31_t)0x8e282a7b, (q31_t)0x3a6ceb96, (q31_t)0x8e1caf80, (q31_t)0x3a568dd4, (q31_t)0x8e1138ea, - (q31_t)0x3a402dd2, (q31_t)0x8e05c6b7, (q31_t)0x3a29cb91, (q31_t)0x8dfa58ea, (q31_t)0x3a136712, (q31_t)0x8deeef82, (q31_t)0x39fd0056, (q31_t)0x8de38a80, - (q31_t)0x39e6975e, (q31_t)0x8dd829e4, (q31_t)0x39d02c2a, (q31_t)0x8dcccdaf, (q31_t)0x39b9bebc, (q31_t)0x8dc175e0, (q31_t)0x39a34f13, (q31_t)0x8db6227a, - (q31_t)0x398cdd32, (q31_t)0x8daad37b, (q31_t)0x39766919, (q31_t)0x8d9f88e5, (q31_t)0x395ff2c9, (q31_t)0x8d9442b8, (q31_t)0x39497a43, (q31_t)0x8d8900f3, - (q31_t)0x3932ff87, (q31_t)0x8d7dc399, (q31_t)0x391c8297, (q31_t)0x8d728aa9, (q31_t)0x39060373, (q31_t)0x8d675623, (q31_t)0x38ef821c, (q31_t)0x8d5c2609, - (q31_t)0x38d8fe93, (q31_t)0x8d50fa59, (q31_t)0x38c278d9, (q31_t)0x8d45d316, (q31_t)0x38abf0ef, (q31_t)0x8d3ab03f, (q31_t)0x389566d6, (q31_t)0x8d2f91d5, - (q31_t)0x387eda8e, (q31_t)0x8d2477d8, (q31_t)0x38684c19, (q31_t)0x8d196249, (q31_t)0x3851bb77, (q31_t)0x8d0e5127, (q31_t)0x383b28a9, (q31_t)0x8d034474, - (q31_t)0x382493b0, (q31_t)0x8cf83c30, (q31_t)0x380dfc8d, (q31_t)0x8ced385b, (q31_t)0x37f76341, (q31_t)0x8ce238f6, (q31_t)0x37e0c7cc, (q31_t)0x8cd73e01, - (q31_t)0x37ca2a30, (q31_t)0x8ccc477d, (q31_t)0x37b38a6d, (q31_t)0x8cc1556a, (q31_t)0x379ce885, (q31_t)0x8cb667c8, (q31_t)0x37864477, (q31_t)0x8cab7e98, - (q31_t)0x376f9e46, (q31_t)0x8ca099da, (q31_t)0x3758f5f2, (q31_t)0x8c95b98f, (q31_t)0x37424b7b, (q31_t)0x8c8addb7, (q31_t)0x372b9ee3, (q31_t)0x8c800652, - (q31_t)0x3714f02a, (q31_t)0x8c753362, (q31_t)0x36fe3f52, (q31_t)0x8c6a64e5, (q31_t)0x36e78c5b, (q31_t)0x8c5f9ade, (q31_t)0x36d0d746, (q31_t)0x8c54d54c, - (q31_t)0x36ba2014, (q31_t)0x8c4a142f, (q31_t)0x36a366c6, (q31_t)0x8c3f5788, (q31_t)0x368cab5c, (q31_t)0x8c349f58, (q31_t)0x3675edd9, (q31_t)0x8c29eb9f, - (q31_t)0x365f2e3b, (q31_t)0x8c1f3c5d, (q31_t)0x36486c86, (q31_t)0x8c149192, (q31_t)0x3631a8b8, (q31_t)0x8c09eb40, (q31_t)0x361ae2d3, (q31_t)0x8bff4966, - (q31_t)0x36041ad9, (q31_t)0x8bf4ac05, (q31_t)0x35ed50c9, (q31_t)0x8bea131e, (q31_t)0x35d684a6, (q31_t)0x8bdf7eb0, (q31_t)0x35bfb66e, (q31_t)0x8bd4eebc, - (q31_t)0x35a8e625, (q31_t)0x8bca6343, (q31_t)0x359213c9, (q31_t)0x8bbfdc44, (q31_t)0x357b3f5d, (q31_t)0x8bb559c1, (q31_t)0x356468e2, (q31_t)0x8baadbba, - (q31_t)0x354d9057, (q31_t)0x8ba0622f, (q31_t)0x3536b5be, (q31_t)0x8b95ed21, (q31_t)0x351fd918, (q31_t)0x8b8b7c8f, (q31_t)0x3508fa66, (q31_t)0x8b81107b, - (q31_t)0x34f219a8, (q31_t)0x8b76a8e4, (q31_t)0x34db36df, (q31_t)0x8b6c45cc, (q31_t)0x34c4520d, (q31_t)0x8b61e733, (q31_t)0x34ad6b32, (q31_t)0x8b578d18, - (q31_t)0x34968250, (q31_t)0x8b4d377c, (q31_t)0x347f9766, (q31_t)0x8b42e661, (q31_t)0x3468aa76, (q31_t)0x8b3899c6, (q31_t)0x3451bb81, (q31_t)0x8b2e51ab, - (q31_t)0x343aca87, (q31_t)0x8b240e11, (q31_t)0x3423d78a, (q31_t)0x8b19cef8, (q31_t)0x340ce28b, (q31_t)0x8b0f9462, (q31_t)0x33f5eb89, (q31_t)0x8b055e4d, - (q31_t)0x33def287, (q31_t)0x8afb2cbb, (q31_t)0x33c7f785, (q31_t)0x8af0ffac, (q31_t)0x33b0fa84, (q31_t)0x8ae6d720, (q31_t)0x3399fb85, (q31_t)0x8adcb318, - (q31_t)0x3382fa88, (q31_t)0x8ad29394, (q31_t)0x336bf78f, (q31_t)0x8ac87894, (q31_t)0x3354f29b, (q31_t)0x8abe6219, (q31_t)0x333debab, (q31_t)0x8ab45024, - (q31_t)0x3326e2c3, (q31_t)0x8aaa42b4, (q31_t)0x330fd7e1, (q31_t)0x8aa039cb, (q31_t)0x32f8cb07, (q31_t)0x8a963567, (q31_t)0x32e1bc36, (q31_t)0x8a8c358b, - (q31_t)0x32caab6f, (q31_t)0x8a823a36, (q31_t)0x32b398b3, (q31_t)0x8a784368, (q31_t)0x329c8402, (q31_t)0x8a6e5123, (q31_t)0x32856d5e, (q31_t)0x8a646365, - (q31_t)0x326e54c7, (q31_t)0x8a5a7a31, (q31_t)0x32573a3f, (q31_t)0x8a509585, (q31_t)0x32401dc6, (q31_t)0x8a46b564, (q31_t)0x3228ff5c, (q31_t)0x8a3cd9cc, - (q31_t)0x3211df04, (q31_t)0x8a3302be, (q31_t)0x31fabcbd, (q31_t)0x8a29303b, (q31_t)0x31e39889, (q31_t)0x8a1f6243, (q31_t)0x31cc7269, (q31_t)0x8a1598d6, - (q31_t)0x31b54a5e, (q31_t)0x8a0bd3f5, (q31_t)0x319e2067, (q31_t)0x8a0213a0, (q31_t)0x3186f487, (q31_t)0x89f857d8, (q31_t)0x316fc6be, (q31_t)0x89eea09d, - (q31_t)0x3158970e, (q31_t)0x89e4edef, (q31_t)0x31416576, (q31_t)0x89db3fcf, (q31_t)0x312a31f8, (q31_t)0x89d1963c, (q31_t)0x3112fc95, (q31_t)0x89c7f138, - (q31_t)0x30fbc54d, (q31_t)0x89be50c3, (q31_t)0x30e48c22, (q31_t)0x89b4b4dd, (q31_t)0x30cd5115, (q31_t)0x89ab1d87, (q31_t)0x30b61426, (q31_t)0x89a18ac0, - (q31_t)0x309ed556, (q31_t)0x8997fc8a, (q31_t)0x308794a6, (q31_t)0x898e72e4, (q31_t)0x30705217, (q31_t)0x8984edcf, (q31_t)0x30590dab, (q31_t)0x897b6d4c, - (q31_t)0x3041c761, (q31_t)0x8971f15a, (q31_t)0x302a7f3a, (q31_t)0x896879fb, (q31_t)0x30133539, (q31_t)0x895f072e, (q31_t)0x2ffbe95d, (q31_t)0x895598f3, - (q31_t)0x2fe49ba7, (q31_t)0x894c2f4c, (q31_t)0x2fcd4c19, (q31_t)0x8942ca39, (q31_t)0x2fb5fab2, (q31_t)0x893969b9, (q31_t)0x2f9ea775, (q31_t)0x89300dce, - (q31_t)0x2f875262, (q31_t)0x8926b677, (q31_t)0x2f6ffb7a, (q31_t)0x891d63b5, (q31_t)0x2f58a2be, (q31_t)0x89141589, (q31_t)0x2f41482e, (q31_t)0x890acbf2, - (q31_t)0x2f29ebcc, (q31_t)0x890186f2, (q31_t)0x2f128d99, (q31_t)0x88f84687, (q31_t)0x2efb2d95, (q31_t)0x88ef0ab4, (q31_t)0x2ee3cbc1, (q31_t)0x88e5d378, - (q31_t)0x2ecc681e, (q31_t)0x88dca0d3, (q31_t)0x2eb502ae, (q31_t)0x88d372c6, (q31_t)0x2e9d9b70, (q31_t)0x88ca4951, (q31_t)0x2e863267, (q31_t)0x88c12475, - (q31_t)0x2e6ec792, (q31_t)0x88b80432, (q31_t)0x2e575af3, (q31_t)0x88aee888, (q31_t)0x2e3fec8b, (q31_t)0x88a5d177, (q31_t)0x2e287c5a, (q31_t)0x889cbf01, - (q31_t)0x2e110a62, (q31_t)0x8893b125, (q31_t)0x2df996a3, (q31_t)0x888aa7e3, (q31_t)0x2de2211e, (q31_t)0x8881a33d, (q31_t)0x2dcaa9d5, (q31_t)0x8878a332, - (q31_t)0x2db330c7, (q31_t)0x886fa7c2, (q31_t)0x2d9bb5f6, (q31_t)0x8866b0ef, (q31_t)0x2d843964, (q31_t)0x885dbeb8, (q31_t)0x2d6cbb10, (q31_t)0x8854d11e, - (q31_t)0x2d553afc, (q31_t)0x884be821, (q31_t)0x2d3db928, (q31_t)0x884303c1, (q31_t)0x2d263596, (q31_t)0x883a23ff, (q31_t)0x2d0eb046, (q31_t)0x883148db, - (q31_t)0x2cf72939, (q31_t)0x88287256, (q31_t)0x2cdfa071, (q31_t)0x881fa06f, (q31_t)0x2cc815ee, (q31_t)0x8816d327, (q31_t)0x2cb089b1, (q31_t)0x880e0a7f, - (q31_t)0x2c98fbba, (q31_t)0x88054677, (q31_t)0x2c816c0c, (q31_t)0x87fc870f, (q31_t)0x2c69daa6, (q31_t)0x87f3cc48, (q31_t)0x2c52478a, (q31_t)0x87eb1621, - (q31_t)0x2c3ab2b9, (q31_t)0x87e2649b, (q31_t)0x2c231c33, (q31_t)0x87d9b7b7, (q31_t)0x2c0b83fa, (q31_t)0x87d10f75, (q31_t)0x2bf3ea0d, (q31_t)0x87c86bd5, - (q31_t)0x2bdc4e6f, (q31_t)0x87bfccd7, (q31_t)0x2bc4b120, (q31_t)0x87b7327d, (q31_t)0x2bad1221, (q31_t)0x87ae9cc5, (q31_t)0x2b957173, (q31_t)0x87a60bb1, - (q31_t)0x2b7dcf17, (q31_t)0x879d7f41, (q31_t)0x2b662b0e, (q31_t)0x8794f774, (q31_t)0x2b4e8558, (q31_t)0x878c744d, (q31_t)0x2b36ddf7, (q31_t)0x8783f5ca, - (q31_t)0x2b1f34eb, (q31_t)0x877b7bec, (q31_t)0x2b078a36, (q31_t)0x877306b4, (q31_t)0x2aefddd8, (q31_t)0x876a9621, (q31_t)0x2ad82fd2, (q31_t)0x87622a35, - (q31_t)0x2ac08026, (q31_t)0x8759c2ef, (q31_t)0x2aa8ced3, (q31_t)0x87516050, (q31_t)0x2a911bdc, (q31_t)0x87490258, (q31_t)0x2a796740, (q31_t)0x8740a907, - (q31_t)0x2a61b101, (q31_t)0x8738545e, (q31_t)0x2a49f920, (q31_t)0x8730045d, (q31_t)0x2a323f9e, (q31_t)0x8727b905, (q31_t)0x2a1a847b, (q31_t)0x871f7255, - (q31_t)0x2a02c7b8, (q31_t)0x8717304e, (q31_t)0x29eb0957, (q31_t)0x870ef2f1, (q31_t)0x29d34958, (q31_t)0x8706ba3d, (q31_t)0x29bb87bc, (q31_t)0x86fe8633, - (q31_t)0x29a3c485, (q31_t)0x86f656d3, (q31_t)0x298bffb2, (q31_t)0x86ee2c1e, (q31_t)0x29743946, (q31_t)0x86e60614, (q31_t)0x295c7140, (q31_t)0x86dde4b5, - (q31_t)0x2944a7a2, (q31_t)0x86d5c802, (q31_t)0x292cdc6d, (q31_t)0x86cdaffa, (q31_t)0x29150fa1, (q31_t)0x86c59c9f, (q31_t)0x28fd4140, (q31_t)0x86bd8df0, - (q31_t)0x28e5714b, (q31_t)0x86b583ee, (q31_t)0x28cd9fc1, (q31_t)0x86ad7e99, (q31_t)0x28b5cca5, (q31_t)0x86a57df2, (q31_t)0x289df7f8, (q31_t)0x869d81f8, - (q31_t)0x288621b9, (q31_t)0x86958aac, (q31_t)0x286e49ea, (q31_t)0x868d980e, (q31_t)0x2856708d, (q31_t)0x8685aa20, (q31_t)0x283e95a1, (q31_t)0x867dc0e0, - (q31_t)0x2826b928, (q31_t)0x8675dc4f, (q31_t)0x280edb23, (q31_t)0x866dfc6e, (q31_t)0x27f6fb92, (q31_t)0x8666213c, (q31_t)0x27df1a77, (q31_t)0x865e4abb, - (q31_t)0x27c737d3, (q31_t)0x865678eb, (q31_t)0x27af53a6, (q31_t)0x864eabcb, (q31_t)0x27976df1, (q31_t)0x8646e35c, (q31_t)0x277f86b5, (q31_t)0x863f1f9e, - (q31_t)0x27679df4, (q31_t)0x86376092, (q31_t)0x274fb3ae, (q31_t)0x862fa638, (q31_t)0x2737c7e3, (q31_t)0x8627f091, (q31_t)0x271fda96, (q31_t)0x86203f9c, - (q31_t)0x2707ebc7, (q31_t)0x86189359, (q31_t)0x26effb76, (q31_t)0x8610ebca, (q31_t)0x26d809a5, (q31_t)0x860948ef, (q31_t)0x26c01655, (q31_t)0x8601aac7, - (q31_t)0x26a82186, (q31_t)0x85fa1153, (q31_t)0x26902b39, (q31_t)0x85f27c93, (q31_t)0x26783370, (q31_t)0x85eaec88, (q31_t)0x26603a2c, (q31_t)0x85e36132, - (q31_t)0x26483f6c, (q31_t)0x85dbda91, (q31_t)0x26304333, (q31_t)0x85d458a6, (q31_t)0x26184581, (q31_t)0x85ccdb70, (q31_t)0x26004657, (q31_t)0x85c562f1, - (q31_t)0x25e845b6, (q31_t)0x85bdef28, (q31_t)0x25d0439f, (q31_t)0x85b68015, (q31_t)0x25b84012, (q31_t)0x85af15b9, (q31_t)0x25a03b11, (q31_t)0x85a7b015, - (q31_t)0x2588349d, (q31_t)0x85a04f28, (q31_t)0x25702cb7, (q31_t)0x8598f2f3, (q31_t)0x2558235f, (q31_t)0x85919b76, (q31_t)0x25401896, (q31_t)0x858a48b1, - (q31_t)0x25280c5e, (q31_t)0x8582faa5, (q31_t)0x250ffeb7, (q31_t)0x857bb152, (q31_t)0x24f7efa2, (q31_t)0x85746cb8, (q31_t)0x24dfdf20, (q31_t)0x856d2cd7, - (q31_t)0x24c7cd33, (q31_t)0x8565f1b0, (q31_t)0x24afb9da, (q31_t)0x855ebb44, (q31_t)0x2497a517, (q31_t)0x85578991, (q31_t)0x247f8eec, (q31_t)0x85505c99, - (q31_t)0x24677758, (q31_t)0x8549345c, (q31_t)0x244f5e5c, (q31_t)0x854210db, (q31_t)0x243743fa, (q31_t)0x853af214, (q31_t)0x241f2833, (q31_t)0x8533d809, - (q31_t)0x24070b08, (q31_t)0x852cc2bb, (q31_t)0x23eeec78, (q31_t)0x8525b228, (q31_t)0x23d6cc87, (q31_t)0x851ea652, (q31_t)0x23beab33, (q31_t)0x85179f39, - (q31_t)0x23a6887f, (q31_t)0x85109cdd, (q31_t)0x238e646a, (q31_t)0x85099f3e, (q31_t)0x23763ef7, (q31_t)0x8502a65c, (q31_t)0x235e1826, (q31_t)0x84fbb239, - (q31_t)0x2345eff8, (q31_t)0x84f4c2d4, (q31_t)0x232dc66d, (q31_t)0x84edd82d, (q31_t)0x23159b88, (q31_t)0x84e6f244, (q31_t)0x22fd6f48, (q31_t)0x84e0111b, - (q31_t)0x22e541af, (q31_t)0x84d934b1, (q31_t)0x22cd12bd, (q31_t)0x84d25d06, (q31_t)0x22b4e274, (q31_t)0x84cb8a1b, (q31_t)0x229cb0d5, (q31_t)0x84c4bbf0, - (q31_t)0x22847de0, (q31_t)0x84bdf286, (q31_t)0x226c4996, (q31_t)0x84b72ddb, (q31_t)0x225413f8, (q31_t)0x84b06df2, (q31_t)0x223bdd08, (q31_t)0x84a9b2ca, - (q31_t)0x2223a4c5, (q31_t)0x84a2fc62, (q31_t)0x220b6b32, (q31_t)0x849c4abd, (q31_t)0x21f3304f, (q31_t)0x84959dd9, (q31_t)0x21daf41d, (q31_t)0x848ef5b7, - (q31_t)0x21c2b69c, (q31_t)0x84885258, (q31_t)0x21aa77cf, (q31_t)0x8481b3bb, (q31_t)0x219237b5, (q31_t)0x847b19e1, (q31_t)0x2179f64f, (q31_t)0x847484ca, - (q31_t)0x2161b3a0, (q31_t)0x846df477, (q31_t)0x21496fa7, (q31_t)0x846768e7, (q31_t)0x21312a65, (q31_t)0x8460e21a, (q31_t)0x2118e3dc, (q31_t)0x845a6012, - (q31_t)0x21009c0c, (q31_t)0x8453e2cf, (q31_t)0x20e852f6, (q31_t)0x844d6a50, (q31_t)0x20d0089c, (q31_t)0x8446f695, (q31_t)0x20b7bcfe, (q31_t)0x844087a0, - (q31_t)0x209f701c, (q31_t)0x843a1d70, (q31_t)0x208721f9, (q31_t)0x8433b806, (q31_t)0x206ed295, (q31_t)0x842d5762, (q31_t)0x205681f1, (q31_t)0x8426fb84, - (q31_t)0x203e300d, (q31_t)0x8420a46c, (q31_t)0x2025dcec, (q31_t)0x841a521a, (q31_t)0x200d888d, (q31_t)0x84140490, (q31_t)0x1ff532f2, (q31_t)0x840dbbcc, - (q31_t)0x1fdcdc1b, (q31_t)0x840777d0, (q31_t)0x1fc4840a, (q31_t)0x8401389b, (q31_t)0x1fac2abf, (q31_t)0x83fafe2e, (q31_t)0x1f93d03c, (q31_t)0x83f4c889, - (q31_t)0x1f7b7481, (q31_t)0x83ee97ad, (q31_t)0x1f63178f, (q31_t)0x83e86b99, (q31_t)0x1f4ab968, (q31_t)0x83e2444d, (q31_t)0x1f325a0b, (q31_t)0x83dc21cb, - (q31_t)0x1f19f97b, (q31_t)0x83d60412, (q31_t)0x1f0197b8, (q31_t)0x83cfeb22, (q31_t)0x1ee934c3, (q31_t)0x83c9d6fc, (q31_t)0x1ed0d09d, (q31_t)0x83c3c7a0, - (q31_t)0x1eb86b46, (q31_t)0x83bdbd0e, (q31_t)0x1ea004c1, (q31_t)0x83b7b746, (q31_t)0x1e879d0d, (q31_t)0x83b1b649, (q31_t)0x1e6f342c, (q31_t)0x83abba17, - (q31_t)0x1e56ca1e, (q31_t)0x83a5c2b0, (q31_t)0x1e3e5ee5, (q31_t)0x839fd014, (q31_t)0x1e25f282, (q31_t)0x8399e244, (q31_t)0x1e0d84f5, (q31_t)0x8393f940, - (q31_t)0x1df5163f, (q31_t)0x838e1507, (q31_t)0x1ddca662, (q31_t)0x8388359b, (q31_t)0x1dc4355e, (q31_t)0x83825afb, (q31_t)0x1dabc334, (q31_t)0x837c8528, - (q31_t)0x1d934fe5, (q31_t)0x8376b422, (q31_t)0x1d7adb73, (q31_t)0x8370e7e9, (q31_t)0x1d6265dd, (q31_t)0x836b207d, (q31_t)0x1d49ef26, (q31_t)0x83655ddf, - (q31_t)0x1d31774d, (q31_t)0x835fa00f, (q31_t)0x1d18fe54, (q31_t)0x8359e70d, (q31_t)0x1d00843d, (q31_t)0x835432d8, (q31_t)0x1ce80906, (q31_t)0x834e8373, - (q31_t)0x1ccf8cb3, (q31_t)0x8348d8dc, (q31_t)0x1cb70f43, (q31_t)0x83433314, (q31_t)0x1c9e90b8, (q31_t)0x833d921b, (q31_t)0x1c861113, (q31_t)0x8337f5f1, - (q31_t)0x1c6d9053, (q31_t)0x83325e97, (q31_t)0x1c550e7c, (q31_t)0x832ccc0d, (q31_t)0x1c3c8b8c, (q31_t)0x83273e52, (q31_t)0x1c240786, (q31_t)0x8321b568, - (q31_t)0x1c0b826a, (q31_t)0x831c314e, (q31_t)0x1bf2fc3a, (q31_t)0x8316b205, (q31_t)0x1bda74f6, (q31_t)0x8311378d, (q31_t)0x1bc1ec9e, (q31_t)0x830bc1e6, - (q31_t)0x1ba96335, (q31_t)0x83065110, (q31_t)0x1b90d8bb, (q31_t)0x8300e50b, (q31_t)0x1b784d30, (q31_t)0x82fb7dd8, (q31_t)0x1b5fc097, (q31_t)0x82f61b77, - (q31_t)0x1b4732ef, (q31_t)0x82f0bde8, (q31_t)0x1b2ea43a, (q31_t)0x82eb652b, (q31_t)0x1b161479, (q31_t)0x82e61141, (q31_t)0x1afd83ad, (q31_t)0x82e0c22a, - (q31_t)0x1ae4f1d6, (q31_t)0x82db77e5, (q31_t)0x1acc5ef6, (q31_t)0x82d63274, (q31_t)0x1ab3cb0d, (q31_t)0x82d0f1d5, (q31_t)0x1a9b361d, (q31_t)0x82cbb60b, - (q31_t)0x1a82a026, (q31_t)0x82c67f14, (q31_t)0x1a6a0929, (q31_t)0x82c14cf1, (q31_t)0x1a517128, (q31_t)0x82bc1fa2, (q31_t)0x1a38d823, (q31_t)0x82b6f727, - (q31_t)0x1a203e1b, (q31_t)0x82b1d381, (q31_t)0x1a07a311, (q31_t)0x82acb4b0, (q31_t)0x19ef0707, (q31_t)0x82a79ab3, (q31_t)0x19d669fc, (q31_t)0x82a2858c, - (q31_t)0x19bdcbf3, (q31_t)0x829d753a, (q31_t)0x19a52ceb, (q31_t)0x829869be, (q31_t)0x198c8ce7, (q31_t)0x82936317, (q31_t)0x1973ebe6, (q31_t)0x828e6146, - (q31_t)0x195b49ea, (q31_t)0x8289644b, (q31_t)0x1942a6f3, (q31_t)0x82846c26, (q31_t)0x192a0304, (q31_t)0x827f78d8, (q31_t)0x19115e1c, (q31_t)0x827a8a61, - (q31_t)0x18f8b83c, (q31_t)0x8275a0c0, (q31_t)0x18e01167, (q31_t)0x8270bbf7, (q31_t)0x18c7699b, (q31_t)0x826bdc04, (q31_t)0x18aec0db, (q31_t)0x826700e9, - (q31_t)0x18961728, (q31_t)0x82622aa6, (q31_t)0x187d6c82, (q31_t)0x825d593a, (q31_t)0x1864c0ea, (q31_t)0x82588ca7, (q31_t)0x184c1461, (q31_t)0x8253c4eb, - (q31_t)0x183366e9, (q31_t)0x824f0208, (q31_t)0x181ab881, (q31_t)0x824a43fe, (q31_t)0x1802092c, (q31_t)0x82458acc, (q31_t)0x17e958ea, (q31_t)0x8240d673, - (q31_t)0x17d0a7bc, (q31_t)0x823c26f3, (q31_t)0x17b7f5a3, (q31_t)0x82377c4c, (q31_t)0x179f429f, (q31_t)0x8232d67f, (q31_t)0x17868eb3, (q31_t)0x822e358b, - (q31_t)0x176dd9de, (q31_t)0x82299971, (q31_t)0x17552422, (q31_t)0x82250232, (q31_t)0x173c6d80, (q31_t)0x82206fcc, (q31_t)0x1723b5f9, (q31_t)0x821be240, - (q31_t)0x170afd8d, (q31_t)0x82175990, (q31_t)0x16f2443e, (q31_t)0x8212d5b9, (q31_t)0x16d98a0c, (q31_t)0x820e56be, (q31_t)0x16c0cef9, (q31_t)0x8209dc9e, - (q31_t)0x16a81305, (q31_t)0x82056758, (q31_t)0x168f5632, (q31_t)0x8200f6ef, (q31_t)0x1676987f, (q31_t)0x81fc8b60, (q31_t)0x165dd9f0, (q31_t)0x81f824ae, - (q31_t)0x16451a83, (q31_t)0x81f3c2d7, (q31_t)0x162c5a3b, (q31_t)0x81ef65dc, (q31_t)0x16139918, (q31_t)0x81eb0dbe, (q31_t)0x15fad71b, (q31_t)0x81e6ba7c, - (q31_t)0x15e21445, (q31_t)0x81e26c16, (q31_t)0x15c95097, (q31_t)0x81de228d, (q31_t)0x15b08c12, (q31_t)0x81d9dde1, (q31_t)0x1597c6b7, (q31_t)0x81d59e13, - (q31_t)0x157f0086, (q31_t)0x81d16321, (q31_t)0x15663982, (q31_t)0x81cd2d0c, (q31_t)0x154d71aa, (q31_t)0x81c8fbd6, (q31_t)0x1534a901, (q31_t)0x81c4cf7d, - (q31_t)0x151bdf86, (q31_t)0x81c0a801, (q31_t)0x1503153a, (q31_t)0x81bc8564, (q31_t)0x14ea4a1f, (q31_t)0x81b867a5, (q31_t)0x14d17e36, (q31_t)0x81b44ec4, - (q31_t)0x14b8b17f, (q31_t)0x81b03ac2, (q31_t)0x149fe3fc, (q31_t)0x81ac2b9e, (q31_t)0x148715ae, (q31_t)0x81a82159, (q31_t)0x146e4694, (q31_t)0x81a41bf4, - (q31_t)0x145576b1, (q31_t)0x81a01b6d, (q31_t)0x143ca605, (q31_t)0x819c1fc5, (q31_t)0x1423d492, (q31_t)0x819828fd, (q31_t)0x140b0258, (q31_t)0x81943715, - (q31_t)0x13f22f58, (q31_t)0x81904a0c, (q31_t)0x13d95b93, (q31_t)0x818c61e3, (q31_t)0x13c0870a, (q31_t)0x81887e9a, (q31_t)0x13a7b1bf, (q31_t)0x8184a032, - (q31_t)0x138edbb1, (q31_t)0x8180c6a9, (q31_t)0x137604e2, (q31_t)0x817cf201, (q31_t)0x135d2d53, (q31_t)0x8179223a, (q31_t)0x13445505, (q31_t)0x81755754, - (q31_t)0x132b7bf9, (q31_t)0x8171914e, (q31_t)0x1312a230, (q31_t)0x816dd02a, (q31_t)0x12f9c7aa, (q31_t)0x816a13e6, (q31_t)0x12e0ec6a, (q31_t)0x81665c84, - (q31_t)0x12c8106f, (q31_t)0x8162aa04, (q31_t)0x12af33ba, (q31_t)0x815efc65, (q31_t)0x1296564d, (q31_t)0x815b53a8, (q31_t)0x127d7829, (q31_t)0x8157afcd, - (q31_t)0x1264994e, (q31_t)0x815410d4, (q31_t)0x124bb9be, (q31_t)0x815076bd, (q31_t)0x1232d979, (q31_t)0x814ce188, (q31_t)0x1219f880, (q31_t)0x81495136, - (q31_t)0x120116d5, (q31_t)0x8145c5c7, (q31_t)0x11e83478, (q31_t)0x81423f3a, (q31_t)0x11cf516a, (q31_t)0x813ebd90, (q31_t)0x11b66dad, (q31_t)0x813b40ca, - (q31_t)0x119d8941, (q31_t)0x8137c8e6, (q31_t)0x1184a427, (q31_t)0x813455e6, (q31_t)0x116bbe60, (q31_t)0x8130e7c9, (q31_t)0x1152d7ed, (q31_t)0x812d7e8f, - (q31_t)0x1139f0cf, (q31_t)0x812a1a3a, (q31_t)0x11210907, (q31_t)0x8126bac8, (q31_t)0x11082096, (q31_t)0x8123603a, (q31_t)0x10ef377d, (q31_t)0x81200a90, - (q31_t)0x10d64dbd, (q31_t)0x811cb9ca, (q31_t)0x10bd6356, (q31_t)0x81196de9, (q31_t)0x10a4784b, (q31_t)0x811626ec, (q31_t)0x108b8c9b, (q31_t)0x8112e4d4, - (q31_t)0x1072a048, (q31_t)0x810fa7a0, (q31_t)0x1059b352, (q31_t)0x810c6f52, (q31_t)0x1040c5bb, (q31_t)0x81093be8, (q31_t)0x1027d784, (q31_t)0x81060d63, - (q31_t)0x100ee8ad, (q31_t)0x8102e3c4, (q31_t)0xff5f938, (q31_t)0x80ffbf0a, (q31_t)0xfdd0926, (q31_t)0x80fc9f35, (q31_t)0xfc41876, (q31_t)0x80f98446, - (q31_t)0xfab272b, (q31_t)0x80f66e3c, (q31_t)0xf923546, (q31_t)0x80f35d19, (q31_t)0xf7942c7, (q31_t)0x80f050db, (q31_t)0xf604faf, (q31_t)0x80ed4984, - (q31_t)0xf475bff, (q31_t)0x80ea4712, (q31_t)0xf2e67b8, (q31_t)0x80e74987, (q31_t)0xf1572dc, (q31_t)0x80e450e2, (q31_t)0xefc7d6b, (q31_t)0x80e15d24, - (q31_t)0xee38766, (q31_t)0x80de6e4c, (q31_t)0xeca90ce, (q31_t)0x80db845b, (q31_t)0xeb199a4, (q31_t)0x80d89f51, (q31_t)0xe98a1e9, (q31_t)0x80d5bf2e, - (q31_t)0xe7fa99e, (q31_t)0x80d2e3f2, (q31_t)0xe66b0c3, (q31_t)0x80d00d9d, (q31_t)0xe4db75b, (q31_t)0x80cd3c2f, (q31_t)0xe34bd66, (q31_t)0x80ca6fa9, - (q31_t)0xe1bc2e4, (q31_t)0x80c7a80a, (q31_t)0xe02c7d7, (q31_t)0x80c4e553, (q31_t)0xde9cc40, (q31_t)0x80c22784, (q31_t)0xdd0d01f, (q31_t)0x80bf6e9c, - (q31_t)0xdb7d376, (q31_t)0x80bcba9d, (q31_t)0xd9ed646, (q31_t)0x80ba0b85, (q31_t)0xd85d88f, (q31_t)0x80b76156, (q31_t)0xd6cda53, (q31_t)0x80b4bc0e, - (q31_t)0xd53db92, (q31_t)0x80b21baf, (q31_t)0xd3adc4e, (q31_t)0x80af8039, (q31_t)0xd21dc87, (q31_t)0x80ace9ab, (q31_t)0xd08dc3f, (q31_t)0x80aa5806, - (q31_t)0xcefdb76, (q31_t)0x80a7cb49, (q31_t)0xcd6da2d, (q31_t)0x80a54376, (q31_t)0xcbdd865, (q31_t)0x80a2c08b, (q31_t)0xca4d620, (q31_t)0x80a04289, - (q31_t)0xc8bd35e, (q31_t)0x809dc971, (q31_t)0xc72d020, (q31_t)0x809b5541, (q31_t)0xc59cc68, (q31_t)0x8098e5fb, (q31_t)0xc40c835, (q31_t)0x80967b9f, - (q31_t)0xc27c389, (q31_t)0x8094162c, (q31_t)0xc0ebe66, (q31_t)0x8091b5a2, (q31_t)0xbf5b8cb, (q31_t)0x808f5a02, (q31_t)0xbdcb2bb, (q31_t)0x808d034c, - (q31_t)0xbc3ac35, (q31_t)0x808ab180, (q31_t)0xbaaa53b, (q31_t)0x8088649e, (q31_t)0xb919dcf, (q31_t)0x80861ca6, (q31_t)0xb7895f0, (q31_t)0x8083d998, - (q31_t)0xb5f8d9f, (q31_t)0x80819b74, (q31_t)0xb4684df, (q31_t)0x807f623b, (q31_t)0xb2d7baf, (q31_t)0x807d2dec, (q31_t)0xb147211, (q31_t)0x807afe87, - (q31_t)0xafb6805, (q31_t)0x8078d40d, (q31_t)0xae25d8d, (q31_t)0x8076ae7e, (q31_t)0xac952aa, (q31_t)0x80748dd9, (q31_t)0xab0475c, (q31_t)0x8072721f, - (q31_t)0xa973ba5, (q31_t)0x80705b50, (q31_t)0xa7e2f85, (q31_t)0x806e496c, (q31_t)0xa6522fe, (q31_t)0x806c3c74, (q31_t)0xa4c1610, (q31_t)0x806a3466, - (q31_t)0xa3308bd, (q31_t)0x80683143, (q31_t)0xa19fb04, (q31_t)0x8066330c, (q31_t)0xa00ece8, (q31_t)0x806439c0, (q31_t)0x9e7de6a, (q31_t)0x80624560, - (q31_t)0x9cecf89, (q31_t)0x806055eb, (q31_t)0x9b5c048, (q31_t)0x805e6b62, (q31_t)0x99cb0a7, (q31_t)0x805c85c4, (q31_t)0x983a0a7, (q31_t)0x805aa512, - (q31_t)0x96a9049, (q31_t)0x8058c94c, (q31_t)0x9517f8f, (q31_t)0x8056f272, (q31_t)0x9386e78, (q31_t)0x80552084, (q31_t)0x91f5d06, (q31_t)0x80535381, - (q31_t)0x9064b3a, (q31_t)0x80518b6b, (q31_t)0x8ed3916, (q31_t)0x804fc841, (q31_t)0x8d42699, (q31_t)0x804e0a04, (q31_t)0x8bb13c5, (q31_t)0x804c50b2, - (q31_t)0x8a2009a, (q31_t)0x804a9c4d, (q31_t)0x888ed1b, (q31_t)0x8048ecd5, (q31_t)0x86fd947, (q31_t)0x80474248, (q31_t)0x856c520, (q31_t)0x80459ca9, - (q31_t)0x83db0a7, (q31_t)0x8043fbf6, (q31_t)0x8249bdd, (q31_t)0x80426030, (q31_t)0x80b86c2, (q31_t)0x8040c956, (q31_t)0x7f27157, (q31_t)0x803f376a, - (q31_t)0x7d95b9e, (q31_t)0x803daa6a, (q31_t)0x7c04598, (q31_t)0x803c2257, (q31_t)0x7a72f45, (q31_t)0x803a9f31, (q31_t)0x78e18a7, (q31_t)0x803920f8, - (q31_t)0x77501be, (q31_t)0x8037a7ac, (q31_t)0x75bea8c, (q31_t)0x8036334e, (q31_t)0x742d311, (q31_t)0x8034c3dd, (q31_t)0x729bb4e, (q31_t)0x80335959, - (q31_t)0x710a345, (q31_t)0x8031f3c2, (q31_t)0x6f78af6, (q31_t)0x80309318, (q31_t)0x6de7262, (q31_t)0x802f375d, (q31_t)0x6c5598a, (q31_t)0x802de08e, - (q31_t)0x6ac406f, (q31_t)0x802c8ead, (q31_t)0x6932713, (q31_t)0x802b41ba, (q31_t)0x67a0d76, (q31_t)0x8029f9b4, (q31_t)0x660f398, (q31_t)0x8028b69c, - (q31_t)0x647d97c, (q31_t)0x80277872, (q31_t)0x62ebf22, (q31_t)0x80263f36, (q31_t)0x615a48b, (q31_t)0x80250ae7, (q31_t)0x5fc89b8, (q31_t)0x8023db86, - (q31_t)0x5e36ea9, (q31_t)0x8022b114, (q31_t)0x5ca5361, (q31_t)0x80218b8f, (q31_t)0x5b137df, (q31_t)0x80206af8, (q31_t)0x5981c26, (q31_t)0x801f4f4f, - (q31_t)0x57f0035, (q31_t)0x801e3895, (q31_t)0x565e40d, (q31_t)0x801d26c8, (q31_t)0x54cc7b1, (q31_t)0x801c19ea, (q31_t)0x533ab20, (q31_t)0x801b11fa, - (q31_t)0x51a8e5c, (q31_t)0x801a0ef8, (q31_t)0x5017165, (q31_t)0x801910e4, (q31_t)0x4e8543e, (q31_t)0x801817bf, (q31_t)0x4cf36e5, (q31_t)0x80172388, - (q31_t)0x4b6195d, (q31_t)0x80163440, (q31_t)0x49cfba7, (q31_t)0x801549e6, (q31_t)0x483ddc3, (q31_t)0x8014647b, (q31_t)0x46abfb3, (q31_t)0x801383fe, - (q31_t)0x451a177, (q31_t)0x8012a86f, (q31_t)0x4388310, (q31_t)0x8011d1d0, (q31_t)0x41f6480, (q31_t)0x8011001f, (q31_t)0x40645c7, (q31_t)0x8010335c, - (q31_t)0x3ed26e6, (q31_t)0x800f6b88, (q31_t)0x3d407df, (q31_t)0x800ea8a3, (q31_t)0x3bae8b2, (q31_t)0x800deaad, (q31_t)0x3a1c960, (q31_t)0x800d31a5, - (q31_t)0x388a9ea, (q31_t)0x800c7d8c, (q31_t)0x36f8a51, (q31_t)0x800bce63, (q31_t)0x3566a96, (q31_t)0x800b2427, (q31_t)0x33d4abb, (q31_t)0x800a7edb, - (q31_t)0x3242abf, (q31_t)0x8009de7e, (q31_t)0x30b0aa4, (q31_t)0x80094310, (q31_t)0x2f1ea6c, (q31_t)0x8008ac90, (q31_t)0x2d8ca16, (q31_t)0x80081b00, - (q31_t)0x2bfa9a4, (q31_t)0x80078e5e, (q31_t)0x2a68917, (q31_t)0x800706ac, (q31_t)0x28d6870, (q31_t)0x800683e8, (q31_t)0x27447b0, (q31_t)0x80060614, - (q31_t)0x25b26d7, (q31_t)0x80058d2f, (q31_t)0x24205e8, (q31_t)0x80051939, (q31_t)0x228e4e2, (q31_t)0x8004aa32, (q31_t)0x20fc3c6, (q31_t)0x8004401a, - (q31_t)0x1f6a297, (q31_t)0x8003daf1, (q31_t)0x1dd8154, (q31_t)0x80037ab7, (q31_t)0x1c45ffe, (q31_t)0x80031f6d, (q31_t)0x1ab3e97, (q31_t)0x8002c912, - (q31_t)0x1921d20, (q31_t)0x800277a6, (q31_t)0x178fb99, (q31_t)0x80022b29, (q31_t)0x15fda03, (q31_t)0x8001e39b, (q31_t)0x146b860, (q31_t)0x8001a0fd, - (q31_t)0x12d96b1, (q31_t)0x8001634e, (q31_t)0x11474f6, (q31_t)0x80012a8e, (q31_t)0x0fb5330, (q31_t)0x8000f6bd, (q31_t)0xe23160, (q31_t)0x8000c7dc, - (q31_t)0x0c90f88, (q31_t)0x80009dea, (q31_t)0x0afeda8, (q31_t)0x800078e7, (q31_t)0x096cbc1, (q31_t)0x800058d4, (q31_t)0x7da9d4, (q31_t)0x80003daf, - (q31_t)0x06487e3, (q31_t)0x8000277a, (q31_t)0x04b65ee, (q31_t)0x80001635, (q31_t)0x03243f5, (q31_t)0x800009df, (q31_t)0x1921fb, (q31_t)0x80000278 -}; + (q31_t)0x7fffffff, (q31_t)0x00000000, (q31_t)0x7ffffd88, (q31_t)0xffe6de05, + (q31_t)0x7ffff621, (q31_t)0xffcdbc0b, (q31_t)0x7fffe9cb, (q31_t)0xffb49a12, + (q31_t)0x7fffd886, (q31_t)0xff9b781d, (q31_t)0x7fffc251, (q31_t)0xff82562c, + (q31_t)0x7fffa72c, (q31_t)0xff69343f, (q31_t)0x7fff8719, (q31_t)0xff501258, + (q31_t)0x7fff6216, (q31_t)0xff36f078, (q31_t)0x7fff3824, (q31_t)0xff1dcea0, + (q31_t)0x7fff0943, (q31_t)0xff04acd0, (q31_t)0x7ffed572, (q31_t)0xfeeb8b0a, + (q31_t)0x7ffe9cb2, (q31_t)0xfed2694f, (q31_t)0x7ffe5f03, (q31_t)0xfeb947a0, + (q31_t)0x7ffe1c65, (q31_t)0xfea025fd, (q31_t)0x7ffdd4d7, (q31_t)0xfe870467, + (q31_t)0x7ffd885a, (q31_t)0xfe6de2e0, (q31_t)0x7ffd36ee, (q31_t)0xfe54c169, + (q31_t)0x7ffce093, (q31_t)0xfe3ba002, (q31_t)0x7ffc8549, (q31_t)0xfe227eac, + (q31_t)0x7ffc250f, (q31_t)0xfe095d69, (q31_t)0x7ffbbfe6, (q31_t)0xfdf03c3a, + (q31_t)0x7ffb55ce, (q31_t)0xfdd71b1e, (q31_t)0x7ffae6c7, (q31_t)0xfdbdfa18, + (q31_t)0x7ffa72d1, (q31_t)0xfda4d929, (q31_t)0x7ff9f9ec, (q31_t)0xfd8bb850, + (q31_t)0x7ff97c18, (q31_t)0xfd729790, (q31_t)0x7ff8f954, (q31_t)0xfd5976e9, + (q31_t)0x7ff871a2, (q31_t)0xfd40565c, (q31_t)0x7ff7e500, (q31_t)0xfd2735ea, + (q31_t)0x7ff75370, (q31_t)0xfd0e1594, (q31_t)0x7ff6bcf0, (q31_t)0xfcf4f55c, + (q31_t)0x7ff62182, (q31_t)0xfcdbd541, (q31_t)0x7ff58125, (q31_t)0xfcc2b545, + (q31_t)0x7ff4dbd9, (q31_t)0xfca9956a, (q31_t)0x7ff4319d, (q31_t)0xfc9075af, + (q31_t)0x7ff38274, (q31_t)0xfc775616, (q31_t)0x7ff2ce5b, (q31_t)0xfc5e36a0, + (q31_t)0x7ff21553, (q31_t)0xfc45174e, (q31_t)0x7ff1575d, (q31_t)0xfc2bf821, + (q31_t)0x7ff09478, (q31_t)0xfc12d91a, (q31_t)0x7fefcca4, (q31_t)0xfbf9ba39, + (q31_t)0x7feeffe1, (q31_t)0xfbe09b80, (q31_t)0x7fee2e30, (q31_t)0xfbc77cf0, + (q31_t)0x7fed5791, (q31_t)0xfbae5e89, (q31_t)0x7fec7c02, (q31_t)0xfb95404d, + (q31_t)0x7feb9b85, (q31_t)0xfb7c223d, (q31_t)0x7feab61a, (q31_t)0xfb630459, + (q31_t)0x7fe9cbc0, (q31_t)0xfb49e6a3, (q31_t)0x7fe8dc78, (q31_t)0xfb30c91b, + (q31_t)0x7fe7e841, (q31_t)0xfb17abc2, (q31_t)0x7fe6ef1c, (q31_t)0xfafe8e9b, + (q31_t)0x7fe5f108, (q31_t)0xfae571a4, (q31_t)0x7fe4ee06, (q31_t)0xfacc54e0, + (q31_t)0x7fe3e616, (q31_t)0xfab3384f, (q31_t)0x7fe2d938, (q31_t)0xfa9a1bf3, + (q31_t)0x7fe1c76b, (q31_t)0xfa80ffcb, (q31_t)0x7fe0b0b1, (q31_t)0xfa67e3da, + (q31_t)0x7fdf9508, (q31_t)0xfa4ec821, (q31_t)0x7fde7471, (q31_t)0xfa35ac9f, + (q31_t)0x7fdd4eec, (q31_t)0xfa1c9157, (q31_t)0x7fdc247a, (q31_t)0xfa037648, + (q31_t)0x7fdaf519, (q31_t)0xf9ea5b75, (q31_t)0x7fd9c0ca, (q31_t)0xf9d140de, + (q31_t)0x7fd8878e, (q31_t)0xf9b82684, (q31_t)0x7fd74964, (q31_t)0xf99f0c68, + (q31_t)0x7fd6064c, (q31_t)0xf985f28a, (q31_t)0x7fd4be46, (q31_t)0xf96cd8ed, + (q31_t)0x7fd37153, (q31_t)0xf953bf91, (q31_t)0x7fd21f72, (q31_t)0xf93aa676, + (q31_t)0x7fd0c8a3, (q31_t)0xf9218d9e, (q31_t)0x7fcf6ce8, (q31_t)0xf908750a, + (q31_t)0x7fce0c3e, (q31_t)0xf8ef5cbb, (q31_t)0x7fcca6a7, (q31_t)0xf8d644b2, + (q31_t)0x7fcb3c23, (q31_t)0xf8bd2cef, (q31_t)0x7fc9ccb2, (q31_t)0xf8a41574, + (q31_t)0x7fc85854, (q31_t)0xf88afe42, (q31_t)0x7fc6df08, (q31_t)0xf871e759, + (q31_t)0x7fc560cf, (q31_t)0xf858d0bb, (q31_t)0x7fc3dda9, (q31_t)0xf83fba68, + (q31_t)0x7fc25596, (q31_t)0xf826a462, (q31_t)0x7fc0c896, (q31_t)0xf80d8ea9, + (q31_t)0x7fbf36aa, (q31_t)0xf7f4793e, (q31_t)0x7fbd9fd0, (q31_t)0xf7db6423, + (q31_t)0x7fbc040a, (q31_t)0xf7c24f59, (q31_t)0x7fba6357, (q31_t)0xf7a93ae0, + (q31_t)0x7fb8bdb8, (q31_t)0xf79026b9, (q31_t)0x7fb7132b, (q31_t)0xf77712e5, + (q31_t)0x7fb563b3, (q31_t)0xf75dff66, (q31_t)0x7fb3af4e, (q31_t)0xf744ec3b, + (q31_t)0x7fb1f5fc, (q31_t)0xf72bd967, (q31_t)0x7fb037bf, (q31_t)0xf712c6ea, + (q31_t)0x7fae7495, (q31_t)0xf6f9b4c6, (q31_t)0x7facac7f, (q31_t)0xf6e0a2fa, + (q31_t)0x7faadf7c, (q31_t)0xf6c79188, (q31_t)0x7fa90d8e, (q31_t)0xf6ae8071, + (q31_t)0x7fa736b4, (q31_t)0xf6956fb7, (q31_t)0x7fa55aee, (q31_t)0xf67c5f59, + (q31_t)0x7fa37a3c, (q31_t)0xf6634f59, (q31_t)0x7fa1949e, (q31_t)0xf64a3fb8, + (q31_t)0x7f9faa15, (q31_t)0xf6313077, (q31_t)0x7f9dbaa0, (q31_t)0xf6182196, + (q31_t)0x7f9bc640, (q31_t)0xf5ff1318, (q31_t)0x7f99ccf4, (q31_t)0xf5e604fc, + (q31_t)0x7f97cebd, (q31_t)0xf5ccf743, (q31_t)0x7f95cb9a, (q31_t)0xf5b3e9f0, + (q31_t)0x7f93c38c, (q31_t)0xf59add02, (q31_t)0x7f91b694, (q31_t)0xf581d07b, + (q31_t)0x7f8fa4b0, (q31_t)0xf568c45b, (q31_t)0x7f8d8de1, (q31_t)0xf54fb8a4, + (q31_t)0x7f8b7227, (q31_t)0xf536ad56, (q31_t)0x7f895182, (q31_t)0xf51da273, + (q31_t)0x7f872bf3, (q31_t)0xf50497fb, (q31_t)0x7f850179, (q31_t)0xf4eb8def, + (q31_t)0x7f82d214, (q31_t)0xf4d28451, (q31_t)0x7f809dc5, (q31_t)0xf4b97b21, + (q31_t)0x7f7e648c, (q31_t)0xf4a07261, (q31_t)0x7f7c2668, (q31_t)0xf4876a10, + (q31_t)0x7f79e35a, (q31_t)0xf46e6231, (q31_t)0x7f779b62, (q31_t)0xf4555ac5, + (q31_t)0x7f754e80, (q31_t)0xf43c53cb, (q31_t)0x7f72fcb4, (q31_t)0xf4234d45, + (q31_t)0x7f70a5fe, (q31_t)0xf40a4735, (q31_t)0x7f6e4a5e, (q31_t)0xf3f1419a, + (q31_t)0x7f6be9d4, (q31_t)0xf3d83c77, (q31_t)0x7f698461, (q31_t)0xf3bf37cb, + (q31_t)0x7f671a05, (q31_t)0xf3a63398, (q31_t)0x7f64aabf, (q31_t)0xf38d2fe0, + (q31_t)0x7f62368f, (q31_t)0xf3742ca2, (q31_t)0x7f5fbd77, (q31_t)0xf35b29e0, + (q31_t)0x7f5d3f75, (q31_t)0xf342279b, (q31_t)0x7f5abc8a, (q31_t)0xf32925d3, + (q31_t)0x7f5834b7, (q31_t)0xf310248a, (q31_t)0x7f55a7fa, (q31_t)0xf2f723c1, + (q31_t)0x7f531655, (q31_t)0xf2de2379, (q31_t)0x7f507fc7, (q31_t)0xf2c523b2, + (q31_t)0x7f4de451, (q31_t)0xf2ac246e, (q31_t)0x7f4b43f2, (q31_t)0xf29325ad, + (q31_t)0x7f489eaa, (q31_t)0xf27a2771, (q31_t)0x7f45f47b, (q31_t)0xf26129ba, + (q31_t)0x7f434563, (q31_t)0xf2482c8a, (q31_t)0x7f409164, (q31_t)0xf22f2fe1, + (q31_t)0x7f3dd87c, (q31_t)0xf21633c0, (q31_t)0x7f3b1aad, (q31_t)0xf1fd3829, + (q31_t)0x7f3857f6, (q31_t)0xf1e43d1c, (q31_t)0x7f359057, (q31_t)0xf1cb429a, + (q31_t)0x7f32c3d1, (q31_t)0xf1b248a5, (q31_t)0x7f2ff263, (q31_t)0xf1994f3d, + (q31_t)0x7f2d1c0e, (q31_t)0xf1805662, (q31_t)0x7f2a40d2, (q31_t)0xf1675e17, + (q31_t)0x7f2760af, (q31_t)0xf14e665c, (q31_t)0x7f247ba5, (q31_t)0xf1356f32, + (q31_t)0x7f2191b4, (q31_t)0xf11c789a, (q31_t)0x7f1ea2dc, (q31_t)0xf1038295, + (q31_t)0x7f1baf1e, (q31_t)0xf0ea8d24, (q31_t)0x7f18b679, (q31_t)0xf0d19848, + (q31_t)0x7f15b8ee, (q31_t)0xf0b8a401, (q31_t)0x7f12b67c, (q31_t)0xf09fb051, + (q31_t)0x7f0faf25, (q31_t)0xf086bd39, (q31_t)0x7f0ca2e7, (q31_t)0xf06dcaba, + (q31_t)0x7f0991c4, (q31_t)0xf054d8d5, (q31_t)0x7f067bba, (q31_t)0xf03be78a, + (q31_t)0x7f0360cb, (q31_t)0xf022f6da, (q31_t)0x7f0040f6, (q31_t)0xf00a06c8, + (q31_t)0x7efd1c3c, (q31_t)0xeff11753, (q31_t)0x7ef9f29d, (q31_t)0xefd8287c, + (q31_t)0x7ef6c418, (q31_t)0xefbf3a45, (q31_t)0x7ef390ae, (q31_t)0xefa64cae, + (q31_t)0x7ef05860, (q31_t)0xef8d5fb8, (q31_t)0x7eed1b2c, (q31_t)0xef747365, + (q31_t)0x7ee9d914, (q31_t)0xef5b87b5, (q31_t)0x7ee69217, (q31_t)0xef429caa, + (q31_t)0x7ee34636, (q31_t)0xef29b243, (q31_t)0x7edff570, (q31_t)0xef10c883, + (q31_t)0x7edc9fc6, (q31_t)0xeef7df6a, (q31_t)0x7ed94538, (q31_t)0xeedef6f9, + (q31_t)0x7ed5e5c6, (q31_t)0xeec60f31, (q31_t)0x7ed28171, (q31_t)0xeead2813, + (q31_t)0x7ecf1837, (q31_t)0xee9441a0, (q31_t)0x7ecbaa1a, (q31_t)0xee7b5bd9, + (q31_t)0x7ec8371a, (q31_t)0xee6276bf, (q31_t)0x7ec4bf36, (q31_t)0xee499253, + (q31_t)0x7ec14270, (q31_t)0xee30ae96, (q31_t)0x7ebdc0c6, (q31_t)0xee17cb88, + (q31_t)0x7eba3a39, (q31_t)0xedfee92b, (q31_t)0x7eb6aeca, (q31_t)0xede60780, + (q31_t)0x7eb31e78, (q31_t)0xedcd2687, (q31_t)0x7eaf8943, (q31_t)0xedb44642, + (q31_t)0x7eabef2c, (q31_t)0xed9b66b2, (q31_t)0x7ea85033, (q31_t)0xed8287d7, + (q31_t)0x7ea4ac58, (q31_t)0xed69a9b3, (q31_t)0x7ea1039b, (q31_t)0xed50cc46, + (q31_t)0x7e9d55fc, (q31_t)0xed37ef91, (q31_t)0x7e99a37c, (q31_t)0xed1f1396, + (q31_t)0x7e95ec1a, (q31_t)0xed063856, (q31_t)0x7e922fd6, (q31_t)0xeced5dd0, + (q31_t)0x7e8e6eb2, (q31_t)0xecd48407, (q31_t)0x7e8aa8ac, (q31_t)0xecbbaafb, + (q31_t)0x7e86ddc6, (q31_t)0xeca2d2ad, (q31_t)0x7e830dff, (q31_t)0xec89fb1e, + (q31_t)0x7e7f3957, (q31_t)0xec71244f, (q31_t)0x7e7b5fce, (q31_t)0xec584e41, + (q31_t)0x7e778166, (q31_t)0xec3f78f6, (q31_t)0x7e739e1d, (q31_t)0xec26a46d, + (q31_t)0x7e6fb5f4, (q31_t)0xec0dd0a8, (q31_t)0x7e6bc8eb, (q31_t)0xebf4fda8, + (q31_t)0x7e67d703, (q31_t)0xebdc2b6e, (q31_t)0x7e63e03b, (q31_t)0xebc359fb, + (q31_t)0x7e5fe493, (q31_t)0xebaa894f, (q31_t)0x7e5be40c, (q31_t)0xeb91b96c, + (q31_t)0x7e57dea7, (q31_t)0xeb78ea52, (q31_t)0x7e53d462, (q31_t)0xeb601c04, + (q31_t)0x7e4fc53e, (q31_t)0xeb474e81, (q31_t)0x7e4bb13c, (q31_t)0xeb2e81ca, + (q31_t)0x7e47985b, (q31_t)0xeb15b5e1, (q31_t)0x7e437a9c, (q31_t)0xeafceac6, + (q31_t)0x7e3f57ff, (q31_t)0xeae4207a, (q31_t)0x7e3b3083, (q31_t)0xeacb56ff, + (q31_t)0x7e37042a, (q31_t)0xeab28e56, (q31_t)0x7e32d2f4, (q31_t)0xea99c67e, + (q31_t)0x7e2e9cdf, (q31_t)0xea80ff7a, (q31_t)0x7e2a61ed, (q31_t)0xea683949, + (q31_t)0x7e26221f, (q31_t)0xea4f73ee, (q31_t)0x7e21dd73, (q31_t)0xea36af69, + (q31_t)0x7e1d93ea, (q31_t)0xea1debbb, (q31_t)0x7e194584, (q31_t)0xea0528e5, + (q31_t)0x7e14f242, (q31_t)0xe9ec66e8, (q31_t)0x7e109a24, (q31_t)0xe9d3a5c5, + (q31_t)0x7e0c3d29, (q31_t)0xe9bae57d, (q31_t)0x7e07db52, (q31_t)0xe9a22610, + (q31_t)0x7e0374a0, (q31_t)0xe9896781, (q31_t)0x7dff0911, (q31_t)0xe970a9ce, + (q31_t)0x7dfa98a8, (q31_t)0xe957ecfb, (q31_t)0x7df62362, (q31_t)0xe93f3107, + (q31_t)0x7df1a942, (q31_t)0xe92675f4, (q31_t)0x7ded2a47, (q31_t)0xe90dbbc2, + (q31_t)0x7de8a670, (q31_t)0xe8f50273, (q31_t)0x7de41dc0, (q31_t)0xe8dc4a07, + (q31_t)0x7ddf9034, (q31_t)0xe8c39280, (q31_t)0x7ddafdce, (q31_t)0xe8aadbde, + (q31_t)0x7dd6668f, (q31_t)0xe8922622, (q31_t)0x7dd1ca75, (q31_t)0xe879714d, + (q31_t)0x7dcd2981, (q31_t)0xe860bd61, (q31_t)0x7dc883b4, (q31_t)0xe8480a5d, + (q31_t)0x7dc3d90d, (q31_t)0xe82f5844, (q31_t)0x7dbf298d, (q31_t)0xe816a716, + (q31_t)0x7dba7534, (q31_t)0xe7fdf6d4, (q31_t)0x7db5bc02, (q31_t)0xe7e5477f, + (q31_t)0x7db0fdf8, (q31_t)0xe7cc9917, (q31_t)0x7dac3b15, (q31_t)0xe7b3eb9f, + (q31_t)0x7da77359, (q31_t)0xe79b3f16, (q31_t)0x7da2a6c6, (q31_t)0xe782937e, + (q31_t)0x7d9dd55a, (q31_t)0xe769e8d8, (q31_t)0x7d98ff17, (q31_t)0xe7513f25, + (q31_t)0x7d9423fc, (q31_t)0xe7389665, (q31_t)0x7d8f4409, (q31_t)0xe71fee99, + (q31_t)0x7d8a5f40, (q31_t)0xe70747c4, (q31_t)0x7d85759f, (q31_t)0xe6eea1e4, + (q31_t)0x7d808728, (q31_t)0xe6d5fcfc, (q31_t)0x7d7b93da, (q31_t)0xe6bd590d, + (q31_t)0x7d769bb5, (q31_t)0xe6a4b616, (q31_t)0x7d719eba, (q31_t)0xe68c141a, + (q31_t)0x7d6c9ce9, (q31_t)0xe6737319, (q31_t)0x7d679642, (q31_t)0xe65ad315, + (q31_t)0x7d628ac6, (q31_t)0xe642340d, (q31_t)0x7d5d7a74, (q31_t)0xe6299604, + (q31_t)0x7d58654d, (q31_t)0xe610f8f9, (q31_t)0x7d534b50, (q31_t)0xe5f85cef, + (q31_t)0x7d4e2c7f, (q31_t)0xe5dfc1e5, (q31_t)0x7d4908d9, (q31_t)0xe5c727dd, + (q31_t)0x7d43e05e, (q31_t)0xe5ae8ed8, (q31_t)0x7d3eb30f, (q31_t)0xe595f6d7, + (q31_t)0x7d3980ec, (q31_t)0xe57d5fda, (q31_t)0x7d3449f5, (q31_t)0xe564c9e3, + (q31_t)0x7d2f0e2b, (q31_t)0xe54c34f3, (q31_t)0x7d29cd8c, (q31_t)0xe533a10a, + (q31_t)0x7d24881b, (q31_t)0xe51b0e2a, (q31_t)0x7d1f3dd6, (q31_t)0xe5027c53, + (q31_t)0x7d19eebf, (q31_t)0xe4e9eb87, (q31_t)0x7d149ad5, (q31_t)0xe4d15bc6, + (q31_t)0x7d0f4218, (q31_t)0xe4b8cd11, (q31_t)0x7d09e489, (q31_t)0xe4a03f69, + (q31_t)0x7d048228, (q31_t)0xe487b2d0, (q31_t)0x7cff1af5, (q31_t)0xe46f2745, + (q31_t)0x7cf9aef0, (q31_t)0xe4569ccb, (q31_t)0x7cf43e1a, (q31_t)0xe43e1362, + (q31_t)0x7ceec873, (q31_t)0xe4258b0a, (q31_t)0x7ce94dfb, (q31_t)0xe40d03c6, + (q31_t)0x7ce3ceb2, (q31_t)0xe3f47d96, (q31_t)0x7cde4a98, (q31_t)0xe3dbf87a, + (q31_t)0x7cd8c1ae, (q31_t)0xe3c37474, (q31_t)0x7cd333f3, (q31_t)0xe3aaf184, + (q31_t)0x7ccda169, (q31_t)0xe3926fad, (q31_t)0x7cc80a0f, (q31_t)0xe379eeed, + (q31_t)0x7cc26de5, (q31_t)0xe3616f48, (q31_t)0x7cbcccec, (q31_t)0xe348f0bd, + (q31_t)0x7cb72724, (q31_t)0xe330734d, (q31_t)0x7cb17c8d, (q31_t)0xe317f6fa, + (q31_t)0x7cabcd28, (q31_t)0xe2ff7bc3, (q31_t)0x7ca618f3, (q31_t)0xe2e701ac, + (q31_t)0x7ca05ff1, (q31_t)0xe2ce88b3, (q31_t)0x7c9aa221, (q31_t)0xe2b610da, + (q31_t)0x7c94df83, (q31_t)0xe29d9a23, (q31_t)0x7c8f1817, (q31_t)0xe285248d, + (q31_t)0x7c894bde, (q31_t)0xe26cb01b, (q31_t)0x7c837ad8, (q31_t)0xe2543ccc, + (q31_t)0x7c7da505, (q31_t)0xe23bcaa2, (q31_t)0x7c77ca65, (q31_t)0xe223599e, + (q31_t)0x7c71eaf9, (q31_t)0xe20ae9c1, (q31_t)0x7c6c06c0, (q31_t)0xe1f27b0b, + (q31_t)0x7c661dbc, (q31_t)0xe1da0d7e, (q31_t)0x7c602fec, (q31_t)0xe1c1a11b, + (q31_t)0x7c5a3d50, (q31_t)0xe1a935e2, (q31_t)0x7c5445e9, (q31_t)0xe190cbd4, + (q31_t)0x7c4e49b7, (q31_t)0xe17862f3, (q31_t)0x7c4848ba, (q31_t)0xe15ffb3f, + (q31_t)0x7c4242f2, (q31_t)0xe14794ba, (q31_t)0x7c3c3860, (q31_t)0xe12f2f63, + (q31_t)0x7c362904, (q31_t)0xe116cb3d, (q31_t)0x7c3014de, (q31_t)0xe0fe6848, + (q31_t)0x7c29fbee, (q31_t)0xe0e60685, (q31_t)0x7c23de35, (q31_t)0xe0cda5f5, + (q31_t)0x7c1dbbb3, (q31_t)0xe0b54698, (q31_t)0x7c179467, (q31_t)0xe09ce871, + (q31_t)0x7c116853, (q31_t)0xe0848b7f, (q31_t)0x7c0b3777, (q31_t)0xe06c2fc4, + (q31_t)0x7c0501d2, (q31_t)0xe053d541, (q31_t)0x7bfec765, (q31_t)0xe03b7bf6, + (q31_t)0x7bf88830, (q31_t)0xe02323e5, (q31_t)0x7bf24434, (q31_t)0xe00acd0e, + (q31_t)0x7bebfb70, (q31_t)0xdff27773, (q31_t)0x7be5ade6, (q31_t)0xdfda2314, + (q31_t)0x7bdf5b94, (q31_t)0xdfc1cff3, (q31_t)0x7bd9047c, (q31_t)0xdfa97e0f, + (q31_t)0x7bd2a89e, (q31_t)0xdf912d6b, (q31_t)0x7bcc47fa, (q31_t)0xdf78de07, + (q31_t)0x7bc5e290, (q31_t)0xdf608fe4, (q31_t)0x7bbf7860, (q31_t)0xdf484302, + (q31_t)0x7bb9096b, (q31_t)0xdf2ff764, (q31_t)0x7bb295b0, (q31_t)0xdf17ad0a, + (q31_t)0x7bac1d31, (q31_t)0xdeff63f4, (q31_t)0x7ba59fee, (q31_t)0xdee71c24, + (q31_t)0x7b9f1de6, (q31_t)0xdeced59b, (q31_t)0x7b989719, (q31_t)0xdeb69059, + (q31_t)0x7b920b89, (q31_t)0xde9e4c60, (q31_t)0x7b8b7b36, (q31_t)0xde8609b1, + (q31_t)0x7b84e61f, (q31_t)0xde6dc84b, (q31_t)0x7b7e4c45, (q31_t)0xde558831, + (q31_t)0x7b77ada8, (q31_t)0xde3d4964, (q31_t)0x7b710a49, (q31_t)0xde250be3, + (q31_t)0x7b6a6227, (q31_t)0xde0ccfb1, (q31_t)0x7b63b543, (q31_t)0xddf494ce, + (q31_t)0x7b5d039e, (q31_t)0xdddc5b3b, (q31_t)0x7b564d36, (q31_t)0xddc422f8, + (q31_t)0x7b4f920e, (q31_t)0xddabec08, (q31_t)0x7b48d225, (q31_t)0xdd93b66a, + (q31_t)0x7b420d7a, (q31_t)0xdd7b8220, (q31_t)0x7b3b4410, (q31_t)0xdd634f2b, + (q31_t)0x7b3475e5, (q31_t)0xdd4b1d8c, (q31_t)0x7b2da2fa, (q31_t)0xdd32ed43, + (q31_t)0x7b26cb4f, (q31_t)0xdd1abe51, (q31_t)0x7b1feee5, (q31_t)0xdd0290b8, + (q31_t)0x7b190dbc, (q31_t)0xdcea6478, (q31_t)0x7b1227d3, (q31_t)0xdcd23993, + (q31_t)0x7b0b3d2c, (q31_t)0xdcba1008, (q31_t)0x7b044dc7, (q31_t)0xdca1e7da, + (q31_t)0x7afd59a4, (q31_t)0xdc89c109, (q31_t)0x7af660c2, (q31_t)0xdc719b96, + (q31_t)0x7aef6323, (q31_t)0xdc597781, (q31_t)0x7ae860c7, (q31_t)0xdc4154cd, + (q31_t)0x7ae159ae, (q31_t)0xdc293379, (q31_t)0x7ada4dd8, (q31_t)0xdc111388, + (q31_t)0x7ad33d45, (q31_t)0xdbf8f4f8, (q31_t)0x7acc27f7, (q31_t)0xdbe0d7cd, + (q31_t)0x7ac50dec, (q31_t)0xdbc8bc06, (q31_t)0x7abdef25, (q31_t)0xdbb0a1a4, + (q31_t)0x7ab6cba4, (q31_t)0xdb9888a8, (q31_t)0x7aafa367, (q31_t)0xdb807114, + (q31_t)0x7aa8766f, (q31_t)0xdb685ae9, (q31_t)0x7aa144bc, (q31_t)0xdb504626, + (q31_t)0x7a9a0e50, (q31_t)0xdb3832cd, (q31_t)0x7a92d329, (q31_t)0xdb2020e0, + (q31_t)0x7a8b9348, (q31_t)0xdb08105e, (q31_t)0x7a844eae, (q31_t)0xdaf00149, + (q31_t)0x7a7d055b, (q31_t)0xdad7f3a2, (q31_t)0x7a75b74f, (q31_t)0xdabfe76a, + (q31_t)0x7a6e648a, (q31_t)0xdaa7dca1, (q31_t)0x7a670d0d, (q31_t)0xda8fd349, + (q31_t)0x7a5fb0d8, (q31_t)0xda77cb63, (q31_t)0x7a584feb, (q31_t)0xda5fc4ef, + (q31_t)0x7a50ea47, (q31_t)0xda47bfee, (q31_t)0x7a497feb, (q31_t)0xda2fbc61, + (q31_t)0x7a4210d8, (q31_t)0xda17ba4a, (q31_t)0x7a3a9d0f, (q31_t)0xd9ffb9a9, + (q31_t)0x7a332490, (q31_t)0xd9e7ba7f, (q31_t)0x7a2ba75a, (q31_t)0xd9cfbccd, + (q31_t)0x7a24256f, (q31_t)0xd9b7c094, (q31_t)0x7a1c9ece, (q31_t)0xd99fc5d4, + (q31_t)0x7a151378, (q31_t)0xd987cc90, (q31_t)0x7a0d836d, (q31_t)0xd96fd4c7, + (q31_t)0x7a05eead, (q31_t)0xd957de7a, (q31_t)0x79fe5539, (q31_t)0xd93fe9ab, + (q31_t)0x79f6b711, (q31_t)0xd927f65b, (q31_t)0x79ef1436, (q31_t)0xd910048a, + (q31_t)0x79e76ca7, (q31_t)0xd8f81439, (q31_t)0x79dfc064, (q31_t)0xd8e0256a, + (q31_t)0x79d80f6f, (q31_t)0xd8c8381d, (q31_t)0x79d059c8, (q31_t)0xd8b04c52, + (q31_t)0x79c89f6e, (q31_t)0xd898620c, (q31_t)0x79c0e062, (q31_t)0xd880794b, + (q31_t)0x79b91ca4, (q31_t)0xd868920f, (q31_t)0x79b15435, (q31_t)0xd850ac5a, + (q31_t)0x79a98715, (q31_t)0xd838c82d, (q31_t)0x79a1b545, (q31_t)0xd820e589, + (q31_t)0x7999dec4, (q31_t)0xd809046e, (q31_t)0x79920392, (q31_t)0xd7f124dd, + (q31_t)0x798a23b1, (q31_t)0xd7d946d8, (q31_t)0x79823f20, (q31_t)0xd7c16a5f, + (q31_t)0x797a55e0, (q31_t)0xd7a98f73, (q31_t)0x797267f2, (q31_t)0xd791b616, + (q31_t)0x796a7554, (q31_t)0xd779de47, (q31_t)0x79627e08, (q31_t)0xd7620808, + (q31_t)0x795a820e, (q31_t)0xd74a335b, (q31_t)0x79528167, (q31_t)0xd732603f, + (q31_t)0x794a7c12, (q31_t)0xd71a8eb5, (q31_t)0x79427210, (q31_t)0xd702bec0, + (q31_t)0x793a6361, (q31_t)0xd6eaf05f, (q31_t)0x79325006, (q31_t)0xd6d32393, + (q31_t)0x792a37fe, (q31_t)0xd6bb585e, (q31_t)0x79221b4b, (q31_t)0xd6a38ec0, + (q31_t)0x7919f9ec, (q31_t)0xd68bc6ba, (q31_t)0x7911d3e2, (q31_t)0xd674004e, + (q31_t)0x7909a92d, (q31_t)0xd65c3b7b, (q31_t)0x790179cd, (q31_t)0xd6447844, + (q31_t)0x78f945c3, (q31_t)0xd62cb6a8, (q31_t)0x78f10d0f, (q31_t)0xd614f6a9, + (q31_t)0x78e8cfb2, (q31_t)0xd5fd3848, (q31_t)0x78e08dab, (q31_t)0xd5e57b85, + (q31_t)0x78d846fb, (q31_t)0xd5cdc062, (q31_t)0x78cffba3, (q31_t)0xd5b606e0, + (q31_t)0x78c7aba2, (q31_t)0xd59e4eff, (q31_t)0x78bf56f9, (q31_t)0xd58698c0, + (q31_t)0x78b6fda8, (q31_t)0xd56ee424, (q31_t)0x78ae9fb0, (q31_t)0xd557312d, + (q31_t)0x78a63d11, (q31_t)0xd53f7fda, (q31_t)0x789dd5cb, (q31_t)0xd527d02e, + (q31_t)0x789569df, (q31_t)0xd5102228, (q31_t)0x788cf94c, (q31_t)0xd4f875ca, + (q31_t)0x78848414, (q31_t)0xd4e0cb15, (q31_t)0x787c0a36, (q31_t)0xd4c92209, + (q31_t)0x78738bb3, (q31_t)0xd4b17aa8, (q31_t)0x786b088c, (q31_t)0xd499d4f2, + (q31_t)0x786280bf, (q31_t)0xd48230e9, (q31_t)0x7859f44f, (q31_t)0xd46a8e8d, + (q31_t)0x7851633b, (q31_t)0xd452eddf, (q31_t)0x7848cd83, (q31_t)0xd43b4ee0, + (q31_t)0x78403329, (q31_t)0xd423b191, (q31_t)0x7837942b, (q31_t)0xd40c15f3, + (q31_t)0x782ef08b, (q31_t)0xd3f47c06, (q31_t)0x78264849, (q31_t)0xd3dce3cd, + (q31_t)0x781d9b65, (q31_t)0xd3c54d47, (q31_t)0x7814e9df, (q31_t)0xd3adb876, + (q31_t)0x780c33b8, (q31_t)0xd396255a, (q31_t)0x780378f1, (q31_t)0xd37e93f4, + (q31_t)0x77fab989, (q31_t)0xd3670446, (q31_t)0x77f1f581, (q31_t)0xd34f764f, + (q31_t)0x77e92cd9, (q31_t)0xd337ea12, (q31_t)0x77e05f91, (q31_t)0xd3205f8f, + (q31_t)0x77d78daa, (q31_t)0xd308d6c7, (q31_t)0x77ceb725, (q31_t)0xd2f14fba, + (q31_t)0x77c5dc01, (q31_t)0xd2d9ca6a, (q31_t)0x77bcfc3f, (q31_t)0xd2c246d8, + (q31_t)0x77b417df, (q31_t)0xd2aac504, (q31_t)0x77ab2ee2, (q31_t)0xd29344f0, + (q31_t)0x77a24148, (q31_t)0xd27bc69c, (q31_t)0x77994f11, (q31_t)0xd2644a0a, + (q31_t)0x7790583e, (q31_t)0xd24ccf39, (q31_t)0x77875cce, (q31_t)0xd235562b, + (q31_t)0x777e5cc3, (q31_t)0xd21ddee2, (q31_t)0x7775581d, (q31_t)0xd206695d, + (q31_t)0x776c4edb, (q31_t)0xd1eef59e, (q31_t)0x776340ff, (q31_t)0xd1d783a6, + (q31_t)0x775a2e89, (q31_t)0xd1c01375, (q31_t)0x77511778, (q31_t)0xd1a8a50d, + (q31_t)0x7747fbce, (q31_t)0xd191386e, (q31_t)0x773edb8b, (q31_t)0xd179cd99, + (q31_t)0x7735b6af, (q31_t)0xd1626490, (q31_t)0x772c8d3a, (q31_t)0xd14afd52, + (q31_t)0x77235f2d, (q31_t)0xd13397e2, (q31_t)0x771a2c88, (q31_t)0xd11c343f, + (q31_t)0x7710f54c, (q31_t)0xd104d26b, (q31_t)0x7707b979, (q31_t)0xd0ed7267, + (q31_t)0x76fe790e, (q31_t)0xd0d61434, (q31_t)0x76f5340e, (q31_t)0xd0beb7d2, + (q31_t)0x76ebea77, (q31_t)0xd0a75d42, (q31_t)0x76e29c4b, (q31_t)0xd0900486, + (q31_t)0x76d94989, (q31_t)0xd078ad9e, (q31_t)0x76cff232, (q31_t)0xd061588b, + (q31_t)0x76c69647, (q31_t)0xd04a054e, (q31_t)0x76bd35c7, (q31_t)0xd032b3e7, + (q31_t)0x76b3d0b4, (q31_t)0xd01b6459, (q31_t)0x76aa670d, (q31_t)0xd00416a3, + (q31_t)0x76a0f8d2, (q31_t)0xcfeccac7, (q31_t)0x76978605, (q31_t)0xcfd580c6, + (q31_t)0x768e0ea6, (q31_t)0xcfbe389f, (q31_t)0x768492b4, (q31_t)0xcfa6f255, + (q31_t)0x767b1231, (q31_t)0xcf8fade9, (q31_t)0x76718d1c, (q31_t)0xcf786b5a, + (q31_t)0x76680376, (q31_t)0xcf612aaa, (q31_t)0x765e7540, (q31_t)0xcf49ebda, + (q31_t)0x7654e279, (q31_t)0xcf32aeeb, (q31_t)0x764b4b23, (q31_t)0xcf1b73de, + (q31_t)0x7641af3d, (q31_t)0xcf043ab3, (q31_t)0x76380ec8, (q31_t)0xceed036b, + (q31_t)0x762e69c4, (q31_t)0xced5ce08, (q31_t)0x7624c031, (q31_t)0xcebe9a8a, + (q31_t)0x761b1211, (q31_t)0xcea768f2, (q31_t)0x76115f63, (q31_t)0xce903942, + (q31_t)0x7607a828, (q31_t)0xce790b79, (q31_t)0x75fdec60, (q31_t)0xce61df99, + (q31_t)0x75f42c0b, (q31_t)0xce4ab5a2, (q31_t)0x75ea672a, (q31_t)0xce338d97, + (q31_t)0x75e09dbd, (q31_t)0xce1c6777, (q31_t)0x75d6cfc5, (q31_t)0xce054343, + (q31_t)0x75ccfd42, (q31_t)0xcdee20fc, (q31_t)0x75c32634, (q31_t)0xcdd700a4, + (q31_t)0x75b94a9c, (q31_t)0xcdbfe23a, (q31_t)0x75af6a7b, (q31_t)0xcda8c5c1, + (q31_t)0x75a585cf, (q31_t)0xcd91ab39, (q31_t)0x759b9c9b, (q31_t)0xcd7a92a2, + (q31_t)0x7591aedd, (q31_t)0xcd637bfe, (q31_t)0x7587bc98, (q31_t)0xcd4c674d, + (q31_t)0x757dc5ca, (q31_t)0xcd355491, (q31_t)0x7573ca75, (q31_t)0xcd1e43ca, + (q31_t)0x7569ca99, (q31_t)0xcd0734f9, (q31_t)0x755fc635, (q31_t)0xccf0281f, + (q31_t)0x7555bd4c, (q31_t)0xccd91d3d, (q31_t)0x754bafdc, (q31_t)0xccc21455, + (q31_t)0x75419de7, (q31_t)0xccab0d65, (q31_t)0x7537876c, (q31_t)0xcc940871, + (q31_t)0x752d6c6c, (q31_t)0xcc7d0578, (q31_t)0x75234ce8, (q31_t)0xcc66047b, + (q31_t)0x751928e0, (q31_t)0xcc4f057c, (q31_t)0x750f0054, (q31_t)0xcc38087b, + (q31_t)0x7504d345, (q31_t)0xcc210d79, (q31_t)0x74faa1b3, (q31_t)0xcc0a1477, + (q31_t)0x74f06b9e, (q31_t)0xcbf31d75, (q31_t)0x74e63108, (q31_t)0xcbdc2876, + (q31_t)0x74dbf1ef, (q31_t)0xcbc53579, (q31_t)0x74d1ae55, (q31_t)0xcbae447f, + (q31_t)0x74c7663a, (q31_t)0xcb97558a, (q31_t)0x74bd199f, (q31_t)0xcb80689a, + (q31_t)0x74b2c884, (q31_t)0xcb697db0, (q31_t)0x74a872e8, (q31_t)0xcb5294ce, + (q31_t)0x749e18cd, (q31_t)0xcb3badf3, (q31_t)0x7493ba34, (q31_t)0xcb24c921, + (q31_t)0x7489571c, (q31_t)0xcb0de658, (q31_t)0x747eef85, (q31_t)0xcaf7059a, + (q31_t)0x74748371, (q31_t)0xcae026e8, (q31_t)0x746a12df, (q31_t)0xcac94a42, + (q31_t)0x745f9dd1, (q31_t)0xcab26fa9, (q31_t)0x74552446, (q31_t)0xca9b971e, + (q31_t)0x744aa63f, (q31_t)0xca84c0a3, (q31_t)0x744023bc, (q31_t)0xca6dec37, + (q31_t)0x74359cbd, (q31_t)0xca5719db, (q31_t)0x742b1144, (q31_t)0xca404992, + (q31_t)0x74208150, (q31_t)0xca297b5a, (q31_t)0x7415ece2, (q31_t)0xca12af37, + (q31_t)0x740b53fb, (q31_t)0xc9fbe527, (q31_t)0x7400b69a, (q31_t)0xc9e51d2d, + (q31_t)0x73f614c0, (q31_t)0xc9ce5748, (q31_t)0x73eb6e6e, (q31_t)0xc9b7937a, + (q31_t)0x73e0c3a3, (q31_t)0xc9a0d1c5, (q31_t)0x73d61461, (q31_t)0xc98a1227, + (q31_t)0x73cb60a8, (q31_t)0xc97354a4, (q31_t)0x73c0a878, (q31_t)0xc95c993a, + (q31_t)0x73b5ebd1, (q31_t)0xc945dfec, (q31_t)0x73ab2ab4, (q31_t)0xc92f28ba, + (q31_t)0x73a06522, (q31_t)0xc91873a5, (q31_t)0x73959b1b, (q31_t)0xc901c0ae, + (q31_t)0x738acc9e, (q31_t)0xc8eb0fd6, (q31_t)0x737ff9ae, (q31_t)0xc8d4611d, + (q31_t)0x73752249, (q31_t)0xc8bdb485, (q31_t)0x736a4671, (q31_t)0xc8a70a0e, + (q31_t)0x735f6626, (q31_t)0xc89061ba, (q31_t)0x73548168, (q31_t)0xc879bb89, + (q31_t)0x73499838, (q31_t)0xc863177b, (q31_t)0x733eaa96, (q31_t)0xc84c7593, + (q31_t)0x7333b883, (q31_t)0xc835d5d0, (q31_t)0x7328c1ff, (q31_t)0xc81f3834, + (q31_t)0x731dc70a, (q31_t)0xc8089cbf, (q31_t)0x7312c7a5, (q31_t)0xc7f20373, + (q31_t)0x7307c3d0, (q31_t)0xc7db6c50, (q31_t)0x72fcbb8c, (q31_t)0xc7c4d757, + (q31_t)0x72f1aed9, (q31_t)0xc7ae4489, (q31_t)0x72e69db7, (q31_t)0xc797b3e7, + (q31_t)0x72db8828, (q31_t)0xc7812572, (q31_t)0x72d06e2b, (q31_t)0xc76a992a, + (q31_t)0x72c54fc1, (q31_t)0xc7540f11, (q31_t)0x72ba2cea, (q31_t)0xc73d8727, + (q31_t)0x72af05a7, (q31_t)0xc727016d, (q31_t)0x72a3d9f7, (q31_t)0xc7107de4, + (q31_t)0x7298a9dd, (q31_t)0xc6f9fc8d, (q31_t)0x728d7557, (q31_t)0xc6e37d69, + (q31_t)0x72823c67, (q31_t)0xc6cd0079, (q31_t)0x7276ff0d, (q31_t)0xc6b685bd, + (q31_t)0x726bbd48, (q31_t)0xc6a00d37, (q31_t)0x7260771b, (q31_t)0xc68996e7, + (q31_t)0x72552c85, (q31_t)0xc67322ce, (q31_t)0x7249dd86, (q31_t)0xc65cb0ed, + (q31_t)0x723e8a20, (q31_t)0xc6464144, (q31_t)0x72333251, (q31_t)0xc62fd3d6, + (q31_t)0x7227d61c, (q31_t)0xc61968a2, (q31_t)0x721c7580, (q31_t)0xc602ffaa, + (q31_t)0x7211107e, (q31_t)0xc5ec98ee, (q31_t)0x7205a716, (q31_t)0xc5d6346f, + (q31_t)0x71fa3949, (q31_t)0xc5bfd22e, (q31_t)0x71eec716, (q31_t)0xc5a9722c, + (q31_t)0x71e35080, (q31_t)0xc593146a, (q31_t)0x71d7d585, (q31_t)0xc57cb8e9, + (q31_t)0x71cc5626, (q31_t)0xc5665fa9, (q31_t)0x71c0d265, (q31_t)0xc55008ab, + (q31_t)0x71b54a41, (q31_t)0xc539b3f1, (q31_t)0x71a9bdba, (q31_t)0xc523617a, + (q31_t)0x719e2cd2, (q31_t)0xc50d1149, (q31_t)0x71929789, (q31_t)0xc4f6c35d, + (q31_t)0x7186fdde, (q31_t)0xc4e077b8, (q31_t)0x717b5fd3, (q31_t)0xc4ca2e5b, + (q31_t)0x716fbd68, (q31_t)0xc4b3e746, (q31_t)0x7164169d, (q31_t)0xc49da27a, + (q31_t)0x71586b74, (q31_t)0xc4875ff9, (q31_t)0x714cbbeb, (q31_t)0xc4711fc2, + (q31_t)0x71410805, (q31_t)0xc45ae1d7, (q31_t)0x71354fc0, (q31_t)0xc444a639, + (q31_t)0x7129931f, (q31_t)0xc42e6ce8, (q31_t)0x711dd220, (q31_t)0xc41835e6, + (q31_t)0x71120cc5, (q31_t)0xc4020133, (q31_t)0x7106430e, (q31_t)0xc3ebced0, + (q31_t)0x70fa74fc, (q31_t)0xc3d59ebe, (q31_t)0x70eea28e, (q31_t)0xc3bf70fd, + (q31_t)0x70e2cbc6, (q31_t)0xc3a94590, (q31_t)0x70d6f0a4, (q31_t)0xc3931c76, + (q31_t)0x70cb1128, (q31_t)0xc37cf5b0, (q31_t)0x70bf2d53, (q31_t)0xc366d140, + (q31_t)0x70b34525, (q31_t)0xc350af26, (q31_t)0x70a7589f, (q31_t)0xc33a8f62, + (q31_t)0x709b67c0, (q31_t)0xc32471f7, (q31_t)0x708f728b, (q31_t)0xc30e56e4, + (q31_t)0x708378ff, (q31_t)0xc2f83e2a, (q31_t)0x70777b1c, (q31_t)0xc2e227cb, + (q31_t)0x706b78e3, (q31_t)0xc2cc13c7, (q31_t)0x705f7255, (q31_t)0xc2b6021f, + (q31_t)0x70536771, (q31_t)0xc29ff2d4, (q31_t)0x70475839, (q31_t)0xc289e5e7, + (q31_t)0x703b44ad, (q31_t)0xc273db58, (q31_t)0x702f2ccd, (q31_t)0xc25dd329, + (q31_t)0x7023109a, (q31_t)0xc247cd5a, (q31_t)0x7016f014, (q31_t)0xc231c9ec, + (q31_t)0x700acb3c, (q31_t)0xc21bc8e1, (q31_t)0x6ffea212, (q31_t)0xc205ca38, + (q31_t)0x6ff27497, (q31_t)0xc1efcdf3, (q31_t)0x6fe642ca, (q31_t)0xc1d9d412, + (q31_t)0x6fda0cae, (q31_t)0xc1c3dc97, (q31_t)0x6fcdd241, (q31_t)0xc1ade781, + (q31_t)0x6fc19385, (q31_t)0xc197f4d4, (q31_t)0x6fb5507a, (q31_t)0xc182048d, + (q31_t)0x6fa90921, (q31_t)0xc16c16b0, (q31_t)0x6f9cbd79, (q31_t)0xc1562b3d, + (q31_t)0x6f906d84, (q31_t)0xc1404233, (q31_t)0x6f841942, (q31_t)0xc12a5b95, + (q31_t)0x6f77c0b3, (q31_t)0xc1147764, (q31_t)0x6f6b63d8, (q31_t)0xc0fe959f, + (q31_t)0x6f5f02b2, (q31_t)0xc0e8b648, (q31_t)0x6f529d40, (q31_t)0xc0d2d960, + (q31_t)0x6f463383, (q31_t)0xc0bcfee7, (q31_t)0x6f39c57d, (q31_t)0xc0a726df, + (q31_t)0x6f2d532c, (q31_t)0xc0915148, (q31_t)0x6f20dc92, (q31_t)0xc07b7e23, + (q31_t)0x6f1461b0, (q31_t)0xc065ad70, (q31_t)0x6f07e285, (q31_t)0xc04fdf32, + (q31_t)0x6efb5f12, (q31_t)0xc03a1368, (q31_t)0x6eeed758, (q31_t)0xc0244a14, + (q31_t)0x6ee24b57, (q31_t)0xc00e8336, (q31_t)0x6ed5bb10, (q31_t)0xbff8bece, + (q31_t)0x6ec92683, (q31_t)0xbfe2fcdf, (q31_t)0x6ebc8db0, (q31_t)0xbfcd3d69, + (q31_t)0x6eaff099, (q31_t)0xbfb7806c, (q31_t)0x6ea34f3d, (q31_t)0xbfa1c5ea, + (q31_t)0x6e96a99d, (q31_t)0xbf8c0de3, (q31_t)0x6e89ffb9, (q31_t)0xbf765858, + (q31_t)0x6e7d5193, (q31_t)0xbf60a54a, (q31_t)0x6e709f2a, (q31_t)0xbf4af4ba, + (q31_t)0x6e63e87f, (q31_t)0xbf3546a8, (q31_t)0x6e572d93, (q31_t)0xbf1f9b16, + (q31_t)0x6e4a6e66, (q31_t)0xbf09f205, (q31_t)0x6e3daaf8, (q31_t)0xbef44b74, + (q31_t)0x6e30e34a, (q31_t)0xbedea765, (q31_t)0x6e24175c, (q31_t)0xbec905d9, + (q31_t)0x6e174730, (q31_t)0xbeb366d1, (q31_t)0x6e0a72c5, (q31_t)0xbe9dca4e, + (q31_t)0x6dfd9a1c, (q31_t)0xbe88304f, (q31_t)0x6df0bd35, (q31_t)0xbe7298d7, + (q31_t)0x6de3dc11, (q31_t)0xbe5d03e6, (q31_t)0x6dd6f6b1, (q31_t)0xbe47717c, + (q31_t)0x6dca0d14, (q31_t)0xbe31e19b, (q31_t)0x6dbd1f3c, (q31_t)0xbe1c5444, + (q31_t)0x6db02d29, (q31_t)0xbe06c977, (q31_t)0x6da336dc, (q31_t)0xbdf14135, + (q31_t)0x6d963c54, (q31_t)0xbddbbb7f, (q31_t)0x6d893d93, (q31_t)0xbdc63856, + (q31_t)0x6d7c3a98, (q31_t)0xbdb0b7bb, (q31_t)0x6d6f3365, (q31_t)0xbd9b39ad, + (q31_t)0x6d6227fa, (q31_t)0xbd85be30, (q31_t)0x6d551858, (q31_t)0xbd704542, + (q31_t)0x6d48047e, (q31_t)0xbd5acee5, (q31_t)0x6d3aec6e, (q31_t)0xbd455b1a, + (q31_t)0x6d2dd027, (q31_t)0xbd2fe9e2, (q31_t)0x6d20afac, (q31_t)0xbd1a7b3d, + (q31_t)0x6d138afb, (q31_t)0xbd050f2c, (q31_t)0x6d066215, (q31_t)0xbcefa5b0, + (q31_t)0x6cf934fc, (q31_t)0xbcda3ecb, (q31_t)0x6cec03af, (q31_t)0xbcc4da7b, + (q31_t)0x6cdece2f, (q31_t)0xbcaf78c4, (q31_t)0x6cd1947c, (q31_t)0xbc9a19a5, + (q31_t)0x6cc45698, (q31_t)0xbc84bd1f, (q31_t)0x6cb71482, (q31_t)0xbc6f6333, + (q31_t)0x6ca9ce3b, (q31_t)0xbc5a0be2, (q31_t)0x6c9c83c3, (q31_t)0xbc44b72c, + (q31_t)0x6c8f351c, (q31_t)0xbc2f6513, (q31_t)0x6c81e245, (q31_t)0xbc1a1598, + (q31_t)0x6c748b3f, (q31_t)0xbc04c8ba, (q31_t)0x6c67300b, (q31_t)0xbbef7e7c, + (q31_t)0x6c59d0a9, (q31_t)0xbbda36dd, (q31_t)0x6c4c6d1a, (q31_t)0xbbc4f1df, + (q31_t)0x6c3f055d, (q31_t)0xbbafaf82, (q31_t)0x6c319975, (q31_t)0xbb9a6fc7, + (q31_t)0x6c242960, (q31_t)0xbb8532b0, (q31_t)0x6c16b521, (q31_t)0xbb6ff83c, + (q31_t)0x6c093cb6, (q31_t)0xbb5ac06d, (q31_t)0x6bfbc021, (q31_t)0xbb458b43, + (q31_t)0x6bee3f62, (q31_t)0xbb3058c0, (q31_t)0x6be0ba7b, (q31_t)0xbb1b28e4, + (q31_t)0x6bd3316a, (q31_t)0xbb05fbb0, (q31_t)0x6bc5a431, (q31_t)0xbaf0d125, + (q31_t)0x6bb812d1, (q31_t)0xbadba943, (q31_t)0x6baa7d49, (q31_t)0xbac6840c, + (q31_t)0x6b9ce39b, (q31_t)0xbab16180, (q31_t)0x6b8f45c7, (q31_t)0xba9c41a0, + (q31_t)0x6b81a3cd, (q31_t)0xba87246d, (q31_t)0x6b73fdae, (q31_t)0xba7209e7, + (q31_t)0x6b66536b, (q31_t)0xba5cf210, (q31_t)0x6b58a503, (q31_t)0xba47dce8, + (q31_t)0x6b4af279, (q31_t)0xba32ca71, (q31_t)0x6b3d3bcb, (q31_t)0xba1dbaaa, + (q31_t)0x6b2f80fb, (q31_t)0xba08ad95, (q31_t)0x6b21c208, (q31_t)0xb9f3a332, + (q31_t)0x6b13fef5, (q31_t)0xb9de9b83, (q31_t)0x6b0637c1, (q31_t)0xb9c99688, + (q31_t)0x6af86c6c, (q31_t)0xb9b49442, (q31_t)0x6aea9cf8, (q31_t)0xb99f94b2, + (q31_t)0x6adcc964, (q31_t)0xb98a97d8, (q31_t)0x6acef1b2, (q31_t)0xb9759db6, + (q31_t)0x6ac115e2, (q31_t)0xb960a64c, (q31_t)0x6ab335f4, (q31_t)0xb94bb19b, + (q31_t)0x6aa551e9, (q31_t)0xb936bfa4, (q31_t)0x6a9769c1, (q31_t)0xb921d067, + (q31_t)0x6a897d7d, (q31_t)0xb90ce3e6, (q31_t)0x6a7b8d1e, (q31_t)0xb8f7fa21, + (q31_t)0x6a6d98a4, (q31_t)0xb8e31319, (q31_t)0x6a5fa010, (q31_t)0xb8ce2ecf, + (q31_t)0x6a51a361, (q31_t)0xb8b94d44, (q31_t)0x6a43a29a, (q31_t)0xb8a46e78, + (q31_t)0x6a359db9, (q31_t)0xb88f926d, (q31_t)0x6a2794c1, (q31_t)0xb87ab922, + (q31_t)0x6a1987b0, (q31_t)0xb865e299, (q31_t)0x6a0b7689, (q31_t)0xb8510ed4, + (q31_t)0x69fd614a, (q31_t)0xb83c3dd1, (q31_t)0x69ef47f6, (q31_t)0xb8276f93, + (q31_t)0x69e12a8c, (q31_t)0xb812a41a, (q31_t)0x69d3090e, (q31_t)0xb7fddb67, + (q31_t)0x69c4e37a, (q31_t)0xb7e9157a, (q31_t)0x69b6b9d3, (q31_t)0xb7d45255, + (q31_t)0x69a88c19, (q31_t)0xb7bf91f8, (q31_t)0x699a5a4c, (q31_t)0xb7aad465, + (q31_t)0x698c246c, (q31_t)0xb796199b, (q31_t)0x697dea7b, (q31_t)0xb781619c, + (q31_t)0x696fac78, (q31_t)0xb76cac69, (q31_t)0x69616a65, (q31_t)0xb757fa01, + (q31_t)0x69532442, (q31_t)0xb7434a67, (q31_t)0x6944da10, (q31_t)0xb72e9d9b, + (q31_t)0x69368bce, (q31_t)0xb719f39e, (q31_t)0x6928397e, (q31_t)0xb7054c6f, + (q31_t)0x6919e320, (q31_t)0xb6f0a812, (q31_t)0x690b88b5, (q31_t)0xb6dc0685, + (q31_t)0x68fd2a3d, (q31_t)0xb6c767ca, (q31_t)0x68eec7b9, (q31_t)0xb6b2cbe2, + (q31_t)0x68e06129, (q31_t)0xb69e32cd, (q31_t)0x68d1f68f, (q31_t)0xb6899c8d, + (q31_t)0x68c387e9, (q31_t)0xb6750921, (q31_t)0x68b5153a, (q31_t)0xb660788c, + (q31_t)0x68a69e81, (q31_t)0xb64beacd, (q31_t)0x689823bf, (q31_t)0xb6375fe5, + (q31_t)0x6889a4f6, (q31_t)0xb622d7d6, (q31_t)0x687b2224, (q31_t)0xb60e529f, + (q31_t)0x686c9b4b, (q31_t)0xb5f9d043, (q31_t)0x685e106c, (q31_t)0xb5e550c1, + (q31_t)0x684f8186, (q31_t)0xb5d0d41a, (q31_t)0x6840ee9b, (q31_t)0xb5bc5a50, + (q31_t)0x683257ab, (q31_t)0xb5a7e362, (q31_t)0x6823bcb7, (q31_t)0xb5936f53, + (q31_t)0x68151dbe, (q31_t)0xb57efe22, (q31_t)0x68067ac3, (q31_t)0xb56a8fd0, + (q31_t)0x67f7d3c5, (q31_t)0xb556245e, (q31_t)0x67e928c5, (q31_t)0xb541bbcd, + (q31_t)0x67da79c3, (q31_t)0xb52d561e, (q31_t)0x67cbc6c0, (q31_t)0xb518f351, + (q31_t)0x67bd0fbd, (q31_t)0xb5049368, (q31_t)0x67ae54ba, (q31_t)0xb4f03663, + (q31_t)0x679f95b7, (q31_t)0xb4dbdc42, (q31_t)0x6790d2b6, (q31_t)0xb4c78507, + (q31_t)0x67820bb7, (q31_t)0xb4b330b3, (q31_t)0x677340ba, (q31_t)0xb49edf45, + (q31_t)0x676471c0, (q31_t)0xb48a90c0, (q31_t)0x67559eca, (q31_t)0xb4764523, + (q31_t)0x6746c7d8, (q31_t)0xb461fc70, (q31_t)0x6737ecea, (q31_t)0xb44db6a8, + (q31_t)0x67290e02, (q31_t)0xb43973ca, (q31_t)0x671a2b20, (q31_t)0xb42533d8, + (q31_t)0x670b4444, (q31_t)0xb410f6d3, (q31_t)0x66fc596f, (q31_t)0xb3fcbcbb, + (q31_t)0x66ed6aa1, (q31_t)0xb3e88592, (q31_t)0x66de77dc, (q31_t)0xb3d45157, + (q31_t)0x66cf8120, (q31_t)0xb3c0200c, (q31_t)0x66c0866d, (q31_t)0xb3abf1b2, + (q31_t)0x66b187c3, (q31_t)0xb397c649, (q31_t)0x66a28524, (q31_t)0xb3839dd3, + (q31_t)0x66937e91, (q31_t)0xb36f784f, (q31_t)0x66847408, (q31_t)0xb35b55bf, + (q31_t)0x6675658c, (q31_t)0xb3473623, (q31_t)0x6666531d, (q31_t)0xb333197c, + (q31_t)0x66573cbb, (q31_t)0xb31effcc, (q31_t)0x66482267, (q31_t)0xb30ae912, + (q31_t)0x66390422, (q31_t)0xb2f6d550, (q31_t)0x6629e1ec, (q31_t)0xb2e2c486, + (q31_t)0x661abbc5, (q31_t)0xb2ceb6b5, (q31_t)0x660b91af, (q31_t)0xb2baabde, + (q31_t)0x65fc63a9, (q31_t)0xb2a6a402, (q31_t)0x65ed31b5, (q31_t)0xb2929f21, + (q31_t)0x65ddfbd3, (q31_t)0xb27e9d3c, (q31_t)0x65cec204, (q31_t)0xb26a9e54, + (q31_t)0x65bf8447, (q31_t)0xb256a26a, (q31_t)0x65b0429f, (q31_t)0xb242a97e, + (q31_t)0x65a0fd0b, (q31_t)0xb22eb392, (q31_t)0x6591b38c, (q31_t)0xb21ac0a6, + (q31_t)0x65826622, (q31_t)0xb206d0ba, (q31_t)0x657314cf, (q31_t)0xb1f2e3d0, + (q31_t)0x6563bf92, (q31_t)0xb1def9e9, (q31_t)0x6554666d, (q31_t)0xb1cb1304, + (q31_t)0x6545095f, (q31_t)0xb1b72f23, (q31_t)0x6535a86b, (q31_t)0xb1a34e47, + (q31_t)0x6526438f, (q31_t)0xb18f7071, (q31_t)0x6516dacd, (q31_t)0xb17b95a0, + (q31_t)0x65076e25, (q31_t)0xb167bdd7, (q31_t)0x64f7fd98, (q31_t)0xb153e915, + (q31_t)0x64e88926, (q31_t)0xb140175b, (q31_t)0x64d910d1, (q31_t)0xb12c48ab, + (q31_t)0x64c99498, (q31_t)0xb1187d05, (q31_t)0x64ba147d, (q31_t)0xb104b46a, + (q31_t)0x64aa907f, (q31_t)0xb0f0eeda, (q31_t)0x649b08a0, (q31_t)0xb0dd2c56, + (q31_t)0x648b7ce0, (q31_t)0xb0c96ce0, (q31_t)0x647bed3f, (q31_t)0xb0b5b077, + (q31_t)0x646c59bf, (q31_t)0xb0a1f71d, (q31_t)0x645cc260, (q31_t)0xb08e40d2, + (q31_t)0x644d2722, (q31_t)0xb07a8d97, (q31_t)0x643d8806, (q31_t)0xb066dd6d, + (q31_t)0x642de50d, (q31_t)0xb0533055, (q31_t)0x641e3e38, (q31_t)0xb03f864f, + (q31_t)0x640e9386, (q31_t)0xb02bdf5c, (q31_t)0x63fee4f8, (q31_t)0xb0183b7d, + (q31_t)0x63ef3290, (q31_t)0xb0049ab3, (q31_t)0x63df7c4d, (q31_t)0xaff0fcfe, + (q31_t)0x63cfc231, (q31_t)0xafdd625f, (q31_t)0x63c0043b, (q31_t)0xafc9cad7, + (q31_t)0x63b0426d, (q31_t)0xafb63667, (q31_t)0x63a07cc7, (q31_t)0xafa2a50f, + (q31_t)0x6390b34a, (q31_t)0xaf8f16d1, (q31_t)0x6380e5f6, (q31_t)0xaf7b8bac, + (q31_t)0x637114cc, (q31_t)0xaf6803a2, (q31_t)0x63613fcd, (q31_t)0xaf547eb3, + (q31_t)0x635166f9, (q31_t)0xaf40fce1, (q31_t)0x63418a50, (q31_t)0xaf2d7e2b, + (q31_t)0x6331a9d4, (q31_t)0xaf1a0293, (q31_t)0x6321c585, (q31_t)0xaf068a1a, + (q31_t)0x6311dd64, (q31_t)0xaef314c0, (q31_t)0x6301f171, (q31_t)0xaedfa285, + (q31_t)0x62f201ac, (q31_t)0xaecc336c, (q31_t)0x62e20e17, (q31_t)0xaeb8c774, + (q31_t)0x62d216b3, (q31_t)0xaea55e9e, (q31_t)0x62c21b7e, (q31_t)0xae91f8eb, + (q31_t)0x62b21c7b, (q31_t)0xae7e965b, (q31_t)0x62a219aa, (q31_t)0xae6b36f0, + (q31_t)0x6292130c, (q31_t)0xae57daab, (q31_t)0x628208a1, (q31_t)0xae44818b, + (q31_t)0x6271fa69, (q31_t)0xae312b92, (q31_t)0x6261e866, (q31_t)0xae1dd8c0, + (q31_t)0x6251d298, (q31_t)0xae0a8916, (q31_t)0x6241b8ff, (q31_t)0xadf73c96, + (q31_t)0x62319b9d, (q31_t)0xade3f33e, (q31_t)0x62217a72, (q31_t)0xadd0ad12, + (q31_t)0x6211557e, (q31_t)0xadbd6a10, (q31_t)0x62012cc2, (q31_t)0xadaa2a3b, + (q31_t)0x61f1003f, (q31_t)0xad96ed92, (q31_t)0x61e0cff5, (q31_t)0xad83b416, + (q31_t)0x61d09be5, (q31_t)0xad707dc8, (q31_t)0x61c06410, (q31_t)0xad5d4aaa, + (q31_t)0x61b02876, (q31_t)0xad4a1aba, (q31_t)0x619fe918, (q31_t)0xad36edfc, + (q31_t)0x618fa5f7, (q31_t)0xad23c46e, (q31_t)0x617f5f12, (q31_t)0xad109e12, + (q31_t)0x616f146c, (q31_t)0xacfd7ae8, (q31_t)0x615ec603, (q31_t)0xacea5af2, + (q31_t)0x614e73da, (q31_t)0xacd73e30, (q31_t)0x613e1df0, (q31_t)0xacc424a3, + (q31_t)0x612dc447, (q31_t)0xacb10e4b, (q31_t)0x611d66de, (q31_t)0xac9dfb29, + (q31_t)0x610d05b7, (q31_t)0xac8aeb3e, (q31_t)0x60fca0d2, (q31_t)0xac77de8b, + (q31_t)0x60ec3830, (q31_t)0xac64d510, (q31_t)0x60dbcbd1, (q31_t)0xac51cecf, + (q31_t)0x60cb5bb7, (q31_t)0xac3ecbc7, (q31_t)0x60bae7e1, (q31_t)0xac2bcbfa, + (q31_t)0x60aa7050, (q31_t)0xac18cf69, (q31_t)0x6099f505, (q31_t)0xac05d613, + (q31_t)0x60897601, (q31_t)0xabf2dffb, (q31_t)0x6078f344, (q31_t)0xabdfed1f, + (q31_t)0x60686ccf, (q31_t)0xabccfd83, (q31_t)0x6057e2a2, (q31_t)0xabba1125, + (q31_t)0x604754bf, (q31_t)0xaba72807, (q31_t)0x6036c325, (q31_t)0xab944229, + (q31_t)0x60262dd6, (q31_t)0xab815f8d, (q31_t)0x601594d1, (q31_t)0xab6e8032, + (q31_t)0x6004f819, (q31_t)0xab5ba41a, (q31_t)0x5ff457ad, (q31_t)0xab48cb46, + (q31_t)0x5fe3b38d, (q31_t)0xab35f5b5, (q31_t)0x5fd30bbc, (q31_t)0xab23236a, + (q31_t)0x5fc26038, (q31_t)0xab105464, (q31_t)0x5fb1b104, (q31_t)0xaafd88a4, + (q31_t)0x5fa0fe1f, (q31_t)0xaaeac02c, (q31_t)0x5f90478a, (q31_t)0xaad7fafb, + (q31_t)0x5f7f8d46, (q31_t)0xaac53912, (q31_t)0x5f6ecf53, (q31_t)0xaab27a73, + (q31_t)0x5f5e0db3, (q31_t)0xaa9fbf1e, (q31_t)0x5f4d4865, (q31_t)0xaa8d0713, + (q31_t)0x5f3c7f6b, (q31_t)0xaa7a5253, (q31_t)0x5f2bb2c5, (q31_t)0xaa67a0e0, + (q31_t)0x5f1ae274, (q31_t)0xaa54f2ba, (q31_t)0x5f0a0e77, (q31_t)0xaa4247e1, + (q31_t)0x5ef936d1, (q31_t)0xaa2fa056, (q31_t)0x5ee85b82, (q31_t)0xaa1cfc1a, + (q31_t)0x5ed77c8a, (q31_t)0xaa0a5b2e, (q31_t)0x5ec699e9, (q31_t)0xa9f7bd92, + (q31_t)0x5eb5b3a2, (q31_t)0xa9e52347, (q31_t)0x5ea4c9b3, (q31_t)0xa9d28c4e, + (q31_t)0x5e93dc1f, (q31_t)0xa9bff8a8, (q31_t)0x5e82eae5, (q31_t)0xa9ad6855, + (q31_t)0x5e71f606, (q31_t)0xa99adb56, (q31_t)0x5e60fd84, (q31_t)0xa98851ac, + (q31_t)0x5e50015d, (q31_t)0xa975cb57, (q31_t)0x5e3f0194, (q31_t)0xa9634858, + (q31_t)0x5e2dfe29, (q31_t)0xa950c8b0, (q31_t)0x5e1cf71c, (q31_t)0xa93e4c5f, + (q31_t)0x5e0bec6e, (q31_t)0xa92bd367, (q31_t)0x5dfade20, (q31_t)0xa9195dc7, + (q31_t)0x5de9cc33, (q31_t)0xa906eb82, (q31_t)0x5dd8b6a7, (q31_t)0xa8f47c97, + (q31_t)0x5dc79d7c, (q31_t)0xa8e21106, (q31_t)0x5db680b4, (q31_t)0xa8cfa8d2, + (q31_t)0x5da5604f, (q31_t)0xa8bd43fa, (q31_t)0x5d943c4e, (q31_t)0xa8aae280, + (q31_t)0x5d8314b1, (q31_t)0xa8988463, (q31_t)0x5d71e979, (q31_t)0xa88629a5, + (q31_t)0x5d60baa7, (q31_t)0xa873d246, (q31_t)0x5d4f883b, (q31_t)0xa8617e48, + (q31_t)0x5d3e5237, (q31_t)0xa84f2daa, (q31_t)0x5d2d189a, (q31_t)0xa83ce06e, + (q31_t)0x5d1bdb65, (q31_t)0xa82a9693, (q31_t)0x5d0a9a9a, (q31_t)0xa818501c, + (q31_t)0x5cf95638, (q31_t)0xa8060d08, (q31_t)0x5ce80e41, (q31_t)0xa7f3cd59, + (q31_t)0x5cd6c2b5, (q31_t)0xa7e1910f, (q31_t)0x5cc57394, (q31_t)0xa7cf582a, + (q31_t)0x5cb420e0, (q31_t)0xa7bd22ac, (q31_t)0x5ca2ca99, (q31_t)0xa7aaf094, + (q31_t)0x5c9170bf, (q31_t)0xa798c1e5, (q31_t)0x5c801354, (q31_t)0xa786969e, + (q31_t)0x5c6eb258, (q31_t)0xa7746ec0, (q31_t)0x5c5d4dcc, (q31_t)0xa7624a4d, + (q31_t)0x5c4be5b0, (q31_t)0xa7502943, (q31_t)0x5c3a7a05, (q31_t)0xa73e0ba5, + (q31_t)0x5c290acc, (q31_t)0xa72bf174, (q31_t)0x5c179806, (q31_t)0xa719daae, + (q31_t)0x5c0621b2, (q31_t)0xa707c757, (q31_t)0x5bf4a7d2, (q31_t)0xa6f5b76d, + (q31_t)0x5be32a67, (q31_t)0xa6e3aaf2, (q31_t)0x5bd1a971, (q31_t)0xa6d1a1e7, + (q31_t)0x5bc024f0, (q31_t)0xa6bf9c4b, (q31_t)0x5bae9ce7, (q31_t)0xa6ad9a21, + (q31_t)0x5b9d1154, (q31_t)0xa69b9b68, (q31_t)0x5b8b8239, (q31_t)0xa689a022, + (q31_t)0x5b79ef96, (q31_t)0xa677a84e, (q31_t)0x5b68596d, (q31_t)0xa665b3ee, + (q31_t)0x5b56bfbd, (q31_t)0xa653c303, (q31_t)0x5b452288, (q31_t)0xa641d58c, + (q31_t)0x5b3381ce, (q31_t)0xa62feb8b, (q31_t)0x5b21dd90, (q31_t)0xa61e0501, + (q31_t)0x5b1035cf, (q31_t)0xa60c21ee, (q31_t)0x5afe8a8b, (q31_t)0xa5fa4252, + (q31_t)0x5aecdbc5, (q31_t)0xa5e8662f, (q31_t)0x5adb297d, (q31_t)0xa5d68d85, + (q31_t)0x5ac973b5, (q31_t)0xa5c4b855, (q31_t)0x5ab7ba6c, (q31_t)0xa5b2e6a0, + (q31_t)0x5aa5fda5, (q31_t)0xa5a11866, (q31_t)0x5a943d5e, (q31_t)0xa58f4da8, + (q31_t)0x5a82799a, (q31_t)0xa57d8666, (q31_t)0x5a70b258, (q31_t)0xa56bc2a2, + (q31_t)0x5a5ee79a, (q31_t)0xa55a025b, (q31_t)0x5a4d1960, (q31_t)0xa5484594, + (q31_t)0x5a3b47ab, (q31_t)0xa5368c4b, (q31_t)0x5a29727b, (q31_t)0xa524d683, + (q31_t)0x5a1799d1, (q31_t)0xa513243b, (q31_t)0x5a05bdae, (q31_t)0xa5017575, + (q31_t)0x59f3de12, (q31_t)0xa4efca31, (q31_t)0x59e1faff, (q31_t)0xa4de2270, + (q31_t)0x59d01475, (q31_t)0xa4cc7e32, (q31_t)0x59be2a74, (q31_t)0xa4badd78, + (q31_t)0x59ac3cfd, (q31_t)0xa4a94043, (q31_t)0x599a4c12, (q31_t)0xa497a693, + (q31_t)0x598857b2, (q31_t)0xa486106a, (q31_t)0x59765fde, (q31_t)0xa4747dc7, + (q31_t)0x59646498, (q31_t)0xa462eeac, (q31_t)0x595265df, (q31_t)0xa4516319, + (q31_t)0x594063b5, (q31_t)0xa43fdb10, (q31_t)0x592e5e19, (q31_t)0xa42e568f, + (q31_t)0x591c550e, (q31_t)0xa41cd599, (q31_t)0x590a4893, (q31_t)0xa40b582e, + (q31_t)0x58f838a9, (q31_t)0xa3f9de4e, (q31_t)0x58e62552, (q31_t)0xa3e867fa, + (q31_t)0x58d40e8c, (q31_t)0xa3d6f534, (q31_t)0x58c1f45b, (q31_t)0xa3c585fb, + (q31_t)0x58afd6bd, (q31_t)0xa3b41a50, (q31_t)0x589db5b3, (q31_t)0xa3a2b234, + (q31_t)0x588b9140, (q31_t)0xa3914da8, (q31_t)0x58796962, (q31_t)0xa37fecac, + (q31_t)0x58673e1b, (q31_t)0xa36e8f41, (q31_t)0x58550f6c, (q31_t)0xa35d3567, + (q31_t)0x5842dd54, (q31_t)0xa34bdf20, (q31_t)0x5830a7d6, (q31_t)0xa33a8c6c, + (q31_t)0x581e6ef1, (q31_t)0xa3293d4b, (q31_t)0x580c32a7, (q31_t)0xa317f1bf, + (q31_t)0x57f9f2f8, (q31_t)0xa306a9c8, (q31_t)0x57e7afe4, (q31_t)0xa2f56566, + (q31_t)0x57d5696d, (q31_t)0xa2e4249b, (q31_t)0x57c31f92, (q31_t)0xa2d2e766, + (q31_t)0x57b0d256, (q31_t)0xa2c1adc9, (q31_t)0x579e81b8, (q31_t)0xa2b077c5, + (q31_t)0x578c2dba, (q31_t)0xa29f4559, (q31_t)0x5779d65b, (q31_t)0xa28e1687, + (q31_t)0x57677b9d, (q31_t)0xa27ceb4f, (q31_t)0x57551d80, (q31_t)0xa26bc3b2, + (q31_t)0x5742bc06, (q31_t)0xa25a9fb1, (q31_t)0x5730572e, (q31_t)0xa2497f4c, + (q31_t)0x571deefa, (q31_t)0xa2386284, (q31_t)0x570b8369, (q31_t)0xa2274959, + (q31_t)0x56f9147e, (q31_t)0xa21633cd, (q31_t)0x56e6a239, (q31_t)0xa20521e0, + (q31_t)0x56d42c99, (q31_t)0xa1f41392, (q31_t)0x56c1b3a1, (q31_t)0xa1e308e4, + (q31_t)0x56af3750, (q31_t)0xa1d201d7, (q31_t)0x569cb7a8, (q31_t)0xa1c0fe6c, + (q31_t)0x568a34a9, (q31_t)0xa1affea3, (q31_t)0x5677ae54, (q31_t)0xa19f027c, + (q31_t)0x566524aa, (q31_t)0xa18e09fa, (q31_t)0x565297ab, (q31_t)0xa17d151b, + (q31_t)0x56400758, (q31_t)0xa16c23e1, (q31_t)0x562d73b2, (q31_t)0xa15b364d, + (q31_t)0x561adcb9, (q31_t)0xa14a4c5e, (q31_t)0x5608426e, (q31_t)0xa1396617, + (q31_t)0x55f5a4d2, (q31_t)0xa1288376, (q31_t)0x55e303e6, (q31_t)0xa117a47e, + (q31_t)0x55d05faa, (q31_t)0xa106c92f, (q31_t)0x55bdb81f, (q31_t)0xa0f5f189, + (q31_t)0x55ab0d46, (q31_t)0xa0e51d8c, (q31_t)0x55985f20, (q31_t)0xa0d44d3b, + (q31_t)0x5585adad, (q31_t)0xa0c38095, (q31_t)0x5572f8ed, (q31_t)0xa0b2b79b, + (q31_t)0x556040e2, (q31_t)0xa0a1f24d, (q31_t)0x554d858d, (q31_t)0xa09130ad, + (q31_t)0x553ac6ee, (q31_t)0xa08072ba, (q31_t)0x55280505, (q31_t)0xa06fb876, + (q31_t)0x55153fd4, (q31_t)0xa05f01e1, (q31_t)0x5502775c, (q31_t)0xa04e4efc, + (q31_t)0x54efab9c, (q31_t)0xa03d9fc8, (q31_t)0x54dcdc96, (q31_t)0xa02cf444, + (q31_t)0x54ca0a4b, (q31_t)0xa01c4c73, (q31_t)0x54b734ba, (q31_t)0xa00ba853, + (q31_t)0x54a45be6, (q31_t)0x9ffb07e7, (q31_t)0x54917fce, (q31_t)0x9fea6b2f, + (q31_t)0x547ea073, (q31_t)0x9fd9d22a, (q31_t)0x546bbdd7, (q31_t)0x9fc93cdb, + (q31_t)0x5458d7f9, (q31_t)0x9fb8ab41, (q31_t)0x5445eedb, (q31_t)0x9fa81d5e, + (q31_t)0x5433027d, (q31_t)0x9f979331, (q31_t)0x542012e1, (q31_t)0x9f870cbc, + (q31_t)0x540d2005, (q31_t)0x9f7689ff, (q31_t)0x53fa29ed, (q31_t)0x9f660afb, + (q31_t)0x53e73097, (q31_t)0x9f558fb0, (q31_t)0x53d43406, (q31_t)0x9f45181f, + (q31_t)0x53c13439, (q31_t)0x9f34a449, (q31_t)0x53ae3131, (q31_t)0x9f24342f, + (q31_t)0x539b2af0, (q31_t)0x9f13c7d0, (q31_t)0x53882175, (q31_t)0x9f035f2e, + (q31_t)0x537514c2, (q31_t)0x9ef2fa49, (q31_t)0x536204d7, (q31_t)0x9ee29922, + (q31_t)0x534ef1b5, (q31_t)0x9ed23bb9, (q31_t)0x533bdb5d, (q31_t)0x9ec1e210, + (q31_t)0x5328c1d0, (q31_t)0x9eb18c26, (q31_t)0x5315a50e, (q31_t)0x9ea139fd, + (q31_t)0x53028518, (q31_t)0x9e90eb94, (q31_t)0x52ef61ee, (q31_t)0x9e80a0ee, + (q31_t)0x52dc3b92, (q31_t)0x9e705a09, (q31_t)0x52c91204, (q31_t)0x9e6016e8, + (q31_t)0x52b5e546, (q31_t)0x9e4fd78a, (q31_t)0x52a2b556, (q31_t)0x9e3f9bf0, + (q31_t)0x528f8238, (q31_t)0x9e2f641b, (q31_t)0x527c4bea, (q31_t)0x9e1f300b, + (q31_t)0x5269126e, (q31_t)0x9e0effc1, (q31_t)0x5255d5c5, (q31_t)0x9dfed33e, + (q31_t)0x524295f0, (q31_t)0x9deeaa82, (q31_t)0x522f52ee, (q31_t)0x9dde858e, + (q31_t)0x521c0cc2, (q31_t)0x9dce6463, (q31_t)0x5208c36a, (q31_t)0x9dbe4701, + (q31_t)0x51f576ea, (q31_t)0x9dae2d68, (q31_t)0x51e22740, (q31_t)0x9d9e179a, + (q31_t)0x51ced46e, (q31_t)0x9d8e0597, (q31_t)0x51bb7e75, (q31_t)0x9d7df75f, + (q31_t)0x51a82555, (q31_t)0x9d6decf4, (q31_t)0x5194c910, (q31_t)0x9d5de656, + (q31_t)0x518169a5, (q31_t)0x9d4de385, (q31_t)0x516e0715, (q31_t)0x9d3de482, + (q31_t)0x515aa162, (q31_t)0x9d2de94d, (q31_t)0x5147388c, (q31_t)0x9d1df1e9, + (q31_t)0x5133cc94, (q31_t)0x9d0dfe54, (q31_t)0x51205d7b, (q31_t)0x9cfe0e8f, + (q31_t)0x510ceb40, (q31_t)0x9cee229c, (q31_t)0x50f975e6, (q31_t)0x9cde3a7b, + (q31_t)0x50e5fd6d, (q31_t)0x9cce562c, (q31_t)0x50d281d5, (q31_t)0x9cbe75b0, + (q31_t)0x50bf031f, (q31_t)0x9cae9907, (q31_t)0x50ab814d, (q31_t)0x9c9ec033, + (q31_t)0x5097fc5e, (q31_t)0x9c8eeb34, (q31_t)0x50847454, (q31_t)0x9c7f1a0a, + (q31_t)0x5070e92f, (q31_t)0x9c6f4cb6, (q31_t)0x505d5af1, (q31_t)0x9c5f8339, + (q31_t)0x5049c999, (q31_t)0x9c4fbd93, (q31_t)0x50363529, (q31_t)0x9c3ffbc5, + (q31_t)0x50229da1, (q31_t)0x9c303dcf, (q31_t)0x500f0302, (q31_t)0x9c2083b3, + (q31_t)0x4ffb654d, (q31_t)0x9c10cd70, (q31_t)0x4fe7c483, (q31_t)0x9c011b08, + (q31_t)0x4fd420a4, (q31_t)0x9bf16c7a, (q31_t)0x4fc079b1, (q31_t)0x9be1c1c8, + (q31_t)0x4faccfab, (q31_t)0x9bd21af3, (q31_t)0x4f992293, (q31_t)0x9bc277fa, + (q31_t)0x4f857269, (q31_t)0x9bb2d8de, (q31_t)0x4f71bf2e, (q31_t)0x9ba33da0, + (q31_t)0x4f5e08e3, (q31_t)0x9b93a641, (q31_t)0x4f4a4f89, (q31_t)0x9b8412c1, + (q31_t)0x4f369320, (q31_t)0x9b748320, (q31_t)0x4f22d3aa, (q31_t)0x9b64f760, + (q31_t)0x4f0f1126, (q31_t)0x9b556f81, (q31_t)0x4efb4b96, (q31_t)0x9b45eb83, + (q31_t)0x4ee782fb, (q31_t)0x9b366b68, (q31_t)0x4ed3b755, (q31_t)0x9b26ef2f, + (q31_t)0x4ebfe8a5, (q31_t)0x9b1776da, (q31_t)0x4eac16eb, (q31_t)0x9b080268, + (q31_t)0x4e984229, (q31_t)0x9af891db, (q31_t)0x4e846a60, (q31_t)0x9ae92533, + (q31_t)0x4e708f8f, (q31_t)0x9ad9bc71, (q31_t)0x4e5cb1b9, (q31_t)0x9aca5795, + (q31_t)0x4e48d0dd, (q31_t)0x9abaf6a1, (q31_t)0x4e34ecfc, (q31_t)0x9aab9993, + (q31_t)0x4e210617, (q31_t)0x9a9c406e, (q31_t)0x4e0d1c30, (q31_t)0x9a8ceb31, + (q31_t)0x4df92f46, (q31_t)0x9a7d99de, (q31_t)0x4de53f5a, (q31_t)0x9a6e4c74, + (q31_t)0x4dd14c6e, (q31_t)0x9a5f02f5, (q31_t)0x4dbd5682, (q31_t)0x9a4fbd61, + (q31_t)0x4da95d96, (q31_t)0x9a407bb9, (q31_t)0x4d9561ac, (q31_t)0x9a313dfc, + (q31_t)0x4d8162c4, (q31_t)0x9a22042d, (q31_t)0x4d6d60df, (q31_t)0x9a12ce4b, + (q31_t)0x4d595bfe, (q31_t)0x9a039c57, (q31_t)0x4d455422, (q31_t)0x99f46e51, + (q31_t)0x4d31494b, (q31_t)0x99e5443b, (q31_t)0x4d1d3b7a, (q31_t)0x99d61e14, + (q31_t)0x4d092ab0, (q31_t)0x99c6fbde, (q31_t)0x4cf516ee, (q31_t)0x99b7dd99, + (q31_t)0x4ce10034, (q31_t)0x99a8c345, (q31_t)0x4ccce684, (q31_t)0x9999ace3, + (q31_t)0x4cb8c9dd, (q31_t)0x998a9a74, (q31_t)0x4ca4aa41, (q31_t)0x997b8bf8, + (q31_t)0x4c9087b1, (q31_t)0x996c816f, (q31_t)0x4c7c622d, (q31_t)0x995d7adc, + (q31_t)0x4c6839b7, (q31_t)0x994e783d, (q31_t)0x4c540e4e, (q31_t)0x993f7993, + (q31_t)0x4c3fdff4, (q31_t)0x99307ee0, (q31_t)0x4c2baea9, (q31_t)0x99218824, + (q31_t)0x4c177a6e, (q31_t)0x9912955f, (q31_t)0x4c034345, (q31_t)0x9903a691, + (q31_t)0x4bef092d, (q31_t)0x98f4bbbc, (q31_t)0x4bdacc28, (q31_t)0x98e5d4e0, + (q31_t)0x4bc68c36, (q31_t)0x98d6f1fe, (q31_t)0x4bb24958, (q31_t)0x98c81316, + (q31_t)0x4b9e0390, (q31_t)0x98b93828, (q31_t)0x4b89badd, (q31_t)0x98aa6136, + (q31_t)0x4b756f40, (q31_t)0x989b8e40, (q31_t)0x4b6120bb, (q31_t)0x988cbf46, + (q31_t)0x4b4ccf4d, (q31_t)0x987df449, (q31_t)0x4b387af9, (q31_t)0x986f2d4a, + (q31_t)0x4b2423be, (q31_t)0x98606a49, (q31_t)0x4b0fc99d, (q31_t)0x9851ab46, + (q31_t)0x4afb6c98, (q31_t)0x9842f043, (q31_t)0x4ae70caf, (q31_t)0x98343940, + (q31_t)0x4ad2a9e2, (q31_t)0x9825863d, (q31_t)0x4abe4433, (q31_t)0x9816d73b, + (q31_t)0x4aa9dba2, (q31_t)0x98082c3b, (q31_t)0x4a957030, (q31_t)0x97f9853d, + (q31_t)0x4a8101de, (q31_t)0x97eae242, (q31_t)0x4a6c90ad, (q31_t)0x97dc4349, + (q31_t)0x4a581c9e, (q31_t)0x97cda855, (q31_t)0x4a43a5b0, (q31_t)0x97bf1165, + (q31_t)0x4a2f2be6, (q31_t)0x97b07e7a, (q31_t)0x4a1aaf3f, (q31_t)0x97a1ef94, + (q31_t)0x4a062fbd, (q31_t)0x979364b5, (q31_t)0x49f1ad61, (q31_t)0x9784dddc, + (q31_t)0x49dd282a, (q31_t)0x97765b0a, (q31_t)0x49c8a01b, (q31_t)0x9767dc41, + (q31_t)0x49b41533, (q31_t)0x9759617f, (q31_t)0x499f8774, (q31_t)0x974aeac6, + (q31_t)0x498af6df, (q31_t)0x973c7817, (q31_t)0x49766373, (q31_t)0x972e0971, + (q31_t)0x4961cd33, (q31_t)0x971f9ed7, (q31_t)0x494d341e, (q31_t)0x97113847, + (q31_t)0x49389836, (q31_t)0x9702d5c3, (q31_t)0x4923f97b, (q31_t)0x96f4774b, + (q31_t)0x490f57ee, (q31_t)0x96e61ce0, (q31_t)0x48fab391, (q31_t)0x96d7c682, + (q31_t)0x48e60c62, (q31_t)0x96c97432, (q31_t)0x48d16265, (q31_t)0x96bb25f0, + (q31_t)0x48bcb599, (q31_t)0x96acdbbe, (q31_t)0x48a805ff, (q31_t)0x969e959b, + (q31_t)0x48935397, (q31_t)0x96905388, (q31_t)0x487e9e64, (q31_t)0x96821585, + (q31_t)0x4869e665, (q31_t)0x9673db94, (q31_t)0x48552b9b, (q31_t)0x9665a5b4, + (q31_t)0x48406e08, (q31_t)0x965773e7, (q31_t)0x482badab, (q31_t)0x9649462d, + (q31_t)0x4816ea86, (q31_t)0x963b1c86, (q31_t)0x48022499, (q31_t)0x962cf6f2, + (q31_t)0x47ed5be6, (q31_t)0x961ed574, (q31_t)0x47d8906d, (q31_t)0x9610b80a, + (q31_t)0x47c3c22f, (q31_t)0x96029eb6, (q31_t)0x47aef12c, (q31_t)0x95f48977, + (q31_t)0x479a1d67, (q31_t)0x95e67850, (q31_t)0x478546de, (q31_t)0x95d86b3f, + (q31_t)0x47706d93, (q31_t)0x95ca6247, (q31_t)0x475b9188, (q31_t)0x95bc5d66, + (q31_t)0x4746b2bc, (q31_t)0x95ae5c9f, (q31_t)0x4731d131, (q31_t)0x95a05ff0, + (q31_t)0x471cece7, (q31_t)0x9592675c, (q31_t)0x470805df, (q31_t)0x958472e2, + (q31_t)0x46f31c1a, (q31_t)0x95768283, (q31_t)0x46de2f99, (q31_t)0x9568963f, + (q31_t)0x46c9405c, (q31_t)0x955aae17, (q31_t)0x46b44e65, (q31_t)0x954cca0c, + (q31_t)0x469f59b4, (q31_t)0x953eea1e, (q31_t)0x468a624a, (q31_t)0x95310e4e, + (q31_t)0x46756828, (q31_t)0x9523369c, (q31_t)0x46606b4e, (q31_t)0x95156308, + (q31_t)0x464b6bbe, (q31_t)0x95079394, (q31_t)0x46366978, (q31_t)0x94f9c83f, + (q31_t)0x4621647d, (q31_t)0x94ec010b, (q31_t)0x460c5cce, (q31_t)0x94de3df8, + (q31_t)0x45f7526b, (q31_t)0x94d07f05, (q31_t)0x45e24556, (q31_t)0x94c2c435, + (q31_t)0x45cd358f, (q31_t)0x94b50d87, (q31_t)0x45b82318, (q31_t)0x94a75afd, + (q31_t)0x45a30df0, (q31_t)0x9499ac95, (q31_t)0x458df619, (q31_t)0x948c0252, + (q31_t)0x4578db93, (q31_t)0x947e5c33, (q31_t)0x4563be60, (q31_t)0x9470ba39, + (q31_t)0x454e9e80, (q31_t)0x94631c65, (q31_t)0x45397bf4, (q31_t)0x945582b7, + (q31_t)0x452456bd, (q31_t)0x9447ed2f, (q31_t)0x450f2edb, (q31_t)0x943a5bcf, + (q31_t)0x44fa0450, (q31_t)0x942cce96, (q31_t)0x44e4d71c, (q31_t)0x941f4585, + (q31_t)0x44cfa740, (q31_t)0x9411c09e, (q31_t)0x44ba74bd, (q31_t)0x94043fdf, + (q31_t)0x44a53f93, (q31_t)0x93f6c34a, (q31_t)0x449007c4, (q31_t)0x93e94adf, + (q31_t)0x447acd50, (q31_t)0x93dbd6a0, (q31_t)0x44659039, (q31_t)0x93ce668b, + (q31_t)0x4450507e, (q31_t)0x93c0faa3, (q31_t)0x443b0e21, (q31_t)0x93b392e6, + (q31_t)0x4425c923, (q31_t)0x93a62f57, (q31_t)0x44108184, (q31_t)0x9398cff5, + (q31_t)0x43fb3746, (q31_t)0x938b74c1, (q31_t)0x43e5ea68, (q31_t)0x937e1dbb, + (q31_t)0x43d09aed, (q31_t)0x9370cae4, (q31_t)0x43bb48d4, (q31_t)0x93637c3d, + (q31_t)0x43a5f41e, (q31_t)0x935631c5, (q31_t)0x43909ccd, (q31_t)0x9348eb7e, + (q31_t)0x437b42e1, (q31_t)0x933ba968, (q31_t)0x4365e65b, (q31_t)0x932e6b84, + (q31_t)0x4350873c, (q31_t)0x932131d1, (q31_t)0x433b2585, (q31_t)0x9313fc51, + (q31_t)0x4325c135, (q31_t)0x9306cb04, (q31_t)0x43105a50, (q31_t)0x92f99deb, + (q31_t)0x42faf0d4, (q31_t)0x92ec7505, (q31_t)0x42e584c3, (q31_t)0x92df5054, + (q31_t)0x42d0161e, (q31_t)0x92d22fd9, (q31_t)0x42baa4e6, (q31_t)0x92c51392, + (q31_t)0x42a5311b, (q31_t)0x92b7fb82, (q31_t)0x428fbabe, (q31_t)0x92aae7a8, + (q31_t)0x427a41d0, (q31_t)0x929dd806, (q31_t)0x4264c653, (q31_t)0x9290cc9b, + (q31_t)0x424f4845, (q31_t)0x9283c568, (q31_t)0x4239c7aa, (q31_t)0x9276c26d, + (q31_t)0x42244481, (q31_t)0x9269c3ac, (q31_t)0x420ebecb, (q31_t)0x925cc924, + (q31_t)0x41f93689, (q31_t)0x924fd2d7, (q31_t)0x41e3abbc, (q31_t)0x9242e0c4, + (q31_t)0x41ce1e65, (q31_t)0x9235f2ec, (q31_t)0x41b88e84, (q31_t)0x9229094f, + (q31_t)0x41a2fc1a, (q31_t)0x921c23ef, (q31_t)0x418d6729, (q31_t)0x920f42cb, + (q31_t)0x4177cfb1, (q31_t)0x920265e4, (q31_t)0x416235b2, (q31_t)0x91f58d3b, + (q31_t)0x414c992f, (q31_t)0x91e8b8d0, (q31_t)0x4136fa27, (q31_t)0x91dbe8a4, + (q31_t)0x4121589b, (q31_t)0x91cf1cb6, (q31_t)0x410bb48c, (q31_t)0x91c25508, + (q31_t)0x40f60dfb, (q31_t)0x91b5919a, (q31_t)0x40e064ea, (q31_t)0x91a8d26d, + (q31_t)0x40cab958, (q31_t)0x919c1781, (q31_t)0x40b50b46, (q31_t)0x918f60d6, + (q31_t)0x409f5ab6, (q31_t)0x9182ae6d, (q31_t)0x4089a7a8, (q31_t)0x91760047, + (q31_t)0x4073f21d, (q31_t)0x91695663, (q31_t)0x405e3a16, (q31_t)0x915cb0c3, + (q31_t)0x40487f94, (q31_t)0x91500f67, (q31_t)0x4032c297, (q31_t)0x91437250, + (q31_t)0x401d0321, (q31_t)0x9136d97d, (q31_t)0x40074132, (q31_t)0x912a44f0, + (q31_t)0x3ff17cca, (q31_t)0x911db4a9, (q31_t)0x3fdbb5ec, (q31_t)0x911128a8, + (q31_t)0x3fc5ec98, (q31_t)0x9104a0ee, (q31_t)0x3fb020ce, (q31_t)0x90f81d7b, + (q31_t)0x3f9a5290, (q31_t)0x90eb9e50, (q31_t)0x3f8481dd, (q31_t)0x90df236e, + (q31_t)0x3f6eaeb8, (q31_t)0x90d2acd4, (q31_t)0x3f58d921, (q31_t)0x90c63a83, + (q31_t)0x3f430119, (q31_t)0x90b9cc7d, (q31_t)0x3f2d26a0, (q31_t)0x90ad62c0, + (q31_t)0x3f1749b8, (q31_t)0x90a0fd4e, (q31_t)0x3f016a61, (q31_t)0x90949c28, + (q31_t)0x3eeb889c, (q31_t)0x90883f4d, (q31_t)0x3ed5a46b, (q31_t)0x907be6be, + (q31_t)0x3ebfbdcd, (q31_t)0x906f927c, (q31_t)0x3ea9d4c3, (q31_t)0x90634287, + (q31_t)0x3e93e950, (q31_t)0x9056f6df, (q31_t)0x3e7dfb73, (q31_t)0x904aaf86, + (q31_t)0x3e680b2c, (q31_t)0x903e6c7b, (q31_t)0x3e52187f, (q31_t)0x90322dbf, + (q31_t)0x3e3c2369, (q31_t)0x9025f352, (q31_t)0x3e262bee, (q31_t)0x9019bd36, + (q31_t)0x3e10320d, (q31_t)0x900d8b69, (q31_t)0x3dfa35c8, (q31_t)0x90015dee, + (q31_t)0x3de4371f, (q31_t)0x8ff534c4, (q31_t)0x3dce3614, (q31_t)0x8fe90fec, + (q31_t)0x3db832a6, (q31_t)0x8fdcef66, (q31_t)0x3da22cd7, (q31_t)0x8fd0d333, + (q31_t)0x3d8c24a8, (q31_t)0x8fc4bb53, (q31_t)0x3d761a19, (q31_t)0x8fb8a7c7, + (q31_t)0x3d600d2c, (q31_t)0x8fac988f, (q31_t)0x3d49fde1, (q31_t)0x8fa08dab, + (q31_t)0x3d33ec39, (q31_t)0x8f94871d, (q31_t)0x3d1dd835, (q31_t)0x8f8884e4, + (q31_t)0x3d07c1d6, (q31_t)0x8f7c8701, (q31_t)0x3cf1a91c, (q31_t)0x8f708d75, + (q31_t)0x3cdb8e09, (q31_t)0x8f649840, (q31_t)0x3cc5709e, (q31_t)0x8f58a761, + (q31_t)0x3caf50da, (q31_t)0x8f4cbadb, (q31_t)0x3c992ec0, (q31_t)0x8f40d2ad, + (q31_t)0x3c830a50, (q31_t)0x8f34eed8, (q31_t)0x3c6ce38a, (q31_t)0x8f290f5c, + (q31_t)0x3c56ba70, (q31_t)0x8f1d343a, (q31_t)0x3c408f03, (q31_t)0x8f115d72, + (q31_t)0x3c2a6142, (q31_t)0x8f058b04, (q31_t)0x3c143130, (q31_t)0x8ef9bcf2, + (q31_t)0x3bfdfecd, (q31_t)0x8eedf33b, (q31_t)0x3be7ca1a, (q31_t)0x8ee22de0, + (q31_t)0x3bd19318, (q31_t)0x8ed66ce1, (q31_t)0x3bbb59c7, (q31_t)0x8ecab040, + (q31_t)0x3ba51e29, (q31_t)0x8ebef7fb, (q31_t)0x3b8ee03e, (q31_t)0x8eb34415, + (q31_t)0x3b78a007, (q31_t)0x8ea7948c, (q31_t)0x3b625d86, (q31_t)0x8e9be963, + (q31_t)0x3b4c18ba, (q31_t)0x8e904298, (q31_t)0x3b35d1a5, (q31_t)0x8e84a02d, + (q31_t)0x3b1f8848, (q31_t)0x8e790222, (q31_t)0x3b093ca3, (q31_t)0x8e6d6877, + (q31_t)0x3af2eeb7, (q31_t)0x8e61d32e, (q31_t)0x3adc9e86, (q31_t)0x8e564246, + (q31_t)0x3ac64c0f, (q31_t)0x8e4ab5bf, (q31_t)0x3aaff755, (q31_t)0x8e3f2d9b, + (q31_t)0x3a99a057, (q31_t)0x8e33a9da, (q31_t)0x3a834717, (q31_t)0x8e282a7b, + (q31_t)0x3a6ceb96, (q31_t)0x8e1caf80, (q31_t)0x3a568dd4, (q31_t)0x8e1138ea, + (q31_t)0x3a402dd2, (q31_t)0x8e05c6b7, (q31_t)0x3a29cb91, (q31_t)0x8dfa58ea, + (q31_t)0x3a136712, (q31_t)0x8deeef82, (q31_t)0x39fd0056, (q31_t)0x8de38a80, + (q31_t)0x39e6975e, (q31_t)0x8dd829e4, (q31_t)0x39d02c2a, (q31_t)0x8dcccdaf, + (q31_t)0x39b9bebc, (q31_t)0x8dc175e0, (q31_t)0x39a34f13, (q31_t)0x8db6227a, + (q31_t)0x398cdd32, (q31_t)0x8daad37b, (q31_t)0x39766919, (q31_t)0x8d9f88e5, + (q31_t)0x395ff2c9, (q31_t)0x8d9442b8, (q31_t)0x39497a43, (q31_t)0x8d8900f3, + (q31_t)0x3932ff87, (q31_t)0x8d7dc399, (q31_t)0x391c8297, (q31_t)0x8d728aa9, + (q31_t)0x39060373, (q31_t)0x8d675623, (q31_t)0x38ef821c, (q31_t)0x8d5c2609, + (q31_t)0x38d8fe93, (q31_t)0x8d50fa59, (q31_t)0x38c278d9, (q31_t)0x8d45d316, + (q31_t)0x38abf0ef, (q31_t)0x8d3ab03f, (q31_t)0x389566d6, (q31_t)0x8d2f91d5, + (q31_t)0x387eda8e, (q31_t)0x8d2477d8, (q31_t)0x38684c19, (q31_t)0x8d196249, + (q31_t)0x3851bb77, (q31_t)0x8d0e5127, (q31_t)0x383b28a9, (q31_t)0x8d034474, + (q31_t)0x382493b0, (q31_t)0x8cf83c30, (q31_t)0x380dfc8d, (q31_t)0x8ced385b, + (q31_t)0x37f76341, (q31_t)0x8ce238f6, (q31_t)0x37e0c7cc, (q31_t)0x8cd73e01, + (q31_t)0x37ca2a30, (q31_t)0x8ccc477d, (q31_t)0x37b38a6d, (q31_t)0x8cc1556a, + (q31_t)0x379ce885, (q31_t)0x8cb667c8, (q31_t)0x37864477, (q31_t)0x8cab7e98, + (q31_t)0x376f9e46, (q31_t)0x8ca099da, (q31_t)0x3758f5f2, (q31_t)0x8c95b98f, + (q31_t)0x37424b7b, (q31_t)0x8c8addb7, (q31_t)0x372b9ee3, (q31_t)0x8c800652, + (q31_t)0x3714f02a, (q31_t)0x8c753362, (q31_t)0x36fe3f52, (q31_t)0x8c6a64e5, + (q31_t)0x36e78c5b, (q31_t)0x8c5f9ade, (q31_t)0x36d0d746, (q31_t)0x8c54d54c, + (q31_t)0x36ba2014, (q31_t)0x8c4a142f, (q31_t)0x36a366c6, (q31_t)0x8c3f5788, + (q31_t)0x368cab5c, (q31_t)0x8c349f58, (q31_t)0x3675edd9, (q31_t)0x8c29eb9f, + (q31_t)0x365f2e3b, (q31_t)0x8c1f3c5d, (q31_t)0x36486c86, (q31_t)0x8c149192, + (q31_t)0x3631a8b8, (q31_t)0x8c09eb40, (q31_t)0x361ae2d3, (q31_t)0x8bff4966, + (q31_t)0x36041ad9, (q31_t)0x8bf4ac05, (q31_t)0x35ed50c9, (q31_t)0x8bea131e, + (q31_t)0x35d684a6, (q31_t)0x8bdf7eb0, (q31_t)0x35bfb66e, (q31_t)0x8bd4eebc, + (q31_t)0x35a8e625, (q31_t)0x8bca6343, (q31_t)0x359213c9, (q31_t)0x8bbfdc44, + (q31_t)0x357b3f5d, (q31_t)0x8bb559c1, (q31_t)0x356468e2, (q31_t)0x8baadbba, + (q31_t)0x354d9057, (q31_t)0x8ba0622f, (q31_t)0x3536b5be, (q31_t)0x8b95ed21, + (q31_t)0x351fd918, (q31_t)0x8b8b7c8f, (q31_t)0x3508fa66, (q31_t)0x8b81107b, + (q31_t)0x34f219a8, (q31_t)0x8b76a8e4, (q31_t)0x34db36df, (q31_t)0x8b6c45cc, + (q31_t)0x34c4520d, (q31_t)0x8b61e733, (q31_t)0x34ad6b32, (q31_t)0x8b578d18, + (q31_t)0x34968250, (q31_t)0x8b4d377c, (q31_t)0x347f9766, (q31_t)0x8b42e661, + (q31_t)0x3468aa76, (q31_t)0x8b3899c6, (q31_t)0x3451bb81, (q31_t)0x8b2e51ab, + (q31_t)0x343aca87, (q31_t)0x8b240e11, (q31_t)0x3423d78a, (q31_t)0x8b19cef8, + (q31_t)0x340ce28b, (q31_t)0x8b0f9462, (q31_t)0x33f5eb89, (q31_t)0x8b055e4d, + (q31_t)0x33def287, (q31_t)0x8afb2cbb, (q31_t)0x33c7f785, (q31_t)0x8af0ffac, + (q31_t)0x33b0fa84, (q31_t)0x8ae6d720, (q31_t)0x3399fb85, (q31_t)0x8adcb318, + (q31_t)0x3382fa88, (q31_t)0x8ad29394, (q31_t)0x336bf78f, (q31_t)0x8ac87894, + (q31_t)0x3354f29b, (q31_t)0x8abe6219, (q31_t)0x333debab, (q31_t)0x8ab45024, + (q31_t)0x3326e2c3, (q31_t)0x8aaa42b4, (q31_t)0x330fd7e1, (q31_t)0x8aa039cb, + (q31_t)0x32f8cb07, (q31_t)0x8a963567, (q31_t)0x32e1bc36, (q31_t)0x8a8c358b, + (q31_t)0x32caab6f, (q31_t)0x8a823a36, (q31_t)0x32b398b3, (q31_t)0x8a784368, + (q31_t)0x329c8402, (q31_t)0x8a6e5123, (q31_t)0x32856d5e, (q31_t)0x8a646365, + (q31_t)0x326e54c7, (q31_t)0x8a5a7a31, (q31_t)0x32573a3f, (q31_t)0x8a509585, + (q31_t)0x32401dc6, (q31_t)0x8a46b564, (q31_t)0x3228ff5c, (q31_t)0x8a3cd9cc, + (q31_t)0x3211df04, (q31_t)0x8a3302be, (q31_t)0x31fabcbd, (q31_t)0x8a29303b, + (q31_t)0x31e39889, (q31_t)0x8a1f6243, (q31_t)0x31cc7269, (q31_t)0x8a1598d6, + (q31_t)0x31b54a5e, (q31_t)0x8a0bd3f5, (q31_t)0x319e2067, (q31_t)0x8a0213a0, + (q31_t)0x3186f487, (q31_t)0x89f857d8, (q31_t)0x316fc6be, (q31_t)0x89eea09d, + (q31_t)0x3158970e, (q31_t)0x89e4edef, (q31_t)0x31416576, (q31_t)0x89db3fcf, + (q31_t)0x312a31f8, (q31_t)0x89d1963c, (q31_t)0x3112fc95, (q31_t)0x89c7f138, + (q31_t)0x30fbc54d, (q31_t)0x89be50c3, (q31_t)0x30e48c22, (q31_t)0x89b4b4dd, + (q31_t)0x30cd5115, (q31_t)0x89ab1d87, (q31_t)0x30b61426, (q31_t)0x89a18ac0, + (q31_t)0x309ed556, (q31_t)0x8997fc8a, (q31_t)0x308794a6, (q31_t)0x898e72e4, + (q31_t)0x30705217, (q31_t)0x8984edcf, (q31_t)0x30590dab, (q31_t)0x897b6d4c, + (q31_t)0x3041c761, (q31_t)0x8971f15a, (q31_t)0x302a7f3a, (q31_t)0x896879fb, + (q31_t)0x30133539, (q31_t)0x895f072e, (q31_t)0x2ffbe95d, (q31_t)0x895598f3, + (q31_t)0x2fe49ba7, (q31_t)0x894c2f4c, (q31_t)0x2fcd4c19, (q31_t)0x8942ca39, + (q31_t)0x2fb5fab2, (q31_t)0x893969b9, (q31_t)0x2f9ea775, (q31_t)0x89300dce, + (q31_t)0x2f875262, (q31_t)0x8926b677, (q31_t)0x2f6ffb7a, (q31_t)0x891d63b5, + (q31_t)0x2f58a2be, (q31_t)0x89141589, (q31_t)0x2f41482e, (q31_t)0x890acbf2, + (q31_t)0x2f29ebcc, (q31_t)0x890186f2, (q31_t)0x2f128d99, (q31_t)0x88f84687, + (q31_t)0x2efb2d95, (q31_t)0x88ef0ab4, (q31_t)0x2ee3cbc1, (q31_t)0x88e5d378, + (q31_t)0x2ecc681e, (q31_t)0x88dca0d3, (q31_t)0x2eb502ae, (q31_t)0x88d372c6, + (q31_t)0x2e9d9b70, (q31_t)0x88ca4951, (q31_t)0x2e863267, (q31_t)0x88c12475, + (q31_t)0x2e6ec792, (q31_t)0x88b80432, (q31_t)0x2e575af3, (q31_t)0x88aee888, + (q31_t)0x2e3fec8b, (q31_t)0x88a5d177, (q31_t)0x2e287c5a, (q31_t)0x889cbf01, + (q31_t)0x2e110a62, (q31_t)0x8893b125, (q31_t)0x2df996a3, (q31_t)0x888aa7e3, + (q31_t)0x2de2211e, (q31_t)0x8881a33d, (q31_t)0x2dcaa9d5, (q31_t)0x8878a332, + (q31_t)0x2db330c7, (q31_t)0x886fa7c2, (q31_t)0x2d9bb5f6, (q31_t)0x8866b0ef, + (q31_t)0x2d843964, (q31_t)0x885dbeb8, (q31_t)0x2d6cbb10, (q31_t)0x8854d11e, + (q31_t)0x2d553afc, (q31_t)0x884be821, (q31_t)0x2d3db928, (q31_t)0x884303c1, + (q31_t)0x2d263596, (q31_t)0x883a23ff, (q31_t)0x2d0eb046, (q31_t)0x883148db, + (q31_t)0x2cf72939, (q31_t)0x88287256, (q31_t)0x2cdfa071, (q31_t)0x881fa06f, + (q31_t)0x2cc815ee, (q31_t)0x8816d327, (q31_t)0x2cb089b1, (q31_t)0x880e0a7f, + (q31_t)0x2c98fbba, (q31_t)0x88054677, (q31_t)0x2c816c0c, (q31_t)0x87fc870f, + (q31_t)0x2c69daa6, (q31_t)0x87f3cc48, (q31_t)0x2c52478a, (q31_t)0x87eb1621, + (q31_t)0x2c3ab2b9, (q31_t)0x87e2649b, (q31_t)0x2c231c33, (q31_t)0x87d9b7b7, + (q31_t)0x2c0b83fa, (q31_t)0x87d10f75, (q31_t)0x2bf3ea0d, (q31_t)0x87c86bd5, + (q31_t)0x2bdc4e6f, (q31_t)0x87bfccd7, (q31_t)0x2bc4b120, (q31_t)0x87b7327d, + (q31_t)0x2bad1221, (q31_t)0x87ae9cc5, (q31_t)0x2b957173, (q31_t)0x87a60bb1, + (q31_t)0x2b7dcf17, (q31_t)0x879d7f41, (q31_t)0x2b662b0e, (q31_t)0x8794f774, + (q31_t)0x2b4e8558, (q31_t)0x878c744d, (q31_t)0x2b36ddf7, (q31_t)0x8783f5ca, + (q31_t)0x2b1f34eb, (q31_t)0x877b7bec, (q31_t)0x2b078a36, (q31_t)0x877306b4, + (q31_t)0x2aefddd8, (q31_t)0x876a9621, (q31_t)0x2ad82fd2, (q31_t)0x87622a35, + (q31_t)0x2ac08026, (q31_t)0x8759c2ef, (q31_t)0x2aa8ced3, (q31_t)0x87516050, + (q31_t)0x2a911bdc, (q31_t)0x87490258, (q31_t)0x2a796740, (q31_t)0x8740a907, + (q31_t)0x2a61b101, (q31_t)0x8738545e, (q31_t)0x2a49f920, (q31_t)0x8730045d, + (q31_t)0x2a323f9e, (q31_t)0x8727b905, (q31_t)0x2a1a847b, (q31_t)0x871f7255, + (q31_t)0x2a02c7b8, (q31_t)0x8717304e, (q31_t)0x29eb0957, (q31_t)0x870ef2f1, + (q31_t)0x29d34958, (q31_t)0x8706ba3d, (q31_t)0x29bb87bc, (q31_t)0x86fe8633, + (q31_t)0x29a3c485, (q31_t)0x86f656d3, (q31_t)0x298bffb2, (q31_t)0x86ee2c1e, + (q31_t)0x29743946, (q31_t)0x86e60614, (q31_t)0x295c7140, (q31_t)0x86dde4b5, + (q31_t)0x2944a7a2, (q31_t)0x86d5c802, (q31_t)0x292cdc6d, (q31_t)0x86cdaffa, + (q31_t)0x29150fa1, (q31_t)0x86c59c9f, (q31_t)0x28fd4140, (q31_t)0x86bd8df0, + (q31_t)0x28e5714b, (q31_t)0x86b583ee, (q31_t)0x28cd9fc1, (q31_t)0x86ad7e99, + (q31_t)0x28b5cca5, (q31_t)0x86a57df2, (q31_t)0x289df7f8, (q31_t)0x869d81f8, + (q31_t)0x288621b9, (q31_t)0x86958aac, (q31_t)0x286e49ea, (q31_t)0x868d980e, + (q31_t)0x2856708d, (q31_t)0x8685aa20, (q31_t)0x283e95a1, (q31_t)0x867dc0e0, + (q31_t)0x2826b928, (q31_t)0x8675dc4f, (q31_t)0x280edb23, (q31_t)0x866dfc6e, + (q31_t)0x27f6fb92, (q31_t)0x8666213c, (q31_t)0x27df1a77, (q31_t)0x865e4abb, + (q31_t)0x27c737d3, (q31_t)0x865678eb, (q31_t)0x27af53a6, (q31_t)0x864eabcb, + (q31_t)0x27976df1, (q31_t)0x8646e35c, (q31_t)0x277f86b5, (q31_t)0x863f1f9e, + (q31_t)0x27679df4, (q31_t)0x86376092, (q31_t)0x274fb3ae, (q31_t)0x862fa638, + (q31_t)0x2737c7e3, (q31_t)0x8627f091, (q31_t)0x271fda96, (q31_t)0x86203f9c, + (q31_t)0x2707ebc7, (q31_t)0x86189359, (q31_t)0x26effb76, (q31_t)0x8610ebca, + (q31_t)0x26d809a5, (q31_t)0x860948ef, (q31_t)0x26c01655, (q31_t)0x8601aac7, + (q31_t)0x26a82186, (q31_t)0x85fa1153, (q31_t)0x26902b39, (q31_t)0x85f27c93, + (q31_t)0x26783370, (q31_t)0x85eaec88, (q31_t)0x26603a2c, (q31_t)0x85e36132, + (q31_t)0x26483f6c, (q31_t)0x85dbda91, (q31_t)0x26304333, (q31_t)0x85d458a6, + (q31_t)0x26184581, (q31_t)0x85ccdb70, (q31_t)0x26004657, (q31_t)0x85c562f1, + (q31_t)0x25e845b6, (q31_t)0x85bdef28, (q31_t)0x25d0439f, (q31_t)0x85b68015, + (q31_t)0x25b84012, (q31_t)0x85af15b9, (q31_t)0x25a03b11, (q31_t)0x85a7b015, + (q31_t)0x2588349d, (q31_t)0x85a04f28, (q31_t)0x25702cb7, (q31_t)0x8598f2f3, + (q31_t)0x2558235f, (q31_t)0x85919b76, (q31_t)0x25401896, (q31_t)0x858a48b1, + (q31_t)0x25280c5e, (q31_t)0x8582faa5, (q31_t)0x250ffeb7, (q31_t)0x857bb152, + (q31_t)0x24f7efa2, (q31_t)0x85746cb8, (q31_t)0x24dfdf20, (q31_t)0x856d2cd7, + (q31_t)0x24c7cd33, (q31_t)0x8565f1b0, (q31_t)0x24afb9da, (q31_t)0x855ebb44, + (q31_t)0x2497a517, (q31_t)0x85578991, (q31_t)0x247f8eec, (q31_t)0x85505c99, + (q31_t)0x24677758, (q31_t)0x8549345c, (q31_t)0x244f5e5c, (q31_t)0x854210db, + (q31_t)0x243743fa, (q31_t)0x853af214, (q31_t)0x241f2833, (q31_t)0x8533d809, + (q31_t)0x24070b08, (q31_t)0x852cc2bb, (q31_t)0x23eeec78, (q31_t)0x8525b228, + (q31_t)0x23d6cc87, (q31_t)0x851ea652, (q31_t)0x23beab33, (q31_t)0x85179f39, + (q31_t)0x23a6887f, (q31_t)0x85109cdd, (q31_t)0x238e646a, (q31_t)0x85099f3e, + (q31_t)0x23763ef7, (q31_t)0x8502a65c, (q31_t)0x235e1826, (q31_t)0x84fbb239, + (q31_t)0x2345eff8, (q31_t)0x84f4c2d4, (q31_t)0x232dc66d, (q31_t)0x84edd82d, + (q31_t)0x23159b88, (q31_t)0x84e6f244, (q31_t)0x22fd6f48, (q31_t)0x84e0111b, + (q31_t)0x22e541af, (q31_t)0x84d934b1, (q31_t)0x22cd12bd, (q31_t)0x84d25d06, + (q31_t)0x22b4e274, (q31_t)0x84cb8a1b, (q31_t)0x229cb0d5, (q31_t)0x84c4bbf0, + (q31_t)0x22847de0, (q31_t)0x84bdf286, (q31_t)0x226c4996, (q31_t)0x84b72ddb, + (q31_t)0x225413f8, (q31_t)0x84b06df2, (q31_t)0x223bdd08, (q31_t)0x84a9b2ca, + (q31_t)0x2223a4c5, (q31_t)0x84a2fc62, (q31_t)0x220b6b32, (q31_t)0x849c4abd, + (q31_t)0x21f3304f, (q31_t)0x84959dd9, (q31_t)0x21daf41d, (q31_t)0x848ef5b7, + (q31_t)0x21c2b69c, (q31_t)0x84885258, (q31_t)0x21aa77cf, (q31_t)0x8481b3bb, + (q31_t)0x219237b5, (q31_t)0x847b19e1, (q31_t)0x2179f64f, (q31_t)0x847484ca, + (q31_t)0x2161b3a0, (q31_t)0x846df477, (q31_t)0x21496fa7, (q31_t)0x846768e7, + (q31_t)0x21312a65, (q31_t)0x8460e21a, (q31_t)0x2118e3dc, (q31_t)0x845a6012, + (q31_t)0x21009c0c, (q31_t)0x8453e2cf, (q31_t)0x20e852f6, (q31_t)0x844d6a50, + (q31_t)0x20d0089c, (q31_t)0x8446f695, (q31_t)0x20b7bcfe, (q31_t)0x844087a0, + (q31_t)0x209f701c, (q31_t)0x843a1d70, (q31_t)0x208721f9, (q31_t)0x8433b806, + (q31_t)0x206ed295, (q31_t)0x842d5762, (q31_t)0x205681f1, (q31_t)0x8426fb84, + (q31_t)0x203e300d, (q31_t)0x8420a46c, (q31_t)0x2025dcec, (q31_t)0x841a521a, + (q31_t)0x200d888d, (q31_t)0x84140490, (q31_t)0x1ff532f2, (q31_t)0x840dbbcc, + (q31_t)0x1fdcdc1b, (q31_t)0x840777d0, (q31_t)0x1fc4840a, (q31_t)0x8401389b, + (q31_t)0x1fac2abf, (q31_t)0x83fafe2e, (q31_t)0x1f93d03c, (q31_t)0x83f4c889, + (q31_t)0x1f7b7481, (q31_t)0x83ee97ad, (q31_t)0x1f63178f, (q31_t)0x83e86b99, + (q31_t)0x1f4ab968, (q31_t)0x83e2444d, (q31_t)0x1f325a0b, (q31_t)0x83dc21cb, + (q31_t)0x1f19f97b, (q31_t)0x83d60412, (q31_t)0x1f0197b8, (q31_t)0x83cfeb22, + (q31_t)0x1ee934c3, (q31_t)0x83c9d6fc, (q31_t)0x1ed0d09d, (q31_t)0x83c3c7a0, + (q31_t)0x1eb86b46, (q31_t)0x83bdbd0e, (q31_t)0x1ea004c1, (q31_t)0x83b7b746, + (q31_t)0x1e879d0d, (q31_t)0x83b1b649, (q31_t)0x1e6f342c, (q31_t)0x83abba17, + (q31_t)0x1e56ca1e, (q31_t)0x83a5c2b0, (q31_t)0x1e3e5ee5, (q31_t)0x839fd014, + (q31_t)0x1e25f282, (q31_t)0x8399e244, (q31_t)0x1e0d84f5, (q31_t)0x8393f940, + (q31_t)0x1df5163f, (q31_t)0x838e1507, (q31_t)0x1ddca662, (q31_t)0x8388359b, + (q31_t)0x1dc4355e, (q31_t)0x83825afb, (q31_t)0x1dabc334, (q31_t)0x837c8528, + (q31_t)0x1d934fe5, (q31_t)0x8376b422, (q31_t)0x1d7adb73, (q31_t)0x8370e7e9, + (q31_t)0x1d6265dd, (q31_t)0x836b207d, (q31_t)0x1d49ef26, (q31_t)0x83655ddf, + (q31_t)0x1d31774d, (q31_t)0x835fa00f, (q31_t)0x1d18fe54, (q31_t)0x8359e70d, + (q31_t)0x1d00843d, (q31_t)0x835432d8, (q31_t)0x1ce80906, (q31_t)0x834e8373, + (q31_t)0x1ccf8cb3, (q31_t)0x8348d8dc, (q31_t)0x1cb70f43, (q31_t)0x83433314, + (q31_t)0x1c9e90b8, (q31_t)0x833d921b, (q31_t)0x1c861113, (q31_t)0x8337f5f1, + (q31_t)0x1c6d9053, (q31_t)0x83325e97, (q31_t)0x1c550e7c, (q31_t)0x832ccc0d, + (q31_t)0x1c3c8b8c, (q31_t)0x83273e52, (q31_t)0x1c240786, (q31_t)0x8321b568, + (q31_t)0x1c0b826a, (q31_t)0x831c314e, (q31_t)0x1bf2fc3a, (q31_t)0x8316b205, + (q31_t)0x1bda74f6, (q31_t)0x8311378d, (q31_t)0x1bc1ec9e, (q31_t)0x830bc1e6, + (q31_t)0x1ba96335, (q31_t)0x83065110, (q31_t)0x1b90d8bb, (q31_t)0x8300e50b, + (q31_t)0x1b784d30, (q31_t)0x82fb7dd8, (q31_t)0x1b5fc097, (q31_t)0x82f61b77, + (q31_t)0x1b4732ef, (q31_t)0x82f0bde8, (q31_t)0x1b2ea43a, (q31_t)0x82eb652b, + (q31_t)0x1b161479, (q31_t)0x82e61141, (q31_t)0x1afd83ad, (q31_t)0x82e0c22a, + (q31_t)0x1ae4f1d6, (q31_t)0x82db77e5, (q31_t)0x1acc5ef6, (q31_t)0x82d63274, + (q31_t)0x1ab3cb0d, (q31_t)0x82d0f1d5, (q31_t)0x1a9b361d, (q31_t)0x82cbb60b, + (q31_t)0x1a82a026, (q31_t)0x82c67f14, (q31_t)0x1a6a0929, (q31_t)0x82c14cf1, + (q31_t)0x1a517128, (q31_t)0x82bc1fa2, (q31_t)0x1a38d823, (q31_t)0x82b6f727, + (q31_t)0x1a203e1b, (q31_t)0x82b1d381, (q31_t)0x1a07a311, (q31_t)0x82acb4b0, + (q31_t)0x19ef0707, (q31_t)0x82a79ab3, (q31_t)0x19d669fc, (q31_t)0x82a2858c, + (q31_t)0x19bdcbf3, (q31_t)0x829d753a, (q31_t)0x19a52ceb, (q31_t)0x829869be, + (q31_t)0x198c8ce7, (q31_t)0x82936317, (q31_t)0x1973ebe6, (q31_t)0x828e6146, + (q31_t)0x195b49ea, (q31_t)0x8289644b, (q31_t)0x1942a6f3, (q31_t)0x82846c26, + (q31_t)0x192a0304, (q31_t)0x827f78d8, (q31_t)0x19115e1c, (q31_t)0x827a8a61, + (q31_t)0x18f8b83c, (q31_t)0x8275a0c0, (q31_t)0x18e01167, (q31_t)0x8270bbf7, + (q31_t)0x18c7699b, (q31_t)0x826bdc04, (q31_t)0x18aec0db, (q31_t)0x826700e9, + (q31_t)0x18961728, (q31_t)0x82622aa6, (q31_t)0x187d6c82, (q31_t)0x825d593a, + (q31_t)0x1864c0ea, (q31_t)0x82588ca7, (q31_t)0x184c1461, (q31_t)0x8253c4eb, + (q31_t)0x183366e9, (q31_t)0x824f0208, (q31_t)0x181ab881, (q31_t)0x824a43fe, + (q31_t)0x1802092c, (q31_t)0x82458acc, (q31_t)0x17e958ea, (q31_t)0x8240d673, + (q31_t)0x17d0a7bc, (q31_t)0x823c26f3, (q31_t)0x17b7f5a3, (q31_t)0x82377c4c, + (q31_t)0x179f429f, (q31_t)0x8232d67f, (q31_t)0x17868eb3, (q31_t)0x822e358b, + (q31_t)0x176dd9de, (q31_t)0x82299971, (q31_t)0x17552422, (q31_t)0x82250232, + (q31_t)0x173c6d80, (q31_t)0x82206fcc, (q31_t)0x1723b5f9, (q31_t)0x821be240, + (q31_t)0x170afd8d, (q31_t)0x82175990, (q31_t)0x16f2443e, (q31_t)0x8212d5b9, + (q31_t)0x16d98a0c, (q31_t)0x820e56be, (q31_t)0x16c0cef9, (q31_t)0x8209dc9e, + (q31_t)0x16a81305, (q31_t)0x82056758, (q31_t)0x168f5632, (q31_t)0x8200f6ef, + (q31_t)0x1676987f, (q31_t)0x81fc8b60, (q31_t)0x165dd9f0, (q31_t)0x81f824ae, + (q31_t)0x16451a83, (q31_t)0x81f3c2d7, (q31_t)0x162c5a3b, (q31_t)0x81ef65dc, + (q31_t)0x16139918, (q31_t)0x81eb0dbe, (q31_t)0x15fad71b, (q31_t)0x81e6ba7c, + (q31_t)0x15e21445, (q31_t)0x81e26c16, (q31_t)0x15c95097, (q31_t)0x81de228d, + (q31_t)0x15b08c12, (q31_t)0x81d9dde1, (q31_t)0x1597c6b7, (q31_t)0x81d59e13, + (q31_t)0x157f0086, (q31_t)0x81d16321, (q31_t)0x15663982, (q31_t)0x81cd2d0c, + (q31_t)0x154d71aa, (q31_t)0x81c8fbd6, (q31_t)0x1534a901, (q31_t)0x81c4cf7d, + (q31_t)0x151bdf86, (q31_t)0x81c0a801, (q31_t)0x1503153a, (q31_t)0x81bc8564, + (q31_t)0x14ea4a1f, (q31_t)0x81b867a5, (q31_t)0x14d17e36, (q31_t)0x81b44ec4, + (q31_t)0x14b8b17f, (q31_t)0x81b03ac2, (q31_t)0x149fe3fc, (q31_t)0x81ac2b9e, + (q31_t)0x148715ae, (q31_t)0x81a82159, (q31_t)0x146e4694, (q31_t)0x81a41bf4, + (q31_t)0x145576b1, (q31_t)0x81a01b6d, (q31_t)0x143ca605, (q31_t)0x819c1fc5, + (q31_t)0x1423d492, (q31_t)0x819828fd, (q31_t)0x140b0258, (q31_t)0x81943715, + (q31_t)0x13f22f58, (q31_t)0x81904a0c, (q31_t)0x13d95b93, (q31_t)0x818c61e3, + (q31_t)0x13c0870a, (q31_t)0x81887e9a, (q31_t)0x13a7b1bf, (q31_t)0x8184a032, + (q31_t)0x138edbb1, (q31_t)0x8180c6a9, (q31_t)0x137604e2, (q31_t)0x817cf201, + (q31_t)0x135d2d53, (q31_t)0x8179223a, (q31_t)0x13445505, (q31_t)0x81755754, + (q31_t)0x132b7bf9, (q31_t)0x8171914e, (q31_t)0x1312a230, (q31_t)0x816dd02a, + (q31_t)0x12f9c7aa, (q31_t)0x816a13e6, (q31_t)0x12e0ec6a, (q31_t)0x81665c84, + (q31_t)0x12c8106f, (q31_t)0x8162aa04, (q31_t)0x12af33ba, (q31_t)0x815efc65, + (q31_t)0x1296564d, (q31_t)0x815b53a8, (q31_t)0x127d7829, (q31_t)0x8157afcd, + (q31_t)0x1264994e, (q31_t)0x815410d4, (q31_t)0x124bb9be, (q31_t)0x815076bd, + (q31_t)0x1232d979, (q31_t)0x814ce188, (q31_t)0x1219f880, (q31_t)0x81495136, + (q31_t)0x120116d5, (q31_t)0x8145c5c7, (q31_t)0x11e83478, (q31_t)0x81423f3a, + (q31_t)0x11cf516a, (q31_t)0x813ebd90, (q31_t)0x11b66dad, (q31_t)0x813b40ca, + (q31_t)0x119d8941, (q31_t)0x8137c8e6, (q31_t)0x1184a427, (q31_t)0x813455e6, + (q31_t)0x116bbe60, (q31_t)0x8130e7c9, (q31_t)0x1152d7ed, (q31_t)0x812d7e8f, + (q31_t)0x1139f0cf, (q31_t)0x812a1a3a, (q31_t)0x11210907, (q31_t)0x8126bac8, + (q31_t)0x11082096, (q31_t)0x8123603a, (q31_t)0x10ef377d, (q31_t)0x81200a90, + (q31_t)0x10d64dbd, (q31_t)0x811cb9ca, (q31_t)0x10bd6356, (q31_t)0x81196de9, + (q31_t)0x10a4784b, (q31_t)0x811626ec, (q31_t)0x108b8c9b, (q31_t)0x8112e4d4, + (q31_t)0x1072a048, (q31_t)0x810fa7a0, (q31_t)0x1059b352, (q31_t)0x810c6f52, + (q31_t)0x1040c5bb, (q31_t)0x81093be8, (q31_t)0x1027d784, (q31_t)0x81060d63, + (q31_t)0x100ee8ad, (q31_t)0x8102e3c4, (q31_t)0xff5f938, (q31_t)0x80ffbf0a, + (q31_t)0xfdd0926, (q31_t)0x80fc9f35, (q31_t)0xfc41876, (q31_t)0x80f98446, + (q31_t)0xfab272b, (q31_t)0x80f66e3c, (q31_t)0xf923546, (q31_t)0x80f35d19, + (q31_t)0xf7942c7, (q31_t)0x80f050db, (q31_t)0xf604faf, (q31_t)0x80ed4984, + (q31_t)0xf475bff, (q31_t)0x80ea4712, (q31_t)0xf2e67b8, (q31_t)0x80e74987, + (q31_t)0xf1572dc, (q31_t)0x80e450e2, (q31_t)0xefc7d6b, (q31_t)0x80e15d24, + (q31_t)0xee38766, (q31_t)0x80de6e4c, (q31_t)0xeca90ce, (q31_t)0x80db845b, + (q31_t)0xeb199a4, (q31_t)0x80d89f51, (q31_t)0xe98a1e9, (q31_t)0x80d5bf2e, + (q31_t)0xe7fa99e, (q31_t)0x80d2e3f2, (q31_t)0xe66b0c3, (q31_t)0x80d00d9d, + (q31_t)0xe4db75b, (q31_t)0x80cd3c2f, (q31_t)0xe34bd66, (q31_t)0x80ca6fa9, + (q31_t)0xe1bc2e4, (q31_t)0x80c7a80a, (q31_t)0xe02c7d7, (q31_t)0x80c4e553, + (q31_t)0xde9cc40, (q31_t)0x80c22784, (q31_t)0xdd0d01f, (q31_t)0x80bf6e9c, + (q31_t)0xdb7d376, (q31_t)0x80bcba9d, (q31_t)0xd9ed646, (q31_t)0x80ba0b85, + (q31_t)0xd85d88f, (q31_t)0x80b76156, (q31_t)0xd6cda53, (q31_t)0x80b4bc0e, + (q31_t)0xd53db92, (q31_t)0x80b21baf, (q31_t)0xd3adc4e, (q31_t)0x80af8039, + (q31_t)0xd21dc87, (q31_t)0x80ace9ab, (q31_t)0xd08dc3f, (q31_t)0x80aa5806, + (q31_t)0xcefdb76, (q31_t)0x80a7cb49, (q31_t)0xcd6da2d, (q31_t)0x80a54376, + (q31_t)0xcbdd865, (q31_t)0x80a2c08b, (q31_t)0xca4d620, (q31_t)0x80a04289, + (q31_t)0xc8bd35e, (q31_t)0x809dc971, (q31_t)0xc72d020, (q31_t)0x809b5541, + (q31_t)0xc59cc68, (q31_t)0x8098e5fb, (q31_t)0xc40c835, (q31_t)0x80967b9f, + (q31_t)0xc27c389, (q31_t)0x8094162c, (q31_t)0xc0ebe66, (q31_t)0x8091b5a2, + (q31_t)0xbf5b8cb, (q31_t)0x808f5a02, (q31_t)0xbdcb2bb, (q31_t)0x808d034c, + (q31_t)0xbc3ac35, (q31_t)0x808ab180, (q31_t)0xbaaa53b, (q31_t)0x8088649e, + (q31_t)0xb919dcf, (q31_t)0x80861ca6, (q31_t)0xb7895f0, (q31_t)0x8083d998, + (q31_t)0xb5f8d9f, (q31_t)0x80819b74, (q31_t)0xb4684df, (q31_t)0x807f623b, + (q31_t)0xb2d7baf, (q31_t)0x807d2dec, (q31_t)0xb147211, (q31_t)0x807afe87, + (q31_t)0xafb6805, (q31_t)0x8078d40d, (q31_t)0xae25d8d, (q31_t)0x8076ae7e, + (q31_t)0xac952aa, (q31_t)0x80748dd9, (q31_t)0xab0475c, (q31_t)0x8072721f, + (q31_t)0xa973ba5, (q31_t)0x80705b50, (q31_t)0xa7e2f85, (q31_t)0x806e496c, + (q31_t)0xa6522fe, (q31_t)0x806c3c74, (q31_t)0xa4c1610, (q31_t)0x806a3466, + (q31_t)0xa3308bd, (q31_t)0x80683143, (q31_t)0xa19fb04, (q31_t)0x8066330c, + (q31_t)0xa00ece8, (q31_t)0x806439c0, (q31_t)0x9e7de6a, (q31_t)0x80624560, + (q31_t)0x9cecf89, (q31_t)0x806055eb, (q31_t)0x9b5c048, (q31_t)0x805e6b62, + (q31_t)0x99cb0a7, (q31_t)0x805c85c4, (q31_t)0x983a0a7, (q31_t)0x805aa512, + (q31_t)0x96a9049, (q31_t)0x8058c94c, (q31_t)0x9517f8f, (q31_t)0x8056f272, + (q31_t)0x9386e78, (q31_t)0x80552084, (q31_t)0x91f5d06, (q31_t)0x80535381, + (q31_t)0x9064b3a, (q31_t)0x80518b6b, (q31_t)0x8ed3916, (q31_t)0x804fc841, + (q31_t)0x8d42699, (q31_t)0x804e0a04, (q31_t)0x8bb13c5, (q31_t)0x804c50b2, + (q31_t)0x8a2009a, (q31_t)0x804a9c4d, (q31_t)0x888ed1b, (q31_t)0x8048ecd5, + (q31_t)0x86fd947, (q31_t)0x80474248, (q31_t)0x856c520, (q31_t)0x80459ca9, + (q31_t)0x83db0a7, (q31_t)0x8043fbf6, (q31_t)0x8249bdd, (q31_t)0x80426030, + (q31_t)0x80b86c2, (q31_t)0x8040c956, (q31_t)0x7f27157, (q31_t)0x803f376a, + (q31_t)0x7d95b9e, (q31_t)0x803daa6a, (q31_t)0x7c04598, (q31_t)0x803c2257, + (q31_t)0x7a72f45, (q31_t)0x803a9f31, (q31_t)0x78e18a7, (q31_t)0x803920f8, + (q31_t)0x77501be, (q31_t)0x8037a7ac, (q31_t)0x75bea8c, (q31_t)0x8036334e, + (q31_t)0x742d311, (q31_t)0x8034c3dd, (q31_t)0x729bb4e, (q31_t)0x80335959, + (q31_t)0x710a345, (q31_t)0x8031f3c2, (q31_t)0x6f78af6, (q31_t)0x80309318, + (q31_t)0x6de7262, (q31_t)0x802f375d, (q31_t)0x6c5598a, (q31_t)0x802de08e, + (q31_t)0x6ac406f, (q31_t)0x802c8ead, (q31_t)0x6932713, (q31_t)0x802b41ba, + (q31_t)0x67a0d76, (q31_t)0x8029f9b4, (q31_t)0x660f398, (q31_t)0x8028b69c, + (q31_t)0x647d97c, (q31_t)0x80277872, (q31_t)0x62ebf22, (q31_t)0x80263f36, + (q31_t)0x615a48b, (q31_t)0x80250ae7, (q31_t)0x5fc89b8, (q31_t)0x8023db86, + (q31_t)0x5e36ea9, (q31_t)0x8022b114, (q31_t)0x5ca5361, (q31_t)0x80218b8f, + (q31_t)0x5b137df, (q31_t)0x80206af8, (q31_t)0x5981c26, (q31_t)0x801f4f4f, + (q31_t)0x57f0035, (q31_t)0x801e3895, (q31_t)0x565e40d, (q31_t)0x801d26c8, + (q31_t)0x54cc7b1, (q31_t)0x801c19ea, (q31_t)0x533ab20, (q31_t)0x801b11fa, + (q31_t)0x51a8e5c, (q31_t)0x801a0ef8, (q31_t)0x5017165, (q31_t)0x801910e4, + (q31_t)0x4e8543e, (q31_t)0x801817bf, (q31_t)0x4cf36e5, (q31_t)0x80172388, + (q31_t)0x4b6195d, (q31_t)0x80163440, (q31_t)0x49cfba7, (q31_t)0x801549e6, + (q31_t)0x483ddc3, (q31_t)0x8014647b, (q31_t)0x46abfb3, (q31_t)0x801383fe, + (q31_t)0x451a177, (q31_t)0x8012a86f, (q31_t)0x4388310, (q31_t)0x8011d1d0, + (q31_t)0x41f6480, (q31_t)0x8011001f, (q31_t)0x40645c7, (q31_t)0x8010335c, + (q31_t)0x3ed26e6, (q31_t)0x800f6b88, (q31_t)0x3d407df, (q31_t)0x800ea8a3, + (q31_t)0x3bae8b2, (q31_t)0x800deaad, (q31_t)0x3a1c960, (q31_t)0x800d31a5, + (q31_t)0x388a9ea, (q31_t)0x800c7d8c, (q31_t)0x36f8a51, (q31_t)0x800bce63, + (q31_t)0x3566a96, (q31_t)0x800b2427, (q31_t)0x33d4abb, (q31_t)0x800a7edb, + (q31_t)0x3242abf, (q31_t)0x8009de7e, (q31_t)0x30b0aa4, (q31_t)0x80094310, + (q31_t)0x2f1ea6c, (q31_t)0x8008ac90, (q31_t)0x2d8ca16, (q31_t)0x80081b00, + (q31_t)0x2bfa9a4, (q31_t)0x80078e5e, (q31_t)0x2a68917, (q31_t)0x800706ac, + (q31_t)0x28d6870, (q31_t)0x800683e8, (q31_t)0x27447b0, (q31_t)0x80060614, + (q31_t)0x25b26d7, (q31_t)0x80058d2f, (q31_t)0x24205e8, (q31_t)0x80051939, + (q31_t)0x228e4e2, (q31_t)0x8004aa32, (q31_t)0x20fc3c6, (q31_t)0x8004401a, + (q31_t)0x1f6a297, (q31_t)0x8003daf1, (q31_t)0x1dd8154, (q31_t)0x80037ab7, + (q31_t)0x1c45ffe, (q31_t)0x80031f6d, (q31_t)0x1ab3e97, (q31_t)0x8002c912, + (q31_t)0x1921d20, (q31_t)0x800277a6, (q31_t)0x178fb99, (q31_t)0x80022b29, + (q31_t)0x15fda03, (q31_t)0x8001e39b, (q31_t)0x146b860, (q31_t)0x8001a0fd, + (q31_t)0x12d96b1, (q31_t)0x8001634e, (q31_t)0x11474f6, (q31_t)0x80012a8e, + (q31_t)0x0fb5330, (q31_t)0x8000f6bd, (q31_t)0xe23160, (q31_t)0x8000c7dc, + (q31_t)0x0c90f88, (q31_t)0x80009dea, (q31_t)0x0afeda8, (q31_t)0x800078e7, + (q31_t)0x096cbc1, (q31_t)0x800058d4, (q31_t)0x7da9d4, (q31_t)0x80003daf, + (q31_t)0x06487e3, (q31_t)0x8000277a, (q31_t)0x04b65ee, (q31_t)0x80001635, + (q31_t)0x03243f5, (q31_t)0x800009df, (q31_t)0x1921fb, (q31_t)0x80000278}; static const q31_t WeightsQ31_8192[16384] = { - (q31_t)0x7fffffff, (q31_t)0x00000000, (q31_t)0x7fffffd9, (q31_t)0xfff9b781, (q31_t)0x7fffff62, (q31_t)0xfff36f02, (q31_t)0x7ffffe9d, (q31_t)0xffed2684, - (q31_t)0x7ffffd88, (q31_t)0xffe6de05, (q31_t)0x7ffffc25, (q31_t)0xffe09586, (q31_t)0x7ffffa73, (q31_t)0xffda4d08, (q31_t)0x7ffff872, (q31_t)0xffd40489, - (q31_t)0x7ffff621, (q31_t)0xffcdbc0b, (q31_t)0x7ffff382, (q31_t)0xffc7738c, (q31_t)0x7ffff094, (q31_t)0xffc12b0e, (q31_t)0x7fffed57, (q31_t)0xffbae290, - (q31_t)0x7fffe9cb, (q31_t)0xffb49a12, (q31_t)0x7fffe5f0, (q31_t)0xffae5195, (q31_t)0x7fffe1c6, (q31_t)0xffa80917, (q31_t)0x7fffdd4d, (q31_t)0xffa1c09a, - (q31_t)0x7fffd886, (q31_t)0xff9b781d, (q31_t)0x7fffd36f, (q31_t)0xff952fa0, (q31_t)0x7fffce09, (q31_t)0xff8ee724, (q31_t)0x7fffc854, (q31_t)0xff889ea7, - (q31_t)0x7fffc251, (q31_t)0xff82562c, (q31_t)0x7fffbbfe, (q31_t)0xff7c0db0, (q31_t)0x7fffb55c, (q31_t)0xff75c535, (q31_t)0x7fffae6c, (q31_t)0xff6f7cba, - (q31_t)0x7fffa72c, (q31_t)0xff69343f, (q31_t)0x7fff9f9e, (q31_t)0xff62ebc5, (q31_t)0x7fff97c1, (q31_t)0xff5ca34b, (q31_t)0x7fff8f94, (q31_t)0xff565ad1, - (q31_t)0x7fff8719, (q31_t)0xff501258, (q31_t)0x7fff7e4f, (q31_t)0xff49c9df, (q31_t)0x7fff7536, (q31_t)0xff438167, (q31_t)0x7fff6bcd, (q31_t)0xff3d38ef, - (q31_t)0x7fff6216, (q31_t)0xff36f078, (q31_t)0x7fff5810, (q31_t)0xff30a801, (q31_t)0x7fff4dbb, (q31_t)0xff2a5f8b, (q31_t)0x7fff4317, (q31_t)0xff241715, - (q31_t)0x7fff3824, (q31_t)0xff1dcea0, (q31_t)0x7fff2ce2, (q31_t)0xff17862b, (q31_t)0x7fff2151, (q31_t)0xff113db7, (q31_t)0x7fff1572, (q31_t)0xff0af543, - (q31_t)0x7fff0943, (q31_t)0xff04acd0, (q31_t)0x7ffefcc5, (q31_t)0xfefe645e, (q31_t)0x7ffeeff8, (q31_t)0xfef81bec, (q31_t)0x7ffee2dd, (q31_t)0xfef1d37b, - (q31_t)0x7ffed572, (q31_t)0xfeeb8b0a, (q31_t)0x7ffec7b9, (q31_t)0xfee5429a, (q31_t)0x7ffeb9b0, (q31_t)0xfedefa2b, (q31_t)0x7ffeab59, (q31_t)0xfed8b1bd, - (q31_t)0x7ffe9cb2, (q31_t)0xfed2694f, (q31_t)0x7ffe8dbd, (q31_t)0xfecc20e2, (q31_t)0x7ffe7e79, (q31_t)0xfec5d876, (q31_t)0x7ffe6ee5, (q31_t)0xfebf900a, - (q31_t)0x7ffe5f03, (q31_t)0xfeb947a0, (q31_t)0x7ffe4ed2, (q31_t)0xfeb2ff36, (q31_t)0x7ffe3e52, (q31_t)0xfeacb6cc, (q31_t)0x7ffe2d83, (q31_t)0xfea66e64, - (q31_t)0x7ffe1c65, (q31_t)0xfea025fd, (q31_t)0x7ffe0af8, (q31_t)0xfe99dd96, (q31_t)0x7ffdf93c, (q31_t)0xfe939530, (q31_t)0x7ffde731, (q31_t)0xfe8d4ccb, - (q31_t)0x7ffdd4d7, (q31_t)0xfe870467, (q31_t)0x7ffdc22e, (q31_t)0xfe80bc04, (q31_t)0x7ffdaf37, (q31_t)0xfe7a73a2, (q31_t)0x7ffd9bf0, (q31_t)0xfe742b41, - (q31_t)0x7ffd885a, (q31_t)0xfe6de2e0, (q31_t)0x7ffd7476, (q31_t)0xfe679a81, (q31_t)0x7ffd6042, (q31_t)0xfe615223, (q31_t)0x7ffd4bc0, (q31_t)0xfe5b09c5, - (q31_t)0x7ffd36ee, (q31_t)0xfe54c169, (q31_t)0x7ffd21ce, (q31_t)0xfe4e790d, (q31_t)0x7ffd0c5f, (q31_t)0xfe4830b3, (q31_t)0x7ffcf6a0, (q31_t)0xfe41e85a, - (q31_t)0x7ffce093, (q31_t)0xfe3ba002, (q31_t)0x7ffcca37, (q31_t)0xfe3557ab, (q31_t)0x7ffcb38c, (q31_t)0xfe2f0f55, (q31_t)0x7ffc9c92, (q31_t)0xfe28c700, - (q31_t)0x7ffc8549, (q31_t)0xfe227eac, (q31_t)0x7ffc6db1, (q31_t)0xfe1c365a, (q31_t)0x7ffc55ca, (q31_t)0xfe15ee09, (q31_t)0x7ffc3d94, (q31_t)0xfe0fa5b8, - (q31_t)0x7ffc250f, (q31_t)0xfe095d69, (q31_t)0x7ffc0c3b, (q31_t)0xfe03151c, (q31_t)0x7ffbf319, (q31_t)0xfdfccccf, (q31_t)0x7ffbd9a7, (q31_t)0xfdf68484, - (q31_t)0x7ffbbfe6, (q31_t)0xfdf03c3a, (q31_t)0x7ffba5d7, (q31_t)0xfde9f3f1, (q31_t)0x7ffb8b78, (q31_t)0xfde3aba9, (q31_t)0x7ffb70cb, (q31_t)0xfddd6363, - (q31_t)0x7ffb55ce, (q31_t)0xfdd71b1e, (q31_t)0x7ffb3a83, (q31_t)0xfdd0d2db, (q31_t)0x7ffb1ee9, (q31_t)0xfdca8a99, (q31_t)0x7ffb0300, (q31_t)0xfdc44258, - (q31_t)0x7ffae6c7, (q31_t)0xfdbdfa18, (q31_t)0x7ffaca40, (q31_t)0xfdb7b1da, (q31_t)0x7ffaad6a, (q31_t)0xfdb1699e, (q31_t)0x7ffa9045, (q31_t)0xfdab2162, - (q31_t)0x7ffa72d1, (q31_t)0xfda4d929, (q31_t)0x7ffa550e, (q31_t)0xfd9e90f0, (q31_t)0x7ffa36fc, (q31_t)0xfd9848b9, (q31_t)0x7ffa189c, (q31_t)0xfd920084, - (q31_t)0x7ff9f9ec, (q31_t)0xfd8bb850, (q31_t)0x7ff9daed, (q31_t)0xfd85701e, (q31_t)0x7ff9bba0, (q31_t)0xfd7f27ed, (q31_t)0x7ff99c03, (q31_t)0xfd78dfbd, - (q31_t)0x7ff97c18, (q31_t)0xfd729790, (q31_t)0x7ff95bdd, (q31_t)0xfd6c4f64, (q31_t)0x7ff93b54, (q31_t)0xfd660739, (q31_t)0x7ff91a7b, (q31_t)0xfd5fbf10, - (q31_t)0x7ff8f954, (q31_t)0xfd5976e9, (q31_t)0x7ff8d7de, (q31_t)0xfd532ec3, (q31_t)0x7ff8b619, (q31_t)0xfd4ce69f, (q31_t)0x7ff89405, (q31_t)0xfd469e7c, - (q31_t)0x7ff871a2, (q31_t)0xfd40565c, (q31_t)0x7ff84ef0, (q31_t)0xfd3a0e3d, (q31_t)0x7ff82bef, (q31_t)0xfd33c61f, (q31_t)0x7ff8089f, (q31_t)0xfd2d7e04, - (q31_t)0x7ff7e500, (q31_t)0xfd2735ea, (q31_t)0x7ff7c113, (q31_t)0xfd20edd2, (q31_t)0x7ff79cd6, (q31_t)0xfd1aa5bc, (q31_t)0x7ff7784a, (q31_t)0xfd145da7, - (q31_t)0x7ff75370, (q31_t)0xfd0e1594, (q31_t)0x7ff72e46, (q31_t)0xfd07cd83, (q31_t)0x7ff708ce, (q31_t)0xfd018574, (q31_t)0x7ff6e307, (q31_t)0xfcfb3d67, - (q31_t)0x7ff6bcf0, (q31_t)0xfcf4f55c, (q31_t)0x7ff6968b, (q31_t)0xfceead52, (q31_t)0x7ff66fd7, (q31_t)0xfce8654b, (q31_t)0x7ff648d4, (q31_t)0xfce21d45, - (q31_t)0x7ff62182, (q31_t)0xfcdbd541, (q31_t)0x7ff5f9e1, (q31_t)0xfcd58d3f, (q31_t)0x7ff5d1f1, (q31_t)0xfccf453f, (q31_t)0x7ff5a9b2, (q31_t)0xfcc8fd41, - (q31_t)0x7ff58125, (q31_t)0xfcc2b545, (q31_t)0x7ff55848, (q31_t)0xfcbc6d4c, (q31_t)0x7ff52f1d, (q31_t)0xfcb62554, (q31_t)0x7ff505a2, (q31_t)0xfcafdd5e, - (q31_t)0x7ff4dbd9, (q31_t)0xfca9956a, (q31_t)0x7ff4b1c0, (q31_t)0xfca34d78, (q31_t)0x7ff48759, (q31_t)0xfc9d0588, (q31_t)0x7ff45ca3, (q31_t)0xfc96bd9b, - (q31_t)0x7ff4319d, (q31_t)0xfc9075af, (q31_t)0x7ff40649, (q31_t)0xfc8a2dc6, (q31_t)0x7ff3daa6, (q31_t)0xfc83e5de, (q31_t)0x7ff3aeb4, (q31_t)0xfc7d9df9, - (q31_t)0x7ff38274, (q31_t)0xfc775616, (q31_t)0x7ff355e4, (q31_t)0xfc710e36, (q31_t)0x7ff32905, (q31_t)0xfc6ac657, (q31_t)0x7ff2fbd7, (q31_t)0xfc647e7b, - (q31_t)0x7ff2ce5b, (q31_t)0xfc5e36a0, (q31_t)0x7ff2a08f, (q31_t)0xfc57eec9, (q31_t)0x7ff27275, (q31_t)0xfc51a6f3, (q31_t)0x7ff2440b, (q31_t)0xfc4b5f20, - (q31_t)0x7ff21553, (q31_t)0xfc45174e, (q31_t)0x7ff1e64c, (q31_t)0xfc3ecf80, (q31_t)0x7ff1b6f6, (q31_t)0xfc3887b3, (q31_t)0x7ff18751, (q31_t)0xfc323fe9, - (q31_t)0x7ff1575d, (q31_t)0xfc2bf821, (q31_t)0x7ff1271a, (q31_t)0xfc25b05c, (q31_t)0x7ff0f688, (q31_t)0xfc1f6899, (q31_t)0x7ff0c5a7, (q31_t)0xfc1920d8, - (q31_t)0x7ff09478, (q31_t)0xfc12d91a, (q31_t)0x7ff062f9, (q31_t)0xfc0c915e, (q31_t)0x7ff0312c, (q31_t)0xfc0649a5, (q31_t)0x7fefff0f, (q31_t)0xfc0001ee, - (q31_t)0x7fefcca4, (q31_t)0xfbf9ba39, (q31_t)0x7fef99ea, (q31_t)0xfbf37287, (q31_t)0x7fef66e1, (q31_t)0xfbed2ad8, (q31_t)0x7fef3388, (q31_t)0xfbe6e32b, - (q31_t)0x7feeffe1, (q31_t)0xfbe09b80, (q31_t)0x7feecbec, (q31_t)0xfbda53d8, (q31_t)0x7fee97a7, (q31_t)0xfbd40c33, (q31_t)0x7fee6313, (q31_t)0xfbcdc490, - (q31_t)0x7fee2e30, (q31_t)0xfbc77cf0, (q31_t)0x7fedf8ff, (q31_t)0xfbc13552, (q31_t)0x7fedc37e, (q31_t)0xfbbaedb7, (q31_t)0x7fed8daf, (q31_t)0xfbb4a61f, - (q31_t)0x7fed5791, (q31_t)0xfbae5e89, (q31_t)0x7fed2123, (q31_t)0xfba816f6, (q31_t)0x7fecea67, (q31_t)0xfba1cf66, (q31_t)0x7fecb35c, (q31_t)0xfb9b87d8, - (q31_t)0x7fec7c02, (q31_t)0xfb95404d, (q31_t)0x7fec4459, (q31_t)0xfb8ef8c5, (q31_t)0x7fec0c62, (q31_t)0xfb88b13f, (q31_t)0x7febd41b, (q31_t)0xfb8269bd, - (q31_t)0x7feb9b85, (q31_t)0xfb7c223d, (q31_t)0x7feb62a1, (q31_t)0xfb75dac0, (q31_t)0x7feb296d, (q31_t)0xfb6f9345, (q31_t)0x7feaefeb, (q31_t)0xfb694bce, - (q31_t)0x7feab61a, (q31_t)0xfb630459, (q31_t)0x7fea7bfa, (q31_t)0xfb5cbce7, (q31_t)0x7fea418b, (q31_t)0xfb567578, (q31_t)0x7fea06cd, (q31_t)0xfb502e0c, - (q31_t)0x7fe9cbc0, (q31_t)0xfb49e6a3, (q31_t)0x7fe99064, (q31_t)0xfb439f3c, (q31_t)0x7fe954ba, (q31_t)0xfb3d57d9, (q31_t)0x7fe918c0, (q31_t)0xfb371078, - (q31_t)0x7fe8dc78, (q31_t)0xfb30c91b, (q31_t)0x7fe89fe0, (q31_t)0xfb2a81c0, (q31_t)0x7fe862fa, (q31_t)0xfb243a69, (q31_t)0x7fe825c5, (q31_t)0xfb1df314, - (q31_t)0x7fe7e841, (q31_t)0xfb17abc2, (q31_t)0x7fe7aa6e, (q31_t)0xfb116474, (q31_t)0x7fe76c4c, (q31_t)0xfb0b1d28, (q31_t)0x7fe72ddb, (q31_t)0xfb04d5e0, - (q31_t)0x7fe6ef1c, (q31_t)0xfafe8e9b, (q31_t)0x7fe6b00d, (q31_t)0xfaf84758, (q31_t)0x7fe670b0, (q31_t)0xfaf20019, (q31_t)0x7fe63103, (q31_t)0xfaebb8dd, - (q31_t)0x7fe5f108, (q31_t)0xfae571a4, (q31_t)0x7fe5b0be, (q31_t)0xfadf2a6e, (q31_t)0x7fe57025, (q31_t)0xfad8e33c, (q31_t)0x7fe52f3d, (q31_t)0xfad29c0c, - (q31_t)0x7fe4ee06, (q31_t)0xfacc54e0, (q31_t)0x7fe4ac81, (q31_t)0xfac60db7, (q31_t)0x7fe46aac, (q31_t)0xfabfc691, (q31_t)0x7fe42889, (q31_t)0xfab97f6e, - (q31_t)0x7fe3e616, (q31_t)0xfab3384f, (q31_t)0x7fe3a355, (q31_t)0xfaacf133, (q31_t)0x7fe36045, (q31_t)0xfaa6aa1a, (q31_t)0x7fe31ce6, (q31_t)0xfaa06305, - (q31_t)0x7fe2d938, (q31_t)0xfa9a1bf3, (q31_t)0x7fe2953b, (q31_t)0xfa93d4e4, (q31_t)0x7fe250ef, (q31_t)0xfa8d8dd8, (q31_t)0x7fe20c55, (q31_t)0xfa8746d0, - (q31_t)0x7fe1c76b, (q31_t)0xfa80ffcb, (q31_t)0x7fe18233, (q31_t)0xfa7ab8ca, (q31_t)0x7fe13cac, (q31_t)0xfa7471cc, (q31_t)0x7fe0f6d6, (q31_t)0xfa6e2ad1, - (q31_t)0x7fe0b0b1, (q31_t)0xfa67e3da, (q31_t)0x7fe06a3d, (q31_t)0xfa619ce7, (q31_t)0x7fe0237a, (q31_t)0xfa5b55f7, (q31_t)0x7fdfdc69, (q31_t)0xfa550f0a, - (q31_t)0x7fdf9508, (q31_t)0xfa4ec821, (q31_t)0x7fdf4d59, (q31_t)0xfa48813b, (q31_t)0x7fdf055a, (q31_t)0xfa423a59, (q31_t)0x7fdebd0d, (q31_t)0xfa3bf37a, - (q31_t)0x7fde7471, (q31_t)0xfa35ac9f, (q31_t)0x7fde2b86, (q31_t)0xfa2f65c8, (q31_t)0x7fdde24d, (q31_t)0xfa291ef4, (q31_t)0x7fdd98c4, (q31_t)0xfa22d823, - (q31_t)0x7fdd4eec, (q31_t)0xfa1c9157, (q31_t)0x7fdd04c6, (q31_t)0xfa164a8e, (q31_t)0x7fdcba51, (q31_t)0xfa1003c8, (q31_t)0x7fdc6f8d, (q31_t)0xfa09bd06, - (q31_t)0x7fdc247a, (q31_t)0xfa037648, (q31_t)0x7fdbd918, (q31_t)0xf9fd2f8e, (q31_t)0x7fdb8d67, (q31_t)0xf9f6e8d7, (q31_t)0x7fdb4167, (q31_t)0xf9f0a224, - (q31_t)0x7fdaf519, (q31_t)0xf9ea5b75, (q31_t)0x7fdaa87c, (q31_t)0xf9e414ca, (q31_t)0x7fda5b8f, (q31_t)0xf9ddce22, (q31_t)0x7fda0e54, (q31_t)0xf9d7877e, - (q31_t)0x7fd9c0ca, (q31_t)0xf9d140de, (q31_t)0x7fd972f2, (q31_t)0xf9cafa42, (q31_t)0x7fd924ca, (q31_t)0xf9c4b3a9, (q31_t)0x7fd8d653, (q31_t)0xf9be6d15, - (q31_t)0x7fd8878e, (q31_t)0xf9b82684, (q31_t)0x7fd8387a, (q31_t)0xf9b1dff7, (q31_t)0x7fd7e917, (q31_t)0xf9ab996e, (q31_t)0x7fd79965, (q31_t)0xf9a552e9, - (q31_t)0x7fd74964, (q31_t)0xf99f0c68, (q31_t)0x7fd6f914, (q31_t)0xf998c5ea, (q31_t)0x7fd6a875, (q31_t)0xf9927f71, (q31_t)0x7fd65788, (q31_t)0xf98c38fc, - (q31_t)0x7fd6064c, (q31_t)0xf985f28a, (q31_t)0x7fd5b4c1, (q31_t)0xf97fac1d, (q31_t)0x7fd562e7, (q31_t)0xf97965b4, (q31_t)0x7fd510be, (q31_t)0xf9731f4e, - (q31_t)0x7fd4be46, (q31_t)0xf96cd8ed, (q31_t)0x7fd46b80, (q31_t)0xf9669290, (q31_t)0x7fd4186a, (q31_t)0xf9604c37, (q31_t)0x7fd3c506, (q31_t)0xf95a05e2, - (q31_t)0x7fd37153, (q31_t)0xf953bf91, (q31_t)0x7fd31d51, (q31_t)0xf94d7944, (q31_t)0x7fd2c900, (q31_t)0xf94732fb, (q31_t)0x7fd27460, (q31_t)0xf940ecb7, - (q31_t)0x7fd21f72, (q31_t)0xf93aa676, (q31_t)0x7fd1ca35, (q31_t)0xf934603a, (q31_t)0x7fd174a8, (q31_t)0xf92e1a02, (q31_t)0x7fd11ecd, (q31_t)0xf927d3ce, - (q31_t)0x7fd0c8a3, (q31_t)0xf9218d9e, (q31_t)0x7fd0722b, (q31_t)0xf91b4773, (q31_t)0x7fd01b63, (q31_t)0xf915014c, (q31_t)0x7fcfc44d, (q31_t)0xf90ebb29, - (q31_t)0x7fcf6ce8, (q31_t)0xf908750a, (q31_t)0x7fcf1533, (q31_t)0xf9022ef0, (q31_t)0x7fcebd31, (q31_t)0xf8fbe8da, (q31_t)0x7fce64df, (q31_t)0xf8f5a2c9, - (q31_t)0x7fce0c3e, (q31_t)0xf8ef5cbb, (q31_t)0x7fcdb34f, (q31_t)0xf8e916b2, (q31_t)0x7fcd5a11, (q31_t)0xf8e2d0ae, (q31_t)0x7fcd0083, (q31_t)0xf8dc8aae, - (q31_t)0x7fcca6a7, (q31_t)0xf8d644b2, (q31_t)0x7fcc4c7d, (q31_t)0xf8cffebb, (q31_t)0x7fcbf203, (q31_t)0xf8c9b8c8, (q31_t)0x7fcb973b, (q31_t)0xf8c372d9, - (q31_t)0x7fcb3c23, (q31_t)0xf8bd2cef, (q31_t)0x7fcae0bd, (q31_t)0xf8b6e70a, (q31_t)0x7fca8508, (q31_t)0xf8b0a129, (q31_t)0x7fca2905, (q31_t)0xf8aa5b4c, - (q31_t)0x7fc9ccb2, (q31_t)0xf8a41574, (q31_t)0x7fc97011, (q31_t)0xf89dcfa1, (q31_t)0x7fc91320, (q31_t)0xf89789d2, (q31_t)0x7fc8b5e1, (q31_t)0xf8914407, - (q31_t)0x7fc85854, (q31_t)0xf88afe42, (q31_t)0x7fc7fa77, (q31_t)0xf884b880, (q31_t)0x7fc79c4b, (q31_t)0xf87e72c4, (q31_t)0x7fc73dd1, (q31_t)0xf8782d0c, - (q31_t)0x7fc6df08, (q31_t)0xf871e759, (q31_t)0x7fc67ff0, (q31_t)0xf86ba1aa, (q31_t)0x7fc62089, (q31_t)0xf8655c00, (q31_t)0x7fc5c0d3, (q31_t)0xf85f165b, - (q31_t)0x7fc560cf, (q31_t)0xf858d0bb, (q31_t)0x7fc5007c, (q31_t)0xf8528b1f, (q31_t)0x7fc49fda, (q31_t)0xf84c4588, (q31_t)0x7fc43ee9, (q31_t)0xf845fff5, - (q31_t)0x7fc3dda9, (q31_t)0xf83fba68, (q31_t)0x7fc37c1b, (q31_t)0xf83974df, (q31_t)0x7fc31a3d, (q31_t)0xf8332f5b, (q31_t)0x7fc2b811, (q31_t)0xf82ce9dc, - (q31_t)0x7fc25596, (q31_t)0xf826a462, (q31_t)0x7fc1f2cc, (q31_t)0xf8205eec, (q31_t)0x7fc18fb4, (q31_t)0xf81a197b, (q31_t)0x7fc12c4d, (q31_t)0xf813d410, - (q31_t)0x7fc0c896, (q31_t)0xf80d8ea9, (q31_t)0x7fc06491, (q31_t)0xf8074947, (q31_t)0x7fc0003e, (q31_t)0xf80103ea, (q31_t)0x7fbf9b9b, (q31_t)0xf7fabe92, - (q31_t)0x7fbf36aa, (q31_t)0xf7f4793e, (q31_t)0x7fbed16a, (q31_t)0xf7ee33f0, (q31_t)0x7fbe6bdb, (q31_t)0xf7e7eea7, (q31_t)0x7fbe05fd, (q31_t)0xf7e1a963, - (q31_t)0x7fbd9fd0, (q31_t)0xf7db6423, (q31_t)0x7fbd3955, (q31_t)0xf7d51ee9, (q31_t)0x7fbcd28b, (q31_t)0xf7ced9b4, (q31_t)0x7fbc6b72, (q31_t)0xf7c89484, - (q31_t)0x7fbc040a, (q31_t)0xf7c24f59, (q31_t)0x7fbb9c53, (q31_t)0xf7bc0a33, (q31_t)0x7fbb344e, (q31_t)0xf7b5c512, (q31_t)0x7fbacbfa, (q31_t)0xf7af7ff6, - (q31_t)0x7fba6357, (q31_t)0xf7a93ae0, (q31_t)0x7fb9fa65, (q31_t)0xf7a2f5ce, (q31_t)0x7fb99125, (q31_t)0xf79cb0c2, (q31_t)0x7fb92796, (q31_t)0xf7966bbb, - (q31_t)0x7fb8bdb8, (q31_t)0xf79026b9, (q31_t)0x7fb8538b, (q31_t)0xf789e1bc, (q31_t)0x7fb7e90f, (q31_t)0xf7839cc4, (q31_t)0x7fb77e45, (q31_t)0xf77d57d2, - (q31_t)0x7fb7132b, (q31_t)0xf77712e5, (q31_t)0x7fb6a7c3, (q31_t)0xf770cdfd, (q31_t)0x7fb63c0d, (q31_t)0xf76a891b, (q31_t)0x7fb5d007, (q31_t)0xf764443d, - (q31_t)0x7fb563b3, (q31_t)0xf75dff66, (q31_t)0x7fb4f710, (q31_t)0xf757ba93, (q31_t)0x7fb48a1e, (q31_t)0xf75175c6, (q31_t)0x7fb41cdd, (q31_t)0xf74b30fe, - (q31_t)0x7fb3af4e, (q31_t)0xf744ec3b, (q31_t)0x7fb34170, (q31_t)0xf73ea77e, (q31_t)0x7fb2d343, (q31_t)0xf73862c6, (q31_t)0x7fb264c7, (q31_t)0xf7321e14, - (q31_t)0x7fb1f5fc, (q31_t)0xf72bd967, (q31_t)0x7fb186e3, (q31_t)0xf72594c0, (q31_t)0x7fb1177b, (q31_t)0xf71f501e, (q31_t)0x7fb0a7c4, (q31_t)0xf7190b81, - (q31_t)0x7fb037bf, (q31_t)0xf712c6ea, (q31_t)0x7fafc76a, (q31_t)0xf70c8259, (q31_t)0x7faf56c7, (q31_t)0xf7063dcd, (q31_t)0x7faee5d5, (q31_t)0xf6fff946, - (q31_t)0x7fae7495, (q31_t)0xf6f9b4c6, (q31_t)0x7fae0305, (q31_t)0xf6f3704a, (q31_t)0x7fad9127, (q31_t)0xf6ed2bd4, (q31_t)0x7fad1efa, (q31_t)0xf6e6e764, - (q31_t)0x7facac7f, (q31_t)0xf6e0a2fa, (q31_t)0x7fac39b4, (q31_t)0xf6da5e95, (q31_t)0x7fabc69b, (q31_t)0xf6d41a36, (q31_t)0x7fab5333, (q31_t)0xf6cdd5dc, - (q31_t)0x7faadf7c, (q31_t)0xf6c79188, (q31_t)0x7faa6b77, (q31_t)0xf6c14d3a, (q31_t)0x7fa9f723, (q31_t)0xf6bb08f1, (q31_t)0x7fa98280, (q31_t)0xf6b4c4ae, - (q31_t)0x7fa90d8e, (q31_t)0xf6ae8071, (q31_t)0x7fa8984e, (q31_t)0xf6a83c3a, (q31_t)0x7fa822bf, (q31_t)0xf6a1f808, (q31_t)0x7fa7ace1, (q31_t)0xf69bb3dd, - (q31_t)0x7fa736b4, (q31_t)0xf6956fb7, (q31_t)0x7fa6c039, (q31_t)0xf68f2b96, (q31_t)0x7fa6496e, (q31_t)0xf688e77c, (q31_t)0x7fa5d256, (q31_t)0xf682a367, - (q31_t)0x7fa55aee, (q31_t)0xf67c5f59, (q31_t)0x7fa4e338, (q31_t)0xf6761b50, (q31_t)0x7fa46b32, (q31_t)0xf66fd74d, (q31_t)0x7fa3f2df, (q31_t)0xf6699350, - (q31_t)0x7fa37a3c, (q31_t)0xf6634f59, (q31_t)0x7fa3014b, (q31_t)0xf65d0b68, (q31_t)0x7fa2880b, (q31_t)0xf656c77c, (q31_t)0x7fa20e7c, (q31_t)0xf6508397, - (q31_t)0x7fa1949e, (q31_t)0xf64a3fb8, (q31_t)0x7fa11a72, (q31_t)0xf643fbdf, (q31_t)0x7fa09ff7, (q31_t)0xf63db80b, (q31_t)0x7fa0252e, (q31_t)0xf637743e, - (q31_t)0x7f9faa15, (q31_t)0xf6313077, (q31_t)0x7f9f2eae, (q31_t)0xf62aecb5, (q31_t)0x7f9eb2f8, (q31_t)0xf624a8fa, (q31_t)0x7f9e36f4, (q31_t)0xf61e6545, - (q31_t)0x7f9dbaa0, (q31_t)0xf6182196, (q31_t)0x7f9d3dfe, (q31_t)0xf611dded, (q31_t)0x7f9cc10d, (q31_t)0xf60b9a4b, (q31_t)0x7f9c43ce, (q31_t)0xf60556ae, - (q31_t)0x7f9bc640, (q31_t)0xf5ff1318, (q31_t)0x7f9b4863, (q31_t)0xf5f8cf87, (q31_t)0x7f9aca37, (q31_t)0xf5f28bfd, (q31_t)0x7f9a4bbd, (q31_t)0xf5ec4879, - (q31_t)0x7f99ccf4, (q31_t)0xf5e604fc, (q31_t)0x7f994ddc, (q31_t)0xf5dfc184, (q31_t)0x7f98ce76, (q31_t)0xf5d97e13, (q31_t)0x7f984ec1, (q31_t)0xf5d33aa8, - (q31_t)0x7f97cebd, (q31_t)0xf5ccf743, (q31_t)0x7f974e6a, (q31_t)0xf5c6b3e5, (q31_t)0x7f96cdc9, (q31_t)0xf5c0708d, (q31_t)0x7f964cd9, (q31_t)0xf5ba2d3b, - (q31_t)0x7f95cb9a, (q31_t)0xf5b3e9f0, (q31_t)0x7f954a0d, (q31_t)0xf5ada6ab, (q31_t)0x7f94c831, (q31_t)0xf5a7636c, (q31_t)0x7f944606, (q31_t)0xf5a12034, - (q31_t)0x7f93c38c, (q31_t)0xf59add02, (q31_t)0x7f9340c4, (q31_t)0xf59499d6, (q31_t)0x7f92bdad, (q31_t)0xf58e56b1, (q31_t)0x7f923a48, (q31_t)0xf5881393, - (q31_t)0x7f91b694, (q31_t)0xf581d07b, (q31_t)0x7f913291, (q31_t)0xf57b8d69, (q31_t)0x7f90ae3f, (q31_t)0xf5754a5e, (q31_t)0x7f90299f, (q31_t)0xf56f0759, - (q31_t)0x7f8fa4b0, (q31_t)0xf568c45b, (q31_t)0x7f8f1f72, (q31_t)0xf5628163, (q31_t)0x7f8e99e6, (q31_t)0xf55c3e72, (q31_t)0x7f8e140a, (q31_t)0xf555fb88, - (q31_t)0x7f8d8de1, (q31_t)0xf54fb8a4, (q31_t)0x7f8d0768, (q31_t)0xf54975c6, (q31_t)0x7f8c80a1, (q31_t)0xf54332ef, (q31_t)0x7f8bf98b, (q31_t)0xf53cf01f, - (q31_t)0x7f8b7227, (q31_t)0xf536ad56, (q31_t)0x7f8aea74, (q31_t)0xf5306a93, (q31_t)0x7f8a6272, (q31_t)0xf52a27d7, (q31_t)0x7f89da21, (q31_t)0xf523e521, - (q31_t)0x7f895182, (q31_t)0xf51da273, (q31_t)0x7f88c894, (q31_t)0xf5175fca, (q31_t)0x7f883f58, (q31_t)0xf5111d29, (q31_t)0x7f87b5cd, (q31_t)0xf50ada8f, - (q31_t)0x7f872bf3, (q31_t)0xf50497fb, (q31_t)0x7f86a1ca, (q31_t)0xf4fe556e, (q31_t)0x7f861753, (q31_t)0xf4f812e7, (q31_t)0x7f858c8d, (q31_t)0xf4f1d068, - (q31_t)0x7f850179, (q31_t)0xf4eb8def, (q31_t)0x7f847616, (q31_t)0xf4e54b7d, (q31_t)0x7f83ea64, (q31_t)0xf4df0912, (q31_t)0x7f835e64, (q31_t)0xf4d8c6ae, - (q31_t)0x7f82d214, (q31_t)0xf4d28451, (q31_t)0x7f824577, (q31_t)0xf4cc41fb, (q31_t)0x7f81b88a, (q31_t)0xf4c5ffab, (q31_t)0x7f812b4f, (q31_t)0xf4bfbd63, - (q31_t)0x7f809dc5, (q31_t)0xf4b97b21, (q31_t)0x7f800fed, (q31_t)0xf4b338e7, (q31_t)0x7f7f81c6, (q31_t)0xf4acf6b3, (q31_t)0x7f7ef350, (q31_t)0xf4a6b486, - (q31_t)0x7f7e648c, (q31_t)0xf4a07261, (q31_t)0x7f7dd579, (q31_t)0xf49a3042, (q31_t)0x7f7d4617, (q31_t)0xf493ee2b, (q31_t)0x7f7cb667, (q31_t)0xf48dac1a, - (q31_t)0x7f7c2668, (q31_t)0xf4876a10, (q31_t)0x7f7b961b, (q31_t)0xf481280e, (q31_t)0x7f7b057e, (q31_t)0xf47ae613, (q31_t)0x7f7a7494, (q31_t)0xf474a41f, - (q31_t)0x7f79e35a, (q31_t)0xf46e6231, (q31_t)0x7f7951d2, (q31_t)0xf468204b, (q31_t)0x7f78bffb, (q31_t)0xf461de6d, (q31_t)0x7f782dd6, (q31_t)0xf45b9c95, - (q31_t)0x7f779b62, (q31_t)0xf4555ac5, (q31_t)0x7f77089f, (q31_t)0xf44f18fb, (q31_t)0x7f76758e, (q31_t)0xf448d739, (q31_t)0x7f75e22e, (q31_t)0xf442957e, - (q31_t)0x7f754e80, (q31_t)0xf43c53cb, (q31_t)0x7f74ba83, (q31_t)0xf436121e, (q31_t)0x7f742637, (q31_t)0xf42fd079, (q31_t)0x7f73919d, (q31_t)0xf4298edc, - (q31_t)0x7f72fcb4, (q31_t)0xf4234d45, (q31_t)0x7f72677c, (q31_t)0xf41d0bb6, (q31_t)0x7f71d1f6, (q31_t)0xf416ca2e, (q31_t)0x7f713c21, (q31_t)0xf41088ae, - (q31_t)0x7f70a5fe, (q31_t)0xf40a4735, (q31_t)0x7f700f8c, (q31_t)0xf40405c3, (q31_t)0x7f6f78cb, (q31_t)0xf3fdc459, (q31_t)0x7f6ee1bc, (q31_t)0xf3f782f6, - (q31_t)0x7f6e4a5e, (q31_t)0xf3f1419a, (q31_t)0x7f6db2b1, (q31_t)0xf3eb0046, (q31_t)0x7f6d1ab6, (q31_t)0xf3e4bef9, (q31_t)0x7f6c826d, (q31_t)0xf3de7db4, - (q31_t)0x7f6be9d4, (q31_t)0xf3d83c77, (q31_t)0x7f6b50ed, (q31_t)0xf3d1fb40, (q31_t)0x7f6ab7b8, (q31_t)0xf3cbba12, (q31_t)0x7f6a1e34, (q31_t)0xf3c578eb, - (q31_t)0x7f698461, (q31_t)0xf3bf37cb, (q31_t)0x7f68ea40, (q31_t)0xf3b8f6b3, (q31_t)0x7f684fd0, (q31_t)0xf3b2b5a3, (q31_t)0x7f67b512, (q31_t)0xf3ac749a, - (q31_t)0x7f671a05, (q31_t)0xf3a63398, (q31_t)0x7f667ea9, (q31_t)0xf39ff29f, (q31_t)0x7f65e2ff, (q31_t)0xf399b1ad, (q31_t)0x7f654706, (q31_t)0xf39370c2, - (q31_t)0x7f64aabf, (q31_t)0xf38d2fe0, (q31_t)0x7f640e29, (q31_t)0xf386ef05, (q31_t)0x7f637144, (q31_t)0xf380ae31, (q31_t)0x7f62d411, (q31_t)0xf37a6d66, - (q31_t)0x7f62368f, (q31_t)0xf3742ca2, (q31_t)0x7f6198bf, (q31_t)0xf36debe6, (q31_t)0x7f60faa0, (q31_t)0xf367ab31, (q31_t)0x7f605c33, (q31_t)0xf3616a85, - (q31_t)0x7f5fbd77, (q31_t)0xf35b29e0, (q31_t)0x7f5f1e6c, (q31_t)0xf354e943, (q31_t)0x7f5e7f13, (q31_t)0xf34ea8ae, (q31_t)0x7f5ddf6b, (q31_t)0xf3486820, - (q31_t)0x7f5d3f75, (q31_t)0xf342279b, (q31_t)0x7f5c9f30, (q31_t)0xf33be71d, (q31_t)0x7f5bfe9d, (q31_t)0xf335a6a7, (q31_t)0x7f5b5dbb, (q31_t)0xf32f6639, - (q31_t)0x7f5abc8a, (q31_t)0xf32925d3, (q31_t)0x7f5a1b0b, (q31_t)0xf322e575, (q31_t)0x7f59793e, (q31_t)0xf31ca51f, (q31_t)0x7f58d721, (q31_t)0xf31664d1, - (q31_t)0x7f5834b7, (q31_t)0xf310248a, (q31_t)0x7f5791fd, (q31_t)0xf309e44c, (q31_t)0x7f56eef5, (q31_t)0xf303a416, (q31_t)0x7f564b9f, (q31_t)0xf2fd63e8, - (q31_t)0x7f55a7fa, (q31_t)0xf2f723c1, (q31_t)0x7f550407, (q31_t)0xf2f0e3a3, (q31_t)0x7f545fc5, (q31_t)0xf2eaa38d, (q31_t)0x7f53bb34, (q31_t)0xf2e4637f, - (q31_t)0x7f531655, (q31_t)0xf2de2379, (q31_t)0x7f527127, (q31_t)0xf2d7e37b, (q31_t)0x7f51cbab, (q31_t)0xf2d1a385, (q31_t)0x7f5125e0, (q31_t)0xf2cb6398, - (q31_t)0x7f507fc7, (q31_t)0xf2c523b2, (q31_t)0x7f4fd95f, (q31_t)0xf2bee3d5, (q31_t)0x7f4f32a9, (q31_t)0xf2b8a400, (q31_t)0x7f4e8ba4, (q31_t)0xf2b26433, - (q31_t)0x7f4de451, (q31_t)0xf2ac246e, (q31_t)0x7f4d3caf, (q31_t)0xf2a5e4b1, (q31_t)0x7f4c94be, (q31_t)0xf29fa4fd, (q31_t)0x7f4bec7f, (q31_t)0xf2996551, - (q31_t)0x7f4b43f2, (q31_t)0xf29325ad, (q31_t)0x7f4a9b16, (q31_t)0xf28ce612, (q31_t)0x7f49f1eb, (q31_t)0xf286a67e, (q31_t)0x7f494872, (q31_t)0xf28066f4, - (q31_t)0x7f489eaa, (q31_t)0xf27a2771, (q31_t)0x7f47f494, (q31_t)0xf273e7f7, (q31_t)0x7f474a30, (q31_t)0xf26da885, (q31_t)0x7f469f7d, (q31_t)0xf267691b, - (q31_t)0x7f45f47b, (q31_t)0xf26129ba, (q31_t)0x7f45492b, (q31_t)0xf25aea61, (q31_t)0x7f449d8c, (q31_t)0xf254ab11, (q31_t)0x7f43f19f, (q31_t)0xf24e6bc9, - (q31_t)0x7f434563, (q31_t)0xf2482c8a, (q31_t)0x7f4298d9, (q31_t)0xf241ed53, (q31_t)0x7f41ec01, (q31_t)0xf23bae24, (q31_t)0x7f413ed9, (q31_t)0xf2356efe, - (q31_t)0x7f409164, (q31_t)0xf22f2fe1, (q31_t)0x7f3fe3a0, (q31_t)0xf228f0cc, (q31_t)0x7f3f358d, (q31_t)0xf222b1c0, (q31_t)0x7f3e872c, (q31_t)0xf21c72bc, - (q31_t)0x7f3dd87c, (q31_t)0xf21633c0, (q31_t)0x7f3d297e, (q31_t)0xf20ff4ce, (q31_t)0x7f3c7a31, (q31_t)0xf209b5e4, (q31_t)0x7f3bca96, (q31_t)0xf2037702, - (q31_t)0x7f3b1aad, (q31_t)0xf1fd3829, (q31_t)0x7f3a6a75, (q31_t)0xf1f6f959, (q31_t)0x7f39b9ee, (q31_t)0xf1f0ba91, (q31_t)0x7f390919, (q31_t)0xf1ea7bd2, - (q31_t)0x7f3857f6, (q31_t)0xf1e43d1c, (q31_t)0x7f37a684, (q31_t)0xf1ddfe6f, (q31_t)0x7f36f4c3, (q31_t)0xf1d7bfca, (q31_t)0x7f3642b4, (q31_t)0xf1d1812e, - (q31_t)0x7f359057, (q31_t)0xf1cb429a, (q31_t)0x7f34ddab, (q31_t)0xf1c50410, (q31_t)0x7f342ab1, (q31_t)0xf1bec58e, (q31_t)0x7f337768, (q31_t)0xf1b88715, - (q31_t)0x7f32c3d1, (q31_t)0xf1b248a5, (q31_t)0x7f320feb, (q31_t)0xf1ac0a3e, (q31_t)0x7f315bb7, (q31_t)0xf1a5cbdf, (q31_t)0x7f30a734, (q31_t)0xf19f8d89, - (q31_t)0x7f2ff263, (q31_t)0xf1994f3d, (q31_t)0x7f2f3d44, (q31_t)0xf19310f9, (q31_t)0x7f2e87d6, (q31_t)0xf18cd2be, (q31_t)0x7f2dd219, (q31_t)0xf186948c, - (q31_t)0x7f2d1c0e, (q31_t)0xf1805662, (q31_t)0x7f2c65b5, (q31_t)0xf17a1842, (q31_t)0x7f2baf0d, (q31_t)0xf173da2b, (q31_t)0x7f2af817, (q31_t)0xf16d9c1d, - (q31_t)0x7f2a40d2, (q31_t)0xf1675e17, (q31_t)0x7f29893f, (q31_t)0xf161201b, (q31_t)0x7f28d15d, (q31_t)0xf15ae228, (q31_t)0x7f28192d, (q31_t)0xf154a43d, - (q31_t)0x7f2760af, (q31_t)0xf14e665c, (q31_t)0x7f26a7e2, (q31_t)0xf1482884, (q31_t)0x7f25eec7, (q31_t)0xf141eab5, (q31_t)0x7f25355d, (q31_t)0xf13bacef, - (q31_t)0x7f247ba5, (q31_t)0xf1356f32, (q31_t)0x7f23c19e, (q31_t)0xf12f317e, (q31_t)0x7f230749, (q31_t)0xf128f3d4, (q31_t)0x7f224ca6, (q31_t)0xf122b632, - (q31_t)0x7f2191b4, (q31_t)0xf11c789a, (q31_t)0x7f20d674, (q31_t)0xf1163b0b, (q31_t)0x7f201ae5, (q31_t)0xf10ffd85, (q31_t)0x7f1f5f08, (q31_t)0xf109c009, - (q31_t)0x7f1ea2dc, (q31_t)0xf1038295, (q31_t)0x7f1de662, (q31_t)0xf0fd452b, (q31_t)0x7f1d299a, (q31_t)0xf0f707ca, (q31_t)0x7f1c6c83, (q31_t)0xf0f0ca72, - (q31_t)0x7f1baf1e, (q31_t)0xf0ea8d24, (q31_t)0x7f1af16a, (q31_t)0xf0e44fdf, (q31_t)0x7f1a3368, (q31_t)0xf0de12a3, (q31_t)0x7f197518, (q31_t)0xf0d7d571, - (q31_t)0x7f18b679, (q31_t)0xf0d19848, (q31_t)0x7f17f78c, (q31_t)0xf0cb5b28, (q31_t)0x7f173850, (q31_t)0xf0c51e12, (q31_t)0x7f1678c6, (q31_t)0xf0bee105, - (q31_t)0x7f15b8ee, (q31_t)0xf0b8a401, (q31_t)0x7f14f8c7, (q31_t)0xf0b26707, (q31_t)0x7f143852, (q31_t)0xf0ac2a16, (q31_t)0x7f13778e, (q31_t)0xf0a5ed2f, - (q31_t)0x7f12b67c, (q31_t)0xf09fb051, (q31_t)0x7f11f51c, (q31_t)0xf099737d, (q31_t)0x7f11336d, (q31_t)0xf09336b2, (q31_t)0x7f107170, (q31_t)0xf08cf9f1, - (q31_t)0x7f0faf25, (q31_t)0xf086bd39, (q31_t)0x7f0eec8b, (q31_t)0xf080808b, (q31_t)0x7f0e29a3, (q31_t)0xf07a43e7, (q31_t)0x7f0d666c, (q31_t)0xf074074c, - (q31_t)0x7f0ca2e7, (q31_t)0xf06dcaba, (q31_t)0x7f0bdf14, (q31_t)0xf0678e32, (q31_t)0x7f0b1af2, (q31_t)0xf06151b4, (q31_t)0x7f0a5682, (q31_t)0xf05b1540, - (q31_t)0x7f0991c4, (q31_t)0xf054d8d5, (q31_t)0x7f08ccb7, (q31_t)0xf04e9c73, (q31_t)0x7f08075c, (q31_t)0xf048601c, (q31_t)0x7f0741b2, (q31_t)0xf04223ce, - (q31_t)0x7f067bba, (q31_t)0xf03be78a, (q31_t)0x7f05b574, (q31_t)0xf035ab4f, (q31_t)0x7f04eedf, (q31_t)0xf02f6f1f, (q31_t)0x7f0427fc, (q31_t)0xf02932f8, - (q31_t)0x7f0360cb, (q31_t)0xf022f6da, (q31_t)0x7f02994b, (q31_t)0xf01cbac7, (q31_t)0x7f01d17d, (q31_t)0xf0167ebd, (q31_t)0x7f010961, (q31_t)0xf01042be, - (q31_t)0x7f0040f6, (q31_t)0xf00a06c8, (q31_t)0x7eff783d, (q31_t)0xf003cadc, (q31_t)0x7efeaf36, (q31_t)0xeffd8ef9, (q31_t)0x7efde5e0, (q31_t)0xeff75321, - (q31_t)0x7efd1c3c, (q31_t)0xeff11753, (q31_t)0x7efc524a, (q31_t)0xefeadb8e, (q31_t)0x7efb8809, (q31_t)0xefe49fd3, (q31_t)0x7efabd7a, (q31_t)0xefde6423, - (q31_t)0x7ef9f29d, (q31_t)0xefd8287c, (q31_t)0x7ef92771, (q31_t)0xefd1ecdf, (q31_t)0x7ef85bf7, (q31_t)0xefcbb14c, (q31_t)0x7ef7902f, (q31_t)0xefc575c3, - (q31_t)0x7ef6c418, (q31_t)0xefbf3a45, (q31_t)0x7ef5f7b3, (q31_t)0xefb8fed0, (q31_t)0x7ef52b00, (q31_t)0xefb2c365, (q31_t)0x7ef45dfe, (q31_t)0xefac8804, - (q31_t)0x7ef390ae, (q31_t)0xefa64cae, (q31_t)0x7ef2c310, (q31_t)0xefa01161, (q31_t)0x7ef1f524, (q31_t)0xef99d61f, (q31_t)0x7ef126e9, (q31_t)0xef939ae6, - (q31_t)0x7ef05860, (q31_t)0xef8d5fb8, (q31_t)0x7eef8988, (q31_t)0xef872494, (q31_t)0x7eeeba62, (q31_t)0xef80e97a, (q31_t)0x7eedeaee, (q31_t)0xef7aae6b, - (q31_t)0x7eed1b2c, (q31_t)0xef747365, (q31_t)0x7eec4b1b, (q31_t)0xef6e386a, (q31_t)0x7eeb7abc, (q31_t)0xef67fd79, (q31_t)0x7eeaaa0f, (q31_t)0xef61c292, - (q31_t)0x7ee9d914, (q31_t)0xef5b87b5, (q31_t)0x7ee907ca, (q31_t)0xef554ce3, (q31_t)0x7ee83632, (q31_t)0xef4f121b, (q31_t)0x7ee7644c, (q31_t)0xef48d75d, - (q31_t)0x7ee69217, (q31_t)0xef429caa, (q31_t)0x7ee5bf94, (q31_t)0xef3c6201, (q31_t)0x7ee4ecc3, (q31_t)0xef362762, (q31_t)0x7ee419a3, (q31_t)0xef2feccd, - (q31_t)0x7ee34636, (q31_t)0xef29b243, (q31_t)0x7ee2727a, (q31_t)0xef2377c4, (q31_t)0x7ee19e6f, (q31_t)0xef1d3d4e, (q31_t)0x7ee0ca17, (q31_t)0xef1702e4, - (q31_t)0x7edff570, (q31_t)0xef10c883, (q31_t)0x7edf207b, (q31_t)0xef0a8e2d, (q31_t)0x7ede4b38, (q31_t)0xef0453e2, (q31_t)0x7edd75a6, (q31_t)0xeefe19a1, - (q31_t)0x7edc9fc6, (q31_t)0xeef7df6a, (q31_t)0x7edbc998, (q31_t)0xeef1a53e, (q31_t)0x7edaf31c, (q31_t)0xeeeb6b1c, (q31_t)0x7eda1c51, (q31_t)0xeee53105, - (q31_t)0x7ed94538, (q31_t)0xeedef6f9, (q31_t)0x7ed86dd1, (q31_t)0xeed8bcf7, (q31_t)0x7ed7961c, (q31_t)0xeed28300, (q31_t)0x7ed6be18, (q31_t)0xeecc4913, - (q31_t)0x7ed5e5c6, (q31_t)0xeec60f31, (q31_t)0x7ed50d26, (q31_t)0xeebfd55a, (q31_t)0x7ed43438, (q31_t)0xeeb99b8d, (q31_t)0x7ed35afb, (q31_t)0xeeb361cb, - (q31_t)0x7ed28171, (q31_t)0xeead2813, (q31_t)0x7ed1a798, (q31_t)0xeea6ee66, (q31_t)0x7ed0cd70, (q31_t)0xeea0b4c4, (q31_t)0x7ecff2fb, (q31_t)0xee9a7b2d, - (q31_t)0x7ecf1837, (q31_t)0xee9441a0, (q31_t)0x7ece3d25, (q31_t)0xee8e081e, (q31_t)0x7ecd61c5, (q31_t)0xee87cea7, (q31_t)0x7ecc8617, (q31_t)0xee81953b, - (q31_t)0x7ecbaa1a, (q31_t)0xee7b5bd9, (q31_t)0x7ecacdd0, (q31_t)0xee752283, (q31_t)0x7ec9f137, (q31_t)0xee6ee937, (q31_t)0x7ec9144f, (q31_t)0xee68aff6, - (q31_t)0x7ec8371a, (q31_t)0xee6276bf, (q31_t)0x7ec75996, (q31_t)0xee5c3d94, (q31_t)0x7ec67bc5, (q31_t)0xee560473, (q31_t)0x7ec59da5, (q31_t)0xee4fcb5e, - (q31_t)0x7ec4bf36, (q31_t)0xee499253, (q31_t)0x7ec3e07a, (q31_t)0xee435953, (q31_t)0x7ec3016f, (q31_t)0xee3d205e, (q31_t)0x7ec22217, (q31_t)0xee36e775, - (q31_t)0x7ec14270, (q31_t)0xee30ae96, (q31_t)0x7ec0627a, (q31_t)0xee2a75c2, (q31_t)0x7ebf8237, (q31_t)0xee243cf9, (q31_t)0x7ebea1a6, (q31_t)0xee1e043b, - (q31_t)0x7ebdc0c6, (q31_t)0xee17cb88, (q31_t)0x7ebcdf98, (q31_t)0xee1192e0, (q31_t)0x7ebbfe1c, (q31_t)0xee0b5a43, (q31_t)0x7ebb1c52, (q31_t)0xee0521b2, - (q31_t)0x7eba3a39, (q31_t)0xedfee92b, (q31_t)0x7eb957d2, (q31_t)0xedf8b0b0, (q31_t)0x7eb8751e, (q31_t)0xedf2783f, (q31_t)0x7eb7921b, (q31_t)0xedec3fda, - (q31_t)0x7eb6aeca, (q31_t)0xede60780, (q31_t)0x7eb5cb2a, (q31_t)0xeddfcf31, (q31_t)0x7eb4e73d, (q31_t)0xedd996ed, (q31_t)0x7eb40301, (q31_t)0xedd35eb5, - (q31_t)0x7eb31e78, (q31_t)0xedcd2687, (q31_t)0x7eb239a0, (q31_t)0xedc6ee65, (q31_t)0x7eb1547a, (q31_t)0xedc0b64e, (q31_t)0x7eb06f05, (q31_t)0xedba7e43, - (q31_t)0x7eaf8943, (q31_t)0xedb44642, (q31_t)0x7eaea333, (q31_t)0xedae0e4d, (q31_t)0x7eadbcd4, (q31_t)0xeda7d664, (q31_t)0x7eacd627, (q31_t)0xeda19e85, - (q31_t)0x7eabef2c, (q31_t)0xed9b66b2, (q31_t)0x7eab07e3, (q31_t)0xed952eea, (q31_t)0x7eaa204c, (q31_t)0xed8ef72e, (q31_t)0x7ea93867, (q31_t)0xed88bf7d, - (q31_t)0x7ea85033, (q31_t)0xed8287d7, (q31_t)0x7ea767b2, (q31_t)0xed7c503d, (q31_t)0x7ea67ee2, (q31_t)0xed7618ae, (q31_t)0x7ea595c4, (q31_t)0xed6fe12b, - (q31_t)0x7ea4ac58, (q31_t)0xed69a9b3, (q31_t)0x7ea3c29e, (q31_t)0xed637246, (q31_t)0x7ea2d896, (q31_t)0xed5d3ae5, (q31_t)0x7ea1ee3f, (q31_t)0xed570390, - (q31_t)0x7ea1039b, (q31_t)0xed50cc46, (q31_t)0x7ea018a8, (q31_t)0xed4a9507, (q31_t)0x7e9f2d68, (q31_t)0xed445dd5, (q31_t)0x7e9e41d9, (q31_t)0xed3e26ad, - (q31_t)0x7e9d55fc, (q31_t)0xed37ef91, (q31_t)0x7e9c69d1, (q31_t)0xed31b881, (q31_t)0x7e9b7d58, (q31_t)0xed2b817d, (q31_t)0x7e9a9091, (q31_t)0xed254a84, - (q31_t)0x7e99a37c, (q31_t)0xed1f1396, (q31_t)0x7e98b618, (q31_t)0xed18dcb5, (q31_t)0x7e97c867, (q31_t)0xed12a5df, (q31_t)0x7e96da67, (q31_t)0xed0c6f14, - (q31_t)0x7e95ec1a, (q31_t)0xed063856, (q31_t)0x7e94fd7e, (q31_t)0xed0001a3, (q31_t)0x7e940e94, (q31_t)0xecf9cafb, (q31_t)0x7e931f5c, (q31_t)0xecf39460, - (q31_t)0x7e922fd6, (q31_t)0xeced5dd0, (q31_t)0x7e914002, (q31_t)0xece7274c, (q31_t)0x7e904fe0, (q31_t)0xece0f0d4, (q31_t)0x7e8f5f70, (q31_t)0xecdaba67, - (q31_t)0x7e8e6eb2, (q31_t)0xecd48407, (q31_t)0x7e8d7da6, (q31_t)0xecce4db2, (q31_t)0x7e8c8c4b, (q31_t)0xecc81769, (q31_t)0x7e8b9aa3, (q31_t)0xecc1e12c, - (q31_t)0x7e8aa8ac, (q31_t)0xecbbaafb, (q31_t)0x7e89b668, (q31_t)0xecb574d5, (q31_t)0x7e88c3d5, (q31_t)0xecaf3ebc, (q31_t)0x7e87d0f5, (q31_t)0xeca908ae, - (q31_t)0x7e86ddc6, (q31_t)0xeca2d2ad, (q31_t)0x7e85ea49, (q31_t)0xec9c9cb7, (q31_t)0x7e84f67e, (q31_t)0xec9666cd, (q31_t)0x7e840265, (q31_t)0xec9030f0, - (q31_t)0x7e830dff, (q31_t)0xec89fb1e, (q31_t)0x7e82194a, (q31_t)0xec83c558, (q31_t)0x7e812447, (q31_t)0xec7d8f9e, (q31_t)0x7e802ef6, (q31_t)0xec7759f1, - (q31_t)0x7e7f3957, (q31_t)0xec71244f, (q31_t)0x7e7e436a, (q31_t)0xec6aeeba, (q31_t)0x7e7d4d2f, (q31_t)0xec64b930, (q31_t)0x7e7c56a5, (q31_t)0xec5e83b3, - (q31_t)0x7e7b5fce, (q31_t)0xec584e41, (q31_t)0x7e7a68a9, (q31_t)0xec5218dc, (q31_t)0x7e797136, (q31_t)0xec4be383, (q31_t)0x7e787975, (q31_t)0xec45ae36, - (q31_t)0x7e778166, (q31_t)0xec3f78f6, (q31_t)0x7e768908, (q31_t)0xec3943c1, (q31_t)0x7e75905d, (q31_t)0xec330e99, (q31_t)0x7e749764, (q31_t)0xec2cd97d, - (q31_t)0x7e739e1d, (q31_t)0xec26a46d, (q31_t)0x7e72a488, (q31_t)0xec206f69, (q31_t)0x7e71aaa4, (q31_t)0xec1a3a72, (q31_t)0x7e70b073, (q31_t)0xec140587, - (q31_t)0x7e6fb5f4, (q31_t)0xec0dd0a8, (q31_t)0x7e6ebb27, (q31_t)0xec079bd6, (q31_t)0x7e6dc00c, (q31_t)0xec01670f, (q31_t)0x7e6cc4a2, (q31_t)0xebfb3256, - (q31_t)0x7e6bc8eb, (q31_t)0xebf4fda8, (q31_t)0x7e6acce6, (q31_t)0xebeec907, (q31_t)0x7e69d093, (q31_t)0xebe89472, (q31_t)0x7e68d3f2, (q31_t)0xebe25fea, - (q31_t)0x7e67d703, (q31_t)0xebdc2b6e, (q31_t)0x7e66d9c6, (q31_t)0xebd5f6fe, (q31_t)0x7e65dc3b, (q31_t)0xebcfc29b, (q31_t)0x7e64de62, (q31_t)0xebc98e45, - (q31_t)0x7e63e03b, (q31_t)0xebc359fb, (q31_t)0x7e62e1c6, (q31_t)0xebbd25bd, (q31_t)0x7e61e303, (q31_t)0xebb6f18c, (q31_t)0x7e60e3f2, (q31_t)0xebb0bd67, - (q31_t)0x7e5fe493, (q31_t)0xebaa894f, (q31_t)0x7e5ee4e6, (q31_t)0xeba45543, (q31_t)0x7e5de4ec, (q31_t)0xeb9e2144, (q31_t)0x7e5ce4a3, (q31_t)0xeb97ed52, - (q31_t)0x7e5be40c, (q31_t)0xeb91b96c, (q31_t)0x7e5ae328, (q31_t)0xeb8b8593, (q31_t)0x7e59e1f5, (q31_t)0xeb8551c6, (q31_t)0x7e58e075, (q31_t)0xeb7f1e06, - (q31_t)0x7e57dea7, (q31_t)0xeb78ea52, (q31_t)0x7e56dc8a, (q31_t)0xeb72b6ac, (q31_t)0x7e55da20, (q31_t)0xeb6c8312, (q31_t)0x7e54d768, (q31_t)0xeb664f84, - (q31_t)0x7e53d462, (q31_t)0xeb601c04, (q31_t)0x7e52d10e, (q31_t)0xeb59e890, (q31_t)0x7e51cd6c, (q31_t)0xeb53b529, (q31_t)0x7e50c97c, (q31_t)0xeb4d81ce, - (q31_t)0x7e4fc53e, (q31_t)0xeb474e81, (q31_t)0x7e4ec0b2, (q31_t)0xeb411b40, (q31_t)0x7e4dbbd9, (q31_t)0xeb3ae80c, (q31_t)0x7e4cb6b1, (q31_t)0xeb34b4e4, - (q31_t)0x7e4bb13c, (q31_t)0xeb2e81ca, (q31_t)0x7e4aab78, (q31_t)0xeb284ebc, (q31_t)0x7e49a567, (q31_t)0xeb221bbb, (q31_t)0x7e489f08, (q31_t)0xeb1be8c8, - (q31_t)0x7e47985b, (q31_t)0xeb15b5e1, (q31_t)0x7e469160, (q31_t)0xeb0f8307, (q31_t)0x7e458a17, (q31_t)0xeb095039, (q31_t)0x7e448281, (q31_t)0xeb031d79, - (q31_t)0x7e437a9c, (q31_t)0xeafceac6, (q31_t)0x7e427269, (q31_t)0xeaf6b81f, (q31_t)0x7e4169e9, (q31_t)0xeaf08586, (q31_t)0x7e40611b, (q31_t)0xeaea52fa, - (q31_t)0x7e3f57ff, (q31_t)0xeae4207a, (q31_t)0x7e3e4e95, (q31_t)0xeaddee08, (q31_t)0x7e3d44dd, (q31_t)0xead7bba3, (q31_t)0x7e3c3ad7, (q31_t)0xead1894b, - (q31_t)0x7e3b3083, (q31_t)0xeacb56ff, (q31_t)0x7e3a25e2, (q31_t)0xeac524c1, (q31_t)0x7e391af3, (q31_t)0xeabef290, (q31_t)0x7e380fb5, (q31_t)0xeab8c06c, - (q31_t)0x7e37042a, (q31_t)0xeab28e56, (q31_t)0x7e35f851, (q31_t)0xeaac5c4c, (q31_t)0x7e34ec2b, (q31_t)0xeaa62a4f, (q31_t)0x7e33dfb6, (q31_t)0xea9ff860, - (q31_t)0x7e32d2f4, (q31_t)0xea99c67e, (q31_t)0x7e31c5e3, (q31_t)0xea9394a9, (q31_t)0x7e30b885, (q31_t)0xea8d62e1, (q31_t)0x7e2faad9, (q31_t)0xea873127, - (q31_t)0x7e2e9cdf, (q31_t)0xea80ff7a, (q31_t)0x7e2d8e97, (q31_t)0xea7acdda, (q31_t)0x7e2c8002, (q31_t)0xea749c47, (q31_t)0x7e2b711f, (q31_t)0xea6e6ac2, - (q31_t)0x7e2a61ed, (q31_t)0xea683949, (q31_t)0x7e29526e, (q31_t)0xea6207df, (q31_t)0x7e2842a2, (q31_t)0xea5bd681, (q31_t)0x7e273287, (q31_t)0xea55a531, - (q31_t)0x7e26221f, (q31_t)0xea4f73ee, (q31_t)0x7e251168, (q31_t)0xea4942b9, (q31_t)0x7e240064, (q31_t)0xea431191, (q31_t)0x7e22ef12, (q31_t)0xea3ce077, - (q31_t)0x7e21dd73, (q31_t)0xea36af69, (q31_t)0x7e20cb85, (q31_t)0xea307e6a, (q31_t)0x7e1fb94a, (q31_t)0xea2a4d78, (q31_t)0x7e1ea6c1, (q31_t)0xea241c93, - (q31_t)0x7e1d93ea, (q31_t)0xea1debbb, (q31_t)0x7e1c80c5, (q31_t)0xea17baf2, (q31_t)0x7e1b6d53, (q31_t)0xea118a35, (q31_t)0x7e1a5992, (q31_t)0xea0b5987, - (q31_t)0x7e194584, (q31_t)0xea0528e5, (q31_t)0x7e183128, (q31_t)0xe9fef852, (q31_t)0x7e171c7f, (q31_t)0xe9f8c7cc, (q31_t)0x7e160787, (q31_t)0xe9f29753, - (q31_t)0x7e14f242, (q31_t)0xe9ec66e8, (q31_t)0x7e13dcaf, (q31_t)0xe9e6368b, (q31_t)0x7e12c6ce, (q31_t)0xe9e0063c, (q31_t)0x7e11b0a0, (q31_t)0xe9d9d5fa, - (q31_t)0x7e109a24, (q31_t)0xe9d3a5c5, (q31_t)0x7e0f835a, (q31_t)0xe9cd759f, (q31_t)0x7e0e6c42, (q31_t)0xe9c74586, (q31_t)0x7e0d54dc, (q31_t)0xe9c1157a, - (q31_t)0x7e0c3d29, (q31_t)0xe9bae57d, (q31_t)0x7e0b2528, (q31_t)0xe9b4b58d, (q31_t)0x7e0a0cd9, (q31_t)0xe9ae85ab, (q31_t)0x7e08f43d, (q31_t)0xe9a855d7, - (q31_t)0x7e07db52, (q31_t)0xe9a22610, (q31_t)0x7e06c21a, (q31_t)0xe99bf658, (q31_t)0x7e05a894, (q31_t)0xe995c6ad, (q31_t)0x7e048ec1, (q31_t)0xe98f9710, - (q31_t)0x7e0374a0, (q31_t)0xe9896781, (q31_t)0x7e025a31, (q31_t)0xe98337ff, (q31_t)0x7e013f74, (q31_t)0xe97d088c, (q31_t)0x7e00246a, (q31_t)0xe976d926, - (q31_t)0x7dff0911, (q31_t)0xe970a9ce, (q31_t)0x7dfded6c, (q31_t)0xe96a7a85, (q31_t)0x7dfcd178, (q31_t)0xe9644b49, (q31_t)0x7dfbb537, (q31_t)0xe95e1c1b, - (q31_t)0x7dfa98a8, (q31_t)0xe957ecfb, (q31_t)0x7df97bcb, (q31_t)0xe951bde9, (q31_t)0x7df85ea0, (q31_t)0xe94b8ee5, (q31_t)0x7df74128, (q31_t)0xe9455fef, - (q31_t)0x7df62362, (q31_t)0xe93f3107, (q31_t)0x7df5054f, (q31_t)0xe939022d, (q31_t)0x7df3e6ee, (q31_t)0xe932d361, (q31_t)0x7df2c83f, (q31_t)0xe92ca4a4, - (q31_t)0x7df1a942, (q31_t)0xe92675f4, (q31_t)0x7df089f8, (q31_t)0xe9204752, (q31_t)0x7def6a60, (q31_t)0xe91a18bf, (q31_t)0x7dee4a7a, (q31_t)0xe913ea39, - (q31_t)0x7ded2a47, (q31_t)0xe90dbbc2, (q31_t)0x7dec09c6, (q31_t)0xe9078d59, (q31_t)0x7deae8f7, (q31_t)0xe9015efe, (q31_t)0x7de9c7da, (q31_t)0xe8fb30b1, - (q31_t)0x7de8a670, (q31_t)0xe8f50273, (q31_t)0x7de784b9, (q31_t)0xe8eed443, (q31_t)0x7de662b3, (q31_t)0xe8e8a621, (q31_t)0x7de54060, (q31_t)0xe8e2780d, - (q31_t)0x7de41dc0, (q31_t)0xe8dc4a07, (q31_t)0x7de2fad1, (q31_t)0xe8d61c10, (q31_t)0x7de1d795, (q31_t)0xe8cfee27, (q31_t)0x7de0b40b, (q31_t)0xe8c9c04c, - (q31_t)0x7ddf9034, (q31_t)0xe8c39280, (q31_t)0x7dde6c0f, (q31_t)0xe8bd64c2, (q31_t)0x7ddd479d, (q31_t)0xe8b73712, (q31_t)0x7ddc22dc, (q31_t)0xe8b10971, - (q31_t)0x7ddafdce, (q31_t)0xe8aadbde, (q31_t)0x7dd9d873, (q31_t)0xe8a4ae59, (q31_t)0x7dd8b2ca, (q31_t)0xe89e80e3, (q31_t)0x7dd78cd3, (q31_t)0xe898537b, - (q31_t)0x7dd6668f, (q31_t)0xe8922622, (q31_t)0x7dd53ffc, (q31_t)0xe88bf8d7, (q31_t)0x7dd4191d, (q31_t)0xe885cb9a, (q31_t)0x7dd2f1f0, (q31_t)0xe87f9e6c, - (q31_t)0x7dd1ca75, (q31_t)0xe879714d, (q31_t)0x7dd0a2ac, (q31_t)0xe873443c, (q31_t)0x7dcf7a96, (q31_t)0xe86d173a, (q31_t)0x7dce5232, (q31_t)0xe866ea46, - (q31_t)0x7dcd2981, (q31_t)0xe860bd61, (q31_t)0x7dcc0082, (q31_t)0xe85a908a, (q31_t)0x7dcad736, (q31_t)0xe85463c2, (q31_t)0x7dc9ad9c, (q31_t)0xe84e3708, - (q31_t)0x7dc883b4, (q31_t)0xe8480a5d, (q31_t)0x7dc7597f, (q31_t)0xe841ddc1, (q31_t)0x7dc62efc, (q31_t)0xe83bb133, (q31_t)0x7dc5042b, (q31_t)0xe83584b4, - (q31_t)0x7dc3d90d, (q31_t)0xe82f5844, (q31_t)0x7dc2ada2, (q31_t)0xe8292be3, (q31_t)0x7dc181e8, (q31_t)0xe822ff90, (q31_t)0x7dc055e2, (q31_t)0xe81cd34b, - (q31_t)0x7dbf298d, (q31_t)0xe816a716, (q31_t)0x7dbdfceb, (q31_t)0xe8107aef, (q31_t)0x7dbccffc, (q31_t)0xe80a4ed7, (q31_t)0x7dbba2bf, (q31_t)0xe80422ce, - (q31_t)0x7dba7534, (q31_t)0xe7fdf6d4, (q31_t)0x7db9475c, (q31_t)0xe7f7cae8, (q31_t)0x7db81936, (q31_t)0xe7f19f0c, (q31_t)0x7db6eac3, (q31_t)0xe7eb733e, - (q31_t)0x7db5bc02, (q31_t)0xe7e5477f, (q31_t)0x7db48cf4, (q31_t)0xe7df1bcf, (q31_t)0x7db35d98, (q31_t)0xe7d8f02d, (q31_t)0x7db22def, (q31_t)0xe7d2c49b, - (q31_t)0x7db0fdf8, (q31_t)0xe7cc9917, (q31_t)0x7dafcdb3, (q31_t)0xe7c66da3, (q31_t)0x7dae9d21, (q31_t)0xe7c0423d, (q31_t)0x7dad6c42, (q31_t)0xe7ba16e7, - (q31_t)0x7dac3b15, (q31_t)0xe7b3eb9f, (q31_t)0x7dab099a, (q31_t)0xe7adc066, (q31_t)0x7da9d7d2, (q31_t)0xe7a7953d, (q31_t)0x7da8a5bc, (q31_t)0xe7a16a22, - (q31_t)0x7da77359, (q31_t)0xe79b3f16, (q31_t)0x7da640a9, (q31_t)0xe795141a, (q31_t)0x7da50dab, (q31_t)0xe78ee92c, (q31_t)0x7da3da5f, (q31_t)0xe788be4e, - (q31_t)0x7da2a6c6, (q31_t)0xe782937e, (q31_t)0x7da172df, (q31_t)0xe77c68be, (q31_t)0x7da03eab, (q31_t)0xe7763e0d, (q31_t)0x7d9f0a29, (q31_t)0xe770136b, - (q31_t)0x7d9dd55a, (q31_t)0xe769e8d8, (q31_t)0x7d9ca03e, (q31_t)0xe763be55, (q31_t)0x7d9b6ad3, (q31_t)0xe75d93e0, (q31_t)0x7d9a351c, (q31_t)0xe757697b, - (q31_t)0x7d98ff17, (q31_t)0xe7513f25, (q31_t)0x7d97c8c4, (q31_t)0xe74b14de, (q31_t)0x7d969224, (q31_t)0xe744eaa6, (q31_t)0x7d955b37, (q31_t)0xe73ec07e, - (q31_t)0x7d9423fc, (q31_t)0xe7389665, (q31_t)0x7d92ec73, (q31_t)0xe7326c5b, (q31_t)0x7d91b49e, (q31_t)0xe72c4260, (q31_t)0x7d907c7a, (q31_t)0xe7261875, - (q31_t)0x7d8f4409, (q31_t)0xe71fee99, (q31_t)0x7d8e0b4b, (q31_t)0xe719c4cd, (q31_t)0x7d8cd240, (q31_t)0xe7139b10, (q31_t)0x7d8b98e6, (q31_t)0xe70d7162, - (q31_t)0x7d8a5f40, (q31_t)0xe70747c4, (q31_t)0x7d89254c, (q31_t)0xe7011e35, (q31_t)0x7d87eb0a, (q31_t)0xe6faf4b5, (q31_t)0x7d86b07c, (q31_t)0xe6f4cb45, - (q31_t)0x7d85759f, (q31_t)0xe6eea1e4, (q31_t)0x7d843a76, (q31_t)0xe6e87893, (q31_t)0x7d82fefe, (q31_t)0xe6e24f51, (q31_t)0x7d81c33a, (q31_t)0xe6dc261f, - (q31_t)0x7d808728, (q31_t)0xe6d5fcfc, (q31_t)0x7d7f4ac8, (q31_t)0xe6cfd3e9, (q31_t)0x7d7e0e1c, (q31_t)0xe6c9aae5, (q31_t)0x7d7cd121, (q31_t)0xe6c381f1, - (q31_t)0x7d7b93da, (q31_t)0xe6bd590d, (q31_t)0x7d7a5645, (q31_t)0xe6b73038, (q31_t)0x7d791862, (q31_t)0xe6b10772, (q31_t)0x7d77da32, (q31_t)0xe6aadebc, - (q31_t)0x7d769bb5, (q31_t)0xe6a4b616, (q31_t)0x7d755cea, (q31_t)0xe69e8d80, (q31_t)0x7d741dd2, (q31_t)0xe69864f9, (q31_t)0x7d72de6d, (q31_t)0xe6923c82, - (q31_t)0x7d719eba, (q31_t)0xe68c141a, (q31_t)0x7d705eba, (q31_t)0xe685ebc2, (q31_t)0x7d6f1e6c, (q31_t)0xe67fc37a, (q31_t)0x7d6dddd2, (q31_t)0xe6799b42, - (q31_t)0x7d6c9ce9, (q31_t)0xe6737319, (q31_t)0x7d6b5bb4, (q31_t)0xe66d4b01, (q31_t)0x7d6a1a31, (q31_t)0xe66722f7, (q31_t)0x7d68d860, (q31_t)0xe660fafe, - (q31_t)0x7d679642, (q31_t)0xe65ad315, (q31_t)0x7d6653d7, (q31_t)0xe654ab3b, (q31_t)0x7d65111f, (q31_t)0xe64e8371, (q31_t)0x7d63ce19, (q31_t)0xe6485bb7, - (q31_t)0x7d628ac6, (q31_t)0xe642340d, (q31_t)0x7d614725, (q31_t)0xe63c0c73, (q31_t)0x7d600338, (q31_t)0xe635e4e9, (q31_t)0x7d5ebefc, (q31_t)0xe62fbd6e, - (q31_t)0x7d5d7a74, (q31_t)0xe6299604, (q31_t)0x7d5c359e, (q31_t)0xe6236ea9, (q31_t)0x7d5af07b, (q31_t)0xe61d475e, (q31_t)0x7d59ab0a, (q31_t)0xe6172024, - (q31_t)0x7d58654d, (q31_t)0xe610f8f9, (q31_t)0x7d571f41, (q31_t)0xe60ad1de, (q31_t)0x7d55d8e9, (q31_t)0xe604aad4, (q31_t)0x7d549243, (q31_t)0xe5fe83d9, - (q31_t)0x7d534b50, (q31_t)0xe5f85cef, (q31_t)0x7d520410, (q31_t)0xe5f23614, (q31_t)0x7d50bc82, (q31_t)0xe5ec0f4a, (q31_t)0x7d4f74a7, (q31_t)0xe5e5e88f, - (q31_t)0x7d4e2c7f, (q31_t)0xe5dfc1e5, (q31_t)0x7d4ce409, (q31_t)0xe5d99b4b, (q31_t)0x7d4b9b46, (q31_t)0xe5d374c1, (q31_t)0x7d4a5236, (q31_t)0xe5cd4e47, - (q31_t)0x7d4908d9, (q31_t)0xe5c727dd, (q31_t)0x7d47bf2e, (q31_t)0xe5c10184, (q31_t)0x7d467536, (q31_t)0xe5badb3a, (q31_t)0x7d452af1, (q31_t)0xe5b4b501, - (q31_t)0x7d43e05e, (q31_t)0xe5ae8ed8, (q31_t)0x7d42957e, (q31_t)0xe5a868bf, (q31_t)0x7d414a51, (q31_t)0xe5a242b7, (q31_t)0x7d3ffed7, (q31_t)0xe59c1cbf, - (q31_t)0x7d3eb30f, (q31_t)0xe595f6d7, (q31_t)0x7d3d66fa, (q31_t)0xe58fd0ff, (q31_t)0x7d3c1a98, (q31_t)0xe589ab38, (q31_t)0x7d3acde9, (q31_t)0xe5838581, - (q31_t)0x7d3980ec, (q31_t)0xe57d5fda, (q31_t)0x7d3833a2, (q31_t)0xe5773a44, (q31_t)0x7d36e60b, (q31_t)0xe57114be, (q31_t)0x7d359827, (q31_t)0xe56aef49, - (q31_t)0x7d3449f5, (q31_t)0xe564c9e3, (q31_t)0x7d32fb76, (q31_t)0xe55ea48f, (q31_t)0x7d31acaa, (q31_t)0xe5587f4a, (q31_t)0x7d305d91, (q31_t)0xe5525a17, - (q31_t)0x7d2f0e2b, (q31_t)0xe54c34f3, (q31_t)0x7d2dbe77, (q31_t)0xe5460fe0, (q31_t)0x7d2c6e76, (q31_t)0xe53feade, (q31_t)0x7d2b1e28, (q31_t)0xe539c5ec, - (q31_t)0x7d29cd8c, (q31_t)0xe533a10a, (q31_t)0x7d287ca4, (q31_t)0xe52d7c39, (q31_t)0x7d272b6e, (q31_t)0xe5275779, (q31_t)0x7d25d9eb, (q31_t)0xe52132c9, - (q31_t)0x7d24881b, (q31_t)0xe51b0e2a, (q31_t)0x7d2335fe, (q31_t)0xe514e99b, (q31_t)0x7d21e393, (q31_t)0xe50ec51d, (q31_t)0x7d2090db, (q31_t)0xe508a0b0, - (q31_t)0x7d1f3dd6, (q31_t)0xe5027c53, (q31_t)0x7d1dea84, (q31_t)0xe4fc5807, (q31_t)0x7d1c96e5, (q31_t)0xe4f633cc, (q31_t)0x7d1b42f9, (q31_t)0xe4f00fa1, - (q31_t)0x7d19eebf, (q31_t)0xe4e9eb87, (q31_t)0x7d189a38, (q31_t)0xe4e3c77d, (q31_t)0x7d174564, (q31_t)0xe4dda385, (q31_t)0x7d15f043, (q31_t)0xe4d77f9d, - (q31_t)0x7d149ad5, (q31_t)0xe4d15bc6, (q31_t)0x7d134519, (q31_t)0xe4cb37ff, (q31_t)0x7d11ef11, (q31_t)0xe4c5144a, (q31_t)0x7d1098bb, (q31_t)0xe4bef0a5, - (q31_t)0x7d0f4218, (q31_t)0xe4b8cd11, (q31_t)0x7d0deb28, (q31_t)0xe4b2a98e, (q31_t)0x7d0c93eb, (q31_t)0xe4ac861b, (q31_t)0x7d0b3c60, (q31_t)0xe4a662ba, - (q31_t)0x7d09e489, (q31_t)0xe4a03f69, (q31_t)0x7d088c64, (q31_t)0xe49a1c29, (q31_t)0x7d0733f3, (q31_t)0xe493f8fb, (q31_t)0x7d05db34, (q31_t)0xe48dd5dd, - (q31_t)0x7d048228, (q31_t)0xe487b2d0, (q31_t)0x7d0328cf, (q31_t)0xe4818fd4, (q31_t)0x7d01cf29, (q31_t)0xe47b6ce9, (q31_t)0x7d007535, (q31_t)0xe4754a0e, - (q31_t)0x7cff1af5, (q31_t)0xe46f2745, (q31_t)0x7cfdc068, (q31_t)0xe469048d, (q31_t)0x7cfc658d, (q31_t)0xe462e1e6, (q31_t)0x7cfb0a65, (q31_t)0xe45cbf50, - (q31_t)0x7cf9aef0, (q31_t)0xe4569ccb, (q31_t)0x7cf8532f, (q31_t)0xe4507a57, (q31_t)0x7cf6f720, (q31_t)0xe44a57f4, (q31_t)0x7cf59ac4, (q31_t)0xe44435a2, - (q31_t)0x7cf43e1a, (q31_t)0xe43e1362, (q31_t)0x7cf2e124, (q31_t)0xe437f132, (q31_t)0x7cf183e1, (q31_t)0xe431cf14, (q31_t)0x7cf02651, (q31_t)0xe42bad07, - (q31_t)0x7ceec873, (q31_t)0xe4258b0a, (q31_t)0x7ced6a49, (q31_t)0xe41f6920, (q31_t)0x7cec0bd1, (q31_t)0xe4194746, (q31_t)0x7ceaad0c, (q31_t)0xe413257d, - (q31_t)0x7ce94dfb, (q31_t)0xe40d03c6, (q31_t)0x7ce7ee9c, (q31_t)0xe406e220, (q31_t)0x7ce68ef0, (q31_t)0xe400c08b, (q31_t)0x7ce52ef7, (q31_t)0xe3fa9f08, - (q31_t)0x7ce3ceb2, (q31_t)0xe3f47d96, (q31_t)0x7ce26e1f, (q31_t)0xe3ee5c35, (q31_t)0x7ce10d3f, (q31_t)0xe3e83ae5, (q31_t)0x7cdfac12, (q31_t)0xe3e219a7, - (q31_t)0x7cde4a98, (q31_t)0xe3dbf87a, (q31_t)0x7cdce8d1, (q31_t)0xe3d5d75e, (q31_t)0x7cdb86bd, (q31_t)0xe3cfb654, (q31_t)0x7cda245c, (q31_t)0xe3c9955b, - (q31_t)0x7cd8c1ae, (q31_t)0xe3c37474, (q31_t)0x7cd75eb3, (q31_t)0xe3bd539e, (q31_t)0x7cd5fb6a, (q31_t)0xe3b732d9, (q31_t)0x7cd497d5, (q31_t)0xe3b11226, - (q31_t)0x7cd333f3, (q31_t)0xe3aaf184, (q31_t)0x7cd1cfc4, (q31_t)0xe3a4d0f4, (q31_t)0x7cd06b48, (q31_t)0xe39eb075, (q31_t)0x7ccf067f, (q31_t)0xe3989008, - (q31_t)0x7ccda169, (q31_t)0xe3926fad, (q31_t)0x7ccc3c06, (q31_t)0xe38c4f63, (q31_t)0x7ccad656, (q31_t)0xe3862f2a, (q31_t)0x7cc97059, (q31_t)0xe3800f03, - (q31_t)0x7cc80a0f, (q31_t)0xe379eeed, (q31_t)0x7cc6a378, (q31_t)0xe373ceea, (q31_t)0x7cc53c94, (q31_t)0xe36daef7, (q31_t)0x7cc3d563, (q31_t)0xe3678f17, - (q31_t)0x7cc26de5, (q31_t)0xe3616f48, (q31_t)0x7cc1061a, (q31_t)0xe35b4f8b, (q31_t)0x7cbf9e03, (q31_t)0xe3552fdf, (q31_t)0x7cbe359e, (q31_t)0xe34f1045, - (q31_t)0x7cbcccec, (q31_t)0xe348f0bd, (q31_t)0x7cbb63ee, (q31_t)0xe342d146, (q31_t)0x7cb9faa2, (q31_t)0xe33cb1e1, (q31_t)0x7cb8910a, (q31_t)0xe336928e, - (q31_t)0x7cb72724, (q31_t)0xe330734d, (q31_t)0x7cb5bcf2, (q31_t)0xe32a541d, (q31_t)0x7cb45272, (q31_t)0xe3243500, (q31_t)0x7cb2e7a6, (q31_t)0xe31e15f4, - (q31_t)0x7cb17c8d, (q31_t)0xe317f6fa, (q31_t)0x7cb01127, (q31_t)0xe311d811, (q31_t)0x7caea574, (q31_t)0xe30bb93b, (q31_t)0x7cad3974, (q31_t)0xe3059a76, - (q31_t)0x7cabcd28, (q31_t)0xe2ff7bc3, (q31_t)0x7caa608e, (q31_t)0xe2f95d23, (q31_t)0x7ca8f3a7, (q31_t)0xe2f33e94, (q31_t)0x7ca78674, (q31_t)0xe2ed2017, - (q31_t)0x7ca618f3, (q31_t)0xe2e701ac, (q31_t)0x7ca4ab26, (q31_t)0xe2e0e352, (q31_t)0x7ca33d0c, (q31_t)0xe2dac50b, (q31_t)0x7ca1cea5, (q31_t)0xe2d4a6d6, - (q31_t)0x7ca05ff1, (q31_t)0xe2ce88b3, (q31_t)0x7c9ef0f0, (q31_t)0xe2c86aa2, (q31_t)0x7c9d81a3, (q31_t)0xe2c24ca2, (q31_t)0x7c9c1208, (q31_t)0xe2bc2eb5, - (q31_t)0x7c9aa221, (q31_t)0xe2b610da, (q31_t)0x7c9931ec, (q31_t)0xe2aff311, (q31_t)0x7c97c16b, (q31_t)0xe2a9d55a, (q31_t)0x7c96509d, (q31_t)0xe2a3b7b5, - (q31_t)0x7c94df83, (q31_t)0xe29d9a23, (q31_t)0x7c936e1b, (q31_t)0xe2977ca2, (q31_t)0x7c91fc66, (q31_t)0xe2915f34, (q31_t)0x7c908a65, (q31_t)0xe28b41d7, - (q31_t)0x7c8f1817, (q31_t)0xe285248d, (q31_t)0x7c8da57c, (q31_t)0xe27f0755, (q31_t)0x7c8c3294, (q31_t)0xe278ea30, (q31_t)0x7c8abf5f, (q31_t)0xe272cd1c, - (q31_t)0x7c894bde, (q31_t)0xe26cb01b, (q31_t)0x7c87d810, (q31_t)0xe266932c, (q31_t)0x7c8663f4, (q31_t)0xe260764f, (q31_t)0x7c84ef8c, (q31_t)0xe25a5984, - (q31_t)0x7c837ad8, (q31_t)0xe2543ccc, (q31_t)0x7c8205d6, (q31_t)0xe24e2026, (q31_t)0x7c809088, (q31_t)0xe2480393, (q31_t)0x7c7f1aed, (q31_t)0xe241e711, - (q31_t)0x7c7da505, (q31_t)0xe23bcaa2, (q31_t)0x7c7c2ed0, (q31_t)0xe235ae46, (q31_t)0x7c7ab84e, (q31_t)0xe22f91fc, (q31_t)0x7c794180, (q31_t)0xe22975c4, - (q31_t)0x7c77ca65, (q31_t)0xe223599e, (q31_t)0x7c7652fd, (q31_t)0xe21d3d8b, (q31_t)0x7c74db48, (q31_t)0xe217218b, (q31_t)0x7c736347, (q31_t)0xe211059d, - (q31_t)0x7c71eaf9, (q31_t)0xe20ae9c1, (q31_t)0x7c70725e, (q31_t)0xe204cdf8, (q31_t)0x7c6ef976, (q31_t)0xe1feb241, (q31_t)0x7c6d8041, (q31_t)0xe1f8969d, - (q31_t)0x7c6c06c0, (q31_t)0xe1f27b0b, (q31_t)0x7c6a8cf2, (q31_t)0xe1ec5f8c, (q31_t)0x7c6912d7, (q31_t)0xe1e64420, (q31_t)0x7c679870, (q31_t)0xe1e028c6, - (q31_t)0x7c661dbc, (q31_t)0xe1da0d7e, (q31_t)0x7c64a2bb, (q31_t)0xe1d3f24a, (q31_t)0x7c63276d, (q31_t)0xe1cdd727, (q31_t)0x7c61abd3, (q31_t)0xe1c7bc18, - (q31_t)0x7c602fec, (q31_t)0xe1c1a11b, (q31_t)0x7c5eb3b8, (q31_t)0xe1bb8631, (q31_t)0x7c5d3737, (q31_t)0xe1b56b59, (q31_t)0x7c5bba6a, (q31_t)0xe1af5094, - (q31_t)0x7c5a3d50, (q31_t)0xe1a935e2, (q31_t)0x7c58bfe9, (q31_t)0xe1a31b42, (q31_t)0x7c574236, (q31_t)0xe19d00b6, (q31_t)0x7c55c436, (q31_t)0xe196e63c, - (q31_t)0x7c5445e9, (q31_t)0xe190cbd4, (q31_t)0x7c52c74f, (q31_t)0xe18ab180, (q31_t)0x7c514869, (q31_t)0xe184973e, (q31_t)0x7c4fc936, (q31_t)0xe17e7d0f, - (q31_t)0x7c4e49b7, (q31_t)0xe17862f3, (q31_t)0x7c4cc9ea, (q31_t)0xe17248ea, (q31_t)0x7c4b49d2, (q31_t)0xe16c2ef4, (q31_t)0x7c49c96c, (q31_t)0xe1661510, - (q31_t)0x7c4848ba, (q31_t)0xe15ffb3f, (q31_t)0x7c46c7bb, (q31_t)0xe159e182, (q31_t)0x7c45466f, (q31_t)0xe153c7d7, (q31_t)0x7c43c4d7, (q31_t)0xe14dae3f, - (q31_t)0x7c4242f2, (q31_t)0xe14794ba, (q31_t)0x7c40c0c1, (q31_t)0xe1417b48, (q31_t)0x7c3f3e42, (q31_t)0xe13b61e9, (q31_t)0x7c3dbb78, (q31_t)0xe135489d, - (q31_t)0x7c3c3860, (q31_t)0xe12f2f63, (q31_t)0x7c3ab4fc, (q31_t)0xe129163d, (q31_t)0x7c39314b, (q31_t)0xe122fd2a, (q31_t)0x7c37ad4e, (q31_t)0xe11ce42a, - (q31_t)0x7c362904, (q31_t)0xe116cb3d, (q31_t)0x7c34a46d, (q31_t)0xe110b263, (q31_t)0x7c331f8a, (q31_t)0xe10a999c, (q31_t)0x7c319a5a, (q31_t)0xe10480e9, - (q31_t)0x7c3014de, (q31_t)0xe0fe6848, (q31_t)0x7c2e8f15, (q31_t)0xe0f84fbb, (q31_t)0x7c2d08ff, (q31_t)0xe0f23740, (q31_t)0x7c2b829d, (q31_t)0xe0ec1ed9, - (q31_t)0x7c29fbee, (q31_t)0xe0e60685, (q31_t)0x7c2874f3, (q31_t)0xe0dfee44, (q31_t)0x7c26edab, (q31_t)0xe0d9d616, (q31_t)0x7c256616, (q31_t)0xe0d3bdfc, - (q31_t)0x7c23de35, (q31_t)0xe0cda5f5, (q31_t)0x7c225607, (q31_t)0xe0c78e01, (q31_t)0x7c20cd8d, (q31_t)0xe0c17620, (q31_t)0x7c1f44c6, (q31_t)0xe0bb5e53, - (q31_t)0x7c1dbbb3, (q31_t)0xe0b54698, (q31_t)0x7c1c3253, (q31_t)0xe0af2ef2, (q31_t)0x7c1aa8a6, (q31_t)0xe0a9175e, (q31_t)0x7c191ead, (q31_t)0xe0a2ffde, - (q31_t)0x7c179467, (q31_t)0xe09ce871, (q31_t)0x7c1609d5, (q31_t)0xe096d117, (q31_t)0x7c147ef6, (q31_t)0xe090b9d1, (q31_t)0x7c12f3cb, (q31_t)0xe08aa29f, - (q31_t)0x7c116853, (q31_t)0xe0848b7f, (q31_t)0x7c0fdc8f, (q31_t)0xe07e7473, (q31_t)0x7c0e507e, (q31_t)0xe0785d7b, (q31_t)0x7c0cc421, (q31_t)0xe0724696, - (q31_t)0x7c0b3777, (q31_t)0xe06c2fc4, (q31_t)0x7c09aa80, (q31_t)0xe0661906, (q31_t)0x7c081d3d, (q31_t)0xe060025c, (q31_t)0x7c068fae, (q31_t)0xe059ebc5, - (q31_t)0x7c0501d2, (q31_t)0xe053d541, (q31_t)0x7c0373a9, (q31_t)0xe04dbed1, (q31_t)0x7c01e534, (q31_t)0xe047a875, (q31_t)0x7c005673, (q31_t)0xe041922c, - (q31_t)0x7bfec765, (q31_t)0xe03b7bf6, (q31_t)0x7bfd380a, (q31_t)0xe03565d5, (q31_t)0x7bfba863, (q31_t)0xe02f4fc6, (q31_t)0x7bfa1870, (q31_t)0xe02939cc, - (q31_t)0x7bf88830, (q31_t)0xe02323e5, (q31_t)0x7bf6f7a4, (q31_t)0xe01d0e12, (q31_t)0x7bf566cb, (q31_t)0xe016f852, (q31_t)0x7bf3d5a6, (q31_t)0xe010e2a7, - (q31_t)0x7bf24434, (q31_t)0xe00acd0e, (q31_t)0x7bf0b276, (q31_t)0xe004b78a, (q31_t)0x7bef206b, (q31_t)0xdffea219, (q31_t)0x7bed8e14, (q31_t)0xdff88cbc, - (q31_t)0x7bebfb70, (q31_t)0xdff27773, (q31_t)0x7bea6880, (q31_t)0xdfec623e, (q31_t)0x7be8d544, (q31_t)0xdfe64d1c, (q31_t)0x7be741bb, (q31_t)0xdfe0380e, - (q31_t)0x7be5ade6, (q31_t)0xdfda2314, (q31_t)0x7be419c4, (q31_t)0xdfd40e2e, (q31_t)0x7be28556, (q31_t)0xdfcdf95c, (q31_t)0x7be0f09b, (q31_t)0xdfc7e49d, - (q31_t)0x7bdf5b94, (q31_t)0xdfc1cff3, (q31_t)0x7bddc641, (q31_t)0xdfbbbb5c, (q31_t)0x7bdc30a1, (q31_t)0xdfb5a6d9, (q31_t)0x7bda9ab5, (q31_t)0xdfaf926a, - (q31_t)0x7bd9047c, (q31_t)0xdfa97e0f, (q31_t)0x7bd76df7, (q31_t)0xdfa369c8, (q31_t)0x7bd5d726, (q31_t)0xdf9d5595, (q31_t)0x7bd44008, (q31_t)0xdf974176, - (q31_t)0x7bd2a89e, (q31_t)0xdf912d6b, (q31_t)0x7bd110e8, (q31_t)0xdf8b1974, (q31_t)0x7bcf78e5, (q31_t)0xdf850591, (q31_t)0x7bcde095, (q31_t)0xdf7ef1c2, - (q31_t)0x7bcc47fa, (q31_t)0xdf78de07, (q31_t)0x7bcaaf12, (q31_t)0xdf72ca60, (q31_t)0x7bc915dd, (q31_t)0xdf6cb6cd, (q31_t)0x7bc77c5d, (q31_t)0xdf66a34e, - (q31_t)0x7bc5e290, (q31_t)0xdf608fe4, (q31_t)0x7bc44876, (q31_t)0xdf5a7c8d, (q31_t)0x7bc2ae10, (q31_t)0xdf54694b, (q31_t)0x7bc1135e, (q31_t)0xdf4e561c, - (q31_t)0x7bbf7860, (q31_t)0xdf484302, (q31_t)0x7bbddd15, (q31_t)0xdf422ffd, (q31_t)0x7bbc417e, (q31_t)0xdf3c1d0b, (q31_t)0x7bbaa59a, (q31_t)0xdf360a2d, - (q31_t)0x7bb9096b, (q31_t)0xdf2ff764, (q31_t)0x7bb76cef, (q31_t)0xdf29e4af, (q31_t)0x7bb5d026, (q31_t)0xdf23d20e, (q31_t)0x7bb43311, (q31_t)0xdf1dbf82, - (q31_t)0x7bb295b0, (q31_t)0xdf17ad0a, (q31_t)0x7bb0f803, (q31_t)0xdf119aa6, (q31_t)0x7baf5a09, (q31_t)0xdf0b8856, (q31_t)0x7badbbc3, (q31_t)0xdf05761b, - (q31_t)0x7bac1d31, (q31_t)0xdeff63f4, (q31_t)0x7baa7e53, (q31_t)0xdef951e2, (q31_t)0x7ba8df28, (q31_t)0xdef33fe3, (q31_t)0x7ba73fb1, (q31_t)0xdeed2dfa, - (q31_t)0x7ba59fee, (q31_t)0xdee71c24, (q31_t)0x7ba3ffde, (q31_t)0xdee10a63, (q31_t)0x7ba25f82, (q31_t)0xdedaf8b7, (q31_t)0x7ba0beda, (q31_t)0xded4e71f, - (q31_t)0x7b9f1de6, (q31_t)0xdeced59b, (q31_t)0x7b9d7ca5, (q31_t)0xdec8c42c, (q31_t)0x7b9bdb18, (q31_t)0xdec2b2d1, (q31_t)0x7b9a393f, (q31_t)0xdebca18b, - (q31_t)0x7b989719, (q31_t)0xdeb69059, (q31_t)0x7b96f4a8, (q31_t)0xdeb07f3c, (q31_t)0x7b9551ea, (q31_t)0xdeaa6e34, (q31_t)0x7b93aee0, (q31_t)0xdea45d40, - (q31_t)0x7b920b89, (q31_t)0xde9e4c60, (q31_t)0x7b9067e7, (q31_t)0xde983b95, (q31_t)0x7b8ec3f8, (q31_t)0xde922adf, (q31_t)0x7b8d1fbd, (q31_t)0xde8c1a3e, - (q31_t)0x7b8b7b36, (q31_t)0xde8609b1, (q31_t)0x7b89d662, (q31_t)0xde7ff938, (q31_t)0x7b883143, (q31_t)0xde79e8d5, (q31_t)0x7b868bd7, (q31_t)0xde73d886, - (q31_t)0x7b84e61f, (q31_t)0xde6dc84b, (q31_t)0x7b83401b, (q31_t)0xde67b826, (q31_t)0x7b8199ca, (q31_t)0xde61a815, (q31_t)0x7b7ff32e, (q31_t)0xde5b9819, - (q31_t)0x7b7e4c45, (q31_t)0xde558831, (q31_t)0x7b7ca510, (q31_t)0xde4f785f, (q31_t)0x7b7afd8f, (q31_t)0xde4968a1, (q31_t)0x7b7955c2, (q31_t)0xde4358f8, - (q31_t)0x7b77ada8, (q31_t)0xde3d4964, (q31_t)0x7b760542, (q31_t)0xde3739e4, (q31_t)0x7b745c91, (q31_t)0xde312a7a, (q31_t)0x7b72b393, (q31_t)0xde2b1b24, - (q31_t)0x7b710a49, (q31_t)0xde250be3, (q31_t)0x7b6f60b2, (q31_t)0xde1efcb7, (q31_t)0x7b6db6d0, (q31_t)0xde18eda0, (q31_t)0x7b6c0ca2, (q31_t)0xde12de9e, - (q31_t)0x7b6a6227, (q31_t)0xde0ccfb1, (q31_t)0x7b68b760, (q31_t)0xde06c0d9, (q31_t)0x7b670c4d, (q31_t)0xde00b216, (q31_t)0x7b6560ee, (q31_t)0xddfaa367, - (q31_t)0x7b63b543, (q31_t)0xddf494ce, (q31_t)0x7b62094c, (q31_t)0xddee8649, (q31_t)0x7b605d09, (q31_t)0xdde877da, (q31_t)0x7b5eb079, (q31_t)0xdde26980, - (q31_t)0x7b5d039e, (q31_t)0xdddc5b3b, (q31_t)0x7b5b5676, (q31_t)0xddd64d0a, (q31_t)0x7b59a902, (q31_t)0xddd03eef, (q31_t)0x7b57fb42, (q31_t)0xddca30e9, - (q31_t)0x7b564d36, (q31_t)0xddc422f8, (q31_t)0x7b549ede, (q31_t)0xddbe151d, (q31_t)0x7b52f03a, (q31_t)0xddb80756, (q31_t)0x7b51414a, (q31_t)0xddb1f9a4, - (q31_t)0x7b4f920e, (q31_t)0xddabec08, (q31_t)0x7b4de286, (q31_t)0xdda5de81, (q31_t)0x7b4c32b1, (q31_t)0xdd9fd10f, (q31_t)0x7b4a8291, (q31_t)0xdd99c3b2, - (q31_t)0x7b48d225, (q31_t)0xdd93b66a, (q31_t)0x7b47216c, (q31_t)0xdd8da938, (q31_t)0x7b457068, (q31_t)0xdd879c1b, (q31_t)0x7b43bf17, (q31_t)0xdd818f13, - (q31_t)0x7b420d7a, (q31_t)0xdd7b8220, (q31_t)0x7b405b92, (q31_t)0xdd757543, (q31_t)0x7b3ea95d, (q31_t)0xdd6f687b, (q31_t)0x7b3cf6dc, (q31_t)0xdd695bc9, - (q31_t)0x7b3b4410, (q31_t)0xdd634f2b, (q31_t)0x7b3990f7, (q31_t)0xdd5d42a3, (q31_t)0x7b37dd92, (q31_t)0xdd573631, (q31_t)0x7b3629e1, (q31_t)0xdd5129d4, - (q31_t)0x7b3475e5, (q31_t)0xdd4b1d8c, (q31_t)0x7b32c19c, (q31_t)0xdd451159, (q31_t)0x7b310d07, (q31_t)0xdd3f053c, (q31_t)0x7b2f5826, (q31_t)0xdd38f935, - (q31_t)0x7b2da2fa, (q31_t)0xdd32ed43, (q31_t)0x7b2bed81, (q31_t)0xdd2ce166, (q31_t)0x7b2a37bc, (q31_t)0xdd26d59f, (q31_t)0x7b2881ac, (q31_t)0xdd20c9ed, - (q31_t)0x7b26cb4f, (q31_t)0xdd1abe51, (q31_t)0x7b2514a6, (q31_t)0xdd14b2ca, (q31_t)0x7b235db2, (q31_t)0xdd0ea759, (q31_t)0x7b21a671, (q31_t)0xdd089bfe, - (q31_t)0x7b1feee5, (q31_t)0xdd0290b8, (q31_t)0x7b1e370d, (q31_t)0xdcfc8588, (q31_t)0x7b1c7ee8, (q31_t)0xdcf67a6d, (q31_t)0x7b1ac678, (q31_t)0xdcf06f68, - (q31_t)0x7b190dbc, (q31_t)0xdcea6478, (q31_t)0x7b1754b3, (q31_t)0xdce4599e, (q31_t)0x7b159b5f, (q31_t)0xdcde4eda, (q31_t)0x7b13e1bf, (q31_t)0xdcd8442b, - (q31_t)0x7b1227d3, (q31_t)0xdcd23993, (q31_t)0x7b106d9b, (q31_t)0xdccc2f0f, (q31_t)0x7b0eb318, (q31_t)0xdcc624a2, (q31_t)0x7b0cf848, (q31_t)0xdcc01a4a, - (q31_t)0x7b0b3d2c, (q31_t)0xdcba1008, (q31_t)0x7b0981c5, (q31_t)0xdcb405dc, (q31_t)0x7b07c612, (q31_t)0xdcadfbc5, (q31_t)0x7b060a12, (q31_t)0xdca7f1c5, - (q31_t)0x7b044dc7, (q31_t)0xdca1e7da, (q31_t)0x7b029130, (q31_t)0xdc9bde05, (q31_t)0x7b00d44d, (q31_t)0xdc95d446, (q31_t)0x7aff171e, (q31_t)0xdc8fca9c, - (q31_t)0x7afd59a4, (q31_t)0xdc89c109, (q31_t)0x7afb9bdd, (q31_t)0xdc83b78b, (q31_t)0x7af9ddcb, (q31_t)0xdc7dae23, (q31_t)0x7af81f6c, (q31_t)0xdc77a4d2, - (q31_t)0x7af660c2, (q31_t)0xdc719b96, (q31_t)0x7af4a1cc, (q31_t)0xdc6b9270, (q31_t)0x7af2e28b, (q31_t)0xdc658960, (q31_t)0x7af122fd, (q31_t)0xdc5f8066, - (q31_t)0x7aef6323, (q31_t)0xdc597781, (q31_t)0x7aeda2fe, (q31_t)0xdc536eb3, (q31_t)0x7aebe28d, (q31_t)0xdc4d65fb, (q31_t)0x7aea21d0, (q31_t)0xdc475d59, - (q31_t)0x7ae860c7, (q31_t)0xdc4154cd, (q31_t)0x7ae69f73, (q31_t)0xdc3b4c57, (q31_t)0x7ae4ddd2, (q31_t)0xdc3543f7, (q31_t)0x7ae31be6, (q31_t)0xdc2f3bad, - (q31_t)0x7ae159ae, (q31_t)0xdc293379, (q31_t)0x7adf972a, (q31_t)0xdc232b5c, (q31_t)0x7addd45b, (q31_t)0xdc1d2354, (q31_t)0x7adc113f, (q31_t)0xdc171b63, - (q31_t)0x7ada4dd8, (q31_t)0xdc111388, (q31_t)0x7ad88a25, (q31_t)0xdc0b0bc2, (q31_t)0x7ad6c626, (q31_t)0xdc050414, (q31_t)0x7ad501dc, (q31_t)0xdbfefc7b, - (q31_t)0x7ad33d45, (q31_t)0xdbf8f4f8, (q31_t)0x7ad17863, (q31_t)0xdbf2ed8c, (q31_t)0x7acfb336, (q31_t)0xdbece636, (q31_t)0x7acdedbc, (q31_t)0xdbe6def6, - (q31_t)0x7acc27f7, (q31_t)0xdbe0d7cd, (q31_t)0x7aca61e6, (q31_t)0xdbdad0b9, (q31_t)0x7ac89b89, (q31_t)0xdbd4c9bc, (q31_t)0x7ac6d4e0, (q31_t)0xdbcec2d6, - (q31_t)0x7ac50dec, (q31_t)0xdbc8bc06, (q31_t)0x7ac346ac, (q31_t)0xdbc2b54c, (q31_t)0x7ac17f20, (q31_t)0xdbbcaea8, (q31_t)0x7abfb749, (q31_t)0xdbb6a81b, - (q31_t)0x7abdef25, (q31_t)0xdbb0a1a4, (q31_t)0x7abc26b7, (q31_t)0xdbaa9b43, (q31_t)0x7aba5dfc, (q31_t)0xdba494f9, (q31_t)0x7ab894f6, (q31_t)0xdb9e8ec6, - (q31_t)0x7ab6cba4, (q31_t)0xdb9888a8, (q31_t)0x7ab50206, (q31_t)0xdb9282a2, (q31_t)0x7ab3381d, (q31_t)0xdb8c7cb1, (q31_t)0x7ab16de7, (q31_t)0xdb8676d8, - (q31_t)0x7aafa367, (q31_t)0xdb807114, (q31_t)0x7aadd89a, (q31_t)0xdb7a6b68, (q31_t)0x7aac0d82, (q31_t)0xdb7465d1, (q31_t)0x7aaa421e, (q31_t)0xdb6e6052, - (q31_t)0x7aa8766f, (q31_t)0xdb685ae9, (q31_t)0x7aa6aa74, (q31_t)0xdb625596, (q31_t)0x7aa4de2d, (q31_t)0xdb5c505a, (q31_t)0x7aa3119a, (q31_t)0xdb564b35, - (q31_t)0x7aa144bc, (q31_t)0xdb504626, (q31_t)0x7a9f7793, (q31_t)0xdb4a412e, (q31_t)0x7a9daa1d, (q31_t)0xdb443c4c, (q31_t)0x7a9bdc5c, (q31_t)0xdb3e3781, - (q31_t)0x7a9a0e50, (q31_t)0xdb3832cd, (q31_t)0x7a983ff7, (q31_t)0xdb322e30, (q31_t)0x7a967153, (q31_t)0xdb2c29a9, (q31_t)0x7a94a264, (q31_t)0xdb262539, - (q31_t)0x7a92d329, (q31_t)0xdb2020e0, (q31_t)0x7a9103a2, (q31_t)0xdb1a1c9d, (q31_t)0x7a8f33d0, (q31_t)0xdb141871, (q31_t)0x7a8d63b2, (q31_t)0xdb0e145c, - (q31_t)0x7a8b9348, (q31_t)0xdb08105e, (q31_t)0x7a89c293, (q31_t)0xdb020c77, (q31_t)0x7a87f192, (q31_t)0xdafc08a6, (q31_t)0x7a862046, (q31_t)0xdaf604ec, - (q31_t)0x7a844eae, (q31_t)0xdaf00149, (q31_t)0x7a827ccb, (q31_t)0xdae9fdbd, (q31_t)0x7a80aa9c, (q31_t)0xdae3fa48, (q31_t)0x7a7ed821, (q31_t)0xdaddf6ea, - (q31_t)0x7a7d055b, (q31_t)0xdad7f3a2, (q31_t)0x7a7b3249, (q31_t)0xdad1f072, (q31_t)0x7a795eec, (q31_t)0xdacbed58, (q31_t)0x7a778b43, (q31_t)0xdac5ea56, - (q31_t)0x7a75b74f, (q31_t)0xdabfe76a, (q31_t)0x7a73e30f, (q31_t)0xdab9e495, (q31_t)0x7a720e84, (q31_t)0xdab3e1d8, (q31_t)0x7a7039ad, (q31_t)0xdaaddf31, - (q31_t)0x7a6e648a, (q31_t)0xdaa7dca1, (q31_t)0x7a6c8f1c, (q31_t)0xdaa1da29, (q31_t)0x7a6ab963, (q31_t)0xda9bd7c7, (q31_t)0x7a68e35e, (q31_t)0xda95d57d, - (q31_t)0x7a670d0d, (q31_t)0xda8fd349, (q31_t)0x7a653671, (q31_t)0xda89d12d, (q31_t)0x7a635f8a, (q31_t)0xda83cf28, (q31_t)0x7a618857, (q31_t)0xda7dcd3a, - (q31_t)0x7a5fb0d8, (q31_t)0xda77cb63, (q31_t)0x7a5dd90e, (q31_t)0xda71c9a3, (q31_t)0x7a5c00f9, (q31_t)0xda6bc7fa, (q31_t)0x7a5a2898, (q31_t)0xda65c669, - (q31_t)0x7a584feb, (q31_t)0xda5fc4ef, (q31_t)0x7a5676f3, (q31_t)0xda59c38c, (q31_t)0x7a549db0, (q31_t)0xda53c240, (q31_t)0x7a52c421, (q31_t)0xda4dc10b, - (q31_t)0x7a50ea47, (q31_t)0xda47bfee, (q31_t)0x7a4f1021, (q31_t)0xda41bee8, (q31_t)0x7a4d35b0, (q31_t)0xda3bbdf9, (q31_t)0x7a4b5af3, (q31_t)0xda35bd22, - (q31_t)0x7a497feb, (q31_t)0xda2fbc61, (q31_t)0x7a47a498, (q31_t)0xda29bbb9, (q31_t)0x7a45c8f9, (q31_t)0xda23bb27, (q31_t)0x7a43ed0e, (q31_t)0xda1dbaad, - (q31_t)0x7a4210d8, (q31_t)0xda17ba4a, (q31_t)0x7a403457, (q31_t)0xda11b9ff, (q31_t)0x7a3e578b, (q31_t)0xda0bb9cb, (q31_t)0x7a3c7a73, (q31_t)0xda05b9ae, - (q31_t)0x7a3a9d0f, (q31_t)0xd9ffb9a9, (q31_t)0x7a38bf60, (q31_t)0xd9f9b9bb, (q31_t)0x7a36e166, (q31_t)0xd9f3b9e5, (q31_t)0x7a350321, (q31_t)0xd9edba26, - (q31_t)0x7a332490, (q31_t)0xd9e7ba7f, (q31_t)0x7a3145b3, (q31_t)0xd9e1baef, (q31_t)0x7a2f668c, (q31_t)0xd9dbbb77, (q31_t)0x7a2d8719, (q31_t)0xd9d5bc16, - (q31_t)0x7a2ba75a, (q31_t)0xd9cfbccd, (q31_t)0x7a29c750, (q31_t)0xd9c9bd9b, (q31_t)0x7a27e6fb, (q31_t)0xd9c3be81, (q31_t)0x7a26065b, (q31_t)0xd9bdbf7e, - (q31_t)0x7a24256f, (q31_t)0xd9b7c094, (q31_t)0x7a224437, (q31_t)0xd9b1c1c0, (q31_t)0x7a2062b5, (q31_t)0xd9abc305, (q31_t)0x7a1e80e7, (q31_t)0xd9a5c461, - (q31_t)0x7a1c9ece, (q31_t)0xd99fc5d4, (q31_t)0x7a1abc69, (q31_t)0xd999c75f, (q31_t)0x7a18d9b9, (q31_t)0xd993c902, (q31_t)0x7a16f6be, (q31_t)0xd98dcabd, - (q31_t)0x7a151378, (q31_t)0xd987cc90, (q31_t)0x7a132fe6, (q31_t)0xd981ce7a, (q31_t)0x7a114c09, (q31_t)0xd97bd07c, (q31_t)0x7a0f67e0, (q31_t)0xd975d295, - (q31_t)0x7a0d836d, (q31_t)0xd96fd4c7, (q31_t)0x7a0b9eae, (q31_t)0xd969d710, (q31_t)0x7a09b9a4, (q31_t)0xd963d971, (q31_t)0x7a07d44e, (q31_t)0xd95ddbea, - (q31_t)0x7a05eead, (q31_t)0xd957de7a, (q31_t)0x7a0408c1, (q31_t)0xd951e123, (q31_t)0x7a02228a, (q31_t)0xd94be3e3, (q31_t)0x7a003c07, (q31_t)0xd945e6bb, - (q31_t)0x79fe5539, (q31_t)0xd93fe9ab, (q31_t)0x79fc6e20, (q31_t)0xd939ecb3, (q31_t)0x79fa86bc, (q31_t)0xd933efd3, (q31_t)0x79f89f0c, (q31_t)0xd92df30b, - (q31_t)0x79f6b711, (q31_t)0xd927f65b, (q31_t)0x79f4cecb, (q31_t)0xd921f9c3, (q31_t)0x79f2e63a, (q31_t)0xd91bfd43, (q31_t)0x79f0fd5d, (q31_t)0xd91600da, - (q31_t)0x79ef1436, (q31_t)0xd910048a, (q31_t)0x79ed2ac3, (q31_t)0xd90a0852, (q31_t)0x79eb4105, (q31_t)0xd9040c32, (q31_t)0x79e956fb, (q31_t)0xd8fe1029, - (q31_t)0x79e76ca7, (q31_t)0xd8f81439, (q31_t)0x79e58207, (q31_t)0xd8f21861, (q31_t)0x79e3971c, (q31_t)0xd8ec1ca1, (q31_t)0x79e1abe6, (q31_t)0xd8e620fa, - (q31_t)0x79dfc064, (q31_t)0xd8e0256a, (q31_t)0x79ddd498, (q31_t)0xd8da29f2, (q31_t)0x79dbe880, (q31_t)0xd8d42e93, (q31_t)0x79d9fc1d, (q31_t)0xd8ce334c, - (q31_t)0x79d80f6f, (q31_t)0xd8c8381d, (q31_t)0x79d62276, (q31_t)0xd8c23d06, (q31_t)0x79d43532, (q31_t)0xd8bc4207, (q31_t)0x79d247a2, (q31_t)0xd8b64720, - (q31_t)0x79d059c8, (q31_t)0xd8b04c52, (q31_t)0x79ce6ba2, (q31_t)0xd8aa519c, (q31_t)0x79cc7d31, (q31_t)0xd8a456ff, (q31_t)0x79ca8e75, (q31_t)0xd89e5c79, - (q31_t)0x79c89f6e, (q31_t)0xd898620c, (q31_t)0x79c6b01b, (q31_t)0xd89267b7, (q31_t)0x79c4c07e, (q31_t)0xd88c6d7b, (q31_t)0x79c2d095, (q31_t)0xd8867356, - (q31_t)0x79c0e062, (q31_t)0xd880794b, (q31_t)0x79beefe3, (q31_t)0xd87a7f57, (q31_t)0x79bcff19, (q31_t)0xd874857c, (q31_t)0x79bb0e04, (q31_t)0xd86e8bb9, - (q31_t)0x79b91ca4, (q31_t)0xd868920f, (q31_t)0x79b72af9, (q31_t)0xd862987d, (q31_t)0x79b53903, (q31_t)0xd85c9f04, (q31_t)0x79b346c2, (q31_t)0xd856a5a3, - (q31_t)0x79b15435, (q31_t)0xd850ac5a, (q31_t)0x79af615e, (q31_t)0xd84ab32a, (q31_t)0x79ad6e3c, (q31_t)0xd844ba13, (q31_t)0x79ab7ace, (q31_t)0xd83ec114, - (q31_t)0x79a98715, (q31_t)0xd838c82d, (q31_t)0x79a79312, (q31_t)0xd832cf5f, (q31_t)0x79a59ec3, (q31_t)0xd82cd6aa, (q31_t)0x79a3aa29, (q31_t)0xd826de0d, - (q31_t)0x79a1b545, (q31_t)0xd820e589, (q31_t)0x799fc015, (q31_t)0xd81aed1d, (q31_t)0x799dca9a, (q31_t)0xd814f4ca, (q31_t)0x799bd4d4, (q31_t)0xd80efc8f, - (q31_t)0x7999dec4, (q31_t)0xd809046e, (q31_t)0x7997e868, (q31_t)0xd8030c64, (q31_t)0x7995f1c1, (q31_t)0xd7fd1474, (q31_t)0x7993facf, (q31_t)0xd7f71c9c, - (q31_t)0x79920392, (q31_t)0xd7f124dd, (q31_t)0x79900c0a, (q31_t)0xd7eb2d37, (q31_t)0x798e1438, (q31_t)0xd7e535a9, (q31_t)0x798c1c1a, (q31_t)0xd7df3e34, - (q31_t)0x798a23b1, (q31_t)0xd7d946d8, (q31_t)0x79882afd, (q31_t)0xd7d34f94, (q31_t)0x798631ff, (q31_t)0xd7cd586a, (q31_t)0x798438b5, (q31_t)0xd7c76158, - (q31_t)0x79823f20, (q31_t)0xd7c16a5f, (q31_t)0x79804541, (q31_t)0xd7bb737f, (q31_t)0x797e4b16, (q31_t)0xd7b57cb7, (q31_t)0x797c50a1, (q31_t)0xd7af8609, - (q31_t)0x797a55e0, (q31_t)0xd7a98f73, (q31_t)0x79785ad5, (q31_t)0xd7a398f6, (q31_t)0x79765f7f, (q31_t)0xd79da293, (q31_t)0x797463de, (q31_t)0xd797ac48, - (q31_t)0x797267f2, (q31_t)0xd791b616, (q31_t)0x79706bbb, (q31_t)0xd78bbffc, (q31_t)0x796e6f39, (q31_t)0xd785c9fc, (q31_t)0x796c726c, (q31_t)0xd77fd415, - (q31_t)0x796a7554, (q31_t)0xd779de47, (q31_t)0x796877f1, (q31_t)0xd773e892, (q31_t)0x79667a44, (q31_t)0xd76df2f6, (q31_t)0x79647c4c, (q31_t)0xd767fd72, - (q31_t)0x79627e08, (q31_t)0xd7620808, (q31_t)0x79607f7a, (q31_t)0xd75c12b7, (q31_t)0x795e80a1, (q31_t)0xd7561d7f, (q31_t)0x795c817d, (q31_t)0xd7502860, - (q31_t)0x795a820e, (q31_t)0xd74a335b, (q31_t)0x79588255, (q31_t)0xd7443e6e, (q31_t)0x79568250, (q31_t)0xd73e499a, (q31_t)0x79548201, (q31_t)0xd73854e0, - (q31_t)0x79528167, (q31_t)0xd732603f, (q31_t)0x79508082, (q31_t)0xd72c6bb6, (q31_t)0x794e7f52, (q31_t)0xd7267748, (q31_t)0x794c7dd7, (q31_t)0xd72082f2, - (q31_t)0x794a7c12, (q31_t)0xd71a8eb5, (q31_t)0x79487a01, (q31_t)0xd7149a92, (q31_t)0x794677a6, (q31_t)0xd70ea688, (q31_t)0x79447500, (q31_t)0xd708b297, - (q31_t)0x79427210, (q31_t)0xd702bec0, (q31_t)0x79406ed4, (q31_t)0xd6fccb01, (q31_t)0x793e6b4e, (q31_t)0xd6f6d75d, (q31_t)0x793c677d, (q31_t)0xd6f0e3d1, - (q31_t)0x793a6361, (q31_t)0xd6eaf05f, (q31_t)0x79385efa, (q31_t)0xd6e4fd06, (q31_t)0x79365a49, (q31_t)0xd6df09c6, (q31_t)0x7934554d, (q31_t)0xd6d916a0, - (q31_t)0x79325006, (q31_t)0xd6d32393, (q31_t)0x79304a74, (q31_t)0xd6cd30a0, (q31_t)0x792e4497, (q31_t)0xd6c73dc6, (q31_t)0x792c3e70, (q31_t)0xd6c14b05, - (q31_t)0x792a37fe, (q31_t)0xd6bb585e, (q31_t)0x79283141, (q31_t)0xd6b565d0, (q31_t)0x79262a3a, (q31_t)0xd6af735c, (q31_t)0x792422e8, (q31_t)0xd6a98101, - (q31_t)0x79221b4b, (q31_t)0xd6a38ec0, (q31_t)0x79201363, (q31_t)0xd69d9c98, (q31_t)0x791e0b31, (q31_t)0xd697aa8a, (q31_t)0x791c02b4, (q31_t)0xd691b895, - (q31_t)0x7919f9ec, (q31_t)0xd68bc6ba, (q31_t)0x7917f0d9, (q31_t)0xd685d4f9, (q31_t)0x7915e77c, (q31_t)0xd67fe351, (q31_t)0x7913ddd4, (q31_t)0xd679f1c2, - (q31_t)0x7911d3e2, (q31_t)0xd674004e, (q31_t)0x790fc9a4, (q31_t)0xd66e0ef2, (q31_t)0x790dbf1d, (q31_t)0xd6681db1, (q31_t)0x790bb44a, (q31_t)0xd6622c89, - (q31_t)0x7909a92d, (q31_t)0xd65c3b7b, (q31_t)0x79079dc5, (q31_t)0xd6564a87, (q31_t)0x79059212, (q31_t)0xd65059ac, (q31_t)0x79038615, (q31_t)0xd64a68eb, - (q31_t)0x790179cd, (q31_t)0xd6447844, (q31_t)0x78ff6d3b, (q31_t)0xd63e87b6, (q31_t)0x78fd605d, (q31_t)0xd6389742, (q31_t)0x78fb5336, (q31_t)0xd632a6e8, - (q31_t)0x78f945c3, (q31_t)0xd62cb6a8, (q31_t)0x78f73806, (q31_t)0xd626c681, (q31_t)0x78f529fe, (q31_t)0xd620d675, (q31_t)0x78f31bac, (q31_t)0xd61ae682, - (q31_t)0x78f10d0f, (q31_t)0xd614f6a9, (q31_t)0x78eefe28, (q31_t)0xd60f06ea, (q31_t)0x78eceef6, (q31_t)0xd6091745, (q31_t)0x78eadf79, (q31_t)0xd60327b9, - (q31_t)0x78e8cfb2, (q31_t)0xd5fd3848, (q31_t)0x78e6bfa0, (q31_t)0xd5f748f0, (q31_t)0x78e4af44, (q31_t)0xd5f159b3, (q31_t)0x78e29e9d, (q31_t)0xd5eb6a8f, - (q31_t)0x78e08dab, (q31_t)0xd5e57b85, (q31_t)0x78de7c6f, (q31_t)0xd5df8c96, (q31_t)0x78dc6ae8, (q31_t)0xd5d99dc0, (q31_t)0x78da5917, (q31_t)0xd5d3af04, - (q31_t)0x78d846fb, (q31_t)0xd5cdc062, (q31_t)0x78d63495, (q31_t)0xd5c7d1db, (q31_t)0x78d421e4, (q31_t)0xd5c1e36d, (q31_t)0x78d20ee9, (q31_t)0xd5bbf519, - (q31_t)0x78cffba3, (q31_t)0xd5b606e0, (q31_t)0x78cde812, (q31_t)0xd5b018c0, (q31_t)0x78cbd437, (q31_t)0xd5aa2abb, (q31_t)0x78c9c012, (q31_t)0xd5a43cd0, - (q31_t)0x78c7aba2, (q31_t)0xd59e4eff, (q31_t)0x78c596e7, (q31_t)0xd5986148, (q31_t)0x78c381e2, (q31_t)0xd59273ab, (q31_t)0x78c16c93, (q31_t)0xd58c8628, - (q31_t)0x78bf56f9, (q31_t)0xd58698c0, (q31_t)0x78bd4114, (q31_t)0xd580ab72, (q31_t)0x78bb2ae5, (q31_t)0xd57abe3d, (q31_t)0x78b9146c, (q31_t)0xd574d124, - (q31_t)0x78b6fda8, (q31_t)0xd56ee424, (q31_t)0x78b4e69a, (q31_t)0xd568f73f, (q31_t)0x78b2cf41, (q31_t)0xd5630a74, (q31_t)0x78b0b79e, (q31_t)0xd55d1dc3, - (q31_t)0x78ae9fb0, (q31_t)0xd557312d, (q31_t)0x78ac8778, (q31_t)0xd55144b0, (q31_t)0x78aa6ef5, (q31_t)0xd54b584f, (q31_t)0x78a85628, (q31_t)0xd5456c07, - (q31_t)0x78a63d11, (q31_t)0xd53f7fda, (q31_t)0x78a423af, (q31_t)0xd53993c7, (q31_t)0x78a20a03, (q31_t)0xd533a7cf, (q31_t)0x789ff00c, (q31_t)0xd52dbbf1, - (q31_t)0x789dd5cb, (q31_t)0xd527d02e, (q31_t)0x789bbb3f, (q31_t)0xd521e484, (q31_t)0x7899a06a, (q31_t)0xd51bf8f6, (q31_t)0x78978549, (q31_t)0xd5160d82, - (q31_t)0x789569df, (q31_t)0xd5102228, (q31_t)0x78934e2a, (q31_t)0xd50a36e9, (q31_t)0x7891322a, (q31_t)0xd5044bc4, (q31_t)0x788f15e0, (q31_t)0xd4fe60ba, - (q31_t)0x788cf94c, (q31_t)0xd4f875ca, (q31_t)0x788adc6e, (q31_t)0xd4f28af5, (q31_t)0x7888bf45, (q31_t)0xd4eca03a, (q31_t)0x7886a1d1, (q31_t)0xd4e6b59a, - (q31_t)0x78848414, (q31_t)0xd4e0cb15, (q31_t)0x7882660c, (q31_t)0xd4dae0aa, (q31_t)0x788047ba, (q31_t)0xd4d4f65a, (q31_t)0x787e291d, (q31_t)0xd4cf0c24, - (q31_t)0x787c0a36, (q31_t)0xd4c92209, (q31_t)0x7879eb05, (q31_t)0xd4c33809, (q31_t)0x7877cb89, (q31_t)0xd4bd4e23, (q31_t)0x7875abc3, (q31_t)0xd4b76458, - (q31_t)0x78738bb3, (q31_t)0xd4b17aa8, (q31_t)0x78716b59, (q31_t)0xd4ab9112, (q31_t)0x786f4ab4, (q31_t)0xd4a5a798, (q31_t)0x786d29c5, (q31_t)0xd49fbe37, - (q31_t)0x786b088c, (q31_t)0xd499d4f2, (q31_t)0x7868e708, (q31_t)0xd493ebc8, (q31_t)0x7866c53a, (q31_t)0xd48e02b8, (q31_t)0x7864a322, (q31_t)0xd48819c3, - (q31_t)0x786280bf, (q31_t)0xd48230e9, (q31_t)0x78605e13, (q31_t)0xd47c4829, (q31_t)0x785e3b1c, (q31_t)0xd4765f85, (q31_t)0x785c17db, (q31_t)0xd47076fb, - (q31_t)0x7859f44f, (q31_t)0xd46a8e8d, (q31_t)0x7857d079, (q31_t)0xd464a639, (q31_t)0x7855ac5a, (q31_t)0xd45ebe00, (q31_t)0x785387ef, (q31_t)0xd458d5e2, - (q31_t)0x7851633b, (q31_t)0xd452eddf, (q31_t)0x784f3e3c, (q31_t)0xd44d05f6, (q31_t)0x784d18f4, (q31_t)0xd4471e29, (q31_t)0x784af361, (q31_t)0xd4413677, - (q31_t)0x7848cd83, (q31_t)0xd43b4ee0, (q31_t)0x7846a75c, (q31_t)0xd4356763, (q31_t)0x784480ea, (q31_t)0xd42f8002, (q31_t)0x78425a2f, (q31_t)0xd42998bc, - (q31_t)0x78403329, (q31_t)0xd423b191, (q31_t)0x783e0bd9, (q31_t)0xd41dca81, (q31_t)0x783be43e, (q31_t)0xd417e38c, (q31_t)0x7839bc5a, (q31_t)0xd411fcb2, - (q31_t)0x7837942b, (q31_t)0xd40c15f3, (q31_t)0x78356bb2, (q31_t)0xd4062f4f, (q31_t)0x783342ef, (q31_t)0xd40048c6, (q31_t)0x783119e2, (q31_t)0xd3fa6259, - (q31_t)0x782ef08b, (q31_t)0xd3f47c06, (q31_t)0x782cc6ea, (q31_t)0xd3ee95cf, (q31_t)0x782a9cfe, (q31_t)0xd3e8afb3, (q31_t)0x782872c8, (q31_t)0xd3e2c9b2, - (q31_t)0x78264849, (q31_t)0xd3dce3cd, (q31_t)0x78241d7f, (q31_t)0xd3d6fe03, (q31_t)0x7821f26b, (q31_t)0xd3d11853, (q31_t)0x781fc70d, (q31_t)0xd3cb32c0, - (q31_t)0x781d9b65, (q31_t)0xd3c54d47, (q31_t)0x781b6f72, (q31_t)0xd3bf67ea, (q31_t)0x78194336, (q31_t)0xd3b982a8, (q31_t)0x781716b0, (q31_t)0xd3b39d81, - (q31_t)0x7814e9df, (q31_t)0xd3adb876, (q31_t)0x7812bcc4, (q31_t)0xd3a7d385, (q31_t)0x78108f60, (q31_t)0xd3a1eeb1, (q31_t)0x780e61b1, (q31_t)0xd39c09f7, - (q31_t)0x780c33b8, (q31_t)0xd396255a, (q31_t)0x780a0575, (q31_t)0xd39040d7, (q31_t)0x7807d6e9, (q31_t)0xd38a5c70, (q31_t)0x7805a812, (q31_t)0xd3847824, - (q31_t)0x780378f1, (q31_t)0xd37e93f4, (q31_t)0x78014986, (q31_t)0xd378afdf, (q31_t)0x77ff19d1, (q31_t)0xd372cbe6, (q31_t)0x77fce9d2, (q31_t)0xd36ce808, - (q31_t)0x77fab989, (q31_t)0xd3670446, (q31_t)0x77f888f6, (q31_t)0xd361209f, (q31_t)0x77f65819, (q31_t)0xd35b3d13, (q31_t)0x77f426f2, (q31_t)0xd35559a4, - (q31_t)0x77f1f581, (q31_t)0xd34f764f, (q31_t)0x77efc3c5, (q31_t)0xd3499317, (q31_t)0x77ed91c0, (q31_t)0xd343affa, (q31_t)0x77eb5f71, (q31_t)0xd33dccf8, - (q31_t)0x77e92cd9, (q31_t)0xd337ea12, (q31_t)0x77e6f9f6, (q31_t)0xd3320748, (q31_t)0x77e4c6c9, (q31_t)0xd32c2499, (q31_t)0x77e29352, (q31_t)0xd3264206, - (q31_t)0x77e05f91, (q31_t)0xd3205f8f, (q31_t)0x77de2b86, (q31_t)0xd31a7d33, (q31_t)0x77dbf732, (q31_t)0xd3149af3, (q31_t)0x77d9c293, (q31_t)0xd30eb8cf, - (q31_t)0x77d78daa, (q31_t)0xd308d6c7, (q31_t)0x77d55878, (q31_t)0xd302f4da, (q31_t)0x77d322fc, (q31_t)0xd2fd1309, (q31_t)0x77d0ed35, (q31_t)0xd2f73154, - (q31_t)0x77ceb725, (q31_t)0xd2f14fba, (q31_t)0x77cc80cb, (q31_t)0xd2eb6e3c, (q31_t)0x77ca4a27, (q31_t)0xd2e58cdb, (q31_t)0x77c81339, (q31_t)0xd2dfab95, - (q31_t)0x77c5dc01, (q31_t)0xd2d9ca6a, (q31_t)0x77c3a47f, (q31_t)0xd2d3e95c, (q31_t)0x77c16cb4, (q31_t)0xd2ce0869, (q31_t)0x77bf349f, (q31_t)0xd2c82793, - (q31_t)0x77bcfc3f, (q31_t)0xd2c246d8, (q31_t)0x77bac396, (q31_t)0xd2bc6639, (q31_t)0x77b88aa3, (q31_t)0xd2b685b6, (q31_t)0x77b65166, (q31_t)0xd2b0a54f, - (q31_t)0x77b417df, (q31_t)0xd2aac504, (q31_t)0x77b1de0f, (q31_t)0xd2a4e4d5, (q31_t)0x77afa3f5, (q31_t)0xd29f04c2, (q31_t)0x77ad6990, (q31_t)0xd29924cb, - (q31_t)0x77ab2ee2, (q31_t)0xd29344f0, (q31_t)0x77a8f3ea, (q31_t)0xd28d6531, (q31_t)0x77a6b8a9, (q31_t)0xd287858e, (q31_t)0x77a47d1d, (q31_t)0xd281a607, - (q31_t)0x77a24148, (q31_t)0xd27bc69c, (q31_t)0x77a00529, (q31_t)0xd275e74d, (q31_t)0x779dc8c0, (q31_t)0xd270081b, (q31_t)0x779b8c0e, (q31_t)0xd26a2904, - (q31_t)0x77994f11, (q31_t)0xd2644a0a, (q31_t)0x779711cb, (q31_t)0xd25e6b2b, (q31_t)0x7794d43b, (q31_t)0xd2588c69, (q31_t)0x77929661, (q31_t)0xd252adc3, - (q31_t)0x7790583e, (q31_t)0xd24ccf39, (q31_t)0x778e19d0, (q31_t)0xd246f0cb, (q31_t)0x778bdb19, (q31_t)0xd241127a, (q31_t)0x77899c19, (q31_t)0xd23b3444, - (q31_t)0x77875cce, (q31_t)0xd235562b, (q31_t)0x77851d3a, (q31_t)0xd22f782f, (q31_t)0x7782dd5c, (q31_t)0xd2299a4e, (q31_t)0x77809d35, (q31_t)0xd223bc8a, - (q31_t)0x777e5cc3, (q31_t)0xd21ddee2, (q31_t)0x777c1c08, (q31_t)0xd2180156, (q31_t)0x7779db03, (q31_t)0xd21223e7, (q31_t)0x777799b5, (q31_t)0xd20c4694, - (q31_t)0x7775581d, (q31_t)0xd206695d, (q31_t)0x7773163b, (q31_t)0xd2008c43, (q31_t)0x7770d40f, (q31_t)0xd1faaf45, (q31_t)0x776e919a, (q31_t)0xd1f4d263, - (q31_t)0x776c4edb, (q31_t)0xd1eef59e, (q31_t)0x776a0bd3, (q31_t)0xd1e918f5, (q31_t)0x7767c880, (q31_t)0xd1e33c69, (q31_t)0x776584e5, (q31_t)0xd1dd5ff9, - (q31_t)0x776340ff, (q31_t)0xd1d783a6, (q31_t)0x7760fcd0, (q31_t)0xd1d1a76f, (q31_t)0x775eb857, (q31_t)0xd1cbcb54, (q31_t)0x775c7395, (q31_t)0xd1c5ef56, - (q31_t)0x775a2e89, (q31_t)0xd1c01375, (q31_t)0x7757e933, (q31_t)0xd1ba37b0, (q31_t)0x7755a394, (q31_t)0xd1b45c08, (q31_t)0x77535dab, (q31_t)0xd1ae807c, - (q31_t)0x77511778, (q31_t)0xd1a8a50d, (q31_t)0x774ed0fc, (q31_t)0xd1a2c9ba, (q31_t)0x774c8a36, (q31_t)0xd19cee84, (q31_t)0x774a4327, (q31_t)0xd197136b, - (q31_t)0x7747fbce, (q31_t)0xd191386e, (q31_t)0x7745b42c, (q31_t)0xd18b5d8e, (q31_t)0x77436c40, (q31_t)0xd18582ca, (q31_t)0x7741240a, (q31_t)0xd17fa823, - (q31_t)0x773edb8b, (q31_t)0xd179cd99, (q31_t)0x773c92c2, (q31_t)0xd173f32c, (q31_t)0x773a49b0, (q31_t)0xd16e18db, (q31_t)0x77380054, (q31_t)0xd1683ea7, - (q31_t)0x7735b6af, (q31_t)0xd1626490, (q31_t)0x77336cc0, (q31_t)0xd15c8a95, (q31_t)0x77312287, (q31_t)0xd156b0b7, (q31_t)0x772ed805, (q31_t)0xd150d6f6, - (q31_t)0x772c8d3a, (q31_t)0xd14afd52, (q31_t)0x772a4225, (q31_t)0xd14523cb, (q31_t)0x7727f6c6, (q31_t)0xd13f4a60, (q31_t)0x7725ab1f, (q31_t)0xd1397113, - (q31_t)0x77235f2d, (q31_t)0xd13397e2, (q31_t)0x772112f2, (q31_t)0xd12dbece, (q31_t)0x771ec66e, (q31_t)0xd127e5d7, (q31_t)0x771c79a0, (q31_t)0xd1220cfc, - (q31_t)0x771a2c88, (q31_t)0xd11c343f, (q31_t)0x7717df27, (q31_t)0xd1165b9f, (q31_t)0x7715917d, (q31_t)0xd110831b, (q31_t)0x77134389, (q31_t)0xd10aaab5, - (q31_t)0x7710f54c, (q31_t)0xd104d26b, (q31_t)0x770ea6c5, (q31_t)0xd0fefa3f, (q31_t)0x770c57f5, (q31_t)0xd0f9222f, (q31_t)0x770a08dc, (q31_t)0xd0f34a3d, - (q31_t)0x7707b979, (q31_t)0xd0ed7267, (q31_t)0x770569cc, (q31_t)0xd0e79aaf, (q31_t)0x770319d6, (q31_t)0xd0e1c313, (q31_t)0x7700c997, (q31_t)0xd0dbeb95, - (q31_t)0x76fe790e, (q31_t)0xd0d61434, (q31_t)0x76fc283c, (q31_t)0xd0d03cf0, (q31_t)0x76f9d721, (q31_t)0xd0ca65c9, (q31_t)0x76f785bc, (q31_t)0xd0c48ebf, - (q31_t)0x76f5340e, (q31_t)0xd0beb7d2, (q31_t)0x76f2e216, (q31_t)0xd0b8e102, (q31_t)0x76f08fd5, (q31_t)0xd0b30a50, (q31_t)0x76ee3d4b, (q31_t)0xd0ad33ba, - (q31_t)0x76ebea77, (q31_t)0xd0a75d42, (q31_t)0x76e9975a, (q31_t)0xd0a186e7, (q31_t)0x76e743f4, (q31_t)0xd09bb0aa, (q31_t)0x76e4f044, (q31_t)0xd095da89, - (q31_t)0x76e29c4b, (q31_t)0xd0900486, (q31_t)0x76e04808, (q31_t)0xd08a2ea0, (q31_t)0x76ddf37c, (q31_t)0xd08458d7, (q31_t)0x76db9ea7, (q31_t)0xd07e832c, - (q31_t)0x76d94989, (q31_t)0xd078ad9e, (q31_t)0x76d6f421, (q31_t)0xd072d82d, (q31_t)0x76d49e70, (q31_t)0xd06d02da, (q31_t)0x76d24876, (q31_t)0xd0672da3, - (q31_t)0x76cff232, (q31_t)0xd061588b, (q31_t)0x76cd9ba5, (q31_t)0xd05b838f, (q31_t)0x76cb44cf, (q31_t)0xd055aeb1, (q31_t)0x76c8edb0, (q31_t)0xd04fd9f1, - (q31_t)0x76c69647, (q31_t)0xd04a054e, (q31_t)0x76c43e95, (q31_t)0xd04430c8, (q31_t)0x76c1e699, (q31_t)0xd03e5c60, (q31_t)0x76bf8e55, (q31_t)0xd0388815, - (q31_t)0x76bd35c7, (q31_t)0xd032b3e7, (q31_t)0x76badcf0, (q31_t)0xd02cdfd8, (q31_t)0x76b883d0, (q31_t)0xd0270be5, (q31_t)0x76b62a66, (q31_t)0xd0213810, - (q31_t)0x76b3d0b4, (q31_t)0xd01b6459, (q31_t)0x76b176b8, (q31_t)0xd01590bf, (q31_t)0x76af1c72, (q31_t)0xd00fbd43, (q31_t)0x76acc1e4, (q31_t)0xd009e9e4, - (q31_t)0x76aa670d, (q31_t)0xd00416a3, (q31_t)0x76a80bec, (q31_t)0xcffe4380, (q31_t)0x76a5b082, (q31_t)0xcff8707a, (q31_t)0x76a354cf, (q31_t)0xcff29d92, - (q31_t)0x76a0f8d2, (q31_t)0xcfeccac7, (q31_t)0x769e9c8d, (q31_t)0xcfe6f81a, (q31_t)0x769c3ffe, (q31_t)0xcfe1258b, (q31_t)0x7699e326, (q31_t)0xcfdb531a, - (q31_t)0x76978605, (q31_t)0xcfd580c6, (q31_t)0x7695289b, (q31_t)0xcfcfae8f, (q31_t)0x7692cae8, (q31_t)0xcfc9dc77, (q31_t)0x76906ceb, (q31_t)0xcfc40a7c, - (q31_t)0x768e0ea6, (q31_t)0xcfbe389f, (q31_t)0x768bb017, (q31_t)0xcfb866e0, (q31_t)0x7689513f, (q31_t)0xcfb2953f, (q31_t)0x7686f21e, (q31_t)0xcfacc3bb, - (q31_t)0x768492b4, (q31_t)0xcfa6f255, (q31_t)0x76823301, (q31_t)0xcfa1210d, (q31_t)0x767fd304, (q31_t)0xcf9b4fe3, (q31_t)0x767d72bf, (q31_t)0xcf957ed7, - (q31_t)0x767b1231, (q31_t)0xcf8fade9, (q31_t)0x7678b159, (q31_t)0xcf89dd18, (q31_t)0x76765038, (q31_t)0xcf840c65, (q31_t)0x7673eecf, (q31_t)0xcf7e3bd1, - (q31_t)0x76718d1c, (q31_t)0xcf786b5a, (q31_t)0x766f2b20, (q31_t)0xcf729b01, (q31_t)0x766cc8db, (q31_t)0xcf6ccac6, (q31_t)0x766a664d, (q31_t)0xcf66faa9, - (q31_t)0x76680376, (q31_t)0xcf612aaa, (q31_t)0x7665a056, (q31_t)0xcf5b5ac9, (q31_t)0x76633ced, (q31_t)0xcf558b06, (q31_t)0x7660d93b, (q31_t)0xcf4fbb61, - (q31_t)0x765e7540, (q31_t)0xcf49ebda, (q31_t)0x765c10fc, (q31_t)0xcf441c71, (q31_t)0x7659ac6f, (q31_t)0xcf3e4d26, (q31_t)0x76574798, (q31_t)0xcf387dfa, - (q31_t)0x7654e279, (q31_t)0xcf32aeeb, (q31_t)0x76527d11, (q31_t)0xcf2cdffa, (q31_t)0x76501760, (q31_t)0xcf271128, (q31_t)0x764db166, (q31_t)0xcf214274, - (q31_t)0x764b4b23, (q31_t)0xcf1b73de, (q31_t)0x7648e497, (q31_t)0xcf15a566, (q31_t)0x76467dc2, (q31_t)0xcf0fd70c, (q31_t)0x764416a4, (q31_t)0xcf0a08d0, - (q31_t)0x7641af3d, (q31_t)0xcf043ab3, (q31_t)0x763f478d, (q31_t)0xcefe6cb3, (q31_t)0x763cdf94, (q31_t)0xcef89ed2, (q31_t)0x763a7752, (q31_t)0xcef2d110, - (q31_t)0x76380ec8, (q31_t)0xceed036b, (q31_t)0x7635a5f4, (q31_t)0xcee735e5, (q31_t)0x76333cd8, (q31_t)0xcee1687d, (q31_t)0x7630d372, (q31_t)0xcedb9b33, - (q31_t)0x762e69c4, (q31_t)0xced5ce08, (q31_t)0x762bffcd, (q31_t)0xced000fb, (q31_t)0x7629958c, (q31_t)0xceca340c, (q31_t)0x76272b03, (q31_t)0xcec4673c, - (q31_t)0x7624c031, (q31_t)0xcebe9a8a, (q31_t)0x76225517, (q31_t)0xceb8cdf7, (q31_t)0x761fe9b3, (q31_t)0xceb30181, (q31_t)0x761d7e06, (q31_t)0xcead352b, - (q31_t)0x761b1211, (q31_t)0xcea768f2, (q31_t)0x7618a5d3, (q31_t)0xcea19cd8, (q31_t)0x7616394c, (q31_t)0xce9bd0dd, (q31_t)0x7613cc7c, (q31_t)0xce960500, - (q31_t)0x76115f63, (q31_t)0xce903942, (q31_t)0x760ef201, (q31_t)0xce8a6da2, (q31_t)0x760c8457, (q31_t)0xce84a220, (q31_t)0x760a1664, (q31_t)0xce7ed6bd, - (q31_t)0x7607a828, (q31_t)0xce790b79, (q31_t)0x760539a3, (q31_t)0xce734053, (q31_t)0x7602cad5, (q31_t)0xce6d754c, (q31_t)0x76005bbf, (q31_t)0xce67aa63, - (q31_t)0x75fdec60, (q31_t)0xce61df99, (q31_t)0x75fb7cb8, (q31_t)0xce5c14ed, (q31_t)0x75f90cc7, (q31_t)0xce564a60, (q31_t)0x75f69c8d, (q31_t)0xce507ff2, - (q31_t)0x75f42c0b, (q31_t)0xce4ab5a2, (q31_t)0x75f1bb40, (q31_t)0xce44eb71, (q31_t)0x75ef4a2c, (q31_t)0xce3f215f, (q31_t)0x75ecd8cf, (q31_t)0xce39576c, - (q31_t)0x75ea672a, (q31_t)0xce338d97, (q31_t)0x75e7f53c, (q31_t)0xce2dc3e1, (q31_t)0x75e58305, (q31_t)0xce27fa49, (q31_t)0x75e31086, (q31_t)0xce2230d0, - (q31_t)0x75e09dbd, (q31_t)0xce1c6777, (q31_t)0x75de2aac, (q31_t)0xce169e3b, (q31_t)0x75dbb753, (q31_t)0xce10d51f, (q31_t)0x75d943b0, (q31_t)0xce0b0c21, - (q31_t)0x75d6cfc5, (q31_t)0xce054343, (q31_t)0x75d45b92, (q31_t)0xcdff7a83, (q31_t)0x75d1e715, (q31_t)0xcdf9b1e2, (q31_t)0x75cf7250, (q31_t)0xcdf3e95f, - (q31_t)0x75ccfd42, (q31_t)0xcdee20fc, (q31_t)0x75ca87ec, (q31_t)0xcde858b8, (q31_t)0x75c8124d, (q31_t)0xcde29092, (q31_t)0x75c59c65, (q31_t)0xcddcc88b, - (q31_t)0x75c32634, (q31_t)0xcdd700a4, (q31_t)0x75c0afbb, (q31_t)0xcdd138db, (q31_t)0x75be38fa, (q31_t)0xcdcb7131, (q31_t)0x75bbc1ef, (q31_t)0xcdc5a9a6, - (q31_t)0x75b94a9c, (q31_t)0xcdbfe23a, (q31_t)0x75b6d301, (q31_t)0xcdba1aee, (q31_t)0x75b45b1d, (q31_t)0xcdb453c0, (q31_t)0x75b1e2f0, (q31_t)0xcdae8cb1, - (q31_t)0x75af6a7b, (q31_t)0xcda8c5c1, (q31_t)0x75acf1bd, (q31_t)0xcda2fef0, (q31_t)0x75aa78b6, (q31_t)0xcd9d383f, (q31_t)0x75a7ff67, (q31_t)0xcd9771ac, - (q31_t)0x75a585cf, (q31_t)0xcd91ab39, (q31_t)0x75a30bef, (q31_t)0xcd8be4e4, (q31_t)0x75a091c6, (q31_t)0xcd861eaf, (q31_t)0x759e1755, (q31_t)0xcd805899, - (q31_t)0x759b9c9b, (q31_t)0xcd7a92a2, (q31_t)0x75992198, (q31_t)0xcd74ccca, (q31_t)0x7596a64d, (q31_t)0xcd6f0711, (q31_t)0x75942ab9, (q31_t)0xcd694178, - (q31_t)0x7591aedd, (q31_t)0xcd637bfe, (q31_t)0x758f32b9, (q31_t)0xcd5db6a3, (q31_t)0x758cb64c, (q31_t)0xcd57f167, (q31_t)0x758a3996, (q31_t)0xcd522c4a, - (q31_t)0x7587bc98, (q31_t)0xcd4c674d, (q31_t)0x75853f51, (q31_t)0xcd46a26f, (q31_t)0x7582c1c2, (q31_t)0xcd40ddb0, (q31_t)0x758043ea, (q31_t)0xcd3b1911, - (q31_t)0x757dc5ca, (q31_t)0xcd355491, (q31_t)0x757b4762, (q31_t)0xcd2f9030, (q31_t)0x7578c8b0, (q31_t)0xcd29cbee, (q31_t)0x757649b7, (q31_t)0xcd2407cc, - (q31_t)0x7573ca75, (q31_t)0xcd1e43ca, (q31_t)0x75714aea, (q31_t)0xcd187fe6, (q31_t)0x756ecb18, (q31_t)0xcd12bc22, (q31_t)0x756c4afc, (q31_t)0xcd0cf87e, - (q31_t)0x7569ca99, (q31_t)0xcd0734f9, (q31_t)0x756749ec, (q31_t)0xcd017193, (q31_t)0x7564c8f8, (q31_t)0xccfbae4d, (q31_t)0x756247bb, (q31_t)0xccf5eb26, - (q31_t)0x755fc635, (q31_t)0xccf0281f, (q31_t)0x755d4467, (q31_t)0xccea6538, (q31_t)0x755ac251, (q31_t)0xcce4a26f, (q31_t)0x75583ff3, (q31_t)0xccdedfc7, - (q31_t)0x7555bd4c, (q31_t)0xccd91d3d, (q31_t)0x75533a5c, (q31_t)0xccd35ad4, (q31_t)0x7550b725, (q31_t)0xcccd988a, (q31_t)0x754e33a4, (q31_t)0xccc7d65f, - (q31_t)0x754bafdc, (q31_t)0xccc21455, (q31_t)0x75492bcb, (q31_t)0xccbc5269, (q31_t)0x7546a772, (q31_t)0xccb6909e, (q31_t)0x754422d0, (q31_t)0xccb0cef2, - (q31_t)0x75419de7, (q31_t)0xccab0d65, (q31_t)0x753f18b4, (q31_t)0xcca54bf9, (q31_t)0x753c933a, (q31_t)0xcc9f8aac, (q31_t)0x753a0d77, (q31_t)0xcc99c97e, - (q31_t)0x7537876c, (q31_t)0xcc940871, (q31_t)0x75350118, (q31_t)0xcc8e4783, (q31_t)0x75327a7d, (q31_t)0xcc8886b5, (q31_t)0x752ff399, (q31_t)0xcc82c607, - (q31_t)0x752d6c6c, (q31_t)0xcc7d0578, (q31_t)0x752ae4f8, (q31_t)0xcc774509, (q31_t)0x75285d3b, (q31_t)0xcc7184ba, (q31_t)0x7525d536, (q31_t)0xcc6bc48b, - (q31_t)0x75234ce8, (q31_t)0xcc66047b, (q31_t)0x7520c453, (q31_t)0xcc60448c, (q31_t)0x751e3b75, (q31_t)0xcc5a84bc, (q31_t)0x751bb24f, (q31_t)0xcc54c50c, - (q31_t)0x751928e0, (q31_t)0xcc4f057c, (q31_t)0x75169f2a, (q31_t)0xcc49460c, (q31_t)0x7514152b, (q31_t)0xcc4386bc, (q31_t)0x75118ae4, (q31_t)0xcc3dc78b, - (q31_t)0x750f0054, (q31_t)0xcc38087b, (q31_t)0x750c757d, (q31_t)0xcc32498a, (q31_t)0x7509ea5d, (q31_t)0xcc2c8aba, (q31_t)0x75075ef5, (q31_t)0xcc26cc09, - (q31_t)0x7504d345, (q31_t)0xcc210d79, (q31_t)0x7502474d, (q31_t)0xcc1b4f08, (q31_t)0x74ffbb0d, (q31_t)0xcc1590b8, (q31_t)0x74fd2e84, (q31_t)0xcc0fd287, - (q31_t)0x74faa1b3, (q31_t)0xcc0a1477, (q31_t)0x74f8149a, (q31_t)0xcc045686, (q31_t)0x74f58739, (q31_t)0xcbfe98b6, (q31_t)0x74f2f990, (q31_t)0xcbf8db05, - (q31_t)0x74f06b9e, (q31_t)0xcbf31d75, (q31_t)0x74eddd65, (q31_t)0xcbed6005, (q31_t)0x74eb4ee3, (q31_t)0xcbe7a2b5, (q31_t)0x74e8c01a, (q31_t)0xcbe1e585, - (q31_t)0x74e63108, (q31_t)0xcbdc2876, (q31_t)0x74e3a1ae, (q31_t)0xcbd66b86, (q31_t)0x74e1120c, (q31_t)0xcbd0aeb7, (q31_t)0x74de8221, (q31_t)0xcbcaf208, - (q31_t)0x74dbf1ef, (q31_t)0xcbc53579, (q31_t)0x74d96175, (q31_t)0xcbbf790a, (q31_t)0x74d6d0b2, (q31_t)0xcbb9bcbb, (q31_t)0x74d43fa8, (q31_t)0xcbb4008d, - (q31_t)0x74d1ae55, (q31_t)0xcbae447f, (q31_t)0x74cf1cbb, (q31_t)0xcba88891, (q31_t)0x74cc8ad8, (q31_t)0xcba2ccc4, (q31_t)0x74c9f8ad, (q31_t)0xcb9d1117, - (q31_t)0x74c7663a, (q31_t)0xcb97558a, (q31_t)0x74c4d380, (q31_t)0xcb919a1d, (q31_t)0x74c2407d, (q31_t)0xcb8bded1, (q31_t)0x74bfad32, (q31_t)0xcb8623a5, - (q31_t)0x74bd199f, (q31_t)0xcb80689a, (q31_t)0x74ba85c4, (q31_t)0xcb7aadaf, (q31_t)0x74b7f1a1, (q31_t)0xcb74f2e4, (q31_t)0x74b55d36, (q31_t)0xcb6f383a, - (q31_t)0x74b2c884, (q31_t)0xcb697db0, (q31_t)0x74b03389, (q31_t)0xcb63c347, (q31_t)0x74ad9e46, (q31_t)0xcb5e08fe, (q31_t)0x74ab08bb, (q31_t)0xcb584ed6, - (q31_t)0x74a872e8, (q31_t)0xcb5294ce, (q31_t)0x74a5dccd, (q31_t)0xcb4cdae6, (q31_t)0x74a3466b, (q31_t)0xcb47211f, (q31_t)0x74a0afc0, (q31_t)0xcb416779, - (q31_t)0x749e18cd, (q31_t)0xcb3badf3, (q31_t)0x749b8193, (q31_t)0xcb35f48d, (q31_t)0x7498ea11, (q31_t)0xcb303b49, (q31_t)0x74965246, (q31_t)0xcb2a8224, - (q31_t)0x7493ba34, (q31_t)0xcb24c921, (q31_t)0x749121da, (q31_t)0xcb1f103e, (q31_t)0x748e8938, (q31_t)0xcb19577b, (q31_t)0x748bf04d, (q31_t)0xcb139ed9, - (q31_t)0x7489571c, (q31_t)0xcb0de658, (q31_t)0x7486bda2, (q31_t)0xcb082df8, (q31_t)0x748423e0, (q31_t)0xcb0275b8, (q31_t)0x748189d7, (q31_t)0xcafcbd99, - (q31_t)0x747eef85, (q31_t)0xcaf7059a, (q31_t)0x747c54ec, (q31_t)0xcaf14dbd, (q31_t)0x7479ba0b, (q31_t)0xcaeb9600, (q31_t)0x74771ee2, (q31_t)0xcae5de64, - (q31_t)0x74748371, (q31_t)0xcae026e8, (q31_t)0x7471e7b8, (q31_t)0xcada6f8d, (q31_t)0x746f4bb8, (q31_t)0xcad4b853, (q31_t)0x746caf70, (q31_t)0xcacf013a, - (q31_t)0x746a12df, (q31_t)0xcac94a42, (q31_t)0x74677608, (q31_t)0xcac3936b, (q31_t)0x7464d8e8, (q31_t)0xcabddcb4, (q31_t)0x74623b80, (q31_t)0xcab8261e, - (q31_t)0x745f9dd1, (q31_t)0xcab26fa9, (q31_t)0x745cffda, (q31_t)0xcaacb955, (q31_t)0x745a619b, (q31_t)0xcaa70322, (q31_t)0x7457c314, (q31_t)0xcaa14d10, - (q31_t)0x74552446, (q31_t)0xca9b971e, (q31_t)0x74528530, (q31_t)0xca95e14e, (q31_t)0x744fe5d2, (q31_t)0xca902b9f, (q31_t)0x744d462c, (q31_t)0xca8a7610, - (q31_t)0x744aa63f, (q31_t)0xca84c0a3, (q31_t)0x7448060a, (q31_t)0xca7f0b56, (q31_t)0x7445658d, (q31_t)0xca79562b, (q31_t)0x7442c4c8, (q31_t)0xca73a120, - (q31_t)0x744023bc, (q31_t)0xca6dec37, (q31_t)0x743d8268, (q31_t)0xca68376e, (q31_t)0x743ae0cc, (q31_t)0xca6282c7, (q31_t)0x74383ee9, (q31_t)0xca5cce40, - (q31_t)0x74359cbd, (q31_t)0xca5719db, (q31_t)0x7432fa4b, (q31_t)0xca516597, (q31_t)0x74305790, (q31_t)0xca4bb174, (q31_t)0x742db48e, (q31_t)0xca45fd72, - (q31_t)0x742b1144, (q31_t)0xca404992, (q31_t)0x74286db3, (q31_t)0xca3a95d2, (q31_t)0x7425c9da, (q31_t)0xca34e234, (q31_t)0x742325b9, (q31_t)0xca2f2eb6, - (q31_t)0x74208150, (q31_t)0xca297b5a, (q31_t)0x741ddca0, (q31_t)0xca23c820, (q31_t)0x741b37a9, (q31_t)0xca1e1506, (q31_t)0x74189269, (q31_t)0xca18620e, - (q31_t)0x7415ece2, (q31_t)0xca12af37, (q31_t)0x74134714, (q31_t)0xca0cfc81, (q31_t)0x7410a0fe, (q31_t)0xca0749ec, (q31_t)0x740dfaa0, (q31_t)0xca019779, - (q31_t)0x740b53fb, (q31_t)0xc9fbe527, (q31_t)0x7408ad0e, (q31_t)0xc9f632f6, (q31_t)0x740605d9, (q31_t)0xc9f080e7, (q31_t)0x74035e5d, (q31_t)0xc9eacef9, - (q31_t)0x7400b69a, (q31_t)0xc9e51d2d, (q31_t)0x73fe0e8f, (q31_t)0xc9df6b81, (q31_t)0x73fb663c, (q31_t)0xc9d9b9f7, (q31_t)0x73f8bda2, (q31_t)0xc9d4088f, - (q31_t)0x73f614c0, (q31_t)0xc9ce5748, (q31_t)0x73f36b97, (q31_t)0xc9c8a622, (q31_t)0x73f0c226, (q31_t)0xc9c2f51e, (q31_t)0x73ee186e, (q31_t)0xc9bd443c, - (q31_t)0x73eb6e6e, (q31_t)0xc9b7937a, (q31_t)0x73e8c426, (q31_t)0xc9b1e2db, (q31_t)0x73e61997, (q31_t)0xc9ac325d, (q31_t)0x73e36ec1, (q31_t)0xc9a68200, - (q31_t)0x73e0c3a3, (q31_t)0xc9a0d1c5, (q31_t)0x73de183e, (q31_t)0xc99b21ab, (q31_t)0x73db6c91, (q31_t)0xc99571b3, (q31_t)0x73d8c09d, (q31_t)0xc98fc1dc, - (q31_t)0x73d61461, (q31_t)0xc98a1227, (q31_t)0x73d367de, (q31_t)0xc9846294, (q31_t)0x73d0bb13, (q31_t)0xc97eb322, (q31_t)0x73ce0e01, (q31_t)0xc97903d2, - (q31_t)0x73cb60a8, (q31_t)0xc97354a4, (q31_t)0x73c8b307, (q31_t)0xc96da597, (q31_t)0x73c6051f, (q31_t)0xc967f6ac, (q31_t)0x73c356ef, (q31_t)0xc96247e2, - (q31_t)0x73c0a878, (q31_t)0xc95c993a, (q31_t)0x73bdf9b9, (q31_t)0xc956eab4, (q31_t)0x73bb4ab3, (q31_t)0xc9513c50, (q31_t)0x73b89b66, (q31_t)0xc94b8e0d, - (q31_t)0x73b5ebd1, (q31_t)0xc945dfec, (q31_t)0x73b33bf5, (q31_t)0xc94031ed, (q31_t)0x73b08bd1, (q31_t)0xc93a8410, (q31_t)0x73addb67, (q31_t)0xc934d654, - (q31_t)0x73ab2ab4, (q31_t)0xc92f28ba, (q31_t)0x73a879bb, (q31_t)0xc9297b42, (q31_t)0x73a5c87a, (q31_t)0xc923cdec, (q31_t)0x73a316f2, (q31_t)0xc91e20b8, - (q31_t)0x73a06522, (q31_t)0xc91873a5, (q31_t)0x739db30b, (q31_t)0xc912c6b5, (q31_t)0x739b00ad, (q31_t)0xc90d19e6, (q31_t)0x73984e07, (q31_t)0xc9076d39, - (q31_t)0x73959b1b, (q31_t)0xc901c0ae, (q31_t)0x7392e7e6, (q31_t)0xc8fc1445, (q31_t)0x7390346b, (q31_t)0xc8f667fe, (q31_t)0x738d80a8, (q31_t)0xc8f0bbd9, - (q31_t)0x738acc9e, (q31_t)0xc8eb0fd6, (q31_t)0x7388184d, (q31_t)0xc8e563f5, (q31_t)0x738563b5, (q31_t)0xc8dfb836, (q31_t)0x7382aed5, (q31_t)0xc8da0c99, - (q31_t)0x737ff9ae, (q31_t)0xc8d4611d, (q31_t)0x737d4440, (q31_t)0xc8ceb5c4, (q31_t)0x737a8e8a, (q31_t)0xc8c90a8d, (q31_t)0x7377d88d, (q31_t)0xc8c35f78, - (q31_t)0x73752249, (q31_t)0xc8bdb485, (q31_t)0x73726bbe, (q31_t)0xc8b809b4, (q31_t)0x736fb4ec, (q31_t)0xc8b25f06, (q31_t)0x736cfdd2, (q31_t)0xc8acb479, - (q31_t)0x736a4671, (q31_t)0xc8a70a0e, (q31_t)0x73678ec9, (q31_t)0xc8a15fc6, (q31_t)0x7364d6da, (q31_t)0xc89bb5a0, (q31_t)0x73621ea4, (q31_t)0xc8960b9c, - (q31_t)0x735f6626, (q31_t)0xc89061ba, (q31_t)0x735cad61, (q31_t)0xc88ab7fa, (q31_t)0x7359f456, (q31_t)0xc8850e5d, (q31_t)0x73573b03, (q31_t)0xc87f64e2, - (q31_t)0x73548168, (q31_t)0xc879bb89, (q31_t)0x7351c787, (q31_t)0xc8741252, (q31_t)0x734f0d5f, (q31_t)0xc86e693d, (q31_t)0x734c52ef, (q31_t)0xc868c04b, - (q31_t)0x73499838, (q31_t)0xc863177b, (q31_t)0x7346dd3a, (q31_t)0xc85d6ece, (q31_t)0x734421f6, (q31_t)0xc857c642, (q31_t)0x7341666a, (q31_t)0xc8521dd9, - (q31_t)0x733eaa96, (q31_t)0xc84c7593, (q31_t)0x733bee7c, (q31_t)0xc846cd6e, (q31_t)0x7339321b, (q31_t)0xc841256d, (q31_t)0x73367572, (q31_t)0xc83b7d8d, - (q31_t)0x7333b883, (q31_t)0xc835d5d0, (q31_t)0x7330fb4d, (q31_t)0xc8302e35, (q31_t)0x732e3dcf, (q31_t)0xc82a86bd, (q31_t)0x732b800a, (q31_t)0xc824df67, - (q31_t)0x7328c1ff, (q31_t)0xc81f3834, (q31_t)0x732603ac, (q31_t)0xc8199123, (q31_t)0x73234512, (q31_t)0xc813ea35, (q31_t)0x73208632, (q31_t)0xc80e4369, - (q31_t)0x731dc70a, (q31_t)0xc8089cbf, (q31_t)0x731b079b, (q31_t)0xc802f638, (q31_t)0x731847e5, (q31_t)0xc7fd4fd4, (q31_t)0x731587e8, (q31_t)0xc7f7a992, - (q31_t)0x7312c7a5, (q31_t)0xc7f20373, (q31_t)0x7310071a, (q31_t)0xc7ec5d76, (q31_t)0x730d4648, (q31_t)0xc7e6b79c, (q31_t)0x730a8530, (q31_t)0xc7e111e5, - (q31_t)0x7307c3d0, (q31_t)0xc7db6c50, (q31_t)0x73050229, (q31_t)0xc7d5c6de, (q31_t)0x7302403c, (q31_t)0xc7d0218e, (q31_t)0x72ff7e07, (q31_t)0xc7ca7c61, - (q31_t)0x72fcbb8c, (q31_t)0xc7c4d757, (q31_t)0x72f9f8c9, (q31_t)0xc7bf3270, (q31_t)0x72f735c0, (q31_t)0xc7b98dab, (q31_t)0x72f47270, (q31_t)0xc7b3e909, - (q31_t)0x72f1aed9, (q31_t)0xc7ae4489, (q31_t)0x72eeeafb, (q31_t)0xc7a8a02c, (q31_t)0x72ec26d6, (q31_t)0xc7a2fbf3, (q31_t)0x72e9626a, (q31_t)0xc79d57db, - (q31_t)0x72e69db7, (q31_t)0xc797b3e7, (q31_t)0x72e3d8be, (q31_t)0xc7921015, (q31_t)0x72e1137d, (q31_t)0xc78c6c67, (q31_t)0x72de4df6, (q31_t)0xc786c8db, - (q31_t)0x72db8828, (q31_t)0xc7812572, (q31_t)0x72d8c213, (q31_t)0xc77b822b, (q31_t)0x72d5fbb7, (q31_t)0xc775df08, (q31_t)0x72d33514, (q31_t)0xc7703c08, - (q31_t)0x72d06e2b, (q31_t)0xc76a992a, (q31_t)0x72cda6fb, (q31_t)0xc764f66f, (q31_t)0x72cadf83, (q31_t)0xc75f53d7, (q31_t)0x72c817c6, (q31_t)0xc759b163, - (q31_t)0x72c54fc1, (q31_t)0xc7540f11, (q31_t)0x72c28775, (q31_t)0xc74e6ce2, (q31_t)0x72bfbee3, (q31_t)0xc748cad6, (q31_t)0x72bcf60a, (q31_t)0xc74328ed, - (q31_t)0x72ba2cea, (q31_t)0xc73d8727, (q31_t)0x72b76383, (q31_t)0xc737e584, (q31_t)0x72b499d6, (q31_t)0xc7324404, (q31_t)0x72b1cfe1, (q31_t)0xc72ca2a7, - (q31_t)0x72af05a7, (q31_t)0xc727016d, (q31_t)0x72ac3b25, (q31_t)0xc7216056, (q31_t)0x72a9705c, (q31_t)0xc71bbf62, (q31_t)0x72a6a54d, (q31_t)0xc7161e92, - (q31_t)0x72a3d9f7, (q31_t)0xc7107de4, (q31_t)0x72a10e5b, (q31_t)0xc70add5a, (q31_t)0x729e4277, (q31_t)0xc7053cf2, (q31_t)0x729b764d, (q31_t)0xc6ff9cae, - (q31_t)0x7298a9dd, (q31_t)0xc6f9fc8d, (q31_t)0x7295dd25, (q31_t)0xc6f45c8f, (q31_t)0x72931027, (q31_t)0xc6eebcb5, (q31_t)0x729042e3, (q31_t)0xc6e91cfd, - (q31_t)0x728d7557, (q31_t)0xc6e37d69, (q31_t)0x728aa785, (q31_t)0xc6ddddf8, (q31_t)0x7287d96c, (q31_t)0xc6d83eab, (q31_t)0x72850b0d, (q31_t)0xc6d29f80, - (q31_t)0x72823c67, (q31_t)0xc6cd0079, (q31_t)0x727f6d7a, (q31_t)0xc6c76195, (q31_t)0x727c9e47, (q31_t)0xc6c1c2d4, (q31_t)0x7279cecd, (q31_t)0xc6bc2437, - (q31_t)0x7276ff0d, (q31_t)0xc6b685bd, (q31_t)0x72742f05, (q31_t)0xc6b0e767, (q31_t)0x72715eb8, (q31_t)0xc6ab4933, (q31_t)0x726e8e23, (q31_t)0xc6a5ab23, - (q31_t)0x726bbd48, (q31_t)0xc6a00d37, (q31_t)0x7268ec27, (q31_t)0xc69a6f6e, (q31_t)0x72661abf, (q31_t)0xc694d1c8, (q31_t)0x72634910, (q31_t)0xc68f3446, - (q31_t)0x7260771b, (q31_t)0xc68996e7, (q31_t)0x725da4df, (q31_t)0xc683f9ab, (q31_t)0x725ad25d, (q31_t)0xc67e5c93, (q31_t)0x7257ff94, (q31_t)0xc678bf9f, - (q31_t)0x72552c85, (q31_t)0xc67322ce, (q31_t)0x7252592f, (q31_t)0xc66d8620, (q31_t)0x724f8593, (q31_t)0xc667e996, (q31_t)0x724cb1b0, (q31_t)0xc6624d30, - (q31_t)0x7249dd86, (q31_t)0xc65cb0ed, (q31_t)0x72470916, (q31_t)0xc65714cd, (q31_t)0x72443460, (q31_t)0xc65178d1, (q31_t)0x72415f63, (q31_t)0xc64bdcf9, - (q31_t)0x723e8a20, (q31_t)0xc6464144, (q31_t)0x723bb496, (q31_t)0xc640a5b3, (q31_t)0x7238dec5, (q31_t)0xc63b0a46, (q31_t)0x723608af, (q31_t)0xc6356efc, - (q31_t)0x72333251, (q31_t)0xc62fd3d6, (q31_t)0x72305bae, (q31_t)0xc62a38d4, (q31_t)0x722d84c4, (q31_t)0xc6249df5, (q31_t)0x722aad93, (q31_t)0xc61f033a, - (q31_t)0x7227d61c, (q31_t)0xc61968a2, (q31_t)0x7224fe5f, (q31_t)0xc613ce2f, (q31_t)0x7222265b, (q31_t)0xc60e33df, (q31_t)0x721f4e11, (q31_t)0xc60899b2, - (q31_t)0x721c7580, (q31_t)0xc602ffaa, (q31_t)0x72199ca9, (q31_t)0xc5fd65c5, (q31_t)0x7216c38c, (q31_t)0xc5f7cc04, (q31_t)0x7213ea28, (q31_t)0xc5f23267, - (q31_t)0x7211107e, (q31_t)0xc5ec98ee, (q31_t)0x720e368d, (q31_t)0xc5e6ff98, (q31_t)0x720b5c57, (q31_t)0xc5e16667, (q31_t)0x720881d9, (q31_t)0xc5dbcd59, - (q31_t)0x7205a716, (q31_t)0xc5d6346f, (q31_t)0x7202cc0c, (q31_t)0xc5d09ba9, (q31_t)0x71fff0bc, (q31_t)0xc5cb0307, (q31_t)0x71fd1525, (q31_t)0xc5c56a89, - (q31_t)0x71fa3949, (q31_t)0xc5bfd22e, (q31_t)0x71f75d25, (q31_t)0xc5ba39f8, (q31_t)0x71f480bc, (q31_t)0xc5b4a1e5, (q31_t)0x71f1a40c, (q31_t)0xc5af09f7, - (q31_t)0x71eec716, (q31_t)0xc5a9722c, (q31_t)0x71ebe9da, (q31_t)0xc5a3da86, (q31_t)0x71e90c57, (q31_t)0xc59e4303, (q31_t)0x71e62e8f, (q31_t)0xc598aba5, - (q31_t)0x71e35080, (q31_t)0xc593146a, (q31_t)0x71e0722a, (q31_t)0xc58d7d54, (q31_t)0x71dd938f, (q31_t)0xc587e661, (q31_t)0x71dab4ad, (q31_t)0xc5824f93, - (q31_t)0x71d7d585, (q31_t)0xc57cb8e9, (q31_t)0x71d4f617, (q31_t)0xc5772263, (q31_t)0x71d21662, (q31_t)0xc5718c00, (q31_t)0x71cf3667, (q31_t)0xc56bf5c2, - (q31_t)0x71cc5626, (q31_t)0xc5665fa9, (q31_t)0x71c9759f, (q31_t)0xc560c9b3, (q31_t)0x71c694d2, (q31_t)0xc55b33e2, (q31_t)0x71c3b3bf, (q31_t)0xc5559e34, - (q31_t)0x71c0d265, (q31_t)0xc55008ab, (q31_t)0x71bdf0c5, (q31_t)0xc54a7346, (q31_t)0x71bb0edf, (q31_t)0xc544de05, (q31_t)0x71b82cb3, (q31_t)0xc53f48e9, - (q31_t)0x71b54a41, (q31_t)0xc539b3f1, (q31_t)0x71b26788, (q31_t)0xc5341f1d, (q31_t)0x71af848a, (q31_t)0xc52e8a6d, (q31_t)0x71aca145, (q31_t)0xc528f5e1, - (q31_t)0x71a9bdba, (q31_t)0xc523617a, (q31_t)0x71a6d9e9, (q31_t)0xc51dcd37, (q31_t)0x71a3f5d2, (q31_t)0xc5183919, (q31_t)0x71a11175, (q31_t)0xc512a51f, - (q31_t)0x719e2cd2, (q31_t)0xc50d1149, (q31_t)0x719b47e9, (q31_t)0xc5077d97, (q31_t)0x719862b9, (q31_t)0xc501ea0a, (q31_t)0x71957d44, (q31_t)0xc4fc56a2, - (q31_t)0x71929789, (q31_t)0xc4f6c35d, (q31_t)0x718fb187, (q31_t)0xc4f1303d, (q31_t)0x718ccb3f, (q31_t)0xc4eb9d42, (q31_t)0x7189e4b2, (q31_t)0xc4e60a6b, - (q31_t)0x7186fdde, (q31_t)0xc4e077b8, (q31_t)0x718416c4, (q31_t)0xc4dae52a, (q31_t)0x71812f65, (q31_t)0xc4d552c1, (q31_t)0x717e47bf, (q31_t)0xc4cfc07c, - (q31_t)0x717b5fd3, (q31_t)0xc4ca2e5b, (q31_t)0x717877a1, (q31_t)0xc4c49c5f, (q31_t)0x71758f29, (q31_t)0xc4bf0a87, (q31_t)0x7172a66c, (q31_t)0xc4b978d4, - (q31_t)0x716fbd68, (q31_t)0xc4b3e746, (q31_t)0x716cd41e, (q31_t)0xc4ae55dc, (q31_t)0x7169ea8f, (q31_t)0xc4a8c497, (q31_t)0x716700b9, (q31_t)0xc4a33376, - (q31_t)0x7164169d, (q31_t)0xc49da27a, (q31_t)0x71612c3c, (q31_t)0xc49811a3, (q31_t)0x715e4194, (q31_t)0xc49280f0, (q31_t)0x715b56a7, (q31_t)0xc48cf062, - (q31_t)0x71586b74, (q31_t)0xc4875ff9, (q31_t)0x71557ffa, (q31_t)0xc481cfb4, (q31_t)0x7152943b, (q31_t)0xc47c3f94, (q31_t)0x714fa836, (q31_t)0xc476af98, - (q31_t)0x714cbbeb, (q31_t)0xc4711fc2, (q31_t)0x7149cf5a, (q31_t)0xc46b9010, (q31_t)0x7146e284, (q31_t)0xc4660083, (q31_t)0x7143f567, (q31_t)0xc460711b, - (q31_t)0x71410805, (q31_t)0xc45ae1d7, (q31_t)0x713e1a5c, (q31_t)0xc45552b8, (q31_t)0x713b2c6e, (q31_t)0xc44fc3be, (q31_t)0x71383e3a, (q31_t)0xc44a34e9, - (q31_t)0x71354fc0, (q31_t)0xc444a639, (q31_t)0x71326101, (q31_t)0xc43f17ad, (q31_t)0x712f71fb, (q31_t)0xc4398947, (q31_t)0x712c82b0, (q31_t)0xc433fb05, - (q31_t)0x7129931f, (q31_t)0xc42e6ce8, (q31_t)0x7126a348, (q31_t)0xc428def0, (q31_t)0x7123b32b, (q31_t)0xc423511d, (q31_t)0x7120c2c8, (q31_t)0xc41dc36f, - (q31_t)0x711dd220, (q31_t)0xc41835e6, (q31_t)0x711ae132, (q31_t)0xc412a882, (q31_t)0x7117effe, (q31_t)0xc40d1b42, (q31_t)0x7114fe84, (q31_t)0xc4078e28, - (q31_t)0x71120cc5, (q31_t)0xc4020133, (q31_t)0x710f1ac0, (q31_t)0xc3fc7462, (q31_t)0x710c2875, (q31_t)0xc3f6e7b7, (q31_t)0x710935e4, (q31_t)0xc3f15b31, - (q31_t)0x7106430e, (q31_t)0xc3ebced0, (q31_t)0x71034ff2, (q31_t)0xc3e64294, (q31_t)0x71005c90, (q31_t)0xc3e0b67d, (q31_t)0x70fd68e9, (q31_t)0xc3db2a8b, - (q31_t)0x70fa74fc, (q31_t)0xc3d59ebe, (q31_t)0x70f780c9, (q31_t)0xc3d01316, (q31_t)0x70f48c50, (q31_t)0xc3ca8793, (q31_t)0x70f19792, (q31_t)0xc3c4fc36, - (q31_t)0x70eea28e, (q31_t)0xc3bf70fd, (q31_t)0x70ebad45, (q31_t)0xc3b9e5ea, (q31_t)0x70e8b7b5, (q31_t)0xc3b45afc, (q31_t)0x70e5c1e1, (q31_t)0xc3aed034, - (q31_t)0x70e2cbc6, (q31_t)0xc3a94590, (q31_t)0x70dfd566, (q31_t)0xc3a3bb12, (q31_t)0x70dcdec0, (q31_t)0xc39e30b8, (q31_t)0x70d9e7d5, (q31_t)0xc398a685, - (q31_t)0x70d6f0a4, (q31_t)0xc3931c76, (q31_t)0x70d3f92d, (q31_t)0xc38d928d, (q31_t)0x70d10171, (q31_t)0xc38808c9, (q31_t)0x70ce096f, (q31_t)0xc3827f2a, - (q31_t)0x70cb1128, (q31_t)0xc37cf5b0, (q31_t)0x70c8189b, (q31_t)0xc3776c5c, (q31_t)0x70c51fc8, (q31_t)0xc371e32d, (q31_t)0x70c226b0, (q31_t)0xc36c5a24, - (q31_t)0x70bf2d53, (q31_t)0xc366d140, (q31_t)0x70bc33b0, (q31_t)0xc3614881, (q31_t)0x70b939c7, (q31_t)0xc35bbfe8, (q31_t)0x70b63f99, (q31_t)0xc3563774, - (q31_t)0x70b34525, (q31_t)0xc350af26, (q31_t)0x70b04a6b, (q31_t)0xc34b26fc, (q31_t)0x70ad4f6d, (q31_t)0xc3459ef9, (q31_t)0x70aa5428, (q31_t)0xc340171b, - (q31_t)0x70a7589f, (q31_t)0xc33a8f62, (q31_t)0x70a45ccf, (q31_t)0xc33507cf, (q31_t)0x70a160ba, (q31_t)0xc32f8061, (q31_t)0x709e6460, (q31_t)0xc329f919, - (q31_t)0x709b67c0, (q31_t)0xc32471f7, (q31_t)0x70986adb, (q31_t)0xc31eeaf9, (q31_t)0x70956db1, (q31_t)0xc3196422, (q31_t)0x70927041, (q31_t)0xc313dd70, - (q31_t)0x708f728b, (q31_t)0xc30e56e4, (q31_t)0x708c7490, (q31_t)0xc308d07d, (q31_t)0x70897650, (q31_t)0xc3034a3c, (q31_t)0x708677ca, (q31_t)0xc2fdc420, - (q31_t)0x708378ff, (q31_t)0xc2f83e2a, (q31_t)0x708079ee, (q31_t)0xc2f2b85a, (q31_t)0x707d7a98, (q31_t)0xc2ed32af, (q31_t)0x707a7afd, (q31_t)0xc2e7ad2a, - (q31_t)0x70777b1c, (q31_t)0xc2e227cb, (q31_t)0x70747af6, (q31_t)0xc2dca291, (q31_t)0x70717a8a, (q31_t)0xc2d71d7e, (q31_t)0x706e79d9, (q31_t)0xc2d1988f, - (q31_t)0x706b78e3, (q31_t)0xc2cc13c7, (q31_t)0x706877a7, (q31_t)0xc2c68f24, (q31_t)0x70657626, (q31_t)0xc2c10aa7, (q31_t)0x70627460, (q31_t)0xc2bb8650, - (q31_t)0x705f7255, (q31_t)0xc2b6021f, (q31_t)0x705c7004, (q31_t)0xc2b07e14, (q31_t)0x70596d6d, (q31_t)0xc2aafa2e, (q31_t)0x70566a92, (q31_t)0xc2a5766e, - (q31_t)0x70536771, (q31_t)0xc29ff2d4, (q31_t)0x7050640b, (q31_t)0xc29a6f60, (q31_t)0x704d6060, (q31_t)0xc294ec12, (q31_t)0x704a5c6f, (q31_t)0xc28f68e9, - (q31_t)0x70475839, (q31_t)0xc289e5e7, (q31_t)0x704453be, (q31_t)0xc284630a, (q31_t)0x70414efd, (q31_t)0xc27ee054, (q31_t)0x703e49f8, (q31_t)0xc2795dc3, - (q31_t)0x703b44ad, (q31_t)0xc273db58, (q31_t)0x70383f1d, (q31_t)0xc26e5913, (q31_t)0x70353947, (q31_t)0xc268d6f5, (q31_t)0x7032332d, (q31_t)0xc26354fc, - (q31_t)0x702f2ccd, (q31_t)0xc25dd329, (q31_t)0x702c2628, (q31_t)0xc258517c, (q31_t)0x70291f3e, (q31_t)0xc252cff5, (q31_t)0x7026180e, (q31_t)0xc24d4e95, - (q31_t)0x7023109a, (q31_t)0xc247cd5a, (q31_t)0x702008e0, (q31_t)0xc2424c46, (q31_t)0x701d00e1, (q31_t)0xc23ccb57, (q31_t)0x7019f89d, (q31_t)0xc2374a8f, - (q31_t)0x7016f014, (q31_t)0xc231c9ec, (q31_t)0x7013e746, (q31_t)0xc22c4970, (q31_t)0x7010de32, (q31_t)0xc226c91a, (q31_t)0x700dd4da, (q31_t)0xc22148ea, - (q31_t)0x700acb3c, (q31_t)0xc21bc8e1, (q31_t)0x7007c159, (q31_t)0xc21648fd, (q31_t)0x7004b731, (q31_t)0xc210c940, (q31_t)0x7001acc4, (q31_t)0xc20b49a9, - (q31_t)0x6ffea212, (q31_t)0xc205ca38, (q31_t)0x6ffb971b, (q31_t)0xc2004aed, (q31_t)0x6ff88bde, (q31_t)0xc1facbc9, (q31_t)0x6ff5805d, (q31_t)0xc1f54cca, - (q31_t)0x6ff27497, (q31_t)0xc1efcdf3, (q31_t)0x6fef688b, (q31_t)0xc1ea4f41, (q31_t)0x6fec5c3b, (q31_t)0xc1e4d0b6, (q31_t)0x6fe94fa5, (q31_t)0xc1df5251, - (q31_t)0x6fe642ca, (q31_t)0xc1d9d412, (q31_t)0x6fe335ab, (q31_t)0xc1d455f9, (q31_t)0x6fe02846, (q31_t)0xc1ced807, (q31_t)0x6fdd1a9c, (q31_t)0xc1c95a3c, - (q31_t)0x6fda0cae, (q31_t)0xc1c3dc97, (q31_t)0x6fd6fe7a, (q31_t)0xc1be5f18, (q31_t)0x6fd3f001, (q31_t)0xc1b8e1bf, (q31_t)0x6fd0e144, (q31_t)0xc1b3648d, - (q31_t)0x6fcdd241, (q31_t)0xc1ade781, (q31_t)0x6fcac2fa, (q31_t)0xc1a86a9c, (q31_t)0x6fc7b36d, (q31_t)0xc1a2edde, (q31_t)0x6fc4a39c, (q31_t)0xc19d7145, - (q31_t)0x6fc19385, (q31_t)0xc197f4d4, (q31_t)0x6fbe832a, (q31_t)0xc1927888, (q31_t)0x6fbb728a, (q31_t)0xc18cfc63, (q31_t)0x6fb861a4, (q31_t)0xc1878065, - (q31_t)0x6fb5507a, (q31_t)0xc182048d, (q31_t)0x6fb23f0b, (q31_t)0xc17c88dc, (q31_t)0x6faf2d57, (q31_t)0xc1770d52, (q31_t)0x6fac1b5f, (q31_t)0xc17191ee, - (q31_t)0x6fa90921, (q31_t)0xc16c16b0, (q31_t)0x6fa5f69e, (q31_t)0xc1669b99, (q31_t)0x6fa2e3d7, (q31_t)0xc16120a9, (q31_t)0x6f9fd0cb, (q31_t)0xc15ba5df, - (q31_t)0x6f9cbd79, (q31_t)0xc1562b3d, (q31_t)0x6f99a9e3, (q31_t)0xc150b0c0, (q31_t)0x6f969608, (q31_t)0xc14b366b, (q31_t)0x6f9381e9, (q31_t)0xc145bc3c, - (q31_t)0x6f906d84, (q31_t)0xc1404233, (q31_t)0x6f8d58db, (q31_t)0xc13ac852, (q31_t)0x6f8a43ed, (q31_t)0xc1354e97, (q31_t)0x6f872eba, (q31_t)0xc12fd503, - (q31_t)0x6f841942, (q31_t)0xc12a5b95, (q31_t)0x6f810386, (q31_t)0xc124e24f, (q31_t)0x6f7ded84, (q31_t)0xc11f692f, (q31_t)0x6f7ad73e, (q31_t)0xc119f036, - (q31_t)0x6f77c0b3, (q31_t)0xc1147764, (q31_t)0x6f74a9e4, (q31_t)0xc10efeb8, (q31_t)0x6f7192cf, (q31_t)0xc1098634, (q31_t)0x6f6e7b76, (q31_t)0xc1040dd6, - (q31_t)0x6f6b63d8, (q31_t)0xc0fe959f, (q31_t)0x6f684bf6, (q31_t)0xc0f91d8f, (q31_t)0x6f6533ce, (q31_t)0xc0f3a5a6, (q31_t)0x6f621b62, (q31_t)0xc0ee2de3, - (q31_t)0x6f5f02b2, (q31_t)0xc0e8b648, (q31_t)0x6f5be9bc, (q31_t)0xc0e33ed4, (q31_t)0x6f58d082, (q31_t)0xc0ddc786, (q31_t)0x6f55b703, (q31_t)0xc0d8505f, - (q31_t)0x6f529d40, (q31_t)0xc0d2d960, (q31_t)0x6f4f8338, (q31_t)0xc0cd6287, (q31_t)0x6f4c68eb, (q31_t)0xc0c7ebd6, (q31_t)0x6f494e5a, (q31_t)0xc0c2754b, - (q31_t)0x6f463383, (q31_t)0xc0bcfee7, (q31_t)0x6f431869, (q31_t)0xc0b788ab, (q31_t)0x6f3ffd09, (q31_t)0xc0b21295, (q31_t)0x6f3ce165, (q31_t)0xc0ac9ca6, - (q31_t)0x6f39c57d, (q31_t)0xc0a726df, (q31_t)0x6f36a94f, (q31_t)0xc0a1b13e, (q31_t)0x6f338cde, (q31_t)0xc09c3bc5, (q31_t)0x6f307027, (q31_t)0xc096c673, - (q31_t)0x6f2d532c, (q31_t)0xc0915148, (q31_t)0x6f2a35ed, (q31_t)0xc08bdc44, (q31_t)0x6f271868, (q31_t)0xc0866767, (q31_t)0x6f23faa0, (q31_t)0xc080f2b1, - (q31_t)0x6f20dc92, (q31_t)0xc07b7e23, (q31_t)0x6f1dbe41, (q31_t)0xc07609bb, (q31_t)0x6f1a9faa, (q31_t)0xc070957b, (q31_t)0x6f1780cf, (q31_t)0xc06b2162, - (q31_t)0x6f1461b0, (q31_t)0xc065ad70, (q31_t)0x6f11424c, (q31_t)0xc06039a6, (q31_t)0x6f0e22a3, (q31_t)0xc05ac603, (q31_t)0x6f0b02b6, (q31_t)0xc0555287, - (q31_t)0x6f07e285, (q31_t)0xc04fdf32, (q31_t)0x6f04c20f, (q31_t)0xc04a6c05, (q31_t)0x6f01a155, (q31_t)0xc044f8fe, (q31_t)0x6efe8056, (q31_t)0xc03f8620, - (q31_t)0x6efb5f12, (q31_t)0xc03a1368, (q31_t)0x6ef83d8a, (q31_t)0xc034a0d8, (q31_t)0x6ef51bbe, (q31_t)0xc02f2e6f, (q31_t)0x6ef1f9ad, (q31_t)0xc029bc2e, - (q31_t)0x6eeed758, (q31_t)0xc0244a14, (q31_t)0x6eebb4bf, (q31_t)0xc01ed821, (q31_t)0x6ee891e1, (q31_t)0xc0196656, (q31_t)0x6ee56ebe, (q31_t)0xc013f4b2, - (q31_t)0x6ee24b57, (q31_t)0xc00e8336, (q31_t)0x6edf27ac, (q31_t)0xc00911e1, (q31_t)0x6edc03bc, (q31_t)0xc003a0b3, (q31_t)0x6ed8df88, (q31_t)0xbffe2fad, - (q31_t)0x6ed5bb10, (q31_t)0xbff8bece, (q31_t)0x6ed29653, (q31_t)0xbff34e17, (q31_t)0x6ecf7152, (q31_t)0xbfeddd88, (q31_t)0x6ecc4c0d, (q31_t)0xbfe86d20, - (q31_t)0x6ec92683, (q31_t)0xbfe2fcdf, (q31_t)0x6ec600b5, (q31_t)0xbfdd8cc6, (q31_t)0x6ec2daa2, (q31_t)0xbfd81cd5, (q31_t)0x6ebfb44b, (q31_t)0xbfd2ad0b, - (q31_t)0x6ebc8db0, (q31_t)0xbfcd3d69, (q31_t)0x6eb966d1, (q31_t)0xbfc7cdee, (q31_t)0x6eb63fad, (q31_t)0xbfc25e9b, (q31_t)0x6eb31845, (q31_t)0xbfbcef70, - (q31_t)0x6eaff099, (q31_t)0xbfb7806c, (q31_t)0x6eacc8a8, (q31_t)0xbfb21190, (q31_t)0x6ea9a073, (q31_t)0xbfaca2dc, (q31_t)0x6ea677fa, (q31_t)0xbfa7344f, - (q31_t)0x6ea34f3d, (q31_t)0xbfa1c5ea, (q31_t)0x6ea0263b, (q31_t)0xbf9c57ac, (q31_t)0x6e9cfcf5, (q31_t)0xbf96e997, (q31_t)0x6e99d36b, (q31_t)0xbf917ba9, - (q31_t)0x6e96a99d, (q31_t)0xbf8c0de3, (q31_t)0x6e937f8a, (q31_t)0xbf86a044, (q31_t)0x6e905534, (q31_t)0xbf8132ce, (q31_t)0x6e8d2a99, (q31_t)0xbf7bc57f, - (q31_t)0x6e89ffb9, (q31_t)0xbf765858, (q31_t)0x6e86d496, (q31_t)0xbf70eb59, (q31_t)0x6e83a92f, (q31_t)0xbf6b7e81, (q31_t)0x6e807d83, (q31_t)0xbf6611d2, - (q31_t)0x6e7d5193, (q31_t)0xbf60a54a, (q31_t)0x6e7a255f, (q31_t)0xbf5b38ea, (q31_t)0x6e76f8e7, (q31_t)0xbf55ccb2, (q31_t)0x6e73cc2b, (q31_t)0xbf5060a2, - (q31_t)0x6e709f2a, (q31_t)0xbf4af4ba, (q31_t)0x6e6d71e6, (q31_t)0xbf4588fa, (q31_t)0x6e6a445d, (q31_t)0xbf401d61, (q31_t)0x6e671690, (q31_t)0xbf3ab1f1, - (q31_t)0x6e63e87f, (q31_t)0xbf3546a8, (q31_t)0x6e60ba2a, (q31_t)0xbf2fdb88, (q31_t)0x6e5d8b91, (q31_t)0xbf2a708f, (q31_t)0x6e5a5cb4, (q31_t)0xbf2505bf, - (q31_t)0x6e572d93, (q31_t)0xbf1f9b16, (q31_t)0x6e53fe2e, (q31_t)0xbf1a3096, (q31_t)0x6e50ce84, (q31_t)0xbf14c63d, (q31_t)0x6e4d9e97, (q31_t)0xbf0f5c0d, - (q31_t)0x6e4a6e66, (q31_t)0xbf09f205, (q31_t)0x6e473df0, (q31_t)0xbf048824, (q31_t)0x6e440d37, (q31_t)0xbeff1e6c, (q31_t)0x6e40dc39, (q31_t)0xbef9b4dc, - (q31_t)0x6e3daaf8, (q31_t)0xbef44b74, (q31_t)0x6e3a7972, (q31_t)0xbeeee234, (q31_t)0x6e3747a9, (q31_t)0xbee9791c, (q31_t)0x6e34159b, (q31_t)0xbee4102d, - (q31_t)0x6e30e34a, (q31_t)0xbedea765, (q31_t)0x6e2db0b4, (q31_t)0xbed93ec6, (q31_t)0x6e2a7ddb, (q31_t)0xbed3d64f, (q31_t)0x6e274abe, (q31_t)0xbece6e00, - (q31_t)0x6e24175c, (q31_t)0xbec905d9, (q31_t)0x6e20e3b7, (q31_t)0xbec39ddb, (q31_t)0x6e1dafce, (q31_t)0xbebe3605, (q31_t)0x6e1a7ba1, (q31_t)0xbeb8ce57, - (q31_t)0x6e174730, (q31_t)0xbeb366d1, (q31_t)0x6e14127b, (q31_t)0xbeadff74, (q31_t)0x6e10dd82, (q31_t)0xbea8983f, (q31_t)0x6e0da845, (q31_t)0xbea33132, - (q31_t)0x6e0a72c5, (q31_t)0xbe9dca4e, (q31_t)0x6e073d00, (q31_t)0xbe986391, (q31_t)0x6e0406f8, (q31_t)0xbe92fcfe, (q31_t)0x6e00d0ac, (q31_t)0xbe8d9692, - (q31_t)0x6dfd9a1c, (q31_t)0xbe88304f, (q31_t)0x6dfa6348, (q31_t)0xbe82ca35, (q31_t)0x6df72c30, (q31_t)0xbe7d6442, (q31_t)0x6df3f4d4, (q31_t)0xbe77fe78, - (q31_t)0x6df0bd35, (q31_t)0xbe7298d7, (q31_t)0x6ded8552, (q31_t)0xbe6d335e, (q31_t)0x6dea4d2b, (q31_t)0xbe67ce0d, (q31_t)0x6de714c0, (q31_t)0xbe6268e5, - (q31_t)0x6de3dc11, (q31_t)0xbe5d03e6, (q31_t)0x6de0a31f, (q31_t)0xbe579f0f, (q31_t)0x6ddd69e9, (q31_t)0xbe523a60, (q31_t)0x6dda306f, (q31_t)0xbe4cd5da, - (q31_t)0x6dd6f6b1, (q31_t)0xbe47717c, (q31_t)0x6dd3bcaf, (q31_t)0xbe420d47, (q31_t)0x6dd0826a, (q31_t)0xbe3ca93b, (q31_t)0x6dcd47e1, (q31_t)0xbe374557, - (q31_t)0x6dca0d14, (q31_t)0xbe31e19b, (q31_t)0x6dc6d204, (q31_t)0xbe2c7e09, (q31_t)0x6dc396b0, (q31_t)0xbe271a9f, (q31_t)0x6dc05b18, (q31_t)0xbe21b75d, - (q31_t)0x6dbd1f3c, (q31_t)0xbe1c5444, (q31_t)0x6db9e31d, (q31_t)0xbe16f154, (q31_t)0x6db6a6ba, (q31_t)0xbe118e8c, (q31_t)0x6db36a14, (q31_t)0xbe0c2bed, - (q31_t)0x6db02d29, (q31_t)0xbe06c977, (q31_t)0x6daceffb, (q31_t)0xbe01672a, (q31_t)0x6da9b28a, (q31_t)0xbdfc0505, (q31_t)0x6da674d5, (q31_t)0xbdf6a309, - (q31_t)0x6da336dc, (q31_t)0xbdf14135, (q31_t)0x6d9ff89f, (q31_t)0xbdebdf8b, (q31_t)0x6d9cba1f, (q31_t)0xbde67e09, (q31_t)0x6d997b5b, (q31_t)0xbde11cb0, - (q31_t)0x6d963c54, (q31_t)0xbddbbb7f, (q31_t)0x6d92fd09, (q31_t)0xbdd65a78, (q31_t)0x6d8fbd7a, (q31_t)0xbdd0f999, (q31_t)0x6d8c7da8, (q31_t)0xbdcb98e3, - (q31_t)0x6d893d93, (q31_t)0xbdc63856, (q31_t)0x6d85fd39, (q31_t)0xbdc0d7f2, (q31_t)0x6d82bc9d, (q31_t)0xbdbb77b7, (q31_t)0x6d7f7bbc, (q31_t)0xbdb617a4, - (q31_t)0x6d7c3a98, (q31_t)0xbdb0b7bb, (q31_t)0x6d78f931, (q31_t)0xbdab57fa, (q31_t)0x6d75b786, (q31_t)0xbda5f862, (q31_t)0x6d727597, (q31_t)0xbda098f3, - (q31_t)0x6d6f3365, (q31_t)0xbd9b39ad, (q31_t)0x6d6bf0f0, (q31_t)0xbd95da91, (q31_t)0x6d68ae37, (q31_t)0xbd907b9d, (q31_t)0x6d656b3a, (q31_t)0xbd8b1cd2, - (q31_t)0x6d6227fa, (q31_t)0xbd85be30, (q31_t)0x6d5ee477, (q31_t)0xbd805fb7, (q31_t)0x6d5ba0b0, (q31_t)0xbd7b0167, (q31_t)0x6d585ca6, (q31_t)0xbd75a340, - (q31_t)0x6d551858, (q31_t)0xbd704542, (q31_t)0x6d51d3c6, (q31_t)0xbd6ae76d, (q31_t)0x6d4e8ef2, (q31_t)0xbd6589c1, (q31_t)0x6d4b49da, (q31_t)0xbd602c3f, - (q31_t)0x6d48047e, (q31_t)0xbd5acee5, (q31_t)0x6d44bedf, (q31_t)0xbd5571b5, (q31_t)0x6d4178fd, (q31_t)0xbd5014ad, (q31_t)0x6d3e32d7, (q31_t)0xbd4ab7cf, - (q31_t)0x6d3aec6e, (q31_t)0xbd455b1a, (q31_t)0x6d37a5c1, (q31_t)0xbd3ffe8e, (q31_t)0x6d345ed1, (q31_t)0xbd3aa22c, (q31_t)0x6d31179e, (q31_t)0xbd3545f2, - (q31_t)0x6d2dd027, (q31_t)0xbd2fe9e2, (q31_t)0x6d2a886e, (q31_t)0xbd2a8dfb, (q31_t)0x6d274070, (q31_t)0xbd25323d, (q31_t)0x6d23f830, (q31_t)0xbd1fd6a8, - (q31_t)0x6d20afac, (q31_t)0xbd1a7b3d, (q31_t)0x6d1d66e4, (q31_t)0xbd151ffb, (q31_t)0x6d1a1dda, (q31_t)0xbd0fc4e2, (q31_t)0x6d16d48c, (q31_t)0xbd0a69f2, - (q31_t)0x6d138afb, (q31_t)0xbd050f2c, (q31_t)0x6d104126, (q31_t)0xbcffb48f, (q31_t)0x6d0cf70f, (q31_t)0xbcfa5a1b, (q31_t)0x6d09acb4, (q31_t)0xbcf4ffd1, - (q31_t)0x6d066215, (q31_t)0xbcefa5b0, (q31_t)0x6d031734, (q31_t)0xbcea4bb9, (q31_t)0x6cffcc0f, (q31_t)0xbce4f1eb, (q31_t)0x6cfc80a7, (q31_t)0xbcdf9846, - (q31_t)0x6cf934fc, (q31_t)0xbcda3ecb, (q31_t)0x6cf5e90d, (q31_t)0xbcd4e579, (q31_t)0x6cf29cdc, (q31_t)0xbccf8c50, (q31_t)0x6cef5067, (q31_t)0xbcca3351, - (q31_t)0x6cec03af, (q31_t)0xbcc4da7b, (q31_t)0x6ce8b6b4, (q31_t)0xbcbf81cf, (q31_t)0x6ce56975, (q31_t)0xbcba294d, (q31_t)0x6ce21bf4, (q31_t)0xbcb4d0f4, - (q31_t)0x6cdece2f, (q31_t)0xbcaf78c4, (q31_t)0x6cdb8027, (q31_t)0xbcaa20be, (q31_t)0x6cd831dc, (q31_t)0xbca4c8e1, (q31_t)0x6cd4e34e, (q31_t)0xbc9f712e, - (q31_t)0x6cd1947c, (q31_t)0xbc9a19a5, (q31_t)0x6cce4568, (q31_t)0xbc94c245, (q31_t)0x6ccaf610, (q31_t)0xbc8f6b0f, (q31_t)0x6cc7a676, (q31_t)0xbc8a1402, - (q31_t)0x6cc45698, (q31_t)0xbc84bd1f, (q31_t)0x6cc10677, (q31_t)0xbc7f6665, (q31_t)0x6cbdb613, (q31_t)0xbc7a0fd6, (q31_t)0x6cba656c, (q31_t)0xbc74b96f, - (q31_t)0x6cb71482, (q31_t)0xbc6f6333, (q31_t)0x6cb3c355, (q31_t)0xbc6a0d20, (q31_t)0x6cb071e4, (q31_t)0xbc64b737, (q31_t)0x6cad2031, (q31_t)0xbc5f6177, - (q31_t)0x6ca9ce3b, (q31_t)0xbc5a0be2, (q31_t)0x6ca67c01, (q31_t)0xbc54b676, (q31_t)0x6ca32985, (q31_t)0xbc4f6134, (q31_t)0x6c9fd6c6, (q31_t)0xbc4a0c1b, - (q31_t)0x6c9c83c3, (q31_t)0xbc44b72c, (q31_t)0x6c99307e, (q31_t)0xbc3f6267, (q31_t)0x6c95dcf6, (q31_t)0xbc3a0dcc, (q31_t)0x6c92892a, (q31_t)0xbc34b95b, - (q31_t)0x6c8f351c, (q31_t)0xbc2f6513, (q31_t)0x6c8be0cb, (q31_t)0xbc2a10f6, (q31_t)0x6c888c36, (q31_t)0xbc24bd02, (q31_t)0x6c85375f, (q31_t)0xbc1f6938, - (q31_t)0x6c81e245, (q31_t)0xbc1a1598, (q31_t)0x6c7e8ce8, (q31_t)0xbc14c221, (q31_t)0x6c7b3748, (q31_t)0xbc0f6ed5, (q31_t)0x6c77e165, (q31_t)0xbc0a1bb3, - (q31_t)0x6c748b3f, (q31_t)0xbc04c8ba, (q31_t)0x6c7134d7, (q31_t)0xbbff75ec, (q31_t)0x6c6dde2b, (q31_t)0xbbfa2347, (q31_t)0x6c6a873d, (q31_t)0xbbf4d0cc, - (q31_t)0x6c67300b, (q31_t)0xbbef7e7c, (q31_t)0x6c63d897, (q31_t)0xbbea2c55, (q31_t)0x6c6080e0, (q31_t)0xbbe4da58, (q31_t)0x6c5d28e6, (q31_t)0xbbdf8885, - (q31_t)0x6c59d0a9, (q31_t)0xbbda36dd, (q31_t)0x6c56782a, (q31_t)0xbbd4e55e, (q31_t)0x6c531f67, (q31_t)0xbbcf940a, (q31_t)0x6c4fc662, (q31_t)0xbbca42df, - (q31_t)0x6c4c6d1a, (q31_t)0xbbc4f1df, (q31_t)0x6c49138f, (q31_t)0xbbbfa108, (q31_t)0x6c45b9c1, (q31_t)0xbbba505c, (q31_t)0x6c425fb1, (q31_t)0xbbb4ffda, - (q31_t)0x6c3f055d, (q31_t)0xbbafaf82, (q31_t)0x6c3baac7, (q31_t)0xbbaa5f54, (q31_t)0x6c384fef, (q31_t)0xbba50f50, (q31_t)0x6c34f4d3, (q31_t)0xbb9fbf77, - (q31_t)0x6c319975, (q31_t)0xbb9a6fc7, (q31_t)0x6c2e3dd4, (q31_t)0xbb952042, (q31_t)0x6c2ae1f0, (q31_t)0xbb8fd0e7, (q31_t)0x6c2785ca, (q31_t)0xbb8a81b6, - (q31_t)0x6c242960, (q31_t)0xbb8532b0, (q31_t)0x6c20ccb4, (q31_t)0xbb7fe3d3, (q31_t)0x6c1d6fc6, (q31_t)0xbb7a9521, (q31_t)0x6c1a1295, (q31_t)0xbb754699, - (q31_t)0x6c16b521, (q31_t)0xbb6ff83c, (q31_t)0x6c13576a, (q31_t)0xbb6aaa09, (q31_t)0x6c0ff971, (q31_t)0xbb655c00, (q31_t)0x6c0c9b35, (q31_t)0xbb600e21, - (q31_t)0x6c093cb6, (q31_t)0xbb5ac06d, (q31_t)0x6c05ddf5, (q31_t)0xbb5572e3, (q31_t)0x6c027ef1, (q31_t)0xbb502583, (q31_t)0x6bff1faa, (q31_t)0xbb4ad84e, - (q31_t)0x6bfbc021, (q31_t)0xbb458b43, (q31_t)0x6bf86055, (q31_t)0xbb403e63, (q31_t)0x6bf50047, (q31_t)0xbb3af1ad, (q31_t)0x6bf19ff6, (q31_t)0xbb35a521, - (q31_t)0x6bee3f62, (q31_t)0xbb3058c0, (q31_t)0x6beade8c, (q31_t)0xbb2b0c8a, (q31_t)0x6be77d74, (q31_t)0xbb25c07d, (q31_t)0x6be41c18, (q31_t)0xbb20749c, - (q31_t)0x6be0ba7b, (q31_t)0xbb1b28e4, (q31_t)0x6bdd589a, (q31_t)0xbb15dd57, (q31_t)0x6bd9f677, (q31_t)0xbb1091f5, (q31_t)0x6bd69412, (q31_t)0xbb0b46bd, - (q31_t)0x6bd3316a, (q31_t)0xbb05fbb0, (q31_t)0x6bcfce80, (q31_t)0xbb00b0ce, (q31_t)0x6bcc6b53, (q31_t)0xbafb6615, (q31_t)0x6bc907e3, (q31_t)0xbaf61b88, - (q31_t)0x6bc5a431, (q31_t)0xbaf0d125, (q31_t)0x6bc2403d, (q31_t)0xbaeb86ed, (q31_t)0x6bbedc06, (q31_t)0xbae63cdf, (q31_t)0x6bbb778d, (q31_t)0xbae0f2fc, - (q31_t)0x6bb812d1, (q31_t)0xbadba943, (q31_t)0x6bb4add3, (q31_t)0xbad65fb5, (q31_t)0x6bb14892, (q31_t)0xbad11652, (q31_t)0x6bade30f, (q31_t)0xbacbcd1a, - (q31_t)0x6baa7d49, (q31_t)0xbac6840c, (q31_t)0x6ba71741, (q31_t)0xbac13b29, (q31_t)0x6ba3b0f7, (q31_t)0xbabbf270, (q31_t)0x6ba04a6a, (q31_t)0xbab6a9e3, - (q31_t)0x6b9ce39b, (q31_t)0xbab16180, (q31_t)0x6b997c8a, (q31_t)0xbaac1948, (q31_t)0x6b961536, (q31_t)0xbaa6d13a, (q31_t)0x6b92ada0, (q31_t)0xbaa18958, - (q31_t)0x6b8f45c7, (q31_t)0xba9c41a0, (q31_t)0x6b8bddac, (q31_t)0xba96fa13, (q31_t)0x6b88754f, (q31_t)0xba91b2b1, (q31_t)0x6b850caf, (q31_t)0xba8c6b79, - (q31_t)0x6b81a3cd, (q31_t)0xba87246d, (q31_t)0x6b7e3aa9, (q31_t)0xba81dd8b, (q31_t)0x6b7ad142, (q31_t)0xba7c96d4, (q31_t)0x6b776799, (q31_t)0xba775048, - (q31_t)0x6b73fdae, (q31_t)0xba7209e7, (q31_t)0x6b709381, (q31_t)0xba6cc3b1, (q31_t)0x6b6d2911, (q31_t)0xba677da6, (q31_t)0x6b69be5f, (q31_t)0xba6237c5, - (q31_t)0x6b66536b, (q31_t)0xba5cf210, (q31_t)0x6b62e834, (q31_t)0xba57ac86, (q31_t)0x6b5f7cbc, (q31_t)0xba526726, (q31_t)0x6b5c1101, (q31_t)0xba4d21f2, - (q31_t)0x6b58a503, (q31_t)0xba47dce8, (q31_t)0x6b5538c4, (q31_t)0xba42980a, (q31_t)0x6b51cc42, (q31_t)0xba3d5356, (q31_t)0x6b4e5f7f, (q31_t)0xba380ece, - (q31_t)0x6b4af279, (q31_t)0xba32ca71, (q31_t)0x6b478530, (q31_t)0xba2d863e, (q31_t)0x6b4417a6, (q31_t)0xba284237, (q31_t)0x6b40a9d9, (q31_t)0xba22fe5b, - (q31_t)0x6b3d3bcb, (q31_t)0xba1dbaaa, (q31_t)0x6b39cd7a, (q31_t)0xba187724, (q31_t)0x6b365ee7, (q31_t)0xba1333c9, (q31_t)0x6b32f012, (q31_t)0xba0df099, - (q31_t)0x6b2f80fb, (q31_t)0xba08ad95, (q31_t)0x6b2c11a1, (q31_t)0xba036abb, (q31_t)0x6b28a206, (q31_t)0xb9fe280d, (q31_t)0x6b253228, (q31_t)0xb9f8e58a, - (q31_t)0x6b21c208, (q31_t)0xb9f3a332, (q31_t)0x6b1e51a7, (q31_t)0xb9ee6106, (q31_t)0x6b1ae103, (q31_t)0xb9e91f04, (q31_t)0x6b17701d, (q31_t)0xb9e3dd2e, - (q31_t)0x6b13fef5, (q31_t)0xb9de9b83, (q31_t)0x6b108d8b, (q31_t)0xb9d95a03, (q31_t)0x6b0d1bdf, (q31_t)0xb9d418af, (q31_t)0x6b09a9f1, (q31_t)0xb9ced786, - (q31_t)0x6b0637c1, (q31_t)0xb9c99688, (q31_t)0x6b02c54f, (q31_t)0xb9c455b6, (q31_t)0x6aff529a, (q31_t)0xb9bf150e, (q31_t)0x6afbdfa4, (q31_t)0xb9b9d493, - (q31_t)0x6af86c6c, (q31_t)0xb9b49442, (q31_t)0x6af4f8f2, (q31_t)0xb9af541d, (q31_t)0x6af18536, (q31_t)0xb9aa1423, (q31_t)0x6aee1138, (q31_t)0xb9a4d455, - (q31_t)0x6aea9cf8, (q31_t)0xb99f94b2, (q31_t)0x6ae72876, (q31_t)0xb99a553a, (q31_t)0x6ae3b3b2, (q31_t)0xb99515ee, (q31_t)0x6ae03eac, (q31_t)0xb98fd6cd, - (q31_t)0x6adcc964, (q31_t)0xb98a97d8, (q31_t)0x6ad953db, (q31_t)0xb985590e, (q31_t)0x6ad5de0f, (q31_t)0xb9801a70, (q31_t)0x6ad26802, (q31_t)0xb97adbfd, - (q31_t)0x6acef1b2, (q31_t)0xb9759db6, (q31_t)0x6acb7b21, (q31_t)0xb9705f9a, (q31_t)0x6ac8044e, (q31_t)0xb96b21aa, (q31_t)0x6ac48d39, (q31_t)0xb965e3e5, - (q31_t)0x6ac115e2, (q31_t)0xb960a64c, (q31_t)0x6abd9e49, (q31_t)0xb95b68de, (q31_t)0x6aba266e, (q31_t)0xb9562b9c, (q31_t)0x6ab6ae52, (q31_t)0xb950ee86, - (q31_t)0x6ab335f4, (q31_t)0xb94bb19b, (q31_t)0x6aafbd54, (q31_t)0xb94674dc, (q31_t)0x6aac4472, (q31_t)0xb9413848, (q31_t)0x6aa8cb4e, (q31_t)0xb93bfbe0, - (q31_t)0x6aa551e9, (q31_t)0xb936bfa4, (q31_t)0x6aa1d841, (q31_t)0xb9318393, (q31_t)0x6a9e5e58, (q31_t)0xb92c47ae, (q31_t)0x6a9ae42e, (q31_t)0xb9270bf5, - (q31_t)0x6a9769c1, (q31_t)0xb921d067, (q31_t)0x6a93ef13, (q31_t)0xb91c9505, (q31_t)0x6a907423, (q31_t)0xb91759cf, (q31_t)0x6a8cf8f1, (q31_t)0xb9121ec5, - (q31_t)0x6a897d7d, (q31_t)0xb90ce3e6, (q31_t)0x6a8601c8, (q31_t)0xb907a933, (q31_t)0x6a8285d1, (q31_t)0xb9026eac, (q31_t)0x6a7f0999, (q31_t)0xb8fd3451, - (q31_t)0x6a7b8d1e, (q31_t)0xb8f7fa21, (q31_t)0x6a781062, (q31_t)0xb8f2c01d, (q31_t)0x6a749365, (q31_t)0xb8ed8646, (q31_t)0x6a711625, (q31_t)0xb8e84c99, - (q31_t)0x6a6d98a4, (q31_t)0xb8e31319, (q31_t)0x6a6a1ae2, (q31_t)0xb8ddd9c5, (q31_t)0x6a669cdd, (q31_t)0xb8d8a09d, (q31_t)0x6a631e97, (q31_t)0xb8d367a0, - (q31_t)0x6a5fa010, (q31_t)0xb8ce2ecf, (q31_t)0x6a5c2147, (q31_t)0xb8c8f62b, (q31_t)0x6a58a23c, (q31_t)0xb8c3bdb2, (q31_t)0x6a5522ef, (q31_t)0xb8be8565, - (q31_t)0x6a51a361, (q31_t)0xb8b94d44, (q31_t)0x6a4e2392, (q31_t)0xb8b4154f, (q31_t)0x6a4aa381, (q31_t)0xb8aedd86, (q31_t)0x6a47232e, (q31_t)0xb8a9a5e9, - (q31_t)0x6a43a29a, (q31_t)0xb8a46e78, (q31_t)0x6a4021c4, (q31_t)0xb89f3733, (q31_t)0x6a3ca0ad, (q31_t)0xb89a001a, (q31_t)0x6a391f54, (q31_t)0xb894c92d, - (q31_t)0x6a359db9, (q31_t)0xb88f926d, (q31_t)0x6a321bdd, (q31_t)0xb88a5bd8, (q31_t)0x6a2e99c0, (q31_t)0xb885256f, (q31_t)0x6a2b1761, (q31_t)0xb87fef33, - (q31_t)0x6a2794c1, (q31_t)0xb87ab922, (q31_t)0x6a2411df, (q31_t)0xb875833e, (q31_t)0x6a208ebb, (q31_t)0xb8704d85, (q31_t)0x6a1d0b57, (q31_t)0xb86b17f9, - (q31_t)0x6a1987b0, (q31_t)0xb865e299, (q31_t)0x6a1603c8, (q31_t)0xb860ad66, (q31_t)0x6a127f9f, (q31_t)0xb85b785e, (q31_t)0x6a0efb35, (q31_t)0xb8564383, - (q31_t)0x6a0b7689, (q31_t)0xb8510ed4, (q31_t)0x6a07f19b, (q31_t)0xb84bda51, (q31_t)0x6a046c6c, (q31_t)0xb846a5fa, (q31_t)0x6a00e6fc, (q31_t)0xb84171cf, - (q31_t)0x69fd614a, (q31_t)0xb83c3dd1, (q31_t)0x69f9db57, (q31_t)0xb83709ff, (q31_t)0x69f65523, (q31_t)0xb831d659, (q31_t)0x69f2cead, (q31_t)0xb82ca2e0, - (q31_t)0x69ef47f6, (q31_t)0xb8276f93, (q31_t)0x69ebc0fe, (q31_t)0xb8223c72, (q31_t)0x69e839c4, (q31_t)0xb81d097e, (q31_t)0x69e4b249, (q31_t)0xb817d6b6, - (q31_t)0x69e12a8c, (q31_t)0xb812a41a, (q31_t)0x69dda28f, (q31_t)0xb80d71aa, (q31_t)0x69da1a50, (q31_t)0xb8083f67, (q31_t)0x69d691cf, (q31_t)0xb8030d51, - (q31_t)0x69d3090e, (q31_t)0xb7fddb67, (q31_t)0x69cf800b, (q31_t)0xb7f8a9a9, (q31_t)0x69cbf6c7, (q31_t)0xb7f37818, (q31_t)0x69c86d41, (q31_t)0xb7ee46b3, - (q31_t)0x69c4e37a, (q31_t)0xb7e9157a, (q31_t)0x69c15973, (q31_t)0xb7e3e46e, (q31_t)0x69bdcf29, (q31_t)0xb7deb38f, (q31_t)0x69ba449f, (q31_t)0xb7d982dc, - (q31_t)0x69b6b9d3, (q31_t)0xb7d45255, (q31_t)0x69b32ec7, (q31_t)0xb7cf21fb, (q31_t)0x69afa378, (q31_t)0xb7c9f1ce, (q31_t)0x69ac17e9, (q31_t)0xb7c4c1cd, - (q31_t)0x69a88c19, (q31_t)0xb7bf91f8, (q31_t)0x69a50007, (q31_t)0xb7ba6251, (q31_t)0x69a173b5, (q31_t)0xb7b532d6, (q31_t)0x699de721, (q31_t)0xb7b00387, - (q31_t)0x699a5a4c, (q31_t)0xb7aad465, (q31_t)0x6996cd35, (q31_t)0xb7a5a570, (q31_t)0x69933fde, (q31_t)0xb7a076a7, (q31_t)0x698fb246, (q31_t)0xb79b480b, - (q31_t)0x698c246c, (q31_t)0xb796199b, (q31_t)0x69889651, (q31_t)0xb790eb58, (q31_t)0x698507f6, (q31_t)0xb78bbd42, (q31_t)0x69817959, (q31_t)0xb7868f59, - (q31_t)0x697dea7b, (q31_t)0xb781619c, (q31_t)0x697a5b5c, (q31_t)0xb77c340c, (q31_t)0x6976cbfc, (q31_t)0xb77706a9, (q31_t)0x69733c5b, (q31_t)0xb771d972, - (q31_t)0x696fac78, (q31_t)0xb76cac69, (q31_t)0x696c1c55, (q31_t)0xb7677f8c, (q31_t)0x69688bf1, (q31_t)0xb76252db, (q31_t)0x6964fb4c, (q31_t)0xb75d2658, - (q31_t)0x69616a65, (q31_t)0xb757fa01, (q31_t)0x695dd93e, (q31_t)0xb752cdd8, (q31_t)0x695a47d6, (q31_t)0xb74da1db, (q31_t)0x6956b62d, (q31_t)0xb748760b, - (q31_t)0x69532442, (q31_t)0xb7434a67, (q31_t)0x694f9217, (q31_t)0xb73e1ef1, (q31_t)0x694bffab, (q31_t)0xb738f3a7, (q31_t)0x69486cfe, (q31_t)0xb733c88b, - (q31_t)0x6944da10, (q31_t)0xb72e9d9b, (q31_t)0x694146e1, (q31_t)0xb72972d8, (q31_t)0x693db371, (q31_t)0xb7244842, (q31_t)0x693a1fc0, (q31_t)0xb71f1dd9, - (q31_t)0x69368bce, (q31_t)0xb719f39e, (q31_t)0x6932f79b, (q31_t)0xb714c98e, (q31_t)0x692f6328, (q31_t)0xb70f9fac, (q31_t)0x692bce73, (q31_t)0xb70a75f7, - (q31_t)0x6928397e, (q31_t)0xb7054c6f, (q31_t)0x6924a448, (q31_t)0xb7002314, (q31_t)0x69210ed1, (q31_t)0xb6faf9e6, (q31_t)0x691d7919, (q31_t)0xb6f5d0e5, - (q31_t)0x6919e320, (q31_t)0xb6f0a812, (q31_t)0x69164ce7, (q31_t)0xb6eb7f6b, (q31_t)0x6912b66c, (q31_t)0xb6e656f1, (q31_t)0x690f1fb1, (q31_t)0xb6e12ea4, - (q31_t)0x690b88b5, (q31_t)0xb6dc0685, (q31_t)0x6907f178, (q31_t)0xb6d6de92, (q31_t)0x690459fb, (q31_t)0xb6d1b6cd, (q31_t)0x6900c23c, (q31_t)0xb6cc8f35, - (q31_t)0x68fd2a3d, (q31_t)0xb6c767ca, (q31_t)0x68f991fd, (q31_t)0xb6c2408c, (q31_t)0x68f5f97d, (q31_t)0xb6bd197c, (q31_t)0x68f260bb, (q31_t)0xb6b7f298, - (q31_t)0x68eec7b9, (q31_t)0xb6b2cbe2, (q31_t)0x68eb2e76, (q31_t)0xb6ada559, (q31_t)0x68e794f3, (q31_t)0xb6a87efd, (q31_t)0x68e3fb2e, (q31_t)0xb6a358ce, - (q31_t)0x68e06129, (q31_t)0xb69e32cd, (q31_t)0x68dcc6e4, (q31_t)0xb6990cf9, (q31_t)0x68d92c5d, (q31_t)0xb693e752, (q31_t)0x68d59196, (q31_t)0xb68ec1d9, - (q31_t)0x68d1f68f, (q31_t)0xb6899c8d, (q31_t)0x68ce5b46, (q31_t)0xb684776e, (q31_t)0x68cabfbd, (q31_t)0xb67f527c, (q31_t)0x68c723f3, (q31_t)0xb67a2db8, - (q31_t)0x68c387e9, (q31_t)0xb6750921, (q31_t)0x68bfeb9e, (q31_t)0xb66fe4b8, (q31_t)0x68bc4f13, (q31_t)0xb66ac07c, (q31_t)0x68b8b247, (q31_t)0xb6659c6d, - (q31_t)0x68b5153a, (q31_t)0xb660788c, (q31_t)0x68b177ed, (q31_t)0xb65b54d8, (q31_t)0x68adda5f, (q31_t)0xb6563151, (q31_t)0x68aa3c90, (q31_t)0xb6510df8, - (q31_t)0x68a69e81, (q31_t)0xb64beacd, (q31_t)0x68a30031, (q31_t)0xb646c7ce, (q31_t)0x689f61a1, (q31_t)0xb641a4fe, (q31_t)0x689bc2d1, (q31_t)0xb63c825b, - (q31_t)0x689823bf, (q31_t)0xb6375fe5, (q31_t)0x6894846e, (q31_t)0xb6323d9d, (q31_t)0x6890e4dc, (q31_t)0xb62d1b82, (q31_t)0x688d4509, (q31_t)0xb627f995, - (q31_t)0x6889a4f6, (q31_t)0xb622d7d6, (q31_t)0x688604a2, (q31_t)0xb61db644, (q31_t)0x6882640e, (q31_t)0xb61894df, (q31_t)0x687ec339, (q31_t)0xb61373a9, - (q31_t)0x687b2224, (q31_t)0xb60e529f, (q31_t)0x687780ce, (q31_t)0xb60931c4, (q31_t)0x6873df38, (q31_t)0xb6041116, (q31_t)0x68703d62, (q31_t)0xb5fef095, - (q31_t)0x686c9b4b, (q31_t)0xb5f9d043, (q31_t)0x6868f8f4, (q31_t)0xb5f4b01e, (q31_t)0x6865565c, (q31_t)0xb5ef9026, (q31_t)0x6861b384, (q31_t)0xb5ea705d, - (q31_t)0x685e106c, (q31_t)0xb5e550c1, (q31_t)0x685a6d13, (q31_t)0xb5e03153, (q31_t)0x6856c979, (q31_t)0xb5db1212, (q31_t)0x685325a0, (q31_t)0xb5d5f2ff, - (q31_t)0x684f8186, (q31_t)0xb5d0d41a, (q31_t)0x684bdd2c, (q31_t)0xb5cbb563, (q31_t)0x68483891, (q31_t)0xb5c696da, (q31_t)0x684493b6, (q31_t)0xb5c1787e, - (q31_t)0x6840ee9b, (q31_t)0xb5bc5a50, (q31_t)0x683d493f, (q31_t)0xb5b73c50, (q31_t)0x6839a3a4, (q31_t)0xb5b21e7e, (q31_t)0x6835fdc7, (q31_t)0xb5ad00d9, - (q31_t)0x683257ab, (q31_t)0xb5a7e362, (q31_t)0x682eb14e, (q31_t)0xb5a2c61a, (q31_t)0x682b0ab1, (q31_t)0xb59da8ff, (q31_t)0x682763d4, (q31_t)0xb5988c12, - (q31_t)0x6823bcb7, (q31_t)0xb5936f53, (q31_t)0x68201559, (q31_t)0xb58e52c2, (q31_t)0x681c6dbb, (q31_t)0xb589365e, (q31_t)0x6818c5dd, (q31_t)0xb5841a29, - (q31_t)0x68151dbe, (q31_t)0xb57efe22, (q31_t)0x68117560, (q31_t)0xb579e248, (q31_t)0x680dccc1, (q31_t)0xb574c69d, (q31_t)0x680a23e2, (q31_t)0xb56fab1f, - (q31_t)0x68067ac3, (q31_t)0xb56a8fd0, (q31_t)0x6802d164, (q31_t)0xb56574ae, (q31_t)0x67ff27c4, (q31_t)0xb56059bb, (q31_t)0x67fb7de5, (q31_t)0xb55b3ef5, - (q31_t)0x67f7d3c5, (q31_t)0xb556245e, (q31_t)0x67f42965, (q31_t)0xb55109f5, (q31_t)0x67f07ec5, (q31_t)0xb54befba, (q31_t)0x67ecd3e5, (q31_t)0xb546d5ac, - (q31_t)0x67e928c5, (q31_t)0xb541bbcd, (q31_t)0x67e57d64, (q31_t)0xb53ca21c, (q31_t)0x67e1d1c4, (q31_t)0xb5378899, (q31_t)0x67de25e3, (q31_t)0xb5326f45, - (q31_t)0x67da79c3, (q31_t)0xb52d561e, (q31_t)0x67d6cd62, (q31_t)0xb5283d26, (q31_t)0x67d320c1, (q31_t)0xb523245b, (q31_t)0x67cf73e1, (q31_t)0xb51e0bbf, - (q31_t)0x67cbc6c0, (q31_t)0xb518f351, (q31_t)0x67c8195f, (q31_t)0xb513db12, (q31_t)0x67c46bbe, (q31_t)0xb50ec300, (q31_t)0x67c0bddd, (q31_t)0xb509ab1d, - (q31_t)0x67bd0fbd, (q31_t)0xb5049368, (q31_t)0x67b9615c, (q31_t)0xb4ff7be1, (q31_t)0x67b5b2bb, (q31_t)0xb4fa6489, (q31_t)0x67b203da, (q31_t)0xb4f54d5f, - (q31_t)0x67ae54ba, (q31_t)0xb4f03663, (q31_t)0x67aaa559, (q31_t)0xb4eb1f95, (q31_t)0x67a6f5b8, (q31_t)0xb4e608f6, (q31_t)0x67a345d8, (q31_t)0xb4e0f285, - (q31_t)0x679f95b7, (q31_t)0xb4dbdc42, (q31_t)0x679be557, (q31_t)0xb4d6c62e, (q31_t)0x679834b6, (q31_t)0xb4d1b048, (q31_t)0x679483d6, (q31_t)0xb4cc9a90, - (q31_t)0x6790d2b6, (q31_t)0xb4c78507, (q31_t)0x678d2156, (q31_t)0xb4c26fad, (q31_t)0x67896fb6, (q31_t)0xb4bd5a80, (q31_t)0x6785bdd6, (q31_t)0xb4b84582, - (q31_t)0x67820bb7, (q31_t)0xb4b330b3, (q31_t)0x677e5957, (q31_t)0xb4ae1c12, (q31_t)0x677aa6b8, (q31_t)0xb4a9079f, (q31_t)0x6776f3d9, (q31_t)0xb4a3f35b, - (q31_t)0x677340ba, (q31_t)0xb49edf45, (q31_t)0x676f8d5b, (q31_t)0xb499cb5e, (q31_t)0x676bd9bd, (q31_t)0xb494b7a6, (q31_t)0x676825de, (q31_t)0xb48fa41c, - (q31_t)0x676471c0, (q31_t)0xb48a90c0, (q31_t)0x6760bd62, (q31_t)0xb4857d93, (q31_t)0x675d08c4, (q31_t)0xb4806a95, (q31_t)0x675953e7, (q31_t)0xb47b57c5, - (q31_t)0x67559eca, (q31_t)0xb4764523, (q31_t)0x6751e96d, (q31_t)0xb47132b1, (q31_t)0x674e33d0, (q31_t)0xb46c206d, (q31_t)0x674a7df4, (q31_t)0xb4670e57, - (q31_t)0x6746c7d8, (q31_t)0xb461fc70, (q31_t)0x6743117c, (q31_t)0xb45ceab8, (q31_t)0x673f5ae0, (q31_t)0xb457d92f, (q31_t)0x673ba405, (q31_t)0xb452c7d4, - (q31_t)0x6737ecea, (q31_t)0xb44db6a8, (q31_t)0x67343590, (q31_t)0xb448a5aa, (q31_t)0x67307df5, (q31_t)0xb44394db, (q31_t)0x672cc61c, (q31_t)0xb43e843b, - (q31_t)0x67290e02, (q31_t)0xb43973ca, (q31_t)0x672555a9, (q31_t)0xb4346387, (q31_t)0x67219d10, (q31_t)0xb42f5373, (q31_t)0x671de438, (q31_t)0xb42a438e, - (q31_t)0x671a2b20, (q31_t)0xb42533d8, (q31_t)0x671671c8, (q31_t)0xb4202451, (q31_t)0x6712b831, (q31_t)0xb41b14f8, (q31_t)0x670efe5a, (q31_t)0xb41605ce, - (q31_t)0x670b4444, (q31_t)0xb410f6d3, (q31_t)0x670789ee, (q31_t)0xb40be807, (q31_t)0x6703cf58, (q31_t)0xb406d969, (q31_t)0x67001483, (q31_t)0xb401cafb, - (q31_t)0x66fc596f, (q31_t)0xb3fcbcbb, (q31_t)0x66f89e1b, (q31_t)0xb3f7aeaa, (q31_t)0x66f4e287, (q31_t)0xb3f2a0c9, (q31_t)0x66f126b4, (q31_t)0xb3ed9316, - (q31_t)0x66ed6aa1, (q31_t)0xb3e88592, (q31_t)0x66e9ae4f, (q31_t)0xb3e3783d, (q31_t)0x66e5f1be, (q31_t)0xb3de6b17, (q31_t)0x66e234ed, (q31_t)0xb3d95e1f, - (q31_t)0x66de77dc, (q31_t)0xb3d45157, (q31_t)0x66daba8c, (q31_t)0xb3cf44be, (q31_t)0x66d6fcfd, (q31_t)0xb3ca3854, (q31_t)0x66d33f2e, (q31_t)0xb3c52c19, - (q31_t)0x66cf8120, (q31_t)0xb3c0200c, (q31_t)0x66cbc2d2, (q31_t)0xb3bb142f, (q31_t)0x66c80445, (q31_t)0xb3b60881, (q31_t)0x66c44579, (q31_t)0xb3b0fd02, - (q31_t)0x66c0866d, (q31_t)0xb3abf1b2, (q31_t)0x66bcc721, (q31_t)0xb3a6e691, (q31_t)0x66b90797, (q31_t)0xb3a1dba0, (q31_t)0x66b547cd, (q31_t)0xb39cd0dd, - (q31_t)0x66b187c3, (q31_t)0xb397c649, (q31_t)0x66adc77b, (q31_t)0xb392bbe5, (q31_t)0x66aa06f3, (q31_t)0xb38db1b0, (q31_t)0x66a6462b, (q31_t)0xb388a7aa, - (q31_t)0x66a28524, (q31_t)0xb3839dd3, (q31_t)0x669ec3de, (q31_t)0xb37e942b, (q31_t)0x669b0259, (q31_t)0xb3798ab2, (q31_t)0x66974095, (q31_t)0xb3748169, - (q31_t)0x66937e91, (q31_t)0xb36f784f, (q31_t)0x668fbc4e, (q31_t)0xb36a6f64, (q31_t)0x668bf9cb, (q31_t)0xb36566a8, (q31_t)0x66883709, (q31_t)0xb3605e1c, - (q31_t)0x66847408, (q31_t)0xb35b55bf, (q31_t)0x6680b0c8, (q31_t)0xb3564d91, (q31_t)0x667ced49, (q31_t)0xb3514592, (q31_t)0x6679298a, (q31_t)0xb34c3dc3, - (q31_t)0x6675658c, (q31_t)0xb3473623, (q31_t)0x6671a14f, (q31_t)0xb3422eb2, (q31_t)0x666ddcd3, (q31_t)0xb33d2771, (q31_t)0x666a1818, (q31_t)0xb338205f, - (q31_t)0x6666531d, (q31_t)0xb333197c, (q31_t)0x66628de4, (q31_t)0xb32e12c9, (q31_t)0x665ec86b, (q31_t)0xb3290c45, (q31_t)0x665b02b3, (q31_t)0xb32405f1, - (q31_t)0x66573cbb, (q31_t)0xb31effcc, (q31_t)0x66537685, (q31_t)0xb319f9d6, (q31_t)0x664fb010, (q31_t)0xb314f410, (q31_t)0x664be95b, (q31_t)0xb30fee79, - (q31_t)0x66482267, (q31_t)0xb30ae912, (q31_t)0x66445b35, (q31_t)0xb305e3da, (q31_t)0x664093c3, (q31_t)0xb300ded2, (q31_t)0x663ccc12, (q31_t)0xb2fbd9f9, - (q31_t)0x66390422, (q31_t)0xb2f6d550, (q31_t)0x66353bf3, (q31_t)0xb2f1d0d6, (q31_t)0x66317385, (q31_t)0xb2eccc8c, (q31_t)0x662daad8, (q31_t)0xb2e7c871, - (q31_t)0x6629e1ec, (q31_t)0xb2e2c486, (q31_t)0x662618c1, (q31_t)0xb2ddc0ca, (q31_t)0x66224f56, (q31_t)0xb2d8bd3e, (q31_t)0x661e85ad, (q31_t)0xb2d3b9e2, - (q31_t)0x661abbc5, (q31_t)0xb2ceb6b5, (q31_t)0x6616f19e, (q31_t)0xb2c9b3b8, (q31_t)0x66132738, (q31_t)0xb2c4b0ea, (q31_t)0x660f5c93, (q31_t)0xb2bfae4c, - (q31_t)0x660b91af, (q31_t)0xb2baabde, (q31_t)0x6607c68c, (q31_t)0xb2b5a99f, (q31_t)0x6603fb2a, (q31_t)0xb2b0a790, (q31_t)0x66002f89, (q31_t)0xb2aba5b1, - (q31_t)0x65fc63a9, (q31_t)0xb2a6a402, (q31_t)0x65f8978b, (q31_t)0xb2a1a282, (q31_t)0x65f4cb2d, (q31_t)0xb29ca132, (q31_t)0x65f0fe91, (q31_t)0xb297a011, - (q31_t)0x65ed31b5, (q31_t)0xb2929f21, (q31_t)0x65e9649b, (q31_t)0xb28d9e60, (q31_t)0x65e59742, (q31_t)0xb2889dcf, (q31_t)0x65e1c9aa, (q31_t)0xb2839d6d, - (q31_t)0x65ddfbd3, (q31_t)0xb27e9d3c, (q31_t)0x65da2dbd, (q31_t)0xb2799d3a, (q31_t)0x65d65f69, (q31_t)0xb2749d68, (q31_t)0x65d290d6, (q31_t)0xb26f9dc6, - (q31_t)0x65cec204, (q31_t)0xb26a9e54, (q31_t)0x65caf2f3, (q31_t)0xb2659f12, (q31_t)0x65c723a3, (q31_t)0xb2609fff, (q31_t)0x65c35415, (q31_t)0xb25ba11d, - (q31_t)0x65bf8447, (q31_t)0xb256a26a, (q31_t)0x65bbb43b, (q31_t)0xb251a3e7, (q31_t)0x65b7e3f1, (q31_t)0xb24ca594, (q31_t)0x65b41367, (q31_t)0xb247a771, - (q31_t)0x65b0429f, (q31_t)0xb242a97e, (q31_t)0x65ac7198, (q31_t)0xb23dabbb, (q31_t)0x65a8a052, (q31_t)0xb238ae28, (q31_t)0x65a4cece, (q31_t)0xb233b0c5, - (q31_t)0x65a0fd0b, (q31_t)0xb22eb392, (q31_t)0x659d2b09, (q31_t)0xb229b68f, (q31_t)0x659958c9, (q31_t)0xb224b9bc, (q31_t)0x6595864a, (q31_t)0xb21fbd19, - (q31_t)0x6591b38c, (q31_t)0xb21ac0a6, (q31_t)0x658de08f, (q31_t)0xb215c463, (q31_t)0x658a0d54, (q31_t)0xb210c850, (q31_t)0x658639db, (q31_t)0xb20bcc6d, - (q31_t)0x65826622, (q31_t)0xb206d0ba, (q31_t)0x657e922b, (q31_t)0xb201d537, (q31_t)0x657abdf6, (q31_t)0xb1fcd9e5, (q31_t)0x6576e982, (q31_t)0xb1f7dec2, - (q31_t)0x657314cf, (q31_t)0xb1f2e3d0, (q31_t)0x656f3fde, (q31_t)0xb1ede90e, (q31_t)0x656b6aae, (q31_t)0xb1e8ee7c, (q31_t)0x6567953f, (q31_t)0xb1e3f41a, - (q31_t)0x6563bf92, (q31_t)0xb1def9e9, (q31_t)0x655fe9a7, (q31_t)0xb1d9ffe7, (q31_t)0x655c137d, (q31_t)0xb1d50616, (q31_t)0x65583d14, (q31_t)0xb1d00c75, - (q31_t)0x6554666d, (q31_t)0xb1cb1304, (q31_t)0x65508f87, (q31_t)0xb1c619c3, (q31_t)0x654cb863, (q31_t)0xb1c120b3, (q31_t)0x6548e101, (q31_t)0xb1bc27d3, - (q31_t)0x6545095f, (q31_t)0xb1b72f23, (q31_t)0x65413180, (q31_t)0xb1b236a4, (q31_t)0x653d5962, (q31_t)0xb1ad3e55, (q31_t)0x65398105, (q31_t)0xb1a84636, - (q31_t)0x6535a86b, (q31_t)0xb1a34e47, (q31_t)0x6531cf91, (q31_t)0xb19e5689, (q31_t)0x652df679, (q31_t)0xb1995efb, (q31_t)0x652a1d23, (q31_t)0xb194679e, - (q31_t)0x6526438f, (q31_t)0xb18f7071, (q31_t)0x652269bc, (q31_t)0xb18a7974, (q31_t)0x651e8faa, (q31_t)0xb18582a8, (q31_t)0x651ab55b, (q31_t)0xb1808c0c, - (q31_t)0x6516dacd, (q31_t)0xb17b95a0, (q31_t)0x65130000, (q31_t)0xb1769f65, (q31_t)0x650f24f5, (q31_t)0xb171a95b, (q31_t)0x650b49ac, (q31_t)0xb16cb380, - (q31_t)0x65076e25, (q31_t)0xb167bdd7, (q31_t)0x6503925f, (q31_t)0xb162c85d, (q31_t)0x64ffb65b, (q31_t)0xb15dd315, (q31_t)0x64fbda18, (q31_t)0xb158ddfd, - (q31_t)0x64f7fd98, (q31_t)0xb153e915, (q31_t)0x64f420d9, (q31_t)0xb14ef45e, (q31_t)0x64f043dc, (q31_t)0xb149ffd7, (q31_t)0x64ec66a0, (q31_t)0xb1450b81, - (q31_t)0x64e88926, (q31_t)0xb140175b, (q31_t)0x64e4ab6e, (q31_t)0xb13b2367, (q31_t)0x64e0cd78, (q31_t)0xb1362fa2, (q31_t)0x64dcef44, (q31_t)0xb1313c0e, - (q31_t)0x64d910d1, (q31_t)0xb12c48ab, (q31_t)0x64d53220, (q31_t)0xb1275579, (q31_t)0x64d15331, (q31_t)0xb1226277, (q31_t)0x64cd7404, (q31_t)0xb11d6fa6, - (q31_t)0x64c99498, (q31_t)0xb1187d05, (q31_t)0x64c5b4ef, (q31_t)0xb1138a95, (q31_t)0x64c1d507, (q31_t)0xb10e9856, (q31_t)0x64bdf4e1, (q31_t)0xb109a648, - (q31_t)0x64ba147d, (q31_t)0xb104b46a, (q31_t)0x64b633da, (q31_t)0xb0ffc2bd, (q31_t)0x64b252fa, (q31_t)0xb0fad140, (q31_t)0x64ae71dc, (q31_t)0xb0f5dff5, - (q31_t)0x64aa907f, (q31_t)0xb0f0eeda, (q31_t)0x64a6aee4, (q31_t)0xb0ebfdf0, (q31_t)0x64a2cd0c, (q31_t)0xb0e70d37, (q31_t)0x649eeaf5, (q31_t)0xb0e21cae, - (q31_t)0x649b08a0, (q31_t)0xb0dd2c56, (q31_t)0x6497260d, (q31_t)0xb0d83c2f, (q31_t)0x6493433c, (q31_t)0xb0d34c39, (q31_t)0x648f602d, (q31_t)0xb0ce5c74, - (q31_t)0x648b7ce0, (q31_t)0xb0c96ce0, (q31_t)0x64879955, (q31_t)0xb0c47d7c, (q31_t)0x6483b58c, (q31_t)0xb0bf8e4a, (q31_t)0x647fd185, (q31_t)0xb0ba9f48, - (q31_t)0x647bed3f, (q31_t)0xb0b5b077, (q31_t)0x647808bc, (q31_t)0xb0b0c1d7, (q31_t)0x647423fb, (q31_t)0xb0abd368, (q31_t)0x64703efc, (q31_t)0xb0a6e52a, - (q31_t)0x646c59bf, (q31_t)0xb0a1f71d, (q31_t)0x64687444, (q31_t)0xb09d0941, (q31_t)0x64648e8c, (q31_t)0xb0981b96, (q31_t)0x6460a895, (q31_t)0xb0932e1b, - (q31_t)0x645cc260, (q31_t)0xb08e40d2, (q31_t)0x6458dbed, (q31_t)0xb08953ba, (q31_t)0x6454f53d, (q31_t)0xb08466d3, (q31_t)0x64510e4e, (q31_t)0xb07f7a1c, - (q31_t)0x644d2722, (q31_t)0xb07a8d97, (q31_t)0x64493fb8, (q31_t)0xb075a143, (q31_t)0x64455810, (q31_t)0xb070b520, (q31_t)0x6441702a, (q31_t)0xb06bc92e, - (q31_t)0x643d8806, (q31_t)0xb066dd6d, (q31_t)0x64399fa5, (q31_t)0xb061f1de, (q31_t)0x6435b706, (q31_t)0xb05d067f, (q31_t)0x6431ce28, (q31_t)0xb0581b51, - (q31_t)0x642de50d, (q31_t)0xb0533055, (q31_t)0x6429fbb5, (q31_t)0xb04e458a, (q31_t)0x6426121e, (q31_t)0xb0495af0, (q31_t)0x6422284a, (q31_t)0xb0447087, - (q31_t)0x641e3e38, (q31_t)0xb03f864f, (q31_t)0x641a53e8, (q31_t)0xb03a9c49, (q31_t)0x6416695a, (q31_t)0xb035b273, (q31_t)0x64127e8f, (q31_t)0xb030c8cf, - (q31_t)0x640e9386, (q31_t)0xb02bdf5c, (q31_t)0x640aa83f, (q31_t)0xb026f61b, (q31_t)0x6406bcba, (q31_t)0xb0220d0a, (q31_t)0x6402d0f8, (q31_t)0xb01d242b, - (q31_t)0x63fee4f8, (q31_t)0xb0183b7d, (q31_t)0x63faf8bb, (q31_t)0xb0135301, (q31_t)0x63f70c3f, (q31_t)0xb00e6ab5, (q31_t)0x63f31f86, (q31_t)0xb009829c, - (q31_t)0x63ef3290, (q31_t)0xb0049ab3, (q31_t)0x63eb455c, (q31_t)0xafffb2fc, (q31_t)0x63e757ea, (q31_t)0xaffacb76, (q31_t)0x63e36a3a, (q31_t)0xaff5e421, - (q31_t)0x63df7c4d, (q31_t)0xaff0fcfe, (q31_t)0x63db8e22, (q31_t)0xafec160c, (q31_t)0x63d79fba, (q31_t)0xafe72f4c, (q31_t)0x63d3b114, (q31_t)0xafe248bd, - (q31_t)0x63cfc231, (q31_t)0xafdd625f, (q31_t)0x63cbd310, (q31_t)0xafd87c33, (q31_t)0x63c7e3b1, (q31_t)0xafd39638, (q31_t)0x63c3f415, (q31_t)0xafceb06f, - (q31_t)0x63c0043b, (q31_t)0xafc9cad7, (q31_t)0x63bc1424, (q31_t)0xafc4e571, (q31_t)0x63b823cf, (q31_t)0xafc0003c, (q31_t)0x63b4333d, (q31_t)0xafbb1b39, - (q31_t)0x63b0426d, (q31_t)0xafb63667, (q31_t)0x63ac5160, (q31_t)0xafb151c7, (q31_t)0x63a86015, (q31_t)0xafac6d58, (q31_t)0x63a46e8d, (q31_t)0xafa7891b, - (q31_t)0x63a07cc7, (q31_t)0xafa2a50f, (q31_t)0x639c8ac4, (q31_t)0xaf9dc135, (q31_t)0x63989884, (q31_t)0xaf98dd8d, (q31_t)0x6394a606, (q31_t)0xaf93fa16, - (q31_t)0x6390b34a, (q31_t)0xaf8f16d1, (q31_t)0x638cc051, (q31_t)0xaf8a33bd, (q31_t)0x6388cd1b, (q31_t)0xaf8550db, (q31_t)0x6384d9a7, (q31_t)0xaf806e2b, - (q31_t)0x6380e5f6, (q31_t)0xaf7b8bac, (q31_t)0x637cf208, (q31_t)0xaf76a95f, (q31_t)0x6378fddc, (q31_t)0xaf71c743, (q31_t)0x63750973, (q31_t)0xaf6ce55a, - (q31_t)0x637114cc, (q31_t)0xaf6803a2, (q31_t)0x636d1fe9, (q31_t)0xaf63221c, (q31_t)0x63692ac7, (q31_t)0xaf5e40c7, (q31_t)0x63653569, (q31_t)0xaf595fa4, - (q31_t)0x63613fcd, (q31_t)0xaf547eb3, (q31_t)0x635d49f4, (q31_t)0xaf4f9df4, (q31_t)0x635953dd, (q31_t)0xaf4abd66, (q31_t)0x63555d8a, (q31_t)0xaf45dd0b, - (q31_t)0x635166f9, (q31_t)0xaf40fce1, (q31_t)0x634d702b, (q31_t)0xaf3c1ce9, (q31_t)0x6349791f, (q31_t)0xaf373d22, (q31_t)0x634581d6, (q31_t)0xaf325d8e, - (q31_t)0x63418a50, (q31_t)0xaf2d7e2b, (q31_t)0x633d928d, (q31_t)0xaf289efa, (q31_t)0x63399a8d, (q31_t)0xaf23bffb, (q31_t)0x6335a24f, (q31_t)0xaf1ee12e, - (q31_t)0x6331a9d4, (q31_t)0xaf1a0293, (q31_t)0x632db11c, (q31_t)0xaf15242a, (q31_t)0x6329b827, (q31_t)0xaf1045f3, (q31_t)0x6325bef5, (q31_t)0xaf0b67ed, - (q31_t)0x6321c585, (q31_t)0xaf068a1a, (q31_t)0x631dcbd9, (q31_t)0xaf01ac78, (q31_t)0x6319d1ef, (q31_t)0xaefccf09, (q31_t)0x6315d7c8, (q31_t)0xaef7f1cb, - (q31_t)0x6311dd64, (q31_t)0xaef314c0, (q31_t)0x630de2c3, (q31_t)0xaeee37e6, (q31_t)0x6309e7e4, (q31_t)0xaee95b3f, (q31_t)0x6305ecc9, (q31_t)0xaee47ec9, - (q31_t)0x6301f171, (q31_t)0xaedfa285, (q31_t)0x62fdf5db, (q31_t)0xaedac674, (q31_t)0x62f9fa09, (q31_t)0xaed5ea95, (q31_t)0x62f5fdf9, (q31_t)0xaed10ee7, - (q31_t)0x62f201ac, (q31_t)0xaecc336c, (q31_t)0x62ee0523, (q31_t)0xaec75823, (q31_t)0x62ea085c, (q31_t)0xaec27d0c, (q31_t)0x62e60b58, (q31_t)0xaebda227, - (q31_t)0x62e20e17, (q31_t)0xaeb8c774, (q31_t)0x62de109a, (q31_t)0xaeb3ecf3, (q31_t)0x62da12df, (q31_t)0xaeaf12a4, (q31_t)0x62d614e7, (q31_t)0xaeaa3888, - (q31_t)0x62d216b3, (q31_t)0xaea55e9e, (q31_t)0x62ce1841, (q31_t)0xaea084e6, (q31_t)0x62ca1992, (q31_t)0xae9bab60, (q31_t)0x62c61aa7, (q31_t)0xae96d20c, - (q31_t)0x62c21b7e, (q31_t)0xae91f8eb, (q31_t)0x62be1c19, (q31_t)0xae8d1ffb, (q31_t)0x62ba1c77, (q31_t)0xae88473e, (q31_t)0x62b61c98, (q31_t)0xae836eb4, - (q31_t)0x62b21c7b, (q31_t)0xae7e965b, (q31_t)0x62ae1c23, (q31_t)0xae79be35, (q31_t)0x62aa1b8d, (q31_t)0xae74e641, (q31_t)0x62a61aba, (q31_t)0xae700e80, - (q31_t)0x62a219aa, (q31_t)0xae6b36f0, (q31_t)0x629e185e, (q31_t)0xae665f93, (q31_t)0x629a16d5, (q31_t)0xae618869, (q31_t)0x6296150f, (q31_t)0xae5cb171, - (q31_t)0x6292130c, (q31_t)0xae57daab, (q31_t)0x628e10cc, (q31_t)0xae530417, (q31_t)0x628a0e50, (q31_t)0xae4e2db6, (q31_t)0x62860b97, (q31_t)0xae495787, - (q31_t)0x628208a1, (q31_t)0xae44818b, (q31_t)0x627e056e, (q31_t)0xae3fabc1, (q31_t)0x627a01fe, (q31_t)0xae3ad629, (q31_t)0x6275fe52, (q31_t)0xae3600c4, - (q31_t)0x6271fa69, (q31_t)0xae312b92, (q31_t)0x626df643, (q31_t)0xae2c5691, (q31_t)0x6269f1e1, (q31_t)0xae2781c4, (q31_t)0x6265ed42, (q31_t)0xae22ad29, - (q31_t)0x6261e866, (q31_t)0xae1dd8c0, (q31_t)0x625de34e, (q31_t)0xae19048a, (q31_t)0x6259ddf8, (q31_t)0xae143086, (q31_t)0x6255d866, (q31_t)0xae0f5cb5, - (q31_t)0x6251d298, (q31_t)0xae0a8916, (q31_t)0x624dcc8d, (q31_t)0xae05b5aa, (q31_t)0x6249c645, (q31_t)0xae00e271, (q31_t)0x6245bfc0, (q31_t)0xadfc0f6a, - (q31_t)0x6241b8ff, (q31_t)0xadf73c96, (q31_t)0x623db202, (q31_t)0xadf269f4, (q31_t)0x6239aac7, (q31_t)0xaded9785, (q31_t)0x6235a351, (q31_t)0xade8c548, - (q31_t)0x62319b9d, (q31_t)0xade3f33e, (q31_t)0x622d93ad, (q31_t)0xaddf2167, (q31_t)0x62298b81, (q31_t)0xadda4fc3, (q31_t)0x62258317, (q31_t)0xadd57e51, - (q31_t)0x62217a72, (q31_t)0xadd0ad12, (q31_t)0x621d7190, (q31_t)0xadcbdc05, (q31_t)0x62196871, (q31_t)0xadc70b2c, (q31_t)0x62155f16, (q31_t)0xadc23a85, - (q31_t)0x6211557e, (q31_t)0xadbd6a10, (q31_t)0x620d4baa, (q31_t)0xadb899cf, (q31_t)0x62094199, (q31_t)0xadb3c9c0, (q31_t)0x6205374c, (q31_t)0xadaef9e4, - (q31_t)0x62012cc2, (q31_t)0xadaa2a3b, (q31_t)0x61fd21fc, (q31_t)0xada55ac4, (q31_t)0x61f916f9, (q31_t)0xada08b80, (q31_t)0x61f50bba, (q31_t)0xad9bbc70, - (q31_t)0x61f1003f, (q31_t)0xad96ed92, (q31_t)0x61ecf487, (q31_t)0xad921ee6, (q31_t)0x61e8e893, (q31_t)0xad8d506e, (q31_t)0x61e4dc62, (q31_t)0xad888229, - (q31_t)0x61e0cff5, (q31_t)0xad83b416, (q31_t)0x61dcc34c, (q31_t)0xad7ee636, (q31_t)0x61d8b666, (q31_t)0xad7a1889, (q31_t)0x61d4a944, (q31_t)0xad754b0f, - (q31_t)0x61d09be5, (q31_t)0xad707dc8, (q31_t)0x61cc8e4b, (q31_t)0xad6bb0b4, (q31_t)0x61c88074, (q31_t)0xad66e3d3, (q31_t)0x61c47260, (q31_t)0xad621725, - (q31_t)0x61c06410, (q31_t)0xad5d4aaa, (q31_t)0x61bc5584, (q31_t)0xad587e61, (q31_t)0x61b846bc, (q31_t)0xad53b24c, (q31_t)0x61b437b7, (q31_t)0xad4ee66a, - (q31_t)0x61b02876, (q31_t)0xad4a1aba, (q31_t)0x61ac18f9, (q31_t)0xad454f3e, (q31_t)0x61a80940, (q31_t)0xad4083f5, (q31_t)0x61a3f94a, (q31_t)0xad3bb8df, - (q31_t)0x619fe918, (q31_t)0xad36edfc, (q31_t)0x619bd8aa, (q31_t)0xad32234b, (q31_t)0x6197c800, (q31_t)0xad2d58ce, (q31_t)0x6193b719, (q31_t)0xad288e85, - (q31_t)0x618fa5f7, (q31_t)0xad23c46e, (q31_t)0x618b9498, (q31_t)0xad1efa8a, (q31_t)0x618782fd, (q31_t)0xad1a30d9, (q31_t)0x61837126, (q31_t)0xad15675c, - (q31_t)0x617f5f12, (q31_t)0xad109e12, (q31_t)0x617b4cc3, (q31_t)0xad0bd4fb, (q31_t)0x61773a37, (q31_t)0xad070c17, (q31_t)0x61732770, (q31_t)0xad024366, - (q31_t)0x616f146c, (q31_t)0xacfd7ae8, (q31_t)0x616b012c, (q31_t)0xacf8b29e, (q31_t)0x6166edb0, (q31_t)0xacf3ea87, (q31_t)0x6162d9f8, (q31_t)0xacef22a3, - (q31_t)0x615ec603, (q31_t)0xacea5af2, (q31_t)0x615ab1d3, (q31_t)0xace59375, (q31_t)0x61569d67, (q31_t)0xace0cc2b, (q31_t)0x615288be, (q31_t)0xacdc0514, - (q31_t)0x614e73da, (q31_t)0xacd73e30, (q31_t)0x614a5eba, (q31_t)0xacd27780, (q31_t)0x6146495d, (q31_t)0xaccdb103, (q31_t)0x614233c5, (q31_t)0xacc8eab9, - (q31_t)0x613e1df0, (q31_t)0xacc424a3, (q31_t)0x613a07e0, (q31_t)0xacbf5ec0, (q31_t)0x6135f193, (q31_t)0xacba9910, (q31_t)0x6131db0b, (q31_t)0xacb5d394, - (q31_t)0x612dc447, (q31_t)0xacb10e4b, (q31_t)0x6129ad46, (q31_t)0xacac4935, (q31_t)0x6125960a, (q31_t)0xaca78453, (q31_t)0x61217e92, (q31_t)0xaca2bfa4, - (q31_t)0x611d66de, (q31_t)0xac9dfb29, (q31_t)0x61194eee, (q31_t)0xac9936e1, (q31_t)0x611536c2, (q31_t)0xac9472cd, (q31_t)0x61111e5b, (q31_t)0xac8faeec, - (q31_t)0x610d05b7, (q31_t)0xac8aeb3e, (q31_t)0x6108ecd8, (q31_t)0xac8627c4, (q31_t)0x6104d3bc, (q31_t)0xac81647e, (q31_t)0x6100ba65, (q31_t)0xac7ca16b, - (q31_t)0x60fca0d2, (q31_t)0xac77de8b, (q31_t)0x60f88703, (q31_t)0xac731bdf, (q31_t)0x60f46cf9, (q31_t)0xac6e5967, (q31_t)0x60f052b2, (q31_t)0xac699722, - (q31_t)0x60ec3830, (q31_t)0xac64d510, (q31_t)0x60e81d72, (q31_t)0xac601333, (q31_t)0x60e40278, (q31_t)0xac5b5189, (q31_t)0x60dfe743, (q31_t)0xac569012, - (q31_t)0x60dbcbd1, (q31_t)0xac51cecf, (q31_t)0x60d7b024, (q31_t)0xac4d0dc0, (q31_t)0x60d3943b, (q31_t)0xac484ce4, (q31_t)0x60cf7817, (q31_t)0xac438c3c, - (q31_t)0x60cb5bb7, (q31_t)0xac3ecbc7, (q31_t)0x60c73f1b, (q31_t)0xac3a0b87, (q31_t)0x60c32243, (q31_t)0xac354b7a, (q31_t)0x60bf0530, (q31_t)0xac308ba0, - (q31_t)0x60bae7e1, (q31_t)0xac2bcbfa, (q31_t)0x60b6ca56, (q31_t)0xac270c88, (q31_t)0x60b2ac8f, (q31_t)0xac224d4a, (q31_t)0x60ae8e8d, (q31_t)0xac1d8e40, - (q31_t)0x60aa7050, (q31_t)0xac18cf69, (q31_t)0x60a651d7, (q31_t)0xac1410c6, (q31_t)0x60a23322, (q31_t)0xac0f5256, (q31_t)0x609e1431, (q31_t)0xac0a941b, - (q31_t)0x6099f505, (q31_t)0xac05d613, (q31_t)0x6095d59d, (q31_t)0xac01183f, (q31_t)0x6091b5fa, (q31_t)0xabfc5a9f, (q31_t)0x608d961b, (q31_t)0xabf79d33, - (q31_t)0x60897601, (q31_t)0xabf2dffb, (q31_t)0x608555ab, (q31_t)0xabee22f6, (q31_t)0x60813519, (q31_t)0xabe96625, (q31_t)0x607d144c, (q31_t)0xabe4a988, - (q31_t)0x6078f344, (q31_t)0xabdfed1f, (q31_t)0x6074d200, (q31_t)0xabdb30ea, (q31_t)0x6070b080, (q31_t)0xabd674e9, (q31_t)0x606c8ec5, (q31_t)0xabd1b91c, - (q31_t)0x60686ccf, (q31_t)0xabccfd83, (q31_t)0x60644a9d, (q31_t)0xabc8421d, (q31_t)0x6060282f, (q31_t)0xabc386ec, (q31_t)0x605c0587, (q31_t)0xabbecbee, - (q31_t)0x6057e2a2, (q31_t)0xabba1125, (q31_t)0x6053bf82, (q31_t)0xabb5568f, (q31_t)0x604f9c27, (q31_t)0xabb09c2e, (q31_t)0x604b7891, (q31_t)0xababe200, - (q31_t)0x604754bf, (q31_t)0xaba72807, (q31_t)0x604330b1, (q31_t)0xaba26e41, (q31_t)0x603f0c69, (q31_t)0xab9db4b0, (q31_t)0x603ae7e5, (q31_t)0xab98fb52, - (q31_t)0x6036c325, (q31_t)0xab944229, (q31_t)0x60329e2a, (q31_t)0xab8f8934, (q31_t)0x602e78f4, (q31_t)0xab8ad073, (q31_t)0x602a5383, (q31_t)0xab8617e6, - (q31_t)0x60262dd6, (q31_t)0xab815f8d, (q31_t)0x602207ee, (q31_t)0xab7ca768, (q31_t)0x601de1ca, (q31_t)0xab77ef77, (q31_t)0x6019bb6b, (q31_t)0xab7337bb, - (q31_t)0x601594d1, (q31_t)0xab6e8032, (q31_t)0x60116dfc, (q31_t)0xab69c8de, (q31_t)0x600d46ec, (q31_t)0xab6511be, (q31_t)0x60091fa0, (q31_t)0xab605ad2, - (q31_t)0x6004f819, (q31_t)0xab5ba41a, (q31_t)0x6000d057, (q31_t)0xab56ed97, (q31_t)0x5ffca859, (q31_t)0xab523748, (q31_t)0x5ff88021, (q31_t)0xab4d812d, - (q31_t)0x5ff457ad, (q31_t)0xab48cb46, (q31_t)0x5ff02efe, (q31_t)0xab441593, (q31_t)0x5fec0613, (q31_t)0xab3f6015, (q31_t)0x5fe7dcee, (q31_t)0xab3aaacb, - (q31_t)0x5fe3b38d, (q31_t)0xab35f5b5, (q31_t)0x5fdf89f2, (q31_t)0xab3140d4, (q31_t)0x5fdb601b, (q31_t)0xab2c8c27, (q31_t)0x5fd73609, (q31_t)0xab27d7ae, - (q31_t)0x5fd30bbc, (q31_t)0xab23236a, (q31_t)0x5fcee133, (q31_t)0xab1e6f5a, (q31_t)0x5fcab670, (q31_t)0xab19bb7e, (q31_t)0x5fc68b72, (q31_t)0xab1507d7, - (q31_t)0x5fc26038, (q31_t)0xab105464, (q31_t)0x5fbe34c4, (q31_t)0xab0ba125, (q31_t)0x5fba0914, (q31_t)0xab06ee1b, (q31_t)0x5fb5dd29, (q31_t)0xab023b46, - (q31_t)0x5fb1b104, (q31_t)0xaafd88a4, (q31_t)0x5fad84a3, (q31_t)0xaaf8d637, (q31_t)0x5fa95807, (q31_t)0xaaf423ff, (q31_t)0x5fa52b31, (q31_t)0xaaef71fb, - (q31_t)0x5fa0fe1f, (q31_t)0xaaeac02c, (q31_t)0x5f9cd0d2, (q31_t)0xaae60e91, (q31_t)0x5f98a34a, (q31_t)0xaae15d2a, (q31_t)0x5f947588, (q31_t)0xaadcabf8, - (q31_t)0x5f90478a, (q31_t)0xaad7fafb, (q31_t)0x5f8c1951, (q31_t)0xaad34a32, (q31_t)0x5f87eade, (q31_t)0xaace999d, (q31_t)0x5f83bc2f, (q31_t)0xaac9e93e, - (q31_t)0x5f7f8d46, (q31_t)0xaac53912, (q31_t)0x5f7b5e22, (q31_t)0xaac0891c, (q31_t)0x5f772ec2, (q31_t)0xaabbd959, (q31_t)0x5f72ff28, (q31_t)0xaab729cc, - (q31_t)0x5f6ecf53, (q31_t)0xaab27a73, (q31_t)0x5f6a9f44, (q31_t)0xaaadcb4f, (q31_t)0x5f666ef9, (q31_t)0xaaa91c5f, (q31_t)0x5f623e73, (q31_t)0xaaa46da4, - (q31_t)0x5f5e0db3, (q31_t)0xaa9fbf1e, (q31_t)0x5f59dcb8, (q31_t)0xaa9b10cc, (q31_t)0x5f55ab82, (q31_t)0xaa9662af, (q31_t)0x5f517a11, (q31_t)0xaa91b4c7, - (q31_t)0x5f4d4865, (q31_t)0xaa8d0713, (q31_t)0x5f49167f, (q31_t)0xaa885994, (q31_t)0x5f44e45e, (q31_t)0xaa83ac4a, (q31_t)0x5f40b202, (q31_t)0xaa7eff34, - (q31_t)0x5f3c7f6b, (q31_t)0xaa7a5253, (q31_t)0x5f384c9a, (q31_t)0xaa75a5a8, (q31_t)0x5f34198e, (q31_t)0xaa70f930, (q31_t)0x5f2fe647, (q31_t)0xaa6c4cee, - (q31_t)0x5f2bb2c5, (q31_t)0xaa67a0e0, (q31_t)0x5f277f09, (q31_t)0xaa62f507, (q31_t)0x5f234b12, (q31_t)0xaa5e4963, (q31_t)0x5f1f16e0, (q31_t)0xaa599df4, - (q31_t)0x5f1ae274, (q31_t)0xaa54f2ba, (q31_t)0x5f16adcc, (q31_t)0xaa5047b4, (q31_t)0x5f1278eb, (q31_t)0xaa4b9ce3, (q31_t)0x5f0e43ce, (q31_t)0xaa46f248, - (q31_t)0x5f0a0e77, (q31_t)0xaa4247e1, (q31_t)0x5f05d8e6, (q31_t)0xaa3d9daf, (q31_t)0x5f01a31a, (q31_t)0xaa38f3b1, (q31_t)0x5efd6d13, (q31_t)0xaa3449e9, - (q31_t)0x5ef936d1, (q31_t)0xaa2fa056, (q31_t)0x5ef50055, (q31_t)0xaa2af6f7, (q31_t)0x5ef0c99f, (q31_t)0xaa264dce, (q31_t)0x5eec92ae, (q31_t)0xaa21a4d9, - (q31_t)0x5ee85b82, (q31_t)0xaa1cfc1a, (q31_t)0x5ee4241c, (q31_t)0xaa18538f, (q31_t)0x5edfec7b, (q31_t)0xaa13ab3a, (q31_t)0x5edbb49f, (q31_t)0xaa0f0319, - (q31_t)0x5ed77c8a, (q31_t)0xaa0a5b2e, (q31_t)0x5ed34439, (q31_t)0xaa05b377, (q31_t)0x5ecf0baf, (q31_t)0xaa010bf6, (q31_t)0x5ecad2e9, (q31_t)0xa9fc64a9, - (q31_t)0x5ec699e9, (q31_t)0xa9f7bd92, (q31_t)0x5ec260af, (q31_t)0xa9f316b0, (q31_t)0x5ebe273b, (q31_t)0xa9ee7002, (q31_t)0x5eb9ed8b, (q31_t)0xa9e9c98a, - (q31_t)0x5eb5b3a2, (q31_t)0xa9e52347, (q31_t)0x5eb1797e, (q31_t)0xa9e07d39, (q31_t)0x5ead3f1f, (q31_t)0xa9dbd761, (q31_t)0x5ea90487, (q31_t)0xa9d731bd, - (q31_t)0x5ea4c9b3, (q31_t)0xa9d28c4e, (q31_t)0x5ea08ea6, (q31_t)0xa9cde715, (q31_t)0x5e9c535e, (q31_t)0xa9c94211, (q31_t)0x5e9817dc, (q31_t)0xa9c49d42, - (q31_t)0x5e93dc1f, (q31_t)0xa9bff8a8, (q31_t)0x5e8fa028, (q31_t)0xa9bb5444, (q31_t)0x5e8b63f7, (q31_t)0xa9b6b014, (q31_t)0x5e87278b, (q31_t)0xa9b20c1a, - (q31_t)0x5e82eae5, (q31_t)0xa9ad6855, (q31_t)0x5e7eae05, (q31_t)0xa9a8c4c5, (q31_t)0x5e7a70ea, (q31_t)0xa9a4216b, (q31_t)0x5e763395, (q31_t)0xa99f7e46, - (q31_t)0x5e71f606, (q31_t)0xa99adb56, (q31_t)0x5e6db83d, (q31_t)0xa996389b, (q31_t)0x5e697a39, (q31_t)0xa9919616, (q31_t)0x5e653bfc, (q31_t)0xa98cf3c6, - (q31_t)0x5e60fd84, (q31_t)0xa98851ac, (q31_t)0x5e5cbed1, (q31_t)0xa983afc6, (q31_t)0x5e587fe5, (q31_t)0xa97f0e16, (q31_t)0x5e5440be, (q31_t)0xa97a6c9c, - (q31_t)0x5e50015d, (q31_t)0xa975cb57, (q31_t)0x5e4bc1c2, (q31_t)0xa9712a47, (q31_t)0x5e4781ed, (q31_t)0xa96c896c, (q31_t)0x5e4341de, (q31_t)0xa967e8c7, - (q31_t)0x5e3f0194, (q31_t)0xa9634858, (q31_t)0x5e3ac110, (q31_t)0xa95ea81d, (q31_t)0x5e368053, (q31_t)0xa95a0819, (q31_t)0x5e323f5b, (q31_t)0xa9556849, - (q31_t)0x5e2dfe29, (q31_t)0xa950c8b0, (q31_t)0x5e29bcbd, (q31_t)0xa94c294b, (q31_t)0x5e257b17, (q31_t)0xa9478a1c, (q31_t)0x5e213936, (q31_t)0xa942eb23, - (q31_t)0x5e1cf71c, (q31_t)0xa93e4c5f, (q31_t)0x5e18b4c8, (q31_t)0xa939add1, (q31_t)0x5e147239, (q31_t)0xa9350f78, (q31_t)0x5e102f71, (q31_t)0xa9307155, - (q31_t)0x5e0bec6e, (q31_t)0xa92bd367, (q31_t)0x5e07a932, (q31_t)0xa92735af, (q31_t)0x5e0365bb, (q31_t)0xa922982c, (q31_t)0x5dff220b, (q31_t)0xa91dfadf, - (q31_t)0x5dfade20, (q31_t)0xa9195dc7, (q31_t)0x5df699fc, (q31_t)0xa914c0e6, (q31_t)0x5df2559e, (q31_t)0xa9102439, (q31_t)0x5dee1105, (q31_t)0xa90b87c3, - (q31_t)0x5de9cc33, (q31_t)0xa906eb82, (q31_t)0x5de58727, (q31_t)0xa9024f76, (q31_t)0x5de141e1, (q31_t)0xa8fdb3a1, (q31_t)0x5ddcfc61, (q31_t)0xa8f91801, - (q31_t)0x5dd8b6a7, (q31_t)0xa8f47c97, (q31_t)0x5dd470b3, (q31_t)0xa8efe162, (q31_t)0x5dd02a85, (q31_t)0xa8eb4663, (q31_t)0x5dcbe41d, (q31_t)0xa8e6ab9a, - (q31_t)0x5dc79d7c, (q31_t)0xa8e21106, (q31_t)0x5dc356a1, (q31_t)0xa8dd76a9, (q31_t)0x5dbf0f8c, (q31_t)0xa8d8dc81, (q31_t)0x5dbac83d, (q31_t)0xa8d4428f, - (q31_t)0x5db680b4, (q31_t)0xa8cfa8d2, (q31_t)0x5db238f1, (q31_t)0xa8cb0f4b, (q31_t)0x5dadf0f5, (q31_t)0xa8c675fb, (q31_t)0x5da9a8bf, (q31_t)0xa8c1dce0, - (q31_t)0x5da5604f, (q31_t)0xa8bd43fa, (q31_t)0x5da117a5, (q31_t)0xa8b8ab4b, (q31_t)0x5d9ccec2, (q31_t)0xa8b412d1, (q31_t)0x5d9885a5, (q31_t)0xa8af7a8e, - (q31_t)0x5d943c4e, (q31_t)0xa8aae280, (q31_t)0x5d8ff2bd, (q31_t)0xa8a64aa8, (q31_t)0x5d8ba8f3, (q31_t)0xa8a1b306, (q31_t)0x5d875eef, (q31_t)0xa89d1b99, - (q31_t)0x5d8314b1, (q31_t)0xa8988463, (q31_t)0x5d7eca39, (q31_t)0xa893ed63, (q31_t)0x5d7a7f88, (q31_t)0xa88f5698, (q31_t)0x5d76349d, (q31_t)0xa88ac004, - (q31_t)0x5d71e979, (q31_t)0xa88629a5, (q31_t)0x5d6d9e1b, (q31_t)0xa881937c, (q31_t)0x5d695283, (q31_t)0xa87cfd8a, (q31_t)0x5d6506b2, (q31_t)0xa87867cd, - (q31_t)0x5d60baa7, (q31_t)0xa873d246, (q31_t)0x5d5c6e62, (q31_t)0xa86f3cf6, (q31_t)0x5d5821e4, (q31_t)0xa86aa7db, (q31_t)0x5d53d52d, (q31_t)0xa86612f6, - (q31_t)0x5d4f883b, (q31_t)0xa8617e48, (q31_t)0x5d4b3b10, (q31_t)0xa85ce9cf, (q31_t)0x5d46edac, (q31_t)0xa858558d, (q31_t)0x5d42a00e, (q31_t)0xa853c180, - (q31_t)0x5d3e5237, (q31_t)0xa84f2daa, (q31_t)0x5d3a0426, (q31_t)0xa84a9a0a, (q31_t)0x5d35b5db, (q31_t)0xa84606a0, (q31_t)0x5d316757, (q31_t)0xa841736c, - (q31_t)0x5d2d189a, (q31_t)0xa83ce06e, (q31_t)0x5d28c9a3, (q31_t)0xa8384da6, (q31_t)0x5d247a72, (q31_t)0xa833bb14, (q31_t)0x5d202b09, (q31_t)0xa82f28b9, - (q31_t)0x5d1bdb65, (q31_t)0xa82a9693, (q31_t)0x5d178b89, (q31_t)0xa82604a4, (q31_t)0x5d133b72, (q31_t)0xa82172eb, (q31_t)0x5d0eeb23, (q31_t)0xa81ce169, - (q31_t)0x5d0a9a9a, (q31_t)0xa818501c, (q31_t)0x5d0649d7, (q31_t)0xa813bf06, (q31_t)0x5d01f8dc, (q31_t)0xa80f2e26, (q31_t)0x5cfda7a7, (q31_t)0xa80a9d7c, - (q31_t)0x5cf95638, (q31_t)0xa8060d08, (q31_t)0x5cf50490, (q31_t)0xa8017ccb, (q31_t)0x5cf0b2af, (q31_t)0xa7fcecc4, (q31_t)0x5cec6095, (q31_t)0xa7f85cf3, - (q31_t)0x5ce80e41, (q31_t)0xa7f3cd59, (q31_t)0x5ce3bbb4, (q31_t)0xa7ef3df5, (q31_t)0x5cdf68ed, (q31_t)0xa7eaaec7, (q31_t)0x5cdb15ed, (q31_t)0xa7e61fd0, - (q31_t)0x5cd6c2b5, (q31_t)0xa7e1910f, (q31_t)0x5cd26f42, (q31_t)0xa7dd0284, (q31_t)0x5cce1b97, (q31_t)0xa7d8742f, (q31_t)0x5cc9c7b2, (q31_t)0xa7d3e611, - (q31_t)0x5cc57394, (q31_t)0xa7cf582a, (q31_t)0x5cc11f3d, (q31_t)0xa7caca79, (q31_t)0x5cbccaac, (q31_t)0xa7c63cfe, (q31_t)0x5cb875e3, (q31_t)0xa7c1afb9, - (q31_t)0x5cb420e0, (q31_t)0xa7bd22ac, (q31_t)0x5cafcba4, (q31_t)0xa7b895d4, (q31_t)0x5cab762f, (q31_t)0xa7b40933, (q31_t)0x5ca72080, (q31_t)0xa7af7cc8, - (q31_t)0x5ca2ca99, (q31_t)0xa7aaf094, (q31_t)0x5c9e7478, (q31_t)0xa7a66497, (q31_t)0x5c9a1e1e, (q31_t)0xa7a1d8d0, (q31_t)0x5c95c78b, (q31_t)0xa79d4d3f, - (q31_t)0x5c9170bf, (q31_t)0xa798c1e5, (q31_t)0x5c8d19ba, (q31_t)0xa79436c1, (q31_t)0x5c88c27c, (q31_t)0xa78fabd4, (q31_t)0x5c846b05, (q31_t)0xa78b211e, - (q31_t)0x5c801354, (q31_t)0xa786969e, (q31_t)0x5c7bbb6b, (q31_t)0xa7820c55, (q31_t)0x5c776348, (q31_t)0xa77d8242, (q31_t)0x5c730aed, (q31_t)0xa778f866, - (q31_t)0x5c6eb258, (q31_t)0xa7746ec0, (q31_t)0x5c6a598b, (q31_t)0xa76fe551, (q31_t)0x5c660084, (q31_t)0xa76b5c19, (q31_t)0x5c61a745, (q31_t)0xa766d317, - (q31_t)0x5c5d4dcc, (q31_t)0xa7624a4d, (q31_t)0x5c58f41a, (q31_t)0xa75dc1b8, (q31_t)0x5c549a30, (q31_t)0xa759395b, (q31_t)0x5c50400d, (q31_t)0xa754b134, - (q31_t)0x5c4be5b0, (q31_t)0xa7502943, (q31_t)0x5c478b1b, (q31_t)0xa74ba18a, (q31_t)0x5c43304d, (q31_t)0xa7471a07, (q31_t)0x5c3ed545, (q31_t)0xa74292bb, - (q31_t)0x5c3a7a05, (q31_t)0xa73e0ba5, (q31_t)0x5c361e8c, (q31_t)0xa73984c7, (q31_t)0x5c31c2db, (q31_t)0xa734fe1f, (q31_t)0x5c2d66f0, (q31_t)0xa73077ae, - (q31_t)0x5c290acc, (q31_t)0xa72bf174, (q31_t)0x5c24ae70, (q31_t)0xa7276b70, (q31_t)0x5c2051db, (q31_t)0xa722e5a3, (q31_t)0x5c1bf50d, (q31_t)0xa71e600d, - (q31_t)0x5c179806, (q31_t)0xa719daae, (q31_t)0x5c133ac6, (q31_t)0xa7155586, (q31_t)0x5c0edd4e, (q31_t)0xa710d095, (q31_t)0x5c0a7f9c, (q31_t)0xa70c4bda, - (q31_t)0x5c0621b2, (q31_t)0xa707c757, (q31_t)0x5c01c38f, (q31_t)0xa703430a, (q31_t)0x5bfd6534, (q31_t)0xa6febef4, (q31_t)0x5bf906a0, (q31_t)0xa6fa3b15, - (q31_t)0x5bf4a7d2, (q31_t)0xa6f5b76d, (q31_t)0x5bf048cd, (q31_t)0xa6f133fc, (q31_t)0x5bebe98e, (q31_t)0xa6ecb0c2, (q31_t)0x5be78a17, (q31_t)0xa6e82dbe, - (q31_t)0x5be32a67, (q31_t)0xa6e3aaf2, (q31_t)0x5bdeca7f, (q31_t)0xa6df285d, (q31_t)0x5bda6a5d, (q31_t)0xa6daa5fe, (q31_t)0x5bd60a03, (q31_t)0xa6d623d7, - (q31_t)0x5bd1a971, (q31_t)0xa6d1a1e7, (q31_t)0x5bcd48a6, (q31_t)0xa6cd202d, (q31_t)0x5bc8e7a2, (q31_t)0xa6c89eab, (q31_t)0x5bc48666, (q31_t)0xa6c41d60, - (q31_t)0x5bc024f0, (q31_t)0xa6bf9c4b, (q31_t)0x5bbbc343, (q31_t)0xa6bb1b6e, (q31_t)0x5bb7615d, (q31_t)0xa6b69ac8, (q31_t)0x5bb2ff3e, (q31_t)0xa6b21a59, - (q31_t)0x5bae9ce7, (q31_t)0xa6ad9a21, (q31_t)0x5baa3a57, (q31_t)0xa6a91a20, (q31_t)0x5ba5d78e, (q31_t)0xa6a49a56, (q31_t)0x5ba1748d, (q31_t)0xa6a01ac4, - (q31_t)0x5b9d1154, (q31_t)0xa69b9b68, (q31_t)0x5b98ade2, (q31_t)0xa6971c44, (q31_t)0x5b944a37, (q31_t)0xa6929d57, (q31_t)0x5b8fe654, (q31_t)0xa68e1ea1, - (q31_t)0x5b8b8239, (q31_t)0xa689a022, (q31_t)0x5b871de5, (q31_t)0xa68521da, (q31_t)0x5b82b958, (q31_t)0xa680a3ca, (q31_t)0x5b7e5493, (q31_t)0xa67c25f0, - (q31_t)0x5b79ef96, (q31_t)0xa677a84e, (q31_t)0x5b758a60, (q31_t)0xa6732ae3, (q31_t)0x5b7124f2, (q31_t)0xa66eadb0, (q31_t)0x5b6cbf4c, (q31_t)0xa66a30b3, - (q31_t)0x5b68596d, (q31_t)0xa665b3ee, (q31_t)0x5b63f355, (q31_t)0xa6613760, (q31_t)0x5b5f8d06, (q31_t)0xa65cbb0a, (q31_t)0x5b5b267e, (q31_t)0xa6583eeb, - (q31_t)0x5b56bfbd, (q31_t)0xa653c303, (q31_t)0x5b5258c4, (q31_t)0xa64f4752, (q31_t)0x5b4df193, (q31_t)0xa64acbd9, (q31_t)0x5b498a2a, (q31_t)0xa6465097, - (q31_t)0x5b452288, (q31_t)0xa641d58c, (q31_t)0x5b40baae, (q31_t)0xa63d5ab9, (q31_t)0x5b3c529c, (q31_t)0xa638e01d, (q31_t)0x5b37ea51, (q31_t)0xa63465b9, - (q31_t)0x5b3381ce, (q31_t)0xa62feb8b, (q31_t)0x5b2f1913, (q31_t)0xa62b7196, (q31_t)0x5b2ab020, (q31_t)0xa626f7d7, (q31_t)0x5b2646f4, (q31_t)0xa6227e50, - (q31_t)0x5b21dd90, (q31_t)0xa61e0501, (q31_t)0x5b1d73f4, (q31_t)0xa6198be9, (q31_t)0x5b190a20, (q31_t)0xa6151308, (q31_t)0x5b14a014, (q31_t)0xa6109a5f, - (q31_t)0x5b1035cf, (q31_t)0xa60c21ee, (q31_t)0x5b0bcb52, (q31_t)0xa607a9b4, (q31_t)0x5b07609d, (q31_t)0xa60331b1, (q31_t)0x5b02f5b0, (q31_t)0xa5feb9e6, - (q31_t)0x5afe8a8b, (q31_t)0xa5fa4252, (q31_t)0x5afa1f2e, (q31_t)0xa5f5caf6, (q31_t)0x5af5b398, (q31_t)0xa5f153d2, (q31_t)0x5af147ca, (q31_t)0xa5ecdce5, - (q31_t)0x5aecdbc5, (q31_t)0xa5e8662f, (q31_t)0x5ae86f87, (q31_t)0xa5e3efb1, (q31_t)0x5ae40311, (q31_t)0xa5df796b, (q31_t)0x5adf9663, (q31_t)0xa5db035c, - (q31_t)0x5adb297d, (q31_t)0xa5d68d85, (q31_t)0x5ad6bc5f, (q31_t)0xa5d217e6, (q31_t)0x5ad24f09, (q31_t)0xa5cda27e, (q31_t)0x5acde17b, (q31_t)0xa5c92d4e, - (q31_t)0x5ac973b5, (q31_t)0xa5c4b855, (q31_t)0x5ac505b7, (q31_t)0xa5c04395, (q31_t)0x5ac09781, (q31_t)0xa5bbcf0b, (q31_t)0x5abc2912, (q31_t)0xa5b75aba, - (q31_t)0x5ab7ba6c, (q31_t)0xa5b2e6a0, (q31_t)0x5ab34b8e, (q31_t)0xa5ae72be, (q31_t)0x5aaedc78, (q31_t)0xa5a9ff14, (q31_t)0x5aaa6d2b, (q31_t)0xa5a58ba1, - (q31_t)0x5aa5fda5, (q31_t)0xa5a11866, (q31_t)0x5aa18de7, (q31_t)0xa59ca563, (q31_t)0x5a9d1df1, (q31_t)0xa5983297, (q31_t)0x5a98adc4, (q31_t)0xa593c004, - (q31_t)0x5a943d5e, (q31_t)0xa58f4da8, (q31_t)0x5a8fccc1, (q31_t)0xa58adb84, (q31_t)0x5a8b5bec, (q31_t)0xa5866997, (q31_t)0x5a86eadf, (q31_t)0xa581f7e3, - (q31_t)0x5a82799a, (q31_t)0xa57d8666, (q31_t)0x5a7e081d, (q31_t)0xa5791521, (q31_t)0x5a799669, (q31_t)0xa574a414, (q31_t)0x5a75247c, (q31_t)0xa570333f, - (q31_t)0x5a70b258, (q31_t)0xa56bc2a2, (q31_t)0x5a6c3ffc, (q31_t)0xa567523c, (q31_t)0x5a67cd69, (q31_t)0xa562e20f, (q31_t)0x5a635a9d, (q31_t)0xa55e7219, - (q31_t)0x5a5ee79a, (q31_t)0xa55a025b, (q31_t)0x5a5a745f, (q31_t)0xa55592d5, (q31_t)0x5a5600ec, (q31_t)0xa5512388, (q31_t)0x5a518d42, (q31_t)0xa54cb472, - (q31_t)0x5a4d1960, (q31_t)0xa5484594, (q31_t)0x5a48a546, (q31_t)0xa543d6ee, (q31_t)0x5a4430f5, (q31_t)0xa53f687f, (q31_t)0x5a3fbc6b, (q31_t)0xa53afa49, - (q31_t)0x5a3b47ab, (q31_t)0xa5368c4b, (q31_t)0x5a36d2b2, (q31_t)0xa5321e85, (q31_t)0x5a325d82, (q31_t)0xa52db0f7, (q31_t)0x5a2de81a, (q31_t)0xa52943a1, - (q31_t)0x5a29727b, (q31_t)0xa524d683, (q31_t)0x5a24fca4, (q31_t)0xa520699d, (q31_t)0x5a208695, (q31_t)0xa51bfcef, (q31_t)0x5a1c104f, (q31_t)0xa5179079, - (q31_t)0x5a1799d1, (q31_t)0xa513243b, (q31_t)0x5a13231b, (q31_t)0xa50eb836, (q31_t)0x5a0eac2e, (q31_t)0xa50a4c68, (q31_t)0x5a0a350a, (q31_t)0xa505e0d2, - (q31_t)0x5a05bdae, (q31_t)0xa5017575, (q31_t)0x5a01461a, (q31_t)0xa4fd0a50, (q31_t)0x59fcce4f, (q31_t)0xa4f89f63, (q31_t)0x59f8564c, (q31_t)0xa4f434ae, - (q31_t)0x59f3de12, (q31_t)0xa4efca31, (q31_t)0x59ef65a1, (q31_t)0xa4eb5fec, (q31_t)0x59eaecf8, (q31_t)0xa4e6f5e0, (q31_t)0x59e67417, (q31_t)0xa4e28c0c, - (q31_t)0x59e1faff, (q31_t)0xa4de2270, (q31_t)0x59dd81b0, (q31_t)0xa4d9b90c, (q31_t)0x59d90829, (q31_t)0xa4d54fe0, (q31_t)0x59d48e6a, (q31_t)0xa4d0e6ed, - (q31_t)0x59d01475, (q31_t)0xa4cc7e32, (q31_t)0x59cb9a47, (q31_t)0xa4c815af, (q31_t)0x59c71fe3, (q31_t)0xa4c3ad64, (q31_t)0x59c2a547, (q31_t)0xa4bf4552, - (q31_t)0x59be2a74, (q31_t)0xa4badd78, (q31_t)0x59b9af69, (q31_t)0xa4b675d6, (q31_t)0x59b53427, (q31_t)0xa4b20e6d, (q31_t)0x59b0b8ae, (q31_t)0xa4ada73c, - (q31_t)0x59ac3cfd, (q31_t)0xa4a94043, (q31_t)0x59a7c115, (q31_t)0xa4a4d982, (q31_t)0x59a344f6, (q31_t)0xa4a072fa, (q31_t)0x599ec8a0, (q31_t)0xa49c0cab, - (q31_t)0x599a4c12, (q31_t)0xa497a693, (q31_t)0x5995cf4d, (q31_t)0xa49340b4, (q31_t)0x59915250, (q31_t)0xa48edb0e, (q31_t)0x598cd51d, (q31_t)0xa48a75a0, - (q31_t)0x598857b2, (q31_t)0xa486106a, (q31_t)0x5983da10, (q31_t)0xa481ab6d, (q31_t)0x597f5c36, (q31_t)0xa47d46a8, (q31_t)0x597ade26, (q31_t)0xa478e21b, - (q31_t)0x59765fde, (q31_t)0xa4747dc7, (q31_t)0x5971e15f, (q31_t)0xa47019ac, (q31_t)0x596d62a9, (q31_t)0xa46bb5c9, (q31_t)0x5968e3bc, (q31_t)0xa467521e, - (q31_t)0x59646498, (q31_t)0xa462eeac, (q31_t)0x595fe53c, (q31_t)0xa45e8b73, (q31_t)0x595b65aa, (q31_t)0xa45a2872, (q31_t)0x5956e5e0, (q31_t)0xa455c5a9, - (q31_t)0x595265df, (q31_t)0xa4516319, (q31_t)0x594de5a7, (q31_t)0xa44d00c2, (q31_t)0x59496538, (q31_t)0xa4489ea3, (q31_t)0x5944e492, (q31_t)0xa4443cbd, - (q31_t)0x594063b5, (q31_t)0xa43fdb10, (q31_t)0x593be2a0, (q31_t)0xa43b799a, (q31_t)0x59376155, (q31_t)0xa437185e, (q31_t)0x5932dfd3, (q31_t)0xa432b75a, - (q31_t)0x592e5e19, (q31_t)0xa42e568f, (q31_t)0x5929dc29, (q31_t)0xa429f5fd, (q31_t)0x59255a02, (q31_t)0xa42595a3, (q31_t)0x5920d7a3, (q31_t)0xa4213581, - (q31_t)0x591c550e, (q31_t)0xa41cd599, (q31_t)0x5917d242, (q31_t)0xa41875e9, (q31_t)0x59134f3e, (q31_t)0xa4141672, (q31_t)0x590ecc04, (q31_t)0xa40fb733, - (q31_t)0x590a4893, (q31_t)0xa40b582e, (q31_t)0x5905c4eb, (q31_t)0xa406f960, (q31_t)0x5901410c, (q31_t)0xa4029acc, (q31_t)0x58fcbcf6, (q31_t)0xa3fe3c71, - (q31_t)0x58f838a9, (q31_t)0xa3f9de4e, (q31_t)0x58f3b426, (q31_t)0xa3f58064, (q31_t)0x58ef2f6b, (q31_t)0xa3f122b2, (q31_t)0x58eaaa7a, (q31_t)0xa3ecc53a, - (q31_t)0x58e62552, (q31_t)0xa3e867fa, (q31_t)0x58e19ff3, (q31_t)0xa3e40af3, (q31_t)0x58dd1a5d, (q31_t)0xa3dfae25, (q31_t)0x58d89490, (q31_t)0xa3db5190, - (q31_t)0x58d40e8c, (q31_t)0xa3d6f534, (q31_t)0x58cf8852, (q31_t)0xa3d29910, (q31_t)0x58cb01e1, (q31_t)0xa3ce3d25, (q31_t)0x58c67b39, (q31_t)0xa3c9e174, - (q31_t)0x58c1f45b, (q31_t)0xa3c585fb, (q31_t)0x58bd6d45, (q31_t)0xa3c12abb, (q31_t)0x58b8e5f9, (q31_t)0xa3bccfb3, (q31_t)0x58b45e76, (q31_t)0xa3b874e5, - (q31_t)0x58afd6bd, (q31_t)0xa3b41a50, (q31_t)0x58ab4ecc, (q31_t)0xa3afbff3, (q31_t)0x58a6c6a5, (q31_t)0xa3ab65d0, (q31_t)0x58a23e48, (q31_t)0xa3a70be6, - (q31_t)0x589db5b3, (q31_t)0xa3a2b234, (q31_t)0x58992ce9, (q31_t)0xa39e58bb, (q31_t)0x5894a3e7, (q31_t)0xa399ff7c, (q31_t)0x58901aaf, (q31_t)0xa395a675, - (q31_t)0x588b9140, (q31_t)0xa3914da8, (q31_t)0x5887079a, (q31_t)0xa38cf513, (q31_t)0x58827dbe, (q31_t)0xa3889cb8, (q31_t)0x587df3ab, (q31_t)0xa3844495, - (q31_t)0x58796962, (q31_t)0xa37fecac, (q31_t)0x5874dee2, (q31_t)0xa37b94fb, (q31_t)0x5870542c, (q31_t)0xa3773d84, (q31_t)0x586bc93f, (q31_t)0xa372e646, - (q31_t)0x58673e1b, (q31_t)0xa36e8f41, (q31_t)0x5862b2c1, (q31_t)0xa36a3875, (q31_t)0x585e2730, (q31_t)0xa365e1e2, (q31_t)0x58599b69, (q31_t)0xa3618b88, - (q31_t)0x58550f6c, (q31_t)0xa35d3567, (q31_t)0x58508338, (q31_t)0xa358df80, (q31_t)0x584bf6cd, (q31_t)0xa35489d1, (q31_t)0x58476a2c, (q31_t)0xa350345c, - (q31_t)0x5842dd54, (q31_t)0xa34bdf20, (q31_t)0x583e5047, (q31_t)0xa3478a1d, (q31_t)0x5839c302, (q31_t)0xa3433554, (q31_t)0x58353587, (q31_t)0xa33ee0c3, - (q31_t)0x5830a7d6, (q31_t)0xa33a8c6c, (q31_t)0x582c19ef, (q31_t)0xa336384e, (q31_t)0x58278bd1, (q31_t)0xa331e469, (q31_t)0x5822fd7c, (q31_t)0xa32d90be, - (q31_t)0x581e6ef1, (q31_t)0xa3293d4b, (q31_t)0x5819e030, (q31_t)0xa324ea13, (q31_t)0x58155139, (q31_t)0xa3209713, (q31_t)0x5810c20b, (q31_t)0xa31c444c, - (q31_t)0x580c32a7, (q31_t)0xa317f1bf, (q31_t)0x5807a30d, (q31_t)0xa3139f6b, (q31_t)0x5803133c, (q31_t)0xa30f4d51, (q31_t)0x57fe8335, (q31_t)0xa30afb70, - (q31_t)0x57f9f2f8, (q31_t)0xa306a9c8, (q31_t)0x57f56284, (q31_t)0xa3025859, (q31_t)0x57f0d1da, (q31_t)0xa2fe0724, (q31_t)0x57ec40fa, (q31_t)0xa2f9b629, - (q31_t)0x57e7afe4, (q31_t)0xa2f56566, (q31_t)0x57e31e97, (q31_t)0xa2f114dd, (q31_t)0x57de8d15, (q31_t)0xa2ecc48e, (q31_t)0x57d9fb5c, (q31_t)0xa2e87477, - (q31_t)0x57d5696d, (q31_t)0xa2e4249b, (q31_t)0x57d0d747, (q31_t)0xa2dfd4f7, (q31_t)0x57cc44ec, (q31_t)0xa2db858e, (q31_t)0x57c7b25a, (q31_t)0xa2d7365d, - (q31_t)0x57c31f92, (q31_t)0xa2d2e766, (q31_t)0x57be8c94, (q31_t)0xa2ce98a9, (q31_t)0x57b9f960, (q31_t)0xa2ca4a25, (q31_t)0x57b565f6, (q31_t)0xa2c5fbda, - (q31_t)0x57b0d256, (q31_t)0xa2c1adc9, (q31_t)0x57ac3e80, (q31_t)0xa2bd5ff2, (q31_t)0x57a7aa73, (q31_t)0xa2b91254, (q31_t)0x57a31631, (q31_t)0xa2b4c4f0, - (q31_t)0x579e81b8, (q31_t)0xa2b077c5, (q31_t)0x5799ed0a, (q31_t)0xa2ac2ad3, (q31_t)0x57955825, (q31_t)0xa2a7de1c, (q31_t)0x5790c30a, (q31_t)0xa2a3919e, - (q31_t)0x578c2dba, (q31_t)0xa29f4559, (q31_t)0x57879833, (q31_t)0xa29af94e, (q31_t)0x57830276, (q31_t)0xa296ad7d, (q31_t)0x577e6c84, (q31_t)0xa29261e5, - (q31_t)0x5779d65b, (q31_t)0xa28e1687, (q31_t)0x57753ffc, (q31_t)0xa289cb63, (q31_t)0x5770a968, (q31_t)0xa2858078, (q31_t)0x576c129d, (q31_t)0xa28135c7, - (q31_t)0x57677b9d, (q31_t)0xa27ceb4f, (q31_t)0x5762e467, (q31_t)0xa278a111, (q31_t)0x575e4cfa, (q31_t)0xa274570d, (q31_t)0x5759b558, (q31_t)0xa2700d43, - (q31_t)0x57551d80, (q31_t)0xa26bc3b2, (q31_t)0x57508572, (q31_t)0xa2677a5b, (q31_t)0x574bed2f, (q31_t)0xa263313e, (q31_t)0x574754b5, (q31_t)0xa25ee85b, - (q31_t)0x5742bc06, (q31_t)0xa25a9fb1, (q31_t)0x573e2320, (q31_t)0xa2565741, (q31_t)0x57398a05, (q31_t)0xa2520f0b, (q31_t)0x5734f0b5, (q31_t)0xa24dc70f, - (q31_t)0x5730572e, (q31_t)0xa2497f4c, (q31_t)0x572bbd71, (q31_t)0xa24537c3, (q31_t)0x5727237f, (q31_t)0xa240f074, (q31_t)0x57228957, (q31_t)0xa23ca95f, - (q31_t)0x571deefa, (q31_t)0xa2386284, (q31_t)0x57195466, (q31_t)0xa2341be3, (q31_t)0x5714b99d, (q31_t)0xa22fd57b, (q31_t)0x57101e9e, (q31_t)0xa22b8f4d, - (q31_t)0x570b8369, (q31_t)0xa2274959, (q31_t)0x5706e7ff, (q31_t)0xa223039f, (q31_t)0x57024c5f, (q31_t)0xa21ebe1f, (q31_t)0x56fdb08a, (q31_t)0xa21a78d9, - (q31_t)0x56f9147e, (q31_t)0xa21633cd, (q31_t)0x56f4783d, (q31_t)0xa211eefb, (q31_t)0x56efdbc7, (q31_t)0xa20daa62, (q31_t)0x56eb3f1a, (q31_t)0xa2096604, - (q31_t)0x56e6a239, (q31_t)0xa20521e0, (q31_t)0x56e20521, (q31_t)0xa200ddf5, (q31_t)0x56dd67d4, (q31_t)0xa1fc9a45, (q31_t)0x56d8ca51, (q31_t)0xa1f856ce, - (q31_t)0x56d42c99, (q31_t)0xa1f41392, (q31_t)0x56cf8eab, (q31_t)0xa1efd08f, (q31_t)0x56caf088, (q31_t)0xa1eb8dc7, (q31_t)0x56c6522f, (q31_t)0xa1e74b38, - (q31_t)0x56c1b3a1, (q31_t)0xa1e308e4, (q31_t)0x56bd14dd, (q31_t)0xa1dec6ca, (q31_t)0x56b875e4, (q31_t)0xa1da84e9, (q31_t)0x56b3d6b5, (q31_t)0xa1d64343, - (q31_t)0x56af3750, (q31_t)0xa1d201d7, (q31_t)0x56aa97b7, (q31_t)0xa1cdc0a5, (q31_t)0x56a5f7e7, (q31_t)0xa1c97fad, (q31_t)0x56a157e3, (q31_t)0xa1c53ef0, - (q31_t)0x569cb7a8, (q31_t)0xa1c0fe6c, (q31_t)0x56981739, (q31_t)0xa1bcbe22, (q31_t)0x56937694, (q31_t)0xa1b87e13, (q31_t)0x568ed5b9, (q31_t)0xa1b43e3e, - (q31_t)0x568a34a9, (q31_t)0xa1affea3, (q31_t)0x56859364, (q31_t)0xa1abbf42, (q31_t)0x5680f1ea, (q31_t)0xa1a7801b, (q31_t)0x567c503a, (q31_t)0xa1a3412f, - (q31_t)0x5677ae54, (q31_t)0xa19f027c, (q31_t)0x56730c3a, (q31_t)0xa19ac404, (q31_t)0x566e69ea, (q31_t)0xa19685c7, (q31_t)0x5669c765, (q31_t)0xa19247c3, - (q31_t)0x566524aa, (q31_t)0xa18e09fa, (q31_t)0x566081ba, (q31_t)0xa189cc6b, (q31_t)0x565bde95, (q31_t)0xa1858f16, (q31_t)0x56573b3b, (q31_t)0xa18151fb, - (q31_t)0x565297ab, (q31_t)0xa17d151b, (q31_t)0x564df3e6, (q31_t)0xa178d875, (q31_t)0x56494fec, (q31_t)0xa1749c09, (q31_t)0x5644abbc, (q31_t)0xa1705fd8, - (q31_t)0x56400758, (q31_t)0xa16c23e1, (q31_t)0x563b62be, (q31_t)0xa167e824, (q31_t)0x5636bdef, (q31_t)0xa163aca2, (q31_t)0x563218eb, (q31_t)0xa15f715a, - (q31_t)0x562d73b2, (q31_t)0xa15b364d, (q31_t)0x5628ce43, (q31_t)0xa156fb79, (q31_t)0x5624289f, (q31_t)0xa152c0e1, (q31_t)0x561f82c7, (q31_t)0xa14e8682, - (q31_t)0x561adcb9, (q31_t)0xa14a4c5e, (q31_t)0x56163676, (q31_t)0xa1461275, (q31_t)0x56118ffe, (q31_t)0xa141d8c5, (q31_t)0x560ce950, (q31_t)0xa13d9f51, - (q31_t)0x5608426e, (q31_t)0xa1396617, (q31_t)0x56039b57, (q31_t)0xa1352d17, (q31_t)0x55fef40a, (q31_t)0xa130f451, (q31_t)0x55fa4c89, (q31_t)0xa12cbbc7, - (q31_t)0x55f5a4d2, (q31_t)0xa1288376, (q31_t)0x55f0fce7, (q31_t)0xa1244b61, (q31_t)0x55ec54c6, (q31_t)0xa1201385, (q31_t)0x55e7ac71, (q31_t)0xa11bdbe4, - (q31_t)0x55e303e6, (q31_t)0xa117a47e, (q31_t)0x55de5b27, (q31_t)0xa1136d52, (q31_t)0x55d9b232, (q31_t)0xa10f3661, (q31_t)0x55d50909, (q31_t)0xa10affab, - (q31_t)0x55d05faa, (q31_t)0xa106c92f, (q31_t)0x55cbb617, (q31_t)0xa10292ed, (q31_t)0x55c70c4f, (q31_t)0xa0fe5ce6, (q31_t)0x55c26251, (q31_t)0xa0fa271a, - (q31_t)0x55bdb81f, (q31_t)0xa0f5f189, (q31_t)0x55b90db8, (q31_t)0xa0f1bc32, (q31_t)0x55b4631d, (q31_t)0xa0ed8715, (q31_t)0x55afb84c, (q31_t)0xa0e95234, - (q31_t)0x55ab0d46, (q31_t)0xa0e51d8c, (q31_t)0x55a6620c, (q31_t)0xa0e0e920, (q31_t)0x55a1b69d, (q31_t)0xa0dcb4ee, (q31_t)0x559d0af9, (q31_t)0xa0d880f7, - (q31_t)0x55985f20, (q31_t)0xa0d44d3b, (q31_t)0x5593b312, (q31_t)0xa0d019b9, (q31_t)0x558f06d0, (q31_t)0xa0cbe672, (q31_t)0x558a5a58, (q31_t)0xa0c7b366, - (q31_t)0x5585adad, (q31_t)0xa0c38095, (q31_t)0x558100cc, (q31_t)0xa0bf4dfe, (q31_t)0x557c53b6, (q31_t)0xa0bb1ba2, (q31_t)0x5577a66c, (q31_t)0xa0b6e981, - (q31_t)0x5572f8ed, (q31_t)0xa0b2b79b, (q31_t)0x556e4b39, (q31_t)0xa0ae85ef, (q31_t)0x55699d51, (q31_t)0xa0aa547e, (q31_t)0x5564ef34, (q31_t)0xa0a62348, - (q31_t)0x556040e2, (q31_t)0xa0a1f24d, (q31_t)0x555b925c, (q31_t)0xa09dc18d, (q31_t)0x5556e3a1, (q31_t)0xa0999107, (q31_t)0x555234b1, (q31_t)0xa09560bc, - (q31_t)0x554d858d, (q31_t)0xa09130ad, (q31_t)0x5548d634, (q31_t)0xa08d00d8, (q31_t)0x554426a7, (q31_t)0xa088d13e, (q31_t)0x553f76e4, (q31_t)0xa084a1de, - (q31_t)0x553ac6ee, (q31_t)0xa08072ba, (q31_t)0x553616c2, (q31_t)0xa07c43d1, (q31_t)0x55316663, (q31_t)0xa0781522, (q31_t)0x552cb5ce, (q31_t)0xa073e6af, - (q31_t)0x55280505, (q31_t)0xa06fb876, (q31_t)0x55235408, (q31_t)0xa06b8a78, (q31_t)0x551ea2d6, (q31_t)0xa0675cb6, (q31_t)0x5519f16f, (q31_t)0xa0632f2e, - (q31_t)0x55153fd4, (q31_t)0xa05f01e1, (q31_t)0x55108e05, (q31_t)0xa05ad4cf, (q31_t)0x550bdc01, (q31_t)0xa056a7f9, (q31_t)0x550729c9, (q31_t)0xa0527b5d, - (q31_t)0x5502775c, (q31_t)0xa04e4efc, (q31_t)0x54fdc4ba, (q31_t)0xa04a22d7, (q31_t)0x54f911e5, (q31_t)0xa045f6ec, (q31_t)0x54f45edb, (q31_t)0xa041cb3c, - (q31_t)0x54efab9c, (q31_t)0xa03d9fc8, (q31_t)0x54eaf829, (q31_t)0xa039748e, (q31_t)0x54e64482, (q31_t)0xa0354990, (q31_t)0x54e190a6, (q31_t)0xa0311ecd, - (q31_t)0x54dcdc96, (q31_t)0xa02cf444, (q31_t)0x54d82852, (q31_t)0xa028c9f7, (q31_t)0x54d373d9, (q31_t)0xa0249fe5, (q31_t)0x54cebf2c, (q31_t)0xa020760e, - (q31_t)0x54ca0a4b, (q31_t)0xa01c4c73, (q31_t)0x54c55535, (q31_t)0xa0182312, (q31_t)0x54c09feb, (q31_t)0xa013f9ed, (q31_t)0x54bbea6d, (q31_t)0xa00fd102, - (q31_t)0x54b734ba, (q31_t)0xa00ba853, (q31_t)0x54b27ed3, (q31_t)0xa0077fdf, (q31_t)0x54adc8b8, (q31_t)0xa00357a7, (q31_t)0x54a91269, (q31_t)0x9fff2fa9, - (q31_t)0x54a45be6, (q31_t)0x9ffb07e7, (q31_t)0x549fa52e, (q31_t)0x9ff6e060, (q31_t)0x549aee42, (q31_t)0x9ff2b914, (q31_t)0x54963722, (q31_t)0x9fee9204, - (q31_t)0x54917fce, (q31_t)0x9fea6b2f, (q31_t)0x548cc845, (q31_t)0x9fe64495, (q31_t)0x54881089, (q31_t)0x9fe21e36, (q31_t)0x54835898, (q31_t)0x9fddf812, - (q31_t)0x547ea073, (q31_t)0x9fd9d22a, (q31_t)0x5479e81a, (q31_t)0x9fd5ac7d, (q31_t)0x54752f8d, (q31_t)0x9fd1870c, (q31_t)0x547076cc, (q31_t)0x9fcd61d6, - (q31_t)0x546bbdd7, (q31_t)0x9fc93cdb, (q31_t)0x546704ae, (q31_t)0x9fc5181b, (q31_t)0x54624b50, (q31_t)0x9fc0f397, (q31_t)0x545d91bf, (q31_t)0x9fbccf4f, - (q31_t)0x5458d7f9, (q31_t)0x9fb8ab41, (q31_t)0x54541e00, (q31_t)0x9fb4876f, (q31_t)0x544f63d2, (q31_t)0x9fb063d9, (q31_t)0x544aa971, (q31_t)0x9fac407e, - (q31_t)0x5445eedb, (q31_t)0x9fa81d5e, (q31_t)0x54413412, (q31_t)0x9fa3fa79, (q31_t)0x543c7914, (q31_t)0x9f9fd7d1, (q31_t)0x5437bde3, (q31_t)0x9f9bb563, - (q31_t)0x5433027d, (q31_t)0x9f979331, (q31_t)0x542e46e4, (q31_t)0x9f93713b, (q31_t)0x54298b17, (q31_t)0x9f8f4f80, (q31_t)0x5424cf16, (q31_t)0x9f8b2e00, - (q31_t)0x542012e1, (q31_t)0x9f870cbc, (q31_t)0x541b5678, (q31_t)0x9f82ebb4, (q31_t)0x541699db, (q31_t)0x9f7ecae7, (q31_t)0x5411dd0a, (q31_t)0x9f7aaa55, - (q31_t)0x540d2005, (q31_t)0x9f7689ff, (q31_t)0x540862cd, (q31_t)0x9f7269e5, (q31_t)0x5403a561, (q31_t)0x9f6e4a06, (q31_t)0x53fee7c1, (q31_t)0x9f6a2a63, - (q31_t)0x53fa29ed, (q31_t)0x9f660afb, (q31_t)0x53f56be5, (q31_t)0x9f61ebcf, (q31_t)0x53f0adaa, (q31_t)0x9f5dccde, (q31_t)0x53ebef3a, (q31_t)0x9f59ae29, - (q31_t)0x53e73097, (q31_t)0x9f558fb0, (q31_t)0x53e271c0, (q31_t)0x9f517173, (q31_t)0x53ddb2b6, (q31_t)0x9f4d5371, (q31_t)0x53d8f378, (q31_t)0x9f4935aa, - (q31_t)0x53d43406, (q31_t)0x9f45181f, (q31_t)0x53cf7460, (q31_t)0x9f40fad0, (q31_t)0x53cab486, (q31_t)0x9f3cddbd, (q31_t)0x53c5f479, (q31_t)0x9f38c0e5, - (q31_t)0x53c13439, (q31_t)0x9f34a449, (q31_t)0x53bc73c4, (q31_t)0x9f3087e9, (q31_t)0x53b7b31c, (q31_t)0x9f2c6bc5, (q31_t)0x53b2f240, (q31_t)0x9f284fdc, - (q31_t)0x53ae3131, (q31_t)0x9f24342f, (q31_t)0x53a96fee, (q31_t)0x9f2018bd, (q31_t)0x53a4ae77, (q31_t)0x9f1bfd88, (q31_t)0x539feccd, (q31_t)0x9f17e28e, - (q31_t)0x539b2af0, (q31_t)0x9f13c7d0, (q31_t)0x539668de, (q31_t)0x9f0fad4e, (q31_t)0x5391a699, (q31_t)0x9f0b9307, (q31_t)0x538ce421, (q31_t)0x9f0778fd, - (q31_t)0x53882175, (q31_t)0x9f035f2e, (q31_t)0x53835e95, (q31_t)0x9eff459b, (q31_t)0x537e9b82, (q31_t)0x9efb2c44, (q31_t)0x5379d83c, (q31_t)0x9ef71328, - (q31_t)0x537514c2, (q31_t)0x9ef2fa49, (q31_t)0x53705114, (q31_t)0x9eeee1a5, (q31_t)0x536b8d33, (q31_t)0x9eeac93e, (q31_t)0x5366c91f, (q31_t)0x9ee6b112, - (q31_t)0x536204d7, (q31_t)0x9ee29922, (q31_t)0x535d405c, (q31_t)0x9ede816e, (q31_t)0x53587bad, (q31_t)0x9eda69f6, (q31_t)0x5353b6cb, (q31_t)0x9ed652ba, - (q31_t)0x534ef1b5, (q31_t)0x9ed23bb9, (q31_t)0x534a2c6c, (q31_t)0x9ece24f5, (q31_t)0x534566f0, (q31_t)0x9eca0e6d, (q31_t)0x5340a140, (q31_t)0x9ec5f820, - (q31_t)0x533bdb5d, (q31_t)0x9ec1e210, (q31_t)0x53371547, (q31_t)0x9ebdcc3b, (q31_t)0x53324efd, (q31_t)0x9eb9b6a3, (q31_t)0x532d8880, (q31_t)0x9eb5a146, - (q31_t)0x5328c1d0, (q31_t)0x9eb18c26, (q31_t)0x5323faec, (q31_t)0x9ead7742, (q31_t)0x531f33d5, (q31_t)0x9ea96299, (q31_t)0x531a6c8b, (q31_t)0x9ea54e2d, - (q31_t)0x5315a50e, (q31_t)0x9ea139fd, (q31_t)0x5310dd5d, (q31_t)0x9e9d2608, (q31_t)0x530c1579, (q31_t)0x9e991250, (q31_t)0x53074d62, (q31_t)0x9e94fed4, - (q31_t)0x53028518, (q31_t)0x9e90eb94, (q31_t)0x52fdbc9a, (q31_t)0x9e8cd890, (q31_t)0x52f8f3e9, (q31_t)0x9e88c5c9, (q31_t)0x52f42b05, (q31_t)0x9e84b33d, - (q31_t)0x52ef61ee, (q31_t)0x9e80a0ee, (q31_t)0x52ea98a4, (q31_t)0x9e7c8eda, (q31_t)0x52e5cf27, (q31_t)0x9e787d03, (q31_t)0x52e10576, (q31_t)0x9e746b68, - (q31_t)0x52dc3b92, (q31_t)0x9e705a09, (q31_t)0x52d7717b, (q31_t)0x9e6c48e7, (q31_t)0x52d2a732, (q31_t)0x9e683800, (q31_t)0x52cddcb5, (q31_t)0x9e642756, - (q31_t)0x52c91204, (q31_t)0x9e6016e8, (q31_t)0x52c44721, (q31_t)0x9e5c06b6, (q31_t)0x52bf7c0b, (q31_t)0x9e57f6c0, (q31_t)0x52bab0c2, (q31_t)0x9e53e707, - (q31_t)0x52b5e546, (q31_t)0x9e4fd78a, (q31_t)0x52b11996, (q31_t)0x9e4bc849, (q31_t)0x52ac4db4, (q31_t)0x9e47b944, (q31_t)0x52a7819f, (q31_t)0x9e43aa7c, - (q31_t)0x52a2b556, (q31_t)0x9e3f9bf0, (q31_t)0x529de8db, (q31_t)0x9e3b8da0, (q31_t)0x52991c2d, (q31_t)0x9e377f8c, (q31_t)0x52944f4c, (q31_t)0x9e3371b5, - (q31_t)0x528f8238, (q31_t)0x9e2f641b, (q31_t)0x528ab4f1, (q31_t)0x9e2b56bc, (q31_t)0x5285e777, (q31_t)0x9e27499a, (q31_t)0x528119ca, (q31_t)0x9e233cb4, - (q31_t)0x527c4bea, (q31_t)0x9e1f300b, (q31_t)0x52777dd7, (q31_t)0x9e1b239e, (q31_t)0x5272af92, (q31_t)0x9e17176d, (q31_t)0x526de11a, (q31_t)0x9e130b79, - (q31_t)0x5269126e, (q31_t)0x9e0effc1, (q31_t)0x52644390, (q31_t)0x9e0af446, (q31_t)0x525f7480, (q31_t)0x9e06e907, (q31_t)0x525aa53c, (q31_t)0x9e02de04, - (q31_t)0x5255d5c5, (q31_t)0x9dfed33e, (q31_t)0x5251061c, (q31_t)0x9dfac8b4, (q31_t)0x524c3640, (q31_t)0x9df6be67, (q31_t)0x52476631, (q31_t)0x9df2b456, - (q31_t)0x524295f0, (q31_t)0x9deeaa82, (q31_t)0x523dc57b, (q31_t)0x9deaa0ea, (q31_t)0x5238f4d4, (q31_t)0x9de6978f, (q31_t)0x523423fb, (q31_t)0x9de28e70, - (q31_t)0x522f52ee, (q31_t)0x9dde858e, (q31_t)0x522a81af, (q31_t)0x9dda7ce9, (q31_t)0x5225b03d, (q31_t)0x9dd6747f, (q31_t)0x5220de99, (q31_t)0x9dd26c53, - (q31_t)0x521c0cc2, (q31_t)0x9dce6463, (q31_t)0x52173ab8, (q31_t)0x9dca5caf, (q31_t)0x5212687b, (q31_t)0x9dc65539, (q31_t)0x520d960c, (q31_t)0x9dc24dfe, - (q31_t)0x5208c36a, (q31_t)0x9dbe4701, (q31_t)0x5203f096, (q31_t)0x9dba4040, (q31_t)0x51ff1d8f, (q31_t)0x9db639bb, (q31_t)0x51fa4a56, (q31_t)0x9db23373, - (q31_t)0x51f576ea, (q31_t)0x9dae2d68, (q31_t)0x51f0a34b, (q31_t)0x9daa279a, (q31_t)0x51ebcf7a, (q31_t)0x9da62208, (q31_t)0x51e6fb76, (q31_t)0x9da21cb2, - (q31_t)0x51e22740, (q31_t)0x9d9e179a, (q31_t)0x51dd52d7, (q31_t)0x9d9a12be, (q31_t)0x51d87e3c, (q31_t)0x9d960e1f, (q31_t)0x51d3a96f, (q31_t)0x9d9209bd, - (q31_t)0x51ced46e, (q31_t)0x9d8e0597, (q31_t)0x51c9ff3c, (q31_t)0x9d8a01ae, (q31_t)0x51c529d7, (q31_t)0x9d85fe02, (q31_t)0x51c0543f, (q31_t)0x9d81fa92, - (q31_t)0x51bb7e75, (q31_t)0x9d7df75f, (q31_t)0x51b6a879, (q31_t)0x9d79f469, (q31_t)0x51b1d24a, (q31_t)0x9d75f1b0, (q31_t)0x51acfbe9, (q31_t)0x9d71ef34, - (q31_t)0x51a82555, (q31_t)0x9d6decf4, (q31_t)0x51a34e8f, (q31_t)0x9d69eaf1, (q31_t)0x519e7797, (q31_t)0x9d65e92b, (q31_t)0x5199a06d, (q31_t)0x9d61e7a2, - (q31_t)0x5194c910, (q31_t)0x9d5de656, (q31_t)0x518ff180, (q31_t)0x9d59e546, (q31_t)0x518b19bf, (q31_t)0x9d55e473, (q31_t)0x518641cb, (q31_t)0x9d51e3dd, - (q31_t)0x518169a5, (q31_t)0x9d4de385, (q31_t)0x517c914c, (q31_t)0x9d49e368, (q31_t)0x5177b8c2, (q31_t)0x9d45e389, (q31_t)0x5172e005, (q31_t)0x9d41e3e7, - (q31_t)0x516e0715, (q31_t)0x9d3de482, (q31_t)0x51692df4, (q31_t)0x9d39e559, (q31_t)0x516454a0, (q31_t)0x9d35e66e, (q31_t)0x515f7b1a, (q31_t)0x9d31e7bf, - (q31_t)0x515aa162, (q31_t)0x9d2de94d, (q31_t)0x5155c778, (q31_t)0x9d29eb19, (q31_t)0x5150ed5c, (q31_t)0x9d25ed21, (q31_t)0x514c130d, (q31_t)0x9d21ef66, - (q31_t)0x5147388c, (q31_t)0x9d1df1e9, (q31_t)0x51425dd9, (q31_t)0x9d19f4a8, (q31_t)0x513d82f4, (q31_t)0x9d15f7a4, (q31_t)0x5138a7dd, (q31_t)0x9d11fadd, - (q31_t)0x5133cc94, (q31_t)0x9d0dfe54, (q31_t)0x512ef119, (q31_t)0x9d0a0207, (q31_t)0x512a156b, (q31_t)0x9d0605f7, (q31_t)0x5125398c, (q31_t)0x9d020a25, - (q31_t)0x51205d7b, (q31_t)0x9cfe0e8f, (q31_t)0x511b8137, (q31_t)0x9cfa1337, (q31_t)0x5116a4c1, (q31_t)0x9cf6181c, (q31_t)0x5111c81a, (q31_t)0x9cf21d3d, - (q31_t)0x510ceb40, (q31_t)0x9cee229c, (q31_t)0x51080e35, (q31_t)0x9cea2838, (q31_t)0x510330f7, (q31_t)0x9ce62e11, (q31_t)0x50fe5388, (q31_t)0x9ce23427, - (q31_t)0x50f975e6, (q31_t)0x9cde3a7b, (q31_t)0x50f49813, (q31_t)0x9cda410b, (q31_t)0x50efba0d, (q31_t)0x9cd647d9, (q31_t)0x50eadbd6, (q31_t)0x9cd24ee4, - (q31_t)0x50e5fd6d, (q31_t)0x9cce562c, (q31_t)0x50e11ed2, (q31_t)0x9cca5db1, (q31_t)0x50dc4005, (q31_t)0x9cc66573, (q31_t)0x50d76106, (q31_t)0x9cc26d73, - (q31_t)0x50d281d5, (q31_t)0x9cbe75b0, (q31_t)0x50cda272, (q31_t)0x9cba7e2a, (q31_t)0x50c8c2de, (q31_t)0x9cb686e1, (q31_t)0x50c3e317, (q31_t)0x9cb28fd5, - (q31_t)0x50bf031f, (q31_t)0x9cae9907, (q31_t)0x50ba22f5, (q31_t)0x9caaa276, (q31_t)0x50b5429a, (q31_t)0x9ca6ac23, (q31_t)0x50b0620c, (q31_t)0x9ca2b60c, - (q31_t)0x50ab814d, (q31_t)0x9c9ec033, (q31_t)0x50a6a05c, (q31_t)0x9c9aca97, (q31_t)0x50a1bf39, (q31_t)0x9c96d539, (q31_t)0x509cdde4, (q31_t)0x9c92e017, - (q31_t)0x5097fc5e, (q31_t)0x9c8eeb34, (q31_t)0x50931aa6, (q31_t)0x9c8af68d, (q31_t)0x508e38bd, (q31_t)0x9c870224, (q31_t)0x508956a1, (q31_t)0x9c830df8, - (q31_t)0x50847454, (q31_t)0x9c7f1a0a, (q31_t)0x507f91d5, (q31_t)0x9c7b2659, (q31_t)0x507aaf25, (q31_t)0x9c7732e5, (q31_t)0x5075cc43, (q31_t)0x9c733faf, - (q31_t)0x5070e92f, (q31_t)0x9c6f4cb6, (q31_t)0x506c05ea, (q31_t)0x9c6b59fa, (q31_t)0x50672273, (q31_t)0x9c67677c, (q31_t)0x50623ecb, (q31_t)0x9c63753c, - (q31_t)0x505d5af1, (q31_t)0x9c5f8339, (q31_t)0x505876e5, (q31_t)0x9c5b9173, (q31_t)0x505392a8, (q31_t)0x9c579feb, (q31_t)0x504eae39, (q31_t)0x9c53aea0, - (q31_t)0x5049c999, (q31_t)0x9c4fbd93, (q31_t)0x5044e4c7, (q31_t)0x9c4bccc3, (q31_t)0x503fffc4, (q31_t)0x9c47dc31, (q31_t)0x503b1a8f, (q31_t)0x9c43ebdc, - (q31_t)0x50363529, (q31_t)0x9c3ffbc5, (q31_t)0x50314f91, (q31_t)0x9c3c0beb, (q31_t)0x502c69c8, (q31_t)0x9c381c4f, (q31_t)0x502783cd, (q31_t)0x9c342cf0, - (q31_t)0x50229da1, (q31_t)0x9c303dcf, (q31_t)0x501db743, (q31_t)0x9c2c4eec, (q31_t)0x5018d0b4, (q31_t)0x9c286046, (q31_t)0x5013e9f4, (q31_t)0x9c2471de, - (q31_t)0x500f0302, (q31_t)0x9c2083b3, (q31_t)0x500a1bdf, (q31_t)0x9c1c95c6, (q31_t)0x5005348a, (q31_t)0x9c18a816, (q31_t)0x50004d04, (q31_t)0x9c14baa4, - (q31_t)0x4ffb654d, (q31_t)0x9c10cd70, (q31_t)0x4ff67d64, (q31_t)0x9c0ce07a, (q31_t)0x4ff1954b, (q31_t)0x9c08f3c1, (q31_t)0x4fecacff, (q31_t)0x9c050745, - (q31_t)0x4fe7c483, (q31_t)0x9c011b08, (q31_t)0x4fe2dbd5, (q31_t)0x9bfd2f08, (q31_t)0x4fddf2f6, (q31_t)0x9bf94346, (q31_t)0x4fd909e5, (q31_t)0x9bf557c1, - (q31_t)0x4fd420a4, (q31_t)0x9bf16c7a, (q31_t)0x4fcf3731, (q31_t)0x9bed8171, (q31_t)0x4fca4d8d, (q31_t)0x9be996a6, (q31_t)0x4fc563b7, (q31_t)0x9be5ac18, - (q31_t)0x4fc079b1, (q31_t)0x9be1c1c8, (q31_t)0x4fbb8f79, (q31_t)0x9bddd7b6, (q31_t)0x4fb6a510, (q31_t)0x9bd9ede2, (q31_t)0x4fb1ba76, (q31_t)0x9bd6044b, - (q31_t)0x4faccfab, (q31_t)0x9bd21af3, (q31_t)0x4fa7e4af, (q31_t)0x9bce31d8, (q31_t)0x4fa2f981, (q31_t)0x9bca48fa, (q31_t)0x4f9e0e22, (q31_t)0x9bc6605b, - (q31_t)0x4f992293, (q31_t)0x9bc277fa, (q31_t)0x4f9436d2, (q31_t)0x9bbe8fd6, (q31_t)0x4f8f4ae0, (q31_t)0x9bbaa7f0, (q31_t)0x4f8a5ebd, (q31_t)0x9bb6c048, - (q31_t)0x4f857269, (q31_t)0x9bb2d8de, (q31_t)0x4f8085e4, (q31_t)0x9baef1b2, (q31_t)0x4f7b992d, (q31_t)0x9bab0ac3, (q31_t)0x4f76ac46, (q31_t)0x9ba72413, - (q31_t)0x4f71bf2e, (q31_t)0x9ba33da0, (q31_t)0x4f6cd1e5, (q31_t)0x9b9f576b, (q31_t)0x4f67e46a, (q31_t)0x9b9b7174, (q31_t)0x4f62f6bf, (q31_t)0x9b978bbc, - (q31_t)0x4f5e08e3, (q31_t)0x9b93a641, (q31_t)0x4f591ad6, (q31_t)0x9b8fc104, (q31_t)0x4f542c98, (q31_t)0x9b8bdc05, (q31_t)0x4f4f3e29, (q31_t)0x9b87f744, - (q31_t)0x4f4a4f89, (q31_t)0x9b8412c1, (q31_t)0x4f4560b8, (q31_t)0x9b802e7b, (q31_t)0x4f4071b6, (q31_t)0x9b7c4a74, (q31_t)0x4f3b8284, (q31_t)0x9b7866ab, - (q31_t)0x4f369320, (q31_t)0x9b748320, (q31_t)0x4f31a38c, (q31_t)0x9b709fd3, (q31_t)0x4f2cb3c7, (q31_t)0x9b6cbcc4, (q31_t)0x4f27c3d1, (q31_t)0x9b68d9f3, - (q31_t)0x4f22d3aa, (q31_t)0x9b64f760, (q31_t)0x4f1de352, (q31_t)0x9b61150b, (q31_t)0x4f18f2c9, (q31_t)0x9b5d32f4, (q31_t)0x4f140210, (q31_t)0x9b59511c, - (q31_t)0x4f0f1126, (q31_t)0x9b556f81, (q31_t)0x4f0a200b, (q31_t)0x9b518e24, (q31_t)0x4f052ec0, (q31_t)0x9b4dad06, (q31_t)0x4f003d43, (q31_t)0x9b49cc26, - (q31_t)0x4efb4b96, (q31_t)0x9b45eb83, (q31_t)0x4ef659b8, (q31_t)0x9b420b1f, (q31_t)0x4ef167aa, (q31_t)0x9b3e2af9, (q31_t)0x4eec756b, (q31_t)0x9b3a4b11, - (q31_t)0x4ee782fb, (q31_t)0x9b366b68, (q31_t)0x4ee2905a, (q31_t)0x9b328bfc, (q31_t)0x4edd9d89, (q31_t)0x9b2eaccf, (q31_t)0x4ed8aa87, (q31_t)0x9b2acde0, - (q31_t)0x4ed3b755, (q31_t)0x9b26ef2f, (q31_t)0x4ecec3f2, (q31_t)0x9b2310bc, (q31_t)0x4ec9d05e, (q31_t)0x9b1f3288, (q31_t)0x4ec4dc99, (q31_t)0x9b1b5492, - (q31_t)0x4ebfe8a5, (q31_t)0x9b1776da, (q31_t)0x4ebaf47f, (q31_t)0x9b139960, (q31_t)0x4eb60029, (q31_t)0x9b0fbc24, (q31_t)0x4eb10ba2, (q31_t)0x9b0bdf27, - (q31_t)0x4eac16eb, (q31_t)0x9b080268, (q31_t)0x4ea72203, (q31_t)0x9b0425e8, (q31_t)0x4ea22ceb, (q31_t)0x9b0049a5, (q31_t)0x4e9d37a3, (q31_t)0x9afc6da1, - (q31_t)0x4e984229, (q31_t)0x9af891db, (q31_t)0x4e934c80, (q31_t)0x9af4b654, (q31_t)0x4e8e56a5, (q31_t)0x9af0db0b, (q31_t)0x4e89609b, (q31_t)0x9aed0000, - (q31_t)0x4e846a60, (q31_t)0x9ae92533, (q31_t)0x4e7f73f4, (q31_t)0x9ae54aa5, (q31_t)0x4e7a7d58, (q31_t)0x9ae17056, (q31_t)0x4e75868c, (q31_t)0x9add9644, - (q31_t)0x4e708f8f, (q31_t)0x9ad9bc71, (q31_t)0x4e6b9862, (q31_t)0x9ad5e2dd, (q31_t)0x4e66a105, (q31_t)0x9ad20987, (q31_t)0x4e61a977, (q31_t)0x9ace306f, - (q31_t)0x4e5cb1b9, (q31_t)0x9aca5795, (q31_t)0x4e57b9ca, (q31_t)0x9ac67efb, (q31_t)0x4e52c1ab, (q31_t)0x9ac2a69e, (q31_t)0x4e4dc95c, (q31_t)0x9abece80, - (q31_t)0x4e48d0dd, (q31_t)0x9abaf6a1, (q31_t)0x4e43d82d, (q31_t)0x9ab71eff, (q31_t)0x4e3edf4d, (q31_t)0x9ab3479d, (q31_t)0x4e39e63d, (q31_t)0x9aaf7079, - (q31_t)0x4e34ecfc, (q31_t)0x9aab9993, (q31_t)0x4e2ff38b, (q31_t)0x9aa7c2ec, (q31_t)0x4e2af9ea, (q31_t)0x9aa3ec83, (q31_t)0x4e260019, (q31_t)0x9aa01659, - (q31_t)0x4e210617, (q31_t)0x9a9c406e, (q31_t)0x4e1c0be6, (q31_t)0x9a986ac1, (q31_t)0x4e171184, (q31_t)0x9a949552, (q31_t)0x4e1216f2, (q31_t)0x9a90c022, - (q31_t)0x4e0d1c30, (q31_t)0x9a8ceb31, (q31_t)0x4e08213e, (q31_t)0x9a89167e, (q31_t)0x4e03261b, (q31_t)0x9a85420a, (q31_t)0x4dfe2ac9, (q31_t)0x9a816dd5, - (q31_t)0x4df92f46, (q31_t)0x9a7d99de, (q31_t)0x4df43393, (q31_t)0x9a79c625, (q31_t)0x4def37b0, (q31_t)0x9a75f2ac, (q31_t)0x4dea3b9d, (q31_t)0x9a721f71, - (q31_t)0x4de53f5a, (q31_t)0x9a6e4c74, (q31_t)0x4de042e7, (q31_t)0x9a6a79b6, (q31_t)0x4ddb4644, (q31_t)0x9a66a737, (q31_t)0x4dd64971, (q31_t)0x9a62d4f7, - (q31_t)0x4dd14c6e, (q31_t)0x9a5f02f5, (q31_t)0x4dcc4f3b, (q31_t)0x9a5b3132, (q31_t)0x4dc751d8, (q31_t)0x9a575fae, (q31_t)0x4dc25445, (q31_t)0x9a538e68, - (q31_t)0x4dbd5682, (q31_t)0x9a4fbd61, (q31_t)0x4db8588f, (q31_t)0x9a4bec99, (q31_t)0x4db35a6c, (q31_t)0x9a481c0f, (q31_t)0x4dae5c19, (q31_t)0x9a444bc5, - (q31_t)0x4da95d96, (q31_t)0x9a407bb9, (q31_t)0x4da45ee3, (q31_t)0x9a3cabeb, (q31_t)0x4d9f6001, (q31_t)0x9a38dc5d, (q31_t)0x4d9a60ee, (q31_t)0x9a350d0d, - (q31_t)0x4d9561ac, (q31_t)0x9a313dfc, (q31_t)0x4d90623a, (q31_t)0x9a2d6f2a, (q31_t)0x4d8b6298, (q31_t)0x9a29a097, (q31_t)0x4d8662c6, (q31_t)0x9a25d243, - (q31_t)0x4d8162c4, (q31_t)0x9a22042d, (q31_t)0x4d7c6293, (q31_t)0x9a1e3656, (q31_t)0x4d776231, (q31_t)0x9a1a68be, (q31_t)0x4d7261a0, (q31_t)0x9a169b65, - (q31_t)0x4d6d60df, (q31_t)0x9a12ce4b, (q31_t)0x4d685fef, (q31_t)0x9a0f016f, (q31_t)0x4d635ece, (q31_t)0x9a0b34d3, (q31_t)0x4d5e5d7e, (q31_t)0x9a076875, - (q31_t)0x4d595bfe, (q31_t)0x9a039c57, (q31_t)0x4d545a4f, (q31_t)0x99ffd077, (q31_t)0x4d4f5870, (q31_t)0x99fc04d6, (q31_t)0x4d4a5661, (q31_t)0x99f83974, - (q31_t)0x4d455422, (q31_t)0x99f46e51, (q31_t)0x4d4051b4, (q31_t)0x99f0a36d, (q31_t)0x4d3b4f16, (q31_t)0x99ecd8c8, (q31_t)0x4d364c48, (q31_t)0x99e90e62, - (q31_t)0x4d31494b, (q31_t)0x99e5443b, (q31_t)0x4d2c461e, (q31_t)0x99e17a53, (q31_t)0x4d2742c2, (q31_t)0x99ddb0aa, (q31_t)0x4d223f36, (q31_t)0x99d9e73f, - (q31_t)0x4d1d3b7a, (q31_t)0x99d61e14, (q31_t)0x4d18378f, (q31_t)0x99d25528, (q31_t)0x4d133374, (q31_t)0x99ce8c7b, (q31_t)0x4d0e2f2a, (q31_t)0x99cac40d, - (q31_t)0x4d092ab0, (q31_t)0x99c6fbde, (q31_t)0x4d042607, (q31_t)0x99c333ee, (q31_t)0x4cff212e, (q31_t)0x99bf6c3d, (q31_t)0x4cfa1c26, (q31_t)0x99bba4cb, - (q31_t)0x4cf516ee, (q31_t)0x99b7dd99, (q31_t)0x4cf01187, (q31_t)0x99b416a5, (q31_t)0x4ceb0bf0, (q31_t)0x99b04ff0, (q31_t)0x4ce6062a, (q31_t)0x99ac897b, - (q31_t)0x4ce10034, (q31_t)0x99a8c345, (q31_t)0x4cdbfa0f, (q31_t)0x99a4fd4d, (q31_t)0x4cd6f3bb, (q31_t)0x99a13795, (q31_t)0x4cd1ed37, (q31_t)0x999d721c, - (q31_t)0x4ccce684, (q31_t)0x9999ace3, (q31_t)0x4cc7dfa1, (q31_t)0x9995e7e8, (q31_t)0x4cc2d88f, (q31_t)0x9992232d, (q31_t)0x4cbdd14e, (q31_t)0x998e5eb1, - (q31_t)0x4cb8c9dd, (q31_t)0x998a9a74, (q31_t)0x4cb3c23d, (q31_t)0x9986d676, (q31_t)0x4caeba6e, (q31_t)0x998312b7, (q31_t)0x4ca9b26f, (q31_t)0x997f4f38, - (q31_t)0x4ca4aa41, (q31_t)0x997b8bf8, (q31_t)0x4c9fa1e4, (q31_t)0x9977c8f7, (q31_t)0x4c9a9958, (q31_t)0x99740635, (q31_t)0x4c95909c, (q31_t)0x997043b2, - (q31_t)0x4c9087b1, (q31_t)0x996c816f, (q31_t)0x4c8b7e97, (q31_t)0x9968bf6b, (q31_t)0x4c86754e, (q31_t)0x9964fda7, (q31_t)0x4c816bd5, (q31_t)0x99613c22, - (q31_t)0x4c7c622d, (q31_t)0x995d7adc, (q31_t)0x4c775856, (q31_t)0x9959b9d5, (q31_t)0x4c724e50, (q31_t)0x9955f90d, (q31_t)0x4c6d441b, (q31_t)0x99523885, - (q31_t)0x4c6839b7, (q31_t)0x994e783d, (q31_t)0x4c632f23, (q31_t)0x994ab833, (q31_t)0x4c5e2460, (q31_t)0x9946f869, (q31_t)0x4c59196f, (q31_t)0x994338df, - (q31_t)0x4c540e4e, (q31_t)0x993f7993, (q31_t)0x4c4f02fe, (q31_t)0x993bba87, (q31_t)0x4c49f77f, (q31_t)0x9937fbbb, (q31_t)0x4c44ebd1, (q31_t)0x99343d2e, - (q31_t)0x4c3fdff4, (q31_t)0x99307ee0, (q31_t)0x4c3ad3e7, (q31_t)0x992cc0d2, (q31_t)0x4c35c7ac, (q31_t)0x99290303, (q31_t)0x4c30bb42, (q31_t)0x99254574, - (q31_t)0x4c2baea9, (q31_t)0x99218824, (q31_t)0x4c26a1e1, (q31_t)0x991dcb13, (q31_t)0x4c2194e9, (q31_t)0x991a0e42, (q31_t)0x4c1c87c3, (q31_t)0x991651b1, - (q31_t)0x4c177a6e, (q31_t)0x9912955f, (q31_t)0x4c126cea, (q31_t)0x990ed94c, (q31_t)0x4c0d5f37, (q31_t)0x990b1d79, (q31_t)0x4c085156, (q31_t)0x990761e5, - (q31_t)0x4c034345, (q31_t)0x9903a691, (q31_t)0x4bfe3505, (q31_t)0x98ffeb7d, (q31_t)0x4bf92697, (q31_t)0x98fc30a8, (q31_t)0x4bf417f9, (q31_t)0x98f87612, - (q31_t)0x4bef092d, (q31_t)0x98f4bbbc, (q31_t)0x4be9fa32, (q31_t)0x98f101a6, (q31_t)0x4be4eb08, (q31_t)0x98ed47cf, (q31_t)0x4bdfdbaf, (q31_t)0x98e98e38, - (q31_t)0x4bdacc28, (q31_t)0x98e5d4e0, (q31_t)0x4bd5bc72, (q31_t)0x98e21bc8, (q31_t)0x4bd0ac8d, (q31_t)0x98de62f0, (q31_t)0x4bcb9c79, (q31_t)0x98daaa57, - (q31_t)0x4bc68c36, (q31_t)0x98d6f1fe, (q31_t)0x4bc17bc5, (q31_t)0x98d339e4, (q31_t)0x4bbc6b25, (q31_t)0x98cf820b, (q31_t)0x4bb75a56, (q31_t)0x98cbca70, - (q31_t)0x4bb24958, (q31_t)0x98c81316, (q31_t)0x4bad382c, (q31_t)0x98c45bfb, (q31_t)0x4ba826d1, (q31_t)0x98c0a520, (q31_t)0x4ba31548, (q31_t)0x98bcee84, - (q31_t)0x4b9e0390, (q31_t)0x98b93828, (q31_t)0x4b98f1a9, (q31_t)0x98b5820c, (q31_t)0x4b93df93, (q31_t)0x98b1cc30, (q31_t)0x4b8ecd4f, (q31_t)0x98ae1693, - (q31_t)0x4b89badd, (q31_t)0x98aa6136, (q31_t)0x4b84a83b, (q31_t)0x98a6ac19, (q31_t)0x4b7f956b, (q31_t)0x98a2f73c, (q31_t)0x4b7a826d, (q31_t)0x989f429e, - (q31_t)0x4b756f40, (q31_t)0x989b8e40, (q31_t)0x4b705be4, (q31_t)0x9897da22, (q31_t)0x4b6b485a, (q31_t)0x98942643, (q31_t)0x4b6634a2, (q31_t)0x989072a5, - (q31_t)0x4b6120bb, (q31_t)0x988cbf46, (q31_t)0x4b5c0ca5, (q31_t)0x98890c27, (q31_t)0x4b56f861, (q31_t)0x98855948, (q31_t)0x4b51e3ee, (q31_t)0x9881a6a9, - (q31_t)0x4b4ccf4d, (q31_t)0x987df449, (q31_t)0x4b47ba7e, (q31_t)0x987a422a, (q31_t)0x4b42a580, (q31_t)0x9876904a, (q31_t)0x4b3d9053, (q31_t)0x9872deaa, - (q31_t)0x4b387af9, (q31_t)0x986f2d4a, (q31_t)0x4b336570, (q31_t)0x986b7c2a, (q31_t)0x4b2e4fb8, (q31_t)0x9867cb4a, (q31_t)0x4b2939d2, (q31_t)0x98641aa9, - (q31_t)0x4b2423be, (q31_t)0x98606a49, (q31_t)0x4b1f0d7b, (q31_t)0x985cba28, (q31_t)0x4b19f70a, (q31_t)0x98590a48, (q31_t)0x4b14e06b, (q31_t)0x98555aa7, - (q31_t)0x4b0fc99d, (q31_t)0x9851ab46, (q31_t)0x4b0ab2a1, (q31_t)0x984dfc26, (q31_t)0x4b059b77, (q31_t)0x984a4d45, (q31_t)0x4b00841f, (q31_t)0x98469ea4, - (q31_t)0x4afb6c98, (q31_t)0x9842f043, (q31_t)0x4af654e3, (q31_t)0x983f4223, (q31_t)0x4af13d00, (q31_t)0x983b9442, (q31_t)0x4aec24ee, (q31_t)0x9837e6a1, - (q31_t)0x4ae70caf, (q31_t)0x98343940, (q31_t)0x4ae1f441, (q31_t)0x98308c1f, (q31_t)0x4adcdba5, (q31_t)0x982cdf3f, (q31_t)0x4ad7c2da, (q31_t)0x9829329e, - (q31_t)0x4ad2a9e2, (q31_t)0x9825863d, (q31_t)0x4acd90bb, (q31_t)0x9821da1d, (q31_t)0x4ac87767, (q31_t)0x981e2e3c, (q31_t)0x4ac35de4, (q31_t)0x981a829c, - (q31_t)0x4abe4433, (q31_t)0x9816d73b, (q31_t)0x4ab92a54, (q31_t)0x98132c1b, (q31_t)0x4ab41046, (q31_t)0x980f813b, (q31_t)0x4aaef60b, (q31_t)0x980bd69b, - (q31_t)0x4aa9dba2, (q31_t)0x98082c3b, (q31_t)0x4aa4c10b, (q31_t)0x9804821b, (q31_t)0x4a9fa645, (q31_t)0x9800d83c, (q31_t)0x4a9a8b52, (q31_t)0x97fd2e9c, - (q31_t)0x4a957030, (q31_t)0x97f9853d, (q31_t)0x4a9054e1, (q31_t)0x97f5dc1e, (q31_t)0x4a8b3963, (q31_t)0x97f2333f, (q31_t)0x4a861db8, (q31_t)0x97ee8aa0, - (q31_t)0x4a8101de, (q31_t)0x97eae242, (q31_t)0x4a7be5d7, (q31_t)0x97e73a23, (q31_t)0x4a76c9a2, (q31_t)0x97e39245, (q31_t)0x4a71ad3e, (q31_t)0x97dfeaa7, - (q31_t)0x4a6c90ad, (q31_t)0x97dc4349, (q31_t)0x4a6773ee, (q31_t)0x97d89c2c, (q31_t)0x4a625701, (q31_t)0x97d4f54f, (q31_t)0x4a5d39e6, (q31_t)0x97d14eb2, - (q31_t)0x4a581c9e, (q31_t)0x97cda855, (q31_t)0x4a52ff27, (q31_t)0x97ca0239, (q31_t)0x4a4de182, (q31_t)0x97c65c5c, (q31_t)0x4a48c3b0, (q31_t)0x97c2b6c1, - (q31_t)0x4a43a5b0, (q31_t)0x97bf1165, (q31_t)0x4a3e8782, (q31_t)0x97bb6c4a, (q31_t)0x4a396926, (q31_t)0x97b7c76f, (q31_t)0x4a344a9d, (q31_t)0x97b422d4, - (q31_t)0x4a2f2be6, (q31_t)0x97b07e7a, (q31_t)0x4a2a0d01, (q31_t)0x97acda60, (q31_t)0x4a24edee, (q31_t)0x97a93687, (q31_t)0x4a1fcead, (q31_t)0x97a592ed, - (q31_t)0x4a1aaf3f, (q31_t)0x97a1ef94, (q31_t)0x4a158fa3, (q31_t)0x979e4c7c, (q31_t)0x4a106fda, (q31_t)0x979aa9a4, (q31_t)0x4a0b4fe2, (q31_t)0x9797070c, - (q31_t)0x4a062fbd, (q31_t)0x979364b5, (q31_t)0x4a010f6b, (q31_t)0x978fc29e, (q31_t)0x49fbeeea, (q31_t)0x978c20c8, (q31_t)0x49f6ce3c, (q31_t)0x97887f32, - (q31_t)0x49f1ad61, (q31_t)0x9784dddc, (q31_t)0x49ec8c57, (q31_t)0x97813cc7, (q31_t)0x49e76b21, (q31_t)0x977d9bf2, (q31_t)0x49e249bc, (q31_t)0x9779fb5e, - (q31_t)0x49dd282a, (q31_t)0x97765b0a, (q31_t)0x49d8066b, (q31_t)0x9772baf7, (q31_t)0x49d2e47e, (q31_t)0x976f1b24, (q31_t)0x49cdc263, (q31_t)0x976b7b92, - (q31_t)0x49c8a01b, (q31_t)0x9767dc41, (q31_t)0x49c37da5, (q31_t)0x97643d2f, (q31_t)0x49be5b02, (q31_t)0x97609e5f, (q31_t)0x49b93832, (q31_t)0x975cffcf, - (q31_t)0x49b41533, (q31_t)0x9759617f, (q31_t)0x49aef208, (q31_t)0x9755c370, (q31_t)0x49a9ceaf, (q31_t)0x975225a1, (q31_t)0x49a4ab28, (q31_t)0x974e8813, - (q31_t)0x499f8774, (q31_t)0x974aeac6, (q31_t)0x499a6393, (q31_t)0x97474db9, (q31_t)0x49953f84, (q31_t)0x9743b0ed, (q31_t)0x49901b48, (q31_t)0x97401462, - (q31_t)0x498af6df, (q31_t)0x973c7817, (q31_t)0x4985d248, (q31_t)0x9738dc0d, (q31_t)0x4980ad84, (q31_t)0x97354043, (q31_t)0x497b8892, (q31_t)0x9731a4ba, - (q31_t)0x49766373, (q31_t)0x972e0971, (q31_t)0x49713e27, (q31_t)0x972a6e6a, (q31_t)0x496c18ae, (q31_t)0x9726d3a3, (q31_t)0x4966f307, (q31_t)0x9723391c, - (q31_t)0x4961cd33, (q31_t)0x971f9ed7, (q31_t)0x495ca732, (q31_t)0x971c04d2, (q31_t)0x49578103, (q31_t)0x97186b0d, (q31_t)0x49525aa7, (q31_t)0x9714d18a, - (q31_t)0x494d341e, (q31_t)0x97113847, (q31_t)0x49480d68, (q31_t)0x970d9f45, (q31_t)0x4942e684, (q31_t)0x970a0683, (q31_t)0x493dbf74, (q31_t)0x97066e03, - (q31_t)0x49389836, (q31_t)0x9702d5c3, (q31_t)0x493370cb, (q31_t)0x96ff3dc4, (q31_t)0x492e4933, (q31_t)0x96fba605, (q31_t)0x4929216e, (q31_t)0x96f80e88, - (q31_t)0x4923f97b, (q31_t)0x96f4774b, (q31_t)0x491ed15c, (q31_t)0x96f0e04f, (q31_t)0x4919a90f, (q31_t)0x96ed4994, (q31_t)0x49148095, (q31_t)0x96e9b319, - (q31_t)0x490f57ee, (q31_t)0x96e61ce0, (q31_t)0x490a2f1b, (q31_t)0x96e286e7, (q31_t)0x4905061a, (q31_t)0x96def12f, (q31_t)0x48ffdcec, (q31_t)0x96db5bb8, - (q31_t)0x48fab391, (q31_t)0x96d7c682, (q31_t)0x48f58a09, (q31_t)0x96d4318d, (q31_t)0x48f06054, (q31_t)0x96d09cd8, (q31_t)0x48eb3672, (q31_t)0x96cd0865, - (q31_t)0x48e60c62, (q31_t)0x96c97432, (q31_t)0x48e0e227, (q31_t)0x96c5e040, (q31_t)0x48dbb7be, (q31_t)0x96c24c8f, (q31_t)0x48d68d28, (q31_t)0x96beb91f, - (q31_t)0x48d16265, (q31_t)0x96bb25f0, (q31_t)0x48cc3775, (q31_t)0x96b79302, (q31_t)0x48c70c59, (q31_t)0x96b40055, (q31_t)0x48c1e10f, (q31_t)0x96b06de9, - (q31_t)0x48bcb599, (q31_t)0x96acdbbe, (q31_t)0x48b789f5, (q31_t)0x96a949d3, (q31_t)0x48b25e25, (q31_t)0x96a5b82a, (q31_t)0x48ad3228, (q31_t)0x96a226c2, - (q31_t)0x48a805ff, (q31_t)0x969e959b, (q31_t)0x48a2d9a8, (q31_t)0x969b04b4, (q31_t)0x489dad25, (q31_t)0x9697740f, (q31_t)0x48988074, (q31_t)0x9693e3ab, - (q31_t)0x48935397, (q31_t)0x96905388, (q31_t)0x488e268e, (q31_t)0x968cc3a5, (q31_t)0x4888f957, (q31_t)0x96893404, (q31_t)0x4883cbf4, (q31_t)0x9685a4a4, - (q31_t)0x487e9e64, (q31_t)0x96821585, (q31_t)0x487970a7, (q31_t)0x967e86a7, (q31_t)0x487442be, (q31_t)0x967af80a, (q31_t)0x486f14a8, (q31_t)0x967769af, - (q31_t)0x4869e665, (q31_t)0x9673db94, (q31_t)0x4864b7f5, (q31_t)0x96704dba, (q31_t)0x485f8959, (q31_t)0x966cc022, (q31_t)0x485a5a90, (q31_t)0x966932cb, - (q31_t)0x48552b9b, (q31_t)0x9665a5b4, (q31_t)0x484ffc79, (q31_t)0x966218df, (q31_t)0x484acd2a, (q31_t)0x965e8c4b, (q31_t)0x48459daf, (q31_t)0x965afff9, - (q31_t)0x48406e08, (q31_t)0x965773e7, (q31_t)0x483b3e33, (q31_t)0x9653e817, (q31_t)0x48360e32, (q31_t)0x96505c88, (q31_t)0x4830de05, (q31_t)0x964cd139, - (q31_t)0x482badab, (q31_t)0x9649462d, (q31_t)0x48267d24, (q31_t)0x9645bb61, (q31_t)0x48214c71, (q31_t)0x964230d7, (q31_t)0x481c1b92, (q31_t)0x963ea68d, - (q31_t)0x4816ea86, (q31_t)0x963b1c86, (q31_t)0x4811b94d, (q31_t)0x963792bf, (q31_t)0x480c87e8, (q31_t)0x96340939, (q31_t)0x48075657, (q31_t)0x96307ff5, - (q31_t)0x48022499, (q31_t)0x962cf6f2, (q31_t)0x47fcf2af, (q31_t)0x96296e31, (q31_t)0x47f7c099, (q31_t)0x9625e5b0, (q31_t)0x47f28e56, (q31_t)0x96225d71, - (q31_t)0x47ed5be6, (q31_t)0x961ed574, (q31_t)0x47e8294a, (q31_t)0x961b4db7, (q31_t)0x47e2f682, (q31_t)0x9617c63c, (q31_t)0x47ddc38e, (q31_t)0x96143f02, - (q31_t)0x47d8906d, (q31_t)0x9610b80a, (q31_t)0x47d35d20, (q31_t)0x960d3153, (q31_t)0x47ce29a7, (q31_t)0x9609aadd, (q31_t)0x47c8f601, (q31_t)0x960624a9, - (q31_t)0x47c3c22f, (q31_t)0x96029eb6, (q31_t)0x47be8e31, (q31_t)0x95ff1904, (q31_t)0x47b95a06, (q31_t)0x95fb9394, (q31_t)0x47b425af, (q31_t)0x95f80e65, - (q31_t)0x47aef12c, (q31_t)0x95f48977, (q31_t)0x47a9bc7d, (q31_t)0x95f104cb, (q31_t)0x47a487a2, (q31_t)0x95ed8061, (q31_t)0x479f529a, (q31_t)0x95e9fc38, - (q31_t)0x479a1d67, (q31_t)0x95e67850, (q31_t)0x4794e807, (q31_t)0x95e2f4a9, (q31_t)0x478fb27b, (q31_t)0x95df7145, (q31_t)0x478a7cc2, (q31_t)0x95dbee21, - (q31_t)0x478546de, (q31_t)0x95d86b3f, (q31_t)0x478010cd, (q31_t)0x95d4e89f, (q31_t)0x477ada91, (q31_t)0x95d16640, (q31_t)0x4775a428, (q31_t)0x95cde423, - (q31_t)0x47706d93, (q31_t)0x95ca6247, (q31_t)0x476b36d3, (q31_t)0x95c6e0ac, (q31_t)0x4765ffe6, (q31_t)0x95c35f53, (q31_t)0x4760c8cd, (q31_t)0x95bfde3c, - (q31_t)0x475b9188, (q31_t)0x95bc5d66, (q31_t)0x47565a17, (q31_t)0x95b8dcd2, (q31_t)0x4751227a, (q31_t)0x95b55c7f, (q31_t)0x474beab1, (q31_t)0x95b1dc6e, - (q31_t)0x4746b2bc, (q31_t)0x95ae5c9f, (q31_t)0x47417a9b, (q31_t)0x95aadd11, (q31_t)0x473c424e, (q31_t)0x95a75dc4, (q31_t)0x473709d5, (q31_t)0x95a3deb9, - (q31_t)0x4731d131, (q31_t)0x95a05ff0, (q31_t)0x472c9860, (q31_t)0x959ce169, (q31_t)0x47275f63, (q31_t)0x95996323, (q31_t)0x4722263b, (q31_t)0x9595e51e, - (q31_t)0x471cece7, (q31_t)0x9592675c, (q31_t)0x4717b367, (q31_t)0x958ee9db, (q31_t)0x471279ba, (q31_t)0x958b6c9b, (q31_t)0x470d3fe3, (q31_t)0x9587ef9e, - (q31_t)0x470805df, (q31_t)0x958472e2, (q31_t)0x4702cbaf, (q31_t)0x9580f667, (q31_t)0x46fd9154, (q31_t)0x957d7a2f, (q31_t)0x46f856cd, (q31_t)0x9579fe38, - (q31_t)0x46f31c1a, (q31_t)0x95768283, (q31_t)0x46ede13b, (q31_t)0x9573070f, (q31_t)0x46e8a631, (q31_t)0x956f8bdd, (q31_t)0x46e36afb, (q31_t)0x956c10ed, - (q31_t)0x46de2f99, (q31_t)0x9568963f, (q31_t)0x46d8f40b, (q31_t)0x95651bd2, (q31_t)0x46d3b852, (q31_t)0x9561a1a8, (q31_t)0x46ce7c6d, (q31_t)0x955e27bf, - (q31_t)0x46c9405c, (q31_t)0x955aae17, (q31_t)0x46c40420, (q31_t)0x955734b2, (q31_t)0x46bec7b8, (q31_t)0x9553bb8e, (q31_t)0x46b98b24, (q31_t)0x955042ac, - (q31_t)0x46b44e65, (q31_t)0x954cca0c, (q31_t)0x46af117a, (q31_t)0x954951ae, (q31_t)0x46a9d464, (q31_t)0x9545d992, (q31_t)0x46a49722, (q31_t)0x954261b7, - (q31_t)0x469f59b4, (q31_t)0x953eea1e, (q31_t)0x469a1c1b, (q31_t)0x953b72c7, (q31_t)0x4694de56, (q31_t)0x9537fbb2, (q31_t)0x468fa066, (q31_t)0x953484df, - (q31_t)0x468a624a, (q31_t)0x95310e4e, (q31_t)0x46852403, (q31_t)0x952d97fe, (q31_t)0x467fe590, (q31_t)0x952a21f1, (q31_t)0x467aa6f2, (q31_t)0x9526ac25, - (q31_t)0x46756828, (q31_t)0x9523369c, (q31_t)0x46702933, (q31_t)0x951fc154, (q31_t)0x466aea12, (q31_t)0x951c4c4e, (q31_t)0x4665aac6, (q31_t)0x9518d78a, - (q31_t)0x46606b4e, (q31_t)0x95156308, (q31_t)0x465b2bab, (q31_t)0x9511eec8, (q31_t)0x4655ebdd, (q31_t)0x950e7aca, (q31_t)0x4650abe3, (q31_t)0x950b070e, - (q31_t)0x464b6bbe, (q31_t)0x95079394, (q31_t)0x46462b6d, (q31_t)0x9504205c, (q31_t)0x4640eaf2, (q31_t)0x9500ad66, (q31_t)0x463baa4a, (q31_t)0x94fd3ab1, - (q31_t)0x46366978, (q31_t)0x94f9c83f, (q31_t)0x4631287a, (q31_t)0x94f6560f, (q31_t)0x462be751, (q31_t)0x94f2e421, (q31_t)0x4626a5fd, (q31_t)0x94ef7275, - (q31_t)0x4621647d, (q31_t)0x94ec010b, (q31_t)0x461c22d2, (q31_t)0x94e88fe3, (q31_t)0x4616e0fc, (q31_t)0x94e51efd, (q31_t)0x46119efa, (q31_t)0x94e1ae59, - (q31_t)0x460c5cce, (q31_t)0x94de3df8, (q31_t)0x46071a76, (q31_t)0x94dacdd8, (q31_t)0x4601d7f3, (q31_t)0x94d75dfa, (q31_t)0x45fc9545, (q31_t)0x94d3ee5f, - (q31_t)0x45f7526b, (q31_t)0x94d07f05, (q31_t)0x45f20f67, (q31_t)0x94cd0fee, (q31_t)0x45eccc37, (q31_t)0x94c9a119, (q31_t)0x45e788dc, (q31_t)0x94c63286, - (q31_t)0x45e24556, (q31_t)0x94c2c435, (q31_t)0x45dd01a5, (q31_t)0x94bf5627, (q31_t)0x45d7bdc9, (q31_t)0x94bbe85a, (q31_t)0x45d279c2, (q31_t)0x94b87ad0, - (q31_t)0x45cd358f, (q31_t)0x94b50d87, (q31_t)0x45c7f132, (q31_t)0x94b1a081, (q31_t)0x45c2acaa, (q31_t)0x94ae33be, (q31_t)0x45bd67f6, (q31_t)0x94aac73c, - (q31_t)0x45b82318, (q31_t)0x94a75afd, (q31_t)0x45b2de0e, (q31_t)0x94a3eeff, (q31_t)0x45ad98da, (q31_t)0x94a08344, (q31_t)0x45a8537a, (q31_t)0x949d17cc, - (q31_t)0x45a30df0, (q31_t)0x9499ac95, (q31_t)0x459dc83b, (q31_t)0x949641a1, (q31_t)0x4598825a, (q31_t)0x9492d6ef, (q31_t)0x45933c4f, (q31_t)0x948f6c7f, - (q31_t)0x458df619, (q31_t)0x948c0252, (q31_t)0x4588afb8, (q31_t)0x94889867, (q31_t)0x4583692c, (q31_t)0x94852ebe, (q31_t)0x457e2275, (q31_t)0x9481c557, - (q31_t)0x4578db93, (q31_t)0x947e5c33, (q31_t)0x45739487, (q31_t)0x947af351, (q31_t)0x456e4d4f, (q31_t)0x94778ab1, (q31_t)0x456905ed, (q31_t)0x94742254, - (q31_t)0x4563be60, (q31_t)0x9470ba39, (q31_t)0x455e76a8, (q31_t)0x946d5260, (q31_t)0x45592ec6, (q31_t)0x9469eaca, (q31_t)0x4553e6b8, (q31_t)0x94668376, - (q31_t)0x454e9e80, (q31_t)0x94631c65, (q31_t)0x4549561d, (q31_t)0x945fb596, (q31_t)0x45440d90, (q31_t)0x945c4f09, (q31_t)0x453ec4d7, (q31_t)0x9458e8bf, - (q31_t)0x45397bf4, (q31_t)0x945582b7, (q31_t)0x453432e6, (q31_t)0x94521cf1, (q31_t)0x452ee9ae, (q31_t)0x944eb76e, (q31_t)0x4529a04b, (q31_t)0x944b522d, - (q31_t)0x452456bd, (q31_t)0x9447ed2f, (q31_t)0x451f0d04, (q31_t)0x94448873, (q31_t)0x4519c321, (q31_t)0x944123fa, (q31_t)0x45147913, (q31_t)0x943dbfc3, - (q31_t)0x450f2edb, (q31_t)0x943a5bcf, (q31_t)0x4509e478, (q31_t)0x9436f81d, (q31_t)0x450499eb, (q31_t)0x943394ad, (q31_t)0x44ff4f32, (q31_t)0x94303180, - (q31_t)0x44fa0450, (q31_t)0x942cce96, (q31_t)0x44f4b943, (q31_t)0x94296bee, (q31_t)0x44ef6e0b, (q31_t)0x94260989, (q31_t)0x44ea22a9, (q31_t)0x9422a766, - (q31_t)0x44e4d71c, (q31_t)0x941f4585, (q31_t)0x44df8b64, (q31_t)0x941be3e8, (q31_t)0x44da3f83, (q31_t)0x9418828c, (q31_t)0x44d4f376, (q31_t)0x94152174, - (q31_t)0x44cfa740, (q31_t)0x9411c09e, (q31_t)0x44ca5adf, (q31_t)0x940e600a, (q31_t)0x44c50e53, (q31_t)0x940affb9, (q31_t)0x44bfc19d, (q31_t)0x94079fab, - (q31_t)0x44ba74bd, (q31_t)0x94043fdf, (q31_t)0x44b527b2, (q31_t)0x9400e056, (q31_t)0x44afda7d, (q31_t)0x93fd810f, (q31_t)0x44aa8d1d, (q31_t)0x93fa220b, - (q31_t)0x44a53f93, (q31_t)0x93f6c34a, (q31_t)0x449ff1df, (q31_t)0x93f364cb, (q31_t)0x449aa400, (q31_t)0x93f0068f, (q31_t)0x449555f7, (q31_t)0x93eca896, - (q31_t)0x449007c4, (q31_t)0x93e94adf, (q31_t)0x448ab967, (q31_t)0x93e5ed6b, (q31_t)0x44856adf, (q31_t)0x93e2903a, (q31_t)0x44801c2d, (q31_t)0x93df334c, - (q31_t)0x447acd50, (q31_t)0x93dbd6a0, (q31_t)0x44757e4a, (q31_t)0x93d87a36, (q31_t)0x44702f19, (q31_t)0x93d51e10, (q31_t)0x446adfbe, (q31_t)0x93d1c22c, - (q31_t)0x44659039, (q31_t)0x93ce668b, (q31_t)0x44604089, (q31_t)0x93cb0b2d, (q31_t)0x445af0b0, (q31_t)0x93c7b011, (q31_t)0x4455a0ac, (q31_t)0x93c45539, - (q31_t)0x4450507e, (q31_t)0x93c0faa3, (q31_t)0x444b0026, (q31_t)0x93bda04f, (q31_t)0x4445afa4, (q31_t)0x93ba463f, (q31_t)0x44405ef8, (q31_t)0x93b6ec71, - (q31_t)0x443b0e21, (q31_t)0x93b392e6, (q31_t)0x4435bd21, (q31_t)0x93b0399e, (q31_t)0x44306bf6, (q31_t)0x93ace099, (q31_t)0x442b1aa2, (q31_t)0x93a987d6, - (q31_t)0x4425c923, (q31_t)0x93a62f57, (q31_t)0x4420777b, (q31_t)0x93a2d71a, (q31_t)0x441b25a8, (q31_t)0x939f7f20, (q31_t)0x4415d3ab, (q31_t)0x939c2769, - (q31_t)0x44108184, (q31_t)0x9398cff5, (q31_t)0x440b2f34, (q31_t)0x939578c3, (q31_t)0x4405dcb9, (q31_t)0x939221d5, (q31_t)0x44008a14, (q31_t)0x938ecb29, - (q31_t)0x43fb3746, (q31_t)0x938b74c1, (q31_t)0x43f5e44d, (q31_t)0x93881e9b, (q31_t)0x43f0912b, (q31_t)0x9384c8b8, (q31_t)0x43eb3ddf, (q31_t)0x93817318, - (q31_t)0x43e5ea68, (q31_t)0x937e1dbb, (q31_t)0x43e096c8, (q31_t)0x937ac8a1, (q31_t)0x43db42fe, (q31_t)0x937773ca, (q31_t)0x43d5ef0a, (q31_t)0x93741f35, - (q31_t)0x43d09aed, (q31_t)0x9370cae4, (q31_t)0x43cb46a5, (q31_t)0x936d76d6, (q31_t)0x43c5f234, (q31_t)0x936a230a, (q31_t)0x43c09d99, (q31_t)0x9366cf82, - (q31_t)0x43bb48d4, (q31_t)0x93637c3d, (q31_t)0x43b5f3e5, (q31_t)0x9360293a, (q31_t)0x43b09ecc, (q31_t)0x935cd67b, (q31_t)0x43ab498a, (q31_t)0x935983ff, - (q31_t)0x43a5f41e, (q31_t)0x935631c5, (q31_t)0x43a09e89, (q31_t)0x9352dfcf, (q31_t)0x439b48c9, (q31_t)0x934f8e1c, (q31_t)0x4395f2e0, (q31_t)0x934c3cab, - (q31_t)0x43909ccd, (q31_t)0x9348eb7e, (q31_t)0x438b4691, (q31_t)0x93459a94, (q31_t)0x4385f02a, (q31_t)0x934249ed, (q31_t)0x4380999b, (q31_t)0x933ef989, - (q31_t)0x437b42e1, (q31_t)0x933ba968, (q31_t)0x4375ebfe, (q31_t)0x9338598a, (q31_t)0x437094f1, (q31_t)0x933509f0, (q31_t)0x436b3dbb, (q31_t)0x9331ba98, - (q31_t)0x4365e65b, (q31_t)0x932e6b84, (q31_t)0x43608ed2, (q31_t)0x932b1cb2, (q31_t)0x435b371f, (q31_t)0x9327ce24, (q31_t)0x4355df42, (q31_t)0x93247fd9, - (q31_t)0x4350873c, (q31_t)0x932131d1, (q31_t)0x434b2f0c, (q31_t)0x931de40c, (q31_t)0x4345d6b3, (q31_t)0x931a968b, (q31_t)0x43407e31, (q31_t)0x9317494c, - (q31_t)0x433b2585, (q31_t)0x9313fc51, (q31_t)0x4335ccaf, (q31_t)0x9310af99, (q31_t)0x433073b0, (q31_t)0x930d6324, (q31_t)0x432b1a87, (q31_t)0x930a16f3, - (q31_t)0x4325c135, (q31_t)0x9306cb04, (q31_t)0x432067ba, (q31_t)0x93037f59, (q31_t)0x431b0e15, (q31_t)0x930033f1, (q31_t)0x4315b447, (q31_t)0x92fce8cc, - (q31_t)0x43105a50, (q31_t)0x92f99deb, (q31_t)0x430b002f, (q31_t)0x92f6534c, (q31_t)0x4305a5e5, (q31_t)0x92f308f1, (q31_t)0x43004b71, (q31_t)0x92efbeda, - (q31_t)0x42faf0d4, (q31_t)0x92ec7505, (q31_t)0x42f5960e, (q31_t)0x92e92b74, (q31_t)0x42f03b1e, (q31_t)0x92e5e226, (q31_t)0x42eae005, (q31_t)0x92e2991c, - (q31_t)0x42e584c3, (q31_t)0x92df5054, (q31_t)0x42e02958, (q31_t)0x92dc07d0, (q31_t)0x42dacdc3, (q31_t)0x92d8bf90, (q31_t)0x42d57205, (q31_t)0x92d57792, - (q31_t)0x42d0161e, (q31_t)0x92d22fd9, (q31_t)0x42caba0e, (q31_t)0x92cee862, (q31_t)0x42c55dd4, (q31_t)0x92cba12f, (q31_t)0x42c00172, (q31_t)0x92c85a3f, - (q31_t)0x42baa4e6, (q31_t)0x92c51392, (q31_t)0x42b54831, (q31_t)0x92c1cd29, (q31_t)0x42afeb53, (q31_t)0x92be8703, (q31_t)0x42aa8e4b, (q31_t)0x92bb4121, - (q31_t)0x42a5311b, (q31_t)0x92b7fb82, (q31_t)0x429fd3c1, (q31_t)0x92b4b626, (q31_t)0x429a763f, (q31_t)0x92b1710e, (q31_t)0x42951893, (q31_t)0x92ae2c3a, - (q31_t)0x428fbabe, (q31_t)0x92aae7a8, (q31_t)0x428a5cc0, (q31_t)0x92a7a35a, (q31_t)0x4284fe99, (q31_t)0x92a45f50, (q31_t)0x427fa049, (q31_t)0x92a11b89, - (q31_t)0x427a41d0, (q31_t)0x929dd806, (q31_t)0x4274e32e, (q31_t)0x929a94c6, (q31_t)0x426f8463, (q31_t)0x929751c9, (q31_t)0x426a256f, (q31_t)0x92940f10, - (q31_t)0x4264c653, (q31_t)0x9290cc9b, (q31_t)0x425f670d, (q31_t)0x928d8a69, (q31_t)0x425a079e, (q31_t)0x928a487a, (q31_t)0x4254a806, (q31_t)0x928706cf, - (q31_t)0x424f4845, (q31_t)0x9283c568, (q31_t)0x4249e85c, (q31_t)0x92808444, (q31_t)0x42448849, (q31_t)0x927d4363, (q31_t)0x423f280e, (q31_t)0x927a02c7, - (q31_t)0x4239c7aa, (q31_t)0x9276c26d, (q31_t)0x4234671d, (q31_t)0x92738258, (q31_t)0x422f0667, (q31_t)0x92704286, (q31_t)0x4229a588, (q31_t)0x926d02f7, - (q31_t)0x42244481, (q31_t)0x9269c3ac, (q31_t)0x421ee350, (q31_t)0x926684a5, (q31_t)0x421981f7, (q31_t)0x926345e1, (q31_t)0x42142075, (q31_t)0x92600761, - (q31_t)0x420ebecb, (q31_t)0x925cc924, (q31_t)0x42095cf7, (q31_t)0x92598b2b, (q31_t)0x4203fafb, (q31_t)0x92564d76, (q31_t)0x41fe98d6, (q31_t)0x92531005, - (q31_t)0x41f93689, (q31_t)0x924fd2d7, (q31_t)0x41f3d413, (q31_t)0x924c95ec, (q31_t)0x41ee7174, (q31_t)0x92495946, (q31_t)0x41e90eac, (q31_t)0x92461ce3, - (q31_t)0x41e3abbc, (q31_t)0x9242e0c4, (q31_t)0x41de48a3, (q31_t)0x923fa4e8, (q31_t)0x41d8e561, (q31_t)0x923c6950, (q31_t)0x41d381f7, (q31_t)0x92392dfc, - (q31_t)0x41ce1e65, (q31_t)0x9235f2ec, (q31_t)0x41c8baa9, (q31_t)0x9232b81f, (q31_t)0x41c356c5, (q31_t)0x922f7d96, (q31_t)0x41bdf2b9, (q31_t)0x922c4351, - (q31_t)0x41b88e84, (q31_t)0x9229094f, (q31_t)0x41b32a26, (q31_t)0x9225cf91, (q31_t)0x41adc5a0, (q31_t)0x92229617, (q31_t)0x41a860f1, (q31_t)0x921f5ce1, - (q31_t)0x41a2fc1a, (q31_t)0x921c23ef, (q31_t)0x419d971b, (q31_t)0x9218eb40, (q31_t)0x419831f3, (q31_t)0x9215b2d5, (q31_t)0x4192cca2, (q31_t)0x92127aae, - (q31_t)0x418d6729, (q31_t)0x920f42cb, (q31_t)0x41880188, (q31_t)0x920c0b2c, (q31_t)0x41829bbe, (q31_t)0x9208d3d0, (q31_t)0x417d35cb, (q31_t)0x92059cb8, - (q31_t)0x4177cfb1, (q31_t)0x920265e4, (q31_t)0x4172696e, (q31_t)0x91ff2f54, (q31_t)0x416d0302, (q31_t)0x91fbf908, (q31_t)0x41679c6f, (q31_t)0x91f8c300, - (q31_t)0x416235b2, (q31_t)0x91f58d3b, (q31_t)0x415ccece, (q31_t)0x91f257bb, (q31_t)0x415767c1, (q31_t)0x91ef227e, (q31_t)0x4152008c, (q31_t)0x91ebed85, - (q31_t)0x414c992f, (q31_t)0x91e8b8d0, (q31_t)0x414731a9, (q31_t)0x91e5845f, (q31_t)0x4141c9fb, (q31_t)0x91e25032, (q31_t)0x413c6225, (q31_t)0x91df1c49, - (q31_t)0x4136fa27, (q31_t)0x91dbe8a4, (q31_t)0x41319200, (q31_t)0x91d8b542, (q31_t)0x412c29b1, (q31_t)0x91d58225, (q31_t)0x4126c13a, (q31_t)0x91d24f4c, - (q31_t)0x4121589b, (q31_t)0x91cf1cb6, (q31_t)0x411befd3, (q31_t)0x91cbea65, (q31_t)0x411686e4, (q31_t)0x91c8b857, (q31_t)0x41111dcc, (q31_t)0x91c5868e, - (q31_t)0x410bb48c, (q31_t)0x91c25508, (q31_t)0x41064b24, (q31_t)0x91bf23c7, (q31_t)0x4100e194, (q31_t)0x91bbf2c9, (q31_t)0x40fb77dc, (q31_t)0x91b8c210, - (q31_t)0x40f60dfb, (q31_t)0x91b5919a, (q31_t)0x40f0a3f3, (q31_t)0x91b26169, (q31_t)0x40eb39c3, (q31_t)0x91af317c, (q31_t)0x40e5cf6a, (q31_t)0x91ac01d2, - (q31_t)0x40e064ea, (q31_t)0x91a8d26d, (q31_t)0x40dafa41, (q31_t)0x91a5a34c, (q31_t)0x40d58f71, (q31_t)0x91a2746f, (q31_t)0x40d02478, (q31_t)0x919f45d6, - (q31_t)0x40cab958, (q31_t)0x919c1781, (q31_t)0x40c54e0f, (q31_t)0x9198e970, (q31_t)0x40bfe29f, (q31_t)0x9195bba3, (q31_t)0x40ba7706, (q31_t)0x91928e1a, - (q31_t)0x40b50b46, (q31_t)0x918f60d6, (q31_t)0x40af9f5e, (q31_t)0x918c33d5, (q31_t)0x40aa334e, (q31_t)0x91890719, (q31_t)0x40a4c716, (q31_t)0x9185daa1, - (q31_t)0x409f5ab6, (q31_t)0x9182ae6d, (q31_t)0x4099ee2e, (q31_t)0x917f827d, (q31_t)0x4094817f, (q31_t)0x917c56d1, (q31_t)0x408f14a7, (q31_t)0x91792b6a, - (q31_t)0x4089a7a8, (q31_t)0x91760047, (q31_t)0x40843a81, (q31_t)0x9172d567, (q31_t)0x407ecd32, (q31_t)0x916faacc, (q31_t)0x40795fbc, (q31_t)0x916c8076, - (q31_t)0x4073f21d, (q31_t)0x91695663, (q31_t)0x406e8457, (q31_t)0x91662c95, (q31_t)0x40691669, (q31_t)0x9163030b, (q31_t)0x4063a854, (q31_t)0x915fd9c5, - (q31_t)0x405e3a16, (q31_t)0x915cb0c3, (q31_t)0x4058cbb1, (q31_t)0x91598806, (q31_t)0x40535d24, (q31_t)0x91565f8d, (q31_t)0x404dee70, (q31_t)0x91533758, - (q31_t)0x40487f94, (q31_t)0x91500f67, (q31_t)0x40431090, (q31_t)0x914ce7bb, (q31_t)0x403da165, (q31_t)0x9149c053, (q31_t)0x40383212, (q31_t)0x9146992f, - (q31_t)0x4032c297, (q31_t)0x91437250, (q31_t)0x402d52f5, (q31_t)0x91404bb5, (q31_t)0x4027e32b, (q31_t)0x913d255e, (q31_t)0x4022733a, (q31_t)0x9139ff4b, - (q31_t)0x401d0321, (q31_t)0x9136d97d, (q31_t)0x401792e0, (q31_t)0x9133b3f3, (q31_t)0x40122278, (q31_t)0x91308eae, (q31_t)0x400cb1e9, (q31_t)0x912d69ad, - (q31_t)0x40074132, (q31_t)0x912a44f0, (q31_t)0x4001d053, (q31_t)0x91272078, (q31_t)0x3ffc5f4d, (q31_t)0x9123fc44, (q31_t)0x3ff6ee1f, (q31_t)0x9120d854, - (q31_t)0x3ff17cca, (q31_t)0x911db4a9, (q31_t)0x3fec0b4e, (q31_t)0x911a9142, (q31_t)0x3fe699aa, (q31_t)0x91176e1f, (q31_t)0x3fe127df, (q31_t)0x91144b41, - (q31_t)0x3fdbb5ec, (q31_t)0x911128a8, (q31_t)0x3fd643d2, (q31_t)0x910e0653, (q31_t)0x3fd0d191, (q31_t)0x910ae442, (q31_t)0x3fcb5f28, (q31_t)0x9107c276, - (q31_t)0x3fc5ec98, (q31_t)0x9104a0ee, (q31_t)0x3fc079e0, (q31_t)0x91017faa, (q31_t)0x3fbb0702, (q31_t)0x90fe5eab, (q31_t)0x3fb593fb, (q31_t)0x90fb3df1, - (q31_t)0x3fb020ce, (q31_t)0x90f81d7b, (q31_t)0x3faaad79, (q31_t)0x90f4fd4a, (q31_t)0x3fa539fd, (q31_t)0x90f1dd5d, (q31_t)0x3f9fc65a, (q31_t)0x90eebdb4, - (q31_t)0x3f9a5290, (q31_t)0x90eb9e50, (q31_t)0x3f94de9e, (q31_t)0x90e87f31, (q31_t)0x3f8f6a85, (q31_t)0x90e56056, (q31_t)0x3f89f645, (q31_t)0x90e241bf, - (q31_t)0x3f8481dd, (q31_t)0x90df236e, (q31_t)0x3f7f0d4f, (q31_t)0x90dc0560, (q31_t)0x3f799899, (q31_t)0x90d8e798, (q31_t)0x3f7423bc, (q31_t)0x90d5ca13, - (q31_t)0x3f6eaeb8, (q31_t)0x90d2acd4, (q31_t)0x3f69398d, (q31_t)0x90cf8fd9, (q31_t)0x3f63c43b, (q31_t)0x90cc7322, (q31_t)0x3f5e4ec2, (q31_t)0x90c956b1, - (q31_t)0x3f58d921, (q31_t)0x90c63a83, (q31_t)0x3f53635a, (q31_t)0x90c31e9b, (q31_t)0x3f4ded6b, (q31_t)0x90c002f7, (q31_t)0x3f487755, (q31_t)0x90bce797, - (q31_t)0x3f430119, (q31_t)0x90b9cc7d, (q31_t)0x3f3d8ab5, (q31_t)0x90b6b1a6, (q31_t)0x3f38142a, (q31_t)0x90b39715, (q31_t)0x3f329d79, (q31_t)0x90b07cc8, - (q31_t)0x3f2d26a0, (q31_t)0x90ad62c0, (q31_t)0x3f27afa1, (q31_t)0x90aa48fd, (q31_t)0x3f22387a, (q31_t)0x90a72f7e, (q31_t)0x3f1cc12c, (q31_t)0x90a41644, - (q31_t)0x3f1749b8, (q31_t)0x90a0fd4e, (q31_t)0x3f11d21d, (q31_t)0x909de49e, (q31_t)0x3f0c5a5a, (q31_t)0x909acc32, (q31_t)0x3f06e271, (q31_t)0x9097b40a, - (q31_t)0x3f016a61, (q31_t)0x90949c28, (q31_t)0x3efbf22a, (q31_t)0x9091848a, (q31_t)0x3ef679cc, (q31_t)0x908e6d31, (q31_t)0x3ef10148, (q31_t)0x908b561c, - (q31_t)0x3eeb889c, (q31_t)0x90883f4d, (q31_t)0x3ee60fca, (q31_t)0x908528c2, (q31_t)0x3ee096d1, (q31_t)0x9082127c, (q31_t)0x3edb1db1, (q31_t)0x907efc7a, - (q31_t)0x3ed5a46b, (q31_t)0x907be6be, (q31_t)0x3ed02afd, (q31_t)0x9078d146, (q31_t)0x3ecab169, (q31_t)0x9075bc13, (q31_t)0x3ec537ae, (q31_t)0x9072a725, - (q31_t)0x3ebfbdcd, (q31_t)0x906f927c, (q31_t)0x3eba43c4, (q31_t)0x906c7e17, (q31_t)0x3eb4c995, (q31_t)0x906969f8, (q31_t)0x3eaf4f40, (q31_t)0x9066561d, - (q31_t)0x3ea9d4c3, (q31_t)0x90634287, (q31_t)0x3ea45a21, (q31_t)0x90602f35, (q31_t)0x3e9edf57, (q31_t)0x905d1c29, (q31_t)0x3e996467, (q31_t)0x905a0962, - (q31_t)0x3e93e950, (q31_t)0x9056f6df, (q31_t)0x3e8e6e12, (q31_t)0x9053e4a1, (q31_t)0x3e88f2ae, (q31_t)0x9050d2a9, (q31_t)0x3e837724, (q31_t)0x904dc0f5, - (q31_t)0x3e7dfb73, (q31_t)0x904aaf86, (q31_t)0x3e787f9b, (q31_t)0x90479e5c, (q31_t)0x3e73039d, (q31_t)0x90448d76, (q31_t)0x3e6d8778, (q31_t)0x90417cd6, - (q31_t)0x3e680b2c, (q31_t)0x903e6c7b, (q31_t)0x3e628ebb, (q31_t)0x903b5c64, (q31_t)0x3e5d1222, (q31_t)0x90384c93, (q31_t)0x3e579564, (q31_t)0x90353d06, - (q31_t)0x3e52187f, (q31_t)0x90322dbf, (q31_t)0x3e4c9b73, (q31_t)0x902f1ebc, (q31_t)0x3e471e41, (q31_t)0x902c0fff, (q31_t)0x3e41a0e8, (q31_t)0x90290186, - (q31_t)0x3e3c2369, (q31_t)0x9025f352, (q31_t)0x3e36a5c4, (q31_t)0x9022e564, (q31_t)0x3e3127f9, (q31_t)0x901fd7ba, (q31_t)0x3e2baa07, (q31_t)0x901cca55, - (q31_t)0x3e262bee, (q31_t)0x9019bd36, (q31_t)0x3e20adaf, (q31_t)0x9016b05b, (q31_t)0x3e1b2f4a, (q31_t)0x9013a3c5, (q31_t)0x3e15b0bf, (q31_t)0x90109775, - (q31_t)0x3e10320d, (q31_t)0x900d8b69, (q31_t)0x3e0ab336, (q31_t)0x900a7fa3, (q31_t)0x3e053437, (q31_t)0x90077422, (q31_t)0x3dffb513, (q31_t)0x900468e5, - (q31_t)0x3dfa35c8, (q31_t)0x90015dee, (q31_t)0x3df4b657, (q31_t)0x8ffe533c, (q31_t)0x3def36c0, (q31_t)0x8ffb48cf, (q31_t)0x3de9b703, (q31_t)0x8ff83ea7, - (q31_t)0x3de4371f, (q31_t)0x8ff534c4, (q31_t)0x3ddeb716, (q31_t)0x8ff22b26, (q31_t)0x3dd936e6, (q31_t)0x8fef21ce, (q31_t)0x3dd3b690, (q31_t)0x8fec18ba, - (q31_t)0x3dce3614, (q31_t)0x8fe90fec, (q31_t)0x3dc8b571, (q31_t)0x8fe60763, (q31_t)0x3dc334a9, (q31_t)0x8fe2ff1f, (q31_t)0x3dbdb3ba, (q31_t)0x8fdff720, - (q31_t)0x3db832a6, (q31_t)0x8fdcef66, (q31_t)0x3db2b16b, (q31_t)0x8fd9e7f2, (q31_t)0x3dad300b, (q31_t)0x8fd6e0c2, (q31_t)0x3da7ae84, (q31_t)0x8fd3d9d8, - (q31_t)0x3da22cd7, (q31_t)0x8fd0d333, (q31_t)0x3d9cab04, (q31_t)0x8fcdccd3, (q31_t)0x3d97290b, (q31_t)0x8fcac6b9, (q31_t)0x3d91a6ed, (q31_t)0x8fc7c0e3, - (q31_t)0x3d8c24a8, (q31_t)0x8fc4bb53, (q31_t)0x3d86a23d, (q31_t)0x8fc1b608, (q31_t)0x3d811fac, (q31_t)0x8fbeb103, (q31_t)0x3d7b9cf6, (q31_t)0x8fbbac42, - (q31_t)0x3d761a19, (q31_t)0x8fb8a7c7, (q31_t)0x3d709717, (q31_t)0x8fb5a391, (q31_t)0x3d6b13ee, (q31_t)0x8fb29fa0, (q31_t)0x3d6590a0, (q31_t)0x8faf9bf5, - (q31_t)0x3d600d2c, (q31_t)0x8fac988f, (q31_t)0x3d5a8992, (q31_t)0x8fa9956e, (q31_t)0x3d5505d2, (q31_t)0x8fa69293, (q31_t)0x3d4f81ec, (q31_t)0x8fa38ffc, - (q31_t)0x3d49fde1, (q31_t)0x8fa08dab, (q31_t)0x3d4479b0, (q31_t)0x8f9d8ba0, (q31_t)0x3d3ef559, (q31_t)0x8f9a89da, (q31_t)0x3d3970dc, (q31_t)0x8f978859, - (q31_t)0x3d33ec39, (q31_t)0x8f94871d, (q31_t)0x3d2e6771, (q31_t)0x8f918627, (q31_t)0x3d28e282, (q31_t)0x8f8e8576, (q31_t)0x3d235d6f, (q31_t)0x8f8b850a, - (q31_t)0x3d1dd835, (q31_t)0x8f8884e4, (q31_t)0x3d1852d6, (q31_t)0x8f858503, (q31_t)0x3d12cd51, (q31_t)0x8f828568, (q31_t)0x3d0d47a6, (q31_t)0x8f7f8612, - (q31_t)0x3d07c1d6, (q31_t)0x8f7c8701, (q31_t)0x3d023be0, (q31_t)0x8f798836, (q31_t)0x3cfcb5c4, (q31_t)0x8f7689b0, (q31_t)0x3cf72f83, (q31_t)0x8f738b70, - (q31_t)0x3cf1a91c, (q31_t)0x8f708d75, (q31_t)0x3cec2290, (q31_t)0x8f6d8fbf, (q31_t)0x3ce69bde, (q31_t)0x8f6a924f, (q31_t)0x3ce11507, (q31_t)0x8f679525, - (q31_t)0x3cdb8e09, (q31_t)0x8f649840, (q31_t)0x3cd606e7, (q31_t)0x8f619ba0, (q31_t)0x3cd07f9f, (q31_t)0x8f5e9f46, (q31_t)0x3ccaf831, (q31_t)0x8f5ba331, - (q31_t)0x3cc5709e, (q31_t)0x8f58a761, (q31_t)0x3cbfe8e5, (q31_t)0x8f55abd8, (q31_t)0x3cba6107, (q31_t)0x8f52b093, (q31_t)0x3cb4d904, (q31_t)0x8f4fb595, - (q31_t)0x3caf50da, (q31_t)0x8f4cbadb, (q31_t)0x3ca9c88c, (q31_t)0x8f49c067, (q31_t)0x3ca44018, (q31_t)0x8f46c639, (q31_t)0x3c9eb77f, (q31_t)0x8f43cc50, - (q31_t)0x3c992ec0, (q31_t)0x8f40d2ad, (q31_t)0x3c93a5dc, (q31_t)0x8f3dd950, (q31_t)0x3c8e1cd3, (q31_t)0x8f3ae038, (q31_t)0x3c8893a4, (q31_t)0x8f37e765, - (q31_t)0x3c830a50, (q31_t)0x8f34eed8, (q31_t)0x3c7d80d6, (q31_t)0x8f31f691, (q31_t)0x3c77f737, (q31_t)0x8f2efe8f, (q31_t)0x3c726d73, (q31_t)0x8f2c06d3, - (q31_t)0x3c6ce38a, (q31_t)0x8f290f5c, (q31_t)0x3c67597b, (q31_t)0x8f26182b, (q31_t)0x3c61cf48, (q31_t)0x8f232140, (q31_t)0x3c5c44ee, (q31_t)0x8f202a9a, - (q31_t)0x3c56ba70, (q31_t)0x8f1d343a, (q31_t)0x3c512fcc, (q31_t)0x8f1a3e1f, (q31_t)0x3c4ba504, (q31_t)0x8f17484b, (q31_t)0x3c461a16, (q31_t)0x8f1452bb, - (q31_t)0x3c408f03, (q31_t)0x8f115d72, (q31_t)0x3c3b03ca, (q31_t)0x8f0e686e, (q31_t)0x3c35786d, (q31_t)0x8f0b73b0, (q31_t)0x3c2fecea, (q31_t)0x8f087f37, - (q31_t)0x3c2a6142, (q31_t)0x8f058b04, (q31_t)0x3c24d575, (q31_t)0x8f029717, (q31_t)0x3c1f4983, (q31_t)0x8effa370, (q31_t)0x3c19bd6c, (q31_t)0x8efcb00e, - (q31_t)0x3c143130, (q31_t)0x8ef9bcf2, (q31_t)0x3c0ea4cf, (q31_t)0x8ef6ca1c, (q31_t)0x3c091849, (q31_t)0x8ef3d78b, (q31_t)0x3c038b9e, (q31_t)0x8ef0e540, - (q31_t)0x3bfdfecd, (q31_t)0x8eedf33b, (q31_t)0x3bf871d8, (q31_t)0x8eeb017c, (q31_t)0x3bf2e4be, (q31_t)0x8ee81002, (q31_t)0x3bed577e, (q31_t)0x8ee51ece, - (q31_t)0x3be7ca1a, (q31_t)0x8ee22de0, (q31_t)0x3be23c91, (q31_t)0x8edf3d38, (q31_t)0x3bdcaee3, (q31_t)0x8edc4cd5, (q31_t)0x3bd72110, (q31_t)0x8ed95cb8, - (q31_t)0x3bd19318, (q31_t)0x8ed66ce1, (q31_t)0x3bcc04fb, (q31_t)0x8ed37d50, (q31_t)0x3bc676b9, (q31_t)0x8ed08e05, (q31_t)0x3bc0e853, (q31_t)0x8ecd9eff, - (q31_t)0x3bbb59c7, (q31_t)0x8ecab040, (q31_t)0x3bb5cb17, (q31_t)0x8ec7c1c6, (q31_t)0x3bb03c42, (q31_t)0x8ec4d392, (q31_t)0x3baaad48, (q31_t)0x8ec1e5a4, - (q31_t)0x3ba51e29, (q31_t)0x8ebef7fb, (q31_t)0x3b9f8ee5, (q31_t)0x8ebc0a99, (q31_t)0x3b99ff7d, (q31_t)0x8eb91d7c, (q31_t)0x3b946ff0, (q31_t)0x8eb630a6, - (q31_t)0x3b8ee03e, (q31_t)0x8eb34415, (q31_t)0x3b895068, (q31_t)0x8eb057ca, (q31_t)0x3b83c06c, (q31_t)0x8ead6bc5, (q31_t)0x3b7e304c, (q31_t)0x8eaa8006, - (q31_t)0x3b78a007, (q31_t)0x8ea7948c, (q31_t)0x3b730f9e, (q31_t)0x8ea4a959, (q31_t)0x3b6d7f10, (q31_t)0x8ea1be6c, (q31_t)0x3b67ee5d, (q31_t)0x8e9ed3c4, - (q31_t)0x3b625d86, (q31_t)0x8e9be963, (q31_t)0x3b5ccc8a, (q31_t)0x8e98ff47, (q31_t)0x3b573b69, (q31_t)0x8e961571, (q31_t)0x3b51aa24, (q31_t)0x8e932be2, - (q31_t)0x3b4c18ba, (q31_t)0x8e904298, (q31_t)0x3b46872c, (q31_t)0x8e8d5994, (q31_t)0x3b40f579, (q31_t)0x8e8a70d7, (q31_t)0x3b3b63a1, (q31_t)0x8e87885f, - (q31_t)0x3b35d1a5, (q31_t)0x8e84a02d, (q31_t)0x3b303f84, (q31_t)0x8e81b841, (q31_t)0x3b2aad3f, (q31_t)0x8e7ed09b, (q31_t)0x3b251ad6, (q31_t)0x8e7be93c, - (q31_t)0x3b1f8848, (q31_t)0x8e790222, (q31_t)0x3b19f595, (q31_t)0x8e761b4e, (q31_t)0x3b1462be, (q31_t)0x8e7334c1, (q31_t)0x3b0ecfc3, (q31_t)0x8e704e79, - (q31_t)0x3b093ca3, (q31_t)0x8e6d6877, (q31_t)0x3b03a95e, (q31_t)0x8e6a82bc, (q31_t)0x3afe15f6, (q31_t)0x8e679d47, (q31_t)0x3af88269, (q31_t)0x8e64b817, - (q31_t)0x3af2eeb7, (q31_t)0x8e61d32e, (q31_t)0x3aed5ae1, (q31_t)0x8e5eee8b, (q31_t)0x3ae7c6e7, (q31_t)0x8e5c0a2e, (q31_t)0x3ae232c9, (q31_t)0x8e592617, - (q31_t)0x3adc9e86, (q31_t)0x8e564246, (q31_t)0x3ad70a1f, (q31_t)0x8e535ebb, (q31_t)0x3ad17593, (q31_t)0x8e507b76, (q31_t)0x3acbe0e3, (q31_t)0x8e4d9878, - (q31_t)0x3ac64c0f, (q31_t)0x8e4ab5bf, (q31_t)0x3ac0b717, (q31_t)0x8e47d34d, (q31_t)0x3abb21fb, (q31_t)0x8e44f121, (q31_t)0x3ab58cba, (q31_t)0x8e420f3b, - (q31_t)0x3aaff755, (q31_t)0x8e3f2d9b, (q31_t)0x3aaa61cc, (q31_t)0x8e3c4c41, (q31_t)0x3aa4cc1e, (q31_t)0x8e396b2e, (q31_t)0x3a9f364d, (q31_t)0x8e368a61, - (q31_t)0x3a99a057, (q31_t)0x8e33a9da, (q31_t)0x3a940a3e, (q31_t)0x8e30c999, (q31_t)0x3a8e7400, (q31_t)0x8e2de99e, (q31_t)0x3a88dd9d, (q31_t)0x8e2b09e9, - (q31_t)0x3a834717, (q31_t)0x8e282a7b, (q31_t)0x3a7db06d, (q31_t)0x8e254b53, (q31_t)0x3a78199f, (q31_t)0x8e226c71, (q31_t)0x3a7282ac, (q31_t)0x8e1f8dd6, - (q31_t)0x3a6ceb96, (q31_t)0x8e1caf80, (q31_t)0x3a67545b, (q31_t)0x8e19d171, (q31_t)0x3a61bcfd, (q31_t)0x8e16f3a9, (q31_t)0x3a5c257a, (q31_t)0x8e141626, - (q31_t)0x3a568dd4, (q31_t)0x8e1138ea, (q31_t)0x3a50f609, (q31_t)0x8e0e5bf4, (q31_t)0x3a4b5e1b, (q31_t)0x8e0b7f44, (q31_t)0x3a45c608, (q31_t)0x8e08a2db, - (q31_t)0x3a402dd2, (q31_t)0x8e05c6b7, (q31_t)0x3a3a9577, (q31_t)0x8e02eadb, (q31_t)0x3a34fcf9, (q31_t)0x8e000f44, (q31_t)0x3a2f6457, (q31_t)0x8dfd33f4, - (q31_t)0x3a29cb91, (q31_t)0x8dfa58ea, (q31_t)0x3a2432a7, (q31_t)0x8df77e27, (q31_t)0x3a1e9999, (q31_t)0x8df4a3a9, (q31_t)0x3a190068, (q31_t)0x8df1c973, - (q31_t)0x3a136712, (q31_t)0x8deeef82, (q31_t)0x3a0dcd99, (q31_t)0x8dec15d8, (q31_t)0x3a0833fc, (q31_t)0x8de93c74, (q31_t)0x3a029a3b, (q31_t)0x8de66357, - (q31_t)0x39fd0056, (q31_t)0x8de38a80, (q31_t)0x39f7664e, (q31_t)0x8de0b1ef, (q31_t)0x39f1cc21, (q31_t)0x8dddd9a5, (q31_t)0x39ec31d1, (q31_t)0x8ddb01a1, - (q31_t)0x39e6975e, (q31_t)0x8dd829e4, (q31_t)0x39e0fcc6, (q31_t)0x8dd5526d, (q31_t)0x39db620b, (q31_t)0x8dd27b3c, (q31_t)0x39d5c72c, (q31_t)0x8dcfa452, - (q31_t)0x39d02c2a, (q31_t)0x8dcccdaf, (q31_t)0x39ca9104, (q31_t)0x8dc9f751, (q31_t)0x39c4f5ba, (q31_t)0x8dc7213b, (q31_t)0x39bf5a4d, (q31_t)0x8dc44b6a, - (q31_t)0x39b9bebc, (q31_t)0x8dc175e0, (q31_t)0x39b42307, (q31_t)0x8dbea09d, (q31_t)0x39ae872f, (q31_t)0x8dbbcba0, (q31_t)0x39a8eb33, (q31_t)0x8db8f6ea, - (q31_t)0x39a34f13, (q31_t)0x8db6227a, (q31_t)0x399db2d0, (q31_t)0x8db34e50, (q31_t)0x3998166a, (q31_t)0x8db07a6d, (q31_t)0x399279e0, (q31_t)0x8dada6d1, - (q31_t)0x398cdd32, (q31_t)0x8daad37b, (q31_t)0x39874061, (q31_t)0x8da8006c, (q31_t)0x3981a36d, (q31_t)0x8da52da3, (q31_t)0x397c0655, (q31_t)0x8da25b21, - (q31_t)0x39766919, (q31_t)0x8d9f88e5, (q31_t)0x3970cbba, (q31_t)0x8d9cb6f0, (q31_t)0x396b2e38, (q31_t)0x8d99e541, (q31_t)0x39659092, (q31_t)0x8d9713d9, - (q31_t)0x395ff2c9, (q31_t)0x8d9442b8, (q31_t)0x395a54dd, (q31_t)0x8d9171dd, (q31_t)0x3954b6cd, (q31_t)0x8d8ea148, (q31_t)0x394f1899, (q31_t)0x8d8bd0fb, - (q31_t)0x39497a43, (q31_t)0x8d8900f3, (q31_t)0x3943dbc9, (q31_t)0x8d863133, (q31_t)0x393e3d2c, (q31_t)0x8d8361b9, (q31_t)0x39389e6b, (q31_t)0x8d809286, - (q31_t)0x3932ff87, (q31_t)0x8d7dc399, (q31_t)0x392d6080, (q31_t)0x8d7af4f3, (q31_t)0x3927c155, (q31_t)0x8d782694, (q31_t)0x39222208, (q31_t)0x8d75587b, - (q31_t)0x391c8297, (q31_t)0x8d728aa9, (q31_t)0x3916e303, (q31_t)0x8d6fbd1d, (q31_t)0x3911434b, (q31_t)0x8d6cefd9, (q31_t)0x390ba371, (q31_t)0x8d6a22db, - (q31_t)0x39060373, (q31_t)0x8d675623, (q31_t)0x39006352, (q31_t)0x8d6489b3, (q31_t)0x38fac30e, (q31_t)0x8d61bd89, (q31_t)0x38f522a6, (q31_t)0x8d5ef1a5, - (q31_t)0x38ef821c, (q31_t)0x8d5c2609, (q31_t)0x38e9e16e, (q31_t)0x8d595ab3, (q31_t)0x38e4409e, (q31_t)0x8d568fa4, (q31_t)0x38de9faa, (q31_t)0x8d53c4db, - (q31_t)0x38d8fe93, (q31_t)0x8d50fa59, (q31_t)0x38d35d59, (q31_t)0x8d4e301f, (q31_t)0x38cdbbfc, (q31_t)0x8d4b662a, (q31_t)0x38c81a7c, (q31_t)0x8d489c7d, - (q31_t)0x38c278d9, (q31_t)0x8d45d316, (q31_t)0x38bcd713, (q31_t)0x8d4309f6, (q31_t)0x38b7352a, (q31_t)0x8d40411d, (q31_t)0x38b1931e, (q31_t)0x8d3d788b, - (q31_t)0x38abf0ef, (q31_t)0x8d3ab03f, (q31_t)0x38a64e9d, (q31_t)0x8d37e83a, (q31_t)0x38a0ac29, (q31_t)0x8d35207d, (q31_t)0x389b0991, (q31_t)0x8d325905, - (q31_t)0x389566d6, (q31_t)0x8d2f91d5, (q31_t)0x388fc3f8, (q31_t)0x8d2ccaec, (q31_t)0x388a20f8, (q31_t)0x8d2a0449, (q31_t)0x38847dd5, (q31_t)0x8d273ded, - (q31_t)0x387eda8e, (q31_t)0x8d2477d8, (q31_t)0x38793725, (q31_t)0x8d21b20a, (q31_t)0x38739399, (q31_t)0x8d1eec83, (q31_t)0x386defeb, (q31_t)0x8d1c2742, - (q31_t)0x38684c19, (q31_t)0x8d196249, (q31_t)0x3862a825, (q31_t)0x8d169d96, (q31_t)0x385d040d, (q31_t)0x8d13d92a, (q31_t)0x38575fd4, (q31_t)0x8d111505, - (q31_t)0x3851bb77, (q31_t)0x8d0e5127, (q31_t)0x384c16f7, (q31_t)0x8d0b8d90, (q31_t)0x38467255, (q31_t)0x8d08ca40, (q31_t)0x3840cd90, (q31_t)0x8d060737, - (q31_t)0x383b28a9, (q31_t)0x8d034474, (q31_t)0x3835839f, (q31_t)0x8d0081f9, (q31_t)0x382fde72, (q31_t)0x8cfdbfc4, (q31_t)0x382a3922, (q31_t)0x8cfafdd7, - (q31_t)0x382493b0, (q31_t)0x8cf83c30, (q31_t)0x381eee1b, (q31_t)0x8cf57ad0, (q31_t)0x38194864, (q31_t)0x8cf2b9b8, (q31_t)0x3813a28a, (q31_t)0x8ceff8e6, - (q31_t)0x380dfc8d, (q31_t)0x8ced385b, (q31_t)0x3808566e, (q31_t)0x8cea7818, (q31_t)0x3802b02c, (q31_t)0x8ce7b81b, (q31_t)0x37fd09c8, (q31_t)0x8ce4f865, - (q31_t)0x37f76341, (q31_t)0x8ce238f6, (q31_t)0x37f1bc97, (q31_t)0x8cdf79ce, (q31_t)0x37ec15cb, (q31_t)0x8cdcbaee, (q31_t)0x37e66edd, (q31_t)0x8cd9fc54, - (q31_t)0x37e0c7cc, (q31_t)0x8cd73e01, (q31_t)0x37db2099, (q31_t)0x8cd47ff6, (q31_t)0x37d57943, (q31_t)0x8cd1c231, (q31_t)0x37cfd1cb, (q31_t)0x8ccf04b3, - (q31_t)0x37ca2a30, (q31_t)0x8ccc477d, (q31_t)0x37c48273, (q31_t)0x8cc98a8e, (q31_t)0x37beda93, (q31_t)0x8cc6cde5, (q31_t)0x37b93292, (q31_t)0x8cc41184, - (q31_t)0x37b38a6d, (q31_t)0x8cc1556a, (q31_t)0x37ade227, (q31_t)0x8cbe9996, (q31_t)0x37a839be, (q31_t)0x8cbbde0a, (q31_t)0x37a29132, (q31_t)0x8cb922c6, - (q31_t)0x379ce885, (q31_t)0x8cb667c8, (q31_t)0x37973fb5, (q31_t)0x8cb3ad11, (q31_t)0x379196c3, (q31_t)0x8cb0f2a1, (q31_t)0x378bedae, (q31_t)0x8cae3879, - (q31_t)0x37864477, (q31_t)0x8cab7e98, (q31_t)0x37809b1e, (q31_t)0x8ca8c4fd, (q31_t)0x377af1a3, (q31_t)0x8ca60baa, (q31_t)0x37754806, (q31_t)0x8ca3529f, - (q31_t)0x376f9e46, (q31_t)0x8ca099da, (q31_t)0x3769f464, (q31_t)0x8c9de15c, (q31_t)0x37644a60, (q31_t)0x8c9b2926, (q31_t)0x375ea03a, (q31_t)0x8c987137, - (q31_t)0x3758f5f2, (q31_t)0x8c95b98f, (q31_t)0x37534b87, (q31_t)0x8c93022e, (q31_t)0x374da0fa, (q31_t)0x8c904b14, (q31_t)0x3747f64c, (q31_t)0x8c8d9442, - (q31_t)0x37424b7b, (q31_t)0x8c8addb7, (q31_t)0x373ca088, (q31_t)0x8c882773, (q31_t)0x3736f573, (q31_t)0x8c857176, (q31_t)0x37314a3c, (q31_t)0x8c82bbc0, - (q31_t)0x372b9ee3, (q31_t)0x8c800652, (q31_t)0x3725f367, (q31_t)0x8c7d512b, (q31_t)0x372047ca, (q31_t)0x8c7a9c4b, (q31_t)0x371a9c0b, (q31_t)0x8c77e7b3, - (q31_t)0x3714f02a, (q31_t)0x8c753362, (q31_t)0x370f4427, (q31_t)0x8c727f58, (q31_t)0x37099802, (q31_t)0x8c6fcb95, (q31_t)0x3703ebbb, (q31_t)0x8c6d181a, - (q31_t)0x36fe3f52, (q31_t)0x8c6a64e5, (q31_t)0x36f892c7, (q31_t)0x8c67b1f9, (q31_t)0x36f2e61a, (q31_t)0x8c64ff53, (q31_t)0x36ed394b, (q31_t)0x8c624cf5, - (q31_t)0x36e78c5b, (q31_t)0x8c5f9ade, (q31_t)0x36e1df48, (q31_t)0x8c5ce90e, (q31_t)0x36dc3214, (q31_t)0x8c5a3786, (q31_t)0x36d684be, (q31_t)0x8c578645, - (q31_t)0x36d0d746, (q31_t)0x8c54d54c, (q31_t)0x36cb29ac, (q31_t)0x8c522499, (q31_t)0x36c57bf0, (q31_t)0x8c4f742f, (q31_t)0x36bfce13, (q31_t)0x8c4cc40b, - (q31_t)0x36ba2014, (q31_t)0x8c4a142f, (q31_t)0x36b471f3, (q31_t)0x8c47649a, (q31_t)0x36aec3b0, (q31_t)0x8c44b54d, (q31_t)0x36a9154c, (q31_t)0x8c420647, - (q31_t)0x36a366c6, (q31_t)0x8c3f5788, (q31_t)0x369db81e, (q31_t)0x8c3ca911, (q31_t)0x36980954, (q31_t)0x8c39fae1, (q31_t)0x36925a69, (q31_t)0x8c374cf9, - (q31_t)0x368cab5c, (q31_t)0x8c349f58, (q31_t)0x3686fc2e, (q31_t)0x8c31f1ff, (q31_t)0x36814cde, (q31_t)0x8c2f44ed, (q31_t)0x367b9d6c, (q31_t)0x8c2c9822, - (q31_t)0x3675edd9, (q31_t)0x8c29eb9f, (q31_t)0x36703e24, (q31_t)0x8c273f63, (q31_t)0x366a8e4d, (q31_t)0x8c24936f, (q31_t)0x3664de55, (q31_t)0x8c21e7c2, - (q31_t)0x365f2e3b, (q31_t)0x8c1f3c5d, (q31_t)0x36597e00, (q31_t)0x8c1c913f, (q31_t)0x3653cda3, (q31_t)0x8c19e669, (q31_t)0x364e1d25, (q31_t)0x8c173bda, - (q31_t)0x36486c86, (q31_t)0x8c149192, (q31_t)0x3642bbc4, (q31_t)0x8c11e792, (q31_t)0x363d0ae2, (q31_t)0x8c0f3dda, (q31_t)0x363759de, (q31_t)0x8c0c9469, - (q31_t)0x3631a8b8, (q31_t)0x8c09eb40, (q31_t)0x362bf771, (q31_t)0x8c07425e, (q31_t)0x36264609, (q31_t)0x8c0499c4, (q31_t)0x3620947f, (q31_t)0x8c01f171, - (q31_t)0x361ae2d3, (q31_t)0x8bff4966, (q31_t)0x36153107, (q31_t)0x8bfca1a3, (q31_t)0x360f7f19, (q31_t)0x8bf9fa27, (q31_t)0x3609cd0a, (q31_t)0x8bf752f2, - (q31_t)0x36041ad9, (q31_t)0x8bf4ac05, (q31_t)0x35fe6887, (q31_t)0x8bf20560, (q31_t)0x35f8b614, (q31_t)0x8bef5f02, (q31_t)0x35f3037f, (q31_t)0x8becb8ec, - (q31_t)0x35ed50c9, (q31_t)0x8bea131e, (q31_t)0x35e79df2, (q31_t)0x8be76d97, (q31_t)0x35e1eafa, (q31_t)0x8be4c857, (q31_t)0x35dc37e0, (q31_t)0x8be22360, - (q31_t)0x35d684a6, (q31_t)0x8bdf7eb0, (q31_t)0x35d0d14a, (q31_t)0x8bdcda47, (q31_t)0x35cb1dcc, (q31_t)0x8bda3626, (q31_t)0x35c56a2e, (q31_t)0x8bd7924d, - (q31_t)0x35bfb66e, (q31_t)0x8bd4eebc, (q31_t)0x35ba028e, (q31_t)0x8bd24b72, (q31_t)0x35b44e8c, (q31_t)0x8bcfa870, (q31_t)0x35ae9a69, (q31_t)0x8bcd05b5, - (q31_t)0x35a8e625, (q31_t)0x8bca6343, (q31_t)0x35a331c0, (q31_t)0x8bc7c117, (q31_t)0x359d7d39, (q31_t)0x8bc51f34, (q31_t)0x3597c892, (q31_t)0x8bc27d98, - (q31_t)0x359213c9, (q31_t)0x8bbfdc44, (q31_t)0x358c5ee0, (q31_t)0x8bbd3b38, (q31_t)0x3586a9d5, (q31_t)0x8bba9a73, (q31_t)0x3580f4aa, (q31_t)0x8bb7f9f6, - (q31_t)0x357b3f5d, (q31_t)0x8bb559c1, (q31_t)0x357589f0, (q31_t)0x8bb2b9d4, (q31_t)0x356fd461, (q31_t)0x8bb01a2e, (q31_t)0x356a1eb2, (q31_t)0x8bad7ad0, - (q31_t)0x356468e2, (q31_t)0x8baadbba, (q31_t)0x355eb2f0, (q31_t)0x8ba83cec, (q31_t)0x3558fcde, (q31_t)0x8ba59e65, (q31_t)0x355346ab, (q31_t)0x8ba30026, - (q31_t)0x354d9057, (q31_t)0x8ba0622f, (q31_t)0x3547d9e2, (q31_t)0x8b9dc480, (q31_t)0x3542234c, (q31_t)0x8b9b2718, (q31_t)0x353c6c95, (q31_t)0x8b9889f8, - (q31_t)0x3536b5be, (q31_t)0x8b95ed21, (q31_t)0x3530fec6, (q31_t)0x8b935090, (q31_t)0x352b47ad, (q31_t)0x8b90b448, (q31_t)0x35259073, (q31_t)0x8b8e1848, - (q31_t)0x351fd918, (q31_t)0x8b8b7c8f, (q31_t)0x351a219c, (q31_t)0x8b88e11e, (q31_t)0x35146a00, (q31_t)0x8b8645f5, (q31_t)0x350eb243, (q31_t)0x8b83ab14, - (q31_t)0x3508fa66, (q31_t)0x8b81107b, (q31_t)0x35034267, (q31_t)0x8b7e7629, (q31_t)0x34fd8a48, (q31_t)0x8b7bdc20, (q31_t)0x34f7d208, (q31_t)0x8b79425e, - (q31_t)0x34f219a8, (q31_t)0x8b76a8e4, (q31_t)0x34ec6127, (q31_t)0x8b740fb3, (q31_t)0x34e6a885, (q31_t)0x8b7176c8, (q31_t)0x34e0efc2, (q31_t)0x8b6ede26, - (q31_t)0x34db36df, (q31_t)0x8b6c45cc, (q31_t)0x34d57ddc, (q31_t)0x8b69adba, (q31_t)0x34cfc4b7, (q31_t)0x8b6715ef, (q31_t)0x34ca0b73, (q31_t)0x8b647e6d, - (q31_t)0x34c4520d, (q31_t)0x8b61e733, (q31_t)0x34be9887, (q31_t)0x8b5f5040, (q31_t)0x34b8dee1, (q31_t)0x8b5cb995, (q31_t)0x34b3251a, (q31_t)0x8b5a2333, - (q31_t)0x34ad6b32, (q31_t)0x8b578d18, (q31_t)0x34a7b12a, (q31_t)0x8b54f745, (q31_t)0x34a1f702, (q31_t)0x8b5261ba, (q31_t)0x349c3cb9, (q31_t)0x8b4fcc77, - (q31_t)0x34968250, (q31_t)0x8b4d377c, (q31_t)0x3490c7c6, (q31_t)0x8b4aa2ca, (q31_t)0x348b0d1c, (q31_t)0x8b480e5f, (q31_t)0x34855251, (q31_t)0x8b457a3c, - (q31_t)0x347f9766, (q31_t)0x8b42e661, (q31_t)0x3479dc5b, (q31_t)0x8b4052ce, (q31_t)0x3474212f, (q31_t)0x8b3dbf83, (q31_t)0x346e65e3, (q31_t)0x8b3b2c80, - (q31_t)0x3468aa76, (q31_t)0x8b3899c6, (q31_t)0x3462eee9, (q31_t)0x8b360753, (q31_t)0x345d333c, (q31_t)0x8b337528, (q31_t)0x3457776f, (q31_t)0x8b30e345, - (q31_t)0x3451bb81, (q31_t)0x8b2e51ab, (q31_t)0x344bff73, (q31_t)0x8b2bc058, (q31_t)0x34464345, (q31_t)0x8b292f4e, (q31_t)0x344086f6, (q31_t)0x8b269e8b, - (q31_t)0x343aca87, (q31_t)0x8b240e11, (q31_t)0x34350df8, (q31_t)0x8b217ddf, (q31_t)0x342f5149, (q31_t)0x8b1eedf4, (q31_t)0x3429947a, (q31_t)0x8b1c5e52, - (q31_t)0x3423d78a, (q31_t)0x8b19cef8, (q31_t)0x341e1a7b, (q31_t)0x8b173fe6, (q31_t)0x34185d4b, (q31_t)0x8b14b11d, (q31_t)0x34129ffb, (q31_t)0x8b12229b, - (q31_t)0x340ce28b, (q31_t)0x8b0f9462, (q31_t)0x340724fb, (q31_t)0x8b0d0670, (q31_t)0x3401674a, (q31_t)0x8b0a78c7, (q31_t)0x33fba97a, (q31_t)0x8b07eb66, - (q31_t)0x33f5eb89, (q31_t)0x8b055e4d, (q31_t)0x33f02d79, (q31_t)0x8b02d17c, (q31_t)0x33ea6f48, (q31_t)0x8b0044f3, (q31_t)0x33e4b0f8, (q31_t)0x8afdb8b3, - (q31_t)0x33def287, (q31_t)0x8afb2cbb, (q31_t)0x33d933f7, (q31_t)0x8af8a10b, (q31_t)0x33d37546, (q31_t)0x8af615a3, (q31_t)0x33cdb676, (q31_t)0x8af38a83, - (q31_t)0x33c7f785, (q31_t)0x8af0ffac, (q31_t)0x33c23875, (q31_t)0x8aee751c, (q31_t)0x33bc7944, (q31_t)0x8aebead5, (q31_t)0x33b6b9f4, (q31_t)0x8ae960d6, - (q31_t)0x33b0fa84, (q31_t)0x8ae6d720, (q31_t)0x33ab3af4, (q31_t)0x8ae44db1, (q31_t)0x33a57b44, (q31_t)0x8ae1c48b, (q31_t)0x339fbb74, (q31_t)0x8adf3bad, - (q31_t)0x3399fb85, (q31_t)0x8adcb318, (q31_t)0x33943b75, (q31_t)0x8ada2aca, (q31_t)0x338e7b46, (q31_t)0x8ad7a2c5, (q31_t)0x3388baf7, (q31_t)0x8ad51b08, - (q31_t)0x3382fa88, (q31_t)0x8ad29394, (q31_t)0x337d39f9, (q31_t)0x8ad00c67, (q31_t)0x3377794b, (q31_t)0x8acd8583, (q31_t)0x3371b87d, (q31_t)0x8acafee8, - (q31_t)0x336bf78f, (q31_t)0x8ac87894, (q31_t)0x33663682, (q31_t)0x8ac5f289, (q31_t)0x33607554, (q31_t)0x8ac36cc6, (q31_t)0x335ab407, (q31_t)0x8ac0e74c, - (q31_t)0x3354f29b, (q31_t)0x8abe6219, (q31_t)0x334f310e, (q31_t)0x8abbdd30, (q31_t)0x33496f62, (q31_t)0x8ab9588e, (q31_t)0x3343ad97, (q31_t)0x8ab6d435, - (q31_t)0x333debab, (q31_t)0x8ab45024, (q31_t)0x333829a1, (q31_t)0x8ab1cc5c, (q31_t)0x33326776, (q31_t)0x8aaf48db, (q31_t)0x332ca52c, (q31_t)0x8aacc5a4, - (q31_t)0x3326e2c3, (q31_t)0x8aaa42b4, (q31_t)0x33212039, (q31_t)0x8aa7c00d, (q31_t)0x331b5d91, (q31_t)0x8aa53daf, (q31_t)0x33159ac8, (q31_t)0x8aa2bb99, - (q31_t)0x330fd7e1, (q31_t)0x8aa039cb, (q31_t)0x330a14da, (q31_t)0x8a9db845, (q31_t)0x330451b3, (q31_t)0x8a9b3708, (q31_t)0x32fe8e6d, (q31_t)0x8a98b614, - (q31_t)0x32f8cb07, (q31_t)0x8a963567, (q31_t)0x32f30782, (q31_t)0x8a93b504, (q31_t)0x32ed43de, (q31_t)0x8a9134e8, (q31_t)0x32e7801a, (q31_t)0x8a8eb516, - (q31_t)0x32e1bc36, (q31_t)0x8a8c358b, (q31_t)0x32dbf834, (q31_t)0x8a89b649, (q31_t)0x32d63412, (q31_t)0x8a873750, (q31_t)0x32d06fd0, (q31_t)0x8a84b89e, - (q31_t)0x32caab6f, (q31_t)0x8a823a36, (q31_t)0x32c4e6ef, (q31_t)0x8a7fbc16, (q31_t)0x32bf2250, (q31_t)0x8a7d3e3e, (q31_t)0x32b95d91, (q31_t)0x8a7ac0af, - (q31_t)0x32b398b3, (q31_t)0x8a784368, (q31_t)0x32add3b6, (q31_t)0x8a75c66a, (q31_t)0x32a80e99, (q31_t)0x8a7349b4, (q31_t)0x32a2495d, (q31_t)0x8a70cd47, - (q31_t)0x329c8402, (q31_t)0x8a6e5123, (q31_t)0x3296be88, (q31_t)0x8a6bd547, (q31_t)0x3290f8ef, (q31_t)0x8a6959b3, (q31_t)0x328b3336, (q31_t)0x8a66de68, - (q31_t)0x32856d5e, (q31_t)0x8a646365, (q31_t)0x327fa767, (q31_t)0x8a61e8ab, (q31_t)0x3279e151, (q31_t)0x8a5f6e3a, (q31_t)0x32741b1c, (q31_t)0x8a5cf411, - (q31_t)0x326e54c7, (q31_t)0x8a5a7a31, (q31_t)0x32688e54, (q31_t)0x8a580099, (q31_t)0x3262c7c1, (q31_t)0x8a55874a, (q31_t)0x325d0110, (q31_t)0x8a530e43, - (q31_t)0x32573a3f, (q31_t)0x8a509585, (q31_t)0x3251734f, (q31_t)0x8a4e1d10, (q31_t)0x324bac40, (q31_t)0x8a4ba4e3, (q31_t)0x3245e512, (q31_t)0x8a492cff, - (q31_t)0x32401dc6, (q31_t)0x8a46b564, (q31_t)0x323a565a, (q31_t)0x8a443e11, (q31_t)0x32348ecf, (q31_t)0x8a41c706, (q31_t)0x322ec725, (q31_t)0x8a3f5045, - (q31_t)0x3228ff5c, (q31_t)0x8a3cd9cc, (q31_t)0x32233775, (q31_t)0x8a3a639b, (q31_t)0x321d6f6e, (q31_t)0x8a37edb3, (q31_t)0x3217a748, (q31_t)0x8a357814, - (q31_t)0x3211df04, (q31_t)0x8a3302be, (q31_t)0x320c16a1, (q31_t)0x8a308db0, (q31_t)0x32064e1e, (q31_t)0x8a2e18eb, (q31_t)0x3200857d, (q31_t)0x8a2ba46e, - (q31_t)0x31fabcbd, (q31_t)0x8a29303b, (q31_t)0x31f4f3df, (q31_t)0x8a26bc50, (q31_t)0x31ef2ae1, (q31_t)0x8a2448ad, (q31_t)0x31e961c5, (q31_t)0x8a21d554, - (q31_t)0x31e39889, (q31_t)0x8a1f6243, (q31_t)0x31ddcf30, (q31_t)0x8a1cef7a, (q31_t)0x31d805b7, (q31_t)0x8a1a7cfb, (q31_t)0x31d23c1f, (q31_t)0x8a180ac4, - (q31_t)0x31cc7269, (q31_t)0x8a1598d6, (q31_t)0x31c6a894, (q31_t)0x8a132731, (q31_t)0x31c0dea1, (q31_t)0x8a10b5d4, (q31_t)0x31bb148f, (q31_t)0x8a0e44c0, - (q31_t)0x31b54a5e, (q31_t)0x8a0bd3f5, (q31_t)0x31af800e, (q31_t)0x8a096373, (q31_t)0x31a9b5a0, (q31_t)0x8a06f339, (q31_t)0x31a3eb13, (q31_t)0x8a048348, - (q31_t)0x319e2067, (q31_t)0x8a0213a0, (q31_t)0x3198559d, (q31_t)0x89ffa441, (q31_t)0x31928ab4, (q31_t)0x89fd352b, (q31_t)0x318cbfad, (q31_t)0x89fac65d, - (q31_t)0x3186f487, (q31_t)0x89f857d8, (q31_t)0x31812943, (q31_t)0x89f5e99c, (q31_t)0x317b5de0, (q31_t)0x89f37ba9, (q31_t)0x3175925e, (q31_t)0x89f10dff, - (q31_t)0x316fc6be, (q31_t)0x89eea09d, (q31_t)0x3169fb00, (q31_t)0x89ec3384, (q31_t)0x31642f23, (q31_t)0x89e9c6b4, (q31_t)0x315e6328, (q31_t)0x89e75a2d, - (q31_t)0x3158970e, (q31_t)0x89e4edef, (q31_t)0x3152cad5, (q31_t)0x89e281fa, (q31_t)0x314cfe7f, (q31_t)0x89e0164d, (q31_t)0x31473209, (q31_t)0x89ddaae9, - (q31_t)0x31416576, (q31_t)0x89db3fcf, (q31_t)0x313b98c4, (q31_t)0x89d8d4fd, (q31_t)0x3135cbf4, (q31_t)0x89d66a74, (q31_t)0x312fff05, (q31_t)0x89d40033, - (q31_t)0x312a31f8, (q31_t)0x89d1963c, (q31_t)0x312464cd, (q31_t)0x89cf2c8e, (q31_t)0x311e9783, (q31_t)0x89ccc328, (q31_t)0x3118ca1b, (q31_t)0x89ca5a0c, - (q31_t)0x3112fc95, (q31_t)0x89c7f138, (q31_t)0x310d2ef0, (q31_t)0x89c588ae, (q31_t)0x3107612e, (q31_t)0x89c3206c, (q31_t)0x3101934d, (q31_t)0x89c0b873, - (q31_t)0x30fbc54d, (q31_t)0x89be50c3, (q31_t)0x30f5f730, (q31_t)0x89bbe95c, (q31_t)0x30f028f4, (q31_t)0x89b9823e, (q31_t)0x30ea5a9a, (q31_t)0x89b71b69, - (q31_t)0x30e48c22, (q31_t)0x89b4b4dd, (q31_t)0x30debd8c, (q31_t)0x89b24e9a, (q31_t)0x30d8eed8, (q31_t)0x89afe8a0, (q31_t)0x30d32006, (q31_t)0x89ad82ef, - (q31_t)0x30cd5115, (q31_t)0x89ab1d87, (q31_t)0x30c78206, (q31_t)0x89a8b868, (q31_t)0x30c1b2da, (q31_t)0x89a65391, (q31_t)0x30bbe38f, (q31_t)0x89a3ef04, - (q31_t)0x30b61426, (q31_t)0x89a18ac0, (q31_t)0x30b0449f, (q31_t)0x899f26c5, (q31_t)0x30aa74fa, (q31_t)0x899cc313, (q31_t)0x30a4a537, (q31_t)0x899a5faa, - (q31_t)0x309ed556, (q31_t)0x8997fc8a, (q31_t)0x30990557, (q31_t)0x899599b3, (q31_t)0x3093353a, (q31_t)0x89933725, (q31_t)0x308d64ff, (q31_t)0x8990d4e0, - (q31_t)0x308794a6, (q31_t)0x898e72e4, (q31_t)0x3081c42f, (q31_t)0x898c1131, (q31_t)0x307bf39b, (q31_t)0x8989afc8, (q31_t)0x307622e8, (q31_t)0x89874ea7, - (q31_t)0x30705217, (q31_t)0x8984edcf, (q31_t)0x306a8129, (q31_t)0x89828d41, (q31_t)0x3064b01d, (q31_t)0x89802cfc, (q31_t)0x305edef3, (q31_t)0x897dccff, - (q31_t)0x30590dab, (q31_t)0x897b6d4c, (q31_t)0x30533c45, (q31_t)0x89790de2, (q31_t)0x304d6ac1, (q31_t)0x8976aec1, (q31_t)0x30479920, (q31_t)0x89744fe9, - (q31_t)0x3041c761, (q31_t)0x8971f15a, (q31_t)0x303bf584, (q31_t)0x896f9315, (q31_t)0x30362389, (q31_t)0x896d3518, (q31_t)0x30305171, (q31_t)0x896ad765, - (q31_t)0x302a7f3a, (q31_t)0x896879fb, (q31_t)0x3024ace6, (q31_t)0x89661cda, (q31_t)0x301eda75, (q31_t)0x8963c002, (q31_t)0x301907e6, (q31_t)0x89616373, - (q31_t)0x30133539, (q31_t)0x895f072e, (q31_t)0x300d626e, (q31_t)0x895cab31, (q31_t)0x30078f86, (q31_t)0x895a4f7e, (q31_t)0x3001bc80, (q31_t)0x8957f414, - (q31_t)0x2ffbe95d, (q31_t)0x895598f3, (q31_t)0x2ff6161c, (q31_t)0x89533e1c, (q31_t)0x2ff042bd, (q31_t)0x8950e38e, (q31_t)0x2fea6f41, (q31_t)0x894e8948, - (q31_t)0x2fe49ba7, (q31_t)0x894c2f4c, (q31_t)0x2fdec7f0, (q31_t)0x8949d59a, (q31_t)0x2fd8f41b, (q31_t)0x89477c30, (q31_t)0x2fd32028, (q31_t)0x89452310, - (q31_t)0x2fcd4c19, (q31_t)0x8942ca39, (q31_t)0x2fc777eb, (q31_t)0x894071ab, (q31_t)0x2fc1a3a0, (q31_t)0x893e1967, (q31_t)0x2fbbcf38, (q31_t)0x893bc16b, - (q31_t)0x2fb5fab2, (q31_t)0x893969b9, (q31_t)0x2fb0260f, (q31_t)0x89371250, (q31_t)0x2faa514f, (q31_t)0x8934bb31, (q31_t)0x2fa47c71, (q31_t)0x8932645b, - (q31_t)0x2f9ea775, (q31_t)0x89300dce, (q31_t)0x2f98d25d, (q31_t)0x892db78a, (q31_t)0x2f92fd26, (q31_t)0x892b6190, (q31_t)0x2f8d27d3, (q31_t)0x89290bdf, - (q31_t)0x2f875262, (q31_t)0x8926b677, (q31_t)0x2f817cd4, (q31_t)0x89246159, (q31_t)0x2f7ba729, (q31_t)0x89220c84, (q31_t)0x2f75d160, (q31_t)0x891fb7f8, - (q31_t)0x2f6ffb7a, (q31_t)0x891d63b5, (q31_t)0x2f6a2577, (q31_t)0x891b0fbc, (q31_t)0x2f644f56, (q31_t)0x8918bc0c, (q31_t)0x2f5e7919, (q31_t)0x891668a6, - (q31_t)0x2f58a2be, (q31_t)0x89141589, (q31_t)0x2f52cc46, (q31_t)0x8911c2b5, (q31_t)0x2f4cf5b0, (q31_t)0x890f702b, (q31_t)0x2f471efe, (q31_t)0x890d1dea, - (q31_t)0x2f41482e, (q31_t)0x890acbf2, (q31_t)0x2f3b7141, (q31_t)0x89087a44, (q31_t)0x2f359a37, (q31_t)0x890628df, (q31_t)0x2f2fc310, (q31_t)0x8903d7c4, - (q31_t)0x2f29ebcc, (q31_t)0x890186f2, (q31_t)0x2f24146b, (q31_t)0x88ff3669, (q31_t)0x2f1e3ced, (q31_t)0x88fce62a, (q31_t)0x2f186551, (q31_t)0x88fa9634, - (q31_t)0x2f128d99, (q31_t)0x88f84687, (q31_t)0x2f0cb5c3, (q31_t)0x88f5f724, (q31_t)0x2f06ddd1, (q31_t)0x88f3a80b, (q31_t)0x2f0105c1, (q31_t)0x88f1593b, - (q31_t)0x2efb2d95, (q31_t)0x88ef0ab4, (q31_t)0x2ef5554b, (q31_t)0x88ecbc77, (q31_t)0x2eef7ce5, (q31_t)0x88ea6e83, (q31_t)0x2ee9a461, (q31_t)0x88e820d9, - (q31_t)0x2ee3cbc1, (q31_t)0x88e5d378, (q31_t)0x2eddf304, (q31_t)0x88e38660, (q31_t)0x2ed81a29, (q31_t)0x88e13992, (q31_t)0x2ed24132, (q31_t)0x88deed0e, - (q31_t)0x2ecc681e, (q31_t)0x88dca0d3, (q31_t)0x2ec68eed, (q31_t)0x88da54e1, (q31_t)0x2ec0b5a0, (q31_t)0x88d8093a, (q31_t)0x2ebadc35, (q31_t)0x88d5bddb, - (q31_t)0x2eb502ae, (q31_t)0x88d372c6, (q31_t)0x2eaf290a, (q31_t)0x88d127fb, (q31_t)0x2ea94f49, (q31_t)0x88cedd79, (q31_t)0x2ea3756b, (q31_t)0x88cc9340, - (q31_t)0x2e9d9b70, (q31_t)0x88ca4951, (q31_t)0x2e97c159, (q31_t)0x88c7ffac, (q31_t)0x2e91e725, (q31_t)0x88c5b650, (q31_t)0x2e8c0cd4, (q31_t)0x88c36d3e, - (q31_t)0x2e863267, (q31_t)0x88c12475, (q31_t)0x2e8057dd, (q31_t)0x88bedbf6, (q31_t)0x2e7a7d36, (q31_t)0x88bc93c0, (q31_t)0x2e74a272, (q31_t)0x88ba4bd4, - (q31_t)0x2e6ec792, (q31_t)0x88b80432, (q31_t)0x2e68ec95, (q31_t)0x88b5bcd9, (q31_t)0x2e63117c, (q31_t)0x88b375ca, (q31_t)0x2e5d3646, (q31_t)0x88b12f04, - (q31_t)0x2e575af3, (q31_t)0x88aee888, (q31_t)0x2e517f84, (q31_t)0x88aca255, (q31_t)0x2e4ba3f8, (q31_t)0x88aa5c6c, (q31_t)0x2e45c850, (q31_t)0x88a816cd, - (q31_t)0x2e3fec8b, (q31_t)0x88a5d177, (q31_t)0x2e3a10aa, (q31_t)0x88a38c6b, (q31_t)0x2e3434ac, (q31_t)0x88a147a9, (q31_t)0x2e2e5891, (q31_t)0x889f0330, - (q31_t)0x2e287c5a, (q31_t)0x889cbf01, (q31_t)0x2e22a007, (q31_t)0x889a7b1b, (q31_t)0x2e1cc397, (q31_t)0x88983780, (q31_t)0x2e16e70b, (q31_t)0x8895f42d, - (q31_t)0x2e110a62, (q31_t)0x8893b125, (q31_t)0x2e0b2d9d, (q31_t)0x88916e66, (q31_t)0x2e0550bb, (q31_t)0x888f2bf1, (q31_t)0x2dff73bd, (q31_t)0x888ce9c5, - (q31_t)0x2df996a3, (q31_t)0x888aa7e3, (q31_t)0x2df3b96c, (q31_t)0x8888664b, (q31_t)0x2deddc19, (q31_t)0x888624fd, (q31_t)0x2de7feaa, (q31_t)0x8883e3f8, - (q31_t)0x2de2211e, (q31_t)0x8881a33d, (q31_t)0x2ddc4376, (q31_t)0x887f62cb, (q31_t)0x2dd665b2, (q31_t)0x887d22a4, (q31_t)0x2dd087d1, (q31_t)0x887ae2c6, - (q31_t)0x2dcaa9d5, (q31_t)0x8878a332, (q31_t)0x2dc4cbbc, (q31_t)0x887663e7, (q31_t)0x2dbeed86, (q31_t)0x887424e7, (q31_t)0x2db90f35, (q31_t)0x8871e630, - (q31_t)0x2db330c7, (q31_t)0x886fa7c2, (q31_t)0x2dad523d, (q31_t)0x886d699f, (q31_t)0x2da77397, (q31_t)0x886b2bc5, (q31_t)0x2da194d5, (q31_t)0x8868ee35, - (q31_t)0x2d9bb5f6, (q31_t)0x8866b0ef, (q31_t)0x2d95d6fc, (q31_t)0x886473f2, (q31_t)0x2d8ff7e5, (q31_t)0x88623740, (q31_t)0x2d8a18b3, (q31_t)0x885ffad7, - (q31_t)0x2d843964, (q31_t)0x885dbeb8, (q31_t)0x2d7e59f9, (q31_t)0x885b82e3, (q31_t)0x2d787a72, (q31_t)0x88594757, (q31_t)0x2d729acf, (q31_t)0x88570c16, - (q31_t)0x2d6cbb10, (q31_t)0x8854d11e, (q31_t)0x2d66db35, (q31_t)0x88529670, (q31_t)0x2d60fb3e, (q31_t)0x88505c0b, (q31_t)0x2d5b1b2b, (q31_t)0x884e21f1, - (q31_t)0x2d553afc, (q31_t)0x884be821, (q31_t)0x2d4f5ab1, (q31_t)0x8849ae9a, (q31_t)0x2d497a4a, (q31_t)0x8847755d, (q31_t)0x2d4399c7, (q31_t)0x88453c6a, - (q31_t)0x2d3db928, (q31_t)0x884303c1, (q31_t)0x2d37d86d, (q31_t)0x8840cb61, (q31_t)0x2d31f797, (q31_t)0x883e934c, (q31_t)0x2d2c16a4, (q31_t)0x883c5b81, - (q31_t)0x2d263596, (q31_t)0x883a23ff, (q31_t)0x2d20546b, (q31_t)0x8837ecc7, (q31_t)0x2d1a7325, (q31_t)0x8835b5d9, (q31_t)0x2d1491c4, (q31_t)0x88337f35, - (q31_t)0x2d0eb046, (q31_t)0x883148db, (q31_t)0x2d08ceac, (q31_t)0x882f12cb, (q31_t)0x2d02ecf7, (q31_t)0x882cdd04, (q31_t)0x2cfd0b26, (q31_t)0x882aa788, - (q31_t)0x2cf72939, (q31_t)0x88287256, (q31_t)0x2cf14731, (q31_t)0x88263d6d, (q31_t)0x2ceb650d, (q31_t)0x882408ce, (q31_t)0x2ce582cd, (q31_t)0x8821d47a, - (q31_t)0x2cdfa071, (q31_t)0x881fa06f, (q31_t)0x2cd9bdfa, (q31_t)0x881d6cae, (q31_t)0x2cd3db67, (q31_t)0x881b3937, (q31_t)0x2ccdf8b8, (q31_t)0x8819060a, - (q31_t)0x2cc815ee, (q31_t)0x8816d327, (q31_t)0x2cc23308, (q31_t)0x8814a08f, (q31_t)0x2cbc5006, (q31_t)0x88126e40, (q31_t)0x2cb66ce9, (q31_t)0x88103c3b, - (q31_t)0x2cb089b1, (q31_t)0x880e0a7f, (q31_t)0x2caaa65c, (q31_t)0x880bd90e, (q31_t)0x2ca4c2ed, (q31_t)0x8809a7e7, (q31_t)0x2c9edf61, (q31_t)0x8807770a, - (q31_t)0x2c98fbba, (q31_t)0x88054677, (q31_t)0x2c9317f8, (q31_t)0x8803162e, (q31_t)0x2c8d341a, (q31_t)0x8800e62f, (q31_t)0x2c875021, (q31_t)0x87feb67a, - (q31_t)0x2c816c0c, (q31_t)0x87fc870f, (q31_t)0x2c7b87dc, (q31_t)0x87fa57ee, (q31_t)0x2c75a390, (q31_t)0x87f82917, (q31_t)0x2c6fbf29, (q31_t)0x87f5fa8b, - (q31_t)0x2c69daa6, (q31_t)0x87f3cc48, (q31_t)0x2c63f609, (q31_t)0x87f19e4f, (q31_t)0x2c5e114f, (q31_t)0x87ef70a0, (q31_t)0x2c582c7b, (q31_t)0x87ed433c, - (q31_t)0x2c52478a, (q31_t)0x87eb1621, (q31_t)0x2c4c627f, (q31_t)0x87e8e950, (q31_t)0x2c467d58, (q31_t)0x87e6bcca, (q31_t)0x2c409816, (q31_t)0x87e4908e, - (q31_t)0x2c3ab2b9, (q31_t)0x87e2649b, (q31_t)0x2c34cd40, (q31_t)0x87e038f3, (q31_t)0x2c2ee7ad, (q31_t)0x87de0d95, (q31_t)0x2c2901fd, (q31_t)0x87dbe281, - (q31_t)0x2c231c33, (q31_t)0x87d9b7b7, (q31_t)0x2c1d364e, (q31_t)0x87d78d38, (q31_t)0x2c17504d, (q31_t)0x87d56302, (q31_t)0x2c116a31, (q31_t)0x87d33916, - (q31_t)0x2c0b83fa, (q31_t)0x87d10f75, (q31_t)0x2c059da7, (q31_t)0x87cee61e, (q31_t)0x2bffb73a, (q31_t)0x87ccbd11, (q31_t)0x2bf9d0b1, (q31_t)0x87ca944e, - (q31_t)0x2bf3ea0d, (q31_t)0x87c86bd5, (q31_t)0x2bee034e, (q31_t)0x87c643a6, (q31_t)0x2be81c74, (q31_t)0x87c41bc2, (q31_t)0x2be2357f, (q31_t)0x87c1f427, - (q31_t)0x2bdc4e6f, (q31_t)0x87bfccd7, (q31_t)0x2bd66744, (q31_t)0x87bda5d1, (q31_t)0x2bd07ffe, (q31_t)0x87bb7f16, (q31_t)0x2bca989d, (q31_t)0x87b958a4, - (q31_t)0x2bc4b120, (q31_t)0x87b7327d, (q31_t)0x2bbec989, (q31_t)0x87b50c9f, (q31_t)0x2bb8e1d7, (q31_t)0x87b2e70c, (q31_t)0x2bb2fa0a, (q31_t)0x87b0c1c4, - (q31_t)0x2bad1221, (q31_t)0x87ae9cc5, (q31_t)0x2ba72a1e, (q31_t)0x87ac7811, (q31_t)0x2ba14200, (q31_t)0x87aa53a6, (q31_t)0x2b9b59c7, (q31_t)0x87a82f87, - (q31_t)0x2b957173, (q31_t)0x87a60bb1, (q31_t)0x2b8f8905, (q31_t)0x87a3e825, (q31_t)0x2b89a07b, (q31_t)0x87a1c4e4, (q31_t)0x2b83b7d7, (q31_t)0x879fa1ed, - (q31_t)0x2b7dcf17, (q31_t)0x879d7f41, (q31_t)0x2b77e63d, (q31_t)0x879b5cde, (q31_t)0x2b71fd48, (q31_t)0x87993ac6, (q31_t)0x2b6c1438, (q31_t)0x879718f8, - (q31_t)0x2b662b0e, (q31_t)0x8794f774, (q31_t)0x2b6041c9, (q31_t)0x8792d63b, (q31_t)0x2b5a5868, (q31_t)0x8790b54c, (q31_t)0x2b546eee, (q31_t)0x878e94a7, - (q31_t)0x2b4e8558, (q31_t)0x878c744d, (q31_t)0x2b489ba8, (q31_t)0x878a543d, (q31_t)0x2b42b1dd, (q31_t)0x87883477, (q31_t)0x2b3cc7f7, (q31_t)0x878614fb, - (q31_t)0x2b36ddf7, (q31_t)0x8783f5ca, (q31_t)0x2b30f3dc, (q31_t)0x8781d6e3, (q31_t)0x2b2b09a6, (q31_t)0x877fb846, (q31_t)0x2b251f56, (q31_t)0x877d99f4, - (q31_t)0x2b1f34eb, (q31_t)0x877b7bec, (q31_t)0x2b194a66, (q31_t)0x87795e2f, (q31_t)0x2b135fc6, (q31_t)0x877740bb, (q31_t)0x2b0d750b, (q31_t)0x87752392, - (q31_t)0x2b078a36, (q31_t)0x877306b4, (q31_t)0x2b019f46, (q31_t)0x8770ea20, (q31_t)0x2afbb43c, (q31_t)0x876ecdd6, (q31_t)0x2af5c917, (q31_t)0x876cb1d6, - (q31_t)0x2aefddd8, (q31_t)0x876a9621, (q31_t)0x2ae9f27e, (q31_t)0x87687ab7, (q31_t)0x2ae4070a, (q31_t)0x87665f96, (q31_t)0x2ade1b7c, (q31_t)0x876444c1, - (q31_t)0x2ad82fd2, (q31_t)0x87622a35, (q31_t)0x2ad2440f, (q31_t)0x87600ff4, (q31_t)0x2acc5831, (q31_t)0x875df5fd, (q31_t)0x2ac66c39, (q31_t)0x875bdc51, - (q31_t)0x2ac08026, (q31_t)0x8759c2ef, (q31_t)0x2aba93f9, (q31_t)0x8757a9d8, (q31_t)0x2ab4a7b1, (q31_t)0x8755910b, (q31_t)0x2aaebb50, (q31_t)0x87537888, - (q31_t)0x2aa8ced3, (q31_t)0x87516050, (q31_t)0x2aa2e23d, (q31_t)0x874f4862, (q31_t)0x2a9cf58c, (q31_t)0x874d30bf, (q31_t)0x2a9708c1, (q31_t)0x874b1966, - (q31_t)0x2a911bdc, (q31_t)0x87490258, (q31_t)0x2a8b2edc, (q31_t)0x8746eb94, (q31_t)0x2a8541c3, (q31_t)0x8744d51b, (q31_t)0x2a7f548e, (q31_t)0x8742beec, - (q31_t)0x2a796740, (q31_t)0x8740a907, (q31_t)0x2a7379d8, (q31_t)0x873e936d, (q31_t)0x2a6d8c55, (q31_t)0x873c7e1e, (q31_t)0x2a679eb8, (q31_t)0x873a6919, - (q31_t)0x2a61b101, (q31_t)0x8738545e, (q31_t)0x2a5bc330, (q31_t)0x87363fee, (q31_t)0x2a55d545, (q31_t)0x87342bc9, (q31_t)0x2a4fe740, (q31_t)0x873217ee, - (q31_t)0x2a49f920, (q31_t)0x8730045d, (q31_t)0x2a440ae7, (q31_t)0x872df117, (q31_t)0x2a3e1c93, (q31_t)0x872bde1c, (q31_t)0x2a382e25, (q31_t)0x8729cb6b, - (q31_t)0x2a323f9e, (q31_t)0x8727b905, (q31_t)0x2a2c50fc, (q31_t)0x8725a6e9, (q31_t)0x2a266240, (q31_t)0x87239518, (q31_t)0x2a20736a, (q31_t)0x87218391, - (q31_t)0x2a1a847b, (q31_t)0x871f7255, (q31_t)0x2a149571, (q31_t)0x871d6163, (q31_t)0x2a0ea64d, (q31_t)0x871b50bc, (q31_t)0x2a08b710, (q31_t)0x87194060, - (q31_t)0x2a02c7b8, (q31_t)0x8717304e, (q31_t)0x29fcd847, (q31_t)0x87152087, (q31_t)0x29f6e8bb, (q31_t)0x8713110a, (q31_t)0x29f0f916, (q31_t)0x871101d8, - (q31_t)0x29eb0957, (q31_t)0x870ef2f1, (q31_t)0x29e5197e, (q31_t)0x870ce454, (q31_t)0x29df298b, (q31_t)0x870ad602, (q31_t)0x29d9397f, (q31_t)0x8708c7fa, - (q31_t)0x29d34958, (q31_t)0x8706ba3d, (q31_t)0x29cd5918, (q31_t)0x8704acca, (q31_t)0x29c768be, (q31_t)0x87029fa3, (q31_t)0x29c1784a, (q31_t)0x870092c5, - (q31_t)0x29bb87bc, (q31_t)0x86fe8633, (q31_t)0x29b59715, (q31_t)0x86fc79eb, (q31_t)0x29afa654, (q31_t)0x86fa6dee, (q31_t)0x29a9b579, (q31_t)0x86f8623b, - (q31_t)0x29a3c485, (q31_t)0x86f656d3, (q31_t)0x299dd377, (q31_t)0x86f44bb6, (q31_t)0x2997e24f, (q31_t)0x86f240e3, (q31_t)0x2991f10e, (q31_t)0x86f0365c, - (q31_t)0x298bffb2, (q31_t)0x86ee2c1e, (q31_t)0x29860e3e, (q31_t)0x86ec222c, (q31_t)0x29801caf, (q31_t)0x86ea1884, (q31_t)0x297a2b07, (q31_t)0x86e80f27, - (q31_t)0x29743946, (q31_t)0x86e60614, (q31_t)0x296e476b, (q31_t)0x86e3fd4c, (q31_t)0x29685576, (q31_t)0x86e1f4cf, (q31_t)0x29626368, (q31_t)0x86dfec9d, - (q31_t)0x295c7140, (q31_t)0x86dde4b5, (q31_t)0x29567eff, (q31_t)0x86dbdd18, (q31_t)0x29508ca4, (q31_t)0x86d9d5c6, (q31_t)0x294a9a30, (q31_t)0x86d7cebf, - (q31_t)0x2944a7a2, (q31_t)0x86d5c802, (q31_t)0x293eb4fb, (q31_t)0x86d3c190, (q31_t)0x2938c23a, (q31_t)0x86d1bb69, (q31_t)0x2932cf60, (q31_t)0x86cfb58c, - (q31_t)0x292cdc6d, (q31_t)0x86cdaffa, (q31_t)0x2926e960, (q31_t)0x86cbaab3, (q31_t)0x2920f63a, (q31_t)0x86c9a5b7, (q31_t)0x291b02fa, (q31_t)0x86c7a106, - (q31_t)0x29150fa1, (q31_t)0x86c59c9f, (q31_t)0x290f1c2f, (q31_t)0x86c39883, (q31_t)0x290928a3, (q31_t)0x86c194b2, (q31_t)0x290334ff, (q31_t)0x86bf912c, - (q31_t)0x28fd4140, (q31_t)0x86bd8df0, (q31_t)0x28f74d69, (q31_t)0x86bb8b00, (q31_t)0x28f15978, (q31_t)0x86b9885a, (q31_t)0x28eb656e, (q31_t)0x86b785ff, - (q31_t)0x28e5714b, (q31_t)0x86b583ee, (q31_t)0x28df7d0e, (q31_t)0x86b38229, (q31_t)0x28d988b8, (q31_t)0x86b180ae, (q31_t)0x28d3944a, (q31_t)0x86af7f7e, - (q31_t)0x28cd9fc1, (q31_t)0x86ad7e99, (q31_t)0x28c7ab20, (q31_t)0x86ab7dff, (q31_t)0x28c1b666, (q31_t)0x86a97db0, (q31_t)0x28bbc192, (q31_t)0x86a77dab, - (q31_t)0x28b5cca5, (q31_t)0x86a57df2, (q31_t)0x28afd7a0, (q31_t)0x86a37e83, (q31_t)0x28a9e281, (q31_t)0x86a17f5f, (q31_t)0x28a3ed49, (q31_t)0x869f8086, - (q31_t)0x289df7f8, (q31_t)0x869d81f8, (q31_t)0x2898028e, (q31_t)0x869b83b4, (q31_t)0x28920d0a, (q31_t)0x869985bc, (q31_t)0x288c176e, (q31_t)0x8697880f, - (q31_t)0x288621b9, (q31_t)0x86958aac, (q31_t)0x28802beb, (q31_t)0x86938d94, (q31_t)0x287a3604, (q31_t)0x869190c7, (q31_t)0x28744004, (q31_t)0x868f9445, - (q31_t)0x286e49ea, (q31_t)0x868d980e, (q31_t)0x286853b8, (q31_t)0x868b9c22, (q31_t)0x28625d6d, (q31_t)0x8689a081, (q31_t)0x285c670a, (q31_t)0x8687a52b, - (q31_t)0x2856708d, (q31_t)0x8685aa20, (q31_t)0x285079f7, (q31_t)0x8683af5f, (q31_t)0x284a8349, (q31_t)0x8681b4ea, (q31_t)0x28448c81, (q31_t)0x867fbabf, - (q31_t)0x283e95a1, (q31_t)0x867dc0e0, (q31_t)0x28389ea8, (q31_t)0x867bc74b, (q31_t)0x2832a796, (q31_t)0x8679ce01, (q31_t)0x282cb06c, (q31_t)0x8677d503, - (q31_t)0x2826b928, (q31_t)0x8675dc4f, (q31_t)0x2820c1cc, (q31_t)0x8673e3e6, (q31_t)0x281aca57, (q31_t)0x8671ebc8, (q31_t)0x2814d2c9, (q31_t)0x866ff3f6, - (q31_t)0x280edb23, (q31_t)0x866dfc6e, (q31_t)0x2808e364, (q31_t)0x866c0531, (q31_t)0x2802eb8c, (q31_t)0x866a0e3f, (q31_t)0x27fcf39c, (q31_t)0x86681798, - (q31_t)0x27f6fb92, (q31_t)0x8666213c, (q31_t)0x27f10371, (q31_t)0x86642b2c, (q31_t)0x27eb0b36, (q31_t)0x86623566, (q31_t)0x27e512e3, (q31_t)0x86603feb, - (q31_t)0x27df1a77, (q31_t)0x865e4abb, (q31_t)0x27d921f3, (q31_t)0x865c55d7, (q31_t)0x27d32956, (q31_t)0x865a613d, (q31_t)0x27cd30a1, (q31_t)0x86586cee, - (q31_t)0x27c737d3, (q31_t)0x865678eb, (q31_t)0x27c13eec, (q31_t)0x86548532, (q31_t)0x27bb45ed, (q31_t)0x865291c4, (q31_t)0x27b54cd6, (q31_t)0x86509ea2, - (q31_t)0x27af53a6, (q31_t)0x864eabcb, (q31_t)0x27a95a5d, (q31_t)0x864cb93e, (q31_t)0x27a360fc, (q31_t)0x864ac6fd, (q31_t)0x279d6783, (q31_t)0x8648d507, - (q31_t)0x27976df1, (q31_t)0x8646e35c, (q31_t)0x27917447, (q31_t)0x8644f1fc, (q31_t)0x278b7a84, (q31_t)0x864300e7, (q31_t)0x278580a9, (q31_t)0x8641101d, - (q31_t)0x277f86b5, (q31_t)0x863f1f9e, (q31_t)0x27798caa, (q31_t)0x863d2f6b, (q31_t)0x27739285, (q31_t)0x863b3f82, (q31_t)0x276d9849, (q31_t)0x86394fe5, - (q31_t)0x27679df4, (q31_t)0x86376092, (q31_t)0x2761a387, (q31_t)0x8635718b, (q31_t)0x275ba901, (q31_t)0x863382cf, (q31_t)0x2755ae64, (q31_t)0x8631945e, - (q31_t)0x274fb3ae, (q31_t)0x862fa638, (q31_t)0x2749b8e0, (q31_t)0x862db85e, (q31_t)0x2743bdf9, (q31_t)0x862bcace, (q31_t)0x273dc2fa, (q31_t)0x8629dd8a, - (q31_t)0x2737c7e3, (q31_t)0x8627f091, (q31_t)0x2731ccb4, (q31_t)0x862603e3, (q31_t)0x272bd16d, (q31_t)0x86241780, (q31_t)0x2725d60e, (q31_t)0x86222b68, - (q31_t)0x271fda96, (q31_t)0x86203f9c, (q31_t)0x2719df06, (q31_t)0x861e541a, (q31_t)0x2713e35f, (q31_t)0x861c68e4, (q31_t)0x270de79f, (q31_t)0x861a7df9, - (q31_t)0x2707ebc7, (q31_t)0x86189359, (q31_t)0x2701efd7, (q31_t)0x8616a905, (q31_t)0x26fbf3ce, (q31_t)0x8614befb, (q31_t)0x26f5f7ae, (q31_t)0x8612d53d, - (q31_t)0x26effb76, (q31_t)0x8610ebca, (q31_t)0x26e9ff26, (q31_t)0x860f02a3, (q31_t)0x26e402bd, (q31_t)0x860d19c6, (q31_t)0x26de063d, (q31_t)0x860b3135, - (q31_t)0x26d809a5, (q31_t)0x860948ef, (q31_t)0x26d20cf5, (q31_t)0x860760f4, (q31_t)0x26cc102d, (q31_t)0x86057944, (q31_t)0x26c6134d, (q31_t)0x860391e0, - (q31_t)0x26c01655, (q31_t)0x8601aac7, (q31_t)0x26ba1945, (q31_t)0x85ffc3f9, (q31_t)0x26b41c1d, (q31_t)0x85fddd76, (q31_t)0x26ae1edd, (q31_t)0x85fbf73f, - (q31_t)0x26a82186, (q31_t)0x85fa1153, (q31_t)0x26a22416, (q31_t)0x85f82bb2, (q31_t)0x269c268f, (q31_t)0x85f6465c, (q31_t)0x269628f0, (q31_t)0x85f46152, - (q31_t)0x26902b39, (q31_t)0x85f27c93, (q31_t)0x268a2d6b, (q31_t)0x85f09820, (q31_t)0x26842f84, (q31_t)0x85eeb3f7, (q31_t)0x267e3186, (q31_t)0x85ecd01a, - (q31_t)0x26783370, (q31_t)0x85eaec88, (q31_t)0x26723543, (q31_t)0x85e90942, (q31_t)0x266c36fe, (q31_t)0x85e72647, (q31_t)0x266638a1, (q31_t)0x85e54397, - (q31_t)0x26603a2c, (q31_t)0x85e36132, (q31_t)0x265a3b9f, (q31_t)0x85e17f19, (q31_t)0x26543cfb, (q31_t)0x85df9d4b, (q31_t)0x264e3e40, (q31_t)0x85ddbbc9, - (q31_t)0x26483f6c, (q31_t)0x85dbda91, (q31_t)0x26424082, (q31_t)0x85d9f9a5, (q31_t)0x263c417f, (q31_t)0x85d81905, (q31_t)0x26364265, (q31_t)0x85d638b0, - (q31_t)0x26304333, (q31_t)0x85d458a6, (q31_t)0x262a43ea, (q31_t)0x85d278e7, (q31_t)0x26244489, (q31_t)0x85d09974, (q31_t)0x261e4511, (q31_t)0x85ceba4d, - (q31_t)0x26184581, (q31_t)0x85ccdb70, (q31_t)0x261245da, (q31_t)0x85cafcdf, (q31_t)0x260c461b, (q31_t)0x85c91e9a, (q31_t)0x26064645, (q31_t)0x85c740a0, - (q31_t)0x26004657, (q31_t)0x85c562f1, (q31_t)0x25fa4652, (q31_t)0x85c3858d, (q31_t)0x25f44635, (q31_t)0x85c1a875, (q31_t)0x25ee4601, (q31_t)0x85bfcba9, - (q31_t)0x25e845b6, (q31_t)0x85bdef28, (q31_t)0x25e24553, (q31_t)0x85bc12f2, (q31_t)0x25dc44d9, (q31_t)0x85ba3707, (q31_t)0x25d64447, (q31_t)0x85b85b68, - (q31_t)0x25d0439f, (q31_t)0x85b68015, (q31_t)0x25ca42de, (q31_t)0x85b4a50d, (q31_t)0x25c44207, (q31_t)0x85b2ca50, (q31_t)0x25be4118, (q31_t)0x85b0efdf, - (q31_t)0x25b84012, (q31_t)0x85af15b9, (q31_t)0x25b23ef5, (q31_t)0x85ad3bdf, (q31_t)0x25ac3dc0, (q31_t)0x85ab6250, (q31_t)0x25a63c74, (q31_t)0x85a9890d, - (q31_t)0x25a03b11, (q31_t)0x85a7b015, (q31_t)0x259a3997, (q31_t)0x85a5d768, (q31_t)0x25943806, (q31_t)0x85a3ff07, (q31_t)0x258e365d, (q31_t)0x85a226f2, - (q31_t)0x2588349d, (q31_t)0x85a04f28, (q31_t)0x258232c6, (q31_t)0x859e77a9, (q31_t)0x257c30d8, (q31_t)0x859ca076, (q31_t)0x25762ed3, (q31_t)0x859ac98f, - (q31_t)0x25702cb7, (q31_t)0x8598f2f3, (q31_t)0x256a2a83, (q31_t)0x85971ca2, (q31_t)0x25642839, (q31_t)0x8595469d, (q31_t)0x255e25d7, (q31_t)0x859370e4, - (q31_t)0x2558235f, (q31_t)0x85919b76, (q31_t)0x255220cf, (q31_t)0x858fc653, (q31_t)0x254c1e28, (q31_t)0x858df17c, (q31_t)0x25461b6b, (q31_t)0x858c1cf1, - (q31_t)0x25401896, (q31_t)0x858a48b1, (q31_t)0x253a15aa, (q31_t)0x858874bd, (q31_t)0x253412a8, (q31_t)0x8586a114, (q31_t)0x252e0f8e, (q31_t)0x8584cdb7, - (q31_t)0x25280c5e, (q31_t)0x8582faa5, (q31_t)0x25220916, (q31_t)0x858127df, (q31_t)0x251c05b8, (q31_t)0x857f5564, (q31_t)0x25160243, (q31_t)0x857d8335, - (q31_t)0x250ffeb7, (q31_t)0x857bb152, (q31_t)0x2509fb14, (q31_t)0x8579dfba, (q31_t)0x2503f75a, (q31_t)0x85780e6e, (q31_t)0x24fdf389, (q31_t)0x85763d6d, - (q31_t)0x24f7efa2, (q31_t)0x85746cb8, (q31_t)0x24f1eba4, (q31_t)0x85729c4e, (q31_t)0x24ebe78f, (q31_t)0x8570cc30, (q31_t)0x24e5e363, (q31_t)0x856efc5e, - (q31_t)0x24dfdf20, (q31_t)0x856d2cd7, (q31_t)0x24d9dac7, (q31_t)0x856b5d9c, (q31_t)0x24d3d657, (q31_t)0x85698ead, (q31_t)0x24cdd1d0, (q31_t)0x8567c009, - (q31_t)0x24c7cd33, (q31_t)0x8565f1b0, (q31_t)0x24c1c87f, (q31_t)0x856423a4, (q31_t)0x24bbc3b4, (q31_t)0x856255e3, (q31_t)0x24b5bed2, (q31_t)0x8560886d, - (q31_t)0x24afb9da, (q31_t)0x855ebb44, (q31_t)0x24a9b4cb, (q31_t)0x855cee66, (q31_t)0x24a3afa6, (q31_t)0x855b21d3, (q31_t)0x249daa6a, (q31_t)0x8559558c, - (q31_t)0x2497a517, (q31_t)0x85578991, (q31_t)0x24919fae, (q31_t)0x8555bde2, (q31_t)0x248b9a2f, (q31_t)0x8553f27e, (q31_t)0x24859498, (q31_t)0x85522766, - (q31_t)0x247f8eec, (q31_t)0x85505c99, (q31_t)0x24798928, (q31_t)0x854e9219, (q31_t)0x2473834f, (q31_t)0x854cc7e3, (q31_t)0x246d7d5e, (q31_t)0x854afdfa, - (q31_t)0x24677758, (q31_t)0x8549345c, (q31_t)0x2461713a, (q31_t)0x85476b0a, (q31_t)0x245b6b07, (q31_t)0x8545a204, (q31_t)0x245564bd, (q31_t)0x8543d949, - (q31_t)0x244f5e5c, (q31_t)0x854210db, (q31_t)0x244957e5, (q31_t)0x854048b7, (q31_t)0x24435158, (q31_t)0x853e80e0, (q31_t)0x243d4ab4, (q31_t)0x853cb954, - (q31_t)0x243743fa, (q31_t)0x853af214, (q31_t)0x24313d2a, (q31_t)0x85392b20, (q31_t)0x242b3644, (q31_t)0x85376477, (q31_t)0x24252f47, (q31_t)0x85359e1a, - (q31_t)0x241f2833, (q31_t)0x8533d809, (q31_t)0x2419210a, (q31_t)0x85321244, (q31_t)0x241319ca, (q31_t)0x85304cca, (q31_t)0x240d1274, (q31_t)0x852e879d, - (q31_t)0x24070b08, (q31_t)0x852cc2bb, (q31_t)0x24010385, (q31_t)0x852afe24, (q31_t)0x23fafbec, (q31_t)0x852939da, (q31_t)0x23f4f43e, (q31_t)0x852775db, - (q31_t)0x23eeec78, (q31_t)0x8525b228, (q31_t)0x23e8e49d, (q31_t)0x8523eec1, (q31_t)0x23e2dcac, (q31_t)0x85222ba5, (q31_t)0x23dcd4a4, (q31_t)0x852068d6, - (q31_t)0x23d6cc87, (q31_t)0x851ea652, (q31_t)0x23d0c453, (q31_t)0x851ce41a, (q31_t)0x23cabc09, (q31_t)0x851b222e, (q31_t)0x23c4b3a9, (q31_t)0x8519608d, - (q31_t)0x23beab33, (q31_t)0x85179f39, (q31_t)0x23b8a2a7, (q31_t)0x8515de30, (q31_t)0x23b29a05, (q31_t)0x85141d73, (q31_t)0x23ac914d, (q31_t)0x85125d02, - (q31_t)0x23a6887f, (q31_t)0x85109cdd, (q31_t)0x23a07f9a, (q31_t)0x850edd03, (q31_t)0x239a76a0, (q31_t)0x850d1d75, (q31_t)0x23946d90, (q31_t)0x850b5e34, - (q31_t)0x238e646a, (q31_t)0x85099f3e, (q31_t)0x23885b2e, (q31_t)0x8507e094, (q31_t)0x238251dd, (q31_t)0x85062235, (q31_t)0x237c4875, (q31_t)0x85046423, - (q31_t)0x23763ef7, (q31_t)0x8502a65c, (q31_t)0x23703564, (q31_t)0x8500e8e2, (q31_t)0x236a2bba, (q31_t)0x84ff2bb3, (q31_t)0x236421fb, (q31_t)0x84fd6ed0, - (q31_t)0x235e1826, (q31_t)0x84fbb239, (q31_t)0x23580e3b, (q31_t)0x84f9f5ee, (q31_t)0x2352043b, (q31_t)0x84f839ee, (q31_t)0x234bfa24, (q31_t)0x84f67e3b, - (q31_t)0x2345eff8, (q31_t)0x84f4c2d4, (q31_t)0x233fe5b6, (q31_t)0x84f307b8, (q31_t)0x2339db5e, (q31_t)0x84f14ce8, (q31_t)0x2333d0f1, (q31_t)0x84ef9265, - (q31_t)0x232dc66d, (q31_t)0x84edd82d, (q31_t)0x2327bbd5, (q31_t)0x84ec1e41, (q31_t)0x2321b126, (q31_t)0x84ea64a1, (q31_t)0x231ba662, (q31_t)0x84e8ab4d, - (q31_t)0x23159b88, (q31_t)0x84e6f244, (q31_t)0x230f9098, (q31_t)0x84e53988, (q31_t)0x23098593, (q31_t)0x84e38118, (q31_t)0x23037a78, (q31_t)0x84e1c8f3, - (q31_t)0x22fd6f48, (q31_t)0x84e0111b, (q31_t)0x22f76402, (q31_t)0x84de598f, (q31_t)0x22f158a7, (q31_t)0x84dca24e, (q31_t)0x22eb4d36, (q31_t)0x84daeb5a, - (q31_t)0x22e541af, (q31_t)0x84d934b1, (q31_t)0x22df3613, (q31_t)0x84d77e54, (q31_t)0x22d92a61, (q31_t)0x84d5c844, (q31_t)0x22d31e9a, (q31_t)0x84d4127f, - (q31_t)0x22cd12bd, (q31_t)0x84d25d06, (q31_t)0x22c706cb, (q31_t)0x84d0a7da, (q31_t)0x22c0fac4, (q31_t)0x84cef2f9, (q31_t)0x22baeea7, (q31_t)0x84cd3e64, - (q31_t)0x22b4e274, (q31_t)0x84cb8a1b, (q31_t)0x22aed62c, (q31_t)0x84c9d61f, (q31_t)0x22a8c9cf, (q31_t)0x84c8226e, (q31_t)0x22a2bd5d, (q31_t)0x84c66f09, - (q31_t)0x229cb0d5, (q31_t)0x84c4bbf0, (q31_t)0x2296a437, (q31_t)0x84c30924, (q31_t)0x22909785, (q31_t)0x84c156a3, (q31_t)0x228a8abd, (q31_t)0x84bfa46e, - (q31_t)0x22847de0, (q31_t)0x84bdf286, (q31_t)0x227e70ed, (q31_t)0x84bc40e9, (q31_t)0x227863e5, (q31_t)0x84ba8f98, (q31_t)0x227256c8, (q31_t)0x84b8de94, - (q31_t)0x226c4996, (q31_t)0x84b72ddb, (q31_t)0x22663c4e, (q31_t)0x84b57d6f, (q31_t)0x22602ef1, (q31_t)0x84b3cd4f, (q31_t)0x225a217f, (q31_t)0x84b21d7a, - (q31_t)0x225413f8, (q31_t)0x84b06df2, (q31_t)0x224e065c, (q31_t)0x84aebeb6, (q31_t)0x2247f8aa, (q31_t)0x84ad0fc6, (q31_t)0x2241eae3, (q31_t)0x84ab6122, - (q31_t)0x223bdd08, (q31_t)0x84a9b2ca, (q31_t)0x2235cf17, (q31_t)0x84a804be, (q31_t)0x222fc111, (q31_t)0x84a656fe, (q31_t)0x2229b2f6, (q31_t)0x84a4a98a, - (q31_t)0x2223a4c5, (q31_t)0x84a2fc62, (q31_t)0x221d9680, (q31_t)0x84a14f87, (q31_t)0x22178826, (q31_t)0x849fa2f7, (q31_t)0x221179b7, (q31_t)0x849df6b4, - (q31_t)0x220b6b32, (q31_t)0x849c4abd, (q31_t)0x22055c99, (q31_t)0x849a9f12, (q31_t)0x21ff4dea, (q31_t)0x8498f3b3, (q31_t)0x21f93f27, (q31_t)0x849748a0, - (q31_t)0x21f3304f, (q31_t)0x84959dd9, (q31_t)0x21ed2162, (q31_t)0x8493f35e, (q31_t)0x21e71260, (q31_t)0x84924930, (q31_t)0x21e10349, (q31_t)0x84909f4e, - (q31_t)0x21daf41d, (q31_t)0x848ef5b7, (q31_t)0x21d4e4dc, (q31_t)0x848d4c6d, (q31_t)0x21ced586, (q31_t)0x848ba36f, (q31_t)0x21c8c61c, (q31_t)0x8489fabe, - (q31_t)0x21c2b69c, (q31_t)0x84885258, (q31_t)0x21bca708, (q31_t)0x8486aa3e, (q31_t)0x21b6975f, (q31_t)0x84850271, (q31_t)0x21b087a1, (q31_t)0x84835af0, - (q31_t)0x21aa77cf, (q31_t)0x8481b3bb, (q31_t)0x21a467e7, (q31_t)0x84800cd2, (q31_t)0x219e57eb, (q31_t)0x847e6636, (q31_t)0x219847da, (q31_t)0x847cbfe5, - (q31_t)0x219237b5, (q31_t)0x847b19e1, (q31_t)0x218c277a, (q31_t)0x84797429, (q31_t)0x2186172b, (q31_t)0x8477cebd, (q31_t)0x218006c8, (q31_t)0x8476299e, - (q31_t)0x2179f64f, (q31_t)0x847484ca, (q31_t)0x2173e5c2, (q31_t)0x8472e043, (q31_t)0x216dd521, (q31_t)0x84713c08, (q31_t)0x2167c46b, (q31_t)0x846f9819, - (q31_t)0x2161b3a0, (q31_t)0x846df477, (q31_t)0x215ba2c0, (q31_t)0x846c5120, (q31_t)0x215591cc, (q31_t)0x846aae16, (q31_t)0x214f80c4, (q31_t)0x84690b58, - (q31_t)0x21496fa7, (q31_t)0x846768e7, (q31_t)0x21435e75, (q31_t)0x8465c6c1, (q31_t)0x213d4d2f, (q31_t)0x846424e8, (q31_t)0x21373bd4, (q31_t)0x8462835b, - (q31_t)0x21312a65, (q31_t)0x8460e21a, (q31_t)0x212b18e1, (q31_t)0x845f4126, (q31_t)0x21250749, (q31_t)0x845da07e, (q31_t)0x211ef59d, (q31_t)0x845c0022, - (q31_t)0x2118e3dc, (q31_t)0x845a6012, (q31_t)0x2112d206, (q31_t)0x8458c04f, (q31_t)0x210cc01d, (q31_t)0x845720d8, (q31_t)0x2106ae1e, (q31_t)0x845581ad, - (q31_t)0x21009c0c, (q31_t)0x8453e2cf, (q31_t)0x20fa89e5, (q31_t)0x8452443d, (q31_t)0x20f477aa, (q31_t)0x8450a5f7, (q31_t)0x20ee655a, (q31_t)0x844f07fd, - (q31_t)0x20e852f6, (q31_t)0x844d6a50, (q31_t)0x20e2407e, (q31_t)0x844bccef, (q31_t)0x20dc2df2, (q31_t)0x844a2fda, (q31_t)0x20d61b51, (q31_t)0x84489311, - (q31_t)0x20d0089c, (q31_t)0x8446f695, (q31_t)0x20c9f5d3, (q31_t)0x84455a66, (q31_t)0x20c3e2f5, (q31_t)0x8443be82, (q31_t)0x20bdd003, (q31_t)0x844222eb, - (q31_t)0x20b7bcfe, (q31_t)0x844087a0, (q31_t)0x20b1a9e4, (q31_t)0x843eeca2, (q31_t)0x20ab96b5, (q31_t)0x843d51f0, (q31_t)0x20a58373, (q31_t)0x843bb78a, - (q31_t)0x209f701c, (q31_t)0x843a1d70, (q31_t)0x20995cb2, (q31_t)0x843883a3, (q31_t)0x20934933, (q31_t)0x8436ea23, (q31_t)0x208d35a0, (q31_t)0x843550ee, - (q31_t)0x208721f9, (q31_t)0x8433b806, (q31_t)0x20810e3e, (q31_t)0x84321f6b, (q31_t)0x207afa6f, (q31_t)0x8430871b, (q31_t)0x2074e68c, (q31_t)0x842eef18, - (q31_t)0x206ed295, (q31_t)0x842d5762, (q31_t)0x2068be8a, (q31_t)0x842bbff8, (q31_t)0x2062aa6b, (q31_t)0x842a28da, (q31_t)0x205c9638, (q31_t)0x84289209, - (q31_t)0x205681f1, (q31_t)0x8426fb84, (q31_t)0x20506d96, (q31_t)0x8425654b, (q31_t)0x204a5927, (q31_t)0x8423cf5f, (q31_t)0x204444a4, (q31_t)0x842239bf, - (q31_t)0x203e300d, (q31_t)0x8420a46c, (q31_t)0x20381b63, (q31_t)0x841f0f65, (q31_t)0x203206a4, (q31_t)0x841d7aaa, (q31_t)0x202bf1d2, (q31_t)0x841be63c, - (q31_t)0x2025dcec, (q31_t)0x841a521a, (q31_t)0x201fc7f2, (q31_t)0x8418be45, (q31_t)0x2019b2e4, (q31_t)0x84172abc, (q31_t)0x20139dc2, (q31_t)0x84159780, - (q31_t)0x200d888d, (q31_t)0x84140490, (q31_t)0x20077344, (q31_t)0x841271ec, (q31_t)0x20015de7, (q31_t)0x8410df95, (q31_t)0x1ffb4876, (q31_t)0x840f4d8a, - (q31_t)0x1ff532f2, (q31_t)0x840dbbcc, (q31_t)0x1fef1d59, (q31_t)0x840c2a5a, (q31_t)0x1fe907ae, (q31_t)0x840a9935, (q31_t)0x1fe2f1ee, (q31_t)0x8409085c, - (q31_t)0x1fdcdc1b, (q31_t)0x840777d0, (q31_t)0x1fd6c634, (q31_t)0x8405e790, (q31_t)0x1fd0b03a, (q31_t)0x8404579d, (q31_t)0x1fca9a2b, (q31_t)0x8402c7f6, - (q31_t)0x1fc4840a, (q31_t)0x8401389b, (q31_t)0x1fbe6dd4, (q31_t)0x83ffa98d, (q31_t)0x1fb8578b, (q31_t)0x83fe1acc, (q31_t)0x1fb2412f, (q31_t)0x83fc8c57, - (q31_t)0x1fac2abf, (q31_t)0x83fafe2e, (q31_t)0x1fa6143b, (q31_t)0x83f97052, (q31_t)0x1f9ffda4, (q31_t)0x83f7e2c3, (q31_t)0x1f99e6fa, (q31_t)0x83f65580, - (q31_t)0x1f93d03c, (q31_t)0x83f4c889, (q31_t)0x1f8db96a, (q31_t)0x83f33bdf, (q31_t)0x1f87a285, (q31_t)0x83f1af82, (q31_t)0x1f818b8d, (q31_t)0x83f02371, - (q31_t)0x1f7b7481, (q31_t)0x83ee97ad, (q31_t)0x1f755d61, (q31_t)0x83ed0c35, (q31_t)0x1f6f462f, (q31_t)0x83eb810a, (q31_t)0x1f692ee9, (q31_t)0x83e9f62b, - (q31_t)0x1f63178f, (q31_t)0x83e86b99, (q31_t)0x1f5d0022, (q31_t)0x83e6e153, (q31_t)0x1f56e8a2, (q31_t)0x83e5575a, (q31_t)0x1f50d10e, (q31_t)0x83e3cdad, - (q31_t)0x1f4ab968, (q31_t)0x83e2444d, (q31_t)0x1f44a1ad, (q31_t)0x83e0bb3a, (q31_t)0x1f3e89e0, (q31_t)0x83df3273, (q31_t)0x1f3871ff, (q31_t)0x83dda9f9, - (q31_t)0x1f325a0b, (q31_t)0x83dc21cb, (q31_t)0x1f2c4204, (q31_t)0x83da99ea, (q31_t)0x1f2629ea, (q31_t)0x83d91255, (q31_t)0x1f2011bc, (q31_t)0x83d78b0d, - (q31_t)0x1f19f97b, (q31_t)0x83d60412, (q31_t)0x1f13e127, (q31_t)0x83d47d63, (q31_t)0x1f0dc8c0, (q31_t)0x83d2f701, (q31_t)0x1f07b045, (q31_t)0x83d170eb, - (q31_t)0x1f0197b8, (q31_t)0x83cfeb22, (q31_t)0x1efb7f17, (q31_t)0x83ce65a6, (q31_t)0x1ef56664, (q31_t)0x83cce076, (q31_t)0x1eef4d9d, (q31_t)0x83cb5b93, - (q31_t)0x1ee934c3, (q31_t)0x83c9d6fc, (q31_t)0x1ee31bd6, (q31_t)0x83c852b2, (q31_t)0x1edd02d6, (q31_t)0x83c6ceb5, (q31_t)0x1ed6e9c3, (q31_t)0x83c54b04, - (q31_t)0x1ed0d09d, (q31_t)0x83c3c7a0, (q31_t)0x1ecab763, (q31_t)0x83c24488, (q31_t)0x1ec49e17, (q31_t)0x83c0c1be, (q31_t)0x1ebe84b8, (q31_t)0x83bf3f3f, - (q31_t)0x1eb86b46, (q31_t)0x83bdbd0e, (q31_t)0x1eb251c1, (q31_t)0x83bc3b29, (q31_t)0x1eac3829, (q31_t)0x83bab991, (q31_t)0x1ea61e7e, (q31_t)0x83b93845, - (q31_t)0x1ea004c1, (q31_t)0x83b7b746, (q31_t)0x1e99eaf0, (q31_t)0x83b63694, (q31_t)0x1e93d10c, (q31_t)0x83b4b62e, (q31_t)0x1e8db716, (q31_t)0x83b33616, - (q31_t)0x1e879d0d, (q31_t)0x83b1b649, (q31_t)0x1e8182f1, (q31_t)0x83b036ca, (q31_t)0x1e7b68c2, (q31_t)0x83aeb797, (q31_t)0x1e754e80, (q31_t)0x83ad38b1, - (q31_t)0x1e6f342c, (q31_t)0x83abba17, (q31_t)0x1e6919c4, (q31_t)0x83aa3bca, (q31_t)0x1e62ff4a, (q31_t)0x83a8bdca, (q31_t)0x1e5ce4be, (q31_t)0x83a74017, - (q31_t)0x1e56ca1e, (q31_t)0x83a5c2b0, (q31_t)0x1e50af6c, (q31_t)0x83a44596, (q31_t)0x1e4a94a7, (q31_t)0x83a2c8c9, (q31_t)0x1e4479cf, (q31_t)0x83a14c48, - (q31_t)0x1e3e5ee5, (q31_t)0x839fd014, (q31_t)0x1e3843e8, (q31_t)0x839e542d, (q31_t)0x1e3228d9, (q31_t)0x839cd893, (q31_t)0x1e2c0db6, (q31_t)0x839b5d45, - (q31_t)0x1e25f282, (q31_t)0x8399e244, (q31_t)0x1e1fd73a, (q31_t)0x83986790, (q31_t)0x1e19bbe0, (q31_t)0x8396ed29, (q31_t)0x1e13a074, (q31_t)0x8395730e, - (q31_t)0x1e0d84f5, (q31_t)0x8393f940, (q31_t)0x1e076963, (q31_t)0x83927fbf, (q31_t)0x1e014dbf, (q31_t)0x8391068a, (q31_t)0x1dfb3208, (q31_t)0x838f8da2, - (q31_t)0x1df5163f, (q31_t)0x838e1507, (q31_t)0x1deefa63, (q31_t)0x838c9cb9, (q31_t)0x1de8de75, (q31_t)0x838b24b8, (q31_t)0x1de2c275, (q31_t)0x8389ad03, - (q31_t)0x1ddca662, (q31_t)0x8388359b, (q31_t)0x1dd68a3c, (q31_t)0x8386be80, (q31_t)0x1dd06e04, (q31_t)0x838547b2, (q31_t)0x1dca51ba, (q31_t)0x8383d130, - (q31_t)0x1dc4355e, (q31_t)0x83825afb, (q31_t)0x1dbe18ef, (q31_t)0x8380e513, (q31_t)0x1db7fc6d, (q31_t)0x837f6f78, (q31_t)0x1db1dfda, (q31_t)0x837dfa2a, - (q31_t)0x1dabc334, (q31_t)0x837c8528, (q31_t)0x1da5a67c, (q31_t)0x837b1074, (q31_t)0x1d9f89b1, (q31_t)0x83799c0c, (q31_t)0x1d996cd4, (q31_t)0x837827f0, - (q31_t)0x1d934fe5, (q31_t)0x8376b422, (q31_t)0x1d8d32e4, (q31_t)0x837540a1, (q31_t)0x1d8715d0, (q31_t)0x8373cd6c, (q31_t)0x1d80f8ab, (q31_t)0x83725a84, - (q31_t)0x1d7adb73, (q31_t)0x8370e7e9, (q31_t)0x1d74be29, (q31_t)0x836f759b, (q31_t)0x1d6ea0cc, (q31_t)0x836e039a, (q31_t)0x1d68835e, (q31_t)0x836c91e5, - (q31_t)0x1d6265dd, (q31_t)0x836b207d, (q31_t)0x1d5c484b, (q31_t)0x8369af63, (q31_t)0x1d562aa6, (q31_t)0x83683e95, (q31_t)0x1d500cef, (q31_t)0x8366ce14, - (q31_t)0x1d49ef26, (q31_t)0x83655ddf, (q31_t)0x1d43d14b, (q31_t)0x8363edf8, (q31_t)0x1d3db35e, (q31_t)0x83627e5d, (q31_t)0x1d37955e, (q31_t)0x83610f10, - (q31_t)0x1d31774d, (q31_t)0x835fa00f, (q31_t)0x1d2b592a, (q31_t)0x835e315b, (q31_t)0x1d253af5, (q31_t)0x835cc2f4, (q31_t)0x1d1f1cae, (q31_t)0x835b54da, - (q31_t)0x1d18fe54, (q31_t)0x8359e70d, (q31_t)0x1d12dfe9, (q31_t)0x8358798c, (q31_t)0x1d0cc16c, (q31_t)0x83570c59, (q31_t)0x1d06a2dd, (q31_t)0x83559f72, - (q31_t)0x1d00843d, (q31_t)0x835432d8, (q31_t)0x1cfa658a, (q31_t)0x8352c68c, (q31_t)0x1cf446c5, (q31_t)0x83515a8c, (q31_t)0x1cee27ef, (q31_t)0x834feed9, - (q31_t)0x1ce80906, (q31_t)0x834e8373, (q31_t)0x1ce1ea0c, (q31_t)0x834d185a, (q31_t)0x1cdbcb00, (q31_t)0x834bad8e, (q31_t)0x1cd5abe3, (q31_t)0x834a430e, - (q31_t)0x1ccf8cb3, (q31_t)0x8348d8dc, (q31_t)0x1cc96d72, (q31_t)0x83476ef6, (q31_t)0x1cc34e1f, (q31_t)0x8346055e, (q31_t)0x1cbd2eba, (q31_t)0x83449c12, - (q31_t)0x1cb70f43, (q31_t)0x83433314, (q31_t)0x1cb0efbb, (q31_t)0x8341ca62, (q31_t)0x1caad021, (q31_t)0x834061fd, (q31_t)0x1ca4b075, (q31_t)0x833ef9e6, - (q31_t)0x1c9e90b8, (q31_t)0x833d921b, (q31_t)0x1c9870e9, (q31_t)0x833c2a9d, (q31_t)0x1c925109, (q31_t)0x833ac36c, (q31_t)0x1c8c3116, (q31_t)0x83395c88, - (q31_t)0x1c861113, (q31_t)0x8337f5f1, (q31_t)0x1c7ff0fd, (q31_t)0x83368fa7, (q31_t)0x1c79d0d6, (q31_t)0x833529aa, (q31_t)0x1c73b09d, (q31_t)0x8333c3fa, - (q31_t)0x1c6d9053, (q31_t)0x83325e97, (q31_t)0x1c676ff8, (q31_t)0x8330f981, (q31_t)0x1c614f8b, (q31_t)0x832f94b8, (q31_t)0x1c5b2f0c, (q31_t)0x832e303c, - (q31_t)0x1c550e7c, (q31_t)0x832ccc0d, (q31_t)0x1c4eedda, (q31_t)0x832b682b, (q31_t)0x1c48cd27, (q31_t)0x832a0496, (q31_t)0x1c42ac62, (q31_t)0x8328a14d, - (q31_t)0x1c3c8b8c, (q31_t)0x83273e52, (q31_t)0x1c366aa5, (q31_t)0x8325dba4, (q31_t)0x1c3049ac, (q31_t)0x83247943, (q31_t)0x1c2a28a2, (q31_t)0x8323172f, - (q31_t)0x1c240786, (q31_t)0x8321b568, (q31_t)0x1c1de659, (q31_t)0x832053ee, (q31_t)0x1c17c51b, (q31_t)0x831ef2c1, (q31_t)0x1c11a3cb, (q31_t)0x831d91e1, - (q31_t)0x1c0b826a, (q31_t)0x831c314e, (q31_t)0x1c0560f8, (q31_t)0x831ad109, (q31_t)0x1bff3f75, (q31_t)0x83197110, (q31_t)0x1bf91de0, (q31_t)0x83181164, - (q31_t)0x1bf2fc3a, (q31_t)0x8316b205, (q31_t)0x1becda83, (q31_t)0x831552f4, (q31_t)0x1be6b8ba, (q31_t)0x8313f42f, (q31_t)0x1be096e0, (q31_t)0x831295b7, - (q31_t)0x1bda74f6, (q31_t)0x8311378d, (q31_t)0x1bd452f9, (q31_t)0x830fd9af, (q31_t)0x1bce30ec, (q31_t)0x830e7c1f, (q31_t)0x1bc80ece, (q31_t)0x830d1edc, - (q31_t)0x1bc1ec9e, (q31_t)0x830bc1e6, (q31_t)0x1bbbca5e, (q31_t)0x830a653c, (q31_t)0x1bb5a80c, (q31_t)0x830908e0, (q31_t)0x1baf85a9, (q31_t)0x8307acd1, - (q31_t)0x1ba96335, (q31_t)0x83065110, (q31_t)0x1ba340b0, (q31_t)0x8304f59b, (q31_t)0x1b9d1e1a, (q31_t)0x83039a73, (q31_t)0x1b96fb73, (q31_t)0x83023f98, - (q31_t)0x1b90d8bb, (q31_t)0x8300e50b, (q31_t)0x1b8ab5f2, (q31_t)0x82ff8acb, (q31_t)0x1b849317, (q31_t)0x82fe30d7, (q31_t)0x1b7e702c, (q31_t)0x82fcd731, - (q31_t)0x1b784d30, (q31_t)0x82fb7dd8, (q31_t)0x1b722a23, (q31_t)0x82fa24cc, (q31_t)0x1b6c0705, (q31_t)0x82f8cc0d, (q31_t)0x1b65e3d7, (q31_t)0x82f7739c, - (q31_t)0x1b5fc097, (q31_t)0x82f61b77, (q31_t)0x1b599d46, (q31_t)0x82f4c3a0, (q31_t)0x1b5379e5, (q31_t)0x82f36c15, (q31_t)0x1b4d5672, (q31_t)0x82f214d8, - (q31_t)0x1b4732ef, (q31_t)0x82f0bde8, (q31_t)0x1b410f5b, (q31_t)0x82ef6745, (q31_t)0x1b3aebb6, (q31_t)0x82ee10ef, (q31_t)0x1b34c801, (q31_t)0x82ecbae7, - (q31_t)0x1b2ea43a, (q31_t)0x82eb652b, (q31_t)0x1b288063, (q31_t)0x82ea0fbd, (q31_t)0x1b225c7b, (q31_t)0x82e8ba9c, (q31_t)0x1b1c3883, (q31_t)0x82e765c8, - (q31_t)0x1b161479, (q31_t)0x82e61141, (q31_t)0x1b0ff05f, (q31_t)0x82e4bd07, (q31_t)0x1b09cc34, (q31_t)0x82e3691b, (q31_t)0x1b03a7f9, (q31_t)0x82e2157c, - (q31_t)0x1afd83ad, (q31_t)0x82e0c22a, (q31_t)0x1af75f50, (q31_t)0x82df6f25, (q31_t)0x1af13ae3, (q31_t)0x82de1c6d, (q31_t)0x1aeb1665, (q31_t)0x82dcca02, - (q31_t)0x1ae4f1d6, (q31_t)0x82db77e5, (q31_t)0x1adecd37, (q31_t)0x82da2615, (q31_t)0x1ad8a887, (q31_t)0x82d8d492, (q31_t)0x1ad283c7, (q31_t)0x82d7835c, - (q31_t)0x1acc5ef6, (q31_t)0x82d63274, (q31_t)0x1ac63a14, (q31_t)0x82d4e1d8, (q31_t)0x1ac01522, (q31_t)0x82d3918a, (q31_t)0x1ab9f020, (q31_t)0x82d24189, - (q31_t)0x1ab3cb0d, (q31_t)0x82d0f1d5, (q31_t)0x1aada5e9, (q31_t)0x82cfa26f, (q31_t)0x1aa780b6, (q31_t)0x82ce5356, (q31_t)0x1aa15b71, (q31_t)0x82cd048a, - (q31_t)0x1a9b361d, (q31_t)0x82cbb60b, (q31_t)0x1a9510b7, (q31_t)0x82ca67d9, (q31_t)0x1a8eeb42, (q31_t)0x82c919f5, (q31_t)0x1a88c5bc, (q31_t)0x82c7cc5e, - (q31_t)0x1a82a026, (q31_t)0x82c67f14, (q31_t)0x1a7c7a7f, (q31_t)0x82c53217, (q31_t)0x1a7654c8, (q31_t)0x82c3e568, (q31_t)0x1a702f01, (q31_t)0x82c29906, - (q31_t)0x1a6a0929, (q31_t)0x82c14cf1, (q31_t)0x1a63e341, (q31_t)0x82c00129, (q31_t)0x1a5dbd49, (q31_t)0x82beb5af, (q31_t)0x1a579741, (q31_t)0x82bd6a82, - (q31_t)0x1a517128, (q31_t)0x82bc1fa2, (q31_t)0x1a4b4aff, (q31_t)0x82bad50f, (q31_t)0x1a4524c6, (q31_t)0x82b98aca, (q31_t)0x1a3efe7c, (q31_t)0x82b840d2, - (q31_t)0x1a38d823, (q31_t)0x82b6f727, (q31_t)0x1a32b1b9, (q31_t)0x82b5adca, (q31_t)0x1a2c8b3f, (q31_t)0x82b464ba, (q31_t)0x1a2664b5, (q31_t)0x82b31bf7, - (q31_t)0x1a203e1b, (q31_t)0x82b1d381, (q31_t)0x1a1a1771, (q31_t)0x82b08b59, (q31_t)0x1a13f0b6, (q31_t)0x82af437e, (q31_t)0x1a0dc9ec, (q31_t)0x82adfbf0, - (q31_t)0x1a07a311, (q31_t)0x82acb4b0, (q31_t)0x1a017c27, (q31_t)0x82ab6dbd, (q31_t)0x19fb552c, (q31_t)0x82aa2717, (q31_t)0x19f52e22, (q31_t)0x82a8e0bf, - (q31_t)0x19ef0707, (q31_t)0x82a79ab3, (q31_t)0x19e8dfdc, (q31_t)0x82a654f6, (q31_t)0x19e2b8a2, (q31_t)0x82a50f85, (q31_t)0x19dc9157, (q31_t)0x82a3ca62, - (q31_t)0x19d669fc, (q31_t)0x82a2858c, (q31_t)0x19d04292, (q31_t)0x82a14104, (q31_t)0x19ca1b17, (q31_t)0x829ffcc8, (q31_t)0x19c3f38d, (q31_t)0x829eb8db, - (q31_t)0x19bdcbf3, (q31_t)0x829d753a, (q31_t)0x19b7a449, (q31_t)0x829c31e7, (q31_t)0x19b17c8f, (q31_t)0x829aeee1, (q31_t)0x19ab54c5, (q31_t)0x8299ac29, - (q31_t)0x19a52ceb, (q31_t)0x829869be, (q31_t)0x199f0502, (q31_t)0x829727a0, (q31_t)0x1998dd09, (q31_t)0x8295e5cf, (q31_t)0x1992b4ff, (q31_t)0x8294a44c, - (q31_t)0x198c8ce7, (q31_t)0x82936317, (q31_t)0x198664be, (q31_t)0x8292222e, (q31_t)0x19803c86, (q31_t)0x8290e194, (q31_t)0x197a143e, (q31_t)0x828fa146, - (q31_t)0x1973ebe6, (q31_t)0x828e6146, (q31_t)0x196dc37e, (q31_t)0x828d2193, (q31_t)0x19679b07, (q31_t)0x828be22e, (q31_t)0x19617280, (q31_t)0x828aa316, - (q31_t)0x195b49ea, (q31_t)0x8289644b, (q31_t)0x19552144, (q31_t)0x828825ce, (q31_t)0x194ef88e, (q31_t)0x8286e79e, (q31_t)0x1948cfc8, (q31_t)0x8285a9bb, - (q31_t)0x1942a6f3, (q31_t)0x82846c26, (q31_t)0x193c7e0f, (q31_t)0x82832edf, (q31_t)0x1936551b, (q31_t)0x8281f1e4, (q31_t)0x19302c17, (q31_t)0x8280b538, - (q31_t)0x192a0304, (q31_t)0x827f78d8, (q31_t)0x1923d9e1, (q31_t)0x827e3cc6, (q31_t)0x191db0af, (q31_t)0x827d0102, (q31_t)0x1917876d, (q31_t)0x827bc58a, - (q31_t)0x19115e1c, (q31_t)0x827a8a61, (q31_t)0x190b34bb, (q31_t)0x82794f84, (q31_t)0x19050b4b, (q31_t)0x827814f6, (q31_t)0x18fee1cb, (q31_t)0x8276dab4, - (q31_t)0x18f8b83c, (q31_t)0x8275a0c0, (q31_t)0x18f28e9e, (q31_t)0x8274671a, (q31_t)0x18ec64f0, (q31_t)0x82732dc0, (q31_t)0x18e63b33, (q31_t)0x8271f4b5, - (q31_t)0x18e01167, (q31_t)0x8270bbf7, (q31_t)0x18d9e78b, (q31_t)0x826f8386, (q31_t)0x18d3bda0, (q31_t)0x826e4b62, (q31_t)0x18cd93a5, (q31_t)0x826d138d, - (q31_t)0x18c7699b, (q31_t)0x826bdc04, (q31_t)0x18c13f82, (q31_t)0x826aa4c9, (q31_t)0x18bb155a, (q31_t)0x82696ddc, (q31_t)0x18b4eb22, (q31_t)0x8268373c, - (q31_t)0x18aec0db, (q31_t)0x826700e9, (q31_t)0x18a89685, (q31_t)0x8265cae4, (q31_t)0x18a26c20, (q31_t)0x8264952d, (q31_t)0x189c41ab, (q31_t)0x82635fc2, - (q31_t)0x18961728, (q31_t)0x82622aa6, (q31_t)0x188fec95, (q31_t)0x8260f5d7, (q31_t)0x1889c1f3, (q31_t)0x825fc155, (q31_t)0x18839742, (q31_t)0x825e8d21, - (q31_t)0x187d6c82, (q31_t)0x825d593a, (q31_t)0x187741b2, (q31_t)0x825c25a1, (q31_t)0x187116d4, (q31_t)0x825af255, (q31_t)0x186aebe6, (q31_t)0x8259bf57, - (q31_t)0x1864c0ea, (q31_t)0x82588ca7, (q31_t)0x185e95de, (q31_t)0x82575a44, (q31_t)0x18586ac3, (q31_t)0x8256282e, (q31_t)0x18523f9a, (q31_t)0x8254f666, - (q31_t)0x184c1461, (q31_t)0x8253c4eb, (q31_t)0x1845e919, (q31_t)0x825293be, (q31_t)0x183fbdc3, (q31_t)0x825162df, (q31_t)0x1839925d, (q31_t)0x8250324d, - (q31_t)0x183366e9, (q31_t)0x824f0208, (q31_t)0x182d3b65, (q31_t)0x824dd211, (q31_t)0x18270fd3, (q31_t)0x824ca268, (q31_t)0x1820e431, (q31_t)0x824b730c, - (q31_t)0x181ab881, (q31_t)0x824a43fe, (q31_t)0x18148cc2, (q31_t)0x8249153d, (q31_t)0x180e60f4, (q31_t)0x8247e6ca, (q31_t)0x18083518, (q31_t)0x8246b8a4, - (q31_t)0x1802092c, (q31_t)0x82458acc, (q31_t)0x17fbdd32, (q31_t)0x82445d41, (q31_t)0x17f5b129, (q31_t)0x82433004, (q31_t)0x17ef8511, (q31_t)0x82420315, - (q31_t)0x17e958ea, (q31_t)0x8240d673, (q31_t)0x17e32cb5, (q31_t)0x823faa1e, (q31_t)0x17dd0070, (q31_t)0x823e7e18, (q31_t)0x17d6d41d, (q31_t)0x823d525e, - (q31_t)0x17d0a7bc, (q31_t)0x823c26f3, (q31_t)0x17ca7b4c, (q31_t)0x823afbd5, (q31_t)0x17c44ecd, (q31_t)0x8239d104, (q31_t)0x17be223f, (q31_t)0x8238a681, - (q31_t)0x17b7f5a3, (q31_t)0x82377c4c, (q31_t)0x17b1c8f8, (q31_t)0x82365264, (q31_t)0x17ab9c3e, (q31_t)0x823528ca, (q31_t)0x17a56f76, (q31_t)0x8233ff7e, - (q31_t)0x179f429f, (q31_t)0x8232d67f, (q31_t)0x179915ba, (q31_t)0x8231adce, (q31_t)0x1792e8c6, (q31_t)0x8230856a, (q31_t)0x178cbbc4, (q31_t)0x822f5d54, - (q31_t)0x17868eb3, (q31_t)0x822e358b, (q31_t)0x17806194, (q31_t)0x822d0e10, (q31_t)0x177a3466, (q31_t)0x822be6e3, (q31_t)0x17740729, (q31_t)0x822ac004, - (q31_t)0x176dd9de, (q31_t)0x82299971, (q31_t)0x1767ac85, (q31_t)0x8228732d, (q31_t)0x17617f1d, (q31_t)0x82274d36, (q31_t)0x175b51a7, (q31_t)0x8226278d, - (q31_t)0x17552422, (q31_t)0x82250232, (q31_t)0x174ef68f, (q31_t)0x8223dd24, (q31_t)0x1748c8ee, (q31_t)0x8222b863, (q31_t)0x17429b3e, (q31_t)0x822193f1, - (q31_t)0x173c6d80, (q31_t)0x82206fcc, (q31_t)0x17363fb4, (q31_t)0x821f4bf5, (q31_t)0x173011d9, (q31_t)0x821e286b, (q31_t)0x1729e3f0, (q31_t)0x821d052f, - (q31_t)0x1723b5f9, (q31_t)0x821be240, (q31_t)0x171d87f3, (q31_t)0x821abfa0, (q31_t)0x171759df, (q31_t)0x82199d4d, (q31_t)0x17112bbd, (q31_t)0x82187b47, - (q31_t)0x170afd8d, (q31_t)0x82175990, (q31_t)0x1704cf4f, (q31_t)0x82163826, (q31_t)0x16fea102, (q31_t)0x82151709, (q31_t)0x16f872a7, (q31_t)0x8213f63a, - (q31_t)0x16f2443e, (q31_t)0x8212d5b9, (q31_t)0x16ec15c7, (q31_t)0x8211b586, (q31_t)0x16e5e741, (q31_t)0x821095a0, (q31_t)0x16dfb8ae, (q31_t)0x820f7608, - (q31_t)0x16d98a0c, (q31_t)0x820e56be, (q31_t)0x16d35b5c, (q31_t)0x820d37c1, (q31_t)0x16cd2c9f, (q31_t)0x820c1912, (q31_t)0x16c6fdd3, (q31_t)0x820afab1, - (q31_t)0x16c0cef9, (q31_t)0x8209dc9e, (q31_t)0x16baa011, (q31_t)0x8208bed8, (q31_t)0x16b4711b, (q31_t)0x8207a160, (q31_t)0x16ae4217, (q31_t)0x82068435, - (q31_t)0x16a81305, (q31_t)0x82056758, (q31_t)0x16a1e3e5, (q31_t)0x82044ac9, (q31_t)0x169bb4b7, (q31_t)0x82032e88, (q31_t)0x1695857b, (q31_t)0x82021294, - (q31_t)0x168f5632, (q31_t)0x8200f6ef, (q31_t)0x168926da, (q31_t)0x81ffdb96, (q31_t)0x1682f774, (q31_t)0x81fec08c, (q31_t)0x167cc801, (q31_t)0x81fda5cf, - (q31_t)0x1676987f, (q31_t)0x81fc8b60, (q31_t)0x167068f0, (q31_t)0x81fb713f, (q31_t)0x166a3953, (q31_t)0x81fa576c, (q31_t)0x166409a8, (q31_t)0x81f93de6, - (q31_t)0x165dd9f0, (q31_t)0x81f824ae, (q31_t)0x1657aa29, (q31_t)0x81f70bc3, (q31_t)0x16517a55, (q31_t)0x81f5f327, (q31_t)0x164b4a73, (q31_t)0x81f4dad8, - (q31_t)0x16451a83, (q31_t)0x81f3c2d7, (q31_t)0x163eea86, (q31_t)0x81f2ab24, (q31_t)0x1638ba7a, (q31_t)0x81f193be, (q31_t)0x16328a61, (q31_t)0x81f07ca6, - (q31_t)0x162c5a3b, (q31_t)0x81ef65dc, (q31_t)0x16262a06, (q31_t)0x81ee4f60, (q31_t)0x161ff9c4, (q31_t)0x81ed3932, (q31_t)0x1619c975, (q31_t)0x81ec2351, - (q31_t)0x16139918, (q31_t)0x81eb0dbe, (q31_t)0x160d68ad, (q31_t)0x81e9f879, (q31_t)0x16073834, (q31_t)0x81e8e381, (q31_t)0x160107ae, (q31_t)0x81e7ced8, - (q31_t)0x15fad71b, (q31_t)0x81e6ba7c, (q31_t)0x15f4a679, (q31_t)0x81e5a66e, (q31_t)0x15ee75cb, (q31_t)0x81e492ad, (q31_t)0x15e8450e, (q31_t)0x81e37f3b, - (q31_t)0x15e21445, (q31_t)0x81e26c16, (q31_t)0x15dbe36d, (q31_t)0x81e1593f, (q31_t)0x15d5b288, (q31_t)0x81e046b6, (q31_t)0x15cf8196, (q31_t)0x81df347b, - (q31_t)0x15c95097, (q31_t)0x81de228d, (q31_t)0x15c31f89, (q31_t)0x81dd10ee, (q31_t)0x15bcee6f, (q31_t)0x81dbff9c, (q31_t)0x15b6bd47, (q31_t)0x81daee98, - (q31_t)0x15b08c12, (q31_t)0x81d9dde1, (q31_t)0x15aa5acf, (q31_t)0x81d8cd79, (q31_t)0x15a4297f, (q31_t)0x81d7bd5e, (q31_t)0x159df821, (q31_t)0x81d6ad92, - (q31_t)0x1597c6b7, (q31_t)0x81d59e13, (q31_t)0x1591953e, (q31_t)0x81d48ee1, (q31_t)0x158b63b9, (q31_t)0x81d37ffe, (q31_t)0x15853226, (q31_t)0x81d27169, - (q31_t)0x157f0086, (q31_t)0x81d16321, (q31_t)0x1578ced9, (q31_t)0x81d05527, (q31_t)0x15729d1f, (q31_t)0x81cf477b, (q31_t)0x156c6b57, (q31_t)0x81ce3a1d, - (q31_t)0x15663982, (q31_t)0x81cd2d0c, (q31_t)0x156007a0, (q31_t)0x81cc204a, (q31_t)0x1559d5b1, (q31_t)0x81cb13d5, (q31_t)0x1553a3b4, (q31_t)0x81ca07af, - (q31_t)0x154d71aa, (q31_t)0x81c8fbd6, (q31_t)0x15473f94, (q31_t)0x81c7f04b, (q31_t)0x15410d70, (q31_t)0x81c6e50d, (q31_t)0x153adb3f, (q31_t)0x81c5da1e, - (q31_t)0x1534a901, (q31_t)0x81c4cf7d, (q31_t)0x152e76b5, (q31_t)0x81c3c529, (q31_t)0x1528445d, (q31_t)0x81c2bb23, (q31_t)0x152211f8, (q31_t)0x81c1b16b, - (q31_t)0x151bdf86, (q31_t)0x81c0a801, (q31_t)0x1515ad06, (q31_t)0x81bf9ee5, (q31_t)0x150f7a7a, (q31_t)0x81be9617, (q31_t)0x150947e1, (q31_t)0x81bd8d97, - (q31_t)0x1503153a, (q31_t)0x81bc8564, (q31_t)0x14fce287, (q31_t)0x81bb7d7f, (q31_t)0x14f6afc7, (q31_t)0x81ba75e9, (q31_t)0x14f07cf9, (q31_t)0x81b96ea0, - (q31_t)0x14ea4a1f, (q31_t)0x81b867a5, (q31_t)0x14e41738, (q31_t)0x81b760f8, (q31_t)0x14dde445, (q31_t)0x81b65a99, (q31_t)0x14d7b144, (q31_t)0x81b55488, - (q31_t)0x14d17e36, (q31_t)0x81b44ec4, (q31_t)0x14cb4b1c, (q31_t)0x81b3494f, (q31_t)0x14c517f4, (q31_t)0x81b24427, (q31_t)0x14bee4c0, (q31_t)0x81b13f4e, - (q31_t)0x14b8b17f, (q31_t)0x81b03ac2, (q31_t)0x14b27e32, (q31_t)0x81af3684, (q31_t)0x14ac4ad7, (q31_t)0x81ae3294, (q31_t)0x14a61770, (q31_t)0x81ad2ef2, - (q31_t)0x149fe3fc, (q31_t)0x81ac2b9e, (q31_t)0x1499b07c, (q31_t)0x81ab2898, (q31_t)0x14937cee, (q31_t)0x81aa25e0, (q31_t)0x148d4954, (q31_t)0x81a92376, - (q31_t)0x148715ae, (q31_t)0x81a82159, (q31_t)0x1480e1fa, (q31_t)0x81a71f8b, (q31_t)0x147aae3a, (q31_t)0x81a61e0b, (q31_t)0x14747a6d, (q31_t)0x81a51cd8, - (q31_t)0x146e4694, (q31_t)0x81a41bf4, (q31_t)0x146812ae, (q31_t)0x81a31b5d, (q31_t)0x1461debc, (q31_t)0x81a21b14, (q31_t)0x145baabd, (q31_t)0x81a11b1a, - (q31_t)0x145576b1, (q31_t)0x81a01b6d, (q31_t)0x144f4299, (q31_t)0x819f1c0e, (q31_t)0x14490e74, (q31_t)0x819e1cfd, (q31_t)0x1442da43, (q31_t)0x819d1e3a, - (q31_t)0x143ca605, (q31_t)0x819c1fc5, (q31_t)0x143671bb, (q31_t)0x819b219e, (q31_t)0x14303d65, (q31_t)0x819a23c5, (q31_t)0x142a0902, (q31_t)0x8199263a, - (q31_t)0x1423d492, (q31_t)0x819828fd, (q31_t)0x141da016, (q31_t)0x81972c0e, (q31_t)0x14176b8e, (q31_t)0x81962f6d, (q31_t)0x141136f9, (q31_t)0x8195331a, - (q31_t)0x140b0258, (q31_t)0x81943715, (q31_t)0x1404cdaa, (q31_t)0x81933b5e, (q31_t)0x13fe98f1, (q31_t)0x81923ff4, (q31_t)0x13f8642a, (q31_t)0x819144d9, - (q31_t)0x13f22f58, (q31_t)0x81904a0c, (q31_t)0x13ebfa79, (q31_t)0x818f4f8d, (q31_t)0x13e5c58e, (q31_t)0x818e555c, (q31_t)0x13df9097, (q31_t)0x818d5b78, - (q31_t)0x13d95b93, (q31_t)0x818c61e3, (q31_t)0x13d32683, (q31_t)0x818b689c, (q31_t)0x13ccf167, (q31_t)0x818a6fa3, (q31_t)0x13c6bc3f, (q31_t)0x818976f8, - (q31_t)0x13c0870a, (q31_t)0x81887e9a, (q31_t)0x13ba51ca, (q31_t)0x8187868b, (q31_t)0x13b41c7d, (q31_t)0x81868eca, (q31_t)0x13ade724, (q31_t)0x81859757, - (q31_t)0x13a7b1bf, (q31_t)0x8184a032, (q31_t)0x13a17c4d, (q31_t)0x8183a95b, (q31_t)0x139b46d0, (q31_t)0x8182b2d1, (q31_t)0x13951146, (q31_t)0x8181bc96, - (q31_t)0x138edbb1, (q31_t)0x8180c6a9, (q31_t)0x1388a60f, (q31_t)0x817fd10a, (q31_t)0x13827062, (q31_t)0x817edbb9, (q31_t)0x137c3aa8, (q31_t)0x817de6b6, - (q31_t)0x137604e2, (q31_t)0x817cf201, (q31_t)0x136fcf10, (q31_t)0x817bfd9b, (q31_t)0x13699933, (q31_t)0x817b0982, (q31_t)0x13636349, (q31_t)0x817a15b7, - (q31_t)0x135d2d53, (q31_t)0x8179223a, (q31_t)0x1356f752, (q31_t)0x81782f0b, (q31_t)0x1350c144, (q31_t)0x81773c2b, (q31_t)0x134a8b2b, (q31_t)0x81764998, - (q31_t)0x13445505, (q31_t)0x81755754, (q31_t)0x133e1ed4, (q31_t)0x8174655d, (q31_t)0x1337e897, (q31_t)0x817373b5, (q31_t)0x1331b24e, (q31_t)0x8172825a, - (q31_t)0x132b7bf9, (q31_t)0x8171914e, (q31_t)0x13254599, (q31_t)0x8170a090, (q31_t)0x131f0f2c, (q31_t)0x816fb020, (q31_t)0x1318d8b4, (q31_t)0x816ebffe, - (q31_t)0x1312a230, (q31_t)0x816dd02a, (q31_t)0x130c6ba0, (q31_t)0x816ce0a4, (q31_t)0x13063505, (q31_t)0x816bf16c, (q31_t)0x12fffe5d, (q31_t)0x816b0282, - (q31_t)0x12f9c7aa, (q31_t)0x816a13e6, (q31_t)0x12f390ec, (q31_t)0x81692599, (q31_t)0x12ed5a21, (q31_t)0x81683799, (q31_t)0x12e7234b, (q31_t)0x816749e8, - (q31_t)0x12e0ec6a, (q31_t)0x81665c84, (q31_t)0x12dab57c, (q31_t)0x81656f6f, (q31_t)0x12d47e83, (q31_t)0x816482a8, (q31_t)0x12ce477f, (q31_t)0x8163962f, - (q31_t)0x12c8106f, (q31_t)0x8162aa04, (q31_t)0x12c1d953, (q31_t)0x8161be27, (q31_t)0x12bba22b, (q31_t)0x8160d298, (q31_t)0x12b56af9, (q31_t)0x815fe758, - (q31_t)0x12af33ba, (q31_t)0x815efc65, (q31_t)0x12a8fc70, (q31_t)0x815e11c1, (q31_t)0x12a2c51b, (q31_t)0x815d276a, (q31_t)0x129c8dba, (q31_t)0x815c3d62, - (q31_t)0x1296564d, (q31_t)0x815b53a8, (q31_t)0x12901ed5, (q31_t)0x815a6a3c, (q31_t)0x1289e752, (q31_t)0x8159811e, (q31_t)0x1283afc3, (q31_t)0x8158984e, - (q31_t)0x127d7829, (q31_t)0x8157afcd, (q31_t)0x12774083, (q31_t)0x8156c799, (q31_t)0x127108d2, (q31_t)0x8155dfb4, (q31_t)0x126ad116, (q31_t)0x8154f81d, - (q31_t)0x1264994e, (q31_t)0x815410d4, (q31_t)0x125e617b, (q31_t)0x815329d9, (q31_t)0x1258299c, (q31_t)0x8152432c, (q31_t)0x1251f1b3, (q31_t)0x81515ccd, - (q31_t)0x124bb9be, (q31_t)0x815076bd, (q31_t)0x124581bd, (q31_t)0x814f90fb, (q31_t)0x123f49b2, (q31_t)0x814eab86, (q31_t)0x1239119b, (q31_t)0x814dc660, - (q31_t)0x1232d979, (q31_t)0x814ce188, (q31_t)0x122ca14b, (q31_t)0x814bfcff, (q31_t)0x12266913, (q31_t)0x814b18c3, (q31_t)0x122030cf, (q31_t)0x814a34d6, - (q31_t)0x1219f880, (q31_t)0x81495136, (q31_t)0x1213c026, (q31_t)0x81486de5, (q31_t)0x120d87c1, (q31_t)0x81478ae2, (q31_t)0x12074f50, (q31_t)0x8146a82e, - (q31_t)0x120116d5, (q31_t)0x8145c5c7, (q31_t)0x11fade4e, (q31_t)0x8144e3ae, (q31_t)0x11f4a5bd, (q31_t)0x814401e4, (q31_t)0x11ee6d20, (q31_t)0x81432068, - (q31_t)0x11e83478, (q31_t)0x81423f3a, (q31_t)0x11e1fbc5, (q31_t)0x81415e5a, (q31_t)0x11dbc307, (q31_t)0x81407dc9, (q31_t)0x11d58a3e, (q31_t)0x813f9d86, - (q31_t)0x11cf516a, (q31_t)0x813ebd90, (q31_t)0x11c9188b, (q31_t)0x813ddde9, (q31_t)0x11c2dfa2, (q31_t)0x813cfe91, (q31_t)0x11bca6ad, (q31_t)0x813c1f86, - (q31_t)0x11b66dad, (q31_t)0x813b40ca, (q31_t)0x11b034a2, (q31_t)0x813a625b, (q31_t)0x11a9fb8d, (q31_t)0x8139843b, (q31_t)0x11a3c26c, (q31_t)0x8138a66a, - (q31_t)0x119d8941, (q31_t)0x8137c8e6, (q31_t)0x1197500a, (q31_t)0x8136ebb1, (q31_t)0x119116c9, (q31_t)0x81360ec9, (q31_t)0x118add7d, (q31_t)0x81353230, - (q31_t)0x1184a427, (q31_t)0x813455e6, (q31_t)0x117e6ac5, (q31_t)0x813379e9, (q31_t)0x11783159, (q31_t)0x81329e3b, (q31_t)0x1171f7e2, (q31_t)0x8131c2db, - (q31_t)0x116bbe60, (q31_t)0x8130e7c9, (q31_t)0x116584d3, (q31_t)0x81300d05, (q31_t)0x115f4b3c, (q31_t)0x812f3290, (q31_t)0x1159119a, (q31_t)0x812e5868, - (q31_t)0x1152d7ed, (q31_t)0x812d7e8f, (q31_t)0x114c9e35, (q31_t)0x812ca505, (q31_t)0x11466473, (q31_t)0x812bcbc8, (q31_t)0x11402aa6, (q31_t)0x812af2da, - (q31_t)0x1139f0cf, (q31_t)0x812a1a3a, (q31_t)0x1133b6ed, (q31_t)0x812941e8, (q31_t)0x112d7d00, (q31_t)0x812869e4, (q31_t)0x11274309, (q31_t)0x8127922f, - (q31_t)0x11210907, (q31_t)0x8126bac8, (q31_t)0x111acefb, (q31_t)0x8125e3af, (q31_t)0x111494e4, (q31_t)0x81250ce4, (q31_t)0x110e5ac2, (q31_t)0x81243668, - (q31_t)0x11082096, (q31_t)0x8123603a, (q31_t)0x1101e65f, (q31_t)0x81228a5a, (q31_t)0x10fbac1e, (q31_t)0x8121b4c8, (q31_t)0x10f571d3, (q31_t)0x8120df85, - (q31_t)0x10ef377d, (q31_t)0x81200a90, (q31_t)0x10e8fd1c, (q31_t)0x811f35e9, (q31_t)0x10e2c2b2, (q31_t)0x811e6191, (q31_t)0x10dc883c, (q31_t)0x811d8d86, - (q31_t)0x10d64dbd, (q31_t)0x811cb9ca, (q31_t)0x10d01333, (q31_t)0x811be65d, (q31_t)0x10c9d89e, (q31_t)0x811b133d, (q31_t)0x10c39dff, (q31_t)0x811a406c, - (q31_t)0x10bd6356, (q31_t)0x81196de9, (q31_t)0x10b728a3, (q31_t)0x81189bb4, (q31_t)0x10b0ede5, (q31_t)0x8117c9ce, (q31_t)0x10aab31d, (q31_t)0x8116f836, - (q31_t)0x10a4784b, (q31_t)0x811626ec, (q31_t)0x109e3d6e, (q31_t)0x811555f1, (q31_t)0x10980287, (q31_t)0x81148544, (q31_t)0x1091c796, (q31_t)0x8113b4e5, - (q31_t)0x108b8c9b, (q31_t)0x8112e4d4, (q31_t)0x10855195, (q31_t)0x81121512, (q31_t)0x107f1686, (q31_t)0x8111459e, (q31_t)0x1078db6c, (q31_t)0x81107678, - (q31_t)0x1072a048, (q31_t)0x810fa7a0, (q31_t)0x106c651a, (q31_t)0x810ed917, (q31_t)0x106629e1, (q31_t)0x810e0adc, (q31_t)0x105fee9f, (q31_t)0x810d3cf0, - (q31_t)0x1059b352, (q31_t)0x810c6f52, (q31_t)0x105377fc, (q31_t)0x810ba202, (q31_t)0x104d3c9b, (q31_t)0x810ad500, (q31_t)0x10470130, (q31_t)0x810a084d, - (q31_t)0x1040c5bb, (q31_t)0x81093be8, (q31_t)0x103a8a3d, (q31_t)0x81086fd1, (q31_t)0x10344eb4, (q31_t)0x8107a409, (q31_t)0x102e1321, (q31_t)0x8106d88f, - (q31_t)0x1027d784, (q31_t)0x81060d63, (q31_t)0x10219bdd, (q31_t)0x81054286, (q31_t)0x101b602d, (q31_t)0x810477f7, (q31_t)0x10152472, (q31_t)0x8103adb6, - (q31_t)0x100ee8ad, (q31_t)0x8102e3c4, (q31_t)0x1008acdf, (q31_t)0x81021a20, (q31_t)0x10027107, (q31_t)0x810150ca, (q31_t)0xffc3524, (q31_t)0x810087c3, - (q31_t)0xff5f938, (q31_t)0x80ffbf0a, (q31_t)0xfefbd42, (q31_t)0x80fef69f, (q31_t)0xfe98143, (q31_t)0x80fe2e83, (q31_t)0xfe34539, (q31_t)0x80fd66b5, - (q31_t)0xfdd0926, (q31_t)0x80fc9f35, (q31_t)0xfd6cd08, (q31_t)0x80fbd804, (q31_t)0xfd090e1, (q31_t)0x80fb1121, (q31_t)0xfca54b1, (q31_t)0x80fa4a8c, - (q31_t)0xfc41876, (q31_t)0x80f98446, (q31_t)0xfbddc32, (q31_t)0x80f8be4e, (q31_t)0xfb79fe4, (q31_t)0x80f7f8a4, (q31_t)0xfb1638d, (q31_t)0x80f73349, - (q31_t)0xfab272b, (q31_t)0x80f66e3c, (q31_t)0xfa4eac0, (q31_t)0x80f5a97e, (q31_t)0xf9eae4c, (q31_t)0x80f4e50e, (q31_t)0xf9871ce, (q31_t)0x80f420ec, - (q31_t)0xf923546, (q31_t)0x80f35d19, (q31_t)0xf8bf8b4, (q31_t)0x80f29994, (q31_t)0xf85bc19, (q31_t)0x80f1d65d, (q31_t)0xf7f7f75, (q31_t)0x80f11375, - (q31_t)0xf7942c7, (q31_t)0x80f050db, (q31_t)0xf73060f, (q31_t)0x80ef8e90, (q31_t)0xf6cc94e, (q31_t)0x80eecc93, (q31_t)0xf668c83, (q31_t)0x80ee0ae4, - (q31_t)0xf604faf, (q31_t)0x80ed4984, (q31_t)0xf5a12d1, (q31_t)0x80ec8872, (q31_t)0xf53d5ea, (q31_t)0x80ebc7ae, (q31_t)0xf4d98f9, (q31_t)0x80eb0739, - (q31_t)0xf475bff, (q31_t)0x80ea4712, (q31_t)0xf411efb, (q31_t)0x80e9873a, (q31_t)0xf3ae1ee, (q31_t)0x80e8c7b0, (q31_t)0xf34a4d8, (q31_t)0x80e80874, - (q31_t)0xf2e67b8, (q31_t)0x80e74987, (q31_t)0xf282a8f, (q31_t)0x80e68ae8, (q31_t)0xf21ed5d, (q31_t)0x80e5cc98, (q31_t)0xf1bb021, (q31_t)0x80e50e96, - (q31_t)0xf1572dc, (q31_t)0x80e450e2, (q31_t)0xf0f358e, (q31_t)0x80e3937d, (q31_t)0xf08f836, (q31_t)0x80e2d666, (q31_t)0xf02bad5, (q31_t)0x80e2199e, - (q31_t)0xefc7d6b, (q31_t)0x80e15d24, (q31_t)0xef63ff7, (q31_t)0x80e0a0f8, (q31_t)0xef0027b, (q31_t)0x80dfe51b, (q31_t)0xee9c4f5, (q31_t)0x80df298c, - (q31_t)0xee38766, (q31_t)0x80de6e4c, (q31_t)0xedd49ce, (q31_t)0x80ddb35a, (q31_t)0xed70c2c, (q31_t)0x80dcf8b7, (q31_t)0xed0ce82, (q31_t)0x80dc3e62, - (q31_t)0xeca90ce, (q31_t)0x80db845b, (q31_t)0xec45311, (q31_t)0x80dacaa3, (q31_t)0xebe154b, (q31_t)0x80da1139, (q31_t)0xeb7d77c, (q31_t)0x80d9581e, - (q31_t)0xeb199a4, (q31_t)0x80d89f51, (q31_t)0xeab5bc3, (q31_t)0x80d7e6d3, (q31_t)0xea51dd8, (q31_t)0x80d72ea3, (q31_t)0xe9edfe5, (q31_t)0x80d676c1, - (q31_t)0xe98a1e9, (q31_t)0x80d5bf2e, (q31_t)0xe9263e3, (q31_t)0x80d507e9, (q31_t)0xe8c25d5, (q31_t)0x80d450f3, (q31_t)0xe85e7be, (q31_t)0x80d39a4b, - (q31_t)0xe7fa99e, (q31_t)0x80d2e3f2, (q31_t)0xe796b74, (q31_t)0x80d22de7, (q31_t)0xe732d42, (q31_t)0x80d1782a, (q31_t)0xe6cef07, (q31_t)0x80d0c2bc, - (q31_t)0xe66b0c3, (q31_t)0x80d00d9d, (q31_t)0xe607277, (q31_t)0x80cf58cc, (q31_t)0xe5a3421, (q31_t)0x80cea449, (q31_t)0xe53f5c2, (q31_t)0x80cdf015, - (q31_t)0xe4db75b, (q31_t)0x80cd3c2f, (q31_t)0xe4778eb, (q31_t)0x80cc8898, (q31_t)0xe413a72, (q31_t)0x80cbd54f, (q31_t)0xe3afbf0, (q31_t)0x80cb2255, - (q31_t)0xe34bd66, (q31_t)0x80ca6fa9, (q31_t)0xe2e7ed2, (q31_t)0x80c9bd4c, (q31_t)0xe284036, (q31_t)0x80c90b3d, (q31_t)0xe220191, (q31_t)0x80c8597c, - (q31_t)0xe1bc2e4, (q31_t)0x80c7a80a, (q31_t)0xe15842e, (q31_t)0x80c6f6e7, (q31_t)0xe0f456f, (q31_t)0x80c64612, (q31_t)0xe0906a7, (q31_t)0x80c5958b, - (q31_t)0xe02c7d7, (q31_t)0x80c4e553, (q31_t)0xdfc88fe, (q31_t)0x80c4356a, (q31_t)0xdf64a1c, (q31_t)0x80c385cf, (q31_t)0xdf00b32, (q31_t)0x80c2d682, - (q31_t)0xde9cc40, (q31_t)0x80c22784, (q31_t)0xde38d44, (q31_t)0x80c178d4, (q31_t)0xddd4e40, (q31_t)0x80c0ca73, (q31_t)0xdd70f34, (q31_t)0x80c01c60, - (q31_t)0xdd0d01f, (q31_t)0x80bf6e9c, (q31_t)0xdca9102, (q31_t)0x80bec127, (q31_t)0xdc451dc, (q31_t)0x80be13ff, (q31_t)0xdbe12ad, (q31_t)0x80bd6727, - (q31_t)0xdb7d376, (q31_t)0x80bcba9d, (q31_t)0xdb19437, (q31_t)0x80bc0e61, (q31_t)0xdab54ef, (q31_t)0x80bb6274, (q31_t)0xda5159f, (q31_t)0x80bab6d5, - (q31_t)0xd9ed646, (q31_t)0x80ba0b85, (q31_t)0xd9896e5, (q31_t)0x80b96083, (q31_t)0xd92577b, (q31_t)0x80b8b5d0, (q31_t)0xd8c1809, (q31_t)0x80b80b6c, - (q31_t)0xd85d88f, (q31_t)0x80b76156, (q31_t)0xd7f990c, (q31_t)0x80b6b78e, (q31_t)0xd795982, (q31_t)0x80b60e15, (q31_t)0xd7319ee, (q31_t)0x80b564ea, - (q31_t)0xd6cda53, (q31_t)0x80b4bc0e, (q31_t)0xd669aaf, (q31_t)0x80b41381, (q31_t)0xd605b03, (q31_t)0x80b36b42, (q31_t)0xd5a1b4f, (q31_t)0x80b2c351, - (q31_t)0xd53db92, (q31_t)0x80b21baf, (q31_t)0xd4d9bcd, (q31_t)0x80b1745c, (q31_t)0xd475c00, (q31_t)0x80b0cd57, (q31_t)0xd411c2b, (q31_t)0x80b026a1, - (q31_t)0xd3adc4e, (q31_t)0x80af8039, (q31_t)0xd349c68, (q31_t)0x80aeda20, (q31_t)0xd2e5c7b, (q31_t)0x80ae3455, (q31_t)0xd281c85, (q31_t)0x80ad8ed9, - (q31_t)0xd21dc87, (q31_t)0x80ace9ab, (q31_t)0xd1b9c81, (q31_t)0x80ac44cc, (q31_t)0xd155c73, (q31_t)0x80aba03b, (q31_t)0xd0f1c5d, (q31_t)0x80aafbf9, - (q31_t)0xd08dc3f, (q31_t)0x80aa5806, (q31_t)0xd029c18, (q31_t)0x80a9b461, (q31_t)0xcfc5bea, (q31_t)0x80a9110b, (q31_t)0xcf61bb4, (q31_t)0x80a86e03, - (q31_t)0xcefdb76, (q31_t)0x80a7cb49, (q31_t)0xce99b2f, (q31_t)0x80a728df, (q31_t)0xce35ae1, (q31_t)0x80a686c2, (q31_t)0xcdd1a8b, (q31_t)0x80a5e4f5, - (q31_t)0xcd6da2d, (q31_t)0x80a54376, (q31_t)0xcd099c7, (q31_t)0x80a4a245, (q31_t)0xcca5959, (q31_t)0x80a40163, (q31_t)0xcc418e3, (q31_t)0x80a360d0, - (q31_t)0xcbdd865, (q31_t)0x80a2c08b, (q31_t)0xcb797e0, (q31_t)0x80a22095, (q31_t)0xcb15752, (q31_t)0x80a180ed, (q31_t)0xcab16bd, (q31_t)0x80a0e194, - (q31_t)0xca4d620, (q31_t)0x80a04289, (q31_t)0xc9e957b, (q31_t)0x809fa3cd, (q31_t)0xc9854cf, (q31_t)0x809f0560, (q31_t)0xc92141a, (q31_t)0x809e6741, - (q31_t)0xc8bd35e, (q31_t)0x809dc971, (q31_t)0xc85929a, (q31_t)0x809d2bef, (q31_t)0xc7f51cf, (q31_t)0x809c8ebc, (q31_t)0xc7910fb, (q31_t)0x809bf1d7, - (q31_t)0xc72d020, (q31_t)0x809b5541, (q31_t)0xc6c8f3e, (q31_t)0x809ab8fa, (q31_t)0xc664e53, (q31_t)0x809a1d01, (q31_t)0xc600d61, (q31_t)0x80998157, - (q31_t)0xc59cc68, (q31_t)0x8098e5fb, (q31_t)0xc538b66, (q31_t)0x80984aee, (q31_t)0xc4d4a5d, (q31_t)0x8097b030, (q31_t)0xc47094d, (q31_t)0x809715c0, - (q31_t)0xc40c835, (q31_t)0x80967b9f, (q31_t)0xc3a8715, (q31_t)0x8095e1cc, (q31_t)0xc3445ee, (q31_t)0x80954848, (q31_t)0xc2e04c0, (q31_t)0x8094af13, - (q31_t)0xc27c389, (q31_t)0x8094162c, (q31_t)0xc21824c, (q31_t)0x80937d93, (q31_t)0xc1b4107, (q31_t)0x8092e54a, (q31_t)0xc14ffba, (q31_t)0x80924d4f, - (q31_t)0xc0ebe66, (q31_t)0x8091b5a2, (q31_t)0xc087d0a, (q31_t)0x80911e44, (q31_t)0xc023ba7, (q31_t)0x80908735, (q31_t)0xbfbfa3d, (q31_t)0x808ff074, - (q31_t)0xbf5b8cb, (q31_t)0x808f5a02, (q31_t)0xbef7752, (q31_t)0x808ec3df, (q31_t)0xbe935d2, (q31_t)0x808e2e0a, (q31_t)0xbe2f44a, (q31_t)0x808d9884, - (q31_t)0xbdcb2bb, (q31_t)0x808d034c, (q31_t)0xbd67124, (q31_t)0x808c6e63, (q31_t)0xbd02f87, (q31_t)0x808bd9c9, (q31_t)0xbc9ede2, (q31_t)0x808b457d, - (q31_t)0xbc3ac35, (q31_t)0x808ab180, (q31_t)0xbbd6a82, (q31_t)0x808a1dd2, (q31_t)0xbb728c7, (q31_t)0x80898a72, (q31_t)0xbb0e705, (q31_t)0x8088f761, - (q31_t)0xbaaa53b, (q31_t)0x8088649e, (q31_t)0xba4636b, (q31_t)0x8087d22a, (q31_t)0xb9e2193, (q31_t)0x80874005, (q31_t)0xb97dfb5, (q31_t)0x8086ae2e, - (q31_t)0xb919dcf, (q31_t)0x80861ca6, (q31_t)0xb8b5be1, (q31_t)0x80858b6c, (q31_t)0xb8519ed, (q31_t)0x8084fa82, (q31_t)0xb7ed7f2, (q31_t)0x808469e5, - (q31_t)0xb7895f0, (q31_t)0x8083d998, (q31_t)0xb7253e6, (q31_t)0x80834999, (q31_t)0xb6c11d5, (q31_t)0x8082b9e9, (q31_t)0xb65cfbe, (q31_t)0x80822a87, - (q31_t)0xb5f8d9f, (q31_t)0x80819b74, (q31_t)0xb594b7a, (q31_t)0x80810cb0, (q31_t)0xb53094d, (q31_t)0x80807e3a, (q31_t)0xb4cc719, (q31_t)0x807ff013, - (q31_t)0xb4684df, (q31_t)0x807f623b, (q31_t)0xb40429d, (q31_t)0x807ed4b1, (q31_t)0xb3a0055, (q31_t)0x807e4776, (q31_t)0xb33be05, (q31_t)0x807dba89, - (q31_t)0xb2d7baf, (q31_t)0x807d2dec, (q31_t)0xb273952, (q31_t)0x807ca19c, (q31_t)0xb20f6ee, (q31_t)0x807c159c, (q31_t)0xb1ab483, (q31_t)0x807b89ea, - (q31_t)0xb147211, (q31_t)0x807afe87, (q31_t)0xb0e2f98, (q31_t)0x807a7373, (q31_t)0xb07ed19, (q31_t)0x8079e8ad, (q31_t)0xb01aa92, (q31_t)0x80795e36, - (q31_t)0xafb6805, (q31_t)0x8078d40d, (q31_t)0xaf52571, (q31_t)0x80784a33, (q31_t)0xaeee2d7, (q31_t)0x8077c0a8, (q31_t)0xae8a036, (q31_t)0x8077376c, - (q31_t)0xae25d8d, (q31_t)0x8076ae7e, (q31_t)0xadc1adf, (q31_t)0x807625df, (q31_t)0xad5d829, (q31_t)0x80759d8e, (q31_t)0xacf956d, (q31_t)0x8075158c, - (q31_t)0xac952aa, (q31_t)0x80748dd9, (q31_t)0xac30fe1, (q31_t)0x80740675, (q31_t)0xabccd11, (q31_t)0x80737f5f, (q31_t)0xab68a3a, (q31_t)0x8072f898, - (q31_t)0xab0475c, (q31_t)0x8072721f, (q31_t)0xaaa0478, (q31_t)0x8071ebf6, (q31_t)0xaa3c18e, (q31_t)0x8071661a, (q31_t)0xa9d7e9d, (q31_t)0x8070e08e, - (q31_t)0xa973ba5, (q31_t)0x80705b50, (q31_t)0xa90f8a7, (q31_t)0x806fd661, (q31_t)0xa8ab5a2, (q31_t)0x806f51c1, (q31_t)0xa847297, (q31_t)0x806ecd6f, - (q31_t)0xa7e2f85, (q31_t)0x806e496c, (q31_t)0xa77ec6d, (q31_t)0x806dc5b8, (q31_t)0xa71a94f, (q31_t)0x806d4253, (q31_t)0xa6b662a, (q31_t)0x806cbf3c, - (q31_t)0xa6522fe, (q31_t)0x806c3c74, (q31_t)0xa5edfcc, (q31_t)0x806bb9fa, (q31_t)0xa589c94, (q31_t)0x806b37cf, (q31_t)0xa525955, (q31_t)0x806ab5f3, - (q31_t)0xa4c1610, (q31_t)0x806a3466, (q31_t)0xa45d2c5, (q31_t)0x8069b327, (q31_t)0xa3f8f73, (q31_t)0x80693237, (q31_t)0xa394c1b, (q31_t)0x8068b196, - (q31_t)0xa3308bd, (q31_t)0x80683143, (q31_t)0xa2cc558, (q31_t)0x8067b13f, (q31_t)0xa2681ed, (q31_t)0x8067318a, (q31_t)0xa203e7c, (q31_t)0x8066b224, - (q31_t)0xa19fb04, (q31_t)0x8066330c, (q31_t)0xa13b787, (q31_t)0x8065b443, (q31_t)0xa0d7403, (q31_t)0x806535c9, (q31_t)0xa073079, (q31_t)0x8064b79d, - (q31_t)0xa00ece8, (q31_t)0x806439c0, (q31_t)0x9faa952, (q31_t)0x8063bc32, (q31_t)0x9f465b5, (q31_t)0x80633ef3, (q31_t)0x9ee2213, (q31_t)0x8062c202, - (q31_t)0x9e7de6a, (q31_t)0x80624560, (q31_t)0x9e19abb, (q31_t)0x8061c90c, (q31_t)0x9db5706, (q31_t)0x80614d08, (q31_t)0x9d5134b, (q31_t)0x8060d152, - (q31_t)0x9cecf89, (q31_t)0x806055eb, (q31_t)0x9c88bc2, (q31_t)0x805fdad2, (q31_t)0x9c247f5, (q31_t)0x805f6009, (q31_t)0x9bc0421, (q31_t)0x805ee58e, - (q31_t)0x9b5c048, (q31_t)0x805e6b62, (q31_t)0x9af7c69, (q31_t)0x805df184, (q31_t)0x9a93884, (q31_t)0x805d77f5, (q31_t)0x9a2f498, (q31_t)0x805cfeb5, - (q31_t)0x99cb0a7, (q31_t)0x805c85c4, (q31_t)0x9966cb0, (q31_t)0x805c0d21, (q31_t)0x99028b3, (q31_t)0x805b94ce, (q31_t)0x989e4b0, (q31_t)0x805b1cc8, - (q31_t)0x983a0a7, (q31_t)0x805aa512, (q31_t)0x97d5c99, (q31_t)0x805a2daa, (q31_t)0x9771884, (q31_t)0x8059b692, (q31_t)0x970d46a, (q31_t)0x80593fc7, - (q31_t)0x96a9049, (q31_t)0x8058c94c, (q31_t)0x9644c23, (q31_t)0x8058531f, (q31_t)0x95e07f8, (q31_t)0x8057dd41, (q31_t)0x957c3c6, (q31_t)0x805767b2, - (q31_t)0x9517f8f, (q31_t)0x8056f272, (q31_t)0x94b3b52, (q31_t)0x80567d80, (q31_t)0x944f70f, (q31_t)0x805608dd, (q31_t)0x93eb2c6, (q31_t)0x80559489, - (q31_t)0x9386e78, (q31_t)0x80552084, (q31_t)0x9322a24, (q31_t)0x8054accd, (q31_t)0x92be5ca, (q31_t)0x80543965, (q31_t)0x925a16b, (q31_t)0x8053c64c, - (q31_t)0x91f5d06, (q31_t)0x80535381, (q31_t)0x919189c, (q31_t)0x8052e106, (q31_t)0x912d42c, (q31_t)0x80526ed9, (q31_t)0x90c8fb6, (q31_t)0x8051fcfb, - (q31_t)0x9064b3a, (q31_t)0x80518b6b, (q31_t)0x90006ba, (q31_t)0x80511a2b, (q31_t)0x8f9c233, (q31_t)0x8050a939, (q31_t)0x8f37da7, (q31_t)0x80503896, - (q31_t)0x8ed3916, (q31_t)0x804fc841, (q31_t)0x8e6f47f, (q31_t)0x804f583c, (q31_t)0x8e0afe2, (q31_t)0x804ee885, (q31_t)0x8da6b40, (q31_t)0x804e791d, - (q31_t)0x8d42699, (q31_t)0x804e0a04, (q31_t)0x8cde1ec, (q31_t)0x804d9b39, (q31_t)0x8c79d3a, (q31_t)0x804d2cbd, (q31_t)0x8c15882, (q31_t)0x804cbe90, - (q31_t)0x8bb13c5, (q31_t)0x804c50b2, (q31_t)0x8b4cf02, (q31_t)0x804be323, (q31_t)0x8ae8a3a, (q31_t)0x804b75e2, (q31_t)0x8a8456d, (q31_t)0x804b08f0, - (q31_t)0x8a2009a, (q31_t)0x804a9c4d, (q31_t)0x89bbbc3, (q31_t)0x804a2ff9, (q31_t)0x89576e5, (q31_t)0x8049c3f3, (q31_t)0x88f3203, (q31_t)0x8049583d, - (q31_t)0x888ed1b, (q31_t)0x8048ecd5, (q31_t)0x882a82e, (q31_t)0x804881bb, (q31_t)0x87c633c, (q31_t)0x804816f1, (q31_t)0x8761e44, (q31_t)0x8047ac75, - (q31_t)0x86fd947, (q31_t)0x80474248, (q31_t)0x8699445, (q31_t)0x8046d86a, (q31_t)0x8634f3e, (q31_t)0x80466edb, (q31_t)0x85d0a32, (q31_t)0x8046059b, - (q31_t)0x856c520, (q31_t)0x80459ca9, (q31_t)0x850800a, (q31_t)0x80453406, (q31_t)0x84a3aee, (q31_t)0x8044cbb2, (q31_t)0x843f5cd, (q31_t)0x804463ad, - (q31_t)0x83db0a7, (q31_t)0x8043fbf6, (q31_t)0x8376b7c, (q31_t)0x8043948e, (q31_t)0x831264c, (q31_t)0x80432d75, (q31_t)0x82ae117, (q31_t)0x8042c6ab, - (q31_t)0x8249bdd, (q31_t)0x80426030, (q31_t)0x81e569d, (q31_t)0x8041fa03, (q31_t)0x8181159, (q31_t)0x80419425, (q31_t)0x811cc10, (q31_t)0x80412e96, - (q31_t)0x80b86c2, (q31_t)0x8040c956, (q31_t)0x805416e, (q31_t)0x80406465, (q31_t)0x7fefc16, (q31_t)0x803fffc2, (q31_t)0x7f8b6b9, (q31_t)0x803f9b6f, - (q31_t)0x7f27157, (q31_t)0x803f376a, (q31_t)0x7ec2bf0, (q31_t)0x803ed3b3, (q31_t)0x7e5e685, (q31_t)0x803e704c, (q31_t)0x7dfa114, (q31_t)0x803e0d34, - (q31_t)0x7d95b9e, (q31_t)0x803daa6a, (q31_t)0x7d31624, (q31_t)0x803d47ef, (q31_t)0x7ccd0a5, (q31_t)0x803ce5c3, (q31_t)0x7c68b21, (q31_t)0x803c83e5, - (q31_t)0x7c04598, (q31_t)0x803c2257, (q31_t)0x7ba000b, (q31_t)0x803bc117, (q31_t)0x7b3ba78, (q31_t)0x803b6026, (q31_t)0x7ad74e1, (q31_t)0x803aff84, - (q31_t)0x7a72f45, (q31_t)0x803a9f31, (q31_t)0x7a0e9a5, (q31_t)0x803a3f2d, (q31_t)0x79aa400, (q31_t)0x8039df77, (q31_t)0x7945e56, (q31_t)0x80398010, - (q31_t)0x78e18a7, (q31_t)0x803920f8, (q31_t)0x787d2f4, (q31_t)0x8038c22f, (q31_t)0x7818d3c, (q31_t)0x803863b5, (q31_t)0x77b4780, (q31_t)0x80380589, - (q31_t)0x77501be, (q31_t)0x8037a7ac, (q31_t)0x76ebbf9, (q31_t)0x80374a1f, (q31_t)0x768762e, (q31_t)0x8036ece0, (q31_t)0x762305f, (q31_t)0x80368fef, - (q31_t)0x75bea8c, (q31_t)0x8036334e, (q31_t)0x755a4b4, (q31_t)0x8035d6fb, (q31_t)0x74f5ed7, (q31_t)0x80357af8, (q31_t)0x74918f6, (q31_t)0x80351f43, - (q31_t)0x742d311, (q31_t)0x8034c3dd, (q31_t)0x73c8d27, (q31_t)0x803468c5, (q31_t)0x7364738, (q31_t)0x80340dfd, (q31_t)0x7300145, (q31_t)0x8033b383, - (q31_t)0x729bb4e, (q31_t)0x80335959, (q31_t)0x7237552, (q31_t)0x8032ff7d, (q31_t)0x71d2f52, (q31_t)0x8032a5ef, (q31_t)0x716e94e, (q31_t)0x80324cb1, - (q31_t)0x710a345, (q31_t)0x8031f3c2, (q31_t)0x70a5d37, (q31_t)0x80319b21, (q31_t)0x7041726, (q31_t)0x803142cf, (q31_t)0x6fdd110, (q31_t)0x8030eacd, - (q31_t)0x6f78af6, (q31_t)0x80309318, (q31_t)0x6f144d7, (q31_t)0x80303bb3, (q31_t)0x6eafeb4, (q31_t)0x802fe49d, (q31_t)0x6e4b88d, (q31_t)0x802f8dd5, - (q31_t)0x6de7262, (q31_t)0x802f375d, (q31_t)0x6d82c32, (q31_t)0x802ee133, (q31_t)0x6d1e5fe, (q31_t)0x802e8b58, (q31_t)0x6cb9fc6, (q31_t)0x802e35cb, - (q31_t)0x6c5598a, (q31_t)0x802de08e, (q31_t)0x6bf1349, (q31_t)0x802d8ba0, (q31_t)0x6b8cd05, (q31_t)0x802d3700, (q31_t)0x6b286bc, (q31_t)0x802ce2af, - (q31_t)0x6ac406f, (q31_t)0x802c8ead, (q31_t)0x6a5fa1e, (q31_t)0x802c3afa, (q31_t)0x69fb3c9, (q31_t)0x802be796, (q31_t)0x6996d70, (q31_t)0x802b9480, - (q31_t)0x6932713, (q31_t)0x802b41ba, (q31_t)0x68ce0b2, (q31_t)0x802aef42, (q31_t)0x6869a4c, (q31_t)0x802a9d19, (q31_t)0x68053e3, (q31_t)0x802a4b3f, - (q31_t)0x67a0d76, (q31_t)0x8029f9b4, (q31_t)0x673c704, (q31_t)0x8029a878, (q31_t)0x66d808f, (q31_t)0x8029578b, (q31_t)0x6673a16, (q31_t)0x802906ec, - (q31_t)0x660f398, (q31_t)0x8028b69c, (q31_t)0x65aad17, (q31_t)0x8028669b, (q31_t)0x6546692, (q31_t)0x802816e9, (q31_t)0x64e2009, (q31_t)0x8027c786, - (q31_t)0x647d97c, (q31_t)0x80277872, (q31_t)0x64192eb, (q31_t)0x802729ad, (q31_t)0x63b4c57, (q31_t)0x8026db36, (q31_t)0x63505be, (q31_t)0x80268d0e, - (q31_t)0x62ebf22, (q31_t)0x80263f36, (q31_t)0x6287882, (q31_t)0x8025f1ac, (q31_t)0x62231de, (q31_t)0x8025a471, (q31_t)0x61beb36, (q31_t)0x80255784, - (q31_t)0x615a48b, (q31_t)0x80250ae7, (q31_t)0x60f5ddc, (q31_t)0x8024be99, (q31_t)0x6091729, (q31_t)0x80247299, (q31_t)0x602d072, (q31_t)0x802426e8, - (q31_t)0x5fc89b8, (q31_t)0x8023db86, (q31_t)0x5f642fa, (q31_t)0x80239073, (q31_t)0x5effc38, (q31_t)0x802345af, (q31_t)0x5e9b572, (q31_t)0x8022fb3a, - (q31_t)0x5e36ea9, (q31_t)0x8022b114, (q31_t)0x5dd27dd, (q31_t)0x8022673c, (q31_t)0x5d6e10c, (q31_t)0x80221db3, (q31_t)0x5d09a38, (q31_t)0x8021d47a, - (q31_t)0x5ca5361, (q31_t)0x80218b8f, (q31_t)0x5c40c86, (q31_t)0x802142f3, (q31_t)0x5bdc5a7, (q31_t)0x8020faa6, (q31_t)0x5b77ec5, (q31_t)0x8020b2a7, - (q31_t)0x5b137df, (q31_t)0x80206af8, (q31_t)0x5aaf0f6, (q31_t)0x80202397, (q31_t)0x5a4aa09, (q31_t)0x801fdc86, (q31_t)0x59e6319, (q31_t)0x801f95c3, - (q31_t)0x5981c26, (q31_t)0x801f4f4f, (q31_t)0x591d52f, (q31_t)0x801f092a, (q31_t)0x58b8e34, (q31_t)0x801ec354, (q31_t)0x5854736, (q31_t)0x801e7dcd, - (q31_t)0x57f0035, (q31_t)0x801e3895, (q31_t)0x578b930, (q31_t)0x801df3ab, (q31_t)0x5727228, (q31_t)0x801daf11, (q31_t)0x56c2b1c, (q31_t)0x801d6ac5, - (q31_t)0x565e40d, (q31_t)0x801d26c8, (q31_t)0x55f9cfb, (q31_t)0x801ce31a, (q31_t)0x55955e6, (q31_t)0x801c9fbb, (q31_t)0x5530ecd, (q31_t)0x801c5cab, - (q31_t)0x54cc7b1, (q31_t)0x801c19ea, (q31_t)0x5468092, (q31_t)0x801bd777, (q31_t)0x540396f, (q31_t)0x801b9554, (q31_t)0x539f249, (q31_t)0x801b537f, - (q31_t)0x533ab20, (q31_t)0x801b11fa, (q31_t)0x52d63f4, (q31_t)0x801ad0c3, (q31_t)0x5271cc4, (q31_t)0x801a8fdb, (q31_t)0x520d592, (q31_t)0x801a4f42, - (q31_t)0x51a8e5c, (q31_t)0x801a0ef8, (q31_t)0x5144723, (q31_t)0x8019cefd, (q31_t)0x50dffe7, (q31_t)0x80198f50, (q31_t)0x507b8a8, (q31_t)0x80194ff3, - (q31_t)0x5017165, (q31_t)0x801910e4, (q31_t)0x4fb2a20, (q31_t)0x8018d225, (q31_t)0x4f4e2d8, (q31_t)0x801893b4, (q31_t)0x4ee9b8c, (q31_t)0x80185592, - (q31_t)0x4e8543e, (q31_t)0x801817bf, (q31_t)0x4e20cec, (q31_t)0x8017da3b, (q31_t)0x4dbc597, (q31_t)0x80179d06, (q31_t)0x4d57e40, (q31_t)0x80176020, - (q31_t)0x4cf36e5, (q31_t)0x80172388, (q31_t)0x4c8ef88, (q31_t)0x8016e740, (q31_t)0x4c2a827, (q31_t)0x8016ab46, (q31_t)0x4bc60c4, (q31_t)0x80166f9c, - (q31_t)0x4b6195d, (q31_t)0x80163440, (q31_t)0x4afd1f4, (q31_t)0x8015f933, (q31_t)0x4a98a88, (q31_t)0x8015be75, (q31_t)0x4a34319, (q31_t)0x80158406, - (q31_t)0x49cfba7, (q31_t)0x801549e6, (q31_t)0x496b432, (q31_t)0x80151015, (q31_t)0x4906cbb, (q31_t)0x8014d693, (q31_t)0x48a2540, (q31_t)0x80149d5f, - (q31_t)0x483ddc3, (q31_t)0x8014647b, (q31_t)0x47d9643, (q31_t)0x80142be5, (q31_t)0x4774ec1, (q31_t)0x8013f39e, (q31_t)0x471073b, (q31_t)0x8013bba7, - (q31_t)0x46abfb3, (q31_t)0x801383fe, (q31_t)0x4647828, (q31_t)0x80134ca4, (q31_t)0x45e309a, (q31_t)0x80131599, (q31_t)0x457e90a, (q31_t)0x8012dedd, - (q31_t)0x451a177, (q31_t)0x8012a86f, (q31_t)0x44b59e1, (q31_t)0x80127251, (q31_t)0x4451249, (q31_t)0x80123c82, (q31_t)0x43ecaae, (q31_t)0x80120701, - (q31_t)0x4388310, (q31_t)0x8011d1d0, (q31_t)0x4323b70, (q31_t)0x80119ced, (q31_t)0x42bf3cd, (q31_t)0x80116859, (q31_t)0x425ac28, (q31_t)0x80113414, - (q31_t)0x41f6480, (q31_t)0x8011001f, (q31_t)0x4191cd5, (q31_t)0x8010cc78, (q31_t)0x412d528, (q31_t)0x8010991f, (q31_t)0x40c8d79, (q31_t)0x80106616, - (q31_t)0x40645c7, (q31_t)0x8010335c, (q31_t)0x3fffe12, (q31_t)0x801000f1, (q31_t)0x3f9b65b, (q31_t)0x800fced4, (q31_t)0x3f36ea2, (q31_t)0x800f9d07, - (q31_t)0x3ed26e6, (q31_t)0x800f6b88, (q31_t)0x3e6df28, (q31_t)0x800f3a59, (q31_t)0x3e09767, (q31_t)0x800f0978, (q31_t)0x3da4fa4, (q31_t)0x800ed8e6, - (q31_t)0x3d407df, (q31_t)0x800ea8a3, (q31_t)0x3cdc017, (q31_t)0x800e78af, (q31_t)0x3c7784d, (q31_t)0x800e490a, (q31_t)0x3c13080, (q31_t)0x800e19b4, - (q31_t)0x3bae8b2, (q31_t)0x800deaad, (q31_t)0x3b4a0e0, (q31_t)0x800dbbf5, (q31_t)0x3ae590d, (q31_t)0x800d8d8b, (q31_t)0x3a81137, (q31_t)0x800d5f71, - (q31_t)0x3a1c960, (q31_t)0x800d31a5, (q31_t)0x39b8185, (q31_t)0x800d0429, (q31_t)0x39539a9, (q31_t)0x800cd6fb, (q31_t)0x38ef1ca, (q31_t)0x800caa1c, - (q31_t)0x388a9ea, (q31_t)0x800c7d8c, (q31_t)0x3826207, (q31_t)0x800c514c, (q31_t)0x37c1a22, (q31_t)0x800c255a, (q31_t)0x375d23a, (q31_t)0x800bf9b7, - (q31_t)0x36f8a51, (q31_t)0x800bce63, (q31_t)0x3694265, (q31_t)0x800ba35d, (q31_t)0x362fa78, (q31_t)0x800b78a7, (q31_t)0x35cb288, (q31_t)0x800b4e40, - (q31_t)0x3566a96, (q31_t)0x800b2427, (q31_t)0x35022a2, (q31_t)0x800afa5e, (q31_t)0x349daac, (q31_t)0x800ad0e3, (q31_t)0x34392b4, (q31_t)0x800aa7b8, - (q31_t)0x33d4abb, (q31_t)0x800a7edb, (q31_t)0x33702bf, (q31_t)0x800a564e, (q31_t)0x330bac1, (q31_t)0x800a2e0f, (q31_t)0x32a72c1, (q31_t)0x800a061f, - (q31_t)0x3242abf, (q31_t)0x8009de7e, (q31_t)0x31de2bb, (q31_t)0x8009b72c, (q31_t)0x3179ab5, (q31_t)0x80099029, (q31_t)0x31152ae, (q31_t)0x80096975, - (q31_t)0x30b0aa4, (q31_t)0x80094310, (q31_t)0x304c299, (q31_t)0x80091cf9, (q31_t)0x2fe7a8c, (q31_t)0x8008f732, (q31_t)0x2f8327d, (q31_t)0x8008d1ba, - (q31_t)0x2f1ea6c, (q31_t)0x8008ac90, (q31_t)0x2eba259, (q31_t)0x800887b6, (q31_t)0x2e55a44, (q31_t)0x8008632a, (q31_t)0x2df122e, (q31_t)0x80083eed, - (q31_t)0x2d8ca16, (q31_t)0x80081b00, (q31_t)0x2d281fc, (q31_t)0x8007f761, (q31_t)0x2cc39e1, (q31_t)0x8007d411, (q31_t)0x2c5f1c3, (q31_t)0x8007b110, - (q31_t)0x2bfa9a4, (q31_t)0x80078e5e, (q31_t)0x2b96184, (q31_t)0x80076bfb, (q31_t)0x2b31961, (q31_t)0x800749e7, (q31_t)0x2acd13d, (q31_t)0x80072822, - (q31_t)0x2a68917, (q31_t)0x800706ac, (q31_t)0x2a040f0, (q31_t)0x8006e585, (q31_t)0x299f8c7, (q31_t)0x8006c4ac, (q31_t)0x293b09c, (q31_t)0x8006a423, - (q31_t)0x28d6870, (q31_t)0x800683e8, (q31_t)0x2872043, (q31_t)0x800663fd, (q31_t)0x280d813, (q31_t)0x80064460, (q31_t)0x27a8fe2, (q31_t)0x80062513, - (q31_t)0x27447b0, (q31_t)0x80060614, (q31_t)0x26dff7c, (q31_t)0x8005e764, (q31_t)0x267b747, (q31_t)0x8005c904, (q31_t)0x2616f10, (q31_t)0x8005aaf2, - (q31_t)0x25b26d7, (q31_t)0x80058d2f, (q31_t)0x254de9e, (q31_t)0x80056fbb, (q31_t)0x24e9662, (q31_t)0x80055296, (q31_t)0x2484e26, (q31_t)0x800535c0, - (q31_t)0x24205e8, (q31_t)0x80051939, (q31_t)0x23bbda8, (q31_t)0x8004fd00, (q31_t)0x2357567, (q31_t)0x8004e117, (q31_t)0x22f2d25, (q31_t)0x8004c57d, - (q31_t)0x228e4e2, (q31_t)0x8004aa32, (q31_t)0x2229c9d, (q31_t)0x80048f35, (q31_t)0x21c5457, (q31_t)0x80047488, (q31_t)0x2160c0f, (q31_t)0x80045a29, - (q31_t)0x20fc3c6, (q31_t)0x8004401a, (q31_t)0x2097b7c, (q31_t)0x80042659, (q31_t)0x2033331, (q31_t)0x80040ce7, (q31_t)0x1fceae4, (q31_t)0x8003f3c5, - (q31_t)0x1f6a297, (q31_t)0x8003daf1, (q31_t)0x1f05a48, (q31_t)0x8003c26c, (q31_t)0x1ea11f7, (q31_t)0x8003aa36, (q31_t)0x1e3c9a6, (q31_t)0x8003924f, - (q31_t)0x1dd8154, (q31_t)0x80037ab7, (q31_t)0x1d73900, (q31_t)0x8003636e, (q31_t)0x1d0f0ab, (q31_t)0x80034c74, (q31_t)0x1caa855, (q31_t)0x800335c9, - (q31_t)0x1c45ffe, (q31_t)0x80031f6d, (q31_t)0x1be17a6, (q31_t)0x80030960, (q31_t)0x1b7cf4d, (q31_t)0x8002f3a1, (q31_t)0x1b186f3, (q31_t)0x8002de32, - (q31_t)0x1ab3e97, (q31_t)0x8002c912, (q31_t)0x1a4f63b, (q31_t)0x8002b440, (q31_t)0x19eaddd, (q31_t)0x80029fbe, (q31_t)0x198657f, (q31_t)0x80028b8a, - (q31_t)0x1921d20, (q31_t)0x800277a6, (q31_t)0x18bd4bf, (q31_t)0x80026410, (q31_t)0x1858c5e, (q31_t)0x800250c9, (q31_t)0x17f43fc, (q31_t)0x80023dd2, - (q31_t)0x178fb99, (q31_t)0x80022b29, (q31_t)0x172b335, (q31_t)0x800218cf, (q31_t)0x16c6ad0, (q31_t)0x800206c4, (q31_t)0x166226a, (q31_t)0x8001f508, - (q31_t)0x15fda03, (q31_t)0x8001e39b, (q31_t)0x159919c, (q31_t)0x8001d27d, (q31_t)0x1534934, (q31_t)0x8001c1ae, (q31_t)0x14d00ca, (q31_t)0x8001b12e, - (q31_t)0x146b860, (q31_t)0x8001a0fd, (q31_t)0x1406ff6, (q31_t)0x8001911b, (q31_t)0x13a278a, (q31_t)0x80018187, (q31_t)0x133df1e, (q31_t)0x80017243, - (q31_t)0x12d96b1, (q31_t)0x8001634e, (q31_t)0x1274e43, (q31_t)0x800154a7, (q31_t)0x12105d5, (q31_t)0x80014650, (q31_t)0x11abd66, (q31_t)0x80013847, - (q31_t)0x11474f6, (q31_t)0x80012a8e, (q31_t)0x10e2c85, (q31_t)0x80011d23, (q31_t)0x107e414, (q31_t)0x80011008, (q31_t)0x1019ba2, (q31_t)0x8001033b, - (q31_t)0x0fb5330, (q31_t)0x8000f6bd, (q31_t)0x0f50abd, (q31_t)0x8000ea8e, (q31_t)0x0eec249, (q31_t)0x8000deaf, (q31_t)0x0e879d5, (q31_t)0x8000d31e, - (q31_t)0x0e23160, (q31_t)0x8000c7dc, (q31_t)0x0dbe8eb, (q31_t)0x8000bce9, (q31_t)0x0d5a075, (q31_t)0x8000b245, (q31_t)0x0cf57ff, (q31_t)0x8000a7f0, - (q31_t)0x0c90f88, (q31_t)0x80009dea, (q31_t)0x0c2c711, (q31_t)0x80009433, (q31_t)0x0bc7e99, (q31_t)0x80008aca, (q31_t)0x0b63621, (q31_t)0x800081b1, - (q31_t)0x0afeda8, (q31_t)0x800078e7, (q31_t)0x0a9a52f, (q31_t)0x8000706c, (q31_t)0x0a35cb5, (q31_t)0x8000683f, (q31_t)0x09d143b, (q31_t)0x80006062, - (q31_t)0x096cbc1, (q31_t)0x800058d4, (q31_t)0x0908346, (q31_t)0x80005194, (q31_t)0x08a3acb, (q31_t)0x80004aa4, (q31_t)0x083f250, (q31_t)0x80004402, - (q31_t)0x07da9d4, (q31_t)0x80003daf, (q31_t)0x0776159, (q31_t)0x800037ac, (q31_t)0x07118dc, (q31_t)0x800031f7, (q31_t)0x06ad060, (q31_t)0x80002c91, - (q31_t)0x06487e3, (q31_t)0x8000277a, (q31_t)0x05e3f66, (q31_t)0x800022b3, (q31_t)0x057f6e9, (q31_t)0x80001e3a, (q31_t)0x051ae6b, (q31_t)0x80001a10, - (q31_t)0x04b65ee, (q31_t)0x80001635, (q31_t)0x0451d70, (q31_t)0x800012a9, (q31_t)0x03ed4f2, (q31_t)0x80000f6c, (q31_t)0x0388c74, (q31_t)0x80000c7e, - (q31_t)0x03243f5, (q31_t)0x800009df, (q31_t)0x02bfb77, (q31_t)0x8000078e, (q31_t)0x025b2f8, (q31_t)0x8000058d, (q31_t)0x01f6a7a, (q31_t)0x800003db, - (q31_t)0x01921fb, (q31_t)0x80000278, (q31_t)0x012d97c, (q31_t)0x80000163, (q31_t)0x00c90fe, (q31_t)0x8000009e, (q31_t)0x006487f, (q31_t)0x80000027 -}; + (q31_t)0x7fffffff, (q31_t)0x00000000, (q31_t)0x7fffffd9, (q31_t)0xfff9b781, + (q31_t)0x7fffff62, (q31_t)0xfff36f02, (q31_t)0x7ffffe9d, (q31_t)0xffed2684, + (q31_t)0x7ffffd88, (q31_t)0xffe6de05, (q31_t)0x7ffffc25, (q31_t)0xffe09586, + (q31_t)0x7ffffa73, (q31_t)0xffda4d08, (q31_t)0x7ffff872, (q31_t)0xffd40489, + (q31_t)0x7ffff621, (q31_t)0xffcdbc0b, (q31_t)0x7ffff382, (q31_t)0xffc7738c, + (q31_t)0x7ffff094, (q31_t)0xffc12b0e, (q31_t)0x7fffed57, (q31_t)0xffbae290, + (q31_t)0x7fffe9cb, (q31_t)0xffb49a12, (q31_t)0x7fffe5f0, (q31_t)0xffae5195, + (q31_t)0x7fffe1c6, (q31_t)0xffa80917, (q31_t)0x7fffdd4d, (q31_t)0xffa1c09a, + (q31_t)0x7fffd886, (q31_t)0xff9b781d, (q31_t)0x7fffd36f, (q31_t)0xff952fa0, + (q31_t)0x7fffce09, (q31_t)0xff8ee724, (q31_t)0x7fffc854, (q31_t)0xff889ea7, + (q31_t)0x7fffc251, (q31_t)0xff82562c, (q31_t)0x7fffbbfe, (q31_t)0xff7c0db0, + (q31_t)0x7fffb55c, (q31_t)0xff75c535, (q31_t)0x7fffae6c, (q31_t)0xff6f7cba, + (q31_t)0x7fffa72c, (q31_t)0xff69343f, (q31_t)0x7fff9f9e, (q31_t)0xff62ebc5, + (q31_t)0x7fff97c1, (q31_t)0xff5ca34b, (q31_t)0x7fff8f94, (q31_t)0xff565ad1, + (q31_t)0x7fff8719, (q31_t)0xff501258, (q31_t)0x7fff7e4f, (q31_t)0xff49c9df, + (q31_t)0x7fff7536, (q31_t)0xff438167, (q31_t)0x7fff6bcd, (q31_t)0xff3d38ef, + (q31_t)0x7fff6216, (q31_t)0xff36f078, (q31_t)0x7fff5810, (q31_t)0xff30a801, + (q31_t)0x7fff4dbb, (q31_t)0xff2a5f8b, (q31_t)0x7fff4317, (q31_t)0xff241715, + (q31_t)0x7fff3824, (q31_t)0xff1dcea0, (q31_t)0x7fff2ce2, (q31_t)0xff17862b, + (q31_t)0x7fff2151, (q31_t)0xff113db7, (q31_t)0x7fff1572, (q31_t)0xff0af543, + (q31_t)0x7fff0943, (q31_t)0xff04acd0, (q31_t)0x7ffefcc5, (q31_t)0xfefe645e, + (q31_t)0x7ffeeff8, (q31_t)0xfef81bec, (q31_t)0x7ffee2dd, (q31_t)0xfef1d37b, + (q31_t)0x7ffed572, (q31_t)0xfeeb8b0a, (q31_t)0x7ffec7b9, (q31_t)0xfee5429a, + (q31_t)0x7ffeb9b0, (q31_t)0xfedefa2b, (q31_t)0x7ffeab59, (q31_t)0xfed8b1bd, + (q31_t)0x7ffe9cb2, (q31_t)0xfed2694f, (q31_t)0x7ffe8dbd, (q31_t)0xfecc20e2, + (q31_t)0x7ffe7e79, (q31_t)0xfec5d876, (q31_t)0x7ffe6ee5, (q31_t)0xfebf900a, + (q31_t)0x7ffe5f03, (q31_t)0xfeb947a0, (q31_t)0x7ffe4ed2, (q31_t)0xfeb2ff36, + (q31_t)0x7ffe3e52, (q31_t)0xfeacb6cc, (q31_t)0x7ffe2d83, (q31_t)0xfea66e64, + (q31_t)0x7ffe1c65, (q31_t)0xfea025fd, (q31_t)0x7ffe0af8, (q31_t)0xfe99dd96, + (q31_t)0x7ffdf93c, (q31_t)0xfe939530, (q31_t)0x7ffde731, (q31_t)0xfe8d4ccb, + (q31_t)0x7ffdd4d7, (q31_t)0xfe870467, (q31_t)0x7ffdc22e, (q31_t)0xfe80bc04, + (q31_t)0x7ffdaf37, (q31_t)0xfe7a73a2, (q31_t)0x7ffd9bf0, (q31_t)0xfe742b41, + (q31_t)0x7ffd885a, (q31_t)0xfe6de2e0, (q31_t)0x7ffd7476, (q31_t)0xfe679a81, + (q31_t)0x7ffd6042, (q31_t)0xfe615223, (q31_t)0x7ffd4bc0, (q31_t)0xfe5b09c5, + (q31_t)0x7ffd36ee, (q31_t)0xfe54c169, (q31_t)0x7ffd21ce, (q31_t)0xfe4e790d, + (q31_t)0x7ffd0c5f, (q31_t)0xfe4830b3, (q31_t)0x7ffcf6a0, (q31_t)0xfe41e85a, + (q31_t)0x7ffce093, (q31_t)0xfe3ba002, (q31_t)0x7ffcca37, (q31_t)0xfe3557ab, + (q31_t)0x7ffcb38c, (q31_t)0xfe2f0f55, (q31_t)0x7ffc9c92, (q31_t)0xfe28c700, + (q31_t)0x7ffc8549, (q31_t)0xfe227eac, (q31_t)0x7ffc6db1, (q31_t)0xfe1c365a, + (q31_t)0x7ffc55ca, (q31_t)0xfe15ee09, (q31_t)0x7ffc3d94, (q31_t)0xfe0fa5b8, + (q31_t)0x7ffc250f, (q31_t)0xfe095d69, (q31_t)0x7ffc0c3b, (q31_t)0xfe03151c, + (q31_t)0x7ffbf319, (q31_t)0xfdfccccf, (q31_t)0x7ffbd9a7, (q31_t)0xfdf68484, + (q31_t)0x7ffbbfe6, (q31_t)0xfdf03c3a, (q31_t)0x7ffba5d7, (q31_t)0xfde9f3f1, + (q31_t)0x7ffb8b78, (q31_t)0xfde3aba9, (q31_t)0x7ffb70cb, (q31_t)0xfddd6363, + (q31_t)0x7ffb55ce, (q31_t)0xfdd71b1e, (q31_t)0x7ffb3a83, (q31_t)0xfdd0d2db, + (q31_t)0x7ffb1ee9, (q31_t)0xfdca8a99, (q31_t)0x7ffb0300, (q31_t)0xfdc44258, + (q31_t)0x7ffae6c7, (q31_t)0xfdbdfa18, (q31_t)0x7ffaca40, (q31_t)0xfdb7b1da, + (q31_t)0x7ffaad6a, (q31_t)0xfdb1699e, (q31_t)0x7ffa9045, (q31_t)0xfdab2162, + (q31_t)0x7ffa72d1, (q31_t)0xfda4d929, (q31_t)0x7ffa550e, (q31_t)0xfd9e90f0, + (q31_t)0x7ffa36fc, (q31_t)0xfd9848b9, (q31_t)0x7ffa189c, (q31_t)0xfd920084, + (q31_t)0x7ff9f9ec, (q31_t)0xfd8bb850, (q31_t)0x7ff9daed, (q31_t)0xfd85701e, + (q31_t)0x7ff9bba0, (q31_t)0xfd7f27ed, (q31_t)0x7ff99c03, (q31_t)0xfd78dfbd, + (q31_t)0x7ff97c18, (q31_t)0xfd729790, (q31_t)0x7ff95bdd, (q31_t)0xfd6c4f64, + (q31_t)0x7ff93b54, (q31_t)0xfd660739, (q31_t)0x7ff91a7b, (q31_t)0xfd5fbf10, + (q31_t)0x7ff8f954, (q31_t)0xfd5976e9, (q31_t)0x7ff8d7de, (q31_t)0xfd532ec3, + (q31_t)0x7ff8b619, (q31_t)0xfd4ce69f, (q31_t)0x7ff89405, (q31_t)0xfd469e7c, + (q31_t)0x7ff871a2, (q31_t)0xfd40565c, (q31_t)0x7ff84ef0, (q31_t)0xfd3a0e3d, + (q31_t)0x7ff82bef, (q31_t)0xfd33c61f, (q31_t)0x7ff8089f, (q31_t)0xfd2d7e04, + (q31_t)0x7ff7e500, (q31_t)0xfd2735ea, (q31_t)0x7ff7c113, (q31_t)0xfd20edd2, + (q31_t)0x7ff79cd6, (q31_t)0xfd1aa5bc, (q31_t)0x7ff7784a, (q31_t)0xfd145da7, + (q31_t)0x7ff75370, (q31_t)0xfd0e1594, (q31_t)0x7ff72e46, (q31_t)0xfd07cd83, + (q31_t)0x7ff708ce, (q31_t)0xfd018574, (q31_t)0x7ff6e307, (q31_t)0xfcfb3d67, + (q31_t)0x7ff6bcf0, (q31_t)0xfcf4f55c, (q31_t)0x7ff6968b, (q31_t)0xfceead52, + (q31_t)0x7ff66fd7, (q31_t)0xfce8654b, (q31_t)0x7ff648d4, (q31_t)0xfce21d45, + (q31_t)0x7ff62182, (q31_t)0xfcdbd541, (q31_t)0x7ff5f9e1, (q31_t)0xfcd58d3f, + (q31_t)0x7ff5d1f1, (q31_t)0xfccf453f, (q31_t)0x7ff5a9b2, (q31_t)0xfcc8fd41, + (q31_t)0x7ff58125, (q31_t)0xfcc2b545, (q31_t)0x7ff55848, (q31_t)0xfcbc6d4c, + (q31_t)0x7ff52f1d, (q31_t)0xfcb62554, (q31_t)0x7ff505a2, (q31_t)0xfcafdd5e, + (q31_t)0x7ff4dbd9, (q31_t)0xfca9956a, (q31_t)0x7ff4b1c0, (q31_t)0xfca34d78, + (q31_t)0x7ff48759, (q31_t)0xfc9d0588, (q31_t)0x7ff45ca3, (q31_t)0xfc96bd9b, + (q31_t)0x7ff4319d, (q31_t)0xfc9075af, (q31_t)0x7ff40649, (q31_t)0xfc8a2dc6, + (q31_t)0x7ff3daa6, (q31_t)0xfc83e5de, (q31_t)0x7ff3aeb4, (q31_t)0xfc7d9df9, + (q31_t)0x7ff38274, (q31_t)0xfc775616, (q31_t)0x7ff355e4, (q31_t)0xfc710e36, + (q31_t)0x7ff32905, (q31_t)0xfc6ac657, (q31_t)0x7ff2fbd7, (q31_t)0xfc647e7b, + (q31_t)0x7ff2ce5b, (q31_t)0xfc5e36a0, (q31_t)0x7ff2a08f, (q31_t)0xfc57eec9, + (q31_t)0x7ff27275, (q31_t)0xfc51a6f3, (q31_t)0x7ff2440b, (q31_t)0xfc4b5f20, + (q31_t)0x7ff21553, (q31_t)0xfc45174e, (q31_t)0x7ff1e64c, (q31_t)0xfc3ecf80, + (q31_t)0x7ff1b6f6, (q31_t)0xfc3887b3, (q31_t)0x7ff18751, (q31_t)0xfc323fe9, + (q31_t)0x7ff1575d, (q31_t)0xfc2bf821, (q31_t)0x7ff1271a, (q31_t)0xfc25b05c, + (q31_t)0x7ff0f688, (q31_t)0xfc1f6899, (q31_t)0x7ff0c5a7, (q31_t)0xfc1920d8, + (q31_t)0x7ff09478, (q31_t)0xfc12d91a, (q31_t)0x7ff062f9, (q31_t)0xfc0c915e, + (q31_t)0x7ff0312c, (q31_t)0xfc0649a5, (q31_t)0x7fefff0f, (q31_t)0xfc0001ee, + (q31_t)0x7fefcca4, (q31_t)0xfbf9ba39, (q31_t)0x7fef99ea, (q31_t)0xfbf37287, + (q31_t)0x7fef66e1, (q31_t)0xfbed2ad8, (q31_t)0x7fef3388, (q31_t)0xfbe6e32b, + (q31_t)0x7feeffe1, (q31_t)0xfbe09b80, (q31_t)0x7feecbec, (q31_t)0xfbda53d8, + (q31_t)0x7fee97a7, (q31_t)0xfbd40c33, (q31_t)0x7fee6313, (q31_t)0xfbcdc490, + (q31_t)0x7fee2e30, (q31_t)0xfbc77cf0, (q31_t)0x7fedf8ff, (q31_t)0xfbc13552, + (q31_t)0x7fedc37e, (q31_t)0xfbbaedb7, (q31_t)0x7fed8daf, (q31_t)0xfbb4a61f, + (q31_t)0x7fed5791, (q31_t)0xfbae5e89, (q31_t)0x7fed2123, (q31_t)0xfba816f6, + (q31_t)0x7fecea67, (q31_t)0xfba1cf66, (q31_t)0x7fecb35c, (q31_t)0xfb9b87d8, + (q31_t)0x7fec7c02, (q31_t)0xfb95404d, (q31_t)0x7fec4459, (q31_t)0xfb8ef8c5, + (q31_t)0x7fec0c62, (q31_t)0xfb88b13f, (q31_t)0x7febd41b, (q31_t)0xfb8269bd, + (q31_t)0x7feb9b85, (q31_t)0xfb7c223d, (q31_t)0x7feb62a1, (q31_t)0xfb75dac0, + (q31_t)0x7feb296d, (q31_t)0xfb6f9345, (q31_t)0x7feaefeb, (q31_t)0xfb694bce, + (q31_t)0x7feab61a, (q31_t)0xfb630459, (q31_t)0x7fea7bfa, (q31_t)0xfb5cbce7, + (q31_t)0x7fea418b, (q31_t)0xfb567578, (q31_t)0x7fea06cd, (q31_t)0xfb502e0c, + (q31_t)0x7fe9cbc0, (q31_t)0xfb49e6a3, (q31_t)0x7fe99064, (q31_t)0xfb439f3c, + (q31_t)0x7fe954ba, (q31_t)0xfb3d57d9, (q31_t)0x7fe918c0, (q31_t)0xfb371078, + (q31_t)0x7fe8dc78, (q31_t)0xfb30c91b, (q31_t)0x7fe89fe0, (q31_t)0xfb2a81c0, + (q31_t)0x7fe862fa, (q31_t)0xfb243a69, (q31_t)0x7fe825c5, (q31_t)0xfb1df314, + (q31_t)0x7fe7e841, (q31_t)0xfb17abc2, (q31_t)0x7fe7aa6e, (q31_t)0xfb116474, + (q31_t)0x7fe76c4c, (q31_t)0xfb0b1d28, (q31_t)0x7fe72ddb, (q31_t)0xfb04d5e0, + (q31_t)0x7fe6ef1c, (q31_t)0xfafe8e9b, (q31_t)0x7fe6b00d, (q31_t)0xfaf84758, + (q31_t)0x7fe670b0, (q31_t)0xfaf20019, (q31_t)0x7fe63103, (q31_t)0xfaebb8dd, + (q31_t)0x7fe5f108, (q31_t)0xfae571a4, (q31_t)0x7fe5b0be, (q31_t)0xfadf2a6e, + (q31_t)0x7fe57025, (q31_t)0xfad8e33c, (q31_t)0x7fe52f3d, (q31_t)0xfad29c0c, + (q31_t)0x7fe4ee06, (q31_t)0xfacc54e0, (q31_t)0x7fe4ac81, (q31_t)0xfac60db7, + (q31_t)0x7fe46aac, (q31_t)0xfabfc691, (q31_t)0x7fe42889, (q31_t)0xfab97f6e, + (q31_t)0x7fe3e616, (q31_t)0xfab3384f, (q31_t)0x7fe3a355, (q31_t)0xfaacf133, + (q31_t)0x7fe36045, (q31_t)0xfaa6aa1a, (q31_t)0x7fe31ce6, (q31_t)0xfaa06305, + (q31_t)0x7fe2d938, (q31_t)0xfa9a1bf3, (q31_t)0x7fe2953b, (q31_t)0xfa93d4e4, + (q31_t)0x7fe250ef, (q31_t)0xfa8d8dd8, (q31_t)0x7fe20c55, (q31_t)0xfa8746d0, + (q31_t)0x7fe1c76b, (q31_t)0xfa80ffcb, (q31_t)0x7fe18233, (q31_t)0xfa7ab8ca, + (q31_t)0x7fe13cac, (q31_t)0xfa7471cc, (q31_t)0x7fe0f6d6, (q31_t)0xfa6e2ad1, + (q31_t)0x7fe0b0b1, (q31_t)0xfa67e3da, (q31_t)0x7fe06a3d, (q31_t)0xfa619ce7, + (q31_t)0x7fe0237a, (q31_t)0xfa5b55f7, (q31_t)0x7fdfdc69, (q31_t)0xfa550f0a, + (q31_t)0x7fdf9508, (q31_t)0xfa4ec821, (q31_t)0x7fdf4d59, (q31_t)0xfa48813b, + (q31_t)0x7fdf055a, (q31_t)0xfa423a59, (q31_t)0x7fdebd0d, (q31_t)0xfa3bf37a, + (q31_t)0x7fde7471, (q31_t)0xfa35ac9f, (q31_t)0x7fde2b86, (q31_t)0xfa2f65c8, + (q31_t)0x7fdde24d, (q31_t)0xfa291ef4, (q31_t)0x7fdd98c4, (q31_t)0xfa22d823, + (q31_t)0x7fdd4eec, (q31_t)0xfa1c9157, (q31_t)0x7fdd04c6, (q31_t)0xfa164a8e, + (q31_t)0x7fdcba51, (q31_t)0xfa1003c8, (q31_t)0x7fdc6f8d, (q31_t)0xfa09bd06, + (q31_t)0x7fdc247a, (q31_t)0xfa037648, (q31_t)0x7fdbd918, (q31_t)0xf9fd2f8e, + (q31_t)0x7fdb8d67, (q31_t)0xf9f6e8d7, (q31_t)0x7fdb4167, (q31_t)0xf9f0a224, + (q31_t)0x7fdaf519, (q31_t)0xf9ea5b75, (q31_t)0x7fdaa87c, (q31_t)0xf9e414ca, + (q31_t)0x7fda5b8f, (q31_t)0xf9ddce22, (q31_t)0x7fda0e54, (q31_t)0xf9d7877e, + (q31_t)0x7fd9c0ca, (q31_t)0xf9d140de, (q31_t)0x7fd972f2, (q31_t)0xf9cafa42, + (q31_t)0x7fd924ca, (q31_t)0xf9c4b3a9, (q31_t)0x7fd8d653, (q31_t)0xf9be6d15, + (q31_t)0x7fd8878e, (q31_t)0xf9b82684, (q31_t)0x7fd8387a, (q31_t)0xf9b1dff7, + (q31_t)0x7fd7e917, (q31_t)0xf9ab996e, (q31_t)0x7fd79965, (q31_t)0xf9a552e9, + (q31_t)0x7fd74964, (q31_t)0xf99f0c68, (q31_t)0x7fd6f914, (q31_t)0xf998c5ea, + (q31_t)0x7fd6a875, (q31_t)0xf9927f71, (q31_t)0x7fd65788, (q31_t)0xf98c38fc, + (q31_t)0x7fd6064c, (q31_t)0xf985f28a, (q31_t)0x7fd5b4c1, (q31_t)0xf97fac1d, + (q31_t)0x7fd562e7, (q31_t)0xf97965b4, (q31_t)0x7fd510be, (q31_t)0xf9731f4e, + (q31_t)0x7fd4be46, (q31_t)0xf96cd8ed, (q31_t)0x7fd46b80, (q31_t)0xf9669290, + (q31_t)0x7fd4186a, (q31_t)0xf9604c37, (q31_t)0x7fd3c506, (q31_t)0xf95a05e2, + (q31_t)0x7fd37153, (q31_t)0xf953bf91, (q31_t)0x7fd31d51, (q31_t)0xf94d7944, + (q31_t)0x7fd2c900, (q31_t)0xf94732fb, (q31_t)0x7fd27460, (q31_t)0xf940ecb7, + (q31_t)0x7fd21f72, (q31_t)0xf93aa676, (q31_t)0x7fd1ca35, (q31_t)0xf934603a, + (q31_t)0x7fd174a8, (q31_t)0xf92e1a02, (q31_t)0x7fd11ecd, (q31_t)0xf927d3ce, + (q31_t)0x7fd0c8a3, (q31_t)0xf9218d9e, (q31_t)0x7fd0722b, (q31_t)0xf91b4773, + (q31_t)0x7fd01b63, (q31_t)0xf915014c, (q31_t)0x7fcfc44d, (q31_t)0xf90ebb29, + (q31_t)0x7fcf6ce8, (q31_t)0xf908750a, (q31_t)0x7fcf1533, (q31_t)0xf9022ef0, + (q31_t)0x7fcebd31, (q31_t)0xf8fbe8da, (q31_t)0x7fce64df, (q31_t)0xf8f5a2c9, + (q31_t)0x7fce0c3e, (q31_t)0xf8ef5cbb, (q31_t)0x7fcdb34f, (q31_t)0xf8e916b2, + (q31_t)0x7fcd5a11, (q31_t)0xf8e2d0ae, (q31_t)0x7fcd0083, (q31_t)0xf8dc8aae, + (q31_t)0x7fcca6a7, (q31_t)0xf8d644b2, (q31_t)0x7fcc4c7d, (q31_t)0xf8cffebb, + (q31_t)0x7fcbf203, (q31_t)0xf8c9b8c8, (q31_t)0x7fcb973b, (q31_t)0xf8c372d9, + (q31_t)0x7fcb3c23, (q31_t)0xf8bd2cef, (q31_t)0x7fcae0bd, (q31_t)0xf8b6e70a, + (q31_t)0x7fca8508, (q31_t)0xf8b0a129, (q31_t)0x7fca2905, (q31_t)0xf8aa5b4c, + (q31_t)0x7fc9ccb2, (q31_t)0xf8a41574, (q31_t)0x7fc97011, (q31_t)0xf89dcfa1, + (q31_t)0x7fc91320, (q31_t)0xf89789d2, (q31_t)0x7fc8b5e1, (q31_t)0xf8914407, + (q31_t)0x7fc85854, (q31_t)0xf88afe42, (q31_t)0x7fc7fa77, (q31_t)0xf884b880, + (q31_t)0x7fc79c4b, (q31_t)0xf87e72c4, (q31_t)0x7fc73dd1, (q31_t)0xf8782d0c, + (q31_t)0x7fc6df08, (q31_t)0xf871e759, (q31_t)0x7fc67ff0, (q31_t)0xf86ba1aa, + (q31_t)0x7fc62089, (q31_t)0xf8655c00, (q31_t)0x7fc5c0d3, (q31_t)0xf85f165b, + (q31_t)0x7fc560cf, (q31_t)0xf858d0bb, (q31_t)0x7fc5007c, (q31_t)0xf8528b1f, + (q31_t)0x7fc49fda, (q31_t)0xf84c4588, (q31_t)0x7fc43ee9, (q31_t)0xf845fff5, + (q31_t)0x7fc3dda9, (q31_t)0xf83fba68, (q31_t)0x7fc37c1b, (q31_t)0xf83974df, + (q31_t)0x7fc31a3d, (q31_t)0xf8332f5b, (q31_t)0x7fc2b811, (q31_t)0xf82ce9dc, + (q31_t)0x7fc25596, (q31_t)0xf826a462, (q31_t)0x7fc1f2cc, (q31_t)0xf8205eec, + (q31_t)0x7fc18fb4, (q31_t)0xf81a197b, (q31_t)0x7fc12c4d, (q31_t)0xf813d410, + (q31_t)0x7fc0c896, (q31_t)0xf80d8ea9, (q31_t)0x7fc06491, (q31_t)0xf8074947, + (q31_t)0x7fc0003e, (q31_t)0xf80103ea, (q31_t)0x7fbf9b9b, (q31_t)0xf7fabe92, + (q31_t)0x7fbf36aa, (q31_t)0xf7f4793e, (q31_t)0x7fbed16a, (q31_t)0xf7ee33f0, + (q31_t)0x7fbe6bdb, (q31_t)0xf7e7eea7, (q31_t)0x7fbe05fd, (q31_t)0xf7e1a963, + (q31_t)0x7fbd9fd0, (q31_t)0xf7db6423, (q31_t)0x7fbd3955, (q31_t)0xf7d51ee9, + (q31_t)0x7fbcd28b, (q31_t)0xf7ced9b4, (q31_t)0x7fbc6b72, (q31_t)0xf7c89484, + (q31_t)0x7fbc040a, (q31_t)0xf7c24f59, (q31_t)0x7fbb9c53, (q31_t)0xf7bc0a33, + (q31_t)0x7fbb344e, (q31_t)0xf7b5c512, (q31_t)0x7fbacbfa, (q31_t)0xf7af7ff6, + (q31_t)0x7fba6357, (q31_t)0xf7a93ae0, (q31_t)0x7fb9fa65, (q31_t)0xf7a2f5ce, + (q31_t)0x7fb99125, (q31_t)0xf79cb0c2, (q31_t)0x7fb92796, (q31_t)0xf7966bbb, + (q31_t)0x7fb8bdb8, (q31_t)0xf79026b9, (q31_t)0x7fb8538b, (q31_t)0xf789e1bc, + (q31_t)0x7fb7e90f, (q31_t)0xf7839cc4, (q31_t)0x7fb77e45, (q31_t)0xf77d57d2, + (q31_t)0x7fb7132b, (q31_t)0xf77712e5, (q31_t)0x7fb6a7c3, (q31_t)0xf770cdfd, + (q31_t)0x7fb63c0d, (q31_t)0xf76a891b, (q31_t)0x7fb5d007, (q31_t)0xf764443d, + (q31_t)0x7fb563b3, (q31_t)0xf75dff66, (q31_t)0x7fb4f710, (q31_t)0xf757ba93, + (q31_t)0x7fb48a1e, (q31_t)0xf75175c6, (q31_t)0x7fb41cdd, (q31_t)0xf74b30fe, + (q31_t)0x7fb3af4e, (q31_t)0xf744ec3b, (q31_t)0x7fb34170, (q31_t)0xf73ea77e, + (q31_t)0x7fb2d343, (q31_t)0xf73862c6, (q31_t)0x7fb264c7, (q31_t)0xf7321e14, + (q31_t)0x7fb1f5fc, (q31_t)0xf72bd967, (q31_t)0x7fb186e3, (q31_t)0xf72594c0, + (q31_t)0x7fb1177b, (q31_t)0xf71f501e, (q31_t)0x7fb0a7c4, (q31_t)0xf7190b81, + (q31_t)0x7fb037bf, (q31_t)0xf712c6ea, (q31_t)0x7fafc76a, (q31_t)0xf70c8259, + (q31_t)0x7faf56c7, (q31_t)0xf7063dcd, (q31_t)0x7faee5d5, (q31_t)0xf6fff946, + (q31_t)0x7fae7495, (q31_t)0xf6f9b4c6, (q31_t)0x7fae0305, (q31_t)0xf6f3704a, + (q31_t)0x7fad9127, (q31_t)0xf6ed2bd4, (q31_t)0x7fad1efa, (q31_t)0xf6e6e764, + (q31_t)0x7facac7f, (q31_t)0xf6e0a2fa, (q31_t)0x7fac39b4, (q31_t)0xf6da5e95, + (q31_t)0x7fabc69b, (q31_t)0xf6d41a36, (q31_t)0x7fab5333, (q31_t)0xf6cdd5dc, + (q31_t)0x7faadf7c, (q31_t)0xf6c79188, (q31_t)0x7faa6b77, (q31_t)0xf6c14d3a, + (q31_t)0x7fa9f723, (q31_t)0xf6bb08f1, (q31_t)0x7fa98280, (q31_t)0xf6b4c4ae, + (q31_t)0x7fa90d8e, (q31_t)0xf6ae8071, (q31_t)0x7fa8984e, (q31_t)0xf6a83c3a, + (q31_t)0x7fa822bf, (q31_t)0xf6a1f808, (q31_t)0x7fa7ace1, (q31_t)0xf69bb3dd, + (q31_t)0x7fa736b4, (q31_t)0xf6956fb7, (q31_t)0x7fa6c039, (q31_t)0xf68f2b96, + (q31_t)0x7fa6496e, (q31_t)0xf688e77c, (q31_t)0x7fa5d256, (q31_t)0xf682a367, + (q31_t)0x7fa55aee, (q31_t)0xf67c5f59, (q31_t)0x7fa4e338, (q31_t)0xf6761b50, + (q31_t)0x7fa46b32, (q31_t)0xf66fd74d, (q31_t)0x7fa3f2df, (q31_t)0xf6699350, + (q31_t)0x7fa37a3c, (q31_t)0xf6634f59, (q31_t)0x7fa3014b, (q31_t)0xf65d0b68, + (q31_t)0x7fa2880b, (q31_t)0xf656c77c, (q31_t)0x7fa20e7c, (q31_t)0xf6508397, + (q31_t)0x7fa1949e, (q31_t)0xf64a3fb8, (q31_t)0x7fa11a72, (q31_t)0xf643fbdf, + (q31_t)0x7fa09ff7, (q31_t)0xf63db80b, (q31_t)0x7fa0252e, (q31_t)0xf637743e, + (q31_t)0x7f9faa15, (q31_t)0xf6313077, (q31_t)0x7f9f2eae, (q31_t)0xf62aecb5, + (q31_t)0x7f9eb2f8, (q31_t)0xf624a8fa, (q31_t)0x7f9e36f4, (q31_t)0xf61e6545, + (q31_t)0x7f9dbaa0, (q31_t)0xf6182196, (q31_t)0x7f9d3dfe, (q31_t)0xf611dded, + (q31_t)0x7f9cc10d, (q31_t)0xf60b9a4b, (q31_t)0x7f9c43ce, (q31_t)0xf60556ae, + (q31_t)0x7f9bc640, (q31_t)0xf5ff1318, (q31_t)0x7f9b4863, (q31_t)0xf5f8cf87, + (q31_t)0x7f9aca37, (q31_t)0xf5f28bfd, (q31_t)0x7f9a4bbd, (q31_t)0xf5ec4879, + (q31_t)0x7f99ccf4, (q31_t)0xf5e604fc, (q31_t)0x7f994ddc, (q31_t)0xf5dfc184, + (q31_t)0x7f98ce76, (q31_t)0xf5d97e13, (q31_t)0x7f984ec1, (q31_t)0xf5d33aa8, + (q31_t)0x7f97cebd, (q31_t)0xf5ccf743, (q31_t)0x7f974e6a, (q31_t)0xf5c6b3e5, + (q31_t)0x7f96cdc9, (q31_t)0xf5c0708d, (q31_t)0x7f964cd9, (q31_t)0xf5ba2d3b, + (q31_t)0x7f95cb9a, (q31_t)0xf5b3e9f0, (q31_t)0x7f954a0d, (q31_t)0xf5ada6ab, + (q31_t)0x7f94c831, (q31_t)0xf5a7636c, (q31_t)0x7f944606, (q31_t)0xf5a12034, + (q31_t)0x7f93c38c, (q31_t)0xf59add02, (q31_t)0x7f9340c4, (q31_t)0xf59499d6, + (q31_t)0x7f92bdad, (q31_t)0xf58e56b1, (q31_t)0x7f923a48, (q31_t)0xf5881393, + (q31_t)0x7f91b694, (q31_t)0xf581d07b, (q31_t)0x7f913291, (q31_t)0xf57b8d69, + (q31_t)0x7f90ae3f, (q31_t)0xf5754a5e, (q31_t)0x7f90299f, (q31_t)0xf56f0759, + (q31_t)0x7f8fa4b0, (q31_t)0xf568c45b, (q31_t)0x7f8f1f72, (q31_t)0xf5628163, + (q31_t)0x7f8e99e6, (q31_t)0xf55c3e72, (q31_t)0x7f8e140a, (q31_t)0xf555fb88, + (q31_t)0x7f8d8de1, (q31_t)0xf54fb8a4, (q31_t)0x7f8d0768, (q31_t)0xf54975c6, + (q31_t)0x7f8c80a1, (q31_t)0xf54332ef, (q31_t)0x7f8bf98b, (q31_t)0xf53cf01f, + (q31_t)0x7f8b7227, (q31_t)0xf536ad56, (q31_t)0x7f8aea74, (q31_t)0xf5306a93, + (q31_t)0x7f8a6272, (q31_t)0xf52a27d7, (q31_t)0x7f89da21, (q31_t)0xf523e521, + (q31_t)0x7f895182, (q31_t)0xf51da273, (q31_t)0x7f88c894, (q31_t)0xf5175fca, + (q31_t)0x7f883f58, (q31_t)0xf5111d29, (q31_t)0x7f87b5cd, (q31_t)0xf50ada8f, + (q31_t)0x7f872bf3, (q31_t)0xf50497fb, (q31_t)0x7f86a1ca, (q31_t)0xf4fe556e, + (q31_t)0x7f861753, (q31_t)0xf4f812e7, (q31_t)0x7f858c8d, (q31_t)0xf4f1d068, + (q31_t)0x7f850179, (q31_t)0xf4eb8def, (q31_t)0x7f847616, (q31_t)0xf4e54b7d, + (q31_t)0x7f83ea64, (q31_t)0xf4df0912, (q31_t)0x7f835e64, (q31_t)0xf4d8c6ae, + (q31_t)0x7f82d214, (q31_t)0xf4d28451, (q31_t)0x7f824577, (q31_t)0xf4cc41fb, + (q31_t)0x7f81b88a, (q31_t)0xf4c5ffab, (q31_t)0x7f812b4f, (q31_t)0xf4bfbd63, + (q31_t)0x7f809dc5, (q31_t)0xf4b97b21, (q31_t)0x7f800fed, (q31_t)0xf4b338e7, + (q31_t)0x7f7f81c6, (q31_t)0xf4acf6b3, (q31_t)0x7f7ef350, (q31_t)0xf4a6b486, + (q31_t)0x7f7e648c, (q31_t)0xf4a07261, (q31_t)0x7f7dd579, (q31_t)0xf49a3042, + (q31_t)0x7f7d4617, (q31_t)0xf493ee2b, (q31_t)0x7f7cb667, (q31_t)0xf48dac1a, + (q31_t)0x7f7c2668, (q31_t)0xf4876a10, (q31_t)0x7f7b961b, (q31_t)0xf481280e, + (q31_t)0x7f7b057e, (q31_t)0xf47ae613, (q31_t)0x7f7a7494, (q31_t)0xf474a41f, + (q31_t)0x7f79e35a, (q31_t)0xf46e6231, (q31_t)0x7f7951d2, (q31_t)0xf468204b, + (q31_t)0x7f78bffb, (q31_t)0xf461de6d, (q31_t)0x7f782dd6, (q31_t)0xf45b9c95, + (q31_t)0x7f779b62, (q31_t)0xf4555ac5, (q31_t)0x7f77089f, (q31_t)0xf44f18fb, + (q31_t)0x7f76758e, (q31_t)0xf448d739, (q31_t)0x7f75e22e, (q31_t)0xf442957e, + (q31_t)0x7f754e80, (q31_t)0xf43c53cb, (q31_t)0x7f74ba83, (q31_t)0xf436121e, + (q31_t)0x7f742637, (q31_t)0xf42fd079, (q31_t)0x7f73919d, (q31_t)0xf4298edc, + (q31_t)0x7f72fcb4, (q31_t)0xf4234d45, (q31_t)0x7f72677c, (q31_t)0xf41d0bb6, + (q31_t)0x7f71d1f6, (q31_t)0xf416ca2e, (q31_t)0x7f713c21, (q31_t)0xf41088ae, + (q31_t)0x7f70a5fe, (q31_t)0xf40a4735, (q31_t)0x7f700f8c, (q31_t)0xf40405c3, + (q31_t)0x7f6f78cb, (q31_t)0xf3fdc459, (q31_t)0x7f6ee1bc, (q31_t)0xf3f782f6, + (q31_t)0x7f6e4a5e, (q31_t)0xf3f1419a, (q31_t)0x7f6db2b1, (q31_t)0xf3eb0046, + (q31_t)0x7f6d1ab6, (q31_t)0xf3e4bef9, (q31_t)0x7f6c826d, (q31_t)0xf3de7db4, + (q31_t)0x7f6be9d4, (q31_t)0xf3d83c77, (q31_t)0x7f6b50ed, (q31_t)0xf3d1fb40, + (q31_t)0x7f6ab7b8, (q31_t)0xf3cbba12, (q31_t)0x7f6a1e34, (q31_t)0xf3c578eb, + (q31_t)0x7f698461, (q31_t)0xf3bf37cb, (q31_t)0x7f68ea40, (q31_t)0xf3b8f6b3, + (q31_t)0x7f684fd0, (q31_t)0xf3b2b5a3, (q31_t)0x7f67b512, (q31_t)0xf3ac749a, + (q31_t)0x7f671a05, (q31_t)0xf3a63398, (q31_t)0x7f667ea9, (q31_t)0xf39ff29f, + (q31_t)0x7f65e2ff, (q31_t)0xf399b1ad, (q31_t)0x7f654706, (q31_t)0xf39370c2, + (q31_t)0x7f64aabf, (q31_t)0xf38d2fe0, (q31_t)0x7f640e29, (q31_t)0xf386ef05, + (q31_t)0x7f637144, (q31_t)0xf380ae31, (q31_t)0x7f62d411, (q31_t)0xf37a6d66, + (q31_t)0x7f62368f, (q31_t)0xf3742ca2, (q31_t)0x7f6198bf, (q31_t)0xf36debe6, + (q31_t)0x7f60faa0, (q31_t)0xf367ab31, (q31_t)0x7f605c33, (q31_t)0xf3616a85, + (q31_t)0x7f5fbd77, (q31_t)0xf35b29e0, (q31_t)0x7f5f1e6c, (q31_t)0xf354e943, + (q31_t)0x7f5e7f13, (q31_t)0xf34ea8ae, (q31_t)0x7f5ddf6b, (q31_t)0xf3486820, + (q31_t)0x7f5d3f75, (q31_t)0xf342279b, (q31_t)0x7f5c9f30, (q31_t)0xf33be71d, + (q31_t)0x7f5bfe9d, (q31_t)0xf335a6a7, (q31_t)0x7f5b5dbb, (q31_t)0xf32f6639, + (q31_t)0x7f5abc8a, (q31_t)0xf32925d3, (q31_t)0x7f5a1b0b, (q31_t)0xf322e575, + (q31_t)0x7f59793e, (q31_t)0xf31ca51f, (q31_t)0x7f58d721, (q31_t)0xf31664d1, + (q31_t)0x7f5834b7, (q31_t)0xf310248a, (q31_t)0x7f5791fd, (q31_t)0xf309e44c, + (q31_t)0x7f56eef5, (q31_t)0xf303a416, (q31_t)0x7f564b9f, (q31_t)0xf2fd63e8, + (q31_t)0x7f55a7fa, (q31_t)0xf2f723c1, (q31_t)0x7f550407, (q31_t)0xf2f0e3a3, + (q31_t)0x7f545fc5, (q31_t)0xf2eaa38d, (q31_t)0x7f53bb34, (q31_t)0xf2e4637f, + (q31_t)0x7f531655, (q31_t)0xf2de2379, (q31_t)0x7f527127, (q31_t)0xf2d7e37b, + (q31_t)0x7f51cbab, (q31_t)0xf2d1a385, (q31_t)0x7f5125e0, (q31_t)0xf2cb6398, + (q31_t)0x7f507fc7, (q31_t)0xf2c523b2, (q31_t)0x7f4fd95f, (q31_t)0xf2bee3d5, + (q31_t)0x7f4f32a9, (q31_t)0xf2b8a400, (q31_t)0x7f4e8ba4, (q31_t)0xf2b26433, + (q31_t)0x7f4de451, (q31_t)0xf2ac246e, (q31_t)0x7f4d3caf, (q31_t)0xf2a5e4b1, + (q31_t)0x7f4c94be, (q31_t)0xf29fa4fd, (q31_t)0x7f4bec7f, (q31_t)0xf2996551, + (q31_t)0x7f4b43f2, (q31_t)0xf29325ad, (q31_t)0x7f4a9b16, (q31_t)0xf28ce612, + (q31_t)0x7f49f1eb, (q31_t)0xf286a67e, (q31_t)0x7f494872, (q31_t)0xf28066f4, + (q31_t)0x7f489eaa, (q31_t)0xf27a2771, (q31_t)0x7f47f494, (q31_t)0xf273e7f7, + (q31_t)0x7f474a30, (q31_t)0xf26da885, (q31_t)0x7f469f7d, (q31_t)0xf267691b, + (q31_t)0x7f45f47b, (q31_t)0xf26129ba, (q31_t)0x7f45492b, (q31_t)0xf25aea61, + (q31_t)0x7f449d8c, (q31_t)0xf254ab11, (q31_t)0x7f43f19f, (q31_t)0xf24e6bc9, + (q31_t)0x7f434563, (q31_t)0xf2482c8a, (q31_t)0x7f4298d9, (q31_t)0xf241ed53, + (q31_t)0x7f41ec01, (q31_t)0xf23bae24, (q31_t)0x7f413ed9, (q31_t)0xf2356efe, + (q31_t)0x7f409164, (q31_t)0xf22f2fe1, (q31_t)0x7f3fe3a0, (q31_t)0xf228f0cc, + (q31_t)0x7f3f358d, (q31_t)0xf222b1c0, (q31_t)0x7f3e872c, (q31_t)0xf21c72bc, + (q31_t)0x7f3dd87c, (q31_t)0xf21633c0, (q31_t)0x7f3d297e, (q31_t)0xf20ff4ce, + (q31_t)0x7f3c7a31, (q31_t)0xf209b5e4, (q31_t)0x7f3bca96, (q31_t)0xf2037702, + (q31_t)0x7f3b1aad, (q31_t)0xf1fd3829, (q31_t)0x7f3a6a75, (q31_t)0xf1f6f959, + (q31_t)0x7f39b9ee, (q31_t)0xf1f0ba91, (q31_t)0x7f390919, (q31_t)0xf1ea7bd2, + (q31_t)0x7f3857f6, (q31_t)0xf1e43d1c, (q31_t)0x7f37a684, (q31_t)0xf1ddfe6f, + (q31_t)0x7f36f4c3, (q31_t)0xf1d7bfca, (q31_t)0x7f3642b4, (q31_t)0xf1d1812e, + (q31_t)0x7f359057, (q31_t)0xf1cb429a, (q31_t)0x7f34ddab, (q31_t)0xf1c50410, + (q31_t)0x7f342ab1, (q31_t)0xf1bec58e, (q31_t)0x7f337768, (q31_t)0xf1b88715, + (q31_t)0x7f32c3d1, (q31_t)0xf1b248a5, (q31_t)0x7f320feb, (q31_t)0xf1ac0a3e, + (q31_t)0x7f315bb7, (q31_t)0xf1a5cbdf, (q31_t)0x7f30a734, (q31_t)0xf19f8d89, + (q31_t)0x7f2ff263, (q31_t)0xf1994f3d, (q31_t)0x7f2f3d44, (q31_t)0xf19310f9, + (q31_t)0x7f2e87d6, (q31_t)0xf18cd2be, (q31_t)0x7f2dd219, (q31_t)0xf186948c, + (q31_t)0x7f2d1c0e, (q31_t)0xf1805662, (q31_t)0x7f2c65b5, (q31_t)0xf17a1842, + (q31_t)0x7f2baf0d, (q31_t)0xf173da2b, (q31_t)0x7f2af817, (q31_t)0xf16d9c1d, + (q31_t)0x7f2a40d2, (q31_t)0xf1675e17, (q31_t)0x7f29893f, (q31_t)0xf161201b, + (q31_t)0x7f28d15d, (q31_t)0xf15ae228, (q31_t)0x7f28192d, (q31_t)0xf154a43d, + (q31_t)0x7f2760af, (q31_t)0xf14e665c, (q31_t)0x7f26a7e2, (q31_t)0xf1482884, + (q31_t)0x7f25eec7, (q31_t)0xf141eab5, (q31_t)0x7f25355d, (q31_t)0xf13bacef, + (q31_t)0x7f247ba5, (q31_t)0xf1356f32, (q31_t)0x7f23c19e, (q31_t)0xf12f317e, + (q31_t)0x7f230749, (q31_t)0xf128f3d4, (q31_t)0x7f224ca6, (q31_t)0xf122b632, + (q31_t)0x7f2191b4, (q31_t)0xf11c789a, (q31_t)0x7f20d674, (q31_t)0xf1163b0b, + (q31_t)0x7f201ae5, (q31_t)0xf10ffd85, (q31_t)0x7f1f5f08, (q31_t)0xf109c009, + (q31_t)0x7f1ea2dc, (q31_t)0xf1038295, (q31_t)0x7f1de662, (q31_t)0xf0fd452b, + (q31_t)0x7f1d299a, (q31_t)0xf0f707ca, (q31_t)0x7f1c6c83, (q31_t)0xf0f0ca72, + (q31_t)0x7f1baf1e, (q31_t)0xf0ea8d24, (q31_t)0x7f1af16a, (q31_t)0xf0e44fdf, + (q31_t)0x7f1a3368, (q31_t)0xf0de12a3, (q31_t)0x7f197518, (q31_t)0xf0d7d571, + (q31_t)0x7f18b679, (q31_t)0xf0d19848, (q31_t)0x7f17f78c, (q31_t)0xf0cb5b28, + (q31_t)0x7f173850, (q31_t)0xf0c51e12, (q31_t)0x7f1678c6, (q31_t)0xf0bee105, + (q31_t)0x7f15b8ee, (q31_t)0xf0b8a401, (q31_t)0x7f14f8c7, (q31_t)0xf0b26707, + (q31_t)0x7f143852, (q31_t)0xf0ac2a16, (q31_t)0x7f13778e, (q31_t)0xf0a5ed2f, + (q31_t)0x7f12b67c, (q31_t)0xf09fb051, (q31_t)0x7f11f51c, (q31_t)0xf099737d, + (q31_t)0x7f11336d, (q31_t)0xf09336b2, (q31_t)0x7f107170, (q31_t)0xf08cf9f1, + (q31_t)0x7f0faf25, (q31_t)0xf086bd39, (q31_t)0x7f0eec8b, (q31_t)0xf080808b, + (q31_t)0x7f0e29a3, (q31_t)0xf07a43e7, (q31_t)0x7f0d666c, (q31_t)0xf074074c, + (q31_t)0x7f0ca2e7, (q31_t)0xf06dcaba, (q31_t)0x7f0bdf14, (q31_t)0xf0678e32, + (q31_t)0x7f0b1af2, (q31_t)0xf06151b4, (q31_t)0x7f0a5682, (q31_t)0xf05b1540, + (q31_t)0x7f0991c4, (q31_t)0xf054d8d5, (q31_t)0x7f08ccb7, (q31_t)0xf04e9c73, + (q31_t)0x7f08075c, (q31_t)0xf048601c, (q31_t)0x7f0741b2, (q31_t)0xf04223ce, + (q31_t)0x7f067bba, (q31_t)0xf03be78a, (q31_t)0x7f05b574, (q31_t)0xf035ab4f, + (q31_t)0x7f04eedf, (q31_t)0xf02f6f1f, (q31_t)0x7f0427fc, (q31_t)0xf02932f8, + (q31_t)0x7f0360cb, (q31_t)0xf022f6da, (q31_t)0x7f02994b, (q31_t)0xf01cbac7, + (q31_t)0x7f01d17d, (q31_t)0xf0167ebd, (q31_t)0x7f010961, (q31_t)0xf01042be, + (q31_t)0x7f0040f6, (q31_t)0xf00a06c8, (q31_t)0x7eff783d, (q31_t)0xf003cadc, + (q31_t)0x7efeaf36, (q31_t)0xeffd8ef9, (q31_t)0x7efde5e0, (q31_t)0xeff75321, + (q31_t)0x7efd1c3c, (q31_t)0xeff11753, (q31_t)0x7efc524a, (q31_t)0xefeadb8e, + (q31_t)0x7efb8809, (q31_t)0xefe49fd3, (q31_t)0x7efabd7a, (q31_t)0xefde6423, + (q31_t)0x7ef9f29d, (q31_t)0xefd8287c, (q31_t)0x7ef92771, (q31_t)0xefd1ecdf, + (q31_t)0x7ef85bf7, (q31_t)0xefcbb14c, (q31_t)0x7ef7902f, (q31_t)0xefc575c3, + (q31_t)0x7ef6c418, (q31_t)0xefbf3a45, (q31_t)0x7ef5f7b3, (q31_t)0xefb8fed0, + (q31_t)0x7ef52b00, (q31_t)0xefb2c365, (q31_t)0x7ef45dfe, (q31_t)0xefac8804, + (q31_t)0x7ef390ae, (q31_t)0xefa64cae, (q31_t)0x7ef2c310, (q31_t)0xefa01161, + (q31_t)0x7ef1f524, (q31_t)0xef99d61f, (q31_t)0x7ef126e9, (q31_t)0xef939ae6, + (q31_t)0x7ef05860, (q31_t)0xef8d5fb8, (q31_t)0x7eef8988, (q31_t)0xef872494, + (q31_t)0x7eeeba62, (q31_t)0xef80e97a, (q31_t)0x7eedeaee, (q31_t)0xef7aae6b, + (q31_t)0x7eed1b2c, (q31_t)0xef747365, (q31_t)0x7eec4b1b, (q31_t)0xef6e386a, + (q31_t)0x7eeb7abc, (q31_t)0xef67fd79, (q31_t)0x7eeaaa0f, (q31_t)0xef61c292, + (q31_t)0x7ee9d914, (q31_t)0xef5b87b5, (q31_t)0x7ee907ca, (q31_t)0xef554ce3, + (q31_t)0x7ee83632, (q31_t)0xef4f121b, (q31_t)0x7ee7644c, (q31_t)0xef48d75d, + (q31_t)0x7ee69217, (q31_t)0xef429caa, (q31_t)0x7ee5bf94, (q31_t)0xef3c6201, + (q31_t)0x7ee4ecc3, (q31_t)0xef362762, (q31_t)0x7ee419a3, (q31_t)0xef2feccd, + (q31_t)0x7ee34636, (q31_t)0xef29b243, (q31_t)0x7ee2727a, (q31_t)0xef2377c4, + (q31_t)0x7ee19e6f, (q31_t)0xef1d3d4e, (q31_t)0x7ee0ca17, (q31_t)0xef1702e4, + (q31_t)0x7edff570, (q31_t)0xef10c883, (q31_t)0x7edf207b, (q31_t)0xef0a8e2d, + (q31_t)0x7ede4b38, (q31_t)0xef0453e2, (q31_t)0x7edd75a6, (q31_t)0xeefe19a1, + (q31_t)0x7edc9fc6, (q31_t)0xeef7df6a, (q31_t)0x7edbc998, (q31_t)0xeef1a53e, + (q31_t)0x7edaf31c, (q31_t)0xeeeb6b1c, (q31_t)0x7eda1c51, (q31_t)0xeee53105, + (q31_t)0x7ed94538, (q31_t)0xeedef6f9, (q31_t)0x7ed86dd1, (q31_t)0xeed8bcf7, + (q31_t)0x7ed7961c, (q31_t)0xeed28300, (q31_t)0x7ed6be18, (q31_t)0xeecc4913, + (q31_t)0x7ed5e5c6, (q31_t)0xeec60f31, (q31_t)0x7ed50d26, (q31_t)0xeebfd55a, + (q31_t)0x7ed43438, (q31_t)0xeeb99b8d, (q31_t)0x7ed35afb, (q31_t)0xeeb361cb, + (q31_t)0x7ed28171, (q31_t)0xeead2813, (q31_t)0x7ed1a798, (q31_t)0xeea6ee66, + (q31_t)0x7ed0cd70, (q31_t)0xeea0b4c4, (q31_t)0x7ecff2fb, (q31_t)0xee9a7b2d, + (q31_t)0x7ecf1837, (q31_t)0xee9441a0, (q31_t)0x7ece3d25, (q31_t)0xee8e081e, + (q31_t)0x7ecd61c5, (q31_t)0xee87cea7, (q31_t)0x7ecc8617, (q31_t)0xee81953b, + (q31_t)0x7ecbaa1a, (q31_t)0xee7b5bd9, (q31_t)0x7ecacdd0, (q31_t)0xee752283, + (q31_t)0x7ec9f137, (q31_t)0xee6ee937, (q31_t)0x7ec9144f, (q31_t)0xee68aff6, + (q31_t)0x7ec8371a, (q31_t)0xee6276bf, (q31_t)0x7ec75996, (q31_t)0xee5c3d94, + (q31_t)0x7ec67bc5, (q31_t)0xee560473, (q31_t)0x7ec59da5, (q31_t)0xee4fcb5e, + (q31_t)0x7ec4bf36, (q31_t)0xee499253, (q31_t)0x7ec3e07a, (q31_t)0xee435953, + (q31_t)0x7ec3016f, (q31_t)0xee3d205e, (q31_t)0x7ec22217, (q31_t)0xee36e775, + (q31_t)0x7ec14270, (q31_t)0xee30ae96, (q31_t)0x7ec0627a, (q31_t)0xee2a75c2, + (q31_t)0x7ebf8237, (q31_t)0xee243cf9, (q31_t)0x7ebea1a6, (q31_t)0xee1e043b, + (q31_t)0x7ebdc0c6, (q31_t)0xee17cb88, (q31_t)0x7ebcdf98, (q31_t)0xee1192e0, + (q31_t)0x7ebbfe1c, (q31_t)0xee0b5a43, (q31_t)0x7ebb1c52, (q31_t)0xee0521b2, + (q31_t)0x7eba3a39, (q31_t)0xedfee92b, (q31_t)0x7eb957d2, (q31_t)0xedf8b0b0, + (q31_t)0x7eb8751e, (q31_t)0xedf2783f, (q31_t)0x7eb7921b, (q31_t)0xedec3fda, + (q31_t)0x7eb6aeca, (q31_t)0xede60780, (q31_t)0x7eb5cb2a, (q31_t)0xeddfcf31, + (q31_t)0x7eb4e73d, (q31_t)0xedd996ed, (q31_t)0x7eb40301, (q31_t)0xedd35eb5, + (q31_t)0x7eb31e78, (q31_t)0xedcd2687, (q31_t)0x7eb239a0, (q31_t)0xedc6ee65, + (q31_t)0x7eb1547a, (q31_t)0xedc0b64e, (q31_t)0x7eb06f05, (q31_t)0xedba7e43, + (q31_t)0x7eaf8943, (q31_t)0xedb44642, (q31_t)0x7eaea333, (q31_t)0xedae0e4d, + (q31_t)0x7eadbcd4, (q31_t)0xeda7d664, (q31_t)0x7eacd627, (q31_t)0xeda19e85, + (q31_t)0x7eabef2c, (q31_t)0xed9b66b2, (q31_t)0x7eab07e3, (q31_t)0xed952eea, + (q31_t)0x7eaa204c, (q31_t)0xed8ef72e, (q31_t)0x7ea93867, (q31_t)0xed88bf7d, + (q31_t)0x7ea85033, (q31_t)0xed8287d7, (q31_t)0x7ea767b2, (q31_t)0xed7c503d, + (q31_t)0x7ea67ee2, (q31_t)0xed7618ae, (q31_t)0x7ea595c4, (q31_t)0xed6fe12b, + (q31_t)0x7ea4ac58, (q31_t)0xed69a9b3, (q31_t)0x7ea3c29e, (q31_t)0xed637246, + (q31_t)0x7ea2d896, (q31_t)0xed5d3ae5, (q31_t)0x7ea1ee3f, (q31_t)0xed570390, + (q31_t)0x7ea1039b, (q31_t)0xed50cc46, (q31_t)0x7ea018a8, (q31_t)0xed4a9507, + (q31_t)0x7e9f2d68, (q31_t)0xed445dd5, (q31_t)0x7e9e41d9, (q31_t)0xed3e26ad, + (q31_t)0x7e9d55fc, (q31_t)0xed37ef91, (q31_t)0x7e9c69d1, (q31_t)0xed31b881, + (q31_t)0x7e9b7d58, (q31_t)0xed2b817d, (q31_t)0x7e9a9091, (q31_t)0xed254a84, + (q31_t)0x7e99a37c, (q31_t)0xed1f1396, (q31_t)0x7e98b618, (q31_t)0xed18dcb5, + (q31_t)0x7e97c867, (q31_t)0xed12a5df, (q31_t)0x7e96da67, (q31_t)0xed0c6f14, + (q31_t)0x7e95ec1a, (q31_t)0xed063856, (q31_t)0x7e94fd7e, (q31_t)0xed0001a3, + (q31_t)0x7e940e94, (q31_t)0xecf9cafb, (q31_t)0x7e931f5c, (q31_t)0xecf39460, + (q31_t)0x7e922fd6, (q31_t)0xeced5dd0, (q31_t)0x7e914002, (q31_t)0xece7274c, + (q31_t)0x7e904fe0, (q31_t)0xece0f0d4, (q31_t)0x7e8f5f70, (q31_t)0xecdaba67, + (q31_t)0x7e8e6eb2, (q31_t)0xecd48407, (q31_t)0x7e8d7da6, (q31_t)0xecce4db2, + (q31_t)0x7e8c8c4b, (q31_t)0xecc81769, (q31_t)0x7e8b9aa3, (q31_t)0xecc1e12c, + (q31_t)0x7e8aa8ac, (q31_t)0xecbbaafb, (q31_t)0x7e89b668, (q31_t)0xecb574d5, + (q31_t)0x7e88c3d5, (q31_t)0xecaf3ebc, (q31_t)0x7e87d0f5, (q31_t)0xeca908ae, + (q31_t)0x7e86ddc6, (q31_t)0xeca2d2ad, (q31_t)0x7e85ea49, (q31_t)0xec9c9cb7, + (q31_t)0x7e84f67e, (q31_t)0xec9666cd, (q31_t)0x7e840265, (q31_t)0xec9030f0, + (q31_t)0x7e830dff, (q31_t)0xec89fb1e, (q31_t)0x7e82194a, (q31_t)0xec83c558, + (q31_t)0x7e812447, (q31_t)0xec7d8f9e, (q31_t)0x7e802ef6, (q31_t)0xec7759f1, + (q31_t)0x7e7f3957, (q31_t)0xec71244f, (q31_t)0x7e7e436a, (q31_t)0xec6aeeba, + (q31_t)0x7e7d4d2f, (q31_t)0xec64b930, (q31_t)0x7e7c56a5, (q31_t)0xec5e83b3, + (q31_t)0x7e7b5fce, (q31_t)0xec584e41, (q31_t)0x7e7a68a9, (q31_t)0xec5218dc, + (q31_t)0x7e797136, (q31_t)0xec4be383, (q31_t)0x7e787975, (q31_t)0xec45ae36, + (q31_t)0x7e778166, (q31_t)0xec3f78f6, (q31_t)0x7e768908, (q31_t)0xec3943c1, + (q31_t)0x7e75905d, (q31_t)0xec330e99, (q31_t)0x7e749764, (q31_t)0xec2cd97d, + (q31_t)0x7e739e1d, (q31_t)0xec26a46d, (q31_t)0x7e72a488, (q31_t)0xec206f69, + (q31_t)0x7e71aaa4, (q31_t)0xec1a3a72, (q31_t)0x7e70b073, (q31_t)0xec140587, + (q31_t)0x7e6fb5f4, (q31_t)0xec0dd0a8, (q31_t)0x7e6ebb27, (q31_t)0xec079bd6, + (q31_t)0x7e6dc00c, (q31_t)0xec01670f, (q31_t)0x7e6cc4a2, (q31_t)0xebfb3256, + (q31_t)0x7e6bc8eb, (q31_t)0xebf4fda8, (q31_t)0x7e6acce6, (q31_t)0xebeec907, + (q31_t)0x7e69d093, (q31_t)0xebe89472, (q31_t)0x7e68d3f2, (q31_t)0xebe25fea, + (q31_t)0x7e67d703, (q31_t)0xebdc2b6e, (q31_t)0x7e66d9c6, (q31_t)0xebd5f6fe, + (q31_t)0x7e65dc3b, (q31_t)0xebcfc29b, (q31_t)0x7e64de62, (q31_t)0xebc98e45, + (q31_t)0x7e63e03b, (q31_t)0xebc359fb, (q31_t)0x7e62e1c6, (q31_t)0xebbd25bd, + (q31_t)0x7e61e303, (q31_t)0xebb6f18c, (q31_t)0x7e60e3f2, (q31_t)0xebb0bd67, + (q31_t)0x7e5fe493, (q31_t)0xebaa894f, (q31_t)0x7e5ee4e6, (q31_t)0xeba45543, + (q31_t)0x7e5de4ec, (q31_t)0xeb9e2144, (q31_t)0x7e5ce4a3, (q31_t)0xeb97ed52, + (q31_t)0x7e5be40c, (q31_t)0xeb91b96c, (q31_t)0x7e5ae328, (q31_t)0xeb8b8593, + (q31_t)0x7e59e1f5, (q31_t)0xeb8551c6, (q31_t)0x7e58e075, (q31_t)0xeb7f1e06, + (q31_t)0x7e57dea7, (q31_t)0xeb78ea52, (q31_t)0x7e56dc8a, (q31_t)0xeb72b6ac, + (q31_t)0x7e55da20, (q31_t)0xeb6c8312, (q31_t)0x7e54d768, (q31_t)0xeb664f84, + (q31_t)0x7e53d462, (q31_t)0xeb601c04, (q31_t)0x7e52d10e, (q31_t)0xeb59e890, + (q31_t)0x7e51cd6c, (q31_t)0xeb53b529, (q31_t)0x7e50c97c, (q31_t)0xeb4d81ce, + (q31_t)0x7e4fc53e, (q31_t)0xeb474e81, (q31_t)0x7e4ec0b2, (q31_t)0xeb411b40, + (q31_t)0x7e4dbbd9, (q31_t)0xeb3ae80c, (q31_t)0x7e4cb6b1, (q31_t)0xeb34b4e4, + (q31_t)0x7e4bb13c, (q31_t)0xeb2e81ca, (q31_t)0x7e4aab78, (q31_t)0xeb284ebc, + (q31_t)0x7e49a567, (q31_t)0xeb221bbb, (q31_t)0x7e489f08, (q31_t)0xeb1be8c8, + (q31_t)0x7e47985b, (q31_t)0xeb15b5e1, (q31_t)0x7e469160, (q31_t)0xeb0f8307, + (q31_t)0x7e458a17, (q31_t)0xeb095039, (q31_t)0x7e448281, (q31_t)0xeb031d79, + (q31_t)0x7e437a9c, (q31_t)0xeafceac6, (q31_t)0x7e427269, (q31_t)0xeaf6b81f, + (q31_t)0x7e4169e9, (q31_t)0xeaf08586, (q31_t)0x7e40611b, (q31_t)0xeaea52fa, + (q31_t)0x7e3f57ff, (q31_t)0xeae4207a, (q31_t)0x7e3e4e95, (q31_t)0xeaddee08, + (q31_t)0x7e3d44dd, (q31_t)0xead7bba3, (q31_t)0x7e3c3ad7, (q31_t)0xead1894b, + (q31_t)0x7e3b3083, (q31_t)0xeacb56ff, (q31_t)0x7e3a25e2, (q31_t)0xeac524c1, + (q31_t)0x7e391af3, (q31_t)0xeabef290, (q31_t)0x7e380fb5, (q31_t)0xeab8c06c, + (q31_t)0x7e37042a, (q31_t)0xeab28e56, (q31_t)0x7e35f851, (q31_t)0xeaac5c4c, + (q31_t)0x7e34ec2b, (q31_t)0xeaa62a4f, (q31_t)0x7e33dfb6, (q31_t)0xea9ff860, + (q31_t)0x7e32d2f4, (q31_t)0xea99c67e, (q31_t)0x7e31c5e3, (q31_t)0xea9394a9, + (q31_t)0x7e30b885, (q31_t)0xea8d62e1, (q31_t)0x7e2faad9, (q31_t)0xea873127, + (q31_t)0x7e2e9cdf, (q31_t)0xea80ff7a, (q31_t)0x7e2d8e97, (q31_t)0xea7acdda, + (q31_t)0x7e2c8002, (q31_t)0xea749c47, (q31_t)0x7e2b711f, (q31_t)0xea6e6ac2, + (q31_t)0x7e2a61ed, (q31_t)0xea683949, (q31_t)0x7e29526e, (q31_t)0xea6207df, + (q31_t)0x7e2842a2, (q31_t)0xea5bd681, (q31_t)0x7e273287, (q31_t)0xea55a531, + (q31_t)0x7e26221f, (q31_t)0xea4f73ee, (q31_t)0x7e251168, (q31_t)0xea4942b9, + (q31_t)0x7e240064, (q31_t)0xea431191, (q31_t)0x7e22ef12, (q31_t)0xea3ce077, + (q31_t)0x7e21dd73, (q31_t)0xea36af69, (q31_t)0x7e20cb85, (q31_t)0xea307e6a, + (q31_t)0x7e1fb94a, (q31_t)0xea2a4d78, (q31_t)0x7e1ea6c1, (q31_t)0xea241c93, + (q31_t)0x7e1d93ea, (q31_t)0xea1debbb, (q31_t)0x7e1c80c5, (q31_t)0xea17baf2, + (q31_t)0x7e1b6d53, (q31_t)0xea118a35, (q31_t)0x7e1a5992, (q31_t)0xea0b5987, + (q31_t)0x7e194584, (q31_t)0xea0528e5, (q31_t)0x7e183128, (q31_t)0xe9fef852, + (q31_t)0x7e171c7f, (q31_t)0xe9f8c7cc, (q31_t)0x7e160787, (q31_t)0xe9f29753, + (q31_t)0x7e14f242, (q31_t)0xe9ec66e8, (q31_t)0x7e13dcaf, (q31_t)0xe9e6368b, + (q31_t)0x7e12c6ce, (q31_t)0xe9e0063c, (q31_t)0x7e11b0a0, (q31_t)0xe9d9d5fa, + (q31_t)0x7e109a24, (q31_t)0xe9d3a5c5, (q31_t)0x7e0f835a, (q31_t)0xe9cd759f, + (q31_t)0x7e0e6c42, (q31_t)0xe9c74586, (q31_t)0x7e0d54dc, (q31_t)0xe9c1157a, + (q31_t)0x7e0c3d29, (q31_t)0xe9bae57d, (q31_t)0x7e0b2528, (q31_t)0xe9b4b58d, + (q31_t)0x7e0a0cd9, (q31_t)0xe9ae85ab, (q31_t)0x7e08f43d, (q31_t)0xe9a855d7, + (q31_t)0x7e07db52, (q31_t)0xe9a22610, (q31_t)0x7e06c21a, (q31_t)0xe99bf658, + (q31_t)0x7e05a894, (q31_t)0xe995c6ad, (q31_t)0x7e048ec1, (q31_t)0xe98f9710, + (q31_t)0x7e0374a0, (q31_t)0xe9896781, (q31_t)0x7e025a31, (q31_t)0xe98337ff, + (q31_t)0x7e013f74, (q31_t)0xe97d088c, (q31_t)0x7e00246a, (q31_t)0xe976d926, + (q31_t)0x7dff0911, (q31_t)0xe970a9ce, (q31_t)0x7dfded6c, (q31_t)0xe96a7a85, + (q31_t)0x7dfcd178, (q31_t)0xe9644b49, (q31_t)0x7dfbb537, (q31_t)0xe95e1c1b, + (q31_t)0x7dfa98a8, (q31_t)0xe957ecfb, (q31_t)0x7df97bcb, (q31_t)0xe951bde9, + (q31_t)0x7df85ea0, (q31_t)0xe94b8ee5, (q31_t)0x7df74128, (q31_t)0xe9455fef, + (q31_t)0x7df62362, (q31_t)0xe93f3107, (q31_t)0x7df5054f, (q31_t)0xe939022d, + (q31_t)0x7df3e6ee, (q31_t)0xe932d361, (q31_t)0x7df2c83f, (q31_t)0xe92ca4a4, + (q31_t)0x7df1a942, (q31_t)0xe92675f4, (q31_t)0x7df089f8, (q31_t)0xe9204752, + (q31_t)0x7def6a60, (q31_t)0xe91a18bf, (q31_t)0x7dee4a7a, (q31_t)0xe913ea39, + (q31_t)0x7ded2a47, (q31_t)0xe90dbbc2, (q31_t)0x7dec09c6, (q31_t)0xe9078d59, + (q31_t)0x7deae8f7, (q31_t)0xe9015efe, (q31_t)0x7de9c7da, (q31_t)0xe8fb30b1, + (q31_t)0x7de8a670, (q31_t)0xe8f50273, (q31_t)0x7de784b9, (q31_t)0xe8eed443, + (q31_t)0x7de662b3, (q31_t)0xe8e8a621, (q31_t)0x7de54060, (q31_t)0xe8e2780d, + (q31_t)0x7de41dc0, (q31_t)0xe8dc4a07, (q31_t)0x7de2fad1, (q31_t)0xe8d61c10, + (q31_t)0x7de1d795, (q31_t)0xe8cfee27, (q31_t)0x7de0b40b, (q31_t)0xe8c9c04c, + (q31_t)0x7ddf9034, (q31_t)0xe8c39280, (q31_t)0x7dde6c0f, (q31_t)0xe8bd64c2, + (q31_t)0x7ddd479d, (q31_t)0xe8b73712, (q31_t)0x7ddc22dc, (q31_t)0xe8b10971, + (q31_t)0x7ddafdce, (q31_t)0xe8aadbde, (q31_t)0x7dd9d873, (q31_t)0xe8a4ae59, + (q31_t)0x7dd8b2ca, (q31_t)0xe89e80e3, (q31_t)0x7dd78cd3, (q31_t)0xe898537b, + (q31_t)0x7dd6668f, (q31_t)0xe8922622, (q31_t)0x7dd53ffc, (q31_t)0xe88bf8d7, + (q31_t)0x7dd4191d, (q31_t)0xe885cb9a, (q31_t)0x7dd2f1f0, (q31_t)0xe87f9e6c, + (q31_t)0x7dd1ca75, (q31_t)0xe879714d, (q31_t)0x7dd0a2ac, (q31_t)0xe873443c, + (q31_t)0x7dcf7a96, (q31_t)0xe86d173a, (q31_t)0x7dce5232, (q31_t)0xe866ea46, + (q31_t)0x7dcd2981, (q31_t)0xe860bd61, (q31_t)0x7dcc0082, (q31_t)0xe85a908a, + (q31_t)0x7dcad736, (q31_t)0xe85463c2, (q31_t)0x7dc9ad9c, (q31_t)0xe84e3708, + (q31_t)0x7dc883b4, (q31_t)0xe8480a5d, (q31_t)0x7dc7597f, (q31_t)0xe841ddc1, + (q31_t)0x7dc62efc, (q31_t)0xe83bb133, (q31_t)0x7dc5042b, (q31_t)0xe83584b4, + (q31_t)0x7dc3d90d, (q31_t)0xe82f5844, (q31_t)0x7dc2ada2, (q31_t)0xe8292be3, + (q31_t)0x7dc181e8, (q31_t)0xe822ff90, (q31_t)0x7dc055e2, (q31_t)0xe81cd34b, + (q31_t)0x7dbf298d, (q31_t)0xe816a716, (q31_t)0x7dbdfceb, (q31_t)0xe8107aef, + (q31_t)0x7dbccffc, (q31_t)0xe80a4ed7, (q31_t)0x7dbba2bf, (q31_t)0xe80422ce, + (q31_t)0x7dba7534, (q31_t)0xe7fdf6d4, (q31_t)0x7db9475c, (q31_t)0xe7f7cae8, + (q31_t)0x7db81936, (q31_t)0xe7f19f0c, (q31_t)0x7db6eac3, (q31_t)0xe7eb733e, + (q31_t)0x7db5bc02, (q31_t)0xe7e5477f, (q31_t)0x7db48cf4, (q31_t)0xe7df1bcf, + (q31_t)0x7db35d98, (q31_t)0xe7d8f02d, (q31_t)0x7db22def, (q31_t)0xe7d2c49b, + (q31_t)0x7db0fdf8, (q31_t)0xe7cc9917, (q31_t)0x7dafcdb3, (q31_t)0xe7c66da3, + (q31_t)0x7dae9d21, (q31_t)0xe7c0423d, (q31_t)0x7dad6c42, (q31_t)0xe7ba16e7, + (q31_t)0x7dac3b15, (q31_t)0xe7b3eb9f, (q31_t)0x7dab099a, (q31_t)0xe7adc066, + (q31_t)0x7da9d7d2, (q31_t)0xe7a7953d, (q31_t)0x7da8a5bc, (q31_t)0xe7a16a22, + (q31_t)0x7da77359, (q31_t)0xe79b3f16, (q31_t)0x7da640a9, (q31_t)0xe795141a, + (q31_t)0x7da50dab, (q31_t)0xe78ee92c, (q31_t)0x7da3da5f, (q31_t)0xe788be4e, + (q31_t)0x7da2a6c6, (q31_t)0xe782937e, (q31_t)0x7da172df, (q31_t)0xe77c68be, + (q31_t)0x7da03eab, (q31_t)0xe7763e0d, (q31_t)0x7d9f0a29, (q31_t)0xe770136b, + (q31_t)0x7d9dd55a, (q31_t)0xe769e8d8, (q31_t)0x7d9ca03e, (q31_t)0xe763be55, + (q31_t)0x7d9b6ad3, (q31_t)0xe75d93e0, (q31_t)0x7d9a351c, (q31_t)0xe757697b, + (q31_t)0x7d98ff17, (q31_t)0xe7513f25, (q31_t)0x7d97c8c4, (q31_t)0xe74b14de, + (q31_t)0x7d969224, (q31_t)0xe744eaa6, (q31_t)0x7d955b37, (q31_t)0xe73ec07e, + (q31_t)0x7d9423fc, (q31_t)0xe7389665, (q31_t)0x7d92ec73, (q31_t)0xe7326c5b, + (q31_t)0x7d91b49e, (q31_t)0xe72c4260, (q31_t)0x7d907c7a, (q31_t)0xe7261875, + (q31_t)0x7d8f4409, (q31_t)0xe71fee99, (q31_t)0x7d8e0b4b, (q31_t)0xe719c4cd, + (q31_t)0x7d8cd240, (q31_t)0xe7139b10, (q31_t)0x7d8b98e6, (q31_t)0xe70d7162, + (q31_t)0x7d8a5f40, (q31_t)0xe70747c4, (q31_t)0x7d89254c, (q31_t)0xe7011e35, + (q31_t)0x7d87eb0a, (q31_t)0xe6faf4b5, (q31_t)0x7d86b07c, (q31_t)0xe6f4cb45, + (q31_t)0x7d85759f, (q31_t)0xe6eea1e4, (q31_t)0x7d843a76, (q31_t)0xe6e87893, + (q31_t)0x7d82fefe, (q31_t)0xe6e24f51, (q31_t)0x7d81c33a, (q31_t)0xe6dc261f, + (q31_t)0x7d808728, (q31_t)0xe6d5fcfc, (q31_t)0x7d7f4ac8, (q31_t)0xe6cfd3e9, + (q31_t)0x7d7e0e1c, (q31_t)0xe6c9aae5, (q31_t)0x7d7cd121, (q31_t)0xe6c381f1, + (q31_t)0x7d7b93da, (q31_t)0xe6bd590d, (q31_t)0x7d7a5645, (q31_t)0xe6b73038, + (q31_t)0x7d791862, (q31_t)0xe6b10772, (q31_t)0x7d77da32, (q31_t)0xe6aadebc, + (q31_t)0x7d769bb5, (q31_t)0xe6a4b616, (q31_t)0x7d755cea, (q31_t)0xe69e8d80, + (q31_t)0x7d741dd2, (q31_t)0xe69864f9, (q31_t)0x7d72de6d, (q31_t)0xe6923c82, + (q31_t)0x7d719eba, (q31_t)0xe68c141a, (q31_t)0x7d705eba, (q31_t)0xe685ebc2, + (q31_t)0x7d6f1e6c, (q31_t)0xe67fc37a, (q31_t)0x7d6dddd2, (q31_t)0xe6799b42, + (q31_t)0x7d6c9ce9, (q31_t)0xe6737319, (q31_t)0x7d6b5bb4, (q31_t)0xe66d4b01, + (q31_t)0x7d6a1a31, (q31_t)0xe66722f7, (q31_t)0x7d68d860, (q31_t)0xe660fafe, + (q31_t)0x7d679642, (q31_t)0xe65ad315, (q31_t)0x7d6653d7, (q31_t)0xe654ab3b, + (q31_t)0x7d65111f, (q31_t)0xe64e8371, (q31_t)0x7d63ce19, (q31_t)0xe6485bb7, + (q31_t)0x7d628ac6, (q31_t)0xe642340d, (q31_t)0x7d614725, (q31_t)0xe63c0c73, + (q31_t)0x7d600338, (q31_t)0xe635e4e9, (q31_t)0x7d5ebefc, (q31_t)0xe62fbd6e, + (q31_t)0x7d5d7a74, (q31_t)0xe6299604, (q31_t)0x7d5c359e, (q31_t)0xe6236ea9, + (q31_t)0x7d5af07b, (q31_t)0xe61d475e, (q31_t)0x7d59ab0a, (q31_t)0xe6172024, + (q31_t)0x7d58654d, (q31_t)0xe610f8f9, (q31_t)0x7d571f41, (q31_t)0xe60ad1de, + (q31_t)0x7d55d8e9, (q31_t)0xe604aad4, (q31_t)0x7d549243, (q31_t)0xe5fe83d9, + (q31_t)0x7d534b50, (q31_t)0xe5f85cef, (q31_t)0x7d520410, (q31_t)0xe5f23614, + (q31_t)0x7d50bc82, (q31_t)0xe5ec0f4a, (q31_t)0x7d4f74a7, (q31_t)0xe5e5e88f, + (q31_t)0x7d4e2c7f, (q31_t)0xe5dfc1e5, (q31_t)0x7d4ce409, (q31_t)0xe5d99b4b, + (q31_t)0x7d4b9b46, (q31_t)0xe5d374c1, (q31_t)0x7d4a5236, (q31_t)0xe5cd4e47, + (q31_t)0x7d4908d9, (q31_t)0xe5c727dd, (q31_t)0x7d47bf2e, (q31_t)0xe5c10184, + (q31_t)0x7d467536, (q31_t)0xe5badb3a, (q31_t)0x7d452af1, (q31_t)0xe5b4b501, + (q31_t)0x7d43e05e, (q31_t)0xe5ae8ed8, (q31_t)0x7d42957e, (q31_t)0xe5a868bf, + (q31_t)0x7d414a51, (q31_t)0xe5a242b7, (q31_t)0x7d3ffed7, (q31_t)0xe59c1cbf, + (q31_t)0x7d3eb30f, (q31_t)0xe595f6d7, (q31_t)0x7d3d66fa, (q31_t)0xe58fd0ff, + (q31_t)0x7d3c1a98, (q31_t)0xe589ab38, (q31_t)0x7d3acde9, (q31_t)0xe5838581, + (q31_t)0x7d3980ec, (q31_t)0xe57d5fda, (q31_t)0x7d3833a2, (q31_t)0xe5773a44, + (q31_t)0x7d36e60b, (q31_t)0xe57114be, (q31_t)0x7d359827, (q31_t)0xe56aef49, + (q31_t)0x7d3449f5, (q31_t)0xe564c9e3, (q31_t)0x7d32fb76, (q31_t)0xe55ea48f, + (q31_t)0x7d31acaa, (q31_t)0xe5587f4a, (q31_t)0x7d305d91, (q31_t)0xe5525a17, + (q31_t)0x7d2f0e2b, (q31_t)0xe54c34f3, (q31_t)0x7d2dbe77, (q31_t)0xe5460fe0, + (q31_t)0x7d2c6e76, (q31_t)0xe53feade, (q31_t)0x7d2b1e28, (q31_t)0xe539c5ec, + (q31_t)0x7d29cd8c, (q31_t)0xe533a10a, (q31_t)0x7d287ca4, (q31_t)0xe52d7c39, + (q31_t)0x7d272b6e, (q31_t)0xe5275779, (q31_t)0x7d25d9eb, (q31_t)0xe52132c9, + (q31_t)0x7d24881b, (q31_t)0xe51b0e2a, (q31_t)0x7d2335fe, (q31_t)0xe514e99b, + (q31_t)0x7d21e393, (q31_t)0xe50ec51d, (q31_t)0x7d2090db, (q31_t)0xe508a0b0, + (q31_t)0x7d1f3dd6, (q31_t)0xe5027c53, (q31_t)0x7d1dea84, (q31_t)0xe4fc5807, + (q31_t)0x7d1c96e5, (q31_t)0xe4f633cc, (q31_t)0x7d1b42f9, (q31_t)0xe4f00fa1, + (q31_t)0x7d19eebf, (q31_t)0xe4e9eb87, (q31_t)0x7d189a38, (q31_t)0xe4e3c77d, + (q31_t)0x7d174564, (q31_t)0xe4dda385, (q31_t)0x7d15f043, (q31_t)0xe4d77f9d, + (q31_t)0x7d149ad5, (q31_t)0xe4d15bc6, (q31_t)0x7d134519, (q31_t)0xe4cb37ff, + (q31_t)0x7d11ef11, (q31_t)0xe4c5144a, (q31_t)0x7d1098bb, (q31_t)0xe4bef0a5, + (q31_t)0x7d0f4218, (q31_t)0xe4b8cd11, (q31_t)0x7d0deb28, (q31_t)0xe4b2a98e, + (q31_t)0x7d0c93eb, (q31_t)0xe4ac861b, (q31_t)0x7d0b3c60, (q31_t)0xe4a662ba, + (q31_t)0x7d09e489, (q31_t)0xe4a03f69, (q31_t)0x7d088c64, (q31_t)0xe49a1c29, + (q31_t)0x7d0733f3, (q31_t)0xe493f8fb, (q31_t)0x7d05db34, (q31_t)0xe48dd5dd, + (q31_t)0x7d048228, (q31_t)0xe487b2d0, (q31_t)0x7d0328cf, (q31_t)0xe4818fd4, + (q31_t)0x7d01cf29, (q31_t)0xe47b6ce9, (q31_t)0x7d007535, (q31_t)0xe4754a0e, + (q31_t)0x7cff1af5, (q31_t)0xe46f2745, (q31_t)0x7cfdc068, (q31_t)0xe469048d, + (q31_t)0x7cfc658d, (q31_t)0xe462e1e6, (q31_t)0x7cfb0a65, (q31_t)0xe45cbf50, + (q31_t)0x7cf9aef0, (q31_t)0xe4569ccb, (q31_t)0x7cf8532f, (q31_t)0xe4507a57, + (q31_t)0x7cf6f720, (q31_t)0xe44a57f4, (q31_t)0x7cf59ac4, (q31_t)0xe44435a2, + (q31_t)0x7cf43e1a, (q31_t)0xe43e1362, (q31_t)0x7cf2e124, (q31_t)0xe437f132, + (q31_t)0x7cf183e1, (q31_t)0xe431cf14, (q31_t)0x7cf02651, (q31_t)0xe42bad07, + (q31_t)0x7ceec873, (q31_t)0xe4258b0a, (q31_t)0x7ced6a49, (q31_t)0xe41f6920, + (q31_t)0x7cec0bd1, (q31_t)0xe4194746, (q31_t)0x7ceaad0c, (q31_t)0xe413257d, + (q31_t)0x7ce94dfb, (q31_t)0xe40d03c6, (q31_t)0x7ce7ee9c, (q31_t)0xe406e220, + (q31_t)0x7ce68ef0, (q31_t)0xe400c08b, (q31_t)0x7ce52ef7, (q31_t)0xe3fa9f08, + (q31_t)0x7ce3ceb2, (q31_t)0xe3f47d96, (q31_t)0x7ce26e1f, (q31_t)0xe3ee5c35, + (q31_t)0x7ce10d3f, (q31_t)0xe3e83ae5, (q31_t)0x7cdfac12, (q31_t)0xe3e219a7, + (q31_t)0x7cde4a98, (q31_t)0xe3dbf87a, (q31_t)0x7cdce8d1, (q31_t)0xe3d5d75e, + (q31_t)0x7cdb86bd, (q31_t)0xe3cfb654, (q31_t)0x7cda245c, (q31_t)0xe3c9955b, + (q31_t)0x7cd8c1ae, (q31_t)0xe3c37474, (q31_t)0x7cd75eb3, (q31_t)0xe3bd539e, + (q31_t)0x7cd5fb6a, (q31_t)0xe3b732d9, (q31_t)0x7cd497d5, (q31_t)0xe3b11226, + (q31_t)0x7cd333f3, (q31_t)0xe3aaf184, (q31_t)0x7cd1cfc4, (q31_t)0xe3a4d0f4, + (q31_t)0x7cd06b48, (q31_t)0xe39eb075, (q31_t)0x7ccf067f, (q31_t)0xe3989008, + (q31_t)0x7ccda169, (q31_t)0xe3926fad, (q31_t)0x7ccc3c06, (q31_t)0xe38c4f63, + (q31_t)0x7ccad656, (q31_t)0xe3862f2a, (q31_t)0x7cc97059, (q31_t)0xe3800f03, + (q31_t)0x7cc80a0f, (q31_t)0xe379eeed, (q31_t)0x7cc6a378, (q31_t)0xe373ceea, + (q31_t)0x7cc53c94, (q31_t)0xe36daef7, (q31_t)0x7cc3d563, (q31_t)0xe3678f17, + (q31_t)0x7cc26de5, (q31_t)0xe3616f48, (q31_t)0x7cc1061a, (q31_t)0xe35b4f8b, + (q31_t)0x7cbf9e03, (q31_t)0xe3552fdf, (q31_t)0x7cbe359e, (q31_t)0xe34f1045, + (q31_t)0x7cbcccec, (q31_t)0xe348f0bd, (q31_t)0x7cbb63ee, (q31_t)0xe342d146, + (q31_t)0x7cb9faa2, (q31_t)0xe33cb1e1, (q31_t)0x7cb8910a, (q31_t)0xe336928e, + (q31_t)0x7cb72724, (q31_t)0xe330734d, (q31_t)0x7cb5bcf2, (q31_t)0xe32a541d, + (q31_t)0x7cb45272, (q31_t)0xe3243500, (q31_t)0x7cb2e7a6, (q31_t)0xe31e15f4, + (q31_t)0x7cb17c8d, (q31_t)0xe317f6fa, (q31_t)0x7cb01127, (q31_t)0xe311d811, + (q31_t)0x7caea574, (q31_t)0xe30bb93b, (q31_t)0x7cad3974, (q31_t)0xe3059a76, + (q31_t)0x7cabcd28, (q31_t)0xe2ff7bc3, (q31_t)0x7caa608e, (q31_t)0xe2f95d23, + (q31_t)0x7ca8f3a7, (q31_t)0xe2f33e94, (q31_t)0x7ca78674, (q31_t)0xe2ed2017, + (q31_t)0x7ca618f3, (q31_t)0xe2e701ac, (q31_t)0x7ca4ab26, (q31_t)0xe2e0e352, + (q31_t)0x7ca33d0c, (q31_t)0xe2dac50b, (q31_t)0x7ca1cea5, (q31_t)0xe2d4a6d6, + (q31_t)0x7ca05ff1, (q31_t)0xe2ce88b3, (q31_t)0x7c9ef0f0, (q31_t)0xe2c86aa2, + (q31_t)0x7c9d81a3, (q31_t)0xe2c24ca2, (q31_t)0x7c9c1208, (q31_t)0xe2bc2eb5, + (q31_t)0x7c9aa221, (q31_t)0xe2b610da, (q31_t)0x7c9931ec, (q31_t)0xe2aff311, + (q31_t)0x7c97c16b, (q31_t)0xe2a9d55a, (q31_t)0x7c96509d, (q31_t)0xe2a3b7b5, + (q31_t)0x7c94df83, (q31_t)0xe29d9a23, (q31_t)0x7c936e1b, (q31_t)0xe2977ca2, + (q31_t)0x7c91fc66, (q31_t)0xe2915f34, (q31_t)0x7c908a65, (q31_t)0xe28b41d7, + (q31_t)0x7c8f1817, (q31_t)0xe285248d, (q31_t)0x7c8da57c, (q31_t)0xe27f0755, + (q31_t)0x7c8c3294, (q31_t)0xe278ea30, (q31_t)0x7c8abf5f, (q31_t)0xe272cd1c, + (q31_t)0x7c894bde, (q31_t)0xe26cb01b, (q31_t)0x7c87d810, (q31_t)0xe266932c, + (q31_t)0x7c8663f4, (q31_t)0xe260764f, (q31_t)0x7c84ef8c, (q31_t)0xe25a5984, + (q31_t)0x7c837ad8, (q31_t)0xe2543ccc, (q31_t)0x7c8205d6, (q31_t)0xe24e2026, + (q31_t)0x7c809088, (q31_t)0xe2480393, (q31_t)0x7c7f1aed, (q31_t)0xe241e711, + (q31_t)0x7c7da505, (q31_t)0xe23bcaa2, (q31_t)0x7c7c2ed0, (q31_t)0xe235ae46, + (q31_t)0x7c7ab84e, (q31_t)0xe22f91fc, (q31_t)0x7c794180, (q31_t)0xe22975c4, + (q31_t)0x7c77ca65, (q31_t)0xe223599e, (q31_t)0x7c7652fd, (q31_t)0xe21d3d8b, + (q31_t)0x7c74db48, (q31_t)0xe217218b, (q31_t)0x7c736347, (q31_t)0xe211059d, + (q31_t)0x7c71eaf9, (q31_t)0xe20ae9c1, (q31_t)0x7c70725e, (q31_t)0xe204cdf8, + (q31_t)0x7c6ef976, (q31_t)0xe1feb241, (q31_t)0x7c6d8041, (q31_t)0xe1f8969d, + (q31_t)0x7c6c06c0, (q31_t)0xe1f27b0b, (q31_t)0x7c6a8cf2, (q31_t)0xe1ec5f8c, + (q31_t)0x7c6912d7, (q31_t)0xe1e64420, (q31_t)0x7c679870, (q31_t)0xe1e028c6, + (q31_t)0x7c661dbc, (q31_t)0xe1da0d7e, (q31_t)0x7c64a2bb, (q31_t)0xe1d3f24a, + (q31_t)0x7c63276d, (q31_t)0xe1cdd727, (q31_t)0x7c61abd3, (q31_t)0xe1c7bc18, + (q31_t)0x7c602fec, (q31_t)0xe1c1a11b, (q31_t)0x7c5eb3b8, (q31_t)0xe1bb8631, + (q31_t)0x7c5d3737, (q31_t)0xe1b56b59, (q31_t)0x7c5bba6a, (q31_t)0xe1af5094, + (q31_t)0x7c5a3d50, (q31_t)0xe1a935e2, (q31_t)0x7c58bfe9, (q31_t)0xe1a31b42, + (q31_t)0x7c574236, (q31_t)0xe19d00b6, (q31_t)0x7c55c436, (q31_t)0xe196e63c, + (q31_t)0x7c5445e9, (q31_t)0xe190cbd4, (q31_t)0x7c52c74f, (q31_t)0xe18ab180, + (q31_t)0x7c514869, (q31_t)0xe184973e, (q31_t)0x7c4fc936, (q31_t)0xe17e7d0f, + (q31_t)0x7c4e49b7, (q31_t)0xe17862f3, (q31_t)0x7c4cc9ea, (q31_t)0xe17248ea, + (q31_t)0x7c4b49d2, (q31_t)0xe16c2ef4, (q31_t)0x7c49c96c, (q31_t)0xe1661510, + (q31_t)0x7c4848ba, (q31_t)0xe15ffb3f, (q31_t)0x7c46c7bb, (q31_t)0xe159e182, + (q31_t)0x7c45466f, (q31_t)0xe153c7d7, (q31_t)0x7c43c4d7, (q31_t)0xe14dae3f, + (q31_t)0x7c4242f2, (q31_t)0xe14794ba, (q31_t)0x7c40c0c1, (q31_t)0xe1417b48, + (q31_t)0x7c3f3e42, (q31_t)0xe13b61e9, (q31_t)0x7c3dbb78, (q31_t)0xe135489d, + (q31_t)0x7c3c3860, (q31_t)0xe12f2f63, (q31_t)0x7c3ab4fc, (q31_t)0xe129163d, + (q31_t)0x7c39314b, (q31_t)0xe122fd2a, (q31_t)0x7c37ad4e, (q31_t)0xe11ce42a, + (q31_t)0x7c362904, (q31_t)0xe116cb3d, (q31_t)0x7c34a46d, (q31_t)0xe110b263, + (q31_t)0x7c331f8a, (q31_t)0xe10a999c, (q31_t)0x7c319a5a, (q31_t)0xe10480e9, + (q31_t)0x7c3014de, (q31_t)0xe0fe6848, (q31_t)0x7c2e8f15, (q31_t)0xe0f84fbb, + (q31_t)0x7c2d08ff, (q31_t)0xe0f23740, (q31_t)0x7c2b829d, (q31_t)0xe0ec1ed9, + (q31_t)0x7c29fbee, (q31_t)0xe0e60685, (q31_t)0x7c2874f3, (q31_t)0xe0dfee44, + (q31_t)0x7c26edab, (q31_t)0xe0d9d616, (q31_t)0x7c256616, (q31_t)0xe0d3bdfc, + (q31_t)0x7c23de35, (q31_t)0xe0cda5f5, (q31_t)0x7c225607, (q31_t)0xe0c78e01, + (q31_t)0x7c20cd8d, (q31_t)0xe0c17620, (q31_t)0x7c1f44c6, (q31_t)0xe0bb5e53, + (q31_t)0x7c1dbbb3, (q31_t)0xe0b54698, (q31_t)0x7c1c3253, (q31_t)0xe0af2ef2, + (q31_t)0x7c1aa8a6, (q31_t)0xe0a9175e, (q31_t)0x7c191ead, (q31_t)0xe0a2ffde, + (q31_t)0x7c179467, (q31_t)0xe09ce871, (q31_t)0x7c1609d5, (q31_t)0xe096d117, + (q31_t)0x7c147ef6, (q31_t)0xe090b9d1, (q31_t)0x7c12f3cb, (q31_t)0xe08aa29f, + (q31_t)0x7c116853, (q31_t)0xe0848b7f, (q31_t)0x7c0fdc8f, (q31_t)0xe07e7473, + (q31_t)0x7c0e507e, (q31_t)0xe0785d7b, (q31_t)0x7c0cc421, (q31_t)0xe0724696, + (q31_t)0x7c0b3777, (q31_t)0xe06c2fc4, (q31_t)0x7c09aa80, (q31_t)0xe0661906, + (q31_t)0x7c081d3d, (q31_t)0xe060025c, (q31_t)0x7c068fae, (q31_t)0xe059ebc5, + (q31_t)0x7c0501d2, (q31_t)0xe053d541, (q31_t)0x7c0373a9, (q31_t)0xe04dbed1, + (q31_t)0x7c01e534, (q31_t)0xe047a875, (q31_t)0x7c005673, (q31_t)0xe041922c, + (q31_t)0x7bfec765, (q31_t)0xe03b7bf6, (q31_t)0x7bfd380a, (q31_t)0xe03565d5, + (q31_t)0x7bfba863, (q31_t)0xe02f4fc6, (q31_t)0x7bfa1870, (q31_t)0xe02939cc, + (q31_t)0x7bf88830, (q31_t)0xe02323e5, (q31_t)0x7bf6f7a4, (q31_t)0xe01d0e12, + (q31_t)0x7bf566cb, (q31_t)0xe016f852, (q31_t)0x7bf3d5a6, (q31_t)0xe010e2a7, + (q31_t)0x7bf24434, (q31_t)0xe00acd0e, (q31_t)0x7bf0b276, (q31_t)0xe004b78a, + (q31_t)0x7bef206b, (q31_t)0xdffea219, (q31_t)0x7bed8e14, (q31_t)0xdff88cbc, + (q31_t)0x7bebfb70, (q31_t)0xdff27773, (q31_t)0x7bea6880, (q31_t)0xdfec623e, + (q31_t)0x7be8d544, (q31_t)0xdfe64d1c, (q31_t)0x7be741bb, (q31_t)0xdfe0380e, + (q31_t)0x7be5ade6, (q31_t)0xdfda2314, (q31_t)0x7be419c4, (q31_t)0xdfd40e2e, + (q31_t)0x7be28556, (q31_t)0xdfcdf95c, (q31_t)0x7be0f09b, (q31_t)0xdfc7e49d, + (q31_t)0x7bdf5b94, (q31_t)0xdfc1cff3, (q31_t)0x7bddc641, (q31_t)0xdfbbbb5c, + (q31_t)0x7bdc30a1, (q31_t)0xdfb5a6d9, (q31_t)0x7bda9ab5, (q31_t)0xdfaf926a, + (q31_t)0x7bd9047c, (q31_t)0xdfa97e0f, (q31_t)0x7bd76df7, (q31_t)0xdfa369c8, + (q31_t)0x7bd5d726, (q31_t)0xdf9d5595, (q31_t)0x7bd44008, (q31_t)0xdf974176, + (q31_t)0x7bd2a89e, (q31_t)0xdf912d6b, (q31_t)0x7bd110e8, (q31_t)0xdf8b1974, + (q31_t)0x7bcf78e5, (q31_t)0xdf850591, (q31_t)0x7bcde095, (q31_t)0xdf7ef1c2, + (q31_t)0x7bcc47fa, (q31_t)0xdf78de07, (q31_t)0x7bcaaf12, (q31_t)0xdf72ca60, + (q31_t)0x7bc915dd, (q31_t)0xdf6cb6cd, (q31_t)0x7bc77c5d, (q31_t)0xdf66a34e, + (q31_t)0x7bc5e290, (q31_t)0xdf608fe4, (q31_t)0x7bc44876, (q31_t)0xdf5a7c8d, + (q31_t)0x7bc2ae10, (q31_t)0xdf54694b, (q31_t)0x7bc1135e, (q31_t)0xdf4e561c, + (q31_t)0x7bbf7860, (q31_t)0xdf484302, (q31_t)0x7bbddd15, (q31_t)0xdf422ffd, + (q31_t)0x7bbc417e, (q31_t)0xdf3c1d0b, (q31_t)0x7bbaa59a, (q31_t)0xdf360a2d, + (q31_t)0x7bb9096b, (q31_t)0xdf2ff764, (q31_t)0x7bb76cef, (q31_t)0xdf29e4af, + (q31_t)0x7bb5d026, (q31_t)0xdf23d20e, (q31_t)0x7bb43311, (q31_t)0xdf1dbf82, + (q31_t)0x7bb295b0, (q31_t)0xdf17ad0a, (q31_t)0x7bb0f803, (q31_t)0xdf119aa6, + (q31_t)0x7baf5a09, (q31_t)0xdf0b8856, (q31_t)0x7badbbc3, (q31_t)0xdf05761b, + (q31_t)0x7bac1d31, (q31_t)0xdeff63f4, (q31_t)0x7baa7e53, (q31_t)0xdef951e2, + (q31_t)0x7ba8df28, (q31_t)0xdef33fe3, (q31_t)0x7ba73fb1, (q31_t)0xdeed2dfa, + (q31_t)0x7ba59fee, (q31_t)0xdee71c24, (q31_t)0x7ba3ffde, (q31_t)0xdee10a63, + (q31_t)0x7ba25f82, (q31_t)0xdedaf8b7, (q31_t)0x7ba0beda, (q31_t)0xded4e71f, + (q31_t)0x7b9f1de6, (q31_t)0xdeced59b, (q31_t)0x7b9d7ca5, (q31_t)0xdec8c42c, + (q31_t)0x7b9bdb18, (q31_t)0xdec2b2d1, (q31_t)0x7b9a393f, (q31_t)0xdebca18b, + (q31_t)0x7b989719, (q31_t)0xdeb69059, (q31_t)0x7b96f4a8, (q31_t)0xdeb07f3c, + (q31_t)0x7b9551ea, (q31_t)0xdeaa6e34, (q31_t)0x7b93aee0, (q31_t)0xdea45d40, + (q31_t)0x7b920b89, (q31_t)0xde9e4c60, (q31_t)0x7b9067e7, (q31_t)0xde983b95, + (q31_t)0x7b8ec3f8, (q31_t)0xde922adf, (q31_t)0x7b8d1fbd, (q31_t)0xde8c1a3e, + (q31_t)0x7b8b7b36, (q31_t)0xde8609b1, (q31_t)0x7b89d662, (q31_t)0xde7ff938, + (q31_t)0x7b883143, (q31_t)0xde79e8d5, (q31_t)0x7b868bd7, (q31_t)0xde73d886, + (q31_t)0x7b84e61f, (q31_t)0xde6dc84b, (q31_t)0x7b83401b, (q31_t)0xde67b826, + (q31_t)0x7b8199ca, (q31_t)0xde61a815, (q31_t)0x7b7ff32e, (q31_t)0xde5b9819, + (q31_t)0x7b7e4c45, (q31_t)0xde558831, (q31_t)0x7b7ca510, (q31_t)0xde4f785f, + (q31_t)0x7b7afd8f, (q31_t)0xde4968a1, (q31_t)0x7b7955c2, (q31_t)0xde4358f8, + (q31_t)0x7b77ada8, (q31_t)0xde3d4964, (q31_t)0x7b760542, (q31_t)0xde3739e4, + (q31_t)0x7b745c91, (q31_t)0xde312a7a, (q31_t)0x7b72b393, (q31_t)0xde2b1b24, + (q31_t)0x7b710a49, (q31_t)0xde250be3, (q31_t)0x7b6f60b2, (q31_t)0xde1efcb7, + (q31_t)0x7b6db6d0, (q31_t)0xde18eda0, (q31_t)0x7b6c0ca2, (q31_t)0xde12de9e, + (q31_t)0x7b6a6227, (q31_t)0xde0ccfb1, (q31_t)0x7b68b760, (q31_t)0xde06c0d9, + (q31_t)0x7b670c4d, (q31_t)0xde00b216, (q31_t)0x7b6560ee, (q31_t)0xddfaa367, + (q31_t)0x7b63b543, (q31_t)0xddf494ce, (q31_t)0x7b62094c, (q31_t)0xddee8649, + (q31_t)0x7b605d09, (q31_t)0xdde877da, (q31_t)0x7b5eb079, (q31_t)0xdde26980, + (q31_t)0x7b5d039e, (q31_t)0xdddc5b3b, (q31_t)0x7b5b5676, (q31_t)0xddd64d0a, + (q31_t)0x7b59a902, (q31_t)0xddd03eef, (q31_t)0x7b57fb42, (q31_t)0xddca30e9, + (q31_t)0x7b564d36, (q31_t)0xddc422f8, (q31_t)0x7b549ede, (q31_t)0xddbe151d, + (q31_t)0x7b52f03a, (q31_t)0xddb80756, (q31_t)0x7b51414a, (q31_t)0xddb1f9a4, + (q31_t)0x7b4f920e, (q31_t)0xddabec08, (q31_t)0x7b4de286, (q31_t)0xdda5de81, + (q31_t)0x7b4c32b1, (q31_t)0xdd9fd10f, (q31_t)0x7b4a8291, (q31_t)0xdd99c3b2, + (q31_t)0x7b48d225, (q31_t)0xdd93b66a, (q31_t)0x7b47216c, (q31_t)0xdd8da938, + (q31_t)0x7b457068, (q31_t)0xdd879c1b, (q31_t)0x7b43bf17, (q31_t)0xdd818f13, + (q31_t)0x7b420d7a, (q31_t)0xdd7b8220, (q31_t)0x7b405b92, (q31_t)0xdd757543, + (q31_t)0x7b3ea95d, (q31_t)0xdd6f687b, (q31_t)0x7b3cf6dc, (q31_t)0xdd695bc9, + (q31_t)0x7b3b4410, (q31_t)0xdd634f2b, (q31_t)0x7b3990f7, (q31_t)0xdd5d42a3, + (q31_t)0x7b37dd92, (q31_t)0xdd573631, (q31_t)0x7b3629e1, (q31_t)0xdd5129d4, + (q31_t)0x7b3475e5, (q31_t)0xdd4b1d8c, (q31_t)0x7b32c19c, (q31_t)0xdd451159, + (q31_t)0x7b310d07, (q31_t)0xdd3f053c, (q31_t)0x7b2f5826, (q31_t)0xdd38f935, + (q31_t)0x7b2da2fa, (q31_t)0xdd32ed43, (q31_t)0x7b2bed81, (q31_t)0xdd2ce166, + (q31_t)0x7b2a37bc, (q31_t)0xdd26d59f, (q31_t)0x7b2881ac, (q31_t)0xdd20c9ed, + (q31_t)0x7b26cb4f, (q31_t)0xdd1abe51, (q31_t)0x7b2514a6, (q31_t)0xdd14b2ca, + (q31_t)0x7b235db2, (q31_t)0xdd0ea759, (q31_t)0x7b21a671, (q31_t)0xdd089bfe, + (q31_t)0x7b1feee5, (q31_t)0xdd0290b8, (q31_t)0x7b1e370d, (q31_t)0xdcfc8588, + (q31_t)0x7b1c7ee8, (q31_t)0xdcf67a6d, (q31_t)0x7b1ac678, (q31_t)0xdcf06f68, + (q31_t)0x7b190dbc, (q31_t)0xdcea6478, (q31_t)0x7b1754b3, (q31_t)0xdce4599e, + (q31_t)0x7b159b5f, (q31_t)0xdcde4eda, (q31_t)0x7b13e1bf, (q31_t)0xdcd8442b, + (q31_t)0x7b1227d3, (q31_t)0xdcd23993, (q31_t)0x7b106d9b, (q31_t)0xdccc2f0f, + (q31_t)0x7b0eb318, (q31_t)0xdcc624a2, (q31_t)0x7b0cf848, (q31_t)0xdcc01a4a, + (q31_t)0x7b0b3d2c, (q31_t)0xdcba1008, (q31_t)0x7b0981c5, (q31_t)0xdcb405dc, + (q31_t)0x7b07c612, (q31_t)0xdcadfbc5, (q31_t)0x7b060a12, (q31_t)0xdca7f1c5, + (q31_t)0x7b044dc7, (q31_t)0xdca1e7da, (q31_t)0x7b029130, (q31_t)0xdc9bde05, + (q31_t)0x7b00d44d, (q31_t)0xdc95d446, (q31_t)0x7aff171e, (q31_t)0xdc8fca9c, + (q31_t)0x7afd59a4, (q31_t)0xdc89c109, (q31_t)0x7afb9bdd, (q31_t)0xdc83b78b, + (q31_t)0x7af9ddcb, (q31_t)0xdc7dae23, (q31_t)0x7af81f6c, (q31_t)0xdc77a4d2, + (q31_t)0x7af660c2, (q31_t)0xdc719b96, (q31_t)0x7af4a1cc, (q31_t)0xdc6b9270, + (q31_t)0x7af2e28b, (q31_t)0xdc658960, (q31_t)0x7af122fd, (q31_t)0xdc5f8066, + (q31_t)0x7aef6323, (q31_t)0xdc597781, (q31_t)0x7aeda2fe, (q31_t)0xdc536eb3, + (q31_t)0x7aebe28d, (q31_t)0xdc4d65fb, (q31_t)0x7aea21d0, (q31_t)0xdc475d59, + (q31_t)0x7ae860c7, (q31_t)0xdc4154cd, (q31_t)0x7ae69f73, (q31_t)0xdc3b4c57, + (q31_t)0x7ae4ddd2, (q31_t)0xdc3543f7, (q31_t)0x7ae31be6, (q31_t)0xdc2f3bad, + (q31_t)0x7ae159ae, (q31_t)0xdc293379, (q31_t)0x7adf972a, (q31_t)0xdc232b5c, + (q31_t)0x7addd45b, (q31_t)0xdc1d2354, (q31_t)0x7adc113f, (q31_t)0xdc171b63, + (q31_t)0x7ada4dd8, (q31_t)0xdc111388, (q31_t)0x7ad88a25, (q31_t)0xdc0b0bc2, + (q31_t)0x7ad6c626, (q31_t)0xdc050414, (q31_t)0x7ad501dc, (q31_t)0xdbfefc7b, + (q31_t)0x7ad33d45, (q31_t)0xdbf8f4f8, (q31_t)0x7ad17863, (q31_t)0xdbf2ed8c, + (q31_t)0x7acfb336, (q31_t)0xdbece636, (q31_t)0x7acdedbc, (q31_t)0xdbe6def6, + (q31_t)0x7acc27f7, (q31_t)0xdbe0d7cd, (q31_t)0x7aca61e6, (q31_t)0xdbdad0b9, + (q31_t)0x7ac89b89, (q31_t)0xdbd4c9bc, (q31_t)0x7ac6d4e0, (q31_t)0xdbcec2d6, + (q31_t)0x7ac50dec, (q31_t)0xdbc8bc06, (q31_t)0x7ac346ac, (q31_t)0xdbc2b54c, + (q31_t)0x7ac17f20, (q31_t)0xdbbcaea8, (q31_t)0x7abfb749, (q31_t)0xdbb6a81b, + (q31_t)0x7abdef25, (q31_t)0xdbb0a1a4, (q31_t)0x7abc26b7, (q31_t)0xdbaa9b43, + (q31_t)0x7aba5dfc, (q31_t)0xdba494f9, (q31_t)0x7ab894f6, (q31_t)0xdb9e8ec6, + (q31_t)0x7ab6cba4, (q31_t)0xdb9888a8, (q31_t)0x7ab50206, (q31_t)0xdb9282a2, + (q31_t)0x7ab3381d, (q31_t)0xdb8c7cb1, (q31_t)0x7ab16de7, (q31_t)0xdb8676d8, + (q31_t)0x7aafa367, (q31_t)0xdb807114, (q31_t)0x7aadd89a, (q31_t)0xdb7a6b68, + (q31_t)0x7aac0d82, (q31_t)0xdb7465d1, (q31_t)0x7aaa421e, (q31_t)0xdb6e6052, + (q31_t)0x7aa8766f, (q31_t)0xdb685ae9, (q31_t)0x7aa6aa74, (q31_t)0xdb625596, + (q31_t)0x7aa4de2d, (q31_t)0xdb5c505a, (q31_t)0x7aa3119a, (q31_t)0xdb564b35, + (q31_t)0x7aa144bc, (q31_t)0xdb504626, (q31_t)0x7a9f7793, (q31_t)0xdb4a412e, + (q31_t)0x7a9daa1d, (q31_t)0xdb443c4c, (q31_t)0x7a9bdc5c, (q31_t)0xdb3e3781, + (q31_t)0x7a9a0e50, (q31_t)0xdb3832cd, (q31_t)0x7a983ff7, (q31_t)0xdb322e30, + (q31_t)0x7a967153, (q31_t)0xdb2c29a9, (q31_t)0x7a94a264, (q31_t)0xdb262539, + (q31_t)0x7a92d329, (q31_t)0xdb2020e0, (q31_t)0x7a9103a2, (q31_t)0xdb1a1c9d, + (q31_t)0x7a8f33d0, (q31_t)0xdb141871, (q31_t)0x7a8d63b2, (q31_t)0xdb0e145c, + (q31_t)0x7a8b9348, (q31_t)0xdb08105e, (q31_t)0x7a89c293, (q31_t)0xdb020c77, + (q31_t)0x7a87f192, (q31_t)0xdafc08a6, (q31_t)0x7a862046, (q31_t)0xdaf604ec, + (q31_t)0x7a844eae, (q31_t)0xdaf00149, (q31_t)0x7a827ccb, (q31_t)0xdae9fdbd, + (q31_t)0x7a80aa9c, (q31_t)0xdae3fa48, (q31_t)0x7a7ed821, (q31_t)0xdaddf6ea, + (q31_t)0x7a7d055b, (q31_t)0xdad7f3a2, (q31_t)0x7a7b3249, (q31_t)0xdad1f072, + (q31_t)0x7a795eec, (q31_t)0xdacbed58, (q31_t)0x7a778b43, (q31_t)0xdac5ea56, + (q31_t)0x7a75b74f, (q31_t)0xdabfe76a, (q31_t)0x7a73e30f, (q31_t)0xdab9e495, + (q31_t)0x7a720e84, (q31_t)0xdab3e1d8, (q31_t)0x7a7039ad, (q31_t)0xdaaddf31, + (q31_t)0x7a6e648a, (q31_t)0xdaa7dca1, (q31_t)0x7a6c8f1c, (q31_t)0xdaa1da29, + (q31_t)0x7a6ab963, (q31_t)0xda9bd7c7, (q31_t)0x7a68e35e, (q31_t)0xda95d57d, + (q31_t)0x7a670d0d, (q31_t)0xda8fd349, (q31_t)0x7a653671, (q31_t)0xda89d12d, + (q31_t)0x7a635f8a, (q31_t)0xda83cf28, (q31_t)0x7a618857, (q31_t)0xda7dcd3a, + (q31_t)0x7a5fb0d8, (q31_t)0xda77cb63, (q31_t)0x7a5dd90e, (q31_t)0xda71c9a3, + (q31_t)0x7a5c00f9, (q31_t)0xda6bc7fa, (q31_t)0x7a5a2898, (q31_t)0xda65c669, + (q31_t)0x7a584feb, (q31_t)0xda5fc4ef, (q31_t)0x7a5676f3, (q31_t)0xda59c38c, + (q31_t)0x7a549db0, (q31_t)0xda53c240, (q31_t)0x7a52c421, (q31_t)0xda4dc10b, + (q31_t)0x7a50ea47, (q31_t)0xda47bfee, (q31_t)0x7a4f1021, (q31_t)0xda41bee8, + (q31_t)0x7a4d35b0, (q31_t)0xda3bbdf9, (q31_t)0x7a4b5af3, (q31_t)0xda35bd22, + (q31_t)0x7a497feb, (q31_t)0xda2fbc61, (q31_t)0x7a47a498, (q31_t)0xda29bbb9, + (q31_t)0x7a45c8f9, (q31_t)0xda23bb27, (q31_t)0x7a43ed0e, (q31_t)0xda1dbaad, + (q31_t)0x7a4210d8, (q31_t)0xda17ba4a, (q31_t)0x7a403457, (q31_t)0xda11b9ff, + (q31_t)0x7a3e578b, (q31_t)0xda0bb9cb, (q31_t)0x7a3c7a73, (q31_t)0xda05b9ae, + (q31_t)0x7a3a9d0f, (q31_t)0xd9ffb9a9, (q31_t)0x7a38bf60, (q31_t)0xd9f9b9bb, + (q31_t)0x7a36e166, (q31_t)0xd9f3b9e5, (q31_t)0x7a350321, (q31_t)0xd9edba26, + (q31_t)0x7a332490, (q31_t)0xd9e7ba7f, (q31_t)0x7a3145b3, (q31_t)0xd9e1baef, + (q31_t)0x7a2f668c, (q31_t)0xd9dbbb77, (q31_t)0x7a2d8719, (q31_t)0xd9d5bc16, + (q31_t)0x7a2ba75a, (q31_t)0xd9cfbccd, (q31_t)0x7a29c750, (q31_t)0xd9c9bd9b, + (q31_t)0x7a27e6fb, (q31_t)0xd9c3be81, (q31_t)0x7a26065b, (q31_t)0xd9bdbf7e, + (q31_t)0x7a24256f, (q31_t)0xd9b7c094, (q31_t)0x7a224437, (q31_t)0xd9b1c1c0, + (q31_t)0x7a2062b5, (q31_t)0xd9abc305, (q31_t)0x7a1e80e7, (q31_t)0xd9a5c461, + (q31_t)0x7a1c9ece, (q31_t)0xd99fc5d4, (q31_t)0x7a1abc69, (q31_t)0xd999c75f, + (q31_t)0x7a18d9b9, (q31_t)0xd993c902, (q31_t)0x7a16f6be, (q31_t)0xd98dcabd, + (q31_t)0x7a151378, (q31_t)0xd987cc90, (q31_t)0x7a132fe6, (q31_t)0xd981ce7a, + (q31_t)0x7a114c09, (q31_t)0xd97bd07c, (q31_t)0x7a0f67e0, (q31_t)0xd975d295, + (q31_t)0x7a0d836d, (q31_t)0xd96fd4c7, (q31_t)0x7a0b9eae, (q31_t)0xd969d710, + (q31_t)0x7a09b9a4, (q31_t)0xd963d971, (q31_t)0x7a07d44e, (q31_t)0xd95ddbea, + (q31_t)0x7a05eead, (q31_t)0xd957de7a, (q31_t)0x7a0408c1, (q31_t)0xd951e123, + (q31_t)0x7a02228a, (q31_t)0xd94be3e3, (q31_t)0x7a003c07, (q31_t)0xd945e6bb, + (q31_t)0x79fe5539, (q31_t)0xd93fe9ab, (q31_t)0x79fc6e20, (q31_t)0xd939ecb3, + (q31_t)0x79fa86bc, (q31_t)0xd933efd3, (q31_t)0x79f89f0c, (q31_t)0xd92df30b, + (q31_t)0x79f6b711, (q31_t)0xd927f65b, (q31_t)0x79f4cecb, (q31_t)0xd921f9c3, + (q31_t)0x79f2e63a, (q31_t)0xd91bfd43, (q31_t)0x79f0fd5d, (q31_t)0xd91600da, + (q31_t)0x79ef1436, (q31_t)0xd910048a, (q31_t)0x79ed2ac3, (q31_t)0xd90a0852, + (q31_t)0x79eb4105, (q31_t)0xd9040c32, (q31_t)0x79e956fb, (q31_t)0xd8fe1029, + (q31_t)0x79e76ca7, (q31_t)0xd8f81439, (q31_t)0x79e58207, (q31_t)0xd8f21861, + (q31_t)0x79e3971c, (q31_t)0xd8ec1ca1, (q31_t)0x79e1abe6, (q31_t)0xd8e620fa, + (q31_t)0x79dfc064, (q31_t)0xd8e0256a, (q31_t)0x79ddd498, (q31_t)0xd8da29f2, + (q31_t)0x79dbe880, (q31_t)0xd8d42e93, (q31_t)0x79d9fc1d, (q31_t)0xd8ce334c, + (q31_t)0x79d80f6f, (q31_t)0xd8c8381d, (q31_t)0x79d62276, (q31_t)0xd8c23d06, + (q31_t)0x79d43532, (q31_t)0xd8bc4207, (q31_t)0x79d247a2, (q31_t)0xd8b64720, + (q31_t)0x79d059c8, (q31_t)0xd8b04c52, (q31_t)0x79ce6ba2, (q31_t)0xd8aa519c, + (q31_t)0x79cc7d31, (q31_t)0xd8a456ff, (q31_t)0x79ca8e75, (q31_t)0xd89e5c79, + (q31_t)0x79c89f6e, (q31_t)0xd898620c, (q31_t)0x79c6b01b, (q31_t)0xd89267b7, + (q31_t)0x79c4c07e, (q31_t)0xd88c6d7b, (q31_t)0x79c2d095, (q31_t)0xd8867356, + (q31_t)0x79c0e062, (q31_t)0xd880794b, (q31_t)0x79beefe3, (q31_t)0xd87a7f57, + (q31_t)0x79bcff19, (q31_t)0xd874857c, (q31_t)0x79bb0e04, (q31_t)0xd86e8bb9, + (q31_t)0x79b91ca4, (q31_t)0xd868920f, (q31_t)0x79b72af9, (q31_t)0xd862987d, + (q31_t)0x79b53903, (q31_t)0xd85c9f04, (q31_t)0x79b346c2, (q31_t)0xd856a5a3, + (q31_t)0x79b15435, (q31_t)0xd850ac5a, (q31_t)0x79af615e, (q31_t)0xd84ab32a, + (q31_t)0x79ad6e3c, (q31_t)0xd844ba13, (q31_t)0x79ab7ace, (q31_t)0xd83ec114, + (q31_t)0x79a98715, (q31_t)0xd838c82d, (q31_t)0x79a79312, (q31_t)0xd832cf5f, + (q31_t)0x79a59ec3, (q31_t)0xd82cd6aa, (q31_t)0x79a3aa29, (q31_t)0xd826de0d, + (q31_t)0x79a1b545, (q31_t)0xd820e589, (q31_t)0x799fc015, (q31_t)0xd81aed1d, + (q31_t)0x799dca9a, (q31_t)0xd814f4ca, (q31_t)0x799bd4d4, (q31_t)0xd80efc8f, + (q31_t)0x7999dec4, (q31_t)0xd809046e, (q31_t)0x7997e868, (q31_t)0xd8030c64, + (q31_t)0x7995f1c1, (q31_t)0xd7fd1474, (q31_t)0x7993facf, (q31_t)0xd7f71c9c, + (q31_t)0x79920392, (q31_t)0xd7f124dd, (q31_t)0x79900c0a, (q31_t)0xd7eb2d37, + (q31_t)0x798e1438, (q31_t)0xd7e535a9, (q31_t)0x798c1c1a, (q31_t)0xd7df3e34, + (q31_t)0x798a23b1, (q31_t)0xd7d946d8, (q31_t)0x79882afd, (q31_t)0xd7d34f94, + (q31_t)0x798631ff, (q31_t)0xd7cd586a, (q31_t)0x798438b5, (q31_t)0xd7c76158, + (q31_t)0x79823f20, (q31_t)0xd7c16a5f, (q31_t)0x79804541, (q31_t)0xd7bb737f, + (q31_t)0x797e4b16, (q31_t)0xd7b57cb7, (q31_t)0x797c50a1, (q31_t)0xd7af8609, + (q31_t)0x797a55e0, (q31_t)0xd7a98f73, (q31_t)0x79785ad5, (q31_t)0xd7a398f6, + (q31_t)0x79765f7f, (q31_t)0xd79da293, (q31_t)0x797463de, (q31_t)0xd797ac48, + (q31_t)0x797267f2, (q31_t)0xd791b616, (q31_t)0x79706bbb, (q31_t)0xd78bbffc, + (q31_t)0x796e6f39, (q31_t)0xd785c9fc, (q31_t)0x796c726c, (q31_t)0xd77fd415, + (q31_t)0x796a7554, (q31_t)0xd779de47, (q31_t)0x796877f1, (q31_t)0xd773e892, + (q31_t)0x79667a44, (q31_t)0xd76df2f6, (q31_t)0x79647c4c, (q31_t)0xd767fd72, + (q31_t)0x79627e08, (q31_t)0xd7620808, (q31_t)0x79607f7a, (q31_t)0xd75c12b7, + (q31_t)0x795e80a1, (q31_t)0xd7561d7f, (q31_t)0x795c817d, (q31_t)0xd7502860, + (q31_t)0x795a820e, (q31_t)0xd74a335b, (q31_t)0x79588255, (q31_t)0xd7443e6e, + (q31_t)0x79568250, (q31_t)0xd73e499a, (q31_t)0x79548201, (q31_t)0xd73854e0, + (q31_t)0x79528167, (q31_t)0xd732603f, (q31_t)0x79508082, (q31_t)0xd72c6bb6, + (q31_t)0x794e7f52, (q31_t)0xd7267748, (q31_t)0x794c7dd7, (q31_t)0xd72082f2, + (q31_t)0x794a7c12, (q31_t)0xd71a8eb5, (q31_t)0x79487a01, (q31_t)0xd7149a92, + (q31_t)0x794677a6, (q31_t)0xd70ea688, (q31_t)0x79447500, (q31_t)0xd708b297, + (q31_t)0x79427210, (q31_t)0xd702bec0, (q31_t)0x79406ed4, (q31_t)0xd6fccb01, + (q31_t)0x793e6b4e, (q31_t)0xd6f6d75d, (q31_t)0x793c677d, (q31_t)0xd6f0e3d1, + (q31_t)0x793a6361, (q31_t)0xd6eaf05f, (q31_t)0x79385efa, (q31_t)0xd6e4fd06, + (q31_t)0x79365a49, (q31_t)0xd6df09c6, (q31_t)0x7934554d, (q31_t)0xd6d916a0, + (q31_t)0x79325006, (q31_t)0xd6d32393, (q31_t)0x79304a74, (q31_t)0xd6cd30a0, + (q31_t)0x792e4497, (q31_t)0xd6c73dc6, (q31_t)0x792c3e70, (q31_t)0xd6c14b05, + (q31_t)0x792a37fe, (q31_t)0xd6bb585e, (q31_t)0x79283141, (q31_t)0xd6b565d0, + (q31_t)0x79262a3a, (q31_t)0xd6af735c, (q31_t)0x792422e8, (q31_t)0xd6a98101, + (q31_t)0x79221b4b, (q31_t)0xd6a38ec0, (q31_t)0x79201363, (q31_t)0xd69d9c98, + (q31_t)0x791e0b31, (q31_t)0xd697aa8a, (q31_t)0x791c02b4, (q31_t)0xd691b895, + (q31_t)0x7919f9ec, (q31_t)0xd68bc6ba, (q31_t)0x7917f0d9, (q31_t)0xd685d4f9, + (q31_t)0x7915e77c, (q31_t)0xd67fe351, (q31_t)0x7913ddd4, (q31_t)0xd679f1c2, + (q31_t)0x7911d3e2, (q31_t)0xd674004e, (q31_t)0x790fc9a4, (q31_t)0xd66e0ef2, + (q31_t)0x790dbf1d, (q31_t)0xd6681db1, (q31_t)0x790bb44a, (q31_t)0xd6622c89, + (q31_t)0x7909a92d, (q31_t)0xd65c3b7b, (q31_t)0x79079dc5, (q31_t)0xd6564a87, + (q31_t)0x79059212, (q31_t)0xd65059ac, (q31_t)0x79038615, (q31_t)0xd64a68eb, + (q31_t)0x790179cd, (q31_t)0xd6447844, (q31_t)0x78ff6d3b, (q31_t)0xd63e87b6, + (q31_t)0x78fd605d, (q31_t)0xd6389742, (q31_t)0x78fb5336, (q31_t)0xd632a6e8, + (q31_t)0x78f945c3, (q31_t)0xd62cb6a8, (q31_t)0x78f73806, (q31_t)0xd626c681, + (q31_t)0x78f529fe, (q31_t)0xd620d675, (q31_t)0x78f31bac, (q31_t)0xd61ae682, + (q31_t)0x78f10d0f, (q31_t)0xd614f6a9, (q31_t)0x78eefe28, (q31_t)0xd60f06ea, + (q31_t)0x78eceef6, (q31_t)0xd6091745, (q31_t)0x78eadf79, (q31_t)0xd60327b9, + (q31_t)0x78e8cfb2, (q31_t)0xd5fd3848, (q31_t)0x78e6bfa0, (q31_t)0xd5f748f0, + (q31_t)0x78e4af44, (q31_t)0xd5f159b3, (q31_t)0x78e29e9d, (q31_t)0xd5eb6a8f, + (q31_t)0x78e08dab, (q31_t)0xd5e57b85, (q31_t)0x78de7c6f, (q31_t)0xd5df8c96, + (q31_t)0x78dc6ae8, (q31_t)0xd5d99dc0, (q31_t)0x78da5917, (q31_t)0xd5d3af04, + (q31_t)0x78d846fb, (q31_t)0xd5cdc062, (q31_t)0x78d63495, (q31_t)0xd5c7d1db, + (q31_t)0x78d421e4, (q31_t)0xd5c1e36d, (q31_t)0x78d20ee9, (q31_t)0xd5bbf519, + (q31_t)0x78cffba3, (q31_t)0xd5b606e0, (q31_t)0x78cde812, (q31_t)0xd5b018c0, + (q31_t)0x78cbd437, (q31_t)0xd5aa2abb, (q31_t)0x78c9c012, (q31_t)0xd5a43cd0, + (q31_t)0x78c7aba2, (q31_t)0xd59e4eff, (q31_t)0x78c596e7, (q31_t)0xd5986148, + (q31_t)0x78c381e2, (q31_t)0xd59273ab, (q31_t)0x78c16c93, (q31_t)0xd58c8628, + (q31_t)0x78bf56f9, (q31_t)0xd58698c0, (q31_t)0x78bd4114, (q31_t)0xd580ab72, + (q31_t)0x78bb2ae5, (q31_t)0xd57abe3d, (q31_t)0x78b9146c, (q31_t)0xd574d124, + (q31_t)0x78b6fda8, (q31_t)0xd56ee424, (q31_t)0x78b4e69a, (q31_t)0xd568f73f, + (q31_t)0x78b2cf41, (q31_t)0xd5630a74, (q31_t)0x78b0b79e, (q31_t)0xd55d1dc3, + (q31_t)0x78ae9fb0, (q31_t)0xd557312d, (q31_t)0x78ac8778, (q31_t)0xd55144b0, + (q31_t)0x78aa6ef5, (q31_t)0xd54b584f, (q31_t)0x78a85628, (q31_t)0xd5456c07, + (q31_t)0x78a63d11, (q31_t)0xd53f7fda, (q31_t)0x78a423af, (q31_t)0xd53993c7, + (q31_t)0x78a20a03, (q31_t)0xd533a7cf, (q31_t)0x789ff00c, (q31_t)0xd52dbbf1, + (q31_t)0x789dd5cb, (q31_t)0xd527d02e, (q31_t)0x789bbb3f, (q31_t)0xd521e484, + (q31_t)0x7899a06a, (q31_t)0xd51bf8f6, (q31_t)0x78978549, (q31_t)0xd5160d82, + (q31_t)0x789569df, (q31_t)0xd5102228, (q31_t)0x78934e2a, (q31_t)0xd50a36e9, + (q31_t)0x7891322a, (q31_t)0xd5044bc4, (q31_t)0x788f15e0, (q31_t)0xd4fe60ba, + (q31_t)0x788cf94c, (q31_t)0xd4f875ca, (q31_t)0x788adc6e, (q31_t)0xd4f28af5, + (q31_t)0x7888bf45, (q31_t)0xd4eca03a, (q31_t)0x7886a1d1, (q31_t)0xd4e6b59a, + (q31_t)0x78848414, (q31_t)0xd4e0cb15, (q31_t)0x7882660c, (q31_t)0xd4dae0aa, + (q31_t)0x788047ba, (q31_t)0xd4d4f65a, (q31_t)0x787e291d, (q31_t)0xd4cf0c24, + (q31_t)0x787c0a36, (q31_t)0xd4c92209, (q31_t)0x7879eb05, (q31_t)0xd4c33809, + (q31_t)0x7877cb89, (q31_t)0xd4bd4e23, (q31_t)0x7875abc3, (q31_t)0xd4b76458, + (q31_t)0x78738bb3, (q31_t)0xd4b17aa8, (q31_t)0x78716b59, (q31_t)0xd4ab9112, + (q31_t)0x786f4ab4, (q31_t)0xd4a5a798, (q31_t)0x786d29c5, (q31_t)0xd49fbe37, + (q31_t)0x786b088c, (q31_t)0xd499d4f2, (q31_t)0x7868e708, (q31_t)0xd493ebc8, + (q31_t)0x7866c53a, (q31_t)0xd48e02b8, (q31_t)0x7864a322, (q31_t)0xd48819c3, + (q31_t)0x786280bf, (q31_t)0xd48230e9, (q31_t)0x78605e13, (q31_t)0xd47c4829, + (q31_t)0x785e3b1c, (q31_t)0xd4765f85, (q31_t)0x785c17db, (q31_t)0xd47076fb, + (q31_t)0x7859f44f, (q31_t)0xd46a8e8d, (q31_t)0x7857d079, (q31_t)0xd464a639, + (q31_t)0x7855ac5a, (q31_t)0xd45ebe00, (q31_t)0x785387ef, (q31_t)0xd458d5e2, + (q31_t)0x7851633b, (q31_t)0xd452eddf, (q31_t)0x784f3e3c, (q31_t)0xd44d05f6, + (q31_t)0x784d18f4, (q31_t)0xd4471e29, (q31_t)0x784af361, (q31_t)0xd4413677, + (q31_t)0x7848cd83, (q31_t)0xd43b4ee0, (q31_t)0x7846a75c, (q31_t)0xd4356763, + (q31_t)0x784480ea, (q31_t)0xd42f8002, (q31_t)0x78425a2f, (q31_t)0xd42998bc, + (q31_t)0x78403329, (q31_t)0xd423b191, (q31_t)0x783e0bd9, (q31_t)0xd41dca81, + (q31_t)0x783be43e, (q31_t)0xd417e38c, (q31_t)0x7839bc5a, (q31_t)0xd411fcb2, + (q31_t)0x7837942b, (q31_t)0xd40c15f3, (q31_t)0x78356bb2, (q31_t)0xd4062f4f, + (q31_t)0x783342ef, (q31_t)0xd40048c6, (q31_t)0x783119e2, (q31_t)0xd3fa6259, + (q31_t)0x782ef08b, (q31_t)0xd3f47c06, (q31_t)0x782cc6ea, (q31_t)0xd3ee95cf, + (q31_t)0x782a9cfe, (q31_t)0xd3e8afb3, (q31_t)0x782872c8, (q31_t)0xd3e2c9b2, + (q31_t)0x78264849, (q31_t)0xd3dce3cd, (q31_t)0x78241d7f, (q31_t)0xd3d6fe03, + (q31_t)0x7821f26b, (q31_t)0xd3d11853, (q31_t)0x781fc70d, (q31_t)0xd3cb32c0, + (q31_t)0x781d9b65, (q31_t)0xd3c54d47, (q31_t)0x781b6f72, (q31_t)0xd3bf67ea, + (q31_t)0x78194336, (q31_t)0xd3b982a8, (q31_t)0x781716b0, (q31_t)0xd3b39d81, + (q31_t)0x7814e9df, (q31_t)0xd3adb876, (q31_t)0x7812bcc4, (q31_t)0xd3a7d385, + (q31_t)0x78108f60, (q31_t)0xd3a1eeb1, (q31_t)0x780e61b1, (q31_t)0xd39c09f7, + (q31_t)0x780c33b8, (q31_t)0xd396255a, (q31_t)0x780a0575, (q31_t)0xd39040d7, + (q31_t)0x7807d6e9, (q31_t)0xd38a5c70, (q31_t)0x7805a812, (q31_t)0xd3847824, + (q31_t)0x780378f1, (q31_t)0xd37e93f4, (q31_t)0x78014986, (q31_t)0xd378afdf, + (q31_t)0x77ff19d1, (q31_t)0xd372cbe6, (q31_t)0x77fce9d2, (q31_t)0xd36ce808, + (q31_t)0x77fab989, (q31_t)0xd3670446, (q31_t)0x77f888f6, (q31_t)0xd361209f, + (q31_t)0x77f65819, (q31_t)0xd35b3d13, (q31_t)0x77f426f2, (q31_t)0xd35559a4, + (q31_t)0x77f1f581, (q31_t)0xd34f764f, (q31_t)0x77efc3c5, (q31_t)0xd3499317, + (q31_t)0x77ed91c0, (q31_t)0xd343affa, (q31_t)0x77eb5f71, (q31_t)0xd33dccf8, + (q31_t)0x77e92cd9, (q31_t)0xd337ea12, (q31_t)0x77e6f9f6, (q31_t)0xd3320748, + (q31_t)0x77e4c6c9, (q31_t)0xd32c2499, (q31_t)0x77e29352, (q31_t)0xd3264206, + (q31_t)0x77e05f91, (q31_t)0xd3205f8f, (q31_t)0x77de2b86, (q31_t)0xd31a7d33, + (q31_t)0x77dbf732, (q31_t)0xd3149af3, (q31_t)0x77d9c293, (q31_t)0xd30eb8cf, + (q31_t)0x77d78daa, (q31_t)0xd308d6c7, (q31_t)0x77d55878, (q31_t)0xd302f4da, + (q31_t)0x77d322fc, (q31_t)0xd2fd1309, (q31_t)0x77d0ed35, (q31_t)0xd2f73154, + (q31_t)0x77ceb725, (q31_t)0xd2f14fba, (q31_t)0x77cc80cb, (q31_t)0xd2eb6e3c, + (q31_t)0x77ca4a27, (q31_t)0xd2e58cdb, (q31_t)0x77c81339, (q31_t)0xd2dfab95, + (q31_t)0x77c5dc01, (q31_t)0xd2d9ca6a, (q31_t)0x77c3a47f, (q31_t)0xd2d3e95c, + (q31_t)0x77c16cb4, (q31_t)0xd2ce0869, (q31_t)0x77bf349f, (q31_t)0xd2c82793, + (q31_t)0x77bcfc3f, (q31_t)0xd2c246d8, (q31_t)0x77bac396, (q31_t)0xd2bc6639, + (q31_t)0x77b88aa3, (q31_t)0xd2b685b6, (q31_t)0x77b65166, (q31_t)0xd2b0a54f, + (q31_t)0x77b417df, (q31_t)0xd2aac504, (q31_t)0x77b1de0f, (q31_t)0xd2a4e4d5, + (q31_t)0x77afa3f5, (q31_t)0xd29f04c2, (q31_t)0x77ad6990, (q31_t)0xd29924cb, + (q31_t)0x77ab2ee2, (q31_t)0xd29344f0, (q31_t)0x77a8f3ea, (q31_t)0xd28d6531, + (q31_t)0x77a6b8a9, (q31_t)0xd287858e, (q31_t)0x77a47d1d, (q31_t)0xd281a607, + (q31_t)0x77a24148, (q31_t)0xd27bc69c, (q31_t)0x77a00529, (q31_t)0xd275e74d, + (q31_t)0x779dc8c0, (q31_t)0xd270081b, (q31_t)0x779b8c0e, (q31_t)0xd26a2904, + (q31_t)0x77994f11, (q31_t)0xd2644a0a, (q31_t)0x779711cb, (q31_t)0xd25e6b2b, + (q31_t)0x7794d43b, (q31_t)0xd2588c69, (q31_t)0x77929661, (q31_t)0xd252adc3, + (q31_t)0x7790583e, (q31_t)0xd24ccf39, (q31_t)0x778e19d0, (q31_t)0xd246f0cb, + (q31_t)0x778bdb19, (q31_t)0xd241127a, (q31_t)0x77899c19, (q31_t)0xd23b3444, + (q31_t)0x77875cce, (q31_t)0xd235562b, (q31_t)0x77851d3a, (q31_t)0xd22f782f, + (q31_t)0x7782dd5c, (q31_t)0xd2299a4e, (q31_t)0x77809d35, (q31_t)0xd223bc8a, + (q31_t)0x777e5cc3, (q31_t)0xd21ddee2, (q31_t)0x777c1c08, (q31_t)0xd2180156, + (q31_t)0x7779db03, (q31_t)0xd21223e7, (q31_t)0x777799b5, (q31_t)0xd20c4694, + (q31_t)0x7775581d, (q31_t)0xd206695d, (q31_t)0x7773163b, (q31_t)0xd2008c43, + (q31_t)0x7770d40f, (q31_t)0xd1faaf45, (q31_t)0x776e919a, (q31_t)0xd1f4d263, + (q31_t)0x776c4edb, (q31_t)0xd1eef59e, (q31_t)0x776a0bd3, (q31_t)0xd1e918f5, + (q31_t)0x7767c880, (q31_t)0xd1e33c69, (q31_t)0x776584e5, (q31_t)0xd1dd5ff9, + (q31_t)0x776340ff, (q31_t)0xd1d783a6, (q31_t)0x7760fcd0, (q31_t)0xd1d1a76f, + (q31_t)0x775eb857, (q31_t)0xd1cbcb54, (q31_t)0x775c7395, (q31_t)0xd1c5ef56, + (q31_t)0x775a2e89, (q31_t)0xd1c01375, (q31_t)0x7757e933, (q31_t)0xd1ba37b0, + (q31_t)0x7755a394, (q31_t)0xd1b45c08, (q31_t)0x77535dab, (q31_t)0xd1ae807c, + (q31_t)0x77511778, (q31_t)0xd1a8a50d, (q31_t)0x774ed0fc, (q31_t)0xd1a2c9ba, + (q31_t)0x774c8a36, (q31_t)0xd19cee84, (q31_t)0x774a4327, (q31_t)0xd197136b, + (q31_t)0x7747fbce, (q31_t)0xd191386e, (q31_t)0x7745b42c, (q31_t)0xd18b5d8e, + (q31_t)0x77436c40, (q31_t)0xd18582ca, (q31_t)0x7741240a, (q31_t)0xd17fa823, + (q31_t)0x773edb8b, (q31_t)0xd179cd99, (q31_t)0x773c92c2, (q31_t)0xd173f32c, + (q31_t)0x773a49b0, (q31_t)0xd16e18db, (q31_t)0x77380054, (q31_t)0xd1683ea7, + (q31_t)0x7735b6af, (q31_t)0xd1626490, (q31_t)0x77336cc0, (q31_t)0xd15c8a95, + (q31_t)0x77312287, (q31_t)0xd156b0b7, (q31_t)0x772ed805, (q31_t)0xd150d6f6, + (q31_t)0x772c8d3a, (q31_t)0xd14afd52, (q31_t)0x772a4225, (q31_t)0xd14523cb, + (q31_t)0x7727f6c6, (q31_t)0xd13f4a60, (q31_t)0x7725ab1f, (q31_t)0xd1397113, + (q31_t)0x77235f2d, (q31_t)0xd13397e2, (q31_t)0x772112f2, (q31_t)0xd12dbece, + (q31_t)0x771ec66e, (q31_t)0xd127e5d7, (q31_t)0x771c79a0, (q31_t)0xd1220cfc, + (q31_t)0x771a2c88, (q31_t)0xd11c343f, (q31_t)0x7717df27, (q31_t)0xd1165b9f, + (q31_t)0x7715917d, (q31_t)0xd110831b, (q31_t)0x77134389, (q31_t)0xd10aaab5, + (q31_t)0x7710f54c, (q31_t)0xd104d26b, (q31_t)0x770ea6c5, (q31_t)0xd0fefa3f, + (q31_t)0x770c57f5, (q31_t)0xd0f9222f, (q31_t)0x770a08dc, (q31_t)0xd0f34a3d, + (q31_t)0x7707b979, (q31_t)0xd0ed7267, (q31_t)0x770569cc, (q31_t)0xd0e79aaf, + (q31_t)0x770319d6, (q31_t)0xd0e1c313, (q31_t)0x7700c997, (q31_t)0xd0dbeb95, + (q31_t)0x76fe790e, (q31_t)0xd0d61434, (q31_t)0x76fc283c, (q31_t)0xd0d03cf0, + (q31_t)0x76f9d721, (q31_t)0xd0ca65c9, (q31_t)0x76f785bc, (q31_t)0xd0c48ebf, + (q31_t)0x76f5340e, (q31_t)0xd0beb7d2, (q31_t)0x76f2e216, (q31_t)0xd0b8e102, + (q31_t)0x76f08fd5, (q31_t)0xd0b30a50, (q31_t)0x76ee3d4b, (q31_t)0xd0ad33ba, + (q31_t)0x76ebea77, (q31_t)0xd0a75d42, (q31_t)0x76e9975a, (q31_t)0xd0a186e7, + (q31_t)0x76e743f4, (q31_t)0xd09bb0aa, (q31_t)0x76e4f044, (q31_t)0xd095da89, + (q31_t)0x76e29c4b, (q31_t)0xd0900486, (q31_t)0x76e04808, (q31_t)0xd08a2ea0, + (q31_t)0x76ddf37c, (q31_t)0xd08458d7, (q31_t)0x76db9ea7, (q31_t)0xd07e832c, + (q31_t)0x76d94989, (q31_t)0xd078ad9e, (q31_t)0x76d6f421, (q31_t)0xd072d82d, + (q31_t)0x76d49e70, (q31_t)0xd06d02da, (q31_t)0x76d24876, (q31_t)0xd0672da3, + (q31_t)0x76cff232, (q31_t)0xd061588b, (q31_t)0x76cd9ba5, (q31_t)0xd05b838f, + (q31_t)0x76cb44cf, (q31_t)0xd055aeb1, (q31_t)0x76c8edb0, (q31_t)0xd04fd9f1, + (q31_t)0x76c69647, (q31_t)0xd04a054e, (q31_t)0x76c43e95, (q31_t)0xd04430c8, + (q31_t)0x76c1e699, (q31_t)0xd03e5c60, (q31_t)0x76bf8e55, (q31_t)0xd0388815, + (q31_t)0x76bd35c7, (q31_t)0xd032b3e7, (q31_t)0x76badcf0, (q31_t)0xd02cdfd8, + (q31_t)0x76b883d0, (q31_t)0xd0270be5, (q31_t)0x76b62a66, (q31_t)0xd0213810, + (q31_t)0x76b3d0b4, (q31_t)0xd01b6459, (q31_t)0x76b176b8, (q31_t)0xd01590bf, + (q31_t)0x76af1c72, (q31_t)0xd00fbd43, (q31_t)0x76acc1e4, (q31_t)0xd009e9e4, + (q31_t)0x76aa670d, (q31_t)0xd00416a3, (q31_t)0x76a80bec, (q31_t)0xcffe4380, + (q31_t)0x76a5b082, (q31_t)0xcff8707a, (q31_t)0x76a354cf, (q31_t)0xcff29d92, + (q31_t)0x76a0f8d2, (q31_t)0xcfeccac7, (q31_t)0x769e9c8d, (q31_t)0xcfe6f81a, + (q31_t)0x769c3ffe, (q31_t)0xcfe1258b, (q31_t)0x7699e326, (q31_t)0xcfdb531a, + (q31_t)0x76978605, (q31_t)0xcfd580c6, (q31_t)0x7695289b, (q31_t)0xcfcfae8f, + (q31_t)0x7692cae8, (q31_t)0xcfc9dc77, (q31_t)0x76906ceb, (q31_t)0xcfc40a7c, + (q31_t)0x768e0ea6, (q31_t)0xcfbe389f, (q31_t)0x768bb017, (q31_t)0xcfb866e0, + (q31_t)0x7689513f, (q31_t)0xcfb2953f, (q31_t)0x7686f21e, (q31_t)0xcfacc3bb, + (q31_t)0x768492b4, (q31_t)0xcfa6f255, (q31_t)0x76823301, (q31_t)0xcfa1210d, + (q31_t)0x767fd304, (q31_t)0xcf9b4fe3, (q31_t)0x767d72bf, (q31_t)0xcf957ed7, + (q31_t)0x767b1231, (q31_t)0xcf8fade9, (q31_t)0x7678b159, (q31_t)0xcf89dd18, + (q31_t)0x76765038, (q31_t)0xcf840c65, (q31_t)0x7673eecf, (q31_t)0xcf7e3bd1, + (q31_t)0x76718d1c, (q31_t)0xcf786b5a, (q31_t)0x766f2b20, (q31_t)0xcf729b01, + (q31_t)0x766cc8db, (q31_t)0xcf6ccac6, (q31_t)0x766a664d, (q31_t)0xcf66faa9, + (q31_t)0x76680376, (q31_t)0xcf612aaa, (q31_t)0x7665a056, (q31_t)0xcf5b5ac9, + (q31_t)0x76633ced, (q31_t)0xcf558b06, (q31_t)0x7660d93b, (q31_t)0xcf4fbb61, + (q31_t)0x765e7540, (q31_t)0xcf49ebda, (q31_t)0x765c10fc, (q31_t)0xcf441c71, + (q31_t)0x7659ac6f, (q31_t)0xcf3e4d26, (q31_t)0x76574798, (q31_t)0xcf387dfa, + (q31_t)0x7654e279, (q31_t)0xcf32aeeb, (q31_t)0x76527d11, (q31_t)0xcf2cdffa, + (q31_t)0x76501760, (q31_t)0xcf271128, (q31_t)0x764db166, (q31_t)0xcf214274, + (q31_t)0x764b4b23, (q31_t)0xcf1b73de, (q31_t)0x7648e497, (q31_t)0xcf15a566, + (q31_t)0x76467dc2, (q31_t)0xcf0fd70c, (q31_t)0x764416a4, (q31_t)0xcf0a08d0, + (q31_t)0x7641af3d, (q31_t)0xcf043ab3, (q31_t)0x763f478d, (q31_t)0xcefe6cb3, + (q31_t)0x763cdf94, (q31_t)0xcef89ed2, (q31_t)0x763a7752, (q31_t)0xcef2d110, + (q31_t)0x76380ec8, (q31_t)0xceed036b, (q31_t)0x7635a5f4, (q31_t)0xcee735e5, + (q31_t)0x76333cd8, (q31_t)0xcee1687d, (q31_t)0x7630d372, (q31_t)0xcedb9b33, + (q31_t)0x762e69c4, (q31_t)0xced5ce08, (q31_t)0x762bffcd, (q31_t)0xced000fb, + (q31_t)0x7629958c, (q31_t)0xceca340c, (q31_t)0x76272b03, (q31_t)0xcec4673c, + (q31_t)0x7624c031, (q31_t)0xcebe9a8a, (q31_t)0x76225517, (q31_t)0xceb8cdf7, + (q31_t)0x761fe9b3, (q31_t)0xceb30181, (q31_t)0x761d7e06, (q31_t)0xcead352b, + (q31_t)0x761b1211, (q31_t)0xcea768f2, (q31_t)0x7618a5d3, (q31_t)0xcea19cd8, + (q31_t)0x7616394c, (q31_t)0xce9bd0dd, (q31_t)0x7613cc7c, (q31_t)0xce960500, + (q31_t)0x76115f63, (q31_t)0xce903942, (q31_t)0x760ef201, (q31_t)0xce8a6da2, + (q31_t)0x760c8457, (q31_t)0xce84a220, (q31_t)0x760a1664, (q31_t)0xce7ed6bd, + (q31_t)0x7607a828, (q31_t)0xce790b79, (q31_t)0x760539a3, (q31_t)0xce734053, + (q31_t)0x7602cad5, (q31_t)0xce6d754c, (q31_t)0x76005bbf, (q31_t)0xce67aa63, + (q31_t)0x75fdec60, (q31_t)0xce61df99, (q31_t)0x75fb7cb8, (q31_t)0xce5c14ed, + (q31_t)0x75f90cc7, (q31_t)0xce564a60, (q31_t)0x75f69c8d, (q31_t)0xce507ff2, + (q31_t)0x75f42c0b, (q31_t)0xce4ab5a2, (q31_t)0x75f1bb40, (q31_t)0xce44eb71, + (q31_t)0x75ef4a2c, (q31_t)0xce3f215f, (q31_t)0x75ecd8cf, (q31_t)0xce39576c, + (q31_t)0x75ea672a, (q31_t)0xce338d97, (q31_t)0x75e7f53c, (q31_t)0xce2dc3e1, + (q31_t)0x75e58305, (q31_t)0xce27fa49, (q31_t)0x75e31086, (q31_t)0xce2230d0, + (q31_t)0x75e09dbd, (q31_t)0xce1c6777, (q31_t)0x75de2aac, (q31_t)0xce169e3b, + (q31_t)0x75dbb753, (q31_t)0xce10d51f, (q31_t)0x75d943b0, (q31_t)0xce0b0c21, + (q31_t)0x75d6cfc5, (q31_t)0xce054343, (q31_t)0x75d45b92, (q31_t)0xcdff7a83, + (q31_t)0x75d1e715, (q31_t)0xcdf9b1e2, (q31_t)0x75cf7250, (q31_t)0xcdf3e95f, + (q31_t)0x75ccfd42, (q31_t)0xcdee20fc, (q31_t)0x75ca87ec, (q31_t)0xcde858b8, + (q31_t)0x75c8124d, (q31_t)0xcde29092, (q31_t)0x75c59c65, (q31_t)0xcddcc88b, + (q31_t)0x75c32634, (q31_t)0xcdd700a4, (q31_t)0x75c0afbb, (q31_t)0xcdd138db, + (q31_t)0x75be38fa, (q31_t)0xcdcb7131, (q31_t)0x75bbc1ef, (q31_t)0xcdc5a9a6, + (q31_t)0x75b94a9c, (q31_t)0xcdbfe23a, (q31_t)0x75b6d301, (q31_t)0xcdba1aee, + (q31_t)0x75b45b1d, (q31_t)0xcdb453c0, (q31_t)0x75b1e2f0, (q31_t)0xcdae8cb1, + (q31_t)0x75af6a7b, (q31_t)0xcda8c5c1, (q31_t)0x75acf1bd, (q31_t)0xcda2fef0, + (q31_t)0x75aa78b6, (q31_t)0xcd9d383f, (q31_t)0x75a7ff67, (q31_t)0xcd9771ac, + (q31_t)0x75a585cf, (q31_t)0xcd91ab39, (q31_t)0x75a30bef, (q31_t)0xcd8be4e4, + (q31_t)0x75a091c6, (q31_t)0xcd861eaf, (q31_t)0x759e1755, (q31_t)0xcd805899, + (q31_t)0x759b9c9b, (q31_t)0xcd7a92a2, (q31_t)0x75992198, (q31_t)0xcd74ccca, + (q31_t)0x7596a64d, (q31_t)0xcd6f0711, (q31_t)0x75942ab9, (q31_t)0xcd694178, + (q31_t)0x7591aedd, (q31_t)0xcd637bfe, (q31_t)0x758f32b9, (q31_t)0xcd5db6a3, + (q31_t)0x758cb64c, (q31_t)0xcd57f167, (q31_t)0x758a3996, (q31_t)0xcd522c4a, + (q31_t)0x7587bc98, (q31_t)0xcd4c674d, (q31_t)0x75853f51, (q31_t)0xcd46a26f, + (q31_t)0x7582c1c2, (q31_t)0xcd40ddb0, (q31_t)0x758043ea, (q31_t)0xcd3b1911, + (q31_t)0x757dc5ca, (q31_t)0xcd355491, (q31_t)0x757b4762, (q31_t)0xcd2f9030, + (q31_t)0x7578c8b0, (q31_t)0xcd29cbee, (q31_t)0x757649b7, (q31_t)0xcd2407cc, + (q31_t)0x7573ca75, (q31_t)0xcd1e43ca, (q31_t)0x75714aea, (q31_t)0xcd187fe6, + (q31_t)0x756ecb18, (q31_t)0xcd12bc22, (q31_t)0x756c4afc, (q31_t)0xcd0cf87e, + (q31_t)0x7569ca99, (q31_t)0xcd0734f9, (q31_t)0x756749ec, (q31_t)0xcd017193, + (q31_t)0x7564c8f8, (q31_t)0xccfbae4d, (q31_t)0x756247bb, (q31_t)0xccf5eb26, + (q31_t)0x755fc635, (q31_t)0xccf0281f, (q31_t)0x755d4467, (q31_t)0xccea6538, + (q31_t)0x755ac251, (q31_t)0xcce4a26f, (q31_t)0x75583ff3, (q31_t)0xccdedfc7, + (q31_t)0x7555bd4c, (q31_t)0xccd91d3d, (q31_t)0x75533a5c, (q31_t)0xccd35ad4, + (q31_t)0x7550b725, (q31_t)0xcccd988a, (q31_t)0x754e33a4, (q31_t)0xccc7d65f, + (q31_t)0x754bafdc, (q31_t)0xccc21455, (q31_t)0x75492bcb, (q31_t)0xccbc5269, + (q31_t)0x7546a772, (q31_t)0xccb6909e, (q31_t)0x754422d0, (q31_t)0xccb0cef2, + (q31_t)0x75419de7, (q31_t)0xccab0d65, (q31_t)0x753f18b4, (q31_t)0xcca54bf9, + (q31_t)0x753c933a, (q31_t)0xcc9f8aac, (q31_t)0x753a0d77, (q31_t)0xcc99c97e, + (q31_t)0x7537876c, (q31_t)0xcc940871, (q31_t)0x75350118, (q31_t)0xcc8e4783, + (q31_t)0x75327a7d, (q31_t)0xcc8886b5, (q31_t)0x752ff399, (q31_t)0xcc82c607, + (q31_t)0x752d6c6c, (q31_t)0xcc7d0578, (q31_t)0x752ae4f8, (q31_t)0xcc774509, + (q31_t)0x75285d3b, (q31_t)0xcc7184ba, (q31_t)0x7525d536, (q31_t)0xcc6bc48b, + (q31_t)0x75234ce8, (q31_t)0xcc66047b, (q31_t)0x7520c453, (q31_t)0xcc60448c, + (q31_t)0x751e3b75, (q31_t)0xcc5a84bc, (q31_t)0x751bb24f, (q31_t)0xcc54c50c, + (q31_t)0x751928e0, (q31_t)0xcc4f057c, (q31_t)0x75169f2a, (q31_t)0xcc49460c, + (q31_t)0x7514152b, (q31_t)0xcc4386bc, (q31_t)0x75118ae4, (q31_t)0xcc3dc78b, + (q31_t)0x750f0054, (q31_t)0xcc38087b, (q31_t)0x750c757d, (q31_t)0xcc32498a, + (q31_t)0x7509ea5d, (q31_t)0xcc2c8aba, (q31_t)0x75075ef5, (q31_t)0xcc26cc09, + (q31_t)0x7504d345, (q31_t)0xcc210d79, (q31_t)0x7502474d, (q31_t)0xcc1b4f08, + (q31_t)0x74ffbb0d, (q31_t)0xcc1590b8, (q31_t)0x74fd2e84, (q31_t)0xcc0fd287, + (q31_t)0x74faa1b3, (q31_t)0xcc0a1477, (q31_t)0x74f8149a, (q31_t)0xcc045686, + (q31_t)0x74f58739, (q31_t)0xcbfe98b6, (q31_t)0x74f2f990, (q31_t)0xcbf8db05, + (q31_t)0x74f06b9e, (q31_t)0xcbf31d75, (q31_t)0x74eddd65, (q31_t)0xcbed6005, + (q31_t)0x74eb4ee3, (q31_t)0xcbe7a2b5, (q31_t)0x74e8c01a, (q31_t)0xcbe1e585, + (q31_t)0x74e63108, (q31_t)0xcbdc2876, (q31_t)0x74e3a1ae, (q31_t)0xcbd66b86, + (q31_t)0x74e1120c, (q31_t)0xcbd0aeb7, (q31_t)0x74de8221, (q31_t)0xcbcaf208, + (q31_t)0x74dbf1ef, (q31_t)0xcbc53579, (q31_t)0x74d96175, (q31_t)0xcbbf790a, + (q31_t)0x74d6d0b2, (q31_t)0xcbb9bcbb, (q31_t)0x74d43fa8, (q31_t)0xcbb4008d, + (q31_t)0x74d1ae55, (q31_t)0xcbae447f, (q31_t)0x74cf1cbb, (q31_t)0xcba88891, + (q31_t)0x74cc8ad8, (q31_t)0xcba2ccc4, (q31_t)0x74c9f8ad, (q31_t)0xcb9d1117, + (q31_t)0x74c7663a, (q31_t)0xcb97558a, (q31_t)0x74c4d380, (q31_t)0xcb919a1d, + (q31_t)0x74c2407d, (q31_t)0xcb8bded1, (q31_t)0x74bfad32, (q31_t)0xcb8623a5, + (q31_t)0x74bd199f, (q31_t)0xcb80689a, (q31_t)0x74ba85c4, (q31_t)0xcb7aadaf, + (q31_t)0x74b7f1a1, (q31_t)0xcb74f2e4, (q31_t)0x74b55d36, (q31_t)0xcb6f383a, + (q31_t)0x74b2c884, (q31_t)0xcb697db0, (q31_t)0x74b03389, (q31_t)0xcb63c347, + (q31_t)0x74ad9e46, (q31_t)0xcb5e08fe, (q31_t)0x74ab08bb, (q31_t)0xcb584ed6, + (q31_t)0x74a872e8, (q31_t)0xcb5294ce, (q31_t)0x74a5dccd, (q31_t)0xcb4cdae6, + (q31_t)0x74a3466b, (q31_t)0xcb47211f, (q31_t)0x74a0afc0, (q31_t)0xcb416779, + (q31_t)0x749e18cd, (q31_t)0xcb3badf3, (q31_t)0x749b8193, (q31_t)0xcb35f48d, + (q31_t)0x7498ea11, (q31_t)0xcb303b49, (q31_t)0x74965246, (q31_t)0xcb2a8224, + (q31_t)0x7493ba34, (q31_t)0xcb24c921, (q31_t)0x749121da, (q31_t)0xcb1f103e, + (q31_t)0x748e8938, (q31_t)0xcb19577b, (q31_t)0x748bf04d, (q31_t)0xcb139ed9, + (q31_t)0x7489571c, (q31_t)0xcb0de658, (q31_t)0x7486bda2, (q31_t)0xcb082df8, + (q31_t)0x748423e0, (q31_t)0xcb0275b8, (q31_t)0x748189d7, (q31_t)0xcafcbd99, + (q31_t)0x747eef85, (q31_t)0xcaf7059a, (q31_t)0x747c54ec, (q31_t)0xcaf14dbd, + (q31_t)0x7479ba0b, (q31_t)0xcaeb9600, (q31_t)0x74771ee2, (q31_t)0xcae5de64, + (q31_t)0x74748371, (q31_t)0xcae026e8, (q31_t)0x7471e7b8, (q31_t)0xcada6f8d, + (q31_t)0x746f4bb8, (q31_t)0xcad4b853, (q31_t)0x746caf70, (q31_t)0xcacf013a, + (q31_t)0x746a12df, (q31_t)0xcac94a42, (q31_t)0x74677608, (q31_t)0xcac3936b, + (q31_t)0x7464d8e8, (q31_t)0xcabddcb4, (q31_t)0x74623b80, (q31_t)0xcab8261e, + (q31_t)0x745f9dd1, (q31_t)0xcab26fa9, (q31_t)0x745cffda, (q31_t)0xcaacb955, + (q31_t)0x745a619b, (q31_t)0xcaa70322, (q31_t)0x7457c314, (q31_t)0xcaa14d10, + (q31_t)0x74552446, (q31_t)0xca9b971e, (q31_t)0x74528530, (q31_t)0xca95e14e, + (q31_t)0x744fe5d2, (q31_t)0xca902b9f, (q31_t)0x744d462c, (q31_t)0xca8a7610, + (q31_t)0x744aa63f, (q31_t)0xca84c0a3, (q31_t)0x7448060a, (q31_t)0xca7f0b56, + (q31_t)0x7445658d, (q31_t)0xca79562b, (q31_t)0x7442c4c8, (q31_t)0xca73a120, + (q31_t)0x744023bc, (q31_t)0xca6dec37, (q31_t)0x743d8268, (q31_t)0xca68376e, + (q31_t)0x743ae0cc, (q31_t)0xca6282c7, (q31_t)0x74383ee9, (q31_t)0xca5cce40, + (q31_t)0x74359cbd, (q31_t)0xca5719db, (q31_t)0x7432fa4b, (q31_t)0xca516597, + (q31_t)0x74305790, (q31_t)0xca4bb174, (q31_t)0x742db48e, (q31_t)0xca45fd72, + (q31_t)0x742b1144, (q31_t)0xca404992, (q31_t)0x74286db3, (q31_t)0xca3a95d2, + (q31_t)0x7425c9da, (q31_t)0xca34e234, (q31_t)0x742325b9, (q31_t)0xca2f2eb6, + (q31_t)0x74208150, (q31_t)0xca297b5a, (q31_t)0x741ddca0, (q31_t)0xca23c820, + (q31_t)0x741b37a9, (q31_t)0xca1e1506, (q31_t)0x74189269, (q31_t)0xca18620e, + (q31_t)0x7415ece2, (q31_t)0xca12af37, (q31_t)0x74134714, (q31_t)0xca0cfc81, + (q31_t)0x7410a0fe, (q31_t)0xca0749ec, (q31_t)0x740dfaa0, (q31_t)0xca019779, + (q31_t)0x740b53fb, (q31_t)0xc9fbe527, (q31_t)0x7408ad0e, (q31_t)0xc9f632f6, + (q31_t)0x740605d9, (q31_t)0xc9f080e7, (q31_t)0x74035e5d, (q31_t)0xc9eacef9, + (q31_t)0x7400b69a, (q31_t)0xc9e51d2d, (q31_t)0x73fe0e8f, (q31_t)0xc9df6b81, + (q31_t)0x73fb663c, (q31_t)0xc9d9b9f7, (q31_t)0x73f8bda2, (q31_t)0xc9d4088f, + (q31_t)0x73f614c0, (q31_t)0xc9ce5748, (q31_t)0x73f36b97, (q31_t)0xc9c8a622, + (q31_t)0x73f0c226, (q31_t)0xc9c2f51e, (q31_t)0x73ee186e, (q31_t)0xc9bd443c, + (q31_t)0x73eb6e6e, (q31_t)0xc9b7937a, (q31_t)0x73e8c426, (q31_t)0xc9b1e2db, + (q31_t)0x73e61997, (q31_t)0xc9ac325d, (q31_t)0x73e36ec1, (q31_t)0xc9a68200, + (q31_t)0x73e0c3a3, (q31_t)0xc9a0d1c5, (q31_t)0x73de183e, (q31_t)0xc99b21ab, + (q31_t)0x73db6c91, (q31_t)0xc99571b3, (q31_t)0x73d8c09d, (q31_t)0xc98fc1dc, + (q31_t)0x73d61461, (q31_t)0xc98a1227, (q31_t)0x73d367de, (q31_t)0xc9846294, + (q31_t)0x73d0bb13, (q31_t)0xc97eb322, (q31_t)0x73ce0e01, (q31_t)0xc97903d2, + (q31_t)0x73cb60a8, (q31_t)0xc97354a4, (q31_t)0x73c8b307, (q31_t)0xc96da597, + (q31_t)0x73c6051f, (q31_t)0xc967f6ac, (q31_t)0x73c356ef, (q31_t)0xc96247e2, + (q31_t)0x73c0a878, (q31_t)0xc95c993a, (q31_t)0x73bdf9b9, (q31_t)0xc956eab4, + (q31_t)0x73bb4ab3, (q31_t)0xc9513c50, (q31_t)0x73b89b66, (q31_t)0xc94b8e0d, + (q31_t)0x73b5ebd1, (q31_t)0xc945dfec, (q31_t)0x73b33bf5, (q31_t)0xc94031ed, + (q31_t)0x73b08bd1, (q31_t)0xc93a8410, (q31_t)0x73addb67, (q31_t)0xc934d654, + (q31_t)0x73ab2ab4, (q31_t)0xc92f28ba, (q31_t)0x73a879bb, (q31_t)0xc9297b42, + (q31_t)0x73a5c87a, (q31_t)0xc923cdec, (q31_t)0x73a316f2, (q31_t)0xc91e20b8, + (q31_t)0x73a06522, (q31_t)0xc91873a5, (q31_t)0x739db30b, (q31_t)0xc912c6b5, + (q31_t)0x739b00ad, (q31_t)0xc90d19e6, (q31_t)0x73984e07, (q31_t)0xc9076d39, + (q31_t)0x73959b1b, (q31_t)0xc901c0ae, (q31_t)0x7392e7e6, (q31_t)0xc8fc1445, + (q31_t)0x7390346b, (q31_t)0xc8f667fe, (q31_t)0x738d80a8, (q31_t)0xc8f0bbd9, + (q31_t)0x738acc9e, (q31_t)0xc8eb0fd6, (q31_t)0x7388184d, (q31_t)0xc8e563f5, + (q31_t)0x738563b5, (q31_t)0xc8dfb836, (q31_t)0x7382aed5, (q31_t)0xc8da0c99, + (q31_t)0x737ff9ae, (q31_t)0xc8d4611d, (q31_t)0x737d4440, (q31_t)0xc8ceb5c4, + (q31_t)0x737a8e8a, (q31_t)0xc8c90a8d, (q31_t)0x7377d88d, (q31_t)0xc8c35f78, + (q31_t)0x73752249, (q31_t)0xc8bdb485, (q31_t)0x73726bbe, (q31_t)0xc8b809b4, + (q31_t)0x736fb4ec, (q31_t)0xc8b25f06, (q31_t)0x736cfdd2, (q31_t)0xc8acb479, + (q31_t)0x736a4671, (q31_t)0xc8a70a0e, (q31_t)0x73678ec9, (q31_t)0xc8a15fc6, + (q31_t)0x7364d6da, (q31_t)0xc89bb5a0, (q31_t)0x73621ea4, (q31_t)0xc8960b9c, + (q31_t)0x735f6626, (q31_t)0xc89061ba, (q31_t)0x735cad61, (q31_t)0xc88ab7fa, + (q31_t)0x7359f456, (q31_t)0xc8850e5d, (q31_t)0x73573b03, (q31_t)0xc87f64e2, + (q31_t)0x73548168, (q31_t)0xc879bb89, (q31_t)0x7351c787, (q31_t)0xc8741252, + (q31_t)0x734f0d5f, (q31_t)0xc86e693d, (q31_t)0x734c52ef, (q31_t)0xc868c04b, + (q31_t)0x73499838, (q31_t)0xc863177b, (q31_t)0x7346dd3a, (q31_t)0xc85d6ece, + (q31_t)0x734421f6, (q31_t)0xc857c642, (q31_t)0x7341666a, (q31_t)0xc8521dd9, + (q31_t)0x733eaa96, (q31_t)0xc84c7593, (q31_t)0x733bee7c, (q31_t)0xc846cd6e, + (q31_t)0x7339321b, (q31_t)0xc841256d, (q31_t)0x73367572, (q31_t)0xc83b7d8d, + (q31_t)0x7333b883, (q31_t)0xc835d5d0, (q31_t)0x7330fb4d, (q31_t)0xc8302e35, + (q31_t)0x732e3dcf, (q31_t)0xc82a86bd, (q31_t)0x732b800a, (q31_t)0xc824df67, + (q31_t)0x7328c1ff, (q31_t)0xc81f3834, (q31_t)0x732603ac, (q31_t)0xc8199123, + (q31_t)0x73234512, (q31_t)0xc813ea35, (q31_t)0x73208632, (q31_t)0xc80e4369, + (q31_t)0x731dc70a, (q31_t)0xc8089cbf, (q31_t)0x731b079b, (q31_t)0xc802f638, + (q31_t)0x731847e5, (q31_t)0xc7fd4fd4, (q31_t)0x731587e8, (q31_t)0xc7f7a992, + (q31_t)0x7312c7a5, (q31_t)0xc7f20373, (q31_t)0x7310071a, (q31_t)0xc7ec5d76, + (q31_t)0x730d4648, (q31_t)0xc7e6b79c, (q31_t)0x730a8530, (q31_t)0xc7e111e5, + (q31_t)0x7307c3d0, (q31_t)0xc7db6c50, (q31_t)0x73050229, (q31_t)0xc7d5c6de, + (q31_t)0x7302403c, (q31_t)0xc7d0218e, (q31_t)0x72ff7e07, (q31_t)0xc7ca7c61, + (q31_t)0x72fcbb8c, (q31_t)0xc7c4d757, (q31_t)0x72f9f8c9, (q31_t)0xc7bf3270, + (q31_t)0x72f735c0, (q31_t)0xc7b98dab, (q31_t)0x72f47270, (q31_t)0xc7b3e909, + (q31_t)0x72f1aed9, (q31_t)0xc7ae4489, (q31_t)0x72eeeafb, (q31_t)0xc7a8a02c, + (q31_t)0x72ec26d6, (q31_t)0xc7a2fbf3, (q31_t)0x72e9626a, (q31_t)0xc79d57db, + (q31_t)0x72e69db7, (q31_t)0xc797b3e7, (q31_t)0x72e3d8be, (q31_t)0xc7921015, + (q31_t)0x72e1137d, (q31_t)0xc78c6c67, (q31_t)0x72de4df6, (q31_t)0xc786c8db, + (q31_t)0x72db8828, (q31_t)0xc7812572, (q31_t)0x72d8c213, (q31_t)0xc77b822b, + (q31_t)0x72d5fbb7, (q31_t)0xc775df08, (q31_t)0x72d33514, (q31_t)0xc7703c08, + (q31_t)0x72d06e2b, (q31_t)0xc76a992a, (q31_t)0x72cda6fb, (q31_t)0xc764f66f, + (q31_t)0x72cadf83, (q31_t)0xc75f53d7, (q31_t)0x72c817c6, (q31_t)0xc759b163, + (q31_t)0x72c54fc1, (q31_t)0xc7540f11, (q31_t)0x72c28775, (q31_t)0xc74e6ce2, + (q31_t)0x72bfbee3, (q31_t)0xc748cad6, (q31_t)0x72bcf60a, (q31_t)0xc74328ed, + (q31_t)0x72ba2cea, (q31_t)0xc73d8727, (q31_t)0x72b76383, (q31_t)0xc737e584, + (q31_t)0x72b499d6, (q31_t)0xc7324404, (q31_t)0x72b1cfe1, (q31_t)0xc72ca2a7, + (q31_t)0x72af05a7, (q31_t)0xc727016d, (q31_t)0x72ac3b25, (q31_t)0xc7216056, + (q31_t)0x72a9705c, (q31_t)0xc71bbf62, (q31_t)0x72a6a54d, (q31_t)0xc7161e92, + (q31_t)0x72a3d9f7, (q31_t)0xc7107de4, (q31_t)0x72a10e5b, (q31_t)0xc70add5a, + (q31_t)0x729e4277, (q31_t)0xc7053cf2, (q31_t)0x729b764d, (q31_t)0xc6ff9cae, + (q31_t)0x7298a9dd, (q31_t)0xc6f9fc8d, (q31_t)0x7295dd25, (q31_t)0xc6f45c8f, + (q31_t)0x72931027, (q31_t)0xc6eebcb5, (q31_t)0x729042e3, (q31_t)0xc6e91cfd, + (q31_t)0x728d7557, (q31_t)0xc6e37d69, (q31_t)0x728aa785, (q31_t)0xc6ddddf8, + (q31_t)0x7287d96c, (q31_t)0xc6d83eab, (q31_t)0x72850b0d, (q31_t)0xc6d29f80, + (q31_t)0x72823c67, (q31_t)0xc6cd0079, (q31_t)0x727f6d7a, (q31_t)0xc6c76195, + (q31_t)0x727c9e47, (q31_t)0xc6c1c2d4, (q31_t)0x7279cecd, (q31_t)0xc6bc2437, + (q31_t)0x7276ff0d, (q31_t)0xc6b685bd, (q31_t)0x72742f05, (q31_t)0xc6b0e767, + (q31_t)0x72715eb8, (q31_t)0xc6ab4933, (q31_t)0x726e8e23, (q31_t)0xc6a5ab23, + (q31_t)0x726bbd48, (q31_t)0xc6a00d37, (q31_t)0x7268ec27, (q31_t)0xc69a6f6e, + (q31_t)0x72661abf, (q31_t)0xc694d1c8, (q31_t)0x72634910, (q31_t)0xc68f3446, + (q31_t)0x7260771b, (q31_t)0xc68996e7, (q31_t)0x725da4df, (q31_t)0xc683f9ab, + (q31_t)0x725ad25d, (q31_t)0xc67e5c93, (q31_t)0x7257ff94, (q31_t)0xc678bf9f, + (q31_t)0x72552c85, (q31_t)0xc67322ce, (q31_t)0x7252592f, (q31_t)0xc66d8620, + (q31_t)0x724f8593, (q31_t)0xc667e996, (q31_t)0x724cb1b0, (q31_t)0xc6624d30, + (q31_t)0x7249dd86, (q31_t)0xc65cb0ed, (q31_t)0x72470916, (q31_t)0xc65714cd, + (q31_t)0x72443460, (q31_t)0xc65178d1, (q31_t)0x72415f63, (q31_t)0xc64bdcf9, + (q31_t)0x723e8a20, (q31_t)0xc6464144, (q31_t)0x723bb496, (q31_t)0xc640a5b3, + (q31_t)0x7238dec5, (q31_t)0xc63b0a46, (q31_t)0x723608af, (q31_t)0xc6356efc, + (q31_t)0x72333251, (q31_t)0xc62fd3d6, (q31_t)0x72305bae, (q31_t)0xc62a38d4, + (q31_t)0x722d84c4, (q31_t)0xc6249df5, (q31_t)0x722aad93, (q31_t)0xc61f033a, + (q31_t)0x7227d61c, (q31_t)0xc61968a2, (q31_t)0x7224fe5f, (q31_t)0xc613ce2f, + (q31_t)0x7222265b, (q31_t)0xc60e33df, (q31_t)0x721f4e11, (q31_t)0xc60899b2, + (q31_t)0x721c7580, (q31_t)0xc602ffaa, (q31_t)0x72199ca9, (q31_t)0xc5fd65c5, + (q31_t)0x7216c38c, (q31_t)0xc5f7cc04, (q31_t)0x7213ea28, (q31_t)0xc5f23267, + (q31_t)0x7211107e, (q31_t)0xc5ec98ee, (q31_t)0x720e368d, (q31_t)0xc5e6ff98, + (q31_t)0x720b5c57, (q31_t)0xc5e16667, (q31_t)0x720881d9, (q31_t)0xc5dbcd59, + (q31_t)0x7205a716, (q31_t)0xc5d6346f, (q31_t)0x7202cc0c, (q31_t)0xc5d09ba9, + (q31_t)0x71fff0bc, (q31_t)0xc5cb0307, (q31_t)0x71fd1525, (q31_t)0xc5c56a89, + (q31_t)0x71fa3949, (q31_t)0xc5bfd22e, (q31_t)0x71f75d25, (q31_t)0xc5ba39f8, + (q31_t)0x71f480bc, (q31_t)0xc5b4a1e5, (q31_t)0x71f1a40c, (q31_t)0xc5af09f7, + (q31_t)0x71eec716, (q31_t)0xc5a9722c, (q31_t)0x71ebe9da, (q31_t)0xc5a3da86, + (q31_t)0x71e90c57, (q31_t)0xc59e4303, (q31_t)0x71e62e8f, (q31_t)0xc598aba5, + (q31_t)0x71e35080, (q31_t)0xc593146a, (q31_t)0x71e0722a, (q31_t)0xc58d7d54, + (q31_t)0x71dd938f, (q31_t)0xc587e661, (q31_t)0x71dab4ad, (q31_t)0xc5824f93, + (q31_t)0x71d7d585, (q31_t)0xc57cb8e9, (q31_t)0x71d4f617, (q31_t)0xc5772263, + (q31_t)0x71d21662, (q31_t)0xc5718c00, (q31_t)0x71cf3667, (q31_t)0xc56bf5c2, + (q31_t)0x71cc5626, (q31_t)0xc5665fa9, (q31_t)0x71c9759f, (q31_t)0xc560c9b3, + (q31_t)0x71c694d2, (q31_t)0xc55b33e2, (q31_t)0x71c3b3bf, (q31_t)0xc5559e34, + (q31_t)0x71c0d265, (q31_t)0xc55008ab, (q31_t)0x71bdf0c5, (q31_t)0xc54a7346, + (q31_t)0x71bb0edf, (q31_t)0xc544de05, (q31_t)0x71b82cb3, (q31_t)0xc53f48e9, + (q31_t)0x71b54a41, (q31_t)0xc539b3f1, (q31_t)0x71b26788, (q31_t)0xc5341f1d, + (q31_t)0x71af848a, (q31_t)0xc52e8a6d, (q31_t)0x71aca145, (q31_t)0xc528f5e1, + (q31_t)0x71a9bdba, (q31_t)0xc523617a, (q31_t)0x71a6d9e9, (q31_t)0xc51dcd37, + (q31_t)0x71a3f5d2, (q31_t)0xc5183919, (q31_t)0x71a11175, (q31_t)0xc512a51f, + (q31_t)0x719e2cd2, (q31_t)0xc50d1149, (q31_t)0x719b47e9, (q31_t)0xc5077d97, + (q31_t)0x719862b9, (q31_t)0xc501ea0a, (q31_t)0x71957d44, (q31_t)0xc4fc56a2, + (q31_t)0x71929789, (q31_t)0xc4f6c35d, (q31_t)0x718fb187, (q31_t)0xc4f1303d, + (q31_t)0x718ccb3f, (q31_t)0xc4eb9d42, (q31_t)0x7189e4b2, (q31_t)0xc4e60a6b, + (q31_t)0x7186fdde, (q31_t)0xc4e077b8, (q31_t)0x718416c4, (q31_t)0xc4dae52a, + (q31_t)0x71812f65, (q31_t)0xc4d552c1, (q31_t)0x717e47bf, (q31_t)0xc4cfc07c, + (q31_t)0x717b5fd3, (q31_t)0xc4ca2e5b, (q31_t)0x717877a1, (q31_t)0xc4c49c5f, + (q31_t)0x71758f29, (q31_t)0xc4bf0a87, (q31_t)0x7172a66c, (q31_t)0xc4b978d4, + (q31_t)0x716fbd68, (q31_t)0xc4b3e746, (q31_t)0x716cd41e, (q31_t)0xc4ae55dc, + (q31_t)0x7169ea8f, (q31_t)0xc4a8c497, (q31_t)0x716700b9, (q31_t)0xc4a33376, + (q31_t)0x7164169d, (q31_t)0xc49da27a, (q31_t)0x71612c3c, (q31_t)0xc49811a3, + (q31_t)0x715e4194, (q31_t)0xc49280f0, (q31_t)0x715b56a7, (q31_t)0xc48cf062, + (q31_t)0x71586b74, (q31_t)0xc4875ff9, (q31_t)0x71557ffa, (q31_t)0xc481cfb4, + (q31_t)0x7152943b, (q31_t)0xc47c3f94, (q31_t)0x714fa836, (q31_t)0xc476af98, + (q31_t)0x714cbbeb, (q31_t)0xc4711fc2, (q31_t)0x7149cf5a, (q31_t)0xc46b9010, + (q31_t)0x7146e284, (q31_t)0xc4660083, (q31_t)0x7143f567, (q31_t)0xc460711b, + (q31_t)0x71410805, (q31_t)0xc45ae1d7, (q31_t)0x713e1a5c, (q31_t)0xc45552b8, + (q31_t)0x713b2c6e, (q31_t)0xc44fc3be, (q31_t)0x71383e3a, (q31_t)0xc44a34e9, + (q31_t)0x71354fc0, (q31_t)0xc444a639, (q31_t)0x71326101, (q31_t)0xc43f17ad, + (q31_t)0x712f71fb, (q31_t)0xc4398947, (q31_t)0x712c82b0, (q31_t)0xc433fb05, + (q31_t)0x7129931f, (q31_t)0xc42e6ce8, (q31_t)0x7126a348, (q31_t)0xc428def0, + (q31_t)0x7123b32b, (q31_t)0xc423511d, (q31_t)0x7120c2c8, (q31_t)0xc41dc36f, + (q31_t)0x711dd220, (q31_t)0xc41835e6, (q31_t)0x711ae132, (q31_t)0xc412a882, + (q31_t)0x7117effe, (q31_t)0xc40d1b42, (q31_t)0x7114fe84, (q31_t)0xc4078e28, + (q31_t)0x71120cc5, (q31_t)0xc4020133, (q31_t)0x710f1ac0, (q31_t)0xc3fc7462, + (q31_t)0x710c2875, (q31_t)0xc3f6e7b7, (q31_t)0x710935e4, (q31_t)0xc3f15b31, + (q31_t)0x7106430e, (q31_t)0xc3ebced0, (q31_t)0x71034ff2, (q31_t)0xc3e64294, + (q31_t)0x71005c90, (q31_t)0xc3e0b67d, (q31_t)0x70fd68e9, (q31_t)0xc3db2a8b, + (q31_t)0x70fa74fc, (q31_t)0xc3d59ebe, (q31_t)0x70f780c9, (q31_t)0xc3d01316, + (q31_t)0x70f48c50, (q31_t)0xc3ca8793, (q31_t)0x70f19792, (q31_t)0xc3c4fc36, + (q31_t)0x70eea28e, (q31_t)0xc3bf70fd, (q31_t)0x70ebad45, (q31_t)0xc3b9e5ea, + (q31_t)0x70e8b7b5, (q31_t)0xc3b45afc, (q31_t)0x70e5c1e1, (q31_t)0xc3aed034, + (q31_t)0x70e2cbc6, (q31_t)0xc3a94590, (q31_t)0x70dfd566, (q31_t)0xc3a3bb12, + (q31_t)0x70dcdec0, (q31_t)0xc39e30b8, (q31_t)0x70d9e7d5, (q31_t)0xc398a685, + (q31_t)0x70d6f0a4, (q31_t)0xc3931c76, (q31_t)0x70d3f92d, (q31_t)0xc38d928d, + (q31_t)0x70d10171, (q31_t)0xc38808c9, (q31_t)0x70ce096f, (q31_t)0xc3827f2a, + (q31_t)0x70cb1128, (q31_t)0xc37cf5b0, (q31_t)0x70c8189b, (q31_t)0xc3776c5c, + (q31_t)0x70c51fc8, (q31_t)0xc371e32d, (q31_t)0x70c226b0, (q31_t)0xc36c5a24, + (q31_t)0x70bf2d53, (q31_t)0xc366d140, (q31_t)0x70bc33b0, (q31_t)0xc3614881, + (q31_t)0x70b939c7, (q31_t)0xc35bbfe8, (q31_t)0x70b63f99, (q31_t)0xc3563774, + (q31_t)0x70b34525, (q31_t)0xc350af26, (q31_t)0x70b04a6b, (q31_t)0xc34b26fc, + (q31_t)0x70ad4f6d, (q31_t)0xc3459ef9, (q31_t)0x70aa5428, (q31_t)0xc340171b, + (q31_t)0x70a7589f, (q31_t)0xc33a8f62, (q31_t)0x70a45ccf, (q31_t)0xc33507cf, + (q31_t)0x70a160ba, (q31_t)0xc32f8061, (q31_t)0x709e6460, (q31_t)0xc329f919, + (q31_t)0x709b67c0, (q31_t)0xc32471f7, (q31_t)0x70986adb, (q31_t)0xc31eeaf9, + (q31_t)0x70956db1, (q31_t)0xc3196422, (q31_t)0x70927041, (q31_t)0xc313dd70, + (q31_t)0x708f728b, (q31_t)0xc30e56e4, (q31_t)0x708c7490, (q31_t)0xc308d07d, + (q31_t)0x70897650, (q31_t)0xc3034a3c, (q31_t)0x708677ca, (q31_t)0xc2fdc420, + (q31_t)0x708378ff, (q31_t)0xc2f83e2a, (q31_t)0x708079ee, (q31_t)0xc2f2b85a, + (q31_t)0x707d7a98, (q31_t)0xc2ed32af, (q31_t)0x707a7afd, (q31_t)0xc2e7ad2a, + (q31_t)0x70777b1c, (q31_t)0xc2e227cb, (q31_t)0x70747af6, (q31_t)0xc2dca291, + (q31_t)0x70717a8a, (q31_t)0xc2d71d7e, (q31_t)0x706e79d9, (q31_t)0xc2d1988f, + (q31_t)0x706b78e3, (q31_t)0xc2cc13c7, (q31_t)0x706877a7, (q31_t)0xc2c68f24, + (q31_t)0x70657626, (q31_t)0xc2c10aa7, (q31_t)0x70627460, (q31_t)0xc2bb8650, + (q31_t)0x705f7255, (q31_t)0xc2b6021f, (q31_t)0x705c7004, (q31_t)0xc2b07e14, + (q31_t)0x70596d6d, (q31_t)0xc2aafa2e, (q31_t)0x70566a92, (q31_t)0xc2a5766e, + (q31_t)0x70536771, (q31_t)0xc29ff2d4, (q31_t)0x7050640b, (q31_t)0xc29a6f60, + (q31_t)0x704d6060, (q31_t)0xc294ec12, (q31_t)0x704a5c6f, (q31_t)0xc28f68e9, + (q31_t)0x70475839, (q31_t)0xc289e5e7, (q31_t)0x704453be, (q31_t)0xc284630a, + (q31_t)0x70414efd, (q31_t)0xc27ee054, (q31_t)0x703e49f8, (q31_t)0xc2795dc3, + (q31_t)0x703b44ad, (q31_t)0xc273db58, (q31_t)0x70383f1d, (q31_t)0xc26e5913, + (q31_t)0x70353947, (q31_t)0xc268d6f5, (q31_t)0x7032332d, (q31_t)0xc26354fc, + (q31_t)0x702f2ccd, (q31_t)0xc25dd329, (q31_t)0x702c2628, (q31_t)0xc258517c, + (q31_t)0x70291f3e, (q31_t)0xc252cff5, (q31_t)0x7026180e, (q31_t)0xc24d4e95, + (q31_t)0x7023109a, (q31_t)0xc247cd5a, (q31_t)0x702008e0, (q31_t)0xc2424c46, + (q31_t)0x701d00e1, (q31_t)0xc23ccb57, (q31_t)0x7019f89d, (q31_t)0xc2374a8f, + (q31_t)0x7016f014, (q31_t)0xc231c9ec, (q31_t)0x7013e746, (q31_t)0xc22c4970, + (q31_t)0x7010de32, (q31_t)0xc226c91a, (q31_t)0x700dd4da, (q31_t)0xc22148ea, + (q31_t)0x700acb3c, (q31_t)0xc21bc8e1, (q31_t)0x7007c159, (q31_t)0xc21648fd, + (q31_t)0x7004b731, (q31_t)0xc210c940, (q31_t)0x7001acc4, (q31_t)0xc20b49a9, + (q31_t)0x6ffea212, (q31_t)0xc205ca38, (q31_t)0x6ffb971b, (q31_t)0xc2004aed, + (q31_t)0x6ff88bde, (q31_t)0xc1facbc9, (q31_t)0x6ff5805d, (q31_t)0xc1f54cca, + (q31_t)0x6ff27497, (q31_t)0xc1efcdf3, (q31_t)0x6fef688b, (q31_t)0xc1ea4f41, + (q31_t)0x6fec5c3b, (q31_t)0xc1e4d0b6, (q31_t)0x6fe94fa5, (q31_t)0xc1df5251, + (q31_t)0x6fe642ca, (q31_t)0xc1d9d412, (q31_t)0x6fe335ab, (q31_t)0xc1d455f9, + (q31_t)0x6fe02846, (q31_t)0xc1ced807, (q31_t)0x6fdd1a9c, (q31_t)0xc1c95a3c, + (q31_t)0x6fda0cae, (q31_t)0xc1c3dc97, (q31_t)0x6fd6fe7a, (q31_t)0xc1be5f18, + (q31_t)0x6fd3f001, (q31_t)0xc1b8e1bf, (q31_t)0x6fd0e144, (q31_t)0xc1b3648d, + (q31_t)0x6fcdd241, (q31_t)0xc1ade781, (q31_t)0x6fcac2fa, (q31_t)0xc1a86a9c, + (q31_t)0x6fc7b36d, (q31_t)0xc1a2edde, (q31_t)0x6fc4a39c, (q31_t)0xc19d7145, + (q31_t)0x6fc19385, (q31_t)0xc197f4d4, (q31_t)0x6fbe832a, (q31_t)0xc1927888, + (q31_t)0x6fbb728a, (q31_t)0xc18cfc63, (q31_t)0x6fb861a4, (q31_t)0xc1878065, + (q31_t)0x6fb5507a, (q31_t)0xc182048d, (q31_t)0x6fb23f0b, (q31_t)0xc17c88dc, + (q31_t)0x6faf2d57, (q31_t)0xc1770d52, (q31_t)0x6fac1b5f, (q31_t)0xc17191ee, + (q31_t)0x6fa90921, (q31_t)0xc16c16b0, (q31_t)0x6fa5f69e, (q31_t)0xc1669b99, + (q31_t)0x6fa2e3d7, (q31_t)0xc16120a9, (q31_t)0x6f9fd0cb, (q31_t)0xc15ba5df, + (q31_t)0x6f9cbd79, (q31_t)0xc1562b3d, (q31_t)0x6f99a9e3, (q31_t)0xc150b0c0, + (q31_t)0x6f969608, (q31_t)0xc14b366b, (q31_t)0x6f9381e9, (q31_t)0xc145bc3c, + (q31_t)0x6f906d84, (q31_t)0xc1404233, (q31_t)0x6f8d58db, (q31_t)0xc13ac852, + (q31_t)0x6f8a43ed, (q31_t)0xc1354e97, (q31_t)0x6f872eba, (q31_t)0xc12fd503, + (q31_t)0x6f841942, (q31_t)0xc12a5b95, (q31_t)0x6f810386, (q31_t)0xc124e24f, + (q31_t)0x6f7ded84, (q31_t)0xc11f692f, (q31_t)0x6f7ad73e, (q31_t)0xc119f036, + (q31_t)0x6f77c0b3, (q31_t)0xc1147764, (q31_t)0x6f74a9e4, (q31_t)0xc10efeb8, + (q31_t)0x6f7192cf, (q31_t)0xc1098634, (q31_t)0x6f6e7b76, (q31_t)0xc1040dd6, + (q31_t)0x6f6b63d8, (q31_t)0xc0fe959f, (q31_t)0x6f684bf6, (q31_t)0xc0f91d8f, + (q31_t)0x6f6533ce, (q31_t)0xc0f3a5a6, (q31_t)0x6f621b62, (q31_t)0xc0ee2de3, + (q31_t)0x6f5f02b2, (q31_t)0xc0e8b648, (q31_t)0x6f5be9bc, (q31_t)0xc0e33ed4, + (q31_t)0x6f58d082, (q31_t)0xc0ddc786, (q31_t)0x6f55b703, (q31_t)0xc0d8505f, + (q31_t)0x6f529d40, (q31_t)0xc0d2d960, (q31_t)0x6f4f8338, (q31_t)0xc0cd6287, + (q31_t)0x6f4c68eb, (q31_t)0xc0c7ebd6, (q31_t)0x6f494e5a, (q31_t)0xc0c2754b, + (q31_t)0x6f463383, (q31_t)0xc0bcfee7, (q31_t)0x6f431869, (q31_t)0xc0b788ab, + (q31_t)0x6f3ffd09, (q31_t)0xc0b21295, (q31_t)0x6f3ce165, (q31_t)0xc0ac9ca6, + (q31_t)0x6f39c57d, (q31_t)0xc0a726df, (q31_t)0x6f36a94f, (q31_t)0xc0a1b13e, + (q31_t)0x6f338cde, (q31_t)0xc09c3bc5, (q31_t)0x6f307027, (q31_t)0xc096c673, + (q31_t)0x6f2d532c, (q31_t)0xc0915148, (q31_t)0x6f2a35ed, (q31_t)0xc08bdc44, + (q31_t)0x6f271868, (q31_t)0xc0866767, (q31_t)0x6f23faa0, (q31_t)0xc080f2b1, + (q31_t)0x6f20dc92, (q31_t)0xc07b7e23, (q31_t)0x6f1dbe41, (q31_t)0xc07609bb, + (q31_t)0x6f1a9faa, (q31_t)0xc070957b, (q31_t)0x6f1780cf, (q31_t)0xc06b2162, + (q31_t)0x6f1461b0, (q31_t)0xc065ad70, (q31_t)0x6f11424c, (q31_t)0xc06039a6, + (q31_t)0x6f0e22a3, (q31_t)0xc05ac603, (q31_t)0x6f0b02b6, (q31_t)0xc0555287, + (q31_t)0x6f07e285, (q31_t)0xc04fdf32, (q31_t)0x6f04c20f, (q31_t)0xc04a6c05, + (q31_t)0x6f01a155, (q31_t)0xc044f8fe, (q31_t)0x6efe8056, (q31_t)0xc03f8620, + (q31_t)0x6efb5f12, (q31_t)0xc03a1368, (q31_t)0x6ef83d8a, (q31_t)0xc034a0d8, + (q31_t)0x6ef51bbe, (q31_t)0xc02f2e6f, (q31_t)0x6ef1f9ad, (q31_t)0xc029bc2e, + (q31_t)0x6eeed758, (q31_t)0xc0244a14, (q31_t)0x6eebb4bf, (q31_t)0xc01ed821, + (q31_t)0x6ee891e1, (q31_t)0xc0196656, (q31_t)0x6ee56ebe, (q31_t)0xc013f4b2, + (q31_t)0x6ee24b57, (q31_t)0xc00e8336, (q31_t)0x6edf27ac, (q31_t)0xc00911e1, + (q31_t)0x6edc03bc, (q31_t)0xc003a0b3, (q31_t)0x6ed8df88, (q31_t)0xbffe2fad, + (q31_t)0x6ed5bb10, (q31_t)0xbff8bece, (q31_t)0x6ed29653, (q31_t)0xbff34e17, + (q31_t)0x6ecf7152, (q31_t)0xbfeddd88, (q31_t)0x6ecc4c0d, (q31_t)0xbfe86d20, + (q31_t)0x6ec92683, (q31_t)0xbfe2fcdf, (q31_t)0x6ec600b5, (q31_t)0xbfdd8cc6, + (q31_t)0x6ec2daa2, (q31_t)0xbfd81cd5, (q31_t)0x6ebfb44b, (q31_t)0xbfd2ad0b, + (q31_t)0x6ebc8db0, (q31_t)0xbfcd3d69, (q31_t)0x6eb966d1, (q31_t)0xbfc7cdee, + (q31_t)0x6eb63fad, (q31_t)0xbfc25e9b, (q31_t)0x6eb31845, (q31_t)0xbfbcef70, + (q31_t)0x6eaff099, (q31_t)0xbfb7806c, (q31_t)0x6eacc8a8, (q31_t)0xbfb21190, + (q31_t)0x6ea9a073, (q31_t)0xbfaca2dc, (q31_t)0x6ea677fa, (q31_t)0xbfa7344f, + (q31_t)0x6ea34f3d, (q31_t)0xbfa1c5ea, (q31_t)0x6ea0263b, (q31_t)0xbf9c57ac, + (q31_t)0x6e9cfcf5, (q31_t)0xbf96e997, (q31_t)0x6e99d36b, (q31_t)0xbf917ba9, + (q31_t)0x6e96a99d, (q31_t)0xbf8c0de3, (q31_t)0x6e937f8a, (q31_t)0xbf86a044, + (q31_t)0x6e905534, (q31_t)0xbf8132ce, (q31_t)0x6e8d2a99, (q31_t)0xbf7bc57f, + (q31_t)0x6e89ffb9, (q31_t)0xbf765858, (q31_t)0x6e86d496, (q31_t)0xbf70eb59, + (q31_t)0x6e83a92f, (q31_t)0xbf6b7e81, (q31_t)0x6e807d83, (q31_t)0xbf6611d2, + (q31_t)0x6e7d5193, (q31_t)0xbf60a54a, (q31_t)0x6e7a255f, (q31_t)0xbf5b38ea, + (q31_t)0x6e76f8e7, (q31_t)0xbf55ccb2, (q31_t)0x6e73cc2b, (q31_t)0xbf5060a2, + (q31_t)0x6e709f2a, (q31_t)0xbf4af4ba, (q31_t)0x6e6d71e6, (q31_t)0xbf4588fa, + (q31_t)0x6e6a445d, (q31_t)0xbf401d61, (q31_t)0x6e671690, (q31_t)0xbf3ab1f1, + (q31_t)0x6e63e87f, (q31_t)0xbf3546a8, (q31_t)0x6e60ba2a, (q31_t)0xbf2fdb88, + (q31_t)0x6e5d8b91, (q31_t)0xbf2a708f, (q31_t)0x6e5a5cb4, (q31_t)0xbf2505bf, + (q31_t)0x6e572d93, (q31_t)0xbf1f9b16, (q31_t)0x6e53fe2e, (q31_t)0xbf1a3096, + (q31_t)0x6e50ce84, (q31_t)0xbf14c63d, (q31_t)0x6e4d9e97, (q31_t)0xbf0f5c0d, + (q31_t)0x6e4a6e66, (q31_t)0xbf09f205, (q31_t)0x6e473df0, (q31_t)0xbf048824, + (q31_t)0x6e440d37, (q31_t)0xbeff1e6c, (q31_t)0x6e40dc39, (q31_t)0xbef9b4dc, + (q31_t)0x6e3daaf8, (q31_t)0xbef44b74, (q31_t)0x6e3a7972, (q31_t)0xbeeee234, + (q31_t)0x6e3747a9, (q31_t)0xbee9791c, (q31_t)0x6e34159b, (q31_t)0xbee4102d, + (q31_t)0x6e30e34a, (q31_t)0xbedea765, (q31_t)0x6e2db0b4, (q31_t)0xbed93ec6, + (q31_t)0x6e2a7ddb, (q31_t)0xbed3d64f, (q31_t)0x6e274abe, (q31_t)0xbece6e00, + (q31_t)0x6e24175c, (q31_t)0xbec905d9, (q31_t)0x6e20e3b7, (q31_t)0xbec39ddb, + (q31_t)0x6e1dafce, (q31_t)0xbebe3605, (q31_t)0x6e1a7ba1, (q31_t)0xbeb8ce57, + (q31_t)0x6e174730, (q31_t)0xbeb366d1, (q31_t)0x6e14127b, (q31_t)0xbeadff74, + (q31_t)0x6e10dd82, (q31_t)0xbea8983f, (q31_t)0x6e0da845, (q31_t)0xbea33132, + (q31_t)0x6e0a72c5, (q31_t)0xbe9dca4e, (q31_t)0x6e073d00, (q31_t)0xbe986391, + (q31_t)0x6e0406f8, (q31_t)0xbe92fcfe, (q31_t)0x6e00d0ac, (q31_t)0xbe8d9692, + (q31_t)0x6dfd9a1c, (q31_t)0xbe88304f, (q31_t)0x6dfa6348, (q31_t)0xbe82ca35, + (q31_t)0x6df72c30, (q31_t)0xbe7d6442, (q31_t)0x6df3f4d4, (q31_t)0xbe77fe78, + (q31_t)0x6df0bd35, (q31_t)0xbe7298d7, (q31_t)0x6ded8552, (q31_t)0xbe6d335e, + (q31_t)0x6dea4d2b, (q31_t)0xbe67ce0d, (q31_t)0x6de714c0, (q31_t)0xbe6268e5, + (q31_t)0x6de3dc11, (q31_t)0xbe5d03e6, (q31_t)0x6de0a31f, (q31_t)0xbe579f0f, + (q31_t)0x6ddd69e9, (q31_t)0xbe523a60, (q31_t)0x6dda306f, (q31_t)0xbe4cd5da, + (q31_t)0x6dd6f6b1, (q31_t)0xbe47717c, (q31_t)0x6dd3bcaf, (q31_t)0xbe420d47, + (q31_t)0x6dd0826a, (q31_t)0xbe3ca93b, (q31_t)0x6dcd47e1, (q31_t)0xbe374557, + (q31_t)0x6dca0d14, (q31_t)0xbe31e19b, (q31_t)0x6dc6d204, (q31_t)0xbe2c7e09, + (q31_t)0x6dc396b0, (q31_t)0xbe271a9f, (q31_t)0x6dc05b18, (q31_t)0xbe21b75d, + (q31_t)0x6dbd1f3c, (q31_t)0xbe1c5444, (q31_t)0x6db9e31d, (q31_t)0xbe16f154, + (q31_t)0x6db6a6ba, (q31_t)0xbe118e8c, (q31_t)0x6db36a14, (q31_t)0xbe0c2bed, + (q31_t)0x6db02d29, (q31_t)0xbe06c977, (q31_t)0x6daceffb, (q31_t)0xbe01672a, + (q31_t)0x6da9b28a, (q31_t)0xbdfc0505, (q31_t)0x6da674d5, (q31_t)0xbdf6a309, + (q31_t)0x6da336dc, (q31_t)0xbdf14135, (q31_t)0x6d9ff89f, (q31_t)0xbdebdf8b, + (q31_t)0x6d9cba1f, (q31_t)0xbde67e09, (q31_t)0x6d997b5b, (q31_t)0xbde11cb0, + (q31_t)0x6d963c54, (q31_t)0xbddbbb7f, (q31_t)0x6d92fd09, (q31_t)0xbdd65a78, + (q31_t)0x6d8fbd7a, (q31_t)0xbdd0f999, (q31_t)0x6d8c7da8, (q31_t)0xbdcb98e3, + (q31_t)0x6d893d93, (q31_t)0xbdc63856, (q31_t)0x6d85fd39, (q31_t)0xbdc0d7f2, + (q31_t)0x6d82bc9d, (q31_t)0xbdbb77b7, (q31_t)0x6d7f7bbc, (q31_t)0xbdb617a4, + (q31_t)0x6d7c3a98, (q31_t)0xbdb0b7bb, (q31_t)0x6d78f931, (q31_t)0xbdab57fa, + (q31_t)0x6d75b786, (q31_t)0xbda5f862, (q31_t)0x6d727597, (q31_t)0xbda098f3, + (q31_t)0x6d6f3365, (q31_t)0xbd9b39ad, (q31_t)0x6d6bf0f0, (q31_t)0xbd95da91, + (q31_t)0x6d68ae37, (q31_t)0xbd907b9d, (q31_t)0x6d656b3a, (q31_t)0xbd8b1cd2, + (q31_t)0x6d6227fa, (q31_t)0xbd85be30, (q31_t)0x6d5ee477, (q31_t)0xbd805fb7, + (q31_t)0x6d5ba0b0, (q31_t)0xbd7b0167, (q31_t)0x6d585ca6, (q31_t)0xbd75a340, + (q31_t)0x6d551858, (q31_t)0xbd704542, (q31_t)0x6d51d3c6, (q31_t)0xbd6ae76d, + (q31_t)0x6d4e8ef2, (q31_t)0xbd6589c1, (q31_t)0x6d4b49da, (q31_t)0xbd602c3f, + (q31_t)0x6d48047e, (q31_t)0xbd5acee5, (q31_t)0x6d44bedf, (q31_t)0xbd5571b5, + (q31_t)0x6d4178fd, (q31_t)0xbd5014ad, (q31_t)0x6d3e32d7, (q31_t)0xbd4ab7cf, + (q31_t)0x6d3aec6e, (q31_t)0xbd455b1a, (q31_t)0x6d37a5c1, (q31_t)0xbd3ffe8e, + (q31_t)0x6d345ed1, (q31_t)0xbd3aa22c, (q31_t)0x6d31179e, (q31_t)0xbd3545f2, + (q31_t)0x6d2dd027, (q31_t)0xbd2fe9e2, (q31_t)0x6d2a886e, (q31_t)0xbd2a8dfb, + (q31_t)0x6d274070, (q31_t)0xbd25323d, (q31_t)0x6d23f830, (q31_t)0xbd1fd6a8, + (q31_t)0x6d20afac, (q31_t)0xbd1a7b3d, (q31_t)0x6d1d66e4, (q31_t)0xbd151ffb, + (q31_t)0x6d1a1dda, (q31_t)0xbd0fc4e2, (q31_t)0x6d16d48c, (q31_t)0xbd0a69f2, + (q31_t)0x6d138afb, (q31_t)0xbd050f2c, (q31_t)0x6d104126, (q31_t)0xbcffb48f, + (q31_t)0x6d0cf70f, (q31_t)0xbcfa5a1b, (q31_t)0x6d09acb4, (q31_t)0xbcf4ffd1, + (q31_t)0x6d066215, (q31_t)0xbcefa5b0, (q31_t)0x6d031734, (q31_t)0xbcea4bb9, + (q31_t)0x6cffcc0f, (q31_t)0xbce4f1eb, (q31_t)0x6cfc80a7, (q31_t)0xbcdf9846, + (q31_t)0x6cf934fc, (q31_t)0xbcda3ecb, (q31_t)0x6cf5e90d, (q31_t)0xbcd4e579, + (q31_t)0x6cf29cdc, (q31_t)0xbccf8c50, (q31_t)0x6cef5067, (q31_t)0xbcca3351, + (q31_t)0x6cec03af, (q31_t)0xbcc4da7b, (q31_t)0x6ce8b6b4, (q31_t)0xbcbf81cf, + (q31_t)0x6ce56975, (q31_t)0xbcba294d, (q31_t)0x6ce21bf4, (q31_t)0xbcb4d0f4, + (q31_t)0x6cdece2f, (q31_t)0xbcaf78c4, (q31_t)0x6cdb8027, (q31_t)0xbcaa20be, + (q31_t)0x6cd831dc, (q31_t)0xbca4c8e1, (q31_t)0x6cd4e34e, (q31_t)0xbc9f712e, + (q31_t)0x6cd1947c, (q31_t)0xbc9a19a5, (q31_t)0x6cce4568, (q31_t)0xbc94c245, + (q31_t)0x6ccaf610, (q31_t)0xbc8f6b0f, (q31_t)0x6cc7a676, (q31_t)0xbc8a1402, + (q31_t)0x6cc45698, (q31_t)0xbc84bd1f, (q31_t)0x6cc10677, (q31_t)0xbc7f6665, + (q31_t)0x6cbdb613, (q31_t)0xbc7a0fd6, (q31_t)0x6cba656c, (q31_t)0xbc74b96f, + (q31_t)0x6cb71482, (q31_t)0xbc6f6333, (q31_t)0x6cb3c355, (q31_t)0xbc6a0d20, + (q31_t)0x6cb071e4, (q31_t)0xbc64b737, (q31_t)0x6cad2031, (q31_t)0xbc5f6177, + (q31_t)0x6ca9ce3b, (q31_t)0xbc5a0be2, (q31_t)0x6ca67c01, (q31_t)0xbc54b676, + (q31_t)0x6ca32985, (q31_t)0xbc4f6134, (q31_t)0x6c9fd6c6, (q31_t)0xbc4a0c1b, + (q31_t)0x6c9c83c3, (q31_t)0xbc44b72c, (q31_t)0x6c99307e, (q31_t)0xbc3f6267, + (q31_t)0x6c95dcf6, (q31_t)0xbc3a0dcc, (q31_t)0x6c92892a, (q31_t)0xbc34b95b, + (q31_t)0x6c8f351c, (q31_t)0xbc2f6513, (q31_t)0x6c8be0cb, (q31_t)0xbc2a10f6, + (q31_t)0x6c888c36, (q31_t)0xbc24bd02, (q31_t)0x6c85375f, (q31_t)0xbc1f6938, + (q31_t)0x6c81e245, (q31_t)0xbc1a1598, (q31_t)0x6c7e8ce8, (q31_t)0xbc14c221, + (q31_t)0x6c7b3748, (q31_t)0xbc0f6ed5, (q31_t)0x6c77e165, (q31_t)0xbc0a1bb3, + (q31_t)0x6c748b3f, (q31_t)0xbc04c8ba, (q31_t)0x6c7134d7, (q31_t)0xbbff75ec, + (q31_t)0x6c6dde2b, (q31_t)0xbbfa2347, (q31_t)0x6c6a873d, (q31_t)0xbbf4d0cc, + (q31_t)0x6c67300b, (q31_t)0xbbef7e7c, (q31_t)0x6c63d897, (q31_t)0xbbea2c55, + (q31_t)0x6c6080e0, (q31_t)0xbbe4da58, (q31_t)0x6c5d28e6, (q31_t)0xbbdf8885, + (q31_t)0x6c59d0a9, (q31_t)0xbbda36dd, (q31_t)0x6c56782a, (q31_t)0xbbd4e55e, + (q31_t)0x6c531f67, (q31_t)0xbbcf940a, (q31_t)0x6c4fc662, (q31_t)0xbbca42df, + (q31_t)0x6c4c6d1a, (q31_t)0xbbc4f1df, (q31_t)0x6c49138f, (q31_t)0xbbbfa108, + (q31_t)0x6c45b9c1, (q31_t)0xbbba505c, (q31_t)0x6c425fb1, (q31_t)0xbbb4ffda, + (q31_t)0x6c3f055d, (q31_t)0xbbafaf82, (q31_t)0x6c3baac7, (q31_t)0xbbaa5f54, + (q31_t)0x6c384fef, (q31_t)0xbba50f50, (q31_t)0x6c34f4d3, (q31_t)0xbb9fbf77, + (q31_t)0x6c319975, (q31_t)0xbb9a6fc7, (q31_t)0x6c2e3dd4, (q31_t)0xbb952042, + (q31_t)0x6c2ae1f0, (q31_t)0xbb8fd0e7, (q31_t)0x6c2785ca, (q31_t)0xbb8a81b6, + (q31_t)0x6c242960, (q31_t)0xbb8532b0, (q31_t)0x6c20ccb4, (q31_t)0xbb7fe3d3, + (q31_t)0x6c1d6fc6, (q31_t)0xbb7a9521, (q31_t)0x6c1a1295, (q31_t)0xbb754699, + (q31_t)0x6c16b521, (q31_t)0xbb6ff83c, (q31_t)0x6c13576a, (q31_t)0xbb6aaa09, + (q31_t)0x6c0ff971, (q31_t)0xbb655c00, (q31_t)0x6c0c9b35, (q31_t)0xbb600e21, + (q31_t)0x6c093cb6, (q31_t)0xbb5ac06d, (q31_t)0x6c05ddf5, (q31_t)0xbb5572e3, + (q31_t)0x6c027ef1, (q31_t)0xbb502583, (q31_t)0x6bff1faa, (q31_t)0xbb4ad84e, + (q31_t)0x6bfbc021, (q31_t)0xbb458b43, (q31_t)0x6bf86055, (q31_t)0xbb403e63, + (q31_t)0x6bf50047, (q31_t)0xbb3af1ad, (q31_t)0x6bf19ff6, (q31_t)0xbb35a521, + (q31_t)0x6bee3f62, (q31_t)0xbb3058c0, (q31_t)0x6beade8c, (q31_t)0xbb2b0c8a, + (q31_t)0x6be77d74, (q31_t)0xbb25c07d, (q31_t)0x6be41c18, (q31_t)0xbb20749c, + (q31_t)0x6be0ba7b, (q31_t)0xbb1b28e4, (q31_t)0x6bdd589a, (q31_t)0xbb15dd57, + (q31_t)0x6bd9f677, (q31_t)0xbb1091f5, (q31_t)0x6bd69412, (q31_t)0xbb0b46bd, + (q31_t)0x6bd3316a, (q31_t)0xbb05fbb0, (q31_t)0x6bcfce80, (q31_t)0xbb00b0ce, + (q31_t)0x6bcc6b53, (q31_t)0xbafb6615, (q31_t)0x6bc907e3, (q31_t)0xbaf61b88, + (q31_t)0x6bc5a431, (q31_t)0xbaf0d125, (q31_t)0x6bc2403d, (q31_t)0xbaeb86ed, + (q31_t)0x6bbedc06, (q31_t)0xbae63cdf, (q31_t)0x6bbb778d, (q31_t)0xbae0f2fc, + (q31_t)0x6bb812d1, (q31_t)0xbadba943, (q31_t)0x6bb4add3, (q31_t)0xbad65fb5, + (q31_t)0x6bb14892, (q31_t)0xbad11652, (q31_t)0x6bade30f, (q31_t)0xbacbcd1a, + (q31_t)0x6baa7d49, (q31_t)0xbac6840c, (q31_t)0x6ba71741, (q31_t)0xbac13b29, + (q31_t)0x6ba3b0f7, (q31_t)0xbabbf270, (q31_t)0x6ba04a6a, (q31_t)0xbab6a9e3, + (q31_t)0x6b9ce39b, (q31_t)0xbab16180, (q31_t)0x6b997c8a, (q31_t)0xbaac1948, + (q31_t)0x6b961536, (q31_t)0xbaa6d13a, (q31_t)0x6b92ada0, (q31_t)0xbaa18958, + (q31_t)0x6b8f45c7, (q31_t)0xba9c41a0, (q31_t)0x6b8bddac, (q31_t)0xba96fa13, + (q31_t)0x6b88754f, (q31_t)0xba91b2b1, (q31_t)0x6b850caf, (q31_t)0xba8c6b79, + (q31_t)0x6b81a3cd, (q31_t)0xba87246d, (q31_t)0x6b7e3aa9, (q31_t)0xba81dd8b, + (q31_t)0x6b7ad142, (q31_t)0xba7c96d4, (q31_t)0x6b776799, (q31_t)0xba775048, + (q31_t)0x6b73fdae, (q31_t)0xba7209e7, (q31_t)0x6b709381, (q31_t)0xba6cc3b1, + (q31_t)0x6b6d2911, (q31_t)0xba677da6, (q31_t)0x6b69be5f, (q31_t)0xba6237c5, + (q31_t)0x6b66536b, (q31_t)0xba5cf210, (q31_t)0x6b62e834, (q31_t)0xba57ac86, + (q31_t)0x6b5f7cbc, (q31_t)0xba526726, (q31_t)0x6b5c1101, (q31_t)0xba4d21f2, + (q31_t)0x6b58a503, (q31_t)0xba47dce8, (q31_t)0x6b5538c4, (q31_t)0xba42980a, + (q31_t)0x6b51cc42, (q31_t)0xba3d5356, (q31_t)0x6b4e5f7f, (q31_t)0xba380ece, + (q31_t)0x6b4af279, (q31_t)0xba32ca71, (q31_t)0x6b478530, (q31_t)0xba2d863e, + (q31_t)0x6b4417a6, (q31_t)0xba284237, (q31_t)0x6b40a9d9, (q31_t)0xba22fe5b, + (q31_t)0x6b3d3bcb, (q31_t)0xba1dbaaa, (q31_t)0x6b39cd7a, (q31_t)0xba187724, + (q31_t)0x6b365ee7, (q31_t)0xba1333c9, (q31_t)0x6b32f012, (q31_t)0xba0df099, + (q31_t)0x6b2f80fb, (q31_t)0xba08ad95, (q31_t)0x6b2c11a1, (q31_t)0xba036abb, + (q31_t)0x6b28a206, (q31_t)0xb9fe280d, (q31_t)0x6b253228, (q31_t)0xb9f8e58a, + (q31_t)0x6b21c208, (q31_t)0xb9f3a332, (q31_t)0x6b1e51a7, (q31_t)0xb9ee6106, + (q31_t)0x6b1ae103, (q31_t)0xb9e91f04, (q31_t)0x6b17701d, (q31_t)0xb9e3dd2e, + (q31_t)0x6b13fef5, (q31_t)0xb9de9b83, (q31_t)0x6b108d8b, (q31_t)0xb9d95a03, + (q31_t)0x6b0d1bdf, (q31_t)0xb9d418af, (q31_t)0x6b09a9f1, (q31_t)0xb9ced786, + (q31_t)0x6b0637c1, (q31_t)0xb9c99688, (q31_t)0x6b02c54f, (q31_t)0xb9c455b6, + (q31_t)0x6aff529a, (q31_t)0xb9bf150e, (q31_t)0x6afbdfa4, (q31_t)0xb9b9d493, + (q31_t)0x6af86c6c, (q31_t)0xb9b49442, (q31_t)0x6af4f8f2, (q31_t)0xb9af541d, + (q31_t)0x6af18536, (q31_t)0xb9aa1423, (q31_t)0x6aee1138, (q31_t)0xb9a4d455, + (q31_t)0x6aea9cf8, (q31_t)0xb99f94b2, (q31_t)0x6ae72876, (q31_t)0xb99a553a, + (q31_t)0x6ae3b3b2, (q31_t)0xb99515ee, (q31_t)0x6ae03eac, (q31_t)0xb98fd6cd, + (q31_t)0x6adcc964, (q31_t)0xb98a97d8, (q31_t)0x6ad953db, (q31_t)0xb985590e, + (q31_t)0x6ad5de0f, (q31_t)0xb9801a70, (q31_t)0x6ad26802, (q31_t)0xb97adbfd, + (q31_t)0x6acef1b2, (q31_t)0xb9759db6, (q31_t)0x6acb7b21, (q31_t)0xb9705f9a, + (q31_t)0x6ac8044e, (q31_t)0xb96b21aa, (q31_t)0x6ac48d39, (q31_t)0xb965e3e5, + (q31_t)0x6ac115e2, (q31_t)0xb960a64c, (q31_t)0x6abd9e49, (q31_t)0xb95b68de, + (q31_t)0x6aba266e, (q31_t)0xb9562b9c, (q31_t)0x6ab6ae52, (q31_t)0xb950ee86, + (q31_t)0x6ab335f4, (q31_t)0xb94bb19b, (q31_t)0x6aafbd54, (q31_t)0xb94674dc, + (q31_t)0x6aac4472, (q31_t)0xb9413848, (q31_t)0x6aa8cb4e, (q31_t)0xb93bfbe0, + (q31_t)0x6aa551e9, (q31_t)0xb936bfa4, (q31_t)0x6aa1d841, (q31_t)0xb9318393, + (q31_t)0x6a9e5e58, (q31_t)0xb92c47ae, (q31_t)0x6a9ae42e, (q31_t)0xb9270bf5, + (q31_t)0x6a9769c1, (q31_t)0xb921d067, (q31_t)0x6a93ef13, (q31_t)0xb91c9505, + (q31_t)0x6a907423, (q31_t)0xb91759cf, (q31_t)0x6a8cf8f1, (q31_t)0xb9121ec5, + (q31_t)0x6a897d7d, (q31_t)0xb90ce3e6, (q31_t)0x6a8601c8, (q31_t)0xb907a933, + (q31_t)0x6a8285d1, (q31_t)0xb9026eac, (q31_t)0x6a7f0999, (q31_t)0xb8fd3451, + (q31_t)0x6a7b8d1e, (q31_t)0xb8f7fa21, (q31_t)0x6a781062, (q31_t)0xb8f2c01d, + (q31_t)0x6a749365, (q31_t)0xb8ed8646, (q31_t)0x6a711625, (q31_t)0xb8e84c99, + (q31_t)0x6a6d98a4, (q31_t)0xb8e31319, (q31_t)0x6a6a1ae2, (q31_t)0xb8ddd9c5, + (q31_t)0x6a669cdd, (q31_t)0xb8d8a09d, (q31_t)0x6a631e97, (q31_t)0xb8d367a0, + (q31_t)0x6a5fa010, (q31_t)0xb8ce2ecf, (q31_t)0x6a5c2147, (q31_t)0xb8c8f62b, + (q31_t)0x6a58a23c, (q31_t)0xb8c3bdb2, (q31_t)0x6a5522ef, (q31_t)0xb8be8565, + (q31_t)0x6a51a361, (q31_t)0xb8b94d44, (q31_t)0x6a4e2392, (q31_t)0xb8b4154f, + (q31_t)0x6a4aa381, (q31_t)0xb8aedd86, (q31_t)0x6a47232e, (q31_t)0xb8a9a5e9, + (q31_t)0x6a43a29a, (q31_t)0xb8a46e78, (q31_t)0x6a4021c4, (q31_t)0xb89f3733, + (q31_t)0x6a3ca0ad, (q31_t)0xb89a001a, (q31_t)0x6a391f54, (q31_t)0xb894c92d, + (q31_t)0x6a359db9, (q31_t)0xb88f926d, (q31_t)0x6a321bdd, (q31_t)0xb88a5bd8, + (q31_t)0x6a2e99c0, (q31_t)0xb885256f, (q31_t)0x6a2b1761, (q31_t)0xb87fef33, + (q31_t)0x6a2794c1, (q31_t)0xb87ab922, (q31_t)0x6a2411df, (q31_t)0xb875833e, + (q31_t)0x6a208ebb, (q31_t)0xb8704d85, (q31_t)0x6a1d0b57, (q31_t)0xb86b17f9, + (q31_t)0x6a1987b0, (q31_t)0xb865e299, (q31_t)0x6a1603c8, (q31_t)0xb860ad66, + (q31_t)0x6a127f9f, (q31_t)0xb85b785e, (q31_t)0x6a0efb35, (q31_t)0xb8564383, + (q31_t)0x6a0b7689, (q31_t)0xb8510ed4, (q31_t)0x6a07f19b, (q31_t)0xb84bda51, + (q31_t)0x6a046c6c, (q31_t)0xb846a5fa, (q31_t)0x6a00e6fc, (q31_t)0xb84171cf, + (q31_t)0x69fd614a, (q31_t)0xb83c3dd1, (q31_t)0x69f9db57, (q31_t)0xb83709ff, + (q31_t)0x69f65523, (q31_t)0xb831d659, (q31_t)0x69f2cead, (q31_t)0xb82ca2e0, + (q31_t)0x69ef47f6, (q31_t)0xb8276f93, (q31_t)0x69ebc0fe, (q31_t)0xb8223c72, + (q31_t)0x69e839c4, (q31_t)0xb81d097e, (q31_t)0x69e4b249, (q31_t)0xb817d6b6, + (q31_t)0x69e12a8c, (q31_t)0xb812a41a, (q31_t)0x69dda28f, (q31_t)0xb80d71aa, + (q31_t)0x69da1a50, (q31_t)0xb8083f67, (q31_t)0x69d691cf, (q31_t)0xb8030d51, + (q31_t)0x69d3090e, (q31_t)0xb7fddb67, (q31_t)0x69cf800b, (q31_t)0xb7f8a9a9, + (q31_t)0x69cbf6c7, (q31_t)0xb7f37818, (q31_t)0x69c86d41, (q31_t)0xb7ee46b3, + (q31_t)0x69c4e37a, (q31_t)0xb7e9157a, (q31_t)0x69c15973, (q31_t)0xb7e3e46e, + (q31_t)0x69bdcf29, (q31_t)0xb7deb38f, (q31_t)0x69ba449f, (q31_t)0xb7d982dc, + (q31_t)0x69b6b9d3, (q31_t)0xb7d45255, (q31_t)0x69b32ec7, (q31_t)0xb7cf21fb, + (q31_t)0x69afa378, (q31_t)0xb7c9f1ce, (q31_t)0x69ac17e9, (q31_t)0xb7c4c1cd, + (q31_t)0x69a88c19, (q31_t)0xb7bf91f8, (q31_t)0x69a50007, (q31_t)0xb7ba6251, + (q31_t)0x69a173b5, (q31_t)0xb7b532d6, (q31_t)0x699de721, (q31_t)0xb7b00387, + (q31_t)0x699a5a4c, (q31_t)0xb7aad465, (q31_t)0x6996cd35, (q31_t)0xb7a5a570, + (q31_t)0x69933fde, (q31_t)0xb7a076a7, (q31_t)0x698fb246, (q31_t)0xb79b480b, + (q31_t)0x698c246c, (q31_t)0xb796199b, (q31_t)0x69889651, (q31_t)0xb790eb58, + (q31_t)0x698507f6, (q31_t)0xb78bbd42, (q31_t)0x69817959, (q31_t)0xb7868f59, + (q31_t)0x697dea7b, (q31_t)0xb781619c, (q31_t)0x697a5b5c, (q31_t)0xb77c340c, + (q31_t)0x6976cbfc, (q31_t)0xb77706a9, (q31_t)0x69733c5b, (q31_t)0xb771d972, + (q31_t)0x696fac78, (q31_t)0xb76cac69, (q31_t)0x696c1c55, (q31_t)0xb7677f8c, + (q31_t)0x69688bf1, (q31_t)0xb76252db, (q31_t)0x6964fb4c, (q31_t)0xb75d2658, + (q31_t)0x69616a65, (q31_t)0xb757fa01, (q31_t)0x695dd93e, (q31_t)0xb752cdd8, + (q31_t)0x695a47d6, (q31_t)0xb74da1db, (q31_t)0x6956b62d, (q31_t)0xb748760b, + (q31_t)0x69532442, (q31_t)0xb7434a67, (q31_t)0x694f9217, (q31_t)0xb73e1ef1, + (q31_t)0x694bffab, (q31_t)0xb738f3a7, (q31_t)0x69486cfe, (q31_t)0xb733c88b, + (q31_t)0x6944da10, (q31_t)0xb72e9d9b, (q31_t)0x694146e1, (q31_t)0xb72972d8, + (q31_t)0x693db371, (q31_t)0xb7244842, (q31_t)0x693a1fc0, (q31_t)0xb71f1dd9, + (q31_t)0x69368bce, (q31_t)0xb719f39e, (q31_t)0x6932f79b, (q31_t)0xb714c98e, + (q31_t)0x692f6328, (q31_t)0xb70f9fac, (q31_t)0x692bce73, (q31_t)0xb70a75f7, + (q31_t)0x6928397e, (q31_t)0xb7054c6f, (q31_t)0x6924a448, (q31_t)0xb7002314, + (q31_t)0x69210ed1, (q31_t)0xb6faf9e6, (q31_t)0x691d7919, (q31_t)0xb6f5d0e5, + (q31_t)0x6919e320, (q31_t)0xb6f0a812, (q31_t)0x69164ce7, (q31_t)0xb6eb7f6b, + (q31_t)0x6912b66c, (q31_t)0xb6e656f1, (q31_t)0x690f1fb1, (q31_t)0xb6e12ea4, + (q31_t)0x690b88b5, (q31_t)0xb6dc0685, (q31_t)0x6907f178, (q31_t)0xb6d6de92, + (q31_t)0x690459fb, (q31_t)0xb6d1b6cd, (q31_t)0x6900c23c, (q31_t)0xb6cc8f35, + (q31_t)0x68fd2a3d, (q31_t)0xb6c767ca, (q31_t)0x68f991fd, (q31_t)0xb6c2408c, + (q31_t)0x68f5f97d, (q31_t)0xb6bd197c, (q31_t)0x68f260bb, (q31_t)0xb6b7f298, + (q31_t)0x68eec7b9, (q31_t)0xb6b2cbe2, (q31_t)0x68eb2e76, (q31_t)0xb6ada559, + (q31_t)0x68e794f3, (q31_t)0xb6a87efd, (q31_t)0x68e3fb2e, (q31_t)0xb6a358ce, + (q31_t)0x68e06129, (q31_t)0xb69e32cd, (q31_t)0x68dcc6e4, (q31_t)0xb6990cf9, + (q31_t)0x68d92c5d, (q31_t)0xb693e752, (q31_t)0x68d59196, (q31_t)0xb68ec1d9, + (q31_t)0x68d1f68f, (q31_t)0xb6899c8d, (q31_t)0x68ce5b46, (q31_t)0xb684776e, + (q31_t)0x68cabfbd, (q31_t)0xb67f527c, (q31_t)0x68c723f3, (q31_t)0xb67a2db8, + (q31_t)0x68c387e9, (q31_t)0xb6750921, (q31_t)0x68bfeb9e, (q31_t)0xb66fe4b8, + (q31_t)0x68bc4f13, (q31_t)0xb66ac07c, (q31_t)0x68b8b247, (q31_t)0xb6659c6d, + (q31_t)0x68b5153a, (q31_t)0xb660788c, (q31_t)0x68b177ed, (q31_t)0xb65b54d8, + (q31_t)0x68adda5f, (q31_t)0xb6563151, (q31_t)0x68aa3c90, (q31_t)0xb6510df8, + (q31_t)0x68a69e81, (q31_t)0xb64beacd, (q31_t)0x68a30031, (q31_t)0xb646c7ce, + (q31_t)0x689f61a1, (q31_t)0xb641a4fe, (q31_t)0x689bc2d1, (q31_t)0xb63c825b, + (q31_t)0x689823bf, (q31_t)0xb6375fe5, (q31_t)0x6894846e, (q31_t)0xb6323d9d, + (q31_t)0x6890e4dc, (q31_t)0xb62d1b82, (q31_t)0x688d4509, (q31_t)0xb627f995, + (q31_t)0x6889a4f6, (q31_t)0xb622d7d6, (q31_t)0x688604a2, (q31_t)0xb61db644, + (q31_t)0x6882640e, (q31_t)0xb61894df, (q31_t)0x687ec339, (q31_t)0xb61373a9, + (q31_t)0x687b2224, (q31_t)0xb60e529f, (q31_t)0x687780ce, (q31_t)0xb60931c4, + (q31_t)0x6873df38, (q31_t)0xb6041116, (q31_t)0x68703d62, (q31_t)0xb5fef095, + (q31_t)0x686c9b4b, (q31_t)0xb5f9d043, (q31_t)0x6868f8f4, (q31_t)0xb5f4b01e, + (q31_t)0x6865565c, (q31_t)0xb5ef9026, (q31_t)0x6861b384, (q31_t)0xb5ea705d, + (q31_t)0x685e106c, (q31_t)0xb5e550c1, (q31_t)0x685a6d13, (q31_t)0xb5e03153, + (q31_t)0x6856c979, (q31_t)0xb5db1212, (q31_t)0x685325a0, (q31_t)0xb5d5f2ff, + (q31_t)0x684f8186, (q31_t)0xb5d0d41a, (q31_t)0x684bdd2c, (q31_t)0xb5cbb563, + (q31_t)0x68483891, (q31_t)0xb5c696da, (q31_t)0x684493b6, (q31_t)0xb5c1787e, + (q31_t)0x6840ee9b, (q31_t)0xb5bc5a50, (q31_t)0x683d493f, (q31_t)0xb5b73c50, + (q31_t)0x6839a3a4, (q31_t)0xb5b21e7e, (q31_t)0x6835fdc7, (q31_t)0xb5ad00d9, + (q31_t)0x683257ab, (q31_t)0xb5a7e362, (q31_t)0x682eb14e, (q31_t)0xb5a2c61a, + (q31_t)0x682b0ab1, (q31_t)0xb59da8ff, (q31_t)0x682763d4, (q31_t)0xb5988c12, + (q31_t)0x6823bcb7, (q31_t)0xb5936f53, (q31_t)0x68201559, (q31_t)0xb58e52c2, + (q31_t)0x681c6dbb, (q31_t)0xb589365e, (q31_t)0x6818c5dd, (q31_t)0xb5841a29, + (q31_t)0x68151dbe, (q31_t)0xb57efe22, (q31_t)0x68117560, (q31_t)0xb579e248, + (q31_t)0x680dccc1, (q31_t)0xb574c69d, (q31_t)0x680a23e2, (q31_t)0xb56fab1f, + (q31_t)0x68067ac3, (q31_t)0xb56a8fd0, (q31_t)0x6802d164, (q31_t)0xb56574ae, + (q31_t)0x67ff27c4, (q31_t)0xb56059bb, (q31_t)0x67fb7de5, (q31_t)0xb55b3ef5, + (q31_t)0x67f7d3c5, (q31_t)0xb556245e, (q31_t)0x67f42965, (q31_t)0xb55109f5, + (q31_t)0x67f07ec5, (q31_t)0xb54befba, (q31_t)0x67ecd3e5, (q31_t)0xb546d5ac, + (q31_t)0x67e928c5, (q31_t)0xb541bbcd, (q31_t)0x67e57d64, (q31_t)0xb53ca21c, + (q31_t)0x67e1d1c4, (q31_t)0xb5378899, (q31_t)0x67de25e3, (q31_t)0xb5326f45, + (q31_t)0x67da79c3, (q31_t)0xb52d561e, (q31_t)0x67d6cd62, (q31_t)0xb5283d26, + (q31_t)0x67d320c1, (q31_t)0xb523245b, (q31_t)0x67cf73e1, (q31_t)0xb51e0bbf, + (q31_t)0x67cbc6c0, (q31_t)0xb518f351, (q31_t)0x67c8195f, (q31_t)0xb513db12, + (q31_t)0x67c46bbe, (q31_t)0xb50ec300, (q31_t)0x67c0bddd, (q31_t)0xb509ab1d, + (q31_t)0x67bd0fbd, (q31_t)0xb5049368, (q31_t)0x67b9615c, (q31_t)0xb4ff7be1, + (q31_t)0x67b5b2bb, (q31_t)0xb4fa6489, (q31_t)0x67b203da, (q31_t)0xb4f54d5f, + (q31_t)0x67ae54ba, (q31_t)0xb4f03663, (q31_t)0x67aaa559, (q31_t)0xb4eb1f95, + (q31_t)0x67a6f5b8, (q31_t)0xb4e608f6, (q31_t)0x67a345d8, (q31_t)0xb4e0f285, + (q31_t)0x679f95b7, (q31_t)0xb4dbdc42, (q31_t)0x679be557, (q31_t)0xb4d6c62e, + (q31_t)0x679834b6, (q31_t)0xb4d1b048, (q31_t)0x679483d6, (q31_t)0xb4cc9a90, + (q31_t)0x6790d2b6, (q31_t)0xb4c78507, (q31_t)0x678d2156, (q31_t)0xb4c26fad, + (q31_t)0x67896fb6, (q31_t)0xb4bd5a80, (q31_t)0x6785bdd6, (q31_t)0xb4b84582, + (q31_t)0x67820bb7, (q31_t)0xb4b330b3, (q31_t)0x677e5957, (q31_t)0xb4ae1c12, + (q31_t)0x677aa6b8, (q31_t)0xb4a9079f, (q31_t)0x6776f3d9, (q31_t)0xb4a3f35b, + (q31_t)0x677340ba, (q31_t)0xb49edf45, (q31_t)0x676f8d5b, (q31_t)0xb499cb5e, + (q31_t)0x676bd9bd, (q31_t)0xb494b7a6, (q31_t)0x676825de, (q31_t)0xb48fa41c, + (q31_t)0x676471c0, (q31_t)0xb48a90c0, (q31_t)0x6760bd62, (q31_t)0xb4857d93, + (q31_t)0x675d08c4, (q31_t)0xb4806a95, (q31_t)0x675953e7, (q31_t)0xb47b57c5, + (q31_t)0x67559eca, (q31_t)0xb4764523, (q31_t)0x6751e96d, (q31_t)0xb47132b1, + (q31_t)0x674e33d0, (q31_t)0xb46c206d, (q31_t)0x674a7df4, (q31_t)0xb4670e57, + (q31_t)0x6746c7d8, (q31_t)0xb461fc70, (q31_t)0x6743117c, (q31_t)0xb45ceab8, + (q31_t)0x673f5ae0, (q31_t)0xb457d92f, (q31_t)0x673ba405, (q31_t)0xb452c7d4, + (q31_t)0x6737ecea, (q31_t)0xb44db6a8, (q31_t)0x67343590, (q31_t)0xb448a5aa, + (q31_t)0x67307df5, (q31_t)0xb44394db, (q31_t)0x672cc61c, (q31_t)0xb43e843b, + (q31_t)0x67290e02, (q31_t)0xb43973ca, (q31_t)0x672555a9, (q31_t)0xb4346387, + (q31_t)0x67219d10, (q31_t)0xb42f5373, (q31_t)0x671de438, (q31_t)0xb42a438e, + (q31_t)0x671a2b20, (q31_t)0xb42533d8, (q31_t)0x671671c8, (q31_t)0xb4202451, + (q31_t)0x6712b831, (q31_t)0xb41b14f8, (q31_t)0x670efe5a, (q31_t)0xb41605ce, + (q31_t)0x670b4444, (q31_t)0xb410f6d3, (q31_t)0x670789ee, (q31_t)0xb40be807, + (q31_t)0x6703cf58, (q31_t)0xb406d969, (q31_t)0x67001483, (q31_t)0xb401cafb, + (q31_t)0x66fc596f, (q31_t)0xb3fcbcbb, (q31_t)0x66f89e1b, (q31_t)0xb3f7aeaa, + (q31_t)0x66f4e287, (q31_t)0xb3f2a0c9, (q31_t)0x66f126b4, (q31_t)0xb3ed9316, + (q31_t)0x66ed6aa1, (q31_t)0xb3e88592, (q31_t)0x66e9ae4f, (q31_t)0xb3e3783d, + (q31_t)0x66e5f1be, (q31_t)0xb3de6b17, (q31_t)0x66e234ed, (q31_t)0xb3d95e1f, + (q31_t)0x66de77dc, (q31_t)0xb3d45157, (q31_t)0x66daba8c, (q31_t)0xb3cf44be, + (q31_t)0x66d6fcfd, (q31_t)0xb3ca3854, (q31_t)0x66d33f2e, (q31_t)0xb3c52c19, + (q31_t)0x66cf8120, (q31_t)0xb3c0200c, (q31_t)0x66cbc2d2, (q31_t)0xb3bb142f, + (q31_t)0x66c80445, (q31_t)0xb3b60881, (q31_t)0x66c44579, (q31_t)0xb3b0fd02, + (q31_t)0x66c0866d, (q31_t)0xb3abf1b2, (q31_t)0x66bcc721, (q31_t)0xb3a6e691, + (q31_t)0x66b90797, (q31_t)0xb3a1dba0, (q31_t)0x66b547cd, (q31_t)0xb39cd0dd, + (q31_t)0x66b187c3, (q31_t)0xb397c649, (q31_t)0x66adc77b, (q31_t)0xb392bbe5, + (q31_t)0x66aa06f3, (q31_t)0xb38db1b0, (q31_t)0x66a6462b, (q31_t)0xb388a7aa, + (q31_t)0x66a28524, (q31_t)0xb3839dd3, (q31_t)0x669ec3de, (q31_t)0xb37e942b, + (q31_t)0x669b0259, (q31_t)0xb3798ab2, (q31_t)0x66974095, (q31_t)0xb3748169, + (q31_t)0x66937e91, (q31_t)0xb36f784f, (q31_t)0x668fbc4e, (q31_t)0xb36a6f64, + (q31_t)0x668bf9cb, (q31_t)0xb36566a8, (q31_t)0x66883709, (q31_t)0xb3605e1c, + (q31_t)0x66847408, (q31_t)0xb35b55bf, (q31_t)0x6680b0c8, (q31_t)0xb3564d91, + (q31_t)0x667ced49, (q31_t)0xb3514592, (q31_t)0x6679298a, (q31_t)0xb34c3dc3, + (q31_t)0x6675658c, (q31_t)0xb3473623, (q31_t)0x6671a14f, (q31_t)0xb3422eb2, + (q31_t)0x666ddcd3, (q31_t)0xb33d2771, (q31_t)0x666a1818, (q31_t)0xb338205f, + (q31_t)0x6666531d, (q31_t)0xb333197c, (q31_t)0x66628de4, (q31_t)0xb32e12c9, + (q31_t)0x665ec86b, (q31_t)0xb3290c45, (q31_t)0x665b02b3, (q31_t)0xb32405f1, + (q31_t)0x66573cbb, (q31_t)0xb31effcc, (q31_t)0x66537685, (q31_t)0xb319f9d6, + (q31_t)0x664fb010, (q31_t)0xb314f410, (q31_t)0x664be95b, (q31_t)0xb30fee79, + (q31_t)0x66482267, (q31_t)0xb30ae912, (q31_t)0x66445b35, (q31_t)0xb305e3da, + (q31_t)0x664093c3, (q31_t)0xb300ded2, (q31_t)0x663ccc12, (q31_t)0xb2fbd9f9, + (q31_t)0x66390422, (q31_t)0xb2f6d550, (q31_t)0x66353bf3, (q31_t)0xb2f1d0d6, + (q31_t)0x66317385, (q31_t)0xb2eccc8c, (q31_t)0x662daad8, (q31_t)0xb2e7c871, + (q31_t)0x6629e1ec, (q31_t)0xb2e2c486, (q31_t)0x662618c1, (q31_t)0xb2ddc0ca, + (q31_t)0x66224f56, (q31_t)0xb2d8bd3e, (q31_t)0x661e85ad, (q31_t)0xb2d3b9e2, + (q31_t)0x661abbc5, (q31_t)0xb2ceb6b5, (q31_t)0x6616f19e, (q31_t)0xb2c9b3b8, + (q31_t)0x66132738, (q31_t)0xb2c4b0ea, (q31_t)0x660f5c93, (q31_t)0xb2bfae4c, + (q31_t)0x660b91af, (q31_t)0xb2baabde, (q31_t)0x6607c68c, (q31_t)0xb2b5a99f, + (q31_t)0x6603fb2a, (q31_t)0xb2b0a790, (q31_t)0x66002f89, (q31_t)0xb2aba5b1, + (q31_t)0x65fc63a9, (q31_t)0xb2a6a402, (q31_t)0x65f8978b, (q31_t)0xb2a1a282, + (q31_t)0x65f4cb2d, (q31_t)0xb29ca132, (q31_t)0x65f0fe91, (q31_t)0xb297a011, + (q31_t)0x65ed31b5, (q31_t)0xb2929f21, (q31_t)0x65e9649b, (q31_t)0xb28d9e60, + (q31_t)0x65e59742, (q31_t)0xb2889dcf, (q31_t)0x65e1c9aa, (q31_t)0xb2839d6d, + (q31_t)0x65ddfbd3, (q31_t)0xb27e9d3c, (q31_t)0x65da2dbd, (q31_t)0xb2799d3a, + (q31_t)0x65d65f69, (q31_t)0xb2749d68, (q31_t)0x65d290d6, (q31_t)0xb26f9dc6, + (q31_t)0x65cec204, (q31_t)0xb26a9e54, (q31_t)0x65caf2f3, (q31_t)0xb2659f12, + (q31_t)0x65c723a3, (q31_t)0xb2609fff, (q31_t)0x65c35415, (q31_t)0xb25ba11d, + (q31_t)0x65bf8447, (q31_t)0xb256a26a, (q31_t)0x65bbb43b, (q31_t)0xb251a3e7, + (q31_t)0x65b7e3f1, (q31_t)0xb24ca594, (q31_t)0x65b41367, (q31_t)0xb247a771, + (q31_t)0x65b0429f, (q31_t)0xb242a97e, (q31_t)0x65ac7198, (q31_t)0xb23dabbb, + (q31_t)0x65a8a052, (q31_t)0xb238ae28, (q31_t)0x65a4cece, (q31_t)0xb233b0c5, + (q31_t)0x65a0fd0b, (q31_t)0xb22eb392, (q31_t)0x659d2b09, (q31_t)0xb229b68f, + (q31_t)0x659958c9, (q31_t)0xb224b9bc, (q31_t)0x6595864a, (q31_t)0xb21fbd19, + (q31_t)0x6591b38c, (q31_t)0xb21ac0a6, (q31_t)0x658de08f, (q31_t)0xb215c463, + (q31_t)0x658a0d54, (q31_t)0xb210c850, (q31_t)0x658639db, (q31_t)0xb20bcc6d, + (q31_t)0x65826622, (q31_t)0xb206d0ba, (q31_t)0x657e922b, (q31_t)0xb201d537, + (q31_t)0x657abdf6, (q31_t)0xb1fcd9e5, (q31_t)0x6576e982, (q31_t)0xb1f7dec2, + (q31_t)0x657314cf, (q31_t)0xb1f2e3d0, (q31_t)0x656f3fde, (q31_t)0xb1ede90e, + (q31_t)0x656b6aae, (q31_t)0xb1e8ee7c, (q31_t)0x6567953f, (q31_t)0xb1e3f41a, + (q31_t)0x6563bf92, (q31_t)0xb1def9e9, (q31_t)0x655fe9a7, (q31_t)0xb1d9ffe7, + (q31_t)0x655c137d, (q31_t)0xb1d50616, (q31_t)0x65583d14, (q31_t)0xb1d00c75, + (q31_t)0x6554666d, (q31_t)0xb1cb1304, (q31_t)0x65508f87, (q31_t)0xb1c619c3, + (q31_t)0x654cb863, (q31_t)0xb1c120b3, (q31_t)0x6548e101, (q31_t)0xb1bc27d3, + (q31_t)0x6545095f, (q31_t)0xb1b72f23, (q31_t)0x65413180, (q31_t)0xb1b236a4, + (q31_t)0x653d5962, (q31_t)0xb1ad3e55, (q31_t)0x65398105, (q31_t)0xb1a84636, + (q31_t)0x6535a86b, (q31_t)0xb1a34e47, (q31_t)0x6531cf91, (q31_t)0xb19e5689, + (q31_t)0x652df679, (q31_t)0xb1995efb, (q31_t)0x652a1d23, (q31_t)0xb194679e, + (q31_t)0x6526438f, (q31_t)0xb18f7071, (q31_t)0x652269bc, (q31_t)0xb18a7974, + (q31_t)0x651e8faa, (q31_t)0xb18582a8, (q31_t)0x651ab55b, (q31_t)0xb1808c0c, + (q31_t)0x6516dacd, (q31_t)0xb17b95a0, (q31_t)0x65130000, (q31_t)0xb1769f65, + (q31_t)0x650f24f5, (q31_t)0xb171a95b, (q31_t)0x650b49ac, (q31_t)0xb16cb380, + (q31_t)0x65076e25, (q31_t)0xb167bdd7, (q31_t)0x6503925f, (q31_t)0xb162c85d, + (q31_t)0x64ffb65b, (q31_t)0xb15dd315, (q31_t)0x64fbda18, (q31_t)0xb158ddfd, + (q31_t)0x64f7fd98, (q31_t)0xb153e915, (q31_t)0x64f420d9, (q31_t)0xb14ef45e, + (q31_t)0x64f043dc, (q31_t)0xb149ffd7, (q31_t)0x64ec66a0, (q31_t)0xb1450b81, + (q31_t)0x64e88926, (q31_t)0xb140175b, (q31_t)0x64e4ab6e, (q31_t)0xb13b2367, + (q31_t)0x64e0cd78, (q31_t)0xb1362fa2, (q31_t)0x64dcef44, (q31_t)0xb1313c0e, + (q31_t)0x64d910d1, (q31_t)0xb12c48ab, (q31_t)0x64d53220, (q31_t)0xb1275579, + (q31_t)0x64d15331, (q31_t)0xb1226277, (q31_t)0x64cd7404, (q31_t)0xb11d6fa6, + (q31_t)0x64c99498, (q31_t)0xb1187d05, (q31_t)0x64c5b4ef, (q31_t)0xb1138a95, + (q31_t)0x64c1d507, (q31_t)0xb10e9856, (q31_t)0x64bdf4e1, (q31_t)0xb109a648, + (q31_t)0x64ba147d, (q31_t)0xb104b46a, (q31_t)0x64b633da, (q31_t)0xb0ffc2bd, + (q31_t)0x64b252fa, (q31_t)0xb0fad140, (q31_t)0x64ae71dc, (q31_t)0xb0f5dff5, + (q31_t)0x64aa907f, (q31_t)0xb0f0eeda, (q31_t)0x64a6aee4, (q31_t)0xb0ebfdf0, + (q31_t)0x64a2cd0c, (q31_t)0xb0e70d37, (q31_t)0x649eeaf5, (q31_t)0xb0e21cae, + (q31_t)0x649b08a0, (q31_t)0xb0dd2c56, (q31_t)0x6497260d, (q31_t)0xb0d83c2f, + (q31_t)0x6493433c, (q31_t)0xb0d34c39, (q31_t)0x648f602d, (q31_t)0xb0ce5c74, + (q31_t)0x648b7ce0, (q31_t)0xb0c96ce0, (q31_t)0x64879955, (q31_t)0xb0c47d7c, + (q31_t)0x6483b58c, (q31_t)0xb0bf8e4a, (q31_t)0x647fd185, (q31_t)0xb0ba9f48, + (q31_t)0x647bed3f, (q31_t)0xb0b5b077, (q31_t)0x647808bc, (q31_t)0xb0b0c1d7, + (q31_t)0x647423fb, (q31_t)0xb0abd368, (q31_t)0x64703efc, (q31_t)0xb0a6e52a, + (q31_t)0x646c59bf, (q31_t)0xb0a1f71d, (q31_t)0x64687444, (q31_t)0xb09d0941, + (q31_t)0x64648e8c, (q31_t)0xb0981b96, (q31_t)0x6460a895, (q31_t)0xb0932e1b, + (q31_t)0x645cc260, (q31_t)0xb08e40d2, (q31_t)0x6458dbed, (q31_t)0xb08953ba, + (q31_t)0x6454f53d, (q31_t)0xb08466d3, (q31_t)0x64510e4e, (q31_t)0xb07f7a1c, + (q31_t)0x644d2722, (q31_t)0xb07a8d97, (q31_t)0x64493fb8, (q31_t)0xb075a143, + (q31_t)0x64455810, (q31_t)0xb070b520, (q31_t)0x6441702a, (q31_t)0xb06bc92e, + (q31_t)0x643d8806, (q31_t)0xb066dd6d, (q31_t)0x64399fa5, (q31_t)0xb061f1de, + (q31_t)0x6435b706, (q31_t)0xb05d067f, (q31_t)0x6431ce28, (q31_t)0xb0581b51, + (q31_t)0x642de50d, (q31_t)0xb0533055, (q31_t)0x6429fbb5, (q31_t)0xb04e458a, + (q31_t)0x6426121e, (q31_t)0xb0495af0, (q31_t)0x6422284a, (q31_t)0xb0447087, + (q31_t)0x641e3e38, (q31_t)0xb03f864f, (q31_t)0x641a53e8, (q31_t)0xb03a9c49, + (q31_t)0x6416695a, (q31_t)0xb035b273, (q31_t)0x64127e8f, (q31_t)0xb030c8cf, + (q31_t)0x640e9386, (q31_t)0xb02bdf5c, (q31_t)0x640aa83f, (q31_t)0xb026f61b, + (q31_t)0x6406bcba, (q31_t)0xb0220d0a, (q31_t)0x6402d0f8, (q31_t)0xb01d242b, + (q31_t)0x63fee4f8, (q31_t)0xb0183b7d, (q31_t)0x63faf8bb, (q31_t)0xb0135301, + (q31_t)0x63f70c3f, (q31_t)0xb00e6ab5, (q31_t)0x63f31f86, (q31_t)0xb009829c, + (q31_t)0x63ef3290, (q31_t)0xb0049ab3, (q31_t)0x63eb455c, (q31_t)0xafffb2fc, + (q31_t)0x63e757ea, (q31_t)0xaffacb76, (q31_t)0x63e36a3a, (q31_t)0xaff5e421, + (q31_t)0x63df7c4d, (q31_t)0xaff0fcfe, (q31_t)0x63db8e22, (q31_t)0xafec160c, + (q31_t)0x63d79fba, (q31_t)0xafe72f4c, (q31_t)0x63d3b114, (q31_t)0xafe248bd, + (q31_t)0x63cfc231, (q31_t)0xafdd625f, (q31_t)0x63cbd310, (q31_t)0xafd87c33, + (q31_t)0x63c7e3b1, (q31_t)0xafd39638, (q31_t)0x63c3f415, (q31_t)0xafceb06f, + (q31_t)0x63c0043b, (q31_t)0xafc9cad7, (q31_t)0x63bc1424, (q31_t)0xafc4e571, + (q31_t)0x63b823cf, (q31_t)0xafc0003c, (q31_t)0x63b4333d, (q31_t)0xafbb1b39, + (q31_t)0x63b0426d, (q31_t)0xafb63667, (q31_t)0x63ac5160, (q31_t)0xafb151c7, + (q31_t)0x63a86015, (q31_t)0xafac6d58, (q31_t)0x63a46e8d, (q31_t)0xafa7891b, + (q31_t)0x63a07cc7, (q31_t)0xafa2a50f, (q31_t)0x639c8ac4, (q31_t)0xaf9dc135, + (q31_t)0x63989884, (q31_t)0xaf98dd8d, (q31_t)0x6394a606, (q31_t)0xaf93fa16, + (q31_t)0x6390b34a, (q31_t)0xaf8f16d1, (q31_t)0x638cc051, (q31_t)0xaf8a33bd, + (q31_t)0x6388cd1b, (q31_t)0xaf8550db, (q31_t)0x6384d9a7, (q31_t)0xaf806e2b, + (q31_t)0x6380e5f6, (q31_t)0xaf7b8bac, (q31_t)0x637cf208, (q31_t)0xaf76a95f, + (q31_t)0x6378fddc, (q31_t)0xaf71c743, (q31_t)0x63750973, (q31_t)0xaf6ce55a, + (q31_t)0x637114cc, (q31_t)0xaf6803a2, (q31_t)0x636d1fe9, (q31_t)0xaf63221c, + (q31_t)0x63692ac7, (q31_t)0xaf5e40c7, (q31_t)0x63653569, (q31_t)0xaf595fa4, + (q31_t)0x63613fcd, (q31_t)0xaf547eb3, (q31_t)0x635d49f4, (q31_t)0xaf4f9df4, + (q31_t)0x635953dd, (q31_t)0xaf4abd66, (q31_t)0x63555d8a, (q31_t)0xaf45dd0b, + (q31_t)0x635166f9, (q31_t)0xaf40fce1, (q31_t)0x634d702b, (q31_t)0xaf3c1ce9, + (q31_t)0x6349791f, (q31_t)0xaf373d22, (q31_t)0x634581d6, (q31_t)0xaf325d8e, + (q31_t)0x63418a50, (q31_t)0xaf2d7e2b, (q31_t)0x633d928d, (q31_t)0xaf289efa, + (q31_t)0x63399a8d, (q31_t)0xaf23bffb, (q31_t)0x6335a24f, (q31_t)0xaf1ee12e, + (q31_t)0x6331a9d4, (q31_t)0xaf1a0293, (q31_t)0x632db11c, (q31_t)0xaf15242a, + (q31_t)0x6329b827, (q31_t)0xaf1045f3, (q31_t)0x6325bef5, (q31_t)0xaf0b67ed, + (q31_t)0x6321c585, (q31_t)0xaf068a1a, (q31_t)0x631dcbd9, (q31_t)0xaf01ac78, + (q31_t)0x6319d1ef, (q31_t)0xaefccf09, (q31_t)0x6315d7c8, (q31_t)0xaef7f1cb, + (q31_t)0x6311dd64, (q31_t)0xaef314c0, (q31_t)0x630de2c3, (q31_t)0xaeee37e6, + (q31_t)0x6309e7e4, (q31_t)0xaee95b3f, (q31_t)0x6305ecc9, (q31_t)0xaee47ec9, + (q31_t)0x6301f171, (q31_t)0xaedfa285, (q31_t)0x62fdf5db, (q31_t)0xaedac674, + (q31_t)0x62f9fa09, (q31_t)0xaed5ea95, (q31_t)0x62f5fdf9, (q31_t)0xaed10ee7, + (q31_t)0x62f201ac, (q31_t)0xaecc336c, (q31_t)0x62ee0523, (q31_t)0xaec75823, + (q31_t)0x62ea085c, (q31_t)0xaec27d0c, (q31_t)0x62e60b58, (q31_t)0xaebda227, + (q31_t)0x62e20e17, (q31_t)0xaeb8c774, (q31_t)0x62de109a, (q31_t)0xaeb3ecf3, + (q31_t)0x62da12df, (q31_t)0xaeaf12a4, (q31_t)0x62d614e7, (q31_t)0xaeaa3888, + (q31_t)0x62d216b3, (q31_t)0xaea55e9e, (q31_t)0x62ce1841, (q31_t)0xaea084e6, + (q31_t)0x62ca1992, (q31_t)0xae9bab60, (q31_t)0x62c61aa7, (q31_t)0xae96d20c, + (q31_t)0x62c21b7e, (q31_t)0xae91f8eb, (q31_t)0x62be1c19, (q31_t)0xae8d1ffb, + (q31_t)0x62ba1c77, (q31_t)0xae88473e, (q31_t)0x62b61c98, (q31_t)0xae836eb4, + (q31_t)0x62b21c7b, (q31_t)0xae7e965b, (q31_t)0x62ae1c23, (q31_t)0xae79be35, + (q31_t)0x62aa1b8d, (q31_t)0xae74e641, (q31_t)0x62a61aba, (q31_t)0xae700e80, + (q31_t)0x62a219aa, (q31_t)0xae6b36f0, (q31_t)0x629e185e, (q31_t)0xae665f93, + (q31_t)0x629a16d5, (q31_t)0xae618869, (q31_t)0x6296150f, (q31_t)0xae5cb171, + (q31_t)0x6292130c, (q31_t)0xae57daab, (q31_t)0x628e10cc, (q31_t)0xae530417, + (q31_t)0x628a0e50, (q31_t)0xae4e2db6, (q31_t)0x62860b97, (q31_t)0xae495787, + (q31_t)0x628208a1, (q31_t)0xae44818b, (q31_t)0x627e056e, (q31_t)0xae3fabc1, + (q31_t)0x627a01fe, (q31_t)0xae3ad629, (q31_t)0x6275fe52, (q31_t)0xae3600c4, + (q31_t)0x6271fa69, (q31_t)0xae312b92, (q31_t)0x626df643, (q31_t)0xae2c5691, + (q31_t)0x6269f1e1, (q31_t)0xae2781c4, (q31_t)0x6265ed42, (q31_t)0xae22ad29, + (q31_t)0x6261e866, (q31_t)0xae1dd8c0, (q31_t)0x625de34e, (q31_t)0xae19048a, + (q31_t)0x6259ddf8, (q31_t)0xae143086, (q31_t)0x6255d866, (q31_t)0xae0f5cb5, + (q31_t)0x6251d298, (q31_t)0xae0a8916, (q31_t)0x624dcc8d, (q31_t)0xae05b5aa, + (q31_t)0x6249c645, (q31_t)0xae00e271, (q31_t)0x6245bfc0, (q31_t)0xadfc0f6a, + (q31_t)0x6241b8ff, (q31_t)0xadf73c96, (q31_t)0x623db202, (q31_t)0xadf269f4, + (q31_t)0x6239aac7, (q31_t)0xaded9785, (q31_t)0x6235a351, (q31_t)0xade8c548, + (q31_t)0x62319b9d, (q31_t)0xade3f33e, (q31_t)0x622d93ad, (q31_t)0xaddf2167, + (q31_t)0x62298b81, (q31_t)0xadda4fc3, (q31_t)0x62258317, (q31_t)0xadd57e51, + (q31_t)0x62217a72, (q31_t)0xadd0ad12, (q31_t)0x621d7190, (q31_t)0xadcbdc05, + (q31_t)0x62196871, (q31_t)0xadc70b2c, (q31_t)0x62155f16, (q31_t)0xadc23a85, + (q31_t)0x6211557e, (q31_t)0xadbd6a10, (q31_t)0x620d4baa, (q31_t)0xadb899cf, + (q31_t)0x62094199, (q31_t)0xadb3c9c0, (q31_t)0x6205374c, (q31_t)0xadaef9e4, + (q31_t)0x62012cc2, (q31_t)0xadaa2a3b, (q31_t)0x61fd21fc, (q31_t)0xada55ac4, + (q31_t)0x61f916f9, (q31_t)0xada08b80, (q31_t)0x61f50bba, (q31_t)0xad9bbc70, + (q31_t)0x61f1003f, (q31_t)0xad96ed92, (q31_t)0x61ecf487, (q31_t)0xad921ee6, + (q31_t)0x61e8e893, (q31_t)0xad8d506e, (q31_t)0x61e4dc62, (q31_t)0xad888229, + (q31_t)0x61e0cff5, (q31_t)0xad83b416, (q31_t)0x61dcc34c, (q31_t)0xad7ee636, + (q31_t)0x61d8b666, (q31_t)0xad7a1889, (q31_t)0x61d4a944, (q31_t)0xad754b0f, + (q31_t)0x61d09be5, (q31_t)0xad707dc8, (q31_t)0x61cc8e4b, (q31_t)0xad6bb0b4, + (q31_t)0x61c88074, (q31_t)0xad66e3d3, (q31_t)0x61c47260, (q31_t)0xad621725, + (q31_t)0x61c06410, (q31_t)0xad5d4aaa, (q31_t)0x61bc5584, (q31_t)0xad587e61, + (q31_t)0x61b846bc, (q31_t)0xad53b24c, (q31_t)0x61b437b7, (q31_t)0xad4ee66a, + (q31_t)0x61b02876, (q31_t)0xad4a1aba, (q31_t)0x61ac18f9, (q31_t)0xad454f3e, + (q31_t)0x61a80940, (q31_t)0xad4083f5, (q31_t)0x61a3f94a, (q31_t)0xad3bb8df, + (q31_t)0x619fe918, (q31_t)0xad36edfc, (q31_t)0x619bd8aa, (q31_t)0xad32234b, + (q31_t)0x6197c800, (q31_t)0xad2d58ce, (q31_t)0x6193b719, (q31_t)0xad288e85, + (q31_t)0x618fa5f7, (q31_t)0xad23c46e, (q31_t)0x618b9498, (q31_t)0xad1efa8a, + (q31_t)0x618782fd, (q31_t)0xad1a30d9, (q31_t)0x61837126, (q31_t)0xad15675c, + (q31_t)0x617f5f12, (q31_t)0xad109e12, (q31_t)0x617b4cc3, (q31_t)0xad0bd4fb, + (q31_t)0x61773a37, (q31_t)0xad070c17, (q31_t)0x61732770, (q31_t)0xad024366, + (q31_t)0x616f146c, (q31_t)0xacfd7ae8, (q31_t)0x616b012c, (q31_t)0xacf8b29e, + (q31_t)0x6166edb0, (q31_t)0xacf3ea87, (q31_t)0x6162d9f8, (q31_t)0xacef22a3, + (q31_t)0x615ec603, (q31_t)0xacea5af2, (q31_t)0x615ab1d3, (q31_t)0xace59375, + (q31_t)0x61569d67, (q31_t)0xace0cc2b, (q31_t)0x615288be, (q31_t)0xacdc0514, + (q31_t)0x614e73da, (q31_t)0xacd73e30, (q31_t)0x614a5eba, (q31_t)0xacd27780, + (q31_t)0x6146495d, (q31_t)0xaccdb103, (q31_t)0x614233c5, (q31_t)0xacc8eab9, + (q31_t)0x613e1df0, (q31_t)0xacc424a3, (q31_t)0x613a07e0, (q31_t)0xacbf5ec0, + (q31_t)0x6135f193, (q31_t)0xacba9910, (q31_t)0x6131db0b, (q31_t)0xacb5d394, + (q31_t)0x612dc447, (q31_t)0xacb10e4b, (q31_t)0x6129ad46, (q31_t)0xacac4935, + (q31_t)0x6125960a, (q31_t)0xaca78453, (q31_t)0x61217e92, (q31_t)0xaca2bfa4, + (q31_t)0x611d66de, (q31_t)0xac9dfb29, (q31_t)0x61194eee, (q31_t)0xac9936e1, + (q31_t)0x611536c2, (q31_t)0xac9472cd, (q31_t)0x61111e5b, (q31_t)0xac8faeec, + (q31_t)0x610d05b7, (q31_t)0xac8aeb3e, (q31_t)0x6108ecd8, (q31_t)0xac8627c4, + (q31_t)0x6104d3bc, (q31_t)0xac81647e, (q31_t)0x6100ba65, (q31_t)0xac7ca16b, + (q31_t)0x60fca0d2, (q31_t)0xac77de8b, (q31_t)0x60f88703, (q31_t)0xac731bdf, + (q31_t)0x60f46cf9, (q31_t)0xac6e5967, (q31_t)0x60f052b2, (q31_t)0xac699722, + (q31_t)0x60ec3830, (q31_t)0xac64d510, (q31_t)0x60e81d72, (q31_t)0xac601333, + (q31_t)0x60e40278, (q31_t)0xac5b5189, (q31_t)0x60dfe743, (q31_t)0xac569012, + (q31_t)0x60dbcbd1, (q31_t)0xac51cecf, (q31_t)0x60d7b024, (q31_t)0xac4d0dc0, + (q31_t)0x60d3943b, (q31_t)0xac484ce4, (q31_t)0x60cf7817, (q31_t)0xac438c3c, + (q31_t)0x60cb5bb7, (q31_t)0xac3ecbc7, (q31_t)0x60c73f1b, (q31_t)0xac3a0b87, + (q31_t)0x60c32243, (q31_t)0xac354b7a, (q31_t)0x60bf0530, (q31_t)0xac308ba0, + (q31_t)0x60bae7e1, (q31_t)0xac2bcbfa, (q31_t)0x60b6ca56, (q31_t)0xac270c88, + (q31_t)0x60b2ac8f, (q31_t)0xac224d4a, (q31_t)0x60ae8e8d, (q31_t)0xac1d8e40, + (q31_t)0x60aa7050, (q31_t)0xac18cf69, (q31_t)0x60a651d7, (q31_t)0xac1410c6, + (q31_t)0x60a23322, (q31_t)0xac0f5256, (q31_t)0x609e1431, (q31_t)0xac0a941b, + (q31_t)0x6099f505, (q31_t)0xac05d613, (q31_t)0x6095d59d, (q31_t)0xac01183f, + (q31_t)0x6091b5fa, (q31_t)0xabfc5a9f, (q31_t)0x608d961b, (q31_t)0xabf79d33, + (q31_t)0x60897601, (q31_t)0xabf2dffb, (q31_t)0x608555ab, (q31_t)0xabee22f6, + (q31_t)0x60813519, (q31_t)0xabe96625, (q31_t)0x607d144c, (q31_t)0xabe4a988, + (q31_t)0x6078f344, (q31_t)0xabdfed1f, (q31_t)0x6074d200, (q31_t)0xabdb30ea, + (q31_t)0x6070b080, (q31_t)0xabd674e9, (q31_t)0x606c8ec5, (q31_t)0xabd1b91c, + (q31_t)0x60686ccf, (q31_t)0xabccfd83, (q31_t)0x60644a9d, (q31_t)0xabc8421d, + (q31_t)0x6060282f, (q31_t)0xabc386ec, (q31_t)0x605c0587, (q31_t)0xabbecbee, + (q31_t)0x6057e2a2, (q31_t)0xabba1125, (q31_t)0x6053bf82, (q31_t)0xabb5568f, + (q31_t)0x604f9c27, (q31_t)0xabb09c2e, (q31_t)0x604b7891, (q31_t)0xababe200, + (q31_t)0x604754bf, (q31_t)0xaba72807, (q31_t)0x604330b1, (q31_t)0xaba26e41, + (q31_t)0x603f0c69, (q31_t)0xab9db4b0, (q31_t)0x603ae7e5, (q31_t)0xab98fb52, + (q31_t)0x6036c325, (q31_t)0xab944229, (q31_t)0x60329e2a, (q31_t)0xab8f8934, + (q31_t)0x602e78f4, (q31_t)0xab8ad073, (q31_t)0x602a5383, (q31_t)0xab8617e6, + (q31_t)0x60262dd6, (q31_t)0xab815f8d, (q31_t)0x602207ee, (q31_t)0xab7ca768, + (q31_t)0x601de1ca, (q31_t)0xab77ef77, (q31_t)0x6019bb6b, (q31_t)0xab7337bb, + (q31_t)0x601594d1, (q31_t)0xab6e8032, (q31_t)0x60116dfc, (q31_t)0xab69c8de, + (q31_t)0x600d46ec, (q31_t)0xab6511be, (q31_t)0x60091fa0, (q31_t)0xab605ad2, + (q31_t)0x6004f819, (q31_t)0xab5ba41a, (q31_t)0x6000d057, (q31_t)0xab56ed97, + (q31_t)0x5ffca859, (q31_t)0xab523748, (q31_t)0x5ff88021, (q31_t)0xab4d812d, + (q31_t)0x5ff457ad, (q31_t)0xab48cb46, (q31_t)0x5ff02efe, (q31_t)0xab441593, + (q31_t)0x5fec0613, (q31_t)0xab3f6015, (q31_t)0x5fe7dcee, (q31_t)0xab3aaacb, + (q31_t)0x5fe3b38d, (q31_t)0xab35f5b5, (q31_t)0x5fdf89f2, (q31_t)0xab3140d4, + (q31_t)0x5fdb601b, (q31_t)0xab2c8c27, (q31_t)0x5fd73609, (q31_t)0xab27d7ae, + (q31_t)0x5fd30bbc, (q31_t)0xab23236a, (q31_t)0x5fcee133, (q31_t)0xab1e6f5a, + (q31_t)0x5fcab670, (q31_t)0xab19bb7e, (q31_t)0x5fc68b72, (q31_t)0xab1507d7, + (q31_t)0x5fc26038, (q31_t)0xab105464, (q31_t)0x5fbe34c4, (q31_t)0xab0ba125, + (q31_t)0x5fba0914, (q31_t)0xab06ee1b, (q31_t)0x5fb5dd29, (q31_t)0xab023b46, + (q31_t)0x5fb1b104, (q31_t)0xaafd88a4, (q31_t)0x5fad84a3, (q31_t)0xaaf8d637, + (q31_t)0x5fa95807, (q31_t)0xaaf423ff, (q31_t)0x5fa52b31, (q31_t)0xaaef71fb, + (q31_t)0x5fa0fe1f, (q31_t)0xaaeac02c, (q31_t)0x5f9cd0d2, (q31_t)0xaae60e91, + (q31_t)0x5f98a34a, (q31_t)0xaae15d2a, (q31_t)0x5f947588, (q31_t)0xaadcabf8, + (q31_t)0x5f90478a, (q31_t)0xaad7fafb, (q31_t)0x5f8c1951, (q31_t)0xaad34a32, + (q31_t)0x5f87eade, (q31_t)0xaace999d, (q31_t)0x5f83bc2f, (q31_t)0xaac9e93e, + (q31_t)0x5f7f8d46, (q31_t)0xaac53912, (q31_t)0x5f7b5e22, (q31_t)0xaac0891c, + (q31_t)0x5f772ec2, (q31_t)0xaabbd959, (q31_t)0x5f72ff28, (q31_t)0xaab729cc, + (q31_t)0x5f6ecf53, (q31_t)0xaab27a73, (q31_t)0x5f6a9f44, (q31_t)0xaaadcb4f, + (q31_t)0x5f666ef9, (q31_t)0xaaa91c5f, (q31_t)0x5f623e73, (q31_t)0xaaa46da4, + (q31_t)0x5f5e0db3, (q31_t)0xaa9fbf1e, (q31_t)0x5f59dcb8, (q31_t)0xaa9b10cc, + (q31_t)0x5f55ab82, (q31_t)0xaa9662af, (q31_t)0x5f517a11, (q31_t)0xaa91b4c7, + (q31_t)0x5f4d4865, (q31_t)0xaa8d0713, (q31_t)0x5f49167f, (q31_t)0xaa885994, + (q31_t)0x5f44e45e, (q31_t)0xaa83ac4a, (q31_t)0x5f40b202, (q31_t)0xaa7eff34, + (q31_t)0x5f3c7f6b, (q31_t)0xaa7a5253, (q31_t)0x5f384c9a, (q31_t)0xaa75a5a8, + (q31_t)0x5f34198e, (q31_t)0xaa70f930, (q31_t)0x5f2fe647, (q31_t)0xaa6c4cee, + (q31_t)0x5f2bb2c5, (q31_t)0xaa67a0e0, (q31_t)0x5f277f09, (q31_t)0xaa62f507, + (q31_t)0x5f234b12, (q31_t)0xaa5e4963, (q31_t)0x5f1f16e0, (q31_t)0xaa599df4, + (q31_t)0x5f1ae274, (q31_t)0xaa54f2ba, (q31_t)0x5f16adcc, (q31_t)0xaa5047b4, + (q31_t)0x5f1278eb, (q31_t)0xaa4b9ce3, (q31_t)0x5f0e43ce, (q31_t)0xaa46f248, + (q31_t)0x5f0a0e77, (q31_t)0xaa4247e1, (q31_t)0x5f05d8e6, (q31_t)0xaa3d9daf, + (q31_t)0x5f01a31a, (q31_t)0xaa38f3b1, (q31_t)0x5efd6d13, (q31_t)0xaa3449e9, + (q31_t)0x5ef936d1, (q31_t)0xaa2fa056, (q31_t)0x5ef50055, (q31_t)0xaa2af6f7, + (q31_t)0x5ef0c99f, (q31_t)0xaa264dce, (q31_t)0x5eec92ae, (q31_t)0xaa21a4d9, + (q31_t)0x5ee85b82, (q31_t)0xaa1cfc1a, (q31_t)0x5ee4241c, (q31_t)0xaa18538f, + (q31_t)0x5edfec7b, (q31_t)0xaa13ab3a, (q31_t)0x5edbb49f, (q31_t)0xaa0f0319, + (q31_t)0x5ed77c8a, (q31_t)0xaa0a5b2e, (q31_t)0x5ed34439, (q31_t)0xaa05b377, + (q31_t)0x5ecf0baf, (q31_t)0xaa010bf6, (q31_t)0x5ecad2e9, (q31_t)0xa9fc64a9, + (q31_t)0x5ec699e9, (q31_t)0xa9f7bd92, (q31_t)0x5ec260af, (q31_t)0xa9f316b0, + (q31_t)0x5ebe273b, (q31_t)0xa9ee7002, (q31_t)0x5eb9ed8b, (q31_t)0xa9e9c98a, + (q31_t)0x5eb5b3a2, (q31_t)0xa9e52347, (q31_t)0x5eb1797e, (q31_t)0xa9e07d39, + (q31_t)0x5ead3f1f, (q31_t)0xa9dbd761, (q31_t)0x5ea90487, (q31_t)0xa9d731bd, + (q31_t)0x5ea4c9b3, (q31_t)0xa9d28c4e, (q31_t)0x5ea08ea6, (q31_t)0xa9cde715, + (q31_t)0x5e9c535e, (q31_t)0xa9c94211, (q31_t)0x5e9817dc, (q31_t)0xa9c49d42, + (q31_t)0x5e93dc1f, (q31_t)0xa9bff8a8, (q31_t)0x5e8fa028, (q31_t)0xa9bb5444, + (q31_t)0x5e8b63f7, (q31_t)0xa9b6b014, (q31_t)0x5e87278b, (q31_t)0xa9b20c1a, + (q31_t)0x5e82eae5, (q31_t)0xa9ad6855, (q31_t)0x5e7eae05, (q31_t)0xa9a8c4c5, + (q31_t)0x5e7a70ea, (q31_t)0xa9a4216b, (q31_t)0x5e763395, (q31_t)0xa99f7e46, + (q31_t)0x5e71f606, (q31_t)0xa99adb56, (q31_t)0x5e6db83d, (q31_t)0xa996389b, + (q31_t)0x5e697a39, (q31_t)0xa9919616, (q31_t)0x5e653bfc, (q31_t)0xa98cf3c6, + (q31_t)0x5e60fd84, (q31_t)0xa98851ac, (q31_t)0x5e5cbed1, (q31_t)0xa983afc6, + (q31_t)0x5e587fe5, (q31_t)0xa97f0e16, (q31_t)0x5e5440be, (q31_t)0xa97a6c9c, + (q31_t)0x5e50015d, (q31_t)0xa975cb57, (q31_t)0x5e4bc1c2, (q31_t)0xa9712a47, + (q31_t)0x5e4781ed, (q31_t)0xa96c896c, (q31_t)0x5e4341de, (q31_t)0xa967e8c7, + (q31_t)0x5e3f0194, (q31_t)0xa9634858, (q31_t)0x5e3ac110, (q31_t)0xa95ea81d, + (q31_t)0x5e368053, (q31_t)0xa95a0819, (q31_t)0x5e323f5b, (q31_t)0xa9556849, + (q31_t)0x5e2dfe29, (q31_t)0xa950c8b0, (q31_t)0x5e29bcbd, (q31_t)0xa94c294b, + (q31_t)0x5e257b17, (q31_t)0xa9478a1c, (q31_t)0x5e213936, (q31_t)0xa942eb23, + (q31_t)0x5e1cf71c, (q31_t)0xa93e4c5f, (q31_t)0x5e18b4c8, (q31_t)0xa939add1, + (q31_t)0x5e147239, (q31_t)0xa9350f78, (q31_t)0x5e102f71, (q31_t)0xa9307155, + (q31_t)0x5e0bec6e, (q31_t)0xa92bd367, (q31_t)0x5e07a932, (q31_t)0xa92735af, + (q31_t)0x5e0365bb, (q31_t)0xa922982c, (q31_t)0x5dff220b, (q31_t)0xa91dfadf, + (q31_t)0x5dfade20, (q31_t)0xa9195dc7, (q31_t)0x5df699fc, (q31_t)0xa914c0e6, + (q31_t)0x5df2559e, (q31_t)0xa9102439, (q31_t)0x5dee1105, (q31_t)0xa90b87c3, + (q31_t)0x5de9cc33, (q31_t)0xa906eb82, (q31_t)0x5de58727, (q31_t)0xa9024f76, + (q31_t)0x5de141e1, (q31_t)0xa8fdb3a1, (q31_t)0x5ddcfc61, (q31_t)0xa8f91801, + (q31_t)0x5dd8b6a7, (q31_t)0xa8f47c97, (q31_t)0x5dd470b3, (q31_t)0xa8efe162, + (q31_t)0x5dd02a85, (q31_t)0xa8eb4663, (q31_t)0x5dcbe41d, (q31_t)0xa8e6ab9a, + (q31_t)0x5dc79d7c, (q31_t)0xa8e21106, (q31_t)0x5dc356a1, (q31_t)0xa8dd76a9, + (q31_t)0x5dbf0f8c, (q31_t)0xa8d8dc81, (q31_t)0x5dbac83d, (q31_t)0xa8d4428f, + (q31_t)0x5db680b4, (q31_t)0xa8cfa8d2, (q31_t)0x5db238f1, (q31_t)0xa8cb0f4b, + (q31_t)0x5dadf0f5, (q31_t)0xa8c675fb, (q31_t)0x5da9a8bf, (q31_t)0xa8c1dce0, + (q31_t)0x5da5604f, (q31_t)0xa8bd43fa, (q31_t)0x5da117a5, (q31_t)0xa8b8ab4b, + (q31_t)0x5d9ccec2, (q31_t)0xa8b412d1, (q31_t)0x5d9885a5, (q31_t)0xa8af7a8e, + (q31_t)0x5d943c4e, (q31_t)0xa8aae280, (q31_t)0x5d8ff2bd, (q31_t)0xa8a64aa8, + (q31_t)0x5d8ba8f3, (q31_t)0xa8a1b306, (q31_t)0x5d875eef, (q31_t)0xa89d1b99, + (q31_t)0x5d8314b1, (q31_t)0xa8988463, (q31_t)0x5d7eca39, (q31_t)0xa893ed63, + (q31_t)0x5d7a7f88, (q31_t)0xa88f5698, (q31_t)0x5d76349d, (q31_t)0xa88ac004, + (q31_t)0x5d71e979, (q31_t)0xa88629a5, (q31_t)0x5d6d9e1b, (q31_t)0xa881937c, + (q31_t)0x5d695283, (q31_t)0xa87cfd8a, (q31_t)0x5d6506b2, (q31_t)0xa87867cd, + (q31_t)0x5d60baa7, (q31_t)0xa873d246, (q31_t)0x5d5c6e62, (q31_t)0xa86f3cf6, + (q31_t)0x5d5821e4, (q31_t)0xa86aa7db, (q31_t)0x5d53d52d, (q31_t)0xa86612f6, + (q31_t)0x5d4f883b, (q31_t)0xa8617e48, (q31_t)0x5d4b3b10, (q31_t)0xa85ce9cf, + (q31_t)0x5d46edac, (q31_t)0xa858558d, (q31_t)0x5d42a00e, (q31_t)0xa853c180, + (q31_t)0x5d3e5237, (q31_t)0xa84f2daa, (q31_t)0x5d3a0426, (q31_t)0xa84a9a0a, + (q31_t)0x5d35b5db, (q31_t)0xa84606a0, (q31_t)0x5d316757, (q31_t)0xa841736c, + (q31_t)0x5d2d189a, (q31_t)0xa83ce06e, (q31_t)0x5d28c9a3, (q31_t)0xa8384da6, + (q31_t)0x5d247a72, (q31_t)0xa833bb14, (q31_t)0x5d202b09, (q31_t)0xa82f28b9, + (q31_t)0x5d1bdb65, (q31_t)0xa82a9693, (q31_t)0x5d178b89, (q31_t)0xa82604a4, + (q31_t)0x5d133b72, (q31_t)0xa82172eb, (q31_t)0x5d0eeb23, (q31_t)0xa81ce169, + (q31_t)0x5d0a9a9a, (q31_t)0xa818501c, (q31_t)0x5d0649d7, (q31_t)0xa813bf06, + (q31_t)0x5d01f8dc, (q31_t)0xa80f2e26, (q31_t)0x5cfda7a7, (q31_t)0xa80a9d7c, + (q31_t)0x5cf95638, (q31_t)0xa8060d08, (q31_t)0x5cf50490, (q31_t)0xa8017ccb, + (q31_t)0x5cf0b2af, (q31_t)0xa7fcecc4, (q31_t)0x5cec6095, (q31_t)0xa7f85cf3, + (q31_t)0x5ce80e41, (q31_t)0xa7f3cd59, (q31_t)0x5ce3bbb4, (q31_t)0xa7ef3df5, + (q31_t)0x5cdf68ed, (q31_t)0xa7eaaec7, (q31_t)0x5cdb15ed, (q31_t)0xa7e61fd0, + (q31_t)0x5cd6c2b5, (q31_t)0xa7e1910f, (q31_t)0x5cd26f42, (q31_t)0xa7dd0284, + (q31_t)0x5cce1b97, (q31_t)0xa7d8742f, (q31_t)0x5cc9c7b2, (q31_t)0xa7d3e611, + (q31_t)0x5cc57394, (q31_t)0xa7cf582a, (q31_t)0x5cc11f3d, (q31_t)0xa7caca79, + (q31_t)0x5cbccaac, (q31_t)0xa7c63cfe, (q31_t)0x5cb875e3, (q31_t)0xa7c1afb9, + (q31_t)0x5cb420e0, (q31_t)0xa7bd22ac, (q31_t)0x5cafcba4, (q31_t)0xa7b895d4, + (q31_t)0x5cab762f, (q31_t)0xa7b40933, (q31_t)0x5ca72080, (q31_t)0xa7af7cc8, + (q31_t)0x5ca2ca99, (q31_t)0xa7aaf094, (q31_t)0x5c9e7478, (q31_t)0xa7a66497, + (q31_t)0x5c9a1e1e, (q31_t)0xa7a1d8d0, (q31_t)0x5c95c78b, (q31_t)0xa79d4d3f, + (q31_t)0x5c9170bf, (q31_t)0xa798c1e5, (q31_t)0x5c8d19ba, (q31_t)0xa79436c1, + (q31_t)0x5c88c27c, (q31_t)0xa78fabd4, (q31_t)0x5c846b05, (q31_t)0xa78b211e, + (q31_t)0x5c801354, (q31_t)0xa786969e, (q31_t)0x5c7bbb6b, (q31_t)0xa7820c55, + (q31_t)0x5c776348, (q31_t)0xa77d8242, (q31_t)0x5c730aed, (q31_t)0xa778f866, + (q31_t)0x5c6eb258, (q31_t)0xa7746ec0, (q31_t)0x5c6a598b, (q31_t)0xa76fe551, + (q31_t)0x5c660084, (q31_t)0xa76b5c19, (q31_t)0x5c61a745, (q31_t)0xa766d317, + (q31_t)0x5c5d4dcc, (q31_t)0xa7624a4d, (q31_t)0x5c58f41a, (q31_t)0xa75dc1b8, + (q31_t)0x5c549a30, (q31_t)0xa759395b, (q31_t)0x5c50400d, (q31_t)0xa754b134, + (q31_t)0x5c4be5b0, (q31_t)0xa7502943, (q31_t)0x5c478b1b, (q31_t)0xa74ba18a, + (q31_t)0x5c43304d, (q31_t)0xa7471a07, (q31_t)0x5c3ed545, (q31_t)0xa74292bb, + (q31_t)0x5c3a7a05, (q31_t)0xa73e0ba5, (q31_t)0x5c361e8c, (q31_t)0xa73984c7, + (q31_t)0x5c31c2db, (q31_t)0xa734fe1f, (q31_t)0x5c2d66f0, (q31_t)0xa73077ae, + (q31_t)0x5c290acc, (q31_t)0xa72bf174, (q31_t)0x5c24ae70, (q31_t)0xa7276b70, + (q31_t)0x5c2051db, (q31_t)0xa722e5a3, (q31_t)0x5c1bf50d, (q31_t)0xa71e600d, + (q31_t)0x5c179806, (q31_t)0xa719daae, (q31_t)0x5c133ac6, (q31_t)0xa7155586, + (q31_t)0x5c0edd4e, (q31_t)0xa710d095, (q31_t)0x5c0a7f9c, (q31_t)0xa70c4bda, + (q31_t)0x5c0621b2, (q31_t)0xa707c757, (q31_t)0x5c01c38f, (q31_t)0xa703430a, + (q31_t)0x5bfd6534, (q31_t)0xa6febef4, (q31_t)0x5bf906a0, (q31_t)0xa6fa3b15, + (q31_t)0x5bf4a7d2, (q31_t)0xa6f5b76d, (q31_t)0x5bf048cd, (q31_t)0xa6f133fc, + (q31_t)0x5bebe98e, (q31_t)0xa6ecb0c2, (q31_t)0x5be78a17, (q31_t)0xa6e82dbe, + (q31_t)0x5be32a67, (q31_t)0xa6e3aaf2, (q31_t)0x5bdeca7f, (q31_t)0xa6df285d, + (q31_t)0x5bda6a5d, (q31_t)0xa6daa5fe, (q31_t)0x5bd60a03, (q31_t)0xa6d623d7, + (q31_t)0x5bd1a971, (q31_t)0xa6d1a1e7, (q31_t)0x5bcd48a6, (q31_t)0xa6cd202d, + (q31_t)0x5bc8e7a2, (q31_t)0xa6c89eab, (q31_t)0x5bc48666, (q31_t)0xa6c41d60, + (q31_t)0x5bc024f0, (q31_t)0xa6bf9c4b, (q31_t)0x5bbbc343, (q31_t)0xa6bb1b6e, + (q31_t)0x5bb7615d, (q31_t)0xa6b69ac8, (q31_t)0x5bb2ff3e, (q31_t)0xa6b21a59, + (q31_t)0x5bae9ce7, (q31_t)0xa6ad9a21, (q31_t)0x5baa3a57, (q31_t)0xa6a91a20, + (q31_t)0x5ba5d78e, (q31_t)0xa6a49a56, (q31_t)0x5ba1748d, (q31_t)0xa6a01ac4, + (q31_t)0x5b9d1154, (q31_t)0xa69b9b68, (q31_t)0x5b98ade2, (q31_t)0xa6971c44, + (q31_t)0x5b944a37, (q31_t)0xa6929d57, (q31_t)0x5b8fe654, (q31_t)0xa68e1ea1, + (q31_t)0x5b8b8239, (q31_t)0xa689a022, (q31_t)0x5b871de5, (q31_t)0xa68521da, + (q31_t)0x5b82b958, (q31_t)0xa680a3ca, (q31_t)0x5b7e5493, (q31_t)0xa67c25f0, + (q31_t)0x5b79ef96, (q31_t)0xa677a84e, (q31_t)0x5b758a60, (q31_t)0xa6732ae3, + (q31_t)0x5b7124f2, (q31_t)0xa66eadb0, (q31_t)0x5b6cbf4c, (q31_t)0xa66a30b3, + (q31_t)0x5b68596d, (q31_t)0xa665b3ee, (q31_t)0x5b63f355, (q31_t)0xa6613760, + (q31_t)0x5b5f8d06, (q31_t)0xa65cbb0a, (q31_t)0x5b5b267e, (q31_t)0xa6583eeb, + (q31_t)0x5b56bfbd, (q31_t)0xa653c303, (q31_t)0x5b5258c4, (q31_t)0xa64f4752, + (q31_t)0x5b4df193, (q31_t)0xa64acbd9, (q31_t)0x5b498a2a, (q31_t)0xa6465097, + (q31_t)0x5b452288, (q31_t)0xa641d58c, (q31_t)0x5b40baae, (q31_t)0xa63d5ab9, + (q31_t)0x5b3c529c, (q31_t)0xa638e01d, (q31_t)0x5b37ea51, (q31_t)0xa63465b9, + (q31_t)0x5b3381ce, (q31_t)0xa62feb8b, (q31_t)0x5b2f1913, (q31_t)0xa62b7196, + (q31_t)0x5b2ab020, (q31_t)0xa626f7d7, (q31_t)0x5b2646f4, (q31_t)0xa6227e50, + (q31_t)0x5b21dd90, (q31_t)0xa61e0501, (q31_t)0x5b1d73f4, (q31_t)0xa6198be9, + (q31_t)0x5b190a20, (q31_t)0xa6151308, (q31_t)0x5b14a014, (q31_t)0xa6109a5f, + (q31_t)0x5b1035cf, (q31_t)0xa60c21ee, (q31_t)0x5b0bcb52, (q31_t)0xa607a9b4, + (q31_t)0x5b07609d, (q31_t)0xa60331b1, (q31_t)0x5b02f5b0, (q31_t)0xa5feb9e6, + (q31_t)0x5afe8a8b, (q31_t)0xa5fa4252, (q31_t)0x5afa1f2e, (q31_t)0xa5f5caf6, + (q31_t)0x5af5b398, (q31_t)0xa5f153d2, (q31_t)0x5af147ca, (q31_t)0xa5ecdce5, + (q31_t)0x5aecdbc5, (q31_t)0xa5e8662f, (q31_t)0x5ae86f87, (q31_t)0xa5e3efb1, + (q31_t)0x5ae40311, (q31_t)0xa5df796b, (q31_t)0x5adf9663, (q31_t)0xa5db035c, + (q31_t)0x5adb297d, (q31_t)0xa5d68d85, (q31_t)0x5ad6bc5f, (q31_t)0xa5d217e6, + (q31_t)0x5ad24f09, (q31_t)0xa5cda27e, (q31_t)0x5acde17b, (q31_t)0xa5c92d4e, + (q31_t)0x5ac973b5, (q31_t)0xa5c4b855, (q31_t)0x5ac505b7, (q31_t)0xa5c04395, + (q31_t)0x5ac09781, (q31_t)0xa5bbcf0b, (q31_t)0x5abc2912, (q31_t)0xa5b75aba, + (q31_t)0x5ab7ba6c, (q31_t)0xa5b2e6a0, (q31_t)0x5ab34b8e, (q31_t)0xa5ae72be, + (q31_t)0x5aaedc78, (q31_t)0xa5a9ff14, (q31_t)0x5aaa6d2b, (q31_t)0xa5a58ba1, + (q31_t)0x5aa5fda5, (q31_t)0xa5a11866, (q31_t)0x5aa18de7, (q31_t)0xa59ca563, + (q31_t)0x5a9d1df1, (q31_t)0xa5983297, (q31_t)0x5a98adc4, (q31_t)0xa593c004, + (q31_t)0x5a943d5e, (q31_t)0xa58f4da8, (q31_t)0x5a8fccc1, (q31_t)0xa58adb84, + (q31_t)0x5a8b5bec, (q31_t)0xa5866997, (q31_t)0x5a86eadf, (q31_t)0xa581f7e3, + (q31_t)0x5a82799a, (q31_t)0xa57d8666, (q31_t)0x5a7e081d, (q31_t)0xa5791521, + (q31_t)0x5a799669, (q31_t)0xa574a414, (q31_t)0x5a75247c, (q31_t)0xa570333f, + (q31_t)0x5a70b258, (q31_t)0xa56bc2a2, (q31_t)0x5a6c3ffc, (q31_t)0xa567523c, + (q31_t)0x5a67cd69, (q31_t)0xa562e20f, (q31_t)0x5a635a9d, (q31_t)0xa55e7219, + (q31_t)0x5a5ee79a, (q31_t)0xa55a025b, (q31_t)0x5a5a745f, (q31_t)0xa55592d5, + (q31_t)0x5a5600ec, (q31_t)0xa5512388, (q31_t)0x5a518d42, (q31_t)0xa54cb472, + (q31_t)0x5a4d1960, (q31_t)0xa5484594, (q31_t)0x5a48a546, (q31_t)0xa543d6ee, + (q31_t)0x5a4430f5, (q31_t)0xa53f687f, (q31_t)0x5a3fbc6b, (q31_t)0xa53afa49, + (q31_t)0x5a3b47ab, (q31_t)0xa5368c4b, (q31_t)0x5a36d2b2, (q31_t)0xa5321e85, + (q31_t)0x5a325d82, (q31_t)0xa52db0f7, (q31_t)0x5a2de81a, (q31_t)0xa52943a1, + (q31_t)0x5a29727b, (q31_t)0xa524d683, (q31_t)0x5a24fca4, (q31_t)0xa520699d, + (q31_t)0x5a208695, (q31_t)0xa51bfcef, (q31_t)0x5a1c104f, (q31_t)0xa5179079, + (q31_t)0x5a1799d1, (q31_t)0xa513243b, (q31_t)0x5a13231b, (q31_t)0xa50eb836, + (q31_t)0x5a0eac2e, (q31_t)0xa50a4c68, (q31_t)0x5a0a350a, (q31_t)0xa505e0d2, + (q31_t)0x5a05bdae, (q31_t)0xa5017575, (q31_t)0x5a01461a, (q31_t)0xa4fd0a50, + (q31_t)0x59fcce4f, (q31_t)0xa4f89f63, (q31_t)0x59f8564c, (q31_t)0xa4f434ae, + (q31_t)0x59f3de12, (q31_t)0xa4efca31, (q31_t)0x59ef65a1, (q31_t)0xa4eb5fec, + (q31_t)0x59eaecf8, (q31_t)0xa4e6f5e0, (q31_t)0x59e67417, (q31_t)0xa4e28c0c, + (q31_t)0x59e1faff, (q31_t)0xa4de2270, (q31_t)0x59dd81b0, (q31_t)0xa4d9b90c, + (q31_t)0x59d90829, (q31_t)0xa4d54fe0, (q31_t)0x59d48e6a, (q31_t)0xa4d0e6ed, + (q31_t)0x59d01475, (q31_t)0xa4cc7e32, (q31_t)0x59cb9a47, (q31_t)0xa4c815af, + (q31_t)0x59c71fe3, (q31_t)0xa4c3ad64, (q31_t)0x59c2a547, (q31_t)0xa4bf4552, + (q31_t)0x59be2a74, (q31_t)0xa4badd78, (q31_t)0x59b9af69, (q31_t)0xa4b675d6, + (q31_t)0x59b53427, (q31_t)0xa4b20e6d, (q31_t)0x59b0b8ae, (q31_t)0xa4ada73c, + (q31_t)0x59ac3cfd, (q31_t)0xa4a94043, (q31_t)0x59a7c115, (q31_t)0xa4a4d982, + (q31_t)0x59a344f6, (q31_t)0xa4a072fa, (q31_t)0x599ec8a0, (q31_t)0xa49c0cab, + (q31_t)0x599a4c12, (q31_t)0xa497a693, (q31_t)0x5995cf4d, (q31_t)0xa49340b4, + (q31_t)0x59915250, (q31_t)0xa48edb0e, (q31_t)0x598cd51d, (q31_t)0xa48a75a0, + (q31_t)0x598857b2, (q31_t)0xa486106a, (q31_t)0x5983da10, (q31_t)0xa481ab6d, + (q31_t)0x597f5c36, (q31_t)0xa47d46a8, (q31_t)0x597ade26, (q31_t)0xa478e21b, + (q31_t)0x59765fde, (q31_t)0xa4747dc7, (q31_t)0x5971e15f, (q31_t)0xa47019ac, + (q31_t)0x596d62a9, (q31_t)0xa46bb5c9, (q31_t)0x5968e3bc, (q31_t)0xa467521e, + (q31_t)0x59646498, (q31_t)0xa462eeac, (q31_t)0x595fe53c, (q31_t)0xa45e8b73, + (q31_t)0x595b65aa, (q31_t)0xa45a2872, (q31_t)0x5956e5e0, (q31_t)0xa455c5a9, + (q31_t)0x595265df, (q31_t)0xa4516319, (q31_t)0x594de5a7, (q31_t)0xa44d00c2, + (q31_t)0x59496538, (q31_t)0xa4489ea3, (q31_t)0x5944e492, (q31_t)0xa4443cbd, + (q31_t)0x594063b5, (q31_t)0xa43fdb10, (q31_t)0x593be2a0, (q31_t)0xa43b799a, + (q31_t)0x59376155, (q31_t)0xa437185e, (q31_t)0x5932dfd3, (q31_t)0xa432b75a, + (q31_t)0x592e5e19, (q31_t)0xa42e568f, (q31_t)0x5929dc29, (q31_t)0xa429f5fd, + (q31_t)0x59255a02, (q31_t)0xa42595a3, (q31_t)0x5920d7a3, (q31_t)0xa4213581, + (q31_t)0x591c550e, (q31_t)0xa41cd599, (q31_t)0x5917d242, (q31_t)0xa41875e9, + (q31_t)0x59134f3e, (q31_t)0xa4141672, (q31_t)0x590ecc04, (q31_t)0xa40fb733, + (q31_t)0x590a4893, (q31_t)0xa40b582e, (q31_t)0x5905c4eb, (q31_t)0xa406f960, + (q31_t)0x5901410c, (q31_t)0xa4029acc, (q31_t)0x58fcbcf6, (q31_t)0xa3fe3c71, + (q31_t)0x58f838a9, (q31_t)0xa3f9de4e, (q31_t)0x58f3b426, (q31_t)0xa3f58064, + (q31_t)0x58ef2f6b, (q31_t)0xa3f122b2, (q31_t)0x58eaaa7a, (q31_t)0xa3ecc53a, + (q31_t)0x58e62552, (q31_t)0xa3e867fa, (q31_t)0x58e19ff3, (q31_t)0xa3e40af3, + (q31_t)0x58dd1a5d, (q31_t)0xa3dfae25, (q31_t)0x58d89490, (q31_t)0xa3db5190, + (q31_t)0x58d40e8c, (q31_t)0xa3d6f534, (q31_t)0x58cf8852, (q31_t)0xa3d29910, + (q31_t)0x58cb01e1, (q31_t)0xa3ce3d25, (q31_t)0x58c67b39, (q31_t)0xa3c9e174, + (q31_t)0x58c1f45b, (q31_t)0xa3c585fb, (q31_t)0x58bd6d45, (q31_t)0xa3c12abb, + (q31_t)0x58b8e5f9, (q31_t)0xa3bccfb3, (q31_t)0x58b45e76, (q31_t)0xa3b874e5, + (q31_t)0x58afd6bd, (q31_t)0xa3b41a50, (q31_t)0x58ab4ecc, (q31_t)0xa3afbff3, + (q31_t)0x58a6c6a5, (q31_t)0xa3ab65d0, (q31_t)0x58a23e48, (q31_t)0xa3a70be6, + (q31_t)0x589db5b3, (q31_t)0xa3a2b234, (q31_t)0x58992ce9, (q31_t)0xa39e58bb, + (q31_t)0x5894a3e7, (q31_t)0xa399ff7c, (q31_t)0x58901aaf, (q31_t)0xa395a675, + (q31_t)0x588b9140, (q31_t)0xa3914da8, (q31_t)0x5887079a, (q31_t)0xa38cf513, + (q31_t)0x58827dbe, (q31_t)0xa3889cb8, (q31_t)0x587df3ab, (q31_t)0xa3844495, + (q31_t)0x58796962, (q31_t)0xa37fecac, (q31_t)0x5874dee2, (q31_t)0xa37b94fb, + (q31_t)0x5870542c, (q31_t)0xa3773d84, (q31_t)0x586bc93f, (q31_t)0xa372e646, + (q31_t)0x58673e1b, (q31_t)0xa36e8f41, (q31_t)0x5862b2c1, (q31_t)0xa36a3875, + (q31_t)0x585e2730, (q31_t)0xa365e1e2, (q31_t)0x58599b69, (q31_t)0xa3618b88, + (q31_t)0x58550f6c, (q31_t)0xa35d3567, (q31_t)0x58508338, (q31_t)0xa358df80, + (q31_t)0x584bf6cd, (q31_t)0xa35489d1, (q31_t)0x58476a2c, (q31_t)0xa350345c, + (q31_t)0x5842dd54, (q31_t)0xa34bdf20, (q31_t)0x583e5047, (q31_t)0xa3478a1d, + (q31_t)0x5839c302, (q31_t)0xa3433554, (q31_t)0x58353587, (q31_t)0xa33ee0c3, + (q31_t)0x5830a7d6, (q31_t)0xa33a8c6c, (q31_t)0x582c19ef, (q31_t)0xa336384e, + (q31_t)0x58278bd1, (q31_t)0xa331e469, (q31_t)0x5822fd7c, (q31_t)0xa32d90be, + (q31_t)0x581e6ef1, (q31_t)0xa3293d4b, (q31_t)0x5819e030, (q31_t)0xa324ea13, + (q31_t)0x58155139, (q31_t)0xa3209713, (q31_t)0x5810c20b, (q31_t)0xa31c444c, + (q31_t)0x580c32a7, (q31_t)0xa317f1bf, (q31_t)0x5807a30d, (q31_t)0xa3139f6b, + (q31_t)0x5803133c, (q31_t)0xa30f4d51, (q31_t)0x57fe8335, (q31_t)0xa30afb70, + (q31_t)0x57f9f2f8, (q31_t)0xa306a9c8, (q31_t)0x57f56284, (q31_t)0xa3025859, + (q31_t)0x57f0d1da, (q31_t)0xa2fe0724, (q31_t)0x57ec40fa, (q31_t)0xa2f9b629, + (q31_t)0x57e7afe4, (q31_t)0xa2f56566, (q31_t)0x57e31e97, (q31_t)0xa2f114dd, + (q31_t)0x57de8d15, (q31_t)0xa2ecc48e, (q31_t)0x57d9fb5c, (q31_t)0xa2e87477, + (q31_t)0x57d5696d, (q31_t)0xa2e4249b, (q31_t)0x57d0d747, (q31_t)0xa2dfd4f7, + (q31_t)0x57cc44ec, (q31_t)0xa2db858e, (q31_t)0x57c7b25a, (q31_t)0xa2d7365d, + (q31_t)0x57c31f92, (q31_t)0xa2d2e766, (q31_t)0x57be8c94, (q31_t)0xa2ce98a9, + (q31_t)0x57b9f960, (q31_t)0xa2ca4a25, (q31_t)0x57b565f6, (q31_t)0xa2c5fbda, + (q31_t)0x57b0d256, (q31_t)0xa2c1adc9, (q31_t)0x57ac3e80, (q31_t)0xa2bd5ff2, + (q31_t)0x57a7aa73, (q31_t)0xa2b91254, (q31_t)0x57a31631, (q31_t)0xa2b4c4f0, + (q31_t)0x579e81b8, (q31_t)0xa2b077c5, (q31_t)0x5799ed0a, (q31_t)0xa2ac2ad3, + (q31_t)0x57955825, (q31_t)0xa2a7de1c, (q31_t)0x5790c30a, (q31_t)0xa2a3919e, + (q31_t)0x578c2dba, (q31_t)0xa29f4559, (q31_t)0x57879833, (q31_t)0xa29af94e, + (q31_t)0x57830276, (q31_t)0xa296ad7d, (q31_t)0x577e6c84, (q31_t)0xa29261e5, + (q31_t)0x5779d65b, (q31_t)0xa28e1687, (q31_t)0x57753ffc, (q31_t)0xa289cb63, + (q31_t)0x5770a968, (q31_t)0xa2858078, (q31_t)0x576c129d, (q31_t)0xa28135c7, + (q31_t)0x57677b9d, (q31_t)0xa27ceb4f, (q31_t)0x5762e467, (q31_t)0xa278a111, + (q31_t)0x575e4cfa, (q31_t)0xa274570d, (q31_t)0x5759b558, (q31_t)0xa2700d43, + (q31_t)0x57551d80, (q31_t)0xa26bc3b2, (q31_t)0x57508572, (q31_t)0xa2677a5b, + (q31_t)0x574bed2f, (q31_t)0xa263313e, (q31_t)0x574754b5, (q31_t)0xa25ee85b, + (q31_t)0x5742bc06, (q31_t)0xa25a9fb1, (q31_t)0x573e2320, (q31_t)0xa2565741, + (q31_t)0x57398a05, (q31_t)0xa2520f0b, (q31_t)0x5734f0b5, (q31_t)0xa24dc70f, + (q31_t)0x5730572e, (q31_t)0xa2497f4c, (q31_t)0x572bbd71, (q31_t)0xa24537c3, + (q31_t)0x5727237f, (q31_t)0xa240f074, (q31_t)0x57228957, (q31_t)0xa23ca95f, + (q31_t)0x571deefa, (q31_t)0xa2386284, (q31_t)0x57195466, (q31_t)0xa2341be3, + (q31_t)0x5714b99d, (q31_t)0xa22fd57b, (q31_t)0x57101e9e, (q31_t)0xa22b8f4d, + (q31_t)0x570b8369, (q31_t)0xa2274959, (q31_t)0x5706e7ff, (q31_t)0xa223039f, + (q31_t)0x57024c5f, (q31_t)0xa21ebe1f, (q31_t)0x56fdb08a, (q31_t)0xa21a78d9, + (q31_t)0x56f9147e, (q31_t)0xa21633cd, (q31_t)0x56f4783d, (q31_t)0xa211eefb, + (q31_t)0x56efdbc7, (q31_t)0xa20daa62, (q31_t)0x56eb3f1a, (q31_t)0xa2096604, + (q31_t)0x56e6a239, (q31_t)0xa20521e0, (q31_t)0x56e20521, (q31_t)0xa200ddf5, + (q31_t)0x56dd67d4, (q31_t)0xa1fc9a45, (q31_t)0x56d8ca51, (q31_t)0xa1f856ce, + (q31_t)0x56d42c99, (q31_t)0xa1f41392, (q31_t)0x56cf8eab, (q31_t)0xa1efd08f, + (q31_t)0x56caf088, (q31_t)0xa1eb8dc7, (q31_t)0x56c6522f, (q31_t)0xa1e74b38, + (q31_t)0x56c1b3a1, (q31_t)0xa1e308e4, (q31_t)0x56bd14dd, (q31_t)0xa1dec6ca, + (q31_t)0x56b875e4, (q31_t)0xa1da84e9, (q31_t)0x56b3d6b5, (q31_t)0xa1d64343, + (q31_t)0x56af3750, (q31_t)0xa1d201d7, (q31_t)0x56aa97b7, (q31_t)0xa1cdc0a5, + (q31_t)0x56a5f7e7, (q31_t)0xa1c97fad, (q31_t)0x56a157e3, (q31_t)0xa1c53ef0, + (q31_t)0x569cb7a8, (q31_t)0xa1c0fe6c, (q31_t)0x56981739, (q31_t)0xa1bcbe22, + (q31_t)0x56937694, (q31_t)0xa1b87e13, (q31_t)0x568ed5b9, (q31_t)0xa1b43e3e, + (q31_t)0x568a34a9, (q31_t)0xa1affea3, (q31_t)0x56859364, (q31_t)0xa1abbf42, + (q31_t)0x5680f1ea, (q31_t)0xa1a7801b, (q31_t)0x567c503a, (q31_t)0xa1a3412f, + (q31_t)0x5677ae54, (q31_t)0xa19f027c, (q31_t)0x56730c3a, (q31_t)0xa19ac404, + (q31_t)0x566e69ea, (q31_t)0xa19685c7, (q31_t)0x5669c765, (q31_t)0xa19247c3, + (q31_t)0x566524aa, (q31_t)0xa18e09fa, (q31_t)0x566081ba, (q31_t)0xa189cc6b, + (q31_t)0x565bde95, (q31_t)0xa1858f16, (q31_t)0x56573b3b, (q31_t)0xa18151fb, + (q31_t)0x565297ab, (q31_t)0xa17d151b, (q31_t)0x564df3e6, (q31_t)0xa178d875, + (q31_t)0x56494fec, (q31_t)0xa1749c09, (q31_t)0x5644abbc, (q31_t)0xa1705fd8, + (q31_t)0x56400758, (q31_t)0xa16c23e1, (q31_t)0x563b62be, (q31_t)0xa167e824, + (q31_t)0x5636bdef, (q31_t)0xa163aca2, (q31_t)0x563218eb, (q31_t)0xa15f715a, + (q31_t)0x562d73b2, (q31_t)0xa15b364d, (q31_t)0x5628ce43, (q31_t)0xa156fb79, + (q31_t)0x5624289f, (q31_t)0xa152c0e1, (q31_t)0x561f82c7, (q31_t)0xa14e8682, + (q31_t)0x561adcb9, (q31_t)0xa14a4c5e, (q31_t)0x56163676, (q31_t)0xa1461275, + (q31_t)0x56118ffe, (q31_t)0xa141d8c5, (q31_t)0x560ce950, (q31_t)0xa13d9f51, + (q31_t)0x5608426e, (q31_t)0xa1396617, (q31_t)0x56039b57, (q31_t)0xa1352d17, + (q31_t)0x55fef40a, (q31_t)0xa130f451, (q31_t)0x55fa4c89, (q31_t)0xa12cbbc7, + (q31_t)0x55f5a4d2, (q31_t)0xa1288376, (q31_t)0x55f0fce7, (q31_t)0xa1244b61, + (q31_t)0x55ec54c6, (q31_t)0xa1201385, (q31_t)0x55e7ac71, (q31_t)0xa11bdbe4, + (q31_t)0x55e303e6, (q31_t)0xa117a47e, (q31_t)0x55de5b27, (q31_t)0xa1136d52, + (q31_t)0x55d9b232, (q31_t)0xa10f3661, (q31_t)0x55d50909, (q31_t)0xa10affab, + (q31_t)0x55d05faa, (q31_t)0xa106c92f, (q31_t)0x55cbb617, (q31_t)0xa10292ed, + (q31_t)0x55c70c4f, (q31_t)0xa0fe5ce6, (q31_t)0x55c26251, (q31_t)0xa0fa271a, + (q31_t)0x55bdb81f, (q31_t)0xa0f5f189, (q31_t)0x55b90db8, (q31_t)0xa0f1bc32, + (q31_t)0x55b4631d, (q31_t)0xa0ed8715, (q31_t)0x55afb84c, (q31_t)0xa0e95234, + (q31_t)0x55ab0d46, (q31_t)0xa0e51d8c, (q31_t)0x55a6620c, (q31_t)0xa0e0e920, + (q31_t)0x55a1b69d, (q31_t)0xa0dcb4ee, (q31_t)0x559d0af9, (q31_t)0xa0d880f7, + (q31_t)0x55985f20, (q31_t)0xa0d44d3b, (q31_t)0x5593b312, (q31_t)0xa0d019b9, + (q31_t)0x558f06d0, (q31_t)0xa0cbe672, (q31_t)0x558a5a58, (q31_t)0xa0c7b366, + (q31_t)0x5585adad, (q31_t)0xa0c38095, (q31_t)0x558100cc, (q31_t)0xa0bf4dfe, + (q31_t)0x557c53b6, (q31_t)0xa0bb1ba2, (q31_t)0x5577a66c, (q31_t)0xa0b6e981, + (q31_t)0x5572f8ed, (q31_t)0xa0b2b79b, (q31_t)0x556e4b39, (q31_t)0xa0ae85ef, + (q31_t)0x55699d51, (q31_t)0xa0aa547e, (q31_t)0x5564ef34, (q31_t)0xa0a62348, + (q31_t)0x556040e2, (q31_t)0xa0a1f24d, (q31_t)0x555b925c, (q31_t)0xa09dc18d, + (q31_t)0x5556e3a1, (q31_t)0xa0999107, (q31_t)0x555234b1, (q31_t)0xa09560bc, + (q31_t)0x554d858d, (q31_t)0xa09130ad, (q31_t)0x5548d634, (q31_t)0xa08d00d8, + (q31_t)0x554426a7, (q31_t)0xa088d13e, (q31_t)0x553f76e4, (q31_t)0xa084a1de, + (q31_t)0x553ac6ee, (q31_t)0xa08072ba, (q31_t)0x553616c2, (q31_t)0xa07c43d1, + (q31_t)0x55316663, (q31_t)0xa0781522, (q31_t)0x552cb5ce, (q31_t)0xa073e6af, + (q31_t)0x55280505, (q31_t)0xa06fb876, (q31_t)0x55235408, (q31_t)0xa06b8a78, + (q31_t)0x551ea2d6, (q31_t)0xa0675cb6, (q31_t)0x5519f16f, (q31_t)0xa0632f2e, + (q31_t)0x55153fd4, (q31_t)0xa05f01e1, (q31_t)0x55108e05, (q31_t)0xa05ad4cf, + (q31_t)0x550bdc01, (q31_t)0xa056a7f9, (q31_t)0x550729c9, (q31_t)0xa0527b5d, + (q31_t)0x5502775c, (q31_t)0xa04e4efc, (q31_t)0x54fdc4ba, (q31_t)0xa04a22d7, + (q31_t)0x54f911e5, (q31_t)0xa045f6ec, (q31_t)0x54f45edb, (q31_t)0xa041cb3c, + (q31_t)0x54efab9c, (q31_t)0xa03d9fc8, (q31_t)0x54eaf829, (q31_t)0xa039748e, + (q31_t)0x54e64482, (q31_t)0xa0354990, (q31_t)0x54e190a6, (q31_t)0xa0311ecd, + (q31_t)0x54dcdc96, (q31_t)0xa02cf444, (q31_t)0x54d82852, (q31_t)0xa028c9f7, + (q31_t)0x54d373d9, (q31_t)0xa0249fe5, (q31_t)0x54cebf2c, (q31_t)0xa020760e, + (q31_t)0x54ca0a4b, (q31_t)0xa01c4c73, (q31_t)0x54c55535, (q31_t)0xa0182312, + (q31_t)0x54c09feb, (q31_t)0xa013f9ed, (q31_t)0x54bbea6d, (q31_t)0xa00fd102, + (q31_t)0x54b734ba, (q31_t)0xa00ba853, (q31_t)0x54b27ed3, (q31_t)0xa0077fdf, + (q31_t)0x54adc8b8, (q31_t)0xa00357a7, (q31_t)0x54a91269, (q31_t)0x9fff2fa9, + (q31_t)0x54a45be6, (q31_t)0x9ffb07e7, (q31_t)0x549fa52e, (q31_t)0x9ff6e060, + (q31_t)0x549aee42, (q31_t)0x9ff2b914, (q31_t)0x54963722, (q31_t)0x9fee9204, + (q31_t)0x54917fce, (q31_t)0x9fea6b2f, (q31_t)0x548cc845, (q31_t)0x9fe64495, + (q31_t)0x54881089, (q31_t)0x9fe21e36, (q31_t)0x54835898, (q31_t)0x9fddf812, + (q31_t)0x547ea073, (q31_t)0x9fd9d22a, (q31_t)0x5479e81a, (q31_t)0x9fd5ac7d, + (q31_t)0x54752f8d, (q31_t)0x9fd1870c, (q31_t)0x547076cc, (q31_t)0x9fcd61d6, + (q31_t)0x546bbdd7, (q31_t)0x9fc93cdb, (q31_t)0x546704ae, (q31_t)0x9fc5181b, + (q31_t)0x54624b50, (q31_t)0x9fc0f397, (q31_t)0x545d91bf, (q31_t)0x9fbccf4f, + (q31_t)0x5458d7f9, (q31_t)0x9fb8ab41, (q31_t)0x54541e00, (q31_t)0x9fb4876f, + (q31_t)0x544f63d2, (q31_t)0x9fb063d9, (q31_t)0x544aa971, (q31_t)0x9fac407e, + (q31_t)0x5445eedb, (q31_t)0x9fa81d5e, (q31_t)0x54413412, (q31_t)0x9fa3fa79, + (q31_t)0x543c7914, (q31_t)0x9f9fd7d1, (q31_t)0x5437bde3, (q31_t)0x9f9bb563, + (q31_t)0x5433027d, (q31_t)0x9f979331, (q31_t)0x542e46e4, (q31_t)0x9f93713b, + (q31_t)0x54298b17, (q31_t)0x9f8f4f80, (q31_t)0x5424cf16, (q31_t)0x9f8b2e00, + (q31_t)0x542012e1, (q31_t)0x9f870cbc, (q31_t)0x541b5678, (q31_t)0x9f82ebb4, + (q31_t)0x541699db, (q31_t)0x9f7ecae7, (q31_t)0x5411dd0a, (q31_t)0x9f7aaa55, + (q31_t)0x540d2005, (q31_t)0x9f7689ff, (q31_t)0x540862cd, (q31_t)0x9f7269e5, + (q31_t)0x5403a561, (q31_t)0x9f6e4a06, (q31_t)0x53fee7c1, (q31_t)0x9f6a2a63, + (q31_t)0x53fa29ed, (q31_t)0x9f660afb, (q31_t)0x53f56be5, (q31_t)0x9f61ebcf, + (q31_t)0x53f0adaa, (q31_t)0x9f5dccde, (q31_t)0x53ebef3a, (q31_t)0x9f59ae29, + (q31_t)0x53e73097, (q31_t)0x9f558fb0, (q31_t)0x53e271c0, (q31_t)0x9f517173, + (q31_t)0x53ddb2b6, (q31_t)0x9f4d5371, (q31_t)0x53d8f378, (q31_t)0x9f4935aa, + (q31_t)0x53d43406, (q31_t)0x9f45181f, (q31_t)0x53cf7460, (q31_t)0x9f40fad0, + (q31_t)0x53cab486, (q31_t)0x9f3cddbd, (q31_t)0x53c5f479, (q31_t)0x9f38c0e5, + (q31_t)0x53c13439, (q31_t)0x9f34a449, (q31_t)0x53bc73c4, (q31_t)0x9f3087e9, + (q31_t)0x53b7b31c, (q31_t)0x9f2c6bc5, (q31_t)0x53b2f240, (q31_t)0x9f284fdc, + (q31_t)0x53ae3131, (q31_t)0x9f24342f, (q31_t)0x53a96fee, (q31_t)0x9f2018bd, + (q31_t)0x53a4ae77, (q31_t)0x9f1bfd88, (q31_t)0x539feccd, (q31_t)0x9f17e28e, + (q31_t)0x539b2af0, (q31_t)0x9f13c7d0, (q31_t)0x539668de, (q31_t)0x9f0fad4e, + (q31_t)0x5391a699, (q31_t)0x9f0b9307, (q31_t)0x538ce421, (q31_t)0x9f0778fd, + (q31_t)0x53882175, (q31_t)0x9f035f2e, (q31_t)0x53835e95, (q31_t)0x9eff459b, + (q31_t)0x537e9b82, (q31_t)0x9efb2c44, (q31_t)0x5379d83c, (q31_t)0x9ef71328, + (q31_t)0x537514c2, (q31_t)0x9ef2fa49, (q31_t)0x53705114, (q31_t)0x9eeee1a5, + (q31_t)0x536b8d33, (q31_t)0x9eeac93e, (q31_t)0x5366c91f, (q31_t)0x9ee6b112, + (q31_t)0x536204d7, (q31_t)0x9ee29922, (q31_t)0x535d405c, (q31_t)0x9ede816e, + (q31_t)0x53587bad, (q31_t)0x9eda69f6, (q31_t)0x5353b6cb, (q31_t)0x9ed652ba, + (q31_t)0x534ef1b5, (q31_t)0x9ed23bb9, (q31_t)0x534a2c6c, (q31_t)0x9ece24f5, + (q31_t)0x534566f0, (q31_t)0x9eca0e6d, (q31_t)0x5340a140, (q31_t)0x9ec5f820, + (q31_t)0x533bdb5d, (q31_t)0x9ec1e210, (q31_t)0x53371547, (q31_t)0x9ebdcc3b, + (q31_t)0x53324efd, (q31_t)0x9eb9b6a3, (q31_t)0x532d8880, (q31_t)0x9eb5a146, + (q31_t)0x5328c1d0, (q31_t)0x9eb18c26, (q31_t)0x5323faec, (q31_t)0x9ead7742, + (q31_t)0x531f33d5, (q31_t)0x9ea96299, (q31_t)0x531a6c8b, (q31_t)0x9ea54e2d, + (q31_t)0x5315a50e, (q31_t)0x9ea139fd, (q31_t)0x5310dd5d, (q31_t)0x9e9d2608, + (q31_t)0x530c1579, (q31_t)0x9e991250, (q31_t)0x53074d62, (q31_t)0x9e94fed4, + (q31_t)0x53028518, (q31_t)0x9e90eb94, (q31_t)0x52fdbc9a, (q31_t)0x9e8cd890, + (q31_t)0x52f8f3e9, (q31_t)0x9e88c5c9, (q31_t)0x52f42b05, (q31_t)0x9e84b33d, + (q31_t)0x52ef61ee, (q31_t)0x9e80a0ee, (q31_t)0x52ea98a4, (q31_t)0x9e7c8eda, + (q31_t)0x52e5cf27, (q31_t)0x9e787d03, (q31_t)0x52e10576, (q31_t)0x9e746b68, + (q31_t)0x52dc3b92, (q31_t)0x9e705a09, (q31_t)0x52d7717b, (q31_t)0x9e6c48e7, + (q31_t)0x52d2a732, (q31_t)0x9e683800, (q31_t)0x52cddcb5, (q31_t)0x9e642756, + (q31_t)0x52c91204, (q31_t)0x9e6016e8, (q31_t)0x52c44721, (q31_t)0x9e5c06b6, + (q31_t)0x52bf7c0b, (q31_t)0x9e57f6c0, (q31_t)0x52bab0c2, (q31_t)0x9e53e707, + (q31_t)0x52b5e546, (q31_t)0x9e4fd78a, (q31_t)0x52b11996, (q31_t)0x9e4bc849, + (q31_t)0x52ac4db4, (q31_t)0x9e47b944, (q31_t)0x52a7819f, (q31_t)0x9e43aa7c, + (q31_t)0x52a2b556, (q31_t)0x9e3f9bf0, (q31_t)0x529de8db, (q31_t)0x9e3b8da0, + (q31_t)0x52991c2d, (q31_t)0x9e377f8c, (q31_t)0x52944f4c, (q31_t)0x9e3371b5, + (q31_t)0x528f8238, (q31_t)0x9e2f641b, (q31_t)0x528ab4f1, (q31_t)0x9e2b56bc, + (q31_t)0x5285e777, (q31_t)0x9e27499a, (q31_t)0x528119ca, (q31_t)0x9e233cb4, + (q31_t)0x527c4bea, (q31_t)0x9e1f300b, (q31_t)0x52777dd7, (q31_t)0x9e1b239e, + (q31_t)0x5272af92, (q31_t)0x9e17176d, (q31_t)0x526de11a, (q31_t)0x9e130b79, + (q31_t)0x5269126e, (q31_t)0x9e0effc1, (q31_t)0x52644390, (q31_t)0x9e0af446, + (q31_t)0x525f7480, (q31_t)0x9e06e907, (q31_t)0x525aa53c, (q31_t)0x9e02de04, + (q31_t)0x5255d5c5, (q31_t)0x9dfed33e, (q31_t)0x5251061c, (q31_t)0x9dfac8b4, + (q31_t)0x524c3640, (q31_t)0x9df6be67, (q31_t)0x52476631, (q31_t)0x9df2b456, + (q31_t)0x524295f0, (q31_t)0x9deeaa82, (q31_t)0x523dc57b, (q31_t)0x9deaa0ea, + (q31_t)0x5238f4d4, (q31_t)0x9de6978f, (q31_t)0x523423fb, (q31_t)0x9de28e70, + (q31_t)0x522f52ee, (q31_t)0x9dde858e, (q31_t)0x522a81af, (q31_t)0x9dda7ce9, + (q31_t)0x5225b03d, (q31_t)0x9dd6747f, (q31_t)0x5220de99, (q31_t)0x9dd26c53, + (q31_t)0x521c0cc2, (q31_t)0x9dce6463, (q31_t)0x52173ab8, (q31_t)0x9dca5caf, + (q31_t)0x5212687b, (q31_t)0x9dc65539, (q31_t)0x520d960c, (q31_t)0x9dc24dfe, + (q31_t)0x5208c36a, (q31_t)0x9dbe4701, (q31_t)0x5203f096, (q31_t)0x9dba4040, + (q31_t)0x51ff1d8f, (q31_t)0x9db639bb, (q31_t)0x51fa4a56, (q31_t)0x9db23373, + (q31_t)0x51f576ea, (q31_t)0x9dae2d68, (q31_t)0x51f0a34b, (q31_t)0x9daa279a, + (q31_t)0x51ebcf7a, (q31_t)0x9da62208, (q31_t)0x51e6fb76, (q31_t)0x9da21cb2, + (q31_t)0x51e22740, (q31_t)0x9d9e179a, (q31_t)0x51dd52d7, (q31_t)0x9d9a12be, + (q31_t)0x51d87e3c, (q31_t)0x9d960e1f, (q31_t)0x51d3a96f, (q31_t)0x9d9209bd, + (q31_t)0x51ced46e, (q31_t)0x9d8e0597, (q31_t)0x51c9ff3c, (q31_t)0x9d8a01ae, + (q31_t)0x51c529d7, (q31_t)0x9d85fe02, (q31_t)0x51c0543f, (q31_t)0x9d81fa92, + (q31_t)0x51bb7e75, (q31_t)0x9d7df75f, (q31_t)0x51b6a879, (q31_t)0x9d79f469, + (q31_t)0x51b1d24a, (q31_t)0x9d75f1b0, (q31_t)0x51acfbe9, (q31_t)0x9d71ef34, + (q31_t)0x51a82555, (q31_t)0x9d6decf4, (q31_t)0x51a34e8f, (q31_t)0x9d69eaf1, + (q31_t)0x519e7797, (q31_t)0x9d65e92b, (q31_t)0x5199a06d, (q31_t)0x9d61e7a2, + (q31_t)0x5194c910, (q31_t)0x9d5de656, (q31_t)0x518ff180, (q31_t)0x9d59e546, + (q31_t)0x518b19bf, (q31_t)0x9d55e473, (q31_t)0x518641cb, (q31_t)0x9d51e3dd, + (q31_t)0x518169a5, (q31_t)0x9d4de385, (q31_t)0x517c914c, (q31_t)0x9d49e368, + (q31_t)0x5177b8c2, (q31_t)0x9d45e389, (q31_t)0x5172e005, (q31_t)0x9d41e3e7, + (q31_t)0x516e0715, (q31_t)0x9d3de482, (q31_t)0x51692df4, (q31_t)0x9d39e559, + (q31_t)0x516454a0, (q31_t)0x9d35e66e, (q31_t)0x515f7b1a, (q31_t)0x9d31e7bf, + (q31_t)0x515aa162, (q31_t)0x9d2de94d, (q31_t)0x5155c778, (q31_t)0x9d29eb19, + (q31_t)0x5150ed5c, (q31_t)0x9d25ed21, (q31_t)0x514c130d, (q31_t)0x9d21ef66, + (q31_t)0x5147388c, (q31_t)0x9d1df1e9, (q31_t)0x51425dd9, (q31_t)0x9d19f4a8, + (q31_t)0x513d82f4, (q31_t)0x9d15f7a4, (q31_t)0x5138a7dd, (q31_t)0x9d11fadd, + (q31_t)0x5133cc94, (q31_t)0x9d0dfe54, (q31_t)0x512ef119, (q31_t)0x9d0a0207, + (q31_t)0x512a156b, (q31_t)0x9d0605f7, (q31_t)0x5125398c, (q31_t)0x9d020a25, + (q31_t)0x51205d7b, (q31_t)0x9cfe0e8f, (q31_t)0x511b8137, (q31_t)0x9cfa1337, + (q31_t)0x5116a4c1, (q31_t)0x9cf6181c, (q31_t)0x5111c81a, (q31_t)0x9cf21d3d, + (q31_t)0x510ceb40, (q31_t)0x9cee229c, (q31_t)0x51080e35, (q31_t)0x9cea2838, + (q31_t)0x510330f7, (q31_t)0x9ce62e11, (q31_t)0x50fe5388, (q31_t)0x9ce23427, + (q31_t)0x50f975e6, (q31_t)0x9cde3a7b, (q31_t)0x50f49813, (q31_t)0x9cda410b, + (q31_t)0x50efba0d, (q31_t)0x9cd647d9, (q31_t)0x50eadbd6, (q31_t)0x9cd24ee4, + (q31_t)0x50e5fd6d, (q31_t)0x9cce562c, (q31_t)0x50e11ed2, (q31_t)0x9cca5db1, + (q31_t)0x50dc4005, (q31_t)0x9cc66573, (q31_t)0x50d76106, (q31_t)0x9cc26d73, + (q31_t)0x50d281d5, (q31_t)0x9cbe75b0, (q31_t)0x50cda272, (q31_t)0x9cba7e2a, + (q31_t)0x50c8c2de, (q31_t)0x9cb686e1, (q31_t)0x50c3e317, (q31_t)0x9cb28fd5, + (q31_t)0x50bf031f, (q31_t)0x9cae9907, (q31_t)0x50ba22f5, (q31_t)0x9caaa276, + (q31_t)0x50b5429a, (q31_t)0x9ca6ac23, (q31_t)0x50b0620c, (q31_t)0x9ca2b60c, + (q31_t)0x50ab814d, (q31_t)0x9c9ec033, (q31_t)0x50a6a05c, (q31_t)0x9c9aca97, + (q31_t)0x50a1bf39, (q31_t)0x9c96d539, (q31_t)0x509cdde4, (q31_t)0x9c92e017, + (q31_t)0x5097fc5e, (q31_t)0x9c8eeb34, (q31_t)0x50931aa6, (q31_t)0x9c8af68d, + (q31_t)0x508e38bd, (q31_t)0x9c870224, (q31_t)0x508956a1, (q31_t)0x9c830df8, + (q31_t)0x50847454, (q31_t)0x9c7f1a0a, (q31_t)0x507f91d5, (q31_t)0x9c7b2659, + (q31_t)0x507aaf25, (q31_t)0x9c7732e5, (q31_t)0x5075cc43, (q31_t)0x9c733faf, + (q31_t)0x5070e92f, (q31_t)0x9c6f4cb6, (q31_t)0x506c05ea, (q31_t)0x9c6b59fa, + (q31_t)0x50672273, (q31_t)0x9c67677c, (q31_t)0x50623ecb, (q31_t)0x9c63753c, + (q31_t)0x505d5af1, (q31_t)0x9c5f8339, (q31_t)0x505876e5, (q31_t)0x9c5b9173, + (q31_t)0x505392a8, (q31_t)0x9c579feb, (q31_t)0x504eae39, (q31_t)0x9c53aea0, + (q31_t)0x5049c999, (q31_t)0x9c4fbd93, (q31_t)0x5044e4c7, (q31_t)0x9c4bccc3, + (q31_t)0x503fffc4, (q31_t)0x9c47dc31, (q31_t)0x503b1a8f, (q31_t)0x9c43ebdc, + (q31_t)0x50363529, (q31_t)0x9c3ffbc5, (q31_t)0x50314f91, (q31_t)0x9c3c0beb, + (q31_t)0x502c69c8, (q31_t)0x9c381c4f, (q31_t)0x502783cd, (q31_t)0x9c342cf0, + (q31_t)0x50229da1, (q31_t)0x9c303dcf, (q31_t)0x501db743, (q31_t)0x9c2c4eec, + (q31_t)0x5018d0b4, (q31_t)0x9c286046, (q31_t)0x5013e9f4, (q31_t)0x9c2471de, + (q31_t)0x500f0302, (q31_t)0x9c2083b3, (q31_t)0x500a1bdf, (q31_t)0x9c1c95c6, + (q31_t)0x5005348a, (q31_t)0x9c18a816, (q31_t)0x50004d04, (q31_t)0x9c14baa4, + (q31_t)0x4ffb654d, (q31_t)0x9c10cd70, (q31_t)0x4ff67d64, (q31_t)0x9c0ce07a, + (q31_t)0x4ff1954b, (q31_t)0x9c08f3c1, (q31_t)0x4fecacff, (q31_t)0x9c050745, + (q31_t)0x4fe7c483, (q31_t)0x9c011b08, (q31_t)0x4fe2dbd5, (q31_t)0x9bfd2f08, + (q31_t)0x4fddf2f6, (q31_t)0x9bf94346, (q31_t)0x4fd909e5, (q31_t)0x9bf557c1, + (q31_t)0x4fd420a4, (q31_t)0x9bf16c7a, (q31_t)0x4fcf3731, (q31_t)0x9bed8171, + (q31_t)0x4fca4d8d, (q31_t)0x9be996a6, (q31_t)0x4fc563b7, (q31_t)0x9be5ac18, + (q31_t)0x4fc079b1, (q31_t)0x9be1c1c8, (q31_t)0x4fbb8f79, (q31_t)0x9bddd7b6, + (q31_t)0x4fb6a510, (q31_t)0x9bd9ede2, (q31_t)0x4fb1ba76, (q31_t)0x9bd6044b, + (q31_t)0x4faccfab, (q31_t)0x9bd21af3, (q31_t)0x4fa7e4af, (q31_t)0x9bce31d8, + (q31_t)0x4fa2f981, (q31_t)0x9bca48fa, (q31_t)0x4f9e0e22, (q31_t)0x9bc6605b, + (q31_t)0x4f992293, (q31_t)0x9bc277fa, (q31_t)0x4f9436d2, (q31_t)0x9bbe8fd6, + (q31_t)0x4f8f4ae0, (q31_t)0x9bbaa7f0, (q31_t)0x4f8a5ebd, (q31_t)0x9bb6c048, + (q31_t)0x4f857269, (q31_t)0x9bb2d8de, (q31_t)0x4f8085e4, (q31_t)0x9baef1b2, + (q31_t)0x4f7b992d, (q31_t)0x9bab0ac3, (q31_t)0x4f76ac46, (q31_t)0x9ba72413, + (q31_t)0x4f71bf2e, (q31_t)0x9ba33da0, (q31_t)0x4f6cd1e5, (q31_t)0x9b9f576b, + (q31_t)0x4f67e46a, (q31_t)0x9b9b7174, (q31_t)0x4f62f6bf, (q31_t)0x9b978bbc, + (q31_t)0x4f5e08e3, (q31_t)0x9b93a641, (q31_t)0x4f591ad6, (q31_t)0x9b8fc104, + (q31_t)0x4f542c98, (q31_t)0x9b8bdc05, (q31_t)0x4f4f3e29, (q31_t)0x9b87f744, + (q31_t)0x4f4a4f89, (q31_t)0x9b8412c1, (q31_t)0x4f4560b8, (q31_t)0x9b802e7b, + (q31_t)0x4f4071b6, (q31_t)0x9b7c4a74, (q31_t)0x4f3b8284, (q31_t)0x9b7866ab, + (q31_t)0x4f369320, (q31_t)0x9b748320, (q31_t)0x4f31a38c, (q31_t)0x9b709fd3, + (q31_t)0x4f2cb3c7, (q31_t)0x9b6cbcc4, (q31_t)0x4f27c3d1, (q31_t)0x9b68d9f3, + (q31_t)0x4f22d3aa, (q31_t)0x9b64f760, (q31_t)0x4f1de352, (q31_t)0x9b61150b, + (q31_t)0x4f18f2c9, (q31_t)0x9b5d32f4, (q31_t)0x4f140210, (q31_t)0x9b59511c, + (q31_t)0x4f0f1126, (q31_t)0x9b556f81, (q31_t)0x4f0a200b, (q31_t)0x9b518e24, + (q31_t)0x4f052ec0, (q31_t)0x9b4dad06, (q31_t)0x4f003d43, (q31_t)0x9b49cc26, + (q31_t)0x4efb4b96, (q31_t)0x9b45eb83, (q31_t)0x4ef659b8, (q31_t)0x9b420b1f, + (q31_t)0x4ef167aa, (q31_t)0x9b3e2af9, (q31_t)0x4eec756b, (q31_t)0x9b3a4b11, + (q31_t)0x4ee782fb, (q31_t)0x9b366b68, (q31_t)0x4ee2905a, (q31_t)0x9b328bfc, + (q31_t)0x4edd9d89, (q31_t)0x9b2eaccf, (q31_t)0x4ed8aa87, (q31_t)0x9b2acde0, + (q31_t)0x4ed3b755, (q31_t)0x9b26ef2f, (q31_t)0x4ecec3f2, (q31_t)0x9b2310bc, + (q31_t)0x4ec9d05e, (q31_t)0x9b1f3288, (q31_t)0x4ec4dc99, (q31_t)0x9b1b5492, + (q31_t)0x4ebfe8a5, (q31_t)0x9b1776da, (q31_t)0x4ebaf47f, (q31_t)0x9b139960, + (q31_t)0x4eb60029, (q31_t)0x9b0fbc24, (q31_t)0x4eb10ba2, (q31_t)0x9b0bdf27, + (q31_t)0x4eac16eb, (q31_t)0x9b080268, (q31_t)0x4ea72203, (q31_t)0x9b0425e8, + (q31_t)0x4ea22ceb, (q31_t)0x9b0049a5, (q31_t)0x4e9d37a3, (q31_t)0x9afc6da1, + (q31_t)0x4e984229, (q31_t)0x9af891db, (q31_t)0x4e934c80, (q31_t)0x9af4b654, + (q31_t)0x4e8e56a5, (q31_t)0x9af0db0b, (q31_t)0x4e89609b, (q31_t)0x9aed0000, + (q31_t)0x4e846a60, (q31_t)0x9ae92533, (q31_t)0x4e7f73f4, (q31_t)0x9ae54aa5, + (q31_t)0x4e7a7d58, (q31_t)0x9ae17056, (q31_t)0x4e75868c, (q31_t)0x9add9644, + (q31_t)0x4e708f8f, (q31_t)0x9ad9bc71, (q31_t)0x4e6b9862, (q31_t)0x9ad5e2dd, + (q31_t)0x4e66a105, (q31_t)0x9ad20987, (q31_t)0x4e61a977, (q31_t)0x9ace306f, + (q31_t)0x4e5cb1b9, (q31_t)0x9aca5795, (q31_t)0x4e57b9ca, (q31_t)0x9ac67efb, + (q31_t)0x4e52c1ab, (q31_t)0x9ac2a69e, (q31_t)0x4e4dc95c, (q31_t)0x9abece80, + (q31_t)0x4e48d0dd, (q31_t)0x9abaf6a1, (q31_t)0x4e43d82d, (q31_t)0x9ab71eff, + (q31_t)0x4e3edf4d, (q31_t)0x9ab3479d, (q31_t)0x4e39e63d, (q31_t)0x9aaf7079, + (q31_t)0x4e34ecfc, (q31_t)0x9aab9993, (q31_t)0x4e2ff38b, (q31_t)0x9aa7c2ec, + (q31_t)0x4e2af9ea, (q31_t)0x9aa3ec83, (q31_t)0x4e260019, (q31_t)0x9aa01659, + (q31_t)0x4e210617, (q31_t)0x9a9c406e, (q31_t)0x4e1c0be6, (q31_t)0x9a986ac1, + (q31_t)0x4e171184, (q31_t)0x9a949552, (q31_t)0x4e1216f2, (q31_t)0x9a90c022, + (q31_t)0x4e0d1c30, (q31_t)0x9a8ceb31, (q31_t)0x4e08213e, (q31_t)0x9a89167e, + (q31_t)0x4e03261b, (q31_t)0x9a85420a, (q31_t)0x4dfe2ac9, (q31_t)0x9a816dd5, + (q31_t)0x4df92f46, (q31_t)0x9a7d99de, (q31_t)0x4df43393, (q31_t)0x9a79c625, + (q31_t)0x4def37b0, (q31_t)0x9a75f2ac, (q31_t)0x4dea3b9d, (q31_t)0x9a721f71, + (q31_t)0x4de53f5a, (q31_t)0x9a6e4c74, (q31_t)0x4de042e7, (q31_t)0x9a6a79b6, + (q31_t)0x4ddb4644, (q31_t)0x9a66a737, (q31_t)0x4dd64971, (q31_t)0x9a62d4f7, + (q31_t)0x4dd14c6e, (q31_t)0x9a5f02f5, (q31_t)0x4dcc4f3b, (q31_t)0x9a5b3132, + (q31_t)0x4dc751d8, (q31_t)0x9a575fae, (q31_t)0x4dc25445, (q31_t)0x9a538e68, + (q31_t)0x4dbd5682, (q31_t)0x9a4fbd61, (q31_t)0x4db8588f, (q31_t)0x9a4bec99, + (q31_t)0x4db35a6c, (q31_t)0x9a481c0f, (q31_t)0x4dae5c19, (q31_t)0x9a444bc5, + (q31_t)0x4da95d96, (q31_t)0x9a407bb9, (q31_t)0x4da45ee3, (q31_t)0x9a3cabeb, + (q31_t)0x4d9f6001, (q31_t)0x9a38dc5d, (q31_t)0x4d9a60ee, (q31_t)0x9a350d0d, + (q31_t)0x4d9561ac, (q31_t)0x9a313dfc, (q31_t)0x4d90623a, (q31_t)0x9a2d6f2a, + (q31_t)0x4d8b6298, (q31_t)0x9a29a097, (q31_t)0x4d8662c6, (q31_t)0x9a25d243, + (q31_t)0x4d8162c4, (q31_t)0x9a22042d, (q31_t)0x4d7c6293, (q31_t)0x9a1e3656, + (q31_t)0x4d776231, (q31_t)0x9a1a68be, (q31_t)0x4d7261a0, (q31_t)0x9a169b65, + (q31_t)0x4d6d60df, (q31_t)0x9a12ce4b, (q31_t)0x4d685fef, (q31_t)0x9a0f016f, + (q31_t)0x4d635ece, (q31_t)0x9a0b34d3, (q31_t)0x4d5e5d7e, (q31_t)0x9a076875, + (q31_t)0x4d595bfe, (q31_t)0x9a039c57, (q31_t)0x4d545a4f, (q31_t)0x99ffd077, + (q31_t)0x4d4f5870, (q31_t)0x99fc04d6, (q31_t)0x4d4a5661, (q31_t)0x99f83974, + (q31_t)0x4d455422, (q31_t)0x99f46e51, (q31_t)0x4d4051b4, (q31_t)0x99f0a36d, + (q31_t)0x4d3b4f16, (q31_t)0x99ecd8c8, (q31_t)0x4d364c48, (q31_t)0x99e90e62, + (q31_t)0x4d31494b, (q31_t)0x99e5443b, (q31_t)0x4d2c461e, (q31_t)0x99e17a53, + (q31_t)0x4d2742c2, (q31_t)0x99ddb0aa, (q31_t)0x4d223f36, (q31_t)0x99d9e73f, + (q31_t)0x4d1d3b7a, (q31_t)0x99d61e14, (q31_t)0x4d18378f, (q31_t)0x99d25528, + (q31_t)0x4d133374, (q31_t)0x99ce8c7b, (q31_t)0x4d0e2f2a, (q31_t)0x99cac40d, + (q31_t)0x4d092ab0, (q31_t)0x99c6fbde, (q31_t)0x4d042607, (q31_t)0x99c333ee, + (q31_t)0x4cff212e, (q31_t)0x99bf6c3d, (q31_t)0x4cfa1c26, (q31_t)0x99bba4cb, + (q31_t)0x4cf516ee, (q31_t)0x99b7dd99, (q31_t)0x4cf01187, (q31_t)0x99b416a5, + (q31_t)0x4ceb0bf0, (q31_t)0x99b04ff0, (q31_t)0x4ce6062a, (q31_t)0x99ac897b, + (q31_t)0x4ce10034, (q31_t)0x99a8c345, (q31_t)0x4cdbfa0f, (q31_t)0x99a4fd4d, + (q31_t)0x4cd6f3bb, (q31_t)0x99a13795, (q31_t)0x4cd1ed37, (q31_t)0x999d721c, + (q31_t)0x4ccce684, (q31_t)0x9999ace3, (q31_t)0x4cc7dfa1, (q31_t)0x9995e7e8, + (q31_t)0x4cc2d88f, (q31_t)0x9992232d, (q31_t)0x4cbdd14e, (q31_t)0x998e5eb1, + (q31_t)0x4cb8c9dd, (q31_t)0x998a9a74, (q31_t)0x4cb3c23d, (q31_t)0x9986d676, + (q31_t)0x4caeba6e, (q31_t)0x998312b7, (q31_t)0x4ca9b26f, (q31_t)0x997f4f38, + (q31_t)0x4ca4aa41, (q31_t)0x997b8bf8, (q31_t)0x4c9fa1e4, (q31_t)0x9977c8f7, + (q31_t)0x4c9a9958, (q31_t)0x99740635, (q31_t)0x4c95909c, (q31_t)0x997043b2, + (q31_t)0x4c9087b1, (q31_t)0x996c816f, (q31_t)0x4c8b7e97, (q31_t)0x9968bf6b, + (q31_t)0x4c86754e, (q31_t)0x9964fda7, (q31_t)0x4c816bd5, (q31_t)0x99613c22, + (q31_t)0x4c7c622d, (q31_t)0x995d7adc, (q31_t)0x4c775856, (q31_t)0x9959b9d5, + (q31_t)0x4c724e50, (q31_t)0x9955f90d, (q31_t)0x4c6d441b, (q31_t)0x99523885, + (q31_t)0x4c6839b7, (q31_t)0x994e783d, (q31_t)0x4c632f23, (q31_t)0x994ab833, + (q31_t)0x4c5e2460, (q31_t)0x9946f869, (q31_t)0x4c59196f, (q31_t)0x994338df, + (q31_t)0x4c540e4e, (q31_t)0x993f7993, (q31_t)0x4c4f02fe, (q31_t)0x993bba87, + (q31_t)0x4c49f77f, (q31_t)0x9937fbbb, (q31_t)0x4c44ebd1, (q31_t)0x99343d2e, + (q31_t)0x4c3fdff4, (q31_t)0x99307ee0, (q31_t)0x4c3ad3e7, (q31_t)0x992cc0d2, + (q31_t)0x4c35c7ac, (q31_t)0x99290303, (q31_t)0x4c30bb42, (q31_t)0x99254574, + (q31_t)0x4c2baea9, (q31_t)0x99218824, (q31_t)0x4c26a1e1, (q31_t)0x991dcb13, + (q31_t)0x4c2194e9, (q31_t)0x991a0e42, (q31_t)0x4c1c87c3, (q31_t)0x991651b1, + (q31_t)0x4c177a6e, (q31_t)0x9912955f, (q31_t)0x4c126cea, (q31_t)0x990ed94c, + (q31_t)0x4c0d5f37, (q31_t)0x990b1d79, (q31_t)0x4c085156, (q31_t)0x990761e5, + (q31_t)0x4c034345, (q31_t)0x9903a691, (q31_t)0x4bfe3505, (q31_t)0x98ffeb7d, + (q31_t)0x4bf92697, (q31_t)0x98fc30a8, (q31_t)0x4bf417f9, (q31_t)0x98f87612, + (q31_t)0x4bef092d, (q31_t)0x98f4bbbc, (q31_t)0x4be9fa32, (q31_t)0x98f101a6, + (q31_t)0x4be4eb08, (q31_t)0x98ed47cf, (q31_t)0x4bdfdbaf, (q31_t)0x98e98e38, + (q31_t)0x4bdacc28, (q31_t)0x98e5d4e0, (q31_t)0x4bd5bc72, (q31_t)0x98e21bc8, + (q31_t)0x4bd0ac8d, (q31_t)0x98de62f0, (q31_t)0x4bcb9c79, (q31_t)0x98daaa57, + (q31_t)0x4bc68c36, (q31_t)0x98d6f1fe, (q31_t)0x4bc17bc5, (q31_t)0x98d339e4, + (q31_t)0x4bbc6b25, (q31_t)0x98cf820b, (q31_t)0x4bb75a56, (q31_t)0x98cbca70, + (q31_t)0x4bb24958, (q31_t)0x98c81316, (q31_t)0x4bad382c, (q31_t)0x98c45bfb, + (q31_t)0x4ba826d1, (q31_t)0x98c0a520, (q31_t)0x4ba31548, (q31_t)0x98bcee84, + (q31_t)0x4b9e0390, (q31_t)0x98b93828, (q31_t)0x4b98f1a9, (q31_t)0x98b5820c, + (q31_t)0x4b93df93, (q31_t)0x98b1cc30, (q31_t)0x4b8ecd4f, (q31_t)0x98ae1693, + (q31_t)0x4b89badd, (q31_t)0x98aa6136, (q31_t)0x4b84a83b, (q31_t)0x98a6ac19, + (q31_t)0x4b7f956b, (q31_t)0x98a2f73c, (q31_t)0x4b7a826d, (q31_t)0x989f429e, + (q31_t)0x4b756f40, (q31_t)0x989b8e40, (q31_t)0x4b705be4, (q31_t)0x9897da22, + (q31_t)0x4b6b485a, (q31_t)0x98942643, (q31_t)0x4b6634a2, (q31_t)0x989072a5, + (q31_t)0x4b6120bb, (q31_t)0x988cbf46, (q31_t)0x4b5c0ca5, (q31_t)0x98890c27, + (q31_t)0x4b56f861, (q31_t)0x98855948, (q31_t)0x4b51e3ee, (q31_t)0x9881a6a9, + (q31_t)0x4b4ccf4d, (q31_t)0x987df449, (q31_t)0x4b47ba7e, (q31_t)0x987a422a, + (q31_t)0x4b42a580, (q31_t)0x9876904a, (q31_t)0x4b3d9053, (q31_t)0x9872deaa, + (q31_t)0x4b387af9, (q31_t)0x986f2d4a, (q31_t)0x4b336570, (q31_t)0x986b7c2a, + (q31_t)0x4b2e4fb8, (q31_t)0x9867cb4a, (q31_t)0x4b2939d2, (q31_t)0x98641aa9, + (q31_t)0x4b2423be, (q31_t)0x98606a49, (q31_t)0x4b1f0d7b, (q31_t)0x985cba28, + (q31_t)0x4b19f70a, (q31_t)0x98590a48, (q31_t)0x4b14e06b, (q31_t)0x98555aa7, + (q31_t)0x4b0fc99d, (q31_t)0x9851ab46, (q31_t)0x4b0ab2a1, (q31_t)0x984dfc26, + (q31_t)0x4b059b77, (q31_t)0x984a4d45, (q31_t)0x4b00841f, (q31_t)0x98469ea4, + (q31_t)0x4afb6c98, (q31_t)0x9842f043, (q31_t)0x4af654e3, (q31_t)0x983f4223, + (q31_t)0x4af13d00, (q31_t)0x983b9442, (q31_t)0x4aec24ee, (q31_t)0x9837e6a1, + (q31_t)0x4ae70caf, (q31_t)0x98343940, (q31_t)0x4ae1f441, (q31_t)0x98308c1f, + (q31_t)0x4adcdba5, (q31_t)0x982cdf3f, (q31_t)0x4ad7c2da, (q31_t)0x9829329e, + (q31_t)0x4ad2a9e2, (q31_t)0x9825863d, (q31_t)0x4acd90bb, (q31_t)0x9821da1d, + (q31_t)0x4ac87767, (q31_t)0x981e2e3c, (q31_t)0x4ac35de4, (q31_t)0x981a829c, + (q31_t)0x4abe4433, (q31_t)0x9816d73b, (q31_t)0x4ab92a54, (q31_t)0x98132c1b, + (q31_t)0x4ab41046, (q31_t)0x980f813b, (q31_t)0x4aaef60b, (q31_t)0x980bd69b, + (q31_t)0x4aa9dba2, (q31_t)0x98082c3b, (q31_t)0x4aa4c10b, (q31_t)0x9804821b, + (q31_t)0x4a9fa645, (q31_t)0x9800d83c, (q31_t)0x4a9a8b52, (q31_t)0x97fd2e9c, + (q31_t)0x4a957030, (q31_t)0x97f9853d, (q31_t)0x4a9054e1, (q31_t)0x97f5dc1e, + (q31_t)0x4a8b3963, (q31_t)0x97f2333f, (q31_t)0x4a861db8, (q31_t)0x97ee8aa0, + (q31_t)0x4a8101de, (q31_t)0x97eae242, (q31_t)0x4a7be5d7, (q31_t)0x97e73a23, + (q31_t)0x4a76c9a2, (q31_t)0x97e39245, (q31_t)0x4a71ad3e, (q31_t)0x97dfeaa7, + (q31_t)0x4a6c90ad, (q31_t)0x97dc4349, (q31_t)0x4a6773ee, (q31_t)0x97d89c2c, + (q31_t)0x4a625701, (q31_t)0x97d4f54f, (q31_t)0x4a5d39e6, (q31_t)0x97d14eb2, + (q31_t)0x4a581c9e, (q31_t)0x97cda855, (q31_t)0x4a52ff27, (q31_t)0x97ca0239, + (q31_t)0x4a4de182, (q31_t)0x97c65c5c, (q31_t)0x4a48c3b0, (q31_t)0x97c2b6c1, + (q31_t)0x4a43a5b0, (q31_t)0x97bf1165, (q31_t)0x4a3e8782, (q31_t)0x97bb6c4a, + (q31_t)0x4a396926, (q31_t)0x97b7c76f, (q31_t)0x4a344a9d, (q31_t)0x97b422d4, + (q31_t)0x4a2f2be6, (q31_t)0x97b07e7a, (q31_t)0x4a2a0d01, (q31_t)0x97acda60, + (q31_t)0x4a24edee, (q31_t)0x97a93687, (q31_t)0x4a1fcead, (q31_t)0x97a592ed, + (q31_t)0x4a1aaf3f, (q31_t)0x97a1ef94, (q31_t)0x4a158fa3, (q31_t)0x979e4c7c, + (q31_t)0x4a106fda, (q31_t)0x979aa9a4, (q31_t)0x4a0b4fe2, (q31_t)0x9797070c, + (q31_t)0x4a062fbd, (q31_t)0x979364b5, (q31_t)0x4a010f6b, (q31_t)0x978fc29e, + (q31_t)0x49fbeeea, (q31_t)0x978c20c8, (q31_t)0x49f6ce3c, (q31_t)0x97887f32, + (q31_t)0x49f1ad61, (q31_t)0x9784dddc, (q31_t)0x49ec8c57, (q31_t)0x97813cc7, + (q31_t)0x49e76b21, (q31_t)0x977d9bf2, (q31_t)0x49e249bc, (q31_t)0x9779fb5e, + (q31_t)0x49dd282a, (q31_t)0x97765b0a, (q31_t)0x49d8066b, (q31_t)0x9772baf7, + (q31_t)0x49d2e47e, (q31_t)0x976f1b24, (q31_t)0x49cdc263, (q31_t)0x976b7b92, + (q31_t)0x49c8a01b, (q31_t)0x9767dc41, (q31_t)0x49c37da5, (q31_t)0x97643d2f, + (q31_t)0x49be5b02, (q31_t)0x97609e5f, (q31_t)0x49b93832, (q31_t)0x975cffcf, + (q31_t)0x49b41533, (q31_t)0x9759617f, (q31_t)0x49aef208, (q31_t)0x9755c370, + (q31_t)0x49a9ceaf, (q31_t)0x975225a1, (q31_t)0x49a4ab28, (q31_t)0x974e8813, + (q31_t)0x499f8774, (q31_t)0x974aeac6, (q31_t)0x499a6393, (q31_t)0x97474db9, + (q31_t)0x49953f84, (q31_t)0x9743b0ed, (q31_t)0x49901b48, (q31_t)0x97401462, + (q31_t)0x498af6df, (q31_t)0x973c7817, (q31_t)0x4985d248, (q31_t)0x9738dc0d, + (q31_t)0x4980ad84, (q31_t)0x97354043, (q31_t)0x497b8892, (q31_t)0x9731a4ba, + (q31_t)0x49766373, (q31_t)0x972e0971, (q31_t)0x49713e27, (q31_t)0x972a6e6a, + (q31_t)0x496c18ae, (q31_t)0x9726d3a3, (q31_t)0x4966f307, (q31_t)0x9723391c, + (q31_t)0x4961cd33, (q31_t)0x971f9ed7, (q31_t)0x495ca732, (q31_t)0x971c04d2, + (q31_t)0x49578103, (q31_t)0x97186b0d, (q31_t)0x49525aa7, (q31_t)0x9714d18a, + (q31_t)0x494d341e, (q31_t)0x97113847, (q31_t)0x49480d68, (q31_t)0x970d9f45, + (q31_t)0x4942e684, (q31_t)0x970a0683, (q31_t)0x493dbf74, (q31_t)0x97066e03, + (q31_t)0x49389836, (q31_t)0x9702d5c3, (q31_t)0x493370cb, (q31_t)0x96ff3dc4, + (q31_t)0x492e4933, (q31_t)0x96fba605, (q31_t)0x4929216e, (q31_t)0x96f80e88, + (q31_t)0x4923f97b, (q31_t)0x96f4774b, (q31_t)0x491ed15c, (q31_t)0x96f0e04f, + (q31_t)0x4919a90f, (q31_t)0x96ed4994, (q31_t)0x49148095, (q31_t)0x96e9b319, + (q31_t)0x490f57ee, (q31_t)0x96e61ce0, (q31_t)0x490a2f1b, (q31_t)0x96e286e7, + (q31_t)0x4905061a, (q31_t)0x96def12f, (q31_t)0x48ffdcec, (q31_t)0x96db5bb8, + (q31_t)0x48fab391, (q31_t)0x96d7c682, (q31_t)0x48f58a09, (q31_t)0x96d4318d, + (q31_t)0x48f06054, (q31_t)0x96d09cd8, (q31_t)0x48eb3672, (q31_t)0x96cd0865, + (q31_t)0x48e60c62, (q31_t)0x96c97432, (q31_t)0x48e0e227, (q31_t)0x96c5e040, + (q31_t)0x48dbb7be, (q31_t)0x96c24c8f, (q31_t)0x48d68d28, (q31_t)0x96beb91f, + (q31_t)0x48d16265, (q31_t)0x96bb25f0, (q31_t)0x48cc3775, (q31_t)0x96b79302, + (q31_t)0x48c70c59, (q31_t)0x96b40055, (q31_t)0x48c1e10f, (q31_t)0x96b06de9, + (q31_t)0x48bcb599, (q31_t)0x96acdbbe, (q31_t)0x48b789f5, (q31_t)0x96a949d3, + (q31_t)0x48b25e25, (q31_t)0x96a5b82a, (q31_t)0x48ad3228, (q31_t)0x96a226c2, + (q31_t)0x48a805ff, (q31_t)0x969e959b, (q31_t)0x48a2d9a8, (q31_t)0x969b04b4, + (q31_t)0x489dad25, (q31_t)0x9697740f, (q31_t)0x48988074, (q31_t)0x9693e3ab, + (q31_t)0x48935397, (q31_t)0x96905388, (q31_t)0x488e268e, (q31_t)0x968cc3a5, + (q31_t)0x4888f957, (q31_t)0x96893404, (q31_t)0x4883cbf4, (q31_t)0x9685a4a4, + (q31_t)0x487e9e64, (q31_t)0x96821585, (q31_t)0x487970a7, (q31_t)0x967e86a7, + (q31_t)0x487442be, (q31_t)0x967af80a, (q31_t)0x486f14a8, (q31_t)0x967769af, + (q31_t)0x4869e665, (q31_t)0x9673db94, (q31_t)0x4864b7f5, (q31_t)0x96704dba, + (q31_t)0x485f8959, (q31_t)0x966cc022, (q31_t)0x485a5a90, (q31_t)0x966932cb, + (q31_t)0x48552b9b, (q31_t)0x9665a5b4, (q31_t)0x484ffc79, (q31_t)0x966218df, + (q31_t)0x484acd2a, (q31_t)0x965e8c4b, (q31_t)0x48459daf, (q31_t)0x965afff9, + (q31_t)0x48406e08, (q31_t)0x965773e7, (q31_t)0x483b3e33, (q31_t)0x9653e817, + (q31_t)0x48360e32, (q31_t)0x96505c88, (q31_t)0x4830de05, (q31_t)0x964cd139, + (q31_t)0x482badab, (q31_t)0x9649462d, (q31_t)0x48267d24, (q31_t)0x9645bb61, + (q31_t)0x48214c71, (q31_t)0x964230d7, (q31_t)0x481c1b92, (q31_t)0x963ea68d, + (q31_t)0x4816ea86, (q31_t)0x963b1c86, (q31_t)0x4811b94d, (q31_t)0x963792bf, + (q31_t)0x480c87e8, (q31_t)0x96340939, (q31_t)0x48075657, (q31_t)0x96307ff5, + (q31_t)0x48022499, (q31_t)0x962cf6f2, (q31_t)0x47fcf2af, (q31_t)0x96296e31, + (q31_t)0x47f7c099, (q31_t)0x9625e5b0, (q31_t)0x47f28e56, (q31_t)0x96225d71, + (q31_t)0x47ed5be6, (q31_t)0x961ed574, (q31_t)0x47e8294a, (q31_t)0x961b4db7, + (q31_t)0x47e2f682, (q31_t)0x9617c63c, (q31_t)0x47ddc38e, (q31_t)0x96143f02, + (q31_t)0x47d8906d, (q31_t)0x9610b80a, (q31_t)0x47d35d20, (q31_t)0x960d3153, + (q31_t)0x47ce29a7, (q31_t)0x9609aadd, (q31_t)0x47c8f601, (q31_t)0x960624a9, + (q31_t)0x47c3c22f, (q31_t)0x96029eb6, (q31_t)0x47be8e31, (q31_t)0x95ff1904, + (q31_t)0x47b95a06, (q31_t)0x95fb9394, (q31_t)0x47b425af, (q31_t)0x95f80e65, + (q31_t)0x47aef12c, (q31_t)0x95f48977, (q31_t)0x47a9bc7d, (q31_t)0x95f104cb, + (q31_t)0x47a487a2, (q31_t)0x95ed8061, (q31_t)0x479f529a, (q31_t)0x95e9fc38, + (q31_t)0x479a1d67, (q31_t)0x95e67850, (q31_t)0x4794e807, (q31_t)0x95e2f4a9, + (q31_t)0x478fb27b, (q31_t)0x95df7145, (q31_t)0x478a7cc2, (q31_t)0x95dbee21, + (q31_t)0x478546de, (q31_t)0x95d86b3f, (q31_t)0x478010cd, (q31_t)0x95d4e89f, + (q31_t)0x477ada91, (q31_t)0x95d16640, (q31_t)0x4775a428, (q31_t)0x95cde423, + (q31_t)0x47706d93, (q31_t)0x95ca6247, (q31_t)0x476b36d3, (q31_t)0x95c6e0ac, + (q31_t)0x4765ffe6, (q31_t)0x95c35f53, (q31_t)0x4760c8cd, (q31_t)0x95bfde3c, + (q31_t)0x475b9188, (q31_t)0x95bc5d66, (q31_t)0x47565a17, (q31_t)0x95b8dcd2, + (q31_t)0x4751227a, (q31_t)0x95b55c7f, (q31_t)0x474beab1, (q31_t)0x95b1dc6e, + (q31_t)0x4746b2bc, (q31_t)0x95ae5c9f, (q31_t)0x47417a9b, (q31_t)0x95aadd11, + (q31_t)0x473c424e, (q31_t)0x95a75dc4, (q31_t)0x473709d5, (q31_t)0x95a3deb9, + (q31_t)0x4731d131, (q31_t)0x95a05ff0, (q31_t)0x472c9860, (q31_t)0x959ce169, + (q31_t)0x47275f63, (q31_t)0x95996323, (q31_t)0x4722263b, (q31_t)0x9595e51e, + (q31_t)0x471cece7, (q31_t)0x9592675c, (q31_t)0x4717b367, (q31_t)0x958ee9db, + (q31_t)0x471279ba, (q31_t)0x958b6c9b, (q31_t)0x470d3fe3, (q31_t)0x9587ef9e, + (q31_t)0x470805df, (q31_t)0x958472e2, (q31_t)0x4702cbaf, (q31_t)0x9580f667, + (q31_t)0x46fd9154, (q31_t)0x957d7a2f, (q31_t)0x46f856cd, (q31_t)0x9579fe38, + (q31_t)0x46f31c1a, (q31_t)0x95768283, (q31_t)0x46ede13b, (q31_t)0x9573070f, + (q31_t)0x46e8a631, (q31_t)0x956f8bdd, (q31_t)0x46e36afb, (q31_t)0x956c10ed, + (q31_t)0x46de2f99, (q31_t)0x9568963f, (q31_t)0x46d8f40b, (q31_t)0x95651bd2, + (q31_t)0x46d3b852, (q31_t)0x9561a1a8, (q31_t)0x46ce7c6d, (q31_t)0x955e27bf, + (q31_t)0x46c9405c, (q31_t)0x955aae17, (q31_t)0x46c40420, (q31_t)0x955734b2, + (q31_t)0x46bec7b8, (q31_t)0x9553bb8e, (q31_t)0x46b98b24, (q31_t)0x955042ac, + (q31_t)0x46b44e65, (q31_t)0x954cca0c, (q31_t)0x46af117a, (q31_t)0x954951ae, + (q31_t)0x46a9d464, (q31_t)0x9545d992, (q31_t)0x46a49722, (q31_t)0x954261b7, + (q31_t)0x469f59b4, (q31_t)0x953eea1e, (q31_t)0x469a1c1b, (q31_t)0x953b72c7, + (q31_t)0x4694de56, (q31_t)0x9537fbb2, (q31_t)0x468fa066, (q31_t)0x953484df, + (q31_t)0x468a624a, (q31_t)0x95310e4e, (q31_t)0x46852403, (q31_t)0x952d97fe, + (q31_t)0x467fe590, (q31_t)0x952a21f1, (q31_t)0x467aa6f2, (q31_t)0x9526ac25, + (q31_t)0x46756828, (q31_t)0x9523369c, (q31_t)0x46702933, (q31_t)0x951fc154, + (q31_t)0x466aea12, (q31_t)0x951c4c4e, (q31_t)0x4665aac6, (q31_t)0x9518d78a, + (q31_t)0x46606b4e, (q31_t)0x95156308, (q31_t)0x465b2bab, (q31_t)0x9511eec8, + (q31_t)0x4655ebdd, (q31_t)0x950e7aca, (q31_t)0x4650abe3, (q31_t)0x950b070e, + (q31_t)0x464b6bbe, (q31_t)0x95079394, (q31_t)0x46462b6d, (q31_t)0x9504205c, + (q31_t)0x4640eaf2, (q31_t)0x9500ad66, (q31_t)0x463baa4a, (q31_t)0x94fd3ab1, + (q31_t)0x46366978, (q31_t)0x94f9c83f, (q31_t)0x4631287a, (q31_t)0x94f6560f, + (q31_t)0x462be751, (q31_t)0x94f2e421, (q31_t)0x4626a5fd, (q31_t)0x94ef7275, + (q31_t)0x4621647d, (q31_t)0x94ec010b, (q31_t)0x461c22d2, (q31_t)0x94e88fe3, + (q31_t)0x4616e0fc, (q31_t)0x94e51efd, (q31_t)0x46119efa, (q31_t)0x94e1ae59, + (q31_t)0x460c5cce, (q31_t)0x94de3df8, (q31_t)0x46071a76, (q31_t)0x94dacdd8, + (q31_t)0x4601d7f3, (q31_t)0x94d75dfa, (q31_t)0x45fc9545, (q31_t)0x94d3ee5f, + (q31_t)0x45f7526b, (q31_t)0x94d07f05, (q31_t)0x45f20f67, (q31_t)0x94cd0fee, + (q31_t)0x45eccc37, (q31_t)0x94c9a119, (q31_t)0x45e788dc, (q31_t)0x94c63286, + (q31_t)0x45e24556, (q31_t)0x94c2c435, (q31_t)0x45dd01a5, (q31_t)0x94bf5627, + (q31_t)0x45d7bdc9, (q31_t)0x94bbe85a, (q31_t)0x45d279c2, (q31_t)0x94b87ad0, + (q31_t)0x45cd358f, (q31_t)0x94b50d87, (q31_t)0x45c7f132, (q31_t)0x94b1a081, + (q31_t)0x45c2acaa, (q31_t)0x94ae33be, (q31_t)0x45bd67f6, (q31_t)0x94aac73c, + (q31_t)0x45b82318, (q31_t)0x94a75afd, (q31_t)0x45b2de0e, (q31_t)0x94a3eeff, + (q31_t)0x45ad98da, (q31_t)0x94a08344, (q31_t)0x45a8537a, (q31_t)0x949d17cc, + (q31_t)0x45a30df0, (q31_t)0x9499ac95, (q31_t)0x459dc83b, (q31_t)0x949641a1, + (q31_t)0x4598825a, (q31_t)0x9492d6ef, (q31_t)0x45933c4f, (q31_t)0x948f6c7f, + (q31_t)0x458df619, (q31_t)0x948c0252, (q31_t)0x4588afb8, (q31_t)0x94889867, + (q31_t)0x4583692c, (q31_t)0x94852ebe, (q31_t)0x457e2275, (q31_t)0x9481c557, + (q31_t)0x4578db93, (q31_t)0x947e5c33, (q31_t)0x45739487, (q31_t)0x947af351, + (q31_t)0x456e4d4f, (q31_t)0x94778ab1, (q31_t)0x456905ed, (q31_t)0x94742254, + (q31_t)0x4563be60, (q31_t)0x9470ba39, (q31_t)0x455e76a8, (q31_t)0x946d5260, + (q31_t)0x45592ec6, (q31_t)0x9469eaca, (q31_t)0x4553e6b8, (q31_t)0x94668376, + (q31_t)0x454e9e80, (q31_t)0x94631c65, (q31_t)0x4549561d, (q31_t)0x945fb596, + (q31_t)0x45440d90, (q31_t)0x945c4f09, (q31_t)0x453ec4d7, (q31_t)0x9458e8bf, + (q31_t)0x45397bf4, (q31_t)0x945582b7, (q31_t)0x453432e6, (q31_t)0x94521cf1, + (q31_t)0x452ee9ae, (q31_t)0x944eb76e, (q31_t)0x4529a04b, (q31_t)0x944b522d, + (q31_t)0x452456bd, (q31_t)0x9447ed2f, (q31_t)0x451f0d04, (q31_t)0x94448873, + (q31_t)0x4519c321, (q31_t)0x944123fa, (q31_t)0x45147913, (q31_t)0x943dbfc3, + (q31_t)0x450f2edb, (q31_t)0x943a5bcf, (q31_t)0x4509e478, (q31_t)0x9436f81d, + (q31_t)0x450499eb, (q31_t)0x943394ad, (q31_t)0x44ff4f32, (q31_t)0x94303180, + (q31_t)0x44fa0450, (q31_t)0x942cce96, (q31_t)0x44f4b943, (q31_t)0x94296bee, + (q31_t)0x44ef6e0b, (q31_t)0x94260989, (q31_t)0x44ea22a9, (q31_t)0x9422a766, + (q31_t)0x44e4d71c, (q31_t)0x941f4585, (q31_t)0x44df8b64, (q31_t)0x941be3e8, + (q31_t)0x44da3f83, (q31_t)0x9418828c, (q31_t)0x44d4f376, (q31_t)0x94152174, + (q31_t)0x44cfa740, (q31_t)0x9411c09e, (q31_t)0x44ca5adf, (q31_t)0x940e600a, + (q31_t)0x44c50e53, (q31_t)0x940affb9, (q31_t)0x44bfc19d, (q31_t)0x94079fab, + (q31_t)0x44ba74bd, (q31_t)0x94043fdf, (q31_t)0x44b527b2, (q31_t)0x9400e056, + (q31_t)0x44afda7d, (q31_t)0x93fd810f, (q31_t)0x44aa8d1d, (q31_t)0x93fa220b, + (q31_t)0x44a53f93, (q31_t)0x93f6c34a, (q31_t)0x449ff1df, (q31_t)0x93f364cb, + (q31_t)0x449aa400, (q31_t)0x93f0068f, (q31_t)0x449555f7, (q31_t)0x93eca896, + (q31_t)0x449007c4, (q31_t)0x93e94adf, (q31_t)0x448ab967, (q31_t)0x93e5ed6b, + (q31_t)0x44856adf, (q31_t)0x93e2903a, (q31_t)0x44801c2d, (q31_t)0x93df334c, + (q31_t)0x447acd50, (q31_t)0x93dbd6a0, (q31_t)0x44757e4a, (q31_t)0x93d87a36, + (q31_t)0x44702f19, (q31_t)0x93d51e10, (q31_t)0x446adfbe, (q31_t)0x93d1c22c, + (q31_t)0x44659039, (q31_t)0x93ce668b, (q31_t)0x44604089, (q31_t)0x93cb0b2d, + (q31_t)0x445af0b0, (q31_t)0x93c7b011, (q31_t)0x4455a0ac, (q31_t)0x93c45539, + (q31_t)0x4450507e, (q31_t)0x93c0faa3, (q31_t)0x444b0026, (q31_t)0x93bda04f, + (q31_t)0x4445afa4, (q31_t)0x93ba463f, (q31_t)0x44405ef8, (q31_t)0x93b6ec71, + (q31_t)0x443b0e21, (q31_t)0x93b392e6, (q31_t)0x4435bd21, (q31_t)0x93b0399e, + (q31_t)0x44306bf6, (q31_t)0x93ace099, (q31_t)0x442b1aa2, (q31_t)0x93a987d6, + (q31_t)0x4425c923, (q31_t)0x93a62f57, (q31_t)0x4420777b, (q31_t)0x93a2d71a, + (q31_t)0x441b25a8, (q31_t)0x939f7f20, (q31_t)0x4415d3ab, (q31_t)0x939c2769, + (q31_t)0x44108184, (q31_t)0x9398cff5, (q31_t)0x440b2f34, (q31_t)0x939578c3, + (q31_t)0x4405dcb9, (q31_t)0x939221d5, (q31_t)0x44008a14, (q31_t)0x938ecb29, + (q31_t)0x43fb3746, (q31_t)0x938b74c1, (q31_t)0x43f5e44d, (q31_t)0x93881e9b, + (q31_t)0x43f0912b, (q31_t)0x9384c8b8, (q31_t)0x43eb3ddf, (q31_t)0x93817318, + (q31_t)0x43e5ea68, (q31_t)0x937e1dbb, (q31_t)0x43e096c8, (q31_t)0x937ac8a1, + (q31_t)0x43db42fe, (q31_t)0x937773ca, (q31_t)0x43d5ef0a, (q31_t)0x93741f35, + (q31_t)0x43d09aed, (q31_t)0x9370cae4, (q31_t)0x43cb46a5, (q31_t)0x936d76d6, + (q31_t)0x43c5f234, (q31_t)0x936a230a, (q31_t)0x43c09d99, (q31_t)0x9366cf82, + (q31_t)0x43bb48d4, (q31_t)0x93637c3d, (q31_t)0x43b5f3e5, (q31_t)0x9360293a, + (q31_t)0x43b09ecc, (q31_t)0x935cd67b, (q31_t)0x43ab498a, (q31_t)0x935983ff, + (q31_t)0x43a5f41e, (q31_t)0x935631c5, (q31_t)0x43a09e89, (q31_t)0x9352dfcf, + (q31_t)0x439b48c9, (q31_t)0x934f8e1c, (q31_t)0x4395f2e0, (q31_t)0x934c3cab, + (q31_t)0x43909ccd, (q31_t)0x9348eb7e, (q31_t)0x438b4691, (q31_t)0x93459a94, + (q31_t)0x4385f02a, (q31_t)0x934249ed, (q31_t)0x4380999b, (q31_t)0x933ef989, + (q31_t)0x437b42e1, (q31_t)0x933ba968, (q31_t)0x4375ebfe, (q31_t)0x9338598a, + (q31_t)0x437094f1, (q31_t)0x933509f0, (q31_t)0x436b3dbb, (q31_t)0x9331ba98, + (q31_t)0x4365e65b, (q31_t)0x932e6b84, (q31_t)0x43608ed2, (q31_t)0x932b1cb2, + (q31_t)0x435b371f, (q31_t)0x9327ce24, (q31_t)0x4355df42, (q31_t)0x93247fd9, + (q31_t)0x4350873c, (q31_t)0x932131d1, (q31_t)0x434b2f0c, (q31_t)0x931de40c, + (q31_t)0x4345d6b3, (q31_t)0x931a968b, (q31_t)0x43407e31, (q31_t)0x9317494c, + (q31_t)0x433b2585, (q31_t)0x9313fc51, (q31_t)0x4335ccaf, (q31_t)0x9310af99, + (q31_t)0x433073b0, (q31_t)0x930d6324, (q31_t)0x432b1a87, (q31_t)0x930a16f3, + (q31_t)0x4325c135, (q31_t)0x9306cb04, (q31_t)0x432067ba, (q31_t)0x93037f59, + (q31_t)0x431b0e15, (q31_t)0x930033f1, (q31_t)0x4315b447, (q31_t)0x92fce8cc, + (q31_t)0x43105a50, (q31_t)0x92f99deb, (q31_t)0x430b002f, (q31_t)0x92f6534c, + (q31_t)0x4305a5e5, (q31_t)0x92f308f1, (q31_t)0x43004b71, (q31_t)0x92efbeda, + (q31_t)0x42faf0d4, (q31_t)0x92ec7505, (q31_t)0x42f5960e, (q31_t)0x92e92b74, + (q31_t)0x42f03b1e, (q31_t)0x92e5e226, (q31_t)0x42eae005, (q31_t)0x92e2991c, + (q31_t)0x42e584c3, (q31_t)0x92df5054, (q31_t)0x42e02958, (q31_t)0x92dc07d0, + (q31_t)0x42dacdc3, (q31_t)0x92d8bf90, (q31_t)0x42d57205, (q31_t)0x92d57792, + (q31_t)0x42d0161e, (q31_t)0x92d22fd9, (q31_t)0x42caba0e, (q31_t)0x92cee862, + (q31_t)0x42c55dd4, (q31_t)0x92cba12f, (q31_t)0x42c00172, (q31_t)0x92c85a3f, + (q31_t)0x42baa4e6, (q31_t)0x92c51392, (q31_t)0x42b54831, (q31_t)0x92c1cd29, + (q31_t)0x42afeb53, (q31_t)0x92be8703, (q31_t)0x42aa8e4b, (q31_t)0x92bb4121, + (q31_t)0x42a5311b, (q31_t)0x92b7fb82, (q31_t)0x429fd3c1, (q31_t)0x92b4b626, + (q31_t)0x429a763f, (q31_t)0x92b1710e, (q31_t)0x42951893, (q31_t)0x92ae2c3a, + (q31_t)0x428fbabe, (q31_t)0x92aae7a8, (q31_t)0x428a5cc0, (q31_t)0x92a7a35a, + (q31_t)0x4284fe99, (q31_t)0x92a45f50, (q31_t)0x427fa049, (q31_t)0x92a11b89, + (q31_t)0x427a41d0, (q31_t)0x929dd806, (q31_t)0x4274e32e, (q31_t)0x929a94c6, + (q31_t)0x426f8463, (q31_t)0x929751c9, (q31_t)0x426a256f, (q31_t)0x92940f10, + (q31_t)0x4264c653, (q31_t)0x9290cc9b, (q31_t)0x425f670d, (q31_t)0x928d8a69, + (q31_t)0x425a079e, (q31_t)0x928a487a, (q31_t)0x4254a806, (q31_t)0x928706cf, + (q31_t)0x424f4845, (q31_t)0x9283c568, (q31_t)0x4249e85c, (q31_t)0x92808444, + (q31_t)0x42448849, (q31_t)0x927d4363, (q31_t)0x423f280e, (q31_t)0x927a02c7, + (q31_t)0x4239c7aa, (q31_t)0x9276c26d, (q31_t)0x4234671d, (q31_t)0x92738258, + (q31_t)0x422f0667, (q31_t)0x92704286, (q31_t)0x4229a588, (q31_t)0x926d02f7, + (q31_t)0x42244481, (q31_t)0x9269c3ac, (q31_t)0x421ee350, (q31_t)0x926684a5, + (q31_t)0x421981f7, (q31_t)0x926345e1, (q31_t)0x42142075, (q31_t)0x92600761, + (q31_t)0x420ebecb, (q31_t)0x925cc924, (q31_t)0x42095cf7, (q31_t)0x92598b2b, + (q31_t)0x4203fafb, (q31_t)0x92564d76, (q31_t)0x41fe98d6, (q31_t)0x92531005, + (q31_t)0x41f93689, (q31_t)0x924fd2d7, (q31_t)0x41f3d413, (q31_t)0x924c95ec, + (q31_t)0x41ee7174, (q31_t)0x92495946, (q31_t)0x41e90eac, (q31_t)0x92461ce3, + (q31_t)0x41e3abbc, (q31_t)0x9242e0c4, (q31_t)0x41de48a3, (q31_t)0x923fa4e8, + (q31_t)0x41d8e561, (q31_t)0x923c6950, (q31_t)0x41d381f7, (q31_t)0x92392dfc, + (q31_t)0x41ce1e65, (q31_t)0x9235f2ec, (q31_t)0x41c8baa9, (q31_t)0x9232b81f, + (q31_t)0x41c356c5, (q31_t)0x922f7d96, (q31_t)0x41bdf2b9, (q31_t)0x922c4351, + (q31_t)0x41b88e84, (q31_t)0x9229094f, (q31_t)0x41b32a26, (q31_t)0x9225cf91, + (q31_t)0x41adc5a0, (q31_t)0x92229617, (q31_t)0x41a860f1, (q31_t)0x921f5ce1, + (q31_t)0x41a2fc1a, (q31_t)0x921c23ef, (q31_t)0x419d971b, (q31_t)0x9218eb40, + (q31_t)0x419831f3, (q31_t)0x9215b2d5, (q31_t)0x4192cca2, (q31_t)0x92127aae, + (q31_t)0x418d6729, (q31_t)0x920f42cb, (q31_t)0x41880188, (q31_t)0x920c0b2c, + (q31_t)0x41829bbe, (q31_t)0x9208d3d0, (q31_t)0x417d35cb, (q31_t)0x92059cb8, + (q31_t)0x4177cfb1, (q31_t)0x920265e4, (q31_t)0x4172696e, (q31_t)0x91ff2f54, + (q31_t)0x416d0302, (q31_t)0x91fbf908, (q31_t)0x41679c6f, (q31_t)0x91f8c300, + (q31_t)0x416235b2, (q31_t)0x91f58d3b, (q31_t)0x415ccece, (q31_t)0x91f257bb, + (q31_t)0x415767c1, (q31_t)0x91ef227e, (q31_t)0x4152008c, (q31_t)0x91ebed85, + (q31_t)0x414c992f, (q31_t)0x91e8b8d0, (q31_t)0x414731a9, (q31_t)0x91e5845f, + (q31_t)0x4141c9fb, (q31_t)0x91e25032, (q31_t)0x413c6225, (q31_t)0x91df1c49, + (q31_t)0x4136fa27, (q31_t)0x91dbe8a4, (q31_t)0x41319200, (q31_t)0x91d8b542, + (q31_t)0x412c29b1, (q31_t)0x91d58225, (q31_t)0x4126c13a, (q31_t)0x91d24f4c, + (q31_t)0x4121589b, (q31_t)0x91cf1cb6, (q31_t)0x411befd3, (q31_t)0x91cbea65, + (q31_t)0x411686e4, (q31_t)0x91c8b857, (q31_t)0x41111dcc, (q31_t)0x91c5868e, + (q31_t)0x410bb48c, (q31_t)0x91c25508, (q31_t)0x41064b24, (q31_t)0x91bf23c7, + (q31_t)0x4100e194, (q31_t)0x91bbf2c9, (q31_t)0x40fb77dc, (q31_t)0x91b8c210, + (q31_t)0x40f60dfb, (q31_t)0x91b5919a, (q31_t)0x40f0a3f3, (q31_t)0x91b26169, + (q31_t)0x40eb39c3, (q31_t)0x91af317c, (q31_t)0x40e5cf6a, (q31_t)0x91ac01d2, + (q31_t)0x40e064ea, (q31_t)0x91a8d26d, (q31_t)0x40dafa41, (q31_t)0x91a5a34c, + (q31_t)0x40d58f71, (q31_t)0x91a2746f, (q31_t)0x40d02478, (q31_t)0x919f45d6, + (q31_t)0x40cab958, (q31_t)0x919c1781, (q31_t)0x40c54e0f, (q31_t)0x9198e970, + (q31_t)0x40bfe29f, (q31_t)0x9195bba3, (q31_t)0x40ba7706, (q31_t)0x91928e1a, + (q31_t)0x40b50b46, (q31_t)0x918f60d6, (q31_t)0x40af9f5e, (q31_t)0x918c33d5, + (q31_t)0x40aa334e, (q31_t)0x91890719, (q31_t)0x40a4c716, (q31_t)0x9185daa1, + (q31_t)0x409f5ab6, (q31_t)0x9182ae6d, (q31_t)0x4099ee2e, (q31_t)0x917f827d, + (q31_t)0x4094817f, (q31_t)0x917c56d1, (q31_t)0x408f14a7, (q31_t)0x91792b6a, + (q31_t)0x4089a7a8, (q31_t)0x91760047, (q31_t)0x40843a81, (q31_t)0x9172d567, + (q31_t)0x407ecd32, (q31_t)0x916faacc, (q31_t)0x40795fbc, (q31_t)0x916c8076, + (q31_t)0x4073f21d, (q31_t)0x91695663, (q31_t)0x406e8457, (q31_t)0x91662c95, + (q31_t)0x40691669, (q31_t)0x9163030b, (q31_t)0x4063a854, (q31_t)0x915fd9c5, + (q31_t)0x405e3a16, (q31_t)0x915cb0c3, (q31_t)0x4058cbb1, (q31_t)0x91598806, + (q31_t)0x40535d24, (q31_t)0x91565f8d, (q31_t)0x404dee70, (q31_t)0x91533758, + (q31_t)0x40487f94, (q31_t)0x91500f67, (q31_t)0x40431090, (q31_t)0x914ce7bb, + (q31_t)0x403da165, (q31_t)0x9149c053, (q31_t)0x40383212, (q31_t)0x9146992f, + (q31_t)0x4032c297, (q31_t)0x91437250, (q31_t)0x402d52f5, (q31_t)0x91404bb5, + (q31_t)0x4027e32b, (q31_t)0x913d255e, (q31_t)0x4022733a, (q31_t)0x9139ff4b, + (q31_t)0x401d0321, (q31_t)0x9136d97d, (q31_t)0x401792e0, (q31_t)0x9133b3f3, + (q31_t)0x40122278, (q31_t)0x91308eae, (q31_t)0x400cb1e9, (q31_t)0x912d69ad, + (q31_t)0x40074132, (q31_t)0x912a44f0, (q31_t)0x4001d053, (q31_t)0x91272078, + (q31_t)0x3ffc5f4d, (q31_t)0x9123fc44, (q31_t)0x3ff6ee1f, (q31_t)0x9120d854, + (q31_t)0x3ff17cca, (q31_t)0x911db4a9, (q31_t)0x3fec0b4e, (q31_t)0x911a9142, + (q31_t)0x3fe699aa, (q31_t)0x91176e1f, (q31_t)0x3fe127df, (q31_t)0x91144b41, + (q31_t)0x3fdbb5ec, (q31_t)0x911128a8, (q31_t)0x3fd643d2, (q31_t)0x910e0653, + (q31_t)0x3fd0d191, (q31_t)0x910ae442, (q31_t)0x3fcb5f28, (q31_t)0x9107c276, + (q31_t)0x3fc5ec98, (q31_t)0x9104a0ee, (q31_t)0x3fc079e0, (q31_t)0x91017faa, + (q31_t)0x3fbb0702, (q31_t)0x90fe5eab, (q31_t)0x3fb593fb, (q31_t)0x90fb3df1, + (q31_t)0x3fb020ce, (q31_t)0x90f81d7b, (q31_t)0x3faaad79, (q31_t)0x90f4fd4a, + (q31_t)0x3fa539fd, (q31_t)0x90f1dd5d, (q31_t)0x3f9fc65a, (q31_t)0x90eebdb4, + (q31_t)0x3f9a5290, (q31_t)0x90eb9e50, (q31_t)0x3f94de9e, (q31_t)0x90e87f31, + (q31_t)0x3f8f6a85, (q31_t)0x90e56056, (q31_t)0x3f89f645, (q31_t)0x90e241bf, + (q31_t)0x3f8481dd, (q31_t)0x90df236e, (q31_t)0x3f7f0d4f, (q31_t)0x90dc0560, + (q31_t)0x3f799899, (q31_t)0x90d8e798, (q31_t)0x3f7423bc, (q31_t)0x90d5ca13, + (q31_t)0x3f6eaeb8, (q31_t)0x90d2acd4, (q31_t)0x3f69398d, (q31_t)0x90cf8fd9, + (q31_t)0x3f63c43b, (q31_t)0x90cc7322, (q31_t)0x3f5e4ec2, (q31_t)0x90c956b1, + (q31_t)0x3f58d921, (q31_t)0x90c63a83, (q31_t)0x3f53635a, (q31_t)0x90c31e9b, + (q31_t)0x3f4ded6b, (q31_t)0x90c002f7, (q31_t)0x3f487755, (q31_t)0x90bce797, + (q31_t)0x3f430119, (q31_t)0x90b9cc7d, (q31_t)0x3f3d8ab5, (q31_t)0x90b6b1a6, + (q31_t)0x3f38142a, (q31_t)0x90b39715, (q31_t)0x3f329d79, (q31_t)0x90b07cc8, + (q31_t)0x3f2d26a0, (q31_t)0x90ad62c0, (q31_t)0x3f27afa1, (q31_t)0x90aa48fd, + (q31_t)0x3f22387a, (q31_t)0x90a72f7e, (q31_t)0x3f1cc12c, (q31_t)0x90a41644, + (q31_t)0x3f1749b8, (q31_t)0x90a0fd4e, (q31_t)0x3f11d21d, (q31_t)0x909de49e, + (q31_t)0x3f0c5a5a, (q31_t)0x909acc32, (q31_t)0x3f06e271, (q31_t)0x9097b40a, + (q31_t)0x3f016a61, (q31_t)0x90949c28, (q31_t)0x3efbf22a, (q31_t)0x9091848a, + (q31_t)0x3ef679cc, (q31_t)0x908e6d31, (q31_t)0x3ef10148, (q31_t)0x908b561c, + (q31_t)0x3eeb889c, (q31_t)0x90883f4d, (q31_t)0x3ee60fca, (q31_t)0x908528c2, + (q31_t)0x3ee096d1, (q31_t)0x9082127c, (q31_t)0x3edb1db1, (q31_t)0x907efc7a, + (q31_t)0x3ed5a46b, (q31_t)0x907be6be, (q31_t)0x3ed02afd, (q31_t)0x9078d146, + (q31_t)0x3ecab169, (q31_t)0x9075bc13, (q31_t)0x3ec537ae, (q31_t)0x9072a725, + (q31_t)0x3ebfbdcd, (q31_t)0x906f927c, (q31_t)0x3eba43c4, (q31_t)0x906c7e17, + (q31_t)0x3eb4c995, (q31_t)0x906969f8, (q31_t)0x3eaf4f40, (q31_t)0x9066561d, + (q31_t)0x3ea9d4c3, (q31_t)0x90634287, (q31_t)0x3ea45a21, (q31_t)0x90602f35, + (q31_t)0x3e9edf57, (q31_t)0x905d1c29, (q31_t)0x3e996467, (q31_t)0x905a0962, + (q31_t)0x3e93e950, (q31_t)0x9056f6df, (q31_t)0x3e8e6e12, (q31_t)0x9053e4a1, + (q31_t)0x3e88f2ae, (q31_t)0x9050d2a9, (q31_t)0x3e837724, (q31_t)0x904dc0f5, + (q31_t)0x3e7dfb73, (q31_t)0x904aaf86, (q31_t)0x3e787f9b, (q31_t)0x90479e5c, + (q31_t)0x3e73039d, (q31_t)0x90448d76, (q31_t)0x3e6d8778, (q31_t)0x90417cd6, + (q31_t)0x3e680b2c, (q31_t)0x903e6c7b, (q31_t)0x3e628ebb, (q31_t)0x903b5c64, + (q31_t)0x3e5d1222, (q31_t)0x90384c93, (q31_t)0x3e579564, (q31_t)0x90353d06, + (q31_t)0x3e52187f, (q31_t)0x90322dbf, (q31_t)0x3e4c9b73, (q31_t)0x902f1ebc, + (q31_t)0x3e471e41, (q31_t)0x902c0fff, (q31_t)0x3e41a0e8, (q31_t)0x90290186, + (q31_t)0x3e3c2369, (q31_t)0x9025f352, (q31_t)0x3e36a5c4, (q31_t)0x9022e564, + (q31_t)0x3e3127f9, (q31_t)0x901fd7ba, (q31_t)0x3e2baa07, (q31_t)0x901cca55, + (q31_t)0x3e262bee, (q31_t)0x9019bd36, (q31_t)0x3e20adaf, (q31_t)0x9016b05b, + (q31_t)0x3e1b2f4a, (q31_t)0x9013a3c5, (q31_t)0x3e15b0bf, (q31_t)0x90109775, + (q31_t)0x3e10320d, (q31_t)0x900d8b69, (q31_t)0x3e0ab336, (q31_t)0x900a7fa3, + (q31_t)0x3e053437, (q31_t)0x90077422, (q31_t)0x3dffb513, (q31_t)0x900468e5, + (q31_t)0x3dfa35c8, (q31_t)0x90015dee, (q31_t)0x3df4b657, (q31_t)0x8ffe533c, + (q31_t)0x3def36c0, (q31_t)0x8ffb48cf, (q31_t)0x3de9b703, (q31_t)0x8ff83ea7, + (q31_t)0x3de4371f, (q31_t)0x8ff534c4, (q31_t)0x3ddeb716, (q31_t)0x8ff22b26, + (q31_t)0x3dd936e6, (q31_t)0x8fef21ce, (q31_t)0x3dd3b690, (q31_t)0x8fec18ba, + (q31_t)0x3dce3614, (q31_t)0x8fe90fec, (q31_t)0x3dc8b571, (q31_t)0x8fe60763, + (q31_t)0x3dc334a9, (q31_t)0x8fe2ff1f, (q31_t)0x3dbdb3ba, (q31_t)0x8fdff720, + (q31_t)0x3db832a6, (q31_t)0x8fdcef66, (q31_t)0x3db2b16b, (q31_t)0x8fd9e7f2, + (q31_t)0x3dad300b, (q31_t)0x8fd6e0c2, (q31_t)0x3da7ae84, (q31_t)0x8fd3d9d8, + (q31_t)0x3da22cd7, (q31_t)0x8fd0d333, (q31_t)0x3d9cab04, (q31_t)0x8fcdccd3, + (q31_t)0x3d97290b, (q31_t)0x8fcac6b9, (q31_t)0x3d91a6ed, (q31_t)0x8fc7c0e3, + (q31_t)0x3d8c24a8, (q31_t)0x8fc4bb53, (q31_t)0x3d86a23d, (q31_t)0x8fc1b608, + (q31_t)0x3d811fac, (q31_t)0x8fbeb103, (q31_t)0x3d7b9cf6, (q31_t)0x8fbbac42, + (q31_t)0x3d761a19, (q31_t)0x8fb8a7c7, (q31_t)0x3d709717, (q31_t)0x8fb5a391, + (q31_t)0x3d6b13ee, (q31_t)0x8fb29fa0, (q31_t)0x3d6590a0, (q31_t)0x8faf9bf5, + (q31_t)0x3d600d2c, (q31_t)0x8fac988f, (q31_t)0x3d5a8992, (q31_t)0x8fa9956e, + (q31_t)0x3d5505d2, (q31_t)0x8fa69293, (q31_t)0x3d4f81ec, (q31_t)0x8fa38ffc, + (q31_t)0x3d49fde1, (q31_t)0x8fa08dab, (q31_t)0x3d4479b0, (q31_t)0x8f9d8ba0, + (q31_t)0x3d3ef559, (q31_t)0x8f9a89da, (q31_t)0x3d3970dc, (q31_t)0x8f978859, + (q31_t)0x3d33ec39, (q31_t)0x8f94871d, (q31_t)0x3d2e6771, (q31_t)0x8f918627, + (q31_t)0x3d28e282, (q31_t)0x8f8e8576, (q31_t)0x3d235d6f, (q31_t)0x8f8b850a, + (q31_t)0x3d1dd835, (q31_t)0x8f8884e4, (q31_t)0x3d1852d6, (q31_t)0x8f858503, + (q31_t)0x3d12cd51, (q31_t)0x8f828568, (q31_t)0x3d0d47a6, (q31_t)0x8f7f8612, + (q31_t)0x3d07c1d6, (q31_t)0x8f7c8701, (q31_t)0x3d023be0, (q31_t)0x8f798836, + (q31_t)0x3cfcb5c4, (q31_t)0x8f7689b0, (q31_t)0x3cf72f83, (q31_t)0x8f738b70, + (q31_t)0x3cf1a91c, (q31_t)0x8f708d75, (q31_t)0x3cec2290, (q31_t)0x8f6d8fbf, + (q31_t)0x3ce69bde, (q31_t)0x8f6a924f, (q31_t)0x3ce11507, (q31_t)0x8f679525, + (q31_t)0x3cdb8e09, (q31_t)0x8f649840, (q31_t)0x3cd606e7, (q31_t)0x8f619ba0, + (q31_t)0x3cd07f9f, (q31_t)0x8f5e9f46, (q31_t)0x3ccaf831, (q31_t)0x8f5ba331, + (q31_t)0x3cc5709e, (q31_t)0x8f58a761, (q31_t)0x3cbfe8e5, (q31_t)0x8f55abd8, + (q31_t)0x3cba6107, (q31_t)0x8f52b093, (q31_t)0x3cb4d904, (q31_t)0x8f4fb595, + (q31_t)0x3caf50da, (q31_t)0x8f4cbadb, (q31_t)0x3ca9c88c, (q31_t)0x8f49c067, + (q31_t)0x3ca44018, (q31_t)0x8f46c639, (q31_t)0x3c9eb77f, (q31_t)0x8f43cc50, + (q31_t)0x3c992ec0, (q31_t)0x8f40d2ad, (q31_t)0x3c93a5dc, (q31_t)0x8f3dd950, + (q31_t)0x3c8e1cd3, (q31_t)0x8f3ae038, (q31_t)0x3c8893a4, (q31_t)0x8f37e765, + (q31_t)0x3c830a50, (q31_t)0x8f34eed8, (q31_t)0x3c7d80d6, (q31_t)0x8f31f691, + (q31_t)0x3c77f737, (q31_t)0x8f2efe8f, (q31_t)0x3c726d73, (q31_t)0x8f2c06d3, + (q31_t)0x3c6ce38a, (q31_t)0x8f290f5c, (q31_t)0x3c67597b, (q31_t)0x8f26182b, + (q31_t)0x3c61cf48, (q31_t)0x8f232140, (q31_t)0x3c5c44ee, (q31_t)0x8f202a9a, + (q31_t)0x3c56ba70, (q31_t)0x8f1d343a, (q31_t)0x3c512fcc, (q31_t)0x8f1a3e1f, + (q31_t)0x3c4ba504, (q31_t)0x8f17484b, (q31_t)0x3c461a16, (q31_t)0x8f1452bb, + (q31_t)0x3c408f03, (q31_t)0x8f115d72, (q31_t)0x3c3b03ca, (q31_t)0x8f0e686e, + (q31_t)0x3c35786d, (q31_t)0x8f0b73b0, (q31_t)0x3c2fecea, (q31_t)0x8f087f37, + (q31_t)0x3c2a6142, (q31_t)0x8f058b04, (q31_t)0x3c24d575, (q31_t)0x8f029717, + (q31_t)0x3c1f4983, (q31_t)0x8effa370, (q31_t)0x3c19bd6c, (q31_t)0x8efcb00e, + (q31_t)0x3c143130, (q31_t)0x8ef9bcf2, (q31_t)0x3c0ea4cf, (q31_t)0x8ef6ca1c, + (q31_t)0x3c091849, (q31_t)0x8ef3d78b, (q31_t)0x3c038b9e, (q31_t)0x8ef0e540, + (q31_t)0x3bfdfecd, (q31_t)0x8eedf33b, (q31_t)0x3bf871d8, (q31_t)0x8eeb017c, + (q31_t)0x3bf2e4be, (q31_t)0x8ee81002, (q31_t)0x3bed577e, (q31_t)0x8ee51ece, + (q31_t)0x3be7ca1a, (q31_t)0x8ee22de0, (q31_t)0x3be23c91, (q31_t)0x8edf3d38, + (q31_t)0x3bdcaee3, (q31_t)0x8edc4cd5, (q31_t)0x3bd72110, (q31_t)0x8ed95cb8, + (q31_t)0x3bd19318, (q31_t)0x8ed66ce1, (q31_t)0x3bcc04fb, (q31_t)0x8ed37d50, + (q31_t)0x3bc676b9, (q31_t)0x8ed08e05, (q31_t)0x3bc0e853, (q31_t)0x8ecd9eff, + (q31_t)0x3bbb59c7, (q31_t)0x8ecab040, (q31_t)0x3bb5cb17, (q31_t)0x8ec7c1c6, + (q31_t)0x3bb03c42, (q31_t)0x8ec4d392, (q31_t)0x3baaad48, (q31_t)0x8ec1e5a4, + (q31_t)0x3ba51e29, (q31_t)0x8ebef7fb, (q31_t)0x3b9f8ee5, (q31_t)0x8ebc0a99, + (q31_t)0x3b99ff7d, (q31_t)0x8eb91d7c, (q31_t)0x3b946ff0, (q31_t)0x8eb630a6, + (q31_t)0x3b8ee03e, (q31_t)0x8eb34415, (q31_t)0x3b895068, (q31_t)0x8eb057ca, + (q31_t)0x3b83c06c, (q31_t)0x8ead6bc5, (q31_t)0x3b7e304c, (q31_t)0x8eaa8006, + (q31_t)0x3b78a007, (q31_t)0x8ea7948c, (q31_t)0x3b730f9e, (q31_t)0x8ea4a959, + (q31_t)0x3b6d7f10, (q31_t)0x8ea1be6c, (q31_t)0x3b67ee5d, (q31_t)0x8e9ed3c4, + (q31_t)0x3b625d86, (q31_t)0x8e9be963, (q31_t)0x3b5ccc8a, (q31_t)0x8e98ff47, + (q31_t)0x3b573b69, (q31_t)0x8e961571, (q31_t)0x3b51aa24, (q31_t)0x8e932be2, + (q31_t)0x3b4c18ba, (q31_t)0x8e904298, (q31_t)0x3b46872c, (q31_t)0x8e8d5994, + (q31_t)0x3b40f579, (q31_t)0x8e8a70d7, (q31_t)0x3b3b63a1, (q31_t)0x8e87885f, + (q31_t)0x3b35d1a5, (q31_t)0x8e84a02d, (q31_t)0x3b303f84, (q31_t)0x8e81b841, + (q31_t)0x3b2aad3f, (q31_t)0x8e7ed09b, (q31_t)0x3b251ad6, (q31_t)0x8e7be93c, + (q31_t)0x3b1f8848, (q31_t)0x8e790222, (q31_t)0x3b19f595, (q31_t)0x8e761b4e, + (q31_t)0x3b1462be, (q31_t)0x8e7334c1, (q31_t)0x3b0ecfc3, (q31_t)0x8e704e79, + (q31_t)0x3b093ca3, (q31_t)0x8e6d6877, (q31_t)0x3b03a95e, (q31_t)0x8e6a82bc, + (q31_t)0x3afe15f6, (q31_t)0x8e679d47, (q31_t)0x3af88269, (q31_t)0x8e64b817, + (q31_t)0x3af2eeb7, (q31_t)0x8e61d32e, (q31_t)0x3aed5ae1, (q31_t)0x8e5eee8b, + (q31_t)0x3ae7c6e7, (q31_t)0x8e5c0a2e, (q31_t)0x3ae232c9, (q31_t)0x8e592617, + (q31_t)0x3adc9e86, (q31_t)0x8e564246, (q31_t)0x3ad70a1f, (q31_t)0x8e535ebb, + (q31_t)0x3ad17593, (q31_t)0x8e507b76, (q31_t)0x3acbe0e3, (q31_t)0x8e4d9878, + (q31_t)0x3ac64c0f, (q31_t)0x8e4ab5bf, (q31_t)0x3ac0b717, (q31_t)0x8e47d34d, + (q31_t)0x3abb21fb, (q31_t)0x8e44f121, (q31_t)0x3ab58cba, (q31_t)0x8e420f3b, + (q31_t)0x3aaff755, (q31_t)0x8e3f2d9b, (q31_t)0x3aaa61cc, (q31_t)0x8e3c4c41, + (q31_t)0x3aa4cc1e, (q31_t)0x8e396b2e, (q31_t)0x3a9f364d, (q31_t)0x8e368a61, + (q31_t)0x3a99a057, (q31_t)0x8e33a9da, (q31_t)0x3a940a3e, (q31_t)0x8e30c999, + (q31_t)0x3a8e7400, (q31_t)0x8e2de99e, (q31_t)0x3a88dd9d, (q31_t)0x8e2b09e9, + (q31_t)0x3a834717, (q31_t)0x8e282a7b, (q31_t)0x3a7db06d, (q31_t)0x8e254b53, + (q31_t)0x3a78199f, (q31_t)0x8e226c71, (q31_t)0x3a7282ac, (q31_t)0x8e1f8dd6, + (q31_t)0x3a6ceb96, (q31_t)0x8e1caf80, (q31_t)0x3a67545b, (q31_t)0x8e19d171, + (q31_t)0x3a61bcfd, (q31_t)0x8e16f3a9, (q31_t)0x3a5c257a, (q31_t)0x8e141626, + (q31_t)0x3a568dd4, (q31_t)0x8e1138ea, (q31_t)0x3a50f609, (q31_t)0x8e0e5bf4, + (q31_t)0x3a4b5e1b, (q31_t)0x8e0b7f44, (q31_t)0x3a45c608, (q31_t)0x8e08a2db, + (q31_t)0x3a402dd2, (q31_t)0x8e05c6b7, (q31_t)0x3a3a9577, (q31_t)0x8e02eadb, + (q31_t)0x3a34fcf9, (q31_t)0x8e000f44, (q31_t)0x3a2f6457, (q31_t)0x8dfd33f4, + (q31_t)0x3a29cb91, (q31_t)0x8dfa58ea, (q31_t)0x3a2432a7, (q31_t)0x8df77e27, + (q31_t)0x3a1e9999, (q31_t)0x8df4a3a9, (q31_t)0x3a190068, (q31_t)0x8df1c973, + (q31_t)0x3a136712, (q31_t)0x8deeef82, (q31_t)0x3a0dcd99, (q31_t)0x8dec15d8, + (q31_t)0x3a0833fc, (q31_t)0x8de93c74, (q31_t)0x3a029a3b, (q31_t)0x8de66357, + (q31_t)0x39fd0056, (q31_t)0x8de38a80, (q31_t)0x39f7664e, (q31_t)0x8de0b1ef, + (q31_t)0x39f1cc21, (q31_t)0x8dddd9a5, (q31_t)0x39ec31d1, (q31_t)0x8ddb01a1, + (q31_t)0x39e6975e, (q31_t)0x8dd829e4, (q31_t)0x39e0fcc6, (q31_t)0x8dd5526d, + (q31_t)0x39db620b, (q31_t)0x8dd27b3c, (q31_t)0x39d5c72c, (q31_t)0x8dcfa452, + (q31_t)0x39d02c2a, (q31_t)0x8dcccdaf, (q31_t)0x39ca9104, (q31_t)0x8dc9f751, + (q31_t)0x39c4f5ba, (q31_t)0x8dc7213b, (q31_t)0x39bf5a4d, (q31_t)0x8dc44b6a, + (q31_t)0x39b9bebc, (q31_t)0x8dc175e0, (q31_t)0x39b42307, (q31_t)0x8dbea09d, + (q31_t)0x39ae872f, (q31_t)0x8dbbcba0, (q31_t)0x39a8eb33, (q31_t)0x8db8f6ea, + (q31_t)0x39a34f13, (q31_t)0x8db6227a, (q31_t)0x399db2d0, (q31_t)0x8db34e50, + (q31_t)0x3998166a, (q31_t)0x8db07a6d, (q31_t)0x399279e0, (q31_t)0x8dada6d1, + (q31_t)0x398cdd32, (q31_t)0x8daad37b, (q31_t)0x39874061, (q31_t)0x8da8006c, + (q31_t)0x3981a36d, (q31_t)0x8da52da3, (q31_t)0x397c0655, (q31_t)0x8da25b21, + (q31_t)0x39766919, (q31_t)0x8d9f88e5, (q31_t)0x3970cbba, (q31_t)0x8d9cb6f0, + (q31_t)0x396b2e38, (q31_t)0x8d99e541, (q31_t)0x39659092, (q31_t)0x8d9713d9, + (q31_t)0x395ff2c9, (q31_t)0x8d9442b8, (q31_t)0x395a54dd, (q31_t)0x8d9171dd, + (q31_t)0x3954b6cd, (q31_t)0x8d8ea148, (q31_t)0x394f1899, (q31_t)0x8d8bd0fb, + (q31_t)0x39497a43, (q31_t)0x8d8900f3, (q31_t)0x3943dbc9, (q31_t)0x8d863133, + (q31_t)0x393e3d2c, (q31_t)0x8d8361b9, (q31_t)0x39389e6b, (q31_t)0x8d809286, + (q31_t)0x3932ff87, (q31_t)0x8d7dc399, (q31_t)0x392d6080, (q31_t)0x8d7af4f3, + (q31_t)0x3927c155, (q31_t)0x8d782694, (q31_t)0x39222208, (q31_t)0x8d75587b, + (q31_t)0x391c8297, (q31_t)0x8d728aa9, (q31_t)0x3916e303, (q31_t)0x8d6fbd1d, + (q31_t)0x3911434b, (q31_t)0x8d6cefd9, (q31_t)0x390ba371, (q31_t)0x8d6a22db, + (q31_t)0x39060373, (q31_t)0x8d675623, (q31_t)0x39006352, (q31_t)0x8d6489b3, + (q31_t)0x38fac30e, (q31_t)0x8d61bd89, (q31_t)0x38f522a6, (q31_t)0x8d5ef1a5, + (q31_t)0x38ef821c, (q31_t)0x8d5c2609, (q31_t)0x38e9e16e, (q31_t)0x8d595ab3, + (q31_t)0x38e4409e, (q31_t)0x8d568fa4, (q31_t)0x38de9faa, (q31_t)0x8d53c4db, + (q31_t)0x38d8fe93, (q31_t)0x8d50fa59, (q31_t)0x38d35d59, (q31_t)0x8d4e301f, + (q31_t)0x38cdbbfc, (q31_t)0x8d4b662a, (q31_t)0x38c81a7c, (q31_t)0x8d489c7d, + (q31_t)0x38c278d9, (q31_t)0x8d45d316, (q31_t)0x38bcd713, (q31_t)0x8d4309f6, + (q31_t)0x38b7352a, (q31_t)0x8d40411d, (q31_t)0x38b1931e, (q31_t)0x8d3d788b, + (q31_t)0x38abf0ef, (q31_t)0x8d3ab03f, (q31_t)0x38a64e9d, (q31_t)0x8d37e83a, + (q31_t)0x38a0ac29, (q31_t)0x8d35207d, (q31_t)0x389b0991, (q31_t)0x8d325905, + (q31_t)0x389566d6, (q31_t)0x8d2f91d5, (q31_t)0x388fc3f8, (q31_t)0x8d2ccaec, + (q31_t)0x388a20f8, (q31_t)0x8d2a0449, (q31_t)0x38847dd5, (q31_t)0x8d273ded, + (q31_t)0x387eda8e, (q31_t)0x8d2477d8, (q31_t)0x38793725, (q31_t)0x8d21b20a, + (q31_t)0x38739399, (q31_t)0x8d1eec83, (q31_t)0x386defeb, (q31_t)0x8d1c2742, + (q31_t)0x38684c19, (q31_t)0x8d196249, (q31_t)0x3862a825, (q31_t)0x8d169d96, + (q31_t)0x385d040d, (q31_t)0x8d13d92a, (q31_t)0x38575fd4, (q31_t)0x8d111505, + (q31_t)0x3851bb77, (q31_t)0x8d0e5127, (q31_t)0x384c16f7, (q31_t)0x8d0b8d90, + (q31_t)0x38467255, (q31_t)0x8d08ca40, (q31_t)0x3840cd90, (q31_t)0x8d060737, + (q31_t)0x383b28a9, (q31_t)0x8d034474, (q31_t)0x3835839f, (q31_t)0x8d0081f9, + (q31_t)0x382fde72, (q31_t)0x8cfdbfc4, (q31_t)0x382a3922, (q31_t)0x8cfafdd7, + (q31_t)0x382493b0, (q31_t)0x8cf83c30, (q31_t)0x381eee1b, (q31_t)0x8cf57ad0, + (q31_t)0x38194864, (q31_t)0x8cf2b9b8, (q31_t)0x3813a28a, (q31_t)0x8ceff8e6, + (q31_t)0x380dfc8d, (q31_t)0x8ced385b, (q31_t)0x3808566e, (q31_t)0x8cea7818, + (q31_t)0x3802b02c, (q31_t)0x8ce7b81b, (q31_t)0x37fd09c8, (q31_t)0x8ce4f865, + (q31_t)0x37f76341, (q31_t)0x8ce238f6, (q31_t)0x37f1bc97, (q31_t)0x8cdf79ce, + (q31_t)0x37ec15cb, (q31_t)0x8cdcbaee, (q31_t)0x37e66edd, (q31_t)0x8cd9fc54, + (q31_t)0x37e0c7cc, (q31_t)0x8cd73e01, (q31_t)0x37db2099, (q31_t)0x8cd47ff6, + (q31_t)0x37d57943, (q31_t)0x8cd1c231, (q31_t)0x37cfd1cb, (q31_t)0x8ccf04b3, + (q31_t)0x37ca2a30, (q31_t)0x8ccc477d, (q31_t)0x37c48273, (q31_t)0x8cc98a8e, + (q31_t)0x37beda93, (q31_t)0x8cc6cde5, (q31_t)0x37b93292, (q31_t)0x8cc41184, + (q31_t)0x37b38a6d, (q31_t)0x8cc1556a, (q31_t)0x37ade227, (q31_t)0x8cbe9996, + (q31_t)0x37a839be, (q31_t)0x8cbbde0a, (q31_t)0x37a29132, (q31_t)0x8cb922c6, + (q31_t)0x379ce885, (q31_t)0x8cb667c8, (q31_t)0x37973fb5, (q31_t)0x8cb3ad11, + (q31_t)0x379196c3, (q31_t)0x8cb0f2a1, (q31_t)0x378bedae, (q31_t)0x8cae3879, + (q31_t)0x37864477, (q31_t)0x8cab7e98, (q31_t)0x37809b1e, (q31_t)0x8ca8c4fd, + (q31_t)0x377af1a3, (q31_t)0x8ca60baa, (q31_t)0x37754806, (q31_t)0x8ca3529f, + (q31_t)0x376f9e46, (q31_t)0x8ca099da, (q31_t)0x3769f464, (q31_t)0x8c9de15c, + (q31_t)0x37644a60, (q31_t)0x8c9b2926, (q31_t)0x375ea03a, (q31_t)0x8c987137, + (q31_t)0x3758f5f2, (q31_t)0x8c95b98f, (q31_t)0x37534b87, (q31_t)0x8c93022e, + (q31_t)0x374da0fa, (q31_t)0x8c904b14, (q31_t)0x3747f64c, (q31_t)0x8c8d9442, + (q31_t)0x37424b7b, (q31_t)0x8c8addb7, (q31_t)0x373ca088, (q31_t)0x8c882773, + (q31_t)0x3736f573, (q31_t)0x8c857176, (q31_t)0x37314a3c, (q31_t)0x8c82bbc0, + (q31_t)0x372b9ee3, (q31_t)0x8c800652, (q31_t)0x3725f367, (q31_t)0x8c7d512b, + (q31_t)0x372047ca, (q31_t)0x8c7a9c4b, (q31_t)0x371a9c0b, (q31_t)0x8c77e7b3, + (q31_t)0x3714f02a, (q31_t)0x8c753362, (q31_t)0x370f4427, (q31_t)0x8c727f58, + (q31_t)0x37099802, (q31_t)0x8c6fcb95, (q31_t)0x3703ebbb, (q31_t)0x8c6d181a, + (q31_t)0x36fe3f52, (q31_t)0x8c6a64e5, (q31_t)0x36f892c7, (q31_t)0x8c67b1f9, + (q31_t)0x36f2e61a, (q31_t)0x8c64ff53, (q31_t)0x36ed394b, (q31_t)0x8c624cf5, + (q31_t)0x36e78c5b, (q31_t)0x8c5f9ade, (q31_t)0x36e1df48, (q31_t)0x8c5ce90e, + (q31_t)0x36dc3214, (q31_t)0x8c5a3786, (q31_t)0x36d684be, (q31_t)0x8c578645, + (q31_t)0x36d0d746, (q31_t)0x8c54d54c, (q31_t)0x36cb29ac, (q31_t)0x8c522499, + (q31_t)0x36c57bf0, (q31_t)0x8c4f742f, (q31_t)0x36bfce13, (q31_t)0x8c4cc40b, + (q31_t)0x36ba2014, (q31_t)0x8c4a142f, (q31_t)0x36b471f3, (q31_t)0x8c47649a, + (q31_t)0x36aec3b0, (q31_t)0x8c44b54d, (q31_t)0x36a9154c, (q31_t)0x8c420647, + (q31_t)0x36a366c6, (q31_t)0x8c3f5788, (q31_t)0x369db81e, (q31_t)0x8c3ca911, + (q31_t)0x36980954, (q31_t)0x8c39fae1, (q31_t)0x36925a69, (q31_t)0x8c374cf9, + (q31_t)0x368cab5c, (q31_t)0x8c349f58, (q31_t)0x3686fc2e, (q31_t)0x8c31f1ff, + (q31_t)0x36814cde, (q31_t)0x8c2f44ed, (q31_t)0x367b9d6c, (q31_t)0x8c2c9822, + (q31_t)0x3675edd9, (q31_t)0x8c29eb9f, (q31_t)0x36703e24, (q31_t)0x8c273f63, + (q31_t)0x366a8e4d, (q31_t)0x8c24936f, (q31_t)0x3664de55, (q31_t)0x8c21e7c2, + (q31_t)0x365f2e3b, (q31_t)0x8c1f3c5d, (q31_t)0x36597e00, (q31_t)0x8c1c913f, + (q31_t)0x3653cda3, (q31_t)0x8c19e669, (q31_t)0x364e1d25, (q31_t)0x8c173bda, + (q31_t)0x36486c86, (q31_t)0x8c149192, (q31_t)0x3642bbc4, (q31_t)0x8c11e792, + (q31_t)0x363d0ae2, (q31_t)0x8c0f3dda, (q31_t)0x363759de, (q31_t)0x8c0c9469, + (q31_t)0x3631a8b8, (q31_t)0x8c09eb40, (q31_t)0x362bf771, (q31_t)0x8c07425e, + (q31_t)0x36264609, (q31_t)0x8c0499c4, (q31_t)0x3620947f, (q31_t)0x8c01f171, + (q31_t)0x361ae2d3, (q31_t)0x8bff4966, (q31_t)0x36153107, (q31_t)0x8bfca1a3, + (q31_t)0x360f7f19, (q31_t)0x8bf9fa27, (q31_t)0x3609cd0a, (q31_t)0x8bf752f2, + (q31_t)0x36041ad9, (q31_t)0x8bf4ac05, (q31_t)0x35fe6887, (q31_t)0x8bf20560, + (q31_t)0x35f8b614, (q31_t)0x8bef5f02, (q31_t)0x35f3037f, (q31_t)0x8becb8ec, + (q31_t)0x35ed50c9, (q31_t)0x8bea131e, (q31_t)0x35e79df2, (q31_t)0x8be76d97, + (q31_t)0x35e1eafa, (q31_t)0x8be4c857, (q31_t)0x35dc37e0, (q31_t)0x8be22360, + (q31_t)0x35d684a6, (q31_t)0x8bdf7eb0, (q31_t)0x35d0d14a, (q31_t)0x8bdcda47, + (q31_t)0x35cb1dcc, (q31_t)0x8bda3626, (q31_t)0x35c56a2e, (q31_t)0x8bd7924d, + (q31_t)0x35bfb66e, (q31_t)0x8bd4eebc, (q31_t)0x35ba028e, (q31_t)0x8bd24b72, + (q31_t)0x35b44e8c, (q31_t)0x8bcfa870, (q31_t)0x35ae9a69, (q31_t)0x8bcd05b5, + (q31_t)0x35a8e625, (q31_t)0x8bca6343, (q31_t)0x35a331c0, (q31_t)0x8bc7c117, + (q31_t)0x359d7d39, (q31_t)0x8bc51f34, (q31_t)0x3597c892, (q31_t)0x8bc27d98, + (q31_t)0x359213c9, (q31_t)0x8bbfdc44, (q31_t)0x358c5ee0, (q31_t)0x8bbd3b38, + (q31_t)0x3586a9d5, (q31_t)0x8bba9a73, (q31_t)0x3580f4aa, (q31_t)0x8bb7f9f6, + (q31_t)0x357b3f5d, (q31_t)0x8bb559c1, (q31_t)0x357589f0, (q31_t)0x8bb2b9d4, + (q31_t)0x356fd461, (q31_t)0x8bb01a2e, (q31_t)0x356a1eb2, (q31_t)0x8bad7ad0, + (q31_t)0x356468e2, (q31_t)0x8baadbba, (q31_t)0x355eb2f0, (q31_t)0x8ba83cec, + (q31_t)0x3558fcde, (q31_t)0x8ba59e65, (q31_t)0x355346ab, (q31_t)0x8ba30026, + (q31_t)0x354d9057, (q31_t)0x8ba0622f, (q31_t)0x3547d9e2, (q31_t)0x8b9dc480, + (q31_t)0x3542234c, (q31_t)0x8b9b2718, (q31_t)0x353c6c95, (q31_t)0x8b9889f8, + (q31_t)0x3536b5be, (q31_t)0x8b95ed21, (q31_t)0x3530fec6, (q31_t)0x8b935090, + (q31_t)0x352b47ad, (q31_t)0x8b90b448, (q31_t)0x35259073, (q31_t)0x8b8e1848, + (q31_t)0x351fd918, (q31_t)0x8b8b7c8f, (q31_t)0x351a219c, (q31_t)0x8b88e11e, + (q31_t)0x35146a00, (q31_t)0x8b8645f5, (q31_t)0x350eb243, (q31_t)0x8b83ab14, + (q31_t)0x3508fa66, (q31_t)0x8b81107b, (q31_t)0x35034267, (q31_t)0x8b7e7629, + (q31_t)0x34fd8a48, (q31_t)0x8b7bdc20, (q31_t)0x34f7d208, (q31_t)0x8b79425e, + (q31_t)0x34f219a8, (q31_t)0x8b76a8e4, (q31_t)0x34ec6127, (q31_t)0x8b740fb3, + (q31_t)0x34e6a885, (q31_t)0x8b7176c8, (q31_t)0x34e0efc2, (q31_t)0x8b6ede26, + (q31_t)0x34db36df, (q31_t)0x8b6c45cc, (q31_t)0x34d57ddc, (q31_t)0x8b69adba, + (q31_t)0x34cfc4b7, (q31_t)0x8b6715ef, (q31_t)0x34ca0b73, (q31_t)0x8b647e6d, + (q31_t)0x34c4520d, (q31_t)0x8b61e733, (q31_t)0x34be9887, (q31_t)0x8b5f5040, + (q31_t)0x34b8dee1, (q31_t)0x8b5cb995, (q31_t)0x34b3251a, (q31_t)0x8b5a2333, + (q31_t)0x34ad6b32, (q31_t)0x8b578d18, (q31_t)0x34a7b12a, (q31_t)0x8b54f745, + (q31_t)0x34a1f702, (q31_t)0x8b5261ba, (q31_t)0x349c3cb9, (q31_t)0x8b4fcc77, + (q31_t)0x34968250, (q31_t)0x8b4d377c, (q31_t)0x3490c7c6, (q31_t)0x8b4aa2ca, + (q31_t)0x348b0d1c, (q31_t)0x8b480e5f, (q31_t)0x34855251, (q31_t)0x8b457a3c, + (q31_t)0x347f9766, (q31_t)0x8b42e661, (q31_t)0x3479dc5b, (q31_t)0x8b4052ce, + (q31_t)0x3474212f, (q31_t)0x8b3dbf83, (q31_t)0x346e65e3, (q31_t)0x8b3b2c80, + (q31_t)0x3468aa76, (q31_t)0x8b3899c6, (q31_t)0x3462eee9, (q31_t)0x8b360753, + (q31_t)0x345d333c, (q31_t)0x8b337528, (q31_t)0x3457776f, (q31_t)0x8b30e345, + (q31_t)0x3451bb81, (q31_t)0x8b2e51ab, (q31_t)0x344bff73, (q31_t)0x8b2bc058, + (q31_t)0x34464345, (q31_t)0x8b292f4e, (q31_t)0x344086f6, (q31_t)0x8b269e8b, + (q31_t)0x343aca87, (q31_t)0x8b240e11, (q31_t)0x34350df8, (q31_t)0x8b217ddf, + (q31_t)0x342f5149, (q31_t)0x8b1eedf4, (q31_t)0x3429947a, (q31_t)0x8b1c5e52, + (q31_t)0x3423d78a, (q31_t)0x8b19cef8, (q31_t)0x341e1a7b, (q31_t)0x8b173fe6, + (q31_t)0x34185d4b, (q31_t)0x8b14b11d, (q31_t)0x34129ffb, (q31_t)0x8b12229b, + (q31_t)0x340ce28b, (q31_t)0x8b0f9462, (q31_t)0x340724fb, (q31_t)0x8b0d0670, + (q31_t)0x3401674a, (q31_t)0x8b0a78c7, (q31_t)0x33fba97a, (q31_t)0x8b07eb66, + (q31_t)0x33f5eb89, (q31_t)0x8b055e4d, (q31_t)0x33f02d79, (q31_t)0x8b02d17c, + (q31_t)0x33ea6f48, (q31_t)0x8b0044f3, (q31_t)0x33e4b0f8, (q31_t)0x8afdb8b3, + (q31_t)0x33def287, (q31_t)0x8afb2cbb, (q31_t)0x33d933f7, (q31_t)0x8af8a10b, + (q31_t)0x33d37546, (q31_t)0x8af615a3, (q31_t)0x33cdb676, (q31_t)0x8af38a83, + (q31_t)0x33c7f785, (q31_t)0x8af0ffac, (q31_t)0x33c23875, (q31_t)0x8aee751c, + (q31_t)0x33bc7944, (q31_t)0x8aebead5, (q31_t)0x33b6b9f4, (q31_t)0x8ae960d6, + (q31_t)0x33b0fa84, (q31_t)0x8ae6d720, (q31_t)0x33ab3af4, (q31_t)0x8ae44db1, + (q31_t)0x33a57b44, (q31_t)0x8ae1c48b, (q31_t)0x339fbb74, (q31_t)0x8adf3bad, + (q31_t)0x3399fb85, (q31_t)0x8adcb318, (q31_t)0x33943b75, (q31_t)0x8ada2aca, + (q31_t)0x338e7b46, (q31_t)0x8ad7a2c5, (q31_t)0x3388baf7, (q31_t)0x8ad51b08, + (q31_t)0x3382fa88, (q31_t)0x8ad29394, (q31_t)0x337d39f9, (q31_t)0x8ad00c67, + (q31_t)0x3377794b, (q31_t)0x8acd8583, (q31_t)0x3371b87d, (q31_t)0x8acafee8, + (q31_t)0x336bf78f, (q31_t)0x8ac87894, (q31_t)0x33663682, (q31_t)0x8ac5f289, + (q31_t)0x33607554, (q31_t)0x8ac36cc6, (q31_t)0x335ab407, (q31_t)0x8ac0e74c, + (q31_t)0x3354f29b, (q31_t)0x8abe6219, (q31_t)0x334f310e, (q31_t)0x8abbdd30, + (q31_t)0x33496f62, (q31_t)0x8ab9588e, (q31_t)0x3343ad97, (q31_t)0x8ab6d435, + (q31_t)0x333debab, (q31_t)0x8ab45024, (q31_t)0x333829a1, (q31_t)0x8ab1cc5c, + (q31_t)0x33326776, (q31_t)0x8aaf48db, (q31_t)0x332ca52c, (q31_t)0x8aacc5a4, + (q31_t)0x3326e2c3, (q31_t)0x8aaa42b4, (q31_t)0x33212039, (q31_t)0x8aa7c00d, + (q31_t)0x331b5d91, (q31_t)0x8aa53daf, (q31_t)0x33159ac8, (q31_t)0x8aa2bb99, + (q31_t)0x330fd7e1, (q31_t)0x8aa039cb, (q31_t)0x330a14da, (q31_t)0x8a9db845, + (q31_t)0x330451b3, (q31_t)0x8a9b3708, (q31_t)0x32fe8e6d, (q31_t)0x8a98b614, + (q31_t)0x32f8cb07, (q31_t)0x8a963567, (q31_t)0x32f30782, (q31_t)0x8a93b504, + (q31_t)0x32ed43de, (q31_t)0x8a9134e8, (q31_t)0x32e7801a, (q31_t)0x8a8eb516, + (q31_t)0x32e1bc36, (q31_t)0x8a8c358b, (q31_t)0x32dbf834, (q31_t)0x8a89b649, + (q31_t)0x32d63412, (q31_t)0x8a873750, (q31_t)0x32d06fd0, (q31_t)0x8a84b89e, + (q31_t)0x32caab6f, (q31_t)0x8a823a36, (q31_t)0x32c4e6ef, (q31_t)0x8a7fbc16, + (q31_t)0x32bf2250, (q31_t)0x8a7d3e3e, (q31_t)0x32b95d91, (q31_t)0x8a7ac0af, + (q31_t)0x32b398b3, (q31_t)0x8a784368, (q31_t)0x32add3b6, (q31_t)0x8a75c66a, + (q31_t)0x32a80e99, (q31_t)0x8a7349b4, (q31_t)0x32a2495d, (q31_t)0x8a70cd47, + (q31_t)0x329c8402, (q31_t)0x8a6e5123, (q31_t)0x3296be88, (q31_t)0x8a6bd547, + (q31_t)0x3290f8ef, (q31_t)0x8a6959b3, (q31_t)0x328b3336, (q31_t)0x8a66de68, + (q31_t)0x32856d5e, (q31_t)0x8a646365, (q31_t)0x327fa767, (q31_t)0x8a61e8ab, + (q31_t)0x3279e151, (q31_t)0x8a5f6e3a, (q31_t)0x32741b1c, (q31_t)0x8a5cf411, + (q31_t)0x326e54c7, (q31_t)0x8a5a7a31, (q31_t)0x32688e54, (q31_t)0x8a580099, + (q31_t)0x3262c7c1, (q31_t)0x8a55874a, (q31_t)0x325d0110, (q31_t)0x8a530e43, + (q31_t)0x32573a3f, (q31_t)0x8a509585, (q31_t)0x3251734f, (q31_t)0x8a4e1d10, + (q31_t)0x324bac40, (q31_t)0x8a4ba4e3, (q31_t)0x3245e512, (q31_t)0x8a492cff, + (q31_t)0x32401dc6, (q31_t)0x8a46b564, (q31_t)0x323a565a, (q31_t)0x8a443e11, + (q31_t)0x32348ecf, (q31_t)0x8a41c706, (q31_t)0x322ec725, (q31_t)0x8a3f5045, + (q31_t)0x3228ff5c, (q31_t)0x8a3cd9cc, (q31_t)0x32233775, (q31_t)0x8a3a639b, + (q31_t)0x321d6f6e, (q31_t)0x8a37edb3, (q31_t)0x3217a748, (q31_t)0x8a357814, + (q31_t)0x3211df04, (q31_t)0x8a3302be, (q31_t)0x320c16a1, (q31_t)0x8a308db0, + (q31_t)0x32064e1e, (q31_t)0x8a2e18eb, (q31_t)0x3200857d, (q31_t)0x8a2ba46e, + (q31_t)0x31fabcbd, (q31_t)0x8a29303b, (q31_t)0x31f4f3df, (q31_t)0x8a26bc50, + (q31_t)0x31ef2ae1, (q31_t)0x8a2448ad, (q31_t)0x31e961c5, (q31_t)0x8a21d554, + (q31_t)0x31e39889, (q31_t)0x8a1f6243, (q31_t)0x31ddcf30, (q31_t)0x8a1cef7a, + (q31_t)0x31d805b7, (q31_t)0x8a1a7cfb, (q31_t)0x31d23c1f, (q31_t)0x8a180ac4, + (q31_t)0x31cc7269, (q31_t)0x8a1598d6, (q31_t)0x31c6a894, (q31_t)0x8a132731, + (q31_t)0x31c0dea1, (q31_t)0x8a10b5d4, (q31_t)0x31bb148f, (q31_t)0x8a0e44c0, + (q31_t)0x31b54a5e, (q31_t)0x8a0bd3f5, (q31_t)0x31af800e, (q31_t)0x8a096373, + (q31_t)0x31a9b5a0, (q31_t)0x8a06f339, (q31_t)0x31a3eb13, (q31_t)0x8a048348, + (q31_t)0x319e2067, (q31_t)0x8a0213a0, (q31_t)0x3198559d, (q31_t)0x89ffa441, + (q31_t)0x31928ab4, (q31_t)0x89fd352b, (q31_t)0x318cbfad, (q31_t)0x89fac65d, + (q31_t)0x3186f487, (q31_t)0x89f857d8, (q31_t)0x31812943, (q31_t)0x89f5e99c, + (q31_t)0x317b5de0, (q31_t)0x89f37ba9, (q31_t)0x3175925e, (q31_t)0x89f10dff, + (q31_t)0x316fc6be, (q31_t)0x89eea09d, (q31_t)0x3169fb00, (q31_t)0x89ec3384, + (q31_t)0x31642f23, (q31_t)0x89e9c6b4, (q31_t)0x315e6328, (q31_t)0x89e75a2d, + (q31_t)0x3158970e, (q31_t)0x89e4edef, (q31_t)0x3152cad5, (q31_t)0x89e281fa, + (q31_t)0x314cfe7f, (q31_t)0x89e0164d, (q31_t)0x31473209, (q31_t)0x89ddaae9, + (q31_t)0x31416576, (q31_t)0x89db3fcf, (q31_t)0x313b98c4, (q31_t)0x89d8d4fd, + (q31_t)0x3135cbf4, (q31_t)0x89d66a74, (q31_t)0x312fff05, (q31_t)0x89d40033, + (q31_t)0x312a31f8, (q31_t)0x89d1963c, (q31_t)0x312464cd, (q31_t)0x89cf2c8e, + (q31_t)0x311e9783, (q31_t)0x89ccc328, (q31_t)0x3118ca1b, (q31_t)0x89ca5a0c, + (q31_t)0x3112fc95, (q31_t)0x89c7f138, (q31_t)0x310d2ef0, (q31_t)0x89c588ae, + (q31_t)0x3107612e, (q31_t)0x89c3206c, (q31_t)0x3101934d, (q31_t)0x89c0b873, + (q31_t)0x30fbc54d, (q31_t)0x89be50c3, (q31_t)0x30f5f730, (q31_t)0x89bbe95c, + (q31_t)0x30f028f4, (q31_t)0x89b9823e, (q31_t)0x30ea5a9a, (q31_t)0x89b71b69, + (q31_t)0x30e48c22, (q31_t)0x89b4b4dd, (q31_t)0x30debd8c, (q31_t)0x89b24e9a, + (q31_t)0x30d8eed8, (q31_t)0x89afe8a0, (q31_t)0x30d32006, (q31_t)0x89ad82ef, + (q31_t)0x30cd5115, (q31_t)0x89ab1d87, (q31_t)0x30c78206, (q31_t)0x89a8b868, + (q31_t)0x30c1b2da, (q31_t)0x89a65391, (q31_t)0x30bbe38f, (q31_t)0x89a3ef04, + (q31_t)0x30b61426, (q31_t)0x89a18ac0, (q31_t)0x30b0449f, (q31_t)0x899f26c5, + (q31_t)0x30aa74fa, (q31_t)0x899cc313, (q31_t)0x30a4a537, (q31_t)0x899a5faa, + (q31_t)0x309ed556, (q31_t)0x8997fc8a, (q31_t)0x30990557, (q31_t)0x899599b3, + (q31_t)0x3093353a, (q31_t)0x89933725, (q31_t)0x308d64ff, (q31_t)0x8990d4e0, + (q31_t)0x308794a6, (q31_t)0x898e72e4, (q31_t)0x3081c42f, (q31_t)0x898c1131, + (q31_t)0x307bf39b, (q31_t)0x8989afc8, (q31_t)0x307622e8, (q31_t)0x89874ea7, + (q31_t)0x30705217, (q31_t)0x8984edcf, (q31_t)0x306a8129, (q31_t)0x89828d41, + (q31_t)0x3064b01d, (q31_t)0x89802cfc, (q31_t)0x305edef3, (q31_t)0x897dccff, + (q31_t)0x30590dab, (q31_t)0x897b6d4c, (q31_t)0x30533c45, (q31_t)0x89790de2, + (q31_t)0x304d6ac1, (q31_t)0x8976aec1, (q31_t)0x30479920, (q31_t)0x89744fe9, + (q31_t)0x3041c761, (q31_t)0x8971f15a, (q31_t)0x303bf584, (q31_t)0x896f9315, + (q31_t)0x30362389, (q31_t)0x896d3518, (q31_t)0x30305171, (q31_t)0x896ad765, + (q31_t)0x302a7f3a, (q31_t)0x896879fb, (q31_t)0x3024ace6, (q31_t)0x89661cda, + (q31_t)0x301eda75, (q31_t)0x8963c002, (q31_t)0x301907e6, (q31_t)0x89616373, + (q31_t)0x30133539, (q31_t)0x895f072e, (q31_t)0x300d626e, (q31_t)0x895cab31, + (q31_t)0x30078f86, (q31_t)0x895a4f7e, (q31_t)0x3001bc80, (q31_t)0x8957f414, + (q31_t)0x2ffbe95d, (q31_t)0x895598f3, (q31_t)0x2ff6161c, (q31_t)0x89533e1c, + (q31_t)0x2ff042bd, (q31_t)0x8950e38e, (q31_t)0x2fea6f41, (q31_t)0x894e8948, + (q31_t)0x2fe49ba7, (q31_t)0x894c2f4c, (q31_t)0x2fdec7f0, (q31_t)0x8949d59a, + (q31_t)0x2fd8f41b, (q31_t)0x89477c30, (q31_t)0x2fd32028, (q31_t)0x89452310, + (q31_t)0x2fcd4c19, (q31_t)0x8942ca39, (q31_t)0x2fc777eb, (q31_t)0x894071ab, + (q31_t)0x2fc1a3a0, (q31_t)0x893e1967, (q31_t)0x2fbbcf38, (q31_t)0x893bc16b, + (q31_t)0x2fb5fab2, (q31_t)0x893969b9, (q31_t)0x2fb0260f, (q31_t)0x89371250, + (q31_t)0x2faa514f, (q31_t)0x8934bb31, (q31_t)0x2fa47c71, (q31_t)0x8932645b, + (q31_t)0x2f9ea775, (q31_t)0x89300dce, (q31_t)0x2f98d25d, (q31_t)0x892db78a, + (q31_t)0x2f92fd26, (q31_t)0x892b6190, (q31_t)0x2f8d27d3, (q31_t)0x89290bdf, + (q31_t)0x2f875262, (q31_t)0x8926b677, (q31_t)0x2f817cd4, (q31_t)0x89246159, + (q31_t)0x2f7ba729, (q31_t)0x89220c84, (q31_t)0x2f75d160, (q31_t)0x891fb7f8, + (q31_t)0x2f6ffb7a, (q31_t)0x891d63b5, (q31_t)0x2f6a2577, (q31_t)0x891b0fbc, + (q31_t)0x2f644f56, (q31_t)0x8918bc0c, (q31_t)0x2f5e7919, (q31_t)0x891668a6, + (q31_t)0x2f58a2be, (q31_t)0x89141589, (q31_t)0x2f52cc46, (q31_t)0x8911c2b5, + (q31_t)0x2f4cf5b0, (q31_t)0x890f702b, (q31_t)0x2f471efe, (q31_t)0x890d1dea, + (q31_t)0x2f41482e, (q31_t)0x890acbf2, (q31_t)0x2f3b7141, (q31_t)0x89087a44, + (q31_t)0x2f359a37, (q31_t)0x890628df, (q31_t)0x2f2fc310, (q31_t)0x8903d7c4, + (q31_t)0x2f29ebcc, (q31_t)0x890186f2, (q31_t)0x2f24146b, (q31_t)0x88ff3669, + (q31_t)0x2f1e3ced, (q31_t)0x88fce62a, (q31_t)0x2f186551, (q31_t)0x88fa9634, + (q31_t)0x2f128d99, (q31_t)0x88f84687, (q31_t)0x2f0cb5c3, (q31_t)0x88f5f724, + (q31_t)0x2f06ddd1, (q31_t)0x88f3a80b, (q31_t)0x2f0105c1, (q31_t)0x88f1593b, + (q31_t)0x2efb2d95, (q31_t)0x88ef0ab4, (q31_t)0x2ef5554b, (q31_t)0x88ecbc77, + (q31_t)0x2eef7ce5, (q31_t)0x88ea6e83, (q31_t)0x2ee9a461, (q31_t)0x88e820d9, + (q31_t)0x2ee3cbc1, (q31_t)0x88e5d378, (q31_t)0x2eddf304, (q31_t)0x88e38660, + (q31_t)0x2ed81a29, (q31_t)0x88e13992, (q31_t)0x2ed24132, (q31_t)0x88deed0e, + (q31_t)0x2ecc681e, (q31_t)0x88dca0d3, (q31_t)0x2ec68eed, (q31_t)0x88da54e1, + (q31_t)0x2ec0b5a0, (q31_t)0x88d8093a, (q31_t)0x2ebadc35, (q31_t)0x88d5bddb, + (q31_t)0x2eb502ae, (q31_t)0x88d372c6, (q31_t)0x2eaf290a, (q31_t)0x88d127fb, + (q31_t)0x2ea94f49, (q31_t)0x88cedd79, (q31_t)0x2ea3756b, (q31_t)0x88cc9340, + (q31_t)0x2e9d9b70, (q31_t)0x88ca4951, (q31_t)0x2e97c159, (q31_t)0x88c7ffac, + (q31_t)0x2e91e725, (q31_t)0x88c5b650, (q31_t)0x2e8c0cd4, (q31_t)0x88c36d3e, + (q31_t)0x2e863267, (q31_t)0x88c12475, (q31_t)0x2e8057dd, (q31_t)0x88bedbf6, + (q31_t)0x2e7a7d36, (q31_t)0x88bc93c0, (q31_t)0x2e74a272, (q31_t)0x88ba4bd4, + (q31_t)0x2e6ec792, (q31_t)0x88b80432, (q31_t)0x2e68ec95, (q31_t)0x88b5bcd9, + (q31_t)0x2e63117c, (q31_t)0x88b375ca, (q31_t)0x2e5d3646, (q31_t)0x88b12f04, + (q31_t)0x2e575af3, (q31_t)0x88aee888, (q31_t)0x2e517f84, (q31_t)0x88aca255, + (q31_t)0x2e4ba3f8, (q31_t)0x88aa5c6c, (q31_t)0x2e45c850, (q31_t)0x88a816cd, + (q31_t)0x2e3fec8b, (q31_t)0x88a5d177, (q31_t)0x2e3a10aa, (q31_t)0x88a38c6b, + (q31_t)0x2e3434ac, (q31_t)0x88a147a9, (q31_t)0x2e2e5891, (q31_t)0x889f0330, + (q31_t)0x2e287c5a, (q31_t)0x889cbf01, (q31_t)0x2e22a007, (q31_t)0x889a7b1b, + (q31_t)0x2e1cc397, (q31_t)0x88983780, (q31_t)0x2e16e70b, (q31_t)0x8895f42d, + (q31_t)0x2e110a62, (q31_t)0x8893b125, (q31_t)0x2e0b2d9d, (q31_t)0x88916e66, + (q31_t)0x2e0550bb, (q31_t)0x888f2bf1, (q31_t)0x2dff73bd, (q31_t)0x888ce9c5, + (q31_t)0x2df996a3, (q31_t)0x888aa7e3, (q31_t)0x2df3b96c, (q31_t)0x8888664b, + (q31_t)0x2deddc19, (q31_t)0x888624fd, (q31_t)0x2de7feaa, (q31_t)0x8883e3f8, + (q31_t)0x2de2211e, (q31_t)0x8881a33d, (q31_t)0x2ddc4376, (q31_t)0x887f62cb, + (q31_t)0x2dd665b2, (q31_t)0x887d22a4, (q31_t)0x2dd087d1, (q31_t)0x887ae2c6, + (q31_t)0x2dcaa9d5, (q31_t)0x8878a332, (q31_t)0x2dc4cbbc, (q31_t)0x887663e7, + (q31_t)0x2dbeed86, (q31_t)0x887424e7, (q31_t)0x2db90f35, (q31_t)0x8871e630, + (q31_t)0x2db330c7, (q31_t)0x886fa7c2, (q31_t)0x2dad523d, (q31_t)0x886d699f, + (q31_t)0x2da77397, (q31_t)0x886b2bc5, (q31_t)0x2da194d5, (q31_t)0x8868ee35, + (q31_t)0x2d9bb5f6, (q31_t)0x8866b0ef, (q31_t)0x2d95d6fc, (q31_t)0x886473f2, + (q31_t)0x2d8ff7e5, (q31_t)0x88623740, (q31_t)0x2d8a18b3, (q31_t)0x885ffad7, + (q31_t)0x2d843964, (q31_t)0x885dbeb8, (q31_t)0x2d7e59f9, (q31_t)0x885b82e3, + (q31_t)0x2d787a72, (q31_t)0x88594757, (q31_t)0x2d729acf, (q31_t)0x88570c16, + (q31_t)0x2d6cbb10, (q31_t)0x8854d11e, (q31_t)0x2d66db35, (q31_t)0x88529670, + (q31_t)0x2d60fb3e, (q31_t)0x88505c0b, (q31_t)0x2d5b1b2b, (q31_t)0x884e21f1, + (q31_t)0x2d553afc, (q31_t)0x884be821, (q31_t)0x2d4f5ab1, (q31_t)0x8849ae9a, + (q31_t)0x2d497a4a, (q31_t)0x8847755d, (q31_t)0x2d4399c7, (q31_t)0x88453c6a, + (q31_t)0x2d3db928, (q31_t)0x884303c1, (q31_t)0x2d37d86d, (q31_t)0x8840cb61, + (q31_t)0x2d31f797, (q31_t)0x883e934c, (q31_t)0x2d2c16a4, (q31_t)0x883c5b81, + (q31_t)0x2d263596, (q31_t)0x883a23ff, (q31_t)0x2d20546b, (q31_t)0x8837ecc7, + (q31_t)0x2d1a7325, (q31_t)0x8835b5d9, (q31_t)0x2d1491c4, (q31_t)0x88337f35, + (q31_t)0x2d0eb046, (q31_t)0x883148db, (q31_t)0x2d08ceac, (q31_t)0x882f12cb, + (q31_t)0x2d02ecf7, (q31_t)0x882cdd04, (q31_t)0x2cfd0b26, (q31_t)0x882aa788, + (q31_t)0x2cf72939, (q31_t)0x88287256, (q31_t)0x2cf14731, (q31_t)0x88263d6d, + (q31_t)0x2ceb650d, (q31_t)0x882408ce, (q31_t)0x2ce582cd, (q31_t)0x8821d47a, + (q31_t)0x2cdfa071, (q31_t)0x881fa06f, (q31_t)0x2cd9bdfa, (q31_t)0x881d6cae, + (q31_t)0x2cd3db67, (q31_t)0x881b3937, (q31_t)0x2ccdf8b8, (q31_t)0x8819060a, + (q31_t)0x2cc815ee, (q31_t)0x8816d327, (q31_t)0x2cc23308, (q31_t)0x8814a08f, + (q31_t)0x2cbc5006, (q31_t)0x88126e40, (q31_t)0x2cb66ce9, (q31_t)0x88103c3b, + (q31_t)0x2cb089b1, (q31_t)0x880e0a7f, (q31_t)0x2caaa65c, (q31_t)0x880bd90e, + (q31_t)0x2ca4c2ed, (q31_t)0x8809a7e7, (q31_t)0x2c9edf61, (q31_t)0x8807770a, + (q31_t)0x2c98fbba, (q31_t)0x88054677, (q31_t)0x2c9317f8, (q31_t)0x8803162e, + (q31_t)0x2c8d341a, (q31_t)0x8800e62f, (q31_t)0x2c875021, (q31_t)0x87feb67a, + (q31_t)0x2c816c0c, (q31_t)0x87fc870f, (q31_t)0x2c7b87dc, (q31_t)0x87fa57ee, + (q31_t)0x2c75a390, (q31_t)0x87f82917, (q31_t)0x2c6fbf29, (q31_t)0x87f5fa8b, + (q31_t)0x2c69daa6, (q31_t)0x87f3cc48, (q31_t)0x2c63f609, (q31_t)0x87f19e4f, + (q31_t)0x2c5e114f, (q31_t)0x87ef70a0, (q31_t)0x2c582c7b, (q31_t)0x87ed433c, + (q31_t)0x2c52478a, (q31_t)0x87eb1621, (q31_t)0x2c4c627f, (q31_t)0x87e8e950, + (q31_t)0x2c467d58, (q31_t)0x87e6bcca, (q31_t)0x2c409816, (q31_t)0x87e4908e, + (q31_t)0x2c3ab2b9, (q31_t)0x87e2649b, (q31_t)0x2c34cd40, (q31_t)0x87e038f3, + (q31_t)0x2c2ee7ad, (q31_t)0x87de0d95, (q31_t)0x2c2901fd, (q31_t)0x87dbe281, + (q31_t)0x2c231c33, (q31_t)0x87d9b7b7, (q31_t)0x2c1d364e, (q31_t)0x87d78d38, + (q31_t)0x2c17504d, (q31_t)0x87d56302, (q31_t)0x2c116a31, (q31_t)0x87d33916, + (q31_t)0x2c0b83fa, (q31_t)0x87d10f75, (q31_t)0x2c059da7, (q31_t)0x87cee61e, + (q31_t)0x2bffb73a, (q31_t)0x87ccbd11, (q31_t)0x2bf9d0b1, (q31_t)0x87ca944e, + (q31_t)0x2bf3ea0d, (q31_t)0x87c86bd5, (q31_t)0x2bee034e, (q31_t)0x87c643a6, + (q31_t)0x2be81c74, (q31_t)0x87c41bc2, (q31_t)0x2be2357f, (q31_t)0x87c1f427, + (q31_t)0x2bdc4e6f, (q31_t)0x87bfccd7, (q31_t)0x2bd66744, (q31_t)0x87bda5d1, + (q31_t)0x2bd07ffe, (q31_t)0x87bb7f16, (q31_t)0x2bca989d, (q31_t)0x87b958a4, + (q31_t)0x2bc4b120, (q31_t)0x87b7327d, (q31_t)0x2bbec989, (q31_t)0x87b50c9f, + (q31_t)0x2bb8e1d7, (q31_t)0x87b2e70c, (q31_t)0x2bb2fa0a, (q31_t)0x87b0c1c4, + (q31_t)0x2bad1221, (q31_t)0x87ae9cc5, (q31_t)0x2ba72a1e, (q31_t)0x87ac7811, + (q31_t)0x2ba14200, (q31_t)0x87aa53a6, (q31_t)0x2b9b59c7, (q31_t)0x87a82f87, + (q31_t)0x2b957173, (q31_t)0x87a60bb1, (q31_t)0x2b8f8905, (q31_t)0x87a3e825, + (q31_t)0x2b89a07b, (q31_t)0x87a1c4e4, (q31_t)0x2b83b7d7, (q31_t)0x879fa1ed, + (q31_t)0x2b7dcf17, (q31_t)0x879d7f41, (q31_t)0x2b77e63d, (q31_t)0x879b5cde, + (q31_t)0x2b71fd48, (q31_t)0x87993ac6, (q31_t)0x2b6c1438, (q31_t)0x879718f8, + (q31_t)0x2b662b0e, (q31_t)0x8794f774, (q31_t)0x2b6041c9, (q31_t)0x8792d63b, + (q31_t)0x2b5a5868, (q31_t)0x8790b54c, (q31_t)0x2b546eee, (q31_t)0x878e94a7, + (q31_t)0x2b4e8558, (q31_t)0x878c744d, (q31_t)0x2b489ba8, (q31_t)0x878a543d, + (q31_t)0x2b42b1dd, (q31_t)0x87883477, (q31_t)0x2b3cc7f7, (q31_t)0x878614fb, + (q31_t)0x2b36ddf7, (q31_t)0x8783f5ca, (q31_t)0x2b30f3dc, (q31_t)0x8781d6e3, + (q31_t)0x2b2b09a6, (q31_t)0x877fb846, (q31_t)0x2b251f56, (q31_t)0x877d99f4, + (q31_t)0x2b1f34eb, (q31_t)0x877b7bec, (q31_t)0x2b194a66, (q31_t)0x87795e2f, + (q31_t)0x2b135fc6, (q31_t)0x877740bb, (q31_t)0x2b0d750b, (q31_t)0x87752392, + (q31_t)0x2b078a36, (q31_t)0x877306b4, (q31_t)0x2b019f46, (q31_t)0x8770ea20, + (q31_t)0x2afbb43c, (q31_t)0x876ecdd6, (q31_t)0x2af5c917, (q31_t)0x876cb1d6, + (q31_t)0x2aefddd8, (q31_t)0x876a9621, (q31_t)0x2ae9f27e, (q31_t)0x87687ab7, + (q31_t)0x2ae4070a, (q31_t)0x87665f96, (q31_t)0x2ade1b7c, (q31_t)0x876444c1, + (q31_t)0x2ad82fd2, (q31_t)0x87622a35, (q31_t)0x2ad2440f, (q31_t)0x87600ff4, + (q31_t)0x2acc5831, (q31_t)0x875df5fd, (q31_t)0x2ac66c39, (q31_t)0x875bdc51, + (q31_t)0x2ac08026, (q31_t)0x8759c2ef, (q31_t)0x2aba93f9, (q31_t)0x8757a9d8, + (q31_t)0x2ab4a7b1, (q31_t)0x8755910b, (q31_t)0x2aaebb50, (q31_t)0x87537888, + (q31_t)0x2aa8ced3, (q31_t)0x87516050, (q31_t)0x2aa2e23d, (q31_t)0x874f4862, + (q31_t)0x2a9cf58c, (q31_t)0x874d30bf, (q31_t)0x2a9708c1, (q31_t)0x874b1966, + (q31_t)0x2a911bdc, (q31_t)0x87490258, (q31_t)0x2a8b2edc, (q31_t)0x8746eb94, + (q31_t)0x2a8541c3, (q31_t)0x8744d51b, (q31_t)0x2a7f548e, (q31_t)0x8742beec, + (q31_t)0x2a796740, (q31_t)0x8740a907, (q31_t)0x2a7379d8, (q31_t)0x873e936d, + (q31_t)0x2a6d8c55, (q31_t)0x873c7e1e, (q31_t)0x2a679eb8, (q31_t)0x873a6919, + (q31_t)0x2a61b101, (q31_t)0x8738545e, (q31_t)0x2a5bc330, (q31_t)0x87363fee, + (q31_t)0x2a55d545, (q31_t)0x87342bc9, (q31_t)0x2a4fe740, (q31_t)0x873217ee, + (q31_t)0x2a49f920, (q31_t)0x8730045d, (q31_t)0x2a440ae7, (q31_t)0x872df117, + (q31_t)0x2a3e1c93, (q31_t)0x872bde1c, (q31_t)0x2a382e25, (q31_t)0x8729cb6b, + (q31_t)0x2a323f9e, (q31_t)0x8727b905, (q31_t)0x2a2c50fc, (q31_t)0x8725a6e9, + (q31_t)0x2a266240, (q31_t)0x87239518, (q31_t)0x2a20736a, (q31_t)0x87218391, + (q31_t)0x2a1a847b, (q31_t)0x871f7255, (q31_t)0x2a149571, (q31_t)0x871d6163, + (q31_t)0x2a0ea64d, (q31_t)0x871b50bc, (q31_t)0x2a08b710, (q31_t)0x87194060, + (q31_t)0x2a02c7b8, (q31_t)0x8717304e, (q31_t)0x29fcd847, (q31_t)0x87152087, + (q31_t)0x29f6e8bb, (q31_t)0x8713110a, (q31_t)0x29f0f916, (q31_t)0x871101d8, + (q31_t)0x29eb0957, (q31_t)0x870ef2f1, (q31_t)0x29e5197e, (q31_t)0x870ce454, + (q31_t)0x29df298b, (q31_t)0x870ad602, (q31_t)0x29d9397f, (q31_t)0x8708c7fa, + (q31_t)0x29d34958, (q31_t)0x8706ba3d, (q31_t)0x29cd5918, (q31_t)0x8704acca, + (q31_t)0x29c768be, (q31_t)0x87029fa3, (q31_t)0x29c1784a, (q31_t)0x870092c5, + (q31_t)0x29bb87bc, (q31_t)0x86fe8633, (q31_t)0x29b59715, (q31_t)0x86fc79eb, + (q31_t)0x29afa654, (q31_t)0x86fa6dee, (q31_t)0x29a9b579, (q31_t)0x86f8623b, + (q31_t)0x29a3c485, (q31_t)0x86f656d3, (q31_t)0x299dd377, (q31_t)0x86f44bb6, + (q31_t)0x2997e24f, (q31_t)0x86f240e3, (q31_t)0x2991f10e, (q31_t)0x86f0365c, + (q31_t)0x298bffb2, (q31_t)0x86ee2c1e, (q31_t)0x29860e3e, (q31_t)0x86ec222c, + (q31_t)0x29801caf, (q31_t)0x86ea1884, (q31_t)0x297a2b07, (q31_t)0x86e80f27, + (q31_t)0x29743946, (q31_t)0x86e60614, (q31_t)0x296e476b, (q31_t)0x86e3fd4c, + (q31_t)0x29685576, (q31_t)0x86e1f4cf, (q31_t)0x29626368, (q31_t)0x86dfec9d, + (q31_t)0x295c7140, (q31_t)0x86dde4b5, (q31_t)0x29567eff, (q31_t)0x86dbdd18, + (q31_t)0x29508ca4, (q31_t)0x86d9d5c6, (q31_t)0x294a9a30, (q31_t)0x86d7cebf, + (q31_t)0x2944a7a2, (q31_t)0x86d5c802, (q31_t)0x293eb4fb, (q31_t)0x86d3c190, + (q31_t)0x2938c23a, (q31_t)0x86d1bb69, (q31_t)0x2932cf60, (q31_t)0x86cfb58c, + (q31_t)0x292cdc6d, (q31_t)0x86cdaffa, (q31_t)0x2926e960, (q31_t)0x86cbaab3, + (q31_t)0x2920f63a, (q31_t)0x86c9a5b7, (q31_t)0x291b02fa, (q31_t)0x86c7a106, + (q31_t)0x29150fa1, (q31_t)0x86c59c9f, (q31_t)0x290f1c2f, (q31_t)0x86c39883, + (q31_t)0x290928a3, (q31_t)0x86c194b2, (q31_t)0x290334ff, (q31_t)0x86bf912c, + (q31_t)0x28fd4140, (q31_t)0x86bd8df0, (q31_t)0x28f74d69, (q31_t)0x86bb8b00, + (q31_t)0x28f15978, (q31_t)0x86b9885a, (q31_t)0x28eb656e, (q31_t)0x86b785ff, + (q31_t)0x28e5714b, (q31_t)0x86b583ee, (q31_t)0x28df7d0e, (q31_t)0x86b38229, + (q31_t)0x28d988b8, (q31_t)0x86b180ae, (q31_t)0x28d3944a, (q31_t)0x86af7f7e, + (q31_t)0x28cd9fc1, (q31_t)0x86ad7e99, (q31_t)0x28c7ab20, (q31_t)0x86ab7dff, + (q31_t)0x28c1b666, (q31_t)0x86a97db0, (q31_t)0x28bbc192, (q31_t)0x86a77dab, + (q31_t)0x28b5cca5, (q31_t)0x86a57df2, (q31_t)0x28afd7a0, (q31_t)0x86a37e83, + (q31_t)0x28a9e281, (q31_t)0x86a17f5f, (q31_t)0x28a3ed49, (q31_t)0x869f8086, + (q31_t)0x289df7f8, (q31_t)0x869d81f8, (q31_t)0x2898028e, (q31_t)0x869b83b4, + (q31_t)0x28920d0a, (q31_t)0x869985bc, (q31_t)0x288c176e, (q31_t)0x8697880f, + (q31_t)0x288621b9, (q31_t)0x86958aac, (q31_t)0x28802beb, (q31_t)0x86938d94, + (q31_t)0x287a3604, (q31_t)0x869190c7, (q31_t)0x28744004, (q31_t)0x868f9445, + (q31_t)0x286e49ea, (q31_t)0x868d980e, (q31_t)0x286853b8, (q31_t)0x868b9c22, + (q31_t)0x28625d6d, (q31_t)0x8689a081, (q31_t)0x285c670a, (q31_t)0x8687a52b, + (q31_t)0x2856708d, (q31_t)0x8685aa20, (q31_t)0x285079f7, (q31_t)0x8683af5f, + (q31_t)0x284a8349, (q31_t)0x8681b4ea, (q31_t)0x28448c81, (q31_t)0x867fbabf, + (q31_t)0x283e95a1, (q31_t)0x867dc0e0, (q31_t)0x28389ea8, (q31_t)0x867bc74b, + (q31_t)0x2832a796, (q31_t)0x8679ce01, (q31_t)0x282cb06c, (q31_t)0x8677d503, + (q31_t)0x2826b928, (q31_t)0x8675dc4f, (q31_t)0x2820c1cc, (q31_t)0x8673e3e6, + (q31_t)0x281aca57, (q31_t)0x8671ebc8, (q31_t)0x2814d2c9, (q31_t)0x866ff3f6, + (q31_t)0x280edb23, (q31_t)0x866dfc6e, (q31_t)0x2808e364, (q31_t)0x866c0531, + (q31_t)0x2802eb8c, (q31_t)0x866a0e3f, (q31_t)0x27fcf39c, (q31_t)0x86681798, + (q31_t)0x27f6fb92, (q31_t)0x8666213c, (q31_t)0x27f10371, (q31_t)0x86642b2c, + (q31_t)0x27eb0b36, (q31_t)0x86623566, (q31_t)0x27e512e3, (q31_t)0x86603feb, + (q31_t)0x27df1a77, (q31_t)0x865e4abb, (q31_t)0x27d921f3, (q31_t)0x865c55d7, + (q31_t)0x27d32956, (q31_t)0x865a613d, (q31_t)0x27cd30a1, (q31_t)0x86586cee, + (q31_t)0x27c737d3, (q31_t)0x865678eb, (q31_t)0x27c13eec, (q31_t)0x86548532, + (q31_t)0x27bb45ed, (q31_t)0x865291c4, (q31_t)0x27b54cd6, (q31_t)0x86509ea2, + (q31_t)0x27af53a6, (q31_t)0x864eabcb, (q31_t)0x27a95a5d, (q31_t)0x864cb93e, + (q31_t)0x27a360fc, (q31_t)0x864ac6fd, (q31_t)0x279d6783, (q31_t)0x8648d507, + (q31_t)0x27976df1, (q31_t)0x8646e35c, (q31_t)0x27917447, (q31_t)0x8644f1fc, + (q31_t)0x278b7a84, (q31_t)0x864300e7, (q31_t)0x278580a9, (q31_t)0x8641101d, + (q31_t)0x277f86b5, (q31_t)0x863f1f9e, (q31_t)0x27798caa, (q31_t)0x863d2f6b, + (q31_t)0x27739285, (q31_t)0x863b3f82, (q31_t)0x276d9849, (q31_t)0x86394fe5, + (q31_t)0x27679df4, (q31_t)0x86376092, (q31_t)0x2761a387, (q31_t)0x8635718b, + (q31_t)0x275ba901, (q31_t)0x863382cf, (q31_t)0x2755ae64, (q31_t)0x8631945e, + (q31_t)0x274fb3ae, (q31_t)0x862fa638, (q31_t)0x2749b8e0, (q31_t)0x862db85e, + (q31_t)0x2743bdf9, (q31_t)0x862bcace, (q31_t)0x273dc2fa, (q31_t)0x8629dd8a, + (q31_t)0x2737c7e3, (q31_t)0x8627f091, (q31_t)0x2731ccb4, (q31_t)0x862603e3, + (q31_t)0x272bd16d, (q31_t)0x86241780, (q31_t)0x2725d60e, (q31_t)0x86222b68, + (q31_t)0x271fda96, (q31_t)0x86203f9c, (q31_t)0x2719df06, (q31_t)0x861e541a, + (q31_t)0x2713e35f, (q31_t)0x861c68e4, (q31_t)0x270de79f, (q31_t)0x861a7df9, + (q31_t)0x2707ebc7, (q31_t)0x86189359, (q31_t)0x2701efd7, (q31_t)0x8616a905, + (q31_t)0x26fbf3ce, (q31_t)0x8614befb, (q31_t)0x26f5f7ae, (q31_t)0x8612d53d, + (q31_t)0x26effb76, (q31_t)0x8610ebca, (q31_t)0x26e9ff26, (q31_t)0x860f02a3, + (q31_t)0x26e402bd, (q31_t)0x860d19c6, (q31_t)0x26de063d, (q31_t)0x860b3135, + (q31_t)0x26d809a5, (q31_t)0x860948ef, (q31_t)0x26d20cf5, (q31_t)0x860760f4, + (q31_t)0x26cc102d, (q31_t)0x86057944, (q31_t)0x26c6134d, (q31_t)0x860391e0, + (q31_t)0x26c01655, (q31_t)0x8601aac7, (q31_t)0x26ba1945, (q31_t)0x85ffc3f9, + (q31_t)0x26b41c1d, (q31_t)0x85fddd76, (q31_t)0x26ae1edd, (q31_t)0x85fbf73f, + (q31_t)0x26a82186, (q31_t)0x85fa1153, (q31_t)0x26a22416, (q31_t)0x85f82bb2, + (q31_t)0x269c268f, (q31_t)0x85f6465c, (q31_t)0x269628f0, (q31_t)0x85f46152, + (q31_t)0x26902b39, (q31_t)0x85f27c93, (q31_t)0x268a2d6b, (q31_t)0x85f09820, + (q31_t)0x26842f84, (q31_t)0x85eeb3f7, (q31_t)0x267e3186, (q31_t)0x85ecd01a, + (q31_t)0x26783370, (q31_t)0x85eaec88, (q31_t)0x26723543, (q31_t)0x85e90942, + (q31_t)0x266c36fe, (q31_t)0x85e72647, (q31_t)0x266638a1, (q31_t)0x85e54397, + (q31_t)0x26603a2c, (q31_t)0x85e36132, (q31_t)0x265a3b9f, (q31_t)0x85e17f19, + (q31_t)0x26543cfb, (q31_t)0x85df9d4b, (q31_t)0x264e3e40, (q31_t)0x85ddbbc9, + (q31_t)0x26483f6c, (q31_t)0x85dbda91, (q31_t)0x26424082, (q31_t)0x85d9f9a5, + (q31_t)0x263c417f, (q31_t)0x85d81905, (q31_t)0x26364265, (q31_t)0x85d638b0, + (q31_t)0x26304333, (q31_t)0x85d458a6, (q31_t)0x262a43ea, (q31_t)0x85d278e7, + (q31_t)0x26244489, (q31_t)0x85d09974, (q31_t)0x261e4511, (q31_t)0x85ceba4d, + (q31_t)0x26184581, (q31_t)0x85ccdb70, (q31_t)0x261245da, (q31_t)0x85cafcdf, + (q31_t)0x260c461b, (q31_t)0x85c91e9a, (q31_t)0x26064645, (q31_t)0x85c740a0, + (q31_t)0x26004657, (q31_t)0x85c562f1, (q31_t)0x25fa4652, (q31_t)0x85c3858d, + (q31_t)0x25f44635, (q31_t)0x85c1a875, (q31_t)0x25ee4601, (q31_t)0x85bfcba9, + (q31_t)0x25e845b6, (q31_t)0x85bdef28, (q31_t)0x25e24553, (q31_t)0x85bc12f2, + (q31_t)0x25dc44d9, (q31_t)0x85ba3707, (q31_t)0x25d64447, (q31_t)0x85b85b68, + (q31_t)0x25d0439f, (q31_t)0x85b68015, (q31_t)0x25ca42de, (q31_t)0x85b4a50d, + (q31_t)0x25c44207, (q31_t)0x85b2ca50, (q31_t)0x25be4118, (q31_t)0x85b0efdf, + (q31_t)0x25b84012, (q31_t)0x85af15b9, (q31_t)0x25b23ef5, (q31_t)0x85ad3bdf, + (q31_t)0x25ac3dc0, (q31_t)0x85ab6250, (q31_t)0x25a63c74, (q31_t)0x85a9890d, + (q31_t)0x25a03b11, (q31_t)0x85a7b015, (q31_t)0x259a3997, (q31_t)0x85a5d768, + (q31_t)0x25943806, (q31_t)0x85a3ff07, (q31_t)0x258e365d, (q31_t)0x85a226f2, + (q31_t)0x2588349d, (q31_t)0x85a04f28, (q31_t)0x258232c6, (q31_t)0x859e77a9, + (q31_t)0x257c30d8, (q31_t)0x859ca076, (q31_t)0x25762ed3, (q31_t)0x859ac98f, + (q31_t)0x25702cb7, (q31_t)0x8598f2f3, (q31_t)0x256a2a83, (q31_t)0x85971ca2, + (q31_t)0x25642839, (q31_t)0x8595469d, (q31_t)0x255e25d7, (q31_t)0x859370e4, + (q31_t)0x2558235f, (q31_t)0x85919b76, (q31_t)0x255220cf, (q31_t)0x858fc653, + (q31_t)0x254c1e28, (q31_t)0x858df17c, (q31_t)0x25461b6b, (q31_t)0x858c1cf1, + (q31_t)0x25401896, (q31_t)0x858a48b1, (q31_t)0x253a15aa, (q31_t)0x858874bd, + (q31_t)0x253412a8, (q31_t)0x8586a114, (q31_t)0x252e0f8e, (q31_t)0x8584cdb7, + (q31_t)0x25280c5e, (q31_t)0x8582faa5, (q31_t)0x25220916, (q31_t)0x858127df, + (q31_t)0x251c05b8, (q31_t)0x857f5564, (q31_t)0x25160243, (q31_t)0x857d8335, + (q31_t)0x250ffeb7, (q31_t)0x857bb152, (q31_t)0x2509fb14, (q31_t)0x8579dfba, + (q31_t)0x2503f75a, (q31_t)0x85780e6e, (q31_t)0x24fdf389, (q31_t)0x85763d6d, + (q31_t)0x24f7efa2, (q31_t)0x85746cb8, (q31_t)0x24f1eba4, (q31_t)0x85729c4e, + (q31_t)0x24ebe78f, (q31_t)0x8570cc30, (q31_t)0x24e5e363, (q31_t)0x856efc5e, + (q31_t)0x24dfdf20, (q31_t)0x856d2cd7, (q31_t)0x24d9dac7, (q31_t)0x856b5d9c, + (q31_t)0x24d3d657, (q31_t)0x85698ead, (q31_t)0x24cdd1d0, (q31_t)0x8567c009, + (q31_t)0x24c7cd33, (q31_t)0x8565f1b0, (q31_t)0x24c1c87f, (q31_t)0x856423a4, + (q31_t)0x24bbc3b4, (q31_t)0x856255e3, (q31_t)0x24b5bed2, (q31_t)0x8560886d, + (q31_t)0x24afb9da, (q31_t)0x855ebb44, (q31_t)0x24a9b4cb, (q31_t)0x855cee66, + (q31_t)0x24a3afa6, (q31_t)0x855b21d3, (q31_t)0x249daa6a, (q31_t)0x8559558c, + (q31_t)0x2497a517, (q31_t)0x85578991, (q31_t)0x24919fae, (q31_t)0x8555bde2, + (q31_t)0x248b9a2f, (q31_t)0x8553f27e, (q31_t)0x24859498, (q31_t)0x85522766, + (q31_t)0x247f8eec, (q31_t)0x85505c99, (q31_t)0x24798928, (q31_t)0x854e9219, + (q31_t)0x2473834f, (q31_t)0x854cc7e3, (q31_t)0x246d7d5e, (q31_t)0x854afdfa, + (q31_t)0x24677758, (q31_t)0x8549345c, (q31_t)0x2461713a, (q31_t)0x85476b0a, + (q31_t)0x245b6b07, (q31_t)0x8545a204, (q31_t)0x245564bd, (q31_t)0x8543d949, + (q31_t)0x244f5e5c, (q31_t)0x854210db, (q31_t)0x244957e5, (q31_t)0x854048b7, + (q31_t)0x24435158, (q31_t)0x853e80e0, (q31_t)0x243d4ab4, (q31_t)0x853cb954, + (q31_t)0x243743fa, (q31_t)0x853af214, (q31_t)0x24313d2a, (q31_t)0x85392b20, + (q31_t)0x242b3644, (q31_t)0x85376477, (q31_t)0x24252f47, (q31_t)0x85359e1a, + (q31_t)0x241f2833, (q31_t)0x8533d809, (q31_t)0x2419210a, (q31_t)0x85321244, + (q31_t)0x241319ca, (q31_t)0x85304cca, (q31_t)0x240d1274, (q31_t)0x852e879d, + (q31_t)0x24070b08, (q31_t)0x852cc2bb, (q31_t)0x24010385, (q31_t)0x852afe24, + (q31_t)0x23fafbec, (q31_t)0x852939da, (q31_t)0x23f4f43e, (q31_t)0x852775db, + (q31_t)0x23eeec78, (q31_t)0x8525b228, (q31_t)0x23e8e49d, (q31_t)0x8523eec1, + (q31_t)0x23e2dcac, (q31_t)0x85222ba5, (q31_t)0x23dcd4a4, (q31_t)0x852068d6, + (q31_t)0x23d6cc87, (q31_t)0x851ea652, (q31_t)0x23d0c453, (q31_t)0x851ce41a, + (q31_t)0x23cabc09, (q31_t)0x851b222e, (q31_t)0x23c4b3a9, (q31_t)0x8519608d, + (q31_t)0x23beab33, (q31_t)0x85179f39, (q31_t)0x23b8a2a7, (q31_t)0x8515de30, + (q31_t)0x23b29a05, (q31_t)0x85141d73, (q31_t)0x23ac914d, (q31_t)0x85125d02, + (q31_t)0x23a6887f, (q31_t)0x85109cdd, (q31_t)0x23a07f9a, (q31_t)0x850edd03, + (q31_t)0x239a76a0, (q31_t)0x850d1d75, (q31_t)0x23946d90, (q31_t)0x850b5e34, + (q31_t)0x238e646a, (q31_t)0x85099f3e, (q31_t)0x23885b2e, (q31_t)0x8507e094, + (q31_t)0x238251dd, (q31_t)0x85062235, (q31_t)0x237c4875, (q31_t)0x85046423, + (q31_t)0x23763ef7, (q31_t)0x8502a65c, (q31_t)0x23703564, (q31_t)0x8500e8e2, + (q31_t)0x236a2bba, (q31_t)0x84ff2bb3, (q31_t)0x236421fb, (q31_t)0x84fd6ed0, + (q31_t)0x235e1826, (q31_t)0x84fbb239, (q31_t)0x23580e3b, (q31_t)0x84f9f5ee, + (q31_t)0x2352043b, (q31_t)0x84f839ee, (q31_t)0x234bfa24, (q31_t)0x84f67e3b, + (q31_t)0x2345eff8, (q31_t)0x84f4c2d4, (q31_t)0x233fe5b6, (q31_t)0x84f307b8, + (q31_t)0x2339db5e, (q31_t)0x84f14ce8, (q31_t)0x2333d0f1, (q31_t)0x84ef9265, + (q31_t)0x232dc66d, (q31_t)0x84edd82d, (q31_t)0x2327bbd5, (q31_t)0x84ec1e41, + (q31_t)0x2321b126, (q31_t)0x84ea64a1, (q31_t)0x231ba662, (q31_t)0x84e8ab4d, + (q31_t)0x23159b88, (q31_t)0x84e6f244, (q31_t)0x230f9098, (q31_t)0x84e53988, + (q31_t)0x23098593, (q31_t)0x84e38118, (q31_t)0x23037a78, (q31_t)0x84e1c8f3, + (q31_t)0x22fd6f48, (q31_t)0x84e0111b, (q31_t)0x22f76402, (q31_t)0x84de598f, + (q31_t)0x22f158a7, (q31_t)0x84dca24e, (q31_t)0x22eb4d36, (q31_t)0x84daeb5a, + (q31_t)0x22e541af, (q31_t)0x84d934b1, (q31_t)0x22df3613, (q31_t)0x84d77e54, + (q31_t)0x22d92a61, (q31_t)0x84d5c844, (q31_t)0x22d31e9a, (q31_t)0x84d4127f, + (q31_t)0x22cd12bd, (q31_t)0x84d25d06, (q31_t)0x22c706cb, (q31_t)0x84d0a7da, + (q31_t)0x22c0fac4, (q31_t)0x84cef2f9, (q31_t)0x22baeea7, (q31_t)0x84cd3e64, + (q31_t)0x22b4e274, (q31_t)0x84cb8a1b, (q31_t)0x22aed62c, (q31_t)0x84c9d61f, + (q31_t)0x22a8c9cf, (q31_t)0x84c8226e, (q31_t)0x22a2bd5d, (q31_t)0x84c66f09, + (q31_t)0x229cb0d5, (q31_t)0x84c4bbf0, (q31_t)0x2296a437, (q31_t)0x84c30924, + (q31_t)0x22909785, (q31_t)0x84c156a3, (q31_t)0x228a8abd, (q31_t)0x84bfa46e, + (q31_t)0x22847de0, (q31_t)0x84bdf286, (q31_t)0x227e70ed, (q31_t)0x84bc40e9, + (q31_t)0x227863e5, (q31_t)0x84ba8f98, (q31_t)0x227256c8, (q31_t)0x84b8de94, + (q31_t)0x226c4996, (q31_t)0x84b72ddb, (q31_t)0x22663c4e, (q31_t)0x84b57d6f, + (q31_t)0x22602ef1, (q31_t)0x84b3cd4f, (q31_t)0x225a217f, (q31_t)0x84b21d7a, + (q31_t)0x225413f8, (q31_t)0x84b06df2, (q31_t)0x224e065c, (q31_t)0x84aebeb6, + (q31_t)0x2247f8aa, (q31_t)0x84ad0fc6, (q31_t)0x2241eae3, (q31_t)0x84ab6122, + (q31_t)0x223bdd08, (q31_t)0x84a9b2ca, (q31_t)0x2235cf17, (q31_t)0x84a804be, + (q31_t)0x222fc111, (q31_t)0x84a656fe, (q31_t)0x2229b2f6, (q31_t)0x84a4a98a, + (q31_t)0x2223a4c5, (q31_t)0x84a2fc62, (q31_t)0x221d9680, (q31_t)0x84a14f87, + (q31_t)0x22178826, (q31_t)0x849fa2f7, (q31_t)0x221179b7, (q31_t)0x849df6b4, + (q31_t)0x220b6b32, (q31_t)0x849c4abd, (q31_t)0x22055c99, (q31_t)0x849a9f12, + (q31_t)0x21ff4dea, (q31_t)0x8498f3b3, (q31_t)0x21f93f27, (q31_t)0x849748a0, + (q31_t)0x21f3304f, (q31_t)0x84959dd9, (q31_t)0x21ed2162, (q31_t)0x8493f35e, + (q31_t)0x21e71260, (q31_t)0x84924930, (q31_t)0x21e10349, (q31_t)0x84909f4e, + (q31_t)0x21daf41d, (q31_t)0x848ef5b7, (q31_t)0x21d4e4dc, (q31_t)0x848d4c6d, + (q31_t)0x21ced586, (q31_t)0x848ba36f, (q31_t)0x21c8c61c, (q31_t)0x8489fabe, + (q31_t)0x21c2b69c, (q31_t)0x84885258, (q31_t)0x21bca708, (q31_t)0x8486aa3e, + (q31_t)0x21b6975f, (q31_t)0x84850271, (q31_t)0x21b087a1, (q31_t)0x84835af0, + (q31_t)0x21aa77cf, (q31_t)0x8481b3bb, (q31_t)0x21a467e7, (q31_t)0x84800cd2, + (q31_t)0x219e57eb, (q31_t)0x847e6636, (q31_t)0x219847da, (q31_t)0x847cbfe5, + (q31_t)0x219237b5, (q31_t)0x847b19e1, (q31_t)0x218c277a, (q31_t)0x84797429, + (q31_t)0x2186172b, (q31_t)0x8477cebd, (q31_t)0x218006c8, (q31_t)0x8476299e, + (q31_t)0x2179f64f, (q31_t)0x847484ca, (q31_t)0x2173e5c2, (q31_t)0x8472e043, + (q31_t)0x216dd521, (q31_t)0x84713c08, (q31_t)0x2167c46b, (q31_t)0x846f9819, + (q31_t)0x2161b3a0, (q31_t)0x846df477, (q31_t)0x215ba2c0, (q31_t)0x846c5120, + (q31_t)0x215591cc, (q31_t)0x846aae16, (q31_t)0x214f80c4, (q31_t)0x84690b58, + (q31_t)0x21496fa7, (q31_t)0x846768e7, (q31_t)0x21435e75, (q31_t)0x8465c6c1, + (q31_t)0x213d4d2f, (q31_t)0x846424e8, (q31_t)0x21373bd4, (q31_t)0x8462835b, + (q31_t)0x21312a65, (q31_t)0x8460e21a, (q31_t)0x212b18e1, (q31_t)0x845f4126, + (q31_t)0x21250749, (q31_t)0x845da07e, (q31_t)0x211ef59d, (q31_t)0x845c0022, + (q31_t)0x2118e3dc, (q31_t)0x845a6012, (q31_t)0x2112d206, (q31_t)0x8458c04f, + (q31_t)0x210cc01d, (q31_t)0x845720d8, (q31_t)0x2106ae1e, (q31_t)0x845581ad, + (q31_t)0x21009c0c, (q31_t)0x8453e2cf, (q31_t)0x20fa89e5, (q31_t)0x8452443d, + (q31_t)0x20f477aa, (q31_t)0x8450a5f7, (q31_t)0x20ee655a, (q31_t)0x844f07fd, + (q31_t)0x20e852f6, (q31_t)0x844d6a50, (q31_t)0x20e2407e, (q31_t)0x844bccef, + (q31_t)0x20dc2df2, (q31_t)0x844a2fda, (q31_t)0x20d61b51, (q31_t)0x84489311, + (q31_t)0x20d0089c, (q31_t)0x8446f695, (q31_t)0x20c9f5d3, (q31_t)0x84455a66, + (q31_t)0x20c3e2f5, (q31_t)0x8443be82, (q31_t)0x20bdd003, (q31_t)0x844222eb, + (q31_t)0x20b7bcfe, (q31_t)0x844087a0, (q31_t)0x20b1a9e4, (q31_t)0x843eeca2, + (q31_t)0x20ab96b5, (q31_t)0x843d51f0, (q31_t)0x20a58373, (q31_t)0x843bb78a, + (q31_t)0x209f701c, (q31_t)0x843a1d70, (q31_t)0x20995cb2, (q31_t)0x843883a3, + (q31_t)0x20934933, (q31_t)0x8436ea23, (q31_t)0x208d35a0, (q31_t)0x843550ee, + (q31_t)0x208721f9, (q31_t)0x8433b806, (q31_t)0x20810e3e, (q31_t)0x84321f6b, + (q31_t)0x207afa6f, (q31_t)0x8430871b, (q31_t)0x2074e68c, (q31_t)0x842eef18, + (q31_t)0x206ed295, (q31_t)0x842d5762, (q31_t)0x2068be8a, (q31_t)0x842bbff8, + (q31_t)0x2062aa6b, (q31_t)0x842a28da, (q31_t)0x205c9638, (q31_t)0x84289209, + (q31_t)0x205681f1, (q31_t)0x8426fb84, (q31_t)0x20506d96, (q31_t)0x8425654b, + (q31_t)0x204a5927, (q31_t)0x8423cf5f, (q31_t)0x204444a4, (q31_t)0x842239bf, + (q31_t)0x203e300d, (q31_t)0x8420a46c, (q31_t)0x20381b63, (q31_t)0x841f0f65, + (q31_t)0x203206a4, (q31_t)0x841d7aaa, (q31_t)0x202bf1d2, (q31_t)0x841be63c, + (q31_t)0x2025dcec, (q31_t)0x841a521a, (q31_t)0x201fc7f2, (q31_t)0x8418be45, + (q31_t)0x2019b2e4, (q31_t)0x84172abc, (q31_t)0x20139dc2, (q31_t)0x84159780, + (q31_t)0x200d888d, (q31_t)0x84140490, (q31_t)0x20077344, (q31_t)0x841271ec, + (q31_t)0x20015de7, (q31_t)0x8410df95, (q31_t)0x1ffb4876, (q31_t)0x840f4d8a, + (q31_t)0x1ff532f2, (q31_t)0x840dbbcc, (q31_t)0x1fef1d59, (q31_t)0x840c2a5a, + (q31_t)0x1fe907ae, (q31_t)0x840a9935, (q31_t)0x1fe2f1ee, (q31_t)0x8409085c, + (q31_t)0x1fdcdc1b, (q31_t)0x840777d0, (q31_t)0x1fd6c634, (q31_t)0x8405e790, + (q31_t)0x1fd0b03a, (q31_t)0x8404579d, (q31_t)0x1fca9a2b, (q31_t)0x8402c7f6, + (q31_t)0x1fc4840a, (q31_t)0x8401389b, (q31_t)0x1fbe6dd4, (q31_t)0x83ffa98d, + (q31_t)0x1fb8578b, (q31_t)0x83fe1acc, (q31_t)0x1fb2412f, (q31_t)0x83fc8c57, + (q31_t)0x1fac2abf, (q31_t)0x83fafe2e, (q31_t)0x1fa6143b, (q31_t)0x83f97052, + (q31_t)0x1f9ffda4, (q31_t)0x83f7e2c3, (q31_t)0x1f99e6fa, (q31_t)0x83f65580, + (q31_t)0x1f93d03c, (q31_t)0x83f4c889, (q31_t)0x1f8db96a, (q31_t)0x83f33bdf, + (q31_t)0x1f87a285, (q31_t)0x83f1af82, (q31_t)0x1f818b8d, (q31_t)0x83f02371, + (q31_t)0x1f7b7481, (q31_t)0x83ee97ad, (q31_t)0x1f755d61, (q31_t)0x83ed0c35, + (q31_t)0x1f6f462f, (q31_t)0x83eb810a, (q31_t)0x1f692ee9, (q31_t)0x83e9f62b, + (q31_t)0x1f63178f, (q31_t)0x83e86b99, (q31_t)0x1f5d0022, (q31_t)0x83e6e153, + (q31_t)0x1f56e8a2, (q31_t)0x83e5575a, (q31_t)0x1f50d10e, (q31_t)0x83e3cdad, + (q31_t)0x1f4ab968, (q31_t)0x83e2444d, (q31_t)0x1f44a1ad, (q31_t)0x83e0bb3a, + (q31_t)0x1f3e89e0, (q31_t)0x83df3273, (q31_t)0x1f3871ff, (q31_t)0x83dda9f9, + (q31_t)0x1f325a0b, (q31_t)0x83dc21cb, (q31_t)0x1f2c4204, (q31_t)0x83da99ea, + (q31_t)0x1f2629ea, (q31_t)0x83d91255, (q31_t)0x1f2011bc, (q31_t)0x83d78b0d, + (q31_t)0x1f19f97b, (q31_t)0x83d60412, (q31_t)0x1f13e127, (q31_t)0x83d47d63, + (q31_t)0x1f0dc8c0, (q31_t)0x83d2f701, (q31_t)0x1f07b045, (q31_t)0x83d170eb, + (q31_t)0x1f0197b8, (q31_t)0x83cfeb22, (q31_t)0x1efb7f17, (q31_t)0x83ce65a6, + (q31_t)0x1ef56664, (q31_t)0x83cce076, (q31_t)0x1eef4d9d, (q31_t)0x83cb5b93, + (q31_t)0x1ee934c3, (q31_t)0x83c9d6fc, (q31_t)0x1ee31bd6, (q31_t)0x83c852b2, + (q31_t)0x1edd02d6, (q31_t)0x83c6ceb5, (q31_t)0x1ed6e9c3, (q31_t)0x83c54b04, + (q31_t)0x1ed0d09d, (q31_t)0x83c3c7a0, (q31_t)0x1ecab763, (q31_t)0x83c24488, + (q31_t)0x1ec49e17, (q31_t)0x83c0c1be, (q31_t)0x1ebe84b8, (q31_t)0x83bf3f3f, + (q31_t)0x1eb86b46, (q31_t)0x83bdbd0e, (q31_t)0x1eb251c1, (q31_t)0x83bc3b29, + (q31_t)0x1eac3829, (q31_t)0x83bab991, (q31_t)0x1ea61e7e, (q31_t)0x83b93845, + (q31_t)0x1ea004c1, (q31_t)0x83b7b746, (q31_t)0x1e99eaf0, (q31_t)0x83b63694, + (q31_t)0x1e93d10c, (q31_t)0x83b4b62e, (q31_t)0x1e8db716, (q31_t)0x83b33616, + (q31_t)0x1e879d0d, (q31_t)0x83b1b649, (q31_t)0x1e8182f1, (q31_t)0x83b036ca, + (q31_t)0x1e7b68c2, (q31_t)0x83aeb797, (q31_t)0x1e754e80, (q31_t)0x83ad38b1, + (q31_t)0x1e6f342c, (q31_t)0x83abba17, (q31_t)0x1e6919c4, (q31_t)0x83aa3bca, + (q31_t)0x1e62ff4a, (q31_t)0x83a8bdca, (q31_t)0x1e5ce4be, (q31_t)0x83a74017, + (q31_t)0x1e56ca1e, (q31_t)0x83a5c2b0, (q31_t)0x1e50af6c, (q31_t)0x83a44596, + (q31_t)0x1e4a94a7, (q31_t)0x83a2c8c9, (q31_t)0x1e4479cf, (q31_t)0x83a14c48, + (q31_t)0x1e3e5ee5, (q31_t)0x839fd014, (q31_t)0x1e3843e8, (q31_t)0x839e542d, + (q31_t)0x1e3228d9, (q31_t)0x839cd893, (q31_t)0x1e2c0db6, (q31_t)0x839b5d45, + (q31_t)0x1e25f282, (q31_t)0x8399e244, (q31_t)0x1e1fd73a, (q31_t)0x83986790, + (q31_t)0x1e19bbe0, (q31_t)0x8396ed29, (q31_t)0x1e13a074, (q31_t)0x8395730e, + (q31_t)0x1e0d84f5, (q31_t)0x8393f940, (q31_t)0x1e076963, (q31_t)0x83927fbf, + (q31_t)0x1e014dbf, (q31_t)0x8391068a, (q31_t)0x1dfb3208, (q31_t)0x838f8da2, + (q31_t)0x1df5163f, (q31_t)0x838e1507, (q31_t)0x1deefa63, (q31_t)0x838c9cb9, + (q31_t)0x1de8de75, (q31_t)0x838b24b8, (q31_t)0x1de2c275, (q31_t)0x8389ad03, + (q31_t)0x1ddca662, (q31_t)0x8388359b, (q31_t)0x1dd68a3c, (q31_t)0x8386be80, + (q31_t)0x1dd06e04, (q31_t)0x838547b2, (q31_t)0x1dca51ba, (q31_t)0x8383d130, + (q31_t)0x1dc4355e, (q31_t)0x83825afb, (q31_t)0x1dbe18ef, (q31_t)0x8380e513, + (q31_t)0x1db7fc6d, (q31_t)0x837f6f78, (q31_t)0x1db1dfda, (q31_t)0x837dfa2a, + (q31_t)0x1dabc334, (q31_t)0x837c8528, (q31_t)0x1da5a67c, (q31_t)0x837b1074, + (q31_t)0x1d9f89b1, (q31_t)0x83799c0c, (q31_t)0x1d996cd4, (q31_t)0x837827f0, + (q31_t)0x1d934fe5, (q31_t)0x8376b422, (q31_t)0x1d8d32e4, (q31_t)0x837540a1, + (q31_t)0x1d8715d0, (q31_t)0x8373cd6c, (q31_t)0x1d80f8ab, (q31_t)0x83725a84, + (q31_t)0x1d7adb73, (q31_t)0x8370e7e9, (q31_t)0x1d74be29, (q31_t)0x836f759b, + (q31_t)0x1d6ea0cc, (q31_t)0x836e039a, (q31_t)0x1d68835e, (q31_t)0x836c91e5, + (q31_t)0x1d6265dd, (q31_t)0x836b207d, (q31_t)0x1d5c484b, (q31_t)0x8369af63, + (q31_t)0x1d562aa6, (q31_t)0x83683e95, (q31_t)0x1d500cef, (q31_t)0x8366ce14, + (q31_t)0x1d49ef26, (q31_t)0x83655ddf, (q31_t)0x1d43d14b, (q31_t)0x8363edf8, + (q31_t)0x1d3db35e, (q31_t)0x83627e5d, (q31_t)0x1d37955e, (q31_t)0x83610f10, + (q31_t)0x1d31774d, (q31_t)0x835fa00f, (q31_t)0x1d2b592a, (q31_t)0x835e315b, + (q31_t)0x1d253af5, (q31_t)0x835cc2f4, (q31_t)0x1d1f1cae, (q31_t)0x835b54da, + (q31_t)0x1d18fe54, (q31_t)0x8359e70d, (q31_t)0x1d12dfe9, (q31_t)0x8358798c, + (q31_t)0x1d0cc16c, (q31_t)0x83570c59, (q31_t)0x1d06a2dd, (q31_t)0x83559f72, + (q31_t)0x1d00843d, (q31_t)0x835432d8, (q31_t)0x1cfa658a, (q31_t)0x8352c68c, + (q31_t)0x1cf446c5, (q31_t)0x83515a8c, (q31_t)0x1cee27ef, (q31_t)0x834feed9, + (q31_t)0x1ce80906, (q31_t)0x834e8373, (q31_t)0x1ce1ea0c, (q31_t)0x834d185a, + (q31_t)0x1cdbcb00, (q31_t)0x834bad8e, (q31_t)0x1cd5abe3, (q31_t)0x834a430e, + (q31_t)0x1ccf8cb3, (q31_t)0x8348d8dc, (q31_t)0x1cc96d72, (q31_t)0x83476ef6, + (q31_t)0x1cc34e1f, (q31_t)0x8346055e, (q31_t)0x1cbd2eba, (q31_t)0x83449c12, + (q31_t)0x1cb70f43, (q31_t)0x83433314, (q31_t)0x1cb0efbb, (q31_t)0x8341ca62, + (q31_t)0x1caad021, (q31_t)0x834061fd, (q31_t)0x1ca4b075, (q31_t)0x833ef9e6, + (q31_t)0x1c9e90b8, (q31_t)0x833d921b, (q31_t)0x1c9870e9, (q31_t)0x833c2a9d, + (q31_t)0x1c925109, (q31_t)0x833ac36c, (q31_t)0x1c8c3116, (q31_t)0x83395c88, + (q31_t)0x1c861113, (q31_t)0x8337f5f1, (q31_t)0x1c7ff0fd, (q31_t)0x83368fa7, + (q31_t)0x1c79d0d6, (q31_t)0x833529aa, (q31_t)0x1c73b09d, (q31_t)0x8333c3fa, + (q31_t)0x1c6d9053, (q31_t)0x83325e97, (q31_t)0x1c676ff8, (q31_t)0x8330f981, + (q31_t)0x1c614f8b, (q31_t)0x832f94b8, (q31_t)0x1c5b2f0c, (q31_t)0x832e303c, + (q31_t)0x1c550e7c, (q31_t)0x832ccc0d, (q31_t)0x1c4eedda, (q31_t)0x832b682b, + (q31_t)0x1c48cd27, (q31_t)0x832a0496, (q31_t)0x1c42ac62, (q31_t)0x8328a14d, + (q31_t)0x1c3c8b8c, (q31_t)0x83273e52, (q31_t)0x1c366aa5, (q31_t)0x8325dba4, + (q31_t)0x1c3049ac, (q31_t)0x83247943, (q31_t)0x1c2a28a2, (q31_t)0x8323172f, + (q31_t)0x1c240786, (q31_t)0x8321b568, (q31_t)0x1c1de659, (q31_t)0x832053ee, + (q31_t)0x1c17c51b, (q31_t)0x831ef2c1, (q31_t)0x1c11a3cb, (q31_t)0x831d91e1, + (q31_t)0x1c0b826a, (q31_t)0x831c314e, (q31_t)0x1c0560f8, (q31_t)0x831ad109, + (q31_t)0x1bff3f75, (q31_t)0x83197110, (q31_t)0x1bf91de0, (q31_t)0x83181164, + (q31_t)0x1bf2fc3a, (q31_t)0x8316b205, (q31_t)0x1becda83, (q31_t)0x831552f4, + (q31_t)0x1be6b8ba, (q31_t)0x8313f42f, (q31_t)0x1be096e0, (q31_t)0x831295b7, + (q31_t)0x1bda74f6, (q31_t)0x8311378d, (q31_t)0x1bd452f9, (q31_t)0x830fd9af, + (q31_t)0x1bce30ec, (q31_t)0x830e7c1f, (q31_t)0x1bc80ece, (q31_t)0x830d1edc, + (q31_t)0x1bc1ec9e, (q31_t)0x830bc1e6, (q31_t)0x1bbbca5e, (q31_t)0x830a653c, + (q31_t)0x1bb5a80c, (q31_t)0x830908e0, (q31_t)0x1baf85a9, (q31_t)0x8307acd1, + (q31_t)0x1ba96335, (q31_t)0x83065110, (q31_t)0x1ba340b0, (q31_t)0x8304f59b, + (q31_t)0x1b9d1e1a, (q31_t)0x83039a73, (q31_t)0x1b96fb73, (q31_t)0x83023f98, + (q31_t)0x1b90d8bb, (q31_t)0x8300e50b, (q31_t)0x1b8ab5f2, (q31_t)0x82ff8acb, + (q31_t)0x1b849317, (q31_t)0x82fe30d7, (q31_t)0x1b7e702c, (q31_t)0x82fcd731, + (q31_t)0x1b784d30, (q31_t)0x82fb7dd8, (q31_t)0x1b722a23, (q31_t)0x82fa24cc, + (q31_t)0x1b6c0705, (q31_t)0x82f8cc0d, (q31_t)0x1b65e3d7, (q31_t)0x82f7739c, + (q31_t)0x1b5fc097, (q31_t)0x82f61b77, (q31_t)0x1b599d46, (q31_t)0x82f4c3a0, + (q31_t)0x1b5379e5, (q31_t)0x82f36c15, (q31_t)0x1b4d5672, (q31_t)0x82f214d8, + (q31_t)0x1b4732ef, (q31_t)0x82f0bde8, (q31_t)0x1b410f5b, (q31_t)0x82ef6745, + (q31_t)0x1b3aebb6, (q31_t)0x82ee10ef, (q31_t)0x1b34c801, (q31_t)0x82ecbae7, + (q31_t)0x1b2ea43a, (q31_t)0x82eb652b, (q31_t)0x1b288063, (q31_t)0x82ea0fbd, + (q31_t)0x1b225c7b, (q31_t)0x82e8ba9c, (q31_t)0x1b1c3883, (q31_t)0x82e765c8, + (q31_t)0x1b161479, (q31_t)0x82e61141, (q31_t)0x1b0ff05f, (q31_t)0x82e4bd07, + (q31_t)0x1b09cc34, (q31_t)0x82e3691b, (q31_t)0x1b03a7f9, (q31_t)0x82e2157c, + (q31_t)0x1afd83ad, (q31_t)0x82e0c22a, (q31_t)0x1af75f50, (q31_t)0x82df6f25, + (q31_t)0x1af13ae3, (q31_t)0x82de1c6d, (q31_t)0x1aeb1665, (q31_t)0x82dcca02, + (q31_t)0x1ae4f1d6, (q31_t)0x82db77e5, (q31_t)0x1adecd37, (q31_t)0x82da2615, + (q31_t)0x1ad8a887, (q31_t)0x82d8d492, (q31_t)0x1ad283c7, (q31_t)0x82d7835c, + (q31_t)0x1acc5ef6, (q31_t)0x82d63274, (q31_t)0x1ac63a14, (q31_t)0x82d4e1d8, + (q31_t)0x1ac01522, (q31_t)0x82d3918a, (q31_t)0x1ab9f020, (q31_t)0x82d24189, + (q31_t)0x1ab3cb0d, (q31_t)0x82d0f1d5, (q31_t)0x1aada5e9, (q31_t)0x82cfa26f, + (q31_t)0x1aa780b6, (q31_t)0x82ce5356, (q31_t)0x1aa15b71, (q31_t)0x82cd048a, + (q31_t)0x1a9b361d, (q31_t)0x82cbb60b, (q31_t)0x1a9510b7, (q31_t)0x82ca67d9, + (q31_t)0x1a8eeb42, (q31_t)0x82c919f5, (q31_t)0x1a88c5bc, (q31_t)0x82c7cc5e, + (q31_t)0x1a82a026, (q31_t)0x82c67f14, (q31_t)0x1a7c7a7f, (q31_t)0x82c53217, + (q31_t)0x1a7654c8, (q31_t)0x82c3e568, (q31_t)0x1a702f01, (q31_t)0x82c29906, + (q31_t)0x1a6a0929, (q31_t)0x82c14cf1, (q31_t)0x1a63e341, (q31_t)0x82c00129, + (q31_t)0x1a5dbd49, (q31_t)0x82beb5af, (q31_t)0x1a579741, (q31_t)0x82bd6a82, + (q31_t)0x1a517128, (q31_t)0x82bc1fa2, (q31_t)0x1a4b4aff, (q31_t)0x82bad50f, + (q31_t)0x1a4524c6, (q31_t)0x82b98aca, (q31_t)0x1a3efe7c, (q31_t)0x82b840d2, + (q31_t)0x1a38d823, (q31_t)0x82b6f727, (q31_t)0x1a32b1b9, (q31_t)0x82b5adca, + (q31_t)0x1a2c8b3f, (q31_t)0x82b464ba, (q31_t)0x1a2664b5, (q31_t)0x82b31bf7, + (q31_t)0x1a203e1b, (q31_t)0x82b1d381, (q31_t)0x1a1a1771, (q31_t)0x82b08b59, + (q31_t)0x1a13f0b6, (q31_t)0x82af437e, (q31_t)0x1a0dc9ec, (q31_t)0x82adfbf0, + (q31_t)0x1a07a311, (q31_t)0x82acb4b0, (q31_t)0x1a017c27, (q31_t)0x82ab6dbd, + (q31_t)0x19fb552c, (q31_t)0x82aa2717, (q31_t)0x19f52e22, (q31_t)0x82a8e0bf, + (q31_t)0x19ef0707, (q31_t)0x82a79ab3, (q31_t)0x19e8dfdc, (q31_t)0x82a654f6, + (q31_t)0x19e2b8a2, (q31_t)0x82a50f85, (q31_t)0x19dc9157, (q31_t)0x82a3ca62, + (q31_t)0x19d669fc, (q31_t)0x82a2858c, (q31_t)0x19d04292, (q31_t)0x82a14104, + (q31_t)0x19ca1b17, (q31_t)0x829ffcc8, (q31_t)0x19c3f38d, (q31_t)0x829eb8db, + (q31_t)0x19bdcbf3, (q31_t)0x829d753a, (q31_t)0x19b7a449, (q31_t)0x829c31e7, + (q31_t)0x19b17c8f, (q31_t)0x829aeee1, (q31_t)0x19ab54c5, (q31_t)0x8299ac29, + (q31_t)0x19a52ceb, (q31_t)0x829869be, (q31_t)0x199f0502, (q31_t)0x829727a0, + (q31_t)0x1998dd09, (q31_t)0x8295e5cf, (q31_t)0x1992b4ff, (q31_t)0x8294a44c, + (q31_t)0x198c8ce7, (q31_t)0x82936317, (q31_t)0x198664be, (q31_t)0x8292222e, + (q31_t)0x19803c86, (q31_t)0x8290e194, (q31_t)0x197a143e, (q31_t)0x828fa146, + (q31_t)0x1973ebe6, (q31_t)0x828e6146, (q31_t)0x196dc37e, (q31_t)0x828d2193, + (q31_t)0x19679b07, (q31_t)0x828be22e, (q31_t)0x19617280, (q31_t)0x828aa316, + (q31_t)0x195b49ea, (q31_t)0x8289644b, (q31_t)0x19552144, (q31_t)0x828825ce, + (q31_t)0x194ef88e, (q31_t)0x8286e79e, (q31_t)0x1948cfc8, (q31_t)0x8285a9bb, + (q31_t)0x1942a6f3, (q31_t)0x82846c26, (q31_t)0x193c7e0f, (q31_t)0x82832edf, + (q31_t)0x1936551b, (q31_t)0x8281f1e4, (q31_t)0x19302c17, (q31_t)0x8280b538, + (q31_t)0x192a0304, (q31_t)0x827f78d8, (q31_t)0x1923d9e1, (q31_t)0x827e3cc6, + (q31_t)0x191db0af, (q31_t)0x827d0102, (q31_t)0x1917876d, (q31_t)0x827bc58a, + (q31_t)0x19115e1c, (q31_t)0x827a8a61, (q31_t)0x190b34bb, (q31_t)0x82794f84, + (q31_t)0x19050b4b, (q31_t)0x827814f6, (q31_t)0x18fee1cb, (q31_t)0x8276dab4, + (q31_t)0x18f8b83c, (q31_t)0x8275a0c0, (q31_t)0x18f28e9e, (q31_t)0x8274671a, + (q31_t)0x18ec64f0, (q31_t)0x82732dc0, (q31_t)0x18e63b33, (q31_t)0x8271f4b5, + (q31_t)0x18e01167, (q31_t)0x8270bbf7, (q31_t)0x18d9e78b, (q31_t)0x826f8386, + (q31_t)0x18d3bda0, (q31_t)0x826e4b62, (q31_t)0x18cd93a5, (q31_t)0x826d138d, + (q31_t)0x18c7699b, (q31_t)0x826bdc04, (q31_t)0x18c13f82, (q31_t)0x826aa4c9, + (q31_t)0x18bb155a, (q31_t)0x82696ddc, (q31_t)0x18b4eb22, (q31_t)0x8268373c, + (q31_t)0x18aec0db, (q31_t)0x826700e9, (q31_t)0x18a89685, (q31_t)0x8265cae4, + (q31_t)0x18a26c20, (q31_t)0x8264952d, (q31_t)0x189c41ab, (q31_t)0x82635fc2, + (q31_t)0x18961728, (q31_t)0x82622aa6, (q31_t)0x188fec95, (q31_t)0x8260f5d7, + (q31_t)0x1889c1f3, (q31_t)0x825fc155, (q31_t)0x18839742, (q31_t)0x825e8d21, + (q31_t)0x187d6c82, (q31_t)0x825d593a, (q31_t)0x187741b2, (q31_t)0x825c25a1, + (q31_t)0x187116d4, (q31_t)0x825af255, (q31_t)0x186aebe6, (q31_t)0x8259bf57, + (q31_t)0x1864c0ea, (q31_t)0x82588ca7, (q31_t)0x185e95de, (q31_t)0x82575a44, + (q31_t)0x18586ac3, (q31_t)0x8256282e, (q31_t)0x18523f9a, (q31_t)0x8254f666, + (q31_t)0x184c1461, (q31_t)0x8253c4eb, (q31_t)0x1845e919, (q31_t)0x825293be, + (q31_t)0x183fbdc3, (q31_t)0x825162df, (q31_t)0x1839925d, (q31_t)0x8250324d, + (q31_t)0x183366e9, (q31_t)0x824f0208, (q31_t)0x182d3b65, (q31_t)0x824dd211, + (q31_t)0x18270fd3, (q31_t)0x824ca268, (q31_t)0x1820e431, (q31_t)0x824b730c, + (q31_t)0x181ab881, (q31_t)0x824a43fe, (q31_t)0x18148cc2, (q31_t)0x8249153d, + (q31_t)0x180e60f4, (q31_t)0x8247e6ca, (q31_t)0x18083518, (q31_t)0x8246b8a4, + (q31_t)0x1802092c, (q31_t)0x82458acc, (q31_t)0x17fbdd32, (q31_t)0x82445d41, + (q31_t)0x17f5b129, (q31_t)0x82433004, (q31_t)0x17ef8511, (q31_t)0x82420315, + (q31_t)0x17e958ea, (q31_t)0x8240d673, (q31_t)0x17e32cb5, (q31_t)0x823faa1e, + (q31_t)0x17dd0070, (q31_t)0x823e7e18, (q31_t)0x17d6d41d, (q31_t)0x823d525e, + (q31_t)0x17d0a7bc, (q31_t)0x823c26f3, (q31_t)0x17ca7b4c, (q31_t)0x823afbd5, + (q31_t)0x17c44ecd, (q31_t)0x8239d104, (q31_t)0x17be223f, (q31_t)0x8238a681, + (q31_t)0x17b7f5a3, (q31_t)0x82377c4c, (q31_t)0x17b1c8f8, (q31_t)0x82365264, + (q31_t)0x17ab9c3e, (q31_t)0x823528ca, (q31_t)0x17a56f76, (q31_t)0x8233ff7e, + (q31_t)0x179f429f, (q31_t)0x8232d67f, (q31_t)0x179915ba, (q31_t)0x8231adce, + (q31_t)0x1792e8c6, (q31_t)0x8230856a, (q31_t)0x178cbbc4, (q31_t)0x822f5d54, + (q31_t)0x17868eb3, (q31_t)0x822e358b, (q31_t)0x17806194, (q31_t)0x822d0e10, + (q31_t)0x177a3466, (q31_t)0x822be6e3, (q31_t)0x17740729, (q31_t)0x822ac004, + (q31_t)0x176dd9de, (q31_t)0x82299971, (q31_t)0x1767ac85, (q31_t)0x8228732d, + (q31_t)0x17617f1d, (q31_t)0x82274d36, (q31_t)0x175b51a7, (q31_t)0x8226278d, + (q31_t)0x17552422, (q31_t)0x82250232, (q31_t)0x174ef68f, (q31_t)0x8223dd24, + (q31_t)0x1748c8ee, (q31_t)0x8222b863, (q31_t)0x17429b3e, (q31_t)0x822193f1, + (q31_t)0x173c6d80, (q31_t)0x82206fcc, (q31_t)0x17363fb4, (q31_t)0x821f4bf5, + (q31_t)0x173011d9, (q31_t)0x821e286b, (q31_t)0x1729e3f0, (q31_t)0x821d052f, + (q31_t)0x1723b5f9, (q31_t)0x821be240, (q31_t)0x171d87f3, (q31_t)0x821abfa0, + (q31_t)0x171759df, (q31_t)0x82199d4d, (q31_t)0x17112bbd, (q31_t)0x82187b47, + (q31_t)0x170afd8d, (q31_t)0x82175990, (q31_t)0x1704cf4f, (q31_t)0x82163826, + (q31_t)0x16fea102, (q31_t)0x82151709, (q31_t)0x16f872a7, (q31_t)0x8213f63a, + (q31_t)0x16f2443e, (q31_t)0x8212d5b9, (q31_t)0x16ec15c7, (q31_t)0x8211b586, + (q31_t)0x16e5e741, (q31_t)0x821095a0, (q31_t)0x16dfb8ae, (q31_t)0x820f7608, + (q31_t)0x16d98a0c, (q31_t)0x820e56be, (q31_t)0x16d35b5c, (q31_t)0x820d37c1, + (q31_t)0x16cd2c9f, (q31_t)0x820c1912, (q31_t)0x16c6fdd3, (q31_t)0x820afab1, + (q31_t)0x16c0cef9, (q31_t)0x8209dc9e, (q31_t)0x16baa011, (q31_t)0x8208bed8, + (q31_t)0x16b4711b, (q31_t)0x8207a160, (q31_t)0x16ae4217, (q31_t)0x82068435, + (q31_t)0x16a81305, (q31_t)0x82056758, (q31_t)0x16a1e3e5, (q31_t)0x82044ac9, + (q31_t)0x169bb4b7, (q31_t)0x82032e88, (q31_t)0x1695857b, (q31_t)0x82021294, + (q31_t)0x168f5632, (q31_t)0x8200f6ef, (q31_t)0x168926da, (q31_t)0x81ffdb96, + (q31_t)0x1682f774, (q31_t)0x81fec08c, (q31_t)0x167cc801, (q31_t)0x81fda5cf, + (q31_t)0x1676987f, (q31_t)0x81fc8b60, (q31_t)0x167068f0, (q31_t)0x81fb713f, + (q31_t)0x166a3953, (q31_t)0x81fa576c, (q31_t)0x166409a8, (q31_t)0x81f93de6, + (q31_t)0x165dd9f0, (q31_t)0x81f824ae, (q31_t)0x1657aa29, (q31_t)0x81f70bc3, + (q31_t)0x16517a55, (q31_t)0x81f5f327, (q31_t)0x164b4a73, (q31_t)0x81f4dad8, + (q31_t)0x16451a83, (q31_t)0x81f3c2d7, (q31_t)0x163eea86, (q31_t)0x81f2ab24, + (q31_t)0x1638ba7a, (q31_t)0x81f193be, (q31_t)0x16328a61, (q31_t)0x81f07ca6, + (q31_t)0x162c5a3b, (q31_t)0x81ef65dc, (q31_t)0x16262a06, (q31_t)0x81ee4f60, + (q31_t)0x161ff9c4, (q31_t)0x81ed3932, (q31_t)0x1619c975, (q31_t)0x81ec2351, + (q31_t)0x16139918, (q31_t)0x81eb0dbe, (q31_t)0x160d68ad, (q31_t)0x81e9f879, + (q31_t)0x16073834, (q31_t)0x81e8e381, (q31_t)0x160107ae, (q31_t)0x81e7ced8, + (q31_t)0x15fad71b, (q31_t)0x81e6ba7c, (q31_t)0x15f4a679, (q31_t)0x81e5a66e, + (q31_t)0x15ee75cb, (q31_t)0x81e492ad, (q31_t)0x15e8450e, (q31_t)0x81e37f3b, + (q31_t)0x15e21445, (q31_t)0x81e26c16, (q31_t)0x15dbe36d, (q31_t)0x81e1593f, + (q31_t)0x15d5b288, (q31_t)0x81e046b6, (q31_t)0x15cf8196, (q31_t)0x81df347b, + (q31_t)0x15c95097, (q31_t)0x81de228d, (q31_t)0x15c31f89, (q31_t)0x81dd10ee, + (q31_t)0x15bcee6f, (q31_t)0x81dbff9c, (q31_t)0x15b6bd47, (q31_t)0x81daee98, + (q31_t)0x15b08c12, (q31_t)0x81d9dde1, (q31_t)0x15aa5acf, (q31_t)0x81d8cd79, + (q31_t)0x15a4297f, (q31_t)0x81d7bd5e, (q31_t)0x159df821, (q31_t)0x81d6ad92, + (q31_t)0x1597c6b7, (q31_t)0x81d59e13, (q31_t)0x1591953e, (q31_t)0x81d48ee1, + (q31_t)0x158b63b9, (q31_t)0x81d37ffe, (q31_t)0x15853226, (q31_t)0x81d27169, + (q31_t)0x157f0086, (q31_t)0x81d16321, (q31_t)0x1578ced9, (q31_t)0x81d05527, + (q31_t)0x15729d1f, (q31_t)0x81cf477b, (q31_t)0x156c6b57, (q31_t)0x81ce3a1d, + (q31_t)0x15663982, (q31_t)0x81cd2d0c, (q31_t)0x156007a0, (q31_t)0x81cc204a, + (q31_t)0x1559d5b1, (q31_t)0x81cb13d5, (q31_t)0x1553a3b4, (q31_t)0x81ca07af, + (q31_t)0x154d71aa, (q31_t)0x81c8fbd6, (q31_t)0x15473f94, (q31_t)0x81c7f04b, + (q31_t)0x15410d70, (q31_t)0x81c6e50d, (q31_t)0x153adb3f, (q31_t)0x81c5da1e, + (q31_t)0x1534a901, (q31_t)0x81c4cf7d, (q31_t)0x152e76b5, (q31_t)0x81c3c529, + (q31_t)0x1528445d, (q31_t)0x81c2bb23, (q31_t)0x152211f8, (q31_t)0x81c1b16b, + (q31_t)0x151bdf86, (q31_t)0x81c0a801, (q31_t)0x1515ad06, (q31_t)0x81bf9ee5, + (q31_t)0x150f7a7a, (q31_t)0x81be9617, (q31_t)0x150947e1, (q31_t)0x81bd8d97, + (q31_t)0x1503153a, (q31_t)0x81bc8564, (q31_t)0x14fce287, (q31_t)0x81bb7d7f, + (q31_t)0x14f6afc7, (q31_t)0x81ba75e9, (q31_t)0x14f07cf9, (q31_t)0x81b96ea0, + (q31_t)0x14ea4a1f, (q31_t)0x81b867a5, (q31_t)0x14e41738, (q31_t)0x81b760f8, + (q31_t)0x14dde445, (q31_t)0x81b65a99, (q31_t)0x14d7b144, (q31_t)0x81b55488, + (q31_t)0x14d17e36, (q31_t)0x81b44ec4, (q31_t)0x14cb4b1c, (q31_t)0x81b3494f, + (q31_t)0x14c517f4, (q31_t)0x81b24427, (q31_t)0x14bee4c0, (q31_t)0x81b13f4e, + (q31_t)0x14b8b17f, (q31_t)0x81b03ac2, (q31_t)0x14b27e32, (q31_t)0x81af3684, + (q31_t)0x14ac4ad7, (q31_t)0x81ae3294, (q31_t)0x14a61770, (q31_t)0x81ad2ef2, + (q31_t)0x149fe3fc, (q31_t)0x81ac2b9e, (q31_t)0x1499b07c, (q31_t)0x81ab2898, + (q31_t)0x14937cee, (q31_t)0x81aa25e0, (q31_t)0x148d4954, (q31_t)0x81a92376, + (q31_t)0x148715ae, (q31_t)0x81a82159, (q31_t)0x1480e1fa, (q31_t)0x81a71f8b, + (q31_t)0x147aae3a, (q31_t)0x81a61e0b, (q31_t)0x14747a6d, (q31_t)0x81a51cd8, + (q31_t)0x146e4694, (q31_t)0x81a41bf4, (q31_t)0x146812ae, (q31_t)0x81a31b5d, + (q31_t)0x1461debc, (q31_t)0x81a21b14, (q31_t)0x145baabd, (q31_t)0x81a11b1a, + (q31_t)0x145576b1, (q31_t)0x81a01b6d, (q31_t)0x144f4299, (q31_t)0x819f1c0e, + (q31_t)0x14490e74, (q31_t)0x819e1cfd, (q31_t)0x1442da43, (q31_t)0x819d1e3a, + (q31_t)0x143ca605, (q31_t)0x819c1fc5, (q31_t)0x143671bb, (q31_t)0x819b219e, + (q31_t)0x14303d65, (q31_t)0x819a23c5, (q31_t)0x142a0902, (q31_t)0x8199263a, + (q31_t)0x1423d492, (q31_t)0x819828fd, (q31_t)0x141da016, (q31_t)0x81972c0e, + (q31_t)0x14176b8e, (q31_t)0x81962f6d, (q31_t)0x141136f9, (q31_t)0x8195331a, + (q31_t)0x140b0258, (q31_t)0x81943715, (q31_t)0x1404cdaa, (q31_t)0x81933b5e, + (q31_t)0x13fe98f1, (q31_t)0x81923ff4, (q31_t)0x13f8642a, (q31_t)0x819144d9, + (q31_t)0x13f22f58, (q31_t)0x81904a0c, (q31_t)0x13ebfa79, (q31_t)0x818f4f8d, + (q31_t)0x13e5c58e, (q31_t)0x818e555c, (q31_t)0x13df9097, (q31_t)0x818d5b78, + (q31_t)0x13d95b93, (q31_t)0x818c61e3, (q31_t)0x13d32683, (q31_t)0x818b689c, + (q31_t)0x13ccf167, (q31_t)0x818a6fa3, (q31_t)0x13c6bc3f, (q31_t)0x818976f8, + (q31_t)0x13c0870a, (q31_t)0x81887e9a, (q31_t)0x13ba51ca, (q31_t)0x8187868b, + (q31_t)0x13b41c7d, (q31_t)0x81868eca, (q31_t)0x13ade724, (q31_t)0x81859757, + (q31_t)0x13a7b1bf, (q31_t)0x8184a032, (q31_t)0x13a17c4d, (q31_t)0x8183a95b, + (q31_t)0x139b46d0, (q31_t)0x8182b2d1, (q31_t)0x13951146, (q31_t)0x8181bc96, + (q31_t)0x138edbb1, (q31_t)0x8180c6a9, (q31_t)0x1388a60f, (q31_t)0x817fd10a, + (q31_t)0x13827062, (q31_t)0x817edbb9, (q31_t)0x137c3aa8, (q31_t)0x817de6b6, + (q31_t)0x137604e2, (q31_t)0x817cf201, (q31_t)0x136fcf10, (q31_t)0x817bfd9b, + (q31_t)0x13699933, (q31_t)0x817b0982, (q31_t)0x13636349, (q31_t)0x817a15b7, + (q31_t)0x135d2d53, (q31_t)0x8179223a, (q31_t)0x1356f752, (q31_t)0x81782f0b, + (q31_t)0x1350c144, (q31_t)0x81773c2b, (q31_t)0x134a8b2b, (q31_t)0x81764998, + (q31_t)0x13445505, (q31_t)0x81755754, (q31_t)0x133e1ed4, (q31_t)0x8174655d, + (q31_t)0x1337e897, (q31_t)0x817373b5, (q31_t)0x1331b24e, (q31_t)0x8172825a, + (q31_t)0x132b7bf9, (q31_t)0x8171914e, (q31_t)0x13254599, (q31_t)0x8170a090, + (q31_t)0x131f0f2c, (q31_t)0x816fb020, (q31_t)0x1318d8b4, (q31_t)0x816ebffe, + (q31_t)0x1312a230, (q31_t)0x816dd02a, (q31_t)0x130c6ba0, (q31_t)0x816ce0a4, + (q31_t)0x13063505, (q31_t)0x816bf16c, (q31_t)0x12fffe5d, (q31_t)0x816b0282, + (q31_t)0x12f9c7aa, (q31_t)0x816a13e6, (q31_t)0x12f390ec, (q31_t)0x81692599, + (q31_t)0x12ed5a21, (q31_t)0x81683799, (q31_t)0x12e7234b, (q31_t)0x816749e8, + (q31_t)0x12e0ec6a, (q31_t)0x81665c84, (q31_t)0x12dab57c, (q31_t)0x81656f6f, + (q31_t)0x12d47e83, (q31_t)0x816482a8, (q31_t)0x12ce477f, (q31_t)0x8163962f, + (q31_t)0x12c8106f, (q31_t)0x8162aa04, (q31_t)0x12c1d953, (q31_t)0x8161be27, + (q31_t)0x12bba22b, (q31_t)0x8160d298, (q31_t)0x12b56af9, (q31_t)0x815fe758, + (q31_t)0x12af33ba, (q31_t)0x815efc65, (q31_t)0x12a8fc70, (q31_t)0x815e11c1, + (q31_t)0x12a2c51b, (q31_t)0x815d276a, (q31_t)0x129c8dba, (q31_t)0x815c3d62, + (q31_t)0x1296564d, (q31_t)0x815b53a8, (q31_t)0x12901ed5, (q31_t)0x815a6a3c, + (q31_t)0x1289e752, (q31_t)0x8159811e, (q31_t)0x1283afc3, (q31_t)0x8158984e, + (q31_t)0x127d7829, (q31_t)0x8157afcd, (q31_t)0x12774083, (q31_t)0x8156c799, + (q31_t)0x127108d2, (q31_t)0x8155dfb4, (q31_t)0x126ad116, (q31_t)0x8154f81d, + (q31_t)0x1264994e, (q31_t)0x815410d4, (q31_t)0x125e617b, (q31_t)0x815329d9, + (q31_t)0x1258299c, (q31_t)0x8152432c, (q31_t)0x1251f1b3, (q31_t)0x81515ccd, + (q31_t)0x124bb9be, (q31_t)0x815076bd, (q31_t)0x124581bd, (q31_t)0x814f90fb, + (q31_t)0x123f49b2, (q31_t)0x814eab86, (q31_t)0x1239119b, (q31_t)0x814dc660, + (q31_t)0x1232d979, (q31_t)0x814ce188, (q31_t)0x122ca14b, (q31_t)0x814bfcff, + (q31_t)0x12266913, (q31_t)0x814b18c3, (q31_t)0x122030cf, (q31_t)0x814a34d6, + (q31_t)0x1219f880, (q31_t)0x81495136, (q31_t)0x1213c026, (q31_t)0x81486de5, + (q31_t)0x120d87c1, (q31_t)0x81478ae2, (q31_t)0x12074f50, (q31_t)0x8146a82e, + (q31_t)0x120116d5, (q31_t)0x8145c5c7, (q31_t)0x11fade4e, (q31_t)0x8144e3ae, + (q31_t)0x11f4a5bd, (q31_t)0x814401e4, (q31_t)0x11ee6d20, (q31_t)0x81432068, + (q31_t)0x11e83478, (q31_t)0x81423f3a, (q31_t)0x11e1fbc5, (q31_t)0x81415e5a, + (q31_t)0x11dbc307, (q31_t)0x81407dc9, (q31_t)0x11d58a3e, (q31_t)0x813f9d86, + (q31_t)0x11cf516a, (q31_t)0x813ebd90, (q31_t)0x11c9188b, (q31_t)0x813ddde9, + (q31_t)0x11c2dfa2, (q31_t)0x813cfe91, (q31_t)0x11bca6ad, (q31_t)0x813c1f86, + (q31_t)0x11b66dad, (q31_t)0x813b40ca, (q31_t)0x11b034a2, (q31_t)0x813a625b, + (q31_t)0x11a9fb8d, (q31_t)0x8139843b, (q31_t)0x11a3c26c, (q31_t)0x8138a66a, + (q31_t)0x119d8941, (q31_t)0x8137c8e6, (q31_t)0x1197500a, (q31_t)0x8136ebb1, + (q31_t)0x119116c9, (q31_t)0x81360ec9, (q31_t)0x118add7d, (q31_t)0x81353230, + (q31_t)0x1184a427, (q31_t)0x813455e6, (q31_t)0x117e6ac5, (q31_t)0x813379e9, + (q31_t)0x11783159, (q31_t)0x81329e3b, (q31_t)0x1171f7e2, (q31_t)0x8131c2db, + (q31_t)0x116bbe60, (q31_t)0x8130e7c9, (q31_t)0x116584d3, (q31_t)0x81300d05, + (q31_t)0x115f4b3c, (q31_t)0x812f3290, (q31_t)0x1159119a, (q31_t)0x812e5868, + (q31_t)0x1152d7ed, (q31_t)0x812d7e8f, (q31_t)0x114c9e35, (q31_t)0x812ca505, + (q31_t)0x11466473, (q31_t)0x812bcbc8, (q31_t)0x11402aa6, (q31_t)0x812af2da, + (q31_t)0x1139f0cf, (q31_t)0x812a1a3a, (q31_t)0x1133b6ed, (q31_t)0x812941e8, + (q31_t)0x112d7d00, (q31_t)0x812869e4, (q31_t)0x11274309, (q31_t)0x8127922f, + (q31_t)0x11210907, (q31_t)0x8126bac8, (q31_t)0x111acefb, (q31_t)0x8125e3af, + (q31_t)0x111494e4, (q31_t)0x81250ce4, (q31_t)0x110e5ac2, (q31_t)0x81243668, + (q31_t)0x11082096, (q31_t)0x8123603a, (q31_t)0x1101e65f, (q31_t)0x81228a5a, + (q31_t)0x10fbac1e, (q31_t)0x8121b4c8, (q31_t)0x10f571d3, (q31_t)0x8120df85, + (q31_t)0x10ef377d, (q31_t)0x81200a90, (q31_t)0x10e8fd1c, (q31_t)0x811f35e9, + (q31_t)0x10e2c2b2, (q31_t)0x811e6191, (q31_t)0x10dc883c, (q31_t)0x811d8d86, + (q31_t)0x10d64dbd, (q31_t)0x811cb9ca, (q31_t)0x10d01333, (q31_t)0x811be65d, + (q31_t)0x10c9d89e, (q31_t)0x811b133d, (q31_t)0x10c39dff, (q31_t)0x811a406c, + (q31_t)0x10bd6356, (q31_t)0x81196de9, (q31_t)0x10b728a3, (q31_t)0x81189bb4, + (q31_t)0x10b0ede5, (q31_t)0x8117c9ce, (q31_t)0x10aab31d, (q31_t)0x8116f836, + (q31_t)0x10a4784b, (q31_t)0x811626ec, (q31_t)0x109e3d6e, (q31_t)0x811555f1, + (q31_t)0x10980287, (q31_t)0x81148544, (q31_t)0x1091c796, (q31_t)0x8113b4e5, + (q31_t)0x108b8c9b, (q31_t)0x8112e4d4, (q31_t)0x10855195, (q31_t)0x81121512, + (q31_t)0x107f1686, (q31_t)0x8111459e, (q31_t)0x1078db6c, (q31_t)0x81107678, + (q31_t)0x1072a048, (q31_t)0x810fa7a0, (q31_t)0x106c651a, (q31_t)0x810ed917, + (q31_t)0x106629e1, (q31_t)0x810e0adc, (q31_t)0x105fee9f, (q31_t)0x810d3cf0, + (q31_t)0x1059b352, (q31_t)0x810c6f52, (q31_t)0x105377fc, (q31_t)0x810ba202, + (q31_t)0x104d3c9b, (q31_t)0x810ad500, (q31_t)0x10470130, (q31_t)0x810a084d, + (q31_t)0x1040c5bb, (q31_t)0x81093be8, (q31_t)0x103a8a3d, (q31_t)0x81086fd1, + (q31_t)0x10344eb4, (q31_t)0x8107a409, (q31_t)0x102e1321, (q31_t)0x8106d88f, + (q31_t)0x1027d784, (q31_t)0x81060d63, (q31_t)0x10219bdd, (q31_t)0x81054286, + (q31_t)0x101b602d, (q31_t)0x810477f7, (q31_t)0x10152472, (q31_t)0x8103adb6, + (q31_t)0x100ee8ad, (q31_t)0x8102e3c4, (q31_t)0x1008acdf, (q31_t)0x81021a20, + (q31_t)0x10027107, (q31_t)0x810150ca, (q31_t)0xffc3524, (q31_t)0x810087c3, + (q31_t)0xff5f938, (q31_t)0x80ffbf0a, (q31_t)0xfefbd42, (q31_t)0x80fef69f, + (q31_t)0xfe98143, (q31_t)0x80fe2e83, (q31_t)0xfe34539, (q31_t)0x80fd66b5, + (q31_t)0xfdd0926, (q31_t)0x80fc9f35, (q31_t)0xfd6cd08, (q31_t)0x80fbd804, + (q31_t)0xfd090e1, (q31_t)0x80fb1121, (q31_t)0xfca54b1, (q31_t)0x80fa4a8c, + (q31_t)0xfc41876, (q31_t)0x80f98446, (q31_t)0xfbddc32, (q31_t)0x80f8be4e, + (q31_t)0xfb79fe4, (q31_t)0x80f7f8a4, (q31_t)0xfb1638d, (q31_t)0x80f73349, + (q31_t)0xfab272b, (q31_t)0x80f66e3c, (q31_t)0xfa4eac0, (q31_t)0x80f5a97e, + (q31_t)0xf9eae4c, (q31_t)0x80f4e50e, (q31_t)0xf9871ce, (q31_t)0x80f420ec, + (q31_t)0xf923546, (q31_t)0x80f35d19, (q31_t)0xf8bf8b4, (q31_t)0x80f29994, + (q31_t)0xf85bc19, (q31_t)0x80f1d65d, (q31_t)0xf7f7f75, (q31_t)0x80f11375, + (q31_t)0xf7942c7, (q31_t)0x80f050db, (q31_t)0xf73060f, (q31_t)0x80ef8e90, + (q31_t)0xf6cc94e, (q31_t)0x80eecc93, (q31_t)0xf668c83, (q31_t)0x80ee0ae4, + (q31_t)0xf604faf, (q31_t)0x80ed4984, (q31_t)0xf5a12d1, (q31_t)0x80ec8872, + (q31_t)0xf53d5ea, (q31_t)0x80ebc7ae, (q31_t)0xf4d98f9, (q31_t)0x80eb0739, + (q31_t)0xf475bff, (q31_t)0x80ea4712, (q31_t)0xf411efb, (q31_t)0x80e9873a, + (q31_t)0xf3ae1ee, (q31_t)0x80e8c7b0, (q31_t)0xf34a4d8, (q31_t)0x80e80874, + (q31_t)0xf2e67b8, (q31_t)0x80e74987, (q31_t)0xf282a8f, (q31_t)0x80e68ae8, + (q31_t)0xf21ed5d, (q31_t)0x80e5cc98, (q31_t)0xf1bb021, (q31_t)0x80e50e96, + (q31_t)0xf1572dc, (q31_t)0x80e450e2, (q31_t)0xf0f358e, (q31_t)0x80e3937d, + (q31_t)0xf08f836, (q31_t)0x80e2d666, (q31_t)0xf02bad5, (q31_t)0x80e2199e, + (q31_t)0xefc7d6b, (q31_t)0x80e15d24, (q31_t)0xef63ff7, (q31_t)0x80e0a0f8, + (q31_t)0xef0027b, (q31_t)0x80dfe51b, (q31_t)0xee9c4f5, (q31_t)0x80df298c, + (q31_t)0xee38766, (q31_t)0x80de6e4c, (q31_t)0xedd49ce, (q31_t)0x80ddb35a, + (q31_t)0xed70c2c, (q31_t)0x80dcf8b7, (q31_t)0xed0ce82, (q31_t)0x80dc3e62, + (q31_t)0xeca90ce, (q31_t)0x80db845b, (q31_t)0xec45311, (q31_t)0x80dacaa3, + (q31_t)0xebe154b, (q31_t)0x80da1139, (q31_t)0xeb7d77c, (q31_t)0x80d9581e, + (q31_t)0xeb199a4, (q31_t)0x80d89f51, (q31_t)0xeab5bc3, (q31_t)0x80d7e6d3, + (q31_t)0xea51dd8, (q31_t)0x80d72ea3, (q31_t)0xe9edfe5, (q31_t)0x80d676c1, + (q31_t)0xe98a1e9, (q31_t)0x80d5bf2e, (q31_t)0xe9263e3, (q31_t)0x80d507e9, + (q31_t)0xe8c25d5, (q31_t)0x80d450f3, (q31_t)0xe85e7be, (q31_t)0x80d39a4b, + (q31_t)0xe7fa99e, (q31_t)0x80d2e3f2, (q31_t)0xe796b74, (q31_t)0x80d22de7, + (q31_t)0xe732d42, (q31_t)0x80d1782a, (q31_t)0xe6cef07, (q31_t)0x80d0c2bc, + (q31_t)0xe66b0c3, (q31_t)0x80d00d9d, (q31_t)0xe607277, (q31_t)0x80cf58cc, + (q31_t)0xe5a3421, (q31_t)0x80cea449, (q31_t)0xe53f5c2, (q31_t)0x80cdf015, + (q31_t)0xe4db75b, (q31_t)0x80cd3c2f, (q31_t)0xe4778eb, (q31_t)0x80cc8898, + (q31_t)0xe413a72, (q31_t)0x80cbd54f, (q31_t)0xe3afbf0, (q31_t)0x80cb2255, + (q31_t)0xe34bd66, (q31_t)0x80ca6fa9, (q31_t)0xe2e7ed2, (q31_t)0x80c9bd4c, + (q31_t)0xe284036, (q31_t)0x80c90b3d, (q31_t)0xe220191, (q31_t)0x80c8597c, + (q31_t)0xe1bc2e4, (q31_t)0x80c7a80a, (q31_t)0xe15842e, (q31_t)0x80c6f6e7, + (q31_t)0xe0f456f, (q31_t)0x80c64612, (q31_t)0xe0906a7, (q31_t)0x80c5958b, + (q31_t)0xe02c7d7, (q31_t)0x80c4e553, (q31_t)0xdfc88fe, (q31_t)0x80c4356a, + (q31_t)0xdf64a1c, (q31_t)0x80c385cf, (q31_t)0xdf00b32, (q31_t)0x80c2d682, + (q31_t)0xde9cc40, (q31_t)0x80c22784, (q31_t)0xde38d44, (q31_t)0x80c178d4, + (q31_t)0xddd4e40, (q31_t)0x80c0ca73, (q31_t)0xdd70f34, (q31_t)0x80c01c60, + (q31_t)0xdd0d01f, (q31_t)0x80bf6e9c, (q31_t)0xdca9102, (q31_t)0x80bec127, + (q31_t)0xdc451dc, (q31_t)0x80be13ff, (q31_t)0xdbe12ad, (q31_t)0x80bd6727, + (q31_t)0xdb7d376, (q31_t)0x80bcba9d, (q31_t)0xdb19437, (q31_t)0x80bc0e61, + (q31_t)0xdab54ef, (q31_t)0x80bb6274, (q31_t)0xda5159f, (q31_t)0x80bab6d5, + (q31_t)0xd9ed646, (q31_t)0x80ba0b85, (q31_t)0xd9896e5, (q31_t)0x80b96083, + (q31_t)0xd92577b, (q31_t)0x80b8b5d0, (q31_t)0xd8c1809, (q31_t)0x80b80b6c, + (q31_t)0xd85d88f, (q31_t)0x80b76156, (q31_t)0xd7f990c, (q31_t)0x80b6b78e, + (q31_t)0xd795982, (q31_t)0x80b60e15, (q31_t)0xd7319ee, (q31_t)0x80b564ea, + (q31_t)0xd6cda53, (q31_t)0x80b4bc0e, (q31_t)0xd669aaf, (q31_t)0x80b41381, + (q31_t)0xd605b03, (q31_t)0x80b36b42, (q31_t)0xd5a1b4f, (q31_t)0x80b2c351, + (q31_t)0xd53db92, (q31_t)0x80b21baf, (q31_t)0xd4d9bcd, (q31_t)0x80b1745c, + (q31_t)0xd475c00, (q31_t)0x80b0cd57, (q31_t)0xd411c2b, (q31_t)0x80b026a1, + (q31_t)0xd3adc4e, (q31_t)0x80af8039, (q31_t)0xd349c68, (q31_t)0x80aeda20, + (q31_t)0xd2e5c7b, (q31_t)0x80ae3455, (q31_t)0xd281c85, (q31_t)0x80ad8ed9, + (q31_t)0xd21dc87, (q31_t)0x80ace9ab, (q31_t)0xd1b9c81, (q31_t)0x80ac44cc, + (q31_t)0xd155c73, (q31_t)0x80aba03b, (q31_t)0xd0f1c5d, (q31_t)0x80aafbf9, + (q31_t)0xd08dc3f, (q31_t)0x80aa5806, (q31_t)0xd029c18, (q31_t)0x80a9b461, + (q31_t)0xcfc5bea, (q31_t)0x80a9110b, (q31_t)0xcf61bb4, (q31_t)0x80a86e03, + (q31_t)0xcefdb76, (q31_t)0x80a7cb49, (q31_t)0xce99b2f, (q31_t)0x80a728df, + (q31_t)0xce35ae1, (q31_t)0x80a686c2, (q31_t)0xcdd1a8b, (q31_t)0x80a5e4f5, + (q31_t)0xcd6da2d, (q31_t)0x80a54376, (q31_t)0xcd099c7, (q31_t)0x80a4a245, + (q31_t)0xcca5959, (q31_t)0x80a40163, (q31_t)0xcc418e3, (q31_t)0x80a360d0, + (q31_t)0xcbdd865, (q31_t)0x80a2c08b, (q31_t)0xcb797e0, (q31_t)0x80a22095, + (q31_t)0xcb15752, (q31_t)0x80a180ed, (q31_t)0xcab16bd, (q31_t)0x80a0e194, + (q31_t)0xca4d620, (q31_t)0x80a04289, (q31_t)0xc9e957b, (q31_t)0x809fa3cd, + (q31_t)0xc9854cf, (q31_t)0x809f0560, (q31_t)0xc92141a, (q31_t)0x809e6741, + (q31_t)0xc8bd35e, (q31_t)0x809dc971, (q31_t)0xc85929a, (q31_t)0x809d2bef, + (q31_t)0xc7f51cf, (q31_t)0x809c8ebc, (q31_t)0xc7910fb, (q31_t)0x809bf1d7, + (q31_t)0xc72d020, (q31_t)0x809b5541, (q31_t)0xc6c8f3e, (q31_t)0x809ab8fa, + (q31_t)0xc664e53, (q31_t)0x809a1d01, (q31_t)0xc600d61, (q31_t)0x80998157, + (q31_t)0xc59cc68, (q31_t)0x8098e5fb, (q31_t)0xc538b66, (q31_t)0x80984aee, + (q31_t)0xc4d4a5d, (q31_t)0x8097b030, (q31_t)0xc47094d, (q31_t)0x809715c0, + (q31_t)0xc40c835, (q31_t)0x80967b9f, (q31_t)0xc3a8715, (q31_t)0x8095e1cc, + (q31_t)0xc3445ee, (q31_t)0x80954848, (q31_t)0xc2e04c0, (q31_t)0x8094af13, + (q31_t)0xc27c389, (q31_t)0x8094162c, (q31_t)0xc21824c, (q31_t)0x80937d93, + (q31_t)0xc1b4107, (q31_t)0x8092e54a, (q31_t)0xc14ffba, (q31_t)0x80924d4f, + (q31_t)0xc0ebe66, (q31_t)0x8091b5a2, (q31_t)0xc087d0a, (q31_t)0x80911e44, + (q31_t)0xc023ba7, (q31_t)0x80908735, (q31_t)0xbfbfa3d, (q31_t)0x808ff074, + (q31_t)0xbf5b8cb, (q31_t)0x808f5a02, (q31_t)0xbef7752, (q31_t)0x808ec3df, + (q31_t)0xbe935d2, (q31_t)0x808e2e0a, (q31_t)0xbe2f44a, (q31_t)0x808d9884, + (q31_t)0xbdcb2bb, (q31_t)0x808d034c, (q31_t)0xbd67124, (q31_t)0x808c6e63, + (q31_t)0xbd02f87, (q31_t)0x808bd9c9, (q31_t)0xbc9ede2, (q31_t)0x808b457d, + (q31_t)0xbc3ac35, (q31_t)0x808ab180, (q31_t)0xbbd6a82, (q31_t)0x808a1dd2, + (q31_t)0xbb728c7, (q31_t)0x80898a72, (q31_t)0xbb0e705, (q31_t)0x8088f761, + (q31_t)0xbaaa53b, (q31_t)0x8088649e, (q31_t)0xba4636b, (q31_t)0x8087d22a, + (q31_t)0xb9e2193, (q31_t)0x80874005, (q31_t)0xb97dfb5, (q31_t)0x8086ae2e, + (q31_t)0xb919dcf, (q31_t)0x80861ca6, (q31_t)0xb8b5be1, (q31_t)0x80858b6c, + (q31_t)0xb8519ed, (q31_t)0x8084fa82, (q31_t)0xb7ed7f2, (q31_t)0x808469e5, + (q31_t)0xb7895f0, (q31_t)0x8083d998, (q31_t)0xb7253e6, (q31_t)0x80834999, + (q31_t)0xb6c11d5, (q31_t)0x8082b9e9, (q31_t)0xb65cfbe, (q31_t)0x80822a87, + (q31_t)0xb5f8d9f, (q31_t)0x80819b74, (q31_t)0xb594b7a, (q31_t)0x80810cb0, + (q31_t)0xb53094d, (q31_t)0x80807e3a, (q31_t)0xb4cc719, (q31_t)0x807ff013, + (q31_t)0xb4684df, (q31_t)0x807f623b, (q31_t)0xb40429d, (q31_t)0x807ed4b1, + (q31_t)0xb3a0055, (q31_t)0x807e4776, (q31_t)0xb33be05, (q31_t)0x807dba89, + (q31_t)0xb2d7baf, (q31_t)0x807d2dec, (q31_t)0xb273952, (q31_t)0x807ca19c, + (q31_t)0xb20f6ee, (q31_t)0x807c159c, (q31_t)0xb1ab483, (q31_t)0x807b89ea, + (q31_t)0xb147211, (q31_t)0x807afe87, (q31_t)0xb0e2f98, (q31_t)0x807a7373, + (q31_t)0xb07ed19, (q31_t)0x8079e8ad, (q31_t)0xb01aa92, (q31_t)0x80795e36, + (q31_t)0xafb6805, (q31_t)0x8078d40d, (q31_t)0xaf52571, (q31_t)0x80784a33, + (q31_t)0xaeee2d7, (q31_t)0x8077c0a8, (q31_t)0xae8a036, (q31_t)0x8077376c, + (q31_t)0xae25d8d, (q31_t)0x8076ae7e, (q31_t)0xadc1adf, (q31_t)0x807625df, + (q31_t)0xad5d829, (q31_t)0x80759d8e, (q31_t)0xacf956d, (q31_t)0x8075158c, + (q31_t)0xac952aa, (q31_t)0x80748dd9, (q31_t)0xac30fe1, (q31_t)0x80740675, + (q31_t)0xabccd11, (q31_t)0x80737f5f, (q31_t)0xab68a3a, (q31_t)0x8072f898, + (q31_t)0xab0475c, (q31_t)0x8072721f, (q31_t)0xaaa0478, (q31_t)0x8071ebf6, + (q31_t)0xaa3c18e, (q31_t)0x8071661a, (q31_t)0xa9d7e9d, (q31_t)0x8070e08e, + (q31_t)0xa973ba5, (q31_t)0x80705b50, (q31_t)0xa90f8a7, (q31_t)0x806fd661, + (q31_t)0xa8ab5a2, (q31_t)0x806f51c1, (q31_t)0xa847297, (q31_t)0x806ecd6f, + (q31_t)0xa7e2f85, (q31_t)0x806e496c, (q31_t)0xa77ec6d, (q31_t)0x806dc5b8, + (q31_t)0xa71a94f, (q31_t)0x806d4253, (q31_t)0xa6b662a, (q31_t)0x806cbf3c, + (q31_t)0xa6522fe, (q31_t)0x806c3c74, (q31_t)0xa5edfcc, (q31_t)0x806bb9fa, + (q31_t)0xa589c94, (q31_t)0x806b37cf, (q31_t)0xa525955, (q31_t)0x806ab5f3, + (q31_t)0xa4c1610, (q31_t)0x806a3466, (q31_t)0xa45d2c5, (q31_t)0x8069b327, + (q31_t)0xa3f8f73, (q31_t)0x80693237, (q31_t)0xa394c1b, (q31_t)0x8068b196, + (q31_t)0xa3308bd, (q31_t)0x80683143, (q31_t)0xa2cc558, (q31_t)0x8067b13f, + (q31_t)0xa2681ed, (q31_t)0x8067318a, (q31_t)0xa203e7c, (q31_t)0x8066b224, + (q31_t)0xa19fb04, (q31_t)0x8066330c, (q31_t)0xa13b787, (q31_t)0x8065b443, + (q31_t)0xa0d7403, (q31_t)0x806535c9, (q31_t)0xa073079, (q31_t)0x8064b79d, + (q31_t)0xa00ece8, (q31_t)0x806439c0, (q31_t)0x9faa952, (q31_t)0x8063bc32, + (q31_t)0x9f465b5, (q31_t)0x80633ef3, (q31_t)0x9ee2213, (q31_t)0x8062c202, + (q31_t)0x9e7de6a, (q31_t)0x80624560, (q31_t)0x9e19abb, (q31_t)0x8061c90c, + (q31_t)0x9db5706, (q31_t)0x80614d08, (q31_t)0x9d5134b, (q31_t)0x8060d152, + (q31_t)0x9cecf89, (q31_t)0x806055eb, (q31_t)0x9c88bc2, (q31_t)0x805fdad2, + (q31_t)0x9c247f5, (q31_t)0x805f6009, (q31_t)0x9bc0421, (q31_t)0x805ee58e, + (q31_t)0x9b5c048, (q31_t)0x805e6b62, (q31_t)0x9af7c69, (q31_t)0x805df184, + (q31_t)0x9a93884, (q31_t)0x805d77f5, (q31_t)0x9a2f498, (q31_t)0x805cfeb5, + (q31_t)0x99cb0a7, (q31_t)0x805c85c4, (q31_t)0x9966cb0, (q31_t)0x805c0d21, + (q31_t)0x99028b3, (q31_t)0x805b94ce, (q31_t)0x989e4b0, (q31_t)0x805b1cc8, + (q31_t)0x983a0a7, (q31_t)0x805aa512, (q31_t)0x97d5c99, (q31_t)0x805a2daa, + (q31_t)0x9771884, (q31_t)0x8059b692, (q31_t)0x970d46a, (q31_t)0x80593fc7, + (q31_t)0x96a9049, (q31_t)0x8058c94c, (q31_t)0x9644c23, (q31_t)0x8058531f, + (q31_t)0x95e07f8, (q31_t)0x8057dd41, (q31_t)0x957c3c6, (q31_t)0x805767b2, + (q31_t)0x9517f8f, (q31_t)0x8056f272, (q31_t)0x94b3b52, (q31_t)0x80567d80, + (q31_t)0x944f70f, (q31_t)0x805608dd, (q31_t)0x93eb2c6, (q31_t)0x80559489, + (q31_t)0x9386e78, (q31_t)0x80552084, (q31_t)0x9322a24, (q31_t)0x8054accd, + (q31_t)0x92be5ca, (q31_t)0x80543965, (q31_t)0x925a16b, (q31_t)0x8053c64c, + (q31_t)0x91f5d06, (q31_t)0x80535381, (q31_t)0x919189c, (q31_t)0x8052e106, + (q31_t)0x912d42c, (q31_t)0x80526ed9, (q31_t)0x90c8fb6, (q31_t)0x8051fcfb, + (q31_t)0x9064b3a, (q31_t)0x80518b6b, (q31_t)0x90006ba, (q31_t)0x80511a2b, + (q31_t)0x8f9c233, (q31_t)0x8050a939, (q31_t)0x8f37da7, (q31_t)0x80503896, + (q31_t)0x8ed3916, (q31_t)0x804fc841, (q31_t)0x8e6f47f, (q31_t)0x804f583c, + (q31_t)0x8e0afe2, (q31_t)0x804ee885, (q31_t)0x8da6b40, (q31_t)0x804e791d, + (q31_t)0x8d42699, (q31_t)0x804e0a04, (q31_t)0x8cde1ec, (q31_t)0x804d9b39, + (q31_t)0x8c79d3a, (q31_t)0x804d2cbd, (q31_t)0x8c15882, (q31_t)0x804cbe90, + (q31_t)0x8bb13c5, (q31_t)0x804c50b2, (q31_t)0x8b4cf02, (q31_t)0x804be323, + (q31_t)0x8ae8a3a, (q31_t)0x804b75e2, (q31_t)0x8a8456d, (q31_t)0x804b08f0, + (q31_t)0x8a2009a, (q31_t)0x804a9c4d, (q31_t)0x89bbbc3, (q31_t)0x804a2ff9, + (q31_t)0x89576e5, (q31_t)0x8049c3f3, (q31_t)0x88f3203, (q31_t)0x8049583d, + (q31_t)0x888ed1b, (q31_t)0x8048ecd5, (q31_t)0x882a82e, (q31_t)0x804881bb, + (q31_t)0x87c633c, (q31_t)0x804816f1, (q31_t)0x8761e44, (q31_t)0x8047ac75, + (q31_t)0x86fd947, (q31_t)0x80474248, (q31_t)0x8699445, (q31_t)0x8046d86a, + (q31_t)0x8634f3e, (q31_t)0x80466edb, (q31_t)0x85d0a32, (q31_t)0x8046059b, + (q31_t)0x856c520, (q31_t)0x80459ca9, (q31_t)0x850800a, (q31_t)0x80453406, + (q31_t)0x84a3aee, (q31_t)0x8044cbb2, (q31_t)0x843f5cd, (q31_t)0x804463ad, + (q31_t)0x83db0a7, (q31_t)0x8043fbf6, (q31_t)0x8376b7c, (q31_t)0x8043948e, + (q31_t)0x831264c, (q31_t)0x80432d75, (q31_t)0x82ae117, (q31_t)0x8042c6ab, + (q31_t)0x8249bdd, (q31_t)0x80426030, (q31_t)0x81e569d, (q31_t)0x8041fa03, + (q31_t)0x8181159, (q31_t)0x80419425, (q31_t)0x811cc10, (q31_t)0x80412e96, + (q31_t)0x80b86c2, (q31_t)0x8040c956, (q31_t)0x805416e, (q31_t)0x80406465, + (q31_t)0x7fefc16, (q31_t)0x803fffc2, (q31_t)0x7f8b6b9, (q31_t)0x803f9b6f, + (q31_t)0x7f27157, (q31_t)0x803f376a, (q31_t)0x7ec2bf0, (q31_t)0x803ed3b3, + (q31_t)0x7e5e685, (q31_t)0x803e704c, (q31_t)0x7dfa114, (q31_t)0x803e0d34, + (q31_t)0x7d95b9e, (q31_t)0x803daa6a, (q31_t)0x7d31624, (q31_t)0x803d47ef, + (q31_t)0x7ccd0a5, (q31_t)0x803ce5c3, (q31_t)0x7c68b21, (q31_t)0x803c83e5, + (q31_t)0x7c04598, (q31_t)0x803c2257, (q31_t)0x7ba000b, (q31_t)0x803bc117, + (q31_t)0x7b3ba78, (q31_t)0x803b6026, (q31_t)0x7ad74e1, (q31_t)0x803aff84, + (q31_t)0x7a72f45, (q31_t)0x803a9f31, (q31_t)0x7a0e9a5, (q31_t)0x803a3f2d, + (q31_t)0x79aa400, (q31_t)0x8039df77, (q31_t)0x7945e56, (q31_t)0x80398010, + (q31_t)0x78e18a7, (q31_t)0x803920f8, (q31_t)0x787d2f4, (q31_t)0x8038c22f, + (q31_t)0x7818d3c, (q31_t)0x803863b5, (q31_t)0x77b4780, (q31_t)0x80380589, + (q31_t)0x77501be, (q31_t)0x8037a7ac, (q31_t)0x76ebbf9, (q31_t)0x80374a1f, + (q31_t)0x768762e, (q31_t)0x8036ece0, (q31_t)0x762305f, (q31_t)0x80368fef, + (q31_t)0x75bea8c, (q31_t)0x8036334e, (q31_t)0x755a4b4, (q31_t)0x8035d6fb, + (q31_t)0x74f5ed7, (q31_t)0x80357af8, (q31_t)0x74918f6, (q31_t)0x80351f43, + (q31_t)0x742d311, (q31_t)0x8034c3dd, (q31_t)0x73c8d27, (q31_t)0x803468c5, + (q31_t)0x7364738, (q31_t)0x80340dfd, (q31_t)0x7300145, (q31_t)0x8033b383, + (q31_t)0x729bb4e, (q31_t)0x80335959, (q31_t)0x7237552, (q31_t)0x8032ff7d, + (q31_t)0x71d2f52, (q31_t)0x8032a5ef, (q31_t)0x716e94e, (q31_t)0x80324cb1, + (q31_t)0x710a345, (q31_t)0x8031f3c2, (q31_t)0x70a5d37, (q31_t)0x80319b21, + (q31_t)0x7041726, (q31_t)0x803142cf, (q31_t)0x6fdd110, (q31_t)0x8030eacd, + (q31_t)0x6f78af6, (q31_t)0x80309318, (q31_t)0x6f144d7, (q31_t)0x80303bb3, + (q31_t)0x6eafeb4, (q31_t)0x802fe49d, (q31_t)0x6e4b88d, (q31_t)0x802f8dd5, + (q31_t)0x6de7262, (q31_t)0x802f375d, (q31_t)0x6d82c32, (q31_t)0x802ee133, + (q31_t)0x6d1e5fe, (q31_t)0x802e8b58, (q31_t)0x6cb9fc6, (q31_t)0x802e35cb, + (q31_t)0x6c5598a, (q31_t)0x802de08e, (q31_t)0x6bf1349, (q31_t)0x802d8ba0, + (q31_t)0x6b8cd05, (q31_t)0x802d3700, (q31_t)0x6b286bc, (q31_t)0x802ce2af, + (q31_t)0x6ac406f, (q31_t)0x802c8ead, (q31_t)0x6a5fa1e, (q31_t)0x802c3afa, + (q31_t)0x69fb3c9, (q31_t)0x802be796, (q31_t)0x6996d70, (q31_t)0x802b9480, + (q31_t)0x6932713, (q31_t)0x802b41ba, (q31_t)0x68ce0b2, (q31_t)0x802aef42, + (q31_t)0x6869a4c, (q31_t)0x802a9d19, (q31_t)0x68053e3, (q31_t)0x802a4b3f, + (q31_t)0x67a0d76, (q31_t)0x8029f9b4, (q31_t)0x673c704, (q31_t)0x8029a878, + (q31_t)0x66d808f, (q31_t)0x8029578b, (q31_t)0x6673a16, (q31_t)0x802906ec, + (q31_t)0x660f398, (q31_t)0x8028b69c, (q31_t)0x65aad17, (q31_t)0x8028669b, + (q31_t)0x6546692, (q31_t)0x802816e9, (q31_t)0x64e2009, (q31_t)0x8027c786, + (q31_t)0x647d97c, (q31_t)0x80277872, (q31_t)0x64192eb, (q31_t)0x802729ad, + (q31_t)0x63b4c57, (q31_t)0x8026db36, (q31_t)0x63505be, (q31_t)0x80268d0e, + (q31_t)0x62ebf22, (q31_t)0x80263f36, (q31_t)0x6287882, (q31_t)0x8025f1ac, + (q31_t)0x62231de, (q31_t)0x8025a471, (q31_t)0x61beb36, (q31_t)0x80255784, + (q31_t)0x615a48b, (q31_t)0x80250ae7, (q31_t)0x60f5ddc, (q31_t)0x8024be99, + (q31_t)0x6091729, (q31_t)0x80247299, (q31_t)0x602d072, (q31_t)0x802426e8, + (q31_t)0x5fc89b8, (q31_t)0x8023db86, (q31_t)0x5f642fa, (q31_t)0x80239073, + (q31_t)0x5effc38, (q31_t)0x802345af, (q31_t)0x5e9b572, (q31_t)0x8022fb3a, + (q31_t)0x5e36ea9, (q31_t)0x8022b114, (q31_t)0x5dd27dd, (q31_t)0x8022673c, + (q31_t)0x5d6e10c, (q31_t)0x80221db3, (q31_t)0x5d09a38, (q31_t)0x8021d47a, + (q31_t)0x5ca5361, (q31_t)0x80218b8f, (q31_t)0x5c40c86, (q31_t)0x802142f3, + (q31_t)0x5bdc5a7, (q31_t)0x8020faa6, (q31_t)0x5b77ec5, (q31_t)0x8020b2a7, + (q31_t)0x5b137df, (q31_t)0x80206af8, (q31_t)0x5aaf0f6, (q31_t)0x80202397, + (q31_t)0x5a4aa09, (q31_t)0x801fdc86, (q31_t)0x59e6319, (q31_t)0x801f95c3, + (q31_t)0x5981c26, (q31_t)0x801f4f4f, (q31_t)0x591d52f, (q31_t)0x801f092a, + (q31_t)0x58b8e34, (q31_t)0x801ec354, (q31_t)0x5854736, (q31_t)0x801e7dcd, + (q31_t)0x57f0035, (q31_t)0x801e3895, (q31_t)0x578b930, (q31_t)0x801df3ab, + (q31_t)0x5727228, (q31_t)0x801daf11, (q31_t)0x56c2b1c, (q31_t)0x801d6ac5, + (q31_t)0x565e40d, (q31_t)0x801d26c8, (q31_t)0x55f9cfb, (q31_t)0x801ce31a, + (q31_t)0x55955e6, (q31_t)0x801c9fbb, (q31_t)0x5530ecd, (q31_t)0x801c5cab, + (q31_t)0x54cc7b1, (q31_t)0x801c19ea, (q31_t)0x5468092, (q31_t)0x801bd777, + (q31_t)0x540396f, (q31_t)0x801b9554, (q31_t)0x539f249, (q31_t)0x801b537f, + (q31_t)0x533ab20, (q31_t)0x801b11fa, (q31_t)0x52d63f4, (q31_t)0x801ad0c3, + (q31_t)0x5271cc4, (q31_t)0x801a8fdb, (q31_t)0x520d592, (q31_t)0x801a4f42, + (q31_t)0x51a8e5c, (q31_t)0x801a0ef8, (q31_t)0x5144723, (q31_t)0x8019cefd, + (q31_t)0x50dffe7, (q31_t)0x80198f50, (q31_t)0x507b8a8, (q31_t)0x80194ff3, + (q31_t)0x5017165, (q31_t)0x801910e4, (q31_t)0x4fb2a20, (q31_t)0x8018d225, + (q31_t)0x4f4e2d8, (q31_t)0x801893b4, (q31_t)0x4ee9b8c, (q31_t)0x80185592, + (q31_t)0x4e8543e, (q31_t)0x801817bf, (q31_t)0x4e20cec, (q31_t)0x8017da3b, + (q31_t)0x4dbc597, (q31_t)0x80179d06, (q31_t)0x4d57e40, (q31_t)0x80176020, + (q31_t)0x4cf36e5, (q31_t)0x80172388, (q31_t)0x4c8ef88, (q31_t)0x8016e740, + (q31_t)0x4c2a827, (q31_t)0x8016ab46, (q31_t)0x4bc60c4, (q31_t)0x80166f9c, + (q31_t)0x4b6195d, (q31_t)0x80163440, (q31_t)0x4afd1f4, (q31_t)0x8015f933, + (q31_t)0x4a98a88, (q31_t)0x8015be75, (q31_t)0x4a34319, (q31_t)0x80158406, + (q31_t)0x49cfba7, (q31_t)0x801549e6, (q31_t)0x496b432, (q31_t)0x80151015, + (q31_t)0x4906cbb, (q31_t)0x8014d693, (q31_t)0x48a2540, (q31_t)0x80149d5f, + (q31_t)0x483ddc3, (q31_t)0x8014647b, (q31_t)0x47d9643, (q31_t)0x80142be5, + (q31_t)0x4774ec1, (q31_t)0x8013f39e, (q31_t)0x471073b, (q31_t)0x8013bba7, + (q31_t)0x46abfb3, (q31_t)0x801383fe, (q31_t)0x4647828, (q31_t)0x80134ca4, + (q31_t)0x45e309a, (q31_t)0x80131599, (q31_t)0x457e90a, (q31_t)0x8012dedd, + (q31_t)0x451a177, (q31_t)0x8012a86f, (q31_t)0x44b59e1, (q31_t)0x80127251, + (q31_t)0x4451249, (q31_t)0x80123c82, (q31_t)0x43ecaae, (q31_t)0x80120701, + (q31_t)0x4388310, (q31_t)0x8011d1d0, (q31_t)0x4323b70, (q31_t)0x80119ced, + (q31_t)0x42bf3cd, (q31_t)0x80116859, (q31_t)0x425ac28, (q31_t)0x80113414, + (q31_t)0x41f6480, (q31_t)0x8011001f, (q31_t)0x4191cd5, (q31_t)0x8010cc78, + (q31_t)0x412d528, (q31_t)0x8010991f, (q31_t)0x40c8d79, (q31_t)0x80106616, + (q31_t)0x40645c7, (q31_t)0x8010335c, (q31_t)0x3fffe12, (q31_t)0x801000f1, + (q31_t)0x3f9b65b, (q31_t)0x800fced4, (q31_t)0x3f36ea2, (q31_t)0x800f9d07, + (q31_t)0x3ed26e6, (q31_t)0x800f6b88, (q31_t)0x3e6df28, (q31_t)0x800f3a59, + (q31_t)0x3e09767, (q31_t)0x800f0978, (q31_t)0x3da4fa4, (q31_t)0x800ed8e6, + (q31_t)0x3d407df, (q31_t)0x800ea8a3, (q31_t)0x3cdc017, (q31_t)0x800e78af, + (q31_t)0x3c7784d, (q31_t)0x800e490a, (q31_t)0x3c13080, (q31_t)0x800e19b4, + (q31_t)0x3bae8b2, (q31_t)0x800deaad, (q31_t)0x3b4a0e0, (q31_t)0x800dbbf5, + (q31_t)0x3ae590d, (q31_t)0x800d8d8b, (q31_t)0x3a81137, (q31_t)0x800d5f71, + (q31_t)0x3a1c960, (q31_t)0x800d31a5, (q31_t)0x39b8185, (q31_t)0x800d0429, + (q31_t)0x39539a9, (q31_t)0x800cd6fb, (q31_t)0x38ef1ca, (q31_t)0x800caa1c, + (q31_t)0x388a9ea, (q31_t)0x800c7d8c, (q31_t)0x3826207, (q31_t)0x800c514c, + (q31_t)0x37c1a22, (q31_t)0x800c255a, (q31_t)0x375d23a, (q31_t)0x800bf9b7, + (q31_t)0x36f8a51, (q31_t)0x800bce63, (q31_t)0x3694265, (q31_t)0x800ba35d, + (q31_t)0x362fa78, (q31_t)0x800b78a7, (q31_t)0x35cb288, (q31_t)0x800b4e40, + (q31_t)0x3566a96, (q31_t)0x800b2427, (q31_t)0x35022a2, (q31_t)0x800afa5e, + (q31_t)0x349daac, (q31_t)0x800ad0e3, (q31_t)0x34392b4, (q31_t)0x800aa7b8, + (q31_t)0x33d4abb, (q31_t)0x800a7edb, (q31_t)0x33702bf, (q31_t)0x800a564e, + (q31_t)0x330bac1, (q31_t)0x800a2e0f, (q31_t)0x32a72c1, (q31_t)0x800a061f, + (q31_t)0x3242abf, (q31_t)0x8009de7e, (q31_t)0x31de2bb, (q31_t)0x8009b72c, + (q31_t)0x3179ab5, (q31_t)0x80099029, (q31_t)0x31152ae, (q31_t)0x80096975, + (q31_t)0x30b0aa4, (q31_t)0x80094310, (q31_t)0x304c299, (q31_t)0x80091cf9, + (q31_t)0x2fe7a8c, (q31_t)0x8008f732, (q31_t)0x2f8327d, (q31_t)0x8008d1ba, + (q31_t)0x2f1ea6c, (q31_t)0x8008ac90, (q31_t)0x2eba259, (q31_t)0x800887b6, + (q31_t)0x2e55a44, (q31_t)0x8008632a, (q31_t)0x2df122e, (q31_t)0x80083eed, + (q31_t)0x2d8ca16, (q31_t)0x80081b00, (q31_t)0x2d281fc, (q31_t)0x8007f761, + (q31_t)0x2cc39e1, (q31_t)0x8007d411, (q31_t)0x2c5f1c3, (q31_t)0x8007b110, + (q31_t)0x2bfa9a4, (q31_t)0x80078e5e, (q31_t)0x2b96184, (q31_t)0x80076bfb, + (q31_t)0x2b31961, (q31_t)0x800749e7, (q31_t)0x2acd13d, (q31_t)0x80072822, + (q31_t)0x2a68917, (q31_t)0x800706ac, (q31_t)0x2a040f0, (q31_t)0x8006e585, + (q31_t)0x299f8c7, (q31_t)0x8006c4ac, (q31_t)0x293b09c, (q31_t)0x8006a423, + (q31_t)0x28d6870, (q31_t)0x800683e8, (q31_t)0x2872043, (q31_t)0x800663fd, + (q31_t)0x280d813, (q31_t)0x80064460, (q31_t)0x27a8fe2, (q31_t)0x80062513, + (q31_t)0x27447b0, (q31_t)0x80060614, (q31_t)0x26dff7c, (q31_t)0x8005e764, + (q31_t)0x267b747, (q31_t)0x8005c904, (q31_t)0x2616f10, (q31_t)0x8005aaf2, + (q31_t)0x25b26d7, (q31_t)0x80058d2f, (q31_t)0x254de9e, (q31_t)0x80056fbb, + (q31_t)0x24e9662, (q31_t)0x80055296, (q31_t)0x2484e26, (q31_t)0x800535c0, + (q31_t)0x24205e8, (q31_t)0x80051939, (q31_t)0x23bbda8, (q31_t)0x8004fd00, + (q31_t)0x2357567, (q31_t)0x8004e117, (q31_t)0x22f2d25, (q31_t)0x8004c57d, + (q31_t)0x228e4e2, (q31_t)0x8004aa32, (q31_t)0x2229c9d, (q31_t)0x80048f35, + (q31_t)0x21c5457, (q31_t)0x80047488, (q31_t)0x2160c0f, (q31_t)0x80045a29, + (q31_t)0x20fc3c6, (q31_t)0x8004401a, (q31_t)0x2097b7c, (q31_t)0x80042659, + (q31_t)0x2033331, (q31_t)0x80040ce7, (q31_t)0x1fceae4, (q31_t)0x8003f3c5, + (q31_t)0x1f6a297, (q31_t)0x8003daf1, (q31_t)0x1f05a48, (q31_t)0x8003c26c, + (q31_t)0x1ea11f7, (q31_t)0x8003aa36, (q31_t)0x1e3c9a6, (q31_t)0x8003924f, + (q31_t)0x1dd8154, (q31_t)0x80037ab7, (q31_t)0x1d73900, (q31_t)0x8003636e, + (q31_t)0x1d0f0ab, (q31_t)0x80034c74, (q31_t)0x1caa855, (q31_t)0x800335c9, + (q31_t)0x1c45ffe, (q31_t)0x80031f6d, (q31_t)0x1be17a6, (q31_t)0x80030960, + (q31_t)0x1b7cf4d, (q31_t)0x8002f3a1, (q31_t)0x1b186f3, (q31_t)0x8002de32, + (q31_t)0x1ab3e97, (q31_t)0x8002c912, (q31_t)0x1a4f63b, (q31_t)0x8002b440, + (q31_t)0x19eaddd, (q31_t)0x80029fbe, (q31_t)0x198657f, (q31_t)0x80028b8a, + (q31_t)0x1921d20, (q31_t)0x800277a6, (q31_t)0x18bd4bf, (q31_t)0x80026410, + (q31_t)0x1858c5e, (q31_t)0x800250c9, (q31_t)0x17f43fc, (q31_t)0x80023dd2, + (q31_t)0x178fb99, (q31_t)0x80022b29, (q31_t)0x172b335, (q31_t)0x800218cf, + (q31_t)0x16c6ad0, (q31_t)0x800206c4, (q31_t)0x166226a, (q31_t)0x8001f508, + (q31_t)0x15fda03, (q31_t)0x8001e39b, (q31_t)0x159919c, (q31_t)0x8001d27d, + (q31_t)0x1534934, (q31_t)0x8001c1ae, (q31_t)0x14d00ca, (q31_t)0x8001b12e, + (q31_t)0x146b860, (q31_t)0x8001a0fd, (q31_t)0x1406ff6, (q31_t)0x8001911b, + (q31_t)0x13a278a, (q31_t)0x80018187, (q31_t)0x133df1e, (q31_t)0x80017243, + (q31_t)0x12d96b1, (q31_t)0x8001634e, (q31_t)0x1274e43, (q31_t)0x800154a7, + (q31_t)0x12105d5, (q31_t)0x80014650, (q31_t)0x11abd66, (q31_t)0x80013847, + (q31_t)0x11474f6, (q31_t)0x80012a8e, (q31_t)0x10e2c85, (q31_t)0x80011d23, + (q31_t)0x107e414, (q31_t)0x80011008, (q31_t)0x1019ba2, (q31_t)0x8001033b, + (q31_t)0x0fb5330, (q31_t)0x8000f6bd, (q31_t)0x0f50abd, (q31_t)0x8000ea8e, + (q31_t)0x0eec249, (q31_t)0x8000deaf, (q31_t)0x0e879d5, (q31_t)0x8000d31e, + (q31_t)0x0e23160, (q31_t)0x8000c7dc, (q31_t)0x0dbe8eb, (q31_t)0x8000bce9, + (q31_t)0x0d5a075, (q31_t)0x8000b245, (q31_t)0x0cf57ff, (q31_t)0x8000a7f0, + (q31_t)0x0c90f88, (q31_t)0x80009dea, (q31_t)0x0c2c711, (q31_t)0x80009433, + (q31_t)0x0bc7e99, (q31_t)0x80008aca, (q31_t)0x0b63621, (q31_t)0x800081b1, + (q31_t)0x0afeda8, (q31_t)0x800078e7, (q31_t)0x0a9a52f, (q31_t)0x8000706c, + (q31_t)0x0a35cb5, (q31_t)0x8000683f, (q31_t)0x09d143b, (q31_t)0x80006062, + (q31_t)0x096cbc1, (q31_t)0x800058d4, (q31_t)0x0908346, (q31_t)0x80005194, + (q31_t)0x08a3acb, (q31_t)0x80004aa4, (q31_t)0x083f250, (q31_t)0x80004402, + (q31_t)0x07da9d4, (q31_t)0x80003daf, (q31_t)0x0776159, (q31_t)0x800037ac, + (q31_t)0x07118dc, (q31_t)0x800031f7, (q31_t)0x06ad060, (q31_t)0x80002c91, + (q31_t)0x06487e3, (q31_t)0x8000277a, (q31_t)0x05e3f66, (q31_t)0x800022b3, + (q31_t)0x057f6e9, (q31_t)0x80001e3a, (q31_t)0x051ae6b, (q31_t)0x80001a10, + (q31_t)0x04b65ee, (q31_t)0x80001635, (q31_t)0x0451d70, (q31_t)0x800012a9, + (q31_t)0x03ed4f2, (q31_t)0x80000f6c, (q31_t)0x0388c74, (q31_t)0x80000c7e, + (q31_t)0x03243f5, (q31_t)0x800009df, (q31_t)0x02bfb77, (q31_t)0x8000078e, + (q31_t)0x025b2f8, (q31_t)0x8000058d, (q31_t)0x01f6a7a, (q31_t)0x800003db, + (q31_t)0x01921fb, (q31_t)0x80000278, (q31_t)0x012d97c, (q31_t)0x80000163, + (q31_t)0x00c90fe, (q31_t)0x8000009e, (q31_t)0x006487f, (q31_t)0x80000027}; /** @par - cosFactor tables are generated using the formula :
cos_factors[n] = 2 * cos((2n+1)*pi/(4*N))
+ cosFactor tables are generated using the formula :
cos_factors[n] = 2 *
+  cos((2n+1)*pi/(4*N))
@par C command to generate the table
@@ -2804,1719 +5524,2740 @@ static const q31_t WeightsQ31_8192[16384] = {
     cos_factors[i] = 2 * cos((2*i+1)*c/2);
   } 
@par - where N is the number of factors to generate and c is pi/(2*N) + where N is the number of factors to generate and c + is pi/(2*N) @par - Then converted to q31 format by multiplying with 2^31 and saturated if required. + Then converted to q31 format by multiplying with 2^31 and saturated if + required. */ - static const q31_t cos_factorsQ31_128[128] = { - (q31_t)0x7fff6216, (q31_t)0x7ffa72d1, (q31_t)0x7ff09478, (q31_t)0x7fe1c76b, (q31_t)0x7fce0c3e, (q31_t)0x7fb563b3, - (q31_t)0x7f97cebd, (q31_t)0x7f754e80, - (q31_t)0x7f4de451, (q31_t)0x7f2191b4, (q31_t)0x7ef05860, (q31_t)0x7eba3a39, (q31_t)0x7e7f3957, (q31_t)0x7e3f57ff, - (q31_t)0x7dfa98a8, (q31_t)0x7db0fdf8, - (q31_t)0x7d628ac6, (q31_t)0x7d0f4218, (q31_t)0x7cb72724, (q31_t)0x7c5a3d50, (q31_t)0x7bf88830, (q31_t)0x7b920b89, - (q31_t)0x7b26cb4f, (q31_t)0x7ab6cba4, - (q31_t)0x7a4210d8, (q31_t)0x79c89f6e, (q31_t)0x794a7c12, (q31_t)0x78c7aba2, (q31_t)0x78403329, (q31_t)0x77b417df, - (q31_t)0x77235f2d, (q31_t)0x768e0ea6, - (q31_t)0x75f42c0b, (q31_t)0x7555bd4c, (q31_t)0x74b2c884, (q31_t)0x740b53fb, (q31_t)0x735f6626, (q31_t)0x72af05a7, - (q31_t)0x71fa3949, (q31_t)0x71410805, - (q31_t)0x708378ff, (q31_t)0x6fc19385, (q31_t)0x6efb5f12, (q31_t)0x6e30e34a, (q31_t)0x6d6227fa, (q31_t)0x6c8f351c, - (q31_t)0x6bb812d1, (q31_t)0x6adcc964, - (q31_t)0x69fd614a, (q31_t)0x6919e320, (q31_t)0x683257ab, (q31_t)0x6746c7d8, (q31_t)0x66573cbb, (q31_t)0x6563bf92, - (q31_t)0x646c59bf, (q31_t)0x637114cc, - (q31_t)0x6271fa69, (q31_t)0x616f146c, (q31_t)0x60686ccf, (q31_t)0x5f5e0db3, (q31_t)0x5e50015d, (q31_t)0x5d3e5237, - (q31_t)0x5c290acc, (q31_t)0x5b1035cf, - (q31_t)0x59f3de12, (q31_t)0x58d40e8c, (q31_t)0x57b0d256, (q31_t)0x568a34a9, (q31_t)0x556040e2, (q31_t)0x5433027d, - (q31_t)0x53028518, (q31_t)0x51ced46e, - (q31_t)0x5097fc5e, (q31_t)0x4f5e08e3, (q31_t)0x4e210617, (q31_t)0x4ce10034, (q31_t)0x4b9e0390, (q31_t)0x4a581c9e, - (q31_t)0x490f57ee, (q31_t)0x47c3c22f, - (q31_t)0x46756828, (q31_t)0x452456bd, (q31_t)0x43d09aed, (q31_t)0x427a41d0, (q31_t)0x4121589b, (q31_t)0x3fc5ec98, - (q31_t)0x3e680b2c, (q31_t)0x3d07c1d6, - (q31_t)0x3ba51e29, (q31_t)0x3a402dd2, (q31_t)0x38d8fe93, (q31_t)0x376f9e46, (q31_t)0x36041ad9, (q31_t)0x34968250, - (q31_t)0x3326e2c3, (q31_t)0x31b54a5e, - (q31_t)0x3041c761, (q31_t)0x2ecc681e, (q31_t)0x2d553afc, (q31_t)0x2bdc4e6f, (q31_t)0x2a61b101, (q31_t)0x28e5714b, - (q31_t)0x27679df4, (q31_t)0x25e845b6, - (q31_t)0x24677758, (q31_t)0x22e541af, (q31_t)0x2161b3a0, (q31_t)0x1fdcdc1b, (q31_t)0x1e56ca1e, (q31_t)0x1ccf8cb3, - (q31_t)0x1b4732ef, (q31_t)0x19bdcbf3, - (q31_t)0x183366e9, (q31_t)0x16a81305, (q31_t)0x151bdf86, (q31_t)0x138edbb1, (q31_t)0x120116d5, (q31_t)0x1072a048, - (q31_t)0xee38766, (q31_t)0xd53db92, - (q31_t)0xbc3ac35, (q31_t)0xa3308bd, (q31_t)0x8a2009a, (q31_t)0x710a345, (q31_t)0x57f0035, (q31_t)0x3ed26e6, (q31_t)0x25b26d7, - (q31_t)0xc90f88 -}; + (q31_t)0x7fff6216, (q31_t)0x7ffa72d1, (q31_t)0x7ff09478, (q31_t)0x7fe1c76b, + (q31_t)0x7fce0c3e, (q31_t)0x7fb563b3, (q31_t)0x7f97cebd, (q31_t)0x7f754e80, + (q31_t)0x7f4de451, (q31_t)0x7f2191b4, (q31_t)0x7ef05860, (q31_t)0x7eba3a39, + (q31_t)0x7e7f3957, (q31_t)0x7e3f57ff, (q31_t)0x7dfa98a8, (q31_t)0x7db0fdf8, + (q31_t)0x7d628ac6, (q31_t)0x7d0f4218, (q31_t)0x7cb72724, (q31_t)0x7c5a3d50, + (q31_t)0x7bf88830, (q31_t)0x7b920b89, (q31_t)0x7b26cb4f, (q31_t)0x7ab6cba4, + (q31_t)0x7a4210d8, (q31_t)0x79c89f6e, (q31_t)0x794a7c12, (q31_t)0x78c7aba2, + (q31_t)0x78403329, (q31_t)0x77b417df, (q31_t)0x77235f2d, (q31_t)0x768e0ea6, + (q31_t)0x75f42c0b, (q31_t)0x7555bd4c, (q31_t)0x74b2c884, (q31_t)0x740b53fb, + (q31_t)0x735f6626, (q31_t)0x72af05a7, (q31_t)0x71fa3949, (q31_t)0x71410805, + (q31_t)0x708378ff, (q31_t)0x6fc19385, (q31_t)0x6efb5f12, (q31_t)0x6e30e34a, + (q31_t)0x6d6227fa, (q31_t)0x6c8f351c, (q31_t)0x6bb812d1, (q31_t)0x6adcc964, + (q31_t)0x69fd614a, (q31_t)0x6919e320, (q31_t)0x683257ab, (q31_t)0x6746c7d8, + (q31_t)0x66573cbb, (q31_t)0x6563bf92, (q31_t)0x646c59bf, (q31_t)0x637114cc, + (q31_t)0x6271fa69, (q31_t)0x616f146c, (q31_t)0x60686ccf, (q31_t)0x5f5e0db3, + (q31_t)0x5e50015d, (q31_t)0x5d3e5237, (q31_t)0x5c290acc, (q31_t)0x5b1035cf, + (q31_t)0x59f3de12, (q31_t)0x58d40e8c, (q31_t)0x57b0d256, (q31_t)0x568a34a9, + (q31_t)0x556040e2, (q31_t)0x5433027d, (q31_t)0x53028518, (q31_t)0x51ced46e, + (q31_t)0x5097fc5e, (q31_t)0x4f5e08e3, (q31_t)0x4e210617, (q31_t)0x4ce10034, + (q31_t)0x4b9e0390, (q31_t)0x4a581c9e, (q31_t)0x490f57ee, (q31_t)0x47c3c22f, + (q31_t)0x46756828, (q31_t)0x452456bd, (q31_t)0x43d09aed, (q31_t)0x427a41d0, + (q31_t)0x4121589b, (q31_t)0x3fc5ec98, (q31_t)0x3e680b2c, (q31_t)0x3d07c1d6, + (q31_t)0x3ba51e29, (q31_t)0x3a402dd2, (q31_t)0x38d8fe93, (q31_t)0x376f9e46, + (q31_t)0x36041ad9, (q31_t)0x34968250, (q31_t)0x3326e2c3, (q31_t)0x31b54a5e, + (q31_t)0x3041c761, (q31_t)0x2ecc681e, (q31_t)0x2d553afc, (q31_t)0x2bdc4e6f, + (q31_t)0x2a61b101, (q31_t)0x28e5714b, (q31_t)0x27679df4, (q31_t)0x25e845b6, + (q31_t)0x24677758, (q31_t)0x22e541af, (q31_t)0x2161b3a0, (q31_t)0x1fdcdc1b, + (q31_t)0x1e56ca1e, (q31_t)0x1ccf8cb3, (q31_t)0x1b4732ef, (q31_t)0x19bdcbf3, + (q31_t)0x183366e9, (q31_t)0x16a81305, (q31_t)0x151bdf86, (q31_t)0x138edbb1, + (q31_t)0x120116d5, (q31_t)0x1072a048, (q31_t)0xee38766, (q31_t)0xd53db92, + (q31_t)0xbc3ac35, (q31_t)0xa3308bd, (q31_t)0x8a2009a, (q31_t)0x710a345, + (q31_t)0x57f0035, (q31_t)0x3ed26e6, (q31_t)0x25b26d7, (q31_t)0xc90f88}; static const q31_t cos_factorsQ31_512[512] = { - (q31_t)0x7ffff621, (q31_t)0x7fffa72c, (q31_t)0x7fff0943, (q31_t)0x7ffe1c65, (q31_t)0x7ffce093, (q31_t)0x7ffb55ce, - (q31_t)0x7ff97c18, (q31_t)0x7ff75370, - (q31_t)0x7ff4dbd9, (q31_t)0x7ff21553, (q31_t)0x7feeffe1, (q31_t)0x7feb9b85, (q31_t)0x7fe7e841, (q31_t)0x7fe3e616, - (q31_t)0x7fdf9508, (q31_t)0x7fdaf519, - (q31_t)0x7fd6064c, (q31_t)0x7fd0c8a3, (q31_t)0x7fcb3c23, (q31_t)0x7fc560cf, (q31_t)0x7fbf36aa, (q31_t)0x7fb8bdb8, - (q31_t)0x7fb1f5fc, (q31_t)0x7faadf7c, - (q31_t)0x7fa37a3c, (q31_t)0x7f9bc640, (q31_t)0x7f93c38c, (q31_t)0x7f8b7227, (q31_t)0x7f82d214, (q31_t)0x7f79e35a, - (q31_t)0x7f70a5fe, (q31_t)0x7f671a05, - (q31_t)0x7f5d3f75, (q31_t)0x7f531655, (q31_t)0x7f489eaa, (q31_t)0x7f3dd87c, (q31_t)0x7f32c3d1, (q31_t)0x7f2760af, - (q31_t)0x7f1baf1e, (q31_t)0x7f0faf25, - (q31_t)0x7f0360cb, (q31_t)0x7ef6c418, (q31_t)0x7ee9d914, (q31_t)0x7edc9fc6, (q31_t)0x7ecf1837, (q31_t)0x7ec14270, - (q31_t)0x7eb31e78, (q31_t)0x7ea4ac58, - (q31_t)0x7e95ec1a, (q31_t)0x7e86ddc6, (q31_t)0x7e778166, (q31_t)0x7e67d703, (q31_t)0x7e57dea7, (q31_t)0x7e47985b, - (q31_t)0x7e37042a, (q31_t)0x7e26221f, - (q31_t)0x7e14f242, (q31_t)0x7e0374a0, (q31_t)0x7df1a942, (q31_t)0x7ddf9034, (q31_t)0x7dcd2981, (q31_t)0x7dba7534, - (q31_t)0x7da77359, (q31_t)0x7d9423fc, - (q31_t)0x7d808728, (q31_t)0x7d6c9ce9, (q31_t)0x7d58654d, (q31_t)0x7d43e05e, (q31_t)0x7d2f0e2b, (q31_t)0x7d19eebf, - (q31_t)0x7d048228, (q31_t)0x7ceec873, - (q31_t)0x7cd8c1ae, (q31_t)0x7cc26de5, (q31_t)0x7cabcd28, (q31_t)0x7c94df83, (q31_t)0x7c7da505, (q31_t)0x7c661dbc, - (q31_t)0x7c4e49b7, (q31_t)0x7c362904, - (q31_t)0x7c1dbbb3, (q31_t)0x7c0501d2, (q31_t)0x7bebfb70, (q31_t)0x7bd2a89e, (q31_t)0x7bb9096b, (q31_t)0x7b9f1de6, - (q31_t)0x7b84e61f, (q31_t)0x7b6a6227, - (q31_t)0x7b4f920e, (q31_t)0x7b3475e5, (q31_t)0x7b190dbc, (q31_t)0x7afd59a4, (q31_t)0x7ae159ae, (q31_t)0x7ac50dec, - (q31_t)0x7aa8766f, (q31_t)0x7a8b9348, - (q31_t)0x7a6e648a, (q31_t)0x7a50ea47, (q31_t)0x7a332490, (q31_t)0x7a151378, (q31_t)0x79f6b711, (q31_t)0x79d80f6f, - (q31_t)0x79b91ca4, (q31_t)0x7999dec4, - (q31_t)0x797a55e0, (q31_t)0x795a820e, (q31_t)0x793a6361, (q31_t)0x7919f9ec, (q31_t)0x78f945c3, (q31_t)0x78d846fb, - (q31_t)0x78b6fda8, (q31_t)0x789569df, - (q31_t)0x78738bb3, (q31_t)0x7851633b, (q31_t)0x782ef08b, (q31_t)0x780c33b8, (q31_t)0x77e92cd9, (q31_t)0x77c5dc01, - (q31_t)0x77a24148, (q31_t)0x777e5cc3, - (q31_t)0x775a2e89, (q31_t)0x7735b6af, (q31_t)0x7710f54c, (q31_t)0x76ebea77, (q31_t)0x76c69647, (q31_t)0x76a0f8d2, - (q31_t)0x767b1231, (q31_t)0x7654e279, - (q31_t)0x762e69c4, (q31_t)0x7607a828, (q31_t)0x75e09dbd, (q31_t)0x75b94a9c, (q31_t)0x7591aedd, (q31_t)0x7569ca99, - (q31_t)0x75419de7, (q31_t)0x751928e0, - (q31_t)0x74f06b9e, (q31_t)0x74c7663a, (q31_t)0x749e18cd, (q31_t)0x74748371, (q31_t)0x744aa63f, (q31_t)0x74208150, - (q31_t)0x73f614c0, (q31_t)0x73cb60a8, - (q31_t)0x73a06522, (q31_t)0x73752249, (q31_t)0x73499838, (q31_t)0x731dc70a, (q31_t)0x72f1aed9, (q31_t)0x72c54fc1, - (q31_t)0x7298a9dd, (q31_t)0x726bbd48, - (q31_t)0x723e8a20, (q31_t)0x7211107e, (q31_t)0x71e35080, (q31_t)0x71b54a41, (q31_t)0x7186fdde, (q31_t)0x71586b74, - (q31_t)0x7129931f, (q31_t)0x70fa74fc, - (q31_t)0x70cb1128, (q31_t)0x709b67c0, (q31_t)0x706b78e3, (q31_t)0x703b44ad, (q31_t)0x700acb3c, (q31_t)0x6fda0cae, - (q31_t)0x6fa90921, (q31_t)0x6f77c0b3, - (q31_t)0x6f463383, (q31_t)0x6f1461b0, (q31_t)0x6ee24b57, (q31_t)0x6eaff099, (q31_t)0x6e7d5193, (q31_t)0x6e4a6e66, - (q31_t)0x6e174730, (q31_t)0x6de3dc11, - (q31_t)0x6db02d29, (q31_t)0x6d7c3a98, (q31_t)0x6d48047e, (q31_t)0x6d138afb, (q31_t)0x6cdece2f, (q31_t)0x6ca9ce3b, - (q31_t)0x6c748b3f, (q31_t)0x6c3f055d, - (q31_t)0x6c093cb6, (q31_t)0x6bd3316a, (q31_t)0x6b9ce39b, (q31_t)0x6b66536b, (q31_t)0x6b2f80fb, (q31_t)0x6af86c6c, - (q31_t)0x6ac115e2, (q31_t)0x6a897d7d, - (q31_t)0x6a51a361, (q31_t)0x6a1987b0, (q31_t)0x69e12a8c, (q31_t)0x69a88c19, (q31_t)0x696fac78, (q31_t)0x69368bce, - (q31_t)0x68fd2a3d, (q31_t)0x68c387e9, - (q31_t)0x6889a4f6, (q31_t)0x684f8186, (q31_t)0x68151dbe, (q31_t)0x67da79c3, (q31_t)0x679f95b7, (q31_t)0x676471c0, - (q31_t)0x67290e02, (q31_t)0x66ed6aa1, - (q31_t)0x66b187c3, (q31_t)0x6675658c, (q31_t)0x66390422, (q31_t)0x65fc63a9, (q31_t)0x65bf8447, (q31_t)0x65826622, - (q31_t)0x6545095f, (q31_t)0x65076e25, - (q31_t)0x64c99498, (q31_t)0x648b7ce0, (q31_t)0x644d2722, (q31_t)0x640e9386, (q31_t)0x63cfc231, (q31_t)0x6390b34a, - (q31_t)0x635166f9, (q31_t)0x6311dd64, - (q31_t)0x62d216b3, (q31_t)0x6292130c, (q31_t)0x6251d298, (q31_t)0x6211557e, (q31_t)0x61d09be5, (q31_t)0x618fa5f7, - (q31_t)0x614e73da, (q31_t)0x610d05b7, - (q31_t)0x60cb5bb7, (q31_t)0x60897601, (q31_t)0x604754bf, (q31_t)0x6004f819, (q31_t)0x5fc26038, (q31_t)0x5f7f8d46, - (q31_t)0x5f3c7f6b, (q31_t)0x5ef936d1, - (q31_t)0x5eb5b3a2, (q31_t)0x5e71f606, (q31_t)0x5e2dfe29, (q31_t)0x5de9cc33, (q31_t)0x5da5604f, (q31_t)0x5d60baa7, - (q31_t)0x5d1bdb65, (q31_t)0x5cd6c2b5, - (q31_t)0x5c9170bf, (q31_t)0x5c4be5b0, (q31_t)0x5c0621b2, (q31_t)0x5bc024f0, (q31_t)0x5b79ef96, (q31_t)0x5b3381ce, - (q31_t)0x5aecdbc5, (q31_t)0x5aa5fda5, - (q31_t)0x5a5ee79a, (q31_t)0x5a1799d1, (q31_t)0x59d01475, (q31_t)0x598857b2, (q31_t)0x594063b5, (q31_t)0x58f838a9, - (q31_t)0x58afd6bd, (q31_t)0x58673e1b, - (q31_t)0x581e6ef1, (q31_t)0x57d5696d, (q31_t)0x578c2dba, (q31_t)0x5742bc06, (q31_t)0x56f9147e, (q31_t)0x56af3750, - (q31_t)0x566524aa, (q31_t)0x561adcb9, - (q31_t)0x55d05faa, (q31_t)0x5585adad, (q31_t)0x553ac6ee, (q31_t)0x54efab9c, (q31_t)0x54a45be6, (q31_t)0x5458d7f9, - (q31_t)0x540d2005, (q31_t)0x53c13439, - (q31_t)0x537514c2, (q31_t)0x5328c1d0, (q31_t)0x52dc3b92, (q31_t)0x528f8238, (q31_t)0x524295f0, (q31_t)0x51f576ea, - (q31_t)0x51a82555, (q31_t)0x515aa162, - (q31_t)0x510ceb40, (q31_t)0x50bf031f, (q31_t)0x5070e92f, (q31_t)0x50229da1, (q31_t)0x4fd420a4, (q31_t)0x4f857269, - (q31_t)0x4f369320, (q31_t)0x4ee782fb, - (q31_t)0x4e984229, (q31_t)0x4e48d0dd, (q31_t)0x4df92f46, (q31_t)0x4da95d96, (q31_t)0x4d595bfe, (q31_t)0x4d092ab0, - (q31_t)0x4cb8c9dd, (q31_t)0x4c6839b7, - (q31_t)0x4c177a6e, (q31_t)0x4bc68c36, (q31_t)0x4b756f40, (q31_t)0x4b2423be, (q31_t)0x4ad2a9e2, (q31_t)0x4a8101de, - (q31_t)0x4a2f2be6, (q31_t)0x49dd282a, - (q31_t)0x498af6df, (q31_t)0x49389836, (q31_t)0x48e60c62, (q31_t)0x48935397, (q31_t)0x48406e08, (q31_t)0x47ed5be6, - (q31_t)0x479a1d67, (q31_t)0x4746b2bc, - (q31_t)0x46f31c1a, (q31_t)0x469f59b4, (q31_t)0x464b6bbe, (q31_t)0x45f7526b, (q31_t)0x45a30df0, (q31_t)0x454e9e80, - (q31_t)0x44fa0450, (q31_t)0x44a53f93, - (q31_t)0x4450507e, (q31_t)0x43fb3746, (q31_t)0x43a5f41e, (q31_t)0x4350873c, (q31_t)0x42faf0d4, (q31_t)0x42a5311b, - (q31_t)0x424f4845, (q31_t)0x41f93689, - (q31_t)0x41a2fc1a, (q31_t)0x414c992f, (q31_t)0x40f60dfb, (q31_t)0x409f5ab6, (q31_t)0x40487f94, (q31_t)0x3ff17cca, - (q31_t)0x3f9a5290, (q31_t)0x3f430119, - (q31_t)0x3eeb889c, (q31_t)0x3e93e950, (q31_t)0x3e3c2369, (q31_t)0x3de4371f, (q31_t)0x3d8c24a8, (q31_t)0x3d33ec39, - (q31_t)0x3cdb8e09, (q31_t)0x3c830a50, - (q31_t)0x3c2a6142, (q31_t)0x3bd19318, (q31_t)0x3b78a007, (q31_t)0x3b1f8848, (q31_t)0x3ac64c0f, (q31_t)0x3a6ceb96, - (q31_t)0x3a136712, (q31_t)0x39b9bebc, - (q31_t)0x395ff2c9, (q31_t)0x39060373, (q31_t)0x38abf0ef, (q31_t)0x3851bb77, (q31_t)0x37f76341, (q31_t)0x379ce885, - (q31_t)0x37424b7b, (q31_t)0x36e78c5b, - (q31_t)0x368cab5c, (q31_t)0x3631a8b8, (q31_t)0x35d684a6, (q31_t)0x357b3f5d, (q31_t)0x351fd918, (q31_t)0x34c4520d, - (q31_t)0x3468aa76, (q31_t)0x340ce28b, - (q31_t)0x33b0fa84, (q31_t)0x3354f29b, (q31_t)0x32f8cb07, (q31_t)0x329c8402, (q31_t)0x32401dc6, (q31_t)0x31e39889, - (q31_t)0x3186f487, (q31_t)0x312a31f8, - (q31_t)0x30cd5115, (q31_t)0x30705217, (q31_t)0x30133539, (q31_t)0x2fb5fab2, (q31_t)0x2f58a2be, (q31_t)0x2efb2d95, - (q31_t)0x2e9d9b70, (q31_t)0x2e3fec8b, - (q31_t)0x2de2211e, (q31_t)0x2d843964, (q31_t)0x2d263596, (q31_t)0x2cc815ee, (q31_t)0x2c69daa6, (q31_t)0x2c0b83fa, - (q31_t)0x2bad1221, (q31_t)0x2b4e8558, - (q31_t)0x2aefddd8, (q31_t)0x2a911bdc, (q31_t)0x2a323f9e, (q31_t)0x29d34958, (q31_t)0x29743946, (q31_t)0x29150fa1, - (q31_t)0x28b5cca5, (q31_t)0x2856708d, - (q31_t)0x27f6fb92, (q31_t)0x27976df1, (q31_t)0x2737c7e3, (q31_t)0x26d809a5, (q31_t)0x26783370, (q31_t)0x26184581, - (q31_t)0x25b84012, (q31_t)0x2558235f, - (q31_t)0x24f7efa2, (q31_t)0x2497a517, (q31_t)0x243743fa, (q31_t)0x23d6cc87, (q31_t)0x23763ef7, (q31_t)0x23159b88, - (q31_t)0x22b4e274, (q31_t)0x225413f8, - (q31_t)0x21f3304f, (q31_t)0x219237b5, (q31_t)0x21312a65, (q31_t)0x20d0089c, (q31_t)0x206ed295, (q31_t)0x200d888d, - (q31_t)0x1fac2abf, (q31_t)0x1f4ab968, - (q31_t)0x1ee934c3, (q31_t)0x1e879d0d, (q31_t)0x1e25f282, (q31_t)0x1dc4355e, (q31_t)0x1d6265dd, (q31_t)0x1d00843d, - (q31_t)0x1c9e90b8, (q31_t)0x1c3c8b8c, - (q31_t)0x1bda74f6, (q31_t)0x1b784d30, (q31_t)0x1b161479, (q31_t)0x1ab3cb0d, (q31_t)0x1a517128, (q31_t)0x19ef0707, - (q31_t)0x198c8ce7, (q31_t)0x192a0304, - (q31_t)0x18c7699b, (q31_t)0x1864c0ea, (q31_t)0x1802092c, (q31_t)0x179f429f, (q31_t)0x173c6d80, (q31_t)0x16d98a0c, - (q31_t)0x1676987f, (q31_t)0x16139918, - (q31_t)0x15b08c12, (q31_t)0x154d71aa, (q31_t)0x14ea4a1f, (q31_t)0x148715ae, (q31_t)0x1423d492, (q31_t)0x13c0870a, - (q31_t)0x135d2d53, (q31_t)0x12f9c7aa, - (q31_t)0x1296564d, (q31_t)0x1232d979, (q31_t)0x11cf516a, (q31_t)0x116bbe60, (q31_t)0x11082096, (q31_t)0x10a4784b, - (q31_t)0x1040c5bb, (q31_t)0xfdd0926, - (q31_t)0xf7942c7, (q31_t)0xf1572dc, (q31_t)0xeb199a4, (q31_t)0xe4db75b, (q31_t)0xde9cc40, (q31_t)0xd85d88f, (q31_t)0xd21dc87, - (q31_t)0xcbdd865, - (q31_t)0xc59cc68, (q31_t)0xbf5b8cb, (q31_t)0xb919dcf, (q31_t)0xb2d7baf, (q31_t)0xac952aa, (q31_t)0xa6522fe, (q31_t)0xa00ece8, - (q31_t)0x99cb0a7, - (q31_t)0x9386e78, (q31_t)0x8d42699, (q31_t)0x86fd947, (q31_t)0x80b86c2, (q31_t)0x7a72f45, (q31_t)0x742d311, (q31_t)0x6de7262, - (q31_t)0x67a0d76, - (q31_t)0x615a48b, (q31_t)0x5b137df, (q31_t)0x54cc7b1, (q31_t)0x4e8543e, (q31_t)0x483ddc3, (q31_t)0x41f6480, (q31_t)0x3bae8b2, - (q31_t)0x3566a96, - (q31_t)0x2f1ea6c, (q31_t)0x28d6870, (q31_t)0x228e4e2, (q31_t)0x1c45ffe, (q31_t)0x15fda03, (q31_t)0xfb5330, (q31_t)0x96cbc1, - (q31_t)0x3243f5 -}; + (q31_t)0x7ffff621, (q31_t)0x7fffa72c, (q31_t)0x7fff0943, (q31_t)0x7ffe1c65, + (q31_t)0x7ffce093, (q31_t)0x7ffb55ce, (q31_t)0x7ff97c18, (q31_t)0x7ff75370, + (q31_t)0x7ff4dbd9, (q31_t)0x7ff21553, (q31_t)0x7feeffe1, (q31_t)0x7feb9b85, + (q31_t)0x7fe7e841, (q31_t)0x7fe3e616, (q31_t)0x7fdf9508, (q31_t)0x7fdaf519, + (q31_t)0x7fd6064c, (q31_t)0x7fd0c8a3, (q31_t)0x7fcb3c23, (q31_t)0x7fc560cf, + (q31_t)0x7fbf36aa, (q31_t)0x7fb8bdb8, (q31_t)0x7fb1f5fc, (q31_t)0x7faadf7c, + (q31_t)0x7fa37a3c, (q31_t)0x7f9bc640, (q31_t)0x7f93c38c, (q31_t)0x7f8b7227, + (q31_t)0x7f82d214, (q31_t)0x7f79e35a, (q31_t)0x7f70a5fe, (q31_t)0x7f671a05, + (q31_t)0x7f5d3f75, (q31_t)0x7f531655, (q31_t)0x7f489eaa, (q31_t)0x7f3dd87c, + (q31_t)0x7f32c3d1, (q31_t)0x7f2760af, (q31_t)0x7f1baf1e, (q31_t)0x7f0faf25, + (q31_t)0x7f0360cb, (q31_t)0x7ef6c418, (q31_t)0x7ee9d914, (q31_t)0x7edc9fc6, + (q31_t)0x7ecf1837, (q31_t)0x7ec14270, (q31_t)0x7eb31e78, (q31_t)0x7ea4ac58, + (q31_t)0x7e95ec1a, (q31_t)0x7e86ddc6, (q31_t)0x7e778166, (q31_t)0x7e67d703, + (q31_t)0x7e57dea7, (q31_t)0x7e47985b, (q31_t)0x7e37042a, (q31_t)0x7e26221f, + (q31_t)0x7e14f242, (q31_t)0x7e0374a0, (q31_t)0x7df1a942, (q31_t)0x7ddf9034, + (q31_t)0x7dcd2981, (q31_t)0x7dba7534, (q31_t)0x7da77359, (q31_t)0x7d9423fc, + (q31_t)0x7d808728, (q31_t)0x7d6c9ce9, (q31_t)0x7d58654d, (q31_t)0x7d43e05e, + (q31_t)0x7d2f0e2b, (q31_t)0x7d19eebf, (q31_t)0x7d048228, (q31_t)0x7ceec873, + (q31_t)0x7cd8c1ae, (q31_t)0x7cc26de5, (q31_t)0x7cabcd28, (q31_t)0x7c94df83, + (q31_t)0x7c7da505, (q31_t)0x7c661dbc, (q31_t)0x7c4e49b7, (q31_t)0x7c362904, + (q31_t)0x7c1dbbb3, (q31_t)0x7c0501d2, (q31_t)0x7bebfb70, (q31_t)0x7bd2a89e, + (q31_t)0x7bb9096b, (q31_t)0x7b9f1de6, (q31_t)0x7b84e61f, (q31_t)0x7b6a6227, + (q31_t)0x7b4f920e, (q31_t)0x7b3475e5, (q31_t)0x7b190dbc, (q31_t)0x7afd59a4, + (q31_t)0x7ae159ae, (q31_t)0x7ac50dec, (q31_t)0x7aa8766f, (q31_t)0x7a8b9348, + (q31_t)0x7a6e648a, (q31_t)0x7a50ea47, (q31_t)0x7a332490, (q31_t)0x7a151378, + (q31_t)0x79f6b711, (q31_t)0x79d80f6f, (q31_t)0x79b91ca4, (q31_t)0x7999dec4, + (q31_t)0x797a55e0, (q31_t)0x795a820e, (q31_t)0x793a6361, (q31_t)0x7919f9ec, + (q31_t)0x78f945c3, (q31_t)0x78d846fb, (q31_t)0x78b6fda8, (q31_t)0x789569df, + (q31_t)0x78738bb3, (q31_t)0x7851633b, (q31_t)0x782ef08b, (q31_t)0x780c33b8, + (q31_t)0x77e92cd9, (q31_t)0x77c5dc01, (q31_t)0x77a24148, (q31_t)0x777e5cc3, + (q31_t)0x775a2e89, (q31_t)0x7735b6af, (q31_t)0x7710f54c, (q31_t)0x76ebea77, + (q31_t)0x76c69647, (q31_t)0x76a0f8d2, (q31_t)0x767b1231, (q31_t)0x7654e279, + (q31_t)0x762e69c4, (q31_t)0x7607a828, (q31_t)0x75e09dbd, (q31_t)0x75b94a9c, + (q31_t)0x7591aedd, (q31_t)0x7569ca99, (q31_t)0x75419de7, (q31_t)0x751928e0, + (q31_t)0x74f06b9e, (q31_t)0x74c7663a, (q31_t)0x749e18cd, (q31_t)0x74748371, + (q31_t)0x744aa63f, (q31_t)0x74208150, (q31_t)0x73f614c0, (q31_t)0x73cb60a8, + (q31_t)0x73a06522, (q31_t)0x73752249, (q31_t)0x73499838, (q31_t)0x731dc70a, + (q31_t)0x72f1aed9, (q31_t)0x72c54fc1, (q31_t)0x7298a9dd, (q31_t)0x726bbd48, + (q31_t)0x723e8a20, (q31_t)0x7211107e, (q31_t)0x71e35080, (q31_t)0x71b54a41, + (q31_t)0x7186fdde, (q31_t)0x71586b74, (q31_t)0x7129931f, (q31_t)0x70fa74fc, + (q31_t)0x70cb1128, (q31_t)0x709b67c0, (q31_t)0x706b78e3, (q31_t)0x703b44ad, + (q31_t)0x700acb3c, (q31_t)0x6fda0cae, (q31_t)0x6fa90921, (q31_t)0x6f77c0b3, + (q31_t)0x6f463383, (q31_t)0x6f1461b0, (q31_t)0x6ee24b57, (q31_t)0x6eaff099, + (q31_t)0x6e7d5193, (q31_t)0x6e4a6e66, (q31_t)0x6e174730, (q31_t)0x6de3dc11, + (q31_t)0x6db02d29, (q31_t)0x6d7c3a98, (q31_t)0x6d48047e, (q31_t)0x6d138afb, + (q31_t)0x6cdece2f, (q31_t)0x6ca9ce3b, (q31_t)0x6c748b3f, (q31_t)0x6c3f055d, + (q31_t)0x6c093cb6, (q31_t)0x6bd3316a, (q31_t)0x6b9ce39b, (q31_t)0x6b66536b, + (q31_t)0x6b2f80fb, (q31_t)0x6af86c6c, (q31_t)0x6ac115e2, (q31_t)0x6a897d7d, + (q31_t)0x6a51a361, (q31_t)0x6a1987b0, (q31_t)0x69e12a8c, (q31_t)0x69a88c19, + (q31_t)0x696fac78, (q31_t)0x69368bce, (q31_t)0x68fd2a3d, (q31_t)0x68c387e9, + (q31_t)0x6889a4f6, (q31_t)0x684f8186, (q31_t)0x68151dbe, (q31_t)0x67da79c3, + (q31_t)0x679f95b7, (q31_t)0x676471c0, (q31_t)0x67290e02, (q31_t)0x66ed6aa1, + (q31_t)0x66b187c3, (q31_t)0x6675658c, (q31_t)0x66390422, (q31_t)0x65fc63a9, + (q31_t)0x65bf8447, (q31_t)0x65826622, (q31_t)0x6545095f, (q31_t)0x65076e25, + (q31_t)0x64c99498, (q31_t)0x648b7ce0, (q31_t)0x644d2722, (q31_t)0x640e9386, + (q31_t)0x63cfc231, (q31_t)0x6390b34a, (q31_t)0x635166f9, (q31_t)0x6311dd64, + (q31_t)0x62d216b3, (q31_t)0x6292130c, (q31_t)0x6251d298, (q31_t)0x6211557e, + (q31_t)0x61d09be5, (q31_t)0x618fa5f7, (q31_t)0x614e73da, (q31_t)0x610d05b7, + (q31_t)0x60cb5bb7, (q31_t)0x60897601, (q31_t)0x604754bf, (q31_t)0x6004f819, + (q31_t)0x5fc26038, (q31_t)0x5f7f8d46, (q31_t)0x5f3c7f6b, (q31_t)0x5ef936d1, + (q31_t)0x5eb5b3a2, (q31_t)0x5e71f606, (q31_t)0x5e2dfe29, (q31_t)0x5de9cc33, + (q31_t)0x5da5604f, (q31_t)0x5d60baa7, (q31_t)0x5d1bdb65, (q31_t)0x5cd6c2b5, + (q31_t)0x5c9170bf, (q31_t)0x5c4be5b0, (q31_t)0x5c0621b2, (q31_t)0x5bc024f0, + (q31_t)0x5b79ef96, (q31_t)0x5b3381ce, (q31_t)0x5aecdbc5, (q31_t)0x5aa5fda5, + (q31_t)0x5a5ee79a, (q31_t)0x5a1799d1, (q31_t)0x59d01475, (q31_t)0x598857b2, + (q31_t)0x594063b5, (q31_t)0x58f838a9, (q31_t)0x58afd6bd, (q31_t)0x58673e1b, + (q31_t)0x581e6ef1, (q31_t)0x57d5696d, (q31_t)0x578c2dba, (q31_t)0x5742bc06, + (q31_t)0x56f9147e, (q31_t)0x56af3750, (q31_t)0x566524aa, (q31_t)0x561adcb9, + (q31_t)0x55d05faa, (q31_t)0x5585adad, (q31_t)0x553ac6ee, (q31_t)0x54efab9c, + (q31_t)0x54a45be6, (q31_t)0x5458d7f9, (q31_t)0x540d2005, (q31_t)0x53c13439, + (q31_t)0x537514c2, (q31_t)0x5328c1d0, (q31_t)0x52dc3b92, (q31_t)0x528f8238, + (q31_t)0x524295f0, (q31_t)0x51f576ea, (q31_t)0x51a82555, (q31_t)0x515aa162, + (q31_t)0x510ceb40, (q31_t)0x50bf031f, (q31_t)0x5070e92f, (q31_t)0x50229da1, + (q31_t)0x4fd420a4, (q31_t)0x4f857269, (q31_t)0x4f369320, (q31_t)0x4ee782fb, + (q31_t)0x4e984229, (q31_t)0x4e48d0dd, (q31_t)0x4df92f46, (q31_t)0x4da95d96, + (q31_t)0x4d595bfe, (q31_t)0x4d092ab0, (q31_t)0x4cb8c9dd, (q31_t)0x4c6839b7, + (q31_t)0x4c177a6e, (q31_t)0x4bc68c36, (q31_t)0x4b756f40, (q31_t)0x4b2423be, + (q31_t)0x4ad2a9e2, (q31_t)0x4a8101de, (q31_t)0x4a2f2be6, (q31_t)0x49dd282a, + (q31_t)0x498af6df, (q31_t)0x49389836, (q31_t)0x48e60c62, (q31_t)0x48935397, + (q31_t)0x48406e08, (q31_t)0x47ed5be6, (q31_t)0x479a1d67, (q31_t)0x4746b2bc, + (q31_t)0x46f31c1a, (q31_t)0x469f59b4, (q31_t)0x464b6bbe, (q31_t)0x45f7526b, + (q31_t)0x45a30df0, (q31_t)0x454e9e80, (q31_t)0x44fa0450, (q31_t)0x44a53f93, + (q31_t)0x4450507e, (q31_t)0x43fb3746, (q31_t)0x43a5f41e, (q31_t)0x4350873c, + (q31_t)0x42faf0d4, (q31_t)0x42a5311b, (q31_t)0x424f4845, (q31_t)0x41f93689, + (q31_t)0x41a2fc1a, (q31_t)0x414c992f, (q31_t)0x40f60dfb, (q31_t)0x409f5ab6, + (q31_t)0x40487f94, (q31_t)0x3ff17cca, (q31_t)0x3f9a5290, (q31_t)0x3f430119, + (q31_t)0x3eeb889c, (q31_t)0x3e93e950, (q31_t)0x3e3c2369, (q31_t)0x3de4371f, + (q31_t)0x3d8c24a8, (q31_t)0x3d33ec39, (q31_t)0x3cdb8e09, (q31_t)0x3c830a50, + (q31_t)0x3c2a6142, (q31_t)0x3bd19318, (q31_t)0x3b78a007, (q31_t)0x3b1f8848, + (q31_t)0x3ac64c0f, (q31_t)0x3a6ceb96, (q31_t)0x3a136712, (q31_t)0x39b9bebc, + (q31_t)0x395ff2c9, (q31_t)0x39060373, (q31_t)0x38abf0ef, (q31_t)0x3851bb77, + (q31_t)0x37f76341, (q31_t)0x379ce885, (q31_t)0x37424b7b, (q31_t)0x36e78c5b, + (q31_t)0x368cab5c, (q31_t)0x3631a8b8, (q31_t)0x35d684a6, (q31_t)0x357b3f5d, + (q31_t)0x351fd918, (q31_t)0x34c4520d, (q31_t)0x3468aa76, (q31_t)0x340ce28b, + (q31_t)0x33b0fa84, (q31_t)0x3354f29b, (q31_t)0x32f8cb07, (q31_t)0x329c8402, + (q31_t)0x32401dc6, (q31_t)0x31e39889, (q31_t)0x3186f487, (q31_t)0x312a31f8, + (q31_t)0x30cd5115, (q31_t)0x30705217, (q31_t)0x30133539, (q31_t)0x2fb5fab2, + (q31_t)0x2f58a2be, (q31_t)0x2efb2d95, (q31_t)0x2e9d9b70, (q31_t)0x2e3fec8b, + (q31_t)0x2de2211e, (q31_t)0x2d843964, (q31_t)0x2d263596, (q31_t)0x2cc815ee, + (q31_t)0x2c69daa6, (q31_t)0x2c0b83fa, (q31_t)0x2bad1221, (q31_t)0x2b4e8558, + (q31_t)0x2aefddd8, (q31_t)0x2a911bdc, (q31_t)0x2a323f9e, (q31_t)0x29d34958, + (q31_t)0x29743946, (q31_t)0x29150fa1, (q31_t)0x28b5cca5, (q31_t)0x2856708d, + (q31_t)0x27f6fb92, (q31_t)0x27976df1, (q31_t)0x2737c7e3, (q31_t)0x26d809a5, + (q31_t)0x26783370, (q31_t)0x26184581, (q31_t)0x25b84012, (q31_t)0x2558235f, + (q31_t)0x24f7efa2, (q31_t)0x2497a517, (q31_t)0x243743fa, (q31_t)0x23d6cc87, + (q31_t)0x23763ef7, (q31_t)0x23159b88, (q31_t)0x22b4e274, (q31_t)0x225413f8, + (q31_t)0x21f3304f, (q31_t)0x219237b5, (q31_t)0x21312a65, (q31_t)0x20d0089c, + (q31_t)0x206ed295, (q31_t)0x200d888d, (q31_t)0x1fac2abf, (q31_t)0x1f4ab968, + (q31_t)0x1ee934c3, (q31_t)0x1e879d0d, (q31_t)0x1e25f282, (q31_t)0x1dc4355e, + (q31_t)0x1d6265dd, (q31_t)0x1d00843d, (q31_t)0x1c9e90b8, (q31_t)0x1c3c8b8c, + (q31_t)0x1bda74f6, (q31_t)0x1b784d30, (q31_t)0x1b161479, (q31_t)0x1ab3cb0d, + (q31_t)0x1a517128, (q31_t)0x19ef0707, (q31_t)0x198c8ce7, (q31_t)0x192a0304, + (q31_t)0x18c7699b, (q31_t)0x1864c0ea, (q31_t)0x1802092c, (q31_t)0x179f429f, + (q31_t)0x173c6d80, (q31_t)0x16d98a0c, (q31_t)0x1676987f, (q31_t)0x16139918, + (q31_t)0x15b08c12, (q31_t)0x154d71aa, (q31_t)0x14ea4a1f, (q31_t)0x148715ae, + (q31_t)0x1423d492, (q31_t)0x13c0870a, (q31_t)0x135d2d53, (q31_t)0x12f9c7aa, + (q31_t)0x1296564d, (q31_t)0x1232d979, (q31_t)0x11cf516a, (q31_t)0x116bbe60, + (q31_t)0x11082096, (q31_t)0x10a4784b, (q31_t)0x1040c5bb, (q31_t)0xfdd0926, + (q31_t)0xf7942c7, (q31_t)0xf1572dc, (q31_t)0xeb199a4, (q31_t)0xe4db75b, + (q31_t)0xde9cc40, (q31_t)0xd85d88f, (q31_t)0xd21dc87, (q31_t)0xcbdd865, + (q31_t)0xc59cc68, (q31_t)0xbf5b8cb, (q31_t)0xb919dcf, (q31_t)0xb2d7baf, + (q31_t)0xac952aa, (q31_t)0xa6522fe, (q31_t)0xa00ece8, (q31_t)0x99cb0a7, + (q31_t)0x9386e78, (q31_t)0x8d42699, (q31_t)0x86fd947, (q31_t)0x80b86c2, + (q31_t)0x7a72f45, (q31_t)0x742d311, (q31_t)0x6de7262, (q31_t)0x67a0d76, + (q31_t)0x615a48b, (q31_t)0x5b137df, (q31_t)0x54cc7b1, (q31_t)0x4e8543e, + (q31_t)0x483ddc3, (q31_t)0x41f6480, (q31_t)0x3bae8b2, (q31_t)0x3566a96, + (q31_t)0x2f1ea6c, (q31_t)0x28d6870, (q31_t)0x228e4e2, (q31_t)0x1c45ffe, + (q31_t)0x15fda03, (q31_t)0xfb5330, (q31_t)0x96cbc1, (q31_t)0x3243f5}; static const q31_t cos_factorsQ31_2048[2048] = { - (q31_t)0x7fffff62, (q31_t)0x7ffffa73, (q31_t)0x7ffff094, (q31_t)0x7fffe1c6, (q31_t)0x7fffce09, (q31_t)0x7fffb55c, - (q31_t)0x7fff97c1, (q31_t)0x7fff7536, - (q31_t)0x7fff4dbb, (q31_t)0x7fff2151, (q31_t)0x7ffeeff8, (q31_t)0x7ffeb9b0, (q31_t)0x7ffe7e79, (q31_t)0x7ffe3e52, - (q31_t)0x7ffdf93c, (q31_t)0x7ffdaf37, - (q31_t)0x7ffd6042, (q31_t)0x7ffd0c5f, (q31_t)0x7ffcb38c, (q31_t)0x7ffc55ca, (q31_t)0x7ffbf319, (q31_t)0x7ffb8b78, - (q31_t)0x7ffb1ee9, (q31_t)0x7ffaad6a, - (q31_t)0x7ffa36fc, (q31_t)0x7ff9bba0, (q31_t)0x7ff93b54, (q31_t)0x7ff8b619, (q31_t)0x7ff82bef, (q31_t)0x7ff79cd6, - (q31_t)0x7ff708ce, (q31_t)0x7ff66fd7, - (q31_t)0x7ff5d1f1, (q31_t)0x7ff52f1d, (q31_t)0x7ff48759, (q31_t)0x7ff3daa6, (q31_t)0x7ff32905, (q31_t)0x7ff27275, - (q31_t)0x7ff1b6f6, (q31_t)0x7ff0f688, - (q31_t)0x7ff0312c, (q31_t)0x7fef66e1, (q31_t)0x7fee97a7, (q31_t)0x7fedc37e, (q31_t)0x7fecea67, (q31_t)0x7fec0c62, - (q31_t)0x7feb296d, (q31_t)0x7fea418b, - (q31_t)0x7fe954ba, (q31_t)0x7fe862fa, (q31_t)0x7fe76c4c, (q31_t)0x7fe670b0, (q31_t)0x7fe57025, (q31_t)0x7fe46aac, - (q31_t)0x7fe36045, (q31_t)0x7fe250ef, - (q31_t)0x7fe13cac, (q31_t)0x7fe0237a, (q31_t)0x7fdf055a, (q31_t)0x7fdde24d, (q31_t)0x7fdcba51, (q31_t)0x7fdb8d67, - (q31_t)0x7fda5b8f, (q31_t)0x7fd924ca, - (q31_t)0x7fd7e917, (q31_t)0x7fd6a875, (q31_t)0x7fd562e7, (q31_t)0x7fd4186a, (q31_t)0x7fd2c900, (q31_t)0x7fd174a8, - (q31_t)0x7fd01b63, (q31_t)0x7fcebd31, - (q31_t)0x7fcd5a11, (q31_t)0x7fcbf203, (q31_t)0x7fca8508, (q31_t)0x7fc91320, (q31_t)0x7fc79c4b, (q31_t)0x7fc62089, - (q31_t)0x7fc49fda, (q31_t)0x7fc31a3d, - (q31_t)0x7fc18fb4, (q31_t)0x7fc0003e, (q31_t)0x7fbe6bdb, (q31_t)0x7fbcd28b, (q31_t)0x7fbb344e, (q31_t)0x7fb99125, - (q31_t)0x7fb7e90f, (q31_t)0x7fb63c0d, - (q31_t)0x7fb48a1e, (q31_t)0x7fb2d343, (q31_t)0x7fb1177b, (q31_t)0x7faf56c7, (q31_t)0x7fad9127, (q31_t)0x7fabc69b, - (q31_t)0x7fa9f723, (q31_t)0x7fa822bf, - (q31_t)0x7fa6496e, (q31_t)0x7fa46b32, (q31_t)0x7fa2880b, (q31_t)0x7fa09ff7, (q31_t)0x7f9eb2f8, (q31_t)0x7f9cc10d, - (q31_t)0x7f9aca37, (q31_t)0x7f98ce76, - (q31_t)0x7f96cdc9, (q31_t)0x7f94c831, (q31_t)0x7f92bdad, (q31_t)0x7f90ae3f, (q31_t)0x7f8e99e6, (q31_t)0x7f8c80a1, - (q31_t)0x7f8a6272, (q31_t)0x7f883f58, - (q31_t)0x7f861753, (q31_t)0x7f83ea64, (q31_t)0x7f81b88a, (q31_t)0x7f7f81c6, (q31_t)0x7f7d4617, (q31_t)0x7f7b057e, - (q31_t)0x7f78bffb, (q31_t)0x7f76758e, - (q31_t)0x7f742637, (q31_t)0x7f71d1f6, (q31_t)0x7f6f78cb, (q31_t)0x7f6d1ab6, (q31_t)0x7f6ab7b8, (q31_t)0x7f684fd0, - (q31_t)0x7f65e2ff, (q31_t)0x7f637144, - (q31_t)0x7f60faa0, (q31_t)0x7f5e7f13, (q31_t)0x7f5bfe9d, (q31_t)0x7f59793e, (q31_t)0x7f56eef5, (q31_t)0x7f545fc5, - (q31_t)0x7f51cbab, (q31_t)0x7f4f32a9, - (q31_t)0x7f4c94be, (q31_t)0x7f49f1eb, (q31_t)0x7f474a30, (q31_t)0x7f449d8c, (q31_t)0x7f41ec01, (q31_t)0x7f3f358d, - (q31_t)0x7f3c7a31, (q31_t)0x7f39b9ee, - (q31_t)0x7f36f4c3, (q31_t)0x7f342ab1, (q31_t)0x7f315bb7, (q31_t)0x7f2e87d6, (q31_t)0x7f2baf0d, (q31_t)0x7f28d15d, - (q31_t)0x7f25eec7, (q31_t)0x7f230749, - (q31_t)0x7f201ae5, (q31_t)0x7f1d299a, (q31_t)0x7f1a3368, (q31_t)0x7f173850, (q31_t)0x7f143852, (q31_t)0x7f11336d, - (q31_t)0x7f0e29a3, (q31_t)0x7f0b1af2, - (q31_t)0x7f08075c, (q31_t)0x7f04eedf, (q31_t)0x7f01d17d, (q31_t)0x7efeaf36, (q31_t)0x7efb8809, (q31_t)0x7ef85bf7, - (q31_t)0x7ef52b00, (q31_t)0x7ef1f524, - (q31_t)0x7eeeba62, (q31_t)0x7eeb7abc, (q31_t)0x7ee83632, (q31_t)0x7ee4ecc3, (q31_t)0x7ee19e6f, (q31_t)0x7ede4b38, - (q31_t)0x7edaf31c, (q31_t)0x7ed7961c, - (q31_t)0x7ed43438, (q31_t)0x7ed0cd70, (q31_t)0x7ecd61c5, (q31_t)0x7ec9f137, (q31_t)0x7ec67bc5, (q31_t)0x7ec3016f, - (q31_t)0x7ebf8237, (q31_t)0x7ebbfe1c, - (q31_t)0x7eb8751e, (q31_t)0x7eb4e73d, (q31_t)0x7eb1547a, (q31_t)0x7eadbcd4, (q31_t)0x7eaa204c, (q31_t)0x7ea67ee2, - (q31_t)0x7ea2d896, (q31_t)0x7e9f2d68, - (q31_t)0x7e9b7d58, (q31_t)0x7e97c867, (q31_t)0x7e940e94, (q31_t)0x7e904fe0, (q31_t)0x7e8c8c4b, (q31_t)0x7e88c3d5, - (q31_t)0x7e84f67e, (q31_t)0x7e812447, - (q31_t)0x7e7d4d2f, (q31_t)0x7e797136, (q31_t)0x7e75905d, (q31_t)0x7e71aaa4, (q31_t)0x7e6dc00c, (q31_t)0x7e69d093, - (q31_t)0x7e65dc3b, (q31_t)0x7e61e303, - (q31_t)0x7e5de4ec, (q31_t)0x7e59e1f5, (q31_t)0x7e55da20, (q31_t)0x7e51cd6c, (q31_t)0x7e4dbbd9, (q31_t)0x7e49a567, - (q31_t)0x7e458a17, (q31_t)0x7e4169e9, - (q31_t)0x7e3d44dd, (q31_t)0x7e391af3, (q31_t)0x7e34ec2b, (q31_t)0x7e30b885, (q31_t)0x7e2c8002, (q31_t)0x7e2842a2, - (q31_t)0x7e240064, (q31_t)0x7e1fb94a, - (q31_t)0x7e1b6d53, (q31_t)0x7e171c7f, (q31_t)0x7e12c6ce, (q31_t)0x7e0e6c42, (q31_t)0x7e0a0cd9, (q31_t)0x7e05a894, - (q31_t)0x7e013f74, (q31_t)0x7dfcd178, - (q31_t)0x7df85ea0, (q31_t)0x7df3e6ee, (q31_t)0x7def6a60, (q31_t)0x7deae8f7, (q31_t)0x7de662b3, (q31_t)0x7de1d795, - (q31_t)0x7ddd479d, (q31_t)0x7dd8b2ca, - (q31_t)0x7dd4191d, (q31_t)0x7dcf7a96, (q31_t)0x7dcad736, (q31_t)0x7dc62efc, (q31_t)0x7dc181e8, (q31_t)0x7dbccffc, - (q31_t)0x7db81936, (q31_t)0x7db35d98, - (q31_t)0x7dae9d21, (q31_t)0x7da9d7d2, (q31_t)0x7da50dab, (q31_t)0x7da03eab, (q31_t)0x7d9b6ad3, (q31_t)0x7d969224, - (q31_t)0x7d91b49e, (q31_t)0x7d8cd240, - (q31_t)0x7d87eb0a, (q31_t)0x7d82fefe, (q31_t)0x7d7e0e1c, (q31_t)0x7d791862, (q31_t)0x7d741dd2, (q31_t)0x7d6f1e6c, - (q31_t)0x7d6a1a31, (q31_t)0x7d65111f, - (q31_t)0x7d600338, (q31_t)0x7d5af07b, (q31_t)0x7d55d8e9, (q31_t)0x7d50bc82, (q31_t)0x7d4b9b46, (q31_t)0x7d467536, - (q31_t)0x7d414a51, (q31_t)0x7d3c1a98, - (q31_t)0x7d36e60b, (q31_t)0x7d31acaa, (q31_t)0x7d2c6e76, (q31_t)0x7d272b6e, (q31_t)0x7d21e393, (q31_t)0x7d1c96e5, - (q31_t)0x7d174564, (q31_t)0x7d11ef11, - (q31_t)0x7d0c93eb, (q31_t)0x7d0733f3, (q31_t)0x7d01cf29, (q31_t)0x7cfc658d, (q31_t)0x7cf6f720, (q31_t)0x7cf183e1, - (q31_t)0x7cec0bd1, (q31_t)0x7ce68ef0, - (q31_t)0x7ce10d3f, (q31_t)0x7cdb86bd, (q31_t)0x7cd5fb6a, (q31_t)0x7cd06b48, (q31_t)0x7ccad656, (q31_t)0x7cc53c94, - (q31_t)0x7cbf9e03, (q31_t)0x7cb9faa2, - (q31_t)0x7cb45272, (q31_t)0x7caea574, (q31_t)0x7ca8f3a7, (q31_t)0x7ca33d0c, (q31_t)0x7c9d81a3, (q31_t)0x7c97c16b, - (q31_t)0x7c91fc66, (q31_t)0x7c8c3294, - (q31_t)0x7c8663f4, (q31_t)0x7c809088, (q31_t)0x7c7ab84e, (q31_t)0x7c74db48, (q31_t)0x7c6ef976, (q31_t)0x7c6912d7, - (q31_t)0x7c63276d, (q31_t)0x7c5d3737, - (q31_t)0x7c574236, (q31_t)0x7c514869, (q31_t)0x7c4b49d2, (q31_t)0x7c45466f, (q31_t)0x7c3f3e42, (q31_t)0x7c39314b, - (q31_t)0x7c331f8a, (q31_t)0x7c2d08ff, - (q31_t)0x7c26edab, (q31_t)0x7c20cd8d, (q31_t)0x7c1aa8a6, (q31_t)0x7c147ef6, (q31_t)0x7c0e507e, (q31_t)0x7c081d3d, - (q31_t)0x7c01e534, (q31_t)0x7bfba863, - (q31_t)0x7bf566cb, (q31_t)0x7bef206b, (q31_t)0x7be8d544, (q31_t)0x7be28556, (q31_t)0x7bdc30a1, (q31_t)0x7bd5d726, - (q31_t)0x7bcf78e5, (q31_t)0x7bc915dd, - (q31_t)0x7bc2ae10, (q31_t)0x7bbc417e, (q31_t)0x7bb5d026, (q31_t)0x7baf5a09, (q31_t)0x7ba8df28, (q31_t)0x7ba25f82, - (q31_t)0x7b9bdb18, (q31_t)0x7b9551ea, - (q31_t)0x7b8ec3f8, (q31_t)0x7b883143, (q31_t)0x7b8199ca, (q31_t)0x7b7afd8f, (q31_t)0x7b745c91, (q31_t)0x7b6db6d0, - (q31_t)0x7b670c4d, (q31_t)0x7b605d09, - (q31_t)0x7b59a902, (q31_t)0x7b52f03a, (q31_t)0x7b4c32b1, (q31_t)0x7b457068, (q31_t)0x7b3ea95d, (q31_t)0x7b37dd92, - (q31_t)0x7b310d07, (q31_t)0x7b2a37bc, - (q31_t)0x7b235db2, (q31_t)0x7b1c7ee8, (q31_t)0x7b159b5f, (q31_t)0x7b0eb318, (q31_t)0x7b07c612, (q31_t)0x7b00d44d, - (q31_t)0x7af9ddcb, (q31_t)0x7af2e28b, - (q31_t)0x7aebe28d, (q31_t)0x7ae4ddd2, (q31_t)0x7addd45b, (q31_t)0x7ad6c626, (q31_t)0x7acfb336, (q31_t)0x7ac89b89, - (q31_t)0x7ac17f20, (q31_t)0x7aba5dfc, - (q31_t)0x7ab3381d, (q31_t)0x7aac0d82, (q31_t)0x7aa4de2d, (q31_t)0x7a9daa1d, (q31_t)0x7a967153, (q31_t)0x7a8f33d0, - (q31_t)0x7a87f192, (q31_t)0x7a80aa9c, - (q31_t)0x7a795eec, (q31_t)0x7a720e84, (q31_t)0x7a6ab963, (q31_t)0x7a635f8a, (q31_t)0x7a5c00f9, (q31_t)0x7a549db0, - (q31_t)0x7a4d35b0, (q31_t)0x7a45c8f9, - (q31_t)0x7a3e578b, (q31_t)0x7a36e166, (q31_t)0x7a2f668c, (q31_t)0x7a27e6fb, (q31_t)0x7a2062b5, (q31_t)0x7a18d9b9, - (q31_t)0x7a114c09, (q31_t)0x7a09b9a4, - (q31_t)0x7a02228a, (q31_t)0x79fa86bc, (q31_t)0x79f2e63a, (q31_t)0x79eb4105, (q31_t)0x79e3971c, (q31_t)0x79dbe880, - (q31_t)0x79d43532, (q31_t)0x79cc7d31, - (q31_t)0x79c4c07e, (q31_t)0x79bcff19, (q31_t)0x79b53903, (q31_t)0x79ad6e3c, (q31_t)0x79a59ec3, (q31_t)0x799dca9a, - (q31_t)0x7995f1c1, (q31_t)0x798e1438, - (q31_t)0x798631ff, (q31_t)0x797e4b16, (q31_t)0x79765f7f, (q31_t)0x796e6f39, (q31_t)0x79667a44, (q31_t)0x795e80a1, - (q31_t)0x79568250, (q31_t)0x794e7f52, - (q31_t)0x794677a6, (q31_t)0x793e6b4e, (q31_t)0x79365a49, (q31_t)0x792e4497, (q31_t)0x79262a3a, (q31_t)0x791e0b31, - (q31_t)0x7915e77c, (q31_t)0x790dbf1d, - (q31_t)0x79059212, (q31_t)0x78fd605d, (q31_t)0x78f529fe, (q31_t)0x78eceef6, (q31_t)0x78e4af44, (q31_t)0x78dc6ae8, - (q31_t)0x78d421e4, (q31_t)0x78cbd437, - (q31_t)0x78c381e2, (q31_t)0x78bb2ae5, (q31_t)0x78b2cf41, (q31_t)0x78aa6ef5, (q31_t)0x78a20a03, (q31_t)0x7899a06a, - (q31_t)0x7891322a, (q31_t)0x7888bf45, - (q31_t)0x788047ba, (q31_t)0x7877cb89, (q31_t)0x786f4ab4, (q31_t)0x7866c53a, (q31_t)0x785e3b1c, (q31_t)0x7855ac5a, - (q31_t)0x784d18f4, (q31_t)0x784480ea, - (q31_t)0x783be43e, (q31_t)0x783342ef, (q31_t)0x782a9cfe, (q31_t)0x7821f26b, (q31_t)0x78194336, (q31_t)0x78108f60, - (q31_t)0x7807d6e9, (q31_t)0x77ff19d1, - (q31_t)0x77f65819, (q31_t)0x77ed91c0, (q31_t)0x77e4c6c9, (q31_t)0x77dbf732, (q31_t)0x77d322fc, (q31_t)0x77ca4a27, - (q31_t)0x77c16cb4, (q31_t)0x77b88aa3, - (q31_t)0x77afa3f5, (q31_t)0x77a6b8a9, (q31_t)0x779dc8c0, (q31_t)0x7794d43b, (q31_t)0x778bdb19, (q31_t)0x7782dd5c, - (q31_t)0x7779db03, (q31_t)0x7770d40f, - (q31_t)0x7767c880, (q31_t)0x775eb857, (q31_t)0x7755a394, (q31_t)0x774c8a36, (q31_t)0x77436c40, (q31_t)0x773a49b0, - (q31_t)0x77312287, (q31_t)0x7727f6c6, - (q31_t)0x771ec66e, (q31_t)0x7715917d, (q31_t)0x770c57f5, (q31_t)0x770319d6, (q31_t)0x76f9d721, (q31_t)0x76f08fd5, - (q31_t)0x76e743f4, (q31_t)0x76ddf37c, - (q31_t)0x76d49e70, (q31_t)0x76cb44cf, (q31_t)0x76c1e699, (q31_t)0x76b883d0, (q31_t)0x76af1c72, (q31_t)0x76a5b082, - (q31_t)0x769c3ffe, (q31_t)0x7692cae8, - (q31_t)0x7689513f, (q31_t)0x767fd304, (q31_t)0x76765038, (q31_t)0x766cc8db, (q31_t)0x76633ced, (q31_t)0x7659ac6f, - (q31_t)0x76501760, (q31_t)0x76467dc2, - (q31_t)0x763cdf94, (q31_t)0x76333cd8, (q31_t)0x7629958c, (q31_t)0x761fe9b3, (q31_t)0x7616394c, (q31_t)0x760c8457, - (q31_t)0x7602cad5, (q31_t)0x75f90cc7, - (q31_t)0x75ef4a2c, (q31_t)0x75e58305, (q31_t)0x75dbb753, (q31_t)0x75d1e715, (q31_t)0x75c8124d, (q31_t)0x75be38fa, - (q31_t)0x75b45b1d, (q31_t)0x75aa78b6, - (q31_t)0x75a091c6, (q31_t)0x7596a64d, (q31_t)0x758cb64c, (q31_t)0x7582c1c2, (q31_t)0x7578c8b0, (q31_t)0x756ecb18, - (q31_t)0x7564c8f8, (q31_t)0x755ac251, - (q31_t)0x7550b725, (q31_t)0x7546a772, (q31_t)0x753c933a, (q31_t)0x75327a7d, (q31_t)0x75285d3b, (q31_t)0x751e3b75, - (q31_t)0x7514152b, (q31_t)0x7509ea5d, - (q31_t)0x74ffbb0d, (q31_t)0x74f58739, (q31_t)0x74eb4ee3, (q31_t)0x74e1120c, (q31_t)0x74d6d0b2, (q31_t)0x74cc8ad8, - (q31_t)0x74c2407d, (q31_t)0x74b7f1a1, - (q31_t)0x74ad9e46, (q31_t)0x74a3466b, (q31_t)0x7498ea11, (q31_t)0x748e8938, (q31_t)0x748423e0, (q31_t)0x7479ba0b, - (q31_t)0x746f4bb8, (q31_t)0x7464d8e8, - (q31_t)0x745a619b, (q31_t)0x744fe5d2, (q31_t)0x7445658d, (q31_t)0x743ae0cc, (q31_t)0x74305790, (q31_t)0x7425c9da, - (q31_t)0x741b37a9, (q31_t)0x7410a0fe, - (q31_t)0x740605d9, (q31_t)0x73fb663c, (q31_t)0x73f0c226, (q31_t)0x73e61997, (q31_t)0x73db6c91, (q31_t)0x73d0bb13, - (q31_t)0x73c6051f, (q31_t)0x73bb4ab3, - (q31_t)0x73b08bd1, (q31_t)0x73a5c87a, (q31_t)0x739b00ad, (q31_t)0x7390346b, (q31_t)0x738563b5, (q31_t)0x737a8e8a, - (q31_t)0x736fb4ec, (q31_t)0x7364d6da, - (q31_t)0x7359f456, (q31_t)0x734f0d5f, (q31_t)0x734421f6, (q31_t)0x7339321b, (q31_t)0x732e3dcf, (q31_t)0x73234512, - (q31_t)0x731847e5, (q31_t)0x730d4648, - (q31_t)0x7302403c, (q31_t)0x72f735c0, (q31_t)0x72ec26d6, (q31_t)0x72e1137d, (q31_t)0x72d5fbb7, (q31_t)0x72cadf83, - (q31_t)0x72bfbee3, (q31_t)0x72b499d6, - (q31_t)0x72a9705c, (q31_t)0x729e4277, (q31_t)0x72931027, (q31_t)0x7287d96c, (q31_t)0x727c9e47, (q31_t)0x72715eb8, - (q31_t)0x72661abf, (q31_t)0x725ad25d, - (q31_t)0x724f8593, (q31_t)0x72443460, (q31_t)0x7238dec5, (q31_t)0x722d84c4, (q31_t)0x7222265b, (q31_t)0x7216c38c, - (q31_t)0x720b5c57, (q31_t)0x71fff0bc, - (q31_t)0x71f480bc, (q31_t)0x71e90c57, (q31_t)0x71dd938f, (q31_t)0x71d21662, (q31_t)0x71c694d2, (q31_t)0x71bb0edf, - (q31_t)0x71af848a, (q31_t)0x71a3f5d2, - (q31_t)0x719862b9, (q31_t)0x718ccb3f, (q31_t)0x71812f65, (q31_t)0x71758f29, (q31_t)0x7169ea8f, (q31_t)0x715e4194, - (q31_t)0x7152943b, (q31_t)0x7146e284, - (q31_t)0x713b2c6e, (q31_t)0x712f71fb, (q31_t)0x7123b32b, (q31_t)0x7117effe, (q31_t)0x710c2875, (q31_t)0x71005c90, - (q31_t)0x70f48c50, (q31_t)0x70e8b7b5, - (q31_t)0x70dcdec0, (q31_t)0x70d10171, (q31_t)0x70c51fc8, (q31_t)0x70b939c7, (q31_t)0x70ad4f6d, (q31_t)0x70a160ba, - (q31_t)0x70956db1, (q31_t)0x70897650, - (q31_t)0x707d7a98, (q31_t)0x70717a8a, (q31_t)0x70657626, (q31_t)0x70596d6d, (q31_t)0x704d6060, (q31_t)0x70414efd, - (q31_t)0x70353947, (q31_t)0x70291f3e, - (q31_t)0x701d00e1, (q31_t)0x7010de32, (q31_t)0x7004b731, (q31_t)0x6ff88bde, (q31_t)0x6fec5c3b, (q31_t)0x6fe02846, - (q31_t)0x6fd3f001, (q31_t)0x6fc7b36d, - (q31_t)0x6fbb728a, (q31_t)0x6faf2d57, (q31_t)0x6fa2e3d7, (q31_t)0x6f969608, (q31_t)0x6f8a43ed, (q31_t)0x6f7ded84, - (q31_t)0x6f7192cf, (q31_t)0x6f6533ce, - (q31_t)0x6f58d082, (q31_t)0x6f4c68eb, (q31_t)0x6f3ffd09, (q31_t)0x6f338cde, (q31_t)0x6f271868, (q31_t)0x6f1a9faa, - (q31_t)0x6f0e22a3, (q31_t)0x6f01a155, - (q31_t)0x6ef51bbe, (q31_t)0x6ee891e1, (q31_t)0x6edc03bc, (q31_t)0x6ecf7152, (q31_t)0x6ec2daa2, (q31_t)0x6eb63fad, - (q31_t)0x6ea9a073, (q31_t)0x6e9cfcf5, - (q31_t)0x6e905534, (q31_t)0x6e83a92f, (q31_t)0x6e76f8e7, (q31_t)0x6e6a445d, (q31_t)0x6e5d8b91, (q31_t)0x6e50ce84, - (q31_t)0x6e440d37, (q31_t)0x6e3747a9, - (q31_t)0x6e2a7ddb, (q31_t)0x6e1dafce, (q31_t)0x6e10dd82, (q31_t)0x6e0406f8, (q31_t)0x6df72c30, (q31_t)0x6dea4d2b, - (q31_t)0x6ddd69e9, (q31_t)0x6dd0826a, - (q31_t)0x6dc396b0, (q31_t)0x6db6a6ba, (q31_t)0x6da9b28a, (q31_t)0x6d9cba1f, (q31_t)0x6d8fbd7a, (q31_t)0x6d82bc9d, - (q31_t)0x6d75b786, (q31_t)0x6d68ae37, - (q31_t)0x6d5ba0b0, (q31_t)0x6d4e8ef2, (q31_t)0x6d4178fd, (q31_t)0x6d345ed1, (q31_t)0x6d274070, (q31_t)0x6d1a1dda, - (q31_t)0x6d0cf70f, (q31_t)0x6cffcc0f, - (q31_t)0x6cf29cdc, (q31_t)0x6ce56975, (q31_t)0x6cd831dc, (q31_t)0x6ccaf610, (q31_t)0x6cbdb613, (q31_t)0x6cb071e4, - (q31_t)0x6ca32985, (q31_t)0x6c95dcf6, - (q31_t)0x6c888c36, (q31_t)0x6c7b3748, (q31_t)0x6c6dde2b, (q31_t)0x6c6080e0, (q31_t)0x6c531f67, (q31_t)0x6c45b9c1, - (q31_t)0x6c384fef, (q31_t)0x6c2ae1f0, - (q31_t)0x6c1d6fc6, (q31_t)0x6c0ff971, (q31_t)0x6c027ef1, (q31_t)0x6bf50047, (q31_t)0x6be77d74, (q31_t)0x6bd9f677, - (q31_t)0x6bcc6b53, (q31_t)0x6bbedc06, - (q31_t)0x6bb14892, (q31_t)0x6ba3b0f7, (q31_t)0x6b961536, (q31_t)0x6b88754f, (q31_t)0x6b7ad142, (q31_t)0x6b6d2911, - (q31_t)0x6b5f7cbc, (q31_t)0x6b51cc42, - (q31_t)0x6b4417a6, (q31_t)0x6b365ee7, (q31_t)0x6b28a206, (q31_t)0x6b1ae103, (q31_t)0x6b0d1bdf, (q31_t)0x6aff529a, - (q31_t)0x6af18536, (q31_t)0x6ae3b3b2, - (q31_t)0x6ad5de0f, (q31_t)0x6ac8044e, (q31_t)0x6aba266e, (q31_t)0x6aac4472, (q31_t)0x6a9e5e58, (q31_t)0x6a907423, - (q31_t)0x6a8285d1, (q31_t)0x6a749365, - (q31_t)0x6a669cdd, (q31_t)0x6a58a23c, (q31_t)0x6a4aa381, (q31_t)0x6a3ca0ad, (q31_t)0x6a2e99c0, (q31_t)0x6a208ebb, - (q31_t)0x6a127f9f, (q31_t)0x6a046c6c, - (q31_t)0x69f65523, (q31_t)0x69e839c4, (q31_t)0x69da1a50, (q31_t)0x69cbf6c7, (q31_t)0x69bdcf29, (q31_t)0x69afa378, - (q31_t)0x69a173b5, (q31_t)0x69933fde, - (q31_t)0x698507f6, (q31_t)0x6976cbfc, (q31_t)0x69688bf1, (q31_t)0x695a47d6, (q31_t)0x694bffab, (q31_t)0x693db371, - (q31_t)0x692f6328, (q31_t)0x69210ed1, - (q31_t)0x6912b66c, (q31_t)0x690459fb, (q31_t)0x68f5f97d, (q31_t)0x68e794f3, (q31_t)0x68d92c5d, (q31_t)0x68cabfbd, - (q31_t)0x68bc4f13, (q31_t)0x68adda5f, - (q31_t)0x689f61a1, (q31_t)0x6890e4dc, (q31_t)0x6882640e, (q31_t)0x6873df38, (q31_t)0x6865565c, (q31_t)0x6856c979, - (q31_t)0x68483891, (q31_t)0x6839a3a4, - (q31_t)0x682b0ab1, (q31_t)0x681c6dbb, (q31_t)0x680dccc1, (q31_t)0x67ff27c4, (q31_t)0x67f07ec5, (q31_t)0x67e1d1c4, - (q31_t)0x67d320c1, (q31_t)0x67c46bbe, - (q31_t)0x67b5b2bb, (q31_t)0x67a6f5b8, (q31_t)0x679834b6, (q31_t)0x67896fb6, (q31_t)0x677aa6b8, (q31_t)0x676bd9bd, - (q31_t)0x675d08c4, (q31_t)0x674e33d0, - (q31_t)0x673f5ae0, (q31_t)0x67307df5, (q31_t)0x67219d10, (q31_t)0x6712b831, (q31_t)0x6703cf58, (q31_t)0x66f4e287, - (q31_t)0x66e5f1be, (q31_t)0x66d6fcfd, - (q31_t)0x66c80445, (q31_t)0x66b90797, (q31_t)0x66aa06f3, (q31_t)0x669b0259, (q31_t)0x668bf9cb, (q31_t)0x667ced49, - (q31_t)0x666ddcd3, (q31_t)0x665ec86b, - (q31_t)0x664fb010, (q31_t)0x664093c3, (q31_t)0x66317385, (q31_t)0x66224f56, (q31_t)0x66132738, (q31_t)0x6603fb2a, - (q31_t)0x65f4cb2d, (q31_t)0x65e59742, - (q31_t)0x65d65f69, (q31_t)0x65c723a3, (q31_t)0x65b7e3f1, (q31_t)0x65a8a052, (q31_t)0x659958c9, (q31_t)0x658a0d54, - (q31_t)0x657abdf6, (q31_t)0x656b6aae, - (q31_t)0x655c137d, (q31_t)0x654cb863, (q31_t)0x653d5962, (q31_t)0x652df679, (q31_t)0x651e8faa, (q31_t)0x650f24f5, - (q31_t)0x64ffb65b, (q31_t)0x64f043dc, - (q31_t)0x64e0cd78, (q31_t)0x64d15331, (q31_t)0x64c1d507, (q31_t)0x64b252fa, (q31_t)0x64a2cd0c, (q31_t)0x6493433c, - (q31_t)0x6483b58c, (q31_t)0x647423fb, - (q31_t)0x64648e8c, (q31_t)0x6454f53d, (q31_t)0x64455810, (q31_t)0x6435b706, (q31_t)0x6426121e, (q31_t)0x6416695a, - (q31_t)0x6406bcba, (q31_t)0x63f70c3f, - (q31_t)0x63e757ea, (q31_t)0x63d79fba, (q31_t)0x63c7e3b1, (q31_t)0x63b823cf, (q31_t)0x63a86015, (q31_t)0x63989884, - (q31_t)0x6388cd1b, (q31_t)0x6378fddc, - (q31_t)0x63692ac7, (q31_t)0x635953dd, (q31_t)0x6349791f, (q31_t)0x63399a8d, (q31_t)0x6329b827, (q31_t)0x6319d1ef, - (q31_t)0x6309e7e4, (q31_t)0x62f9fa09, - (q31_t)0x62ea085c, (q31_t)0x62da12df, (q31_t)0x62ca1992, (q31_t)0x62ba1c77, (q31_t)0x62aa1b8d, (q31_t)0x629a16d5, - (q31_t)0x628a0e50, (q31_t)0x627a01fe, - (q31_t)0x6269f1e1, (q31_t)0x6259ddf8, (q31_t)0x6249c645, (q31_t)0x6239aac7, (q31_t)0x62298b81, (q31_t)0x62196871, - (q31_t)0x62094199, (q31_t)0x61f916f9, - (q31_t)0x61e8e893, (q31_t)0x61d8b666, (q31_t)0x61c88074, (q31_t)0x61b846bc, (q31_t)0x61a80940, (q31_t)0x6197c800, - (q31_t)0x618782fd, (q31_t)0x61773a37, - (q31_t)0x6166edb0, (q31_t)0x61569d67, (q31_t)0x6146495d, (q31_t)0x6135f193, (q31_t)0x6125960a, (q31_t)0x611536c2, - (q31_t)0x6104d3bc, (q31_t)0x60f46cf9, - (q31_t)0x60e40278, (q31_t)0x60d3943b, (q31_t)0x60c32243, (q31_t)0x60b2ac8f, (q31_t)0x60a23322, (q31_t)0x6091b5fa, - (q31_t)0x60813519, (q31_t)0x6070b080, - (q31_t)0x6060282f, (q31_t)0x604f9c27, (q31_t)0x603f0c69, (q31_t)0x602e78f4, (q31_t)0x601de1ca, (q31_t)0x600d46ec, - (q31_t)0x5ffca859, (q31_t)0x5fec0613, - (q31_t)0x5fdb601b, (q31_t)0x5fcab670, (q31_t)0x5fba0914, (q31_t)0x5fa95807, (q31_t)0x5f98a34a, (q31_t)0x5f87eade, - (q31_t)0x5f772ec2, (q31_t)0x5f666ef9, - (q31_t)0x5f55ab82, (q31_t)0x5f44e45e, (q31_t)0x5f34198e, (q31_t)0x5f234b12, (q31_t)0x5f1278eb, (q31_t)0x5f01a31a, - (q31_t)0x5ef0c99f, (q31_t)0x5edfec7b, - (q31_t)0x5ecf0baf, (q31_t)0x5ebe273b, (q31_t)0x5ead3f1f, (q31_t)0x5e9c535e, (q31_t)0x5e8b63f7, (q31_t)0x5e7a70ea, - (q31_t)0x5e697a39, (q31_t)0x5e587fe5, - (q31_t)0x5e4781ed, (q31_t)0x5e368053, (q31_t)0x5e257b17, (q31_t)0x5e147239, (q31_t)0x5e0365bb, (q31_t)0x5df2559e, - (q31_t)0x5de141e1, (q31_t)0x5dd02a85, - (q31_t)0x5dbf0f8c, (q31_t)0x5dadf0f5, (q31_t)0x5d9ccec2, (q31_t)0x5d8ba8f3, (q31_t)0x5d7a7f88, (q31_t)0x5d695283, - (q31_t)0x5d5821e4, (q31_t)0x5d46edac, - (q31_t)0x5d35b5db, (q31_t)0x5d247a72, (q31_t)0x5d133b72, (q31_t)0x5d01f8dc, (q31_t)0x5cf0b2af, (q31_t)0x5cdf68ed, - (q31_t)0x5cce1b97, (q31_t)0x5cbccaac, - (q31_t)0x5cab762f, (q31_t)0x5c9a1e1e, (q31_t)0x5c88c27c, (q31_t)0x5c776348, (q31_t)0x5c660084, (q31_t)0x5c549a30, - (q31_t)0x5c43304d, (q31_t)0x5c31c2db, - (q31_t)0x5c2051db, (q31_t)0x5c0edd4e, (q31_t)0x5bfd6534, (q31_t)0x5bebe98e, (q31_t)0x5bda6a5d, (q31_t)0x5bc8e7a2, - (q31_t)0x5bb7615d, (q31_t)0x5ba5d78e, - (q31_t)0x5b944a37, (q31_t)0x5b82b958, (q31_t)0x5b7124f2, (q31_t)0x5b5f8d06, (q31_t)0x5b4df193, (q31_t)0x5b3c529c, - (q31_t)0x5b2ab020, (q31_t)0x5b190a20, - (q31_t)0x5b07609d, (q31_t)0x5af5b398, (q31_t)0x5ae40311, (q31_t)0x5ad24f09, (q31_t)0x5ac09781, (q31_t)0x5aaedc78, - (q31_t)0x5a9d1df1, (q31_t)0x5a8b5bec, - (q31_t)0x5a799669, (q31_t)0x5a67cd69, (q31_t)0x5a5600ec, (q31_t)0x5a4430f5, (q31_t)0x5a325d82, (q31_t)0x5a208695, - (q31_t)0x5a0eac2e, (q31_t)0x59fcce4f, - (q31_t)0x59eaecf8, (q31_t)0x59d90829, (q31_t)0x59c71fe3, (q31_t)0x59b53427, (q31_t)0x59a344f6, (q31_t)0x59915250, - (q31_t)0x597f5c36, (q31_t)0x596d62a9, - (q31_t)0x595b65aa, (q31_t)0x59496538, (q31_t)0x59376155, (q31_t)0x59255a02, (q31_t)0x59134f3e, (q31_t)0x5901410c, - (q31_t)0x58ef2f6b, (q31_t)0x58dd1a5d, - (q31_t)0x58cb01e1, (q31_t)0x58b8e5f9, (q31_t)0x58a6c6a5, (q31_t)0x5894a3e7, (q31_t)0x58827dbe, (q31_t)0x5870542c, - (q31_t)0x585e2730, (q31_t)0x584bf6cd, - (q31_t)0x5839c302, (q31_t)0x58278bd1, (q31_t)0x58155139, (q31_t)0x5803133c, (q31_t)0x57f0d1da, (q31_t)0x57de8d15, - (q31_t)0x57cc44ec, (q31_t)0x57b9f960, - (q31_t)0x57a7aa73, (q31_t)0x57955825, (q31_t)0x57830276, (q31_t)0x5770a968, (q31_t)0x575e4cfa, (q31_t)0x574bed2f, - (q31_t)0x57398a05, (q31_t)0x5727237f, - (q31_t)0x5714b99d, (q31_t)0x57024c5f, (q31_t)0x56efdbc7, (q31_t)0x56dd67d4, (q31_t)0x56caf088, (q31_t)0x56b875e4, - (q31_t)0x56a5f7e7, (q31_t)0x56937694, - (q31_t)0x5680f1ea, (q31_t)0x566e69ea, (q31_t)0x565bde95, (q31_t)0x56494fec, (q31_t)0x5636bdef, (q31_t)0x5624289f, - (q31_t)0x56118ffe, (q31_t)0x55fef40a, - (q31_t)0x55ec54c6, (q31_t)0x55d9b232, (q31_t)0x55c70c4f, (q31_t)0x55b4631d, (q31_t)0x55a1b69d, (q31_t)0x558f06d0, - (q31_t)0x557c53b6, (q31_t)0x55699d51, - (q31_t)0x5556e3a1, (q31_t)0x554426a7, (q31_t)0x55316663, (q31_t)0x551ea2d6, (q31_t)0x550bdc01, (q31_t)0x54f911e5, - (q31_t)0x54e64482, (q31_t)0x54d373d9, - (q31_t)0x54c09feb, (q31_t)0x54adc8b8, (q31_t)0x549aee42, (q31_t)0x54881089, (q31_t)0x54752f8d, (q31_t)0x54624b50, - (q31_t)0x544f63d2, (q31_t)0x543c7914, - (q31_t)0x54298b17, (q31_t)0x541699db, (q31_t)0x5403a561, (q31_t)0x53f0adaa, (q31_t)0x53ddb2b6, (q31_t)0x53cab486, - (q31_t)0x53b7b31c, (q31_t)0x53a4ae77, - (q31_t)0x5391a699, (q31_t)0x537e9b82, (q31_t)0x536b8d33, (q31_t)0x53587bad, (q31_t)0x534566f0, (q31_t)0x53324efd, - (q31_t)0x531f33d5, (q31_t)0x530c1579, - (q31_t)0x52f8f3e9, (q31_t)0x52e5cf27, (q31_t)0x52d2a732, (q31_t)0x52bf7c0b, (q31_t)0x52ac4db4, (q31_t)0x52991c2d, - (q31_t)0x5285e777, (q31_t)0x5272af92, - (q31_t)0x525f7480, (q31_t)0x524c3640, (q31_t)0x5238f4d4, (q31_t)0x5225b03d, (q31_t)0x5212687b, (q31_t)0x51ff1d8f, - (q31_t)0x51ebcf7a, (q31_t)0x51d87e3c, - (q31_t)0x51c529d7, (q31_t)0x51b1d24a, (q31_t)0x519e7797, (q31_t)0x518b19bf, (q31_t)0x5177b8c2, (q31_t)0x516454a0, - (q31_t)0x5150ed5c, (q31_t)0x513d82f4, - (q31_t)0x512a156b, (q31_t)0x5116a4c1, (q31_t)0x510330f7, (q31_t)0x50efba0d, (q31_t)0x50dc4005, (q31_t)0x50c8c2de, - (q31_t)0x50b5429a, (q31_t)0x50a1bf39, - (q31_t)0x508e38bd, (q31_t)0x507aaf25, (q31_t)0x50672273, (q31_t)0x505392a8, (q31_t)0x503fffc4, (q31_t)0x502c69c8, - (q31_t)0x5018d0b4, (q31_t)0x5005348a, - (q31_t)0x4ff1954b, (q31_t)0x4fddf2f6, (q31_t)0x4fca4d8d, (q31_t)0x4fb6a510, (q31_t)0x4fa2f981, (q31_t)0x4f8f4ae0, - (q31_t)0x4f7b992d, (q31_t)0x4f67e46a, - (q31_t)0x4f542c98, (q31_t)0x4f4071b6, (q31_t)0x4f2cb3c7, (q31_t)0x4f18f2c9, (q31_t)0x4f052ec0, (q31_t)0x4ef167aa, - (q31_t)0x4edd9d89, (q31_t)0x4ec9d05e, - (q31_t)0x4eb60029, (q31_t)0x4ea22ceb, (q31_t)0x4e8e56a5, (q31_t)0x4e7a7d58, (q31_t)0x4e66a105, (q31_t)0x4e52c1ab, - (q31_t)0x4e3edf4d, (q31_t)0x4e2af9ea, - (q31_t)0x4e171184, (q31_t)0x4e03261b, (q31_t)0x4def37b0, (q31_t)0x4ddb4644, (q31_t)0x4dc751d8, (q31_t)0x4db35a6c, - (q31_t)0x4d9f6001, (q31_t)0x4d8b6298, - (q31_t)0x4d776231, (q31_t)0x4d635ece, (q31_t)0x4d4f5870, (q31_t)0x4d3b4f16, (q31_t)0x4d2742c2, (q31_t)0x4d133374, - (q31_t)0x4cff212e, (q31_t)0x4ceb0bf0, - (q31_t)0x4cd6f3bb, (q31_t)0x4cc2d88f, (q31_t)0x4caeba6e, (q31_t)0x4c9a9958, (q31_t)0x4c86754e, (q31_t)0x4c724e50, - (q31_t)0x4c5e2460, (q31_t)0x4c49f77f, - (q31_t)0x4c35c7ac, (q31_t)0x4c2194e9, (q31_t)0x4c0d5f37, (q31_t)0x4bf92697, (q31_t)0x4be4eb08, (q31_t)0x4bd0ac8d, - (q31_t)0x4bbc6b25, (q31_t)0x4ba826d1, - (q31_t)0x4b93df93, (q31_t)0x4b7f956b, (q31_t)0x4b6b485a, (q31_t)0x4b56f861, (q31_t)0x4b42a580, (q31_t)0x4b2e4fb8, - (q31_t)0x4b19f70a, (q31_t)0x4b059b77, - (q31_t)0x4af13d00, (q31_t)0x4adcdba5, (q31_t)0x4ac87767, (q31_t)0x4ab41046, (q31_t)0x4a9fa645, (q31_t)0x4a8b3963, - (q31_t)0x4a76c9a2, (q31_t)0x4a625701, - (q31_t)0x4a4de182, (q31_t)0x4a396926, (q31_t)0x4a24edee, (q31_t)0x4a106fda, (q31_t)0x49fbeeea, (q31_t)0x49e76b21, - (q31_t)0x49d2e47e, (q31_t)0x49be5b02, - (q31_t)0x49a9ceaf, (q31_t)0x49953f84, (q31_t)0x4980ad84, (q31_t)0x496c18ae, (q31_t)0x49578103, (q31_t)0x4942e684, - (q31_t)0x492e4933, (q31_t)0x4919a90f, - (q31_t)0x4905061a, (q31_t)0x48f06054, (q31_t)0x48dbb7be, (q31_t)0x48c70c59, (q31_t)0x48b25e25, (q31_t)0x489dad25, - (q31_t)0x4888f957, (q31_t)0x487442be, - (q31_t)0x485f8959, (q31_t)0x484acd2a, (q31_t)0x48360e32, (q31_t)0x48214c71, (q31_t)0x480c87e8, (q31_t)0x47f7c099, - (q31_t)0x47e2f682, (q31_t)0x47ce29a7, - (q31_t)0x47b95a06, (q31_t)0x47a487a2, (q31_t)0x478fb27b, (q31_t)0x477ada91, (q31_t)0x4765ffe6, (q31_t)0x4751227a, - (q31_t)0x473c424e, (q31_t)0x47275f63, - (q31_t)0x471279ba, (q31_t)0x46fd9154, (q31_t)0x46e8a631, (q31_t)0x46d3b852, (q31_t)0x46bec7b8, (q31_t)0x46a9d464, - (q31_t)0x4694de56, (q31_t)0x467fe590, - (q31_t)0x466aea12, (q31_t)0x4655ebdd, (q31_t)0x4640eaf2, (q31_t)0x462be751, (q31_t)0x4616e0fc, (q31_t)0x4601d7f3, - (q31_t)0x45eccc37, (q31_t)0x45d7bdc9, - (q31_t)0x45c2acaa, (q31_t)0x45ad98da, (q31_t)0x4598825a, (q31_t)0x4583692c, (q31_t)0x456e4d4f, (q31_t)0x45592ec6, - (q31_t)0x45440d90, (q31_t)0x452ee9ae, - (q31_t)0x4519c321, (q31_t)0x450499eb, (q31_t)0x44ef6e0b, (q31_t)0x44da3f83, (q31_t)0x44c50e53, (q31_t)0x44afda7d, - (q31_t)0x449aa400, (q31_t)0x44856adf, - (q31_t)0x44702f19, (q31_t)0x445af0b0, (q31_t)0x4445afa4, (q31_t)0x44306bf6, (q31_t)0x441b25a8, (q31_t)0x4405dcb9, - (q31_t)0x43f0912b, (q31_t)0x43db42fe, - (q31_t)0x43c5f234, (q31_t)0x43b09ecc, (q31_t)0x439b48c9, (q31_t)0x4385f02a, (q31_t)0x437094f1, (q31_t)0x435b371f, - (q31_t)0x4345d6b3, (q31_t)0x433073b0, - (q31_t)0x431b0e15, (q31_t)0x4305a5e5, (q31_t)0x42f03b1e, (q31_t)0x42dacdc3, (q31_t)0x42c55dd4, (q31_t)0x42afeb53, - (q31_t)0x429a763f, (q31_t)0x4284fe99, - (q31_t)0x426f8463, (q31_t)0x425a079e, (q31_t)0x42448849, (q31_t)0x422f0667, (q31_t)0x421981f7, (q31_t)0x4203fafb, - (q31_t)0x41ee7174, (q31_t)0x41d8e561, - (q31_t)0x41c356c5, (q31_t)0x41adc5a0, (q31_t)0x419831f3, (q31_t)0x41829bbe, (q31_t)0x416d0302, (q31_t)0x415767c1, - (q31_t)0x4141c9fb, (q31_t)0x412c29b1, - (q31_t)0x411686e4, (q31_t)0x4100e194, (q31_t)0x40eb39c3, (q31_t)0x40d58f71, (q31_t)0x40bfe29f, (q31_t)0x40aa334e, - (q31_t)0x4094817f, (q31_t)0x407ecd32, - (q31_t)0x40691669, (q31_t)0x40535d24, (q31_t)0x403da165, (q31_t)0x4027e32b, (q31_t)0x40122278, (q31_t)0x3ffc5f4d, - (q31_t)0x3fe699aa, (q31_t)0x3fd0d191, - (q31_t)0x3fbb0702, (q31_t)0x3fa539fd, (q31_t)0x3f8f6a85, (q31_t)0x3f799899, (q31_t)0x3f63c43b, (q31_t)0x3f4ded6b, - (q31_t)0x3f38142a, (q31_t)0x3f22387a, - (q31_t)0x3f0c5a5a, (q31_t)0x3ef679cc, (q31_t)0x3ee096d1, (q31_t)0x3ecab169, (q31_t)0x3eb4c995, (q31_t)0x3e9edf57, - (q31_t)0x3e88f2ae, (q31_t)0x3e73039d, - (q31_t)0x3e5d1222, (q31_t)0x3e471e41, (q31_t)0x3e3127f9, (q31_t)0x3e1b2f4a, (q31_t)0x3e053437, (q31_t)0x3def36c0, - (q31_t)0x3dd936e6, (q31_t)0x3dc334a9, - (q31_t)0x3dad300b, (q31_t)0x3d97290b, (q31_t)0x3d811fac, (q31_t)0x3d6b13ee, (q31_t)0x3d5505d2, (q31_t)0x3d3ef559, - (q31_t)0x3d28e282, (q31_t)0x3d12cd51, - (q31_t)0x3cfcb5c4, (q31_t)0x3ce69bde, (q31_t)0x3cd07f9f, (q31_t)0x3cba6107, (q31_t)0x3ca44018, (q31_t)0x3c8e1cd3, - (q31_t)0x3c77f737, (q31_t)0x3c61cf48, - (q31_t)0x3c4ba504, (q31_t)0x3c35786d, (q31_t)0x3c1f4983, (q31_t)0x3c091849, (q31_t)0x3bf2e4be, (q31_t)0x3bdcaee3, - (q31_t)0x3bc676b9, (q31_t)0x3bb03c42, - (q31_t)0x3b99ff7d, (q31_t)0x3b83c06c, (q31_t)0x3b6d7f10, (q31_t)0x3b573b69, (q31_t)0x3b40f579, (q31_t)0x3b2aad3f, - (q31_t)0x3b1462be, (q31_t)0x3afe15f6, - (q31_t)0x3ae7c6e7, (q31_t)0x3ad17593, (q31_t)0x3abb21fb, (q31_t)0x3aa4cc1e, (q31_t)0x3a8e7400, (q31_t)0x3a78199f, - (q31_t)0x3a61bcfd, (q31_t)0x3a4b5e1b, - (q31_t)0x3a34fcf9, (q31_t)0x3a1e9999, (q31_t)0x3a0833fc, (q31_t)0x39f1cc21, (q31_t)0x39db620b, (q31_t)0x39c4f5ba, - (q31_t)0x39ae872f, (q31_t)0x3998166a, - (q31_t)0x3981a36d, (q31_t)0x396b2e38, (q31_t)0x3954b6cd, (q31_t)0x393e3d2c, (q31_t)0x3927c155, (q31_t)0x3911434b, - (q31_t)0x38fac30e, (q31_t)0x38e4409e, - (q31_t)0x38cdbbfc, (q31_t)0x38b7352a, (q31_t)0x38a0ac29, (q31_t)0x388a20f8, (q31_t)0x38739399, (q31_t)0x385d040d, - (q31_t)0x38467255, (q31_t)0x382fde72, - (q31_t)0x38194864, (q31_t)0x3802b02c, (q31_t)0x37ec15cb, (q31_t)0x37d57943, (q31_t)0x37beda93, (q31_t)0x37a839be, - (q31_t)0x379196c3, (q31_t)0x377af1a3, - (q31_t)0x37644a60, (q31_t)0x374da0fa, (q31_t)0x3736f573, (q31_t)0x372047ca, (q31_t)0x37099802, (q31_t)0x36f2e61a, - (q31_t)0x36dc3214, (q31_t)0x36c57bf0, - (q31_t)0x36aec3b0, (q31_t)0x36980954, (q31_t)0x36814cde, (q31_t)0x366a8e4d, (q31_t)0x3653cda3, (q31_t)0x363d0ae2, - (q31_t)0x36264609, (q31_t)0x360f7f19, - (q31_t)0x35f8b614, (q31_t)0x35e1eafa, (q31_t)0x35cb1dcc, (q31_t)0x35b44e8c, (q31_t)0x359d7d39, (q31_t)0x3586a9d5, - (q31_t)0x356fd461, (q31_t)0x3558fcde, - (q31_t)0x3542234c, (q31_t)0x352b47ad, (q31_t)0x35146a00, (q31_t)0x34fd8a48, (q31_t)0x34e6a885, (q31_t)0x34cfc4b7, - (q31_t)0x34b8dee1, (q31_t)0x34a1f702, - (q31_t)0x348b0d1c, (q31_t)0x3474212f, (q31_t)0x345d333c, (q31_t)0x34464345, (q31_t)0x342f5149, (q31_t)0x34185d4b, - (q31_t)0x3401674a, (q31_t)0x33ea6f48, - (q31_t)0x33d37546, (q31_t)0x33bc7944, (q31_t)0x33a57b44, (q31_t)0x338e7b46, (q31_t)0x3377794b, (q31_t)0x33607554, - (q31_t)0x33496f62, (q31_t)0x33326776, - (q31_t)0x331b5d91, (q31_t)0x330451b3, (q31_t)0x32ed43de, (q31_t)0x32d63412, (q31_t)0x32bf2250, (q31_t)0x32a80e99, - (q31_t)0x3290f8ef, (q31_t)0x3279e151, - (q31_t)0x3262c7c1, (q31_t)0x324bac40, (q31_t)0x32348ecf, (q31_t)0x321d6f6e, (q31_t)0x32064e1e, (q31_t)0x31ef2ae1, - (q31_t)0x31d805b7, (q31_t)0x31c0dea1, - (q31_t)0x31a9b5a0, (q31_t)0x31928ab4, (q31_t)0x317b5de0, (q31_t)0x31642f23, (q31_t)0x314cfe7f, (q31_t)0x3135cbf4, - (q31_t)0x311e9783, (q31_t)0x3107612e, - (q31_t)0x30f028f4, (q31_t)0x30d8eed8, (q31_t)0x30c1b2da, (q31_t)0x30aa74fa, (q31_t)0x3093353a, (q31_t)0x307bf39b, - (q31_t)0x3064b01d, (q31_t)0x304d6ac1, - (q31_t)0x30362389, (q31_t)0x301eda75, (q31_t)0x30078f86, (q31_t)0x2ff042bd, (q31_t)0x2fd8f41b, (q31_t)0x2fc1a3a0, - (q31_t)0x2faa514f, (q31_t)0x2f92fd26, - (q31_t)0x2f7ba729, (q31_t)0x2f644f56, (q31_t)0x2f4cf5b0, (q31_t)0x2f359a37, (q31_t)0x2f1e3ced, (q31_t)0x2f06ddd1, - (q31_t)0x2eef7ce5, (q31_t)0x2ed81a29, - (q31_t)0x2ec0b5a0, (q31_t)0x2ea94f49, (q31_t)0x2e91e725, (q31_t)0x2e7a7d36, (q31_t)0x2e63117c, (q31_t)0x2e4ba3f8, - (q31_t)0x2e3434ac, (q31_t)0x2e1cc397, - (q31_t)0x2e0550bb, (q31_t)0x2deddc19, (q31_t)0x2dd665b2, (q31_t)0x2dbeed86, (q31_t)0x2da77397, (q31_t)0x2d8ff7e5, - (q31_t)0x2d787a72, (q31_t)0x2d60fb3e, - (q31_t)0x2d497a4a, (q31_t)0x2d31f797, (q31_t)0x2d1a7325, (q31_t)0x2d02ecf7, (q31_t)0x2ceb650d, (q31_t)0x2cd3db67, - (q31_t)0x2cbc5006, (q31_t)0x2ca4c2ed, - (q31_t)0x2c8d341a, (q31_t)0x2c75a390, (q31_t)0x2c5e114f, (q31_t)0x2c467d58, (q31_t)0x2c2ee7ad, (q31_t)0x2c17504d, - (q31_t)0x2bffb73a, (q31_t)0x2be81c74, - (q31_t)0x2bd07ffe, (q31_t)0x2bb8e1d7, (q31_t)0x2ba14200, (q31_t)0x2b89a07b, (q31_t)0x2b71fd48, (q31_t)0x2b5a5868, - (q31_t)0x2b42b1dd, (q31_t)0x2b2b09a6, - (q31_t)0x2b135fc6, (q31_t)0x2afbb43c, (q31_t)0x2ae4070a, (q31_t)0x2acc5831, (q31_t)0x2ab4a7b1, (q31_t)0x2a9cf58c, - (q31_t)0x2a8541c3, (q31_t)0x2a6d8c55, - (q31_t)0x2a55d545, (q31_t)0x2a3e1c93, (q31_t)0x2a266240, (q31_t)0x2a0ea64d, (q31_t)0x29f6e8bb, (q31_t)0x29df298b, - (q31_t)0x29c768be, (q31_t)0x29afa654, - (q31_t)0x2997e24f, (q31_t)0x29801caf, (q31_t)0x29685576, (q31_t)0x29508ca4, (q31_t)0x2938c23a, (q31_t)0x2920f63a, - (q31_t)0x290928a3, (q31_t)0x28f15978, - (q31_t)0x28d988b8, (q31_t)0x28c1b666, (q31_t)0x28a9e281, (q31_t)0x28920d0a, (q31_t)0x287a3604, (q31_t)0x28625d6d, - (q31_t)0x284a8349, (q31_t)0x2832a796, - (q31_t)0x281aca57, (q31_t)0x2802eb8c, (q31_t)0x27eb0b36, (q31_t)0x27d32956, (q31_t)0x27bb45ed, (q31_t)0x27a360fc, - (q31_t)0x278b7a84, (q31_t)0x27739285, - (q31_t)0x275ba901, (q31_t)0x2743bdf9, (q31_t)0x272bd16d, (q31_t)0x2713e35f, (q31_t)0x26fbf3ce, (q31_t)0x26e402bd, - (q31_t)0x26cc102d, (q31_t)0x26b41c1d, - (q31_t)0x269c268f, (q31_t)0x26842f84, (q31_t)0x266c36fe, (q31_t)0x26543cfb, (q31_t)0x263c417f, (q31_t)0x26244489, - (q31_t)0x260c461b, (q31_t)0x25f44635, - (q31_t)0x25dc44d9, (q31_t)0x25c44207, (q31_t)0x25ac3dc0, (q31_t)0x25943806, (q31_t)0x257c30d8, (q31_t)0x25642839, - (q31_t)0x254c1e28, (q31_t)0x253412a8, - (q31_t)0x251c05b8, (q31_t)0x2503f75a, (q31_t)0x24ebe78f, (q31_t)0x24d3d657, (q31_t)0x24bbc3b4, (q31_t)0x24a3afa6, - (q31_t)0x248b9a2f, (q31_t)0x2473834f, - (q31_t)0x245b6b07, (q31_t)0x24435158, (q31_t)0x242b3644, (q31_t)0x241319ca, (q31_t)0x23fafbec, (q31_t)0x23e2dcac, - (q31_t)0x23cabc09, (q31_t)0x23b29a05, - (q31_t)0x239a76a0, (q31_t)0x238251dd, (q31_t)0x236a2bba, (q31_t)0x2352043b, (q31_t)0x2339db5e, (q31_t)0x2321b126, - (q31_t)0x23098593, (q31_t)0x22f158a7, - (q31_t)0x22d92a61, (q31_t)0x22c0fac4, (q31_t)0x22a8c9cf, (q31_t)0x22909785, (q31_t)0x227863e5, (q31_t)0x22602ef1, - (q31_t)0x2247f8aa, (q31_t)0x222fc111, - (q31_t)0x22178826, (q31_t)0x21ff4dea, (q31_t)0x21e71260, (q31_t)0x21ced586, (q31_t)0x21b6975f, (q31_t)0x219e57eb, - (q31_t)0x2186172b, (q31_t)0x216dd521, - (q31_t)0x215591cc, (q31_t)0x213d4d2f, (q31_t)0x21250749, (q31_t)0x210cc01d, (q31_t)0x20f477aa, (q31_t)0x20dc2df2, - (q31_t)0x20c3e2f5, (q31_t)0x20ab96b5, - (q31_t)0x20934933, (q31_t)0x207afa6f, (q31_t)0x2062aa6b, (q31_t)0x204a5927, (q31_t)0x203206a4, (q31_t)0x2019b2e4, - (q31_t)0x20015de7, (q31_t)0x1fe907ae, - (q31_t)0x1fd0b03a, (q31_t)0x1fb8578b, (q31_t)0x1f9ffda4, (q31_t)0x1f87a285, (q31_t)0x1f6f462f, (q31_t)0x1f56e8a2, - (q31_t)0x1f3e89e0, (q31_t)0x1f2629ea, - (q31_t)0x1f0dc8c0, (q31_t)0x1ef56664, (q31_t)0x1edd02d6, (q31_t)0x1ec49e17, (q31_t)0x1eac3829, (q31_t)0x1e93d10c, - (q31_t)0x1e7b68c2, (q31_t)0x1e62ff4a, - (q31_t)0x1e4a94a7, (q31_t)0x1e3228d9, (q31_t)0x1e19bbe0, (q31_t)0x1e014dbf, (q31_t)0x1de8de75, (q31_t)0x1dd06e04, - (q31_t)0x1db7fc6d, (q31_t)0x1d9f89b1, - (q31_t)0x1d8715d0, (q31_t)0x1d6ea0cc, (q31_t)0x1d562aa6, (q31_t)0x1d3db35e, (q31_t)0x1d253af5, (q31_t)0x1d0cc16c, - (q31_t)0x1cf446c5, (q31_t)0x1cdbcb00, - (q31_t)0x1cc34e1f, (q31_t)0x1caad021, (q31_t)0x1c925109, (q31_t)0x1c79d0d6, (q31_t)0x1c614f8b, (q31_t)0x1c48cd27, - (q31_t)0x1c3049ac, (q31_t)0x1c17c51b, - (q31_t)0x1bff3f75, (q31_t)0x1be6b8ba, (q31_t)0x1bce30ec, (q31_t)0x1bb5a80c, (q31_t)0x1b9d1e1a, (q31_t)0x1b849317, - (q31_t)0x1b6c0705, (q31_t)0x1b5379e5, - (q31_t)0x1b3aebb6, (q31_t)0x1b225c7b, (q31_t)0x1b09cc34, (q31_t)0x1af13ae3, (q31_t)0x1ad8a887, (q31_t)0x1ac01522, - (q31_t)0x1aa780b6, (q31_t)0x1a8eeb42, - (q31_t)0x1a7654c8, (q31_t)0x1a5dbd49, (q31_t)0x1a4524c6, (q31_t)0x1a2c8b3f, (q31_t)0x1a13f0b6, (q31_t)0x19fb552c, - (q31_t)0x19e2b8a2, (q31_t)0x19ca1b17, - (q31_t)0x19b17c8f, (q31_t)0x1998dd09, (q31_t)0x19803c86, (q31_t)0x19679b07, (q31_t)0x194ef88e, (q31_t)0x1936551b, - (q31_t)0x191db0af, (q31_t)0x19050b4b, - (q31_t)0x18ec64f0, (q31_t)0x18d3bda0, (q31_t)0x18bb155a, (q31_t)0x18a26c20, (q31_t)0x1889c1f3, (q31_t)0x187116d4, - (q31_t)0x18586ac3, (q31_t)0x183fbdc3, - (q31_t)0x18270fd3, (q31_t)0x180e60f4, (q31_t)0x17f5b129, (q31_t)0x17dd0070, (q31_t)0x17c44ecd, (q31_t)0x17ab9c3e, - (q31_t)0x1792e8c6, (q31_t)0x177a3466, - (q31_t)0x17617f1d, (q31_t)0x1748c8ee, (q31_t)0x173011d9, (q31_t)0x171759df, (q31_t)0x16fea102, (q31_t)0x16e5e741, - (q31_t)0x16cd2c9f, (q31_t)0x16b4711b, - (q31_t)0x169bb4b7, (q31_t)0x1682f774, (q31_t)0x166a3953, (q31_t)0x16517a55, (q31_t)0x1638ba7a, (q31_t)0x161ff9c4, - (q31_t)0x16073834, (q31_t)0x15ee75cb, - (q31_t)0x15d5b288, (q31_t)0x15bcee6f, (q31_t)0x15a4297f, (q31_t)0x158b63b9, (q31_t)0x15729d1f, (q31_t)0x1559d5b1, - (q31_t)0x15410d70, (q31_t)0x1528445d, - (q31_t)0x150f7a7a, (q31_t)0x14f6afc7, (q31_t)0x14dde445, (q31_t)0x14c517f4, (q31_t)0x14ac4ad7, (q31_t)0x14937cee, - (q31_t)0x147aae3a, (q31_t)0x1461debc, - (q31_t)0x14490e74, (q31_t)0x14303d65, (q31_t)0x14176b8e, (q31_t)0x13fe98f1, (q31_t)0x13e5c58e, (q31_t)0x13ccf167, - (q31_t)0x13b41c7d, (q31_t)0x139b46d0, - (q31_t)0x13827062, (q31_t)0x13699933, (q31_t)0x1350c144, (q31_t)0x1337e897, (q31_t)0x131f0f2c, (q31_t)0x13063505, - (q31_t)0x12ed5a21, (q31_t)0x12d47e83, - (q31_t)0x12bba22b, (q31_t)0x12a2c51b, (q31_t)0x1289e752, (q31_t)0x127108d2, (q31_t)0x1258299c, (q31_t)0x123f49b2, - (q31_t)0x12266913, (q31_t)0x120d87c1, - (q31_t)0x11f4a5bd, (q31_t)0x11dbc307, (q31_t)0x11c2dfa2, (q31_t)0x11a9fb8d, (q31_t)0x119116c9, (q31_t)0x11783159, - (q31_t)0x115f4b3c, (q31_t)0x11466473, - (q31_t)0x112d7d00, (q31_t)0x111494e4, (q31_t)0x10fbac1e, (q31_t)0x10e2c2b2, (q31_t)0x10c9d89e, (q31_t)0x10b0ede5, - (q31_t)0x10980287, (q31_t)0x107f1686, - (q31_t)0x106629e1, (q31_t)0x104d3c9b, (q31_t)0x10344eb4, (q31_t)0x101b602d, (q31_t)0x10027107, (q31_t)0xfe98143, - (q31_t)0xfd090e1, (q31_t)0xfb79fe4, - (q31_t)0xf9eae4c, (q31_t)0xf85bc19, (q31_t)0xf6cc94e, (q31_t)0xf53d5ea, (q31_t)0xf3ae1ee, (q31_t)0xf21ed5d, (q31_t)0xf08f836, - (q31_t)0xef0027b, - (q31_t)0xed70c2c, (q31_t)0xebe154b, (q31_t)0xea51dd8, (q31_t)0xe8c25d5, (q31_t)0xe732d42, (q31_t)0xe5a3421, (q31_t)0xe413a72, - (q31_t)0xe284036, - (q31_t)0xe0f456f, (q31_t)0xdf64a1c, (q31_t)0xddd4e40, (q31_t)0xdc451dc, (q31_t)0xdab54ef, (q31_t)0xd92577b, (q31_t)0xd795982, - (q31_t)0xd605b03, - (q31_t)0xd475c00, (q31_t)0xd2e5c7b, (q31_t)0xd155c73, (q31_t)0xcfc5bea, (q31_t)0xce35ae1, (q31_t)0xcca5959, (q31_t)0xcb15752, - (q31_t)0xc9854cf, - (q31_t)0xc7f51cf, (q31_t)0xc664e53, (q31_t)0xc4d4a5d, (q31_t)0xc3445ee, (q31_t)0xc1b4107, (q31_t)0xc023ba7, (q31_t)0xbe935d2, - (q31_t)0xbd02f87, - (q31_t)0xbb728c7, (q31_t)0xb9e2193, (q31_t)0xb8519ed, (q31_t)0xb6c11d5, (q31_t)0xb53094d, (q31_t)0xb3a0055, (q31_t)0xb20f6ee, - (q31_t)0xb07ed19, - (q31_t)0xaeee2d7, (q31_t)0xad5d829, (q31_t)0xabccd11, (q31_t)0xaa3c18e, (q31_t)0xa8ab5a2, (q31_t)0xa71a94f, (q31_t)0xa589c94, - (q31_t)0xa3f8f73, - (q31_t)0xa2681ed, (q31_t)0xa0d7403, (q31_t)0x9f465b5, (q31_t)0x9db5706, (q31_t)0x9c247f5, (q31_t)0x9a93884, (q31_t)0x99028b3, - (q31_t)0x9771884, - (q31_t)0x95e07f8, (q31_t)0x944f70f, (q31_t)0x92be5ca, (q31_t)0x912d42c, (q31_t)0x8f9c233, (q31_t)0x8e0afe2, (q31_t)0x8c79d3a, - (q31_t)0x8ae8a3a, - (q31_t)0x89576e5, (q31_t)0x87c633c, (q31_t)0x8634f3e, (q31_t)0x84a3aee, (q31_t)0x831264c, (q31_t)0x8181159, (q31_t)0x7fefc16, - (q31_t)0x7e5e685, - (q31_t)0x7ccd0a5, (q31_t)0x7b3ba78, (q31_t)0x79aa400, (q31_t)0x7818d3c, (q31_t)0x768762e, (q31_t)0x74f5ed7, (q31_t)0x7364738, - (q31_t)0x71d2f52, - (q31_t)0x7041726, (q31_t)0x6eafeb4, (q31_t)0x6d1e5fe, (q31_t)0x6b8cd05, (q31_t)0x69fb3c9, (q31_t)0x6869a4c, (q31_t)0x66d808f, - (q31_t)0x6546692, - (q31_t)0x63b4c57, (q31_t)0x62231de, (q31_t)0x6091729, (q31_t)0x5effc38, (q31_t)0x5d6e10c, (q31_t)0x5bdc5a7, (q31_t)0x5a4aa09, - (q31_t)0x58b8e34, - (q31_t)0x5727228, (q31_t)0x55955e6, (q31_t)0x540396f, (q31_t)0x5271cc4, (q31_t)0x50dffe7, (q31_t)0x4f4e2d8, (q31_t)0x4dbc597, - (q31_t)0x4c2a827, - (q31_t)0x4a98a88, (q31_t)0x4906cbb, (q31_t)0x4774ec1, (q31_t)0x45e309a, (q31_t)0x4451249, (q31_t)0x42bf3cd, (q31_t)0x412d528, - (q31_t)0x3f9b65b, - (q31_t)0x3e09767, (q31_t)0x3c7784d, (q31_t)0x3ae590d, (q31_t)0x39539a9, (q31_t)0x37c1a22, (q31_t)0x362fa78, (q31_t)0x349daac, - (q31_t)0x330bac1, - (q31_t)0x3179ab5, (q31_t)0x2fe7a8c, (q31_t)0x2e55a44, (q31_t)0x2cc39e1, (q31_t)0x2b31961, (q31_t)0x299f8c7, (q31_t)0x280d813, - (q31_t)0x267b747, - (q31_t)0x24e9662, (q31_t)0x2357567, (q31_t)0x21c5457, (q31_t)0x2033331, (q31_t)0x1ea11f7, (q31_t)0x1d0f0ab, (q31_t)0x1b7cf4d, - (q31_t)0x19eaddd, - (q31_t)0x1858c5e, (q31_t)0x16c6ad0, (q31_t)0x1534934, (q31_t)0x13a278a, (q31_t)0x12105d5, (q31_t)0x107e414, (q31_t)0xeec249, - (q31_t)0xd5a075, - (q31_t)0xbc7e99, (q31_t)0xa35cb5, (q31_t)0x8a3acb, (q31_t)0x7118dc, (q31_t)0x57f6e9, (q31_t)0x3ed4f2, (q31_t)0x25b2f8, - (q31_t)0xc90fe -}; + (q31_t)0x7fffff62, (q31_t)0x7ffffa73, (q31_t)0x7ffff094, (q31_t)0x7fffe1c6, + (q31_t)0x7fffce09, (q31_t)0x7fffb55c, (q31_t)0x7fff97c1, (q31_t)0x7fff7536, + (q31_t)0x7fff4dbb, (q31_t)0x7fff2151, (q31_t)0x7ffeeff8, (q31_t)0x7ffeb9b0, + (q31_t)0x7ffe7e79, (q31_t)0x7ffe3e52, (q31_t)0x7ffdf93c, (q31_t)0x7ffdaf37, + (q31_t)0x7ffd6042, (q31_t)0x7ffd0c5f, (q31_t)0x7ffcb38c, (q31_t)0x7ffc55ca, + (q31_t)0x7ffbf319, (q31_t)0x7ffb8b78, (q31_t)0x7ffb1ee9, (q31_t)0x7ffaad6a, + (q31_t)0x7ffa36fc, (q31_t)0x7ff9bba0, (q31_t)0x7ff93b54, (q31_t)0x7ff8b619, + (q31_t)0x7ff82bef, (q31_t)0x7ff79cd6, (q31_t)0x7ff708ce, (q31_t)0x7ff66fd7, + (q31_t)0x7ff5d1f1, (q31_t)0x7ff52f1d, (q31_t)0x7ff48759, (q31_t)0x7ff3daa6, + (q31_t)0x7ff32905, (q31_t)0x7ff27275, (q31_t)0x7ff1b6f6, (q31_t)0x7ff0f688, + (q31_t)0x7ff0312c, (q31_t)0x7fef66e1, (q31_t)0x7fee97a7, (q31_t)0x7fedc37e, + (q31_t)0x7fecea67, (q31_t)0x7fec0c62, (q31_t)0x7feb296d, (q31_t)0x7fea418b, + (q31_t)0x7fe954ba, (q31_t)0x7fe862fa, (q31_t)0x7fe76c4c, (q31_t)0x7fe670b0, + (q31_t)0x7fe57025, (q31_t)0x7fe46aac, (q31_t)0x7fe36045, (q31_t)0x7fe250ef, + (q31_t)0x7fe13cac, (q31_t)0x7fe0237a, (q31_t)0x7fdf055a, (q31_t)0x7fdde24d, + (q31_t)0x7fdcba51, (q31_t)0x7fdb8d67, (q31_t)0x7fda5b8f, (q31_t)0x7fd924ca, + (q31_t)0x7fd7e917, (q31_t)0x7fd6a875, (q31_t)0x7fd562e7, (q31_t)0x7fd4186a, + (q31_t)0x7fd2c900, (q31_t)0x7fd174a8, (q31_t)0x7fd01b63, (q31_t)0x7fcebd31, + (q31_t)0x7fcd5a11, (q31_t)0x7fcbf203, (q31_t)0x7fca8508, (q31_t)0x7fc91320, + (q31_t)0x7fc79c4b, (q31_t)0x7fc62089, (q31_t)0x7fc49fda, (q31_t)0x7fc31a3d, + (q31_t)0x7fc18fb4, (q31_t)0x7fc0003e, (q31_t)0x7fbe6bdb, (q31_t)0x7fbcd28b, + (q31_t)0x7fbb344e, (q31_t)0x7fb99125, (q31_t)0x7fb7e90f, (q31_t)0x7fb63c0d, + (q31_t)0x7fb48a1e, (q31_t)0x7fb2d343, (q31_t)0x7fb1177b, (q31_t)0x7faf56c7, + (q31_t)0x7fad9127, (q31_t)0x7fabc69b, (q31_t)0x7fa9f723, (q31_t)0x7fa822bf, + (q31_t)0x7fa6496e, (q31_t)0x7fa46b32, (q31_t)0x7fa2880b, (q31_t)0x7fa09ff7, + (q31_t)0x7f9eb2f8, (q31_t)0x7f9cc10d, (q31_t)0x7f9aca37, (q31_t)0x7f98ce76, + (q31_t)0x7f96cdc9, (q31_t)0x7f94c831, (q31_t)0x7f92bdad, (q31_t)0x7f90ae3f, + (q31_t)0x7f8e99e6, (q31_t)0x7f8c80a1, (q31_t)0x7f8a6272, (q31_t)0x7f883f58, + (q31_t)0x7f861753, (q31_t)0x7f83ea64, (q31_t)0x7f81b88a, (q31_t)0x7f7f81c6, + (q31_t)0x7f7d4617, (q31_t)0x7f7b057e, (q31_t)0x7f78bffb, (q31_t)0x7f76758e, + (q31_t)0x7f742637, (q31_t)0x7f71d1f6, (q31_t)0x7f6f78cb, (q31_t)0x7f6d1ab6, + (q31_t)0x7f6ab7b8, (q31_t)0x7f684fd0, (q31_t)0x7f65e2ff, (q31_t)0x7f637144, + (q31_t)0x7f60faa0, (q31_t)0x7f5e7f13, (q31_t)0x7f5bfe9d, (q31_t)0x7f59793e, + (q31_t)0x7f56eef5, (q31_t)0x7f545fc5, (q31_t)0x7f51cbab, (q31_t)0x7f4f32a9, + (q31_t)0x7f4c94be, (q31_t)0x7f49f1eb, (q31_t)0x7f474a30, (q31_t)0x7f449d8c, + (q31_t)0x7f41ec01, (q31_t)0x7f3f358d, (q31_t)0x7f3c7a31, (q31_t)0x7f39b9ee, + (q31_t)0x7f36f4c3, (q31_t)0x7f342ab1, (q31_t)0x7f315bb7, (q31_t)0x7f2e87d6, + (q31_t)0x7f2baf0d, (q31_t)0x7f28d15d, (q31_t)0x7f25eec7, (q31_t)0x7f230749, + (q31_t)0x7f201ae5, (q31_t)0x7f1d299a, (q31_t)0x7f1a3368, (q31_t)0x7f173850, + (q31_t)0x7f143852, (q31_t)0x7f11336d, (q31_t)0x7f0e29a3, (q31_t)0x7f0b1af2, + (q31_t)0x7f08075c, (q31_t)0x7f04eedf, (q31_t)0x7f01d17d, (q31_t)0x7efeaf36, + (q31_t)0x7efb8809, (q31_t)0x7ef85bf7, (q31_t)0x7ef52b00, (q31_t)0x7ef1f524, + (q31_t)0x7eeeba62, (q31_t)0x7eeb7abc, (q31_t)0x7ee83632, (q31_t)0x7ee4ecc3, + (q31_t)0x7ee19e6f, (q31_t)0x7ede4b38, (q31_t)0x7edaf31c, (q31_t)0x7ed7961c, + (q31_t)0x7ed43438, (q31_t)0x7ed0cd70, (q31_t)0x7ecd61c5, (q31_t)0x7ec9f137, + (q31_t)0x7ec67bc5, (q31_t)0x7ec3016f, (q31_t)0x7ebf8237, (q31_t)0x7ebbfe1c, + (q31_t)0x7eb8751e, (q31_t)0x7eb4e73d, (q31_t)0x7eb1547a, (q31_t)0x7eadbcd4, + (q31_t)0x7eaa204c, (q31_t)0x7ea67ee2, (q31_t)0x7ea2d896, (q31_t)0x7e9f2d68, + (q31_t)0x7e9b7d58, (q31_t)0x7e97c867, (q31_t)0x7e940e94, (q31_t)0x7e904fe0, + (q31_t)0x7e8c8c4b, (q31_t)0x7e88c3d5, (q31_t)0x7e84f67e, (q31_t)0x7e812447, + (q31_t)0x7e7d4d2f, (q31_t)0x7e797136, (q31_t)0x7e75905d, (q31_t)0x7e71aaa4, + (q31_t)0x7e6dc00c, (q31_t)0x7e69d093, (q31_t)0x7e65dc3b, (q31_t)0x7e61e303, + (q31_t)0x7e5de4ec, (q31_t)0x7e59e1f5, (q31_t)0x7e55da20, (q31_t)0x7e51cd6c, + (q31_t)0x7e4dbbd9, (q31_t)0x7e49a567, (q31_t)0x7e458a17, (q31_t)0x7e4169e9, + (q31_t)0x7e3d44dd, (q31_t)0x7e391af3, (q31_t)0x7e34ec2b, (q31_t)0x7e30b885, + (q31_t)0x7e2c8002, (q31_t)0x7e2842a2, (q31_t)0x7e240064, (q31_t)0x7e1fb94a, + (q31_t)0x7e1b6d53, (q31_t)0x7e171c7f, (q31_t)0x7e12c6ce, (q31_t)0x7e0e6c42, + (q31_t)0x7e0a0cd9, (q31_t)0x7e05a894, (q31_t)0x7e013f74, (q31_t)0x7dfcd178, + (q31_t)0x7df85ea0, (q31_t)0x7df3e6ee, (q31_t)0x7def6a60, (q31_t)0x7deae8f7, + (q31_t)0x7de662b3, (q31_t)0x7de1d795, (q31_t)0x7ddd479d, (q31_t)0x7dd8b2ca, + (q31_t)0x7dd4191d, (q31_t)0x7dcf7a96, (q31_t)0x7dcad736, (q31_t)0x7dc62efc, + (q31_t)0x7dc181e8, (q31_t)0x7dbccffc, (q31_t)0x7db81936, (q31_t)0x7db35d98, + (q31_t)0x7dae9d21, (q31_t)0x7da9d7d2, (q31_t)0x7da50dab, (q31_t)0x7da03eab, + (q31_t)0x7d9b6ad3, (q31_t)0x7d969224, (q31_t)0x7d91b49e, (q31_t)0x7d8cd240, + (q31_t)0x7d87eb0a, (q31_t)0x7d82fefe, (q31_t)0x7d7e0e1c, (q31_t)0x7d791862, + (q31_t)0x7d741dd2, (q31_t)0x7d6f1e6c, (q31_t)0x7d6a1a31, (q31_t)0x7d65111f, + (q31_t)0x7d600338, (q31_t)0x7d5af07b, (q31_t)0x7d55d8e9, (q31_t)0x7d50bc82, + (q31_t)0x7d4b9b46, (q31_t)0x7d467536, (q31_t)0x7d414a51, (q31_t)0x7d3c1a98, + (q31_t)0x7d36e60b, (q31_t)0x7d31acaa, (q31_t)0x7d2c6e76, (q31_t)0x7d272b6e, + (q31_t)0x7d21e393, (q31_t)0x7d1c96e5, (q31_t)0x7d174564, (q31_t)0x7d11ef11, + (q31_t)0x7d0c93eb, (q31_t)0x7d0733f3, (q31_t)0x7d01cf29, (q31_t)0x7cfc658d, + (q31_t)0x7cf6f720, (q31_t)0x7cf183e1, (q31_t)0x7cec0bd1, (q31_t)0x7ce68ef0, + (q31_t)0x7ce10d3f, (q31_t)0x7cdb86bd, (q31_t)0x7cd5fb6a, (q31_t)0x7cd06b48, + (q31_t)0x7ccad656, (q31_t)0x7cc53c94, (q31_t)0x7cbf9e03, (q31_t)0x7cb9faa2, + (q31_t)0x7cb45272, (q31_t)0x7caea574, (q31_t)0x7ca8f3a7, (q31_t)0x7ca33d0c, + (q31_t)0x7c9d81a3, (q31_t)0x7c97c16b, (q31_t)0x7c91fc66, (q31_t)0x7c8c3294, + (q31_t)0x7c8663f4, (q31_t)0x7c809088, (q31_t)0x7c7ab84e, (q31_t)0x7c74db48, + (q31_t)0x7c6ef976, (q31_t)0x7c6912d7, (q31_t)0x7c63276d, (q31_t)0x7c5d3737, + (q31_t)0x7c574236, (q31_t)0x7c514869, (q31_t)0x7c4b49d2, (q31_t)0x7c45466f, + (q31_t)0x7c3f3e42, (q31_t)0x7c39314b, (q31_t)0x7c331f8a, (q31_t)0x7c2d08ff, + (q31_t)0x7c26edab, (q31_t)0x7c20cd8d, (q31_t)0x7c1aa8a6, (q31_t)0x7c147ef6, + (q31_t)0x7c0e507e, (q31_t)0x7c081d3d, (q31_t)0x7c01e534, (q31_t)0x7bfba863, + (q31_t)0x7bf566cb, (q31_t)0x7bef206b, (q31_t)0x7be8d544, (q31_t)0x7be28556, + (q31_t)0x7bdc30a1, (q31_t)0x7bd5d726, (q31_t)0x7bcf78e5, (q31_t)0x7bc915dd, + (q31_t)0x7bc2ae10, (q31_t)0x7bbc417e, (q31_t)0x7bb5d026, (q31_t)0x7baf5a09, + (q31_t)0x7ba8df28, (q31_t)0x7ba25f82, (q31_t)0x7b9bdb18, (q31_t)0x7b9551ea, + (q31_t)0x7b8ec3f8, (q31_t)0x7b883143, (q31_t)0x7b8199ca, (q31_t)0x7b7afd8f, + (q31_t)0x7b745c91, (q31_t)0x7b6db6d0, (q31_t)0x7b670c4d, (q31_t)0x7b605d09, + (q31_t)0x7b59a902, (q31_t)0x7b52f03a, (q31_t)0x7b4c32b1, (q31_t)0x7b457068, + (q31_t)0x7b3ea95d, (q31_t)0x7b37dd92, (q31_t)0x7b310d07, (q31_t)0x7b2a37bc, + (q31_t)0x7b235db2, (q31_t)0x7b1c7ee8, (q31_t)0x7b159b5f, (q31_t)0x7b0eb318, + (q31_t)0x7b07c612, (q31_t)0x7b00d44d, (q31_t)0x7af9ddcb, (q31_t)0x7af2e28b, + (q31_t)0x7aebe28d, (q31_t)0x7ae4ddd2, (q31_t)0x7addd45b, (q31_t)0x7ad6c626, + (q31_t)0x7acfb336, (q31_t)0x7ac89b89, (q31_t)0x7ac17f20, (q31_t)0x7aba5dfc, + (q31_t)0x7ab3381d, (q31_t)0x7aac0d82, (q31_t)0x7aa4de2d, (q31_t)0x7a9daa1d, + (q31_t)0x7a967153, (q31_t)0x7a8f33d0, (q31_t)0x7a87f192, (q31_t)0x7a80aa9c, + (q31_t)0x7a795eec, (q31_t)0x7a720e84, (q31_t)0x7a6ab963, (q31_t)0x7a635f8a, + (q31_t)0x7a5c00f9, (q31_t)0x7a549db0, (q31_t)0x7a4d35b0, (q31_t)0x7a45c8f9, + (q31_t)0x7a3e578b, (q31_t)0x7a36e166, (q31_t)0x7a2f668c, (q31_t)0x7a27e6fb, + (q31_t)0x7a2062b5, (q31_t)0x7a18d9b9, (q31_t)0x7a114c09, (q31_t)0x7a09b9a4, + (q31_t)0x7a02228a, (q31_t)0x79fa86bc, (q31_t)0x79f2e63a, (q31_t)0x79eb4105, + (q31_t)0x79e3971c, (q31_t)0x79dbe880, (q31_t)0x79d43532, (q31_t)0x79cc7d31, + (q31_t)0x79c4c07e, (q31_t)0x79bcff19, (q31_t)0x79b53903, (q31_t)0x79ad6e3c, + (q31_t)0x79a59ec3, (q31_t)0x799dca9a, (q31_t)0x7995f1c1, (q31_t)0x798e1438, + (q31_t)0x798631ff, (q31_t)0x797e4b16, (q31_t)0x79765f7f, (q31_t)0x796e6f39, + (q31_t)0x79667a44, (q31_t)0x795e80a1, (q31_t)0x79568250, (q31_t)0x794e7f52, + (q31_t)0x794677a6, (q31_t)0x793e6b4e, (q31_t)0x79365a49, (q31_t)0x792e4497, + (q31_t)0x79262a3a, (q31_t)0x791e0b31, (q31_t)0x7915e77c, (q31_t)0x790dbf1d, + (q31_t)0x79059212, (q31_t)0x78fd605d, (q31_t)0x78f529fe, (q31_t)0x78eceef6, + (q31_t)0x78e4af44, (q31_t)0x78dc6ae8, (q31_t)0x78d421e4, (q31_t)0x78cbd437, + (q31_t)0x78c381e2, (q31_t)0x78bb2ae5, (q31_t)0x78b2cf41, (q31_t)0x78aa6ef5, + (q31_t)0x78a20a03, (q31_t)0x7899a06a, (q31_t)0x7891322a, (q31_t)0x7888bf45, + (q31_t)0x788047ba, (q31_t)0x7877cb89, (q31_t)0x786f4ab4, (q31_t)0x7866c53a, + (q31_t)0x785e3b1c, (q31_t)0x7855ac5a, (q31_t)0x784d18f4, (q31_t)0x784480ea, + (q31_t)0x783be43e, (q31_t)0x783342ef, (q31_t)0x782a9cfe, (q31_t)0x7821f26b, + (q31_t)0x78194336, (q31_t)0x78108f60, (q31_t)0x7807d6e9, (q31_t)0x77ff19d1, + (q31_t)0x77f65819, (q31_t)0x77ed91c0, (q31_t)0x77e4c6c9, (q31_t)0x77dbf732, + (q31_t)0x77d322fc, (q31_t)0x77ca4a27, (q31_t)0x77c16cb4, (q31_t)0x77b88aa3, + (q31_t)0x77afa3f5, (q31_t)0x77a6b8a9, (q31_t)0x779dc8c0, (q31_t)0x7794d43b, + (q31_t)0x778bdb19, (q31_t)0x7782dd5c, (q31_t)0x7779db03, (q31_t)0x7770d40f, + (q31_t)0x7767c880, (q31_t)0x775eb857, (q31_t)0x7755a394, (q31_t)0x774c8a36, + (q31_t)0x77436c40, (q31_t)0x773a49b0, (q31_t)0x77312287, (q31_t)0x7727f6c6, + (q31_t)0x771ec66e, (q31_t)0x7715917d, (q31_t)0x770c57f5, (q31_t)0x770319d6, + (q31_t)0x76f9d721, (q31_t)0x76f08fd5, (q31_t)0x76e743f4, (q31_t)0x76ddf37c, + (q31_t)0x76d49e70, (q31_t)0x76cb44cf, (q31_t)0x76c1e699, (q31_t)0x76b883d0, + (q31_t)0x76af1c72, (q31_t)0x76a5b082, (q31_t)0x769c3ffe, (q31_t)0x7692cae8, + (q31_t)0x7689513f, (q31_t)0x767fd304, (q31_t)0x76765038, (q31_t)0x766cc8db, + (q31_t)0x76633ced, (q31_t)0x7659ac6f, (q31_t)0x76501760, (q31_t)0x76467dc2, + (q31_t)0x763cdf94, (q31_t)0x76333cd8, (q31_t)0x7629958c, (q31_t)0x761fe9b3, + (q31_t)0x7616394c, (q31_t)0x760c8457, (q31_t)0x7602cad5, (q31_t)0x75f90cc7, + (q31_t)0x75ef4a2c, (q31_t)0x75e58305, (q31_t)0x75dbb753, (q31_t)0x75d1e715, + (q31_t)0x75c8124d, (q31_t)0x75be38fa, (q31_t)0x75b45b1d, (q31_t)0x75aa78b6, + (q31_t)0x75a091c6, (q31_t)0x7596a64d, (q31_t)0x758cb64c, (q31_t)0x7582c1c2, + (q31_t)0x7578c8b0, (q31_t)0x756ecb18, (q31_t)0x7564c8f8, (q31_t)0x755ac251, + (q31_t)0x7550b725, (q31_t)0x7546a772, (q31_t)0x753c933a, (q31_t)0x75327a7d, + (q31_t)0x75285d3b, (q31_t)0x751e3b75, (q31_t)0x7514152b, (q31_t)0x7509ea5d, + (q31_t)0x74ffbb0d, (q31_t)0x74f58739, (q31_t)0x74eb4ee3, (q31_t)0x74e1120c, + (q31_t)0x74d6d0b2, (q31_t)0x74cc8ad8, (q31_t)0x74c2407d, (q31_t)0x74b7f1a1, + (q31_t)0x74ad9e46, (q31_t)0x74a3466b, (q31_t)0x7498ea11, (q31_t)0x748e8938, + (q31_t)0x748423e0, (q31_t)0x7479ba0b, (q31_t)0x746f4bb8, (q31_t)0x7464d8e8, + (q31_t)0x745a619b, (q31_t)0x744fe5d2, (q31_t)0x7445658d, (q31_t)0x743ae0cc, + (q31_t)0x74305790, (q31_t)0x7425c9da, (q31_t)0x741b37a9, (q31_t)0x7410a0fe, + (q31_t)0x740605d9, (q31_t)0x73fb663c, (q31_t)0x73f0c226, (q31_t)0x73e61997, + (q31_t)0x73db6c91, (q31_t)0x73d0bb13, (q31_t)0x73c6051f, (q31_t)0x73bb4ab3, + (q31_t)0x73b08bd1, (q31_t)0x73a5c87a, (q31_t)0x739b00ad, (q31_t)0x7390346b, + (q31_t)0x738563b5, (q31_t)0x737a8e8a, (q31_t)0x736fb4ec, (q31_t)0x7364d6da, + (q31_t)0x7359f456, (q31_t)0x734f0d5f, (q31_t)0x734421f6, (q31_t)0x7339321b, + (q31_t)0x732e3dcf, (q31_t)0x73234512, (q31_t)0x731847e5, (q31_t)0x730d4648, + (q31_t)0x7302403c, (q31_t)0x72f735c0, (q31_t)0x72ec26d6, (q31_t)0x72e1137d, + (q31_t)0x72d5fbb7, (q31_t)0x72cadf83, (q31_t)0x72bfbee3, (q31_t)0x72b499d6, + (q31_t)0x72a9705c, (q31_t)0x729e4277, (q31_t)0x72931027, (q31_t)0x7287d96c, + (q31_t)0x727c9e47, (q31_t)0x72715eb8, (q31_t)0x72661abf, (q31_t)0x725ad25d, + (q31_t)0x724f8593, (q31_t)0x72443460, (q31_t)0x7238dec5, (q31_t)0x722d84c4, + (q31_t)0x7222265b, (q31_t)0x7216c38c, (q31_t)0x720b5c57, (q31_t)0x71fff0bc, + (q31_t)0x71f480bc, (q31_t)0x71e90c57, (q31_t)0x71dd938f, (q31_t)0x71d21662, + (q31_t)0x71c694d2, (q31_t)0x71bb0edf, (q31_t)0x71af848a, (q31_t)0x71a3f5d2, + (q31_t)0x719862b9, (q31_t)0x718ccb3f, (q31_t)0x71812f65, (q31_t)0x71758f29, + (q31_t)0x7169ea8f, (q31_t)0x715e4194, (q31_t)0x7152943b, (q31_t)0x7146e284, + (q31_t)0x713b2c6e, (q31_t)0x712f71fb, (q31_t)0x7123b32b, (q31_t)0x7117effe, + (q31_t)0x710c2875, (q31_t)0x71005c90, (q31_t)0x70f48c50, (q31_t)0x70e8b7b5, + (q31_t)0x70dcdec0, (q31_t)0x70d10171, (q31_t)0x70c51fc8, (q31_t)0x70b939c7, + (q31_t)0x70ad4f6d, (q31_t)0x70a160ba, (q31_t)0x70956db1, (q31_t)0x70897650, + (q31_t)0x707d7a98, (q31_t)0x70717a8a, (q31_t)0x70657626, (q31_t)0x70596d6d, + (q31_t)0x704d6060, (q31_t)0x70414efd, (q31_t)0x70353947, (q31_t)0x70291f3e, + (q31_t)0x701d00e1, (q31_t)0x7010de32, (q31_t)0x7004b731, (q31_t)0x6ff88bde, + (q31_t)0x6fec5c3b, (q31_t)0x6fe02846, (q31_t)0x6fd3f001, (q31_t)0x6fc7b36d, + (q31_t)0x6fbb728a, (q31_t)0x6faf2d57, (q31_t)0x6fa2e3d7, (q31_t)0x6f969608, + (q31_t)0x6f8a43ed, (q31_t)0x6f7ded84, (q31_t)0x6f7192cf, (q31_t)0x6f6533ce, + (q31_t)0x6f58d082, (q31_t)0x6f4c68eb, (q31_t)0x6f3ffd09, (q31_t)0x6f338cde, + (q31_t)0x6f271868, (q31_t)0x6f1a9faa, (q31_t)0x6f0e22a3, (q31_t)0x6f01a155, + (q31_t)0x6ef51bbe, (q31_t)0x6ee891e1, (q31_t)0x6edc03bc, (q31_t)0x6ecf7152, + (q31_t)0x6ec2daa2, (q31_t)0x6eb63fad, (q31_t)0x6ea9a073, (q31_t)0x6e9cfcf5, + (q31_t)0x6e905534, (q31_t)0x6e83a92f, (q31_t)0x6e76f8e7, (q31_t)0x6e6a445d, + (q31_t)0x6e5d8b91, (q31_t)0x6e50ce84, (q31_t)0x6e440d37, (q31_t)0x6e3747a9, + (q31_t)0x6e2a7ddb, (q31_t)0x6e1dafce, (q31_t)0x6e10dd82, (q31_t)0x6e0406f8, + (q31_t)0x6df72c30, (q31_t)0x6dea4d2b, (q31_t)0x6ddd69e9, (q31_t)0x6dd0826a, + (q31_t)0x6dc396b0, (q31_t)0x6db6a6ba, (q31_t)0x6da9b28a, (q31_t)0x6d9cba1f, + (q31_t)0x6d8fbd7a, (q31_t)0x6d82bc9d, (q31_t)0x6d75b786, (q31_t)0x6d68ae37, + (q31_t)0x6d5ba0b0, (q31_t)0x6d4e8ef2, (q31_t)0x6d4178fd, (q31_t)0x6d345ed1, + (q31_t)0x6d274070, (q31_t)0x6d1a1dda, (q31_t)0x6d0cf70f, (q31_t)0x6cffcc0f, + (q31_t)0x6cf29cdc, (q31_t)0x6ce56975, (q31_t)0x6cd831dc, (q31_t)0x6ccaf610, + (q31_t)0x6cbdb613, (q31_t)0x6cb071e4, (q31_t)0x6ca32985, (q31_t)0x6c95dcf6, + (q31_t)0x6c888c36, (q31_t)0x6c7b3748, (q31_t)0x6c6dde2b, (q31_t)0x6c6080e0, + (q31_t)0x6c531f67, (q31_t)0x6c45b9c1, (q31_t)0x6c384fef, (q31_t)0x6c2ae1f0, + (q31_t)0x6c1d6fc6, (q31_t)0x6c0ff971, (q31_t)0x6c027ef1, (q31_t)0x6bf50047, + (q31_t)0x6be77d74, (q31_t)0x6bd9f677, (q31_t)0x6bcc6b53, (q31_t)0x6bbedc06, + (q31_t)0x6bb14892, (q31_t)0x6ba3b0f7, (q31_t)0x6b961536, (q31_t)0x6b88754f, + (q31_t)0x6b7ad142, (q31_t)0x6b6d2911, (q31_t)0x6b5f7cbc, (q31_t)0x6b51cc42, + (q31_t)0x6b4417a6, (q31_t)0x6b365ee7, (q31_t)0x6b28a206, (q31_t)0x6b1ae103, + (q31_t)0x6b0d1bdf, (q31_t)0x6aff529a, (q31_t)0x6af18536, (q31_t)0x6ae3b3b2, + (q31_t)0x6ad5de0f, (q31_t)0x6ac8044e, (q31_t)0x6aba266e, (q31_t)0x6aac4472, + (q31_t)0x6a9e5e58, (q31_t)0x6a907423, (q31_t)0x6a8285d1, (q31_t)0x6a749365, + (q31_t)0x6a669cdd, (q31_t)0x6a58a23c, (q31_t)0x6a4aa381, (q31_t)0x6a3ca0ad, + (q31_t)0x6a2e99c0, (q31_t)0x6a208ebb, (q31_t)0x6a127f9f, (q31_t)0x6a046c6c, + (q31_t)0x69f65523, (q31_t)0x69e839c4, (q31_t)0x69da1a50, (q31_t)0x69cbf6c7, + (q31_t)0x69bdcf29, (q31_t)0x69afa378, (q31_t)0x69a173b5, (q31_t)0x69933fde, + (q31_t)0x698507f6, (q31_t)0x6976cbfc, (q31_t)0x69688bf1, (q31_t)0x695a47d6, + (q31_t)0x694bffab, (q31_t)0x693db371, (q31_t)0x692f6328, (q31_t)0x69210ed1, + (q31_t)0x6912b66c, (q31_t)0x690459fb, (q31_t)0x68f5f97d, (q31_t)0x68e794f3, + (q31_t)0x68d92c5d, (q31_t)0x68cabfbd, (q31_t)0x68bc4f13, (q31_t)0x68adda5f, + (q31_t)0x689f61a1, (q31_t)0x6890e4dc, (q31_t)0x6882640e, (q31_t)0x6873df38, + (q31_t)0x6865565c, (q31_t)0x6856c979, (q31_t)0x68483891, (q31_t)0x6839a3a4, + (q31_t)0x682b0ab1, (q31_t)0x681c6dbb, (q31_t)0x680dccc1, (q31_t)0x67ff27c4, + (q31_t)0x67f07ec5, (q31_t)0x67e1d1c4, (q31_t)0x67d320c1, (q31_t)0x67c46bbe, + (q31_t)0x67b5b2bb, (q31_t)0x67a6f5b8, (q31_t)0x679834b6, (q31_t)0x67896fb6, + (q31_t)0x677aa6b8, (q31_t)0x676bd9bd, (q31_t)0x675d08c4, (q31_t)0x674e33d0, + (q31_t)0x673f5ae0, (q31_t)0x67307df5, (q31_t)0x67219d10, (q31_t)0x6712b831, + (q31_t)0x6703cf58, (q31_t)0x66f4e287, (q31_t)0x66e5f1be, (q31_t)0x66d6fcfd, + (q31_t)0x66c80445, (q31_t)0x66b90797, (q31_t)0x66aa06f3, (q31_t)0x669b0259, + (q31_t)0x668bf9cb, (q31_t)0x667ced49, (q31_t)0x666ddcd3, (q31_t)0x665ec86b, + (q31_t)0x664fb010, (q31_t)0x664093c3, (q31_t)0x66317385, (q31_t)0x66224f56, + (q31_t)0x66132738, (q31_t)0x6603fb2a, (q31_t)0x65f4cb2d, (q31_t)0x65e59742, + (q31_t)0x65d65f69, (q31_t)0x65c723a3, (q31_t)0x65b7e3f1, (q31_t)0x65a8a052, + (q31_t)0x659958c9, (q31_t)0x658a0d54, (q31_t)0x657abdf6, (q31_t)0x656b6aae, + (q31_t)0x655c137d, (q31_t)0x654cb863, (q31_t)0x653d5962, (q31_t)0x652df679, + (q31_t)0x651e8faa, (q31_t)0x650f24f5, (q31_t)0x64ffb65b, (q31_t)0x64f043dc, + (q31_t)0x64e0cd78, (q31_t)0x64d15331, (q31_t)0x64c1d507, (q31_t)0x64b252fa, + (q31_t)0x64a2cd0c, (q31_t)0x6493433c, (q31_t)0x6483b58c, (q31_t)0x647423fb, + (q31_t)0x64648e8c, (q31_t)0x6454f53d, (q31_t)0x64455810, (q31_t)0x6435b706, + (q31_t)0x6426121e, (q31_t)0x6416695a, (q31_t)0x6406bcba, (q31_t)0x63f70c3f, + (q31_t)0x63e757ea, (q31_t)0x63d79fba, (q31_t)0x63c7e3b1, (q31_t)0x63b823cf, + (q31_t)0x63a86015, (q31_t)0x63989884, (q31_t)0x6388cd1b, (q31_t)0x6378fddc, + (q31_t)0x63692ac7, (q31_t)0x635953dd, (q31_t)0x6349791f, (q31_t)0x63399a8d, + (q31_t)0x6329b827, (q31_t)0x6319d1ef, (q31_t)0x6309e7e4, (q31_t)0x62f9fa09, + (q31_t)0x62ea085c, (q31_t)0x62da12df, (q31_t)0x62ca1992, (q31_t)0x62ba1c77, + (q31_t)0x62aa1b8d, (q31_t)0x629a16d5, (q31_t)0x628a0e50, (q31_t)0x627a01fe, + (q31_t)0x6269f1e1, (q31_t)0x6259ddf8, (q31_t)0x6249c645, (q31_t)0x6239aac7, + (q31_t)0x62298b81, (q31_t)0x62196871, (q31_t)0x62094199, (q31_t)0x61f916f9, + (q31_t)0x61e8e893, (q31_t)0x61d8b666, (q31_t)0x61c88074, (q31_t)0x61b846bc, + (q31_t)0x61a80940, (q31_t)0x6197c800, (q31_t)0x618782fd, (q31_t)0x61773a37, + (q31_t)0x6166edb0, (q31_t)0x61569d67, (q31_t)0x6146495d, (q31_t)0x6135f193, + (q31_t)0x6125960a, (q31_t)0x611536c2, (q31_t)0x6104d3bc, (q31_t)0x60f46cf9, + (q31_t)0x60e40278, (q31_t)0x60d3943b, (q31_t)0x60c32243, (q31_t)0x60b2ac8f, + (q31_t)0x60a23322, (q31_t)0x6091b5fa, (q31_t)0x60813519, (q31_t)0x6070b080, + (q31_t)0x6060282f, (q31_t)0x604f9c27, (q31_t)0x603f0c69, (q31_t)0x602e78f4, + (q31_t)0x601de1ca, (q31_t)0x600d46ec, (q31_t)0x5ffca859, (q31_t)0x5fec0613, + (q31_t)0x5fdb601b, (q31_t)0x5fcab670, (q31_t)0x5fba0914, (q31_t)0x5fa95807, + (q31_t)0x5f98a34a, (q31_t)0x5f87eade, (q31_t)0x5f772ec2, (q31_t)0x5f666ef9, + (q31_t)0x5f55ab82, (q31_t)0x5f44e45e, (q31_t)0x5f34198e, (q31_t)0x5f234b12, + (q31_t)0x5f1278eb, (q31_t)0x5f01a31a, (q31_t)0x5ef0c99f, (q31_t)0x5edfec7b, + (q31_t)0x5ecf0baf, (q31_t)0x5ebe273b, (q31_t)0x5ead3f1f, (q31_t)0x5e9c535e, + (q31_t)0x5e8b63f7, (q31_t)0x5e7a70ea, (q31_t)0x5e697a39, (q31_t)0x5e587fe5, + (q31_t)0x5e4781ed, (q31_t)0x5e368053, (q31_t)0x5e257b17, (q31_t)0x5e147239, + (q31_t)0x5e0365bb, (q31_t)0x5df2559e, (q31_t)0x5de141e1, (q31_t)0x5dd02a85, + (q31_t)0x5dbf0f8c, (q31_t)0x5dadf0f5, (q31_t)0x5d9ccec2, (q31_t)0x5d8ba8f3, + (q31_t)0x5d7a7f88, (q31_t)0x5d695283, (q31_t)0x5d5821e4, (q31_t)0x5d46edac, + (q31_t)0x5d35b5db, (q31_t)0x5d247a72, (q31_t)0x5d133b72, (q31_t)0x5d01f8dc, + (q31_t)0x5cf0b2af, (q31_t)0x5cdf68ed, (q31_t)0x5cce1b97, (q31_t)0x5cbccaac, + (q31_t)0x5cab762f, (q31_t)0x5c9a1e1e, (q31_t)0x5c88c27c, (q31_t)0x5c776348, + (q31_t)0x5c660084, (q31_t)0x5c549a30, (q31_t)0x5c43304d, (q31_t)0x5c31c2db, + (q31_t)0x5c2051db, (q31_t)0x5c0edd4e, (q31_t)0x5bfd6534, (q31_t)0x5bebe98e, + (q31_t)0x5bda6a5d, (q31_t)0x5bc8e7a2, (q31_t)0x5bb7615d, (q31_t)0x5ba5d78e, + (q31_t)0x5b944a37, (q31_t)0x5b82b958, (q31_t)0x5b7124f2, (q31_t)0x5b5f8d06, + (q31_t)0x5b4df193, (q31_t)0x5b3c529c, (q31_t)0x5b2ab020, (q31_t)0x5b190a20, + (q31_t)0x5b07609d, (q31_t)0x5af5b398, (q31_t)0x5ae40311, (q31_t)0x5ad24f09, + (q31_t)0x5ac09781, (q31_t)0x5aaedc78, (q31_t)0x5a9d1df1, (q31_t)0x5a8b5bec, + (q31_t)0x5a799669, (q31_t)0x5a67cd69, (q31_t)0x5a5600ec, (q31_t)0x5a4430f5, + (q31_t)0x5a325d82, (q31_t)0x5a208695, (q31_t)0x5a0eac2e, (q31_t)0x59fcce4f, + (q31_t)0x59eaecf8, (q31_t)0x59d90829, (q31_t)0x59c71fe3, (q31_t)0x59b53427, + (q31_t)0x59a344f6, (q31_t)0x59915250, (q31_t)0x597f5c36, (q31_t)0x596d62a9, + (q31_t)0x595b65aa, (q31_t)0x59496538, (q31_t)0x59376155, (q31_t)0x59255a02, + (q31_t)0x59134f3e, (q31_t)0x5901410c, (q31_t)0x58ef2f6b, (q31_t)0x58dd1a5d, + (q31_t)0x58cb01e1, (q31_t)0x58b8e5f9, (q31_t)0x58a6c6a5, (q31_t)0x5894a3e7, + (q31_t)0x58827dbe, (q31_t)0x5870542c, (q31_t)0x585e2730, (q31_t)0x584bf6cd, + (q31_t)0x5839c302, (q31_t)0x58278bd1, (q31_t)0x58155139, (q31_t)0x5803133c, + (q31_t)0x57f0d1da, (q31_t)0x57de8d15, (q31_t)0x57cc44ec, (q31_t)0x57b9f960, + (q31_t)0x57a7aa73, (q31_t)0x57955825, (q31_t)0x57830276, (q31_t)0x5770a968, + (q31_t)0x575e4cfa, (q31_t)0x574bed2f, (q31_t)0x57398a05, (q31_t)0x5727237f, + (q31_t)0x5714b99d, (q31_t)0x57024c5f, (q31_t)0x56efdbc7, (q31_t)0x56dd67d4, + (q31_t)0x56caf088, (q31_t)0x56b875e4, (q31_t)0x56a5f7e7, (q31_t)0x56937694, + (q31_t)0x5680f1ea, (q31_t)0x566e69ea, (q31_t)0x565bde95, (q31_t)0x56494fec, + (q31_t)0x5636bdef, (q31_t)0x5624289f, (q31_t)0x56118ffe, (q31_t)0x55fef40a, + (q31_t)0x55ec54c6, (q31_t)0x55d9b232, (q31_t)0x55c70c4f, (q31_t)0x55b4631d, + (q31_t)0x55a1b69d, (q31_t)0x558f06d0, (q31_t)0x557c53b6, (q31_t)0x55699d51, + (q31_t)0x5556e3a1, (q31_t)0x554426a7, (q31_t)0x55316663, (q31_t)0x551ea2d6, + (q31_t)0x550bdc01, (q31_t)0x54f911e5, (q31_t)0x54e64482, (q31_t)0x54d373d9, + (q31_t)0x54c09feb, (q31_t)0x54adc8b8, (q31_t)0x549aee42, (q31_t)0x54881089, + (q31_t)0x54752f8d, (q31_t)0x54624b50, (q31_t)0x544f63d2, (q31_t)0x543c7914, + (q31_t)0x54298b17, (q31_t)0x541699db, (q31_t)0x5403a561, (q31_t)0x53f0adaa, + (q31_t)0x53ddb2b6, (q31_t)0x53cab486, (q31_t)0x53b7b31c, (q31_t)0x53a4ae77, + (q31_t)0x5391a699, (q31_t)0x537e9b82, (q31_t)0x536b8d33, (q31_t)0x53587bad, + (q31_t)0x534566f0, (q31_t)0x53324efd, (q31_t)0x531f33d5, (q31_t)0x530c1579, + (q31_t)0x52f8f3e9, (q31_t)0x52e5cf27, (q31_t)0x52d2a732, (q31_t)0x52bf7c0b, + (q31_t)0x52ac4db4, (q31_t)0x52991c2d, (q31_t)0x5285e777, (q31_t)0x5272af92, + (q31_t)0x525f7480, (q31_t)0x524c3640, (q31_t)0x5238f4d4, (q31_t)0x5225b03d, + (q31_t)0x5212687b, (q31_t)0x51ff1d8f, (q31_t)0x51ebcf7a, (q31_t)0x51d87e3c, + (q31_t)0x51c529d7, (q31_t)0x51b1d24a, (q31_t)0x519e7797, (q31_t)0x518b19bf, + (q31_t)0x5177b8c2, (q31_t)0x516454a0, (q31_t)0x5150ed5c, (q31_t)0x513d82f4, + (q31_t)0x512a156b, (q31_t)0x5116a4c1, (q31_t)0x510330f7, (q31_t)0x50efba0d, + (q31_t)0x50dc4005, (q31_t)0x50c8c2de, (q31_t)0x50b5429a, (q31_t)0x50a1bf39, + (q31_t)0x508e38bd, (q31_t)0x507aaf25, (q31_t)0x50672273, (q31_t)0x505392a8, + (q31_t)0x503fffc4, (q31_t)0x502c69c8, (q31_t)0x5018d0b4, (q31_t)0x5005348a, + (q31_t)0x4ff1954b, (q31_t)0x4fddf2f6, (q31_t)0x4fca4d8d, (q31_t)0x4fb6a510, + (q31_t)0x4fa2f981, (q31_t)0x4f8f4ae0, (q31_t)0x4f7b992d, (q31_t)0x4f67e46a, + (q31_t)0x4f542c98, (q31_t)0x4f4071b6, (q31_t)0x4f2cb3c7, (q31_t)0x4f18f2c9, + (q31_t)0x4f052ec0, (q31_t)0x4ef167aa, (q31_t)0x4edd9d89, (q31_t)0x4ec9d05e, + (q31_t)0x4eb60029, (q31_t)0x4ea22ceb, (q31_t)0x4e8e56a5, (q31_t)0x4e7a7d58, + (q31_t)0x4e66a105, (q31_t)0x4e52c1ab, (q31_t)0x4e3edf4d, (q31_t)0x4e2af9ea, + (q31_t)0x4e171184, (q31_t)0x4e03261b, (q31_t)0x4def37b0, (q31_t)0x4ddb4644, + (q31_t)0x4dc751d8, (q31_t)0x4db35a6c, (q31_t)0x4d9f6001, (q31_t)0x4d8b6298, + (q31_t)0x4d776231, (q31_t)0x4d635ece, (q31_t)0x4d4f5870, (q31_t)0x4d3b4f16, + (q31_t)0x4d2742c2, (q31_t)0x4d133374, (q31_t)0x4cff212e, (q31_t)0x4ceb0bf0, + (q31_t)0x4cd6f3bb, (q31_t)0x4cc2d88f, (q31_t)0x4caeba6e, (q31_t)0x4c9a9958, + (q31_t)0x4c86754e, (q31_t)0x4c724e50, (q31_t)0x4c5e2460, (q31_t)0x4c49f77f, + (q31_t)0x4c35c7ac, (q31_t)0x4c2194e9, (q31_t)0x4c0d5f37, (q31_t)0x4bf92697, + (q31_t)0x4be4eb08, (q31_t)0x4bd0ac8d, (q31_t)0x4bbc6b25, (q31_t)0x4ba826d1, + (q31_t)0x4b93df93, (q31_t)0x4b7f956b, (q31_t)0x4b6b485a, (q31_t)0x4b56f861, + (q31_t)0x4b42a580, (q31_t)0x4b2e4fb8, (q31_t)0x4b19f70a, (q31_t)0x4b059b77, + (q31_t)0x4af13d00, (q31_t)0x4adcdba5, (q31_t)0x4ac87767, (q31_t)0x4ab41046, + (q31_t)0x4a9fa645, (q31_t)0x4a8b3963, (q31_t)0x4a76c9a2, (q31_t)0x4a625701, + (q31_t)0x4a4de182, (q31_t)0x4a396926, (q31_t)0x4a24edee, (q31_t)0x4a106fda, + (q31_t)0x49fbeeea, (q31_t)0x49e76b21, (q31_t)0x49d2e47e, (q31_t)0x49be5b02, + (q31_t)0x49a9ceaf, (q31_t)0x49953f84, (q31_t)0x4980ad84, (q31_t)0x496c18ae, + (q31_t)0x49578103, (q31_t)0x4942e684, (q31_t)0x492e4933, (q31_t)0x4919a90f, + (q31_t)0x4905061a, (q31_t)0x48f06054, (q31_t)0x48dbb7be, (q31_t)0x48c70c59, + (q31_t)0x48b25e25, (q31_t)0x489dad25, (q31_t)0x4888f957, (q31_t)0x487442be, + (q31_t)0x485f8959, (q31_t)0x484acd2a, (q31_t)0x48360e32, (q31_t)0x48214c71, + (q31_t)0x480c87e8, (q31_t)0x47f7c099, (q31_t)0x47e2f682, (q31_t)0x47ce29a7, + (q31_t)0x47b95a06, (q31_t)0x47a487a2, (q31_t)0x478fb27b, (q31_t)0x477ada91, + (q31_t)0x4765ffe6, (q31_t)0x4751227a, (q31_t)0x473c424e, (q31_t)0x47275f63, + (q31_t)0x471279ba, (q31_t)0x46fd9154, (q31_t)0x46e8a631, (q31_t)0x46d3b852, + (q31_t)0x46bec7b8, (q31_t)0x46a9d464, (q31_t)0x4694de56, (q31_t)0x467fe590, + (q31_t)0x466aea12, (q31_t)0x4655ebdd, (q31_t)0x4640eaf2, (q31_t)0x462be751, + (q31_t)0x4616e0fc, (q31_t)0x4601d7f3, (q31_t)0x45eccc37, (q31_t)0x45d7bdc9, + (q31_t)0x45c2acaa, (q31_t)0x45ad98da, (q31_t)0x4598825a, (q31_t)0x4583692c, + (q31_t)0x456e4d4f, (q31_t)0x45592ec6, (q31_t)0x45440d90, (q31_t)0x452ee9ae, + (q31_t)0x4519c321, (q31_t)0x450499eb, (q31_t)0x44ef6e0b, (q31_t)0x44da3f83, + (q31_t)0x44c50e53, (q31_t)0x44afda7d, (q31_t)0x449aa400, (q31_t)0x44856adf, + (q31_t)0x44702f19, (q31_t)0x445af0b0, (q31_t)0x4445afa4, (q31_t)0x44306bf6, + (q31_t)0x441b25a8, (q31_t)0x4405dcb9, (q31_t)0x43f0912b, (q31_t)0x43db42fe, + (q31_t)0x43c5f234, (q31_t)0x43b09ecc, (q31_t)0x439b48c9, (q31_t)0x4385f02a, + (q31_t)0x437094f1, (q31_t)0x435b371f, (q31_t)0x4345d6b3, (q31_t)0x433073b0, + (q31_t)0x431b0e15, (q31_t)0x4305a5e5, (q31_t)0x42f03b1e, (q31_t)0x42dacdc3, + (q31_t)0x42c55dd4, (q31_t)0x42afeb53, (q31_t)0x429a763f, (q31_t)0x4284fe99, + (q31_t)0x426f8463, (q31_t)0x425a079e, (q31_t)0x42448849, (q31_t)0x422f0667, + (q31_t)0x421981f7, (q31_t)0x4203fafb, (q31_t)0x41ee7174, (q31_t)0x41d8e561, + (q31_t)0x41c356c5, (q31_t)0x41adc5a0, (q31_t)0x419831f3, (q31_t)0x41829bbe, + (q31_t)0x416d0302, (q31_t)0x415767c1, (q31_t)0x4141c9fb, (q31_t)0x412c29b1, + (q31_t)0x411686e4, (q31_t)0x4100e194, (q31_t)0x40eb39c3, (q31_t)0x40d58f71, + (q31_t)0x40bfe29f, (q31_t)0x40aa334e, (q31_t)0x4094817f, (q31_t)0x407ecd32, + (q31_t)0x40691669, (q31_t)0x40535d24, (q31_t)0x403da165, (q31_t)0x4027e32b, + (q31_t)0x40122278, (q31_t)0x3ffc5f4d, (q31_t)0x3fe699aa, (q31_t)0x3fd0d191, + (q31_t)0x3fbb0702, (q31_t)0x3fa539fd, (q31_t)0x3f8f6a85, (q31_t)0x3f799899, + (q31_t)0x3f63c43b, (q31_t)0x3f4ded6b, (q31_t)0x3f38142a, (q31_t)0x3f22387a, + (q31_t)0x3f0c5a5a, (q31_t)0x3ef679cc, (q31_t)0x3ee096d1, (q31_t)0x3ecab169, + (q31_t)0x3eb4c995, (q31_t)0x3e9edf57, (q31_t)0x3e88f2ae, (q31_t)0x3e73039d, + (q31_t)0x3e5d1222, (q31_t)0x3e471e41, (q31_t)0x3e3127f9, (q31_t)0x3e1b2f4a, + (q31_t)0x3e053437, (q31_t)0x3def36c0, (q31_t)0x3dd936e6, (q31_t)0x3dc334a9, + (q31_t)0x3dad300b, (q31_t)0x3d97290b, (q31_t)0x3d811fac, (q31_t)0x3d6b13ee, + (q31_t)0x3d5505d2, (q31_t)0x3d3ef559, (q31_t)0x3d28e282, (q31_t)0x3d12cd51, + (q31_t)0x3cfcb5c4, (q31_t)0x3ce69bde, (q31_t)0x3cd07f9f, (q31_t)0x3cba6107, + (q31_t)0x3ca44018, (q31_t)0x3c8e1cd3, (q31_t)0x3c77f737, (q31_t)0x3c61cf48, + (q31_t)0x3c4ba504, (q31_t)0x3c35786d, (q31_t)0x3c1f4983, (q31_t)0x3c091849, + (q31_t)0x3bf2e4be, (q31_t)0x3bdcaee3, (q31_t)0x3bc676b9, (q31_t)0x3bb03c42, + (q31_t)0x3b99ff7d, (q31_t)0x3b83c06c, (q31_t)0x3b6d7f10, (q31_t)0x3b573b69, + (q31_t)0x3b40f579, (q31_t)0x3b2aad3f, (q31_t)0x3b1462be, (q31_t)0x3afe15f6, + (q31_t)0x3ae7c6e7, (q31_t)0x3ad17593, (q31_t)0x3abb21fb, (q31_t)0x3aa4cc1e, + (q31_t)0x3a8e7400, (q31_t)0x3a78199f, (q31_t)0x3a61bcfd, (q31_t)0x3a4b5e1b, + (q31_t)0x3a34fcf9, (q31_t)0x3a1e9999, (q31_t)0x3a0833fc, (q31_t)0x39f1cc21, + (q31_t)0x39db620b, (q31_t)0x39c4f5ba, (q31_t)0x39ae872f, (q31_t)0x3998166a, + (q31_t)0x3981a36d, (q31_t)0x396b2e38, (q31_t)0x3954b6cd, (q31_t)0x393e3d2c, + (q31_t)0x3927c155, (q31_t)0x3911434b, (q31_t)0x38fac30e, (q31_t)0x38e4409e, + (q31_t)0x38cdbbfc, (q31_t)0x38b7352a, (q31_t)0x38a0ac29, (q31_t)0x388a20f8, + (q31_t)0x38739399, (q31_t)0x385d040d, (q31_t)0x38467255, (q31_t)0x382fde72, + (q31_t)0x38194864, (q31_t)0x3802b02c, (q31_t)0x37ec15cb, (q31_t)0x37d57943, + (q31_t)0x37beda93, (q31_t)0x37a839be, (q31_t)0x379196c3, (q31_t)0x377af1a3, + (q31_t)0x37644a60, (q31_t)0x374da0fa, (q31_t)0x3736f573, (q31_t)0x372047ca, + (q31_t)0x37099802, (q31_t)0x36f2e61a, (q31_t)0x36dc3214, (q31_t)0x36c57bf0, + (q31_t)0x36aec3b0, (q31_t)0x36980954, (q31_t)0x36814cde, (q31_t)0x366a8e4d, + (q31_t)0x3653cda3, (q31_t)0x363d0ae2, (q31_t)0x36264609, (q31_t)0x360f7f19, + (q31_t)0x35f8b614, (q31_t)0x35e1eafa, (q31_t)0x35cb1dcc, (q31_t)0x35b44e8c, + (q31_t)0x359d7d39, (q31_t)0x3586a9d5, (q31_t)0x356fd461, (q31_t)0x3558fcde, + (q31_t)0x3542234c, (q31_t)0x352b47ad, (q31_t)0x35146a00, (q31_t)0x34fd8a48, + (q31_t)0x34e6a885, (q31_t)0x34cfc4b7, (q31_t)0x34b8dee1, (q31_t)0x34a1f702, + (q31_t)0x348b0d1c, (q31_t)0x3474212f, (q31_t)0x345d333c, (q31_t)0x34464345, + (q31_t)0x342f5149, (q31_t)0x34185d4b, (q31_t)0x3401674a, (q31_t)0x33ea6f48, + (q31_t)0x33d37546, (q31_t)0x33bc7944, (q31_t)0x33a57b44, (q31_t)0x338e7b46, + (q31_t)0x3377794b, (q31_t)0x33607554, (q31_t)0x33496f62, (q31_t)0x33326776, + (q31_t)0x331b5d91, (q31_t)0x330451b3, (q31_t)0x32ed43de, (q31_t)0x32d63412, + (q31_t)0x32bf2250, (q31_t)0x32a80e99, (q31_t)0x3290f8ef, (q31_t)0x3279e151, + (q31_t)0x3262c7c1, (q31_t)0x324bac40, (q31_t)0x32348ecf, (q31_t)0x321d6f6e, + (q31_t)0x32064e1e, (q31_t)0x31ef2ae1, (q31_t)0x31d805b7, (q31_t)0x31c0dea1, + (q31_t)0x31a9b5a0, (q31_t)0x31928ab4, (q31_t)0x317b5de0, (q31_t)0x31642f23, + (q31_t)0x314cfe7f, (q31_t)0x3135cbf4, (q31_t)0x311e9783, (q31_t)0x3107612e, + (q31_t)0x30f028f4, (q31_t)0x30d8eed8, (q31_t)0x30c1b2da, (q31_t)0x30aa74fa, + (q31_t)0x3093353a, (q31_t)0x307bf39b, (q31_t)0x3064b01d, (q31_t)0x304d6ac1, + (q31_t)0x30362389, (q31_t)0x301eda75, (q31_t)0x30078f86, (q31_t)0x2ff042bd, + (q31_t)0x2fd8f41b, (q31_t)0x2fc1a3a0, (q31_t)0x2faa514f, (q31_t)0x2f92fd26, + (q31_t)0x2f7ba729, (q31_t)0x2f644f56, (q31_t)0x2f4cf5b0, (q31_t)0x2f359a37, + (q31_t)0x2f1e3ced, (q31_t)0x2f06ddd1, (q31_t)0x2eef7ce5, (q31_t)0x2ed81a29, + (q31_t)0x2ec0b5a0, (q31_t)0x2ea94f49, (q31_t)0x2e91e725, (q31_t)0x2e7a7d36, + (q31_t)0x2e63117c, (q31_t)0x2e4ba3f8, (q31_t)0x2e3434ac, (q31_t)0x2e1cc397, + (q31_t)0x2e0550bb, (q31_t)0x2deddc19, (q31_t)0x2dd665b2, (q31_t)0x2dbeed86, + (q31_t)0x2da77397, (q31_t)0x2d8ff7e5, (q31_t)0x2d787a72, (q31_t)0x2d60fb3e, + (q31_t)0x2d497a4a, (q31_t)0x2d31f797, (q31_t)0x2d1a7325, (q31_t)0x2d02ecf7, + (q31_t)0x2ceb650d, (q31_t)0x2cd3db67, (q31_t)0x2cbc5006, (q31_t)0x2ca4c2ed, + (q31_t)0x2c8d341a, (q31_t)0x2c75a390, (q31_t)0x2c5e114f, (q31_t)0x2c467d58, + (q31_t)0x2c2ee7ad, (q31_t)0x2c17504d, (q31_t)0x2bffb73a, (q31_t)0x2be81c74, + (q31_t)0x2bd07ffe, (q31_t)0x2bb8e1d7, (q31_t)0x2ba14200, (q31_t)0x2b89a07b, + (q31_t)0x2b71fd48, (q31_t)0x2b5a5868, (q31_t)0x2b42b1dd, (q31_t)0x2b2b09a6, + (q31_t)0x2b135fc6, (q31_t)0x2afbb43c, (q31_t)0x2ae4070a, (q31_t)0x2acc5831, + (q31_t)0x2ab4a7b1, (q31_t)0x2a9cf58c, (q31_t)0x2a8541c3, (q31_t)0x2a6d8c55, + (q31_t)0x2a55d545, (q31_t)0x2a3e1c93, (q31_t)0x2a266240, (q31_t)0x2a0ea64d, + (q31_t)0x29f6e8bb, (q31_t)0x29df298b, (q31_t)0x29c768be, (q31_t)0x29afa654, + (q31_t)0x2997e24f, (q31_t)0x29801caf, (q31_t)0x29685576, (q31_t)0x29508ca4, + (q31_t)0x2938c23a, (q31_t)0x2920f63a, (q31_t)0x290928a3, (q31_t)0x28f15978, + (q31_t)0x28d988b8, (q31_t)0x28c1b666, (q31_t)0x28a9e281, (q31_t)0x28920d0a, + (q31_t)0x287a3604, (q31_t)0x28625d6d, (q31_t)0x284a8349, (q31_t)0x2832a796, + (q31_t)0x281aca57, (q31_t)0x2802eb8c, (q31_t)0x27eb0b36, (q31_t)0x27d32956, + (q31_t)0x27bb45ed, (q31_t)0x27a360fc, (q31_t)0x278b7a84, (q31_t)0x27739285, + (q31_t)0x275ba901, (q31_t)0x2743bdf9, (q31_t)0x272bd16d, (q31_t)0x2713e35f, + (q31_t)0x26fbf3ce, (q31_t)0x26e402bd, (q31_t)0x26cc102d, (q31_t)0x26b41c1d, + (q31_t)0x269c268f, (q31_t)0x26842f84, (q31_t)0x266c36fe, (q31_t)0x26543cfb, + (q31_t)0x263c417f, (q31_t)0x26244489, (q31_t)0x260c461b, (q31_t)0x25f44635, + (q31_t)0x25dc44d9, (q31_t)0x25c44207, (q31_t)0x25ac3dc0, (q31_t)0x25943806, + (q31_t)0x257c30d8, (q31_t)0x25642839, (q31_t)0x254c1e28, (q31_t)0x253412a8, + (q31_t)0x251c05b8, (q31_t)0x2503f75a, (q31_t)0x24ebe78f, (q31_t)0x24d3d657, + (q31_t)0x24bbc3b4, (q31_t)0x24a3afa6, (q31_t)0x248b9a2f, (q31_t)0x2473834f, + (q31_t)0x245b6b07, (q31_t)0x24435158, (q31_t)0x242b3644, (q31_t)0x241319ca, + (q31_t)0x23fafbec, (q31_t)0x23e2dcac, (q31_t)0x23cabc09, (q31_t)0x23b29a05, + (q31_t)0x239a76a0, (q31_t)0x238251dd, (q31_t)0x236a2bba, (q31_t)0x2352043b, + (q31_t)0x2339db5e, (q31_t)0x2321b126, (q31_t)0x23098593, (q31_t)0x22f158a7, + (q31_t)0x22d92a61, (q31_t)0x22c0fac4, (q31_t)0x22a8c9cf, (q31_t)0x22909785, + (q31_t)0x227863e5, (q31_t)0x22602ef1, (q31_t)0x2247f8aa, (q31_t)0x222fc111, + (q31_t)0x22178826, (q31_t)0x21ff4dea, (q31_t)0x21e71260, (q31_t)0x21ced586, + (q31_t)0x21b6975f, (q31_t)0x219e57eb, (q31_t)0x2186172b, (q31_t)0x216dd521, + (q31_t)0x215591cc, (q31_t)0x213d4d2f, (q31_t)0x21250749, (q31_t)0x210cc01d, + (q31_t)0x20f477aa, (q31_t)0x20dc2df2, (q31_t)0x20c3e2f5, (q31_t)0x20ab96b5, + (q31_t)0x20934933, (q31_t)0x207afa6f, (q31_t)0x2062aa6b, (q31_t)0x204a5927, + (q31_t)0x203206a4, (q31_t)0x2019b2e4, (q31_t)0x20015de7, (q31_t)0x1fe907ae, + (q31_t)0x1fd0b03a, (q31_t)0x1fb8578b, (q31_t)0x1f9ffda4, (q31_t)0x1f87a285, + (q31_t)0x1f6f462f, (q31_t)0x1f56e8a2, (q31_t)0x1f3e89e0, (q31_t)0x1f2629ea, + (q31_t)0x1f0dc8c0, (q31_t)0x1ef56664, (q31_t)0x1edd02d6, (q31_t)0x1ec49e17, + (q31_t)0x1eac3829, (q31_t)0x1e93d10c, (q31_t)0x1e7b68c2, (q31_t)0x1e62ff4a, + (q31_t)0x1e4a94a7, (q31_t)0x1e3228d9, (q31_t)0x1e19bbe0, (q31_t)0x1e014dbf, + (q31_t)0x1de8de75, (q31_t)0x1dd06e04, (q31_t)0x1db7fc6d, (q31_t)0x1d9f89b1, + (q31_t)0x1d8715d0, (q31_t)0x1d6ea0cc, (q31_t)0x1d562aa6, (q31_t)0x1d3db35e, + (q31_t)0x1d253af5, (q31_t)0x1d0cc16c, (q31_t)0x1cf446c5, (q31_t)0x1cdbcb00, + (q31_t)0x1cc34e1f, (q31_t)0x1caad021, (q31_t)0x1c925109, (q31_t)0x1c79d0d6, + (q31_t)0x1c614f8b, (q31_t)0x1c48cd27, (q31_t)0x1c3049ac, (q31_t)0x1c17c51b, + (q31_t)0x1bff3f75, (q31_t)0x1be6b8ba, (q31_t)0x1bce30ec, (q31_t)0x1bb5a80c, + (q31_t)0x1b9d1e1a, (q31_t)0x1b849317, (q31_t)0x1b6c0705, (q31_t)0x1b5379e5, + (q31_t)0x1b3aebb6, (q31_t)0x1b225c7b, (q31_t)0x1b09cc34, (q31_t)0x1af13ae3, + (q31_t)0x1ad8a887, (q31_t)0x1ac01522, (q31_t)0x1aa780b6, (q31_t)0x1a8eeb42, + (q31_t)0x1a7654c8, (q31_t)0x1a5dbd49, (q31_t)0x1a4524c6, (q31_t)0x1a2c8b3f, + (q31_t)0x1a13f0b6, (q31_t)0x19fb552c, (q31_t)0x19e2b8a2, (q31_t)0x19ca1b17, + (q31_t)0x19b17c8f, (q31_t)0x1998dd09, (q31_t)0x19803c86, (q31_t)0x19679b07, + (q31_t)0x194ef88e, (q31_t)0x1936551b, (q31_t)0x191db0af, (q31_t)0x19050b4b, + (q31_t)0x18ec64f0, (q31_t)0x18d3bda0, (q31_t)0x18bb155a, (q31_t)0x18a26c20, + (q31_t)0x1889c1f3, (q31_t)0x187116d4, (q31_t)0x18586ac3, (q31_t)0x183fbdc3, + (q31_t)0x18270fd3, (q31_t)0x180e60f4, (q31_t)0x17f5b129, (q31_t)0x17dd0070, + (q31_t)0x17c44ecd, (q31_t)0x17ab9c3e, (q31_t)0x1792e8c6, (q31_t)0x177a3466, + (q31_t)0x17617f1d, (q31_t)0x1748c8ee, (q31_t)0x173011d9, (q31_t)0x171759df, + (q31_t)0x16fea102, (q31_t)0x16e5e741, (q31_t)0x16cd2c9f, (q31_t)0x16b4711b, + (q31_t)0x169bb4b7, (q31_t)0x1682f774, (q31_t)0x166a3953, (q31_t)0x16517a55, + (q31_t)0x1638ba7a, (q31_t)0x161ff9c4, (q31_t)0x16073834, (q31_t)0x15ee75cb, + (q31_t)0x15d5b288, (q31_t)0x15bcee6f, (q31_t)0x15a4297f, (q31_t)0x158b63b9, + (q31_t)0x15729d1f, (q31_t)0x1559d5b1, (q31_t)0x15410d70, (q31_t)0x1528445d, + (q31_t)0x150f7a7a, (q31_t)0x14f6afc7, (q31_t)0x14dde445, (q31_t)0x14c517f4, + (q31_t)0x14ac4ad7, (q31_t)0x14937cee, (q31_t)0x147aae3a, (q31_t)0x1461debc, + (q31_t)0x14490e74, (q31_t)0x14303d65, (q31_t)0x14176b8e, (q31_t)0x13fe98f1, + (q31_t)0x13e5c58e, (q31_t)0x13ccf167, (q31_t)0x13b41c7d, (q31_t)0x139b46d0, + (q31_t)0x13827062, (q31_t)0x13699933, (q31_t)0x1350c144, (q31_t)0x1337e897, + (q31_t)0x131f0f2c, (q31_t)0x13063505, (q31_t)0x12ed5a21, (q31_t)0x12d47e83, + (q31_t)0x12bba22b, (q31_t)0x12a2c51b, (q31_t)0x1289e752, (q31_t)0x127108d2, + (q31_t)0x1258299c, (q31_t)0x123f49b2, (q31_t)0x12266913, (q31_t)0x120d87c1, + (q31_t)0x11f4a5bd, (q31_t)0x11dbc307, (q31_t)0x11c2dfa2, (q31_t)0x11a9fb8d, + (q31_t)0x119116c9, (q31_t)0x11783159, (q31_t)0x115f4b3c, (q31_t)0x11466473, + (q31_t)0x112d7d00, (q31_t)0x111494e4, (q31_t)0x10fbac1e, (q31_t)0x10e2c2b2, + (q31_t)0x10c9d89e, (q31_t)0x10b0ede5, (q31_t)0x10980287, (q31_t)0x107f1686, + (q31_t)0x106629e1, (q31_t)0x104d3c9b, (q31_t)0x10344eb4, (q31_t)0x101b602d, + (q31_t)0x10027107, (q31_t)0xfe98143, (q31_t)0xfd090e1, (q31_t)0xfb79fe4, + (q31_t)0xf9eae4c, (q31_t)0xf85bc19, (q31_t)0xf6cc94e, (q31_t)0xf53d5ea, + (q31_t)0xf3ae1ee, (q31_t)0xf21ed5d, (q31_t)0xf08f836, (q31_t)0xef0027b, + (q31_t)0xed70c2c, (q31_t)0xebe154b, (q31_t)0xea51dd8, (q31_t)0xe8c25d5, + (q31_t)0xe732d42, (q31_t)0xe5a3421, (q31_t)0xe413a72, (q31_t)0xe284036, + (q31_t)0xe0f456f, (q31_t)0xdf64a1c, (q31_t)0xddd4e40, (q31_t)0xdc451dc, + (q31_t)0xdab54ef, (q31_t)0xd92577b, (q31_t)0xd795982, (q31_t)0xd605b03, + (q31_t)0xd475c00, (q31_t)0xd2e5c7b, (q31_t)0xd155c73, (q31_t)0xcfc5bea, + (q31_t)0xce35ae1, (q31_t)0xcca5959, (q31_t)0xcb15752, (q31_t)0xc9854cf, + (q31_t)0xc7f51cf, (q31_t)0xc664e53, (q31_t)0xc4d4a5d, (q31_t)0xc3445ee, + (q31_t)0xc1b4107, (q31_t)0xc023ba7, (q31_t)0xbe935d2, (q31_t)0xbd02f87, + (q31_t)0xbb728c7, (q31_t)0xb9e2193, (q31_t)0xb8519ed, (q31_t)0xb6c11d5, + (q31_t)0xb53094d, (q31_t)0xb3a0055, (q31_t)0xb20f6ee, (q31_t)0xb07ed19, + (q31_t)0xaeee2d7, (q31_t)0xad5d829, (q31_t)0xabccd11, (q31_t)0xaa3c18e, + (q31_t)0xa8ab5a2, (q31_t)0xa71a94f, (q31_t)0xa589c94, (q31_t)0xa3f8f73, + (q31_t)0xa2681ed, (q31_t)0xa0d7403, (q31_t)0x9f465b5, (q31_t)0x9db5706, + (q31_t)0x9c247f5, (q31_t)0x9a93884, (q31_t)0x99028b3, (q31_t)0x9771884, + (q31_t)0x95e07f8, (q31_t)0x944f70f, (q31_t)0x92be5ca, (q31_t)0x912d42c, + (q31_t)0x8f9c233, (q31_t)0x8e0afe2, (q31_t)0x8c79d3a, (q31_t)0x8ae8a3a, + (q31_t)0x89576e5, (q31_t)0x87c633c, (q31_t)0x8634f3e, (q31_t)0x84a3aee, + (q31_t)0x831264c, (q31_t)0x8181159, (q31_t)0x7fefc16, (q31_t)0x7e5e685, + (q31_t)0x7ccd0a5, (q31_t)0x7b3ba78, (q31_t)0x79aa400, (q31_t)0x7818d3c, + (q31_t)0x768762e, (q31_t)0x74f5ed7, (q31_t)0x7364738, (q31_t)0x71d2f52, + (q31_t)0x7041726, (q31_t)0x6eafeb4, (q31_t)0x6d1e5fe, (q31_t)0x6b8cd05, + (q31_t)0x69fb3c9, (q31_t)0x6869a4c, (q31_t)0x66d808f, (q31_t)0x6546692, + (q31_t)0x63b4c57, (q31_t)0x62231de, (q31_t)0x6091729, (q31_t)0x5effc38, + (q31_t)0x5d6e10c, (q31_t)0x5bdc5a7, (q31_t)0x5a4aa09, (q31_t)0x58b8e34, + (q31_t)0x5727228, (q31_t)0x55955e6, (q31_t)0x540396f, (q31_t)0x5271cc4, + (q31_t)0x50dffe7, (q31_t)0x4f4e2d8, (q31_t)0x4dbc597, (q31_t)0x4c2a827, + (q31_t)0x4a98a88, (q31_t)0x4906cbb, (q31_t)0x4774ec1, (q31_t)0x45e309a, + (q31_t)0x4451249, (q31_t)0x42bf3cd, (q31_t)0x412d528, (q31_t)0x3f9b65b, + (q31_t)0x3e09767, (q31_t)0x3c7784d, (q31_t)0x3ae590d, (q31_t)0x39539a9, + (q31_t)0x37c1a22, (q31_t)0x362fa78, (q31_t)0x349daac, (q31_t)0x330bac1, + (q31_t)0x3179ab5, (q31_t)0x2fe7a8c, (q31_t)0x2e55a44, (q31_t)0x2cc39e1, + (q31_t)0x2b31961, (q31_t)0x299f8c7, (q31_t)0x280d813, (q31_t)0x267b747, + (q31_t)0x24e9662, (q31_t)0x2357567, (q31_t)0x21c5457, (q31_t)0x2033331, + (q31_t)0x1ea11f7, (q31_t)0x1d0f0ab, (q31_t)0x1b7cf4d, (q31_t)0x19eaddd, + (q31_t)0x1858c5e, (q31_t)0x16c6ad0, (q31_t)0x1534934, (q31_t)0x13a278a, + (q31_t)0x12105d5, (q31_t)0x107e414, (q31_t)0xeec249, (q31_t)0xd5a075, + (q31_t)0xbc7e99, (q31_t)0xa35cb5, (q31_t)0x8a3acb, (q31_t)0x7118dc, + (q31_t)0x57f6e9, (q31_t)0x3ed4f2, (q31_t)0x25b2f8, (q31_t)0xc90fe}; static const q31_t cos_factorsQ31_8192[8192] = { - (q31_t)0x7ffffff6, (q31_t)0x7fffffa7, (q31_t)0x7fffff09, (q31_t)0x7ffffe1c, (q31_t)0x7ffffce1, (q31_t)0x7ffffb56, (q31_t)0x7ffff97c, (q31_t)0x7ffff753, - (q31_t)0x7ffff4dc, (q31_t)0x7ffff215, (q31_t)0x7fffef00, (q31_t)0x7fffeb9b, (q31_t)0x7fffe7e8, (q31_t)0x7fffe3e5, (q31_t)0x7fffdf94, (q31_t)0x7fffdaf3, - (q31_t)0x7fffd604, (q31_t)0x7fffd0c6, (q31_t)0x7fffcb39, (q31_t)0x7fffc55c, (q31_t)0x7fffbf31, (q31_t)0x7fffb8b7, (q31_t)0x7fffb1ee, (q31_t)0x7fffaad6, - (q31_t)0x7fffa36f, (q31_t)0x7fff9bb9, (q31_t)0x7fff93b4, (q31_t)0x7fff8b61, (q31_t)0x7fff82be, (q31_t)0x7fff79cc, (q31_t)0x7fff708b, (q31_t)0x7fff66fc, - (q31_t)0x7fff5d1d, (q31_t)0x7fff52ef, (q31_t)0x7fff4873, (q31_t)0x7fff3da8, (q31_t)0x7fff328d, (q31_t)0x7fff2724, (q31_t)0x7fff1b6b, (q31_t)0x7fff0f64, - (q31_t)0x7fff030e, (q31_t)0x7ffef669, (q31_t)0x7ffee975, (q31_t)0x7ffedc31, (q31_t)0x7ffece9f, (q31_t)0x7ffec0be, (q31_t)0x7ffeb28e, (q31_t)0x7ffea40f, - (q31_t)0x7ffe9542, (q31_t)0x7ffe8625, (q31_t)0x7ffe76b9, (q31_t)0x7ffe66fe, (q31_t)0x7ffe56f5, (q31_t)0x7ffe469c, (q31_t)0x7ffe35f4, (q31_t)0x7ffe24fe, - (q31_t)0x7ffe13b8, (q31_t)0x7ffe0224, (q31_t)0x7ffdf040, (q31_t)0x7ffdde0e, (q31_t)0x7ffdcb8d, (q31_t)0x7ffdb8bc, (q31_t)0x7ffda59d, (q31_t)0x7ffd922f, - (q31_t)0x7ffd7e72, (q31_t)0x7ffd6a66, (q31_t)0x7ffd560b, (q31_t)0x7ffd4161, (q31_t)0x7ffd2c68, (q31_t)0x7ffd1720, (q31_t)0x7ffd0189, (q31_t)0x7ffceba4, - (q31_t)0x7ffcd56f, (q31_t)0x7ffcbeeb, (q31_t)0x7ffca819, (q31_t)0x7ffc90f7, (q31_t)0x7ffc7987, (q31_t)0x7ffc61c7, (q31_t)0x7ffc49b9, (q31_t)0x7ffc315b, - (q31_t)0x7ffc18af, (q31_t)0x7ffbffb4, (q31_t)0x7ffbe66a, (q31_t)0x7ffbccd0, (q31_t)0x7ffbb2e8, (q31_t)0x7ffb98b1, (q31_t)0x7ffb7e2b, (q31_t)0x7ffb6356, - (q31_t)0x7ffb4833, (q31_t)0x7ffb2cc0, (q31_t)0x7ffb10fe, (q31_t)0x7ffaf4ed, (q31_t)0x7ffad88e, (q31_t)0x7ffabbdf, (q31_t)0x7ffa9ee2, (q31_t)0x7ffa8195, - (q31_t)0x7ffa63fa, (q31_t)0x7ffa460f, (q31_t)0x7ffa27d6, (q31_t)0x7ffa094e, (q31_t)0x7ff9ea76, (q31_t)0x7ff9cb50, (q31_t)0x7ff9abdb, (q31_t)0x7ff98c17, - (q31_t)0x7ff96c04, (q31_t)0x7ff94ba2, (q31_t)0x7ff92af1, (q31_t)0x7ff909f2, (q31_t)0x7ff8e8a3, (q31_t)0x7ff8c705, (q31_t)0x7ff8a519, (q31_t)0x7ff882dd, - (q31_t)0x7ff86053, (q31_t)0x7ff83d79, (q31_t)0x7ff81a51, (q31_t)0x7ff7f6da, (q31_t)0x7ff7d313, (q31_t)0x7ff7aefe, (q31_t)0x7ff78a9a, (q31_t)0x7ff765e7, - (q31_t)0x7ff740e5, (q31_t)0x7ff71b94, (q31_t)0x7ff6f5f4, (q31_t)0x7ff6d005, (q31_t)0x7ff6a9c8, (q31_t)0x7ff6833b, (q31_t)0x7ff65c5f, (q31_t)0x7ff63535, - (q31_t)0x7ff60dbb, (q31_t)0x7ff5e5f3, (q31_t)0x7ff5bddc, (q31_t)0x7ff59576, (q31_t)0x7ff56cc0, (q31_t)0x7ff543bc, (q31_t)0x7ff51a69, (q31_t)0x7ff4f0c7, - (q31_t)0x7ff4c6d6, (q31_t)0x7ff49c96, (q31_t)0x7ff47208, (q31_t)0x7ff4472a, (q31_t)0x7ff41bfd, (q31_t)0x7ff3f082, (q31_t)0x7ff3c4b7, (q31_t)0x7ff3989e, - (q31_t)0x7ff36c36, (q31_t)0x7ff33f7e, (q31_t)0x7ff31278, (q31_t)0x7ff2e523, (q31_t)0x7ff2b77f, (q31_t)0x7ff2898c, (q31_t)0x7ff25b4a, (q31_t)0x7ff22cb9, - (q31_t)0x7ff1fdd9, (q31_t)0x7ff1ceab, (q31_t)0x7ff19f2d, (q31_t)0x7ff16f61, (q31_t)0x7ff13f45, (q31_t)0x7ff10edb, (q31_t)0x7ff0de22, (q31_t)0x7ff0ad19, - (q31_t)0x7ff07bc2, (q31_t)0x7ff04a1c, (q31_t)0x7ff01827, (q31_t)0x7fefe5e4, (q31_t)0x7fefb351, (q31_t)0x7fef806f, (q31_t)0x7fef4d3e, (q31_t)0x7fef19bf, - (q31_t)0x7feee5f0, (q31_t)0x7feeb1d3, (q31_t)0x7fee7d67, (q31_t)0x7fee48ac, (q31_t)0x7fee13a1, (q31_t)0x7fedde48, (q31_t)0x7feda8a0, (q31_t)0x7fed72aa, - (q31_t)0x7fed3c64, (q31_t)0x7fed05cf, (q31_t)0x7fecceec, (q31_t)0x7fec97b9, (q31_t)0x7fec6038, (q31_t)0x7fec2867, (q31_t)0x7febf048, (q31_t)0x7febb7da, - (q31_t)0x7feb7f1d, (q31_t)0x7feb4611, (q31_t)0x7feb0cb6, (q31_t)0x7fead30c, (q31_t)0x7fea9914, (q31_t)0x7fea5ecc, (q31_t)0x7fea2436, (q31_t)0x7fe9e950, - (q31_t)0x7fe9ae1c, (q31_t)0x7fe97299, (q31_t)0x7fe936c7, (q31_t)0x7fe8faa6, (q31_t)0x7fe8be36, (q31_t)0x7fe88177, (q31_t)0x7fe84469, (q31_t)0x7fe8070d, - (q31_t)0x7fe7c961, (q31_t)0x7fe78b67, (q31_t)0x7fe74d1e, (q31_t)0x7fe70e85, (q31_t)0x7fe6cf9e, (q31_t)0x7fe69068, (q31_t)0x7fe650e3, (q31_t)0x7fe61110, - (q31_t)0x7fe5d0ed, (q31_t)0x7fe5907b, (q31_t)0x7fe54fbb, (q31_t)0x7fe50eac, (q31_t)0x7fe4cd4d, (q31_t)0x7fe48ba0, (q31_t)0x7fe449a4, (q31_t)0x7fe40759, - (q31_t)0x7fe3c4bf, (q31_t)0x7fe381d7, (q31_t)0x7fe33e9f, (q31_t)0x7fe2fb19, (q31_t)0x7fe2b743, (q31_t)0x7fe2731f, (q31_t)0x7fe22eac, (q31_t)0x7fe1e9ea, - (q31_t)0x7fe1a4d9, (q31_t)0x7fe15f79, (q31_t)0x7fe119cb, (q31_t)0x7fe0d3cd, (q31_t)0x7fe08d81, (q31_t)0x7fe046e5, (q31_t)0x7fdffffb, (q31_t)0x7fdfb8c2, - (q31_t)0x7fdf713a, (q31_t)0x7fdf2963, (q31_t)0x7fdee13e, (q31_t)0x7fde98c9, (q31_t)0x7fde5006, (q31_t)0x7fde06f3, (q31_t)0x7fddbd92, (q31_t)0x7fdd73e2, - (q31_t)0x7fdd29e3, (q31_t)0x7fdcdf95, (q31_t)0x7fdc94f9, (q31_t)0x7fdc4a0d, (q31_t)0x7fdbfed3, (q31_t)0x7fdbb349, (q31_t)0x7fdb6771, (q31_t)0x7fdb1b4a, - (q31_t)0x7fdaced4, (q31_t)0x7fda820f, (q31_t)0x7fda34fc, (q31_t)0x7fd9e799, (q31_t)0x7fd999e8, (q31_t)0x7fd94be8, (q31_t)0x7fd8fd98, (q31_t)0x7fd8aefa, - (q31_t)0x7fd8600e, (q31_t)0x7fd810d2, (q31_t)0x7fd7c147, (q31_t)0x7fd7716e, (q31_t)0x7fd72146, (q31_t)0x7fd6d0cf, (q31_t)0x7fd68009, (q31_t)0x7fd62ef4, - (q31_t)0x7fd5dd90, (q31_t)0x7fd58bdd, (q31_t)0x7fd539dc, (q31_t)0x7fd4e78c, (q31_t)0x7fd494ed, (q31_t)0x7fd441ff, (q31_t)0x7fd3eec2, (q31_t)0x7fd39b36, - (q31_t)0x7fd3475c, (q31_t)0x7fd2f332, (q31_t)0x7fd29eba, (q31_t)0x7fd249f3, (q31_t)0x7fd1f4dd, (q31_t)0x7fd19f78, (q31_t)0x7fd149c5, (q31_t)0x7fd0f3c2, - (q31_t)0x7fd09d71, (q31_t)0x7fd046d1, (q31_t)0x7fcfefe2, (q31_t)0x7fcf98a4, (q31_t)0x7fcf4117, (q31_t)0x7fcee93c, (q31_t)0x7fce9112, (q31_t)0x7fce3898, - (q31_t)0x7fcddfd0, (q31_t)0x7fcd86b9, (q31_t)0x7fcd2d54, (q31_t)0x7fccd39f, (q31_t)0x7fcc799c, (q31_t)0x7fcc1f4a, (q31_t)0x7fcbc4a9, (q31_t)0x7fcb69b9, - (q31_t)0x7fcb0e7a, (q31_t)0x7fcab2ed, (q31_t)0x7fca5710, (q31_t)0x7fc9fae5, (q31_t)0x7fc99e6b, (q31_t)0x7fc941a2, (q31_t)0x7fc8e48b, (q31_t)0x7fc88724, - (q31_t)0x7fc8296f, (q31_t)0x7fc7cb6b, (q31_t)0x7fc76d18, (q31_t)0x7fc70e76, (q31_t)0x7fc6af86, (q31_t)0x7fc65046, (q31_t)0x7fc5f0b8, (q31_t)0x7fc590db, - (q31_t)0x7fc530af, (q31_t)0x7fc4d035, (q31_t)0x7fc46f6b, (q31_t)0x7fc40e53, (q31_t)0x7fc3acec, (q31_t)0x7fc34b36, (q31_t)0x7fc2e931, (q31_t)0x7fc286de, - (q31_t)0x7fc2243b, (q31_t)0x7fc1c14a, (q31_t)0x7fc15e0a, (q31_t)0x7fc0fa7b, (q31_t)0x7fc0969e, (q31_t)0x7fc03271, (q31_t)0x7fbfcdf6, (q31_t)0x7fbf692c, - (q31_t)0x7fbf0414, (q31_t)0x7fbe9eac, (q31_t)0x7fbe38f6, (q31_t)0x7fbdd2f0, (q31_t)0x7fbd6c9c, (q31_t)0x7fbd05fa, (q31_t)0x7fbc9f08, (q31_t)0x7fbc37c8, - (q31_t)0x7fbbd039, (q31_t)0x7fbb685b, (q31_t)0x7fbb002e, (q31_t)0x7fba97b2, (q31_t)0x7fba2ee8, (q31_t)0x7fb9c5cf, (q31_t)0x7fb95c67, (q31_t)0x7fb8f2b0, - (q31_t)0x7fb888ab, (q31_t)0x7fb81e57, (q31_t)0x7fb7b3b4, (q31_t)0x7fb748c2, (q31_t)0x7fb6dd81, (q31_t)0x7fb671f2, (q31_t)0x7fb60614, (q31_t)0x7fb599e7, - (q31_t)0x7fb52d6b, (q31_t)0x7fb4c0a1, (q31_t)0x7fb45387, (q31_t)0x7fb3e61f, (q31_t)0x7fb37869, (q31_t)0x7fb30a63, (q31_t)0x7fb29c0f, (q31_t)0x7fb22d6c, - (q31_t)0x7fb1be7a, (q31_t)0x7fb14f39, (q31_t)0x7fb0dfaa, (q31_t)0x7fb06fcb, (q31_t)0x7fafff9e, (q31_t)0x7faf8f23, (q31_t)0x7faf1e58, (q31_t)0x7faead3f, - (q31_t)0x7fae3bd7, (q31_t)0x7fadca20, (q31_t)0x7fad581b, (q31_t)0x7face5c6, (q31_t)0x7fac7323, (q31_t)0x7fac0031, (q31_t)0x7fab8cf1, (q31_t)0x7fab1962, - (q31_t)0x7faaa584, (q31_t)0x7faa3157, (q31_t)0x7fa9bcdb, (q31_t)0x7fa94811, (q31_t)0x7fa8d2f8, (q31_t)0x7fa85d90, (q31_t)0x7fa7e7d9, (q31_t)0x7fa771d4, - (q31_t)0x7fa6fb80, (q31_t)0x7fa684dd, (q31_t)0x7fa60dec, (q31_t)0x7fa596ac, (q31_t)0x7fa51f1d, (q31_t)0x7fa4a73f, (q31_t)0x7fa42f12, (q31_t)0x7fa3b697, - (q31_t)0x7fa33dcd, (q31_t)0x7fa2c4b5, (q31_t)0x7fa24b4d, (q31_t)0x7fa1d197, (q31_t)0x7fa15792, (q31_t)0x7fa0dd3f, (q31_t)0x7fa0629c, (q31_t)0x7f9fe7ab, - (q31_t)0x7f9f6c6b, (q31_t)0x7f9ef0dd, (q31_t)0x7f9e7500, (q31_t)0x7f9df8d4, (q31_t)0x7f9d7c59, (q31_t)0x7f9cff90, (q31_t)0x7f9c8278, (q31_t)0x7f9c0511, - (q31_t)0x7f9b875b, (q31_t)0x7f9b0957, (q31_t)0x7f9a8b04, (q31_t)0x7f9a0c62, (q31_t)0x7f998d72, (q31_t)0x7f990e33, (q31_t)0x7f988ea5, (q31_t)0x7f980ec8, - (q31_t)0x7f978e9d, (q31_t)0x7f970e23, (q31_t)0x7f968d5b, (q31_t)0x7f960c43, (q31_t)0x7f958add, (q31_t)0x7f950929, (q31_t)0x7f948725, (q31_t)0x7f9404d3, - (q31_t)0x7f938232, (q31_t)0x7f92ff43, (q31_t)0x7f927c04, (q31_t)0x7f91f878, (q31_t)0x7f91749c, (q31_t)0x7f90f072, (q31_t)0x7f906bf9, (q31_t)0x7f8fe731, - (q31_t)0x7f8f621b, (q31_t)0x7f8edcb6, (q31_t)0x7f8e5702, (q31_t)0x7f8dd0ff, (q31_t)0x7f8d4aae, (q31_t)0x7f8cc40f, (q31_t)0x7f8c3d20, (q31_t)0x7f8bb5e3, - (q31_t)0x7f8b2e57, (q31_t)0x7f8aa67d, (q31_t)0x7f8a1e54, (q31_t)0x7f8995dc, (q31_t)0x7f890d15, (q31_t)0x7f888400, (q31_t)0x7f87fa9c, (q31_t)0x7f8770ea, - (q31_t)0x7f86e6e9, (q31_t)0x7f865c99, (q31_t)0x7f85d1fa, (q31_t)0x7f85470d, (q31_t)0x7f84bbd1, (q31_t)0x7f843047, (q31_t)0x7f83a46e, (q31_t)0x7f831846, - (q31_t)0x7f828bcf, (q31_t)0x7f81ff0a, (q31_t)0x7f8171f6, (q31_t)0x7f80e494, (q31_t)0x7f8056e3, (q31_t)0x7f7fc8e3, (q31_t)0x7f7f3a95, (q31_t)0x7f7eabf8, - (q31_t)0x7f7e1d0c, (q31_t)0x7f7d8dd2, (q31_t)0x7f7cfe49, (q31_t)0x7f7c6e71, (q31_t)0x7f7bde4b, (q31_t)0x7f7b4dd6, (q31_t)0x7f7abd13, (q31_t)0x7f7a2c01, - (q31_t)0x7f799aa0, (q31_t)0x7f7908f0, (q31_t)0x7f7876f2, (q31_t)0x7f77e4a6, (q31_t)0x7f77520a, (q31_t)0x7f76bf21, (q31_t)0x7f762be8, (q31_t)0x7f759861, - (q31_t)0x7f75048b, (q31_t)0x7f747067, (q31_t)0x7f73dbf4, (q31_t)0x7f734732, (q31_t)0x7f72b222, (q31_t)0x7f721cc3, (q31_t)0x7f718715, (q31_t)0x7f70f119, - (q31_t)0x7f705ace, (q31_t)0x7f6fc435, (q31_t)0x7f6f2d4d, (q31_t)0x7f6e9617, (q31_t)0x7f6dfe91, (q31_t)0x7f6d66be, (q31_t)0x7f6cce9b, (q31_t)0x7f6c362a, - (q31_t)0x7f6b9d6b, (q31_t)0x7f6b045d, (q31_t)0x7f6a6b00, (q31_t)0x7f69d154, (q31_t)0x7f69375a, (q31_t)0x7f689d12, (q31_t)0x7f68027b, (q31_t)0x7f676795, - (q31_t)0x7f66cc61, (q31_t)0x7f6630de, (q31_t)0x7f65950c, (q31_t)0x7f64f8ec, (q31_t)0x7f645c7d, (q31_t)0x7f63bfc0, (q31_t)0x7f6322b4, (q31_t)0x7f62855a, - (q31_t)0x7f61e7b1, (q31_t)0x7f6149b9, (q31_t)0x7f60ab73, (q31_t)0x7f600cdf, (q31_t)0x7f5f6dfb, (q31_t)0x7f5ecec9, (q31_t)0x7f5e2f49, (q31_t)0x7f5d8f7a, - (q31_t)0x7f5cef5c, (q31_t)0x7f5c4ef0, (q31_t)0x7f5bae36, (q31_t)0x7f5b0d2c, (q31_t)0x7f5a6bd5, (q31_t)0x7f59ca2e, (q31_t)0x7f592839, (q31_t)0x7f5885f6, - (q31_t)0x7f57e364, (q31_t)0x7f574083, (q31_t)0x7f569d54, (q31_t)0x7f55f9d6, (q31_t)0x7f55560a, (q31_t)0x7f54b1ef, (q31_t)0x7f540d86, (q31_t)0x7f5368ce, - (q31_t)0x7f52c3c8, (q31_t)0x7f521e73, (q31_t)0x7f5178cf, (q31_t)0x7f50d2dd, (q31_t)0x7f502c9d, (q31_t)0x7f4f860e, (q31_t)0x7f4edf30, (q31_t)0x7f4e3804, - (q31_t)0x7f4d9089, (q31_t)0x7f4ce8c0, (q31_t)0x7f4c40a8, (q31_t)0x7f4b9842, (q31_t)0x7f4aef8d, (q31_t)0x7f4a468a, (q31_t)0x7f499d38, (q31_t)0x7f48f398, - (q31_t)0x7f4849a9, (q31_t)0x7f479f6c, (q31_t)0x7f46f4e0, (q31_t)0x7f464a06, (q31_t)0x7f459edd, (q31_t)0x7f44f365, (q31_t)0x7f44479f, (q31_t)0x7f439b8b, - (q31_t)0x7f42ef28, (q31_t)0x7f424277, (q31_t)0x7f419577, (q31_t)0x7f40e828, (q31_t)0x7f403a8b, (q31_t)0x7f3f8ca0, (q31_t)0x7f3ede66, (q31_t)0x7f3e2fde, - (q31_t)0x7f3d8107, (q31_t)0x7f3cd1e2, (q31_t)0x7f3c226e, (q31_t)0x7f3b72ab, (q31_t)0x7f3ac29b, (q31_t)0x7f3a123b, (q31_t)0x7f39618e, (q31_t)0x7f38b091, - (q31_t)0x7f37ff47, (q31_t)0x7f374dad, (q31_t)0x7f369bc6, (q31_t)0x7f35e990, (q31_t)0x7f35370b, (q31_t)0x7f348438, (q31_t)0x7f33d116, (q31_t)0x7f331da6, - (q31_t)0x7f3269e8, (q31_t)0x7f31b5db, (q31_t)0x7f31017f, (q31_t)0x7f304cd6, (q31_t)0x7f2f97dd, (q31_t)0x7f2ee296, (q31_t)0x7f2e2d01, (q31_t)0x7f2d771e, - (q31_t)0x7f2cc0eb, (q31_t)0x7f2c0a6b, (q31_t)0x7f2b539c, (q31_t)0x7f2a9c7e, (q31_t)0x7f29e512, (q31_t)0x7f292d58, (q31_t)0x7f28754f, (q31_t)0x7f27bcf8, - (q31_t)0x7f270452, (q31_t)0x7f264b5e, (q31_t)0x7f25921c, (q31_t)0x7f24d88b, (q31_t)0x7f241eab, (q31_t)0x7f23647e, (q31_t)0x7f22aa01, (q31_t)0x7f21ef37, - (q31_t)0x7f21341e, (q31_t)0x7f2078b6, (q31_t)0x7f1fbd00, (q31_t)0x7f1f00fc, (q31_t)0x7f1e44a9, (q31_t)0x7f1d8808, (q31_t)0x7f1ccb18, (q31_t)0x7f1c0dda, - (q31_t)0x7f1b504e, (q31_t)0x7f1a9273, (q31_t)0x7f19d44a, (q31_t)0x7f1915d2, (q31_t)0x7f18570c, (q31_t)0x7f1797f8, (q31_t)0x7f16d895, (q31_t)0x7f1618e4, - (q31_t)0x7f1558e4, (q31_t)0x7f149896, (q31_t)0x7f13d7fa, (q31_t)0x7f13170f, (q31_t)0x7f1255d6, (q31_t)0x7f11944f, (q31_t)0x7f10d279, (q31_t)0x7f101054, - (q31_t)0x7f0f4de2, (q31_t)0x7f0e8b21, (q31_t)0x7f0dc811, (q31_t)0x7f0d04b3, (q31_t)0x7f0c4107, (q31_t)0x7f0b7d0d, (q31_t)0x7f0ab8c4, (q31_t)0x7f09f42d, - (q31_t)0x7f092f47, (q31_t)0x7f086a13, (q31_t)0x7f07a491, (q31_t)0x7f06dec0, (q31_t)0x7f0618a1, (q31_t)0x7f055233, (q31_t)0x7f048b78, (q31_t)0x7f03c46d, - (q31_t)0x7f02fd15, (q31_t)0x7f02356e, (q31_t)0x7f016d79, (q31_t)0x7f00a535, (q31_t)0x7effdca4, (q31_t)0x7eff13c3, (q31_t)0x7efe4a95, (q31_t)0x7efd8118, - (q31_t)0x7efcb74d, (q31_t)0x7efbed33, (q31_t)0x7efb22cb, (q31_t)0x7efa5815, (q31_t)0x7ef98d11, (q31_t)0x7ef8c1be, (q31_t)0x7ef7f61d, (q31_t)0x7ef72a2d, - (q31_t)0x7ef65def, (q31_t)0x7ef59163, (q31_t)0x7ef4c489, (q31_t)0x7ef3f760, (q31_t)0x7ef329e9, (q31_t)0x7ef25c24, (q31_t)0x7ef18e10, (q31_t)0x7ef0bfae, - (q31_t)0x7eeff0fe, (q31_t)0x7eef21ff, (q31_t)0x7eee52b2, (q31_t)0x7eed8317, (q31_t)0x7eecb32d, (q31_t)0x7eebe2f6, (q31_t)0x7eeb1270, (q31_t)0x7eea419b, - (q31_t)0x7ee97079, (q31_t)0x7ee89f08, (q31_t)0x7ee7cd49, (q31_t)0x7ee6fb3b, (q31_t)0x7ee628df, (q31_t)0x7ee55635, (q31_t)0x7ee4833d, (q31_t)0x7ee3aff6, - (q31_t)0x7ee2dc61, (q31_t)0x7ee2087e, (q31_t)0x7ee1344d, (q31_t)0x7ee05fcd, (q31_t)0x7edf8aff, (q31_t)0x7edeb5e3, (q31_t)0x7edde079, (q31_t)0x7edd0ac0, - (q31_t)0x7edc34b9, (q31_t)0x7edb5e64, (q31_t)0x7eda87c0, (q31_t)0x7ed9b0ce, (q31_t)0x7ed8d98e, (q31_t)0x7ed80200, (q31_t)0x7ed72a24, (q31_t)0x7ed651f9, - (q31_t)0x7ed57980, (q31_t)0x7ed4a0b9, (q31_t)0x7ed3c7a3, (q31_t)0x7ed2ee40, (q31_t)0x7ed2148e, (q31_t)0x7ed13a8e, (q31_t)0x7ed0603f, (q31_t)0x7ecf85a3, - (q31_t)0x7eceaab8, (q31_t)0x7ecdcf7f, (q31_t)0x7eccf3f8, (q31_t)0x7ecc1822, (q31_t)0x7ecb3bff, (q31_t)0x7eca5f8d, (q31_t)0x7ec982cd, (q31_t)0x7ec8a5bf, - (q31_t)0x7ec7c862, (q31_t)0x7ec6eab7, (q31_t)0x7ec60cbe, (q31_t)0x7ec52e77, (q31_t)0x7ec44fe2, (q31_t)0x7ec370fe, (q31_t)0x7ec291cd, (q31_t)0x7ec1b24d, - (q31_t)0x7ec0d27f, (q31_t)0x7ebff263, (q31_t)0x7ebf11f8, (q31_t)0x7ebe313f, (q31_t)0x7ebd5039, (q31_t)0x7ebc6ee4, (q31_t)0x7ebb8d40, (q31_t)0x7ebaab4f, - (q31_t)0x7eb9c910, (q31_t)0x7eb8e682, (q31_t)0x7eb803a6, (q31_t)0x7eb7207c, (q31_t)0x7eb63d04, (q31_t)0x7eb5593d, (q31_t)0x7eb47529, (q31_t)0x7eb390c6, - (q31_t)0x7eb2ac15, (q31_t)0x7eb1c716, (q31_t)0x7eb0e1c9, (q31_t)0x7eaffc2e, (q31_t)0x7eaf1645, (q31_t)0x7eae300d, (q31_t)0x7ead4987, (q31_t)0x7eac62b3, - (q31_t)0x7eab7b91, (q31_t)0x7eaa9421, (q31_t)0x7ea9ac63, (q31_t)0x7ea8c457, (q31_t)0x7ea7dbfc, (q31_t)0x7ea6f353, (q31_t)0x7ea60a5d, (q31_t)0x7ea52118, - (q31_t)0x7ea43785, (q31_t)0x7ea34da4, (q31_t)0x7ea26374, (q31_t)0x7ea178f7, (q31_t)0x7ea08e2b, (q31_t)0x7e9fa312, (q31_t)0x7e9eb7aa, (q31_t)0x7e9dcbf4, - (q31_t)0x7e9cdff0, (q31_t)0x7e9bf39e, (q31_t)0x7e9b06fe, (q31_t)0x7e9a1a10, (q31_t)0x7e992cd4, (q31_t)0x7e983f49, (q31_t)0x7e975171, (q31_t)0x7e96634a, - (q31_t)0x7e9574d6, (q31_t)0x7e948613, (q31_t)0x7e939702, (q31_t)0x7e92a7a3, (q31_t)0x7e91b7f6, (q31_t)0x7e90c7fb, (q31_t)0x7e8fd7b2, (q31_t)0x7e8ee71b, - (q31_t)0x7e8df636, (q31_t)0x7e8d0502, (q31_t)0x7e8c1381, (q31_t)0x7e8b21b1, (q31_t)0x7e8a2f94, (q31_t)0x7e893d28, (q31_t)0x7e884a6f, (q31_t)0x7e875767, - (q31_t)0x7e866411, (q31_t)0x7e85706d, (q31_t)0x7e847c7c, (q31_t)0x7e83883c, (q31_t)0x7e8293ae, (q31_t)0x7e819ed2, (q31_t)0x7e80a9a8, (q31_t)0x7e7fb430, - (q31_t)0x7e7ebe6a, (q31_t)0x7e7dc856, (q31_t)0x7e7cd1f4, (q31_t)0x7e7bdb44, (q31_t)0x7e7ae446, (q31_t)0x7e79ecf9, (q31_t)0x7e78f55f, (q31_t)0x7e77fd77, - (q31_t)0x7e770541, (q31_t)0x7e760cbd, (q31_t)0x7e7513ea, (q31_t)0x7e741aca, (q31_t)0x7e73215c, (q31_t)0x7e7227a0, (q31_t)0x7e712d96, (q31_t)0x7e70333d, - (q31_t)0x7e6f3897, (q31_t)0x7e6e3da3, (q31_t)0x7e6d4261, (q31_t)0x7e6c46d1, (q31_t)0x7e6b4af2, (q31_t)0x7e6a4ec6, (q31_t)0x7e69524c, (q31_t)0x7e685584, - (q31_t)0x7e67586e, (q31_t)0x7e665b0a, (q31_t)0x7e655d58, (q31_t)0x7e645f58, (q31_t)0x7e63610a, (q31_t)0x7e62626e, (q31_t)0x7e616384, (q31_t)0x7e60644c, - (q31_t)0x7e5f64c7, (q31_t)0x7e5e64f3, (q31_t)0x7e5d64d1, (q31_t)0x7e5c6461, (q31_t)0x7e5b63a4, (q31_t)0x7e5a6298, (q31_t)0x7e59613f, (q31_t)0x7e585f97, - (q31_t)0x7e575da2, (q31_t)0x7e565b5f, (q31_t)0x7e5558ce, (q31_t)0x7e5455ef, (q31_t)0x7e5352c1, (q31_t)0x7e524f46, (q31_t)0x7e514b7e, (q31_t)0x7e504767, - (q31_t)0x7e4f4302, (q31_t)0x7e4e3e4f, (q31_t)0x7e4d394f, (q31_t)0x7e4c3400, (q31_t)0x7e4b2e64, (q31_t)0x7e4a287a, (q31_t)0x7e492241, (q31_t)0x7e481bbb, - (q31_t)0x7e4714e7, (q31_t)0x7e460dc5, (q31_t)0x7e450656, (q31_t)0x7e43fe98, (q31_t)0x7e42f68c, (q31_t)0x7e41ee33, (q31_t)0x7e40e58c, (q31_t)0x7e3fdc97, - (q31_t)0x7e3ed353, (q31_t)0x7e3dc9c3, (q31_t)0x7e3cbfe4, (q31_t)0x7e3bb5b7, (q31_t)0x7e3aab3c, (q31_t)0x7e39a074, (q31_t)0x7e38955e, (q31_t)0x7e3789fa, - (q31_t)0x7e367e48, (q31_t)0x7e357248, (q31_t)0x7e3465fa, (q31_t)0x7e33595e, (q31_t)0x7e324c75, (q31_t)0x7e313f3e, (q31_t)0x7e3031b9, (q31_t)0x7e2f23e6, - (q31_t)0x7e2e15c5, (q31_t)0x7e2d0756, (q31_t)0x7e2bf89a, (q31_t)0x7e2ae990, (q31_t)0x7e29da38, (q31_t)0x7e28ca92, (q31_t)0x7e27ba9e, (q31_t)0x7e26aa5d, - (q31_t)0x7e2599cd, (q31_t)0x7e2488f0, (q31_t)0x7e2377c5, (q31_t)0x7e22664c, (q31_t)0x7e215486, (q31_t)0x7e204271, (q31_t)0x7e1f300f, (q31_t)0x7e1e1d5f, - (q31_t)0x7e1d0a61, (q31_t)0x7e1bf716, (q31_t)0x7e1ae37c, (q31_t)0x7e19cf95, (q31_t)0x7e18bb60, (q31_t)0x7e17a6dd, (q31_t)0x7e16920d, (q31_t)0x7e157cee, - (q31_t)0x7e146782, (q31_t)0x7e1351c9, (q31_t)0x7e123bc1, (q31_t)0x7e11256c, (q31_t)0x7e100ec8, (q31_t)0x7e0ef7d7, (q31_t)0x7e0de099, (q31_t)0x7e0cc90c, - (q31_t)0x7e0bb132, (q31_t)0x7e0a990a, (q31_t)0x7e098095, (q31_t)0x7e0867d1, (q31_t)0x7e074ec0, (q31_t)0x7e063561, (q31_t)0x7e051bb4, (q31_t)0x7e0401ba, - (q31_t)0x7e02e772, (q31_t)0x7e01ccdc, (q31_t)0x7e00b1f9, (q31_t)0x7dff96c7, (q31_t)0x7dfe7b48, (q31_t)0x7dfd5f7b, (q31_t)0x7dfc4361, (q31_t)0x7dfb26f9, - (q31_t)0x7dfa0a43, (q31_t)0x7df8ed3f, (q31_t)0x7df7cfee, (q31_t)0x7df6b24f, (q31_t)0x7df59462, (q31_t)0x7df47628, (q31_t)0x7df357a0, (q31_t)0x7df238ca, - (q31_t)0x7df119a7, (q31_t)0x7deffa35, (q31_t)0x7deeda77, (q31_t)0x7dedba6a, (q31_t)0x7dec9a10, (q31_t)0x7deb7968, (q31_t)0x7dea5872, (q31_t)0x7de9372f, - (q31_t)0x7de8159e, (q31_t)0x7de6f3c0, (q31_t)0x7de5d193, (q31_t)0x7de4af1a, (q31_t)0x7de38c52, (q31_t)0x7de2693d, (q31_t)0x7de145da, (q31_t)0x7de02229, - (q31_t)0x7ddefe2b, (q31_t)0x7dddd9e0, (q31_t)0x7ddcb546, (q31_t)0x7ddb905f, (q31_t)0x7dda6b2a, (q31_t)0x7dd945a8, (q31_t)0x7dd81fd8, (q31_t)0x7dd6f9ba, - (q31_t)0x7dd5d34f, (q31_t)0x7dd4ac96, (q31_t)0x7dd38590, (q31_t)0x7dd25e3c, (q31_t)0x7dd1369a, (q31_t)0x7dd00eab, (q31_t)0x7dcee66e, (q31_t)0x7dcdbde3, - (q31_t)0x7dcc950b, (q31_t)0x7dcb6be6, (q31_t)0x7dca4272, (q31_t)0x7dc918b1, (q31_t)0x7dc7eea3, (q31_t)0x7dc6c447, (q31_t)0x7dc5999d, (q31_t)0x7dc46ea6, - (q31_t)0x7dc34361, (q31_t)0x7dc217cf, (q31_t)0x7dc0ebef, (q31_t)0x7dbfbfc1, (q31_t)0x7dbe9346, (q31_t)0x7dbd667d, (q31_t)0x7dbc3967, (q31_t)0x7dbb0c03, - (q31_t)0x7db9de52, (q31_t)0x7db8b053, (q31_t)0x7db78207, (q31_t)0x7db6536d, (q31_t)0x7db52485, (q31_t)0x7db3f550, (q31_t)0x7db2c5cd, (q31_t)0x7db195fd, - (q31_t)0x7db065df, (q31_t)0x7daf3574, (q31_t)0x7dae04bb, (q31_t)0x7dacd3b5, (q31_t)0x7daba261, (q31_t)0x7daa70c0, (q31_t)0x7da93ed1, (q31_t)0x7da80c95, - (q31_t)0x7da6da0b, (q31_t)0x7da5a733, (q31_t)0x7da4740e, (q31_t)0x7da3409c, (q31_t)0x7da20cdc, (q31_t)0x7da0d8cf, (q31_t)0x7d9fa474, (q31_t)0x7d9e6fcb, - (q31_t)0x7d9d3ad6, (q31_t)0x7d9c0592, (q31_t)0x7d9ad001, (q31_t)0x7d999a23, (q31_t)0x7d9863f7, (q31_t)0x7d972d7e, (q31_t)0x7d95f6b7, (q31_t)0x7d94bfa3, - (q31_t)0x7d938841, (q31_t)0x7d925092, (q31_t)0x7d911896, (q31_t)0x7d8fe04c, (q31_t)0x7d8ea7b4, (q31_t)0x7d8d6ecf, (q31_t)0x7d8c359d, (q31_t)0x7d8afc1d, - (q31_t)0x7d89c250, (q31_t)0x7d888835, (q31_t)0x7d874dcd, (q31_t)0x7d861317, (q31_t)0x7d84d814, (q31_t)0x7d839cc4, (q31_t)0x7d826126, (q31_t)0x7d81253a, - (q31_t)0x7d7fe902, (q31_t)0x7d7eac7c, (q31_t)0x7d7d6fa8, (q31_t)0x7d7c3287, (q31_t)0x7d7af519, (q31_t)0x7d79b75d, (q31_t)0x7d787954, (q31_t)0x7d773afd, - (q31_t)0x7d75fc59, (q31_t)0x7d74bd68, (q31_t)0x7d737e29, (q31_t)0x7d723e9d, (q31_t)0x7d70fec4, (q31_t)0x7d6fbe9d, (q31_t)0x7d6e7e29, (q31_t)0x7d6d3d67, - (q31_t)0x7d6bfc58, (q31_t)0x7d6abafc, (q31_t)0x7d697952, (q31_t)0x7d68375b, (q31_t)0x7d66f517, (q31_t)0x7d65b285, (q31_t)0x7d646fa6, (q31_t)0x7d632c79, - (q31_t)0x7d61e8ff, (q31_t)0x7d60a538, (q31_t)0x7d5f6124, (q31_t)0x7d5e1cc2, (q31_t)0x7d5cd813, (q31_t)0x7d5b9316, (q31_t)0x7d5a4dcc, (q31_t)0x7d590835, - (q31_t)0x7d57c251, (q31_t)0x7d567c1f, (q31_t)0x7d5535a0, (q31_t)0x7d53eed3, (q31_t)0x7d52a7ba, (q31_t)0x7d516053, (q31_t)0x7d50189e, (q31_t)0x7d4ed09d, - (q31_t)0x7d4d884e, (q31_t)0x7d4c3fb1, (q31_t)0x7d4af6c8, (q31_t)0x7d49ad91, (q31_t)0x7d48640d, (q31_t)0x7d471a3c, (q31_t)0x7d45d01d, (q31_t)0x7d4485b1, - (q31_t)0x7d433af8, (q31_t)0x7d41eff1, (q31_t)0x7d40a49e, (q31_t)0x7d3f58fd, (q31_t)0x7d3e0d0e, (q31_t)0x7d3cc0d3, (q31_t)0x7d3b744a, (q31_t)0x7d3a2774, - (q31_t)0x7d38da51, (q31_t)0x7d378ce0, (q31_t)0x7d363f23, (q31_t)0x7d34f118, (q31_t)0x7d33a2bf, (q31_t)0x7d32541a, (q31_t)0x7d310527, (q31_t)0x7d2fb5e7, - (q31_t)0x7d2e665a, (q31_t)0x7d2d1680, (q31_t)0x7d2bc659, (q31_t)0x7d2a75e4, (q31_t)0x7d292522, (q31_t)0x7d27d413, (q31_t)0x7d2682b6, (q31_t)0x7d25310d, - (q31_t)0x7d23df16, (q31_t)0x7d228cd2, (q31_t)0x7d213a41, (q31_t)0x7d1fe762, (q31_t)0x7d1e9437, (q31_t)0x7d1d40be, (q31_t)0x7d1becf8, (q31_t)0x7d1a98e5, - (q31_t)0x7d194485, (q31_t)0x7d17efd8, (q31_t)0x7d169add, (q31_t)0x7d154595, (q31_t)0x7d13f001, (q31_t)0x7d129a1f, (q31_t)0x7d1143ef, (q31_t)0x7d0fed73, - (q31_t)0x7d0e96aa, (q31_t)0x7d0d3f93, (q31_t)0x7d0be82f, (q31_t)0x7d0a907e, (q31_t)0x7d093880, (q31_t)0x7d07e035, (q31_t)0x7d06879d, (q31_t)0x7d052eb8, - (q31_t)0x7d03d585, (q31_t)0x7d027c05, (q31_t)0x7d012239, (q31_t)0x7cffc81f, (q31_t)0x7cfe6db8, (q31_t)0x7cfd1304, (q31_t)0x7cfbb803, (q31_t)0x7cfa5cb4, - (q31_t)0x7cf90119, (q31_t)0x7cf7a531, (q31_t)0x7cf648fb, (q31_t)0x7cf4ec79, (q31_t)0x7cf38fa9, (q31_t)0x7cf2328c, (q31_t)0x7cf0d522, (q31_t)0x7cef776b, - (q31_t)0x7cee1967, (q31_t)0x7cecbb16, (q31_t)0x7ceb5c78, (q31_t)0x7ce9fd8d, (q31_t)0x7ce89e55, (q31_t)0x7ce73ed0, (q31_t)0x7ce5defd, (q31_t)0x7ce47ede, - (q31_t)0x7ce31e72, (q31_t)0x7ce1bdb8, (q31_t)0x7ce05cb2, (q31_t)0x7cdefb5e, (q31_t)0x7cdd99be, (q31_t)0x7cdc37d0, (q31_t)0x7cdad596, (q31_t)0x7cd9730e, - (q31_t)0x7cd8103a, (q31_t)0x7cd6ad18, (q31_t)0x7cd549aa, (q31_t)0x7cd3e5ee, (q31_t)0x7cd281e5, (q31_t)0x7cd11d90, (q31_t)0x7ccfb8ed, (q31_t)0x7cce53fe, - (q31_t)0x7ccceec1, (q31_t)0x7ccb8937, (q31_t)0x7cca2361, (q31_t)0x7cc8bd3d, (q31_t)0x7cc756cd, (q31_t)0x7cc5f010, (q31_t)0x7cc48905, (q31_t)0x7cc321ae, - (q31_t)0x7cc1ba09, (q31_t)0x7cc05218, (q31_t)0x7cbee9da, (q31_t)0x7cbd814f, (q31_t)0x7cbc1877, (q31_t)0x7cbaaf51, (q31_t)0x7cb945df, (q31_t)0x7cb7dc20, - (q31_t)0x7cb67215, (q31_t)0x7cb507bc, (q31_t)0x7cb39d16, (q31_t)0x7cb23223, (q31_t)0x7cb0c6e4, (q31_t)0x7caf5b57, (q31_t)0x7cadef7e, (q31_t)0x7cac8358, - (q31_t)0x7cab16e4, (q31_t)0x7ca9aa24, (q31_t)0x7ca83d17, (q31_t)0x7ca6cfbd, (q31_t)0x7ca56216, (q31_t)0x7ca3f423, (q31_t)0x7ca285e2, (q31_t)0x7ca11755, - (q31_t)0x7c9fa87a, (q31_t)0x7c9e3953, (q31_t)0x7c9cc9df, (q31_t)0x7c9b5a1e, (q31_t)0x7c99ea10, (q31_t)0x7c9879b6, (q31_t)0x7c97090e, (q31_t)0x7c95981a, - (q31_t)0x7c9426d8, (q31_t)0x7c92b54a, (q31_t)0x7c91436f, (q31_t)0x7c8fd148, (q31_t)0x7c8e5ed3, (q31_t)0x7c8cec12, (q31_t)0x7c8b7903, (q31_t)0x7c8a05a8, - (q31_t)0x7c889200, (q31_t)0x7c871e0c, (q31_t)0x7c85a9ca, (q31_t)0x7c84353c, (q31_t)0x7c82c060, (q31_t)0x7c814b39, (q31_t)0x7c7fd5c4, (q31_t)0x7c7e6002, - (q31_t)0x7c7ce9f4, (q31_t)0x7c7b7399, (q31_t)0x7c79fcf1, (q31_t)0x7c7885fc, (q31_t)0x7c770eba, (q31_t)0x7c75972c, (q31_t)0x7c741f51, (q31_t)0x7c72a729, - (q31_t)0x7c712eb5, (q31_t)0x7c6fb5f3, (q31_t)0x7c6e3ce5, (q31_t)0x7c6cc38a, (q31_t)0x7c6b49e3, (q31_t)0x7c69cfee, (q31_t)0x7c6855ad, (q31_t)0x7c66db1f, - (q31_t)0x7c656045, (q31_t)0x7c63e51e, (q31_t)0x7c6269aa, (q31_t)0x7c60ede9, (q31_t)0x7c5f71db, (q31_t)0x7c5df581, (q31_t)0x7c5c78da, (q31_t)0x7c5afbe6, - (q31_t)0x7c597ea6, (q31_t)0x7c580119, (q31_t)0x7c56833f, (q31_t)0x7c550519, (q31_t)0x7c5386a6, (q31_t)0x7c5207e6, (q31_t)0x7c5088d9, (q31_t)0x7c4f0980, - (q31_t)0x7c4d89da, (q31_t)0x7c4c09e8, (q31_t)0x7c4a89a8, (q31_t)0x7c49091c, (q31_t)0x7c478844, (q31_t)0x7c46071f, (q31_t)0x7c4485ad, (q31_t)0x7c4303ee, - (q31_t)0x7c4181e3, (q31_t)0x7c3fff8b, (q31_t)0x7c3e7ce7, (q31_t)0x7c3cf9f5, (q31_t)0x7c3b76b8, (q31_t)0x7c39f32d, (q31_t)0x7c386f56, (q31_t)0x7c36eb33, - (q31_t)0x7c3566c2, (q31_t)0x7c33e205, (q31_t)0x7c325cfc, (q31_t)0x7c30d7a6, (q31_t)0x7c2f5203, (q31_t)0x7c2dcc14, (q31_t)0x7c2c45d8, (q31_t)0x7c2abf4f, - (q31_t)0x7c29387a, (q31_t)0x7c27b158, (q31_t)0x7c2629ea, (q31_t)0x7c24a22f, (q31_t)0x7c231a28, (q31_t)0x7c2191d4, (q31_t)0x7c200933, (q31_t)0x7c1e8046, - (q31_t)0x7c1cf70c, (q31_t)0x7c1b6d86, (q31_t)0x7c19e3b3, (q31_t)0x7c185994, (q31_t)0x7c16cf28, (q31_t)0x7c15446f, (q31_t)0x7c13b96a, (q31_t)0x7c122e19, - (q31_t)0x7c10a27b, (q31_t)0x7c0f1690, (q31_t)0x7c0d8a59, (q31_t)0x7c0bfdd5, (q31_t)0x7c0a7105, (q31_t)0x7c08e3e8, (q31_t)0x7c07567f, (q31_t)0x7c05c8c9, - (q31_t)0x7c043ac7, (q31_t)0x7c02ac78, (q31_t)0x7c011ddd, (q31_t)0x7bff8ef5, (q31_t)0x7bfdffc1, (q31_t)0x7bfc7041, (q31_t)0x7bfae073, (q31_t)0x7bf9505a, - (q31_t)0x7bf7bff4, (q31_t)0x7bf62f41, (q31_t)0x7bf49e42, (q31_t)0x7bf30cf6, (q31_t)0x7bf17b5e, (q31_t)0x7befe97a, (q31_t)0x7bee5749, (q31_t)0x7becc4cc, - (q31_t)0x7beb3202, (q31_t)0x7be99eec, (q31_t)0x7be80b89, (q31_t)0x7be677da, (q31_t)0x7be4e3df, (q31_t)0x7be34f97, (q31_t)0x7be1bb02, (q31_t)0x7be02621, - (q31_t)0x7bde90f4, (q31_t)0x7bdcfb7b, (q31_t)0x7bdb65b5, (q31_t)0x7bd9cfa2, (q31_t)0x7bd83944, (q31_t)0x7bd6a298, (q31_t)0x7bd50ba1, (q31_t)0x7bd3745d, - (q31_t)0x7bd1dccc, (q31_t)0x7bd044f0, (q31_t)0x7bceacc7, (q31_t)0x7bcd1451, (q31_t)0x7bcb7b8f, (q31_t)0x7bc9e281, (q31_t)0x7bc84927, (q31_t)0x7bc6af80, - (q31_t)0x7bc5158c, (q31_t)0x7bc37b4d, (q31_t)0x7bc1e0c1, (q31_t)0x7bc045e9, (q31_t)0x7bbeaac4, (q31_t)0x7bbd0f53, (q31_t)0x7bbb7396, (q31_t)0x7bb9d78c, - (q31_t)0x7bb83b36, (q31_t)0x7bb69e94, (q31_t)0x7bb501a5, (q31_t)0x7bb3646a, (q31_t)0x7bb1c6e3, (q31_t)0x7bb02910, (q31_t)0x7bae8af0, (q31_t)0x7bacec84, - (q31_t)0x7bab4dcc, (q31_t)0x7ba9aec7, (q31_t)0x7ba80f76, (q31_t)0x7ba66fd9, (q31_t)0x7ba4cfef, (q31_t)0x7ba32fba, (q31_t)0x7ba18f38, (q31_t)0x7b9fee69, - (q31_t)0x7b9e4d4f, (q31_t)0x7b9cabe8, (q31_t)0x7b9b0a35, (q31_t)0x7b996836, (q31_t)0x7b97c5ea, (q31_t)0x7b962352, (q31_t)0x7b94806e, (q31_t)0x7b92dd3e, - (q31_t)0x7b9139c2, (q31_t)0x7b8f95f9, (q31_t)0x7b8df1e4, (q31_t)0x7b8c4d83, (q31_t)0x7b8aa8d6, (q31_t)0x7b8903dc, (q31_t)0x7b875e96, (q31_t)0x7b85b904, - (q31_t)0x7b841326, (q31_t)0x7b826cfc, (q31_t)0x7b80c686, (q31_t)0x7b7f1fc3, (q31_t)0x7b7d78b4, (q31_t)0x7b7bd159, (q31_t)0x7b7a29b2, (q31_t)0x7b7881be, - (q31_t)0x7b76d97f, (q31_t)0x7b7530f3, (q31_t)0x7b73881b, (q31_t)0x7b71def7, (q31_t)0x7b703587, (q31_t)0x7b6e8bcb, (q31_t)0x7b6ce1c2, (q31_t)0x7b6b376e, - (q31_t)0x7b698ccd, (q31_t)0x7b67e1e0, (q31_t)0x7b6636a7, (q31_t)0x7b648b22, (q31_t)0x7b62df51, (q31_t)0x7b613334, (q31_t)0x7b5f86ca, (q31_t)0x7b5dda15, - (q31_t)0x7b5c2d13, (q31_t)0x7b5a7fc6, (q31_t)0x7b58d22c, (q31_t)0x7b572446, (q31_t)0x7b557614, (q31_t)0x7b53c796, (q31_t)0x7b5218cc, (q31_t)0x7b5069b6, - (q31_t)0x7b4eba53, (q31_t)0x7b4d0aa5, (q31_t)0x7b4b5aab, (q31_t)0x7b49aa64, (q31_t)0x7b47f9d2, (q31_t)0x7b4648f3, (q31_t)0x7b4497c9, (q31_t)0x7b42e652, - (q31_t)0x7b413490, (q31_t)0x7b3f8281, (q31_t)0x7b3dd026, (q31_t)0x7b3c1d80, (q31_t)0x7b3a6a8d, (q31_t)0x7b38b74e, (q31_t)0x7b3703c3, (q31_t)0x7b354fed, - (q31_t)0x7b339bca, (q31_t)0x7b31e75b, (q31_t)0x7b3032a0, (q31_t)0x7b2e7d9a, (q31_t)0x7b2cc847, (q31_t)0x7b2b12a8, (q31_t)0x7b295cbe, (q31_t)0x7b27a687, - (q31_t)0x7b25f004, (q31_t)0x7b243936, (q31_t)0x7b22821b, (q31_t)0x7b20cab5, (q31_t)0x7b1f1302, (q31_t)0x7b1d5b04, (q31_t)0x7b1ba2b9, (q31_t)0x7b19ea23, - (q31_t)0x7b183141, (q31_t)0x7b167813, (q31_t)0x7b14be99, (q31_t)0x7b1304d3, (q31_t)0x7b114ac1, (q31_t)0x7b0f9063, (q31_t)0x7b0dd5b9, (q31_t)0x7b0c1ac4, - (q31_t)0x7b0a5f82, (q31_t)0x7b08a3f5, (q31_t)0x7b06e81b, (q31_t)0x7b052bf6, (q31_t)0x7b036f85, (q31_t)0x7b01b2c8, (q31_t)0x7afff5bf, (q31_t)0x7afe386a, - (q31_t)0x7afc7aca, (q31_t)0x7afabcdd, (q31_t)0x7af8fea5, (q31_t)0x7af74021, (q31_t)0x7af58151, (q31_t)0x7af3c235, (q31_t)0x7af202cd, (q31_t)0x7af0431a, - (q31_t)0x7aee831a, (q31_t)0x7aecc2cf, (q31_t)0x7aeb0238, (q31_t)0x7ae94155, (q31_t)0x7ae78026, (q31_t)0x7ae5beac, (q31_t)0x7ae3fce6, (q31_t)0x7ae23ad4, - (q31_t)0x7ae07876, (q31_t)0x7adeb5cc, (q31_t)0x7adcf2d6, (q31_t)0x7adb2f95, (q31_t)0x7ad96c08, (q31_t)0x7ad7a82f, (q31_t)0x7ad5e40a, (q31_t)0x7ad41f9a, - (q31_t)0x7ad25ade, (q31_t)0x7ad095d6, (q31_t)0x7aced082, (q31_t)0x7acd0ae3, (q31_t)0x7acb44f8, (q31_t)0x7ac97ec1, (q31_t)0x7ac7b83e, (q31_t)0x7ac5f170, - (q31_t)0x7ac42a55, (q31_t)0x7ac262ef, (q31_t)0x7ac09b3e, (q31_t)0x7abed341, (q31_t)0x7abd0af7, (q31_t)0x7abb4263, (q31_t)0x7ab97982, (q31_t)0x7ab7b056, - (q31_t)0x7ab5e6de, (q31_t)0x7ab41d1b, (q31_t)0x7ab2530b, (q31_t)0x7ab088b0, (q31_t)0x7aaebe0a, (q31_t)0x7aacf318, (q31_t)0x7aab27da, (q31_t)0x7aa95c50, - (q31_t)0x7aa7907b, (q31_t)0x7aa5c45a, (q31_t)0x7aa3f7ed, (q31_t)0x7aa22b35, (q31_t)0x7aa05e31, (q31_t)0x7a9e90e1, (q31_t)0x7a9cc346, (q31_t)0x7a9af55f, - (q31_t)0x7a99272d, (q31_t)0x7a9758af, (q31_t)0x7a9589e5, (q31_t)0x7a93bad0, (q31_t)0x7a91eb6f, (q31_t)0x7a901bc2, (q31_t)0x7a8e4bca, (q31_t)0x7a8c7b87, - (q31_t)0x7a8aaaf7, (q31_t)0x7a88da1c, (q31_t)0x7a8708f6, (q31_t)0x7a853784, (q31_t)0x7a8365c6, (q31_t)0x7a8193bd, (q31_t)0x7a7fc168, (q31_t)0x7a7deec8, - (q31_t)0x7a7c1bdc, (q31_t)0x7a7a48a4, (q31_t)0x7a787521, (q31_t)0x7a76a153, (q31_t)0x7a74cd38, (q31_t)0x7a72f8d3, (q31_t)0x7a712422, (q31_t)0x7a6f4f25, - (q31_t)0x7a6d79dd, (q31_t)0x7a6ba449, (q31_t)0x7a69ce6a, (q31_t)0x7a67f83f, (q31_t)0x7a6621c9, (q31_t)0x7a644b07, (q31_t)0x7a6273fa, (q31_t)0x7a609ca1, - (q31_t)0x7a5ec4fc, (q31_t)0x7a5ced0d, (q31_t)0x7a5b14d1, (q31_t)0x7a593c4b, (q31_t)0x7a576379, (q31_t)0x7a558a5b, (q31_t)0x7a53b0f2, (q31_t)0x7a51d73d, - (q31_t)0x7a4ffd3d, (q31_t)0x7a4e22f2, (q31_t)0x7a4c485b, (q31_t)0x7a4a6d78, (q31_t)0x7a48924b, (q31_t)0x7a46b6d1, (q31_t)0x7a44db0d, (q31_t)0x7a42fefd, - (q31_t)0x7a4122a1, (q31_t)0x7a3f45fa, (q31_t)0x7a3d6908, (q31_t)0x7a3b8bca, (q31_t)0x7a39ae41, (q31_t)0x7a37d06d, (q31_t)0x7a35f24d, (q31_t)0x7a3413e2, - (q31_t)0x7a32352b, (q31_t)0x7a305629, (q31_t)0x7a2e76dc, (q31_t)0x7a2c9743, (q31_t)0x7a2ab75f, (q31_t)0x7a28d72f, (q31_t)0x7a26f6b4, (q31_t)0x7a2515ee, - (q31_t)0x7a2334dd, (q31_t)0x7a215380, (q31_t)0x7a1f71d7, (q31_t)0x7a1d8fe4, (q31_t)0x7a1bada5, (q31_t)0x7a19cb1b, (q31_t)0x7a17e845, (q31_t)0x7a160524, - (q31_t)0x7a1421b8, (q31_t)0x7a123e01, (q31_t)0x7a1059fe, (q31_t)0x7a0e75b0, (q31_t)0x7a0c9117, (q31_t)0x7a0aac32, (q31_t)0x7a08c702, (q31_t)0x7a06e187, - (q31_t)0x7a04fbc1, (q31_t)0x7a0315af, (q31_t)0x7a012f52, (q31_t)0x79ff48aa, (q31_t)0x79fd61b6, (q31_t)0x79fb7a77, (q31_t)0x79f992ed, (q31_t)0x79f7ab18, - (q31_t)0x79f5c2f8, (q31_t)0x79f3da8c, (q31_t)0x79f1f1d5, (q31_t)0x79f008d3, (q31_t)0x79ee1f86, (q31_t)0x79ec35ed, (q31_t)0x79ea4c09, (q31_t)0x79e861da, - (q31_t)0x79e67760, (q31_t)0x79e48c9b, (q31_t)0x79e2a18a, (q31_t)0x79e0b62e, (q31_t)0x79deca87, (q31_t)0x79dcde95, (q31_t)0x79daf258, (q31_t)0x79d905d0, - (q31_t)0x79d718fc, (q31_t)0x79d52bdd, (q31_t)0x79d33e73, (q31_t)0x79d150be, (q31_t)0x79cf62be, (q31_t)0x79cd7473, (q31_t)0x79cb85dc, (q31_t)0x79c996fb, - (q31_t)0x79c7a7ce, (q31_t)0x79c5b856, (q31_t)0x79c3c893, (q31_t)0x79c1d885, (q31_t)0x79bfe82c, (q31_t)0x79bdf788, (q31_t)0x79bc0698, (q31_t)0x79ba155e, - (q31_t)0x79b823d8, (q31_t)0x79b63207, (q31_t)0x79b43fec, (q31_t)0x79b24d85, (q31_t)0x79b05ad3, (q31_t)0x79ae67d6, (q31_t)0x79ac748e, (q31_t)0x79aa80fb, - (q31_t)0x79a88d1d, (q31_t)0x79a698f4, (q31_t)0x79a4a480, (q31_t)0x79a2afc1, (q31_t)0x79a0bab6, (q31_t)0x799ec561, (q31_t)0x799ccfc1, (q31_t)0x799ad9d5, - (q31_t)0x7998e39f, (q31_t)0x7996ed1e, (q31_t)0x7994f651, (q31_t)0x7992ff3a, (q31_t)0x799107d8, (q31_t)0x798f102a, (q31_t)0x798d1832, (q31_t)0x798b1fef, - (q31_t)0x79892761, (q31_t)0x79872e87, (q31_t)0x79853563, (q31_t)0x79833bf4, (q31_t)0x7981423a, (q31_t)0x797f4835, (q31_t)0x797d4de5, (q31_t)0x797b534a, - (q31_t)0x79795864, (q31_t)0x79775d33, (q31_t)0x797561b8, (q31_t)0x797365f1, (q31_t)0x797169df, (q31_t)0x796f6d83, (q31_t)0x796d70dc, (q31_t)0x796b73e9, - (q31_t)0x796976ac, (q31_t)0x79677924, (q31_t)0x79657b51, (q31_t)0x79637d33, (q31_t)0x79617eca, (q31_t)0x795f8017, (q31_t)0x795d8118, (q31_t)0x795b81cf, - (q31_t)0x7959823b, (q31_t)0x7957825c, (q31_t)0x79558232, (q31_t)0x795381bd, (q31_t)0x795180fe, (q31_t)0x794f7ff3, (q31_t)0x794d7e9e, (q31_t)0x794b7cfe, - (q31_t)0x79497b13, (q31_t)0x794778dd, (q31_t)0x7945765d, (q31_t)0x79437391, (q31_t)0x7941707b, (q31_t)0x793f6d1a, (q31_t)0x793d696f, (q31_t)0x793b6578, - (q31_t)0x79396137, (q31_t)0x79375cab, (q31_t)0x793557d4, (q31_t)0x793352b2, (q31_t)0x79314d46, (q31_t)0x792f478f, (q31_t)0x792d418d, (q31_t)0x792b3b40, - (q31_t)0x792934a9, (q31_t)0x79272dc7, (q31_t)0x7925269a, (q31_t)0x79231f22, (q31_t)0x79211760, (q31_t)0x791f0f53, (q31_t)0x791d06fb, (q31_t)0x791afe59, - (q31_t)0x7918f56c, (q31_t)0x7916ec34, (q31_t)0x7914e2b2, (q31_t)0x7912d8e4, (q31_t)0x7910cecc, (q31_t)0x790ec46a, (q31_t)0x790cb9bd, (q31_t)0x790aaec5, - (q31_t)0x7908a382, (q31_t)0x790697f5, (q31_t)0x79048c1d, (q31_t)0x79027ffa, (q31_t)0x7900738d, (q31_t)0x78fe66d5, (q31_t)0x78fc59d3, (q31_t)0x78fa4c86, - (q31_t)0x78f83eee, (q31_t)0x78f6310c, (q31_t)0x78f422df, (q31_t)0x78f21467, (q31_t)0x78f005a5, (q31_t)0x78edf698, (q31_t)0x78ebe741, (q31_t)0x78e9d79f, - (q31_t)0x78e7c7b2, (q31_t)0x78e5b77b, (q31_t)0x78e3a6f9, (q31_t)0x78e1962d, (q31_t)0x78df8516, (q31_t)0x78dd73b5, (q31_t)0x78db6209, (q31_t)0x78d95012, - (q31_t)0x78d73dd1, (q31_t)0x78d52b46, (q31_t)0x78d31870, (q31_t)0x78d1054f, (q31_t)0x78cef1e4, (q31_t)0x78ccde2e, (q31_t)0x78caca2e, (q31_t)0x78c8b5e3, - (q31_t)0x78c6a14e, (q31_t)0x78c48c6e, (q31_t)0x78c27744, (q31_t)0x78c061cf, (q31_t)0x78be4c10, (q31_t)0x78bc3606, (q31_t)0x78ba1fb2, (q31_t)0x78b80913, - (q31_t)0x78b5f22a, (q31_t)0x78b3daf7, (q31_t)0x78b1c379, (q31_t)0x78afabb0, (q31_t)0x78ad939d, (q31_t)0x78ab7b40, (q31_t)0x78a96298, (q31_t)0x78a749a6, - (q31_t)0x78a53069, (q31_t)0x78a316e2, (q31_t)0x78a0fd11, (q31_t)0x789ee2f5, (q31_t)0x789cc88f, (q31_t)0x789aadde, (q31_t)0x789892e3, (q31_t)0x7896779d, - (q31_t)0x78945c0d, (q31_t)0x78924033, (q31_t)0x7890240e, (q31_t)0x788e07a0, (q31_t)0x788beae6, (q31_t)0x7889cde2, (q31_t)0x7887b094, (q31_t)0x788592fc, - (q31_t)0x78837519, (q31_t)0x788156ec, (q31_t)0x787f3875, (q31_t)0x787d19b3, (q31_t)0x787afaa7, (q31_t)0x7878db50, (q31_t)0x7876bbb0, (q31_t)0x78749bc5, - (q31_t)0x78727b8f, (q31_t)0x78705b10, (q31_t)0x786e3a46, (q31_t)0x786c1932, (q31_t)0x7869f7d3, (q31_t)0x7867d62a, (q31_t)0x7865b437, (q31_t)0x786391fa, - (q31_t)0x78616f72, (q31_t)0x785f4ca1, (q31_t)0x785d2984, (q31_t)0x785b061e, (q31_t)0x7858e26e, (q31_t)0x7856be73, (q31_t)0x78549a2e, (q31_t)0x7852759e, - (q31_t)0x785050c5, (q31_t)0x784e2ba1, (q31_t)0x784c0633, (q31_t)0x7849e07b, (q31_t)0x7847ba79, (q31_t)0x7845942c, (q31_t)0x78436d96, (q31_t)0x784146b5, - (q31_t)0x783f1f8a, (q31_t)0x783cf815, (q31_t)0x783ad055, (q31_t)0x7838a84c, (q31_t)0x78367ff8, (q31_t)0x7834575a, (q31_t)0x78322e72, (q31_t)0x78300540, - (q31_t)0x782ddbc4, (q31_t)0x782bb1fd, (q31_t)0x782987ed, (q31_t)0x78275d92, (q31_t)0x782532ed, (q31_t)0x782307fe, (q31_t)0x7820dcc5, (q31_t)0x781eb142, - (q31_t)0x781c8575, (q31_t)0x781a595d, (q31_t)0x78182cfc, (q31_t)0x78160051, (q31_t)0x7813d35b, (q31_t)0x7811a61b, (q31_t)0x780f7892, (q31_t)0x780d4abe, - (q31_t)0x780b1ca0, (q31_t)0x7808ee38, (q31_t)0x7806bf86, (q31_t)0x7804908a, (q31_t)0x78026145, (q31_t)0x780031b5, (q31_t)0x77fe01db, (q31_t)0x77fbd1b6, - (q31_t)0x77f9a148, (q31_t)0x77f77090, (q31_t)0x77f53f8e, (q31_t)0x77f30e42, (q31_t)0x77f0dcac, (q31_t)0x77eeaacc, (q31_t)0x77ec78a2, (q31_t)0x77ea462e, - (q31_t)0x77e81370, (q31_t)0x77e5e068, (q31_t)0x77e3ad17, (q31_t)0x77e1797b, (q31_t)0x77df4595, (q31_t)0x77dd1165, (q31_t)0x77dadcec, (q31_t)0x77d8a828, - (q31_t)0x77d6731a, (q31_t)0x77d43dc3, (q31_t)0x77d20822, (q31_t)0x77cfd236, (q31_t)0x77cd9c01, (q31_t)0x77cb6582, (q31_t)0x77c92eb9, (q31_t)0x77c6f7a6, - (q31_t)0x77c4c04a, (q31_t)0x77c288a3, (q31_t)0x77c050b2, (q31_t)0x77be1878, (q31_t)0x77bbdff4, (q31_t)0x77b9a726, (q31_t)0x77b76e0e, (q31_t)0x77b534ac, - (q31_t)0x77b2fb00, (q31_t)0x77b0c10b, (q31_t)0x77ae86cc, (q31_t)0x77ac4c43, (q31_t)0x77aa1170, (q31_t)0x77a7d653, (q31_t)0x77a59aec, (q31_t)0x77a35f3c, - (q31_t)0x77a12342, (q31_t)0x779ee6fe, (q31_t)0x779caa70, (q31_t)0x779a6d99, (q31_t)0x77983077, (q31_t)0x7795f30c, (q31_t)0x7793b557, (q31_t)0x77917759, - (q31_t)0x778f3910, (q31_t)0x778cfa7e, (q31_t)0x778abba2, (q31_t)0x77887c7d, (q31_t)0x77863d0d, (q31_t)0x7783fd54, (q31_t)0x7781bd52, (q31_t)0x777f7d05, - (q31_t)0x777d3c6f, (q31_t)0x777afb8f, (q31_t)0x7778ba65, (q31_t)0x777678f2, (q31_t)0x77743735, (q31_t)0x7771f52e, (q31_t)0x776fb2de, (q31_t)0x776d7044, - (q31_t)0x776b2d60, (q31_t)0x7768ea33, (q31_t)0x7766a6bc, (q31_t)0x776462fb, (q31_t)0x77621ef1, (q31_t)0x775fda9d, (q31_t)0x775d95ff, (q31_t)0x775b5118, - (q31_t)0x77590be7, (q31_t)0x7756c66c, (q31_t)0x775480a8, (q31_t)0x77523a9b, (q31_t)0x774ff443, (q31_t)0x774dada2, (q31_t)0x774b66b8, (q31_t)0x77491f84, - (q31_t)0x7746d806, (q31_t)0x7744903f, (q31_t)0x7742482e, (q31_t)0x773fffd4, (q31_t)0x773db730, (q31_t)0x773b6e42, (q31_t)0x7739250b, (q31_t)0x7736db8b, - (q31_t)0x773491c0, (q31_t)0x773247ad, (q31_t)0x772ffd50, (q31_t)0x772db2a9, (q31_t)0x772b67b9, (q31_t)0x77291c7f, (q31_t)0x7726d0fc, (q31_t)0x7724852f, - (q31_t)0x77223919, (q31_t)0x771fecb9, (q31_t)0x771da010, (q31_t)0x771b531d, (q31_t)0x771905e1, (q31_t)0x7716b85b, (q31_t)0x77146a8c, (q31_t)0x77121c74, - (q31_t)0x770fce12, (q31_t)0x770d7f66, (q31_t)0x770b3072, (q31_t)0x7708e133, (q31_t)0x770691ab, (q31_t)0x770441da, (q31_t)0x7701f1c0, (q31_t)0x76ffa15c, - (q31_t)0x76fd50ae, (q31_t)0x76faffb8, (q31_t)0x76f8ae78, (q31_t)0x76f65cee, (q31_t)0x76f40b1b, (q31_t)0x76f1b8ff, (q31_t)0x76ef6699, (q31_t)0x76ed13ea, - (q31_t)0x76eac0f2, (q31_t)0x76e86db0, (q31_t)0x76e61a25, (q31_t)0x76e3c650, (q31_t)0x76e17233, (q31_t)0x76df1dcb, (q31_t)0x76dcc91b, (q31_t)0x76da7421, - (q31_t)0x76d81ede, (q31_t)0x76d5c952, (q31_t)0x76d3737c, (q31_t)0x76d11d5d, (q31_t)0x76cec6f5, (q31_t)0x76cc7043, (q31_t)0x76ca1948, (q31_t)0x76c7c204, - (q31_t)0x76c56a77, (q31_t)0x76c312a0, (q31_t)0x76c0ba80, (q31_t)0x76be6217, (q31_t)0x76bc0965, (q31_t)0x76b9b069, (q31_t)0x76b75724, (q31_t)0x76b4fd96, - (q31_t)0x76b2a3bf, (q31_t)0x76b0499e, (q31_t)0x76adef34, (q31_t)0x76ab9481, (q31_t)0x76a93985, (q31_t)0x76a6de40, (q31_t)0x76a482b1, (q31_t)0x76a226da, - (q31_t)0x769fcab9, (q31_t)0x769d6e4f, (q31_t)0x769b119b, (q31_t)0x7698b49f, (q31_t)0x76965759, (q31_t)0x7693f9ca, (q31_t)0x76919bf3, (q31_t)0x768f3dd2, - (q31_t)0x768cdf67, (q31_t)0x768a80b4, (q31_t)0x768821b8, (q31_t)0x7685c272, (q31_t)0x768362e4, (q31_t)0x7681030c, (q31_t)0x767ea2eb, (q31_t)0x767c4281, - (q31_t)0x7679e1ce, (q31_t)0x767780d2, (q31_t)0x76751f8d, (q31_t)0x7672bdfe, (q31_t)0x76705c27, (q31_t)0x766dfa07, (q31_t)0x766b979d, (q31_t)0x766934eb, - (q31_t)0x7666d1ef, (q31_t)0x76646eab, (q31_t)0x76620b1d, (q31_t)0x765fa747, (q31_t)0x765d4327, (q31_t)0x765adebe, (q31_t)0x76587a0d, (q31_t)0x76561512, - (q31_t)0x7653afce, (q31_t)0x76514a42, (q31_t)0x764ee46c, (q31_t)0x764c7e4d, (q31_t)0x764a17e6, (q31_t)0x7647b135, (q31_t)0x76454a3c, (q31_t)0x7642e2f9, - (q31_t)0x76407b6e, (q31_t)0x763e139a, (q31_t)0x763bab7c, (q31_t)0x76394316, (q31_t)0x7636da67, (q31_t)0x7634716f, (q31_t)0x7632082e, (q31_t)0x762f9ea4, - (q31_t)0x762d34d1, (q31_t)0x762acab6, (q31_t)0x76286051, (q31_t)0x7625f5a3, (q31_t)0x76238aad, (q31_t)0x76211f6e, (q31_t)0x761eb3e6, (q31_t)0x761c4815, - (q31_t)0x7619dbfb, (q31_t)0x76176f98, (q31_t)0x761502ed, (q31_t)0x761295f9, (q31_t)0x761028bb, (q31_t)0x760dbb35, (q31_t)0x760b4d67, (q31_t)0x7608df4f, - (q31_t)0x760670ee, (q31_t)0x76040245, (q31_t)0x76019353, (q31_t)0x75ff2418, (q31_t)0x75fcb495, (q31_t)0x75fa44c8, (q31_t)0x75f7d4b3, (q31_t)0x75f56455, - (q31_t)0x75f2f3ae, (q31_t)0x75f082bf, (q31_t)0x75ee1187, (q31_t)0x75eba006, (q31_t)0x75e92e3c, (q31_t)0x75e6bc2a, (q31_t)0x75e449ce, (q31_t)0x75e1d72b, - (q31_t)0x75df643e, (q31_t)0x75dcf109, (q31_t)0x75da7d8b, (q31_t)0x75d809c4, (q31_t)0x75d595b4, (q31_t)0x75d3215c, (q31_t)0x75d0acbc, (q31_t)0x75ce37d2, - (q31_t)0x75cbc2a0, (q31_t)0x75c94d25, (q31_t)0x75c6d762, (q31_t)0x75c46156, (q31_t)0x75c1eb01, (q31_t)0x75bf7464, (q31_t)0x75bcfd7e, (q31_t)0x75ba864f, - (q31_t)0x75b80ed8, (q31_t)0x75b59718, (q31_t)0x75b31f0f, (q31_t)0x75b0a6be, (q31_t)0x75ae2e25, (q31_t)0x75abb542, (q31_t)0x75a93c18, (q31_t)0x75a6c2a4, - (q31_t)0x75a448e8, (q31_t)0x75a1cee4, (q31_t)0x759f5496, (q31_t)0x759cda01, (q31_t)0x759a5f22, (q31_t)0x7597e3fc, (q31_t)0x7595688c, (q31_t)0x7592ecd4, - (q31_t)0x759070d4, (q31_t)0x758df48b, (q31_t)0x758b77fa, (q31_t)0x7588fb20, (q31_t)0x75867dfd, (q31_t)0x75840093, (q31_t)0x758182df, (q31_t)0x757f04e3, - (q31_t)0x757c869f, (q31_t)0x757a0812, (q31_t)0x7577893d, (q31_t)0x75750a1f, (q31_t)0x75728ab9, (q31_t)0x75700b0a, (q31_t)0x756d8b13, (q31_t)0x756b0ad3, - (q31_t)0x75688a4b, (q31_t)0x7566097b, (q31_t)0x75638862, (q31_t)0x75610701, (q31_t)0x755e8557, (q31_t)0x755c0365, (q31_t)0x7559812b, (q31_t)0x7556fea8, - (q31_t)0x75547bdd, (q31_t)0x7551f8c9, (q31_t)0x754f756e, (q31_t)0x754cf1c9, (q31_t)0x754a6ddd, (q31_t)0x7547e9a8, (q31_t)0x7545652a, (q31_t)0x7542e065, - (q31_t)0x75405b57, (q31_t)0x753dd600, (q31_t)0x753b5061, (q31_t)0x7538ca7b, (q31_t)0x7536444b, (q31_t)0x7533bdd4, (q31_t)0x75313714, (q31_t)0x752eb00c, - (q31_t)0x752c28bb, (q31_t)0x7529a122, (q31_t)0x75271941, (q31_t)0x75249118, (q31_t)0x752208a7, (q31_t)0x751f7fed, (q31_t)0x751cf6eb, (q31_t)0x751a6da0, - (q31_t)0x7517e40e, (q31_t)0x75155a33, (q31_t)0x7512d010, (q31_t)0x751045a5, (q31_t)0x750dbaf2, (q31_t)0x750b2ff6, (q31_t)0x7508a4b2, (q31_t)0x75061926, - (q31_t)0x75038d52, (q31_t)0x75010136, (q31_t)0x74fe74d1, (q31_t)0x74fbe825, (q31_t)0x74f95b30, (q31_t)0x74f6cdf3, (q31_t)0x74f4406d, (q31_t)0x74f1b2a0, - (q31_t)0x74ef248b, (q31_t)0x74ec962d, (q31_t)0x74ea0787, (q31_t)0x74e7789a, (q31_t)0x74e4e964, (q31_t)0x74e259e6, (q31_t)0x74dfca20, (q31_t)0x74dd3a11, - (q31_t)0x74daa9bb, (q31_t)0x74d8191d, (q31_t)0x74d58836, (q31_t)0x74d2f708, (q31_t)0x74d06591, (q31_t)0x74cdd3d2, (q31_t)0x74cb41cc, (q31_t)0x74c8af7d, - (q31_t)0x74c61ce6, (q31_t)0x74c38a07, (q31_t)0x74c0f6e0, (q31_t)0x74be6372, (q31_t)0x74bbcfbb, (q31_t)0x74b93bbc, (q31_t)0x74b6a775, (q31_t)0x74b412e6, - (q31_t)0x74b17e0f, (q31_t)0x74aee8f0, (q31_t)0x74ac5389, (q31_t)0x74a9bddb, (q31_t)0x74a727e4, (q31_t)0x74a491a5, (q31_t)0x74a1fb1e, (q31_t)0x749f6450, - (q31_t)0x749ccd39, (q31_t)0x749a35db, (q31_t)0x74979e34, (q31_t)0x74950646, (q31_t)0x74926e10, (q31_t)0x748fd592, (q31_t)0x748d3ccb, (q31_t)0x748aa3be, - (q31_t)0x74880a68, (q31_t)0x748570ca, (q31_t)0x7482d6e4, (q31_t)0x74803cb7, (q31_t)0x747da242, (q31_t)0x747b0784, (q31_t)0x74786c7f, (q31_t)0x7475d132, - (q31_t)0x7473359e, (q31_t)0x747099c1, (q31_t)0x746dfd9d, (q31_t)0x746b6131, (q31_t)0x7468c47c, (q31_t)0x74662781, (q31_t)0x74638a3d, (q31_t)0x7460ecb2, - (q31_t)0x745e4ede, (q31_t)0x745bb0c3, (q31_t)0x74591261, (q31_t)0x745673b6, (q31_t)0x7453d4c4, (q31_t)0x7451358a, (q31_t)0x744e9608, (q31_t)0x744bf63e, - (q31_t)0x7449562d, (q31_t)0x7446b5d4, (q31_t)0x74441533, (q31_t)0x7441744b, (q31_t)0x743ed31b, (q31_t)0x743c31a3, (q31_t)0x74398fe3, (q31_t)0x7436eddc, - (q31_t)0x74344b8d, (q31_t)0x7431a8f6, (q31_t)0x742f0618, (q31_t)0x742c62f2, (q31_t)0x7429bf84, (q31_t)0x74271bcf, (q31_t)0x742477d2, (q31_t)0x7421d38e, - (q31_t)0x741f2f01, (q31_t)0x741c8a2d, (q31_t)0x7419e512, (q31_t)0x74173faf, (q31_t)0x74149a04, (q31_t)0x7411f412, (q31_t)0x740f4dd8, (q31_t)0x740ca756, - (q31_t)0x740a008d, (q31_t)0x7407597d, (q31_t)0x7404b224, (q31_t)0x74020a85, (q31_t)0x73ff629d, (q31_t)0x73fcba6e, (q31_t)0x73fa11f8, (q31_t)0x73f7693a, - (q31_t)0x73f4c034, (q31_t)0x73f216e7, (q31_t)0x73ef6d53, (q31_t)0x73ecc377, (q31_t)0x73ea1953, (q31_t)0x73e76ee8, (q31_t)0x73e4c435, (q31_t)0x73e2193b, - (q31_t)0x73df6df9, (q31_t)0x73dcc270, (q31_t)0x73da16a0, (q31_t)0x73d76a88, (q31_t)0x73d4be28, (q31_t)0x73d21182, (q31_t)0x73cf6493, (q31_t)0x73ccb75d, - (q31_t)0x73ca09e0, (q31_t)0x73c75c1c, (q31_t)0x73c4ae10, (q31_t)0x73c1ffbc, (q31_t)0x73bf5121, (q31_t)0x73bca23f, (q31_t)0x73b9f315, (q31_t)0x73b743a4, - (q31_t)0x73b493ec, (q31_t)0x73b1e3ec, (q31_t)0x73af33a5, (q31_t)0x73ac8316, (q31_t)0x73a9d240, (q31_t)0x73a72123, (q31_t)0x73a46fbf, (q31_t)0x73a1be13, - (q31_t)0x739f0c20, (q31_t)0x739c59e5, (q31_t)0x7399a763, (q31_t)0x7396f49a, (q31_t)0x73944189, (q31_t)0x73918e32, (q31_t)0x738eda93, (q31_t)0x738c26ac, - (q31_t)0x7389727f, (q31_t)0x7386be0a, (q31_t)0x7384094e, (q31_t)0x7381544a, (q31_t)0x737e9f00, (q31_t)0x737be96e, (q31_t)0x73793395, (q31_t)0x73767d74, - (q31_t)0x7373c70d, (q31_t)0x7371105e, (q31_t)0x736e5968, (q31_t)0x736ba22b, (q31_t)0x7368eaa6, (q31_t)0x736632db, (q31_t)0x73637ac8, (q31_t)0x7360c26e, - (q31_t)0x735e09cd, (q31_t)0x735b50e4, (q31_t)0x735897b5, (q31_t)0x7355de3e, (q31_t)0x73532481, (q31_t)0x73506a7c, (q31_t)0x734db030, (q31_t)0x734af59d, - (q31_t)0x73483ac2, (q31_t)0x73457fa1, (q31_t)0x7342c438, (q31_t)0x73400889, (q31_t)0x733d4c92, (q31_t)0x733a9054, (q31_t)0x7337d3d0, (q31_t)0x73351704, - (q31_t)0x733259f1, (q31_t)0x732f9c97, (q31_t)0x732cdef6, (q31_t)0x732a210d, (q31_t)0x732762de, (q31_t)0x7324a468, (q31_t)0x7321e5ab, (q31_t)0x731f26a7, - (q31_t)0x731c675b, (q31_t)0x7319a7c9, (q31_t)0x7316e7f0, (q31_t)0x731427cf, (q31_t)0x73116768, (q31_t)0x730ea6ba, (q31_t)0x730be5c5, (q31_t)0x73092489, - (q31_t)0x73066306, (q31_t)0x7303a13b, (q31_t)0x7300df2a, (q31_t)0x72fe1cd2, (q31_t)0x72fb5a34, (q31_t)0x72f8974e, (q31_t)0x72f5d421, (q31_t)0x72f310ad, - (q31_t)0x72f04cf3, (q31_t)0x72ed88f1, (q31_t)0x72eac4a9, (q31_t)0x72e8001a, (q31_t)0x72e53b44, (q31_t)0x72e27627, (q31_t)0x72dfb0c3, (q31_t)0x72dceb18, - (q31_t)0x72da2526, (q31_t)0x72d75eee, (q31_t)0x72d4986f, (q31_t)0x72d1d1a9, (q31_t)0x72cf0a9c, (q31_t)0x72cc4348, (q31_t)0x72c97bad, (q31_t)0x72c6b3cc, - (q31_t)0x72c3eba4, (q31_t)0x72c12335, (q31_t)0x72be5a7f, (q31_t)0x72bb9183, (q31_t)0x72b8c83f, (q31_t)0x72b5feb5, (q31_t)0x72b334e4, (q31_t)0x72b06acd, - (q31_t)0x72ada06f, (q31_t)0x72aad5c9, (q31_t)0x72a80ade, (q31_t)0x72a53fab, (q31_t)0x72a27432, (q31_t)0x729fa872, (q31_t)0x729cdc6b, (q31_t)0x729a101e, - (q31_t)0x7297438a, (q31_t)0x729476af, (q31_t)0x7291a98e, (q31_t)0x728edc26, (q31_t)0x728c0e77, (q31_t)0x72894082, (q31_t)0x72867245, (q31_t)0x7283a3c3, - (q31_t)0x7280d4f9, (q31_t)0x727e05e9, (q31_t)0x727b3693, (q31_t)0x727866f6, (q31_t)0x72759712, (q31_t)0x7272c6e7, (q31_t)0x726ff676, (q31_t)0x726d25bf, - (q31_t)0x726a54c1, (q31_t)0x7267837c, (q31_t)0x7264b1f0, (q31_t)0x7261e01e, (q31_t)0x725f0e06, (q31_t)0x725c3ba7, (q31_t)0x72596901, (q31_t)0x72569615, - (q31_t)0x7253c2e3, (q31_t)0x7250ef6a, (q31_t)0x724e1baa, (q31_t)0x724b47a4, (q31_t)0x72487357, (q31_t)0x72459ec4, (q31_t)0x7242c9ea, (q31_t)0x723ff4ca, - (q31_t)0x723d1f63, (q31_t)0x723a49b6, (q31_t)0x723773c3, (q31_t)0x72349d89, (q31_t)0x7231c708, (q31_t)0x722ef041, (q31_t)0x722c1934, (q31_t)0x722941e0, - (q31_t)0x72266a46, (q31_t)0x72239266, (q31_t)0x7220ba3f, (q31_t)0x721de1d1, (q31_t)0x721b091d, (q31_t)0x72183023, (q31_t)0x721556e3, (q31_t)0x72127d5c, - (q31_t)0x720fa38e, (q31_t)0x720cc97b, (q31_t)0x7209ef21, (q31_t)0x72071480, (q31_t)0x7204399a, (q31_t)0x72015e6d, (q31_t)0x71fe82f9, (q31_t)0x71fba740, - (q31_t)0x71f8cb40, (q31_t)0x71f5eefa, (q31_t)0x71f3126d, (q31_t)0x71f0359a, (q31_t)0x71ed5881, (q31_t)0x71ea7b22, (q31_t)0x71e79d7c, (q31_t)0x71e4bf90, - (q31_t)0x71e1e15e, (q31_t)0x71df02e5, (q31_t)0x71dc2427, (q31_t)0x71d94522, (q31_t)0x71d665d6, (q31_t)0x71d38645, (q31_t)0x71d0a66d, (q31_t)0x71cdc650, - (q31_t)0x71cae5ec, (q31_t)0x71c80542, (q31_t)0x71c52451, (q31_t)0x71c2431b, (q31_t)0x71bf619e, (q31_t)0x71bc7fdb, (q31_t)0x71b99dd2, (q31_t)0x71b6bb83, - (q31_t)0x71b3d8ed, (q31_t)0x71b0f612, (q31_t)0x71ae12f0, (q31_t)0x71ab2f89, (q31_t)0x71a84bdb, (q31_t)0x71a567e7, (q31_t)0x71a283ad, (q31_t)0x719f9f2c, - (q31_t)0x719cba66, (q31_t)0x7199d55a, (q31_t)0x7196f008, (q31_t)0x71940a6f, (q31_t)0x71912490, (q31_t)0x718e3e6c, (q31_t)0x718b5801, (q31_t)0x71887151, - (q31_t)0x71858a5a, (q31_t)0x7182a31d, (q31_t)0x717fbb9a, (q31_t)0x717cd3d2, (q31_t)0x7179ebc3, (q31_t)0x7177036e, (q31_t)0x71741ad3, (q31_t)0x717131f3, - (q31_t)0x716e48cc, (q31_t)0x716b5f5f, (q31_t)0x716875ad, (q31_t)0x71658bb4, (q31_t)0x7162a175, (q31_t)0x715fb6f1, (q31_t)0x715ccc26, (q31_t)0x7159e116, - (q31_t)0x7156f5c0, (q31_t)0x71540a24, (q31_t)0x71511e42, (q31_t)0x714e321a, (q31_t)0x714b45ac, (q31_t)0x714858f8, (q31_t)0x71456bfe, (q31_t)0x71427ebf, - (q31_t)0x713f9139, (q31_t)0x713ca36e, (q31_t)0x7139b55d, (q31_t)0x7136c706, (q31_t)0x7133d869, (q31_t)0x7130e987, (q31_t)0x712dfa5e, (q31_t)0x712b0af0, - (q31_t)0x71281b3c, (q31_t)0x71252b42, (q31_t)0x71223b02, (q31_t)0x711f4a7d, (q31_t)0x711c59b2, (q31_t)0x711968a1, (q31_t)0x7116774a, (q31_t)0x711385ad, - (q31_t)0x711093cb, (q31_t)0x710da1a3, (q31_t)0x710aaf35, (q31_t)0x7107bc82, (q31_t)0x7104c989, (q31_t)0x7101d64a, (q31_t)0x70fee2c5, (q31_t)0x70fbeefb, - (q31_t)0x70f8faeb, (q31_t)0x70f60695, (q31_t)0x70f311fa, (q31_t)0x70f01d19, (q31_t)0x70ed27f2, (q31_t)0x70ea3286, (q31_t)0x70e73cd4, (q31_t)0x70e446dc, - (q31_t)0x70e1509f, (q31_t)0x70de5a1c, (q31_t)0x70db6353, (q31_t)0x70d86c45, (q31_t)0x70d574f1, (q31_t)0x70d27d58, (q31_t)0x70cf8579, (q31_t)0x70cc8d54, - (q31_t)0x70c994ea, (q31_t)0x70c69c3a, (q31_t)0x70c3a345, (q31_t)0x70c0aa0a, (q31_t)0x70bdb08a, (q31_t)0x70bab6c4, (q31_t)0x70b7bcb8, (q31_t)0x70b4c267, - (q31_t)0x70b1c7d1, (q31_t)0x70aeccf5, (q31_t)0x70abd1d3, (q31_t)0x70a8d66c, (q31_t)0x70a5dac0, (q31_t)0x70a2dece, (q31_t)0x709fe296, (q31_t)0x709ce619, - (q31_t)0x7099e957, (q31_t)0x7096ec4f, (q31_t)0x7093ef01, (q31_t)0x7090f16e, (q31_t)0x708df396, (q31_t)0x708af579, (q31_t)0x7087f715, (q31_t)0x7084f86d, - (q31_t)0x7081f97f, (q31_t)0x707efa4c, (q31_t)0x707bfad3, (q31_t)0x7078fb15, (q31_t)0x7075fb11, (q31_t)0x7072fac9, (q31_t)0x706ffa3a, (q31_t)0x706cf967, - (q31_t)0x7069f84e, (q31_t)0x7066f6f0, (q31_t)0x7063f54c, (q31_t)0x7060f363, (q31_t)0x705df135, (q31_t)0x705aeec1, (q31_t)0x7057ec08, (q31_t)0x7054e90a, - (q31_t)0x7051e5c7, (q31_t)0x704ee23e, (q31_t)0x704bde70, (q31_t)0x7048da5d, (q31_t)0x7045d604, (q31_t)0x7042d166, (q31_t)0x703fcc83, (q31_t)0x703cc75b, - (q31_t)0x7039c1ed, (q31_t)0x7036bc3b, (q31_t)0x7033b643, (q31_t)0x7030b005, (q31_t)0x702da983, (q31_t)0x702aa2bb, (q31_t)0x70279baf, (q31_t)0x7024945d, - (q31_t)0x70218cc6, (q31_t)0x701e84e9, (q31_t)0x701b7cc8, (q31_t)0x70187461, (q31_t)0x70156bb5, (q31_t)0x701262c4, (q31_t)0x700f598e, (q31_t)0x700c5013, - (q31_t)0x70094653, (q31_t)0x70063c4e, (q31_t)0x70033203, (q31_t)0x70002774, (q31_t)0x6ffd1c9f, (q31_t)0x6ffa1185, (q31_t)0x6ff70626, (q31_t)0x6ff3fa82, - (q31_t)0x6ff0ee99, (q31_t)0x6fede26b, (q31_t)0x6fead5f8, (q31_t)0x6fe7c940, (q31_t)0x6fe4bc43, (q31_t)0x6fe1af01, (q31_t)0x6fdea17a, (q31_t)0x6fdb93ae, - (q31_t)0x6fd8859d, (q31_t)0x6fd57746, (q31_t)0x6fd268ab, (q31_t)0x6fcf59cb, (q31_t)0x6fcc4aa6, (q31_t)0x6fc93b3c, (q31_t)0x6fc62b8d, (q31_t)0x6fc31b99, - (q31_t)0x6fc00b60, (q31_t)0x6fbcfae2, (q31_t)0x6fb9ea20, (q31_t)0x6fb6d918, (q31_t)0x6fb3c7cb, (q31_t)0x6fb0b63a, (q31_t)0x6fada464, (q31_t)0x6faa9248, - (q31_t)0x6fa77fe8, (q31_t)0x6fa46d43, (q31_t)0x6fa15a59, (q31_t)0x6f9e472b, (q31_t)0x6f9b33b7, (q31_t)0x6f981fff, (q31_t)0x6f950c01, (q31_t)0x6f91f7bf, - (q31_t)0x6f8ee338, (q31_t)0x6f8bce6c, (q31_t)0x6f88b95c, (q31_t)0x6f85a407, (q31_t)0x6f828e6c, (q31_t)0x6f7f788d, (q31_t)0x6f7c626a, (q31_t)0x6f794c01, - (q31_t)0x6f763554, (q31_t)0x6f731e62, (q31_t)0x6f70072b, (q31_t)0x6f6cefb0, (q31_t)0x6f69d7f0, (q31_t)0x6f66bfeb, (q31_t)0x6f63a7a1, (q31_t)0x6f608f13, - (q31_t)0x6f5d7640, (q31_t)0x6f5a5d28, (q31_t)0x6f5743cb, (q31_t)0x6f542a2a, (q31_t)0x6f511044, (q31_t)0x6f4df61a, (q31_t)0x6f4adbab, (q31_t)0x6f47c0f7, - (q31_t)0x6f44a5ff, (q31_t)0x6f418ac2, (q31_t)0x6f3e6f40, (q31_t)0x6f3b537a, (q31_t)0x6f38376f, (q31_t)0x6f351b1f, (q31_t)0x6f31fe8b, (q31_t)0x6f2ee1b2, - (q31_t)0x6f2bc495, (q31_t)0x6f28a733, (q31_t)0x6f25898d, (q31_t)0x6f226ba2, (q31_t)0x6f1f4d72, (q31_t)0x6f1c2efe, (q31_t)0x6f191045, (q31_t)0x6f15f148, - (q31_t)0x6f12d206, (q31_t)0x6f0fb280, (q31_t)0x6f0c92b6, (q31_t)0x6f0972a6, (q31_t)0x6f065253, (q31_t)0x6f0331ba, (q31_t)0x6f0010de, (q31_t)0x6efcefbd, - (q31_t)0x6ef9ce57, (q31_t)0x6ef6acad, (q31_t)0x6ef38abe, (q31_t)0x6ef0688b, (q31_t)0x6eed4614, (q31_t)0x6eea2358, (q31_t)0x6ee70058, (q31_t)0x6ee3dd13, - (q31_t)0x6ee0b98a, (q31_t)0x6edd95bd, (q31_t)0x6eda71ab, (q31_t)0x6ed74d55, (q31_t)0x6ed428ba, (q31_t)0x6ed103db, (q31_t)0x6ecddeb8, (q31_t)0x6ecab950, - (q31_t)0x6ec793a4, (q31_t)0x6ec46db4, (q31_t)0x6ec1477f, (q31_t)0x6ebe2106, (q31_t)0x6ebafa49, (q31_t)0x6eb7d347, (q31_t)0x6eb4ac02, (q31_t)0x6eb18477, - (q31_t)0x6eae5ca9, (q31_t)0x6eab3496, (q31_t)0x6ea80c3f, (q31_t)0x6ea4e3a4, (q31_t)0x6ea1bac4, (q31_t)0x6e9e91a1, (q31_t)0x6e9b6839, (q31_t)0x6e983e8d, - (q31_t)0x6e95149c, (q31_t)0x6e91ea67, (q31_t)0x6e8ebfef, (q31_t)0x6e8b9532, (q31_t)0x6e886a30, (q31_t)0x6e853eeb, (q31_t)0x6e821361, (q31_t)0x6e7ee794, - (q31_t)0x6e7bbb82, (q31_t)0x6e788f2c, (q31_t)0x6e756291, (q31_t)0x6e7235b3, (q31_t)0x6e6f0890, (q31_t)0x6e6bdb2a, (q31_t)0x6e68ad7f, (q31_t)0x6e657f90, - (q31_t)0x6e62515d, (q31_t)0x6e5f22e6, (q31_t)0x6e5bf42b, (q31_t)0x6e58c52c, (q31_t)0x6e5595e9, (q31_t)0x6e526662, (q31_t)0x6e4f3696, (q31_t)0x6e4c0687, - (q31_t)0x6e48d633, (q31_t)0x6e45a59c, (q31_t)0x6e4274c1, (q31_t)0x6e3f43a1, (q31_t)0x6e3c123e, (q31_t)0x6e38e096, (q31_t)0x6e35aeab, (q31_t)0x6e327c7b, - (q31_t)0x6e2f4a08, (q31_t)0x6e2c1750, (q31_t)0x6e28e455, (q31_t)0x6e25b115, (q31_t)0x6e227d92, (q31_t)0x6e1f49cb, (q31_t)0x6e1c15c0, (q31_t)0x6e18e171, - (q31_t)0x6e15acde, (q31_t)0x6e127807, (q31_t)0x6e0f42ec, (q31_t)0x6e0c0d8e, (q31_t)0x6e08d7eb, (q31_t)0x6e05a205, (q31_t)0x6e026bda, (q31_t)0x6dff356c, - (q31_t)0x6dfbfeba, (q31_t)0x6df8c7c4, (q31_t)0x6df5908b, (q31_t)0x6df2590d, (q31_t)0x6def214c, (q31_t)0x6debe947, (q31_t)0x6de8b0fe, (q31_t)0x6de57871, - (q31_t)0x6de23fa0, (q31_t)0x6ddf068c, (q31_t)0x6ddbcd34, (q31_t)0x6dd89398, (q31_t)0x6dd559b9, (q31_t)0x6dd21f95, (q31_t)0x6dcee52e, (q31_t)0x6dcbaa83, - (q31_t)0x6dc86f95, (q31_t)0x6dc53462, (q31_t)0x6dc1f8ec, (q31_t)0x6dbebd33, (q31_t)0x6dbb8135, (q31_t)0x6db844f4, (q31_t)0x6db5086f, (q31_t)0x6db1cba7, - (q31_t)0x6dae8e9b, (q31_t)0x6dab514b, (q31_t)0x6da813b8, (q31_t)0x6da4d5e1, (q31_t)0x6da197c6, (q31_t)0x6d9e5968, (q31_t)0x6d9b1ac6, (q31_t)0x6d97dbe0, - (q31_t)0x6d949cb7, (q31_t)0x6d915d4a, (q31_t)0x6d8e1d9a, (q31_t)0x6d8adda6, (q31_t)0x6d879d6e, (q31_t)0x6d845cf3, (q31_t)0x6d811c35, (q31_t)0x6d7ddb33, - (q31_t)0x6d7a99ed, (q31_t)0x6d775864, (q31_t)0x6d741697, (q31_t)0x6d70d487, (q31_t)0x6d6d9233, (q31_t)0x6d6a4f9c, (q31_t)0x6d670cc1, (q31_t)0x6d63c9a3, - (q31_t)0x6d608641, (q31_t)0x6d5d429c, (q31_t)0x6d59feb3, (q31_t)0x6d56ba87, (q31_t)0x6d537617, (q31_t)0x6d503164, (q31_t)0x6d4cec6e, (q31_t)0x6d49a734, - (q31_t)0x6d4661b7, (q31_t)0x6d431bf6, (q31_t)0x6d3fd5f2, (q31_t)0x6d3c8fab, (q31_t)0x6d394920, (q31_t)0x6d360252, (q31_t)0x6d32bb40, (q31_t)0x6d2f73eb, - (q31_t)0x6d2c2c53, (q31_t)0x6d28e477, (q31_t)0x6d259c58, (q31_t)0x6d2253f6, (q31_t)0x6d1f0b50, (q31_t)0x6d1bc267, (q31_t)0x6d18793b, (q31_t)0x6d152fcc, - (q31_t)0x6d11e619, (q31_t)0x6d0e9c23, (q31_t)0x6d0b51e9, (q31_t)0x6d08076d, (q31_t)0x6d04bcad, (q31_t)0x6d0171aa, (q31_t)0x6cfe2663, (q31_t)0x6cfadada, - (q31_t)0x6cf78f0d, (q31_t)0x6cf442fd, (q31_t)0x6cf0f6aa, (q31_t)0x6cedaa13, (q31_t)0x6cea5d3a, (q31_t)0x6ce7101d, (q31_t)0x6ce3c2bd, (q31_t)0x6ce0751a, - (q31_t)0x6cdd2733, (q31_t)0x6cd9d90a, (q31_t)0x6cd68a9d, (q31_t)0x6cd33bed, (q31_t)0x6ccfecfa, (q31_t)0x6ccc9dc4, (q31_t)0x6cc94e4b, (q31_t)0x6cc5fe8f, - (q31_t)0x6cc2ae90, (q31_t)0x6cbf5e4d, (q31_t)0x6cbc0dc8, (q31_t)0x6cb8bcff, (q31_t)0x6cb56bf4, (q31_t)0x6cb21aa5, (q31_t)0x6caec913, (q31_t)0x6cab773e, - (q31_t)0x6ca82527, (q31_t)0x6ca4d2cc, (q31_t)0x6ca1802e, (q31_t)0x6c9e2d4d, (q31_t)0x6c9ada29, (q31_t)0x6c9786c2, (q31_t)0x6c943318, (q31_t)0x6c90df2c, - (q31_t)0x6c8d8afc, (q31_t)0x6c8a3689, (q31_t)0x6c86e1d3, (q31_t)0x6c838cdb, (q31_t)0x6c80379f, (q31_t)0x6c7ce220, (q31_t)0x6c798c5f, (q31_t)0x6c76365b, - (q31_t)0x6c72e013, (q31_t)0x6c6f8989, (q31_t)0x6c6c32bc, (q31_t)0x6c68dbac, (q31_t)0x6c658459, (q31_t)0x6c622cc4, (q31_t)0x6c5ed4eb, (q31_t)0x6c5b7cd0, - (q31_t)0x6c582472, (q31_t)0x6c54cbd1, (q31_t)0x6c5172ed, (q31_t)0x6c4e19c6, (q31_t)0x6c4ac05d, (q31_t)0x6c4766b0, (q31_t)0x6c440cc1, (q31_t)0x6c40b28f, - (q31_t)0x6c3d581b, (q31_t)0x6c39fd63, (q31_t)0x6c36a269, (q31_t)0x6c33472c, (q31_t)0x6c2febad, (q31_t)0x6c2c8fea, (q31_t)0x6c2933e5, (q31_t)0x6c25d79d, - (q31_t)0x6c227b13, (q31_t)0x6c1f1e45, (q31_t)0x6c1bc136, (q31_t)0x6c1863e3, (q31_t)0x6c15064e, (q31_t)0x6c11a876, (q31_t)0x6c0e4a5b, (q31_t)0x6c0aebfe, - (q31_t)0x6c078d5e, (q31_t)0x6c042e7b, (q31_t)0x6c00cf56, (q31_t)0x6bfd6fee, (q31_t)0x6bfa1044, (q31_t)0x6bf6b056, (q31_t)0x6bf35027, (q31_t)0x6befefb5, - (q31_t)0x6bec8f00, (q31_t)0x6be92e08, (q31_t)0x6be5ccce, (q31_t)0x6be26b52, (q31_t)0x6bdf0993, (q31_t)0x6bdba791, (q31_t)0x6bd8454d, (q31_t)0x6bd4e2c6, - (q31_t)0x6bd17ffd, (q31_t)0x6bce1cf1, (q31_t)0x6bcab9a3, (q31_t)0x6bc75613, (q31_t)0x6bc3f23f, (q31_t)0x6bc08e2a, (q31_t)0x6bbd29d2, (q31_t)0x6bb9c537, - (q31_t)0x6bb6605a, (q31_t)0x6bb2fb3b, (q31_t)0x6baf95d9, (q31_t)0x6bac3034, (q31_t)0x6ba8ca4e, (q31_t)0x6ba56425, (q31_t)0x6ba1fdb9, (q31_t)0x6b9e970b, - (q31_t)0x6b9b301b, (q31_t)0x6b97c8e8, (q31_t)0x6b946173, (q31_t)0x6b90f9bc, (q31_t)0x6b8d91c2, (q31_t)0x6b8a2986, (q31_t)0x6b86c107, (q31_t)0x6b835846, - (q31_t)0x6b7fef43, (q31_t)0x6b7c85fe, (q31_t)0x6b791c76, (q31_t)0x6b75b2ac, (q31_t)0x6b7248a0, (q31_t)0x6b6ede51, (q31_t)0x6b6b73c0, (q31_t)0x6b6808ed, - (q31_t)0x6b649dd8, (q31_t)0x6b613280, (q31_t)0x6b5dc6e6, (q31_t)0x6b5a5b0a, (q31_t)0x6b56eeec, (q31_t)0x6b53828b, (q31_t)0x6b5015e9, (q31_t)0x6b4ca904, - (q31_t)0x6b493bdd, (q31_t)0x6b45ce73, (q31_t)0x6b4260c8, (q31_t)0x6b3ef2da, (q31_t)0x6b3b84ab, (q31_t)0x6b381639, (q31_t)0x6b34a785, (q31_t)0x6b31388e, - (q31_t)0x6b2dc956, (q31_t)0x6b2a59dc, (q31_t)0x6b26ea1f, (q31_t)0x6b237a21, (q31_t)0x6b2009e0, (q31_t)0x6b1c995d, (q31_t)0x6b192898, (q31_t)0x6b15b791, - (q31_t)0x6b124648, (q31_t)0x6b0ed4bd, (q31_t)0x6b0b62f0, (q31_t)0x6b07f0e1, (q31_t)0x6b047e90, (q31_t)0x6b010bfd, (q31_t)0x6afd9928, (q31_t)0x6afa2610, - (q31_t)0x6af6b2b7, (q31_t)0x6af33f1c, (q31_t)0x6aefcb3f, (q31_t)0x6aec5720, (q31_t)0x6ae8e2bf, (q31_t)0x6ae56e1c, (q31_t)0x6ae1f937, (q31_t)0x6ade8410, - (q31_t)0x6adb0ea8, (q31_t)0x6ad798fd, (q31_t)0x6ad42311, (q31_t)0x6ad0ace2, (q31_t)0x6acd3672, (q31_t)0x6ac9bfc0, (q31_t)0x6ac648cb, (q31_t)0x6ac2d195, - (q31_t)0x6abf5a1e, (q31_t)0x6abbe264, (q31_t)0x6ab86a68, (q31_t)0x6ab4f22b, (q31_t)0x6ab179ac, (q31_t)0x6aae00eb, (q31_t)0x6aaa87e8, (q31_t)0x6aa70ea4, - (q31_t)0x6aa3951d, (q31_t)0x6aa01b55, (q31_t)0x6a9ca14b, (q31_t)0x6a992700, (q31_t)0x6a95ac72, (q31_t)0x6a9231a3, (q31_t)0x6a8eb692, (q31_t)0x6a8b3b3f, - (q31_t)0x6a87bfab, (q31_t)0x6a8443d5, (q31_t)0x6a80c7bd, (q31_t)0x6a7d4b64, (q31_t)0x6a79cec8, (q31_t)0x6a7651ec, (q31_t)0x6a72d4cd, (q31_t)0x6a6f576d, - (q31_t)0x6a6bd9cb, (q31_t)0x6a685be8, (q31_t)0x6a64ddc2, (q31_t)0x6a615f5c, (q31_t)0x6a5de0b3, (q31_t)0x6a5a61c9, (q31_t)0x6a56e29e, (q31_t)0x6a536331, - (q31_t)0x6a4fe382, (q31_t)0x6a4c6391, (q31_t)0x6a48e360, (q31_t)0x6a4562ec, (q31_t)0x6a41e237, (q31_t)0x6a3e6140, (q31_t)0x6a3ae008, (q31_t)0x6a375e8f, - (q31_t)0x6a33dcd4, (q31_t)0x6a305ad7, (q31_t)0x6a2cd899, (q31_t)0x6a295619, (q31_t)0x6a25d358, (q31_t)0x6a225055, (q31_t)0x6a1ecd11, (q31_t)0x6a1b498c, - (q31_t)0x6a17c5c5, (q31_t)0x6a1441bc, (q31_t)0x6a10bd72, (q31_t)0x6a0d38e7, (q31_t)0x6a09b41a, (q31_t)0x6a062f0c, (q31_t)0x6a02a9bc, (q31_t)0x69ff242b, - (q31_t)0x69fb9e59, (q31_t)0x69f81845, (q31_t)0x69f491f0, (q31_t)0x69f10b5a, (q31_t)0x69ed8482, (q31_t)0x69e9fd69, (q31_t)0x69e6760f, (q31_t)0x69e2ee73, - (q31_t)0x69df6696, (q31_t)0x69dbde77, (q31_t)0x69d85618, (q31_t)0x69d4cd77, (q31_t)0x69d14494, (q31_t)0x69cdbb71, (q31_t)0x69ca320c, (q31_t)0x69c6a866, - (q31_t)0x69c31e7f, (q31_t)0x69bf9456, (q31_t)0x69bc09ec, (q31_t)0x69b87f41, (q31_t)0x69b4f455, (q31_t)0x69b16928, (q31_t)0x69adddb9, (q31_t)0x69aa5209, - (q31_t)0x69a6c618, (q31_t)0x69a339e6, (q31_t)0x699fad73, (q31_t)0x699c20be, (q31_t)0x699893c9, (q31_t)0x69950692, (q31_t)0x6991791a, (q31_t)0x698deb61, - (q31_t)0x698a5d67, (q31_t)0x6986cf2c, (q31_t)0x698340af, (q31_t)0x697fb1f2, (q31_t)0x697c22f3, (q31_t)0x697893b4, (q31_t)0x69750433, (q31_t)0x69717472, - (q31_t)0x696de46f, (q31_t)0x696a542b, (q31_t)0x6966c3a6, (q31_t)0x696332e1, (q31_t)0x695fa1da, (q31_t)0x695c1092, (q31_t)0x69587f09, (q31_t)0x6954ed40, - (q31_t)0x69515b35, (q31_t)0x694dc8e9, (q31_t)0x694a365c, (q31_t)0x6946a38f, (q31_t)0x69431080, (q31_t)0x693f7d31, (q31_t)0x693be9a0, (q31_t)0x693855cf, - (q31_t)0x6934c1bd, (q31_t)0x69312d6a, (q31_t)0x692d98d6, (q31_t)0x692a0401, (q31_t)0x69266eeb, (q31_t)0x6922d995, (q31_t)0x691f43fd, (q31_t)0x691bae25, - (q31_t)0x6918180c, (q31_t)0x691481b2, (q31_t)0x6910eb17, (q31_t)0x690d543b, (q31_t)0x6909bd1f, (q31_t)0x690625c2, (q31_t)0x69028e24, (q31_t)0x68fef645, - (q31_t)0x68fb5e25, (q31_t)0x68f7c5c5, (q31_t)0x68f42d24, (q31_t)0x68f09442, (q31_t)0x68ecfb20, (q31_t)0x68e961bd, (q31_t)0x68e5c819, (q31_t)0x68e22e34, - (q31_t)0x68de940f, (q31_t)0x68daf9a9, (q31_t)0x68d75f02, (q31_t)0x68d3c41b, (q31_t)0x68d028f2, (q31_t)0x68cc8d8a, (q31_t)0x68c8f1e0, (q31_t)0x68c555f6, - (q31_t)0x68c1b9cc, (q31_t)0x68be1d61, (q31_t)0x68ba80b5, (q31_t)0x68b6e3c8, (q31_t)0x68b3469b, (q31_t)0x68afa92e, (q31_t)0x68ac0b7f, (q31_t)0x68a86d91, - (q31_t)0x68a4cf61, (q31_t)0x68a130f1, (q31_t)0x689d9241, (q31_t)0x6899f350, (q31_t)0x6896541f, (q31_t)0x6892b4ad, (q31_t)0x688f14fa, (q31_t)0x688b7507, - (q31_t)0x6887d4d4, (q31_t)0x68843460, (q31_t)0x688093ab, (q31_t)0x687cf2b6, (q31_t)0x68795181, (q31_t)0x6875b00b, (q31_t)0x68720e55, (q31_t)0x686e6c5e, - (q31_t)0x686aca27, (q31_t)0x686727b0, (q31_t)0x686384f8, (q31_t)0x685fe200, (q31_t)0x685c3ec7, (q31_t)0x68589b4e, (q31_t)0x6854f795, (q31_t)0x6851539b, - (q31_t)0x684daf61, (q31_t)0x684a0ae6, (q31_t)0x6846662c, (q31_t)0x6842c131, (q31_t)0x683f1bf5, (q31_t)0x683b7679, (q31_t)0x6837d0bd, (q31_t)0x68342ac1, - (q31_t)0x68308485, (q31_t)0x682cde08, (q31_t)0x6829374b, (q31_t)0x6825904d, (q31_t)0x6821e910, (q31_t)0x681e4192, (q31_t)0x681a99d4, (q31_t)0x6816f1d6, - (q31_t)0x68134997, (q31_t)0x680fa118, (q31_t)0x680bf85a, (q31_t)0x68084f5a, (q31_t)0x6804a61b, (q31_t)0x6800fc9c, (q31_t)0x67fd52dc, (q31_t)0x67f9a8dd, - (q31_t)0x67f5fe9d, (q31_t)0x67f2541d, (q31_t)0x67eea95d, (q31_t)0x67eafe5d, (q31_t)0x67e7531c, (q31_t)0x67e3a79c, (q31_t)0x67dffbdc, (q31_t)0x67dc4fdb, - (q31_t)0x67d8a39a, (q31_t)0x67d4f71a, (q31_t)0x67d14a59, (q31_t)0x67cd9d58, (q31_t)0x67c9f017, (q31_t)0x67c64297, (q31_t)0x67c294d6, (q31_t)0x67bee6d5, - (q31_t)0x67bb3894, (q31_t)0x67b78a13, (q31_t)0x67b3db53, (q31_t)0x67b02c52, (q31_t)0x67ac7d11, (q31_t)0x67a8cd91, (q31_t)0x67a51dd0, (q31_t)0x67a16dcf, - (q31_t)0x679dbd8f, (q31_t)0x679a0d0f, (q31_t)0x67965c4e, (q31_t)0x6792ab4e, (q31_t)0x678efa0e, (q31_t)0x678b488e, (q31_t)0x678796ce, (q31_t)0x6783e4cf, - (q31_t)0x6780328f, (q31_t)0x677c8010, (q31_t)0x6778cd50, (q31_t)0x67751a51, (q31_t)0x67716713, (q31_t)0x676db394, (q31_t)0x6769ffd5, (q31_t)0x67664bd7, - (q31_t)0x67629799, (q31_t)0x675ee31b, (q31_t)0x675b2e5e, (q31_t)0x67577960, (q31_t)0x6753c423, (q31_t)0x67500ea7, (q31_t)0x674c58ea, (q31_t)0x6748a2ee, - (q31_t)0x6744ecb2, (q31_t)0x67413636, (q31_t)0x673d7f7b, (q31_t)0x6739c880, (q31_t)0x67361145, (q31_t)0x673259ca, (q31_t)0x672ea210, (q31_t)0x672aea17, - (q31_t)0x672731dd, (q31_t)0x67237964, (q31_t)0x671fc0ac, (q31_t)0x671c07b4, (q31_t)0x67184e7c, (q31_t)0x67149504, (q31_t)0x6710db4d, (q31_t)0x670d2157, - (q31_t)0x67096721, (q31_t)0x6705acab, (q31_t)0x6701f1f6, (q31_t)0x66fe3701, (q31_t)0x66fa7bcd, (q31_t)0x66f6c059, (q31_t)0x66f304a6, (q31_t)0x66ef48b3, - (q31_t)0x66eb8c80, (q31_t)0x66e7d00f, (q31_t)0x66e4135d, (q31_t)0x66e0566c, (q31_t)0x66dc993c, (q31_t)0x66d8dbcd, (q31_t)0x66d51e1d, (q31_t)0x66d1602f, - (q31_t)0x66cda201, (q31_t)0x66c9e393, (q31_t)0x66c624e7, (q31_t)0x66c265fa, (q31_t)0x66bea6cf, (q31_t)0x66bae764, (q31_t)0x66b727ba, (q31_t)0x66b367d0, - (q31_t)0x66afa7a7, (q31_t)0x66abe73f, (q31_t)0x66a82697, (q31_t)0x66a465b0, (q31_t)0x66a0a489, (q31_t)0x669ce324, (q31_t)0x6699217f, (q31_t)0x66955f9b, - (q31_t)0x66919d77, (q31_t)0x668ddb14, (q31_t)0x668a1872, (q31_t)0x66865591, (q31_t)0x66829270, (q31_t)0x667ecf11, (q31_t)0x667b0b72, (q31_t)0x66774793, - (q31_t)0x66738376, (q31_t)0x666fbf19, (q31_t)0x666bfa7d, (q31_t)0x666835a2, (q31_t)0x66647088, (q31_t)0x6660ab2f, (q31_t)0x665ce596, (q31_t)0x66591fbf, - (q31_t)0x665559a8, (q31_t)0x66519352, (q31_t)0x664dccbd, (q31_t)0x664a05e9, (q31_t)0x66463ed6, (q31_t)0x66427784, (q31_t)0x663eaff2, (q31_t)0x663ae822, - (q31_t)0x66372012, (q31_t)0x663357c4, (q31_t)0x662f8f36, (q31_t)0x662bc66a, (q31_t)0x6627fd5e, (q31_t)0x66243413, (q31_t)0x66206a8a, (q31_t)0x661ca0c1, - (q31_t)0x6618d6b9, (q31_t)0x66150c73, (q31_t)0x661141ed, (q31_t)0x660d7729, (q31_t)0x6609ac25, (q31_t)0x6605e0e3, (q31_t)0x66021561, (q31_t)0x65fe49a1, - (q31_t)0x65fa7da2, (q31_t)0x65f6b164, (q31_t)0x65f2e4e7, (q31_t)0x65ef182b, (q31_t)0x65eb4b30, (q31_t)0x65e77df6, (q31_t)0x65e3b07e, (q31_t)0x65dfe2c6, - (q31_t)0x65dc14d0, (q31_t)0x65d8469b, (q31_t)0x65d47827, (q31_t)0x65d0a975, (q31_t)0x65ccda83, (q31_t)0x65c90b53, (q31_t)0x65c53be4, (q31_t)0x65c16c36, - (q31_t)0x65bd9c49, (q31_t)0x65b9cc1e, (q31_t)0x65b5fbb4, (q31_t)0x65b22b0b, (q31_t)0x65ae5a23, (q31_t)0x65aa88fd, (q31_t)0x65a6b798, (q31_t)0x65a2e5f4, - (q31_t)0x659f1412, (q31_t)0x659b41f1, (q31_t)0x65976f91, (q31_t)0x65939cf3, (q31_t)0x658fca15, (q31_t)0x658bf6fa, (q31_t)0x6588239f, (q31_t)0x65845006, - (q31_t)0x65807c2f, (q31_t)0x657ca818, (q31_t)0x6578d3c4, (q31_t)0x6574ff30, (q31_t)0x65712a5e, (q31_t)0x656d554d, (q31_t)0x65697ffe, (q31_t)0x6565aa71, - (q31_t)0x6561d4a4, (q31_t)0x655dfe99, (q31_t)0x655a2850, (q31_t)0x655651c8, (q31_t)0x65527b02, (q31_t)0x654ea3fd, (q31_t)0x654accba, (q31_t)0x6546f538, - (q31_t)0x65431d77, (q31_t)0x653f4579, (q31_t)0x653b6d3b, (q31_t)0x653794c0, (q31_t)0x6533bc06, (q31_t)0x652fe30d, (q31_t)0x652c09d6, (q31_t)0x65283061, - (q31_t)0x652456ad, (q31_t)0x65207cbb, (q31_t)0x651ca28a, (q31_t)0x6518c81b, (q31_t)0x6514ed6e, (q31_t)0x65111283, (q31_t)0x650d3759, (q31_t)0x65095bf0, - (q31_t)0x6505804a, (q31_t)0x6501a465, (q31_t)0x64fdc841, (q31_t)0x64f9ebe0, (q31_t)0x64f60f40, (q31_t)0x64f23262, (q31_t)0x64ee5546, (q31_t)0x64ea77eb, - (q31_t)0x64e69a52, (q31_t)0x64e2bc7b, (q31_t)0x64dede66, (q31_t)0x64db0012, (q31_t)0x64d72180, (q31_t)0x64d342b0, (q31_t)0x64cf63a2, (q31_t)0x64cb8456, - (q31_t)0x64c7a4cb, (q31_t)0x64c3c502, (q31_t)0x64bfe4fc, (q31_t)0x64bc04b6, (q31_t)0x64b82433, (q31_t)0x64b44372, (q31_t)0x64b06273, (q31_t)0x64ac8135, - (q31_t)0x64a89fba, (q31_t)0x64a4be00, (q31_t)0x64a0dc08, (q31_t)0x649cf9d2, (q31_t)0x6499175e, (q31_t)0x649534ac, (q31_t)0x649151bc, (q31_t)0x648d6e8e, - (q31_t)0x64898b22, (q31_t)0x6485a778, (q31_t)0x6481c390, (q31_t)0x647ddf6a, (q31_t)0x6479fb06, (q31_t)0x64761664, (q31_t)0x64723184, (q31_t)0x646e4c66, - (q31_t)0x646a670a, (q31_t)0x64668170, (q31_t)0x64629b98, (q31_t)0x645eb582, (q31_t)0x645acf2e, (q31_t)0x6456e89d, (q31_t)0x645301cd, (q31_t)0x644f1ac0, - (q31_t)0x644b3375, (q31_t)0x64474bec, (q31_t)0x64436425, (q31_t)0x643f7c20, (q31_t)0x643b93dd, (q31_t)0x6437ab5d, (q31_t)0x6433c29f, (q31_t)0x642fd9a3, - (q31_t)0x642bf069, (q31_t)0x642806f1, (q31_t)0x64241d3c, (q31_t)0x64203348, (q31_t)0x641c4917, (q31_t)0x64185ea9, (q31_t)0x641473fc, (q31_t)0x64108912, - (q31_t)0x640c9dea, (q31_t)0x6408b284, (q31_t)0x6404c6e1, (q31_t)0x6400db00, (q31_t)0x63fceee1, (q31_t)0x63f90285, (q31_t)0x63f515eb, (q31_t)0x63f12913, - (q31_t)0x63ed3bfd, (q31_t)0x63e94eaa, (q31_t)0x63e5611a, (q31_t)0x63e1734b, (q31_t)0x63dd853f, (q31_t)0x63d996f6, (q31_t)0x63d5a86f, (q31_t)0x63d1b9aa, - (q31_t)0x63cdcaa8, (q31_t)0x63c9db68, (q31_t)0x63c5ebeb, (q31_t)0x63c1fc30, (q31_t)0x63be0c37, (q31_t)0x63ba1c01, (q31_t)0x63b62b8e, (q31_t)0x63b23add, - (q31_t)0x63ae49ee, (q31_t)0x63aa58c2, (q31_t)0x63a66759, (q31_t)0x63a275b2, (q31_t)0x639e83cd, (q31_t)0x639a91ac, (q31_t)0x63969f4c, (q31_t)0x6392acaf, - (q31_t)0x638eb9d5, (q31_t)0x638ac6be, (q31_t)0x6386d369, (q31_t)0x6382dfd6, (q31_t)0x637eec07, (q31_t)0x637af7fa, (q31_t)0x637703af, (q31_t)0x63730f27, - (q31_t)0x636f1a62, (q31_t)0x636b2560, (q31_t)0x63673020, (q31_t)0x63633aa3, (q31_t)0x635f44e8, (q31_t)0x635b4ef0, (q31_t)0x635758bb, (q31_t)0x63536249, - (q31_t)0x634f6b99, (q31_t)0x634b74ad, (q31_t)0x63477d82, (q31_t)0x6343861b, (q31_t)0x633f8e76, (q31_t)0x633b9695, (q31_t)0x63379e76, (q31_t)0x6333a619, - (q31_t)0x632fad80, (q31_t)0x632bb4a9, (q31_t)0x6327bb96, (q31_t)0x6323c245, (q31_t)0x631fc8b7, (q31_t)0x631bceeb, (q31_t)0x6317d4e3, (q31_t)0x6313da9e, - (q31_t)0x630fe01b, (q31_t)0x630be55b, (q31_t)0x6307ea5e, (q31_t)0x6303ef25, (q31_t)0x62fff3ae, (q31_t)0x62fbf7fa, (q31_t)0x62f7fc08, (q31_t)0x62f3ffda, - (q31_t)0x62f0036f, (q31_t)0x62ec06c7, (q31_t)0x62e809e2, (q31_t)0x62e40cbf, (q31_t)0x62e00f60, (q31_t)0x62dc11c4, (q31_t)0x62d813eb, (q31_t)0x62d415d4, - (q31_t)0x62d01781, (q31_t)0x62cc18f1, (q31_t)0x62c81a24, (q31_t)0x62c41b1a, (q31_t)0x62c01bd3, (q31_t)0x62bc1c4f, (q31_t)0x62b81c8f, (q31_t)0x62b41c91, - (q31_t)0x62b01c57, (q31_t)0x62ac1bdf, (q31_t)0x62a81b2b, (q31_t)0x62a41a3a, (q31_t)0x62a0190c, (q31_t)0x629c17a1, (q31_t)0x629815fa, (q31_t)0x62941415, - (q31_t)0x629011f4, (q31_t)0x628c0f96, (q31_t)0x62880cfb, (q31_t)0x62840a23, (q31_t)0x6280070f, (q31_t)0x627c03be, (q31_t)0x62780030, (q31_t)0x6273fc65, - (q31_t)0x626ff85e, (q31_t)0x626bf41a, (q31_t)0x6267ef99, (q31_t)0x6263eadc, (q31_t)0x625fe5e1, (q31_t)0x625be0ab, (q31_t)0x6257db37, (q31_t)0x6253d587, - (q31_t)0x624fcf9a, (q31_t)0x624bc970, (q31_t)0x6247c30a, (q31_t)0x6243bc68, (q31_t)0x623fb588, (q31_t)0x623bae6c, (q31_t)0x6237a714, (q31_t)0x62339f7e, - (q31_t)0x622f97ad, (q31_t)0x622b8f9e, (q31_t)0x62278754, (q31_t)0x62237ecc, (q31_t)0x621f7608, (q31_t)0x621b6d08, (q31_t)0x621763cb, (q31_t)0x62135a51, - (q31_t)0x620f509b, (q31_t)0x620b46a9, (q31_t)0x62073c7a, (q31_t)0x6203320e, (q31_t)0x61ff2766, (q31_t)0x61fb1c82, (q31_t)0x61f71161, (q31_t)0x61f30604, - (q31_t)0x61eefa6b, (q31_t)0x61eaee95, (q31_t)0x61e6e282, (q31_t)0x61e2d633, (q31_t)0x61dec9a8, (q31_t)0x61dabce0, (q31_t)0x61d6afdd, (q31_t)0x61d2a29c, - (q31_t)0x61ce9520, (q31_t)0x61ca8767, (q31_t)0x61c67971, (q31_t)0x61c26b40, (q31_t)0x61be5cd2, (q31_t)0x61ba4e28, (q31_t)0x61b63f41, (q31_t)0x61b2301e, - (q31_t)0x61ae20bf, (q31_t)0x61aa1124, (q31_t)0x61a6014d, (q31_t)0x61a1f139, (q31_t)0x619de0e9, (q31_t)0x6199d05d, (q31_t)0x6195bf94, (q31_t)0x6191ae90, - (q31_t)0x618d9d4f, (q31_t)0x61898bd2, (q31_t)0x61857a19, (q31_t)0x61816824, (q31_t)0x617d55f2, (q31_t)0x61794385, (q31_t)0x617530db, (q31_t)0x61711df5, - (q31_t)0x616d0ad3, (q31_t)0x6168f775, (q31_t)0x6164e3db, (q31_t)0x6160d005, (q31_t)0x615cbbf3, (q31_t)0x6158a7a4, (q31_t)0x6154931a, (q31_t)0x61507e54, - (q31_t)0x614c6951, (q31_t)0x61485413, (q31_t)0x61443e98, (q31_t)0x614028e2, (q31_t)0x613c12f0, (q31_t)0x6137fcc1, (q31_t)0x6133e657, (q31_t)0x612fcfb0, - (q31_t)0x612bb8ce, (q31_t)0x6127a1b0, (q31_t)0x61238a56, (q31_t)0x611f72c0, (q31_t)0x611b5aee, (q31_t)0x611742e0, (q31_t)0x61132a96, (q31_t)0x610f1210, - (q31_t)0x610af94f, (q31_t)0x6106e051, (q31_t)0x6102c718, (q31_t)0x60feada3, (q31_t)0x60fa93f2, (q31_t)0x60f67a05, (q31_t)0x60f25fdd, (q31_t)0x60ee4579, - (q31_t)0x60ea2ad8, (q31_t)0x60e60ffd, (q31_t)0x60e1f4e5, (q31_t)0x60ddd991, (q31_t)0x60d9be02, (q31_t)0x60d5a237, (q31_t)0x60d18631, (q31_t)0x60cd69ee, - (q31_t)0x60c94d70, (q31_t)0x60c530b6, (q31_t)0x60c113c1, (q31_t)0x60bcf690, (q31_t)0x60b8d923, (q31_t)0x60b4bb7a, (q31_t)0x60b09d96, (q31_t)0x60ac7f76, - (q31_t)0x60a8611b, (q31_t)0x60a44284, (q31_t)0x60a023b1, (q31_t)0x609c04a3, (q31_t)0x6097e559, (q31_t)0x6093c5d3, (q31_t)0x608fa612, (q31_t)0x608b8616, - (q31_t)0x608765dd, (q31_t)0x6083456a, (q31_t)0x607f24ba, (q31_t)0x607b03d0, (q31_t)0x6076e2a9, (q31_t)0x6072c148, (q31_t)0x606e9faa, (q31_t)0x606a7dd2, - (q31_t)0x60665bbd, (q31_t)0x6062396e, (q31_t)0x605e16e2, (q31_t)0x6059f41c, (q31_t)0x6055d11a, (q31_t)0x6051addc, (q31_t)0x604d8a63, (q31_t)0x604966af, - (q31_t)0x604542bf, (q31_t)0x60411e94, (q31_t)0x603cfa2e, (q31_t)0x6038d58c, (q31_t)0x6034b0af, (q31_t)0x60308b97, (q31_t)0x602c6643, (q31_t)0x602840b4, - (q31_t)0x60241ae9, (q31_t)0x601ff4e3, (q31_t)0x601bcea2, (q31_t)0x6017a826, (q31_t)0x6013816e, (q31_t)0x600f5a7b, (q31_t)0x600b334d, (q31_t)0x60070be4, - (q31_t)0x6002e43f, (q31_t)0x5ffebc5f, (q31_t)0x5ffa9444, (q31_t)0x5ff66bee, (q31_t)0x5ff2435d, (q31_t)0x5fee1a90, (q31_t)0x5fe9f188, (q31_t)0x5fe5c845, - (q31_t)0x5fe19ec7, (q31_t)0x5fdd750e, (q31_t)0x5fd94b19, (q31_t)0x5fd520ea, (q31_t)0x5fd0f67f, (q31_t)0x5fcccbd9, (q31_t)0x5fc8a0f8, (q31_t)0x5fc475dc, - (q31_t)0x5fc04a85, (q31_t)0x5fbc1ef3, (q31_t)0x5fb7f326, (q31_t)0x5fb3c71e, (q31_t)0x5faf9adb, (q31_t)0x5fab6e5d, (q31_t)0x5fa741a3, (q31_t)0x5fa314af, - (q31_t)0x5f9ee780, (q31_t)0x5f9aba16, (q31_t)0x5f968c70, (q31_t)0x5f925e90, (q31_t)0x5f8e3075, (q31_t)0x5f8a021f, (q31_t)0x5f85d38e, (q31_t)0x5f81a4c2, - (q31_t)0x5f7d75bb, (q31_t)0x5f794679, (q31_t)0x5f7516fd, (q31_t)0x5f70e745, (q31_t)0x5f6cb753, (q31_t)0x5f688726, (q31_t)0x5f6456be, (q31_t)0x5f60261b, - (q31_t)0x5f5bf53d, (q31_t)0x5f57c424, (q31_t)0x5f5392d1, (q31_t)0x5f4f6143, (q31_t)0x5f4b2f7a, (q31_t)0x5f46fd76, (q31_t)0x5f42cb37, (q31_t)0x5f3e98be, - (q31_t)0x5f3a660a, (q31_t)0x5f36331b, (q31_t)0x5f31fff1, (q31_t)0x5f2dcc8d, (q31_t)0x5f2998ee, (q31_t)0x5f256515, (q31_t)0x5f213100, (q31_t)0x5f1cfcb1, - (q31_t)0x5f18c827, (q31_t)0x5f149363, (q31_t)0x5f105e64, (q31_t)0x5f0c292a, (q31_t)0x5f07f3b6, (q31_t)0x5f03be07, (q31_t)0x5eff881d, (q31_t)0x5efb51f9, - (q31_t)0x5ef71b9b, (q31_t)0x5ef2e501, (q31_t)0x5eeeae2d, (q31_t)0x5eea771f, (q31_t)0x5ee63fd6, (q31_t)0x5ee20853, (q31_t)0x5eddd094, (q31_t)0x5ed9989c, - (q31_t)0x5ed56069, (q31_t)0x5ed127fb, (q31_t)0x5eccef53, (q31_t)0x5ec8b671, (q31_t)0x5ec47d54, (q31_t)0x5ec043fc, (q31_t)0x5ebc0a6a, (q31_t)0x5eb7d09e, - (q31_t)0x5eb39697, (q31_t)0x5eaf5c56, (q31_t)0x5eab21da, (q31_t)0x5ea6e724, (q31_t)0x5ea2ac34, (q31_t)0x5e9e7109, (q31_t)0x5e9a35a4, (q31_t)0x5e95fa05, - (q31_t)0x5e91be2b, (q31_t)0x5e8d8217, (q31_t)0x5e8945c8, (q31_t)0x5e85093f, (q31_t)0x5e80cc7c, (q31_t)0x5e7c8f7f, (q31_t)0x5e785247, (q31_t)0x5e7414d5, - (q31_t)0x5e6fd729, (q31_t)0x5e6b9943, (q31_t)0x5e675b22, (q31_t)0x5e631cc7, (q31_t)0x5e5ede32, (q31_t)0x5e5a9f62, (q31_t)0x5e566059, (q31_t)0x5e522115, - (q31_t)0x5e4de197, (q31_t)0x5e49a1df, (q31_t)0x5e4561ed, (q31_t)0x5e4121c0, (q31_t)0x5e3ce15a, (q31_t)0x5e38a0b9, (q31_t)0x5e345fde, (q31_t)0x5e301ec9, - (q31_t)0x5e2bdd7a, (q31_t)0x5e279bf1, (q31_t)0x5e235a2e, (q31_t)0x5e1f1830, (q31_t)0x5e1ad5f9, (q31_t)0x5e169388, (q31_t)0x5e1250dc, (q31_t)0x5e0e0df7, - (q31_t)0x5e09cad7, (q31_t)0x5e05877e, (q31_t)0x5e0143ea, (q31_t)0x5dfd001d, (q31_t)0x5df8bc15, (q31_t)0x5df477d4, (q31_t)0x5df03359, (q31_t)0x5debeea3, - (q31_t)0x5de7a9b4, (q31_t)0x5de3648b, (q31_t)0x5ddf1f28, (q31_t)0x5ddad98b, (q31_t)0x5dd693b4, (q31_t)0x5dd24da3, (q31_t)0x5dce0759, (q31_t)0x5dc9c0d4, - (q31_t)0x5dc57a16, (q31_t)0x5dc1331d, (q31_t)0x5dbcebeb, (q31_t)0x5db8a480, (q31_t)0x5db45cda, (q31_t)0x5db014fa, (q31_t)0x5dabcce1, (q31_t)0x5da7848e, - (q31_t)0x5da33c01, (q31_t)0x5d9ef33b, (q31_t)0x5d9aaa3a, (q31_t)0x5d966100, (q31_t)0x5d92178d, (q31_t)0x5d8dcddf, (q31_t)0x5d8983f8, (q31_t)0x5d8539d7, - (q31_t)0x5d80ef7c, (q31_t)0x5d7ca4e8, (q31_t)0x5d785a1a, (q31_t)0x5d740f12, (q31_t)0x5d6fc3d1, (q31_t)0x5d6b7856, (q31_t)0x5d672ca2, (q31_t)0x5d62e0b4, - (q31_t)0x5d5e948c, (q31_t)0x5d5a482a, (q31_t)0x5d55fb90, (q31_t)0x5d51aebb, (q31_t)0x5d4d61ad, (q31_t)0x5d491465, (q31_t)0x5d44c6e4, (q31_t)0x5d40792a, - (q31_t)0x5d3c2b35, (q31_t)0x5d37dd08, (q31_t)0x5d338ea0, (q31_t)0x5d2f4000, (q31_t)0x5d2af125, (q31_t)0x5d26a212, (q31_t)0x5d2252c5, (q31_t)0x5d1e033e, - (q31_t)0x5d19b37e, (q31_t)0x5d156385, (q31_t)0x5d111352, (q31_t)0x5d0cc2e5, (q31_t)0x5d087240, (q31_t)0x5d042161, (q31_t)0x5cffd048, (q31_t)0x5cfb7ef7, - (q31_t)0x5cf72d6b, (q31_t)0x5cf2dba7, (q31_t)0x5cee89a9, (q31_t)0x5cea3772, (q31_t)0x5ce5e501, (q31_t)0x5ce19258, (q31_t)0x5cdd3f75, (q31_t)0x5cd8ec58, - (q31_t)0x5cd49903, (q31_t)0x5cd04574, (q31_t)0x5ccbf1ab, (q31_t)0x5cc79daa, (q31_t)0x5cc3496f, (q31_t)0x5cbef4fc, (q31_t)0x5cbaa04f, (q31_t)0x5cb64b68, - (q31_t)0x5cb1f649, (q31_t)0x5cada0f0, (q31_t)0x5ca94b5e, (q31_t)0x5ca4f594, (q31_t)0x5ca09f8f, (q31_t)0x5c9c4952, (q31_t)0x5c97f2dc, (q31_t)0x5c939c2c, - (q31_t)0x5c8f4544, (q31_t)0x5c8aee22, (q31_t)0x5c8696c7, (q31_t)0x5c823f34, (q31_t)0x5c7de767, (q31_t)0x5c798f61, (q31_t)0x5c753722, (q31_t)0x5c70deaa, - (q31_t)0x5c6c85f9, (q31_t)0x5c682d0f, (q31_t)0x5c63d3eb, (q31_t)0x5c5f7a8f, (q31_t)0x5c5b20fa, (q31_t)0x5c56c72c, (q31_t)0x5c526d25, (q31_t)0x5c4e12e5, - (q31_t)0x5c49b86d, (q31_t)0x5c455dbb, (q31_t)0x5c4102d0, (q31_t)0x5c3ca7ad, (q31_t)0x5c384c50, (q31_t)0x5c33f0bb, (q31_t)0x5c2f94ec, (q31_t)0x5c2b38e5, - (q31_t)0x5c26dca5, (q31_t)0x5c22802c, (q31_t)0x5c1e237b, (q31_t)0x5c19c690, (q31_t)0x5c15696d, (q31_t)0x5c110c11, (q31_t)0x5c0cae7c, (q31_t)0x5c0850ae, - (q31_t)0x5c03f2a8, (q31_t)0x5bff9469, (q31_t)0x5bfb35f1, (q31_t)0x5bf6d740, (q31_t)0x5bf27857, (q31_t)0x5bee1935, (q31_t)0x5be9b9da, (q31_t)0x5be55a46, - (q31_t)0x5be0fa7a, (q31_t)0x5bdc9a75, (q31_t)0x5bd83a37, (q31_t)0x5bd3d9c1, (q31_t)0x5bcf7912, (q31_t)0x5bcb182b, (q31_t)0x5bc6b70b, (q31_t)0x5bc255b2, - (q31_t)0x5bbdf421, (q31_t)0x5bb99257, (q31_t)0x5bb53054, (q31_t)0x5bb0ce19, (q31_t)0x5bac6ba6, (q31_t)0x5ba808f9, (q31_t)0x5ba3a615, (q31_t)0x5b9f42f7, - (q31_t)0x5b9adfa2, (q31_t)0x5b967c13, (q31_t)0x5b92184d, (q31_t)0x5b8db44d, (q31_t)0x5b895016, (q31_t)0x5b84eba6, (q31_t)0x5b8086fd, (q31_t)0x5b7c221c, - (q31_t)0x5b77bd02, (q31_t)0x5b7357b0, (q31_t)0x5b6ef226, (q31_t)0x5b6a8c63, (q31_t)0x5b662668, (q31_t)0x5b61c035, (q31_t)0x5b5d59c9, (q31_t)0x5b58f324, - (q31_t)0x5b548c48, (q31_t)0x5b502533, (q31_t)0x5b4bbde6, (q31_t)0x5b475660, (q31_t)0x5b42eea2, (q31_t)0x5b3e86ac, (q31_t)0x5b3a1e7e, (q31_t)0x5b35b617, - (q31_t)0x5b314d78, (q31_t)0x5b2ce4a1, (q31_t)0x5b287b91, (q31_t)0x5b241249, (q31_t)0x5b1fa8c9, (q31_t)0x5b1b3f11, (q31_t)0x5b16d521, (q31_t)0x5b126af8, - (q31_t)0x5b0e0098, (q31_t)0x5b0995ff, (q31_t)0x5b052b2e, (q31_t)0x5b00c025, (q31_t)0x5afc54e3, (q31_t)0x5af7e96a, (q31_t)0x5af37db8, (q31_t)0x5aef11cf, - (q31_t)0x5aeaa5ad, (q31_t)0x5ae63953, (q31_t)0x5ae1ccc1, (q31_t)0x5add5ff7, (q31_t)0x5ad8f2f5, (q31_t)0x5ad485bb, (q31_t)0x5ad01849, (q31_t)0x5acbaa9f, - (q31_t)0x5ac73cbd, (q31_t)0x5ac2cea3, (q31_t)0x5abe6050, (q31_t)0x5ab9f1c6, (q31_t)0x5ab58304, (q31_t)0x5ab1140a, (q31_t)0x5aaca4d8, (q31_t)0x5aa8356f, - (q31_t)0x5aa3c5cd, (q31_t)0x5a9f55f3, (q31_t)0x5a9ae5e2, (q31_t)0x5a967598, (q31_t)0x5a920517, (q31_t)0x5a8d945d, (q31_t)0x5a89236c, (q31_t)0x5a84b243, - (q31_t)0x5a8040e3, (q31_t)0x5a7bcf4a, (q31_t)0x5a775d7a, (q31_t)0x5a72eb71, (q31_t)0x5a6e7931, (q31_t)0x5a6a06ba, (q31_t)0x5a65940a, (q31_t)0x5a612123, - (q31_t)0x5a5cae04, (q31_t)0x5a583aad, (q31_t)0x5a53c71e, (q31_t)0x5a4f5358, (q31_t)0x5a4adf5a, (q31_t)0x5a466b24, (q31_t)0x5a41f6b7, (q31_t)0x5a3d8212, - (q31_t)0x5a390d35, (q31_t)0x5a349821, (q31_t)0x5a3022d5, (q31_t)0x5a2bad51, (q31_t)0x5a273796, (q31_t)0x5a22c1a3, (q31_t)0x5a1e4b79, (q31_t)0x5a19d517, - (q31_t)0x5a155e7d, (q31_t)0x5a10e7ac, (q31_t)0x5a0c70a3, (q31_t)0x5a07f963, (q31_t)0x5a0381eb, (q31_t)0x59ff0a3c, (q31_t)0x59fa9255, (q31_t)0x59f61a36, - (q31_t)0x59f1a1e0, (q31_t)0x59ed2953, (q31_t)0x59e8b08e, (q31_t)0x59e43792, (q31_t)0x59dfbe5e, (q31_t)0x59db44f3, (q31_t)0x59d6cb50, (q31_t)0x59d25176, - (q31_t)0x59cdd765, (q31_t)0x59c95d1c, (q31_t)0x59c4e29c, (q31_t)0x59c067e4, (q31_t)0x59bbecf5, (q31_t)0x59b771cf, (q31_t)0x59b2f671, (q31_t)0x59ae7add, - (q31_t)0x59a9ff10, (q31_t)0x59a5830d, (q31_t)0x59a106d2, (q31_t)0x599c8a60, (q31_t)0x59980db6, (q31_t)0x599390d5, (q31_t)0x598f13bd, (q31_t)0x598a966e, - (q31_t)0x598618e8, (q31_t)0x59819b2a, (q31_t)0x597d1d35, (q31_t)0x59789f09, (q31_t)0x597420a6, (q31_t)0x596fa20b, (q31_t)0x596b233a, (q31_t)0x5966a431, - (q31_t)0x596224f1, (q31_t)0x595da57a, (q31_t)0x595925cc, (q31_t)0x5954a5e6, (q31_t)0x595025ca, (q31_t)0x594ba576, (q31_t)0x594724ec, (q31_t)0x5942a42a, - (q31_t)0x593e2331, (q31_t)0x5939a202, (q31_t)0x5935209b, (q31_t)0x59309efd, (q31_t)0x592c1d28, (q31_t)0x59279b1c, (q31_t)0x592318d9, (q31_t)0x591e9660, - (q31_t)0x591a13af, (q31_t)0x591590c7, (q31_t)0x59110da8, (q31_t)0x590c8a53, (q31_t)0x590806c6, (q31_t)0x59038302, (q31_t)0x58feff08, (q31_t)0x58fa7ad7, - (q31_t)0x58f5f66e, (q31_t)0x58f171cf, (q31_t)0x58ececf9, (q31_t)0x58e867ed, (q31_t)0x58e3e2a9, (q31_t)0x58df5d2e, (q31_t)0x58dad77d, (q31_t)0x58d65195, - (q31_t)0x58d1cb76, (q31_t)0x58cd4520, (q31_t)0x58c8be94, (q31_t)0x58c437d1, (q31_t)0x58bfb0d7, (q31_t)0x58bb29a6, (q31_t)0x58b6a23e, (q31_t)0x58b21aa0, - (q31_t)0x58ad92cb, (q31_t)0x58a90ac0, (q31_t)0x58a4827d, (q31_t)0x589ffa04, (q31_t)0x589b7155, (q31_t)0x5896e86f, (q31_t)0x58925f52, (q31_t)0x588dd5fe, - (q31_t)0x58894c74, (q31_t)0x5884c2b3, (q31_t)0x588038bb, (q31_t)0x587bae8d, (q31_t)0x58772429, (q31_t)0x5872998e, (q31_t)0x586e0ebc, (q31_t)0x586983b4, - (q31_t)0x5864f875, (q31_t)0x58606d00, (q31_t)0x585be154, (q31_t)0x58575571, (q31_t)0x5852c958, (q31_t)0x584e3d09, (q31_t)0x5849b083, (q31_t)0x584523c7, - (q31_t)0x584096d4, (q31_t)0x583c09ab, (q31_t)0x58377c4c, (q31_t)0x5832eeb6, (q31_t)0x582e60e9, (q31_t)0x5829d2e6, (q31_t)0x582544ad, (q31_t)0x5820b63e, - (q31_t)0x581c2798, (q31_t)0x581798bb, (q31_t)0x581309a9, (q31_t)0x580e7a60, (q31_t)0x5809eae1, (q31_t)0x58055b2b, (q31_t)0x5800cb3f, (q31_t)0x57fc3b1d, - (q31_t)0x57f7aac5, (q31_t)0x57f31a36, (q31_t)0x57ee8971, (q31_t)0x57e9f876, (q31_t)0x57e56744, (q31_t)0x57e0d5dd, (q31_t)0x57dc443f, (q31_t)0x57d7b26b, - (q31_t)0x57d32061, (q31_t)0x57ce8e20, (q31_t)0x57c9fbaa, (q31_t)0x57c568fd, (q31_t)0x57c0d61a, (q31_t)0x57bc4301, (q31_t)0x57b7afb2, (q31_t)0x57b31c2d, - (q31_t)0x57ae8872, (q31_t)0x57a9f480, (q31_t)0x57a56059, (q31_t)0x57a0cbfb, (q31_t)0x579c3768, (q31_t)0x5797a29e, (q31_t)0x57930d9e, (q31_t)0x578e7869, - (q31_t)0x5789e2fd, (q31_t)0x57854d5b, (q31_t)0x5780b784, (q31_t)0x577c2176, (q31_t)0x57778b32, (q31_t)0x5772f4b9, (q31_t)0x576e5e09, (q31_t)0x5769c724, - (q31_t)0x57653009, (q31_t)0x576098b7, (q31_t)0x575c0130, (q31_t)0x57576973, (q31_t)0x5752d180, (q31_t)0x574e3957, (q31_t)0x5749a0f9, (q31_t)0x57450864, - (q31_t)0x57406f9a, (q31_t)0x573bd69a, (q31_t)0x57373d64, (q31_t)0x5732a3f8, (q31_t)0x572e0a56, (q31_t)0x5729707f, (q31_t)0x5724d672, (q31_t)0x57203c2f, - (q31_t)0x571ba1b7, (q31_t)0x57170708, (q31_t)0x57126c24, (q31_t)0x570dd10a, (q31_t)0x570935bb, (q31_t)0x57049a36, (q31_t)0x56fffe7b, (q31_t)0x56fb628b, - (q31_t)0x56f6c664, (q31_t)0x56f22a09, (q31_t)0x56ed8d77, (q31_t)0x56e8f0b0, (q31_t)0x56e453b4, (q31_t)0x56dfb681, (q31_t)0x56db1919, (q31_t)0x56d67b7c, - (q31_t)0x56d1dda9, (q31_t)0x56cd3fa1, (q31_t)0x56c8a162, (q31_t)0x56c402ef, (q31_t)0x56bf6446, (q31_t)0x56bac567, (q31_t)0x56b62653, (q31_t)0x56b18709, - (q31_t)0x56ace78a, (q31_t)0x56a847d6, (q31_t)0x56a3a7ec, (q31_t)0x569f07cc, (q31_t)0x569a6777, (q31_t)0x5695c6ed, (q31_t)0x5691262d, (q31_t)0x568c8538, - (q31_t)0x5687e40e, (q31_t)0x568342ae, (q31_t)0x567ea118, (q31_t)0x5679ff4e, (q31_t)0x56755d4e, (q31_t)0x5670bb19, (q31_t)0x566c18ae, (q31_t)0x5667760e, - (q31_t)0x5662d339, (q31_t)0x565e302e, (q31_t)0x56598cee, (q31_t)0x5654e979, (q31_t)0x565045cf, (q31_t)0x564ba1f0, (q31_t)0x5646fddb, (q31_t)0x56425991, - (q31_t)0x563db512, (q31_t)0x5639105d, (q31_t)0x56346b74, (q31_t)0x562fc655, (q31_t)0x562b2101, (q31_t)0x56267b78, (q31_t)0x5621d5ba, (q31_t)0x561d2fc6, - (q31_t)0x5618899e, (q31_t)0x5613e340, (q31_t)0x560f3cae, (q31_t)0x560a95e6, (q31_t)0x5605eee9, (q31_t)0x560147b7, (q31_t)0x55fca050, (q31_t)0x55f7f8b4, - (q31_t)0x55f350e3, (q31_t)0x55eea8dd, (q31_t)0x55ea00a2, (q31_t)0x55e55832, (q31_t)0x55e0af8d, (q31_t)0x55dc06b3, (q31_t)0x55d75da4, (q31_t)0x55d2b460, - (q31_t)0x55ce0ae7, (q31_t)0x55c96139, (q31_t)0x55c4b757, (q31_t)0x55c00d3f, (q31_t)0x55bb62f3, (q31_t)0x55b6b871, (q31_t)0x55b20dbb, (q31_t)0x55ad62d0, - (q31_t)0x55a8b7b0, (q31_t)0x55a40c5b, (q31_t)0x559f60d1, (q31_t)0x559ab513, (q31_t)0x55960920, (q31_t)0x55915cf8, (q31_t)0x558cb09b, (q31_t)0x55880409, - (q31_t)0x55835743, (q31_t)0x557eaa48, (q31_t)0x5579fd18, (q31_t)0x55754fb3, (q31_t)0x5570a21a, (q31_t)0x556bf44c, (q31_t)0x55674649, (q31_t)0x55629812, - (q31_t)0x555de9a6, (q31_t)0x55593b05, (q31_t)0x55548c30, (q31_t)0x554fdd26, (q31_t)0x554b2de7, (q31_t)0x55467e74, (q31_t)0x5541cecc, (q31_t)0x553d1ef0, - (q31_t)0x55386edf, (q31_t)0x5533be99, (q31_t)0x552f0e1f, (q31_t)0x552a5d70, (q31_t)0x5525ac8d, (q31_t)0x5520fb75, (q31_t)0x551c4a29, (q31_t)0x551798a8, - (q31_t)0x5512e6f3, (q31_t)0x550e3509, (q31_t)0x550982eb, (q31_t)0x5504d099, (q31_t)0x55001e12, (q31_t)0x54fb6b56, (q31_t)0x54f6b866, (q31_t)0x54f20542, - (q31_t)0x54ed51e9, (q31_t)0x54e89e5c, (q31_t)0x54e3ea9a, (q31_t)0x54df36a5, (q31_t)0x54da827a, (q31_t)0x54d5ce1c, (q31_t)0x54d11989, (q31_t)0x54cc64c2, - (q31_t)0x54c7afc6, (q31_t)0x54c2fa96, (q31_t)0x54be4532, (q31_t)0x54b98f9a, (q31_t)0x54b4d9cd, (q31_t)0x54b023cc, (q31_t)0x54ab6d97, (q31_t)0x54a6b72e, - (q31_t)0x54a20090, (q31_t)0x549d49bf, (q31_t)0x549892b9, (q31_t)0x5493db7f, (q31_t)0x548f2410, (q31_t)0x548a6c6e, (q31_t)0x5485b497, (q31_t)0x5480fc8c, - (q31_t)0x547c444d, (q31_t)0x54778bda, (q31_t)0x5472d333, (q31_t)0x546e1a58, (q31_t)0x54696149, (q31_t)0x5464a805, (q31_t)0x545fee8e, (q31_t)0x545b34e3, - (q31_t)0x54567b03, (q31_t)0x5451c0f0, (q31_t)0x544d06a8, (q31_t)0x54484c2d, (q31_t)0x5443917d, (q31_t)0x543ed699, (q31_t)0x543a1b82, (q31_t)0x54356037, - (q31_t)0x5430a4b7, (q31_t)0x542be904, (q31_t)0x54272d1d, (q31_t)0x54227102, (q31_t)0x541db4b3, (q31_t)0x5418f830, (q31_t)0x54143b79, (q31_t)0x540f7e8e, - (q31_t)0x540ac170, (q31_t)0x5406041d, (q31_t)0x54014697, (q31_t)0x53fc88dd, (q31_t)0x53f7caef, (q31_t)0x53f30cce, (q31_t)0x53ee4e78, (q31_t)0x53e98fef, - (q31_t)0x53e4d132, (q31_t)0x53e01242, (q31_t)0x53db531d, (q31_t)0x53d693c5, (q31_t)0x53d1d439, (q31_t)0x53cd147a, (q31_t)0x53c85486, (q31_t)0x53c3945f, - (q31_t)0x53bed405, (q31_t)0x53ba1377, (q31_t)0x53b552b5, (q31_t)0x53b091bf, (q31_t)0x53abd096, (q31_t)0x53a70f39, (q31_t)0x53a24da9, (q31_t)0x539d8be5, - (q31_t)0x5398c9ed, (q31_t)0x539407c2, (q31_t)0x538f4564, (q31_t)0x538a82d1, (q31_t)0x5385c00c, (q31_t)0x5380fd12, (q31_t)0x537c39e6, (q31_t)0x53777685, - (q31_t)0x5372b2f2, (q31_t)0x536def2a, (q31_t)0x53692b30, (q31_t)0x53646701, (q31_t)0x535fa2a0, (q31_t)0x535ade0b, (q31_t)0x53561942, (q31_t)0x53515447, - (q31_t)0x534c8f17, (q31_t)0x5347c9b5, (q31_t)0x5343041f, (q31_t)0x533e3e55, (q31_t)0x53397859, (q31_t)0x5334b229, (q31_t)0x532febc5, (q31_t)0x532b252f, - (q31_t)0x53265e65, (q31_t)0x53219767, (q31_t)0x531cd037, (q31_t)0x531808d3, (q31_t)0x5313413c, (q31_t)0x530e7972, (q31_t)0x5309b174, (q31_t)0x5304e943, - (q31_t)0x530020df, (q31_t)0x52fb5848, (q31_t)0x52f68f7e, (q31_t)0x52f1c680, (q31_t)0x52ecfd4f, (q31_t)0x52e833ec, (q31_t)0x52e36a55, (q31_t)0x52dea08a, - (q31_t)0x52d9d68d, (q31_t)0x52d50c5d, (q31_t)0x52d041f9, (q31_t)0x52cb7763, (q31_t)0x52c6ac99, (q31_t)0x52c1e19d, (q31_t)0x52bd166d, (q31_t)0x52b84b0a, - (q31_t)0x52b37f74, (q31_t)0x52aeb3ac, (q31_t)0x52a9e7b0, (q31_t)0x52a51b81, (q31_t)0x52a04f1f, (q31_t)0x529b828a, (q31_t)0x5296b5c3, (q31_t)0x5291e8c8, - (q31_t)0x528d1b9b, (q31_t)0x52884e3a, (q31_t)0x528380a7, (q31_t)0x527eb2e0, (q31_t)0x5279e4e7, (q31_t)0x527516bb, (q31_t)0x5270485c, (q31_t)0x526b79ca, - (q31_t)0x5266ab06, (q31_t)0x5261dc0e, (q31_t)0x525d0ce4, (q31_t)0x52583d87, (q31_t)0x52536df7, (q31_t)0x524e9e34, (q31_t)0x5249ce3f, (q31_t)0x5244fe17, - (q31_t)0x52402dbc, (q31_t)0x523b5d2e, (q31_t)0x52368c6e, (q31_t)0x5231bb7b, (q31_t)0x522cea55, (q31_t)0x522818fc, (q31_t)0x52234771, (q31_t)0x521e75b3, - (q31_t)0x5219a3c3, (q31_t)0x5214d1a0, (q31_t)0x520fff4a, (q31_t)0x520b2cc2, (q31_t)0x52065a07, (q31_t)0x52018719, (q31_t)0x51fcb3f9, (q31_t)0x51f7e0a6, - (q31_t)0x51f30d21, (q31_t)0x51ee3969, (q31_t)0x51e9657e, (q31_t)0x51e49162, (q31_t)0x51dfbd12, (q31_t)0x51dae890, (q31_t)0x51d613dc, (q31_t)0x51d13ef5, - (q31_t)0x51cc69db, (q31_t)0x51c79490, (q31_t)0x51c2bf11, (q31_t)0x51bde960, (q31_t)0x51b9137d, (q31_t)0x51b43d68, (q31_t)0x51af6720, (q31_t)0x51aa90a5, - (q31_t)0x51a5b9f9, (q31_t)0x51a0e31a, (q31_t)0x519c0c08, (q31_t)0x519734c4, (q31_t)0x51925d4e, (q31_t)0x518d85a6, (q31_t)0x5188adcb, (q31_t)0x5183d5be, - (q31_t)0x517efd7f, (q31_t)0x517a250d, (q31_t)0x51754c69, (q31_t)0x51707393, (q31_t)0x516b9a8b, (q31_t)0x5166c150, (q31_t)0x5161e7e4, (q31_t)0x515d0e45, - (q31_t)0x51583473, (q31_t)0x51535a70, (q31_t)0x514e803b, (q31_t)0x5149a5d3, (q31_t)0x5144cb39, (q31_t)0x513ff06d, (q31_t)0x513b156f, (q31_t)0x51363a3f, - (q31_t)0x51315edd, (q31_t)0x512c8348, (q31_t)0x5127a782, (q31_t)0x5122cb8a, (q31_t)0x511def5f, (q31_t)0x51191302, (q31_t)0x51143674, (q31_t)0x510f59b3, - (q31_t)0x510a7cc1, (q31_t)0x51059f9c, (q31_t)0x5100c246, (q31_t)0x50fbe4bd, (q31_t)0x50f70703, (q31_t)0x50f22916, (q31_t)0x50ed4af8, (q31_t)0x50e86ca8, - (q31_t)0x50e38e25, (q31_t)0x50deaf71, (q31_t)0x50d9d08b, (q31_t)0x50d4f173, (q31_t)0x50d0122a, (q31_t)0x50cb32ae, (q31_t)0x50c65301, (q31_t)0x50c17322, - (q31_t)0x50bc9311, (q31_t)0x50b7b2ce, (q31_t)0x50b2d259, (q31_t)0x50adf1b3, (q31_t)0x50a910db, (q31_t)0x50a42fd1, (q31_t)0x509f4e95, (q31_t)0x509a6d28, - (q31_t)0x50958b88, (q31_t)0x5090a9b8, (q31_t)0x508bc7b5, (q31_t)0x5086e581, (q31_t)0x5082031b, (q31_t)0x507d2083, (q31_t)0x50783dba, (q31_t)0x50735abf, - (q31_t)0x506e7793, (q31_t)0x50699435, (q31_t)0x5064b0a5, (q31_t)0x505fcce4, (q31_t)0x505ae8f1, (q31_t)0x505604cd, (q31_t)0x50512077, (q31_t)0x504c3bef, - (q31_t)0x50475736, (q31_t)0x5042724c, (q31_t)0x503d8d30, (q31_t)0x5038a7e2, (q31_t)0x5033c263, (q31_t)0x502edcb2, (q31_t)0x5029f6d1, (q31_t)0x502510bd, - (q31_t)0x50202a78, (q31_t)0x501b4402, (q31_t)0x50165d5a, (q31_t)0x50117681, (q31_t)0x500c8f77, (q31_t)0x5007a83b, (q31_t)0x5002c0cd, (q31_t)0x4ffdd92f, - (q31_t)0x4ff8f15f, (q31_t)0x4ff4095e, (q31_t)0x4fef212b, (q31_t)0x4fea38c7, (q31_t)0x4fe55032, (q31_t)0x4fe0676c, (q31_t)0x4fdb7e74, (q31_t)0x4fd6954b, - (q31_t)0x4fd1abf0, (q31_t)0x4fccc265, (q31_t)0x4fc7d8a8, (q31_t)0x4fc2eeba, (q31_t)0x4fbe049b, (q31_t)0x4fb91a4b, (q31_t)0x4fb42fc9, (q31_t)0x4faf4517, - (q31_t)0x4faa5a33, (q31_t)0x4fa56f1e, (q31_t)0x4fa083d8, (q31_t)0x4f9b9861, (q31_t)0x4f96acb8, (q31_t)0x4f91c0df, (q31_t)0x4f8cd4d4, (q31_t)0x4f87e899, - (q31_t)0x4f82fc2c, (q31_t)0x4f7e0f8f, (q31_t)0x4f7922c0, (q31_t)0x4f7435c0, (q31_t)0x4f6f488f, (q31_t)0x4f6a5b2e, (q31_t)0x4f656d9b, (q31_t)0x4f607fd7, - (q31_t)0x4f5b91e3, (q31_t)0x4f56a3bd, (q31_t)0x4f51b566, (q31_t)0x4f4cc6df, (q31_t)0x4f47d827, (q31_t)0x4f42e93d, (q31_t)0x4f3dfa23, (q31_t)0x4f390ad8, - (q31_t)0x4f341b5c, (q31_t)0x4f2f2baf, (q31_t)0x4f2a3bd2, (q31_t)0x4f254bc3, (q31_t)0x4f205b84, (q31_t)0x4f1b6b14, (q31_t)0x4f167a73, (q31_t)0x4f1189a1, - (q31_t)0x4f0c989f, (q31_t)0x4f07a76b, (q31_t)0x4f02b608, (q31_t)0x4efdc473, (q31_t)0x4ef8d2ad, (q31_t)0x4ef3e0b7, (q31_t)0x4eeeee90, (q31_t)0x4ee9fc39, - (q31_t)0x4ee509b1, (q31_t)0x4ee016f8, (q31_t)0x4edb240e, (q31_t)0x4ed630f4, (q31_t)0x4ed13da9, (q31_t)0x4ecc4a2e, (q31_t)0x4ec75682, (q31_t)0x4ec262a5, - (q31_t)0x4ebd6e98, (q31_t)0x4eb87a5a, (q31_t)0x4eb385ec, (q31_t)0x4eae914d, (q31_t)0x4ea99c7d, (q31_t)0x4ea4a77d, (q31_t)0x4e9fb24d, (q31_t)0x4e9abcec, - (q31_t)0x4e95c75b, (q31_t)0x4e90d199, (q31_t)0x4e8bdba6, (q31_t)0x4e86e583, (q31_t)0x4e81ef30, (q31_t)0x4e7cf8ac, (q31_t)0x4e7801f8, (q31_t)0x4e730b14, - (q31_t)0x4e6e13ff, (q31_t)0x4e691cba, (q31_t)0x4e642544, (q31_t)0x4e5f2d9e, (q31_t)0x4e5a35c7, (q31_t)0x4e553dc1, (q31_t)0x4e50458a, (q31_t)0x4e4b4d22, - (q31_t)0x4e46548b, (q31_t)0x4e415bc3, (q31_t)0x4e3c62cb, (q31_t)0x4e3769a2, (q31_t)0x4e32704a, (q31_t)0x4e2d76c1, (q31_t)0x4e287d08, (q31_t)0x4e23831e, - (q31_t)0x4e1e8905, (q31_t)0x4e198ebb, (q31_t)0x4e149441, (q31_t)0x4e0f9997, (q31_t)0x4e0a9ebd, (q31_t)0x4e05a3b2, (q31_t)0x4e00a878, (q31_t)0x4dfbad0d, - (q31_t)0x4df6b173, (q31_t)0x4df1b5a8, (q31_t)0x4decb9ad, (q31_t)0x4de7bd82, (q31_t)0x4de2c127, (q31_t)0x4dddc49c, (q31_t)0x4dd8c7e1, (q31_t)0x4dd3caf6, - (q31_t)0x4dcecdda, (q31_t)0x4dc9d08f, (q31_t)0x4dc4d314, (q31_t)0x4dbfd569, (q31_t)0x4dbad78e, (q31_t)0x4db5d983, (q31_t)0x4db0db48, (q31_t)0x4dabdcdd, - (q31_t)0x4da6de43, (q31_t)0x4da1df78, (q31_t)0x4d9ce07d, (q31_t)0x4d97e153, (q31_t)0x4d92e1f9, (q31_t)0x4d8de26f, (q31_t)0x4d88e2b5, (q31_t)0x4d83e2cb, - (q31_t)0x4d7ee2b1, (q31_t)0x4d79e268, (q31_t)0x4d74e1ef, (q31_t)0x4d6fe146, (q31_t)0x4d6ae06d, (q31_t)0x4d65df64, (q31_t)0x4d60de2c, (q31_t)0x4d5bdcc4, - (q31_t)0x4d56db2d, (q31_t)0x4d51d965, (q31_t)0x4d4cd76e, (q31_t)0x4d47d547, (q31_t)0x4d42d2f1, (q31_t)0x4d3dd06b, (q31_t)0x4d38cdb5, (q31_t)0x4d33cad0, - (q31_t)0x4d2ec7bb, (q31_t)0x4d29c476, (q31_t)0x4d24c102, (q31_t)0x4d1fbd5e, (q31_t)0x4d1ab98b, (q31_t)0x4d15b588, (q31_t)0x4d10b155, (q31_t)0x4d0bacf3, - (q31_t)0x4d06a862, (q31_t)0x4d01a3a0, (q31_t)0x4cfc9eb0, (q31_t)0x4cf79990, (q31_t)0x4cf29440, (q31_t)0x4ced8ec1, (q31_t)0x4ce88913, (q31_t)0x4ce38335, - (q31_t)0x4cde7d28, (q31_t)0x4cd976eb, (q31_t)0x4cd4707f, (q31_t)0x4ccf69e3, (q31_t)0x4cca6318, (q31_t)0x4cc55c1e, (q31_t)0x4cc054f4, (q31_t)0x4cbb4d9b, - (q31_t)0x4cb64613, (q31_t)0x4cb13e5b, (q31_t)0x4cac3674, (q31_t)0x4ca72e5e, (q31_t)0x4ca22619, (q31_t)0x4c9d1da4, (q31_t)0x4c981500, (q31_t)0x4c930c2d, - (q31_t)0x4c8e032a, (q31_t)0x4c88f9f8, (q31_t)0x4c83f097, (q31_t)0x4c7ee707, (q31_t)0x4c79dd48, (q31_t)0x4c74d359, (q31_t)0x4c6fc93b, (q31_t)0x4c6abeef, - (q31_t)0x4c65b473, (q31_t)0x4c60a9c8, (q31_t)0x4c5b9eed, (q31_t)0x4c5693e4, (q31_t)0x4c5188ac, (q31_t)0x4c4c7d44, (q31_t)0x4c4771ae, (q31_t)0x4c4265e8, - (q31_t)0x4c3d59f3, (q31_t)0x4c384dd0, (q31_t)0x4c33417d, (q31_t)0x4c2e34fb, (q31_t)0x4c29284b, (q31_t)0x4c241b6b, (q31_t)0x4c1f0e5c, (q31_t)0x4c1a011f, - (q31_t)0x4c14f3b2, (q31_t)0x4c0fe617, (q31_t)0x4c0ad84c, (q31_t)0x4c05ca53, (q31_t)0x4c00bc2b, (q31_t)0x4bfbadd4, (q31_t)0x4bf69f4e, (q31_t)0x4bf19099, - (q31_t)0x4bec81b5, (q31_t)0x4be772a3, (q31_t)0x4be26362, (q31_t)0x4bdd53f2, (q31_t)0x4bd84453, (q31_t)0x4bd33485, (q31_t)0x4bce2488, (q31_t)0x4bc9145d, - (q31_t)0x4bc40403, (q31_t)0x4bbef37b, (q31_t)0x4bb9e2c3, (q31_t)0x4bb4d1dd, (q31_t)0x4bafc0c8, (q31_t)0x4baaaf85, (q31_t)0x4ba59e12, (q31_t)0x4ba08c72, - (q31_t)0x4b9b7aa2, (q31_t)0x4b9668a4, (q31_t)0x4b915677, (q31_t)0x4b8c441c, (q31_t)0x4b873192, (q31_t)0x4b821ed9, (q31_t)0x4b7d0bf2, (q31_t)0x4b77f8dc, - (q31_t)0x4b72e598, (q31_t)0x4b6dd225, (q31_t)0x4b68be84, (q31_t)0x4b63aab4, (q31_t)0x4b5e96b6, (q31_t)0x4b598289, (q31_t)0x4b546e2d, (q31_t)0x4b4f59a4, - (q31_t)0x4b4a44eb, (q31_t)0x4b453005, (q31_t)0x4b401aef, (q31_t)0x4b3b05ac, (q31_t)0x4b35f03a, (q31_t)0x4b30da9a, (q31_t)0x4b2bc4cb, (q31_t)0x4b26aece, - (q31_t)0x4b2198a2, (q31_t)0x4b1c8248, (q31_t)0x4b176bc0, (q31_t)0x4b12550a, (q31_t)0x4b0d3e25, (q31_t)0x4b082712, (q31_t)0x4b030fd1, (q31_t)0x4afdf861, - (q31_t)0x4af8e0c3, (q31_t)0x4af3c8f7, (q31_t)0x4aeeb0fd, (q31_t)0x4ae998d4, (q31_t)0x4ae4807d, (q31_t)0x4adf67f8, (q31_t)0x4ada4f45, (q31_t)0x4ad53664, - (q31_t)0x4ad01d54, (q31_t)0x4acb0417, (q31_t)0x4ac5eaab, (q31_t)0x4ac0d111, (q31_t)0x4abbb749, (q31_t)0x4ab69d53, (q31_t)0x4ab1832f, (q31_t)0x4aac68dc, - (q31_t)0x4aa74e5c, (q31_t)0x4aa233ae, (q31_t)0x4a9d18d1, (q31_t)0x4a97fdc7, (q31_t)0x4a92e28e, (q31_t)0x4a8dc728, (q31_t)0x4a88ab93, (q31_t)0x4a838fd1, - (q31_t)0x4a7e73e0, (q31_t)0x4a7957c2, (q31_t)0x4a743b76, (q31_t)0x4a6f1efc, (q31_t)0x4a6a0253, (q31_t)0x4a64e57d, (q31_t)0x4a5fc879, (q31_t)0x4a5aab48, - (q31_t)0x4a558de8, (q31_t)0x4a50705a, (q31_t)0x4a4b529f, (q31_t)0x4a4634b6, (q31_t)0x4a41169f, (q31_t)0x4a3bf85a, (q31_t)0x4a36d9e7, (q31_t)0x4a31bb47, - (q31_t)0x4a2c9c79, (q31_t)0x4a277d7d, (q31_t)0x4a225e53, (q31_t)0x4a1d3efc, (q31_t)0x4a181f77, (q31_t)0x4a12ffc4, (q31_t)0x4a0ddfe4, (q31_t)0x4a08bfd5, - (q31_t)0x4a039f9a, (q31_t)0x49fe7f30, (q31_t)0x49f95e99, (q31_t)0x49f43dd4, (q31_t)0x49ef1ce2, (q31_t)0x49e9fbc2, (q31_t)0x49e4da74, (q31_t)0x49dfb8f9, - (q31_t)0x49da9750, (q31_t)0x49d5757a, (q31_t)0x49d05376, (q31_t)0x49cb3145, (q31_t)0x49c60ee6, (q31_t)0x49c0ec59, (q31_t)0x49bbc9a0, (q31_t)0x49b6a6b8, - (q31_t)0x49b183a3, (q31_t)0x49ac6061, (q31_t)0x49a73cf1, (q31_t)0x49a21954, (q31_t)0x499cf589, (q31_t)0x4997d191, (q31_t)0x4992ad6c, (q31_t)0x498d8919, - (q31_t)0x49886499, (q31_t)0x49833fec, (q31_t)0x497e1b11, (q31_t)0x4978f609, (q31_t)0x4973d0d3, (q31_t)0x496eab70, (q31_t)0x496985e0, (q31_t)0x49646023, - (q31_t)0x495f3a38, (q31_t)0x495a1420, (q31_t)0x4954eddb, (q31_t)0x494fc768, (q31_t)0x494aa0c9, (q31_t)0x494579fc, (q31_t)0x49405302, (q31_t)0x493b2bdb, - (q31_t)0x49360486, (q31_t)0x4930dd05, (q31_t)0x492bb556, (q31_t)0x49268d7a, (q31_t)0x49216571, (q31_t)0x491c3d3b, (q31_t)0x491714d8, (q31_t)0x4911ec47, - (q31_t)0x490cc38a, (q31_t)0x49079aa0, (q31_t)0x49027188, (q31_t)0x48fd4844, (q31_t)0x48f81ed2, (q31_t)0x48f2f534, (q31_t)0x48edcb68, (q31_t)0x48e8a170, - (q31_t)0x48e3774a, (q31_t)0x48de4cf8, (q31_t)0x48d92278, (q31_t)0x48d3f7cc, (q31_t)0x48ceccf3, (q31_t)0x48c9a1ed, (q31_t)0x48c476b9, (q31_t)0x48bf4b59, - (q31_t)0x48ba1fcd, (q31_t)0x48b4f413, (q31_t)0x48afc82c, (q31_t)0x48aa9c19, (q31_t)0x48a56fd9, (q31_t)0x48a0436c, (q31_t)0x489b16d2, (q31_t)0x4895ea0b, - (q31_t)0x4890bd18, (q31_t)0x488b8ff8, (q31_t)0x488662ab, (q31_t)0x48813531, (q31_t)0x487c078b, (q31_t)0x4876d9b8, (q31_t)0x4871abb8, (q31_t)0x486c7d8c, - (q31_t)0x48674f33, (q31_t)0x486220ad, (q31_t)0x485cf1fa, (q31_t)0x4857c31b, (q31_t)0x48529410, (q31_t)0x484d64d7, (q31_t)0x48483572, (q31_t)0x484305e1, - (q31_t)0x483dd623, (q31_t)0x4838a638, (q31_t)0x48337621, (q31_t)0x482e45dd, (q31_t)0x4829156d, (q31_t)0x4823e4d0, (q31_t)0x481eb407, (q31_t)0x48198311, - (q31_t)0x481451ef, (q31_t)0x480f20a0, (q31_t)0x4809ef25, (q31_t)0x4804bd7e, (q31_t)0x47ff8baa, (q31_t)0x47fa59a9, (q31_t)0x47f5277d, (q31_t)0x47eff523, - (q31_t)0x47eac29e, (q31_t)0x47e58fec, (q31_t)0x47e05d0e, (q31_t)0x47db2a03, (q31_t)0x47d5f6cc, (q31_t)0x47d0c369, (q31_t)0x47cb8fd9, (q31_t)0x47c65c1d, - (q31_t)0x47c12835, (q31_t)0x47bbf421, (q31_t)0x47b6bfe0, (q31_t)0x47b18b74, (q31_t)0x47ac56da, (q31_t)0x47a72215, (q31_t)0x47a1ed24, (q31_t)0x479cb806, - (q31_t)0x479782bc, (q31_t)0x47924d46, (q31_t)0x478d17a4, (q31_t)0x4787e1d6, (q31_t)0x4782abdb, (q31_t)0x477d75b5, (q31_t)0x47783f62, (q31_t)0x477308e3, - (q31_t)0x476dd239, (q31_t)0x47689b62, (q31_t)0x4763645f, (q31_t)0x475e2d30, (q31_t)0x4758f5d5, (q31_t)0x4753be4e, (q31_t)0x474e869b, (q31_t)0x47494ebc, - (q31_t)0x474416b1, (q31_t)0x473ede7a, (q31_t)0x4739a617, (q31_t)0x47346d89, (q31_t)0x472f34ce, (q31_t)0x4729fbe7, (q31_t)0x4724c2d5, (q31_t)0x471f8996, - (q31_t)0x471a502c, (q31_t)0x47151696, (q31_t)0x470fdcd4, (q31_t)0x470aa2e6, (q31_t)0x470568cd, (q31_t)0x47002e87, (q31_t)0x46faf416, (q31_t)0x46f5b979, - (q31_t)0x46f07eb0, (q31_t)0x46eb43bc, (q31_t)0x46e6089b, (q31_t)0x46e0cd4f, (q31_t)0x46db91d8, (q31_t)0x46d65634, (q31_t)0x46d11a65, (q31_t)0x46cbde6a, - (q31_t)0x46c6a244, (q31_t)0x46c165f1, (q31_t)0x46bc2974, (q31_t)0x46b6ecca, (q31_t)0x46b1aff5, (q31_t)0x46ac72f4, (q31_t)0x46a735c8, (q31_t)0x46a1f870, - (q31_t)0x469cbaed, (q31_t)0x46977d3e, (q31_t)0x46923f63, (q31_t)0x468d015d, (q31_t)0x4687c32c, (q31_t)0x468284cf, (q31_t)0x467d4646, (q31_t)0x46780792, - (q31_t)0x4672c8b3, (q31_t)0x466d89a8, (q31_t)0x46684a71, (q31_t)0x46630b0f, (q31_t)0x465dcb82, (q31_t)0x46588bc9, (q31_t)0x46534be5, (q31_t)0x464e0bd6, - (q31_t)0x4648cb9b, (q31_t)0x46438b35, (q31_t)0x463e4aa3, (q31_t)0x463909e7, (q31_t)0x4633c8fe, (q31_t)0x462e87eb, (q31_t)0x462946ac, (q31_t)0x46240542, - (q31_t)0x461ec3ad, (q31_t)0x461981ec, (q31_t)0x46144001, (q31_t)0x460efde9, (q31_t)0x4609bba7, (q31_t)0x4604793a, (q31_t)0x45ff36a1, (q31_t)0x45f9f3dd, - (q31_t)0x45f4b0ee, (q31_t)0x45ef6dd4, (q31_t)0x45ea2a8f, (q31_t)0x45e4e71f, (q31_t)0x45dfa383, (q31_t)0x45da5fbc, (q31_t)0x45d51bcb, (q31_t)0x45cfd7ae, - (q31_t)0x45ca9366, (q31_t)0x45c54ef3, (q31_t)0x45c00a55, (q31_t)0x45bac58c, (q31_t)0x45b58098, (q31_t)0x45b03b79, (q31_t)0x45aaf630, (q31_t)0x45a5b0bb, - (q31_t)0x45a06b1b, (q31_t)0x459b2550, (q31_t)0x4595df5a, (q31_t)0x45909939, (q31_t)0x458b52ee, (q31_t)0x45860c77, (q31_t)0x4580c5d6, (q31_t)0x457b7f0a, - (q31_t)0x45763813, (q31_t)0x4570f0f1, (q31_t)0x456ba9a4, (q31_t)0x4566622c, (q31_t)0x45611a8a, (q31_t)0x455bd2bc, (q31_t)0x45568ac4, (q31_t)0x455142a2, - (q31_t)0x454bfa54, (q31_t)0x4546b1dc, (q31_t)0x45416939, (q31_t)0x453c206b, (q31_t)0x4536d773, (q31_t)0x45318e4f, (q31_t)0x452c4502, (q31_t)0x4526fb89, - (q31_t)0x4521b1e6, (q31_t)0x451c6818, (q31_t)0x45171e20, (q31_t)0x4511d3fd, (q31_t)0x450c89af, (q31_t)0x45073f37, (q31_t)0x4501f494, (q31_t)0x44fca9c6, - (q31_t)0x44f75ecf, (q31_t)0x44f213ac, (q31_t)0x44ecc85f, (q31_t)0x44e77ce7, (q31_t)0x44e23145, (q31_t)0x44dce579, (q31_t)0x44d79982, (q31_t)0x44d24d60, - (q31_t)0x44cd0114, (q31_t)0x44c7b49e, (q31_t)0x44c267fd, (q31_t)0x44bd1b32, (q31_t)0x44b7ce3c, (q31_t)0x44b2811c, (q31_t)0x44ad33d2, (q31_t)0x44a7e65d, - (q31_t)0x44a298be, (q31_t)0x449d4af5, (q31_t)0x4497fd01, (q31_t)0x4492aee3, (q31_t)0x448d609b, (q31_t)0x44881228, (q31_t)0x4482c38b, (q31_t)0x447d74c4, - (q31_t)0x447825d2, (q31_t)0x4472d6b7, (q31_t)0x446d8771, (q31_t)0x44683801, (q31_t)0x4462e866, (q31_t)0x445d98a2, (q31_t)0x445848b3, (q31_t)0x4452f89b, - (q31_t)0x444da858, (q31_t)0x444857ea, (q31_t)0x44430753, (q31_t)0x443db692, (q31_t)0x443865a7, (q31_t)0x44331491, (q31_t)0x442dc351, (q31_t)0x442871e8, - (q31_t)0x44232054, (q31_t)0x441dce96, (q31_t)0x44187caf, (q31_t)0x44132a9d, (q31_t)0x440dd861, (q31_t)0x440885fc, (q31_t)0x4403336c, (q31_t)0x43fde0b2, - (q31_t)0x43f88dcf, (q31_t)0x43f33ac1, (q31_t)0x43ede78a, (q31_t)0x43e89429, (q31_t)0x43e3409d, (q31_t)0x43ddece8, (q31_t)0x43d8990a, (q31_t)0x43d34501, - (q31_t)0x43cdf0ce, (q31_t)0x43c89c72, (q31_t)0x43c347eb, (q31_t)0x43bdf33b, (q31_t)0x43b89e62, (q31_t)0x43b3495e, (q31_t)0x43adf431, (q31_t)0x43a89ed9, - (q31_t)0x43a34959, (q31_t)0x439df3ae, (q31_t)0x43989dda, (q31_t)0x439347dc, (q31_t)0x438df1b4, (q31_t)0x43889b63, (q31_t)0x438344e8, (q31_t)0x437dee43, - (q31_t)0x43789775, (q31_t)0x4373407d, (q31_t)0x436de95b, (q31_t)0x43689210, (q31_t)0x43633a9c, (q31_t)0x435de2fd, (q31_t)0x43588b36, (q31_t)0x43533344, - (q31_t)0x434ddb29, (q31_t)0x434882e5, (q31_t)0x43432a77, (q31_t)0x433dd1e0, (q31_t)0x4338791f, (q31_t)0x43332035, (q31_t)0x432dc721, (q31_t)0x43286de4, - (q31_t)0x4323147d, (q31_t)0x431dbaed, (q31_t)0x43186133, (q31_t)0x43130751, (q31_t)0x430dad44, (q31_t)0x4308530f, (q31_t)0x4302f8b0, (q31_t)0x42fd9e28, - (q31_t)0x42f84376, (q31_t)0x42f2e89b, (q31_t)0x42ed8d97, (q31_t)0x42e83269, (q31_t)0x42e2d713, (q31_t)0x42dd7b93, (q31_t)0x42d81fe9, (q31_t)0x42d2c417, - (q31_t)0x42cd681b, (q31_t)0x42c80bf6, (q31_t)0x42c2afa8, (q31_t)0x42bd5331, (q31_t)0x42b7f690, (q31_t)0x42b299c7, (q31_t)0x42ad3cd4, (q31_t)0x42a7dfb8, - (q31_t)0x42a28273, (q31_t)0x429d2505, (q31_t)0x4297c76e, (q31_t)0x429269ae, (q31_t)0x428d0bc4, (q31_t)0x4287adb2, (q31_t)0x42824f76, (q31_t)0x427cf112, - (q31_t)0x42779285, (q31_t)0x427233ce, (q31_t)0x426cd4ef, (q31_t)0x426775e6, (q31_t)0x426216b5, (q31_t)0x425cb75a, (q31_t)0x425757d7, (q31_t)0x4251f82b, - (q31_t)0x424c9856, (q31_t)0x42473858, (q31_t)0x4241d831, (q31_t)0x423c77e1, (q31_t)0x42371769, (q31_t)0x4231b6c7, (q31_t)0x422c55fd, (q31_t)0x4226f50a, - (q31_t)0x422193ee, (q31_t)0x421c32a9, (q31_t)0x4216d13c, (q31_t)0x42116fa5, (q31_t)0x420c0de6, (q31_t)0x4206abfe, (q31_t)0x420149ee, (q31_t)0x41fbe7b5, - (q31_t)0x41f68553, (q31_t)0x41f122c8, (q31_t)0x41ebc015, (q31_t)0x41e65d39, (q31_t)0x41e0fa35, (q31_t)0x41db9707, (q31_t)0x41d633b1, (q31_t)0x41d0d033, - (q31_t)0x41cb6c8c, (q31_t)0x41c608bc, (q31_t)0x41c0a4c4, (q31_t)0x41bb40a3, (q31_t)0x41b5dc5a, (q31_t)0x41b077e8, (q31_t)0x41ab134e, (q31_t)0x41a5ae8b, - (q31_t)0x41a049a0, (q31_t)0x419ae48c, (q31_t)0x41957f4f, (q31_t)0x419019eb, (q31_t)0x418ab45d, (q31_t)0x41854ea8, (q31_t)0x417fe8ca, (q31_t)0x417a82c3, - (q31_t)0x41751c94, (q31_t)0x416fb63d, (q31_t)0x416a4fbd, (q31_t)0x4164e916, (q31_t)0x415f8245, (q31_t)0x415a1b4d, (q31_t)0x4154b42c, (q31_t)0x414f4ce2, - (q31_t)0x4149e571, (q31_t)0x41447dd7, (q31_t)0x413f1615, (q31_t)0x4139ae2b, (q31_t)0x41344618, (q31_t)0x412edddd, (q31_t)0x4129757b, (q31_t)0x41240cef, - (q31_t)0x411ea43c, (q31_t)0x41193b61, (q31_t)0x4113d25d, (q31_t)0x410e6931, (q31_t)0x4108ffdd, (q31_t)0x41039661, (q31_t)0x40fe2cbd, (q31_t)0x40f8c2f1, - (q31_t)0x40f358fc, (q31_t)0x40edeee0, (q31_t)0x40e8849b, (q31_t)0x40e31a2f, (q31_t)0x40ddaf9b, (q31_t)0x40d844de, (q31_t)0x40d2d9f9, (q31_t)0x40cd6eed, - (q31_t)0x40c803b8, (q31_t)0x40c2985c, (q31_t)0x40bd2cd8, (q31_t)0x40b7c12b, (q31_t)0x40b25557, (q31_t)0x40ace95b, (q31_t)0x40a77d37, (q31_t)0x40a210eb, - (q31_t)0x409ca477, (q31_t)0x409737dc, (q31_t)0x4091cb18, (q31_t)0x408c5e2d, (q31_t)0x4086f11a, (q31_t)0x408183df, (q31_t)0x407c167c, (q31_t)0x4076a8f1, - (q31_t)0x40713b3f, (q31_t)0x406bcd65, (q31_t)0x40665f63, (q31_t)0x4060f13a, (q31_t)0x405b82e9, (q31_t)0x40561470, (q31_t)0x4050a5cf, (q31_t)0x404b3707, - (q31_t)0x4045c817, (q31_t)0x404058ff, (q31_t)0x403ae9c0, (q31_t)0x40357a59, (q31_t)0x40300acb, (q31_t)0x402a9b15, (q31_t)0x40252b37, (q31_t)0x401fbb32, - (q31_t)0x401a4b05, (q31_t)0x4014dab1, (q31_t)0x400f6a35, (q31_t)0x4009f992, (q31_t)0x400488c7, (q31_t)0x3fff17d5, (q31_t)0x3ff9a6bb, (q31_t)0x3ff4357a, - (q31_t)0x3feec411, (q31_t)0x3fe95281, (q31_t)0x3fe3e0c9, (q31_t)0x3fde6eeb, (q31_t)0x3fd8fce4, (q31_t)0x3fd38ab6, (q31_t)0x3fce1861, (q31_t)0x3fc8a5e5, - (q31_t)0x3fc33341, (q31_t)0x3fbdc076, (q31_t)0x3fb84d83, (q31_t)0x3fb2da6a, (q31_t)0x3fad6729, (q31_t)0x3fa7f3c0, (q31_t)0x3fa28031, (q31_t)0x3f9d0c7a, - (q31_t)0x3f97989c, (q31_t)0x3f922496, (q31_t)0x3f8cb06a, (q31_t)0x3f873c16, (q31_t)0x3f81c79b, (q31_t)0x3f7c52f9, (q31_t)0x3f76de30, (q31_t)0x3f71693f, - (q31_t)0x3f6bf428, (q31_t)0x3f667ee9, (q31_t)0x3f610983, (q31_t)0x3f5b93f6, (q31_t)0x3f561e42, (q31_t)0x3f50a867, (q31_t)0x3f4b3265, (q31_t)0x3f45bc3c, - (q31_t)0x3f4045ec, (q31_t)0x3f3acf75, (q31_t)0x3f3558d7, (q31_t)0x3f2fe211, (q31_t)0x3f2a6b25, (q31_t)0x3f24f412, (q31_t)0x3f1f7cd8, (q31_t)0x3f1a0577, - (q31_t)0x3f148def, (q31_t)0x3f0f1640, (q31_t)0x3f099e6b, (q31_t)0x3f04266e, (q31_t)0x3efeae4a, (q31_t)0x3ef93600, (q31_t)0x3ef3bd8f, (q31_t)0x3eee44f7, - (q31_t)0x3ee8cc38, (q31_t)0x3ee35352, (q31_t)0x3eddda46, (q31_t)0x3ed86113, (q31_t)0x3ed2e7b9, (q31_t)0x3ecd6e38, (q31_t)0x3ec7f491, (q31_t)0x3ec27ac2, - (q31_t)0x3ebd00cd, (q31_t)0x3eb786b2, (q31_t)0x3eb20c6f, (q31_t)0x3eac9206, (q31_t)0x3ea71777, (q31_t)0x3ea19cc1, (q31_t)0x3e9c21e4, (q31_t)0x3e96a6e0, - (q31_t)0x3e912bb6, (q31_t)0x3e8bb065, (q31_t)0x3e8634ee, (q31_t)0x3e80b950, (q31_t)0x3e7b3d8c, (q31_t)0x3e75c1a1, (q31_t)0x3e70458f, (q31_t)0x3e6ac957, - (q31_t)0x3e654cf8, (q31_t)0x3e5fd073, (q31_t)0x3e5a53c8, (q31_t)0x3e54d6f6, (q31_t)0x3e4f59fe, (q31_t)0x3e49dcdf, (q31_t)0x3e445f99, (q31_t)0x3e3ee22e, - (q31_t)0x3e39649c, (q31_t)0x3e33e6e3, (q31_t)0x3e2e6904, (q31_t)0x3e28eaff, (q31_t)0x3e236cd4, (q31_t)0x3e1dee82, (q31_t)0x3e18700a, (q31_t)0x3e12f16b, - (q31_t)0x3e0d72a6, (q31_t)0x3e07f3bb, (q31_t)0x3e0274aa, (q31_t)0x3dfcf572, (q31_t)0x3df77615, (q31_t)0x3df1f691, (q31_t)0x3dec76e6, (q31_t)0x3de6f716, - (q31_t)0x3de1771f, (q31_t)0x3ddbf703, (q31_t)0x3dd676c0, (q31_t)0x3dd0f656, (q31_t)0x3dcb75c7, (q31_t)0x3dc5f512, (q31_t)0x3dc07436, (q31_t)0x3dbaf335, - (q31_t)0x3db5720d, (q31_t)0x3daff0c0, (q31_t)0x3daa6f4c, (q31_t)0x3da4edb2, (q31_t)0x3d9f6bf2, (q31_t)0x3d99ea0d, (q31_t)0x3d946801, (q31_t)0x3d8ee5cf, - (q31_t)0x3d896377, (q31_t)0x3d83e0f9, (q31_t)0x3d7e5e56, (q31_t)0x3d78db8c, (q31_t)0x3d73589d, (q31_t)0x3d6dd587, (q31_t)0x3d68524c, (q31_t)0x3d62ceeb, - (q31_t)0x3d5d4b64, (q31_t)0x3d57c7b7, (q31_t)0x3d5243e4, (q31_t)0x3d4cbfeb, (q31_t)0x3d473bcd, (q31_t)0x3d41b789, (q31_t)0x3d3c331f, (q31_t)0x3d36ae8f, - (q31_t)0x3d3129da, (q31_t)0x3d2ba4fe, (q31_t)0x3d261ffd, (q31_t)0x3d209ad7, (q31_t)0x3d1b158a, (q31_t)0x3d159018, (q31_t)0x3d100a80, (q31_t)0x3d0a84c3, - (q31_t)0x3d04fee0, (q31_t)0x3cff78d7, (q31_t)0x3cf9f2a9, (q31_t)0x3cf46c55, (q31_t)0x3ceee5db, (q31_t)0x3ce95f3c, (q31_t)0x3ce3d877, (q31_t)0x3cde518d, - (q31_t)0x3cd8ca7d, (q31_t)0x3cd34347, (q31_t)0x3ccdbbed, (q31_t)0x3cc8346c, (q31_t)0x3cc2acc6, (q31_t)0x3cbd24fb, (q31_t)0x3cb79d0a, (q31_t)0x3cb214f4, - (q31_t)0x3cac8cb8, (q31_t)0x3ca70457, (q31_t)0x3ca17bd0, (q31_t)0x3c9bf324, (q31_t)0x3c966a53, (q31_t)0x3c90e15c, (q31_t)0x3c8b5840, (q31_t)0x3c85cefe, - (q31_t)0x3c804598, (q31_t)0x3c7abc0c, (q31_t)0x3c75325a, (q31_t)0x3c6fa883, (q31_t)0x3c6a1e87, (q31_t)0x3c649466, (q31_t)0x3c5f0a20, (q31_t)0x3c597fb4, - (q31_t)0x3c53f523, (q31_t)0x3c4e6a6d, (q31_t)0x3c48df91, (q31_t)0x3c435491, (q31_t)0x3c3dc96b, (q31_t)0x3c383e20, (q31_t)0x3c32b2b0, (q31_t)0x3c2d271b, - (q31_t)0x3c279b61, (q31_t)0x3c220f81, (q31_t)0x3c1c837d, (q31_t)0x3c16f753, (q31_t)0x3c116b04, (q31_t)0x3c0bde91, (q31_t)0x3c0651f8, (q31_t)0x3c00c53a, - (q31_t)0x3bfb3857, (q31_t)0x3bf5ab50, (q31_t)0x3bf01e23, (q31_t)0x3bea90d1, (q31_t)0x3be5035a, (q31_t)0x3bdf75bf, (q31_t)0x3bd9e7fe, (q31_t)0x3bd45a19, - (q31_t)0x3bcecc0e, (q31_t)0x3bc93ddf, (q31_t)0x3bc3af8b, (q31_t)0x3bbe2112, (q31_t)0x3bb89274, (q31_t)0x3bb303b1, (q31_t)0x3bad74c9, (q31_t)0x3ba7e5bd, - (q31_t)0x3ba2568c, (q31_t)0x3b9cc736, (q31_t)0x3b9737bb, (q31_t)0x3b91a81c, (q31_t)0x3b8c1857, (q31_t)0x3b86886e, (q31_t)0x3b80f861, (q31_t)0x3b7b682e, - (q31_t)0x3b75d7d7, (q31_t)0x3b70475c, (q31_t)0x3b6ab6bb, (q31_t)0x3b6525f6, (q31_t)0x3b5f950c, (q31_t)0x3b5a03fe, (q31_t)0x3b5472cb, (q31_t)0x3b4ee173, - (q31_t)0x3b494ff7, (q31_t)0x3b43be57, (q31_t)0x3b3e2c91, (q31_t)0x3b389aa8, (q31_t)0x3b330899, (q31_t)0x3b2d7666, (q31_t)0x3b27e40f, (q31_t)0x3b225193, - (q31_t)0x3b1cbef3, (q31_t)0x3b172c2e, (q31_t)0x3b119945, (q31_t)0x3b0c0637, (q31_t)0x3b067305, (q31_t)0x3b00dfaf, (q31_t)0x3afb4c34, (q31_t)0x3af5b894, - (q31_t)0x3af024d1, (q31_t)0x3aea90e9, (q31_t)0x3ae4fcdc, (q31_t)0x3adf68ac, (q31_t)0x3ad9d457, (q31_t)0x3ad43fdd, (q31_t)0x3aceab40, (q31_t)0x3ac9167e, - (q31_t)0x3ac38198, (q31_t)0x3abdec8d, (q31_t)0x3ab8575f, (q31_t)0x3ab2c20c, (q31_t)0x3aad2c95, (q31_t)0x3aa796fa, (q31_t)0x3aa2013a, (q31_t)0x3a9c6b57, - (q31_t)0x3a96d54f, (q31_t)0x3a913f23, (q31_t)0x3a8ba8d3, (q31_t)0x3a86125f, (q31_t)0x3a807bc7, (q31_t)0x3a7ae50a, (q31_t)0x3a754e2a, (q31_t)0x3a6fb726, - (q31_t)0x3a6a1ffd, (q31_t)0x3a6488b1, (q31_t)0x3a5ef140, (q31_t)0x3a5959ab, (q31_t)0x3a53c1f3, (q31_t)0x3a4e2a16, (q31_t)0x3a489216, (q31_t)0x3a42f9f2, - (q31_t)0x3a3d61a9, (q31_t)0x3a37c93d, (q31_t)0x3a3230ad, (q31_t)0x3a2c97f9, (q31_t)0x3a26ff21, (q31_t)0x3a216625, (q31_t)0x3a1bcd05, (q31_t)0x3a1633c1, - (q31_t)0x3a109a5a, (q31_t)0x3a0b00cf, (q31_t)0x3a056720, (q31_t)0x39ffcd4d, (q31_t)0x39fa3356, (q31_t)0x39f4993c, (q31_t)0x39eefefe, (q31_t)0x39e9649c, - (q31_t)0x39e3ca17, (q31_t)0x39de2f6d, (q31_t)0x39d894a0, (q31_t)0x39d2f9b0, (q31_t)0x39cd5e9b, (q31_t)0x39c7c363, (q31_t)0x39c22808, (q31_t)0x39bc8c89, - (q31_t)0x39b6f0e6, (q31_t)0x39b1551f, (q31_t)0x39abb935, (q31_t)0x39a61d28, (q31_t)0x39a080f6, (q31_t)0x399ae4a2, (q31_t)0x39954829, (q31_t)0x398fab8e, - (q31_t)0x398a0ece, (q31_t)0x398471ec, (q31_t)0x397ed4e5, (q31_t)0x397937bc, (q31_t)0x39739a6e, (q31_t)0x396dfcfe, (q31_t)0x39685f6a, (q31_t)0x3962c1b2, - (q31_t)0x395d23d7, (q31_t)0x395785d9, (q31_t)0x3951e7b8, (q31_t)0x394c4973, (q31_t)0x3946ab0a, (q31_t)0x39410c7f, (q31_t)0x393b6dd0, (q31_t)0x3935cefd, - (q31_t)0x39303008, (q31_t)0x392a90ef, (q31_t)0x3924f1b3, (q31_t)0x391f5254, (q31_t)0x3919b2d1, (q31_t)0x3914132b, (q31_t)0x390e7362, (q31_t)0x3908d376, - (q31_t)0x39033367, (q31_t)0x38fd9334, (q31_t)0x38f7f2de, (q31_t)0x38f25266, (q31_t)0x38ecb1ca, (q31_t)0x38e7110a, (q31_t)0x38e17028, (q31_t)0x38dbcf23, - (q31_t)0x38d62dfb, (q31_t)0x38d08caf, (q31_t)0x38caeb41, (q31_t)0x38c549af, (q31_t)0x38bfa7fb, (q31_t)0x38ba0623, (q31_t)0x38b46429, (q31_t)0x38aec20b, - (q31_t)0x38a91fcb, (q31_t)0x38a37d67, (q31_t)0x389ddae1, (q31_t)0x38983838, (q31_t)0x3892956c, (q31_t)0x388cf27d, (q31_t)0x38874f6b, (q31_t)0x3881ac36, - (q31_t)0x387c08de, (q31_t)0x38766564, (q31_t)0x3870c1c6, (q31_t)0x386b1e06, (q31_t)0x38657a23, (q31_t)0x385fd61d, (q31_t)0x385a31f5, (q31_t)0x38548daa, - (q31_t)0x384ee93b, (q31_t)0x384944ab, (q31_t)0x38439ff7, (q31_t)0x383dfb21, (q31_t)0x38385628, (q31_t)0x3832b10d, (q31_t)0x382d0bce, (q31_t)0x3827666d, - (q31_t)0x3821c0ea, (q31_t)0x381c1b44, (q31_t)0x3816757b, (q31_t)0x3810cf90, (q31_t)0x380b2982, (q31_t)0x38058351, (q31_t)0x37ffdcfe, (q31_t)0x37fa3688, - (q31_t)0x37f48ff0, (q31_t)0x37eee936, (q31_t)0x37e94259, (q31_t)0x37e39b59, (q31_t)0x37ddf437, (q31_t)0x37d84cf2, (q31_t)0x37d2a58b, (q31_t)0x37ccfe02, - (q31_t)0x37c75656, (q31_t)0x37c1ae87, (q31_t)0x37bc0697, (q31_t)0x37b65e84, (q31_t)0x37b0b64e, (q31_t)0x37ab0df6, (q31_t)0x37a5657c, (q31_t)0x379fbce0, - (q31_t)0x379a1421, (q31_t)0x37946b40, (q31_t)0x378ec23d, (q31_t)0x37891917, (q31_t)0x37836fcf, (q31_t)0x377dc665, (q31_t)0x37781cd9, (q31_t)0x3772732a, - (q31_t)0x376cc959, (q31_t)0x37671f66, (q31_t)0x37617551, (q31_t)0x375bcb1a, (q31_t)0x375620c1, (q31_t)0x37507645, (q31_t)0x374acba7, (q31_t)0x374520e7, - (q31_t)0x373f7606, (q31_t)0x3739cb02, (q31_t)0x37341fdc, (q31_t)0x372e7493, (q31_t)0x3728c929, (q31_t)0x37231d9d, (q31_t)0x371d71ef, (q31_t)0x3717c61f, - (q31_t)0x37121a2d, (q31_t)0x370c6e19, (q31_t)0x3706c1e2, (q31_t)0x3701158a, (q31_t)0x36fb6910, (q31_t)0x36f5bc75, (q31_t)0x36f00fb7, (q31_t)0x36ea62d7, - (q31_t)0x36e4b5d6, (q31_t)0x36df08b2, (q31_t)0x36d95b6d, (q31_t)0x36d3ae06, (q31_t)0x36ce007d, (q31_t)0x36c852d2, (q31_t)0x36c2a506, (q31_t)0x36bcf718, - (q31_t)0x36b74908, (q31_t)0x36b19ad6, (q31_t)0x36abec82, (q31_t)0x36a63e0d, (q31_t)0x36a08f76, (q31_t)0x369ae0bd, (q31_t)0x369531e3, (q31_t)0x368f82e7, - (q31_t)0x3689d3c9, (q31_t)0x3684248a, (q31_t)0x367e7529, (q31_t)0x3678c5a7, (q31_t)0x36731602, (q31_t)0x366d663d, (q31_t)0x3667b655, (q31_t)0x3662064c, - (q31_t)0x365c5622, (q31_t)0x3656a5d6, (q31_t)0x3650f569, (q31_t)0x364b44da, (q31_t)0x36459429, (q31_t)0x363fe357, (q31_t)0x363a3264, (q31_t)0x3634814f, - (q31_t)0x362ed019, (q31_t)0x36291ec1, (q31_t)0x36236d48, (q31_t)0x361dbbad, (q31_t)0x361809f1, (q31_t)0x36125814, (q31_t)0x360ca615, (q31_t)0x3606f3f5, - (q31_t)0x360141b4, (q31_t)0x35fb8f52, (q31_t)0x35f5dcce, (q31_t)0x35f02a28, (q31_t)0x35ea7762, (q31_t)0x35e4c47a, (q31_t)0x35df1171, (q31_t)0x35d95e47, - (q31_t)0x35d3aafc, (q31_t)0x35cdf78f, (q31_t)0x35c84401, (q31_t)0x35c29052, (q31_t)0x35bcdc82, (q31_t)0x35b72891, (q31_t)0x35b1747e, (q31_t)0x35abc04b, - (q31_t)0x35a60bf6, (q31_t)0x35a05781, (q31_t)0x359aa2ea, (q31_t)0x3594ee32, (q31_t)0x358f3959, (q31_t)0x3589845f, (q31_t)0x3583cf44, (q31_t)0x357e1a08, - (q31_t)0x357864ab, (q31_t)0x3572af2d, (q31_t)0x356cf98e, (q31_t)0x356743ce, (q31_t)0x35618ded, (q31_t)0x355bd7eb, (q31_t)0x355621c9, (q31_t)0x35506b85, - (q31_t)0x354ab520, (q31_t)0x3544fe9b, (q31_t)0x353f47f5, (q31_t)0x3539912e, (q31_t)0x3533da46, (q31_t)0x352e233d, (q31_t)0x35286c14, (q31_t)0x3522b4c9, - (q31_t)0x351cfd5e, (q31_t)0x351745d2, (q31_t)0x35118e26, (q31_t)0x350bd658, (q31_t)0x35061e6a, (q31_t)0x3500665c, (q31_t)0x34faae2c, (q31_t)0x34f4f5dc, - (q31_t)0x34ef3d6b, (q31_t)0x34e984da, (q31_t)0x34e3cc28, (q31_t)0x34de1355, (q31_t)0x34d85a62, (q31_t)0x34d2a14e, (q31_t)0x34cce819, (q31_t)0x34c72ec4, - (q31_t)0x34c1754e, (q31_t)0x34bbbbb8, (q31_t)0x34b60202, (q31_t)0x34b0482a, (q31_t)0x34aa8e33, (q31_t)0x34a4d41a, (q31_t)0x349f19e2, (q31_t)0x34995f88, - (q31_t)0x3493a50f, (q31_t)0x348dea75, (q31_t)0x34882fba, (q31_t)0x348274e0, (q31_t)0x347cb9e4, (q31_t)0x3476fec9, (q31_t)0x3471438d, (q31_t)0x346b8830, - (q31_t)0x3465ccb4, (q31_t)0x34601117, (q31_t)0x345a5559, (q31_t)0x3454997c, (q31_t)0x344edd7e, (q31_t)0x34492160, (q31_t)0x34436521, (q31_t)0x343da8c3, - (q31_t)0x3437ec44, (q31_t)0x34322fa5, (q31_t)0x342c72e6, (q31_t)0x3426b606, (q31_t)0x3420f907, (q31_t)0x341b3be7, (q31_t)0x34157ea7, (q31_t)0x340fc147, - (q31_t)0x340a03c7, (q31_t)0x34044626, (q31_t)0x33fe8866, (q31_t)0x33f8ca86, (q31_t)0x33f30c85, (q31_t)0x33ed4e65, (q31_t)0x33e79024, (q31_t)0x33e1d1c4, - (q31_t)0x33dc1343, (q31_t)0x33d654a2, (q31_t)0x33d095e2, (q31_t)0x33cad701, (q31_t)0x33c51801, (q31_t)0x33bf58e1, (q31_t)0x33b999a0, (q31_t)0x33b3da40, - (q31_t)0x33ae1ac0, (q31_t)0x33a85b20, (q31_t)0x33a29b60, (q31_t)0x339cdb81, (q31_t)0x33971b81, (q31_t)0x33915b62, (q31_t)0x338b9b22, (q31_t)0x3385dac4, - (q31_t)0x33801a45, (q31_t)0x337a59a6, (q31_t)0x337498e8, (q31_t)0x336ed80a, (q31_t)0x3369170c, (q31_t)0x336355ef, (q31_t)0x335d94b2, (q31_t)0x3357d355, - (q31_t)0x335211d8, (q31_t)0x334c503c, (q31_t)0x33468e80, (q31_t)0x3340cca5, (q31_t)0x333b0aaa, (q31_t)0x3335488f, (q31_t)0x332f8655, (q31_t)0x3329c3fb, - (q31_t)0x33240182, (q31_t)0x331e3ee9, (q31_t)0x33187c31, (q31_t)0x3312b959, (q31_t)0x330cf661, (q31_t)0x3307334a, (q31_t)0x33017014, (q31_t)0x32fbacbe, - (q31_t)0x32f5e948, (q31_t)0x32f025b4, (q31_t)0x32ea61ff, (q31_t)0x32e49e2c, (q31_t)0x32deda39, (q31_t)0x32d91626, (q31_t)0x32d351f5, (q31_t)0x32cd8da4, - (q31_t)0x32c7c933, (q31_t)0x32c204a3, (q31_t)0x32bc3ff4, (q31_t)0x32b67b26, (q31_t)0x32b0b638, (q31_t)0x32aaf12b, (q31_t)0x32a52bff, (q31_t)0x329f66b4, - (q31_t)0x3299a149, (q31_t)0x3293dbbf, (q31_t)0x328e1616, (q31_t)0x3288504e, (q31_t)0x32828a67, (q31_t)0x327cc460, (q31_t)0x3276fe3a, (q31_t)0x327137f6, - (q31_t)0x326b7192, (q31_t)0x3265ab0f, (q31_t)0x325fe46c, (q31_t)0x325a1dab, (q31_t)0x325456cb, (q31_t)0x324e8fcc, (q31_t)0x3248c8ad, (q31_t)0x32430170, - (q31_t)0x323d3a14, (q31_t)0x32377298, (q31_t)0x3231aafe, (q31_t)0x322be345, (q31_t)0x32261b6c, (q31_t)0x32205375, (q31_t)0x321a8b5f, (q31_t)0x3214c32a, - (q31_t)0x320efad6, (q31_t)0x32093263, (q31_t)0x320369d2, (q31_t)0x31fda121, (q31_t)0x31f7d852, (q31_t)0x31f20f64, (q31_t)0x31ec4657, (q31_t)0x31e67d2b, - (q31_t)0x31e0b3e0, (q31_t)0x31daea77, (q31_t)0x31d520ef, (q31_t)0x31cf5748, (q31_t)0x31c98d83, (q31_t)0x31c3c39e, (q31_t)0x31bdf99b, (q31_t)0x31b82f7a, - (q31_t)0x31b2653a, (q31_t)0x31ac9adb, (q31_t)0x31a6d05d, (q31_t)0x31a105c1, (q31_t)0x319b3b06, (q31_t)0x3195702d, (q31_t)0x318fa535, (q31_t)0x3189da1e, - (q31_t)0x31840ee9, (q31_t)0x317e4395, (q31_t)0x31787823, (q31_t)0x3172ac92, (q31_t)0x316ce0e3, (q31_t)0x31671515, (q31_t)0x31614929, (q31_t)0x315b7d1e, - (q31_t)0x3155b0f5, (q31_t)0x314fe4ae, (q31_t)0x314a1848, (q31_t)0x31444bc3, (q31_t)0x313e7f21, (q31_t)0x3138b260, (q31_t)0x3132e580, (q31_t)0x312d1882, - (q31_t)0x31274b66, (q31_t)0x31217e2c, (q31_t)0x311bb0d3, (q31_t)0x3115e35c, (q31_t)0x311015c6, (q31_t)0x310a4813, (q31_t)0x31047a41, (q31_t)0x30feac51, - (q31_t)0x30f8de42, (q31_t)0x30f31016, (q31_t)0x30ed41cb, (q31_t)0x30e77362, (q31_t)0x30e1a4db, (q31_t)0x30dbd636, (q31_t)0x30d60772, (q31_t)0x30d03891, - (q31_t)0x30ca6991, (q31_t)0x30c49a74, (q31_t)0x30becb38, (q31_t)0x30b8fbde, (q31_t)0x30b32c66, (q31_t)0x30ad5cd0, (q31_t)0x30a78d1c, (q31_t)0x30a1bd4a, - (q31_t)0x309bed5a, (q31_t)0x30961d4c, (q31_t)0x30904d20, (q31_t)0x308a7cd6, (q31_t)0x3084ac6e, (q31_t)0x307edbe9, (q31_t)0x30790b45, (q31_t)0x30733a83, - (q31_t)0x306d69a4, (q31_t)0x306798a7, (q31_t)0x3061c78b, (q31_t)0x305bf652, (q31_t)0x305624fb, (q31_t)0x30505387, (q31_t)0x304a81f4, (q31_t)0x3044b044, - (q31_t)0x303ede76, (q31_t)0x30390c8a, (q31_t)0x30333a80, (q31_t)0x302d6859, (q31_t)0x30279614, (q31_t)0x3021c3b1, (q31_t)0x301bf131, (q31_t)0x30161e93, - (q31_t)0x30104bd7, (q31_t)0x300a78fe, (q31_t)0x3004a607, (q31_t)0x2ffed2f2, (q31_t)0x2ff8ffc0, (q31_t)0x2ff32c70, (q31_t)0x2fed5902, (q31_t)0x2fe78577, - (q31_t)0x2fe1b1cf, (q31_t)0x2fdbde09, (q31_t)0x2fd60a25, (q31_t)0x2fd03624, (q31_t)0x2fca6206, (q31_t)0x2fc48dc9, (q31_t)0x2fbeb970, (q31_t)0x2fb8e4f9, - (q31_t)0x2fb31064, (q31_t)0x2fad3bb3, (q31_t)0x2fa766e3, (q31_t)0x2fa191f7, (q31_t)0x2f9bbced, (q31_t)0x2f95e7c5, (q31_t)0x2f901280, (q31_t)0x2f8a3d1e, - (q31_t)0x2f84679f, (q31_t)0x2f7e9202, (q31_t)0x2f78bc48, (q31_t)0x2f72e671, (q31_t)0x2f6d107c, (q31_t)0x2f673a6a, (q31_t)0x2f61643b, (q31_t)0x2f5b8def, - (q31_t)0x2f55b785, (q31_t)0x2f4fe0ff, (q31_t)0x2f4a0a5b, (q31_t)0x2f44339a, (q31_t)0x2f3e5cbb, (q31_t)0x2f3885c0, (q31_t)0x2f32aea8, (q31_t)0x2f2cd772, - (q31_t)0x2f27001f, (q31_t)0x2f2128af, (q31_t)0x2f1b5122, (q31_t)0x2f157979, (q31_t)0x2f0fa1b2, (q31_t)0x2f09c9ce, (q31_t)0x2f03f1cd, (q31_t)0x2efe19ae, - (q31_t)0x2ef84173, (q31_t)0x2ef2691b, (q31_t)0x2eec90a7, (q31_t)0x2ee6b815, (q31_t)0x2ee0df66, (q31_t)0x2edb069a, (q31_t)0x2ed52db1, (q31_t)0x2ecf54ac, - (q31_t)0x2ec97b89, (q31_t)0x2ec3a24a, (q31_t)0x2ebdc8ee, (q31_t)0x2eb7ef75, (q31_t)0x2eb215df, (q31_t)0x2eac3c2d, (q31_t)0x2ea6625d, (q31_t)0x2ea08871, - (q31_t)0x2e9aae68, (q31_t)0x2e94d443, (q31_t)0x2e8efa00, (q31_t)0x2e891fa1, (q31_t)0x2e834525, (q31_t)0x2e7d6a8d, (q31_t)0x2e778fd8, (q31_t)0x2e71b506, - (q31_t)0x2e6bda17, (q31_t)0x2e65ff0c, (q31_t)0x2e6023e5, (q31_t)0x2e5a48a0, (q31_t)0x2e546d3f, (q31_t)0x2e4e91c2, (q31_t)0x2e48b628, (q31_t)0x2e42da71, - (q31_t)0x2e3cfe9e, (q31_t)0x2e3722ae, (q31_t)0x2e3146a2, (q31_t)0x2e2b6a79, (q31_t)0x2e258e34, (q31_t)0x2e1fb1d3, (q31_t)0x2e19d554, (q31_t)0x2e13f8ba, - (q31_t)0x2e0e1c03, (q31_t)0x2e083f30, (q31_t)0x2e026240, (q31_t)0x2dfc8534, (q31_t)0x2df6a80b, (q31_t)0x2df0cac6, (q31_t)0x2deaed65, (q31_t)0x2de50fe8, - (q31_t)0x2ddf324e, (q31_t)0x2dd95498, (q31_t)0x2dd376c5, (q31_t)0x2dcd98d7, (q31_t)0x2dc7bacc, (q31_t)0x2dc1dca4, (q31_t)0x2dbbfe61, (q31_t)0x2db62001, - (q31_t)0x2db04186, (q31_t)0x2daa62ee, (q31_t)0x2da4843a, (q31_t)0x2d9ea569, (q31_t)0x2d98c67d, (q31_t)0x2d92e774, (q31_t)0x2d8d084f, (q31_t)0x2d87290f, - (q31_t)0x2d8149b2, (q31_t)0x2d7b6a39, (q31_t)0x2d758aa4, (q31_t)0x2d6faaf3, (q31_t)0x2d69cb26, (q31_t)0x2d63eb3d, (q31_t)0x2d5e0b38, (q31_t)0x2d582b17, - (q31_t)0x2d524ada, (q31_t)0x2d4c6a81, (q31_t)0x2d468a0c, (q31_t)0x2d40a97b, (q31_t)0x2d3ac8ce, (q31_t)0x2d34e805, (q31_t)0x2d2f0721, (q31_t)0x2d292620, - (q31_t)0x2d234504, (q31_t)0x2d1d63cc, (q31_t)0x2d178278, (q31_t)0x2d11a108, (q31_t)0x2d0bbf7d, (q31_t)0x2d05ddd5, (q31_t)0x2cfffc12, (q31_t)0x2cfa1a33, - (q31_t)0x2cf43839, (q31_t)0x2cee5622, (q31_t)0x2ce873f0, (q31_t)0x2ce291a2, (q31_t)0x2cdcaf39, (q31_t)0x2cd6ccb4, (q31_t)0x2cd0ea13, (q31_t)0x2ccb0756, - (q31_t)0x2cc5247e, (q31_t)0x2cbf418b, (q31_t)0x2cb95e7b, (q31_t)0x2cb37b51, (q31_t)0x2cad980a, (q31_t)0x2ca7b4a8, (q31_t)0x2ca1d12a, (q31_t)0x2c9bed91, - (q31_t)0x2c9609dd, (q31_t)0x2c90260d, (q31_t)0x2c8a4221, (q31_t)0x2c845e1a, (q31_t)0x2c7e79f7, (q31_t)0x2c7895b9, (q31_t)0x2c72b160, (q31_t)0x2c6ccceb, - (q31_t)0x2c66e85b, (q31_t)0x2c6103af, (q31_t)0x2c5b1ee8, (q31_t)0x2c553a06, (q31_t)0x2c4f5508, (q31_t)0x2c496fef, (q31_t)0x2c438abb, (q31_t)0x2c3da56b, - (q31_t)0x2c37c000, (q31_t)0x2c31da7a, (q31_t)0x2c2bf4d8, (q31_t)0x2c260f1c, (q31_t)0x2c202944, (q31_t)0x2c1a4351, (q31_t)0x2c145d42, (q31_t)0x2c0e7719, - (q31_t)0x2c0890d4, (q31_t)0x2c02aa74, (q31_t)0x2bfcc3f9, (q31_t)0x2bf6dd63, (q31_t)0x2bf0f6b1, (q31_t)0x2beb0fe5, (q31_t)0x2be528fd, (q31_t)0x2bdf41fb, - (q31_t)0x2bd95add, (q31_t)0x2bd373a4, (q31_t)0x2bcd8c51, (q31_t)0x2bc7a4e2, (q31_t)0x2bc1bd58, (q31_t)0x2bbbd5b3, (q31_t)0x2bb5edf4, (q31_t)0x2bb00619, - (q31_t)0x2baa1e23, (q31_t)0x2ba43613, (q31_t)0x2b9e4de7, (q31_t)0x2b9865a1, (q31_t)0x2b927d3f, (q31_t)0x2b8c94c3, (q31_t)0x2b86ac2c, (q31_t)0x2b80c37a, - (q31_t)0x2b7adaae, (q31_t)0x2b74f1c6, (q31_t)0x2b6f08c4, (q31_t)0x2b691fa6, (q31_t)0x2b63366f, (q31_t)0x2b5d4d1c, (q31_t)0x2b5763ae, (q31_t)0x2b517a26, - (q31_t)0x2b4b9083, (q31_t)0x2b45a6c6, (q31_t)0x2b3fbced, (q31_t)0x2b39d2fa, (q31_t)0x2b33e8ed, (q31_t)0x2b2dfec5, (q31_t)0x2b281482, (q31_t)0x2b222a24, - (q31_t)0x2b1c3fac, (q31_t)0x2b165519, (q31_t)0x2b106a6c, (q31_t)0x2b0a7fa4, (q31_t)0x2b0494c2, (q31_t)0x2afea9c5, (q31_t)0x2af8bead, (q31_t)0x2af2d37b, - (q31_t)0x2aece82f, (q31_t)0x2ae6fcc8, (q31_t)0x2ae11146, (q31_t)0x2adb25aa, (q31_t)0x2ad539f4, (q31_t)0x2acf4e23, (q31_t)0x2ac96238, (q31_t)0x2ac37633, - (q31_t)0x2abd8a13, (q31_t)0x2ab79dd8, (q31_t)0x2ab1b184, (q31_t)0x2aabc515, (q31_t)0x2aa5d88b, (q31_t)0x2a9febe8, (q31_t)0x2a99ff2a, (q31_t)0x2a941252, - (q31_t)0x2a8e255f, (q31_t)0x2a883853, (q31_t)0x2a824b2c, (q31_t)0x2a7c5deb, (q31_t)0x2a76708f, (q31_t)0x2a70831a, (q31_t)0x2a6a958a, (q31_t)0x2a64a7e0, - (q31_t)0x2a5eba1c, (q31_t)0x2a58cc3e, (q31_t)0x2a52de46, (q31_t)0x2a4cf033, (q31_t)0x2a470207, (q31_t)0x2a4113c0, (q31_t)0x2a3b2560, (q31_t)0x2a3536e5, - (q31_t)0x2a2f4850, (q31_t)0x2a2959a1, (q31_t)0x2a236ad9, (q31_t)0x2a1d7bf6, (q31_t)0x2a178cf9, (q31_t)0x2a119de2, (q31_t)0x2a0baeb2, (q31_t)0x2a05bf67, - (q31_t)0x29ffd003, (q31_t)0x29f9e084, (q31_t)0x29f3f0ec, (q31_t)0x29ee013a, (q31_t)0x29e8116e, (q31_t)0x29e22188, (q31_t)0x29dc3188, (q31_t)0x29d6416f, - (q31_t)0x29d0513b, (q31_t)0x29ca60ee, (q31_t)0x29c47087, (q31_t)0x29be8007, (q31_t)0x29b88f6c, (q31_t)0x29b29eb8, (q31_t)0x29acadea, (q31_t)0x29a6bd02, - (q31_t)0x29a0cc01, (q31_t)0x299adae6, (q31_t)0x2994e9b1, (q31_t)0x298ef863, (q31_t)0x298906fb, (q31_t)0x2983157a, (q31_t)0x297d23df, (q31_t)0x2977322a, - (q31_t)0x2971405b, (q31_t)0x296b4e74, (q31_t)0x29655c72, (q31_t)0x295f6a57, (q31_t)0x29597823, (q31_t)0x295385d5, (q31_t)0x294d936d, (q31_t)0x2947a0ec, - (q31_t)0x2941ae52, (q31_t)0x293bbb9e, (q31_t)0x2935c8d1, (q31_t)0x292fd5ea, (q31_t)0x2929e2ea, (q31_t)0x2923efd0, (q31_t)0x291dfc9d, (q31_t)0x29180951, - (q31_t)0x291215eb, (q31_t)0x290c226c, (q31_t)0x29062ed4, (q31_t)0x29003b23, (q31_t)0x28fa4758, (q31_t)0x28f45374, (q31_t)0x28ee5f76, (q31_t)0x28e86b5f, - (q31_t)0x28e27730, (q31_t)0x28dc82e6, (q31_t)0x28d68e84, (q31_t)0x28d09a09, (q31_t)0x28caa574, (q31_t)0x28c4b0c6, (q31_t)0x28bebbff, (q31_t)0x28b8c71f, - (q31_t)0x28b2d226, (q31_t)0x28acdd13, (q31_t)0x28a6e7e8, (q31_t)0x28a0f2a3, (q31_t)0x289afd46, (q31_t)0x289507cf, (q31_t)0x288f123f, (q31_t)0x28891c97, - (q31_t)0x288326d5, (q31_t)0x287d30fa, (q31_t)0x28773b07, (q31_t)0x287144fa, (q31_t)0x286b4ed5, (q31_t)0x28655896, (q31_t)0x285f623f, (q31_t)0x28596bce, - (q31_t)0x28537545, (q31_t)0x284d7ea3, (q31_t)0x284787e8, (q31_t)0x28419114, (q31_t)0x283b9a28, (q31_t)0x2835a322, (q31_t)0x282fac04, (q31_t)0x2829b4cd, - (q31_t)0x2823bd7d, (q31_t)0x281dc615, (q31_t)0x2817ce93, (q31_t)0x2811d6f9, (q31_t)0x280bdf46, (q31_t)0x2805e77b, (q31_t)0x27ffef97, (q31_t)0x27f9f79a, - (q31_t)0x27f3ff85, (q31_t)0x27ee0756, (q31_t)0x27e80f10, (q31_t)0x27e216b0, (q31_t)0x27dc1e38, (q31_t)0x27d625a8, (q31_t)0x27d02cff, (q31_t)0x27ca343d, - (q31_t)0x27c43b63, (q31_t)0x27be4270, (q31_t)0x27b84965, (q31_t)0x27b25041, (q31_t)0x27ac5705, (q31_t)0x27a65db0, (q31_t)0x27a06443, (q31_t)0x279a6abd, - (q31_t)0x2794711f, (q31_t)0x278e7768, (q31_t)0x27887d99, (q31_t)0x278283b2, (q31_t)0x277c89b3, (q31_t)0x27768f9b, (q31_t)0x2770956a, (q31_t)0x276a9b21, - (q31_t)0x2764a0c0, (q31_t)0x275ea647, (q31_t)0x2758abb6, (q31_t)0x2752b10c, (q31_t)0x274cb64a, (q31_t)0x2746bb6f, (q31_t)0x2740c07d, (q31_t)0x273ac572, - (q31_t)0x2734ca4f, (q31_t)0x272ecf14, (q31_t)0x2728d3c0, (q31_t)0x2722d855, (q31_t)0x271cdcd1, (q31_t)0x2716e136, (q31_t)0x2710e582, (q31_t)0x270ae9b6, - (q31_t)0x2704edd2, (q31_t)0x26fef1d5, (q31_t)0x26f8f5c1, (q31_t)0x26f2f995, (q31_t)0x26ecfd51, (q31_t)0x26e700f5, (q31_t)0x26e10480, (q31_t)0x26db07f4, - (q31_t)0x26d50b50, (q31_t)0x26cf0e94, (q31_t)0x26c911c0, (q31_t)0x26c314d4, (q31_t)0x26bd17d0, (q31_t)0x26b71ab4, (q31_t)0x26b11d80, (q31_t)0x26ab2034, - (q31_t)0x26a522d1, (q31_t)0x269f2556, (q31_t)0x269927c3, (q31_t)0x26932a18, (q31_t)0x268d2c55, (q31_t)0x26872e7b, (q31_t)0x26813088, (q31_t)0x267b327e, - (q31_t)0x2675345d, (q31_t)0x266f3623, (q31_t)0x266937d2, (q31_t)0x26633969, (q31_t)0x265d3ae9, (q31_t)0x26573c50, (q31_t)0x26513da1, (q31_t)0x264b3ed9, - (q31_t)0x26453ffa, (q31_t)0x263f4103, (q31_t)0x263941f5, (q31_t)0x263342cf, (q31_t)0x262d4392, (q31_t)0x2627443d, (q31_t)0x262144d0, (q31_t)0x261b454c, - (q31_t)0x261545b0, (q31_t)0x260f45fd, (q31_t)0x26094633, (q31_t)0x26034651, (q31_t)0x25fd4657, (q31_t)0x25f74646, (q31_t)0x25f1461e, (q31_t)0x25eb45de, - (q31_t)0x25e54587, (q31_t)0x25df4519, (q31_t)0x25d94493, (q31_t)0x25d343f6, (q31_t)0x25cd4341, (q31_t)0x25c74276, (q31_t)0x25c14192, (q31_t)0x25bb4098, - (q31_t)0x25b53f86, (q31_t)0x25af3e5d, (q31_t)0x25a93d1d, (q31_t)0x25a33bc6, (q31_t)0x259d3a57, (q31_t)0x259738d1, (q31_t)0x25913734, (q31_t)0x258b3580, - (q31_t)0x258533b5, (q31_t)0x257f31d2, (q31_t)0x25792fd8, (q31_t)0x25732dc8, (q31_t)0x256d2ba0, (q31_t)0x25672961, (q31_t)0x2561270b, (q31_t)0x255b249e, - (q31_t)0x2555221a, (q31_t)0x254f1f7e, (q31_t)0x25491ccc, (q31_t)0x25431a03, (q31_t)0x253d1723, (q31_t)0x2537142c, (q31_t)0x2531111e, (q31_t)0x252b0df9, - (q31_t)0x25250abd, (q31_t)0x251f076a, (q31_t)0x25190400, (q31_t)0x25130080, (q31_t)0x250cfce8, (q31_t)0x2506f93a, (q31_t)0x2500f574, (q31_t)0x24faf198, - (q31_t)0x24f4eda6, (q31_t)0x24eee99c, (q31_t)0x24e8e57c, (q31_t)0x24e2e144, (q31_t)0x24dcdcf6, (q31_t)0x24d6d892, (q31_t)0x24d0d416, (q31_t)0x24cacf84, - (q31_t)0x24c4cadb, (q31_t)0x24bec61c, (q31_t)0x24b8c146, (q31_t)0x24b2bc59, (q31_t)0x24acb756, (q31_t)0x24a6b23b, (q31_t)0x24a0ad0b, (q31_t)0x249aa7c4, - (q31_t)0x2494a266, (q31_t)0x248e9cf1, (q31_t)0x24889766, (q31_t)0x248291c5, (q31_t)0x247c8c0d, (q31_t)0x2476863e, (q31_t)0x24708059, (q31_t)0x246a7a5e, - (q31_t)0x2464744c, (q31_t)0x245e6e23, (q31_t)0x245867e4, (q31_t)0x2452618f, (q31_t)0x244c5b24, (q31_t)0x244654a1, (q31_t)0x24404e09, (q31_t)0x243a475a, - (q31_t)0x24344095, (q31_t)0x242e39ba, (q31_t)0x242832c8, (q31_t)0x24222bc0, (q31_t)0x241c24a1, (q31_t)0x24161d6d, (q31_t)0x24101622, (q31_t)0x240a0ec1, - (q31_t)0x24040749, (q31_t)0x23fdffbc, (q31_t)0x23f7f818, (q31_t)0x23f1f05e, (q31_t)0x23ebe88e, (q31_t)0x23e5e0a7, (q31_t)0x23dfd8ab, (q31_t)0x23d9d098, - (q31_t)0x23d3c86f, (q31_t)0x23cdc031, (q31_t)0x23c7b7dc, (q31_t)0x23c1af71, (q31_t)0x23bba6f0, (q31_t)0x23b59e59, (q31_t)0x23af95ac, (q31_t)0x23a98ce8, - (q31_t)0x23a3840f, (q31_t)0x239d7b20, (q31_t)0x2397721b, (q31_t)0x23916900, (q31_t)0x238b5fcf, (q31_t)0x23855688, (q31_t)0x237f4d2b, (q31_t)0x237943b9, - (q31_t)0x23733a30, (q31_t)0x236d3092, (q31_t)0x236726dd, (q31_t)0x23611d13, (q31_t)0x235b1333, (q31_t)0x2355093e, (q31_t)0x234eff32, (q31_t)0x2348f511, - (q31_t)0x2342eada, (q31_t)0x233ce08d, (q31_t)0x2336d62a, (q31_t)0x2330cbb2, (q31_t)0x232ac124, (q31_t)0x2324b680, (q31_t)0x231eabc7, (q31_t)0x2318a0f8, - (q31_t)0x23129613, (q31_t)0x230c8b19, (q31_t)0x23068009, (q31_t)0x230074e3, (q31_t)0x22fa69a8, (q31_t)0x22f45e57, (q31_t)0x22ee52f1, (q31_t)0x22e84775, - (q31_t)0x22e23be4, (q31_t)0x22dc303d, (q31_t)0x22d62480, (q31_t)0x22d018ae, (q31_t)0x22ca0cc7, (q31_t)0x22c400ca, (q31_t)0x22bdf4b8, (q31_t)0x22b7e890, - (q31_t)0x22b1dc53, (q31_t)0x22abd001, (q31_t)0x22a5c399, (q31_t)0x229fb71b, (q31_t)0x2299aa89, (q31_t)0x22939de1, (q31_t)0x228d9123, (q31_t)0x22878451, - (q31_t)0x22817769, (q31_t)0x227b6a6c, (q31_t)0x22755d59, (q31_t)0x226f5032, (q31_t)0x226942f5, (q31_t)0x226335a2, (q31_t)0x225d283b, (q31_t)0x22571abe, - (q31_t)0x22510d2d, (q31_t)0x224aff86, (q31_t)0x2244f1c9, (q31_t)0x223ee3f8, (q31_t)0x2238d612, (q31_t)0x2232c816, (q31_t)0x222cba06, (q31_t)0x2226abe0, - (q31_t)0x22209da5, (q31_t)0x221a8f56, (q31_t)0x221480f1, (q31_t)0x220e7277, (q31_t)0x220863e8, (q31_t)0x22025544, (q31_t)0x21fc468b, (q31_t)0x21f637be, - (q31_t)0x21f028db, (q31_t)0x21ea19e3, (q31_t)0x21e40ad7, (q31_t)0x21ddfbb5, (q31_t)0x21d7ec7f, (q31_t)0x21d1dd34, (q31_t)0x21cbcdd3, (q31_t)0x21c5be5e, - (q31_t)0x21bfaed5, (q31_t)0x21b99f36, (q31_t)0x21b38f83, (q31_t)0x21ad7fba, (q31_t)0x21a76fdd, (q31_t)0x21a15fec, (q31_t)0x219b4fe5, (q31_t)0x21953fca, - (q31_t)0x218f2f9a, (q31_t)0x21891f55, (q31_t)0x21830efc, (q31_t)0x217cfe8e, (q31_t)0x2176ee0b, (q31_t)0x2170dd74, (q31_t)0x216accc8, (q31_t)0x2164bc08, - (q31_t)0x215eab33, (q31_t)0x21589a49, (q31_t)0x2152894b, (q31_t)0x214c7838, (q31_t)0x21466710, (q31_t)0x214055d4, (q31_t)0x213a4484, (q31_t)0x2134331f, - (q31_t)0x212e21a6, (q31_t)0x21281018, (q31_t)0x2121fe76, (q31_t)0x211becbf, (q31_t)0x2115daf4, (q31_t)0x210fc914, (q31_t)0x2109b720, (q31_t)0x2103a518, - (q31_t)0x20fd92fb, (q31_t)0x20f780ca, (q31_t)0x20f16e84, (q31_t)0x20eb5c2b, (q31_t)0x20e549bd, (q31_t)0x20df373a, (q31_t)0x20d924a4, (q31_t)0x20d311f9, - (q31_t)0x20ccff3a, (q31_t)0x20c6ec66, (q31_t)0x20c0d97f, (q31_t)0x20bac683, (q31_t)0x20b4b373, (q31_t)0x20aea04f, (q31_t)0x20a88d17, (q31_t)0x20a279ca, - (q31_t)0x209c666a, (q31_t)0x209652f5, (q31_t)0x20903f6c, (q31_t)0x208a2bcf, (q31_t)0x2084181e, (q31_t)0x207e0459, (q31_t)0x2077f080, (q31_t)0x2071dc93, - (q31_t)0x206bc892, (q31_t)0x2065b47d, (q31_t)0x205fa054, (q31_t)0x20598c17, (q31_t)0x205377c6, (q31_t)0x204d6361, (q31_t)0x20474ee8, (q31_t)0x20413a5b, - (q31_t)0x203b25bb, (q31_t)0x20351106, (q31_t)0x202efc3e, (q31_t)0x2028e761, (q31_t)0x2022d271, (q31_t)0x201cbd6d, (q31_t)0x2016a856, (q31_t)0x2010932a, - (q31_t)0x200a7deb, (q31_t)0x20046898, (q31_t)0x1ffe5331, (q31_t)0x1ff83db6, (q31_t)0x1ff22828, (q31_t)0x1fec1286, (q31_t)0x1fe5fcd0, (q31_t)0x1fdfe707, - (q31_t)0x1fd9d12a, (q31_t)0x1fd3bb39, (q31_t)0x1fcda535, (q31_t)0x1fc78f1d, (q31_t)0x1fc178f1, (q31_t)0x1fbb62b2, (q31_t)0x1fb54c60, (q31_t)0x1faf35f9, - (q31_t)0x1fa91f80, (q31_t)0x1fa308f2, (q31_t)0x1f9cf252, (q31_t)0x1f96db9d, (q31_t)0x1f90c4d5, (q31_t)0x1f8aadfa, (q31_t)0x1f84970b, (q31_t)0x1f7e8009, - (q31_t)0x1f7868f4, (q31_t)0x1f7251ca, (q31_t)0x1f6c3a8e, (q31_t)0x1f66233e, (q31_t)0x1f600bdb, (q31_t)0x1f59f465, (q31_t)0x1f53dcdb, (q31_t)0x1f4dc53d, - (q31_t)0x1f47ad8d, (q31_t)0x1f4195c9, (q31_t)0x1f3b7df2, (q31_t)0x1f356608, (q31_t)0x1f2f4e0a, (q31_t)0x1f2935f9, (q31_t)0x1f231dd5, (q31_t)0x1f1d059e, - (q31_t)0x1f16ed54, (q31_t)0x1f10d4f6, (q31_t)0x1f0abc85, (q31_t)0x1f04a401, (q31_t)0x1efe8b6a, (q31_t)0x1ef872c0, (q31_t)0x1ef25a03, (q31_t)0x1eec4132, - (q31_t)0x1ee6284f, (q31_t)0x1ee00f58, (q31_t)0x1ed9f64f, (q31_t)0x1ed3dd32, (q31_t)0x1ecdc402, (q31_t)0x1ec7aac0, (q31_t)0x1ec1916a, (q31_t)0x1ebb7802, - (q31_t)0x1eb55e86, (q31_t)0x1eaf44f8, (q31_t)0x1ea92b56, (q31_t)0x1ea311a2, (q31_t)0x1e9cf7db, (q31_t)0x1e96de01, (q31_t)0x1e90c414, (q31_t)0x1e8aaa14, - (q31_t)0x1e849001, (q31_t)0x1e7e75dc, (q31_t)0x1e785ba3, (q31_t)0x1e724158, (q31_t)0x1e6c26fa, (q31_t)0x1e660c8a, (q31_t)0x1e5ff206, (q31_t)0x1e59d770, - (q31_t)0x1e53bcc7, (q31_t)0x1e4da20c, (q31_t)0x1e47873d, (q31_t)0x1e416c5d, (q31_t)0x1e3b5169, (q31_t)0x1e353663, (q31_t)0x1e2f1b4a, (q31_t)0x1e29001e, - (q31_t)0x1e22e4e0, (q31_t)0x1e1cc990, (q31_t)0x1e16ae2c, (q31_t)0x1e1092b6, (q31_t)0x1e0a772e, (q31_t)0x1e045b93, (q31_t)0x1dfe3fe6, (q31_t)0x1df82426, - (q31_t)0x1df20853, (q31_t)0x1debec6f, (q31_t)0x1de5d077, (q31_t)0x1ddfb46e, (q31_t)0x1dd99851, (q31_t)0x1dd37c23, (q31_t)0x1dcd5fe2, (q31_t)0x1dc7438e, - (q31_t)0x1dc12729, (q31_t)0x1dbb0ab0, (q31_t)0x1db4ee26, (q31_t)0x1daed189, (q31_t)0x1da8b4da, (q31_t)0x1da29819, (q31_t)0x1d9c7b45, (q31_t)0x1d965e5f, - (q31_t)0x1d904167, (q31_t)0x1d8a245c, (q31_t)0x1d840740, (q31_t)0x1d7dea11, (q31_t)0x1d77ccd0, (q31_t)0x1d71af7d, (q31_t)0x1d6b9217, (q31_t)0x1d6574a0, - (q31_t)0x1d5f5716, (q31_t)0x1d59397a, (q31_t)0x1d531bcc, (q31_t)0x1d4cfe0d, (q31_t)0x1d46e03a, (q31_t)0x1d40c256, (q31_t)0x1d3aa460, (q31_t)0x1d348658, - (q31_t)0x1d2e683e, (q31_t)0x1d284a12, (q31_t)0x1d222bd3, (q31_t)0x1d1c0d83, (q31_t)0x1d15ef21, (q31_t)0x1d0fd0ad, (q31_t)0x1d09b227, (q31_t)0x1d03938f, - (q31_t)0x1cfd74e5, (q31_t)0x1cf7562a, (q31_t)0x1cf1375c, (q31_t)0x1ceb187d, (q31_t)0x1ce4f98c, (q31_t)0x1cdeda89, (q31_t)0x1cd8bb74, (q31_t)0x1cd29c4d, - (q31_t)0x1ccc7d15, (q31_t)0x1cc65dca, (q31_t)0x1cc03e6e, (q31_t)0x1cba1f01, (q31_t)0x1cb3ff81, (q31_t)0x1caddff0, (q31_t)0x1ca7c04d, (q31_t)0x1ca1a099, - (q31_t)0x1c9b80d3, (q31_t)0x1c9560fb, (q31_t)0x1c8f4112, (q31_t)0x1c892117, (q31_t)0x1c83010a, (q31_t)0x1c7ce0ec, (q31_t)0x1c76c0bc, (q31_t)0x1c70a07b, - (q31_t)0x1c6a8028, (q31_t)0x1c645fc3, (q31_t)0x1c5e3f4d, (q31_t)0x1c581ec6, (q31_t)0x1c51fe2d, (q31_t)0x1c4bdd83, (q31_t)0x1c45bcc7, (q31_t)0x1c3f9bf9, - (q31_t)0x1c397b1b, (q31_t)0x1c335a2b, (q31_t)0x1c2d3929, (q31_t)0x1c271816, (q31_t)0x1c20f6f2, (q31_t)0x1c1ad5bc, (q31_t)0x1c14b475, (q31_t)0x1c0e931d, - (q31_t)0x1c0871b4, (q31_t)0x1c025039, (q31_t)0x1bfc2ead, (q31_t)0x1bf60d0f, (q31_t)0x1befeb60, (q31_t)0x1be9c9a1, (q31_t)0x1be3a7cf, (q31_t)0x1bdd85ed, - (q31_t)0x1bd763fa, (q31_t)0x1bd141f5, (q31_t)0x1bcb1fdf, (q31_t)0x1bc4fdb8, (q31_t)0x1bbedb80, (q31_t)0x1bb8b937, (q31_t)0x1bb296dc, (q31_t)0x1bac7471, - (q31_t)0x1ba651f5, (q31_t)0x1ba02f67, (q31_t)0x1b9a0cc8, (q31_t)0x1b93ea19, (q31_t)0x1b8dc758, (q31_t)0x1b87a487, (q31_t)0x1b8181a4, (q31_t)0x1b7b5eb0, - (q31_t)0x1b753bac, (q31_t)0x1b6f1897, (q31_t)0x1b68f570, (q31_t)0x1b62d239, (q31_t)0x1b5caef1, (q31_t)0x1b568b98, (q31_t)0x1b50682e, (q31_t)0x1b4a44b3, - (q31_t)0x1b442127, (q31_t)0x1b3dfd8b, (q31_t)0x1b37d9de, (q31_t)0x1b31b620, (q31_t)0x1b2b9251, (q31_t)0x1b256e71, (q31_t)0x1b1f4a81, (q31_t)0x1b192680, - (q31_t)0x1b13026e, (q31_t)0x1b0cde4c, (q31_t)0x1b06ba19, (q31_t)0x1b0095d5, (q31_t)0x1afa7180, (q31_t)0x1af44d1b, (q31_t)0x1aee28a6, (q31_t)0x1ae8041f, - (q31_t)0x1ae1df88, (q31_t)0x1adbbae1, (q31_t)0x1ad59629, (q31_t)0x1acf7160, (q31_t)0x1ac94c87, (q31_t)0x1ac3279d, (q31_t)0x1abd02a3, (q31_t)0x1ab6dd98, - (q31_t)0x1ab0b87d, (q31_t)0x1aaa9352, (q31_t)0x1aa46e16, (q31_t)0x1a9e48c9, (q31_t)0x1a98236c, (q31_t)0x1a91fdff, (q31_t)0x1a8bd881, (q31_t)0x1a85b2f3, - (q31_t)0x1a7f8d54, (q31_t)0x1a7967a6, (q31_t)0x1a7341e6, (q31_t)0x1a6d1c17, (q31_t)0x1a66f637, (q31_t)0x1a60d047, (q31_t)0x1a5aaa47, (q31_t)0x1a548436, - (q31_t)0x1a4e5e15, (q31_t)0x1a4837e4, (q31_t)0x1a4211a3, (q31_t)0x1a3beb52, (q31_t)0x1a35c4f0, (q31_t)0x1a2f9e7e, (q31_t)0x1a2977fc, (q31_t)0x1a23516a, - (q31_t)0x1a1d2ac8, (q31_t)0x1a170416, (q31_t)0x1a10dd53, (q31_t)0x1a0ab681, (q31_t)0x1a048f9e, (q31_t)0x19fe68ac, (q31_t)0x19f841a9, (q31_t)0x19f21a96, - (q31_t)0x19ebf374, (q31_t)0x19e5cc41, (q31_t)0x19dfa4fe, (q31_t)0x19d97dac, (q31_t)0x19d35649, (q31_t)0x19cd2ed7, (q31_t)0x19c70754, (q31_t)0x19c0dfc2, - (q31_t)0x19bab820, (q31_t)0x19b4906e, (q31_t)0x19ae68ac, (q31_t)0x19a840da, (q31_t)0x19a218f9, (q31_t)0x199bf107, (q31_t)0x1995c906, (q31_t)0x198fa0f5, - (q31_t)0x198978d4, (q31_t)0x198350a4, (q31_t)0x197d2864, (q31_t)0x19770014, (q31_t)0x1970d7b4, (q31_t)0x196aaf45, (q31_t)0x196486c6, (q31_t)0x195e5e37, - (q31_t)0x19583599, (q31_t)0x19520ceb, (q31_t)0x194be42d, (q31_t)0x1945bb60, (q31_t)0x193f9283, (q31_t)0x19396997, (q31_t)0x1933409b, (q31_t)0x192d178f, - (q31_t)0x1926ee74, (q31_t)0x1920c54a, (q31_t)0x191a9c10, (q31_t)0x191472c6, (q31_t)0x190e496d, (q31_t)0x19082005, (q31_t)0x1901f68d, (q31_t)0x18fbcd06, - (q31_t)0x18f5a36f, (q31_t)0x18ef79c9, (q31_t)0x18e95014, (q31_t)0x18e3264f, (q31_t)0x18dcfc7b, (q31_t)0x18d6d297, (q31_t)0x18d0a8a4, (q31_t)0x18ca7ea2, - (q31_t)0x18c45491, (q31_t)0x18be2a70, (q31_t)0x18b80040, (q31_t)0x18b1d601, (q31_t)0x18ababb2, (q31_t)0x18a58154, (q31_t)0x189f56e8, (q31_t)0x18992c6b, - (q31_t)0x189301e0, (q31_t)0x188cd746, (q31_t)0x1886ac9c, (q31_t)0x188081e4, (q31_t)0x187a571c, (q31_t)0x18742c45, (q31_t)0x186e015f, (q31_t)0x1867d66a, - (q31_t)0x1861ab66, (q31_t)0x185b8053, (q31_t)0x18555530, (q31_t)0x184f29ff, (q31_t)0x1848febf, (q31_t)0x1842d370, (q31_t)0x183ca812, (q31_t)0x18367ca5, - (q31_t)0x18305129, (q31_t)0x182a259e, (q31_t)0x1823fa04, (q31_t)0x181dce5b, (q31_t)0x1817a2a4, (q31_t)0x181176dd, (q31_t)0x180b4b08, (q31_t)0x18051f24, - (q31_t)0x17fef331, (q31_t)0x17f8c72f, (q31_t)0x17f29b1e, (q31_t)0x17ec6eff, (q31_t)0x17e642d1, (q31_t)0x17e01694, (q31_t)0x17d9ea49, (q31_t)0x17d3bdee, - (q31_t)0x17cd9186, (q31_t)0x17c7650e, (q31_t)0x17c13888, (q31_t)0x17bb0bf3, (q31_t)0x17b4df4f, (q31_t)0x17aeb29d, (q31_t)0x17a885dc, (q31_t)0x17a2590d, - (q31_t)0x179c2c2f, (q31_t)0x1795ff42, (q31_t)0x178fd247, (q31_t)0x1789a53d, (q31_t)0x17837825, (q31_t)0x177d4afe, (q31_t)0x17771dc9, (q31_t)0x1770f086, - (q31_t)0x176ac333, (q31_t)0x176495d3, (q31_t)0x175e6864, (q31_t)0x17583ae7, (q31_t)0x17520d5b, (q31_t)0x174bdfc1, (q31_t)0x1745b218, (q31_t)0x173f8461, - (q31_t)0x1739569c, (q31_t)0x173328c8, (q31_t)0x172cfae6, (q31_t)0x1726ccf6, (q31_t)0x17209ef8, (q31_t)0x171a70eb, (q31_t)0x171442d0, (q31_t)0x170e14a7, - (q31_t)0x1707e670, (q31_t)0x1701b82a, (q31_t)0x16fb89d6, (q31_t)0x16f55b74, (q31_t)0x16ef2d04, (q31_t)0x16e8fe86, (q31_t)0x16e2cff9, (q31_t)0x16dca15f, - (q31_t)0x16d672b6, (q31_t)0x16d043ff, (q31_t)0x16ca153a, (q31_t)0x16c3e667, (q31_t)0x16bdb787, (q31_t)0x16b78898, (q31_t)0x16b1599b, (q31_t)0x16ab2a90, - (q31_t)0x16a4fb77, (q31_t)0x169ecc50, (q31_t)0x16989d1b, (q31_t)0x16926dd8, (q31_t)0x168c3e87, (q31_t)0x16860f29, (q31_t)0x167fdfbc, (q31_t)0x1679b042, - (q31_t)0x167380ba, (q31_t)0x166d5123, (q31_t)0x1667217f, (q31_t)0x1660f1ce, (q31_t)0x165ac20e, (q31_t)0x16549241, (q31_t)0x164e6266, (q31_t)0x1648327d, - (q31_t)0x16420286, (q31_t)0x163bd282, (q31_t)0x1635a270, (q31_t)0x162f7250, (q31_t)0x16294222, (q31_t)0x162311e7, (q31_t)0x161ce19e, (q31_t)0x1616b148, - (q31_t)0x161080e4, (q31_t)0x160a5072, (q31_t)0x16041ff3, (q31_t)0x15fdef66, (q31_t)0x15f7becc, (q31_t)0x15f18e24, (q31_t)0x15eb5d6e, (q31_t)0x15e52cab, - (q31_t)0x15defbdb, (q31_t)0x15d8cafd, (q31_t)0x15d29a11, (q31_t)0x15cc6918, (q31_t)0x15c63812, (q31_t)0x15c006fe, (q31_t)0x15b9d5dd, (q31_t)0x15b3a4ae, - (q31_t)0x15ad7372, (q31_t)0x15a74228, (q31_t)0x15a110d2, (q31_t)0x159adf6e, (q31_t)0x1594adfc, (q31_t)0x158e7c7d, (q31_t)0x15884af1, (q31_t)0x15821958, - (q31_t)0x157be7b1, (q31_t)0x1575b5fe, (q31_t)0x156f843c, (q31_t)0x1569526e, (q31_t)0x15632093, (q31_t)0x155ceeaa, (q31_t)0x1556bcb4, (q31_t)0x15508ab1, - (q31_t)0x154a58a1, (q31_t)0x15442683, (q31_t)0x153df459, (q31_t)0x1537c221, (q31_t)0x15318fdd, (q31_t)0x152b5d8b, (q31_t)0x15252b2c, (q31_t)0x151ef8c0, - (q31_t)0x1518c648, (q31_t)0x151293c2, (q31_t)0x150c612f, (q31_t)0x15062e8f, (q31_t)0x14fffbe2, (q31_t)0x14f9c928, (q31_t)0x14f39662, (q31_t)0x14ed638e, - (q31_t)0x14e730ae, (q31_t)0x14e0fdc0, (q31_t)0x14dacac6, (q31_t)0x14d497bf, (q31_t)0x14ce64ab, (q31_t)0x14c8318a, (q31_t)0x14c1fe5c, (q31_t)0x14bbcb22, - (q31_t)0x14b597da, (q31_t)0x14af6486, (q31_t)0x14a93125, (q31_t)0x14a2fdb8, (q31_t)0x149cca3e, (q31_t)0x149696b7, (q31_t)0x14906323, (q31_t)0x148a2f82, - (q31_t)0x1483fbd5, (q31_t)0x147dc81c, (q31_t)0x14779455, (q31_t)0x14716082, (q31_t)0x146b2ca3, (q31_t)0x1464f8b7, (q31_t)0x145ec4be, (q31_t)0x145890b9, - (q31_t)0x14525ca7, (q31_t)0x144c2888, (q31_t)0x1445f45d, (q31_t)0x143fc026, (q31_t)0x14398be2, (q31_t)0x14335792, (q31_t)0x142d2335, (q31_t)0x1426eecb, - (q31_t)0x1420ba56, (q31_t)0x141a85d3, (q31_t)0x14145145, (q31_t)0x140e1caa, (q31_t)0x1407e803, (q31_t)0x1401b34f, (q31_t)0x13fb7e8f, (q31_t)0x13f549c3, - (q31_t)0x13ef14ea, (q31_t)0x13e8e005, (q31_t)0x13e2ab14, (q31_t)0x13dc7616, (q31_t)0x13d6410d, (q31_t)0x13d00bf7, (q31_t)0x13c9d6d4, (q31_t)0x13c3a1a6, - (q31_t)0x13bd6c6b, (q31_t)0x13b73725, (q31_t)0x13b101d2, (q31_t)0x13aacc73, (q31_t)0x13a49707, (q31_t)0x139e6190, (q31_t)0x13982c0d, (q31_t)0x1391f67d, - (q31_t)0x138bc0e1, (q31_t)0x13858b3a, (q31_t)0x137f5586, (q31_t)0x13791fc6, (q31_t)0x1372e9fb, (q31_t)0x136cb423, (q31_t)0x13667e3f, (q31_t)0x13604850, - (q31_t)0x135a1254, (q31_t)0x1353dc4c, (q31_t)0x134da639, (q31_t)0x1347701a, (q31_t)0x134139ee, (q31_t)0x133b03b7, (q31_t)0x1334cd74, (q31_t)0x132e9725, - (q31_t)0x132860ca, (q31_t)0x13222a64, (q31_t)0x131bf3f2, (q31_t)0x1315bd73, (q31_t)0x130f86ea, (q31_t)0x13095054, (q31_t)0x130319b3, (q31_t)0x12fce305, - (q31_t)0x12f6ac4d, (q31_t)0x12f07588, (q31_t)0x12ea3eb8, (q31_t)0x12e407dc, (q31_t)0x12ddd0f4, (q31_t)0x12d79a01, (q31_t)0x12d16303, (q31_t)0x12cb2bf8, - (q31_t)0x12c4f4e2, (q31_t)0x12bebdc1, (q31_t)0x12b88693, (q31_t)0x12b24f5b, (q31_t)0x12ac1817, (q31_t)0x12a5e0c7, (q31_t)0x129fa96c, (q31_t)0x12997205, - (q31_t)0x12933a93, (q31_t)0x128d0315, (q31_t)0x1286cb8c, (q31_t)0x128093f7, (q31_t)0x127a5c57, (q31_t)0x127424ac, (q31_t)0x126decf5, (q31_t)0x1267b533, - (q31_t)0x12617d66, (q31_t)0x125b458d, (q31_t)0x12550da9, (q31_t)0x124ed5ba, (q31_t)0x12489dbf, (q31_t)0x124265b9, (q31_t)0x123c2da8, (q31_t)0x1235f58b, - (q31_t)0x122fbd63, (q31_t)0x12298530, (q31_t)0x12234cf2, (q31_t)0x121d14a9, (q31_t)0x1216dc54, (q31_t)0x1210a3f5, (q31_t)0x120a6b8a, (q31_t)0x12043314, - (q31_t)0x11fdfa93, (q31_t)0x11f7c207, (q31_t)0x11f18970, (q31_t)0x11eb50cd, (q31_t)0x11e51820, (q31_t)0x11dedf68, (q31_t)0x11d8a6a4, (q31_t)0x11d26dd6, - (q31_t)0x11cc34fc, (q31_t)0x11c5fc18, (q31_t)0x11bfc329, (q31_t)0x11b98a2e, (q31_t)0x11b35129, (q31_t)0x11ad1819, (q31_t)0x11a6defe, (q31_t)0x11a0a5d8, - (q31_t)0x119a6ca7, (q31_t)0x1194336b, (q31_t)0x118dfa25, (q31_t)0x1187c0d3, (q31_t)0x11818777, (q31_t)0x117b4e10, (q31_t)0x1175149e, (q31_t)0x116edb22, - (q31_t)0x1168a19b, (q31_t)0x11626809, (q31_t)0x115c2e6c, (q31_t)0x1155f4c4, (q31_t)0x114fbb12, (q31_t)0x11498156, (q31_t)0x1143478e, (q31_t)0x113d0dbc, - (q31_t)0x1136d3df, (q31_t)0x113099f8, (q31_t)0x112a6006, (q31_t)0x11242609, (q31_t)0x111dec02, (q31_t)0x1117b1f0, (q31_t)0x111177d4, (q31_t)0x110b3dad, - (q31_t)0x1105037c, (q31_t)0x10fec940, (q31_t)0x10f88efa, (q31_t)0x10f254a9, (q31_t)0x10ec1a4e, (q31_t)0x10e5dfe8, (q31_t)0x10dfa578, (q31_t)0x10d96afe, - (q31_t)0x10d33079, (q31_t)0x10ccf5ea, (q31_t)0x10c6bb50, (q31_t)0x10c080ac, (q31_t)0x10ba45fe, (q31_t)0x10b40b45, (q31_t)0x10add082, (q31_t)0x10a795b5, - (q31_t)0x10a15ade, (q31_t)0x109b1ffc, (q31_t)0x1094e510, (q31_t)0x108eaa1a, (q31_t)0x10886f19, (q31_t)0x1082340f, (q31_t)0x107bf8fa, (q31_t)0x1075bddb, - (q31_t)0x106f82b2, (q31_t)0x1069477f, (q31_t)0x10630c41, (q31_t)0x105cd0fa, (q31_t)0x105695a8, (q31_t)0x10505a4d, (q31_t)0x104a1ee7, (q31_t)0x1043e377, - (q31_t)0x103da7fd, (q31_t)0x10376c79, (q31_t)0x103130ec, (q31_t)0x102af554, (q31_t)0x1024b9b2, (q31_t)0x101e7e06, (q31_t)0x10184251, (q31_t)0x10120691, - (q31_t)0x100bcac7, (q31_t)0x10058ef4, (q31_t)0xfff5317, (q31_t)0xff91730, (q31_t)0xff2db3e, (q31_t)0xfec9f44, (q31_t)0xfe6633f, (q31_t)0xfe02730, - (q31_t)0xfd9eb18, (q31_t)0xfd3aef6, (q31_t)0xfcd72ca, (q31_t)0xfc73695, (q31_t)0xfc0fa55, (q31_t)0xfbabe0c, (q31_t)0xfb481ba, (q31_t)0xfae455d, - (q31_t)0xfa808f7, (q31_t)0xfa1cc87, (q31_t)0xf9b900e, (q31_t)0xf95538b, (q31_t)0xf8f16fe, (q31_t)0xf88da68, (q31_t)0xf829dc8, (q31_t)0xf7c611f, - (q31_t)0xf76246c, (q31_t)0xf6fe7af, (q31_t)0xf69aae9, (q31_t)0xf636e1a, (q31_t)0xf5d3141, (q31_t)0xf56f45e, (q31_t)0xf50b773, (q31_t)0xf4a7a7d, - (q31_t)0xf443d7e, (q31_t)0xf3e0076, (q31_t)0xf37c365, (q31_t)0xf318649, (q31_t)0xf2b4925, (q31_t)0xf250bf7, (q31_t)0xf1ecec0, (q31_t)0xf189180, - (q31_t)0xf125436, (q31_t)0xf0c16e3, (q31_t)0xf05d987, (q31_t)0xeff9c21, (q31_t)0xef95eb2, (q31_t)0xef3213a, (q31_t)0xeece3b9, (q31_t)0xee6a62f, - (q31_t)0xee0689b, (q31_t)0xeda2afe, (q31_t)0xed3ed58, (q31_t)0xecdafa9, (q31_t)0xec771f1, (q31_t)0xec1342f, (q31_t)0xebaf665, (q31_t)0xeb4b891, - (q31_t)0xeae7ab4, (q31_t)0xea83ccf, (q31_t)0xea1fee0, (q31_t)0xe9bc0e8, (q31_t)0xe9582e7, (q31_t)0xe8f44dd, (q31_t)0xe8906cb, (q31_t)0xe82c8af, - (q31_t)0xe7c8a8a, (q31_t)0xe764c5c, (q31_t)0xe700e26, (q31_t)0xe69cfe6, (q31_t)0xe63919e, (q31_t)0xe5d534d, (q31_t)0xe5714f3, (q31_t)0xe50d690, - (q31_t)0xe4a9824, (q31_t)0xe4459af, (q31_t)0xe3e1b32, (q31_t)0xe37dcac, (q31_t)0xe319e1d, (q31_t)0xe2b5f85, (q31_t)0xe2520e5, (q31_t)0xe1ee23c, - (q31_t)0xe18a38a, (q31_t)0xe1264cf, (q31_t)0xe0c260c, (q31_t)0xe05e740, (q31_t)0xdffa86b, (q31_t)0xdf9698e, (q31_t)0xdf32aa8, (q31_t)0xdecebba, - (q31_t)0xde6acc3, (q31_t)0xde06dc3, (q31_t)0xdda2ebb, (q31_t)0xdd3efab, (q31_t)0xdcdb091, (q31_t)0xdc77170, (q31_t)0xdc13245, (q31_t)0xdbaf313, - (q31_t)0xdb4b3d7, (q31_t)0xdae7494, (q31_t)0xda83548, (q31_t)0xda1f5f3, (q31_t)0xd9bb696, (q31_t)0xd957731, (q31_t)0xd8f37c3, (q31_t)0xd88f84d, - (q31_t)0xd82b8cf, (q31_t)0xd7c7948, (q31_t)0xd7639b9, (q31_t)0xd6ffa22, (q31_t)0xd69ba82, (q31_t)0xd637ada, (q31_t)0xd5d3b2a, (q31_t)0xd56fb71, - (q31_t)0xd50bbb1, (q31_t)0xd4a7be8, (q31_t)0xd443c17, (q31_t)0xd3dfc3e, (q31_t)0xd37bc5c, (q31_t)0xd317c73, (q31_t)0xd2b3c81, (q31_t)0xd24fc87, - (q31_t)0xd1ebc85, (q31_t)0xd187c7b, (q31_t)0xd123c69, (q31_t)0xd0bfc4f, (q31_t)0xd05bc2d, (q31_t)0xcff7c02, (q31_t)0xcf93bd0, (q31_t)0xcf2fb96, - (q31_t)0xcecbb53, (q31_t)0xce67b09, (q31_t)0xce03ab7, (q31_t)0xcd9fa5d, (q31_t)0xcd3b9fb, (q31_t)0xccd7991, (q31_t)0xcc7391f, (q31_t)0xcc0f8a5, - (q31_t)0xcbab824, (q31_t)0xcb4779a, (q31_t)0xcae3709, (q31_t)0xca7f670, (q31_t)0xca1b5cf, (q31_t)0xc9b7526, (q31_t)0xc953475, (q31_t)0xc8ef3bd, - (q31_t)0xc88b2fd, (q31_t)0xc827235, (q31_t)0xc7c3166, (q31_t)0xc75f08f, (q31_t)0xc6fafb0, (q31_t)0xc696ec9, (q31_t)0xc632ddb, (q31_t)0xc5cece5, - (q31_t)0xc56abe8, (q31_t)0xc506ae3, (q31_t)0xc4a29d6, (q31_t)0xc43e8c2, (q31_t)0xc3da7a6, (q31_t)0xc376683, (q31_t)0xc312558, (q31_t)0xc2ae425, - (q31_t)0xc24a2eb, (q31_t)0xc1e61aa, (q31_t)0xc182061, (q31_t)0xc11df11, (q31_t)0xc0b9db9, (q31_t)0xc055c5a, (q31_t)0xbff1af3, (q31_t)0xbf8d985, - (q31_t)0xbf29810, (q31_t)0xbec5693, (q31_t)0xbe6150f, (q31_t)0xbdfd383, (q31_t)0xbd991f0, (q31_t)0xbd35056, (q31_t)0xbcd0eb5, (q31_t)0xbc6cd0c, - (q31_t)0xbc08b5c, (q31_t)0xbba49a5, (q31_t)0xbb407e7, (q31_t)0xbadc621, (q31_t)0xba78454, (q31_t)0xba14280, (q31_t)0xb9b00a5, (q31_t)0xb94bec2, - (q31_t)0xb8e7cd9, (q31_t)0xb883ae8, (q31_t)0xb81f8f0, (q31_t)0xb7bb6f2, (q31_t)0xb7574ec, (q31_t)0xb6f32df, (q31_t)0xb68f0cb, (q31_t)0xb62aeaf, - (q31_t)0xb5c6c8d, (q31_t)0xb562a64, (q31_t)0xb4fe834, (q31_t)0xb49a5fd, (q31_t)0xb4363bf, (q31_t)0xb3d217a, (q31_t)0xb36df2e, (q31_t)0xb309cdb, - (q31_t)0xb2a5a81, (q31_t)0xb241820, (q31_t)0xb1dd5b9, (q31_t)0xb17934b, (q31_t)0xb1150d5, (q31_t)0xb0b0e59, (q31_t)0xb04cbd6, (q31_t)0xafe894d, - (q31_t)0xaf846bc, (q31_t)0xaf20425, (q31_t)0xaebc187, (q31_t)0xae57ee2, (q31_t)0xadf3c37, (q31_t)0xad8f985, (q31_t)0xad2b6cc, (q31_t)0xacc740c, - (q31_t)0xac63146, (q31_t)0xabfee79, (q31_t)0xab9aba6, (q31_t)0xab368cc, (q31_t)0xaad25eb, (q31_t)0xaa6e304, (q31_t)0xaa0a016, (q31_t)0xa9a5d22, - (q31_t)0xa941a27, (q31_t)0xa8dd725, (q31_t)0xa87941d, (q31_t)0xa81510f, (q31_t)0xa7b0dfa, (q31_t)0xa74cadf, (q31_t)0xa6e87bd, (q31_t)0xa684495, - (q31_t)0xa620166, (q31_t)0xa5bbe31, (q31_t)0xa557af5, (q31_t)0xa4f37b3, (q31_t)0xa48f46b, (q31_t)0xa42b11d, (q31_t)0xa3c6dc8, (q31_t)0xa362a6d, - (q31_t)0xa2fe70b, (q31_t)0xa29a3a3, (q31_t)0xa236035, (q31_t)0xa1d1cc1, (q31_t)0xa16d946, (q31_t)0xa1095c6, (q31_t)0xa0a523f, (q31_t)0xa040eb1, - (q31_t)0x9fdcb1e, (q31_t)0x9f78784, (q31_t)0x9f143e5, (q31_t)0x9eb003f, (q31_t)0x9e4bc93, (q31_t)0x9de78e1, (q31_t)0x9d83529, (q31_t)0x9d1f16b, - (q31_t)0x9cbada7, (q31_t)0x9c569dc, (q31_t)0x9bf260c, (q31_t)0x9b8e236, (q31_t)0x9b29e59, (q31_t)0x9ac5a77, (q31_t)0x9a6168f, (q31_t)0x99fd2a0, - (q31_t)0x9998eac, (q31_t)0x9934ab2, (q31_t)0x98d06b2, (q31_t)0x986c2ac, (q31_t)0x9807ea1, (q31_t)0x97a3a8f, (q31_t)0x973f678, (q31_t)0x96db25a, - (q31_t)0x9676e37, (q31_t)0x9612a0e, (q31_t)0x95ae5e0, (q31_t)0x954a1ab, (q31_t)0x94e5d71, (q31_t)0x9481931, (q31_t)0x941d4eb, (q31_t)0x93b90a0, - (q31_t)0x9354c4f, (q31_t)0x92f07f8, (q31_t)0x928c39b, (q31_t)0x9227f39, (q31_t)0x91c3ad2, (q31_t)0x915f664, (q31_t)0x90fb1f1, (q31_t)0x9096d79, - (q31_t)0x90328fb, (q31_t)0x8fce477, (q31_t)0x8f69fee, (q31_t)0x8f05b5f, (q31_t)0x8ea16cb, (q31_t)0x8e3d231, (q31_t)0x8dd8d92, (q31_t)0x8d748ed, - (q31_t)0x8d10443, (q31_t)0x8cabf93, (q31_t)0x8c47ade, (q31_t)0x8be3624, (q31_t)0x8b7f164, (q31_t)0x8b1ac9f, (q31_t)0x8ab67d4, (q31_t)0x8a52304, - (q31_t)0x89ede2f, (q31_t)0x8989955, (q31_t)0x8925475, (q31_t)0x88c0f90, (q31_t)0x885caa5, (q31_t)0x87f85b5, (q31_t)0x87940c1, (q31_t)0x872fbc6, - (q31_t)0x86cb6c7, (q31_t)0x86671c2, (q31_t)0x8602cb9, (q31_t)0x859e7aa, (q31_t)0x853a296, (q31_t)0x84d5d7d, (q31_t)0x847185e, (q31_t)0x840d33b, - (q31_t)0x83a8e12, (q31_t)0x83448e5, (q31_t)0x82e03b2, (q31_t)0x827be7a, (q31_t)0x821793e, (q31_t)0x81b33fc, (q31_t)0x814eeb5, (q31_t)0x80ea969, - (q31_t)0x8086419, (q31_t)0x8021ec3, (q31_t)0x7fbd968, (q31_t)0x7f59409, (q31_t)0x7ef4ea4, (q31_t)0x7e9093b, (q31_t)0x7e2c3cd, (q31_t)0x7dc7e5a, - (q31_t)0x7d638e2, (q31_t)0x7cff365, (q31_t)0x7c9ade4, (q31_t)0x7c3685d, (q31_t)0x7bd22d2, (q31_t)0x7b6dd42, (q31_t)0x7b097ad, (q31_t)0x7aa5214, - (q31_t)0x7a40c76, (q31_t)0x79dc6d3, (q31_t)0x797812b, (q31_t)0x7913b7f, (q31_t)0x78af5ce, (q31_t)0x784b019, (q31_t)0x77e6a5e, (q31_t)0x77824a0, - (q31_t)0x771dedc, (q31_t)0x76b9914, (q31_t)0x7655347, (q31_t)0x75f0d76, (q31_t)0x758c7a1, (q31_t)0x75281c6, (q31_t)0x74c3be7, (q31_t)0x745f604, - (q31_t)0x73fb01c, (q31_t)0x7396a30, (q31_t)0x733243f, (q31_t)0x72cde4a, (q31_t)0x7269851, (q31_t)0x7205253, (q31_t)0x71a0c50, (q31_t)0x713c64a, - (q31_t)0x70d803f, (q31_t)0x7073a2f, (q31_t)0x700f41b, (q31_t)0x6faae03, (q31_t)0x6f467e7, (q31_t)0x6ee21c6, (q31_t)0x6e7dba1, (q31_t)0x6e19578, - (q31_t)0x6db4f4a, (q31_t)0x6d50919, (q31_t)0x6cec2e3, (q31_t)0x6c87ca9, (q31_t)0x6c2366a, (q31_t)0x6bbf028, (q31_t)0x6b5a9e1, (q31_t)0x6af6396, - (q31_t)0x6a91d47, (q31_t)0x6a2d6f4, (q31_t)0x69c909d, (q31_t)0x6964a42, (q31_t)0x69003e3, (q31_t)0x689bd80, (q31_t)0x6837718, (q31_t)0x67d30ad, - (q31_t)0x676ea3d, (q31_t)0x670a3ca, (q31_t)0x66a5d53, (q31_t)0x66416d8, (q31_t)0x65dd058, (q31_t)0x65789d5, (q31_t)0x651434e, (q31_t)0x64afcc3, - (q31_t)0x644b634, (q31_t)0x63e6fa2, (q31_t)0x638290b, (q31_t)0x631e271, (q31_t)0x62b9bd3, (q31_t)0x6255531, (q31_t)0x61f0e8b, (q31_t)0x618c7e1, - (q31_t)0x6128134, (q31_t)0x60c3a83, (q31_t)0x605f3ce, (q31_t)0x5ffad15, (q31_t)0x5f96659, (q31_t)0x5f31f99, (q31_t)0x5ecd8d6, (q31_t)0x5e6920e, - (q31_t)0x5e04b43, (q31_t)0x5da0475, (q31_t)0x5d3bda3, (q31_t)0x5cd76cd, (q31_t)0x5c72ff4, (q31_t)0x5c0e917, (q31_t)0x5baa237, (q31_t)0x5b45b53, - (q31_t)0x5ae146b, (q31_t)0x5a7cd80, (q31_t)0x5a18692, (q31_t)0x59b3fa0, (q31_t)0x594f8aa, (q31_t)0x58eb1b2, (q31_t)0x5886ab5, (q31_t)0x58223b6, - (q31_t)0x57bdcb3, (q31_t)0x57595ac, (q31_t)0x56f4ea2, (q31_t)0x5690795, (q31_t)0x562c085, (q31_t)0x55c7971, (q31_t)0x556325a, (q31_t)0x54feb3f, - (q31_t)0x549a422, (q31_t)0x5435d01, (q31_t)0x53d15dd, (q31_t)0x536ceb5, (q31_t)0x530878a, (q31_t)0x52a405d, (q31_t)0x523f92c, (q31_t)0x51db1f7, - (q31_t)0x5176ac0, (q31_t)0x5112385, (q31_t)0x50adc48, (q31_t)0x5049507, (q31_t)0x4fe4dc3, (q31_t)0x4f8067c, (q31_t)0x4f1bf32, (q31_t)0x4eb77e5, - (q31_t)0x4e53095, (q31_t)0x4dee942, (q31_t)0x4d8a1ec, (q31_t)0x4d25a93, (q31_t)0x4cc1337, (q31_t)0x4c5cbd8, (q31_t)0x4bf8476, (q31_t)0x4b93d11, - (q31_t)0x4b2f5a9, (q31_t)0x4acae3e, (q31_t)0x4a666d1, (q31_t)0x4a01f60, (q31_t)0x499d7ed, (q31_t)0x4939077, (q31_t)0x48d48fe, (q31_t)0x4870182, - (q31_t)0x480ba04, (q31_t)0x47a7282, (q31_t)0x4742afe, (q31_t)0x46de377, (q31_t)0x4679bee, (q31_t)0x4615461, (q31_t)0x45b0cd2, (q31_t)0x454c541, - (q31_t)0x44e7dac, (q31_t)0x4483615, (q31_t)0x441ee7c, (q31_t)0x43ba6df, (q31_t)0x4355f40, (q31_t)0x42f179f, (q31_t)0x428cffb, (q31_t)0x4228854, - (q31_t)0x41c40ab, (q31_t)0x415f8ff, (q31_t)0x40fb151, (q31_t)0x40969a0, (q31_t)0x40321ed, (q31_t)0x3fcda37, (q31_t)0x3f6927f, (q31_t)0x3f04ac4, - (q31_t)0x3ea0307, (q31_t)0x3e3bb48, (q31_t)0x3dd7386, (q31_t)0x3d72bc2, (q31_t)0x3d0e3fb, (q31_t)0x3ca9c32, (q31_t)0x3c45467, (q31_t)0x3be0c99, - (q31_t)0x3b7c4c9, (q31_t)0x3b17cf7, (q31_t)0x3ab3523, (q31_t)0x3a4ed4c, (q31_t)0x39ea573, (q31_t)0x3985d97, (q31_t)0x39215ba, (q31_t)0x38bcdda, - (q31_t)0x38585f8, (q31_t)0x37f3e14, (q31_t)0x378f62e, (q31_t)0x372ae46, (q31_t)0x36c665b, (q31_t)0x3661e6f, (q31_t)0x35fd680, (q31_t)0x3598e8f, - (q31_t)0x353469c, (q31_t)0x34cfea8, (q31_t)0x346b6b1, (q31_t)0x3406eb8, (q31_t)0x33a26bd, (q31_t)0x333dec0, (q31_t)0x32d96c1, (q31_t)0x3274ec0, - (q31_t)0x32106bd, (q31_t)0x31abeb9, (q31_t)0x31476b2, (q31_t)0x30e2ea9, (q31_t)0x307e69f, (q31_t)0x3019e93, (q31_t)0x2fb5684, (q31_t)0x2f50e74, - (q31_t)0x2eec663, (q31_t)0x2e87e4f, (q31_t)0x2e2363a, (q31_t)0x2dbee22, (q31_t)0x2d5a609, (q31_t)0x2cf5def, (q31_t)0x2c915d2, (q31_t)0x2c2cdb4, - (q31_t)0x2bc8594, (q31_t)0x2b63d73, (q31_t)0x2aff54f, (q31_t)0x2a9ad2a, (q31_t)0x2a36504, (q31_t)0x29d1cdc, (q31_t)0x296d4b2, (q31_t)0x2908c87, - (q31_t)0x28a445a, (q31_t)0x283fc2b, (q31_t)0x27db3fb, (q31_t)0x2776bc9, (q31_t)0x2712396, (q31_t)0x26adb62, (q31_t)0x264932b, (q31_t)0x25e4af4, - (q31_t)0x25802bb, (q31_t)0x251ba80, (q31_t)0x24b7244, (q31_t)0x2452a07, (q31_t)0x23ee1c8, (q31_t)0x2389988, (q31_t)0x2325147, (q31_t)0x22c0904, - (q31_t)0x225c0bf, (q31_t)0x21f787a, (q31_t)0x2193033, (q31_t)0x212e7eb, (q31_t)0x20c9fa1, (q31_t)0x2065757, (q31_t)0x2000f0b, (q31_t)0x1f9c6be, - (q31_t)0x1f37e6f, (q31_t)0x1ed3620, (q31_t)0x1e6edcf, (q31_t)0x1e0a57d, (q31_t)0x1da5d2a, (q31_t)0x1d414d6, (q31_t)0x1cdcc80, (q31_t)0x1c7842a, - (q31_t)0x1c13bd2, (q31_t)0x1baf37a, (q31_t)0x1b4ab20, (q31_t)0x1ae62c5, (q31_t)0x1a81a69, (q31_t)0x1a1d20c, (q31_t)0x19b89ae, (q31_t)0x1954150, - (q31_t)0x18ef8f0, (q31_t)0x188b08f, (q31_t)0x182682d, (q31_t)0x17c1fcb, (q31_t)0x175d767, (q31_t)0x16f8f03, (q31_t)0x169469d, (q31_t)0x162fe37, - (q31_t)0x15cb5d0, (q31_t)0x1566d68, (q31_t)0x15024ff, (q31_t)0x149dc96, (q31_t)0x143942b, (q31_t)0x13d4bc0, (q31_t)0x1370354, (q31_t)0x130bae7, - (q31_t)0x12a727a, (q31_t)0x1242a0c, (q31_t)0x11de19d, (q31_t)0x117992e, (q31_t)0x11150be, (q31_t)0x10b084d, (q31_t)0x104bfdb, (q31_t)0xfe7769, - (q31_t)0xf82ef6, (q31_t)0xf1e683, (q31_t)0xeb9e0f, (q31_t)0xe5559b, (q31_t)0xdf0d26, (q31_t)0xd8c4b0, (q31_t)0xd27c3a, (q31_t)0xcc33c3, - (q31_t)0xc5eb4c, (q31_t)0xbfa2d5, (q31_t)0xb95a5d, (q31_t)0xb311e4, (q31_t)0xacc96b, (q31_t)0xa680f2, (q31_t)0xa03878, (q31_t)0x99effe, - (q31_t)0x93a784, (q31_t)0x8d5f09, (q31_t)0x87168e, (q31_t)0x80ce12, (q31_t)0x7a8597, (q31_t)0x743d1a, (q31_t)0x6df49e, (q31_t)0x67ac21, - (q31_t)0x6163a5, (q31_t)0x5b1b27, (q31_t)0x54d2aa, (q31_t)0x4e8a2c, (q31_t)0x4841af, (q31_t)0x41f931, (q31_t)0x3bb0b3, (q31_t)0x356835, - (q31_t)0x2f1fb6, (q31_t)0x28d738, (q31_t)0x228eb9, (q31_t)0x1c463b, (q31_t)0x15fdbc, (q31_t)0xfb53d, (q31_t)0x96cbe, (q31_t)0x3243f -}; + (q31_t)0x7ffffff6, (q31_t)0x7fffffa7, (q31_t)0x7fffff09, (q31_t)0x7ffffe1c, + (q31_t)0x7ffffce1, (q31_t)0x7ffffb56, (q31_t)0x7ffff97c, (q31_t)0x7ffff753, + (q31_t)0x7ffff4dc, (q31_t)0x7ffff215, (q31_t)0x7fffef00, (q31_t)0x7fffeb9b, + (q31_t)0x7fffe7e8, (q31_t)0x7fffe3e5, (q31_t)0x7fffdf94, (q31_t)0x7fffdaf3, + (q31_t)0x7fffd604, (q31_t)0x7fffd0c6, (q31_t)0x7fffcb39, (q31_t)0x7fffc55c, + (q31_t)0x7fffbf31, (q31_t)0x7fffb8b7, (q31_t)0x7fffb1ee, (q31_t)0x7fffaad6, + (q31_t)0x7fffa36f, (q31_t)0x7fff9bb9, (q31_t)0x7fff93b4, (q31_t)0x7fff8b61, + (q31_t)0x7fff82be, (q31_t)0x7fff79cc, (q31_t)0x7fff708b, (q31_t)0x7fff66fc, + (q31_t)0x7fff5d1d, (q31_t)0x7fff52ef, (q31_t)0x7fff4873, (q31_t)0x7fff3da8, + (q31_t)0x7fff328d, (q31_t)0x7fff2724, (q31_t)0x7fff1b6b, (q31_t)0x7fff0f64, + (q31_t)0x7fff030e, (q31_t)0x7ffef669, (q31_t)0x7ffee975, (q31_t)0x7ffedc31, + (q31_t)0x7ffece9f, (q31_t)0x7ffec0be, (q31_t)0x7ffeb28e, (q31_t)0x7ffea40f, + (q31_t)0x7ffe9542, (q31_t)0x7ffe8625, (q31_t)0x7ffe76b9, (q31_t)0x7ffe66fe, + (q31_t)0x7ffe56f5, (q31_t)0x7ffe469c, (q31_t)0x7ffe35f4, (q31_t)0x7ffe24fe, + (q31_t)0x7ffe13b8, (q31_t)0x7ffe0224, (q31_t)0x7ffdf040, (q31_t)0x7ffdde0e, + (q31_t)0x7ffdcb8d, (q31_t)0x7ffdb8bc, (q31_t)0x7ffda59d, (q31_t)0x7ffd922f, + (q31_t)0x7ffd7e72, (q31_t)0x7ffd6a66, (q31_t)0x7ffd560b, (q31_t)0x7ffd4161, + (q31_t)0x7ffd2c68, (q31_t)0x7ffd1720, (q31_t)0x7ffd0189, (q31_t)0x7ffceba4, + (q31_t)0x7ffcd56f, (q31_t)0x7ffcbeeb, (q31_t)0x7ffca819, (q31_t)0x7ffc90f7, + (q31_t)0x7ffc7987, (q31_t)0x7ffc61c7, (q31_t)0x7ffc49b9, (q31_t)0x7ffc315b, + (q31_t)0x7ffc18af, (q31_t)0x7ffbffb4, (q31_t)0x7ffbe66a, (q31_t)0x7ffbccd0, + (q31_t)0x7ffbb2e8, (q31_t)0x7ffb98b1, (q31_t)0x7ffb7e2b, (q31_t)0x7ffb6356, + (q31_t)0x7ffb4833, (q31_t)0x7ffb2cc0, (q31_t)0x7ffb10fe, (q31_t)0x7ffaf4ed, + (q31_t)0x7ffad88e, (q31_t)0x7ffabbdf, (q31_t)0x7ffa9ee2, (q31_t)0x7ffa8195, + (q31_t)0x7ffa63fa, (q31_t)0x7ffa460f, (q31_t)0x7ffa27d6, (q31_t)0x7ffa094e, + (q31_t)0x7ff9ea76, (q31_t)0x7ff9cb50, (q31_t)0x7ff9abdb, (q31_t)0x7ff98c17, + (q31_t)0x7ff96c04, (q31_t)0x7ff94ba2, (q31_t)0x7ff92af1, (q31_t)0x7ff909f2, + (q31_t)0x7ff8e8a3, (q31_t)0x7ff8c705, (q31_t)0x7ff8a519, (q31_t)0x7ff882dd, + (q31_t)0x7ff86053, (q31_t)0x7ff83d79, (q31_t)0x7ff81a51, (q31_t)0x7ff7f6da, + (q31_t)0x7ff7d313, (q31_t)0x7ff7aefe, (q31_t)0x7ff78a9a, (q31_t)0x7ff765e7, + (q31_t)0x7ff740e5, (q31_t)0x7ff71b94, (q31_t)0x7ff6f5f4, (q31_t)0x7ff6d005, + (q31_t)0x7ff6a9c8, (q31_t)0x7ff6833b, (q31_t)0x7ff65c5f, (q31_t)0x7ff63535, + (q31_t)0x7ff60dbb, (q31_t)0x7ff5e5f3, (q31_t)0x7ff5bddc, (q31_t)0x7ff59576, + (q31_t)0x7ff56cc0, (q31_t)0x7ff543bc, (q31_t)0x7ff51a69, (q31_t)0x7ff4f0c7, + (q31_t)0x7ff4c6d6, (q31_t)0x7ff49c96, (q31_t)0x7ff47208, (q31_t)0x7ff4472a, + (q31_t)0x7ff41bfd, (q31_t)0x7ff3f082, (q31_t)0x7ff3c4b7, (q31_t)0x7ff3989e, + (q31_t)0x7ff36c36, (q31_t)0x7ff33f7e, (q31_t)0x7ff31278, (q31_t)0x7ff2e523, + (q31_t)0x7ff2b77f, (q31_t)0x7ff2898c, (q31_t)0x7ff25b4a, (q31_t)0x7ff22cb9, + (q31_t)0x7ff1fdd9, (q31_t)0x7ff1ceab, (q31_t)0x7ff19f2d, (q31_t)0x7ff16f61, + (q31_t)0x7ff13f45, (q31_t)0x7ff10edb, (q31_t)0x7ff0de22, (q31_t)0x7ff0ad19, + (q31_t)0x7ff07bc2, (q31_t)0x7ff04a1c, (q31_t)0x7ff01827, (q31_t)0x7fefe5e4, + (q31_t)0x7fefb351, (q31_t)0x7fef806f, (q31_t)0x7fef4d3e, (q31_t)0x7fef19bf, + (q31_t)0x7feee5f0, (q31_t)0x7feeb1d3, (q31_t)0x7fee7d67, (q31_t)0x7fee48ac, + (q31_t)0x7fee13a1, (q31_t)0x7fedde48, (q31_t)0x7feda8a0, (q31_t)0x7fed72aa, + (q31_t)0x7fed3c64, (q31_t)0x7fed05cf, (q31_t)0x7fecceec, (q31_t)0x7fec97b9, + (q31_t)0x7fec6038, (q31_t)0x7fec2867, (q31_t)0x7febf048, (q31_t)0x7febb7da, + (q31_t)0x7feb7f1d, (q31_t)0x7feb4611, (q31_t)0x7feb0cb6, (q31_t)0x7fead30c, + (q31_t)0x7fea9914, (q31_t)0x7fea5ecc, (q31_t)0x7fea2436, (q31_t)0x7fe9e950, + (q31_t)0x7fe9ae1c, (q31_t)0x7fe97299, (q31_t)0x7fe936c7, (q31_t)0x7fe8faa6, + (q31_t)0x7fe8be36, (q31_t)0x7fe88177, (q31_t)0x7fe84469, (q31_t)0x7fe8070d, + (q31_t)0x7fe7c961, (q31_t)0x7fe78b67, (q31_t)0x7fe74d1e, (q31_t)0x7fe70e85, + (q31_t)0x7fe6cf9e, (q31_t)0x7fe69068, (q31_t)0x7fe650e3, (q31_t)0x7fe61110, + (q31_t)0x7fe5d0ed, (q31_t)0x7fe5907b, (q31_t)0x7fe54fbb, (q31_t)0x7fe50eac, + (q31_t)0x7fe4cd4d, (q31_t)0x7fe48ba0, (q31_t)0x7fe449a4, (q31_t)0x7fe40759, + (q31_t)0x7fe3c4bf, (q31_t)0x7fe381d7, (q31_t)0x7fe33e9f, (q31_t)0x7fe2fb19, + (q31_t)0x7fe2b743, (q31_t)0x7fe2731f, (q31_t)0x7fe22eac, (q31_t)0x7fe1e9ea, + (q31_t)0x7fe1a4d9, (q31_t)0x7fe15f79, (q31_t)0x7fe119cb, (q31_t)0x7fe0d3cd, + (q31_t)0x7fe08d81, (q31_t)0x7fe046e5, (q31_t)0x7fdffffb, (q31_t)0x7fdfb8c2, + (q31_t)0x7fdf713a, (q31_t)0x7fdf2963, (q31_t)0x7fdee13e, (q31_t)0x7fde98c9, + (q31_t)0x7fde5006, (q31_t)0x7fde06f3, (q31_t)0x7fddbd92, (q31_t)0x7fdd73e2, + (q31_t)0x7fdd29e3, (q31_t)0x7fdcdf95, (q31_t)0x7fdc94f9, (q31_t)0x7fdc4a0d, + (q31_t)0x7fdbfed3, (q31_t)0x7fdbb349, (q31_t)0x7fdb6771, (q31_t)0x7fdb1b4a, + (q31_t)0x7fdaced4, (q31_t)0x7fda820f, (q31_t)0x7fda34fc, (q31_t)0x7fd9e799, + (q31_t)0x7fd999e8, (q31_t)0x7fd94be8, (q31_t)0x7fd8fd98, (q31_t)0x7fd8aefa, + (q31_t)0x7fd8600e, (q31_t)0x7fd810d2, (q31_t)0x7fd7c147, (q31_t)0x7fd7716e, + (q31_t)0x7fd72146, (q31_t)0x7fd6d0cf, (q31_t)0x7fd68009, (q31_t)0x7fd62ef4, + (q31_t)0x7fd5dd90, (q31_t)0x7fd58bdd, (q31_t)0x7fd539dc, (q31_t)0x7fd4e78c, + (q31_t)0x7fd494ed, (q31_t)0x7fd441ff, (q31_t)0x7fd3eec2, (q31_t)0x7fd39b36, + (q31_t)0x7fd3475c, (q31_t)0x7fd2f332, (q31_t)0x7fd29eba, (q31_t)0x7fd249f3, + (q31_t)0x7fd1f4dd, (q31_t)0x7fd19f78, (q31_t)0x7fd149c5, (q31_t)0x7fd0f3c2, + (q31_t)0x7fd09d71, (q31_t)0x7fd046d1, (q31_t)0x7fcfefe2, (q31_t)0x7fcf98a4, + (q31_t)0x7fcf4117, (q31_t)0x7fcee93c, (q31_t)0x7fce9112, (q31_t)0x7fce3898, + (q31_t)0x7fcddfd0, (q31_t)0x7fcd86b9, (q31_t)0x7fcd2d54, (q31_t)0x7fccd39f, + (q31_t)0x7fcc799c, (q31_t)0x7fcc1f4a, (q31_t)0x7fcbc4a9, (q31_t)0x7fcb69b9, + (q31_t)0x7fcb0e7a, (q31_t)0x7fcab2ed, (q31_t)0x7fca5710, (q31_t)0x7fc9fae5, + (q31_t)0x7fc99e6b, (q31_t)0x7fc941a2, (q31_t)0x7fc8e48b, (q31_t)0x7fc88724, + (q31_t)0x7fc8296f, (q31_t)0x7fc7cb6b, (q31_t)0x7fc76d18, (q31_t)0x7fc70e76, + (q31_t)0x7fc6af86, (q31_t)0x7fc65046, (q31_t)0x7fc5f0b8, (q31_t)0x7fc590db, + (q31_t)0x7fc530af, (q31_t)0x7fc4d035, (q31_t)0x7fc46f6b, (q31_t)0x7fc40e53, + (q31_t)0x7fc3acec, (q31_t)0x7fc34b36, (q31_t)0x7fc2e931, (q31_t)0x7fc286de, + (q31_t)0x7fc2243b, (q31_t)0x7fc1c14a, (q31_t)0x7fc15e0a, (q31_t)0x7fc0fa7b, + (q31_t)0x7fc0969e, (q31_t)0x7fc03271, (q31_t)0x7fbfcdf6, (q31_t)0x7fbf692c, + (q31_t)0x7fbf0414, (q31_t)0x7fbe9eac, (q31_t)0x7fbe38f6, (q31_t)0x7fbdd2f0, + (q31_t)0x7fbd6c9c, (q31_t)0x7fbd05fa, (q31_t)0x7fbc9f08, (q31_t)0x7fbc37c8, + (q31_t)0x7fbbd039, (q31_t)0x7fbb685b, (q31_t)0x7fbb002e, (q31_t)0x7fba97b2, + (q31_t)0x7fba2ee8, (q31_t)0x7fb9c5cf, (q31_t)0x7fb95c67, (q31_t)0x7fb8f2b0, + (q31_t)0x7fb888ab, (q31_t)0x7fb81e57, (q31_t)0x7fb7b3b4, (q31_t)0x7fb748c2, + (q31_t)0x7fb6dd81, (q31_t)0x7fb671f2, (q31_t)0x7fb60614, (q31_t)0x7fb599e7, + (q31_t)0x7fb52d6b, (q31_t)0x7fb4c0a1, (q31_t)0x7fb45387, (q31_t)0x7fb3e61f, + (q31_t)0x7fb37869, (q31_t)0x7fb30a63, (q31_t)0x7fb29c0f, (q31_t)0x7fb22d6c, + (q31_t)0x7fb1be7a, (q31_t)0x7fb14f39, (q31_t)0x7fb0dfaa, (q31_t)0x7fb06fcb, + (q31_t)0x7fafff9e, (q31_t)0x7faf8f23, (q31_t)0x7faf1e58, (q31_t)0x7faead3f, + (q31_t)0x7fae3bd7, (q31_t)0x7fadca20, (q31_t)0x7fad581b, (q31_t)0x7face5c6, + (q31_t)0x7fac7323, (q31_t)0x7fac0031, (q31_t)0x7fab8cf1, (q31_t)0x7fab1962, + (q31_t)0x7faaa584, (q31_t)0x7faa3157, (q31_t)0x7fa9bcdb, (q31_t)0x7fa94811, + (q31_t)0x7fa8d2f8, (q31_t)0x7fa85d90, (q31_t)0x7fa7e7d9, (q31_t)0x7fa771d4, + (q31_t)0x7fa6fb80, (q31_t)0x7fa684dd, (q31_t)0x7fa60dec, (q31_t)0x7fa596ac, + (q31_t)0x7fa51f1d, (q31_t)0x7fa4a73f, (q31_t)0x7fa42f12, (q31_t)0x7fa3b697, + (q31_t)0x7fa33dcd, (q31_t)0x7fa2c4b5, (q31_t)0x7fa24b4d, (q31_t)0x7fa1d197, + (q31_t)0x7fa15792, (q31_t)0x7fa0dd3f, (q31_t)0x7fa0629c, (q31_t)0x7f9fe7ab, + (q31_t)0x7f9f6c6b, (q31_t)0x7f9ef0dd, (q31_t)0x7f9e7500, (q31_t)0x7f9df8d4, + (q31_t)0x7f9d7c59, (q31_t)0x7f9cff90, (q31_t)0x7f9c8278, (q31_t)0x7f9c0511, + (q31_t)0x7f9b875b, (q31_t)0x7f9b0957, (q31_t)0x7f9a8b04, (q31_t)0x7f9a0c62, + (q31_t)0x7f998d72, (q31_t)0x7f990e33, (q31_t)0x7f988ea5, (q31_t)0x7f980ec8, + (q31_t)0x7f978e9d, (q31_t)0x7f970e23, (q31_t)0x7f968d5b, (q31_t)0x7f960c43, + (q31_t)0x7f958add, (q31_t)0x7f950929, (q31_t)0x7f948725, (q31_t)0x7f9404d3, + (q31_t)0x7f938232, (q31_t)0x7f92ff43, (q31_t)0x7f927c04, (q31_t)0x7f91f878, + (q31_t)0x7f91749c, (q31_t)0x7f90f072, (q31_t)0x7f906bf9, (q31_t)0x7f8fe731, + (q31_t)0x7f8f621b, (q31_t)0x7f8edcb6, (q31_t)0x7f8e5702, (q31_t)0x7f8dd0ff, + (q31_t)0x7f8d4aae, (q31_t)0x7f8cc40f, (q31_t)0x7f8c3d20, (q31_t)0x7f8bb5e3, + (q31_t)0x7f8b2e57, (q31_t)0x7f8aa67d, (q31_t)0x7f8a1e54, (q31_t)0x7f8995dc, + (q31_t)0x7f890d15, (q31_t)0x7f888400, (q31_t)0x7f87fa9c, (q31_t)0x7f8770ea, + (q31_t)0x7f86e6e9, (q31_t)0x7f865c99, (q31_t)0x7f85d1fa, (q31_t)0x7f85470d, + (q31_t)0x7f84bbd1, (q31_t)0x7f843047, (q31_t)0x7f83a46e, (q31_t)0x7f831846, + (q31_t)0x7f828bcf, (q31_t)0x7f81ff0a, (q31_t)0x7f8171f6, (q31_t)0x7f80e494, + (q31_t)0x7f8056e3, (q31_t)0x7f7fc8e3, (q31_t)0x7f7f3a95, (q31_t)0x7f7eabf8, + (q31_t)0x7f7e1d0c, (q31_t)0x7f7d8dd2, (q31_t)0x7f7cfe49, (q31_t)0x7f7c6e71, + (q31_t)0x7f7bde4b, (q31_t)0x7f7b4dd6, (q31_t)0x7f7abd13, (q31_t)0x7f7a2c01, + (q31_t)0x7f799aa0, (q31_t)0x7f7908f0, (q31_t)0x7f7876f2, (q31_t)0x7f77e4a6, + (q31_t)0x7f77520a, (q31_t)0x7f76bf21, (q31_t)0x7f762be8, (q31_t)0x7f759861, + (q31_t)0x7f75048b, (q31_t)0x7f747067, (q31_t)0x7f73dbf4, (q31_t)0x7f734732, + (q31_t)0x7f72b222, (q31_t)0x7f721cc3, (q31_t)0x7f718715, (q31_t)0x7f70f119, + (q31_t)0x7f705ace, (q31_t)0x7f6fc435, (q31_t)0x7f6f2d4d, (q31_t)0x7f6e9617, + (q31_t)0x7f6dfe91, (q31_t)0x7f6d66be, (q31_t)0x7f6cce9b, (q31_t)0x7f6c362a, + (q31_t)0x7f6b9d6b, (q31_t)0x7f6b045d, (q31_t)0x7f6a6b00, (q31_t)0x7f69d154, + (q31_t)0x7f69375a, (q31_t)0x7f689d12, (q31_t)0x7f68027b, (q31_t)0x7f676795, + (q31_t)0x7f66cc61, (q31_t)0x7f6630de, (q31_t)0x7f65950c, (q31_t)0x7f64f8ec, + (q31_t)0x7f645c7d, (q31_t)0x7f63bfc0, (q31_t)0x7f6322b4, (q31_t)0x7f62855a, + (q31_t)0x7f61e7b1, (q31_t)0x7f6149b9, (q31_t)0x7f60ab73, (q31_t)0x7f600cdf, + (q31_t)0x7f5f6dfb, (q31_t)0x7f5ecec9, (q31_t)0x7f5e2f49, (q31_t)0x7f5d8f7a, + (q31_t)0x7f5cef5c, (q31_t)0x7f5c4ef0, (q31_t)0x7f5bae36, (q31_t)0x7f5b0d2c, + (q31_t)0x7f5a6bd5, (q31_t)0x7f59ca2e, (q31_t)0x7f592839, (q31_t)0x7f5885f6, + (q31_t)0x7f57e364, (q31_t)0x7f574083, (q31_t)0x7f569d54, (q31_t)0x7f55f9d6, + (q31_t)0x7f55560a, (q31_t)0x7f54b1ef, (q31_t)0x7f540d86, (q31_t)0x7f5368ce, + (q31_t)0x7f52c3c8, (q31_t)0x7f521e73, (q31_t)0x7f5178cf, (q31_t)0x7f50d2dd, + (q31_t)0x7f502c9d, (q31_t)0x7f4f860e, (q31_t)0x7f4edf30, (q31_t)0x7f4e3804, + (q31_t)0x7f4d9089, (q31_t)0x7f4ce8c0, (q31_t)0x7f4c40a8, (q31_t)0x7f4b9842, + (q31_t)0x7f4aef8d, (q31_t)0x7f4a468a, (q31_t)0x7f499d38, (q31_t)0x7f48f398, + (q31_t)0x7f4849a9, (q31_t)0x7f479f6c, (q31_t)0x7f46f4e0, (q31_t)0x7f464a06, + (q31_t)0x7f459edd, (q31_t)0x7f44f365, (q31_t)0x7f44479f, (q31_t)0x7f439b8b, + (q31_t)0x7f42ef28, (q31_t)0x7f424277, (q31_t)0x7f419577, (q31_t)0x7f40e828, + (q31_t)0x7f403a8b, (q31_t)0x7f3f8ca0, (q31_t)0x7f3ede66, (q31_t)0x7f3e2fde, + (q31_t)0x7f3d8107, (q31_t)0x7f3cd1e2, (q31_t)0x7f3c226e, (q31_t)0x7f3b72ab, + (q31_t)0x7f3ac29b, (q31_t)0x7f3a123b, (q31_t)0x7f39618e, (q31_t)0x7f38b091, + (q31_t)0x7f37ff47, (q31_t)0x7f374dad, (q31_t)0x7f369bc6, (q31_t)0x7f35e990, + (q31_t)0x7f35370b, (q31_t)0x7f348438, (q31_t)0x7f33d116, (q31_t)0x7f331da6, + (q31_t)0x7f3269e8, (q31_t)0x7f31b5db, (q31_t)0x7f31017f, (q31_t)0x7f304cd6, + (q31_t)0x7f2f97dd, (q31_t)0x7f2ee296, (q31_t)0x7f2e2d01, (q31_t)0x7f2d771e, + (q31_t)0x7f2cc0eb, (q31_t)0x7f2c0a6b, (q31_t)0x7f2b539c, (q31_t)0x7f2a9c7e, + (q31_t)0x7f29e512, (q31_t)0x7f292d58, (q31_t)0x7f28754f, (q31_t)0x7f27bcf8, + (q31_t)0x7f270452, (q31_t)0x7f264b5e, (q31_t)0x7f25921c, (q31_t)0x7f24d88b, + (q31_t)0x7f241eab, (q31_t)0x7f23647e, (q31_t)0x7f22aa01, (q31_t)0x7f21ef37, + (q31_t)0x7f21341e, (q31_t)0x7f2078b6, (q31_t)0x7f1fbd00, (q31_t)0x7f1f00fc, + (q31_t)0x7f1e44a9, (q31_t)0x7f1d8808, (q31_t)0x7f1ccb18, (q31_t)0x7f1c0dda, + (q31_t)0x7f1b504e, (q31_t)0x7f1a9273, (q31_t)0x7f19d44a, (q31_t)0x7f1915d2, + (q31_t)0x7f18570c, (q31_t)0x7f1797f8, (q31_t)0x7f16d895, (q31_t)0x7f1618e4, + (q31_t)0x7f1558e4, (q31_t)0x7f149896, (q31_t)0x7f13d7fa, (q31_t)0x7f13170f, + (q31_t)0x7f1255d6, (q31_t)0x7f11944f, (q31_t)0x7f10d279, (q31_t)0x7f101054, + (q31_t)0x7f0f4de2, (q31_t)0x7f0e8b21, (q31_t)0x7f0dc811, (q31_t)0x7f0d04b3, + (q31_t)0x7f0c4107, (q31_t)0x7f0b7d0d, (q31_t)0x7f0ab8c4, (q31_t)0x7f09f42d, + (q31_t)0x7f092f47, (q31_t)0x7f086a13, (q31_t)0x7f07a491, (q31_t)0x7f06dec0, + (q31_t)0x7f0618a1, (q31_t)0x7f055233, (q31_t)0x7f048b78, (q31_t)0x7f03c46d, + (q31_t)0x7f02fd15, (q31_t)0x7f02356e, (q31_t)0x7f016d79, (q31_t)0x7f00a535, + (q31_t)0x7effdca4, (q31_t)0x7eff13c3, (q31_t)0x7efe4a95, (q31_t)0x7efd8118, + (q31_t)0x7efcb74d, (q31_t)0x7efbed33, (q31_t)0x7efb22cb, (q31_t)0x7efa5815, + (q31_t)0x7ef98d11, (q31_t)0x7ef8c1be, (q31_t)0x7ef7f61d, (q31_t)0x7ef72a2d, + (q31_t)0x7ef65def, (q31_t)0x7ef59163, (q31_t)0x7ef4c489, (q31_t)0x7ef3f760, + (q31_t)0x7ef329e9, (q31_t)0x7ef25c24, (q31_t)0x7ef18e10, (q31_t)0x7ef0bfae, + (q31_t)0x7eeff0fe, (q31_t)0x7eef21ff, (q31_t)0x7eee52b2, (q31_t)0x7eed8317, + (q31_t)0x7eecb32d, (q31_t)0x7eebe2f6, (q31_t)0x7eeb1270, (q31_t)0x7eea419b, + (q31_t)0x7ee97079, (q31_t)0x7ee89f08, (q31_t)0x7ee7cd49, (q31_t)0x7ee6fb3b, + (q31_t)0x7ee628df, (q31_t)0x7ee55635, (q31_t)0x7ee4833d, (q31_t)0x7ee3aff6, + (q31_t)0x7ee2dc61, (q31_t)0x7ee2087e, (q31_t)0x7ee1344d, (q31_t)0x7ee05fcd, + (q31_t)0x7edf8aff, (q31_t)0x7edeb5e3, (q31_t)0x7edde079, (q31_t)0x7edd0ac0, + (q31_t)0x7edc34b9, (q31_t)0x7edb5e64, (q31_t)0x7eda87c0, (q31_t)0x7ed9b0ce, + (q31_t)0x7ed8d98e, (q31_t)0x7ed80200, (q31_t)0x7ed72a24, (q31_t)0x7ed651f9, + (q31_t)0x7ed57980, (q31_t)0x7ed4a0b9, (q31_t)0x7ed3c7a3, (q31_t)0x7ed2ee40, + (q31_t)0x7ed2148e, (q31_t)0x7ed13a8e, (q31_t)0x7ed0603f, (q31_t)0x7ecf85a3, + (q31_t)0x7eceaab8, (q31_t)0x7ecdcf7f, (q31_t)0x7eccf3f8, (q31_t)0x7ecc1822, + (q31_t)0x7ecb3bff, (q31_t)0x7eca5f8d, (q31_t)0x7ec982cd, (q31_t)0x7ec8a5bf, + (q31_t)0x7ec7c862, (q31_t)0x7ec6eab7, (q31_t)0x7ec60cbe, (q31_t)0x7ec52e77, + (q31_t)0x7ec44fe2, (q31_t)0x7ec370fe, (q31_t)0x7ec291cd, (q31_t)0x7ec1b24d, + (q31_t)0x7ec0d27f, (q31_t)0x7ebff263, (q31_t)0x7ebf11f8, (q31_t)0x7ebe313f, + (q31_t)0x7ebd5039, (q31_t)0x7ebc6ee4, (q31_t)0x7ebb8d40, (q31_t)0x7ebaab4f, + (q31_t)0x7eb9c910, (q31_t)0x7eb8e682, (q31_t)0x7eb803a6, (q31_t)0x7eb7207c, + (q31_t)0x7eb63d04, (q31_t)0x7eb5593d, (q31_t)0x7eb47529, (q31_t)0x7eb390c6, + (q31_t)0x7eb2ac15, (q31_t)0x7eb1c716, (q31_t)0x7eb0e1c9, (q31_t)0x7eaffc2e, + (q31_t)0x7eaf1645, (q31_t)0x7eae300d, (q31_t)0x7ead4987, (q31_t)0x7eac62b3, + (q31_t)0x7eab7b91, (q31_t)0x7eaa9421, (q31_t)0x7ea9ac63, (q31_t)0x7ea8c457, + (q31_t)0x7ea7dbfc, (q31_t)0x7ea6f353, (q31_t)0x7ea60a5d, (q31_t)0x7ea52118, + (q31_t)0x7ea43785, (q31_t)0x7ea34da4, (q31_t)0x7ea26374, (q31_t)0x7ea178f7, + (q31_t)0x7ea08e2b, (q31_t)0x7e9fa312, (q31_t)0x7e9eb7aa, (q31_t)0x7e9dcbf4, + (q31_t)0x7e9cdff0, (q31_t)0x7e9bf39e, (q31_t)0x7e9b06fe, (q31_t)0x7e9a1a10, + (q31_t)0x7e992cd4, (q31_t)0x7e983f49, (q31_t)0x7e975171, (q31_t)0x7e96634a, + (q31_t)0x7e9574d6, (q31_t)0x7e948613, (q31_t)0x7e939702, (q31_t)0x7e92a7a3, + (q31_t)0x7e91b7f6, (q31_t)0x7e90c7fb, (q31_t)0x7e8fd7b2, (q31_t)0x7e8ee71b, + (q31_t)0x7e8df636, (q31_t)0x7e8d0502, (q31_t)0x7e8c1381, (q31_t)0x7e8b21b1, + (q31_t)0x7e8a2f94, (q31_t)0x7e893d28, (q31_t)0x7e884a6f, (q31_t)0x7e875767, + (q31_t)0x7e866411, (q31_t)0x7e85706d, (q31_t)0x7e847c7c, (q31_t)0x7e83883c, + (q31_t)0x7e8293ae, (q31_t)0x7e819ed2, (q31_t)0x7e80a9a8, (q31_t)0x7e7fb430, + (q31_t)0x7e7ebe6a, (q31_t)0x7e7dc856, (q31_t)0x7e7cd1f4, (q31_t)0x7e7bdb44, + (q31_t)0x7e7ae446, (q31_t)0x7e79ecf9, (q31_t)0x7e78f55f, (q31_t)0x7e77fd77, + (q31_t)0x7e770541, (q31_t)0x7e760cbd, (q31_t)0x7e7513ea, (q31_t)0x7e741aca, + (q31_t)0x7e73215c, (q31_t)0x7e7227a0, (q31_t)0x7e712d96, (q31_t)0x7e70333d, + (q31_t)0x7e6f3897, (q31_t)0x7e6e3da3, (q31_t)0x7e6d4261, (q31_t)0x7e6c46d1, + (q31_t)0x7e6b4af2, (q31_t)0x7e6a4ec6, (q31_t)0x7e69524c, (q31_t)0x7e685584, + (q31_t)0x7e67586e, (q31_t)0x7e665b0a, (q31_t)0x7e655d58, (q31_t)0x7e645f58, + (q31_t)0x7e63610a, (q31_t)0x7e62626e, (q31_t)0x7e616384, (q31_t)0x7e60644c, + (q31_t)0x7e5f64c7, (q31_t)0x7e5e64f3, (q31_t)0x7e5d64d1, (q31_t)0x7e5c6461, + (q31_t)0x7e5b63a4, (q31_t)0x7e5a6298, (q31_t)0x7e59613f, (q31_t)0x7e585f97, + (q31_t)0x7e575da2, (q31_t)0x7e565b5f, (q31_t)0x7e5558ce, (q31_t)0x7e5455ef, + (q31_t)0x7e5352c1, (q31_t)0x7e524f46, (q31_t)0x7e514b7e, (q31_t)0x7e504767, + (q31_t)0x7e4f4302, (q31_t)0x7e4e3e4f, (q31_t)0x7e4d394f, (q31_t)0x7e4c3400, + (q31_t)0x7e4b2e64, (q31_t)0x7e4a287a, (q31_t)0x7e492241, (q31_t)0x7e481bbb, + (q31_t)0x7e4714e7, (q31_t)0x7e460dc5, (q31_t)0x7e450656, (q31_t)0x7e43fe98, + (q31_t)0x7e42f68c, (q31_t)0x7e41ee33, (q31_t)0x7e40e58c, (q31_t)0x7e3fdc97, + (q31_t)0x7e3ed353, (q31_t)0x7e3dc9c3, (q31_t)0x7e3cbfe4, (q31_t)0x7e3bb5b7, + (q31_t)0x7e3aab3c, (q31_t)0x7e39a074, (q31_t)0x7e38955e, (q31_t)0x7e3789fa, + (q31_t)0x7e367e48, (q31_t)0x7e357248, (q31_t)0x7e3465fa, (q31_t)0x7e33595e, + (q31_t)0x7e324c75, (q31_t)0x7e313f3e, (q31_t)0x7e3031b9, (q31_t)0x7e2f23e6, + (q31_t)0x7e2e15c5, (q31_t)0x7e2d0756, (q31_t)0x7e2bf89a, (q31_t)0x7e2ae990, + (q31_t)0x7e29da38, (q31_t)0x7e28ca92, (q31_t)0x7e27ba9e, (q31_t)0x7e26aa5d, + (q31_t)0x7e2599cd, (q31_t)0x7e2488f0, (q31_t)0x7e2377c5, (q31_t)0x7e22664c, + (q31_t)0x7e215486, (q31_t)0x7e204271, (q31_t)0x7e1f300f, (q31_t)0x7e1e1d5f, + (q31_t)0x7e1d0a61, (q31_t)0x7e1bf716, (q31_t)0x7e1ae37c, (q31_t)0x7e19cf95, + (q31_t)0x7e18bb60, (q31_t)0x7e17a6dd, (q31_t)0x7e16920d, (q31_t)0x7e157cee, + (q31_t)0x7e146782, (q31_t)0x7e1351c9, (q31_t)0x7e123bc1, (q31_t)0x7e11256c, + (q31_t)0x7e100ec8, (q31_t)0x7e0ef7d7, (q31_t)0x7e0de099, (q31_t)0x7e0cc90c, + (q31_t)0x7e0bb132, (q31_t)0x7e0a990a, (q31_t)0x7e098095, (q31_t)0x7e0867d1, + (q31_t)0x7e074ec0, (q31_t)0x7e063561, (q31_t)0x7e051bb4, (q31_t)0x7e0401ba, + (q31_t)0x7e02e772, (q31_t)0x7e01ccdc, (q31_t)0x7e00b1f9, (q31_t)0x7dff96c7, + (q31_t)0x7dfe7b48, (q31_t)0x7dfd5f7b, (q31_t)0x7dfc4361, (q31_t)0x7dfb26f9, + (q31_t)0x7dfa0a43, (q31_t)0x7df8ed3f, (q31_t)0x7df7cfee, (q31_t)0x7df6b24f, + (q31_t)0x7df59462, (q31_t)0x7df47628, (q31_t)0x7df357a0, (q31_t)0x7df238ca, + (q31_t)0x7df119a7, (q31_t)0x7deffa35, (q31_t)0x7deeda77, (q31_t)0x7dedba6a, + (q31_t)0x7dec9a10, (q31_t)0x7deb7968, (q31_t)0x7dea5872, (q31_t)0x7de9372f, + (q31_t)0x7de8159e, (q31_t)0x7de6f3c0, (q31_t)0x7de5d193, (q31_t)0x7de4af1a, + (q31_t)0x7de38c52, (q31_t)0x7de2693d, (q31_t)0x7de145da, (q31_t)0x7de02229, + (q31_t)0x7ddefe2b, (q31_t)0x7dddd9e0, (q31_t)0x7ddcb546, (q31_t)0x7ddb905f, + (q31_t)0x7dda6b2a, (q31_t)0x7dd945a8, (q31_t)0x7dd81fd8, (q31_t)0x7dd6f9ba, + (q31_t)0x7dd5d34f, (q31_t)0x7dd4ac96, (q31_t)0x7dd38590, (q31_t)0x7dd25e3c, + (q31_t)0x7dd1369a, (q31_t)0x7dd00eab, (q31_t)0x7dcee66e, (q31_t)0x7dcdbde3, + (q31_t)0x7dcc950b, (q31_t)0x7dcb6be6, (q31_t)0x7dca4272, (q31_t)0x7dc918b1, + (q31_t)0x7dc7eea3, (q31_t)0x7dc6c447, (q31_t)0x7dc5999d, (q31_t)0x7dc46ea6, + (q31_t)0x7dc34361, (q31_t)0x7dc217cf, (q31_t)0x7dc0ebef, (q31_t)0x7dbfbfc1, + (q31_t)0x7dbe9346, (q31_t)0x7dbd667d, (q31_t)0x7dbc3967, (q31_t)0x7dbb0c03, + (q31_t)0x7db9de52, (q31_t)0x7db8b053, (q31_t)0x7db78207, (q31_t)0x7db6536d, + (q31_t)0x7db52485, (q31_t)0x7db3f550, (q31_t)0x7db2c5cd, (q31_t)0x7db195fd, + (q31_t)0x7db065df, (q31_t)0x7daf3574, (q31_t)0x7dae04bb, (q31_t)0x7dacd3b5, + (q31_t)0x7daba261, (q31_t)0x7daa70c0, (q31_t)0x7da93ed1, (q31_t)0x7da80c95, + (q31_t)0x7da6da0b, (q31_t)0x7da5a733, (q31_t)0x7da4740e, (q31_t)0x7da3409c, + (q31_t)0x7da20cdc, (q31_t)0x7da0d8cf, (q31_t)0x7d9fa474, (q31_t)0x7d9e6fcb, + (q31_t)0x7d9d3ad6, (q31_t)0x7d9c0592, (q31_t)0x7d9ad001, (q31_t)0x7d999a23, + (q31_t)0x7d9863f7, (q31_t)0x7d972d7e, (q31_t)0x7d95f6b7, (q31_t)0x7d94bfa3, + (q31_t)0x7d938841, (q31_t)0x7d925092, (q31_t)0x7d911896, (q31_t)0x7d8fe04c, + (q31_t)0x7d8ea7b4, (q31_t)0x7d8d6ecf, (q31_t)0x7d8c359d, (q31_t)0x7d8afc1d, + (q31_t)0x7d89c250, (q31_t)0x7d888835, (q31_t)0x7d874dcd, (q31_t)0x7d861317, + (q31_t)0x7d84d814, (q31_t)0x7d839cc4, (q31_t)0x7d826126, (q31_t)0x7d81253a, + (q31_t)0x7d7fe902, (q31_t)0x7d7eac7c, (q31_t)0x7d7d6fa8, (q31_t)0x7d7c3287, + (q31_t)0x7d7af519, (q31_t)0x7d79b75d, (q31_t)0x7d787954, (q31_t)0x7d773afd, + (q31_t)0x7d75fc59, (q31_t)0x7d74bd68, (q31_t)0x7d737e29, (q31_t)0x7d723e9d, + (q31_t)0x7d70fec4, (q31_t)0x7d6fbe9d, (q31_t)0x7d6e7e29, (q31_t)0x7d6d3d67, + (q31_t)0x7d6bfc58, (q31_t)0x7d6abafc, (q31_t)0x7d697952, (q31_t)0x7d68375b, + (q31_t)0x7d66f517, (q31_t)0x7d65b285, (q31_t)0x7d646fa6, (q31_t)0x7d632c79, + (q31_t)0x7d61e8ff, (q31_t)0x7d60a538, (q31_t)0x7d5f6124, (q31_t)0x7d5e1cc2, + (q31_t)0x7d5cd813, (q31_t)0x7d5b9316, (q31_t)0x7d5a4dcc, (q31_t)0x7d590835, + (q31_t)0x7d57c251, (q31_t)0x7d567c1f, (q31_t)0x7d5535a0, (q31_t)0x7d53eed3, + (q31_t)0x7d52a7ba, (q31_t)0x7d516053, (q31_t)0x7d50189e, (q31_t)0x7d4ed09d, + (q31_t)0x7d4d884e, (q31_t)0x7d4c3fb1, (q31_t)0x7d4af6c8, (q31_t)0x7d49ad91, + (q31_t)0x7d48640d, (q31_t)0x7d471a3c, (q31_t)0x7d45d01d, (q31_t)0x7d4485b1, + (q31_t)0x7d433af8, (q31_t)0x7d41eff1, (q31_t)0x7d40a49e, (q31_t)0x7d3f58fd, + (q31_t)0x7d3e0d0e, (q31_t)0x7d3cc0d3, (q31_t)0x7d3b744a, (q31_t)0x7d3a2774, + (q31_t)0x7d38da51, (q31_t)0x7d378ce0, (q31_t)0x7d363f23, (q31_t)0x7d34f118, + (q31_t)0x7d33a2bf, (q31_t)0x7d32541a, (q31_t)0x7d310527, (q31_t)0x7d2fb5e7, + (q31_t)0x7d2e665a, (q31_t)0x7d2d1680, (q31_t)0x7d2bc659, (q31_t)0x7d2a75e4, + (q31_t)0x7d292522, (q31_t)0x7d27d413, (q31_t)0x7d2682b6, (q31_t)0x7d25310d, + (q31_t)0x7d23df16, (q31_t)0x7d228cd2, (q31_t)0x7d213a41, (q31_t)0x7d1fe762, + (q31_t)0x7d1e9437, (q31_t)0x7d1d40be, (q31_t)0x7d1becf8, (q31_t)0x7d1a98e5, + (q31_t)0x7d194485, (q31_t)0x7d17efd8, (q31_t)0x7d169add, (q31_t)0x7d154595, + (q31_t)0x7d13f001, (q31_t)0x7d129a1f, (q31_t)0x7d1143ef, (q31_t)0x7d0fed73, + (q31_t)0x7d0e96aa, (q31_t)0x7d0d3f93, (q31_t)0x7d0be82f, (q31_t)0x7d0a907e, + (q31_t)0x7d093880, (q31_t)0x7d07e035, (q31_t)0x7d06879d, (q31_t)0x7d052eb8, + (q31_t)0x7d03d585, (q31_t)0x7d027c05, (q31_t)0x7d012239, (q31_t)0x7cffc81f, + (q31_t)0x7cfe6db8, (q31_t)0x7cfd1304, (q31_t)0x7cfbb803, (q31_t)0x7cfa5cb4, + (q31_t)0x7cf90119, (q31_t)0x7cf7a531, (q31_t)0x7cf648fb, (q31_t)0x7cf4ec79, + (q31_t)0x7cf38fa9, (q31_t)0x7cf2328c, (q31_t)0x7cf0d522, (q31_t)0x7cef776b, + (q31_t)0x7cee1967, (q31_t)0x7cecbb16, (q31_t)0x7ceb5c78, (q31_t)0x7ce9fd8d, + (q31_t)0x7ce89e55, (q31_t)0x7ce73ed0, (q31_t)0x7ce5defd, (q31_t)0x7ce47ede, + (q31_t)0x7ce31e72, (q31_t)0x7ce1bdb8, (q31_t)0x7ce05cb2, (q31_t)0x7cdefb5e, + (q31_t)0x7cdd99be, (q31_t)0x7cdc37d0, (q31_t)0x7cdad596, (q31_t)0x7cd9730e, + (q31_t)0x7cd8103a, (q31_t)0x7cd6ad18, (q31_t)0x7cd549aa, (q31_t)0x7cd3e5ee, + (q31_t)0x7cd281e5, (q31_t)0x7cd11d90, (q31_t)0x7ccfb8ed, (q31_t)0x7cce53fe, + (q31_t)0x7ccceec1, (q31_t)0x7ccb8937, (q31_t)0x7cca2361, (q31_t)0x7cc8bd3d, + (q31_t)0x7cc756cd, (q31_t)0x7cc5f010, (q31_t)0x7cc48905, (q31_t)0x7cc321ae, + (q31_t)0x7cc1ba09, (q31_t)0x7cc05218, (q31_t)0x7cbee9da, (q31_t)0x7cbd814f, + (q31_t)0x7cbc1877, (q31_t)0x7cbaaf51, (q31_t)0x7cb945df, (q31_t)0x7cb7dc20, + (q31_t)0x7cb67215, (q31_t)0x7cb507bc, (q31_t)0x7cb39d16, (q31_t)0x7cb23223, + (q31_t)0x7cb0c6e4, (q31_t)0x7caf5b57, (q31_t)0x7cadef7e, (q31_t)0x7cac8358, + (q31_t)0x7cab16e4, (q31_t)0x7ca9aa24, (q31_t)0x7ca83d17, (q31_t)0x7ca6cfbd, + (q31_t)0x7ca56216, (q31_t)0x7ca3f423, (q31_t)0x7ca285e2, (q31_t)0x7ca11755, + (q31_t)0x7c9fa87a, (q31_t)0x7c9e3953, (q31_t)0x7c9cc9df, (q31_t)0x7c9b5a1e, + (q31_t)0x7c99ea10, (q31_t)0x7c9879b6, (q31_t)0x7c97090e, (q31_t)0x7c95981a, + (q31_t)0x7c9426d8, (q31_t)0x7c92b54a, (q31_t)0x7c91436f, (q31_t)0x7c8fd148, + (q31_t)0x7c8e5ed3, (q31_t)0x7c8cec12, (q31_t)0x7c8b7903, (q31_t)0x7c8a05a8, + (q31_t)0x7c889200, (q31_t)0x7c871e0c, (q31_t)0x7c85a9ca, (q31_t)0x7c84353c, + (q31_t)0x7c82c060, (q31_t)0x7c814b39, (q31_t)0x7c7fd5c4, (q31_t)0x7c7e6002, + (q31_t)0x7c7ce9f4, (q31_t)0x7c7b7399, (q31_t)0x7c79fcf1, (q31_t)0x7c7885fc, + (q31_t)0x7c770eba, (q31_t)0x7c75972c, (q31_t)0x7c741f51, (q31_t)0x7c72a729, + (q31_t)0x7c712eb5, (q31_t)0x7c6fb5f3, (q31_t)0x7c6e3ce5, (q31_t)0x7c6cc38a, + (q31_t)0x7c6b49e3, (q31_t)0x7c69cfee, (q31_t)0x7c6855ad, (q31_t)0x7c66db1f, + (q31_t)0x7c656045, (q31_t)0x7c63e51e, (q31_t)0x7c6269aa, (q31_t)0x7c60ede9, + (q31_t)0x7c5f71db, (q31_t)0x7c5df581, (q31_t)0x7c5c78da, (q31_t)0x7c5afbe6, + (q31_t)0x7c597ea6, (q31_t)0x7c580119, (q31_t)0x7c56833f, (q31_t)0x7c550519, + (q31_t)0x7c5386a6, (q31_t)0x7c5207e6, (q31_t)0x7c5088d9, (q31_t)0x7c4f0980, + (q31_t)0x7c4d89da, (q31_t)0x7c4c09e8, (q31_t)0x7c4a89a8, (q31_t)0x7c49091c, + (q31_t)0x7c478844, (q31_t)0x7c46071f, (q31_t)0x7c4485ad, (q31_t)0x7c4303ee, + (q31_t)0x7c4181e3, (q31_t)0x7c3fff8b, (q31_t)0x7c3e7ce7, (q31_t)0x7c3cf9f5, + (q31_t)0x7c3b76b8, (q31_t)0x7c39f32d, (q31_t)0x7c386f56, (q31_t)0x7c36eb33, + (q31_t)0x7c3566c2, (q31_t)0x7c33e205, (q31_t)0x7c325cfc, (q31_t)0x7c30d7a6, + (q31_t)0x7c2f5203, (q31_t)0x7c2dcc14, (q31_t)0x7c2c45d8, (q31_t)0x7c2abf4f, + (q31_t)0x7c29387a, (q31_t)0x7c27b158, (q31_t)0x7c2629ea, (q31_t)0x7c24a22f, + (q31_t)0x7c231a28, (q31_t)0x7c2191d4, (q31_t)0x7c200933, (q31_t)0x7c1e8046, + (q31_t)0x7c1cf70c, (q31_t)0x7c1b6d86, (q31_t)0x7c19e3b3, (q31_t)0x7c185994, + (q31_t)0x7c16cf28, (q31_t)0x7c15446f, (q31_t)0x7c13b96a, (q31_t)0x7c122e19, + (q31_t)0x7c10a27b, (q31_t)0x7c0f1690, (q31_t)0x7c0d8a59, (q31_t)0x7c0bfdd5, + (q31_t)0x7c0a7105, (q31_t)0x7c08e3e8, (q31_t)0x7c07567f, (q31_t)0x7c05c8c9, + (q31_t)0x7c043ac7, (q31_t)0x7c02ac78, (q31_t)0x7c011ddd, (q31_t)0x7bff8ef5, + (q31_t)0x7bfdffc1, (q31_t)0x7bfc7041, (q31_t)0x7bfae073, (q31_t)0x7bf9505a, + (q31_t)0x7bf7bff4, (q31_t)0x7bf62f41, (q31_t)0x7bf49e42, (q31_t)0x7bf30cf6, + (q31_t)0x7bf17b5e, (q31_t)0x7befe97a, (q31_t)0x7bee5749, (q31_t)0x7becc4cc, + (q31_t)0x7beb3202, (q31_t)0x7be99eec, (q31_t)0x7be80b89, (q31_t)0x7be677da, + (q31_t)0x7be4e3df, (q31_t)0x7be34f97, (q31_t)0x7be1bb02, (q31_t)0x7be02621, + (q31_t)0x7bde90f4, (q31_t)0x7bdcfb7b, (q31_t)0x7bdb65b5, (q31_t)0x7bd9cfa2, + (q31_t)0x7bd83944, (q31_t)0x7bd6a298, (q31_t)0x7bd50ba1, (q31_t)0x7bd3745d, + (q31_t)0x7bd1dccc, (q31_t)0x7bd044f0, (q31_t)0x7bceacc7, (q31_t)0x7bcd1451, + (q31_t)0x7bcb7b8f, (q31_t)0x7bc9e281, (q31_t)0x7bc84927, (q31_t)0x7bc6af80, + (q31_t)0x7bc5158c, (q31_t)0x7bc37b4d, (q31_t)0x7bc1e0c1, (q31_t)0x7bc045e9, + (q31_t)0x7bbeaac4, (q31_t)0x7bbd0f53, (q31_t)0x7bbb7396, (q31_t)0x7bb9d78c, + (q31_t)0x7bb83b36, (q31_t)0x7bb69e94, (q31_t)0x7bb501a5, (q31_t)0x7bb3646a, + (q31_t)0x7bb1c6e3, (q31_t)0x7bb02910, (q31_t)0x7bae8af0, (q31_t)0x7bacec84, + (q31_t)0x7bab4dcc, (q31_t)0x7ba9aec7, (q31_t)0x7ba80f76, (q31_t)0x7ba66fd9, + (q31_t)0x7ba4cfef, (q31_t)0x7ba32fba, (q31_t)0x7ba18f38, (q31_t)0x7b9fee69, + (q31_t)0x7b9e4d4f, (q31_t)0x7b9cabe8, (q31_t)0x7b9b0a35, (q31_t)0x7b996836, + (q31_t)0x7b97c5ea, (q31_t)0x7b962352, (q31_t)0x7b94806e, (q31_t)0x7b92dd3e, + (q31_t)0x7b9139c2, (q31_t)0x7b8f95f9, (q31_t)0x7b8df1e4, (q31_t)0x7b8c4d83, + (q31_t)0x7b8aa8d6, (q31_t)0x7b8903dc, (q31_t)0x7b875e96, (q31_t)0x7b85b904, + (q31_t)0x7b841326, (q31_t)0x7b826cfc, (q31_t)0x7b80c686, (q31_t)0x7b7f1fc3, + (q31_t)0x7b7d78b4, (q31_t)0x7b7bd159, (q31_t)0x7b7a29b2, (q31_t)0x7b7881be, + (q31_t)0x7b76d97f, (q31_t)0x7b7530f3, (q31_t)0x7b73881b, (q31_t)0x7b71def7, + (q31_t)0x7b703587, (q31_t)0x7b6e8bcb, (q31_t)0x7b6ce1c2, (q31_t)0x7b6b376e, + (q31_t)0x7b698ccd, (q31_t)0x7b67e1e0, (q31_t)0x7b6636a7, (q31_t)0x7b648b22, + (q31_t)0x7b62df51, (q31_t)0x7b613334, (q31_t)0x7b5f86ca, (q31_t)0x7b5dda15, + (q31_t)0x7b5c2d13, (q31_t)0x7b5a7fc6, (q31_t)0x7b58d22c, (q31_t)0x7b572446, + (q31_t)0x7b557614, (q31_t)0x7b53c796, (q31_t)0x7b5218cc, (q31_t)0x7b5069b6, + (q31_t)0x7b4eba53, (q31_t)0x7b4d0aa5, (q31_t)0x7b4b5aab, (q31_t)0x7b49aa64, + (q31_t)0x7b47f9d2, (q31_t)0x7b4648f3, (q31_t)0x7b4497c9, (q31_t)0x7b42e652, + (q31_t)0x7b413490, (q31_t)0x7b3f8281, (q31_t)0x7b3dd026, (q31_t)0x7b3c1d80, + (q31_t)0x7b3a6a8d, (q31_t)0x7b38b74e, (q31_t)0x7b3703c3, (q31_t)0x7b354fed, + (q31_t)0x7b339bca, (q31_t)0x7b31e75b, (q31_t)0x7b3032a0, (q31_t)0x7b2e7d9a, + (q31_t)0x7b2cc847, (q31_t)0x7b2b12a8, (q31_t)0x7b295cbe, (q31_t)0x7b27a687, + (q31_t)0x7b25f004, (q31_t)0x7b243936, (q31_t)0x7b22821b, (q31_t)0x7b20cab5, + (q31_t)0x7b1f1302, (q31_t)0x7b1d5b04, (q31_t)0x7b1ba2b9, (q31_t)0x7b19ea23, + (q31_t)0x7b183141, (q31_t)0x7b167813, (q31_t)0x7b14be99, (q31_t)0x7b1304d3, + (q31_t)0x7b114ac1, (q31_t)0x7b0f9063, (q31_t)0x7b0dd5b9, (q31_t)0x7b0c1ac4, + (q31_t)0x7b0a5f82, (q31_t)0x7b08a3f5, (q31_t)0x7b06e81b, (q31_t)0x7b052bf6, + (q31_t)0x7b036f85, (q31_t)0x7b01b2c8, (q31_t)0x7afff5bf, (q31_t)0x7afe386a, + (q31_t)0x7afc7aca, (q31_t)0x7afabcdd, (q31_t)0x7af8fea5, (q31_t)0x7af74021, + (q31_t)0x7af58151, (q31_t)0x7af3c235, (q31_t)0x7af202cd, (q31_t)0x7af0431a, + (q31_t)0x7aee831a, (q31_t)0x7aecc2cf, (q31_t)0x7aeb0238, (q31_t)0x7ae94155, + (q31_t)0x7ae78026, (q31_t)0x7ae5beac, (q31_t)0x7ae3fce6, (q31_t)0x7ae23ad4, + (q31_t)0x7ae07876, (q31_t)0x7adeb5cc, (q31_t)0x7adcf2d6, (q31_t)0x7adb2f95, + (q31_t)0x7ad96c08, (q31_t)0x7ad7a82f, (q31_t)0x7ad5e40a, (q31_t)0x7ad41f9a, + (q31_t)0x7ad25ade, (q31_t)0x7ad095d6, (q31_t)0x7aced082, (q31_t)0x7acd0ae3, + (q31_t)0x7acb44f8, (q31_t)0x7ac97ec1, (q31_t)0x7ac7b83e, (q31_t)0x7ac5f170, + (q31_t)0x7ac42a55, (q31_t)0x7ac262ef, (q31_t)0x7ac09b3e, (q31_t)0x7abed341, + (q31_t)0x7abd0af7, (q31_t)0x7abb4263, (q31_t)0x7ab97982, (q31_t)0x7ab7b056, + (q31_t)0x7ab5e6de, (q31_t)0x7ab41d1b, (q31_t)0x7ab2530b, (q31_t)0x7ab088b0, + (q31_t)0x7aaebe0a, (q31_t)0x7aacf318, (q31_t)0x7aab27da, (q31_t)0x7aa95c50, + (q31_t)0x7aa7907b, (q31_t)0x7aa5c45a, (q31_t)0x7aa3f7ed, (q31_t)0x7aa22b35, + (q31_t)0x7aa05e31, (q31_t)0x7a9e90e1, (q31_t)0x7a9cc346, (q31_t)0x7a9af55f, + (q31_t)0x7a99272d, (q31_t)0x7a9758af, (q31_t)0x7a9589e5, (q31_t)0x7a93bad0, + (q31_t)0x7a91eb6f, (q31_t)0x7a901bc2, (q31_t)0x7a8e4bca, (q31_t)0x7a8c7b87, + (q31_t)0x7a8aaaf7, (q31_t)0x7a88da1c, (q31_t)0x7a8708f6, (q31_t)0x7a853784, + (q31_t)0x7a8365c6, (q31_t)0x7a8193bd, (q31_t)0x7a7fc168, (q31_t)0x7a7deec8, + (q31_t)0x7a7c1bdc, (q31_t)0x7a7a48a4, (q31_t)0x7a787521, (q31_t)0x7a76a153, + (q31_t)0x7a74cd38, (q31_t)0x7a72f8d3, (q31_t)0x7a712422, (q31_t)0x7a6f4f25, + (q31_t)0x7a6d79dd, (q31_t)0x7a6ba449, (q31_t)0x7a69ce6a, (q31_t)0x7a67f83f, + (q31_t)0x7a6621c9, (q31_t)0x7a644b07, (q31_t)0x7a6273fa, (q31_t)0x7a609ca1, + (q31_t)0x7a5ec4fc, (q31_t)0x7a5ced0d, (q31_t)0x7a5b14d1, (q31_t)0x7a593c4b, + (q31_t)0x7a576379, (q31_t)0x7a558a5b, (q31_t)0x7a53b0f2, (q31_t)0x7a51d73d, + (q31_t)0x7a4ffd3d, (q31_t)0x7a4e22f2, (q31_t)0x7a4c485b, (q31_t)0x7a4a6d78, + (q31_t)0x7a48924b, (q31_t)0x7a46b6d1, (q31_t)0x7a44db0d, (q31_t)0x7a42fefd, + (q31_t)0x7a4122a1, (q31_t)0x7a3f45fa, (q31_t)0x7a3d6908, (q31_t)0x7a3b8bca, + (q31_t)0x7a39ae41, (q31_t)0x7a37d06d, (q31_t)0x7a35f24d, (q31_t)0x7a3413e2, + (q31_t)0x7a32352b, (q31_t)0x7a305629, (q31_t)0x7a2e76dc, (q31_t)0x7a2c9743, + (q31_t)0x7a2ab75f, (q31_t)0x7a28d72f, (q31_t)0x7a26f6b4, (q31_t)0x7a2515ee, + (q31_t)0x7a2334dd, (q31_t)0x7a215380, (q31_t)0x7a1f71d7, (q31_t)0x7a1d8fe4, + (q31_t)0x7a1bada5, (q31_t)0x7a19cb1b, (q31_t)0x7a17e845, (q31_t)0x7a160524, + (q31_t)0x7a1421b8, (q31_t)0x7a123e01, (q31_t)0x7a1059fe, (q31_t)0x7a0e75b0, + (q31_t)0x7a0c9117, (q31_t)0x7a0aac32, (q31_t)0x7a08c702, (q31_t)0x7a06e187, + (q31_t)0x7a04fbc1, (q31_t)0x7a0315af, (q31_t)0x7a012f52, (q31_t)0x79ff48aa, + (q31_t)0x79fd61b6, (q31_t)0x79fb7a77, (q31_t)0x79f992ed, (q31_t)0x79f7ab18, + (q31_t)0x79f5c2f8, (q31_t)0x79f3da8c, (q31_t)0x79f1f1d5, (q31_t)0x79f008d3, + (q31_t)0x79ee1f86, (q31_t)0x79ec35ed, (q31_t)0x79ea4c09, (q31_t)0x79e861da, + (q31_t)0x79e67760, (q31_t)0x79e48c9b, (q31_t)0x79e2a18a, (q31_t)0x79e0b62e, + (q31_t)0x79deca87, (q31_t)0x79dcde95, (q31_t)0x79daf258, (q31_t)0x79d905d0, + (q31_t)0x79d718fc, (q31_t)0x79d52bdd, (q31_t)0x79d33e73, (q31_t)0x79d150be, + (q31_t)0x79cf62be, (q31_t)0x79cd7473, (q31_t)0x79cb85dc, (q31_t)0x79c996fb, + (q31_t)0x79c7a7ce, (q31_t)0x79c5b856, (q31_t)0x79c3c893, (q31_t)0x79c1d885, + (q31_t)0x79bfe82c, (q31_t)0x79bdf788, (q31_t)0x79bc0698, (q31_t)0x79ba155e, + (q31_t)0x79b823d8, (q31_t)0x79b63207, (q31_t)0x79b43fec, (q31_t)0x79b24d85, + (q31_t)0x79b05ad3, (q31_t)0x79ae67d6, (q31_t)0x79ac748e, (q31_t)0x79aa80fb, + (q31_t)0x79a88d1d, (q31_t)0x79a698f4, (q31_t)0x79a4a480, (q31_t)0x79a2afc1, + (q31_t)0x79a0bab6, (q31_t)0x799ec561, (q31_t)0x799ccfc1, (q31_t)0x799ad9d5, + (q31_t)0x7998e39f, (q31_t)0x7996ed1e, (q31_t)0x7994f651, (q31_t)0x7992ff3a, + (q31_t)0x799107d8, (q31_t)0x798f102a, (q31_t)0x798d1832, (q31_t)0x798b1fef, + (q31_t)0x79892761, (q31_t)0x79872e87, (q31_t)0x79853563, (q31_t)0x79833bf4, + (q31_t)0x7981423a, (q31_t)0x797f4835, (q31_t)0x797d4de5, (q31_t)0x797b534a, + (q31_t)0x79795864, (q31_t)0x79775d33, (q31_t)0x797561b8, (q31_t)0x797365f1, + (q31_t)0x797169df, (q31_t)0x796f6d83, (q31_t)0x796d70dc, (q31_t)0x796b73e9, + (q31_t)0x796976ac, (q31_t)0x79677924, (q31_t)0x79657b51, (q31_t)0x79637d33, + (q31_t)0x79617eca, (q31_t)0x795f8017, (q31_t)0x795d8118, (q31_t)0x795b81cf, + (q31_t)0x7959823b, (q31_t)0x7957825c, (q31_t)0x79558232, (q31_t)0x795381bd, + (q31_t)0x795180fe, (q31_t)0x794f7ff3, (q31_t)0x794d7e9e, (q31_t)0x794b7cfe, + (q31_t)0x79497b13, (q31_t)0x794778dd, (q31_t)0x7945765d, (q31_t)0x79437391, + (q31_t)0x7941707b, (q31_t)0x793f6d1a, (q31_t)0x793d696f, (q31_t)0x793b6578, + (q31_t)0x79396137, (q31_t)0x79375cab, (q31_t)0x793557d4, (q31_t)0x793352b2, + (q31_t)0x79314d46, (q31_t)0x792f478f, (q31_t)0x792d418d, (q31_t)0x792b3b40, + (q31_t)0x792934a9, (q31_t)0x79272dc7, (q31_t)0x7925269a, (q31_t)0x79231f22, + (q31_t)0x79211760, (q31_t)0x791f0f53, (q31_t)0x791d06fb, (q31_t)0x791afe59, + (q31_t)0x7918f56c, (q31_t)0x7916ec34, (q31_t)0x7914e2b2, (q31_t)0x7912d8e4, + (q31_t)0x7910cecc, (q31_t)0x790ec46a, (q31_t)0x790cb9bd, (q31_t)0x790aaec5, + (q31_t)0x7908a382, (q31_t)0x790697f5, (q31_t)0x79048c1d, (q31_t)0x79027ffa, + (q31_t)0x7900738d, (q31_t)0x78fe66d5, (q31_t)0x78fc59d3, (q31_t)0x78fa4c86, + (q31_t)0x78f83eee, (q31_t)0x78f6310c, (q31_t)0x78f422df, (q31_t)0x78f21467, + (q31_t)0x78f005a5, (q31_t)0x78edf698, (q31_t)0x78ebe741, (q31_t)0x78e9d79f, + (q31_t)0x78e7c7b2, (q31_t)0x78e5b77b, (q31_t)0x78e3a6f9, (q31_t)0x78e1962d, + (q31_t)0x78df8516, (q31_t)0x78dd73b5, (q31_t)0x78db6209, (q31_t)0x78d95012, + (q31_t)0x78d73dd1, (q31_t)0x78d52b46, (q31_t)0x78d31870, (q31_t)0x78d1054f, + (q31_t)0x78cef1e4, (q31_t)0x78ccde2e, (q31_t)0x78caca2e, (q31_t)0x78c8b5e3, + (q31_t)0x78c6a14e, (q31_t)0x78c48c6e, (q31_t)0x78c27744, (q31_t)0x78c061cf, + (q31_t)0x78be4c10, (q31_t)0x78bc3606, (q31_t)0x78ba1fb2, (q31_t)0x78b80913, + (q31_t)0x78b5f22a, (q31_t)0x78b3daf7, (q31_t)0x78b1c379, (q31_t)0x78afabb0, + (q31_t)0x78ad939d, (q31_t)0x78ab7b40, (q31_t)0x78a96298, (q31_t)0x78a749a6, + (q31_t)0x78a53069, (q31_t)0x78a316e2, (q31_t)0x78a0fd11, (q31_t)0x789ee2f5, + (q31_t)0x789cc88f, (q31_t)0x789aadde, (q31_t)0x789892e3, (q31_t)0x7896779d, + (q31_t)0x78945c0d, (q31_t)0x78924033, (q31_t)0x7890240e, (q31_t)0x788e07a0, + (q31_t)0x788beae6, (q31_t)0x7889cde2, (q31_t)0x7887b094, (q31_t)0x788592fc, + (q31_t)0x78837519, (q31_t)0x788156ec, (q31_t)0x787f3875, (q31_t)0x787d19b3, + (q31_t)0x787afaa7, (q31_t)0x7878db50, (q31_t)0x7876bbb0, (q31_t)0x78749bc5, + (q31_t)0x78727b8f, (q31_t)0x78705b10, (q31_t)0x786e3a46, (q31_t)0x786c1932, + (q31_t)0x7869f7d3, (q31_t)0x7867d62a, (q31_t)0x7865b437, (q31_t)0x786391fa, + (q31_t)0x78616f72, (q31_t)0x785f4ca1, (q31_t)0x785d2984, (q31_t)0x785b061e, + (q31_t)0x7858e26e, (q31_t)0x7856be73, (q31_t)0x78549a2e, (q31_t)0x7852759e, + (q31_t)0x785050c5, (q31_t)0x784e2ba1, (q31_t)0x784c0633, (q31_t)0x7849e07b, + (q31_t)0x7847ba79, (q31_t)0x7845942c, (q31_t)0x78436d96, (q31_t)0x784146b5, + (q31_t)0x783f1f8a, (q31_t)0x783cf815, (q31_t)0x783ad055, (q31_t)0x7838a84c, + (q31_t)0x78367ff8, (q31_t)0x7834575a, (q31_t)0x78322e72, (q31_t)0x78300540, + (q31_t)0x782ddbc4, (q31_t)0x782bb1fd, (q31_t)0x782987ed, (q31_t)0x78275d92, + (q31_t)0x782532ed, (q31_t)0x782307fe, (q31_t)0x7820dcc5, (q31_t)0x781eb142, + (q31_t)0x781c8575, (q31_t)0x781a595d, (q31_t)0x78182cfc, (q31_t)0x78160051, + (q31_t)0x7813d35b, (q31_t)0x7811a61b, (q31_t)0x780f7892, (q31_t)0x780d4abe, + (q31_t)0x780b1ca0, (q31_t)0x7808ee38, (q31_t)0x7806bf86, (q31_t)0x7804908a, + (q31_t)0x78026145, (q31_t)0x780031b5, (q31_t)0x77fe01db, (q31_t)0x77fbd1b6, + (q31_t)0x77f9a148, (q31_t)0x77f77090, (q31_t)0x77f53f8e, (q31_t)0x77f30e42, + (q31_t)0x77f0dcac, (q31_t)0x77eeaacc, (q31_t)0x77ec78a2, (q31_t)0x77ea462e, + (q31_t)0x77e81370, (q31_t)0x77e5e068, (q31_t)0x77e3ad17, (q31_t)0x77e1797b, + (q31_t)0x77df4595, (q31_t)0x77dd1165, (q31_t)0x77dadcec, (q31_t)0x77d8a828, + (q31_t)0x77d6731a, (q31_t)0x77d43dc3, (q31_t)0x77d20822, (q31_t)0x77cfd236, + (q31_t)0x77cd9c01, (q31_t)0x77cb6582, (q31_t)0x77c92eb9, (q31_t)0x77c6f7a6, + (q31_t)0x77c4c04a, (q31_t)0x77c288a3, (q31_t)0x77c050b2, (q31_t)0x77be1878, + (q31_t)0x77bbdff4, (q31_t)0x77b9a726, (q31_t)0x77b76e0e, (q31_t)0x77b534ac, + (q31_t)0x77b2fb00, (q31_t)0x77b0c10b, (q31_t)0x77ae86cc, (q31_t)0x77ac4c43, + (q31_t)0x77aa1170, (q31_t)0x77a7d653, (q31_t)0x77a59aec, (q31_t)0x77a35f3c, + (q31_t)0x77a12342, (q31_t)0x779ee6fe, (q31_t)0x779caa70, (q31_t)0x779a6d99, + (q31_t)0x77983077, (q31_t)0x7795f30c, (q31_t)0x7793b557, (q31_t)0x77917759, + (q31_t)0x778f3910, (q31_t)0x778cfa7e, (q31_t)0x778abba2, (q31_t)0x77887c7d, + (q31_t)0x77863d0d, (q31_t)0x7783fd54, (q31_t)0x7781bd52, (q31_t)0x777f7d05, + (q31_t)0x777d3c6f, (q31_t)0x777afb8f, (q31_t)0x7778ba65, (q31_t)0x777678f2, + (q31_t)0x77743735, (q31_t)0x7771f52e, (q31_t)0x776fb2de, (q31_t)0x776d7044, + (q31_t)0x776b2d60, (q31_t)0x7768ea33, (q31_t)0x7766a6bc, (q31_t)0x776462fb, + (q31_t)0x77621ef1, (q31_t)0x775fda9d, (q31_t)0x775d95ff, (q31_t)0x775b5118, + (q31_t)0x77590be7, (q31_t)0x7756c66c, (q31_t)0x775480a8, (q31_t)0x77523a9b, + (q31_t)0x774ff443, (q31_t)0x774dada2, (q31_t)0x774b66b8, (q31_t)0x77491f84, + (q31_t)0x7746d806, (q31_t)0x7744903f, (q31_t)0x7742482e, (q31_t)0x773fffd4, + (q31_t)0x773db730, (q31_t)0x773b6e42, (q31_t)0x7739250b, (q31_t)0x7736db8b, + (q31_t)0x773491c0, (q31_t)0x773247ad, (q31_t)0x772ffd50, (q31_t)0x772db2a9, + (q31_t)0x772b67b9, (q31_t)0x77291c7f, (q31_t)0x7726d0fc, (q31_t)0x7724852f, + (q31_t)0x77223919, (q31_t)0x771fecb9, (q31_t)0x771da010, (q31_t)0x771b531d, + (q31_t)0x771905e1, (q31_t)0x7716b85b, (q31_t)0x77146a8c, (q31_t)0x77121c74, + (q31_t)0x770fce12, (q31_t)0x770d7f66, (q31_t)0x770b3072, (q31_t)0x7708e133, + (q31_t)0x770691ab, (q31_t)0x770441da, (q31_t)0x7701f1c0, (q31_t)0x76ffa15c, + (q31_t)0x76fd50ae, (q31_t)0x76faffb8, (q31_t)0x76f8ae78, (q31_t)0x76f65cee, + (q31_t)0x76f40b1b, (q31_t)0x76f1b8ff, (q31_t)0x76ef6699, (q31_t)0x76ed13ea, + (q31_t)0x76eac0f2, (q31_t)0x76e86db0, (q31_t)0x76e61a25, (q31_t)0x76e3c650, + (q31_t)0x76e17233, (q31_t)0x76df1dcb, (q31_t)0x76dcc91b, (q31_t)0x76da7421, + (q31_t)0x76d81ede, (q31_t)0x76d5c952, (q31_t)0x76d3737c, (q31_t)0x76d11d5d, + (q31_t)0x76cec6f5, (q31_t)0x76cc7043, (q31_t)0x76ca1948, (q31_t)0x76c7c204, + (q31_t)0x76c56a77, (q31_t)0x76c312a0, (q31_t)0x76c0ba80, (q31_t)0x76be6217, + (q31_t)0x76bc0965, (q31_t)0x76b9b069, (q31_t)0x76b75724, (q31_t)0x76b4fd96, + (q31_t)0x76b2a3bf, (q31_t)0x76b0499e, (q31_t)0x76adef34, (q31_t)0x76ab9481, + (q31_t)0x76a93985, (q31_t)0x76a6de40, (q31_t)0x76a482b1, (q31_t)0x76a226da, + (q31_t)0x769fcab9, (q31_t)0x769d6e4f, (q31_t)0x769b119b, (q31_t)0x7698b49f, + (q31_t)0x76965759, (q31_t)0x7693f9ca, (q31_t)0x76919bf3, (q31_t)0x768f3dd2, + (q31_t)0x768cdf67, (q31_t)0x768a80b4, (q31_t)0x768821b8, (q31_t)0x7685c272, + (q31_t)0x768362e4, (q31_t)0x7681030c, (q31_t)0x767ea2eb, (q31_t)0x767c4281, + (q31_t)0x7679e1ce, (q31_t)0x767780d2, (q31_t)0x76751f8d, (q31_t)0x7672bdfe, + (q31_t)0x76705c27, (q31_t)0x766dfa07, (q31_t)0x766b979d, (q31_t)0x766934eb, + (q31_t)0x7666d1ef, (q31_t)0x76646eab, (q31_t)0x76620b1d, (q31_t)0x765fa747, + (q31_t)0x765d4327, (q31_t)0x765adebe, (q31_t)0x76587a0d, (q31_t)0x76561512, + (q31_t)0x7653afce, (q31_t)0x76514a42, (q31_t)0x764ee46c, (q31_t)0x764c7e4d, + (q31_t)0x764a17e6, (q31_t)0x7647b135, (q31_t)0x76454a3c, (q31_t)0x7642e2f9, + (q31_t)0x76407b6e, (q31_t)0x763e139a, (q31_t)0x763bab7c, (q31_t)0x76394316, + (q31_t)0x7636da67, (q31_t)0x7634716f, (q31_t)0x7632082e, (q31_t)0x762f9ea4, + (q31_t)0x762d34d1, (q31_t)0x762acab6, (q31_t)0x76286051, (q31_t)0x7625f5a3, + (q31_t)0x76238aad, (q31_t)0x76211f6e, (q31_t)0x761eb3e6, (q31_t)0x761c4815, + (q31_t)0x7619dbfb, (q31_t)0x76176f98, (q31_t)0x761502ed, (q31_t)0x761295f9, + (q31_t)0x761028bb, (q31_t)0x760dbb35, (q31_t)0x760b4d67, (q31_t)0x7608df4f, + (q31_t)0x760670ee, (q31_t)0x76040245, (q31_t)0x76019353, (q31_t)0x75ff2418, + (q31_t)0x75fcb495, (q31_t)0x75fa44c8, (q31_t)0x75f7d4b3, (q31_t)0x75f56455, + (q31_t)0x75f2f3ae, (q31_t)0x75f082bf, (q31_t)0x75ee1187, (q31_t)0x75eba006, + (q31_t)0x75e92e3c, (q31_t)0x75e6bc2a, (q31_t)0x75e449ce, (q31_t)0x75e1d72b, + (q31_t)0x75df643e, (q31_t)0x75dcf109, (q31_t)0x75da7d8b, (q31_t)0x75d809c4, + (q31_t)0x75d595b4, (q31_t)0x75d3215c, (q31_t)0x75d0acbc, (q31_t)0x75ce37d2, + (q31_t)0x75cbc2a0, (q31_t)0x75c94d25, (q31_t)0x75c6d762, (q31_t)0x75c46156, + (q31_t)0x75c1eb01, (q31_t)0x75bf7464, (q31_t)0x75bcfd7e, (q31_t)0x75ba864f, + (q31_t)0x75b80ed8, (q31_t)0x75b59718, (q31_t)0x75b31f0f, (q31_t)0x75b0a6be, + (q31_t)0x75ae2e25, (q31_t)0x75abb542, (q31_t)0x75a93c18, (q31_t)0x75a6c2a4, + (q31_t)0x75a448e8, (q31_t)0x75a1cee4, (q31_t)0x759f5496, (q31_t)0x759cda01, + (q31_t)0x759a5f22, (q31_t)0x7597e3fc, (q31_t)0x7595688c, (q31_t)0x7592ecd4, + (q31_t)0x759070d4, (q31_t)0x758df48b, (q31_t)0x758b77fa, (q31_t)0x7588fb20, + (q31_t)0x75867dfd, (q31_t)0x75840093, (q31_t)0x758182df, (q31_t)0x757f04e3, + (q31_t)0x757c869f, (q31_t)0x757a0812, (q31_t)0x7577893d, (q31_t)0x75750a1f, + (q31_t)0x75728ab9, (q31_t)0x75700b0a, (q31_t)0x756d8b13, (q31_t)0x756b0ad3, + (q31_t)0x75688a4b, (q31_t)0x7566097b, (q31_t)0x75638862, (q31_t)0x75610701, + (q31_t)0x755e8557, (q31_t)0x755c0365, (q31_t)0x7559812b, (q31_t)0x7556fea8, + (q31_t)0x75547bdd, (q31_t)0x7551f8c9, (q31_t)0x754f756e, (q31_t)0x754cf1c9, + (q31_t)0x754a6ddd, (q31_t)0x7547e9a8, (q31_t)0x7545652a, (q31_t)0x7542e065, + (q31_t)0x75405b57, (q31_t)0x753dd600, (q31_t)0x753b5061, (q31_t)0x7538ca7b, + (q31_t)0x7536444b, (q31_t)0x7533bdd4, (q31_t)0x75313714, (q31_t)0x752eb00c, + (q31_t)0x752c28bb, (q31_t)0x7529a122, (q31_t)0x75271941, (q31_t)0x75249118, + (q31_t)0x752208a7, (q31_t)0x751f7fed, (q31_t)0x751cf6eb, (q31_t)0x751a6da0, + (q31_t)0x7517e40e, (q31_t)0x75155a33, (q31_t)0x7512d010, (q31_t)0x751045a5, + (q31_t)0x750dbaf2, (q31_t)0x750b2ff6, (q31_t)0x7508a4b2, (q31_t)0x75061926, + (q31_t)0x75038d52, (q31_t)0x75010136, (q31_t)0x74fe74d1, (q31_t)0x74fbe825, + (q31_t)0x74f95b30, (q31_t)0x74f6cdf3, (q31_t)0x74f4406d, (q31_t)0x74f1b2a0, + (q31_t)0x74ef248b, (q31_t)0x74ec962d, (q31_t)0x74ea0787, (q31_t)0x74e7789a, + (q31_t)0x74e4e964, (q31_t)0x74e259e6, (q31_t)0x74dfca20, (q31_t)0x74dd3a11, + (q31_t)0x74daa9bb, (q31_t)0x74d8191d, (q31_t)0x74d58836, (q31_t)0x74d2f708, + (q31_t)0x74d06591, (q31_t)0x74cdd3d2, (q31_t)0x74cb41cc, (q31_t)0x74c8af7d, + (q31_t)0x74c61ce6, (q31_t)0x74c38a07, (q31_t)0x74c0f6e0, (q31_t)0x74be6372, + (q31_t)0x74bbcfbb, (q31_t)0x74b93bbc, (q31_t)0x74b6a775, (q31_t)0x74b412e6, + (q31_t)0x74b17e0f, (q31_t)0x74aee8f0, (q31_t)0x74ac5389, (q31_t)0x74a9bddb, + (q31_t)0x74a727e4, (q31_t)0x74a491a5, (q31_t)0x74a1fb1e, (q31_t)0x749f6450, + (q31_t)0x749ccd39, (q31_t)0x749a35db, (q31_t)0x74979e34, (q31_t)0x74950646, + (q31_t)0x74926e10, (q31_t)0x748fd592, (q31_t)0x748d3ccb, (q31_t)0x748aa3be, + (q31_t)0x74880a68, (q31_t)0x748570ca, (q31_t)0x7482d6e4, (q31_t)0x74803cb7, + (q31_t)0x747da242, (q31_t)0x747b0784, (q31_t)0x74786c7f, (q31_t)0x7475d132, + (q31_t)0x7473359e, (q31_t)0x747099c1, (q31_t)0x746dfd9d, (q31_t)0x746b6131, + (q31_t)0x7468c47c, (q31_t)0x74662781, (q31_t)0x74638a3d, (q31_t)0x7460ecb2, + (q31_t)0x745e4ede, (q31_t)0x745bb0c3, (q31_t)0x74591261, (q31_t)0x745673b6, + (q31_t)0x7453d4c4, (q31_t)0x7451358a, (q31_t)0x744e9608, (q31_t)0x744bf63e, + (q31_t)0x7449562d, (q31_t)0x7446b5d4, (q31_t)0x74441533, (q31_t)0x7441744b, + (q31_t)0x743ed31b, (q31_t)0x743c31a3, (q31_t)0x74398fe3, (q31_t)0x7436eddc, + (q31_t)0x74344b8d, (q31_t)0x7431a8f6, (q31_t)0x742f0618, (q31_t)0x742c62f2, + (q31_t)0x7429bf84, (q31_t)0x74271bcf, (q31_t)0x742477d2, (q31_t)0x7421d38e, + (q31_t)0x741f2f01, (q31_t)0x741c8a2d, (q31_t)0x7419e512, (q31_t)0x74173faf, + (q31_t)0x74149a04, (q31_t)0x7411f412, (q31_t)0x740f4dd8, (q31_t)0x740ca756, + (q31_t)0x740a008d, (q31_t)0x7407597d, (q31_t)0x7404b224, (q31_t)0x74020a85, + (q31_t)0x73ff629d, (q31_t)0x73fcba6e, (q31_t)0x73fa11f8, (q31_t)0x73f7693a, + (q31_t)0x73f4c034, (q31_t)0x73f216e7, (q31_t)0x73ef6d53, (q31_t)0x73ecc377, + (q31_t)0x73ea1953, (q31_t)0x73e76ee8, (q31_t)0x73e4c435, (q31_t)0x73e2193b, + (q31_t)0x73df6df9, (q31_t)0x73dcc270, (q31_t)0x73da16a0, (q31_t)0x73d76a88, + (q31_t)0x73d4be28, (q31_t)0x73d21182, (q31_t)0x73cf6493, (q31_t)0x73ccb75d, + (q31_t)0x73ca09e0, (q31_t)0x73c75c1c, (q31_t)0x73c4ae10, (q31_t)0x73c1ffbc, + (q31_t)0x73bf5121, (q31_t)0x73bca23f, (q31_t)0x73b9f315, (q31_t)0x73b743a4, + (q31_t)0x73b493ec, (q31_t)0x73b1e3ec, (q31_t)0x73af33a5, (q31_t)0x73ac8316, + (q31_t)0x73a9d240, (q31_t)0x73a72123, (q31_t)0x73a46fbf, (q31_t)0x73a1be13, + (q31_t)0x739f0c20, (q31_t)0x739c59e5, (q31_t)0x7399a763, (q31_t)0x7396f49a, + (q31_t)0x73944189, (q31_t)0x73918e32, (q31_t)0x738eda93, (q31_t)0x738c26ac, + (q31_t)0x7389727f, (q31_t)0x7386be0a, (q31_t)0x7384094e, (q31_t)0x7381544a, + (q31_t)0x737e9f00, (q31_t)0x737be96e, (q31_t)0x73793395, (q31_t)0x73767d74, + (q31_t)0x7373c70d, (q31_t)0x7371105e, (q31_t)0x736e5968, (q31_t)0x736ba22b, + (q31_t)0x7368eaa6, (q31_t)0x736632db, (q31_t)0x73637ac8, (q31_t)0x7360c26e, + (q31_t)0x735e09cd, (q31_t)0x735b50e4, (q31_t)0x735897b5, (q31_t)0x7355de3e, + (q31_t)0x73532481, (q31_t)0x73506a7c, (q31_t)0x734db030, (q31_t)0x734af59d, + (q31_t)0x73483ac2, (q31_t)0x73457fa1, (q31_t)0x7342c438, (q31_t)0x73400889, + (q31_t)0x733d4c92, (q31_t)0x733a9054, (q31_t)0x7337d3d0, (q31_t)0x73351704, + (q31_t)0x733259f1, (q31_t)0x732f9c97, (q31_t)0x732cdef6, (q31_t)0x732a210d, + (q31_t)0x732762de, (q31_t)0x7324a468, (q31_t)0x7321e5ab, (q31_t)0x731f26a7, + (q31_t)0x731c675b, (q31_t)0x7319a7c9, (q31_t)0x7316e7f0, (q31_t)0x731427cf, + (q31_t)0x73116768, (q31_t)0x730ea6ba, (q31_t)0x730be5c5, (q31_t)0x73092489, + (q31_t)0x73066306, (q31_t)0x7303a13b, (q31_t)0x7300df2a, (q31_t)0x72fe1cd2, + (q31_t)0x72fb5a34, (q31_t)0x72f8974e, (q31_t)0x72f5d421, (q31_t)0x72f310ad, + (q31_t)0x72f04cf3, (q31_t)0x72ed88f1, (q31_t)0x72eac4a9, (q31_t)0x72e8001a, + (q31_t)0x72e53b44, (q31_t)0x72e27627, (q31_t)0x72dfb0c3, (q31_t)0x72dceb18, + (q31_t)0x72da2526, (q31_t)0x72d75eee, (q31_t)0x72d4986f, (q31_t)0x72d1d1a9, + (q31_t)0x72cf0a9c, (q31_t)0x72cc4348, (q31_t)0x72c97bad, (q31_t)0x72c6b3cc, + (q31_t)0x72c3eba4, (q31_t)0x72c12335, (q31_t)0x72be5a7f, (q31_t)0x72bb9183, + (q31_t)0x72b8c83f, (q31_t)0x72b5feb5, (q31_t)0x72b334e4, (q31_t)0x72b06acd, + (q31_t)0x72ada06f, (q31_t)0x72aad5c9, (q31_t)0x72a80ade, (q31_t)0x72a53fab, + (q31_t)0x72a27432, (q31_t)0x729fa872, (q31_t)0x729cdc6b, (q31_t)0x729a101e, + (q31_t)0x7297438a, (q31_t)0x729476af, (q31_t)0x7291a98e, (q31_t)0x728edc26, + (q31_t)0x728c0e77, (q31_t)0x72894082, (q31_t)0x72867245, (q31_t)0x7283a3c3, + (q31_t)0x7280d4f9, (q31_t)0x727e05e9, (q31_t)0x727b3693, (q31_t)0x727866f6, + (q31_t)0x72759712, (q31_t)0x7272c6e7, (q31_t)0x726ff676, (q31_t)0x726d25bf, + (q31_t)0x726a54c1, (q31_t)0x7267837c, (q31_t)0x7264b1f0, (q31_t)0x7261e01e, + (q31_t)0x725f0e06, (q31_t)0x725c3ba7, (q31_t)0x72596901, (q31_t)0x72569615, + (q31_t)0x7253c2e3, (q31_t)0x7250ef6a, (q31_t)0x724e1baa, (q31_t)0x724b47a4, + (q31_t)0x72487357, (q31_t)0x72459ec4, (q31_t)0x7242c9ea, (q31_t)0x723ff4ca, + (q31_t)0x723d1f63, (q31_t)0x723a49b6, (q31_t)0x723773c3, (q31_t)0x72349d89, + (q31_t)0x7231c708, (q31_t)0x722ef041, (q31_t)0x722c1934, (q31_t)0x722941e0, + (q31_t)0x72266a46, (q31_t)0x72239266, (q31_t)0x7220ba3f, (q31_t)0x721de1d1, + (q31_t)0x721b091d, (q31_t)0x72183023, (q31_t)0x721556e3, (q31_t)0x72127d5c, + (q31_t)0x720fa38e, (q31_t)0x720cc97b, (q31_t)0x7209ef21, (q31_t)0x72071480, + (q31_t)0x7204399a, (q31_t)0x72015e6d, (q31_t)0x71fe82f9, (q31_t)0x71fba740, + (q31_t)0x71f8cb40, (q31_t)0x71f5eefa, (q31_t)0x71f3126d, (q31_t)0x71f0359a, + (q31_t)0x71ed5881, (q31_t)0x71ea7b22, (q31_t)0x71e79d7c, (q31_t)0x71e4bf90, + (q31_t)0x71e1e15e, (q31_t)0x71df02e5, (q31_t)0x71dc2427, (q31_t)0x71d94522, + (q31_t)0x71d665d6, (q31_t)0x71d38645, (q31_t)0x71d0a66d, (q31_t)0x71cdc650, + (q31_t)0x71cae5ec, (q31_t)0x71c80542, (q31_t)0x71c52451, (q31_t)0x71c2431b, + (q31_t)0x71bf619e, (q31_t)0x71bc7fdb, (q31_t)0x71b99dd2, (q31_t)0x71b6bb83, + (q31_t)0x71b3d8ed, (q31_t)0x71b0f612, (q31_t)0x71ae12f0, (q31_t)0x71ab2f89, + (q31_t)0x71a84bdb, (q31_t)0x71a567e7, (q31_t)0x71a283ad, (q31_t)0x719f9f2c, + (q31_t)0x719cba66, (q31_t)0x7199d55a, (q31_t)0x7196f008, (q31_t)0x71940a6f, + (q31_t)0x71912490, (q31_t)0x718e3e6c, (q31_t)0x718b5801, (q31_t)0x71887151, + (q31_t)0x71858a5a, (q31_t)0x7182a31d, (q31_t)0x717fbb9a, (q31_t)0x717cd3d2, + (q31_t)0x7179ebc3, (q31_t)0x7177036e, (q31_t)0x71741ad3, (q31_t)0x717131f3, + (q31_t)0x716e48cc, (q31_t)0x716b5f5f, (q31_t)0x716875ad, (q31_t)0x71658bb4, + (q31_t)0x7162a175, (q31_t)0x715fb6f1, (q31_t)0x715ccc26, (q31_t)0x7159e116, + (q31_t)0x7156f5c0, (q31_t)0x71540a24, (q31_t)0x71511e42, (q31_t)0x714e321a, + (q31_t)0x714b45ac, (q31_t)0x714858f8, (q31_t)0x71456bfe, (q31_t)0x71427ebf, + (q31_t)0x713f9139, (q31_t)0x713ca36e, (q31_t)0x7139b55d, (q31_t)0x7136c706, + (q31_t)0x7133d869, (q31_t)0x7130e987, (q31_t)0x712dfa5e, (q31_t)0x712b0af0, + (q31_t)0x71281b3c, (q31_t)0x71252b42, (q31_t)0x71223b02, (q31_t)0x711f4a7d, + (q31_t)0x711c59b2, (q31_t)0x711968a1, (q31_t)0x7116774a, (q31_t)0x711385ad, + (q31_t)0x711093cb, (q31_t)0x710da1a3, (q31_t)0x710aaf35, (q31_t)0x7107bc82, + (q31_t)0x7104c989, (q31_t)0x7101d64a, (q31_t)0x70fee2c5, (q31_t)0x70fbeefb, + (q31_t)0x70f8faeb, (q31_t)0x70f60695, (q31_t)0x70f311fa, (q31_t)0x70f01d19, + (q31_t)0x70ed27f2, (q31_t)0x70ea3286, (q31_t)0x70e73cd4, (q31_t)0x70e446dc, + (q31_t)0x70e1509f, (q31_t)0x70de5a1c, (q31_t)0x70db6353, (q31_t)0x70d86c45, + (q31_t)0x70d574f1, (q31_t)0x70d27d58, (q31_t)0x70cf8579, (q31_t)0x70cc8d54, + (q31_t)0x70c994ea, (q31_t)0x70c69c3a, (q31_t)0x70c3a345, (q31_t)0x70c0aa0a, + (q31_t)0x70bdb08a, (q31_t)0x70bab6c4, (q31_t)0x70b7bcb8, (q31_t)0x70b4c267, + (q31_t)0x70b1c7d1, (q31_t)0x70aeccf5, (q31_t)0x70abd1d3, (q31_t)0x70a8d66c, + (q31_t)0x70a5dac0, (q31_t)0x70a2dece, (q31_t)0x709fe296, (q31_t)0x709ce619, + (q31_t)0x7099e957, (q31_t)0x7096ec4f, (q31_t)0x7093ef01, (q31_t)0x7090f16e, + (q31_t)0x708df396, (q31_t)0x708af579, (q31_t)0x7087f715, (q31_t)0x7084f86d, + (q31_t)0x7081f97f, (q31_t)0x707efa4c, (q31_t)0x707bfad3, (q31_t)0x7078fb15, + (q31_t)0x7075fb11, (q31_t)0x7072fac9, (q31_t)0x706ffa3a, (q31_t)0x706cf967, + (q31_t)0x7069f84e, (q31_t)0x7066f6f0, (q31_t)0x7063f54c, (q31_t)0x7060f363, + (q31_t)0x705df135, (q31_t)0x705aeec1, (q31_t)0x7057ec08, (q31_t)0x7054e90a, + (q31_t)0x7051e5c7, (q31_t)0x704ee23e, (q31_t)0x704bde70, (q31_t)0x7048da5d, + (q31_t)0x7045d604, (q31_t)0x7042d166, (q31_t)0x703fcc83, (q31_t)0x703cc75b, + (q31_t)0x7039c1ed, (q31_t)0x7036bc3b, (q31_t)0x7033b643, (q31_t)0x7030b005, + (q31_t)0x702da983, (q31_t)0x702aa2bb, (q31_t)0x70279baf, (q31_t)0x7024945d, + (q31_t)0x70218cc6, (q31_t)0x701e84e9, (q31_t)0x701b7cc8, (q31_t)0x70187461, + (q31_t)0x70156bb5, (q31_t)0x701262c4, (q31_t)0x700f598e, (q31_t)0x700c5013, + (q31_t)0x70094653, (q31_t)0x70063c4e, (q31_t)0x70033203, (q31_t)0x70002774, + (q31_t)0x6ffd1c9f, (q31_t)0x6ffa1185, (q31_t)0x6ff70626, (q31_t)0x6ff3fa82, + (q31_t)0x6ff0ee99, (q31_t)0x6fede26b, (q31_t)0x6fead5f8, (q31_t)0x6fe7c940, + (q31_t)0x6fe4bc43, (q31_t)0x6fe1af01, (q31_t)0x6fdea17a, (q31_t)0x6fdb93ae, + (q31_t)0x6fd8859d, (q31_t)0x6fd57746, (q31_t)0x6fd268ab, (q31_t)0x6fcf59cb, + (q31_t)0x6fcc4aa6, (q31_t)0x6fc93b3c, (q31_t)0x6fc62b8d, (q31_t)0x6fc31b99, + (q31_t)0x6fc00b60, (q31_t)0x6fbcfae2, (q31_t)0x6fb9ea20, (q31_t)0x6fb6d918, + (q31_t)0x6fb3c7cb, (q31_t)0x6fb0b63a, (q31_t)0x6fada464, (q31_t)0x6faa9248, + (q31_t)0x6fa77fe8, (q31_t)0x6fa46d43, (q31_t)0x6fa15a59, (q31_t)0x6f9e472b, + (q31_t)0x6f9b33b7, (q31_t)0x6f981fff, (q31_t)0x6f950c01, (q31_t)0x6f91f7bf, + (q31_t)0x6f8ee338, (q31_t)0x6f8bce6c, (q31_t)0x6f88b95c, (q31_t)0x6f85a407, + (q31_t)0x6f828e6c, (q31_t)0x6f7f788d, (q31_t)0x6f7c626a, (q31_t)0x6f794c01, + (q31_t)0x6f763554, (q31_t)0x6f731e62, (q31_t)0x6f70072b, (q31_t)0x6f6cefb0, + (q31_t)0x6f69d7f0, (q31_t)0x6f66bfeb, (q31_t)0x6f63a7a1, (q31_t)0x6f608f13, + (q31_t)0x6f5d7640, (q31_t)0x6f5a5d28, (q31_t)0x6f5743cb, (q31_t)0x6f542a2a, + (q31_t)0x6f511044, (q31_t)0x6f4df61a, (q31_t)0x6f4adbab, (q31_t)0x6f47c0f7, + (q31_t)0x6f44a5ff, (q31_t)0x6f418ac2, (q31_t)0x6f3e6f40, (q31_t)0x6f3b537a, + (q31_t)0x6f38376f, (q31_t)0x6f351b1f, (q31_t)0x6f31fe8b, (q31_t)0x6f2ee1b2, + (q31_t)0x6f2bc495, (q31_t)0x6f28a733, (q31_t)0x6f25898d, (q31_t)0x6f226ba2, + (q31_t)0x6f1f4d72, (q31_t)0x6f1c2efe, (q31_t)0x6f191045, (q31_t)0x6f15f148, + (q31_t)0x6f12d206, (q31_t)0x6f0fb280, (q31_t)0x6f0c92b6, (q31_t)0x6f0972a6, + (q31_t)0x6f065253, (q31_t)0x6f0331ba, (q31_t)0x6f0010de, (q31_t)0x6efcefbd, + (q31_t)0x6ef9ce57, (q31_t)0x6ef6acad, (q31_t)0x6ef38abe, (q31_t)0x6ef0688b, + (q31_t)0x6eed4614, (q31_t)0x6eea2358, (q31_t)0x6ee70058, (q31_t)0x6ee3dd13, + (q31_t)0x6ee0b98a, (q31_t)0x6edd95bd, (q31_t)0x6eda71ab, (q31_t)0x6ed74d55, + (q31_t)0x6ed428ba, (q31_t)0x6ed103db, (q31_t)0x6ecddeb8, (q31_t)0x6ecab950, + (q31_t)0x6ec793a4, (q31_t)0x6ec46db4, (q31_t)0x6ec1477f, (q31_t)0x6ebe2106, + (q31_t)0x6ebafa49, (q31_t)0x6eb7d347, (q31_t)0x6eb4ac02, (q31_t)0x6eb18477, + (q31_t)0x6eae5ca9, (q31_t)0x6eab3496, (q31_t)0x6ea80c3f, (q31_t)0x6ea4e3a4, + (q31_t)0x6ea1bac4, (q31_t)0x6e9e91a1, (q31_t)0x6e9b6839, (q31_t)0x6e983e8d, + (q31_t)0x6e95149c, (q31_t)0x6e91ea67, (q31_t)0x6e8ebfef, (q31_t)0x6e8b9532, + (q31_t)0x6e886a30, (q31_t)0x6e853eeb, (q31_t)0x6e821361, (q31_t)0x6e7ee794, + (q31_t)0x6e7bbb82, (q31_t)0x6e788f2c, (q31_t)0x6e756291, (q31_t)0x6e7235b3, + (q31_t)0x6e6f0890, (q31_t)0x6e6bdb2a, (q31_t)0x6e68ad7f, (q31_t)0x6e657f90, + (q31_t)0x6e62515d, (q31_t)0x6e5f22e6, (q31_t)0x6e5bf42b, (q31_t)0x6e58c52c, + (q31_t)0x6e5595e9, (q31_t)0x6e526662, (q31_t)0x6e4f3696, (q31_t)0x6e4c0687, + (q31_t)0x6e48d633, (q31_t)0x6e45a59c, (q31_t)0x6e4274c1, (q31_t)0x6e3f43a1, + (q31_t)0x6e3c123e, (q31_t)0x6e38e096, (q31_t)0x6e35aeab, (q31_t)0x6e327c7b, + (q31_t)0x6e2f4a08, (q31_t)0x6e2c1750, (q31_t)0x6e28e455, (q31_t)0x6e25b115, + (q31_t)0x6e227d92, (q31_t)0x6e1f49cb, (q31_t)0x6e1c15c0, (q31_t)0x6e18e171, + (q31_t)0x6e15acde, (q31_t)0x6e127807, (q31_t)0x6e0f42ec, (q31_t)0x6e0c0d8e, + (q31_t)0x6e08d7eb, (q31_t)0x6e05a205, (q31_t)0x6e026bda, (q31_t)0x6dff356c, + (q31_t)0x6dfbfeba, (q31_t)0x6df8c7c4, (q31_t)0x6df5908b, (q31_t)0x6df2590d, + (q31_t)0x6def214c, (q31_t)0x6debe947, (q31_t)0x6de8b0fe, (q31_t)0x6de57871, + (q31_t)0x6de23fa0, (q31_t)0x6ddf068c, (q31_t)0x6ddbcd34, (q31_t)0x6dd89398, + (q31_t)0x6dd559b9, (q31_t)0x6dd21f95, (q31_t)0x6dcee52e, (q31_t)0x6dcbaa83, + (q31_t)0x6dc86f95, (q31_t)0x6dc53462, (q31_t)0x6dc1f8ec, (q31_t)0x6dbebd33, + (q31_t)0x6dbb8135, (q31_t)0x6db844f4, (q31_t)0x6db5086f, (q31_t)0x6db1cba7, + (q31_t)0x6dae8e9b, (q31_t)0x6dab514b, (q31_t)0x6da813b8, (q31_t)0x6da4d5e1, + (q31_t)0x6da197c6, (q31_t)0x6d9e5968, (q31_t)0x6d9b1ac6, (q31_t)0x6d97dbe0, + (q31_t)0x6d949cb7, (q31_t)0x6d915d4a, (q31_t)0x6d8e1d9a, (q31_t)0x6d8adda6, + (q31_t)0x6d879d6e, (q31_t)0x6d845cf3, (q31_t)0x6d811c35, (q31_t)0x6d7ddb33, + (q31_t)0x6d7a99ed, (q31_t)0x6d775864, (q31_t)0x6d741697, (q31_t)0x6d70d487, + (q31_t)0x6d6d9233, (q31_t)0x6d6a4f9c, (q31_t)0x6d670cc1, (q31_t)0x6d63c9a3, + (q31_t)0x6d608641, (q31_t)0x6d5d429c, (q31_t)0x6d59feb3, (q31_t)0x6d56ba87, + (q31_t)0x6d537617, (q31_t)0x6d503164, (q31_t)0x6d4cec6e, (q31_t)0x6d49a734, + (q31_t)0x6d4661b7, (q31_t)0x6d431bf6, (q31_t)0x6d3fd5f2, (q31_t)0x6d3c8fab, + (q31_t)0x6d394920, (q31_t)0x6d360252, (q31_t)0x6d32bb40, (q31_t)0x6d2f73eb, + (q31_t)0x6d2c2c53, (q31_t)0x6d28e477, (q31_t)0x6d259c58, (q31_t)0x6d2253f6, + (q31_t)0x6d1f0b50, (q31_t)0x6d1bc267, (q31_t)0x6d18793b, (q31_t)0x6d152fcc, + (q31_t)0x6d11e619, (q31_t)0x6d0e9c23, (q31_t)0x6d0b51e9, (q31_t)0x6d08076d, + (q31_t)0x6d04bcad, (q31_t)0x6d0171aa, (q31_t)0x6cfe2663, (q31_t)0x6cfadada, + (q31_t)0x6cf78f0d, (q31_t)0x6cf442fd, (q31_t)0x6cf0f6aa, (q31_t)0x6cedaa13, + (q31_t)0x6cea5d3a, (q31_t)0x6ce7101d, (q31_t)0x6ce3c2bd, (q31_t)0x6ce0751a, + (q31_t)0x6cdd2733, (q31_t)0x6cd9d90a, (q31_t)0x6cd68a9d, (q31_t)0x6cd33bed, + (q31_t)0x6ccfecfa, (q31_t)0x6ccc9dc4, (q31_t)0x6cc94e4b, (q31_t)0x6cc5fe8f, + (q31_t)0x6cc2ae90, (q31_t)0x6cbf5e4d, (q31_t)0x6cbc0dc8, (q31_t)0x6cb8bcff, + (q31_t)0x6cb56bf4, (q31_t)0x6cb21aa5, (q31_t)0x6caec913, (q31_t)0x6cab773e, + (q31_t)0x6ca82527, (q31_t)0x6ca4d2cc, (q31_t)0x6ca1802e, (q31_t)0x6c9e2d4d, + (q31_t)0x6c9ada29, (q31_t)0x6c9786c2, (q31_t)0x6c943318, (q31_t)0x6c90df2c, + (q31_t)0x6c8d8afc, (q31_t)0x6c8a3689, (q31_t)0x6c86e1d3, (q31_t)0x6c838cdb, + (q31_t)0x6c80379f, (q31_t)0x6c7ce220, (q31_t)0x6c798c5f, (q31_t)0x6c76365b, + (q31_t)0x6c72e013, (q31_t)0x6c6f8989, (q31_t)0x6c6c32bc, (q31_t)0x6c68dbac, + (q31_t)0x6c658459, (q31_t)0x6c622cc4, (q31_t)0x6c5ed4eb, (q31_t)0x6c5b7cd0, + (q31_t)0x6c582472, (q31_t)0x6c54cbd1, (q31_t)0x6c5172ed, (q31_t)0x6c4e19c6, + (q31_t)0x6c4ac05d, (q31_t)0x6c4766b0, (q31_t)0x6c440cc1, (q31_t)0x6c40b28f, + (q31_t)0x6c3d581b, (q31_t)0x6c39fd63, (q31_t)0x6c36a269, (q31_t)0x6c33472c, + (q31_t)0x6c2febad, (q31_t)0x6c2c8fea, (q31_t)0x6c2933e5, (q31_t)0x6c25d79d, + (q31_t)0x6c227b13, (q31_t)0x6c1f1e45, (q31_t)0x6c1bc136, (q31_t)0x6c1863e3, + (q31_t)0x6c15064e, (q31_t)0x6c11a876, (q31_t)0x6c0e4a5b, (q31_t)0x6c0aebfe, + (q31_t)0x6c078d5e, (q31_t)0x6c042e7b, (q31_t)0x6c00cf56, (q31_t)0x6bfd6fee, + (q31_t)0x6bfa1044, (q31_t)0x6bf6b056, (q31_t)0x6bf35027, (q31_t)0x6befefb5, + (q31_t)0x6bec8f00, (q31_t)0x6be92e08, (q31_t)0x6be5ccce, (q31_t)0x6be26b52, + (q31_t)0x6bdf0993, (q31_t)0x6bdba791, (q31_t)0x6bd8454d, (q31_t)0x6bd4e2c6, + (q31_t)0x6bd17ffd, (q31_t)0x6bce1cf1, (q31_t)0x6bcab9a3, (q31_t)0x6bc75613, + (q31_t)0x6bc3f23f, (q31_t)0x6bc08e2a, (q31_t)0x6bbd29d2, (q31_t)0x6bb9c537, + (q31_t)0x6bb6605a, (q31_t)0x6bb2fb3b, (q31_t)0x6baf95d9, (q31_t)0x6bac3034, + (q31_t)0x6ba8ca4e, (q31_t)0x6ba56425, (q31_t)0x6ba1fdb9, (q31_t)0x6b9e970b, + (q31_t)0x6b9b301b, (q31_t)0x6b97c8e8, (q31_t)0x6b946173, (q31_t)0x6b90f9bc, + (q31_t)0x6b8d91c2, (q31_t)0x6b8a2986, (q31_t)0x6b86c107, (q31_t)0x6b835846, + (q31_t)0x6b7fef43, (q31_t)0x6b7c85fe, (q31_t)0x6b791c76, (q31_t)0x6b75b2ac, + (q31_t)0x6b7248a0, (q31_t)0x6b6ede51, (q31_t)0x6b6b73c0, (q31_t)0x6b6808ed, + (q31_t)0x6b649dd8, (q31_t)0x6b613280, (q31_t)0x6b5dc6e6, (q31_t)0x6b5a5b0a, + (q31_t)0x6b56eeec, (q31_t)0x6b53828b, (q31_t)0x6b5015e9, (q31_t)0x6b4ca904, + (q31_t)0x6b493bdd, (q31_t)0x6b45ce73, (q31_t)0x6b4260c8, (q31_t)0x6b3ef2da, + (q31_t)0x6b3b84ab, (q31_t)0x6b381639, (q31_t)0x6b34a785, (q31_t)0x6b31388e, + (q31_t)0x6b2dc956, (q31_t)0x6b2a59dc, (q31_t)0x6b26ea1f, (q31_t)0x6b237a21, + (q31_t)0x6b2009e0, (q31_t)0x6b1c995d, (q31_t)0x6b192898, (q31_t)0x6b15b791, + (q31_t)0x6b124648, (q31_t)0x6b0ed4bd, (q31_t)0x6b0b62f0, (q31_t)0x6b07f0e1, + (q31_t)0x6b047e90, (q31_t)0x6b010bfd, (q31_t)0x6afd9928, (q31_t)0x6afa2610, + (q31_t)0x6af6b2b7, (q31_t)0x6af33f1c, (q31_t)0x6aefcb3f, (q31_t)0x6aec5720, + (q31_t)0x6ae8e2bf, (q31_t)0x6ae56e1c, (q31_t)0x6ae1f937, (q31_t)0x6ade8410, + (q31_t)0x6adb0ea8, (q31_t)0x6ad798fd, (q31_t)0x6ad42311, (q31_t)0x6ad0ace2, + (q31_t)0x6acd3672, (q31_t)0x6ac9bfc0, (q31_t)0x6ac648cb, (q31_t)0x6ac2d195, + (q31_t)0x6abf5a1e, (q31_t)0x6abbe264, (q31_t)0x6ab86a68, (q31_t)0x6ab4f22b, + (q31_t)0x6ab179ac, (q31_t)0x6aae00eb, (q31_t)0x6aaa87e8, (q31_t)0x6aa70ea4, + (q31_t)0x6aa3951d, (q31_t)0x6aa01b55, (q31_t)0x6a9ca14b, (q31_t)0x6a992700, + (q31_t)0x6a95ac72, (q31_t)0x6a9231a3, (q31_t)0x6a8eb692, (q31_t)0x6a8b3b3f, + (q31_t)0x6a87bfab, (q31_t)0x6a8443d5, (q31_t)0x6a80c7bd, (q31_t)0x6a7d4b64, + (q31_t)0x6a79cec8, (q31_t)0x6a7651ec, (q31_t)0x6a72d4cd, (q31_t)0x6a6f576d, + (q31_t)0x6a6bd9cb, (q31_t)0x6a685be8, (q31_t)0x6a64ddc2, (q31_t)0x6a615f5c, + (q31_t)0x6a5de0b3, (q31_t)0x6a5a61c9, (q31_t)0x6a56e29e, (q31_t)0x6a536331, + (q31_t)0x6a4fe382, (q31_t)0x6a4c6391, (q31_t)0x6a48e360, (q31_t)0x6a4562ec, + (q31_t)0x6a41e237, (q31_t)0x6a3e6140, (q31_t)0x6a3ae008, (q31_t)0x6a375e8f, + (q31_t)0x6a33dcd4, (q31_t)0x6a305ad7, (q31_t)0x6a2cd899, (q31_t)0x6a295619, + (q31_t)0x6a25d358, (q31_t)0x6a225055, (q31_t)0x6a1ecd11, (q31_t)0x6a1b498c, + (q31_t)0x6a17c5c5, (q31_t)0x6a1441bc, (q31_t)0x6a10bd72, (q31_t)0x6a0d38e7, + (q31_t)0x6a09b41a, (q31_t)0x6a062f0c, (q31_t)0x6a02a9bc, (q31_t)0x69ff242b, + (q31_t)0x69fb9e59, (q31_t)0x69f81845, (q31_t)0x69f491f0, (q31_t)0x69f10b5a, + (q31_t)0x69ed8482, (q31_t)0x69e9fd69, (q31_t)0x69e6760f, (q31_t)0x69e2ee73, + (q31_t)0x69df6696, (q31_t)0x69dbde77, (q31_t)0x69d85618, (q31_t)0x69d4cd77, + (q31_t)0x69d14494, (q31_t)0x69cdbb71, (q31_t)0x69ca320c, (q31_t)0x69c6a866, + (q31_t)0x69c31e7f, (q31_t)0x69bf9456, (q31_t)0x69bc09ec, (q31_t)0x69b87f41, + (q31_t)0x69b4f455, (q31_t)0x69b16928, (q31_t)0x69adddb9, (q31_t)0x69aa5209, + (q31_t)0x69a6c618, (q31_t)0x69a339e6, (q31_t)0x699fad73, (q31_t)0x699c20be, + (q31_t)0x699893c9, (q31_t)0x69950692, (q31_t)0x6991791a, (q31_t)0x698deb61, + (q31_t)0x698a5d67, (q31_t)0x6986cf2c, (q31_t)0x698340af, (q31_t)0x697fb1f2, + (q31_t)0x697c22f3, (q31_t)0x697893b4, (q31_t)0x69750433, (q31_t)0x69717472, + (q31_t)0x696de46f, (q31_t)0x696a542b, (q31_t)0x6966c3a6, (q31_t)0x696332e1, + (q31_t)0x695fa1da, (q31_t)0x695c1092, (q31_t)0x69587f09, (q31_t)0x6954ed40, + (q31_t)0x69515b35, (q31_t)0x694dc8e9, (q31_t)0x694a365c, (q31_t)0x6946a38f, + (q31_t)0x69431080, (q31_t)0x693f7d31, (q31_t)0x693be9a0, (q31_t)0x693855cf, + (q31_t)0x6934c1bd, (q31_t)0x69312d6a, (q31_t)0x692d98d6, (q31_t)0x692a0401, + (q31_t)0x69266eeb, (q31_t)0x6922d995, (q31_t)0x691f43fd, (q31_t)0x691bae25, + (q31_t)0x6918180c, (q31_t)0x691481b2, (q31_t)0x6910eb17, (q31_t)0x690d543b, + (q31_t)0x6909bd1f, (q31_t)0x690625c2, (q31_t)0x69028e24, (q31_t)0x68fef645, + (q31_t)0x68fb5e25, (q31_t)0x68f7c5c5, (q31_t)0x68f42d24, (q31_t)0x68f09442, + (q31_t)0x68ecfb20, (q31_t)0x68e961bd, (q31_t)0x68e5c819, (q31_t)0x68e22e34, + (q31_t)0x68de940f, (q31_t)0x68daf9a9, (q31_t)0x68d75f02, (q31_t)0x68d3c41b, + (q31_t)0x68d028f2, (q31_t)0x68cc8d8a, (q31_t)0x68c8f1e0, (q31_t)0x68c555f6, + (q31_t)0x68c1b9cc, (q31_t)0x68be1d61, (q31_t)0x68ba80b5, (q31_t)0x68b6e3c8, + (q31_t)0x68b3469b, (q31_t)0x68afa92e, (q31_t)0x68ac0b7f, (q31_t)0x68a86d91, + (q31_t)0x68a4cf61, (q31_t)0x68a130f1, (q31_t)0x689d9241, (q31_t)0x6899f350, + (q31_t)0x6896541f, (q31_t)0x6892b4ad, (q31_t)0x688f14fa, (q31_t)0x688b7507, + (q31_t)0x6887d4d4, (q31_t)0x68843460, (q31_t)0x688093ab, (q31_t)0x687cf2b6, + (q31_t)0x68795181, (q31_t)0x6875b00b, (q31_t)0x68720e55, (q31_t)0x686e6c5e, + (q31_t)0x686aca27, (q31_t)0x686727b0, (q31_t)0x686384f8, (q31_t)0x685fe200, + (q31_t)0x685c3ec7, (q31_t)0x68589b4e, (q31_t)0x6854f795, (q31_t)0x6851539b, + (q31_t)0x684daf61, (q31_t)0x684a0ae6, (q31_t)0x6846662c, (q31_t)0x6842c131, + (q31_t)0x683f1bf5, (q31_t)0x683b7679, (q31_t)0x6837d0bd, (q31_t)0x68342ac1, + (q31_t)0x68308485, (q31_t)0x682cde08, (q31_t)0x6829374b, (q31_t)0x6825904d, + (q31_t)0x6821e910, (q31_t)0x681e4192, (q31_t)0x681a99d4, (q31_t)0x6816f1d6, + (q31_t)0x68134997, (q31_t)0x680fa118, (q31_t)0x680bf85a, (q31_t)0x68084f5a, + (q31_t)0x6804a61b, (q31_t)0x6800fc9c, (q31_t)0x67fd52dc, (q31_t)0x67f9a8dd, + (q31_t)0x67f5fe9d, (q31_t)0x67f2541d, (q31_t)0x67eea95d, (q31_t)0x67eafe5d, + (q31_t)0x67e7531c, (q31_t)0x67e3a79c, (q31_t)0x67dffbdc, (q31_t)0x67dc4fdb, + (q31_t)0x67d8a39a, (q31_t)0x67d4f71a, (q31_t)0x67d14a59, (q31_t)0x67cd9d58, + (q31_t)0x67c9f017, (q31_t)0x67c64297, (q31_t)0x67c294d6, (q31_t)0x67bee6d5, + (q31_t)0x67bb3894, (q31_t)0x67b78a13, (q31_t)0x67b3db53, (q31_t)0x67b02c52, + (q31_t)0x67ac7d11, (q31_t)0x67a8cd91, (q31_t)0x67a51dd0, (q31_t)0x67a16dcf, + (q31_t)0x679dbd8f, (q31_t)0x679a0d0f, (q31_t)0x67965c4e, (q31_t)0x6792ab4e, + (q31_t)0x678efa0e, (q31_t)0x678b488e, (q31_t)0x678796ce, (q31_t)0x6783e4cf, + (q31_t)0x6780328f, (q31_t)0x677c8010, (q31_t)0x6778cd50, (q31_t)0x67751a51, + (q31_t)0x67716713, (q31_t)0x676db394, (q31_t)0x6769ffd5, (q31_t)0x67664bd7, + (q31_t)0x67629799, (q31_t)0x675ee31b, (q31_t)0x675b2e5e, (q31_t)0x67577960, + (q31_t)0x6753c423, (q31_t)0x67500ea7, (q31_t)0x674c58ea, (q31_t)0x6748a2ee, + (q31_t)0x6744ecb2, (q31_t)0x67413636, (q31_t)0x673d7f7b, (q31_t)0x6739c880, + (q31_t)0x67361145, (q31_t)0x673259ca, (q31_t)0x672ea210, (q31_t)0x672aea17, + (q31_t)0x672731dd, (q31_t)0x67237964, (q31_t)0x671fc0ac, (q31_t)0x671c07b4, + (q31_t)0x67184e7c, (q31_t)0x67149504, (q31_t)0x6710db4d, (q31_t)0x670d2157, + (q31_t)0x67096721, (q31_t)0x6705acab, (q31_t)0x6701f1f6, (q31_t)0x66fe3701, + (q31_t)0x66fa7bcd, (q31_t)0x66f6c059, (q31_t)0x66f304a6, (q31_t)0x66ef48b3, + (q31_t)0x66eb8c80, (q31_t)0x66e7d00f, (q31_t)0x66e4135d, (q31_t)0x66e0566c, + (q31_t)0x66dc993c, (q31_t)0x66d8dbcd, (q31_t)0x66d51e1d, (q31_t)0x66d1602f, + (q31_t)0x66cda201, (q31_t)0x66c9e393, (q31_t)0x66c624e7, (q31_t)0x66c265fa, + (q31_t)0x66bea6cf, (q31_t)0x66bae764, (q31_t)0x66b727ba, (q31_t)0x66b367d0, + (q31_t)0x66afa7a7, (q31_t)0x66abe73f, (q31_t)0x66a82697, (q31_t)0x66a465b0, + (q31_t)0x66a0a489, (q31_t)0x669ce324, (q31_t)0x6699217f, (q31_t)0x66955f9b, + (q31_t)0x66919d77, (q31_t)0x668ddb14, (q31_t)0x668a1872, (q31_t)0x66865591, + (q31_t)0x66829270, (q31_t)0x667ecf11, (q31_t)0x667b0b72, (q31_t)0x66774793, + (q31_t)0x66738376, (q31_t)0x666fbf19, (q31_t)0x666bfa7d, (q31_t)0x666835a2, + (q31_t)0x66647088, (q31_t)0x6660ab2f, (q31_t)0x665ce596, (q31_t)0x66591fbf, + (q31_t)0x665559a8, (q31_t)0x66519352, (q31_t)0x664dccbd, (q31_t)0x664a05e9, + (q31_t)0x66463ed6, (q31_t)0x66427784, (q31_t)0x663eaff2, (q31_t)0x663ae822, + (q31_t)0x66372012, (q31_t)0x663357c4, (q31_t)0x662f8f36, (q31_t)0x662bc66a, + (q31_t)0x6627fd5e, (q31_t)0x66243413, (q31_t)0x66206a8a, (q31_t)0x661ca0c1, + (q31_t)0x6618d6b9, (q31_t)0x66150c73, (q31_t)0x661141ed, (q31_t)0x660d7729, + (q31_t)0x6609ac25, (q31_t)0x6605e0e3, (q31_t)0x66021561, (q31_t)0x65fe49a1, + (q31_t)0x65fa7da2, (q31_t)0x65f6b164, (q31_t)0x65f2e4e7, (q31_t)0x65ef182b, + (q31_t)0x65eb4b30, (q31_t)0x65e77df6, (q31_t)0x65e3b07e, (q31_t)0x65dfe2c6, + (q31_t)0x65dc14d0, (q31_t)0x65d8469b, (q31_t)0x65d47827, (q31_t)0x65d0a975, + (q31_t)0x65ccda83, (q31_t)0x65c90b53, (q31_t)0x65c53be4, (q31_t)0x65c16c36, + (q31_t)0x65bd9c49, (q31_t)0x65b9cc1e, (q31_t)0x65b5fbb4, (q31_t)0x65b22b0b, + (q31_t)0x65ae5a23, (q31_t)0x65aa88fd, (q31_t)0x65a6b798, (q31_t)0x65a2e5f4, + (q31_t)0x659f1412, (q31_t)0x659b41f1, (q31_t)0x65976f91, (q31_t)0x65939cf3, + (q31_t)0x658fca15, (q31_t)0x658bf6fa, (q31_t)0x6588239f, (q31_t)0x65845006, + (q31_t)0x65807c2f, (q31_t)0x657ca818, (q31_t)0x6578d3c4, (q31_t)0x6574ff30, + (q31_t)0x65712a5e, (q31_t)0x656d554d, (q31_t)0x65697ffe, (q31_t)0x6565aa71, + (q31_t)0x6561d4a4, (q31_t)0x655dfe99, (q31_t)0x655a2850, (q31_t)0x655651c8, + (q31_t)0x65527b02, (q31_t)0x654ea3fd, (q31_t)0x654accba, (q31_t)0x6546f538, + (q31_t)0x65431d77, (q31_t)0x653f4579, (q31_t)0x653b6d3b, (q31_t)0x653794c0, + (q31_t)0x6533bc06, (q31_t)0x652fe30d, (q31_t)0x652c09d6, (q31_t)0x65283061, + (q31_t)0x652456ad, (q31_t)0x65207cbb, (q31_t)0x651ca28a, (q31_t)0x6518c81b, + (q31_t)0x6514ed6e, (q31_t)0x65111283, (q31_t)0x650d3759, (q31_t)0x65095bf0, + (q31_t)0x6505804a, (q31_t)0x6501a465, (q31_t)0x64fdc841, (q31_t)0x64f9ebe0, + (q31_t)0x64f60f40, (q31_t)0x64f23262, (q31_t)0x64ee5546, (q31_t)0x64ea77eb, + (q31_t)0x64e69a52, (q31_t)0x64e2bc7b, (q31_t)0x64dede66, (q31_t)0x64db0012, + (q31_t)0x64d72180, (q31_t)0x64d342b0, (q31_t)0x64cf63a2, (q31_t)0x64cb8456, + (q31_t)0x64c7a4cb, (q31_t)0x64c3c502, (q31_t)0x64bfe4fc, (q31_t)0x64bc04b6, + (q31_t)0x64b82433, (q31_t)0x64b44372, (q31_t)0x64b06273, (q31_t)0x64ac8135, + (q31_t)0x64a89fba, (q31_t)0x64a4be00, (q31_t)0x64a0dc08, (q31_t)0x649cf9d2, + (q31_t)0x6499175e, (q31_t)0x649534ac, (q31_t)0x649151bc, (q31_t)0x648d6e8e, + (q31_t)0x64898b22, (q31_t)0x6485a778, (q31_t)0x6481c390, (q31_t)0x647ddf6a, + (q31_t)0x6479fb06, (q31_t)0x64761664, (q31_t)0x64723184, (q31_t)0x646e4c66, + (q31_t)0x646a670a, (q31_t)0x64668170, (q31_t)0x64629b98, (q31_t)0x645eb582, + (q31_t)0x645acf2e, (q31_t)0x6456e89d, (q31_t)0x645301cd, (q31_t)0x644f1ac0, + (q31_t)0x644b3375, (q31_t)0x64474bec, (q31_t)0x64436425, (q31_t)0x643f7c20, + (q31_t)0x643b93dd, (q31_t)0x6437ab5d, (q31_t)0x6433c29f, (q31_t)0x642fd9a3, + (q31_t)0x642bf069, (q31_t)0x642806f1, (q31_t)0x64241d3c, (q31_t)0x64203348, + (q31_t)0x641c4917, (q31_t)0x64185ea9, (q31_t)0x641473fc, (q31_t)0x64108912, + (q31_t)0x640c9dea, (q31_t)0x6408b284, (q31_t)0x6404c6e1, (q31_t)0x6400db00, + (q31_t)0x63fceee1, (q31_t)0x63f90285, (q31_t)0x63f515eb, (q31_t)0x63f12913, + (q31_t)0x63ed3bfd, (q31_t)0x63e94eaa, (q31_t)0x63e5611a, (q31_t)0x63e1734b, + (q31_t)0x63dd853f, (q31_t)0x63d996f6, (q31_t)0x63d5a86f, (q31_t)0x63d1b9aa, + (q31_t)0x63cdcaa8, (q31_t)0x63c9db68, (q31_t)0x63c5ebeb, (q31_t)0x63c1fc30, + (q31_t)0x63be0c37, (q31_t)0x63ba1c01, (q31_t)0x63b62b8e, (q31_t)0x63b23add, + (q31_t)0x63ae49ee, (q31_t)0x63aa58c2, (q31_t)0x63a66759, (q31_t)0x63a275b2, + (q31_t)0x639e83cd, (q31_t)0x639a91ac, (q31_t)0x63969f4c, (q31_t)0x6392acaf, + (q31_t)0x638eb9d5, (q31_t)0x638ac6be, (q31_t)0x6386d369, (q31_t)0x6382dfd6, + (q31_t)0x637eec07, (q31_t)0x637af7fa, (q31_t)0x637703af, (q31_t)0x63730f27, + (q31_t)0x636f1a62, (q31_t)0x636b2560, (q31_t)0x63673020, (q31_t)0x63633aa3, + (q31_t)0x635f44e8, (q31_t)0x635b4ef0, (q31_t)0x635758bb, (q31_t)0x63536249, + (q31_t)0x634f6b99, (q31_t)0x634b74ad, (q31_t)0x63477d82, (q31_t)0x6343861b, + (q31_t)0x633f8e76, (q31_t)0x633b9695, (q31_t)0x63379e76, (q31_t)0x6333a619, + (q31_t)0x632fad80, (q31_t)0x632bb4a9, (q31_t)0x6327bb96, (q31_t)0x6323c245, + (q31_t)0x631fc8b7, (q31_t)0x631bceeb, (q31_t)0x6317d4e3, (q31_t)0x6313da9e, + (q31_t)0x630fe01b, (q31_t)0x630be55b, (q31_t)0x6307ea5e, (q31_t)0x6303ef25, + (q31_t)0x62fff3ae, (q31_t)0x62fbf7fa, (q31_t)0x62f7fc08, (q31_t)0x62f3ffda, + (q31_t)0x62f0036f, (q31_t)0x62ec06c7, (q31_t)0x62e809e2, (q31_t)0x62e40cbf, + (q31_t)0x62e00f60, (q31_t)0x62dc11c4, (q31_t)0x62d813eb, (q31_t)0x62d415d4, + (q31_t)0x62d01781, (q31_t)0x62cc18f1, (q31_t)0x62c81a24, (q31_t)0x62c41b1a, + (q31_t)0x62c01bd3, (q31_t)0x62bc1c4f, (q31_t)0x62b81c8f, (q31_t)0x62b41c91, + (q31_t)0x62b01c57, (q31_t)0x62ac1bdf, (q31_t)0x62a81b2b, (q31_t)0x62a41a3a, + (q31_t)0x62a0190c, (q31_t)0x629c17a1, (q31_t)0x629815fa, (q31_t)0x62941415, + (q31_t)0x629011f4, (q31_t)0x628c0f96, (q31_t)0x62880cfb, (q31_t)0x62840a23, + (q31_t)0x6280070f, (q31_t)0x627c03be, (q31_t)0x62780030, (q31_t)0x6273fc65, + (q31_t)0x626ff85e, (q31_t)0x626bf41a, (q31_t)0x6267ef99, (q31_t)0x6263eadc, + (q31_t)0x625fe5e1, (q31_t)0x625be0ab, (q31_t)0x6257db37, (q31_t)0x6253d587, + (q31_t)0x624fcf9a, (q31_t)0x624bc970, (q31_t)0x6247c30a, (q31_t)0x6243bc68, + (q31_t)0x623fb588, (q31_t)0x623bae6c, (q31_t)0x6237a714, (q31_t)0x62339f7e, + (q31_t)0x622f97ad, (q31_t)0x622b8f9e, (q31_t)0x62278754, (q31_t)0x62237ecc, + (q31_t)0x621f7608, (q31_t)0x621b6d08, (q31_t)0x621763cb, (q31_t)0x62135a51, + (q31_t)0x620f509b, (q31_t)0x620b46a9, (q31_t)0x62073c7a, (q31_t)0x6203320e, + (q31_t)0x61ff2766, (q31_t)0x61fb1c82, (q31_t)0x61f71161, (q31_t)0x61f30604, + (q31_t)0x61eefa6b, (q31_t)0x61eaee95, (q31_t)0x61e6e282, (q31_t)0x61e2d633, + (q31_t)0x61dec9a8, (q31_t)0x61dabce0, (q31_t)0x61d6afdd, (q31_t)0x61d2a29c, + (q31_t)0x61ce9520, (q31_t)0x61ca8767, (q31_t)0x61c67971, (q31_t)0x61c26b40, + (q31_t)0x61be5cd2, (q31_t)0x61ba4e28, (q31_t)0x61b63f41, (q31_t)0x61b2301e, + (q31_t)0x61ae20bf, (q31_t)0x61aa1124, (q31_t)0x61a6014d, (q31_t)0x61a1f139, + (q31_t)0x619de0e9, (q31_t)0x6199d05d, (q31_t)0x6195bf94, (q31_t)0x6191ae90, + (q31_t)0x618d9d4f, (q31_t)0x61898bd2, (q31_t)0x61857a19, (q31_t)0x61816824, + (q31_t)0x617d55f2, (q31_t)0x61794385, (q31_t)0x617530db, (q31_t)0x61711df5, + (q31_t)0x616d0ad3, (q31_t)0x6168f775, (q31_t)0x6164e3db, (q31_t)0x6160d005, + (q31_t)0x615cbbf3, (q31_t)0x6158a7a4, (q31_t)0x6154931a, (q31_t)0x61507e54, + (q31_t)0x614c6951, (q31_t)0x61485413, (q31_t)0x61443e98, (q31_t)0x614028e2, + (q31_t)0x613c12f0, (q31_t)0x6137fcc1, (q31_t)0x6133e657, (q31_t)0x612fcfb0, + (q31_t)0x612bb8ce, (q31_t)0x6127a1b0, (q31_t)0x61238a56, (q31_t)0x611f72c0, + (q31_t)0x611b5aee, (q31_t)0x611742e0, (q31_t)0x61132a96, (q31_t)0x610f1210, + (q31_t)0x610af94f, (q31_t)0x6106e051, (q31_t)0x6102c718, (q31_t)0x60feada3, + (q31_t)0x60fa93f2, (q31_t)0x60f67a05, (q31_t)0x60f25fdd, (q31_t)0x60ee4579, + (q31_t)0x60ea2ad8, (q31_t)0x60e60ffd, (q31_t)0x60e1f4e5, (q31_t)0x60ddd991, + (q31_t)0x60d9be02, (q31_t)0x60d5a237, (q31_t)0x60d18631, (q31_t)0x60cd69ee, + (q31_t)0x60c94d70, (q31_t)0x60c530b6, (q31_t)0x60c113c1, (q31_t)0x60bcf690, + (q31_t)0x60b8d923, (q31_t)0x60b4bb7a, (q31_t)0x60b09d96, (q31_t)0x60ac7f76, + (q31_t)0x60a8611b, (q31_t)0x60a44284, (q31_t)0x60a023b1, (q31_t)0x609c04a3, + (q31_t)0x6097e559, (q31_t)0x6093c5d3, (q31_t)0x608fa612, (q31_t)0x608b8616, + (q31_t)0x608765dd, (q31_t)0x6083456a, (q31_t)0x607f24ba, (q31_t)0x607b03d0, + (q31_t)0x6076e2a9, (q31_t)0x6072c148, (q31_t)0x606e9faa, (q31_t)0x606a7dd2, + (q31_t)0x60665bbd, (q31_t)0x6062396e, (q31_t)0x605e16e2, (q31_t)0x6059f41c, + (q31_t)0x6055d11a, (q31_t)0x6051addc, (q31_t)0x604d8a63, (q31_t)0x604966af, + (q31_t)0x604542bf, (q31_t)0x60411e94, (q31_t)0x603cfa2e, (q31_t)0x6038d58c, + (q31_t)0x6034b0af, (q31_t)0x60308b97, (q31_t)0x602c6643, (q31_t)0x602840b4, + (q31_t)0x60241ae9, (q31_t)0x601ff4e3, (q31_t)0x601bcea2, (q31_t)0x6017a826, + (q31_t)0x6013816e, (q31_t)0x600f5a7b, (q31_t)0x600b334d, (q31_t)0x60070be4, + (q31_t)0x6002e43f, (q31_t)0x5ffebc5f, (q31_t)0x5ffa9444, (q31_t)0x5ff66bee, + (q31_t)0x5ff2435d, (q31_t)0x5fee1a90, (q31_t)0x5fe9f188, (q31_t)0x5fe5c845, + (q31_t)0x5fe19ec7, (q31_t)0x5fdd750e, (q31_t)0x5fd94b19, (q31_t)0x5fd520ea, + (q31_t)0x5fd0f67f, (q31_t)0x5fcccbd9, (q31_t)0x5fc8a0f8, (q31_t)0x5fc475dc, + (q31_t)0x5fc04a85, (q31_t)0x5fbc1ef3, (q31_t)0x5fb7f326, (q31_t)0x5fb3c71e, + (q31_t)0x5faf9adb, (q31_t)0x5fab6e5d, (q31_t)0x5fa741a3, (q31_t)0x5fa314af, + (q31_t)0x5f9ee780, (q31_t)0x5f9aba16, (q31_t)0x5f968c70, (q31_t)0x5f925e90, + (q31_t)0x5f8e3075, (q31_t)0x5f8a021f, (q31_t)0x5f85d38e, (q31_t)0x5f81a4c2, + (q31_t)0x5f7d75bb, (q31_t)0x5f794679, (q31_t)0x5f7516fd, (q31_t)0x5f70e745, + (q31_t)0x5f6cb753, (q31_t)0x5f688726, (q31_t)0x5f6456be, (q31_t)0x5f60261b, + (q31_t)0x5f5bf53d, (q31_t)0x5f57c424, (q31_t)0x5f5392d1, (q31_t)0x5f4f6143, + (q31_t)0x5f4b2f7a, (q31_t)0x5f46fd76, (q31_t)0x5f42cb37, (q31_t)0x5f3e98be, + (q31_t)0x5f3a660a, (q31_t)0x5f36331b, (q31_t)0x5f31fff1, (q31_t)0x5f2dcc8d, + (q31_t)0x5f2998ee, (q31_t)0x5f256515, (q31_t)0x5f213100, (q31_t)0x5f1cfcb1, + (q31_t)0x5f18c827, (q31_t)0x5f149363, (q31_t)0x5f105e64, (q31_t)0x5f0c292a, + (q31_t)0x5f07f3b6, (q31_t)0x5f03be07, (q31_t)0x5eff881d, (q31_t)0x5efb51f9, + (q31_t)0x5ef71b9b, (q31_t)0x5ef2e501, (q31_t)0x5eeeae2d, (q31_t)0x5eea771f, + (q31_t)0x5ee63fd6, (q31_t)0x5ee20853, (q31_t)0x5eddd094, (q31_t)0x5ed9989c, + (q31_t)0x5ed56069, (q31_t)0x5ed127fb, (q31_t)0x5eccef53, (q31_t)0x5ec8b671, + (q31_t)0x5ec47d54, (q31_t)0x5ec043fc, (q31_t)0x5ebc0a6a, (q31_t)0x5eb7d09e, + (q31_t)0x5eb39697, (q31_t)0x5eaf5c56, (q31_t)0x5eab21da, (q31_t)0x5ea6e724, + (q31_t)0x5ea2ac34, (q31_t)0x5e9e7109, (q31_t)0x5e9a35a4, (q31_t)0x5e95fa05, + (q31_t)0x5e91be2b, (q31_t)0x5e8d8217, (q31_t)0x5e8945c8, (q31_t)0x5e85093f, + (q31_t)0x5e80cc7c, (q31_t)0x5e7c8f7f, (q31_t)0x5e785247, (q31_t)0x5e7414d5, + (q31_t)0x5e6fd729, (q31_t)0x5e6b9943, (q31_t)0x5e675b22, (q31_t)0x5e631cc7, + (q31_t)0x5e5ede32, (q31_t)0x5e5a9f62, (q31_t)0x5e566059, (q31_t)0x5e522115, + (q31_t)0x5e4de197, (q31_t)0x5e49a1df, (q31_t)0x5e4561ed, (q31_t)0x5e4121c0, + (q31_t)0x5e3ce15a, (q31_t)0x5e38a0b9, (q31_t)0x5e345fde, (q31_t)0x5e301ec9, + (q31_t)0x5e2bdd7a, (q31_t)0x5e279bf1, (q31_t)0x5e235a2e, (q31_t)0x5e1f1830, + (q31_t)0x5e1ad5f9, (q31_t)0x5e169388, (q31_t)0x5e1250dc, (q31_t)0x5e0e0df7, + (q31_t)0x5e09cad7, (q31_t)0x5e05877e, (q31_t)0x5e0143ea, (q31_t)0x5dfd001d, + (q31_t)0x5df8bc15, (q31_t)0x5df477d4, (q31_t)0x5df03359, (q31_t)0x5debeea3, + (q31_t)0x5de7a9b4, (q31_t)0x5de3648b, (q31_t)0x5ddf1f28, (q31_t)0x5ddad98b, + (q31_t)0x5dd693b4, (q31_t)0x5dd24da3, (q31_t)0x5dce0759, (q31_t)0x5dc9c0d4, + (q31_t)0x5dc57a16, (q31_t)0x5dc1331d, (q31_t)0x5dbcebeb, (q31_t)0x5db8a480, + (q31_t)0x5db45cda, (q31_t)0x5db014fa, (q31_t)0x5dabcce1, (q31_t)0x5da7848e, + (q31_t)0x5da33c01, (q31_t)0x5d9ef33b, (q31_t)0x5d9aaa3a, (q31_t)0x5d966100, + (q31_t)0x5d92178d, (q31_t)0x5d8dcddf, (q31_t)0x5d8983f8, (q31_t)0x5d8539d7, + (q31_t)0x5d80ef7c, (q31_t)0x5d7ca4e8, (q31_t)0x5d785a1a, (q31_t)0x5d740f12, + (q31_t)0x5d6fc3d1, (q31_t)0x5d6b7856, (q31_t)0x5d672ca2, (q31_t)0x5d62e0b4, + (q31_t)0x5d5e948c, (q31_t)0x5d5a482a, (q31_t)0x5d55fb90, (q31_t)0x5d51aebb, + (q31_t)0x5d4d61ad, (q31_t)0x5d491465, (q31_t)0x5d44c6e4, (q31_t)0x5d40792a, + (q31_t)0x5d3c2b35, (q31_t)0x5d37dd08, (q31_t)0x5d338ea0, (q31_t)0x5d2f4000, + (q31_t)0x5d2af125, (q31_t)0x5d26a212, (q31_t)0x5d2252c5, (q31_t)0x5d1e033e, + (q31_t)0x5d19b37e, (q31_t)0x5d156385, (q31_t)0x5d111352, (q31_t)0x5d0cc2e5, + (q31_t)0x5d087240, (q31_t)0x5d042161, (q31_t)0x5cffd048, (q31_t)0x5cfb7ef7, + (q31_t)0x5cf72d6b, (q31_t)0x5cf2dba7, (q31_t)0x5cee89a9, (q31_t)0x5cea3772, + (q31_t)0x5ce5e501, (q31_t)0x5ce19258, (q31_t)0x5cdd3f75, (q31_t)0x5cd8ec58, + (q31_t)0x5cd49903, (q31_t)0x5cd04574, (q31_t)0x5ccbf1ab, (q31_t)0x5cc79daa, + (q31_t)0x5cc3496f, (q31_t)0x5cbef4fc, (q31_t)0x5cbaa04f, (q31_t)0x5cb64b68, + (q31_t)0x5cb1f649, (q31_t)0x5cada0f0, (q31_t)0x5ca94b5e, (q31_t)0x5ca4f594, + (q31_t)0x5ca09f8f, (q31_t)0x5c9c4952, (q31_t)0x5c97f2dc, (q31_t)0x5c939c2c, + (q31_t)0x5c8f4544, (q31_t)0x5c8aee22, (q31_t)0x5c8696c7, (q31_t)0x5c823f34, + (q31_t)0x5c7de767, (q31_t)0x5c798f61, (q31_t)0x5c753722, (q31_t)0x5c70deaa, + (q31_t)0x5c6c85f9, (q31_t)0x5c682d0f, (q31_t)0x5c63d3eb, (q31_t)0x5c5f7a8f, + (q31_t)0x5c5b20fa, (q31_t)0x5c56c72c, (q31_t)0x5c526d25, (q31_t)0x5c4e12e5, + (q31_t)0x5c49b86d, (q31_t)0x5c455dbb, (q31_t)0x5c4102d0, (q31_t)0x5c3ca7ad, + (q31_t)0x5c384c50, (q31_t)0x5c33f0bb, (q31_t)0x5c2f94ec, (q31_t)0x5c2b38e5, + (q31_t)0x5c26dca5, (q31_t)0x5c22802c, (q31_t)0x5c1e237b, (q31_t)0x5c19c690, + (q31_t)0x5c15696d, (q31_t)0x5c110c11, (q31_t)0x5c0cae7c, (q31_t)0x5c0850ae, + (q31_t)0x5c03f2a8, (q31_t)0x5bff9469, (q31_t)0x5bfb35f1, (q31_t)0x5bf6d740, + (q31_t)0x5bf27857, (q31_t)0x5bee1935, (q31_t)0x5be9b9da, (q31_t)0x5be55a46, + (q31_t)0x5be0fa7a, (q31_t)0x5bdc9a75, (q31_t)0x5bd83a37, (q31_t)0x5bd3d9c1, + (q31_t)0x5bcf7912, (q31_t)0x5bcb182b, (q31_t)0x5bc6b70b, (q31_t)0x5bc255b2, + (q31_t)0x5bbdf421, (q31_t)0x5bb99257, (q31_t)0x5bb53054, (q31_t)0x5bb0ce19, + (q31_t)0x5bac6ba6, (q31_t)0x5ba808f9, (q31_t)0x5ba3a615, (q31_t)0x5b9f42f7, + (q31_t)0x5b9adfa2, (q31_t)0x5b967c13, (q31_t)0x5b92184d, (q31_t)0x5b8db44d, + (q31_t)0x5b895016, (q31_t)0x5b84eba6, (q31_t)0x5b8086fd, (q31_t)0x5b7c221c, + (q31_t)0x5b77bd02, (q31_t)0x5b7357b0, (q31_t)0x5b6ef226, (q31_t)0x5b6a8c63, + (q31_t)0x5b662668, (q31_t)0x5b61c035, (q31_t)0x5b5d59c9, (q31_t)0x5b58f324, + (q31_t)0x5b548c48, (q31_t)0x5b502533, (q31_t)0x5b4bbde6, (q31_t)0x5b475660, + (q31_t)0x5b42eea2, (q31_t)0x5b3e86ac, (q31_t)0x5b3a1e7e, (q31_t)0x5b35b617, + (q31_t)0x5b314d78, (q31_t)0x5b2ce4a1, (q31_t)0x5b287b91, (q31_t)0x5b241249, + (q31_t)0x5b1fa8c9, (q31_t)0x5b1b3f11, (q31_t)0x5b16d521, (q31_t)0x5b126af8, + (q31_t)0x5b0e0098, (q31_t)0x5b0995ff, (q31_t)0x5b052b2e, (q31_t)0x5b00c025, + (q31_t)0x5afc54e3, (q31_t)0x5af7e96a, (q31_t)0x5af37db8, (q31_t)0x5aef11cf, + (q31_t)0x5aeaa5ad, (q31_t)0x5ae63953, (q31_t)0x5ae1ccc1, (q31_t)0x5add5ff7, + (q31_t)0x5ad8f2f5, (q31_t)0x5ad485bb, (q31_t)0x5ad01849, (q31_t)0x5acbaa9f, + (q31_t)0x5ac73cbd, (q31_t)0x5ac2cea3, (q31_t)0x5abe6050, (q31_t)0x5ab9f1c6, + (q31_t)0x5ab58304, (q31_t)0x5ab1140a, (q31_t)0x5aaca4d8, (q31_t)0x5aa8356f, + (q31_t)0x5aa3c5cd, (q31_t)0x5a9f55f3, (q31_t)0x5a9ae5e2, (q31_t)0x5a967598, + (q31_t)0x5a920517, (q31_t)0x5a8d945d, (q31_t)0x5a89236c, (q31_t)0x5a84b243, + (q31_t)0x5a8040e3, (q31_t)0x5a7bcf4a, (q31_t)0x5a775d7a, (q31_t)0x5a72eb71, + (q31_t)0x5a6e7931, (q31_t)0x5a6a06ba, (q31_t)0x5a65940a, (q31_t)0x5a612123, + (q31_t)0x5a5cae04, (q31_t)0x5a583aad, (q31_t)0x5a53c71e, (q31_t)0x5a4f5358, + (q31_t)0x5a4adf5a, (q31_t)0x5a466b24, (q31_t)0x5a41f6b7, (q31_t)0x5a3d8212, + (q31_t)0x5a390d35, (q31_t)0x5a349821, (q31_t)0x5a3022d5, (q31_t)0x5a2bad51, + (q31_t)0x5a273796, (q31_t)0x5a22c1a3, (q31_t)0x5a1e4b79, (q31_t)0x5a19d517, + (q31_t)0x5a155e7d, (q31_t)0x5a10e7ac, (q31_t)0x5a0c70a3, (q31_t)0x5a07f963, + (q31_t)0x5a0381eb, (q31_t)0x59ff0a3c, (q31_t)0x59fa9255, (q31_t)0x59f61a36, + (q31_t)0x59f1a1e0, (q31_t)0x59ed2953, (q31_t)0x59e8b08e, (q31_t)0x59e43792, + (q31_t)0x59dfbe5e, (q31_t)0x59db44f3, (q31_t)0x59d6cb50, (q31_t)0x59d25176, + (q31_t)0x59cdd765, (q31_t)0x59c95d1c, (q31_t)0x59c4e29c, (q31_t)0x59c067e4, + (q31_t)0x59bbecf5, (q31_t)0x59b771cf, (q31_t)0x59b2f671, (q31_t)0x59ae7add, + (q31_t)0x59a9ff10, (q31_t)0x59a5830d, (q31_t)0x59a106d2, (q31_t)0x599c8a60, + (q31_t)0x59980db6, (q31_t)0x599390d5, (q31_t)0x598f13bd, (q31_t)0x598a966e, + (q31_t)0x598618e8, (q31_t)0x59819b2a, (q31_t)0x597d1d35, (q31_t)0x59789f09, + (q31_t)0x597420a6, (q31_t)0x596fa20b, (q31_t)0x596b233a, (q31_t)0x5966a431, + (q31_t)0x596224f1, (q31_t)0x595da57a, (q31_t)0x595925cc, (q31_t)0x5954a5e6, + (q31_t)0x595025ca, (q31_t)0x594ba576, (q31_t)0x594724ec, (q31_t)0x5942a42a, + (q31_t)0x593e2331, (q31_t)0x5939a202, (q31_t)0x5935209b, (q31_t)0x59309efd, + (q31_t)0x592c1d28, (q31_t)0x59279b1c, (q31_t)0x592318d9, (q31_t)0x591e9660, + (q31_t)0x591a13af, (q31_t)0x591590c7, (q31_t)0x59110da8, (q31_t)0x590c8a53, + (q31_t)0x590806c6, (q31_t)0x59038302, (q31_t)0x58feff08, (q31_t)0x58fa7ad7, + (q31_t)0x58f5f66e, (q31_t)0x58f171cf, (q31_t)0x58ececf9, (q31_t)0x58e867ed, + (q31_t)0x58e3e2a9, (q31_t)0x58df5d2e, (q31_t)0x58dad77d, (q31_t)0x58d65195, + (q31_t)0x58d1cb76, (q31_t)0x58cd4520, (q31_t)0x58c8be94, (q31_t)0x58c437d1, + (q31_t)0x58bfb0d7, (q31_t)0x58bb29a6, (q31_t)0x58b6a23e, (q31_t)0x58b21aa0, + (q31_t)0x58ad92cb, (q31_t)0x58a90ac0, (q31_t)0x58a4827d, (q31_t)0x589ffa04, + (q31_t)0x589b7155, (q31_t)0x5896e86f, (q31_t)0x58925f52, (q31_t)0x588dd5fe, + (q31_t)0x58894c74, (q31_t)0x5884c2b3, (q31_t)0x588038bb, (q31_t)0x587bae8d, + (q31_t)0x58772429, (q31_t)0x5872998e, (q31_t)0x586e0ebc, (q31_t)0x586983b4, + (q31_t)0x5864f875, (q31_t)0x58606d00, (q31_t)0x585be154, (q31_t)0x58575571, + (q31_t)0x5852c958, (q31_t)0x584e3d09, (q31_t)0x5849b083, (q31_t)0x584523c7, + (q31_t)0x584096d4, (q31_t)0x583c09ab, (q31_t)0x58377c4c, (q31_t)0x5832eeb6, + (q31_t)0x582e60e9, (q31_t)0x5829d2e6, (q31_t)0x582544ad, (q31_t)0x5820b63e, + (q31_t)0x581c2798, (q31_t)0x581798bb, (q31_t)0x581309a9, (q31_t)0x580e7a60, + (q31_t)0x5809eae1, (q31_t)0x58055b2b, (q31_t)0x5800cb3f, (q31_t)0x57fc3b1d, + (q31_t)0x57f7aac5, (q31_t)0x57f31a36, (q31_t)0x57ee8971, (q31_t)0x57e9f876, + (q31_t)0x57e56744, (q31_t)0x57e0d5dd, (q31_t)0x57dc443f, (q31_t)0x57d7b26b, + (q31_t)0x57d32061, (q31_t)0x57ce8e20, (q31_t)0x57c9fbaa, (q31_t)0x57c568fd, + (q31_t)0x57c0d61a, (q31_t)0x57bc4301, (q31_t)0x57b7afb2, (q31_t)0x57b31c2d, + (q31_t)0x57ae8872, (q31_t)0x57a9f480, (q31_t)0x57a56059, (q31_t)0x57a0cbfb, + (q31_t)0x579c3768, (q31_t)0x5797a29e, (q31_t)0x57930d9e, (q31_t)0x578e7869, + (q31_t)0x5789e2fd, (q31_t)0x57854d5b, (q31_t)0x5780b784, (q31_t)0x577c2176, + (q31_t)0x57778b32, (q31_t)0x5772f4b9, (q31_t)0x576e5e09, (q31_t)0x5769c724, + (q31_t)0x57653009, (q31_t)0x576098b7, (q31_t)0x575c0130, (q31_t)0x57576973, + (q31_t)0x5752d180, (q31_t)0x574e3957, (q31_t)0x5749a0f9, (q31_t)0x57450864, + (q31_t)0x57406f9a, (q31_t)0x573bd69a, (q31_t)0x57373d64, (q31_t)0x5732a3f8, + (q31_t)0x572e0a56, (q31_t)0x5729707f, (q31_t)0x5724d672, (q31_t)0x57203c2f, + (q31_t)0x571ba1b7, (q31_t)0x57170708, (q31_t)0x57126c24, (q31_t)0x570dd10a, + (q31_t)0x570935bb, (q31_t)0x57049a36, (q31_t)0x56fffe7b, (q31_t)0x56fb628b, + (q31_t)0x56f6c664, (q31_t)0x56f22a09, (q31_t)0x56ed8d77, (q31_t)0x56e8f0b0, + (q31_t)0x56e453b4, (q31_t)0x56dfb681, (q31_t)0x56db1919, (q31_t)0x56d67b7c, + (q31_t)0x56d1dda9, (q31_t)0x56cd3fa1, (q31_t)0x56c8a162, (q31_t)0x56c402ef, + (q31_t)0x56bf6446, (q31_t)0x56bac567, (q31_t)0x56b62653, (q31_t)0x56b18709, + (q31_t)0x56ace78a, (q31_t)0x56a847d6, (q31_t)0x56a3a7ec, (q31_t)0x569f07cc, + (q31_t)0x569a6777, (q31_t)0x5695c6ed, (q31_t)0x5691262d, (q31_t)0x568c8538, + (q31_t)0x5687e40e, (q31_t)0x568342ae, (q31_t)0x567ea118, (q31_t)0x5679ff4e, + (q31_t)0x56755d4e, (q31_t)0x5670bb19, (q31_t)0x566c18ae, (q31_t)0x5667760e, + (q31_t)0x5662d339, (q31_t)0x565e302e, (q31_t)0x56598cee, (q31_t)0x5654e979, + (q31_t)0x565045cf, (q31_t)0x564ba1f0, (q31_t)0x5646fddb, (q31_t)0x56425991, + (q31_t)0x563db512, (q31_t)0x5639105d, (q31_t)0x56346b74, (q31_t)0x562fc655, + (q31_t)0x562b2101, (q31_t)0x56267b78, (q31_t)0x5621d5ba, (q31_t)0x561d2fc6, + (q31_t)0x5618899e, (q31_t)0x5613e340, (q31_t)0x560f3cae, (q31_t)0x560a95e6, + (q31_t)0x5605eee9, (q31_t)0x560147b7, (q31_t)0x55fca050, (q31_t)0x55f7f8b4, + (q31_t)0x55f350e3, (q31_t)0x55eea8dd, (q31_t)0x55ea00a2, (q31_t)0x55e55832, + (q31_t)0x55e0af8d, (q31_t)0x55dc06b3, (q31_t)0x55d75da4, (q31_t)0x55d2b460, + (q31_t)0x55ce0ae7, (q31_t)0x55c96139, (q31_t)0x55c4b757, (q31_t)0x55c00d3f, + (q31_t)0x55bb62f3, (q31_t)0x55b6b871, (q31_t)0x55b20dbb, (q31_t)0x55ad62d0, + (q31_t)0x55a8b7b0, (q31_t)0x55a40c5b, (q31_t)0x559f60d1, (q31_t)0x559ab513, + (q31_t)0x55960920, (q31_t)0x55915cf8, (q31_t)0x558cb09b, (q31_t)0x55880409, + (q31_t)0x55835743, (q31_t)0x557eaa48, (q31_t)0x5579fd18, (q31_t)0x55754fb3, + (q31_t)0x5570a21a, (q31_t)0x556bf44c, (q31_t)0x55674649, (q31_t)0x55629812, + (q31_t)0x555de9a6, (q31_t)0x55593b05, (q31_t)0x55548c30, (q31_t)0x554fdd26, + (q31_t)0x554b2de7, (q31_t)0x55467e74, (q31_t)0x5541cecc, (q31_t)0x553d1ef0, + (q31_t)0x55386edf, (q31_t)0x5533be99, (q31_t)0x552f0e1f, (q31_t)0x552a5d70, + (q31_t)0x5525ac8d, (q31_t)0x5520fb75, (q31_t)0x551c4a29, (q31_t)0x551798a8, + (q31_t)0x5512e6f3, (q31_t)0x550e3509, (q31_t)0x550982eb, (q31_t)0x5504d099, + (q31_t)0x55001e12, (q31_t)0x54fb6b56, (q31_t)0x54f6b866, (q31_t)0x54f20542, + (q31_t)0x54ed51e9, (q31_t)0x54e89e5c, (q31_t)0x54e3ea9a, (q31_t)0x54df36a5, + (q31_t)0x54da827a, (q31_t)0x54d5ce1c, (q31_t)0x54d11989, (q31_t)0x54cc64c2, + (q31_t)0x54c7afc6, (q31_t)0x54c2fa96, (q31_t)0x54be4532, (q31_t)0x54b98f9a, + (q31_t)0x54b4d9cd, (q31_t)0x54b023cc, (q31_t)0x54ab6d97, (q31_t)0x54a6b72e, + (q31_t)0x54a20090, (q31_t)0x549d49bf, (q31_t)0x549892b9, (q31_t)0x5493db7f, + (q31_t)0x548f2410, (q31_t)0x548a6c6e, (q31_t)0x5485b497, (q31_t)0x5480fc8c, + (q31_t)0x547c444d, (q31_t)0x54778bda, (q31_t)0x5472d333, (q31_t)0x546e1a58, + (q31_t)0x54696149, (q31_t)0x5464a805, (q31_t)0x545fee8e, (q31_t)0x545b34e3, + (q31_t)0x54567b03, (q31_t)0x5451c0f0, (q31_t)0x544d06a8, (q31_t)0x54484c2d, + (q31_t)0x5443917d, (q31_t)0x543ed699, (q31_t)0x543a1b82, (q31_t)0x54356037, + (q31_t)0x5430a4b7, (q31_t)0x542be904, (q31_t)0x54272d1d, (q31_t)0x54227102, + (q31_t)0x541db4b3, (q31_t)0x5418f830, (q31_t)0x54143b79, (q31_t)0x540f7e8e, + (q31_t)0x540ac170, (q31_t)0x5406041d, (q31_t)0x54014697, (q31_t)0x53fc88dd, + (q31_t)0x53f7caef, (q31_t)0x53f30cce, (q31_t)0x53ee4e78, (q31_t)0x53e98fef, + (q31_t)0x53e4d132, (q31_t)0x53e01242, (q31_t)0x53db531d, (q31_t)0x53d693c5, + (q31_t)0x53d1d439, (q31_t)0x53cd147a, (q31_t)0x53c85486, (q31_t)0x53c3945f, + (q31_t)0x53bed405, (q31_t)0x53ba1377, (q31_t)0x53b552b5, (q31_t)0x53b091bf, + (q31_t)0x53abd096, (q31_t)0x53a70f39, (q31_t)0x53a24da9, (q31_t)0x539d8be5, + (q31_t)0x5398c9ed, (q31_t)0x539407c2, (q31_t)0x538f4564, (q31_t)0x538a82d1, + (q31_t)0x5385c00c, (q31_t)0x5380fd12, (q31_t)0x537c39e6, (q31_t)0x53777685, + (q31_t)0x5372b2f2, (q31_t)0x536def2a, (q31_t)0x53692b30, (q31_t)0x53646701, + (q31_t)0x535fa2a0, (q31_t)0x535ade0b, (q31_t)0x53561942, (q31_t)0x53515447, + (q31_t)0x534c8f17, (q31_t)0x5347c9b5, (q31_t)0x5343041f, (q31_t)0x533e3e55, + (q31_t)0x53397859, (q31_t)0x5334b229, (q31_t)0x532febc5, (q31_t)0x532b252f, + (q31_t)0x53265e65, (q31_t)0x53219767, (q31_t)0x531cd037, (q31_t)0x531808d3, + (q31_t)0x5313413c, (q31_t)0x530e7972, (q31_t)0x5309b174, (q31_t)0x5304e943, + (q31_t)0x530020df, (q31_t)0x52fb5848, (q31_t)0x52f68f7e, (q31_t)0x52f1c680, + (q31_t)0x52ecfd4f, (q31_t)0x52e833ec, (q31_t)0x52e36a55, (q31_t)0x52dea08a, + (q31_t)0x52d9d68d, (q31_t)0x52d50c5d, (q31_t)0x52d041f9, (q31_t)0x52cb7763, + (q31_t)0x52c6ac99, (q31_t)0x52c1e19d, (q31_t)0x52bd166d, (q31_t)0x52b84b0a, + (q31_t)0x52b37f74, (q31_t)0x52aeb3ac, (q31_t)0x52a9e7b0, (q31_t)0x52a51b81, + (q31_t)0x52a04f1f, (q31_t)0x529b828a, (q31_t)0x5296b5c3, (q31_t)0x5291e8c8, + (q31_t)0x528d1b9b, (q31_t)0x52884e3a, (q31_t)0x528380a7, (q31_t)0x527eb2e0, + (q31_t)0x5279e4e7, (q31_t)0x527516bb, (q31_t)0x5270485c, (q31_t)0x526b79ca, + (q31_t)0x5266ab06, (q31_t)0x5261dc0e, (q31_t)0x525d0ce4, (q31_t)0x52583d87, + (q31_t)0x52536df7, (q31_t)0x524e9e34, (q31_t)0x5249ce3f, (q31_t)0x5244fe17, + (q31_t)0x52402dbc, (q31_t)0x523b5d2e, (q31_t)0x52368c6e, (q31_t)0x5231bb7b, + (q31_t)0x522cea55, (q31_t)0x522818fc, (q31_t)0x52234771, (q31_t)0x521e75b3, + (q31_t)0x5219a3c3, (q31_t)0x5214d1a0, (q31_t)0x520fff4a, (q31_t)0x520b2cc2, + (q31_t)0x52065a07, (q31_t)0x52018719, (q31_t)0x51fcb3f9, (q31_t)0x51f7e0a6, + (q31_t)0x51f30d21, (q31_t)0x51ee3969, (q31_t)0x51e9657e, (q31_t)0x51e49162, + (q31_t)0x51dfbd12, (q31_t)0x51dae890, (q31_t)0x51d613dc, (q31_t)0x51d13ef5, + (q31_t)0x51cc69db, (q31_t)0x51c79490, (q31_t)0x51c2bf11, (q31_t)0x51bde960, + (q31_t)0x51b9137d, (q31_t)0x51b43d68, (q31_t)0x51af6720, (q31_t)0x51aa90a5, + (q31_t)0x51a5b9f9, (q31_t)0x51a0e31a, (q31_t)0x519c0c08, (q31_t)0x519734c4, + (q31_t)0x51925d4e, (q31_t)0x518d85a6, (q31_t)0x5188adcb, (q31_t)0x5183d5be, + (q31_t)0x517efd7f, (q31_t)0x517a250d, (q31_t)0x51754c69, (q31_t)0x51707393, + (q31_t)0x516b9a8b, (q31_t)0x5166c150, (q31_t)0x5161e7e4, (q31_t)0x515d0e45, + (q31_t)0x51583473, (q31_t)0x51535a70, (q31_t)0x514e803b, (q31_t)0x5149a5d3, + (q31_t)0x5144cb39, (q31_t)0x513ff06d, (q31_t)0x513b156f, (q31_t)0x51363a3f, + (q31_t)0x51315edd, (q31_t)0x512c8348, (q31_t)0x5127a782, (q31_t)0x5122cb8a, + (q31_t)0x511def5f, (q31_t)0x51191302, (q31_t)0x51143674, (q31_t)0x510f59b3, + (q31_t)0x510a7cc1, (q31_t)0x51059f9c, (q31_t)0x5100c246, (q31_t)0x50fbe4bd, + (q31_t)0x50f70703, (q31_t)0x50f22916, (q31_t)0x50ed4af8, (q31_t)0x50e86ca8, + (q31_t)0x50e38e25, (q31_t)0x50deaf71, (q31_t)0x50d9d08b, (q31_t)0x50d4f173, + (q31_t)0x50d0122a, (q31_t)0x50cb32ae, (q31_t)0x50c65301, (q31_t)0x50c17322, + (q31_t)0x50bc9311, (q31_t)0x50b7b2ce, (q31_t)0x50b2d259, (q31_t)0x50adf1b3, + (q31_t)0x50a910db, (q31_t)0x50a42fd1, (q31_t)0x509f4e95, (q31_t)0x509a6d28, + (q31_t)0x50958b88, (q31_t)0x5090a9b8, (q31_t)0x508bc7b5, (q31_t)0x5086e581, + (q31_t)0x5082031b, (q31_t)0x507d2083, (q31_t)0x50783dba, (q31_t)0x50735abf, + (q31_t)0x506e7793, (q31_t)0x50699435, (q31_t)0x5064b0a5, (q31_t)0x505fcce4, + (q31_t)0x505ae8f1, (q31_t)0x505604cd, (q31_t)0x50512077, (q31_t)0x504c3bef, + (q31_t)0x50475736, (q31_t)0x5042724c, (q31_t)0x503d8d30, (q31_t)0x5038a7e2, + (q31_t)0x5033c263, (q31_t)0x502edcb2, (q31_t)0x5029f6d1, (q31_t)0x502510bd, + (q31_t)0x50202a78, (q31_t)0x501b4402, (q31_t)0x50165d5a, (q31_t)0x50117681, + (q31_t)0x500c8f77, (q31_t)0x5007a83b, (q31_t)0x5002c0cd, (q31_t)0x4ffdd92f, + (q31_t)0x4ff8f15f, (q31_t)0x4ff4095e, (q31_t)0x4fef212b, (q31_t)0x4fea38c7, + (q31_t)0x4fe55032, (q31_t)0x4fe0676c, (q31_t)0x4fdb7e74, (q31_t)0x4fd6954b, + (q31_t)0x4fd1abf0, (q31_t)0x4fccc265, (q31_t)0x4fc7d8a8, (q31_t)0x4fc2eeba, + (q31_t)0x4fbe049b, (q31_t)0x4fb91a4b, (q31_t)0x4fb42fc9, (q31_t)0x4faf4517, + (q31_t)0x4faa5a33, (q31_t)0x4fa56f1e, (q31_t)0x4fa083d8, (q31_t)0x4f9b9861, + (q31_t)0x4f96acb8, (q31_t)0x4f91c0df, (q31_t)0x4f8cd4d4, (q31_t)0x4f87e899, + (q31_t)0x4f82fc2c, (q31_t)0x4f7e0f8f, (q31_t)0x4f7922c0, (q31_t)0x4f7435c0, + (q31_t)0x4f6f488f, (q31_t)0x4f6a5b2e, (q31_t)0x4f656d9b, (q31_t)0x4f607fd7, + (q31_t)0x4f5b91e3, (q31_t)0x4f56a3bd, (q31_t)0x4f51b566, (q31_t)0x4f4cc6df, + (q31_t)0x4f47d827, (q31_t)0x4f42e93d, (q31_t)0x4f3dfa23, (q31_t)0x4f390ad8, + (q31_t)0x4f341b5c, (q31_t)0x4f2f2baf, (q31_t)0x4f2a3bd2, (q31_t)0x4f254bc3, + (q31_t)0x4f205b84, (q31_t)0x4f1b6b14, (q31_t)0x4f167a73, (q31_t)0x4f1189a1, + (q31_t)0x4f0c989f, (q31_t)0x4f07a76b, (q31_t)0x4f02b608, (q31_t)0x4efdc473, + (q31_t)0x4ef8d2ad, (q31_t)0x4ef3e0b7, (q31_t)0x4eeeee90, (q31_t)0x4ee9fc39, + (q31_t)0x4ee509b1, (q31_t)0x4ee016f8, (q31_t)0x4edb240e, (q31_t)0x4ed630f4, + (q31_t)0x4ed13da9, (q31_t)0x4ecc4a2e, (q31_t)0x4ec75682, (q31_t)0x4ec262a5, + (q31_t)0x4ebd6e98, (q31_t)0x4eb87a5a, (q31_t)0x4eb385ec, (q31_t)0x4eae914d, + (q31_t)0x4ea99c7d, (q31_t)0x4ea4a77d, (q31_t)0x4e9fb24d, (q31_t)0x4e9abcec, + (q31_t)0x4e95c75b, (q31_t)0x4e90d199, (q31_t)0x4e8bdba6, (q31_t)0x4e86e583, + (q31_t)0x4e81ef30, (q31_t)0x4e7cf8ac, (q31_t)0x4e7801f8, (q31_t)0x4e730b14, + (q31_t)0x4e6e13ff, (q31_t)0x4e691cba, (q31_t)0x4e642544, (q31_t)0x4e5f2d9e, + (q31_t)0x4e5a35c7, (q31_t)0x4e553dc1, (q31_t)0x4e50458a, (q31_t)0x4e4b4d22, + (q31_t)0x4e46548b, (q31_t)0x4e415bc3, (q31_t)0x4e3c62cb, (q31_t)0x4e3769a2, + (q31_t)0x4e32704a, (q31_t)0x4e2d76c1, (q31_t)0x4e287d08, (q31_t)0x4e23831e, + (q31_t)0x4e1e8905, (q31_t)0x4e198ebb, (q31_t)0x4e149441, (q31_t)0x4e0f9997, + (q31_t)0x4e0a9ebd, (q31_t)0x4e05a3b2, (q31_t)0x4e00a878, (q31_t)0x4dfbad0d, + (q31_t)0x4df6b173, (q31_t)0x4df1b5a8, (q31_t)0x4decb9ad, (q31_t)0x4de7bd82, + (q31_t)0x4de2c127, (q31_t)0x4dddc49c, (q31_t)0x4dd8c7e1, (q31_t)0x4dd3caf6, + (q31_t)0x4dcecdda, (q31_t)0x4dc9d08f, (q31_t)0x4dc4d314, (q31_t)0x4dbfd569, + (q31_t)0x4dbad78e, (q31_t)0x4db5d983, (q31_t)0x4db0db48, (q31_t)0x4dabdcdd, + (q31_t)0x4da6de43, (q31_t)0x4da1df78, (q31_t)0x4d9ce07d, (q31_t)0x4d97e153, + (q31_t)0x4d92e1f9, (q31_t)0x4d8de26f, (q31_t)0x4d88e2b5, (q31_t)0x4d83e2cb, + (q31_t)0x4d7ee2b1, (q31_t)0x4d79e268, (q31_t)0x4d74e1ef, (q31_t)0x4d6fe146, + (q31_t)0x4d6ae06d, (q31_t)0x4d65df64, (q31_t)0x4d60de2c, (q31_t)0x4d5bdcc4, + (q31_t)0x4d56db2d, (q31_t)0x4d51d965, (q31_t)0x4d4cd76e, (q31_t)0x4d47d547, + (q31_t)0x4d42d2f1, (q31_t)0x4d3dd06b, (q31_t)0x4d38cdb5, (q31_t)0x4d33cad0, + (q31_t)0x4d2ec7bb, (q31_t)0x4d29c476, (q31_t)0x4d24c102, (q31_t)0x4d1fbd5e, + (q31_t)0x4d1ab98b, (q31_t)0x4d15b588, (q31_t)0x4d10b155, (q31_t)0x4d0bacf3, + (q31_t)0x4d06a862, (q31_t)0x4d01a3a0, (q31_t)0x4cfc9eb0, (q31_t)0x4cf79990, + (q31_t)0x4cf29440, (q31_t)0x4ced8ec1, (q31_t)0x4ce88913, (q31_t)0x4ce38335, + (q31_t)0x4cde7d28, (q31_t)0x4cd976eb, (q31_t)0x4cd4707f, (q31_t)0x4ccf69e3, + (q31_t)0x4cca6318, (q31_t)0x4cc55c1e, (q31_t)0x4cc054f4, (q31_t)0x4cbb4d9b, + (q31_t)0x4cb64613, (q31_t)0x4cb13e5b, (q31_t)0x4cac3674, (q31_t)0x4ca72e5e, + (q31_t)0x4ca22619, (q31_t)0x4c9d1da4, (q31_t)0x4c981500, (q31_t)0x4c930c2d, + (q31_t)0x4c8e032a, (q31_t)0x4c88f9f8, (q31_t)0x4c83f097, (q31_t)0x4c7ee707, + (q31_t)0x4c79dd48, (q31_t)0x4c74d359, (q31_t)0x4c6fc93b, (q31_t)0x4c6abeef, + (q31_t)0x4c65b473, (q31_t)0x4c60a9c8, (q31_t)0x4c5b9eed, (q31_t)0x4c5693e4, + (q31_t)0x4c5188ac, (q31_t)0x4c4c7d44, (q31_t)0x4c4771ae, (q31_t)0x4c4265e8, + (q31_t)0x4c3d59f3, (q31_t)0x4c384dd0, (q31_t)0x4c33417d, (q31_t)0x4c2e34fb, + (q31_t)0x4c29284b, (q31_t)0x4c241b6b, (q31_t)0x4c1f0e5c, (q31_t)0x4c1a011f, + (q31_t)0x4c14f3b2, (q31_t)0x4c0fe617, (q31_t)0x4c0ad84c, (q31_t)0x4c05ca53, + (q31_t)0x4c00bc2b, (q31_t)0x4bfbadd4, (q31_t)0x4bf69f4e, (q31_t)0x4bf19099, + (q31_t)0x4bec81b5, (q31_t)0x4be772a3, (q31_t)0x4be26362, (q31_t)0x4bdd53f2, + (q31_t)0x4bd84453, (q31_t)0x4bd33485, (q31_t)0x4bce2488, (q31_t)0x4bc9145d, + (q31_t)0x4bc40403, (q31_t)0x4bbef37b, (q31_t)0x4bb9e2c3, (q31_t)0x4bb4d1dd, + (q31_t)0x4bafc0c8, (q31_t)0x4baaaf85, (q31_t)0x4ba59e12, (q31_t)0x4ba08c72, + (q31_t)0x4b9b7aa2, (q31_t)0x4b9668a4, (q31_t)0x4b915677, (q31_t)0x4b8c441c, + (q31_t)0x4b873192, (q31_t)0x4b821ed9, (q31_t)0x4b7d0bf2, (q31_t)0x4b77f8dc, + (q31_t)0x4b72e598, (q31_t)0x4b6dd225, (q31_t)0x4b68be84, (q31_t)0x4b63aab4, + (q31_t)0x4b5e96b6, (q31_t)0x4b598289, (q31_t)0x4b546e2d, (q31_t)0x4b4f59a4, + (q31_t)0x4b4a44eb, (q31_t)0x4b453005, (q31_t)0x4b401aef, (q31_t)0x4b3b05ac, + (q31_t)0x4b35f03a, (q31_t)0x4b30da9a, (q31_t)0x4b2bc4cb, (q31_t)0x4b26aece, + (q31_t)0x4b2198a2, (q31_t)0x4b1c8248, (q31_t)0x4b176bc0, (q31_t)0x4b12550a, + (q31_t)0x4b0d3e25, (q31_t)0x4b082712, (q31_t)0x4b030fd1, (q31_t)0x4afdf861, + (q31_t)0x4af8e0c3, (q31_t)0x4af3c8f7, (q31_t)0x4aeeb0fd, (q31_t)0x4ae998d4, + (q31_t)0x4ae4807d, (q31_t)0x4adf67f8, (q31_t)0x4ada4f45, (q31_t)0x4ad53664, + (q31_t)0x4ad01d54, (q31_t)0x4acb0417, (q31_t)0x4ac5eaab, (q31_t)0x4ac0d111, + (q31_t)0x4abbb749, (q31_t)0x4ab69d53, (q31_t)0x4ab1832f, (q31_t)0x4aac68dc, + (q31_t)0x4aa74e5c, (q31_t)0x4aa233ae, (q31_t)0x4a9d18d1, (q31_t)0x4a97fdc7, + (q31_t)0x4a92e28e, (q31_t)0x4a8dc728, (q31_t)0x4a88ab93, (q31_t)0x4a838fd1, + (q31_t)0x4a7e73e0, (q31_t)0x4a7957c2, (q31_t)0x4a743b76, (q31_t)0x4a6f1efc, + (q31_t)0x4a6a0253, (q31_t)0x4a64e57d, (q31_t)0x4a5fc879, (q31_t)0x4a5aab48, + (q31_t)0x4a558de8, (q31_t)0x4a50705a, (q31_t)0x4a4b529f, (q31_t)0x4a4634b6, + (q31_t)0x4a41169f, (q31_t)0x4a3bf85a, (q31_t)0x4a36d9e7, (q31_t)0x4a31bb47, + (q31_t)0x4a2c9c79, (q31_t)0x4a277d7d, (q31_t)0x4a225e53, (q31_t)0x4a1d3efc, + (q31_t)0x4a181f77, (q31_t)0x4a12ffc4, (q31_t)0x4a0ddfe4, (q31_t)0x4a08bfd5, + (q31_t)0x4a039f9a, (q31_t)0x49fe7f30, (q31_t)0x49f95e99, (q31_t)0x49f43dd4, + (q31_t)0x49ef1ce2, (q31_t)0x49e9fbc2, (q31_t)0x49e4da74, (q31_t)0x49dfb8f9, + (q31_t)0x49da9750, (q31_t)0x49d5757a, (q31_t)0x49d05376, (q31_t)0x49cb3145, + (q31_t)0x49c60ee6, (q31_t)0x49c0ec59, (q31_t)0x49bbc9a0, (q31_t)0x49b6a6b8, + (q31_t)0x49b183a3, (q31_t)0x49ac6061, (q31_t)0x49a73cf1, (q31_t)0x49a21954, + (q31_t)0x499cf589, (q31_t)0x4997d191, (q31_t)0x4992ad6c, (q31_t)0x498d8919, + (q31_t)0x49886499, (q31_t)0x49833fec, (q31_t)0x497e1b11, (q31_t)0x4978f609, + (q31_t)0x4973d0d3, (q31_t)0x496eab70, (q31_t)0x496985e0, (q31_t)0x49646023, + (q31_t)0x495f3a38, (q31_t)0x495a1420, (q31_t)0x4954eddb, (q31_t)0x494fc768, + (q31_t)0x494aa0c9, (q31_t)0x494579fc, (q31_t)0x49405302, (q31_t)0x493b2bdb, + (q31_t)0x49360486, (q31_t)0x4930dd05, (q31_t)0x492bb556, (q31_t)0x49268d7a, + (q31_t)0x49216571, (q31_t)0x491c3d3b, (q31_t)0x491714d8, (q31_t)0x4911ec47, + (q31_t)0x490cc38a, (q31_t)0x49079aa0, (q31_t)0x49027188, (q31_t)0x48fd4844, + (q31_t)0x48f81ed2, (q31_t)0x48f2f534, (q31_t)0x48edcb68, (q31_t)0x48e8a170, + (q31_t)0x48e3774a, (q31_t)0x48de4cf8, (q31_t)0x48d92278, (q31_t)0x48d3f7cc, + (q31_t)0x48ceccf3, (q31_t)0x48c9a1ed, (q31_t)0x48c476b9, (q31_t)0x48bf4b59, + (q31_t)0x48ba1fcd, (q31_t)0x48b4f413, (q31_t)0x48afc82c, (q31_t)0x48aa9c19, + (q31_t)0x48a56fd9, (q31_t)0x48a0436c, (q31_t)0x489b16d2, (q31_t)0x4895ea0b, + (q31_t)0x4890bd18, (q31_t)0x488b8ff8, (q31_t)0x488662ab, (q31_t)0x48813531, + (q31_t)0x487c078b, (q31_t)0x4876d9b8, (q31_t)0x4871abb8, (q31_t)0x486c7d8c, + (q31_t)0x48674f33, (q31_t)0x486220ad, (q31_t)0x485cf1fa, (q31_t)0x4857c31b, + (q31_t)0x48529410, (q31_t)0x484d64d7, (q31_t)0x48483572, (q31_t)0x484305e1, + (q31_t)0x483dd623, (q31_t)0x4838a638, (q31_t)0x48337621, (q31_t)0x482e45dd, + (q31_t)0x4829156d, (q31_t)0x4823e4d0, (q31_t)0x481eb407, (q31_t)0x48198311, + (q31_t)0x481451ef, (q31_t)0x480f20a0, (q31_t)0x4809ef25, (q31_t)0x4804bd7e, + (q31_t)0x47ff8baa, (q31_t)0x47fa59a9, (q31_t)0x47f5277d, (q31_t)0x47eff523, + (q31_t)0x47eac29e, (q31_t)0x47e58fec, (q31_t)0x47e05d0e, (q31_t)0x47db2a03, + (q31_t)0x47d5f6cc, (q31_t)0x47d0c369, (q31_t)0x47cb8fd9, (q31_t)0x47c65c1d, + (q31_t)0x47c12835, (q31_t)0x47bbf421, (q31_t)0x47b6bfe0, (q31_t)0x47b18b74, + (q31_t)0x47ac56da, (q31_t)0x47a72215, (q31_t)0x47a1ed24, (q31_t)0x479cb806, + (q31_t)0x479782bc, (q31_t)0x47924d46, (q31_t)0x478d17a4, (q31_t)0x4787e1d6, + (q31_t)0x4782abdb, (q31_t)0x477d75b5, (q31_t)0x47783f62, (q31_t)0x477308e3, + (q31_t)0x476dd239, (q31_t)0x47689b62, (q31_t)0x4763645f, (q31_t)0x475e2d30, + (q31_t)0x4758f5d5, (q31_t)0x4753be4e, (q31_t)0x474e869b, (q31_t)0x47494ebc, + (q31_t)0x474416b1, (q31_t)0x473ede7a, (q31_t)0x4739a617, (q31_t)0x47346d89, + (q31_t)0x472f34ce, (q31_t)0x4729fbe7, (q31_t)0x4724c2d5, (q31_t)0x471f8996, + (q31_t)0x471a502c, (q31_t)0x47151696, (q31_t)0x470fdcd4, (q31_t)0x470aa2e6, + (q31_t)0x470568cd, (q31_t)0x47002e87, (q31_t)0x46faf416, (q31_t)0x46f5b979, + (q31_t)0x46f07eb0, (q31_t)0x46eb43bc, (q31_t)0x46e6089b, (q31_t)0x46e0cd4f, + (q31_t)0x46db91d8, (q31_t)0x46d65634, (q31_t)0x46d11a65, (q31_t)0x46cbde6a, + (q31_t)0x46c6a244, (q31_t)0x46c165f1, (q31_t)0x46bc2974, (q31_t)0x46b6ecca, + (q31_t)0x46b1aff5, (q31_t)0x46ac72f4, (q31_t)0x46a735c8, (q31_t)0x46a1f870, + (q31_t)0x469cbaed, (q31_t)0x46977d3e, (q31_t)0x46923f63, (q31_t)0x468d015d, + (q31_t)0x4687c32c, (q31_t)0x468284cf, (q31_t)0x467d4646, (q31_t)0x46780792, + (q31_t)0x4672c8b3, (q31_t)0x466d89a8, (q31_t)0x46684a71, (q31_t)0x46630b0f, + (q31_t)0x465dcb82, (q31_t)0x46588bc9, (q31_t)0x46534be5, (q31_t)0x464e0bd6, + (q31_t)0x4648cb9b, (q31_t)0x46438b35, (q31_t)0x463e4aa3, (q31_t)0x463909e7, + (q31_t)0x4633c8fe, (q31_t)0x462e87eb, (q31_t)0x462946ac, (q31_t)0x46240542, + (q31_t)0x461ec3ad, (q31_t)0x461981ec, (q31_t)0x46144001, (q31_t)0x460efde9, + (q31_t)0x4609bba7, (q31_t)0x4604793a, (q31_t)0x45ff36a1, (q31_t)0x45f9f3dd, + (q31_t)0x45f4b0ee, (q31_t)0x45ef6dd4, (q31_t)0x45ea2a8f, (q31_t)0x45e4e71f, + (q31_t)0x45dfa383, (q31_t)0x45da5fbc, (q31_t)0x45d51bcb, (q31_t)0x45cfd7ae, + (q31_t)0x45ca9366, (q31_t)0x45c54ef3, (q31_t)0x45c00a55, (q31_t)0x45bac58c, + (q31_t)0x45b58098, (q31_t)0x45b03b79, (q31_t)0x45aaf630, (q31_t)0x45a5b0bb, + (q31_t)0x45a06b1b, (q31_t)0x459b2550, (q31_t)0x4595df5a, (q31_t)0x45909939, + (q31_t)0x458b52ee, (q31_t)0x45860c77, (q31_t)0x4580c5d6, (q31_t)0x457b7f0a, + (q31_t)0x45763813, (q31_t)0x4570f0f1, (q31_t)0x456ba9a4, (q31_t)0x4566622c, + (q31_t)0x45611a8a, (q31_t)0x455bd2bc, (q31_t)0x45568ac4, (q31_t)0x455142a2, + (q31_t)0x454bfa54, (q31_t)0x4546b1dc, (q31_t)0x45416939, (q31_t)0x453c206b, + (q31_t)0x4536d773, (q31_t)0x45318e4f, (q31_t)0x452c4502, (q31_t)0x4526fb89, + (q31_t)0x4521b1e6, (q31_t)0x451c6818, (q31_t)0x45171e20, (q31_t)0x4511d3fd, + (q31_t)0x450c89af, (q31_t)0x45073f37, (q31_t)0x4501f494, (q31_t)0x44fca9c6, + (q31_t)0x44f75ecf, (q31_t)0x44f213ac, (q31_t)0x44ecc85f, (q31_t)0x44e77ce7, + (q31_t)0x44e23145, (q31_t)0x44dce579, (q31_t)0x44d79982, (q31_t)0x44d24d60, + (q31_t)0x44cd0114, (q31_t)0x44c7b49e, (q31_t)0x44c267fd, (q31_t)0x44bd1b32, + (q31_t)0x44b7ce3c, (q31_t)0x44b2811c, (q31_t)0x44ad33d2, (q31_t)0x44a7e65d, + (q31_t)0x44a298be, (q31_t)0x449d4af5, (q31_t)0x4497fd01, (q31_t)0x4492aee3, + (q31_t)0x448d609b, (q31_t)0x44881228, (q31_t)0x4482c38b, (q31_t)0x447d74c4, + (q31_t)0x447825d2, (q31_t)0x4472d6b7, (q31_t)0x446d8771, (q31_t)0x44683801, + (q31_t)0x4462e866, (q31_t)0x445d98a2, (q31_t)0x445848b3, (q31_t)0x4452f89b, + (q31_t)0x444da858, (q31_t)0x444857ea, (q31_t)0x44430753, (q31_t)0x443db692, + (q31_t)0x443865a7, (q31_t)0x44331491, (q31_t)0x442dc351, (q31_t)0x442871e8, + (q31_t)0x44232054, (q31_t)0x441dce96, (q31_t)0x44187caf, (q31_t)0x44132a9d, + (q31_t)0x440dd861, (q31_t)0x440885fc, (q31_t)0x4403336c, (q31_t)0x43fde0b2, + (q31_t)0x43f88dcf, (q31_t)0x43f33ac1, (q31_t)0x43ede78a, (q31_t)0x43e89429, + (q31_t)0x43e3409d, (q31_t)0x43ddece8, (q31_t)0x43d8990a, (q31_t)0x43d34501, + (q31_t)0x43cdf0ce, (q31_t)0x43c89c72, (q31_t)0x43c347eb, (q31_t)0x43bdf33b, + (q31_t)0x43b89e62, (q31_t)0x43b3495e, (q31_t)0x43adf431, (q31_t)0x43a89ed9, + (q31_t)0x43a34959, (q31_t)0x439df3ae, (q31_t)0x43989dda, (q31_t)0x439347dc, + (q31_t)0x438df1b4, (q31_t)0x43889b63, (q31_t)0x438344e8, (q31_t)0x437dee43, + (q31_t)0x43789775, (q31_t)0x4373407d, (q31_t)0x436de95b, (q31_t)0x43689210, + (q31_t)0x43633a9c, (q31_t)0x435de2fd, (q31_t)0x43588b36, (q31_t)0x43533344, + (q31_t)0x434ddb29, (q31_t)0x434882e5, (q31_t)0x43432a77, (q31_t)0x433dd1e0, + (q31_t)0x4338791f, (q31_t)0x43332035, (q31_t)0x432dc721, (q31_t)0x43286de4, + (q31_t)0x4323147d, (q31_t)0x431dbaed, (q31_t)0x43186133, (q31_t)0x43130751, + (q31_t)0x430dad44, (q31_t)0x4308530f, (q31_t)0x4302f8b0, (q31_t)0x42fd9e28, + (q31_t)0x42f84376, (q31_t)0x42f2e89b, (q31_t)0x42ed8d97, (q31_t)0x42e83269, + (q31_t)0x42e2d713, (q31_t)0x42dd7b93, (q31_t)0x42d81fe9, (q31_t)0x42d2c417, + (q31_t)0x42cd681b, (q31_t)0x42c80bf6, (q31_t)0x42c2afa8, (q31_t)0x42bd5331, + (q31_t)0x42b7f690, (q31_t)0x42b299c7, (q31_t)0x42ad3cd4, (q31_t)0x42a7dfb8, + (q31_t)0x42a28273, (q31_t)0x429d2505, (q31_t)0x4297c76e, (q31_t)0x429269ae, + (q31_t)0x428d0bc4, (q31_t)0x4287adb2, (q31_t)0x42824f76, (q31_t)0x427cf112, + (q31_t)0x42779285, (q31_t)0x427233ce, (q31_t)0x426cd4ef, (q31_t)0x426775e6, + (q31_t)0x426216b5, (q31_t)0x425cb75a, (q31_t)0x425757d7, (q31_t)0x4251f82b, + (q31_t)0x424c9856, (q31_t)0x42473858, (q31_t)0x4241d831, (q31_t)0x423c77e1, + (q31_t)0x42371769, (q31_t)0x4231b6c7, (q31_t)0x422c55fd, (q31_t)0x4226f50a, + (q31_t)0x422193ee, (q31_t)0x421c32a9, (q31_t)0x4216d13c, (q31_t)0x42116fa5, + (q31_t)0x420c0de6, (q31_t)0x4206abfe, (q31_t)0x420149ee, (q31_t)0x41fbe7b5, + (q31_t)0x41f68553, (q31_t)0x41f122c8, (q31_t)0x41ebc015, (q31_t)0x41e65d39, + (q31_t)0x41e0fa35, (q31_t)0x41db9707, (q31_t)0x41d633b1, (q31_t)0x41d0d033, + (q31_t)0x41cb6c8c, (q31_t)0x41c608bc, (q31_t)0x41c0a4c4, (q31_t)0x41bb40a3, + (q31_t)0x41b5dc5a, (q31_t)0x41b077e8, (q31_t)0x41ab134e, (q31_t)0x41a5ae8b, + (q31_t)0x41a049a0, (q31_t)0x419ae48c, (q31_t)0x41957f4f, (q31_t)0x419019eb, + (q31_t)0x418ab45d, (q31_t)0x41854ea8, (q31_t)0x417fe8ca, (q31_t)0x417a82c3, + (q31_t)0x41751c94, (q31_t)0x416fb63d, (q31_t)0x416a4fbd, (q31_t)0x4164e916, + (q31_t)0x415f8245, (q31_t)0x415a1b4d, (q31_t)0x4154b42c, (q31_t)0x414f4ce2, + (q31_t)0x4149e571, (q31_t)0x41447dd7, (q31_t)0x413f1615, (q31_t)0x4139ae2b, + (q31_t)0x41344618, (q31_t)0x412edddd, (q31_t)0x4129757b, (q31_t)0x41240cef, + (q31_t)0x411ea43c, (q31_t)0x41193b61, (q31_t)0x4113d25d, (q31_t)0x410e6931, + (q31_t)0x4108ffdd, (q31_t)0x41039661, (q31_t)0x40fe2cbd, (q31_t)0x40f8c2f1, + (q31_t)0x40f358fc, (q31_t)0x40edeee0, (q31_t)0x40e8849b, (q31_t)0x40e31a2f, + (q31_t)0x40ddaf9b, (q31_t)0x40d844de, (q31_t)0x40d2d9f9, (q31_t)0x40cd6eed, + (q31_t)0x40c803b8, (q31_t)0x40c2985c, (q31_t)0x40bd2cd8, (q31_t)0x40b7c12b, + (q31_t)0x40b25557, (q31_t)0x40ace95b, (q31_t)0x40a77d37, (q31_t)0x40a210eb, + (q31_t)0x409ca477, (q31_t)0x409737dc, (q31_t)0x4091cb18, (q31_t)0x408c5e2d, + (q31_t)0x4086f11a, (q31_t)0x408183df, (q31_t)0x407c167c, (q31_t)0x4076a8f1, + (q31_t)0x40713b3f, (q31_t)0x406bcd65, (q31_t)0x40665f63, (q31_t)0x4060f13a, + (q31_t)0x405b82e9, (q31_t)0x40561470, (q31_t)0x4050a5cf, (q31_t)0x404b3707, + (q31_t)0x4045c817, (q31_t)0x404058ff, (q31_t)0x403ae9c0, (q31_t)0x40357a59, + (q31_t)0x40300acb, (q31_t)0x402a9b15, (q31_t)0x40252b37, (q31_t)0x401fbb32, + (q31_t)0x401a4b05, (q31_t)0x4014dab1, (q31_t)0x400f6a35, (q31_t)0x4009f992, + (q31_t)0x400488c7, (q31_t)0x3fff17d5, (q31_t)0x3ff9a6bb, (q31_t)0x3ff4357a, + (q31_t)0x3feec411, (q31_t)0x3fe95281, (q31_t)0x3fe3e0c9, (q31_t)0x3fde6eeb, + (q31_t)0x3fd8fce4, (q31_t)0x3fd38ab6, (q31_t)0x3fce1861, (q31_t)0x3fc8a5e5, + (q31_t)0x3fc33341, (q31_t)0x3fbdc076, (q31_t)0x3fb84d83, (q31_t)0x3fb2da6a, + (q31_t)0x3fad6729, (q31_t)0x3fa7f3c0, (q31_t)0x3fa28031, (q31_t)0x3f9d0c7a, + (q31_t)0x3f97989c, (q31_t)0x3f922496, (q31_t)0x3f8cb06a, (q31_t)0x3f873c16, + (q31_t)0x3f81c79b, (q31_t)0x3f7c52f9, (q31_t)0x3f76de30, (q31_t)0x3f71693f, + (q31_t)0x3f6bf428, (q31_t)0x3f667ee9, (q31_t)0x3f610983, (q31_t)0x3f5b93f6, + (q31_t)0x3f561e42, (q31_t)0x3f50a867, (q31_t)0x3f4b3265, (q31_t)0x3f45bc3c, + (q31_t)0x3f4045ec, (q31_t)0x3f3acf75, (q31_t)0x3f3558d7, (q31_t)0x3f2fe211, + (q31_t)0x3f2a6b25, (q31_t)0x3f24f412, (q31_t)0x3f1f7cd8, (q31_t)0x3f1a0577, + (q31_t)0x3f148def, (q31_t)0x3f0f1640, (q31_t)0x3f099e6b, (q31_t)0x3f04266e, + (q31_t)0x3efeae4a, (q31_t)0x3ef93600, (q31_t)0x3ef3bd8f, (q31_t)0x3eee44f7, + (q31_t)0x3ee8cc38, (q31_t)0x3ee35352, (q31_t)0x3eddda46, (q31_t)0x3ed86113, + (q31_t)0x3ed2e7b9, (q31_t)0x3ecd6e38, (q31_t)0x3ec7f491, (q31_t)0x3ec27ac2, + (q31_t)0x3ebd00cd, (q31_t)0x3eb786b2, (q31_t)0x3eb20c6f, (q31_t)0x3eac9206, + (q31_t)0x3ea71777, (q31_t)0x3ea19cc1, (q31_t)0x3e9c21e4, (q31_t)0x3e96a6e0, + (q31_t)0x3e912bb6, (q31_t)0x3e8bb065, (q31_t)0x3e8634ee, (q31_t)0x3e80b950, + (q31_t)0x3e7b3d8c, (q31_t)0x3e75c1a1, (q31_t)0x3e70458f, (q31_t)0x3e6ac957, + (q31_t)0x3e654cf8, (q31_t)0x3e5fd073, (q31_t)0x3e5a53c8, (q31_t)0x3e54d6f6, + (q31_t)0x3e4f59fe, (q31_t)0x3e49dcdf, (q31_t)0x3e445f99, (q31_t)0x3e3ee22e, + (q31_t)0x3e39649c, (q31_t)0x3e33e6e3, (q31_t)0x3e2e6904, (q31_t)0x3e28eaff, + (q31_t)0x3e236cd4, (q31_t)0x3e1dee82, (q31_t)0x3e18700a, (q31_t)0x3e12f16b, + (q31_t)0x3e0d72a6, (q31_t)0x3e07f3bb, (q31_t)0x3e0274aa, (q31_t)0x3dfcf572, + (q31_t)0x3df77615, (q31_t)0x3df1f691, (q31_t)0x3dec76e6, (q31_t)0x3de6f716, + (q31_t)0x3de1771f, (q31_t)0x3ddbf703, (q31_t)0x3dd676c0, (q31_t)0x3dd0f656, + (q31_t)0x3dcb75c7, (q31_t)0x3dc5f512, (q31_t)0x3dc07436, (q31_t)0x3dbaf335, + (q31_t)0x3db5720d, (q31_t)0x3daff0c0, (q31_t)0x3daa6f4c, (q31_t)0x3da4edb2, + (q31_t)0x3d9f6bf2, (q31_t)0x3d99ea0d, (q31_t)0x3d946801, (q31_t)0x3d8ee5cf, + (q31_t)0x3d896377, (q31_t)0x3d83e0f9, (q31_t)0x3d7e5e56, (q31_t)0x3d78db8c, + (q31_t)0x3d73589d, (q31_t)0x3d6dd587, (q31_t)0x3d68524c, (q31_t)0x3d62ceeb, + (q31_t)0x3d5d4b64, (q31_t)0x3d57c7b7, (q31_t)0x3d5243e4, (q31_t)0x3d4cbfeb, + (q31_t)0x3d473bcd, (q31_t)0x3d41b789, (q31_t)0x3d3c331f, (q31_t)0x3d36ae8f, + (q31_t)0x3d3129da, (q31_t)0x3d2ba4fe, (q31_t)0x3d261ffd, (q31_t)0x3d209ad7, + (q31_t)0x3d1b158a, (q31_t)0x3d159018, (q31_t)0x3d100a80, (q31_t)0x3d0a84c3, + (q31_t)0x3d04fee0, (q31_t)0x3cff78d7, (q31_t)0x3cf9f2a9, (q31_t)0x3cf46c55, + (q31_t)0x3ceee5db, (q31_t)0x3ce95f3c, (q31_t)0x3ce3d877, (q31_t)0x3cde518d, + (q31_t)0x3cd8ca7d, (q31_t)0x3cd34347, (q31_t)0x3ccdbbed, (q31_t)0x3cc8346c, + (q31_t)0x3cc2acc6, (q31_t)0x3cbd24fb, (q31_t)0x3cb79d0a, (q31_t)0x3cb214f4, + (q31_t)0x3cac8cb8, (q31_t)0x3ca70457, (q31_t)0x3ca17bd0, (q31_t)0x3c9bf324, + (q31_t)0x3c966a53, (q31_t)0x3c90e15c, (q31_t)0x3c8b5840, (q31_t)0x3c85cefe, + (q31_t)0x3c804598, (q31_t)0x3c7abc0c, (q31_t)0x3c75325a, (q31_t)0x3c6fa883, + (q31_t)0x3c6a1e87, (q31_t)0x3c649466, (q31_t)0x3c5f0a20, (q31_t)0x3c597fb4, + (q31_t)0x3c53f523, (q31_t)0x3c4e6a6d, (q31_t)0x3c48df91, (q31_t)0x3c435491, + (q31_t)0x3c3dc96b, (q31_t)0x3c383e20, (q31_t)0x3c32b2b0, (q31_t)0x3c2d271b, + (q31_t)0x3c279b61, (q31_t)0x3c220f81, (q31_t)0x3c1c837d, (q31_t)0x3c16f753, + (q31_t)0x3c116b04, (q31_t)0x3c0bde91, (q31_t)0x3c0651f8, (q31_t)0x3c00c53a, + (q31_t)0x3bfb3857, (q31_t)0x3bf5ab50, (q31_t)0x3bf01e23, (q31_t)0x3bea90d1, + (q31_t)0x3be5035a, (q31_t)0x3bdf75bf, (q31_t)0x3bd9e7fe, (q31_t)0x3bd45a19, + (q31_t)0x3bcecc0e, (q31_t)0x3bc93ddf, (q31_t)0x3bc3af8b, (q31_t)0x3bbe2112, + (q31_t)0x3bb89274, (q31_t)0x3bb303b1, (q31_t)0x3bad74c9, (q31_t)0x3ba7e5bd, + (q31_t)0x3ba2568c, (q31_t)0x3b9cc736, (q31_t)0x3b9737bb, (q31_t)0x3b91a81c, + (q31_t)0x3b8c1857, (q31_t)0x3b86886e, (q31_t)0x3b80f861, (q31_t)0x3b7b682e, + (q31_t)0x3b75d7d7, (q31_t)0x3b70475c, (q31_t)0x3b6ab6bb, (q31_t)0x3b6525f6, + (q31_t)0x3b5f950c, (q31_t)0x3b5a03fe, (q31_t)0x3b5472cb, (q31_t)0x3b4ee173, + (q31_t)0x3b494ff7, (q31_t)0x3b43be57, (q31_t)0x3b3e2c91, (q31_t)0x3b389aa8, + (q31_t)0x3b330899, (q31_t)0x3b2d7666, (q31_t)0x3b27e40f, (q31_t)0x3b225193, + (q31_t)0x3b1cbef3, (q31_t)0x3b172c2e, (q31_t)0x3b119945, (q31_t)0x3b0c0637, + (q31_t)0x3b067305, (q31_t)0x3b00dfaf, (q31_t)0x3afb4c34, (q31_t)0x3af5b894, + (q31_t)0x3af024d1, (q31_t)0x3aea90e9, (q31_t)0x3ae4fcdc, (q31_t)0x3adf68ac, + (q31_t)0x3ad9d457, (q31_t)0x3ad43fdd, (q31_t)0x3aceab40, (q31_t)0x3ac9167e, + (q31_t)0x3ac38198, (q31_t)0x3abdec8d, (q31_t)0x3ab8575f, (q31_t)0x3ab2c20c, + (q31_t)0x3aad2c95, (q31_t)0x3aa796fa, (q31_t)0x3aa2013a, (q31_t)0x3a9c6b57, + (q31_t)0x3a96d54f, (q31_t)0x3a913f23, (q31_t)0x3a8ba8d3, (q31_t)0x3a86125f, + (q31_t)0x3a807bc7, (q31_t)0x3a7ae50a, (q31_t)0x3a754e2a, (q31_t)0x3a6fb726, + (q31_t)0x3a6a1ffd, (q31_t)0x3a6488b1, (q31_t)0x3a5ef140, (q31_t)0x3a5959ab, + (q31_t)0x3a53c1f3, (q31_t)0x3a4e2a16, (q31_t)0x3a489216, (q31_t)0x3a42f9f2, + (q31_t)0x3a3d61a9, (q31_t)0x3a37c93d, (q31_t)0x3a3230ad, (q31_t)0x3a2c97f9, + (q31_t)0x3a26ff21, (q31_t)0x3a216625, (q31_t)0x3a1bcd05, (q31_t)0x3a1633c1, + (q31_t)0x3a109a5a, (q31_t)0x3a0b00cf, (q31_t)0x3a056720, (q31_t)0x39ffcd4d, + (q31_t)0x39fa3356, (q31_t)0x39f4993c, (q31_t)0x39eefefe, (q31_t)0x39e9649c, + (q31_t)0x39e3ca17, (q31_t)0x39de2f6d, (q31_t)0x39d894a0, (q31_t)0x39d2f9b0, + (q31_t)0x39cd5e9b, (q31_t)0x39c7c363, (q31_t)0x39c22808, (q31_t)0x39bc8c89, + (q31_t)0x39b6f0e6, (q31_t)0x39b1551f, (q31_t)0x39abb935, (q31_t)0x39a61d28, + (q31_t)0x39a080f6, (q31_t)0x399ae4a2, (q31_t)0x39954829, (q31_t)0x398fab8e, + (q31_t)0x398a0ece, (q31_t)0x398471ec, (q31_t)0x397ed4e5, (q31_t)0x397937bc, + (q31_t)0x39739a6e, (q31_t)0x396dfcfe, (q31_t)0x39685f6a, (q31_t)0x3962c1b2, + (q31_t)0x395d23d7, (q31_t)0x395785d9, (q31_t)0x3951e7b8, (q31_t)0x394c4973, + (q31_t)0x3946ab0a, (q31_t)0x39410c7f, (q31_t)0x393b6dd0, (q31_t)0x3935cefd, + (q31_t)0x39303008, (q31_t)0x392a90ef, (q31_t)0x3924f1b3, (q31_t)0x391f5254, + (q31_t)0x3919b2d1, (q31_t)0x3914132b, (q31_t)0x390e7362, (q31_t)0x3908d376, + (q31_t)0x39033367, (q31_t)0x38fd9334, (q31_t)0x38f7f2de, (q31_t)0x38f25266, + (q31_t)0x38ecb1ca, (q31_t)0x38e7110a, (q31_t)0x38e17028, (q31_t)0x38dbcf23, + (q31_t)0x38d62dfb, (q31_t)0x38d08caf, (q31_t)0x38caeb41, (q31_t)0x38c549af, + (q31_t)0x38bfa7fb, (q31_t)0x38ba0623, (q31_t)0x38b46429, (q31_t)0x38aec20b, + (q31_t)0x38a91fcb, (q31_t)0x38a37d67, (q31_t)0x389ddae1, (q31_t)0x38983838, + (q31_t)0x3892956c, (q31_t)0x388cf27d, (q31_t)0x38874f6b, (q31_t)0x3881ac36, + (q31_t)0x387c08de, (q31_t)0x38766564, (q31_t)0x3870c1c6, (q31_t)0x386b1e06, + (q31_t)0x38657a23, (q31_t)0x385fd61d, (q31_t)0x385a31f5, (q31_t)0x38548daa, + (q31_t)0x384ee93b, (q31_t)0x384944ab, (q31_t)0x38439ff7, (q31_t)0x383dfb21, + (q31_t)0x38385628, (q31_t)0x3832b10d, (q31_t)0x382d0bce, (q31_t)0x3827666d, + (q31_t)0x3821c0ea, (q31_t)0x381c1b44, (q31_t)0x3816757b, (q31_t)0x3810cf90, + (q31_t)0x380b2982, (q31_t)0x38058351, (q31_t)0x37ffdcfe, (q31_t)0x37fa3688, + (q31_t)0x37f48ff0, (q31_t)0x37eee936, (q31_t)0x37e94259, (q31_t)0x37e39b59, + (q31_t)0x37ddf437, (q31_t)0x37d84cf2, (q31_t)0x37d2a58b, (q31_t)0x37ccfe02, + (q31_t)0x37c75656, (q31_t)0x37c1ae87, (q31_t)0x37bc0697, (q31_t)0x37b65e84, + (q31_t)0x37b0b64e, (q31_t)0x37ab0df6, (q31_t)0x37a5657c, (q31_t)0x379fbce0, + (q31_t)0x379a1421, (q31_t)0x37946b40, (q31_t)0x378ec23d, (q31_t)0x37891917, + (q31_t)0x37836fcf, (q31_t)0x377dc665, (q31_t)0x37781cd9, (q31_t)0x3772732a, + (q31_t)0x376cc959, (q31_t)0x37671f66, (q31_t)0x37617551, (q31_t)0x375bcb1a, + (q31_t)0x375620c1, (q31_t)0x37507645, (q31_t)0x374acba7, (q31_t)0x374520e7, + (q31_t)0x373f7606, (q31_t)0x3739cb02, (q31_t)0x37341fdc, (q31_t)0x372e7493, + (q31_t)0x3728c929, (q31_t)0x37231d9d, (q31_t)0x371d71ef, (q31_t)0x3717c61f, + (q31_t)0x37121a2d, (q31_t)0x370c6e19, (q31_t)0x3706c1e2, (q31_t)0x3701158a, + (q31_t)0x36fb6910, (q31_t)0x36f5bc75, (q31_t)0x36f00fb7, (q31_t)0x36ea62d7, + (q31_t)0x36e4b5d6, (q31_t)0x36df08b2, (q31_t)0x36d95b6d, (q31_t)0x36d3ae06, + (q31_t)0x36ce007d, (q31_t)0x36c852d2, (q31_t)0x36c2a506, (q31_t)0x36bcf718, + (q31_t)0x36b74908, (q31_t)0x36b19ad6, (q31_t)0x36abec82, (q31_t)0x36a63e0d, + (q31_t)0x36a08f76, (q31_t)0x369ae0bd, (q31_t)0x369531e3, (q31_t)0x368f82e7, + (q31_t)0x3689d3c9, (q31_t)0x3684248a, (q31_t)0x367e7529, (q31_t)0x3678c5a7, + (q31_t)0x36731602, (q31_t)0x366d663d, (q31_t)0x3667b655, (q31_t)0x3662064c, + (q31_t)0x365c5622, (q31_t)0x3656a5d6, (q31_t)0x3650f569, (q31_t)0x364b44da, + (q31_t)0x36459429, (q31_t)0x363fe357, (q31_t)0x363a3264, (q31_t)0x3634814f, + (q31_t)0x362ed019, (q31_t)0x36291ec1, (q31_t)0x36236d48, (q31_t)0x361dbbad, + (q31_t)0x361809f1, (q31_t)0x36125814, (q31_t)0x360ca615, (q31_t)0x3606f3f5, + (q31_t)0x360141b4, (q31_t)0x35fb8f52, (q31_t)0x35f5dcce, (q31_t)0x35f02a28, + (q31_t)0x35ea7762, (q31_t)0x35e4c47a, (q31_t)0x35df1171, (q31_t)0x35d95e47, + (q31_t)0x35d3aafc, (q31_t)0x35cdf78f, (q31_t)0x35c84401, (q31_t)0x35c29052, + (q31_t)0x35bcdc82, (q31_t)0x35b72891, (q31_t)0x35b1747e, (q31_t)0x35abc04b, + (q31_t)0x35a60bf6, (q31_t)0x35a05781, (q31_t)0x359aa2ea, (q31_t)0x3594ee32, + (q31_t)0x358f3959, (q31_t)0x3589845f, (q31_t)0x3583cf44, (q31_t)0x357e1a08, + (q31_t)0x357864ab, (q31_t)0x3572af2d, (q31_t)0x356cf98e, (q31_t)0x356743ce, + (q31_t)0x35618ded, (q31_t)0x355bd7eb, (q31_t)0x355621c9, (q31_t)0x35506b85, + (q31_t)0x354ab520, (q31_t)0x3544fe9b, (q31_t)0x353f47f5, (q31_t)0x3539912e, + (q31_t)0x3533da46, (q31_t)0x352e233d, (q31_t)0x35286c14, (q31_t)0x3522b4c9, + (q31_t)0x351cfd5e, (q31_t)0x351745d2, (q31_t)0x35118e26, (q31_t)0x350bd658, + (q31_t)0x35061e6a, (q31_t)0x3500665c, (q31_t)0x34faae2c, (q31_t)0x34f4f5dc, + (q31_t)0x34ef3d6b, (q31_t)0x34e984da, (q31_t)0x34e3cc28, (q31_t)0x34de1355, + (q31_t)0x34d85a62, (q31_t)0x34d2a14e, (q31_t)0x34cce819, (q31_t)0x34c72ec4, + (q31_t)0x34c1754e, (q31_t)0x34bbbbb8, (q31_t)0x34b60202, (q31_t)0x34b0482a, + (q31_t)0x34aa8e33, (q31_t)0x34a4d41a, (q31_t)0x349f19e2, (q31_t)0x34995f88, + (q31_t)0x3493a50f, (q31_t)0x348dea75, (q31_t)0x34882fba, (q31_t)0x348274e0, + (q31_t)0x347cb9e4, (q31_t)0x3476fec9, (q31_t)0x3471438d, (q31_t)0x346b8830, + (q31_t)0x3465ccb4, (q31_t)0x34601117, (q31_t)0x345a5559, (q31_t)0x3454997c, + (q31_t)0x344edd7e, (q31_t)0x34492160, (q31_t)0x34436521, (q31_t)0x343da8c3, + (q31_t)0x3437ec44, (q31_t)0x34322fa5, (q31_t)0x342c72e6, (q31_t)0x3426b606, + (q31_t)0x3420f907, (q31_t)0x341b3be7, (q31_t)0x34157ea7, (q31_t)0x340fc147, + (q31_t)0x340a03c7, (q31_t)0x34044626, (q31_t)0x33fe8866, (q31_t)0x33f8ca86, + (q31_t)0x33f30c85, (q31_t)0x33ed4e65, (q31_t)0x33e79024, (q31_t)0x33e1d1c4, + (q31_t)0x33dc1343, (q31_t)0x33d654a2, (q31_t)0x33d095e2, (q31_t)0x33cad701, + (q31_t)0x33c51801, (q31_t)0x33bf58e1, (q31_t)0x33b999a0, (q31_t)0x33b3da40, + (q31_t)0x33ae1ac0, (q31_t)0x33a85b20, (q31_t)0x33a29b60, (q31_t)0x339cdb81, + (q31_t)0x33971b81, (q31_t)0x33915b62, (q31_t)0x338b9b22, (q31_t)0x3385dac4, + (q31_t)0x33801a45, (q31_t)0x337a59a6, (q31_t)0x337498e8, (q31_t)0x336ed80a, + (q31_t)0x3369170c, (q31_t)0x336355ef, (q31_t)0x335d94b2, (q31_t)0x3357d355, + (q31_t)0x335211d8, (q31_t)0x334c503c, (q31_t)0x33468e80, (q31_t)0x3340cca5, + (q31_t)0x333b0aaa, (q31_t)0x3335488f, (q31_t)0x332f8655, (q31_t)0x3329c3fb, + (q31_t)0x33240182, (q31_t)0x331e3ee9, (q31_t)0x33187c31, (q31_t)0x3312b959, + (q31_t)0x330cf661, (q31_t)0x3307334a, (q31_t)0x33017014, (q31_t)0x32fbacbe, + (q31_t)0x32f5e948, (q31_t)0x32f025b4, (q31_t)0x32ea61ff, (q31_t)0x32e49e2c, + (q31_t)0x32deda39, (q31_t)0x32d91626, (q31_t)0x32d351f5, (q31_t)0x32cd8da4, + (q31_t)0x32c7c933, (q31_t)0x32c204a3, (q31_t)0x32bc3ff4, (q31_t)0x32b67b26, + (q31_t)0x32b0b638, (q31_t)0x32aaf12b, (q31_t)0x32a52bff, (q31_t)0x329f66b4, + (q31_t)0x3299a149, (q31_t)0x3293dbbf, (q31_t)0x328e1616, (q31_t)0x3288504e, + (q31_t)0x32828a67, (q31_t)0x327cc460, (q31_t)0x3276fe3a, (q31_t)0x327137f6, + (q31_t)0x326b7192, (q31_t)0x3265ab0f, (q31_t)0x325fe46c, (q31_t)0x325a1dab, + (q31_t)0x325456cb, (q31_t)0x324e8fcc, (q31_t)0x3248c8ad, (q31_t)0x32430170, + (q31_t)0x323d3a14, (q31_t)0x32377298, (q31_t)0x3231aafe, (q31_t)0x322be345, + (q31_t)0x32261b6c, (q31_t)0x32205375, (q31_t)0x321a8b5f, (q31_t)0x3214c32a, + (q31_t)0x320efad6, (q31_t)0x32093263, (q31_t)0x320369d2, (q31_t)0x31fda121, + (q31_t)0x31f7d852, (q31_t)0x31f20f64, (q31_t)0x31ec4657, (q31_t)0x31e67d2b, + (q31_t)0x31e0b3e0, (q31_t)0x31daea77, (q31_t)0x31d520ef, (q31_t)0x31cf5748, + (q31_t)0x31c98d83, (q31_t)0x31c3c39e, (q31_t)0x31bdf99b, (q31_t)0x31b82f7a, + (q31_t)0x31b2653a, (q31_t)0x31ac9adb, (q31_t)0x31a6d05d, (q31_t)0x31a105c1, + (q31_t)0x319b3b06, (q31_t)0x3195702d, (q31_t)0x318fa535, (q31_t)0x3189da1e, + (q31_t)0x31840ee9, (q31_t)0x317e4395, (q31_t)0x31787823, (q31_t)0x3172ac92, + (q31_t)0x316ce0e3, (q31_t)0x31671515, (q31_t)0x31614929, (q31_t)0x315b7d1e, + (q31_t)0x3155b0f5, (q31_t)0x314fe4ae, (q31_t)0x314a1848, (q31_t)0x31444bc3, + (q31_t)0x313e7f21, (q31_t)0x3138b260, (q31_t)0x3132e580, (q31_t)0x312d1882, + (q31_t)0x31274b66, (q31_t)0x31217e2c, (q31_t)0x311bb0d3, (q31_t)0x3115e35c, + (q31_t)0x311015c6, (q31_t)0x310a4813, (q31_t)0x31047a41, (q31_t)0x30feac51, + (q31_t)0x30f8de42, (q31_t)0x30f31016, (q31_t)0x30ed41cb, (q31_t)0x30e77362, + (q31_t)0x30e1a4db, (q31_t)0x30dbd636, (q31_t)0x30d60772, (q31_t)0x30d03891, + (q31_t)0x30ca6991, (q31_t)0x30c49a74, (q31_t)0x30becb38, (q31_t)0x30b8fbde, + (q31_t)0x30b32c66, (q31_t)0x30ad5cd0, (q31_t)0x30a78d1c, (q31_t)0x30a1bd4a, + (q31_t)0x309bed5a, (q31_t)0x30961d4c, (q31_t)0x30904d20, (q31_t)0x308a7cd6, + (q31_t)0x3084ac6e, (q31_t)0x307edbe9, (q31_t)0x30790b45, (q31_t)0x30733a83, + (q31_t)0x306d69a4, (q31_t)0x306798a7, (q31_t)0x3061c78b, (q31_t)0x305bf652, + (q31_t)0x305624fb, (q31_t)0x30505387, (q31_t)0x304a81f4, (q31_t)0x3044b044, + (q31_t)0x303ede76, (q31_t)0x30390c8a, (q31_t)0x30333a80, (q31_t)0x302d6859, + (q31_t)0x30279614, (q31_t)0x3021c3b1, (q31_t)0x301bf131, (q31_t)0x30161e93, + (q31_t)0x30104bd7, (q31_t)0x300a78fe, (q31_t)0x3004a607, (q31_t)0x2ffed2f2, + (q31_t)0x2ff8ffc0, (q31_t)0x2ff32c70, (q31_t)0x2fed5902, (q31_t)0x2fe78577, + (q31_t)0x2fe1b1cf, (q31_t)0x2fdbde09, (q31_t)0x2fd60a25, (q31_t)0x2fd03624, + (q31_t)0x2fca6206, (q31_t)0x2fc48dc9, (q31_t)0x2fbeb970, (q31_t)0x2fb8e4f9, + (q31_t)0x2fb31064, (q31_t)0x2fad3bb3, (q31_t)0x2fa766e3, (q31_t)0x2fa191f7, + (q31_t)0x2f9bbced, (q31_t)0x2f95e7c5, (q31_t)0x2f901280, (q31_t)0x2f8a3d1e, + (q31_t)0x2f84679f, (q31_t)0x2f7e9202, (q31_t)0x2f78bc48, (q31_t)0x2f72e671, + (q31_t)0x2f6d107c, (q31_t)0x2f673a6a, (q31_t)0x2f61643b, (q31_t)0x2f5b8def, + (q31_t)0x2f55b785, (q31_t)0x2f4fe0ff, (q31_t)0x2f4a0a5b, (q31_t)0x2f44339a, + (q31_t)0x2f3e5cbb, (q31_t)0x2f3885c0, (q31_t)0x2f32aea8, (q31_t)0x2f2cd772, + (q31_t)0x2f27001f, (q31_t)0x2f2128af, (q31_t)0x2f1b5122, (q31_t)0x2f157979, + (q31_t)0x2f0fa1b2, (q31_t)0x2f09c9ce, (q31_t)0x2f03f1cd, (q31_t)0x2efe19ae, + (q31_t)0x2ef84173, (q31_t)0x2ef2691b, (q31_t)0x2eec90a7, (q31_t)0x2ee6b815, + (q31_t)0x2ee0df66, (q31_t)0x2edb069a, (q31_t)0x2ed52db1, (q31_t)0x2ecf54ac, + (q31_t)0x2ec97b89, (q31_t)0x2ec3a24a, (q31_t)0x2ebdc8ee, (q31_t)0x2eb7ef75, + (q31_t)0x2eb215df, (q31_t)0x2eac3c2d, (q31_t)0x2ea6625d, (q31_t)0x2ea08871, + (q31_t)0x2e9aae68, (q31_t)0x2e94d443, (q31_t)0x2e8efa00, (q31_t)0x2e891fa1, + (q31_t)0x2e834525, (q31_t)0x2e7d6a8d, (q31_t)0x2e778fd8, (q31_t)0x2e71b506, + (q31_t)0x2e6bda17, (q31_t)0x2e65ff0c, (q31_t)0x2e6023e5, (q31_t)0x2e5a48a0, + (q31_t)0x2e546d3f, (q31_t)0x2e4e91c2, (q31_t)0x2e48b628, (q31_t)0x2e42da71, + (q31_t)0x2e3cfe9e, (q31_t)0x2e3722ae, (q31_t)0x2e3146a2, (q31_t)0x2e2b6a79, + (q31_t)0x2e258e34, (q31_t)0x2e1fb1d3, (q31_t)0x2e19d554, (q31_t)0x2e13f8ba, + (q31_t)0x2e0e1c03, (q31_t)0x2e083f30, (q31_t)0x2e026240, (q31_t)0x2dfc8534, + (q31_t)0x2df6a80b, (q31_t)0x2df0cac6, (q31_t)0x2deaed65, (q31_t)0x2de50fe8, + (q31_t)0x2ddf324e, (q31_t)0x2dd95498, (q31_t)0x2dd376c5, (q31_t)0x2dcd98d7, + (q31_t)0x2dc7bacc, (q31_t)0x2dc1dca4, (q31_t)0x2dbbfe61, (q31_t)0x2db62001, + (q31_t)0x2db04186, (q31_t)0x2daa62ee, (q31_t)0x2da4843a, (q31_t)0x2d9ea569, + (q31_t)0x2d98c67d, (q31_t)0x2d92e774, (q31_t)0x2d8d084f, (q31_t)0x2d87290f, + (q31_t)0x2d8149b2, (q31_t)0x2d7b6a39, (q31_t)0x2d758aa4, (q31_t)0x2d6faaf3, + (q31_t)0x2d69cb26, (q31_t)0x2d63eb3d, (q31_t)0x2d5e0b38, (q31_t)0x2d582b17, + (q31_t)0x2d524ada, (q31_t)0x2d4c6a81, (q31_t)0x2d468a0c, (q31_t)0x2d40a97b, + (q31_t)0x2d3ac8ce, (q31_t)0x2d34e805, (q31_t)0x2d2f0721, (q31_t)0x2d292620, + (q31_t)0x2d234504, (q31_t)0x2d1d63cc, (q31_t)0x2d178278, (q31_t)0x2d11a108, + (q31_t)0x2d0bbf7d, (q31_t)0x2d05ddd5, (q31_t)0x2cfffc12, (q31_t)0x2cfa1a33, + (q31_t)0x2cf43839, (q31_t)0x2cee5622, (q31_t)0x2ce873f0, (q31_t)0x2ce291a2, + (q31_t)0x2cdcaf39, (q31_t)0x2cd6ccb4, (q31_t)0x2cd0ea13, (q31_t)0x2ccb0756, + (q31_t)0x2cc5247e, (q31_t)0x2cbf418b, (q31_t)0x2cb95e7b, (q31_t)0x2cb37b51, + (q31_t)0x2cad980a, (q31_t)0x2ca7b4a8, (q31_t)0x2ca1d12a, (q31_t)0x2c9bed91, + (q31_t)0x2c9609dd, (q31_t)0x2c90260d, (q31_t)0x2c8a4221, (q31_t)0x2c845e1a, + (q31_t)0x2c7e79f7, (q31_t)0x2c7895b9, (q31_t)0x2c72b160, (q31_t)0x2c6ccceb, + (q31_t)0x2c66e85b, (q31_t)0x2c6103af, (q31_t)0x2c5b1ee8, (q31_t)0x2c553a06, + (q31_t)0x2c4f5508, (q31_t)0x2c496fef, (q31_t)0x2c438abb, (q31_t)0x2c3da56b, + (q31_t)0x2c37c000, (q31_t)0x2c31da7a, (q31_t)0x2c2bf4d8, (q31_t)0x2c260f1c, + (q31_t)0x2c202944, (q31_t)0x2c1a4351, (q31_t)0x2c145d42, (q31_t)0x2c0e7719, + (q31_t)0x2c0890d4, (q31_t)0x2c02aa74, (q31_t)0x2bfcc3f9, (q31_t)0x2bf6dd63, + (q31_t)0x2bf0f6b1, (q31_t)0x2beb0fe5, (q31_t)0x2be528fd, (q31_t)0x2bdf41fb, + (q31_t)0x2bd95add, (q31_t)0x2bd373a4, (q31_t)0x2bcd8c51, (q31_t)0x2bc7a4e2, + (q31_t)0x2bc1bd58, (q31_t)0x2bbbd5b3, (q31_t)0x2bb5edf4, (q31_t)0x2bb00619, + (q31_t)0x2baa1e23, (q31_t)0x2ba43613, (q31_t)0x2b9e4de7, (q31_t)0x2b9865a1, + (q31_t)0x2b927d3f, (q31_t)0x2b8c94c3, (q31_t)0x2b86ac2c, (q31_t)0x2b80c37a, + (q31_t)0x2b7adaae, (q31_t)0x2b74f1c6, (q31_t)0x2b6f08c4, (q31_t)0x2b691fa6, + (q31_t)0x2b63366f, (q31_t)0x2b5d4d1c, (q31_t)0x2b5763ae, (q31_t)0x2b517a26, + (q31_t)0x2b4b9083, (q31_t)0x2b45a6c6, (q31_t)0x2b3fbced, (q31_t)0x2b39d2fa, + (q31_t)0x2b33e8ed, (q31_t)0x2b2dfec5, (q31_t)0x2b281482, (q31_t)0x2b222a24, + (q31_t)0x2b1c3fac, (q31_t)0x2b165519, (q31_t)0x2b106a6c, (q31_t)0x2b0a7fa4, + (q31_t)0x2b0494c2, (q31_t)0x2afea9c5, (q31_t)0x2af8bead, (q31_t)0x2af2d37b, + (q31_t)0x2aece82f, (q31_t)0x2ae6fcc8, (q31_t)0x2ae11146, (q31_t)0x2adb25aa, + (q31_t)0x2ad539f4, (q31_t)0x2acf4e23, (q31_t)0x2ac96238, (q31_t)0x2ac37633, + (q31_t)0x2abd8a13, (q31_t)0x2ab79dd8, (q31_t)0x2ab1b184, (q31_t)0x2aabc515, + (q31_t)0x2aa5d88b, (q31_t)0x2a9febe8, (q31_t)0x2a99ff2a, (q31_t)0x2a941252, + (q31_t)0x2a8e255f, (q31_t)0x2a883853, (q31_t)0x2a824b2c, (q31_t)0x2a7c5deb, + (q31_t)0x2a76708f, (q31_t)0x2a70831a, (q31_t)0x2a6a958a, (q31_t)0x2a64a7e0, + (q31_t)0x2a5eba1c, (q31_t)0x2a58cc3e, (q31_t)0x2a52de46, (q31_t)0x2a4cf033, + (q31_t)0x2a470207, (q31_t)0x2a4113c0, (q31_t)0x2a3b2560, (q31_t)0x2a3536e5, + (q31_t)0x2a2f4850, (q31_t)0x2a2959a1, (q31_t)0x2a236ad9, (q31_t)0x2a1d7bf6, + (q31_t)0x2a178cf9, (q31_t)0x2a119de2, (q31_t)0x2a0baeb2, (q31_t)0x2a05bf67, + (q31_t)0x29ffd003, (q31_t)0x29f9e084, (q31_t)0x29f3f0ec, (q31_t)0x29ee013a, + (q31_t)0x29e8116e, (q31_t)0x29e22188, (q31_t)0x29dc3188, (q31_t)0x29d6416f, + (q31_t)0x29d0513b, (q31_t)0x29ca60ee, (q31_t)0x29c47087, (q31_t)0x29be8007, + (q31_t)0x29b88f6c, (q31_t)0x29b29eb8, (q31_t)0x29acadea, (q31_t)0x29a6bd02, + (q31_t)0x29a0cc01, (q31_t)0x299adae6, (q31_t)0x2994e9b1, (q31_t)0x298ef863, + (q31_t)0x298906fb, (q31_t)0x2983157a, (q31_t)0x297d23df, (q31_t)0x2977322a, + (q31_t)0x2971405b, (q31_t)0x296b4e74, (q31_t)0x29655c72, (q31_t)0x295f6a57, + (q31_t)0x29597823, (q31_t)0x295385d5, (q31_t)0x294d936d, (q31_t)0x2947a0ec, + (q31_t)0x2941ae52, (q31_t)0x293bbb9e, (q31_t)0x2935c8d1, (q31_t)0x292fd5ea, + (q31_t)0x2929e2ea, (q31_t)0x2923efd0, (q31_t)0x291dfc9d, (q31_t)0x29180951, + (q31_t)0x291215eb, (q31_t)0x290c226c, (q31_t)0x29062ed4, (q31_t)0x29003b23, + (q31_t)0x28fa4758, (q31_t)0x28f45374, (q31_t)0x28ee5f76, (q31_t)0x28e86b5f, + (q31_t)0x28e27730, (q31_t)0x28dc82e6, (q31_t)0x28d68e84, (q31_t)0x28d09a09, + (q31_t)0x28caa574, (q31_t)0x28c4b0c6, (q31_t)0x28bebbff, (q31_t)0x28b8c71f, + (q31_t)0x28b2d226, (q31_t)0x28acdd13, (q31_t)0x28a6e7e8, (q31_t)0x28a0f2a3, + (q31_t)0x289afd46, (q31_t)0x289507cf, (q31_t)0x288f123f, (q31_t)0x28891c97, + (q31_t)0x288326d5, (q31_t)0x287d30fa, (q31_t)0x28773b07, (q31_t)0x287144fa, + (q31_t)0x286b4ed5, (q31_t)0x28655896, (q31_t)0x285f623f, (q31_t)0x28596bce, + (q31_t)0x28537545, (q31_t)0x284d7ea3, (q31_t)0x284787e8, (q31_t)0x28419114, + (q31_t)0x283b9a28, (q31_t)0x2835a322, (q31_t)0x282fac04, (q31_t)0x2829b4cd, + (q31_t)0x2823bd7d, (q31_t)0x281dc615, (q31_t)0x2817ce93, (q31_t)0x2811d6f9, + (q31_t)0x280bdf46, (q31_t)0x2805e77b, (q31_t)0x27ffef97, (q31_t)0x27f9f79a, + (q31_t)0x27f3ff85, (q31_t)0x27ee0756, (q31_t)0x27e80f10, (q31_t)0x27e216b0, + (q31_t)0x27dc1e38, (q31_t)0x27d625a8, (q31_t)0x27d02cff, (q31_t)0x27ca343d, + (q31_t)0x27c43b63, (q31_t)0x27be4270, (q31_t)0x27b84965, (q31_t)0x27b25041, + (q31_t)0x27ac5705, (q31_t)0x27a65db0, (q31_t)0x27a06443, (q31_t)0x279a6abd, + (q31_t)0x2794711f, (q31_t)0x278e7768, (q31_t)0x27887d99, (q31_t)0x278283b2, + (q31_t)0x277c89b3, (q31_t)0x27768f9b, (q31_t)0x2770956a, (q31_t)0x276a9b21, + (q31_t)0x2764a0c0, (q31_t)0x275ea647, (q31_t)0x2758abb6, (q31_t)0x2752b10c, + (q31_t)0x274cb64a, (q31_t)0x2746bb6f, (q31_t)0x2740c07d, (q31_t)0x273ac572, + (q31_t)0x2734ca4f, (q31_t)0x272ecf14, (q31_t)0x2728d3c0, (q31_t)0x2722d855, + (q31_t)0x271cdcd1, (q31_t)0x2716e136, (q31_t)0x2710e582, (q31_t)0x270ae9b6, + (q31_t)0x2704edd2, (q31_t)0x26fef1d5, (q31_t)0x26f8f5c1, (q31_t)0x26f2f995, + (q31_t)0x26ecfd51, (q31_t)0x26e700f5, (q31_t)0x26e10480, (q31_t)0x26db07f4, + (q31_t)0x26d50b50, (q31_t)0x26cf0e94, (q31_t)0x26c911c0, (q31_t)0x26c314d4, + (q31_t)0x26bd17d0, (q31_t)0x26b71ab4, (q31_t)0x26b11d80, (q31_t)0x26ab2034, + (q31_t)0x26a522d1, (q31_t)0x269f2556, (q31_t)0x269927c3, (q31_t)0x26932a18, + (q31_t)0x268d2c55, (q31_t)0x26872e7b, (q31_t)0x26813088, (q31_t)0x267b327e, + (q31_t)0x2675345d, (q31_t)0x266f3623, (q31_t)0x266937d2, (q31_t)0x26633969, + (q31_t)0x265d3ae9, (q31_t)0x26573c50, (q31_t)0x26513da1, (q31_t)0x264b3ed9, + (q31_t)0x26453ffa, (q31_t)0x263f4103, (q31_t)0x263941f5, (q31_t)0x263342cf, + (q31_t)0x262d4392, (q31_t)0x2627443d, (q31_t)0x262144d0, (q31_t)0x261b454c, + (q31_t)0x261545b0, (q31_t)0x260f45fd, (q31_t)0x26094633, (q31_t)0x26034651, + (q31_t)0x25fd4657, (q31_t)0x25f74646, (q31_t)0x25f1461e, (q31_t)0x25eb45de, + (q31_t)0x25e54587, (q31_t)0x25df4519, (q31_t)0x25d94493, (q31_t)0x25d343f6, + (q31_t)0x25cd4341, (q31_t)0x25c74276, (q31_t)0x25c14192, (q31_t)0x25bb4098, + (q31_t)0x25b53f86, (q31_t)0x25af3e5d, (q31_t)0x25a93d1d, (q31_t)0x25a33bc6, + (q31_t)0x259d3a57, (q31_t)0x259738d1, (q31_t)0x25913734, (q31_t)0x258b3580, + (q31_t)0x258533b5, (q31_t)0x257f31d2, (q31_t)0x25792fd8, (q31_t)0x25732dc8, + (q31_t)0x256d2ba0, (q31_t)0x25672961, (q31_t)0x2561270b, (q31_t)0x255b249e, + (q31_t)0x2555221a, (q31_t)0x254f1f7e, (q31_t)0x25491ccc, (q31_t)0x25431a03, + (q31_t)0x253d1723, (q31_t)0x2537142c, (q31_t)0x2531111e, (q31_t)0x252b0df9, + (q31_t)0x25250abd, (q31_t)0x251f076a, (q31_t)0x25190400, (q31_t)0x25130080, + (q31_t)0x250cfce8, (q31_t)0x2506f93a, (q31_t)0x2500f574, (q31_t)0x24faf198, + (q31_t)0x24f4eda6, (q31_t)0x24eee99c, (q31_t)0x24e8e57c, (q31_t)0x24e2e144, + (q31_t)0x24dcdcf6, (q31_t)0x24d6d892, (q31_t)0x24d0d416, (q31_t)0x24cacf84, + (q31_t)0x24c4cadb, (q31_t)0x24bec61c, (q31_t)0x24b8c146, (q31_t)0x24b2bc59, + (q31_t)0x24acb756, (q31_t)0x24a6b23b, (q31_t)0x24a0ad0b, (q31_t)0x249aa7c4, + (q31_t)0x2494a266, (q31_t)0x248e9cf1, (q31_t)0x24889766, (q31_t)0x248291c5, + (q31_t)0x247c8c0d, (q31_t)0x2476863e, (q31_t)0x24708059, (q31_t)0x246a7a5e, + (q31_t)0x2464744c, (q31_t)0x245e6e23, (q31_t)0x245867e4, (q31_t)0x2452618f, + (q31_t)0x244c5b24, (q31_t)0x244654a1, (q31_t)0x24404e09, (q31_t)0x243a475a, + (q31_t)0x24344095, (q31_t)0x242e39ba, (q31_t)0x242832c8, (q31_t)0x24222bc0, + (q31_t)0x241c24a1, (q31_t)0x24161d6d, (q31_t)0x24101622, (q31_t)0x240a0ec1, + (q31_t)0x24040749, (q31_t)0x23fdffbc, (q31_t)0x23f7f818, (q31_t)0x23f1f05e, + (q31_t)0x23ebe88e, (q31_t)0x23e5e0a7, (q31_t)0x23dfd8ab, (q31_t)0x23d9d098, + (q31_t)0x23d3c86f, (q31_t)0x23cdc031, (q31_t)0x23c7b7dc, (q31_t)0x23c1af71, + (q31_t)0x23bba6f0, (q31_t)0x23b59e59, (q31_t)0x23af95ac, (q31_t)0x23a98ce8, + (q31_t)0x23a3840f, (q31_t)0x239d7b20, (q31_t)0x2397721b, (q31_t)0x23916900, + (q31_t)0x238b5fcf, (q31_t)0x23855688, (q31_t)0x237f4d2b, (q31_t)0x237943b9, + (q31_t)0x23733a30, (q31_t)0x236d3092, (q31_t)0x236726dd, (q31_t)0x23611d13, + (q31_t)0x235b1333, (q31_t)0x2355093e, (q31_t)0x234eff32, (q31_t)0x2348f511, + (q31_t)0x2342eada, (q31_t)0x233ce08d, (q31_t)0x2336d62a, (q31_t)0x2330cbb2, + (q31_t)0x232ac124, (q31_t)0x2324b680, (q31_t)0x231eabc7, (q31_t)0x2318a0f8, + (q31_t)0x23129613, (q31_t)0x230c8b19, (q31_t)0x23068009, (q31_t)0x230074e3, + (q31_t)0x22fa69a8, (q31_t)0x22f45e57, (q31_t)0x22ee52f1, (q31_t)0x22e84775, + (q31_t)0x22e23be4, (q31_t)0x22dc303d, (q31_t)0x22d62480, (q31_t)0x22d018ae, + (q31_t)0x22ca0cc7, (q31_t)0x22c400ca, (q31_t)0x22bdf4b8, (q31_t)0x22b7e890, + (q31_t)0x22b1dc53, (q31_t)0x22abd001, (q31_t)0x22a5c399, (q31_t)0x229fb71b, + (q31_t)0x2299aa89, (q31_t)0x22939de1, (q31_t)0x228d9123, (q31_t)0x22878451, + (q31_t)0x22817769, (q31_t)0x227b6a6c, (q31_t)0x22755d59, (q31_t)0x226f5032, + (q31_t)0x226942f5, (q31_t)0x226335a2, (q31_t)0x225d283b, (q31_t)0x22571abe, + (q31_t)0x22510d2d, (q31_t)0x224aff86, (q31_t)0x2244f1c9, (q31_t)0x223ee3f8, + (q31_t)0x2238d612, (q31_t)0x2232c816, (q31_t)0x222cba06, (q31_t)0x2226abe0, + (q31_t)0x22209da5, (q31_t)0x221a8f56, (q31_t)0x221480f1, (q31_t)0x220e7277, + (q31_t)0x220863e8, (q31_t)0x22025544, (q31_t)0x21fc468b, (q31_t)0x21f637be, + (q31_t)0x21f028db, (q31_t)0x21ea19e3, (q31_t)0x21e40ad7, (q31_t)0x21ddfbb5, + (q31_t)0x21d7ec7f, (q31_t)0x21d1dd34, (q31_t)0x21cbcdd3, (q31_t)0x21c5be5e, + (q31_t)0x21bfaed5, (q31_t)0x21b99f36, (q31_t)0x21b38f83, (q31_t)0x21ad7fba, + (q31_t)0x21a76fdd, (q31_t)0x21a15fec, (q31_t)0x219b4fe5, (q31_t)0x21953fca, + (q31_t)0x218f2f9a, (q31_t)0x21891f55, (q31_t)0x21830efc, (q31_t)0x217cfe8e, + (q31_t)0x2176ee0b, (q31_t)0x2170dd74, (q31_t)0x216accc8, (q31_t)0x2164bc08, + (q31_t)0x215eab33, (q31_t)0x21589a49, (q31_t)0x2152894b, (q31_t)0x214c7838, + (q31_t)0x21466710, (q31_t)0x214055d4, (q31_t)0x213a4484, (q31_t)0x2134331f, + (q31_t)0x212e21a6, (q31_t)0x21281018, (q31_t)0x2121fe76, (q31_t)0x211becbf, + (q31_t)0x2115daf4, (q31_t)0x210fc914, (q31_t)0x2109b720, (q31_t)0x2103a518, + (q31_t)0x20fd92fb, (q31_t)0x20f780ca, (q31_t)0x20f16e84, (q31_t)0x20eb5c2b, + (q31_t)0x20e549bd, (q31_t)0x20df373a, (q31_t)0x20d924a4, (q31_t)0x20d311f9, + (q31_t)0x20ccff3a, (q31_t)0x20c6ec66, (q31_t)0x20c0d97f, (q31_t)0x20bac683, + (q31_t)0x20b4b373, (q31_t)0x20aea04f, (q31_t)0x20a88d17, (q31_t)0x20a279ca, + (q31_t)0x209c666a, (q31_t)0x209652f5, (q31_t)0x20903f6c, (q31_t)0x208a2bcf, + (q31_t)0x2084181e, (q31_t)0x207e0459, (q31_t)0x2077f080, (q31_t)0x2071dc93, + (q31_t)0x206bc892, (q31_t)0x2065b47d, (q31_t)0x205fa054, (q31_t)0x20598c17, + (q31_t)0x205377c6, (q31_t)0x204d6361, (q31_t)0x20474ee8, (q31_t)0x20413a5b, + (q31_t)0x203b25bb, (q31_t)0x20351106, (q31_t)0x202efc3e, (q31_t)0x2028e761, + (q31_t)0x2022d271, (q31_t)0x201cbd6d, (q31_t)0x2016a856, (q31_t)0x2010932a, + (q31_t)0x200a7deb, (q31_t)0x20046898, (q31_t)0x1ffe5331, (q31_t)0x1ff83db6, + (q31_t)0x1ff22828, (q31_t)0x1fec1286, (q31_t)0x1fe5fcd0, (q31_t)0x1fdfe707, + (q31_t)0x1fd9d12a, (q31_t)0x1fd3bb39, (q31_t)0x1fcda535, (q31_t)0x1fc78f1d, + (q31_t)0x1fc178f1, (q31_t)0x1fbb62b2, (q31_t)0x1fb54c60, (q31_t)0x1faf35f9, + (q31_t)0x1fa91f80, (q31_t)0x1fa308f2, (q31_t)0x1f9cf252, (q31_t)0x1f96db9d, + (q31_t)0x1f90c4d5, (q31_t)0x1f8aadfa, (q31_t)0x1f84970b, (q31_t)0x1f7e8009, + (q31_t)0x1f7868f4, (q31_t)0x1f7251ca, (q31_t)0x1f6c3a8e, (q31_t)0x1f66233e, + (q31_t)0x1f600bdb, (q31_t)0x1f59f465, (q31_t)0x1f53dcdb, (q31_t)0x1f4dc53d, + (q31_t)0x1f47ad8d, (q31_t)0x1f4195c9, (q31_t)0x1f3b7df2, (q31_t)0x1f356608, + (q31_t)0x1f2f4e0a, (q31_t)0x1f2935f9, (q31_t)0x1f231dd5, (q31_t)0x1f1d059e, + (q31_t)0x1f16ed54, (q31_t)0x1f10d4f6, (q31_t)0x1f0abc85, (q31_t)0x1f04a401, + (q31_t)0x1efe8b6a, (q31_t)0x1ef872c0, (q31_t)0x1ef25a03, (q31_t)0x1eec4132, + (q31_t)0x1ee6284f, (q31_t)0x1ee00f58, (q31_t)0x1ed9f64f, (q31_t)0x1ed3dd32, + (q31_t)0x1ecdc402, (q31_t)0x1ec7aac0, (q31_t)0x1ec1916a, (q31_t)0x1ebb7802, + (q31_t)0x1eb55e86, (q31_t)0x1eaf44f8, (q31_t)0x1ea92b56, (q31_t)0x1ea311a2, + (q31_t)0x1e9cf7db, (q31_t)0x1e96de01, (q31_t)0x1e90c414, (q31_t)0x1e8aaa14, + (q31_t)0x1e849001, (q31_t)0x1e7e75dc, (q31_t)0x1e785ba3, (q31_t)0x1e724158, + (q31_t)0x1e6c26fa, (q31_t)0x1e660c8a, (q31_t)0x1e5ff206, (q31_t)0x1e59d770, + (q31_t)0x1e53bcc7, (q31_t)0x1e4da20c, (q31_t)0x1e47873d, (q31_t)0x1e416c5d, + (q31_t)0x1e3b5169, (q31_t)0x1e353663, (q31_t)0x1e2f1b4a, (q31_t)0x1e29001e, + (q31_t)0x1e22e4e0, (q31_t)0x1e1cc990, (q31_t)0x1e16ae2c, (q31_t)0x1e1092b6, + (q31_t)0x1e0a772e, (q31_t)0x1e045b93, (q31_t)0x1dfe3fe6, (q31_t)0x1df82426, + (q31_t)0x1df20853, (q31_t)0x1debec6f, (q31_t)0x1de5d077, (q31_t)0x1ddfb46e, + (q31_t)0x1dd99851, (q31_t)0x1dd37c23, (q31_t)0x1dcd5fe2, (q31_t)0x1dc7438e, + (q31_t)0x1dc12729, (q31_t)0x1dbb0ab0, (q31_t)0x1db4ee26, (q31_t)0x1daed189, + (q31_t)0x1da8b4da, (q31_t)0x1da29819, (q31_t)0x1d9c7b45, (q31_t)0x1d965e5f, + (q31_t)0x1d904167, (q31_t)0x1d8a245c, (q31_t)0x1d840740, (q31_t)0x1d7dea11, + (q31_t)0x1d77ccd0, (q31_t)0x1d71af7d, (q31_t)0x1d6b9217, (q31_t)0x1d6574a0, + (q31_t)0x1d5f5716, (q31_t)0x1d59397a, (q31_t)0x1d531bcc, (q31_t)0x1d4cfe0d, + (q31_t)0x1d46e03a, (q31_t)0x1d40c256, (q31_t)0x1d3aa460, (q31_t)0x1d348658, + (q31_t)0x1d2e683e, (q31_t)0x1d284a12, (q31_t)0x1d222bd3, (q31_t)0x1d1c0d83, + (q31_t)0x1d15ef21, (q31_t)0x1d0fd0ad, (q31_t)0x1d09b227, (q31_t)0x1d03938f, + (q31_t)0x1cfd74e5, (q31_t)0x1cf7562a, (q31_t)0x1cf1375c, (q31_t)0x1ceb187d, + (q31_t)0x1ce4f98c, (q31_t)0x1cdeda89, (q31_t)0x1cd8bb74, (q31_t)0x1cd29c4d, + (q31_t)0x1ccc7d15, (q31_t)0x1cc65dca, (q31_t)0x1cc03e6e, (q31_t)0x1cba1f01, + (q31_t)0x1cb3ff81, (q31_t)0x1caddff0, (q31_t)0x1ca7c04d, (q31_t)0x1ca1a099, + (q31_t)0x1c9b80d3, (q31_t)0x1c9560fb, (q31_t)0x1c8f4112, (q31_t)0x1c892117, + (q31_t)0x1c83010a, (q31_t)0x1c7ce0ec, (q31_t)0x1c76c0bc, (q31_t)0x1c70a07b, + (q31_t)0x1c6a8028, (q31_t)0x1c645fc3, (q31_t)0x1c5e3f4d, (q31_t)0x1c581ec6, + (q31_t)0x1c51fe2d, (q31_t)0x1c4bdd83, (q31_t)0x1c45bcc7, (q31_t)0x1c3f9bf9, + (q31_t)0x1c397b1b, (q31_t)0x1c335a2b, (q31_t)0x1c2d3929, (q31_t)0x1c271816, + (q31_t)0x1c20f6f2, (q31_t)0x1c1ad5bc, (q31_t)0x1c14b475, (q31_t)0x1c0e931d, + (q31_t)0x1c0871b4, (q31_t)0x1c025039, (q31_t)0x1bfc2ead, (q31_t)0x1bf60d0f, + (q31_t)0x1befeb60, (q31_t)0x1be9c9a1, (q31_t)0x1be3a7cf, (q31_t)0x1bdd85ed, + (q31_t)0x1bd763fa, (q31_t)0x1bd141f5, (q31_t)0x1bcb1fdf, (q31_t)0x1bc4fdb8, + (q31_t)0x1bbedb80, (q31_t)0x1bb8b937, (q31_t)0x1bb296dc, (q31_t)0x1bac7471, + (q31_t)0x1ba651f5, (q31_t)0x1ba02f67, (q31_t)0x1b9a0cc8, (q31_t)0x1b93ea19, + (q31_t)0x1b8dc758, (q31_t)0x1b87a487, (q31_t)0x1b8181a4, (q31_t)0x1b7b5eb0, + (q31_t)0x1b753bac, (q31_t)0x1b6f1897, (q31_t)0x1b68f570, (q31_t)0x1b62d239, + (q31_t)0x1b5caef1, (q31_t)0x1b568b98, (q31_t)0x1b50682e, (q31_t)0x1b4a44b3, + (q31_t)0x1b442127, (q31_t)0x1b3dfd8b, (q31_t)0x1b37d9de, (q31_t)0x1b31b620, + (q31_t)0x1b2b9251, (q31_t)0x1b256e71, (q31_t)0x1b1f4a81, (q31_t)0x1b192680, + (q31_t)0x1b13026e, (q31_t)0x1b0cde4c, (q31_t)0x1b06ba19, (q31_t)0x1b0095d5, + (q31_t)0x1afa7180, (q31_t)0x1af44d1b, (q31_t)0x1aee28a6, (q31_t)0x1ae8041f, + (q31_t)0x1ae1df88, (q31_t)0x1adbbae1, (q31_t)0x1ad59629, (q31_t)0x1acf7160, + (q31_t)0x1ac94c87, (q31_t)0x1ac3279d, (q31_t)0x1abd02a3, (q31_t)0x1ab6dd98, + (q31_t)0x1ab0b87d, (q31_t)0x1aaa9352, (q31_t)0x1aa46e16, (q31_t)0x1a9e48c9, + (q31_t)0x1a98236c, (q31_t)0x1a91fdff, (q31_t)0x1a8bd881, (q31_t)0x1a85b2f3, + (q31_t)0x1a7f8d54, (q31_t)0x1a7967a6, (q31_t)0x1a7341e6, (q31_t)0x1a6d1c17, + (q31_t)0x1a66f637, (q31_t)0x1a60d047, (q31_t)0x1a5aaa47, (q31_t)0x1a548436, + (q31_t)0x1a4e5e15, (q31_t)0x1a4837e4, (q31_t)0x1a4211a3, (q31_t)0x1a3beb52, + (q31_t)0x1a35c4f0, (q31_t)0x1a2f9e7e, (q31_t)0x1a2977fc, (q31_t)0x1a23516a, + (q31_t)0x1a1d2ac8, (q31_t)0x1a170416, (q31_t)0x1a10dd53, (q31_t)0x1a0ab681, + (q31_t)0x1a048f9e, (q31_t)0x19fe68ac, (q31_t)0x19f841a9, (q31_t)0x19f21a96, + (q31_t)0x19ebf374, (q31_t)0x19e5cc41, (q31_t)0x19dfa4fe, (q31_t)0x19d97dac, + (q31_t)0x19d35649, (q31_t)0x19cd2ed7, (q31_t)0x19c70754, (q31_t)0x19c0dfc2, + (q31_t)0x19bab820, (q31_t)0x19b4906e, (q31_t)0x19ae68ac, (q31_t)0x19a840da, + (q31_t)0x19a218f9, (q31_t)0x199bf107, (q31_t)0x1995c906, (q31_t)0x198fa0f5, + (q31_t)0x198978d4, (q31_t)0x198350a4, (q31_t)0x197d2864, (q31_t)0x19770014, + (q31_t)0x1970d7b4, (q31_t)0x196aaf45, (q31_t)0x196486c6, (q31_t)0x195e5e37, + (q31_t)0x19583599, (q31_t)0x19520ceb, (q31_t)0x194be42d, (q31_t)0x1945bb60, + (q31_t)0x193f9283, (q31_t)0x19396997, (q31_t)0x1933409b, (q31_t)0x192d178f, + (q31_t)0x1926ee74, (q31_t)0x1920c54a, (q31_t)0x191a9c10, (q31_t)0x191472c6, + (q31_t)0x190e496d, (q31_t)0x19082005, (q31_t)0x1901f68d, (q31_t)0x18fbcd06, + (q31_t)0x18f5a36f, (q31_t)0x18ef79c9, (q31_t)0x18e95014, (q31_t)0x18e3264f, + (q31_t)0x18dcfc7b, (q31_t)0x18d6d297, (q31_t)0x18d0a8a4, (q31_t)0x18ca7ea2, + (q31_t)0x18c45491, (q31_t)0x18be2a70, (q31_t)0x18b80040, (q31_t)0x18b1d601, + (q31_t)0x18ababb2, (q31_t)0x18a58154, (q31_t)0x189f56e8, (q31_t)0x18992c6b, + (q31_t)0x189301e0, (q31_t)0x188cd746, (q31_t)0x1886ac9c, (q31_t)0x188081e4, + (q31_t)0x187a571c, (q31_t)0x18742c45, (q31_t)0x186e015f, (q31_t)0x1867d66a, + (q31_t)0x1861ab66, (q31_t)0x185b8053, (q31_t)0x18555530, (q31_t)0x184f29ff, + (q31_t)0x1848febf, (q31_t)0x1842d370, (q31_t)0x183ca812, (q31_t)0x18367ca5, + (q31_t)0x18305129, (q31_t)0x182a259e, (q31_t)0x1823fa04, (q31_t)0x181dce5b, + (q31_t)0x1817a2a4, (q31_t)0x181176dd, (q31_t)0x180b4b08, (q31_t)0x18051f24, + (q31_t)0x17fef331, (q31_t)0x17f8c72f, (q31_t)0x17f29b1e, (q31_t)0x17ec6eff, + (q31_t)0x17e642d1, (q31_t)0x17e01694, (q31_t)0x17d9ea49, (q31_t)0x17d3bdee, + (q31_t)0x17cd9186, (q31_t)0x17c7650e, (q31_t)0x17c13888, (q31_t)0x17bb0bf3, + (q31_t)0x17b4df4f, (q31_t)0x17aeb29d, (q31_t)0x17a885dc, (q31_t)0x17a2590d, + (q31_t)0x179c2c2f, (q31_t)0x1795ff42, (q31_t)0x178fd247, (q31_t)0x1789a53d, + (q31_t)0x17837825, (q31_t)0x177d4afe, (q31_t)0x17771dc9, (q31_t)0x1770f086, + (q31_t)0x176ac333, (q31_t)0x176495d3, (q31_t)0x175e6864, (q31_t)0x17583ae7, + (q31_t)0x17520d5b, (q31_t)0x174bdfc1, (q31_t)0x1745b218, (q31_t)0x173f8461, + (q31_t)0x1739569c, (q31_t)0x173328c8, (q31_t)0x172cfae6, (q31_t)0x1726ccf6, + (q31_t)0x17209ef8, (q31_t)0x171a70eb, (q31_t)0x171442d0, (q31_t)0x170e14a7, + (q31_t)0x1707e670, (q31_t)0x1701b82a, (q31_t)0x16fb89d6, (q31_t)0x16f55b74, + (q31_t)0x16ef2d04, (q31_t)0x16e8fe86, (q31_t)0x16e2cff9, (q31_t)0x16dca15f, + (q31_t)0x16d672b6, (q31_t)0x16d043ff, (q31_t)0x16ca153a, (q31_t)0x16c3e667, + (q31_t)0x16bdb787, (q31_t)0x16b78898, (q31_t)0x16b1599b, (q31_t)0x16ab2a90, + (q31_t)0x16a4fb77, (q31_t)0x169ecc50, (q31_t)0x16989d1b, (q31_t)0x16926dd8, + (q31_t)0x168c3e87, (q31_t)0x16860f29, (q31_t)0x167fdfbc, (q31_t)0x1679b042, + (q31_t)0x167380ba, (q31_t)0x166d5123, (q31_t)0x1667217f, (q31_t)0x1660f1ce, + (q31_t)0x165ac20e, (q31_t)0x16549241, (q31_t)0x164e6266, (q31_t)0x1648327d, + (q31_t)0x16420286, (q31_t)0x163bd282, (q31_t)0x1635a270, (q31_t)0x162f7250, + (q31_t)0x16294222, (q31_t)0x162311e7, (q31_t)0x161ce19e, (q31_t)0x1616b148, + (q31_t)0x161080e4, (q31_t)0x160a5072, (q31_t)0x16041ff3, (q31_t)0x15fdef66, + (q31_t)0x15f7becc, (q31_t)0x15f18e24, (q31_t)0x15eb5d6e, (q31_t)0x15e52cab, + (q31_t)0x15defbdb, (q31_t)0x15d8cafd, (q31_t)0x15d29a11, (q31_t)0x15cc6918, + (q31_t)0x15c63812, (q31_t)0x15c006fe, (q31_t)0x15b9d5dd, (q31_t)0x15b3a4ae, + (q31_t)0x15ad7372, (q31_t)0x15a74228, (q31_t)0x15a110d2, (q31_t)0x159adf6e, + (q31_t)0x1594adfc, (q31_t)0x158e7c7d, (q31_t)0x15884af1, (q31_t)0x15821958, + (q31_t)0x157be7b1, (q31_t)0x1575b5fe, (q31_t)0x156f843c, (q31_t)0x1569526e, + (q31_t)0x15632093, (q31_t)0x155ceeaa, (q31_t)0x1556bcb4, (q31_t)0x15508ab1, + (q31_t)0x154a58a1, (q31_t)0x15442683, (q31_t)0x153df459, (q31_t)0x1537c221, + (q31_t)0x15318fdd, (q31_t)0x152b5d8b, (q31_t)0x15252b2c, (q31_t)0x151ef8c0, + (q31_t)0x1518c648, (q31_t)0x151293c2, (q31_t)0x150c612f, (q31_t)0x15062e8f, + (q31_t)0x14fffbe2, (q31_t)0x14f9c928, (q31_t)0x14f39662, (q31_t)0x14ed638e, + (q31_t)0x14e730ae, (q31_t)0x14e0fdc0, (q31_t)0x14dacac6, (q31_t)0x14d497bf, + (q31_t)0x14ce64ab, (q31_t)0x14c8318a, (q31_t)0x14c1fe5c, (q31_t)0x14bbcb22, + (q31_t)0x14b597da, (q31_t)0x14af6486, (q31_t)0x14a93125, (q31_t)0x14a2fdb8, + (q31_t)0x149cca3e, (q31_t)0x149696b7, (q31_t)0x14906323, (q31_t)0x148a2f82, + (q31_t)0x1483fbd5, (q31_t)0x147dc81c, (q31_t)0x14779455, (q31_t)0x14716082, + (q31_t)0x146b2ca3, (q31_t)0x1464f8b7, (q31_t)0x145ec4be, (q31_t)0x145890b9, + (q31_t)0x14525ca7, (q31_t)0x144c2888, (q31_t)0x1445f45d, (q31_t)0x143fc026, + (q31_t)0x14398be2, (q31_t)0x14335792, (q31_t)0x142d2335, (q31_t)0x1426eecb, + (q31_t)0x1420ba56, (q31_t)0x141a85d3, (q31_t)0x14145145, (q31_t)0x140e1caa, + (q31_t)0x1407e803, (q31_t)0x1401b34f, (q31_t)0x13fb7e8f, (q31_t)0x13f549c3, + (q31_t)0x13ef14ea, (q31_t)0x13e8e005, (q31_t)0x13e2ab14, (q31_t)0x13dc7616, + (q31_t)0x13d6410d, (q31_t)0x13d00bf7, (q31_t)0x13c9d6d4, (q31_t)0x13c3a1a6, + (q31_t)0x13bd6c6b, (q31_t)0x13b73725, (q31_t)0x13b101d2, (q31_t)0x13aacc73, + (q31_t)0x13a49707, (q31_t)0x139e6190, (q31_t)0x13982c0d, (q31_t)0x1391f67d, + (q31_t)0x138bc0e1, (q31_t)0x13858b3a, (q31_t)0x137f5586, (q31_t)0x13791fc6, + (q31_t)0x1372e9fb, (q31_t)0x136cb423, (q31_t)0x13667e3f, (q31_t)0x13604850, + (q31_t)0x135a1254, (q31_t)0x1353dc4c, (q31_t)0x134da639, (q31_t)0x1347701a, + (q31_t)0x134139ee, (q31_t)0x133b03b7, (q31_t)0x1334cd74, (q31_t)0x132e9725, + (q31_t)0x132860ca, (q31_t)0x13222a64, (q31_t)0x131bf3f2, (q31_t)0x1315bd73, + (q31_t)0x130f86ea, (q31_t)0x13095054, (q31_t)0x130319b3, (q31_t)0x12fce305, + (q31_t)0x12f6ac4d, (q31_t)0x12f07588, (q31_t)0x12ea3eb8, (q31_t)0x12e407dc, + (q31_t)0x12ddd0f4, (q31_t)0x12d79a01, (q31_t)0x12d16303, (q31_t)0x12cb2bf8, + (q31_t)0x12c4f4e2, (q31_t)0x12bebdc1, (q31_t)0x12b88693, (q31_t)0x12b24f5b, + (q31_t)0x12ac1817, (q31_t)0x12a5e0c7, (q31_t)0x129fa96c, (q31_t)0x12997205, + (q31_t)0x12933a93, (q31_t)0x128d0315, (q31_t)0x1286cb8c, (q31_t)0x128093f7, + (q31_t)0x127a5c57, (q31_t)0x127424ac, (q31_t)0x126decf5, (q31_t)0x1267b533, + (q31_t)0x12617d66, (q31_t)0x125b458d, (q31_t)0x12550da9, (q31_t)0x124ed5ba, + (q31_t)0x12489dbf, (q31_t)0x124265b9, (q31_t)0x123c2da8, (q31_t)0x1235f58b, + (q31_t)0x122fbd63, (q31_t)0x12298530, (q31_t)0x12234cf2, (q31_t)0x121d14a9, + (q31_t)0x1216dc54, (q31_t)0x1210a3f5, (q31_t)0x120a6b8a, (q31_t)0x12043314, + (q31_t)0x11fdfa93, (q31_t)0x11f7c207, (q31_t)0x11f18970, (q31_t)0x11eb50cd, + (q31_t)0x11e51820, (q31_t)0x11dedf68, (q31_t)0x11d8a6a4, (q31_t)0x11d26dd6, + (q31_t)0x11cc34fc, (q31_t)0x11c5fc18, (q31_t)0x11bfc329, (q31_t)0x11b98a2e, + (q31_t)0x11b35129, (q31_t)0x11ad1819, (q31_t)0x11a6defe, (q31_t)0x11a0a5d8, + (q31_t)0x119a6ca7, (q31_t)0x1194336b, (q31_t)0x118dfa25, (q31_t)0x1187c0d3, + (q31_t)0x11818777, (q31_t)0x117b4e10, (q31_t)0x1175149e, (q31_t)0x116edb22, + (q31_t)0x1168a19b, (q31_t)0x11626809, (q31_t)0x115c2e6c, (q31_t)0x1155f4c4, + (q31_t)0x114fbb12, (q31_t)0x11498156, (q31_t)0x1143478e, (q31_t)0x113d0dbc, + (q31_t)0x1136d3df, (q31_t)0x113099f8, (q31_t)0x112a6006, (q31_t)0x11242609, + (q31_t)0x111dec02, (q31_t)0x1117b1f0, (q31_t)0x111177d4, (q31_t)0x110b3dad, + (q31_t)0x1105037c, (q31_t)0x10fec940, (q31_t)0x10f88efa, (q31_t)0x10f254a9, + (q31_t)0x10ec1a4e, (q31_t)0x10e5dfe8, (q31_t)0x10dfa578, (q31_t)0x10d96afe, + (q31_t)0x10d33079, (q31_t)0x10ccf5ea, (q31_t)0x10c6bb50, (q31_t)0x10c080ac, + (q31_t)0x10ba45fe, (q31_t)0x10b40b45, (q31_t)0x10add082, (q31_t)0x10a795b5, + (q31_t)0x10a15ade, (q31_t)0x109b1ffc, (q31_t)0x1094e510, (q31_t)0x108eaa1a, + (q31_t)0x10886f19, (q31_t)0x1082340f, (q31_t)0x107bf8fa, (q31_t)0x1075bddb, + (q31_t)0x106f82b2, (q31_t)0x1069477f, (q31_t)0x10630c41, (q31_t)0x105cd0fa, + (q31_t)0x105695a8, (q31_t)0x10505a4d, (q31_t)0x104a1ee7, (q31_t)0x1043e377, + (q31_t)0x103da7fd, (q31_t)0x10376c79, (q31_t)0x103130ec, (q31_t)0x102af554, + (q31_t)0x1024b9b2, (q31_t)0x101e7e06, (q31_t)0x10184251, (q31_t)0x10120691, + (q31_t)0x100bcac7, (q31_t)0x10058ef4, (q31_t)0xfff5317, (q31_t)0xff91730, + (q31_t)0xff2db3e, (q31_t)0xfec9f44, (q31_t)0xfe6633f, (q31_t)0xfe02730, + (q31_t)0xfd9eb18, (q31_t)0xfd3aef6, (q31_t)0xfcd72ca, (q31_t)0xfc73695, + (q31_t)0xfc0fa55, (q31_t)0xfbabe0c, (q31_t)0xfb481ba, (q31_t)0xfae455d, + (q31_t)0xfa808f7, (q31_t)0xfa1cc87, (q31_t)0xf9b900e, (q31_t)0xf95538b, + (q31_t)0xf8f16fe, (q31_t)0xf88da68, (q31_t)0xf829dc8, (q31_t)0xf7c611f, + (q31_t)0xf76246c, (q31_t)0xf6fe7af, (q31_t)0xf69aae9, (q31_t)0xf636e1a, + (q31_t)0xf5d3141, (q31_t)0xf56f45e, (q31_t)0xf50b773, (q31_t)0xf4a7a7d, + (q31_t)0xf443d7e, (q31_t)0xf3e0076, (q31_t)0xf37c365, (q31_t)0xf318649, + (q31_t)0xf2b4925, (q31_t)0xf250bf7, (q31_t)0xf1ecec0, (q31_t)0xf189180, + (q31_t)0xf125436, (q31_t)0xf0c16e3, (q31_t)0xf05d987, (q31_t)0xeff9c21, + (q31_t)0xef95eb2, (q31_t)0xef3213a, (q31_t)0xeece3b9, (q31_t)0xee6a62f, + (q31_t)0xee0689b, (q31_t)0xeda2afe, (q31_t)0xed3ed58, (q31_t)0xecdafa9, + (q31_t)0xec771f1, (q31_t)0xec1342f, (q31_t)0xebaf665, (q31_t)0xeb4b891, + (q31_t)0xeae7ab4, (q31_t)0xea83ccf, (q31_t)0xea1fee0, (q31_t)0xe9bc0e8, + (q31_t)0xe9582e7, (q31_t)0xe8f44dd, (q31_t)0xe8906cb, (q31_t)0xe82c8af, + (q31_t)0xe7c8a8a, (q31_t)0xe764c5c, (q31_t)0xe700e26, (q31_t)0xe69cfe6, + (q31_t)0xe63919e, (q31_t)0xe5d534d, (q31_t)0xe5714f3, (q31_t)0xe50d690, + (q31_t)0xe4a9824, (q31_t)0xe4459af, (q31_t)0xe3e1b32, (q31_t)0xe37dcac, + (q31_t)0xe319e1d, (q31_t)0xe2b5f85, (q31_t)0xe2520e5, (q31_t)0xe1ee23c, + (q31_t)0xe18a38a, (q31_t)0xe1264cf, (q31_t)0xe0c260c, (q31_t)0xe05e740, + (q31_t)0xdffa86b, (q31_t)0xdf9698e, (q31_t)0xdf32aa8, (q31_t)0xdecebba, + (q31_t)0xde6acc3, (q31_t)0xde06dc3, (q31_t)0xdda2ebb, (q31_t)0xdd3efab, + (q31_t)0xdcdb091, (q31_t)0xdc77170, (q31_t)0xdc13245, (q31_t)0xdbaf313, + (q31_t)0xdb4b3d7, (q31_t)0xdae7494, (q31_t)0xda83548, (q31_t)0xda1f5f3, + (q31_t)0xd9bb696, (q31_t)0xd957731, (q31_t)0xd8f37c3, (q31_t)0xd88f84d, + (q31_t)0xd82b8cf, (q31_t)0xd7c7948, (q31_t)0xd7639b9, (q31_t)0xd6ffa22, + (q31_t)0xd69ba82, (q31_t)0xd637ada, (q31_t)0xd5d3b2a, (q31_t)0xd56fb71, + (q31_t)0xd50bbb1, (q31_t)0xd4a7be8, (q31_t)0xd443c17, (q31_t)0xd3dfc3e, + (q31_t)0xd37bc5c, (q31_t)0xd317c73, (q31_t)0xd2b3c81, (q31_t)0xd24fc87, + (q31_t)0xd1ebc85, (q31_t)0xd187c7b, (q31_t)0xd123c69, (q31_t)0xd0bfc4f, + (q31_t)0xd05bc2d, (q31_t)0xcff7c02, (q31_t)0xcf93bd0, (q31_t)0xcf2fb96, + (q31_t)0xcecbb53, (q31_t)0xce67b09, (q31_t)0xce03ab7, (q31_t)0xcd9fa5d, + (q31_t)0xcd3b9fb, (q31_t)0xccd7991, (q31_t)0xcc7391f, (q31_t)0xcc0f8a5, + (q31_t)0xcbab824, (q31_t)0xcb4779a, (q31_t)0xcae3709, (q31_t)0xca7f670, + (q31_t)0xca1b5cf, (q31_t)0xc9b7526, (q31_t)0xc953475, (q31_t)0xc8ef3bd, + (q31_t)0xc88b2fd, (q31_t)0xc827235, (q31_t)0xc7c3166, (q31_t)0xc75f08f, + (q31_t)0xc6fafb0, (q31_t)0xc696ec9, (q31_t)0xc632ddb, (q31_t)0xc5cece5, + (q31_t)0xc56abe8, (q31_t)0xc506ae3, (q31_t)0xc4a29d6, (q31_t)0xc43e8c2, + (q31_t)0xc3da7a6, (q31_t)0xc376683, (q31_t)0xc312558, (q31_t)0xc2ae425, + (q31_t)0xc24a2eb, (q31_t)0xc1e61aa, (q31_t)0xc182061, (q31_t)0xc11df11, + (q31_t)0xc0b9db9, (q31_t)0xc055c5a, (q31_t)0xbff1af3, (q31_t)0xbf8d985, + (q31_t)0xbf29810, (q31_t)0xbec5693, (q31_t)0xbe6150f, (q31_t)0xbdfd383, + (q31_t)0xbd991f0, (q31_t)0xbd35056, (q31_t)0xbcd0eb5, (q31_t)0xbc6cd0c, + (q31_t)0xbc08b5c, (q31_t)0xbba49a5, (q31_t)0xbb407e7, (q31_t)0xbadc621, + (q31_t)0xba78454, (q31_t)0xba14280, (q31_t)0xb9b00a5, (q31_t)0xb94bec2, + (q31_t)0xb8e7cd9, (q31_t)0xb883ae8, (q31_t)0xb81f8f0, (q31_t)0xb7bb6f2, + (q31_t)0xb7574ec, (q31_t)0xb6f32df, (q31_t)0xb68f0cb, (q31_t)0xb62aeaf, + (q31_t)0xb5c6c8d, (q31_t)0xb562a64, (q31_t)0xb4fe834, (q31_t)0xb49a5fd, + (q31_t)0xb4363bf, (q31_t)0xb3d217a, (q31_t)0xb36df2e, (q31_t)0xb309cdb, + (q31_t)0xb2a5a81, (q31_t)0xb241820, (q31_t)0xb1dd5b9, (q31_t)0xb17934b, + (q31_t)0xb1150d5, (q31_t)0xb0b0e59, (q31_t)0xb04cbd6, (q31_t)0xafe894d, + (q31_t)0xaf846bc, (q31_t)0xaf20425, (q31_t)0xaebc187, (q31_t)0xae57ee2, + (q31_t)0xadf3c37, (q31_t)0xad8f985, (q31_t)0xad2b6cc, (q31_t)0xacc740c, + (q31_t)0xac63146, (q31_t)0xabfee79, (q31_t)0xab9aba6, (q31_t)0xab368cc, + (q31_t)0xaad25eb, (q31_t)0xaa6e304, (q31_t)0xaa0a016, (q31_t)0xa9a5d22, + (q31_t)0xa941a27, (q31_t)0xa8dd725, (q31_t)0xa87941d, (q31_t)0xa81510f, + (q31_t)0xa7b0dfa, (q31_t)0xa74cadf, (q31_t)0xa6e87bd, (q31_t)0xa684495, + (q31_t)0xa620166, (q31_t)0xa5bbe31, (q31_t)0xa557af5, (q31_t)0xa4f37b3, + (q31_t)0xa48f46b, (q31_t)0xa42b11d, (q31_t)0xa3c6dc8, (q31_t)0xa362a6d, + (q31_t)0xa2fe70b, (q31_t)0xa29a3a3, (q31_t)0xa236035, (q31_t)0xa1d1cc1, + (q31_t)0xa16d946, (q31_t)0xa1095c6, (q31_t)0xa0a523f, (q31_t)0xa040eb1, + (q31_t)0x9fdcb1e, (q31_t)0x9f78784, (q31_t)0x9f143e5, (q31_t)0x9eb003f, + (q31_t)0x9e4bc93, (q31_t)0x9de78e1, (q31_t)0x9d83529, (q31_t)0x9d1f16b, + (q31_t)0x9cbada7, (q31_t)0x9c569dc, (q31_t)0x9bf260c, (q31_t)0x9b8e236, + (q31_t)0x9b29e59, (q31_t)0x9ac5a77, (q31_t)0x9a6168f, (q31_t)0x99fd2a0, + (q31_t)0x9998eac, (q31_t)0x9934ab2, (q31_t)0x98d06b2, (q31_t)0x986c2ac, + (q31_t)0x9807ea1, (q31_t)0x97a3a8f, (q31_t)0x973f678, (q31_t)0x96db25a, + (q31_t)0x9676e37, (q31_t)0x9612a0e, (q31_t)0x95ae5e0, (q31_t)0x954a1ab, + (q31_t)0x94e5d71, (q31_t)0x9481931, (q31_t)0x941d4eb, (q31_t)0x93b90a0, + (q31_t)0x9354c4f, (q31_t)0x92f07f8, (q31_t)0x928c39b, (q31_t)0x9227f39, + (q31_t)0x91c3ad2, (q31_t)0x915f664, (q31_t)0x90fb1f1, (q31_t)0x9096d79, + (q31_t)0x90328fb, (q31_t)0x8fce477, (q31_t)0x8f69fee, (q31_t)0x8f05b5f, + (q31_t)0x8ea16cb, (q31_t)0x8e3d231, (q31_t)0x8dd8d92, (q31_t)0x8d748ed, + (q31_t)0x8d10443, (q31_t)0x8cabf93, (q31_t)0x8c47ade, (q31_t)0x8be3624, + (q31_t)0x8b7f164, (q31_t)0x8b1ac9f, (q31_t)0x8ab67d4, (q31_t)0x8a52304, + (q31_t)0x89ede2f, (q31_t)0x8989955, (q31_t)0x8925475, (q31_t)0x88c0f90, + (q31_t)0x885caa5, (q31_t)0x87f85b5, (q31_t)0x87940c1, (q31_t)0x872fbc6, + (q31_t)0x86cb6c7, (q31_t)0x86671c2, (q31_t)0x8602cb9, (q31_t)0x859e7aa, + (q31_t)0x853a296, (q31_t)0x84d5d7d, (q31_t)0x847185e, (q31_t)0x840d33b, + (q31_t)0x83a8e12, (q31_t)0x83448e5, (q31_t)0x82e03b2, (q31_t)0x827be7a, + (q31_t)0x821793e, (q31_t)0x81b33fc, (q31_t)0x814eeb5, (q31_t)0x80ea969, + (q31_t)0x8086419, (q31_t)0x8021ec3, (q31_t)0x7fbd968, (q31_t)0x7f59409, + (q31_t)0x7ef4ea4, (q31_t)0x7e9093b, (q31_t)0x7e2c3cd, (q31_t)0x7dc7e5a, + (q31_t)0x7d638e2, (q31_t)0x7cff365, (q31_t)0x7c9ade4, (q31_t)0x7c3685d, + (q31_t)0x7bd22d2, (q31_t)0x7b6dd42, (q31_t)0x7b097ad, (q31_t)0x7aa5214, + (q31_t)0x7a40c76, (q31_t)0x79dc6d3, (q31_t)0x797812b, (q31_t)0x7913b7f, + (q31_t)0x78af5ce, (q31_t)0x784b019, (q31_t)0x77e6a5e, (q31_t)0x77824a0, + (q31_t)0x771dedc, (q31_t)0x76b9914, (q31_t)0x7655347, (q31_t)0x75f0d76, + (q31_t)0x758c7a1, (q31_t)0x75281c6, (q31_t)0x74c3be7, (q31_t)0x745f604, + (q31_t)0x73fb01c, (q31_t)0x7396a30, (q31_t)0x733243f, (q31_t)0x72cde4a, + (q31_t)0x7269851, (q31_t)0x7205253, (q31_t)0x71a0c50, (q31_t)0x713c64a, + (q31_t)0x70d803f, (q31_t)0x7073a2f, (q31_t)0x700f41b, (q31_t)0x6faae03, + (q31_t)0x6f467e7, (q31_t)0x6ee21c6, (q31_t)0x6e7dba1, (q31_t)0x6e19578, + (q31_t)0x6db4f4a, (q31_t)0x6d50919, (q31_t)0x6cec2e3, (q31_t)0x6c87ca9, + (q31_t)0x6c2366a, (q31_t)0x6bbf028, (q31_t)0x6b5a9e1, (q31_t)0x6af6396, + (q31_t)0x6a91d47, (q31_t)0x6a2d6f4, (q31_t)0x69c909d, (q31_t)0x6964a42, + (q31_t)0x69003e3, (q31_t)0x689bd80, (q31_t)0x6837718, (q31_t)0x67d30ad, + (q31_t)0x676ea3d, (q31_t)0x670a3ca, (q31_t)0x66a5d53, (q31_t)0x66416d8, + (q31_t)0x65dd058, (q31_t)0x65789d5, (q31_t)0x651434e, (q31_t)0x64afcc3, + (q31_t)0x644b634, (q31_t)0x63e6fa2, (q31_t)0x638290b, (q31_t)0x631e271, + (q31_t)0x62b9bd3, (q31_t)0x6255531, (q31_t)0x61f0e8b, (q31_t)0x618c7e1, + (q31_t)0x6128134, (q31_t)0x60c3a83, (q31_t)0x605f3ce, (q31_t)0x5ffad15, + (q31_t)0x5f96659, (q31_t)0x5f31f99, (q31_t)0x5ecd8d6, (q31_t)0x5e6920e, + (q31_t)0x5e04b43, (q31_t)0x5da0475, (q31_t)0x5d3bda3, (q31_t)0x5cd76cd, + (q31_t)0x5c72ff4, (q31_t)0x5c0e917, (q31_t)0x5baa237, (q31_t)0x5b45b53, + (q31_t)0x5ae146b, (q31_t)0x5a7cd80, (q31_t)0x5a18692, (q31_t)0x59b3fa0, + (q31_t)0x594f8aa, (q31_t)0x58eb1b2, (q31_t)0x5886ab5, (q31_t)0x58223b6, + (q31_t)0x57bdcb3, (q31_t)0x57595ac, (q31_t)0x56f4ea2, (q31_t)0x5690795, + (q31_t)0x562c085, (q31_t)0x55c7971, (q31_t)0x556325a, (q31_t)0x54feb3f, + (q31_t)0x549a422, (q31_t)0x5435d01, (q31_t)0x53d15dd, (q31_t)0x536ceb5, + (q31_t)0x530878a, (q31_t)0x52a405d, (q31_t)0x523f92c, (q31_t)0x51db1f7, + (q31_t)0x5176ac0, (q31_t)0x5112385, (q31_t)0x50adc48, (q31_t)0x5049507, + (q31_t)0x4fe4dc3, (q31_t)0x4f8067c, (q31_t)0x4f1bf32, (q31_t)0x4eb77e5, + (q31_t)0x4e53095, (q31_t)0x4dee942, (q31_t)0x4d8a1ec, (q31_t)0x4d25a93, + (q31_t)0x4cc1337, (q31_t)0x4c5cbd8, (q31_t)0x4bf8476, (q31_t)0x4b93d11, + (q31_t)0x4b2f5a9, (q31_t)0x4acae3e, (q31_t)0x4a666d1, (q31_t)0x4a01f60, + (q31_t)0x499d7ed, (q31_t)0x4939077, (q31_t)0x48d48fe, (q31_t)0x4870182, + (q31_t)0x480ba04, (q31_t)0x47a7282, (q31_t)0x4742afe, (q31_t)0x46de377, + (q31_t)0x4679bee, (q31_t)0x4615461, (q31_t)0x45b0cd2, (q31_t)0x454c541, + (q31_t)0x44e7dac, (q31_t)0x4483615, (q31_t)0x441ee7c, (q31_t)0x43ba6df, + (q31_t)0x4355f40, (q31_t)0x42f179f, (q31_t)0x428cffb, (q31_t)0x4228854, + (q31_t)0x41c40ab, (q31_t)0x415f8ff, (q31_t)0x40fb151, (q31_t)0x40969a0, + (q31_t)0x40321ed, (q31_t)0x3fcda37, (q31_t)0x3f6927f, (q31_t)0x3f04ac4, + (q31_t)0x3ea0307, (q31_t)0x3e3bb48, (q31_t)0x3dd7386, (q31_t)0x3d72bc2, + (q31_t)0x3d0e3fb, (q31_t)0x3ca9c32, (q31_t)0x3c45467, (q31_t)0x3be0c99, + (q31_t)0x3b7c4c9, (q31_t)0x3b17cf7, (q31_t)0x3ab3523, (q31_t)0x3a4ed4c, + (q31_t)0x39ea573, (q31_t)0x3985d97, (q31_t)0x39215ba, (q31_t)0x38bcdda, + (q31_t)0x38585f8, (q31_t)0x37f3e14, (q31_t)0x378f62e, (q31_t)0x372ae46, + (q31_t)0x36c665b, (q31_t)0x3661e6f, (q31_t)0x35fd680, (q31_t)0x3598e8f, + (q31_t)0x353469c, (q31_t)0x34cfea8, (q31_t)0x346b6b1, (q31_t)0x3406eb8, + (q31_t)0x33a26bd, (q31_t)0x333dec0, (q31_t)0x32d96c1, (q31_t)0x3274ec0, + (q31_t)0x32106bd, (q31_t)0x31abeb9, (q31_t)0x31476b2, (q31_t)0x30e2ea9, + (q31_t)0x307e69f, (q31_t)0x3019e93, (q31_t)0x2fb5684, (q31_t)0x2f50e74, + (q31_t)0x2eec663, (q31_t)0x2e87e4f, (q31_t)0x2e2363a, (q31_t)0x2dbee22, + (q31_t)0x2d5a609, (q31_t)0x2cf5def, (q31_t)0x2c915d2, (q31_t)0x2c2cdb4, + (q31_t)0x2bc8594, (q31_t)0x2b63d73, (q31_t)0x2aff54f, (q31_t)0x2a9ad2a, + (q31_t)0x2a36504, (q31_t)0x29d1cdc, (q31_t)0x296d4b2, (q31_t)0x2908c87, + (q31_t)0x28a445a, (q31_t)0x283fc2b, (q31_t)0x27db3fb, (q31_t)0x2776bc9, + (q31_t)0x2712396, (q31_t)0x26adb62, (q31_t)0x264932b, (q31_t)0x25e4af4, + (q31_t)0x25802bb, (q31_t)0x251ba80, (q31_t)0x24b7244, (q31_t)0x2452a07, + (q31_t)0x23ee1c8, (q31_t)0x2389988, (q31_t)0x2325147, (q31_t)0x22c0904, + (q31_t)0x225c0bf, (q31_t)0x21f787a, (q31_t)0x2193033, (q31_t)0x212e7eb, + (q31_t)0x20c9fa1, (q31_t)0x2065757, (q31_t)0x2000f0b, (q31_t)0x1f9c6be, + (q31_t)0x1f37e6f, (q31_t)0x1ed3620, (q31_t)0x1e6edcf, (q31_t)0x1e0a57d, + (q31_t)0x1da5d2a, (q31_t)0x1d414d6, (q31_t)0x1cdcc80, (q31_t)0x1c7842a, + (q31_t)0x1c13bd2, (q31_t)0x1baf37a, (q31_t)0x1b4ab20, (q31_t)0x1ae62c5, + (q31_t)0x1a81a69, (q31_t)0x1a1d20c, (q31_t)0x19b89ae, (q31_t)0x1954150, + (q31_t)0x18ef8f0, (q31_t)0x188b08f, (q31_t)0x182682d, (q31_t)0x17c1fcb, + (q31_t)0x175d767, (q31_t)0x16f8f03, (q31_t)0x169469d, (q31_t)0x162fe37, + (q31_t)0x15cb5d0, (q31_t)0x1566d68, (q31_t)0x15024ff, (q31_t)0x149dc96, + (q31_t)0x143942b, (q31_t)0x13d4bc0, (q31_t)0x1370354, (q31_t)0x130bae7, + (q31_t)0x12a727a, (q31_t)0x1242a0c, (q31_t)0x11de19d, (q31_t)0x117992e, + (q31_t)0x11150be, (q31_t)0x10b084d, (q31_t)0x104bfdb, (q31_t)0xfe7769, + (q31_t)0xf82ef6, (q31_t)0xf1e683, (q31_t)0xeb9e0f, (q31_t)0xe5559b, + (q31_t)0xdf0d26, (q31_t)0xd8c4b0, (q31_t)0xd27c3a, (q31_t)0xcc33c3, + (q31_t)0xc5eb4c, (q31_t)0xbfa2d5, (q31_t)0xb95a5d, (q31_t)0xb311e4, + (q31_t)0xacc96b, (q31_t)0xa680f2, (q31_t)0xa03878, (q31_t)0x99effe, + (q31_t)0x93a784, (q31_t)0x8d5f09, (q31_t)0x87168e, (q31_t)0x80ce12, + (q31_t)0x7a8597, (q31_t)0x743d1a, (q31_t)0x6df49e, (q31_t)0x67ac21, + (q31_t)0x6163a5, (q31_t)0x5b1b27, (q31_t)0x54d2aa, (q31_t)0x4e8a2c, + (q31_t)0x4841af, (q31_t)0x41f931, (q31_t)0x3bb0b3, (q31_t)0x356835, + (q31_t)0x2f1fb6, (q31_t)0x28d738, (q31_t)0x228eb9, (q31_t)0x1c463b, + (q31_t)0x15fdbc, (q31_t)0xfb53d, (q31_t)0x96cbe, (q31_t)0x3243f}; /** @} end of DCT4_IDCT4_Table group @@ -4537,37 +8278,34 @@ static const q31_t cos_factorsQ31_8192[8192] = { @param[in] normalize normalizing factor. @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : N is not a supported transform length + - \ref ARM_MATH_ARGUMENT_ERROR : N is not a + supported transform length @par Normalizing factor: - The normalizing factor is sqrt(2/N), which depends on the size of transform N. - Normalizing factors in 1.31 format are mentioned in the table below for different DCT sizes: + The normalizing factor is sqrt(2/N), which + depends on the size of transform N. Normalizing factors in 1.31 + format are mentioned in the table below for different DCT sizes: \image html dct4NormalizingQ31Table.gif */ -arm_status arm_dct4_init_q31( - arm_dct4_instance_q31 * S, - arm_rfft_instance_q31 * S_RFFT, - arm_cfft_radix4_instance_q31 * S_CFFT, - uint16_t N, - uint16_t Nby2, - q31_t normalize) -{ +arm_status arm_dct4_init_q31(arm_dct4_instance_q31 *S, + arm_rfft_instance_q31 *S_RFFT, + arm_cfft_radix4_instance_q31 *S_CFFT, uint16_t N, + uint16_t Nby2, q31_t normalize) { /* Initialize the default arm status */ arm_status status = ARM_MATH_SUCCESS; - /* Initializing the pointer array with the weight table base addresses of different lengths */ - q31_t *twiddlePtr[4] = - { (q31_t *) WeightsQ31_128, (q31_t *) WeightsQ31_512, - (q31_t *) WeightsQ31_2048, (q31_t *) WeightsQ31_8192 - }; + /* Initializing the pointer array with the weight table base addresses of + * different lengths */ + q31_t *twiddlePtr[4] = {(q31_t *)WeightsQ31_128, (q31_t *)WeightsQ31_512, + (q31_t *)WeightsQ31_2048, (q31_t *)WeightsQ31_8192}; - /* Initializing the pointer array with the cos factor table base addresses of different lengths */ - q31_t *pCosFactor[4] = - { (q31_t *) cos_factorsQ31_128, (q31_t *) cos_factorsQ31_512, - (q31_t *) cos_factorsQ31_2048, (q31_t *) cos_factorsQ31_8192 - }; + /* Initializing the pointer array with the cos factor table base addresses of + * different lengths */ + q31_t *pCosFactor[4] = { + (q31_t *)cos_factorsQ31_128, (q31_t *)cos_factorsQ31_512, + (q31_t *)cos_factorsQ31_2048, (q31_t *)cos_factorsQ31_8192}; /* Initialize the DCT4 length */ S->N = N; @@ -4584,8 +8322,7 @@ arm_status arm_dct4_init_q31( /* Initialize Complex FFT Instance */ S->pCfft = S_CFFT; - switch (N) - { + switch (N) { /* Initialize the table modifier values */ case 8192U: S->pTwiddle = twiddlePtr[3]; @@ -4608,7 +8345,7 @@ arm_status arm_dct4_init_q31( } /* Initialize the RFFT/RIFFT Function */ - arm_rfft_init_q31(S->pRfft, S->N, 0U, 1U); + arm_rfft_init_q31(S->pRfft, S->N, 0U, 1U); /* return the status of DCT4 Init function */ return (status); diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_q15.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_q15.c index f926a1d..d8196c4 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_q15.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_q15.c @@ -39,26 +39,24 @@ @param[in] pState points to state buffer. @param[in,out] pInlineBuffer points to the in-place input and output buffer. @return none - + @par Input an output formats - Internally inputs are downscaled in the RFFT process function to avoid overflows. - Number of bits downscaled, depends on the size of the transform. The input and output - formats for different DCT sizes and number of bits to upscale are mentioned in the table below: + Internally inputs are downscaled in the RFFT process function + to avoid overflows. Number of bits downscaled, depends on the size of the + transform. The input and output formats for different DCT sizes and number of + bits to upscale are mentioned in the table below: \image html dct4FormatsQ15Table.gif */ -void arm_dct4_q15( - const arm_dct4_instance_q15 * S, - q15_t * pState, - q15_t * pInlineBuffer) -{ - const q15_t *weights = S->pTwiddle; /* Pointer to the Weights table */ - const q15_t *cosFact = S->pCosFactor; /* Pointer to the cos factors table */ - q15_t *pS1, *pS2, *pbuff; /* Temporary pointers for input buffer and pState buffer */ - q15_t in; /* Temporary variable */ - uint32_t i; /* Loop counter */ - +void arm_dct4_q15(const arm_dct4_instance_q15 *S, q15_t *pState, + q15_t *pInlineBuffer) { + const q15_t *weights = S->pTwiddle; /* Pointer to the Weights table */ + const q15_t *cosFact = S->pCosFactor; /* Pointer to the cos factors table */ + q15_t *pS1, *pS2, + *pbuff; /* Temporary pointers for input buffer and pState buffer */ + q15_t in; /* Temporary variable */ + uint32_t i; /* Loop counter */ /* DCT4 computation involves DCT2 (which is calculated using RFFT) * along with some pre-processing and post-processing. @@ -71,18 +69,19 @@ void arm_dct4_q15( * (b) Calculation of DCT2 using FFT is divided into three steps: * Step1: Re-ordering of even and odd elements of input. * Step2: Calculating FFT of the re-ordered input. - * Step3: Taking the real part of the product of FFT output and weights. - * (c) Post-processing - DCT4 can be obtained from DCT2 output using the following equation: - * Y4(k) = Y2(k) - Y4(k-1) and Y4(-1) = Y4(0) + * Step3: Taking the real part of the product of FFT output + * and weights. (c) Post-processing - DCT4 can be obtained from DCT2 output + * using the following equation: Y4(k) = Y2(k) - Y4(k-1) and Y4(-1) = Y4(0) * where, * Y4 -- DCT4 output, Y2 -- DCT2 output * (d) Multiplying the output with the normalizing factor sqrt(2/N). */ /*-------- Pre-processing ------------*/ - /* Multiplying input with cos factor i.e. r(n) = 2 * x(n) * cos(pi*(2*n+1)/(4*n)) */ - arm_mult_q15 (pInlineBuffer, cosFact, pInlineBuffer, S->N); - arm_shift_q15 (pInlineBuffer, 1, pInlineBuffer, S->N); + /* Multiplying input with cos factor i.e. r(n) = 2 * x(n) * + * cos(pi*(2*n+1)/(4*n)) */ + arm_mult_q15(pInlineBuffer, cosFact, pInlineBuffer, S->N); + arm_shift_q15(pInlineBuffer, 1, pInlineBuffer, S->N); /* ---------------------------------------------------------------- * Step1: Re-ordering of even and odd elements as @@ -93,22 +92,22 @@ void arm_dct4_q15( /* pS1 initialized to pState */ pS1 = pState; - /* pS2 initialized to pState+N-1, so that it points to the end of the state buffer */ + /* pS2 initialized to pState+N-1, so that it points to the end of the state + * buffer */ pS2 = pState + (S->N - 1U); /* pbuff initialized to input buffer */ pbuff = pInlineBuffer; - -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Initializing the loop counter to N/2 >> 2 for loop unrolling by 4 */ i = S->Nby2 >> 2U; - /* First part of the processing with loop unrolling. Compute 4 outputs at a time. + /* First part of the processing with loop unrolling. Compute 4 outputs at a + *time. ** a second loop below computes the remaining 1 to 3 samples. */ - do - { + do { /* Re-ordering of even and odd elements */ /* pState[i] = pInlineBuffer[2*i] */ *pS1++ = *pbuff++; @@ -139,8 +138,7 @@ void arm_dct4_q15( /* Processing with loop unrolling 4 times as N is always multiple of 4. * Compute 4 outputs at a time */ - do - { + do { /* Writing the re-ordered output back to inplace input buffer */ *pbuff++ = *pS1++; *pbuff++ = *pS1++; @@ -151,21 +149,22 @@ void arm_dct4_q15( i--; } while (i > 0U); - /* --------------------------------------------------------- * Step2: Calculate RFFT for N-point input * ---------------------------------------------------------- */ - /* pInlineBuffer is real input of length N , pState is the complex output of length 2N */ - arm_rfft_q15 (S->pRfft, pInlineBuffer, pState); + /* pInlineBuffer is real input of length N , pState is the complex output of + * length 2N */ + arm_rfft_q15(S->pRfft, pInlineBuffer, pState); /*---------------------------------------------------------------------- * Step3: Multiply the FFT output with the weights. *----------------------------------------------------------------------*/ - arm_cmplx_mult_cmplx_q15 (pState, weights, pState, S->N); + arm_cmplx_mult_cmplx_q15(pState, weights, pState, S->N); /* The output of complex multiplication is in 3.13 format. - * Hence changing the format of N (i.e. 2*N elements) complex numbers to 1.15 format by shifting left by 2 bits. */ - arm_shift_q15 (pState, 2, pState, S->N * 2); + * Hence changing the format of N (i.e. 2*N elements) complex numbers to 1.15 + * format by shifting left by 2 bits. */ + arm_shift_q15(pState, 2, pState, S->N * 2); /* ----------- Post-processing ---------- */ /* DCT-IV can be obtained from DCT-II by the equation, @@ -184,18 +183,22 @@ void arm_dct4_q15( /* Calculating Y4(0) from Y2(0) using Y4(0) = Y2(0)/2 */ in = *pS1++ >> 1U; - /* input buffer acts as inplace, so output values are stored in the input itself. */ + /* input buffer acts as inplace, so output values are stored in the input + * itself. */ *pbuff++ = in; - /* pState pointer is incremented twice as the real values are located alternatively in the array */ + /* pState pointer is incremented twice as the real values are located + * alternatively in the array */ pS1++; - /* First part of the processing with loop unrolling. Compute 4 outputs at a time. + /* First part of the processing with loop unrolling. Compute 4 outputs at a + *time. ** a second loop below computes the remaining 1 to 3 samples. */ - do - { - /* Calculating Y4(1) to Y4(N-1) from Y2 using equation Y4(k) = Y2(k) - Y4(k-1) */ - /* pState pointer (pS1) is incremented twice as the real values are located alternatively in the array */ + do { + /* Calculating Y4(1) to Y4(N-1) from Y2 using equation Y4(k) = Y2(k) - + * Y4(k-1) */ + /* pState pointer (pS1) is incremented twice as the real values are located + * alternatively in the array */ in = *pS1++ - in; *pbuff++ = in; /* points to the next real value */ @@ -217,14 +220,16 @@ void arm_dct4_q15( i--; } while (i > 0U); - /* If the blockSize is not a multiple of 4, compute any remaining output samples here. + /* If the blockSize is not a multiple of 4, compute any remaining output + *samples here. ** No loop unrolling is used. */ i = (S->N - 1U) % 0x4U; - while (i > 0U) - { - /* Calculating Y4(1) to Y4(N-1) from Y2 using equation Y4(k) = Y2(k) - Y4(k-1) */ - /* pState pointer (pS1) is incremented twice as the real values are located alternatively in the array */ + while (i > 0U) { + /* Calculating Y4(1) to Y4(N-1) from Y2 using equation Y4(k) = Y2(k) - + * Y4(k-1) */ + /* pState pointer (pS1) is incremented twice as the real values are located + * alternatively in the array */ in = *pS1++ - in; *pbuff++ = in; @@ -235,8 +240,8 @@ void arm_dct4_q15( i--; } - - /*------------ Normalizing the output by multiplying with the normalizing factor ----------*/ + /*------------ Normalizing the output by multiplying with the normalizing + * factor ----------*/ /* Initializing the loop counter to N/4 instead of N for loop unrolling */ i = S->N >> 2U; @@ -244,34 +249,32 @@ void arm_dct4_q15( /* pbuff initialized to the pInlineBuffer(now contains the output values) */ pbuff = pInlineBuffer; - /* Processing with loop unrolling 4 times as N is always multiple of 4. Compute 4 outputs at a time */ - do - { + /* Processing with loop unrolling 4 times as N is always multiple of 4. + * Compute 4 outputs at a time */ + do { /* Multiplying pInlineBuffer with the normalizing factor sqrt(2/N) */ in = *pbuff; - *pbuff++ = ((q15_t) (((q31_t) in * S->normalize) >> 15)); + *pbuff++ = ((q15_t)(((q31_t)in * S->normalize) >> 15)); in = *pbuff; - *pbuff++ = ((q15_t) (((q31_t) in * S->normalize) >> 15)); + *pbuff++ = ((q15_t)(((q31_t)in * S->normalize) >> 15)); in = *pbuff; - *pbuff++ = ((q15_t) (((q31_t) in * S->normalize) >> 15)); + *pbuff++ = ((q15_t)(((q31_t)in * S->normalize) >> 15)); in = *pbuff; - *pbuff++ = ((q15_t) (((q31_t) in * S->normalize) >> 15)); + *pbuff++ = ((q15_t)(((q31_t)in * S->normalize) >> 15)); /* Decrement loop counter */ i--; } while (i > 0U); - #else /* Initializing the loop counter to N/2 */ i = S->Nby2; - do - { + do { /* Re-ordering of even and odd elements */ /* pState[i] = pInlineBuffer[2*i] */ *pS1++ = *pbuff++; @@ -291,8 +294,7 @@ void arm_dct4_q15( /* Initializing the loop counter */ i = S->N; - do - { + do { /* Writing the re-ordered output back to inplace input buffer */ *pbuff++ = *pS1++; @@ -300,21 +302,22 @@ void arm_dct4_q15( i--; } while (i > 0U); - /* --------------------------------------------------------- * Step2: Calculate RFFT for N-point input * ---------------------------------------------------------- */ - /* pInlineBuffer is real input of length N , pState is the complex output of length 2N */ - arm_rfft_q15 (S->pRfft, pInlineBuffer, pState); + /* pInlineBuffer is real input of length N , pState is the complex output of + * length 2N */ + arm_rfft_q15(S->pRfft, pInlineBuffer, pState); /*---------------------------------------------------------------------- * Step3: Multiply the FFT output with the weights. *----------------------------------------------------------------------*/ - arm_cmplx_mult_cmplx_q15 (pState, weights, pState, S->N); + arm_cmplx_mult_cmplx_q15(pState, weights, pState, S->N); /* The output of complex multiplication is in 3.13 format. - * Hence changing the format of N (i.e. 2*N elements) complex numbers to 1.15 format by shifting left by 2 bits. */ - arm_shift_q15 (pState, 2, pState, S->N * 2); + * Hence changing the format of N (i.e. 2*N elements) complex numbers to 1.15 + * format by shifting left by 2 bits. */ + arm_shift_q15(pState, 2, pState, S->N * 2); /* ----------- Post-processing ---------- */ /* DCT-IV can be obtained from DCT-II by the equation, @@ -330,19 +333,22 @@ void arm_dct4_q15( /* Calculating Y4(0) from Y2(0) using Y4(0) = Y2(0)/2 */ in = *pS1++ >> 1U; - /* input buffer acts as inplace, so output values are stored in the input itself. */ + /* input buffer acts as inplace, so output values are stored in the input + * itself. */ *pbuff++ = in; - /* pState pointer is incremented twice as the real values are located alternatively in the array */ + /* pState pointer is incremented twice as the real values are located + * alternatively in the array */ pS1++; /* Initializing the loop counter */ i = (S->N - 1U); - do - { - /* Calculating Y4(1) to Y4(N-1) from Y2 using equation Y4(k) = Y2(k) - Y4(k-1) */ - /* pState pointer (pS1) is incremented twice as the real values are located alternatively in the array */ + do { + /* Calculating Y4(1) to Y4(N-1) from Y2 using equation Y4(k) = Y2(k) - + * Y4(k-1) */ + /* pState pointer (pS1) is incremented twice as the real values are located + * alternatively in the array */ in = *pS1++ - in; *pbuff++ = in; @@ -353,7 +359,8 @@ void arm_dct4_q15( i--; } while (i > 0U); - /*------------ Normalizing the output by multiplying with the normalizing factor ----------*/ + /*------------ Normalizing the output by multiplying with the normalizing + * factor ----------*/ /* Initializing loop counter */ i = S->N; @@ -361,11 +368,10 @@ void arm_dct4_q15( /* pbuff initialized to the pInlineBuffer (now contains the output values) */ pbuff = pInlineBuffer; - do - { + do { /* Multiplying pInlineBuffer with the normalizing factor sqrt(2/N) */ in = *pbuff; - *pbuff++ = ((q15_t) (((q31_t) in * S->normalize) >> 15)); + *pbuff++ = ((q15_t)(((q31_t)in * S->normalize) >> 15)); /* Decrement loop counter */ i--; @@ -373,7 +379,6 @@ void arm_dct4_q15( } while (i > 0U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - } /** diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_q31.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_q31.c index 369a5c3..15b2cbf 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_q31.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_dct4_q31.c @@ -41,27 +41,24 @@ @return none @par Input an output formats - Input samples need to be downscaled by 1 bit to avoid saturations in the Q31 DCT process, - as the conversion from DCT2 to DCT4 involves one subtraction. - Internally inputs are downscaled in the RFFT process function to avoid overflows. - Number of bits downscaled, depends on the size of the transform. - The input and output formats for different DCT sizes and number of bits to upscale are - mentioned in the table below: + Input samples need to be downscaled by 1 bit to avoid + saturations in the Q31 DCT process, as the conversion from DCT2 to DCT4 + involves one subtraction. Internally inputs are downscaled in the RFFT process + function to avoid overflows. Number of bits downscaled, depends on the size of + the transform. The input and output formats for different DCT sizes and number + of bits to upscale are mentioned in the table below: \image html dct4FormatsQ31Table.gif */ -void arm_dct4_q31( - const arm_dct4_instance_q31 * S, - q31_t * pState, - q31_t * pInlineBuffer) -{ - const q31_t *weights = S->pTwiddle; /* Pointer to the Weights table */ - const q31_t *cosFact = S->pCosFactor; /* Pointer to the cos factors table */ - q31_t *pS1, *pS2, *pbuff; /* Temporary pointers for input buffer and pState buffer */ - q31_t in; /* Temporary variable */ - uint32_t i; /* Loop counter */ - +void arm_dct4_q31(const arm_dct4_instance_q31 *S, q31_t *pState, + q31_t *pInlineBuffer) { + const q31_t *weights = S->pTwiddle; /* Pointer to the Weights table */ + const q31_t *cosFact = S->pCosFactor; /* Pointer to the cos factors table */ + q31_t *pS1, *pS2, + *pbuff; /* Temporary pointers for input buffer and pState buffer */ + q31_t in; /* Temporary variable */ + uint32_t i; /* Loop counter */ /* DCT4 computation involves DCT2 (which is calculated using RFFT) * along with some pre-processing and post-processing. @@ -74,18 +71,19 @@ void arm_dct4_q31( * (b) Calculation of DCT2 using FFT is divided into three steps: * Step1: Re-ordering of even and odd elements of input. * Step2: Calculating FFT of the re-ordered input. - * Step3: Taking the real part of the product of FFT output and weights. - * (c) Post-processing - DCT4 can be obtained from DCT2 output using the following equation: - * Y4(k) = Y2(k) - Y4(k-1) and Y4(-1) = Y4(0) + * Step3: Taking the real part of the product of FFT output + * and weights. (c) Post-processing - DCT4 can be obtained from DCT2 output + * using the following equation: Y4(k) = Y2(k) - Y4(k-1) and Y4(-1) = Y4(0) * where, * Y4 -- DCT4 output, Y2 -- DCT2 output * (d) Multiplying the output with the normalizing factor sqrt(2/N). */ /*-------- Pre-processing ------------*/ - /* Multiplying input with cos factor i.e. r(n) = 2 * x(n) * cos(pi*(2*n+1)/(4*n)) */ - arm_mult_q31 (pInlineBuffer, cosFact, pInlineBuffer, S->N); - arm_shift_q31 (pInlineBuffer, 1, pInlineBuffer, S->N); + /* Multiplying input with cos factor i.e. r(n) = 2 * x(n) * + * cos(pi*(2*n+1)/(4*n)) */ + arm_mult_q31(pInlineBuffer, cosFact, pInlineBuffer, S->N); + arm_shift_q31(pInlineBuffer, 1, pInlineBuffer, S->N); /* ---------------------------------------------------------------- * Step1: Re-ordering of even and odd elements as @@ -96,22 +94,22 @@ void arm_dct4_q31( /* pS1 initialized to pState */ pS1 = pState; - /* pS2 initialized to pState+N-1, so that it points to the end of the state buffer */ + /* pS2 initialized to pState+N-1, so that it points to the end of the state + * buffer */ pS2 = pState + (S->N - 1U); /* pbuff initialized to input buffer */ pbuff = pInlineBuffer; - -#if defined (ARM_MATH_LOOPUNROLL) +#if defined(ARM_MATH_LOOPUNROLL) /* Initializing the loop counter to N/2 >> 2 for loop unrolling by 4 */ i = S->Nby2 >> 2U; - /* First part of the processing with loop unrolling. Compute 4 outputs at a time. + /* First part of the processing with loop unrolling. Compute 4 outputs at a + *time. ** a second loop below computes the remaining 1 to 3 samples. */ - do - { + do { /* Re-ordering of even and odd elements */ /* pState[i] = pInlineBuffer[2*i] */ *pS1++ = *pbuff++; @@ -142,8 +140,7 @@ void arm_dct4_q31( /* Processing with loop unrolling 4 times as N is always multiple of 4. * Compute 4 outputs at a time */ - do - { + do { /* Writing the re-ordered output back to inplace input buffer */ *pbuff++ = *pS1++; *pbuff++ = *pS1++; @@ -154,21 +151,22 @@ void arm_dct4_q31( i--; } while (i > 0U); - /* --------------------------------------------------------- * Step2: Calculate RFFT for N-point input * ---------------------------------------------------------- */ - /* pInlineBuffer is real input of length N , pState is the complex output of length 2N */ - arm_rfft_q31 (S->pRfft, pInlineBuffer, pState); + /* pInlineBuffer is real input of length N , pState is the complex output of + * length 2N */ + arm_rfft_q31(S->pRfft, pInlineBuffer, pState); /*---------------------------------------------------------------------- * Step3: Multiply the FFT output with the weights. *----------------------------------------------------------------------*/ - arm_cmplx_mult_cmplx_q31 (pState, weights, pState, S->N); + arm_cmplx_mult_cmplx_q31(pState, weights, pState, S->N); /* The output of complex multiplication is in 3.29 format. - * Hence changing the format of N (i.e. 2*N elements) complex numbers to 1.31 format by shifting left by 2 bits. */ - arm_shift_q31 (pState, 2, pState, S->N * 2); + * Hence changing the format of N (i.e. 2*N elements) complex numbers to 1.31 + * format by shifting left by 2 bits. */ + arm_shift_q31(pState, 2, pState, S->N * 2); /* ----------- Post-processing ---------- */ /* DCT-IV can be obtained from DCT-II by the equation, @@ -187,18 +185,22 @@ void arm_dct4_q31( /* Calculating Y4(0) from Y2(0) using Y4(0) = Y2(0)/2 */ in = *pS1++ >> 1U; - /* input buffer acts as inplace, so output values are stored in the input itself. */ + /* input buffer acts as inplace, so output values are stored in the input + * itself. */ *pbuff++ = in; - /* pState pointer is incremented twice as the real values are located alternatively in the array */ + /* pState pointer is incremented twice as the real values are located + * alternatively in the array */ pS1++; - /* First part of the processing with loop unrolling. Compute 4 outputs at a time. + /* First part of the processing with loop unrolling. Compute 4 outputs at a + *time. ** a second loop below computes the remaining 1 to 3 samples. */ - do - { - /* Calculating Y4(1) to Y4(N-1) from Y2 using equation Y4(k) = Y2(k) - Y4(k-1) */ - /* pState pointer (pS1) is incremented twice as the real values are located alternatively in the array */ + do { + /* Calculating Y4(1) to Y4(N-1) from Y2 using equation Y4(k) = Y2(k) - + * Y4(k-1) */ + /* pState pointer (pS1) is incremented twice as the real values are located + * alternatively in the array */ in = *pS1++ - in; *pbuff++ = in; /* points to the next real value */ @@ -220,14 +222,16 @@ void arm_dct4_q31( i--; } while (i > 0U); - /* If the blockSize is not a multiple of 4, compute any remaining output samples here. + /* If the blockSize is not a multiple of 4, compute any remaining output + *samples here. ** No loop unrolling is used. */ i = (S->N - 1U) % 0x4U; - while (i > 0U) - { - /* Calculating Y4(1) to Y4(N-1) from Y2 using equation Y4(k) = Y2(k) - Y4(k-1) */ - /* pState pointer (pS1) is incremented twice as the real values are located alternatively in the array */ + while (i > 0U) { + /* Calculating Y4(1) to Y4(N-1) from Y2 using equation Y4(k) = Y2(k) - + * Y4(k-1) */ + /* pState pointer (pS1) is incremented twice as the real values are located + * alternatively in the array */ in = *pS1++ - in; *pbuff++ = in; @@ -238,8 +242,8 @@ void arm_dct4_q31( i--; } - - /*------------ Normalizing the output by multiplying with the normalizing factor ----------*/ + /*------------ Normalizing the output by multiplying with the normalizing + * factor ----------*/ /* Initializing the loop counter to N/4 instead of N for loop unrolling */ i = S->N >> 2U; @@ -247,34 +251,32 @@ void arm_dct4_q31( /* pbuff initialized to the pInlineBuffer(now contains the output values) */ pbuff = pInlineBuffer; - /* Processing with loop unrolling 4 times as N is always multiple of 4. Compute 4 outputs at a time */ - do - { + /* Processing with loop unrolling 4 times as N is always multiple of 4. + * Compute 4 outputs at a time */ + do { /* Multiplying pInlineBuffer with the normalizing factor sqrt(2/N) */ in = *pbuff; - *pbuff++ = ((q31_t) (((q63_t) in * S->normalize) >> 31)); + *pbuff++ = ((q31_t)(((q63_t)in * S->normalize) >> 31)); in = *pbuff; - *pbuff++ = ((q31_t) (((q63_t) in * S->normalize) >> 31)); + *pbuff++ = ((q31_t)(((q63_t)in * S->normalize) >> 31)); in = *pbuff; - *pbuff++ = ((q31_t) (((q63_t) in * S->normalize) >> 31)); + *pbuff++ = ((q31_t)(((q63_t)in * S->normalize) >> 31)); in = *pbuff; - *pbuff++ = ((q31_t) (((q63_t) in * S->normalize) >> 31)); + *pbuff++ = ((q31_t)(((q63_t)in * S->normalize) >> 31)); /* Decrement loop counter */ i--; } while (i > 0U); - #else /* Initializing the loop counter to N/2 */ i = S->Nby2; - do - { + do { /* Re-ordering of even and odd elements */ /* pState[i] = pInlineBuffer[2*i] */ *pS1++ = *pbuff++; @@ -294,8 +296,7 @@ void arm_dct4_q31( /* Initializing the loop counter */ i = S->N; - do - { + do { /* Writing the re-ordered output back to inplace input buffer */ *pbuff++ = *pS1++; @@ -303,20 +304,21 @@ void arm_dct4_q31( i--; } while (i > 0U); - /* --------------------------------------------------------- * Step2: Calculate RFFT for N-point input * ---------------------------------------------------------- */ - /* pInlineBuffer is real input of length N , pState is the complex output of length 2N */ - arm_rfft_q31 (S->pRfft, pInlineBuffer, pState); + /* pInlineBuffer is real input of length N , pState is the complex output of + * length 2N */ + arm_rfft_q31(S->pRfft, pInlineBuffer, pState); /*---------------------------------------------------------------------- * Step3: Multiply the FFT output with the weights. *----------------------------------------------------------------------*/ - arm_cmplx_mult_cmplx_q31 (pState, weights, pState, S->N); + arm_cmplx_mult_cmplx_q31(pState, weights, pState, S->N); /* The output of complex multiplication is in 3.29 format. - * Hence changing the format of N (i.e. 2*N elements) complex numbers to 1.31 format by shifting left by 2 bits. */ + * Hence changing the format of N (i.e. 2*N elements) complex numbers to 1.31 + * format by shifting left by 2 bits. */ arm_shift_q31(pState, 2, pState, S->N * 2); /* ----------- Post-processing ---------- */ @@ -333,19 +335,22 @@ void arm_dct4_q31( /* Calculating Y4(0) from Y2(0) using Y4(0) = Y2(0)/2 */ in = *pS1++ >> 1U; - /* input buffer acts as inplace, so output values are stored in the input itself. */ + /* input buffer acts as inplace, so output values are stored in the input + * itself. */ *pbuff++ = in; - /* pState pointer is incremented twice as the real values are located alternatively in the array */ + /* pState pointer is incremented twice as the real values are located + * alternatively in the array */ pS1++; /* Initializing the loop counter */ i = (S->N - 1U); - while (i > 0U) - { - /* Calculating Y4(1) to Y4(N-1) from Y2 using equation Y4(k) = Y2(k) - Y4(k-1) */ - /* pState pointer (pS1) is incremented twice as the real values are located alternatively in the array */ + while (i > 0U) { + /* Calculating Y4(1) to Y4(N-1) from Y2 using equation Y4(k) = Y2(k) - + * Y4(k-1) */ + /* pState pointer (pS1) is incremented twice as the real values are located + * alternatively in the array */ in = *pS1++ - in; *pbuff++ = in; @@ -356,7 +361,8 @@ void arm_dct4_q31( i--; } - /*------------ Normalizing the output by multiplying with the normalizing factor ----------*/ + /*------------ Normalizing the output by multiplying with the normalizing + * factor ----------*/ /* Initializing loop counter */ i = S->N; @@ -364,18 +370,16 @@ void arm_dct4_q31( /* pbuff initialized to the pInlineBuffer (now contains the output values) */ pbuff = pInlineBuffer; - do - { + do { /* Multiplying pInlineBuffer with the normalizing factor sqrt(2/N) */ in = *pbuff; - *pbuff++ = ((q31_t) (((q63_t) in * S->normalize) >> 31)); + *pbuff++ = ((q31_t)(((q63_t)in * S->normalize) >> 31)); /* Decrement loop counter */ i--; } while (i > 0U); #endif /* #if defined (ARM_MATH_LOOPUNROLL) */ - } /** diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_f32.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_f32.c index b5d0a66..4e2b021 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_f32.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_f32.c @@ -32,40 +32,26 @@ * Internal functions prototypes * -------------------------------------------------------------------- */ -extern void arm_radix4_butterfly_f32( - float32_t * pSrc, - uint16_t fftLen, - const float32_t * pCoef, - uint16_t twidCoefModifier); +extern void arm_radix4_butterfly_f32(float32_t *pSrc, uint16_t fftLen, + const float32_t *pCoef, + uint16_t twidCoefModifier); -extern void arm_radix4_butterfly_inverse_f32( - float32_t * pSrc, - uint16_t fftLen, - const float32_t * pCoef, - uint16_t twidCoefModifier, - float32_t onebyfftLen); +extern void arm_radix4_butterfly_inverse_f32(float32_t *pSrc, uint16_t fftLen, + const float32_t *pCoef, + uint16_t twidCoefModifier, + float32_t onebyfftLen); -extern void arm_bitreversal_f32( - float32_t * pSrc, - uint16_t fftSize, - uint16_t bitRevFactor, - const uint16_t * pBitRevTab); +extern void arm_bitreversal_f32(float32_t *pSrc, uint16_t fftSize, + uint16_t bitRevFactor, + const uint16_t *pBitRevTab); -void arm_split_rfft_f32( - float32_t * pSrc, - uint32_t fftLen, - const float32_t * pATable, - const float32_t * pBTable, - float32_t * pDst, - uint32_t modifier); +void arm_split_rfft_f32(float32_t *pSrc, uint32_t fftLen, + const float32_t *pATable, const float32_t *pBTable, + float32_t *pDst, uint32_t modifier); -void arm_split_rifft_f32( - float32_t * pSrc, - uint32_t fftLen, - const float32_t * pATable, - const float32_t * pBTable, - float32_t * pDst, - uint32_t modifier); +void arm_split_rifft_f32(float32_t *pSrc, uint32_t fftLen, + const float32_t *pATable, const float32_t *pBTable, + float32_t *pDst, uint32_t modifier); /** @ingroup groupTransforms @@ -78,53 +64,52 @@ void arm_split_rifft_f32( /** @brief Processing function for the floating-point RFFT/RIFFT. - @deprecated Do not use this function. It has been superceded by \ref arm_rfft_fast_f32 and will be removed in the future. - @param[in] S points to an instance of the floating-point RFFT/RIFFT structure + @deprecated Do not use this function. It has been superceded by \ref + arm_rfft_fast_f32 and will be removed in the future. + @param[in] S points to an instance of the floating-point RFFT/RIFFT + structure @param[in] pSrc points to the input buffer @param[out] pDst points to the output buffer @return none */ -void arm_rfft_f32( - const arm_rfft_instance_f32 * S, - float32_t * pSrc, - float32_t * pDst) -{ +void arm_rfft_f32(const arm_rfft_instance_f32 *S, float32_t *pSrc, + float32_t *pDst) { const arm_cfft_radix4_instance_f32 *S_CFFT = S->pCfft; /* Calculation of Real IFFT of input */ - if (S->ifftFlagR == 1U) - { - /* Real IFFT core process */ - arm_split_rifft_f32 (pSrc, S->fftLenBy2, S->pTwiddleAReal, S->pTwiddleBReal, pDst, S->twidCoefRModifier); + if (S->ifftFlagR == 1U) { + /* Real IFFT core process */ + arm_split_rifft_f32(pSrc, S->fftLenBy2, S->pTwiddleAReal, S->pTwiddleBReal, + pDst, S->twidCoefRModifier); - - /* Complex radix-4 IFFT process */ - arm_radix4_butterfly_inverse_f32 (pDst, S_CFFT->fftLen, S_CFFT->pTwiddle, S_CFFT->twidCoefModifier, S_CFFT->onebyfftLen); + /* Complex radix-4 IFFT process */ + arm_radix4_butterfly_inverse_f32(pDst, S_CFFT->fftLen, S_CFFT->pTwiddle, + S_CFFT->twidCoefModifier, + S_CFFT->onebyfftLen); /* Bit reversal process */ - if (S->bitReverseFlagR == 1U) - { - arm_bitreversal_f32 (pDst, S_CFFT->fftLen, S_CFFT->bitRevFactor, S_CFFT->pBitRevTable); + if (S->bitReverseFlagR == 1U) { + arm_bitreversal_f32(pDst, S_CFFT->fftLen, S_CFFT->bitRevFactor, + S_CFFT->pBitRevTable); } - } - else - { + } else { /* Calculation of RFFT of input */ /* Complex radix-4 FFT process */ - arm_radix4_butterfly_f32 (pSrc, S_CFFT->fftLen, S_CFFT->pTwiddle, S_CFFT->twidCoefModifier); + arm_radix4_butterfly_f32(pSrc, S_CFFT->fftLen, S_CFFT->pTwiddle, + S_CFFT->twidCoefModifier); /* Bit reversal process */ - if (S->bitReverseFlagR == 1U) - { - arm_bitreversal_f32 (pSrc, S_CFFT->fftLen, S_CFFT->bitRevFactor, S_CFFT->pBitRevTable); + if (S->bitReverseFlagR == 1U) { + arm_bitreversal_f32(pSrc, S_CFFT->fftLen, S_CFFT->bitRevFactor, + S_CFFT->pBitRevTable); } /* Real FFT core process */ - arm_split_rfft_f32 (pSrc, S->fftLenBy2, S->pTwiddleAReal, S->pTwiddleBReal, pDst, S->twidCoefRModifier); + arm_split_rfft_f32(pSrc, S->fftLenBy2, S->pTwiddleAReal, S->pTwiddleBReal, + pDst, S->twidCoefRModifier); } - } /** @@ -138,24 +123,25 @@ void arm_rfft_f32( @param[in] pATable points to twiddle Coef A buffer @param[in] pBTable points to twiddle Coef B buffer @param[out] pDst points to output buffer - @param[in] modifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table + @param[in] modifier twiddle coefficient modifier that supports different + size FFTs with the same twiddle factor table @return none */ -void arm_split_rfft_f32( - float32_t * pSrc, - uint32_t fftLen, - const float32_t * pATable, - const float32_t * pBTable, - float32_t * pDst, - uint32_t modifier) -{ - uint32_t i; /* Loop Counter */ - float32_t outR, outI; /* Temporary variables for output */ - const float32_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */ - float32_t CoefA1, CoefA2, CoefB1; /* Temporary variables for twiddle coefficients */ - float32_t *pDst1 = &pDst[2], *pDst2 = &pDst[(4U * fftLen) - 1U]; /* temp pointers for output buffer */ - float32_t *pSrc1 = &pSrc[2], *pSrc2 = &pSrc[(2U * fftLen) - 1U]; /* temp pointers for input buffer */ +void arm_split_rfft_f32(float32_t *pSrc, uint32_t fftLen, + const float32_t *pATable, const float32_t *pBTable, + float32_t *pDst, uint32_t modifier) { + uint32_t i; /* Loop Counter */ + float32_t outR, outI; /* Temporary variables for output */ + const float32_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */ + float32_t CoefA1, CoefA2, + CoefB1; /* Temporary variables for twiddle coefficients */ + float32_t *pDst1 = &pDst[2], + *pDst2 = + &pDst[(4U * fftLen) - 1U]; /* temp pointers for output buffer */ + float32_t *pSrc1 = &pSrc[2], + *pSrc2 = + &pSrc[(2U * fftLen) - 1U]; /* temp pointers for input buffer */ /* Init coefficient pointers */ pCoefA = &pATable[modifier * 2]; @@ -163,19 +149,18 @@ void arm_split_rfft_f32( i = fftLen - 1U; - while (i > 0U) - { - /* - outR = ( pSrc[2 * i] * pATable[2 * i] - - pSrc[2 * i + 1] * pATable[2 * i + 1] - + pSrc[2 * n - 2 * i] * pBTable[2 * i] - + pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1]); + while (i > 0U) { + /* + outR = ( pSrc[2 * i] * pATable[2 * i] + - pSrc[2 * i + 1] * pATable[2 * i + 1] + + pSrc[2 * n - 2 * i] * pBTable[2 * i] + + pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1]); - outI = ( pIn[2 * i + 1] * pATable[2 * i] - + pIn[2 * i] * pATable[2 * i + 1] - + pIn[2 * n - 2 * i] * pBTable[2 * i + 1] - - pIn[2 * n - 2 * i + 1] * pBTable[2 * i]); - */ + outI = ( pIn[2 * i + 1] * pATable[2 * i] + + pIn[2 * i] * pATable[2 * i + 1] + + pIn[2 * n - 2 * i] * pBTable[2 * i + 1] + - pIn[2 * n - 2 * i + 1] * pBTable[2 * i]); + */ /* read pATable[2 * i] */ CoefA1 = *pCoefA++; @@ -215,7 +200,6 @@ void arm_split_rfft_f32( pCoefA = pCoefA + ((modifier * 2U) - 1U); i--; - } pDst[2U * fftLen] = pSrc[0] - pSrc[1]; @@ -223,10 +207,8 @@ void arm_split_rfft_f32( pDst[0] = pSrc[0] + pSrc[1]; pDst[1] = 0.0f; - } - /** @brief Core Real IFFT process @param[in] pSrc points to input buffer @@ -234,76 +216,71 @@ void arm_split_rfft_f32( @param[in] pATable points to twiddle Coef A buffer @param[in] pBTable points to twiddle Coef B buffer @param[out] pDst points to output buffer - @param[in] modifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table + @param[in] modifier twiddle coefficient modifier that supports different + size FFTs with the same twiddle factor table @return none */ -void arm_split_rifft_f32( - float32_t * pSrc, - uint32_t fftLen, - const float32_t * pATable, - const float32_t * pBTable, - float32_t * pDst, - uint32_t modifier) -{ - float32_t outR, outI; /* Temporary variables for output */ - const float32_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */ - float32_t CoefA1, CoefA2, CoefB1; /* Temporary variables for twiddle coefficients */ - float32_t *pSrc1 = &pSrc[0], *pSrc2 = &pSrc[(2U * fftLen) + 1U]; +void arm_split_rifft_f32(float32_t *pSrc, uint32_t fftLen, + const float32_t *pATable, const float32_t *pBTable, + float32_t *pDst, uint32_t modifier) { + float32_t outR, outI; /* Temporary variables for output */ + const float32_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */ + float32_t CoefA1, CoefA2, + CoefB1; /* Temporary variables for twiddle coefficients */ + float32_t *pSrc1 = &pSrc[0], *pSrc2 = &pSrc[(2U * fftLen) + 1U]; pCoefA = &pATable[0]; pCoefB = &pBTable[0]; - while (fftLen > 0U) - { - /* - outR = ( pIn[2 * i] * pATable[2 * i] - + pIn[2 * i + 1] * pATable[2 * i + 1] - + pIn[2 * n - 2 * i] * pBTable[2 * i] - - pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1]); + while (fftLen > 0U) { + /* + outR = ( pIn[2 * i] * pATable[2 * i] + + pIn[2 * i + 1] * pATable[2 * i + 1] + + pIn[2 * n - 2 * i] * pBTable[2 * i] + - pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1]); - outI = ( pIn[2 * i + 1] * pATable[2 * i] - - pIn[2 * i] * pATable[2 * i + 1] - - pIn[2 * n - 2 * i] * pBTable[2 * i + 1] - - pIn[2 * n - 2 * i + 1] * pBTable[2 * i]); - */ + outI = ( pIn[2 * i + 1] * pATable[2 * i] + - pIn[2 * i] * pATable[2 * i + 1] + - pIn[2 * n - 2 * i] * pBTable[2 * i + 1] + - pIn[2 * n - 2 * i + 1] * pBTable[2 * i]); + */ - CoefA1 = *pCoefA++; - CoefA2 = *pCoefA; + CoefA1 = *pCoefA++; + CoefA2 = *pCoefA; - /* outR = (pSrc[2 * i] * CoefA1 */ - outR = *pSrc1 * CoefA1; + /* outR = (pSrc[2 * i] * CoefA1 */ + outR = *pSrc1 * CoefA1; - /* - pSrc[2 * i] * CoefA2 */ - outI = -(*pSrc1++) * CoefA2; + /* - pSrc[2 * i] * CoefA2 */ + outI = -(*pSrc1++) * CoefA2; - /* (pSrc[2 * i + 1] + pSrc[2 * fftLen - 2 * i + 1]) * CoefA2 */ - outR += (*pSrc1 + *pSrc2) * CoefA2; + /* (pSrc[2 * i + 1] + pSrc[2 * fftLen - 2 * i + 1]) * CoefA2 */ + outR += (*pSrc1 + *pSrc2) * CoefA2; - /* pSrc[2 * i + 1] * CoefA1 */ - outI += (*pSrc1++) * CoefA1; + /* pSrc[2 * i + 1] * CoefA1 */ + outI += (*pSrc1++) * CoefA1; - CoefB1 = *pCoefB; + CoefB1 = *pCoefB; - /* - pSrc[2 * fftLen - 2 * i + 1] * CoefB1 */ - outI -= *pSrc2-- * CoefB1; + /* - pSrc[2 * fftLen - 2 * i + 1] * CoefB1 */ + outI -= *pSrc2-- * CoefB1; - /* pSrc[2 * fftLen - 2 * i] * CoefB1 */ - outR += *pSrc2 * CoefB1; + /* pSrc[2 * fftLen - 2 * i] * CoefB1 */ + outR += *pSrc2 * CoefB1; - /* pSrc[2 * fftLen - 2 * i] * CoefA2 */ - outI += *pSrc2-- * CoefA2; + /* pSrc[2 * fftLen - 2 * i] * CoefA2 */ + outI += *pSrc2-- * CoefA2; - /* write output */ - *pDst++ = outR; - *pDst++ = outI; + /* write output */ + *pDst++ = outR; + *pDst++ = outI; - /* update coefficient pointer */ - pCoefB = pCoefB + (modifier * 2); - pCoefA = pCoefA + (modifier * 2 - 1); + /* update coefficient pointer */ + pCoefB = pCoefB + (modifier * 2); + pCoefA = pCoefA + (modifier * 2 - 1); - /* Decrement loop count */ - fftLen--; + /* Decrement loop count */ + fftLen--; } - } diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_fast_f32.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_fast_f32.c index 7a1af14..53e327a 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_fast_f32.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_fast_f32.c @@ -28,150 +28,143 @@ #include "arm_math.h" -void stage_rfft_f32( - const arm_rfft_fast_instance_f32 * S, - float32_t * p, - float32_t * pOut) -{ - uint32_t k; /* Loop Counter */ - float32_t twR, twI; /* RFFT Twiddle coefficients */ - const float32_t * pCoeff = S->pTwiddleRFFT; /* Points to RFFT Twiddle factors */ - float32_t *pA = p; /* increasing pointer */ - float32_t *pB = p; /* decreasing pointer */ - float32_t xAR, xAI, xBR, xBI; /* temporary variables */ - float32_t t1a, t1b; /* temporary variables */ - float32_t p0, p1, p2, p3; /* temporary variables */ +void stage_rfft_f32(const arm_rfft_fast_instance_f32 *S, float32_t *p, + float32_t *pOut) { + uint32_t k; /* Loop Counter */ + float32_t twR, twI; /* RFFT Twiddle coefficients */ + const float32_t *pCoeff = + S->pTwiddleRFFT; /* Points to RFFT Twiddle factors */ + float32_t *pA = p; /* increasing pointer */ + float32_t *pB = p; /* decreasing pointer */ + float32_t xAR, xAI, xBR, xBI; /* temporary variables */ + float32_t t1a, t1b; /* temporary variables */ + float32_t p0, p1, p2, p3; /* temporary variables */ + k = (S->Sint).fftLen - 1; - k = (S->Sint).fftLen - 1; + /* Pack first and last sample of the frequency domain together */ - /* Pack first and last sample of the frequency domain together */ + xBR = pB[0]; + xBI = pB[1]; + xAR = pA[0]; + xAI = pA[1]; - xBR = pB[0]; - xBI = pB[1]; - xAR = pA[0]; - xAI = pA[1]; + twR = *pCoeff++; + twI = *pCoeff++; - twR = *pCoeff++ ; - twI = *pCoeff++ ; + // U1 = XA(1) + XB(1); % It is real + t1a = xBR + xAR; - // U1 = XA(1) + XB(1); % It is real - t1a = xBR + xAR ; + // U2 = XB(1) - XA(1); % It is imaginary + t1b = xBI + xAI; - // U2 = XB(1) - XA(1); % It is imaginary - t1b = xBI + xAI ; + // real(tw * (xB - xA)) = twR * (xBR - xAR) - twI * (xBI - xAI); + // imag(tw * (xB - xA)) = twI * (xBR - xAR) + twR * (xBI - xAI); + *pOut++ = 0.5f * (t1a + t1b); + *pOut++ = 0.5f * (t1a - t1b); - // real(tw * (xB - xA)) = twR * (xBR - xAR) - twI * (xBI - xAI); - // imag(tw * (xB - xA)) = twI * (xBR - xAR) + twR * (xBI - xAI); - *pOut++ = 0.5f * ( t1a + t1b ); - *pOut++ = 0.5f * ( t1a - t1b ); + // XA(1) = 1/2*( U1 - imag(U2) + i*( U1 +imag(U2) )); + pB = p + 2 * k; + pA += 2; - // XA(1) = 1/2*( U1 - imag(U2) + i*( U1 +imag(U2) )); - pB = p + 2*k; - pA += 2; + do { + /* + function X = my_split_rfft(X, ifftFlag) + % X is a series of real numbers + L = length(X); + XC = X(1:2:end) +i*X(2:2:end); + XA = fft(XC); + XB = conj(XA([1 end:-1:2])); + TW = i*exp(-2*pi*i*[0:L/2-1]/L).'; + for l = 2:L/2 + XA(l) = 1/2 * (XA(l) + XB(l) + TW(l) * (XB(l) - XA(l))); + end + XA(1) = 1/2* (XA(1) + XB(1) + TW(1) * (XB(1) - XA(1))) + i*( 1/2*( XA(1) + + XB(1) + i*( XA(1) - XB(1)))); X = XA; + */ - do - { - /* - function X = my_split_rfft(X, ifftFlag) - % X is a series of real numbers - L = length(X); - XC = X(1:2:end) +i*X(2:2:end); - XA = fft(XC); - XB = conj(XA([1 end:-1:2])); - TW = i*exp(-2*pi*i*[0:L/2-1]/L).'; - for l = 2:L/2 - XA(l) = 1/2 * (XA(l) + XB(l) + TW(l) * (XB(l) - XA(l))); - end - XA(1) = 1/2* (XA(1) + XB(1) + TW(1) * (XB(1) - XA(1))) + i*( 1/2*( XA(1) + XB(1) + i*( XA(1) - XB(1)))); - X = XA; - */ + xBI = pB[1]; + xBR = pB[0]; + xAR = pA[0]; + xAI = pA[1]; - xBI = pB[1]; - xBR = pB[0]; - xAR = pA[0]; - xAI = pA[1]; + twR = *pCoeff++; + twI = *pCoeff++; - twR = *pCoeff++; - twI = *pCoeff++; + t1a = xBR - xAR; + t1b = xBI + xAI; - t1a = xBR - xAR ; - t1b = xBI + xAI ; + // real(tw * (xB - xA)) = twR * (xBR - xAR) - twI * (xBI - xAI); + // imag(tw * (xB - xA)) = twI * (xBR - xAR) + twR * (xBI - xAI); + p0 = twR * t1a; + p1 = twI * t1a; + p2 = twR * t1b; + p3 = twI * t1b; - // real(tw * (xB - xA)) = twR * (xBR - xAR) - twI * (xBI - xAI); - // imag(tw * (xB - xA)) = twI * (xBR - xAR) + twR * (xBI - xAI); - p0 = twR * t1a; - p1 = twI * t1a; - p2 = twR * t1b; - p3 = twI * t1b; + *pOut++ = 0.5f * (xAR + xBR + p0 + p3); // xAR + *pOut++ = 0.5f * (xAI - xBI + p1 - p2); // xAI - *pOut++ = 0.5f * (xAR + xBR + p0 + p3 ); //xAR - *pOut++ = 0.5f * (xAI - xBI + p1 - p2 ); //xAI - - pA += 2; - pB -= 2; - k--; - } while (k > 0U); + pA += 2; + pB -= 2; + k--; + } while (k > 0U); } /* Prepares data for inverse cfft */ -void merge_rfft_f32( - const arm_rfft_fast_instance_f32 * S, - float32_t * p, - float32_t * pOut) -{ - uint32_t k; /* Loop Counter */ - float32_t twR, twI; /* RFFT Twiddle coefficients */ - const float32_t *pCoeff = S->pTwiddleRFFT; /* Points to RFFT Twiddle factors */ - float32_t *pA = p; /* increasing pointer */ - float32_t *pB = p; /* decreasing pointer */ - float32_t xAR, xAI, xBR, xBI; /* temporary variables */ - float32_t t1a, t1b, r, s, t, u; /* temporary variables */ +void merge_rfft_f32(const arm_rfft_fast_instance_f32 *S, float32_t *p, + float32_t *pOut) { + uint32_t k; /* Loop Counter */ + float32_t twR, twI; /* RFFT Twiddle coefficients */ + const float32_t *pCoeff = + S->pTwiddleRFFT; /* Points to RFFT Twiddle factors */ + float32_t *pA = p; /* increasing pointer */ + float32_t *pB = p; /* decreasing pointer */ + float32_t xAR, xAI, xBR, xBI; /* temporary variables */ + float32_t t1a, t1b, r, s, t, u; /* temporary variables */ - k = (S->Sint).fftLen - 1; + k = (S->Sint).fftLen - 1; - xAR = pA[0]; - xAI = pA[1]; + xAR = pA[0]; + xAI = pA[1]; - pCoeff += 2 ; + pCoeff += 2; - *pOut++ = 0.5f * ( xAR + xAI ); - *pOut++ = 0.5f * ( xAR - xAI ); + *pOut++ = 0.5f * (xAR + xAI); + *pOut++ = 0.5f * (xAR - xAI); - pB = p + 2*k ; - pA += 2 ; + pB = p + 2 * k; + pA += 2; - while (k > 0U) - { - /* G is half of the frequency complex spectrum */ - //for k = 2:N - // Xk(k) = 1/2 * (G(k) + conj(G(N-k+2)) + Tw(k)*( G(k) - conj(G(N-k+2)))); - xBI = pB[1] ; - xBR = pB[0] ; - xAR = pA[0]; - xAI = pA[1]; + while (k > 0U) { + /* G is half of the frequency complex spectrum */ + // for k = 2:N + // Xk(k) = 1/2 * (G(k) + conj(G(N-k+2)) + Tw(k)*( G(k) - + // conj(G(N-k+2)))); + xBI = pB[1]; + xBR = pB[0]; + xAR = pA[0]; + xAI = pA[1]; - twR = *pCoeff++; - twI = *pCoeff++; + twR = *pCoeff++; + twI = *pCoeff++; - t1a = xAR - xBR ; - t1b = xAI + xBI ; + t1a = xAR - xBR; + t1b = xAI + xBI; - r = twR * t1a; - s = twI * t1b; - t = twI * t1a; - u = twR * t1b; + r = twR * t1a; + s = twI * t1b; + t = twI * t1a; + u = twR * t1b; - // real(tw * (xA - xB)) = twR * (xAR - xBR) - twI * (xAI - xBI); - // imag(tw * (xA - xB)) = twI * (xAR - xBR) + twR * (xAI - xBI); - *pOut++ = 0.5f * (xAR + xBR - r - s ); //xAR - *pOut++ = 0.5f * (xAI - xBI + t - u ); //xAI - - pA += 2; - pB -= 2; - k--; - } + // real(tw * (xA - xB)) = twR * (xAR - xBR) - twI * (xAI - xBI); + // imag(tw * (xA - xB)) = twI * (xAR - xBR) + twR * (xAI - xBI); + *pOut++ = 0.5f * (xAR + xBR - r - s); // xAR + *pOut++ = 0.5f * (xAI - xBI + t - u); // xAI + pA += 2; + pB -= 2; + k--; + } } /** @@ -180,95 +173,99 @@ void merge_rfft_f32( /** @defgroup RealFFT Real FFT Functions - + @par - The CMSIS DSP library includes specialized algorithms for computing the - FFT of real data sequences. The FFT is defined over complex data but - in many applications the input is real. Real FFT algorithms take advantage - of the symmetry properties of the FFT and have a speed advantage over complex - algorithms of the same length. + The CMSIS DSP library includes specialized algorithms for + computing the FFT of real data sequences. The FFT is defined over complex + data but in many applications the input is real. Real FFT algorithms take + advantage of the symmetry properties of the FFT and have a speed advantage + over complex algorithms of the same length. @par - The Fast RFFT algorith relays on the mixed radix CFFT that save processor usage. + The Fast RFFT algorith relays on the mixed radix CFFT that + save processor usage. @par - The real length N forward FFT of a sequence is computed using the steps shown below. + The real length N forward FFT of a sequence is computed using + the steps shown below. @par \image html RFFT.gif "Real Fast Fourier Transform" @par - The real sequence is initially treated as if it were complex to perform a CFFT. - Later, a processing stage reshapes the data to obtain half of the frequency spectrum - in complex format. Except the first complex number that contains the two real numbers - X[0] and X[N/2] all the data is complex. In other words, the first complex sample - contains two real values packed. + The real sequence is initially treated as if it were complex + to perform a CFFT. Later, a processing stage reshapes the data to obtain half + of the frequency spectrum in complex format. Except the first complex number + that contains the two real numbers X[0] and X[N/2] all the data is complex. In + other words, the first complex sample contains two real values packed. @par - The input for the inverse RFFT should keep the same format as the output of the - forward RFFT. A first processing stage pre-process the data to later perform an - inverse CFFT. + The input for the inverse RFFT should keep the same format as + the output of the forward RFFT. A first processing stage pre-process the data + to later perform an inverse CFFT. @par \image html RIFFT.gif "Real Inverse Fast Fourier Transform" @par - The algorithms for floating-point, Q15, and Q31 data are slightly different - and we describe each algorithm in turn. + The algorithms for floating-point, Q15, and Q31 data are + slightly different and we describe each algorithm in turn. @par Floating-point - The main functions are \ref arm_rfft_fast_f32() and \ref arm_rfft_fast_init_f32(). - The older functions \ref arm_rfft_f32() and \ref arm_rfft_init_f32() have been deprecated - but are still documented. + The main functions are \ref arm_rfft_fast_f32() and \ref + arm_rfft_fast_init_f32(). The older functions \ref arm_rfft_f32() and \ref + arm_rfft_init_f32() have been deprecated but are still documented. @par - The FFT of a real N-point sequence has even symmetry in the frequency domain. - The second half of the data equals the conjugate of the first half flipped in frequency. - Looking at the data, we see that we can uniquely represent the FFT using only N/2 complex numbers. - These are packed into the output array in alternating real and imaginary components: + The FFT of a real N-point sequence has even symmetry in the + frequency domain. The second half of the data equals the conjugate of the + first half flipped in frequency. Looking at the data, we see that we can + uniquely represent the FFT using only N/2 complex numbers. These are packed + into the output array in alternating real and imaginary components: @par - X = { real[0], imag[0], real[1], imag[1], real[2], imag[2] ... - real[(N/2)-1], imag[(N/2)-1 } + X = { real[0], imag[0], real[1], imag[1], real[2], imag[2] + ... real[(N/2)-1], imag[(N/2)-1 } @par - It happens that the first complex number (real[0], imag[0]) is actually - all real. real[0] represents the DC offset, and imag[0] should be 0. - (real[1], imag[1]) is the fundamental frequency, (real[2], imag[2]) is - the first harmonic and so on. + It happens that the first complex number (real[0], imag[0]) + is actually all real. real[0] represents the DC offset, and imag[0] should be + 0. (real[1], imag[1]) is the fundamental frequency, (real[2], imag[2]) is the + first harmonic and so on. @par - The real FFT functions pack the frequency domain data in this fashion. - The forward transform outputs the data in this form and the inverse - transform expects input data in this form. The function always performs - the needed bitreversal so that the input and output data is always in - normal order. The functions support lengths of [32, 64, 128, ..., 4096] - samples. + The real FFT functions pack the frequency domain data in this + fashion. The forward transform outputs the data in this form and the inverse + transform expects input data in this form. The function + always performs the needed bitreversal so that the input and output data is + always in normal order. The functions support lengths of [32, 64, 128, ..., + 4096] samples. @par Q15 and Q31 - The real algorithms are defined in a similar manner and utilize N/2 complex - transforms behind the scenes. + The real algorithms are defined in a similar manner and + utilize N/2 complex transforms behind the scenes. @par - The complex transforms used internally include scaling to prevent fixed-point - overflows. The overall scaling equals 1/(fftLen/2). + The complex transforms used internally include scaling to + prevent fixed-point overflows. The overall scaling equals 1/(fftLen/2). @par - A separate instance structure must be defined for each transform used but - twiddle factor and bit reversal tables can be reused. + A separate instance structure must be defined for each + transform used but twiddle factor and bit reversal tables can be reused. @par - There is also an associated initialization function for each data type. - The initialization function performs the following operations: + There is also an associated initialization function for each + data type. The initialization function performs the following operations: - Sets the values of the internal structure fields. - - Initializes twiddle factor table and bit reversal table pointers. + - Initializes twiddle factor table and bit reversal table + pointers. - Initializes the internal complex FFT data structure. @par Use of the initialization function is optional. - However, if the initialization function is used, then the instance structure - cannot be placed into a const data section. To place an instance structure - into a const data section, the instance structure should be manually - initialized as follows: -
-      arm_rfft_instance_q31 S = {fftLenReal, fftLenBy2, ifftFlagR, bitReverseFlagR, twidCoefRModifier, pTwiddleAReal, pTwiddleBReal, pCfft};
-      arm_rfft_instance_q15 S = {fftLenReal, fftLenBy2, ifftFlagR, bitReverseFlagR, twidCoefRModifier, pTwiddleAReal, pTwiddleBReal, pCfft};
+                   However, if the initialization function is used, then the
+  instance structure cannot be placed into a const data section. To place an
+  instance structure into a const data section, the instance structure should be
+  manually initialized as follows: 
 arm_rfft_instance_q31 S = {fftLenReal,
+  fftLenBy2, ifftFlagR, bitReverseFlagR, twidCoefRModifier, pTwiddleAReal,
+  pTwiddleBReal, pCfft}; arm_rfft_instance_q15 S = {fftLenReal, fftLenBy2,
+  ifftFlagR, bitReverseFlagR, twidCoefRModifier, pTwiddleAReal, pTwiddleBReal,
+  pCfft};
   
- where fftLenReal is the length of the real transform; - fftLenBy2 length of the internal complex transform. - ifftFlagR Selects forward (=0) or inverse (=1) transform. - bitReverseFlagR Selects bit reversed output (=0) or normal order - output (=1). - twidCoefRModifier stride modifier for the twiddle factor table. - The value is based on the FFT length; - pTwiddleARealpoints to the A array of twiddle coefficients; - pTwiddleBRealpoints to the B array of twiddle coefficients; - pCfft points to the CFFT Instance structure. The CFFT structure - must also be initialized. Refer to arm_cfft_radix4_f32() for details regarding - static initialization of the complex FFT instance structure. + where fftLenReal is the length of the real + transform; fftLenBy2 length of the internal complex transform. + ifftFlagR Selects forward (=0) or inverse (=1) + transform. bitReverseFlagR Selects bit reversed output (=0) or + normal order output (=1). twidCoefRModifier stride modifier for + the twiddle factor table. The value is based on the FFT length; + pTwiddleARealpoints to the A array of twiddle + coefficients; pTwiddleBRealpoints to the B array of twiddle + coefficients; pCfft points to the CFFT Instance structure. The + CFFT structure must also be initialized. Refer to arm_cfft_radix4_f32() for + details regarding static initialization of the complex FFT instance structure. */ /** @@ -287,34 +284,27 @@ void merge_rfft_f32( @return none */ -void arm_rfft_fast_f32( - arm_rfft_fast_instance_f32 * S, - float32_t * p, - float32_t * pOut, - uint8_t ifftFlag) -{ - arm_cfft_instance_f32 * Sint = &(S->Sint); - Sint->fftLen = S->fftLenRFFT / 2; +void arm_rfft_fast_f32(arm_rfft_fast_instance_f32 *S, float32_t *p, + float32_t *pOut, uint8_t ifftFlag) { + arm_cfft_instance_f32 *Sint = &(S->Sint); + Sint->fftLen = S->fftLenRFFT / 2; - /* Calculation of Real FFT */ - if (ifftFlag) - { - /* Real FFT compression */ - merge_rfft_f32(S, p, pOut); + /* Calculation of Real FFT */ + if (ifftFlag) { + /* Real FFT compression */ + merge_rfft_f32(S, p, pOut); - /* Complex radix-4 IFFT process */ - arm_cfft_f32( Sint, pOut, ifftFlag, 1); - } - else - { - /* Calculation of RFFT of input */ - arm_cfft_f32( Sint, p, ifftFlag, 1); + /* Complex radix-4 IFFT process */ + arm_cfft_f32(Sint, pOut, ifftFlag, 1); + } else { + /* Calculation of RFFT of input */ + arm_cfft_f32(Sint, p, ifftFlag, 1); - /* Real FFT extraction */ - stage_rfft_f32(S, p, pOut); - } + /* Real FFT extraction */ + stage_rfft_f32(S, p, pOut); + } } /** -* @} end of RealFFT group -*/ + * @} end of RealFFT group + */ diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_fast_init_f32.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_fast_init_f32.c index ff70329..5a11d78 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_fast_init_f32.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_fast_init_f32.c @@ -1,7 +1,8 @@ /* ---------------------------------------------------------------------- * Project: CMSIS DSP Library * Title: arm_cfft_init_f32.c - * Description: Split Radix Decimation in Frequency CFFT Floating point processing function + * Description: Split Radix Decimation in Frequency CFFT Floating point + * processing function * * $Date: 18. March 2019 * $Revision: V1.6.0 @@ -26,8 +27,8 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" +#include "arm_math.h" /** @ingroup groupTransforms @@ -38,7 +39,6 @@ @{ */ - /** @brief Initialization function for the 32pt floating-point real FFT. @param[in,out] S points to an arm_rfft_fast_instance_f32 structure @@ -47,11 +47,12 @@ - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected */ -arm_status arm_rfft_32_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { +arm_status arm_rfft_32_fast_init_f32(arm_rfft_fast_instance_f32 *S) { - arm_cfft_instance_f32 * Sint; + arm_cfft_instance_f32 *Sint; - if( !S ) return ARM_MATH_ARGUMENT_ERROR; + if (!S) + return ARM_MATH_ARGUMENT_ERROR; Sint = &(S->Sint); Sint->fftLen = 16U; @@ -59,8 +60,8 @@ arm_status arm_rfft_32_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { Sint->bitRevLength = ARMBITREVINDEXTABLE_16_TABLE_LENGTH; Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable16; - Sint->pTwiddle = (float32_t *) twiddleCoef_16; - S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_32; + Sint->pTwiddle = (float32_t *)twiddleCoef_16; + S->pTwiddleRFFT = (float32_t *)twiddleCoef_rfft_32; return ARM_MATH_SUCCESS; } @@ -73,11 +74,12 @@ arm_status arm_rfft_32_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected */ -arm_status arm_rfft_64_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { +arm_status arm_rfft_64_fast_init_f32(arm_rfft_fast_instance_f32 *S) { - arm_cfft_instance_f32 * Sint; + arm_cfft_instance_f32 *Sint; - if( !S ) return ARM_MATH_ARGUMENT_ERROR; + if (!S) + return ARM_MATH_ARGUMENT_ERROR; Sint = &(S->Sint); Sint->fftLen = 32U; @@ -85,8 +87,8 @@ arm_status arm_rfft_64_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { Sint->bitRevLength = ARMBITREVINDEXTABLE_32_TABLE_LENGTH; Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable32; - Sint->pTwiddle = (float32_t *) twiddleCoef_32; - S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_64; + Sint->pTwiddle = (float32_t *)twiddleCoef_32; + S->pTwiddleRFFT = (float32_t *)twiddleCoef_rfft_64; return ARM_MATH_SUCCESS; } @@ -99,11 +101,12 @@ arm_status arm_rfft_64_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected */ -arm_status arm_rfft_128_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { +arm_status arm_rfft_128_fast_init_f32(arm_rfft_fast_instance_f32 *S) { - arm_cfft_instance_f32 * Sint; + arm_cfft_instance_f32 *Sint; - if( !S ) return ARM_MATH_ARGUMENT_ERROR; + if (!S) + return ARM_MATH_ARGUMENT_ERROR; Sint = &(S->Sint); Sint->fftLen = 64U; @@ -111,8 +114,8 @@ arm_status arm_rfft_128_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { Sint->bitRevLength = ARMBITREVINDEXTABLE_64_TABLE_LENGTH; Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable64; - Sint->pTwiddle = (float32_t *) twiddleCoef_64; - S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_128; + Sint->pTwiddle = (float32_t *)twiddleCoef_64; + S->pTwiddleRFFT = (float32_t *)twiddleCoef_rfft_128; return ARM_MATH_SUCCESS; } @@ -125,11 +128,12 @@ arm_status arm_rfft_128_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected */ -arm_status arm_rfft_256_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { +arm_status arm_rfft_256_fast_init_f32(arm_rfft_fast_instance_f32 *S) { - arm_cfft_instance_f32 * Sint; + arm_cfft_instance_f32 *Sint; - if( !S ) return ARM_MATH_ARGUMENT_ERROR; + if (!S) + return ARM_MATH_ARGUMENT_ERROR; Sint = &(S->Sint); Sint->fftLen = 128U; @@ -137,8 +141,8 @@ arm_status arm_rfft_256_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { Sint->bitRevLength = ARMBITREVINDEXTABLE_128_TABLE_LENGTH; Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable128; - Sint->pTwiddle = (float32_t *) twiddleCoef_128; - S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_256; + Sint->pTwiddle = (float32_t *)twiddleCoef_128; + S->pTwiddleRFFT = (float32_t *)twiddleCoef_rfft_256; return ARM_MATH_SUCCESS; } @@ -151,11 +155,12 @@ arm_status arm_rfft_256_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected */ -arm_status arm_rfft_512_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { +arm_status arm_rfft_512_fast_init_f32(arm_rfft_fast_instance_f32 *S) { - arm_cfft_instance_f32 * Sint; + arm_cfft_instance_f32 *Sint; - if( !S ) return ARM_MATH_ARGUMENT_ERROR; + if (!S) + return ARM_MATH_ARGUMENT_ERROR; Sint = &(S->Sint); Sint->fftLen = 256U; @@ -163,8 +168,8 @@ arm_status arm_rfft_512_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { Sint->bitRevLength = ARMBITREVINDEXTABLE_256_TABLE_LENGTH; Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable256; - Sint->pTwiddle = (float32_t *) twiddleCoef_256; - S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_512; + Sint->pTwiddle = (float32_t *)twiddleCoef_256; + S->pTwiddleRFFT = (float32_t *)twiddleCoef_rfft_512; return ARM_MATH_SUCCESS; } @@ -177,11 +182,12 @@ arm_status arm_rfft_512_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected */ -arm_status arm_rfft_1024_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { +arm_status arm_rfft_1024_fast_init_f32(arm_rfft_fast_instance_f32 *S) { - arm_cfft_instance_f32 * Sint; + arm_cfft_instance_f32 *Sint; - if( !S ) return ARM_MATH_ARGUMENT_ERROR; + if (!S) + return ARM_MATH_ARGUMENT_ERROR; Sint = &(S->Sint); Sint->fftLen = 512U; @@ -189,8 +195,8 @@ arm_status arm_rfft_1024_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { Sint->bitRevLength = ARMBITREVINDEXTABLE_512_TABLE_LENGTH; Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable512; - Sint->pTwiddle = (float32_t *) twiddleCoef_512; - S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_1024; + Sint->pTwiddle = (float32_t *)twiddleCoef_512; + S->pTwiddleRFFT = (float32_t *)twiddleCoef_rfft_1024; return ARM_MATH_SUCCESS; } @@ -202,11 +208,12 @@ arm_status arm_rfft_1024_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { - \ref ARM_MATH_SUCCESS : Operation successful - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected */ -arm_status arm_rfft_2048_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { +arm_status arm_rfft_2048_fast_init_f32(arm_rfft_fast_instance_f32 *S) { - arm_cfft_instance_f32 * Sint; + arm_cfft_instance_f32 *Sint; - if( !S ) return ARM_MATH_ARGUMENT_ERROR; + if (!S) + return ARM_MATH_ARGUMENT_ERROR; Sint = &(S->Sint); Sint->fftLen = 1024U; @@ -214,8 +221,8 @@ arm_status arm_rfft_2048_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { Sint->bitRevLength = ARMBITREVINDEXTABLE_1024_TABLE_LENGTH; Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable1024; - Sint->pTwiddle = (float32_t *) twiddleCoef_1024; - S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_2048; + Sint->pTwiddle = (float32_t *)twiddleCoef_1024; + S->pTwiddleRFFT = (float32_t *)twiddleCoef_rfft_2048; return ARM_MATH_SUCCESS; } @@ -228,11 +235,12 @@ arm_status arm_rfft_2048_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected */ -arm_status arm_rfft_4096_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { +arm_status arm_rfft_4096_fast_init_f32(arm_rfft_fast_instance_f32 *S) { - arm_cfft_instance_f32 * Sint; + arm_cfft_instance_f32 *Sint; - if( !S ) return ARM_MATH_ARGUMENT_ERROR; + if (!S) + return ARM_MATH_ARGUMENT_ERROR; Sint = &(S->Sint); Sint->fftLen = 2048U; @@ -240,8 +248,8 @@ arm_status arm_rfft_4096_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { Sint->bitRevLength = ARMBITREVINDEXTABLE_2048_TABLE_LENGTH; Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable2048; - Sint->pTwiddle = (float32_t *) twiddleCoef_2048; - S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_4096; + Sint->pTwiddle = (float32_t *)twiddleCoef_2048; + S->pTwiddleRFFT = (float32_t *)twiddleCoef_rfft_4096; return ARM_MATH_SUCCESS; } @@ -252,24 +260,24 @@ arm_status arm_rfft_4096_fast_init_f32( arm_rfft_fast_instance_f32 * S ) { @param[in] fftLen length of the Real Sequence @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : fftLen is not a supported length + - \ref ARM_MATH_ARGUMENT_ERROR : fftLen is not a + supported length @par Description - The parameter fftLen specifies the length of RFFT/CIFFT process. - Supported FFT Lengths are 32, 64, 128, 256, 512, 1024, 2048, 4096. + The parameter fftLen specifies the length of + RFFT/CIFFT process. Supported FFT Lengths are 32, 64, 128, 256, 512, 1024, + 2048, 4096. @par - This Function also initializes Twiddle factor table pointer and Bit reversal table pointer. + This Function also initializes Twiddle factor table pointer + and Bit reversal table pointer. */ -arm_status arm_rfft_fast_init_f32( - arm_rfft_fast_instance_f32 * S, - uint16_t fftLen) -{ - typedef arm_status(*fft_init_ptr)( arm_rfft_fast_instance_f32 *); +arm_status arm_rfft_fast_init_f32(arm_rfft_fast_instance_f32 *S, + uint16_t fftLen) { + typedef arm_status (*fft_init_ptr)(arm_rfft_fast_instance_f32 *); fft_init_ptr fptr = 0x0; - switch (fftLen) - { + switch (fftLen) { #ifdef ENABLE_ARM_RFFT_F32_4096 case 4096U: fptr = arm_rfft_4096_fast_init_f32; @@ -302,9 +310,9 @@ arm_status arm_rfft_fast_init_f32( return ARM_MATH_ARGUMENT_ERROR; } - if( ! fptr ) return ARM_MATH_ARGUMENT_ERROR; - return fptr( S ); - + if (!fptr) + return ARM_MATH_ARGUMENT_ERROR; + return fptr(S); } /** diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_init_f32.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_init_f32.c index 57a6c4d..06c5d3e 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_init_f32.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_init_f32.c @@ -44,2063 +44,2746 @@ n = 4096
for (i = 0; i < n; i++)
   {
-     pATable[2 * i]     = 0.5 * ( 1.0 - sin (2 * PI / (double) (2 * n) * (double) i));
-     pATable[2 * i + 1] = 0.5 * (-1.0 * cos (2 * PI / (double) (2 * n) * (double) i));
+     pATable[2 * i]     = 0.5 * ( 1.0 - sin (2 * PI / (double) (2 * n) *
+  (double) i)); pATable[2 * i + 1] = 0.5 * (-1.0 * cos (2 * PI / (double) (2 *
+  n) * (double) i));
   }
*/ static const float32_t realCoefA[8192] = { - 0.500000000000000f, -0.500000000000000f, 0.499616503715515f, -0.499999850988388f, - 0.499233007431030f, -0.499999403953552f, 0.498849511146545f, -0.499998688697815f, - 0.498466014862061f, -0.499997645616531f, 0.498082518577576f, -0.499996334314346f, - 0.497699022293091f, -0.499994695186615f, 0.497315555810928f, -0.499992787837982f, - 0.496932059526443f, -0.499990582466125f, 0.496548563241959f, -0.499988079071045f, - 0.496165096759796f, -0.499985307455063f, 0.495781600475311f, -0.499982208013535f, - 0.495398133993149f, -0.499978810548782f, 0.495014637708664f, -0.499975144863129f, - 0.494631171226501f, -0.499971181154251f, 0.494247704744339f, -0.499966919422150f, - 0.493864238262177f, -0.499962359666824f, 0.493480771780014f, -0.499957501888275f, - 0.493097305297852f, -0.499952346086502f, 0.492713838815689f, -0.499946922063828f, - 0.492330402135849f, -0.499941170215607f, 0.491946935653687f, -0.499935150146484f, - 0.491563498973846f, -0.499928832054138f, 0.491180062294006f, -0.499922215938568f, - 0.490796625614166f, -0.499915301799774f, 0.490413218736649f, -0.499908089637756f, - 0.490029782056808f, -0.499900579452515f, 0.489646375179291f, -0.499892801046371f, - 0.489262968301773f, -0.499884694814682f, 0.488879561424255f, -0.499876320362091f, - 0.488496154546738f, -0.499867647886276f, 0.488112777471542f, -0.499858677387238f, - 0.487729400396347f, -0.499849408864975f, 0.487346023321152f, -0.499839842319489f, - 0.486962646245956f, -0.499830007553101f, 0.486579269170761f, -0.499819844961166f, - 0.486195921897888f, -0.499809414148331f, 0.485812574625015f, -0.499798685312271f, - 0.485429257154465f, -0.499787658452988f, 0.485045909881592f, -0.499776333570480f, - 0.484662592411041f, -0.499764710664749f, 0.484279274940491f, -0.499752789735794f, - 0.483895987272263f, -0.499740600585938f, 0.483512699604034f, -0.499728083610535f, - 0.483129411935806f, -0.499715298414230f, 0.482746154069901f, -0.499702215194702f, - 0.482362866401672f, -0.499688833951950f, 0.481979638338089f, -0.499675154685974f, - 0.481596380472183f, -0.499661177396774f, 0.481213152408600f, -0.499646931886673f, - 0.480829954147339f, -0.499632388353348f, 0.480446726083755f, -0.499617516994476f, - 0.480063527822495f, -0.499602377414703f, 0.479680359363556f, -0.499586939811707f, - 0.479297190904617f, -0.499571204185486f, 0.478914022445679f, -0.499555170536041f, - 0.478530883789063f, -0.499538868665695f, 0.478147745132446f, -0.499522238969803f, - 0.477764606475830f, -0.499505341053009f, 0.477381497621536f, -0.499488145112991f, - 0.476998418569565f, -0.499470651149750f, 0.476615339517593f, -0.499452859163284f, - 0.476232260465622f, -0.499434769153595f, 0.475849211215973f, -0.499416410923004f, - 0.475466161966324f, -0.499397724866867f, 0.475083142518997f, -0.499378770589828f, - 0.474700123071671f, -0.499359518289566f, 0.474317133426666f, -0.499339967966080f, - 0.473934143781662f, -0.499320119619370f, 0.473551183938980f, -0.499299973249435f, - 0.473168224096298f, -0.499279528856277f, 0.472785294055939f, -0.499258816242218f, - 0.472402364015579f, -0.499237775802612f, 0.472019463777542f, -0.499216467142105f, - 0.471636593341827f, -0.499194860458374f, 0.471253722906113f, -0.499172955751419f, - 0.470870882272720f, -0.499150782823563f, 0.470488041639328f, -0.499128282070160f, - 0.470105201005936f, -0.499105513095856f, 0.469722419977188f, -0.499082416296005f, - 0.469339638948441f, -0.499059051275253f, 0.468956857919693f, -0.499035388231277f, - 0.468574106693268f, -0.499011427164078f, 0.468191385269165f, -0.498987197875977f, - 0.467808693647385f, -0.498962640762329f, 0.467426002025604f, -0.498937815427780f, - 0.467043310403824f, -0.498912662267685f, 0.466660678386688f, -0.498887240886688f, - 0.466278046369553f, -0.498861521482468f, 0.465895414352417f, -0.498835533857346f, - 0.465512841939926f, -0.498809218406677f, 0.465130269527435f, -0.498782604932785f, - 0.464747726917267f, -0.498755723237991f, 0.464365184307098f, -0.498728543519974f, - 0.463982671499252f, -0.498701065778732f, 0.463600188493729f, -0.498673290014267f, - 0.463217705488205f, -0.498645216226578f, 0.462835282087326f, -0.498616874217987f, - 0.462452858686447f, -0.498588204383850f, 0.462070435285568f, -0.498559266328812f, - 0.461688071489334f, -0.498530030250549f, 0.461305707693100f, -0.498500496149063f, - 0.460923373699188f, -0.498470664024353f, 0.460541069507599f, -0.498440563678741f, - 0.460158795118332f, -0.498410135507584f, 0.459776520729065f, -0.498379439115524f, - 0.459394276142120f, -0.498348444700241f, 0.459012061357498f, -0.498317152261734f, - 0.458629876375198f, -0.498285561800003f, 0.458247691392899f, -0.498253703117371f, - 0.457865566015244f, -0.498221516609192f, 0.457483440637589f, -0.498189061880112f, - 0.457101345062256f, -0.498156309127808f, 0.456719279289246f, -0.498123258352280f, - 0.456337243318558f, -0.498089909553528f, 0.455955207347870f, -0.498056292533875f, - 0.455573230981827f, -0.498022347688675f, 0.455191254615784f, -0.497988134622574f, - 0.454809308052063f, -0.497953623533249f, 0.454427421092987f, -0.497918814420700f, - 0.454045534133911f, -0.497883707284927f, 0.453663676977158f, -0.497848302125931f, - 0.453281819820404f, -0.497812628746033f, 0.452900022268295f, -0.497776657342911f, - 0.452518254518509f, -0.497740387916565f, 0.452136516571045f, -0.497703820466995f, - 0.451754778623581f, -0.497666954994202f, 0.451373100280762f, -0.497629791498184f, - 0.450991421937943f, -0.497592359781265f, 0.450609803199768f, -0.497554630041122f, - 0.450228184461594f, -0.497516602277756f, 0.449846625328064f, -0.497478276491165f, - 0.449465066194534f, -0.497439652681351f, 0.449083566665649f, -0.497400760650635f, - 0.448702067136765f, -0.497361570596695f, 0.448320597410202f, -0.497322082519531f, - 0.447939187288284f, -0.497282296419144f, 0.447557777166367f, -0.497242212295532f, - 0.447176426649094f, -0.497201830148697f, 0.446795076131821f, -0.497161179780960f, - 0.446413785219193f, -0.497120231389999f, 0.446032524108887f, -0.497078984975815f, - 0.445651292800903f, -0.497037440538406f, 0.445270061492920f, -0.496995598077774f, - 0.444888889789581f, -0.496953487396240f, 0.444507747888565f, -0.496911078691483f, - 0.444126635789871f, -0.496868371963501f, 0.443745553493500f, -0.496825367212296f, - 0.443364530801773f, -0.496782064437866f, 0.442983508110046f, -0.496738493442535f, - 0.442602545022964f, -0.496694594621658f, 0.442221581935883f, -0.496650427579880f, - 0.441840678453445f, -0.496605962514877f, 0.441459804773331f, -0.496561229228973f, - 0.441078960895538f, -0.496516168117523f, 0.440698176622391f, -0.496470838785172f, - 0.440317392349243f, -0.496425211429596f, 0.439936667680740f, -0.496379286050797f, - 0.439555943012238f, -0.496333062648773f, 0.439175277948380f, -0.496286571025848f, - 0.438794672489166f, -0.496239781379700f, 0.438414067029953f, -0.496192663908005f, - 0.438033521175385f, -0.496145308017731f, 0.437653005123138f, -0.496097624301910f, - 0.437272518873215f, -0.496049642562866f, 0.436892062425613f, -0.496001392602921f, - 0.436511665582657f, -0.495952844619751f, 0.436131268739700f, -0.495903998613358f, - 0.435750931501389f, -0.495854884386063f, 0.435370653867722f, -0.495805442333221f, - 0.434990376234055f, -0.495755732059479f, 0.434610158205032f, -0.495705723762512f, - 0.434229999780655f, -0.495655417442322f, 0.433849841356277f, -0.495604842901230f, - 0.433469742536545f, -0.495553970336914f, 0.433089673519135f, -0.495502769947052f, - 0.432709634304047f, -0.495451331138611f, 0.432329654693604f, -0.495399564504623f, - 0.431949704885483f, -0.495347499847412f, 0.431569814682007f, -0.495295166969299f, - 0.431189924478531f, -0.495242536067963f, 0.430810123682022f, -0.495189607143402f, - 0.430430322885513f, -0.495136409997940f, 0.430050581693649f, -0.495082914829254f, - 0.429670870304108f, -0.495029091835022f, 0.429291218519211f, -0.494975030422211f, - 0.428911596536636f, -0.494920641183853f, 0.428532034158707f, -0.494865983724594f, - 0.428152471780777f, -0.494810998439789f, 0.427772998809814f, -0.494755744934082f, - 0.427393525838852f, -0.494700223207474f, 0.427014142274857f, -0.494644373655319f, - 0.426634758710861f, -0.494588255882263f, 0.426255434751511f, -0.494531840085983f, - 0.425876170396805f, -0.494475126266479f, 0.425496935844421f, -0.494418144226074f, - 0.425117731094360f, -0.494360834360123f, 0.424738585948944f, -0.494303256273270f, - 0.424359470605850f, -0.494245409965515f, 0.423980414867401f, -0.494187235832214f, - 0.423601418733597f, -0.494128793478012f, 0.423222452402115f, -0.494070053100586f, - 0.422843515872955f, -0.494011014699936f, 0.422464638948441f, -0.493951678276062f, - 0.422085791826248f, -0.493892073631287f, 0.421707004308701f, -0.493832170963287f, - 0.421328276395798f, -0.493771970272064f, 0.420949578285217f, -0.493711471557617f, - 0.420570939779282f, -0.493650704622269f, 0.420192331075668f, -0.493589639663696f, - 0.419813781976700f, -0.493528276681900f, 0.419435262680054f, -0.493466645479202f, - 0.419056802988052f, -0.493404686450958f, 0.418678402900696f, -0.493342459201813f, - 0.418300032615662f, -0.493279963731766f, 0.417921721935272f, -0.493217140436172f, - 0.417543441057205f, -0.493154048919678f, 0.417165219783783f, -0.493090659379959f, - 0.416787058115005f, -0.493026971817017f, 0.416408926248550f, -0.492963016033173f, - 0.416030853986740f, -0.492898762226105f, 0.415652841329575f, -0.492834210395813f, - 0.415274858474731f, -0.492769360542297f, 0.414896935224533f, -0.492704242467880f, - 0.414519041776657f, -0.492638826370239f, 0.414141237735748f, -0.492573112249374f, - 0.413763463497162f, -0.492507129907608f, 0.413385748863220f, -0.492440819740295f, - 0.413008064031601f, -0.492374241352081f, 0.412630438804626f, -0.492307394742966f, - 0.412252873182297f, -0.492240220308304f, 0.411875367164612f, -0.492172777652740f, - 0.411497890949249f, -0.492105036973953f, 0.411120474338531f, -0.492037028074265f, - 0.410743117332459f, -0.491968721151352f, 0.410365819931030f, -0.491900116205215f, - 0.409988552331924f, -0.491831213235855f, 0.409611344337463f, -0.491762012243271f, - 0.409234195947647f, -0.491692543029785f, 0.408857107162476f, -0.491622805595398f, - 0.408480048179626f, -0.491552740335464f, 0.408103078603745f, -0.491482406854630f, - 0.407726138830185f, -0.491411775350571f, 0.407349258661270f, -0.491340845823288f, - 0.406972438097000f, -0.491269648075104f, 0.406595647335052f, -0.491198152303696f, - 0.406218945980072f, -0.491126358509064f, 0.405842274427414f, -0.491054296493530f, - 0.405465662479401f, -0.490981936454773f, 0.405089110136032f, -0.490909278392792f, - 0.404712617397308f, -0.490836352109909f, 0.404336184263229f, -0.490763127803802f, - 0.403959810733795f, -0.490689605474472f, 0.403583467006683f, -0.490615785121918f, - 0.403207212686539f, -0.490541696548462f, 0.402830988168716f, -0.490467309951782f, - 0.402454853057861f, -0.490392625331879f, 0.402078747749329f, -0.490317672491074f, - 0.401702702045441f, -0.490242421627045f, 0.401326715946198f, -0.490166902542114f, - 0.400950789451599f, -0.490091055631638f, 0.400574922561646f, -0.490014940500259f, - 0.400199115276337f, -0.489938557147980f, 0.399823367595673f, -0.489861875772476f, - 0.399447679519653f, -0.489784896373749f, 0.399072051048279f, -0.489707618951797f, - 0.398696482181549f, -0.489630073308945f, 0.398320972919464f, -0.489552229642868f, - 0.397945523262024f, -0.489474087953568f, 0.397570133209229f, -0.489395678043365f, - 0.397194802761078f, -0.489316970109940f, 0.396819531917572f, -0.489237964153290f, - 0.396444320678711f, -0.489158689975739f, 0.396069169044495f, -0.489079117774963f, - 0.395694077014923f, -0.488999247550964f, 0.395319044589996f, -0.488919109106064f, - 0.394944071769714f, -0.488838672637939f, 0.394569188356400f, -0.488757967948914f, - 0.394194334745407f, -0.488676935434341f, 0.393819570541382f, -0.488595664501190f, - 0.393444836139679f, -0.488514065742493f, 0.393070191144943f, -0.488432198762894f, - 0.392695605754852f, -0.488350033760071f, 0.392321079969406f, -0.488267600536346f, - 0.391946613788605f, -0.488184869289398f, 0.391572207212448f, -0.488101840019226f, - 0.391197860240936f, -0.488018542528152f, 0.390823602676392f, -0.487934947013855f, - 0.390449374914169f, -0.487851053476334f, 0.390075236558914f, -0.487766891717911f, - 0.389701157808304f, -0.487682431936264f, 0.389327138662338f, -0.487597703933716f, - 0.388953179121017f, -0.487512677907944f, 0.388579308986664f, -0.487427353858948f, - 0.388205498456955f, -0.487341761589050f, 0.387831717729568f, -0.487255871295929f, - 0.387458056211472f, -0.487169682979584f, 0.387084424495697f, -0.487083226442337f, - 0.386710882186890f, -0.486996471881866f, 0.386337369680405f, -0.486909449100494f, - 0.385963946580887f, -0.486822128295898f, 0.385590612888336f, -0.486734509468079f, - 0.385217308998108f, -0.486646622419357f, 0.384844094514847f, -0.486558437347412f, - 0.384470939636230f, -0.486469984054565f, 0.384097874164581f, -0.486381232738495f, - 0.383724838495255f, -0.486292183399200f, 0.383351892232895f, -0.486202865839005f, - 0.382979035377502f, -0.486113250255585f, 0.382606208324432f, -0.486023366451263f, - 0.382233470678329f, -0.485933154821396f, 0.381860792636871f, -0.485842704772949f, - 0.381488204002380f, -0.485751956701279f, 0.381115674972534f, -0.485660910606384f, - 0.380743205547333f, -0.485569566488266f, 0.380370795726776f, -0.485477954149246f, - 0.379998475313187f, -0.485386073589325f, 0.379626244306564f, -0.485293895006180f, - 0.379254043102264f, -0.485201418399811f, 0.378881961107254f, -0.485108673572540f, - 0.378509908914566f, -0.485015630722046f, 0.378137946128845f, -0.484922289848328f, - 0.377766042947769f, -0.484828680753708f, 0.377394229173660f, -0.484734803438187f, - 0.377022475004196f, -0.484640628099442f, 0.376650810241699f, -0.484546154737473f, - 0.376279205083847f, -0.484451413154602f, 0.375907659530640f, -0.484356373548508f, - 0.375536203384399f, -0.484261035919189f, 0.375164806842804f, -0.484165430068970f, - 0.374793499708176f, -0.484069555997849f, 0.374422252178192f, -0.483973383903503f, - 0.374051094055176f, -0.483876913785934f, 0.373679995536804f, -0.483780175447464f, - 0.373308986425400f, -0.483683139085770f, 0.372938036918640f, -0.483585834503174f, - 0.372567176818848f, -0.483488231897354f, 0.372196376323700f, -0.483390361070633f, - 0.371825665235519f, -0.483292192220688f, 0.371455013751984f, -0.483193725347519f, - 0.371084451675415f, -0.483094990253448f, 0.370713949203491f, -0.482995986938477f, - 0.370343536138535f, -0.482896685600281f, 0.369973212480545f, -0.482797086238861f, - 0.369602948427200f, -0.482697218656540f, 0.369232743978500f, -0.482597053050995f, - 0.368862658739090f, -0.482496619224548f, 0.368492603302002f, -0.482395917177200f, - 0.368122667074203f, -0.482294887304306f, 0.367752790451050f, -0.482193619012833f, - 0.367382973432541f, -0.482092022895813f, 0.367013275623322f, -0.481990188360214f, - 0.366643607616425f, -0.481888025999069f, 0.366274058818817f, -0.481785595417023f, - 0.365904569625854f, -0.481682896614075f, 0.365535169839859f, -0.481579899787903f, - 0.365165829658508f, -0.481476634740829f, 0.364796578884125f, -0.481373071670532f, - 0.364427417516708f, -0.481269240379334f, 0.364058345556259f, -0.481165111064911f, - 0.363689333200455f, -0.481060713529587f, 0.363320380449295f, -0.480956017971039f, - 0.362951546907425f, -0.480851024389267f, 0.362582772970200f, -0.480745792388916f, - 0.362214088439941f, -0.480640232563019f, 0.361845493316650f, -0.480534434318542f, - 0.361476957798004f, -0.480428308248520f, 0.361108511686325f, -0.480321943759918f, - 0.360740154981613f, -0.480215251445770f, 0.360371887683868f, -0.480108320713043f, - 0.360003679990768f, -0.480001062154770f, 0.359635561704636f, -0.479893565177917f, - 0.359267532825470f, -0.479785770177841f, 0.358899593353271f, -0.479677677154541f, - 0.358531713485718f, -0.479569315910339f, 0.358163923025131f, -0.479460656642914f, - 0.357796221971512f, -0.479351729154587f, 0.357428610324860f, -0.479242533445358f, - 0.357061088085175f, -0.479133039712906f, 0.356693625450134f, -0.479023247957230f, - 0.356326282024384f, -0.478913217782974f, 0.355958998203278f, -0.478802859783173f, - 0.355591803789139f, -0.478692263364792f, 0.355224698781967f, -0.478581339120865f, - 0.354857653379440f, -0.478470176458359f, 0.354490727186203f, -0.478358715772629f, - 0.354123860597610f, -0.478246957063675f, 0.353757113218308f, -0.478134930133820f, - 0.353390425443649f, -0.478022634983063f, 0.353023827075958f, -0.477910041809082f, - 0.352657318115234f, -0.477797180414200f, 0.352290898561478f, -0.477684020996094f, - 0.351924568414688f, -0.477570593357086f, 0.351558297872543f, -0.477456867694855f, - 0.351192146539688f, -0.477342873811722f, 0.350826084613800f, -0.477228611707687f, - 0.350460082292557f, -0.477114051580429f, 0.350094199180603f, -0.476999223232269f, - 0.349728375673294f, -0.476884096860886f, 0.349362671375275f, -0.476768702268600f, - 0.348997026681900f, -0.476653009653091f, 0.348631471395493f, -0.476537048816681f, - 0.348266035318375f, -0.476420819759369f, 0.347900658845901f, -0.476304292678833f, - 0.347535371780396f, -0.476187497377396f, 0.347170203924179f, -0.476070433855057f, - 0.346805095672607f, -0.475953072309494f, 0.346440106630325f, -0.475835442543030f, - 0.346075177192688f, -0.475717514753342f, 0.345710366964340f, -0.475599318742752f, - 0.345345616340637f, -0.475480824708939f, 0.344980984926224f, -0.475362062454224f, - 0.344616413116455f, -0.475243031978607f, 0.344251960515976f, -0.475123733282089f, - 0.343887597322464f, -0.475004136562347f, 0.343523323535919f, -0.474884241819382f, - 0.343159139156342f, -0.474764078855515f, 0.342795044183731f, -0.474643647670746f, - 0.342431038618088f, -0.474522948265076f, 0.342067122459412f, -0.474401950836182f, - 0.341703325510025f, -0.474280685186386f, 0.341339588165283f, -0.474159121513367f, - 0.340975970029831f, -0.474037289619446f, 0.340612411499023f, -0.473915189504623f, - 0.340248972177505f, -0.473792791366577f, 0.339885622262955f, -0.473670125007629f, - 0.339522391557693f, -0.473547190427780f, 0.339159220457077f, -0.473423957824707f, - 0.338796168565750f, -0.473300457000732f, 0.338433176279068f, -0.473176687955856f, - 0.338070303201675f, -0.473052620887756f, 0.337707549333572f, -0.472928285598755f, - 0.337344855070114f, -0.472803652286530f, 0.336982280015945f, -0.472678780555725f, - 0.336619764566422f, -0.472553610801697f, 0.336257368326187f, -0.472428143024445f, - 0.335895091295242f, -0.472302407026291f, 0.335532873868942f, -0.472176402807236f, - 0.335170775651932f, -0.472050130367279f, 0.334808766841888f, -0.471923559904099f, - 0.334446847438812f, -0.471796721220016f, 0.334085017442703f, -0.471669614315033f, - 0.333723306655884f, -0.471542209386826f, 0.333361685276031f, -0.471414536237717f, - 0.333000183105469f, -0.471286594867706f, 0.332638740539551f, -0.471158385276794f, - 0.332277417182922f, -0.471029877662659f, 0.331916213035584f, -0.470901101827621f, - 0.331555068492889f, -0.470772027969360f, 0.331194043159485f, -0.470642685890198f, - 0.330833107233047f, -0.470513075590134f, 0.330472290515900f, -0.470383197069168f, - 0.330111563205719f, -0.470253020524979f, 0.329750925302505f, -0.470122605562210f, - 0.329390406608582f, -0.469991862773895f, 0.329029977321625f, -0.469860881567001f, - 0.328669637441635f, -0.469729602336884f, 0.328309416770935f, -0.469598054885864f, - 0.327949285507202f, -0.469466239213943f, 0.327589273452759f, -0.469334155321121f, - 0.327229350805283f, -0.469201773405075f, 0.326869517564774f, -0.469069123268127f, - 0.326509803533554f, -0.468936175107956f, 0.326150178909302f, -0.468802988529205f, - 0.325790673494339f, -0.468669503927231f, 0.325431257486343f, -0.468535751104355f, - 0.325071930885315f, -0.468401730060577f, 0.324712723493576f, -0.468267410993576f, - 0.324353635311127f, -0.468132823705673f, 0.323994606733322f, -0.467997968196869f, - 0.323635727167130f, -0.467862844467163f, 0.323276937007904f, -0.467727422714233f, - 0.322918236255646f, -0.467591762542725f, 0.322559654712677f, -0.467455804347992f, - 0.322201162576675f, -0.467319577932358f, 0.321842789649963f, -0.467183053493500f, - 0.321484506130219f, -0.467046260833740f, 0.321126341819763f, -0.466909229755402f, - 0.320768296718597f, -0.466771900653839f, 0.320410341024399f, -0.466634273529053f, - 0.320052474737167f, -0.466496407985687f, 0.319694727659225f, -0.466358244419098f, - 0.319337099790573f, -0.466219812631607f, 0.318979561328888f, -0.466081112623215f, - 0.318622142076492f, -0.465942144393921f, 0.318264812231064f, -0.465802878141403f, - 0.317907601594925f, -0.465663343667984f, 0.317550510168076f, -0.465523540973663f, - 0.317193508148193f, -0.465383470058441f, 0.316836595535278f, -0.465243130922318f, - 0.316479831933975f, -0.465102523565292f, 0.316123157739639f, -0.464961618185043f, - 0.315766572952271f, -0.464820444583893f, 0.315410137176514f, -0.464679002761841f, - 0.315053790807724f, -0.464537292718887f, 0.314697533845901f, -0.464395314455032f, - 0.314341396093369f, -0.464253038167953f, 0.313985377550125f, -0.464110493659973f, - 0.313629478216171f, -0.463967710733414f, 0.313273668289185f, -0.463824629783630f, - 0.312917977571487f, -0.463681250810623f, 0.312562376260757f, -0.463537633419037f, - 0.312206923961639f, -0.463393747806549f, 0.311851561069489f, -0.463249564170837f, - 0.311496287584305f, -0.463105112314224f, 0.311141163110733f, -0.462960392236710f, - 0.310786128044128f, -0.462815403938293f, 0.310431212186813f, -0.462670147418976f, - 0.310076385736465f, -0.462524622678757f, 0.309721708297729f, -0.462378799915314f, - 0.309367120265961f, -0.462232738733292f, 0.309012651443481f, -0.462086379528046f, - 0.308658272027969f, -0.461939752101898f, 0.308304041624069f, -0.461792886257172f, - 0.307949900627136f, -0.461645722389221f, 0.307595878839493f, -0.461498260498047f, - 0.307241976261139f, -0.461350560188293f, 0.306888192892075f, -0.461202591657639f, - 0.306534498929977f, -0.461054325103760f, 0.306180924177170f, -0.460905820131302f, - 0.305827468633652f, -0.460757017135620f, 0.305474132299423f, -0.460607945919037f, - 0.305120915174484f, -0.460458606481552f, 0.304767817258835f, -0.460309028625488f, - 0.304414808750153f, -0.460159152746201f, 0.304061919450760f, -0.460008978843689f, - 0.303709149360657f, -0.459858566522598f, 0.303356528282166f, -0.459707885980606f, - 0.303003966808319f, -0.459556937217712f, 0.302651554346085f, -0.459405690431595f, - 0.302299261093140f, -0.459254205226898f, 0.301947087049484f, -0.459102421998978f, - 0.301595002412796f, -0.458950400352478f, 0.301243066787720f, -0.458798080682755f, - 0.300891220569611f, -0.458645492792130f, 0.300539493560791f, -0.458492636680603f, - 0.300187885761261f, -0.458339542150497f, 0.299836426973343f, -0.458186149597168f, - 0.299485057592392f, -0.458032488822937f, 0.299133807420731f, -0.457878559827805f, - 0.298782676458359f, -0.457724362611771f, 0.298431664705276f, -0.457569897174835f, - 0.298080772161484f, -0.457415163516998f, 0.297729998826981f, -0.457260161638260f, - 0.297379344701767f, -0.457104891538620f, 0.297028809785843f, -0.456949323415756f, - 0.296678394079208f, -0.456793516874313f, 0.296328097581863f, -0.456637442111969f, - 0.295977920293808f, -0.456481099128723f, 0.295627862215042f, -0.456324487924576f, - 0.295277923345566f, -0.456167578697205f, 0.294928103685379f, -0.456010431051254f, - 0.294578403234482f, -0.455853015184402f, 0.294228851795197f, -0.455695331096649f, - 0.293879389762878f, -0.455537378787994f, 0.293530046939850f, -0.455379128456116f, - 0.293180853128433f, -0.455220639705658f, 0.292831748723984f, -0.455061882734299f, - 0.292482793331146f, -0.454902857542038f, 0.292133957147598f, -0.454743564128876f, - 0.291785210371017f, -0.454584002494812f, 0.291436612606049f, -0.454424172639847f, - 0.291088134050369f, -0.454264044761658f, 0.290739774703979f, -0.454103678464890f, - 0.290391564369202f, -0.453943043947220f, 0.290043443441391f, -0.453782171010971f, - 0.289695471525192f, -0.453621000051498f, 0.289347589015961f, -0.453459560871124f, - 0.288999855518341f, -0.453297853469849f, 0.288652241230011f, -0.453135877847672f, - 0.288304775953293f, -0.452973634004593f, 0.287957400083542f, -0.452811151742935f, - 0.287610173225403f, -0.452648371458054f, 0.287263035774231f, -0.452485352754593f, - 0.286916047334671f, -0.452322036027908f, 0.286569178104401f, -0.452158480882645f, - 0.286222457885742f, -0.451994657516479f, 0.285875827074051f, -0.451830536127090f, - 0.285529345273972f, -0.451666176319122f, 0.285182982683182f, -0.451501548290253f, - 0.284836769104004f, -0.451336652040482f, 0.284490644931793f, -0.451171487569809f, - 0.284144669771194f, -0.451006084680557f, 0.283798813819885f, -0.450840383768082f, - 0.283453077077866f, -0.450674414634705f, 0.283107489347458f, -0.450508207082748f, - 0.282762020826340f, -0.450341701507568f, 0.282416671514511f, -0.450174957513809f, - 0.282071471214294f, -0.450007945299149f, 0.281726360321045f, -0.449840664863586f, - 0.281381398439407f, -0.449673116207123f, 0.281036585569382f, -0.449505299329758f, - 0.280691891908646f, -0.449337244033813f, 0.280347317457199f, -0.449168890714645f, - 0.280002862215042f, -0.449000298976898f, 0.279658555984497f, -0.448831409215927f, - 0.279314368963242f, -0.448662281036377f, 0.278970301151276f, -0.448492884635925f, - 0.278626382350922f, -0.448323249816895f, 0.278282582759857f, -0.448153316974640f, - 0.277938932180405f, -0.447983115911484f, 0.277595400810242f, -0.447812676429749f, - 0.277251988649368f, -0.447641968727112f, 0.276908725500107f, -0.447470992803574f, - 0.276565581560135f, -0.447299748659134f, 0.276222556829453f, -0.447128236293793f, - 0.275879681110382f, -0.446956485509872f, 0.275536954402924f, -0.446784436702728f, - 0.275194346904755f, -0.446612149477005f, 0.274851858615875f, -0.446439594030380f, - 0.274509519338608f, -0.446266770362854f, 0.274167299270630f, -0.446093708276749f, - 0.273825198411942f, -0.445920348167419f, 0.273483246564865f, -0.445746749639511f, - 0.273141443729401f, -0.445572882890701f, 0.272799760103226f, -0.445398747920990f, - 0.272458195686340f, -0.445224374532700f, 0.272116780281067f, -0.445049703121185f, - 0.271775513887405f, -0.444874793291092f, 0.271434366703033f, -0.444699615240097f, - 0.271093338727951f, -0.444524168968201f, 0.270752459764481f, -0.444348484277725f, - 0.270411729812622f, -0.444172531366348f, 0.270071119070053f, -0.443996280431747f, - 0.269730657339096f, -0.443819820880890f, 0.269390314817429f, -0.443643063306808f, - 0.269050091505051f, -0.443466067314148f, 0.268710047006607f, -0.443288803100586f, - 0.268370121717453f, -0.443111270666122f, 0.268030315637589f, -0.442933470010757f, - 0.267690658569336f, -0.442755430936813f, 0.267351150512695f, -0.442577123641968f, - 0.267011761665344f, -0.442398548126221f, 0.266672492027283f, -0.442219734191895f, - 0.266333401203156f, -0.442040622234344f, 0.265994429588318f, -0.441861271858215f, - 0.265655577182770f, -0.441681683063507f, 0.265316903591156f, -0.441501796245575f, - 0.264978319406509f, -0.441321671009064f, 0.264639914035797f, -0.441141277551651f, - 0.264301627874374f, -0.440960645675659f, 0.263963490724564f, -0.440779715776443f, - 0.263625472784042f, -0.440598547458649f, 0.263287603855133f, -0.440417140722275f, - 0.262949883937836f, -0.440235435962677f, 0.262612313032150f, -0.440053492784500f, - 0.262274861335754f, -0.439871311187744f, 0.261937558650970f, -0.439688831567764f, - 0.261600375175476f, -0.439506113529205f, 0.261263370513916f, -0.439323127269745f, - 0.260926485061646f, -0.439139902591705f, 0.260589718818665f, -0.438956409692764f, - 0.260253131389618f, -0.438772648572922f, 0.259916663169861f, -0.438588619232178f, - 0.259580343961716f, -0.438404351472855f, 0.259244143962860f, -0.438219845294952f, - 0.258908122777939f, -0.438035041093826f, 0.258572220802307f, -0.437849998474121f, - 0.258236467838287f, -0.437664687633514f, 0.257900834083557f, -0.437479138374329f, - 0.257565379142761f, -0.437293320894241f, 0.257230043411255f, -0.437107264995575f, - 0.256894856691360f, -0.436920911073685f, 0.256559818983078f, -0.436734348535538f, - 0.256224930286407f, -0.436547487974167f, 0.255890160799026f, -0.436360388994217f, - 0.255555540323257f, -0.436173021793365f, 0.255221068859100f, -0.435985416173935f, - 0.254886746406555f, -0.435797542333603f, 0.254552572965622f, -0.435609430074692f, - 0.254218548536301f, -0.435421019792557f, 0.253884643316269f, -0.435232400894165f, - 0.253550916910172f, -0.435043483972549f, 0.253217309713364f, -0.434854328632355f, - 0.252883851528168f, -0.434664934873581f, 0.252550542354584f, -0.434475272893906f, - 0.252217382192612f, -0.434285342693329f, 0.251884341239929f, -0.434095174074173f, - 0.251551479101181f, -0.433904737234116f, 0.251218736171722f, -0.433714061975479f, - 0.250886172056198f, -0.433523118495941f, 0.250553727149963f, -0.433331936597824f, - 0.250221431255341f, -0.433140486478806f, 0.249889299273491f, -0.432948768138886f, - 0.249557301402092f, -0.432756811380386f, 0.249225467443466f, -0.432564586400986f, - 0.248893767595291f, -0.432372123003006f, 0.248562216758728f, -0.432179391384125f, - 0.248230814933777f, -0.431986421346664f, 0.247899547219276f, -0.431793183088303f, - 0.247568443417549f, -0.431599706411362f, 0.247237488627434f, -0.431405961513519f, - 0.246906682848930f, -0.431211978197098f, 0.246576011180878f, -0.431017726659775f, - 0.246245503425598f, -0.430823236703873f, 0.245915144681931f, -0.430628478527069f, - 0.245584934949875f, -0.430433481931686f, 0.245254859328270f, -0.430238217115402f, - 0.244924947619438f, -0.430042684078217f, 0.244595184922218f, -0.429846942424774f, - 0.244265571236610f, -0.429650902748108f, 0.243936106562614f, -0.429454624652863f, - 0.243606805801392f, -0.429258108139038f, 0.243277639150620f, -0.429061323404312f, - 0.242948621511459f, -0.428864300251007f, 0.242619767785072f, -0.428667008876801f, - 0.242291063070297f, -0.428469479084015f, 0.241962507367134f, -0.428271710872650f, - 0.241634100675583f, -0.428073674440384f, 0.241305842995644f, -0.427875369787216f, - 0.240977749228477f, -0.427676826715469f, 0.240649804472923f, -0.427478045225143f, - 0.240322008728981f, -0.427278995513916f, 0.239994361996651f, -0.427079707384110f, - 0.239666879177094f, -0.426880151033401f, 0.239339530467987f, -0.426680356264114f, - 0.239012360572815f, -0.426480293273926f, 0.238685324788094f, -0.426279991865158f, - 0.238358452916145f, -0.426079452037811f, 0.238031730055809f, -0.425878643989563f, - 0.237705156207085f, -0.425677597522736f, 0.237378746271133f, -0.425476282835007f, - 0.237052485346794f, -0.425274729728699f, 0.236726388335228f, -0.425072938203812f, - 0.236400425434113f, -0.424870878458023f, 0.236074641346931f, -0.424668580293655f, - 0.235749006271362f, -0.424466013908386f, 0.235423520207405f, -0.424263238906860f, - 0.235098183155060f, -0.424060165882111f, 0.234773010015488f, -0.423856884241104f, - 0.234448000788689f, -0.423653304576874f, 0.234123140573502f, -0.423449516296387f, - 0.233798429369926f, -0.423245459794998f, 0.233473882079124f, -0.423041164875031f, - 0.233149498701096f, -0.422836631536484f, 0.232825264334679f, -0.422631829977036f, - 0.232501193881035f, -0.422426789999008f, 0.232177272439003f, -0.422221481800079f, - 0.231853514909744f, -0.422015935182571f, 0.231529906392097f, -0.421810150146484f, - 0.231206461787224f, -0.421604126691818f, 0.230883181095123f, -0.421397835016251f, - 0.230560049414635f, -0.421191304922104f, 0.230237081646919f, -0.420984506607056f, - 0.229914262890816f, -0.420777499675751f, 0.229591608047485f, -0.420570224523544f, - 0.229269117116928f, -0.420362681150436f, 0.228946775197983f, -0.420154929161072f, - 0.228624612092972f, -0.419946908950806f, 0.228302597999573f, -0.419738620519638f, - 0.227980732917786f, -0.419530123472214f, 0.227659046649933f, -0.419321358203888f, - 0.227337509393692f, -0.419112354516983f, 0.227016136050224f, -0.418903112411499f, - 0.226694911718369f, -0.418693602085114f, 0.226373866200447f, -0.418483853340149f, - 0.226052969694138f, -0.418273866176605f, 0.225732237100601f, -0.418063640594482f, - 0.225411668419838f, -0.417853146791458f, 0.225091263651848f, -0.417642414569855f, - 0.224771007895470f, -0.417431443929672f, 0.224450930953026f, -0.417220205068588f, - 0.224131003022194f, -0.417008757591248f, 0.223811239004135f, -0.416797041893005f, - 0.223491653800011f, -0.416585087776184f, 0.223172217607498f, -0.416372895240784f, - 0.222852945327759f, -0.416160434484482f, 0.222533836960793f, -0.415947735309601f, - 0.222214877605438f, -0.415734797716141f, 0.221896097064018f, -0.415521621704102f, - 0.221577480435371f, -0.415308207273483f, 0.221259027719498f, -0.415094524621964f, - 0.220940738916397f, -0.414880603551865f, 0.220622614026070f, -0.414666473865509f, - 0.220304638147354f, -0.414452046155930f, 0.219986841082573f, -0.414237409830093f, - 0.219669207930565f, -0.414022535085678f, 0.219351738691330f, -0.413807392120361f, - 0.219034433364868f, -0.413592010736465f, 0.218717306852341f, -0.413376390933990f, - 0.218400329351425f, -0.413160532712936f, 0.218083515763283f, -0.412944436073303f, - 0.217766880989075f, -0.412728071212769f, 0.217450410127640f, -0.412511497735977f, - 0.217134088277817f, -0.412294656038284f, 0.216817945241928f, -0.412077575922012f, - 0.216501981019974f, -0.411860257387161f, 0.216186165809631f, -0.411642700433731f, - 0.215870529413223f, -0.411424905061722f, 0.215555042028427f, -0.411206841468811f, - 0.215239733457565f, -0.410988569259644f, 0.214924603700638f, -0.410770028829575f, - 0.214609622955322f, -0.410551249980927f, 0.214294821023941f, -0.410332232713699f, - 0.213980183005333f, -0.410112977027893f, 0.213665723800659f, -0.409893482923508f, - 0.213351413607597f, -0.409673750400543f, 0.213037282228470f, -0.409453779459000f, - 0.212723329663277f, -0.409233570098877f, 0.212409526109695f, -0.409013092517853f, - 0.212095901370049f, -0.408792406320572f, 0.211782455444336f, -0.408571451902390f, - 0.211469158530235f, -0.408350288867950f, 0.211156040430069f, -0.408128857612610f, - 0.210843101143837f, -0.407907217741013f, 0.210530325770378f, -0.407685309648514f, - 0.210217714309692f, -0.407463163137436f, 0.209905281662941f, -0.407240778207779f, - 0.209593027830124f, -0.407018154859543f, 0.209280923008919f, -0.406795293092728f, - 0.208969011902809f, -0.406572192907333f, 0.208657249808311f, -0.406348884105682f, - 0.208345666527748f, -0.406125307083130f, 0.208034262061119f, -0.405901491641998f, - 0.207723021507263f, -0.405677437782288f, 0.207411959767342f, -0.405453115701675f, - 0.207101076841354f, -0.405228585004807f, 0.206790357828140f, -0.405003815889359f, - 0.206479802727699f, -0.404778808355331f, 0.206169426441193f, -0.404553562402725f, - 0.205859228968620f, -0.404328078031540f, 0.205549195408821f, -0.404102355241776f, - 0.205239340662956f, -0.403876423835754f, 0.204929664731026f, -0.403650224208832f, - 0.204620152711868f, -0.403423786163330f, 0.204310819506645f, -0.403197109699249f, - 0.204001650214195f, -0.402970194816589f, 0.203692659735680f, -0.402743041515350f, - 0.203383848071098f, -0.402515679597855f, 0.203075215220451f, -0.402288049459457f, - 0.202766746282578f, -0.402060180902481f, 0.202458456158638f, -0.401832103729248f, - 0.202150344848633f, -0.401603758335114f, 0.201842412352562f, -0.401375204324722f, - 0.201534643769264f, -0.401146411895752f, 0.201227053999901f, -0.400917351245880f, - 0.200919643044472f, -0.400688081979752f, 0.200612410902977f, -0.400458574295044f, - 0.200305357575417f, -0.400228828191757f, 0.199998468160629f, -0.399998843669891f, - 0.199691757559776f, -0.399768620729446f, 0.199385225772858f, -0.399538189172745f, - 0.199078872799873f, -0.399307489395142f, 0.198772698640823f, -0.399076581001282f, - 0.198466703295708f, -0.398845434188843f, 0.198160871863365f, -0.398614019155502f, - 0.197855234146118f, -0.398382395505905f, 0.197549775242805f, -0.398150533437729f, - 0.197244480252266f, -0.397918462753296f, 0.196939364075661f, -0.397686123847961f, - 0.196634441614151f, -0.397453576326370f, 0.196329683065414f, -0.397220760583878f, - 0.196025103330612f, -0.396987736225128f, 0.195720717310905f, -0.396754473447800f, - 0.195416495203972f, -0.396520972251892f, 0.195112451910973f, -0.396287262439728f, - 0.194808602333069f, -0.396053284406662f, 0.194504916667938f, -0.395819097757339f, - 0.194201424717903f, -0.395584672689438f, 0.193898096680641f, -0.395350009202957f, - 0.193594962358475f, -0.395115107297897f, 0.193292006850243f, -0.394879996776581f, - 0.192989215254784f, -0.394644618034363f, 0.192686617374420f, -0.394409030675888f, - 0.192384198307991f, -0.394173204898834f, 0.192081972956657f, -0.393937170505524f, - 0.191779911518097f, -0.393700867891312f, 0.191478043794632f, -0.393464356660843f, - 0.191176339983940f, -0.393227607011795f, 0.190874829888344f, -0.392990618944168f, - 0.190573498606682f, -0.392753422260284f, 0.190272361040115f, -0.392515957355499f, - 0.189971387386322f, -0.392278283834457f, 0.189670607447624f, -0.392040401697159f, - 0.189370006322861f, -0.391802251338959f, 0.189069598913193f, -0.391563892364502f, - 0.188769355416298f, -0.391325294971466f, 0.188469305634499f, -0.391086459159851f, - 0.188169434666634f, -0.390847414731979f, 0.187869757413864f, -0.390608131885529f, - 0.187570258975029f, -0.390368610620499f, 0.187270939350128f, -0.390128880739212f, - 0.186971798539162f, -0.389888882637024f, 0.186672851443291f, -0.389648675918579f, - 0.186374098062515f, -0.389408260583878f, 0.186075508594513f, -0.389167606830597f, - 0.185777112841606f, -0.388926714658737f, 0.185478910803795f, -0.388685584068298f, - 0.185180887579918f, -0.388444244861603f, 0.184883043169975f, -0.388202667236328f, - 0.184585392475128f, -0.387960851192474f, 0.184287920594215f, -0.387718826532364f, - 0.183990627527237f, -0.387476563453674f, 0.183693528175354f, -0.387234061956406f, - 0.183396622538567f, -0.386991351842880f, 0.183099895715714f, -0.386748403310776f, - 0.182803362607956f, -0.386505216360092f, 0.182507008314133f, -0.386261820793152f, - 0.182210832834244f, -0.386018186807632f, 0.181914865970612f, -0.385774344205856f, - 0.181619063019753f, -0.385530263185501f, 0.181323468685150f, -0.385285943746567f, - 0.181028053164482f, -0.385041415691376f, 0.180732816457748f, -0.384796649217606f, - 0.180437773466110f, -0.384551674127579f, 0.180142924189568f, -0.384306460618973f, - 0.179848253726959f, -0.384061008691788f, 0.179553776979446f, -0.383815348148346f, - 0.179259493947029f, -0.383569449186325f, 0.178965389728546f, -0.383323341608047f, - 0.178671479225159f, -0.383076995611191f, 0.178377762436867f, -0.382830440998077f, - 0.178084224462509f, -0.382583618164063f, 0.177790880203247f, -0.382336616516113f, - 0.177497729659081f, -0.382089376449585f, 0.177204772830009f, -0.381841897964478f, - 0.176911994814873f, -0.381594210863113f, 0.176619410514832f, -0.381346285343170f, - 0.176327019929886f, -0.381098151206970f, 0.176034808158875f, -0.380849778652191f, - 0.175742805004120f, -0.380601197481155f, 0.175450980663300f, -0.380352377891541f, - 0.175159350037575f, -0.380103349685669f, 0.174867913126946f, -0.379854083061218f, - 0.174576655030251f, -0.379604607820511f, 0.174285605549812f, -0.379354894161224f, - 0.173994734883308f, -0.379104942083359f, 0.173704057931900f, -0.378854811191559f, - 0.173413574695587f, -0.378604412078857f, 0.173123285174370f, -0.378353834152222f, - 0.172833189368248f, -0.378102988004684f, 0.172543287277222f, -0.377851963043213f, - 0.172253578901291f, -0.377600699663162f, 0.171964049339294f, -0.377349197864532f, - 0.171674728393555f, -0.377097487449646f, 0.171385586261749f, -0.376845568418503f, - 0.171096652746201f, -0.376593410968781f, 0.170807912945747f, -0.376341015100479f, - 0.170519351959229f, -0.376088410615921f, 0.170230999588966f, -0.375835597515106f, - 0.169942826032639f, -0.375582575798035f, 0.169654861092567f, -0.375329315662384f, - 0.169367074966431f, -0.375075817108154f, 0.169079497456551f, -0.374822109937668f, - 0.168792113661766f, -0.374568194150925f, 0.168504923582077f, -0.374314039945602f, - 0.168217927217484f, -0.374059677124023f, 0.167931124567986f, -0.373805105686188f, - 0.167644515633583f, -0.373550295829773f, 0.167358100414276f, -0.373295277357101f, - 0.167071878910065f, -0.373040050268173f, 0.166785866022110f, -0.372784584760666f, - 0.166500031948090f, -0.372528880834579f, 0.166214406490326f, -0.372272998094559f, - 0.165928974747658f, -0.372016876935959f, 0.165643751621246f, -0.371760547161102f, - 0.165358707308769f, -0.371503978967667f, 0.165073871612549f, -0.371247202157974f, - 0.164789214730263f, -0.370990216732025f, 0.164504766464233f, -0.370732992887497f, - 0.164220526814461f, -0.370475560426712f, 0.163936465978622f, -0.370217919349670f, - 0.163652613759041f, -0.369960039854050f, 0.163368955254555f, -0.369701951742172f, - 0.163085505366325f, -0.369443655014038f, 0.162802234292030f, -0.369185149669647f, - 0.162519171833992f, -0.368926405906677f, 0.162236317992210f, -0.368667453527451f, - 0.161953642964363f, -0.368408292531967f, 0.161671176552773f, -0.368148893117905f, - 0.161388918757439f, -0.367889285087585f, 0.161106839776039f, -0.367629468441010f, - 0.160824984312058f, -0.367369443178177f, 0.160543307662010f, -0.367109179496765f, - 0.160261839628220f, -0.366848707199097f, 0.159980565309525f, -0.366588026285172f, - 0.159699499607086f, -0.366327136754990f, 0.159418627619743f, -0.366066008806229f, - 0.159137964248657f, -0.365804702043533f, 0.158857494592667f, -0.365543156862259f, - 0.158577233552933f, -0.365281373262405f, 0.158297166228294f, -0.365019410848618f, - 0.158017292618752f, -0.364757210016251f, 0.157737627625465f, -0.364494800567627f, - 0.157458171248436f, -0.364232182502747f, 0.157178908586502f, -0.363969355821610f, - 0.156899839639664f, -0.363706320524216f, 0.156620979309082f, -0.363443046808243f, - 0.156342327594757f, -0.363179564476013f, 0.156063869595528f, -0.362915903329849f, - 0.155785620212555f, -0.362651973962784f, 0.155507579445839f, -0.362387865781784f, - 0.155229732394218f, -0.362123548984528f, 0.154952079057693f, -0.361858993768692f, - 0.154674649238586f, -0.361594229936600f, 0.154397398233414f, -0.361329287290573f, - 0.154120370745659f, -0.361064106225967f, 0.153843536973000f, -0.360798716545105f, - 0.153566911816597f, -0.360533088445663f, 0.153290495276451f, -0.360267281532288f, - 0.153014272451401f, -0.360001266002655f, 0.152738258242607f, -0.359735012054443f, - 0.152462437748909f, -0.359468549489975f, 0.152186840772629f, -0.359201908111572f, - 0.151911437511444f, -0.358935028314590f, 0.151636242866516f, -0.358667939901352f, - 0.151361241936684f, -0.358400642871857f, 0.151086464524269f, -0.358133137226105f, - 0.150811880826950f, -0.357865422964096f, 0.150537505745888f, -0.357597470283508f, - 0.150263324379921f, -0.357329338788986f, 0.149989366531372f, -0.357060998678207f, - 0.149715602397919f, -0.356792420148849f, 0.149442046880722f, -0.356523662805557f, - 0.149168699979782f, -0.356254696846008f, 0.148895561695099f, -0.355985492467880f, - 0.148622632026672f, -0.355716109275818f, 0.148349896073341f, -0.355446487665176f, - 0.148077383637428f, -0.355176687240601f, 0.147805064916611f, -0.354906648397446f, - 0.147532954812050f, -0.354636400938034f, 0.147261068224907f, -0.354365974664688f, - 0.146989375352860f, -0.354095309972763f, 0.146717891097069f, -0.353824466466904f, - 0.146446615457535f, -0.353553384542465f, 0.146175548434258f, -0.353282123804092f, - 0.145904675126076f, -0.353010624647141f, 0.145634025335312f, -0.352738946676254f, - 0.145363584160805f, -0.352467030286789f, 0.145093351602554f, -0.352194935083389f, - 0.144823327660561f, -0.351922631263733f, 0.144553512334824f, -0.351650089025497f, - 0.144283905625343f, -0.351377367973328f, 0.144014507532120f, -0.351104438304901f, - 0.143745318055153f, -0.350831300020218f, 0.143476337194443f, -0.350557953119278f, - 0.143207564949989f, -0.350284397602081f, 0.142939001321793f, -0.350010633468628f, - 0.142670661211014f, -0.349736660718918f, 0.142402514815331f, -0.349462509155273f, - 0.142134591937065f, -0.349188119173050f, 0.141866862773895f, -0.348913550376892f, - 0.141599357128143f, -0.348638743162155f, 0.141332060098648f, -0.348363757133484f, - 0.141064971685410f, -0.348088562488556f, 0.140798106789589f, -0.347813159227371f, - 0.140531435608864f, -0.347537547349930f, 0.140264987945557f, -0.347261756658554f, - 0.139998748898506f, -0.346985727548599f, 0.139732718467712f, -0.346709519624710f, - 0.139466896653175f, -0.346433073282242f, 0.139201298356056f, -0.346156448125839f, - 0.138935908675194f, -0.345879614353180f, 0.138670727610588f, -0.345602601766586f, - 0.138405755162239f, -0.345325350761414f, 0.138141006231308f, -0.345047920942307f, - 0.137876465916634f, -0.344770282506943f, 0.137612134218216f, -0.344492435455322f, - 0.137348011136055f, -0.344214379787445f, 0.137084111571312f, -0.343936115503311f, - 0.136820420622826f, -0.343657672405243f, 0.136556953191757f, -0.343379020690918f, - 0.136293679475784f, -0.343100160360336f, 0.136030644178391f, -0.342821091413498f, - 0.135767802596092f, -0.342541843652725f, 0.135505184531212f, -0.342262357473373f, - 0.135242775082588f, -0.341982692480087f, 0.134980589151382f, -0.341702848672867f, - 0.134718611836433f, -0.341422766447067f, 0.134456858038902f, -0.341142505407333f, - 0.134195312857628f, -0.340862035751343f, 0.133933976292610f, -0.340581357479095f, - 0.133672863245010f, -0.340300500392914f, 0.133411958813667f, -0.340019434690475f, - 0.133151277899742f, -0.339738160371780f, 0.132890805602074f, -0.339456677436829f, - 0.132630556821823f, -0.339175015687943f, 0.132370531558990f, -0.338893145322800f, - 0.132110700011253f, -0.338611096143723f, 0.131851106882095f, -0.338328808546066f, - 0.131591722369194f, -0.338046342134476f, 0.131332546472549f, -0.337763696908951f, - 0.131073594093323f, -0.337480813264847f, 0.130814850330353f, -0.337197750806808f, - 0.130556344985962f, -0.336914509534836f, 0.130298033356667f, -0.336631029844284f, - 0.130039945244789f, -0.336347371339798f, 0.129782080650330f, -0.336063534021378f, - 0.129524439573288f, -0.335779488086700f, 0.129267007112503f, -0.335495233535767f, - 0.129009798169136f, -0.335210770368576f, 0.128752797842026f, -0.334926128387451f, - 0.128496021032333f, -0.334641307592392f, 0.128239467740059f, -0.334356248378754f, - 0.127983123064041f, -0.334071010351181f, 0.127727001905441f, -0.333785593509674f, - 0.127471104264259f, -0.333499968051910f, 0.127215430140495f, -0.333214133977890f, - 0.126959964632988f, -0.332928121089935f, 0.126704722642899f, -0.332641899585724f, - 0.126449704170227f, -0.332355499267578f, 0.126194894313812f, -0.332068890333176f, - 0.125940307974815f, -0.331782072782516f, 0.125685945153236f, -0.331495076417923f, - 0.125431805849075f, -0.331207901239395f, 0.125177875161171f, -0.330920487642288f, - 0.124924175441265f, -0.330632925033569f, 0.124670691788197f, -0.330345153808594f, - 0.124417431652546f, -0.330057173967361f, 0.124164395034313f, -0.329769015312195f, - 0.123911574482918f, -0.329480648040771f, 0.123658977448940f, -0.329192101955414f, - 0.123406603932381f, -0.328903347253799f, 0.123154446482658f, -0.328614413738251f, - 0.122902512550354f, -0.328325271606445f, 0.122650802135468f, -0.328035950660706f, - 0.122399315237999f, -0.327746421098709f, 0.122148044407368f, -0.327456712722778f, - 0.121896997094154f, -0.327166795730591f, 0.121646173298359f, -0.326876699924469f, - 0.121395580470562f, -0.326586425304413f, 0.121145196259022f, -0.326295942068100f, - 0.120895043015480f, -0.326005280017853f, 0.120645113289356f, -0.325714409351349f, - 0.120395407080650f, -0.325423330068588f, 0.120145916938782f, -0.325132101774216f, - 0.119896657764912f, -0.324840664863586f, 0.119647622108459f, -0.324549019336700f, - 0.119398809969425f, -0.324257194995880f, 0.119150213897228f, -0.323965191841125f, - 0.118901848793030f, -0.323672980070114f, 0.118653707206249f, -0.323380589485168f, - 0.118405789136887f, -0.323088020086288f, 0.118158094584942f, -0.322795242071152f, - 0.117910631000996f, -0.322502255439758f, 0.117663383483887f, -0.322209119796753f, - 0.117416366934776f, -0.321915775537491f, 0.117169573903084f, -0.321622252464294f, - 0.116923004388809f, -0.321328520774841f, 0.116676658391953f, -0.321034610271454f, - 0.116430543363094f, -0.320740520954132f, 0.116184651851654f, -0.320446223020554f, - 0.115938983857632f, -0.320151746273041f, 0.115693546831608f, -0.319857090711594f, - 0.115448333323002f, -0.319562226533890f, 0.115203343331814f, -0.319267183542252f, - 0.114958584308624f, -0.318971961736679f, 0.114714048802853f, -0.318676531314850f, - 0.114469736814499f, -0.318380922079086f, 0.114225655794144f, -0.318085134029388f, - 0.113981798291206f, -0.317789167165756f, 0.113738171756268f, -0.317492991685867f, - 0.113494776189327f, -0.317196637392044f, 0.113251596689224f, -0.316900104284287f, - 0.113008655607700f, -0.316603392362595f, 0.112765938043594f, -0.316306471824646f, - 0.112523443996906f, -0.316009372472763f, 0.112281180918217f, -0.315712094306946f, - 0.112039148807526f, -0.315414607524872f, 0.111797347664833f, -0.315116971731186f, - 0.111555770039558f, -0.314819127321243f, 0.111314415931702f, -0.314521104097366f, - 0.111073300242424f, -0.314222872257233f, 0.110832408070564f, -0.313924491405487f, - 0.110591746866703f, -0.313625901937485f, 0.110351309180260f, -0.313327133655548f, - 0.110111102461815f, -0.313028186559677f, 0.109871134161949f, -0.312729060649872f, - 0.109631389379501f, -0.312429755926132f, 0.109391868114471f, -0.312130242586136f, - 0.109152585268021f, -0.311830550432205f, 0.108913525938988f, -0.311530679464340f, - 0.108674705028534f, -0.311230629682541f, 0.108436107635498f, -0.310930401086807f, - 0.108197741210461f, -0.310629993677139f, 0.107959605753422f, -0.310329377651215f, - 0.107721701264381f, -0.310028612613678f, 0.107484027743340f, -0.309727638959885f, - 0.107246585190296f, -0.309426486492157f, 0.107009373605251f, -0.309125155210495f, - 0.106772392988205f, -0.308823645114899f, 0.106535643339157f, -0.308521956205368f, - 0.106299124658108f, -0.308220088481903f, 0.106062836945057f, -0.307918041944504f, - 0.105826787650585f, -0.307615786790848f, 0.105590961873531f, -0.307313382625580f, - 0.105355374515057f, -0.307010769844055f, 0.105120018124580f, -0.306708008050919f, - 0.104884892702103f, -0.306405037641525f, 0.104649998247623f, -0.306101888418198f, - 0.104415334761143f, -0.305798590183258f, 0.104180909693241f, -0.305495083332062f, - 0.103946708142757f, -0.305191397666931f, 0.103712752461433f, -0.304887533187866f, - 0.103479020297527f, -0.304583519697189f, 0.103245526552200f, -0.304279297590256f, - 0.103012263774872f, -0.303974896669388f, 0.102779231965542f, -0.303670316934586f, - 0.102546438574791f, -0.303365558385849f, 0.102313876152039f, -0.303060621023178f, - 0.102081544697285f, -0.302755534648895f, 0.101849451661110f, -0.302450239658356f, - 0.101617597043514f, -0.302144765853882f, 0.101385973393917f, -0.301839113235474f, - 0.101154580712318f, -0.301533311605453f, 0.100923426449299f, -0.301227301359177f, - 0.100692503154278f, -0.300921112298965f, 0.100461818277836f, -0.300614774227142f, - 0.100231364369392f, -0.300308227539063f, 0.100001148879528f, -0.300001531839371f, - 0.099771171808243f, -0.299694657325745f, 0.099541425704956f, -0.299387603998184f, - 0.099311910569668f, -0.299080342054367f, 0.099082641303539f, -0.298772931098938f, - 0.098853603005409f, -0.298465341329575f, 0.098624803125858f, -0.298157602548599f, - 0.098396234214306f, -0.297849655151367f, 0.098167903721333f, -0.297541528940201f, - 0.097939811646938f, -0.297233253717422f, 0.097711957991123f, -0.296924799680710f, - 0.097484335303307f, -0.296616137027740f, 0.097256951034069f, -0.296307325363159f, - 0.097029805183411f, -0.295998334884644f, 0.096802897751331f, -0.295689195394516f, - 0.096576221287251f, -0.295379847288132f, 0.096349790692329f, -0.295070350170136f, - 0.096123591065407f, -0.294760644435883f, 0.095897629857063f, -0.294450789690018f, - 0.095671907067299f, -0.294140785932541f, 0.095446422696114f, -0.293830573558807f, - 0.095221176743507f, -0.293520182371140f, 0.094996169209480f, -0.293209642171860f, - 0.094771400094032f, -0.292898923158646f, 0.094546869397163f, -0.292588025331497f, - 0.094322577118874f, -0.292276978492737f, 0.094098523259163f, -0.291965723037720f, - 0.093874707818031f, -0.291654318571091f, 0.093651130795479f, -0.291342735290527f, - 0.093427792191505f, -0.291031002998352f, 0.093204692006111f, -0.290719062089920f, - 0.092981837689877f, -0.290406972169876f, 0.092759214341640f, -0.290094703435898f, - 0.092536836862564f, -0.289782285690308f, 0.092314697802067f, -0.289469659328461f, - 0.092092797160149f, -0.289156883955002f, 0.091871134936810f, -0.288843959569931f, - 0.091649711132050f, -0.288530826568604f, 0.091428533196449f, -0.288217544555664f, - 0.091207593679428f, -0.287904083728790f, 0.090986892580986f, -0.287590473890305f, - 0.090766437351704f, -0.287276685237885f, 0.090546220541000f, -0.286962717771530f, - 0.090326242148876f, -0.286648571491241f, 0.090106502175331f, -0.286334276199341f, - 0.089887008070946f, -0.286019802093506f, 0.089667752385139f, -0.285705178976059f, - 0.089448742568493f, -0.285390377044678f, 0.089229971170425f, -0.285075396299362f, - 0.089011445641518f, -0.284760266542435f, 0.088793158531189f, -0.284444957971573f, - 0.088575109839439f, -0.284129470586777f, 0.088357307016850f, -0.283813834190369f, - 0.088139742612839f, -0.283498018980026f, 0.087922424077988f, -0.283182054758072f, - 0.087705351412296f, -0.282865911722183f, 0.087488517165184f, -0.282549589872360f, - 0.087271921336651f, -0.282233119010925f, 0.087055571377277f, -0.281916469335556f, - 0.086839467287064f, -0.281599670648575f, 0.086623609066010f, -0.281282693147659f, - 0.086407989263535f, -0.280965566635132f, 0.086192607879639f, -0.280648261308670f, - 0.085977479815483f, -0.280330777168274f, 0.085762590169907f, -0.280013144016266f, - 0.085547938942909f, -0.279695361852646f, 0.085333541035652f, -0.279377400875092f, - 0.085119381546974f, -0.279059261083603f, 0.084905467927456f, -0.278740972280502f, - 0.084691800177097f, -0.278422504663467f, 0.084478378295898f, -0.278103888034821f, - 0.084265194833279f, -0.277785122394562f, 0.084052257239819f, -0.277466177940369f, - 0.083839565515518f, -0.277147054672241f, 0.083627119660378f, -0.276827782392502f, - 0.083414919674397f, -0.276508361101151f, 0.083202958106995f, -0.276188760995865f, - 0.082991249859333f, -0.275868982076645f, 0.082779780030251f, -0.275549083948135f, - 0.082568563520908f, -0.275228977203369f, 0.082357585430145f, -0.274908751249313f, - 0.082146860659122f, -0.274588316679001f, 0.081936374306679f, -0.274267762899399f, - 0.081726133823395f, -0.273947030305862f, 0.081516146659851f, -0.273626148700714f, - 0.081306397914886f, -0.273305088281631f, 0.081096902489662f, -0.272983878850937f, - 0.080887645483017f, -0.272662490606308f, 0.080678641796112f, -0.272340953350067f, - 0.080469883978367f, -0.272019267082214f, 0.080261372029781f, -0.271697402000427f, - 0.080053105950356f, -0.271375387907028f, 0.079845085740089f, -0.271053224802017f, - 0.079637311398983f, -0.270730882883072f, 0.079429790377617f, -0.270408391952515f, - 0.079222507774830f, -0.270085722208023f, 0.079015478491783f, -0.269762933254242f, - 0.078808702528477f, -0.269439965486526f, 0.078602164983749f, -0.269116818904877f, - 0.078395880758762f, -0.268793523311615f, 0.078189842402935f, -0.268470078706741f, - 0.077984049916267f, -0.268146485090256f, 0.077778510749340f, -0.267822742462158f, - 0.077573217451572f, -0.267498821020126f, 0.077368170022964f, -0.267174720764160f, - 0.077163375914097f, -0.266850501298904f, 0.076958827674389f, -0.266526103019714f, - 0.076754532754421f, -0.266201555728912f, 0.076550483703613f, -0.265876859426498f, - 0.076346680521965f, -0.265552014112473f, 0.076143130660057f, -0.265226989984512f, - 0.075939826667309f, -0.264901816844940f, 0.075736775994301f, -0.264576494693756f, - 0.075533971190453f, -0.264250993728638f, 0.075331419706345f, -0.263925373554230f, - 0.075129114091396f, -0.263599574565887f, 0.074927061796188f, -0.263273626565933f, - 0.074725262820721f, -0.262947499752045f, 0.074523709714413f, -0.262621253728867f, - 0.074322402477264f, -0.262294828891754f, 0.074121348559856f, -0.261968284845352f, - 0.073920547962189f, -0.261641561985016f, 0.073720000684261f, -0.261314690113068f, - 0.073519699275494f, -0.260987639427185f, 0.073319651186466f, -0.260660469532013f, - 0.073119848966599f, -0.260333120822906f, 0.072920300066471f, -0.260005623102188f, - 0.072721004486084f, -0.259678006172180f, 0.072521962225437f, -0.259350210428238f, - 0.072323165833950f, -0.259022265672684f, 0.072124622762203f, -0.258694142103195f, - 0.071926333010197f, -0.258365899324417f, 0.071728296577930f, -0.258037507534027f, - 0.071530513465405f, -0.257708936929703f, 0.071332976222038f, -0.257380217313766f, - 0.071135692298412f, -0.257051378488541f, 0.070938661694527f, -0.256722360849380f, - 0.070741884410381f, -0.256393194198608f, 0.070545360445976f, -0.256063878536224f, - 0.070349089801311f, -0.255734413862228f, 0.070153072476387f, -0.255404800176620f, - 0.069957308471203f, -0.255075037479401f, 0.069761790335178f, -0.254745125770569f, - 0.069566532969475f, -0.254415065050125f, 0.069371521472931f, -0.254084855318069f, - 0.069176770746708f, -0.253754496574402f, 0.068982265889645f, -0.253423988819122f, - 0.068788021802902f, -0.253093332052231f, 0.068594031035900f, -0.252762526273727f, - 0.068400286138058f, -0.252431541681290f, 0.068206802010536f, -0.252100437879562f, - 0.068013571202755f, -0.251769185066223f, 0.067820593714714f, -0.251437783241272f, - 0.067627869546413f, -0.251106232404709f, 0.067435398697853f, -0.250774532556534f, - 0.067243188619614f, -0.250442683696747f, 0.067051224410534f, -0.250110685825348f, - 0.066859520971775f, -0.249778553843498f, 0.066668070852757f, -0.249446272850037f, - 0.066476874053478f, -0.249113827943802f, 0.066285938024521f, -0.248781248927116f, - 0.066095255315304f, -0.248448520898819f, 0.065904818475246f, -0.248115643858910f, - 0.065714649856091f, -0.247782632708550f, 0.065524727106094f, -0.247449472546577f, - 0.065335065126419f, -0.247116148471832f, 0.065145656466484f, -0.246782705187798f, - 0.064956501126289f, -0.246449097990990f, 0.064767606556416f, -0.246115356683731f, - 0.064578965306282f, -0.245781451463699f, 0.064390584826469f, -0.245447427034378f, - 0.064202457666397f, -0.245113238692284f, 0.064014583826065f, -0.244778916239738f, - 0.063826970756054f, -0.244444444775581f, 0.063639611005783f, -0.244109839200974f, - 0.063452512025833f, -0.243775084614754f, 0.063265666365623f, -0.243440181016922f, - 0.063079081475735f, -0.243105143308640f, 0.062892749905586f, -0.242769956588745f, - 0.062706671655178f, -0.242434620857239f, 0.062520854175091f, -0.242099151015282f, - 0.062335297465324f, -0.241763532161713f, 0.062149997800589f, -0.241427779197693f, - 0.061964951455593f, -0.241091892123222f, 0.061780165880919f, -0.240755841135979f, - 0.061595637351274f, -0.240419670939446f, 0.061411365866661f, -0.240083336830139f, - 0.061227355152369f, -0.239746883511543f, 0.061043601483107f, -0.239410281181335f, - 0.060860104858875f, -0.239073529839516f, 0.060676865279675f, -0.238736644387245f, - 0.060493886470795f, -0.238399609923363f, 0.060311164706945f, -0.238062441349030f, - 0.060128703713417f, -0.237725138664246f, 0.059946499764919f, -0.237387686967850f, - 0.059764556586742f, -0.237050101161003f, 0.059582870453596f, -0.236712381243706f, - 0.059401445090771f, -0.236374512314796f, 0.059220276772976f, -0.236036509275436f, - 0.059039369225502f, -0.235698372125626f, 0.058858718723059f, -0.235360085964203f, - 0.058678328990936f, -0.235021665692329f, 0.058498200029135f, -0.234683111310005f, - 0.058318331837654f, -0.234344407916069f, 0.058138720691204f, -0.234005570411682f, - 0.057959370315075f, -0.233666598796844f, 0.057780280709267f, -0.233327493071556f, - 0.057601451873779f, -0.232988253235817f, 0.057422880083323f, -0.232648864388466f, - 0.057244572788477f, -0.232309341430664f, 0.057066522538662f, -0.231969684362412f, - 0.056888736784458f, -0.231629893183708f, 0.056711208075285f, -0.231289967894554f, - 0.056533940136433f, -0.230949893593788f, 0.056356932967901f, -0.230609700083733f, - 0.056180190294981f, -0.230269357562065f, 0.056003704667091f, -0.229928880929947f, - 0.055827483534813f, -0.229588270187378f, 0.055651523172855f, -0.229247525334358f, - 0.055475823581219f, -0.228906646370888f, 0.055300384759903f, -0.228565633296967f, - 0.055125206708908f, -0.228224486112595f, 0.054950293153524f, -0.227883204817772f, - 0.054775636643171f, -0.227541789412498f, 0.054601248353720f, -0.227200239896774f, - 0.054427117109299f, -0.226858556270599f, 0.054253250360489f, -0.226516738533974f, - 0.054079644382000f, -0.226174786686897f, 0.053906302899122f, -0.225832715630531f, - 0.053733222186565f, -0.225490495562553f, 0.053560405969620f, -0.225148141384125f, - 0.053387850522995f, -0.224805667996407f, 0.053215555846691f, -0.224463045597076f, - 0.053043525665998f, -0.224120303988457f, 0.052871759980917f, -0.223777428269386f, - 0.052700258791447f, -0.223434418439865f, 0.052529018372297f, -0.223091274499893f, - 0.052358038723469f, -0.222748011350632f, 0.052187327295542f, -0.222404599189758f, - 0.052016876637936f, -0.222061067819595f, 0.051846686750650f, -0.221717402338982f, - 0.051676765084267f, -0.221373617649078f, 0.051507104188204f, -0.221029683947563f, - 0.051337707787752f, -0.220685631036758f, 0.051168579608202f, -0.220341444015503f, - 0.050999708473682f, -0.219997137784958f, 0.050831105560064f, -0.219652697443962f, - 0.050662767142057f, -0.219308122992516f, 0.050494693219662f, -0.218963414430618f, - 0.050326880067587f, -0.218618586659431f, 0.050159335136414f, -0.218273624777794f, - 0.049992054700851f, -0.217928543686867f, 0.049825038760900f, -0.217583328485489f, - 0.049658283591270f, -0.217237979173660f, 0.049491796642542f, -0.216892510652542f, - 0.049325577914715f, -0.216546908020973f, 0.049159619957209f, -0.216201186180115f, - 0.048993926495314f, -0.215855330228806f, 0.048828501254320f, -0.215509355068207f, - 0.048663340508938f, -0.215163245797157f, 0.048498444259167f, -0.214817002415657f, - 0.048333816230297f, -0.214470639824867f, 0.048169452697039f, -0.214124158024788f, - 0.048005353659391f, -0.213777542114258f, 0.047841522842646f, -0.213430806994438f, - 0.047677956521511f, -0.213083937764168f, 0.047514654695988f, -0.212736949324608f, - 0.047351621091366f, -0.212389841675758f, 0.047188851982355f, -0.212042599916458f, - 0.047026351094246f, -0.211695238947868f, 0.046864114701748f, -0.211347743868828f, - 0.046702146530151f, -0.211000129580498f, 0.046540446579456f, -0.210652396082878f, - 0.046379011124372f, -0.210304543375969f, 0.046217843890190f, -0.209956556558609f, - 0.046056941151619f, -0.209608450531960f, 0.045896306633949f, -0.209260210394859f, - 0.045735940337181f, -0.208911851048470f, 0.045575842261314f, -0.208563387393951f, - 0.045416008681059f, -0.208214774727821f, 0.045256443321705f, -0.207866057753563f, - 0.045097146183252f, -0.207517206668854f, 0.044938117265701f, -0.207168251276016f, - 0.044779352843761f, -0.206819161772728f, 0.044620860368013f, -0.206469938158989f, - 0.044462632387877f, -0.206120610237122f, 0.044304672628641f, -0.205771163105965f, - 0.044146984815598f, -0.205421581864357f, 0.043989561498165f, -0.205071896314621f, - 0.043832406401634f, -0.204722076654434f, 0.043675523251295f, -0.204372137784958f, - 0.043518904596567f, -0.204022079706192f, 0.043362557888031f, -0.203671902418137f, - 0.043206475675106f, -0.203321605920792f, 0.043050665408373f, -0.202971190214157f, - 0.042895123362541f, -0.202620655298233f, 0.042739849537611f, -0.202270001173019f, - 0.042584843933582f, -0.201919227838516f, 0.042430106550455f, -0.201568335294724f, - 0.042275641113520f, -0.201217323541641f, 0.042121443897486f, -0.200866192579269f, - 0.041967518627644f, -0.200514942407608f, 0.041813857853413f, -0.200163587927818f, - 0.041660469025373f, -0.199812099337578f, 0.041507352143526f, -0.199460506439209f, - 0.041354499757290f, -0.199108779430389f, 0.041201923042536f, -0.198756948113441f, - 0.041049610823393f, -0.198404997587204f, 0.040897574275732f, -0.198052927851677f, - 0.040745802223682f, -0.197700738906860f, 0.040594302117825f, -0.197348430752754f, - 0.040443073958158f, -0.196996018290520f, 0.040292114019394f, -0.196643486618996f, - 0.040141426026821f, -0.196290835738182f, 0.039991009980440f, -0.195938065648079f, - 0.039840862154961f, -0.195585191249847f, 0.039690986275673f, -0.195232197642326f, - 0.039541378617287f, -0.194879084825516f, 0.039392042905092f, -0.194525867700577f, - 0.039242979139090f, -0.194172516465187f, 0.039094187319279f, -0.193819075822830f, - 0.038945667445660f, -0.193465501070023f, 0.038797415792942f, -0.193111822009087f, - 0.038649436086416f, -0.192758023738861f, 0.038501728326082f, -0.192404121160507f, - 0.038354292511940f, -0.192050099372864f, 0.038207128643990f, -0.191695958375931f, - 0.038060232996941f, -0.191341713070869f, 0.037913613021374f, -0.190987363457680f, - 0.037767261266708f, -0.190632879734039f, 0.037621185183525f, -0.190278306603432f, - 0.037475381046534f, -0.189923599362373f, 0.037329845130444f, -0.189568802714348f, - 0.037184584885836f, -0.189213871955872f, 0.037039596587420f, -0.188858851790428f, - 0.036894880235195f, -0.188503712415695f, 0.036750435829163f, -0.188148453831673f, - 0.036606263369322f, -0.187793090939522f, 0.036462362855673f, -0.187437608838081f, - 0.036318738013506f, -0.187082037329674f, 0.036175385117531f, -0.186726331710815f, - 0.036032304167747f, -0.186370536684990f, 0.035889495164156f, -0.186014622449875f, - 0.035746958106756f, -0.185658603906631f, 0.035604696720839f, -0.185302466154099f, - 0.035462711006403f, -0.184946224093437f, 0.035320993512869f, -0.184589877724648f, - 0.035179551690817f, -0.184233412146568f, 0.035038381814957f, -0.183876842260361f, - 0.034897487610579f, -0.183520168066025f, 0.034756865352392f, -0.183163389563560f, - 0.034616518765688f, -0.182806491851807f, 0.034476444125175f, -0.182449504733086f, - 0.034336645156145f, -0.182092398405075f, 0.034197118133307f, -0.181735187768936f, - 0.034057866781950f, -0.181377857923508f, 0.033918887376785f, -0.181020438671112f, - 0.033780183643103f, -0.180662900209427f, 0.033641755580902f, -0.180305257439613f, - 0.033503599464893f, -0.179947525262833f, 0.033365719020367f, -0.179589673876762f, - 0.033228114247322f, -0.179231703281403f, 0.033090781420469f, -0.178873643279076f, - 0.032953724265099f, -0.178515478968620f, 0.032816942781210f, -0.178157210350037f, - 0.032680433243513f, -0.177798837423325f, 0.032544203102589f, -0.177440345287323f, - 0.032408244907856f, -0.177081763744354f, 0.032272562384605f, -0.176723077893257f, - 0.032137155532837f, -0.176364272832870f, 0.032002024352551f, -0.176005378365517f, - 0.031867165118456f, -0.175646379590034f, 0.031732585281134f, -0.175287276506424f, - 0.031598277390003f, -0.174928069114685f, 0.031464248895645f, -0.174568757414818f, - 0.031330492347479f, -0.174209341406822f, 0.031197015196085f, -0.173849821090698f, - 0.031063811853528f, -0.173490211367607f, 0.030930884182453f, -0.173130482435226f, - 0.030798232182860f, -0.172770664095879f, 0.030665857717395f, -0.172410741448402f, - 0.030533758923411f, -0.172050714492798f, 0.030401935800910f, -0.171690583229065f, - 0.030270388349891f, -0.171330362558365f, 0.030139118432999f, -0.170970037579536f, - 0.030008124187589f, -0.170609608292580f, 0.029877405613661f, -0.170249074697495f, - 0.029746964573860f, -0.169888436794281f, 0.029616801068187f, -0.169527709484100f, - 0.029486913233995f, -0.169166877865791f, 0.029357301071286f, -0.168805956840515f, - 0.029227968305349f, -0.168444931507111f, 0.029098909348249f, -0.168083801865578f, - 0.028970129787922f, -0.167722567915916f, 0.028841627761722f, -0.167361244559288f, - 0.028713401407003f, -0.166999831795692f, 0.028585452586412f, -0.166638299822807f, - 0.028457781299949f, -0.166276678442955f, 0.028330387547612f, -0.165914967656136f, - 0.028203271329403f, -0.165553152561188f, 0.028076432645321f, -0.165191248059273f, - 0.027949871495366f, -0.164829224348068f, 0.027823587879539f, -0.164467126131058f, - 0.027697581797838f, -0.164104923605919f, 0.027571853250265f, -0.163742616772652f, - 0.027446404099464f, -0.163380220532417f, 0.027321230620146f, -0.163017734885216f, - 0.027196336537600f, -0.162655144929886f, 0.027071721851826f, -0.162292465567589f, - 0.026947384700179f, -0.161929681897163f, 0.026823325082660f, -0.161566808819771f, - 0.026699542999268f, -0.161203846335411f, 0.026576040312648f, -0.160840779542923f, - 0.026452817022800f, -0.160477623343468f, 0.026329871267080f, -0.160114362835884f, - 0.026207204908133f, -0.159751012921333f, 0.026084816083312f, -0.159387573599815f, - 0.025962706655264f, -0.159024044871330f, 0.025840876623988f, -0.158660411834717f, - 0.025719324126840f, -0.158296689391136f, 0.025598052889109f, -0.157932877540588f, - 0.025477059185505f, -0.157568961381912f, 0.025356344878674f, -0.157204970717430f, - 0.025235909968615f, -0.156840875744820f, 0.025115754455328f, -0.156476691365242f, - 0.024995878338814f, -0.156112402677536f, 0.024876279756427f, -0.155748039484024f, - 0.024756962433457f, -0.155383571982384f, 0.024637924507260f, -0.155019029974937f, - 0.024519165977836f, -0.154654383659363f, 0.024400688707829f, -0.154289647936821f, - 0.024282488971949f, -0.153924822807312f, 0.024164570495486f, -0.153559908270836f, - 0.024046931415796f, -0.153194904327393f, 0.023929571732879f, -0.152829796075821f, - 0.023812493309379f, -0.152464613318443f, 0.023695694282651f, -0.152099341154099f, - 0.023579176515341f, -0.151733979582787f, 0.023462938144803f, -0.151368513703346f, - 0.023346979171038f, -0.151002973318100f, 0.023231301456690f, -0.150637343525887f, - 0.023115905001760f, -0.150271624326706f, 0.023000787943602f, -0.149905815720558f, - 0.022885952144861f, -0.149539917707443f, 0.022771397605538f, -0.149173930287361f, - 0.022657122462988f, -0.148807853460312f, 0.022543128579855f, -0.148441687226295f, - 0.022429415956140f, -0.148075446486473f, 0.022315984591842f, -0.147709101438522f, - 0.022202832624316f, -0.147342681884766f, 0.022089963778853f, -0.146976172924042f, - 0.021977374330163f, -0.146609574556351f, 0.021865066140890f, -0.146242901682854f, - 0.021753041073680f, -0.145876124501228f, 0.021641295403242f, -0.145509272813797f, - 0.021529832854867f, -0.145142331719399f, 0.021418649703264f, -0.144775316119194f, - 0.021307749673724f, -0.144408211112022f, 0.021197130903602f, -0.144041016697884f, - 0.021086793392897f, -0.143673732876778f, 0.020976737141609f, -0.143306359648705f, - 0.020866964012384f, -0.142938911914825f, 0.020757472142577f, -0.142571389675140f, - 0.020648263394833f, -0.142203763127327f, 0.020539334043860f, -0.141836062073708f, - 0.020430689677596f, -0.141468286514282f, 0.020322324708104f, -0.141100421547890f, - 0.020214242860675f, -0.140732467174530f, 0.020106444135308f, -0.140364438295364f, - 0.019998926669359f, -0.139996320009232f, 0.019891692325473f, -0.139628127217293f, - 0.019784741103649f, -0.139259845018387f, 0.019678071141243f, -0.138891488313675f, - 0.019571684300900f, -0.138523042201996f, 0.019465578719974f, -0.138154521584511f, - 0.019359756261110f, -0.137785911560059f, 0.019254218786955f, -0.137417227029800f, - 0.019148962572217f, -0.137048453092575f, 0.019043987616897f, -0.136679604649544f, - 0.018939297646284f, -0.136310681700706f, 0.018834890797734f, -0.135941669344902f, - 0.018730765208602f, -0.135572582483292f, 0.018626924604177f, -0.135203406214714f, - 0.018523367121816f, -0.134834155440331f, 0.018420090898871f, -0.134464830160141f, - 0.018317099660635f, -0.134095430374146f, 0.018214391544461f, -0.133725941181183f, - 0.018111966550350f, -0.133356377482414f, 0.018009826540947f, -0.132986739277840f, - 0.017907967790961f, -0.132617011666298f, 0.017806394025683f, -0.132247209548950f, - 0.017705103382468f, -0.131877332925797f, 0.017604095861316f, -0.131507381796837f, - 0.017503373324871f, -0.131137356162071f, 0.017402933910489f, -0.130767241120338f, - 0.017302779480815f, -0.130397051572800f, 0.017202908173203f, -0.130026802420616f, - 0.017103319987655f, -0.129656463861465f, 0.017004016786814f, -0.129286035895348f, - 0.016904998570681f, -0.128915548324585f, 0.016806263476610f, -0.128544986248016f, - 0.016707813367248f, -0.128174334764481f, 0.016609646379948f, -0.127803623676300f, - 0.016511764377356f, -0.127432823181152f, 0.016414167359471f, -0.127061963081360f, - 0.016316853463650f, -0.126691013574600f, 0.016219824552536f, -0.126320004463196f, - 0.016123080626130f, -0.125948905944824f, 0.016026621684432f, -0.125577747821808f, - 0.015930447727442f, -0.125206500291824f, 0.015834558755159f, -0.124835193157196f, - 0.015738952904940f, -0.124463804066181f, 0.015643632039428f, -0.124092340469360f, - 0.015548598021269f, -0.123720809817314f, 0.015453847125173f, -0.123349204659462f, - 0.015359382145107f, -0.122977524995804f, 0.015265202149749f, -0.122605770826340f, - 0.015171307139099f, -0.122233949601650f, 0.015077698044479f, -0.121862053871155f, - 0.014984373003244f, -0.121490091085434f, 0.014891333878040f, -0.121118053793907f, - 0.014798580668867f, -0.120745941996574f, 0.014706112444401f, -0.120373763144016f, - 0.014613929204643f, -0.120001509785652f, 0.014522032812238f, -0.119629189372063f, - 0.014430420473218f, -0.119256794452667f, 0.014339094981551f, -0.118884332478046f, - 0.014248054474592f, -0.118511803448200f, 0.014157299883664f, -0.118139199912548f, - 0.014066831208766f, -0.117766529321671f, 0.013976648449898f, -0.117393791675568f, - 0.013886751607060f, -0.117020979523659f, 0.013797140680254f, -0.116648100316525f, - 0.013707815669477f, -0.116275154054165f, 0.013618776574731f, -0.115902140736580f, - 0.013530024327338f, -0.115529052913189f, 0.013441557064652f, -0.115155905485153f, - 0.013353376649320f, -0.114782683551311f, 0.013265483081341f, -0.114409394562244f, - 0.013177875429392f, -0.114036038517952f, 0.013090553693473f, -0.113662622869015f, - 0.013003518804908f, -0.113289132714272f, 0.012916770763695f, -0.112915575504303f, - 0.012830308638513f, -0.112541958689690f, 0.012744133360684f, -0.112168267369270f, - 0.012658244930208f, -0.111794516444206f, 0.012572642415762f, -0.111420698463917f, - 0.012487327679992f, -0.111046813428402f, 0.012402298860252f, -0.110672861337662f, - 0.012317557819188f, -0.110298842191696f, 0.012233102694154f, -0.109924763441086f, - 0.012148935347795f, -0.109550617635250f, 0.012065053917468f, -0.109176412224770f, - 0.011981460265815f, -0.108802139759064f, 0.011898153461516f, -0.108427800238132f, - 0.011815134435892f, -0.108053401112556f, 0.011732402257621f, -0.107678934931755f, - 0.011649956926703f, -0.107304409146309f, 0.011567799374461f, -0.106929816305637f, - 0.011485928669572f, -0.106555156409740f, 0.011404345743358f, -0.106180444359779f, - 0.011323049664497f, -0.105805665254593f, 0.011242041364312f, -0.105430819094181f, - 0.011161320842803f, -0.105055920779705f, 0.011080888099968f, -0.104680955410004f, - 0.011000742204487f, -0.104305922985077f, 0.010920885019004f, -0.103930838406086f, - 0.010841314680874f, -0.103555686771870f, 0.010762032121420f, -0.103180475533009f, - 0.010683037340641f, -0.102805204689503f, 0.010604331269860f, -0.102429874241352f, - 0.010525912046432f, -0.102054484188557f, 0.010447781533003f, -0.101679034531116f, - 0.010369938798249f, -0.101303517818451f, 0.010292383842170f, -0.100927948951721f, - 0.010215117596090f, -0.100552320480347f, 0.010138138197362f, -0.100176624953747f, - 0.010061448439956f, -0.099800877273083f, 0.009985045529902f, -0.099425069987774f, - 0.009908932261169f, -0.099049203097820f, 0.009833106771111f, -0.098673284053802f, - 0.009757569059730f, -0.098297297954559f, 0.009682320058346f, -0.097921259701252f, - 0.009607359766960f, -0.097545161843300f, 0.009532688185573f, -0.097169004380703f, - 0.009458304382861f, -0.096792794764042f, 0.009384209290147f, -0.096416525542736f, - 0.009310402907431f, -0.096040196716785f, 0.009236886166036f, -0.095663815736771f, - 0.009163657203317f, -0.095287375152111f, 0.009090716950595f, -0.094910882413387f, - 0.009018065407872f, -0.094534330070019f, 0.008945702575147f, -0.094157725572586f, - 0.008873629383743f, -0.093781061470509f, 0.008801844902337f, -0.093404345214367f, - 0.008730349130929f, -0.093027576804161f, 0.008659142069519f, -0.092650748789310f, - 0.008588224649429f, -0.092273868620396f, 0.008517595939338f, -0.091896936297417f, - 0.008447255939245f, -0.091519944369793f, 0.008377205580473f, -0.091142900288105f, - 0.008307444863021f, -0.090765804052353f, 0.008237972855568f, -0.090388655662537f, - 0.008168790489435f, -0.090011447668076f, 0.008099896833301f, -0.089634194970131f, - 0.008031292818487f, -0.089256882667542f, 0.007962978444993f, -0.088879525661469f, - 0.007894953712821f, -0.088502109050751f, 0.007827218621969f, -0.088124647736549f, - 0.007759772241116f, -0.087747126817703f, 0.007692615967244f, -0.087369553744793f, - 0.007625748869032f, -0.086991935968399f, 0.007559171877801f, -0.086614266037941f, - 0.007492884527892f, -0.086236543953419f, 0.007426886819303f, -0.085858769714832f, - 0.007361178752035f, -0.085480943322182f, 0.007295760791749f, -0.085103072226048f, - 0.007230632472783f, -0.084725148975849f, 0.007165793795139f, -0.084347173571587f, - 0.007101245224476f, -0.083969146013260f, 0.007036986760795f, -0.083591073751450f, - 0.006973018404096f, -0.083212949335575f, 0.006909339688718f, -0.082834780216217f, - 0.006845951545984f, -0.082456558942795f, 0.006782853044569f, -0.082078292965889f, - 0.006720044650137f, -0.081699974834919f, 0.006657526828349f, -0.081321612000465f, - 0.006595299113542f, -0.080943197011948f, 0.006533361505717f, -0.080564737319946f, - 0.006471714470536f, -0.080186225473881f, 0.006410357542336f, -0.079807676374912f, - 0.006349290721118f, -0.079429075121880f, 0.006288514938205f, -0.079050421714783f, - 0.006228029262275f, -0.078671731054783f, 0.006167833693326f, -0.078292988240719f, - 0.006107929162681f, -0.077914200723171f, 0.006048315204680f, -0.077535368502140f, - 0.005988991353661f, -0.077156484127045f, 0.005929958540946f, -0.076777562499046f, - 0.005871216300875f, -0.076398596167564f, 0.005812764633447f, -0.076019577682018f, - 0.005754603538662f, -0.075640521943569f, 0.005696733482182f, -0.075261414051056f, - 0.005639153998345f, -0.074882268905640f, 0.005581865552813f, -0.074503071606159f, - 0.005524867679924f, -0.074123837053776f, 0.005468160845339f, -0.073744557797909f, - 0.005411745049059f, -0.073365233838558f, 0.005355620291084f, -0.072985872626305f, - 0.005299786105752f, -0.072606459259987f, 0.005244242958724f, -0.072227008640766f, - 0.005188991315663f, -0.071847513318062f, 0.005134030245245f, -0.071467980742455f, - 0.005079360678792f, -0.071088403463364f, 0.005024982150644f, -0.070708781480789f, - 0.004970894660801f, -0.070329122245312f, 0.004917098674923f, -0.069949418306351f, - 0.004863593727350f, -0.069569669663906f, 0.004810380283743f, -0.069189883768559f, - 0.004757457878441f, -0.068810060620308f, 0.004704826977104f, -0.068430192768574f, - 0.004652487114072f, -0.068050287663937f, 0.004600439220667f, -0.067670337855816f, - 0.004548682365566f, -0.067290350794792f, 0.004497217014432f, -0.066910326480865f, - 0.004446043167263f, -0.066530264914036f, 0.004395160824060f, -0.066150158643723f, - 0.004344569984823f, -0.065770015120506f, 0.004294271115214f, -0.065389834344387f, - 0.004244263283908f, -0.065009608864784f, 0.004194547422230f, -0.064629353582859f, - 0.004145123064518f, -0.064249053597450f, 0.004095990676433f, -0.063868723809719f, - 0.004047149792314f, -0.063488349318504f, 0.003998600877821f, -0.063107937574387f, - 0.003950343467295f, -0.062727488577366f, 0.003902378026396f, -0.062347009778023f, - 0.003854704322293f, -0.061966486275196f, 0.003807322587818f, -0.061585929244757f, - 0.003760232590139f, -0.061205338686705f, 0.003713434794918f, -0.060824707150459f, - 0.003666928736493f, -0.060444042086601f, 0.003620714880526f, -0.060063343495131f, - 0.003574792761356f, -0.059682607650757f, 0.003529162844643f, -0.059301838278770f, - 0.003483824897557f, -0.058921031653881f, 0.003438779152930f, -0.058540191501379f, - 0.003394025377929f, -0.058159314095974f, 0.003349563805386f, -0.057778406888247f, - 0.003305394435301f, -0.057397462427616f, 0.003261517267674f, -0.057016488164663f, - 0.003217932302505f, -0.056635476648808f, 0.003174639539793f, -0.056254431605339f, - 0.003131638979539f, -0.055873356759548f, 0.003088930854574f, -0.055492244660854f, - 0.003046514932066f, -0.055111102759838f, 0.003004391444847f, -0.054729927331209f, - 0.002962560392916f, -0.054348722100258f, 0.002921021543443f, -0.053967483341694f, - 0.002879775362089f, -0.053586211055517f, 0.002838821383193f, -0.053204908967018f, - 0.002798160072416f, -0.052823577076197f, 0.002757790964097f, -0.052442211657763f, - 0.002717714523897f, -0.052060816437006f, 0.002677930751815f, -0.051679391413927f, - 0.002638439415023f, -0.051297932863235f, 0.002599240746349f, -0.050916448235512f, - 0.002560334512964f, -0.050534930080175f, 0.002521721180528f, -0.050153385847807f, - 0.002483400283381f, -0.049771808087826f, 0.002445372054353f, -0.049390204250813f, - 0.002407636726275f, -0.049008570611477f, 0.002370193833485f, -0.048626907169819f, - 0.002333043841645f, -0.048245213925838f, 0.002296186750755f, -0.047863494604826f, - 0.002259622327983f, -0.047481749206781f, 0.002223350573331f, -0.047099970281124f, - 0.002187371719629f, -0.046718169003725f, 0.002151685766876f, -0.046336337924004f, - 0.002116292715073f, -0.045954477041960f, 0.002081192564219f, -0.045572593808174f, - 0.002046385314316f, -0.045190680772066f, 0.002011870965362f, -0.044808741658926f, - 0.001977649517357f, -0.044426776468754f, 0.001943721086718f, -0.044044785201550f, - 0.001910085673444f, -0.043662767857313f, 0.001876743277535f, -0.043280724436045f, - 0.001843693898991f, -0.042898654937744f, 0.001810937537812f, -0.042516563087702f, - 0.001778474310413f, -0.042134445160627f, 0.001746304216795f, -0.041752301156521f, - 0.001714427140541f, -0.041370131075382f, 0.001682843198068f, -0.040987938642502f, - 0.001651552389376f, -0.040605723857880f, 0.001620554830879f, -0.040223482996225f, - 0.001589850406162f, -0.039841219782829f, 0.001559439115226f, -0.039458930492401f, - 0.001529321074486f, -0.039076622575521f, 0.001499496400356f, -0.038694288581610f, - 0.001469964860007f, -0.038311932235956f, 0.001440726569854f, -0.037929553538561f, - 0.001411781646311f, -0.037547148764133f, 0.001383129972965f, -0.037164725363255f, - 0.001354771666229f, -0.036782283335924f, 0.001326706726104f, -0.036399815231562f, - 0.001298935036175f, -0.036017324775457f, 0.001271456829272f, -0.035634815692902f, - 0.001244271872565f, -0.035252287983894f, 0.001217380515300f, -0.034869734197855f, - 0.001190782408230f, -0.034487165510654f, 0.001164477784187f, -0.034104570746422f, - 0.001138466643170f, -0.033721961081028f, 0.001112748985179f, -0.033339329063892f, - 0.001087324810214f, -0.032956674695015f, 0.001062194118276f, -0.032574005424976f, - 0.001037356909364f, -0.032191313803196f, 0.001012813183479f, -0.031808607280254f, - 0.000988563057035f, -0.031425878405571f, 0.000964606530033f, -0.031043132767081f, - 0.000940943544265f, -0.030660368502140f, 0.000917574157938f, -0.030277585610747f, - 0.000894498312846f, -0.029894785955548f, 0.000871716125403f, -0.029511967673898f, - 0.000849227537401f, -0.029129132628441f, 0.000827032607049f, -0.028746278956532f, - 0.000805131276138f, -0.028363410383463f, 0.000783523661084f, -0.027980525046587f, - 0.000762209703680f, -0.027597622945905f, 0.000741189462133f, -0.027214704081416f, - 0.000720462878235f, -0.026831768453121f, 0.000700030010194f, -0.026448817923665f, - 0.000679890916217f, -0.026065852493048f, 0.000660045538098f, -0.025682870298624f, - 0.000640493875835f, -0.025299875065684f, 0.000621235987637f, -0.024916863068938f, - 0.000602271873504f, -0.024533838033676f, 0.000583601591643f, -0.024150796234608f, - 0.000565225025639f, -0.023767741397023f, 0.000547142291907f, -0.023384673520923f, - 0.000529353390448f, -0.023001590743661f, 0.000511858321261f, -0.022618494927883f, - 0.000494657084346f, -0.022235386073589f, 0.000477749679703f, -0.021852264180779f, - 0.000461136136437f, -0.021469129249454f, 0.000444816454547f, -0.021085981279612f, - 0.000428790634032f, -0.020702820271254f, 0.000413058703998f, -0.020319648087025f, - 0.000397620693548f, -0.019936462864280f, 0.000382476573577f, -0.019553268328309f, - 0.000367626344087f, -0.019170060753822f, 0.000353070063284f, -0.018786842003465f, - 0.000338807702065f, -0.018403612077236f, 0.000324839289533f, -0.018020370975137f, - 0.000311164796585f, -0.017637118697166f, 0.000297784281429f, -0.017253857105970f, - 0.000284697714960f, -0.016870586201549f, 0.000271905126283f, -0.016487304121256f, - 0.000259406515397f, -0.016104012727737f, 0.000247201882303f, -0.015720712020993f, - 0.000235291256104f, -0.015337402001023f, 0.000223674607696f, -0.014954082667828f, - 0.000212351980736f, -0.014570754021406f, 0.000201323360670f, -0.014187417924404f, - 0.000190588747500f, -0.013804072514176f, 0.000180148170330f, -0.013420719653368f, - 0.000170001629158f, -0.013037359341979f, 0.000160149123985f, -0.012653990648687f, - 0.000150590654812f, -0.012270614504814f, 0.000141326236189f, -0.011887230910361f, - 0.000132355868118f, -0.011503840796649f, 0.000123679565149f, -0.011120444163680f, - 0.000115297327284f, -0.010737040080130f, 0.000107209154521f, -0.010353630408645f, - 0.000099415054137f, -0.009970214217901f, 0.000091915040684f, -0.009586792439222f, - 0.000084709099610f, -0.009203365072608f, 0.000077797252743f, -0.008819932118058f, - 0.000071179500083f, -0.008436493575573f, 0.000064855834353f, -0.008053051307797f, - 0.000058826273744f, -0.007669602986425f, 0.000053090810979f, -0.007286150939763f, - 0.000047649456974f, -0.006902694236487f, 0.000042502211727f, -0.006519233807921f, - 0.000037649078877f, -0.006135769188404f, 0.000033090062061f, -0.005752300843596f, - 0.000028825161280f, -0.005368829704821f, 0.000024854381991f, -0.004985354840755f, - 0.000021177724193f, -0.004601877182722f, 0.000017795191525f, -0.004218397196382f, - 0.000014706784896f, -0.003834914416075f, 0.000011912506125f, -0.003451429307461f, - 0.000009412358850f, -0.003067942336202f, 0.000007206342616f, -0.002684453502297f, - 0.000005294459243f, -0.002300963038579f, 0.000003676709639f, -0.001917471294291f, - 0.000002353095169f, -0.001533978385851f, 0.000001323616516f, -0.001150484546088f, - 0.000000588274133f, -0.000766990066040f, 0.000000147068562f, -0.000383495149435f, - 0.000000000000000f, -0.000000000000023f, 0.000000147068562f, 0.000383495149435f, - 0.000000588274133f, 0.000766990066040f, 0.000001323616516f, 0.001150484546088f, - 0.000002353095169f, 0.001533978385851f, 0.000003676709639f, 0.001917471294291f, - 0.000005294459243f, 0.002300963038579f, 0.000007206342616f, 0.002684453502297f, - 0.000009412358850f, 0.003067942336202f, 0.000011912506125f, 0.003451429307461f, - 0.000014706784896f, 0.003834914416075f, 0.000017795191525f, 0.004218397196382f, - 0.000021177724193f, 0.004601877182722f, 0.000024854381991f, 0.004985354840755f, - 0.000028825161280f, 0.005368829704821f, 0.000033090062061f, 0.005752300843596f, - 0.000037649078877f, 0.006135769188404f, 0.000042502211727f, 0.006519233807921f, - 0.000047649456974f, 0.006902694236487f, 0.000053090810979f, 0.007286150939763f, - 0.000058826273744f, 0.007669602986425f, 0.000064855834353f, 0.008053051307797f, - 0.000071179500083f, 0.008436493575573f, 0.000077797252743f, 0.008819932118058f, - 0.000084709099610f, 0.009203365072608f, 0.000091915040684f, 0.009586792439222f, - 0.000099415054137f, 0.009970214217901f, 0.000107209154521f, 0.010353630408645f, - 0.000115297327284f, 0.010737040080130f, 0.000123679565149f, 0.011120444163680f, - 0.000132355868118f, 0.011503840796649f, 0.000141326236189f, 0.011887230910361f, - 0.000150590654812f, 0.012270614504814f, 0.000160149123985f, 0.012653990648687f, - 0.000170001629158f, 0.013037359341979f, 0.000180148170330f, 0.013420719653368f, - 0.000190588747500f, 0.013804072514176f, 0.000201323360670f, 0.014187417924404f, - 0.000212351980736f, 0.014570754021406f, 0.000223674607696f, 0.014954082667828f, - 0.000235291256104f, 0.015337402001023f, 0.000247201882303f, 0.015720712020993f, - 0.000259406515397f, 0.016104012727737f, 0.000271905126283f, 0.016487304121256f, - 0.000284697714960f, 0.016870586201549f, 0.000297784281429f, 0.017253857105970f, - 0.000311164796585f, 0.017637118697166f, 0.000324839289533f, 0.018020370975137f, - 0.000338807702065f, 0.018403612077236f, 0.000353070063284f, 0.018786842003465f, - 0.000367626344087f, 0.019170060753822f, 0.000382476573577f, 0.019553268328309f, - 0.000397620693548f, 0.019936462864280f, 0.000413058703998f, 0.020319648087025f, - 0.000428790634032f, 0.020702820271254f, 0.000444816454547f, 0.021085981279612f, - 0.000461136136437f, 0.021469129249454f, 0.000477749679703f, 0.021852264180779f, - 0.000494657084346f, 0.022235386073589f, 0.000511858321261f, 0.022618494927883f, - 0.000529353390448f, 0.023001590743661f, 0.000547142291907f, 0.023384673520923f, - 0.000565225025639f, 0.023767741397023f, 0.000583601591643f, 0.024150796234608f, - 0.000602271873504f, 0.024533838033676f, 0.000621235987637f, 0.024916863068938f, - 0.000640493875835f, 0.025299875065684f, 0.000660045538098f, 0.025682870298624f, - 0.000679890916217f, 0.026065852493048f, 0.000700030010194f, 0.026448817923665f, - 0.000720462878235f, 0.026831768453121f, 0.000741189462133f, 0.027214704081416f, - 0.000762209703680f, 0.027597622945905f, 0.000783523661084f, 0.027980525046587f, - 0.000805131276138f, 0.028363410383463f, 0.000827032607049f, 0.028746278956532f, - 0.000849227537401f, 0.029129132628441f, 0.000871716125403f, 0.029511967673898f, - 0.000894498312846f, 0.029894785955548f, 0.000917574157938f, 0.030277585610747f, - 0.000940943544265f, 0.030660368502140f, 0.000964606530033f, 0.031043132767081f, - 0.000988563057035f, 0.031425878405571f, 0.001012813183479f, 0.031808607280254f, - 0.001037356909364f, 0.032191313803196f, 0.001062194118276f, 0.032574005424976f, - 0.001087324810214f, 0.032956674695015f, 0.001112748985179f, 0.033339329063892f, - 0.001138466643170f, 0.033721961081028f, 0.001164477784187f, 0.034104570746422f, - 0.001190782408230f, 0.034487165510654f, 0.001217380515300f, 0.034869734197855f, - 0.001244271872565f, 0.035252287983894f, 0.001271456829272f, 0.035634815692902f, - 0.001298935036175f, 0.036017324775457f, 0.001326706726104f, 0.036399815231562f, - 0.001354771666229f, 0.036782283335924f, 0.001383129972965f, 0.037164725363255f, - 0.001411781646311f, 0.037547148764133f, 0.001440726569854f, 0.037929553538561f, - 0.001469964860007f, 0.038311932235956f, 0.001499496400356f, 0.038694288581610f, - 0.001529321074486f, 0.039076622575521f, 0.001559439115226f, 0.039458930492401f, - 0.001589850406162f, 0.039841219782829f, 0.001620554830879f, 0.040223482996225f, - 0.001651552389376f, 0.040605723857880f, 0.001682843198068f, 0.040987938642502f, - 0.001714427140541f, 0.041370131075382f, 0.001746304216795f, 0.041752301156521f, - 0.001778474310413f, 0.042134445160627f, 0.001810937537812f, 0.042516563087702f, - 0.001843693898991f, 0.042898654937744f, 0.001876743277535f, 0.043280724436045f, - 0.001910085673444f, 0.043662767857313f, 0.001943721086718f, 0.044044785201550f, - 0.001977649517357f, 0.044426776468754f, 0.002011870965362f, 0.044808741658926f, - 0.002046385314316f, 0.045190680772066f, 0.002081192564219f, 0.045572593808174f, - 0.002116292715073f, 0.045954477041960f, 0.002151685766876f, 0.046336337924004f, - 0.002187371719629f, 0.046718169003725f, 0.002223350573331f, 0.047099970281124f, - 0.002259622327983f, 0.047481749206781f, 0.002296186750755f, 0.047863494604826f, - 0.002333043841645f, 0.048245213925838f, 0.002370193833485f, 0.048626907169819f, - 0.002407636726275f, 0.049008570611477f, 0.002445372054353f, 0.049390204250813f, - 0.002483400283381f, 0.049771808087826f, 0.002521721180528f, 0.050153385847807f, - 0.002560334512964f, 0.050534930080175f, 0.002599240746349f, 0.050916448235512f, - 0.002638439415023f, 0.051297932863235f, 0.002677930751815f, 0.051679391413927f, - 0.002717714523897f, 0.052060816437006f, 0.002757790964097f, 0.052442211657763f, - 0.002798160072416f, 0.052823577076197f, 0.002838821383193f, 0.053204908967018f, - 0.002879775362089f, 0.053586211055517f, 0.002921021543443f, 0.053967483341694f, - 0.002962560392916f, 0.054348722100258f, 0.003004391444847f, 0.054729927331209f, - 0.003046514932066f, 0.055111102759838f, 0.003088930854574f, 0.055492244660854f, - 0.003131638979539f, 0.055873356759548f, 0.003174639539793f, 0.056254431605339f, - 0.003217932302505f, 0.056635476648808f, 0.003261517267674f, 0.057016488164663f, - 0.003305394435301f, 0.057397462427616f, 0.003349563805386f, 0.057778406888247f, - 0.003394025377929f, 0.058159314095974f, 0.003438779152930f, 0.058540191501379f, - 0.003483824897557f, 0.058921031653881f, 0.003529162844643f, 0.059301838278770f, - 0.003574792761356f, 0.059682607650757f, 0.003620714880526f, 0.060063343495131f, - 0.003666928736493f, 0.060444042086601f, 0.003713434794918f, 0.060824707150459f, - 0.003760232590139f, 0.061205338686705f, 0.003807322587818f, 0.061585929244757f, - 0.003854704322293f, 0.061966486275196f, 0.003902378026396f, 0.062347009778023f, - 0.003950343467295f, 0.062727488577366f, 0.003998600877821f, 0.063107937574387f, - 0.004047149792314f, 0.063488349318504f, 0.004095990676433f, 0.063868723809719f, - 0.004145123064518f, 0.064249053597450f, 0.004194547422230f, 0.064629353582859f, - 0.004244263283908f, 0.065009608864784f, 0.004294271115214f, 0.065389834344387f, - 0.004344569984823f, 0.065770015120506f, 0.004395160824060f, 0.066150158643723f, - 0.004446043167263f, 0.066530264914036f, 0.004497217014432f, 0.066910326480865f, - 0.004548682365566f, 0.067290350794792f, 0.004600439220667f, 0.067670337855816f, - 0.004652487114072f, 0.068050287663937f, 0.004704826977104f, 0.068430192768574f, - 0.004757457878441f, 0.068810060620308f, 0.004810380283743f, 0.069189883768559f, - 0.004863593727350f, 0.069569669663906f, 0.004917098674923f, 0.069949418306351f, - 0.004970894660801f, 0.070329122245312f, 0.005024982150644f, 0.070708781480789f, - 0.005079360678792f, 0.071088403463364f, 0.005134030245245f, 0.071467980742455f, - 0.005188991315663f, 0.071847513318062f, 0.005244242958724f, 0.072227008640766f, - 0.005299786105752f, 0.072606459259987f, 0.005355620291084f, 0.072985872626305f, - 0.005411745049059f, 0.073365233838558f, 0.005468160845339f, 0.073744557797909f, - 0.005524867679924f, 0.074123837053776f, 0.005581865552813f, 0.074503071606159f, - 0.005639153998345f, 0.074882268905640f, 0.005696733482182f, 0.075261414051056f, - 0.005754603538662f, 0.075640521943569f, 0.005812764633447f, 0.076019577682018f, - 0.005871216300875f, 0.076398596167564f, 0.005929958540946f, 0.076777562499046f, - 0.005988991353661f, 0.077156484127045f, 0.006048315204680f, 0.077535368502140f, - 0.006107929162681f, 0.077914200723171f, 0.006167833693326f, 0.078292988240719f, - 0.006228029262275f, 0.078671731054783f, 0.006288514938205f, 0.079050421714783f, - 0.006349290721118f, 0.079429075121880f, 0.006410357542336f, 0.079807676374912f, - 0.006471714470536f, 0.080186225473881f, 0.006533361505717f, 0.080564737319946f, - 0.006595299113542f, 0.080943197011948f, 0.006657526828349f, 0.081321612000465f, - 0.006720044650137f, 0.081699974834919f, 0.006782853044569f, 0.082078292965889f, - 0.006845951545984f, 0.082456558942795f, 0.006909339688718f, 0.082834780216217f, - 0.006973018404096f, 0.083212949335575f, 0.007036986760795f, 0.083591073751450f, - 0.007101245224476f, 0.083969146013260f, 0.007165793795139f, 0.084347173571587f, - 0.007230632472783f, 0.084725148975849f, 0.007295760791749f, 0.085103072226048f, - 0.007361178752035f, 0.085480943322182f, 0.007426886819303f, 0.085858769714832f, - 0.007492884527892f, 0.086236543953419f, 0.007559171877801f, 0.086614266037941f, - 0.007625748869032f, 0.086991935968399f, 0.007692615967244f, 0.087369553744793f, - 0.007759772241116f, 0.087747126817703f, 0.007827218621969f, 0.088124647736549f, - 0.007894953712821f, 0.088502109050751f, 0.007962978444993f, 0.088879525661469f, - 0.008031292818487f, 0.089256882667542f, 0.008099896833301f, 0.089634194970131f, - 0.008168790489435f, 0.090011447668076f, 0.008237972855568f, 0.090388655662537f, - 0.008307444863021f, 0.090765804052353f, 0.008377205580473f, 0.091142900288105f, - 0.008447255939245f, 0.091519944369793f, 0.008517595939338f, 0.091896936297417f, - 0.008588224649429f, 0.092273868620396f, 0.008659142069519f, 0.092650748789310f, - 0.008730349130929f, 0.093027576804161f, 0.008801844902337f, 0.093404345214367f, - 0.008873629383743f, 0.093781061470509f, 0.008945702575147f, 0.094157725572586f, - 0.009018065407872f, 0.094534330070019f, 0.009090716950595f, 0.094910882413387f, - 0.009163657203317f, 0.095287375152111f, 0.009236886166036f, 0.095663815736771f, - 0.009310402907431f, 0.096040196716785f, 0.009384209290147f, 0.096416525542736f, - 0.009458304382861f, 0.096792794764042f, 0.009532688185573f, 0.097169004380703f, - 0.009607359766960f, 0.097545161843300f, 0.009682320058346f, 0.097921259701252f, - 0.009757569059730f, 0.098297297954559f, 0.009833106771111f, 0.098673284053802f, - 0.009908932261169f, 0.099049203097820f, 0.009985045529902f, 0.099425069987774f, - 0.010061448439956f, 0.099800877273083f, 0.010138138197362f, 0.100176624953747f, - 0.010215117596090f, 0.100552320480347f, 0.010292383842170f, 0.100927948951721f, - 0.010369938798249f, 0.101303517818451f, 0.010447781533003f, 0.101679034531116f, - 0.010525912046432f, 0.102054484188557f, 0.010604331269860f, 0.102429874241352f, - 0.010683037340641f, 0.102805204689503f, 0.010762032121420f, 0.103180475533009f, - 0.010841314680874f, 0.103555686771870f, 0.010920885019004f, 0.103930838406086f, - 0.011000742204487f, 0.104305922985077f, 0.011080888099968f, 0.104680955410004f, - 0.011161320842803f, 0.105055920779705f, 0.011242041364312f, 0.105430819094181f, - 0.011323049664497f, 0.105805665254593f, 0.011404345743358f, 0.106180444359779f, - 0.011485928669572f, 0.106555156409740f, 0.011567799374461f, 0.106929816305637f, - 0.011649956926703f, 0.107304409146309f, 0.011732402257621f, 0.107678934931755f, - 0.011815134435892f, 0.108053401112556f, 0.011898153461516f, 0.108427800238132f, - 0.011981460265815f, 0.108802139759064f, 0.012065053917468f, 0.109176412224770f, - 0.012148935347795f, 0.109550617635250f, 0.012233102694154f, 0.109924763441086f, - 0.012317557819188f, 0.110298842191696f, 0.012402298860252f, 0.110672861337662f, - 0.012487327679992f, 0.111046813428402f, 0.012572642415762f, 0.111420698463917f, - 0.012658244930208f, 0.111794516444206f, 0.012744133360684f, 0.112168267369270f, - 0.012830308638513f, 0.112541958689690f, 0.012916770763695f, 0.112915575504303f, - 0.013003518804908f, 0.113289132714272f, 0.013090553693473f, 0.113662622869015f, - 0.013177875429392f, 0.114036038517952f, 0.013265483081341f, 0.114409394562244f, - 0.013353376649320f, 0.114782683551311f, 0.013441557064652f, 0.115155905485153f, - 0.013530024327338f, 0.115529052913189f, 0.013618776574731f, 0.115902140736580f, - 0.013707815669477f, 0.116275154054165f, 0.013797140680254f, 0.116648100316525f, - 0.013886751607060f, 0.117020979523659f, 0.013976648449898f, 0.117393791675568f, - 0.014066831208766f, 0.117766529321671f, 0.014157299883664f, 0.118139199912548f, - 0.014248054474592f, 0.118511803448200f, 0.014339094981551f, 0.118884332478046f, - 0.014430420473218f, 0.119256794452667f, 0.014522032812238f, 0.119629189372063f, - 0.014613929204643f, 0.120001509785652f, 0.014706112444401f, 0.120373763144016f, - 0.014798580668867f, 0.120745941996574f, 0.014891333878040f, 0.121118053793907f, - 0.014984373003244f, 0.121490091085434f, 0.015077698044479f, 0.121862053871155f, - 0.015171307139099f, 0.122233949601650f, 0.015265202149749f, 0.122605770826340f, - 0.015359382145107f, 0.122977524995804f, 0.015453847125173f, 0.123349204659462f, - 0.015548598021269f, 0.123720809817314f, 0.015643632039428f, 0.124092340469360f, - 0.015738952904940f, 0.124463804066181f, 0.015834558755159f, 0.124835193157196f, - 0.015930447727442f, 0.125206500291824f, 0.016026621684432f, 0.125577747821808f, - 0.016123080626130f, 0.125948905944824f, 0.016219824552536f, 0.126320004463196f, - 0.016316853463650f, 0.126691013574600f, 0.016414167359471f, 0.127061963081360f, - 0.016511764377356f, 0.127432823181152f, 0.016609646379948f, 0.127803623676300f, - 0.016707813367248f, 0.128174334764481f, 0.016806263476610f, 0.128544986248016f, - 0.016904998570681f, 0.128915548324585f, 0.017004016786814f, 0.129286035895348f, - 0.017103319987655f, 0.129656463861465f, 0.017202908173203f, 0.130026802420616f, - 0.017302779480815f, 0.130397051572800f, 0.017402933910489f, 0.130767241120338f, - 0.017503373324871f, 0.131137356162071f, 0.017604095861316f, 0.131507381796837f, - 0.017705103382468f, 0.131877332925797f, 0.017806394025683f, 0.132247209548950f, - 0.017907967790961f, 0.132617011666298f, 0.018009826540947f, 0.132986739277840f, - 0.018111966550350f, 0.133356377482414f, 0.018214391544461f, 0.133725941181183f, - 0.018317099660635f, 0.134095430374146f, 0.018420090898871f, 0.134464830160141f, - 0.018523367121816f, 0.134834155440331f, 0.018626924604177f, 0.135203406214714f, - 0.018730765208602f, 0.135572582483292f, 0.018834890797734f, 0.135941669344902f, - 0.018939297646284f, 0.136310681700706f, 0.019043987616897f, 0.136679604649544f, - 0.019148962572217f, 0.137048453092575f, 0.019254218786955f, 0.137417227029800f, - 0.019359756261110f, 0.137785911560059f, 0.019465578719974f, 0.138154521584511f, - 0.019571684300900f, 0.138523042201996f, 0.019678071141243f, 0.138891488313675f, - 0.019784741103649f, 0.139259845018387f, 0.019891692325473f, 0.139628127217293f, - 0.019998926669359f, 0.139996320009232f, 0.020106444135308f, 0.140364438295364f, - 0.020214242860675f, 0.140732467174530f, 0.020322324708104f, 0.141100421547890f, - 0.020430689677596f, 0.141468286514282f, 0.020539334043860f, 0.141836062073708f, - 0.020648263394833f, 0.142203763127327f, 0.020757472142577f, 0.142571389675140f, - 0.020866964012384f, 0.142938911914825f, 0.020976737141609f, 0.143306359648705f, - 0.021086793392897f, 0.143673732876778f, 0.021197130903602f, 0.144041016697884f, - 0.021307749673724f, 0.144408211112022f, 0.021418649703264f, 0.144775316119194f, - 0.021529832854867f, 0.145142331719399f, 0.021641295403242f, 0.145509272813797f, - 0.021753041073680f, 0.145876124501228f, 0.021865066140890f, 0.146242901682854f, - 0.021977374330163f, 0.146609574556351f, 0.022089963778853f, 0.146976172924042f, - 0.022202832624316f, 0.147342681884766f, 0.022315984591842f, 0.147709101438522f, - 0.022429415956140f, 0.148075446486473f, 0.022543128579855f, 0.148441687226295f, - 0.022657122462988f, 0.148807853460312f, 0.022771397605538f, 0.149173930287361f, - 0.022885952144861f, 0.149539917707443f, 0.023000787943602f, 0.149905815720558f, - 0.023115905001760f, 0.150271624326706f, 0.023231301456690f, 0.150637343525887f, - 0.023346979171038f, 0.151002973318100f, 0.023462938144803f, 0.151368513703346f, - 0.023579176515341f, 0.151733979582787f, 0.023695694282651f, 0.152099341154099f, - 0.023812493309379f, 0.152464613318443f, 0.023929571732879f, 0.152829796075821f, - 0.024046931415796f, 0.153194904327393f, 0.024164570495486f, 0.153559908270836f, - 0.024282488971949f, 0.153924822807312f, 0.024400688707829f, 0.154289647936821f, - 0.024519165977836f, 0.154654383659363f, 0.024637924507260f, 0.155019029974937f, - 0.024756962433457f, 0.155383571982384f, 0.024876279756427f, 0.155748039484024f, - 0.024995878338814f, 0.156112402677536f, 0.025115754455328f, 0.156476691365242f, - 0.025235909968615f, 0.156840875744820f, 0.025356344878674f, 0.157204970717430f, - 0.025477059185505f, 0.157568961381912f, 0.025598052889109f, 0.157932877540588f, - 0.025719324126840f, 0.158296689391136f, 0.025840876623988f, 0.158660411834717f, - 0.025962706655264f, 0.159024044871330f, 0.026084816083312f, 0.159387573599815f, - 0.026207204908133f, 0.159751012921333f, 0.026329871267080f, 0.160114362835884f, - 0.026452817022800f, 0.160477623343468f, 0.026576040312648f, 0.160840779542923f, - 0.026699542999268f, 0.161203846335411f, 0.026823325082660f, 0.161566808819771f, - 0.026947384700179f, 0.161929681897163f, 0.027071721851826f, 0.162292465567589f, - 0.027196336537600f, 0.162655144929886f, 0.027321230620146f, 0.163017734885216f, - 0.027446404099464f, 0.163380220532417f, 0.027571853250265f, 0.163742616772652f, - 0.027697581797838f, 0.164104923605919f, 0.027823587879539f, 0.164467126131058f, - 0.027949871495366f, 0.164829224348068f, 0.028076432645321f, 0.165191248059273f, - 0.028203271329403f, 0.165553152561188f, 0.028330387547612f, 0.165914967656136f, - 0.028457781299949f, 0.166276678442955f, 0.028585452586412f, 0.166638299822807f, - 0.028713401407003f, 0.166999831795692f, 0.028841627761722f, 0.167361244559288f, - 0.028970129787922f, 0.167722567915916f, 0.029098909348249f, 0.168083801865578f, - 0.029227968305349f, 0.168444931507111f, 0.029357301071286f, 0.168805956840515f, - 0.029486913233995f, 0.169166877865791f, 0.029616801068187f, 0.169527709484100f, - 0.029746964573860f, 0.169888436794281f, 0.029877405613661f, 0.170249074697495f, - 0.030008124187589f, 0.170609608292580f, 0.030139118432999f, 0.170970037579536f, - 0.030270388349891f, 0.171330362558365f, 0.030401935800910f, 0.171690583229065f, - 0.030533758923411f, 0.172050714492798f, 0.030665857717395f, 0.172410741448402f, - 0.030798232182860f, 0.172770664095879f, 0.030930884182453f, 0.173130482435226f, - 0.031063811853528f, 0.173490211367607f, 0.031197015196085f, 0.173849821090698f, - 0.031330492347479f, 0.174209341406822f, 0.031464248895645f, 0.174568757414818f, - 0.031598277390003f, 0.174928069114685f, 0.031732585281134f, 0.175287276506424f, - 0.031867165118456f, 0.175646379590034f, 0.032002024352551f, 0.176005378365517f, - 0.032137155532837f, 0.176364272832870f, 0.032272562384605f, 0.176723077893257f, - 0.032408244907856f, 0.177081763744354f, 0.032544203102589f, 0.177440345287323f, - 0.032680433243513f, 0.177798837423325f, 0.032816942781210f, 0.178157210350037f, - 0.032953724265099f, 0.178515478968620f, 0.033090781420469f, 0.178873643279076f, - 0.033228114247322f, 0.179231703281403f, 0.033365719020367f, 0.179589673876762f, - 0.033503599464893f, 0.179947525262833f, 0.033641755580902f, 0.180305257439613f, - 0.033780183643103f, 0.180662900209427f, 0.033918887376785f, 0.181020438671112f, - 0.034057866781950f, 0.181377857923508f, 0.034197118133307f, 0.181735187768936f, - 0.034336645156145f, 0.182092398405075f, 0.034476444125175f, 0.182449504733086f, - 0.034616518765688f, 0.182806491851807f, 0.034756865352392f, 0.183163389563560f, - 0.034897487610579f, 0.183520168066025f, 0.035038381814957f, 0.183876842260361f, - 0.035179551690817f, 0.184233412146568f, 0.035320993512869f, 0.184589877724648f, - 0.035462711006403f, 0.184946224093437f, 0.035604696720839f, 0.185302466154099f, - 0.035746958106756f, 0.185658603906631f, 0.035889495164156f, 0.186014622449875f, - 0.036032304167747f, 0.186370536684990f, 0.036175385117531f, 0.186726331710815f, - 0.036318738013506f, 0.187082037329674f, 0.036462362855673f, 0.187437608838081f, - 0.036606263369322f, 0.187793090939522f, 0.036750435829163f, 0.188148453831673f, - 0.036894880235195f, 0.188503712415695f, 0.037039596587420f, 0.188858851790428f, - 0.037184584885836f, 0.189213871955872f, 0.037329845130444f, 0.189568802714348f, - 0.037475381046534f, 0.189923599362373f, 0.037621185183525f, 0.190278306603432f, - 0.037767261266708f, 0.190632879734039f, 0.037913613021374f, 0.190987363457680f, - 0.038060232996941f, 0.191341713070869f, 0.038207128643990f, 0.191695958375931f, - 0.038354292511940f, 0.192050099372864f, 0.038501728326082f, 0.192404121160507f, - 0.038649436086416f, 0.192758023738861f, 0.038797415792942f, 0.193111822009087f, - 0.038945667445660f, 0.193465501070023f, 0.039094187319279f, 0.193819075822830f, - 0.039242979139090f, 0.194172516465187f, 0.039392042905092f, 0.194525867700577f, - 0.039541378617287f, 0.194879084825516f, 0.039690986275673f, 0.195232197642326f, - 0.039840862154961f, 0.195585191249847f, 0.039991009980440f, 0.195938065648079f, - 0.040141426026821f, 0.196290835738182f, 0.040292114019394f, 0.196643486618996f, - 0.040443073958158f, 0.196996018290520f, 0.040594302117825f, 0.197348430752754f, - 0.040745802223682f, 0.197700738906860f, 0.040897574275732f, 0.198052927851677f, - 0.041049610823393f, 0.198404997587204f, 0.041201923042536f, 0.198756948113441f, - 0.041354499757290f, 0.199108779430389f, 0.041507352143526f, 0.199460506439209f, - 0.041660469025373f, 0.199812099337578f, 0.041813857853413f, 0.200163587927818f, - 0.041967518627644f, 0.200514942407608f, 0.042121443897486f, 0.200866192579269f, - 0.042275641113520f, 0.201217323541641f, 0.042430106550455f, 0.201568335294724f, - 0.042584843933582f, 0.201919227838516f, 0.042739849537611f, 0.202270001173019f, - 0.042895123362541f, 0.202620655298233f, 0.043050665408373f, 0.202971190214157f, - 0.043206475675106f, 0.203321605920792f, 0.043362557888031f, 0.203671902418137f, - 0.043518904596567f, 0.204022079706192f, 0.043675523251295f, 0.204372137784958f, - 0.043832406401634f, 0.204722076654434f, 0.043989561498165f, 0.205071896314621f, - 0.044146984815598f, 0.205421581864357f, 0.044304672628641f, 0.205771163105965f, - 0.044462632387877f, 0.206120610237122f, 0.044620860368013f, 0.206469938158989f, - 0.044779352843761f, 0.206819161772728f, 0.044938117265701f, 0.207168251276016f, - 0.045097146183252f, 0.207517206668854f, 0.045256443321705f, 0.207866057753563f, - 0.045416008681059f, 0.208214774727821f, 0.045575842261314f, 0.208563387393951f, - 0.045735940337181f, 0.208911851048470f, 0.045896306633949f, 0.209260210394859f, - 0.046056941151619f, 0.209608450531960f, 0.046217843890190f, 0.209956556558609f, - 0.046379011124372f, 0.210304543375969f, 0.046540446579456f, 0.210652396082878f, - 0.046702146530151f, 0.211000129580498f, 0.046864114701748f, 0.211347743868828f, - 0.047026351094246f, 0.211695238947868f, 0.047188851982355f, 0.212042599916458f, - 0.047351621091366f, 0.212389841675758f, 0.047514654695988f, 0.212736949324608f, - 0.047677956521511f, 0.213083937764168f, 0.047841522842646f, 0.213430806994438f, - 0.048005353659391f, 0.213777542114258f, 0.048169452697039f, 0.214124158024788f, - 0.048333816230297f, 0.214470639824867f, 0.048498444259167f, 0.214817002415657f, - 0.048663340508938f, 0.215163245797157f, 0.048828501254320f, 0.215509355068207f, - 0.048993926495314f, 0.215855330228806f, 0.049159619957209f, 0.216201186180115f, - 0.049325577914715f, 0.216546908020973f, 0.049491796642542f, 0.216892510652542f, - 0.049658283591270f, 0.217237979173660f, 0.049825038760900f, 0.217583328485489f, - 0.049992054700851f, 0.217928543686867f, 0.050159335136414f, 0.218273624777794f, - 0.050326880067587f, 0.218618586659431f, 0.050494693219662f, 0.218963414430618f, - 0.050662767142057f, 0.219308122992516f, 0.050831105560064f, 0.219652697443962f, - 0.050999708473682f, 0.219997137784958f, 0.051168579608202f, 0.220341444015503f, - 0.051337707787752f, 0.220685631036758f, 0.051507104188204f, 0.221029683947563f, - 0.051676765084267f, 0.221373617649078f, 0.051846686750650f, 0.221717402338982f, - 0.052016876637936f, 0.222061067819595f, 0.052187327295542f, 0.222404599189758f, - 0.052358038723469f, 0.222748011350632f, 0.052529018372297f, 0.223091274499893f, - 0.052700258791447f, 0.223434418439865f, 0.052871759980917f, 0.223777428269386f, - 0.053043525665998f, 0.224120303988457f, 0.053215555846691f, 0.224463045597076f, - 0.053387850522995f, 0.224805667996407f, 0.053560405969620f, 0.225148141384125f, - 0.053733222186565f, 0.225490495562553f, 0.053906302899122f, 0.225832715630531f, - 0.054079644382000f, 0.226174786686897f, 0.054253250360489f, 0.226516738533974f, - 0.054427117109299f, 0.226858556270599f, 0.054601248353720f, 0.227200239896774f, - 0.054775636643171f, 0.227541789412498f, 0.054950293153524f, 0.227883204817772f, - 0.055125206708908f, 0.228224486112595f, 0.055300384759903f, 0.228565633296967f, - 0.055475823581219f, 0.228906646370888f, 0.055651523172855f, 0.229247525334358f, - 0.055827483534813f, 0.229588270187378f, 0.056003704667091f, 0.229928880929947f, - 0.056180190294981f, 0.230269357562065f, 0.056356932967901f, 0.230609700083733f, - 0.056533940136433f, 0.230949893593788f, 0.056711208075285f, 0.231289967894554f, - 0.056888736784458f, 0.231629893183708f, 0.057066522538662f, 0.231969684362412f, - 0.057244572788477f, 0.232309341430664f, 0.057422880083323f, 0.232648864388466f, - 0.057601451873779f, 0.232988253235817f, 0.057780280709267f, 0.233327493071556f, - 0.057959370315075f, 0.233666598796844f, 0.058138720691204f, 0.234005570411682f, - 0.058318331837654f, 0.234344407916069f, 0.058498200029135f, 0.234683111310005f, - 0.058678328990936f, 0.235021665692329f, 0.058858718723059f, 0.235360085964203f, - 0.059039369225502f, 0.235698372125626f, 0.059220276772976f, 0.236036509275436f, - 0.059401445090771f, 0.236374512314796f, 0.059582870453596f, 0.236712381243706f, - 0.059764556586742f, 0.237050101161003f, 0.059946499764919f, 0.237387686967850f, - 0.060128703713417f, 0.237725138664246f, 0.060311164706945f, 0.238062441349030f, - 0.060493886470795f, 0.238399609923363f, 0.060676865279675f, 0.238736644387245f, - 0.060860104858875f, 0.239073529839516f, 0.061043601483107f, 0.239410281181335f, - 0.061227355152369f, 0.239746883511543f, 0.061411365866661f, 0.240083336830139f, - 0.061595637351274f, 0.240419670939446f, 0.061780165880919f, 0.240755841135979f, - 0.061964951455593f, 0.241091892123222f, 0.062149997800589f, 0.241427779197693f, - 0.062335297465324f, 0.241763532161713f, 0.062520854175091f, 0.242099151015282f, - 0.062706671655178f, 0.242434620857239f, 0.062892749905586f, 0.242769956588745f, - 0.063079081475735f, 0.243105143308640f, 0.063265666365623f, 0.243440181016922f, - 0.063452512025833f, 0.243775084614754f, 0.063639611005783f, 0.244109839200974f, - 0.063826970756054f, 0.244444444775581f, 0.064014583826065f, 0.244778916239738f, - 0.064202457666397f, 0.245113238692284f, 0.064390584826469f, 0.245447427034378f, - 0.064578965306282f, 0.245781451463699f, 0.064767606556416f, 0.246115356683731f, - 0.064956501126289f, 0.246449097990990f, 0.065145656466484f, 0.246782705187798f, - 0.065335065126419f, 0.247116148471832f, 0.065524727106094f, 0.247449472546577f, - 0.065714649856091f, 0.247782632708550f, 0.065904818475246f, 0.248115643858910f, - 0.066095255315304f, 0.248448520898819f, 0.066285938024521f, 0.248781248927116f, - 0.066476874053478f, 0.249113827943802f, 0.066668070852757f, 0.249446272850037f, - 0.066859520971775f, 0.249778553843498f, 0.067051224410534f, 0.250110685825348f, - 0.067243188619614f, 0.250442683696747f, 0.067435398697853f, 0.250774532556534f, - 0.067627869546413f, 0.251106232404709f, 0.067820593714714f, 0.251437783241272f, - 0.068013571202755f, 0.251769185066223f, 0.068206802010536f, 0.252100437879562f, - 0.068400286138058f, 0.252431541681290f, 0.068594031035900f, 0.252762526273727f, - 0.068788021802902f, 0.253093332052231f, 0.068982265889645f, 0.253423988819122f, - 0.069176770746708f, 0.253754496574402f, 0.069371521472931f, 0.254084855318069f, - 0.069566532969475f, 0.254415065050125f, 0.069761790335178f, 0.254745125770569f, - 0.069957308471203f, 0.255075037479401f, 0.070153072476387f, 0.255404800176620f, - 0.070349089801311f, 0.255734413862228f, 0.070545360445976f, 0.256063878536224f, - 0.070741884410381f, 0.256393194198608f, 0.070938661694527f, 0.256722360849380f, - 0.071135692298412f, 0.257051378488541f, 0.071332976222038f, 0.257380217313766f, - 0.071530513465405f, 0.257708936929703f, 0.071728296577930f, 0.258037507534027f, - 0.071926333010197f, 0.258365899324417f, 0.072124622762203f, 0.258694142103195f, - 0.072323165833950f, 0.259022265672684f, 0.072521962225437f, 0.259350210428238f, - 0.072721004486084f, 0.259678006172180f, 0.072920300066471f, 0.260005623102188f, - 0.073119848966599f, 0.260333120822906f, 0.073319651186466f, 0.260660469532013f, - 0.073519699275494f, 0.260987639427185f, 0.073720000684261f, 0.261314690113068f, - 0.073920547962189f, 0.261641561985016f, 0.074121348559856f, 0.261968284845352f, - 0.074322402477264f, 0.262294828891754f, 0.074523709714413f, 0.262621253728867f, - 0.074725262820721f, 0.262947499752045f, 0.074927061796188f, 0.263273626565933f, - 0.075129114091396f, 0.263599574565887f, 0.075331419706345f, 0.263925373554230f, - 0.075533971190453f, 0.264250993728638f, 0.075736775994301f, 0.264576494693756f, - 0.075939826667309f, 0.264901816844940f, 0.076143130660057f, 0.265226989984512f, - 0.076346680521965f, 0.265552014112473f, 0.076550483703613f, 0.265876859426498f, - 0.076754532754421f, 0.266201555728912f, 0.076958827674389f, 0.266526103019714f, - 0.077163375914097f, 0.266850501298904f, 0.077368170022964f, 0.267174720764160f, - 0.077573217451572f, 0.267498821020126f, 0.077778510749340f, 0.267822742462158f, - 0.077984049916267f, 0.268146485090256f, 0.078189842402935f, 0.268470078706741f, - 0.078395880758762f, 0.268793523311615f, 0.078602164983749f, 0.269116818904877f, - 0.078808702528477f, 0.269439965486526f, 0.079015478491783f, 0.269762933254242f, - 0.079222507774830f, 0.270085722208023f, 0.079429790377617f, 0.270408391952515f, - 0.079637311398983f, 0.270730882883072f, 0.079845085740089f, 0.271053224802017f, - 0.080053105950356f, 0.271375387907028f, 0.080261372029781f, 0.271697402000427f, - 0.080469883978367f, 0.272019267082214f, 0.080678641796112f, 0.272340953350067f, - 0.080887645483017f, 0.272662490606308f, 0.081096902489662f, 0.272983878850937f, - 0.081306397914886f, 0.273305088281631f, 0.081516146659851f, 0.273626148700714f, - 0.081726133823395f, 0.273947030305862f, 0.081936374306679f, 0.274267762899399f, - 0.082146860659122f, 0.274588316679001f, 0.082357585430145f, 0.274908751249313f, - 0.082568563520908f, 0.275228977203369f, 0.082779780030251f, 0.275549083948135f, - 0.082991249859333f, 0.275868982076645f, 0.083202958106995f, 0.276188760995865f, - 0.083414919674397f, 0.276508361101151f, 0.083627119660378f, 0.276827782392502f, - 0.083839565515518f, 0.277147054672241f, 0.084052257239819f, 0.277466177940369f, - 0.084265194833279f, 0.277785122394562f, 0.084478378295898f, 0.278103888034821f, - 0.084691800177097f, 0.278422504663467f, 0.084905467927456f, 0.278740972280502f, - 0.085119381546974f, 0.279059261083603f, 0.085333541035652f, 0.279377400875092f, - 0.085547938942909f, 0.279695361852646f, 0.085762590169907f, 0.280013144016266f, - 0.085977479815483f, 0.280330777168274f, 0.086192607879639f, 0.280648261308670f, - 0.086407989263535f, 0.280965566635132f, 0.086623609066010f, 0.281282693147659f, - 0.086839467287064f, 0.281599670648575f, 0.087055571377277f, 0.281916469335556f, - 0.087271921336651f, 0.282233119010925f, 0.087488517165184f, 0.282549589872360f, - 0.087705351412296f, 0.282865911722183f, 0.087922424077988f, 0.283182054758072f, - 0.088139742612839f, 0.283498018980026f, 0.088357307016850f, 0.283813834190369f, - 0.088575109839439f, 0.284129470586777f, 0.088793158531189f, 0.284444957971573f, - 0.089011445641518f, 0.284760266542435f, 0.089229971170425f, 0.285075396299362f, - 0.089448742568493f, 0.285390377044678f, 0.089667752385139f, 0.285705178976059f, - 0.089887008070946f, 0.286019802093506f, 0.090106502175331f, 0.286334276199341f, - 0.090326242148876f, 0.286648571491241f, 0.090546220541000f, 0.286962717771530f, - 0.090766437351704f, 0.287276685237885f, 0.090986892580986f, 0.287590473890305f, - 0.091207593679428f, 0.287904083728790f, 0.091428533196449f, 0.288217544555664f, - 0.091649711132050f, 0.288530826568604f, 0.091871134936810f, 0.288843959569931f, - 0.092092797160149f, 0.289156883955002f, 0.092314697802067f, 0.289469659328461f, - 0.092536836862564f, 0.289782285690308f, 0.092759214341640f, 0.290094703435898f, - 0.092981837689877f, 0.290406972169876f, 0.093204692006111f, 0.290719062089920f, - 0.093427792191505f, 0.291031002998352f, 0.093651130795479f, 0.291342735290527f, - 0.093874707818031f, 0.291654318571091f, 0.094098523259163f, 0.291965723037720f, - 0.094322577118874f, 0.292276978492737f, 0.094546869397163f, 0.292588025331497f, - 0.094771400094032f, 0.292898923158646f, 0.094996169209480f, 0.293209642171860f, - 0.095221176743507f, 0.293520182371140f, 0.095446422696114f, 0.293830573558807f, - 0.095671907067299f, 0.294140785932541f, 0.095897629857063f, 0.294450789690018f, - 0.096123591065407f, 0.294760644435883f, 0.096349790692329f, 0.295070350170136f, - 0.096576221287251f, 0.295379847288132f, 0.096802897751331f, 0.295689195394516f, - 0.097029805183411f, 0.295998334884644f, 0.097256951034069f, 0.296307325363159f, - 0.097484335303307f, 0.296616137027740f, 0.097711957991123f, 0.296924799680710f, - 0.097939811646938f, 0.297233253717422f, 0.098167903721333f, 0.297541528940201f, - 0.098396234214306f, 0.297849655151367f, 0.098624803125858f, 0.298157602548599f, - 0.098853603005409f, 0.298465341329575f, 0.099082641303539f, 0.298772931098938f, - 0.099311910569668f, 0.299080342054367f, 0.099541425704956f, 0.299387603998184f, - 0.099771171808243f, 0.299694657325745f, 0.100001148879528f, 0.300001531839371f, - 0.100231364369392f, 0.300308227539063f, 0.100461818277836f, 0.300614774227142f, - 0.100692503154278f, 0.300921112298965f, 0.100923426449299f, 0.301227301359177f, - 0.101154580712318f, 0.301533311605453f, 0.101385973393917f, 0.301839113235474f, - 0.101617597043514f, 0.302144765853882f, 0.101849451661110f, 0.302450239658356f, - 0.102081544697285f, 0.302755534648895f, 0.102313876152039f, 0.303060621023178f, - 0.102546438574791f, 0.303365558385849f, 0.102779231965542f, 0.303670316934586f, - 0.103012263774872f, 0.303974896669388f, 0.103245526552200f, 0.304279297590256f, - 0.103479020297527f, 0.304583519697189f, 0.103712752461433f, 0.304887533187866f, - 0.103946708142757f, 0.305191397666931f, 0.104180909693241f, 0.305495083332062f, - 0.104415334761143f, 0.305798590183258f, 0.104649998247623f, 0.306101888418198f, - 0.104884892702103f, 0.306405037641525f, 0.105120018124580f, 0.306708008050919f, - 0.105355374515057f, 0.307010769844055f, 0.105590961873531f, 0.307313382625580f, - 0.105826787650585f, 0.307615786790848f, 0.106062836945057f, 0.307918041944504f, - 0.106299124658108f, 0.308220088481903f, 0.106535643339157f, 0.308521956205368f, - 0.106772392988205f, 0.308823645114899f, 0.107009373605251f, 0.309125155210495f, - 0.107246585190296f, 0.309426486492157f, 0.107484027743340f, 0.309727638959885f, - 0.107721701264381f, 0.310028612613678f, 0.107959605753422f, 0.310329377651215f, - 0.108197741210461f, 0.310629993677139f, 0.108436107635498f, 0.310930401086807f, - 0.108674705028534f, 0.311230629682541f, 0.108913525938988f, 0.311530679464340f, - 0.109152585268021f, 0.311830550432205f, 0.109391868114471f, 0.312130242586136f, - 0.109631389379501f, 0.312429755926132f, 0.109871134161949f, 0.312729060649872f, - 0.110111102461815f, 0.313028186559677f, 0.110351309180260f, 0.313327133655548f, - 0.110591746866703f, 0.313625901937485f, 0.110832408070564f, 0.313924491405487f, - 0.111073300242424f, 0.314222872257233f, 0.111314415931702f, 0.314521104097366f, - 0.111555770039558f, 0.314819127321243f, 0.111797347664833f, 0.315116971731186f, - 0.112039148807526f, 0.315414607524872f, 0.112281180918217f, 0.315712094306946f, - 0.112523443996906f, 0.316009372472763f, 0.112765938043594f, 0.316306471824646f, - 0.113008655607700f, 0.316603392362595f, 0.113251596689224f, 0.316900104284287f, - 0.113494776189327f, 0.317196637392044f, 0.113738171756268f, 0.317492991685867f, - 0.113981798291206f, 0.317789167165756f, 0.114225655794144f, 0.318085134029388f, - 0.114469736814499f, 0.318380922079086f, 0.114714048802853f, 0.318676531314850f, - 0.114958584308624f, 0.318971961736679f, 0.115203343331814f, 0.319267183542252f, - 0.115448333323002f, 0.319562226533890f, 0.115693546831608f, 0.319857090711594f, - 0.115938983857632f, 0.320151746273041f, 0.116184651851654f, 0.320446223020554f, - 0.116430543363094f, 0.320740520954132f, 0.116676658391953f, 0.321034610271454f, - 0.116923004388809f, 0.321328520774841f, 0.117169573903084f, 0.321622252464294f, - 0.117416366934776f, 0.321915775537491f, 0.117663383483887f, 0.322209119796753f, - 0.117910631000996f, 0.322502255439758f, 0.118158094584942f, 0.322795242071152f, - 0.118405789136887f, 0.323088020086288f, 0.118653707206249f, 0.323380589485168f, - 0.118901848793030f, 0.323672980070114f, 0.119150213897228f, 0.323965191841125f, - 0.119398809969425f, 0.324257194995880f, 0.119647622108459f, 0.324549019336700f, - 0.119896657764912f, 0.324840664863586f, 0.120145916938782f, 0.325132101774216f, - 0.120395407080650f, 0.325423330068588f, 0.120645113289356f, 0.325714409351349f, - 0.120895043015480f, 0.326005280017853f, 0.121145196259022f, 0.326295942068100f, - 0.121395580470562f, 0.326586425304413f, 0.121646173298359f, 0.326876699924469f, - 0.121896997094154f, 0.327166795730591f, 0.122148044407368f, 0.327456712722778f, - 0.122399315237999f, 0.327746421098709f, 0.122650802135468f, 0.328035950660706f, - 0.122902512550354f, 0.328325271606445f, 0.123154446482658f, 0.328614413738251f, - 0.123406603932381f, 0.328903347253799f, 0.123658977448940f, 0.329192101955414f, - 0.123911574482918f, 0.329480648040771f, 0.124164395034313f, 0.329769015312195f, - 0.124417431652546f, 0.330057173967361f, 0.124670691788197f, 0.330345153808594f, - 0.124924175441265f, 0.330632925033569f, 0.125177875161171f, 0.330920487642288f, - 0.125431805849075f, 0.331207901239395f, 0.125685945153236f, 0.331495076417923f, - 0.125940307974815f, 0.331782072782516f, 0.126194894313812f, 0.332068890333176f, - 0.126449704170227f, 0.332355499267578f, 0.126704722642899f, 0.332641899585724f, - 0.126959964632988f, 0.332928121089935f, 0.127215430140495f, 0.333214133977890f, - 0.127471104264259f, 0.333499968051910f, 0.127727001905441f, 0.333785593509674f, - 0.127983123064041f, 0.334071010351181f, 0.128239467740059f, 0.334356248378754f, - 0.128496021032333f, 0.334641307592392f, 0.128752797842026f, 0.334926128387451f, - 0.129009798169136f, 0.335210770368576f, 0.129267007112503f, 0.335495233535767f, - 0.129524439573288f, 0.335779488086700f, 0.129782080650330f, 0.336063534021378f, - 0.130039945244789f, 0.336347371339798f, 0.130298033356667f, 0.336631029844284f, - 0.130556344985962f, 0.336914509534836f, 0.130814850330353f, 0.337197750806808f, - 0.131073594093323f, 0.337480813264847f, 0.131332546472549f, 0.337763696908951f, - 0.131591722369194f, 0.338046342134476f, 0.131851106882095f, 0.338328808546066f, - 0.132110700011253f, 0.338611096143723f, 0.132370531558990f, 0.338893145322800f, - 0.132630556821823f, 0.339175015687943f, 0.132890805602074f, 0.339456677436829f, - 0.133151277899742f, 0.339738160371780f, 0.133411958813667f, 0.340019434690475f, - 0.133672863245010f, 0.340300500392914f, 0.133933976292610f, 0.340581357479095f, - 0.134195312857628f, 0.340862035751343f, 0.134456858038902f, 0.341142505407333f, - 0.134718611836433f, 0.341422766447067f, 0.134980589151382f, 0.341702848672867f, - 0.135242775082588f, 0.341982692480087f, 0.135505184531212f, 0.342262357473373f, - 0.135767802596092f, 0.342541843652725f, 0.136030644178391f, 0.342821091413498f, - 0.136293679475784f, 0.343100160360336f, 0.136556953191757f, 0.343379020690918f, - 0.136820420622826f, 0.343657672405243f, 0.137084111571312f, 0.343936115503311f, - 0.137348011136055f, 0.344214379787445f, 0.137612134218216f, 0.344492435455322f, - 0.137876465916634f, 0.344770282506943f, 0.138141006231308f, 0.345047920942307f, - 0.138405755162239f, 0.345325350761414f, 0.138670727610588f, 0.345602601766586f, - 0.138935908675194f, 0.345879614353180f, 0.139201298356056f, 0.346156448125839f, - 0.139466896653175f, 0.346433073282242f, 0.139732718467712f, 0.346709519624710f, - 0.139998748898506f, 0.346985727548599f, 0.140264987945557f, 0.347261756658554f, - 0.140531435608864f, 0.347537547349930f, 0.140798106789589f, 0.347813159227371f, - 0.141064971685410f, 0.348088562488556f, 0.141332060098648f, 0.348363757133484f, - 0.141599357128143f, 0.348638743162155f, 0.141866862773895f, 0.348913550376892f, - 0.142134591937065f, 0.349188119173050f, 0.142402514815331f, 0.349462509155273f, - 0.142670661211014f, 0.349736660718918f, 0.142939001321793f, 0.350010633468628f, - 0.143207564949989f, 0.350284397602081f, 0.143476337194443f, 0.350557953119278f, - 0.143745318055153f, 0.350831300020218f, 0.144014507532120f, 0.351104438304901f, - 0.144283905625343f, 0.351377367973328f, 0.144553512334824f, 0.351650089025497f, - 0.144823327660561f, 0.351922631263733f, 0.145093351602554f, 0.352194935083389f, - 0.145363584160805f, 0.352467030286789f, 0.145634025335312f, 0.352738946676254f, - 0.145904675126076f, 0.353010624647141f, 0.146175548434258f, 0.353282123804092f, - 0.146446615457535f, 0.353553384542465f, 0.146717891097069f, 0.353824466466904f, - 0.146989375352860f, 0.354095309972763f, 0.147261068224907f, 0.354365974664688f, - 0.147532954812050f, 0.354636400938034f, 0.147805064916611f, 0.354906648397446f, - 0.148077383637428f, 0.355176687240601f, 0.148349896073341f, 0.355446487665176f, - 0.148622632026672f, 0.355716109275818f, 0.148895561695099f, 0.355985492467880f, - 0.149168699979782f, 0.356254696846008f, 0.149442046880722f, 0.356523662805557f, - 0.149715602397919f, 0.356792420148849f, 0.149989366531372f, 0.357060998678207f, - 0.150263324379921f, 0.357329338788986f, 0.150537505745888f, 0.357597470283508f, - 0.150811880826950f, 0.357865422964096f, 0.151086464524269f, 0.358133137226105f, - 0.151361241936684f, 0.358400642871857f, 0.151636242866516f, 0.358667939901352f, - 0.151911437511444f, 0.358935028314590f, 0.152186840772629f, 0.359201908111572f, - 0.152462437748909f, 0.359468549489975f, 0.152738258242607f, 0.359735012054443f, - 0.153014272451401f, 0.360001266002655f, 0.153290495276451f, 0.360267281532288f, - 0.153566911816597f, 0.360533088445663f, 0.153843536973000f, 0.360798716545105f, - 0.154120370745659f, 0.361064106225967f, 0.154397398233414f, 0.361329287290573f, - 0.154674649238586f, 0.361594229936600f, 0.154952079057693f, 0.361858993768692f, - 0.155229732394218f, 0.362123548984528f, 0.155507579445839f, 0.362387865781784f, - 0.155785620212555f, 0.362651973962784f, 0.156063869595528f, 0.362915903329849f, - 0.156342327594757f, 0.363179564476013f, 0.156620979309082f, 0.363443046808243f, - 0.156899839639664f, 0.363706320524216f, 0.157178908586502f, 0.363969355821610f, - 0.157458171248436f, 0.364232182502747f, 0.157737627625465f, 0.364494800567627f, - 0.158017292618752f, 0.364757210016251f, 0.158297166228294f, 0.365019410848618f, - 0.158577233552933f, 0.365281373262405f, 0.158857494592667f, 0.365543156862259f, - 0.159137964248657f, 0.365804702043533f, 0.159418627619743f, 0.366066008806229f, - 0.159699499607086f, 0.366327136754990f, 0.159980565309525f, 0.366588026285172f, - 0.160261839628220f, 0.366848707199097f, 0.160543307662010f, 0.367109179496765f, - 0.160824984312058f, 0.367369443178177f, 0.161106839776039f, 0.367629468441010f, - 0.161388918757439f, 0.367889285087585f, 0.161671176552773f, 0.368148893117905f, - 0.161953642964363f, 0.368408292531967f, 0.162236317992210f, 0.368667453527451f, - 0.162519171833992f, 0.368926405906677f, 0.162802234292030f, 0.369185149669647f, - 0.163085505366325f, 0.369443655014038f, 0.163368955254555f, 0.369701951742172f, - 0.163652613759041f, 0.369960039854050f, 0.163936465978622f, 0.370217919349670f, - 0.164220526814461f, 0.370475560426712f, 0.164504766464233f, 0.370732992887497f, - 0.164789214730263f, 0.370990216732025f, 0.165073871612549f, 0.371247202157974f, - 0.165358707308769f, 0.371503978967667f, 0.165643751621246f, 0.371760547161102f, - 0.165928974747658f, 0.372016876935959f, 0.166214406490326f, 0.372272998094559f, - 0.166500031948090f, 0.372528880834579f, 0.166785866022110f, 0.372784584760666f, - 0.167071878910065f, 0.373040050268173f, 0.167358100414276f, 0.373295277357101f, - 0.167644515633583f, 0.373550295829773f, 0.167931124567986f, 0.373805105686188f, - 0.168217927217484f, 0.374059677124023f, 0.168504923582077f, 0.374314039945602f, - 0.168792113661766f, 0.374568194150925f, 0.169079497456551f, 0.374822109937668f, - 0.169367074966431f, 0.375075817108154f, 0.169654861092567f, 0.375329315662384f, - 0.169942826032639f, 0.375582575798035f, 0.170230999588966f, 0.375835597515106f, - 0.170519351959229f, 0.376088410615921f, 0.170807912945747f, 0.376341015100479f, - 0.171096652746201f, 0.376593410968781f, 0.171385586261749f, 0.376845568418503f, - 0.171674728393555f, 0.377097487449646f, 0.171964049339294f, 0.377349197864532f, - 0.172253578901291f, 0.377600699663162f, 0.172543287277222f, 0.377851963043213f, - 0.172833189368248f, 0.378102988004684f, 0.173123285174370f, 0.378353834152222f, - 0.173413574695587f, 0.378604412078857f, 0.173704057931900f, 0.378854811191559f, - 0.173994734883308f, 0.379104942083359f, 0.174285605549812f, 0.379354894161224f, - 0.174576655030251f, 0.379604607820511f, 0.174867913126946f, 0.379854083061218f, - 0.175159350037575f, 0.380103349685669f, 0.175450980663300f, 0.380352377891541f, - 0.175742805004120f, 0.380601197481155f, 0.176034808158875f, 0.380849778652191f, - 0.176327019929886f, 0.381098151206970f, 0.176619410514832f, 0.381346285343170f, - 0.176911994814873f, 0.381594210863113f, 0.177204772830009f, 0.381841897964478f, - 0.177497729659081f, 0.382089376449585f, 0.177790880203247f, 0.382336616516113f, - 0.178084224462509f, 0.382583618164063f, 0.178377762436867f, 0.382830440998077f, - 0.178671479225159f, 0.383076995611191f, 0.178965389728546f, 0.383323341608047f, - 0.179259493947029f, 0.383569449186325f, 0.179553776979446f, 0.383815348148346f, - 0.179848253726959f, 0.384061008691788f, 0.180142924189568f, 0.384306460618973f, - 0.180437773466110f, 0.384551674127579f, 0.180732816457748f, 0.384796649217606f, - 0.181028053164482f, 0.385041415691376f, 0.181323468685150f, 0.385285943746567f, - 0.181619063019753f, 0.385530263185501f, 0.181914865970612f, 0.385774344205856f, - 0.182210832834244f, 0.386018186807632f, 0.182507008314133f, 0.386261820793152f, - 0.182803362607956f, 0.386505216360092f, 0.183099895715714f, 0.386748403310776f, - 0.183396622538567f, 0.386991351842880f, 0.183693528175354f, 0.387234061956406f, - 0.183990627527237f, 0.387476563453674f, 0.184287920594215f, 0.387718826532364f, - 0.184585392475128f, 0.387960851192474f, 0.184883043169975f, 0.388202667236328f, - 0.185180887579918f, 0.388444244861603f, 0.185478910803795f, 0.388685584068298f, - 0.185777112841606f, 0.388926714658737f, 0.186075508594513f, 0.389167606830597f, - 0.186374098062515f, 0.389408260583878f, 0.186672851443291f, 0.389648675918579f, - 0.186971798539162f, 0.389888882637024f, 0.187270939350128f, 0.390128880739212f, - 0.187570258975029f, 0.390368610620499f, 0.187869757413864f, 0.390608131885529f, - 0.188169434666634f, 0.390847414731979f, 0.188469305634499f, 0.391086459159851f, - 0.188769355416298f, 0.391325294971466f, 0.189069598913193f, 0.391563892364502f, - 0.189370006322861f, 0.391802251338959f, 0.189670607447624f, 0.392040401697159f, - 0.189971387386322f, 0.392278283834457f, 0.190272361040115f, 0.392515957355499f, - 0.190573498606682f, 0.392753422260284f, 0.190874829888344f, 0.392990618944168f, - 0.191176339983940f, 0.393227607011795f, 0.191478043794632f, 0.393464356660843f, - 0.191779911518097f, 0.393700867891312f, 0.192081972956657f, 0.393937170505524f, - 0.192384198307991f, 0.394173204898834f, 0.192686617374420f, 0.394409030675888f, - 0.192989215254784f, 0.394644618034363f, 0.193292006850243f, 0.394879996776581f, - 0.193594962358475f, 0.395115107297897f, 0.193898096680641f, 0.395350009202957f, - 0.194201424717903f, 0.395584672689438f, 0.194504916667938f, 0.395819097757339f, - 0.194808602333069f, 0.396053284406662f, 0.195112451910973f, 0.396287262439728f, - 0.195416495203972f, 0.396520972251892f, 0.195720717310905f, 0.396754473447800f, - 0.196025103330612f, 0.396987736225128f, 0.196329683065414f, 0.397220760583878f, - 0.196634441614151f, 0.397453576326370f, 0.196939364075661f, 0.397686123847961f, - 0.197244480252266f, 0.397918462753296f, 0.197549775242805f, 0.398150533437729f, - 0.197855234146118f, 0.398382395505905f, 0.198160871863365f, 0.398614019155502f, - 0.198466703295708f, 0.398845434188843f, 0.198772698640823f, 0.399076581001282f, - 0.199078872799873f, 0.399307489395142f, 0.199385225772858f, 0.399538189172745f, - 0.199691757559776f, 0.399768620729446f, 0.199998468160629f, 0.399998843669891f, - 0.200305357575417f, 0.400228828191757f, 0.200612410902977f, 0.400458574295044f, - 0.200919643044472f, 0.400688081979752f, 0.201227053999901f, 0.400917351245880f, - 0.201534643769264f, 0.401146411895752f, 0.201842412352562f, 0.401375204324722f, - 0.202150344848633f, 0.401603758335114f, 0.202458456158638f, 0.401832103729248f, - 0.202766746282578f, 0.402060180902481f, 0.203075215220451f, 0.402288049459457f, - 0.203383848071098f, 0.402515679597855f, 0.203692659735680f, 0.402743041515350f, - 0.204001650214195f, 0.402970194816589f, 0.204310819506645f, 0.403197109699249f, - 0.204620152711868f, 0.403423786163330f, 0.204929664731026f, 0.403650224208832f, - 0.205239340662956f, 0.403876423835754f, 0.205549195408821f, 0.404102355241776f, - 0.205859228968620f, 0.404328078031540f, 0.206169426441193f, 0.404553562402725f, - 0.206479802727699f, 0.404778808355331f, 0.206790357828140f, 0.405003815889359f, - 0.207101076841354f, 0.405228585004807f, 0.207411959767342f, 0.405453115701675f, - 0.207723021507263f, 0.405677437782288f, 0.208034262061119f, 0.405901491641998f, - 0.208345666527748f, 0.406125307083130f, 0.208657249808311f, 0.406348884105682f, - 0.208969011902809f, 0.406572192907333f, 0.209280923008919f, 0.406795293092728f, - 0.209593027830124f, 0.407018154859543f, 0.209905281662941f, 0.407240778207779f, - 0.210217714309692f, 0.407463163137436f, 0.210530325770378f, 0.407685309648514f, - 0.210843101143837f, 0.407907217741013f, 0.211156040430069f, 0.408128857612610f, - 0.211469158530235f, 0.408350288867950f, 0.211782455444336f, 0.408571451902390f, - 0.212095901370049f, 0.408792406320572f, 0.212409526109695f, 0.409013092517853f, - 0.212723329663277f, 0.409233570098877f, 0.213037282228470f, 0.409453779459000f, - 0.213351413607597f, 0.409673750400543f, 0.213665723800659f, 0.409893482923508f, - 0.213980183005333f, 0.410112977027893f, 0.214294821023941f, 0.410332232713699f, - 0.214609622955322f, 0.410551249980927f, 0.214924603700638f, 0.410770028829575f, - 0.215239733457565f, 0.410988569259644f, 0.215555042028427f, 0.411206841468811f, - 0.215870529413223f, 0.411424905061722f, 0.216186165809631f, 0.411642700433731f, - 0.216501981019974f, 0.411860257387161f, 0.216817945241928f, 0.412077575922012f, - 0.217134088277817f, 0.412294656038284f, 0.217450410127640f, 0.412511497735977f, - 0.217766880989075f, 0.412728071212769f, 0.218083515763283f, 0.412944436073303f, - 0.218400329351425f, 0.413160532712936f, 0.218717306852341f, 0.413376390933990f, - 0.219034433364868f, 0.413592010736465f, 0.219351738691330f, 0.413807392120361f, - 0.219669207930565f, 0.414022535085678f, 0.219986841082573f, 0.414237409830093f, - 0.220304638147354f, 0.414452046155930f, 0.220622614026070f, 0.414666473865509f, - 0.220940738916397f, 0.414880603551865f, 0.221259027719498f, 0.415094524621964f, - 0.221577480435371f, 0.415308207273483f, 0.221896097064018f, 0.415521621704102f, - 0.222214877605438f, 0.415734797716141f, 0.222533836960793f, 0.415947735309601f, - 0.222852945327759f, 0.416160434484482f, 0.223172217607498f, 0.416372895240784f, - 0.223491653800011f, 0.416585087776184f, 0.223811239004135f, 0.416797041893005f, - 0.224131003022194f, 0.417008757591248f, 0.224450930953026f, 0.417220205068588f, - 0.224771007895470f, 0.417431443929672f, 0.225091263651848f, 0.417642414569855f, - 0.225411668419838f, 0.417853146791458f, 0.225732237100601f, 0.418063640594482f, - 0.226052969694138f, 0.418273866176605f, 0.226373866200447f, 0.418483853340149f, - 0.226694911718369f, 0.418693602085114f, 0.227016136050224f, 0.418903112411499f, - 0.227337509393692f, 0.419112354516983f, 0.227659046649933f, 0.419321358203888f, - 0.227980732917786f, 0.419530123472214f, 0.228302597999573f, 0.419738620519638f, - 0.228624612092972f, 0.419946908950806f, 0.228946775197983f, 0.420154929161072f, - 0.229269117116928f, 0.420362681150436f, 0.229591608047485f, 0.420570224523544f, - 0.229914262890816f, 0.420777499675751f, 0.230237081646919f, 0.420984506607056f, - 0.230560049414635f, 0.421191304922104f, 0.230883181095123f, 0.421397835016251f, - 0.231206461787224f, 0.421604126691818f, 0.231529906392097f, 0.421810150146484f, - 0.231853514909744f, 0.422015935182571f, 0.232177272439003f, 0.422221481800079f, - 0.232501193881035f, 0.422426789999008f, 0.232825264334679f, 0.422631829977036f, - 0.233149498701096f, 0.422836631536484f, 0.233473882079124f, 0.423041164875031f, - 0.233798429369926f, 0.423245459794998f, 0.234123140573502f, 0.423449516296387f, - 0.234448000788689f, 0.423653304576874f, 0.234773010015488f, 0.423856884241104f, - 0.235098183155060f, 0.424060165882111f, 0.235423520207405f, 0.424263238906860f, - 0.235749006271362f, 0.424466013908386f, 0.236074641346931f, 0.424668580293655f, - 0.236400425434113f, 0.424870878458023f, 0.236726388335228f, 0.425072938203812f, - 0.237052485346794f, 0.425274729728699f, 0.237378746271133f, 0.425476282835007f, - 0.237705156207085f, 0.425677597522736f, 0.238031730055809f, 0.425878643989563f, - 0.238358452916145f, 0.426079452037811f, 0.238685324788094f, 0.426279991865158f, - 0.239012360572815f, 0.426480293273926f, 0.239339530467987f, 0.426680356264114f, - 0.239666879177094f, 0.426880151033401f, 0.239994361996651f, 0.427079707384110f, - 0.240322008728981f, 0.427278995513916f, 0.240649804472923f, 0.427478045225143f, - 0.240977749228477f, 0.427676826715469f, 0.241305842995644f, 0.427875369787216f, - 0.241634100675583f, 0.428073674440384f, 0.241962507367134f, 0.428271710872650f, - 0.242291063070297f, 0.428469479084015f, 0.242619767785072f, 0.428667008876801f, - 0.242948621511459f, 0.428864300251007f, 0.243277639150620f, 0.429061323404312f, - 0.243606805801392f, 0.429258108139038f, 0.243936106562614f, 0.429454624652863f, - 0.244265571236610f, 0.429650902748108f, 0.244595184922218f, 0.429846942424774f, - 0.244924947619438f, 0.430042684078217f, 0.245254859328270f, 0.430238217115402f, - 0.245584934949875f, 0.430433481931686f, 0.245915144681931f, 0.430628478527069f, - 0.246245503425598f, 0.430823236703873f, 0.246576011180878f, 0.431017726659775f, - 0.246906682848930f, 0.431211978197098f, 0.247237488627434f, 0.431405961513519f, - 0.247568443417549f, 0.431599706411362f, 0.247899547219276f, 0.431793183088303f, - 0.248230814933777f, 0.431986421346664f, 0.248562216758728f, 0.432179391384125f, - 0.248893767595291f, 0.432372123003006f, 0.249225467443466f, 0.432564586400986f, - 0.249557301402092f, 0.432756811380386f, 0.249889299273491f, 0.432948768138886f, - 0.250221431255341f, 0.433140486478806f, 0.250553727149963f, 0.433331936597824f, - 0.250886172056198f, 0.433523118495941f, 0.251218736171722f, 0.433714061975479f, - 0.251551479101181f, 0.433904737234116f, 0.251884341239929f, 0.434095174074173f, - 0.252217382192612f, 0.434285342693329f, 0.252550542354584f, 0.434475272893906f, - 0.252883851528168f, 0.434664934873581f, 0.253217309713364f, 0.434854328632355f, - 0.253550916910172f, 0.435043483972549f, 0.253884643316269f, 0.435232400894165f, - 0.254218548536301f, 0.435421019792557f, 0.254552572965622f, 0.435609430074692f, - 0.254886746406555f, 0.435797542333603f, 0.255221068859100f, 0.435985416173935f, - 0.255555540323257f, 0.436173021793365f, 0.255890160799026f, 0.436360388994217f, - 0.256224930286407f, 0.436547487974167f, 0.256559818983078f, 0.436734348535538f, - 0.256894856691360f, 0.436920911073685f, 0.257230043411255f, 0.437107264995575f, - 0.257565379142761f, 0.437293320894241f, 0.257900834083557f, 0.437479138374329f, - 0.258236467838287f, 0.437664687633514f, 0.258572220802307f, 0.437849998474121f, - 0.258908122777939f, 0.438035041093826f, 0.259244143962860f, 0.438219845294952f, - 0.259580343961716f, 0.438404351472855f, 0.259916663169861f, 0.438588619232178f, - 0.260253131389618f, 0.438772648572922f, 0.260589718818665f, 0.438956409692764f, - 0.260926485061646f, 0.439139902591705f, 0.261263370513916f, 0.439323127269745f, - 0.261600375175476f, 0.439506113529205f, 0.261937558650970f, 0.439688831567764f, - 0.262274861335754f, 0.439871311187744f, 0.262612313032150f, 0.440053492784500f, - 0.262949883937836f, 0.440235435962677f, 0.263287603855133f, 0.440417140722275f, - 0.263625472784042f, 0.440598547458649f, 0.263963490724564f, 0.440779715776443f, - 0.264301627874374f, 0.440960645675659f, 0.264639914035797f, 0.441141277551651f, - 0.264978319406509f, 0.441321671009064f, 0.265316903591156f, 0.441501796245575f, - 0.265655577182770f, 0.441681683063507f, 0.265994429588318f, 0.441861271858215f, - 0.266333401203156f, 0.442040622234344f, 0.266672492027283f, 0.442219734191895f, - 0.267011761665344f, 0.442398548126221f, 0.267351150512695f, 0.442577123641968f, - 0.267690658569336f, 0.442755430936813f, 0.268030315637589f, 0.442933470010757f, - 0.268370121717453f, 0.443111270666122f, 0.268710047006607f, 0.443288803100586f, - 0.269050091505051f, 0.443466067314148f, 0.269390314817429f, 0.443643063306808f, - 0.269730657339096f, 0.443819820880890f, 0.270071119070053f, 0.443996280431747f, - 0.270411729812622f, 0.444172531366348f, 0.270752459764481f, 0.444348484277725f, - 0.271093338727951f, 0.444524168968201f, 0.271434366703033f, 0.444699615240097f, - 0.271775513887405f, 0.444874793291092f, 0.272116780281067f, 0.445049703121185f, - 0.272458195686340f, 0.445224374532700f, 0.272799760103226f, 0.445398747920990f, - 0.273141443729401f, 0.445572882890701f, 0.273483246564865f, 0.445746749639511f, - 0.273825198411942f, 0.445920348167419f, 0.274167299270630f, 0.446093708276749f, - 0.274509519338608f, 0.446266770362854f, 0.274851858615875f, 0.446439594030380f, - 0.275194346904755f, 0.446612149477005f, 0.275536954402924f, 0.446784436702728f, - 0.275879681110382f, 0.446956485509872f, 0.276222556829453f, 0.447128236293793f, - 0.276565581560135f, 0.447299748659134f, 0.276908725500107f, 0.447470992803574f, - 0.277251988649368f, 0.447641968727112f, 0.277595400810242f, 0.447812676429749f, - 0.277938932180405f, 0.447983115911484f, 0.278282582759857f, 0.448153316974640f, - 0.278626382350922f, 0.448323249816895f, 0.278970301151276f, 0.448492884635925f, - 0.279314368963242f, 0.448662281036377f, 0.279658555984497f, 0.448831409215927f, - 0.280002862215042f, 0.449000298976898f, 0.280347317457199f, 0.449168890714645f, - 0.280691891908646f, 0.449337244033813f, 0.281036585569382f, 0.449505299329758f, - 0.281381398439407f, 0.449673116207123f, 0.281726360321045f, 0.449840664863586f, - 0.282071471214294f, 0.450007945299149f, 0.282416671514511f, 0.450174957513809f, - 0.282762020826340f, 0.450341701507568f, 0.283107489347458f, 0.450508207082748f, - 0.283453077077866f, 0.450674414634705f, 0.283798813819885f, 0.450840383768082f, - 0.284144669771194f, 0.451006084680557f, 0.284490644931793f, 0.451171487569809f, - 0.284836769104004f, 0.451336652040482f, 0.285182982683182f, 0.451501548290253f, - 0.285529345273972f, 0.451666176319122f, 0.285875827074051f, 0.451830536127090f, - 0.286222457885742f, 0.451994657516479f, 0.286569178104401f, 0.452158480882645f, - 0.286916047334671f, 0.452322036027908f, 0.287263035774231f, 0.452485352754593f, - 0.287610173225403f, 0.452648371458054f, 0.287957400083542f, 0.452811151742935f, - 0.288304775953293f, 0.452973634004593f, 0.288652241230011f, 0.453135877847672f, - 0.288999855518341f, 0.453297853469849f, 0.289347589015961f, 0.453459560871124f, - 0.289695471525192f, 0.453621000051498f, 0.290043443441391f, 0.453782171010971f, - 0.290391564369202f, 0.453943043947220f, 0.290739774703979f, 0.454103678464890f, - 0.291088134050369f, 0.454264044761658f, 0.291436612606049f, 0.454424172639847f, - 0.291785210371017f, 0.454584002494812f, 0.292133957147598f, 0.454743564128876f, - 0.292482793331146f, 0.454902857542038f, 0.292831748723984f, 0.455061882734299f, - 0.293180853128433f, 0.455220639705658f, 0.293530046939850f, 0.455379128456116f, - 0.293879389762878f, 0.455537378787994f, 0.294228851795197f, 0.455695331096649f, - 0.294578403234482f, 0.455853015184402f, 0.294928103685379f, 0.456010431051254f, - 0.295277923345566f, 0.456167578697205f, 0.295627862215042f, 0.456324487924576f, - 0.295977920293808f, 0.456481099128723f, 0.296328097581863f, 0.456637442111969f, - 0.296678394079208f, 0.456793516874313f, 0.297028809785843f, 0.456949323415756f, - 0.297379344701767f, 0.457104891538620f, 0.297729998826981f, 0.457260161638260f, - 0.298080772161484f, 0.457415163516998f, 0.298431664705276f, 0.457569897174835f, - 0.298782676458359f, 0.457724362611771f, 0.299133807420731f, 0.457878559827805f, - 0.299485057592392f, 0.458032488822937f, 0.299836426973343f, 0.458186149597168f, - 0.300187885761261f, 0.458339542150497f, 0.300539493560791f, 0.458492636680603f, - 0.300891220569611f, 0.458645492792130f, 0.301243066787720f, 0.458798080682755f, - 0.301595002412796f, 0.458950400352478f, 0.301947087049484f, 0.459102421998978f, - 0.302299261093140f, 0.459254205226898f, 0.302651554346085f, 0.459405690431595f, - 0.303003966808319f, 0.459556937217712f, 0.303356528282166f, 0.459707885980606f, - 0.303709149360657f, 0.459858566522598f, 0.304061919450760f, 0.460008978843689f, - 0.304414808750153f, 0.460159152746201f, 0.304767817258835f, 0.460309028625488f, - 0.305120915174484f, 0.460458606481552f, 0.305474132299423f, 0.460607945919037f, - 0.305827468633652f, 0.460757017135620f, 0.306180924177170f, 0.460905820131302f, - 0.306534498929977f, 0.461054325103760f, 0.306888192892075f, 0.461202591657639f, - 0.307241976261139f, 0.461350560188293f, 0.307595878839493f, 0.461498260498047f, - 0.307949900627136f, 0.461645722389221f, 0.308304041624069f, 0.461792886257172f, - 0.308658272027969f, 0.461939752101898f, 0.309012651443481f, 0.462086379528046f, - 0.309367120265961f, 0.462232738733292f, 0.309721708297729f, 0.462378799915314f, - 0.310076385736465f, 0.462524622678757f, 0.310431212186813f, 0.462670147418976f, - 0.310786128044128f, 0.462815403938293f, 0.311141163110733f, 0.462960392236710f, - 0.311496287584305f, 0.463105112314224f, 0.311851561069489f, 0.463249564170837f, - 0.312206923961639f, 0.463393747806549f, 0.312562376260757f, 0.463537633419037f, - 0.312917977571487f, 0.463681250810623f, 0.313273668289185f, 0.463824629783630f, - 0.313629478216171f, 0.463967710733414f, 0.313985377550125f, 0.464110493659973f, - 0.314341396093369f, 0.464253038167953f, 0.314697533845901f, 0.464395314455032f, - 0.315053790807724f, 0.464537292718887f, 0.315410137176514f, 0.464679002761841f, - 0.315766572952271f, 0.464820444583893f, 0.316123157739639f, 0.464961618185043f, - 0.316479831933975f, 0.465102523565292f, 0.316836595535278f, 0.465243130922318f, - 0.317193508148193f, 0.465383470058441f, 0.317550510168076f, 0.465523540973663f, - 0.317907601594925f, 0.465663343667984f, 0.318264812231064f, 0.465802878141403f, - 0.318622142076492f, 0.465942144393921f, 0.318979561328888f, 0.466081112623215f, - 0.319337099790573f, 0.466219812631607f, 0.319694727659225f, 0.466358244419098f, - 0.320052474737167f, 0.466496407985687f, 0.320410341024399f, 0.466634273529053f, - 0.320768296718597f, 0.466771900653839f, 0.321126341819763f, 0.466909229755402f, - 0.321484506130219f, 0.467046260833740f, 0.321842789649963f, 0.467183053493500f, - 0.322201162576675f, 0.467319577932358f, 0.322559654712677f, 0.467455804347992f, - 0.322918236255646f, 0.467591762542725f, 0.323276937007904f, 0.467727422714233f, - 0.323635727167130f, 0.467862844467163f, 0.323994606733322f, 0.467997968196869f, - 0.324353635311127f, 0.468132823705673f, 0.324712723493576f, 0.468267410993576f, - 0.325071930885315f, 0.468401730060577f, 0.325431257486343f, 0.468535751104355f, - 0.325790673494339f, 0.468669503927231f, 0.326150178909302f, 0.468802988529205f, - 0.326509803533554f, 0.468936175107956f, 0.326869517564774f, 0.469069123268127f, - 0.327229350805283f, 0.469201773405075f, 0.327589273452759f, 0.469334155321121f, - 0.327949285507202f, 0.469466239213943f, 0.328309416770935f, 0.469598054885864f, - 0.328669637441635f, 0.469729602336884f, 0.329029977321625f, 0.469860881567001f, - 0.329390406608582f, 0.469991862773895f, 0.329750925302505f, 0.470122605562210f, - 0.330111563205719f, 0.470253020524979f, 0.330472290515900f, 0.470383197069168f, - 0.330833107233047f, 0.470513075590134f, 0.331194043159485f, 0.470642685890198f, - 0.331555068492889f, 0.470772027969360f, 0.331916213035584f, 0.470901101827621f, - 0.332277417182922f, 0.471029877662659f, 0.332638740539551f, 0.471158385276794f, - 0.333000183105469f, 0.471286594867706f, 0.333361685276031f, 0.471414536237717f, - 0.333723306655884f, 0.471542209386826f, 0.334085017442703f, 0.471669614315033f, - 0.334446847438812f, 0.471796721220016f, 0.334808766841888f, 0.471923559904099f, - 0.335170775651932f, 0.472050130367279f, 0.335532873868942f, 0.472176402807236f, - 0.335895091295242f, 0.472302407026291f, 0.336257368326187f, 0.472428143024445f, - 0.336619764566422f, 0.472553610801697f, 0.336982280015945f, 0.472678780555725f, - 0.337344855070114f, 0.472803652286530f, 0.337707549333572f, 0.472928285598755f, - 0.338070303201675f, 0.473052620887756f, 0.338433176279068f, 0.473176687955856f, - 0.338796168565750f, 0.473300457000732f, 0.339159220457077f, 0.473423957824707f, - 0.339522391557693f, 0.473547190427780f, 0.339885622262955f, 0.473670125007629f, - 0.340248972177505f, 0.473792791366577f, 0.340612411499023f, 0.473915189504623f, - 0.340975970029831f, 0.474037289619446f, 0.341339588165283f, 0.474159121513367f, - 0.341703325510025f, 0.474280685186386f, 0.342067122459412f, 0.474401950836182f, - 0.342431038618088f, 0.474522948265076f, 0.342795044183731f, 0.474643647670746f, - 0.343159139156342f, 0.474764078855515f, 0.343523323535919f, 0.474884241819382f, - 0.343887597322464f, 0.475004136562347f, 0.344251960515976f, 0.475123733282089f, - 0.344616413116455f, 0.475243031978607f, 0.344980984926224f, 0.475362062454224f, - 0.345345616340637f, 0.475480824708939f, 0.345710366964340f, 0.475599318742752f, - 0.346075177192688f, 0.475717514753342f, 0.346440106630325f, 0.475835442543030f, - 0.346805095672607f, 0.475953072309494f, 0.347170203924179f, 0.476070433855057f, - 0.347535371780396f, 0.476187497377396f, 0.347900658845901f, 0.476304292678833f, - 0.348266035318375f, 0.476420819759369f, 0.348631471395493f, 0.476537048816681f, - 0.348997026681900f, 0.476653009653091f, 0.349362671375275f, 0.476768702268600f, - 0.349728375673294f, 0.476884096860886f, 0.350094199180603f, 0.476999223232269f, - 0.350460082292557f, 0.477114051580429f, 0.350826084613800f, 0.477228611707687f, - 0.351192146539688f, 0.477342873811722f, 0.351558297872543f, 0.477456867694855f, - 0.351924568414688f, 0.477570593357086f, 0.352290898561478f, 0.477684020996094f, - 0.352657318115234f, 0.477797180414200f, 0.353023827075958f, 0.477910041809082f, - 0.353390425443649f, 0.478022634983063f, 0.353757113218308f, 0.478134930133820f, - 0.354123860597610f, 0.478246957063675f, 0.354490727186203f, 0.478358715772629f, - 0.354857653379440f, 0.478470176458359f, 0.355224698781967f, 0.478581339120865f, - 0.355591803789139f, 0.478692263364792f, 0.355958998203278f, 0.478802859783173f, - 0.356326282024384f, 0.478913217782974f, 0.356693625450134f, 0.479023247957230f, - 0.357061088085175f, 0.479133039712906f, 0.357428610324860f, 0.479242533445358f, - 0.357796221971512f, 0.479351729154587f, 0.358163923025131f, 0.479460656642914f, - 0.358531713485718f, 0.479569315910339f, 0.358899593353271f, 0.479677677154541f, - 0.359267532825470f, 0.479785770177841f, 0.359635561704636f, 0.479893565177917f, - 0.360003679990768f, 0.480001062154770f, 0.360371887683868f, 0.480108320713043f, - 0.360740154981613f, 0.480215251445770f, 0.361108511686325f, 0.480321943759918f, - 0.361476957798004f, 0.480428308248520f, 0.361845493316650f, 0.480534434318542f, - 0.362214088439941f, 0.480640232563019f, 0.362582772970200f, 0.480745792388916f, - 0.362951546907425f, 0.480851024389267f, 0.363320380449295f, 0.480956017971039f, - 0.363689333200455f, 0.481060713529587f, 0.364058345556259f, 0.481165111064911f, - 0.364427417516708f, 0.481269240379334f, 0.364796578884125f, 0.481373071670532f, - 0.365165829658508f, 0.481476634740829f, 0.365535169839859f, 0.481579899787903f, - 0.365904569625854f, 0.481682896614075f, 0.366274058818817f, 0.481785595417023f, - 0.366643607616425f, 0.481888025999069f, 0.367013275623322f, 0.481990188360214f, - 0.367382973432541f, 0.482092022895813f, 0.367752790451050f, 0.482193619012833f, - 0.368122667074203f, 0.482294887304306f, 0.368492603302002f, 0.482395917177200f, - 0.368862658739090f, 0.482496619224548f, 0.369232743978500f, 0.482597053050995f, - 0.369602948427200f, 0.482697218656540f, 0.369973212480545f, 0.482797086238861f, - 0.370343536138535f, 0.482896685600281f, 0.370713949203491f, 0.482995986938477f, - 0.371084451675415f, 0.483094990253448f, 0.371455013751984f, 0.483193725347519f, - 0.371825665235519f, 0.483292192220688f, 0.372196376323700f, 0.483390361070633f, - 0.372567176818848f, 0.483488231897354f, 0.372938036918640f, 0.483585834503174f, - 0.373308986425400f, 0.483683139085770f, 0.373679995536804f, 0.483780175447464f, - 0.374051094055176f, 0.483876913785934f, 0.374422252178192f, 0.483973383903503f, - 0.374793499708176f, 0.484069555997849f, 0.375164806842804f, 0.484165430068970f, - 0.375536203384399f, 0.484261035919189f, 0.375907659530640f, 0.484356373548508f, - 0.376279205083847f, 0.484451413154602f, 0.376650810241699f, 0.484546154737473f, - 0.377022475004196f, 0.484640628099442f, 0.377394229173660f, 0.484734803438187f, - 0.377766042947769f, 0.484828680753708f, 0.378137946128845f, 0.484922289848328f, - 0.378509908914566f, 0.485015630722046f, 0.378881961107254f, 0.485108673572540f, - 0.379254043102264f, 0.485201418399811f, 0.379626244306564f, 0.485293895006180f, - 0.379998475313187f, 0.485386073589325f, 0.380370795726776f, 0.485477954149246f, - 0.380743205547333f, 0.485569566488266f, 0.381115674972534f, 0.485660910606384f, - 0.381488204002380f, 0.485751956701279f, 0.381860792636871f, 0.485842704772949f, - 0.382233470678329f, 0.485933154821396f, 0.382606208324432f, 0.486023366451263f, - 0.382979035377502f, 0.486113250255585f, 0.383351892232895f, 0.486202865839005f, - 0.383724838495255f, 0.486292183399200f, 0.384097874164581f, 0.486381232738495f, - 0.384470939636230f, 0.486469984054565f, 0.384844094514847f, 0.486558437347412f, - 0.385217308998108f, 0.486646622419357f, 0.385590612888336f, 0.486734509468079f, - 0.385963946580887f, 0.486822128295898f, 0.386337369680405f, 0.486909449100494f, - 0.386710882186890f, 0.486996471881866f, 0.387084424495697f, 0.487083226442337f, - 0.387458056211472f, 0.487169682979584f, 0.387831717729568f, 0.487255871295929f, - 0.388205498456955f, 0.487341761589050f, 0.388579308986664f, 0.487427353858948f, - 0.388953179121017f, 0.487512677907944f, 0.389327138662338f, 0.487597703933716f, - 0.389701157808304f, 0.487682431936264f, 0.390075236558914f, 0.487766891717911f, - 0.390449374914169f, 0.487851053476334f, 0.390823602676392f, 0.487934947013855f, - 0.391197860240936f, 0.488018542528152f, 0.391572207212448f, 0.488101840019226f, - 0.391946613788605f, 0.488184869289398f, 0.392321079969406f, 0.488267600536346f, - 0.392695605754852f, 0.488350033760071f, 0.393070191144943f, 0.488432198762894f, - 0.393444836139679f, 0.488514065742493f, 0.393819570541382f, 0.488595664501190f, - 0.394194334745407f, 0.488676935434341f, 0.394569188356400f, 0.488757967948914f, - 0.394944071769714f, 0.488838672637939f, 0.395319044589996f, 0.488919109106064f, - 0.395694077014923f, 0.488999247550964f, 0.396069169044495f, 0.489079117774963f, - 0.396444320678711f, 0.489158689975739f, 0.396819531917572f, 0.489237964153290f, - 0.397194802761078f, 0.489316970109940f, 0.397570133209229f, 0.489395678043365f, - 0.397945523262024f, 0.489474087953568f, 0.398320972919464f, 0.489552229642868f, - 0.398696482181549f, 0.489630073308945f, 0.399072051048279f, 0.489707618951797f, - 0.399447679519653f, 0.489784896373749f, 0.399823367595673f, 0.489861875772476f, - 0.400199115276337f, 0.489938557147980f, 0.400574922561646f, 0.490014940500259f, - 0.400950789451599f, 0.490091055631638f, 0.401326715946198f, 0.490166902542114f, - 0.401702702045441f, 0.490242421627045f, 0.402078747749329f, 0.490317672491074f, - 0.402454853057861f, 0.490392625331879f, 0.402830988168716f, 0.490467309951782f, - 0.403207212686539f, 0.490541696548462f, 0.403583467006683f, 0.490615785121918f, - 0.403959810733795f, 0.490689605474472f, 0.404336184263229f, 0.490763127803802f, - 0.404712617397308f, 0.490836352109909f, 0.405089110136032f, 0.490909278392792f, - 0.405465662479401f, 0.490981936454773f, 0.405842274427414f, 0.491054296493530f, - 0.406218945980072f, 0.491126358509064f, 0.406595647335052f, 0.491198152303696f, - 0.406972438097000f, 0.491269648075104f, 0.407349258661270f, 0.491340845823288f, - 0.407726138830185f, 0.491411775350571f, 0.408103078603745f, 0.491482406854630f, - 0.408480048179626f, 0.491552740335464f, 0.408857107162476f, 0.491622805595398f, - 0.409234195947647f, 0.491692543029785f, 0.409611344337463f, 0.491762012243271f, - 0.409988552331924f, 0.491831213235855f, 0.410365819931030f, 0.491900116205215f, - 0.410743117332459f, 0.491968721151352f, 0.411120474338531f, 0.492037028074265f, - 0.411497890949249f, 0.492105036973953f, 0.411875367164612f, 0.492172777652740f, - 0.412252873182297f, 0.492240220308304f, 0.412630438804626f, 0.492307394742966f, - 0.413008064031601f, 0.492374241352081f, 0.413385748863220f, 0.492440819740295f, - 0.413763463497162f, 0.492507129907608f, 0.414141237735748f, 0.492573112249374f, - 0.414519041776657f, 0.492638826370239f, 0.414896935224533f, 0.492704242467880f, - 0.415274858474731f, 0.492769360542297f, 0.415652841329575f, 0.492834210395813f, - 0.416030853986740f, 0.492898762226105f, 0.416408926248550f, 0.492963016033173f, - 0.416787058115005f, 0.493026971817017f, 0.417165219783783f, 0.493090659379959f, - 0.417543441057205f, 0.493154048919678f, 0.417921721935272f, 0.493217140436172f, - 0.418300032615662f, 0.493279963731766f, 0.418678402900696f, 0.493342459201813f, - 0.419056802988052f, 0.493404686450958f, 0.419435262680054f, 0.493466645479202f, - 0.419813781976700f, 0.493528276681900f, 0.420192331075668f, 0.493589639663696f, - 0.420570939779282f, 0.493650704622269f, 0.420949578285217f, 0.493711471557617f, - 0.421328276395798f, 0.493771970272064f, 0.421707004308701f, 0.493832170963287f, - 0.422085791826248f, 0.493892073631287f, 0.422464638948441f, 0.493951678276062f, - 0.422843515872955f, 0.494011014699936f, 0.423222452402115f, 0.494070053100586f, - 0.423601418733597f, 0.494128793478012f, 0.423980414867401f, 0.494187235832214f, - 0.424359470605850f, 0.494245409965515f, 0.424738585948944f, 0.494303256273270f, - 0.425117731094360f, 0.494360834360123f, 0.425496935844421f, 0.494418144226074f, - 0.425876170396805f, 0.494475126266479f, 0.426255434751511f, 0.494531840085983f, - 0.426634758710861f, 0.494588255882263f, 0.427014142274857f, 0.494644373655319f, - 0.427393525838852f, 0.494700223207474f, 0.427772998809814f, 0.494755744934082f, - 0.428152471780777f, 0.494810998439789f, 0.428532034158707f, 0.494865983724594f, - 0.428911596536636f, 0.494920641183853f, 0.429291218519211f, 0.494975030422211f, - 0.429670870304108f, 0.495029091835022f, 0.430050581693649f, 0.495082914829254f, - 0.430430322885513f, 0.495136409997940f, 0.430810123682022f, 0.495189607143402f, - 0.431189924478531f, 0.495242536067963f, 0.431569814682007f, 0.495295166969299f, - 0.431949704885483f, 0.495347499847412f, 0.432329654693604f, 0.495399564504623f, - 0.432709634304047f, 0.495451331138611f, 0.433089673519135f, 0.495502769947052f, - 0.433469742536545f, 0.495553970336914f, 0.433849841356277f, 0.495604842901230f, - 0.434229999780655f, 0.495655417442322f, 0.434610158205032f, 0.495705723762512f, - 0.434990376234055f, 0.495755732059479f, 0.435370653867722f, 0.495805442333221f, - 0.435750931501389f, 0.495854884386063f, 0.436131268739700f, 0.495903998613358f, - 0.436511665582657f, 0.495952844619751f, 0.436892062425613f, 0.496001392602921f, - 0.437272518873215f, 0.496049642562866f, 0.437653005123138f, 0.496097624301910f, - 0.438033521175385f, 0.496145308017731f, 0.438414067029953f, 0.496192663908005f, - 0.438794672489166f, 0.496239781379700f, 0.439175277948380f, 0.496286571025848f, - 0.439555943012238f, 0.496333062648773f, 0.439936667680740f, 0.496379286050797f, - 0.440317392349243f, 0.496425211429596f, 0.440698176622391f, 0.496470838785172f, - 0.441078960895538f, 0.496516168117523f, 0.441459804773331f, 0.496561229228973f, - 0.441840678453445f, 0.496605962514877f, 0.442221581935883f, 0.496650427579880f, - 0.442602545022964f, 0.496694594621658f, 0.442983508110046f, 0.496738493442535f, - 0.443364530801773f, 0.496782064437866f, 0.443745553493500f, 0.496825367212296f, - 0.444126635789871f, 0.496868371963501f, 0.444507747888565f, 0.496911078691483f, - 0.444888889789581f, 0.496953487396240f, 0.445270061492920f, 0.496995598077774f, - 0.445651292800903f, 0.497037440538406f, 0.446032524108887f, 0.497078984975815f, - 0.446413785219193f, 0.497120231389999f, 0.446795076131821f, 0.497161179780960f, - 0.447176426649094f, 0.497201830148697f, 0.447557777166367f, 0.497242212295532f, - 0.447939187288284f, 0.497282296419144f, 0.448320597410202f, 0.497322082519531f, - 0.448702067136765f, 0.497361570596695f, 0.449083566665649f, 0.497400760650635f, - 0.449465066194534f, 0.497439652681351f, 0.449846625328064f, 0.497478276491165f, - 0.450228184461594f, 0.497516602277756f, 0.450609803199768f, 0.497554630041122f, - 0.450991421937943f, 0.497592359781265f, 0.451373100280762f, 0.497629791498184f, - 0.451754778623581f, 0.497666954994202f, 0.452136516571045f, 0.497703820466995f, - 0.452518254518509f, 0.497740387916565f, 0.452900022268295f, 0.497776657342911f, - 0.453281819820404f, 0.497812628746033f, 0.453663676977158f, 0.497848302125931f, - 0.454045534133911f, 0.497883707284927f, 0.454427421092987f, 0.497918814420700f, - 0.454809308052063f, 0.497953623533249f, 0.455191254615784f, 0.497988134622574f, - 0.455573230981827f, 0.498022347688675f, 0.455955207347870f, 0.498056292533875f, - 0.456337243318558f, 0.498089909553528f, 0.456719279289246f, 0.498123258352280f, - 0.457101345062256f, 0.498156309127808f, 0.457483440637589f, 0.498189061880112f, - 0.457865566015244f, 0.498221516609192f, 0.458247691392899f, 0.498253703117371f, - 0.458629876375198f, 0.498285561800003f, 0.459012061357498f, 0.498317152261734f, - 0.459394276142120f, 0.498348444700241f, 0.459776520729065f, 0.498379439115524f, - 0.460158795118332f, 0.498410135507584f, 0.460541069507599f, 0.498440563678741f, - 0.460923373699188f, 0.498470664024353f, 0.461305707693100f, 0.498500496149063f, - 0.461688071489334f, 0.498530030250549f, 0.462070435285568f, 0.498559266328812f, - 0.462452858686447f, 0.498588204383850f, 0.462835282087326f, 0.498616874217987f, - 0.463217705488205f, 0.498645216226578f, 0.463600188493729f, 0.498673290014267f, - 0.463982671499252f, 0.498701065778732f, 0.464365184307098f, 0.498728543519974f, - 0.464747726917267f, 0.498755723237991f, 0.465130269527435f, 0.498782604932785f, - 0.465512841939926f, 0.498809218406677f, 0.465895414352417f, 0.498835533857346f, - 0.466278046369553f, 0.498861521482468f, 0.466660678386688f, 0.498887240886688f, - 0.467043310403824f, 0.498912662267685f, 0.467426002025604f, 0.498937815427780f, - 0.467808693647385f, 0.498962640762329f, 0.468191385269165f, 0.498987197875977f, - 0.468574106693268f, 0.499011427164078f, 0.468956857919693f, 0.499035388231277f, - 0.469339638948441f, 0.499059051275253f, 0.469722419977188f, 0.499082416296005f, - 0.470105201005936f, 0.499105513095856f, 0.470488041639328f, 0.499128282070160f, - 0.470870882272720f, 0.499150782823563f, 0.471253722906113f, 0.499172955751419f, - 0.471636593341827f, 0.499194860458374f, 0.472019463777542f, 0.499216467142105f, - 0.472402364015579f, 0.499237775802612f, 0.472785294055939f, 0.499258816242218f, - 0.473168224096298f, 0.499279528856277f, 0.473551183938980f, 0.499299973249435f, - 0.473934143781662f, 0.499320119619370f, 0.474317133426666f, 0.499339967966080f, - 0.474700123071671f, 0.499359518289566f, 0.475083142518997f, 0.499378770589828f, - 0.475466161966324f, 0.499397724866867f, 0.475849211215973f, 0.499416410923004f, - 0.476232260465622f, 0.499434769153595f, 0.476615339517593f, 0.499452859163284f, - 0.476998418569565f, 0.499470651149750f, 0.477381497621536f, 0.499488145112991f, - 0.477764606475830f, 0.499505341053009f, 0.478147745132446f, 0.499522238969803f, - 0.478530883789063f, 0.499538868665695f, 0.478914022445679f, 0.499555170536041f, - 0.479297190904617f, 0.499571204185486f, 0.479680359363556f, 0.499586939811707f, - 0.480063527822495f, 0.499602377414703f, 0.480446726083755f, 0.499617516994476f, - 0.480829954147339f, 0.499632388353348f, 0.481213152408600f, 0.499646931886673f, - 0.481596380472183f, 0.499661177396774f, 0.481979638338089f, 0.499675154685974f, - 0.482362866401672f, 0.499688833951950f, 0.482746154069901f, 0.499702215194702f, - 0.483129411935806f, 0.499715298414230f, 0.483512699604034f, 0.499728083610535f, - 0.483895987272263f, 0.499740600585938f, 0.484279274940491f, 0.499752789735794f, - 0.484662592411041f, 0.499764710664749f, 0.485045909881592f, 0.499776333570480f, - 0.485429257154465f, 0.499787658452988f, 0.485812574625015f, 0.499798685312271f, - 0.486195921897888f, 0.499809414148331f, 0.486579269170761f, 0.499819844961166f, - 0.486962646245956f, 0.499830007553101f, 0.487346023321152f, 0.499839842319489f, - 0.487729400396347f, 0.499849408864975f, 0.488112777471542f, 0.499858677387238f, - 0.488496154546738f, 0.499867647886276f, 0.488879561424255f, 0.499876320362091f, - 0.489262968301773f, 0.499884694814682f, 0.489646375179291f, 0.499892801046371f, - 0.490029782056808f, 0.499900579452515f, 0.490413218736649f, 0.499908089637756f, - 0.490796625614166f, 0.499915301799774f, 0.491180062294006f, 0.499922215938568f, - 0.491563498973846f, 0.499928832054138f, 0.491946935653687f, 0.499935150146484f, - 0.492330402135849f, 0.499941170215607f, 0.492713838815689f, 0.499946922063828f, - 0.493097305297852f, 0.499952346086502f, 0.493480771780014f, 0.499957501888275f, - 0.493864238262177f, 0.499962359666824f, 0.494247704744339f, 0.499966919422150f, - 0.494631171226501f, 0.499971181154251f, 0.495014637708664f, 0.499975144863129f, - 0.495398133993149f, 0.499978810548782f, 0.495781600475311f, 0.499982208013535f, - 0.496165096759796f, 0.499985307455063f, 0.496548563241959f, 0.499988079071045f, - 0.496932059526443f, 0.499990582466125f, 0.497315555810928f, 0.499992787837982f, - 0.497699022293091f, 0.499994695186615f, 0.498082518577576f, 0.499996334314346f, - 0.498466014862061f, 0.499997645616531f, 0.498849511146545f, 0.499998688697815f, - 0.499233007431030f, 0.499999403953552f, 0.499616503715515f, 0.499999850988388f, + 0.500000000000000f, -0.500000000000000f, 0.499616503715515f, + -0.499999850988388f, 0.499233007431030f, -0.499999403953552f, + 0.498849511146545f, -0.499998688697815f, 0.498466014862061f, + -0.499997645616531f, 0.498082518577576f, -0.499996334314346f, + 0.497699022293091f, -0.499994695186615f, 0.497315555810928f, + -0.499992787837982f, 0.496932059526443f, -0.499990582466125f, + 0.496548563241959f, -0.499988079071045f, 0.496165096759796f, + -0.499985307455063f, 0.495781600475311f, -0.499982208013535f, + 0.495398133993149f, -0.499978810548782f, 0.495014637708664f, + -0.499975144863129f, 0.494631171226501f, -0.499971181154251f, + 0.494247704744339f, -0.499966919422150f, 0.493864238262177f, + -0.499962359666824f, 0.493480771780014f, -0.499957501888275f, + 0.493097305297852f, -0.499952346086502f, 0.492713838815689f, + -0.499946922063828f, 0.492330402135849f, -0.499941170215607f, + 0.491946935653687f, -0.499935150146484f, 0.491563498973846f, + -0.499928832054138f, 0.491180062294006f, -0.499922215938568f, + 0.490796625614166f, -0.499915301799774f, 0.490413218736649f, + -0.499908089637756f, 0.490029782056808f, -0.499900579452515f, + 0.489646375179291f, -0.499892801046371f, 0.489262968301773f, + -0.499884694814682f, 0.488879561424255f, -0.499876320362091f, + 0.488496154546738f, -0.499867647886276f, 0.488112777471542f, + -0.499858677387238f, 0.487729400396347f, -0.499849408864975f, + 0.487346023321152f, -0.499839842319489f, 0.486962646245956f, + -0.499830007553101f, 0.486579269170761f, -0.499819844961166f, + 0.486195921897888f, -0.499809414148331f, 0.485812574625015f, + -0.499798685312271f, 0.485429257154465f, -0.499787658452988f, + 0.485045909881592f, -0.499776333570480f, 0.484662592411041f, + -0.499764710664749f, 0.484279274940491f, -0.499752789735794f, + 0.483895987272263f, -0.499740600585938f, 0.483512699604034f, + -0.499728083610535f, 0.483129411935806f, -0.499715298414230f, + 0.482746154069901f, -0.499702215194702f, 0.482362866401672f, + -0.499688833951950f, 0.481979638338089f, -0.499675154685974f, + 0.481596380472183f, -0.499661177396774f, 0.481213152408600f, + -0.499646931886673f, 0.480829954147339f, -0.499632388353348f, + 0.480446726083755f, -0.499617516994476f, 0.480063527822495f, + -0.499602377414703f, 0.479680359363556f, -0.499586939811707f, + 0.479297190904617f, -0.499571204185486f, 0.478914022445679f, + -0.499555170536041f, 0.478530883789063f, -0.499538868665695f, + 0.478147745132446f, -0.499522238969803f, 0.477764606475830f, + -0.499505341053009f, 0.477381497621536f, -0.499488145112991f, + 0.476998418569565f, -0.499470651149750f, 0.476615339517593f, + -0.499452859163284f, 0.476232260465622f, -0.499434769153595f, + 0.475849211215973f, -0.499416410923004f, 0.475466161966324f, + -0.499397724866867f, 0.475083142518997f, -0.499378770589828f, + 0.474700123071671f, -0.499359518289566f, 0.474317133426666f, + -0.499339967966080f, 0.473934143781662f, -0.499320119619370f, + 0.473551183938980f, -0.499299973249435f, 0.473168224096298f, + -0.499279528856277f, 0.472785294055939f, -0.499258816242218f, + 0.472402364015579f, -0.499237775802612f, 0.472019463777542f, + -0.499216467142105f, 0.471636593341827f, -0.499194860458374f, + 0.471253722906113f, -0.499172955751419f, 0.470870882272720f, + -0.499150782823563f, 0.470488041639328f, -0.499128282070160f, + 0.470105201005936f, -0.499105513095856f, 0.469722419977188f, + -0.499082416296005f, 0.469339638948441f, -0.499059051275253f, + 0.468956857919693f, -0.499035388231277f, 0.468574106693268f, + -0.499011427164078f, 0.468191385269165f, -0.498987197875977f, + 0.467808693647385f, -0.498962640762329f, 0.467426002025604f, + -0.498937815427780f, 0.467043310403824f, -0.498912662267685f, + 0.466660678386688f, -0.498887240886688f, 0.466278046369553f, + -0.498861521482468f, 0.465895414352417f, -0.498835533857346f, + 0.465512841939926f, -0.498809218406677f, 0.465130269527435f, + -0.498782604932785f, 0.464747726917267f, -0.498755723237991f, + 0.464365184307098f, -0.498728543519974f, 0.463982671499252f, + -0.498701065778732f, 0.463600188493729f, -0.498673290014267f, + 0.463217705488205f, -0.498645216226578f, 0.462835282087326f, + -0.498616874217987f, 0.462452858686447f, -0.498588204383850f, + 0.462070435285568f, -0.498559266328812f, 0.461688071489334f, + -0.498530030250549f, 0.461305707693100f, -0.498500496149063f, + 0.460923373699188f, -0.498470664024353f, 0.460541069507599f, + -0.498440563678741f, 0.460158795118332f, -0.498410135507584f, + 0.459776520729065f, -0.498379439115524f, 0.459394276142120f, + -0.498348444700241f, 0.459012061357498f, -0.498317152261734f, + 0.458629876375198f, -0.498285561800003f, 0.458247691392899f, + -0.498253703117371f, 0.457865566015244f, -0.498221516609192f, + 0.457483440637589f, -0.498189061880112f, 0.457101345062256f, + -0.498156309127808f, 0.456719279289246f, -0.498123258352280f, + 0.456337243318558f, -0.498089909553528f, 0.455955207347870f, + -0.498056292533875f, 0.455573230981827f, -0.498022347688675f, + 0.455191254615784f, -0.497988134622574f, 0.454809308052063f, + -0.497953623533249f, 0.454427421092987f, -0.497918814420700f, + 0.454045534133911f, -0.497883707284927f, 0.453663676977158f, + -0.497848302125931f, 0.453281819820404f, -0.497812628746033f, + 0.452900022268295f, -0.497776657342911f, 0.452518254518509f, + -0.497740387916565f, 0.452136516571045f, -0.497703820466995f, + 0.451754778623581f, -0.497666954994202f, 0.451373100280762f, + -0.497629791498184f, 0.450991421937943f, -0.497592359781265f, + 0.450609803199768f, -0.497554630041122f, 0.450228184461594f, + -0.497516602277756f, 0.449846625328064f, -0.497478276491165f, + 0.449465066194534f, -0.497439652681351f, 0.449083566665649f, + -0.497400760650635f, 0.448702067136765f, -0.497361570596695f, + 0.448320597410202f, -0.497322082519531f, 0.447939187288284f, + -0.497282296419144f, 0.447557777166367f, -0.497242212295532f, + 0.447176426649094f, -0.497201830148697f, 0.446795076131821f, + -0.497161179780960f, 0.446413785219193f, -0.497120231389999f, + 0.446032524108887f, -0.497078984975815f, 0.445651292800903f, + -0.497037440538406f, 0.445270061492920f, -0.496995598077774f, + 0.444888889789581f, -0.496953487396240f, 0.444507747888565f, + -0.496911078691483f, 0.444126635789871f, -0.496868371963501f, + 0.443745553493500f, -0.496825367212296f, 0.443364530801773f, + -0.496782064437866f, 0.442983508110046f, -0.496738493442535f, + 0.442602545022964f, -0.496694594621658f, 0.442221581935883f, + -0.496650427579880f, 0.441840678453445f, -0.496605962514877f, + 0.441459804773331f, -0.496561229228973f, 0.441078960895538f, + -0.496516168117523f, 0.440698176622391f, -0.496470838785172f, + 0.440317392349243f, -0.496425211429596f, 0.439936667680740f, + -0.496379286050797f, 0.439555943012238f, -0.496333062648773f, + 0.439175277948380f, -0.496286571025848f, 0.438794672489166f, + -0.496239781379700f, 0.438414067029953f, -0.496192663908005f, + 0.438033521175385f, -0.496145308017731f, 0.437653005123138f, + -0.496097624301910f, 0.437272518873215f, -0.496049642562866f, + 0.436892062425613f, -0.496001392602921f, 0.436511665582657f, + -0.495952844619751f, 0.436131268739700f, -0.495903998613358f, + 0.435750931501389f, -0.495854884386063f, 0.435370653867722f, + -0.495805442333221f, 0.434990376234055f, -0.495755732059479f, + 0.434610158205032f, -0.495705723762512f, 0.434229999780655f, + -0.495655417442322f, 0.433849841356277f, -0.495604842901230f, + 0.433469742536545f, -0.495553970336914f, 0.433089673519135f, + -0.495502769947052f, 0.432709634304047f, -0.495451331138611f, + 0.432329654693604f, -0.495399564504623f, 0.431949704885483f, + -0.495347499847412f, 0.431569814682007f, -0.495295166969299f, + 0.431189924478531f, -0.495242536067963f, 0.430810123682022f, + -0.495189607143402f, 0.430430322885513f, -0.495136409997940f, + 0.430050581693649f, -0.495082914829254f, 0.429670870304108f, + -0.495029091835022f, 0.429291218519211f, -0.494975030422211f, + 0.428911596536636f, -0.494920641183853f, 0.428532034158707f, + -0.494865983724594f, 0.428152471780777f, -0.494810998439789f, + 0.427772998809814f, -0.494755744934082f, 0.427393525838852f, + -0.494700223207474f, 0.427014142274857f, -0.494644373655319f, + 0.426634758710861f, -0.494588255882263f, 0.426255434751511f, + -0.494531840085983f, 0.425876170396805f, -0.494475126266479f, + 0.425496935844421f, -0.494418144226074f, 0.425117731094360f, + -0.494360834360123f, 0.424738585948944f, -0.494303256273270f, + 0.424359470605850f, -0.494245409965515f, 0.423980414867401f, + -0.494187235832214f, 0.423601418733597f, -0.494128793478012f, + 0.423222452402115f, -0.494070053100586f, 0.422843515872955f, + -0.494011014699936f, 0.422464638948441f, -0.493951678276062f, + 0.422085791826248f, -0.493892073631287f, 0.421707004308701f, + -0.493832170963287f, 0.421328276395798f, -0.493771970272064f, + 0.420949578285217f, -0.493711471557617f, 0.420570939779282f, + -0.493650704622269f, 0.420192331075668f, -0.493589639663696f, + 0.419813781976700f, -0.493528276681900f, 0.419435262680054f, + -0.493466645479202f, 0.419056802988052f, -0.493404686450958f, + 0.418678402900696f, -0.493342459201813f, 0.418300032615662f, + -0.493279963731766f, 0.417921721935272f, -0.493217140436172f, + 0.417543441057205f, -0.493154048919678f, 0.417165219783783f, + -0.493090659379959f, 0.416787058115005f, -0.493026971817017f, + 0.416408926248550f, -0.492963016033173f, 0.416030853986740f, + -0.492898762226105f, 0.415652841329575f, -0.492834210395813f, + 0.415274858474731f, -0.492769360542297f, 0.414896935224533f, + -0.492704242467880f, 0.414519041776657f, -0.492638826370239f, + 0.414141237735748f, -0.492573112249374f, 0.413763463497162f, + -0.492507129907608f, 0.413385748863220f, -0.492440819740295f, + 0.413008064031601f, -0.492374241352081f, 0.412630438804626f, + -0.492307394742966f, 0.412252873182297f, -0.492240220308304f, + 0.411875367164612f, -0.492172777652740f, 0.411497890949249f, + -0.492105036973953f, 0.411120474338531f, -0.492037028074265f, + 0.410743117332459f, -0.491968721151352f, 0.410365819931030f, + -0.491900116205215f, 0.409988552331924f, -0.491831213235855f, + 0.409611344337463f, -0.491762012243271f, 0.409234195947647f, + -0.491692543029785f, 0.408857107162476f, -0.491622805595398f, + 0.408480048179626f, -0.491552740335464f, 0.408103078603745f, + -0.491482406854630f, 0.407726138830185f, -0.491411775350571f, + 0.407349258661270f, -0.491340845823288f, 0.406972438097000f, + -0.491269648075104f, 0.406595647335052f, -0.491198152303696f, + 0.406218945980072f, -0.491126358509064f, 0.405842274427414f, + -0.491054296493530f, 0.405465662479401f, -0.490981936454773f, + 0.405089110136032f, -0.490909278392792f, 0.404712617397308f, + -0.490836352109909f, 0.404336184263229f, -0.490763127803802f, + 0.403959810733795f, -0.490689605474472f, 0.403583467006683f, + -0.490615785121918f, 0.403207212686539f, -0.490541696548462f, + 0.402830988168716f, -0.490467309951782f, 0.402454853057861f, + -0.490392625331879f, 0.402078747749329f, -0.490317672491074f, + 0.401702702045441f, -0.490242421627045f, 0.401326715946198f, + -0.490166902542114f, 0.400950789451599f, -0.490091055631638f, + 0.400574922561646f, -0.490014940500259f, 0.400199115276337f, + -0.489938557147980f, 0.399823367595673f, -0.489861875772476f, + 0.399447679519653f, -0.489784896373749f, 0.399072051048279f, + -0.489707618951797f, 0.398696482181549f, -0.489630073308945f, + 0.398320972919464f, -0.489552229642868f, 0.397945523262024f, + -0.489474087953568f, 0.397570133209229f, -0.489395678043365f, + 0.397194802761078f, -0.489316970109940f, 0.396819531917572f, + -0.489237964153290f, 0.396444320678711f, -0.489158689975739f, + 0.396069169044495f, -0.489079117774963f, 0.395694077014923f, + -0.488999247550964f, 0.395319044589996f, -0.488919109106064f, + 0.394944071769714f, -0.488838672637939f, 0.394569188356400f, + -0.488757967948914f, 0.394194334745407f, -0.488676935434341f, + 0.393819570541382f, -0.488595664501190f, 0.393444836139679f, + -0.488514065742493f, 0.393070191144943f, -0.488432198762894f, + 0.392695605754852f, -0.488350033760071f, 0.392321079969406f, + -0.488267600536346f, 0.391946613788605f, -0.488184869289398f, + 0.391572207212448f, -0.488101840019226f, 0.391197860240936f, + -0.488018542528152f, 0.390823602676392f, -0.487934947013855f, + 0.390449374914169f, -0.487851053476334f, 0.390075236558914f, + -0.487766891717911f, 0.389701157808304f, -0.487682431936264f, + 0.389327138662338f, -0.487597703933716f, 0.388953179121017f, + -0.487512677907944f, 0.388579308986664f, -0.487427353858948f, + 0.388205498456955f, -0.487341761589050f, 0.387831717729568f, + -0.487255871295929f, 0.387458056211472f, -0.487169682979584f, + 0.387084424495697f, -0.487083226442337f, 0.386710882186890f, + -0.486996471881866f, 0.386337369680405f, -0.486909449100494f, + 0.385963946580887f, -0.486822128295898f, 0.385590612888336f, + -0.486734509468079f, 0.385217308998108f, -0.486646622419357f, + 0.384844094514847f, -0.486558437347412f, 0.384470939636230f, + -0.486469984054565f, 0.384097874164581f, -0.486381232738495f, + 0.383724838495255f, -0.486292183399200f, 0.383351892232895f, + -0.486202865839005f, 0.382979035377502f, -0.486113250255585f, + 0.382606208324432f, -0.486023366451263f, 0.382233470678329f, + -0.485933154821396f, 0.381860792636871f, -0.485842704772949f, + 0.381488204002380f, -0.485751956701279f, 0.381115674972534f, + -0.485660910606384f, 0.380743205547333f, -0.485569566488266f, + 0.380370795726776f, -0.485477954149246f, 0.379998475313187f, + -0.485386073589325f, 0.379626244306564f, -0.485293895006180f, + 0.379254043102264f, -0.485201418399811f, 0.378881961107254f, + -0.485108673572540f, 0.378509908914566f, -0.485015630722046f, + 0.378137946128845f, -0.484922289848328f, 0.377766042947769f, + -0.484828680753708f, 0.377394229173660f, -0.484734803438187f, + 0.377022475004196f, -0.484640628099442f, 0.376650810241699f, + -0.484546154737473f, 0.376279205083847f, -0.484451413154602f, + 0.375907659530640f, -0.484356373548508f, 0.375536203384399f, + -0.484261035919189f, 0.375164806842804f, -0.484165430068970f, + 0.374793499708176f, -0.484069555997849f, 0.374422252178192f, + -0.483973383903503f, 0.374051094055176f, -0.483876913785934f, + 0.373679995536804f, -0.483780175447464f, 0.373308986425400f, + -0.483683139085770f, 0.372938036918640f, -0.483585834503174f, + 0.372567176818848f, -0.483488231897354f, 0.372196376323700f, + -0.483390361070633f, 0.371825665235519f, -0.483292192220688f, + 0.371455013751984f, -0.483193725347519f, 0.371084451675415f, + -0.483094990253448f, 0.370713949203491f, -0.482995986938477f, + 0.370343536138535f, -0.482896685600281f, 0.369973212480545f, + -0.482797086238861f, 0.369602948427200f, -0.482697218656540f, + 0.369232743978500f, -0.482597053050995f, 0.368862658739090f, + -0.482496619224548f, 0.368492603302002f, -0.482395917177200f, + 0.368122667074203f, -0.482294887304306f, 0.367752790451050f, + -0.482193619012833f, 0.367382973432541f, -0.482092022895813f, + 0.367013275623322f, -0.481990188360214f, 0.366643607616425f, + -0.481888025999069f, 0.366274058818817f, -0.481785595417023f, + 0.365904569625854f, -0.481682896614075f, 0.365535169839859f, + -0.481579899787903f, 0.365165829658508f, -0.481476634740829f, + 0.364796578884125f, -0.481373071670532f, 0.364427417516708f, + -0.481269240379334f, 0.364058345556259f, -0.481165111064911f, + 0.363689333200455f, -0.481060713529587f, 0.363320380449295f, + -0.480956017971039f, 0.362951546907425f, -0.480851024389267f, + 0.362582772970200f, -0.480745792388916f, 0.362214088439941f, + -0.480640232563019f, 0.361845493316650f, -0.480534434318542f, + 0.361476957798004f, -0.480428308248520f, 0.361108511686325f, + -0.480321943759918f, 0.360740154981613f, -0.480215251445770f, + 0.360371887683868f, -0.480108320713043f, 0.360003679990768f, + -0.480001062154770f, 0.359635561704636f, -0.479893565177917f, + 0.359267532825470f, -0.479785770177841f, 0.358899593353271f, + -0.479677677154541f, 0.358531713485718f, -0.479569315910339f, + 0.358163923025131f, -0.479460656642914f, 0.357796221971512f, + -0.479351729154587f, 0.357428610324860f, -0.479242533445358f, + 0.357061088085175f, -0.479133039712906f, 0.356693625450134f, + -0.479023247957230f, 0.356326282024384f, -0.478913217782974f, + 0.355958998203278f, -0.478802859783173f, 0.355591803789139f, + -0.478692263364792f, 0.355224698781967f, -0.478581339120865f, + 0.354857653379440f, -0.478470176458359f, 0.354490727186203f, + -0.478358715772629f, 0.354123860597610f, -0.478246957063675f, + 0.353757113218308f, -0.478134930133820f, 0.353390425443649f, + -0.478022634983063f, 0.353023827075958f, -0.477910041809082f, + 0.352657318115234f, -0.477797180414200f, 0.352290898561478f, + -0.477684020996094f, 0.351924568414688f, -0.477570593357086f, + 0.351558297872543f, -0.477456867694855f, 0.351192146539688f, + -0.477342873811722f, 0.350826084613800f, -0.477228611707687f, + 0.350460082292557f, -0.477114051580429f, 0.350094199180603f, + -0.476999223232269f, 0.349728375673294f, -0.476884096860886f, + 0.349362671375275f, -0.476768702268600f, 0.348997026681900f, + -0.476653009653091f, 0.348631471395493f, -0.476537048816681f, + 0.348266035318375f, -0.476420819759369f, 0.347900658845901f, + -0.476304292678833f, 0.347535371780396f, -0.476187497377396f, + 0.347170203924179f, -0.476070433855057f, 0.346805095672607f, + -0.475953072309494f, 0.346440106630325f, -0.475835442543030f, + 0.346075177192688f, -0.475717514753342f, 0.345710366964340f, + -0.475599318742752f, 0.345345616340637f, -0.475480824708939f, + 0.344980984926224f, -0.475362062454224f, 0.344616413116455f, + -0.475243031978607f, 0.344251960515976f, -0.475123733282089f, + 0.343887597322464f, -0.475004136562347f, 0.343523323535919f, + -0.474884241819382f, 0.343159139156342f, -0.474764078855515f, + 0.342795044183731f, -0.474643647670746f, 0.342431038618088f, + -0.474522948265076f, 0.342067122459412f, -0.474401950836182f, + 0.341703325510025f, -0.474280685186386f, 0.341339588165283f, + -0.474159121513367f, 0.340975970029831f, -0.474037289619446f, + 0.340612411499023f, -0.473915189504623f, 0.340248972177505f, + -0.473792791366577f, 0.339885622262955f, -0.473670125007629f, + 0.339522391557693f, -0.473547190427780f, 0.339159220457077f, + -0.473423957824707f, 0.338796168565750f, -0.473300457000732f, + 0.338433176279068f, -0.473176687955856f, 0.338070303201675f, + -0.473052620887756f, 0.337707549333572f, -0.472928285598755f, + 0.337344855070114f, -0.472803652286530f, 0.336982280015945f, + -0.472678780555725f, 0.336619764566422f, -0.472553610801697f, + 0.336257368326187f, -0.472428143024445f, 0.335895091295242f, + -0.472302407026291f, 0.335532873868942f, -0.472176402807236f, + 0.335170775651932f, -0.472050130367279f, 0.334808766841888f, + -0.471923559904099f, 0.334446847438812f, -0.471796721220016f, + 0.334085017442703f, -0.471669614315033f, 0.333723306655884f, + -0.471542209386826f, 0.333361685276031f, -0.471414536237717f, + 0.333000183105469f, -0.471286594867706f, 0.332638740539551f, + -0.471158385276794f, 0.332277417182922f, -0.471029877662659f, + 0.331916213035584f, -0.470901101827621f, 0.331555068492889f, + -0.470772027969360f, 0.331194043159485f, -0.470642685890198f, + 0.330833107233047f, -0.470513075590134f, 0.330472290515900f, + -0.470383197069168f, 0.330111563205719f, -0.470253020524979f, + 0.329750925302505f, -0.470122605562210f, 0.329390406608582f, + -0.469991862773895f, 0.329029977321625f, -0.469860881567001f, + 0.328669637441635f, -0.469729602336884f, 0.328309416770935f, + -0.469598054885864f, 0.327949285507202f, -0.469466239213943f, + 0.327589273452759f, -0.469334155321121f, 0.327229350805283f, + -0.469201773405075f, 0.326869517564774f, -0.469069123268127f, + 0.326509803533554f, -0.468936175107956f, 0.326150178909302f, + -0.468802988529205f, 0.325790673494339f, -0.468669503927231f, + 0.325431257486343f, -0.468535751104355f, 0.325071930885315f, + -0.468401730060577f, 0.324712723493576f, -0.468267410993576f, + 0.324353635311127f, -0.468132823705673f, 0.323994606733322f, + -0.467997968196869f, 0.323635727167130f, -0.467862844467163f, + 0.323276937007904f, -0.467727422714233f, 0.322918236255646f, + -0.467591762542725f, 0.322559654712677f, -0.467455804347992f, + 0.322201162576675f, -0.467319577932358f, 0.321842789649963f, + -0.467183053493500f, 0.321484506130219f, -0.467046260833740f, + 0.321126341819763f, -0.466909229755402f, 0.320768296718597f, + -0.466771900653839f, 0.320410341024399f, -0.466634273529053f, + 0.320052474737167f, -0.466496407985687f, 0.319694727659225f, + -0.466358244419098f, 0.319337099790573f, -0.466219812631607f, + 0.318979561328888f, -0.466081112623215f, 0.318622142076492f, + -0.465942144393921f, 0.318264812231064f, -0.465802878141403f, + 0.317907601594925f, -0.465663343667984f, 0.317550510168076f, + -0.465523540973663f, 0.317193508148193f, -0.465383470058441f, + 0.316836595535278f, -0.465243130922318f, 0.316479831933975f, + -0.465102523565292f, 0.316123157739639f, -0.464961618185043f, + 0.315766572952271f, -0.464820444583893f, 0.315410137176514f, + -0.464679002761841f, 0.315053790807724f, -0.464537292718887f, + 0.314697533845901f, -0.464395314455032f, 0.314341396093369f, + -0.464253038167953f, 0.313985377550125f, -0.464110493659973f, + 0.313629478216171f, -0.463967710733414f, 0.313273668289185f, + -0.463824629783630f, 0.312917977571487f, -0.463681250810623f, + 0.312562376260757f, -0.463537633419037f, 0.312206923961639f, + -0.463393747806549f, 0.311851561069489f, -0.463249564170837f, + 0.311496287584305f, -0.463105112314224f, 0.311141163110733f, + -0.462960392236710f, 0.310786128044128f, -0.462815403938293f, + 0.310431212186813f, -0.462670147418976f, 0.310076385736465f, + -0.462524622678757f, 0.309721708297729f, -0.462378799915314f, + 0.309367120265961f, -0.462232738733292f, 0.309012651443481f, + -0.462086379528046f, 0.308658272027969f, -0.461939752101898f, + 0.308304041624069f, -0.461792886257172f, 0.307949900627136f, + -0.461645722389221f, 0.307595878839493f, -0.461498260498047f, + 0.307241976261139f, -0.461350560188293f, 0.306888192892075f, + -0.461202591657639f, 0.306534498929977f, -0.461054325103760f, + 0.306180924177170f, -0.460905820131302f, 0.305827468633652f, + -0.460757017135620f, 0.305474132299423f, -0.460607945919037f, + 0.305120915174484f, -0.460458606481552f, 0.304767817258835f, + -0.460309028625488f, 0.304414808750153f, -0.460159152746201f, + 0.304061919450760f, -0.460008978843689f, 0.303709149360657f, + -0.459858566522598f, 0.303356528282166f, -0.459707885980606f, + 0.303003966808319f, -0.459556937217712f, 0.302651554346085f, + -0.459405690431595f, 0.302299261093140f, -0.459254205226898f, + 0.301947087049484f, -0.459102421998978f, 0.301595002412796f, + -0.458950400352478f, 0.301243066787720f, -0.458798080682755f, + 0.300891220569611f, -0.458645492792130f, 0.300539493560791f, + -0.458492636680603f, 0.300187885761261f, -0.458339542150497f, + 0.299836426973343f, -0.458186149597168f, 0.299485057592392f, + -0.458032488822937f, 0.299133807420731f, -0.457878559827805f, + 0.298782676458359f, -0.457724362611771f, 0.298431664705276f, + -0.457569897174835f, 0.298080772161484f, -0.457415163516998f, + 0.297729998826981f, -0.457260161638260f, 0.297379344701767f, + -0.457104891538620f, 0.297028809785843f, -0.456949323415756f, + 0.296678394079208f, -0.456793516874313f, 0.296328097581863f, + -0.456637442111969f, 0.295977920293808f, -0.456481099128723f, + 0.295627862215042f, -0.456324487924576f, 0.295277923345566f, + -0.456167578697205f, 0.294928103685379f, -0.456010431051254f, + 0.294578403234482f, -0.455853015184402f, 0.294228851795197f, + -0.455695331096649f, 0.293879389762878f, -0.455537378787994f, + 0.293530046939850f, -0.455379128456116f, 0.293180853128433f, + -0.455220639705658f, 0.292831748723984f, -0.455061882734299f, + 0.292482793331146f, -0.454902857542038f, 0.292133957147598f, + -0.454743564128876f, 0.291785210371017f, -0.454584002494812f, + 0.291436612606049f, -0.454424172639847f, 0.291088134050369f, + -0.454264044761658f, 0.290739774703979f, -0.454103678464890f, + 0.290391564369202f, -0.453943043947220f, 0.290043443441391f, + -0.453782171010971f, 0.289695471525192f, -0.453621000051498f, + 0.289347589015961f, -0.453459560871124f, 0.288999855518341f, + -0.453297853469849f, 0.288652241230011f, -0.453135877847672f, + 0.288304775953293f, -0.452973634004593f, 0.287957400083542f, + -0.452811151742935f, 0.287610173225403f, -0.452648371458054f, + 0.287263035774231f, -0.452485352754593f, 0.286916047334671f, + -0.452322036027908f, 0.286569178104401f, -0.452158480882645f, + 0.286222457885742f, -0.451994657516479f, 0.285875827074051f, + -0.451830536127090f, 0.285529345273972f, -0.451666176319122f, + 0.285182982683182f, -0.451501548290253f, 0.284836769104004f, + -0.451336652040482f, 0.284490644931793f, -0.451171487569809f, + 0.284144669771194f, -0.451006084680557f, 0.283798813819885f, + -0.450840383768082f, 0.283453077077866f, -0.450674414634705f, + 0.283107489347458f, -0.450508207082748f, 0.282762020826340f, + -0.450341701507568f, 0.282416671514511f, -0.450174957513809f, + 0.282071471214294f, -0.450007945299149f, 0.281726360321045f, + -0.449840664863586f, 0.281381398439407f, -0.449673116207123f, + 0.281036585569382f, -0.449505299329758f, 0.280691891908646f, + -0.449337244033813f, 0.280347317457199f, -0.449168890714645f, + 0.280002862215042f, -0.449000298976898f, 0.279658555984497f, + -0.448831409215927f, 0.279314368963242f, -0.448662281036377f, + 0.278970301151276f, -0.448492884635925f, 0.278626382350922f, + -0.448323249816895f, 0.278282582759857f, -0.448153316974640f, + 0.277938932180405f, -0.447983115911484f, 0.277595400810242f, + -0.447812676429749f, 0.277251988649368f, -0.447641968727112f, + 0.276908725500107f, -0.447470992803574f, 0.276565581560135f, + -0.447299748659134f, 0.276222556829453f, -0.447128236293793f, + 0.275879681110382f, -0.446956485509872f, 0.275536954402924f, + -0.446784436702728f, 0.275194346904755f, -0.446612149477005f, + 0.274851858615875f, -0.446439594030380f, 0.274509519338608f, + -0.446266770362854f, 0.274167299270630f, -0.446093708276749f, + 0.273825198411942f, -0.445920348167419f, 0.273483246564865f, + -0.445746749639511f, 0.273141443729401f, -0.445572882890701f, + 0.272799760103226f, -0.445398747920990f, 0.272458195686340f, + -0.445224374532700f, 0.272116780281067f, -0.445049703121185f, + 0.271775513887405f, -0.444874793291092f, 0.271434366703033f, + -0.444699615240097f, 0.271093338727951f, -0.444524168968201f, + 0.270752459764481f, -0.444348484277725f, 0.270411729812622f, + -0.444172531366348f, 0.270071119070053f, -0.443996280431747f, + 0.269730657339096f, -0.443819820880890f, 0.269390314817429f, + -0.443643063306808f, 0.269050091505051f, -0.443466067314148f, + 0.268710047006607f, -0.443288803100586f, 0.268370121717453f, + -0.443111270666122f, 0.268030315637589f, -0.442933470010757f, + 0.267690658569336f, -0.442755430936813f, 0.267351150512695f, + -0.442577123641968f, 0.267011761665344f, -0.442398548126221f, + 0.266672492027283f, -0.442219734191895f, 0.266333401203156f, + -0.442040622234344f, 0.265994429588318f, -0.441861271858215f, + 0.265655577182770f, -0.441681683063507f, 0.265316903591156f, + -0.441501796245575f, 0.264978319406509f, -0.441321671009064f, + 0.264639914035797f, -0.441141277551651f, 0.264301627874374f, + -0.440960645675659f, 0.263963490724564f, -0.440779715776443f, + 0.263625472784042f, -0.440598547458649f, 0.263287603855133f, + -0.440417140722275f, 0.262949883937836f, -0.440235435962677f, + 0.262612313032150f, -0.440053492784500f, 0.262274861335754f, + -0.439871311187744f, 0.261937558650970f, -0.439688831567764f, + 0.261600375175476f, -0.439506113529205f, 0.261263370513916f, + -0.439323127269745f, 0.260926485061646f, -0.439139902591705f, + 0.260589718818665f, -0.438956409692764f, 0.260253131389618f, + -0.438772648572922f, 0.259916663169861f, -0.438588619232178f, + 0.259580343961716f, -0.438404351472855f, 0.259244143962860f, + -0.438219845294952f, 0.258908122777939f, -0.438035041093826f, + 0.258572220802307f, -0.437849998474121f, 0.258236467838287f, + -0.437664687633514f, 0.257900834083557f, -0.437479138374329f, + 0.257565379142761f, -0.437293320894241f, 0.257230043411255f, + -0.437107264995575f, 0.256894856691360f, -0.436920911073685f, + 0.256559818983078f, -0.436734348535538f, 0.256224930286407f, + -0.436547487974167f, 0.255890160799026f, -0.436360388994217f, + 0.255555540323257f, -0.436173021793365f, 0.255221068859100f, + -0.435985416173935f, 0.254886746406555f, -0.435797542333603f, + 0.254552572965622f, -0.435609430074692f, 0.254218548536301f, + -0.435421019792557f, 0.253884643316269f, -0.435232400894165f, + 0.253550916910172f, -0.435043483972549f, 0.253217309713364f, + -0.434854328632355f, 0.252883851528168f, -0.434664934873581f, + 0.252550542354584f, -0.434475272893906f, 0.252217382192612f, + -0.434285342693329f, 0.251884341239929f, -0.434095174074173f, + 0.251551479101181f, -0.433904737234116f, 0.251218736171722f, + -0.433714061975479f, 0.250886172056198f, -0.433523118495941f, + 0.250553727149963f, -0.433331936597824f, 0.250221431255341f, + -0.433140486478806f, 0.249889299273491f, -0.432948768138886f, + 0.249557301402092f, -0.432756811380386f, 0.249225467443466f, + -0.432564586400986f, 0.248893767595291f, -0.432372123003006f, + 0.248562216758728f, -0.432179391384125f, 0.248230814933777f, + -0.431986421346664f, 0.247899547219276f, -0.431793183088303f, + 0.247568443417549f, -0.431599706411362f, 0.247237488627434f, + -0.431405961513519f, 0.246906682848930f, -0.431211978197098f, + 0.246576011180878f, -0.431017726659775f, 0.246245503425598f, + -0.430823236703873f, 0.245915144681931f, -0.430628478527069f, + 0.245584934949875f, -0.430433481931686f, 0.245254859328270f, + -0.430238217115402f, 0.244924947619438f, -0.430042684078217f, + 0.244595184922218f, -0.429846942424774f, 0.244265571236610f, + -0.429650902748108f, 0.243936106562614f, -0.429454624652863f, + 0.243606805801392f, -0.429258108139038f, 0.243277639150620f, + -0.429061323404312f, 0.242948621511459f, -0.428864300251007f, + 0.242619767785072f, -0.428667008876801f, 0.242291063070297f, + -0.428469479084015f, 0.241962507367134f, -0.428271710872650f, + 0.241634100675583f, -0.428073674440384f, 0.241305842995644f, + -0.427875369787216f, 0.240977749228477f, -0.427676826715469f, + 0.240649804472923f, -0.427478045225143f, 0.240322008728981f, + -0.427278995513916f, 0.239994361996651f, -0.427079707384110f, + 0.239666879177094f, -0.426880151033401f, 0.239339530467987f, + -0.426680356264114f, 0.239012360572815f, -0.426480293273926f, + 0.238685324788094f, -0.426279991865158f, 0.238358452916145f, + -0.426079452037811f, 0.238031730055809f, -0.425878643989563f, + 0.237705156207085f, -0.425677597522736f, 0.237378746271133f, + -0.425476282835007f, 0.237052485346794f, -0.425274729728699f, + 0.236726388335228f, -0.425072938203812f, 0.236400425434113f, + -0.424870878458023f, 0.236074641346931f, -0.424668580293655f, + 0.235749006271362f, -0.424466013908386f, 0.235423520207405f, + -0.424263238906860f, 0.235098183155060f, -0.424060165882111f, + 0.234773010015488f, -0.423856884241104f, 0.234448000788689f, + -0.423653304576874f, 0.234123140573502f, -0.423449516296387f, + 0.233798429369926f, -0.423245459794998f, 0.233473882079124f, + -0.423041164875031f, 0.233149498701096f, -0.422836631536484f, + 0.232825264334679f, -0.422631829977036f, 0.232501193881035f, + -0.422426789999008f, 0.232177272439003f, -0.422221481800079f, + 0.231853514909744f, -0.422015935182571f, 0.231529906392097f, + -0.421810150146484f, 0.231206461787224f, -0.421604126691818f, + 0.230883181095123f, -0.421397835016251f, 0.230560049414635f, + -0.421191304922104f, 0.230237081646919f, -0.420984506607056f, + 0.229914262890816f, -0.420777499675751f, 0.229591608047485f, + -0.420570224523544f, 0.229269117116928f, -0.420362681150436f, + 0.228946775197983f, -0.420154929161072f, 0.228624612092972f, + -0.419946908950806f, 0.228302597999573f, -0.419738620519638f, + 0.227980732917786f, -0.419530123472214f, 0.227659046649933f, + -0.419321358203888f, 0.227337509393692f, -0.419112354516983f, + 0.227016136050224f, -0.418903112411499f, 0.226694911718369f, + -0.418693602085114f, 0.226373866200447f, -0.418483853340149f, + 0.226052969694138f, -0.418273866176605f, 0.225732237100601f, + -0.418063640594482f, 0.225411668419838f, -0.417853146791458f, + 0.225091263651848f, -0.417642414569855f, 0.224771007895470f, + -0.417431443929672f, 0.224450930953026f, -0.417220205068588f, + 0.224131003022194f, -0.417008757591248f, 0.223811239004135f, + -0.416797041893005f, 0.223491653800011f, -0.416585087776184f, + 0.223172217607498f, -0.416372895240784f, 0.222852945327759f, + -0.416160434484482f, 0.222533836960793f, -0.415947735309601f, + 0.222214877605438f, -0.415734797716141f, 0.221896097064018f, + -0.415521621704102f, 0.221577480435371f, -0.415308207273483f, + 0.221259027719498f, -0.415094524621964f, 0.220940738916397f, + -0.414880603551865f, 0.220622614026070f, -0.414666473865509f, + 0.220304638147354f, -0.414452046155930f, 0.219986841082573f, + -0.414237409830093f, 0.219669207930565f, -0.414022535085678f, + 0.219351738691330f, -0.413807392120361f, 0.219034433364868f, + -0.413592010736465f, 0.218717306852341f, -0.413376390933990f, + 0.218400329351425f, -0.413160532712936f, 0.218083515763283f, + -0.412944436073303f, 0.217766880989075f, -0.412728071212769f, + 0.217450410127640f, -0.412511497735977f, 0.217134088277817f, + -0.412294656038284f, 0.216817945241928f, -0.412077575922012f, + 0.216501981019974f, -0.411860257387161f, 0.216186165809631f, + -0.411642700433731f, 0.215870529413223f, -0.411424905061722f, + 0.215555042028427f, -0.411206841468811f, 0.215239733457565f, + -0.410988569259644f, 0.214924603700638f, -0.410770028829575f, + 0.214609622955322f, -0.410551249980927f, 0.214294821023941f, + -0.410332232713699f, 0.213980183005333f, -0.410112977027893f, + 0.213665723800659f, -0.409893482923508f, 0.213351413607597f, + -0.409673750400543f, 0.213037282228470f, -0.409453779459000f, + 0.212723329663277f, -0.409233570098877f, 0.212409526109695f, + -0.409013092517853f, 0.212095901370049f, -0.408792406320572f, + 0.211782455444336f, -0.408571451902390f, 0.211469158530235f, + -0.408350288867950f, 0.211156040430069f, -0.408128857612610f, + 0.210843101143837f, -0.407907217741013f, 0.210530325770378f, + -0.407685309648514f, 0.210217714309692f, -0.407463163137436f, + 0.209905281662941f, -0.407240778207779f, 0.209593027830124f, + -0.407018154859543f, 0.209280923008919f, -0.406795293092728f, + 0.208969011902809f, -0.406572192907333f, 0.208657249808311f, + -0.406348884105682f, 0.208345666527748f, -0.406125307083130f, + 0.208034262061119f, -0.405901491641998f, 0.207723021507263f, + -0.405677437782288f, 0.207411959767342f, -0.405453115701675f, + 0.207101076841354f, -0.405228585004807f, 0.206790357828140f, + -0.405003815889359f, 0.206479802727699f, -0.404778808355331f, + 0.206169426441193f, -0.404553562402725f, 0.205859228968620f, + -0.404328078031540f, 0.205549195408821f, -0.404102355241776f, + 0.205239340662956f, -0.403876423835754f, 0.204929664731026f, + -0.403650224208832f, 0.204620152711868f, -0.403423786163330f, + 0.204310819506645f, -0.403197109699249f, 0.204001650214195f, + -0.402970194816589f, 0.203692659735680f, -0.402743041515350f, + 0.203383848071098f, -0.402515679597855f, 0.203075215220451f, + -0.402288049459457f, 0.202766746282578f, -0.402060180902481f, + 0.202458456158638f, -0.401832103729248f, 0.202150344848633f, + -0.401603758335114f, 0.201842412352562f, -0.401375204324722f, + 0.201534643769264f, -0.401146411895752f, 0.201227053999901f, + -0.400917351245880f, 0.200919643044472f, -0.400688081979752f, + 0.200612410902977f, -0.400458574295044f, 0.200305357575417f, + -0.400228828191757f, 0.199998468160629f, -0.399998843669891f, + 0.199691757559776f, -0.399768620729446f, 0.199385225772858f, + -0.399538189172745f, 0.199078872799873f, -0.399307489395142f, + 0.198772698640823f, -0.399076581001282f, 0.198466703295708f, + -0.398845434188843f, 0.198160871863365f, -0.398614019155502f, + 0.197855234146118f, -0.398382395505905f, 0.197549775242805f, + -0.398150533437729f, 0.197244480252266f, -0.397918462753296f, + 0.196939364075661f, -0.397686123847961f, 0.196634441614151f, + -0.397453576326370f, 0.196329683065414f, -0.397220760583878f, + 0.196025103330612f, -0.396987736225128f, 0.195720717310905f, + -0.396754473447800f, 0.195416495203972f, -0.396520972251892f, + 0.195112451910973f, -0.396287262439728f, 0.194808602333069f, + -0.396053284406662f, 0.194504916667938f, -0.395819097757339f, + 0.194201424717903f, -0.395584672689438f, 0.193898096680641f, + -0.395350009202957f, 0.193594962358475f, -0.395115107297897f, + 0.193292006850243f, -0.394879996776581f, 0.192989215254784f, + -0.394644618034363f, 0.192686617374420f, -0.394409030675888f, + 0.192384198307991f, -0.394173204898834f, 0.192081972956657f, + -0.393937170505524f, 0.191779911518097f, -0.393700867891312f, + 0.191478043794632f, -0.393464356660843f, 0.191176339983940f, + -0.393227607011795f, 0.190874829888344f, -0.392990618944168f, + 0.190573498606682f, -0.392753422260284f, 0.190272361040115f, + -0.392515957355499f, 0.189971387386322f, -0.392278283834457f, + 0.189670607447624f, -0.392040401697159f, 0.189370006322861f, + -0.391802251338959f, 0.189069598913193f, -0.391563892364502f, + 0.188769355416298f, -0.391325294971466f, 0.188469305634499f, + -0.391086459159851f, 0.188169434666634f, -0.390847414731979f, + 0.187869757413864f, -0.390608131885529f, 0.187570258975029f, + -0.390368610620499f, 0.187270939350128f, -0.390128880739212f, + 0.186971798539162f, -0.389888882637024f, 0.186672851443291f, + -0.389648675918579f, 0.186374098062515f, -0.389408260583878f, + 0.186075508594513f, -0.389167606830597f, 0.185777112841606f, + -0.388926714658737f, 0.185478910803795f, -0.388685584068298f, + 0.185180887579918f, -0.388444244861603f, 0.184883043169975f, + -0.388202667236328f, 0.184585392475128f, -0.387960851192474f, + 0.184287920594215f, -0.387718826532364f, 0.183990627527237f, + -0.387476563453674f, 0.183693528175354f, -0.387234061956406f, + 0.183396622538567f, -0.386991351842880f, 0.183099895715714f, + -0.386748403310776f, 0.182803362607956f, -0.386505216360092f, + 0.182507008314133f, -0.386261820793152f, 0.182210832834244f, + -0.386018186807632f, 0.181914865970612f, -0.385774344205856f, + 0.181619063019753f, -0.385530263185501f, 0.181323468685150f, + -0.385285943746567f, 0.181028053164482f, -0.385041415691376f, + 0.180732816457748f, -0.384796649217606f, 0.180437773466110f, + -0.384551674127579f, 0.180142924189568f, -0.384306460618973f, + 0.179848253726959f, -0.384061008691788f, 0.179553776979446f, + -0.383815348148346f, 0.179259493947029f, -0.383569449186325f, + 0.178965389728546f, -0.383323341608047f, 0.178671479225159f, + -0.383076995611191f, 0.178377762436867f, -0.382830440998077f, + 0.178084224462509f, -0.382583618164063f, 0.177790880203247f, + -0.382336616516113f, 0.177497729659081f, -0.382089376449585f, + 0.177204772830009f, -0.381841897964478f, 0.176911994814873f, + -0.381594210863113f, 0.176619410514832f, -0.381346285343170f, + 0.176327019929886f, -0.381098151206970f, 0.176034808158875f, + -0.380849778652191f, 0.175742805004120f, -0.380601197481155f, + 0.175450980663300f, -0.380352377891541f, 0.175159350037575f, + -0.380103349685669f, 0.174867913126946f, -0.379854083061218f, + 0.174576655030251f, -0.379604607820511f, 0.174285605549812f, + -0.379354894161224f, 0.173994734883308f, -0.379104942083359f, + 0.173704057931900f, -0.378854811191559f, 0.173413574695587f, + -0.378604412078857f, 0.173123285174370f, -0.378353834152222f, + 0.172833189368248f, -0.378102988004684f, 0.172543287277222f, + -0.377851963043213f, 0.172253578901291f, -0.377600699663162f, + 0.171964049339294f, -0.377349197864532f, 0.171674728393555f, + -0.377097487449646f, 0.171385586261749f, -0.376845568418503f, + 0.171096652746201f, -0.376593410968781f, 0.170807912945747f, + -0.376341015100479f, 0.170519351959229f, -0.376088410615921f, + 0.170230999588966f, -0.375835597515106f, 0.169942826032639f, + -0.375582575798035f, 0.169654861092567f, -0.375329315662384f, + 0.169367074966431f, -0.375075817108154f, 0.169079497456551f, + -0.374822109937668f, 0.168792113661766f, -0.374568194150925f, + 0.168504923582077f, -0.374314039945602f, 0.168217927217484f, + -0.374059677124023f, 0.167931124567986f, -0.373805105686188f, + 0.167644515633583f, -0.373550295829773f, 0.167358100414276f, + -0.373295277357101f, 0.167071878910065f, -0.373040050268173f, + 0.166785866022110f, -0.372784584760666f, 0.166500031948090f, + -0.372528880834579f, 0.166214406490326f, -0.372272998094559f, + 0.165928974747658f, -0.372016876935959f, 0.165643751621246f, + -0.371760547161102f, 0.165358707308769f, -0.371503978967667f, + 0.165073871612549f, -0.371247202157974f, 0.164789214730263f, + -0.370990216732025f, 0.164504766464233f, -0.370732992887497f, + 0.164220526814461f, -0.370475560426712f, 0.163936465978622f, + -0.370217919349670f, 0.163652613759041f, -0.369960039854050f, + 0.163368955254555f, -0.369701951742172f, 0.163085505366325f, + -0.369443655014038f, 0.162802234292030f, -0.369185149669647f, + 0.162519171833992f, -0.368926405906677f, 0.162236317992210f, + -0.368667453527451f, 0.161953642964363f, -0.368408292531967f, + 0.161671176552773f, -0.368148893117905f, 0.161388918757439f, + -0.367889285087585f, 0.161106839776039f, -0.367629468441010f, + 0.160824984312058f, -0.367369443178177f, 0.160543307662010f, + -0.367109179496765f, 0.160261839628220f, -0.366848707199097f, + 0.159980565309525f, -0.366588026285172f, 0.159699499607086f, + -0.366327136754990f, 0.159418627619743f, -0.366066008806229f, + 0.159137964248657f, -0.365804702043533f, 0.158857494592667f, + -0.365543156862259f, 0.158577233552933f, -0.365281373262405f, + 0.158297166228294f, -0.365019410848618f, 0.158017292618752f, + -0.364757210016251f, 0.157737627625465f, -0.364494800567627f, + 0.157458171248436f, -0.364232182502747f, 0.157178908586502f, + -0.363969355821610f, 0.156899839639664f, -0.363706320524216f, + 0.156620979309082f, -0.363443046808243f, 0.156342327594757f, + -0.363179564476013f, 0.156063869595528f, -0.362915903329849f, + 0.155785620212555f, -0.362651973962784f, 0.155507579445839f, + -0.362387865781784f, 0.155229732394218f, -0.362123548984528f, + 0.154952079057693f, -0.361858993768692f, 0.154674649238586f, + -0.361594229936600f, 0.154397398233414f, -0.361329287290573f, + 0.154120370745659f, -0.361064106225967f, 0.153843536973000f, + -0.360798716545105f, 0.153566911816597f, -0.360533088445663f, + 0.153290495276451f, -0.360267281532288f, 0.153014272451401f, + -0.360001266002655f, 0.152738258242607f, -0.359735012054443f, + 0.152462437748909f, -0.359468549489975f, 0.152186840772629f, + -0.359201908111572f, 0.151911437511444f, -0.358935028314590f, + 0.151636242866516f, -0.358667939901352f, 0.151361241936684f, + -0.358400642871857f, 0.151086464524269f, -0.358133137226105f, + 0.150811880826950f, -0.357865422964096f, 0.150537505745888f, + -0.357597470283508f, 0.150263324379921f, -0.357329338788986f, + 0.149989366531372f, -0.357060998678207f, 0.149715602397919f, + -0.356792420148849f, 0.149442046880722f, -0.356523662805557f, + 0.149168699979782f, -0.356254696846008f, 0.148895561695099f, + -0.355985492467880f, 0.148622632026672f, -0.355716109275818f, + 0.148349896073341f, -0.355446487665176f, 0.148077383637428f, + -0.355176687240601f, 0.147805064916611f, -0.354906648397446f, + 0.147532954812050f, -0.354636400938034f, 0.147261068224907f, + -0.354365974664688f, 0.146989375352860f, -0.354095309972763f, + 0.146717891097069f, -0.353824466466904f, 0.146446615457535f, + -0.353553384542465f, 0.146175548434258f, -0.353282123804092f, + 0.145904675126076f, -0.353010624647141f, 0.145634025335312f, + -0.352738946676254f, 0.145363584160805f, -0.352467030286789f, + 0.145093351602554f, -0.352194935083389f, 0.144823327660561f, + -0.351922631263733f, 0.144553512334824f, -0.351650089025497f, + 0.144283905625343f, -0.351377367973328f, 0.144014507532120f, + -0.351104438304901f, 0.143745318055153f, -0.350831300020218f, + 0.143476337194443f, -0.350557953119278f, 0.143207564949989f, + -0.350284397602081f, 0.142939001321793f, -0.350010633468628f, + 0.142670661211014f, -0.349736660718918f, 0.142402514815331f, + -0.349462509155273f, 0.142134591937065f, -0.349188119173050f, + 0.141866862773895f, -0.348913550376892f, 0.141599357128143f, + -0.348638743162155f, 0.141332060098648f, -0.348363757133484f, + 0.141064971685410f, -0.348088562488556f, 0.140798106789589f, + -0.347813159227371f, 0.140531435608864f, -0.347537547349930f, + 0.140264987945557f, -0.347261756658554f, 0.139998748898506f, + -0.346985727548599f, 0.139732718467712f, -0.346709519624710f, + 0.139466896653175f, -0.346433073282242f, 0.139201298356056f, + -0.346156448125839f, 0.138935908675194f, -0.345879614353180f, + 0.138670727610588f, -0.345602601766586f, 0.138405755162239f, + -0.345325350761414f, 0.138141006231308f, -0.345047920942307f, + 0.137876465916634f, -0.344770282506943f, 0.137612134218216f, + -0.344492435455322f, 0.137348011136055f, -0.344214379787445f, + 0.137084111571312f, -0.343936115503311f, 0.136820420622826f, + -0.343657672405243f, 0.136556953191757f, -0.343379020690918f, + 0.136293679475784f, -0.343100160360336f, 0.136030644178391f, + -0.342821091413498f, 0.135767802596092f, -0.342541843652725f, + 0.135505184531212f, -0.342262357473373f, 0.135242775082588f, + -0.341982692480087f, 0.134980589151382f, -0.341702848672867f, + 0.134718611836433f, -0.341422766447067f, 0.134456858038902f, + -0.341142505407333f, 0.134195312857628f, -0.340862035751343f, + 0.133933976292610f, -0.340581357479095f, 0.133672863245010f, + -0.340300500392914f, 0.133411958813667f, -0.340019434690475f, + 0.133151277899742f, -0.339738160371780f, 0.132890805602074f, + -0.339456677436829f, 0.132630556821823f, -0.339175015687943f, + 0.132370531558990f, -0.338893145322800f, 0.132110700011253f, + -0.338611096143723f, 0.131851106882095f, -0.338328808546066f, + 0.131591722369194f, -0.338046342134476f, 0.131332546472549f, + -0.337763696908951f, 0.131073594093323f, -0.337480813264847f, + 0.130814850330353f, -0.337197750806808f, 0.130556344985962f, + -0.336914509534836f, 0.130298033356667f, -0.336631029844284f, + 0.130039945244789f, -0.336347371339798f, 0.129782080650330f, + -0.336063534021378f, 0.129524439573288f, -0.335779488086700f, + 0.129267007112503f, -0.335495233535767f, 0.129009798169136f, + -0.335210770368576f, 0.128752797842026f, -0.334926128387451f, + 0.128496021032333f, -0.334641307592392f, 0.128239467740059f, + -0.334356248378754f, 0.127983123064041f, -0.334071010351181f, + 0.127727001905441f, -0.333785593509674f, 0.127471104264259f, + -0.333499968051910f, 0.127215430140495f, -0.333214133977890f, + 0.126959964632988f, -0.332928121089935f, 0.126704722642899f, + -0.332641899585724f, 0.126449704170227f, -0.332355499267578f, + 0.126194894313812f, -0.332068890333176f, 0.125940307974815f, + -0.331782072782516f, 0.125685945153236f, -0.331495076417923f, + 0.125431805849075f, -0.331207901239395f, 0.125177875161171f, + -0.330920487642288f, 0.124924175441265f, -0.330632925033569f, + 0.124670691788197f, -0.330345153808594f, 0.124417431652546f, + -0.330057173967361f, 0.124164395034313f, -0.329769015312195f, + 0.123911574482918f, -0.329480648040771f, 0.123658977448940f, + -0.329192101955414f, 0.123406603932381f, -0.328903347253799f, + 0.123154446482658f, -0.328614413738251f, 0.122902512550354f, + -0.328325271606445f, 0.122650802135468f, -0.328035950660706f, + 0.122399315237999f, -0.327746421098709f, 0.122148044407368f, + -0.327456712722778f, 0.121896997094154f, -0.327166795730591f, + 0.121646173298359f, -0.326876699924469f, 0.121395580470562f, + -0.326586425304413f, 0.121145196259022f, -0.326295942068100f, + 0.120895043015480f, -0.326005280017853f, 0.120645113289356f, + -0.325714409351349f, 0.120395407080650f, -0.325423330068588f, + 0.120145916938782f, -0.325132101774216f, 0.119896657764912f, + -0.324840664863586f, 0.119647622108459f, -0.324549019336700f, + 0.119398809969425f, -0.324257194995880f, 0.119150213897228f, + -0.323965191841125f, 0.118901848793030f, -0.323672980070114f, + 0.118653707206249f, -0.323380589485168f, 0.118405789136887f, + -0.323088020086288f, 0.118158094584942f, -0.322795242071152f, + 0.117910631000996f, -0.322502255439758f, 0.117663383483887f, + -0.322209119796753f, 0.117416366934776f, -0.321915775537491f, + 0.117169573903084f, -0.321622252464294f, 0.116923004388809f, + -0.321328520774841f, 0.116676658391953f, -0.321034610271454f, + 0.116430543363094f, -0.320740520954132f, 0.116184651851654f, + -0.320446223020554f, 0.115938983857632f, -0.320151746273041f, + 0.115693546831608f, -0.319857090711594f, 0.115448333323002f, + -0.319562226533890f, 0.115203343331814f, -0.319267183542252f, + 0.114958584308624f, -0.318971961736679f, 0.114714048802853f, + -0.318676531314850f, 0.114469736814499f, -0.318380922079086f, + 0.114225655794144f, -0.318085134029388f, 0.113981798291206f, + -0.317789167165756f, 0.113738171756268f, -0.317492991685867f, + 0.113494776189327f, -0.317196637392044f, 0.113251596689224f, + -0.316900104284287f, 0.113008655607700f, -0.316603392362595f, + 0.112765938043594f, -0.316306471824646f, 0.112523443996906f, + -0.316009372472763f, 0.112281180918217f, -0.315712094306946f, + 0.112039148807526f, -0.315414607524872f, 0.111797347664833f, + -0.315116971731186f, 0.111555770039558f, -0.314819127321243f, + 0.111314415931702f, -0.314521104097366f, 0.111073300242424f, + -0.314222872257233f, 0.110832408070564f, -0.313924491405487f, + 0.110591746866703f, -0.313625901937485f, 0.110351309180260f, + -0.313327133655548f, 0.110111102461815f, -0.313028186559677f, + 0.109871134161949f, -0.312729060649872f, 0.109631389379501f, + -0.312429755926132f, 0.109391868114471f, -0.312130242586136f, + 0.109152585268021f, -0.311830550432205f, 0.108913525938988f, + -0.311530679464340f, 0.108674705028534f, -0.311230629682541f, + 0.108436107635498f, -0.310930401086807f, 0.108197741210461f, + -0.310629993677139f, 0.107959605753422f, -0.310329377651215f, + 0.107721701264381f, -0.310028612613678f, 0.107484027743340f, + -0.309727638959885f, 0.107246585190296f, -0.309426486492157f, + 0.107009373605251f, -0.309125155210495f, 0.106772392988205f, + -0.308823645114899f, 0.106535643339157f, -0.308521956205368f, + 0.106299124658108f, -0.308220088481903f, 0.106062836945057f, + -0.307918041944504f, 0.105826787650585f, -0.307615786790848f, + 0.105590961873531f, -0.307313382625580f, 0.105355374515057f, + -0.307010769844055f, 0.105120018124580f, -0.306708008050919f, + 0.104884892702103f, -0.306405037641525f, 0.104649998247623f, + -0.306101888418198f, 0.104415334761143f, -0.305798590183258f, + 0.104180909693241f, -0.305495083332062f, 0.103946708142757f, + -0.305191397666931f, 0.103712752461433f, -0.304887533187866f, + 0.103479020297527f, -0.304583519697189f, 0.103245526552200f, + -0.304279297590256f, 0.103012263774872f, -0.303974896669388f, + 0.102779231965542f, -0.303670316934586f, 0.102546438574791f, + -0.303365558385849f, 0.102313876152039f, -0.303060621023178f, + 0.102081544697285f, -0.302755534648895f, 0.101849451661110f, + -0.302450239658356f, 0.101617597043514f, -0.302144765853882f, + 0.101385973393917f, -0.301839113235474f, 0.101154580712318f, + -0.301533311605453f, 0.100923426449299f, -0.301227301359177f, + 0.100692503154278f, -0.300921112298965f, 0.100461818277836f, + -0.300614774227142f, 0.100231364369392f, -0.300308227539063f, + 0.100001148879528f, -0.300001531839371f, 0.099771171808243f, + -0.299694657325745f, 0.099541425704956f, -0.299387603998184f, + 0.099311910569668f, -0.299080342054367f, 0.099082641303539f, + -0.298772931098938f, 0.098853603005409f, -0.298465341329575f, + 0.098624803125858f, -0.298157602548599f, 0.098396234214306f, + -0.297849655151367f, 0.098167903721333f, -0.297541528940201f, + 0.097939811646938f, -0.297233253717422f, 0.097711957991123f, + -0.296924799680710f, 0.097484335303307f, -0.296616137027740f, + 0.097256951034069f, -0.296307325363159f, 0.097029805183411f, + -0.295998334884644f, 0.096802897751331f, -0.295689195394516f, + 0.096576221287251f, -0.295379847288132f, 0.096349790692329f, + -0.295070350170136f, 0.096123591065407f, -0.294760644435883f, + 0.095897629857063f, -0.294450789690018f, 0.095671907067299f, + -0.294140785932541f, 0.095446422696114f, -0.293830573558807f, + 0.095221176743507f, -0.293520182371140f, 0.094996169209480f, + -0.293209642171860f, 0.094771400094032f, -0.292898923158646f, + 0.094546869397163f, -0.292588025331497f, 0.094322577118874f, + -0.292276978492737f, 0.094098523259163f, -0.291965723037720f, + 0.093874707818031f, -0.291654318571091f, 0.093651130795479f, + -0.291342735290527f, 0.093427792191505f, -0.291031002998352f, + 0.093204692006111f, -0.290719062089920f, 0.092981837689877f, + -0.290406972169876f, 0.092759214341640f, -0.290094703435898f, + 0.092536836862564f, -0.289782285690308f, 0.092314697802067f, + -0.289469659328461f, 0.092092797160149f, -0.289156883955002f, + 0.091871134936810f, -0.288843959569931f, 0.091649711132050f, + -0.288530826568604f, 0.091428533196449f, -0.288217544555664f, + 0.091207593679428f, -0.287904083728790f, 0.090986892580986f, + -0.287590473890305f, 0.090766437351704f, -0.287276685237885f, + 0.090546220541000f, -0.286962717771530f, 0.090326242148876f, + -0.286648571491241f, 0.090106502175331f, -0.286334276199341f, + 0.089887008070946f, -0.286019802093506f, 0.089667752385139f, + -0.285705178976059f, 0.089448742568493f, -0.285390377044678f, + 0.089229971170425f, -0.285075396299362f, 0.089011445641518f, + -0.284760266542435f, 0.088793158531189f, -0.284444957971573f, + 0.088575109839439f, -0.284129470586777f, 0.088357307016850f, + -0.283813834190369f, 0.088139742612839f, -0.283498018980026f, + 0.087922424077988f, -0.283182054758072f, 0.087705351412296f, + -0.282865911722183f, 0.087488517165184f, -0.282549589872360f, + 0.087271921336651f, -0.282233119010925f, 0.087055571377277f, + -0.281916469335556f, 0.086839467287064f, -0.281599670648575f, + 0.086623609066010f, -0.281282693147659f, 0.086407989263535f, + -0.280965566635132f, 0.086192607879639f, -0.280648261308670f, + 0.085977479815483f, -0.280330777168274f, 0.085762590169907f, + -0.280013144016266f, 0.085547938942909f, -0.279695361852646f, + 0.085333541035652f, -0.279377400875092f, 0.085119381546974f, + -0.279059261083603f, 0.084905467927456f, -0.278740972280502f, + 0.084691800177097f, -0.278422504663467f, 0.084478378295898f, + -0.278103888034821f, 0.084265194833279f, -0.277785122394562f, + 0.084052257239819f, -0.277466177940369f, 0.083839565515518f, + -0.277147054672241f, 0.083627119660378f, -0.276827782392502f, + 0.083414919674397f, -0.276508361101151f, 0.083202958106995f, + -0.276188760995865f, 0.082991249859333f, -0.275868982076645f, + 0.082779780030251f, -0.275549083948135f, 0.082568563520908f, + -0.275228977203369f, 0.082357585430145f, -0.274908751249313f, + 0.082146860659122f, -0.274588316679001f, 0.081936374306679f, + -0.274267762899399f, 0.081726133823395f, -0.273947030305862f, + 0.081516146659851f, -0.273626148700714f, 0.081306397914886f, + -0.273305088281631f, 0.081096902489662f, -0.272983878850937f, + 0.080887645483017f, -0.272662490606308f, 0.080678641796112f, + -0.272340953350067f, 0.080469883978367f, -0.272019267082214f, + 0.080261372029781f, -0.271697402000427f, 0.080053105950356f, + -0.271375387907028f, 0.079845085740089f, -0.271053224802017f, + 0.079637311398983f, -0.270730882883072f, 0.079429790377617f, + -0.270408391952515f, 0.079222507774830f, -0.270085722208023f, + 0.079015478491783f, -0.269762933254242f, 0.078808702528477f, + -0.269439965486526f, 0.078602164983749f, -0.269116818904877f, + 0.078395880758762f, -0.268793523311615f, 0.078189842402935f, + -0.268470078706741f, 0.077984049916267f, -0.268146485090256f, + 0.077778510749340f, -0.267822742462158f, 0.077573217451572f, + -0.267498821020126f, 0.077368170022964f, -0.267174720764160f, + 0.077163375914097f, -0.266850501298904f, 0.076958827674389f, + -0.266526103019714f, 0.076754532754421f, -0.266201555728912f, + 0.076550483703613f, -0.265876859426498f, 0.076346680521965f, + -0.265552014112473f, 0.076143130660057f, -0.265226989984512f, + 0.075939826667309f, -0.264901816844940f, 0.075736775994301f, + -0.264576494693756f, 0.075533971190453f, -0.264250993728638f, + 0.075331419706345f, -0.263925373554230f, 0.075129114091396f, + -0.263599574565887f, 0.074927061796188f, -0.263273626565933f, + 0.074725262820721f, -0.262947499752045f, 0.074523709714413f, + -0.262621253728867f, 0.074322402477264f, -0.262294828891754f, + 0.074121348559856f, -0.261968284845352f, 0.073920547962189f, + -0.261641561985016f, 0.073720000684261f, -0.261314690113068f, + 0.073519699275494f, -0.260987639427185f, 0.073319651186466f, + -0.260660469532013f, 0.073119848966599f, -0.260333120822906f, + 0.072920300066471f, -0.260005623102188f, 0.072721004486084f, + -0.259678006172180f, 0.072521962225437f, -0.259350210428238f, + 0.072323165833950f, -0.259022265672684f, 0.072124622762203f, + -0.258694142103195f, 0.071926333010197f, -0.258365899324417f, + 0.071728296577930f, -0.258037507534027f, 0.071530513465405f, + -0.257708936929703f, 0.071332976222038f, -0.257380217313766f, + 0.071135692298412f, -0.257051378488541f, 0.070938661694527f, + -0.256722360849380f, 0.070741884410381f, -0.256393194198608f, + 0.070545360445976f, -0.256063878536224f, 0.070349089801311f, + -0.255734413862228f, 0.070153072476387f, -0.255404800176620f, + 0.069957308471203f, -0.255075037479401f, 0.069761790335178f, + -0.254745125770569f, 0.069566532969475f, -0.254415065050125f, + 0.069371521472931f, -0.254084855318069f, 0.069176770746708f, + -0.253754496574402f, 0.068982265889645f, -0.253423988819122f, + 0.068788021802902f, -0.253093332052231f, 0.068594031035900f, + -0.252762526273727f, 0.068400286138058f, -0.252431541681290f, + 0.068206802010536f, -0.252100437879562f, 0.068013571202755f, + -0.251769185066223f, 0.067820593714714f, -0.251437783241272f, + 0.067627869546413f, -0.251106232404709f, 0.067435398697853f, + -0.250774532556534f, 0.067243188619614f, -0.250442683696747f, + 0.067051224410534f, -0.250110685825348f, 0.066859520971775f, + -0.249778553843498f, 0.066668070852757f, -0.249446272850037f, + 0.066476874053478f, -0.249113827943802f, 0.066285938024521f, + -0.248781248927116f, 0.066095255315304f, -0.248448520898819f, + 0.065904818475246f, -0.248115643858910f, 0.065714649856091f, + -0.247782632708550f, 0.065524727106094f, -0.247449472546577f, + 0.065335065126419f, -0.247116148471832f, 0.065145656466484f, + -0.246782705187798f, 0.064956501126289f, -0.246449097990990f, + 0.064767606556416f, -0.246115356683731f, 0.064578965306282f, + -0.245781451463699f, 0.064390584826469f, -0.245447427034378f, + 0.064202457666397f, -0.245113238692284f, 0.064014583826065f, + -0.244778916239738f, 0.063826970756054f, -0.244444444775581f, + 0.063639611005783f, -0.244109839200974f, 0.063452512025833f, + -0.243775084614754f, 0.063265666365623f, -0.243440181016922f, + 0.063079081475735f, -0.243105143308640f, 0.062892749905586f, + -0.242769956588745f, 0.062706671655178f, -0.242434620857239f, + 0.062520854175091f, -0.242099151015282f, 0.062335297465324f, + -0.241763532161713f, 0.062149997800589f, -0.241427779197693f, + 0.061964951455593f, -0.241091892123222f, 0.061780165880919f, + -0.240755841135979f, 0.061595637351274f, -0.240419670939446f, + 0.061411365866661f, -0.240083336830139f, 0.061227355152369f, + -0.239746883511543f, 0.061043601483107f, -0.239410281181335f, + 0.060860104858875f, -0.239073529839516f, 0.060676865279675f, + -0.238736644387245f, 0.060493886470795f, -0.238399609923363f, + 0.060311164706945f, -0.238062441349030f, 0.060128703713417f, + -0.237725138664246f, 0.059946499764919f, -0.237387686967850f, + 0.059764556586742f, -0.237050101161003f, 0.059582870453596f, + -0.236712381243706f, 0.059401445090771f, -0.236374512314796f, + 0.059220276772976f, -0.236036509275436f, 0.059039369225502f, + -0.235698372125626f, 0.058858718723059f, -0.235360085964203f, + 0.058678328990936f, -0.235021665692329f, 0.058498200029135f, + -0.234683111310005f, 0.058318331837654f, -0.234344407916069f, + 0.058138720691204f, -0.234005570411682f, 0.057959370315075f, + -0.233666598796844f, 0.057780280709267f, -0.233327493071556f, + 0.057601451873779f, -0.232988253235817f, 0.057422880083323f, + -0.232648864388466f, 0.057244572788477f, -0.232309341430664f, + 0.057066522538662f, -0.231969684362412f, 0.056888736784458f, + -0.231629893183708f, 0.056711208075285f, -0.231289967894554f, + 0.056533940136433f, -0.230949893593788f, 0.056356932967901f, + -0.230609700083733f, 0.056180190294981f, -0.230269357562065f, + 0.056003704667091f, -0.229928880929947f, 0.055827483534813f, + -0.229588270187378f, 0.055651523172855f, -0.229247525334358f, + 0.055475823581219f, -0.228906646370888f, 0.055300384759903f, + -0.228565633296967f, 0.055125206708908f, -0.228224486112595f, + 0.054950293153524f, -0.227883204817772f, 0.054775636643171f, + -0.227541789412498f, 0.054601248353720f, -0.227200239896774f, + 0.054427117109299f, -0.226858556270599f, 0.054253250360489f, + -0.226516738533974f, 0.054079644382000f, -0.226174786686897f, + 0.053906302899122f, -0.225832715630531f, 0.053733222186565f, + -0.225490495562553f, 0.053560405969620f, -0.225148141384125f, + 0.053387850522995f, -0.224805667996407f, 0.053215555846691f, + -0.224463045597076f, 0.053043525665998f, -0.224120303988457f, + 0.052871759980917f, -0.223777428269386f, 0.052700258791447f, + -0.223434418439865f, 0.052529018372297f, -0.223091274499893f, + 0.052358038723469f, -0.222748011350632f, 0.052187327295542f, + -0.222404599189758f, 0.052016876637936f, -0.222061067819595f, + 0.051846686750650f, -0.221717402338982f, 0.051676765084267f, + -0.221373617649078f, 0.051507104188204f, -0.221029683947563f, + 0.051337707787752f, -0.220685631036758f, 0.051168579608202f, + -0.220341444015503f, 0.050999708473682f, -0.219997137784958f, + 0.050831105560064f, -0.219652697443962f, 0.050662767142057f, + -0.219308122992516f, 0.050494693219662f, -0.218963414430618f, + 0.050326880067587f, -0.218618586659431f, 0.050159335136414f, + -0.218273624777794f, 0.049992054700851f, -0.217928543686867f, + 0.049825038760900f, -0.217583328485489f, 0.049658283591270f, + -0.217237979173660f, 0.049491796642542f, -0.216892510652542f, + 0.049325577914715f, -0.216546908020973f, 0.049159619957209f, + -0.216201186180115f, 0.048993926495314f, -0.215855330228806f, + 0.048828501254320f, -0.215509355068207f, 0.048663340508938f, + -0.215163245797157f, 0.048498444259167f, -0.214817002415657f, + 0.048333816230297f, -0.214470639824867f, 0.048169452697039f, + -0.214124158024788f, 0.048005353659391f, -0.213777542114258f, + 0.047841522842646f, -0.213430806994438f, 0.047677956521511f, + -0.213083937764168f, 0.047514654695988f, -0.212736949324608f, + 0.047351621091366f, -0.212389841675758f, 0.047188851982355f, + -0.212042599916458f, 0.047026351094246f, -0.211695238947868f, + 0.046864114701748f, -0.211347743868828f, 0.046702146530151f, + -0.211000129580498f, 0.046540446579456f, -0.210652396082878f, + 0.046379011124372f, -0.210304543375969f, 0.046217843890190f, + -0.209956556558609f, 0.046056941151619f, -0.209608450531960f, + 0.045896306633949f, -0.209260210394859f, 0.045735940337181f, + -0.208911851048470f, 0.045575842261314f, -0.208563387393951f, + 0.045416008681059f, -0.208214774727821f, 0.045256443321705f, + -0.207866057753563f, 0.045097146183252f, -0.207517206668854f, + 0.044938117265701f, -0.207168251276016f, 0.044779352843761f, + -0.206819161772728f, 0.044620860368013f, -0.206469938158989f, + 0.044462632387877f, -0.206120610237122f, 0.044304672628641f, + -0.205771163105965f, 0.044146984815598f, -0.205421581864357f, + 0.043989561498165f, -0.205071896314621f, 0.043832406401634f, + -0.204722076654434f, 0.043675523251295f, -0.204372137784958f, + 0.043518904596567f, -0.204022079706192f, 0.043362557888031f, + -0.203671902418137f, 0.043206475675106f, -0.203321605920792f, + 0.043050665408373f, -0.202971190214157f, 0.042895123362541f, + -0.202620655298233f, 0.042739849537611f, -0.202270001173019f, + 0.042584843933582f, -0.201919227838516f, 0.042430106550455f, + -0.201568335294724f, 0.042275641113520f, -0.201217323541641f, + 0.042121443897486f, -0.200866192579269f, 0.041967518627644f, + -0.200514942407608f, 0.041813857853413f, -0.200163587927818f, + 0.041660469025373f, -0.199812099337578f, 0.041507352143526f, + -0.199460506439209f, 0.041354499757290f, -0.199108779430389f, + 0.041201923042536f, -0.198756948113441f, 0.041049610823393f, + -0.198404997587204f, 0.040897574275732f, -0.198052927851677f, + 0.040745802223682f, -0.197700738906860f, 0.040594302117825f, + -0.197348430752754f, 0.040443073958158f, -0.196996018290520f, + 0.040292114019394f, -0.196643486618996f, 0.040141426026821f, + -0.196290835738182f, 0.039991009980440f, -0.195938065648079f, + 0.039840862154961f, -0.195585191249847f, 0.039690986275673f, + -0.195232197642326f, 0.039541378617287f, -0.194879084825516f, + 0.039392042905092f, -0.194525867700577f, 0.039242979139090f, + -0.194172516465187f, 0.039094187319279f, -0.193819075822830f, + 0.038945667445660f, -0.193465501070023f, 0.038797415792942f, + -0.193111822009087f, 0.038649436086416f, -0.192758023738861f, + 0.038501728326082f, -0.192404121160507f, 0.038354292511940f, + -0.192050099372864f, 0.038207128643990f, -0.191695958375931f, + 0.038060232996941f, -0.191341713070869f, 0.037913613021374f, + -0.190987363457680f, 0.037767261266708f, -0.190632879734039f, + 0.037621185183525f, -0.190278306603432f, 0.037475381046534f, + -0.189923599362373f, 0.037329845130444f, -0.189568802714348f, + 0.037184584885836f, -0.189213871955872f, 0.037039596587420f, + -0.188858851790428f, 0.036894880235195f, -0.188503712415695f, + 0.036750435829163f, -0.188148453831673f, 0.036606263369322f, + -0.187793090939522f, 0.036462362855673f, -0.187437608838081f, + 0.036318738013506f, -0.187082037329674f, 0.036175385117531f, + -0.186726331710815f, 0.036032304167747f, -0.186370536684990f, + 0.035889495164156f, -0.186014622449875f, 0.035746958106756f, + -0.185658603906631f, 0.035604696720839f, -0.185302466154099f, + 0.035462711006403f, -0.184946224093437f, 0.035320993512869f, + -0.184589877724648f, 0.035179551690817f, -0.184233412146568f, + 0.035038381814957f, -0.183876842260361f, 0.034897487610579f, + -0.183520168066025f, 0.034756865352392f, -0.183163389563560f, + 0.034616518765688f, -0.182806491851807f, 0.034476444125175f, + -0.182449504733086f, 0.034336645156145f, -0.182092398405075f, + 0.034197118133307f, -0.181735187768936f, 0.034057866781950f, + -0.181377857923508f, 0.033918887376785f, -0.181020438671112f, + 0.033780183643103f, -0.180662900209427f, 0.033641755580902f, + -0.180305257439613f, 0.033503599464893f, -0.179947525262833f, + 0.033365719020367f, -0.179589673876762f, 0.033228114247322f, + -0.179231703281403f, 0.033090781420469f, -0.178873643279076f, + 0.032953724265099f, -0.178515478968620f, 0.032816942781210f, + -0.178157210350037f, 0.032680433243513f, -0.177798837423325f, + 0.032544203102589f, -0.177440345287323f, 0.032408244907856f, + -0.177081763744354f, 0.032272562384605f, -0.176723077893257f, + 0.032137155532837f, -0.176364272832870f, 0.032002024352551f, + -0.176005378365517f, 0.031867165118456f, -0.175646379590034f, + 0.031732585281134f, -0.175287276506424f, 0.031598277390003f, + -0.174928069114685f, 0.031464248895645f, -0.174568757414818f, + 0.031330492347479f, -0.174209341406822f, 0.031197015196085f, + -0.173849821090698f, 0.031063811853528f, -0.173490211367607f, + 0.030930884182453f, -0.173130482435226f, 0.030798232182860f, + -0.172770664095879f, 0.030665857717395f, -0.172410741448402f, + 0.030533758923411f, -0.172050714492798f, 0.030401935800910f, + -0.171690583229065f, 0.030270388349891f, -0.171330362558365f, + 0.030139118432999f, -0.170970037579536f, 0.030008124187589f, + -0.170609608292580f, 0.029877405613661f, -0.170249074697495f, + 0.029746964573860f, -0.169888436794281f, 0.029616801068187f, + -0.169527709484100f, 0.029486913233995f, -0.169166877865791f, + 0.029357301071286f, -0.168805956840515f, 0.029227968305349f, + -0.168444931507111f, 0.029098909348249f, -0.168083801865578f, + 0.028970129787922f, -0.167722567915916f, 0.028841627761722f, + -0.167361244559288f, 0.028713401407003f, -0.166999831795692f, + 0.028585452586412f, -0.166638299822807f, 0.028457781299949f, + -0.166276678442955f, 0.028330387547612f, -0.165914967656136f, + 0.028203271329403f, -0.165553152561188f, 0.028076432645321f, + -0.165191248059273f, 0.027949871495366f, -0.164829224348068f, + 0.027823587879539f, -0.164467126131058f, 0.027697581797838f, + -0.164104923605919f, 0.027571853250265f, -0.163742616772652f, + 0.027446404099464f, -0.163380220532417f, 0.027321230620146f, + -0.163017734885216f, 0.027196336537600f, -0.162655144929886f, + 0.027071721851826f, -0.162292465567589f, 0.026947384700179f, + -0.161929681897163f, 0.026823325082660f, -0.161566808819771f, + 0.026699542999268f, -0.161203846335411f, 0.026576040312648f, + -0.160840779542923f, 0.026452817022800f, -0.160477623343468f, + 0.026329871267080f, -0.160114362835884f, 0.026207204908133f, + -0.159751012921333f, 0.026084816083312f, -0.159387573599815f, + 0.025962706655264f, -0.159024044871330f, 0.025840876623988f, + -0.158660411834717f, 0.025719324126840f, -0.158296689391136f, + 0.025598052889109f, -0.157932877540588f, 0.025477059185505f, + -0.157568961381912f, 0.025356344878674f, -0.157204970717430f, + 0.025235909968615f, -0.156840875744820f, 0.025115754455328f, + -0.156476691365242f, 0.024995878338814f, -0.156112402677536f, + 0.024876279756427f, -0.155748039484024f, 0.024756962433457f, + -0.155383571982384f, 0.024637924507260f, -0.155019029974937f, + 0.024519165977836f, -0.154654383659363f, 0.024400688707829f, + -0.154289647936821f, 0.024282488971949f, -0.153924822807312f, + 0.024164570495486f, -0.153559908270836f, 0.024046931415796f, + -0.153194904327393f, 0.023929571732879f, -0.152829796075821f, + 0.023812493309379f, -0.152464613318443f, 0.023695694282651f, + -0.152099341154099f, 0.023579176515341f, -0.151733979582787f, + 0.023462938144803f, -0.151368513703346f, 0.023346979171038f, + -0.151002973318100f, 0.023231301456690f, -0.150637343525887f, + 0.023115905001760f, -0.150271624326706f, 0.023000787943602f, + -0.149905815720558f, 0.022885952144861f, -0.149539917707443f, + 0.022771397605538f, -0.149173930287361f, 0.022657122462988f, + -0.148807853460312f, 0.022543128579855f, -0.148441687226295f, + 0.022429415956140f, -0.148075446486473f, 0.022315984591842f, + -0.147709101438522f, 0.022202832624316f, -0.147342681884766f, + 0.022089963778853f, -0.146976172924042f, 0.021977374330163f, + -0.146609574556351f, 0.021865066140890f, -0.146242901682854f, + 0.021753041073680f, -0.145876124501228f, 0.021641295403242f, + -0.145509272813797f, 0.021529832854867f, -0.145142331719399f, + 0.021418649703264f, -0.144775316119194f, 0.021307749673724f, + -0.144408211112022f, 0.021197130903602f, -0.144041016697884f, + 0.021086793392897f, -0.143673732876778f, 0.020976737141609f, + -0.143306359648705f, 0.020866964012384f, -0.142938911914825f, + 0.020757472142577f, -0.142571389675140f, 0.020648263394833f, + -0.142203763127327f, 0.020539334043860f, -0.141836062073708f, + 0.020430689677596f, -0.141468286514282f, 0.020322324708104f, + -0.141100421547890f, 0.020214242860675f, -0.140732467174530f, + 0.020106444135308f, -0.140364438295364f, 0.019998926669359f, + -0.139996320009232f, 0.019891692325473f, -0.139628127217293f, + 0.019784741103649f, -0.139259845018387f, 0.019678071141243f, + -0.138891488313675f, 0.019571684300900f, -0.138523042201996f, + 0.019465578719974f, -0.138154521584511f, 0.019359756261110f, + -0.137785911560059f, 0.019254218786955f, -0.137417227029800f, + 0.019148962572217f, -0.137048453092575f, 0.019043987616897f, + -0.136679604649544f, 0.018939297646284f, -0.136310681700706f, + 0.018834890797734f, -0.135941669344902f, 0.018730765208602f, + -0.135572582483292f, 0.018626924604177f, -0.135203406214714f, + 0.018523367121816f, -0.134834155440331f, 0.018420090898871f, + -0.134464830160141f, 0.018317099660635f, -0.134095430374146f, + 0.018214391544461f, -0.133725941181183f, 0.018111966550350f, + -0.133356377482414f, 0.018009826540947f, -0.132986739277840f, + 0.017907967790961f, -0.132617011666298f, 0.017806394025683f, + -0.132247209548950f, 0.017705103382468f, -0.131877332925797f, + 0.017604095861316f, -0.131507381796837f, 0.017503373324871f, + -0.131137356162071f, 0.017402933910489f, -0.130767241120338f, + 0.017302779480815f, -0.130397051572800f, 0.017202908173203f, + -0.130026802420616f, 0.017103319987655f, -0.129656463861465f, + 0.017004016786814f, -0.129286035895348f, 0.016904998570681f, + -0.128915548324585f, 0.016806263476610f, -0.128544986248016f, + 0.016707813367248f, -0.128174334764481f, 0.016609646379948f, + -0.127803623676300f, 0.016511764377356f, -0.127432823181152f, + 0.016414167359471f, -0.127061963081360f, 0.016316853463650f, + -0.126691013574600f, 0.016219824552536f, -0.126320004463196f, + 0.016123080626130f, -0.125948905944824f, 0.016026621684432f, + -0.125577747821808f, 0.015930447727442f, -0.125206500291824f, + 0.015834558755159f, -0.124835193157196f, 0.015738952904940f, + -0.124463804066181f, 0.015643632039428f, -0.124092340469360f, + 0.015548598021269f, -0.123720809817314f, 0.015453847125173f, + -0.123349204659462f, 0.015359382145107f, -0.122977524995804f, + 0.015265202149749f, -0.122605770826340f, 0.015171307139099f, + -0.122233949601650f, 0.015077698044479f, -0.121862053871155f, + 0.014984373003244f, -0.121490091085434f, 0.014891333878040f, + -0.121118053793907f, 0.014798580668867f, -0.120745941996574f, + 0.014706112444401f, -0.120373763144016f, 0.014613929204643f, + -0.120001509785652f, 0.014522032812238f, -0.119629189372063f, + 0.014430420473218f, -0.119256794452667f, 0.014339094981551f, + -0.118884332478046f, 0.014248054474592f, -0.118511803448200f, + 0.014157299883664f, -0.118139199912548f, 0.014066831208766f, + -0.117766529321671f, 0.013976648449898f, -0.117393791675568f, + 0.013886751607060f, -0.117020979523659f, 0.013797140680254f, + -0.116648100316525f, 0.013707815669477f, -0.116275154054165f, + 0.013618776574731f, -0.115902140736580f, 0.013530024327338f, + -0.115529052913189f, 0.013441557064652f, -0.115155905485153f, + 0.013353376649320f, -0.114782683551311f, 0.013265483081341f, + -0.114409394562244f, 0.013177875429392f, -0.114036038517952f, + 0.013090553693473f, -0.113662622869015f, 0.013003518804908f, + -0.113289132714272f, 0.012916770763695f, -0.112915575504303f, + 0.012830308638513f, -0.112541958689690f, 0.012744133360684f, + -0.112168267369270f, 0.012658244930208f, -0.111794516444206f, + 0.012572642415762f, -0.111420698463917f, 0.012487327679992f, + -0.111046813428402f, 0.012402298860252f, -0.110672861337662f, + 0.012317557819188f, -0.110298842191696f, 0.012233102694154f, + -0.109924763441086f, 0.012148935347795f, -0.109550617635250f, + 0.012065053917468f, -0.109176412224770f, 0.011981460265815f, + -0.108802139759064f, 0.011898153461516f, -0.108427800238132f, + 0.011815134435892f, -0.108053401112556f, 0.011732402257621f, + -0.107678934931755f, 0.011649956926703f, -0.107304409146309f, + 0.011567799374461f, -0.106929816305637f, 0.011485928669572f, + -0.106555156409740f, 0.011404345743358f, -0.106180444359779f, + 0.011323049664497f, -0.105805665254593f, 0.011242041364312f, + -0.105430819094181f, 0.011161320842803f, -0.105055920779705f, + 0.011080888099968f, -0.104680955410004f, 0.011000742204487f, + -0.104305922985077f, 0.010920885019004f, -0.103930838406086f, + 0.010841314680874f, -0.103555686771870f, 0.010762032121420f, + -0.103180475533009f, 0.010683037340641f, -0.102805204689503f, + 0.010604331269860f, -0.102429874241352f, 0.010525912046432f, + -0.102054484188557f, 0.010447781533003f, -0.101679034531116f, + 0.010369938798249f, -0.101303517818451f, 0.010292383842170f, + -0.100927948951721f, 0.010215117596090f, -0.100552320480347f, + 0.010138138197362f, -0.100176624953747f, 0.010061448439956f, + -0.099800877273083f, 0.009985045529902f, -0.099425069987774f, + 0.009908932261169f, -0.099049203097820f, 0.009833106771111f, + -0.098673284053802f, 0.009757569059730f, -0.098297297954559f, + 0.009682320058346f, -0.097921259701252f, 0.009607359766960f, + -0.097545161843300f, 0.009532688185573f, -0.097169004380703f, + 0.009458304382861f, -0.096792794764042f, 0.009384209290147f, + -0.096416525542736f, 0.009310402907431f, -0.096040196716785f, + 0.009236886166036f, -0.095663815736771f, 0.009163657203317f, + -0.095287375152111f, 0.009090716950595f, -0.094910882413387f, + 0.009018065407872f, -0.094534330070019f, 0.008945702575147f, + -0.094157725572586f, 0.008873629383743f, -0.093781061470509f, + 0.008801844902337f, -0.093404345214367f, 0.008730349130929f, + -0.093027576804161f, 0.008659142069519f, -0.092650748789310f, + 0.008588224649429f, -0.092273868620396f, 0.008517595939338f, + -0.091896936297417f, 0.008447255939245f, -0.091519944369793f, + 0.008377205580473f, -0.091142900288105f, 0.008307444863021f, + -0.090765804052353f, 0.008237972855568f, -0.090388655662537f, + 0.008168790489435f, -0.090011447668076f, 0.008099896833301f, + -0.089634194970131f, 0.008031292818487f, -0.089256882667542f, + 0.007962978444993f, -0.088879525661469f, 0.007894953712821f, + -0.088502109050751f, 0.007827218621969f, -0.088124647736549f, + 0.007759772241116f, -0.087747126817703f, 0.007692615967244f, + -0.087369553744793f, 0.007625748869032f, -0.086991935968399f, + 0.007559171877801f, -0.086614266037941f, 0.007492884527892f, + -0.086236543953419f, 0.007426886819303f, -0.085858769714832f, + 0.007361178752035f, -0.085480943322182f, 0.007295760791749f, + -0.085103072226048f, 0.007230632472783f, -0.084725148975849f, + 0.007165793795139f, -0.084347173571587f, 0.007101245224476f, + -0.083969146013260f, 0.007036986760795f, -0.083591073751450f, + 0.006973018404096f, -0.083212949335575f, 0.006909339688718f, + -0.082834780216217f, 0.006845951545984f, -0.082456558942795f, + 0.006782853044569f, -0.082078292965889f, 0.006720044650137f, + -0.081699974834919f, 0.006657526828349f, -0.081321612000465f, + 0.006595299113542f, -0.080943197011948f, 0.006533361505717f, + -0.080564737319946f, 0.006471714470536f, -0.080186225473881f, + 0.006410357542336f, -0.079807676374912f, 0.006349290721118f, + -0.079429075121880f, 0.006288514938205f, -0.079050421714783f, + 0.006228029262275f, -0.078671731054783f, 0.006167833693326f, + -0.078292988240719f, 0.006107929162681f, -0.077914200723171f, + 0.006048315204680f, -0.077535368502140f, 0.005988991353661f, + -0.077156484127045f, 0.005929958540946f, -0.076777562499046f, + 0.005871216300875f, -0.076398596167564f, 0.005812764633447f, + -0.076019577682018f, 0.005754603538662f, -0.075640521943569f, + 0.005696733482182f, -0.075261414051056f, 0.005639153998345f, + -0.074882268905640f, 0.005581865552813f, -0.074503071606159f, + 0.005524867679924f, -0.074123837053776f, 0.005468160845339f, + -0.073744557797909f, 0.005411745049059f, -0.073365233838558f, + 0.005355620291084f, -0.072985872626305f, 0.005299786105752f, + -0.072606459259987f, 0.005244242958724f, -0.072227008640766f, + 0.005188991315663f, -0.071847513318062f, 0.005134030245245f, + -0.071467980742455f, 0.005079360678792f, -0.071088403463364f, + 0.005024982150644f, -0.070708781480789f, 0.004970894660801f, + -0.070329122245312f, 0.004917098674923f, -0.069949418306351f, + 0.004863593727350f, -0.069569669663906f, 0.004810380283743f, + -0.069189883768559f, 0.004757457878441f, -0.068810060620308f, + 0.004704826977104f, -0.068430192768574f, 0.004652487114072f, + -0.068050287663937f, 0.004600439220667f, -0.067670337855816f, + 0.004548682365566f, -0.067290350794792f, 0.004497217014432f, + -0.066910326480865f, 0.004446043167263f, -0.066530264914036f, + 0.004395160824060f, -0.066150158643723f, 0.004344569984823f, + -0.065770015120506f, 0.004294271115214f, -0.065389834344387f, + 0.004244263283908f, -0.065009608864784f, 0.004194547422230f, + -0.064629353582859f, 0.004145123064518f, -0.064249053597450f, + 0.004095990676433f, -0.063868723809719f, 0.004047149792314f, + -0.063488349318504f, 0.003998600877821f, -0.063107937574387f, + 0.003950343467295f, -0.062727488577366f, 0.003902378026396f, + -0.062347009778023f, 0.003854704322293f, -0.061966486275196f, + 0.003807322587818f, -0.061585929244757f, 0.003760232590139f, + -0.061205338686705f, 0.003713434794918f, -0.060824707150459f, + 0.003666928736493f, -0.060444042086601f, 0.003620714880526f, + -0.060063343495131f, 0.003574792761356f, -0.059682607650757f, + 0.003529162844643f, -0.059301838278770f, 0.003483824897557f, + -0.058921031653881f, 0.003438779152930f, -0.058540191501379f, + 0.003394025377929f, -0.058159314095974f, 0.003349563805386f, + -0.057778406888247f, 0.003305394435301f, -0.057397462427616f, + 0.003261517267674f, -0.057016488164663f, 0.003217932302505f, + -0.056635476648808f, 0.003174639539793f, -0.056254431605339f, + 0.003131638979539f, -0.055873356759548f, 0.003088930854574f, + -0.055492244660854f, 0.003046514932066f, -0.055111102759838f, + 0.003004391444847f, -0.054729927331209f, 0.002962560392916f, + -0.054348722100258f, 0.002921021543443f, -0.053967483341694f, + 0.002879775362089f, -0.053586211055517f, 0.002838821383193f, + -0.053204908967018f, 0.002798160072416f, -0.052823577076197f, + 0.002757790964097f, -0.052442211657763f, 0.002717714523897f, + -0.052060816437006f, 0.002677930751815f, -0.051679391413927f, + 0.002638439415023f, -0.051297932863235f, 0.002599240746349f, + -0.050916448235512f, 0.002560334512964f, -0.050534930080175f, + 0.002521721180528f, -0.050153385847807f, 0.002483400283381f, + -0.049771808087826f, 0.002445372054353f, -0.049390204250813f, + 0.002407636726275f, -0.049008570611477f, 0.002370193833485f, + -0.048626907169819f, 0.002333043841645f, -0.048245213925838f, + 0.002296186750755f, -0.047863494604826f, 0.002259622327983f, + -0.047481749206781f, 0.002223350573331f, -0.047099970281124f, + 0.002187371719629f, -0.046718169003725f, 0.002151685766876f, + -0.046336337924004f, 0.002116292715073f, -0.045954477041960f, + 0.002081192564219f, -0.045572593808174f, 0.002046385314316f, + -0.045190680772066f, 0.002011870965362f, -0.044808741658926f, + 0.001977649517357f, -0.044426776468754f, 0.001943721086718f, + -0.044044785201550f, 0.001910085673444f, -0.043662767857313f, + 0.001876743277535f, -0.043280724436045f, 0.001843693898991f, + -0.042898654937744f, 0.001810937537812f, -0.042516563087702f, + 0.001778474310413f, -0.042134445160627f, 0.001746304216795f, + -0.041752301156521f, 0.001714427140541f, -0.041370131075382f, + 0.001682843198068f, -0.040987938642502f, 0.001651552389376f, + -0.040605723857880f, 0.001620554830879f, -0.040223482996225f, + 0.001589850406162f, -0.039841219782829f, 0.001559439115226f, + -0.039458930492401f, 0.001529321074486f, -0.039076622575521f, + 0.001499496400356f, -0.038694288581610f, 0.001469964860007f, + -0.038311932235956f, 0.001440726569854f, -0.037929553538561f, + 0.001411781646311f, -0.037547148764133f, 0.001383129972965f, + -0.037164725363255f, 0.001354771666229f, -0.036782283335924f, + 0.001326706726104f, -0.036399815231562f, 0.001298935036175f, + -0.036017324775457f, 0.001271456829272f, -0.035634815692902f, + 0.001244271872565f, -0.035252287983894f, 0.001217380515300f, + -0.034869734197855f, 0.001190782408230f, -0.034487165510654f, + 0.001164477784187f, -0.034104570746422f, 0.001138466643170f, + -0.033721961081028f, 0.001112748985179f, -0.033339329063892f, + 0.001087324810214f, -0.032956674695015f, 0.001062194118276f, + -0.032574005424976f, 0.001037356909364f, -0.032191313803196f, + 0.001012813183479f, -0.031808607280254f, 0.000988563057035f, + -0.031425878405571f, 0.000964606530033f, -0.031043132767081f, + 0.000940943544265f, -0.030660368502140f, 0.000917574157938f, + -0.030277585610747f, 0.000894498312846f, -0.029894785955548f, + 0.000871716125403f, -0.029511967673898f, 0.000849227537401f, + -0.029129132628441f, 0.000827032607049f, -0.028746278956532f, + 0.000805131276138f, -0.028363410383463f, 0.000783523661084f, + -0.027980525046587f, 0.000762209703680f, -0.027597622945905f, + 0.000741189462133f, -0.027214704081416f, 0.000720462878235f, + -0.026831768453121f, 0.000700030010194f, -0.026448817923665f, + 0.000679890916217f, -0.026065852493048f, 0.000660045538098f, + -0.025682870298624f, 0.000640493875835f, -0.025299875065684f, + 0.000621235987637f, -0.024916863068938f, 0.000602271873504f, + -0.024533838033676f, 0.000583601591643f, -0.024150796234608f, + 0.000565225025639f, -0.023767741397023f, 0.000547142291907f, + -0.023384673520923f, 0.000529353390448f, -0.023001590743661f, + 0.000511858321261f, -0.022618494927883f, 0.000494657084346f, + -0.022235386073589f, 0.000477749679703f, -0.021852264180779f, + 0.000461136136437f, -0.021469129249454f, 0.000444816454547f, + -0.021085981279612f, 0.000428790634032f, -0.020702820271254f, + 0.000413058703998f, -0.020319648087025f, 0.000397620693548f, + -0.019936462864280f, 0.000382476573577f, -0.019553268328309f, + 0.000367626344087f, -0.019170060753822f, 0.000353070063284f, + -0.018786842003465f, 0.000338807702065f, -0.018403612077236f, + 0.000324839289533f, -0.018020370975137f, 0.000311164796585f, + -0.017637118697166f, 0.000297784281429f, -0.017253857105970f, + 0.000284697714960f, -0.016870586201549f, 0.000271905126283f, + -0.016487304121256f, 0.000259406515397f, -0.016104012727737f, + 0.000247201882303f, -0.015720712020993f, 0.000235291256104f, + -0.015337402001023f, 0.000223674607696f, -0.014954082667828f, + 0.000212351980736f, -0.014570754021406f, 0.000201323360670f, + -0.014187417924404f, 0.000190588747500f, -0.013804072514176f, + 0.000180148170330f, -0.013420719653368f, 0.000170001629158f, + -0.013037359341979f, 0.000160149123985f, -0.012653990648687f, + 0.000150590654812f, -0.012270614504814f, 0.000141326236189f, + -0.011887230910361f, 0.000132355868118f, -0.011503840796649f, + 0.000123679565149f, -0.011120444163680f, 0.000115297327284f, + -0.010737040080130f, 0.000107209154521f, -0.010353630408645f, + 0.000099415054137f, -0.009970214217901f, 0.000091915040684f, + -0.009586792439222f, 0.000084709099610f, -0.009203365072608f, + 0.000077797252743f, -0.008819932118058f, 0.000071179500083f, + -0.008436493575573f, 0.000064855834353f, -0.008053051307797f, + 0.000058826273744f, -0.007669602986425f, 0.000053090810979f, + -0.007286150939763f, 0.000047649456974f, -0.006902694236487f, + 0.000042502211727f, -0.006519233807921f, 0.000037649078877f, + -0.006135769188404f, 0.000033090062061f, -0.005752300843596f, + 0.000028825161280f, -0.005368829704821f, 0.000024854381991f, + -0.004985354840755f, 0.000021177724193f, -0.004601877182722f, + 0.000017795191525f, -0.004218397196382f, 0.000014706784896f, + -0.003834914416075f, 0.000011912506125f, -0.003451429307461f, + 0.000009412358850f, -0.003067942336202f, 0.000007206342616f, + -0.002684453502297f, 0.000005294459243f, -0.002300963038579f, + 0.000003676709639f, -0.001917471294291f, 0.000002353095169f, + -0.001533978385851f, 0.000001323616516f, -0.001150484546088f, + 0.000000588274133f, -0.000766990066040f, 0.000000147068562f, + -0.000383495149435f, 0.000000000000000f, -0.000000000000023f, + 0.000000147068562f, 0.000383495149435f, 0.000000588274133f, + 0.000766990066040f, 0.000001323616516f, 0.001150484546088f, + 0.000002353095169f, 0.001533978385851f, 0.000003676709639f, + 0.001917471294291f, 0.000005294459243f, 0.002300963038579f, + 0.000007206342616f, 0.002684453502297f, 0.000009412358850f, + 0.003067942336202f, 0.000011912506125f, 0.003451429307461f, + 0.000014706784896f, 0.003834914416075f, 0.000017795191525f, + 0.004218397196382f, 0.000021177724193f, 0.004601877182722f, + 0.000024854381991f, 0.004985354840755f, 0.000028825161280f, + 0.005368829704821f, 0.000033090062061f, 0.005752300843596f, + 0.000037649078877f, 0.006135769188404f, 0.000042502211727f, + 0.006519233807921f, 0.000047649456974f, 0.006902694236487f, + 0.000053090810979f, 0.007286150939763f, 0.000058826273744f, + 0.007669602986425f, 0.000064855834353f, 0.008053051307797f, + 0.000071179500083f, 0.008436493575573f, 0.000077797252743f, + 0.008819932118058f, 0.000084709099610f, 0.009203365072608f, + 0.000091915040684f, 0.009586792439222f, 0.000099415054137f, + 0.009970214217901f, 0.000107209154521f, 0.010353630408645f, + 0.000115297327284f, 0.010737040080130f, 0.000123679565149f, + 0.011120444163680f, 0.000132355868118f, 0.011503840796649f, + 0.000141326236189f, 0.011887230910361f, 0.000150590654812f, + 0.012270614504814f, 0.000160149123985f, 0.012653990648687f, + 0.000170001629158f, 0.013037359341979f, 0.000180148170330f, + 0.013420719653368f, 0.000190588747500f, 0.013804072514176f, + 0.000201323360670f, 0.014187417924404f, 0.000212351980736f, + 0.014570754021406f, 0.000223674607696f, 0.014954082667828f, + 0.000235291256104f, 0.015337402001023f, 0.000247201882303f, + 0.015720712020993f, 0.000259406515397f, 0.016104012727737f, + 0.000271905126283f, 0.016487304121256f, 0.000284697714960f, + 0.016870586201549f, 0.000297784281429f, 0.017253857105970f, + 0.000311164796585f, 0.017637118697166f, 0.000324839289533f, + 0.018020370975137f, 0.000338807702065f, 0.018403612077236f, + 0.000353070063284f, 0.018786842003465f, 0.000367626344087f, + 0.019170060753822f, 0.000382476573577f, 0.019553268328309f, + 0.000397620693548f, 0.019936462864280f, 0.000413058703998f, + 0.020319648087025f, 0.000428790634032f, 0.020702820271254f, + 0.000444816454547f, 0.021085981279612f, 0.000461136136437f, + 0.021469129249454f, 0.000477749679703f, 0.021852264180779f, + 0.000494657084346f, 0.022235386073589f, 0.000511858321261f, + 0.022618494927883f, 0.000529353390448f, 0.023001590743661f, + 0.000547142291907f, 0.023384673520923f, 0.000565225025639f, + 0.023767741397023f, 0.000583601591643f, 0.024150796234608f, + 0.000602271873504f, 0.024533838033676f, 0.000621235987637f, + 0.024916863068938f, 0.000640493875835f, 0.025299875065684f, + 0.000660045538098f, 0.025682870298624f, 0.000679890916217f, + 0.026065852493048f, 0.000700030010194f, 0.026448817923665f, + 0.000720462878235f, 0.026831768453121f, 0.000741189462133f, + 0.027214704081416f, 0.000762209703680f, 0.027597622945905f, + 0.000783523661084f, 0.027980525046587f, 0.000805131276138f, + 0.028363410383463f, 0.000827032607049f, 0.028746278956532f, + 0.000849227537401f, 0.029129132628441f, 0.000871716125403f, + 0.029511967673898f, 0.000894498312846f, 0.029894785955548f, + 0.000917574157938f, 0.030277585610747f, 0.000940943544265f, + 0.030660368502140f, 0.000964606530033f, 0.031043132767081f, + 0.000988563057035f, 0.031425878405571f, 0.001012813183479f, + 0.031808607280254f, 0.001037356909364f, 0.032191313803196f, + 0.001062194118276f, 0.032574005424976f, 0.001087324810214f, + 0.032956674695015f, 0.001112748985179f, 0.033339329063892f, + 0.001138466643170f, 0.033721961081028f, 0.001164477784187f, + 0.034104570746422f, 0.001190782408230f, 0.034487165510654f, + 0.001217380515300f, 0.034869734197855f, 0.001244271872565f, + 0.035252287983894f, 0.001271456829272f, 0.035634815692902f, + 0.001298935036175f, 0.036017324775457f, 0.001326706726104f, + 0.036399815231562f, 0.001354771666229f, 0.036782283335924f, + 0.001383129972965f, 0.037164725363255f, 0.001411781646311f, + 0.037547148764133f, 0.001440726569854f, 0.037929553538561f, + 0.001469964860007f, 0.038311932235956f, 0.001499496400356f, + 0.038694288581610f, 0.001529321074486f, 0.039076622575521f, + 0.001559439115226f, 0.039458930492401f, 0.001589850406162f, + 0.039841219782829f, 0.001620554830879f, 0.040223482996225f, + 0.001651552389376f, 0.040605723857880f, 0.001682843198068f, + 0.040987938642502f, 0.001714427140541f, 0.041370131075382f, + 0.001746304216795f, 0.041752301156521f, 0.001778474310413f, + 0.042134445160627f, 0.001810937537812f, 0.042516563087702f, + 0.001843693898991f, 0.042898654937744f, 0.001876743277535f, + 0.043280724436045f, 0.001910085673444f, 0.043662767857313f, + 0.001943721086718f, 0.044044785201550f, 0.001977649517357f, + 0.044426776468754f, 0.002011870965362f, 0.044808741658926f, + 0.002046385314316f, 0.045190680772066f, 0.002081192564219f, + 0.045572593808174f, 0.002116292715073f, 0.045954477041960f, + 0.002151685766876f, 0.046336337924004f, 0.002187371719629f, + 0.046718169003725f, 0.002223350573331f, 0.047099970281124f, + 0.002259622327983f, 0.047481749206781f, 0.002296186750755f, + 0.047863494604826f, 0.002333043841645f, 0.048245213925838f, + 0.002370193833485f, 0.048626907169819f, 0.002407636726275f, + 0.049008570611477f, 0.002445372054353f, 0.049390204250813f, + 0.002483400283381f, 0.049771808087826f, 0.002521721180528f, + 0.050153385847807f, 0.002560334512964f, 0.050534930080175f, + 0.002599240746349f, 0.050916448235512f, 0.002638439415023f, + 0.051297932863235f, 0.002677930751815f, 0.051679391413927f, + 0.002717714523897f, 0.052060816437006f, 0.002757790964097f, + 0.052442211657763f, 0.002798160072416f, 0.052823577076197f, + 0.002838821383193f, 0.053204908967018f, 0.002879775362089f, + 0.053586211055517f, 0.002921021543443f, 0.053967483341694f, + 0.002962560392916f, 0.054348722100258f, 0.003004391444847f, + 0.054729927331209f, 0.003046514932066f, 0.055111102759838f, + 0.003088930854574f, 0.055492244660854f, 0.003131638979539f, + 0.055873356759548f, 0.003174639539793f, 0.056254431605339f, + 0.003217932302505f, 0.056635476648808f, 0.003261517267674f, + 0.057016488164663f, 0.003305394435301f, 0.057397462427616f, + 0.003349563805386f, 0.057778406888247f, 0.003394025377929f, + 0.058159314095974f, 0.003438779152930f, 0.058540191501379f, + 0.003483824897557f, 0.058921031653881f, 0.003529162844643f, + 0.059301838278770f, 0.003574792761356f, 0.059682607650757f, + 0.003620714880526f, 0.060063343495131f, 0.003666928736493f, + 0.060444042086601f, 0.003713434794918f, 0.060824707150459f, + 0.003760232590139f, 0.061205338686705f, 0.003807322587818f, + 0.061585929244757f, 0.003854704322293f, 0.061966486275196f, + 0.003902378026396f, 0.062347009778023f, 0.003950343467295f, + 0.062727488577366f, 0.003998600877821f, 0.063107937574387f, + 0.004047149792314f, 0.063488349318504f, 0.004095990676433f, + 0.063868723809719f, 0.004145123064518f, 0.064249053597450f, + 0.004194547422230f, 0.064629353582859f, 0.004244263283908f, + 0.065009608864784f, 0.004294271115214f, 0.065389834344387f, + 0.004344569984823f, 0.065770015120506f, 0.004395160824060f, + 0.066150158643723f, 0.004446043167263f, 0.066530264914036f, + 0.004497217014432f, 0.066910326480865f, 0.004548682365566f, + 0.067290350794792f, 0.004600439220667f, 0.067670337855816f, + 0.004652487114072f, 0.068050287663937f, 0.004704826977104f, + 0.068430192768574f, 0.004757457878441f, 0.068810060620308f, + 0.004810380283743f, 0.069189883768559f, 0.004863593727350f, + 0.069569669663906f, 0.004917098674923f, 0.069949418306351f, + 0.004970894660801f, 0.070329122245312f, 0.005024982150644f, + 0.070708781480789f, 0.005079360678792f, 0.071088403463364f, + 0.005134030245245f, 0.071467980742455f, 0.005188991315663f, + 0.071847513318062f, 0.005244242958724f, 0.072227008640766f, + 0.005299786105752f, 0.072606459259987f, 0.005355620291084f, + 0.072985872626305f, 0.005411745049059f, 0.073365233838558f, + 0.005468160845339f, 0.073744557797909f, 0.005524867679924f, + 0.074123837053776f, 0.005581865552813f, 0.074503071606159f, + 0.005639153998345f, 0.074882268905640f, 0.005696733482182f, + 0.075261414051056f, 0.005754603538662f, 0.075640521943569f, + 0.005812764633447f, 0.076019577682018f, 0.005871216300875f, + 0.076398596167564f, 0.005929958540946f, 0.076777562499046f, + 0.005988991353661f, 0.077156484127045f, 0.006048315204680f, + 0.077535368502140f, 0.006107929162681f, 0.077914200723171f, + 0.006167833693326f, 0.078292988240719f, 0.006228029262275f, + 0.078671731054783f, 0.006288514938205f, 0.079050421714783f, + 0.006349290721118f, 0.079429075121880f, 0.006410357542336f, + 0.079807676374912f, 0.006471714470536f, 0.080186225473881f, + 0.006533361505717f, 0.080564737319946f, 0.006595299113542f, + 0.080943197011948f, 0.006657526828349f, 0.081321612000465f, + 0.006720044650137f, 0.081699974834919f, 0.006782853044569f, + 0.082078292965889f, 0.006845951545984f, 0.082456558942795f, + 0.006909339688718f, 0.082834780216217f, 0.006973018404096f, + 0.083212949335575f, 0.007036986760795f, 0.083591073751450f, + 0.007101245224476f, 0.083969146013260f, 0.007165793795139f, + 0.084347173571587f, 0.007230632472783f, 0.084725148975849f, + 0.007295760791749f, 0.085103072226048f, 0.007361178752035f, + 0.085480943322182f, 0.007426886819303f, 0.085858769714832f, + 0.007492884527892f, 0.086236543953419f, 0.007559171877801f, + 0.086614266037941f, 0.007625748869032f, 0.086991935968399f, + 0.007692615967244f, 0.087369553744793f, 0.007759772241116f, + 0.087747126817703f, 0.007827218621969f, 0.088124647736549f, + 0.007894953712821f, 0.088502109050751f, 0.007962978444993f, + 0.088879525661469f, 0.008031292818487f, 0.089256882667542f, + 0.008099896833301f, 0.089634194970131f, 0.008168790489435f, + 0.090011447668076f, 0.008237972855568f, 0.090388655662537f, + 0.008307444863021f, 0.090765804052353f, 0.008377205580473f, + 0.091142900288105f, 0.008447255939245f, 0.091519944369793f, + 0.008517595939338f, 0.091896936297417f, 0.008588224649429f, + 0.092273868620396f, 0.008659142069519f, 0.092650748789310f, + 0.008730349130929f, 0.093027576804161f, 0.008801844902337f, + 0.093404345214367f, 0.008873629383743f, 0.093781061470509f, + 0.008945702575147f, 0.094157725572586f, 0.009018065407872f, + 0.094534330070019f, 0.009090716950595f, 0.094910882413387f, + 0.009163657203317f, 0.095287375152111f, 0.009236886166036f, + 0.095663815736771f, 0.009310402907431f, 0.096040196716785f, + 0.009384209290147f, 0.096416525542736f, 0.009458304382861f, + 0.096792794764042f, 0.009532688185573f, 0.097169004380703f, + 0.009607359766960f, 0.097545161843300f, 0.009682320058346f, + 0.097921259701252f, 0.009757569059730f, 0.098297297954559f, + 0.009833106771111f, 0.098673284053802f, 0.009908932261169f, + 0.099049203097820f, 0.009985045529902f, 0.099425069987774f, + 0.010061448439956f, 0.099800877273083f, 0.010138138197362f, + 0.100176624953747f, 0.010215117596090f, 0.100552320480347f, + 0.010292383842170f, 0.100927948951721f, 0.010369938798249f, + 0.101303517818451f, 0.010447781533003f, 0.101679034531116f, + 0.010525912046432f, 0.102054484188557f, 0.010604331269860f, + 0.102429874241352f, 0.010683037340641f, 0.102805204689503f, + 0.010762032121420f, 0.103180475533009f, 0.010841314680874f, + 0.103555686771870f, 0.010920885019004f, 0.103930838406086f, + 0.011000742204487f, 0.104305922985077f, 0.011080888099968f, + 0.104680955410004f, 0.011161320842803f, 0.105055920779705f, + 0.011242041364312f, 0.105430819094181f, 0.011323049664497f, + 0.105805665254593f, 0.011404345743358f, 0.106180444359779f, + 0.011485928669572f, 0.106555156409740f, 0.011567799374461f, + 0.106929816305637f, 0.011649956926703f, 0.107304409146309f, + 0.011732402257621f, 0.107678934931755f, 0.011815134435892f, + 0.108053401112556f, 0.011898153461516f, 0.108427800238132f, + 0.011981460265815f, 0.108802139759064f, 0.012065053917468f, + 0.109176412224770f, 0.012148935347795f, 0.109550617635250f, + 0.012233102694154f, 0.109924763441086f, 0.012317557819188f, + 0.110298842191696f, 0.012402298860252f, 0.110672861337662f, + 0.012487327679992f, 0.111046813428402f, 0.012572642415762f, + 0.111420698463917f, 0.012658244930208f, 0.111794516444206f, + 0.012744133360684f, 0.112168267369270f, 0.012830308638513f, + 0.112541958689690f, 0.012916770763695f, 0.112915575504303f, + 0.013003518804908f, 0.113289132714272f, 0.013090553693473f, + 0.113662622869015f, 0.013177875429392f, 0.114036038517952f, + 0.013265483081341f, 0.114409394562244f, 0.013353376649320f, + 0.114782683551311f, 0.013441557064652f, 0.115155905485153f, + 0.013530024327338f, 0.115529052913189f, 0.013618776574731f, + 0.115902140736580f, 0.013707815669477f, 0.116275154054165f, + 0.013797140680254f, 0.116648100316525f, 0.013886751607060f, + 0.117020979523659f, 0.013976648449898f, 0.117393791675568f, + 0.014066831208766f, 0.117766529321671f, 0.014157299883664f, + 0.118139199912548f, 0.014248054474592f, 0.118511803448200f, + 0.014339094981551f, 0.118884332478046f, 0.014430420473218f, + 0.119256794452667f, 0.014522032812238f, 0.119629189372063f, + 0.014613929204643f, 0.120001509785652f, 0.014706112444401f, + 0.120373763144016f, 0.014798580668867f, 0.120745941996574f, + 0.014891333878040f, 0.121118053793907f, 0.014984373003244f, + 0.121490091085434f, 0.015077698044479f, 0.121862053871155f, + 0.015171307139099f, 0.122233949601650f, 0.015265202149749f, + 0.122605770826340f, 0.015359382145107f, 0.122977524995804f, + 0.015453847125173f, 0.123349204659462f, 0.015548598021269f, + 0.123720809817314f, 0.015643632039428f, 0.124092340469360f, + 0.015738952904940f, 0.124463804066181f, 0.015834558755159f, + 0.124835193157196f, 0.015930447727442f, 0.125206500291824f, + 0.016026621684432f, 0.125577747821808f, 0.016123080626130f, + 0.125948905944824f, 0.016219824552536f, 0.126320004463196f, + 0.016316853463650f, 0.126691013574600f, 0.016414167359471f, + 0.127061963081360f, 0.016511764377356f, 0.127432823181152f, + 0.016609646379948f, 0.127803623676300f, 0.016707813367248f, + 0.128174334764481f, 0.016806263476610f, 0.128544986248016f, + 0.016904998570681f, 0.128915548324585f, 0.017004016786814f, + 0.129286035895348f, 0.017103319987655f, 0.129656463861465f, + 0.017202908173203f, 0.130026802420616f, 0.017302779480815f, + 0.130397051572800f, 0.017402933910489f, 0.130767241120338f, + 0.017503373324871f, 0.131137356162071f, 0.017604095861316f, + 0.131507381796837f, 0.017705103382468f, 0.131877332925797f, + 0.017806394025683f, 0.132247209548950f, 0.017907967790961f, + 0.132617011666298f, 0.018009826540947f, 0.132986739277840f, + 0.018111966550350f, 0.133356377482414f, 0.018214391544461f, + 0.133725941181183f, 0.018317099660635f, 0.134095430374146f, + 0.018420090898871f, 0.134464830160141f, 0.018523367121816f, + 0.134834155440331f, 0.018626924604177f, 0.135203406214714f, + 0.018730765208602f, 0.135572582483292f, 0.018834890797734f, + 0.135941669344902f, 0.018939297646284f, 0.136310681700706f, + 0.019043987616897f, 0.136679604649544f, 0.019148962572217f, + 0.137048453092575f, 0.019254218786955f, 0.137417227029800f, + 0.019359756261110f, 0.137785911560059f, 0.019465578719974f, + 0.138154521584511f, 0.019571684300900f, 0.138523042201996f, + 0.019678071141243f, 0.138891488313675f, 0.019784741103649f, + 0.139259845018387f, 0.019891692325473f, 0.139628127217293f, + 0.019998926669359f, 0.139996320009232f, 0.020106444135308f, + 0.140364438295364f, 0.020214242860675f, 0.140732467174530f, + 0.020322324708104f, 0.141100421547890f, 0.020430689677596f, + 0.141468286514282f, 0.020539334043860f, 0.141836062073708f, + 0.020648263394833f, 0.142203763127327f, 0.020757472142577f, + 0.142571389675140f, 0.020866964012384f, 0.142938911914825f, + 0.020976737141609f, 0.143306359648705f, 0.021086793392897f, + 0.143673732876778f, 0.021197130903602f, 0.144041016697884f, + 0.021307749673724f, 0.144408211112022f, 0.021418649703264f, + 0.144775316119194f, 0.021529832854867f, 0.145142331719399f, + 0.021641295403242f, 0.145509272813797f, 0.021753041073680f, + 0.145876124501228f, 0.021865066140890f, 0.146242901682854f, + 0.021977374330163f, 0.146609574556351f, 0.022089963778853f, + 0.146976172924042f, 0.022202832624316f, 0.147342681884766f, + 0.022315984591842f, 0.147709101438522f, 0.022429415956140f, + 0.148075446486473f, 0.022543128579855f, 0.148441687226295f, + 0.022657122462988f, 0.148807853460312f, 0.022771397605538f, + 0.149173930287361f, 0.022885952144861f, 0.149539917707443f, + 0.023000787943602f, 0.149905815720558f, 0.023115905001760f, + 0.150271624326706f, 0.023231301456690f, 0.150637343525887f, + 0.023346979171038f, 0.151002973318100f, 0.023462938144803f, + 0.151368513703346f, 0.023579176515341f, 0.151733979582787f, + 0.023695694282651f, 0.152099341154099f, 0.023812493309379f, + 0.152464613318443f, 0.023929571732879f, 0.152829796075821f, + 0.024046931415796f, 0.153194904327393f, 0.024164570495486f, + 0.153559908270836f, 0.024282488971949f, 0.153924822807312f, + 0.024400688707829f, 0.154289647936821f, 0.024519165977836f, + 0.154654383659363f, 0.024637924507260f, 0.155019029974937f, + 0.024756962433457f, 0.155383571982384f, 0.024876279756427f, + 0.155748039484024f, 0.024995878338814f, 0.156112402677536f, + 0.025115754455328f, 0.156476691365242f, 0.025235909968615f, + 0.156840875744820f, 0.025356344878674f, 0.157204970717430f, + 0.025477059185505f, 0.157568961381912f, 0.025598052889109f, + 0.157932877540588f, 0.025719324126840f, 0.158296689391136f, + 0.025840876623988f, 0.158660411834717f, 0.025962706655264f, + 0.159024044871330f, 0.026084816083312f, 0.159387573599815f, + 0.026207204908133f, 0.159751012921333f, 0.026329871267080f, + 0.160114362835884f, 0.026452817022800f, 0.160477623343468f, + 0.026576040312648f, 0.160840779542923f, 0.026699542999268f, + 0.161203846335411f, 0.026823325082660f, 0.161566808819771f, + 0.026947384700179f, 0.161929681897163f, 0.027071721851826f, + 0.162292465567589f, 0.027196336537600f, 0.162655144929886f, + 0.027321230620146f, 0.163017734885216f, 0.027446404099464f, + 0.163380220532417f, 0.027571853250265f, 0.163742616772652f, + 0.027697581797838f, 0.164104923605919f, 0.027823587879539f, + 0.164467126131058f, 0.027949871495366f, 0.164829224348068f, + 0.028076432645321f, 0.165191248059273f, 0.028203271329403f, + 0.165553152561188f, 0.028330387547612f, 0.165914967656136f, + 0.028457781299949f, 0.166276678442955f, 0.028585452586412f, + 0.166638299822807f, 0.028713401407003f, 0.166999831795692f, + 0.028841627761722f, 0.167361244559288f, 0.028970129787922f, + 0.167722567915916f, 0.029098909348249f, 0.168083801865578f, + 0.029227968305349f, 0.168444931507111f, 0.029357301071286f, + 0.168805956840515f, 0.029486913233995f, 0.169166877865791f, + 0.029616801068187f, 0.169527709484100f, 0.029746964573860f, + 0.169888436794281f, 0.029877405613661f, 0.170249074697495f, + 0.030008124187589f, 0.170609608292580f, 0.030139118432999f, + 0.170970037579536f, 0.030270388349891f, 0.171330362558365f, + 0.030401935800910f, 0.171690583229065f, 0.030533758923411f, + 0.172050714492798f, 0.030665857717395f, 0.172410741448402f, + 0.030798232182860f, 0.172770664095879f, 0.030930884182453f, + 0.173130482435226f, 0.031063811853528f, 0.173490211367607f, + 0.031197015196085f, 0.173849821090698f, 0.031330492347479f, + 0.174209341406822f, 0.031464248895645f, 0.174568757414818f, + 0.031598277390003f, 0.174928069114685f, 0.031732585281134f, + 0.175287276506424f, 0.031867165118456f, 0.175646379590034f, + 0.032002024352551f, 0.176005378365517f, 0.032137155532837f, + 0.176364272832870f, 0.032272562384605f, 0.176723077893257f, + 0.032408244907856f, 0.177081763744354f, 0.032544203102589f, + 0.177440345287323f, 0.032680433243513f, 0.177798837423325f, + 0.032816942781210f, 0.178157210350037f, 0.032953724265099f, + 0.178515478968620f, 0.033090781420469f, 0.178873643279076f, + 0.033228114247322f, 0.179231703281403f, 0.033365719020367f, + 0.179589673876762f, 0.033503599464893f, 0.179947525262833f, + 0.033641755580902f, 0.180305257439613f, 0.033780183643103f, + 0.180662900209427f, 0.033918887376785f, 0.181020438671112f, + 0.034057866781950f, 0.181377857923508f, 0.034197118133307f, + 0.181735187768936f, 0.034336645156145f, 0.182092398405075f, + 0.034476444125175f, 0.182449504733086f, 0.034616518765688f, + 0.182806491851807f, 0.034756865352392f, 0.183163389563560f, + 0.034897487610579f, 0.183520168066025f, 0.035038381814957f, + 0.183876842260361f, 0.035179551690817f, 0.184233412146568f, + 0.035320993512869f, 0.184589877724648f, 0.035462711006403f, + 0.184946224093437f, 0.035604696720839f, 0.185302466154099f, + 0.035746958106756f, 0.185658603906631f, 0.035889495164156f, + 0.186014622449875f, 0.036032304167747f, 0.186370536684990f, + 0.036175385117531f, 0.186726331710815f, 0.036318738013506f, + 0.187082037329674f, 0.036462362855673f, 0.187437608838081f, + 0.036606263369322f, 0.187793090939522f, 0.036750435829163f, + 0.188148453831673f, 0.036894880235195f, 0.188503712415695f, + 0.037039596587420f, 0.188858851790428f, 0.037184584885836f, + 0.189213871955872f, 0.037329845130444f, 0.189568802714348f, + 0.037475381046534f, 0.189923599362373f, 0.037621185183525f, + 0.190278306603432f, 0.037767261266708f, 0.190632879734039f, + 0.037913613021374f, 0.190987363457680f, 0.038060232996941f, + 0.191341713070869f, 0.038207128643990f, 0.191695958375931f, + 0.038354292511940f, 0.192050099372864f, 0.038501728326082f, + 0.192404121160507f, 0.038649436086416f, 0.192758023738861f, + 0.038797415792942f, 0.193111822009087f, 0.038945667445660f, + 0.193465501070023f, 0.039094187319279f, 0.193819075822830f, + 0.039242979139090f, 0.194172516465187f, 0.039392042905092f, + 0.194525867700577f, 0.039541378617287f, 0.194879084825516f, + 0.039690986275673f, 0.195232197642326f, 0.039840862154961f, + 0.195585191249847f, 0.039991009980440f, 0.195938065648079f, + 0.040141426026821f, 0.196290835738182f, 0.040292114019394f, + 0.196643486618996f, 0.040443073958158f, 0.196996018290520f, + 0.040594302117825f, 0.197348430752754f, 0.040745802223682f, + 0.197700738906860f, 0.040897574275732f, 0.198052927851677f, + 0.041049610823393f, 0.198404997587204f, 0.041201923042536f, + 0.198756948113441f, 0.041354499757290f, 0.199108779430389f, + 0.041507352143526f, 0.199460506439209f, 0.041660469025373f, + 0.199812099337578f, 0.041813857853413f, 0.200163587927818f, + 0.041967518627644f, 0.200514942407608f, 0.042121443897486f, + 0.200866192579269f, 0.042275641113520f, 0.201217323541641f, + 0.042430106550455f, 0.201568335294724f, 0.042584843933582f, + 0.201919227838516f, 0.042739849537611f, 0.202270001173019f, + 0.042895123362541f, 0.202620655298233f, 0.043050665408373f, + 0.202971190214157f, 0.043206475675106f, 0.203321605920792f, + 0.043362557888031f, 0.203671902418137f, 0.043518904596567f, + 0.204022079706192f, 0.043675523251295f, 0.204372137784958f, + 0.043832406401634f, 0.204722076654434f, 0.043989561498165f, + 0.205071896314621f, 0.044146984815598f, 0.205421581864357f, + 0.044304672628641f, 0.205771163105965f, 0.044462632387877f, + 0.206120610237122f, 0.044620860368013f, 0.206469938158989f, + 0.044779352843761f, 0.206819161772728f, 0.044938117265701f, + 0.207168251276016f, 0.045097146183252f, 0.207517206668854f, + 0.045256443321705f, 0.207866057753563f, 0.045416008681059f, + 0.208214774727821f, 0.045575842261314f, 0.208563387393951f, + 0.045735940337181f, 0.208911851048470f, 0.045896306633949f, + 0.209260210394859f, 0.046056941151619f, 0.209608450531960f, + 0.046217843890190f, 0.209956556558609f, 0.046379011124372f, + 0.210304543375969f, 0.046540446579456f, 0.210652396082878f, + 0.046702146530151f, 0.211000129580498f, 0.046864114701748f, + 0.211347743868828f, 0.047026351094246f, 0.211695238947868f, + 0.047188851982355f, 0.212042599916458f, 0.047351621091366f, + 0.212389841675758f, 0.047514654695988f, 0.212736949324608f, + 0.047677956521511f, 0.213083937764168f, 0.047841522842646f, + 0.213430806994438f, 0.048005353659391f, 0.213777542114258f, + 0.048169452697039f, 0.214124158024788f, 0.048333816230297f, + 0.214470639824867f, 0.048498444259167f, 0.214817002415657f, + 0.048663340508938f, 0.215163245797157f, 0.048828501254320f, + 0.215509355068207f, 0.048993926495314f, 0.215855330228806f, + 0.049159619957209f, 0.216201186180115f, 0.049325577914715f, + 0.216546908020973f, 0.049491796642542f, 0.216892510652542f, + 0.049658283591270f, 0.217237979173660f, 0.049825038760900f, + 0.217583328485489f, 0.049992054700851f, 0.217928543686867f, + 0.050159335136414f, 0.218273624777794f, 0.050326880067587f, + 0.218618586659431f, 0.050494693219662f, 0.218963414430618f, + 0.050662767142057f, 0.219308122992516f, 0.050831105560064f, + 0.219652697443962f, 0.050999708473682f, 0.219997137784958f, + 0.051168579608202f, 0.220341444015503f, 0.051337707787752f, + 0.220685631036758f, 0.051507104188204f, 0.221029683947563f, + 0.051676765084267f, 0.221373617649078f, 0.051846686750650f, + 0.221717402338982f, 0.052016876637936f, 0.222061067819595f, + 0.052187327295542f, 0.222404599189758f, 0.052358038723469f, + 0.222748011350632f, 0.052529018372297f, 0.223091274499893f, + 0.052700258791447f, 0.223434418439865f, 0.052871759980917f, + 0.223777428269386f, 0.053043525665998f, 0.224120303988457f, + 0.053215555846691f, 0.224463045597076f, 0.053387850522995f, + 0.224805667996407f, 0.053560405969620f, 0.225148141384125f, + 0.053733222186565f, 0.225490495562553f, 0.053906302899122f, + 0.225832715630531f, 0.054079644382000f, 0.226174786686897f, + 0.054253250360489f, 0.226516738533974f, 0.054427117109299f, + 0.226858556270599f, 0.054601248353720f, 0.227200239896774f, + 0.054775636643171f, 0.227541789412498f, 0.054950293153524f, + 0.227883204817772f, 0.055125206708908f, 0.228224486112595f, + 0.055300384759903f, 0.228565633296967f, 0.055475823581219f, + 0.228906646370888f, 0.055651523172855f, 0.229247525334358f, + 0.055827483534813f, 0.229588270187378f, 0.056003704667091f, + 0.229928880929947f, 0.056180190294981f, 0.230269357562065f, + 0.056356932967901f, 0.230609700083733f, 0.056533940136433f, + 0.230949893593788f, 0.056711208075285f, 0.231289967894554f, + 0.056888736784458f, 0.231629893183708f, 0.057066522538662f, + 0.231969684362412f, 0.057244572788477f, 0.232309341430664f, + 0.057422880083323f, 0.232648864388466f, 0.057601451873779f, + 0.232988253235817f, 0.057780280709267f, 0.233327493071556f, + 0.057959370315075f, 0.233666598796844f, 0.058138720691204f, + 0.234005570411682f, 0.058318331837654f, 0.234344407916069f, + 0.058498200029135f, 0.234683111310005f, 0.058678328990936f, + 0.235021665692329f, 0.058858718723059f, 0.235360085964203f, + 0.059039369225502f, 0.235698372125626f, 0.059220276772976f, + 0.236036509275436f, 0.059401445090771f, 0.236374512314796f, + 0.059582870453596f, 0.236712381243706f, 0.059764556586742f, + 0.237050101161003f, 0.059946499764919f, 0.237387686967850f, + 0.060128703713417f, 0.237725138664246f, 0.060311164706945f, + 0.238062441349030f, 0.060493886470795f, 0.238399609923363f, + 0.060676865279675f, 0.238736644387245f, 0.060860104858875f, + 0.239073529839516f, 0.061043601483107f, 0.239410281181335f, + 0.061227355152369f, 0.239746883511543f, 0.061411365866661f, + 0.240083336830139f, 0.061595637351274f, 0.240419670939446f, + 0.061780165880919f, 0.240755841135979f, 0.061964951455593f, + 0.241091892123222f, 0.062149997800589f, 0.241427779197693f, + 0.062335297465324f, 0.241763532161713f, 0.062520854175091f, + 0.242099151015282f, 0.062706671655178f, 0.242434620857239f, + 0.062892749905586f, 0.242769956588745f, 0.063079081475735f, + 0.243105143308640f, 0.063265666365623f, 0.243440181016922f, + 0.063452512025833f, 0.243775084614754f, 0.063639611005783f, + 0.244109839200974f, 0.063826970756054f, 0.244444444775581f, + 0.064014583826065f, 0.244778916239738f, 0.064202457666397f, + 0.245113238692284f, 0.064390584826469f, 0.245447427034378f, + 0.064578965306282f, 0.245781451463699f, 0.064767606556416f, + 0.246115356683731f, 0.064956501126289f, 0.246449097990990f, + 0.065145656466484f, 0.246782705187798f, 0.065335065126419f, + 0.247116148471832f, 0.065524727106094f, 0.247449472546577f, + 0.065714649856091f, 0.247782632708550f, 0.065904818475246f, + 0.248115643858910f, 0.066095255315304f, 0.248448520898819f, + 0.066285938024521f, 0.248781248927116f, 0.066476874053478f, + 0.249113827943802f, 0.066668070852757f, 0.249446272850037f, + 0.066859520971775f, 0.249778553843498f, 0.067051224410534f, + 0.250110685825348f, 0.067243188619614f, 0.250442683696747f, + 0.067435398697853f, 0.250774532556534f, 0.067627869546413f, + 0.251106232404709f, 0.067820593714714f, 0.251437783241272f, + 0.068013571202755f, 0.251769185066223f, 0.068206802010536f, + 0.252100437879562f, 0.068400286138058f, 0.252431541681290f, + 0.068594031035900f, 0.252762526273727f, 0.068788021802902f, + 0.253093332052231f, 0.068982265889645f, 0.253423988819122f, + 0.069176770746708f, 0.253754496574402f, 0.069371521472931f, + 0.254084855318069f, 0.069566532969475f, 0.254415065050125f, + 0.069761790335178f, 0.254745125770569f, 0.069957308471203f, + 0.255075037479401f, 0.070153072476387f, 0.255404800176620f, + 0.070349089801311f, 0.255734413862228f, 0.070545360445976f, + 0.256063878536224f, 0.070741884410381f, 0.256393194198608f, + 0.070938661694527f, 0.256722360849380f, 0.071135692298412f, + 0.257051378488541f, 0.071332976222038f, 0.257380217313766f, + 0.071530513465405f, 0.257708936929703f, 0.071728296577930f, + 0.258037507534027f, 0.071926333010197f, 0.258365899324417f, + 0.072124622762203f, 0.258694142103195f, 0.072323165833950f, + 0.259022265672684f, 0.072521962225437f, 0.259350210428238f, + 0.072721004486084f, 0.259678006172180f, 0.072920300066471f, + 0.260005623102188f, 0.073119848966599f, 0.260333120822906f, + 0.073319651186466f, 0.260660469532013f, 0.073519699275494f, + 0.260987639427185f, 0.073720000684261f, 0.261314690113068f, + 0.073920547962189f, 0.261641561985016f, 0.074121348559856f, + 0.261968284845352f, 0.074322402477264f, 0.262294828891754f, + 0.074523709714413f, 0.262621253728867f, 0.074725262820721f, + 0.262947499752045f, 0.074927061796188f, 0.263273626565933f, + 0.075129114091396f, 0.263599574565887f, 0.075331419706345f, + 0.263925373554230f, 0.075533971190453f, 0.264250993728638f, + 0.075736775994301f, 0.264576494693756f, 0.075939826667309f, + 0.264901816844940f, 0.076143130660057f, 0.265226989984512f, + 0.076346680521965f, 0.265552014112473f, 0.076550483703613f, + 0.265876859426498f, 0.076754532754421f, 0.266201555728912f, + 0.076958827674389f, 0.266526103019714f, 0.077163375914097f, + 0.266850501298904f, 0.077368170022964f, 0.267174720764160f, + 0.077573217451572f, 0.267498821020126f, 0.077778510749340f, + 0.267822742462158f, 0.077984049916267f, 0.268146485090256f, + 0.078189842402935f, 0.268470078706741f, 0.078395880758762f, + 0.268793523311615f, 0.078602164983749f, 0.269116818904877f, + 0.078808702528477f, 0.269439965486526f, 0.079015478491783f, + 0.269762933254242f, 0.079222507774830f, 0.270085722208023f, + 0.079429790377617f, 0.270408391952515f, 0.079637311398983f, + 0.270730882883072f, 0.079845085740089f, 0.271053224802017f, + 0.080053105950356f, 0.271375387907028f, 0.080261372029781f, + 0.271697402000427f, 0.080469883978367f, 0.272019267082214f, + 0.080678641796112f, 0.272340953350067f, 0.080887645483017f, + 0.272662490606308f, 0.081096902489662f, 0.272983878850937f, + 0.081306397914886f, 0.273305088281631f, 0.081516146659851f, + 0.273626148700714f, 0.081726133823395f, 0.273947030305862f, + 0.081936374306679f, 0.274267762899399f, 0.082146860659122f, + 0.274588316679001f, 0.082357585430145f, 0.274908751249313f, + 0.082568563520908f, 0.275228977203369f, 0.082779780030251f, + 0.275549083948135f, 0.082991249859333f, 0.275868982076645f, + 0.083202958106995f, 0.276188760995865f, 0.083414919674397f, + 0.276508361101151f, 0.083627119660378f, 0.276827782392502f, + 0.083839565515518f, 0.277147054672241f, 0.084052257239819f, + 0.277466177940369f, 0.084265194833279f, 0.277785122394562f, + 0.084478378295898f, 0.278103888034821f, 0.084691800177097f, + 0.278422504663467f, 0.084905467927456f, 0.278740972280502f, + 0.085119381546974f, 0.279059261083603f, 0.085333541035652f, + 0.279377400875092f, 0.085547938942909f, 0.279695361852646f, + 0.085762590169907f, 0.280013144016266f, 0.085977479815483f, + 0.280330777168274f, 0.086192607879639f, 0.280648261308670f, + 0.086407989263535f, 0.280965566635132f, 0.086623609066010f, + 0.281282693147659f, 0.086839467287064f, 0.281599670648575f, + 0.087055571377277f, 0.281916469335556f, 0.087271921336651f, + 0.282233119010925f, 0.087488517165184f, 0.282549589872360f, + 0.087705351412296f, 0.282865911722183f, 0.087922424077988f, + 0.283182054758072f, 0.088139742612839f, 0.283498018980026f, + 0.088357307016850f, 0.283813834190369f, 0.088575109839439f, + 0.284129470586777f, 0.088793158531189f, 0.284444957971573f, + 0.089011445641518f, 0.284760266542435f, 0.089229971170425f, + 0.285075396299362f, 0.089448742568493f, 0.285390377044678f, + 0.089667752385139f, 0.285705178976059f, 0.089887008070946f, + 0.286019802093506f, 0.090106502175331f, 0.286334276199341f, + 0.090326242148876f, 0.286648571491241f, 0.090546220541000f, + 0.286962717771530f, 0.090766437351704f, 0.287276685237885f, + 0.090986892580986f, 0.287590473890305f, 0.091207593679428f, + 0.287904083728790f, 0.091428533196449f, 0.288217544555664f, + 0.091649711132050f, 0.288530826568604f, 0.091871134936810f, + 0.288843959569931f, 0.092092797160149f, 0.289156883955002f, + 0.092314697802067f, 0.289469659328461f, 0.092536836862564f, + 0.289782285690308f, 0.092759214341640f, 0.290094703435898f, + 0.092981837689877f, 0.290406972169876f, 0.093204692006111f, + 0.290719062089920f, 0.093427792191505f, 0.291031002998352f, + 0.093651130795479f, 0.291342735290527f, 0.093874707818031f, + 0.291654318571091f, 0.094098523259163f, 0.291965723037720f, + 0.094322577118874f, 0.292276978492737f, 0.094546869397163f, + 0.292588025331497f, 0.094771400094032f, 0.292898923158646f, + 0.094996169209480f, 0.293209642171860f, 0.095221176743507f, + 0.293520182371140f, 0.095446422696114f, 0.293830573558807f, + 0.095671907067299f, 0.294140785932541f, 0.095897629857063f, + 0.294450789690018f, 0.096123591065407f, 0.294760644435883f, + 0.096349790692329f, 0.295070350170136f, 0.096576221287251f, + 0.295379847288132f, 0.096802897751331f, 0.295689195394516f, + 0.097029805183411f, 0.295998334884644f, 0.097256951034069f, + 0.296307325363159f, 0.097484335303307f, 0.296616137027740f, + 0.097711957991123f, 0.296924799680710f, 0.097939811646938f, + 0.297233253717422f, 0.098167903721333f, 0.297541528940201f, + 0.098396234214306f, 0.297849655151367f, 0.098624803125858f, + 0.298157602548599f, 0.098853603005409f, 0.298465341329575f, + 0.099082641303539f, 0.298772931098938f, 0.099311910569668f, + 0.299080342054367f, 0.099541425704956f, 0.299387603998184f, + 0.099771171808243f, 0.299694657325745f, 0.100001148879528f, + 0.300001531839371f, 0.100231364369392f, 0.300308227539063f, + 0.100461818277836f, 0.300614774227142f, 0.100692503154278f, + 0.300921112298965f, 0.100923426449299f, 0.301227301359177f, + 0.101154580712318f, 0.301533311605453f, 0.101385973393917f, + 0.301839113235474f, 0.101617597043514f, 0.302144765853882f, + 0.101849451661110f, 0.302450239658356f, 0.102081544697285f, + 0.302755534648895f, 0.102313876152039f, 0.303060621023178f, + 0.102546438574791f, 0.303365558385849f, 0.102779231965542f, + 0.303670316934586f, 0.103012263774872f, 0.303974896669388f, + 0.103245526552200f, 0.304279297590256f, 0.103479020297527f, + 0.304583519697189f, 0.103712752461433f, 0.304887533187866f, + 0.103946708142757f, 0.305191397666931f, 0.104180909693241f, + 0.305495083332062f, 0.104415334761143f, 0.305798590183258f, + 0.104649998247623f, 0.306101888418198f, 0.104884892702103f, + 0.306405037641525f, 0.105120018124580f, 0.306708008050919f, + 0.105355374515057f, 0.307010769844055f, 0.105590961873531f, + 0.307313382625580f, 0.105826787650585f, 0.307615786790848f, + 0.106062836945057f, 0.307918041944504f, 0.106299124658108f, + 0.308220088481903f, 0.106535643339157f, 0.308521956205368f, + 0.106772392988205f, 0.308823645114899f, 0.107009373605251f, + 0.309125155210495f, 0.107246585190296f, 0.309426486492157f, + 0.107484027743340f, 0.309727638959885f, 0.107721701264381f, + 0.310028612613678f, 0.107959605753422f, 0.310329377651215f, + 0.108197741210461f, 0.310629993677139f, 0.108436107635498f, + 0.310930401086807f, 0.108674705028534f, 0.311230629682541f, + 0.108913525938988f, 0.311530679464340f, 0.109152585268021f, + 0.311830550432205f, 0.109391868114471f, 0.312130242586136f, + 0.109631389379501f, 0.312429755926132f, 0.109871134161949f, + 0.312729060649872f, 0.110111102461815f, 0.313028186559677f, + 0.110351309180260f, 0.313327133655548f, 0.110591746866703f, + 0.313625901937485f, 0.110832408070564f, 0.313924491405487f, + 0.111073300242424f, 0.314222872257233f, 0.111314415931702f, + 0.314521104097366f, 0.111555770039558f, 0.314819127321243f, + 0.111797347664833f, 0.315116971731186f, 0.112039148807526f, + 0.315414607524872f, 0.112281180918217f, 0.315712094306946f, + 0.112523443996906f, 0.316009372472763f, 0.112765938043594f, + 0.316306471824646f, 0.113008655607700f, 0.316603392362595f, + 0.113251596689224f, 0.316900104284287f, 0.113494776189327f, + 0.317196637392044f, 0.113738171756268f, 0.317492991685867f, + 0.113981798291206f, 0.317789167165756f, 0.114225655794144f, + 0.318085134029388f, 0.114469736814499f, 0.318380922079086f, + 0.114714048802853f, 0.318676531314850f, 0.114958584308624f, + 0.318971961736679f, 0.115203343331814f, 0.319267183542252f, + 0.115448333323002f, 0.319562226533890f, 0.115693546831608f, + 0.319857090711594f, 0.115938983857632f, 0.320151746273041f, + 0.116184651851654f, 0.320446223020554f, 0.116430543363094f, + 0.320740520954132f, 0.116676658391953f, 0.321034610271454f, + 0.116923004388809f, 0.321328520774841f, 0.117169573903084f, + 0.321622252464294f, 0.117416366934776f, 0.321915775537491f, + 0.117663383483887f, 0.322209119796753f, 0.117910631000996f, + 0.322502255439758f, 0.118158094584942f, 0.322795242071152f, + 0.118405789136887f, 0.323088020086288f, 0.118653707206249f, + 0.323380589485168f, 0.118901848793030f, 0.323672980070114f, + 0.119150213897228f, 0.323965191841125f, 0.119398809969425f, + 0.324257194995880f, 0.119647622108459f, 0.324549019336700f, + 0.119896657764912f, 0.324840664863586f, 0.120145916938782f, + 0.325132101774216f, 0.120395407080650f, 0.325423330068588f, + 0.120645113289356f, 0.325714409351349f, 0.120895043015480f, + 0.326005280017853f, 0.121145196259022f, 0.326295942068100f, + 0.121395580470562f, 0.326586425304413f, 0.121646173298359f, + 0.326876699924469f, 0.121896997094154f, 0.327166795730591f, + 0.122148044407368f, 0.327456712722778f, 0.122399315237999f, + 0.327746421098709f, 0.122650802135468f, 0.328035950660706f, + 0.122902512550354f, 0.328325271606445f, 0.123154446482658f, + 0.328614413738251f, 0.123406603932381f, 0.328903347253799f, + 0.123658977448940f, 0.329192101955414f, 0.123911574482918f, + 0.329480648040771f, 0.124164395034313f, 0.329769015312195f, + 0.124417431652546f, 0.330057173967361f, 0.124670691788197f, + 0.330345153808594f, 0.124924175441265f, 0.330632925033569f, + 0.125177875161171f, 0.330920487642288f, 0.125431805849075f, + 0.331207901239395f, 0.125685945153236f, 0.331495076417923f, + 0.125940307974815f, 0.331782072782516f, 0.126194894313812f, + 0.332068890333176f, 0.126449704170227f, 0.332355499267578f, + 0.126704722642899f, 0.332641899585724f, 0.126959964632988f, + 0.332928121089935f, 0.127215430140495f, 0.333214133977890f, + 0.127471104264259f, 0.333499968051910f, 0.127727001905441f, + 0.333785593509674f, 0.127983123064041f, 0.334071010351181f, + 0.128239467740059f, 0.334356248378754f, 0.128496021032333f, + 0.334641307592392f, 0.128752797842026f, 0.334926128387451f, + 0.129009798169136f, 0.335210770368576f, 0.129267007112503f, + 0.335495233535767f, 0.129524439573288f, 0.335779488086700f, + 0.129782080650330f, 0.336063534021378f, 0.130039945244789f, + 0.336347371339798f, 0.130298033356667f, 0.336631029844284f, + 0.130556344985962f, 0.336914509534836f, 0.130814850330353f, + 0.337197750806808f, 0.131073594093323f, 0.337480813264847f, + 0.131332546472549f, 0.337763696908951f, 0.131591722369194f, + 0.338046342134476f, 0.131851106882095f, 0.338328808546066f, + 0.132110700011253f, 0.338611096143723f, 0.132370531558990f, + 0.338893145322800f, 0.132630556821823f, 0.339175015687943f, + 0.132890805602074f, 0.339456677436829f, 0.133151277899742f, + 0.339738160371780f, 0.133411958813667f, 0.340019434690475f, + 0.133672863245010f, 0.340300500392914f, 0.133933976292610f, + 0.340581357479095f, 0.134195312857628f, 0.340862035751343f, + 0.134456858038902f, 0.341142505407333f, 0.134718611836433f, + 0.341422766447067f, 0.134980589151382f, 0.341702848672867f, + 0.135242775082588f, 0.341982692480087f, 0.135505184531212f, + 0.342262357473373f, 0.135767802596092f, 0.342541843652725f, + 0.136030644178391f, 0.342821091413498f, 0.136293679475784f, + 0.343100160360336f, 0.136556953191757f, 0.343379020690918f, + 0.136820420622826f, 0.343657672405243f, 0.137084111571312f, + 0.343936115503311f, 0.137348011136055f, 0.344214379787445f, + 0.137612134218216f, 0.344492435455322f, 0.137876465916634f, + 0.344770282506943f, 0.138141006231308f, 0.345047920942307f, + 0.138405755162239f, 0.345325350761414f, 0.138670727610588f, + 0.345602601766586f, 0.138935908675194f, 0.345879614353180f, + 0.139201298356056f, 0.346156448125839f, 0.139466896653175f, + 0.346433073282242f, 0.139732718467712f, 0.346709519624710f, + 0.139998748898506f, 0.346985727548599f, 0.140264987945557f, + 0.347261756658554f, 0.140531435608864f, 0.347537547349930f, + 0.140798106789589f, 0.347813159227371f, 0.141064971685410f, + 0.348088562488556f, 0.141332060098648f, 0.348363757133484f, + 0.141599357128143f, 0.348638743162155f, 0.141866862773895f, + 0.348913550376892f, 0.142134591937065f, 0.349188119173050f, + 0.142402514815331f, 0.349462509155273f, 0.142670661211014f, + 0.349736660718918f, 0.142939001321793f, 0.350010633468628f, + 0.143207564949989f, 0.350284397602081f, 0.143476337194443f, + 0.350557953119278f, 0.143745318055153f, 0.350831300020218f, + 0.144014507532120f, 0.351104438304901f, 0.144283905625343f, + 0.351377367973328f, 0.144553512334824f, 0.351650089025497f, + 0.144823327660561f, 0.351922631263733f, 0.145093351602554f, + 0.352194935083389f, 0.145363584160805f, 0.352467030286789f, + 0.145634025335312f, 0.352738946676254f, 0.145904675126076f, + 0.353010624647141f, 0.146175548434258f, 0.353282123804092f, + 0.146446615457535f, 0.353553384542465f, 0.146717891097069f, + 0.353824466466904f, 0.146989375352860f, 0.354095309972763f, + 0.147261068224907f, 0.354365974664688f, 0.147532954812050f, + 0.354636400938034f, 0.147805064916611f, 0.354906648397446f, + 0.148077383637428f, 0.355176687240601f, 0.148349896073341f, + 0.355446487665176f, 0.148622632026672f, 0.355716109275818f, + 0.148895561695099f, 0.355985492467880f, 0.149168699979782f, + 0.356254696846008f, 0.149442046880722f, 0.356523662805557f, + 0.149715602397919f, 0.356792420148849f, 0.149989366531372f, + 0.357060998678207f, 0.150263324379921f, 0.357329338788986f, + 0.150537505745888f, 0.357597470283508f, 0.150811880826950f, + 0.357865422964096f, 0.151086464524269f, 0.358133137226105f, + 0.151361241936684f, 0.358400642871857f, 0.151636242866516f, + 0.358667939901352f, 0.151911437511444f, 0.358935028314590f, + 0.152186840772629f, 0.359201908111572f, 0.152462437748909f, + 0.359468549489975f, 0.152738258242607f, 0.359735012054443f, + 0.153014272451401f, 0.360001266002655f, 0.153290495276451f, + 0.360267281532288f, 0.153566911816597f, 0.360533088445663f, + 0.153843536973000f, 0.360798716545105f, 0.154120370745659f, + 0.361064106225967f, 0.154397398233414f, 0.361329287290573f, + 0.154674649238586f, 0.361594229936600f, 0.154952079057693f, + 0.361858993768692f, 0.155229732394218f, 0.362123548984528f, + 0.155507579445839f, 0.362387865781784f, 0.155785620212555f, + 0.362651973962784f, 0.156063869595528f, 0.362915903329849f, + 0.156342327594757f, 0.363179564476013f, 0.156620979309082f, + 0.363443046808243f, 0.156899839639664f, 0.363706320524216f, + 0.157178908586502f, 0.363969355821610f, 0.157458171248436f, + 0.364232182502747f, 0.157737627625465f, 0.364494800567627f, + 0.158017292618752f, 0.364757210016251f, 0.158297166228294f, + 0.365019410848618f, 0.158577233552933f, 0.365281373262405f, + 0.158857494592667f, 0.365543156862259f, 0.159137964248657f, + 0.365804702043533f, 0.159418627619743f, 0.366066008806229f, + 0.159699499607086f, 0.366327136754990f, 0.159980565309525f, + 0.366588026285172f, 0.160261839628220f, 0.366848707199097f, + 0.160543307662010f, 0.367109179496765f, 0.160824984312058f, + 0.367369443178177f, 0.161106839776039f, 0.367629468441010f, + 0.161388918757439f, 0.367889285087585f, 0.161671176552773f, + 0.368148893117905f, 0.161953642964363f, 0.368408292531967f, + 0.162236317992210f, 0.368667453527451f, 0.162519171833992f, + 0.368926405906677f, 0.162802234292030f, 0.369185149669647f, + 0.163085505366325f, 0.369443655014038f, 0.163368955254555f, + 0.369701951742172f, 0.163652613759041f, 0.369960039854050f, + 0.163936465978622f, 0.370217919349670f, 0.164220526814461f, + 0.370475560426712f, 0.164504766464233f, 0.370732992887497f, + 0.164789214730263f, 0.370990216732025f, 0.165073871612549f, + 0.371247202157974f, 0.165358707308769f, 0.371503978967667f, + 0.165643751621246f, 0.371760547161102f, 0.165928974747658f, + 0.372016876935959f, 0.166214406490326f, 0.372272998094559f, + 0.166500031948090f, 0.372528880834579f, 0.166785866022110f, + 0.372784584760666f, 0.167071878910065f, 0.373040050268173f, + 0.167358100414276f, 0.373295277357101f, 0.167644515633583f, + 0.373550295829773f, 0.167931124567986f, 0.373805105686188f, + 0.168217927217484f, 0.374059677124023f, 0.168504923582077f, + 0.374314039945602f, 0.168792113661766f, 0.374568194150925f, + 0.169079497456551f, 0.374822109937668f, 0.169367074966431f, + 0.375075817108154f, 0.169654861092567f, 0.375329315662384f, + 0.169942826032639f, 0.375582575798035f, 0.170230999588966f, + 0.375835597515106f, 0.170519351959229f, 0.376088410615921f, + 0.170807912945747f, 0.376341015100479f, 0.171096652746201f, + 0.376593410968781f, 0.171385586261749f, 0.376845568418503f, + 0.171674728393555f, 0.377097487449646f, 0.171964049339294f, + 0.377349197864532f, 0.172253578901291f, 0.377600699663162f, + 0.172543287277222f, 0.377851963043213f, 0.172833189368248f, + 0.378102988004684f, 0.173123285174370f, 0.378353834152222f, + 0.173413574695587f, 0.378604412078857f, 0.173704057931900f, + 0.378854811191559f, 0.173994734883308f, 0.379104942083359f, + 0.174285605549812f, 0.379354894161224f, 0.174576655030251f, + 0.379604607820511f, 0.174867913126946f, 0.379854083061218f, + 0.175159350037575f, 0.380103349685669f, 0.175450980663300f, + 0.380352377891541f, 0.175742805004120f, 0.380601197481155f, + 0.176034808158875f, 0.380849778652191f, 0.176327019929886f, + 0.381098151206970f, 0.176619410514832f, 0.381346285343170f, + 0.176911994814873f, 0.381594210863113f, 0.177204772830009f, + 0.381841897964478f, 0.177497729659081f, 0.382089376449585f, + 0.177790880203247f, 0.382336616516113f, 0.178084224462509f, + 0.382583618164063f, 0.178377762436867f, 0.382830440998077f, + 0.178671479225159f, 0.383076995611191f, 0.178965389728546f, + 0.383323341608047f, 0.179259493947029f, 0.383569449186325f, + 0.179553776979446f, 0.383815348148346f, 0.179848253726959f, + 0.384061008691788f, 0.180142924189568f, 0.384306460618973f, + 0.180437773466110f, 0.384551674127579f, 0.180732816457748f, + 0.384796649217606f, 0.181028053164482f, 0.385041415691376f, + 0.181323468685150f, 0.385285943746567f, 0.181619063019753f, + 0.385530263185501f, 0.181914865970612f, 0.385774344205856f, + 0.182210832834244f, 0.386018186807632f, 0.182507008314133f, + 0.386261820793152f, 0.182803362607956f, 0.386505216360092f, + 0.183099895715714f, 0.386748403310776f, 0.183396622538567f, + 0.386991351842880f, 0.183693528175354f, 0.387234061956406f, + 0.183990627527237f, 0.387476563453674f, 0.184287920594215f, + 0.387718826532364f, 0.184585392475128f, 0.387960851192474f, + 0.184883043169975f, 0.388202667236328f, 0.185180887579918f, + 0.388444244861603f, 0.185478910803795f, 0.388685584068298f, + 0.185777112841606f, 0.388926714658737f, 0.186075508594513f, + 0.389167606830597f, 0.186374098062515f, 0.389408260583878f, + 0.186672851443291f, 0.389648675918579f, 0.186971798539162f, + 0.389888882637024f, 0.187270939350128f, 0.390128880739212f, + 0.187570258975029f, 0.390368610620499f, 0.187869757413864f, + 0.390608131885529f, 0.188169434666634f, 0.390847414731979f, + 0.188469305634499f, 0.391086459159851f, 0.188769355416298f, + 0.391325294971466f, 0.189069598913193f, 0.391563892364502f, + 0.189370006322861f, 0.391802251338959f, 0.189670607447624f, + 0.392040401697159f, 0.189971387386322f, 0.392278283834457f, + 0.190272361040115f, 0.392515957355499f, 0.190573498606682f, + 0.392753422260284f, 0.190874829888344f, 0.392990618944168f, + 0.191176339983940f, 0.393227607011795f, 0.191478043794632f, + 0.393464356660843f, 0.191779911518097f, 0.393700867891312f, + 0.192081972956657f, 0.393937170505524f, 0.192384198307991f, + 0.394173204898834f, 0.192686617374420f, 0.394409030675888f, + 0.192989215254784f, 0.394644618034363f, 0.193292006850243f, + 0.394879996776581f, 0.193594962358475f, 0.395115107297897f, + 0.193898096680641f, 0.395350009202957f, 0.194201424717903f, + 0.395584672689438f, 0.194504916667938f, 0.395819097757339f, + 0.194808602333069f, 0.396053284406662f, 0.195112451910973f, + 0.396287262439728f, 0.195416495203972f, 0.396520972251892f, + 0.195720717310905f, 0.396754473447800f, 0.196025103330612f, + 0.396987736225128f, 0.196329683065414f, 0.397220760583878f, + 0.196634441614151f, 0.397453576326370f, 0.196939364075661f, + 0.397686123847961f, 0.197244480252266f, 0.397918462753296f, + 0.197549775242805f, 0.398150533437729f, 0.197855234146118f, + 0.398382395505905f, 0.198160871863365f, 0.398614019155502f, + 0.198466703295708f, 0.398845434188843f, 0.198772698640823f, + 0.399076581001282f, 0.199078872799873f, 0.399307489395142f, + 0.199385225772858f, 0.399538189172745f, 0.199691757559776f, + 0.399768620729446f, 0.199998468160629f, 0.399998843669891f, + 0.200305357575417f, 0.400228828191757f, 0.200612410902977f, + 0.400458574295044f, 0.200919643044472f, 0.400688081979752f, + 0.201227053999901f, 0.400917351245880f, 0.201534643769264f, + 0.401146411895752f, 0.201842412352562f, 0.401375204324722f, + 0.202150344848633f, 0.401603758335114f, 0.202458456158638f, + 0.401832103729248f, 0.202766746282578f, 0.402060180902481f, + 0.203075215220451f, 0.402288049459457f, 0.203383848071098f, + 0.402515679597855f, 0.203692659735680f, 0.402743041515350f, + 0.204001650214195f, 0.402970194816589f, 0.204310819506645f, + 0.403197109699249f, 0.204620152711868f, 0.403423786163330f, + 0.204929664731026f, 0.403650224208832f, 0.205239340662956f, + 0.403876423835754f, 0.205549195408821f, 0.404102355241776f, + 0.205859228968620f, 0.404328078031540f, 0.206169426441193f, + 0.404553562402725f, 0.206479802727699f, 0.404778808355331f, + 0.206790357828140f, 0.405003815889359f, 0.207101076841354f, + 0.405228585004807f, 0.207411959767342f, 0.405453115701675f, + 0.207723021507263f, 0.405677437782288f, 0.208034262061119f, + 0.405901491641998f, 0.208345666527748f, 0.406125307083130f, + 0.208657249808311f, 0.406348884105682f, 0.208969011902809f, + 0.406572192907333f, 0.209280923008919f, 0.406795293092728f, + 0.209593027830124f, 0.407018154859543f, 0.209905281662941f, + 0.407240778207779f, 0.210217714309692f, 0.407463163137436f, + 0.210530325770378f, 0.407685309648514f, 0.210843101143837f, + 0.407907217741013f, 0.211156040430069f, 0.408128857612610f, + 0.211469158530235f, 0.408350288867950f, 0.211782455444336f, + 0.408571451902390f, 0.212095901370049f, 0.408792406320572f, + 0.212409526109695f, 0.409013092517853f, 0.212723329663277f, + 0.409233570098877f, 0.213037282228470f, 0.409453779459000f, + 0.213351413607597f, 0.409673750400543f, 0.213665723800659f, + 0.409893482923508f, 0.213980183005333f, 0.410112977027893f, + 0.214294821023941f, 0.410332232713699f, 0.214609622955322f, + 0.410551249980927f, 0.214924603700638f, 0.410770028829575f, + 0.215239733457565f, 0.410988569259644f, 0.215555042028427f, + 0.411206841468811f, 0.215870529413223f, 0.411424905061722f, + 0.216186165809631f, 0.411642700433731f, 0.216501981019974f, + 0.411860257387161f, 0.216817945241928f, 0.412077575922012f, + 0.217134088277817f, 0.412294656038284f, 0.217450410127640f, + 0.412511497735977f, 0.217766880989075f, 0.412728071212769f, + 0.218083515763283f, 0.412944436073303f, 0.218400329351425f, + 0.413160532712936f, 0.218717306852341f, 0.413376390933990f, + 0.219034433364868f, 0.413592010736465f, 0.219351738691330f, + 0.413807392120361f, 0.219669207930565f, 0.414022535085678f, + 0.219986841082573f, 0.414237409830093f, 0.220304638147354f, + 0.414452046155930f, 0.220622614026070f, 0.414666473865509f, + 0.220940738916397f, 0.414880603551865f, 0.221259027719498f, + 0.415094524621964f, 0.221577480435371f, 0.415308207273483f, + 0.221896097064018f, 0.415521621704102f, 0.222214877605438f, + 0.415734797716141f, 0.222533836960793f, 0.415947735309601f, + 0.222852945327759f, 0.416160434484482f, 0.223172217607498f, + 0.416372895240784f, 0.223491653800011f, 0.416585087776184f, + 0.223811239004135f, 0.416797041893005f, 0.224131003022194f, + 0.417008757591248f, 0.224450930953026f, 0.417220205068588f, + 0.224771007895470f, 0.417431443929672f, 0.225091263651848f, + 0.417642414569855f, 0.225411668419838f, 0.417853146791458f, + 0.225732237100601f, 0.418063640594482f, 0.226052969694138f, + 0.418273866176605f, 0.226373866200447f, 0.418483853340149f, + 0.226694911718369f, 0.418693602085114f, 0.227016136050224f, + 0.418903112411499f, 0.227337509393692f, 0.419112354516983f, + 0.227659046649933f, 0.419321358203888f, 0.227980732917786f, + 0.419530123472214f, 0.228302597999573f, 0.419738620519638f, + 0.228624612092972f, 0.419946908950806f, 0.228946775197983f, + 0.420154929161072f, 0.229269117116928f, 0.420362681150436f, + 0.229591608047485f, 0.420570224523544f, 0.229914262890816f, + 0.420777499675751f, 0.230237081646919f, 0.420984506607056f, + 0.230560049414635f, 0.421191304922104f, 0.230883181095123f, + 0.421397835016251f, 0.231206461787224f, 0.421604126691818f, + 0.231529906392097f, 0.421810150146484f, 0.231853514909744f, + 0.422015935182571f, 0.232177272439003f, 0.422221481800079f, + 0.232501193881035f, 0.422426789999008f, 0.232825264334679f, + 0.422631829977036f, 0.233149498701096f, 0.422836631536484f, + 0.233473882079124f, 0.423041164875031f, 0.233798429369926f, + 0.423245459794998f, 0.234123140573502f, 0.423449516296387f, + 0.234448000788689f, 0.423653304576874f, 0.234773010015488f, + 0.423856884241104f, 0.235098183155060f, 0.424060165882111f, + 0.235423520207405f, 0.424263238906860f, 0.235749006271362f, + 0.424466013908386f, 0.236074641346931f, 0.424668580293655f, + 0.236400425434113f, 0.424870878458023f, 0.236726388335228f, + 0.425072938203812f, 0.237052485346794f, 0.425274729728699f, + 0.237378746271133f, 0.425476282835007f, 0.237705156207085f, + 0.425677597522736f, 0.238031730055809f, 0.425878643989563f, + 0.238358452916145f, 0.426079452037811f, 0.238685324788094f, + 0.426279991865158f, 0.239012360572815f, 0.426480293273926f, + 0.239339530467987f, 0.426680356264114f, 0.239666879177094f, + 0.426880151033401f, 0.239994361996651f, 0.427079707384110f, + 0.240322008728981f, 0.427278995513916f, 0.240649804472923f, + 0.427478045225143f, 0.240977749228477f, 0.427676826715469f, + 0.241305842995644f, 0.427875369787216f, 0.241634100675583f, + 0.428073674440384f, 0.241962507367134f, 0.428271710872650f, + 0.242291063070297f, 0.428469479084015f, 0.242619767785072f, + 0.428667008876801f, 0.242948621511459f, 0.428864300251007f, + 0.243277639150620f, 0.429061323404312f, 0.243606805801392f, + 0.429258108139038f, 0.243936106562614f, 0.429454624652863f, + 0.244265571236610f, 0.429650902748108f, 0.244595184922218f, + 0.429846942424774f, 0.244924947619438f, 0.430042684078217f, + 0.245254859328270f, 0.430238217115402f, 0.245584934949875f, + 0.430433481931686f, 0.245915144681931f, 0.430628478527069f, + 0.246245503425598f, 0.430823236703873f, 0.246576011180878f, + 0.431017726659775f, 0.246906682848930f, 0.431211978197098f, + 0.247237488627434f, 0.431405961513519f, 0.247568443417549f, + 0.431599706411362f, 0.247899547219276f, 0.431793183088303f, + 0.248230814933777f, 0.431986421346664f, 0.248562216758728f, + 0.432179391384125f, 0.248893767595291f, 0.432372123003006f, + 0.249225467443466f, 0.432564586400986f, 0.249557301402092f, + 0.432756811380386f, 0.249889299273491f, 0.432948768138886f, + 0.250221431255341f, 0.433140486478806f, 0.250553727149963f, + 0.433331936597824f, 0.250886172056198f, 0.433523118495941f, + 0.251218736171722f, 0.433714061975479f, 0.251551479101181f, + 0.433904737234116f, 0.251884341239929f, 0.434095174074173f, + 0.252217382192612f, 0.434285342693329f, 0.252550542354584f, + 0.434475272893906f, 0.252883851528168f, 0.434664934873581f, + 0.253217309713364f, 0.434854328632355f, 0.253550916910172f, + 0.435043483972549f, 0.253884643316269f, 0.435232400894165f, + 0.254218548536301f, 0.435421019792557f, 0.254552572965622f, + 0.435609430074692f, 0.254886746406555f, 0.435797542333603f, + 0.255221068859100f, 0.435985416173935f, 0.255555540323257f, + 0.436173021793365f, 0.255890160799026f, 0.436360388994217f, + 0.256224930286407f, 0.436547487974167f, 0.256559818983078f, + 0.436734348535538f, 0.256894856691360f, 0.436920911073685f, + 0.257230043411255f, 0.437107264995575f, 0.257565379142761f, + 0.437293320894241f, 0.257900834083557f, 0.437479138374329f, + 0.258236467838287f, 0.437664687633514f, 0.258572220802307f, + 0.437849998474121f, 0.258908122777939f, 0.438035041093826f, + 0.259244143962860f, 0.438219845294952f, 0.259580343961716f, + 0.438404351472855f, 0.259916663169861f, 0.438588619232178f, + 0.260253131389618f, 0.438772648572922f, 0.260589718818665f, + 0.438956409692764f, 0.260926485061646f, 0.439139902591705f, + 0.261263370513916f, 0.439323127269745f, 0.261600375175476f, + 0.439506113529205f, 0.261937558650970f, 0.439688831567764f, + 0.262274861335754f, 0.439871311187744f, 0.262612313032150f, + 0.440053492784500f, 0.262949883937836f, 0.440235435962677f, + 0.263287603855133f, 0.440417140722275f, 0.263625472784042f, + 0.440598547458649f, 0.263963490724564f, 0.440779715776443f, + 0.264301627874374f, 0.440960645675659f, 0.264639914035797f, + 0.441141277551651f, 0.264978319406509f, 0.441321671009064f, + 0.265316903591156f, 0.441501796245575f, 0.265655577182770f, + 0.441681683063507f, 0.265994429588318f, 0.441861271858215f, + 0.266333401203156f, 0.442040622234344f, 0.266672492027283f, + 0.442219734191895f, 0.267011761665344f, 0.442398548126221f, + 0.267351150512695f, 0.442577123641968f, 0.267690658569336f, + 0.442755430936813f, 0.268030315637589f, 0.442933470010757f, + 0.268370121717453f, 0.443111270666122f, 0.268710047006607f, + 0.443288803100586f, 0.269050091505051f, 0.443466067314148f, + 0.269390314817429f, 0.443643063306808f, 0.269730657339096f, + 0.443819820880890f, 0.270071119070053f, 0.443996280431747f, + 0.270411729812622f, 0.444172531366348f, 0.270752459764481f, + 0.444348484277725f, 0.271093338727951f, 0.444524168968201f, + 0.271434366703033f, 0.444699615240097f, 0.271775513887405f, + 0.444874793291092f, 0.272116780281067f, 0.445049703121185f, + 0.272458195686340f, 0.445224374532700f, 0.272799760103226f, + 0.445398747920990f, 0.273141443729401f, 0.445572882890701f, + 0.273483246564865f, 0.445746749639511f, 0.273825198411942f, + 0.445920348167419f, 0.274167299270630f, 0.446093708276749f, + 0.274509519338608f, 0.446266770362854f, 0.274851858615875f, + 0.446439594030380f, 0.275194346904755f, 0.446612149477005f, + 0.275536954402924f, 0.446784436702728f, 0.275879681110382f, + 0.446956485509872f, 0.276222556829453f, 0.447128236293793f, + 0.276565581560135f, 0.447299748659134f, 0.276908725500107f, + 0.447470992803574f, 0.277251988649368f, 0.447641968727112f, + 0.277595400810242f, 0.447812676429749f, 0.277938932180405f, + 0.447983115911484f, 0.278282582759857f, 0.448153316974640f, + 0.278626382350922f, 0.448323249816895f, 0.278970301151276f, + 0.448492884635925f, 0.279314368963242f, 0.448662281036377f, + 0.279658555984497f, 0.448831409215927f, 0.280002862215042f, + 0.449000298976898f, 0.280347317457199f, 0.449168890714645f, + 0.280691891908646f, 0.449337244033813f, 0.281036585569382f, + 0.449505299329758f, 0.281381398439407f, 0.449673116207123f, + 0.281726360321045f, 0.449840664863586f, 0.282071471214294f, + 0.450007945299149f, 0.282416671514511f, 0.450174957513809f, + 0.282762020826340f, 0.450341701507568f, 0.283107489347458f, + 0.450508207082748f, 0.283453077077866f, 0.450674414634705f, + 0.283798813819885f, 0.450840383768082f, 0.284144669771194f, + 0.451006084680557f, 0.284490644931793f, 0.451171487569809f, + 0.284836769104004f, 0.451336652040482f, 0.285182982683182f, + 0.451501548290253f, 0.285529345273972f, 0.451666176319122f, + 0.285875827074051f, 0.451830536127090f, 0.286222457885742f, + 0.451994657516479f, 0.286569178104401f, 0.452158480882645f, + 0.286916047334671f, 0.452322036027908f, 0.287263035774231f, + 0.452485352754593f, 0.287610173225403f, 0.452648371458054f, + 0.287957400083542f, 0.452811151742935f, 0.288304775953293f, + 0.452973634004593f, 0.288652241230011f, 0.453135877847672f, + 0.288999855518341f, 0.453297853469849f, 0.289347589015961f, + 0.453459560871124f, 0.289695471525192f, 0.453621000051498f, + 0.290043443441391f, 0.453782171010971f, 0.290391564369202f, + 0.453943043947220f, 0.290739774703979f, 0.454103678464890f, + 0.291088134050369f, 0.454264044761658f, 0.291436612606049f, + 0.454424172639847f, 0.291785210371017f, 0.454584002494812f, + 0.292133957147598f, 0.454743564128876f, 0.292482793331146f, + 0.454902857542038f, 0.292831748723984f, 0.455061882734299f, + 0.293180853128433f, 0.455220639705658f, 0.293530046939850f, + 0.455379128456116f, 0.293879389762878f, 0.455537378787994f, + 0.294228851795197f, 0.455695331096649f, 0.294578403234482f, + 0.455853015184402f, 0.294928103685379f, 0.456010431051254f, + 0.295277923345566f, 0.456167578697205f, 0.295627862215042f, + 0.456324487924576f, 0.295977920293808f, 0.456481099128723f, + 0.296328097581863f, 0.456637442111969f, 0.296678394079208f, + 0.456793516874313f, 0.297028809785843f, 0.456949323415756f, + 0.297379344701767f, 0.457104891538620f, 0.297729998826981f, + 0.457260161638260f, 0.298080772161484f, 0.457415163516998f, + 0.298431664705276f, 0.457569897174835f, 0.298782676458359f, + 0.457724362611771f, 0.299133807420731f, 0.457878559827805f, + 0.299485057592392f, 0.458032488822937f, 0.299836426973343f, + 0.458186149597168f, 0.300187885761261f, 0.458339542150497f, + 0.300539493560791f, 0.458492636680603f, 0.300891220569611f, + 0.458645492792130f, 0.301243066787720f, 0.458798080682755f, + 0.301595002412796f, 0.458950400352478f, 0.301947087049484f, + 0.459102421998978f, 0.302299261093140f, 0.459254205226898f, + 0.302651554346085f, 0.459405690431595f, 0.303003966808319f, + 0.459556937217712f, 0.303356528282166f, 0.459707885980606f, + 0.303709149360657f, 0.459858566522598f, 0.304061919450760f, + 0.460008978843689f, 0.304414808750153f, 0.460159152746201f, + 0.304767817258835f, 0.460309028625488f, 0.305120915174484f, + 0.460458606481552f, 0.305474132299423f, 0.460607945919037f, + 0.305827468633652f, 0.460757017135620f, 0.306180924177170f, + 0.460905820131302f, 0.306534498929977f, 0.461054325103760f, + 0.306888192892075f, 0.461202591657639f, 0.307241976261139f, + 0.461350560188293f, 0.307595878839493f, 0.461498260498047f, + 0.307949900627136f, 0.461645722389221f, 0.308304041624069f, + 0.461792886257172f, 0.308658272027969f, 0.461939752101898f, + 0.309012651443481f, 0.462086379528046f, 0.309367120265961f, + 0.462232738733292f, 0.309721708297729f, 0.462378799915314f, + 0.310076385736465f, 0.462524622678757f, 0.310431212186813f, + 0.462670147418976f, 0.310786128044128f, 0.462815403938293f, + 0.311141163110733f, 0.462960392236710f, 0.311496287584305f, + 0.463105112314224f, 0.311851561069489f, 0.463249564170837f, + 0.312206923961639f, 0.463393747806549f, 0.312562376260757f, + 0.463537633419037f, 0.312917977571487f, 0.463681250810623f, + 0.313273668289185f, 0.463824629783630f, 0.313629478216171f, + 0.463967710733414f, 0.313985377550125f, 0.464110493659973f, + 0.314341396093369f, 0.464253038167953f, 0.314697533845901f, + 0.464395314455032f, 0.315053790807724f, 0.464537292718887f, + 0.315410137176514f, 0.464679002761841f, 0.315766572952271f, + 0.464820444583893f, 0.316123157739639f, 0.464961618185043f, + 0.316479831933975f, 0.465102523565292f, 0.316836595535278f, + 0.465243130922318f, 0.317193508148193f, 0.465383470058441f, + 0.317550510168076f, 0.465523540973663f, 0.317907601594925f, + 0.465663343667984f, 0.318264812231064f, 0.465802878141403f, + 0.318622142076492f, 0.465942144393921f, 0.318979561328888f, + 0.466081112623215f, 0.319337099790573f, 0.466219812631607f, + 0.319694727659225f, 0.466358244419098f, 0.320052474737167f, + 0.466496407985687f, 0.320410341024399f, 0.466634273529053f, + 0.320768296718597f, 0.466771900653839f, 0.321126341819763f, + 0.466909229755402f, 0.321484506130219f, 0.467046260833740f, + 0.321842789649963f, 0.467183053493500f, 0.322201162576675f, + 0.467319577932358f, 0.322559654712677f, 0.467455804347992f, + 0.322918236255646f, 0.467591762542725f, 0.323276937007904f, + 0.467727422714233f, 0.323635727167130f, 0.467862844467163f, + 0.323994606733322f, 0.467997968196869f, 0.324353635311127f, + 0.468132823705673f, 0.324712723493576f, 0.468267410993576f, + 0.325071930885315f, 0.468401730060577f, 0.325431257486343f, + 0.468535751104355f, 0.325790673494339f, 0.468669503927231f, + 0.326150178909302f, 0.468802988529205f, 0.326509803533554f, + 0.468936175107956f, 0.326869517564774f, 0.469069123268127f, + 0.327229350805283f, 0.469201773405075f, 0.327589273452759f, + 0.469334155321121f, 0.327949285507202f, 0.469466239213943f, + 0.328309416770935f, 0.469598054885864f, 0.328669637441635f, + 0.469729602336884f, 0.329029977321625f, 0.469860881567001f, + 0.329390406608582f, 0.469991862773895f, 0.329750925302505f, + 0.470122605562210f, 0.330111563205719f, 0.470253020524979f, + 0.330472290515900f, 0.470383197069168f, 0.330833107233047f, + 0.470513075590134f, 0.331194043159485f, 0.470642685890198f, + 0.331555068492889f, 0.470772027969360f, 0.331916213035584f, + 0.470901101827621f, 0.332277417182922f, 0.471029877662659f, + 0.332638740539551f, 0.471158385276794f, 0.333000183105469f, + 0.471286594867706f, 0.333361685276031f, 0.471414536237717f, + 0.333723306655884f, 0.471542209386826f, 0.334085017442703f, + 0.471669614315033f, 0.334446847438812f, 0.471796721220016f, + 0.334808766841888f, 0.471923559904099f, 0.335170775651932f, + 0.472050130367279f, 0.335532873868942f, 0.472176402807236f, + 0.335895091295242f, 0.472302407026291f, 0.336257368326187f, + 0.472428143024445f, 0.336619764566422f, 0.472553610801697f, + 0.336982280015945f, 0.472678780555725f, 0.337344855070114f, + 0.472803652286530f, 0.337707549333572f, 0.472928285598755f, + 0.338070303201675f, 0.473052620887756f, 0.338433176279068f, + 0.473176687955856f, 0.338796168565750f, 0.473300457000732f, + 0.339159220457077f, 0.473423957824707f, 0.339522391557693f, + 0.473547190427780f, 0.339885622262955f, 0.473670125007629f, + 0.340248972177505f, 0.473792791366577f, 0.340612411499023f, + 0.473915189504623f, 0.340975970029831f, 0.474037289619446f, + 0.341339588165283f, 0.474159121513367f, 0.341703325510025f, + 0.474280685186386f, 0.342067122459412f, 0.474401950836182f, + 0.342431038618088f, 0.474522948265076f, 0.342795044183731f, + 0.474643647670746f, 0.343159139156342f, 0.474764078855515f, + 0.343523323535919f, 0.474884241819382f, 0.343887597322464f, + 0.475004136562347f, 0.344251960515976f, 0.475123733282089f, + 0.344616413116455f, 0.475243031978607f, 0.344980984926224f, + 0.475362062454224f, 0.345345616340637f, 0.475480824708939f, + 0.345710366964340f, 0.475599318742752f, 0.346075177192688f, + 0.475717514753342f, 0.346440106630325f, 0.475835442543030f, + 0.346805095672607f, 0.475953072309494f, 0.347170203924179f, + 0.476070433855057f, 0.347535371780396f, 0.476187497377396f, + 0.347900658845901f, 0.476304292678833f, 0.348266035318375f, + 0.476420819759369f, 0.348631471395493f, 0.476537048816681f, + 0.348997026681900f, 0.476653009653091f, 0.349362671375275f, + 0.476768702268600f, 0.349728375673294f, 0.476884096860886f, + 0.350094199180603f, 0.476999223232269f, 0.350460082292557f, + 0.477114051580429f, 0.350826084613800f, 0.477228611707687f, + 0.351192146539688f, 0.477342873811722f, 0.351558297872543f, + 0.477456867694855f, 0.351924568414688f, 0.477570593357086f, + 0.352290898561478f, 0.477684020996094f, 0.352657318115234f, + 0.477797180414200f, 0.353023827075958f, 0.477910041809082f, + 0.353390425443649f, 0.478022634983063f, 0.353757113218308f, + 0.478134930133820f, 0.354123860597610f, 0.478246957063675f, + 0.354490727186203f, 0.478358715772629f, 0.354857653379440f, + 0.478470176458359f, 0.355224698781967f, 0.478581339120865f, + 0.355591803789139f, 0.478692263364792f, 0.355958998203278f, + 0.478802859783173f, 0.356326282024384f, 0.478913217782974f, + 0.356693625450134f, 0.479023247957230f, 0.357061088085175f, + 0.479133039712906f, 0.357428610324860f, 0.479242533445358f, + 0.357796221971512f, 0.479351729154587f, 0.358163923025131f, + 0.479460656642914f, 0.358531713485718f, 0.479569315910339f, + 0.358899593353271f, 0.479677677154541f, 0.359267532825470f, + 0.479785770177841f, 0.359635561704636f, 0.479893565177917f, + 0.360003679990768f, 0.480001062154770f, 0.360371887683868f, + 0.480108320713043f, 0.360740154981613f, 0.480215251445770f, + 0.361108511686325f, 0.480321943759918f, 0.361476957798004f, + 0.480428308248520f, 0.361845493316650f, 0.480534434318542f, + 0.362214088439941f, 0.480640232563019f, 0.362582772970200f, + 0.480745792388916f, 0.362951546907425f, 0.480851024389267f, + 0.363320380449295f, 0.480956017971039f, 0.363689333200455f, + 0.481060713529587f, 0.364058345556259f, 0.481165111064911f, + 0.364427417516708f, 0.481269240379334f, 0.364796578884125f, + 0.481373071670532f, 0.365165829658508f, 0.481476634740829f, + 0.365535169839859f, 0.481579899787903f, 0.365904569625854f, + 0.481682896614075f, 0.366274058818817f, 0.481785595417023f, + 0.366643607616425f, 0.481888025999069f, 0.367013275623322f, + 0.481990188360214f, 0.367382973432541f, 0.482092022895813f, + 0.367752790451050f, 0.482193619012833f, 0.368122667074203f, + 0.482294887304306f, 0.368492603302002f, 0.482395917177200f, + 0.368862658739090f, 0.482496619224548f, 0.369232743978500f, + 0.482597053050995f, 0.369602948427200f, 0.482697218656540f, + 0.369973212480545f, 0.482797086238861f, 0.370343536138535f, + 0.482896685600281f, 0.370713949203491f, 0.482995986938477f, + 0.371084451675415f, 0.483094990253448f, 0.371455013751984f, + 0.483193725347519f, 0.371825665235519f, 0.483292192220688f, + 0.372196376323700f, 0.483390361070633f, 0.372567176818848f, + 0.483488231897354f, 0.372938036918640f, 0.483585834503174f, + 0.373308986425400f, 0.483683139085770f, 0.373679995536804f, + 0.483780175447464f, 0.374051094055176f, 0.483876913785934f, + 0.374422252178192f, 0.483973383903503f, 0.374793499708176f, + 0.484069555997849f, 0.375164806842804f, 0.484165430068970f, + 0.375536203384399f, 0.484261035919189f, 0.375907659530640f, + 0.484356373548508f, 0.376279205083847f, 0.484451413154602f, + 0.376650810241699f, 0.484546154737473f, 0.377022475004196f, + 0.484640628099442f, 0.377394229173660f, 0.484734803438187f, + 0.377766042947769f, 0.484828680753708f, 0.378137946128845f, + 0.484922289848328f, 0.378509908914566f, 0.485015630722046f, + 0.378881961107254f, 0.485108673572540f, 0.379254043102264f, + 0.485201418399811f, 0.379626244306564f, 0.485293895006180f, + 0.379998475313187f, 0.485386073589325f, 0.380370795726776f, + 0.485477954149246f, 0.380743205547333f, 0.485569566488266f, + 0.381115674972534f, 0.485660910606384f, 0.381488204002380f, + 0.485751956701279f, 0.381860792636871f, 0.485842704772949f, + 0.382233470678329f, 0.485933154821396f, 0.382606208324432f, + 0.486023366451263f, 0.382979035377502f, 0.486113250255585f, + 0.383351892232895f, 0.486202865839005f, 0.383724838495255f, + 0.486292183399200f, 0.384097874164581f, 0.486381232738495f, + 0.384470939636230f, 0.486469984054565f, 0.384844094514847f, + 0.486558437347412f, 0.385217308998108f, 0.486646622419357f, + 0.385590612888336f, 0.486734509468079f, 0.385963946580887f, + 0.486822128295898f, 0.386337369680405f, 0.486909449100494f, + 0.386710882186890f, 0.486996471881866f, 0.387084424495697f, + 0.487083226442337f, 0.387458056211472f, 0.487169682979584f, + 0.387831717729568f, 0.487255871295929f, 0.388205498456955f, + 0.487341761589050f, 0.388579308986664f, 0.487427353858948f, + 0.388953179121017f, 0.487512677907944f, 0.389327138662338f, + 0.487597703933716f, 0.389701157808304f, 0.487682431936264f, + 0.390075236558914f, 0.487766891717911f, 0.390449374914169f, + 0.487851053476334f, 0.390823602676392f, 0.487934947013855f, + 0.391197860240936f, 0.488018542528152f, 0.391572207212448f, + 0.488101840019226f, 0.391946613788605f, 0.488184869289398f, + 0.392321079969406f, 0.488267600536346f, 0.392695605754852f, + 0.488350033760071f, 0.393070191144943f, 0.488432198762894f, + 0.393444836139679f, 0.488514065742493f, 0.393819570541382f, + 0.488595664501190f, 0.394194334745407f, 0.488676935434341f, + 0.394569188356400f, 0.488757967948914f, 0.394944071769714f, + 0.488838672637939f, 0.395319044589996f, 0.488919109106064f, + 0.395694077014923f, 0.488999247550964f, 0.396069169044495f, + 0.489079117774963f, 0.396444320678711f, 0.489158689975739f, + 0.396819531917572f, 0.489237964153290f, 0.397194802761078f, + 0.489316970109940f, 0.397570133209229f, 0.489395678043365f, + 0.397945523262024f, 0.489474087953568f, 0.398320972919464f, + 0.489552229642868f, 0.398696482181549f, 0.489630073308945f, + 0.399072051048279f, 0.489707618951797f, 0.399447679519653f, + 0.489784896373749f, 0.399823367595673f, 0.489861875772476f, + 0.400199115276337f, 0.489938557147980f, 0.400574922561646f, + 0.490014940500259f, 0.400950789451599f, 0.490091055631638f, + 0.401326715946198f, 0.490166902542114f, 0.401702702045441f, + 0.490242421627045f, 0.402078747749329f, 0.490317672491074f, + 0.402454853057861f, 0.490392625331879f, 0.402830988168716f, + 0.490467309951782f, 0.403207212686539f, 0.490541696548462f, + 0.403583467006683f, 0.490615785121918f, 0.403959810733795f, + 0.490689605474472f, 0.404336184263229f, 0.490763127803802f, + 0.404712617397308f, 0.490836352109909f, 0.405089110136032f, + 0.490909278392792f, 0.405465662479401f, 0.490981936454773f, + 0.405842274427414f, 0.491054296493530f, 0.406218945980072f, + 0.491126358509064f, 0.406595647335052f, 0.491198152303696f, + 0.406972438097000f, 0.491269648075104f, 0.407349258661270f, + 0.491340845823288f, 0.407726138830185f, 0.491411775350571f, + 0.408103078603745f, 0.491482406854630f, 0.408480048179626f, + 0.491552740335464f, 0.408857107162476f, 0.491622805595398f, + 0.409234195947647f, 0.491692543029785f, 0.409611344337463f, + 0.491762012243271f, 0.409988552331924f, 0.491831213235855f, + 0.410365819931030f, 0.491900116205215f, 0.410743117332459f, + 0.491968721151352f, 0.411120474338531f, 0.492037028074265f, + 0.411497890949249f, 0.492105036973953f, 0.411875367164612f, + 0.492172777652740f, 0.412252873182297f, 0.492240220308304f, + 0.412630438804626f, 0.492307394742966f, 0.413008064031601f, + 0.492374241352081f, 0.413385748863220f, 0.492440819740295f, + 0.413763463497162f, 0.492507129907608f, 0.414141237735748f, + 0.492573112249374f, 0.414519041776657f, 0.492638826370239f, + 0.414896935224533f, 0.492704242467880f, 0.415274858474731f, + 0.492769360542297f, 0.415652841329575f, 0.492834210395813f, + 0.416030853986740f, 0.492898762226105f, 0.416408926248550f, + 0.492963016033173f, 0.416787058115005f, 0.493026971817017f, + 0.417165219783783f, 0.493090659379959f, 0.417543441057205f, + 0.493154048919678f, 0.417921721935272f, 0.493217140436172f, + 0.418300032615662f, 0.493279963731766f, 0.418678402900696f, + 0.493342459201813f, 0.419056802988052f, 0.493404686450958f, + 0.419435262680054f, 0.493466645479202f, 0.419813781976700f, + 0.493528276681900f, 0.420192331075668f, 0.493589639663696f, + 0.420570939779282f, 0.493650704622269f, 0.420949578285217f, + 0.493711471557617f, 0.421328276395798f, 0.493771970272064f, + 0.421707004308701f, 0.493832170963287f, 0.422085791826248f, + 0.493892073631287f, 0.422464638948441f, 0.493951678276062f, + 0.422843515872955f, 0.494011014699936f, 0.423222452402115f, + 0.494070053100586f, 0.423601418733597f, 0.494128793478012f, + 0.423980414867401f, 0.494187235832214f, 0.424359470605850f, + 0.494245409965515f, 0.424738585948944f, 0.494303256273270f, + 0.425117731094360f, 0.494360834360123f, 0.425496935844421f, + 0.494418144226074f, 0.425876170396805f, 0.494475126266479f, + 0.426255434751511f, 0.494531840085983f, 0.426634758710861f, + 0.494588255882263f, 0.427014142274857f, 0.494644373655319f, + 0.427393525838852f, 0.494700223207474f, 0.427772998809814f, + 0.494755744934082f, 0.428152471780777f, 0.494810998439789f, + 0.428532034158707f, 0.494865983724594f, 0.428911596536636f, + 0.494920641183853f, 0.429291218519211f, 0.494975030422211f, + 0.429670870304108f, 0.495029091835022f, 0.430050581693649f, + 0.495082914829254f, 0.430430322885513f, 0.495136409997940f, + 0.430810123682022f, 0.495189607143402f, 0.431189924478531f, + 0.495242536067963f, 0.431569814682007f, 0.495295166969299f, + 0.431949704885483f, 0.495347499847412f, 0.432329654693604f, + 0.495399564504623f, 0.432709634304047f, 0.495451331138611f, + 0.433089673519135f, 0.495502769947052f, 0.433469742536545f, + 0.495553970336914f, 0.433849841356277f, 0.495604842901230f, + 0.434229999780655f, 0.495655417442322f, 0.434610158205032f, + 0.495705723762512f, 0.434990376234055f, 0.495755732059479f, + 0.435370653867722f, 0.495805442333221f, 0.435750931501389f, + 0.495854884386063f, 0.436131268739700f, 0.495903998613358f, + 0.436511665582657f, 0.495952844619751f, 0.436892062425613f, + 0.496001392602921f, 0.437272518873215f, 0.496049642562866f, + 0.437653005123138f, 0.496097624301910f, 0.438033521175385f, + 0.496145308017731f, 0.438414067029953f, 0.496192663908005f, + 0.438794672489166f, 0.496239781379700f, 0.439175277948380f, + 0.496286571025848f, 0.439555943012238f, 0.496333062648773f, + 0.439936667680740f, 0.496379286050797f, 0.440317392349243f, + 0.496425211429596f, 0.440698176622391f, 0.496470838785172f, + 0.441078960895538f, 0.496516168117523f, 0.441459804773331f, + 0.496561229228973f, 0.441840678453445f, 0.496605962514877f, + 0.442221581935883f, 0.496650427579880f, 0.442602545022964f, + 0.496694594621658f, 0.442983508110046f, 0.496738493442535f, + 0.443364530801773f, 0.496782064437866f, 0.443745553493500f, + 0.496825367212296f, 0.444126635789871f, 0.496868371963501f, + 0.444507747888565f, 0.496911078691483f, 0.444888889789581f, + 0.496953487396240f, 0.445270061492920f, 0.496995598077774f, + 0.445651292800903f, 0.497037440538406f, 0.446032524108887f, + 0.497078984975815f, 0.446413785219193f, 0.497120231389999f, + 0.446795076131821f, 0.497161179780960f, 0.447176426649094f, + 0.497201830148697f, 0.447557777166367f, 0.497242212295532f, + 0.447939187288284f, 0.497282296419144f, 0.448320597410202f, + 0.497322082519531f, 0.448702067136765f, 0.497361570596695f, + 0.449083566665649f, 0.497400760650635f, 0.449465066194534f, + 0.497439652681351f, 0.449846625328064f, 0.497478276491165f, + 0.450228184461594f, 0.497516602277756f, 0.450609803199768f, + 0.497554630041122f, 0.450991421937943f, 0.497592359781265f, + 0.451373100280762f, 0.497629791498184f, 0.451754778623581f, + 0.497666954994202f, 0.452136516571045f, 0.497703820466995f, + 0.452518254518509f, 0.497740387916565f, 0.452900022268295f, + 0.497776657342911f, 0.453281819820404f, 0.497812628746033f, + 0.453663676977158f, 0.497848302125931f, 0.454045534133911f, + 0.497883707284927f, 0.454427421092987f, 0.497918814420700f, + 0.454809308052063f, 0.497953623533249f, 0.455191254615784f, + 0.497988134622574f, 0.455573230981827f, 0.498022347688675f, + 0.455955207347870f, 0.498056292533875f, 0.456337243318558f, + 0.498089909553528f, 0.456719279289246f, 0.498123258352280f, + 0.457101345062256f, 0.498156309127808f, 0.457483440637589f, + 0.498189061880112f, 0.457865566015244f, 0.498221516609192f, + 0.458247691392899f, 0.498253703117371f, 0.458629876375198f, + 0.498285561800003f, 0.459012061357498f, 0.498317152261734f, + 0.459394276142120f, 0.498348444700241f, 0.459776520729065f, + 0.498379439115524f, 0.460158795118332f, 0.498410135507584f, + 0.460541069507599f, 0.498440563678741f, 0.460923373699188f, + 0.498470664024353f, 0.461305707693100f, 0.498500496149063f, + 0.461688071489334f, 0.498530030250549f, 0.462070435285568f, + 0.498559266328812f, 0.462452858686447f, 0.498588204383850f, + 0.462835282087326f, 0.498616874217987f, 0.463217705488205f, + 0.498645216226578f, 0.463600188493729f, 0.498673290014267f, + 0.463982671499252f, 0.498701065778732f, 0.464365184307098f, + 0.498728543519974f, 0.464747726917267f, 0.498755723237991f, + 0.465130269527435f, 0.498782604932785f, 0.465512841939926f, + 0.498809218406677f, 0.465895414352417f, 0.498835533857346f, + 0.466278046369553f, 0.498861521482468f, 0.466660678386688f, + 0.498887240886688f, 0.467043310403824f, 0.498912662267685f, + 0.467426002025604f, 0.498937815427780f, 0.467808693647385f, + 0.498962640762329f, 0.468191385269165f, 0.498987197875977f, + 0.468574106693268f, 0.499011427164078f, 0.468956857919693f, + 0.499035388231277f, 0.469339638948441f, 0.499059051275253f, + 0.469722419977188f, 0.499082416296005f, 0.470105201005936f, + 0.499105513095856f, 0.470488041639328f, 0.499128282070160f, + 0.470870882272720f, 0.499150782823563f, 0.471253722906113f, + 0.499172955751419f, 0.471636593341827f, 0.499194860458374f, + 0.472019463777542f, 0.499216467142105f, 0.472402364015579f, + 0.499237775802612f, 0.472785294055939f, 0.499258816242218f, + 0.473168224096298f, 0.499279528856277f, 0.473551183938980f, + 0.499299973249435f, 0.473934143781662f, 0.499320119619370f, + 0.474317133426666f, 0.499339967966080f, 0.474700123071671f, + 0.499359518289566f, 0.475083142518997f, 0.499378770589828f, + 0.475466161966324f, 0.499397724866867f, 0.475849211215973f, + 0.499416410923004f, 0.476232260465622f, 0.499434769153595f, + 0.476615339517593f, 0.499452859163284f, 0.476998418569565f, + 0.499470651149750f, 0.477381497621536f, 0.499488145112991f, + 0.477764606475830f, 0.499505341053009f, 0.478147745132446f, + 0.499522238969803f, 0.478530883789063f, 0.499538868665695f, + 0.478914022445679f, 0.499555170536041f, 0.479297190904617f, + 0.499571204185486f, 0.479680359363556f, 0.499586939811707f, + 0.480063527822495f, 0.499602377414703f, 0.480446726083755f, + 0.499617516994476f, 0.480829954147339f, 0.499632388353348f, + 0.481213152408600f, 0.499646931886673f, 0.481596380472183f, + 0.499661177396774f, 0.481979638338089f, 0.499675154685974f, + 0.482362866401672f, 0.499688833951950f, 0.482746154069901f, + 0.499702215194702f, 0.483129411935806f, 0.499715298414230f, + 0.483512699604034f, 0.499728083610535f, 0.483895987272263f, + 0.499740600585938f, 0.484279274940491f, 0.499752789735794f, + 0.484662592411041f, 0.499764710664749f, 0.485045909881592f, + 0.499776333570480f, 0.485429257154465f, 0.499787658452988f, + 0.485812574625015f, 0.499798685312271f, 0.486195921897888f, + 0.499809414148331f, 0.486579269170761f, 0.499819844961166f, + 0.486962646245956f, 0.499830007553101f, 0.487346023321152f, + 0.499839842319489f, 0.487729400396347f, 0.499849408864975f, + 0.488112777471542f, 0.499858677387238f, 0.488496154546738f, + 0.499867647886276f, 0.488879561424255f, 0.499876320362091f, + 0.489262968301773f, 0.499884694814682f, 0.489646375179291f, + 0.499892801046371f, 0.490029782056808f, 0.499900579452515f, + 0.490413218736649f, 0.499908089637756f, 0.490796625614166f, + 0.499915301799774f, 0.491180062294006f, 0.499922215938568f, + 0.491563498973846f, 0.499928832054138f, 0.491946935653687f, + 0.499935150146484f, 0.492330402135849f, 0.499941170215607f, + 0.492713838815689f, 0.499946922063828f, 0.493097305297852f, + 0.499952346086502f, 0.493480771780014f, 0.499957501888275f, + 0.493864238262177f, 0.499962359666824f, 0.494247704744339f, + 0.499966919422150f, 0.494631171226501f, 0.499971181154251f, + 0.495014637708664f, 0.499975144863129f, 0.495398133993149f, + 0.499978810548782f, 0.495781600475311f, 0.499982208013535f, + 0.496165096759796f, 0.499985307455063f, 0.496548563241959f, + 0.499988079071045f, 0.496932059526443f, 0.499990582466125f, + 0.497315555810928f, 0.499992787837982f, 0.497699022293091f, + 0.499994695186615f, 0.498082518577576f, 0.499996334314346f, + 0.498466014862061f, 0.499997645616531f, 0.498849511146545f, + 0.499998688697815f, 0.499233007431030f, 0.499999403953552f, + 0.499616503715515f, 0.499999850988388f, }; - /** @par Generation of realCoefB array: @@ -2108,2064 +2791,2746 @@ static const float32_t realCoefA[8192] = { n = 4096
for (i = 0; i < n; i++)
   {
-     pBTable[2 * i]     = 0.5 * (1.0 + sin (2 * PI / (double) (2 * n) * (double) i));
-     pBTable[2 * i + 1] = 0.5 * (1.0 * cos (2 * PI / (double) (2 * n) * (double) i));
+     pBTable[2 * i]     = 0.5 * (1.0 + sin (2 * PI / (double) (2 * n) * (double)
+  i)); pBTable[2 * i + 1] = 0.5 * (1.0 * cos (2 * PI / (double) (2 * n) *
+  (double) i));
   }
*/ static const float32_t realCoefB[8192] = { - 0.500000000000000f, 0.500000000000000f, 0.500383496284485f, 0.499999850988388f, - 0.500766992568970f, 0.499999403953552f, 0.501150488853455f, 0.499998688697815f, - 0.501533985137939f, 0.499997645616531f, 0.501917481422424f, 0.499996334314346f, - 0.502300977706909f, 0.499994695186615f, 0.502684473991394f, 0.499992787837982f, - 0.503067970275879f, 0.499990582466125f, 0.503451406955719f, 0.499988079071045f, - 0.503834903240204f, 0.499985307455063f, 0.504218399524689f, 0.499982208013535f, - 0.504601895809174f, 0.499978810548782f, 0.504985332489014f, 0.499975144863129f, - 0.505368828773499f, 0.499971181154251f, 0.505752325057983f, 0.499966919422150f, - 0.506135761737823f, 0.499962359666824f, 0.506519258022308f, 0.499957501888275f, - 0.506902694702148f, 0.499952346086502f, 0.507286131381989f, 0.499946922063828f, - 0.507669627666473f, 0.499941170215607f, 0.508053064346313f, 0.499935150146484f, - 0.508436501026154f, 0.499928832054138f, 0.508819937705994f, 0.499922215938568f, - 0.509203374385834f, 0.499915301799774f, 0.509586811065674f, 0.499908089637756f, - 0.509970188140869f, 0.499900579452515f, 0.510353624820709f, 0.499892801046371f, - 0.510737061500549f, 0.499884694814682f, 0.511120438575745f, 0.499876320362091f, - 0.511503815650940f, 0.499867647886276f, 0.511887252330780f, 0.499858677387238f, - 0.512270629405975f, 0.499849408864975f, 0.512654006481171f, 0.499839842319489f, - 0.513037383556366f, 0.499830007553101f, 0.513420701026917f, 0.499819844961166f, - 0.513804078102112f, 0.499809414148331f, 0.514187395572662f, 0.499798685312271f, - 0.514570772647858f, 0.499787658452988f, 0.514954090118408f, 0.499776333570480f, - 0.515337407588959f, 0.499764710664749f, 0.515720725059509f, 0.499752789735794f, - 0.516103982925415f, 0.499740600585938f, 0.516487300395966f, 0.499728083610535f, - 0.516870558261871f, 0.499715298414230f, 0.517253875732422f, 0.499702215194702f, - 0.517637133598328f, 0.499688833951950f, 0.518020391464233f, 0.499675154685974f, - 0.518403589725494f, 0.499661177396774f, 0.518786847591400f, 0.499646931886673f, - 0.519170045852661f, 0.499632388353348f, 0.519553244113922f, 0.499617516994476f, - 0.519936442375183f, 0.499602377414703f, 0.520319640636444f, 0.499586939811707f, - 0.520702838897705f, 0.499571204185486f, 0.521085977554321f, 0.499555170536041f, - 0.521469116210938f, 0.499538868665695f, 0.521852254867554f, 0.499522238969803f, - 0.522235393524170f, 0.499505341053009f, 0.522618472576141f, 0.499488145112991f, - 0.523001611232758f, 0.499470651149750f, 0.523384690284729f, 0.499452859163284f, - 0.523767769336700f, 0.499434769153595f, 0.524150788784027f, 0.499416410923004f, - 0.524533808231354f, 0.499397724866867f, 0.524916887283325f, 0.499378770589828f, - 0.525299847126007f, 0.499359518289566f, 0.525682866573334f, 0.499339967966080f, - 0.526065826416016f, 0.499320119619370f, 0.526448845863342f, 0.499299973249435f, - 0.526831746101379f, 0.499279528856277f, 0.527214705944061f, 0.499258816242218f, - 0.527597606182098f, 0.499237775802612f, 0.527980506420136f, 0.499216467142105f, - 0.528363406658173f, 0.499194860458374f, 0.528746306896210f, 0.499172955751419f, - 0.529129147529602f, 0.499150782823563f, 0.529511988162994f, 0.499128282070160f, - 0.529894769191742f, 0.499105513095856f, 0.530277609825134f, 0.499082416296005f, - 0.530660390853882f, 0.499059051275253f, 0.531043112277985f, 0.499035388231277f, - 0.531425893306732f, 0.499011427164078f, 0.531808614730835f, 0.498987197875977f, - 0.532191336154938f, 0.498962640762329f, 0.532573997974396f, 0.498937815427780f, - 0.532956659793854f, 0.498912662267685f, 0.533339321613312f, 0.498887240886688f, - 0.533721983432770f, 0.498861521482468f, 0.534104585647583f, 0.498835533857346f, - 0.534487187862396f, 0.498809218406677f, 0.534869730472565f, 0.498782604932785f, - 0.535252273082733f, 0.498755723237991f, 0.535634815692902f, 0.498728543519974f, - 0.536017298698425f, 0.498701065778732f, 0.536399841308594f, 0.498673290014267f, - 0.536782264709473f, 0.498645216226578f, 0.537164747714996f, 0.498616874217987f, - 0.537547171115875f, 0.498588204383850f, 0.537929534912109f, 0.498559266328812f, - 0.538311958312988f, 0.498530030250549f, 0.538694262504578f, 0.498500496149063f, - 0.539076626300812f, 0.498470664024353f, 0.539458930492401f, 0.498440563678741f, - 0.539841234683990f, 0.498410135507584f, 0.540223479270935f, 0.498379439115524f, - 0.540605723857880f, 0.498348444700241f, 0.540987968444824f, 0.498317152261734f, - 0.541370153427124f, 0.498285561800003f, 0.541752278804779f, 0.498253703117371f, - 0.542134463787079f, 0.498221516609192f, 0.542516589164734f, 0.498189061880112f, - 0.542898654937744f, 0.498156309127808f, 0.543280720710754f, 0.498123258352280f, - 0.543662786483765f, 0.498089909553528f, 0.544044792652130f, 0.498056292533875f, - 0.544426798820496f, 0.498022347688675f, 0.544808745384216f, 0.497988134622574f, - 0.545190691947937f, 0.497953623533249f, 0.545572578907013f, 0.497918814420700f, - 0.545954465866089f, 0.497883707284927f, 0.546336352825165f, 0.497848302125931f, - 0.546718180179596f, 0.497812628746033f, 0.547099947929382f, 0.497776657342911f, - 0.547481775283813f, 0.497740387916565f, 0.547863483428955f, 0.497703820466995f, - 0.548245191574097f, 0.497666954994202f, 0.548626899719238f, 0.497629791498184f, - 0.549008548259735f, 0.497592359781265f, 0.549390196800232f, 0.497554630041122f, - 0.549771785736084f, 0.497516602277756f, 0.550153374671936f, 0.497478276491165f, - 0.550534904003143f, 0.497439652681351f, 0.550916433334351f, 0.497400760650635f, - 0.551297962665558f, 0.497361570596695f, 0.551679372787476f, 0.497322082519531f, - 0.552060842514038f, 0.497282296419144f, 0.552442193031311f, 0.497242212295532f, - 0.552823603153229f, 0.497201830148697f, 0.553204894065857f, 0.497161179780960f, - 0.553586184978485f, 0.497120231389999f, 0.553967475891113f, 0.497078984975815f, - 0.554348707199097f, 0.497037440538406f, 0.554729938507080f, 0.496995598077774f, - 0.555111110210419f, 0.496953487396240f, 0.555492222309113f, 0.496911078691483f, - 0.555873334407806f, 0.496868371963501f, 0.556254446506500f, 0.496825367212296f, - 0.556635499000549f, 0.496782064437866f, 0.557016491889954f, 0.496738493442535f, - 0.557397484779358f, 0.496694594621658f, 0.557778418064117f, 0.496650427579880f, - 0.558159291744232f, 0.496605962514877f, 0.558540165424347f, 0.496561229228973f, - 0.558921039104462f, 0.496516168117523f, 0.559301853179932f, 0.496470838785172f, - 0.559682607650757f, 0.496425211429596f, 0.560063362121582f, 0.496379286050797f, - 0.560444056987762f, 0.496333062648773f, 0.560824692249298f, 0.496286571025848f, - 0.561205327510834f, 0.496239781379700f, 0.561585903167725f, 0.496192663908005f, - 0.561966478824615f, 0.496145308017731f, 0.562346994876862f, 0.496097624301910f, - 0.562727510929108f, 0.496049642562866f, 0.563107967376709f, 0.496001392602921f, - 0.563488364219666f, 0.495952844619751f, 0.563868701457977f, 0.495903998613358f, - 0.564249038696289f, 0.495854884386063f, 0.564629375934601f, 0.495805442333221f, - 0.565009593963623f, 0.495755732059479f, 0.565389811992645f, 0.495705723762512f, - 0.565770030021667f, 0.495655417442322f, 0.566150128841400f, 0.495604842901230f, - 0.566530287265778f, 0.495553970336914f, 0.566910326480865f, 0.495502769947052f, - 0.567290365695953f, 0.495451331138611f, 0.567670345306396f, 0.495399564504623f, - 0.568050265312195f, 0.495347499847412f, 0.568430185317993f, 0.495295166969299f, - 0.568810045719147f, 0.495242536067963f, 0.569189906120300f, 0.495189607143402f, - 0.569569647312164f, 0.495136409997940f, 0.569949388504028f, 0.495082914829254f, - 0.570329129695892f, 0.495029091835022f, 0.570708811283112f, 0.494975030422211f, - 0.571088373661041f, 0.494920641183853f, 0.571467995643616f, 0.494865983724594f, - 0.571847498416901f, 0.494810998439789f, 0.572227001190186f, 0.494755744934082f, - 0.572606444358826f, 0.494700223207474f, 0.572985887527466f, 0.494644373655319f, - 0.573365211486816f, 0.494588255882263f, 0.573744535446167f, 0.494531840085983f, - 0.574123859405518f, 0.494475126266479f, 0.574503064155579f, 0.494418144226074f, - 0.574882268905640f, 0.494360834360123f, 0.575261414051056f, 0.494303256273270f, - 0.575640499591827f, 0.494245409965515f, 0.576019585132599f, 0.494187235832214f, - 0.576398611068726f, 0.494128793478012f, 0.576777577400208f, 0.494070053100586f, - 0.577156484127045f, 0.494011014699936f, 0.577535390853882f, 0.493951678276062f, - 0.577914178371429f, 0.493892073631287f, 0.578292965888977f, 0.493832170963287f, - 0.578671753406525f, 0.493771970272064f, 0.579050421714783f, 0.493711471557617f, - 0.579429090023041f, 0.493650704622269f, 0.579807698726654f, 0.493589639663696f, - 0.580186247825623f, 0.493528276681900f, 0.580564737319946f, 0.493466645479202f, - 0.580943167209625f, 0.493404686450958f, 0.581321597099304f, 0.493342459201813f, - 0.581699967384338f, 0.493279963731766f, 0.582078278064728f, 0.493217140436172f, - 0.582456588745117f, 0.493154048919678f, 0.582834780216217f, 0.493090659379959f, - 0.583212971687317f, 0.493026971817017f, 0.583591103553772f, 0.492963016033173f, - 0.583969175815582f, 0.492898762226105f, 0.584347188472748f, 0.492834210395813f, - 0.584725141525269f, 0.492769360542297f, 0.585103094577789f, 0.492704242467880f, - 0.585480928421021f, 0.492638826370239f, 0.585858762264252f, 0.492573112249374f, - 0.586236536502838f, 0.492507129907608f, 0.586614251136780f, 0.492440819740295f, - 0.586991965770721f, 0.492374241352081f, 0.587369561195374f, 0.492307394742966f, - 0.587747097015381f, 0.492240220308304f, 0.588124632835388f, 0.492172777652740f, - 0.588502109050751f, 0.492105036973953f, 0.588879525661469f, 0.492037028074265f, - 0.589256882667542f, 0.491968721151352f, 0.589634180068970f, 0.491900116205215f, - 0.590011477470398f, 0.491831213235855f, 0.590388655662537f, 0.491762012243271f, - 0.590765833854675f, 0.491692543029785f, 0.591142892837524f, 0.491622805595398f, - 0.591519951820374f, 0.491552740335464f, 0.591896951198578f, 0.491482406854630f, - 0.592273890972137f, 0.491411775350571f, 0.592650771141052f, 0.491340845823288f, - 0.593027591705322f, 0.491269648075104f, 0.593404352664948f, 0.491198152303696f, - 0.593781054019928f, 0.491126358509064f, 0.594157755374908f, 0.491054296493530f, - 0.594534337520599f, 0.490981936454773f, 0.594910860061646f, 0.490909278392792f, - 0.595287382602692f, 0.490836352109909f, 0.595663845539093f, 0.490763127803802f, - 0.596040189266205f, 0.490689605474472f, 0.596416532993317f, 0.490615785121918f, - 0.596792817115784f, 0.490541696548462f, 0.597168982028961f, 0.490467309951782f, - 0.597545146942139f, 0.490392625331879f, 0.597921252250671f, 0.490317672491074f, - 0.598297297954559f, 0.490242421627045f, 0.598673284053802f, 0.490166902542114f, - 0.599049210548401f, 0.490091055631638f, 0.599425077438354f, 0.490014940500259f, - 0.599800884723663f, 0.489938557147980f, 0.600176632404327f, 0.489861875772476f, - 0.600552320480347f, 0.489784896373749f, 0.600927948951721f, 0.489707618951797f, - 0.601303517818451f, 0.489630073308945f, 0.601679027080536f, 0.489552229642868f, - 0.602054476737976f, 0.489474087953568f, 0.602429866790771f, 0.489395678043365f, - 0.602805197238922f, 0.489316970109940f, 0.603180468082428f, 0.489237964153290f, - 0.603555679321289f, 0.489158689975739f, 0.603930830955505f, 0.489079117774963f, - 0.604305922985077f, 0.488999247550964f, 0.604680955410004f, 0.488919109106064f, - 0.605055928230286f, 0.488838672637939f, 0.605430841445923f, 0.488757967948914f, - 0.605805635452271f, 0.488676935434341f, 0.606180429458618f, 0.488595664501190f, - 0.606555163860321f, 0.488514065742493f, 0.606929838657379f, 0.488432198762894f, - 0.607304394245148f, 0.488350033760071f, 0.607678949832916f, 0.488267600536346f, - 0.608053386211395f, 0.488184869289398f, 0.608427822589874f, 0.488101840019226f, - 0.608802139759064f, 0.488018542528152f, 0.609176397323608f, 0.487934947013855f, - 0.609550595283508f, 0.487851053476334f, 0.609924793243408f, 0.487766891717911f, - 0.610298871994019f, 0.487682431936264f, 0.610672831535339f, 0.487597703933716f, - 0.611046791076660f, 0.487512677907944f, 0.611420691013336f, 0.487427353858948f, - 0.611794531345367f, 0.487341761589050f, 0.612168252468109f, 0.487255871295929f, - 0.612541973590851f, 0.487169682979584f, 0.612915575504303f, 0.487083226442337f, - 0.613289117813110f, 0.486996471881866f, 0.613662600517273f, 0.486909449100494f, - 0.614036023616791f, 0.486822128295898f, 0.614409387111664f, 0.486734509468079f, - 0.614782691001892f, 0.486646622419357f, 0.615155875682831f, 0.486558437347412f, - 0.615529060363770f, 0.486469984054565f, 0.615902125835419f, 0.486381232738495f, - 0.616275131702423f, 0.486292183399200f, 0.616648077964783f, 0.486202865839005f, - 0.617020964622498f, 0.486113250255585f, 0.617393791675568f, 0.486023366451263f, - 0.617766559123993f, 0.485933154821396f, 0.618139207363129f, 0.485842704772949f, - 0.618511795997620f, 0.485751956701279f, 0.618884325027466f, 0.485660910606384f, - 0.619256794452667f, 0.485569566488266f, 0.619629204273224f, 0.485477954149246f, - 0.620001494884491f, 0.485386073589325f, 0.620373785495758f, 0.485293895006180f, - 0.620745956897736f, 0.485201418399811f, 0.621118068695068f, 0.485108673572540f, - 0.621490061283112f, 0.485015630722046f, 0.621862053871155f, 0.484922289848328f, - 0.622233927249908f, 0.484828680753708f, 0.622605800628662f, 0.484734803438187f, - 0.622977554798126f, 0.484640628099442f, 0.623349189758301f, 0.484546154737473f, - 0.623720824718475f, 0.484451413154602f, 0.624092340469360f, 0.484356373548508f, - 0.624463796615601f, 0.484261035919189f, 0.624835193157196f, 0.484165430068970f, - 0.625206530094147f, 0.484069555997849f, 0.625577747821808f, 0.483973383903503f, - 0.625948905944824f, 0.483876913785934f, 0.626320004463196f, 0.483780175447464f, - 0.626691043376923f, 0.483683139085770f, 0.627061963081360f, 0.483585834503174f, - 0.627432823181152f, 0.483488231897354f, 0.627803623676300f, 0.483390361070633f, - 0.628174364566803f, 0.483292192220688f, 0.628544986248016f, 0.483193725347519f, - 0.628915548324585f, 0.483094990253448f, 0.629286050796509f, 0.482995986938477f, - 0.629656434059143f, 0.482896685600281f, 0.630026817321777f, 0.482797086238861f, - 0.630397081375122f, 0.482697218656540f, 0.630767226219177f, 0.482597053050995f, - 0.631137371063232f, 0.482496619224548f, 0.631507396697998f, 0.482395917177200f, - 0.631877362728119f, 0.482294887304306f, 0.632247209548950f, 0.482193619012833f, - 0.632616996765137f, 0.482092022895813f, 0.632986724376678f, 0.481990188360214f, - 0.633356392383575f, 0.481888025999069f, 0.633725941181183f, 0.481785595417023f, - 0.634095430374146f, 0.481682896614075f, 0.634464859962463f, 0.481579899787903f, - 0.634834170341492f, 0.481476634740829f, 0.635203421115875f, 0.481373071670532f, - 0.635572552680969f, 0.481269240379334f, 0.635941684246063f, 0.481165111064911f, - 0.636310696601868f, 0.481060713529587f, 0.636679589748383f, 0.480956017971039f, - 0.637048482894897f, 0.480851024389267f, 0.637417197227478f, 0.480745792388916f, - 0.637785911560059f, 0.480640232563019f, 0.638154506683350f, 0.480534434318542f, - 0.638523042201996f, 0.480428308248520f, 0.638891458511353f, 0.480321943759918f, - 0.639259815216064f, 0.480215251445770f, 0.639628112316132f, 0.480108320713043f, - 0.639996349811554f, 0.480001062154770f, 0.640364408493042f, 0.479893565177917f, - 0.640732467174530f, 0.479785770177841f, 0.641100406646729f, 0.479677677154541f, - 0.641468286514282f, 0.479569315910339f, 0.641836047172546f, 0.479460656642914f, - 0.642203748226166f, 0.479351729154587f, 0.642571389675140f, 0.479242533445358f, - 0.642938911914825f, 0.479133039712906f, 0.643306374549866f, 0.479023247957230f, - 0.643673717975616f, 0.478913217782974f, 0.644041001796722f, 0.478802859783173f, - 0.644408226013184f, 0.478692263364792f, 0.644775331020355f, 0.478581339120865f, - 0.645142316818237f, 0.478470176458359f, 0.645509302616119f, 0.478358715772629f, - 0.645876109600067f, 0.478246957063675f, 0.646242916584015f, 0.478134930133820f, - 0.646609604358673f, 0.478022634983063f, 0.646976172924042f, 0.477910041809082f, - 0.647342681884766f, 0.477797180414200f, 0.647709131240845f, 0.477684020996094f, - 0.648075461387634f, 0.477570593357086f, 0.648441672325134f, 0.477456867694855f, - 0.648807883262634f, 0.477342873811722f, 0.649173915386200f, 0.477228611707687f, - 0.649539887905121f, 0.477114051580429f, 0.649905800819397f, 0.476999223232269f, - 0.650271594524384f, 0.476884096860886f, 0.650637328624725f, 0.476768702268600f, - 0.651003003120422f, 0.476653009653091f, 0.651368498802185f, 0.476537048816681f, - 0.651733994483948f, 0.476420819759369f, 0.652099311351776f, 0.476304292678833f, - 0.652464628219604f, 0.476187497377396f, 0.652829825878143f, 0.476070433855057f, - 0.653194904327393f, 0.475953072309494f, 0.653559923171997f, 0.475835442543030f, - 0.653924822807312f, 0.475717514753342f, 0.654289662837982f, 0.475599318742752f, - 0.654654383659363f, 0.475480824708939f, 0.655019044876099f, 0.475362062454224f, - 0.655383586883545f, 0.475243031978607f, 0.655748009681702f, 0.475123733282089f, - 0.656112432479858f, 0.475004136562347f, 0.656476676464081f, 0.474884241819382f, - 0.656840860843658f, 0.474764078855515f, 0.657204985618591f, 0.474643647670746f, - 0.657568991184235f, 0.474522948265076f, 0.657932877540588f, 0.474401950836182f, - 0.658296704292297f, 0.474280685186386f, 0.658660411834717f, 0.474159121513367f, - 0.659024059772491f, 0.474037289619446f, 0.659387588500977f, 0.473915189504623f, - 0.659750998020172f, 0.473792791366577f, 0.660114347934723f, 0.473670125007629f, - 0.660477638244629f, 0.473547190427780f, 0.660840749740601f, 0.473423957824707f, - 0.661203861236572f, 0.473300457000732f, 0.661566793918610f, 0.473176687955856f, - 0.661929666996002f, 0.473052620887756f, 0.662292480468750f, 0.472928285598755f, - 0.662655174732208f, 0.472803652286530f, 0.663017749786377f, 0.472678780555725f, - 0.663380205631256f, 0.472553610801697f, 0.663742601871490f, 0.472428143024445f, - 0.664104938507080f, 0.472302407026291f, 0.664467096328735f, 0.472176402807236f, - 0.664829254150391f, 0.472050130367279f, 0.665191233158112f, 0.471923559904099f, - 0.665553152561188f, 0.471796721220016f, 0.665914952754974f, 0.471669614315033f, - 0.666276693344116f, 0.471542209386826f, 0.666638314723969f, 0.471414536237717f, - 0.666999816894531f, 0.471286594867706f, 0.667361259460449f, 0.471158385276794f, - 0.667722582817078f, 0.471029877662659f, 0.668083786964417f, 0.470901101827621f, - 0.668444931507111f, 0.470772027969360f, 0.668805956840515f, 0.470642685890198f, - 0.669166862964630f, 0.470513075590134f, 0.669527709484100f, 0.470383197069168f, - 0.669888436794281f, 0.470253020524979f, 0.670249044895172f, 0.470122605562210f, - 0.670609593391418f, 0.469991862773895f, 0.670970022678375f, 0.469860881567001f, - 0.671330332756042f, 0.469729602336884f, 0.671690583229065f, 0.469598054885864f, - 0.672050714492798f, 0.469466239213943f, 0.672410726547241f, 0.469334155321121f, - 0.672770678997040f, 0.469201773405075f, 0.673130512237549f, 0.469069123268127f, - 0.673490226268768f, 0.468936175107956f, 0.673849821090698f, 0.468802988529205f, - 0.674209356307983f, 0.468669503927231f, 0.674568772315979f, 0.468535751104355f, - 0.674928069114685f, 0.468401730060577f, 0.675287246704102f, 0.468267410993576f, - 0.675646364688873f, 0.468132823705673f, 0.676005363464355f, 0.467997968196869f, - 0.676364302635193f, 0.467862844467163f, 0.676723062992096f, 0.467727422714233f, - 0.677081763744354f, 0.467591762542725f, 0.677440345287323f, 0.467455804347992f, - 0.677798807621002f, 0.467319577932358f, 0.678157210350037f, 0.467183053493500f, - 0.678515493869781f, 0.467046260833740f, 0.678873658180237f, 0.466909229755402f, - 0.679231703281403f, 0.466771900653839f, 0.679589688777924f, 0.466634273529053f, - 0.679947495460510f, 0.466496407985687f, 0.680305242538452f, 0.466358244419098f, - 0.680662930011749f, 0.466219812631607f, 0.681020438671112f, 0.466081112623215f, - 0.681377887725830f, 0.465942144393921f, 0.681735157966614f, 0.465802878141403f, - 0.682092368602753f, 0.465663343667984f, 0.682449519634247f, 0.465523540973663f, - 0.682806491851807f, 0.465383470058441f, 0.683163404464722f, 0.465243130922318f, - 0.683520197868347f, 0.465102523565292f, 0.683876872062683f, 0.464961618185043f, - 0.684233427047729f, 0.464820444583893f, 0.684589862823486f, 0.464679002761841f, - 0.684946238994598f, 0.464537292718887f, 0.685302436351776f, 0.464395314455032f, - 0.685658574104309f, 0.464253038167953f, 0.686014592647552f, 0.464110493659973f, - 0.686370551586151f, 0.463967710733414f, 0.686726331710815f, 0.463824629783630f, - 0.687082052230835f, 0.463681250810623f, 0.687437593936920f, 0.463537633419037f, - 0.687793076038361f, 0.463393747806549f, 0.688148438930511f, 0.463249564170837f, - 0.688503682613373f, 0.463105112314224f, 0.688858866691589f, 0.462960392236710f, - 0.689213871955872f, 0.462815403938293f, 0.689568817615509f, 0.462670147418976f, - 0.689923584461212f, 0.462524622678757f, 0.690278291702271f, 0.462378799915314f, - 0.690632879734039f, 0.462232738733292f, 0.690987348556519f, 0.462086379528046f, - 0.691341698169708f, 0.461939752101898f, 0.691695988178253f, 0.461792886257172f, - 0.692050099372864f, 0.461645722389221f, 0.692404091358185f, 0.461498260498047f, - 0.692758023738861f, 0.461350560188293f, 0.693111836910248f, 0.461202591657639f, - 0.693465530872345f, 0.461054325103760f, 0.693819046020508f, 0.460905820131302f, - 0.694172501564026f, 0.460757017135620f, 0.694525837898254f, 0.460607945919037f, - 0.694879114627838f, 0.460458606481552f, 0.695232212543488f, 0.460309028625488f, - 0.695585191249847f, 0.460159152746201f, 0.695938050746918f, 0.460008978843689f, - 0.696290850639343f, 0.459858566522598f, 0.696643471717834f, 0.459707885980606f, - 0.696996033191681f, 0.459556937217712f, 0.697348415851593f, 0.459405690431595f, - 0.697700738906860f, 0.459254205226898f, 0.698052942752838f, 0.459102421998978f, - 0.698404967784882f, 0.458950400352478f, 0.698756933212280f, 0.458798080682755f, - 0.699108779430389f, 0.458645492792130f, 0.699460506439209f, 0.458492636680603f, - 0.699812114238739f, 0.458339542150497f, 0.700163602828979f, 0.458186149597168f, - 0.700514972209930f, 0.458032488822937f, 0.700866222381592f, 0.457878559827805f, - 0.701217353343964f, 0.457724362611771f, 0.701568365097046f, 0.457569897174835f, - 0.701919257640839f, 0.457415163516998f, 0.702270030975342f, 0.457260161638260f, - 0.702620685100555f, 0.457104891538620f, 0.702971220016479f, 0.456949323415756f, - 0.703321635723114f, 0.456793516874313f, 0.703671932220459f, 0.456637442111969f, - 0.704022109508514f, 0.456481099128723f, 0.704372167587280f, 0.456324487924576f, - 0.704722046852112f, 0.456167578697205f, 0.705071866512299f, 0.456010431051254f, - 0.705421566963196f, 0.455853015184402f, 0.705771148204803f, 0.455695331096649f, - 0.706120610237122f, 0.455537378787994f, 0.706469953060150f, 0.455379128456116f, - 0.706819176673889f, 0.455220639705658f, 0.707168221473694f, 0.455061882734299f, - 0.707517206668854f, 0.454902857542038f, 0.707866072654724f, 0.454743564128876f, - 0.708214759826660f, 0.454584002494812f, 0.708563387393951f, 0.454424172639847f, - 0.708911836147308f, 0.454264044761658f, 0.709260225296021f, 0.454103678464890f, - 0.709608435630798f, 0.453943043947220f, 0.709956526756287f, 0.453782171010971f, - 0.710304558277130f, 0.453621000051498f, 0.710652410984039f, 0.453459560871124f, - 0.711000144481659f, 0.453297853469849f, 0.711347758769989f, 0.453135877847672f, - 0.711695253849030f, 0.452973634004593f, 0.712042629718781f, 0.452811151742935f, - 0.712389826774597f, 0.452648371458054f, 0.712736964225769f, 0.452485352754593f, - 0.713083922863007f, 0.452322036027908f, 0.713430821895599f, 0.452158480882645f, - 0.713777542114258f, 0.451994657516479f, 0.714124143123627f, 0.451830536127090f, - 0.714470624923706f, 0.451666176319122f, 0.714816987514496f, 0.451501548290253f, - 0.715163230895996f, 0.451336652040482f, 0.715509355068207f, 0.451171487569809f, - 0.715855300426483f, 0.451006084680557f, 0.716201186180115f, 0.450840383768082f, - 0.716546893119812f, 0.450674414634705f, 0.716892480850220f, 0.450508207082748f, - 0.717238008975983f, 0.450341701507568f, 0.717583298683167f, 0.450174957513809f, - 0.717928528785706f, 0.450007945299149f, 0.718273639678955f, 0.449840664863586f, - 0.718618571758270f, 0.449673116207123f, 0.718963444232941f, 0.449505299329758f, - 0.719308137893677f, 0.449337244033813f, 0.719652712345123f, 0.449168890714645f, - 0.719997107982636f, 0.449000298976898f, 0.720341444015503f, 0.448831409215927f, - 0.720685660839081f, 0.448662281036377f, 0.721029698848724f, 0.448492884635925f, - 0.721373617649078f, 0.448323249816895f, 0.721717417240143f, 0.448153316974640f, - 0.722061097621918f, 0.447983115911484f, 0.722404599189758f, 0.447812676429749f, - 0.722747981548309f, 0.447641968727112f, 0.723091304302216f, 0.447470992803574f, - 0.723434448242188f, 0.447299748659134f, 0.723777413368225f, 0.447128236293793f, - 0.724120318889618f, 0.446956485509872f, 0.724463045597076f, 0.446784436702728f, - 0.724805653095245f, 0.446612149477005f, 0.725148141384125f, 0.446439594030380f, - 0.725490510463715f, 0.446266770362854f, 0.725832700729370f, 0.446093708276749f, - 0.726174771785736f, 0.445920348167419f, 0.726516723632813f, 0.445746749639511f, - 0.726858556270599f, 0.445572882890701f, 0.727200269699097f, 0.445398747920990f, - 0.727541804313660f, 0.445224374532700f, 0.727883219718933f, 0.445049703121185f, - 0.728224515914917f, 0.444874793291092f, 0.728565633296967f, 0.444699615240097f, - 0.728906631469727f, 0.444524168968201f, 0.729247510433197f, 0.444348484277725f, - 0.729588270187378f, 0.444172531366348f, 0.729928910732269f, 0.443996280431747f, - 0.730269372463226f, 0.443819820880890f, 0.730609714984894f, 0.443643063306808f, - 0.730949878692627f, 0.443466067314148f, 0.731289982795715f, 0.443288803100586f, - 0.731629908084869f, 0.443111270666122f, 0.731969714164734f, 0.442933470010757f, - 0.732309341430664f, 0.442755430936813f, 0.732648849487305f, 0.442577123641968f, - 0.732988238334656f, 0.442398548126221f, 0.733327507972717f, 0.442219734191895f, - 0.733666598796844f, 0.442040622234344f, 0.734005570411682f, 0.441861271858215f, - 0.734344422817230f, 0.441681683063507f, 0.734683096408844f, 0.441501796245575f, - 0.735021650791168f, 0.441321671009064f, 0.735360085964203f, 0.441141277551651f, - 0.735698342323303f, 0.440960645675659f, 0.736036539077759f, 0.440779715776443f, - 0.736374497413635f, 0.440598547458649f, 0.736712396144867f, 0.440417140722275f, - 0.737050116062164f, 0.440235435962677f, 0.737387716770172f, 0.440053492784500f, - 0.737725138664246f, 0.439871311187744f, 0.738062441349030f, 0.439688831567764f, - 0.738399624824524f, 0.439506113529205f, 0.738736629486084f, 0.439323127269745f, - 0.739073514938354f, 0.439139902591705f, 0.739410281181335f, 0.438956409692764f, - 0.739746868610382f, 0.438772648572922f, 0.740083336830139f, 0.438588619232178f, - 0.740419685840607f, 0.438404351472855f, 0.740755856037140f, 0.438219845294952f, - 0.741091907024384f, 0.438035041093826f, 0.741427779197693f, 0.437849998474121f, - 0.741763532161713f, 0.437664687633514f, 0.742099165916443f, 0.437479138374329f, - 0.742434620857239f, 0.437293320894241f, 0.742769956588745f, 0.437107264995575f, - 0.743105113506317f, 0.436920911073685f, 0.743440151214600f, 0.436734348535538f, - 0.743775069713593f, 0.436547487974167f, 0.744109809398651f, 0.436360388994217f, - 0.744444429874420f, 0.436173021793365f, 0.744778931140900f, 0.435985416173935f, - 0.745113253593445f, 0.435797542333603f, 0.745447397232056f, 0.435609430074692f, - 0.745781481266022f, 0.435421019792557f, 0.746115326881409f, 0.435232400894165f, - 0.746449112892151f, 0.435043483972549f, 0.746782720088959f, 0.434854328632355f, - 0.747116148471832f, 0.434664934873581f, 0.747449457645416f, 0.434475272893906f, - 0.747782647609711f, 0.434285342693329f, 0.748115658760071f, 0.434095174074173f, - 0.748448550701141f, 0.433904737234116f, 0.748781263828278f, 0.433714061975479f, - 0.749113857746124f, 0.433523118495941f, 0.749446272850037f, 0.433331936597824f, - 0.749778568744659f, 0.433140486478806f, 0.750110685825348f, 0.432948768138886f, - 0.750442683696747f, 0.432756811380386f, 0.750774562358856f, 0.432564586400986f, - 0.751106262207031f, 0.432372123003006f, 0.751437783241272f, 0.432179391384125f, - 0.751769185066223f, 0.431986421346664f, 0.752100467681885f, 0.431793183088303f, - 0.752431571483612f, 0.431599706411362f, 0.752762496471405f, 0.431405961513519f, - 0.753093302249908f, 0.431211978197098f, 0.753423988819122f, 0.431017726659775f, - 0.753754496574402f, 0.430823236703873f, 0.754084885120392f, 0.430628478527069f, - 0.754415094852448f, 0.430433481931686f, 0.754745125770569f, 0.430238217115402f, - 0.755075037479401f, 0.430042684078217f, 0.755404829978943f, 0.429846942424774f, - 0.755734443664551f, 0.429650902748108f, 0.756063878536224f, 0.429454624652863f, - 0.756393194198608f, 0.429258108139038f, 0.756722390651703f, 0.429061323404312f, - 0.757051348686218f, 0.428864300251007f, 0.757380247116089f, 0.428667008876801f, - 0.757708966732025f, 0.428469479084015f, 0.758037507534027f, 0.428271710872650f, - 0.758365929126740f, 0.428073674440384f, 0.758694171905518f, 0.427875369787216f, - 0.759022235870361f, 0.427676826715469f, 0.759350180625916f, 0.427478045225143f, - 0.759678006172180f, 0.427278995513916f, 0.760005652904511f, 0.427079707384110f, - 0.760333120822906f, 0.426880151033401f, 0.760660469532013f, 0.426680356264114f, - 0.760987639427185f, 0.426480293273926f, 0.761314690113068f, 0.426279991865158f, - 0.761641561985016f, 0.426079452037811f, 0.761968255043030f, 0.425878643989563f, - 0.762294828891754f, 0.425677597522736f, 0.762621283531189f, 0.425476282835007f, - 0.762947499752045f, 0.425274729728699f, 0.763273596763611f, 0.425072938203812f, - 0.763599574565887f, 0.424870878458023f, 0.763925373554230f, 0.424668580293655f, - 0.764250993728638f, 0.424466013908386f, 0.764576494693756f, 0.424263238906860f, - 0.764901816844940f, 0.424060165882111f, 0.765226960182190f, 0.423856884241104f, - 0.765551984310150f, 0.423653304576874f, 0.765876889228821f, 0.423449516296387f, - 0.766201555728912f, 0.423245459794998f, 0.766526103019714f, 0.423041164875031f, - 0.766850471496582f, 0.422836631536484f, 0.767174720764160f, 0.422631829977036f, - 0.767498791217804f, 0.422426789999008f, 0.767822742462158f, 0.422221481800079f, - 0.768146514892578f, 0.422015935182571f, 0.768470108509064f, 0.421810150146484f, - 0.768793523311615f, 0.421604126691818f, 0.769116818904877f, 0.421397835016251f, - 0.769439935684204f, 0.421191304922104f, 0.769762933254242f, 0.420984506607056f, - 0.770085752010345f, 0.420777499675751f, 0.770408391952515f, 0.420570224523544f, - 0.770730912685394f, 0.420362681150436f, 0.771053194999695f, 0.420154929161072f, - 0.771375417709351f, 0.419946908950806f, 0.771697402000427f, 0.419738620519638f, - 0.772019267082214f, 0.419530123472214f, 0.772340953350067f, 0.419321358203888f, - 0.772662520408630f, 0.419112354516983f, 0.772983849048615f, 0.418903112411499f, - 0.773305058479309f, 0.418693602085114f, 0.773626148700714f, 0.418483853340149f, - 0.773947000503540f, 0.418273866176605f, 0.774267733097076f, 0.418063640594482f, - 0.774588346481323f, 0.417853146791458f, 0.774908721446991f, 0.417642414569855f, - 0.775228977203369f, 0.417431443929672f, 0.775549054145813f, 0.417220205068588f, - 0.775869011878967f, 0.417008757591248f, 0.776188731193542f, 0.416797041893005f, - 0.776508331298828f, 0.416585087776184f, 0.776827812194824f, 0.416372895240784f, - 0.777147054672241f, 0.416160434484482f, 0.777466177940369f, 0.415947735309601f, - 0.777785122394562f, 0.415734797716141f, 0.778103888034821f, 0.415521621704102f, - 0.778422534465790f, 0.415308207273483f, 0.778741002082825f, 0.415094524621964f, - 0.779059290885925f, 0.414880603551865f, 0.779377400875092f, 0.414666473865509f, - 0.779695332050323f, 0.414452046155930f, 0.780013144016266f, 0.414237409830093f, - 0.780330777168274f, 0.414022535085678f, 0.780648231506348f, 0.413807392120361f, - 0.780965566635132f, 0.413592010736465f, 0.781282722949982f, 0.413376390933990f, - 0.781599700450897f, 0.413160532712936f, 0.781916499137878f, 0.412944436073303f, - 0.782233119010925f, 0.412728071212769f, 0.782549619674683f, 0.412511497735977f, - 0.782865881919861f, 0.412294656038284f, 0.783182024955750f, 0.412077575922012f, - 0.783498048782349f, 0.411860257387161f, 0.783813834190369f, 0.411642700433731f, - 0.784129500389099f, 0.411424905061722f, 0.784444928169250f, 0.411206841468811f, - 0.784760236740112f, 0.410988569259644f, 0.785075426101685f, 0.410770028829575f, - 0.785390377044678f, 0.410551249980927f, 0.785705149173737f, 0.410332232713699f, - 0.786019802093506f, 0.410112977027893f, 0.786334276199341f, 0.409893482923508f, - 0.786648571491241f, 0.409673750400543f, 0.786962687969208f, 0.409453779459000f, - 0.787276685237885f, 0.409233570098877f, 0.787590444087982f, 0.409013092517853f, - 0.787904083728790f, 0.408792406320572f, 0.788217544555664f, 0.408571451902390f, - 0.788530826568604f, 0.408350288867950f, 0.788843929767609f, 0.408128857612610f, - 0.789156913757324f, 0.407907217741013f, 0.789469659328461f, 0.407685309648514f, - 0.789782285690308f, 0.407463163137436f, 0.790094733238220f, 0.407240778207779f, - 0.790407001972198f, 0.407018154859543f, 0.790719091892242f, 0.406795293092728f, - 0.791031002998352f, 0.406572192907333f, 0.791342735290527f, 0.406348884105682f, - 0.791654348373413f, 0.406125307083130f, 0.791965723037720f, 0.405901491641998f, - 0.792276978492737f, 0.405677437782288f, 0.792588055133820f, 0.405453115701675f, - 0.792898952960968f, 0.405228585004807f, 0.793209671974182f, 0.405003815889359f, - 0.793520212173462f, 0.404778808355331f, 0.793830573558807f, 0.404553562402725f, - 0.794140756130219f, 0.404328078031540f, 0.794450819492340f, 0.404102355241776f, - 0.794760644435883f, 0.403876423835754f, 0.795070350170136f, 0.403650224208832f, - 0.795379877090454f, 0.403423786163330f, 0.795689165592194f, 0.403197109699249f, - 0.795998334884644f, 0.402970194816589f, 0.796307325363159f, 0.402743041515350f, - 0.796616137027740f, 0.402515679597855f, 0.796924769878387f, 0.402288049459457f, - 0.797233223915100f, 0.402060180902481f, 0.797541558742523f, 0.401832103729248f, - 0.797849655151367f, 0.401603758335114f, 0.798157572746277f, 0.401375204324722f, - 0.798465371131897f, 0.401146411895752f, 0.798772931098938f, 0.400917351245880f, - 0.799080371856689f, 0.400688081979752f, 0.799387574195862f, 0.400458574295044f, - 0.799694657325745f, 0.400228828191757f, 0.800001561641693f, 0.399998843669891f, - 0.800308227539063f, 0.399768620729446f, 0.800614774227142f, 0.399538189172745f, - 0.800921142101288f, 0.399307489395142f, 0.801227271556854f, 0.399076581001282f, - 0.801533281803131f, 0.398845434188843f, 0.801839113235474f, 0.398614019155502f, - 0.802144765853882f, 0.398382395505905f, 0.802450239658356f, 0.398150533437729f, - 0.802755534648895f, 0.397918462753296f, 0.803060650825500f, 0.397686123847961f, - 0.803365588188171f, 0.397453576326370f, 0.803670346736908f, 0.397220760583878f, - 0.803974866867065f, 0.396987736225128f, 0.804279267787933f, 0.396754473447800f, - 0.804583489894867f, 0.396520972251892f, 0.804887533187866f, 0.396287262439728f, - 0.805191397666931f, 0.396053284406662f, 0.805495083332062f, 0.395819097757339f, - 0.805798590183258f, 0.395584672689438f, 0.806101918220520f, 0.395350009202957f, - 0.806405067443848f, 0.395115107297897f, 0.806707978248596f, 0.394879996776581f, - 0.807010769844055f, 0.394644618034363f, 0.807313382625580f, 0.394409030675888f, - 0.807615816593170f, 0.394173204898834f, 0.807918012142181f, 0.393937170505524f, - 0.808220088481903f, 0.393700867891312f, 0.808521986007690f, 0.393464356660843f, - 0.808823645114899f, 0.393227607011795f, 0.809125185012817f, 0.392990618944168f, - 0.809426486492157f, 0.392753422260284f, 0.809727668762207f, 0.392515957355499f, - 0.810028612613678f, 0.392278283834457f, 0.810329377651215f, 0.392040401697159f, - 0.810629963874817f, 0.391802251338959f, 0.810930430889130f, 0.391563892364502f, - 0.811230659484863f, 0.391325294971466f, 0.811530709266663f, 0.391086459159851f, - 0.811830580234528f, 0.390847414731979f, 0.812130272388458f, 0.390608131885529f, - 0.812429726123810f, 0.390368610620499f, 0.812729060649872f, 0.390128880739212f, - 0.813028216362000f, 0.389888882637024f, 0.813327133655548f, 0.389648675918579f, - 0.813625931739807f, 0.389408260583878f, 0.813924491405487f, 0.389167606830597f, - 0.814222872257233f, 0.388926714658737f, 0.814521074295044f, 0.388685584068298f, - 0.814819097518921f, 0.388444244861603f, 0.815116941928864f, 0.388202667236328f, - 0.815414607524872f, 0.387960851192474f, 0.815712094306946f, 0.387718826532364f, - 0.816009342670441f, 0.387476563453674f, 0.816306471824646f, 0.387234061956406f, - 0.816603362560272f, 0.386991351842880f, 0.816900074481964f, 0.386748403310776f, - 0.817196667194366f, 0.386505216360092f, 0.817493021488190f, 0.386261820793152f, - 0.817789137363434f, 0.386018186807632f, 0.818085134029388f, 0.385774344205856f, - 0.818380951881409f, 0.385530263185501f, 0.818676531314850f, 0.385285943746567f, - 0.818971931934357f, 0.385041415691376f, 0.819267153739929f, 0.384796649217606f, - 0.819562196731567f, 0.384551674127579f, 0.819857060909271f, 0.384306460618973f, - 0.820151746273041f, 0.384061008691788f, 0.820446193218231f, 0.383815348148346f, - 0.820740520954132f, 0.383569449186325f, 0.821034610271454f, 0.383323341608047f, - 0.821328520774841f, 0.383076995611191f, 0.821622252464294f, 0.382830440998077f, - 0.821915745735168f, 0.382583618164063f, 0.822209119796753f, 0.382336616516113f, - 0.822502255439758f, 0.382089376449585f, 0.822795212268829f, 0.381841897964478f, - 0.823087990283966f, 0.381594210863113f, 0.823380589485168f, 0.381346285343170f, - 0.823673009872437f, 0.381098151206970f, 0.823965191841125f, 0.380849778652191f, - 0.824257194995880f, 0.380601197481155f, 0.824549019336700f, 0.380352377891541f, - 0.824840664863586f, 0.380103349685669f, 0.825132071971893f, 0.379854083061218f, - 0.825423359870911f, 0.379604607820511f, 0.825714409351349f, 0.379354894161224f, - 0.826005280017853f, 0.379104942083359f, 0.826295912265778f, 0.378854811191559f, - 0.826586425304413f, 0.378604412078857f, 0.826876699924469f, 0.378353834152222f, - 0.827166795730591f, 0.378102988004684f, 0.827456712722778f, 0.377851963043213f, - 0.827746450901031f, 0.377600699663162f, 0.828035950660706f, 0.377349197864532f, - 0.828325271606445f, 0.377097487449646f, 0.828614413738251f, 0.376845568418503f, - 0.828903317451477f, 0.376593410968781f, 0.829192101955414f, 0.376341015100479f, - 0.829480648040771f, 0.376088410615921f, 0.829769015312195f, 0.375835597515106f, - 0.830057144165039f, 0.375582575798035f, 0.830345153808594f, 0.375329315662384f, - 0.830632925033569f, 0.375075817108154f, 0.830920517444611f, 0.374822109937668f, - 0.831207871437073f, 0.374568194150925f, 0.831495106220245f, 0.374314039945602f, - 0.831782102584839f, 0.374059677124023f, 0.832068860530853f, 0.373805105686188f, - 0.832355499267578f, 0.373550295829773f, 0.832641899585724f, 0.373295277357101f, - 0.832928121089935f, 0.373040050268173f, 0.833214163780212f, 0.372784584760666f, - 0.833499968051910f, 0.372528880834579f, 0.833785593509674f, 0.372272998094559f, - 0.834071040153503f, 0.372016876935959f, 0.834356248378754f, 0.371760547161102f, - 0.834641277790070f, 0.371503978967667f, 0.834926128387451f, 0.371247202157974f, - 0.835210800170898f, 0.370990216732025f, 0.835495233535767f, 0.370732992887497f, - 0.835779488086700f, 0.370475560426712f, 0.836063504219055f, 0.370217919349670f, - 0.836347401142120f, 0.369960039854050f, 0.836631059646606f, 0.369701951742172f, - 0.836914479732513f, 0.369443655014038f, 0.837197780609131f, 0.369185149669647f, - 0.837480843067169f, 0.368926405906677f, 0.837763667106628f, 0.368667453527451f, - 0.838046371936798f, 0.368408292531967f, 0.838328838348389f, 0.368148893117905f, - 0.838611066341400f, 0.367889285087585f, 0.838893175125122f, 0.367629468441010f, - 0.839175045490265f, 0.367369443178177f, 0.839456677436829f, 0.367109179496765f, - 0.839738130569458f, 0.366848707199097f, 0.840019404888153f, 0.366588026285172f, - 0.840300500392914f, 0.366327136754990f, 0.840581357479095f, 0.366066008806229f, - 0.840862035751343f, 0.365804702043533f, 0.841142535209656f, 0.365543156862259f, - 0.841422796249390f, 0.365281373262405f, 0.841702818870544f, 0.365019410848618f, - 0.841982722282410f, 0.364757210016251f, 0.842262387275696f, 0.364494800567627f, - 0.842541813850403f, 0.364232182502747f, 0.842821121215820f, 0.363969355821610f, - 0.843100130558014f, 0.363706320524216f, 0.843379020690918f, 0.363443046808243f, - 0.843657672405243f, 0.363179564476013f, 0.843936145305634f, 0.362915903329849f, - 0.844214379787445f, 0.362651973962784f, 0.844492435455322f, 0.362387865781784f, - 0.844770252704620f, 0.362123548984528f, 0.845047891139984f, 0.361858993768692f, - 0.845325350761414f, 0.361594229936600f, 0.845602571964264f, 0.361329287290573f, - 0.845879614353180f, 0.361064106225967f, 0.846156477928162f, 0.360798716545105f, - 0.846433103084564f, 0.360533088445663f, 0.846709489822388f, 0.360267281532288f, - 0.846985757350922f, 0.360001266002655f, 0.847261726856232f, 0.359735012054443f, - 0.847537577152252f, 0.359468549489975f, 0.847813189029694f, 0.359201908111572f, - 0.848088562488556f, 0.358935028314590f, 0.848363757133484f, 0.358667939901352f, - 0.848638772964478f, 0.358400642871857f, 0.848913550376892f, 0.358133137226105f, - 0.849188148975372f, 0.357865422964096f, 0.849462509155273f, 0.357597470283508f, - 0.849736690521240f, 0.357329338788986f, 0.850010633468628f, 0.357060998678207f, - 0.850284397602081f, 0.356792420148849f, 0.850557923316956f, 0.356523662805557f, - 0.850831270217896f, 0.356254696846008f, 0.851104438304901f, 0.355985492467880f, - 0.851377367973328f, 0.355716109275818f, 0.851650118827820f, 0.355446487665176f, - 0.851922631263733f, 0.355176687240601f, 0.852194905281067f, 0.354906648397446f, - 0.852467060089111f, 0.354636400938034f, 0.852738916873932f, 0.354365974664688f, - 0.853010654449463f, 0.354095309972763f, 0.853282094001770f, 0.353824466466904f, - 0.853553414344788f, 0.353553384542465f, 0.853824436664581f, 0.353282123804092f, - 0.854095339775085f, 0.353010624647141f, 0.854365944862366f, 0.352738946676254f, - 0.854636430740356f, 0.352467030286789f, 0.854906618595123f, 0.352194935083389f, - 0.855176687240601f, 0.351922631263733f, 0.855446517467499f, 0.351650089025497f, - 0.855716109275818f, 0.351377367973328f, 0.855985522270203f, 0.351104438304901f, - 0.856254696846008f, 0.350831300020218f, 0.856523692607880f, 0.350557953119278f, - 0.856792449951172f, 0.350284397602081f, 0.857060968875885f, 0.350010633468628f, - 0.857329368591309f, 0.349736660718918f, 0.857597470283508f, 0.349462509155273f, - 0.857865393161774f, 0.349188119173050f, 0.858133137226105f, 0.348913550376892f, - 0.858400642871857f, 0.348638743162155f, 0.858667910099030f, 0.348363757133484f, - 0.858934998512268f, 0.348088562488556f, 0.859201908111572f, 0.347813159227371f, - 0.859468579292297f, 0.347537547349930f, 0.859735012054443f, 0.347261756658554f, - 0.860001266002655f, 0.346985727548599f, 0.860267281532288f, 0.346709519624710f, - 0.860533118247986f, 0.346433073282242f, 0.860798716545105f, 0.346156448125839f, - 0.861064076423645f, 0.345879614353180f, 0.861329257488251f, 0.345602601766586f, - 0.861594259738922f, 0.345325350761414f, 0.861859023571014f, 0.345047920942307f, - 0.862123548984528f, 0.344770282506943f, 0.862387895584106f, 0.344492435455322f, - 0.862652003765106f, 0.344214379787445f, 0.862915873527527f, 0.343936115503311f, - 0.863179564476013f, 0.343657672405243f, 0.863443076610565f, 0.343379020690918f, - 0.863706290721893f, 0.343100160360336f, 0.863969385623932f, 0.342821091413498f, - 0.864232182502747f, 0.342541843652725f, 0.864494800567627f, 0.342262357473373f, - 0.864757239818573f, 0.341982692480087f, 0.865019381046295f, 0.341702848672867f, - 0.865281403064728f, 0.341422766447067f, 0.865543127059937f, 0.341142505407333f, - 0.865804672241211f, 0.340862035751343f, 0.866066038608551f, 0.340581357479095f, - 0.866327106952667f, 0.340300500392914f, 0.866588056087494f, 0.340019434690475f, - 0.866848707199097f, 0.339738160371780f, 0.867109179496765f, 0.339456677436829f, - 0.867369413375854f, 0.339175015687943f, 0.867629468441010f, 0.338893145322800f, - 0.867889285087585f, 0.338611096143723f, 0.868148922920227f, 0.338328808546066f, - 0.868408262729645f, 0.338046342134476f, 0.868667483329773f, 0.337763696908951f, - 0.868926405906677f, 0.337480813264847f, 0.869185149669647f, 0.337197750806808f, - 0.869443655014038f, 0.336914509534836f, 0.869701981544495f, 0.336631029844284f, - 0.869960069656372f, 0.336347371339798f, 0.870217919349670f, 0.336063534021378f, - 0.870475590229034f, 0.335779488086700f, 0.870733022689819f, 0.335495233535767f, - 0.870990216732025f, 0.335210770368576f, 0.871247172355652f, 0.334926128387451f, - 0.871503949165344f, 0.334641307592392f, 0.871760547161102f, 0.334356248378754f, - 0.872016847133636f, 0.334071010351181f, 0.872272968292236f, 0.333785593509674f, - 0.872528910636902f, 0.333499968051910f, 0.872784554958344f, 0.333214133977890f, - 0.873040020465851f, 0.332928121089935f, 0.873295307159424f, 0.332641899585724f, - 0.873550295829773f, 0.332355499267578f, 0.873805105686188f, 0.332068890333176f, - 0.874059677124023f, 0.331782072782516f, 0.874314069747925f, 0.331495076417923f, - 0.874568223953247f, 0.331207901239395f, 0.874822139739990f, 0.330920487642288f, - 0.875075817108154f, 0.330632925033569f, 0.875329315662384f, 0.330345153808594f, - 0.875582575798035f, 0.330057173967361f, 0.875835597515106f, 0.329769015312195f, - 0.876088440418243f, 0.329480648040771f, 0.876341044902802f, 0.329192101955414f, - 0.876593410968781f, 0.328903347253799f, 0.876845538616180f, 0.328614413738251f, - 0.877097487449646f, 0.328325271606445f, 0.877349197864532f, 0.328035950660706f, - 0.877600669860840f, 0.327746421098709f, 0.877851963043213f, 0.327456712722778f, - 0.878103017807007f, 0.327166795730591f, 0.878353834152222f, 0.326876699924469f, - 0.878604412078857f, 0.326586425304413f, 0.878854811191559f, 0.326295942068100f, - 0.879104971885681f, 0.326005280017853f, 0.879354894161224f, 0.325714409351349f, - 0.879604578018188f, 0.325423330068588f, 0.879854083061218f, 0.325132101774216f, - 0.880103349685669f, 0.324840664863586f, 0.880352377891541f, 0.324549019336700f, - 0.880601167678833f, 0.324257194995880f, 0.880849778652191f, 0.323965191841125f, - 0.881098151206970f, 0.323672980070114f, 0.881346285343170f, 0.323380589485168f, - 0.881594181060791f, 0.323088020086288f, 0.881841897964478f, 0.322795242071152f, - 0.882089376449585f, 0.322502255439758f, 0.882336616516113f, 0.322209119796753f, - 0.882583618164063f, 0.321915775537491f, 0.882830440998077f, 0.321622252464294f, - 0.883076965808868f, 0.321328520774841f, 0.883323311805725f, 0.321034610271454f, - 0.883569478988647f, 0.320740520954132f, 0.883815348148346f, 0.320446223020554f, - 0.884061038494110f, 0.320151746273041f, 0.884306430816650f, 0.319857090711594f, - 0.884551644325256f, 0.319562226533890f, 0.884796679019928f, 0.319267183542252f, - 0.885041415691376f, 0.318971961736679f, 0.885285973548889f, 0.318676531314850f, - 0.885530233383179f, 0.318380922079086f, 0.885774314403534f, 0.318085134029388f, - 0.886018216609955f, 0.317789167165756f, 0.886261820793152f, 0.317492991685867f, - 0.886505246162415f, 0.317196637392044f, 0.886748373508453f, 0.316900104284287f, - 0.886991322040558f, 0.316603392362595f, 0.887234091758728f, 0.316306471824646f, - 0.887476563453674f, 0.316009372472763f, 0.887718796730042f, 0.315712094306946f, - 0.887960851192474f, 0.315414607524872f, 0.888202667236328f, 0.315116971731186f, - 0.888444244861603f, 0.314819127321243f, 0.888685584068298f, 0.314521104097366f, - 0.888926684856415f, 0.314222872257233f, 0.889167606830597f, 0.313924491405487f, - 0.889408230781555f, 0.313625901937485f, 0.889648675918579f, 0.313327133655548f, - 0.889888882637024f, 0.313028186559677f, 0.890128850936890f, 0.312729060649872f, - 0.890368640422821f, 0.312429755926132f, 0.890608131885529f, 0.312130242586136f, - 0.890847444534302f, 0.311830550432205f, 0.891086459159851f, 0.311530679464340f, - 0.891325294971466f, 0.311230629682541f, 0.891563892364502f, 0.310930401086807f, - 0.891802251338959f, 0.310629993677139f, 0.892040371894836f, 0.310329377651215f, - 0.892278313636780f, 0.310028612613678f, 0.892515957355499f, 0.309727638959885f, - 0.892753422260284f, 0.309426486492157f, 0.892990648746490f, 0.309125155210495f, - 0.893227577209473f, 0.308823645114899f, 0.893464326858521f, 0.308521956205368f, - 0.893700897693634f, 0.308220088481903f, 0.893937170505524f, 0.307918041944504f, - 0.894173204898834f, 0.307615786790848f, 0.894409060478210f, 0.307313382625580f, - 0.894644618034363f, 0.307010769844055f, 0.894879996776581f, 0.306708008050919f, - 0.895115137100220f, 0.306405037641525f, 0.895349979400635f, 0.306101888418198f, - 0.895584642887115f, 0.305798590183258f, 0.895819067955017f, 0.305495083332062f, - 0.896053314208984f, 0.305191397666931f, 0.896287262439728f, 0.304887533187866f, - 0.896520972251892f, 0.304583519697189f, 0.896754503250122f, 0.304279297590256f, - 0.896987736225128f, 0.303974896669388f, 0.897220790386200f, 0.303670316934586f, - 0.897453546524048f, 0.303365558385849f, 0.897686123847961f, 0.303060621023178f, - 0.897918462753296f, 0.302755534648895f, 0.898150563240051f, 0.302450239658356f, - 0.898382425308228f, 0.302144765853882f, 0.898614048957825f, 0.301839113235474f, - 0.898845434188843f, 0.301533311605453f, 0.899076581001282f, 0.301227301359177f, - 0.899307489395142f, 0.300921112298965f, 0.899538159370422f, 0.300614774227142f, - 0.899768650531769f, 0.300308227539063f, 0.899998843669891f, 0.300001531839371f, - 0.900228857994080f, 0.299694657325745f, 0.900458574295044f, 0.299387603998184f, - 0.900688111782074f, 0.299080342054367f, 0.900917351245880f, 0.298772931098938f, - 0.901146411895752f, 0.298465341329575f, 0.901375174522400f, 0.298157602548599f, - 0.901603758335114f, 0.297849655151367f, 0.901832103729248f, 0.297541528940201f, - 0.902060210704803f, 0.297233253717422f, 0.902288019657135f, 0.296924799680710f, - 0.902515649795532f, 0.296616137027740f, 0.902743041515350f, 0.296307325363159f, - 0.902970194816589f, 0.295998334884644f, 0.903197109699249f, 0.295689195394516f, - 0.903423786163330f, 0.295379847288132f, 0.903650224208832f, 0.295070350170136f, - 0.903876423835754f, 0.294760644435883f, 0.904102385044098f, 0.294450789690018f, - 0.904328107833862f, 0.294140785932541f, 0.904553592205048f, 0.293830573558807f, - 0.904778838157654f, 0.293520182371140f, 0.905003845691681f, 0.293209642171860f, - 0.905228614807129f, 0.292898923158646f, 0.905453145503998f, 0.292588025331497f, - 0.905677437782288f, 0.292276978492737f, 0.905901491641998f, 0.291965723037720f, - 0.906125307083130f, 0.291654318571091f, 0.906348884105682f, 0.291342735290527f, - 0.906572222709656f, 0.291031002998352f, 0.906795322895050f, 0.290719062089920f, - 0.907018184661865f, 0.290406972169876f, 0.907240808010101f, 0.290094703435898f, - 0.907463192939758f, 0.289782285690308f, 0.907685279846191f, 0.289469659328461f, - 0.907907187938690f, 0.289156883955002f, 0.908128857612610f, 0.288843959569931f, - 0.908350288867950f, 0.288530826568604f, 0.908571481704712f, 0.288217544555664f, - 0.908792436122894f, 0.287904083728790f, 0.909013092517853f, 0.287590473890305f, - 0.909233570098877f, 0.287276685237885f, 0.909453809261322f, 0.286962717771530f, - 0.909673750400543f, 0.286648571491241f, 0.909893512725830f, 0.286334276199341f, - 0.910112977027893f, 0.286019802093506f, 0.910332262516022f, 0.285705178976059f, - 0.910551249980927f, 0.285390377044678f, 0.910769999027252f, 0.285075396299362f, - 0.910988569259644f, 0.284760266542435f, 0.911206841468811f, 0.284444957971573f, - 0.911424875259399f, 0.284129470586777f, 0.911642670631409f, 0.283813834190369f, - 0.911860227584839f, 0.283498018980026f, 0.912077546119690f, 0.283182054758072f, - 0.912294626235962f, 0.282865911722183f, 0.912511467933655f, 0.282549589872360f, - 0.912728071212769f, 0.282233119010925f, 0.912944436073303f, 0.281916469335556f, - 0.913160502910614f, 0.281599670648575f, 0.913376390933990f, 0.281282693147659f, - 0.913592040538788f, 0.280965566635132f, 0.913807392120361f, 0.280648261308670f, - 0.914022505283356f, 0.280330777168274f, 0.914237439632416f, 0.280013144016266f, - 0.914452075958252f, 0.279695361852646f, 0.914666473865509f, 0.279377400875092f, - 0.914880633354187f, 0.279059261083603f, 0.915094554424286f, 0.278740972280502f, - 0.915308177471161f, 0.278422504663467f, 0.915521621704102f, 0.278103888034821f, - 0.915734827518463f, 0.277785122394562f, 0.915947735309601f, 0.277466177940369f, - 0.916160404682159f, 0.277147054672241f, 0.916372895240784f, 0.276827782392502f, - 0.916585087776184f, 0.276508361101151f, 0.916797041893005f, 0.276188760995865f, - 0.917008757591248f, 0.275868982076645f, 0.917220234870911f, 0.275549083948135f, - 0.917431414127350f, 0.275228977203369f, 0.917642414569855f, 0.274908751249313f, - 0.917853116989136f, 0.274588316679001f, 0.918063640594482f, 0.274267762899399f, - 0.918273866176605f, 0.273947030305862f, 0.918483853340149f, 0.273626148700714f, - 0.918693602085114f, 0.273305088281631f, 0.918903112411499f, 0.272983878850937f, - 0.919112324714661f, 0.272662490606308f, 0.919321358203888f, 0.272340953350067f, - 0.919530093669891f, 0.272019267082214f, 0.919738650321960f, 0.271697402000427f, - 0.919946908950806f, 0.271375387907028f, 0.920154929161072f, 0.271053224802017f, - 0.920362710952759f, 0.270730882883072f, 0.920570194721222f, 0.270408391952515f, - 0.920777499675751f, 0.270085722208023f, 0.920984506607056f, 0.269762933254242f, - 0.921191275119781f, 0.269439965486526f, 0.921397805213928f, 0.269116818904877f, - 0.921604096889496f, 0.268793523311615f, 0.921810150146484f, 0.268470078706741f, - 0.922015964984894f, 0.268146485090256f, 0.922221481800079f, 0.267822742462158f, - 0.922426760196686f, 0.267498821020126f, 0.922631800174713f, 0.267174720764160f, - 0.922836601734161f, 0.266850501298904f, 0.923041164875031f, 0.266526103019714f, - 0.923245489597321f, 0.266201555728912f, 0.923449516296387f, 0.265876859426498f, - 0.923653304576874f, 0.265552014112473f, 0.923856854438782f, 0.265226989984512f, - 0.924060165882111f, 0.264901816844940f, 0.924263238906860f, 0.264576494693756f, - 0.924466013908386f, 0.264250993728638f, 0.924668610095978f, 0.263925373554230f, - 0.924870908260345f, 0.263599574565887f, 0.925072908401489f, 0.263273626565933f, - 0.925274729728699f, 0.262947499752045f, 0.925476312637329f, 0.262621253728867f, - 0.925677597522736f, 0.262294828891754f, 0.925878643989563f, 0.261968284845352f, - 0.926079452037811f, 0.261641561985016f, 0.926280021667480f, 0.261314690113068f, - 0.926480293273926f, 0.260987639427185f, 0.926680326461792f, 0.260660469532013f, - 0.926880121231079f, 0.260333120822906f, 0.927079677581787f, 0.260005623102188f, - 0.927278995513916f, 0.259678006172180f, 0.927478015422821f, 0.259350210428238f, - 0.927676856517792f, 0.259022265672684f, 0.927875399589539f, 0.258694142103195f, - 0.928073644638062f, 0.258365899324417f, 0.928271710872650f, 0.258037507534027f, - 0.928469479084015f, 0.257708936929703f, 0.928667008876801f, 0.257380217313766f, - 0.928864300251007f, 0.257051378488541f, 0.929061353206635f, 0.256722360849380f, - 0.929258108139038f, 0.256393194198608f, 0.929454624652863f, 0.256063878536224f, - 0.929650902748108f, 0.255734413862228f, 0.929846942424774f, 0.255404800176620f, - 0.930042684078217f, 0.255075037479401f, 0.930238187313080f, 0.254745125770569f, - 0.930433452129364f, 0.254415065050125f, 0.930628478527069f, 0.254084855318069f, - 0.930823206901550f, 0.253754496574402f, 0.931017756462097f, 0.253423988819122f, - 0.931211948394775f, 0.253093332052231f, 0.931405961513519f, 0.252762526273727f, - 0.931599736213684f, 0.252431541681290f, 0.931793212890625f, 0.252100437879562f, - 0.931986451148987f, 0.251769185066223f, 0.932179391384125f, 0.251437783241272f, - 0.932372152805328f, 0.251106232404709f, 0.932564616203308f, 0.250774532556534f, - 0.932756841182709f, 0.250442683696747f, 0.932948768138886f, 0.250110685825348f, - 0.933140456676483f, 0.249778553843498f, 0.933331906795502f, 0.249446272850037f, - 0.933523118495941f, 0.249113827943802f, 0.933714091777802f, 0.248781248927116f, - 0.933904767036438f, 0.248448520898819f, 0.934095203876495f, 0.248115643858910f, - 0.934285342693329f, 0.247782632708550f, 0.934475243091583f, 0.247449472546577f, - 0.934664964675903f, 0.247116148471832f, 0.934854328632355f, 0.246782705187798f, - 0.935043513774872f, 0.246449097990990f, 0.935232400894165f, 0.246115356683731f, - 0.935421049594879f, 0.245781451463699f, 0.935609400272369f, 0.245447427034378f, - 0.935797572135925f, 0.245113238692284f, 0.935985386371613f, 0.244778916239738f, - 0.936173021793365f, 0.244444444775581f, 0.936360359191895f, 0.244109839200974f, - 0.936547517776489f, 0.243775084614754f, 0.936734318733215f, 0.243440181016922f, - 0.936920940876007f, 0.243105143308640f, 0.937107264995575f, 0.242769956588745f, - 0.937293350696564f, 0.242434620857239f, 0.937479138374329f, 0.242099151015282f, - 0.937664687633514f, 0.241763532161713f, 0.937849998474121f, 0.241427779197693f, - 0.938035070896149f, 0.241091892123222f, 0.938219845294952f, 0.240755841135979f, - 0.938404381275177f, 0.240419670939446f, 0.938588619232178f, 0.240083336830139f, - 0.938772618770599f, 0.239746883511543f, 0.938956379890442f, 0.239410281181335f, - 0.939139902591705f, 0.239073529839516f, 0.939323127269745f, 0.238736644387245f, - 0.939506113529205f, 0.238399609923363f, 0.939688861370087f, 0.238062441349030f, - 0.939871311187744f, 0.237725138664246f, 0.940053522586823f, 0.237387686967850f, - 0.940235435962677f, 0.237050101161003f, 0.940417110919952f, 0.236712381243706f, - 0.940598547458649f, 0.236374512314796f, 0.940779745578766f, 0.236036509275436f, - 0.940960645675659f, 0.235698372125626f, 0.941141307353973f, 0.235360085964203f, - 0.941321671009064f, 0.235021665692329f, 0.941501796245575f, 0.234683111310005f, - 0.941681683063507f, 0.234344407916069f, 0.941861271858215f, 0.234005570411682f, - 0.942040622234344f, 0.233666598796844f, 0.942219734191895f, 0.233327493071556f, - 0.942398548126221f, 0.232988253235817f, 0.942577123641968f, 0.232648864388466f, - 0.942755401134491f, 0.232309341430664f, 0.942933499813080f, 0.231969684362412f, - 0.943111240863800f, 0.231629893183708f, 0.943288803100586f, 0.231289967894554f, - 0.943466067314148f, 0.230949893593788f, 0.943643093109131f, 0.230609700083733f, - 0.943819820880890f, 0.230269357562065f, 0.943996310234070f, 0.229928880929947f, - 0.944172501564026f, 0.229588270187378f, 0.944348454475403f, 0.229247525334358f, - 0.944524168968201f, 0.228906646370888f, 0.944699645042419f, 0.228565633296967f, - 0.944874763488770f, 0.228224486112595f, 0.945049703121185f, 0.227883204817772f, - 0.945224344730377f, 0.227541789412498f, 0.945398747920990f, 0.227200239896774f, - 0.945572853088379f, 0.226858556270599f, 0.945746779441834f, 0.226516738533974f, - 0.945920348167419f, 0.226174786686897f, 0.946093678474426f, 0.225832715630531f, - 0.946266770362854f, 0.225490495562553f, 0.946439623832703f, 0.225148141384125f, - 0.946612179279327f, 0.224805667996407f, 0.946784436702728f, 0.224463045597076f, - 0.946956455707550f, 0.224120303988457f, 0.947128236293793f, 0.223777428269386f, - 0.947299718856812f, 0.223434418439865f, 0.947470963001251f, 0.223091274499893f, - 0.947641968727112f, 0.222748011350632f, 0.947812676429749f, 0.222404599189758f, - 0.947983145713806f, 0.222061067819595f, 0.948153316974640f, 0.221717402338982f, - 0.948323249816895f, 0.221373617649078f, 0.948492884635925f, 0.221029683947563f, - 0.948662281036377f, 0.220685631036758f, 0.948831439018250f, 0.220341444015503f, - 0.949000298976898f, 0.219997137784958f, 0.949168920516968f, 0.219652697443962f, - 0.949337244033813f, 0.219308122992516f, 0.949505329132080f, 0.218963414430618f, - 0.949673116207123f, 0.218618586659431f, 0.949840664863586f, 0.218273624777794f, - 0.950007975101471f, 0.217928543686867f, 0.950174987316132f, 0.217583328485489f, - 0.950341701507568f, 0.217237979173660f, 0.950508177280426f, 0.216892510652542f, - 0.950674414634705f, 0.216546908020973f, 0.950840353965759f, 0.216201186180115f, - 0.951006054878235f, 0.215855330228806f, 0.951171517372131f, 0.215509355068207f, - 0.951336681842804f, 0.215163245797157f, 0.951501548290253f, 0.214817002415657f, - 0.951666176319122f, 0.214470639824867f, 0.951830565929413f, 0.214124158024788f, - 0.951994657516479f, 0.213777542114258f, 0.952158451080322f, 0.213430806994438f, - 0.952322065830231f, 0.213083937764168f, 0.952485322952271f, 0.212736949324608f, - 0.952648401260376f, 0.212389841675758f, 0.952811121940613f, 0.212042599916458f, - 0.952973663806915f, 0.211695238947868f, 0.953135907649994f, 0.211347743868828f, - 0.953297853469849f, 0.211000129580498f, 0.953459560871124f, 0.210652396082878f, - 0.953620970249176f, 0.210304543375969f, 0.953782141208649f, 0.209956556558609f, - 0.953943073749542f, 0.209608450531960f, 0.954103708267212f, 0.209260210394859f, - 0.954264044761658f, 0.208911851048470f, 0.954424142837524f, 0.208563387393951f, - 0.954584002494812f, 0.208214774727821f, 0.954743564128876f, 0.207866057753563f, - 0.954902827739716f, 0.207517206668854f, 0.955061912536621f, 0.207168251276016f, - 0.955220639705658f, 0.206819161772728f, 0.955379128456116f, 0.206469938158989f, - 0.955537378787994f, 0.206120610237122f, 0.955695331096649f, 0.205771163105965f, - 0.955853044986725f, 0.205421581864357f, 0.956010460853577f, 0.205071896314621f, - 0.956167578697205f, 0.204722076654434f, 0.956324458122253f, 0.204372137784958f, - 0.956481099128723f, 0.204022079706192f, 0.956637442111969f, 0.203671902418137f, - 0.956793546676636f, 0.203321605920792f, 0.956949353218079f, 0.202971190214157f, - 0.957104861736298f, 0.202620655298233f, 0.957260131835938f, 0.202270001173019f, - 0.957415163516998f, 0.201919227838516f, 0.957569897174835f, 0.201568335294724f, - 0.957724332809448f, 0.201217323541641f, 0.957878530025482f, 0.200866192579269f, - 0.958032488822937f, 0.200514942407608f, 0.958186149597168f, 0.200163587927818f, - 0.958339512348175f, 0.199812099337578f, 0.958492636680603f, 0.199460506439209f, - 0.958645522594452f, 0.199108779430389f, 0.958798050880432f, 0.198756948113441f, - 0.958950400352478f, 0.198404997587204f, 0.959102451801300f, 0.198052927851677f, - 0.959254205226898f, 0.197700738906860f, 0.959405720233917f, 0.197348430752754f, - 0.959556937217712f, 0.196996018290520f, 0.959707856178284f, 0.196643486618996f, - 0.959858596324921f, 0.196290835738182f, 0.960008978843689f, 0.195938065648079f, - 0.960159122943878f, 0.195585191249847f, 0.960309028625488f, 0.195232197642326f, - 0.960458636283875f, 0.194879084825516f, 0.960607945919037f, 0.194525867700577f, - 0.960757017135620f, 0.194172516465187f, 0.960905790328979f, 0.193819075822830f, - 0.961054325103760f, 0.193465501070023f, 0.961202561855316f, 0.193111822009087f, - 0.961350560188293f, 0.192758023738861f, 0.961498260498047f, 0.192404121160507f, - 0.961645722389221f, 0.192050099372864f, 0.961792886257172f, 0.191695958375931f, - 0.961939752101898f, 0.191341713070869f, 0.962086379528046f, 0.190987363457680f, - 0.962232708930969f, 0.190632879734039f, 0.962378799915314f, 0.190278306603432f, - 0.962524592876434f, 0.189923599362373f, 0.962670147418976f, 0.189568802714348f, - 0.962815403938293f, 0.189213871955872f, 0.962960422039032f, 0.188858851790428f, - 0.963105142116547f, 0.188503712415695f, 0.963249564170837f, 0.188148453831673f, - 0.963393747806549f, 0.187793090939522f, 0.963537633419037f, 0.187437608838081f, - 0.963681280612946f, 0.187082037329674f, 0.963824629783630f, 0.186726331710815f, - 0.963967680931091f, 0.186370536684990f, 0.964110493659973f, 0.186014622449875f, - 0.964253067970276f, 0.185658603906631f, 0.964395284652710f, 0.185302466154099f, - 0.964537262916565f, 0.184946224093437f, 0.964679002761841f, 0.184589877724648f, - 0.964820444583893f, 0.184233412146568f, 0.964961588382721f, 0.183876842260361f, - 0.965102493762970f, 0.183520168066025f, 0.965243160724640f, 0.183163389563560f, - 0.965383470058441f, 0.182806491851807f, 0.965523540973663f, 0.182449504733086f, - 0.965663373470306f, 0.182092398405075f, 0.965802907943726f, 0.181735187768936f, - 0.965942144393921f, 0.181377857923508f, 0.966081082820892f, 0.181020438671112f, - 0.966219842433929f, 0.180662900209427f, 0.966358244419098f, 0.180305257439613f, - 0.966496407985687f, 0.179947525262833f, 0.966634273529053f, 0.179589673876762f, - 0.966771900653839f, 0.179231703281403f, 0.966909229755402f, 0.178873643279076f, - 0.967046260833740f, 0.178515478968620f, 0.967183053493500f, 0.178157210350037f, - 0.967319548130035f, 0.177798837423325f, 0.967455804347992f, 0.177440345287323f, - 0.967591762542725f, 0.177081763744354f, 0.967727422714233f, 0.176723077893257f, - 0.967862844467163f, 0.176364272832870f, 0.967997968196869f, 0.176005378365517f, - 0.968132853507996f, 0.175646379590034f, 0.968267440795898f, 0.175287276506424f, - 0.968401730060577f, 0.174928069114685f, 0.968535780906677f, 0.174568757414818f, - 0.968669533729553f, 0.174209341406822f, 0.968802988529205f, 0.173849821090698f, - 0.968936204910278f, 0.173490211367607f, 0.969069123268127f, 0.173130482435226f, - 0.969201743602753f, 0.172770664095879f, 0.969334125518799f, 0.172410741448402f, - 0.969466269016266f, 0.172050714492798f, 0.969598054885864f, 0.171690583229065f, - 0.969729602336884f, 0.171330362558365f, 0.969860911369324f, 0.170970037579536f, - 0.969991862773895f, 0.170609608292580f, 0.970122575759888f, 0.170249074697495f, - 0.970253050327301f, 0.169888436794281f, 0.970383226871490f, 0.169527709484100f, - 0.970513105392456f, 0.169166877865791f, 0.970642685890198f, 0.168805956840515f, - 0.970772027969360f, 0.168444931507111f, 0.970901072025299f, 0.168083801865578f, - 0.971029877662659f, 0.167722567915916f, 0.971158385276794f, 0.167361244559288f, - 0.971286594867706f, 0.166999831795692f, 0.971414566040039f, 0.166638299822807f, - 0.971542239189148f, 0.166276678442955f, 0.971669614315033f, 0.165914967656136f, - 0.971796751022339f, 0.165553152561188f, 0.971923589706421f, 0.165191248059273f, - 0.972050130367279f, 0.164829224348068f, 0.972176432609558f, 0.164467126131058f, - 0.972302436828613f, 0.164104923605919f, 0.972428143024445f, 0.163742616772652f, - 0.972553610801697f, 0.163380220532417f, 0.972678780555725f, 0.163017734885216f, - 0.972803652286530f, 0.162655144929886f, 0.972928285598755f, 0.162292465567589f, - 0.973052620887756f, 0.161929681897163f, 0.973176658153534f, 0.161566808819771f, - 0.973300457000732f, 0.161203846335411f, 0.973423957824707f, 0.160840779542923f, - 0.973547160625458f, 0.160477623343468f, 0.973670125007629f, 0.160114362835884f, - 0.973792791366577f, 0.159751012921333f, 0.973915159702301f, 0.159387573599815f, - 0.974037289619446f, 0.159024044871330f, 0.974159121513367f, 0.158660411834717f, - 0.974280655384064f, 0.158296689391136f, 0.974401950836182f, 0.157932877540588f, - 0.974522948265076f, 0.157568961381912f, 0.974643647670746f, 0.157204970717430f, - 0.974764108657837f, 0.156840875744820f, 0.974884271621704f, 0.156476691365242f, - 0.975004136562347f, 0.156112402677536f, 0.975123703479767f, 0.155748039484024f, - 0.975243031978607f, 0.155383571982384f, 0.975362062454224f, 0.155019029974937f, - 0.975480854511261f, 0.154654383659363f, 0.975599288940430f, 0.154289647936821f, - 0.975717484951019f, 0.153924822807312f, 0.975835442543030f, 0.153559908270836f, - 0.975953042507172f, 0.153194904327393f, 0.976070404052734f, 0.152829796075821f, - 0.976187527179718f, 0.152464613318443f, 0.976304292678833f, 0.152099341154099f, - 0.976420819759369f, 0.151733979582787f, 0.976537048816681f, 0.151368513703346f, - 0.976653039455414f, 0.151002973318100f, 0.976768672466278f, 0.150637343525887f, - 0.976884067058563f, 0.150271624326706f, 0.976999223232269f, 0.149905815720558f, - 0.977114021778107f, 0.149539917707443f, 0.977228581905365f, 0.149173930287361f, - 0.977342903614044f, 0.148807853460312f, 0.977456867694855f, 0.148441687226295f, - 0.977570593357086f, 0.148075446486473f, 0.977684020996094f, 0.147709101438522f, - 0.977797150611877f, 0.147342681884766f, 0.977910041809082f, 0.146976172924042f, - 0.978022634983063f, 0.146609574556351f, 0.978134930133820f, 0.146242901682854f, - 0.978246986865997f, 0.145876124501228f, 0.978358685970306f, 0.145509272813797f, - 0.978470146656036f, 0.145142331719399f, 0.978581368923187f, 0.144775316119194f, - 0.978692233562469f, 0.144408211112022f, 0.978802859783173f, 0.144041016697884f, - 0.978913187980652f, 0.143673732876778f, 0.979023277759552f, 0.143306359648705f, - 0.979133009910584f, 0.142938911914825f, 0.979242503643036f, 0.142571389675140f, - 0.979351758956909f, 0.142203763127327f, 0.979460656642914f, 0.141836062073708f, - 0.979569315910339f, 0.141468286514282f, 0.979677677154541f, 0.141100421547890f, - 0.979785740375519f, 0.140732467174530f, 0.979893565177917f, 0.140364438295364f, - 0.980001091957092f, 0.139996320009232f, 0.980108320713043f, 0.139628127217293f, - 0.980215251445770f, 0.139259845018387f, 0.980321943759918f, 0.138891488313675f, - 0.980428338050842f, 0.138523042201996f, 0.980534434318542f, 0.138154521584511f, - 0.980640232563019f, 0.137785911560059f, 0.980745792388916f, 0.137417227029800f, - 0.980851054191589f, 0.137048453092575f, 0.980956017971039f, 0.136679604649544f, - 0.981060683727264f, 0.136310681700706f, 0.981165111064911f, 0.135941669344902f, - 0.981269240379334f, 0.135572582483292f, 0.981373071670532f, 0.135203406214714f, - 0.981476604938507f, 0.134834155440331f, 0.981579899787903f, 0.134464830160141f, - 0.981682896614075f, 0.134095430374146f, 0.981785595417023f, 0.133725941181183f, - 0.981888055801392f, 0.133356377482414f, 0.981990158557892f, 0.132986739277840f, - 0.982092022895813f, 0.132617011666298f, 0.982193589210510f, 0.132247209548950f, - 0.982294917106628f, 0.131877332925797f, 0.982395887374878f, 0.131507381796837f, - 0.982496619224548f, 0.131137356162071f, 0.982597053050995f, 0.130767241120338f, - 0.982697248458862f, 0.130397051572800f, 0.982797086238861f, 0.130026802420616f, - 0.982896685600281f, 0.129656463861465f, 0.982995986938477f, 0.129286035895348f, - 0.983094990253448f, 0.128915548324585f, 0.983193755149841f, 0.128544986248016f, - 0.983292162418365f, 0.128174334764481f, 0.983390331268311f, 0.127803623676300f, - 0.983488261699677f, 0.127432823181152f, 0.983585834503174f, 0.127061963081360f, - 0.983683168888092f, 0.126691013574600f, 0.983780145645142f, 0.126320004463196f, - 0.983876943588257f, 0.125948905944824f, 0.983973383903503f, 0.125577747821808f, - 0.984069526195526f, 0.125206500291824f, 0.984165430068970f, 0.124835193157196f, - 0.984261035919189f, 0.124463804066181f, 0.984356343746185f, 0.124092340469360f, - 0.984451413154602f, 0.123720809817314f, 0.984546124935150f, 0.123349204659462f, - 0.984640598297119f, 0.122977524995804f, 0.984734773635864f, 0.122605770826340f, - 0.984828710556030f, 0.122233949601650f, 0.984922289848328f, 0.121862053871155f, - 0.985015630722046f, 0.121490091085434f, 0.985108673572540f, 0.121118053793907f, - 0.985201418399811f, 0.120745941996574f, 0.985293865203857f, 0.120373763144016f, - 0.985386073589325f, 0.120001509785652f, 0.985477983951569f, 0.119629189372063f, - 0.985569596290588f, 0.119256794452667f, 0.985660910606384f, 0.118884332478046f, - 0.985751926898956f, 0.118511803448200f, 0.985842704772949f, 0.118139199912548f, - 0.985933184623718f, 0.117766529321671f, 0.986023366451263f, 0.117393791675568f, - 0.986113250255585f, 0.117020979523659f, 0.986202836036682f, 0.116648100316525f, - 0.986292183399200f, 0.116275154054165f, 0.986381232738495f, 0.115902140736580f, - 0.986469984054565f, 0.115529052913189f, 0.986558437347412f, 0.115155905485153f, - 0.986646652221680f, 0.114782683551311f, 0.986734509468079f, 0.114409394562244f, - 0.986822128295898f, 0.114036038517952f, 0.986909449100494f, 0.113662622869015f, - 0.986996471881866f, 0.113289132714272f, 0.987083256244659f, 0.112915575504303f, - 0.987169682979584f, 0.112541958689690f, 0.987255871295929f, 0.112168267369270f, - 0.987341761589050f, 0.111794516444206f, 0.987427353858948f, 0.111420698463917f, - 0.987512648105621f, 0.111046813428402f, 0.987597703933716f, 0.110672861337662f, - 0.987682461738586f, 0.110298842191696f, 0.987766921520233f, 0.109924763441086f, - 0.987851083278656f, 0.109550617635250f, 0.987934947013855f, 0.109176412224770f, - 0.988018512725830f, 0.108802139759064f, 0.988101840019226f, 0.108427800238132f, - 0.988184869289398f, 0.108053401112556f, 0.988267600536346f, 0.107678934931755f, - 0.988350033760071f, 0.107304409146309f, 0.988432228565216f, 0.106929816305637f, - 0.988514065742493f, 0.106555156409740f, 0.988595664501190f, 0.106180444359779f, - 0.988676965236664f, 0.105805665254593f, 0.988757967948914f, 0.105430819094181f, - 0.988838672637939f, 0.105055920779705f, 0.988919138908386f, 0.104680955410004f, - 0.988999247550964f, 0.104305922985077f, 0.989079117774963f, 0.103930838406086f, - 0.989158689975739f, 0.103555686771870f, 0.989237964153290f, 0.103180475533009f, - 0.989316940307617f, 0.102805204689503f, 0.989395678043365f, 0.102429874241352f, - 0.989474058151245f, 0.102054484188557f, 0.989552199840546f, 0.101679034531116f, - 0.989630043506622f, 0.101303517818451f, 0.989707589149475f, 0.100927948951721f, - 0.989784896373749f, 0.100552320480347f, 0.989861845970154f, 0.100176624953747f, - 0.989938557147980f, 0.099800877273083f, 0.990014970302582f, 0.099425069987774f, - 0.990091085433960f, 0.099049203097820f, 0.990166902542114f, 0.098673284053802f, - 0.990242421627045f, 0.098297297954559f, 0.990317702293396f, 0.097921259701252f, - 0.990392625331879f, 0.097545161843300f, 0.990467309951782f, 0.097169004380703f, - 0.990541696548462f, 0.096792794764042f, 0.990615785121918f, 0.096416525542736f, - 0.990689575672150f, 0.096040196716785f, 0.990763127803802f, 0.095663815736771f, - 0.990836322307587f, 0.095287375152111f, 0.990909278392792f, 0.094910882413387f, - 0.990981936454773f, 0.094534330070019f, 0.991054296493530f, 0.094157725572586f, - 0.991126358509064f, 0.093781061470509f, 0.991198182106018f, 0.093404345214367f, - 0.991269648075104f, 0.093027576804161f, 0.991340875625610f, 0.092650748789310f, - 0.991411805152893f, 0.092273868620396f, 0.991482377052307f, 0.091896936297417f, - 0.991552770137787f, 0.091519944369793f, 0.991622805595398f, 0.091142900288105f, - 0.991692543029785f, 0.090765804052353f, 0.991762042045593f, 0.090388655662537f, - 0.991831183433533f, 0.090011447668076f, 0.991900086402893f, 0.089634194970131f, - 0.991968691349030f, 0.089256882667542f, 0.992036998271942f, 0.088879525661469f, - 0.992105066776276f, 0.088502109050751f, 0.992172777652740f, 0.088124647736549f, - 0.992240250110626f, 0.087747126817703f, 0.992307364940643f, 0.087369553744793f, - 0.992374241352081f, 0.086991935968399f, 0.992440819740295f, 0.086614266037941f, - 0.992507100105286f, 0.086236543953419f, 0.992573142051697f, 0.085858769714832f, - 0.992638826370239f, 0.085480943322182f, 0.992704212665558f, 0.085103072226048f, - 0.992769360542297f, 0.084725148975849f, 0.992834210395813f, 0.084347173571587f, - 0.992898762226105f, 0.083969146013260f, 0.992963016033173f, 0.083591073751450f, - 0.993026971817017f, 0.083212949335575f, 0.993090689182281f, 0.082834780216217f, - 0.993154048919678f, 0.082456558942795f, 0.993217170238495f, 0.082078292965889f, - 0.993279933929443f, 0.081699974834919f, 0.993342459201813f, 0.081321612000465f, - 0.993404686450958f, 0.080943197011948f, 0.993466615676880f, 0.080564737319946f, - 0.993528306484222f, 0.080186225473881f, 0.993589639663696f, 0.079807676374912f, - 0.993650734424591f, 0.079429075121880f, 0.993711471557617f, 0.079050421714783f, - 0.993771970272064f, 0.078671731054783f, 0.993832170963287f, 0.078292988240719f, - 0.993892073631287f, 0.077914200723171f, 0.993951678276062f, 0.077535368502140f, - 0.994010984897614f, 0.077156484127045f, 0.994070053100586f, 0.076777562499046f, - 0.994128763675690f, 0.076398596167564f, 0.994187235832214f, 0.076019577682018f, - 0.994245409965515f, 0.075640521943569f, 0.994303286075592f, 0.075261414051056f, - 0.994360864162445f, 0.074882268905640f, 0.994418144226074f, 0.074503071606159f, - 0.994475126266479f, 0.074123837053776f, 0.994531810283661f, 0.073744557797909f, - 0.994588255882263f, 0.073365233838558f, 0.994644403457642f, 0.072985872626305f, - 0.994700193405151f, 0.072606459259987f, 0.994755744934082f, 0.072227008640766f, - 0.994810998439789f, 0.071847513318062f, 0.994865953922272f, 0.071467980742455f, - 0.994920611381531f, 0.071088403463364f, 0.994975030422211f, 0.070708781480789f, - 0.995029091835022f, 0.070329122245312f, 0.995082914829254f, 0.069949418306351f, - 0.995136380195618f, 0.069569669663906f, 0.995189607143402f, 0.069189883768559f, - 0.995242536067963f, 0.068810060620308f, 0.995295166969299f, 0.068430192768574f, - 0.995347499847412f, 0.068050287663937f, 0.995399534702301f, 0.067670337855816f, - 0.995451331138611f, 0.067290350794792f, 0.995502769947052f, 0.066910326480865f, - 0.995553970336914f, 0.066530264914036f, 0.995604813098907f, 0.066150158643723f, - 0.995655417442322f, 0.065770015120506f, 0.995705723762512f, 0.065389834344387f, - 0.995755732059479f, 0.065009608864784f, 0.995805442333221f, 0.064629353582859f, - 0.995854854583740f, 0.064249053597450f, 0.995904028415680f, 0.063868723809719f, - 0.995952844619751f, 0.063488349318504f, 0.996001422405243f, 0.063107937574387f, - 0.996049642562866f, 0.062727488577366f, 0.996097624301910f, 0.062347009778023f, - 0.996145308017731f, 0.061966486275196f, 0.996192693710327f, 0.061585929244757f, - 0.996239781379700f, 0.061205338686705f, 0.996286571025848f, 0.060824707150459f, - 0.996333062648773f, 0.060444042086601f, 0.996379256248474f, 0.060063343495131f, - 0.996425211429596f, 0.059682607650757f, 0.996470808982849f, 0.059301838278770f, - 0.996516168117523f, 0.058921031653881f, 0.996561229228973f, 0.058540191501379f, - 0.996605992317200f, 0.058159314095974f, 0.996650457382202f, 0.057778406888247f, - 0.996694624423981f, 0.057397462427616f, 0.996738493442535f, 0.057016488164663f, - 0.996782064437866f, 0.056635476648808f, 0.996825337409973f, 0.056254431605339f, - 0.996868371963501f, 0.055873356759548f, 0.996911048889160f, 0.055492244660854f, - 0.996953487396240f, 0.055111102759838f, 0.996995627880096f, 0.054729927331209f, - 0.997037410736084f, 0.054348722100258f, 0.997078955173492f, 0.053967483341694f, - 0.997120201587677f, 0.053586211055517f, 0.997161149978638f, 0.053204908967018f, - 0.997201859951019f, 0.052823577076197f, 0.997242212295532f, 0.052442211657763f, - 0.997282266616821f, 0.052060816437006f, 0.997322082519531f, 0.051679391413927f, - 0.997361540794373f, 0.051297932863235f, 0.997400760650635f, 0.050916448235512f, - 0.997439682483673f, 0.050534930080175f, 0.997478306293488f, 0.050153385847807f, - 0.997516572475433f, 0.049771808087826f, 0.997554600238800f, 0.049390204250813f, - 0.997592389583588f, 0.049008570611477f, 0.997629821300507f, 0.048626907169819f, - 0.997666954994202f, 0.048245213925838f, 0.997703790664673f, 0.047863494604826f, - 0.997740387916565f, 0.047481749206781f, 0.997776627540588f, 0.047099970281124f, - 0.997812628746033f, 0.046718169003725f, 0.997848331928253f, 0.046336337924004f, - 0.997883677482605f, 0.045954477041960f, 0.997918784618378f, 0.045572593808174f, - 0.997953593730927f, 0.045190680772066f, 0.997988104820251f, 0.044808741658926f, - 0.998022377490997f, 0.044426776468754f, 0.998056292533875f, 0.044044785201550f, - 0.998089909553528f, 0.043662767857313f, 0.998123228549957f, 0.043280724436045f, - 0.998156309127808f, 0.042898654937744f, 0.998189091682434f, 0.042516563087702f, - 0.998221516609192f, 0.042134445160627f, 0.998253703117371f, 0.041752301156521f, - 0.998285591602325f, 0.041370131075382f, 0.998317182064056f, 0.040987938642502f, - 0.998348474502563f, 0.040605723857880f, 0.998379468917847f, 0.040223482996225f, - 0.998410165309906f, 0.039841219782829f, 0.998440563678741f, 0.039458930492401f, - 0.998470664024353f, 0.039076622575521f, 0.998500525951386f, 0.038694288581610f, - 0.998530030250549f, 0.038311932235956f, 0.998559296131134f, 0.037929553538561f, - 0.998588204383850f, 0.037547148764133f, 0.998616874217987f, 0.037164725363255f, - 0.998645246028900f, 0.036782283335924f, 0.998673319816589f, 0.036399815231562f, - 0.998701035976410f, 0.036017324775457f, 0.998728513717651f, 0.035634815692902f, - 0.998755753040314f, 0.035252287983894f, 0.998782634735107f, 0.034869734197855f, - 0.998809218406677f, 0.034487165510654f, 0.998835504055023f, 0.034104570746422f, - 0.998861551284790f, 0.033721961081028f, 0.998887240886688f, 0.033339329063892f, - 0.998912692070007f, 0.032956674695015f, 0.998937785625458f, 0.032574005424976f, - 0.998962640762329f, 0.032191313803196f, 0.998987197875977f, 0.031808607280254f, - 0.999011456966400f, 0.031425878405571f, 0.999035418033600f, 0.031043132767081f, - 0.999059081077576f, 0.030660368502140f, 0.999082446098328f, 0.030277585610747f, - 0.999105513095856f, 0.029894785955548f, 0.999128282070160f, 0.029511967673898f, - 0.999150753021240f, 0.029129132628441f, 0.999172985553741f, 0.028746278956532f, - 0.999194860458374f, 0.028363410383463f, 0.999216496944427f, 0.027980525046587f, - 0.999237775802612f, 0.027597622945905f, 0.999258816242218f, 0.027214704081416f, - 0.999279558658600f, 0.026831768453121f, 0.999299943447113f, 0.026448817923665f, - 0.999320089817047f, 0.026065852493048f, 0.999339938163757f, 0.025682870298624f, - 0.999359488487244f, 0.025299875065684f, 0.999378740787506f, 0.024916863068938f, - 0.999397754669189f, 0.024533838033676f, 0.999416410923004f, 0.024150796234608f, - 0.999434769153595f, 0.023767741397023f, 0.999452829360962f, 0.023384673520923f, - 0.999470651149750f, 0.023001590743661f, 0.999488115310669f, 0.022618494927883f, - 0.999505341053009f, 0.022235386073589f, 0.999522268772125f, 0.021852264180779f, - 0.999538838863373f, 0.021469129249454f, 0.999555170536041f, 0.021085981279612f, - 0.999571204185486f, 0.020702820271254f, 0.999586939811707f, 0.020319648087025f, - 0.999602377414703f, 0.019936462864280f, 0.999617516994476f, 0.019553268328309f, - 0.999632358551025f, 0.019170060753822f, 0.999646902084351f, 0.018786842003465f, - 0.999661207199097f, 0.018403612077236f, 0.999675154685974f, 0.018020370975137f, - 0.999688863754272f, 0.017637118697166f, 0.999702215194702f, 0.017253857105970f, - 0.999715328216553f, 0.016870586201549f, 0.999728083610535f, 0.016487304121256f, - 0.999740600585938f, 0.016104012727737f, 0.999752819538116f, 0.015720712020993f, - 0.999764680862427f, 0.015337402001023f, 0.999776303768158f, 0.014954082667828f, - 0.999787628650665f, 0.014570754021406f, 0.999798655509949f, 0.014187417924404f, - 0.999809384346008f, 0.013804072514176f, 0.999819874763489f, 0.013420719653368f, - 0.999830007553101f, 0.013037359341979f, 0.999839842319489f, 0.012653990648687f, - 0.999849438667297f, 0.012270614504814f, 0.999858677387238f, 0.011887230910361f, - 0.999867618083954f, 0.011503840796649f, 0.999876320362091f, 0.011120444163680f, - 0.999884724617004f, 0.010737040080130f, 0.999892771244049f, 0.010353630408645f, - 0.999900579452515f, 0.009970214217901f, 0.999908089637756f, 0.009586792439222f, - 0.999915301799774f, 0.009203365072608f, 0.999922215938568f, 0.008819932118058f, - 0.999928832054138f, 0.008436493575573f, 0.999935150146484f, 0.008053051307797f, - 0.999941170215607f, 0.007669602986425f, 0.999946892261505f, 0.007286150939763f, - 0.999952375888824f, 0.006902694236487f, 0.999957501888275f, 0.006519233807921f, - 0.999962329864502f, 0.006135769188404f, 0.999966919422150f, 0.005752300843596f, - 0.999971151351929f, 0.005368829704821f, 0.999975144863129f, 0.004985354840755f, - 0.999978840351105f, 0.004601877182722f, 0.999982178211212f, 0.004218397196382f, - 0.999985277652740f, 0.003834914416075f, 0.999988079071045f, 0.003451429307461f, - 0.999990582466125f, 0.003067942336202f, 0.999992787837982f, 0.002684453502297f, - 0.999994695186615f, 0.002300963038579f, 0.999996304512024f, 0.001917471294291f, - 0.999997675418854f, 0.001533978385851f, 0.999998688697815f, 0.001150484546088f, - 0.999999403953552f, 0.000766990066040f, 0.999999880790710f, 0.000383495149435f, - 1.000000000000000f, 0.000000000000023f, 0.999999880790710f, -0.000383495149435f, - 0.999999403953552f, -0.000766990066040f, 0.999998688697815f, -0.001150484546088f, - 0.999997675418854f, -0.001533978385851f, 0.999996304512024f, -0.001917471294291f, - 0.999994695186615f, -0.002300963038579f, 0.999992787837982f, -0.002684453502297f, - 0.999990582466125f, -0.003067942336202f, 0.999988079071045f, -0.003451429307461f, - 0.999985277652740f, -0.003834914416075f, 0.999982178211212f, -0.004218397196382f, - 0.999978840351105f, -0.004601877182722f, 0.999975144863129f, -0.004985354840755f, - 0.999971151351929f, -0.005368829704821f, 0.999966919422150f, -0.005752300843596f, - 0.999962329864502f, -0.006135769188404f, 0.999957501888275f, -0.006519233807921f, - 0.999952375888824f, -0.006902694236487f, 0.999946892261505f, -0.007286150939763f, - 0.999941170215607f, -0.007669602986425f, 0.999935150146484f, -0.008053051307797f, - 0.999928832054138f, -0.008436493575573f, 0.999922215938568f, -0.008819932118058f, - 0.999915301799774f, -0.009203365072608f, 0.999908089637756f, -0.009586792439222f, - 0.999900579452515f, -0.009970214217901f, 0.999892771244049f, -0.010353630408645f, - 0.999884724617004f, -0.010737040080130f, 0.999876320362091f, -0.011120444163680f, - 0.999867618083954f, -0.011503840796649f, 0.999858677387238f, -0.011887230910361f, - 0.999849438667297f, -0.012270614504814f, 0.999839842319489f, -0.012653990648687f, - 0.999830007553101f, -0.013037359341979f, 0.999819874763489f, -0.013420719653368f, - 0.999809384346008f, -0.013804072514176f, 0.999798655509949f, -0.014187417924404f, - 0.999787628650665f, -0.014570754021406f, 0.999776303768158f, -0.014954082667828f, - 0.999764680862427f, -0.015337402001023f, 0.999752819538116f, -0.015720712020993f, - 0.999740600585938f, -0.016104012727737f, 0.999728083610535f, -0.016487304121256f, - 0.999715328216553f, -0.016870586201549f, 0.999702215194702f, -0.017253857105970f, - 0.999688863754272f, -0.017637118697166f, 0.999675154685974f, -0.018020370975137f, - 0.999661207199097f, -0.018403612077236f, 0.999646902084351f, -0.018786842003465f, - 0.999632358551025f, -0.019170060753822f, 0.999617516994476f, -0.019553268328309f, - 0.999602377414703f, -0.019936462864280f, 0.999586939811707f, -0.020319648087025f, - 0.999571204185486f, -0.020702820271254f, 0.999555170536041f, -0.021085981279612f, - 0.999538838863373f, -0.021469129249454f, 0.999522268772125f, -0.021852264180779f, - 0.999505341053009f, -0.022235386073589f, 0.999488115310669f, -0.022618494927883f, - 0.999470651149750f, -0.023001590743661f, 0.999452829360962f, -0.023384673520923f, - 0.999434769153595f, -0.023767741397023f, 0.999416410923004f, -0.024150796234608f, - 0.999397754669189f, -0.024533838033676f, 0.999378740787506f, -0.024916863068938f, - 0.999359488487244f, -0.025299875065684f, 0.999339938163757f, -0.025682870298624f, - 0.999320089817047f, -0.026065852493048f, 0.999299943447113f, -0.026448817923665f, - 0.999279558658600f, -0.026831768453121f, 0.999258816242218f, -0.027214704081416f, - 0.999237775802612f, -0.027597622945905f, 0.999216496944427f, -0.027980525046587f, - 0.999194860458374f, -0.028363410383463f, 0.999172985553741f, -0.028746278956532f, - 0.999150753021240f, -0.029129132628441f, 0.999128282070160f, -0.029511967673898f, - 0.999105513095856f, -0.029894785955548f, 0.999082446098328f, -0.030277585610747f, - 0.999059081077576f, -0.030660368502140f, 0.999035418033600f, -0.031043132767081f, - 0.999011456966400f, -0.031425878405571f, 0.998987197875977f, -0.031808607280254f, - 0.998962640762329f, -0.032191313803196f, 0.998937785625458f, -0.032574005424976f, - 0.998912692070007f, -0.032956674695015f, 0.998887240886688f, -0.033339329063892f, - 0.998861551284790f, -0.033721961081028f, 0.998835504055023f, -0.034104570746422f, - 0.998809218406677f, -0.034487165510654f, 0.998782634735107f, -0.034869734197855f, - 0.998755753040314f, -0.035252287983894f, 0.998728513717651f, -0.035634815692902f, - 0.998701035976410f, -0.036017324775457f, 0.998673319816589f, -0.036399815231562f, - 0.998645246028900f, -0.036782283335924f, 0.998616874217987f, -0.037164725363255f, - 0.998588204383850f, -0.037547148764133f, 0.998559296131134f, -0.037929553538561f, - 0.998530030250549f, -0.038311932235956f, 0.998500525951386f, -0.038694288581610f, - 0.998470664024353f, -0.039076622575521f, 0.998440563678741f, -0.039458930492401f, - 0.998410165309906f, -0.039841219782829f, 0.998379468917847f, -0.040223482996225f, - 0.998348474502563f, -0.040605723857880f, 0.998317182064056f, -0.040987938642502f, - 0.998285591602325f, -0.041370131075382f, 0.998253703117371f, -0.041752301156521f, - 0.998221516609192f, -0.042134445160627f, 0.998189091682434f, -0.042516563087702f, - 0.998156309127808f, -0.042898654937744f, 0.998123228549957f, -0.043280724436045f, - 0.998089909553528f, -0.043662767857313f, 0.998056292533875f, -0.044044785201550f, - 0.998022377490997f, -0.044426776468754f, 0.997988104820251f, -0.044808741658926f, - 0.997953593730927f, -0.045190680772066f, 0.997918784618378f, -0.045572593808174f, - 0.997883677482605f, -0.045954477041960f, 0.997848331928253f, -0.046336337924004f, - 0.997812628746033f, -0.046718169003725f, 0.997776627540588f, -0.047099970281124f, - 0.997740387916565f, -0.047481749206781f, 0.997703790664673f, -0.047863494604826f, - 0.997666954994202f, -0.048245213925838f, 0.997629821300507f, -0.048626907169819f, - 0.997592389583588f, -0.049008570611477f, 0.997554600238800f, -0.049390204250813f, - 0.997516572475433f, -0.049771808087826f, 0.997478306293488f, -0.050153385847807f, - 0.997439682483673f, -0.050534930080175f, 0.997400760650635f, -0.050916448235512f, - 0.997361540794373f, -0.051297932863235f, 0.997322082519531f, -0.051679391413927f, - 0.997282266616821f, -0.052060816437006f, 0.997242212295532f, -0.052442211657763f, - 0.997201859951019f, -0.052823577076197f, 0.997161149978638f, -0.053204908967018f, - 0.997120201587677f, -0.053586211055517f, 0.997078955173492f, -0.053967483341694f, - 0.997037410736084f, -0.054348722100258f, 0.996995627880096f, -0.054729927331209f, - 0.996953487396240f, -0.055111102759838f, 0.996911048889160f, -0.055492244660854f, - 0.996868371963501f, -0.055873356759548f, 0.996825337409973f, -0.056254431605339f, - 0.996782064437866f, -0.056635476648808f, 0.996738493442535f, -0.057016488164663f, - 0.996694624423981f, -0.057397462427616f, 0.996650457382202f, -0.057778406888247f, - 0.996605992317200f, -0.058159314095974f, 0.996561229228973f, -0.058540191501379f, - 0.996516168117523f, -0.058921031653881f, 0.996470808982849f, -0.059301838278770f, - 0.996425211429596f, -0.059682607650757f, 0.996379256248474f, -0.060063343495131f, - 0.996333062648773f, -0.060444042086601f, 0.996286571025848f, -0.060824707150459f, - 0.996239781379700f, -0.061205338686705f, 0.996192693710327f, -0.061585929244757f, - 0.996145308017731f, -0.061966486275196f, 0.996097624301910f, -0.062347009778023f, - 0.996049642562866f, -0.062727488577366f, 0.996001422405243f, -0.063107937574387f, - 0.995952844619751f, -0.063488349318504f, 0.995904028415680f, -0.063868723809719f, - 0.995854854583740f, -0.064249053597450f, 0.995805442333221f, -0.064629353582859f, - 0.995755732059479f, -0.065009608864784f, 0.995705723762512f, -0.065389834344387f, - 0.995655417442322f, -0.065770015120506f, 0.995604813098907f, -0.066150158643723f, - 0.995553970336914f, -0.066530264914036f, 0.995502769947052f, -0.066910326480865f, - 0.995451331138611f, -0.067290350794792f, 0.995399534702301f, -0.067670337855816f, - 0.995347499847412f, -0.068050287663937f, 0.995295166969299f, -0.068430192768574f, - 0.995242536067963f, -0.068810060620308f, 0.995189607143402f, -0.069189883768559f, - 0.995136380195618f, -0.069569669663906f, 0.995082914829254f, -0.069949418306351f, - 0.995029091835022f, -0.070329122245312f, 0.994975030422211f, -0.070708781480789f, - 0.994920611381531f, -0.071088403463364f, 0.994865953922272f, -0.071467980742455f, - 0.994810998439789f, -0.071847513318062f, 0.994755744934082f, -0.072227008640766f, - 0.994700193405151f, -0.072606459259987f, 0.994644403457642f, -0.072985872626305f, - 0.994588255882263f, -0.073365233838558f, 0.994531810283661f, -0.073744557797909f, - 0.994475126266479f, -0.074123837053776f, 0.994418144226074f, -0.074503071606159f, - 0.994360864162445f, -0.074882268905640f, 0.994303286075592f, -0.075261414051056f, - 0.994245409965515f, -0.075640521943569f, 0.994187235832214f, -0.076019577682018f, - 0.994128763675690f, -0.076398596167564f, 0.994070053100586f, -0.076777562499046f, - 0.994010984897614f, -0.077156484127045f, 0.993951678276062f, -0.077535368502140f, - 0.993892073631287f, -0.077914200723171f, 0.993832170963287f, -0.078292988240719f, - 0.993771970272064f, -0.078671731054783f, 0.993711471557617f, -0.079050421714783f, - 0.993650734424591f, -0.079429075121880f, 0.993589639663696f, -0.079807676374912f, - 0.993528306484222f, -0.080186225473881f, 0.993466615676880f, -0.080564737319946f, - 0.993404686450958f, -0.080943197011948f, 0.993342459201813f, -0.081321612000465f, - 0.993279933929443f, -0.081699974834919f, 0.993217170238495f, -0.082078292965889f, - 0.993154048919678f, -0.082456558942795f, 0.993090689182281f, -0.082834780216217f, - 0.993026971817017f, -0.083212949335575f, 0.992963016033173f, -0.083591073751450f, - 0.992898762226105f, -0.083969146013260f, 0.992834210395813f, -0.084347173571587f, - 0.992769360542297f, -0.084725148975849f, 0.992704212665558f, -0.085103072226048f, - 0.992638826370239f, -0.085480943322182f, 0.992573142051697f, -0.085858769714832f, - 0.992507100105286f, -0.086236543953419f, 0.992440819740295f, -0.086614266037941f, - 0.992374241352081f, -0.086991935968399f, 0.992307364940643f, -0.087369553744793f, - 0.992240250110626f, -0.087747126817703f, 0.992172777652740f, -0.088124647736549f, - 0.992105066776276f, -0.088502109050751f, 0.992036998271942f, -0.088879525661469f, - 0.991968691349030f, -0.089256882667542f, 0.991900086402893f, -0.089634194970131f, - 0.991831183433533f, -0.090011447668076f, 0.991762042045593f, -0.090388655662537f, - 0.991692543029785f, -0.090765804052353f, 0.991622805595398f, -0.091142900288105f, - 0.991552770137787f, -0.091519944369793f, 0.991482377052307f, -0.091896936297417f, - 0.991411805152893f, -0.092273868620396f, 0.991340875625610f, -0.092650748789310f, - 0.991269648075104f, -0.093027576804161f, 0.991198182106018f, -0.093404345214367f, - 0.991126358509064f, -0.093781061470509f, 0.991054296493530f, -0.094157725572586f, - 0.990981936454773f, -0.094534330070019f, 0.990909278392792f, -0.094910882413387f, - 0.990836322307587f, -0.095287375152111f, 0.990763127803802f, -0.095663815736771f, - 0.990689575672150f, -0.096040196716785f, 0.990615785121918f, -0.096416525542736f, - 0.990541696548462f, -0.096792794764042f, 0.990467309951782f, -0.097169004380703f, - 0.990392625331879f, -0.097545161843300f, 0.990317702293396f, -0.097921259701252f, - 0.990242421627045f, -0.098297297954559f, 0.990166902542114f, -0.098673284053802f, - 0.990091085433960f, -0.099049203097820f, 0.990014970302582f, -0.099425069987774f, - 0.989938557147980f, -0.099800877273083f, 0.989861845970154f, -0.100176624953747f, - 0.989784896373749f, -0.100552320480347f, 0.989707589149475f, -0.100927948951721f, - 0.989630043506622f, -0.101303517818451f, 0.989552199840546f, -0.101679034531116f, - 0.989474058151245f, -0.102054484188557f, 0.989395678043365f, -0.102429874241352f, - 0.989316940307617f, -0.102805204689503f, 0.989237964153290f, -0.103180475533009f, - 0.989158689975739f, -0.103555686771870f, 0.989079117774963f, -0.103930838406086f, - 0.988999247550964f, -0.104305922985077f, 0.988919138908386f, -0.104680955410004f, - 0.988838672637939f, -0.105055920779705f, 0.988757967948914f, -0.105430819094181f, - 0.988676965236664f, -0.105805665254593f, 0.988595664501190f, -0.106180444359779f, - 0.988514065742493f, -0.106555156409740f, 0.988432228565216f, -0.106929816305637f, - 0.988350033760071f, -0.107304409146309f, 0.988267600536346f, -0.107678934931755f, - 0.988184869289398f, -0.108053401112556f, 0.988101840019226f, -0.108427800238132f, - 0.988018512725830f, -0.108802139759064f, 0.987934947013855f, -0.109176412224770f, - 0.987851083278656f, -0.109550617635250f, 0.987766921520233f, -0.109924763441086f, - 0.987682461738586f, -0.110298842191696f, 0.987597703933716f, -0.110672861337662f, - 0.987512648105621f, -0.111046813428402f, 0.987427353858948f, -0.111420698463917f, - 0.987341761589050f, -0.111794516444206f, 0.987255871295929f, -0.112168267369270f, - 0.987169682979584f, -0.112541958689690f, 0.987083256244659f, -0.112915575504303f, - 0.986996471881866f, -0.113289132714272f, 0.986909449100494f, -0.113662622869015f, - 0.986822128295898f, -0.114036038517952f, 0.986734509468079f, -0.114409394562244f, - 0.986646652221680f, -0.114782683551311f, 0.986558437347412f, -0.115155905485153f, - 0.986469984054565f, -0.115529052913189f, 0.986381232738495f, -0.115902140736580f, - 0.986292183399200f, -0.116275154054165f, 0.986202836036682f, -0.116648100316525f, - 0.986113250255585f, -0.117020979523659f, 0.986023366451263f, -0.117393791675568f, - 0.985933184623718f, -0.117766529321671f, 0.985842704772949f, -0.118139199912548f, - 0.985751926898956f, -0.118511803448200f, 0.985660910606384f, -0.118884332478046f, - 0.985569596290588f, -0.119256794452667f, 0.985477983951569f, -0.119629189372063f, - 0.985386073589325f, -0.120001509785652f, 0.985293865203857f, -0.120373763144016f, - 0.985201418399811f, -0.120745941996574f, 0.985108673572540f, -0.121118053793907f, - 0.985015630722046f, -0.121490091085434f, 0.984922289848328f, -0.121862053871155f, - 0.984828710556030f, -0.122233949601650f, 0.984734773635864f, -0.122605770826340f, - 0.984640598297119f, -0.122977524995804f, 0.984546124935150f, -0.123349204659462f, - 0.984451413154602f, -0.123720809817314f, 0.984356343746185f, -0.124092340469360f, - 0.984261035919189f, -0.124463804066181f, 0.984165430068970f, -0.124835193157196f, - 0.984069526195526f, -0.125206500291824f, 0.983973383903503f, -0.125577747821808f, - 0.983876943588257f, -0.125948905944824f, 0.983780145645142f, -0.126320004463196f, - 0.983683168888092f, -0.126691013574600f, 0.983585834503174f, -0.127061963081360f, - 0.983488261699677f, -0.127432823181152f, 0.983390331268311f, -0.127803623676300f, - 0.983292162418365f, -0.128174334764481f, 0.983193755149841f, -0.128544986248016f, - 0.983094990253448f, -0.128915548324585f, 0.982995986938477f, -0.129286035895348f, - 0.982896685600281f, -0.129656463861465f, 0.982797086238861f, -0.130026802420616f, - 0.982697248458862f, -0.130397051572800f, 0.982597053050995f, -0.130767241120338f, - 0.982496619224548f, -0.131137356162071f, 0.982395887374878f, -0.131507381796837f, - 0.982294917106628f, -0.131877332925797f, 0.982193589210510f, -0.132247209548950f, - 0.982092022895813f, -0.132617011666298f, 0.981990158557892f, -0.132986739277840f, - 0.981888055801392f, -0.133356377482414f, 0.981785595417023f, -0.133725941181183f, - 0.981682896614075f, -0.134095430374146f, 0.981579899787903f, -0.134464830160141f, - 0.981476604938507f, -0.134834155440331f, 0.981373071670532f, -0.135203406214714f, - 0.981269240379334f, -0.135572582483292f, 0.981165111064911f, -0.135941669344902f, - 0.981060683727264f, -0.136310681700706f, 0.980956017971039f, -0.136679604649544f, - 0.980851054191589f, -0.137048453092575f, 0.980745792388916f, -0.137417227029800f, - 0.980640232563019f, -0.137785911560059f, 0.980534434318542f, -0.138154521584511f, - 0.980428338050842f, -0.138523042201996f, 0.980321943759918f, -0.138891488313675f, - 0.980215251445770f, -0.139259845018387f, 0.980108320713043f, -0.139628127217293f, - 0.980001091957092f, -0.139996320009232f, 0.979893565177917f, -0.140364438295364f, - 0.979785740375519f, -0.140732467174530f, 0.979677677154541f, -0.141100421547890f, - 0.979569315910339f, -0.141468286514282f, 0.979460656642914f, -0.141836062073708f, - 0.979351758956909f, -0.142203763127327f, 0.979242503643036f, -0.142571389675140f, - 0.979133009910584f, -0.142938911914825f, 0.979023277759552f, -0.143306359648705f, - 0.978913187980652f, -0.143673732876778f, 0.978802859783173f, -0.144041016697884f, - 0.978692233562469f, -0.144408211112022f, 0.978581368923187f, -0.144775316119194f, - 0.978470146656036f, -0.145142331719399f, 0.978358685970306f, -0.145509272813797f, - 0.978246986865997f, -0.145876124501228f, 0.978134930133820f, -0.146242901682854f, - 0.978022634983063f, -0.146609574556351f, 0.977910041809082f, -0.146976172924042f, - 0.977797150611877f, -0.147342681884766f, 0.977684020996094f, -0.147709101438522f, - 0.977570593357086f, -0.148075446486473f, 0.977456867694855f, -0.148441687226295f, - 0.977342903614044f, -0.148807853460312f, 0.977228581905365f, -0.149173930287361f, - 0.977114021778107f, -0.149539917707443f, 0.976999223232269f, -0.149905815720558f, - 0.976884067058563f, -0.150271624326706f, 0.976768672466278f, -0.150637343525887f, - 0.976653039455414f, -0.151002973318100f, 0.976537048816681f, -0.151368513703346f, - 0.976420819759369f, -0.151733979582787f, 0.976304292678833f, -0.152099341154099f, - 0.976187527179718f, -0.152464613318443f, 0.976070404052734f, -0.152829796075821f, - 0.975953042507172f, -0.153194904327393f, 0.975835442543030f, -0.153559908270836f, - 0.975717484951019f, -0.153924822807312f, 0.975599288940430f, -0.154289647936821f, - 0.975480854511261f, -0.154654383659363f, 0.975362062454224f, -0.155019029974937f, - 0.975243031978607f, -0.155383571982384f, 0.975123703479767f, -0.155748039484024f, - 0.975004136562347f, -0.156112402677536f, 0.974884271621704f, -0.156476691365242f, - 0.974764108657837f, -0.156840875744820f, 0.974643647670746f, -0.157204970717430f, - 0.974522948265076f, -0.157568961381912f, 0.974401950836182f, -0.157932877540588f, - 0.974280655384064f, -0.158296689391136f, 0.974159121513367f, -0.158660411834717f, - 0.974037289619446f, -0.159024044871330f, 0.973915159702301f, -0.159387573599815f, - 0.973792791366577f, -0.159751012921333f, 0.973670125007629f, -0.160114362835884f, - 0.973547160625458f, -0.160477623343468f, 0.973423957824707f, -0.160840779542923f, - 0.973300457000732f, -0.161203846335411f, 0.973176658153534f, -0.161566808819771f, - 0.973052620887756f, -0.161929681897163f, 0.972928285598755f, -0.162292465567589f, - 0.972803652286530f, -0.162655144929886f, 0.972678780555725f, -0.163017734885216f, - 0.972553610801697f, -0.163380220532417f, 0.972428143024445f, -0.163742616772652f, - 0.972302436828613f, -0.164104923605919f, 0.972176432609558f, -0.164467126131058f, - 0.972050130367279f, -0.164829224348068f, 0.971923589706421f, -0.165191248059273f, - 0.971796751022339f, -0.165553152561188f, 0.971669614315033f, -0.165914967656136f, - 0.971542239189148f, -0.166276678442955f, 0.971414566040039f, -0.166638299822807f, - 0.971286594867706f, -0.166999831795692f, 0.971158385276794f, -0.167361244559288f, - 0.971029877662659f, -0.167722567915916f, 0.970901072025299f, -0.168083801865578f, - 0.970772027969360f, -0.168444931507111f, 0.970642685890198f, -0.168805956840515f, - 0.970513105392456f, -0.169166877865791f, 0.970383226871490f, -0.169527709484100f, - 0.970253050327301f, -0.169888436794281f, 0.970122575759888f, -0.170249074697495f, - 0.969991862773895f, -0.170609608292580f, 0.969860911369324f, -0.170970037579536f, - 0.969729602336884f, -0.171330362558365f, 0.969598054885864f, -0.171690583229065f, - 0.969466269016266f, -0.172050714492798f, 0.969334125518799f, -0.172410741448402f, - 0.969201743602753f, -0.172770664095879f, 0.969069123268127f, -0.173130482435226f, - 0.968936204910278f, -0.173490211367607f, 0.968802988529205f, -0.173849821090698f, - 0.968669533729553f, -0.174209341406822f, 0.968535780906677f, -0.174568757414818f, - 0.968401730060577f, -0.174928069114685f, 0.968267440795898f, -0.175287276506424f, - 0.968132853507996f, -0.175646379590034f, 0.967997968196869f, -0.176005378365517f, - 0.967862844467163f, -0.176364272832870f, 0.967727422714233f, -0.176723077893257f, - 0.967591762542725f, -0.177081763744354f, 0.967455804347992f, -0.177440345287323f, - 0.967319548130035f, -0.177798837423325f, 0.967183053493500f, -0.178157210350037f, - 0.967046260833740f, -0.178515478968620f, 0.966909229755402f, -0.178873643279076f, - 0.966771900653839f, -0.179231703281403f, 0.966634273529053f, -0.179589673876762f, - 0.966496407985687f, -0.179947525262833f, 0.966358244419098f, -0.180305257439613f, - 0.966219842433929f, -0.180662900209427f, 0.966081082820892f, -0.181020438671112f, - 0.965942144393921f, -0.181377857923508f, 0.965802907943726f, -0.181735187768936f, - 0.965663373470306f, -0.182092398405075f, 0.965523540973663f, -0.182449504733086f, - 0.965383470058441f, -0.182806491851807f, 0.965243160724640f, -0.183163389563560f, - 0.965102493762970f, -0.183520168066025f, 0.964961588382721f, -0.183876842260361f, - 0.964820444583893f, -0.184233412146568f, 0.964679002761841f, -0.184589877724648f, - 0.964537262916565f, -0.184946224093437f, 0.964395284652710f, -0.185302466154099f, - 0.964253067970276f, -0.185658603906631f, 0.964110493659973f, -0.186014622449875f, - 0.963967680931091f, -0.186370536684990f, 0.963824629783630f, -0.186726331710815f, - 0.963681280612946f, -0.187082037329674f, 0.963537633419037f, -0.187437608838081f, - 0.963393747806549f, -0.187793090939522f, 0.963249564170837f, -0.188148453831673f, - 0.963105142116547f, -0.188503712415695f, 0.962960422039032f, -0.188858851790428f, - 0.962815403938293f, -0.189213871955872f, 0.962670147418976f, -0.189568802714348f, - 0.962524592876434f, -0.189923599362373f, 0.962378799915314f, -0.190278306603432f, - 0.962232708930969f, -0.190632879734039f, 0.962086379528046f, -0.190987363457680f, - 0.961939752101898f, -0.191341713070869f, 0.961792886257172f, -0.191695958375931f, - 0.961645722389221f, -0.192050099372864f, 0.961498260498047f, -0.192404121160507f, - 0.961350560188293f, -0.192758023738861f, 0.961202561855316f, -0.193111822009087f, - 0.961054325103760f, -0.193465501070023f, 0.960905790328979f, -0.193819075822830f, - 0.960757017135620f, -0.194172516465187f, 0.960607945919037f, -0.194525867700577f, - 0.960458636283875f, -0.194879084825516f, 0.960309028625488f, -0.195232197642326f, - 0.960159122943878f, -0.195585191249847f, 0.960008978843689f, -0.195938065648079f, - 0.959858596324921f, -0.196290835738182f, 0.959707856178284f, -0.196643486618996f, - 0.959556937217712f, -0.196996018290520f, 0.959405720233917f, -0.197348430752754f, - 0.959254205226898f, -0.197700738906860f, 0.959102451801300f, -0.198052927851677f, - 0.958950400352478f, -0.198404997587204f, 0.958798050880432f, -0.198756948113441f, - 0.958645522594452f, -0.199108779430389f, 0.958492636680603f, -0.199460506439209f, - 0.958339512348175f, -0.199812099337578f, 0.958186149597168f, -0.200163587927818f, - 0.958032488822937f, -0.200514942407608f, 0.957878530025482f, -0.200866192579269f, - 0.957724332809448f, -0.201217323541641f, 0.957569897174835f, -0.201568335294724f, - 0.957415163516998f, -0.201919227838516f, 0.957260131835938f, -0.202270001173019f, - 0.957104861736298f, -0.202620655298233f, 0.956949353218079f, -0.202971190214157f, - 0.956793546676636f, -0.203321605920792f, 0.956637442111969f, -0.203671902418137f, - 0.956481099128723f, -0.204022079706192f, 0.956324458122253f, -0.204372137784958f, - 0.956167578697205f, -0.204722076654434f, 0.956010460853577f, -0.205071896314621f, - 0.955853044986725f, -0.205421581864357f, 0.955695331096649f, -0.205771163105965f, - 0.955537378787994f, -0.206120610237122f, 0.955379128456116f, -0.206469938158989f, - 0.955220639705658f, -0.206819161772728f, 0.955061912536621f, -0.207168251276016f, - 0.954902827739716f, -0.207517206668854f, 0.954743564128876f, -0.207866057753563f, - 0.954584002494812f, -0.208214774727821f, 0.954424142837524f, -0.208563387393951f, - 0.954264044761658f, -0.208911851048470f, 0.954103708267212f, -0.209260210394859f, - 0.953943073749542f, -0.209608450531960f, 0.953782141208649f, -0.209956556558609f, - 0.953620970249176f, -0.210304543375969f, 0.953459560871124f, -0.210652396082878f, - 0.953297853469849f, -0.211000129580498f, 0.953135907649994f, -0.211347743868828f, - 0.952973663806915f, -0.211695238947868f, 0.952811121940613f, -0.212042599916458f, - 0.952648401260376f, -0.212389841675758f, 0.952485322952271f, -0.212736949324608f, - 0.952322065830231f, -0.213083937764168f, 0.952158451080322f, -0.213430806994438f, - 0.951994657516479f, -0.213777542114258f, 0.951830565929413f, -0.214124158024788f, - 0.951666176319122f, -0.214470639824867f, 0.951501548290253f, -0.214817002415657f, - 0.951336681842804f, -0.215163245797157f, 0.951171517372131f, -0.215509355068207f, - 0.951006054878235f, -0.215855330228806f, 0.950840353965759f, -0.216201186180115f, - 0.950674414634705f, -0.216546908020973f, 0.950508177280426f, -0.216892510652542f, - 0.950341701507568f, -0.217237979173660f, 0.950174987316132f, -0.217583328485489f, - 0.950007975101471f, -0.217928543686867f, 0.949840664863586f, -0.218273624777794f, - 0.949673116207123f, -0.218618586659431f, 0.949505329132080f, -0.218963414430618f, - 0.949337244033813f, -0.219308122992516f, 0.949168920516968f, -0.219652697443962f, - 0.949000298976898f, -0.219997137784958f, 0.948831439018250f, -0.220341444015503f, - 0.948662281036377f, -0.220685631036758f, 0.948492884635925f, -0.221029683947563f, - 0.948323249816895f, -0.221373617649078f, 0.948153316974640f, -0.221717402338982f, - 0.947983145713806f, -0.222061067819595f, 0.947812676429749f, -0.222404599189758f, - 0.947641968727112f, -0.222748011350632f, 0.947470963001251f, -0.223091274499893f, - 0.947299718856812f, -0.223434418439865f, 0.947128236293793f, -0.223777428269386f, - 0.946956455707550f, -0.224120303988457f, 0.946784436702728f, -0.224463045597076f, - 0.946612179279327f, -0.224805667996407f, 0.946439623832703f, -0.225148141384125f, - 0.946266770362854f, -0.225490495562553f, 0.946093678474426f, -0.225832715630531f, - 0.945920348167419f, -0.226174786686897f, 0.945746779441834f, -0.226516738533974f, - 0.945572853088379f, -0.226858556270599f, 0.945398747920990f, -0.227200239896774f, - 0.945224344730377f, -0.227541789412498f, 0.945049703121185f, -0.227883204817772f, - 0.944874763488770f, -0.228224486112595f, 0.944699645042419f, -0.228565633296967f, - 0.944524168968201f, -0.228906646370888f, 0.944348454475403f, -0.229247525334358f, - 0.944172501564026f, -0.229588270187378f, 0.943996310234070f, -0.229928880929947f, - 0.943819820880890f, -0.230269357562065f, 0.943643093109131f, -0.230609700083733f, - 0.943466067314148f, -0.230949893593788f, 0.943288803100586f, -0.231289967894554f, - 0.943111240863800f, -0.231629893183708f, 0.942933499813080f, -0.231969684362412f, - 0.942755401134491f, -0.232309341430664f, 0.942577123641968f, -0.232648864388466f, - 0.942398548126221f, -0.232988253235817f, 0.942219734191895f, -0.233327493071556f, - 0.942040622234344f, -0.233666598796844f, 0.941861271858215f, -0.234005570411682f, - 0.941681683063507f, -0.234344407916069f, 0.941501796245575f, -0.234683111310005f, - 0.941321671009064f, -0.235021665692329f, 0.941141307353973f, -0.235360085964203f, - 0.940960645675659f, -0.235698372125626f, 0.940779745578766f, -0.236036509275436f, - 0.940598547458649f, -0.236374512314796f, 0.940417110919952f, -0.236712381243706f, - 0.940235435962677f, -0.237050101161003f, 0.940053522586823f, -0.237387686967850f, - 0.939871311187744f, -0.237725138664246f, 0.939688861370087f, -0.238062441349030f, - 0.939506113529205f, -0.238399609923363f, 0.939323127269745f, -0.238736644387245f, - 0.939139902591705f, -0.239073529839516f, 0.938956379890442f, -0.239410281181335f, - 0.938772618770599f, -0.239746883511543f, 0.938588619232178f, -0.240083336830139f, - 0.938404381275177f, -0.240419670939446f, 0.938219845294952f, -0.240755841135979f, - 0.938035070896149f, -0.241091892123222f, 0.937849998474121f, -0.241427779197693f, - 0.937664687633514f, -0.241763532161713f, 0.937479138374329f, -0.242099151015282f, - 0.937293350696564f, -0.242434620857239f, 0.937107264995575f, -0.242769956588745f, - 0.936920940876007f, -0.243105143308640f, 0.936734318733215f, -0.243440181016922f, - 0.936547517776489f, -0.243775084614754f, 0.936360359191895f, -0.244109839200974f, - 0.936173021793365f, -0.244444444775581f, 0.935985386371613f, -0.244778916239738f, - 0.935797572135925f, -0.245113238692284f, 0.935609400272369f, -0.245447427034378f, - 0.935421049594879f, -0.245781451463699f, 0.935232400894165f, -0.246115356683731f, - 0.935043513774872f, -0.246449097990990f, 0.934854328632355f, -0.246782705187798f, - 0.934664964675903f, -0.247116148471832f, 0.934475243091583f, -0.247449472546577f, - 0.934285342693329f, -0.247782632708550f, 0.934095203876495f, -0.248115643858910f, - 0.933904767036438f, -0.248448520898819f, 0.933714091777802f, -0.248781248927116f, - 0.933523118495941f, -0.249113827943802f, 0.933331906795502f, -0.249446272850037f, - 0.933140456676483f, -0.249778553843498f, 0.932948768138886f, -0.250110685825348f, - 0.932756841182709f, -0.250442683696747f, 0.932564616203308f, -0.250774532556534f, - 0.932372152805328f, -0.251106232404709f, 0.932179391384125f, -0.251437783241272f, - 0.931986451148987f, -0.251769185066223f, 0.931793212890625f, -0.252100437879562f, - 0.931599736213684f, -0.252431541681290f, 0.931405961513519f, -0.252762526273727f, - 0.931211948394775f, -0.253093332052231f, 0.931017756462097f, -0.253423988819122f, - 0.930823206901550f, -0.253754496574402f, 0.930628478527069f, -0.254084855318069f, - 0.930433452129364f, -0.254415065050125f, 0.930238187313080f, -0.254745125770569f, - 0.930042684078217f, -0.255075037479401f, 0.929846942424774f, -0.255404800176620f, - 0.929650902748108f, -0.255734413862228f, 0.929454624652863f, -0.256063878536224f, - 0.929258108139038f, -0.256393194198608f, 0.929061353206635f, -0.256722360849380f, - 0.928864300251007f, -0.257051378488541f, 0.928667008876801f, -0.257380217313766f, - 0.928469479084015f, -0.257708936929703f, 0.928271710872650f, -0.258037507534027f, - 0.928073644638062f, -0.258365899324417f, 0.927875399589539f, -0.258694142103195f, - 0.927676856517792f, -0.259022265672684f, 0.927478015422821f, -0.259350210428238f, - 0.927278995513916f, -0.259678006172180f, 0.927079677581787f, -0.260005623102188f, - 0.926880121231079f, -0.260333120822906f, 0.926680326461792f, -0.260660469532013f, - 0.926480293273926f, -0.260987639427185f, 0.926280021667480f, -0.261314690113068f, - 0.926079452037811f, -0.261641561985016f, 0.925878643989563f, -0.261968284845352f, - 0.925677597522736f, -0.262294828891754f, 0.925476312637329f, -0.262621253728867f, - 0.925274729728699f, -0.262947499752045f, 0.925072908401489f, -0.263273626565933f, - 0.924870908260345f, -0.263599574565887f, 0.924668610095978f, -0.263925373554230f, - 0.924466013908386f, -0.264250993728638f, 0.924263238906860f, -0.264576494693756f, - 0.924060165882111f, -0.264901816844940f, 0.923856854438782f, -0.265226989984512f, - 0.923653304576874f, -0.265552014112473f, 0.923449516296387f, -0.265876859426498f, - 0.923245489597321f, -0.266201555728912f, 0.923041164875031f, -0.266526103019714f, - 0.922836601734161f, -0.266850501298904f, 0.922631800174713f, -0.267174720764160f, - 0.922426760196686f, -0.267498821020126f, 0.922221481800079f, -0.267822742462158f, - 0.922015964984894f, -0.268146485090256f, 0.921810150146484f, -0.268470078706741f, - 0.921604096889496f, -0.268793523311615f, 0.921397805213928f, -0.269116818904877f, - 0.921191275119781f, -0.269439965486526f, 0.920984506607056f, -0.269762933254242f, - 0.920777499675751f, -0.270085722208023f, 0.920570194721222f, -0.270408391952515f, - 0.920362710952759f, -0.270730882883072f, 0.920154929161072f, -0.271053224802017f, - 0.919946908950806f, -0.271375387907028f, 0.919738650321960f, -0.271697402000427f, - 0.919530093669891f, -0.272019267082214f, 0.919321358203888f, -0.272340953350067f, - 0.919112324714661f, -0.272662490606308f, 0.918903112411499f, -0.272983878850937f, - 0.918693602085114f, -0.273305088281631f, 0.918483853340149f, -0.273626148700714f, - 0.918273866176605f, -0.273947030305862f, 0.918063640594482f, -0.274267762899399f, - 0.917853116989136f, -0.274588316679001f, 0.917642414569855f, -0.274908751249313f, - 0.917431414127350f, -0.275228977203369f, 0.917220234870911f, -0.275549083948135f, - 0.917008757591248f, -0.275868982076645f, 0.916797041893005f, -0.276188760995865f, - 0.916585087776184f, -0.276508361101151f, 0.916372895240784f, -0.276827782392502f, - 0.916160404682159f, -0.277147054672241f, 0.915947735309601f, -0.277466177940369f, - 0.915734827518463f, -0.277785122394562f, 0.915521621704102f, -0.278103888034821f, - 0.915308177471161f, -0.278422504663467f, 0.915094554424286f, -0.278740972280502f, - 0.914880633354187f, -0.279059261083603f, 0.914666473865509f, -0.279377400875092f, - 0.914452075958252f, -0.279695361852646f, 0.914237439632416f, -0.280013144016266f, - 0.914022505283356f, -0.280330777168274f, 0.913807392120361f, -0.280648261308670f, - 0.913592040538788f, -0.280965566635132f, 0.913376390933990f, -0.281282693147659f, - 0.913160502910614f, -0.281599670648575f, 0.912944436073303f, -0.281916469335556f, - 0.912728071212769f, -0.282233119010925f, 0.912511467933655f, -0.282549589872360f, - 0.912294626235962f, -0.282865911722183f, 0.912077546119690f, -0.283182054758072f, - 0.911860227584839f, -0.283498018980026f, 0.911642670631409f, -0.283813834190369f, - 0.911424875259399f, -0.284129470586777f, 0.911206841468811f, -0.284444957971573f, - 0.910988569259644f, -0.284760266542435f, 0.910769999027252f, -0.285075396299362f, - 0.910551249980927f, -0.285390377044678f, 0.910332262516022f, -0.285705178976059f, - 0.910112977027893f, -0.286019802093506f, 0.909893512725830f, -0.286334276199341f, - 0.909673750400543f, -0.286648571491241f, 0.909453809261322f, -0.286962717771530f, - 0.909233570098877f, -0.287276685237885f, 0.909013092517853f, -0.287590473890305f, - 0.908792436122894f, -0.287904083728790f, 0.908571481704712f, -0.288217544555664f, - 0.908350288867950f, -0.288530826568604f, 0.908128857612610f, -0.288843959569931f, - 0.907907187938690f, -0.289156883955002f, 0.907685279846191f, -0.289469659328461f, - 0.907463192939758f, -0.289782285690308f, 0.907240808010101f, -0.290094703435898f, - 0.907018184661865f, -0.290406972169876f, 0.906795322895050f, -0.290719062089920f, - 0.906572222709656f, -0.291031002998352f, 0.906348884105682f, -0.291342735290527f, - 0.906125307083130f, -0.291654318571091f, 0.905901491641998f, -0.291965723037720f, - 0.905677437782288f, -0.292276978492737f, 0.905453145503998f, -0.292588025331497f, - 0.905228614807129f, -0.292898923158646f, 0.905003845691681f, -0.293209642171860f, - 0.904778838157654f, -0.293520182371140f, 0.904553592205048f, -0.293830573558807f, - 0.904328107833862f, -0.294140785932541f, 0.904102385044098f, -0.294450789690018f, - 0.903876423835754f, -0.294760644435883f, 0.903650224208832f, -0.295070350170136f, - 0.903423786163330f, -0.295379847288132f, 0.903197109699249f, -0.295689195394516f, - 0.902970194816589f, -0.295998334884644f, 0.902743041515350f, -0.296307325363159f, - 0.902515649795532f, -0.296616137027740f, 0.902288019657135f, -0.296924799680710f, - 0.902060210704803f, -0.297233253717422f, 0.901832103729248f, -0.297541528940201f, - 0.901603758335114f, -0.297849655151367f, 0.901375174522400f, -0.298157602548599f, - 0.901146411895752f, -0.298465341329575f, 0.900917351245880f, -0.298772931098938f, - 0.900688111782074f, -0.299080342054367f, 0.900458574295044f, -0.299387603998184f, - 0.900228857994080f, -0.299694657325745f, 0.899998843669891f, -0.300001531839371f, - 0.899768650531769f, -0.300308227539063f, 0.899538159370422f, -0.300614774227142f, - 0.899307489395142f, -0.300921112298965f, 0.899076581001282f, -0.301227301359177f, - 0.898845434188843f, -0.301533311605453f, 0.898614048957825f, -0.301839113235474f, - 0.898382425308228f, -0.302144765853882f, 0.898150563240051f, -0.302450239658356f, - 0.897918462753296f, -0.302755534648895f, 0.897686123847961f, -0.303060621023178f, - 0.897453546524048f, -0.303365558385849f, 0.897220790386200f, -0.303670316934586f, - 0.896987736225128f, -0.303974896669388f, 0.896754503250122f, -0.304279297590256f, - 0.896520972251892f, -0.304583519697189f, 0.896287262439728f, -0.304887533187866f, - 0.896053314208984f, -0.305191397666931f, 0.895819067955017f, -0.305495083332062f, - 0.895584642887115f, -0.305798590183258f, 0.895349979400635f, -0.306101888418198f, - 0.895115137100220f, -0.306405037641525f, 0.894879996776581f, -0.306708008050919f, - 0.894644618034363f, -0.307010769844055f, 0.894409060478210f, -0.307313382625580f, - 0.894173204898834f, -0.307615786790848f, 0.893937170505524f, -0.307918041944504f, - 0.893700897693634f, -0.308220088481903f, 0.893464326858521f, -0.308521956205368f, - 0.893227577209473f, -0.308823645114899f, 0.892990648746490f, -0.309125155210495f, - 0.892753422260284f, -0.309426486492157f, 0.892515957355499f, -0.309727638959885f, - 0.892278313636780f, -0.310028612613678f, 0.892040371894836f, -0.310329377651215f, - 0.891802251338959f, -0.310629993677139f, 0.891563892364502f, -0.310930401086807f, - 0.891325294971466f, -0.311230629682541f, 0.891086459159851f, -0.311530679464340f, - 0.890847444534302f, -0.311830550432205f, 0.890608131885529f, -0.312130242586136f, - 0.890368640422821f, -0.312429755926132f, 0.890128850936890f, -0.312729060649872f, - 0.889888882637024f, -0.313028186559677f, 0.889648675918579f, -0.313327133655548f, - 0.889408230781555f, -0.313625901937485f, 0.889167606830597f, -0.313924491405487f, - 0.888926684856415f, -0.314222872257233f, 0.888685584068298f, -0.314521104097366f, - 0.888444244861603f, -0.314819127321243f, 0.888202667236328f, -0.315116971731186f, - 0.887960851192474f, -0.315414607524872f, 0.887718796730042f, -0.315712094306946f, - 0.887476563453674f, -0.316009372472763f, 0.887234091758728f, -0.316306471824646f, - 0.886991322040558f, -0.316603392362595f, 0.886748373508453f, -0.316900104284287f, - 0.886505246162415f, -0.317196637392044f, 0.886261820793152f, -0.317492991685867f, - 0.886018216609955f, -0.317789167165756f, 0.885774314403534f, -0.318085134029388f, - 0.885530233383179f, -0.318380922079086f, 0.885285973548889f, -0.318676531314850f, - 0.885041415691376f, -0.318971961736679f, 0.884796679019928f, -0.319267183542252f, - 0.884551644325256f, -0.319562226533890f, 0.884306430816650f, -0.319857090711594f, - 0.884061038494110f, -0.320151746273041f, 0.883815348148346f, -0.320446223020554f, - 0.883569478988647f, -0.320740520954132f, 0.883323311805725f, -0.321034610271454f, - 0.883076965808868f, -0.321328520774841f, 0.882830440998077f, -0.321622252464294f, - 0.882583618164063f, -0.321915775537491f, 0.882336616516113f, -0.322209119796753f, - 0.882089376449585f, -0.322502255439758f, 0.881841897964478f, -0.322795242071152f, - 0.881594181060791f, -0.323088020086288f, 0.881346285343170f, -0.323380589485168f, - 0.881098151206970f, -0.323672980070114f, 0.880849778652191f, -0.323965191841125f, - 0.880601167678833f, -0.324257194995880f, 0.880352377891541f, -0.324549019336700f, - 0.880103349685669f, -0.324840664863586f, 0.879854083061218f, -0.325132101774216f, - 0.879604578018188f, -0.325423330068588f, 0.879354894161224f, -0.325714409351349f, - 0.879104971885681f, -0.326005280017853f, 0.878854811191559f, -0.326295942068100f, - 0.878604412078857f, -0.326586425304413f, 0.878353834152222f, -0.326876699924469f, - 0.878103017807007f, -0.327166795730591f, 0.877851963043213f, -0.327456712722778f, - 0.877600669860840f, -0.327746421098709f, 0.877349197864532f, -0.328035950660706f, - 0.877097487449646f, -0.328325271606445f, 0.876845538616180f, -0.328614413738251f, - 0.876593410968781f, -0.328903347253799f, 0.876341044902802f, -0.329192101955414f, - 0.876088440418243f, -0.329480648040771f, 0.875835597515106f, -0.329769015312195f, - 0.875582575798035f, -0.330057173967361f, 0.875329315662384f, -0.330345153808594f, - 0.875075817108154f, -0.330632925033569f, 0.874822139739990f, -0.330920487642288f, - 0.874568223953247f, -0.331207901239395f, 0.874314069747925f, -0.331495076417923f, - 0.874059677124023f, -0.331782072782516f, 0.873805105686188f, -0.332068890333176f, - 0.873550295829773f, -0.332355499267578f, 0.873295307159424f, -0.332641899585724f, - 0.873040020465851f, -0.332928121089935f, 0.872784554958344f, -0.333214133977890f, - 0.872528910636902f, -0.333499968051910f, 0.872272968292236f, -0.333785593509674f, - 0.872016847133636f, -0.334071010351181f, 0.871760547161102f, -0.334356248378754f, - 0.871503949165344f, -0.334641307592392f, 0.871247172355652f, -0.334926128387451f, - 0.870990216732025f, -0.335210770368576f, 0.870733022689819f, -0.335495233535767f, - 0.870475590229034f, -0.335779488086700f, 0.870217919349670f, -0.336063534021378f, - 0.869960069656372f, -0.336347371339798f, 0.869701981544495f, -0.336631029844284f, - 0.869443655014038f, -0.336914509534836f, 0.869185149669647f, -0.337197750806808f, - 0.868926405906677f, -0.337480813264847f, 0.868667483329773f, -0.337763696908951f, - 0.868408262729645f, -0.338046342134476f, 0.868148922920227f, -0.338328808546066f, - 0.867889285087585f, -0.338611096143723f, 0.867629468441010f, -0.338893145322800f, - 0.867369413375854f, -0.339175015687943f, 0.867109179496765f, -0.339456677436829f, - 0.866848707199097f, -0.339738160371780f, 0.866588056087494f, -0.340019434690475f, - 0.866327106952667f, -0.340300500392914f, 0.866066038608551f, -0.340581357479095f, - 0.865804672241211f, -0.340862035751343f, 0.865543127059937f, -0.341142505407333f, - 0.865281403064728f, -0.341422766447067f, 0.865019381046295f, -0.341702848672867f, - 0.864757239818573f, -0.341982692480087f, 0.864494800567627f, -0.342262357473373f, - 0.864232182502747f, -0.342541843652725f, 0.863969385623932f, -0.342821091413498f, - 0.863706290721893f, -0.343100160360336f, 0.863443076610565f, -0.343379020690918f, - 0.863179564476013f, -0.343657672405243f, 0.862915873527527f, -0.343936115503311f, - 0.862652003765106f, -0.344214379787445f, 0.862387895584106f, -0.344492435455322f, - 0.862123548984528f, -0.344770282506943f, 0.861859023571014f, -0.345047920942307f, - 0.861594259738922f, -0.345325350761414f, 0.861329257488251f, -0.345602601766586f, - 0.861064076423645f, -0.345879614353180f, 0.860798716545105f, -0.346156448125839f, - 0.860533118247986f, -0.346433073282242f, 0.860267281532288f, -0.346709519624710f, - 0.860001266002655f, -0.346985727548599f, 0.859735012054443f, -0.347261756658554f, - 0.859468579292297f, -0.347537547349930f, 0.859201908111572f, -0.347813159227371f, - 0.858934998512268f, -0.348088562488556f, 0.858667910099030f, -0.348363757133484f, - 0.858400642871857f, -0.348638743162155f, 0.858133137226105f, -0.348913550376892f, - 0.857865393161774f, -0.349188119173050f, 0.857597470283508f, -0.349462509155273f, - 0.857329368591309f, -0.349736660718918f, 0.857060968875885f, -0.350010633468628f, - 0.856792449951172f, -0.350284397602081f, 0.856523692607880f, -0.350557953119278f, - 0.856254696846008f, -0.350831300020218f, 0.855985522270203f, -0.351104438304901f, - 0.855716109275818f, -0.351377367973328f, 0.855446517467499f, -0.351650089025497f, - 0.855176687240601f, -0.351922631263733f, 0.854906618595123f, -0.352194935083389f, - 0.854636430740356f, -0.352467030286789f, 0.854365944862366f, -0.352738946676254f, - 0.854095339775085f, -0.353010624647141f, 0.853824436664581f, -0.353282123804092f, - 0.853553414344788f, -0.353553384542465f, 0.853282094001770f, -0.353824466466904f, - 0.853010654449463f, -0.354095309972763f, 0.852738916873932f, -0.354365974664688f, - 0.852467060089111f, -0.354636400938034f, 0.852194905281067f, -0.354906648397446f, - 0.851922631263733f, -0.355176687240601f, 0.851650118827820f, -0.355446487665176f, - 0.851377367973328f, -0.355716109275818f, 0.851104438304901f, -0.355985492467880f, - 0.850831270217896f, -0.356254696846008f, 0.850557923316956f, -0.356523662805557f, - 0.850284397602081f, -0.356792420148849f, 0.850010633468628f, -0.357060998678207f, - 0.849736690521240f, -0.357329338788986f, 0.849462509155273f, -0.357597470283508f, - 0.849188148975372f, -0.357865422964096f, 0.848913550376892f, -0.358133137226105f, - 0.848638772964478f, -0.358400642871857f, 0.848363757133484f, -0.358667939901352f, - 0.848088562488556f, -0.358935028314590f, 0.847813189029694f, -0.359201908111572f, - 0.847537577152252f, -0.359468549489975f, 0.847261726856232f, -0.359735012054443f, - 0.846985757350922f, -0.360001266002655f, 0.846709489822388f, -0.360267281532288f, - 0.846433103084564f, -0.360533088445663f, 0.846156477928162f, -0.360798716545105f, - 0.845879614353180f, -0.361064106225967f, 0.845602571964264f, -0.361329287290573f, - 0.845325350761414f, -0.361594229936600f, 0.845047891139984f, -0.361858993768692f, - 0.844770252704620f, -0.362123548984528f, 0.844492435455322f, -0.362387865781784f, - 0.844214379787445f, -0.362651973962784f, 0.843936145305634f, -0.362915903329849f, - 0.843657672405243f, -0.363179564476013f, 0.843379020690918f, -0.363443046808243f, - 0.843100130558014f, -0.363706320524216f, 0.842821121215820f, -0.363969355821610f, - 0.842541813850403f, -0.364232182502747f, 0.842262387275696f, -0.364494800567627f, - 0.841982722282410f, -0.364757210016251f, 0.841702818870544f, -0.365019410848618f, - 0.841422796249390f, -0.365281373262405f, 0.841142535209656f, -0.365543156862259f, - 0.840862035751343f, -0.365804702043533f, 0.840581357479095f, -0.366066008806229f, - 0.840300500392914f, -0.366327136754990f, 0.840019404888153f, -0.366588026285172f, - 0.839738130569458f, -0.366848707199097f, 0.839456677436829f, -0.367109179496765f, - 0.839175045490265f, -0.367369443178177f, 0.838893175125122f, -0.367629468441010f, - 0.838611066341400f, -0.367889285087585f, 0.838328838348389f, -0.368148893117905f, - 0.838046371936798f, -0.368408292531967f, 0.837763667106628f, -0.368667453527451f, - 0.837480843067169f, -0.368926405906677f, 0.837197780609131f, -0.369185149669647f, - 0.836914479732513f, -0.369443655014038f, 0.836631059646606f, -0.369701951742172f, - 0.836347401142120f, -0.369960039854050f, 0.836063504219055f, -0.370217919349670f, - 0.835779488086700f, -0.370475560426712f, 0.835495233535767f, -0.370732992887497f, - 0.835210800170898f, -0.370990216732025f, 0.834926128387451f, -0.371247202157974f, - 0.834641277790070f, -0.371503978967667f, 0.834356248378754f, -0.371760547161102f, - 0.834071040153503f, -0.372016876935959f, 0.833785593509674f, -0.372272998094559f, - 0.833499968051910f, -0.372528880834579f, 0.833214163780212f, -0.372784584760666f, - 0.832928121089935f, -0.373040050268173f, 0.832641899585724f, -0.373295277357101f, - 0.832355499267578f, -0.373550295829773f, 0.832068860530853f, -0.373805105686188f, - 0.831782102584839f, -0.374059677124023f, 0.831495106220245f, -0.374314039945602f, - 0.831207871437073f, -0.374568194150925f, 0.830920517444611f, -0.374822109937668f, - 0.830632925033569f, -0.375075817108154f, 0.830345153808594f, -0.375329315662384f, - 0.830057144165039f, -0.375582575798035f, 0.829769015312195f, -0.375835597515106f, - 0.829480648040771f, -0.376088410615921f, 0.829192101955414f, -0.376341015100479f, - 0.828903317451477f, -0.376593410968781f, 0.828614413738251f, -0.376845568418503f, - 0.828325271606445f, -0.377097487449646f, 0.828035950660706f, -0.377349197864532f, - 0.827746450901031f, -0.377600699663162f, 0.827456712722778f, -0.377851963043213f, - 0.827166795730591f, -0.378102988004684f, 0.826876699924469f, -0.378353834152222f, - 0.826586425304413f, -0.378604412078857f, 0.826295912265778f, -0.378854811191559f, - 0.826005280017853f, -0.379104942083359f, 0.825714409351349f, -0.379354894161224f, - 0.825423359870911f, -0.379604607820511f, 0.825132071971893f, -0.379854083061218f, - 0.824840664863586f, -0.380103349685669f, 0.824549019336700f, -0.380352377891541f, - 0.824257194995880f, -0.380601197481155f, 0.823965191841125f, -0.380849778652191f, - 0.823673009872437f, -0.381098151206970f, 0.823380589485168f, -0.381346285343170f, - 0.823087990283966f, -0.381594210863113f, 0.822795212268829f, -0.381841897964478f, - 0.822502255439758f, -0.382089376449585f, 0.822209119796753f, -0.382336616516113f, - 0.821915745735168f, -0.382583618164063f, 0.821622252464294f, -0.382830440998077f, - 0.821328520774841f, -0.383076995611191f, 0.821034610271454f, -0.383323341608047f, - 0.820740520954132f, -0.383569449186325f, 0.820446193218231f, -0.383815348148346f, - 0.820151746273041f, -0.384061008691788f, 0.819857060909271f, -0.384306460618973f, - 0.819562196731567f, -0.384551674127579f, 0.819267153739929f, -0.384796649217606f, - 0.818971931934357f, -0.385041415691376f, 0.818676531314850f, -0.385285943746567f, - 0.818380951881409f, -0.385530263185501f, 0.818085134029388f, -0.385774344205856f, - 0.817789137363434f, -0.386018186807632f, 0.817493021488190f, -0.386261820793152f, - 0.817196667194366f, -0.386505216360092f, 0.816900074481964f, -0.386748403310776f, - 0.816603362560272f, -0.386991351842880f, 0.816306471824646f, -0.387234061956406f, - 0.816009342670441f, -0.387476563453674f, 0.815712094306946f, -0.387718826532364f, - 0.815414607524872f, -0.387960851192474f, 0.815116941928864f, -0.388202667236328f, - 0.814819097518921f, -0.388444244861603f, 0.814521074295044f, -0.388685584068298f, - 0.814222872257233f, -0.388926714658737f, 0.813924491405487f, -0.389167606830597f, - 0.813625931739807f, -0.389408260583878f, 0.813327133655548f, -0.389648675918579f, - 0.813028216362000f, -0.389888882637024f, 0.812729060649872f, -0.390128880739212f, - 0.812429726123810f, -0.390368610620499f, 0.812130272388458f, -0.390608131885529f, - 0.811830580234528f, -0.390847414731979f, 0.811530709266663f, -0.391086459159851f, - 0.811230659484863f, -0.391325294971466f, 0.810930430889130f, -0.391563892364502f, - 0.810629963874817f, -0.391802251338959f, 0.810329377651215f, -0.392040401697159f, - 0.810028612613678f, -0.392278283834457f, 0.809727668762207f, -0.392515957355499f, - 0.809426486492157f, -0.392753422260284f, 0.809125185012817f, -0.392990618944168f, - 0.808823645114899f, -0.393227607011795f, 0.808521986007690f, -0.393464356660843f, - 0.808220088481903f, -0.393700867891312f, 0.807918012142181f, -0.393937170505524f, - 0.807615816593170f, -0.394173204898834f, 0.807313382625580f, -0.394409030675888f, - 0.807010769844055f, -0.394644618034363f, 0.806707978248596f, -0.394879996776581f, - 0.806405067443848f, -0.395115107297897f, 0.806101918220520f, -0.395350009202957f, - 0.805798590183258f, -0.395584672689438f, 0.805495083332062f, -0.395819097757339f, - 0.805191397666931f, -0.396053284406662f, 0.804887533187866f, -0.396287262439728f, - 0.804583489894867f, -0.396520972251892f, 0.804279267787933f, -0.396754473447800f, - 0.803974866867065f, -0.396987736225128f, 0.803670346736908f, -0.397220760583878f, - 0.803365588188171f, -0.397453576326370f, 0.803060650825500f, -0.397686123847961f, - 0.802755534648895f, -0.397918462753296f, 0.802450239658356f, -0.398150533437729f, - 0.802144765853882f, -0.398382395505905f, 0.801839113235474f, -0.398614019155502f, - 0.801533281803131f, -0.398845434188843f, 0.801227271556854f, -0.399076581001282f, - 0.800921142101288f, -0.399307489395142f, 0.800614774227142f, -0.399538189172745f, - 0.800308227539063f, -0.399768620729446f, 0.800001561641693f, -0.399998843669891f, - 0.799694657325745f, -0.400228828191757f, 0.799387574195862f, -0.400458574295044f, - 0.799080371856689f, -0.400688081979752f, 0.798772931098938f, -0.400917351245880f, - 0.798465371131897f, -0.401146411895752f, 0.798157572746277f, -0.401375204324722f, - 0.797849655151367f, -0.401603758335114f, 0.797541558742523f, -0.401832103729248f, - 0.797233223915100f, -0.402060180902481f, 0.796924769878387f, -0.402288049459457f, - 0.796616137027740f, -0.402515679597855f, 0.796307325363159f, -0.402743041515350f, - 0.795998334884644f, -0.402970194816589f, 0.795689165592194f, -0.403197109699249f, - 0.795379877090454f, -0.403423786163330f, 0.795070350170136f, -0.403650224208832f, - 0.794760644435883f, -0.403876423835754f, 0.794450819492340f, -0.404102355241776f, - 0.794140756130219f, -0.404328078031540f, 0.793830573558807f, -0.404553562402725f, - 0.793520212173462f, -0.404778808355331f, 0.793209671974182f, -0.405003815889359f, - 0.792898952960968f, -0.405228585004807f, 0.792588055133820f, -0.405453115701675f, - 0.792276978492737f, -0.405677437782288f, 0.791965723037720f, -0.405901491641998f, - 0.791654348373413f, -0.406125307083130f, 0.791342735290527f, -0.406348884105682f, - 0.791031002998352f, -0.406572192907333f, 0.790719091892242f, -0.406795293092728f, - 0.790407001972198f, -0.407018154859543f, 0.790094733238220f, -0.407240778207779f, - 0.789782285690308f, -0.407463163137436f, 0.789469659328461f, -0.407685309648514f, - 0.789156913757324f, -0.407907217741013f, 0.788843929767609f, -0.408128857612610f, - 0.788530826568604f, -0.408350288867950f, 0.788217544555664f, -0.408571451902390f, - 0.787904083728790f, -0.408792406320572f, 0.787590444087982f, -0.409013092517853f, - 0.787276685237885f, -0.409233570098877f, 0.786962687969208f, -0.409453779459000f, - 0.786648571491241f, -0.409673750400543f, 0.786334276199341f, -0.409893482923508f, - 0.786019802093506f, -0.410112977027893f, 0.785705149173737f, -0.410332232713699f, - 0.785390377044678f, -0.410551249980927f, 0.785075426101685f, -0.410770028829575f, - 0.784760236740112f, -0.410988569259644f, 0.784444928169250f, -0.411206841468811f, - 0.784129500389099f, -0.411424905061722f, 0.783813834190369f, -0.411642700433731f, - 0.783498048782349f, -0.411860257387161f, 0.783182024955750f, -0.412077575922012f, - 0.782865881919861f, -0.412294656038284f, 0.782549619674683f, -0.412511497735977f, - 0.782233119010925f, -0.412728071212769f, 0.781916499137878f, -0.412944436073303f, - 0.781599700450897f, -0.413160532712936f, 0.781282722949982f, -0.413376390933990f, - 0.780965566635132f, -0.413592010736465f, 0.780648231506348f, -0.413807392120361f, - 0.780330777168274f, -0.414022535085678f, 0.780013144016266f, -0.414237409830093f, - 0.779695332050323f, -0.414452046155930f, 0.779377400875092f, -0.414666473865509f, - 0.779059290885925f, -0.414880603551865f, 0.778741002082825f, -0.415094524621964f, - 0.778422534465790f, -0.415308207273483f, 0.778103888034821f, -0.415521621704102f, - 0.777785122394562f, -0.415734797716141f, 0.777466177940369f, -0.415947735309601f, - 0.777147054672241f, -0.416160434484482f, 0.776827812194824f, -0.416372895240784f, - 0.776508331298828f, -0.416585087776184f, 0.776188731193542f, -0.416797041893005f, - 0.775869011878967f, -0.417008757591248f, 0.775549054145813f, -0.417220205068588f, - 0.775228977203369f, -0.417431443929672f, 0.774908721446991f, -0.417642414569855f, - 0.774588346481323f, -0.417853146791458f, 0.774267733097076f, -0.418063640594482f, - 0.773947000503540f, -0.418273866176605f, 0.773626148700714f, -0.418483853340149f, - 0.773305058479309f, -0.418693602085114f, 0.772983849048615f, -0.418903112411499f, - 0.772662520408630f, -0.419112354516983f, 0.772340953350067f, -0.419321358203888f, - 0.772019267082214f, -0.419530123472214f, 0.771697402000427f, -0.419738620519638f, - 0.771375417709351f, -0.419946908950806f, 0.771053194999695f, -0.420154929161072f, - 0.770730912685394f, -0.420362681150436f, 0.770408391952515f, -0.420570224523544f, - 0.770085752010345f, -0.420777499675751f, 0.769762933254242f, -0.420984506607056f, - 0.769439935684204f, -0.421191304922104f, 0.769116818904877f, -0.421397835016251f, - 0.768793523311615f, -0.421604126691818f, 0.768470108509064f, -0.421810150146484f, - 0.768146514892578f, -0.422015935182571f, 0.767822742462158f, -0.422221481800079f, - 0.767498791217804f, -0.422426789999008f, 0.767174720764160f, -0.422631829977036f, - 0.766850471496582f, -0.422836631536484f, 0.766526103019714f, -0.423041164875031f, - 0.766201555728912f, -0.423245459794998f, 0.765876889228821f, -0.423449516296387f, - 0.765551984310150f, -0.423653304576874f, 0.765226960182190f, -0.423856884241104f, - 0.764901816844940f, -0.424060165882111f, 0.764576494693756f, -0.424263238906860f, - 0.764250993728638f, -0.424466013908386f, 0.763925373554230f, -0.424668580293655f, - 0.763599574565887f, -0.424870878458023f, 0.763273596763611f, -0.425072938203812f, - 0.762947499752045f, -0.425274729728699f, 0.762621283531189f, -0.425476282835007f, - 0.762294828891754f, -0.425677597522736f, 0.761968255043030f, -0.425878643989563f, - 0.761641561985016f, -0.426079452037811f, 0.761314690113068f, -0.426279991865158f, - 0.760987639427185f, -0.426480293273926f, 0.760660469532013f, -0.426680356264114f, - 0.760333120822906f, -0.426880151033401f, 0.760005652904511f, -0.427079707384110f, - 0.759678006172180f, -0.427278995513916f, 0.759350180625916f, -0.427478045225143f, - 0.759022235870361f, -0.427676826715469f, 0.758694171905518f, -0.427875369787216f, - 0.758365929126740f, -0.428073674440384f, 0.758037507534027f, -0.428271710872650f, - 0.757708966732025f, -0.428469479084015f, 0.757380247116089f, -0.428667008876801f, - 0.757051348686218f, -0.428864300251007f, 0.756722390651703f, -0.429061323404312f, - 0.756393194198608f, -0.429258108139038f, 0.756063878536224f, -0.429454624652863f, - 0.755734443664551f, -0.429650902748108f, 0.755404829978943f, -0.429846942424774f, - 0.755075037479401f, -0.430042684078217f, 0.754745125770569f, -0.430238217115402f, - 0.754415094852448f, -0.430433481931686f, 0.754084885120392f, -0.430628478527069f, - 0.753754496574402f, -0.430823236703873f, 0.753423988819122f, -0.431017726659775f, - 0.753093302249908f, -0.431211978197098f, 0.752762496471405f, -0.431405961513519f, - 0.752431571483612f, -0.431599706411362f, 0.752100467681885f, -0.431793183088303f, - 0.751769185066223f, -0.431986421346664f, 0.751437783241272f, -0.432179391384125f, - 0.751106262207031f, -0.432372123003006f, 0.750774562358856f, -0.432564586400986f, - 0.750442683696747f, -0.432756811380386f, 0.750110685825348f, -0.432948768138886f, - 0.749778568744659f, -0.433140486478806f, 0.749446272850037f, -0.433331936597824f, - 0.749113857746124f, -0.433523118495941f, 0.748781263828278f, -0.433714061975479f, - 0.748448550701141f, -0.433904737234116f, 0.748115658760071f, -0.434095174074173f, - 0.747782647609711f, -0.434285342693329f, 0.747449457645416f, -0.434475272893906f, - 0.747116148471832f, -0.434664934873581f, 0.746782720088959f, -0.434854328632355f, - 0.746449112892151f, -0.435043483972549f, 0.746115326881409f, -0.435232400894165f, - 0.745781481266022f, -0.435421019792557f, 0.745447397232056f, -0.435609430074692f, - 0.745113253593445f, -0.435797542333603f, 0.744778931140900f, -0.435985416173935f, - 0.744444429874420f, -0.436173021793365f, 0.744109809398651f, -0.436360388994217f, - 0.743775069713593f, -0.436547487974167f, 0.743440151214600f, -0.436734348535538f, - 0.743105113506317f, -0.436920911073685f, 0.742769956588745f, -0.437107264995575f, - 0.742434620857239f, -0.437293320894241f, 0.742099165916443f, -0.437479138374329f, - 0.741763532161713f, -0.437664687633514f, 0.741427779197693f, -0.437849998474121f, - 0.741091907024384f, -0.438035041093826f, 0.740755856037140f, -0.438219845294952f, - 0.740419685840607f, -0.438404351472855f, 0.740083336830139f, -0.438588619232178f, - 0.739746868610382f, -0.438772648572922f, 0.739410281181335f, -0.438956409692764f, - 0.739073514938354f, -0.439139902591705f, 0.738736629486084f, -0.439323127269745f, - 0.738399624824524f, -0.439506113529205f, 0.738062441349030f, -0.439688831567764f, - 0.737725138664246f, -0.439871311187744f, 0.737387716770172f, -0.440053492784500f, - 0.737050116062164f, -0.440235435962677f, 0.736712396144867f, -0.440417140722275f, - 0.736374497413635f, -0.440598547458649f, 0.736036539077759f, -0.440779715776443f, - 0.735698342323303f, -0.440960645675659f, 0.735360085964203f, -0.441141277551651f, - 0.735021650791168f, -0.441321671009064f, 0.734683096408844f, -0.441501796245575f, - 0.734344422817230f, -0.441681683063507f, 0.734005570411682f, -0.441861271858215f, - 0.733666598796844f, -0.442040622234344f, 0.733327507972717f, -0.442219734191895f, - 0.732988238334656f, -0.442398548126221f, 0.732648849487305f, -0.442577123641968f, - 0.732309341430664f, -0.442755430936813f, 0.731969714164734f, -0.442933470010757f, - 0.731629908084869f, -0.443111270666122f, 0.731289982795715f, -0.443288803100586f, - 0.730949878692627f, -0.443466067314148f, 0.730609714984894f, -0.443643063306808f, - 0.730269372463226f, -0.443819820880890f, 0.729928910732269f, -0.443996280431747f, - 0.729588270187378f, -0.444172531366348f, 0.729247510433197f, -0.444348484277725f, - 0.728906631469727f, -0.444524168968201f, 0.728565633296967f, -0.444699615240097f, - 0.728224515914917f, -0.444874793291092f, 0.727883219718933f, -0.445049703121185f, - 0.727541804313660f, -0.445224374532700f, 0.727200269699097f, -0.445398747920990f, - 0.726858556270599f, -0.445572882890701f, 0.726516723632813f, -0.445746749639511f, - 0.726174771785736f, -0.445920348167419f, 0.725832700729370f, -0.446093708276749f, - 0.725490510463715f, -0.446266770362854f, 0.725148141384125f, -0.446439594030380f, - 0.724805653095245f, -0.446612149477005f, 0.724463045597076f, -0.446784436702728f, - 0.724120318889618f, -0.446956485509872f, 0.723777413368225f, -0.447128236293793f, - 0.723434448242188f, -0.447299748659134f, 0.723091304302216f, -0.447470992803574f, - 0.722747981548309f, -0.447641968727112f, 0.722404599189758f, -0.447812676429749f, - 0.722061097621918f, -0.447983115911484f, 0.721717417240143f, -0.448153316974640f, - 0.721373617649078f, -0.448323249816895f, 0.721029698848724f, -0.448492884635925f, - 0.720685660839081f, -0.448662281036377f, 0.720341444015503f, -0.448831409215927f, - 0.719997107982636f, -0.449000298976898f, 0.719652712345123f, -0.449168890714645f, - 0.719308137893677f, -0.449337244033813f, 0.718963444232941f, -0.449505299329758f, - 0.718618571758270f, -0.449673116207123f, 0.718273639678955f, -0.449840664863586f, - 0.717928528785706f, -0.450007945299149f, 0.717583298683167f, -0.450174957513809f, - 0.717238008975983f, -0.450341701507568f, 0.716892480850220f, -0.450508207082748f, - 0.716546893119812f, -0.450674414634705f, 0.716201186180115f, -0.450840383768082f, - 0.715855300426483f, -0.451006084680557f, 0.715509355068207f, -0.451171487569809f, - 0.715163230895996f, -0.451336652040482f, 0.714816987514496f, -0.451501548290253f, - 0.714470624923706f, -0.451666176319122f, 0.714124143123627f, -0.451830536127090f, - 0.713777542114258f, -0.451994657516479f, 0.713430821895599f, -0.452158480882645f, - 0.713083922863007f, -0.452322036027908f, 0.712736964225769f, -0.452485352754593f, - 0.712389826774597f, -0.452648371458054f, 0.712042629718781f, -0.452811151742935f, - 0.711695253849030f, -0.452973634004593f, 0.711347758769989f, -0.453135877847672f, - 0.711000144481659f, -0.453297853469849f, 0.710652410984039f, -0.453459560871124f, - 0.710304558277130f, -0.453621000051498f, 0.709956526756287f, -0.453782171010971f, - 0.709608435630798f, -0.453943043947220f, 0.709260225296021f, -0.454103678464890f, - 0.708911836147308f, -0.454264044761658f, 0.708563387393951f, -0.454424172639847f, - 0.708214759826660f, -0.454584002494812f, 0.707866072654724f, -0.454743564128876f, - 0.707517206668854f, -0.454902857542038f, 0.707168221473694f, -0.455061882734299f, - 0.706819176673889f, -0.455220639705658f, 0.706469953060150f, -0.455379128456116f, - 0.706120610237122f, -0.455537378787994f, 0.705771148204803f, -0.455695331096649f, - 0.705421566963196f, -0.455853015184402f, 0.705071866512299f, -0.456010431051254f, - 0.704722046852112f, -0.456167578697205f, 0.704372167587280f, -0.456324487924576f, - 0.704022109508514f, -0.456481099128723f, 0.703671932220459f, -0.456637442111969f, - 0.703321635723114f, -0.456793516874313f, 0.702971220016479f, -0.456949323415756f, - 0.702620685100555f, -0.457104891538620f, 0.702270030975342f, -0.457260161638260f, - 0.701919257640839f, -0.457415163516998f, 0.701568365097046f, -0.457569897174835f, - 0.701217353343964f, -0.457724362611771f, 0.700866222381592f, -0.457878559827805f, - 0.700514972209930f, -0.458032488822937f, 0.700163602828979f, -0.458186149597168f, - 0.699812114238739f, -0.458339542150497f, 0.699460506439209f, -0.458492636680603f, - 0.699108779430389f, -0.458645492792130f, 0.698756933212280f, -0.458798080682755f, - 0.698404967784882f, -0.458950400352478f, 0.698052942752838f, -0.459102421998978f, - 0.697700738906860f, -0.459254205226898f, 0.697348415851593f, -0.459405690431595f, - 0.696996033191681f, -0.459556937217712f, 0.696643471717834f, -0.459707885980606f, - 0.696290850639343f, -0.459858566522598f, 0.695938050746918f, -0.460008978843689f, - 0.695585191249847f, -0.460159152746201f, 0.695232212543488f, -0.460309028625488f, - 0.694879114627838f, -0.460458606481552f, 0.694525837898254f, -0.460607945919037f, - 0.694172501564026f, -0.460757017135620f, 0.693819046020508f, -0.460905820131302f, - 0.693465530872345f, -0.461054325103760f, 0.693111836910248f, -0.461202591657639f, - 0.692758023738861f, -0.461350560188293f, 0.692404091358185f, -0.461498260498047f, - 0.692050099372864f, -0.461645722389221f, 0.691695988178253f, -0.461792886257172f, - 0.691341698169708f, -0.461939752101898f, 0.690987348556519f, -0.462086379528046f, - 0.690632879734039f, -0.462232738733292f, 0.690278291702271f, -0.462378799915314f, - 0.689923584461212f, -0.462524622678757f, 0.689568817615509f, -0.462670147418976f, - 0.689213871955872f, -0.462815403938293f, 0.688858866691589f, -0.462960392236710f, - 0.688503682613373f, -0.463105112314224f, 0.688148438930511f, -0.463249564170837f, - 0.687793076038361f, -0.463393747806549f, 0.687437593936920f, -0.463537633419037f, - 0.687082052230835f, -0.463681250810623f, 0.686726331710815f, -0.463824629783630f, - 0.686370551586151f, -0.463967710733414f, 0.686014592647552f, -0.464110493659973f, - 0.685658574104309f, -0.464253038167953f, 0.685302436351776f, -0.464395314455032f, - 0.684946238994598f, -0.464537292718887f, 0.684589862823486f, -0.464679002761841f, - 0.684233427047729f, -0.464820444583893f, 0.683876872062683f, -0.464961618185043f, - 0.683520197868347f, -0.465102523565292f, 0.683163404464722f, -0.465243130922318f, - 0.682806491851807f, -0.465383470058441f, 0.682449519634247f, -0.465523540973663f, - 0.682092368602753f, -0.465663343667984f, 0.681735157966614f, -0.465802878141403f, - 0.681377887725830f, -0.465942144393921f, 0.681020438671112f, -0.466081112623215f, - 0.680662930011749f, -0.466219812631607f, 0.680305242538452f, -0.466358244419098f, - 0.679947495460510f, -0.466496407985687f, 0.679589688777924f, -0.466634273529053f, - 0.679231703281403f, -0.466771900653839f, 0.678873658180237f, -0.466909229755402f, - 0.678515493869781f, -0.467046260833740f, 0.678157210350037f, -0.467183053493500f, - 0.677798807621002f, -0.467319577932358f, 0.677440345287323f, -0.467455804347992f, - 0.677081763744354f, -0.467591762542725f, 0.676723062992096f, -0.467727422714233f, - 0.676364302635193f, -0.467862844467163f, 0.676005363464355f, -0.467997968196869f, - 0.675646364688873f, -0.468132823705673f, 0.675287246704102f, -0.468267410993576f, - 0.674928069114685f, -0.468401730060577f, 0.674568772315979f, -0.468535751104355f, - 0.674209356307983f, -0.468669503927231f, 0.673849821090698f, -0.468802988529205f, - 0.673490226268768f, -0.468936175107956f, 0.673130512237549f, -0.469069123268127f, - 0.672770678997040f, -0.469201773405075f, 0.672410726547241f, -0.469334155321121f, - 0.672050714492798f, -0.469466239213943f, 0.671690583229065f, -0.469598054885864f, - 0.671330332756042f, -0.469729602336884f, 0.670970022678375f, -0.469860881567001f, - 0.670609593391418f, -0.469991862773895f, 0.670249044895172f, -0.470122605562210f, - 0.669888436794281f, -0.470253020524979f, 0.669527709484100f, -0.470383197069168f, - 0.669166862964630f, -0.470513075590134f, 0.668805956840515f, -0.470642685890198f, - 0.668444931507111f, -0.470772027969360f, 0.668083786964417f, -0.470901101827621f, - 0.667722582817078f, -0.471029877662659f, 0.667361259460449f, -0.471158385276794f, - 0.666999816894531f, -0.471286594867706f, 0.666638314723969f, -0.471414536237717f, - 0.666276693344116f, -0.471542209386826f, 0.665914952754974f, -0.471669614315033f, - 0.665553152561188f, -0.471796721220016f, 0.665191233158112f, -0.471923559904099f, - 0.664829254150391f, -0.472050130367279f, 0.664467096328735f, -0.472176402807236f, - 0.664104938507080f, -0.472302407026291f, 0.663742601871490f, -0.472428143024445f, - 0.663380205631256f, -0.472553610801697f, 0.663017749786377f, -0.472678780555725f, - 0.662655174732208f, -0.472803652286530f, 0.662292480468750f, -0.472928285598755f, - 0.661929666996002f, -0.473052620887756f, 0.661566793918610f, -0.473176687955856f, - 0.661203861236572f, -0.473300457000732f, 0.660840749740601f, -0.473423957824707f, - 0.660477638244629f, -0.473547190427780f, 0.660114347934723f, -0.473670125007629f, - 0.659750998020172f, -0.473792791366577f, 0.659387588500977f, -0.473915189504623f, - 0.659024059772491f, -0.474037289619446f, 0.658660411834717f, -0.474159121513367f, - 0.658296704292297f, -0.474280685186386f, 0.657932877540588f, -0.474401950836182f, - 0.657568991184235f, -0.474522948265076f, 0.657204985618591f, -0.474643647670746f, - 0.656840860843658f, -0.474764078855515f, 0.656476676464081f, -0.474884241819382f, - 0.656112432479858f, -0.475004136562347f, 0.655748009681702f, -0.475123733282089f, - 0.655383586883545f, -0.475243031978607f, 0.655019044876099f, -0.475362062454224f, - 0.654654383659363f, -0.475480824708939f, 0.654289662837982f, -0.475599318742752f, - 0.653924822807312f, -0.475717514753342f, 0.653559923171997f, -0.475835442543030f, - 0.653194904327393f, -0.475953072309494f, 0.652829825878143f, -0.476070433855057f, - 0.652464628219604f, -0.476187497377396f, 0.652099311351776f, -0.476304292678833f, - 0.651733994483948f, -0.476420819759369f, 0.651368498802185f, -0.476537048816681f, - 0.651003003120422f, -0.476653009653091f, 0.650637328624725f, -0.476768702268600f, - 0.650271594524384f, -0.476884096860886f, 0.649905800819397f, -0.476999223232269f, - 0.649539887905121f, -0.477114051580429f, 0.649173915386200f, -0.477228611707687f, - 0.648807883262634f, -0.477342873811722f, 0.648441672325134f, -0.477456867694855f, - 0.648075461387634f, -0.477570593357086f, 0.647709131240845f, -0.477684020996094f, - 0.647342681884766f, -0.477797180414200f, 0.646976172924042f, -0.477910041809082f, - 0.646609604358673f, -0.478022634983063f, 0.646242916584015f, -0.478134930133820f, - 0.645876109600067f, -0.478246957063675f, 0.645509302616119f, -0.478358715772629f, - 0.645142316818237f, -0.478470176458359f, 0.644775331020355f, -0.478581339120865f, - 0.644408226013184f, -0.478692263364792f, 0.644041001796722f, -0.478802859783173f, - 0.643673717975616f, -0.478913217782974f, 0.643306374549866f, -0.479023247957230f, - 0.642938911914825f, -0.479133039712906f, 0.642571389675140f, -0.479242533445358f, - 0.642203748226166f, -0.479351729154587f, 0.641836047172546f, -0.479460656642914f, - 0.641468286514282f, -0.479569315910339f, 0.641100406646729f, -0.479677677154541f, - 0.640732467174530f, -0.479785770177841f, 0.640364408493042f, -0.479893565177917f, - 0.639996349811554f, -0.480001062154770f, 0.639628112316132f, -0.480108320713043f, - 0.639259815216064f, -0.480215251445770f, 0.638891458511353f, -0.480321943759918f, - 0.638523042201996f, -0.480428308248520f, 0.638154506683350f, -0.480534434318542f, - 0.637785911560059f, -0.480640232563019f, 0.637417197227478f, -0.480745792388916f, - 0.637048482894897f, -0.480851024389267f, 0.636679589748383f, -0.480956017971039f, - 0.636310696601868f, -0.481060713529587f, 0.635941684246063f, -0.481165111064911f, - 0.635572552680969f, -0.481269240379334f, 0.635203421115875f, -0.481373071670532f, - 0.634834170341492f, -0.481476634740829f, 0.634464859962463f, -0.481579899787903f, - 0.634095430374146f, -0.481682896614075f, 0.633725941181183f, -0.481785595417023f, - 0.633356392383575f, -0.481888025999069f, 0.632986724376678f, -0.481990188360214f, - 0.632616996765137f, -0.482092022895813f, 0.632247209548950f, -0.482193619012833f, - 0.631877362728119f, -0.482294887304306f, 0.631507396697998f, -0.482395917177200f, - 0.631137371063232f, -0.482496619224548f, 0.630767226219177f, -0.482597053050995f, - 0.630397081375122f, -0.482697218656540f, 0.630026817321777f, -0.482797086238861f, - 0.629656434059143f, -0.482896685600281f, 0.629286050796509f, -0.482995986938477f, - 0.628915548324585f, -0.483094990253448f, 0.628544986248016f, -0.483193725347519f, - 0.628174364566803f, -0.483292192220688f, 0.627803623676300f, -0.483390361070633f, - 0.627432823181152f, -0.483488231897354f, 0.627061963081360f, -0.483585834503174f, - 0.626691043376923f, -0.483683139085770f, 0.626320004463196f, -0.483780175447464f, - 0.625948905944824f, -0.483876913785934f, 0.625577747821808f, -0.483973383903503f, - 0.625206530094147f, -0.484069555997849f, 0.624835193157196f, -0.484165430068970f, - 0.624463796615601f, -0.484261035919189f, 0.624092340469360f, -0.484356373548508f, - 0.623720824718475f, -0.484451413154602f, 0.623349189758301f, -0.484546154737473f, - 0.622977554798126f, -0.484640628099442f, 0.622605800628662f, -0.484734803438187f, - 0.622233927249908f, -0.484828680753708f, 0.621862053871155f, -0.484922289848328f, - 0.621490061283112f, -0.485015630722046f, 0.621118068695068f, -0.485108673572540f, - 0.620745956897736f, -0.485201418399811f, 0.620373785495758f, -0.485293895006180f, - 0.620001494884491f, -0.485386073589325f, 0.619629204273224f, -0.485477954149246f, - 0.619256794452667f, -0.485569566488266f, 0.618884325027466f, -0.485660910606384f, - 0.618511795997620f, -0.485751956701279f, 0.618139207363129f, -0.485842704772949f, - 0.617766559123993f, -0.485933154821396f, 0.617393791675568f, -0.486023366451263f, - 0.617020964622498f, -0.486113250255585f, 0.616648077964783f, -0.486202865839005f, - 0.616275131702423f, -0.486292183399200f, 0.615902125835419f, -0.486381232738495f, - 0.615529060363770f, -0.486469984054565f, 0.615155875682831f, -0.486558437347412f, - 0.614782691001892f, -0.486646622419357f, 0.614409387111664f, -0.486734509468079f, - 0.614036023616791f, -0.486822128295898f, 0.613662600517273f, -0.486909449100494f, - 0.613289117813110f, -0.486996471881866f, 0.612915575504303f, -0.487083226442337f, - 0.612541973590851f, -0.487169682979584f, 0.612168252468109f, -0.487255871295929f, - 0.611794531345367f, -0.487341761589050f, 0.611420691013336f, -0.487427353858948f, - 0.611046791076660f, -0.487512677907944f, 0.610672831535339f, -0.487597703933716f, - 0.610298871994019f, -0.487682431936264f, 0.609924793243408f, -0.487766891717911f, - 0.609550595283508f, -0.487851053476334f, 0.609176397323608f, -0.487934947013855f, - 0.608802139759064f, -0.488018542528152f, 0.608427822589874f, -0.488101840019226f, - 0.608053386211395f, -0.488184869289398f, 0.607678949832916f, -0.488267600536346f, - 0.607304394245148f, -0.488350033760071f, 0.606929838657379f, -0.488432198762894f, - 0.606555163860321f, -0.488514065742493f, 0.606180429458618f, -0.488595664501190f, - 0.605805635452271f, -0.488676935434341f, 0.605430841445923f, -0.488757967948914f, - 0.605055928230286f, -0.488838672637939f, 0.604680955410004f, -0.488919109106064f, - 0.604305922985077f, -0.488999247550964f, 0.603930830955505f, -0.489079117774963f, - 0.603555679321289f, -0.489158689975739f, 0.603180468082428f, -0.489237964153290f, - 0.602805197238922f, -0.489316970109940f, 0.602429866790771f, -0.489395678043365f, - 0.602054476737976f, -0.489474087953568f, 0.601679027080536f, -0.489552229642868f, - 0.601303517818451f, -0.489630073308945f, 0.600927948951721f, -0.489707618951797f, - 0.600552320480347f, -0.489784896373749f, 0.600176632404327f, -0.489861875772476f, - 0.599800884723663f, -0.489938557147980f, 0.599425077438354f, -0.490014940500259f, - 0.599049210548401f, -0.490091055631638f, 0.598673284053802f, -0.490166902542114f, - 0.598297297954559f, -0.490242421627045f, 0.597921252250671f, -0.490317672491074f, - 0.597545146942139f, -0.490392625331879f, 0.597168982028961f, -0.490467309951782f, - 0.596792817115784f, -0.490541696548462f, 0.596416532993317f, -0.490615785121918f, - 0.596040189266205f, -0.490689605474472f, 0.595663845539093f, -0.490763127803802f, - 0.595287382602692f, -0.490836352109909f, 0.594910860061646f, -0.490909278392792f, - 0.594534337520599f, -0.490981936454773f, 0.594157755374908f, -0.491054296493530f, - 0.593781054019928f, -0.491126358509064f, 0.593404352664948f, -0.491198152303696f, - 0.593027591705322f, -0.491269648075104f, 0.592650771141052f, -0.491340845823288f, - 0.592273890972137f, -0.491411775350571f, 0.591896951198578f, -0.491482406854630f, - 0.591519951820374f, -0.491552740335464f, 0.591142892837524f, -0.491622805595398f, - 0.590765833854675f, -0.491692543029785f, 0.590388655662537f, -0.491762012243271f, - 0.590011477470398f, -0.491831213235855f, 0.589634180068970f, -0.491900116205215f, - 0.589256882667542f, -0.491968721151352f, 0.588879525661469f, -0.492037028074265f, - 0.588502109050751f, -0.492105036973953f, 0.588124632835388f, -0.492172777652740f, - 0.587747097015381f, -0.492240220308304f, 0.587369561195374f, -0.492307394742966f, - 0.586991965770721f, -0.492374241352081f, 0.586614251136780f, -0.492440819740295f, - 0.586236536502838f, -0.492507129907608f, 0.585858762264252f, -0.492573112249374f, - 0.585480928421021f, -0.492638826370239f, 0.585103094577789f, -0.492704242467880f, - 0.584725141525269f, -0.492769360542297f, 0.584347188472748f, -0.492834210395813f, - 0.583969175815582f, -0.492898762226105f, 0.583591103553772f, -0.492963016033173f, - 0.583212971687317f, -0.493026971817017f, 0.582834780216217f, -0.493090659379959f, - 0.582456588745117f, -0.493154048919678f, 0.582078278064728f, -0.493217140436172f, - 0.581699967384338f, -0.493279963731766f, 0.581321597099304f, -0.493342459201813f, - 0.580943167209625f, -0.493404686450958f, 0.580564737319946f, -0.493466645479202f, - 0.580186247825623f, -0.493528276681900f, 0.579807698726654f, -0.493589639663696f, - 0.579429090023041f, -0.493650704622269f, 0.579050421714783f, -0.493711471557617f, - 0.578671753406525f, -0.493771970272064f, 0.578292965888977f, -0.493832170963287f, - 0.577914178371429f, -0.493892073631287f, 0.577535390853882f, -0.493951678276062f, - 0.577156484127045f, -0.494011014699936f, 0.576777577400208f, -0.494070053100586f, - 0.576398611068726f, -0.494128793478012f, 0.576019585132599f, -0.494187235832214f, - 0.575640499591827f, -0.494245409965515f, 0.575261414051056f, -0.494303256273270f, - 0.574882268905640f, -0.494360834360123f, 0.574503064155579f, -0.494418144226074f, - 0.574123859405518f, -0.494475126266479f, 0.573744535446167f, -0.494531840085983f, - 0.573365211486816f, -0.494588255882263f, 0.572985887527466f, -0.494644373655319f, - 0.572606444358826f, -0.494700223207474f, 0.572227001190186f, -0.494755744934082f, - 0.571847498416901f, -0.494810998439789f, 0.571467995643616f, -0.494865983724594f, - 0.571088373661041f, -0.494920641183853f, 0.570708811283112f, -0.494975030422211f, - 0.570329129695892f, -0.495029091835022f, 0.569949388504028f, -0.495082914829254f, - 0.569569647312164f, -0.495136409997940f, 0.569189906120300f, -0.495189607143402f, - 0.568810045719147f, -0.495242536067963f, 0.568430185317993f, -0.495295166969299f, - 0.568050265312195f, -0.495347499847412f, 0.567670345306396f, -0.495399564504623f, - 0.567290365695953f, -0.495451331138611f, 0.566910326480865f, -0.495502769947052f, - 0.566530287265778f, -0.495553970336914f, 0.566150128841400f, -0.495604842901230f, - 0.565770030021667f, -0.495655417442322f, 0.565389811992645f, -0.495705723762512f, - 0.565009593963623f, -0.495755732059479f, 0.564629375934601f, -0.495805442333221f, - 0.564249038696289f, -0.495854884386063f, 0.563868701457977f, -0.495903998613358f, - 0.563488364219666f, -0.495952844619751f, 0.563107967376709f, -0.496001392602921f, - 0.562727510929108f, -0.496049642562866f, 0.562346994876862f, -0.496097624301910f, - 0.561966478824615f, -0.496145308017731f, 0.561585903167725f, -0.496192663908005f, - 0.561205327510834f, -0.496239781379700f, 0.560824692249298f, -0.496286571025848f, - 0.560444056987762f, -0.496333062648773f, 0.560063362121582f, -0.496379286050797f, - 0.559682607650757f, -0.496425211429596f, 0.559301853179932f, -0.496470838785172f, - 0.558921039104462f, -0.496516168117523f, 0.558540165424347f, -0.496561229228973f, - 0.558159291744232f, -0.496605962514877f, 0.557778418064117f, -0.496650427579880f, - 0.557397484779358f, -0.496694594621658f, 0.557016491889954f, -0.496738493442535f, - 0.556635499000549f, -0.496782064437866f, 0.556254446506500f, -0.496825367212296f, - 0.555873334407806f, -0.496868371963501f, 0.555492222309113f, -0.496911078691483f, - 0.555111110210419f, -0.496953487396240f, 0.554729938507080f, -0.496995598077774f, - 0.554348707199097f, -0.497037440538406f, 0.553967475891113f, -0.497078984975815f, - 0.553586184978485f, -0.497120231389999f, 0.553204894065857f, -0.497161179780960f, - 0.552823603153229f, -0.497201830148697f, 0.552442193031311f, -0.497242212295532f, - 0.552060842514038f, -0.497282296419144f, 0.551679372787476f, -0.497322082519531f, - 0.551297962665558f, -0.497361570596695f, 0.550916433334351f, -0.497400760650635f, - 0.550534904003143f, -0.497439652681351f, 0.550153374671936f, -0.497478276491165f, - 0.549771785736084f, -0.497516602277756f, 0.549390196800232f, -0.497554630041122f, - 0.549008548259735f, -0.497592359781265f, 0.548626899719238f, -0.497629791498184f, - 0.548245191574097f, -0.497666954994202f, 0.547863483428955f, -0.497703820466995f, - 0.547481775283813f, -0.497740387916565f, 0.547099947929382f, -0.497776657342911f, - 0.546718180179596f, -0.497812628746033f, 0.546336352825165f, -0.497848302125931f, - 0.545954465866089f, -0.497883707284927f, 0.545572578907013f, -0.497918814420700f, - 0.545190691947937f, -0.497953623533249f, 0.544808745384216f, -0.497988134622574f, - 0.544426798820496f, -0.498022347688675f, 0.544044792652130f, -0.498056292533875f, - 0.543662786483765f, -0.498089909553528f, 0.543280720710754f, -0.498123258352280f, - 0.542898654937744f, -0.498156309127808f, 0.542516589164734f, -0.498189061880112f, - 0.542134463787079f, -0.498221516609192f, 0.541752278804779f, -0.498253703117371f, - 0.541370153427124f, -0.498285561800003f, 0.540987968444824f, -0.498317152261734f, - 0.540605723857880f, -0.498348444700241f, 0.540223479270935f, -0.498379439115524f, - 0.539841234683990f, -0.498410135507584f, 0.539458930492401f, -0.498440563678741f, - 0.539076626300812f, -0.498470664024353f, 0.538694262504578f, -0.498500496149063f, - 0.538311958312988f, -0.498530030250549f, 0.537929534912109f, -0.498559266328812f, - 0.537547171115875f, -0.498588204383850f, 0.537164747714996f, -0.498616874217987f, - 0.536782264709473f, -0.498645216226578f, 0.536399841308594f, -0.498673290014267f, - 0.536017298698425f, -0.498701065778732f, 0.535634815692902f, -0.498728543519974f, - 0.535252273082733f, -0.498755723237991f, 0.534869730472565f, -0.498782604932785f, - 0.534487187862396f, -0.498809218406677f, 0.534104585647583f, -0.498835533857346f, - 0.533721983432770f, -0.498861521482468f, 0.533339321613312f, -0.498887240886688f, - 0.532956659793854f, -0.498912662267685f, 0.532573997974396f, -0.498937815427780f, - 0.532191336154938f, -0.498962640762329f, 0.531808614730835f, -0.498987197875977f, - 0.531425893306732f, -0.499011427164078f, 0.531043112277985f, -0.499035388231277f, - 0.530660390853882f, -0.499059051275253f, 0.530277609825134f, -0.499082416296005f, - 0.529894769191742f, -0.499105513095856f, 0.529511988162994f, -0.499128282070160f, - 0.529129147529602f, -0.499150782823563f, 0.528746306896210f, -0.499172955751419f, - 0.528363406658173f, -0.499194860458374f, 0.527980506420136f, -0.499216467142105f, - 0.527597606182098f, -0.499237775802612f, 0.527214705944061f, -0.499258816242218f, - 0.526831746101379f, -0.499279528856277f, 0.526448845863342f, -0.499299973249435f, - 0.526065826416016f, -0.499320119619370f, 0.525682866573334f, -0.499339967966080f, - 0.525299847126007f, -0.499359518289566f, 0.524916887283325f, -0.499378770589828f, - 0.524533808231354f, -0.499397724866867f, 0.524150788784027f, -0.499416410923004f, - 0.523767769336700f, -0.499434769153595f, 0.523384690284729f, -0.499452859163284f, - 0.523001611232758f, -0.499470651149750f, 0.522618472576141f, -0.499488145112991f, - 0.522235393524170f, -0.499505341053009f, 0.521852254867554f, -0.499522238969803f, - 0.521469116210938f, -0.499538868665695f, 0.521085977554321f, -0.499555170536041f, - 0.520702838897705f, -0.499571204185486f, 0.520319640636444f, -0.499586939811707f, - 0.519936442375183f, -0.499602377414703f, 0.519553244113922f, -0.499617516994476f, - 0.519170045852661f, -0.499632388353348f, 0.518786847591400f, -0.499646931886673f, - 0.518403589725494f, -0.499661177396774f, 0.518020391464233f, -0.499675154685974f, - 0.517637133598328f, -0.499688833951950f, 0.517253875732422f, -0.499702215194702f, - 0.516870558261871f, -0.499715298414230f, 0.516487300395966f, -0.499728083610535f, - 0.516103982925415f, -0.499740600585938f, 0.515720725059509f, -0.499752789735794f, - 0.515337407588959f, -0.499764710664749f, 0.514954090118408f, -0.499776333570480f, - 0.514570772647858f, -0.499787658452988f, 0.514187395572662f, -0.499798685312271f, - 0.513804078102112f, -0.499809414148331f, 0.513420701026917f, -0.499819844961166f, - 0.513037383556366f, -0.499830007553101f, 0.512654006481171f, -0.499839842319489f, - 0.512270629405975f, -0.499849408864975f, 0.511887252330780f, -0.499858677387238f, - 0.511503815650940f, -0.499867647886276f, 0.511120438575745f, -0.499876320362091f, - 0.510737061500549f, -0.499884694814682f, 0.510353624820709f, -0.499892801046371f, - 0.509970188140869f, -0.499900579452515f, 0.509586811065674f, -0.499908089637756f, - 0.509203374385834f, -0.499915301799774f, 0.508819937705994f, -0.499922215938568f, - 0.508436501026154f, -0.499928832054138f, 0.508053064346313f, -0.499935150146484f, - 0.507669627666473f, -0.499941170215607f, 0.507286131381989f, -0.499946922063828f, - 0.506902694702148f, -0.499952346086502f, 0.506519258022308f, -0.499957501888275f, - 0.506135761737823f, -0.499962359666824f, 0.505752325057983f, -0.499966919422150f, - 0.505368828773499f, -0.499971181154251f, 0.504985332489014f, -0.499975144863129f, - 0.504601895809174f, -0.499978810548782f, 0.504218399524689f, -0.499982208013535f, - 0.503834903240204f, -0.499985307455063f, 0.503451406955719f, -0.499988079071045f, - 0.503067970275879f, -0.499990582466125f, 0.502684473991394f, -0.499992787837982f, - 0.502300977706909f, -0.499994695186615f, 0.501917481422424f, -0.499996334314346f, - 0.501533985137939f, -0.499997645616531f, 0.501150488853455f, -0.499998688697815f, - 0.500766992568970f, -0.499999403953552f, 0.500383496284485f, -0.499999850988388f, + 0.500000000000000f, 0.500000000000000f, 0.500383496284485f, + 0.499999850988388f, 0.500766992568970f, 0.499999403953552f, + 0.501150488853455f, 0.499998688697815f, 0.501533985137939f, + 0.499997645616531f, 0.501917481422424f, 0.499996334314346f, + 0.502300977706909f, 0.499994695186615f, 0.502684473991394f, + 0.499992787837982f, 0.503067970275879f, 0.499990582466125f, + 0.503451406955719f, 0.499988079071045f, 0.503834903240204f, + 0.499985307455063f, 0.504218399524689f, 0.499982208013535f, + 0.504601895809174f, 0.499978810548782f, 0.504985332489014f, + 0.499975144863129f, 0.505368828773499f, 0.499971181154251f, + 0.505752325057983f, 0.499966919422150f, 0.506135761737823f, + 0.499962359666824f, 0.506519258022308f, 0.499957501888275f, + 0.506902694702148f, 0.499952346086502f, 0.507286131381989f, + 0.499946922063828f, 0.507669627666473f, 0.499941170215607f, + 0.508053064346313f, 0.499935150146484f, 0.508436501026154f, + 0.499928832054138f, 0.508819937705994f, 0.499922215938568f, + 0.509203374385834f, 0.499915301799774f, 0.509586811065674f, + 0.499908089637756f, 0.509970188140869f, 0.499900579452515f, + 0.510353624820709f, 0.499892801046371f, 0.510737061500549f, + 0.499884694814682f, 0.511120438575745f, 0.499876320362091f, + 0.511503815650940f, 0.499867647886276f, 0.511887252330780f, + 0.499858677387238f, 0.512270629405975f, 0.499849408864975f, + 0.512654006481171f, 0.499839842319489f, 0.513037383556366f, + 0.499830007553101f, 0.513420701026917f, 0.499819844961166f, + 0.513804078102112f, 0.499809414148331f, 0.514187395572662f, + 0.499798685312271f, 0.514570772647858f, 0.499787658452988f, + 0.514954090118408f, 0.499776333570480f, 0.515337407588959f, + 0.499764710664749f, 0.515720725059509f, 0.499752789735794f, + 0.516103982925415f, 0.499740600585938f, 0.516487300395966f, + 0.499728083610535f, 0.516870558261871f, 0.499715298414230f, + 0.517253875732422f, 0.499702215194702f, 0.517637133598328f, + 0.499688833951950f, 0.518020391464233f, 0.499675154685974f, + 0.518403589725494f, 0.499661177396774f, 0.518786847591400f, + 0.499646931886673f, 0.519170045852661f, 0.499632388353348f, + 0.519553244113922f, 0.499617516994476f, 0.519936442375183f, + 0.499602377414703f, 0.520319640636444f, 0.499586939811707f, + 0.520702838897705f, 0.499571204185486f, 0.521085977554321f, + 0.499555170536041f, 0.521469116210938f, 0.499538868665695f, + 0.521852254867554f, 0.499522238969803f, 0.522235393524170f, + 0.499505341053009f, 0.522618472576141f, 0.499488145112991f, + 0.523001611232758f, 0.499470651149750f, 0.523384690284729f, + 0.499452859163284f, 0.523767769336700f, 0.499434769153595f, + 0.524150788784027f, 0.499416410923004f, 0.524533808231354f, + 0.499397724866867f, 0.524916887283325f, 0.499378770589828f, + 0.525299847126007f, 0.499359518289566f, 0.525682866573334f, + 0.499339967966080f, 0.526065826416016f, 0.499320119619370f, + 0.526448845863342f, 0.499299973249435f, 0.526831746101379f, + 0.499279528856277f, 0.527214705944061f, 0.499258816242218f, + 0.527597606182098f, 0.499237775802612f, 0.527980506420136f, + 0.499216467142105f, 0.528363406658173f, 0.499194860458374f, + 0.528746306896210f, 0.499172955751419f, 0.529129147529602f, + 0.499150782823563f, 0.529511988162994f, 0.499128282070160f, + 0.529894769191742f, 0.499105513095856f, 0.530277609825134f, + 0.499082416296005f, 0.530660390853882f, 0.499059051275253f, + 0.531043112277985f, 0.499035388231277f, 0.531425893306732f, + 0.499011427164078f, 0.531808614730835f, 0.498987197875977f, + 0.532191336154938f, 0.498962640762329f, 0.532573997974396f, + 0.498937815427780f, 0.532956659793854f, 0.498912662267685f, + 0.533339321613312f, 0.498887240886688f, 0.533721983432770f, + 0.498861521482468f, 0.534104585647583f, 0.498835533857346f, + 0.534487187862396f, 0.498809218406677f, 0.534869730472565f, + 0.498782604932785f, 0.535252273082733f, 0.498755723237991f, + 0.535634815692902f, 0.498728543519974f, 0.536017298698425f, + 0.498701065778732f, 0.536399841308594f, 0.498673290014267f, + 0.536782264709473f, 0.498645216226578f, 0.537164747714996f, + 0.498616874217987f, 0.537547171115875f, 0.498588204383850f, + 0.537929534912109f, 0.498559266328812f, 0.538311958312988f, + 0.498530030250549f, 0.538694262504578f, 0.498500496149063f, + 0.539076626300812f, 0.498470664024353f, 0.539458930492401f, + 0.498440563678741f, 0.539841234683990f, 0.498410135507584f, + 0.540223479270935f, 0.498379439115524f, 0.540605723857880f, + 0.498348444700241f, 0.540987968444824f, 0.498317152261734f, + 0.541370153427124f, 0.498285561800003f, 0.541752278804779f, + 0.498253703117371f, 0.542134463787079f, 0.498221516609192f, + 0.542516589164734f, 0.498189061880112f, 0.542898654937744f, + 0.498156309127808f, 0.543280720710754f, 0.498123258352280f, + 0.543662786483765f, 0.498089909553528f, 0.544044792652130f, + 0.498056292533875f, 0.544426798820496f, 0.498022347688675f, + 0.544808745384216f, 0.497988134622574f, 0.545190691947937f, + 0.497953623533249f, 0.545572578907013f, 0.497918814420700f, + 0.545954465866089f, 0.497883707284927f, 0.546336352825165f, + 0.497848302125931f, 0.546718180179596f, 0.497812628746033f, + 0.547099947929382f, 0.497776657342911f, 0.547481775283813f, + 0.497740387916565f, 0.547863483428955f, 0.497703820466995f, + 0.548245191574097f, 0.497666954994202f, 0.548626899719238f, + 0.497629791498184f, 0.549008548259735f, 0.497592359781265f, + 0.549390196800232f, 0.497554630041122f, 0.549771785736084f, + 0.497516602277756f, 0.550153374671936f, 0.497478276491165f, + 0.550534904003143f, 0.497439652681351f, 0.550916433334351f, + 0.497400760650635f, 0.551297962665558f, 0.497361570596695f, + 0.551679372787476f, 0.497322082519531f, 0.552060842514038f, + 0.497282296419144f, 0.552442193031311f, 0.497242212295532f, + 0.552823603153229f, 0.497201830148697f, 0.553204894065857f, + 0.497161179780960f, 0.553586184978485f, 0.497120231389999f, + 0.553967475891113f, 0.497078984975815f, 0.554348707199097f, + 0.497037440538406f, 0.554729938507080f, 0.496995598077774f, + 0.555111110210419f, 0.496953487396240f, 0.555492222309113f, + 0.496911078691483f, 0.555873334407806f, 0.496868371963501f, + 0.556254446506500f, 0.496825367212296f, 0.556635499000549f, + 0.496782064437866f, 0.557016491889954f, 0.496738493442535f, + 0.557397484779358f, 0.496694594621658f, 0.557778418064117f, + 0.496650427579880f, 0.558159291744232f, 0.496605962514877f, + 0.558540165424347f, 0.496561229228973f, 0.558921039104462f, + 0.496516168117523f, 0.559301853179932f, 0.496470838785172f, + 0.559682607650757f, 0.496425211429596f, 0.560063362121582f, + 0.496379286050797f, 0.560444056987762f, 0.496333062648773f, + 0.560824692249298f, 0.496286571025848f, 0.561205327510834f, + 0.496239781379700f, 0.561585903167725f, 0.496192663908005f, + 0.561966478824615f, 0.496145308017731f, 0.562346994876862f, + 0.496097624301910f, 0.562727510929108f, 0.496049642562866f, + 0.563107967376709f, 0.496001392602921f, 0.563488364219666f, + 0.495952844619751f, 0.563868701457977f, 0.495903998613358f, + 0.564249038696289f, 0.495854884386063f, 0.564629375934601f, + 0.495805442333221f, 0.565009593963623f, 0.495755732059479f, + 0.565389811992645f, 0.495705723762512f, 0.565770030021667f, + 0.495655417442322f, 0.566150128841400f, 0.495604842901230f, + 0.566530287265778f, 0.495553970336914f, 0.566910326480865f, + 0.495502769947052f, 0.567290365695953f, 0.495451331138611f, + 0.567670345306396f, 0.495399564504623f, 0.568050265312195f, + 0.495347499847412f, 0.568430185317993f, 0.495295166969299f, + 0.568810045719147f, 0.495242536067963f, 0.569189906120300f, + 0.495189607143402f, 0.569569647312164f, 0.495136409997940f, + 0.569949388504028f, 0.495082914829254f, 0.570329129695892f, + 0.495029091835022f, 0.570708811283112f, 0.494975030422211f, + 0.571088373661041f, 0.494920641183853f, 0.571467995643616f, + 0.494865983724594f, 0.571847498416901f, 0.494810998439789f, + 0.572227001190186f, 0.494755744934082f, 0.572606444358826f, + 0.494700223207474f, 0.572985887527466f, 0.494644373655319f, + 0.573365211486816f, 0.494588255882263f, 0.573744535446167f, + 0.494531840085983f, 0.574123859405518f, 0.494475126266479f, + 0.574503064155579f, 0.494418144226074f, 0.574882268905640f, + 0.494360834360123f, 0.575261414051056f, 0.494303256273270f, + 0.575640499591827f, 0.494245409965515f, 0.576019585132599f, + 0.494187235832214f, 0.576398611068726f, 0.494128793478012f, + 0.576777577400208f, 0.494070053100586f, 0.577156484127045f, + 0.494011014699936f, 0.577535390853882f, 0.493951678276062f, + 0.577914178371429f, 0.493892073631287f, 0.578292965888977f, + 0.493832170963287f, 0.578671753406525f, 0.493771970272064f, + 0.579050421714783f, 0.493711471557617f, 0.579429090023041f, + 0.493650704622269f, 0.579807698726654f, 0.493589639663696f, + 0.580186247825623f, 0.493528276681900f, 0.580564737319946f, + 0.493466645479202f, 0.580943167209625f, 0.493404686450958f, + 0.581321597099304f, 0.493342459201813f, 0.581699967384338f, + 0.493279963731766f, 0.582078278064728f, 0.493217140436172f, + 0.582456588745117f, 0.493154048919678f, 0.582834780216217f, + 0.493090659379959f, 0.583212971687317f, 0.493026971817017f, + 0.583591103553772f, 0.492963016033173f, 0.583969175815582f, + 0.492898762226105f, 0.584347188472748f, 0.492834210395813f, + 0.584725141525269f, 0.492769360542297f, 0.585103094577789f, + 0.492704242467880f, 0.585480928421021f, 0.492638826370239f, + 0.585858762264252f, 0.492573112249374f, 0.586236536502838f, + 0.492507129907608f, 0.586614251136780f, 0.492440819740295f, + 0.586991965770721f, 0.492374241352081f, 0.587369561195374f, + 0.492307394742966f, 0.587747097015381f, 0.492240220308304f, + 0.588124632835388f, 0.492172777652740f, 0.588502109050751f, + 0.492105036973953f, 0.588879525661469f, 0.492037028074265f, + 0.589256882667542f, 0.491968721151352f, 0.589634180068970f, + 0.491900116205215f, 0.590011477470398f, 0.491831213235855f, + 0.590388655662537f, 0.491762012243271f, 0.590765833854675f, + 0.491692543029785f, 0.591142892837524f, 0.491622805595398f, + 0.591519951820374f, 0.491552740335464f, 0.591896951198578f, + 0.491482406854630f, 0.592273890972137f, 0.491411775350571f, + 0.592650771141052f, 0.491340845823288f, 0.593027591705322f, + 0.491269648075104f, 0.593404352664948f, 0.491198152303696f, + 0.593781054019928f, 0.491126358509064f, 0.594157755374908f, + 0.491054296493530f, 0.594534337520599f, 0.490981936454773f, + 0.594910860061646f, 0.490909278392792f, 0.595287382602692f, + 0.490836352109909f, 0.595663845539093f, 0.490763127803802f, + 0.596040189266205f, 0.490689605474472f, 0.596416532993317f, + 0.490615785121918f, 0.596792817115784f, 0.490541696548462f, + 0.597168982028961f, 0.490467309951782f, 0.597545146942139f, + 0.490392625331879f, 0.597921252250671f, 0.490317672491074f, + 0.598297297954559f, 0.490242421627045f, 0.598673284053802f, + 0.490166902542114f, 0.599049210548401f, 0.490091055631638f, + 0.599425077438354f, 0.490014940500259f, 0.599800884723663f, + 0.489938557147980f, 0.600176632404327f, 0.489861875772476f, + 0.600552320480347f, 0.489784896373749f, 0.600927948951721f, + 0.489707618951797f, 0.601303517818451f, 0.489630073308945f, + 0.601679027080536f, 0.489552229642868f, 0.602054476737976f, + 0.489474087953568f, 0.602429866790771f, 0.489395678043365f, + 0.602805197238922f, 0.489316970109940f, 0.603180468082428f, + 0.489237964153290f, 0.603555679321289f, 0.489158689975739f, + 0.603930830955505f, 0.489079117774963f, 0.604305922985077f, + 0.488999247550964f, 0.604680955410004f, 0.488919109106064f, + 0.605055928230286f, 0.488838672637939f, 0.605430841445923f, + 0.488757967948914f, 0.605805635452271f, 0.488676935434341f, + 0.606180429458618f, 0.488595664501190f, 0.606555163860321f, + 0.488514065742493f, 0.606929838657379f, 0.488432198762894f, + 0.607304394245148f, 0.488350033760071f, 0.607678949832916f, + 0.488267600536346f, 0.608053386211395f, 0.488184869289398f, + 0.608427822589874f, 0.488101840019226f, 0.608802139759064f, + 0.488018542528152f, 0.609176397323608f, 0.487934947013855f, + 0.609550595283508f, 0.487851053476334f, 0.609924793243408f, + 0.487766891717911f, 0.610298871994019f, 0.487682431936264f, + 0.610672831535339f, 0.487597703933716f, 0.611046791076660f, + 0.487512677907944f, 0.611420691013336f, 0.487427353858948f, + 0.611794531345367f, 0.487341761589050f, 0.612168252468109f, + 0.487255871295929f, 0.612541973590851f, 0.487169682979584f, + 0.612915575504303f, 0.487083226442337f, 0.613289117813110f, + 0.486996471881866f, 0.613662600517273f, 0.486909449100494f, + 0.614036023616791f, 0.486822128295898f, 0.614409387111664f, + 0.486734509468079f, 0.614782691001892f, 0.486646622419357f, + 0.615155875682831f, 0.486558437347412f, 0.615529060363770f, + 0.486469984054565f, 0.615902125835419f, 0.486381232738495f, + 0.616275131702423f, 0.486292183399200f, 0.616648077964783f, + 0.486202865839005f, 0.617020964622498f, 0.486113250255585f, + 0.617393791675568f, 0.486023366451263f, 0.617766559123993f, + 0.485933154821396f, 0.618139207363129f, 0.485842704772949f, + 0.618511795997620f, 0.485751956701279f, 0.618884325027466f, + 0.485660910606384f, 0.619256794452667f, 0.485569566488266f, + 0.619629204273224f, 0.485477954149246f, 0.620001494884491f, + 0.485386073589325f, 0.620373785495758f, 0.485293895006180f, + 0.620745956897736f, 0.485201418399811f, 0.621118068695068f, + 0.485108673572540f, 0.621490061283112f, 0.485015630722046f, + 0.621862053871155f, 0.484922289848328f, 0.622233927249908f, + 0.484828680753708f, 0.622605800628662f, 0.484734803438187f, + 0.622977554798126f, 0.484640628099442f, 0.623349189758301f, + 0.484546154737473f, 0.623720824718475f, 0.484451413154602f, + 0.624092340469360f, 0.484356373548508f, 0.624463796615601f, + 0.484261035919189f, 0.624835193157196f, 0.484165430068970f, + 0.625206530094147f, 0.484069555997849f, 0.625577747821808f, + 0.483973383903503f, 0.625948905944824f, 0.483876913785934f, + 0.626320004463196f, 0.483780175447464f, 0.626691043376923f, + 0.483683139085770f, 0.627061963081360f, 0.483585834503174f, + 0.627432823181152f, 0.483488231897354f, 0.627803623676300f, + 0.483390361070633f, 0.628174364566803f, 0.483292192220688f, + 0.628544986248016f, 0.483193725347519f, 0.628915548324585f, + 0.483094990253448f, 0.629286050796509f, 0.482995986938477f, + 0.629656434059143f, 0.482896685600281f, 0.630026817321777f, + 0.482797086238861f, 0.630397081375122f, 0.482697218656540f, + 0.630767226219177f, 0.482597053050995f, 0.631137371063232f, + 0.482496619224548f, 0.631507396697998f, 0.482395917177200f, + 0.631877362728119f, 0.482294887304306f, 0.632247209548950f, + 0.482193619012833f, 0.632616996765137f, 0.482092022895813f, + 0.632986724376678f, 0.481990188360214f, 0.633356392383575f, + 0.481888025999069f, 0.633725941181183f, 0.481785595417023f, + 0.634095430374146f, 0.481682896614075f, 0.634464859962463f, + 0.481579899787903f, 0.634834170341492f, 0.481476634740829f, + 0.635203421115875f, 0.481373071670532f, 0.635572552680969f, + 0.481269240379334f, 0.635941684246063f, 0.481165111064911f, + 0.636310696601868f, 0.481060713529587f, 0.636679589748383f, + 0.480956017971039f, 0.637048482894897f, 0.480851024389267f, + 0.637417197227478f, 0.480745792388916f, 0.637785911560059f, + 0.480640232563019f, 0.638154506683350f, 0.480534434318542f, + 0.638523042201996f, 0.480428308248520f, 0.638891458511353f, + 0.480321943759918f, 0.639259815216064f, 0.480215251445770f, + 0.639628112316132f, 0.480108320713043f, 0.639996349811554f, + 0.480001062154770f, 0.640364408493042f, 0.479893565177917f, + 0.640732467174530f, 0.479785770177841f, 0.641100406646729f, + 0.479677677154541f, 0.641468286514282f, 0.479569315910339f, + 0.641836047172546f, 0.479460656642914f, 0.642203748226166f, + 0.479351729154587f, 0.642571389675140f, 0.479242533445358f, + 0.642938911914825f, 0.479133039712906f, 0.643306374549866f, + 0.479023247957230f, 0.643673717975616f, 0.478913217782974f, + 0.644041001796722f, 0.478802859783173f, 0.644408226013184f, + 0.478692263364792f, 0.644775331020355f, 0.478581339120865f, + 0.645142316818237f, 0.478470176458359f, 0.645509302616119f, + 0.478358715772629f, 0.645876109600067f, 0.478246957063675f, + 0.646242916584015f, 0.478134930133820f, 0.646609604358673f, + 0.478022634983063f, 0.646976172924042f, 0.477910041809082f, + 0.647342681884766f, 0.477797180414200f, 0.647709131240845f, + 0.477684020996094f, 0.648075461387634f, 0.477570593357086f, + 0.648441672325134f, 0.477456867694855f, 0.648807883262634f, + 0.477342873811722f, 0.649173915386200f, 0.477228611707687f, + 0.649539887905121f, 0.477114051580429f, 0.649905800819397f, + 0.476999223232269f, 0.650271594524384f, 0.476884096860886f, + 0.650637328624725f, 0.476768702268600f, 0.651003003120422f, + 0.476653009653091f, 0.651368498802185f, 0.476537048816681f, + 0.651733994483948f, 0.476420819759369f, 0.652099311351776f, + 0.476304292678833f, 0.652464628219604f, 0.476187497377396f, + 0.652829825878143f, 0.476070433855057f, 0.653194904327393f, + 0.475953072309494f, 0.653559923171997f, 0.475835442543030f, + 0.653924822807312f, 0.475717514753342f, 0.654289662837982f, + 0.475599318742752f, 0.654654383659363f, 0.475480824708939f, + 0.655019044876099f, 0.475362062454224f, 0.655383586883545f, + 0.475243031978607f, 0.655748009681702f, 0.475123733282089f, + 0.656112432479858f, 0.475004136562347f, 0.656476676464081f, + 0.474884241819382f, 0.656840860843658f, 0.474764078855515f, + 0.657204985618591f, 0.474643647670746f, 0.657568991184235f, + 0.474522948265076f, 0.657932877540588f, 0.474401950836182f, + 0.658296704292297f, 0.474280685186386f, 0.658660411834717f, + 0.474159121513367f, 0.659024059772491f, 0.474037289619446f, + 0.659387588500977f, 0.473915189504623f, 0.659750998020172f, + 0.473792791366577f, 0.660114347934723f, 0.473670125007629f, + 0.660477638244629f, 0.473547190427780f, 0.660840749740601f, + 0.473423957824707f, 0.661203861236572f, 0.473300457000732f, + 0.661566793918610f, 0.473176687955856f, 0.661929666996002f, + 0.473052620887756f, 0.662292480468750f, 0.472928285598755f, + 0.662655174732208f, 0.472803652286530f, 0.663017749786377f, + 0.472678780555725f, 0.663380205631256f, 0.472553610801697f, + 0.663742601871490f, 0.472428143024445f, 0.664104938507080f, + 0.472302407026291f, 0.664467096328735f, 0.472176402807236f, + 0.664829254150391f, 0.472050130367279f, 0.665191233158112f, + 0.471923559904099f, 0.665553152561188f, 0.471796721220016f, + 0.665914952754974f, 0.471669614315033f, 0.666276693344116f, + 0.471542209386826f, 0.666638314723969f, 0.471414536237717f, + 0.666999816894531f, 0.471286594867706f, 0.667361259460449f, + 0.471158385276794f, 0.667722582817078f, 0.471029877662659f, + 0.668083786964417f, 0.470901101827621f, 0.668444931507111f, + 0.470772027969360f, 0.668805956840515f, 0.470642685890198f, + 0.669166862964630f, 0.470513075590134f, 0.669527709484100f, + 0.470383197069168f, 0.669888436794281f, 0.470253020524979f, + 0.670249044895172f, 0.470122605562210f, 0.670609593391418f, + 0.469991862773895f, 0.670970022678375f, 0.469860881567001f, + 0.671330332756042f, 0.469729602336884f, 0.671690583229065f, + 0.469598054885864f, 0.672050714492798f, 0.469466239213943f, + 0.672410726547241f, 0.469334155321121f, 0.672770678997040f, + 0.469201773405075f, 0.673130512237549f, 0.469069123268127f, + 0.673490226268768f, 0.468936175107956f, 0.673849821090698f, + 0.468802988529205f, 0.674209356307983f, 0.468669503927231f, + 0.674568772315979f, 0.468535751104355f, 0.674928069114685f, + 0.468401730060577f, 0.675287246704102f, 0.468267410993576f, + 0.675646364688873f, 0.468132823705673f, 0.676005363464355f, + 0.467997968196869f, 0.676364302635193f, 0.467862844467163f, + 0.676723062992096f, 0.467727422714233f, 0.677081763744354f, + 0.467591762542725f, 0.677440345287323f, 0.467455804347992f, + 0.677798807621002f, 0.467319577932358f, 0.678157210350037f, + 0.467183053493500f, 0.678515493869781f, 0.467046260833740f, + 0.678873658180237f, 0.466909229755402f, 0.679231703281403f, + 0.466771900653839f, 0.679589688777924f, 0.466634273529053f, + 0.679947495460510f, 0.466496407985687f, 0.680305242538452f, + 0.466358244419098f, 0.680662930011749f, 0.466219812631607f, + 0.681020438671112f, 0.466081112623215f, 0.681377887725830f, + 0.465942144393921f, 0.681735157966614f, 0.465802878141403f, + 0.682092368602753f, 0.465663343667984f, 0.682449519634247f, + 0.465523540973663f, 0.682806491851807f, 0.465383470058441f, + 0.683163404464722f, 0.465243130922318f, 0.683520197868347f, + 0.465102523565292f, 0.683876872062683f, 0.464961618185043f, + 0.684233427047729f, 0.464820444583893f, 0.684589862823486f, + 0.464679002761841f, 0.684946238994598f, 0.464537292718887f, + 0.685302436351776f, 0.464395314455032f, 0.685658574104309f, + 0.464253038167953f, 0.686014592647552f, 0.464110493659973f, + 0.686370551586151f, 0.463967710733414f, 0.686726331710815f, + 0.463824629783630f, 0.687082052230835f, 0.463681250810623f, + 0.687437593936920f, 0.463537633419037f, 0.687793076038361f, + 0.463393747806549f, 0.688148438930511f, 0.463249564170837f, + 0.688503682613373f, 0.463105112314224f, 0.688858866691589f, + 0.462960392236710f, 0.689213871955872f, 0.462815403938293f, + 0.689568817615509f, 0.462670147418976f, 0.689923584461212f, + 0.462524622678757f, 0.690278291702271f, 0.462378799915314f, + 0.690632879734039f, 0.462232738733292f, 0.690987348556519f, + 0.462086379528046f, 0.691341698169708f, 0.461939752101898f, + 0.691695988178253f, 0.461792886257172f, 0.692050099372864f, + 0.461645722389221f, 0.692404091358185f, 0.461498260498047f, + 0.692758023738861f, 0.461350560188293f, 0.693111836910248f, + 0.461202591657639f, 0.693465530872345f, 0.461054325103760f, + 0.693819046020508f, 0.460905820131302f, 0.694172501564026f, + 0.460757017135620f, 0.694525837898254f, 0.460607945919037f, + 0.694879114627838f, 0.460458606481552f, 0.695232212543488f, + 0.460309028625488f, 0.695585191249847f, 0.460159152746201f, + 0.695938050746918f, 0.460008978843689f, 0.696290850639343f, + 0.459858566522598f, 0.696643471717834f, 0.459707885980606f, + 0.696996033191681f, 0.459556937217712f, 0.697348415851593f, + 0.459405690431595f, 0.697700738906860f, 0.459254205226898f, + 0.698052942752838f, 0.459102421998978f, 0.698404967784882f, + 0.458950400352478f, 0.698756933212280f, 0.458798080682755f, + 0.699108779430389f, 0.458645492792130f, 0.699460506439209f, + 0.458492636680603f, 0.699812114238739f, 0.458339542150497f, + 0.700163602828979f, 0.458186149597168f, 0.700514972209930f, + 0.458032488822937f, 0.700866222381592f, 0.457878559827805f, + 0.701217353343964f, 0.457724362611771f, 0.701568365097046f, + 0.457569897174835f, 0.701919257640839f, 0.457415163516998f, + 0.702270030975342f, 0.457260161638260f, 0.702620685100555f, + 0.457104891538620f, 0.702971220016479f, 0.456949323415756f, + 0.703321635723114f, 0.456793516874313f, 0.703671932220459f, + 0.456637442111969f, 0.704022109508514f, 0.456481099128723f, + 0.704372167587280f, 0.456324487924576f, 0.704722046852112f, + 0.456167578697205f, 0.705071866512299f, 0.456010431051254f, + 0.705421566963196f, 0.455853015184402f, 0.705771148204803f, + 0.455695331096649f, 0.706120610237122f, 0.455537378787994f, + 0.706469953060150f, 0.455379128456116f, 0.706819176673889f, + 0.455220639705658f, 0.707168221473694f, 0.455061882734299f, + 0.707517206668854f, 0.454902857542038f, 0.707866072654724f, + 0.454743564128876f, 0.708214759826660f, 0.454584002494812f, + 0.708563387393951f, 0.454424172639847f, 0.708911836147308f, + 0.454264044761658f, 0.709260225296021f, 0.454103678464890f, + 0.709608435630798f, 0.453943043947220f, 0.709956526756287f, + 0.453782171010971f, 0.710304558277130f, 0.453621000051498f, + 0.710652410984039f, 0.453459560871124f, 0.711000144481659f, + 0.453297853469849f, 0.711347758769989f, 0.453135877847672f, + 0.711695253849030f, 0.452973634004593f, 0.712042629718781f, + 0.452811151742935f, 0.712389826774597f, 0.452648371458054f, + 0.712736964225769f, 0.452485352754593f, 0.713083922863007f, + 0.452322036027908f, 0.713430821895599f, 0.452158480882645f, + 0.713777542114258f, 0.451994657516479f, 0.714124143123627f, + 0.451830536127090f, 0.714470624923706f, 0.451666176319122f, + 0.714816987514496f, 0.451501548290253f, 0.715163230895996f, + 0.451336652040482f, 0.715509355068207f, 0.451171487569809f, + 0.715855300426483f, 0.451006084680557f, 0.716201186180115f, + 0.450840383768082f, 0.716546893119812f, 0.450674414634705f, + 0.716892480850220f, 0.450508207082748f, 0.717238008975983f, + 0.450341701507568f, 0.717583298683167f, 0.450174957513809f, + 0.717928528785706f, 0.450007945299149f, 0.718273639678955f, + 0.449840664863586f, 0.718618571758270f, 0.449673116207123f, + 0.718963444232941f, 0.449505299329758f, 0.719308137893677f, + 0.449337244033813f, 0.719652712345123f, 0.449168890714645f, + 0.719997107982636f, 0.449000298976898f, 0.720341444015503f, + 0.448831409215927f, 0.720685660839081f, 0.448662281036377f, + 0.721029698848724f, 0.448492884635925f, 0.721373617649078f, + 0.448323249816895f, 0.721717417240143f, 0.448153316974640f, + 0.722061097621918f, 0.447983115911484f, 0.722404599189758f, + 0.447812676429749f, 0.722747981548309f, 0.447641968727112f, + 0.723091304302216f, 0.447470992803574f, 0.723434448242188f, + 0.447299748659134f, 0.723777413368225f, 0.447128236293793f, + 0.724120318889618f, 0.446956485509872f, 0.724463045597076f, + 0.446784436702728f, 0.724805653095245f, 0.446612149477005f, + 0.725148141384125f, 0.446439594030380f, 0.725490510463715f, + 0.446266770362854f, 0.725832700729370f, 0.446093708276749f, + 0.726174771785736f, 0.445920348167419f, 0.726516723632813f, + 0.445746749639511f, 0.726858556270599f, 0.445572882890701f, + 0.727200269699097f, 0.445398747920990f, 0.727541804313660f, + 0.445224374532700f, 0.727883219718933f, 0.445049703121185f, + 0.728224515914917f, 0.444874793291092f, 0.728565633296967f, + 0.444699615240097f, 0.728906631469727f, 0.444524168968201f, + 0.729247510433197f, 0.444348484277725f, 0.729588270187378f, + 0.444172531366348f, 0.729928910732269f, 0.443996280431747f, + 0.730269372463226f, 0.443819820880890f, 0.730609714984894f, + 0.443643063306808f, 0.730949878692627f, 0.443466067314148f, + 0.731289982795715f, 0.443288803100586f, 0.731629908084869f, + 0.443111270666122f, 0.731969714164734f, 0.442933470010757f, + 0.732309341430664f, 0.442755430936813f, 0.732648849487305f, + 0.442577123641968f, 0.732988238334656f, 0.442398548126221f, + 0.733327507972717f, 0.442219734191895f, 0.733666598796844f, + 0.442040622234344f, 0.734005570411682f, 0.441861271858215f, + 0.734344422817230f, 0.441681683063507f, 0.734683096408844f, + 0.441501796245575f, 0.735021650791168f, 0.441321671009064f, + 0.735360085964203f, 0.441141277551651f, 0.735698342323303f, + 0.440960645675659f, 0.736036539077759f, 0.440779715776443f, + 0.736374497413635f, 0.440598547458649f, 0.736712396144867f, + 0.440417140722275f, 0.737050116062164f, 0.440235435962677f, + 0.737387716770172f, 0.440053492784500f, 0.737725138664246f, + 0.439871311187744f, 0.738062441349030f, 0.439688831567764f, + 0.738399624824524f, 0.439506113529205f, 0.738736629486084f, + 0.439323127269745f, 0.739073514938354f, 0.439139902591705f, + 0.739410281181335f, 0.438956409692764f, 0.739746868610382f, + 0.438772648572922f, 0.740083336830139f, 0.438588619232178f, + 0.740419685840607f, 0.438404351472855f, 0.740755856037140f, + 0.438219845294952f, 0.741091907024384f, 0.438035041093826f, + 0.741427779197693f, 0.437849998474121f, 0.741763532161713f, + 0.437664687633514f, 0.742099165916443f, 0.437479138374329f, + 0.742434620857239f, 0.437293320894241f, 0.742769956588745f, + 0.437107264995575f, 0.743105113506317f, 0.436920911073685f, + 0.743440151214600f, 0.436734348535538f, 0.743775069713593f, + 0.436547487974167f, 0.744109809398651f, 0.436360388994217f, + 0.744444429874420f, 0.436173021793365f, 0.744778931140900f, + 0.435985416173935f, 0.745113253593445f, 0.435797542333603f, + 0.745447397232056f, 0.435609430074692f, 0.745781481266022f, + 0.435421019792557f, 0.746115326881409f, 0.435232400894165f, + 0.746449112892151f, 0.435043483972549f, 0.746782720088959f, + 0.434854328632355f, 0.747116148471832f, 0.434664934873581f, + 0.747449457645416f, 0.434475272893906f, 0.747782647609711f, + 0.434285342693329f, 0.748115658760071f, 0.434095174074173f, + 0.748448550701141f, 0.433904737234116f, 0.748781263828278f, + 0.433714061975479f, 0.749113857746124f, 0.433523118495941f, + 0.749446272850037f, 0.433331936597824f, 0.749778568744659f, + 0.433140486478806f, 0.750110685825348f, 0.432948768138886f, + 0.750442683696747f, 0.432756811380386f, 0.750774562358856f, + 0.432564586400986f, 0.751106262207031f, 0.432372123003006f, + 0.751437783241272f, 0.432179391384125f, 0.751769185066223f, + 0.431986421346664f, 0.752100467681885f, 0.431793183088303f, + 0.752431571483612f, 0.431599706411362f, 0.752762496471405f, + 0.431405961513519f, 0.753093302249908f, 0.431211978197098f, + 0.753423988819122f, 0.431017726659775f, 0.753754496574402f, + 0.430823236703873f, 0.754084885120392f, 0.430628478527069f, + 0.754415094852448f, 0.430433481931686f, 0.754745125770569f, + 0.430238217115402f, 0.755075037479401f, 0.430042684078217f, + 0.755404829978943f, 0.429846942424774f, 0.755734443664551f, + 0.429650902748108f, 0.756063878536224f, 0.429454624652863f, + 0.756393194198608f, 0.429258108139038f, 0.756722390651703f, + 0.429061323404312f, 0.757051348686218f, 0.428864300251007f, + 0.757380247116089f, 0.428667008876801f, 0.757708966732025f, + 0.428469479084015f, 0.758037507534027f, 0.428271710872650f, + 0.758365929126740f, 0.428073674440384f, 0.758694171905518f, + 0.427875369787216f, 0.759022235870361f, 0.427676826715469f, + 0.759350180625916f, 0.427478045225143f, 0.759678006172180f, + 0.427278995513916f, 0.760005652904511f, 0.427079707384110f, + 0.760333120822906f, 0.426880151033401f, 0.760660469532013f, + 0.426680356264114f, 0.760987639427185f, 0.426480293273926f, + 0.761314690113068f, 0.426279991865158f, 0.761641561985016f, + 0.426079452037811f, 0.761968255043030f, 0.425878643989563f, + 0.762294828891754f, 0.425677597522736f, 0.762621283531189f, + 0.425476282835007f, 0.762947499752045f, 0.425274729728699f, + 0.763273596763611f, 0.425072938203812f, 0.763599574565887f, + 0.424870878458023f, 0.763925373554230f, 0.424668580293655f, + 0.764250993728638f, 0.424466013908386f, 0.764576494693756f, + 0.424263238906860f, 0.764901816844940f, 0.424060165882111f, + 0.765226960182190f, 0.423856884241104f, 0.765551984310150f, + 0.423653304576874f, 0.765876889228821f, 0.423449516296387f, + 0.766201555728912f, 0.423245459794998f, 0.766526103019714f, + 0.423041164875031f, 0.766850471496582f, 0.422836631536484f, + 0.767174720764160f, 0.422631829977036f, 0.767498791217804f, + 0.422426789999008f, 0.767822742462158f, 0.422221481800079f, + 0.768146514892578f, 0.422015935182571f, 0.768470108509064f, + 0.421810150146484f, 0.768793523311615f, 0.421604126691818f, + 0.769116818904877f, 0.421397835016251f, 0.769439935684204f, + 0.421191304922104f, 0.769762933254242f, 0.420984506607056f, + 0.770085752010345f, 0.420777499675751f, 0.770408391952515f, + 0.420570224523544f, 0.770730912685394f, 0.420362681150436f, + 0.771053194999695f, 0.420154929161072f, 0.771375417709351f, + 0.419946908950806f, 0.771697402000427f, 0.419738620519638f, + 0.772019267082214f, 0.419530123472214f, 0.772340953350067f, + 0.419321358203888f, 0.772662520408630f, 0.419112354516983f, + 0.772983849048615f, 0.418903112411499f, 0.773305058479309f, + 0.418693602085114f, 0.773626148700714f, 0.418483853340149f, + 0.773947000503540f, 0.418273866176605f, 0.774267733097076f, + 0.418063640594482f, 0.774588346481323f, 0.417853146791458f, + 0.774908721446991f, 0.417642414569855f, 0.775228977203369f, + 0.417431443929672f, 0.775549054145813f, 0.417220205068588f, + 0.775869011878967f, 0.417008757591248f, 0.776188731193542f, + 0.416797041893005f, 0.776508331298828f, 0.416585087776184f, + 0.776827812194824f, 0.416372895240784f, 0.777147054672241f, + 0.416160434484482f, 0.777466177940369f, 0.415947735309601f, + 0.777785122394562f, 0.415734797716141f, 0.778103888034821f, + 0.415521621704102f, 0.778422534465790f, 0.415308207273483f, + 0.778741002082825f, 0.415094524621964f, 0.779059290885925f, + 0.414880603551865f, 0.779377400875092f, 0.414666473865509f, + 0.779695332050323f, 0.414452046155930f, 0.780013144016266f, + 0.414237409830093f, 0.780330777168274f, 0.414022535085678f, + 0.780648231506348f, 0.413807392120361f, 0.780965566635132f, + 0.413592010736465f, 0.781282722949982f, 0.413376390933990f, + 0.781599700450897f, 0.413160532712936f, 0.781916499137878f, + 0.412944436073303f, 0.782233119010925f, 0.412728071212769f, + 0.782549619674683f, 0.412511497735977f, 0.782865881919861f, + 0.412294656038284f, 0.783182024955750f, 0.412077575922012f, + 0.783498048782349f, 0.411860257387161f, 0.783813834190369f, + 0.411642700433731f, 0.784129500389099f, 0.411424905061722f, + 0.784444928169250f, 0.411206841468811f, 0.784760236740112f, + 0.410988569259644f, 0.785075426101685f, 0.410770028829575f, + 0.785390377044678f, 0.410551249980927f, 0.785705149173737f, + 0.410332232713699f, 0.786019802093506f, 0.410112977027893f, + 0.786334276199341f, 0.409893482923508f, 0.786648571491241f, + 0.409673750400543f, 0.786962687969208f, 0.409453779459000f, + 0.787276685237885f, 0.409233570098877f, 0.787590444087982f, + 0.409013092517853f, 0.787904083728790f, 0.408792406320572f, + 0.788217544555664f, 0.408571451902390f, 0.788530826568604f, + 0.408350288867950f, 0.788843929767609f, 0.408128857612610f, + 0.789156913757324f, 0.407907217741013f, 0.789469659328461f, + 0.407685309648514f, 0.789782285690308f, 0.407463163137436f, + 0.790094733238220f, 0.407240778207779f, 0.790407001972198f, + 0.407018154859543f, 0.790719091892242f, 0.406795293092728f, + 0.791031002998352f, 0.406572192907333f, 0.791342735290527f, + 0.406348884105682f, 0.791654348373413f, 0.406125307083130f, + 0.791965723037720f, 0.405901491641998f, 0.792276978492737f, + 0.405677437782288f, 0.792588055133820f, 0.405453115701675f, + 0.792898952960968f, 0.405228585004807f, 0.793209671974182f, + 0.405003815889359f, 0.793520212173462f, 0.404778808355331f, + 0.793830573558807f, 0.404553562402725f, 0.794140756130219f, + 0.404328078031540f, 0.794450819492340f, 0.404102355241776f, + 0.794760644435883f, 0.403876423835754f, 0.795070350170136f, + 0.403650224208832f, 0.795379877090454f, 0.403423786163330f, + 0.795689165592194f, 0.403197109699249f, 0.795998334884644f, + 0.402970194816589f, 0.796307325363159f, 0.402743041515350f, + 0.796616137027740f, 0.402515679597855f, 0.796924769878387f, + 0.402288049459457f, 0.797233223915100f, 0.402060180902481f, + 0.797541558742523f, 0.401832103729248f, 0.797849655151367f, + 0.401603758335114f, 0.798157572746277f, 0.401375204324722f, + 0.798465371131897f, 0.401146411895752f, 0.798772931098938f, + 0.400917351245880f, 0.799080371856689f, 0.400688081979752f, + 0.799387574195862f, 0.400458574295044f, 0.799694657325745f, + 0.400228828191757f, 0.800001561641693f, 0.399998843669891f, + 0.800308227539063f, 0.399768620729446f, 0.800614774227142f, + 0.399538189172745f, 0.800921142101288f, 0.399307489395142f, + 0.801227271556854f, 0.399076581001282f, 0.801533281803131f, + 0.398845434188843f, 0.801839113235474f, 0.398614019155502f, + 0.802144765853882f, 0.398382395505905f, 0.802450239658356f, + 0.398150533437729f, 0.802755534648895f, 0.397918462753296f, + 0.803060650825500f, 0.397686123847961f, 0.803365588188171f, + 0.397453576326370f, 0.803670346736908f, 0.397220760583878f, + 0.803974866867065f, 0.396987736225128f, 0.804279267787933f, + 0.396754473447800f, 0.804583489894867f, 0.396520972251892f, + 0.804887533187866f, 0.396287262439728f, 0.805191397666931f, + 0.396053284406662f, 0.805495083332062f, 0.395819097757339f, + 0.805798590183258f, 0.395584672689438f, 0.806101918220520f, + 0.395350009202957f, 0.806405067443848f, 0.395115107297897f, + 0.806707978248596f, 0.394879996776581f, 0.807010769844055f, + 0.394644618034363f, 0.807313382625580f, 0.394409030675888f, + 0.807615816593170f, 0.394173204898834f, 0.807918012142181f, + 0.393937170505524f, 0.808220088481903f, 0.393700867891312f, + 0.808521986007690f, 0.393464356660843f, 0.808823645114899f, + 0.393227607011795f, 0.809125185012817f, 0.392990618944168f, + 0.809426486492157f, 0.392753422260284f, 0.809727668762207f, + 0.392515957355499f, 0.810028612613678f, 0.392278283834457f, + 0.810329377651215f, 0.392040401697159f, 0.810629963874817f, + 0.391802251338959f, 0.810930430889130f, 0.391563892364502f, + 0.811230659484863f, 0.391325294971466f, 0.811530709266663f, + 0.391086459159851f, 0.811830580234528f, 0.390847414731979f, + 0.812130272388458f, 0.390608131885529f, 0.812429726123810f, + 0.390368610620499f, 0.812729060649872f, 0.390128880739212f, + 0.813028216362000f, 0.389888882637024f, 0.813327133655548f, + 0.389648675918579f, 0.813625931739807f, 0.389408260583878f, + 0.813924491405487f, 0.389167606830597f, 0.814222872257233f, + 0.388926714658737f, 0.814521074295044f, 0.388685584068298f, + 0.814819097518921f, 0.388444244861603f, 0.815116941928864f, + 0.388202667236328f, 0.815414607524872f, 0.387960851192474f, + 0.815712094306946f, 0.387718826532364f, 0.816009342670441f, + 0.387476563453674f, 0.816306471824646f, 0.387234061956406f, + 0.816603362560272f, 0.386991351842880f, 0.816900074481964f, + 0.386748403310776f, 0.817196667194366f, 0.386505216360092f, + 0.817493021488190f, 0.386261820793152f, 0.817789137363434f, + 0.386018186807632f, 0.818085134029388f, 0.385774344205856f, + 0.818380951881409f, 0.385530263185501f, 0.818676531314850f, + 0.385285943746567f, 0.818971931934357f, 0.385041415691376f, + 0.819267153739929f, 0.384796649217606f, 0.819562196731567f, + 0.384551674127579f, 0.819857060909271f, 0.384306460618973f, + 0.820151746273041f, 0.384061008691788f, 0.820446193218231f, + 0.383815348148346f, 0.820740520954132f, 0.383569449186325f, + 0.821034610271454f, 0.383323341608047f, 0.821328520774841f, + 0.383076995611191f, 0.821622252464294f, 0.382830440998077f, + 0.821915745735168f, 0.382583618164063f, 0.822209119796753f, + 0.382336616516113f, 0.822502255439758f, 0.382089376449585f, + 0.822795212268829f, 0.381841897964478f, 0.823087990283966f, + 0.381594210863113f, 0.823380589485168f, 0.381346285343170f, + 0.823673009872437f, 0.381098151206970f, 0.823965191841125f, + 0.380849778652191f, 0.824257194995880f, 0.380601197481155f, + 0.824549019336700f, 0.380352377891541f, 0.824840664863586f, + 0.380103349685669f, 0.825132071971893f, 0.379854083061218f, + 0.825423359870911f, 0.379604607820511f, 0.825714409351349f, + 0.379354894161224f, 0.826005280017853f, 0.379104942083359f, + 0.826295912265778f, 0.378854811191559f, 0.826586425304413f, + 0.378604412078857f, 0.826876699924469f, 0.378353834152222f, + 0.827166795730591f, 0.378102988004684f, 0.827456712722778f, + 0.377851963043213f, 0.827746450901031f, 0.377600699663162f, + 0.828035950660706f, 0.377349197864532f, 0.828325271606445f, + 0.377097487449646f, 0.828614413738251f, 0.376845568418503f, + 0.828903317451477f, 0.376593410968781f, 0.829192101955414f, + 0.376341015100479f, 0.829480648040771f, 0.376088410615921f, + 0.829769015312195f, 0.375835597515106f, 0.830057144165039f, + 0.375582575798035f, 0.830345153808594f, 0.375329315662384f, + 0.830632925033569f, 0.375075817108154f, 0.830920517444611f, + 0.374822109937668f, 0.831207871437073f, 0.374568194150925f, + 0.831495106220245f, 0.374314039945602f, 0.831782102584839f, + 0.374059677124023f, 0.832068860530853f, 0.373805105686188f, + 0.832355499267578f, 0.373550295829773f, 0.832641899585724f, + 0.373295277357101f, 0.832928121089935f, 0.373040050268173f, + 0.833214163780212f, 0.372784584760666f, 0.833499968051910f, + 0.372528880834579f, 0.833785593509674f, 0.372272998094559f, + 0.834071040153503f, 0.372016876935959f, 0.834356248378754f, + 0.371760547161102f, 0.834641277790070f, 0.371503978967667f, + 0.834926128387451f, 0.371247202157974f, 0.835210800170898f, + 0.370990216732025f, 0.835495233535767f, 0.370732992887497f, + 0.835779488086700f, 0.370475560426712f, 0.836063504219055f, + 0.370217919349670f, 0.836347401142120f, 0.369960039854050f, + 0.836631059646606f, 0.369701951742172f, 0.836914479732513f, + 0.369443655014038f, 0.837197780609131f, 0.369185149669647f, + 0.837480843067169f, 0.368926405906677f, 0.837763667106628f, + 0.368667453527451f, 0.838046371936798f, 0.368408292531967f, + 0.838328838348389f, 0.368148893117905f, 0.838611066341400f, + 0.367889285087585f, 0.838893175125122f, 0.367629468441010f, + 0.839175045490265f, 0.367369443178177f, 0.839456677436829f, + 0.367109179496765f, 0.839738130569458f, 0.366848707199097f, + 0.840019404888153f, 0.366588026285172f, 0.840300500392914f, + 0.366327136754990f, 0.840581357479095f, 0.366066008806229f, + 0.840862035751343f, 0.365804702043533f, 0.841142535209656f, + 0.365543156862259f, 0.841422796249390f, 0.365281373262405f, + 0.841702818870544f, 0.365019410848618f, 0.841982722282410f, + 0.364757210016251f, 0.842262387275696f, 0.364494800567627f, + 0.842541813850403f, 0.364232182502747f, 0.842821121215820f, + 0.363969355821610f, 0.843100130558014f, 0.363706320524216f, + 0.843379020690918f, 0.363443046808243f, 0.843657672405243f, + 0.363179564476013f, 0.843936145305634f, 0.362915903329849f, + 0.844214379787445f, 0.362651973962784f, 0.844492435455322f, + 0.362387865781784f, 0.844770252704620f, 0.362123548984528f, + 0.845047891139984f, 0.361858993768692f, 0.845325350761414f, + 0.361594229936600f, 0.845602571964264f, 0.361329287290573f, + 0.845879614353180f, 0.361064106225967f, 0.846156477928162f, + 0.360798716545105f, 0.846433103084564f, 0.360533088445663f, + 0.846709489822388f, 0.360267281532288f, 0.846985757350922f, + 0.360001266002655f, 0.847261726856232f, 0.359735012054443f, + 0.847537577152252f, 0.359468549489975f, 0.847813189029694f, + 0.359201908111572f, 0.848088562488556f, 0.358935028314590f, + 0.848363757133484f, 0.358667939901352f, 0.848638772964478f, + 0.358400642871857f, 0.848913550376892f, 0.358133137226105f, + 0.849188148975372f, 0.357865422964096f, 0.849462509155273f, + 0.357597470283508f, 0.849736690521240f, 0.357329338788986f, + 0.850010633468628f, 0.357060998678207f, 0.850284397602081f, + 0.356792420148849f, 0.850557923316956f, 0.356523662805557f, + 0.850831270217896f, 0.356254696846008f, 0.851104438304901f, + 0.355985492467880f, 0.851377367973328f, 0.355716109275818f, + 0.851650118827820f, 0.355446487665176f, 0.851922631263733f, + 0.355176687240601f, 0.852194905281067f, 0.354906648397446f, + 0.852467060089111f, 0.354636400938034f, 0.852738916873932f, + 0.354365974664688f, 0.853010654449463f, 0.354095309972763f, + 0.853282094001770f, 0.353824466466904f, 0.853553414344788f, + 0.353553384542465f, 0.853824436664581f, 0.353282123804092f, + 0.854095339775085f, 0.353010624647141f, 0.854365944862366f, + 0.352738946676254f, 0.854636430740356f, 0.352467030286789f, + 0.854906618595123f, 0.352194935083389f, 0.855176687240601f, + 0.351922631263733f, 0.855446517467499f, 0.351650089025497f, + 0.855716109275818f, 0.351377367973328f, 0.855985522270203f, + 0.351104438304901f, 0.856254696846008f, 0.350831300020218f, + 0.856523692607880f, 0.350557953119278f, 0.856792449951172f, + 0.350284397602081f, 0.857060968875885f, 0.350010633468628f, + 0.857329368591309f, 0.349736660718918f, 0.857597470283508f, + 0.349462509155273f, 0.857865393161774f, 0.349188119173050f, + 0.858133137226105f, 0.348913550376892f, 0.858400642871857f, + 0.348638743162155f, 0.858667910099030f, 0.348363757133484f, + 0.858934998512268f, 0.348088562488556f, 0.859201908111572f, + 0.347813159227371f, 0.859468579292297f, 0.347537547349930f, + 0.859735012054443f, 0.347261756658554f, 0.860001266002655f, + 0.346985727548599f, 0.860267281532288f, 0.346709519624710f, + 0.860533118247986f, 0.346433073282242f, 0.860798716545105f, + 0.346156448125839f, 0.861064076423645f, 0.345879614353180f, + 0.861329257488251f, 0.345602601766586f, 0.861594259738922f, + 0.345325350761414f, 0.861859023571014f, 0.345047920942307f, + 0.862123548984528f, 0.344770282506943f, 0.862387895584106f, + 0.344492435455322f, 0.862652003765106f, 0.344214379787445f, + 0.862915873527527f, 0.343936115503311f, 0.863179564476013f, + 0.343657672405243f, 0.863443076610565f, 0.343379020690918f, + 0.863706290721893f, 0.343100160360336f, 0.863969385623932f, + 0.342821091413498f, 0.864232182502747f, 0.342541843652725f, + 0.864494800567627f, 0.342262357473373f, 0.864757239818573f, + 0.341982692480087f, 0.865019381046295f, 0.341702848672867f, + 0.865281403064728f, 0.341422766447067f, 0.865543127059937f, + 0.341142505407333f, 0.865804672241211f, 0.340862035751343f, + 0.866066038608551f, 0.340581357479095f, 0.866327106952667f, + 0.340300500392914f, 0.866588056087494f, 0.340019434690475f, + 0.866848707199097f, 0.339738160371780f, 0.867109179496765f, + 0.339456677436829f, 0.867369413375854f, 0.339175015687943f, + 0.867629468441010f, 0.338893145322800f, 0.867889285087585f, + 0.338611096143723f, 0.868148922920227f, 0.338328808546066f, + 0.868408262729645f, 0.338046342134476f, 0.868667483329773f, + 0.337763696908951f, 0.868926405906677f, 0.337480813264847f, + 0.869185149669647f, 0.337197750806808f, 0.869443655014038f, + 0.336914509534836f, 0.869701981544495f, 0.336631029844284f, + 0.869960069656372f, 0.336347371339798f, 0.870217919349670f, + 0.336063534021378f, 0.870475590229034f, 0.335779488086700f, + 0.870733022689819f, 0.335495233535767f, 0.870990216732025f, + 0.335210770368576f, 0.871247172355652f, 0.334926128387451f, + 0.871503949165344f, 0.334641307592392f, 0.871760547161102f, + 0.334356248378754f, 0.872016847133636f, 0.334071010351181f, + 0.872272968292236f, 0.333785593509674f, 0.872528910636902f, + 0.333499968051910f, 0.872784554958344f, 0.333214133977890f, + 0.873040020465851f, 0.332928121089935f, 0.873295307159424f, + 0.332641899585724f, 0.873550295829773f, 0.332355499267578f, + 0.873805105686188f, 0.332068890333176f, 0.874059677124023f, + 0.331782072782516f, 0.874314069747925f, 0.331495076417923f, + 0.874568223953247f, 0.331207901239395f, 0.874822139739990f, + 0.330920487642288f, 0.875075817108154f, 0.330632925033569f, + 0.875329315662384f, 0.330345153808594f, 0.875582575798035f, + 0.330057173967361f, 0.875835597515106f, 0.329769015312195f, + 0.876088440418243f, 0.329480648040771f, 0.876341044902802f, + 0.329192101955414f, 0.876593410968781f, 0.328903347253799f, + 0.876845538616180f, 0.328614413738251f, 0.877097487449646f, + 0.328325271606445f, 0.877349197864532f, 0.328035950660706f, + 0.877600669860840f, 0.327746421098709f, 0.877851963043213f, + 0.327456712722778f, 0.878103017807007f, 0.327166795730591f, + 0.878353834152222f, 0.326876699924469f, 0.878604412078857f, + 0.326586425304413f, 0.878854811191559f, 0.326295942068100f, + 0.879104971885681f, 0.326005280017853f, 0.879354894161224f, + 0.325714409351349f, 0.879604578018188f, 0.325423330068588f, + 0.879854083061218f, 0.325132101774216f, 0.880103349685669f, + 0.324840664863586f, 0.880352377891541f, 0.324549019336700f, + 0.880601167678833f, 0.324257194995880f, 0.880849778652191f, + 0.323965191841125f, 0.881098151206970f, 0.323672980070114f, + 0.881346285343170f, 0.323380589485168f, 0.881594181060791f, + 0.323088020086288f, 0.881841897964478f, 0.322795242071152f, + 0.882089376449585f, 0.322502255439758f, 0.882336616516113f, + 0.322209119796753f, 0.882583618164063f, 0.321915775537491f, + 0.882830440998077f, 0.321622252464294f, 0.883076965808868f, + 0.321328520774841f, 0.883323311805725f, 0.321034610271454f, + 0.883569478988647f, 0.320740520954132f, 0.883815348148346f, + 0.320446223020554f, 0.884061038494110f, 0.320151746273041f, + 0.884306430816650f, 0.319857090711594f, 0.884551644325256f, + 0.319562226533890f, 0.884796679019928f, 0.319267183542252f, + 0.885041415691376f, 0.318971961736679f, 0.885285973548889f, + 0.318676531314850f, 0.885530233383179f, 0.318380922079086f, + 0.885774314403534f, 0.318085134029388f, 0.886018216609955f, + 0.317789167165756f, 0.886261820793152f, 0.317492991685867f, + 0.886505246162415f, 0.317196637392044f, 0.886748373508453f, + 0.316900104284287f, 0.886991322040558f, 0.316603392362595f, + 0.887234091758728f, 0.316306471824646f, 0.887476563453674f, + 0.316009372472763f, 0.887718796730042f, 0.315712094306946f, + 0.887960851192474f, 0.315414607524872f, 0.888202667236328f, + 0.315116971731186f, 0.888444244861603f, 0.314819127321243f, + 0.888685584068298f, 0.314521104097366f, 0.888926684856415f, + 0.314222872257233f, 0.889167606830597f, 0.313924491405487f, + 0.889408230781555f, 0.313625901937485f, 0.889648675918579f, + 0.313327133655548f, 0.889888882637024f, 0.313028186559677f, + 0.890128850936890f, 0.312729060649872f, 0.890368640422821f, + 0.312429755926132f, 0.890608131885529f, 0.312130242586136f, + 0.890847444534302f, 0.311830550432205f, 0.891086459159851f, + 0.311530679464340f, 0.891325294971466f, 0.311230629682541f, + 0.891563892364502f, 0.310930401086807f, 0.891802251338959f, + 0.310629993677139f, 0.892040371894836f, 0.310329377651215f, + 0.892278313636780f, 0.310028612613678f, 0.892515957355499f, + 0.309727638959885f, 0.892753422260284f, 0.309426486492157f, + 0.892990648746490f, 0.309125155210495f, 0.893227577209473f, + 0.308823645114899f, 0.893464326858521f, 0.308521956205368f, + 0.893700897693634f, 0.308220088481903f, 0.893937170505524f, + 0.307918041944504f, 0.894173204898834f, 0.307615786790848f, + 0.894409060478210f, 0.307313382625580f, 0.894644618034363f, + 0.307010769844055f, 0.894879996776581f, 0.306708008050919f, + 0.895115137100220f, 0.306405037641525f, 0.895349979400635f, + 0.306101888418198f, 0.895584642887115f, 0.305798590183258f, + 0.895819067955017f, 0.305495083332062f, 0.896053314208984f, + 0.305191397666931f, 0.896287262439728f, 0.304887533187866f, + 0.896520972251892f, 0.304583519697189f, 0.896754503250122f, + 0.304279297590256f, 0.896987736225128f, 0.303974896669388f, + 0.897220790386200f, 0.303670316934586f, 0.897453546524048f, + 0.303365558385849f, 0.897686123847961f, 0.303060621023178f, + 0.897918462753296f, 0.302755534648895f, 0.898150563240051f, + 0.302450239658356f, 0.898382425308228f, 0.302144765853882f, + 0.898614048957825f, 0.301839113235474f, 0.898845434188843f, + 0.301533311605453f, 0.899076581001282f, 0.301227301359177f, + 0.899307489395142f, 0.300921112298965f, 0.899538159370422f, + 0.300614774227142f, 0.899768650531769f, 0.300308227539063f, + 0.899998843669891f, 0.300001531839371f, 0.900228857994080f, + 0.299694657325745f, 0.900458574295044f, 0.299387603998184f, + 0.900688111782074f, 0.299080342054367f, 0.900917351245880f, + 0.298772931098938f, 0.901146411895752f, 0.298465341329575f, + 0.901375174522400f, 0.298157602548599f, 0.901603758335114f, + 0.297849655151367f, 0.901832103729248f, 0.297541528940201f, + 0.902060210704803f, 0.297233253717422f, 0.902288019657135f, + 0.296924799680710f, 0.902515649795532f, 0.296616137027740f, + 0.902743041515350f, 0.296307325363159f, 0.902970194816589f, + 0.295998334884644f, 0.903197109699249f, 0.295689195394516f, + 0.903423786163330f, 0.295379847288132f, 0.903650224208832f, + 0.295070350170136f, 0.903876423835754f, 0.294760644435883f, + 0.904102385044098f, 0.294450789690018f, 0.904328107833862f, + 0.294140785932541f, 0.904553592205048f, 0.293830573558807f, + 0.904778838157654f, 0.293520182371140f, 0.905003845691681f, + 0.293209642171860f, 0.905228614807129f, 0.292898923158646f, + 0.905453145503998f, 0.292588025331497f, 0.905677437782288f, + 0.292276978492737f, 0.905901491641998f, 0.291965723037720f, + 0.906125307083130f, 0.291654318571091f, 0.906348884105682f, + 0.291342735290527f, 0.906572222709656f, 0.291031002998352f, + 0.906795322895050f, 0.290719062089920f, 0.907018184661865f, + 0.290406972169876f, 0.907240808010101f, 0.290094703435898f, + 0.907463192939758f, 0.289782285690308f, 0.907685279846191f, + 0.289469659328461f, 0.907907187938690f, 0.289156883955002f, + 0.908128857612610f, 0.288843959569931f, 0.908350288867950f, + 0.288530826568604f, 0.908571481704712f, 0.288217544555664f, + 0.908792436122894f, 0.287904083728790f, 0.909013092517853f, + 0.287590473890305f, 0.909233570098877f, 0.287276685237885f, + 0.909453809261322f, 0.286962717771530f, 0.909673750400543f, + 0.286648571491241f, 0.909893512725830f, 0.286334276199341f, + 0.910112977027893f, 0.286019802093506f, 0.910332262516022f, + 0.285705178976059f, 0.910551249980927f, 0.285390377044678f, + 0.910769999027252f, 0.285075396299362f, 0.910988569259644f, + 0.284760266542435f, 0.911206841468811f, 0.284444957971573f, + 0.911424875259399f, 0.284129470586777f, 0.911642670631409f, + 0.283813834190369f, 0.911860227584839f, 0.283498018980026f, + 0.912077546119690f, 0.283182054758072f, 0.912294626235962f, + 0.282865911722183f, 0.912511467933655f, 0.282549589872360f, + 0.912728071212769f, 0.282233119010925f, 0.912944436073303f, + 0.281916469335556f, 0.913160502910614f, 0.281599670648575f, + 0.913376390933990f, 0.281282693147659f, 0.913592040538788f, + 0.280965566635132f, 0.913807392120361f, 0.280648261308670f, + 0.914022505283356f, 0.280330777168274f, 0.914237439632416f, + 0.280013144016266f, 0.914452075958252f, 0.279695361852646f, + 0.914666473865509f, 0.279377400875092f, 0.914880633354187f, + 0.279059261083603f, 0.915094554424286f, 0.278740972280502f, + 0.915308177471161f, 0.278422504663467f, 0.915521621704102f, + 0.278103888034821f, 0.915734827518463f, 0.277785122394562f, + 0.915947735309601f, 0.277466177940369f, 0.916160404682159f, + 0.277147054672241f, 0.916372895240784f, 0.276827782392502f, + 0.916585087776184f, 0.276508361101151f, 0.916797041893005f, + 0.276188760995865f, 0.917008757591248f, 0.275868982076645f, + 0.917220234870911f, 0.275549083948135f, 0.917431414127350f, + 0.275228977203369f, 0.917642414569855f, 0.274908751249313f, + 0.917853116989136f, 0.274588316679001f, 0.918063640594482f, + 0.274267762899399f, 0.918273866176605f, 0.273947030305862f, + 0.918483853340149f, 0.273626148700714f, 0.918693602085114f, + 0.273305088281631f, 0.918903112411499f, 0.272983878850937f, + 0.919112324714661f, 0.272662490606308f, 0.919321358203888f, + 0.272340953350067f, 0.919530093669891f, 0.272019267082214f, + 0.919738650321960f, 0.271697402000427f, 0.919946908950806f, + 0.271375387907028f, 0.920154929161072f, 0.271053224802017f, + 0.920362710952759f, 0.270730882883072f, 0.920570194721222f, + 0.270408391952515f, 0.920777499675751f, 0.270085722208023f, + 0.920984506607056f, 0.269762933254242f, 0.921191275119781f, + 0.269439965486526f, 0.921397805213928f, 0.269116818904877f, + 0.921604096889496f, 0.268793523311615f, 0.921810150146484f, + 0.268470078706741f, 0.922015964984894f, 0.268146485090256f, + 0.922221481800079f, 0.267822742462158f, 0.922426760196686f, + 0.267498821020126f, 0.922631800174713f, 0.267174720764160f, + 0.922836601734161f, 0.266850501298904f, 0.923041164875031f, + 0.266526103019714f, 0.923245489597321f, 0.266201555728912f, + 0.923449516296387f, 0.265876859426498f, 0.923653304576874f, + 0.265552014112473f, 0.923856854438782f, 0.265226989984512f, + 0.924060165882111f, 0.264901816844940f, 0.924263238906860f, + 0.264576494693756f, 0.924466013908386f, 0.264250993728638f, + 0.924668610095978f, 0.263925373554230f, 0.924870908260345f, + 0.263599574565887f, 0.925072908401489f, 0.263273626565933f, + 0.925274729728699f, 0.262947499752045f, 0.925476312637329f, + 0.262621253728867f, 0.925677597522736f, 0.262294828891754f, + 0.925878643989563f, 0.261968284845352f, 0.926079452037811f, + 0.261641561985016f, 0.926280021667480f, 0.261314690113068f, + 0.926480293273926f, 0.260987639427185f, 0.926680326461792f, + 0.260660469532013f, 0.926880121231079f, 0.260333120822906f, + 0.927079677581787f, 0.260005623102188f, 0.927278995513916f, + 0.259678006172180f, 0.927478015422821f, 0.259350210428238f, + 0.927676856517792f, 0.259022265672684f, 0.927875399589539f, + 0.258694142103195f, 0.928073644638062f, 0.258365899324417f, + 0.928271710872650f, 0.258037507534027f, 0.928469479084015f, + 0.257708936929703f, 0.928667008876801f, 0.257380217313766f, + 0.928864300251007f, 0.257051378488541f, 0.929061353206635f, + 0.256722360849380f, 0.929258108139038f, 0.256393194198608f, + 0.929454624652863f, 0.256063878536224f, 0.929650902748108f, + 0.255734413862228f, 0.929846942424774f, 0.255404800176620f, + 0.930042684078217f, 0.255075037479401f, 0.930238187313080f, + 0.254745125770569f, 0.930433452129364f, 0.254415065050125f, + 0.930628478527069f, 0.254084855318069f, 0.930823206901550f, + 0.253754496574402f, 0.931017756462097f, 0.253423988819122f, + 0.931211948394775f, 0.253093332052231f, 0.931405961513519f, + 0.252762526273727f, 0.931599736213684f, 0.252431541681290f, + 0.931793212890625f, 0.252100437879562f, 0.931986451148987f, + 0.251769185066223f, 0.932179391384125f, 0.251437783241272f, + 0.932372152805328f, 0.251106232404709f, 0.932564616203308f, + 0.250774532556534f, 0.932756841182709f, 0.250442683696747f, + 0.932948768138886f, 0.250110685825348f, 0.933140456676483f, + 0.249778553843498f, 0.933331906795502f, 0.249446272850037f, + 0.933523118495941f, 0.249113827943802f, 0.933714091777802f, + 0.248781248927116f, 0.933904767036438f, 0.248448520898819f, + 0.934095203876495f, 0.248115643858910f, 0.934285342693329f, + 0.247782632708550f, 0.934475243091583f, 0.247449472546577f, + 0.934664964675903f, 0.247116148471832f, 0.934854328632355f, + 0.246782705187798f, 0.935043513774872f, 0.246449097990990f, + 0.935232400894165f, 0.246115356683731f, 0.935421049594879f, + 0.245781451463699f, 0.935609400272369f, 0.245447427034378f, + 0.935797572135925f, 0.245113238692284f, 0.935985386371613f, + 0.244778916239738f, 0.936173021793365f, 0.244444444775581f, + 0.936360359191895f, 0.244109839200974f, 0.936547517776489f, + 0.243775084614754f, 0.936734318733215f, 0.243440181016922f, + 0.936920940876007f, 0.243105143308640f, 0.937107264995575f, + 0.242769956588745f, 0.937293350696564f, 0.242434620857239f, + 0.937479138374329f, 0.242099151015282f, 0.937664687633514f, + 0.241763532161713f, 0.937849998474121f, 0.241427779197693f, + 0.938035070896149f, 0.241091892123222f, 0.938219845294952f, + 0.240755841135979f, 0.938404381275177f, 0.240419670939446f, + 0.938588619232178f, 0.240083336830139f, 0.938772618770599f, + 0.239746883511543f, 0.938956379890442f, 0.239410281181335f, + 0.939139902591705f, 0.239073529839516f, 0.939323127269745f, + 0.238736644387245f, 0.939506113529205f, 0.238399609923363f, + 0.939688861370087f, 0.238062441349030f, 0.939871311187744f, + 0.237725138664246f, 0.940053522586823f, 0.237387686967850f, + 0.940235435962677f, 0.237050101161003f, 0.940417110919952f, + 0.236712381243706f, 0.940598547458649f, 0.236374512314796f, + 0.940779745578766f, 0.236036509275436f, 0.940960645675659f, + 0.235698372125626f, 0.941141307353973f, 0.235360085964203f, + 0.941321671009064f, 0.235021665692329f, 0.941501796245575f, + 0.234683111310005f, 0.941681683063507f, 0.234344407916069f, + 0.941861271858215f, 0.234005570411682f, 0.942040622234344f, + 0.233666598796844f, 0.942219734191895f, 0.233327493071556f, + 0.942398548126221f, 0.232988253235817f, 0.942577123641968f, + 0.232648864388466f, 0.942755401134491f, 0.232309341430664f, + 0.942933499813080f, 0.231969684362412f, 0.943111240863800f, + 0.231629893183708f, 0.943288803100586f, 0.231289967894554f, + 0.943466067314148f, 0.230949893593788f, 0.943643093109131f, + 0.230609700083733f, 0.943819820880890f, 0.230269357562065f, + 0.943996310234070f, 0.229928880929947f, 0.944172501564026f, + 0.229588270187378f, 0.944348454475403f, 0.229247525334358f, + 0.944524168968201f, 0.228906646370888f, 0.944699645042419f, + 0.228565633296967f, 0.944874763488770f, 0.228224486112595f, + 0.945049703121185f, 0.227883204817772f, 0.945224344730377f, + 0.227541789412498f, 0.945398747920990f, 0.227200239896774f, + 0.945572853088379f, 0.226858556270599f, 0.945746779441834f, + 0.226516738533974f, 0.945920348167419f, 0.226174786686897f, + 0.946093678474426f, 0.225832715630531f, 0.946266770362854f, + 0.225490495562553f, 0.946439623832703f, 0.225148141384125f, + 0.946612179279327f, 0.224805667996407f, 0.946784436702728f, + 0.224463045597076f, 0.946956455707550f, 0.224120303988457f, + 0.947128236293793f, 0.223777428269386f, 0.947299718856812f, + 0.223434418439865f, 0.947470963001251f, 0.223091274499893f, + 0.947641968727112f, 0.222748011350632f, 0.947812676429749f, + 0.222404599189758f, 0.947983145713806f, 0.222061067819595f, + 0.948153316974640f, 0.221717402338982f, 0.948323249816895f, + 0.221373617649078f, 0.948492884635925f, 0.221029683947563f, + 0.948662281036377f, 0.220685631036758f, 0.948831439018250f, + 0.220341444015503f, 0.949000298976898f, 0.219997137784958f, + 0.949168920516968f, 0.219652697443962f, 0.949337244033813f, + 0.219308122992516f, 0.949505329132080f, 0.218963414430618f, + 0.949673116207123f, 0.218618586659431f, 0.949840664863586f, + 0.218273624777794f, 0.950007975101471f, 0.217928543686867f, + 0.950174987316132f, 0.217583328485489f, 0.950341701507568f, + 0.217237979173660f, 0.950508177280426f, 0.216892510652542f, + 0.950674414634705f, 0.216546908020973f, 0.950840353965759f, + 0.216201186180115f, 0.951006054878235f, 0.215855330228806f, + 0.951171517372131f, 0.215509355068207f, 0.951336681842804f, + 0.215163245797157f, 0.951501548290253f, 0.214817002415657f, + 0.951666176319122f, 0.214470639824867f, 0.951830565929413f, + 0.214124158024788f, 0.951994657516479f, 0.213777542114258f, + 0.952158451080322f, 0.213430806994438f, 0.952322065830231f, + 0.213083937764168f, 0.952485322952271f, 0.212736949324608f, + 0.952648401260376f, 0.212389841675758f, 0.952811121940613f, + 0.212042599916458f, 0.952973663806915f, 0.211695238947868f, + 0.953135907649994f, 0.211347743868828f, 0.953297853469849f, + 0.211000129580498f, 0.953459560871124f, 0.210652396082878f, + 0.953620970249176f, 0.210304543375969f, 0.953782141208649f, + 0.209956556558609f, 0.953943073749542f, 0.209608450531960f, + 0.954103708267212f, 0.209260210394859f, 0.954264044761658f, + 0.208911851048470f, 0.954424142837524f, 0.208563387393951f, + 0.954584002494812f, 0.208214774727821f, 0.954743564128876f, + 0.207866057753563f, 0.954902827739716f, 0.207517206668854f, + 0.955061912536621f, 0.207168251276016f, 0.955220639705658f, + 0.206819161772728f, 0.955379128456116f, 0.206469938158989f, + 0.955537378787994f, 0.206120610237122f, 0.955695331096649f, + 0.205771163105965f, 0.955853044986725f, 0.205421581864357f, + 0.956010460853577f, 0.205071896314621f, 0.956167578697205f, + 0.204722076654434f, 0.956324458122253f, 0.204372137784958f, + 0.956481099128723f, 0.204022079706192f, 0.956637442111969f, + 0.203671902418137f, 0.956793546676636f, 0.203321605920792f, + 0.956949353218079f, 0.202971190214157f, 0.957104861736298f, + 0.202620655298233f, 0.957260131835938f, 0.202270001173019f, + 0.957415163516998f, 0.201919227838516f, 0.957569897174835f, + 0.201568335294724f, 0.957724332809448f, 0.201217323541641f, + 0.957878530025482f, 0.200866192579269f, 0.958032488822937f, + 0.200514942407608f, 0.958186149597168f, 0.200163587927818f, + 0.958339512348175f, 0.199812099337578f, 0.958492636680603f, + 0.199460506439209f, 0.958645522594452f, 0.199108779430389f, + 0.958798050880432f, 0.198756948113441f, 0.958950400352478f, + 0.198404997587204f, 0.959102451801300f, 0.198052927851677f, + 0.959254205226898f, 0.197700738906860f, 0.959405720233917f, + 0.197348430752754f, 0.959556937217712f, 0.196996018290520f, + 0.959707856178284f, 0.196643486618996f, 0.959858596324921f, + 0.196290835738182f, 0.960008978843689f, 0.195938065648079f, + 0.960159122943878f, 0.195585191249847f, 0.960309028625488f, + 0.195232197642326f, 0.960458636283875f, 0.194879084825516f, + 0.960607945919037f, 0.194525867700577f, 0.960757017135620f, + 0.194172516465187f, 0.960905790328979f, 0.193819075822830f, + 0.961054325103760f, 0.193465501070023f, 0.961202561855316f, + 0.193111822009087f, 0.961350560188293f, 0.192758023738861f, + 0.961498260498047f, 0.192404121160507f, 0.961645722389221f, + 0.192050099372864f, 0.961792886257172f, 0.191695958375931f, + 0.961939752101898f, 0.191341713070869f, 0.962086379528046f, + 0.190987363457680f, 0.962232708930969f, 0.190632879734039f, + 0.962378799915314f, 0.190278306603432f, 0.962524592876434f, + 0.189923599362373f, 0.962670147418976f, 0.189568802714348f, + 0.962815403938293f, 0.189213871955872f, 0.962960422039032f, + 0.188858851790428f, 0.963105142116547f, 0.188503712415695f, + 0.963249564170837f, 0.188148453831673f, 0.963393747806549f, + 0.187793090939522f, 0.963537633419037f, 0.187437608838081f, + 0.963681280612946f, 0.187082037329674f, 0.963824629783630f, + 0.186726331710815f, 0.963967680931091f, 0.186370536684990f, + 0.964110493659973f, 0.186014622449875f, 0.964253067970276f, + 0.185658603906631f, 0.964395284652710f, 0.185302466154099f, + 0.964537262916565f, 0.184946224093437f, 0.964679002761841f, + 0.184589877724648f, 0.964820444583893f, 0.184233412146568f, + 0.964961588382721f, 0.183876842260361f, 0.965102493762970f, + 0.183520168066025f, 0.965243160724640f, 0.183163389563560f, + 0.965383470058441f, 0.182806491851807f, 0.965523540973663f, + 0.182449504733086f, 0.965663373470306f, 0.182092398405075f, + 0.965802907943726f, 0.181735187768936f, 0.965942144393921f, + 0.181377857923508f, 0.966081082820892f, 0.181020438671112f, + 0.966219842433929f, 0.180662900209427f, 0.966358244419098f, + 0.180305257439613f, 0.966496407985687f, 0.179947525262833f, + 0.966634273529053f, 0.179589673876762f, 0.966771900653839f, + 0.179231703281403f, 0.966909229755402f, 0.178873643279076f, + 0.967046260833740f, 0.178515478968620f, 0.967183053493500f, + 0.178157210350037f, 0.967319548130035f, 0.177798837423325f, + 0.967455804347992f, 0.177440345287323f, 0.967591762542725f, + 0.177081763744354f, 0.967727422714233f, 0.176723077893257f, + 0.967862844467163f, 0.176364272832870f, 0.967997968196869f, + 0.176005378365517f, 0.968132853507996f, 0.175646379590034f, + 0.968267440795898f, 0.175287276506424f, 0.968401730060577f, + 0.174928069114685f, 0.968535780906677f, 0.174568757414818f, + 0.968669533729553f, 0.174209341406822f, 0.968802988529205f, + 0.173849821090698f, 0.968936204910278f, 0.173490211367607f, + 0.969069123268127f, 0.173130482435226f, 0.969201743602753f, + 0.172770664095879f, 0.969334125518799f, 0.172410741448402f, + 0.969466269016266f, 0.172050714492798f, 0.969598054885864f, + 0.171690583229065f, 0.969729602336884f, 0.171330362558365f, + 0.969860911369324f, 0.170970037579536f, 0.969991862773895f, + 0.170609608292580f, 0.970122575759888f, 0.170249074697495f, + 0.970253050327301f, 0.169888436794281f, 0.970383226871490f, + 0.169527709484100f, 0.970513105392456f, 0.169166877865791f, + 0.970642685890198f, 0.168805956840515f, 0.970772027969360f, + 0.168444931507111f, 0.970901072025299f, 0.168083801865578f, + 0.971029877662659f, 0.167722567915916f, 0.971158385276794f, + 0.167361244559288f, 0.971286594867706f, 0.166999831795692f, + 0.971414566040039f, 0.166638299822807f, 0.971542239189148f, + 0.166276678442955f, 0.971669614315033f, 0.165914967656136f, + 0.971796751022339f, 0.165553152561188f, 0.971923589706421f, + 0.165191248059273f, 0.972050130367279f, 0.164829224348068f, + 0.972176432609558f, 0.164467126131058f, 0.972302436828613f, + 0.164104923605919f, 0.972428143024445f, 0.163742616772652f, + 0.972553610801697f, 0.163380220532417f, 0.972678780555725f, + 0.163017734885216f, 0.972803652286530f, 0.162655144929886f, + 0.972928285598755f, 0.162292465567589f, 0.973052620887756f, + 0.161929681897163f, 0.973176658153534f, 0.161566808819771f, + 0.973300457000732f, 0.161203846335411f, 0.973423957824707f, + 0.160840779542923f, 0.973547160625458f, 0.160477623343468f, + 0.973670125007629f, 0.160114362835884f, 0.973792791366577f, + 0.159751012921333f, 0.973915159702301f, 0.159387573599815f, + 0.974037289619446f, 0.159024044871330f, 0.974159121513367f, + 0.158660411834717f, 0.974280655384064f, 0.158296689391136f, + 0.974401950836182f, 0.157932877540588f, 0.974522948265076f, + 0.157568961381912f, 0.974643647670746f, 0.157204970717430f, + 0.974764108657837f, 0.156840875744820f, 0.974884271621704f, + 0.156476691365242f, 0.975004136562347f, 0.156112402677536f, + 0.975123703479767f, 0.155748039484024f, 0.975243031978607f, + 0.155383571982384f, 0.975362062454224f, 0.155019029974937f, + 0.975480854511261f, 0.154654383659363f, 0.975599288940430f, + 0.154289647936821f, 0.975717484951019f, 0.153924822807312f, + 0.975835442543030f, 0.153559908270836f, 0.975953042507172f, + 0.153194904327393f, 0.976070404052734f, 0.152829796075821f, + 0.976187527179718f, 0.152464613318443f, 0.976304292678833f, + 0.152099341154099f, 0.976420819759369f, 0.151733979582787f, + 0.976537048816681f, 0.151368513703346f, 0.976653039455414f, + 0.151002973318100f, 0.976768672466278f, 0.150637343525887f, + 0.976884067058563f, 0.150271624326706f, 0.976999223232269f, + 0.149905815720558f, 0.977114021778107f, 0.149539917707443f, + 0.977228581905365f, 0.149173930287361f, 0.977342903614044f, + 0.148807853460312f, 0.977456867694855f, 0.148441687226295f, + 0.977570593357086f, 0.148075446486473f, 0.977684020996094f, + 0.147709101438522f, 0.977797150611877f, 0.147342681884766f, + 0.977910041809082f, 0.146976172924042f, 0.978022634983063f, + 0.146609574556351f, 0.978134930133820f, 0.146242901682854f, + 0.978246986865997f, 0.145876124501228f, 0.978358685970306f, + 0.145509272813797f, 0.978470146656036f, 0.145142331719399f, + 0.978581368923187f, 0.144775316119194f, 0.978692233562469f, + 0.144408211112022f, 0.978802859783173f, 0.144041016697884f, + 0.978913187980652f, 0.143673732876778f, 0.979023277759552f, + 0.143306359648705f, 0.979133009910584f, 0.142938911914825f, + 0.979242503643036f, 0.142571389675140f, 0.979351758956909f, + 0.142203763127327f, 0.979460656642914f, 0.141836062073708f, + 0.979569315910339f, 0.141468286514282f, 0.979677677154541f, + 0.141100421547890f, 0.979785740375519f, 0.140732467174530f, + 0.979893565177917f, 0.140364438295364f, 0.980001091957092f, + 0.139996320009232f, 0.980108320713043f, 0.139628127217293f, + 0.980215251445770f, 0.139259845018387f, 0.980321943759918f, + 0.138891488313675f, 0.980428338050842f, 0.138523042201996f, + 0.980534434318542f, 0.138154521584511f, 0.980640232563019f, + 0.137785911560059f, 0.980745792388916f, 0.137417227029800f, + 0.980851054191589f, 0.137048453092575f, 0.980956017971039f, + 0.136679604649544f, 0.981060683727264f, 0.136310681700706f, + 0.981165111064911f, 0.135941669344902f, 0.981269240379334f, + 0.135572582483292f, 0.981373071670532f, 0.135203406214714f, + 0.981476604938507f, 0.134834155440331f, 0.981579899787903f, + 0.134464830160141f, 0.981682896614075f, 0.134095430374146f, + 0.981785595417023f, 0.133725941181183f, 0.981888055801392f, + 0.133356377482414f, 0.981990158557892f, 0.132986739277840f, + 0.982092022895813f, 0.132617011666298f, 0.982193589210510f, + 0.132247209548950f, 0.982294917106628f, 0.131877332925797f, + 0.982395887374878f, 0.131507381796837f, 0.982496619224548f, + 0.131137356162071f, 0.982597053050995f, 0.130767241120338f, + 0.982697248458862f, 0.130397051572800f, 0.982797086238861f, + 0.130026802420616f, 0.982896685600281f, 0.129656463861465f, + 0.982995986938477f, 0.129286035895348f, 0.983094990253448f, + 0.128915548324585f, 0.983193755149841f, 0.128544986248016f, + 0.983292162418365f, 0.128174334764481f, 0.983390331268311f, + 0.127803623676300f, 0.983488261699677f, 0.127432823181152f, + 0.983585834503174f, 0.127061963081360f, 0.983683168888092f, + 0.126691013574600f, 0.983780145645142f, 0.126320004463196f, + 0.983876943588257f, 0.125948905944824f, 0.983973383903503f, + 0.125577747821808f, 0.984069526195526f, 0.125206500291824f, + 0.984165430068970f, 0.124835193157196f, 0.984261035919189f, + 0.124463804066181f, 0.984356343746185f, 0.124092340469360f, + 0.984451413154602f, 0.123720809817314f, 0.984546124935150f, + 0.123349204659462f, 0.984640598297119f, 0.122977524995804f, + 0.984734773635864f, 0.122605770826340f, 0.984828710556030f, + 0.122233949601650f, 0.984922289848328f, 0.121862053871155f, + 0.985015630722046f, 0.121490091085434f, 0.985108673572540f, + 0.121118053793907f, 0.985201418399811f, 0.120745941996574f, + 0.985293865203857f, 0.120373763144016f, 0.985386073589325f, + 0.120001509785652f, 0.985477983951569f, 0.119629189372063f, + 0.985569596290588f, 0.119256794452667f, 0.985660910606384f, + 0.118884332478046f, 0.985751926898956f, 0.118511803448200f, + 0.985842704772949f, 0.118139199912548f, 0.985933184623718f, + 0.117766529321671f, 0.986023366451263f, 0.117393791675568f, + 0.986113250255585f, 0.117020979523659f, 0.986202836036682f, + 0.116648100316525f, 0.986292183399200f, 0.116275154054165f, + 0.986381232738495f, 0.115902140736580f, 0.986469984054565f, + 0.115529052913189f, 0.986558437347412f, 0.115155905485153f, + 0.986646652221680f, 0.114782683551311f, 0.986734509468079f, + 0.114409394562244f, 0.986822128295898f, 0.114036038517952f, + 0.986909449100494f, 0.113662622869015f, 0.986996471881866f, + 0.113289132714272f, 0.987083256244659f, 0.112915575504303f, + 0.987169682979584f, 0.112541958689690f, 0.987255871295929f, + 0.112168267369270f, 0.987341761589050f, 0.111794516444206f, + 0.987427353858948f, 0.111420698463917f, 0.987512648105621f, + 0.111046813428402f, 0.987597703933716f, 0.110672861337662f, + 0.987682461738586f, 0.110298842191696f, 0.987766921520233f, + 0.109924763441086f, 0.987851083278656f, 0.109550617635250f, + 0.987934947013855f, 0.109176412224770f, 0.988018512725830f, + 0.108802139759064f, 0.988101840019226f, 0.108427800238132f, + 0.988184869289398f, 0.108053401112556f, 0.988267600536346f, + 0.107678934931755f, 0.988350033760071f, 0.107304409146309f, + 0.988432228565216f, 0.106929816305637f, 0.988514065742493f, + 0.106555156409740f, 0.988595664501190f, 0.106180444359779f, + 0.988676965236664f, 0.105805665254593f, 0.988757967948914f, + 0.105430819094181f, 0.988838672637939f, 0.105055920779705f, + 0.988919138908386f, 0.104680955410004f, 0.988999247550964f, + 0.104305922985077f, 0.989079117774963f, 0.103930838406086f, + 0.989158689975739f, 0.103555686771870f, 0.989237964153290f, + 0.103180475533009f, 0.989316940307617f, 0.102805204689503f, + 0.989395678043365f, 0.102429874241352f, 0.989474058151245f, + 0.102054484188557f, 0.989552199840546f, 0.101679034531116f, + 0.989630043506622f, 0.101303517818451f, 0.989707589149475f, + 0.100927948951721f, 0.989784896373749f, 0.100552320480347f, + 0.989861845970154f, 0.100176624953747f, 0.989938557147980f, + 0.099800877273083f, 0.990014970302582f, 0.099425069987774f, + 0.990091085433960f, 0.099049203097820f, 0.990166902542114f, + 0.098673284053802f, 0.990242421627045f, 0.098297297954559f, + 0.990317702293396f, 0.097921259701252f, 0.990392625331879f, + 0.097545161843300f, 0.990467309951782f, 0.097169004380703f, + 0.990541696548462f, 0.096792794764042f, 0.990615785121918f, + 0.096416525542736f, 0.990689575672150f, 0.096040196716785f, + 0.990763127803802f, 0.095663815736771f, 0.990836322307587f, + 0.095287375152111f, 0.990909278392792f, 0.094910882413387f, + 0.990981936454773f, 0.094534330070019f, 0.991054296493530f, + 0.094157725572586f, 0.991126358509064f, 0.093781061470509f, + 0.991198182106018f, 0.093404345214367f, 0.991269648075104f, + 0.093027576804161f, 0.991340875625610f, 0.092650748789310f, + 0.991411805152893f, 0.092273868620396f, 0.991482377052307f, + 0.091896936297417f, 0.991552770137787f, 0.091519944369793f, + 0.991622805595398f, 0.091142900288105f, 0.991692543029785f, + 0.090765804052353f, 0.991762042045593f, 0.090388655662537f, + 0.991831183433533f, 0.090011447668076f, 0.991900086402893f, + 0.089634194970131f, 0.991968691349030f, 0.089256882667542f, + 0.992036998271942f, 0.088879525661469f, 0.992105066776276f, + 0.088502109050751f, 0.992172777652740f, 0.088124647736549f, + 0.992240250110626f, 0.087747126817703f, 0.992307364940643f, + 0.087369553744793f, 0.992374241352081f, 0.086991935968399f, + 0.992440819740295f, 0.086614266037941f, 0.992507100105286f, + 0.086236543953419f, 0.992573142051697f, 0.085858769714832f, + 0.992638826370239f, 0.085480943322182f, 0.992704212665558f, + 0.085103072226048f, 0.992769360542297f, 0.084725148975849f, + 0.992834210395813f, 0.084347173571587f, 0.992898762226105f, + 0.083969146013260f, 0.992963016033173f, 0.083591073751450f, + 0.993026971817017f, 0.083212949335575f, 0.993090689182281f, + 0.082834780216217f, 0.993154048919678f, 0.082456558942795f, + 0.993217170238495f, 0.082078292965889f, 0.993279933929443f, + 0.081699974834919f, 0.993342459201813f, 0.081321612000465f, + 0.993404686450958f, 0.080943197011948f, 0.993466615676880f, + 0.080564737319946f, 0.993528306484222f, 0.080186225473881f, + 0.993589639663696f, 0.079807676374912f, 0.993650734424591f, + 0.079429075121880f, 0.993711471557617f, 0.079050421714783f, + 0.993771970272064f, 0.078671731054783f, 0.993832170963287f, + 0.078292988240719f, 0.993892073631287f, 0.077914200723171f, + 0.993951678276062f, 0.077535368502140f, 0.994010984897614f, + 0.077156484127045f, 0.994070053100586f, 0.076777562499046f, + 0.994128763675690f, 0.076398596167564f, 0.994187235832214f, + 0.076019577682018f, 0.994245409965515f, 0.075640521943569f, + 0.994303286075592f, 0.075261414051056f, 0.994360864162445f, + 0.074882268905640f, 0.994418144226074f, 0.074503071606159f, + 0.994475126266479f, 0.074123837053776f, 0.994531810283661f, + 0.073744557797909f, 0.994588255882263f, 0.073365233838558f, + 0.994644403457642f, 0.072985872626305f, 0.994700193405151f, + 0.072606459259987f, 0.994755744934082f, 0.072227008640766f, + 0.994810998439789f, 0.071847513318062f, 0.994865953922272f, + 0.071467980742455f, 0.994920611381531f, 0.071088403463364f, + 0.994975030422211f, 0.070708781480789f, 0.995029091835022f, + 0.070329122245312f, 0.995082914829254f, 0.069949418306351f, + 0.995136380195618f, 0.069569669663906f, 0.995189607143402f, + 0.069189883768559f, 0.995242536067963f, 0.068810060620308f, + 0.995295166969299f, 0.068430192768574f, 0.995347499847412f, + 0.068050287663937f, 0.995399534702301f, 0.067670337855816f, + 0.995451331138611f, 0.067290350794792f, 0.995502769947052f, + 0.066910326480865f, 0.995553970336914f, 0.066530264914036f, + 0.995604813098907f, 0.066150158643723f, 0.995655417442322f, + 0.065770015120506f, 0.995705723762512f, 0.065389834344387f, + 0.995755732059479f, 0.065009608864784f, 0.995805442333221f, + 0.064629353582859f, 0.995854854583740f, 0.064249053597450f, + 0.995904028415680f, 0.063868723809719f, 0.995952844619751f, + 0.063488349318504f, 0.996001422405243f, 0.063107937574387f, + 0.996049642562866f, 0.062727488577366f, 0.996097624301910f, + 0.062347009778023f, 0.996145308017731f, 0.061966486275196f, + 0.996192693710327f, 0.061585929244757f, 0.996239781379700f, + 0.061205338686705f, 0.996286571025848f, 0.060824707150459f, + 0.996333062648773f, 0.060444042086601f, 0.996379256248474f, + 0.060063343495131f, 0.996425211429596f, 0.059682607650757f, + 0.996470808982849f, 0.059301838278770f, 0.996516168117523f, + 0.058921031653881f, 0.996561229228973f, 0.058540191501379f, + 0.996605992317200f, 0.058159314095974f, 0.996650457382202f, + 0.057778406888247f, 0.996694624423981f, 0.057397462427616f, + 0.996738493442535f, 0.057016488164663f, 0.996782064437866f, + 0.056635476648808f, 0.996825337409973f, 0.056254431605339f, + 0.996868371963501f, 0.055873356759548f, 0.996911048889160f, + 0.055492244660854f, 0.996953487396240f, 0.055111102759838f, + 0.996995627880096f, 0.054729927331209f, 0.997037410736084f, + 0.054348722100258f, 0.997078955173492f, 0.053967483341694f, + 0.997120201587677f, 0.053586211055517f, 0.997161149978638f, + 0.053204908967018f, 0.997201859951019f, 0.052823577076197f, + 0.997242212295532f, 0.052442211657763f, 0.997282266616821f, + 0.052060816437006f, 0.997322082519531f, 0.051679391413927f, + 0.997361540794373f, 0.051297932863235f, 0.997400760650635f, + 0.050916448235512f, 0.997439682483673f, 0.050534930080175f, + 0.997478306293488f, 0.050153385847807f, 0.997516572475433f, + 0.049771808087826f, 0.997554600238800f, 0.049390204250813f, + 0.997592389583588f, 0.049008570611477f, 0.997629821300507f, + 0.048626907169819f, 0.997666954994202f, 0.048245213925838f, + 0.997703790664673f, 0.047863494604826f, 0.997740387916565f, + 0.047481749206781f, 0.997776627540588f, 0.047099970281124f, + 0.997812628746033f, 0.046718169003725f, 0.997848331928253f, + 0.046336337924004f, 0.997883677482605f, 0.045954477041960f, + 0.997918784618378f, 0.045572593808174f, 0.997953593730927f, + 0.045190680772066f, 0.997988104820251f, 0.044808741658926f, + 0.998022377490997f, 0.044426776468754f, 0.998056292533875f, + 0.044044785201550f, 0.998089909553528f, 0.043662767857313f, + 0.998123228549957f, 0.043280724436045f, 0.998156309127808f, + 0.042898654937744f, 0.998189091682434f, 0.042516563087702f, + 0.998221516609192f, 0.042134445160627f, 0.998253703117371f, + 0.041752301156521f, 0.998285591602325f, 0.041370131075382f, + 0.998317182064056f, 0.040987938642502f, 0.998348474502563f, + 0.040605723857880f, 0.998379468917847f, 0.040223482996225f, + 0.998410165309906f, 0.039841219782829f, 0.998440563678741f, + 0.039458930492401f, 0.998470664024353f, 0.039076622575521f, + 0.998500525951386f, 0.038694288581610f, 0.998530030250549f, + 0.038311932235956f, 0.998559296131134f, 0.037929553538561f, + 0.998588204383850f, 0.037547148764133f, 0.998616874217987f, + 0.037164725363255f, 0.998645246028900f, 0.036782283335924f, + 0.998673319816589f, 0.036399815231562f, 0.998701035976410f, + 0.036017324775457f, 0.998728513717651f, 0.035634815692902f, + 0.998755753040314f, 0.035252287983894f, 0.998782634735107f, + 0.034869734197855f, 0.998809218406677f, 0.034487165510654f, + 0.998835504055023f, 0.034104570746422f, 0.998861551284790f, + 0.033721961081028f, 0.998887240886688f, 0.033339329063892f, + 0.998912692070007f, 0.032956674695015f, 0.998937785625458f, + 0.032574005424976f, 0.998962640762329f, 0.032191313803196f, + 0.998987197875977f, 0.031808607280254f, 0.999011456966400f, + 0.031425878405571f, 0.999035418033600f, 0.031043132767081f, + 0.999059081077576f, 0.030660368502140f, 0.999082446098328f, + 0.030277585610747f, 0.999105513095856f, 0.029894785955548f, + 0.999128282070160f, 0.029511967673898f, 0.999150753021240f, + 0.029129132628441f, 0.999172985553741f, 0.028746278956532f, + 0.999194860458374f, 0.028363410383463f, 0.999216496944427f, + 0.027980525046587f, 0.999237775802612f, 0.027597622945905f, + 0.999258816242218f, 0.027214704081416f, 0.999279558658600f, + 0.026831768453121f, 0.999299943447113f, 0.026448817923665f, + 0.999320089817047f, 0.026065852493048f, 0.999339938163757f, + 0.025682870298624f, 0.999359488487244f, 0.025299875065684f, + 0.999378740787506f, 0.024916863068938f, 0.999397754669189f, + 0.024533838033676f, 0.999416410923004f, 0.024150796234608f, + 0.999434769153595f, 0.023767741397023f, 0.999452829360962f, + 0.023384673520923f, 0.999470651149750f, 0.023001590743661f, + 0.999488115310669f, 0.022618494927883f, 0.999505341053009f, + 0.022235386073589f, 0.999522268772125f, 0.021852264180779f, + 0.999538838863373f, 0.021469129249454f, 0.999555170536041f, + 0.021085981279612f, 0.999571204185486f, 0.020702820271254f, + 0.999586939811707f, 0.020319648087025f, 0.999602377414703f, + 0.019936462864280f, 0.999617516994476f, 0.019553268328309f, + 0.999632358551025f, 0.019170060753822f, 0.999646902084351f, + 0.018786842003465f, 0.999661207199097f, 0.018403612077236f, + 0.999675154685974f, 0.018020370975137f, 0.999688863754272f, + 0.017637118697166f, 0.999702215194702f, 0.017253857105970f, + 0.999715328216553f, 0.016870586201549f, 0.999728083610535f, + 0.016487304121256f, 0.999740600585938f, 0.016104012727737f, + 0.999752819538116f, 0.015720712020993f, 0.999764680862427f, + 0.015337402001023f, 0.999776303768158f, 0.014954082667828f, + 0.999787628650665f, 0.014570754021406f, 0.999798655509949f, + 0.014187417924404f, 0.999809384346008f, 0.013804072514176f, + 0.999819874763489f, 0.013420719653368f, 0.999830007553101f, + 0.013037359341979f, 0.999839842319489f, 0.012653990648687f, + 0.999849438667297f, 0.012270614504814f, 0.999858677387238f, + 0.011887230910361f, 0.999867618083954f, 0.011503840796649f, + 0.999876320362091f, 0.011120444163680f, 0.999884724617004f, + 0.010737040080130f, 0.999892771244049f, 0.010353630408645f, + 0.999900579452515f, 0.009970214217901f, 0.999908089637756f, + 0.009586792439222f, 0.999915301799774f, 0.009203365072608f, + 0.999922215938568f, 0.008819932118058f, 0.999928832054138f, + 0.008436493575573f, 0.999935150146484f, 0.008053051307797f, + 0.999941170215607f, 0.007669602986425f, 0.999946892261505f, + 0.007286150939763f, 0.999952375888824f, 0.006902694236487f, + 0.999957501888275f, 0.006519233807921f, 0.999962329864502f, + 0.006135769188404f, 0.999966919422150f, 0.005752300843596f, + 0.999971151351929f, 0.005368829704821f, 0.999975144863129f, + 0.004985354840755f, 0.999978840351105f, 0.004601877182722f, + 0.999982178211212f, 0.004218397196382f, 0.999985277652740f, + 0.003834914416075f, 0.999988079071045f, 0.003451429307461f, + 0.999990582466125f, 0.003067942336202f, 0.999992787837982f, + 0.002684453502297f, 0.999994695186615f, 0.002300963038579f, + 0.999996304512024f, 0.001917471294291f, 0.999997675418854f, + 0.001533978385851f, 0.999998688697815f, 0.001150484546088f, + 0.999999403953552f, 0.000766990066040f, 0.999999880790710f, + 0.000383495149435f, 1.000000000000000f, 0.000000000000023f, + 0.999999880790710f, -0.000383495149435f, 0.999999403953552f, + -0.000766990066040f, 0.999998688697815f, -0.001150484546088f, + 0.999997675418854f, -0.001533978385851f, 0.999996304512024f, + -0.001917471294291f, 0.999994695186615f, -0.002300963038579f, + 0.999992787837982f, -0.002684453502297f, 0.999990582466125f, + -0.003067942336202f, 0.999988079071045f, -0.003451429307461f, + 0.999985277652740f, -0.003834914416075f, 0.999982178211212f, + -0.004218397196382f, 0.999978840351105f, -0.004601877182722f, + 0.999975144863129f, -0.004985354840755f, 0.999971151351929f, + -0.005368829704821f, 0.999966919422150f, -0.005752300843596f, + 0.999962329864502f, -0.006135769188404f, 0.999957501888275f, + -0.006519233807921f, 0.999952375888824f, -0.006902694236487f, + 0.999946892261505f, -0.007286150939763f, 0.999941170215607f, + -0.007669602986425f, 0.999935150146484f, -0.008053051307797f, + 0.999928832054138f, -0.008436493575573f, 0.999922215938568f, + -0.008819932118058f, 0.999915301799774f, -0.009203365072608f, + 0.999908089637756f, -0.009586792439222f, 0.999900579452515f, + -0.009970214217901f, 0.999892771244049f, -0.010353630408645f, + 0.999884724617004f, -0.010737040080130f, 0.999876320362091f, + -0.011120444163680f, 0.999867618083954f, -0.011503840796649f, + 0.999858677387238f, -0.011887230910361f, 0.999849438667297f, + -0.012270614504814f, 0.999839842319489f, -0.012653990648687f, + 0.999830007553101f, -0.013037359341979f, 0.999819874763489f, + -0.013420719653368f, 0.999809384346008f, -0.013804072514176f, + 0.999798655509949f, -0.014187417924404f, 0.999787628650665f, + -0.014570754021406f, 0.999776303768158f, -0.014954082667828f, + 0.999764680862427f, -0.015337402001023f, 0.999752819538116f, + -0.015720712020993f, 0.999740600585938f, -0.016104012727737f, + 0.999728083610535f, -0.016487304121256f, 0.999715328216553f, + -0.016870586201549f, 0.999702215194702f, -0.017253857105970f, + 0.999688863754272f, -0.017637118697166f, 0.999675154685974f, + -0.018020370975137f, 0.999661207199097f, -0.018403612077236f, + 0.999646902084351f, -0.018786842003465f, 0.999632358551025f, + -0.019170060753822f, 0.999617516994476f, -0.019553268328309f, + 0.999602377414703f, -0.019936462864280f, 0.999586939811707f, + -0.020319648087025f, 0.999571204185486f, -0.020702820271254f, + 0.999555170536041f, -0.021085981279612f, 0.999538838863373f, + -0.021469129249454f, 0.999522268772125f, -0.021852264180779f, + 0.999505341053009f, -0.022235386073589f, 0.999488115310669f, + -0.022618494927883f, 0.999470651149750f, -0.023001590743661f, + 0.999452829360962f, -0.023384673520923f, 0.999434769153595f, + -0.023767741397023f, 0.999416410923004f, -0.024150796234608f, + 0.999397754669189f, -0.024533838033676f, 0.999378740787506f, + -0.024916863068938f, 0.999359488487244f, -0.025299875065684f, + 0.999339938163757f, -0.025682870298624f, 0.999320089817047f, + -0.026065852493048f, 0.999299943447113f, -0.026448817923665f, + 0.999279558658600f, -0.026831768453121f, 0.999258816242218f, + -0.027214704081416f, 0.999237775802612f, -0.027597622945905f, + 0.999216496944427f, -0.027980525046587f, 0.999194860458374f, + -0.028363410383463f, 0.999172985553741f, -0.028746278956532f, + 0.999150753021240f, -0.029129132628441f, 0.999128282070160f, + -0.029511967673898f, 0.999105513095856f, -0.029894785955548f, + 0.999082446098328f, -0.030277585610747f, 0.999059081077576f, + -0.030660368502140f, 0.999035418033600f, -0.031043132767081f, + 0.999011456966400f, -0.031425878405571f, 0.998987197875977f, + -0.031808607280254f, 0.998962640762329f, -0.032191313803196f, + 0.998937785625458f, -0.032574005424976f, 0.998912692070007f, + -0.032956674695015f, 0.998887240886688f, -0.033339329063892f, + 0.998861551284790f, -0.033721961081028f, 0.998835504055023f, + -0.034104570746422f, 0.998809218406677f, -0.034487165510654f, + 0.998782634735107f, -0.034869734197855f, 0.998755753040314f, + -0.035252287983894f, 0.998728513717651f, -0.035634815692902f, + 0.998701035976410f, -0.036017324775457f, 0.998673319816589f, + -0.036399815231562f, 0.998645246028900f, -0.036782283335924f, + 0.998616874217987f, -0.037164725363255f, 0.998588204383850f, + -0.037547148764133f, 0.998559296131134f, -0.037929553538561f, + 0.998530030250549f, -0.038311932235956f, 0.998500525951386f, + -0.038694288581610f, 0.998470664024353f, -0.039076622575521f, + 0.998440563678741f, -0.039458930492401f, 0.998410165309906f, + -0.039841219782829f, 0.998379468917847f, -0.040223482996225f, + 0.998348474502563f, -0.040605723857880f, 0.998317182064056f, + -0.040987938642502f, 0.998285591602325f, -0.041370131075382f, + 0.998253703117371f, -0.041752301156521f, 0.998221516609192f, + -0.042134445160627f, 0.998189091682434f, -0.042516563087702f, + 0.998156309127808f, -0.042898654937744f, 0.998123228549957f, + -0.043280724436045f, 0.998089909553528f, -0.043662767857313f, + 0.998056292533875f, -0.044044785201550f, 0.998022377490997f, + -0.044426776468754f, 0.997988104820251f, -0.044808741658926f, + 0.997953593730927f, -0.045190680772066f, 0.997918784618378f, + -0.045572593808174f, 0.997883677482605f, -0.045954477041960f, + 0.997848331928253f, -0.046336337924004f, 0.997812628746033f, + -0.046718169003725f, 0.997776627540588f, -0.047099970281124f, + 0.997740387916565f, -0.047481749206781f, 0.997703790664673f, + -0.047863494604826f, 0.997666954994202f, -0.048245213925838f, + 0.997629821300507f, -0.048626907169819f, 0.997592389583588f, + -0.049008570611477f, 0.997554600238800f, -0.049390204250813f, + 0.997516572475433f, -0.049771808087826f, 0.997478306293488f, + -0.050153385847807f, 0.997439682483673f, -0.050534930080175f, + 0.997400760650635f, -0.050916448235512f, 0.997361540794373f, + -0.051297932863235f, 0.997322082519531f, -0.051679391413927f, + 0.997282266616821f, -0.052060816437006f, 0.997242212295532f, + -0.052442211657763f, 0.997201859951019f, -0.052823577076197f, + 0.997161149978638f, -0.053204908967018f, 0.997120201587677f, + -0.053586211055517f, 0.997078955173492f, -0.053967483341694f, + 0.997037410736084f, -0.054348722100258f, 0.996995627880096f, + -0.054729927331209f, 0.996953487396240f, -0.055111102759838f, + 0.996911048889160f, -0.055492244660854f, 0.996868371963501f, + -0.055873356759548f, 0.996825337409973f, -0.056254431605339f, + 0.996782064437866f, -0.056635476648808f, 0.996738493442535f, + -0.057016488164663f, 0.996694624423981f, -0.057397462427616f, + 0.996650457382202f, -0.057778406888247f, 0.996605992317200f, + -0.058159314095974f, 0.996561229228973f, -0.058540191501379f, + 0.996516168117523f, -0.058921031653881f, 0.996470808982849f, + -0.059301838278770f, 0.996425211429596f, -0.059682607650757f, + 0.996379256248474f, -0.060063343495131f, 0.996333062648773f, + -0.060444042086601f, 0.996286571025848f, -0.060824707150459f, + 0.996239781379700f, -0.061205338686705f, 0.996192693710327f, + -0.061585929244757f, 0.996145308017731f, -0.061966486275196f, + 0.996097624301910f, -0.062347009778023f, 0.996049642562866f, + -0.062727488577366f, 0.996001422405243f, -0.063107937574387f, + 0.995952844619751f, -0.063488349318504f, 0.995904028415680f, + -0.063868723809719f, 0.995854854583740f, -0.064249053597450f, + 0.995805442333221f, -0.064629353582859f, 0.995755732059479f, + -0.065009608864784f, 0.995705723762512f, -0.065389834344387f, + 0.995655417442322f, -0.065770015120506f, 0.995604813098907f, + -0.066150158643723f, 0.995553970336914f, -0.066530264914036f, + 0.995502769947052f, -0.066910326480865f, 0.995451331138611f, + -0.067290350794792f, 0.995399534702301f, -0.067670337855816f, + 0.995347499847412f, -0.068050287663937f, 0.995295166969299f, + -0.068430192768574f, 0.995242536067963f, -0.068810060620308f, + 0.995189607143402f, -0.069189883768559f, 0.995136380195618f, + -0.069569669663906f, 0.995082914829254f, -0.069949418306351f, + 0.995029091835022f, -0.070329122245312f, 0.994975030422211f, + -0.070708781480789f, 0.994920611381531f, -0.071088403463364f, + 0.994865953922272f, -0.071467980742455f, 0.994810998439789f, + -0.071847513318062f, 0.994755744934082f, -0.072227008640766f, + 0.994700193405151f, -0.072606459259987f, 0.994644403457642f, + -0.072985872626305f, 0.994588255882263f, -0.073365233838558f, + 0.994531810283661f, -0.073744557797909f, 0.994475126266479f, + -0.074123837053776f, 0.994418144226074f, -0.074503071606159f, + 0.994360864162445f, -0.074882268905640f, 0.994303286075592f, + -0.075261414051056f, 0.994245409965515f, -0.075640521943569f, + 0.994187235832214f, -0.076019577682018f, 0.994128763675690f, + -0.076398596167564f, 0.994070053100586f, -0.076777562499046f, + 0.994010984897614f, -0.077156484127045f, 0.993951678276062f, + -0.077535368502140f, 0.993892073631287f, -0.077914200723171f, + 0.993832170963287f, -0.078292988240719f, 0.993771970272064f, + -0.078671731054783f, 0.993711471557617f, -0.079050421714783f, + 0.993650734424591f, -0.079429075121880f, 0.993589639663696f, + -0.079807676374912f, 0.993528306484222f, -0.080186225473881f, + 0.993466615676880f, -0.080564737319946f, 0.993404686450958f, + -0.080943197011948f, 0.993342459201813f, -0.081321612000465f, + 0.993279933929443f, -0.081699974834919f, 0.993217170238495f, + -0.082078292965889f, 0.993154048919678f, -0.082456558942795f, + 0.993090689182281f, -0.082834780216217f, 0.993026971817017f, + -0.083212949335575f, 0.992963016033173f, -0.083591073751450f, + 0.992898762226105f, -0.083969146013260f, 0.992834210395813f, + -0.084347173571587f, 0.992769360542297f, -0.084725148975849f, + 0.992704212665558f, -0.085103072226048f, 0.992638826370239f, + -0.085480943322182f, 0.992573142051697f, -0.085858769714832f, + 0.992507100105286f, -0.086236543953419f, 0.992440819740295f, + -0.086614266037941f, 0.992374241352081f, -0.086991935968399f, + 0.992307364940643f, -0.087369553744793f, 0.992240250110626f, + -0.087747126817703f, 0.992172777652740f, -0.088124647736549f, + 0.992105066776276f, -0.088502109050751f, 0.992036998271942f, + -0.088879525661469f, 0.991968691349030f, -0.089256882667542f, + 0.991900086402893f, -0.089634194970131f, 0.991831183433533f, + -0.090011447668076f, 0.991762042045593f, -0.090388655662537f, + 0.991692543029785f, -0.090765804052353f, 0.991622805595398f, + -0.091142900288105f, 0.991552770137787f, -0.091519944369793f, + 0.991482377052307f, -0.091896936297417f, 0.991411805152893f, + -0.092273868620396f, 0.991340875625610f, -0.092650748789310f, + 0.991269648075104f, -0.093027576804161f, 0.991198182106018f, + -0.093404345214367f, 0.991126358509064f, -0.093781061470509f, + 0.991054296493530f, -0.094157725572586f, 0.990981936454773f, + -0.094534330070019f, 0.990909278392792f, -0.094910882413387f, + 0.990836322307587f, -0.095287375152111f, 0.990763127803802f, + -0.095663815736771f, 0.990689575672150f, -0.096040196716785f, + 0.990615785121918f, -0.096416525542736f, 0.990541696548462f, + -0.096792794764042f, 0.990467309951782f, -0.097169004380703f, + 0.990392625331879f, -0.097545161843300f, 0.990317702293396f, + -0.097921259701252f, 0.990242421627045f, -0.098297297954559f, + 0.990166902542114f, -0.098673284053802f, 0.990091085433960f, + -0.099049203097820f, 0.990014970302582f, -0.099425069987774f, + 0.989938557147980f, -0.099800877273083f, 0.989861845970154f, + -0.100176624953747f, 0.989784896373749f, -0.100552320480347f, + 0.989707589149475f, -0.100927948951721f, 0.989630043506622f, + -0.101303517818451f, 0.989552199840546f, -0.101679034531116f, + 0.989474058151245f, -0.102054484188557f, 0.989395678043365f, + -0.102429874241352f, 0.989316940307617f, -0.102805204689503f, + 0.989237964153290f, -0.103180475533009f, 0.989158689975739f, + -0.103555686771870f, 0.989079117774963f, -0.103930838406086f, + 0.988999247550964f, -0.104305922985077f, 0.988919138908386f, + -0.104680955410004f, 0.988838672637939f, -0.105055920779705f, + 0.988757967948914f, -0.105430819094181f, 0.988676965236664f, + -0.105805665254593f, 0.988595664501190f, -0.106180444359779f, + 0.988514065742493f, -0.106555156409740f, 0.988432228565216f, + -0.106929816305637f, 0.988350033760071f, -0.107304409146309f, + 0.988267600536346f, -0.107678934931755f, 0.988184869289398f, + -0.108053401112556f, 0.988101840019226f, -0.108427800238132f, + 0.988018512725830f, -0.108802139759064f, 0.987934947013855f, + -0.109176412224770f, 0.987851083278656f, -0.109550617635250f, + 0.987766921520233f, -0.109924763441086f, 0.987682461738586f, + -0.110298842191696f, 0.987597703933716f, -0.110672861337662f, + 0.987512648105621f, -0.111046813428402f, 0.987427353858948f, + -0.111420698463917f, 0.987341761589050f, -0.111794516444206f, + 0.987255871295929f, -0.112168267369270f, 0.987169682979584f, + -0.112541958689690f, 0.987083256244659f, -0.112915575504303f, + 0.986996471881866f, -0.113289132714272f, 0.986909449100494f, + -0.113662622869015f, 0.986822128295898f, -0.114036038517952f, + 0.986734509468079f, -0.114409394562244f, 0.986646652221680f, + -0.114782683551311f, 0.986558437347412f, -0.115155905485153f, + 0.986469984054565f, -0.115529052913189f, 0.986381232738495f, + -0.115902140736580f, 0.986292183399200f, -0.116275154054165f, + 0.986202836036682f, -0.116648100316525f, 0.986113250255585f, + -0.117020979523659f, 0.986023366451263f, -0.117393791675568f, + 0.985933184623718f, -0.117766529321671f, 0.985842704772949f, + -0.118139199912548f, 0.985751926898956f, -0.118511803448200f, + 0.985660910606384f, -0.118884332478046f, 0.985569596290588f, + -0.119256794452667f, 0.985477983951569f, -0.119629189372063f, + 0.985386073589325f, -0.120001509785652f, 0.985293865203857f, + -0.120373763144016f, 0.985201418399811f, -0.120745941996574f, + 0.985108673572540f, -0.121118053793907f, 0.985015630722046f, + -0.121490091085434f, 0.984922289848328f, -0.121862053871155f, + 0.984828710556030f, -0.122233949601650f, 0.984734773635864f, + -0.122605770826340f, 0.984640598297119f, -0.122977524995804f, + 0.984546124935150f, -0.123349204659462f, 0.984451413154602f, + -0.123720809817314f, 0.984356343746185f, -0.124092340469360f, + 0.984261035919189f, -0.124463804066181f, 0.984165430068970f, + -0.124835193157196f, 0.984069526195526f, -0.125206500291824f, + 0.983973383903503f, -0.125577747821808f, 0.983876943588257f, + -0.125948905944824f, 0.983780145645142f, -0.126320004463196f, + 0.983683168888092f, -0.126691013574600f, 0.983585834503174f, + -0.127061963081360f, 0.983488261699677f, -0.127432823181152f, + 0.983390331268311f, -0.127803623676300f, 0.983292162418365f, + -0.128174334764481f, 0.983193755149841f, -0.128544986248016f, + 0.983094990253448f, -0.128915548324585f, 0.982995986938477f, + -0.129286035895348f, 0.982896685600281f, -0.129656463861465f, + 0.982797086238861f, -0.130026802420616f, 0.982697248458862f, + -0.130397051572800f, 0.982597053050995f, -0.130767241120338f, + 0.982496619224548f, -0.131137356162071f, 0.982395887374878f, + -0.131507381796837f, 0.982294917106628f, -0.131877332925797f, + 0.982193589210510f, -0.132247209548950f, 0.982092022895813f, + -0.132617011666298f, 0.981990158557892f, -0.132986739277840f, + 0.981888055801392f, -0.133356377482414f, 0.981785595417023f, + -0.133725941181183f, 0.981682896614075f, -0.134095430374146f, + 0.981579899787903f, -0.134464830160141f, 0.981476604938507f, + -0.134834155440331f, 0.981373071670532f, -0.135203406214714f, + 0.981269240379334f, -0.135572582483292f, 0.981165111064911f, + -0.135941669344902f, 0.981060683727264f, -0.136310681700706f, + 0.980956017971039f, -0.136679604649544f, 0.980851054191589f, + -0.137048453092575f, 0.980745792388916f, -0.137417227029800f, + 0.980640232563019f, -0.137785911560059f, 0.980534434318542f, + -0.138154521584511f, 0.980428338050842f, -0.138523042201996f, + 0.980321943759918f, -0.138891488313675f, 0.980215251445770f, + -0.139259845018387f, 0.980108320713043f, -0.139628127217293f, + 0.980001091957092f, -0.139996320009232f, 0.979893565177917f, + -0.140364438295364f, 0.979785740375519f, -0.140732467174530f, + 0.979677677154541f, -0.141100421547890f, 0.979569315910339f, + -0.141468286514282f, 0.979460656642914f, -0.141836062073708f, + 0.979351758956909f, -0.142203763127327f, 0.979242503643036f, + -0.142571389675140f, 0.979133009910584f, -0.142938911914825f, + 0.979023277759552f, -0.143306359648705f, 0.978913187980652f, + -0.143673732876778f, 0.978802859783173f, -0.144041016697884f, + 0.978692233562469f, -0.144408211112022f, 0.978581368923187f, + -0.144775316119194f, 0.978470146656036f, -0.145142331719399f, + 0.978358685970306f, -0.145509272813797f, 0.978246986865997f, + -0.145876124501228f, 0.978134930133820f, -0.146242901682854f, + 0.978022634983063f, -0.146609574556351f, 0.977910041809082f, + -0.146976172924042f, 0.977797150611877f, -0.147342681884766f, + 0.977684020996094f, -0.147709101438522f, 0.977570593357086f, + -0.148075446486473f, 0.977456867694855f, -0.148441687226295f, + 0.977342903614044f, -0.148807853460312f, 0.977228581905365f, + -0.149173930287361f, 0.977114021778107f, -0.149539917707443f, + 0.976999223232269f, -0.149905815720558f, 0.976884067058563f, + -0.150271624326706f, 0.976768672466278f, -0.150637343525887f, + 0.976653039455414f, -0.151002973318100f, 0.976537048816681f, + -0.151368513703346f, 0.976420819759369f, -0.151733979582787f, + 0.976304292678833f, -0.152099341154099f, 0.976187527179718f, + -0.152464613318443f, 0.976070404052734f, -0.152829796075821f, + 0.975953042507172f, -0.153194904327393f, 0.975835442543030f, + -0.153559908270836f, 0.975717484951019f, -0.153924822807312f, + 0.975599288940430f, -0.154289647936821f, 0.975480854511261f, + -0.154654383659363f, 0.975362062454224f, -0.155019029974937f, + 0.975243031978607f, -0.155383571982384f, 0.975123703479767f, + -0.155748039484024f, 0.975004136562347f, -0.156112402677536f, + 0.974884271621704f, -0.156476691365242f, 0.974764108657837f, + -0.156840875744820f, 0.974643647670746f, -0.157204970717430f, + 0.974522948265076f, -0.157568961381912f, 0.974401950836182f, + -0.157932877540588f, 0.974280655384064f, -0.158296689391136f, + 0.974159121513367f, -0.158660411834717f, 0.974037289619446f, + -0.159024044871330f, 0.973915159702301f, -0.159387573599815f, + 0.973792791366577f, -0.159751012921333f, 0.973670125007629f, + -0.160114362835884f, 0.973547160625458f, -0.160477623343468f, + 0.973423957824707f, -0.160840779542923f, 0.973300457000732f, + -0.161203846335411f, 0.973176658153534f, -0.161566808819771f, + 0.973052620887756f, -0.161929681897163f, 0.972928285598755f, + -0.162292465567589f, 0.972803652286530f, -0.162655144929886f, + 0.972678780555725f, -0.163017734885216f, 0.972553610801697f, + -0.163380220532417f, 0.972428143024445f, -0.163742616772652f, + 0.972302436828613f, -0.164104923605919f, 0.972176432609558f, + -0.164467126131058f, 0.972050130367279f, -0.164829224348068f, + 0.971923589706421f, -0.165191248059273f, 0.971796751022339f, + -0.165553152561188f, 0.971669614315033f, -0.165914967656136f, + 0.971542239189148f, -0.166276678442955f, 0.971414566040039f, + -0.166638299822807f, 0.971286594867706f, -0.166999831795692f, + 0.971158385276794f, -0.167361244559288f, 0.971029877662659f, + -0.167722567915916f, 0.970901072025299f, -0.168083801865578f, + 0.970772027969360f, -0.168444931507111f, 0.970642685890198f, + -0.168805956840515f, 0.970513105392456f, -0.169166877865791f, + 0.970383226871490f, -0.169527709484100f, 0.970253050327301f, + -0.169888436794281f, 0.970122575759888f, -0.170249074697495f, + 0.969991862773895f, -0.170609608292580f, 0.969860911369324f, + -0.170970037579536f, 0.969729602336884f, -0.171330362558365f, + 0.969598054885864f, -0.171690583229065f, 0.969466269016266f, + -0.172050714492798f, 0.969334125518799f, -0.172410741448402f, + 0.969201743602753f, -0.172770664095879f, 0.969069123268127f, + -0.173130482435226f, 0.968936204910278f, -0.173490211367607f, + 0.968802988529205f, -0.173849821090698f, 0.968669533729553f, + -0.174209341406822f, 0.968535780906677f, -0.174568757414818f, + 0.968401730060577f, -0.174928069114685f, 0.968267440795898f, + -0.175287276506424f, 0.968132853507996f, -0.175646379590034f, + 0.967997968196869f, -0.176005378365517f, 0.967862844467163f, + -0.176364272832870f, 0.967727422714233f, -0.176723077893257f, + 0.967591762542725f, -0.177081763744354f, 0.967455804347992f, + -0.177440345287323f, 0.967319548130035f, -0.177798837423325f, + 0.967183053493500f, -0.178157210350037f, 0.967046260833740f, + -0.178515478968620f, 0.966909229755402f, -0.178873643279076f, + 0.966771900653839f, -0.179231703281403f, 0.966634273529053f, + -0.179589673876762f, 0.966496407985687f, -0.179947525262833f, + 0.966358244419098f, -0.180305257439613f, 0.966219842433929f, + -0.180662900209427f, 0.966081082820892f, -0.181020438671112f, + 0.965942144393921f, -0.181377857923508f, 0.965802907943726f, + -0.181735187768936f, 0.965663373470306f, -0.182092398405075f, + 0.965523540973663f, -0.182449504733086f, 0.965383470058441f, + -0.182806491851807f, 0.965243160724640f, -0.183163389563560f, + 0.965102493762970f, -0.183520168066025f, 0.964961588382721f, + -0.183876842260361f, 0.964820444583893f, -0.184233412146568f, + 0.964679002761841f, -0.184589877724648f, 0.964537262916565f, + -0.184946224093437f, 0.964395284652710f, -0.185302466154099f, + 0.964253067970276f, -0.185658603906631f, 0.964110493659973f, + -0.186014622449875f, 0.963967680931091f, -0.186370536684990f, + 0.963824629783630f, -0.186726331710815f, 0.963681280612946f, + -0.187082037329674f, 0.963537633419037f, -0.187437608838081f, + 0.963393747806549f, -0.187793090939522f, 0.963249564170837f, + -0.188148453831673f, 0.963105142116547f, -0.188503712415695f, + 0.962960422039032f, -0.188858851790428f, 0.962815403938293f, + -0.189213871955872f, 0.962670147418976f, -0.189568802714348f, + 0.962524592876434f, -0.189923599362373f, 0.962378799915314f, + -0.190278306603432f, 0.962232708930969f, -0.190632879734039f, + 0.962086379528046f, -0.190987363457680f, 0.961939752101898f, + -0.191341713070869f, 0.961792886257172f, -0.191695958375931f, + 0.961645722389221f, -0.192050099372864f, 0.961498260498047f, + -0.192404121160507f, 0.961350560188293f, -0.192758023738861f, + 0.961202561855316f, -0.193111822009087f, 0.961054325103760f, + -0.193465501070023f, 0.960905790328979f, -0.193819075822830f, + 0.960757017135620f, -0.194172516465187f, 0.960607945919037f, + -0.194525867700577f, 0.960458636283875f, -0.194879084825516f, + 0.960309028625488f, -0.195232197642326f, 0.960159122943878f, + -0.195585191249847f, 0.960008978843689f, -0.195938065648079f, + 0.959858596324921f, -0.196290835738182f, 0.959707856178284f, + -0.196643486618996f, 0.959556937217712f, -0.196996018290520f, + 0.959405720233917f, -0.197348430752754f, 0.959254205226898f, + -0.197700738906860f, 0.959102451801300f, -0.198052927851677f, + 0.958950400352478f, -0.198404997587204f, 0.958798050880432f, + -0.198756948113441f, 0.958645522594452f, -0.199108779430389f, + 0.958492636680603f, -0.199460506439209f, 0.958339512348175f, + -0.199812099337578f, 0.958186149597168f, -0.200163587927818f, + 0.958032488822937f, -0.200514942407608f, 0.957878530025482f, + -0.200866192579269f, 0.957724332809448f, -0.201217323541641f, + 0.957569897174835f, -0.201568335294724f, 0.957415163516998f, + -0.201919227838516f, 0.957260131835938f, -0.202270001173019f, + 0.957104861736298f, -0.202620655298233f, 0.956949353218079f, + -0.202971190214157f, 0.956793546676636f, -0.203321605920792f, + 0.956637442111969f, -0.203671902418137f, 0.956481099128723f, + -0.204022079706192f, 0.956324458122253f, -0.204372137784958f, + 0.956167578697205f, -0.204722076654434f, 0.956010460853577f, + -0.205071896314621f, 0.955853044986725f, -0.205421581864357f, + 0.955695331096649f, -0.205771163105965f, 0.955537378787994f, + -0.206120610237122f, 0.955379128456116f, -0.206469938158989f, + 0.955220639705658f, -0.206819161772728f, 0.955061912536621f, + -0.207168251276016f, 0.954902827739716f, -0.207517206668854f, + 0.954743564128876f, -0.207866057753563f, 0.954584002494812f, + -0.208214774727821f, 0.954424142837524f, -0.208563387393951f, + 0.954264044761658f, -0.208911851048470f, 0.954103708267212f, + -0.209260210394859f, 0.953943073749542f, -0.209608450531960f, + 0.953782141208649f, -0.209956556558609f, 0.953620970249176f, + -0.210304543375969f, 0.953459560871124f, -0.210652396082878f, + 0.953297853469849f, -0.211000129580498f, 0.953135907649994f, + -0.211347743868828f, 0.952973663806915f, -0.211695238947868f, + 0.952811121940613f, -0.212042599916458f, 0.952648401260376f, + -0.212389841675758f, 0.952485322952271f, -0.212736949324608f, + 0.952322065830231f, -0.213083937764168f, 0.952158451080322f, + -0.213430806994438f, 0.951994657516479f, -0.213777542114258f, + 0.951830565929413f, -0.214124158024788f, 0.951666176319122f, + -0.214470639824867f, 0.951501548290253f, -0.214817002415657f, + 0.951336681842804f, -0.215163245797157f, 0.951171517372131f, + -0.215509355068207f, 0.951006054878235f, -0.215855330228806f, + 0.950840353965759f, -0.216201186180115f, 0.950674414634705f, + -0.216546908020973f, 0.950508177280426f, -0.216892510652542f, + 0.950341701507568f, -0.217237979173660f, 0.950174987316132f, + -0.217583328485489f, 0.950007975101471f, -0.217928543686867f, + 0.949840664863586f, -0.218273624777794f, 0.949673116207123f, + -0.218618586659431f, 0.949505329132080f, -0.218963414430618f, + 0.949337244033813f, -0.219308122992516f, 0.949168920516968f, + -0.219652697443962f, 0.949000298976898f, -0.219997137784958f, + 0.948831439018250f, -0.220341444015503f, 0.948662281036377f, + -0.220685631036758f, 0.948492884635925f, -0.221029683947563f, + 0.948323249816895f, -0.221373617649078f, 0.948153316974640f, + -0.221717402338982f, 0.947983145713806f, -0.222061067819595f, + 0.947812676429749f, -0.222404599189758f, 0.947641968727112f, + -0.222748011350632f, 0.947470963001251f, -0.223091274499893f, + 0.947299718856812f, -0.223434418439865f, 0.947128236293793f, + -0.223777428269386f, 0.946956455707550f, -0.224120303988457f, + 0.946784436702728f, -0.224463045597076f, 0.946612179279327f, + -0.224805667996407f, 0.946439623832703f, -0.225148141384125f, + 0.946266770362854f, -0.225490495562553f, 0.946093678474426f, + -0.225832715630531f, 0.945920348167419f, -0.226174786686897f, + 0.945746779441834f, -0.226516738533974f, 0.945572853088379f, + -0.226858556270599f, 0.945398747920990f, -0.227200239896774f, + 0.945224344730377f, -0.227541789412498f, 0.945049703121185f, + -0.227883204817772f, 0.944874763488770f, -0.228224486112595f, + 0.944699645042419f, -0.228565633296967f, 0.944524168968201f, + -0.228906646370888f, 0.944348454475403f, -0.229247525334358f, + 0.944172501564026f, -0.229588270187378f, 0.943996310234070f, + -0.229928880929947f, 0.943819820880890f, -0.230269357562065f, + 0.943643093109131f, -0.230609700083733f, 0.943466067314148f, + -0.230949893593788f, 0.943288803100586f, -0.231289967894554f, + 0.943111240863800f, -0.231629893183708f, 0.942933499813080f, + -0.231969684362412f, 0.942755401134491f, -0.232309341430664f, + 0.942577123641968f, -0.232648864388466f, 0.942398548126221f, + -0.232988253235817f, 0.942219734191895f, -0.233327493071556f, + 0.942040622234344f, -0.233666598796844f, 0.941861271858215f, + -0.234005570411682f, 0.941681683063507f, -0.234344407916069f, + 0.941501796245575f, -0.234683111310005f, 0.941321671009064f, + -0.235021665692329f, 0.941141307353973f, -0.235360085964203f, + 0.940960645675659f, -0.235698372125626f, 0.940779745578766f, + -0.236036509275436f, 0.940598547458649f, -0.236374512314796f, + 0.940417110919952f, -0.236712381243706f, 0.940235435962677f, + -0.237050101161003f, 0.940053522586823f, -0.237387686967850f, + 0.939871311187744f, -0.237725138664246f, 0.939688861370087f, + -0.238062441349030f, 0.939506113529205f, -0.238399609923363f, + 0.939323127269745f, -0.238736644387245f, 0.939139902591705f, + -0.239073529839516f, 0.938956379890442f, -0.239410281181335f, + 0.938772618770599f, -0.239746883511543f, 0.938588619232178f, + -0.240083336830139f, 0.938404381275177f, -0.240419670939446f, + 0.938219845294952f, -0.240755841135979f, 0.938035070896149f, + -0.241091892123222f, 0.937849998474121f, -0.241427779197693f, + 0.937664687633514f, -0.241763532161713f, 0.937479138374329f, + -0.242099151015282f, 0.937293350696564f, -0.242434620857239f, + 0.937107264995575f, -0.242769956588745f, 0.936920940876007f, + -0.243105143308640f, 0.936734318733215f, -0.243440181016922f, + 0.936547517776489f, -0.243775084614754f, 0.936360359191895f, + -0.244109839200974f, 0.936173021793365f, -0.244444444775581f, + 0.935985386371613f, -0.244778916239738f, 0.935797572135925f, + -0.245113238692284f, 0.935609400272369f, -0.245447427034378f, + 0.935421049594879f, -0.245781451463699f, 0.935232400894165f, + -0.246115356683731f, 0.935043513774872f, -0.246449097990990f, + 0.934854328632355f, -0.246782705187798f, 0.934664964675903f, + -0.247116148471832f, 0.934475243091583f, -0.247449472546577f, + 0.934285342693329f, -0.247782632708550f, 0.934095203876495f, + -0.248115643858910f, 0.933904767036438f, -0.248448520898819f, + 0.933714091777802f, -0.248781248927116f, 0.933523118495941f, + -0.249113827943802f, 0.933331906795502f, -0.249446272850037f, + 0.933140456676483f, -0.249778553843498f, 0.932948768138886f, + -0.250110685825348f, 0.932756841182709f, -0.250442683696747f, + 0.932564616203308f, -0.250774532556534f, 0.932372152805328f, + -0.251106232404709f, 0.932179391384125f, -0.251437783241272f, + 0.931986451148987f, -0.251769185066223f, 0.931793212890625f, + -0.252100437879562f, 0.931599736213684f, -0.252431541681290f, + 0.931405961513519f, -0.252762526273727f, 0.931211948394775f, + -0.253093332052231f, 0.931017756462097f, -0.253423988819122f, + 0.930823206901550f, -0.253754496574402f, 0.930628478527069f, + -0.254084855318069f, 0.930433452129364f, -0.254415065050125f, + 0.930238187313080f, -0.254745125770569f, 0.930042684078217f, + -0.255075037479401f, 0.929846942424774f, -0.255404800176620f, + 0.929650902748108f, -0.255734413862228f, 0.929454624652863f, + -0.256063878536224f, 0.929258108139038f, -0.256393194198608f, + 0.929061353206635f, -0.256722360849380f, 0.928864300251007f, + -0.257051378488541f, 0.928667008876801f, -0.257380217313766f, + 0.928469479084015f, -0.257708936929703f, 0.928271710872650f, + -0.258037507534027f, 0.928073644638062f, -0.258365899324417f, + 0.927875399589539f, -0.258694142103195f, 0.927676856517792f, + -0.259022265672684f, 0.927478015422821f, -0.259350210428238f, + 0.927278995513916f, -0.259678006172180f, 0.927079677581787f, + -0.260005623102188f, 0.926880121231079f, -0.260333120822906f, + 0.926680326461792f, -0.260660469532013f, 0.926480293273926f, + -0.260987639427185f, 0.926280021667480f, -0.261314690113068f, + 0.926079452037811f, -0.261641561985016f, 0.925878643989563f, + -0.261968284845352f, 0.925677597522736f, -0.262294828891754f, + 0.925476312637329f, -0.262621253728867f, 0.925274729728699f, + -0.262947499752045f, 0.925072908401489f, -0.263273626565933f, + 0.924870908260345f, -0.263599574565887f, 0.924668610095978f, + -0.263925373554230f, 0.924466013908386f, -0.264250993728638f, + 0.924263238906860f, -0.264576494693756f, 0.924060165882111f, + -0.264901816844940f, 0.923856854438782f, -0.265226989984512f, + 0.923653304576874f, -0.265552014112473f, 0.923449516296387f, + -0.265876859426498f, 0.923245489597321f, -0.266201555728912f, + 0.923041164875031f, -0.266526103019714f, 0.922836601734161f, + -0.266850501298904f, 0.922631800174713f, -0.267174720764160f, + 0.922426760196686f, -0.267498821020126f, 0.922221481800079f, + -0.267822742462158f, 0.922015964984894f, -0.268146485090256f, + 0.921810150146484f, -0.268470078706741f, 0.921604096889496f, + -0.268793523311615f, 0.921397805213928f, -0.269116818904877f, + 0.921191275119781f, -0.269439965486526f, 0.920984506607056f, + -0.269762933254242f, 0.920777499675751f, -0.270085722208023f, + 0.920570194721222f, -0.270408391952515f, 0.920362710952759f, + -0.270730882883072f, 0.920154929161072f, -0.271053224802017f, + 0.919946908950806f, -0.271375387907028f, 0.919738650321960f, + -0.271697402000427f, 0.919530093669891f, -0.272019267082214f, + 0.919321358203888f, -0.272340953350067f, 0.919112324714661f, + -0.272662490606308f, 0.918903112411499f, -0.272983878850937f, + 0.918693602085114f, -0.273305088281631f, 0.918483853340149f, + -0.273626148700714f, 0.918273866176605f, -0.273947030305862f, + 0.918063640594482f, -0.274267762899399f, 0.917853116989136f, + -0.274588316679001f, 0.917642414569855f, -0.274908751249313f, + 0.917431414127350f, -0.275228977203369f, 0.917220234870911f, + -0.275549083948135f, 0.917008757591248f, -0.275868982076645f, + 0.916797041893005f, -0.276188760995865f, 0.916585087776184f, + -0.276508361101151f, 0.916372895240784f, -0.276827782392502f, + 0.916160404682159f, -0.277147054672241f, 0.915947735309601f, + -0.277466177940369f, 0.915734827518463f, -0.277785122394562f, + 0.915521621704102f, -0.278103888034821f, 0.915308177471161f, + -0.278422504663467f, 0.915094554424286f, -0.278740972280502f, + 0.914880633354187f, -0.279059261083603f, 0.914666473865509f, + -0.279377400875092f, 0.914452075958252f, -0.279695361852646f, + 0.914237439632416f, -0.280013144016266f, 0.914022505283356f, + -0.280330777168274f, 0.913807392120361f, -0.280648261308670f, + 0.913592040538788f, -0.280965566635132f, 0.913376390933990f, + -0.281282693147659f, 0.913160502910614f, -0.281599670648575f, + 0.912944436073303f, -0.281916469335556f, 0.912728071212769f, + -0.282233119010925f, 0.912511467933655f, -0.282549589872360f, + 0.912294626235962f, -0.282865911722183f, 0.912077546119690f, + -0.283182054758072f, 0.911860227584839f, -0.283498018980026f, + 0.911642670631409f, -0.283813834190369f, 0.911424875259399f, + -0.284129470586777f, 0.911206841468811f, -0.284444957971573f, + 0.910988569259644f, -0.284760266542435f, 0.910769999027252f, + -0.285075396299362f, 0.910551249980927f, -0.285390377044678f, + 0.910332262516022f, -0.285705178976059f, 0.910112977027893f, + -0.286019802093506f, 0.909893512725830f, -0.286334276199341f, + 0.909673750400543f, -0.286648571491241f, 0.909453809261322f, + -0.286962717771530f, 0.909233570098877f, -0.287276685237885f, + 0.909013092517853f, -0.287590473890305f, 0.908792436122894f, + -0.287904083728790f, 0.908571481704712f, -0.288217544555664f, + 0.908350288867950f, -0.288530826568604f, 0.908128857612610f, + -0.288843959569931f, 0.907907187938690f, -0.289156883955002f, + 0.907685279846191f, -0.289469659328461f, 0.907463192939758f, + -0.289782285690308f, 0.907240808010101f, -0.290094703435898f, + 0.907018184661865f, -0.290406972169876f, 0.906795322895050f, + -0.290719062089920f, 0.906572222709656f, -0.291031002998352f, + 0.906348884105682f, -0.291342735290527f, 0.906125307083130f, + -0.291654318571091f, 0.905901491641998f, -0.291965723037720f, + 0.905677437782288f, -0.292276978492737f, 0.905453145503998f, + -0.292588025331497f, 0.905228614807129f, -0.292898923158646f, + 0.905003845691681f, -0.293209642171860f, 0.904778838157654f, + -0.293520182371140f, 0.904553592205048f, -0.293830573558807f, + 0.904328107833862f, -0.294140785932541f, 0.904102385044098f, + -0.294450789690018f, 0.903876423835754f, -0.294760644435883f, + 0.903650224208832f, -0.295070350170136f, 0.903423786163330f, + -0.295379847288132f, 0.903197109699249f, -0.295689195394516f, + 0.902970194816589f, -0.295998334884644f, 0.902743041515350f, + -0.296307325363159f, 0.902515649795532f, -0.296616137027740f, + 0.902288019657135f, -0.296924799680710f, 0.902060210704803f, + -0.297233253717422f, 0.901832103729248f, -0.297541528940201f, + 0.901603758335114f, -0.297849655151367f, 0.901375174522400f, + -0.298157602548599f, 0.901146411895752f, -0.298465341329575f, + 0.900917351245880f, -0.298772931098938f, 0.900688111782074f, + -0.299080342054367f, 0.900458574295044f, -0.299387603998184f, + 0.900228857994080f, -0.299694657325745f, 0.899998843669891f, + -0.300001531839371f, 0.899768650531769f, -0.300308227539063f, + 0.899538159370422f, -0.300614774227142f, 0.899307489395142f, + -0.300921112298965f, 0.899076581001282f, -0.301227301359177f, + 0.898845434188843f, -0.301533311605453f, 0.898614048957825f, + -0.301839113235474f, 0.898382425308228f, -0.302144765853882f, + 0.898150563240051f, -0.302450239658356f, 0.897918462753296f, + -0.302755534648895f, 0.897686123847961f, -0.303060621023178f, + 0.897453546524048f, -0.303365558385849f, 0.897220790386200f, + -0.303670316934586f, 0.896987736225128f, -0.303974896669388f, + 0.896754503250122f, -0.304279297590256f, 0.896520972251892f, + -0.304583519697189f, 0.896287262439728f, -0.304887533187866f, + 0.896053314208984f, -0.305191397666931f, 0.895819067955017f, + -0.305495083332062f, 0.895584642887115f, -0.305798590183258f, + 0.895349979400635f, -0.306101888418198f, 0.895115137100220f, + -0.306405037641525f, 0.894879996776581f, -0.306708008050919f, + 0.894644618034363f, -0.307010769844055f, 0.894409060478210f, + -0.307313382625580f, 0.894173204898834f, -0.307615786790848f, + 0.893937170505524f, -0.307918041944504f, 0.893700897693634f, + -0.308220088481903f, 0.893464326858521f, -0.308521956205368f, + 0.893227577209473f, -0.308823645114899f, 0.892990648746490f, + -0.309125155210495f, 0.892753422260284f, -0.309426486492157f, + 0.892515957355499f, -0.309727638959885f, 0.892278313636780f, + -0.310028612613678f, 0.892040371894836f, -0.310329377651215f, + 0.891802251338959f, -0.310629993677139f, 0.891563892364502f, + -0.310930401086807f, 0.891325294971466f, -0.311230629682541f, + 0.891086459159851f, -0.311530679464340f, 0.890847444534302f, + -0.311830550432205f, 0.890608131885529f, -0.312130242586136f, + 0.890368640422821f, -0.312429755926132f, 0.890128850936890f, + -0.312729060649872f, 0.889888882637024f, -0.313028186559677f, + 0.889648675918579f, -0.313327133655548f, 0.889408230781555f, + -0.313625901937485f, 0.889167606830597f, -0.313924491405487f, + 0.888926684856415f, -0.314222872257233f, 0.888685584068298f, + -0.314521104097366f, 0.888444244861603f, -0.314819127321243f, + 0.888202667236328f, -0.315116971731186f, 0.887960851192474f, + -0.315414607524872f, 0.887718796730042f, -0.315712094306946f, + 0.887476563453674f, -0.316009372472763f, 0.887234091758728f, + -0.316306471824646f, 0.886991322040558f, -0.316603392362595f, + 0.886748373508453f, -0.316900104284287f, 0.886505246162415f, + -0.317196637392044f, 0.886261820793152f, -0.317492991685867f, + 0.886018216609955f, -0.317789167165756f, 0.885774314403534f, + -0.318085134029388f, 0.885530233383179f, -0.318380922079086f, + 0.885285973548889f, -0.318676531314850f, 0.885041415691376f, + -0.318971961736679f, 0.884796679019928f, -0.319267183542252f, + 0.884551644325256f, -0.319562226533890f, 0.884306430816650f, + -0.319857090711594f, 0.884061038494110f, -0.320151746273041f, + 0.883815348148346f, -0.320446223020554f, 0.883569478988647f, + -0.320740520954132f, 0.883323311805725f, -0.321034610271454f, + 0.883076965808868f, -0.321328520774841f, 0.882830440998077f, + -0.321622252464294f, 0.882583618164063f, -0.321915775537491f, + 0.882336616516113f, -0.322209119796753f, 0.882089376449585f, + -0.322502255439758f, 0.881841897964478f, -0.322795242071152f, + 0.881594181060791f, -0.323088020086288f, 0.881346285343170f, + -0.323380589485168f, 0.881098151206970f, -0.323672980070114f, + 0.880849778652191f, -0.323965191841125f, 0.880601167678833f, + -0.324257194995880f, 0.880352377891541f, -0.324549019336700f, + 0.880103349685669f, -0.324840664863586f, 0.879854083061218f, + -0.325132101774216f, 0.879604578018188f, -0.325423330068588f, + 0.879354894161224f, -0.325714409351349f, 0.879104971885681f, + -0.326005280017853f, 0.878854811191559f, -0.326295942068100f, + 0.878604412078857f, -0.326586425304413f, 0.878353834152222f, + -0.326876699924469f, 0.878103017807007f, -0.327166795730591f, + 0.877851963043213f, -0.327456712722778f, 0.877600669860840f, + -0.327746421098709f, 0.877349197864532f, -0.328035950660706f, + 0.877097487449646f, -0.328325271606445f, 0.876845538616180f, + -0.328614413738251f, 0.876593410968781f, -0.328903347253799f, + 0.876341044902802f, -0.329192101955414f, 0.876088440418243f, + -0.329480648040771f, 0.875835597515106f, -0.329769015312195f, + 0.875582575798035f, -0.330057173967361f, 0.875329315662384f, + -0.330345153808594f, 0.875075817108154f, -0.330632925033569f, + 0.874822139739990f, -0.330920487642288f, 0.874568223953247f, + -0.331207901239395f, 0.874314069747925f, -0.331495076417923f, + 0.874059677124023f, -0.331782072782516f, 0.873805105686188f, + -0.332068890333176f, 0.873550295829773f, -0.332355499267578f, + 0.873295307159424f, -0.332641899585724f, 0.873040020465851f, + -0.332928121089935f, 0.872784554958344f, -0.333214133977890f, + 0.872528910636902f, -0.333499968051910f, 0.872272968292236f, + -0.333785593509674f, 0.872016847133636f, -0.334071010351181f, + 0.871760547161102f, -0.334356248378754f, 0.871503949165344f, + -0.334641307592392f, 0.871247172355652f, -0.334926128387451f, + 0.870990216732025f, -0.335210770368576f, 0.870733022689819f, + -0.335495233535767f, 0.870475590229034f, -0.335779488086700f, + 0.870217919349670f, -0.336063534021378f, 0.869960069656372f, + -0.336347371339798f, 0.869701981544495f, -0.336631029844284f, + 0.869443655014038f, -0.336914509534836f, 0.869185149669647f, + -0.337197750806808f, 0.868926405906677f, -0.337480813264847f, + 0.868667483329773f, -0.337763696908951f, 0.868408262729645f, + -0.338046342134476f, 0.868148922920227f, -0.338328808546066f, + 0.867889285087585f, -0.338611096143723f, 0.867629468441010f, + -0.338893145322800f, 0.867369413375854f, -0.339175015687943f, + 0.867109179496765f, -0.339456677436829f, 0.866848707199097f, + -0.339738160371780f, 0.866588056087494f, -0.340019434690475f, + 0.866327106952667f, -0.340300500392914f, 0.866066038608551f, + -0.340581357479095f, 0.865804672241211f, -0.340862035751343f, + 0.865543127059937f, -0.341142505407333f, 0.865281403064728f, + -0.341422766447067f, 0.865019381046295f, -0.341702848672867f, + 0.864757239818573f, -0.341982692480087f, 0.864494800567627f, + -0.342262357473373f, 0.864232182502747f, -0.342541843652725f, + 0.863969385623932f, -0.342821091413498f, 0.863706290721893f, + -0.343100160360336f, 0.863443076610565f, -0.343379020690918f, + 0.863179564476013f, -0.343657672405243f, 0.862915873527527f, + -0.343936115503311f, 0.862652003765106f, -0.344214379787445f, + 0.862387895584106f, -0.344492435455322f, 0.862123548984528f, + -0.344770282506943f, 0.861859023571014f, -0.345047920942307f, + 0.861594259738922f, -0.345325350761414f, 0.861329257488251f, + -0.345602601766586f, 0.861064076423645f, -0.345879614353180f, + 0.860798716545105f, -0.346156448125839f, 0.860533118247986f, + -0.346433073282242f, 0.860267281532288f, -0.346709519624710f, + 0.860001266002655f, -0.346985727548599f, 0.859735012054443f, + -0.347261756658554f, 0.859468579292297f, -0.347537547349930f, + 0.859201908111572f, -0.347813159227371f, 0.858934998512268f, + -0.348088562488556f, 0.858667910099030f, -0.348363757133484f, + 0.858400642871857f, -0.348638743162155f, 0.858133137226105f, + -0.348913550376892f, 0.857865393161774f, -0.349188119173050f, + 0.857597470283508f, -0.349462509155273f, 0.857329368591309f, + -0.349736660718918f, 0.857060968875885f, -0.350010633468628f, + 0.856792449951172f, -0.350284397602081f, 0.856523692607880f, + -0.350557953119278f, 0.856254696846008f, -0.350831300020218f, + 0.855985522270203f, -0.351104438304901f, 0.855716109275818f, + -0.351377367973328f, 0.855446517467499f, -0.351650089025497f, + 0.855176687240601f, -0.351922631263733f, 0.854906618595123f, + -0.352194935083389f, 0.854636430740356f, -0.352467030286789f, + 0.854365944862366f, -0.352738946676254f, 0.854095339775085f, + -0.353010624647141f, 0.853824436664581f, -0.353282123804092f, + 0.853553414344788f, -0.353553384542465f, 0.853282094001770f, + -0.353824466466904f, 0.853010654449463f, -0.354095309972763f, + 0.852738916873932f, -0.354365974664688f, 0.852467060089111f, + -0.354636400938034f, 0.852194905281067f, -0.354906648397446f, + 0.851922631263733f, -0.355176687240601f, 0.851650118827820f, + -0.355446487665176f, 0.851377367973328f, -0.355716109275818f, + 0.851104438304901f, -0.355985492467880f, 0.850831270217896f, + -0.356254696846008f, 0.850557923316956f, -0.356523662805557f, + 0.850284397602081f, -0.356792420148849f, 0.850010633468628f, + -0.357060998678207f, 0.849736690521240f, -0.357329338788986f, + 0.849462509155273f, -0.357597470283508f, 0.849188148975372f, + -0.357865422964096f, 0.848913550376892f, -0.358133137226105f, + 0.848638772964478f, -0.358400642871857f, 0.848363757133484f, + -0.358667939901352f, 0.848088562488556f, -0.358935028314590f, + 0.847813189029694f, -0.359201908111572f, 0.847537577152252f, + -0.359468549489975f, 0.847261726856232f, -0.359735012054443f, + 0.846985757350922f, -0.360001266002655f, 0.846709489822388f, + -0.360267281532288f, 0.846433103084564f, -0.360533088445663f, + 0.846156477928162f, -0.360798716545105f, 0.845879614353180f, + -0.361064106225967f, 0.845602571964264f, -0.361329287290573f, + 0.845325350761414f, -0.361594229936600f, 0.845047891139984f, + -0.361858993768692f, 0.844770252704620f, -0.362123548984528f, + 0.844492435455322f, -0.362387865781784f, 0.844214379787445f, + -0.362651973962784f, 0.843936145305634f, -0.362915903329849f, + 0.843657672405243f, -0.363179564476013f, 0.843379020690918f, + -0.363443046808243f, 0.843100130558014f, -0.363706320524216f, + 0.842821121215820f, -0.363969355821610f, 0.842541813850403f, + -0.364232182502747f, 0.842262387275696f, -0.364494800567627f, + 0.841982722282410f, -0.364757210016251f, 0.841702818870544f, + -0.365019410848618f, 0.841422796249390f, -0.365281373262405f, + 0.841142535209656f, -0.365543156862259f, 0.840862035751343f, + -0.365804702043533f, 0.840581357479095f, -0.366066008806229f, + 0.840300500392914f, -0.366327136754990f, 0.840019404888153f, + -0.366588026285172f, 0.839738130569458f, -0.366848707199097f, + 0.839456677436829f, -0.367109179496765f, 0.839175045490265f, + -0.367369443178177f, 0.838893175125122f, -0.367629468441010f, + 0.838611066341400f, -0.367889285087585f, 0.838328838348389f, + -0.368148893117905f, 0.838046371936798f, -0.368408292531967f, + 0.837763667106628f, -0.368667453527451f, 0.837480843067169f, + -0.368926405906677f, 0.837197780609131f, -0.369185149669647f, + 0.836914479732513f, -0.369443655014038f, 0.836631059646606f, + -0.369701951742172f, 0.836347401142120f, -0.369960039854050f, + 0.836063504219055f, -0.370217919349670f, 0.835779488086700f, + -0.370475560426712f, 0.835495233535767f, -0.370732992887497f, + 0.835210800170898f, -0.370990216732025f, 0.834926128387451f, + -0.371247202157974f, 0.834641277790070f, -0.371503978967667f, + 0.834356248378754f, -0.371760547161102f, 0.834071040153503f, + -0.372016876935959f, 0.833785593509674f, -0.372272998094559f, + 0.833499968051910f, -0.372528880834579f, 0.833214163780212f, + -0.372784584760666f, 0.832928121089935f, -0.373040050268173f, + 0.832641899585724f, -0.373295277357101f, 0.832355499267578f, + -0.373550295829773f, 0.832068860530853f, -0.373805105686188f, + 0.831782102584839f, -0.374059677124023f, 0.831495106220245f, + -0.374314039945602f, 0.831207871437073f, -0.374568194150925f, + 0.830920517444611f, -0.374822109937668f, 0.830632925033569f, + -0.375075817108154f, 0.830345153808594f, -0.375329315662384f, + 0.830057144165039f, -0.375582575798035f, 0.829769015312195f, + -0.375835597515106f, 0.829480648040771f, -0.376088410615921f, + 0.829192101955414f, -0.376341015100479f, 0.828903317451477f, + -0.376593410968781f, 0.828614413738251f, -0.376845568418503f, + 0.828325271606445f, -0.377097487449646f, 0.828035950660706f, + -0.377349197864532f, 0.827746450901031f, -0.377600699663162f, + 0.827456712722778f, -0.377851963043213f, 0.827166795730591f, + -0.378102988004684f, 0.826876699924469f, -0.378353834152222f, + 0.826586425304413f, -0.378604412078857f, 0.826295912265778f, + -0.378854811191559f, 0.826005280017853f, -0.379104942083359f, + 0.825714409351349f, -0.379354894161224f, 0.825423359870911f, + -0.379604607820511f, 0.825132071971893f, -0.379854083061218f, + 0.824840664863586f, -0.380103349685669f, 0.824549019336700f, + -0.380352377891541f, 0.824257194995880f, -0.380601197481155f, + 0.823965191841125f, -0.380849778652191f, 0.823673009872437f, + -0.381098151206970f, 0.823380589485168f, -0.381346285343170f, + 0.823087990283966f, -0.381594210863113f, 0.822795212268829f, + -0.381841897964478f, 0.822502255439758f, -0.382089376449585f, + 0.822209119796753f, -0.382336616516113f, 0.821915745735168f, + -0.382583618164063f, 0.821622252464294f, -0.382830440998077f, + 0.821328520774841f, -0.383076995611191f, 0.821034610271454f, + -0.383323341608047f, 0.820740520954132f, -0.383569449186325f, + 0.820446193218231f, -0.383815348148346f, 0.820151746273041f, + -0.384061008691788f, 0.819857060909271f, -0.384306460618973f, + 0.819562196731567f, -0.384551674127579f, 0.819267153739929f, + -0.384796649217606f, 0.818971931934357f, -0.385041415691376f, + 0.818676531314850f, -0.385285943746567f, 0.818380951881409f, + -0.385530263185501f, 0.818085134029388f, -0.385774344205856f, + 0.817789137363434f, -0.386018186807632f, 0.817493021488190f, + -0.386261820793152f, 0.817196667194366f, -0.386505216360092f, + 0.816900074481964f, -0.386748403310776f, 0.816603362560272f, + -0.386991351842880f, 0.816306471824646f, -0.387234061956406f, + 0.816009342670441f, -0.387476563453674f, 0.815712094306946f, + -0.387718826532364f, 0.815414607524872f, -0.387960851192474f, + 0.815116941928864f, -0.388202667236328f, 0.814819097518921f, + -0.388444244861603f, 0.814521074295044f, -0.388685584068298f, + 0.814222872257233f, -0.388926714658737f, 0.813924491405487f, + -0.389167606830597f, 0.813625931739807f, -0.389408260583878f, + 0.813327133655548f, -0.389648675918579f, 0.813028216362000f, + -0.389888882637024f, 0.812729060649872f, -0.390128880739212f, + 0.812429726123810f, -0.390368610620499f, 0.812130272388458f, + -0.390608131885529f, 0.811830580234528f, -0.390847414731979f, + 0.811530709266663f, -0.391086459159851f, 0.811230659484863f, + -0.391325294971466f, 0.810930430889130f, -0.391563892364502f, + 0.810629963874817f, -0.391802251338959f, 0.810329377651215f, + -0.392040401697159f, 0.810028612613678f, -0.392278283834457f, + 0.809727668762207f, -0.392515957355499f, 0.809426486492157f, + -0.392753422260284f, 0.809125185012817f, -0.392990618944168f, + 0.808823645114899f, -0.393227607011795f, 0.808521986007690f, + -0.393464356660843f, 0.808220088481903f, -0.393700867891312f, + 0.807918012142181f, -0.393937170505524f, 0.807615816593170f, + -0.394173204898834f, 0.807313382625580f, -0.394409030675888f, + 0.807010769844055f, -0.394644618034363f, 0.806707978248596f, + -0.394879996776581f, 0.806405067443848f, -0.395115107297897f, + 0.806101918220520f, -0.395350009202957f, 0.805798590183258f, + -0.395584672689438f, 0.805495083332062f, -0.395819097757339f, + 0.805191397666931f, -0.396053284406662f, 0.804887533187866f, + -0.396287262439728f, 0.804583489894867f, -0.396520972251892f, + 0.804279267787933f, -0.396754473447800f, 0.803974866867065f, + -0.396987736225128f, 0.803670346736908f, -0.397220760583878f, + 0.803365588188171f, -0.397453576326370f, 0.803060650825500f, + -0.397686123847961f, 0.802755534648895f, -0.397918462753296f, + 0.802450239658356f, -0.398150533437729f, 0.802144765853882f, + -0.398382395505905f, 0.801839113235474f, -0.398614019155502f, + 0.801533281803131f, -0.398845434188843f, 0.801227271556854f, + -0.399076581001282f, 0.800921142101288f, -0.399307489395142f, + 0.800614774227142f, -0.399538189172745f, 0.800308227539063f, + -0.399768620729446f, 0.800001561641693f, -0.399998843669891f, + 0.799694657325745f, -0.400228828191757f, 0.799387574195862f, + -0.400458574295044f, 0.799080371856689f, -0.400688081979752f, + 0.798772931098938f, -0.400917351245880f, 0.798465371131897f, + -0.401146411895752f, 0.798157572746277f, -0.401375204324722f, + 0.797849655151367f, -0.401603758335114f, 0.797541558742523f, + -0.401832103729248f, 0.797233223915100f, -0.402060180902481f, + 0.796924769878387f, -0.402288049459457f, 0.796616137027740f, + -0.402515679597855f, 0.796307325363159f, -0.402743041515350f, + 0.795998334884644f, -0.402970194816589f, 0.795689165592194f, + -0.403197109699249f, 0.795379877090454f, -0.403423786163330f, + 0.795070350170136f, -0.403650224208832f, 0.794760644435883f, + -0.403876423835754f, 0.794450819492340f, -0.404102355241776f, + 0.794140756130219f, -0.404328078031540f, 0.793830573558807f, + -0.404553562402725f, 0.793520212173462f, -0.404778808355331f, + 0.793209671974182f, -0.405003815889359f, 0.792898952960968f, + -0.405228585004807f, 0.792588055133820f, -0.405453115701675f, + 0.792276978492737f, -0.405677437782288f, 0.791965723037720f, + -0.405901491641998f, 0.791654348373413f, -0.406125307083130f, + 0.791342735290527f, -0.406348884105682f, 0.791031002998352f, + -0.406572192907333f, 0.790719091892242f, -0.406795293092728f, + 0.790407001972198f, -0.407018154859543f, 0.790094733238220f, + -0.407240778207779f, 0.789782285690308f, -0.407463163137436f, + 0.789469659328461f, -0.407685309648514f, 0.789156913757324f, + -0.407907217741013f, 0.788843929767609f, -0.408128857612610f, + 0.788530826568604f, -0.408350288867950f, 0.788217544555664f, + -0.408571451902390f, 0.787904083728790f, -0.408792406320572f, + 0.787590444087982f, -0.409013092517853f, 0.787276685237885f, + -0.409233570098877f, 0.786962687969208f, -0.409453779459000f, + 0.786648571491241f, -0.409673750400543f, 0.786334276199341f, + -0.409893482923508f, 0.786019802093506f, -0.410112977027893f, + 0.785705149173737f, -0.410332232713699f, 0.785390377044678f, + -0.410551249980927f, 0.785075426101685f, -0.410770028829575f, + 0.784760236740112f, -0.410988569259644f, 0.784444928169250f, + -0.411206841468811f, 0.784129500389099f, -0.411424905061722f, + 0.783813834190369f, -0.411642700433731f, 0.783498048782349f, + -0.411860257387161f, 0.783182024955750f, -0.412077575922012f, + 0.782865881919861f, -0.412294656038284f, 0.782549619674683f, + -0.412511497735977f, 0.782233119010925f, -0.412728071212769f, + 0.781916499137878f, -0.412944436073303f, 0.781599700450897f, + -0.413160532712936f, 0.781282722949982f, -0.413376390933990f, + 0.780965566635132f, -0.413592010736465f, 0.780648231506348f, + -0.413807392120361f, 0.780330777168274f, -0.414022535085678f, + 0.780013144016266f, -0.414237409830093f, 0.779695332050323f, + -0.414452046155930f, 0.779377400875092f, -0.414666473865509f, + 0.779059290885925f, -0.414880603551865f, 0.778741002082825f, + -0.415094524621964f, 0.778422534465790f, -0.415308207273483f, + 0.778103888034821f, -0.415521621704102f, 0.777785122394562f, + -0.415734797716141f, 0.777466177940369f, -0.415947735309601f, + 0.777147054672241f, -0.416160434484482f, 0.776827812194824f, + -0.416372895240784f, 0.776508331298828f, -0.416585087776184f, + 0.776188731193542f, -0.416797041893005f, 0.775869011878967f, + -0.417008757591248f, 0.775549054145813f, -0.417220205068588f, + 0.775228977203369f, -0.417431443929672f, 0.774908721446991f, + -0.417642414569855f, 0.774588346481323f, -0.417853146791458f, + 0.774267733097076f, -0.418063640594482f, 0.773947000503540f, + -0.418273866176605f, 0.773626148700714f, -0.418483853340149f, + 0.773305058479309f, -0.418693602085114f, 0.772983849048615f, + -0.418903112411499f, 0.772662520408630f, -0.419112354516983f, + 0.772340953350067f, -0.419321358203888f, 0.772019267082214f, + -0.419530123472214f, 0.771697402000427f, -0.419738620519638f, + 0.771375417709351f, -0.419946908950806f, 0.771053194999695f, + -0.420154929161072f, 0.770730912685394f, -0.420362681150436f, + 0.770408391952515f, -0.420570224523544f, 0.770085752010345f, + -0.420777499675751f, 0.769762933254242f, -0.420984506607056f, + 0.769439935684204f, -0.421191304922104f, 0.769116818904877f, + -0.421397835016251f, 0.768793523311615f, -0.421604126691818f, + 0.768470108509064f, -0.421810150146484f, 0.768146514892578f, + -0.422015935182571f, 0.767822742462158f, -0.422221481800079f, + 0.767498791217804f, -0.422426789999008f, 0.767174720764160f, + -0.422631829977036f, 0.766850471496582f, -0.422836631536484f, + 0.766526103019714f, -0.423041164875031f, 0.766201555728912f, + -0.423245459794998f, 0.765876889228821f, -0.423449516296387f, + 0.765551984310150f, -0.423653304576874f, 0.765226960182190f, + -0.423856884241104f, 0.764901816844940f, -0.424060165882111f, + 0.764576494693756f, -0.424263238906860f, 0.764250993728638f, + -0.424466013908386f, 0.763925373554230f, -0.424668580293655f, + 0.763599574565887f, -0.424870878458023f, 0.763273596763611f, + -0.425072938203812f, 0.762947499752045f, -0.425274729728699f, + 0.762621283531189f, -0.425476282835007f, 0.762294828891754f, + -0.425677597522736f, 0.761968255043030f, -0.425878643989563f, + 0.761641561985016f, -0.426079452037811f, 0.761314690113068f, + -0.426279991865158f, 0.760987639427185f, -0.426480293273926f, + 0.760660469532013f, -0.426680356264114f, 0.760333120822906f, + -0.426880151033401f, 0.760005652904511f, -0.427079707384110f, + 0.759678006172180f, -0.427278995513916f, 0.759350180625916f, + -0.427478045225143f, 0.759022235870361f, -0.427676826715469f, + 0.758694171905518f, -0.427875369787216f, 0.758365929126740f, + -0.428073674440384f, 0.758037507534027f, -0.428271710872650f, + 0.757708966732025f, -0.428469479084015f, 0.757380247116089f, + -0.428667008876801f, 0.757051348686218f, -0.428864300251007f, + 0.756722390651703f, -0.429061323404312f, 0.756393194198608f, + -0.429258108139038f, 0.756063878536224f, -0.429454624652863f, + 0.755734443664551f, -0.429650902748108f, 0.755404829978943f, + -0.429846942424774f, 0.755075037479401f, -0.430042684078217f, + 0.754745125770569f, -0.430238217115402f, 0.754415094852448f, + -0.430433481931686f, 0.754084885120392f, -0.430628478527069f, + 0.753754496574402f, -0.430823236703873f, 0.753423988819122f, + -0.431017726659775f, 0.753093302249908f, -0.431211978197098f, + 0.752762496471405f, -0.431405961513519f, 0.752431571483612f, + -0.431599706411362f, 0.752100467681885f, -0.431793183088303f, + 0.751769185066223f, -0.431986421346664f, 0.751437783241272f, + -0.432179391384125f, 0.751106262207031f, -0.432372123003006f, + 0.750774562358856f, -0.432564586400986f, 0.750442683696747f, + -0.432756811380386f, 0.750110685825348f, -0.432948768138886f, + 0.749778568744659f, -0.433140486478806f, 0.749446272850037f, + -0.433331936597824f, 0.749113857746124f, -0.433523118495941f, + 0.748781263828278f, -0.433714061975479f, 0.748448550701141f, + -0.433904737234116f, 0.748115658760071f, -0.434095174074173f, + 0.747782647609711f, -0.434285342693329f, 0.747449457645416f, + -0.434475272893906f, 0.747116148471832f, -0.434664934873581f, + 0.746782720088959f, -0.434854328632355f, 0.746449112892151f, + -0.435043483972549f, 0.746115326881409f, -0.435232400894165f, + 0.745781481266022f, -0.435421019792557f, 0.745447397232056f, + -0.435609430074692f, 0.745113253593445f, -0.435797542333603f, + 0.744778931140900f, -0.435985416173935f, 0.744444429874420f, + -0.436173021793365f, 0.744109809398651f, -0.436360388994217f, + 0.743775069713593f, -0.436547487974167f, 0.743440151214600f, + -0.436734348535538f, 0.743105113506317f, -0.436920911073685f, + 0.742769956588745f, -0.437107264995575f, 0.742434620857239f, + -0.437293320894241f, 0.742099165916443f, -0.437479138374329f, + 0.741763532161713f, -0.437664687633514f, 0.741427779197693f, + -0.437849998474121f, 0.741091907024384f, -0.438035041093826f, + 0.740755856037140f, -0.438219845294952f, 0.740419685840607f, + -0.438404351472855f, 0.740083336830139f, -0.438588619232178f, + 0.739746868610382f, -0.438772648572922f, 0.739410281181335f, + -0.438956409692764f, 0.739073514938354f, -0.439139902591705f, + 0.738736629486084f, -0.439323127269745f, 0.738399624824524f, + -0.439506113529205f, 0.738062441349030f, -0.439688831567764f, + 0.737725138664246f, -0.439871311187744f, 0.737387716770172f, + -0.440053492784500f, 0.737050116062164f, -0.440235435962677f, + 0.736712396144867f, -0.440417140722275f, 0.736374497413635f, + -0.440598547458649f, 0.736036539077759f, -0.440779715776443f, + 0.735698342323303f, -0.440960645675659f, 0.735360085964203f, + -0.441141277551651f, 0.735021650791168f, -0.441321671009064f, + 0.734683096408844f, -0.441501796245575f, 0.734344422817230f, + -0.441681683063507f, 0.734005570411682f, -0.441861271858215f, + 0.733666598796844f, -0.442040622234344f, 0.733327507972717f, + -0.442219734191895f, 0.732988238334656f, -0.442398548126221f, + 0.732648849487305f, -0.442577123641968f, 0.732309341430664f, + -0.442755430936813f, 0.731969714164734f, -0.442933470010757f, + 0.731629908084869f, -0.443111270666122f, 0.731289982795715f, + -0.443288803100586f, 0.730949878692627f, -0.443466067314148f, + 0.730609714984894f, -0.443643063306808f, 0.730269372463226f, + -0.443819820880890f, 0.729928910732269f, -0.443996280431747f, + 0.729588270187378f, -0.444172531366348f, 0.729247510433197f, + -0.444348484277725f, 0.728906631469727f, -0.444524168968201f, + 0.728565633296967f, -0.444699615240097f, 0.728224515914917f, + -0.444874793291092f, 0.727883219718933f, -0.445049703121185f, + 0.727541804313660f, -0.445224374532700f, 0.727200269699097f, + -0.445398747920990f, 0.726858556270599f, -0.445572882890701f, + 0.726516723632813f, -0.445746749639511f, 0.726174771785736f, + -0.445920348167419f, 0.725832700729370f, -0.446093708276749f, + 0.725490510463715f, -0.446266770362854f, 0.725148141384125f, + -0.446439594030380f, 0.724805653095245f, -0.446612149477005f, + 0.724463045597076f, -0.446784436702728f, 0.724120318889618f, + -0.446956485509872f, 0.723777413368225f, -0.447128236293793f, + 0.723434448242188f, -0.447299748659134f, 0.723091304302216f, + -0.447470992803574f, 0.722747981548309f, -0.447641968727112f, + 0.722404599189758f, -0.447812676429749f, 0.722061097621918f, + -0.447983115911484f, 0.721717417240143f, -0.448153316974640f, + 0.721373617649078f, -0.448323249816895f, 0.721029698848724f, + -0.448492884635925f, 0.720685660839081f, -0.448662281036377f, + 0.720341444015503f, -0.448831409215927f, 0.719997107982636f, + -0.449000298976898f, 0.719652712345123f, -0.449168890714645f, + 0.719308137893677f, -0.449337244033813f, 0.718963444232941f, + -0.449505299329758f, 0.718618571758270f, -0.449673116207123f, + 0.718273639678955f, -0.449840664863586f, 0.717928528785706f, + -0.450007945299149f, 0.717583298683167f, -0.450174957513809f, + 0.717238008975983f, -0.450341701507568f, 0.716892480850220f, + -0.450508207082748f, 0.716546893119812f, -0.450674414634705f, + 0.716201186180115f, -0.450840383768082f, 0.715855300426483f, + -0.451006084680557f, 0.715509355068207f, -0.451171487569809f, + 0.715163230895996f, -0.451336652040482f, 0.714816987514496f, + -0.451501548290253f, 0.714470624923706f, -0.451666176319122f, + 0.714124143123627f, -0.451830536127090f, 0.713777542114258f, + -0.451994657516479f, 0.713430821895599f, -0.452158480882645f, + 0.713083922863007f, -0.452322036027908f, 0.712736964225769f, + -0.452485352754593f, 0.712389826774597f, -0.452648371458054f, + 0.712042629718781f, -0.452811151742935f, 0.711695253849030f, + -0.452973634004593f, 0.711347758769989f, -0.453135877847672f, + 0.711000144481659f, -0.453297853469849f, 0.710652410984039f, + -0.453459560871124f, 0.710304558277130f, -0.453621000051498f, + 0.709956526756287f, -0.453782171010971f, 0.709608435630798f, + -0.453943043947220f, 0.709260225296021f, -0.454103678464890f, + 0.708911836147308f, -0.454264044761658f, 0.708563387393951f, + -0.454424172639847f, 0.708214759826660f, -0.454584002494812f, + 0.707866072654724f, -0.454743564128876f, 0.707517206668854f, + -0.454902857542038f, 0.707168221473694f, -0.455061882734299f, + 0.706819176673889f, -0.455220639705658f, 0.706469953060150f, + -0.455379128456116f, 0.706120610237122f, -0.455537378787994f, + 0.705771148204803f, -0.455695331096649f, 0.705421566963196f, + -0.455853015184402f, 0.705071866512299f, -0.456010431051254f, + 0.704722046852112f, -0.456167578697205f, 0.704372167587280f, + -0.456324487924576f, 0.704022109508514f, -0.456481099128723f, + 0.703671932220459f, -0.456637442111969f, 0.703321635723114f, + -0.456793516874313f, 0.702971220016479f, -0.456949323415756f, + 0.702620685100555f, -0.457104891538620f, 0.702270030975342f, + -0.457260161638260f, 0.701919257640839f, -0.457415163516998f, + 0.701568365097046f, -0.457569897174835f, 0.701217353343964f, + -0.457724362611771f, 0.700866222381592f, -0.457878559827805f, + 0.700514972209930f, -0.458032488822937f, 0.700163602828979f, + -0.458186149597168f, 0.699812114238739f, -0.458339542150497f, + 0.699460506439209f, -0.458492636680603f, 0.699108779430389f, + -0.458645492792130f, 0.698756933212280f, -0.458798080682755f, + 0.698404967784882f, -0.458950400352478f, 0.698052942752838f, + -0.459102421998978f, 0.697700738906860f, -0.459254205226898f, + 0.697348415851593f, -0.459405690431595f, 0.696996033191681f, + -0.459556937217712f, 0.696643471717834f, -0.459707885980606f, + 0.696290850639343f, -0.459858566522598f, 0.695938050746918f, + -0.460008978843689f, 0.695585191249847f, -0.460159152746201f, + 0.695232212543488f, -0.460309028625488f, 0.694879114627838f, + -0.460458606481552f, 0.694525837898254f, -0.460607945919037f, + 0.694172501564026f, -0.460757017135620f, 0.693819046020508f, + -0.460905820131302f, 0.693465530872345f, -0.461054325103760f, + 0.693111836910248f, -0.461202591657639f, 0.692758023738861f, + -0.461350560188293f, 0.692404091358185f, -0.461498260498047f, + 0.692050099372864f, -0.461645722389221f, 0.691695988178253f, + -0.461792886257172f, 0.691341698169708f, -0.461939752101898f, + 0.690987348556519f, -0.462086379528046f, 0.690632879734039f, + -0.462232738733292f, 0.690278291702271f, -0.462378799915314f, + 0.689923584461212f, -0.462524622678757f, 0.689568817615509f, + -0.462670147418976f, 0.689213871955872f, -0.462815403938293f, + 0.688858866691589f, -0.462960392236710f, 0.688503682613373f, + -0.463105112314224f, 0.688148438930511f, -0.463249564170837f, + 0.687793076038361f, -0.463393747806549f, 0.687437593936920f, + -0.463537633419037f, 0.687082052230835f, -0.463681250810623f, + 0.686726331710815f, -0.463824629783630f, 0.686370551586151f, + -0.463967710733414f, 0.686014592647552f, -0.464110493659973f, + 0.685658574104309f, -0.464253038167953f, 0.685302436351776f, + -0.464395314455032f, 0.684946238994598f, -0.464537292718887f, + 0.684589862823486f, -0.464679002761841f, 0.684233427047729f, + -0.464820444583893f, 0.683876872062683f, -0.464961618185043f, + 0.683520197868347f, -0.465102523565292f, 0.683163404464722f, + -0.465243130922318f, 0.682806491851807f, -0.465383470058441f, + 0.682449519634247f, -0.465523540973663f, 0.682092368602753f, + -0.465663343667984f, 0.681735157966614f, -0.465802878141403f, + 0.681377887725830f, -0.465942144393921f, 0.681020438671112f, + -0.466081112623215f, 0.680662930011749f, -0.466219812631607f, + 0.680305242538452f, -0.466358244419098f, 0.679947495460510f, + -0.466496407985687f, 0.679589688777924f, -0.466634273529053f, + 0.679231703281403f, -0.466771900653839f, 0.678873658180237f, + -0.466909229755402f, 0.678515493869781f, -0.467046260833740f, + 0.678157210350037f, -0.467183053493500f, 0.677798807621002f, + -0.467319577932358f, 0.677440345287323f, -0.467455804347992f, + 0.677081763744354f, -0.467591762542725f, 0.676723062992096f, + -0.467727422714233f, 0.676364302635193f, -0.467862844467163f, + 0.676005363464355f, -0.467997968196869f, 0.675646364688873f, + -0.468132823705673f, 0.675287246704102f, -0.468267410993576f, + 0.674928069114685f, -0.468401730060577f, 0.674568772315979f, + -0.468535751104355f, 0.674209356307983f, -0.468669503927231f, + 0.673849821090698f, -0.468802988529205f, 0.673490226268768f, + -0.468936175107956f, 0.673130512237549f, -0.469069123268127f, + 0.672770678997040f, -0.469201773405075f, 0.672410726547241f, + -0.469334155321121f, 0.672050714492798f, -0.469466239213943f, + 0.671690583229065f, -0.469598054885864f, 0.671330332756042f, + -0.469729602336884f, 0.670970022678375f, -0.469860881567001f, + 0.670609593391418f, -0.469991862773895f, 0.670249044895172f, + -0.470122605562210f, 0.669888436794281f, -0.470253020524979f, + 0.669527709484100f, -0.470383197069168f, 0.669166862964630f, + -0.470513075590134f, 0.668805956840515f, -0.470642685890198f, + 0.668444931507111f, -0.470772027969360f, 0.668083786964417f, + -0.470901101827621f, 0.667722582817078f, -0.471029877662659f, + 0.667361259460449f, -0.471158385276794f, 0.666999816894531f, + -0.471286594867706f, 0.666638314723969f, -0.471414536237717f, + 0.666276693344116f, -0.471542209386826f, 0.665914952754974f, + -0.471669614315033f, 0.665553152561188f, -0.471796721220016f, + 0.665191233158112f, -0.471923559904099f, 0.664829254150391f, + -0.472050130367279f, 0.664467096328735f, -0.472176402807236f, + 0.664104938507080f, -0.472302407026291f, 0.663742601871490f, + -0.472428143024445f, 0.663380205631256f, -0.472553610801697f, + 0.663017749786377f, -0.472678780555725f, 0.662655174732208f, + -0.472803652286530f, 0.662292480468750f, -0.472928285598755f, + 0.661929666996002f, -0.473052620887756f, 0.661566793918610f, + -0.473176687955856f, 0.661203861236572f, -0.473300457000732f, + 0.660840749740601f, -0.473423957824707f, 0.660477638244629f, + -0.473547190427780f, 0.660114347934723f, -0.473670125007629f, + 0.659750998020172f, -0.473792791366577f, 0.659387588500977f, + -0.473915189504623f, 0.659024059772491f, -0.474037289619446f, + 0.658660411834717f, -0.474159121513367f, 0.658296704292297f, + -0.474280685186386f, 0.657932877540588f, -0.474401950836182f, + 0.657568991184235f, -0.474522948265076f, 0.657204985618591f, + -0.474643647670746f, 0.656840860843658f, -0.474764078855515f, + 0.656476676464081f, -0.474884241819382f, 0.656112432479858f, + -0.475004136562347f, 0.655748009681702f, -0.475123733282089f, + 0.655383586883545f, -0.475243031978607f, 0.655019044876099f, + -0.475362062454224f, 0.654654383659363f, -0.475480824708939f, + 0.654289662837982f, -0.475599318742752f, 0.653924822807312f, + -0.475717514753342f, 0.653559923171997f, -0.475835442543030f, + 0.653194904327393f, -0.475953072309494f, 0.652829825878143f, + -0.476070433855057f, 0.652464628219604f, -0.476187497377396f, + 0.652099311351776f, -0.476304292678833f, 0.651733994483948f, + -0.476420819759369f, 0.651368498802185f, -0.476537048816681f, + 0.651003003120422f, -0.476653009653091f, 0.650637328624725f, + -0.476768702268600f, 0.650271594524384f, -0.476884096860886f, + 0.649905800819397f, -0.476999223232269f, 0.649539887905121f, + -0.477114051580429f, 0.649173915386200f, -0.477228611707687f, + 0.648807883262634f, -0.477342873811722f, 0.648441672325134f, + -0.477456867694855f, 0.648075461387634f, -0.477570593357086f, + 0.647709131240845f, -0.477684020996094f, 0.647342681884766f, + -0.477797180414200f, 0.646976172924042f, -0.477910041809082f, + 0.646609604358673f, -0.478022634983063f, 0.646242916584015f, + -0.478134930133820f, 0.645876109600067f, -0.478246957063675f, + 0.645509302616119f, -0.478358715772629f, 0.645142316818237f, + -0.478470176458359f, 0.644775331020355f, -0.478581339120865f, + 0.644408226013184f, -0.478692263364792f, 0.644041001796722f, + -0.478802859783173f, 0.643673717975616f, -0.478913217782974f, + 0.643306374549866f, -0.479023247957230f, 0.642938911914825f, + -0.479133039712906f, 0.642571389675140f, -0.479242533445358f, + 0.642203748226166f, -0.479351729154587f, 0.641836047172546f, + -0.479460656642914f, 0.641468286514282f, -0.479569315910339f, + 0.641100406646729f, -0.479677677154541f, 0.640732467174530f, + -0.479785770177841f, 0.640364408493042f, -0.479893565177917f, + 0.639996349811554f, -0.480001062154770f, 0.639628112316132f, + -0.480108320713043f, 0.639259815216064f, -0.480215251445770f, + 0.638891458511353f, -0.480321943759918f, 0.638523042201996f, + -0.480428308248520f, 0.638154506683350f, -0.480534434318542f, + 0.637785911560059f, -0.480640232563019f, 0.637417197227478f, + -0.480745792388916f, 0.637048482894897f, -0.480851024389267f, + 0.636679589748383f, -0.480956017971039f, 0.636310696601868f, + -0.481060713529587f, 0.635941684246063f, -0.481165111064911f, + 0.635572552680969f, -0.481269240379334f, 0.635203421115875f, + -0.481373071670532f, 0.634834170341492f, -0.481476634740829f, + 0.634464859962463f, -0.481579899787903f, 0.634095430374146f, + -0.481682896614075f, 0.633725941181183f, -0.481785595417023f, + 0.633356392383575f, -0.481888025999069f, 0.632986724376678f, + -0.481990188360214f, 0.632616996765137f, -0.482092022895813f, + 0.632247209548950f, -0.482193619012833f, 0.631877362728119f, + -0.482294887304306f, 0.631507396697998f, -0.482395917177200f, + 0.631137371063232f, -0.482496619224548f, 0.630767226219177f, + -0.482597053050995f, 0.630397081375122f, -0.482697218656540f, + 0.630026817321777f, -0.482797086238861f, 0.629656434059143f, + -0.482896685600281f, 0.629286050796509f, -0.482995986938477f, + 0.628915548324585f, -0.483094990253448f, 0.628544986248016f, + -0.483193725347519f, 0.628174364566803f, -0.483292192220688f, + 0.627803623676300f, -0.483390361070633f, 0.627432823181152f, + -0.483488231897354f, 0.627061963081360f, -0.483585834503174f, + 0.626691043376923f, -0.483683139085770f, 0.626320004463196f, + -0.483780175447464f, 0.625948905944824f, -0.483876913785934f, + 0.625577747821808f, -0.483973383903503f, 0.625206530094147f, + -0.484069555997849f, 0.624835193157196f, -0.484165430068970f, + 0.624463796615601f, -0.484261035919189f, 0.624092340469360f, + -0.484356373548508f, 0.623720824718475f, -0.484451413154602f, + 0.623349189758301f, -0.484546154737473f, 0.622977554798126f, + -0.484640628099442f, 0.622605800628662f, -0.484734803438187f, + 0.622233927249908f, -0.484828680753708f, 0.621862053871155f, + -0.484922289848328f, 0.621490061283112f, -0.485015630722046f, + 0.621118068695068f, -0.485108673572540f, 0.620745956897736f, + -0.485201418399811f, 0.620373785495758f, -0.485293895006180f, + 0.620001494884491f, -0.485386073589325f, 0.619629204273224f, + -0.485477954149246f, 0.619256794452667f, -0.485569566488266f, + 0.618884325027466f, -0.485660910606384f, 0.618511795997620f, + -0.485751956701279f, 0.618139207363129f, -0.485842704772949f, + 0.617766559123993f, -0.485933154821396f, 0.617393791675568f, + -0.486023366451263f, 0.617020964622498f, -0.486113250255585f, + 0.616648077964783f, -0.486202865839005f, 0.616275131702423f, + -0.486292183399200f, 0.615902125835419f, -0.486381232738495f, + 0.615529060363770f, -0.486469984054565f, 0.615155875682831f, + -0.486558437347412f, 0.614782691001892f, -0.486646622419357f, + 0.614409387111664f, -0.486734509468079f, 0.614036023616791f, + -0.486822128295898f, 0.613662600517273f, -0.486909449100494f, + 0.613289117813110f, -0.486996471881866f, 0.612915575504303f, + -0.487083226442337f, 0.612541973590851f, -0.487169682979584f, + 0.612168252468109f, -0.487255871295929f, 0.611794531345367f, + -0.487341761589050f, 0.611420691013336f, -0.487427353858948f, + 0.611046791076660f, -0.487512677907944f, 0.610672831535339f, + -0.487597703933716f, 0.610298871994019f, -0.487682431936264f, + 0.609924793243408f, -0.487766891717911f, 0.609550595283508f, + -0.487851053476334f, 0.609176397323608f, -0.487934947013855f, + 0.608802139759064f, -0.488018542528152f, 0.608427822589874f, + -0.488101840019226f, 0.608053386211395f, -0.488184869289398f, + 0.607678949832916f, -0.488267600536346f, 0.607304394245148f, + -0.488350033760071f, 0.606929838657379f, -0.488432198762894f, + 0.606555163860321f, -0.488514065742493f, 0.606180429458618f, + -0.488595664501190f, 0.605805635452271f, -0.488676935434341f, + 0.605430841445923f, -0.488757967948914f, 0.605055928230286f, + -0.488838672637939f, 0.604680955410004f, -0.488919109106064f, + 0.604305922985077f, -0.488999247550964f, 0.603930830955505f, + -0.489079117774963f, 0.603555679321289f, -0.489158689975739f, + 0.603180468082428f, -0.489237964153290f, 0.602805197238922f, + -0.489316970109940f, 0.602429866790771f, -0.489395678043365f, + 0.602054476737976f, -0.489474087953568f, 0.601679027080536f, + -0.489552229642868f, 0.601303517818451f, -0.489630073308945f, + 0.600927948951721f, -0.489707618951797f, 0.600552320480347f, + -0.489784896373749f, 0.600176632404327f, -0.489861875772476f, + 0.599800884723663f, -0.489938557147980f, 0.599425077438354f, + -0.490014940500259f, 0.599049210548401f, -0.490091055631638f, + 0.598673284053802f, -0.490166902542114f, 0.598297297954559f, + -0.490242421627045f, 0.597921252250671f, -0.490317672491074f, + 0.597545146942139f, -0.490392625331879f, 0.597168982028961f, + -0.490467309951782f, 0.596792817115784f, -0.490541696548462f, + 0.596416532993317f, -0.490615785121918f, 0.596040189266205f, + -0.490689605474472f, 0.595663845539093f, -0.490763127803802f, + 0.595287382602692f, -0.490836352109909f, 0.594910860061646f, + -0.490909278392792f, 0.594534337520599f, -0.490981936454773f, + 0.594157755374908f, -0.491054296493530f, 0.593781054019928f, + -0.491126358509064f, 0.593404352664948f, -0.491198152303696f, + 0.593027591705322f, -0.491269648075104f, 0.592650771141052f, + -0.491340845823288f, 0.592273890972137f, -0.491411775350571f, + 0.591896951198578f, -0.491482406854630f, 0.591519951820374f, + -0.491552740335464f, 0.591142892837524f, -0.491622805595398f, + 0.590765833854675f, -0.491692543029785f, 0.590388655662537f, + -0.491762012243271f, 0.590011477470398f, -0.491831213235855f, + 0.589634180068970f, -0.491900116205215f, 0.589256882667542f, + -0.491968721151352f, 0.588879525661469f, -0.492037028074265f, + 0.588502109050751f, -0.492105036973953f, 0.588124632835388f, + -0.492172777652740f, 0.587747097015381f, -0.492240220308304f, + 0.587369561195374f, -0.492307394742966f, 0.586991965770721f, + -0.492374241352081f, 0.586614251136780f, -0.492440819740295f, + 0.586236536502838f, -0.492507129907608f, 0.585858762264252f, + -0.492573112249374f, 0.585480928421021f, -0.492638826370239f, + 0.585103094577789f, -0.492704242467880f, 0.584725141525269f, + -0.492769360542297f, 0.584347188472748f, -0.492834210395813f, + 0.583969175815582f, -0.492898762226105f, 0.583591103553772f, + -0.492963016033173f, 0.583212971687317f, -0.493026971817017f, + 0.582834780216217f, -0.493090659379959f, 0.582456588745117f, + -0.493154048919678f, 0.582078278064728f, -0.493217140436172f, + 0.581699967384338f, -0.493279963731766f, 0.581321597099304f, + -0.493342459201813f, 0.580943167209625f, -0.493404686450958f, + 0.580564737319946f, -0.493466645479202f, 0.580186247825623f, + -0.493528276681900f, 0.579807698726654f, -0.493589639663696f, + 0.579429090023041f, -0.493650704622269f, 0.579050421714783f, + -0.493711471557617f, 0.578671753406525f, -0.493771970272064f, + 0.578292965888977f, -0.493832170963287f, 0.577914178371429f, + -0.493892073631287f, 0.577535390853882f, -0.493951678276062f, + 0.577156484127045f, -0.494011014699936f, 0.576777577400208f, + -0.494070053100586f, 0.576398611068726f, -0.494128793478012f, + 0.576019585132599f, -0.494187235832214f, 0.575640499591827f, + -0.494245409965515f, 0.575261414051056f, -0.494303256273270f, + 0.574882268905640f, -0.494360834360123f, 0.574503064155579f, + -0.494418144226074f, 0.574123859405518f, -0.494475126266479f, + 0.573744535446167f, -0.494531840085983f, 0.573365211486816f, + -0.494588255882263f, 0.572985887527466f, -0.494644373655319f, + 0.572606444358826f, -0.494700223207474f, 0.572227001190186f, + -0.494755744934082f, 0.571847498416901f, -0.494810998439789f, + 0.571467995643616f, -0.494865983724594f, 0.571088373661041f, + -0.494920641183853f, 0.570708811283112f, -0.494975030422211f, + 0.570329129695892f, -0.495029091835022f, 0.569949388504028f, + -0.495082914829254f, 0.569569647312164f, -0.495136409997940f, + 0.569189906120300f, -0.495189607143402f, 0.568810045719147f, + -0.495242536067963f, 0.568430185317993f, -0.495295166969299f, + 0.568050265312195f, -0.495347499847412f, 0.567670345306396f, + -0.495399564504623f, 0.567290365695953f, -0.495451331138611f, + 0.566910326480865f, -0.495502769947052f, 0.566530287265778f, + -0.495553970336914f, 0.566150128841400f, -0.495604842901230f, + 0.565770030021667f, -0.495655417442322f, 0.565389811992645f, + -0.495705723762512f, 0.565009593963623f, -0.495755732059479f, + 0.564629375934601f, -0.495805442333221f, 0.564249038696289f, + -0.495854884386063f, 0.563868701457977f, -0.495903998613358f, + 0.563488364219666f, -0.495952844619751f, 0.563107967376709f, + -0.496001392602921f, 0.562727510929108f, -0.496049642562866f, + 0.562346994876862f, -0.496097624301910f, 0.561966478824615f, + -0.496145308017731f, 0.561585903167725f, -0.496192663908005f, + 0.561205327510834f, -0.496239781379700f, 0.560824692249298f, + -0.496286571025848f, 0.560444056987762f, -0.496333062648773f, + 0.560063362121582f, -0.496379286050797f, 0.559682607650757f, + -0.496425211429596f, 0.559301853179932f, -0.496470838785172f, + 0.558921039104462f, -0.496516168117523f, 0.558540165424347f, + -0.496561229228973f, 0.558159291744232f, -0.496605962514877f, + 0.557778418064117f, -0.496650427579880f, 0.557397484779358f, + -0.496694594621658f, 0.557016491889954f, -0.496738493442535f, + 0.556635499000549f, -0.496782064437866f, 0.556254446506500f, + -0.496825367212296f, 0.555873334407806f, -0.496868371963501f, + 0.555492222309113f, -0.496911078691483f, 0.555111110210419f, + -0.496953487396240f, 0.554729938507080f, -0.496995598077774f, + 0.554348707199097f, -0.497037440538406f, 0.553967475891113f, + -0.497078984975815f, 0.553586184978485f, -0.497120231389999f, + 0.553204894065857f, -0.497161179780960f, 0.552823603153229f, + -0.497201830148697f, 0.552442193031311f, -0.497242212295532f, + 0.552060842514038f, -0.497282296419144f, 0.551679372787476f, + -0.497322082519531f, 0.551297962665558f, -0.497361570596695f, + 0.550916433334351f, -0.497400760650635f, 0.550534904003143f, + -0.497439652681351f, 0.550153374671936f, -0.497478276491165f, + 0.549771785736084f, -0.497516602277756f, 0.549390196800232f, + -0.497554630041122f, 0.549008548259735f, -0.497592359781265f, + 0.548626899719238f, -0.497629791498184f, 0.548245191574097f, + -0.497666954994202f, 0.547863483428955f, -0.497703820466995f, + 0.547481775283813f, -0.497740387916565f, 0.547099947929382f, + -0.497776657342911f, 0.546718180179596f, -0.497812628746033f, + 0.546336352825165f, -0.497848302125931f, 0.545954465866089f, + -0.497883707284927f, 0.545572578907013f, -0.497918814420700f, + 0.545190691947937f, -0.497953623533249f, 0.544808745384216f, + -0.497988134622574f, 0.544426798820496f, -0.498022347688675f, + 0.544044792652130f, -0.498056292533875f, 0.543662786483765f, + -0.498089909553528f, 0.543280720710754f, -0.498123258352280f, + 0.542898654937744f, -0.498156309127808f, 0.542516589164734f, + -0.498189061880112f, 0.542134463787079f, -0.498221516609192f, + 0.541752278804779f, -0.498253703117371f, 0.541370153427124f, + -0.498285561800003f, 0.540987968444824f, -0.498317152261734f, + 0.540605723857880f, -0.498348444700241f, 0.540223479270935f, + -0.498379439115524f, 0.539841234683990f, -0.498410135507584f, + 0.539458930492401f, -0.498440563678741f, 0.539076626300812f, + -0.498470664024353f, 0.538694262504578f, -0.498500496149063f, + 0.538311958312988f, -0.498530030250549f, 0.537929534912109f, + -0.498559266328812f, 0.537547171115875f, -0.498588204383850f, + 0.537164747714996f, -0.498616874217987f, 0.536782264709473f, + -0.498645216226578f, 0.536399841308594f, -0.498673290014267f, + 0.536017298698425f, -0.498701065778732f, 0.535634815692902f, + -0.498728543519974f, 0.535252273082733f, -0.498755723237991f, + 0.534869730472565f, -0.498782604932785f, 0.534487187862396f, + -0.498809218406677f, 0.534104585647583f, -0.498835533857346f, + 0.533721983432770f, -0.498861521482468f, 0.533339321613312f, + -0.498887240886688f, 0.532956659793854f, -0.498912662267685f, + 0.532573997974396f, -0.498937815427780f, 0.532191336154938f, + -0.498962640762329f, 0.531808614730835f, -0.498987197875977f, + 0.531425893306732f, -0.499011427164078f, 0.531043112277985f, + -0.499035388231277f, 0.530660390853882f, -0.499059051275253f, + 0.530277609825134f, -0.499082416296005f, 0.529894769191742f, + -0.499105513095856f, 0.529511988162994f, -0.499128282070160f, + 0.529129147529602f, -0.499150782823563f, 0.528746306896210f, + -0.499172955751419f, 0.528363406658173f, -0.499194860458374f, + 0.527980506420136f, -0.499216467142105f, 0.527597606182098f, + -0.499237775802612f, 0.527214705944061f, -0.499258816242218f, + 0.526831746101379f, -0.499279528856277f, 0.526448845863342f, + -0.499299973249435f, 0.526065826416016f, -0.499320119619370f, + 0.525682866573334f, -0.499339967966080f, 0.525299847126007f, + -0.499359518289566f, 0.524916887283325f, -0.499378770589828f, + 0.524533808231354f, -0.499397724866867f, 0.524150788784027f, + -0.499416410923004f, 0.523767769336700f, -0.499434769153595f, + 0.523384690284729f, -0.499452859163284f, 0.523001611232758f, + -0.499470651149750f, 0.522618472576141f, -0.499488145112991f, + 0.522235393524170f, -0.499505341053009f, 0.521852254867554f, + -0.499522238969803f, 0.521469116210938f, -0.499538868665695f, + 0.521085977554321f, -0.499555170536041f, 0.520702838897705f, + -0.499571204185486f, 0.520319640636444f, -0.499586939811707f, + 0.519936442375183f, -0.499602377414703f, 0.519553244113922f, + -0.499617516994476f, 0.519170045852661f, -0.499632388353348f, + 0.518786847591400f, -0.499646931886673f, 0.518403589725494f, + -0.499661177396774f, 0.518020391464233f, -0.499675154685974f, + 0.517637133598328f, -0.499688833951950f, 0.517253875732422f, + -0.499702215194702f, 0.516870558261871f, -0.499715298414230f, + 0.516487300395966f, -0.499728083610535f, 0.516103982925415f, + -0.499740600585938f, 0.515720725059509f, -0.499752789735794f, + 0.515337407588959f, -0.499764710664749f, 0.514954090118408f, + -0.499776333570480f, 0.514570772647858f, -0.499787658452988f, + 0.514187395572662f, -0.499798685312271f, 0.513804078102112f, + -0.499809414148331f, 0.513420701026917f, -0.499819844961166f, + 0.513037383556366f, -0.499830007553101f, 0.512654006481171f, + -0.499839842319489f, 0.512270629405975f, -0.499849408864975f, + 0.511887252330780f, -0.499858677387238f, 0.511503815650940f, + -0.499867647886276f, 0.511120438575745f, -0.499876320362091f, + 0.510737061500549f, -0.499884694814682f, 0.510353624820709f, + -0.499892801046371f, 0.509970188140869f, -0.499900579452515f, + 0.509586811065674f, -0.499908089637756f, 0.509203374385834f, + -0.499915301799774f, 0.508819937705994f, -0.499922215938568f, + 0.508436501026154f, -0.499928832054138f, 0.508053064346313f, + -0.499935150146484f, 0.507669627666473f, -0.499941170215607f, + 0.507286131381989f, -0.499946922063828f, 0.506902694702148f, + -0.499952346086502f, 0.506519258022308f, -0.499957501888275f, + 0.506135761737823f, -0.499962359666824f, 0.505752325057983f, + -0.499966919422150f, 0.505368828773499f, -0.499971181154251f, + 0.504985332489014f, -0.499975144863129f, 0.504601895809174f, + -0.499978810548782f, 0.504218399524689f, -0.499982208013535f, + 0.503834903240204f, -0.499985307455063f, 0.503451406955719f, + -0.499988079071045f, 0.503067970275879f, -0.499990582466125f, + 0.502684473991394f, -0.499992787837982f, 0.502300977706909f, + -0.499994695186615f, 0.501917481422424f, -0.499996334314346f, + 0.501533985137939f, -0.499997645616531f, 0.501150488853455f, + -0.499998688697815f, 0.500766992568970f, -0.499999403953552f, + 0.500383496284485f, -0.499999850988388f, }; - - /** @} end of RealFFT_Table group */ @@ -4177,65 +5542,68 @@ static const float32_t realCoefB[8192] = { /** @brief Initialization function for the floating-point RFFT/RIFFT. - @deprecated Do not use this function. It has been superceded by \ref arm_rfft_fast_init_f32 and will be removed in the future. - @param[in,out] S points to an instance of the floating-point RFFT/RIFFT structure - @param[in,out] S_CFFT points to an instance of the floating-point CFFT/CIFFT structure + @deprecated Do not use this function. It has been superceded by \ref + arm_rfft_fast_init_f32 and will be removed in the future. + @param[in,out] S points to an instance of the floating-point + RFFT/RIFFT structure + @param[in,out] S_CFFT points to an instance of the floating-point + CFFT/CIFFT structure @param[in] fftLenReal length of the FFT. @param[in] ifftFlagR flag that selects transform direction - value = 0: forward transform - value = 1: inverse transform - @param[in] bitReverseFlag flag that enables / disables bit reversal of output + @param[in] bitReverseFlag flag that enables / disables bit reversal of + output - value = 0: disables bit reversal of output - value = 1: enables bit reversal of output @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : fftLenReal is not a supported length + - \ref ARM_MATH_ARGUMENT_ERROR : fftLenReal is + not a supported length @par Description - The parameter fftLenRealspecifies length of RFFT/RIFFT Process. - Supported FFT Lengths are 128, 512, 2048. + The parameter fftLenRealspecifies length of + RFFT/RIFFT Process. Supported FFT Lengths are 128, 512, 2048. @par - The parameter ifftFlagR controls whether a forward or inverse transform is computed. - Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT is calculated. + The parameter ifftFlagR controls whether a + forward or inverse transform is computed. Set(=1) ifftFlagR to calculate + RIFFT, otherwise RFFT is calculated. @par - The parameter bitReverseFlag controls whether output is in normal order or bit reversed order. - Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order. + The parameter bitReverseFlag controls whether + output is in normal order or bit reversed order. Set(=1) bitReverseFlag for + output to be in normal order otherwise output is in bit reversed order. @par This function also initializes Twiddle factor table. */ -arm_status arm_rfft_init_f32( - arm_rfft_instance_f32 * S, - arm_cfft_radix4_instance_f32 * S_CFFT, - uint32_t fftLenReal, - uint32_t ifftFlagR, - uint32_t bitReverseFlag) -{ +arm_status arm_rfft_init_f32(arm_rfft_instance_f32 *S, + arm_cfft_radix4_instance_f32 *S_CFFT, + uint32_t fftLenReal, uint32_t ifftFlagR, + uint32_t bitReverseFlag) { /* Initialise the default arm status */ arm_status status = ARM_MATH_SUCCESS; /* Initialize the Real FFT length */ - S->fftLenReal = (uint16_t) fftLenReal; + S->fftLenReal = (uint16_t)fftLenReal; /* Initialize the Complex FFT length */ - S->fftLenBy2 = (uint16_t) fftLenReal / 2U; + S->fftLenBy2 = (uint16_t)fftLenReal / 2U; /* Initialize the Twiddle coefficientA pointer */ - S->pTwiddleAReal = (float32_t *) realCoefA; + S->pTwiddleAReal = (float32_t *)realCoefA; /* Initialize the Twiddle coefficientB pointer */ - S->pTwiddleBReal = (float32_t *) realCoefB; + S->pTwiddleBReal = (float32_t *)realCoefB; /* Initialize the Flag for selection of RFFT or RIFFT */ - S->ifftFlagR = (uint8_t) ifftFlagR; + S->ifftFlagR = (uint8_t)ifftFlagR; /* Initialize the Flag for calculation Bit reversal or not */ - S->bitReverseFlagR = (uint8_t) bitReverseFlag; + S->bitReverseFlagR = (uint8_t)bitReverseFlag; /* Initializations of structure parameters depending on the FFT length */ - switch (S->fftLenReal) - { + switch (S->fftLenReal) { /* Init table modifier value */ case 8192U: S->twidCoefRModifier = 1U; @@ -4258,20 +5626,16 @@ arm_status arm_rfft_init_f32( /* Init Complex FFT Instance */ S->pCfft = S_CFFT; - if (S->ifftFlagR) - { + if (S->ifftFlagR) { /* Initializes the CIFFT Module for fftLenreal/2 length */ arm_cfft_radix4_init_f32(S->pCfft, S->fftLenBy2, 1U, 0U); - } - else - { + } else { /* Initializes the CFFT Module for fftLenreal/2 length */ arm_cfft_radix4_init_f32(S->pCfft, S->fftLenBy2, 0U, 0U); } /* return the status of RFFT Init function */ return (status); - } /** diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_init_q15.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_init_q15.c index 2abdd33..7c8af17 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_init_q15.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_init_q15.c @@ -26,9 +26,9 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" #include "arm_const_structs.h" +#include "arm_math.h" /** @ingroup RealFFT @@ -46,1038 +46,1654 @@ n = 4096
for (i = 0; i < n; i++)
   {
-     pATable[2 * i]     = 0.5 * ( 1.0 - sin (2 * PI / (double) (2 * n) * (double) i));
-     pATable[2 * i + 1] = 0.5 * (-1.0 * cos (2 * PI / (double) (2 * n) * (double) i));
+     pATable[2 * i]     = 0.5 * ( 1.0 - sin (2 * PI / (double) (2 * n) *
+  (double) i)); pATable[2 * i + 1] = 0.5 * (-1.0 * cos (2 * PI / (double) (2 *
+  n) * (double) i));
   }
@par Convert to fixed point Q15 format round(pATable[i] * pow(2, 15)) */ const q15_t __ALIGNED(4) realCoefAQ15[8192] = { - (q15_t)0x4000, (q15_t)0xc000, (q15_t)0x3ff3, (q15_t)0xc000, (q15_t)0x3fe7, (q15_t)0xc000, (q15_t)0x3fda, (q15_t)0xc000, - (q15_t)0x3fce, (q15_t)0xc000, (q15_t)0x3fc1, (q15_t)0xc000, (q15_t)0x3fb5, (q15_t)0xc000, (q15_t)0x3fa8, (q15_t)0xc000, - (q15_t)0x3f9b, (q15_t)0xc000, (q15_t)0x3f8f, (q15_t)0xc000, (q15_t)0x3f82, (q15_t)0xc000, (q15_t)0x3f76, (q15_t)0xc001, - (q15_t)0x3f69, (q15_t)0xc001, (q15_t)0x3f5d, (q15_t)0xc001, (q15_t)0x3f50, (q15_t)0xc001, (q15_t)0x3f44, (q15_t)0xc001, - (q15_t)0x3f37, (q15_t)0xc001, (q15_t)0x3f2a, (q15_t)0xc001, (q15_t)0x3f1e, (q15_t)0xc002, (q15_t)0x3f11, (q15_t)0xc002, - (q15_t)0x3f05, (q15_t)0xc002, (q15_t)0x3ef8, (q15_t)0xc002, (q15_t)0x3eec, (q15_t)0xc002, (q15_t)0x3edf, (q15_t)0xc003, - (q15_t)0x3ed2, (q15_t)0xc003, (q15_t)0x3ec6, (q15_t)0xc003, (q15_t)0x3eb9, (q15_t)0xc003, (q15_t)0x3ead, (q15_t)0xc004, - (q15_t)0x3ea0, (q15_t)0xc004, (q15_t)0x3e94, (q15_t)0xc004, (q15_t)0x3e87, (q15_t)0xc004, (q15_t)0x3e7a, (q15_t)0xc005, - (q15_t)0x3e6e, (q15_t)0xc005, (q15_t)0x3e61, (q15_t)0xc005, (q15_t)0x3e55, (q15_t)0xc006, (q15_t)0x3e48, (q15_t)0xc006, - (q15_t)0x3e3c, (q15_t)0xc006, (q15_t)0x3e2f, (q15_t)0xc007, (q15_t)0x3e23, (q15_t)0xc007, (q15_t)0x3e16, (q15_t)0xc007, - (q15_t)0x3e09, (q15_t)0xc008, (q15_t)0x3dfd, (q15_t)0xc008, (q15_t)0x3df0, (q15_t)0xc009, (q15_t)0x3de4, (q15_t)0xc009, - (q15_t)0x3dd7, (q15_t)0xc009, (q15_t)0x3dcb, (q15_t)0xc00a, (q15_t)0x3dbe, (q15_t)0xc00a, (q15_t)0x3db2, (q15_t)0xc00b, - (q15_t)0x3da5, (q15_t)0xc00b, (q15_t)0x3d98, (q15_t)0xc00c, (q15_t)0x3d8c, (q15_t)0xc00c, (q15_t)0x3d7f, (q15_t)0xc00d, - (q15_t)0x3d73, (q15_t)0xc00d, (q15_t)0x3d66, (q15_t)0xc00e, (q15_t)0x3d5a, (q15_t)0xc00e, (q15_t)0x3d4d, (q15_t)0xc00f, - (q15_t)0x3d40, (q15_t)0xc00f, (q15_t)0x3d34, (q15_t)0xc010, (q15_t)0x3d27, (q15_t)0xc010, (q15_t)0x3d1b, (q15_t)0xc011, - (q15_t)0x3d0e, (q15_t)0xc011, (q15_t)0x3d02, (q15_t)0xc012, (q15_t)0x3cf5, (q15_t)0xc013, (q15_t)0x3ce9, (q15_t)0xc013, - (q15_t)0x3cdc, (q15_t)0xc014, (q15_t)0x3cd0, (q15_t)0xc014, (q15_t)0x3cc3, (q15_t)0xc015, (q15_t)0x3cb6, (q15_t)0xc016, - (q15_t)0x3caa, (q15_t)0xc016, (q15_t)0x3c9d, (q15_t)0xc017, (q15_t)0x3c91, (q15_t)0xc018, (q15_t)0x3c84, (q15_t)0xc018, - (q15_t)0x3c78, (q15_t)0xc019, (q15_t)0x3c6b, (q15_t)0xc01a, (q15_t)0x3c5f, (q15_t)0xc01a, (q15_t)0x3c52, (q15_t)0xc01b, - (q15_t)0x3c45, (q15_t)0xc01c, (q15_t)0x3c39, (q15_t)0xc01d, (q15_t)0x3c2c, (q15_t)0xc01d, (q15_t)0x3c20, (q15_t)0xc01e, - (q15_t)0x3c13, (q15_t)0xc01f, (q15_t)0x3c07, (q15_t)0xc020, (q15_t)0x3bfa, (q15_t)0xc020, (q15_t)0x3bee, (q15_t)0xc021, - (q15_t)0x3be1, (q15_t)0xc022, (q15_t)0x3bd5, (q15_t)0xc023, (q15_t)0x3bc8, (q15_t)0xc024, (q15_t)0x3bbc, (q15_t)0xc024, - (q15_t)0x3baf, (q15_t)0xc025, (q15_t)0x3ba2, (q15_t)0xc026, (q15_t)0x3b96, (q15_t)0xc027, (q15_t)0x3b89, (q15_t)0xc028, - (q15_t)0x3b7d, (q15_t)0xc029, (q15_t)0x3b70, (q15_t)0xc02a, (q15_t)0x3b64, (q15_t)0xc02b, (q15_t)0x3b57, (q15_t)0xc02b, - (q15_t)0x3b4b, (q15_t)0xc02c, (q15_t)0x3b3e, (q15_t)0xc02d, (q15_t)0x3b32, (q15_t)0xc02e, (q15_t)0x3b25, (q15_t)0xc02f, - (q15_t)0x3b19, (q15_t)0xc030, (q15_t)0x3b0c, (q15_t)0xc031, (q15_t)0x3b00, (q15_t)0xc032, (q15_t)0x3af3, (q15_t)0xc033, - (q15_t)0x3ae6, (q15_t)0xc034, (q15_t)0x3ada, (q15_t)0xc035, (q15_t)0x3acd, (q15_t)0xc036, (q15_t)0x3ac1, (q15_t)0xc037, - (q15_t)0x3ab4, (q15_t)0xc038, (q15_t)0x3aa8, (q15_t)0xc039, (q15_t)0x3a9b, (q15_t)0xc03a, (q15_t)0x3a8f, (q15_t)0xc03b, - (q15_t)0x3a82, (q15_t)0xc03c, (q15_t)0x3a76, (q15_t)0xc03d, (q15_t)0x3a69, (q15_t)0xc03f, (q15_t)0x3a5d, (q15_t)0xc040, - (q15_t)0x3a50, (q15_t)0xc041, (q15_t)0x3a44, (q15_t)0xc042, (q15_t)0x3a37, (q15_t)0xc043, (q15_t)0x3a2b, (q15_t)0xc044, - (q15_t)0x3a1e, (q15_t)0xc045, (q15_t)0x3a12, (q15_t)0xc047, (q15_t)0x3a05, (q15_t)0xc048, (q15_t)0x39f9, (q15_t)0xc049, - (q15_t)0x39ec, (q15_t)0xc04a, (q15_t)0x39e0, (q15_t)0xc04b, (q15_t)0x39d3, (q15_t)0xc04c, (q15_t)0x39c7, (q15_t)0xc04e, - (q15_t)0x39ba, (q15_t)0xc04f, (q15_t)0x39ae, (q15_t)0xc050, (q15_t)0x39a1, (q15_t)0xc051, (q15_t)0x3995, (q15_t)0xc053, - (q15_t)0x3988, (q15_t)0xc054, (q15_t)0x397c, (q15_t)0xc055, (q15_t)0x396f, (q15_t)0xc056, (q15_t)0x3963, (q15_t)0xc058, - (q15_t)0x3956, (q15_t)0xc059, (q15_t)0x394a, (q15_t)0xc05a, (q15_t)0x393d, (q15_t)0xc05c, (q15_t)0x3931, (q15_t)0xc05d, - (q15_t)0x3924, (q15_t)0xc05e, (q15_t)0x3918, (q15_t)0xc060, (q15_t)0x390b, (q15_t)0xc061, (q15_t)0x38ff, (q15_t)0xc062, - (q15_t)0x38f2, (q15_t)0xc064, (q15_t)0x38e6, (q15_t)0xc065, (q15_t)0x38d9, (q15_t)0xc067, (q15_t)0x38cd, (q15_t)0xc068, - (q15_t)0x38c0, (q15_t)0xc069, (q15_t)0x38b4, (q15_t)0xc06b, (q15_t)0x38a7, (q15_t)0xc06c, (q15_t)0x389b, (q15_t)0xc06e, - (q15_t)0x388e, (q15_t)0xc06f, (q15_t)0x3882, (q15_t)0xc071, (q15_t)0x3875, (q15_t)0xc072, (q15_t)0x3869, (q15_t)0xc074, - (q15_t)0x385c, (q15_t)0xc075, (q15_t)0x3850, (q15_t)0xc077, (q15_t)0x3843, (q15_t)0xc078, (q15_t)0x3837, (q15_t)0xc07a, - (q15_t)0x382a, (q15_t)0xc07b, (q15_t)0x381e, (q15_t)0xc07d, (q15_t)0x3811, (q15_t)0xc07e, (q15_t)0x3805, (q15_t)0xc080, - (q15_t)0x37f9, (q15_t)0xc081, (q15_t)0x37ec, (q15_t)0xc083, (q15_t)0x37e0, (q15_t)0xc085, (q15_t)0x37d3, (q15_t)0xc086, - (q15_t)0x37c7, (q15_t)0xc088, (q15_t)0x37ba, (q15_t)0xc089, (q15_t)0x37ae, (q15_t)0xc08b, (q15_t)0x37a1, (q15_t)0xc08d, - (q15_t)0x3795, (q15_t)0xc08e, (q15_t)0x3788, (q15_t)0xc090, (q15_t)0x377c, (q15_t)0xc092, (q15_t)0x376f, (q15_t)0xc093, - (q15_t)0x3763, (q15_t)0xc095, (q15_t)0x3757, (q15_t)0xc097, (q15_t)0x374a, (q15_t)0xc098, (q15_t)0x373e, (q15_t)0xc09a, - (q15_t)0x3731, (q15_t)0xc09c, (q15_t)0x3725, (q15_t)0xc09e, (q15_t)0x3718, (q15_t)0xc09f, (q15_t)0x370c, (q15_t)0xc0a1, - (q15_t)0x36ff, (q15_t)0xc0a3, (q15_t)0x36f3, (q15_t)0xc0a5, (q15_t)0x36e7, (q15_t)0xc0a6, (q15_t)0x36da, (q15_t)0xc0a8, - (q15_t)0x36ce, (q15_t)0xc0aa, (q15_t)0x36c1, (q15_t)0xc0ac, (q15_t)0x36b5, (q15_t)0xc0ae, (q15_t)0x36a8, (q15_t)0xc0af, - (q15_t)0x369c, (q15_t)0xc0b1, (q15_t)0x3690, (q15_t)0xc0b3, (q15_t)0x3683, (q15_t)0xc0b5, (q15_t)0x3677, (q15_t)0xc0b7, - (q15_t)0x366a, (q15_t)0xc0b9, (q15_t)0x365e, (q15_t)0xc0bb, (q15_t)0x3651, (q15_t)0xc0bd, (q15_t)0x3645, (q15_t)0xc0be, - (q15_t)0x3639, (q15_t)0xc0c0, (q15_t)0x362c, (q15_t)0xc0c2, (q15_t)0x3620, (q15_t)0xc0c4, (q15_t)0x3613, (q15_t)0xc0c6, - (q15_t)0x3607, (q15_t)0xc0c8, (q15_t)0x35fa, (q15_t)0xc0ca, (q15_t)0x35ee, (q15_t)0xc0cc, (q15_t)0x35e2, (q15_t)0xc0ce, - (q15_t)0x35d5, (q15_t)0xc0d0, (q15_t)0x35c9, (q15_t)0xc0d2, (q15_t)0x35bc, (q15_t)0xc0d4, (q15_t)0x35b0, (q15_t)0xc0d6, - (q15_t)0x35a4, (q15_t)0xc0d8, (q15_t)0x3597, (q15_t)0xc0da, (q15_t)0x358b, (q15_t)0xc0dc, (q15_t)0x357e, (q15_t)0xc0de, - (q15_t)0x3572, (q15_t)0xc0e0, (q15_t)0x3566, (q15_t)0xc0e2, (q15_t)0x3559, (q15_t)0xc0e4, (q15_t)0x354d, (q15_t)0xc0e7, - (q15_t)0x3540, (q15_t)0xc0e9, (q15_t)0x3534, (q15_t)0xc0eb, (q15_t)0x3528, (q15_t)0xc0ed, (q15_t)0x351b, (q15_t)0xc0ef, - (q15_t)0x350f, (q15_t)0xc0f1, (q15_t)0x3503, (q15_t)0xc0f3, (q15_t)0x34f6, (q15_t)0xc0f6, (q15_t)0x34ea, (q15_t)0xc0f8, - (q15_t)0x34dd, (q15_t)0xc0fa, (q15_t)0x34d1, (q15_t)0xc0fc, (q15_t)0x34c5, (q15_t)0xc0fe, (q15_t)0x34b8, (q15_t)0xc100, - (q15_t)0x34ac, (q15_t)0xc103, (q15_t)0x34a0, (q15_t)0xc105, (q15_t)0x3493, (q15_t)0xc107, (q15_t)0x3487, (q15_t)0xc109, - (q15_t)0x347b, (q15_t)0xc10c, (q15_t)0x346e, (q15_t)0xc10e, (q15_t)0x3462, (q15_t)0xc110, (q15_t)0x3455, (q15_t)0xc113, - (q15_t)0x3449, (q15_t)0xc115, (q15_t)0x343d, (q15_t)0xc117, (q15_t)0x3430, (q15_t)0xc119, (q15_t)0x3424, (q15_t)0xc11c, - (q15_t)0x3418, (q15_t)0xc11e, (q15_t)0x340b, (q15_t)0xc120, (q15_t)0x33ff, (q15_t)0xc123, (q15_t)0x33f3, (q15_t)0xc125, - (q15_t)0x33e6, (q15_t)0xc128, (q15_t)0x33da, (q15_t)0xc12a, (q15_t)0x33ce, (q15_t)0xc12c, (q15_t)0x33c1, (q15_t)0xc12f, - (q15_t)0x33b5, (q15_t)0xc131, (q15_t)0x33a9, (q15_t)0xc134, (q15_t)0x339c, (q15_t)0xc136, (q15_t)0x3390, (q15_t)0xc138, - (q15_t)0x3384, (q15_t)0xc13b, (q15_t)0x3377, (q15_t)0xc13d, (q15_t)0x336b, (q15_t)0xc140, (q15_t)0x335f, (q15_t)0xc142, - (q15_t)0x3352, (q15_t)0xc145, (q15_t)0x3346, (q15_t)0xc147, (q15_t)0x333a, (q15_t)0xc14a, (q15_t)0x332d, (q15_t)0xc14c, - (q15_t)0x3321, (q15_t)0xc14f, (q15_t)0x3315, (q15_t)0xc151, (q15_t)0x3308, (q15_t)0xc154, (q15_t)0x32fc, (q15_t)0xc156, - (q15_t)0x32f0, (q15_t)0xc159, (q15_t)0x32e4, (q15_t)0xc15b, (q15_t)0x32d7, (q15_t)0xc15e, (q15_t)0x32cb, (q15_t)0xc161, - (q15_t)0x32bf, (q15_t)0xc163, (q15_t)0x32b2, (q15_t)0xc166, (q15_t)0x32a6, (q15_t)0xc168, (q15_t)0x329a, (q15_t)0xc16b, - (q15_t)0x328e, (q15_t)0xc16e, (q15_t)0x3281, (q15_t)0xc170, (q15_t)0x3275, (q15_t)0xc173, (q15_t)0x3269, (q15_t)0xc176, - (q15_t)0x325c, (q15_t)0xc178, (q15_t)0x3250, (q15_t)0xc17b, (q15_t)0x3244, (q15_t)0xc17e, (q15_t)0x3238, (q15_t)0xc180, - (q15_t)0x322b, (q15_t)0xc183, (q15_t)0x321f, (q15_t)0xc186, (q15_t)0x3213, (q15_t)0xc189, (q15_t)0x3207, (q15_t)0xc18b, - (q15_t)0x31fa, (q15_t)0xc18e, (q15_t)0x31ee, (q15_t)0xc191, (q15_t)0x31e2, (q15_t)0xc194, (q15_t)0x31d5, (q15_t)0xc196, - (q15_t)0x31c9, (q15_t)0xc199, (q15_t)0x31bd, (q15_t)0xc19c, (q15_t)0x31b1, (q15_t)0xc19f, (q15_t)0x31a4, (q15_t)0xc1a2, - (q15_t)0x3198, (q15_t)0xc1a4, (q15_t)0x318c, (q15_t)0xc1a7, (q15_t)0x3180, (q15_t)0xc1aa, (q15_t)0x3174, (q15_t)0xc1ad, - (q15_t)0x3167, (q15_t)0xc1b0, (q15_t)0x315b, (q15_t)0xc1b3, (q15_t)0x314f, (q15_t)0xc1b6, (q15_t)0x3143, (q15_t)0xc1b8, - (q15_t)0x3136, (q15_t)0xc1bb, (q15_t)0x312a, (q15_t)0xc1be, (q15_t)0x311e, (q15_t)0xc1c1, (q15_t)0x3112, (q15_t)0xc1c4, - (q15_t)0x3105, (q15_t)0xc1c7, (q15_t)0x30f9, (q15_t)0xc1ca, (q15_t)0x30ed, (q15_t)0xc1cd, (q15_t)0x30e1, (q15_t)0xc1d0, - (q15_t)0x30d5, (q15_t)0xc1d3, (q15_t)0x30c8, (q15_t)0xc1d6, (q15_t)0x30bc, (q15_t)0xc1d9, (q15_t)0x30b0, (q15_t)0xc1dc, - (q15_t)0x30a4, (q15_t)0xc1df, (q15_t)0x3098, (q15_t)0xc1e2, (q15_t)0x308b, (q15_t)0xc1e5, (q15_t)0x307f, (q15_t)0xc1e8, - (q15_t)0x3073, (q15_t)0xc1eb, (q15_t)0x3067, (q15_t)0xc1ee, (q15_t)0x305b, (q15_t)0xc1f1, (q15_t)0x304e, (q15_t)0xc1f4, - (q15_t)0x3042, (q15_t)0xc1f7, (q15_t)0x3036, (q15_t)0xc1fa, (q15_t)0x302a, (q15_t)0xc1fd, (q15_t)0x301e, (q15_t)0xc201, - (q15_t)0x3012, (q15_t)0xc204, (q15_t)0x3005, (q15_t)0xc207, (q15_t)0x2ff9, (q15_t)0xc20a, (q15_t)0x2fed, (q15_t)0xc20d, - (q15_t)0x2fe1, (q15_t)0xc210, (q15_t)0x2fd5, (q15_t)0xc213, (q15_t)0x2fc9, (q15_t)0xc217, (q15_t)0x2fbc, (q15_t)0xc21a, - (q15_t)0x2fb0, (q15_t)0xc21d, (q15_t)0x2fa4, (q15_t)0xc220, (q15_t)0x2f98, (q15_t)0xc223, (q15_t)0x2f8c, (q15_t)0xc227, - (q15_t)0x2f80, (q15_t)0xc22a, (q15_t)0x2f74, (q15_t)0xc22d, (q15_t)0x2f67, (q15_t)0xc230, (q15_t)0x2f5b, (q15_t)0xc234, - (q15_t)0x2f4f, (q15_t)0xc237, (q15_t)0x2f43, (q15_t)0xc23a, (q15_t)0x2f37, (q15_t)0xc23e, (q15_t)0x2f2b, (q15_t)0xc241, - (q15_t)0x2f1f, (q15_t)0xc244, (q15_t)0x2f13, (q15_t)0xc247, (q15_t)0x2f06, (q15_t)0xc24b, (q15_t)0x2efa, (q15_t)0xc24e, - (q15_t)0x2eee, (q15_t)0xc251, (q15_t)0x2ee2, (q15_t)0xc255, (q15_t)0x2ed6, (q15_t)0xc258, (q15_t)0x2eca, (q15_t)0xc25c, - (q15_t)0x2ebe, (q15_t)0xc25f, (q15_t)0x2eb2, (q15_t)0xc262, (q15_t)0x2ea6, (q15_t)0xc266, (q15_t)0x2e99, (q15_t)0xc269, - (q15_t)0x2e8d, (q15_t)0xc26d, (q15_t)0x2e81, (q15_t)0xc270, (q15_t)0x2e75, (q15_t)0xc273, (q15_t)0x2e69, (q15_t)0xc277, - (q15_t)0x2e5d, (q15_t)0xc27a, (q15_t)0x2e51, (q15_t)0xc27e, (q15_t)0x2e45, (q15_t)0xc281, (q15_t)0x2e39, (q15_t)0xc285, - (q15_t)0x2e2d, (q15_t)0xc288, (q15_t)0x2e21, (q15_t)0xc28c, (q15_t)0x2e15, (q15_t)0xc28f, (q15_t)0x2e09, (q15_t)0xc293, - (q15_t)0x2dfc, (q15_t)0xc296, (q15_t)0x2df0, (q15_t)0xc29a, (q15_t)0x2de4, (q15_t)0xc29d, (q15_t)0x2dd8, (q15_t)0xc2a1, - (q15_t)0x2dcc, (q15_t)0xc2a5, (q15_t)0x2dc0, (q15_t)0xc2a8, (q15_t)0x2db4, (q15_t)0xc2ac, (q15_t)0x2da8, (q15_t)0xc2af, - (q15_t)0x2d9c, (q15_t)0xc2b3, (q15_t)0x2d90, (q15_t)0xc2b7, (q15_t)0x2d84, (q15_t)0xc2ba, (q15_t)0x2d78, (q15_t)0xc2be, - (q15_t)0x2d6c, (q15_t)0xc2c1, (q15_t)0x2d60, (q15_t)0xc2c5, (q15_t)0x2d54, (q15_t)0xc2c9, (q15_t)0x2d48, (q15_t)0xc2cc, - (q15_t)0x2d3c, (q15_t)0xc2d0, (q15_t)0x2d30, (q15_t)0xc2d4, (q15_t)0x2d24, (q15_t)0xc2d8, (q15_t)0x2d18, (q15_t)0xc2db, - (q15_t)0x2d0c, (q15_t)0xc2df, (q15_t)0x2d00, (q15_t)0xc2e3, (q15_t)0x2cf4, (q15_t)0xc2e6, (q15_t)0x2ce8, (q15_t)0xc2ea, - (q15_t)0x2cdc, (q15_t)0xc2ee, (q15_t)0x2cd0, (q15_t)0xc2f2, (q15_t)0x2cc4, (q15_t)0xc2f5, (q15_t)0x2cb8, (q15_t)0xc2f9, - (q15_t)0x2cac, (q15_t)0xc2fd, (q15_t)0x2ca0, (q15_t)0xc301, (q15_t)0x2c94, (q15_t)0xc305, (q15_t)0x2c88, (q15_t)0xc308, - (q15_t)0x2c7c, (q15_t)0xc30c, (q15_t)0x2c70, (q15_t)0xc310, (q15_t)0x2c64, (q15_t)0xc314, (q15_t)0x2c58, (q15_t)0xc318, - (q15_t)0x2c4c, (q15_t)0xc31c, (q15_t)0x2c40, (q15_t)0xc320, (q15_t)0x2c34, (q15_t)0xc323, (q15_t)0x2c28, (q15_t)0xc327, - (q15_t)0x2c1c, (q15_t)0xc32b, (q15_t)0x2c10, (q15_t)0xc32f, (q15_t)0x2c05, (q15_t)0xc333, (q15_t)0x2bf9, (q15_t)0xc337, - (q15_t)0x2bed, (q15_t)0xc33b, (q15_t)0x2be1, (q15_t)0xc33f, (q15_t)0x2bd5, (q15_t)0xc343, (q15_t)0x2bc9, (q15_t)0xc347, - (q15_t)0x2bbd, (q15_t)0xc34b, (q15_t)0x2bb1, (q15_t)0xc34f, (q15_t)0x2ba5, (q15_t)0xc353, (q15_t)0x2b99, (q15_t)0xc357, - (q15_t)0x2b8d, (q15_t)0xc35b, (q15_t)0x2b81, (q15_t)0xc35f, (q15_t)0x2b75, (q15_t)0xc363, (q15_t)0x2b6a, (q15_t)0xc367, - (q15_t)0x2b5e, (q15_t)0xc36b, (q15_t)0x2b52, (q15_t)0xc36f, (q15_t)0x2b46, (q15_t)0xc373, (q15_t)0x2b3a, (q15_t)0xc377, - (q15_t)0x2b2e, (q15_t)0xc37b, (q15_t)0x2b22, (q15_t)0xc37f, (q15_t)0x2b16, (q15_t)0xc383, (q15_t)0x2b0a, (q15_t)0xc387, - (q15_t)0x2aff, (q15_t)0xc38c, (q15_t)0x2af3, (q15_t)0xc390, (q15_t)0x2ae7, (q15_t)0xc394, (q15_t)0x2adb, (q15_t)0xc398, - (q15_t)0x2acf, (q15_t)0xc39c, (q15_t)0x2ac3, (q15_t)0xc3a0, (q15_t)0x2ab7, (q15_t)0xc3a5, (q15_t)0x2aac, (q15_t)0xc3a9, - (q15_t)0x2aa0, (q15_t)0xc3ad, (q15_t)0x2a94, (q15_t)0xc3b1, (q15_t)0x2a88, (q15_t)0xc3b5, (q15_t)0x2a7c, (q15_t)0xc3ba, - (q15_t)0x2a70, (q15_t)0xc3be, (q15_t)0x2a65, (q15_t)0xc3c2, (q15_t)0x2a59, (q15_t)0xc3c6, (q15_t)0x2a4d, (q15_t)0xc3ca, - (q15_t)0x2a41, (q15_t)0xc3cf, (q15_t)0x2a35, (q15_t)0xc3d3, (q15_t)0x2a29, (q15_t)0xc3d7, (q15_t)0x2a1e, (q15_t)0xc3dc, - (q15_t)0x2a12, (q15_t)0xc3e0, (q15_t)0x2a06, (q15_t)0xc3e4, (q15_t)0x29fa, (q15_t)0xc3e9, (q15_t)0x29ee, (q15_t)0xc3ed, - (q15_t)0x29e3, (q15_t)0xc3f1, (q15_t)0x29d7, (q15_t)0xc3f6, (q15_t)0x29cb, (q15_t)0xc3fa, (q15_t)0x29bf, (q15_t)0xc3fe, - (q15_t)0x29b4, (q15_t)0xc403, (q15_t)0x29a8, (q15_t)0xc407, (q15_t)0x299c, (q15_t)0xc40b, (q15_t)0x2990, (q15_t)0xc410, - (q15_t)0x2984, (q15_t)0xc414, (q15_t)0x2979, (q15_t)0xc419, (q15_t)0x296d, (q15_t)0xc41d, (q15_t)0x2961, (q15_t)0xc422, - (q15_t)0x2955, (q15_t)0xc426, (q15_t)0x294a, (q15_t)0xc42a, (q15_t)0x293e, (q15_t)0xc42f, (q15_t)0x2932, (q15_t)0xc433, - (q15_t)0x2926, (q15_t)0xc438, (q15_t)0x291b, (q15_t)0xc43c, (q15_t)0x290f, (q15_t)0xc441, (q15_t)0x2903, (q15_t)0xc445, - (q15_t)0x28f7, (q15_t)0xc44a, (q15_t)0x28ec, (q15_t)0xc44e, (q15_t)0x28e0, (q15_t)0xc453, (q15_t)0x28d4, (q15_t)0xc457, - (q15_t)0x28c9, (q15_t)0xc45c, (q15_t)0x28bd, (q15_t)0xc461, (q15_t)0x28b1, (q15_t)0xc465, (q15_t)0x28a5, (q15_t)0xc46a, - (q15_t)0x289a, (q15_t)0xc46e, (q15_t)0x288e, (q15_t)0xc473, (q15_t)0x2882, (q15_t)0xc478, (q15_t)0x2877, (q15_t)0xc47c, - (q15_t)0x286b, (q15_t)0xc481, (q15_t)0x285f, (q15_t)0xc485, (q15_t)0x2854, (q15_t)0xc48a, (q15_t)0x2848, (q15_t)0xc48f, - (q15_t)0x283c, (q15_t)0xc493, (q15_t)0x2831, (q15_t)0xc498, (q15_t)0x2825, (q15_t)0xc49d, (q15_t)0x2819, (q15_t)0xc4a1, - (q15_t)0x280e, (q15_t)0xc4a6, (q15_t)0x2802, (q15_t)0xc4ab, (q15_t)0x27f6, (q15_t)0xc4b0, (q15_t)0x27eb, (q15_t)0xc4b4, - (q15_t)0x27df, (q15_t)0xc4b9, (q15_t)0x27d3, (q15_t)0xc4be, (q15_t)0x27c8, (q15_t)0xc4c2, (q15_t)0x27bc, (q15_t)0xc4c7, - (q15_t)0x27b1, (q15_t)0xc4cc, (q15_t)0x27a5, (q15_t)0xc4d1, (q15_t)0x2799, (q15_t)0xc4d6, (q15_t)0x278e, (q15_t)0xc4da, - (q15_t)0x2782, (q15_t)0xc4df, (q15_t)0x2777, (q15_t)0xc4e4, (q15_t)0x276b, (q15_t)0xc4e9, (q15_t)0x275f, (q15_t)0xc4ee, - (q15_t)0x2754, (q15_t)0xc4f2, (q15_t)0x2748, (q15_t)0xc4f7, (q15_t)0x273d, (q15_t)0xc4fc, (q15_t)0x2731, (q15_t)0xc501, - (q15_t)0x2725, (q15_t)0xc506, (q15_t)0x271a, (q15_t)0xc50b, (q15_t)0x270e, (q15_t)0xc510, (q15_t)0x2703, (q15_t)0xc515, - (q15_t)0x26f7, (q15_t)0xc51a, (q15_t)0x26ec, (q15_t)0xc51e, (q15_t)0x26e0, (q15_t)0xc523, (q15_t)0x26d4, (q15_t)0xc528, - (q15_t)0x26c9, (q15_t)0xc52d, (q15_t)0x26bd, (q15_t)0xc532, (q15_t)0x26b2, (q15_t)0xc537, (q15_t)0x26a6, (q15_t)0xc53c, - (q15_t)0x269b, (q15_t)0xc541, (q15_t)0x268f, (q15_t)0xc546, (q15_t)0x2684, (q15_t)0xc54b, (q15_t)0x2678, (q15_t)0xc550, - (q15_t)0x266d, (q15_t)0xc555, (q15_t)0x2661, (q15_t)0xc55a, (q15_t)0x2656, (q15_t)0xc55f, (q15_t)0x264a, (q15_t)0xc564, - (q15_t)0x263f, (q15_t)0xc569, (q15_t)0x2633, (q15_t)0xc56e, (q15_t)0x2628, (q15_t)0xc573, (q15_t)0x261c, (q15_t)0xc578, - (q15_t)0x2611, (q15_t)0xc57e, (q15_t)0x2605, (q15_t)0xc583, (q15_t)0x25fa, (q15_t)0xc588, (q15_t)0x25ee, (q15_t)0xc58d, - (q15_t)0x25e3, (q15_t)0xc592, (q15_t)0x25d7, (q15_t)0xc597, (q15_t)0x25cc, (q15_t)0xc59c, (q15_t)0x25c0, (q15_t)0xc5a1, - (q15_t)0x25b5, (q15_t)0xc5a7, (q15_t)0x25a9, (q15_t)0xc5ac, (q15_t)0x259e, (q15_t)0xc5b1, (q15_t)0x2592, (q15_t)0xc5b6, - (q15_t)0x2587, (q15_t)0xc5bb, (q15_t)0x257c, (q15_t)0xc5c1, (q15_t)0x2570, (q15_t)0xc5c6, (q15_t)0x2565, (q15_t)0xc5cb, - (q15_t)0x2559, (q15_t)0xc5d0, (q15_t)0x254e, (q15_t)0xc5d5, (q15_t)0x2542, (q15_t)0xc5db, (q15_t)0x2537, (q15_t)0xc5e0, - (q15_t)0x252c, (q15_t)0xc5e5, (q15_t)0x2520, (q15_t)0xc5ea, (q15_t)0x2515, (q15_t)0xc5f0, (q15_t)0x2509, (q15_t)0xc5f5, - (q15_t)0x24fe, (q15_t)0xc5fa, (q15_t)0x24f3, (q15_t)0xc600, (q15_t)0x24e7, (q15_t)0xc605, (q15_t)0x24dc, (q15_t)0xc60a, - (q15_t)0x24d0, (q15_t)0xc610, (q15_t)0x24c5, (q15_t)0xc615, (q15_t)0x24ba, (q15_t)0xc61a, (q15_t)0x24ae, (q15_t)0xc620, - (q15_t)0x24a3, (q15_t)0xc625, (q15_t)0x2498, (q15_t)0xc62a, (q15_t)0x248c, (q15_t)0xc630, (q15_t)0x2481, (q15_t)0xc635, - (q15_t)0x2476, (q15_t)0xc63b, (q15_t)0x246a, (q15_t)0xc640, (q15_t)0x245f, (q15_t)0xc645, (q15_t)0x2454, (q15_t)0xc64b, - (q15_t)0x2448, (q15_t)0xc650, (q15_t)0x243d, (q15_t)0xc656, (q15_t)0x2432, (q15_t)0xc65b, (q15_t)0x2426, (q15_t)0xc661, - (q15_t)0x241b, (q15_t)0xc666, (q15_t)0x2410, (q15_t)0xc66c, (q15_t)0x2404, (q15_t)0xc671, (q15_t)0x23f9, (q15_t)0xc677, - (q15_t)0x23ee, (q15_t)0xc67c, (q15_t)0x23e2, (q15_t)0xc682, (q15_t)0x23d7, (q15_t)0xc687, (q15_t)0x23cc, (q15_t)0xc68d, - (q15_t)0x23c1, (q15_t)0xc692, (q15_t)0x23b5, (q15_t)0xc698, (q15_t)0x23aa, (q15_t)0xc69d, (q15_t)0x239f, (q15_t)0xc6a3, - (q15_t)0x2394, (q15_t)0xc6a8, (q15_t)0x2388, (q15_t)0xc6ae, (q15_t)0x237d, (q15_t)0xc6b4, (q15_t)0x2372, (q15_t)0xc6b9, - (q15_t)0x2367, (q15_t)0xc6bf, (q15_t)0x235b, (q15_t)0xc6c5, (q15_t)0x2350, (q15_t)0xc6ca, (q15_t)0x2345, (q15_t)0xc6d0, - (q15_t)0x233a, (q15_t)0xc6d5, (q15_t)0x232e, (q15_t)0xc6db, (q15_t)0x2323, (q15_t)0xc6e1, (q15_t)0x2318, (q15_t)0xc6e6, - (q15_t)0x230d, (q15_t)0xc6ec, (q15_t)0x2301, (q15_t)0xc6f2, (q15_t)0x22f6, (q15_t)0xc6f7, (q15_t)0x22eb, (q15_t)0xc6fd, - (q15_t)0x22e0, (q15_t)0xc703, (q15_t)0x22d5, (q15_t)0xc709, (q15_t)0x22ca, (q15_t)0xc70e, (q15_t)0x22be, (q15_t)0xc714, - (q15_t)0x22b3, (q15_t)0xc71a, (q15_t)0x22a8, (q15_t)0xc720, (q15_t)0x229d, (q15_t)0xc725, (q15_t)0x2292, (q15_t)0xc72b, - (q15_t)0x2287, (q15_t)0xc731, (q15_t)0x227b, (q15_t)0xc737, (q15_t)0x2270, (q15_t)0xc73d, (q15_t)0x2265, (q15_t)0xc742, - (q15_t)0x225a, (q15_t)0xc748, (q15_t)0x224f, (q15_t)0xc74e, (q15_t)0x2244, (q15_t)0xc754, (q15_t)0x2239, (q15_t)0xc75a, - (q15_t)0x222d, (q15_t)0xc75f, (q15_t)0x2222, (q15_t)0xc765, (q15_t)0x2217, (q15_t)0xc76b, (q15_t)0x220c, (q15_t)0xc771, - (q15_t)0x2201, (q15_t)0xc777, (q15_t)0x21f6, (q15_t)0xc77d, (q15_t)0x21eb, (q15_t)0xc783, (q15_t)0x21e0, (q15_t)0xc789, - (q15_t)0x21d5, (q15_t)0xc78f, (q15_t)0x21ca, (q15_t)0xc795, (q15_t)0x21be, (q15_t)0xc79a, (q15_t)0x21b3, (q15_t)0xc7a0, - (q15_t)0x21a8, (q15_t)0xc7a6, (q15_t)0x219d, (q15_t)0xc7ac, (q15_t)0x2192, (q15_t)0xc7b2, (q15_t)0x2187, (q15_t)0xc7b8, - (q15_t)0x217c, (q15_t)0xc7be, (q15_t)0x2171, (q15_t)0xc7c4, (q15_t)0x2166, (q15_t)0xc7ca, (q15_t)0x215b, (q15_t)0xc7d0, - (q15_t)0x2150, (q15_t)0xc7d6, (q15_t)0x2145, (q15_t)0xc7dc, (q15_t)0x213a, (q15_t)0xc7e2, (q15_t)0x212f, (q15_t)0xc7e8, - (q15_t)0x2124, (q15_t)0xc7ee, (q15_t)0x2119, (q15_t)0xc7f5, (q15_t)0x210e, (q15_t)0xc7fb, (q15_t)0x2103, (q15_t)0xc801, - (q15_t)0x20f8, (q15_t)0xc807, (q15_t)0x20ed, (q15_t)0xc80d, (q15_t)0x20e2, (q15_t)0xc813, (q15_t)0x20d7, (q15_t)0xc819, - (q15_t)0x20cc, (q15_t)0xc81f, (q15_t)0x20c1, (q15_t)0xc825, (q15_t)0x20b6, (q15_t)0xc82b, (q15_t)0x20ab, (q15_t)0xc832, - (q15_t)0x20a0, (q15_t)0xc838, (q15_t)0x2095, (q15_t)0xc83e, (q15_t)0x208a, (q15_t)0xc844, (q15_t)0x207f, (q15_t)0xc84a, - (q15_t)0x2074, (q15_t)0xc850, (q15_t)0x2069, (q15_t)0xc857, (q15_t)0x205e, (q15_t)0xc85d, (q15_t)0x2054, (q15_t)0xc863, - (q15_t)0x2049, (q15_t)0xc869, (q15_t)0x203e, (q15_t)0xc870, (q15_t)0x2033, (q15_t)0xc876, (q15_t)0x2028, (q15_t)0xc87c, - (q15_t)0x201d, (q15_t)0xc882, (q15_t)0x2012, (q15_t)0xc889, (q15_t)0x2007, (q15_t)0xc88f, (q15_t)0x1ffc, (q15_t)0xc895, - (q15_t)0x1ff1, (q15_t)0xc89b, (q15_t)0x1fe7, (q15_t)0xc8a2, (q15_t)0x1fdc, (q15_t)0xc8a8, (q15_t)0x1fd1, (q15_t)0xc8ae, - (q15_t)0x1fc6, (q15_t)0xc8b5, (q15_t)0x1fbb, (q15_t)0xc8bb, (q15_t)0x1fb0, (q15_t)0xc8c1, (q15_t)0x1fa5, (q15_t)0xc8c8, - (q15_t)0x1f9b, (q15_t)0xc8ce, (q15_t)0x1f90, (q15_t)0xc8d4, (q15_t)0x1f85, (q15_t)0xc8db, (q15_t)0x1f7a, (q15_t)0xc8e1, - (q15_t)0x1f6f, (q15_t)0xc8e8, (q15_t)0x1f65, (q15_t)0xc8ee, (q15_t)0x1f5a, (q15_t)0xc8f4, (q15_t)0x1f4f, (q15_t)0xc8fb, - (q15_t)0x1f44, (q15_t)0xc901, (q15_t)0x1f39, (q15_t)0xc908, (q15_t)0x1f2f, (q15_t)0xc90e, (q15_t)0x1f24, (q15_t)0xc915, - (q15_t)0x1f19, (q15_t)0xc91b, (q15_t)0x1f0e, (q15_t)0xc921, (q15_t)0x1f03, (q15_t)0xc928, (q15_t)0x1ef9, (q15_t)0xc92e, - (q15_t)0x1eee, (q15_t)0xc935, (q15_t)0x1ee3, (q15_t)0xc93b, (q15_t)0x1ed8, (q15_t)0xc942, (q15_t)0x1ece, (q15_t)0xc948, - (q15_t)0x1ec3, (q15_t)0xc94f, (q15_t)0x1eb8, (q15_t)0xc955, (q15_t)0x1ead, (q15_t)0xc95c, (q15_t)0x1ea3, (q15_t)0xc963, - (q15_t)0x1e98, (q15_t)0xc969, (q15_t)0x1e8d, (q15_t)0xc970, (q15_t)0x1e83, (q15_t)0xc976, (q15_t)0x1e78, (q15_t)0xc97d, - (q15_t)0x1e6d, (q15_t)0xc983, (q15_t)0x1e62, (q15_t)0xc98a, (q15_t)0x1e58, (q15_t)0xc991, (q15_t)0x1e4d, (q15_t)0xc997, - (q15_t)0x1e42, (q15_t)0xc99e, (q15_t)0x1e38, (q15_t)0xc9a4, (q15_t)0x1e2d, (q15_t)0xc9ab, (q15_t)0x1e22, (q15_t)0xc9b2, - (q15_t)0x1e18, (q15_t)0xc9b8, (q15_t)0x1e0d, (q15_t)0xc9bf, (q15_t)0x1e02, (q15_t)0xc9c6, (q15_t)0x1df8, (q15_t)0xc9cc, - (q15_t)0x1ded, (q15_t)0xc9d3, (q15_t)0x1de2, (q15_t)0xc9da, (q15_t)0x1dd8, (q15_t)0xc9e0, (q15_t)0x1dcd, (q15_t)0xc9e7, - (q15_t)0x1dc3, (q15_t)0xc9ee, (q15_t)0x1db8, (q15_t)0xc9f5, (q15_t)0x1dad, (q15_t)0xc9fb, (q15_t)0x1da3, (q15_t)0xca02, - (q15_t)0x1d98, (q15_t)0xca09, (q15_t)0x1d8e, (q15_t)0xca10, (q15_t)0x1d83, (q15_t)0xca16, (q15_t)0x1d78, (q15_t)0xca1d, - (q15_t)0x1d6e, (q15_t)0xca24, (q15_t)0x1d63, (q15_t)0xca2b, (q15_t)0x1d59, (q15_t)0xca32, (q15_t)0x1d4e, (q15_t)0xca38, - (q15_t)0x1d44, (q15_t)0xca3f, (q15_t)0x1d39, (q15_t)0xca46, (q15_t)0x1d2e, (q15_t)0xca4d, (q15_t)0x1d24, (q15_t)0xca54, - (q15_t)0x1d19, (q15_t)0xca5b, (q15_t)0x1d0f, (q15_t)0xca61, (q15_t)0x1d04, (q15_t)0xca68, (q15_t)0x1cfa, (q15_t)0xca6f, - (q15_t)0x1cef, (q15_t)0xca76, (q15_t)0x1ce5, (q15_t)0xca7d, (q15_t)0x1cda, (q15_t)0xca84, (q15_t)0x1cd0, (q15_t)0xca8b, - (q15_t)0x1cc5, (q15_t)0xca92, (q15_t)0x1cbb, (q15_t)0xca99, (q15_t)0x1cb0, (q15_t)0xca9f, (q15_t)0x1ca6, (q15_t)0xcaa6, - (q15_t)0x1c9b, (q15_t)0xcaad, (q15_t)0x1c91, (q15_t)0xcab4, (q15_t)0x1c86, (q15_t)0xcabb, (q15_t)0x1c7c, (q15_t)0xcac2, - (q15_t)0x1c72, (q15_t)0xcac9, (q15_t)0x1c67, (q15_t)0xcad0, (q15_t)0x1c5d, (q15_t)0xcad7, (q15_t)0x1c52, (q15_t)0xcade, - (q15_t)0x1c48, (q15_t)0xcae5, (q15_t)0x1c3d, (q15_t)0xcaec, (q15_t)0x1c33, (q15_t)0xcaf3, (q15_t)0x1c29, (q15_t)0xcafa, - (q15_t)0x1c1e, (q15_t)0xcb01, (q15_t)0x1c14, (q15_t)0xcb08, (q15_t)0x1c09, (q15_t)0xcb0f, (q15_t)0x1bff, (q15_t)0xcb16, - (q15_t)0x1bf5, (q15_t)0xcb1e, (q15_t)0x1bea, (q15_t)0xcb25, (q15_t)0x1be0, (q15_t)0xcb2c, (q15_t)0x1bd5, (q15_t)0xcb33, - (q15_t)0x1bcb, (q15_t)0xcb3a, (q15_t)0x1bc1, (q15_t)0xcb41, (q15_t)0x1bb6, (q15_t)0xcb48, (q15_t)0x1bac, (q15_t)0xcb4f, - (q15_t)0x1ba2, (q15_t)0xcb56, (q15_t)0x1b97, (q15_t)0xcb5e, (q15_t)0x1b8d, (q15_t)0xcb65, (q15_t)0x1b83, (q15_t)0xcb6c, - (q15_t)0x1b78, (q15_t)0xcb73, (q15_t)0x1b6e, (q15_t)0xcb7a, (q15_t)0x1b64, (q15_t)0xcb81, (q15_t)0x1b59, (q15_t)0xcb89, - (q15_t)0x1b4f, (q15_t)0xcb90, (q15_t)0x1b45, (q15_t)0xcb97, (q15_t)0x1b3b, (q15_t)0xcb9e, (q15_t)0x1b30, (q15_t)0xcba5, - (q15_t)0x1b26, (q15_t)0xcbad, (q15_t)0x1b1c, (q15_t)0xcbb4, (q15_t)0x1b11, (q15_t)0xcbbb, (q15_t)0x1b07, (q15_t)0xcbc2, - (q15_t)0x1afd, (q15_t)0xcbca, (q15_t)0x1af3, (q15_t)0xcbd1, (q15_t)0x1ae8, (q15_t)0xcbd8, (q15_t)0x1ade, (q15_t)0xcbe0, - (q15_t)0x1ad4, (q15_t)0xcbe7, (q15_t)0x1aca, (q15_t)0xcbee, (q15_t)0x1abf, (q15_t)0xcbf5, (q15_t)0x1ab5, (q15_t)0xcbfd, - (q15_t)0x1aab, (q15_t)0xcc04, (q15_t)0x1aa1, (q15_t)0xcc0b, (q15_t)0x1a97, (q15_t)0xcc13, (q15_t)0x1a8c, (q15_t)0xcc1a, - (q15_t)0x1a82, (q15_t)0xcc21, (q15_t)0x1a78, (q15_t)0xcc29, (q15_t)0x1a6e, (q15_t)0xcc30, (q15_t)0x1a64, (q15_t)0xcc38, - (q15_t)0x1a5a, (q15_t)0xcc3f, (q15_t)0x1a4f, (q15_t)0xcc46, (q15_t)0x1a45, (q15_t)0xcc4e, (q15_t)0x1a3b, (q15_t)0xcc55, - (q15_t)0x1a31, (q15_t)0xcc5d, (q15_t)0x1a27, (q15_t)0xcc64, (q15_t)0x1a1d, (q15_t)0xcc6b, (q15_t)0x1a13, (q15_t)0xcc73, - (q15_t)0x1a08, (q15_t)0xcc7a, (q15_t)0x19fe, (q15_t)0xcc82, (q15_t)0x19f4, (q15_t)0xcc89, (q15_t)0x19ea, (q15_t)0xcc91, - (q15_t)0x19e0, (q15_t)0xcc98, (q15_t)0x19d6, (q15_t)0xcca0, (q15_t)0x19cc, (q15_t)0xcca7, (q15_t)0x19c2, (q15_t)0xccaf, - (q15_t)0x19b8, (q15_t)0xccb6, (q15_t)0x19ae, (q15_t)0xccbe, (q15_t)0x19a4, (q15_t)0xccc5, (q15_t)0x199a, (q15_t)0xcccd, - (q15_t)0x198f, (q15_t)0xccd4, (q15_t)0x1985, (q15_t)0xccdc, (q15_t)0x197b, (q15_t)0xcce3, (q15_t)0x1971, (q15_t)0xcceb, - (q15_t)0x1967, (q15_t)0xccf3, (q15_t)0x195d, (q15_t)0xccfa, (q15_t)0x1953, (q15_t)0xcd02, (q15_t)0x1949, (q15_t)0xcd09, - (q15_t)0x193f, (q15_t)0xcd11, (q15_t)0x1935, (q15_t)0xcd19, (q15_t)0x192b, (q15_t)0xcd20, (q15_t)0x1921, (q15_t)0xcd28, - (q15_t)0x1917, (q15_t)0xcd30, (q15_t)0x190d, (q15_t)0xcd37, (q15_t)0x1903, (q15_t)0xcd3f, (q15_t)0x18f9, (q15_t)0xcd46, - (q15_t)0x18ef, (q15_t)0xcd4e, (q15_t)0x18e6, (q15_t)0xcd56, (q15_t)0x18dc, (q15_t)0xcd5d, (q15_t)0x18d2, (q15_t)0xcd65, - (q15_t)0x18c8, (q15_t)0xcd6d, (q15_t)0x18be, (q15_t)0xcd75, (q15_t)0x18b4, (q15_t)0xcd7c, (q15_t)0x18aa, (q15_t)0xcd84, - (q15_t)0x18a0, (q15_t)0xcd8c, (q15_t)0x1896, (q15_t)0xcd93, (q15_t)0x188c, (q15_t)0xcd9b, (q15_t)0x1882, (q15_t)0xcda3, - (q15_t)0x1878, (q15_t)0xcdab, (q15_t)0x186f, (q15_t)0xcdb2, (q15_t)0x1865, (q15_t)0xcdba, (q15_t)0x185b, (q15_t)0xcdc2, - (q15_t)0x1851, (q15_t)0xcdca, (q15_t)0x1847, (q15_t)0xcdd2, (q15_t)0x183d, (q15_t)0xcdd9, (q15_t)0x1833, (q15_t)0xcde1, - (q15_t)0x182a, (q15_t)0xcde9, (q15_t)0x1820, (q15_t)0xcdf1, (q15_t)0x1816, (q15_t)0xcdf9, (q15_t)0x180c, (q15_t)0xce01, - (q15_t)0x1802, (q15_t)0xce08, (q15_t)0x17f8, (q15_t)0xce10, (q15_t)0x17ef, (q15_t)0xce18, (q15_t)0x17e5, (q15_t)0xce20, - (q15_t)0x17db, (q15_t)0xce28, (q15_t)0x17d1, (q15_t)0xce30, (q15_t)0x17c8, (q15_t)0xce38, (q15_t)0x17be, (q15_t)0xce40, - (q15_t)0x17b4, (q15_t)0xce47, (q15_t)0x17aa, (q15_t)0xce4f, (q15_t)0x17a0, (q15_t)0xce57, (q15_t)0x1797, (q15_t)0xce5f, - (q15_t)0x178d, (q15_t)0xce67, (q15_t)0x1783, (q15_t)0xce6f, (q15_t)0x177a, (q15_t)0xce77, (q15_t)0x1770, (q15_t)0xce7f, - (q15_t)0x1766, (q15_t)0xce87, (q15_t)0x175c, (q15_t)0xce8f, (q15_t)0x1753, (q15_t)0xce97, (q15_t)0x1749, (q15_t)0xce9f, - (q15_t)0x173f, (q15_t)0xcea7, (q15_t)0x1736, (q15_t)0xceaf, (q15_t)0x172c, (q15_t)0xceb7, (q15_t)0x1722, (q15_t)0xcebf, - (q15_t)0x1719, (q15_t)0xcec7, (q15_t)0x170f, (q15_t)0xcecf, (q15_t)0x1705, (q15_t)0xced7, (q15_t)0x16fc, (q15_t)0xcedf, - (q15_t)0x16f2, (q15_t)0xcee7, (q15_t)0x16e8, (q15_t)0xceef, (q15_t)0x16df, (q15_t)0xcef7, (q15_t)0x16d5, (q15_t)0xceff, - (q15_t)0x16cb, (q15_t)0xcf07, (q15_t)0x16c2, (q15_t)0xcf10, (q15_t)0x16b8, (q15_t)0xcf18, (q15_t)0x16af, (q15_t)0xcf20, - (q15_t)0x16a5, (q15_t)0xcf28, (q15_t)0x169b, (q15_t)0xcf30, (q15_t)0x1692, (q15_t)0xcf38, (q15_t)0x1688, (q15_t)0xcf40, - (q15_t)0x167f, (q15_t)0xcf48, (q15_t)0x1675, (q15_t)0xcf51, (q15_t)0x166c, (q15_t)0xcf59, (q15_t)0x1662, (q15_t)0xcf61, - (q15_t)0x1659, (q15_t)0xcf69, (q15_t)0x164f, (q15_t)0xcf71, (q15_t)0x1645, (q15_t)0xcf79, (q15_t)0x163c, (q15_t)0xcf82, - (q15_t)0x1632, (q15_t)0xcf8a, (q15_t)0x1629, (q15_t)0xcf92, (q15_t)0x161f, (q15_t)0xcf9a, (q15_t)0x1616, (q15_t)0xcfa3, - (q15_t)0x160c, (q15_t)0xcfab, (q15_t)0x1603, (q15_t)0xcfb3, (q15_t)0x15f9, (q15_t)0xcfbb, (q15_t)0x15f0, (q15_t)0xcfc4, - (q15_t)0x15e6, (q15_t)0xcfcc, (q15_t)0x15dd, (q15_t)0xcfd4, (q15_t)0x15d4, (q15_t)0xcfdc, (q15_t)0x15ca, (q15_t)0xcfe5, - (q15_t)0x15c1, (q15_t)0xcfed, (q15_t)0x15b7, (q15_t)0xcff5, (q15_t)0x15ae, (q15_t)0xcffe, (q15_t)0x15a4, (q15_t)0xd006, - (q15_t)0x159b, (q15_t)0xd00e, (q15_t)0x1592, (q15_t)0xd016, (q15_t)0x1588, (q15_t)0xd01f, (q15_t)0x157f, (q15_t)0xd027, - (q15_t)0x1575, (q15_t)0xd030, (q15_t)0x156c, (q15_t)0xd038, (q15_t)0x1563, (q15_t)0xd040, (q15_t)0x1559, (q15_t)0xd049, - (q15_t)0x1550, (q15_t)0xd051, (q15_t)0x1547, (q15_t)0xd059, (q15_t)0x153d, (q15_t)0xd062, (q15_t)0x1534, (q15_t)0xd06a, - (q15_t)0x152a, (q15_t)0xd073, (q15_t)0x1521, (q15_t)0xd07b, (q15_t)0x1518, (q15_t)0xd083, (q15_t)0x150e, (q15_t)0xd08c, - (q15_t)0x1505, (q15_t)0xd094, (q15_t)0x14fc, (q15_t)0xd09d, (q15_t)0x14f3, (q15_t)0xd0a5, (q15_t)0x14e9, (q15_t)0xd0ae, - (q15_t)0x14e0, (q15_t)0xd0b6, (q15_t)0x14d7, (q15_t)0xd0bf, (q15_t)0x14cd, (q15_t)0xd0c7, (q15_t)0x14c4, (q15_t)0xd0d0, - (q15_t)0x14bb, (q15_t)0xd0d8, (q15_t)0x14b2, (q15_t)0xd0e0, (q15_t)0x14a8, (q15_t)0xd0e9, (q15_t)0x149f, (q15_t)0xd0f2, - (q15_t)0x1496, (q15_t)0xd0fa, (q15_t)0x148d, (q15_t)0xd103, (q15_t)0x1483, (q15_t)0xd10b, (q15_t)0x147a, (q15_t)0xd114, - (q15_t)0x1471, (q15_t)0xd11c, (q15_t)0x1468, (q15_t)0xd125, (q15_t)0x145f, (q15_t)0xd12d, (q15_t)0x1455, (q15_t)0xd136, - (q15_t)0x144c, (q15_t)0xd13e, (q15_t)0x1443, (q15_t)0xd147, (q15_t)0x143a, (q15_t)0xd150, (q15_t)0x1431, (q15_t)0xd158, - (q15_t)0x1428, (q15_t)0xd161, (q15_t)0x141e, (q15_t)0xd169, (q15_t)0x1415, (q15_t)0xd172, (q15_t)0x140c, (q15_t)0xd17b, - (q15_t)0x1403, (q15_t)0xd183, (q15_t)0x13fa, (q15_t)0xd18c, (q15_t)0x13f1, (q15_t)0xd195, (q15_t)0x13e8, (q15_t)0xd19d, - (q15_t)0x13df, (q15_t)0xd1a6, (q15_t)0x13d5, (q15_t)0xd1af, (q15_t)0x13cc, (q15_t)0xd1b7, (q15_t)0x13c3, (q15_t)0xd1c0, - (q15_t)0x13ba, (q15_t)0xd1c9, (q15_t)0x13b1, (q15_t)0xd1d1, (q15_t)0x13a8, (q15_t)0xd1da, (q15_t)0x139f, (q15_t)0xd1e3, - (q15_t)0x1396, (q15_t)0xd1eb, (q15_t)0x138d, (q15_t)0xd1f4, (q15_t)0x1384, (q15_t)0xd1fd, (q15_t)0x137b, (q15_t)0xd206, - (q15_t)0x1372, (q15_t)0xd20e, (q15_t)0x1369, (q15_t)0xd217, (q15_t)0x1360, (q15_t)0xd220, (q15_t)0x1357, (q15_t)0xd229, - (q15_t)0x134e, (q15_t)0xd231, (q15_t)0x1345, (q15_t)0xd23a, (q15_t)0x133c, (q15_t)0xd243, (q15_t)0x1333, (q15_t)0xd24c, - (q15_t)0x132a, (q15_t)0xd255, (q15_t)0x1321, (q15_t)0xd25d, (q15_t)0x1318, (q15_t)0xd266, (q15_t)0x130f, (q15_t)0xd26f, - (q15_t)0x1306, (q15_t)0xd278, (q15_t)0x12fd, (q15_t)0xd281, (q15_t)0x12f4, (q15_t)0xd28a, (q15_t)0x12eb, (q15_t)0xd292, - (q15_t)0x12e2, (q15_t)0xd29b, (q15_t)0x12d9, (q15_t)0xd2a4, (q15_t)0x12d1, (q15_t)0xd2ad, (q15_t)0x12c8, (q15_t)0xd2b6, - (q15_t)0x12bf, (q15_t)0xd2bf, (q15_t)0x12b6, (q15_t)0xd2c8, (q15_t)0x12ad, (q15_t)0xd2d1, (q15_t)0x12a4, (q15_t)0xd2d9, - (q15_t)0x129b, (q15_t)0xd2e2, (q15_t)0x1292, (q15_t)0xd2eb, (q15_t)0x128a, (q15_t)0xd2f4, (q15_t)0x1281, (q15_t)0xd2fd, - (q15_t)0x1278, (q15_t)0xd306, (q15_t)0x126f, (q15_t)0xd30f, (q15_t)0x1266, (q15_t)0xd318, (q15_t)0x125d, (q15_t)0xd321, - (q15_t)0x1255, (q15_t)0xd32a, (q15_t)0x124c, (q15_t)0xd333, (q15_t)0x1243, (q15_t)0xd33c, (q15_t)0x123a, (q15_t)0xd345, - (q15_t)0x1231, (q15_t)0xd34e, (q15_t)0x1229, (q15_t)0xd357, (q15_t)0x1220, (q15_t)0xd360, (q15_t)0x1217, (q15_t)0xd369, - (q15_t)0x120e, (q15_t)0xd372, (q15_t)0x1206, (q15_t)0xd37b, (q15_t)0x11fd, (q15_t)0xd384, (q15_t)0x11f4, (q15_t)0xd38d, - (q15_t)0x11eb, (q15_t)0xd396, (q15_t)0x11e3, (q15_t)0xd39f, (q15_t)0x11da, (q15_t)0xd3a8, (q15_t)0x11d1, (q15_t)0xd3b1, - (q15_t)0x11c9, (q15_t)0xd3ba, (q15_t)0x11c0, (q15_t)0xd3c3, (q15_t)0x11b7, (q15_t)0xd3cc, (q15_t)0x11af, (q15_t)0xd3d5, - (q15_t)0x11a6, (q15_t)0xd3df, (q15_t)0x119d, (q15_t)0xd3e8, (q15_t)0x1195, (q15_t)0xd3f1, (q15_t)0x118c, (q15_t)0xd3fa, - (q15_t)0x1183, (q15_t)0xd403, (q15_t)0x117b, (q15_t)0xd40c, (q15_t)0x1172, (q15_t)0xd415, (q15_t)0x1169, (q15_t)0xd41e, - (q15_t)0x1161, (q15_t)0xd428, (q15_t)0x1158, (q15_t)0xd431, (q15_t)0x1150, (q15_t)0xd43a, (q15_t)0x1147, (q15_t)0xd443, - (q15_t)0x113e, (q15_t)0xd44c, (q15_t)0x1136, (q15_t)0xd455, (q15_t)0x112d, (q15_t)0xd45f, (q15_t)0x1125, (q15_t)0xd468, - (q15_t)0x111c, (q15_t)0xd471, (q15_t)0x1114, (q15_t)0xd47a, (q15_t)0x110b, (q15_t)0xd483, (q15_t)0x1103, (q15_t)0xd48d, - (q15_t)0x10fa, (q15_t)0xd496, (q15_t)0x10f2, (q15_t)0xd49f, (q15_t)0x10e9, (q15_t)0xd4a8, (q15_t)0x10e0, (q15_t)0xd4b2, - (q15_t)0x10d8, (q15_t)0xd4bb, (q15_t)0x10d0, (q15_t)0xd4c4, (q15_t)0x10c7, (q15_t)0xd4cd, (q15_t)0x10bf, (q15_t)0xd4d7, - (q15_t)0x10b6, (q15_t)0xd4e0, (q15_t)0x10ae, (q15_t)0xd4e9, (q15_t)0x10a5, (q15_t)0xd4f3, (q15_t)0x109d, (q15_t)0xd4fc, - (q15_t)0x1094, (q15_t)0xd505, (q15_t)0x108c, (q15_t)0xd50e, (q15_t)0x1083, (q15_t)0xd518, (q15_t)0x107b, (q15_t)0xd521, - (q15_t)0x1073, (q15_t)0xd52a, (q15_t)0x106a, (q15_t)0xd534, (q15_t)0x1062, (q15_t)0xd53d, (q15_t)0x1059, (q15_t)0xd547, - (q15_t)0x1051, (q15_t)0xd550, (q15_t)0x1049, (q15_t)0xd559, (q15_t)0x1040, (q15_t)0xd563, (q15_t)0x1038, (q15_t)0xd56c, - (q15_t)0x1030, (q15_t)0xd575, (q15_t)0x1027, (q15_t)0xd57f, (q15_t)0x101f, (q15_t)0xd588, (q15_t)0x1016, (q15_t)0xd592, - (q15_t)0x100e, (q15_t)0xd59b, (q15_t)0x1006, (q15_t)0xd5a4, (q15_t)0xffe, (q15_t)0xd5ae, (q15_t)0xff5, (q15_t)0xd5b7, - (q15_t)0xfed, (q15_t)0xd5c1, (q15_t)0xfe5, (q15_t)0xd5ca, (q15_t)0xfdc, (q15_t)0xd5d4, (q15_t)0xfd4, (q15_t)0xd5dd, - (q15_t)0xfcc, (q15_t)0xd5e6, (q15_t)0xfc4, (q15_t)0xd5f0, (q15_t)0xfbb, (q15_t)0xd5f9, (q15_t)0xfb3, (q15_t)0xd603, - (q15_t)0xfab, (q15_t)0xd60c, (q15_t)0xfa3, (q15_t)0xd616, (q15_t)0xf9a, (q15_t)0xd61f, (q15_t)0xf92, (q15_t)0xd629, - (q15_t)0xf8a, (q15_t)0xd632, (q15_t)0xf82, (q15_t)0xd63c, (q15_t)0xf79, (q15_t)0xd645, (q15_t)0xf71, (q15_t)0xd64f, - (q15_t)0xf69, (q15_t)0xd659, (q15_t)0xf61, (q15_t)0xd662, (q15_t)0xf59, (q15_t)0xd66c, (q15_t)0xf51, (q15_t)0xd675, - (q15_t)0xf48, (q15_t)0xd67f, (q15_t)0xf40, (q15_t)0xd688, (q15_t)0xf38, (q15_t)0xd692, (q15_t)0xf30, (q15_t)0xd69b, - (q15_t)0xf28, (q15_t)0xd6a5, (q15_t)0xf20, (q15_t)0xd6af, (q15_t)0xf18, (q15_t)0xd6b8, (q15_t)0xf10, (q15_t)0xd6c2, - (q15_t)0xf07, (q15_t)0xd6cb, (q15_t)0xeff, (q15_t)0xd6d5, (q15_t)0xef7, (q15_t)0xd6df, (q15_t)0xeef, (q15_t)0xd6e8, - (q15_t)0xee7, (q15_t)0xd6f2, (q15_t)0xedf, (q15_t)0xd6fc, (q15_t)0xed7, (q15_t)0xd705, (q15_t)0xecf, (q15_t)0xd70f, - (q15_t)0xec7, (q15_t)0xd719, (q15_t)0xebf, (q15_t)0xd722, (q15_t)0xeb7, (q15_t)0xd72c, (q15_t)0xeaf, (q15_t)0xd736, - (q15_t)0xea7, (q15_t)0xd73f, (q15_t)0xe9f, (q15_t)0xd749, (q15_t)0xe97, (q15_t)0xd753, (q15_t)0xe8f, (q15_t)0xd75c, - (q15_t)0xe87, (q15_t)0xd766, (q15_t)0xe7f, (q15_t)0xd770, (q15_t)0xe77, (q15_t)0xd77a, (q15_t)0xe6f, (q15_t)0xd783, - (q15_t)0xe67, (q15_t)0xd78d, (q15_t)0xe5f, (q15_t)0xd797, (q15_t)0xe57, (q15_t)0xd7a0, (q15_t)0xe4f, (q15_t)0xd7aa, - (q15_t)0xe47, (q15_t)0xd7b4, (q15_t)0xe40, (q15_t)0xd7be, (q15_t)0xe38, (q15_t)0xd7c8, (q15_t)0xe30, (q15_t)0xd7d1, - (q15_t)0xe28, (q15_t)0xd7db, (q15_t)0xe20, (q15_t)0xd7e5, (q15_t)0xe18, (q15_t)0xd7ef, (q15_t)0xe10, (q15_t)0xd7f8, - (q15_t)0xe08, (q15_t)0xd802, (q15_t)0xe01, (q15_t)0xd80c, (q15_t)0xdf9, (q15_t)0xd816, (q15_t)0xdf1, (q15_t)0xd820, - (q15_t)0xde9, (q15_t)0xd82a, (q15_t)0xde1, (q15_t)0xd833, (q15_t)0xdd9, (q15_t)0xd83d, (q15_t)0xdd2, (q15_t)0xd847, - (q15_t)0xdca, (q15_t)0xd851, (q15_t)0xdc2, (q15_t)0xd85b, (q15_t)0xdba, (q15_t)0xd865, (q15_t)0xdb2, (q15_t)0xd86f, - (q15_t)0xdab, (q15_t)0xd878, (q15_t)0xda3, (q15_t)0xd882, (q15_t)0xd9b, (q15_t)0xd88c, (q15_t)0xd93, (q15_t)0xd896, - (q15_t)0xd8c, (q15_t)0xd8a0, (q15_t)0xd84, (q15_t)0xd8aa, (q15_t)0xd7c, (q15_t)0xd8b4, (q15_t)0xd75, (q15_t)0xd8be, - (q15_t)0xd6d, (q15_t)0xd8c8, (q15_t)0xd65, (q15_t)0xd8d2, (q15_t)0xd5d, (q15_t)0xd8dc, (q15_t)0xd56, (q15_t)0xd8e6, - (q15_t)0xd4e, (q15_t)0xd8ef, (q15_t)0xd46, (q15_t)0xd8f9, (q15_t)0xd3f, (q15_t)0xd903, (q15_t)0xd37, (q15_t)0xd90d, - (q15_t)0xd30, (q15_t)0xd917, (q15_t)0xd28, (q15_t)0xd921, (q15_t)0xd20, (q15_t)0xd92b, (q15_t)0xd19, (q15_t)0xd935, - (q15_t)0xd11, (q15_t)0xd93f, (q15_t)0xd09, (q15_t)0xd949, (q15_t)0xd02, (q15_t)0xd953, (q15_t)0xcfa, (q15_t)0xd95d, - (q15_t)0xcf3, (q15_t)0xd967, (q15_t)0xceb, (q15_t)0xd971, (q15_t)0xce3, (q15_t)0xd97b, (q15_t)0xcdc, (q15_t)0xd985, - (q15_t)0xcd4, (q15_t)0xd98f, (q15_t)0xccd, (q15_t)0xd99a, (q15_t)0xcc5, (q15_t)0xd9a4, (q15_t)0xcbe, (q15_t)0xd9ae, - (q15_t)0xcb6, (q15_t)0xd9b8, (q15_t)0xcaf, (q15_t)0xd9c2, (q15_t)0xca7, (q15_t)0xd9cc, (q15_t)0xca0, (q15_t)0xd9d6, - (q15_t)0xc98, (q15_t)0xd9e0, (q15_t)0xc91, (q15_t)0xd9ea, (q15_t)0xc89, (q15_t)0xd9f4, (q15_t)0xc82, (q15_t)0xd9fe, - (q15_t)0xc7a, (q15_t)0xda08, (q15_t)0xc73, (q15_t)0xda13, (q15_t)0xc6b, (q15_t)0xda1d, (q15_t)0xc64, (q15_t)0xda27, - (q15_t)0xc5d, (q15_t)0xda31, (q15_t)0xc55, (q15_t)0xda3b, (q15_t)0xc4e, (q15_t)0xda45, (q15_t)0xc46, (q15_t)0xda4f, - (q15_t)0xc3f, (q15_t)0xda5a, (q15_t)0xc38, (q15_t)0xda64, (q15_t)0xc30, (q15_t)0xda6e, (q15_t)0xc29, (q15_t)0xda78, - (q15_t)0xc21, (q15_t)0xda82, (q15_t)0xc1a, (q15_t)0xda8c, (q15_t)0xc13, (q15_t)0xda97, (q15_t)0xc0b, (q15_t)0xdaa1, - (q15_t)0xc04, (q15_t)0xdaab, (q15_t)0xbfd, (q15_t)0xdab5, (q15_t)0xbf5, (q15_t)0xdabf, (q15_t)0xbee, (q15_t)0xdaca, - (q15_t)0xbe7, (q15_t)0xdad4, (q15_t)0xbe0, (q15_t)0xdade, (q15_t)0xbd8, (q15_t)0xdae8, (q15_t)0xbd1, (q15_t)0xdaf3, - (q15_t)0xbca, (q15_t)0xdafd, (q15_t)0xbc2, (q15_t)0xdb07, (q15_t)0xbbb, (q15_t)0xdb11, (q15_t)0xbb4, (q15_t)0xdb1c, - (q15_t)0xbad, (q15_t)0xdb26, (q15_t)0xba5, (q15_t)0xdb30, (q15_t)0xb9e, (q15_t)0xdb3b, (q15_t)0xb97, (q15_t)0xdb45, - (q15_t)0xb90, (q15_t)0xdb4f, (q15_t)0xb89, (q15_t)0xdb59, (q15_t)0xb81, (q15_t)0xdb64, (q15_t)0xb7a, (q15_t)0xdb6e, - (q15_t)0xb73, (q15_t)0xdb78, (q15_t)0xb6c, (q15_t)0xdb83, (q15_t)0xb65, (q15_t)0xdb8d, (q15_t)0xb5e, (q15_t)0xdb97, - (q15_t)0xb56, (q15_t)0xdba2, (q15_t)0xb4f, (q15_t)0xdbac, (q15_t)0xb48, (q15_t)0xdbb6, (q15_t)0xb41, (q15_t)0xdbc1, - (q15_t)0xb3a, (q15_t)0xdbcb, (q15_t)0xb33, (q15_t)0xdbd5, (q15_t)0xb2c, (q15_t)0xdbe0, (q15_t)0xb25, (q15_t)0xdbea, - (q15_t)0xb1e, (q15_t)0xdbf5, (q15_t)0xb16, (q15_t)0xdbff, (q15_t)0xb0f, (q15_t)0xdc09, (q15_t)0xb08, (q15_t)0xdc14, - (q15_t)0xb01, (q15_t)0xdc1e, (q15_t)0xafa, (q15_t)0xdc29, (q15_t)0xaf3, (q15_t)0xdc33, (q15_t)0xaec, (q15_t)0xdc3d, - (q15_t)0xae5, (q15_t)0xdc48, (q15_t)0xade, (q15_t)0xdc52, (q15_t)0xad7, (q15_t)0xdc5d, (q15_t)0xad0, (q15_t)0xdc67, - (q15_t)0xac9, (q15_t)0xdc72, (q15_t)0xac2, (q15_t)0xdc7c, (q15_t)0xabb, (q15_t)0xdc86, (q15_t)0xab4, (q15_t)0xdc91, - (q15_t)0xaad, (q15_t)0xdc9b, (q15_t)0xaa6, (q15_t)0xdca6, (q15_t)0xa9f, (q15_t)0xdcb0, (q15_t)0xa99, (q15_t)0xdcbb, - (q15_t)0xa92, (q15_t)0xdcc5, (q15_t)0xa8b, (q15_t)0xdcd0, (q15_t)0xa84, (q15_t)0xdcda, (q15_t)0xa7d, (q15_t)0xdce5, - (q15_t)0xa76, (q15_t)0xdcef, (q15_t)0xa6f, (q15_t)0xdcfa, (q15_t)0xa68, (q15_t)0xdd04, (q15_t)0xa61, (q15_t)0xdd0f, - (q15_t)0xa5b, (q15_t)0xdd19, (q15_t)0xa54, (q15_t)0xdd24, (q15_t)0xa4d, (q15_t)0xdd2e, (q15_t)0xa46, (q15_t)0xdd39, - (q15_t)0xa3f, (q15_t)0xdd44, (q15_t)0xa38, (q15_t)0xdd4e, (q15_t)0xa32, (q15_t)0xdd59, (q15_t)0xa2b, (q15_t)0xdd63, - (q15_t)0xa24, (q15_t)0xdd6e, (q15_t)0xa1d, (q15_t)0xdd78, (q15_t)0xa16, (q15_t)0xdd83, (q15_t)0xa10, (q15_t)0xdd8e, - (q15_t)0xa09, (q15_t)0xdd98, (q15_t)0xa02, (q15_t)0xdda3, (q15_t)0x9fb, (q15_t)0xddad, (q15_t)0x9f5, (q15_t)0xddb8, - (q15_t)0x9ee, (q15_t)0xddc3, (q15_t)0x9e7, (q15_t)0xddcd, (q15_t)0x9e0, (q15_t)0xddd8, (q15_t)0x9da, (q15_t)0xdde2, - (q15_t)0x9d3, (q15_t)0xdded, (q15_t)0x9cc, (q15_t)0xddf8, (q15_t)0x9c6, (q15_t)0xde02, (q15_t)0x9bf, (q15_t)0xde0d, - (q15_t)0x9b8, (q15_t)0xde18, (q15_t)0x9b2, (q15_t)0xde22, (q15_t)0x9ab, (q15_t)0xde2d, (q15_t)0x9a4, (q15_t)0xde38, - (q15_t)0x99e, (q15_t)0xde42, (q15_t)0x997, (q15_t)0xde4d, (q15_t)0x991, (q15_t)0xde58, (q15_t)0x98a, (q15_t)0xde62, - (q15_t)0x983, (q15_t)0xde6d, (q15_t)0x97d, (q15_t)0xde78, (q15_t)0x976, (q15_t)0xde83, (q15_t)0x970, (q15_t)0xde8d, - (q15_t)0x969, (q15_t)0xde98, (q15_t)0x963, (q15_t)0xdea3, (q15_t)0x95c, (q15_t)0xdead, (q15_t)0x955, (q15_t)0xdeb8, - (q15_t)0x94f, (q15_t)0xdec3, (q15_t)0x948, (q15_t)0xdece, (q15_t)0x942, (q15_t)0xded8, (q15_t)0x93b, (q15_t)0xdee3, - (q15_t)0x935, (q15_t)0xdeee, (q15_t)0x92e, (q15_t)0xdef9, (q15_t)0x928, (q15_t)0xdf03, (q15_t)0x921, (q15_t)0xdf0e, - (q15_t)0x91b, (q15_t)0xdf19, (q15_t)0x915, (q15_t)0xdf24, (q15_t)0x90e, (q15_t)0xdf2f, (q15_t)0x908, (q15_t)0xdf39, - (q15_t)0x901, (q15_t)0xdf44, (q15_t)0x8fb, (q15_t)0xdf4f, (q15_t)0x8f4, (q15_t)0xdf5a, (q15_t)0x8ee, (q15_t)0xdf65, - (q15_t)0x8e8, (q15_t)0xdf6f, (q15_t)0x8e1, (q15_t)0xdf7a, (q15_t)0x8db, (q15_t)0xdf85, (q15_t)0x8d4, (q15_t)0xdf90, - (q15_t)0x8ce, (q15_t)0xdf9b, (q15_t)0x8c8, (q15_t)0xdfa5, (q15_t)0x8c1, (q15_t)0xdfb0, (q15_t)0x8bb, (q15_t)0xdfbb, - (q15_t)0x8b5, (q15_t)0xdfc6, (q15_t)0x8ae, (q15_t)0xdfd1, (q15_t)0x8a8, (q15_t)0xdfdc, (q15_t)0x8a2, (q15_t)0xdfe7, - (q15_t)0x89b, (q15_t)0xdff1, (q15_t)0x895, (q15_t)0xdffc, (q15_t)0x88f, (q15_t)0xe007, (q15_t)0x889, (q15_t)0xe012, - (q15_t)0x882, (q15_t)0xe01d, (q15_t)0x87c, (q15_t)0xe028, (q15_t)0x876, (q15_t)0xe033, (q15_t)0x870, (q15_t)0xe03e, - (q15_t)0x869, (q15_t)0xe049, (q15_t)0x863, (q15_t)0xe054, (q15_t)0x85d, (q15_t)0xe05e, (q15_t)0x857, (q15_t)0xe069, - (q15_t)0x850, (q15_t)0xe074, (q15_t)0x84a, (q15_t)0xe07f, (q15_t)0x844, (q15_t)0xe08a, (q15_t)0x83e, (q15_t)0xe095, - (q15_t)0x838, (q15_t)0xe0a0, (q15_t)0x832, (q15_t)0xe0ab, (q15_t)0x82b, (q15_t)0xe0b6, (q15_t)0x825, (q15_t)0xe0c1, - (q15_t)0x81f, (q15_t)0xe0cc, (q15_t)0x819, (q15_t)0xe0d7, (q15_t)0x813, (q15_t)0xe0e2, (q15_t)0x80d, (q15_t)0xe0ed, - (q15_t)0x807, (q15_t)0xe0f8, (q15_t)0x801, (q15_t)0xe103, (q15_t)0x7fb, (q15_t)0xe10e, (q15_t)0x7f5, (q15_t)0xe119, - (q15_t)0x7ee, (q15_t)0xe124, (q15_t)0x7e8, (q15_t)0xe12f, (q15_t)0x7e2, (q15_t)0xe13a, (q15_t)0x7dc, (q15_t)0xe145, - (q15_t)0x7d6, (q15_t)0xe150, (q15_t)0x7d0, (q15_t)0xe15b, (q15_t)0x7ca, (q15_t)0xe166, (q15_t)0x7c4, (q15_t)0xe171, - (q15_t)0x7be, (q15_t)0xe17c, (q15_t)0x7b8, (q15_t)0xe187, (q15_t)0x7b2, (q15_t)0xe192, (q15_t)0x7ac, (q15_t)0xe19d, - (q15_t)0x7a6, (q15_t)0xe1a8, (q15_t)0x7a0, (q15_t)0xe1b3, (q15_t)0x79a, (q15_t)0xe1be, (q15_t)0x795, (q15_t)0xe1ca, - (q15_t)0x78f, (q15_t)0xe1d5, (q15_t)0x789, (q15_t)0xe1e0, (q15_t)0x783, (q15_t)0xe1eb, (q15_t)0x77d, (q15_t)0xe1f6, - (q15_t)0x777, (q15_t)0xe201, (q15_t)0x771, (q15_t)0xe20c, (q15_t)0x76b, (q15_t)0xe217, (q15_t)0x765, (q15_t)0xe222, - (q15_t)0x75f, (q15_t)0xe22d, (q15_t)0x75a, (q15_t)0xe239, (q15_t)0x754, (q15_t)0xe244, (q15_t)0x74e, (q15_t)0xe24f, - (q15_t)0x748, (q15_t)0xe25a, (q15_t)0x742, (q15_t)0xe265, (q15_t)0x73d, (q15_t)0xe270, (q15_t)0x737, (q15_t)0xe27b, - (q15_t)0x731, (q15_t)0xe287, (q15_t)0x72b, (q15_t)0xe292, (q15_t)0x725, (q15_t)0xe29d, (q15_t)0x720, (q15_t)0xe2a8, - (q15_t)0x71a, (q15_t)0xe2b3, (q15_t)0x714, (q15_t)0xe2be, (q15_t)0x70e, (q15_t)0xe2ca, (q15_t)0x709, (q15_t)0xe2d5, - (q15_t)0x703, (q15_t)0xe2e0, (q15_t)0x6fd, (q15_t)0xe2eb, (q15_t)0x6f7, (q15_t)0xe2f6, (q15_t)0x6f2, (q15_t)0xe301, - (q15_t)0x6ec, (q15_t)0xe30d, (q15_t)0x6e6, (q15_t)0xe318, (q15_t)0x6e1, (q15_t)0xe323, (q15_t)0x6db, (q15_t)0xe32e, - (q15_t)0x6d5, (q15_t)0xe33a, (q15_t)0x6d0, (q15_t)0xe345, (q15_t)0x6ca, (q15_t)0xe350, (q15_t)0x6c5, (q15_t)0xe35b, - (q15_t)0x6bf, (q15_t)0xe367, (q15_t)0x6b9, (q15_t)0xe372, (q15_t)0x6b4, (q15_t)0xe37d, (q15_t)0x6ae, (q15_t)0xe388, - (q15_t)0x6a8, (q15_t)0xe394, (q15_t)0x6a3, (q15_t)0xe39f, (q15_t)0x69d, (q15_t)0xe3aa, (q15_t)0x698, (q15_t)0xe3b5, - (q15_t)0x692, (q15_t)0xe3c1, (q15_t)0x68d, (q15_t)0xe3cc, (q15_t)0x687, (q15_t)0xe3d7, (q15_t)0x682, (q15_t)0xe3e2, - (q15_t)0x67c, (q15_t)0xe3ee, (q15_t)0x677, (q15_t)0xe3f9, (q15_t)0x671, (q15_t)0xe404, (q15_t)0x66c, (q15_t)0xe410, - (q15_t)0x666, (q15_t)0xe41b, (q15_t)0x661, (q15_t)0xe426, (q15_t)0x65b, (q15_t)0xe432, (q15_t)0x656, (q15_t)0xe43d, - (q15_t)0x650, (q15_t)0xe448, (q15_t)0x64b, (q15_t)0xe454, (q15_t)0x645, (q15_t)0xe45f, (q15_t)0x640, (q15_t)0xe46a, - (q15_t)0x63b, (q15_t)0xe476, (q15_t)0x635, (q15_t)0xe481, (q15_t)0x630, (q15_t)0xe48c, (q15_t)0x62a, (q15_t)0xe498, - (q15_t)0x625, (q15_t)0xe4a3, (q15_t)0x620, (q15_t)0xe4ae, (q15_t)0x61a, (q15_t)0xe4ba, (q15_t)0x615, (q15_t)0xe4c5, - (q15_t)0x610, (q15_t)0xe4d0, (q15_t)0x60a, (q15_t)0xe4dc, (q15_t)0x605, (q15_t)0xe4e7, (q15_t)0x600, (q15_t)0xe4f3, - (q15_t)0x5fa, (q15_t)0xe4fe, (q15_t)0x5f5, (q15_t)0xe509, (q15_t)0x5f0, (q15_t)0xe515, (q15_t)0x5ea, (q15_t)0xe520, - (q15_t)0x5e5, (q15_t)0xe52c, (q15_t)0x5e0, (q15_t)0xe537, (q15_t)0x5db, (q15_t)0xe542, (q15_t)0x5d5, (q15_t)0xe54e, - (q15_t)0x5d0, (q15_t)0xe559, (q15_t)0x5cb, (q15_t)0xe565, (q15_t)0x5c6, (q15_t)0xe570, (q15_t)0x5c1, (q15_t)0xe57c, - (q15_t)0x5bb, (q15_t)0xe587, (q15_t)0x5b6, (q15_t)0xe592, (q15_t)0x5b1, (q15_t)0xe59e, (q15_t)0x5ac, (q15_t)0xe5a9, - (q15_t)0x5a7, (q15_t)0xe5b5, (q15_t)0x5a1, (q15_t)0xe5c0, (q15_t)0x59c, (q15_t)0xe5cc, (q15_t)0x597, (q15_t)0xe5d7, - (q15_t)0x592, (q15_t)0xe5e3, (q15_t)0x58d, (q15_t)0xe5ee, (q15_t)0x588, (q15_t)0xe5fa, (q15_t)0x583, (q15_t)0xe605, - (q15_t)0x57e, (q15_t)0xe611, (q15_t)0x578, (q15_t)0xe61c, (q15_t)0x573, (q15_t)0xe628, (q15_t)0x56e, (q15_t)0xe633, - (q15_t)0x569, (q15_t)0xe63f, (q15_t)0x564, (q15_t)0xe64a, (q15_t)0x55f, (q15_t)0xe656, (q15_t)0x55a, (q15_t)0xe661, - (q15_t)0x555, (q15_t)0xe66d, (q15_t)0x550, (q15_t)0xe678, (q15_t)0x54b, (q15_t)0xe684, (q15_t)0x546, (q15_t)0xe68f, - (q15_t)0x541, (q15_t)0xe69b, (q15_t)0x53c, (q15_t)0xe6a6, (q15_t)0x537, (q15_t)0xe6b2, (q15_t)0x532, (q15_t)0xe6bd, - (q15_t)0x52d, (q15_t)0xe6c9, (q15_t)0x528, (q15_t)0xe6d4, (q15_t)0x523, (q15_t)0xe6e0, (q15_t)0x51e, (q15_t)0xe6ec, - (q15_t)0x51a, (q15_t)0xe6f7, (q15_t)0x515, (q15_t)0xe703, (q15_t)0x510, (q15_t)0xe70e, (q15_t)0x50b, (q15_t)0xe71a, - (q15_t)0x506, (q15_t)0xe725, (q15_t)0x501, (q15_t)0xe731, (q15_t)0x4fc, (q15_t)0xe73d, (q15_t)0x4f7, (q15_t)0xe748, - (q15_t)0x4f2, (q15_t)0xe754, (q15_t)0x4ee, (q15_t)0xe75f, (q15_t)0x4e9, (q15_t)0xe76b, (q15_t)0x4e4, (q15_t)0xe777, - (q15_t)0x4df, (q15_t)0xe782, (q15_t)0x4da, (q15_t)0xe78e, (q15_t)0x4d6, (q15_t)0xe799, (q15_t)0x4d1, (q15_t)0xe7a5, - (q15_t)0x4cc, (q15_t)0xe7b1, (q15_t)0x4c7, (q15_t)0xe7bc, (q15_t)0x4c2, (q15_t)0xe7c8, (q15_t)0x4be, (q15_t)0xe7d3, - (q15_t)0x4b9, (q15_t)0xe7df, (q15_t)0x4b4, (q15_t)0xe7eb, (q15_t)0x4b0, (q15_t)0xe7f6, (q15_t)0x4ab, (q15_t)0xe802, - (q15_t)0x4a6, (q15_t)0xe80e, (q15_t)0x4a1, (q15_t)0xe819, (q15_t)0x49d, (q15_t)0xe825, (q15_t)0x498, (q15_t)0xe831, - (q15_t)0x493, (q15_t)0xe83c, (q15_t)0x48f, (q15_t)0xe848, (q15_t)0x48a, (q15_t)0xe854, (q15_t)0x485, (q15_t)0xe85f, - (q15_t)0x481, (q15_t)0xe86b, (q15_t)0x47c, (q15_t)0xe877, (q15_t)0x478, (q15_t)0xe882, (q15_t)0x473, (q15_t)0xe88e, - (q15_t)0x46e, (q15_t)0xe89a, (q15_t)0x46a, (q15_t)0xe8a5, (q15_t)0x465, (q15_t)0xe8b1, (q15_t)0x461, (q15_t)0xe8bd, - (q15_t)0x45c, (q15_t)0xe8c9, (q15_t)0x457, (q15_t)0xe8d4, (q15_t)0x453, (q15_t)0xe8e0, (q15_t)0x44e, (q15_t)0xe8ec, - (q15_t)0x44a, (q15_t)0xe8f7, (q15_t)0x445, (q15_t)0xe903, (q15_t)0x441, (q15_t)0xe90f, (q15_t)0x43c, (q15_t)0xe91b, - (q15_t)0x438, (q15_t)0xe926, (q15_t)0x433, (q15_t)0xe932, (q15_t)0x42f, (q15_t)0xe93e, (q15_t)0x42a, (q15_t)0xe94a, - (q15_t)0x426, (q15_t)0xe955, (q15_t)0x422, (q15_t)0xe961, (q15_t)0x41d, (q15_t)0xe96d, (q15_t)0x419, (q15_t)0xe979, - (q15_t)0x414, (q15_t)0xe984, (q15_t)0x410, (q15_t)0xe990, (q15_t)0x40b, (q15_t)0xe99c, (q15_t)0x407, (q15_t)0xe9a8, - (q15_t)0x403, (q15_t)0xe9b4, (q15_t)0x3fe, (q15_t)0xe9bf, (q15_t)0x3fa, (q15_t)0xe9cb, (q15_t)0x3f6, (q15_t)0xe9d7, - (q15_t)0x3f1, (q15_t)0xe9e3, (q15_t)0x3ed, (q15_t)0xe9ee, (q15_t)0x3e9, (q15_t)0xe9fa, (q15_t)0x3e4, (q15_t)0xea06, - (q15_t)0x3e0, (q15_t)0xea12, (q15_t)0x3dc, (q15_t)0xea1e, (q15_t)0x3d7, (q15_t)0xea29, (q15_t)0x3d3, (q15_t)0xea35, - (q15_t)0x3cf, (q15_t)0xea41, (q15_t)0x3ca, (q15_t)0xea4d, (q15_t)0x3c6, (q15_t)0xea59, (q15_t)0x3c2, (q15_t)0xea65, - (q15_t)0x3be, (q15_t)0xea70, (q15_t)0x3ba, (q15_t)0xea7c, (q15_t)0x3b5, (q15_t)0xea88, (q15_t)0x3b1, (q15_t)0xea94, - (q15_t)0x3ad, (q15_t)0xeaa0, (q15_t)0x3a9, (q15_t)0xeaac, (q15_t)0x3a5, (q15_t)0xeab7, (q15_t)0x3a0, (q15_t)0xeac3, - (q15_t)0x39c, (q15_t)0xeacf, (q15_t)0x398, (q15_t)0xeadb, (q15_t)0x394, (q15_t)0xeae7, (q15_t)0x390, (q15_t)0xeaf3, - (q15_t)0x38c, (q15_t)0xeaff, (q15_t)0x387, (q15_t)0xeb0a, (q15_t)0x383, (q15_t)0xeb16, (q15_t)0x37f, (q15_t)0xeb22, - (q15_t)0x37b, (q15_t)0xeb2e, (q15_t)0x377, (q15_t)0xeb3a, (q15_t)0x373, (q15_t)0xeb46, (q15_t)0x36f, (q15_t)0xeb52, - (q15_t)0x36b, (q15_t)0xeb5e, (q15_t)0x367, (q15_t)0xeb6a, (q15_t)0x363, (q15_t)0xeb75, (q15_t)0x35f, (q15_t)0xeb81, - (q15_t)0x35b, (q15_t)0xeb8d, (q15_t)0x357, (q15_t)0xeb99, (q15_t)0x353, (q15_t)0xeba5, (q15_t)0x34f, (q15_t)0xebb1, - (q15_t)0x34b, (q15_t)0xebbd, (q15_t)0x347, (q15_t)0xebc9, (q15_t)0x343, (q15_t)0xebd5, (q15_t)0x33f, (q15_t)0xebe1, - (q15_t)0x33b, (q15_t)0xebed, (q15_t)0x337, (q15_t)0xebf9, (q15_t)0x333, (q15_t)0xec05, (q15_t)0x32f, (q15_t)0xec10, - (q15_t)0x32b, (q15_t)0xec1c, (q15_t)0x327, (q15_t)0xec28, (q15_t)0x323, (q15_t)0xec34, (q15_t)0x320, (q15_t)0xec40, - (q15_t)0x31c, (q15_t)0xec4c, (q15_t)0x318, (q15_t)0xec58, (q15_t)0x314, (q15_t)0xec64, (q15_t)0x310, (q15_t)0xec70, - (q15_t)0x30c, (q15_t)0xec7c, (q15_t)0x308, (q15_t)0xec88, (q15_t)0x305, (q15_t)0xec94, (q15_t)0x301, (q15_t)0xeca0, - (q15_t)0x2fd, (q15_t)0xecac, (q15_t)0x2f9, (q15_t)0xecb8, (q15_t)0x2f5, (q15_t)0xecc4, (q15_t)0x2f2, (q15_t)0xecd0, - (q15_t)0x2ee, (q15_t)0xecdc, (q15_t)0x2ea, (q15_t)0xece8, (q15_t)0x2e6, (q15_t)0xecf4, (q15_t)0x2e3, (q15_t)0xed00, - (q15_t)0x2df, (q15_t)0xed0c, (q15_t)0x2db, (q15_t)0xed18, (q15_t)0x2d8, (q15_t)0xed24, (q15_t)0x2d4, (q15_t)0xed30, - (q15_t)0x2d0, (q15_t)0xed3c, (q15_t)0x2cc, (q15_t)0xed48, (q15_t)0x2c9, (q15_t)0xed54, (q15_t)0x2c5, (q15_t)0xed60, - (q15_t)0x2c1, (q15_t)0xed6c, (q15_t)0x2be, (q15_t)0xed78, (q15_t)0x2ba, (q15_t)0xed84, (q15_t)0x2b7, (q15_t)0xed90, - (q15_t)0x2b3, (q15_t)0xed9c, (q15_t)0x2af, (q15_t)0xeda8, (q15_t)0x2ac, (q15_t)0xedb4, (q15_t)0x2a8, (q15_t)0xedc0, - (q15_t)0x2a5, (q15_t)0xedcc, (q15_t)0x2a1, (q15_t)0xedd8, (q15_t)0x29d, (q15_t)0xede4, (q15_t)0x29a, (q15_t)0xedf0, - (q15_t)0x296, (q15_t)0xedfc, (q15_t)0x293, (q15_t)0xee09, (q15_t)0x28f, (q15_t)0xee15, (q15_t)0x28c, (q15_t)0xee21, - (q15_t)0x288, (q15_t)0xee2d, (q15_t)0x285, (q15_t)0xee39, (q15_t)0x281, (q15_t)0xee45, (q15_t)0x27e, (q15_t)0xee51, - (q15_t)0x27a, (q15_t)0xee5d, (q15_t)0x277, (q15_t)0xee69, (q15_t)0x273, (q15_t)0xee75, (q15_t)0x270, (q15_t)0xee81, - (q15_t)0x26d, (q15_t)0xee8d, (q15_t)0x269, (q15_t)0xee99, (q15_t)0x266, (q15_t)0xeea6, (q15_t)0x262, (q15_t)0xeeb2, - (q15_t)0x25f, (q15_t)0xeebe, (q15_t)0x25c, (q15_t)0xeeca, (q15_t)0x258, (q15_t)0xeed6, (q15_t)0x255, (q15_t)0xeee2, - (q15_t)0x251, (q15_t)0xeeee, (q15_t)0x24e, (q15_t)0xeefa, (q15_t)0x24b, (q15_t)0xef06, (q15_t)0x247, (q15_t)0xef13, - (q15_t)0x244, (q15_t)0xef1f, (q15_t)0x241, (q15_t)0xef2b, (q15_t)0x23e, (q15_t)0xef37, (q15_t)0x23a, (q15_t)0xef43, - (q15_t)0x237, (q15_t)0xef4f, (q15_t)0x234, (q15_t)0xef5b, (q15_t)0x230, (q15_t)0xef67, (q15_t)0x22d, (q15_t)0xef74, - (q15_t)0x22a, (q15_t)0xef80, (q15_t)0x227, (q15_t)0xef8c, (q15_t)0x223, (q15_t)0xef98, (q15_t)0x220, (q15_t)0xefa4, - (q15_t)0x21d, (q15_t)0xefb0, (q15_t)0x21a, (q15_t)0xefbc, (q15_t)0x217, (q15_t)0xefc9, (q15_t)0x213, (q15_t)0xefd5, - (q15_t)0x210, (q15_t)0xefe1, (q15_t)0x20d, (q15_t)0xefed, (q15_t)0x20a, (q15_t)0xeff9, (q15_t)0x207, (q15_t)0xf005, - (q15_t)0x204, (q15_t)0xf012, (q15_t)0x201, (q15_t)0xf01e, (q15_t)0x1fd, (q15_t)0xf02a, (q15_t)0x1fa, (q15_t)0xf036, - (q15_t)0x1f7, (q15_t)0xf042, (q15_t)0x1f4, (q15_t)0xf04e, (q15_t)0x1f1, (q15_t)0xf05b, (q15_t)0x1ee, (q15_t)0xf067, - (q15_t)0x1eb, (q15_t)0xf073, (q15_t)0x1e8, (q15_t)0xf07f, (q15_t)0x1e5, (q15_t)0xf08b, (q15_t)0x1e2, (q15_t)0xf098, - (q15_t)0x1df, (q15_t)0xf0a4, (q15_t)0x1dc, (q15_t)0xf0b0, (q15_t)0x1d9, (q15_t)0xf0bc, (q15_t)0x1d6, (q15_t)0xf0c8, - (q15_t)0x1d3, (q15_t)0xf0d5, (q15_t)0x1d0, (q15_t)0xf0e1, (q15_t)0x1cd, (q15_t)0xf0ed, (q15_t)0x1ca, (q15_t)0xf0f9, - (q15_t)0x1c7, (q15_t)0xf105, (q15_t)0x1c4, (q15_t)0xf112, (q15_t)0x1c1, (q15_t)0xf11e, (q15_t)0x1be, (q15_t)0xf12a, - (q15_t)0x1bb, (q15_t)0xf136, (q15_t)0x1b8, (q15_t)0xf143, (q15_t)0x1b6, (q15_t)0xf14f, (q15_t)0x1b3, (q15_t)0xf15b, - (q15_t)0x1b0, (q15_t)0xf167, (q15_t)0x1ad, (q15_t)0xf174, (q15_t)0x1aa, (q15_t)0xf180, (q15_t)0x1a7, (q15_t)0xf18c, - (q15_t)0x1a4, (q15_t)0xf198, (q15_t)0x1a2, (q15_t)0xf1a4, (q15_t)0x19f, (q15_t)0xf1b1, (q15_t)0x19c, (q15_t)0xf1bd, - (q15_t)0x199, (q15_t)0xf1c9, (q15_t)0x196, (q15_t)0xf1d5, (q15_t)0x194, (q15_t)0xf1e2, (q15_t)0x191, (q15_t)0xf1ee, - (q15_t)0x18e, (q15_t)0xf1fa, (q15_t)0x18b, (q15_t)0xf207, (q15_t)0x189, (q15_t)0xf213, (q15_t)0x186, (q15_t)0xf21f, - (q15_t)0x183, (q15_t)0xf22b, (q15_t)0x180, (q15_t)0xf238, (q15_t)0x17e, (q15_t)0xf244, (q15_t)0x17b, (q15_t)0xf250, - (q15_t)0x178, (q15_t)0xf25c, (q15_t)0x176, (q15_t)0xf269, (q15_t)0x173, (q15_t)0xf275, (q15_t)0x170, (q15_t)0xf281, - (q15_t)0x16e, (q15_t)0xf28e, (q15_t)0x16b, (q15_t)0xf29a, (q15_t)0x168, (q15_t)0xf2a6, (q15_t)0x166, (q15_t)0xf2b2, - (q15_t)0x163, (q15_t)0xf2bf, (q15_t)0x161, (q15_t)0xf2cb, (q15_t)0x15e, (q15_t)0xf2d7, (q15_t)0x15b, (q15_t)0xf2e4, - (q15_t)0x159, (q15_t)0xf2f0, (q15_t)0x156, (q15_t)0xf2fc, (q15_t)0x154, (q15_t)0xf308, (q15_t)0x151, (q15_t)0xf315, - (q15_t)0x14f, (q15_t)0xf321, (q15_t)0x14c, (q15_t)0xf32d, (q15_t)0x14a, (q15_t)0xf33a, (q15_t)0x147, (q15_t)0xf346, - (q15_t)0x145, (q15_t)0xf352, (q15_t)0x142, (q15_t)0xf35f, (q15_t)0x140, (q15_t)0xf36b, (q15_t)0x13d, (q15_t)0xf377, - (q15_t)0x13b, (q15_t)0xf384, (q15_t)0x138, (q15_t)0xf390, (q15_t)0x136, (q15_t)0xf39c, (q15_t)0x134, (q15_t)0xf3a9, - (q15_t)0x131, (q15_t)0xf3b5, (q15_t)0x12f, (q15_t)0xf3c1, (q15_t)0x12c, (q15_t)0xf3ce, (q15_t)0x12a, (q15_t)0xf3da, - (q15_t)0x128, (q15_t)0xf3e6, (q15_t)0x125, (q15_t)0xf3f3, (q15_t)0x123, (q15_t)0xf3ff, (q15_t)0x120, (q15_t)0xf40b, - (q15_t)0x11e, (q15_t)0xf418, (q15_t)0x11c, (q15_t)0xf424, (q15_t)0x119, (q15_t)0xf430, (q15_t)0x117, (q15_t)0xf43d, - (q15_t)0x115, (q15_t)0xf449, (q15_t)0x113, (q15_t)0xf455, (q15_t)0x110, (q15_t)0xf462, (q15_t)0x10e, (q15_t)0xf46e, - (q15_t)0x10c, (q15_t)0xf47b, (q15_t)0x109, (q15_t)0xf487, (q15_t)0x107, (q15_t)0xf493, (q15_t)0x105, (q15_t)0xf4a0, - (q15_t)0x103, (q15_t)0xf4ac, (q15_t)0x100, (q15_t)0xf4b8, (q15_t)0xfe, (q15_t)0xf4c5, (q15_t)0xfc, (q15_t)0xf4d1, - (q15_t)0xfa, (q15_t)0xf4dd, (q15_t)0xf8, (q15_t)0xf4ea, (q15_t)0xf6, (q15_t)0xf4f6, (q15_t)0xf3, (q15_t)0xf503, - (q15_t)0xf1, (q15_t)0xf50f, (q15_t)0xef, (q15_t)0xf51b, (q15_t)0xed, (q15_t)0xf528, (q15_t)0xeb, (q15_t)0xf534, - (q15_t)0xe9, (q15_t)0xf540, (q15_t)0xe7, (q15_t)0xf54d, (q15_t)0xe4, (q15_t)0xf559, (q15_t)0xe2, (q15_t)0xf566, - (q15_t)0xe0, (q15_t)0xf572, (q15_t)0xde, (q15_t)0xf57e, (q15_t)0xdc, (q15_t)0xf58b, (q15_t)0xda, (q15_t)0xf597, - (q15_t)0xd8, (q15_t)0xf5a4, (q15_t)0xd6, (q15_t)0xf5b0, (q15_t)0xd4, (q15_t)0xf5bc, (q15_t)0xd2, (q15_t)0xf5c9, - (q15_t)0xd0, (q15_t)0xf5d5, (q15_t)0xce, (q15_t)0xf5e2, (q15_t)0xcc, (q15_t)0xf5ee, (q15_t)0xca, (q15_t)0xf5fa, - (q15_t)0xc8, (q15_t)0xf607, (q15_t)0xc6, (q15_t)0xf613, (q15_t)0xc4, (q15_t)0xf620, (q15_t)0xc2, (q15_t)0xf62c, - (q15_t)0xc0, (q15_t)0xf639, (q15_t)0xbe, (q15_t)0xf645, (q15_t)0xbd, (q15_t)0xf651, (q15_t)0xbb, (q15_t)0xf65e, - (q15_t)0xb9, (q15_t)0xf66a, (q15_t)0xb7, (q15_t)0xf677, (q15_t)0xb5, (q15_t)0xf683, (q15_t)0xb3, (q15_t)0xf690, - (q15_t)0xb1, (q15_t)0xf69c, (q15_t)0xaf, (q15_t)0xf6a8, (q15_t)0xae, (q15_t)0xf6b5, (q15_t)0xac, (q15_t)0xf6c1, - (q15_t)0xaa, (q15_t)0xf6ce, (q15_t)0xa8, (q15_t)0xf6da, (q15_t)0xa6, (q15_t)0xf6e7, (q15_t)0xa5, (q15_t)0xf6f3, - (q15_t)0xa3, (q15_t)0xf6ff, (q15_t)0xa1, (q15_t)0xf70c, (q15_t)0x9f, (q15_t)0xf718, (q15_t)0x9e, (q15_t)0xf725, - (q15_t)0x9c, (q15_t)0xf731, (q15_t)0x9a, (q15_t)0xf73e, (q15_t)0x98, (q15_t)0xf74a, (q15_t)0x97, (q15_t)0xf757, - (q15_t)0x95, (q15_t)0xf763, (q15_t)0x93, (q15_t)0xf76f, (q15_t)0x92, (q15_t)0xf77c, (q15_t)0x90, (q15_t)0xf788, - (q15_t)0x8e, (q15_t)0xf795, (q15_t)0x8d, (q15_t)0xf7a1, (q15_t)0x8b, (q15_t)0xf7ae, (q15_t)0x89, (q15_t)0xf7ba, - (q15_t)0x88, (q15_t)0xf7c7, (q15_t)0x86, (q15_t)0xf7d3, (q15_t)0x85, (q15_t)0xf7e0, (q15_t)0x83, (q15_t)0xf7ec, - (q15_t)0x81, (q15_t)0xf7f9, (q15_t)0x80, (q15_t)0xf805, (q15_t)0x7e, (q15_t)0xf811, (q15_t)0x7d, (q15_t)0xf81e, - (q15_t)0x7b, (q15_t)0xf82a, (q15_t)0x7a, (q15_t)0xf837, (q15_t)0x78, (q15_t)0xf843, (q15_t)0x77, (q15_t)0xf850, - (q15_t)0x75, (q15_t)0xf85c, (q15_t)0x74, (q15_t)0xf869, (q15_t)0x72, (q15_t)0xf875, (q15_t)0x71, (q15_t)0xf882, - (q15_t)0x6f, (q15_t)0xf88e, (q15_t)0x6e, (q15_t)0xf89b, (q15_t)0x6c, (q15_t)0xf8a7, (q15_t)0x6b, (q15_t)0xf8b4, - (q15_t)0x69, (q15_t)0xf8c0, (q15_t)0x68, (q15_t)0xf8cd, (q15_t)0x67, (q15_t)0xf8d9, (q15_t)0x65, (q15_t)0xf8e6, - (q15_t)0x64, (q15_t)0xf8f2, (q15_t)0x62, (q15_t)0xf8ff, (q15_t)0x61, (q15_t)0xf90b, (q15_t)0x60, (q15_t)0xf918, - (q15_t)0x5e, (q15_t)0xf924, (q15_t)0x5d, (q15_t)0xf931, (q15_t)0x5c, (q15_t)0xf93d, (q15_t)0x5a, (q15_t)0xf94a, - (q15_t)0x59, (q15_t)0xf956, (q15_t)0x58, (q15_t)0xf963, (q15_t)0x56, (q15_t)0xf96f, (q15_t)0x55, (q15_t)0xf97c, - (q15_t)0x54, (q15_t)0xf988, (q15_t)0x53, (q15_t)0xf995, (q15_t)0x51, (q15_t)0xf9a1, (q15_t)0x50, (q15_t)0xf9ae, - (q15_t)0x4f, (q15_t)0xf9ba, (q15_t)0x4e, (q15_t)0xf9c7, (q15_t)0x4c, (q15_t)0xf9d3, (q15_t)0x4b, (q15_t)0xf9e0, - (q15_t)0x4a, (q15_t)0xf9ec, (q15_t)0x49, (q15_t)0xf9f9, (q15_t)0x48, (q15_t)0xfa05, (q15_t)0x47, (q15_t)0xfa12, - (q15_t)0x45, (q15_t)0xfa1e, (q15_t)0x44, (q15_t)0xfa2b, (q15_t)0x43, (q15_t)0xfa37, (q15_t)0x42, (q15_t)0xfa44, - (q15_t)0x41, (q15_t)0xfa50, (q15_t)0x40, (q15_t)0xfa5d, (q15_t)0x3f, (q15_t)0xfa69, (q15_t)0x3d, (q15_t)0xfa76, - (q15_t)0x3c, (q15_t)0xfa82, (q15_t)0x3b, (q15_t)0xfa8f, (q15_t)0x3a, (q15_t)0xfa9b, (q15_t)0x39, (q15_t)0xfaa8, - (q15_t)0x38, (q15_t)0xfab4, (q15_t)0x37, (q15_t)0xfac1, (q15_t)0x36, (q15_t)0xfacd, (q15_t)0x35, (q15_t)0xfada, - (q15_t)0x34, (q15_t)0xfae6, (q15_t)0x33, (q15_t)0xfaf3, (q15_t)0x32, (q15_t)0xfb00, (q15_t)0x31, (q15_t)0xfb0c, - (q15_t)0x30, (q15_t)0xfb19, (q15_t)0x2f, (q15_t)0xfb25, (q15_t)0x2e, (q15_t)0xfb32, (q15_t)0x2d, (q15_t)0xfb3e, - (q15_t)0x2c, (q15_t)0xfb4b, (q15_t)0x2b, (q15_t)0xfb57, (q15_t)0x2b, (q15_t)0xfb64, (q15_t)0x2a, (q15_t)0xfb70, - (q15_t)0x29, (q15_t)0xfb7d, (q15_t)0x28, (q15_t)0xfb89, (q15_t)0x27, (q15_t)0xfb96, (q15_t)0x26, (q15_t)0xfba2, - (q15_t)0x25, (q15_t)0xfbaf, (q15_t)0x24, (q15_t)0xfbbc, (q15_t)0x24, (q15_t)0xfbc8, (q15_t)0x23, (q15_t)0xfbd5, - (q15_t)0x22, (q15_t)0xfbe1, (q15_t)0x21, (q15_t)0xfbee, (q15_t)0x20, (q15_t)0xfbfa, (q15_t)0x20, (q15_t)0xfc07, - (q15_t)0x1f, (q15_t)0xfc13, (q15_t)0x1e, (q15_t)0xfc20, (q15_t)0x1d, (q15_t)0xfc2c, (q15_t)0x1d, (q15_t)0xfc39, - (q15_t)0x1c, (q15_t)0xfc45, (q15_t)0x1b, (q15_t)0xfc52, (q15_t)0x1a, (q15_t)0xfc5f, (q15_t)0x1a, (q15_t)0xfc6b, - (q15_t)0x19, (q15_t)0xfc78, (q15_t)0x18, (q15_t)0xfc84, (q15_t)0x18, (q15_t)0xfc91, (q15_t)0x17, (q15_t)0xfc9d, - (q15_t)0x16, (q15_t)0xfcaa, (q15_t)0x16, (q15_t)0xfcb6, (q15_t)0x15, (q15_t)0xfcc3, (q15_t)0x14, (q15_t)0xfcd0, - (q15_t)0x14, (q15_t)0xfcdc, (q15_t)0x13, (q15_t)0xfce9, (q15_t)0x13, (q15_t)0xfcf5, (q15_t)0x12, (q15_t)0xfd02, - (q15_t)0x11, (q15_t)0xfd0e, (q15_t)0x11, (q15_t)0xfd1b, (q15_t)0x10, (q15_t)0xfd27, (q15_t)0x10, (q15_t)0xfd34, - (q15_t)0xf, (q15_t)0xfd40, (q15_t)0xf, (q15_t)0xfd4d, (q15_t)0xe, (q15_t)0xfd5a, (q15_t)0xe, (q15_t)0xfd66, - (q15_t)0xd, (q15_t)0xfd73, (q15_t)0xd, (q15_t)0xfd7f, (q15_t)0xc, (q15_t)0xfd8c, (q15_t)0xc, (q15_t)0xfd98, - (q15_t)0xb, (q15_t)0xfda5, (q15_t)0xb, (q15_t)0xfdb2, (q15_t)0xa, (q15_t)0xfdbe, (q15_t)0xa, (q15_t)0xfdcb, - (q15_t)0x9, (q15_t)0xfdd7, (q15_t)0x9, (q15_t)0xfde4, (q15_t)0x9, (q15_t)0xfdf0, (q15_t)0x8, (q15_t)0xfdfd, - (q15_t)0x8, (q15_t)0xfe09, (q15_t)0x7, (q15_t)0xfe16, (q15_t)0x7, (q15_t)0xfe23, (q15_t)0x7, (q15_t)0xfe2f, - (q15_t)0x6, (q15_t)0xfe3c, (q15_t)0x6, (q15_t)0xfe48, (q15_t)0x6, (q15_t)0xfe55, (q15_t)0x5, (q15_t)0xfe61, - (q15_t)0x5, (q15_t)0xfe6e, (q15_t)0x5, (q15_t)0xfe7a, (q15_t)0x4, (q15_t)0xfe87, (q15_t)0x4, (q15_t)0xfe94, - (q15_t)0x4, (q15_t)0xfea0, (q15_t)0x4, (q15_t)0xfead, (q15_t)0x3, (q15_t)0xfeb9, (q15_t)0x3, (q15_t)0xfec6, - (q15_t)0x3, (q15_t)0xfed2, (q15_t)0x3, (q15_t)0xfedf, (q15_t)0x2, (q15_t)0xfeec, (q15_t)0x2, (q15_t)0xfef8, - (q15_t)0x2, (q15_t)0xff05, (q15_t)0x2, (q15_t)0xff11, (q15_t)0x2, (q15_t)0xff1e, (q15_t)0x1, (q15_t)0xff2a, - (q15_t)0x1, (q15_t)0xff37, (q15_t)0x1, (q15_t)0xff44, (q15_t)0x1, (q15_t)0xff50, (q15_t)0x1, (q15_t)0xff5d, - (q15_t)0x1, (q15_t)0xff69, (q15_t)0x1, (q15_t)0xff76, (q15_t)0x0, (q15_t)0xff82, (q15_t)0x0, (q15_t)0xff8f, - (q15_t)0x0, (q15_t)0xff9b, (q15_t)0x0, (q15_t)0xffa8, (q15_t)0x0, (q15_t)0xffb5, (q15_t)0x0, (q15_t)0xffc1, - (q15_t)0x0, (q15_t)0xffce, (q15_t)0x0, (q15_t)0xffda, (q15_t)0x0, (q15_t)0xffe7, (q15_t)0x0, (q15_t)0xfff3, - (q15_t)0x0, (q15_t)0x0, (q15_t)0x0, (q15_t)0xd, (q15_t)0x0, (q15_t)0x19, (q15_t)0x0, (q15_t)0x26, - (q15_t)0x0, (q15_t)0x32, (q15_t)0x0, (q15_t)0x3f, (q15_t)0x0, (q15_t)0x4b, (q15_t)0x0, (q15_t)0x58, - (q15_t)0x0, (q15_t)0x65, (q15_t)0x0, (q15_t)0x71, (q15_t)0x0, (q15_t)0x7e, (q15_t)0x1, (q15_t)0x8a, - (q15_t)0x1, (q15_t)0x97, (q15_t)0x1, (q15_t)0xa3, (q15_t)0x1, (q15_t)0xb0, (q15_t)0x1, (q15_t)0xbc, - (q15_t)0x1, (q15_t)0xc9, (q15_t)0x1, (q15_t)0xd6, (q15_t)0x2, (q15_t)0xe2, (q15_t)0x2, (q15_t)0xef, - (q15_t)0x2, (q15_t)0xfb, (q15_t)0x2, (q15_t)0x108, (q15_t)0x2, (q15_t)0x114, (q15_t)0x3, (q15_t)0x121, - (q15_t)0x3, (q15_t)0x12e, (q15_t)0x3, (q15_t)0x13a, (q15_t)0x3, (q15_t)0x147, (q15_t)0x4, (q15_t)0x153, - (q15_t)0x4, (q15_t)0x160, (q15_t)0x4, (q15_t)0x16c, (q15_t)0x4, (q15_t)0x179, (q15_t)0x5, (q15_t)0x186, - (q15_t)0x5, (q15_t)0x192, (q15_t)0x5, (q15_t)0x19f, (q15_t)0x6, (q15_t)0x1ab, (q15_t)0x6, (q15_t)0x1b8, - (q15_t)0x6, (q15_t)0x1c4, (q15_t)0x7, (q15_t)0x1d1, (q15_t)0x7, (q15_t)0x1dd, (q15_t)0x7, (q15_t)0x1ea, - (q15_t)0x8, (q15_t)0x1f7, (q15_t)0x8, (q15_t)0x203, (q15_t)0x9, (q15_t)0x210, (q15_t)0x9, (q15_t)0x21c, - (q15_t)0x9, (q15_t)0x229, (q15_t)0xa, (q15_t)0x235, (q15_t)0xa, (q15_t)0x242, (q15_t)0xb, (q15_t)0x24e, - (q15_t)0xb, (q15_t)0x25b, (q15_t)0xc, (q15_t)0x268, (q15_t)0xc, (q15_t)0x274, (q15_t)0xd, (q15_t)0x281, - (q15_t)0xd, (q15_t)0x28d, (q15_t)0xe, (q15_t)0x29a, (q15_t)0xe, (q15_t)0x2a6, (q15_t)0xf, (q15_t)0x2b3, - (q15_t)0xf, (q15_t)0x2c0, (q15_t)0x10, (q15_t)0x2cc, (q15_t)0x10, (q15_t)0x2d9, (q15_t)0x11, (q15_t)0x2e5, - (q15_t)0x11, (q15_t)0x2f2, (q15_t)0x12, (q15_t)0x2fe, (q15_t)0x13, (q15_t)0x30b, (q15_t)0x13, (q15_t)0x317, - (q15_t)0x14, (q15_t)0x324, (q15_t)0x14, (q15_t)0x330, (q15_t)0x15, (q15_t)0x33d, (q15_t)0x16, (q15_t)0x34a, - (q15_t)0x16, (q15_t)0x356, (q15_t)0x17, (q15_t)0x363, (q15_t)0x18, (q15_t)0x36f, (q15_t)0x18, (q15_t)0x37c, - (q15_t)0x19, (q15_t)0x388, (q15_t)0x1a, (q15_t)0x395, (q15_t)0x1a, (q15_t)0x3a1, (q15_t)0x1b, (q15_t)0x3ae, - (q15_t)0x1c, (q15_t)0x3bb, (q15_t)0x1d, (q15_t)0x3c7, (q15_t)0x1d, (q15_t)0x3d4, (q15_t)0x1e, (q15_t)0x3e0, - (q15_t)0x1f, (q15_t)0x3ed, (q15_t)0x20, (q15_t)0x3f9, (q15_t)0x20, (q15_t)0x406, (q15_t)0x21, (q15_t)0x412, - (q15_t)0x22, (q15_t)0x41f, (q15_t)0x23, (q15_t)0x42b, (q15_t)0x24, (q15_t)0x438, (q15_t)0x24, (q15_t)0x444, - (q15_t)0x25, (q15_t)0x451, (q15_t)0x26, (q15_t)0x45e, (q15_t)0x27, (q15_t)0x46a, (q15_t)0x28, (q15_t)0x477, - (q15_t)0x29, (q15_t)0x483, (q15_t)0x2a, (q15_t)0x490, (q15_t)0x2b, (q15_t)0x49c, (q15_t)0x2b, (q15_t)0x4a9, - (q15_t)0x2c, (q15_t)0x4b5, (q15_t)0x2d, (q15_t)0x4c2, (q15_t)0x2e, (q15_t)0x4ce, (q15_t)0x2f, (q15_t)0x4db, - (q15_t)0x30, (q15_t)0x4e7, (q15_t)0x31, (q15_t)0x4f4, (q15_t)0x32, (q15_t)0x500, (q15_t)0x33, (q15_t)0x50d, - (q15_t)0x34, (q15_t)0x51a, (q15_t)0x35, (q15_t)0x526, (q15_t)0x36, (q15_t)0x533, (q15_t)0x37, (q15_t)0x53f, - (q15_t)0x38, (q15_t)0x54c, (q15_t)0x39, (q15_t)0x558, (q15_t)0x3a, (q15_t)0x565, (q15_t)0x3b, (q15_t)0x571, - (q15_t)0x3c, (q15_t)0x57e, (q15_t)0x3d, (q15_t)0x58a, (q15_t)0x3f, (q15_t)0x597, (q15_t)0x40, (q15_t)0x5a3, - (q15_t)0x41, (q15_t)0x5b0, (q15_t)0x42, (q15_t)0x5bc, (q15_t)0x43, (q15_t)0x5c9, (q15_t)0x44, (q15_t)0x5d5, - (q15_t)0x45, (q15_t)0x5e2, (q15_t)0x47, (q15_t)0x5ee, (q15_t)0x48, (q15_t)0x5fb, (q15_t)0x49, (q15_t)0x607, - (q15_t)0x4a, (q15_t)0x614, (q15_t)0x4b, (q15_t)0x620, (q15_t)0x4c, (q15_t)0x62d, (q15_t)0x4e, (q15_t)0x639, - (q15_t)0x4f, (q15_t)0x646, (q15_t)0x50, (q15_t)0x652, (q15_t)0x51, (q15_t)0x65f, (q15_t)0x53, (q15_t)0x66b, - (q15_t)0x54, (q15_t)0x678, (q15_t)0x55, (q15_t)0x684, (q15_t)0x56, (q15_t)0x691, (q15_t)0x58, (q15_t)0x69d, - (q15_t)0x59, (q15_t)0x6aa, (q15_t)0x5a, (q15_t)0x6b6, (q15_t)0x5c, (q15_t)0x6c3, (q15_t)0x5d, (q15_t)0x6cf, - (q15_t)0x5e, (q15_t)0x6dc, (q15_t)0x60, (q15_t)0x6e8, (q15_t)0x61, (q15_t)0x6f5, (q15_t)0x62, (q15_t)0x701, - (q15_t)0x64, (q15_t)0x70e, (q15_t)0x65, (q15_t)0x71a, (q15_t)0x67, (q15_t)0x727, (q15_t)0x68, (q15_t)0x733, - (q15_t)0x69, (q15_t)0x740, (q15_t)0x6b, (q15_t)0x74c, (q15_t)0x6c, (q15_t)0x759, (q15_t)0x6e, (q15_t)0x765, - (q15_t)0x6f, (q15_t)0x772, (q15_t)0x71, (q15_t)0x77e, (q15_t)0x72, (q15_t)0x78b, (q15_t)0x74, (q15_t)0x797, - (q15_t)0x75, (q15_t)0x7a4, (q15_t)0x77, (q15_t)0x7b0, (q15_t)0x78, (q15_t)0x7bd, (q15_t)0x7a, (q15_t)0x7c9, - (q15_t)0x7b, (q15_t)0x7d6, (q15_t)0x7d, (q15_t)0x7e2, (q15_t)0x7e, (q15_t)0x7ef, (q15_t)0x80, (q15_t)0x7fb, - (q15_t)0x81, (q15_t)0x807, (q15_t)0x83, (q15_t)0x814, (q15_t)0x85, (q15_t)0x820, (q15_t)0x86, (q15_t)0x82d, - (q15_t)0x88, (q15_t)0x839, (q15_t)0x89, (q15_t)0x846, (q15_t)0x8b, (q15_t)0x852, (q15_t)0x8d, (q15_t)0x85f, - (q15_t)0x8e, (q15_t)0x86b, (q15_t)0x90, (q15_t)0x878, (q15_t)0x92, (q15_t)0x884, (q15_t)0x93, (q15_t)0x891, - (q15_t)0x95, (q15_t)0x89d, (q15_t)0x97, (q15_t)0x8a9, (q15_t)0x98, (q15_t)0x8b6, (q15_t)0x9a, (q15_t)0x8c2, - (q15_t)0x9c, (q15_t)0x8cf, (q15_t)0x9e, (q15_t)0x8db, (q15_t)0x9f, (q15_t)0x8e8, (q15_t)0xa1, (q15_t)0x8f4, - (q15_t)0xa3, (q15_t)0x901, (q15_t)0xa5, (q15_t)0x90d, (q15_t)0xa6, (q15_t)0x919, (q15_t)0xa8, (q15_t)0x926, - (q15_t)0xaa, (q15_t)0x932, (q15_t)0xac, (q15_t)0x93f, (q15_t)0xae, (q15_t)0x94b, (q15_t)0xaf, (q15_t)0x958, - (q15_t)0xb1, (q15_t)0x964, (q15_t)0xb3, (q15_t)0x970, (q15_t)0xb5, (q15_t)0x97d, (q15_t)0xb7, (q15_t)0x989, - (q15_t)0xb9, (q15_t)0x996, (q15_t)0xbb, (q15_t)0x9a2, (q15_t)0xbd, (q15_t)0x9af, (q15_t)0xbe, (q15_t)0x9bb, - (q15_t)0xc0, (q15_t)0x9c7, (q15_t)0xc2, (q15_t)0x9d4, (q15_t)0xc4, (q15_t)0x9e0, (q15_t)0xc6, (q15_t)0x9ed, - (q15_t)0xc8, (q15_t)0x9f9, (q15_t)0xca, (q15_t)0xa06, (q15_t)0xcc, (q15_t)0xa12, (q15_t)0xce, (q15_t)0xa1e, - (q15_t)0xd0, (q15_t)0xa2b, (q15_t)0xd2, (q15_t)0xa37, (q15_t)0xd4, (q15_t)0xa44, (q15_t)0xd6, (q15_t)0xa50, - (q15_t)0xd8, (q15_t)0xa5c, (q15_t)0xda, (q15_t)0xa69, (q15_t)0xdc, (q15_t)0xa75, (q15_t)0xde, (q15_t)0xa82, - (q15_t)0xe0, (q15_t)0xa8e, (q15_t)0xe2, (q15_t)0xa9a, (q15_t)0xe4, (q15_t)0xaa7, (q15_t)0xe7, (q15_t)0xab3, - (q15_t)0xe9, (q15_t)0xac0, (q15_t)0xeb, (q15_t)0xacc, (q15_t)0xed, (q15_t)0xad8, (q15_t)0xef, (q15_t)0xae5, - (q15_t)0xf1, (q15_t)0xaf1, (q15_t)0xf3, (q15_t)0xafd, (q15_t)0xf6, (q15_t)0xb0a, (q15_t)0xf8, (q15_t)0xb16, - (q15_t)0xfa, (q15_t)0xb23, (q15_t)0xfc, (q15_t)0xb2f, (q15_t)0xfe, (q15_t)0xb3b, (q15_t)0x100, (q15_t)0xb48, - (q15_t)0x103, (q15_t)0xb54, (q15_t)0x105, (q15_t)0xb60, (q15_t)0x107, (q15_t)0xb6d, (q15_t)0x109, (q15_t)0xb79, - (q15_t)0x10c, (q15_t)0xb85, (q15_t)0x10e, (q15_t)0xb92, (q15_t)0x110, (q15_t)0xb9e, (q15_t)0x113, (q15_t)0xbab, - (q15_t)0x115, (q15_t)0xbb7, (q15_t)0x117, (q15_t)0xbc3, (q15_t)0x119, (q15_t)0xbd0, (q15_t)0x11c, (q15_t)0xbdc, - (q15_t)0x11e, (q15_t)0xbe8, (q15_t)0x120, (q15_t)0xbf5, (q15_t)0x123, (q15_t)0xc01, (q15_t)0x125, (q15_t)0xc0d, - (q15_t)0x128, (q15_t)0xc1a, (q15_t)0x12a, (q15_t)0xc26, (q15_t)0x12c, (q15_t)0xc32, (q15_t)0x12f, (q15_t)0xc3f, - (q15_t)0x131, (q15_t)0xc4b, (q15_t)0x134, (q15_t)0xc57, (q15_t)0x136, (q15_t)0xc64, (q15_t)0x138, (q15_t)0xc70, - (q15_t)0x13b, (q15_t)0xc7c, (q15_t)0x13d, (q15_t)0xc89, (q15_t)0x140, (q15_t)0xc95, (q15_t)0x142, (q15_t)0xca1, - (q15_t)0x145, (q15_t)0xcae, (q15_t)0x147, (q15_t)0xcba, (q15_t)0x14a, (q15_t)0xcc6, (q15_t)0x14c, (q15_t)0xcd3, - (q15_t)0x14f, (q15_t)0xcdf, (q15_t)0x151, (q15_t)0xceb, (q15_t)0x154, (q15_t)0xcf8, (q15_t)0x156, (q15_t)0xd04, - (q15_t)0x159, (q15_t)0xd10, (q15_t)0x15b, (q15_t)0xd1c, (q15_t)0x15e, (q15_t)0xd29, (q15_t)0x161, (q15_t)0xd35, - (q15_t)0x163, (q15_t)0xd41, (q15_t)0x166, (q15_t)0xd4e, (q15_t)0x168, (q15_t)0xd5a, (q15_t)0x16b, (q15_t)0xd66, - (q15_t)0x16e, (q15_t)0xd72, (q15_t)0x170, (q15_t)0xd7f, (q15_t)0x173, (q15_t)0xd8b, (q15_t)0x176, (q15_t)0xd97, - (q15_t)0x178, (q15_t)0xda4, (q15_t)0x17b, (q15_t)0xdb0, (q15_t)0x17e, (q15_t)0xdbc, (q15_t)0x180, (q15_t)0xdc8, - (q15_t)0x183, (q15_t)0xdd5, (q15_t)0x186, (q15_t)0xde1, (q15_t)0x189, (q15_t)0xded, (q15_t)0x18b, (q15_t)0xdf9, - (q15_t)0x18e, (q15_t)0xe06, (q15_t)0x191, (q15_t)0xe12, (q15_t)0x194, (q15_t)0xe1e, (q15_t)0x196, (q15_t)0xe2b, - (q15_t)0x199, (q15_t)0xe37, (q15_t)0x19c, (q15_t)0xe43, (q15_t)0x19f, (q15_t)0xe4f, (q15_t)0x1a2, (q15_t)0xe5c, - (q15_t)0x1a4, (q15_t)0xe68, (q15_t)0x1a7, (q15_t)0xe74, (q15_t)0x1aa, (q15_t)0xe80, (q15_t)0x1ad, (q15_t)0xe8c, - (q15_t)0x1b0, (q15_t)0xe99, (q15_t)0x1b3, (q15_t)0xea5, (q15_t)0x1b6, (q15_t)0xeb1, (q15_t)0x1b8, (q15_t)0xebd, - (q15_t)0x1bb, (q15_t)0xeca, (q15_t)0x1be, (q15_t)0xed6, (q15_t)0x1c1, (q15_t)0xee2, (q15_t)0x1c4, (q15_t)0xeee, - (q15_t)0x1c7, (q15_t)0xefb, (q15_t)0x1ca, (q15_t)0xf07, (q15_t)0x1cd, (q15_t)0xf13, (q15_t)0x1d0, (q15_t)0xf1f, - (q15_t)0x1d3, (q15_t)0xf2b, (q15_t)0x1d6, (q15_t)0xf38, (q15_t)0x1d9, (q15_t)0xf44, (q15_t)0x1dc, (q15_t)0xf50, - (q15_t)0x1df, (q15_t)0xf5c, (q15_t)0x1e2, (q15_t)0xf68, (q15_t)0x1e5, (q15_t)0xf75, (q15_t)0x1e8, (q15_t)0xf81, - (q15_t)0x1eb, (q15_t)0xf8d, (q15_t)0x1ee, (q15_t)0xf99, (q15_t)0x1f1, (q15_t)0xfa5, (q15_t)0x1f4, (q15_t)0xfb2, - (q15_t)0x1f7, (q15_t)0xfbe, (q15_t)0x1fa, (q15_t)0xfca, (q15_t)0x1fd, (q15_t)0xfd6, (q15_t)0x201, (q15_t)0xfe2, - (q15_t)0x204, (q15_t)0xfee, (q15_t)0x207, (q15_t)0xffb, (q15_t)0x20a, (q15_t)0x1007, (q15_t)0x20d, (q15_t)0x1013, - (q15_t)0x210, (q15_t)0x101f, (q15_t)0x213, (q15_t)0x102b, (q15_t)0x217, (q15_t)0x1037, (q15_t)0x21a, (q15_t)0x1044, - (q15_t)0x21d, (q15_t)0x1050, (q15_t)0x220, (q15_t)0x105c, (q15_t)0x223, (q15_t)0x1068, (q15_t)0x227, (q15_t)0x1074, - (q15_t)0x22a, (q15_t)0x1080, (q15_t)0x22d, (q15_t)0x108c, (q15_t)0x230, (q15_t)0x1099, (q15_t)0x234, (q15_t)0x10a5, - (q15_t)0x237, (q15_t)0x10b1, (q15_t)0x23a, (q15_t)0x10bd, (q15_t)0x23e, (q15_t)0x10c9, (q15_t)0x241, (q15_t)0x10d5, - (q15_t)0x244, (q15_t)0x10e1, (q15_t)0x247, (q15_t)0x10ed, (q15_t)0x24b, (q15_t)0x10fa, (q15_t)0x24e, (q15_t)0x1106, - (q15_t)0x251, (q15_t)0x1112, (q15_t)0x255, (q15_t)0x111e, (q15_t)0x258, (q15_t)0x112a, (q15_t)0x25c, (q15_t)0x1136, - (q15_t)0x25f, (q15_t)0x1142, (q15_t)0x262, (q15_t)0x114e, (q15_t)0x266, (q15_t)0x115a, (q15_t)0x269, (q15_t)0x1167, - (q15_t)0x26d, (q15_t)0x1173, (q15_t)0x270, (q15_t)0x117f, (q15_t)0x273, (q15_t)0x118b, (q15_t)0x277, (q15_t)0x1197, - (q15_t)0x27a, (q15_t)0x11a3, (q15_t)0x27e, (q15_t)0x11af, (q15_t)0x281, (q15_t)0x11bb, (q15_t)0x285, (q15_t)0x11c7, - (q15_t)0x288, (q15_t)0x11d3, (q15_t)0x28c, (q15_t)0x11df, (q15_t)0x28f, (q15_t)0x11eb, (q15_t)0x293, (q15_t)0x11f7, - (q15_t)0x296, (q15_t)0x1204, (q15_t)0x29a, (q15_t)0x1210, (q15_t)0x29d, (q15_t)0x121c, (q15_t)0x2a1, (q15_t)0x1228, - (q15_t)0x2a5, (q15_t)0x1234, (q15_t)0x2a8, (q15_t)0x1240, (q15_t)0x2ac, (q15_t)0x124c, (q15_t)0x2af, (q15_t)0x1258, - (q15_t)0x2b3, (q15_t)0x1264, (q15_t)0x2b7, (q15_t)0x1270, (q15_t)0x2ba, (q15_t)0x127c, (q15_t)0x2be, (q15_t)0x1288, - (q15_t)0x2c1, (q15_t)0x1294, (q15_t)0x2c5, (q15_t)0x12a0, (q15_t)0x2c9, (q15_t)0x12ac, (q15_t)0x2cc, (q15_t)0x12b8, - (q15_t)0x2d0, (q15_t)0x12c4, (q15_t)0x2d4, (q15_t)0x12d0, (q15_t)0x2d8, (q15_t)0x12dc, (q15_t)0x2db, (q15_t)0x12e8, - (q15_t)0x2df, (q15_t)0x12f4, (q15_t)0x2e3, (q15_t)0x1300, (q15_t)0x2e6, (q15_t)0x130c, (q15_t)0x2ea, (q15_t)0x1318, - (q15_t)0x2ee, (q15_t)0x1324, (q15_t)0x2f2, (q15_t)0x1330, (q15_t)0x2f5, (q15_t)0x133c, (q15_t)0x2f9, (q15_t)0x1348, - (q15_t)0x2fd, (q15_t)0x1354, (q15_t)0x301, (q15_t)0x1360, (q15_t)0x305, (q15_t)0x136c, (q15_t)0x308, (q15_t)0x1378, - (q15_t)0x30c, (q15_t)0x1384, (q15_t)0x310, (q15_t)0x1390, (q15_t)0x314, (q15_t)0x139c, (q15_t)0x318, (q15_t)0x13a8, - (q15_t)0x31c, (q15_t)0x13b4, (q15_t)0x320, (q15_t)0x13c0, (q15_t)0x323, (q15_t)0x13cc, (q15_t)0x327, (q15_t)0x13d8, - (q15_t)0x32b, (q15_t)0x13e4, (q15_t)0x32f, (q15_t)0x13f0, (q15_t)0x333, (q15_t)0x13fb, (q15_t)0x337, (q15_t)0x1407, - (q15_t)0x33b, (q15_t)0x1413, (q15_t)0x33f, (q15_t)0x141f, (q15_t)0x343, (q15_t)0x142b, (q15_t)0x347, (q15_t)0x1437, - (q15_t)0x34b, (q15_t)0x1443, (q15_t)0x34f, (q15_t)0x144f, (q15_t)0x353, (q15_t)0x145b, (q15_t)0x357, (q15_t)0x1467, - (q15_t)0x35b, (q15_t)0x1473, (q15_t)0x35f, (q15_t)0x147f, (q15_t)0x363, (q15_t)0x148b, (q15_t)0x367, (q15_t)0x1496, - (q15_t)0x36b, (q15_t)0x14a2, (q15_t)0x36f, (q15_t)0x14ae, (q15_t)0x373, (q15_t)0x14ba, (q15_t)0x377, (q15_t)0x14c6, - (q15_t)0x37b, (q15_t)0x14d2, (q15_t)0x37f, (q15_t)0x14de, (q15_t)0x383, (q15_t)0x14ea, (q15_t)0x387, (q15_t)0x14f6, - (q15_t)0x38c, (q15_t)0x1501, (q15_t)0x390, (q15_t)0x150d, (q15_t)0x394, (q15_t)0x1519, (q15_t)0x398, (q15_t)0x1525, - (q15_t)0x39c, (q15_t)0x1531, (q15_t)0x3a0, (q15_t)0x153d, (q15_t)0x3a5, (q15_t)0x1549, (q15_t)0x3a9, (q15_t)0x1554, - (q15_t)0x3ad, (q15_t)0x1560, (q15_t)0x3b1, (q15_t)0x156c, (q15_t)0x3b5, (q15_t)0x1578, (q15_t)0x3ba, (q15_t)0x1584, - (q15_t)0x3be, (q15_t)0x1590, (q15_t)0x3c2, (q15_t)0x159b, (q15_t)0x3c6, (q15_t)0x15a7, (q15_t)0x3ca, (q15_t)0x15b3, - (q15_t)0x3cf, (q15_t)0x15bf, (q15_t)0x3d3, (q15_t)0x15cb, (q15_t)0x3d7, (q15_t)0x15d7, (q15_t)0x3dc, (q15_t)0x15e2, - (q15_t)0x3e0, (q15_t)0x15ee, (q15_t)0x3e4, (q15_t)0x15fa, (q15_t)0x3e9, (q15_t)0x1606, (q15_t)0x3ed, (q15_t)0x1612, - (q15_t)0x3f1, (q15_t)0x161d, (q15_t)0x3f6, (q15_t)0x1629, (q15_t)0x3fa, (q15_t)0x1635, (q15_t)0x3fe, (q15_t)0x1641, - (q15_t)0x403, (q15_t)0x164c, (q15_t)0x407, (q15_t)0x1658, (q15_t)0x40b, (q15_t)0x1664, (q15_t)0x410, (q15_t)0x1670, - (q15_t)0x414, (q15_t)0x167c, (q15_t)0x419, (q15_t)0x1687, (q15_t)0x41d, (q15_t)0x1693, (q15_t)0x422, (q15_t)0x169f, - (q15_t)0x426, (q15_t)0x16ab, (q15_t)0x42a, (q15_t)0x16b6, (q15_t)0x42f, (q15_t)0x16c2, (q15_t)0x433, (q15_t)0x16ce, - (q15_t)0x438, (q15_t)0x16da, (q15_t)0x43c, (q15_t)0x16e5, (q15_t)0x441, (q15_t)0x16f1, (q15_t)0x445, (q15_t)0x16fd, - (q15_t)0x44a, (q15_t)0x1709, (q15_t)0x44e, (q15_t)0x1714, (q15_t)0x453, (q15_t)0x1720, (q15_t)0x457, (q15_t)0x172c, - (q15_t)0x45c, (q15_t)0x1737, (q15_t)0x461, (q15_t)0x1743, (q15_t)0x465, (q15_t)0x174f, (q15_t)0x46a, (q15_t)0x175b, - (q15_t)0x46e, (q15_t)0x1766, (q15_t)0x473, (q15_t)0x1772, (q15_t)0x478, (q15_t)0x177e, (q15_t)0x47c, (q15_t)0x1789, - (q15_t)0x481, (q15_t)0x1795, (q15_t)0x485, (q15_t)0x17a1, (q15_t)0x48a, (q15_t)0x17ac, (q15_t)0x48f, (q15_t)0x17b8, - (q15_t)0x493, (q15_t)0x17c4, (q15_t)0x498, (q15_t)0x17cf, (q15_t)0x49d, (q15_t)0x17db, (q15_t)0x4a1, (q15_t)0x17e7, - (q15_t)0x4a6, (q15_t)0x17f2, (q15_t)0x4ab, (q15_t)0x17fe, (q15_t)0x4b0, (q15_t)0x180a, (q15_t)0x4b4, (q15_t)0x1815, - (q15_t)0x4b9, (q15_t)0x1821, (q15_t)0x4be, (q15_t)0x182d, (q15_t)0x4c2, (q15_t)0x1838, (q15_t)0x4c7, (q15_t)0x1844, - (q15_t)0x4cc, (q15_t)0x184f, (q15_t)0x4d1, (q15_t)0x185b, (q15_t)0x4d6, (q15_t)0x1867, (q15_t)0x4da, (q15_t)0x1872, - (q15_t)0x4df, (q15_t)0x187e, (q15_t)0x4e4, (q15_t)0x1889, (q15_t)0x4e9, (q15_t)0x1895, (q15_t)0x4ee, (q15_t)0x18a1, - (q15_t)0x4f2, (q15_t)0x18ac, (q15_t)0x4f7, (q15_t)0x18b8, (q15_t)0x4fc, (q15_t)0x18c3, (q15_t)0x501, (q15_t)0x18cf, - (q15_t)0x506, (q15_t)0x18db, (q15_t)0x50b, (q15_t)0x18e6, (q15_t)0x510, (q15_t)0x18f2, (q15_t)0x515, (q15_t)0x18fd, - (q15_t)0x51a, (q15_t)0x1909, (q15_t)0x51e, (q15_t)0x1914, (q15_t)0x523, (q15_t)0x1920, (q15_t)0x528, (q15_t)0x192c, - (q15_t)0x52d, (q15_t)0x1937, (q15_t)0x532, (q15_t)0x1943, (q15_t)0x537, (q15_t)0x194e, (q15_t)0x53c, (q15_t)0x195a, - (q15_t)0x541, (q15_t)0x1965, (q15_t)0x546, (q15_t)0x1971, (q15_t)0x54b, (q15_t)0x197c, (q15_t)0x550, (q15_t)0x1988, - (q15_t)0x555, (q15_t)0x1993, (q15_t)0x55a, (q15_t)0x199f, (q15_t)0x55f, (q15_t)0x19aa, (q15_t)0x564, (q15_t)0x19b6, - (q15_t)0x569, (q15_t)0x19c1, (q15_t)0x56e, (q15_t)0x19cd, (q15_t)0x573, (q15_t)0x19d8, (q15_t)0x578, (q15_t)0x19e4, - (q15_t)0x57e, (q15_t)0x19ef, (q15_t)0x583, (q15_t)0x19fb, (q15_t)0x588, (q15_t)0x1a06, (q15_t)0x58d, (q15_t)0x1a12, - (q15_t)0x592, (q15_t)0x1a1d, (q15_t)0x597, (q15_t)0x1a29, (q15_t)0x59c, (q15_t)0x1a34, (q15_t)0x5a1, (q15_t)0x1a40, - (q15_t)0x5a7, (q15_t)0x1a4b, (q15_t)0x5ac, (q15_t)0x1a57, (q15_t)0x5b1, (q15_t)0x1a62, (q15_t)0x5b6, (q15_t)0x1a6e, - (q15_t)0x5bb, (q15_t)0x1a79, (q15_t)0x5c1, (q15_t)0x1a84, (q15_t)0x5c6, (q15_t)0x1a90, (q15_t)0x5cb, (q15_t)0x1a9b, - (q15_t)0x5d0, (q15_t)0x1aa7, (q15_t)0x5d5, (q15_t)0x1ab2, (q15_t)0x5db, (q15_t)0x1abe, (q15_t)0x5e0, (q15_t)0x1ac9, - (q15_t)0x5e5, (q15_t)0x1ad4, (q15_t)0x5ea, (q15_t)0x1ae0, (q15_t)0x5f0, (q15_t)0x1aeb, (q15_t)0x5f5, (q15_t)0x1af7, - (q15_t)0x5fa, (q15_t)0x1b02, (q15_t)0x600, (q15_t)0x1b0d, (q15_t)0x605, (q15_t)0x1b19, (q15_t)0x60a, (q15_t)0x1b24, - (q15_t)0x610, (q15_t)0x1b30, (q15_t)0x615, (q15_t)0x1b3b, (q15_t)0x61a, (q15_t)0x1b46, (q15_t)0x620, (q15_t)0x1b52, - (q15_t)0x625, (q15_t)0x1b5d, (q15_t)0x62a, (q15_t)0x1b68, (q15_t)0x630, (q15_t)0x1b74, (q15_t)0x635, (q15_t)0x1b7f, - (q15_t)0x63b, (q15_t)0x1b8a, (q15_t)0x640, (q15_t)0x1b96, (q15_t)0x645, (q15_t)0x1ba1, (q15_t)0x64b, (q15_t)0x1bac, - (q15_t)0x650, (q15_t)0x1bb8, (q15_t)0x656, (q15_t)0x1bc3, (q15_t)0x65b, (q15_t)0x1bce, (q15_t)0x661, (q15_t)0x1bda, - (q15_t)0x666, (q15_t)0x1be5, (q15_t)0x66c, (q15_t)0x1bf0, (q15_t)0x671, (q15_t)0x1bfc, (q15_t)0x677, (q15_t)0x1c07, - (q15_t)0x67c, (q15_t)0x1c12, (q15_t)0x682, (q15_t)0x1c1e, (q15_t)0x687, (q15_t)0x1c29, (q15_t)0x68d, (q15_t)0x1c34, - (q15_t)0x692, (q15_t)0x1c3f, (q15_t)0x698, (q15_t)0x1c4b, (q15_t)0x69d, (q15_t)0x1c56, (q15_t)0x6a3, (q15_t)0x1c61, - (q15_t)0x6a8, (q15_t)0x1c6c, (q15_t)0x6ae, (q15_t)0x1c78, (q15_t)0x6b4, (q15_t)0x1c83, (q15_t)0x6b9, (q15_t)0x1c8e, - (q15_t)0x6bf, (q15_t)0x1c99, (q15_t)0x6c5, (q15_t)0x1ca5, (q15_t)0x6ca, (q15_t)0x1cb0, (q15_t)0x6d0, (q15_t)0x1cbb, - (q15_t)0x6d5, (q15_t)0x1cc6, (q15_t)0x6db, (q15_t)0x1cd2, (q15_t)0x6e1, (q15_t)0x1cdd, (q15_t)0x6e6, (q15_t)0x1ce8, - (q15_t)0x6ec, (q15_t)0x1cf3, (q15_t)0x6f2, (q15_t)0x1cff, (q15_t)0x6f7, (q15_t)0x1d0a, (q15_t)0x6fd, (q15_t)0x1d15, - (q15_t)0x703, (q15_t)0x1d20, (q15_t)0x709, (q15_t)0x1d2b, (q15_t)0x70e, (q15_t)0x1d36, (q15_t)0x714, (q15_t)0x1d42, - (q15_t)0x71a, (q15_t)0x1d4d, (q15_t)0x720, (q15_t)0x1d58, (q15_t)0x725, (q15_t)0x1d63, (q15_t)0x72b, (q15_t)0x1d6e, - (q15_t)0x731, (q15_t)0x1d79, (q15_t)0x737, (q15_t)0x1d85, (q15_t)0x73d, (q15_t)0x1d90, (q15_t)0x742, (q15_t)0x1d9b, - (q15_t)0x748, (q15_t)0x1da6, (q15_t)0x74e, (q15_t)0x1db1, (q15_t)0x754, (q15_t)0x1dbc, (q15_t)0x75a, (q15_t)0x1dc7, - (q15_t)0x75f, (q15_t)0x1dd3, (q15_t)0x765, (q15_t)0x1dde, (q15_t)0x76b, (q15_t)0x1de9, (q15_t)0x771, (q15_t)0x1df4, - (q15_t)0x777, (q15_t)0x1dff, (q15_t)0x77d, (q15_t)0x1e0a, (q15_t)0x783, (q15_t)0x1e15, (q15_t)0x789, (q15_t)0x1e20, - (q15_t)0x78f, (q15_t)0x1e2b, (q15_t)0x795, (q15_t)0x1e36, (q15_t)0x79a, (q15_t)0x1e42, (q15_t)0x7a0, (q15_t)0x1e4d, - (q15_t)0x7a6, (q15_t)0x1e58, (q15_t)0x7ac, (q15_t)0x1e63, (q15_t)0x7b2, (q15_t)0x1e6e, (q15_t)0x7b8, (q15_t)0x1e79, - (q15_t)0x7be, (q15_t)0x1e84, (q15_t)0x7c4, (q15_t)0x1e8f, (q15_t)0x7ca, (q15_t)0x1e9a, (q15_t)0x7d0, (q15_t)0x1ea5, - (q15_t)0x7d6, (q15_t)0x1eb0, (q15_t)0x7dc, (q15_t)0x1ebb, (q15_t)0x7e2, (q15_t)0x1ec6, (q15_t)0x7e8, (q15_t)0x1ed1, - (q15_t)0x7ee, (q15_t)0x1edc, (q15_t)0x7f5, (q15_t)0x1ee7, (q15_t)0x7fb, (q15_t)0x1ef2, (q15_t)0x801, (q15_t)0x1efd, - (q15_t)0x807, (q15_t)0x1f08, (q15_t)0x80d, (q15_t)0x1f13, (q15_t)0x813, (q15_t)0x1f1e, (q15_t)0x819, (q15_t)0x1f29, - (q15_t)0x81f, (q15_t)0x1f34, (q15_t)0x825, (q15_t)0x1f3f, (q15_t)0x82b, (q15_t)0x1f4a, (q15_t)0x832, (q15_t)0x1f55, - (q15_t)0x838, (q15_t)0x1f60, (q15_t)0x83e, (q15_t)0x1f6b, (q15_t)0x844, (q15_t)0x1f76, (q15_t)0x84a, (q15_t)0x1f81, - (q15_t)0x850, (q15_t)0x1f8c, (q15_t)0x857, (q15_t)0x1f97, (q15_t)0x85d, (q15_t)0x1fa2, (q15_t)0x863, (q15_t)0x1fac, - (q15_t)0x869, (q15_t)0x1fb7, (q15_t)0x870, (q15_t)0x1fc2, (q15_t)0x876, (q15_t)0x1fcd, (q15_t)0x87c, (q15_t)0x1fd8, - (q15_t)0x882, (q15_t)0x1fe3, (q15_t)0x889, (q15_t)0x1fee, (q15_t)0x88f, (q15_t)0x1ff9, (q15_t)0x895, (q15_t)0x2004, - (q15_t)0x89b, (q15_t)0x200f, (q15_t)0x8a2, (q15_t)0x2019, (q15_t)0x8a8, (q15_t)0x2024, (q15_t)0x8ae, (q15_t)0x202f, - (q15_t)0x8b5, (q15_t)0x203a, (q15_t)0x8bb, (q15_t)0x2045, (q15_t)0x8c1, (q15_t)0x2050, (q15_t)0x8c8, (q15_t)0x205b, - (q15_t)0x8ce, (q15_t)0x2065, (q15_t)0x8d4, (q15_t)0x2070, (q15_t)0x8db, (q15_t)0x207b, (q15_t)0x8e1, (q15_t)0x2086, - (q15_t)0x8e8, (q15_t)0x2091, (q15_t)0x8ee, (q15_t)0x209b, (q15_t)0x8f4, (q15_t)0x20a6, (q15_t)0x8fb, (q15_t)0x20b1, - (q15_t)0x901, (q15_t)0x20bc, (q15_t)0x908, (q15_t)0x20c7, (q15_t)0x90e, (q15_t)0x20d1, (q15_t)0x915, (q15_t)0x20dc, - (q15_t)0x91b, (q15_t)0x20e7, (q15_t)0x921, (q15_t)0x20f2, (q15_t)0x928, (q15_t)0x20fd, (q15_t)0x92e, (q15_t)0x2107, - (q15_t)0x935, (q15_t)0x2112, (q15_t)0x93b, (q15_t)0x211d, (q15_t)0x942, (q15_t)0x2128, (q15_t)0x948, (q15_t)0x2132, - (q15_t)0x94f, (q15_t)0x213d, (q15_t)0x955, (q15_t)0x2148, (q15_t)0x95c, (q15_t)0x2153, (q15_t)0x963, (q15_t)0x215d, - (q15_t)0x969, (q15_t)0x2168, (q15_t)0x970, (q15_t)0x2173, (q15_t)0x976, (q15_t)0x217d, (q15_t)0x97d, (q15_t)0x2188, - (q15_t)0x983, (q15_t)0x2193, (q15_t)0x98a, (q15_t)0x219e, (q15_t)0x991, (q15_t)0x21a8, (q15_t)0x997, (q15_t)0x21b3, - (q15_t)0x99e, (q15_t)0x21be, (q15_t)0x9a4, (q15_t)0x21c8, (q15_t)0x9ab, (q15_t)0x21d3, (q15_t)0x9b2, (q15_t)0x21de, - (q15_t)0x9b8, (q15_t)0x21e8, (q15_t)0x9bf, (q15_t)0x21f3, (q15_t)0x9c6, (q15_t)0x21fe, (q15_t)0x9cc, (q15_t)0x2208, - (q15_t)0x9d3, (q15_t)0x2213, (q15_t)0x9da, (q15_t)0x221e, (q15_t)0x9e0, (q15_t)0x2228, (q15_t)0x9e7, (q15_t)0x2233, - (q15_t)0x9ee, (q15_t)0x223d, (q15_t)0x9f5, (q15_t)0x2248, (q15_t)0x9fb, (q15_t)0x2253, (q15_t)0xa02, (q15_t)0x225d, - (q15_t)0xa09, (q15_t)0x2268, (q15_t)0xa10, (q15_t)0x2272, (q15_t)0xa16, (q15_t)0x227d, (q15_t)0xa1d, (q15_t)0x2288, - (q15_t)0xa24, (q15_t)0x2292, (q15_t)0xa2b, (q15_t)0x229d, (q15_t)0xa32, (q15_t)0x22a7, (q15_t)0xa38, (q15_t)0x22b2, - (q15_t)0xa3f, (q15_t)0x22bc, (q15_t)0xa46, (q15_t)0x22c7, (q15_t)0xa4d, (q15_t)0x22d2, (q15_t)0xa54, (q15_t)0x22dc, - (q15_t)0xa5b, (q15_t)0x22e7, (q15_t)0xa61, (q15_t)0x22f1, (q15_t)0xa68, (q15_t)0x22fc, (q15_t)0xa6f, (q15_t)0x2306, - (q15_t)0xa76, (q15_t)0x2311, (q15_t)0xa7d, (q15_t)0x231b, (q15_t)0xa84, (q15_t)0x2326, (q15_t)0xa8b, (q15_t)0x2330, - (q15_t)0xa92, (q15_t)0x233b, (q15_t)0xa99, (q15_t)0x2345, (q15_t)0xa9f, (q15_t)0x2350, (q15_t)0xaa6, (q15_t)0x235a, - (q15_t)0xaad, (q15_t)0x2365, (q15_t)0xab4, (q15_t)0x236f, (q15_t)0xabb, (q15_t)0x237a, (q15_t)0xac2, (q15_t)0x2384, - (q15_t)0xac9, (q15_t)0x238e, (q15_t)0xad0, (q15_t)0x2399, (q15_t)0xad7, (q15_t)0x23a3, (q15_t)0xade, (q15_t)0x23ae, - (q15_t)0xae5, (q15_t)0x23b8, (q15_t)0xaec, (q15_t)0x23c3, (q15_t)0xaf3, (q15_t)0x23cd, (q15_t)0xafa, (q15_t)0x23d7, - (q15_t)0xb01, (q15_t)0x23e2, (q15_t)0xb08, (q15_t)0x23ec, (q15_t)0xb0f, (q15_t)0x23f7, (q15_t)0xb16, (q15_t)0x2401, - (q15_t)0xb1e, (q15_t)0x240b, (q15_t)0xb25, (q15_t)0x2416, (q15_t)0xb2c, (q15_t)0x2420, (q15_t)0xb33, (q15_t)0x242b, - (q15_t)0xb3a, (q15_t)0x2435, (q15_t)0xb41, (q15_t)0x243f, (q15_t)0xb48, (q15_t)0x244a, (q15_t)0xb4f, (q15_t)0x2454, - (q15_t)0xb56, (q15_t)0x245e, (q15_t)0xb5e, (q15_t)0x2469, (q15_t)0xb65, (q15_t)0x2473, (q15_t)0xb6c, (q15_t)0x247d, - (q15_t)0xb73, (q15_t)0x2488, (q15_t)0xb7a, (q15_t)0x2492, (q15_t)0xb81, (q15_t)0x249c, (q15_t)0xb89, (q15_t)0x24a7, - (q15_t)0xb90, (q15_t)0x24b1, (q15_t)0xb97, (q15_t)0x24bb, (q15_t)0xb9e, (q15_t)0x24c5, (q15_t)0xba5, (q15_t)0x24d0, - (q15_t)0xbad, (q15_t)0x24da, (q15_t)0xbb4, (q15_t)0x24e4, (q15_t)0xbbb, (q15_t)0x24ef, (q15_t)0xbc2, (q15_t)0x24f9, - (q15_t)0xbca, (q15_t)0x2503, (q15_t)0xbd1, (q15_t)0x250d, (q15_t)0xbd8, (q15_t)0x2518, (q15_t)0xbe0, (q15_t)0x2522, - (q15_t)0xbe7, (q15_t)0x252c, (q15_t)0xbee, (q15_t)0x2536, (q15_t)0xbf5, (q15_t)0x2541, (q15_t)0xbfd, (q15_t)0x254b, - (q15_t)0xc04, (q15_t)0x2555, (q15_t)0xc0b, (q15_t)0x255f, (q15_t)0xc13, (q15_t)0x2569, (q15_t)0xc1a, (q15_t)0x2574, - (q15_t)0xc21, (q15_t)0x257e, (q15_t)0xc29, (q15_t)0x2588, (q15_t)0xc30, (q15_t)0x2592, (q15_t)0xc38, (q15_t)0x259c, - (q15_t)0xc3f, (q15_t)0x25a6, (q15_t)0xc46, (q15_t)0x25b1, (q15_t)0xc4e, (q15_t)0x25bb, (q15_t)0xc55, (q15_t)0x25c5, - (q15_t)0xc5d, (q15_t)0x25cf, (q15_t)0xc64, (q15_t)0x25d9, (q15_t)0xc6b, (q15_t)0x25e3, (q15_t)0xc73, (q15_t)0x25ed, - (q15_t)0xc7a, (q15_t)0x25f8, (q15_t)0xc82, (q15_t)0x2602, (q15_t)0xc89, (q15_t)0x260c, (q15_t)0xc91, (q15_t)0x2616, - (q15_t)0xc98, (q15_t)0x2620, (q15_t)0xca0, (q15_t)0x262a, (q15_t)0xca7, (q15_t)0x2634, (q15_t)0xcaf, (q15_t)0x263e, - (q15_t)0xcb6, (q15_t)0x2648, (q15_t)0xcbe, (q15_t)0x2652, (q15_t)0xcc5, (q15_t)0x265c, (q15_t)0xccd, (q15_t)0x2666, - (q15_t)0xcd4, (q15_t)0x2671, (q15_t)0xcdc, (q15_t)0x267b, (q15_t)0xce3, (q15_t)0x2685, (q15_t)0xceb, (q15_t)0x268f, - (q15_t)0xcf3, (q15_t)0x2699, (q15_t)0xcfa, (q15_t)0x26a3, (q15_t)0xd02, (q15_t)0x26ad, (q15_t)0xd09, (q15_t)0x26b7, - (q15_t)0xd11, (q15_t)0x26c1, (q15_t)0xd19, (q15_t)0x26cb, (q15_t)0xd20, (q15_t)0x26d5, (q15_t)0xd28, (q15_t)0x26df, - (q15_t)0xd30, (q15_t)0x26e9, (q15_t)0xd37, (q15_t)0x26f3, (q15_t)0xd3f, (q15_t)0x26fd, (q15_t)0xd46, (q15_t)0x2707, - (q15_t)0xd4e, (q15_t)0x2711, (q15_t)0xd56, (q15_t)0x271a, (q15_t)0xd5d, (q15_t)0x2724, (q15_t)0xd65, (q15_t)0x272e, - (q15_t)0xd6d, (q15_t)0x2738, (q15_t)0xd75, (q15_t)0x2742, (q15_t)0xd7c, (q15_t)0x274c, (q15_t)0xd84, (q15_t)0x2756, - (q15_t)0xd8c, (q15_t)0x2760, (q15_t)0xd93, (q15_t)0x276a, (q15_t)0xd9b, (q15_t)0x2774, (q15_t)0xda3, (q15_t)0x277e, - (q15_t)0xdab, (q15_t)0x2788, (q15_t)0xdb2, (q15_t)0x2791, (q15_t)0xdba, (q15_t)0x279b, (q15_t)0xdc2, (q15_t)0x27a5, - (q15_t)0xdca, (q15_t)0x27af, (q15_t)0xdd2, (q15_t)0x27b9, (q15_t)0xdd9, (q15_t)0x27c3, (q15_t)0xde1, (q15_t)0x27cd, - (q15_t)0xde9, (q15_t)0x27d6, (q15_t)0xdf1, (q15_t)0x27e0, (q15_t)0xdf9, (q15_t)0x27ea, (q15_t)0xe01, (q15_t)0x27f4, - (q15_t)0xe08, (q15_t)0x27fe, (q15_t)0xe10, (q15_t)0x2808, (q15_t)0xe18, (q15_t)0x2811, (q15_t)0xe20, (q15_t)0x281b, - (q15_t)0xe28, (q15_t)0x2825, (q15_t)0xe30, (q15_t)0x282f, (q15_t)0xe38, (q15_t)0x2838, (q15_t)0xe40, (q15_t)0x2842, - (q15_t)0xe47, (q15_t)0x284c, (q15_t)0xe4f, (q15_t)0x2856, (q15_t)0xe57, (q15_t)0x2860, (q15_t)0xe5f, (q15_t)0x2869, - (q15_t)0xe67, (q15_t)0x2873, (q15_t)0xe6f, (q15_t)0x287d, (q15_t)0xe77, (q15_t)0x2886, (q15_t)0xe7f, (q15_t)0x2890, - (q15_t)0xe87, (q15_t)0x289a, (q15_t)0xe8f, (q15_t)0x28a4, (q15_t)0xe97, (q15_t)0x28ad, (q15_t)0xe9f, (q15_t)0x28b7, - (q15_t)0xea7, (q15_t)0x28c1, (q15_t)0xeaf, (q15_t)0x28ca, (q15_t)0xeb7, (q15_t)0x28d4, (q15_t)0xebf, (q15_t)0x28de, - (q15_t)0xec7, (q15_t)0x28e7, (q15_t)0xecf, (q15_t)0x28f1, (q15_t)0xed7, (q15_t)0x28fb, (q15_t)0xedf, (q15_t)0x2904, - (q15_t)0xee7, (q15_t)0x290e, (q15_t)0xeef, (q15_t)0x2918, (q15_t)0xef7, (q15_t)0x2921, (q15_t)0xeff, (q15_t)0x292b, - (q15_t)0xf07, (q15_t)0x2935, (q15_t)0xf10, (q15_t)0x293e, (q15_t)0xf18, (q15_t)0x2948, (q15_t)0xf20, (q15_t)0x2951, - (q15_t)0xf28, (q15_t)0x295b, (q15_t)0xf30, (q15_t)0x2965, (q15_t)0xf38, (q15_t)0x296e, (q15_t)0xf40, (q15_t)0x2978, - (q15_t)0xf48, (q15_t)0x2981, (q15_t)0xf51, (q15_t)0x298b, (q15_t)0xf59, (q15_t)0x2994, (q15_t)0xf61, (q15_t)0x299e, - (q15_t)0xf69, (q15_t)0x29a7, (q15_t)0xf71, (q15_t)0x29b1, (q15_t)0xf79, (q15_t)0x29bb, (q15_t)0xf82, (q15_t)0x29c4, - (q15_t)0xf8a, (q15_t)0x29ce, (q15_t)0xf92, (q15_t)0x29d7, (q15_t)0xf9a, (q15_t)0x29e1, (q15_t)0xfa3, (q15_t)0x29ea, - (q15_t)0xfab, (q15_t)0x29f4, (q15_t)0xfb3, (q15_t)0x29fd, (q15_t)0xfbb, (q15_t)0x2a07, (q15_t)0xfc4, (q15_t)0x2a10, - (q15_t)0xfcc, (q15_t)0x2a1a, (q15_t)0xfd4, (q15_t)0x2a23, (q15_t)0xfdc, (q15_t)0x2a2c, (q15_t)0xfe5, (q15_t)0x2a36, - (q15_t)0xfed, (q15_t)0x2a3f, (q15_t)0xff5, (q15_t)0x2a49, (q15_t)0xffe, (q15_t)0x2a52, (q15_t)0x1006, (q15_t)0x2a5c, - (q15_t)0x100e, (q15_t)0x2a65, (q15_t)0x1016, (q15_t)0x2a6e, (q15_t)0x101f, (q15_t)0x2a78, (q15_t)0x1027, (q15_t)0x2a81, - (q15_t)0x1030, (q15_t)0x2a8b, (q15_t)0x1038, (q15_t)0x2a94, (q15_t)0x1040, (q15_t)0x2a9d, (q15_t)0x1049, (q15_t)0x2aa7, - (q15_t)0x1051, (q15_t)0x2ab0, (q15_t)0x1059, (q15_t)0x2ab9, (q15_t)0x1062, (q15_t)0x2ac3, (q15_t)0x106a, (q15_t)0x2acc, - (q15_t)0x1073, (q15_t)0x2ad6, (q15_t)0x107b, (q15_t)0x2adf, (q15_t)0x1083, (q15_t)0x2ae8, (q15_t)0x108c, (q15_t)0x2af2, - (q15_t)0x1094, (q15_t)0x2afb, (q15_t)0x109d, (q15_t)0x2b04, (q15_t)0x10a5, (q15_t)0x2b0d, (q15_t)0x10ae, (q15_t)0x2b17, - (q15_t)0x10b6, (q15_t)0x2b20, (q15_t)0x10bf, (q15_t)0x2b29, (q15_t)0x10c7, (q15_t)0x2b33, (q15_t)0x10d0, (q15_t)0x2b3c, - (q15_t)0x10d8, (q15_t)0x2b45, (q15_t)0x10e0, (q15_t)0x2b4e, (q15_t)0x10e9, (q15_t)0x2b58, (q15_t)0x10f2, (q15_t)0x2b61, - (q15_t)0x10fa, (q15_t)0x2b6a, (q15_t)0x1103, (q15_t)0x2b73, (q15_t)0x110b, (q15_t)0x2b7d, (q15_t)0x1114, (q15_t)0x2b86, - (q15_t)0x111c, (q15_t)0x2b8f, (q15_t)0x1125, (q15_t)0x2b98, (q15_t)0x112d, (q15_t)0x2ba1, (q15_t)0x1136, (q15_t)0x2bab, - (q15_t)0x113e, (q15_t)0x2bb4, (q15_t)0x1147, (q15_t)0x2bbd, (q15_t)0x1150, (q15_t)0x2bc6, (q15_t)0x1158, (q15_t)0x2bcf, - (q15_t)0x1161, (q15_t)0x2bd8, (q15_t)0x1169, (q15_t)0x2be2, (q15_t)0x1172, (q15_t)0x2beb, (q15_t)0x117b, (q15_t)0x2bf4, - (q15_t)0x1183, (q15_t)0x2bfd, (q15_t)0x118c, (q15_t)0x2c06, (q15_t)0x1195, (q15_t)0x2c0f, (q15_t)0x119d, (q15_t)0x2c18, - (q15_t)0x11a6, (q15_t)0x2c21, (q15_t)0x11af, (q15_t)0x2c2b, (q15_t)0x11b7, (q15_t)0x2c34, (q15_t)0x11c0, (q15_t)0x2c3d, - (q15_t)0x11c9, (q15_t)0x2c46, (q15_t)0x11d1, (q15_t)0x2c4f, (q15_t)0x11da, (q15_t)0x2c58, (q15_t)0x11e3, (q15_t)0x2c61, - (q15_t)0x11eb, (q15_t)0x2c6a, (q15_t)0x11f4, (q15_t)0x2c73, (q15_t)0x11fd, (q15_t)0x2c7c, (q15_t)0x1206, (q15_t)0x2c85, - (q15_t)0x120e, (q15_t)0x2c8e, (q15_t)0x1217, (q15_t)0x2c97, (q15_t)0x1220, (q15_t)0x2ca0, (q15_t)0x1229, (q15_t)0x2ca9, - (q15_t)0x1231, (q15_t)0x2cb2, (q15_t)0x123a, (q15_t)0x2cbb, (q15_t)0x1243, (q15_t)0x2cc4, (q15_t)0x124c, (q15_t)0x2ccd, - (q15_t)0x1255, (q15_t)0x2cd6, (q15_t)0x125d, (q15_t)0x2cdf, (q15_t)0x1266, (q15_t)0x2ce8, (q15_t)0x126f, (q15_t)0x2cf1, - (q15_t)0x1278, (q15_t)0x2cfa, (q15_t)0x1281, (q15_t)0x2d03, (q15_t)0x128a, (q15_t)0x2d0c, (q15_t)0x1292, (q15_t)0x2d15, - (q15_t)0x129b, (q15_t)0x2d1e, (q15_t)0x12a4, (q15_t)0x2d27, (q15_t)0x12ad, (q15_t)0x2d2f, (q15_t)0x12b6, (q15_t)0x2d38, - (q15_t)0x12bf, (q15_t)0x2d41, (q15_t)0x12c8, (q15_t)0x2d4a, (q15_t)0x12d1, (q15_t)0x2d53, (q15_t)0x12d9, (q15_t)0x2d5c, - (q15_t)0x12e2, (q15_t)0x2d65, (q15_t)0x12eb, (q15_t)0x2d6e, (q15_t)0x12f4, (q15_t)0x2d76, (q15_t)0x12fd, (q15_t)0x2d7f, - (q15_t)0x1306, (q15_t)0x2d88, (q15_t)0x130f, (q15_t)0x2d91, (q15_t)0x1318, (q15_t)0x2d9a, (q15_t)0x1321, (q15_t)0x2da3, - (q15_t)0x132a, (q15_t)0x2dab, (q15_t)0x1333, (q15_t)0x2db4, (q15_t)0x133c, (q15_t)0x2dbd, (q15_t)0x1345, (q15_t)0x2dc6, - (q15_t)0x134e, (q15_t)0x2dcf, (q15_t)0x1357, (q15_t)0x2dd7, (q15_t)0x1360, (q15_t)0x2de0, (q15_t)0x1369, (q15_t)0x2de9, - (q15_t)0x1372, (q15_t)0x2df2, (q15_t)0x137b, (q15_t)0x2dfa, (q15_t)0x1384, (q15_t)0x2e03, (q15_t)0x138d, (q15_t)0x2e0c, - (q15_t)0x1396, (q15_t)0x2e15, (q15_t)0x139f, (q15_t)0x2e1d, (q15_t)0x13a8, (q15_t)0x2e26, (q15_t)0x13b1, (q15_t)0x2e2f, - (q15_t)0x13ba, (q15_t)0x2e37, (q15_t)0x13c3, (q15_t)0x2e40, (q15_t)0x13cc, (q15_t)0x2e49, (q15_t)0x13d5, (q15_t)0x2e51, - (q15_t)0x13df, (q15_t)0x2e5a, (q15_t)0x13e8, (q15_t)0x2e63, (q15_t)0x13f1, (q15_t)0x2e6b, (q15_t)0x13fa, (q15_t)0x2e74, - (q15_t)0x1403, (q15_t)0x2e7d, (q15_t)0x140c, (q15_t)0x2e85, (q15_t)0x1415, (q15_t)0x2e8e, (q15_t)0x141e, (q15_t)0x2e97, - (q15_t)0x1428, (q15_t)0x2e9f, (q15_t)0x1431, (q15_t)0x2ea8, (q15_t)0x143a, (q15_t)0x2eb0, (q15_t)0x1443, (q15_t)0x2eb9, - (q15_t)0x144c, (q15_t)0x2ec2, (q15_t)0x1455, (q15_t)0x2eca, (q15_t)0x145f, (q15_t)0x2ed3, (q15_t)0x1468, (q15_t)0x2edb, - (q15_t)0x1471, (q15_t)0x2ee4, (q15_t)0x147a, (q15_t)0x2eec, (q15_t)0x1483, (q15_t)0x2ef5, (q15_t)0x148d, (q15_t)0x2efd, - (q15_t)0x1496, (q15_t)0x2f06, (q15_t)0x149f, (q15_t)0x2f0e, (q15_t)0x14a8, (q15_t)0x2f17, (q15_t)0x14b2, (q15_t)0x2f20, - (q15_t)0x14bb, (q15_t)0x2f28, (q15_t)0x14c4, (q15_t)0x2f30, (q15_t)0x14cd, (q15_t)0x2f39, (q15_t)0x14d7, (q15_t)0x2f41, - (q15_t)0x14e0, (q15_t)0x2f4a, (q15_t)0x14e9, (q15_t)0x2f52, (q15_t)0x14f3, (q15_t)0x2f5b, (q15_t)0x14fc, (q15_t)0x2f63, - (q15_t)0x1505, (q15_t)0x2f6c, (q15_t)0x150e, (q15_t)0x2f74, (q15_t)0x1518, (q15_t)0x2f7d, (q15_t)0x1521, (q15_t)0x2f85, - (q15_t)0x152a, (q15_t)0x2f8d, (q15_t)0x1534, (q15_t)0x2f96, (q15_t)0x153d, (q15_t)0x2f9e, (q15_t)0x1547, (q15_t)0x2fa7, - (q15_t)0x1550, (q15_t)0x2faf, (q15_t)0x1559, (q15_t)0x2fb7, (q15_t)0x1563, (q15_t)0x2fc0, (q15_t)0x156c, (q15_t)0x2fc8, - (q15_t)0x1575, (q15_t)0x2fd0, (q15_t)0x157f, (q15_t)0x2fd9, (q15_t)0x1588, (q15_t)0x2fe1, (q15_t)0x1592, (q15_t)0x2fea, - (q15_t)0x159b, (q15_t)0x2ff2, (q15_t)0x15a4, (q15_t)0x2ffa, (q15_t)0x15ae, (q15_t)0x3002, (q15_t)0x15b7, (q15_t)0x300b, - (q15_t)0x15c1, (q15_t)0x3013, (q15_t)0x15ca, (q15_t)0x301b, (q15_t)0x15d4, (q15_t)0x3024, (q15_t)0x15dd, (q15_t)0x302c, - (q15_t)0x15e6, (q15_t)0x3034, (q15_t)0x15f0, (q15_t)0x303c, (q15_t)0x15f9, (q15_t)0x3045, (q15_t)0x1603, (q15_t)0x304d, - (q15_t)0x160c, (q15_t)0x3055, (q15_t)0x1616, (q15_t)0x305d, (q15_t)0x161f, (q15_t)0x3066, (q15_t)0x1629, (q15_t)0x306e, - (q15_t)0x1632, (q15_t)0x3076, (q15_t)0x163c, (q15_t)0x307e, (q15_t)0x1645, (q15_t)0x3087, (q15_t)0x164f, (q15_t)0x308f, - (q15_t)0x1659, (q15_t)0x3097, (q15_t)0x1662, (q15_t)0x309f, (q15_t)0x166c, (q15_t)0x30a7, (q15_t)0x1675, (q15_t)0x30af, - (q15_t)0x167f, (q15_t)0x30b8, (q15_t)0x1688, (q15_t)0x30c0, (q15_t)0x1692, (q15_t)0x30c8, (q15_t)0x169b, (q15_t)0x30d0, - (q15_t)0x16a5, (q15_t)0x30d8, (q15_t)0x16af, (q15_t)0x30e0, (q15_t)0x16b8, (q15_t)0x30e8, (q15_t)0x16c2, (q15_t)0x30f0, - (q15_t)0x16cb, (q15_t)0x30f9, (q15_t)0x16d5, (q15_t)0x3101, (q15_t)0x16df, (q15_t)0x3109, (q15_t)0x16e8, (q15_t)0x3111, - (q15_t)0x16f2, (q15_t)0x3119, (q15_t)0x16fc, (q15_t)0x3121, (q15_t)0x1705, (q15_t)0x3129, (q15_t)0x170f, (q15_t)0x3131, - (q15_t)0x1719, (q15_t)0x3139, (q15_t)0x1722, (q15_t)0x3141, (q15_t)0x172c, (q15_t)0x3149, (q15_t)0x1736, (q15_t)0x3151, - (q15_t)0x173f, (q15_t)0x3159, (q15_t)0x1749, (q15_t)0x3161, (q15_t)0x1753, (q15_t)0x3169, (q15_t)0x175c, (q15_t)0x3171, - (q15_t)0x1766, (q15_t)0x3179, (q15_t)0x1770, (q15_t)0x3181, (q15_t)0x177a, (q15_t)0x3189, (q15_t)0x1783, (q15_t)0x3191, - (q15_t)0x178d, (q15_t)0x3199, (q15_t)0x1797, (q15_t)0x31a1, (q15_t)0x17a0, (q15_t)0x31a9, (q15_t)0x17aa, (q15_t)0x31b1, - (q15_t)0x17b4, (q15_t)0x31b9, (q15_t)0x17be, (q15_t)0x31c0, (q15_t)0x17c8, (q15_t)0x31c8, (q15_t)0x17d1, (q15_t)0x31d0, - (q15_t)0x17db, (q15_t)0x31d8, (q15_t)0x17e5, (q15_t)0x31e0, (q15_t)0x17ef, (q15_t)0x31e8, (q15_t)0x17f8, (q15_t)0x31f0, - (q15_t)0x1802, (q15_t)0x31f8, (q15_t)0x180c, (q15_t)0x31ff, (q15_t)0x1816, (q15_t)0x3207, (q15_t)0x1820, (q15_t)0x320f, - (q15_t)0x182a, (q15_t)0x3217, (q15_t)0x1833, (q15_t)0x321f, (q15_t)0x183d, (q15_t)0x3227, (q15_t)0x1847, (q15_t)0x322e, - (q15_t)0x1851, (q15_t)0x3236, (q15_t)0x185b, (q15_t)0x323e, (q15_t)0x1865, (q15_t)0x3246, (q15_t)0x186f, (q15_t)0x324e, - (q15_t)0x1878, (q15_t)0x3255, (q15_t)0x1882, (q15_t)0x325d, (q15_t)0x188c, (q15_t)0x3265, (q15_t)0x1896, (q15_t)0x326d, - (q15_t)0x18a0, (q15_t)0x3274, (q15_t)0x18aa, (q15_t)0x327c, (q15_t)0x18b4, (q15_t)0x3284, (q15_t)0x18be, (q15_t)0x328b, - (q15_t)0x18c8, (q15_t)0x3293, (q15_t)0x18d2, (q15_t)0x329b, (q15_t)0x18dc, (q15_t)0x32a3, (q15_t)0x18e6, (q15_t)0x32aa, - (q15_t)0x18ef, (q15_t)0x32b2, (q15_t)0x18f9, (q15_t)0x32ba, (q15_t)0x1903, (q15_t)0x32c1, (q15_t)0x190d, (q15_t)0x32c9, - (q15_t)0x1917, (q15_t)0x32d0, (q15_t)0x1921, (q15_t)0x32d8, (q15_t)0x192b, (q15_t)0x32e0, (q15_t)0x1935, (q15_t)0x32e7, - (q15_t)0x193f, (q15_t)0x32ef, (q15_t)0x1949, (q15_t)0x32f7, (q15_t)0x1953, (q15_t)0x32fe, (q15_t)0x195d, (q15_t)0x3306, - (q15_t)0x1967, (q15_t)0x330d, (q15_t)0x1971, (q15_t)0x3315, (q15_t)0x197b, (q15_t)0x331d, (q15_t)0x1985, (q15_t)0x3324, - (q15_t)0x198f, (q15_t)0x332c, (q15_t)0x199a, (q15_t)0x3333, (q15_t)0x19a4, (q15_t)0x333b, (q15_t)0x19ae, (q15_t)0x3342, - (q15_t)0x19b8, (q15_t)0x334a, (q15_t)0x19c2, (q15_t)0x3351, (q15_t)0x19cc, (q15_t)0x3359, (q15_t)0x19d6, (q15_t)0x3360, - (q15_t)0x19e0, (q15_t)0x3368, (q15_t)0x19ea, (q15_t)0x336f, (q15_t)0x19f4, (q15_t)0x3377, (q15_t)0x19fe, (q15_t)0x337e, - (q15_t)0x1a08, (q15_t)0x3386, (q15_t)0x1a13, (q15_t)0x338d, (q15_t)0x1a1d, (q15_t)0x3395, (q15_t)0x1a27, (q15_t)0x339c, - (q15_t)0x1a31, (q15_t)0x33a3, (q15_t)0x1a3b, (q15_t)0x33ab, (q15_t)0x1a45, (q15_t)0x33b2, (q15_t)0x1a4f, (q15_t)0x33ba, - (q15_t)0x1a5a, (q15_t)0x33c1, (q15_t)0x1a64, (q15_t)0x33c8, (q15_t)0x1a6e, (q15_t)0x33d0, (q15_t)0x1a78, (q15_t)0x33d7, - (q15_t)0x1a82, (q15_t)0x33df, (q15_t)0x1a8c, (q15_t)0x33e6, (q15_t)0x1a97, (q15_t)0x33ed, (q15_t)0x1aa1, (q15_t)0x33f5, - (q15_t)0x1aab, (q15_t)0x33fc, (q15_t)0x1ab5, (q15_t)0x3403, (q15_t)0x1abf, (q15_t)0x340b, (q15_t)0x1aca, (q15_t)0x3412, - (q15_t)0x1ad4, (q15_t)0x3419, (q15_t)0x1ade, (q15_t)0x3420, (q15_t)0x1ae8, (q15_t)0x3428, (q15_t)0x1af3, (q15_t)0x342f, - (q15_t)0x1afd, (q15_t)0x3436, (q15_t)0x1b07, (q15_t)0x343e, (q15_t)0x1b11, (q15_t)0x3445, (q15_t)0x1b1c, (q15_t)0x344c, - (q15_t)0x1b26, (q15_t)0x3453, (q15_t)0x1b30, (q15_t)0x345b, (q15_t)0x1b3b, (q15_t)0x3462, (q15_t)0x1b45, (q15_t)0x3469, - (q15_t)0x1b4f, (q15_t)0x3470, (q15_t)0x1b59, (q15_t)0x3477, (q15_t)0x1b64, (q15_t)0x347f, (q15_t)0x1b6e, (q15_t)0x3486, - (q15_t)0x1b78, (q15_t)0x348d, (q15_t)0x1b83, (q15_t)0x3494, (q15_t)0x1b8d, (q15_t)0x349b, (q15_t)0x1b97, (q15_t)0x34a2, - (q15_t)0x1ba2, (q15_t)0x34aa, (q15_t)0x1bac, (q15_t)0x34b1, (q15_t)0x1bb6, (q15_t)0x34b8, (q15_t)0x1bc1, (q15_t)0x34bf, - (q15_t)0x1bcb, (q15_t)0x34c6, (q15_t)0x1bd5, (q15_t)0x34cd, (q15_t)0x1be0, (q15_t)0x34d4, (q15_t)0x1bea, (q15_t)0x34db, - (q15_t)0x1bf5, (q15_t)0x34e2, (q15_t)0x1bff, (q15_t)0x34ea, (q15_t)0x1c09, (q15_t)0x34f1, (q15_t)0x1c14, (q15_t)0x34f8, - (q15_t)0x1c1e, (q15_t)0x34ff, (q15_t)0x1c29, (q15_t)0x3506, (q15_t)0x1c33, (q15_t)0x350d, (q15_t)0x1c3d, (q15_t)0x3514, - (q15_t)0x1c48, (q15_t)0x351b, (q15_t)0x1c52, (q15_t)0x3522, (q15_t)0x1c5d, (q15_t)0x3529, (q15_t)0x1c67, (q15_t)0x3530, - (q15_t)0x1c72, (q15_t)0x3537, (q15_t)0x1c7c, (q15_t)0x353e, (q15_t)0x1c86, (q15_t)0x3545, (q15_t)0x1c91, (q15_t)0x354c, - (q15_t)0x1c9b, (q15_t)0x3553, (q15_t)0x1ca6, (q15_t)0x355a, (q15_t)0x1cb0, (q15_t)0x3561, (q15_t)0x1cbb, (q15_t)0x3567, - (q15_t)0x1cc5, (q15_t)0x356e, (q15_t)0x1cd0, (q15_t)0x3575, (q15_t)0x1cda, (q15_t)0x357c, (q15_t)0x1ce5, (q15_t)0x3583, - (q15_t)0x1cef, (q15_t)0x358a, (q15_t)0x1cfa, (q15_t)0x3591, (q15_t)0x1d04, (q15_t)0x3598, (q15_t)0x1d0f, (q15_t)0x359f, - (q15_t)0x1d19, (q15_t)0x35a5, (q15_t)0x1d24, (q15_t)0x35ac, (q15_t)0x1d2e, (q15_t)0x35b3, (q15_t)0x1d39, (q15_t)0x35ba, - (q15_t)0x1d44, (q15_t)0x35c1, (q15_t)0x1d4e, (q15_t)0x35c8, (q15_t)0x1d59, (q15_t)0x35ce, (q15_t)0x1d63, (q15_t)0x35d5, - (q15_t)0x1d6e, (q15_t)0x35dc, (q15_t)0x1d78, (q15_t)0x35e3, (q15_t)0x1d83, (q15_t)0x35ea, (q15_t)0x1d8e, (q15_t)0x35f0, - (q15_t)0x1d98, (q15_t)0x35f7, (q15_t)0x1da3, (q15_t)0x35fe, (q15_t)0x1dad, (q15_t)0x3605, (q15_t)0x1db8, (q15_t)0x360b, - (q15_t)0x1dc3, (q15_t)0x3612, (q15_t)0x1dcd, (q15_t)0x3619, (q15_t)0x1dd8, (q15_t)0x3620, (q15_t)0x1de2, (q15_t)0x3626, - (q15_t)0x1ded, (q15_t)0x362d, (q15_t)0x1df8, (q15_t)0x3634, (q15_t)0x1e02, (q15_t)0x363a, (q15_t)0x1e0d, (q15_t)0x3641, - (q15_t)0x1e18, (q15_t)0x3648, (q15_t)0x1e22, (q15_t)0x364e, (q15_t)0x1e2d, (q15_t)0x3655, (q15_t)0x1e38, (q15_t)0x365c, - (q15_t)0x1e42, (q15_t)0x3662, (q15_t)0x1e4d, (q15_t)0x3669, (q15_t)0x1e58, (q15_t)0x366f, (q15_t)0x1e62, (q15_t)0x3676, - (q15_t)0x1e6d, (q15_t)0x367d, (q15_t)0x1e78, (q15_t)0x3683, (q15_t)0x1e83, (q15_t)0x368a, (q15_t)0x1e8d, (q15_t)0x3690, - (q15_t)0x1e98, (q15_t)0x3697, (q15_t)0x1ea3, (q15_t)0x369d, (q15_t)0x1ead, (q15_t)0x36a4, (q15_t)0x1eb8, (q15_t)0x36ab, - (q15_t)0x1ec3, (q15_t)0x36b1, (q15_t)0x1ece, (q15_t)0x36b8, (q15_t)0x1ed8, (q15_t)0x36be, (q15_t)0x1ee3, (q15_t)0x36c5, - (q15_t)0x1eee, (q15_t)0x36cb, (q15_t)0x1ef9, (q15_t)0x36d2, (q15_t)0x1f03, (q15_t)0x36d8, (q15_t)0x1f0e, (q15_t)0x36df, - (q15_t)0x1f19, (q15_t)0x36e5, (q15_t)0x1f24, (q15_t)0x36eb, (q15_t)0x1f2f, (q15_t)0x36f2, (q15_t)0x1f39, (q15_t)0x36f8, - (q15_t)0x1f44, (q15_t)0x36ff, (q15_t)0x1f4f, (q15_t)0x3705, (q15_t)0x1f5a, (q15_t)0x370c, (q15_t)0x1f65, (q15_t)0x3712, - (q15_t)0x1f6f, (q15_t)0x3718, (q15_t)0x1f7a, (q15_t)0x371f, (q15_t)0x1f85, (q15_t)0x3725, (q15_t)0x1f90, (q15_t)0x372c, - (q15_t)0x1f9b, (q15_t)0x3732, (q15_t)0x1fa5, (q15_t)0x3738, (q15_t)0x1fb0, (q15_t)0x373f, (q15_t)0x1fbb, (q15_t)0x3745, - (q15_t)0x1fc6, (q15_t)0x374b, (q15_t)0x1fd1, (q15_t)0x3752, (q15_t)0x1fdc, (q15_t)0x3758, (q15_t)0x1fe7, (q15_t)0x375e, - (q15_t)0x1ff1, (q15_t)0x3765, (q15_t)0x1ffc, (q15_t)0x376b, (q15_t)0x2007, (q15_t)0x3771, (q15_t)0x2012, (q15_t)0x3777, - (q15_t)0x201d, (q15_t)0x377e, (q15_t)0x2028, (q15_t)0x3784, (q15_t)0x2033, (q15_t)0x378a, (q15_t)0x203e, (q15_t)0x3790, - (q15_t)0x2049, (q15_t)0x3797, (q15_t)0x2054, (q15_t)0x379d, (q15_t)0x205e, (q15_t)0x37a3, (q15_t)0x2069, (q15_t)0x37a9, - (q15_t)0x2074, (q15_t)0x37b0, (q15_t)0x207f, (q15_t)0x37b6, (q15_t)0x208a, (q15_t)0x37bc, (q15_t)0x2095, (q15_t)0x37c2, - (q15_t)0x20a0, (q15_t)0x37c8, (q15_t)0x20ab, (q15_t)0x37ce, (q15_t)0x20b6, (q15_t)0x37d5, (q15_t)0x20c1, (q15_t)0x37db, - (q15_t)0x20cc, (q15_t)0x37e1, (q15_t)0x20d7, (q15_t)0x37e7, (q15_t)0x20e2, (q15_t)0x37ed, (q15_t)0x20ed, (q15_t)0x37f3, - (q15_t)0x20f8, (q15_t)0x37f9, (q15_t)0x2103, (q15_t)0x37ff, (q15_t)0x210e, (q15_t)0x3805, (q15_t)0x2119, (q15_t)0x380b, - (q15_t)0x2124, (q15_t)0x3812, (q15_t)0x212f, (q15_t)0x3818, (q15_t)0x213a, (q15_t)0x381e, (q15_t)0x2145, (q15_t)0x3824, - (q15_t)0x2150, (q15_t)0x382a, (q15_t)0x215b, (q15_t)0x3830, (q15_t)0x2166, (q15_t)0x3836, (q15_t)0x2171, (q15_t)0x383c, - (q15_t)0x217c, (q15_t)0x3842, (q15_t)0x2187, (q15_t)0x3848, (q15_t)0x2192, (q15_t)0x384e, (q15_t)0x219d, (q15_t)0x3854, - (q15_t)0x21a8, (q15_t)0x385a, (q15_t)0x21b3, (q15_t)0x3860, (q15_t)0x21be, (q15_t)0x3866, (q15_t)0x21ca, (q15_t)0x386b, - (q15_t)0x21d5, (q15_t)0x3871, (q15_t)0x21e0, (q15_t)0x3877, (q15_t)0x21eb, (q15_t)0x387d, (q15_t)0x21f6, (q15_t)0x3883, - (q15_t)0x2201, (q15_t)0x3889, (q15_t)0x220c, (q15_t)0x388f, (q15_t)0x2217, (q15_t)0x3895, (q15_t)0x2222, (q15_t)0x389b, - (q15_t)0x222d, (q15_t)0x38a1, (q15_t)0x2239, (q15_t)0x38a6, (q15_t)0x2244, (q15_t)0x38ac, (q15_t)0x224f, (q15_t)0x38b2, - (q15_t)0x225a, (q15_t)0x38b8, (q15_t)0x2265, (q15_t)0x38be, (q15_t)0x2270, (q15_t)0x38c3, (q15_t)0x227b, (q15_t)0x38c9, - (q15_t)0x2287, (q15_t)0x38cf, (q15_t)0x2292, (q15_t)0x38d5, (q15_t)0x229d, (q15_t)0x38db, (q15_t)0x22a8, (q15_t)0x38e0, - (q15_t)0x22b3, (q15_t)0x38e6, (q15_t)0x22be, (q15_t)0x38ec, (q15_t)0x22ca, (q15_t)0x38f2, (q15_t)0x22d5, (q15_t)0x38f7, - (q15_t)0x22e0, (q15_t)0x38fd, (q15_t)0x22eb, (q15_t)0x3903, (q15_t)0x22f6, (q15_t)0x3909, (q15_t)0x2301, (q15_t)0x390e, - (q15_t)0x230d, (q15_t)0x3914, (q15_t)0x2318, (q15_t)0x391a, (q15_t)0x2323, (q15_t)0x391f, (q15_t)0x232e, (q15_t)0x3925, - (q15_t)0x233a, (q15_t)0x392b, (q15_t)0x2345, (q15_t)0x3930, (q15_t)0x2350, (q15_t)0x3936, (q15_t)0x235b, (q15_t)0x393b, - (q15_t)0x2367, (q15_t)0x3941, (q15_t)0x2372, (q15_t)0x3947, (q15_t)0x237d, (q15_t)0x394c, (q15_t)0x2388, (q15_t)0x3952, - (q15_t)0x2394, (q15_t)0x3958, (q15_t)0x239f, (q15_t)0x395d, (q15_t)0x23aa, (q15_t)0x3963, (q15_t)0x23b5, (q15_t)0x3968, - (q15_t)0x23c1, (q15_t)0x396e, (q15_t)0x23cc, (q15_t)0x3973, (q15_t)0x23d7, (q15_t)0x3979, (q15_t)0x23e2, (q15_t)0x397e, - (q15_t)0x23ee, (q15_t)0x3984, (q15_t)0x23f9, (q15_t)0x3989, (q15_t)0x2404, (q15_t)0x398f, (q15_t)0x2410, (q15_t)0x3994, - (q15_t)0x241b, (q15_t)0x399a, (q15_t)0x2426, (q15_t)0x399f, (q15_t)0x2432, (q15_t)0x39a5, (q15_t)0x243d, (q15_t)0x39aa, - (q15_t)0x2448, (q15_t)0x39b0, (q15_t)0x2454, (q15_t)0x39b5, (q15_t)0x245f, (q15_t)0x39bb, (q15_t)0x246a, (q15_t)0x39c0, - (q15_t)0x2476, (q15_t)0x39c5, (q15_t)0x2481, (q15_t)0x39cb, (q15_t)0x248c, (q15_t)0x39d0, (q15_t)0x2498, (q15_t)0x39d6, - (q15_t)0x24a3, (q15_t)0x39db, (q15_t)0x24ae, (q15_t)0x39e0, (q15_t)0x24ba, (q15_t)0x39e6, (q15_t)0x24c5, (q15_t)0x39eb, - (q15_t)0x24d0, (q15_t)0x39f0, (q15_t)0x24dc, (q15_t)0x39f6, (q15_t)0x24e7, (q15_t)0x39fb, (q15_t)0x24f3, (q15_t)0x3a00, - (q15_t)0x24fe, (q15_t)0x3a06, (q15_t)0x2509, (q15_t)0x3a0b, (q15_t)0x2515, (q15_t)0x3a10, (q15_t)0x2520, (q15_t)0x3a16, - (q15_t)0x252c, (q15_t)0x3a1b, (q15_t)0x2537, (q15_t)0x3a20, (q15_t)0x2542, (q15_t)0x3a25, (q15_t)0x254e, (q15_t)0x3a2b, - (q15_t)0x2559, (q15_t)0x3a30, (q15_t)0x2565, (q15_t)0x3a35, (q15_t)0x2570, (q15_t)0x3a3a, (q15_t)0x257c, (q15_t)0x3a3f, - (q15_t)0x2587, (q15_t)0x3a45, (q15_t)0x2592, (q15_t)0x3a4a, (q15_t)0x259e, (q15_t)0x3a4f, (q15_t)0x25a9, (q15_t)0x3a54, - (q15_t)0x25b5, (q15_t)0x3a59, (q15_t)0x25c0, (q15_t)0x3a5f, (q15_t)0x25cc, (q15_t)0x3a64, (q15_t)0x25d7, (q15_t)0x3a69, - (q15_t)0x25e3, (q15_t)0x3a6e, (q15_t)0x25ee, (q15_t)0x3a73, (q15_t)0x25fa, (q15_t)0x3a78, (q15_t)0x2605, (q15_t)0x3a7d, - (q15_t)0x2611, (q15_t)0x3a82, (q15_t)0x261c, (q15_t)0x3a88, (q15_t)0x2628, (q15_t)0x3a8d, (q15_t)0x2633, (q15_t)0x3a92, - (q15_t)0x263f, (q15_t)0x3a97, (q15_t)0x264a, (q15_t)0x3a9c, (q15_t)0x2656, (q15_t)0x3aa1, (q15_t)0x2661, (q15_t)0x3aa6, - (q15_t)0x266d, (q15_t)0x3aab, (q15_t)0x2678, (q15_t)0x3ab0, (q15_t)0x2684, (q15_t)0x3ab5, (q15_t)0x268f, (q15_t)0x3aba, - (q15_t)0x269b, (q15_t)0x3abf, (q15_t)0x26a6, (q15_t)0x3ac4, (q15_t)0x26b2, (q15_t)0x3ac9, (q15_t)0x26bd, (q15_t)0x3ace, - (q15_t)0x26c9, (q15_t)0x3ad3, (q15_t)0x26d4, (q15_t)0x3ad8, (q15_t)0x26e0, (q15_t)0x3add, (q15_t)0x26ec, (q15_t)0x3ae2, - (q15_t)0x26f7, (q15_t)0x3ae6, (q15_t)0x2703, (q15_t)0x3aeb, (q15_t)0x270e, (q15_t)0x3af0, (q15_t)0x271a, (q15_t)0x3af5, - (q15_t)0x2725, (q15_t)0x3afa, (q15_t)0x2731, (q15_t)0x3aff, (q15_t)0x273d, (q15_t)0x3b04, (q15_t)0x2748, (q15_t)0x3b09, - (q15_t)0x2754, (q15_t)0x3b0e, (q15_t)0x275f, (q15_t)0x3b12, (q15_t)0x276b, (q15_t)0x3b17, (q15_t)0x2777, (q15_t)0x3b1c, - (q15_t)0x2782, (q15_t)0x3b21, (q15_t)0x278e, (q15_t)0x3b26, (q15_t)0x2799, (q15_t)0x3b2a, (q15_t)0x27a5, (q15_t)0x3b2f, - (q15_t)0x27b1, (q15_t)0x3b34, (q15_t)0x27bc, (q15_t)0x3b39, (q15_t)0x27c8, (q15_t)0x3b3e, (q15_t)0x27d3, (q15_t)0x3b42, - (q15_t)0x27df, (q15_t)0x3b47, (q15_t)0x27eb, (q15_t)0x3b4c, (q15_t)0x27f6, (q15_t)0x3b50, (q15_t)0x2802, (q15_t)0x3b55, - (q15_t)0x280e, (q15_t)0x3b5a, (q15_t)0x2819, (q15_t)0x3b5f, (q15_t)0x2825, (q15_t)0x3b63, (q15_t)0x2831, (q15_t)0x3b68, - (q15_t)0x283c, (q15_t)0x3b6d, (q15_t)0x2848, (q15_t)0x3b71, (q15_t)0x2854, (q15_t)0x3b76, (q15_t)0x285f, (q15_t)0x3b7b, - (q15_t)0x286b, (q15_t)0x3b7f, (q15_t)0x2877, (q15_t)0x3b84, (q15_t)0x2882, (q15_t)0x3b88, (q15_t)0x288e, (q15_t)0x3b8d, - (q15_t)0x289a, (q15_t)0x3b92, (q15_t)0x28a5, (q15_t)0x3b96, (q15_t)0x28b1, (q15_t)0x3b9b, (q15_t)0x28bd, (q15_t)0x3b9f, - (q15_t)0x28c9, (q15_t)0x3ba4, (q15_t)0x28d4, (q15_t)0x3ba9, (q15_t)0x28e0, (q15_t)0x3bad, (q15_t)0x28ec, (q15_t)0x3bb2, - (q15_t)0x28f7, (q15_t)0x3bb6, (q15_t)0x2903, (q15_t)0x3bbb, (q15_t)0x290f, (q15_t)0x3bbf, (q15_t)0x291b, (q15_t)0x3bc4, - (q15_t)0x2926, (q15_t)0x3bc8, (q15_t)0x2932, (q15_t)0x3bcd, (q15_t)0x293e, (q15_t)0x3bd1, (q15_t)0x294a, (q15_t)0x3bd6, - (q15_t)0x2955, (q15_t)0x3bda, (q15_t)0x2961, (q15_t)0x3bde, (q15_t)0x296d, (q15_t)0x3be3, (q15_t)0x2979, (q15_t)0x3be7, - (q15_t)0x2984, (q15_t)0x3bec, (q15_t)0x2990, (q15_t)0x3bf0, (q15_t)0x299c, (q15_t)0x3bf5, (q15_t)0x29a8, (q15_t)0x3bf9, - (q15_t)0x29b4, (q15_t)0x3bfd, (q15_t)0x29bf, (q15_t)0x3c02, (q15_t)0x29cb, (q15_t)0x3c06, (q15_t)0x29d7, (q15_t)0x3c0a, - (q15_t)0x29e3, (q15_t)0x3c0f, (q15_t)0x29ee, (q15_t)0x3c13, (q15_t)0x29fa, (q15_t)0x3c17, (q15_t)0x2a06, (q15_t)0x3c1c, - (q15_t)0x2a12, (q15_t)0x3c20, (q15_t)0x2a1e, (q15_t)0x3c24, (q15_t)0x2a29, (q15_t)0x3c29, (q15_t)0x2a35, (q15_t)0x3c2d, - (q15_t)0x2a41, (q15_t)0x3c31, (q15_t)0x2a4d, (q15_t)0x3c36, (q15_t)0x2a59, (q15_t)0x3c3a, (q15_t)0x2a65, (q15_t)0x3c3e, - (q15_t)0x2a70, (q15_t)0x3c42, (q15_t)0x2a7c, (q15_t)0x3c46, (q15_t)0x2a88, (q15_t)0x3c4b, (q15_t)0x2a94, (q15_t)0x3c4f, - (q15_t)0x2aa0, (q15_t)0x3c53, (q15_t)0x2aac, (q15_t)0x3c57, (q15_t)0x2ab7, (q15_t)0x3c5b, (q15_t)0x2ac3, (q15_t)0x3c60, - (q15_t)0x2acf, (q15_t)0x3c64, (q15_t)0x2adb, (q15_t)0x3c68, (q15_t)0x2ae7, (q15_t)0x3c6c, (q15_t)0x2af3, (q15_t)0x3c70, - (q15_t)0x2aff, (q15_t)0x3c74, (q15_t)0x2b0a, (q15_t)0x3c79, (q15_t)0x2b16, (q15_t)0x3c7d, (q15_t)0x2b22, (q15_t)0x3c81, - (q15_t)0x2b2e, (q15_t)0x3c85, (q15_t)0x2b3a, (q15_t)0x3c89, (q15_t)0x2b46, (q15_t)0x3c8d, (q15_t)0x2b52, (q15_t)0x3c91, - (q15_t)0x2b5e, (q15_t)0x3c95, (q15_t)0x2b6a, (q15_t)0x3c99, (q15_t)0x2b75, (q15_t)0x3c9d, (q15_t)0x2b81, (q15_t)0x3ca1, - (q15_t)0x2b8d, (q15_t)0x3ca5, (q15_t)0x2b99, (q15_t)0x3ca9, (q15_t)0x2ba5, (q15_t)0x3cad, (q15_t)0x2bb1, (q15_t)0x3cb1, - (q15_t)0x2bbd, (q15_t)0x3cb5, (q15_t)0x2bc9, (q15_t)0x3cb9, (q15_t)0x2bd5, (q15_t)0x3cbd, (q15_t)0x2be1, (q15_t)0x3cc1, - (q15_t)0x2bed, (q15_t)0x3cc5, (q15_t)0x2bf9, (q15_t)0x3cc9, (q15_t)0x2c05, (q15_t)0x3ccd, (q15_t)0x2c10, (q15_t)0x3cd1, - (q15_t)0x2c1c, (q15_t)0x3cd5, (q15_t)0x2c28, (q15_t)0x3cd9, (q15_t)0x2c34, (q15_t)0x3cdd, (q15_t)0x2c40, (q15_t)0x3ce0, - (q15_t)0x2c4c, (q15_t)0x3ce4, (q15_t)0x2c58, (q15_t)0x3ce8, (q15_t)0x2c64, (q15_t)0x3cec, (q15_t)0x2c70, (q15_t)0x3cf0, - (q15_t)0x2c7c, (q15_t)0x3cf4, (q15_t)0x2c88, (q15_t)0x3cf8, (q15_t)0x2c94, (q15_t)0x3cfb, (q15_t)0x2ca0, (q15_t)0x3cff, - (q15_t)0x2cac, (q15_t)0x3d03, (q15_t)0x2cb8, (q15_t)0x3d07, (q15_t)0x2cc4, (q15_t)0x3d0b, (q15_t)0x2cd0, (q15_t)0x3d0e, - (q15_t)0x2cdc, (q15_t)0x3d12, (q15_t)0x2ce8, (q15_t)0x3d16, (q15_t)0x2cf4, (q15_t)0x3d1a, (q15_t)0x2d00, (q15_t)0x3d1d, - (q15_t)0x2d0c, (q15_t)0x3d21, (q15_t)0x2d18, (q15_t)0x3d25, (q15_t)0x2d24, (q15_t)0x3d28, (q15_t)0x2d30, (q15_t)0x3d2c, - (q15_t)0x2d3c, (q15_t)0x3d30, (q15_t)0x2d48, (q15_t)0x3d34, (q15_t)0x2d54, (q15_t)0x3d37, (q15_t)0x2d60, (q15_t)0x3d3b, - (q15_t)0x2d6c, (q15_t)0x3d3f, (q15_t)0x2d78, (q15_t)0x3d42, (q15_t)0x2d84, (q15_t)0x3d46, (q15_t)0x2d90, (q15_t)0x3d49, - (q15_t)0x2d9c, (q15_t)0x3d4d, (q15_t)0x2da8, (q15_t)0x3d51, (q15_t)0x2db4, (q15_t)0x3d54, (q15_t)0x2dc0, (q15_t)0x3d58, - (q15_t)0x2dcc, (q15_t)0x3d5b, (q15_t)0x2dd8, (q15_t)0x3d5f, (q15_t)0x2de4, (q15_t)0x3d63, (q15_t)0x2df0, (q15_t)0x3d66, - (q15_t)0x2dfc, (q15_t)0x3d6a, (q15_t)0x2e09, (q15_t)0x3d6d, (q15_t)0x2e15, (q15_t)0x3d71, (q15_t)0x2e21, (q15_t)0x3d74, - (q15_t)0x2e2d, (q15_t)0x3d78, (q15_t)0x2e39, (q15_t)0x3d7b, (q15_t)0x2e45, (q15_t)0x3d7f, (q15_t)0x2e51, (q15_t)0x3d82, - (q15_t)0x2e5d, (q15_t)0x3d86, (q15_t)0x2e69, (q15_t)0x3d89, (q15_t)0x2e75, (q15_t)0x3d8d, (q15_t)0x2e81, (q15_t)0x3d90, - (q15_t)0x2e8d, (q15_t)0x3d93, (q15_t)0x2e99, (q15_t)0x3d97, (q15_t)0x2ea6, (q15_t)0x3d9a, (q15_t)0x2eb2, (q15_t)0x3d9e, - (q15_t)0x2ebe, (q15_t)0x3da1, (q15_t)0x2eca, (q15_t)0x3da4, (q15_t)0x2ed6, (q15_t)0x3da8, (q15_t)0x2ee2, (q15_t)0x3dab, - (q15_t)0x2eee, (q15_t)0x3daf, (q15_t)0x2efa, (q15_t)0x3db2, (q15_t)0x2f06, (q15_t)0x3db5, (q15_t)0x2f13, (q15_t)0x3db9, - (q15_t)0x2f1f, (q15_t)0x3dbc, (q15_t)0x2f2b, (q15_t)0x3dbf, (q15_t)0x2f37, (q15_t)0x3dc2, (q15_t)0x2f43, (q15_t)0x3dc6, - (q15_t)0x2f4f, (q15_t)0x3dc9, (q15_t)0x2f5b, (q15_t)0x3dcc, (q15_t)0x2f67, (q15_t)0x3dd0, (q15_t)0x2f74, (q15_t)0x3dd3, - (q15_t)0x2f80, (q15_t)0x3dd6, (q15_t)0x2f8c, (q15_t)0x3dd9, (q15_t)0x2f98, (q15_t)0x3ddd, (q15_t)0x2fa4, (q15_t)0x3de0, - (q15_t)0x2fb0, (q15_t)0x3de3, (q15_t)0x2fbc, (q15_t)0x3de6, (q15_t)0x2fc9, (q15_t)0x3de9, (q15_t)0x2fd5, (q15_t)0x3ded, - (q15_t)0x2fe1, (q15_t)0x3df0, (q15_t)0x2fed, (q15_t)0x3df3, (q15_t)0x2ff9, (q15_t)0x3df6, (q15_t)0x3005, (q15_t)0x3df9, - (q15_t)0x3012, (q15_t)0x3dfc, (q15_t)0x301e, (q15_t)0x3dff, (q15_t)0x302a, (q15_t)0x3e03, (q15_t)0x3036, (q15_t)0x3e06, - (q15_t)0x3042, (q15_t)0x3e09, (q15_t)0x304e, (q15_t)0x3e0c, (q15_t)0x305b, (q15_t)0x3e0f, (q15_t)0x3067, (q15_t)0x3e12, - (q15_t)0x3073, (q15_t)0x3e15, (q15_t)0x307f, (q15_t)0x3e18, (q15_t)0x308b, (q15_t)0x3e1b, (q15_t)0x3098, (q15_t)0x3e1e, - (q15_t)0x30a4, (q15_t)0x3e21, (q15_t)0x30b0, (q15_t)0x3e24, (q15_t)0x30bc, (q15_t)0x3e27, (q15_t)0x30c8, (q15_t)0x3e2a, - (q15_t)0x30d5, (q15_t)0x3e2d, (q15_t)0x30e1, (q15_t)0x3e30, (q15_t)0x30ed, (q15_t)0x3e33, (q15_t)0x30f9, (q15_t)0x3e36, - (q15_t)0x3105, (q15_t)0x3e39, (q15_t)0x3112, (q15_t)0x3e3c, (q15_t)0x311e, (q15_t)0x3e3f, (q15_t)0x312a, (q15_t)0x3e42, - (q15_t)0x3136, (q15_t)0x3e45, (q15_t)0x3143, (q15_t)0x3e48, (q15_t)0x314f, (q15_t)0x3e4a, (q15_t)0x315b, (q15_t)0x3e4d, - (q15_t)0x3167, (q15_t)0x3e50, (q15_t)0x3174, (q15_t)0x3e53, (q15_t)0x3180, (q15_t)0x3e56, (q15_t)0x318c, (q15_t)0x3e59, - (q15_t)0x3198, (q15_t)0x3e5c, (q15_t)0x31a4, (q15_t)0x3e5e, (q15_t)0x31b1, (q15_t)0x3e61, (q15_t)0x31bd, (q15_t)0x3e64, - (q15_t)0x31c9, (q15_t)0x3e67, (q15_t)0x31d5, (q15_t)0x3e6a, (q15_t)0x31e2, (q15_t)0x3e6c, (q15_t)0x31ee, (q15_t)0x3e6f, - (q15_t)0x31fa, (q15_t)0x3e72, (q15_t)0x3207, (q15_t)0x3e75, (q15_t)0x3213, (q15_t)0x3e77, (q15_t)0x321f, (q15_t)0x3e7a, - (q15_t)0x322b, (q15_t)0x3e7d, (q15_t)0x3238, (q15_t)0x3e80, (q15_t)0x3244, (q15_t)0x3e82, (q15_t)0x3250, (q15_t)0x3e85, - (q15_t)0x325c, (q15_t)0x3e88, (q15_t)0x3269, (q15_t)0x3e8a, (q15_t)0x3275, (q15_t)0x3e8d, (q15_t)0x3281, (q15_t)0x3e90, - (q15_t)0x328e, (q15_t)0x3e92, (q15_t)0x329a, (q15_t)0x3e95, (q15_t)0x32a6, (q15_t)0x3e98, (q15_t)0x32b2, (q15_t)0x3e9a, - (q15_t)0x32bf, (q15_t)0x3e9d, (q15_t)0x32cb, (q15_t)0x3e9f, (q15_t)0x32d7, (q15_t)0x3ea2, (q15_t)0x32e4, (q15_t)0x3ea5, - (q15_t)0x32f0, (q15_t)0x3ea7, (q15_t)0x32fc, (q15_t)0x3eaa, (q15_t)0x3308, (q15_t)0x3eac, (q15_t)0x3315, (q15_t)0x3eaf, - (q15_t)0x3321, (q15_t)0x3eb1, (q15_t)0x332d, (q15_t)0x3eb4, (q15_t)0x333a, (q15_t)0x3eb6, (q15_t)0x3346, (q15_t)0x3eb9, - (q15_t)0x3352, (q15_t)0x3ebb, (q15_t)0x335f, (q15_t)0x3ebe, (q15_t)0x336b, (q15_t)0x3ec0, (q15_t)0x3377, (q15_t)0x3ec3, - (q15_t)0x3384, (q15_t)0x3ec5, (q15_t)0x3390, (q15_t)0x3ec8, (q15_t)0x339c, (q15_t)0x3eca, (q15_t)0x33a9, (q15_t)0x3ecc, - (q15_t)0x33b5, (q15_t)0x3ecf, (q15_t)0x33c1, (q15_t)0x3ed1, (q15_t)0x33ce, (q15_t)0x3ed4, (q15_t)0x33da, (q15_t)0x3ed6, - (q15_t)0x33e6, (q15_t)0x3ed8, (q15_t)0x33f3, (q15_t)0x3edb, (q15_t)0x33ff, (q15_t)0x3edd, (q15_t)0x340b, (q15_t)0x3ee0, - (q15_t)0x3418, (q15_t)0x3ee2, (q15_t)0x3424, (q15_t)0x3ee4, (q15_t)0x3430, (q15_t)0x3ee7, (q15_t)0x343d, (q15_t)0x3ee9, - (q15_t)0x3449, (q15_t)0x3eeb, (q15_t)0x3455, (q15_t)0x3eed, (q15_t)0x3462, (q15_t)0x3ef0, (q15_t)0x346e, (q15_t)0x3ef2, - (q15_t)0x347b, (q15_t)0x3ef4, (q15_t)0x3487, (q15_t)0x3ef7, (q15_t)0x3493, (q15_t)0x3ef9, (q15_t)0x34a0, (q15_t)0x3efb, - (q15_t)0x34ac, (q15_t)0x3efd, (q15_t)0x34b8, (q15_t)0x3f00, (q15_t)0x34c5, (q15_t)0x3f02, (q15_t)0x34d1, (q15_t)0x3f04, - (q15_t)0x34dd, (q15_t)0x3f06, (q15_t)0x34ea, (q15_t)0x3f08, (q15_t)0x34f6, (q15_t)0x3f0a, (q15_t)0x3503, (q15_t)0x3f0d, - (q15_t)0x350f, (q15_t)0x3f0f, (q15_t)0x351b, (q15_t)0x3f11, (q15_t)0x3528, (q15_t)0x3f13, (q15_t)0x3534, (q15_t)0x3f15, - (q15_t)0x3540, (q15_t)0x3f17, (q15_t)0x354d, (q15_t)0x3f19, (q15_t)0x3559, (q15_t)0x3f1c, (q15_t)0x3566, (q15_t)0x3f1e, - (q15_t)0x3572, (q15_t)0x3f20, (q15_t)0x357e, (q15_t)0x3f22, (q15_t)0x358b, (q15_t)0x3f24, (q15_t)0x3597, (q15_t)0x3f26, - (q15_t)0x35a4, (q15_t)0x3f28, (q15_t)0x35b0, (q15_t)0x3f2a, (q15_t)0x35bc, (q15_t)0x3f2c, (q15_t)0x35c9, (q15_t)0x3f2e, - (q15_t)0x35d5, (q15_t)0x3f30, (q15_t)0x35e2, (q15_t)0x3f32, (q15_t)0x35ee, (q15_t)0x3f34, (q15_t)0x35fa, (q15_t)0x3f36, - (q15_t)0x3607, (q15_t)0x3f38, (q15_t)0x3613, (q15_t)0x3f3a, (q15_t)0x3620, (q15_t)0x3f3c, (q15_t)0x362c, (q15_t)0x3f3e, - (q15_t)0x3639, (q15_t)0x3f40, (q15_t)0x3645, (q15_t)0x3f42, (q15_t)0x3651, (q15_t)0x3f43, (q15_t)0x365e, (q15_t)0x3f45, - (q15_t)0x366a, (q15_t)0x3f47, (q15_t)0x3677, (q15_t)0x3f49, (q15_t)0x3683, (q15_t)0x3f4b, (q15_t)0x3690, (q15_t)0x3f4d, - (q15_t)0x369c, (q15_t)0x3f4f, (q15_t)0x36a8, (q15_t)0x3f51, (q15_t)0x36b5, (q15_t)0x3f52, (q15_t)0x36c1, (q15_t)0x3f54, - (q15_t)0x36ce, (q15_t)0x3f56, (q15_t)0x36da, (q15_t)0x3f58, (q15_t)0x36e7, (q15_t)0x3f5a, (q15_t)0x36f3, (q15_t)0x3f5b, - (q15_t)0x36ff, (q15_t)0x3f5d, (q15_t)0x370c, (q15_t)0x3f5f, (q15_t)0x3718, (q15_t)0x3f61, (q15_t)0x3725, (q15_t)0x3f62, - (q15_t)0x3731, (q15_t)0x3f64, (q15_t)0x373e, (q15_t)0x3f66, (q15_t)0x374a, (q15_t)0x3f68, (q15_t)0x3757, (q15_t)0x3f69, - (q15_t)0x3763, (q15_t)0x3f6b, (q15_t)0x376f, (q15_t)0x3f6d, (q15_t)0x377c, (q15_t)0x3f6e, (q15_t)0x3788, (q15_t)0x3f70, - (q15_t)0x3795, (q15_t)0x3f72, (q15_t)0x37a1, (q15_t)0x3f73, (q15_t)0x37ae, (q15_t)0x3f75, (q15_t)0x37ba, (q15_t)0x3f77, - (q15_t)0x37c7, (q15_t)0x3f78, (q15_t)0x37d3, (q15_t)0x3f7a, (q15_t)0x37e0, (q15_t)0x3f7b, (q15_t)0x37ec, (q15_t)0x3f7d, - (q15_t)0x37f9, (q15_t)0x3f7f, (q15_t)0x3805, (q15_t)0x3f80, (q15_t)0x3811, (q15_t)0x3f82, (q15_t)0x381e, (q15_t)0x3f83, - (q15_t)0x382a, (q15_t)0x3f85, (q15_t)0x3837, (q15_t)0x3f86, (q15_t)0x3843, (q15_t)0x3f88, (q15_t)0x3850, (q15_t)0x3f89, - (q15_t)0x385c, (q15_t)0x3f8b, (q15_t)0x3869, (q15_t)0x3f8c, (q15_t)0x3875, (q15_t)0x3f8e, (q15_t)0x3882, (q15_t)0x3f8f, - (q15_t)0x388e, (q15_t)0x3f91, (q15_t)0x389b, (q15_t)0x3f92, (q15_t)0x38a7, (q15_t)0x3f94, (q15_t)0x38b4, (q15_t)0x3f95, - (q15_t)0x38c0, (q15_t)0x3f97, (q15_t)0x38cd, (q15_t)0x3f98, (q15_t)0x38d9, (q15_t)0x3f99, (q15_t)0x38e6, (q15_t)0x3f9b, - (q15_t)0x38f2, (q15_t)0x3f9c, (q15_t)0x38ff, (q15_t)0x3f9e, (q15_t)0x390b, (q15_t)0x3f9f, (q15_t)0x3918, (q15_t)0x3fa0, - (q15_t)0x3924, (q15_t)0x3fa2, (q15_t)0x3931, (q15_t)0x3fa3, (q15_t)0x393d, (q15_t)0x3fa4, (q15_t)0x394a, (q15_t)0x3fa6, - (q15_t)0x3956, (q15_t)0x3fa7, (q15_t)0x3963, (q15_t)0x3fa8, (q15_t)0x396f, (q15_t)0x3faa, (q15_t)0x397c, (q15_t)0x3fab, - (q15_t)0x3988, (q15_t)0x3fac, (q15_t)0x3995, (q15_t)0x3fad, (q15_t)0x39a1, (q15_t)0x3faf, (q15_t)0x39ae, (q15_t)0x3fb0, - (q15_t)0x39ba, (q15_t)0x3fb1, (q15_t)0x39c7, (q15_t)0x3fb2, (q15_t)0x39d3, (q15_t)0x3fb4, (q15_t)0x39e0, (q15_t)0x3fb5, - (q15_t)0x39ec, (q15_t)0x3fb6, (q15_t)0x39f9, (q15_t)0x3fb7, (q15_t)0x3a05, (q15_t)0x3fb8, (q15_t)0x3a12, (q15_t)0x3fb9, - (q15_t)0x3a1e, (q15_t)0x3fbb, (q15_t)0x3a2b, (q15_t)0x3fbc, (q15_t)0x3a37, (q15_t)0x3fbd, (q15_t)0x3a44, (q15_t)0x3fbe, - (q15_t)0x3a50, (q15_t)0x3fbf, (q15_t)0x3a5d, (q15_t)0x3fc0, (q15_t)0x3a69, (q15_t)0x3fc1, (q15_t)0x3a76, (q15_t)0x3fc3, - (q15_t)0x3a82, (q15_t)0x3fc4, (q15_t)0x3a8f, (q15_t)0x3fc5, (q15_t)0x3a9b, (q15_t)0x3fc6, (q15_t)0x3aa8, (q15_t)0x3fc7, - (q15_t)0x3ab4, (q15_t)0x3fc8, (q15_t)0x3ac1, (q15_t)0x3fc9, (q15_t)0x3acd, (q15_t)0x3fca, (q15_t)0x3ada, (q15_t)0x3fcb, - (q15_t)0x3ae6, (q15_t)0x3fcc, (q15_t)0x3af3, (q15_t)0x3fcd, (q15_t)0x3b00, (q15_t)0x3fce, (q15_t)0x3b0c, (q15_t)0x3fcf, - (q15_t)0x3b19, (q15_t)0x3fd0, (q15_t)0x3b25, (q15_t)0x3fd1, (q15_t)0x3b32, (q15_t)0x3fd2, (q15_t)0x3b3e, (q15_t)0x3fd3, - (q15_t)0x3b4b, (q15_t)0x3fd4, (q15_t)0x3b57, (q15_t)0x3fd5, (q15_t)0x3b64, (q15_t)0x3fd5, (q15_t)0x3b70, (q15_t)0x3fd6, - (q15_t)0x3b7d, (q15_t)0x3fd7, (q15_t)0x3b89, (q15_t)0x3fd8, (q15_t)0x3b96, (q15_t)0x3fd9, (q15_t)0x3ba2, (q15_t)0x3fda, - (q15_t)0x3baf, (q15_t)0x3fdb, (q15_t)0x3bbc, (q15_t)0x3fdc, (q15_t)0x3bc8, (q15_t)0x3fdc, (q15_t)0x3bd5, (q15_t)0x3fdd, - (q15_t)0x3be1, (q15_t)0x3fde, (q15_t)0x3bee, (q15_t)0x3fdf, (q15_t)0x3bfa, (q15_t)0x3fe0, (q15_t)0x3c07, (q15_t)0x3fe0, - (q15_t)0x3c13, (q15_t)0x3fe1, (q15_t)0x3c20, (q15_t)0x3fe2, (q15_t)0x3c2c, (q15_t)0x3fe3, (q15_t)0x3c39, (q15_t)0x3fe3, - (q15_t)0x3c45, (q15_t)0x3fe4, (q15_t)0x3c52, (q15_t)0x3fe5, (q15_t)0x3c5f, (q15_t)0x3fe6, (q15_t)0x3c6b, (q15_t)0x3fe6, - (q15_t)0x3c78, (q15_t)0x3fe7, (q15_t)0x3c84, (q15_t)0x3fe8, (q15_t)0x3c91, (q15_t)0x3fe8, (q15_t)0x3c9d, (q15_t)0x3fe9, - (q15_t)0x3caa, (q15_t)0x3fea, (q15_t)0x3cb6, (q15_t)0x3fea, (q15_t)0x3cc3, (q15_t)0x3feb, (q15_t)0x3cd0, (q15_t)0x3fec, - (q15_t)0x3cdc, (q15_t)0x3fec, (q15_t)0x3ce9, (q15_t)0x3fed, (q15_t)0x3cf5, (q15_t)0x3fed, (q15_t)0x3d02, (q15_t)0x3fee, - (q15_t)0x3d0e, (q15_t)0x3fef, (q15_t)0x3d1b, (q15_t)0x3fef, (q15_t)0x3d27, (q15_t)0x3ff0, (q15_t)0x3d34, (q15_t)0x3ff0, - (q15_t)0x3d40, (q15_t)0x3ff1, (q15_t)0x3d4d, (q15_t)0x3ff1, (q15_t)0x3d5a, (q15_t)0x3ff2, (q15_t)0x3d66, (q15_t)0x3ff2, - (q15_t)0x3d73, (q15_t)0x3ff3, (q15_t)0x3d7f, (q15_t)0x3ff3, (q15_t)0x3d8c, (q15_t)0x3ff4, (q15_t)0x3d98, (q15_t)0x3ff4, - (q15_t)0x3da5, (q15_t)0x3ff5, (q15_t)0x3db2, (q15_t)0x3ff5, (q15_t)0x3dbe, (q15_t)0x3ff6, (q15_t)0x3dcb, (q15_t)0x3ff6, - (q15_t)0x3dd7, (q15_t)0x3ff7, (q15_t)0x3de4, (q15_t)0x3ff7, (q15_t)0x3df0, (q15_t)0x3ff7, (q15_t)0x3dfd, (q15_t)0x3ff8, - (q15_t)0x3e09, (q15_t)0x3ff8, (q15_t)0x3e16, (q15_t)0x3ff9, (q15_t)0x3e23, (q15_t)0x3ff9, (q15_t)0x3e2f, (q15_t)0x3ff9, - (q15_t)0x3e3c, (q15_t)0x3ffa, (q15_t)0x3e48, (q15_t)0x3ffa, (q15_t)0x3e55, (q15_t)0x3ffa, (q15_t)0x3e61, (q15_t)0x3ffb, - (q15_t)0x3e6e, (q15_t)0x3ffb, (q15_t)0x3e7a, (q15_t)0x3ffb, (q15_t)0x3e87, (q15_t)0x3ffc, (q15_t)0x3e94, (q15_t)0x3ffc, - (q15_t)0x3ea0, (q15_t)0x3ffc, (q15_t)0x3ead, (q15_t)0x3ffc, (q15_t)0x3eb9, (q15_t)0x3ffd, (q15_t)0x3ec6, (q15_t)0x3ffd, - (q15_t)0x3ed2, (q15_t)0x3ffd, (q15_t)0x3edf, (q15_t)0x3ffd, (q15_t)0x3eec, (q15_t)0x3ffe, (q15_t)0x3ef8, (q15_t)0x3ffe, - (q15_t)0x3f05, (q15_t)0x3ffe, (q15_t)0x3f11, (q15_t)0x3ffe, (q15_t)0x3f1e, (q15_t)0x3ffe, (q15_t)0x3f2a, (q15_t)0x3fff, - (q15_t)0x3f37, (q15_t)0x3fff, (q15_t)0x3f44, (q15_t)0x3fff, (q15_t)0x3f50, (q15_t)0x3fff, (q15_t)0x3f5d, (q15_t)0x3fff, - (q15_t)0x3f69, (q15_t)0x3fff, (q15_t)0x3f76, (q15_t)0x3fff, (q15_t)0x3f82, (q15_t)0x4000, (q15_t)0x3f8f, (q15_t)0x4000, - (q15_t)0x3f9b, (q15_t)0x4000, (q15_t)0x3fa8, (q15_t)0x4000, (q15_t)0x3fb5, (q15_t)0x4000, (q15_t)0x3fc1, (q15_t)0x4000, - (q15_t)0x3fce, (q15_t)0x4000, (q15_t)0x3fda, (q15_t)0x4000, (q15_t)0x3fe7, (q15_t)0x4000, (q15_t)0x3ff3, (q15_t)0x4000, + (q15_t)0x4000, (q15_t)0xc000, (q15_t)0x3ff3, (q15_t)0xc000, (q15_t)0x3fe7, + (q15_t)0xc000, (q15_t)0x3fda, (q15_t)0xc000, (q15_t)0x3fce, (q15_t)0xc000, + (q15_t)0x3fc1, (q15_t)0xc000, (q15_t)0x3fb5, (q15_t)0xc000, (q15_t)0x3fa8, + (q15_t)0xc000, (q15_t)0x3f9b, (q15_t)0xc000, (q15_t)0x3f8f, (q15_t)0xc000, + (q15_t)0x3f82, (q15_t)0xc000, (q15_t)0x3f76, (q15_t)0xc001, (q15_t)0x3f69, + (q15_t)0xc001, (q15_t)0x3f5d, (q15_t)0xc001, (q15_t)0x3f50, (q15_t)0xc001, + (q15_t)0x3f44, (q15_t)0xc001, (q15_t)0x3f37, (q15_t)0xc001, (q15_t)0x3f2a, + (q15_t)0xc001, (q15_t)0x3f1e, (q15_t)0xc002, (q15_t)0x3f11, (q15_t)0xc002, + (q15_t)0x3f05, (q15_t)0xc002, (q15_t)0x3ef8, (q15_t)0xc002, (q15_t)0x3eec, + (q15_t)0xc002, (q15_t)0x3edf, (q15_t)0xc003, (q15_t)0x3ed2, (q15_t)0xc003, + (q15_t)0x3ec6, (q15_t)0xc003, (q15_t)0x3eb9, (q15_t)0xc003, (q15_t)0x3ead, + (q15_t)0xc004, (q15_t)0x3ea0, (q15_t)0xc004, (q15_t)0x3e94, (q15_t)0xc004, + (q15_t)0x3e87, (q15_t)0xc004, (q15_t)0x3e7a, (q15_t)0xc005, (q15_t)0x3e6e, + (q15_t)0xc005, (q15_t)0x3e61, (q15_t)0xc005, (q15_t)0x3e55, (q15_t)0xc006, + (q15_t)0x3e48, (q15_t)0xc006, (q15_t)0x3e3c, (q15_t)0xc006, (q15_t)0x3e2f, + (q15_t)0xc007, (q15_t)0x3e23, (q15_t)0xc007, (q15_t)0x3e16, (q15_t)0xc007, + (q15_t)0x3e09, (q15_t)0xc008, (q15_t)0x3dfd, (q15_t)0xc008, (q15_t)0x3df0, + (q15_t)0xc009, (q15_t)0x3de4, (q15_t)0xc009, (q15_t)0x3dd7, (q15_t)0xc009, + (q15_t)0x3dcb, (q15_t)0xc00a, (q15_t)0x3dbe, (q15_t)0xc00a, (q15_t)0x3db2, + (q15_t)0xc00b, (q15_t)0x3da5, (q15_t)0xc00b, (q15_t)0x3d98, (q15_t)0xc00c, + (q15_t)0x3d8c, (q15_t)0xc00c, (q15_t)0x3d7f, (q15_t)0xc00d, (q15_t)0x3d73, + (q15_t)0xc00d, (q15_t)0x3d66, (q15_t)0xc00e, (q15_t)0x3d5a, (q15_t)0xc00e, + (q15_t)0x3d4d, (q15_t)0xc00f, (q15_t)0x3d40, (q15_t)0xc00f, (q15_t)0x3d34, + (q15_t)0xc010, (q15_t)0x3d27, (q15_t)0xc010, (q15_t)0x3d1b, (q15_t)0xc011, + (q15_t)0x3d0e, (q15_t)0xc011, (q15_t)0x3d02, (q15_t)0xc012, (q15_t)0x3cf5, + (q15_t)0xc013, (q15_t)0x3ce9, (q15_t)0xc013, (q15_t)0x3cdc, (q15_t)0xc014, + (q15_t)0x3cd0, (q15_t)0xc014, (q15_t)0x3cc3, (q15_t)0xc015, (q15_t)0x3cb6, + (q15_t)0xc016, (q15_t)0x3caa, (q15_t)0xc016, (q15_t)0x3c9d, (q15_t)0xc017, + (q15_t)0x3c91, (q15_t)0xc018, (q15_t)0x3c84, (q15_t)0xc018, (q15_t)0x3c78, + (q15_t)0xc019, (q15_t)0x3c6b, (q15_t)0xc01a, (q15_t)0x3c5f, (q15_t)0xc01a, + (q15_t)0x3c52, (q15_t)0xc01b, (q15_t)0x3c45, (q15_t)0xc01c, (q15_t)0x3c39, + (q15_t)0xc01d, (q15_t)0x3c2c, (q15_t)0xc01d, (q15_t)0x3c20, (q15_t)0xc01e, + (q15_t)0x3c13, (q15_t)0xc01f, (q15_t)0x3c07, (q15_t)0xc020, (q15_t)0x3bfa, + (q15_t)0xc020, (q15_t)0x3bee, (q15_t)0xc021, (q15_t)0x3be1, (q15_t)0xc022, + (q15_t)0x3bd5, (q15_t)0xc023, (q15_t)0x3bc8, (q15_t)0xc024, (q15_t)0x3bbc, + (q15_t)0xc024, (q15_t)0x3baf, (q15_t)0xc025, (q15_t)0x3ba2, (q15_t)0xc026, + (q15_t)0x3b96, (q15_t)0xc027, (q15_t)0x3b89, (q15_t)0xc028, (q15_t)0x3b7d, + (q15_t)0xc029, (q15_t)0x3b70, (q15_t)0xc02a, (q15_t)0x3b64, (q15_t)0xc02b, + (q15_t)0x3b57, (q15_t)0xc02b, (q15_t)0x3b4b, (q15_t)0xc02c, (q15_t)0x3b3e, + (q15_t)0xc02d, (q15_t)0x3b32, (q15_t)0xc02e, (q15_t)0x3b25, (q15_t)0xc02f, + (q15_t)0x3b19, (q15_t)0xc030, (q15_t)0x3b0c, (q15_t)0xc031, (q15_t)0x3b00, + (q15_t)0xc032, (q15_t)0x3af3, (q15_t)0xc033, (q15_t)0x3ae6, (q15_t)0xc034, + (q15_t)0x3ada, (q15_t)0xc035, (q15_t)0x3acd, (q15_t)0xc036, (q15_t)0x3ac1, + (q15_t)0xc037, (q15_t)0x3ab4, (q15_t)0xc038, (q15_t)0x3aa8, (q15_t)0xc039, + (q15_t)0x3a9b, (q15_t)0xc03a, (q15_t)0x3a8f, (q15_t)0xc03b, (q15_t)0x3a82, + (q15_t)0xc03c, (q15_t)0x3a76, (q15_t)0xc03d, (q15_t)0x3a69, (q15_t)0xc03f, + (q15_t)0x3a5d, (q15_t)0xc040, (q15_t)0x3a50, (q15_t)0xc041, (q15_t)0x3a44, + (q15_t)0xc042, (q15_t)0x3a37, (q15_t)0xc043, (q15_t)0x3a2b, (q15_t)0xc044, + (q15_t)0x3a1e, (q15_t)0xc045, (q15_t)0x3a12, (q15_t)0xc047, (q15_t)0x3a05, + (q15_t)0xc048, (q15_t)0x39f9, (q15_t)0xc049, (q15_t)0x39ec, (q15_t)0xc04a, + (q15_t)0x39e0, (q15_t)0xc04b, (q15_t)0x39d3, (q15_t)0xc04c, (q15_t)0x39c7, + (q15_t)0xc04e, (q15_t)0x39ba, (q15_t)0xc04f, (q15_t)0x39ae, (q15_t)0xc050, + (q15_t)0x39a1, (q15_t)0xc051, (q15_t)0x3995, (q15_t)0xc053, (q15_t)0x3988, + (q15_t)0xc054, (q15_t)0x397c, (q15_t)0xc055, (q15_t)0x396f, (q15_t)0xc056, + (q15_t)0x3963, (q15_t)0xc058, (q15_t)0x3956, (q15_t)0xc059, (q15_t)0x394a, + (q15_t)0xc05a, (q15_t)0x393d, (q15_t)0xc05c, (q15_t)0x3931, (q15_t)0xc05d, + (q15_t)0x3924, (q15_t)0xc05e, (q15_t)0x3918, (q15_t)0xc060, (q15_t)0x390b, + (q15_t)0xc061, (q15_t)0x38ff, (q15_t)0xc062, (q15_t)0x38f2, (q15_t)0xc064, + (q15_t)0x38e6, (q15_t)0xc065, (q15_t)0x38d9, (q15_t)0xc067, (q15_t)0x38cd, + (q15_t)0xc068, (q15_t)0x38c0, (q15_t)0xc069, (q15_t)0x38b4, (q15_t)0xc06b, + (q15_t)0x38a7, (q15_t)0xc06c, (q15_t)0x389b, (q15_t)0xc06e, (q15_t)0x388e, + (q15_t)0xc06f, (q15_t)0x3882, (q15_t)0xc071, (q15_t)0x3875, (q15_t)0xc072, + (q15_t)0x3869, (q15_t)0xc074, (q15_t)0x385c, (q15_t)0xc075, (q15_t)0x3850, + (q15_t)0xc077, (q15_t)0x3843, (q15_t)0xc078, (q15_t)0x3837, (q15_t)0xc07a, + (q15_t)0x382a, (q15_t)0xc07b, (q15_t)0x381e, (q15_t)0xc07d, (q15_t)0x3811, + (q15_t)0xc07e, (q15_t)0x3805, (q15_t)0xc080, (q15_t)0x37f9, (q15_t)0xc081, + (q15_t)0x37ec, (q15_t)0xc083, (q15_t)0x37e0, (q15_t)0xc085, (q15_t)0x37d3, + (q15_t)0xc086, (q15_t)0x37c7, (q15_t)0xc088, (q15_t)0x37ba, (q15_t)0xc089, + (q15_t)0x37ae, (q15_t)0xc08b, (q15_t)0x37a1, (q15_t)0xc08d, (q15_t)0x3795, + (q15_t)0xc08e, (q15_t)0x3788, (q15_t)0xc090, (q15_t)0x377c, (q15_t)0xc092, + (q15_t)0x376f, (q15_t)0xc093, (q15_t)0x3763, (q15_t)0xc095, (q15_t)0x3757, + (q15_t)0xc097, (q15_t)0x374a, (q15_t)0xc098, (q15_t)0x373e, (q15_t)0xc09a, + (q15_t)0x3731, (q15_t)0xc09c, (q15_t)0x3725, (q15_t)0xc09e, (q15_t)0x3718, + (q15_t)0xc09f, (q15_t)0x370c, (q15_t)0xc0a1, (q15_t)0x36ff, (q15_t)0xc0a3, + (q15_t)0x36f3, (q15_t)0xc0a5, (q15_t)0x36e7, (q15_t)0xc0a6, (q15_t)0x36da, + (q15_t)0xc0a8, (q15_t)0x36ce, (q15_t)0xc0aa, (q15_t)0x36c1, (q15_t)0xc0ac, + (q15_t)0x36b5, (q15_t)0xc0ae, (q15_t)0x36a8, (q15_t)0xc0af, (q15_t)0x369c, + (q15_t)0xc0b1, (q15_t)0x3690, (q15_t)0xc0b3, (q15_t)0x3683, (q15_t)0xc0b5, + (q15_t)0x3677, (q15_t)0xc0b7, (q15_t)0x366a, (q15_t)0xc0b9, (q15_t)0x365e, + (q15_t)0xc0bb, (q15_t)0x3651, (q15_t)0xc0bd, (q15_t)0x3645, (q15_t)0xc0be, + (q15_t)0x3639, (q15_t)0xc0c0, (q15_t)0x362c, (q15_t)0xc0c2, (q15_t)0x3620, + (q15_t)0xc0c4, (q15_t)0x3613, (q15_t)0xc0c6, (q15_t)0x3607, (q15_t)0xc0c8, + (q15_t)0x35fa, (q15_t)0xc0ca, (q15_t)0x35ee, (q15_t)0xc0cc, (q15_t)0x35e2, + (q15_t)0xc0ce, (q15_t)0x35d5, (q15_t)0xc0d0, (q15_t)0x35c9, (q15_t)0xc0d2, + (q15_t)0x35bc, (q15_t)0xc0d4, (q15_t)0x35b0, (q15_t)0xc0d6, (q15_t)0x35a4, + (q15_t)0xc0d8, (q15_t)0x3597, (q15_t)0xc0da, (q15_t)0x358b, (q15_t)0xc0dc, + (q15_t)0x357e, (q15_t)0xc0de, (q15_t)0x3572, (q15_t)0xc0e0, (q15_t)0x3566, + (q15_t)0xc0e2, (q15_t)0x3559, (q15_t)0xc0e4, (q15_t)0x354d, (q15_t)0xc0e7, + (q15_t)0x3540, (q15_t)0xc0e9, (q15_t)0x3534, (q15_t)0xc0eb, (q15_t)0x3528, + (q15_t)0xc0ed, (q15_t)0x351b, (q15_t)0xc0ef, (q15_t)0x350f, (q15_t)0xc0f1, + (q15_t)0x3503, (q15_t)0xc0f3, (q15_t)0x34f6, (q15_t)0xc0f6, (q15_t)0x34ea, + (q15_t)0xc0f8, (q15_t)0x34dd, (q15_t)0xc0fa, (q15_t)0x34d1, (q15_t)0xc0fc, + (q15_t)0x34c5, (q15_t)0xc0fe, (q15_t)0x34b8, (q15_t)0xc100, (q15_t)0x34ac, + (q15_t)0xc103, (q15_t)0x34a0, (q15_t)0xc105, (q15_t)0x3493, (q15_t)0xc107, + (q15_t)0x3487, (q15_t)0xc109, (q15_t)0x347b, (q15_t)0xc10c, (q15_t)0x346e, + (q15_t)0xc10e, (q15_t)0x3462, (q15_t)0xc110, (q15_t)0x3455, (q15_t)0xc113, + (q15_t)0x3449, (q15_t)0xc115, (q15_t)0x343d, (q15_t)0xc117, (q15_t)0x3430, + (q15_t)0xc119, (q15_t)0x3424, (q15_t)0xc11c, (q15_t)0x3418, (q15_t)0xc11e, + (q15_t)0x340b, (q15_t)0xc120, (q15_t)0x33ff, (q15_t)0xc123, (q15_t)0x33f3, + (q15_t)0xc125, (q15_t)0x33e6, (q15_t)0xc128, (q15_t)0x33da, (q15_t)0xc12a, + (q15_t)0x33ce, (q15_t)0xc12c, (q15_t)0x33c1, (q15_t)0xc12f, (q15_t)0x33b5, + (q15_t)0xc131, (q15_t)0x33a9, (q15_t)0xc134, (q15_t)0x339c, (q15_t)0xc136, + (q15_t)0x3390, (q15_t)0xc138, (q15_t)0x3384, (q15_t)0xc13b, (q15_t)0x3377, + (q15_t)0xc13d, (q15_t)0x336b, (q15_t)0xc140, (q15_t)0x335f, (q15_t)0xc142, + (q15_t)0x3352, (q15_t)0xc145, (q15_t)0x3346, (q15_t)0xc147, (q15_t)0x333a, + (q15_t)0xc14a, (q15_t)0x332d, (q15_t)0xc14c, (q15_t)0x3321, (q15_t)0xc14f, + (q15_t)0x3315, (q15_t)0xc151, (q15_t)0x3308, (q15_t)0xc154, (q15_t)0x32fc, + (q15_t)0xc156, (q15_t)0x32f0, (q15_t)0xc159, (q15_t)0x32e4, (q15_t)0xc15b, + (q15_t)0x32d7, (q15_t)0xc15e, (q15_t)0x32cb, (q15_t)0xc161, (q15_t)0x32bf, + (q15_t)0xc163, (q15_t)0x32b2, (q15_t)0xc166, (q15_t)0x32a6, (q15_t)0xc168, + (q15_t)0x329a, (q15_t)0xc16b, (q15_t)0x328e, (q15_t)0xc16e, (q15_t)0x3281, + (q15_t)0xc170, (q15_t)0x3275, (q15_t)0xc173, (q15_t)0x3269, (q15_t)0xc176, + (q15_t)0x325c, (q15_t)0xc178, (q15_t)0x3250, (q15_t)0xc17b, (q15_t)0x3244, + (q15_t)0xc17e, (q15_t)0x3238, (q15_t)0xc180, (q15_t)0x322b, (q15_t)0xc183, + (q15_t)0x321f, (q15_t)0xc186, (q15_t)0x3213, (q15_t)0xc189, (q15_t)0x3207, + (q15_t)0xc18b, (q15_t)0x31fa, (q15_t)0xc18e, (q15_t)0x31ee, (q15_t)0xc191, + (q15_t)0x31e2, (q15_t)0xc194, (q15_t)0x31d5, (q15_t)0xc196, (q15_t)0x31c9, + (q15_t)0xc199, (q15_t)0x31bd, (q15_t)0xc19c, (q15_t)0x31b1, (q15_t)0xc19f, + (q15_t)0x31a4, (q15_t)0xc1a2, (q15_t)0x3198, (q15_t)0xc1a4, (q15_t)0x318c, + (q15_t)0xc1a7, (q15_t)0x3180, (q15_t)0xc1aa, (q15_t)0x3174, (q15_t)0xc1ad, + (q15_t)0x3167, (q15_t)0xc1b0, (q15_t)0x315b, (q15_t)0xc1b3, (q15_t)0x314f, + (q15_t)0xc1b6, (q15_t)0x3143, (q15_t)0xc1b8, (q15_t)0x3136, (q15_t)0xc1bb, + (q15_t)0x312a, (q15_t)0xc1be, (q15_t)0x311e, (q15_t)0xc1c1, (q15_t)0x3112, + (q15_t)0xc1c4, (q15_t)0x3105, (q15_t)0xc1c7, (q15_t)0x30f9, (q15_t)0xc1ca, + (q15_t)0x30ed, (q15_t)0xc1cd, (q15_t)0x30e1, (q15_t)0xc1d0, (q15_t)0x30d5, + (q15_t)0xc1d3, (q15_t)0x30c8, (q15_t)0xc1d6, (q15_t)0x30bc, (q15_t)0xc1d9, + (q15_t)0x30b0, (q15_t)0xc1dc, (q15_t)0x30a4, (q15_t)0xc1df, (q15_t)0x3098, + (q15_t)0xc1e2, (q15_t)0x308b, (q15_t)0xc1e5, (q15_t)0x307f, (q15_t)0xc1e8, + (q15_t)0x3073, (q15_t)0xc1eb, (q15_t)0x3067, (q15_t)0xc1ee, (q15_t)0x305b, + (q15_t)0xc1f1, (q15_t)0x304e, (q15_t)0xc1f4, (q15_t)0x3042, (q15_t)0xc1f7, + (q15_t)0x3036, (q15_t)0xc1fa, (q15_t)0x302a, (q15_t)0xc1fd, (q15_t)0x301e, + (q15_t)0xc201, (q15_t)0x3012, (q15_t)0xc204, (q15_t)0x3005, (q15_t)0xc207, + (q15_t)0x2ff9, (q15_t)0xc20a, (q15_t)0x2fed, (q15_t)0xc20d, (q15_t)0x2fe1, + (q15_t)0xc210, (q15_t)0x2fd5, (q15_t)0xc213, (q15_t)0x2fc9, (q15_t)0xc217, + (q15_t)0x2fbc, (q15_t)0xc21a, (q15_t)0x2fb0, (q15_t)0xc21d, (q15_t)0x2fa4, + (q15_t)0xc220, (q15_t)0x2f98, (q15_t)0xc223, (q15_t)0x2f8c, (q15_t)0xc227, + (q15_t)0x2f80, (q15_t)0xc22a, (q15_t)0x2f74, (q15_t)0xc22d, (q15_t)0x2f67, + (q15_t)0xc230, (q15_t)0x2f5b, (q15_t)0xc234, (q15_t)0x2f4f, (q15_t)0xc237, + (q15_t)0x2f43, (q15_t)0xc23a, (q15_t)0x2f37, (q15_t)0xc23e, (q15_t)0x2f2b, + (q15_t)0xc241, (q15_t)0x2f1f, (q15_t)0xc244, (q15_t)0x2f13, (q15_t)0xc247, + (q15_t)0x2f06, (q15_t)0xc24b, (q15_t)0x2efa, (q15_t)0xc24e, (q15_t)0x2eee, + (q15_t)0xc251, (q15_t)0x2ee2, (q15_t)0xc255, (q15_t)0x2ed6, (q15_t)0xc258, + (q15_t)0x2eca, (q15_t)0xc25c, (q15_t)0x2ebe, (q15_t)0xc25f, (q15_t)0x2eb2, + (q15_t)0xc262, (q15_t)0x2ea6, (q15_t)0xc266, (q15_t)0x2e99, (q15_t)0xc269, + (q15_t)0x2e8d, (q15_t)0xc26d, (q15_t)0x2e81, (q15_t)0xc270, (q15_t)0x2e75, + (q15_t)0xc273, (q15_t)0x2e69, (q15_t)0xc277, (q15_t)0x2e5d, (q15_t)0xc27a, + (q15_t)0x2e51, (q15_t)0xc27e, (q15_t)0x2e45, (q15_t)0xc281, (q15_t)0x2e39, + (q15_t)0xc285, (q15_t)0x2e2d, (q15_t)0xc288, (q15_t)0x2e21, (q15_t)0xc28c, + (q15_t)0x2e15, (q15_t)0xc28f, (q15_t)0x2e09, (q15_t)0xc293, (q15_t)0x2dfc, + (q15_t)0xc296, (q15_t)0x2df0, (q15_t)0xc29a, (q15_t)0x2de4, (q15_t)0xc29d, + (q15_t)0x2dd8, (q15_t)0xc2a1, (q15_t)0x2dcc, (q15_t)0xc2a5, (q15_t)0x2dc0, + (q15_t)0xc2a8, (q15_t)0x2db4, (q15_t)0xc2ac, (q15_t)0x2da8, (q15_t)0xc2af, + (q15_t)0x2d9c, (q15_t)0xc2b3, (q15_t)0x2d90, (q15_t)0xc2b7, (q15_t)0x2d84, + (q15_t)0xc2ba, (q15_t)0x2d78, (q15_t)0xc2be, (q15_t)0x2d6c, (q15_t)0xc2c1, + (q15_t)0x2d60, (q15_t)0xc2c5, (q15_t)0x2d54, (q15_t)0xc2c9, (q15_t)0x2d48, + (q15_t)0xc2cc, (q15_t)0x2d3c, (q15_t)0xc2d0, (q15_t)0x2d30, (q15_t)0xc2d4, + (q15_t)0x2d24, (q15_t)0xc2d8, (q15_t)0x2d18, (q15_t)0xc2db, (q15_t)0x2d0c, + (q15_t)0xc2df, (q15_t)0x2d00, (q15_t)0xc2e3, (q15_t)0x2cf4, (q15_t)0xc2e6, + (q15_t)0x2ce8, (q15_t)0xc2ea, (q15_t)0x2cdc, (q15_t)0xc2ee, (q15_t)0x2cd0, + (q15_t)0xc2f2, (q15_t)0x2cc4, (q15_t)0xc2f5, (q15_t)0x2cb8, (q15_t)0xc2f9, + (q15_t)0x2cac, (q15_t)0xc2fd, (q15_t)0x2ca0, (q15_t)0xc301, (q15_t)0x2c94, + (q15_t)0xc305, (q15_t)0x2c88, (q15_t)0xc308, (q15_t)0x2c7c, (q15_t)0xc30c, + (q15_t)0x2c70, (q15_t)0xc310, (q15_t)0x2c64, (q15_t)0xc314, (q15_t)0x2c58, + (q15_t)0xc318, (q15_t)0x2c4c, (q15_t)0xc31c, (q15_t)0x2c40, (q15_t)0xc320, + (q15_t)0x2c34, (q15_t)0xc323, (q15_t)0x2c28, (q15_t)0xc327, (q15_t)0x2c1c, + (q15_t)0xc32b, (q15_t)0x2c10, (q15_t)0xc32f, (q15_t)0x2c05, (q15_t)0xc333, + (q15_t)0x2bf9, (q15_t)0xc337, (q15_t)0x2bed, (q15_t)0xc33b, (q15_t)0x2be1, + (q15_t)0xc33f, (q15_t)0x2bd5, (q15_t)0xc343, (q15_t)0x2bc9, (q15_t)0xc347, + (q15_t)0x2bbd, (q15_t)0xc34b, (q15_t)0x2bb1, (q15_t)0xc34f, (q15_t)0x2ba5, + (q15_t)0xc353, (q15_t)0x2b99, (q15_t)0xc357, (q15_t)0x2b8d, (q15_t)0xc35b, + (q15_t)0x2b81, (q15_t)0xc35f, (q15_t)0x2b75, (q15_t)0xc363, (q15_t)0x2b6a, + (q15_t)0xc367, (q15_t)0x2b5e, (q15_t)0xc36b, (q15_t)0x2b52, (q15_t)0xc36f, + (q15_t)0x2b46, (q15_t)0xc373, (q15_t)0x2b3a, (q15_t)0xc377, (q15_t)0x2b2e, + (q15_t)0xc37b, (q15_t)0x2b22, (q15_t)0xc37f, (q15_t)0x2b16, (q15_t)0xc383, + (q15_t)0x2b0a, (q15_t)0xc387, (q15_t)0x2aff, (q15_t)0xc38c, (q15_t)0x2af3, + (q15_t)0xc390, (q15_t)0x2ae7, (q15_t)0xc394, (q15_t)0x2adb, (q15_t)0xc398, + (q15_t)0x2acf, (q15_t)0xc39c, (q15_t)0x2ac3, (q15_t)0xc3a0, (q15_t)0x2ab7, + (q15_t)0xc3a5, (q15_t)0x2aac, (q15_t)0xc3a9, (q15_t)0x2aa0, (q15_t)0xc3ad, + (q15_t)0x2a94, (q15_t)0xc3b1, (q15_t)0x2a88, (q15_t)0xc3b5, (q15_t)0x2a7c, + (q15_t)0xc3ba, (q15_t)0x2a70, (q15_t)0xc3be, (q15_t)0x2a65, (q15_t)0xc3c2, + (q15_t)0x2a59, (q15_t)0xc3c6, (q15_t)0x2a4d, (q15_t)0xc3ca, (q15_t)0x2a41, + (q15_t)0xc3cf, (q15_t)0x2a35, (q15_t)0xc3d3, (q15_t)0x2a29, (q15_t)0xc3d7, + (q15_t)0x2a1e, (q15_t)0xc3dc, (q15_t)0x2a12, (q15_t)0xc3e0, (q15_t)0x2a06, + (q15_t)0xc3e4, (q15_t)0x29fa, (q15_t)0xc3e9, (q15_t)0x29ee, (q15_t)0xc3ed, + (q15_t)0x29e3, (q15_t)0xc3f1, (q15_t)0x29d7, (q15_t)0xc3f6, (q15_t)0x29cb, + (q15_t)0xc3fa, (q15_t)0x29bf, (q15_t)0xc3fe, (q15_t)0x29b4, (q15_t)0xc403, + (q15_t)0x29a8, (q15_t)0xc407, (q15_t)0x299c, (q15_t)0xc40b, (q15_t)0x2990, + (q15_t)0xc410, (q15_t)0x2984, (q15_t)0xc414, (q15_t)0x2979, (q15_t)0xc419, + (q15_t)0x296d, (q15_t)0xc41d, (q15_t)0x2961, (q15_t)0xc422, (q15_t)0x2955, + (q15_t)0xc426, (q15_t)0x294a, (q15_t)0xc42a, (q15_t)0x293e, (q15_t)0xc42f, + (q15_t)0x2932, (q15_t)0xc433, (q15_t)0x2926, (q15_t)0xc438, (q15_t)0x291b, + (q15_t)0xc43c, (q15_t)0x290f, (q15_t)0xc441, (q15_t)0x2903, (q15_t)0xc445, + (q15_t)0x28f7, (q15_t)0xc44a, (q15_t)0x28ec, (q15_t)0xc44e, (q15_t)0x28e0, + (q15_t)0xc453, (q15_t)0x28d4, (q15_t)0xc457, (q15_t)0x28c9, (q15_t)0xc45c, + (q15_t)0x28bd, (q15_t)0xc461, (q15_t)0x28b1, (q15_t)0xc465, (q15_t)0x28a5, + (q15_t)0xc46a, (q15_t)0x289a, (q15_t)0xc46e, (q15_t)0x288e, (q15_t)0xc473, + (q15_t)0x2882, (q15_t)0xc478, (q15_t)0x2877, (q15_t)0xc47c, (q15_t)0x286b, + (q15_t)0xc481, (q15_t)0x285f, (q15_t)0xc485, (q15_t)0x2854, (q15_t)0xc48a, + (q15_t)0x2848, (q15_t)0xc48f, (q15_t)0x283c, (q15_t)0xc493, (q15_t)0x2831, + (q15_t)0xc498, (q15_t)0x2825, (q15_t)0xc49d, (q15_t)0x2819, (q15_t)0xc4a1, + (q15_t)0x280e, (q15_t)0xc4a6, (q15_t)0x2802, (q15_t)0xc4ab, (q15_t)0x27f6, + (q15_t)0xc4b0, (q15_t)0x27eb, (q15_t)0xc4b4, (q15_t)0x27df, (q15_t)0xc4b9, + (q15_t)0x27d3, (q15_t)0xc4be, (q15_t)0x27c8, (q15_t)0xc4c2, (q15_t)0x27bc, + (q15_t)0xc4c7, (q15_t)0x27b1, (q15_t)0xc4cc, (q15_t)0x27a5, (q15_t)0xc4d1, + (q15_t)0x2799, (q15_t)0xc4d6, (q15_t)0x278e, (q15_t)0xc4da, (q15_t)0x2782, + (q15_t)0xc4df, (q15_t)0x2777, (q15_t)0xc4e4, (q15_t)0x276b, (q15_t)0xc4e9, + (q15_t)0x275f, (q15_t)0xc4ee, (q15_t)0x2754, (q15_t)0xc4f2, (q15_t)0x2748, + (q15_t)0xc4f7, (q15_t)0x273d, (q15_t)0xc4fc, (q15_t)0x2731, (q15_t)0xc501, + (q15_t)0x2725, (q15_t)0xc506, (q15_t)0x271a, (q15_t)0xc50b, (q15_t)0x270e, + (q15_t)0xc510, (q15_t)0x2703, (q15_t)0xc515, (q15_t)0x26f7, (q15_t)0xc51a, + (q15_t)0x26ec, (q15_t)0xc51e, (q15_t)0x26e0, (q15_t)0xc523, (q15_t)0x26d4, + (q15_t)0xc528, (q15_t)0x26c9, (q15_t)0xc52d, (q15_t)0x26bd, (q15_t)0xc532, + (q15_t)0x26b2, (q15_t)0xc537, (q15_t)0x26a6, (q15_t)0xc53c, (q15_t)0x269b, + (q15_t)0xc541, (q15_t)0x268f, (q15_t)0xc546, (q15_t)0x2684, (q15_t)0xc54b, + (q15_t)0x2678, (q15_t)0xc550, (q15_t)0x266d, (q15_t)0xc555, (q15_t)0x2661, + (q15_t)0xc55a, (q15_t)0x2656, (q15_t)0xc55f, (q15_t)0x264a, (q15_t)0xc564, + (q15_t)0x263f, (q15_t)0xc569, (q15_t)0x2633, (q15_t)0xc56e, (q15_t)0x2628, + (q15_t)0xc573, (q15_t)0x261c, (q15_t)0xc578, (q15_t)0x2611, (q15_t)0xc57e, + (q15_t)0x2605, (q15_t)0xc583, (q15_t)0x25fa, (q15_t)0xc588, (q15_t)0x25ee, + (q15_t)0xc58d, (q15_t)0x25e3, (q15_t)0xc592, (q15_t)0x25d7, (q15_t)0xc597, + (q15_t)0x25cc, (q15_t)0xc59c, (q15_t)0x25c0, (q15_t)0xc5a1, (q15_t)0x25b5, + (q15_t)0xc5a7, (q15_t)0x25a9, (q15_t)0xc5ac, (q15_t)0x259e, (q15_t)0xc5b1, + (q15_t)0x2592, (q15_t)0xc5b6, (q15_t)0x2587, (q15_t)0xc5bb, (q15_t)0x257c, + (q15_t)0xc5c1, (q15_t)0x2570, (q15_t)0xc5c6, (q15_t)0x2565, (q15_t)0xc5cb, + (q15_t)0x2559, (q15_t)0xc5d0, (q15_t)0x254e, (q15_t)0xc5d5, (q15_t)0x2542, + (q15_t)0xc5db, (q15_t)0x2537, (q15_t)0xc5e0, (q15_t)0x252c, (q15_t)0xc5e5, + (q15_t)0x2520, (q15_t)0xc5ea, (q15_t)0x2515, (q15_t)0xc5f0, (q15_t)0x2509, + (q15_t)0xc5f5, (q15_t)0x24fe, (q15_t)0xc5fa, (q15_t)0x24f3, (q15_t)0xc600, + (q15_t)0x24e7, (q15_t)0xc605, (q15_t)0x24dc, (q15_t)0xc60a, (q15_t)0x24d0, + (q15_t)0xc610, (q15_t)0x24c5, (q15_t)0xc615, (q15_t)0x24ba, (q15_t)0xc61a, + (q15_t)0x24ae, (q15_t)0xc620, (q15_t)0x24a3, (q15_t)0xc625, (q15_t)0x2498, + (q15_t)0xc62a, (q15_t)0x248c, (q15_t)0xc630, (q15_t)0x2481, (q15_t)0xc635, + (q15_t)0x2476, (q15_t)0xc63b, (q15_t)0x246a, (q15_t)0xc640, (q15_t)0x245f, + (q15_t)0xc645, (q15_t)0x2454, (q15_t)0xc64b, (q15_t)0x2448, (q15_t)0xc650, + (q15_t)0x243d, (q15_t)0xc656, (q15_t)0x2432, (q15_t)0xc65b, (q15_t)0x2426, + (q15_t)0xc661, (q15_t)0x241b, (q15_t)0xc666, (q15_t)0x2410, (q15_t)0xc66c, + (q15_t)0x2404, (q15_t)0xc671, (q15_t)0x23f9, (q15_t)0xc677, (q15_t)0x23ee, + (q15_t)0xc67c, (q15_t)0x23e2, (q15_t)0xc682, (q15_t)0x23d7, (q15_t)0xc687, + (q15_t)0x23cc, (q15_t)0xc68d, (q15_t)0x23c1, (q15_t)0xc692, (q15_t)0x23b5, + (q15_t)0xc698, (q15_t)0x23aa, (q15_t)0xc69d, (q15_t)0x239f, (q15_t)0xc6a3, + (q15_t)0x2394, (q15_t)0xc6a8, (q15_t)0x2388, (q15_t)0xc6ae, (q15_t)0x237d, + (q15_t)0xc6b4, (q15_t)0x2372, (q15_t)0xc6b9, (q15_t)0x2367, (q15_t)0xc6bf, + (q15_t)0x235b, (q15_t)0xc6c5, (q15_t)0x2350, (q15_t)0xc6ca, (q15_t)0x2345, + (q15_t)0xc6d0, (q15_t)0x233a, (q15_t)0xc6d5, (q15_t)0x232e, (q15_t)0xc6db, + (q15_t)0x2323, (q15_t)0xc6e1, (q15_t)0x2318, (q15_t)0xc6e6, (q15_t)0x230d, + (q15_t)0xc6ec, (q15_t)0x2301, (q15_t)0xc6f2, (q15_t)0x22f6, (q15_t)0xc6f7, + (q15_t)0x22eb, (q15_t)0xc6fd, (q15_t)0x22e0, (q15_t)0xc703, (q15_t)0x22d5, + (q15_t)0xc709, (q15_t)0x22ca, (q15_t)0xc70e, (q15_t)0x22be, (q15_t)0xc714, + (q15_t)0x22b3, (q15_t)0xc71a, (q15_t)0x22a8, (q15_t)0xc720, (q15_t)0x229d, + (q15_t)0xc725, (q15_t)0x2292, (q15_t)0xc72b, (q15_t)0x2287, (q15_t)0xc731, + (q15_t)0x227b, (q15_t)0xc737, (q15_t)0x2270, (q15_t)0xc73d, (q15_t)0x2265, + (q15_t)0xc742, (q15_t)0x225a, (q15_t)0xc748, (q15_t)0x224f, (q15_t)0xc74e, + (q15_t)0x2244, (q15_t)0xc754, (q15_t)0x2239, (q15_t)0xc75a, (q15_t)0x222d, + (q15_t)0xc75f, (q15_t)0x2222, (q15_t)0xc765, (q15_t)0x2217, (q15_t)0xc76b, + (q15_t)0x220c, (q15_t)0xc771, (q15_t)0x2201, (q15_t)0xc777, (q15_t)0x21f6, + (q15_t)0xc77d, (q15_t)0x21eb, (q15_t)0xc783, (q15_t)0x21e0, (q15_t)0xc789, + (q15_t)0x21d5, (q15_t)0xc78f, (q15_t)0x21ca, (q15_t)0xc795, (q15_t)0x21be, + (q15_t)0xc79a, (q15_t)0x21b3, (q15_t)0xc7a0, (q15_t)0x21a8, (q15_t)0xc7a6, + (q15_t)0x219d, (q15_t)0xc7ac, (q15_t)0x2192, (q15_t)0xc7b2, (q15_t)0x2187, + (q15_t)0xc7b8, (q15_t)0x217c, (q15_t)0xc7be, (q15_t)0x2171, (q15_t)0xc7c4, + (q15_t)0x2166, (q15_t)0xc7ca, (q15_t)0x215b, (q15_t)0xc7d0, (q15_t)0x2150, + (q15_t)0xc7d6, (q15_t)0x2145, (q15_t)0xc7dc, (q15_t)0x213a, (q15_t)0xc7e2, + (q15_t)0x212f, (q15_t)0xc7e8, (q15_t)0x2124, (q15_t)0xc7ee, (q15_t)0x2119, + (q15_t)0xc7f5, (q15_t)0x210e, (q15_t)0xc7fb, (q15_t)0x2103, (q15_t)0xc801, + (q15_t)0x20f8, (q15_t)0xc807, (q15_t)0x20ed, (q15_t)0xc80d, (q15_t)0x20e2, + (q15_t)0xc813, (q15_t)0x20d7, (q15_t)0xc819, (q15_t)0x20cc, (q15_t)0xc81f, + (q15_t)0x20c1, (q15_t)0xc825, (q15_t)0x20b6, (q15_t)0xc82b, (q15_t)0x20ab, + (q15_t)0xc832, (q15_t)0x20a0, (q15_t)0xc838, (q15_t)0x2095, (q15_t)0xc83e, + (q15_t)0x208a, (q15_t)0xc844, (q15_t)0x207f, (q15_t)0xc84a, (q15_t)0x2074, + (q15_t)0xc850, (q15_t)0x2069, (q15_t)0xc857, (q15_t)0x205e, (q15_t)0xc85d, + (q15_t)0x2054, (q15_t)0xc863, (q15_t)0x2049, (q15_t)0xc869, (q15_t)0x203e, + (q15_t)0xc870, (q15_t)0x2033, (q15_t)0xc876, (q15_t)0x2028, (q15_t)0xc87c, + (q15_t)0x201d, (q15_t)0xc882, (q15_t)0x2012, (q15_t)0xc889, (q15_t)0x2007, + (q15_t)0xc88f, (q15_t)0x1ffc, (q15_t)0xc895, (q15_t)0x1ff1, (q15_t)0xc89b, + (q15_t)0x1fe7, (q15_t)0xc8a2, (q15_t)0x1fdc, (q15_t)0xc8a8, (q15_t)0x1fd1, + (q15_t)0xc8ae, (q15_t)0x1fc6, (q15_t)0xc8b5, (q15_t)0x1fbb, (q15_t)0xc8bb, + (q15_t)0x1fb0, (q15_t)0xc8c1, (q15_t)0x1fa5, (q15_t)0xc8c8, (q15_t)0x1f9b, + (q15_t)0xc8ce, (q15_t)0x1f90, (q15_t)0xc8d4, (q15_t)0x1f85, (q15_t)0xc8db, + (q15_t)0x1f7a, (q15_t)0xc8e1, (q15_t)0x1f6f, (q15_t)0xc8e8, (q15_t)0x1f65, + (q15_t)0xc8ee, (q15_t)0x1f5a, (q15_t)0xc8f4, (q15_t)0x1f4f, (q15_t)0xc8fb, + (q15_t)0x1f44, (q15_t)0xc901, (q15_t)0x1f39, (q15_t)0xc908, (q15_t)0x1f2f, + (q15_t)0xc90e, (q15_t)0x1f24, (q15_t)0xc915, (q15_t)0x1f19, (q15_t)0xc91b, + (q15_t)0x1f0e, (q15_t)0xc921, (q15_t)0x1f03, (q15_t)0xc928, (q15_t)0x1ef9, + (q15_t)0xc92e, (q15_t)0x1eee, (q15_t)0xc935, (q15_t)0x1ee3, (q15_t)0xc93b, + (q15_t)0x1ed8, (q15_t)0xc942, (q15_t)0x1ece, (q15_t)0xc948, (q15_t)0x1ec3, + (q15_t)0xc94f, (q15_t)0x1eb8, (q15_t)0xc955, (q15_t)0x1ead, (q15_t)0xc95c, + (q15_t)0x1ea3, (q15_t)0xc963, (q15_t)0x1e98, (q15_t)0xc969, (q15_t)0x1e8d, + (q15_t)0xc970, (q15_t)0x1e83, (q15_t)0xc976, (q15_t)0x1e78, (q15_t)0xc97d, + (q15_t)0x1e6d, (q15_t)0xc983, (q15_t)0x1e62, (q15_t)0xc98a, (q15_t)0x1e58, + (q15_t)0xc991, (q15_t)0x1e4d, (q15_t)0xc997, (q15_t)0x1e42, (q15_t)0xc99e, + (q15_t)0x1e38, (q15_t)0xc9a4, (q15_t)0x1e2d, (q15_t)0xc9ab, (q15_t)0x1e22, + (q15_t)0xc9b2, (q15_t)0x1e18, (q15_t)0xc9b8, (q15_t)0x1e0d, (q15_t)0xc9bf, + (q15_t)0x1e02, (q15_t)0xc9c6, (q15_t)0x1df8, (q15_t)0xc9cc, (q15_t)0x1ded, + (q15_t)0xc9d3, (q15_t)0x1de2, (q15_t)0xc9da, (q15_t)0x1dd8, (q15_t)0xc9e0, + (q15_t)0x1dcd, (q15_t)0xc9e7, (q15_t)0x1dc3, (q15_t)0xc9ee, (q15_t)0x1db8, + (q15_t)0xc9f5, (q15_t)0x1dad, (q15_t)0xc9fb, (q15_t)0x1da3, (q15_t)0xca02, + (q15_t)0x1d98, (q15_t)0xca09, (q15_t)0x1d8e, (q15_t)0xca10, (q15_t)0x1d83, + (q15_t)0xca16, (q15_t)0x1d78, (q15_t)0xca1d, (q15_t)0x1d6e, (q15_t)0xca24, + (q15_t)0x1d63, (q15_t)0xca2b, (q15_t)0x1d59, (q15_t)0xca32, (q15_t)0x1d4e, + (q15_t)0xca38, (q15_t)0x1d44, (q15_t)0xca3f, (q15_t)0x1d39, (q15_t)0xca46, + (q15_t)0x1d2e, (q15_t)0xca4d, (q15_t)0x1d24, (q15_t)0xca54, (q15_t)0x1d19, + (q15_t)0xca5b, (q15_t)0x1d0f, (q15_t)0xca61, (q15_t)0x1d04, (q15_t)0xca68, + (q15_t)0x1cfa, (q15_t)0xca6f, (q15_t)0x1cef, (q15_t)0xca76, (q15_t)0x1ce5, + (q15_t)0xca7d, (q15_t)0x1cda, (q15_t)0xca84, (q15_t)0x1cd0, (q15_t)0xca8b, + (q15_t)0x1cc5, (q15_t)0xca92, (q15_t)0x1cbb, (q15_t)0xca99, (q15_t)0x1cb0, + (q15_t)0xca9f, (q15_t)0x1ca6, (q15_t)0xcaa6, (q15_t)0x1c9b, (q15_t)0xcaad, + (q15_t)0x1c91, (q15_t)0xcab4, (q15_t)0x1c86, (q15_t)0xcabb, (q15_t)0x1c7c, + (q15_t)0xcac2, (q15_t)0x1c72, (q15_t)0xcac9, (q15_t)0x1c67, (q15_t)0xcad0, + (q15_t)0x1c5d, (q15_t)0xcad7, (q15_t)0x1c52, (q15_t)0xcade, (q15_t)0x1c48, + (q15_t)0xcae5, (q15_t)0x1c3d, (q15_t)0xcaec, (q15_t)0x1c33, (q15_t)0xcaf3, + (q15_t)0x1c29, (q15_t)0xcafa, (q15_t)0x1c1e, (q15_t)0xcb01, (q15_t)0x1c14, + (q15_t)0xcb08, (q15_t)0x1c09, (q15_t)0xcb0f, (q15_t)0x1bff, (q15_t)0xcb16, + (q15_t)0x1bf5, (q15_t)0xcb1e, (q15_t)0x1bea, (q15_t)0xcb25, (q15_t)0x1be0, + (q15_t)0xcb2c, (q15_t)0x1bd5, (q15_t)0xcb33, (q15_t)0x1bcb, (q15_t)0xcb3a, + (q15_t)0x1bc1, (q15_t)0xcb41, (q15_t)0x1bb6, (q15_t)0xcb48, (q15_t)0x1bac, + (q15_t)0xcb4f, (q15_t)0x1ba2, (q15_t)0xcb56, (q15_t)0x1b97, (q15_t)0xcb5e, + (q15_t)0x1b8d, (q15_t)0xcb65, (q15_t)0x1b83, (q15_t)0xcb6c, (q15_t)0x1b78, + (q15_t)0xcb73, (q15_t)0x1b6e, (q15_t)0xcb7a, (q15_t)0x1b64, (q15_t)0xcb81, + (q15_t)0x1b59, (q15_t)0xcb89, (q15_t)0x1b4f, (q15_t)0xcb90, (q15_t)0x1b45, + (q15_t)0xcb97, (q15_t)0x1b3b, (q15_t)0xcb9e, (q15_t)0x1b30, (q15_t)0xcba5, + (q15_t)0x1b26, (q15_t)0xcbad, (q15_t)0x1b1c, (q15_t)0xcbb4, (q15_t)0x1b11, + (q15_t)0xcbbb, (q15_t)0x1b07, (q15_t)0xcbc2, (q15_t)0x1afd, (q15_t)0xcbca, + (q15_t)0x1af3, (q15_t)0xcbd1, (q15_t)0x1ae8, (q15_t)0xcbd8, (q15_t)0x1ade, + (q15_t)0xcbe0, (q15_t)0x1ad4, (q15_t)0xcbe7, (q15_t)0x1aca, (q15_t)0xcbee, + (q15_t)0x1abf, (q15_t)0xcbf5, (q15_t)0x1ab5, (q15_t)0xcbfd, (q15_t)0x1aab, + (q15_t)0xcc04, (q15_t)0x1aa1, (q15_t)0xcc0b, (q15_t)0x1a97, (q15_t)0xcc13, + (q15_t)0x1a8c, (q15_t)0xcc1a, (q15_t)0x1a82, (q15_t)0xcc21, (q15_t)0x1a78, + (q15_t)0xcc29, (q15_t)0x1a6e, (q15_t)0xcc30, (q15_t)0x1a64, (q15_t)0xcc38, + (q15_t)0x1a5a, (q15_t)0xcc3f, (q15_t)0x1a4f, (q15_t)0xcc46, (q15_t)0x1a45, + (q15_t)0xcc4e, (q15_t)0x1a3b, (q15_t)0xcc55, (q15_t)0x1a31, (q15_t)0xcc5d, + (q15_t)0x1a27, (q15_t)0xcc64, (q15_t)0x1a1d, (q15_t)0xcc6b, (q15_t)0x1a13, + (q15_t)0xcc73, (q15_t)0x1a08, (q15_t)0xcc7a, (q15_t)0x19fe, (q15_t)0xcc82, + (q15_t)0x19f4, (q15_t)0xcc89, (q15_t)0x19ea, (q15_t)0xcc91, (q15_t)0x19e0, + (q15_t)0xcc98, (q15_t)0x19d6, (q15_t)0xcca0, (q15_t)0x19cc, (q15_t)0xcca7, + (q15_t)0x19c2, (q15_t)0xccaf, (q15_t)0x19b8, (q15_t)0xccb6, (q15_t)0x19ae, + (q15_t)0xccbe, (q15_t)0x19a4, (q15_t)0xccc5, (q15_t)0x199a, (q15_t)0xcccd, + (q15_t)0x198f, (q15_t)0xccd4, (q15_t)0x1985, (q15_t)0xccdc, (q15_t)0x197b, + (q15_t)0xcce3, (q15_t)0x1971, (q15_t)0xcceb, (q15_t)0x1967, (q15_t)0xccf3, + (q15_t)0x195d, (q15_t)0xccfa, (q15_t)0x1953, (q15_t)0xcd02, (q15_t)0x1949, + (q15_t)0xcd09, (q15_t)0x193f, (q15_t)0xcd11, (q15_t)0x1935, (q15_t)0xcd19, + (q15_t)0x192b, (q15_t)0xcd20, (q15_t)0x1921, (q15_t)0xcd28, (q15_t)0x1917, + (q15_t)0xcd30, (q15_t)0x190d, (q15_t)0xcd37, (q15_t)0x1903, (q15_t)0xcd3f, + (q15_t)0x18f9, (q15_t)0xcd46, (q15_t)0x18ef, (q15_t)0xcd4e, (q15_t)0x18e6, + (q15_t)0xcd56, (q15_t)0x18dc, (q15_t)0xcd5d, (q15_t)0x18d2, (q15_t)0xcd65, + (q15_t)0x18c8, (q15_t)0xcd6d, (q15_t)0x18be, (q15_t)0xcd75, (q15_t)0x18b4, + (q15_t)0xcd7c, (q15_t)0x18aa, (q15_t)0xcd84, (q15_t)0x18a0, (q15_t)0xcd8c, + (q15_t)0x1896, (q15_t)0xcd93, (q15_t)0x188c, (q15_t)0xcd9b, (q15_t)0x1882, + (q15_t)0xcda3, (q15_t)0x1878, (q15_t)0xcdab, (q15_t)0x186f, (q15_t)0xcdb2, + (q15_t)0x1865, (q15_t)0xcdba, (q15_t)0x185b, (q15_t)0xcdc2, (q15_t)0x1851, + (q15_t)0xcdca, (q15_t)0x1847, (q15_t)0xcdd2, (q15_t)0x183d, (q15_t)0xcdd9, + (q15_t)0x1833, (q15_t)0xcde1, (q15_t)0x182a, (q15_t)0xcde9, (q15_t)0x1820, + (q15_t)0xcdf1, (q15_t)0x1816, (q15_t)0xcdf9, (q15_t)0x180c, (q15_t)0xce01, + (q15_t)0x1802, (q15_t)0xce08, (q15_t)0x17f8, (q15_t)0xce10, (q15_t)0x17ef, + (q15_t)0xce18, (q15_t)0x17e5, (q15_t)0xce20, (q15_t)0x17db, (q15_t)0xce28, + (q15_t)0x17d1, (q15_t)0xce30, (q15_t)0x17c8, (q15_t)0xce38, (q15_t)0x17be, + (q15_t)0xce40, (q15_t)0x17b4, (q15_t)0xce47, (q15_t)0x17aa, (q15_t)0xce4f, + (q15_t)0x17a0, (q15_t)0xce57, (q15_t)0x1797, (q15_t)0xce5f, (q15_t)0x178d, + (q15_t)0xce67, (q15_t)0x1783, (q15_t)0xce6f, (q15_t)0x177a, (q15_t)0xce77, + (q15_t)0x1770, (q15_t)0xce7f, (q15_t)0x1766, (q15_t)0xce87, (q15_t)0x175c, + (q15_t)0xce8f, (q15_t)0x1753, (q15_t)0xce97, (q15_t)0x1749, (q15_t)0xce9f, + (q15_t)0x173f, (q15_t)0xcea7, (q15_t)0x1736, (q15_t)0xceaf, (q15_t)0x172c, + (q15_t)0xceb7, (q15_t)0x1722, (q15_t)0xcebf, (q15_t)0x1719, (q15_t)0xcec7, + (q15_t)0x170f, (q15_t)0xcecf, (q15_t)0x1705, (q15_t)0xced7, (q15_t)0x16fc, + (q15_t)0xcedf, (q15_t)0x16f2, (q15_t)0xcee7, (q15_t)0x16e8, (q15_t)0xceef, + (q15_t)0x16df, (q15_t)0xcef7, (q15_t)0x16d5, (q15_t)0xceff, (q15_t)0x16cb, + (q15_t)0xcf07, (q15_t)0x16c2, (q15_t)0xcf10, (q15_t)0x16b8, (q15_t)0xcf18, + (q15_t)0x16af, (q15_t)0xcf20, (q15_t)0x16a5, (q15_t)0xcf28, (q15_t)0x169b, + (q15_t)0xcf30, (q15_t)0x1692, (q15_t)0xcf38, (q15_t)0x1688, (q15_t)0xcf40, + (q15_t)0x167f, (q15_t)0xcf48, (q15_t)0x1675, (q15_t)0xcf51, (q15_t)0x166c, + (q15_t)0xcf59, (q15_t)0x1662, (q15_t)0xcf61, (q15_t)0x1659, (q15_t)0xcf69, + (q15_t)0x164f, (q15_t)0xcf71, (q15_t)0x1645, (q15_t)0xcf79, (q15_t)0x163c, + (q15_t)0xcf82, (q15_t)0x1632, (q15_t)0xcf8a, (q15_t)0x1629, (q15_t)0xcf92, + (q15_t)0x161f, (q15_t)0xcf9a, (q15_t)0x1616, (q15_t)0xcfa3, (q15_t)0x160c, + (q15_t)0xcfab, (q15_t)0x1603, (q15_t)0xcfb3, (q15_t)0x15f9, (q15_t)0xcfbb, + (q15_t)0x15f0, (q15_t)0xcfc4, (q15_t)0x15e6, (q15_t)0xcfcc, (q15_t)0x15dd, + (q15_t)0xcfd4, (q15_t)0x15d4, (q15_t)0xcfdc, (q15_t)0x15ca, (q15_t)0xcfe5, + (q15_t)0x15c1, (q15_t)0xcfed, (q15_t)0x15b7, (q15_t)0xcff5, (q15_t)0x15ae, + (q15_t)0xcffe, (q15_t)0x15a4, (q15_t)0xd006, (q15_t)0x159b, (q15_t)0xd00e, + (q15_t)0x1592, (q15_t)0xd016, (q15_t)0x1588, (q15_t)0xd01f, (q15_t)0x157f, + (q15_t)0xd027, (q15_t)0x1575, (q15_t)0xd030, (q15_t)0x156c, (q15_t)0xd038, + (q15_t)0x1563, (q15_t)0xd040, (q15_t)0x1559, (q15_t)0xd049, (q15_t)0x1550, + (q15_t)0xd051, (q15_t)0x1547, (q15_t)0xd059, (q15_t)0x153d, (q15_t)0xd062, + (q15_t)0x1534, (q15_t)0xd06a, (q15_t)0x152a, (q15_t)0xd073, (q15_t)0x1521, + (q15_t)0xd07b, (q15_t)0x1518, (q15_t)0xd083, (q15_t)0x150e, (q15_t)0xd08c, + (q15_t)0x1505, (q15_t)0xd094, (q15_t)0x14fc, (q15_t)0xd09d, (q15_t)0x14f3, + (q15_t)0xd0a5, (q15_t)0x14e9, (q15_t)0xd0ae, (q15_t)0x14e0, (q15_t)0xd0b6, + (q15_t)0x14d7, (q15_t)0xd0bf, (q15_t)0x14cd, (q15_t)0xd0c7, (q15_t)0x14c4, + (q15_t)0xd0d0, (q15_t)0x14bb, (q15_t)0xd0d8, (q15_t)0x14b2, (q15_t)0xd0e0, + (q15_t)0x14a8, (q15_t)0xd0e9, (q15_t)0x149f, (q15_t)0xd0f2, (q15_t)0x1496, + (q15_t)0xd0fa, (q15_t)0x148d, (q15_t)0xd103, (q15_t)0x1483, (q15_t)0xd10b, + (q15_t)0x147a, (q15_t)0xd114, (q15_t)0x1471, (q15_t)0xd11c, (q15_t)0x1468, + (q15_t)0xd125, (q15_t)0x145f, (q15_t)0xd12d, (q15_t)0x1455, (q15_t)0xd136, + (q15_t)0x144c, (q15_t)0xd13e, (q15_t)0x1443, (q15_t)0xd147, (q15_t)0x143a, + (q15_t)0xd150, (q15_t)0x1431, (q15_t)0xd158, (q15_t)0x1428, (q15_t)0xd161, + (q15_t)0x141e, (q15_t)0xd169, (q15_t)0x1415, (q15_t)0xd172, (q15_t)0x140c, + (q15_t)0xd17b, (q15_t)0x1403, (q15_t)0xd183, (q15_t)0x13fa, (q15_t)0xd18c, + (q15_t)0x13f1, (q15_t)0xd195, (q15_t)0x13e8, (q15_t)0xd19d, (q15_t)0x13df, + (q15_t)0xd1a6, (q15_t)0x13d5, (q15_t)0xd1af, (q15_t)0x13cc, (q15_t)0xd1b7, + (q15_t)0x13c3, (q15_t)0xd1c0, (q15_t)0x13ba, (q15_t)0xd1c9, (q15_t)0x13b1, + (q15_t)0xd1d1, (q15_t)0x13a8, (q15_t)0xd1da, (q15_t)0x139f, (q15_t)0xd1e3, + (q15_t)0x1396, (q15_t)0xd1eb, (q15_t)0x138d, (q15_t)0xd1f4, (q15_t)0x1384, + (q15_t)0xd1fd, (q15_t)0x137b, (q15_t)0xd206, (q15_t)0x1372, (q15_t)0xd20e, + (q15_t)0x1369, (q15_t)0xd217, (q15_t)0x1360, (q15_t)0xd220, (q15_t)0x1357, + (q15_t)0xd229, (q15_t)0x134e, (q15_t)0xd231, (q15_t)0x1345, (q15_t)0xd23a, + (q15_t)0x133c, (q15_t)0xd243, (q15_t)0x1333, (q15_t)0xd24c, (q15_t)0x132a, + (q15_t)0xd255, (q15_t)0x1321, (q15_t)0xd25d, (q15_t)0x1318, (q15_t)0xd266, + (q15_t)0x130f, (q15_t)0xd26f, (q15_t)0x1306, (q15_t)0xd278, (q15_t)0x12fd, + (q15_t)0xd281, (q15_t)0x12f4, (q15_t)0xd28a, (q15_t)0x12eb, (q15_t)0xd292, + (q15_t)0x12e2, (q15_t)0xd29b, (q15_t)0x12d9, (q15_t)0xd2a4, (q15_t)0x12d1, + (q15_t)0xd2ad, (q15_t)0x12c8, (q15_t)0xd2b6, (q15_t)0x12bf, (q15_t)0xd2bf, + (q15_t)0x12b6, (q15_t)0xd2c8, (q15_t)0x12ad, (q15_t)0xd2d1, (q15_t)0x12a4, + (q15_t)0xd2d9, (q15_t)0x129b, (q15_t)0xd2e2, (q15_t)0x1292, (q15_t)0xd2eb, + (q15_t)0x128a, (q15_t)0xd2f4, (q15_t)0x1281, (q15_t)0xd2fd, (q15_t)0x1278, + (q15_t)0xd306, (q15_t)0x126f, (q15_t)0xd30f, (q15_t)0x1266, (q15_t)0xd318, + (q15_t)0x125d, (q15_t)0xd321, (q15_t)0x1255, (q15_t)0xd32a, (q15_t)0x124c, + (q15_t)0xd333, (q15_t)0x1243, (q15_t)0xd33c, (q15_t)0x123a, (q15_t)0xd345, + (q15_t)0x1231, (q15_t)0xd34e, (q15_t)0x1229, (q15_t)0xd357, (q15_t)0x1220, + (q15_t)0xd360, (q15_t)0x1217, (q15_t)0xd369, (q15_t)0x120e, (q15_t)0xd372, + (q15_t)0x1206, (q15_t)0xd37b, (q15_t)0x11fd, (q15_t)0xd384, (q15_t)0x11f4, + (q15_t)0xd38d, (q15_t)0x11eb, (q15_t)0xd396, (q15_t)0x11e3, (q15_t)0xd39f, + (q15_t)0x11da, (q15_t)0xd3a8, (q15_t)0x11d1, (q15_t)0xd3b1, (q15_t)0x11c9, + (q15_t)0xd3ba, (q15_t)0x11c0, (q15_t)0xd3c3, (q15_t)0x11b7, (q15_t)0xd3cc, + (q15_t)0x11af, (q15_t)0xd3d5, (q15_t)0x11a6, (q15_t)0xd3df, (q15_t)0x119d, + (q15_t)0xd3e8, (q15_t)0x1195, (q15_t)0xd3f1, (q15_t)0x118c, (q15_t)0xd3fa, + (q15_t)0x1183, (q15_t)0xd403, (q15_t)0x117b, (q15_t)0xd40c, (q15_t)0x1172, + (q15_t)0xd415, (q15_t)0x1169, (q15_t)0xd41e, (q15_t)0x1161, (q15_t)0xd428, + (q15_t)0x1158, (q15_t)0xd431, (q15_t)0x1150, (q15_t)0xd43a, (q15_t)0x1147, + (q15_t)0xd443, (q15_t)0x113e, (q15_t)0xd44c, (q15_t)0x1136, (q15_t)0xd455, + (q15_t)0x112d, (q15_t)0xd45f, (q15_t)0x1125, (q15_t)0xd468, (q15_t)0x111c, + (q15_t)0xd471, (q15_t)0x1114, (q15_t)0xd47a, (q15_t)0x110b, (q15_t)0xd483, + (q15_t)0x1103, (q15_t)0xd48d, (q15_t)0x10fa, (q15_t)0xd496, (q15_t)0x10f2, + (q15_t)0xd49f, (q15_t)0x10e9, (q15_t)0xd4a8, (q15_t)0x10e0, (q15_t)0xd4b2, + (q15_t)0x10d8, (q15_t)0xd4bb, (q15_t)0x10d0, (q15_t)0xd4c4, (q15_t)0x10c7, + (q15_t)0xd4cd, (q15_t)0x10bf, (q15_t)0xd4d7, (q15_t)0x10b6, (q15_t)0xd4e0, + (q15_t)0x10ae, (q15_t)0xd4e9, (q15_t)0x10a5, (q15_t)0xd4f3, (q15_t)0x109d, + (q15_t)0xd4fc, (q15_t)0x1094, (q15_t)0xd505, (q15_t)0x108c, (q15_t)0xd50e, + (q15_t)0x1083, (q15_t)0xd518, (q15_t)0x107b, (q15_t)0xd521, (q15_t)0x1073, + (q15_t)0xd52a, (q15_t)0x106a, (q15_t)0xd534, (q15_t)0x1062, (q15_t)0xd53d, + (q15_t)0x1059, (q15_t)0xd547, (q15_t)0x1051, (q15_t)0xd550, (q15_t)0x1049, + (q15_t)0xd559, (q15_t)0x1040, (q15_t)0xd563, (q15_t)0x1038, (q15_t)0xd56c, + (q15_t)0x1030, (q15_t)0xd575, (q15_t)0x1027, (q15_t)0xd57f, (q15_t)0x101f, + (q15_t)0xd588, (q15_t)0x1016, (q15_t)0xd592, (q15_t)0x100e, (q15_t)0xd59b, + (q15_t)0x1006, (q15_t)0xd5a4, (q15_t)0xffe, (q15_t)0xd5ae, (q15_t)0xff5, + (q15_t)0xd5b7, (q15_t)0xfed, (q15_t)0xd5c1, (q15_t)0xfe5, (q15_t)0xd5ca, + (q15_t)0xfdc, (q15_t)0xd5d4, (q15_t)0xfd4, (q15_t)0xd5dd, (q15_t)0xfcc, + (q15_t)0xd5e6, (q15_t)0xfc4, (q15_t)0xd5f0, (q15_t)0xfbb, (q15_t)0xd5f9, + (q15_t)0xfb3, (q15_t)0xd603, (q15_t)0xfab, (q15_t)0xd60c, (q15_t)0xfa3, + (q15_t)0xd616, (q15_t)0xf9a, (q15_t)0xd61f, (q15_t)0xf92, (q15_t)0xd629, + (q15_t)0xf8a, (q15_t)0xd632, (q15_t)0xf82, (q15_t)0xd63c, (q15_t)0xf79, + (q15_t)0xd645, (q15_t)0xf71, (q15_t)0xd64f, (q15_t)0xf69, (q15_t)0xd659, + (q15_t)0xf61, (q15_t)0xd662, (q15_t)0xf59, (q15_t)0xd66c, (q15_t)0xf51, + (q15_t)0xd675, (q15_t)0xf48, (q15_t)0xd67f, (q15_t)0xf40, (q15_t)0xd688, + (q15_t)0xf38, (q15_t)0xd692, (q15_t)0xf30, (q15_t)0xd69b, (q15_t)0xf28, + (q15_t)0xd6a5, (q15_t)0xf20, (q15_t)0xd6af, (q15_t)0xf18, (q15_t)0xd6b8, + (q15_t)0xf10, (q15_t)0xd6c2, (q15_t)0xf07, (q15_t)0xd6cb, (q15_t)0xeff, + (q15_t)0xd6d5, (q15_t)0xef7, (q15_t)0xd6df, (q15_t)0xeef, (q15_t)0xd6e8, + (q15_t)0xee7, (q15_t)0xd6f2, (q15_t)0xedf, (q15_t)0xd6fc, (q15_t)0xed7, + (q15_t)0xd705, (q15_t)0xecf, (q15_t)0xd70f, (q15_t)0xec7, (q15_t)0xd719, + (q15_t)0xebf, (q15_t)0xd722, (q15_t)0xeb7, (q15_t)0xd72c, (q15_t)0xeaf, + (q15_t)0xd736, (q15_t)0xea7, (q15_t)0xd73f, (q15_t)0xe9f, (q15_t)0xd749, + (q15_t)0xe97, (q15_t)0xd753, (q15_t)0xe8f, (q15_t)0xd75c, (q15_t)0xe87, + (q15_t)0xd766, (q15_t)0xe7f, (q15_t)0xd770, (q15_t)0xe77, (q15_t)0xd77a, + (q15_t)0xe6f, (q15_t)0xd783, (q15_t)0xe67, (q15_t)0xd78d, (q15_t)0xe5f, + (q15_t)0xd797, (q15_t)0xe57, (q15_t)0xd7a0, (q15_t)0xe4f, (q15_t)0xd7aa, + (q15_t)0xe47, (q15_t)0xd7b4, (q15_t)0xe40, (q15_t)0xd7be, (q15_t)0xe38, + (q15_t)0xd7c8, (q15_t)0xe30, (q15_t)0xd7d1, (q15_t)0xe28, (q15_t)0xd7db, + (q15_t)0xe20, (q15_t)0xd7e5, (q15_t)0xe18, (q15_t)0xd7ef, (q15_t)0xe10, + (q15_t)0xd7f8, (q15_t)0xe08, (q15_t)0xd802, (q15_t)0xe01, (q15_t)0xd80c, + (q15_t)0xdf9, (q15_t)0xd816, (q15_t)0xdf1, (q15_t)0xd820, (q15_t)0xde9, + (q15_t)0xd82a, (q15_t)0xde1, (q15_t)0xd833, (q15_t)0xdd9, (q15_t)0xd83d, + (q15_t)0xdd2, (q15_t)0xd847, (q15_t)0xdca, (q15_t)0xd851, (q15_t)0xdc2, + (q15_t)0xd85b, (q15_t)0xdba, (q15_t)0xd865, (q15_t)0xdb2, (q15_t)0xd86f, + (q15_t)0xdab, (q15_t)0xd878, (q15_t)0xda3, (q15_t)0xd882, (q15_t)0xd9b, + (q15_t)0xd88c, (q15_t)0xd93, (q15_t)0xd896, (q15_t)0xd8c, (q15_t)0xd8a0, + (q15_t)0xd84, (q15_t)0xd8aa, (q15_t)0xd7c, (q15_t)0xd8b4, (q15_t)0xd75, + (q15_t)0xd8be, (q15_t)0xd6d, (q15_t)0xd8c8, (q15_t)0xd65, (q15_t)0xd8d2, + (q15_t)0xd5d, (q15_t)0xd8dc, (q15_t)0xd56, (q15_t)0xd8e6, (q15_t)0xd4e, + (q15_t)0xd8ef, (q15_t)0xd46, (q15_t)0xd8f9, (q15_t)0xd3f, (q15_t)0xd903, + (q15_t)0xd37, (q15_t)0xd90d, (q15_t)0xd30, (q15_t)0xd917, (q15_t)0xd28, + (q15_t)0xd921, (q15_t)0xd20, (q15_t)0xd92b, (q15_t)0xd19, (q15_t)0xd935, + (q15_t)0xd11, (q15_t)0xd93f, (q15_t)0xd09, (q15_t)0xd949, (q15_t)0xd02, + (q15_t)0xd953, (q15_t)0xcfa, (q15_t)0xd95d, (q15_t)0xcf3, (q15_t)0xd967, + (q15_t)0xceb, (q15_t)0xd971, (q15_t)0xce3, (q15_t)0xd97b, (q15_t)0xcdc, + (q15_t)0xd985, (q15_t)0xcd4, (q15_t)0xd98f, (q15_t)0xccd, (q15_t)0xd99a, + (q15_t)0xcc5, (q15_t)0xd9a4, (q15_t)0xcbe, (q15_t)0xd9ae, (q15_t)0xcb6, + (q15_t)0xd9b8, (q15_t)0xcaf, (q15_t)0xd9c2, (q15_t)0xca7, (q15_t)0xd9cc, + (q15_t)0xca0, (q15_t)0xd9d6, (q15_t)0xc98, (q15_t)0xd9e0, (q15_t)0xc91, + (q15_t)0xd9ea, (q15_t)0xc89, (q15_t)0xd9f4, (q15_t)0xc82, (q15_t)0xd9fe, + (q15_t)0xc7a, (q15_t)0xda08, (q15_t)0xc73, (q15_t)0xda13, (q15_t)0xc6b, + (q15_t)0xda1d, (q15_t)0xc64, (q15_t)0xda27, (q15_t)0xc5d, (q15_t)0xda31, + (q15_t)0xc55, (q15_t)0xda3b, (q15_t)0xc4e, (q15_t)0xda45, (q15_t)0xc46, + (q15_t)0xda4f, (q15_t)0xc3f, (q15_t)0xda5a, (q15_t)0xc38, (q15_t)0xda64, + (q15_t)0xc30, (q15_t)0xda6e, (q15_t)0xc29, (q15_t)0xda78, (q15_t)0xc21, + (q15_t)0xda82, (q15_t)0xc1a, (q15_t)0xda8c, (q15_t)0xc13, (q15_t)0xda97, + (q15_t)0xc0b, (q15_t)0xdaa1, (q15_t)0xc04, (q15_t)0xdaab, (q15_t)0xbfd, + (q15_t)0xdab5, (q15_t)0xbf5, (q15_t)0xdabf, (q15_t)0xbee, (q15_t)0xdaca, + (q15_t)0xbe7, (q15_t)0xdad4, (q15_t)0xbe0, (q15_t)0xdade, (q15_t)0xbd8, + (q15_t)0xdae8, (q15_t)0xbd1, (q15_t)0xdaf3, (q15_t)0xbca, (q15_t)0xdafd, + (q15_t)0xbc2, (q15_t)0xdb07, (q15_t)0xbbb, (q15_t)0xdb11, (q15_t)0xbb4, + (q15_t)0xdb1c, (q15_t)0xbad, (q15_t)0xdb26, (q15_t)0xba5, (q15_t)0xdb30, + (q15_t)0xb9e, (q15_t)0xdb3b, (q15_t)0xb97, (q15_t)0xdb45, (q15_t)0xb90, + (q15_t)0xdb4f, (q15_t)0xb89, (q15_t)0xdb59, (q15_t)0xb81, (q15_t)0xdb64, + (q15_t)0xb7a, (q15_t)0xdb6e, (q15_t)0xb73, (q15_t)0xdb78, (q15_t)0xb6c, + (q15_t)0xdb83, (q15_t)0xb65, (q15_t)0xdb8d, (q15_t)0xb5e, (q15_t)0xdb97, + (q15_t)0xb56, (q15_t)0xdba2, (q15_t)0xb4f, (q15_t)0xdbac, (q15_t)0xb48, + (q15_t)0xdbb6, (q15_t)0xb41, (q15_t)0xdbc1, (q15_t)0xb3a, (q15_t)0xdbcb, + (q15_t)0xb33, (q15_t)0xdbd5, (q15_t)0xb2c, (q15_t)0xdbe0, (q15_t)0xb25, + (q15_t)0xdbea, (q15_t)0xb1e, (q15_t)0xdbf5, (q15_t)0xb16, (q15_t)0xdbff, + (q15_t)0xb0f, (q15_t)0xdc09, (q15_t)0xb08, (q15_t)0xdc14, (q15_t)0xb01, + (q15_t)0xdc1e, (q15_t)0xafa, (q15_t)0xdc29, (q15_t)0xaf3, (q15_t)0xdc33, + (q15_t)0xaec, (q15_t)0xdc3d, (q15_t)0xae5, (q15_t)0xdc48, (q15_t)0xade, + (q15_t)0xdc52, (q15_t)0xad7, (q15_t)0xdc5d, (q15_t)0xad0, (q15_t)0xdc67, + (q15_t)0xac9, (q15_t)0xdc72, (q15_t)0xac2, (q15_t)0xdc7c, (q15_t)0xabb, + (q15_t)0xdc86, (q15_t)0xab4, (q15_t)0xdc91, (q15_t)0xaad, (q15_t)0xdc9b, + (q15_t)0xaa6, (q15_t)0xdca6, (q15_t)0xa9f, (q15_t)0xdcb0, (q15_t)0xa99, + (q15_t)0xdcbb, (q15_t)0xa92, (q15_t)0xdcc5, (q15_t)0xa8b, (q15_t)0xdcd0, + (q15_t)0xa84, (q15_t)0xdcda, (q15_t)0xa7d, (q15_t)0xdce5, (q15_t)0xa76, + (q15_t)0xdcef, (q15_t)0xa6f, (q15_t)0xdcfa, (q15_t)0xa68, (q15_t)0xdd04, + (q15_t)0xa61, (q15_t)0xdd0f, (q15_t)0xa5b, (q15_t)0xdd19, (q15_t)0xa54, + (q15_t)0xdd24, (q15_t)0xa4d, (q15_t)0xdd2e, (q15_t)0xa46, (q15_t)0xdd39, + (q15_t)0xa3f, (q15_t)0xdd44, (q15_t)0xa38, (q15_t)0xdd4e, (q15_t)0xa32, + (q15_t)0xdd59, (q15_t)0xa2b, (q15_t)0xdd63, (q15_t)0xa24, (q15_t)0xdd6e, + (q15_t)0xa1d, (q15_t)0xdd78, (q15_t)0xa16, (q15_t)0xdd83, (q15_t)0xa10, + (q15_t)0xdd8e, (q15_t)0xa09, (q15_t)0xdd98, (q15_t)0xa02, (q15_t)0xdda3, + (q15_t)0x9fb, (q15_t)0xddad, (q15_t)0x9f5, (q15_t)0xddb8, (q15_t)0x9ee, + (q15_t)0xddc3, (q15_t)0x9e7, (q15_t)0xddcd, (q15_t)0x9e0, (q15_t)0xddd8, + (q15_t)0x9da, (q15_t)0xdde2, (q15_t)0x9d3, (q15_t)0xdded, (q15_t)0x9cc, + (q15_t)0xddf8, (q15_t)0x9c6, (q15_t)0xde02, (q15_t)0x9bf, (q15_t)0xde0d, + (q15_t)0x9b8, (q15_t)0xde18, (q15_t)0x9b2, (q15_t)0xde22, (q15_t)0x9ab, + (q15_t)0xde2d, (q15_t)0x9a4, (q15_t)0xde38, (q15_t)0x99e, (q15_t)0xde42, + (q15_t)0x997, (q15_t)0xde4d, (q15_t)0x991, (q15_t)0xde58, (q15_t)0x98a, + (q15_t)0xde62, (q15_t)0x983, (q15_t)0xde6d, (q15_t)0x97d, (q15_t)0xde78, + (q15_t)0x976, (q15_t)0xde83, (q15_t)0x970, (q15_t)0xde8d, (q15_t)0x969, + (q15_t)0xde98, (q15_t)0x963, (q15_t)0xdea3, (q15_t)0x95c, (q15_t)0xdead, + (q15_t)0x955, (q15_t)0xdeb8, (q15_t)0x94f, (q15_t)0xdec3, (q15_t)0x948, + (q15_t)0xdece, (q15_t)0x942, (q15_t)0xded8, (q15_t)0x93b, (q15_t)0xdee3, + (q15_t)0x935, (q15_t)0xdeee, (q15_t)0x92e, (q15_t)0xdef9, (q15_t)0x928, + (q15_t)0xdf03, (q15_t)0x921, (q15_t)0xdf0e, (q15_t)0x91b, (q15_t)0xdf19, + (q15_t)0x915, (q15_t)0xdf24, (q15_t)0x90e, (q15_t)0xdf2f, (q15_t)0x908, + (q15_t)0xdf39, (q15_t)0x901, (q15_t)0xdf44, (q15_t)0x8fb, (q15_t)0xdf4f, + (q15_t)0x8f4, (q15_t)0xdf5a, (q15_t)0x8ee, (q15_t)0xdf65, (q15_t)0x8e8, + (q15_t)0xdf6f, (q15_t)0x8e1, (q15_t)0xdf7a, (q15_t)0x8db, (q15_t)0xdf85, + (q15_t)0x8d4, (q15_t)0xdf90, (q15_t)0x8ce, (q15_t)0xdf9b, (q15_t)0x8c8, + (q15_t)0xdfa5, (q15_t)0x8c1, (q15_t)0xdfb0, (q15_t)0x8bb, (q15_t)0xdfbb, + (q15_t)0x8b5, (q15_t)0xdfc6, (q15_t)0x8ae, (q15_t)0xdfd1, (q15_t)0x8a8, + (q15_t)0xdfdc, (q15_t)0x8a2, (q15_t)0xdfe7, (q15_t)0x89b, (q15_t)0xdff1, + (q15_t)0x895, (q15_t)0xdffc, (q15_t)0x88f, (q15_t)0xe007, (q15_t)0x889, + (q15_t)0xe012, (q15_t)0x882, (q15_t)0xe01d, (q15_t)0x87c, (q15_t)0xe028, + (q15_t)0x876, (q15_t)0xe033, (q15_t)0x870, (q15_t)0xe03e, (q15_t)0x869, + (q15_t)0xe049, (q15_t)0x863, (q15_t)0xe054, (q15_t)0x85d, (q15_t)0xe05e, + (q15_t)0x857, (q15_t)0xe069, (q15_t)0x850, (q15_t)0xe074, (q15_t)0x84a, + (q15_t)0xe07f, (q15_t)0x844, (q15_t)0xe08a, (q15_t)0x83e, (q15_t)0xe095, + (q15_t)0x838, (q15_t)0xe0a0, (q15_t)0x832, (q15_t)0xe0ab, (q15_t)0x82b, + (q15_t)0xe0b6, (q15_t)0x825, (q15_t)0xe0c1, (q15_t)0x81f, (q15_t)0xe0cc, + (q15_t)0x819, (q15_t)0xe0d7, (q15_t)0x813, (q15_t)0xe0e2, (q15_t)0x80d, + (q15_t)0xe0ed, (q15_t)0x807, (q15_t)0xe0f8, (q15_t)0x801, (q15_t)0xe103, + (q15_t)0x7fb, (q15_t)0xe10e, (q15_t)0x7f5, (q15_t)0xe119, (q15_t)0x7ee, + (q15_t)0xe124, (q15_t)0x7e8, (q15_t)0xe12f, (q15_t)0x7e2, (q15_t)0xe13a, + (q15_t)0x7dc, (q15_t)0xe145, (q15_t)0x7d6, (q15_t)0xe150, (q15_t)0x7d0, + (q15_t)0xe15b, (q15_t)0x7ca, (q15_t)0xe166, (q15_t)0x7c4, (q15_t)0xe171, + (q15_t)0x7be, (q15_t)0xe17c, (q15_t)0x7b8, (q15_t)0xe187, (q15_t)0x7b2, + (q15_t)0xe192, (q15_t)0x7ac, (q15_t)0xe19d, (q15_t)0x7a6, (q15_t)0xe1a8, + (q15_t)0x7a0, (q15_t)0xe1b3, (q15_t)0x79a, (q15_t)0xe1be, (q15_t)0x795, + (q15_t)0xe1ca, (q15_t)0x78f, (q15_t)0xe1d5, (q15_t)0x789, (q15_t)0xe1e0, + (q15_t)0x783, (q15_t)0xe1eb, (q15_t)0x77d, (q15_t)0xe1f6, (q15_t)0x777, + (q15_t)0xe201, (q15_t)0x771, (q15_t)0xe20c, (q15_t)0x76b, (q15_t)0xe217, + (q15_t)0x765, (q15_t)0xe222, (q15_t)0x75f, (q15_t)0xe22d, (q15_t)0x75a, + (q15_t)0xe239, (q15_t)0x754, (q15_t)0xe244, (q15_t)0x74e, (q15_t)0xe24f, + (q15_t)0x748, (q15_t)0xe25a, (q15_t)0x742, (q15_t)0xe265, (q15_t)0x73d, + (q15_t)0xe270, (q15_t)0x737, (q15_t)0xe27b, (q15_t)0x731, (q15_t)0xe287, + (q15_t)0x72b, (q15_t)0xe292, (q15_t)0x725, (q15_t)0xe29d, (q15_t)0x720, + (q15_t)0xe2a8, (q15_t)0x71a, (q15_t)0xe2b3, (q15_t)0x714, (q15_t)0xe2be, + (q15_t)0x70e, (q15_t)0xe2ca, (q15_t)0x709, (q15_t)0xe2d5, (q15_t)0x703, + (q15_t)0xe2e0, (q15_t)0x6fd, (q15_t)0xe2eb, (q15_t)0x6f7, (q15_t)0xe2f6, + (q15_t)0x6f2, (q15_t)0xe301, (q15_t)0x6ec, (q15_t)0xe30d, (q15_t)0x6e6, + (q15_t)0xe318, (q15_t)0x6e1, (q15_t)0xe323, (q15_t)0x6db, (q15_t)0xe32e, + (q15_t)0x6d5, (q15_t)0xe33a, (q15_t)0x6d0, (q15_t)0xe345, (q15_t)0x6ca, + (q15_t)0xe350, (q15_t)0x6c5, (q15_t)0xe35b, (q15_t)0x6bf, (q15_t)0xe367, + (q15_t)0x6b9, (q15_t)0xe372, (q15_t)0x6b4, (q15_t)0xe37d, (q15_t)0x6ae, + (q15_t)0xe388, (q15_t)0x6a8, (q15_t)0xe394, (q15_t)0x6a3, (q15_t)0xe39f, + (q15_t)0x69d, (q15_t)0xe3aa, (q15_t)0x698, (q15_t)0xe3b5, (q15_t)0x692, + (q15_t)0xe3c1, (q15_t)0x68d, (q15_t)0xe3cc, (q15_t)0x687, (q15_t)0xe3d7, + (q15_t)0x682, (q15_t)0xe3e2, (q15_t)0x67c, (q15_t)0xe3ee, (q15_t)0x677, + (q15_t)0xe3f9, (q15_t)0x671, (q15_t)0xe404, (q15_t)0x66c, (q15_t)0xe410, + (q15_t)0x666, (q15_t)0xe41b, (q15_t)0x661, (q15_t)0xe426, (q15_t)0x65b, + (q15_t)0xe432, (q15_t)0x656, (q15_t)0xe43d, (q15_t)0x650, (q15_t)0xe448, + (q15_t)0x64b, (q15_t)0xe454, (q15_t)0x645, (q15_t)0xe45f, (q15_t)0x640, + (q15_t)0xe46a, (q15_t)0x63b, (q15_t)0xe476, (q15_t)0x635, (q15_t)0xe481, + (q15_t)0x630, (q15_t)0xe48c, (q15_t)0x62a, (q15_t)0xe498, (q15_t)0x625, + (q15_t)0xe4a3, (q15_t)0x620, (q15_t)0xe4ae, (q15_t)0x61a, (q15_t)0xe4ba, + (q15_t)0x615, (q15_t)0xe4c5, (q15_t)0x610, (q15_t)0xe4d0, (q15_t)0x60a, + (q15_t)0xe4dc, (q15_t)0x605, (q15_t)0xe4e7, (q15_t)0x600, (q15_t)0xe4f3, + (q15_t)0x5fa, (q15_t)0xe4fe, (q15_t)0x5f5, (q15_t)0xe509, (q15_t)0x5f0, + (q15_t)0xe515, (q15_t)0x5ea, (q15_t)0xe520, (q15_t)0x5e5, (q15_t)0xe52c, + (q15_t)0x5e0, (q15_t)0xe537, (q15_t)0x5db, (q15_t)0xe542, (q15_t)0x5d5, + (q15_t)0xe54e, (q15_t)0x5d0, (q15_t)0xe559, (q15_t)0x5cb, (q15_t)0xe565, + (q15_t)0x5c6, (q15_t)0xe570, (q15_t)0x5c1, (q15_t)0xe57c, (q15_t)0x5bb, + (q15_t)0xe587, (q15_t)0x5b6, (q15_t)0xe592, (q15_t)0x5b1, (q15_t)0xe59e, + (q15_t)0x5ac, (q15_t)0xe5a9, (q15_t)0x5a7, (q15_t)0xe5b5, (q15_t)0x5a1, + (q15_t)0xe5c0, (q15_t)0x59c, (q15_t)0xe5cc, (q15_t)0x597, (q15_t)0xe5d7, + (q15_t)0x592, (q15_t)0xe5e3, (q15_t)0x58d, (q15_t)0xe5ee, (q15_t)0x588, + (q15_t)0xe5fa, (q15_t)0x583, (q15_t)0xe605, (q15_t)0x57e, (q15_t)0xe611, + (q15_t)0x578, (q15_t)0xe61c, (q15_t)0x573, (q15_t)0xe628, (q15_t)0x56e, + (q15_t)0xe633, (q15_t)0x569, (q15_t)0xe63f, (q15_t)0x564, (q15_t)0xe64a, + (q15_t)0x55f, (q15_t)0xe656, (q15_t)0x55a, (q15_t)0xe661, (q15_t)0x555, + (q15_t)0xe66d, (q15_t)0x550, (q15_t)0xe678, (q15_t)0x54b, (q15_t)0xe684, + (q15_t)0x546, (q15_t)0xe68f, (q15_t)0x541, (q15_t)0xe69b, (q15_t)0x53c, + (q15_t)0xe6a6, (q15_t)0x537, (q15_t)0xe6b2, (q15_t)0x532, (q15_t)0xe6bd, + (q15_t)0x52d, (q15_t)0xe6c9, (q15_t)0x528, (q15_t)0xe6d4, (q15_t)0x523, + (q15_t)0xe6e0, (q15_t)0x51e, (q15_t)0xe6ec, (q15_t)0x51a, (q15_t)0xe6f7, + (q15_t)0x515, (q15_t)0xe703, (q15_t)0x510, (q15_t)0xe70e, (q15_t)0x50b, + (q15_t)0xe71a, (q15_t)0x506, (q15_t)0xe725, (q15_t)0x501, (q15_t)0xe731, + (q15_t)0x4fc, (q15_t)0xe73d, (q15_t)0x4f7, (q15_t)0xe748, (q15_t)0x4f2, + (q15_t)0xe754, (q15_t)0x4ee, (q15_t)0xe75f, (q15_t)0x4e9, (q15_t)0xe76b, + (q15_t)0x4e4, (q15_t)0xe777, (q15_t)0x4df, (q15_t)0xe782, (q15_t)0x4da, + (q15_t)0xe78e, (q15_t)0x4d6, (q15_t)0xe799, (q15_t)0x4d1, (q15_t)0xe7a5, + (q15_t)0x4cc, (q15_t)0xe7b1, (q15_t)0x4c7, (q15_t)0xe7bc, (q15_t)0x4c2, + (q15_t)0xe7c8, (q15_t)0x4be, (q15_t)0xe7d3, (q15_t)0x4b9, (q15_t)0xe7df, + (q15_t)0x4b4, (q15_t)0xe7eb, (q15_t)0x4b0, (q15_t)0xe7f6, (q15_t)0x4ab, + (q15_t)0xe802, (q15_t)0x4a6, (q15_t)0xe80e, (q15_t)0x4a1, (q15_t)0xe819, + (q15_t)0x49d, (q15_t)0xe825, (q15_t)0x498, (q15_t)0xe831, (q15_t)0x493, + (q15_t)0xe83c, (q15_t)0x48f, (q15_t)0xe848, (q15_t)0x48a, (q15_t)0xe854, + (q15_t)0x485, (q15_t)0xe85f, (q15_t)0x481, (q15_t)0xe86b, (q15_t)0x47c, + (q15_t)0xe877, (q15_t)0x478, (q15_t)0xe882, (q15_t)0x473, (q15_t)0xe88e, + (q15_t)0x46e, (q15_t)0xe89a, (q15_t)0x46a, (q15_t)0xe8a5, (q15_t)0x465, + (q15_t)0xe8b1, (q15_t)0x461, (q15_t)0xe8bd, (q15_t)0x45c, (q15_t)0xe8c9, + (q15_t)0x457, (q15_t)0xe8d4, (q15_t)0x453, (q15_t)0xe8e0, (q15_t)0x44e, + (q15_t)0xe8ec, (q15_t)0x44a, (q15_t)0xe8f7, (q15_t)0x445, (q15_t)0xe903, + (q15_t)0x441, (q15_t)0xe90f, (q15_t)0x43c, (q15_t)0xe91b, (q15_t)0x438, + (q15_t)0xe926, (q15_t)0x433, (q15_t)0xe932, (q15_t)0x42f, (q15_t)0xe93e, + (q15_t)0x42a, (q15_t)0xe94a, (q15_t)0x426, (q15_t)0xe955, (q15_t)0x422, + (q15_t)0xe961, (q15_t)0x41d, (q15_t)0xe96d, (q15_t)0x419, (q15_t)0xe979, + (q15_t)0x414, (q15_t)0xe984, (q15_t)0x410, (q15_t)0xe990, (q15_t)0x40b, + (q15_t)0xe99c, (q15_t)0x407, (q15_t)0xe9a8, (q15_t)0x403, (q15_t)0xe9b4, + (q15_t)0x3fe, (q15_t)0xe9bf, (q15_t)0x3fa, (q15_t)0xe9cb, (q15_t)0x3f6, + (q15_t)0xe9d7, (q15_t)0x3f1, (q15_t)0xe9e3, (q15_t)0x3ed, (q15_t)0xe9ee, + (q15_t)0x3e9, (q15_t)0xe9fa, (q15_t)0x3e4, (q15_t)0xea06, (q15_t)0x3e0, + (q15_t)0xea12, (q15_t)0x3dc, (q15_t)0xea1e, (q15_t)0x3d7, (q15_t)0xea29, + (q15_t)0x3d3, (q15_t)0xea35, (q15_t)0x3cf, (q15_t)0xea41, (q15_t)0x3ca, + (q15_t)0xea4d, (q15_t)0x3c6, (q15_t)0xea59, (q15_t)0x3c2, (q15_t)0xea65, + (q15_t)0x3be, (q15_t)0xea70, (q15_t)0x3ba, (q15_t)0xea7c, (q15_t)0x3b5, + (q15_t)0xea88, (q15_t)0x3b1, (q15_t)0xea94, (q15_t)0x3ad, (q15_t)0xeaa0, + (q15_t)0x3a9, (q15_t)0xeaac, (q15_t)0x3a5, (q15_t)0xeab7, (q15_t)0x3a0, + (q15_t)0xeac3, (q15_t)0x39c, (q15_t)0xeacf, (q15_t)0x398, (q15_t)0xeadb, + (q15_t)0x394, (q15_t)0xeae7, (q15_t)0x390, (q15_t)0xeaf3, (q15_t)0x38c, + (q15_t)0xeaff, (q15_t)0x387, (q15_t)0xeb0a, (q15_t)0x383, (q15_t)0xeb16, + (q15_t)0x37f, (q15_t)0xeb22, (q15_t)0x37b, (q15_t)0xeb2e, (q15_t)0x377, + (q15_t)0xeb3a, (q15_t)0x373, (q15_t)0xeb46, (q15_t)0x36f, (q15_t)0xeb52, + (q15_t)0x36b, (q15_t)0xeb5e, (q15_t)0x367, (q15_t)0xeb6a, (q15_t)0x363, + (q15_t)0xeb75, (q15_t)0x35f, (q15_t)0xeb81, (q15_t)0x35b, (q15_t)0xeb8d, + (q15_t)0x357, (q15_t)0xeb99, (q15_t)0x353, (q15_t)0xeba5, (q15_t)0x34f, + (q15_t)0xebb1, (q15_t)0x34b, (q15_t)0xebbd, (q15_t)0x347, (q15_t)0xebc9, + (q15_t)0x343, (q15_t)0xebd5, (q15_t)0x33f, (q15_t)0xebe1, (q15_t)0x33b, + (q15_t)0xebed, (q15_t)0x337, (q15_t)0xebf9, (q15_t)0x333, (q15_t)0xec05, + (q15_t)0x32f, (q15_t)0xec10, (q15_t)0x32b, (q15_t)0xec1c, (q15_t)0x327, + (q15_t)0xec28, (q15_t)0x323, (q15_t)0xec34, (q15_t)0x320, (q15_t)0xec40, + (q15_t)0x31c, (q15_t)0xec4c, (q15_t)0x318, (q15_t)0xec58, (q15_t)0x314, + (q15_t)0xec64, (q15_t)0x310, (q15_t)0xec70, (q15_t)0x30c, (q15_t)0xec7c, + (q15_t)0x308, (q15_t)0xec88, (q15_t)0x305, (q15_t)0xec94, (q15_t)0x301, + (q15_t)0xeca0, (q15_t)0x2fd, (q15_t)0xecac, (q15_t)0x2f9, (q15_t)0xecb8, + (q15_t)0x2f5, (q15_t)0xecc4, (q15_t)0x2f2, (q15_t)0xecd0, (q15_t)0x2ee, + (q15_t)0xecdc, (q15_t)0x2ea, (q15_t)0xece8, (q15_t)0x2e6, (q15_t)0xecf4, + (q15_t)0x2e3, (q15_t)0xed00, (q15_t)0x2df, (q15_t)0xed0c, (q15_t)0x2db, + (q15_t)0xed18, (q15_t)0x2d8, (q15_t)0xed24, (q15_t)0x2d4, (q15_t)0xed30, + (q15_t)0x2d0, (q15_t)0xed3c, (q15_t)0x2cc, (q15_t)0xed48, (q15_t)0x2c9, + (q15_t)0xed54, (q15_t)0x2c5, (q15_t)0xed60, (q15_t)0x2c1, (q15_t)0xed6c, + (q15_t)0x2be, (q15_t)0xed78, (q15_t)0x2ba, (q15_t)0xed84, (q15_t)0x2b7, + (q15_t)0xed90, (q15_t)0x2b3, (q15_t)0xed9c, (q15_t)0x2af, (q15_t)0xeda8, + (q15_t)0x2ac, (q15_t)0xedb4, (q15_t)0x2a8, (q15_t)0xedc0, (q15_t)0x2a5, + (q15_t)0xedcc, (q15_t)0x2a1, (q15_t)0xedd8, (q15_t)0x29d, (q15_t)0xede4, + (q15_t)0x29a, (q15_t)0xedf0, (q15_t)0x296, (q15_t)0xedfc, (q15_t)0x293, + (q15_t)0xee09, (q15_t)0x28f, (q15_t)0xee15, (q15_t)0x28c, (q15_t)0xee21, + (q15_t)0x288, (q15_t)0xee2d, (q15_t)0x285, (q15_t)0xee39, (q15_t)0x281, + (q15_t)0xee45, (q15_t)0x27e, (q15_t)0xee51, (q15_t)0x27a, (q15_t)0xee5d, + (q15_t)0x277, (q15_t)0xee69, (q15_t)0x273, (q15_t)0xee75, (q15_t)0x270, + (q15_t)0xee81, (q15_t)0x26d, (q15_t)0xee8d, (q15_t)0x269, (q15_t)0xee99, + (q15_t)0x266, (q15_t)0xeea6, (q15_t)0x262, (q15_t)0xeeb2, (q15_t)0x25f, + (q15_t)0xeebe, (q15_t)0x25c, (q15_t)0xeeca, (q15_t)0x258, (q15_t)0xeed6, + (q15_t)0x255, (q15_t)0xeee2, (q15_t)0x251, (q15_t)0xeeee, (q15_t)0x24e, + (q15_t)0xeefa, (q15_t)0x24b, (q15_t)0xef06, (q15_t)0x247, (q15_t)0xef13, + (q15_t)0x244, (q15_t)0xef1f, (q15_t)0x241, (q15_t)0xef2b, (q15_t)0x23e, + (q15_t)0xef37, (q15_t)0x23a, (q15_t)0xef43, (q15_t)0x237, (q15_t)0xef4f, + (q15_t)0x234, (q15_t)0xef5b, (q15_t)0x230, (q15_t)0xef67, (q15_t)0x22d, + (q15_t)0xef74, (q15_t)0x22a, (q15_t)0xef80, (q15_t)0x227, (q15_t)0xef8c, + (q15_t)0x223, (q15_t)0xef98, (q15_t)0x220, (q15_t)0xefa4, (q15_t)0x21d, + (q15_t)0xefb0, (q15_t)0x21a, (q15_t)0xefbc, (q15_t)0x217, (q15_t)0xefc9, + (q15_t)0x213, (q15_t)0xefd5, (q15_t)0x210, (q15_t)0xefe1, (q15_t)0x20d, + (q15_t)0xefed, (q15_t)0x20a, (q15_t)0xeff9, (q15_t)0x207, (q15_t)0xf005, + (q15_t)0x204, (q15_t)0xf012, (q15_t)0x201, (q15_t)0xf01e, (q15_t)0x1fd, + (q15_t)0xf02a, (q15_t)0x1fa, (q15_t)0xf036, (q15_t)0x1f7, (q15_t)0xf042, + (q15_t)0x1f4, (q15_t)0xf04e, (q15_t)0x1f1, (q15_t)0xf05b, (q15_t)0x1ee, + (q15_t)0xf067, (q15_t)0x1eb, (q15_t)0xf073, (q15_t)0x1e8, (q15_t)0xf07f, + (q15_t)0x1e5, (q15_t)0xf08b, (q15_t)0x1e2, (q15_t)0xf098, (q15_t)0x1df, + (q15_t)0xf0a4, (q15_t)0x1dc, (q15_t)0xf0b0, (q15_t)0x1d9, (q15_t)0xf0bc, + (q15_t)0x1d6, (q15_t)0xf0c8, (q15_t)0x1d3, (q15_t)0xf0d5, (q15_t)0x1d0, + (q15_t)0xf0e1, (q15_t)0x1cd, (q15_t)0xf0ed, (q15_t)0x1ca, (q15_t)0xf0f9, + (q15_t)0x1c7, (q15_t)0xf105, (q15_t)0x1c4, (q15_t)0xf112, (q15_t)0x1c1, + (q15_t)0xf11e, (q15_t)0x1be, (q15_t)0xf12a, (q15_t)0x1bb, (q15_t)0xf136, + (q15_t)0x1b8, (q15_t)0xf143, (q15_t)0x1b6, (q15_t)0xf14f, (q15_t)0x1b3, + (q15_t)0xf15b, (q15_t)0x1b0, (q15_t)0xf167, (q15_t)0x1ad, (q15_t)0xf174, + (q15_t)0x1aa, (q15_t)0xf180, (q15_t)0x1a7, (q15_t)0xf18c, (q15_t)0x1a4, + (q15_t)0xf198, (q15_t)0x1a2, (q15_t)0xf1a4, (q15_t)0x19f, (q15_t)0xf1b1, + (q15_t)0x19c, (q15_t)0xf1bd, (q15_t)0x199, (q15_t)0xf1c9, (q15_t)0x196, + (q15_t)0xf1d5, (q15_t)0x194, (q15_t)0xf1e2, (q15_t)0x191, (q15_t)0xf1ee, + (q15_t)0x18e, (q15_t)0xf1fa, (q15_t)0x18b, (q15_t)0xf207, (q15_t)0x189, + (q15_t)0xf213, (q15_t)0x186, (q15_t)0xf21f, (q15_t)0x183, (q15_t)0xf22b, + (q15_t)0x180, (q15_t)0xf238, (q15_t)0x17e, (q15_t)0xf244, (q15_t)0x17b, + (q15_t)0xf250, (q15_t)0x178, (q15_t)0xf25c, (q15_t)0x176, (q15_t)0xf269, + (q15_t)0x173, (q15_t)0xf275, (q15_t)0x170, (q15_t)0xf281, (q15_t)0x16e, + (q15_t)0xf28e, (q15_t)0x16b, (q15_t)0xf29a, (q15_t)0x168, (q15_t)0xf2a6, + (q15_t)0x166, (q15_t)0xf2b2, (q15_t)0x163, (q15_t)0xf2bf, (q15_t)0x161, + (q15_t)0xf2cb, (q15_t)0x15e, (q15_t)0xf2d7, (q15_t)0x15b, (q15_t)0xf2e4, + (q15_t)0x159, (q15_t)0xf2f0, (q15_t)0x156, (q15_t)0xf2fc, (q15_t)0x154, + (q15_t)0xf308, (q15_t)0x151, (q15_t)0xf315, (q15_t)0x14f, (q15_t)0xf321, + (q15_t)0x14c, (q15_t)0xf32d, (q15_t)0x14a, (q15_t)0xf33a, (q15_t)0x147, + (q15_t)0xf346, (q15_t)0x145, (q15_t)0xf352, (q15_t)0x142, (q15_t)0xf35f, + (q15_t)0x140, (q15_t)0xf36b, (q15_t)0x13d, (q15_t)0xf377, (q15_t)0x13b, + (q15_t)0xf384, (q15_t)0x138, (q15_t)0xf390, (q15_t)0x136, (q15_t)0xf39c, + (q15_t)0x134, (q15_t)0xf3a9, (q15_t)0x131, (q15_t)0xf3b5, (q15_t)0x12f, + (q15_t)0xf3c1, (q15_t)0x12c, (q15_t)0xf3ce, (q15_t)0x12a, (q15_t)0xf3da, + (q15_t)0x128, (q15_t)0xf3e6, (q15_t)0x125, (q15_t)0xf3f3, (q15_t)0x123, + (q15_t)0xf3ff, (q15_t)0x120, (q15_t)0xf40b, (q15_t)0x11e, (q15_t)0xf418, + (q15_t)0x11c, (q15_t)0xf424, (q15_t)0x119, (q15_t)0xf430, (q15_t)0x117, + (q15_t)0xf43d, (q15_t)0x115, (q15_t)0xf449, (q15_t)0x113, (q15_t)0xf455, + (q15_t)0x110, (q15_t)0xf462, (q15_t)0x10e, (q15_t)0xf46e, (q15_t)0x10c, + (q15_t)0xf47b, (q15_t)0x109, (q15_t)0xf487, (q15_t)0x107, (q15_t)0xf493, + (q15_t)0x105, (q15_t)0xf4a0, (q15_t)0x103, (q15_t)0xf4ac, (q15_t)0x100, + (q15_t)0xf4b8, (q15_t)0xfe, (q15_t)0xf4c5, (q15_t)0xfc, (q15_t)0xf4d1, + (q15_t)0xfa, (q15_t)0xf4dd, (q15_t)0xf8, (q15_t)0xf4ea, (q15_t)0xf6, + (q15_t)0xf4f6, (q15_t)0xf3, (q15_t)0xf503, (q15_t)0xf1, (q15_t)0xf50f, + (q15_t)0xef, (q15_t)0xf51b, (q15_t)0xed, (q15_t)0xf528, (q15_t)0xeb, + (q15_t)0xf534, (q15_t)0xe9, (q15_t)0xf540, (q15_t)0xe7, (q15_t)0xf54d, + (q15_t)0xe4, (q15_t)0xf559, (q15_t)0xe2, (q15_t)0xf566, (q15_t)0xe0, + (q15_t)0xf572, (q15_t)0xde, (q15_t)0xf57e, (q15_t)0xdc, (q15_t)0xf58b, + (q15_t)0xda, (q15_t)0xf597, (q15_t)0xd8, (q15_t)0xf5a4, (q15_t)0xd6, + (q15_t)0xf5b0, (q15_t)0xd4, (q15_t)0xf5bc, (q15_t)0xd2, (q15_t)0xf5c9, + (q15_t)0xd0, (q15_t)0xf5d5, (q15_t)0xce, (q15_t)0xf5e2, (q15_t)0xcc, + (q15_t)0xf5ee, (q15_t)0xca, (q15_t)0xf5fa, (q15_t)0xc8, (q15_t)0xf607, + (q15_t)0xc6, (q15_t)0xf613, (q15_t)0xc4, (q15_t)0xf620, (q15_t)0xc2, + (q15_t)0xf62c, (q15_t)0xc0, (q15_t)0xf639, (q15_t)0xbe, (q15_t)0xf645, + (q15_t)0xbd, (q15_t)0xf651, (q15_t)0xbb, (q15_t)0xf65e, (q15_t)0xb9, + (q15_t)0xf66a, (q15_t)0xb7, (q15_t)0xf677, (q15_t)0xb5, (q15_t)0xf683, + (q15_t)0xb3, (q15_t)0xf690, (q15_t)0xb1, (q15_t)0xf69c, (q15_t)0xaf, + (q15_t)0xf6a8, (q15_t)0xae, (q15_t)0xf6b5, (q15_t)0xac, (q15_t)0xf6c1, + (q15_t)0xaa, (q15_t)0xf6ce, (q15_t)0xa8, (q15_t)0xf6da, (q15_t)0xa6, + (q15_t)0xf6e7, (q15_t)0xa5, (q15_t)0xf6f3, (q15_t)0xa3, (q15_t)0xf6ff, + (q15_t)0xa1, (q15_t)0xf70c, (q15_t)0x9f, (q15_t)0xf718, (q15_t)0x9e, + (q15_t)0xf725, (q15_t)0x9c, (q15_t)0xf731, (q15_t)0x9a, (q15_t)0xf73e, + (q15_t)0x98, (q15_t)0xf74a, (q15_t)0x97, (q15_t)0xf757, (q15_t)0x95, + (q15_t)0xf763, (q15_t)0x93, (q15_t)0xf76f, (q15_t)0x92, (q15_t)0xf77c, + (q15_t)0x90, (q15_t)0xf788, (q15_t)0x8e, (q15_t)0xf795, (q15_t)0x8d, + (q15_t)0xf7a1, (q15_t)0x8b, (q15_t)0xf7ae, (q15_t)0x89, (q15_t)0xf7ba, + (q15_t)0x88, (q15_t)0xf7c7, (q15_t)0x86, (q15_t)0xf7d3, (q15_t)0x85, + (q15_t)0xf7e0, (q15_t)0x83, (q15_t)0xf7ec, (q15_t)0x81, (q15_t)0xf7f9, + (q15_t)0x80, (q15_t)0xf805, (q15_t)0x7e, (q15_t)0xf811, (q15_t)0x7d, + (q15_t)0xf81e, (q15_t)0x7b, (q15_t)0xf82a, (q15_t)0x7a, (q15_t)0xf837, + (q15_t)0x78, (q15_t)0xf843, (q15_t)0x77, (q15_t)0xf850, (q15_t)0x75, + (q15_t)0xf85c, (q15_t)0x74, (q15_t)0xf869, (q15_t)0x72, (q15_t)0xf875, + (q15_t)0x71, (q15_t)0xf882, (q15_t)0x6f, (q15_t)0xf88e, (q15_t)0x6e, + (q15_t)0xf89b, (q15_t)0x6c, (q15_t)0xf8a7, (q15_t)0x6b, (q15_t)0xf8b4, + (q15_t)0x69, (q15_t)0xf8c0, (q15_t)0x68, (q15_t)0xf8cd, (q15_t)0x67, + (q15_t)0xf8d9, (q15_t)0x65, (q15_t)0xf8e6, (q15_t)0x64, (q15_t)0xf8f2, + (q15_t)0x62, (q15_t)0xf8ff, (q15_t)0x61, (q15_t)0xf90b, (q15_t)0x60, + (q15_t)0xf918, (q15_t)0x5e, (q15_t)0xf924, (q15_t)0x5d, (q15_t)0xf931, + (q15_t)0x5c, (q15_t)0xf93d, (q15_t)0x5a, (q15_t)0xf94a, (q15_t)0x59, + (q15_t)0xf956, (q15_t)0x58, (q15_t)0xf963, (q15_t)0x56, (q15_t)0xf96f, + (q15_t)0x55, (q15_t)0xf97c, (q15_t)0x54, (q15_t)0xf988, (q15_t)0x53, + (q15_t)0xf995, (q15_t)0x51, (q15_t)0xf9a1, (q15_t)0x50, (q15_t)0xf9ae, + (q15_t)0x4f, (q15_t)0xf9ba, (q15_t)0x4e, (q15_t)0xf9c7, (q15_t)0x4c, + (q15_t)0xf9d3, (q15_t)0x4b, (q15_t)0xf9e0, (q15_t)0x4a, (q15_t)0xf9ec, + (q15_t)0x49, (q15_t)0xf9f9, (q15_t)0x48, (q15_t)0xfa05, (q15_t)0x47, + (q15_t)0xfa12, (q15_t)0x45, (q15_t)0xfa1e, (q15_t)0x44, (q15_t)0xfa2b, + (q15_t)0x43, (q15_t)0xfa37, (q15_t)0x42, (q15_t)0xfa44, (q15_t)0x41, + (q15_t)0xfa50, (q15_t)0x40, (q15_t)0xfa5d, (q15_t)0x3f, (q15_t)0xfa69, + (q15_t)0x3d, (q15_t)0xfa76, (q15_t)0x3c, (q15_t)0xfa82, (q15_t)0x3b, + (q15_t)0xfa8f, (q15_t)0x3a, (q15_t)0xfa9b, (q15_t)0x39, (q15_t)0xfaa8, + (q15_t)0x38, (q15_t)0xfab4, (q15_t)0x37, (q15_t)0xfac1, (q15_t)0x36, + (q15_t)0xfacd, (q15_t)0x35, (q15_t)0xfada, (q15_t)0x34, (q15_t)0xfae6, + (q15_t)0x33, (q15_t)0xfaf3, (q15_t)0x32, (q15_t)0xfb00, (q15_t)0x31, + (q15_t)0xfb0c, (q15_t)0x30, (q15_t)0xfb19, (q15_t)0x2f, (q15_t)0xfb25, + (q15_t)0x2e, (q15_t)0xfb32, (q15_t)0x2d, (q15_t)0xfb3e, (q15_t)0x2c, + (q15_t)0xfb4b, (q15_t)0x2b, (q15_t)0xfb57, (q15_t)0x2b, (q15_t)0xfb64, + (q15_t)0x2a, (q15_t)0xfb70, (q15_t)0x29, (q15_t)0xfb7d, (q15_t)0x28, + (q15_t)0xfb89, (q15_t)0x27, (q15_t)0xfb96, (q15_t)0x26, (q15_t)0xfba2, + (q15_t)0x25, (q15_t)0xfbaf, (q15_t)0x24, (q15_t)0xfbbc, (q15_t)0x24, + (q15_t)0xfbc8, (q15_t)0x23, (q15_t)0xfbd5, (q15_t)0x22, (q15_t)0xfbe1, + (q15_t)0x21, (q15_t)0xfbee, (q15_t)0x20, (q15_t)0xfbfa, (q15_t)0x20, + (q15_t)0xfc07, (q15_t)0x1f, (q15_t)0xfc13, (q15_t)0x1e, (q15_t)0xfc20, + (q15_t)0x1d, (q15_t)0xfc2c, (q15_t)0x1d, (q15_t)0xfc39, (q15_t)0x1c, + (q15_t)0xfc45, (q15_t)0x1b, (q15_t)0xfc52, (q15_t)0x1a, (q15_t)0xfc5f, + (q15_t)0x1a, (q15_t)0xfc6b, (q15_t)0x19, (q15_t)0xfc78, (q15_t)0x18, + (q15_t)0xfc84, (q15_t)0x18, (q15_t)0xfc91, (q15_t)0x17, (q15_t)0xfc9d, + (q15_t)0x16, (q15_t)0xfcaa, (q15_t)0x16, (q15_t)0xfcb6, (q15_t)0x15, + (q15_t)0xfcc3, (q15_t)0x14, (q15_t)0xfcd0, (q15_t)0x14, (q15_t)0xfcdc, + (q15_t)0x13, (q15_t)0xfce9, (q15_t)0x13, (q15_t)0xfcf5, (q15_t)0x12, + (q15_t)0xfd02, (q15_t)0x11, (q15_t)0xfd0e, (q15_t)0x11, (q15_t)0xfd1b, + (q15_t)0x10, (q15_t)0xfd27, (q15_t)0x10, (q15_t)0xfd34, (q15_t)0xf, + (q15_t)0xfd40, (q15_t)0xf, (q15_t)0xfd4d, (q15_t)0xe, (q15_t)0xfd5a, + (q15_t)0xe, (q15_t)0xfd66, (q15_t)0xd, (q15_t)0xfd73, (q15_t)0xd, + (q15_t)0xfd7f, (q15_t)0xc, (q15_t)0xfd8c, (q15_t)0xc, (q15_t)0xfd98, + (q15_t)0xb, (q15_t)0xfda5, (q15_t)0xb, (q15_t)0xfdb2, (q15_t)0xa, + (q15_t)0xfdbe, (q15_t)0xa, (q15_t)0xfdcb, (q15_t)0x9, (q15_t)0xfdd7, + (q15_t)0x9, (q15_t)0xfde4, (q15_t)0x9, (q15_t)0xfdf0, (q15_t)0x8, + (q15_t)0xfdfd, (q15_t)0x8, (q15_t)0xfe09, (q15_t)0x7, (q15_t)0xfe16, + (q15_t)0x7, (q15_t)0xfe23, (q15_t)0x7, (q15_t)0xfe2f, (q15_t)0x6, + (q15_t)0xfe3c, (q15_t)0x6, (q15_t)0xfe48, (q15_t)0x6, (q15_t)0xfe55, + (q15_t)0x5, (q15_t)0xfe61, (q15_t)0x5, (q15_t)0xfe6e, (q15_t)0x5, + (q15_t)0xfe7a, (q15_t)0x4, (q15_t)0xfe87, (q15_t)0x4, (q15_t)0xfe94, + (q15_t)0x4, (q15_t)0xfea0, (q15_t)0x4, (q15_t)0xfead, (q15_t)0x3, + (q15_t)0xfeb9, (q15_t)0x3, (q15_t)0xfec6, (q15_t)0x3, (q15_t)0xfed2, + (q15_t)0x3, (q15_t)0xfedf, (q15_t)0x2, (q15_t)0xfeec, (q15_t)0x2, + (q15_t)0xfef8, (q15_t)0x2, (q15_t)0xff05, (q15_t)0x2, (q15_t)0xff11, + (q15_t)0x2, (q15_t)0xff1e, (q15_t)0x1, (q15_t)0xff2a, (q15_t)0x1, + (q15_t)0xff37, (q15_t)0x1, (q15_t)0xff44, (q15_t)0x1, (q15_t)0xff50, + (q15_t)0x1, (q15_t)0xff5d, (q15_t)0x1, (q15_t)0xff69, (q15_t)0x1, + (q15_t)0xff76, (q15_t)0x0, (q15_t)0xff82, (q15_t)0x0, (q15_t)0xff8f, + (q15_t)0x0, (q15_t)0xff9b, (q15_t)0x0, (q15_t)0xffa8, (q15_t)0x0, + (q15_t)0xffb5, (q15_t)0x0, (q15_t)0xffc1, (q15_t)0x0, (q15_t)0xffce, + (q15_t)0x0, (q15_t)0xffda, (q15_t)0x0, (q15_t)0xffe7, (q15_t)0x0, + (q15_t)0xfff3, (q15_t)0x0, (q15_t)0x0, (q15_t)0x0, (q15_t)0xd, + (q15_t)0x0, (q15_t)0x19, (q15_t)0x0, (q15_t)0x26, (q15_t)0x0, + (q15_t)0x32, (q15_t)0x0, (q15_t)0x3f, (q15_t)0x0, (q15_t)0x4b, + (q15_t)0x0, (q15_t)0x58, (q15_t)0x0, (q15_t)0x65, (q15_t)0x0, + (q15_t)0x71, (q15_t)0x0, (q15_t)0x7e, (q15_t)0x1, (q15_t)0x8a, + (q15_t)0x1, (q15_t)0x97, (q15_t)0x1, (q15_t)0xa3, (q15_t)0x1, + (q15_t)0xb0, (q15_t)0x1, (q15_t)0xbc, (q15_t)0x1, (q15_t)0xc9, + (q15_t)0x1, (q15_t)0xd6, (q15_t)0x2, (q15_t)0xe2, (q15_t)0x2, + (q15_t)0xef, (q15_t)0x2, (q15_t)0xfb, (q15_t)0x2, (q15_t)0x108, + (q15_t)0x2, (q15_t)0x114, (q15_t)0x3, (q15_t)0x121, (q15_t)0x3, + (q15_t)0x12e, (q15_t)0x3, (q15_t)0x13a, (q15_t)0x3, (q15_t)0x147, + (q15_t)0x4, (q15_t)0x153, (q15_t)0x4, (q15_t)0x160, (q15_t)0x4, + (q15_t)0x16c, (q15_t)0x4, (q15_t)0x179, (q15_t)0x5, (q15_t)0x186, + (q15_t)0x5, (q15_t)0x192, (q15_t)0x5, (q15_t)0x19f, (q15_t)0x6, + (q15_t)0x1ab, (q15_t)0x6, (q15_t)0x1b8, (q15_t)0x6, (q15_t)0x1c4, + (q15_t)0x7, (q15_t)0x1d1, (q15_t)0x7, (q15_t)0x1dd, (q15_t)0x7, + (q15_t)0x1ea, (q15_t)0x8, (q15_t)0x1f7, (q15_t)0x8, (q15_t)0x203, + (q15_t)0x9, (q15_t)0x210, (q15_t)0x9, (q15_t)0x21c, (q15_t)0x9, + (q15_t)0x229, (q15_t)0xa, (q15_t)0x235, (q15_t)0xa, (q15_t)0x242, + (q15_t)0xb, (q15_t)0x24e, (q15_t)0xb, (q15_t)0x25b, (q15_t)0xc, + (q15_t)0x268, (q15_t)0xc, (q15_t)0x274, (q15_t)0xd, (q15_t)0x281, + (q15_t)0xd, (q15_t)0x28d, (q15_t)0xe, (q15_t)0x29a, (q15_t)0xe, + (q15_t)0x2a6, (q15_t)0xf, (q15_t)0x2b3, (q15_t)0xf, (q15_t)0x2c0, + (q15_t)0x10, (q15_t)0x2cc, (q15_t)0x10, (q15_t)0x2d9, (q15_t)0x11, + (q15_t)0x2e5, (q15_t)0x11, (q15_t)0x2f2, (q15_t)0x12, (q15_t)0x2fe, + (q15_t)0x13, (q15_t)0x30b, (q15_t)0x13, (q15_t)0x317, (q15_t)0x14, + (q15_t)0x324, (q15_t)0x14, (q15_t)0x330, (q15_t)0x15, (q15_t)0x33d, + (q15_t)0x16, (q15_t)0x34a, (q15_t)0x16, (q15_t)0x356, (q15_t)0x17, + (q15_t)0x363, (q15_t)0x18, (q15_t)0x36f, (q15_t)0x18, (q15_t)0x37c, + (q15_t)0x19, (q15_t)0x388, (q15_t)0x1a, (q15_t)0x395, (q15_t)0x1a, + (q15_t)0x3a1, (q15_t)0x1b, (q15_t)0x3ae, (q15_t)0x1c, (q15_t)0x3bb, + (q15_t)0x1d, (q15_t)0x3c7, (q15_t)0x1d, (q15_t)0x3d4, (q15_t)0x1e, + (q15_t)0x3e0, (q15_t)0x1f, (q15_t)0x3ed, (q15_t)0x20, (q15_t)0x3f9, + (q15_t)0x20, (q15_t)0x406, (q15_t)0x21, (q15_t)0x412, (q15_t)0x22, + (q15_t)0x41f, (q15_t)0x23, (q15_t)0x42b, (q15_t)0x24, (q15_t)0x438, + (q15_t)0x24, (q15_t)0x444, (q15_t)0x25, (q15_t)0x451, (q15_t)0x26, + (q15_t)0x45e, (q15_t)0x27, (q15_t)0x46a, (q15_t)0x28, (q15_t)0x477, + (q15_t)0x29, (q15_t)0x483, (q15_t)0x2a, (q15_t)0x490, (q15_t)0x2b, + (q15_t)0x49c, (q15_t)0x2b, (q15_t)0x4a9, (q15_t)0x2c, (q15_t)0x4b5, + (q15_t)0x2d, (q15_t)0x4c2, (q15_t)0x2e, (q15_t)0x4ce, (q15_t)0x2f, + (q15_t)0x4db, (q15_t)0x30, (q15_t)0x4e7, (q15_t)0x31, (q15_t)0x4f4, + (q15_t)0x32, (q15_t)0x500, (q15_t)0x33, (q15_t)0x50d, (q15_t)0x34, + (q15_t)0x51a, (q15_t)0x35, (q15_t)0x526, (q15_t)0x36, (q15_t)0x533, + (q15_t)0x37, (q15_t)0x53f, (q15_t)0x38, (q15_t)0x54c, (q15_t)0x39, + (q15_t)0x558, (q15_t)0x3a, (q15_t)0x565, (q15_t)0x3b, (q15_t)0x571, + (q15_t)0x3c, (q15_t)0x57e, (q15_t)0x3d, (q15_t)0x58a, (q15_t)0x3f, + (q15_t)0x597, (q15_t)0x40, (q15_t)0x5a3, (q15_t)0x41, (q15_t)0x5b0, + (q15_t)0x42, (q15_t)0x5bc, (q15_t)0x43, (q15_t)0x5c9, (q15_t)0x44, + (q15_t)0x5d5, (q15_t)0x45, (q15_t)0x5e2, (q15_t)0x47, (q15_t)0x5ee, + (q15_t)0x48, (q15_t)0x5fb, (q15_t)0x49, (q15_t)0x607, (q15_t)0x4a, + (q15_t)0x614, (q15_t)0x4b, (q15_t)0x620, (q15_t)0x4c, (q15_t)0x62d, + (q15_t)0x4e, (q15_t)0x639, (q15_t)0x4f, (q15_t)0x646, (q15_t)0x50, + (q15_t)0x652, (q15_t)0x51, (q15_t)0x65f, (q15_t)0x53, (q15_t)0x66b, + (q15_t)0x54, (q15_t)0x678, (q15_t)0x55, (q15_t)0x684, (q15_t)0x56, + (q15_t)0x691, (q15_t)0x58, (q15_t)0x69d, (q15_t)0x59, (q15_t)0x6aa, + (q15_t)0x5a, (q15_t)0x6b6, (q15_t)0x5c, (q15_t)0x6c3, (q15_t)0x5d, + (q15_t)0x6cf, (q15_t)0x5e, (q15_t)0x6dc, (q15_t)0x60, (q15_t)0x6e8, + (q15_t)0x61, (q15_t)0x6f5, (q15_t)0x62, (q15_t)0x701, (q15_t)0x64, + (q15_t)0x70e, (q15_t)0x65, (q15_t)0x71a, (q15_t)0x67, (q15_t)0x727, + (q15_t)0x68, (q15_t)0x733, (q15_t)0x69, (q15_t)0x740, (q15_t)0x6b, + (q15_t)0x74c, (q15_t)0x6c, (q15_t)0x759, (q15_t)0x6e, (q15_t)0x765, + (q15_t)0x6f, (q15_t)0x772, (q15_t)0x71, (q15_t)0x77e, (q15_t)0x72, + (q15_t)0x78b, (q15_t)0x74, (q15_t)0x797, (q15_t)0x75, (q15_t)0x7a4, + (q15_t)0x77, (q15_t)0x7b0, (q15_t)0x78, (q15_t)0x7bd, (q15_t)0x7a, + (q15_t)0x7c9, (q15_t)0x7b, (q15_t)0x7d6, (q15_t)0x7d, (q15_t)0x7e2, + (q15_t)0x7e, (q15_t)0x7ef, (q15_t)0x80, (q15_t)0x7fb, (q15_t)0x81, + (q15_t)0x807, (q15_t)0x83, (q15_t)0x814, (q15_t)0x85, (q15_t)0x820, + (q15_t)0x86, (q15_t)0x82d, (q15_t)0x88, (q15_t)0x839, (q15_t)0x89, + (q15_t)0x846, (q15_t)0x8b, (q15_t)0x852, (q15_t)0x8d, (q15_t)0x85f, + (q15_t)0x8e, (q15_t)0x86b, (q15_t)0x90, (q15_t)0x878, (q15_t)0x92, + (q15_t)0x884, (q15_t)0x93, (q15_t)0x891, (q15_t)0x95, (q15_t)0x89d, + (q15_t)0x97, (q15_t)0x8a9, (q15_t)0x98, (q15_t)0x8b6, (q15_t)0x9a, + (q15_t)0x8c2, (q15_t)0x9c, (q15_t)0x8cf, (q15_t)0x9e, (q15_t)0x8db, + (q15_t)0x9f, (q15_t)0x8e8, (q15_t)0xa1, (q15_t)0x8f4, (q15_t)0xa3, + (q15_t)0x901, (q15_t)0xa5, (q15_t)0x90d, (q15_t)0xa6, (q15_t)0x919, + (q15_t)0xa8, (q15_t)0x926, (q15_t)0xaa, (q15_t)0x932, (q15_t)0xac, + (q15_t)0x93f, (q15_t)0xae, (q15_t)0x94b, (q15_t)0xaf, (q15_t)0x958, + (q15_t)0xb1, (q15_t)0x964, (q15_t)0xb3, (q15_t)0x970, (q15_t)0xb5, + (q15_t)0x97d, (q15_t)0xb7, (q15_t)0x989, (q15_t)0xb9, (q15_t)0x996, + (q15_t)0xbb, (q15_t)0x9a2, (q15_t)0xbd, (q15_t)0x9af, (q15_t)0xbe, + (q15_t)0x9bb, (q15_t)0xc0, (q15_t)0x9c7, (q15_t)0xc2, (q15_t)0x9d4, + (q15_t)0xc4, (q15_t)0x9e0, (q15_t)0xc6, (q15_t)0x9ed, (q15_t)0xc8, + (q15_t)0x9f9, (q15_t)0xca, (q15_t)0xa06, (q15_t)0xcc, (q15_t)0xa12, + (q15_t)0xce, (q15_t)0xa1e, (q15_t)0xd0, (q15_t)0xa2b, (q15_t)0xd2, + (q15_t)0xa37, (q15_t)0xd4, (q15_t)0xa44, (q15_t)0xd6, (q15_t)0xa50, + (q15_t)0xd8, (q15_t)0xa5c, (q15_t)0xda, (q15_t)0xa69, (q15_t)0xdc, + (q15_t)0xa75, (q15_t)0xde, (q15_t)0xa82, (q15_t)0xe0, (q15_t)0xa8e, + (q15_t)0xe2, (q15_t)0xa9a, (q15_t)0xe4, (q15_t)0xaa7, (q15_t)0xe7, + (q15_t)0xab3, (q15_t)0xe9, (q15_t)0xac0, (q15_t)0xeb, (q15_t)0xacc, + (q15_t)0xed, (q15_t)0xad8, (q15_t)0xef, (q15_t)0xae5, (q15_t)0xf1, + (q15_t)0xaf1, (q15_t)0xf3, (q15_t)0xafd, (q15_t)0xf6, (q15_t)0xb0a, + (q15_t)0xf8, (q15_t)0xb16, (q15_t)0xfa, (q15_t)0xb23, (q15_t)0xfc, + (q15_t)0xb2f, (q15_t)0xfe, (q15_t)0xb3b, (q15_t)0x100, (q15_t)0xb48, + (q15_t)0x103, (q15_t)0xb54, (q15_t)0x105, (q15_t)0xb60, (q15_t)0x107, + (q15_t)0xb6d, (q15_t)0x109, (q15_t)0xb79, (q15_t)0x10c, (q15_t)0xb85, + (q15_t)0x10e, (q15_t)0xb92, (q15_t)0x110, (q15_t)0xb9e, (q15_t)0x113, + (q15_t)0xbab, (q15_t)0x115, (q15_t)0xbb7, (q15_t)0x117, (q15_t)0xbc3, + (q15_t)0x119, (q15_t)0xbd0, (q15_t)0x11c, (q15_t)0xbdc, (q15_t)0x11e, + (q15_t)0xbe8, (q15_t)0x120, (q15_t)0xbf5, (q15_t)0x123, (q15_t)0xc01, + (q15_t)0x125, (q15_t)0xc0d, (q15_t)0x128, (q15_t)0xc1a, (q15_t)0x12a, + (q15_t)0xc26, (q15_t)0x12c, (q15_t)0xc32, (q15_t)0x12f, (q15_t)0xc3f, + (q15_t)0x131, (q15_t)0xc4b, (q15_t)0x134, (q15_t)0xc57, (q15_t)0x136, + (q15_t)0xc64, (q15_t)0x138, (q15_t)0xc70, (q15_t)0x13b, (q15_t)0xc7c, + (q15_t)0x13d, (q15_t)0xc89, (q15_t)0x140, (q15_t)0xc95, (q15_t)0x142, + (q15_t)0xca1, (q15_t)0x145, (q15_t)0xcae, (q15_t)0x147, (q15_t)0xcba, + (q15_t)0x14a, (q15_t)0xcc6, (q15_t)0x14c, (q15_t)0xcd3, (q15_t)0x14f, + (q15_t)0xcdf, (q15_t)0x151, (q15_t)0xceb, (q15_t)0x154, (q15_t)0xcf8, + (q15_t)0x156, (q15_t)0xd04, (q15_t)0x159, (q15_t)0xd10, (q15_t)0x15b, + (q15_t)0xd1c, (q15_t)0x15e, (q15_t)0xd29, (q15_t)0x161, (q15_t)0xd35, + (q15_t)0x163, (q15_t)0xd41, (q15_t)0x166, (q15_t)0xd4e, (q15_t)0x168, + (q15_t)0xd5a, (q15_t)0x16b, (q15_t)0xd66, (q15_t)0x16e, (q15_t)0xd72, + (q15_t)0x170, (q15_t)0xd7f, (q15_t)0x173, (q15_t)0xd8b, (q15_t)0x176, + (q15_t)0xd97, (q15_t)0x178, (q15_t)0xda4, (q15_t)0x17b, (q15_t)0xdb0, + (q15_t)0x17e, (q15_t)0xdbc, (q15_t)0x180, (q15_t)0xdc8, (q15_t)0x183, + (q15_t)0xdd5, (q15_t)0x186, (q15_t)0xde1, (q15_t)0x189, (q15_t)0xded, + (q15_t)0x18b, (q15_t)0xdf9, (q15_t)0x18e, (q15_t)0xe06, (q15_t)0x191, + (q15_t)0xe12, (q15_t)0x194, (q15_t)0xe1e, (q15_t)0x196, (q15_t)0xe2b, + (q15_t)0x199, (q15_t)0xe37, (q15_t)0x19c, (q15_t)0xe43, (q15_t)0x19f, + (q15_t)0xe4f, (q15_t)0x1a2, (q15_t)0xe5c, (q15_t)0x1a4, (q15_t)0xe68, + (q15_t)0x1a7, (q15_t)0xe74, (q15_t)0x1aa, (q15_t)0xe80, (q15_t)0x1ad, + (q15_t)0xe8c, (q15_t)0x1b0, (q15_t)0xe99, (q15_t)0x1b3, (q15_t)0xea5, + (q15_t)0x1b6, (q15_t)0xeb1, (q15_t)0x1b8, (q15_t)0xebd, (q15_t)0x1bb, + (q15_t)0xeca, (q15_t)0x1be, (q15_t)0xed6, (q15_t)0x1c1, (q15_t)0xee2, + (q15_t)0x1c4, (q15_t)0xeee, (q15_t)0x1c7, (q15_t)0xefb, (q15_t)0x1ca, + (q15_t)0xf07, (q15_t)0x1cd, (q15_t)0xf13, (q15_t)0x1d0, (q15_t)0xf1f, + (q15_t)0x1d3, (q15_t)0xf2b, (q15_t)0x1d6, (q15_t)0xf38, (q15_t)0x1d9, + (q15_t)0xf44, (q15_t)0x1dc, (q15_t)0xf50, (q15_t)0x1df, (q15_t)0xf5c, + (q15_t)0x1e2, (q15_t)0xf68, (q15_t)0x1e5, (q15_t)0xf75, (q15_t)0x1e8, + (q15_t)0xf81, (q15_t)0x1eb, (q15_t)0xf8d, (q15_t)0x1ee, (q15_t)0xf99, + (q15_t)0x1f1, (q15_t)0xfa5, (q15_t)0x1f4, (q15_t)0xfb2, (q15_t)0x1f7, + (q15_t)0xfbe, (q15_t)0x1fa, (q15_t)0xfca, (q15_t)0x1fd, (q15_t)0xfd6, + (q15_t)0x201, (q15_t)0xfe2, (q15_t)0x204, (q15_t)0xfee, (q15_t)0x207, + (q15_t)0xffb, (q15_t)0x20a, (q15_t)0x1007, (q15_t)0x20d, (q15_t)0x1013, + (q15_t)0x210, (q15_t)0x101f, (q15_t)0x213, (q15_t)0x102b, (q15_t)0x217, + (q15_t)0x1037, (q15_t)0x21a, (q15_t)0x1044, (q15_t)0x21d, (q15_t)0x1050, + (q15_t)0x220, (q15_t)0x105c, (q15_t)0x223, (q15_t)0x1068, (q15_t)0x227, + (q15_t)0x1074, (q15_t)0x22a, (q15_t)0x1080, (q15_t)0x22d, (q15_t)0x108c, + (q15_t)0x230, (q15_t)0x1099, (q15_t)0x234, (q15_t)0x10a5, (q15_t)0x237, + (q15_t)0x10b1, (q15_t)0x23a, (q15_t)0x10bd, (q15_t)0x23e, (q15_t)0x10c9, + (q15_t)0x241, (q15_t)0x10d5, (q15_t)0x244, (q15_t)0x10e1, (q15_t)0x247, + (q15_t)0x10ed, (q15_t)0x24b, (q15_t)0x10fa, (q15_t)0x24e, (q15_t)0x1106, + (q15_t)0x251, (q15_t)0x1112, (q15_t)0x255, (q15_t)0x111e, (q15_t)0x258, + (q15_t)0x112a, (q15_t)0x25c, (q15_t)0x1136, (q15_t)0x25f, (q15_t)0x1142, + (q15_t)0x262, (q15_t)0x114e, (q15_t)0x266, (q15_t)0x115a, (q15_t)0x269, + (q15_t)0x1167, (q15_t)0x26d, (q15_t)0x1173, (q15_t)0x270, (q15_t)0x117f, + (q15_t)0x273, (q15_t)0x118b, (q15_t)0x277, (q15_t)0x1197, (q15_t)0x27a, + (q15_t)0x11a3, (q15_t)0x27e, (q15_t)0x11af, (q15_t)0x281, (q15_t)0x11bb, + (q15_t)0x285, (q15_t)0x11c7, (q15_t)0x288, (q15_t)0x11d3, (q15_t)0x28c, + (q15_t)0x11df, (q15_t)0x28f, (q15_t)0x11eb, (q15_t)0x293, (q15_t)0x11f7, + (q15_t)0x296, (q15_t)0x1204, (q15_t)0x29a, (q15_t)0x1210, (q15_t)0x29d, + (q15_t)0x121c, (q15_t)0x2a1, (q15_t)0x1228, (q15_t)0x2a5, (q15_t)0x1234, + (q15_t)0x2a8, (q15_t)0x1240, (q15_t)0x2ac, (q15_t)0x124c, (q15_t)0x2af, + (q15_t)0x1258, (q15_t)0x2b3, (q15_t)0x1264, (q15_t)0x2b7, (q15_t)0x1270, + (q15_t)0x2ba, (q15_t)0x127c, (q15_t)0x2be, (q15_t)0x1288, (q15_t)0x2c1, + (q15_t)0x1294, (q15_t)0x2c5, (q15_t)0x12a0, (q15_t)0x2c9, (q15_t)0x12ac, + (q15_t)0x2cc, (q15_t)0x12b8, (q15_t)0x2d0, (q15_t)0x12c4, (q15_t)0x2d4, + (q15_t)0x12d0, (q15_t)0x2d8, (q15_t)0x12dc, (q15_t)0x2db, (q15_t)0x12e8, + (q15_t)0x2df, (q15_t)0x12f4, (q15_t)0x2e3, (q15_t)0x1300, (q15_t)0x2e6, + (q15_t)0x130c, (q15_t)0x2ea, (q15_t)0x1318, (q15_t)0x2ee, (q15_t)0x1324, + (q15_t)0x2f2, (q15_t)0x1330, (q15_t)0x2f5, (q15_t)0x133c, (q15_t)0x2f9, + (q15_t)0x1348, (q15_t)0x2fd, (q15_t)0x1354, (q15_t)0x301, (q15_t)0x1360, + (q15_t)0x305, (q15_t)0x136c, (q15_t)0x308, (q15_t)0x1378, (q15_t)0x30c, + (q15_t)0x1384, (q15_t)0x310, (q15_t)0x1390, (q15_t)0x314, (q15_t)0x139c, + (q15_t)0x318, (q15_t)0x13a8, (q15_t)0x31c, (q15_t)0x13b4, (q15_t)0x320, + (q15_t)0x13c0, (q15_t)0x323, (q15_t)0x13cc, (q15_t)0x327, (q15_t)0x13d8, + (q15_t)0x32b, (q15_t)0x13e4, (q15_t)0x32f, (q15_t)0x13f0, (q15_t)0x333, + (q15_t)0x13fb, (q15_t)0x337, (q15_t)0x1407, (q15_t)0x33b, (q15_t)0x1413, + (q15_t)0x33f, (q15_t)0x141f, (q15_t)0x343, (q15_t)0x142b, (q15_t)0x347, + (q15_t)0x1437, (q15_t)0x34b, (q15_t)0x1443, (q15_t)0x34f, (q15_t)0x144f, + (q15_t)0x353, (q15_t)0x145b, (q15_t)0x357, (q15_t)0x1467, (q15_t)0x35b, + (q15_t)0x1473, (q15_t)0x35f, (q15_t)0x147f, (q15_t)0x363, (q15_t)0x148b, + (q15_t)0x367, (q15_t)0x1496, (q15_t)0x36b, (q15_t)0x14a2, (q15_t)0x36f, + (q15_t)0x14ae, (q15_t)0x373, (q15_t)0x14ba, (q15_t)0x377, (q15_t)0x14c6, + (q15_t)0x37b, (q15_t)0x14d2, (q15_t)0x37f, (q15_t)0x14de, (q15_t)0x383, + (q15_t)0x14ea, (q15_t)0x387, (q15_t)0x14f6, (q15_t)0x38c, (q15_t)0x1501, + (q15_t)0x390, (q15_t)0x150d, (q15_t)0x394, (q15_t)0x1519, (q15_t)0x398, + (q15_t)0x1525, (q15_t)0x39c, (q15_t)0x1531, (q15_t)0x3a0, (q15_t)0x153d, + (q15_t)0x3a5, (q15_t)0x1549, (q15_t)0x3a9, (q15_t)0x1554, (q15_t)0x3ad, + (q15_t)0x1560, (q15_t)0x3b1, (q15_t)0x156c, (q15_t)0x3b5, (q15_t)0x1578, + (q15_t)0x3ba, (q15_t)0x1584, (q15_t)0x3be, (q15_t)0x1590, (q15_t)0x3c2, + (q15_t)0x159b, (q15_t)0x3c6, (q15_t)0x15a7, (q15_t)0x3ca, (q15_t)0x15b3, + (q15_t)0x3cf, (q15_t)0x15bf, (q15_t)0x3d3, (q15_t)0x15cb, (q15_t)0x3d7, + (q15_t)0x15d7, (q15_t)0x3dc, (q15_t)0x15e2, (q15_t)0x3e0, (q15_t)0x15ee, + (q15_t)0x3e4, (q15_t)0x15fa, (q15_t)0x3e9, (q15_t)0x1606, (q15_t)0x3ed, + (q15_t)0x1612, (q15_t)0x3f1, (q15_t)0x161d, (q15_t)0x3f6, (q15_t)0x1629, + (q15_t)0x3fa, (q15_t)0x1635, (q15_t)0x3fe, (q15_t)0x1641, (q15_t)0x403, + (q15_t)0x164c, (q15_t)0x407, (q15_t)0x1658, (q15_t)0x40b, (q15_t)0x1664, + (q15_t)0x410, (q15_t)0x1670, (q15_t)0x414, (q15_t)0x167c, (q15_t)0x419, + (q15_t)0x1687, (q15_t)0x41d, (q15_t)0x1693, (q15_t)0x422, (q15_t)0x169f, + (q15_t)0x426, (q15_t)0x16ab, (q15_t)0x42a, (q15_t)0x16b6, (q15_t)0x42f, + (q15_t)0x16c2, (q15_t)0x433, (q15_t)0x16ce, (q15_t)0x438, (q15_t)0x16da, + (q15_t)0x43c, (q15_t)0x16e5, (q15_t)0x441, (q15_t)0x16f1, (q15_t)0x445, + (q15_t)0x16fd, (q15_t)0x44a, (q15_t)0x1709, (q15_t)0x44e, (q15_t)0x1714, + (q15_t)0x453, (q15_t)0x1720, (q15_t)0x457, (q15_t)0x172c, (q15_t)0x45c, + (q15_t)0x1737, (q15_t)0x461, (q15_t)0x1743, (q15_t)0x465, (q15_t)0x174f, + (q15_t)0x46a, (q15_t)0x175b, (q15_t)0x46e, (q15_t)0x1766, (q15_t)0x473, + (q15_t)0x1772, (q15_t)0x478, (q15_t)0x177e, (q15_t)0x47c, (q15_t)0x1789, + (q15_t)0x481, (q15_t)0x1795, (q15_t)0x485, (q15_t)0x17a1, (q15_t)0x48a, + (q15_t)0x17ac, (q15_t)0x48f, (q15_t)0x17b8, (q15_t)0x493, (q15_t)0x17c4, + (q15_t)0x498, (q15_t)0x17cf, (q15_t)0x49d, (q15_t)0x17db, (q15_t)0x4a1, + (q15_t)0x17e7, (q15_t)0x4a6, (q15_t)0x17f2, (q15_t)0x4ab, (q15_t)0x17fe, + (q15_t)0x4b0, (q15_t)0x180a, (q15_t)0x4b4, (q15_t)0x1815, (q15_t)0x4b9, + (q15_t)0x1821, (q15_t)0x4be, (q15_t)0x182d, (q15_t)0x4c2, (q15_t)0x1838, + (q15_t)0x4c7, (q15_t)0x1844, (q15_t)0x4cc, (q15_t)0x184f, (q15_t)0x4d1, + (q15_t)0x185b, (q15_t)0x4d6, (q15_t)0x1867, (q15_t)0x4da, (q15_t)0x1872, + (q15_t)0x4df, (q15_t)0x187e, (q15_t)0x4e4, (q15_t)0x1889, (q15_t)0x4e9, + (q15_t)0x1895, (q15_t)0x4ee, (q15_t)0x18a1, (q15_t)0x4f2, (q15_t)0x18ac, + (q15_t)0x4f7, (q15_t)0x18b8, (q15_t)0x4fc, (q15_t)0x18c3, (q15_t)0x501, + (q15_t)0x18cf, (q15_t)0x506, (q15_t)0x18db, (q15_t)0x50b, (q15_t)0x18e6, + (q15_t)0x510, (q15_t)0x18f2, (q15_t)0x515, (q15_t)0x18fd, (q15_t)0x51a, + (q15_t)0x1909, (q15_t)0x51e, (q15_t)0x1914, (q15_t)0x523, (q15_t)0x1920, + (q15_t)0x528, (q15_t)0x192c, (q15_t)0x52d, (q15_t)0x1937, (q15_t)0x532, + (q15_t)0x1943, (q15_t)0x537, (q15_t)0x194e, (q15_t)0x53c, (q15_t)0x195a, + (q15_t)0x541, (q15_t)0x1965, (q15_t)0x546, (q15_t)0x1971, (q15_t)0x54b, + (q15_t)0x197c, (q15_t)0x550, (q15_t)0x1988, (q15_t)0x555, (q15_t)0x1993, + (q15_t)0x55a, (q15_t)0x199f, (q15_t)0x55f, (q15_t)0x19aa, (q15_t)0x564, + (q15_t)0x19b6, (q15_t)0x569, (q15_t)0x19c1, (q15_t)0x56e, (q15_t)0x19cd, + (q15_t)0x573, (q15_t)0x19d8, (q15_t)0x578, (q15_t)0x19e4, (q15_t)0x57e, + (q15_t)0x19ef, (q15_t)0x583, (q15_t)0x19fb, (q15_t)0x588, (q15_t)0x1a06, + (q15_t)0x58d, (q15_t)0x1a12, (q15_t)0x592, (q15_t)0x1a1d, (q15_t)0x597, + (q15_t)0x1a29, (q15_t)0x59c, (q15_t)0x1a34, (q15_t)0x5a1, (q15_t)0x1a40, + (q15_t)0x5a7, (q15_t)0x1a4b, (q15_t)0x5ac, (q15_t)0x1a57, (q15_t)0x5b1, + (q15_t)0x1a62, (q15_t)0x5b6, (q15_t)0x1a6e, (q15_t)0x5bb, (q15_t)0x1a79, + (q15_t)0x5c1, (q15_t)0x1a84, (q15_t)0x5c6, (q15_t)0x1a90, (q15_t)0x5cb, + (q15_t)0x1a9b, (q15_t)0x5d0, (q15_t)0x1aa7, (q15_t)0x5d5, (q15_t)0x1ab2, + (q15_t)0x5db, (q15_t)0x1abe, (q15_t)0x5e0, (q15_t)0x1ac9, (q15_t)0x5e5, + (q15_t)0x1ad4, (q15_t)0x5ea, (q15_t)0x1ae0, (q15_t)0x5f0, (q15_t)0x1aeb, + (q15_t)0x5f5, (q15_t)0x1af7, (q15_t)0x5fa, (q15_t)0x1b02, (q15_t)0x600, + (q15_t)0x1b0d, (q15_t)0x605, (q15_t)0x1b19, (q15_t)0x60a, (q15_t)0x1b24, + (q15_t)0x610, (q15_t)0x1b30, (q15_t)0x615, (q15_t)0x1b3b, (q15_t)0x61a, + (q15_t)0x1b46, (q15_t)0x620, (q15_t)0x1b52, (q15_t)0x625, (q15_t)0x1b5d, + (q15_t)0x62a, (q15_t)0x1b68, (q15_t)0x630, (q15_t)0x1b74, (q15_t)0x635, + (q15_t)0x1b7f, (q15_t)0x63b, (q15_t)0x1b8a, (q15_t)0x640, (q15_t)0x1b96, + (q15_t)0x645, (q15_t)0x1ba1, (q15_t)0x64b, (q15_t)0x1bac, (q15_t)0x650, + (q15_t)0x1bb8, (q15_t)0x656, (q15_t)0x1bc3, (q15_t)0x65b, (q15_t)0x1bce, + (q15_t)0x661, (q15_t)0x1bda, (q15_t)0x666, (q15_t)0x1be5, (q15_t)0x66c, + (q15_t)0x1bf0, (q15_t)0x671, (q15_t)0x1bfc, (q15_t)0x677, (q15_t)0x1c07, + (q15_t)0x67c, (q15_t)0x1c12, (q15_t)0x682, (q15_t)0x1c1e, (q15_t)0x687, + (q15_t)0x1c29, (q15_t)0x68d, (q15_t)0x1c34, (q15_t)0x692, (q15_t)0x1c3f, + (q15_t)0x698, (q15_t)0x1c4b, (q15_t)0x69d, (q15_t)0x1c56, (q15_t)0x6a3, + (q15_t)0x1c61, (q15_t)0x6a8, (q15_t)0x1c6c, (q15_t)0x6ae, (q15_t)0x1c78, + (q15_t)0x6b4, (q15_t)0x1c83, (q15_t)0x6b9, (q15_t)0x1c8e, (q15_t)0x6bf, + (q15_t)0x1c99, (q15_t)0x6c5, (q15_t)0x1ca5, (q15_t)0x6ca, (q15_t)0x1cb0, + (q15_t)0x6d0, (q15_t)0x1cbb, (q15_t)0x6d5, (q15_t)0x1cc6, (q15_t)0x6db, + (q15_t)0x1cd2, (q15_t)0x6e1, (q15_t)0x1cdd, (q15_t)0x6e6, (q15_t)0x1ce8, + (q15_t)0x6ec, (q15_t)0x1cf3, (q15_t)0x6f2, (q15_t)0x1cff, (q15_t)0x6f7, + (q15_t)0x1d0a, (q15_t)0x6fd, (q15_t)0x1d15, (q15_t)0x703, (q15_t)0x1d20, + (q15_t)0x709, (q15_t)0x1d2b, (q15_t)0x70e, (q15_t)0x1d36, (q15_t)0x714, + (q15_t)0x1d42, (q15_t)0x71a, (q15_t)0x1d4d, (q15_t)0x720, (q15_t)0x1d58, + (q15_t)0x725, (q15_t)0x1d63, (q15_t)0x72b, (q15_t)0x1d6e, (q15_t)0x731, + (q15_t)0x1d79, (q15_t)0x737, (q15_t)0x1d85, (q15_t)0x73d, (q15_t)0x1d90, + (q15_t)0x742, (q15_t)0x1d9b, (q15_t)0x748, (q15_t)0x1da6, (q15_t)0x74e, + (q15_t)0x1db1, (q15_t)0x754, (q15_t)0x1dbc, (q15_t)0x75a, (q15_t)0x1dc7, + (q15_t)0x75f, (q15_t)0x1dd3, (q15_t)0x765, (q15_t)0x1dde, (q15_t)0x76b, + (q15_t)0x1de9, (q15_t)0x771, (q15_t)0x1df4, (q15_t)0x777, (q15_t)0x1dff, + (q15_t)0x77d, (q15_t)0x1e0a, (q15_t)0x783, (q15_t)0x1e15, (q15_t)0x789, + (q15_t)0x1e20, (q15_t)0x78f, (q15_t)0x1e2b, (q15_t)0x795, (q15_t)0x1e36, + (q15_t)0x79a, (q15_t)0x1e42, (q15_t)0x7a0, (q15_t)0x1e4d, (q15_t)0x7a6, + (q15_t)0x1e58, (q15_t)0x7ac, (q15_t)0x1e63, (q15_t)0x7b2, (q15_t)0x1e6e, + (q15_t)0x7b8, (q15_t)0x1e79, (q15_t)0x7be, (q15_t)0x1e84, (q15_t)0x7c4, + (q15_t)0x1e8f, (q15_t)0x7ca, (q15_t)0x1e9a, (q15_t)0x7d0, (q15_t)0x1ea5, + (q15_t)0x7d6, (q15_t)0x1eb0, (q15_t)0x7dc, (q15_t)0x1ebb, (q15_t)0x7e2, + (q15_t)0x1ec6, (q15_t)0x7e8, (q15_t)0x1ed1, (q15_t)0x7ee, (q15_t)0x1edc, + (q15_t)0x7f5, (q15_t)0x1ee7, (q15_t)0x7fb, (q15_t)0x1ef2, (q15_t)0x801, + (q15_t)0x1efd, (q15_t)0x807, (q15_t)0x1f08, (q15_t)0x80d, (q15_t)0x1f13, + (q15_t)0x813, (q15_t)0x1f1e, (q15_t)0x819, (q15_t)0x1f29, (q15_t)0x81f, + (q15_t)0x1f34, (q15_t)0x825, (q15_t)0x1f3f, (q15_t)0x82b, (q15_t)0x1f4a, + (q15_t)0x832, (q15_t)0x1f55, (q15_t)0x838, (q15_t)0x1f60, (q15_t)0x83e, + (q15_t)0x1f6b, (q15_t)0x844, (q15_t)0x1f76, (q15_t)0x84a, (q15_t)0x1f81, + (q15_t)0x850, (q15_t)0x1f8c, (q15_t)0x857, (q15_t)0x1f97, (q15_t)0x85d, + (q15_t)0x1fa2, (q15_t)0x863, (q15_t)0x1fac, (q15_t)0x869, (q15_t)0x1fb7, + (q15_t)0x870, (q15_t)0x1fc2, (q15_t)0x876, (q15_t)0x1fcd, (q15_t)0x87c, + (q15_t)0x1fd8, (q15_t)0x882, (q15_t)0x1fe3, (q15_t)0x889, (q15_t)0x1fee, + (q15_t)0x88f, (q15_t)0x1ff9, (q15_t)0x895, (q15_t)0x2004, (q15_t)0x89b, + (q15_t)0x200f, (q15_t)0x8a2, (q15_t)0x2019, (q15_t)0x8a8, (q15_t)0x2024, + (q15_t)0x8ae, (q15_t)0x202f, (q15_t)0x8b5, (q15_t)0x203a, (q15_t)0x8bb, + (q15_t)0x2045, (q15_t)0x8c1, (q15_t)0x2050, (q15_t)0x8c8, (q15_t)0x205b, + (q15_t)0x8ce, (q15_t)0x2065, (q15_t)0x8d4, (q15_t)0x2070, (q15_t)0x8db, + (q15_t)0x207b, (q15_t)0x8e1, (q15_t)0x2086, (q15_t)0x8e8, (q15_t)0x2091, + (q15_t)0x8ee, (q15_t)0x209b, (q15_t)0x8f4, (q15_t)0x20a6, (q15_t)0x8fb, + (q15_t)0x20b1, (q15_t)0x901, (q15_t)0x20bc, (q15_t)0x908, (q15_t)0x20c7, + (q15_t)0x90e, (q15_t)0x20d1, (q15_t)0x915, (q15_t)0x20dc, (q15_t)0x91b, + (q15_t)0x20e7, (q15_t)0x921, (q15_t)0x20f2, (q15_t)0x928, (q15_t)0x20fd, + (q15_t)0x92e, (q15_t)0x2107, (q15_t)0x935, (q15_t)0x2112, (q15_t)0x93b, + (q15_t)0x211d, (q15_t)0x942, (q15_t)0x2128, (q15_t)0x948, (q15_t)0x2132, + (q15_t)0x94f, (q15_t)0x213d, (q15_t)0x955, (q15_t)0x2148, (q15_t)0x95c, + (q15_t)0x2153, (q15_t)0x963, (q15_t)0x215d, (q15_t)0x969, (q15_t)0x2168, + (q15_t)0x970, (q15_t)0x2173, (q15_t)0x976, (q15_t)0x217d, (q15_t)0x97d, + (q15_t)0x2188, (q15_t)0x983, (q15_t)0x2193, (q15_t)0x98a, (q15_t)0x219e, + (q15_t)0x991, (q15_t)0x21a8, (q15_t)0x997, (q15_t)0x21b3, (q15_t)0x99e, + (q15_t)0x21be, (q15_t)0x9a4, (q15_t)0x21c8, (q15_t)0x9ab, (q15_t)0x21d3, + (q15_t)0x9b2, (q15_t)0x21de, (q15_t)0x9b8, (q15_t)0x21e8, (q15_t)0x9bf, + (q15_t)0x21f3, (q15_t)0x9c6, (q15_t)0x21fe, (q15_t)0x9cc, (q15_t)0x2208, + (q15_t)0x9d3, (q15_t)0x2213, (q15_t)0x9da, (q15_t)0x221e, (q15_t)0x9e0, + (q15_t)0x2228, (q15_t)0x9e7, (q15_t)0x2233, (q15_t)0x9ee, (q15_t)0x223d, + (q15_t)0x9f5, (q15_t)0x2248, (q15_t)0x9fb, (q15_t)0x2253, (q15_t)0xa02, + (q15_t)0x225d, (q15_t)0xa09, (q15_t)0x2268, (q15_t)0xa10, (q15_t)0x2272, + (q15_t)0xa16, (q15_t)0x227d, (q15_t)0xa1d, (q15_t)0x2288, (q15_t)0xa24, + (q15_t)0x2292, (q15_t)0xa2b, (q15_t)0x229d, (q15_t)0xa32, (q15_t)0x22a7, + (q15_t)0xa38, (q15_t)0x22b2, (q15_t)0xa3f, (q15_t)0x22bc, (q15_t)0xa46, + (q15_t)0x22c7, (q15_t)0xa4d, (q15_t)0x22d2, (q15_t)0xa54, (q15_t)0x22dc, + (q15_t)0xa5b, (q15_t)0x22e7, (q15_t)0xa61, (q15_t)0x22f1, (q15_t)0xa68, + (q15_t)0x22fc, (q15_t)0xa6f, (q15_t)0x2306, (q15_t)0xa76, (q15_t)0x2311, + (q15_t)0xa7d, (q15_t)0x231b, (q15_t)0xa84, (q15_t)0x2326, (q15_t)0xa8b, + (q15_t)0x2330, (q15_t)0xa92, (q15_t)0x233b, (q15_t)0xa99, (q15_t)0x2345, + (q15_t)0xa9f, (q15_t)0x2350, (q15_t)0xaa6, (q15_t)0x235a, (q15_t)0xaad, + (q15_t)0x2365, (q15_t)0xab4, (q15_t)0x236f, (q15_t)0xabb, (q15_t)0x237a, + (q15_t)0xac2, (q15_t)0x2384, (q15_t)0xac9, (q15_t)0x238e, (q15_t)0xad0, + (q15_t)0x2399, (q15_t)0xad7, (q15_t)0x23a3, (q15_t)0xade, (q15_t)0x23ae, + (q15_t)0xae5, (q15_t)0x23b8, (q15_t)0xaec, (q15_t)0x23c3, (q15_t)0xaf3, + (q15_t)0x23cd, (q15_t)0xafa, (q15_t)0x23d7, (q15_t)0xb01, (q15_t)0x23e2, + (q15_t)0xb08, (q15_t)0x23ec, (q15_t)0xb0f, (q15_t)0x23f7, (q15_t)0xb16, + (q15_t)0x2401, (q15_t)0xb1e, (q15_t)0x240b, (q15_t)0xb25, (q15_t)0x2416, + (q15_t)0xb2c, (q15_t)0x2420, (q15_t)0xb33, (q15_t)0x242b, (q15_t)0xb3a, + (q15_t)0x2435, (q15_t)0xb41, (q15_t)0x243f, (q15_t)0xb48, (q15_t)0x244a, + (q15_t)0xb4f, (q15_t)0x2454, (q15_t)0xb56, (q15_t)0x245e, (q15_t)0xb5e, + (q15_t)0x2469, (q15_t)0xb65, (q15_t)0x2473, (q15_t)0xb6c, (q15_t)0x247d, + (q15_t)0xb73, (q15_t)0x2488, (q15_t)0xb7a, (q15_t)0x2492, (q15_t)0xb81, + (q15_t)0x249c, (q15_t)0xb89, (q15_t)0x24a7, (q15_t)0xb90, (q15_t)0x24b1, + (q15_t)0xb97, (q15_t)0x24bb, (q15_t)0xb9e, (q15_t)0x24c5, (q15_t)0xba5, + (q15_t)0x24d0, (q15_t)0xbad, (q15_t)0x24da, (q15_t)0xbb4, (q15_t)0x24e4, + (q15_t)0xbbb, (q15_t)0x24ef, (q15_t)0xbc2, (q15_t)0x24f9, (q15_t)0xbca, + (q15_t)0x2503, (q15_t)0xbd1, (q15_t)0x250d, (q15_t)0xbd8, (q15_t)0x2518, + (q15_t)0xbe0, (q15_t)0x2522, (q15_t)0xbe7, (q15_t)0x252c, (q15_t)0xbee, + (q15_t)0x2536, (q15_t)0xbf5, (q15_t)0x2541, (q15_t)0xbfd, (q15_t)0x254b, + (q15_t)0xc04, (q15_t)0x2555, (q15_t)0xc0b, (q15_t)0x255f, (q15_t)0xc13, + (q15_t)0x2569, (q15_t)0xc1a, (q15_t)0x2574, (q15_t)0xc21, (q15_t)0x257e, + (q15_t)0xc29, (q15_t)0x2588, (q15_t)0xc30, (q15_t)0x2592, (q15_t)0xc38, + (q15_t)0x259c, (q15_t)0xc3f, (q15_t)0x25a6, (q15_t)0xc46, (q15_t)0x25b1, + (q15_t)0xc4e, (q15_t)0x25bb, (q15_t)0xc55, (q15_t)0x25c5, (q15_t)0xc5d, + (q15_t)0x25cf, (q15_t)0xc64, (q15_t)0x25d9, (q15_t)0xc6b, (q15_t)0x25e3, + (q15_t)0xc73, (q15_t)0x25ed, (q15_t)0xc7a, (q15_t)0x25f8, (q15_t)0xc82, + (q15_t)0x2602, (q15_t)0xc89, (q15_t)0x260c, (q15_t)0xc91, (q15_t)0x2616, + (q15_t)0xc98, (q15_t)0x2620, (q15_t)0xca0, (q15_t)0x262a, (q15_t)0xca7, + (q15_t)0x2634, (q15_t)0xcaf, (q15_t)0x263e, (q15_t)0xcb6, (q15_t)0x2648, + (q15_t)0xcbe, (q15_t)0x2652, (q15_t)0xcc5, (q15_t)0x265c, (q15_t)0xccd, + (q15_t)0x2666, (q15_t)0xcd4, (q15_t)0x2671, (q15_t)0xcdc, (q15_t)0x267b, + (q15_t)0xce3, (q15_t)0x2685, (q15_t)0xceb, (q15_t)0x268f, (q15_t)0xcf3, + (q15_t)0x2699, (q15_t)0xcfa, (q15_t)0x26a3, (q15_t)0xd02, (q15_t)0x26ad, + (q15_t)0xd09, (q15_t)0x26b7, (q15_t)0xd11, (q15_t)0x26c1, (q15_t)0xd19, + (q15_t)0x26cb, (q15_t)0xd20, (q15_t)0x26d5, (q15_t)0xd28, (q15_t)0x26df, + (q15_t)0xd30, (q15_t)0x26e9, (q15_t)0xd37, (q15_t)0x26f3, (q15_t)0xd3f, + (q15_t)0x26fd, (q15_t)0xd46, (q15_t)0x2707, (q15_t)0xd4e, (q15_t)0x2711, + (q15_t)0xd56, (q15_t)0x271a, (q15_t)0xd5d, (q15_t)0x2724, (q15_t)0xd65, + (q15_t)0x272e, (q15_t)0xd6d, (q15_t)0x2738, (q15_t)0xd75, (q15_t)0x2742, + (q15_t)0xd7c, (q15_t)0x274c, (q15_t)0xd84, (q15_t)0x2756, (q15_t)0xd8c, + (q15_t)0x2760, (q15_t)0xd93, (q15_t)0x276a, (q15_t)0xd9b, (q15_t)0x2774, + (q15_t)0xda3, (q15_t)0x277e, (q15_t)0xdab, (q15_t)0x2788, (q15_t)0xdb2, + (q15_t)0x2791, (q15_t)0xdba, (q15_t)0x279b, (q15_t)0xdc2, (q15_t)0x27a5, + (q15_t)0xdca, (q15_t)0x27af, (q15_t)0xdd2, (q15_t)0x27b9, (q15_t)0xdd9, + (q15_t)0x27c3, (q15_t)0xde1, (q15_t)0x27cd, (q15_t)0xde9, (q15_t)0x27d6, + (q15_t)0xdf1, (q15_t)0x27e0, (q15_t)0xdf9, (q15_t)0x27ea, (q15_t)0xe01, + (q15_t)0x27f4, (q15_t)0xe08, (q15_t)0x27fe, (q15_t)0xe10, (q15_t)0x2808, + (q15_t)0xe18, (q15_t)0x2811, (q15_t)0xe20, (q15_t)0x281b, (q15_t)0xe28, + (q15_t)0x2825, (q15_t)0xe30, (q15_t)0x282f, (q15_t)0xe38, (q15_t)0x2838, + (q15_t)0xe40, (q15_t)0x2842, (q15_t)0xe47, (q15_t)0x284c, (q15_t)0xe4f, + (q15_t)0x2856, (q15_t)0xe57, (q15_t)0x2860, (q15_t)0xe5f, (q15_t)0x2869, + (q15_t)0xe67, (q15_t)0x2873, (q15_t)0xe6f, (q15_t)0x287d, (q15_t)0xe77, + (q15_t)0x2886, (q15_t)0xe7f, (q15_t)0x2890, (q15_t)0xe87, (q15_t)0x289a, + (q15_t)0xe8f, (q15_t)0x28a4, (q15_t)0xe97, (q15_t)0x28ad, (q15_t)0xe9f, + (q15_t)0x28b7, (q15_t)0xea7, (q15_t)0x28c1, (q15_t)0xeaf, (q15_t)0x28ca, + (q15_t)0xeb7, (q15_t)0x28d4, (q15_t)0xebf, (q15_t)0x28de, (q15_t)0xec7, + (q15_t)0x28e7, (q15_t)0xecf, (q15_t)0x28f1, (q15_t)0xed7, (q15_t)0x28fb, + (q15_t)0xedf, (q15_t)0x2904, (q15_t)0xee7, (q15_t)0x290e, (q15_t)0xeef, + (q15_t)0x2918, (q15_t)0xef7, (q15_t)0x2921, (q15_t)0xeff, (q15_t)0x292b, + (q15_t)0xf07, (q15_t)0x2935, (q15_t)0xf10, (q15_t)0x293e, (q15_t)0xf18, + (q15_t)0x2948, (q15_t)0xf20, (q15_t)0x2951, (q15_t)0xf28, (q15_t)0x295b, + (q15_t)0xf30, (q15_t)0x2965, (q15_t)0xf38, (q15_t)0x296e, (q15_t)0xf40, + (q15_t)0x2978, (q15_t)0xf48, (q15_t)0x2981, (q15_t)0xf51, (q15_t)0x298b, + (q15_t)0xf59, (q15_t)0x2994, (q15_t)0xf61, (q15_t)0x299e, (q15_t)0xf69, + (q15_t)0x29a7, (q15_t)0xf71, (q15_t)0x29b1, (q15_t)0xf79, (q15_t)0x29bb, + (q15_t)0xf82, (q15_t)0x29c4, (q15_t)0xf8a, (q15_t)0x29ce, (q15_t)0xf92, + (q15_t)0x29d7, (q15_t)0xf9a, (q15_t)0x29e1, (q15_t)0xfa3, (q15_t)0x29ea, + (q15_t)0xfab, (q15_t)0x29f4, (q15_t)0xfb3, (q15_t)0x29fd, (q15_t)0xfbb, + (q15_t)0x2a07, (q15_t)0xfc4, (q15_t)0x2a10, (q15_t)0xfcc, (q15_t)0x2a1a, + (q15_t)0xfd4, (q15_t)0x2a23, (q15_t)0xfdc, (q15_t)0x2a2c, (q15_t)0xfe5, + (q15_t)0x2a36, (q15_t)0xfed, (q15_t)0x2a3f, (q15_t)0xff5, (q15_t)0x2a49, + (q15_t)0xffe, (q15_t)0x2a52, (q15_t)0x1006, (q15_t)0x2a5c, (q15_t)0x100e, + (q15_t)0x2a65, (q15_t)0x1016, (q15_t)0x2a6e, (q15_t)0x101f, (q15_t)0x2a78, + (q15_t)0x1027, (q15_t)0x2a81, (q15_t)0x1030, (q15_t)0x2a8b, (q15_t)0x1038, + (q15_t)0x2a94, (q15_t)0x1040, (q15_t)0x2a9d, (q15_t)0x1049, (q15_t)0x2aa7, + (q15_t)0x1051, (q15_t)0x2ab0, (q15_t)0x1059, (q15_t)0x2ab9, (q15_t)0x1062, + (q15_t)0x2ac3, (q15_t)0x106a, (q15_t)0x2acc, (q15_t)0x1073, (q15_t)0x2ad6, + (q15_t)0x107b, (q15_t)0x2adf, (q15_t)0x1083, (q15_t)0x2ae8, (q15_t)0x108c, + (q15_t)0x2af2, (q15_t)0x1094, (q15_t)0x2afb, (q15_t)0x109d, (q15_t)0x2b04, + (q15_t)0x10a5, (q15_t)0x2b0d, (q15_t)0x10ae, (q15_t)0x2b17, (q15_t)0x10b6, + (q15_t)0x2b20, (q15_t)0x10bf, (q15_t)0x2b29, (q15_t)0x10c7, (q15_t)0x2b33, + (q15_t)0x10d0, (q15_t)0x2b3c, (q15_t)0x10d8, (q15_t)0x2b45, (q15_t)0x10e0, + (q15_t)0x2b4e, (q15_t)0x10e9, (q15_t)0x2b58, (q15_t)0x10f2, (q15_t)0x2b61, + (q15_t)0x10fa, (q15_t)0x2b6a, (q15_t)0x1103, (q15_t)0x2b73, (q15_t)0x110b, + (q15_t)0x2b7d, (q15_t)0x1114, (q15_t)0x2b86, (q15_t)0x111c, (q15_t)0x2b8f, + (q15_t)0x1125, (q15_t)0x2b98, (q15_t)0x112d, (q15_t)0x2ba1, (q15_t)0x1136, + (q15_t)0x2bab, (q15_t)0x113e, (q15_t)0x2bb4, (q15_t)0x1147, (q15_t)0x2bbd, + (q15_t)0x1150, (q15_t)0x2bc6, (q15_t)0x1158, (q15_t)0x2bcf, (q15_t)0x1161, + (q15_t)0x2bd8, (q15_t)0x1169, (q15_t)0x2be2, (q15_t)0x1172, (q15_t)0x2beb, + (q15_t)0x117b, (q15_t)0x2bf4, (q15_t)0x1183, (q15_t)0x2bfd, (q15_t)0x118c, + (q15_t)0x2c06, (q15_t)0x1195, (q15_t)0x2c0f, (q15_t)0x119d, (q15_t)0x2c18, + (q15_t)0x11a6, (q15_t)0x2c21, (q15_t)0x11af, (q15_t)0x2c2b, (q15_t)0x11b7, + (q15_t)0x2c34, (q15_t)0x11c0, (q15_t)0x2c3d, (q15_t)0x11c9, (q15_t)0x2c46, + (q15_t)0x11d1, (q15_t)0x2c4f, (q15_t)0x11da, (q15_t)0x2c58, (q15_t)0x11e3, + (q15_t)0x2c61, (q15_t)0x11eb, (q15_t)0x2c6a, (q15_t)0x11f4, (q15_t)0x2c73, + (q15_t)0x11fd, (q15_t)0x2c7c, (q15_t)0x1206, (q15_t)0x2c85, (q15_t)0x120e, + (q15_t)0x2c8e, (q15_t)0x1217, (q15_t)0x2c97, (q15_t)0x1220, (q15_t)0x2ca0, + (q15_t)0x1229, (q15_t)0x2ca9, (q15_t)0x1231, (q15_t)0x2cb2, (q15_t)0x123a, + (q15_t)0x2cbb, (q15_t)0x1243, (q15_t)0x2cc4, (q15_t)0x124c, (q15_t)0x2ccd, + (q15_t)0x1255, (q15_t)0x2cd6, (q15_t)0x125d, (q15_t)0x2cdf, (q15_t)0x1266, + (q15_t)0x2ce8, (q15_t)0x126f, (q15_t)0x2cf1, (q15_t)0x1278, (q15_t)0x2cfa, + (q15_t)0x1281, (q15_t)0x2d03, (q15_t)0x128a, (q15_t)0x2d0c, (q15_t)0x1292, + (q15_t)0x2d15, (q15_t)0x129b, (q15_t)0x2d1e, (q15_t)0x12a4, (q15_t)0x2d27, + (q15_t)0x12ad, (q15_t)0x2d2f, (q15_t)0x12b6, (q15_t)0x2d38, (q15_t)0x12bf, + (q15_t)0x2d41, (q15_t)0x12c8, (q15_t)0x2d4a, (q15_t)0x12d1, (q15_t)0x2d53, + (q15_t)0x12d9, (q15_t)0x2d5c, (q15_t)0x12e2, (q15_t)0x2d65, (q15_t)0x12eb, + (q15_t)0x2d6e, (q15_t)0x12f4, (q15_t)0x2d76, (q15_t)0x12fd, (q15_t)0x2d7f, + (q15_t)0x1306, (q15_t)0x2d88, (q15_t)0x130f, (q15_t)0x2d91, (q15_t)0x1318, + (q15_t)0x2d9a, (q15_t)0x1321, (q15_t)0x2da3, (q15_t)0x132a, (q15_t)0x2dab, + (q15_t)0x1333, (q15_t)0x2db4, (q15_t)0x133c, (q15_t)0x2dbd, (q15_t)0x1345, + (q15_t)0x2dc6, (q15_t)0x134e, (q15_t)0x2dcf, (q15_t)0x1357, (q15_t)0x2dd7, + (q15_t)0x1360, (q15_t)0x2de0, (q15_t)0x1369, (q15_t)0x2de9, (q15_t)0x1372, + (q15_t)0x2df2, (q15_t)0x137b, (q15_t)0x2dfa, (q15_t)0x1384, (q15_t)0x2e03, + (q15_t)0x138d, (q15_t)0x2e0c, (q15_t)0x1396, (q15_t)0x2e15, (q15_t)0x139f, + (q15_t)0x2e1d, (q15_t)0x13a8, (q15_t)0x2e26, (q15_t)0x13b1, (q15_t)0x2e2f, + (q15_t)0x13ba, (q15_t)0x2e37, (q15_t)0x13c3, (q15_t)0x2e40, (q15_t)0x13cc, + (q15_t)0x2e49, (q15_t)0x13d5, (q15_t)0x2e51, (q15_t)0x13df, (q15_t)0x2e5a, + (q15_t)0x13e8, (q15_t)0x2e63, (q15_t)0x13f1, (q15_t)0x2e6b, (q15_t)0x13fa, + (q15_t)0x2e74, (q15_t)0x1403, (q15_t)0x2e7d, (q15_t)0x140c, (q15_t)0x2e85, + (q15_t)0x1415, (q15_t)0x2e8e, (q15_t)0x141e, (q15_t)0x2e97, (q15_t)0x1428, + (q15_t)0x2e9f, (q15_t)0x1431, (q15_t)0x2ea8, (q15_t)0x143a, (q15_t)0x2eb0, + (q15_t)0x1443, (q15_t)0x2eb9, (q15_t)0x144c, (q15_t)0x2ec2, (q15_t)0x1455, + (q15_t)0x2eca, (q15_t)0x145f, (q15_t)0x2ed3, (q15_t)0x1468, (q15_t)0x2edb, + (q15_t)0x1471, (q15_t)0x2ee4, (q15_t)0x147a, (q15_t)0x2eec, (q15_t)0x1483, + (q15_t)0x2ef5, (q15_t)0x148d, (q15_t)0x2efd, (q15_t)0x1496, (q15_t)0x2f06, + (q15_t)0x149f, (q15_t)0x2f0e, (q15_t)0x14a8, (q15_t)0x2f17, (q15_t)0x14b2, + (q15_t)0x2f20, (q15_t)0x14bb, (q15_t)0x2f28, (q15_t)0x14c4, (q15_t)0x2f30, + (q15_t)0x14cd, (q15_t)0x2f39, (q15_t)0x14d7, (q15_t)0x2f41, (q15_t)0x14e0, + (q15_t)0x2f4a, (q15_t)0x14e9, (q15_t)0x2f52, (q15_t)0x14f3, (q15_t)0x2f5b, + (q15_t)0x14fc, (q15_t)0x2f63, (q15_t)0x1505, (q15_t)0x2f6c, (q15_t)0x150e, + (q15_t)0x2f74, (q15_t)0x1518, (q15_t)0x2f7d, (q15_t)0x1521, (q15_t)0x2f85, + (q15_t)0x152a, (q15_t)0x2f8d, (q15_t)0x1534, (q15_t)0x2f96, (q15_t)0x153d, + (q15_t)0x2f9e, (q15_t)0x1547, (q15_t)0x2fa7, (q15_t)0x1550, (q15_t)0x2faf, + (q15_t)0x1559, (q15_t)0x2fb7, (q15_t)0x1563, (q15_t)0x2fc0, (q15_t)0x156c, + (q15_t)0x2fc8, (q15_t)0x1575, (q15_t)0x2fd0, (q15_t)0x157f, (q15_t)0x2fd9, + (q15_t)0x1588, (q15_t)0x2fe1, (q15_t)0x1592, (q15_t)0x2fea, (q15_t)0x159b, + (q15_t)0x2ff2, (q15_t)0x15a4, (q15_t)0x2ffa, (q15_t)0x15ae, (q15_t)0x3002, + (q15_t)0x15b7, (q15_t)0x300b, (q15_t)0x15c1, (q15_t)0x3013, (q15_t)0x15ca, + (q15_t)0x301b, (q15_t)0x15d4, (q15_t)0x3024, (q15_t)0x15dd, (q15_t)0x302c, + (q15_t)0x15e6, (q15_t)0x3034, (q15_t)0x15f0, (q15_t)0x303c, (q15_t)0x15f9, + (q15_t)0x3045, (q15_t)0x1603, (q15_t)0x304d, (q15_t)0x160c, (q15_t)0x3055, + (q15_t)0x1616, (q15_t)0x305d, (q15_t)0x161f, (q15_t)0x3066, (q15_t)0x1629, + (q15_t)0x306e, (q15_t)0x1632, (q15_t)0x3076, (q15_t)0x163c, (q15_t)0x307e, + (q15_t)0x1645, (q15_t)0x3087, (q15_t)0x164f, (q15_t)0x308f, (q15_t)0x1659, + (q15_t)0x3097, (q15_t)0x1662, (q15_t)0x309f, (q15_t)0x166c, (q15_t)0x30a7, + (q15_t)0x1675, (q15_t)0x30af, (q15_t)0x167f, (q15_t)0x30b8, (q15_t)0x1688, + (q15_t)0x30c0, (q15_t)0x1692, (q15_t)0x30c8, (q15_t)0x169b, (q15_t)0x30d0, + (q15_t)0x16a5, (q15_t)0x30d8, (q15_t)0x16af, (q15_t)0x30e0, (q15_t)0x16b8, + (q15_t)0x30e8, (q15_t)0x16c2, (q15_t)0x30f0, (q15_t)0x16cb, (q15_t)0x30f9, + (q15_t)0x16d5, (q15_t)0x3101, (q15_t)0x16df, (q15_t)0x3109, (q15_t)0x16e8, + (q15_t)0x3111, (q15_t)0x16f2, (q15_t)0x3119, (q15_t)0x16fc, (q15_t)0x3121, + (q15_t)0x1705, (q15_t)0x3129, (q15_t)0x170f, (q15_t)0x3131, (q15_t)0x1719, + (q15_t)0x3139, (q15_t)0x1722, (q15_t)0x3141, (q15_t)0x172c, (q15_t)0x3149, + (q15_t)0x1736, (q15_t)0x3151, (q15_t)0x173f, (q15_t)0x3159, (q15_t)0x1749, + (q15_t)0x3161, (q15_t)0x1753, (q15_t)0x3169, (q15_t)0x175c, (q15_t)0x3171, + (q15_t)0x1766, (q15_t)0x3179, (q15_t)0x1770, (q15_t)0x3181, (q15_t)0x177a, + (q15_t)0x3189, (q15_t)0x1783, (q15_t)0x3191, (q15_t)0x178d, (q15_t)0x3199, + (q15_t)0x1797, (q15_t)0x31a1, (q15_t)0x17a0, (q15_t)0x31a9, (q15_t)0x17aa, + (q15_t)0x31b1, (q15_t)0x17b4, (q15_t)0x31b9, (q15_t)0x17be, (q15_t)0x31c0, + (q15_t)0x17c8, (q15_t)0x31c8, (q15_t)0x17d1, (q15_t)0x31d0, (q15_t)0x17db, + (q15_t)0x31d8, (q15_t)0x17e5, (q15_t)0x31e0, (q15_t)0x17ef, (q15_t)0x31e8, + (q15_t)0x17f8, (q15_t)0x31f0, (q15_t)0x1802, (q15_t)0x31f8, (q15_t)0x180c, + (q15_t)0x31ff, (q15_t)0x1816, (q15_t)0x3207, (q15_t)0x1820, (q15_t)0x320f, + (q15_t)0x182a, (q15_t)0x3217, (q15_t)0x1833, (q15_t)0x321f, (q15_t)0x183d, + (q15_t)0x3227, (q15_t)0x1847, (q15_t)0x322e, (q15_t)0x1851, (q15_t)0x3236, + (q15_t)0x185b, (q15_t)0x323e, (q15_t)0x1865, (q15_t)0x3246, (q15_t)0x186f, + (q15_t)0x324e, (q15_t)0x1878, (q15_t)0x3255, (q15_t)0x1882, (q15_t)0x325d, + (q15_t)0x188c, (q15_t)0x3265, (q15_t)0x1896, (q15_t)0x326d, (q15_t)0x18a0, + (q15_t)0x3274, (q15_t)0x18aa, (q15_t)0x327c, (q15_t)0x18b4, (q15_t)0x3284, + (q15_t)0x18be, (q15_t)0x328b, (q15_t)0x18c8, (q15_t)0x3293, (q15_t)0x18d2, + (q15_t)0x329b, (q15_t)0x18dc, (q15_t)0x32a3, (q15_t)0x18e6, (q15_t)0x32aa, + (q15_t)0x18ef, (q15_t)0x32b2, (q15_t)0x18f9, (q15_t)0x32ba, (q15_t)0x1903, + (q15_t)0x32c1, (q15_t)0x190d, (q15_t)0x32c9, (q15_t)0x1917, (q15_t)0x32d0, + (q15_t)0x1921, (q15_t)0x32d8, (q15_t)0x192b, (q15_t)0x32e0, (q15_t)0x1935, + (q15_t)0x32e7, (q15_t)0x193f, (q15_t)0x32ef, (q15_t)0x1949, (q15_t)0x32f7, + (q15_t)0x1953, (q15_t)0x32fe, (q15_t)0x195d, (q15_t)0x3306, (q15_t)0x1967, + (q15_t)0x330d, (q15_t)0x1971, (q15_t)0x3315, (q15_t)0x197b, (q15_t)0x331d, + (q15_t)0x1985, (q15_t)0x3324, (q15_t)0x198f, (q15_t)0x332c, (q15_t)0x199a, + (q15_t)0x3333, (q15_t)0x19a4, (q15_t)0x333b, (q15_t)0x19ae, (q15_t)0x3342, + (q15_t)0x19b8, (q15_t)0x334a, (q15_t)0x19c2, (q15_t)0x3351, (q15_t)0x19cc, + (q15_t)0x3359, (q15_t)0x19d6, (q15_t)0x3360, (q15_t)0x19e0, (q15_t)0x3368, + (q15_t)0x19ea, (q15_t)0x336f, (q15_t)0x19f4, (q15_t)0x3377, (q15_t)0x19fe, + (q15_t)0x337e, (q15_t)0x1a08, (q15_t)0x3386, (q15_t)0x1a13, (q15_t)0x338d, + (q15_t)0x1a1d, (q15_t)0x3395, (q15_t)0x1a27, (q15_t)0x339c, (q15_t)0x1a31, + (q15_t)0x33a3, (q15_t)0x1a3b, (q15_t)0x33ab, (q15_t)0x1a45, (q15_t)0x33b2, + (q15_t)0x1a4f, (q15_t)0x33ba, (q15_t)0x1a5a, (q15_t)0x33c1, (q15_t)0x1a64, + (q15_t)0x33c8, (q15_t)0x1a6e, (q15_t)0x33d0, (q15_t)0x1a78, (q15_t)0x33d7, + (q15_t)0x1a82, (q15_t)0x33df, (q15_t)0x1a8c, (q15_t)0x33e6, (q15_t)0x1a97, + (q15_t)0x33ed, (q15_t)0x1aa1, (q15_t)0x33f5, (q15_t)0x1aab, (q15_t)0x33fc, + (q15_t)0x1ab5, (q15_t)0x3403, (q15_t)0x1abf, (q15_t)0x340b, (q15_t)0x1aca, + (q15_t)0x3412, (q15_t)0x1ad4, (q15_t)0x3419, (q15_t)0x1ade, (q15_t)0x3420, + (q15_t)0x1ae8, (q15_t)0x3428, (q15_t)0x1af3, (q15_t)0x342f, (q15_t)0x1afd, + (q15_t)0x3436, (q15_t)0x1b07, (q15_t)0x343e, (q15_t)0x1b11, (q15_t)0x3445, + (q15_t)0x1b1c, (q15_t)0x344c, (q15_t)0x1b26, (q15_t)0x3453, (q15_t)0x1b30, + (q15_t)0x345b, (q15_t)0x1b3b, (q15_t)0x3462, (q15_t)0x1b45, (q15_t)0x3469, + (q15_t)0x1b4f, (q15_t)0x3470, (q15_t)0x1b59, (q15_t)0x3477, (q15_t)0x1b64, + (q15_t)0x347f, (q15_t)0x1b6e, (q15_t)0x3486, (q15_t)0x1b78, (q15_t)0x348d, + (q15_t)0x1b83, (q15_t)0x3494, (q15_t)0x1b8d, (q15_t)0x349b, (q15_t)0x1b97, + (q15_t)0x34a2, (q15_t)0x1ba2, (q15_t)0x34aa, (q15_t)0x1bac, (q15_t)0x34b1, + (q15_t)0x1bb6, (q15_t)0x34b8, (q15_t)0x1bc1, (q15_t)0x34bf, (q15_t)0x1bcb, + (q15_t)0x34c6, (q15_t)0x1bd5, (q15_t)0x34cd, (q15_t)0x1be0, (q15_t)0x34d4, + (q15_t)0x1bea, (q15_t)0x34db, (q15_t)0x1bf5, (q15_t)0x34e2, (q15_t)0x1bff, + (q15_t)0x34ea, (q15_t)0x1c09, (q15_t)0x34f1, (q15_t)0x1c14, (q15_t)0x34f8, + (q15_t)0x1c1e, (q15_t)0x34ff, (q15_t)0x1c29, (q15_t)0x3506, (q15_t)0x1c33, + (q15_t)0x350d, (q15_t)0x1c3d, (q15_t)0x3514, (q15_t)0x1c48, (q15_t)0x351b, + (q15_t)0x1c52, (q15_t)0x3522, (q15_t)0x1c5d, (q15_t)0x3529, (q15_t)0x1c67, + (q15_t)0x3530, (q15_t)0x1c72, (q15_t)0x3537, (q15_t)0x1c7c, (q15_t)0x353e, + (q15_t)0x1c86, (q15_t)0x3545, (q15_t)0x1c91, (q15_t)0x354c, (q15_t)0x1c9b, + (q15_t)0x3553, (q15_t)0x1ca6, (q15_t)0x355a, (q15_t)0x1cb0, (q15_t)0x3561, + (q15_t)0x1cbb, (q15_t)0x3567, (q15_t)0x1cc5, (q15_t)0x356e, (q15_t)0x1cd0, + (q15_t)0x3575, (q15_t)0x1cda, (q15_t)0x357c, (q15_t)0x1ce5, (q15_t)0x3583, + (q15_t)0x1cef, (q15_t)0x358a, (q15_t)0x1cfa, (q15_t)0x3591, (q15_t)0x1d04, + (q15_t)0x3598, (q15_t)0x1d0f, (q15_t)0x359f, (q15_t)0x1d19, (q15_t)0x35a5, + (q15_t)0x1d24, (q15_t)0x35ac, (q15_t)0x1d2e, (q15_t)0x35b3, (q15_t)0x1d39, + (q15_t)0x35ba, (q15_t)0x1d44, (q15_t)0x35c1, (q15_t)0x1d4e, (q15_t)0x35c8, + (q15_t)0x1d59, (q15_t)0x35ce, (q15_t)0x1d63, (q15_t)0x35d5, (q15_t)0x1d6e, + (q15_t)0x35dc, (q15_t)0x1d78, (q15_t)0x35e3, (q15_t)0x1d83, (q15_t)0x35ea, + (q15_t)0x1d8e, (q15_t)0x35f0, (q15_t)0x1d98, (q15_t)0x35f7, (q15_t)0x1da3, + (q15_t)0x35fe, (q15_t)0x1dad, (q15_t)0x3605, (q15_t)0x1db8, (q15_t)0x360b, + (q15_t)0x1dc3, (q15_t)0x3612, (q15_t)0x1dcd, (q15_t)0x3619, (q15_t)0x1dd8, + (q15_t)0x3620, (q15_t)0x1de2, (q15_t)0x3626, (q15_t)0x1ded, (q15_t)0x362d, + (q15_t)0x1df8, (q15_t)0x3634, (q15_t)0x1e02, (q15_t)0x363a, (q15_t)0x1e0d, + (q15_t)0x3641, (q15_t)0x1e18, (q15_t)0x3648, (q15_t)0x1e22, (q15_t)0x364e, + (q15_t)0x1e2d, (q15_t)0x3655, (q15_t)0x1e38, (q15_t)0x365c, (q15_t)0x1e42, + (q15_t)0x3662, (q15_t)0x1e4d, (q15_t)0x3669, (q15_t)0x1e58, (q15_t)0x366f, + (q15_t)0x1e62, (q15_t)0x3676, (q15_t)0x1e6d, (q15_t)0x367d, (q15_t)0x1e78, + (q15_t)0x3683, (q15_t)0x1e83, (q15_t)0x368a, (q15_t)0x1e8d, (q15_t)0x3690, + (q15_t)0x1e98, (q15_t)0x3697, (q15_t)0x1ea3, (q15_t)0x369d, (q15_t)0x1ead, + (q15_t)0x36a4, (q15_t)0x1eb8, (q15_t)0x36ab, (q15_t)0x1ec3, (q15_t)0x36b1, + (q15_t)0x1ece, (q15_t)0x36b8, (q15_t)0x1ed8, (q15_t)0x36be, (q15_t)0x1ee3, + (q15_t)0x36c5, (q15_t)0x1eee, (q15_t)0x36cb, (q15_t)0x1ef9, (q15_t)0x36d2, + (q15_t)0x1f03, (q15_t)0x36d8, (q15_t)0x1f0e, (q15_t)0x36df, (q15_t)0x1f19, + (q15_t)0x36e5, (q15_t)0x1f24, (q15_t)0x36eb, (q15_t)0x1f2f, (q15_t)0x36f2, + (q15_t)0x1f39, (q15_t)0x36f8, (q15_t)0x1f44, (q15_t)0x36ff, (q15_t)0x1f4f, + (q15_t)0x3705, (q15_t)0x1f5a, (q15_t)0x370c, (q15_t)0x1f65, (q15_t)0x3712, + (q15_t)0x1f6f, (q15_t)0x3718, (q15_t)0x1f7a, (q15_t)0x371f, (q15_t)0x1f85, + (q15_t)0x3725, (q15_t)0x1f90, (q15_t)0x372c, (q15_t)0x1f9b, (q15_t)0x3732, + (q15_t)0x1fa5, (q15_t)0x3738, (q15_t)0x1fb0, (q15_t)0x373f, (q15_t)0x1fbb, + (q15_t)0x3745, (q15_t)0x1fc6, (q15_t)0x374b, (q15_t)0x1fd1, (q15_t)0x3752, + (q15_t)0x1fdc, (q15_t)0x3758, (q15_t)0x1fe7, (q15_t)0x375e, (q15_t)0x1ff1, + (q15_t)0x3765, (q15_t)0x1ffc, (q15_t)0x376b, (q15_t)0x2007, (q15_t)0x3771, + (q15_t)0x2012, (q15_t)0x3777, (q15_t)0x201d, (q15_t)0x377e, (q15_t)0x2028, + (q15_t)0x3784, (q15_t)0x2033, (q15_t)0x378a, (q15_t)0x203e, (q15_t)0x3790, + (q15_t)0x2049, (q15_t)0x3797, (q15_t)0x2054, (q15_t)0x379d, (q15_t)0x205e, + (q15_t)0x37a3, (q15_t)0x2069, (q15_t)0x37a9, (q15_t)0x2074, (q15_t)0x37b0, + (q15_t)0x207f, (q15_t)0x37b6, (q15_t)0x208a, (q15_t)0x37bc, (q15_t)0x2095, + (q15_t)0x37c2, (q15_t)0x20a0, (q15_t)0x37c8, (q15_t)0x20ab, (q15_t)0x37ce, + (q15_t)0x20b6, (q15_t)0x37d5, (q15_t)0x20c1, (q15_t)0x37db, (q15_t)0x20cc, + (q15_t)0x37e1, (q15_t)0x20d7, (q15_t)0x37e7, (q15_t)0x20e2, (q15_t)0x37ed, + (q15_t)0x20ed, (q15_t)0x37f3, (q15_t)0x20f8, (q15_t)0x37f9, (q15_t)0x2103, + (q15_t)0x37ff, (q15_t)0x210e, (q15_t)0x3805, (q15_t)0x2119, (q15_t)0x380b, + (q15_t)0x2124, (q15_t)0x3812, (q15_t)0x212f, (q15_t)0x3818, (q15_t)0x213a, + (q15_t)0x381e, (q15_t)0x2145, (q15_t)0x3824, (q15_t)0x2150, (q15_t)0x382a, + (q15_t)0x215b, (q15_t)0x3830, (q15_t)0x2166, (q15_t)0x3836, (q15_t)0x2171, + (q15_t)0x383c, (q15_t)0x217c, (q15_t)0x3842, (q15_t)0x2187, (q15_t)0x3848, + (q15_t)0x2192, (q15_t)0x384e, (q15_t)0x219d, (q15_t)0x3854, (q15_t)0x21a8, + (q15_t)0x385a, (q15_t)0x21b3, (q15_t)0x3860, (q15_t)0x21be, (q15_t)0x3866, + (q15_t)0x21ca, (q15_t)0x386b, (q15_t)0x21d5, (q15_t)0x3871, (q15_t)0x21e0, + (q15_t)0x3877, (q15_t)0x21eb, (q15_t)0x387d, (q15_t)0x21f6, (q15_t)0x3883, + (q15_t)0x2201, (q15_t)0x3889, (q15_t)0x220c, (q15_t)0x388f, (q15_t)0x2217, + (q15_t)0x3895, (q15_t)0x2222, (q15_t)0x389b, (q15_t)0x222d, (q15_t)0x38a1, + (q15_t)0x2239, (q15_t)0x38a6, (q15_t)0x2244, (q15_t)0x38ac, (q15_t)0x224f, + (q15_t)0x38b2, (q15_t)0x225a, (q15_t)0x38b8, (q15_t)0x2265, (q15_t)0x38be, + (q15_t)0x2270, (q15_t)0x38c3, (q15_t)0x227b, (q15_t)0x38c9, (q15_t)0x2287, + (q15_t)0x38cf, (q15_t)0x2292, (q15_t)0x38d5, (q15_t)0x229d, (q15_t)0x38db, + (q15_t)0x22a8, (q15_t)0x38e0, (q15_t)0x22b3, (q15_t)0x38e6, (q15_t)0x22be, + (q15_t)0x38ec, (q15_t)0x22ca, (q15_t)0x38f2, (q15_t)0x22d5, (q15_t)0x38f7, + (q15_t)0x22e0, (q15_t)0x38fd, (q15_t)0x22eb, (q15_t)0x3903, (q15_t)0x22f6, + (q15_t)0x3909, (q15_t)0x2301, (q15_t)0x390e, (q15_t)0x230d, (q15_t)0x3914, + (q15_t)0x2318, (q15_t)0x391a, (q15_t)0x2323, (q15_t)0x391f, (q15_t)0x232e, + (q15_t)0x3925, (q15_t)0x233a, (q15_t)0x392b, (q15_t)0x2345, (q15_t)0x3930, + (q15_t)0x2350, (q15_t)0x3936, (q15_t)0x235b, (q15_t)0x393b, (q15_t)0x2367, + (q15_t)0x3941, (q15_t)0x2372, (q15_t)0x3947, (q15_t)0x237d, (q15_t)0x394c, + (q15_t)0x2388, (q15_t)0x3952, (q15_t)0x2394, (q15_t)0x3958, (q15_t)0x239f, + (q15_t)0x395d, (q15_t)0x23aa, (q15_t)0x3963, (q15_t)0x23b5, (q15_t)0x3968, + (q15_t)0x23c1, (q15_t)0x396e, (q15_t)0x23cc, (q15_t)0x3973, (q15_t)0x23d7, + (q15_t)0x3979, (q15_t)0x23e2, (q15_t)0x397e, (q15_t)0x23ee, (q15_t)0x3984, + (q15_t)0x23f9, (q15_t)0x3989, (q15_t)0x2404, (q15_t)0x398f, (q15_t)0x2410, + (q15_t)0x3994, (q15_t)0x241b, (q15_t)0x399a, (q15_t)0x2426, (q15_t)0x399f, + (q15_t)0x2432, (q15_t)0x39a5, (q15_t)0x243d, (q15_t)0x39aa, (q15_t)0x2448, + (q15_t)0x39b0, (q15_t)0x2454, (q15_t)0x39b5, (q15_t)0x245f, (q15_t)0x39bb, + (q15_t)0x246a, (q15_t)0x39c0, (q15_t)0x2476, (q15_t)0x39c5, (q15_t)0x2481, + (q15_t)0x39cb, (q15_t)0x248c, (q15_t)0x39d0, (q15_t)0x2498, (q15_t)0x39d6, + (q15_t)0x24a3, (q15_t)0x39db, (q15_t)0x24ae, (q15_t)0x39e0, (q15_t)0x24ba, + (q15_t)0x39e6, (q15_t)0x24c5, (q15_t)0x39eb, (q15_t)0x24d0, (q15_t)0x39f0, + (q15_t)0x24dc, (q15_t)0x39f6, (q15_t)0x24e7, (q15_t)0x39fb, (q15_t)0x24f3, + (q15_t)0x3a00, (q15_t)0x24fe, (q15_t)0x3a06, (q15_t)0x2509, (q15_t)0x3a0b, + (q15_t)0x2515, (q15_t)0x3a10, (q15_t)0x2520, (q15_t)0x3a16, (q15_t)0x252c, + (q15_t)0x3a1b, (q15_t)0x2537, (q15_t)0x3a20, (q15_t)0x2542, (q15_t)0x3a25, + (q15_t)0x254e, (q15_t)0x3a2b, (q15_t)0x2559, (q15_t)0x3a30, (q15_t)0x2565, + (q15_t)0x3a35, (q15_t)0x2570, (q15_t)0x3a3a, (q15_t)0x257c, (q15_t)0x3a3f, + (q15_t)0x2587, (q15_t)0x3a45, (q15_t)0x2592, (q15_t)0x3a4a, (q15_t)0x259e, + (q15_t)0x3a4f, (q15_t)0x25a9, (q15_t)0x3a54, (q15_t)0x25b5, (q15_t)0x3a59, + (q15_t)0x25c0, (q15_t)0x3a5f, (q15_t)0x25cc, (q15_t)0x3a64, (q15_t)0x25d7, + (q15_t)0x3a69, (q15_t)0x25e3, (q15_t)0x3a6e, (q15_t)0x25ee, (q15_t)0x3a73, + (q15_t)0x25fa, (q15_t)0x3a78, (q15_t)0x2605, (q15_t)0x3a7d, (q15_t)0x2611, + (q15_t)0x3a82, (q15_t)0x261c, (q15_t)0x3a88, (q15_t)0x2628, (q15_t)0x3a8d, + (q15_t)0x2633, (q15_t)0x3a92, (q15_t)0x263f, (q15_t)0x3a97, (q15_t)0x264a, + (q15_t)0x3a9c, (q15_t)0x2656, (q15_t)0x3aa1, (q15_t)0x2661, (q15_t)0x3aa6, + (q15_t)0x266d, (q15_t)0x3aab, (q15_t)0x2678, (q15_t)0x3ab0, (q15_t)0x2684, + (q15_t)0x3ab5, (q15_t)0x268f, (q15_t)0x3aba, (q15_t)0x269b, (q15_t)0x3abf, + (q15_t)0x26a6, (q15_t)0x3ac4, (q15_t)0x26b2, (q15_t)0x3ac9, (q15_t)0x26bd, + (q15_t)0x3ace, (q15_t)0x26c9, (q15_t)0x3ad3, (q15_t)0x26d4, (q15_t)0x3ad8, + (q15_t)0x26e0, (q15_t)0x3add, (q15_t)0x26ec, (q15_t)0x3ae2, (q15_t)0x26f7, + (q15_t)0x3ae6, (q15_t)0x2703, (q15_t)0x3aeb, (q15_t)0x270e, (q15_t)0x3af0, + (q15_t)0x271a, (q15_t)0x3af5, (q15_t)0x2725, (q15_t)0x3afa, (q15_t)0x2731, + (q15_t)0x3aff, (q15_t)0x273d, (q15_t)0x3b04, (q15_t)0x2748, (q15_t)0x3b09, + (q15_t)0x2754, (q15_t)0x3b0e, (q15_t)0x275f, (q15_t)0x3b12, (q15_t)0x276b, + (q15_t)0x3b17, (q15_t)0x2777, (q15_t)0x3b1c, (q15_t)0x2782, (q15_t)0x3b21, + (q15_t)0x278e, (q15_t)0x3b26, (q15_t)0x2799, (q15_t)0x3b2a, (q15_t)0x27a5, + (q15_t)0x3b2f, (q15_t)0x27b1, (q15_t)0x3b34, (q15_t)0x27bc, (q15_t)0x3b39, + (q15_t)0x27c8, (q15_t)0x3b3e, (q15_t)0x27d3, (q15_t)0x3b42, (q15_t)0x27df, + (q15_t)0x3b47, (q15_t)0x27eb, (q15_t)0x3b4c, (q15_t)0x27f6, (q15_t)0x3b50, + (q15_t)0x2802, (q15_t)0x3b55, (q15_t)0x280e, (q15_t)0x3b5a, (q15_t)0x2819, + (q15_t)0x3b5f, (q15_t)0x2825, (q15_t)0x3b63, (q15_t)0x2831, (q15_t)0x3b68, + (q15_t)0x283c, (q15_t)0x3b6d, (q15_t)0x2848, (q15_t)0x3b71, (q15_t)0x2854, + (q15_t)0x3b76, (q15_t)0x285f, (q15_t)0x3b7b, (q15_t)0x286b, (q15_t)0x3b7f, + (q15_t)0x2877, (q15_t)0x3b84, (q15_t)0x2882, (q15_t)0x3b88, (q15_t)0x288e, + (q15_t)0x3b8d, (q15_t)0x289a, (q15_t)0x3b92, (q15_t)0x28a5, (q15_t)0x3b96, + (q15_t)0x28b1, (q15_t)0x3b9b, (q15_t)0x28bd, (q15_t)0x3b9f, (q15_t)0x28c9, + (q15_t)0x3ba4, (q15_t)0x28d4, (q15_t)0x3ba9, (q15_t)0x28e0, (q15_t)0x3bad, + (q15_t)0x28ec, (q15_t)0x3bb2, (q15_t)0x28f7, (q15_t)0x3bb6, (q15_t)0x2903, + (q15_t)0x3bbb, (q15_t)0x290f, (q15_t)0x3bbf, (q15_t)0x291b, (q15_t)0x3bc4, + (q15_t)0x2926, (q15_t)0x3bc8, (q15_t)0x2932, (q15_t)0x3bcd, (q15_t)0x293e, + (q15_t)0x3bd1, (q15_t)0x294a, (q15_t)0x3bd6, (q15_t)0x2955, (q15_t)0x3bda, + (q15_t)0x2961, (q15_t)0x3bde, (q15_t)0x296d, (q15_t)0x3be3, (q15_t)0x2979, + (q15_t)0x3be7, (q15_t)0x2984, (q15_t)0x3bec, (q15_t)0x2990, (q15_t)0x3bf0, + (q15_t)0x299c, (q15_t)0x3bf5, (q15_t)0x29a8, (q15_t)0x3bf9, (q15_t)0x29b4, + (q15_t)0x3bfd, (q15_t)0x29bf, (q15_t)0x3c02, (q15_t)0x29cb, (q15_t)0x3c06, + (q15_t)0x29d7, (q15_t)0x3c0a, (q15_t)0x29e3, (q15_t)0x3c0f, (q15_t)0x29ee, + (q15_t)0x3c13, (q15_t)0x29fa, (q15_t)0x3c17, (q15_t)0x2a06, (q15_t)0x3c1c, + (q15_t)0x2a12, (q15_t)0x3c20, (q15_t)0x2a1e, (q15_t)0x3c24, (q15_t)0x2a29, + (q15_t)0x3c29, (q15_t)0x2a35, (q15_t)0x3c2d, (q15_t)0x2a41, (q15_t)0x3c31, + (q15_t)0x2a4d, (q15_t)0x3c36, (q15_t)0x2a59, (q15_t)0x3c3a, (q15_t)0x2a65, + (q15_t)0x3c3e, (q15_t)0x2a70, (q15_t)0x3c42, (q15_t)0x2a7c, (q15_t)0x3c46, + (q15_t)0x2a88, (q15_t)0x3c4b, (q15_t)0x2a94, (q15_t)0x3c4f, (q15_t)0x2aa0, + (q15_t)0x3c53, (q15_t)0x2aac, (q15_t)0x3c57, (q15_t)0x2ab7, (q15_t)0x3c5b, + (q15_t)0x2ac3, (q15_t)0x3c60, (q15_t)0x2acf, (q15_t)0x3c64, (q15_t)0x2adb, + (q15_t)0x3c68, (q15_t)0x2ae7, (q15_t)0x3c6c, (q15_t)0x2af3, (q15_t)0x3c70, + (q15_t)0x2aff, (q15_t)0x3c74, (q15_t)0x2b0a, (q15_t)0x3c79, (q15_t)0x2b16, + (q15_t)0x3c7d, (q15_t)0x2b22, (q15_t)0x3c81, (q15_t)0x2b2e, (q15_t)0x3c85, + (q15_t)0x2b3a, (q15_t)0x3c89, (q15_t)0x2b46, (q15_t)0x3c8d, (q15_t)0x2b52, + (q15_t)0x3c91, (q15_t)0x2b5e, (q15_t)0x3c95, (q15_t)0x2b6a, (q15_t)0x3c99, + (q15_t)0x2b75, (q15_t)0x3c9d, (q15_t)0x2b81, (q15_t)0x3ca1, (q15_t)0x2b8d, + (q15_t)0x3ca5, (q15_t)0x2b99, (q15_t)0x3ca9, (q15_t)0x2ba5, (q15_t)0x3cad, + (q15_t)0x2bb1, (q15_t)0x3cb1, (q15_t)0x2bbd, (q15_t)0x3cb5, (q15_t)0x2bc9, + (q15_t)0x3cb9, (q15_t)0x2bd5, (q15_t)0x3cbd, (q15_t)0x2be1, (q15_t)0x3cc1, + (q15_t)0x2bed, (q15_t)0x3cc5, (q15_t)0x2bf9, (q15_t)0x3cc9, (q15_t)0x2c05, + (q15_t)0x3ccd, (q15_t)0x2c10, (q15_t)0x3cd1, (q15_t)0x2c1c, (q15_t)0x3cd5, + (q15_t)0x2c28, (q15_t)0x3cd9, (q15_t)0x2c34, (q15_t)0x3cdd, (q15_t)0x2c40, + (q15_t)0x3ce0, (q15_t)0x2c4c, (q15_t)0x3ce4, (q15_t)0x2c58, (q15_t)0x3ce8, + (q15_t)0x2c64, (q15_t)0x3cec, (q15_t)0x2c70, (q15_t)0x3cf0, (q15_t)0x2c7c, + (q15_t)0x3cf4, (q15_t)0x2c88, (q15_t)0x3cf8, (q15_t)0x2c94, (q15_t)0x3cfb, + (q15_t)0x2ca0, (q15_t)0x3cff, (q15_t)0x2cac, (q15_t)0x3d03, (q15_t)0x2cb8, + (q15_t)0x3d07, (q15_t)0x2cc4, (q15_t)0x3d0b, (q15_t)0x2cd0, (q15_t)0x3d0e, + (q15_t)0x2cdc, (q15_t)0x3d12, (q15_t)0x2ce8, (q15_t)0x3d16, (q15_t)0x2cf4, + (q15_t)0x3d1a, (q15_t)0x2d00, (q15_t)0x3d1d, (q15_t)0x2d0c, (q15_t)0x3d21, + (q15_t)0x2d18, (q15_t)0x3d25, (q15_t)0x2d24, (q15_t)0x3d28, (q15_t)0x2d30, + (q15_t)0x3d2c, (q15_t)0x2d3c, (q15_t)0x3d30, (q15_t)0x2d48, (q15_t)0x3d34, + (q15_t)0x2d54, (q15_t)0x3d37, (q15_t)0x2d60, (q15_t)0x3d3b, (q15_t)0x2d6c, + (q15_t)0x3d3f, (q15_t)0x2d78, (q15_t)0x3d42, (q15_t)0x2d84, (q15_t)0x3d46, + (q15_t)0x2d90, (q15_t)0x3d49, (q15_t)0x2d9c, (q15_t)0x3d4d, (q15_t)0x2da8, + (q15_t)0x3d51, (q15_t)0x2db4, (q15_t)0x3d54, (q15_t)0x2dc0, (q15_t)0x3d58, + (q15_t)0x2dcc, (q15_t)0x3d5b, (q15_t)0x2dd8, (q15_t)0x3d5f, (q15_t)0x2de4, + (q15_t)0x3d63, (q15_t)0x2df0, (q15_t)0x3d66, (q15_t)0x2dfc, (q15_t)0x3d6a, + (q15_t)0x2e09, (q15_t)0x3d6d, (q15_t)0x2e15, (q15_t)0x3d71, (q15_t)0x2e21, + (q15_t)0x3d74, (q15_t)0x2e2d, (q15_t)0x3d78, (q15_t)0x2e39, (q15_t)0x3d7b, + (q15_t)0x2e45, (q15_t)0x3d7f, (q15_t)0x2e51, (q15_t)0x3d82, (q15_t)0x2e5d, + (q15_t)0x3d86, (q15_t)0x2e69, (q15_t)0x3d89, (q15_t)0x2e75, (q15_t)0x3d8d, + (q15_t)0x2e81, (q15_t)0x3d90, (q15_t)0x2e8d, (q15_t)0x3d93, (q15_t)0x2e99, + (q15_t)0x3d97, (q15_t)0x2ea6, (q15_t)0x3d9a, (q15_t)0x2eb2, (q15_t)0x3d9e, + (q15_t)0x2ebe, (q15_t)0x3da1, (q15_t)0x2eca, (q15_t)0x3da4, (q15_t)0x2ed6, + (q15_t)0x3da8, (q15_t)0x2ee2, (q15_t)0x3dab, (q15_t)0x2eee, (q15_t)0x3daf, + (q15_t)0x2efa, (q15_t)0x3db2, (q15_t)0x2f06, (q15_t)0x3db5, (q15_t)0x2f13, + (q15_t)0x3db9, (q15_t)0x2f1f, (q15_t)0x3dbc, (q15_t)0x2f2b, (q15_t)0x3dbf, + (q15_t)0x2f37, (q15_t)0x3dc2, (q15_t)0x2f43, (q15_t)0x3dc6, (q15_t)0x2f4f, + (q15_t)0x3dc9, (q15_t)0x2f5b, (q15_t)0x3dcc, (q15_t)0x2f67, (q15_t)0x3dd0, + (q15_t)0x2f74, (q15_t)0x3dd3, (q15_t)0x2f80, (q15_t)0x3dd6, (q15_t)0x2f8c, + (q15_t)0x3dd9, (q15_t)0x2f98, (q15_t)0x3ddd, (q15_t)0x2fa4, (q15_t)0x3de0, + (q15_t)0x2fb0, (q15_t)0x3de3, (q15_t)0x2fbc, (q15_t)0x3de6, (q15_t)0x2fc9, + (q15_t)0x3de9, (q15_t)0x2fd5, (q15_t)0x3ded, (q15_t)0x2fe1, (q15_t)0x3df0, + (q15_t)0x2fed, (q15_t)0x3df3, (q15_t)0x2ff9, (q15_t)0x3df6, (q15_t)0x3005, + (q15_t)0x3df9, (q15_t)0x3012, (q15_t)0x3dfc, (q15_t)0x301e, (q15_t)0x3dff, + (q15_t)0x302a, (q15_t)0x3e03, (q15_t)0x3036, (q15_t)0x3e06, (q15_t)0x3042, + (q15_t)0x3e09, (q15_t)0x304e, (q15_t)0x3e0c, (q15_t)0x305b, (q15_t)0x3e0f, + (q15_t)0x3067, (q15_t)0x3e12, (q15_t)0x3073, (q15_t)0x3e15, (q15_t)0x307f, + (q15_t)0x3e18, (q15_t)0x308b, (q15_t)0x3e1b, (q15_t)0x3098, (q15_t)0x3e1e, + (q15_t)0x30a4, (q15_t)0x3e21, (q15_t)0x30b0, (q15_t)0x3e24, (q15_t)0x30bc, + (q15_t)0x3e27, (q15_t)0x30c8, (q15_t)0x3e2a, (q15_t)0x30d5, (q15_t)0x3e2d, + (q15_t)0x30e1, (q15_t)0x3e30, (q15_t)0x30ed, (q15_t)0x3e33, (q15_t)0x30f9, + (q15_t)0x3e36, (q15_t)0x3105, (q15_t)0x3e39, (q15_t)0x3112, (q15_t)0x3e3c, + (q15_t)0x311e, (q15_t)0x3e3f, (q15_t)0x312a, (q15_t)0x3e42, (q15_t)0x3136, + (q15_t)0x3e45, (q15_t)0x3143, (q15_t)0x3e48, (q15_t)0x314f, (q15_t)0x3e4a, + (q15_t)0x315b, (q15_t)0x3e4d, (q15_t)0x3167, (q15_t)0x3e50, (q15_t)0x3174, + (q15_t)0x3e53, (q15_t)0x3180, (q15_t)0x3e56, (q15_t)0x318c, (q15_t)0x3e59, + (q15_t)0x3198, (q15_t)0x3e5c, (q15_t)0x31a4, (q15_t)0x3e5e, (q15_t)0x31b1, + (q15_t)0x3e61, (q15_t)0x31bd, (q15_t)0x3e64, (q15_t)0x31c9, (q15_t)0x3e67, + (q15_t)0x31d5, (q15_t)0x3e6a, (q15_t)0x31e2, (q15_t)0x3e6c, (q15_t)0x31ee, + (q15_t)0x3e6f, (q15_t)0x31fa, (q15_t)0x3e72, (q15_t)0x3207, (q15_t)0x3e75, + (q15_t)0x3213, (q15_t)0x3e77, (q15_t)0x321f, (q15_t)0x3e7a, (q15_t)0x322b, + (q15_t)0x3e7d, (q15_t)0x3238, (q15_t)0x3e80, (q15_t)0x3244, (q15_t)0x3e82, + (q15_t)0x3250, (q15_t)0x3e85, (q15_t)0x325c, (q15_t)0x3e88, (q15_t)0x3269, + (q15_t)0x3e8a, (q15_t)0x3275, (q15_t)0x3e8d, (q15_t)0x3281, (q15_t)0x3e90, + (q15_t)0x328e, (q15_t)0x3e92, (q15_t)0x329a, (q15_t)0x3e95, (q15_t)0x32a6, + (q15_t)0x3e98, (q15_t)0x32b2, (q15_t)0x3e9a, (q15_t)0x32bf, (q15_t)0x3e9d, + (q15_t)0x32cb, (q15_t)0x3e9f, (q15_t)0x32d7, (q15_t)0x3ea2, (q15_t)0x32e4, + (q15_t)0x3ea5, (q15_t)0x32f0, (q15_t)0x3ea7, (q15_t)0x32fc, (q15_t)0x3eaa, + (q15_t)0x3308, (q15_t)0x3eac, (q15_t)0x3315, (q15_t)0x3eaf, (q15_t)0x3321, + (q15_t)0x3eb1, (q15_t)0x332d, (q15_t)0x3eb4, (q15_t)0x333a, (q15_t)0x3eb6, + (q15_t)0x3346, (q15_t)0x3eb9, (q15_t)0x3352, (q15_t)0x3ebb, (q15_t)0x335f, + (q15_t)0x3ebe, (q15_t)0x336b, (q15_t)0x3ec0, (q15_t)0x3377, (q15_t)0x3ec3, + (q15_t)0x3384, (q15_t)0x3ec5, (q15_t)0x3390, (q15_t)0x3ec8, (q15_t)0x339c, + (q15_t)0x3eca, (q15_t)0x33a9, (q15_t)0x3ecc, (q15_t)0x33b5, (q15_t)0x3ecf, + (q15_t)0x33c1, (q15_t)0x3ed1, (q15_t)0x33ce, (q15_t)0x3ed4, (q15_t)0x33da, + (q15_t)0x3ed6, (q15_t)0x33e6, (q15_t)0x3ed8, (q15_t)0x33f3, (q15_t)0x3edb, + (q15_t)0x33ff, (q15_t)0x3edd, (q15_t)0x340b, (q15_t)0x3ee0, (q15_t)0x3418, + (q15_t)0x3ee2, (q15_t)0x3424, (q15_t)0x3ee4, (q15_t)0x3430, (q15_t)0x3ee7, + (q15_t)0x343d, (q15_t)0x3ee9, (q15_t)0x3449, (q15_t)0x3eeb, (q15_t)0x3455, + (q15_t)0x3eed, (q15_t)0x3462, (q15_t)0x3ef0, (q15_t)0x346e, (q15_t)0x3ef2, + (q15_t)0x347b, (q15_t)0x3ef4, (q15_t)0x3487, (q15_t)0x3ef7, (q15_t)0x3493, + (q15_t)0x3ef9, (q15_t)0x34a0, (q15_t)0x3efb, (q15_t)0x34ac, (q15_t)0x3efd, + (q15_t)0x34b8, (q15_t)0x3f00, (q15_t)0x34c5, (q15_t)0x3f02, (q15_t)0x34d1, + (q15_t)0x3f04, (q15_t)0x34dd, (q15_t)0x3f06, (q15_t)0x34ea, (q15_t)0x3f08, + (q15_t)0x34f6, (q15_t)0x3f0a, (q15_t)0x3503, (q15_t)0x3f0d, (q15_t)0x350f, + (q15_t)0x3f0f, (q15_t)0x351b, (q15_t)0x3f11, (q15_t)0x3528, (q15_t)0x3f13, + (q15_t)0x3534, (q15_t)0x3f15, (q15_t)0x3540, (q15_t)0x3f17, (q15_t)0x354d, + (q15_t)0x3f19, (q15_t)0x3559, (q15_t)0x3f1c, (q15_t)0x3566, (q15_t)0x3f1e, + (q15_t)0x3572, (q15_t)0x3f20, (q15_t)0x357e, (q15_t)0x3f22, (q15_t)0x358b, + (q15_t)0x3f24, (q15_t)0x3597, (q15_t)0x3f26, (q15_t)0x35a4, (q15_t)0x3f28, + (q15_t)0x35b0, (q15_t)0x3f2a, (q15_t)0x35bc, (q15_t)0x3f2c, (q15_t)0x35c9, + (q15_t)0x3f2e, (q15_t)0x35d5, (q15_t)0x3f30, (q15_t)0x35e2, (q15_t)0x3f32, + (q15_t)0x35ee, (q15_t)0x3f34, (q15_t)0x35fa, (q15_t)0x3f36, (q15_t)0x3607, + (q15_t)0x3f38, (q15_t)0x3613, (q15_t)0x3f3a, (q15_t)0x3620, (q15_t)0x3f3c, + (q15_t)0x362c, (q15_t)0x3f3e, (q15_t)0x3639, (q15_t)0x3f40, (q15_t)0x3645, + (q15_t)0x3f42, (q15_t)0x3651, (q15_t)0x3f43, (q15_t)0x365e, (q15_t)0x3f45, + (q15_t)0x366a, (q15_t)0x3f47, (q15_t)0x3677, (q15_t)0x3f49, (q15_t)0x3683, + (q15_t)0x3f4b, (q15_t)0x3690, (q15_t)0x3f4d, (q15_t)0x369c, (q15_t)0x3f4f, + (q15_t)0x36a8, (q15_t)0x3f51, (q15_t)0x36b5, (q15_t)0x3f52, (q15_t)0x36c1, + (q15_t)0x3f54, (q15_t)0x36ce, (q15_t)0x3f56, (q15_t)0x36da, (q15_t)0x3f58, + (q15_t)0x36e7, (q15_t)0x3f5a, (q15_t)0x36f3, (q15_t)0x3f5b, (q15_t)0x36ff, + (q15_t)0x3f5d, (q15_t)0x370c, (q15_t)0x3f5f, (q15_t)0x3718, (q15_t)0x3f61, + (q15_t)0x3725, (q15_t)0x3f62, (q15_t)0x3731, (q15_t)0x3f64, (q15_t)0x373e, + (q15_t)0x3f66, (q15_t)0x374a, (q15_t)0x3f68, (q15_t)0x3757, (q15_t)0x3f69, + (q15_t)0x3763, (q15_t)0x3f6b, (q15_t)0x376f, (q15_t)0x3f6d, (q15_t)0x377c, + (q15_t)0x3f6e, (q15_t)0x3788, (q15_t)0x3f70, (q15_t)0x3795, (q15_t)0x3f72, + (q15_t)0x37a1, (q15_t)0x3f73, (q15_t)0x37ae, (q15_t)0x3f75, (q15_t)0x37ba, + (q15_t)0x3f77, (q15_t)0x37c7, (q15_t)0x3f78, (q15_t)0x37d3, (q15_t)0x3f7a, + (q15_t)0x37e0, (q15_t)0x3f7b, (q15_t)0x37ec, (q15_t)0x3f7d, (q15_t)0x37f9, + (q15_t)0x3f7f, (q15_t)0x3805, (q15_t)0x3f80, (q15_t)0x3811, (q15_t)0x3f82, + (q15_t)0x381e, (q15_t)0x3f83, (q15_t)0x382a, (q15_t)0x3f85, (q15_t)0x3837, + (q15_t)0x3f86, (q15_t)0x3843, (q15_t)0x3f88, (q15_t)0x3850, (q15_t)0x3f89, + (q15_t)0x385c, (q15_t)0x3f8b, (q15_t)0x3869, (q15_t)0x3f8c, (q15_t)0x3875, + (q15_t)0x3f8e, (q15_t)0x3882, (q15_t)0x3f8f, (q15_t)0x388e, (q15_t)0x3f91, + (q15_t)0x389b, (q15_t)0x3f92, (q15_t)0x38a7, (q15_t)0x3f94, (q15_t)0x38b4, + (q15_t)0x3f95, (q15_t)0x38c0, (q15_t)0x3f97, (q15_t)0x38cd, (q15_t)0x3f98, + (q15_t)0x38d9, (q15_t)0x3f99, (q15_t)0x38e6, (q15_t)0x3f9b, (q15_t)0x38f2, + (q15_t)0x3f9c, (q15_t)0x38ff, (q15_t)0x3f9e, (q15_t)0x390b, (q15_t)0x3f9f, + (q15_t)0x3918, (q15_t)0x3fa0, (q15_t)0x3924, (q15_t)0x3fa2, (q15_t)0x3931, + (q15_t)0x3fa3, (q15_t)0x393d, (q15_t)0x3fa4, (q15_t)0x394a, (q15_t)0x3fa6, + (q15_t)0x3956, (q15_t)0x3fa7, (q15_t)0x3963, (q15_t)0x3fa8, (q15_t)0x396f, + (q15_t)0x3faa, (q15_t)0x397c, (q15_t)0x3fab, (q15_t)0x3988, (q15_t)0x3fac, + (q15_t)0x3995, (q15_t)0x3fad, (q15_t)0x39a1, (q15_t)0x3faf, (q15_t)0x39ae, + (q15_t)0x3fb0, (q15_t)0x39ba, (q15_t)0x3fb1, (q15_t)0x39c7, (q15_t)0x3fb2, + (q15_t)0x39d3, (q15_t)0x3fb4, (q15_t)0x39e0, (q15_t)0x3fb5, (q15_t)0x39ec, + (q15_t)0x3fb6, (q15_t)0x39f9, (q15_t)0x3fb7, (q15_t)0x3a05, (q15_t)0x3fb8, + (q15_t)0x3a12, (q15_t)0x3fb9, (q15_t)0x3a1e, (q15_t)0x3fbb, (q15_t)0x3a2b, + (q15_t)0x3fbc, (q15_t)0x3a37, (q15_t)0x3fbd, (q15_t)0x3a44, (q15_t)0x3fbe, + (q15_t)0x3a50, (q15_t)0x3fbf, (q15_t)0x3a5d, (q15_t)0x3fc0, (q15_t)0x3a69, + (q15_t)0x3fc1, (q15_t)0x3a76, (q15_t)0x3fc3, (q15_t)0x3a82, (q15_t)0x3fc4, + (q15_t)0x3a8f, (q15_t)0x3fc5, (q15_t)0x3a9b, (q15_t)0x3fc6, (q15_t)0x3aa8, + (q15_t)0x3fc7, (q15_t)0x3ab4, (q15_t)0x3fc8, (q15_t)0x3ac1, (q15_t)0x3fc9, + (q15_t)0x3acd, (q15_t)0x3fca, (q15_t)0x3ada, (q15_t)0x3fcb, (q15_t)0x3ae6, + (q15_t)0x3fcc, (q15_t)0x3af3, (q15_t)0x3fcd, (q15_t)0x3b00, (q15_t)0x3fce, + (q15_t)0x3b0c, (q15_t)0x3fcf, (q15_t)0x3b19, (q15_t)0x3fd0, (q15_t)0x3b25, + (q15_t)0x3fd1, (q15_t)0x3b32, (q15_t)0x3fd2, (q15_t)0x3b3e, (q15_t)0x3fd3, + (q15_t)0x3b4b, (q15_t)0x3fd4, (q15_t)0x3b57, (q15_t)0x3fd5, (q15_t)0x3b64, + (q15_t)0x3fd5, (q15_t)0x3b70, (q15_t)0x3fd6, (q15_t)0x3b7d, (q15_t)0x3fd7, + (q15_t)0x3b89, (q15_t)0x3fd8, (q15_t)0x3b96, (q15_t)0x3fd9, (q15_t)0x3ba2, + (q15_t)0x3fda, (q15_t)0x3baf, (q15_t)0x3fdb, (q15_t)0x3bbc, (q15_t)0x3fdc, + (q15_t)0x3bc8, (q15_t)0x3fdc, (q15_t)0x3bd5, (q15_t)0x3fdd, (q15_t)0x3be1, + (q15_t)0x3fde, (q15_t)0x3bee, (q15_t)0x3fdf, (q15_t)0x3bfa, (q15_t)0x3fe0, + (q15_t)0x3c07, (q15_t)0x3fe0, (q15_t)0x3c13, (q15_t)0x3fe1, (q15_t)0x3c20, + (q15_t)0x3fe2, (q15_t)0x3c2c, (q15_t)0x3fe3, (q15_t)0x3c39, (q15_t)0x3fe3, + (q15_t)0x3c45, (q15_t)0x3fe4, (q15_t)0x3c52, (q15_t)0x3fe5, (q15_t)0x3c5f, + (q15_t)0x3fe6, (q15_t)0x3c6b, (q15_t)0x3fe6, (q15_t)0x3c78, (q15_t)0x3fe7, + (q15_t)0x3c84, (q15_t)0x3fe8, (q15_t)0x3c91, (q15_t)0x3fe8, (q15_t)0x3c9d, + (q15_t)0x3fe9, (q15_t)0x3caa, (q15_t)0x3fea, (q15_t)0x3cb6, (q15_t)0x3fea, + (q15_t)0x3cc3, (q15_t)0x3feb, (q15_t)0x3cd0, (q15_t)0x3fec, (q15_t)0x3cdc, + (q15_t)0x3fec, (q15_t)0x3ce9, (q15_t)0x3fed, (q15_t)0x3cf5, (q15_t)0x3fed, + (q15_t)0x3d02, (q15_t)0x3fee, (q15_t)0x3d0e, (q15_t)0x3fef, (q15_t)0x3d1b, + (q15_t)0x3fef, (q15_t)0x3d27, (q15_t)0x3ff0, (q15_t)0x3d34, (q15_t)0x3ff0, + (q15_t)0x3d40, (q15_t)0x3ff1, (q15_t)0x3d4d, (q15_t)0x3ff1, (q15_t)0x3d5a, + (q15_t)0x3ff2, (q15_t)0x3d66, (q15_t)0x3ff2, (q15_t)0x3d73, (q15_t)0x3ff3, + (q15_t)0x3d7f, (q15_t)0x3ff3, (q15_t)0x3d8c, (q15_t)0x3ff4, (q15_t)0x3d98, + (q15_t)0x3ff4, (q15_t)0x3da5, (q15_t)0x3ff5, (q15_t)0x3db2, (q15_t)0x3ff5, + (q15_t)0x3dbe, (q15_t)0x3ff6, (q15_t)0x3dcb, (q15_t)0x3ff6, (q15_t)0x3dd7, + (q15_t)0x3ff7, (q15_t)0x3de4, (q15_t)0x3ff7, (q15_t)0x3df0, (q15_t)0x3ff7, + (q15_t)0x3dfd, (q15_t)0x3ff8, (q15_t)0x3e09, (q15_t)0x3ff8, (q15_t)0x3e16, + (q15_t)0x3ff9, (q15_t)0x3e23, (q15_t)0x3ff9, (q15_t)0x3e2f, (q15_t)0x3ff9, + (q15_t)0x3e3c, (q15_t)0x3ffa, (q15_t)0x3e48, (q15_t)0x3ffa, (q15_t)0x3e55, + (q15_t)0x3ffa, (q15_t)0x3e61, (q15_t)0x3ffb, (q15_t)0x3e6e, (q15_t)0x3ffb, + (q15_t)0x3e7a, (q15_t)0x3ffb, (q15_t)0x3e87, (q15_t)0x3ffc, (q15_t)0x3e94, + (q15_t)0x3ffc, (q15_t)0x3ea0, (q15_t)0x3ffc, (q15_t)0x3ead, (q15_t)0x3ffc, + (q15_t)0x3eb9, (q15_t)0x3ffd, (q15_t)0x3ec6, (q15_t)0x3ffd, (q15_t)0x3ed2, + (q15_t)0x3ffd, (q15_t)0x3edf, (q15_t)0x3ffd, (q15_t)0x3eec, (q15_t)0x3ffe, + (q15_t)0x3ef8, (q15_t)0x3ffe, (q15_t)0x3f05, (q15_t)0x3ffe, (q15_t)0x3f11, + (q15_t)0x3ffe, (q15_t)0x3f1e, (q15_t)0x3ffe, (q15_t)0x3f2a, (q15_t)0x3fff, + (q15_t)0x3f37, (q15_t)0x3fff, (q15_t)0x3f44, (q15_t)0x3fff, (q15_t)0x3f50, + (q15_t)0x3fff, (q15_t)0x3f5d, (q15_t)0x3fff, (q15_t)0x3f69, (q15_t)0x3fff, + (q15_t)0x3f76, (q15_t)0x3fff, (q15_t)0x3f82, (q15_t)0x4000, (q15_t)0x3f8f, + (q15_t)0x4000, (q15_t)0x3f9b, (q15_t)0x4000, (q15_t)0x3fa8, (q15_t)0x4000, + (q15_t)0x3fb5, (q15_t)0x4000, (q15_t)0x3fc1, (q15_t)0x4000, (q15_t)0x3fce, + (q15_t)0x4000, (q15_t)0x3fda, (q15_t)0x4000, (q15_t)0x3fe7, (q15_t)0x4000, + (q15_t)0x3ff3, (q15_t)0x4000, }; /** @@ -1087,1038 +1703,1654 @@ const q15_t __ALIGNED(4) realCoefAQ15[8192] = { n = 4096
for (i = 0; i < n; i++)
   {
-     pBTable[2 * i]     = 0.5 * (1.0 + sin (2 * PI / (double) (2 * n) * (double) i));
-     pBTable[2 * i + 1] = 0.5 * (1.0 * cos (2 * PI / (double) (2 * n) * (double) i));
+     pBTable[2 * i]     = 0.5 * (1.0 + sin (2 * PI / (double) (2 * n) * (double)
+  i)); pBTable[2 * i + 1] = 0.5 * (1.0 * cos (2 * PI / (double) (2 * n) *
+  (double) i));
   }
@par Convert to fixed point Q15 format round(pBTable[i] * pow(2, 15)) */ const q15_t __ALIGNED(4) realCoefBQ15[8192] = { - (q15_t)0x4000, (q15_t)0x4000, (q15_t)0x400d, (q15_t)0x4000, (q15_t)0x4019, (q15_t)0x4000, (q15_t)0x4026, (q15_t)0x4000, - (q15_t)0x4032, (q15_t)0x4000, (q15_t)0x403f, (q15_t)0x4000, (q15_t)0x404b, (q15_t)0x4000, (q15_t)0x4058, (q15_t)0x4000, - (q15_t)0x4065, (q15_t)0x4000, (q15_t)0x4071, (q15_t)0x4000, (q15_t)0x407e, (q15_t)0x4000, (q15_t)0x408a, (q15_t)0x3fff, - (q15_t)0x4097, (q15_t)0x3fff, (q15_t)0x40a3, (q15_t)0x3fff, (q15_t)0x40b0, (q15_t)0x3fff, (q15_t)0x40bc, (q15_t)0x3fff, - (q15_t)0x40c9, (q15_t)0x3fff, (q15_t)0x40d6, (q15_t)0x3fff, (q15_t)0x40e2, (q15_t)0x3ffe, (q15_t)0x40ef, (q15_t)0x3ffe, - (q15_t)0x40fb, (q15_t)0x3ffe, (q15_t)0x4108, (q15_t)0x3ffe, (q15_t)0x4114, (q15_t)0x3ffe, (q15_t)0x4121, (q15_t)0x3ffd, - (q15_t)0x412e, (q15_t)0x3ffd, (q15_t)0x413a, (q15_t)0x3ffd, (q15_t)0x4147, (q15_t)0x3ffd, (q15_t)0x4153, (q15_t)0x3ffc, - (q15_t)0x4160, (q15_t)0x3ffc, (q15_t)0x416c, (q15_t)0x3ffc, (q15_t)0x4179, (q15_t)0x3ffc, (q15_t)0x4186, (q15_t)0x3ffb, - (q15_t)0x4192, (q15_t)0x3ffb, (q15_t)0x419f, (q15_t)0x3ffb, (q15_t)0x41ab, (q15_t)0x3ffa, (q15_t)0x41b8, (q15_t)0x3ffa, - (q15_t)0x41c4, (q15_t)0x3ffa, (q15_t)0x41d1, (q15_t)0x3ff9, (q15_t)0x41dd, (q15_t)0x3ff9, (q15_t)0x41ea, (q15_t)0x3ff9, - (q15_t)0x41f7, (q15_t)0x3ff8, (q15_t)0x4203, (q15_t)0x3ff8, (q15_t)0x4210, (q15_t)0x3ff7, (q15_t)0x421c, (q15_t)0x3ff7, - (q15_t)0x4229, (q15_t)0x3ff7, (q15_t)0x4235, (q15_t)0x3ff6, (q15_t)0x4242, (q15_t)0x3ff6, (q15_t)0x424e, (q15_t)0x3ff5, - (q15_t)0x425b, (q15_t)0x3ff5, (q15_t)0x4268, (q15_t)0x3ff4, (q15_t)0x4274, (q15_t)0x3ff4, (q15_t)0x4281, (q15_t)0x3ff3, - (q15_t)0x428d, (q15_t)0x3ff3, (q15_t)0x429a, (q15_t)0x3ff2, (q15_t)0x42a6, (q15_t)0x3ff2, (q15_t)0x42b3, (q15_t)0x3ff1, - (q15_t)0x42c0, (q15_t)0x3ff1, (q15_t)0x42cc, (q15_t)0x3ff0, (q15_t)0x42d9, (q15_t)0x3ff0, (q15_t)0x42e5, (q15_t)0x3fef, - (q15_t)0x42f2, (q15_t)0x3fef, (q15_t)0x42fe, (q15_t)0x3fee, (q15_t)0x430b, (q15_t)0x3fed, (q15_t)0x4317, (q15_t)0x3fed, - (q15_t)0x4324, (q15_t)0x3fec, (q15_t)0x4330, (q15_t)0x3fec, (q15_t)0x433d, (q15_t)0x3feb, (q15_t)0x434a, (q15_t)0x3fea, - (q15_t)0x4356, (q15_t)0x3fea, (q15_t)0x4363, (q15_t)0x3fe9, (q15_t)0x436f, (q15_t)0x3fe8, (q15_t)0x437c, (q15_t)0x3fe8, - (q15_t)0x4388, (q15_t)0x3fe7, (q15_t)0x4395, (q15_t)0x3fe6, (q15_t)0x43a1, (q15_t)0x3fe6, (q15_t)0x43ae, (q15_t)0x3fe5, - (q15_t)0x43bb, (q15_t)0x3fe4, (q15_t)0x43c7, (q15_t)0x3fe3, (q15_t)0x43d4, (q15_t)0x3fe3, (q15_t)0x43e0, (q15_t)0x3fe2, - (q15_t)0x43ed, (q15_t)0x3fe1, (q15_t)0x43f9, (q15_t)0x3fe0, (q15_t)0x4406, (q15_t)0x3fe0, (q15_t)0x4412, (q15_t)0x3fdf, - (q15_t)0x441f, (q15_t)0x3fde, (q15_t)0x442b, (q15_t)0x3fdd, (q15_t)0x4438, (q15_t)0x3fdc, (q15_t)0x4444, (q15_t)0x3fdc, - (q15_t)0x4451, (q15_t)0x3fdb, (q15_t)0x445e, (q15_t)0x3fda, (q15_t)0x446a, (q15_t)0x3fd9, (q15_t)0x4477, (q15_t)0x3fd8, - (q15_t)0x4483, (q15_t)0x3fd7, (q15_t)0x4490, (q15_t)0x3fd6, (q15_t)0x449c, (q15_t)0x3fd5, (q15_t)0x44a9, (q15_t)0x3fd5, - (q15_t)0x44b5, (q15_t)0x3fd4, (q15_t)0x44c2, (q15_t)0x3fd3, (q15_t)0x44ce, (q15_t)0x3fd2, (q15_t)0x44db, (q15_t)0x3fd1, - (q15_t)0x44e7, (q15_t)0x3fd0, (q15_t)0x44f4, (q15_t)0x3fcf, (q15_t)0x4500, (q15_t)0x3fce, (q15_t)0x450d, (q15_t)0x3fcd, - (q15_t)0x451a, (q15_t)0x3fcc, (q15_t)0x4526, (q15_t)0x3fcb, (q15_t)0x4533, (q15_t)0x3fca, (q15_t)0x453f, (q15_t)0x3fc9, - (q15_t)0x454c, (q15_t)0x3fc8, (q15_t)0x4558, (q15_t)0x3fc7, (q15_t)0x4565, (q15_t)0x3fc6, (q15_t)0x4571, (q15_t)0x3fc5, - (q15_t)0x457e, (q15_t)0x3fc4, (q15_t)0x458a, (q15_t)0x3fc3, (q15_t)0x4597, (q15_t)0x3fc1, (q15_t)0x45a3, (q15_t)0x3fc0, - (q15_t)0x45b0, (q15_t)0x3fbf, (q15_t)0x45bc, (q15_t)0x3fbe, (q15_t)0x45c9, (q15_t)0x3fbd, (q15_t)0x45d5, (q15_t)0x3fbc, - (q15_t)0x45e2, (q15_t)0x3fbb, (q15_t)0x45ee, (q15_t)0x3fb9, (q15_t)0x45fb, (q15_t)0x3fb8, (q15_t)0x4607, (q15_t)0x3fb7, - (q15_t)0x4614, (q15_t)0x3fb6, (q15_t)0x4620, (q15_t)0x3fb5, (q15_t)0x462d, (q15_t)0x3fb4, (q15_t)0x4639, (q15_t)0x3fb2, - (q15_t)0x4646, (q15_t)0x3fb1, (q15_t)0x4652, (q15_t)0x3fb0, (q15_t)0x465f, (q15_t)0x3faf, (q15_t)0x466b, (q15_t)0x3fad, - (q15_t)0x4678, (q15_t)0x3fac, (q15_t)0x4684, (q15_t)0x3fab, (q15_t)0x4691, (q15_t)0x3faa, (q15_t)0x469d, (q15_t)0x3fa8, - (q15_t)0x46aa, (q15_t)0x3fa7, (q15_t)0x46b6, (q15_t)0x3fa6, (q15_t)0x46c3, (q15_t)0x3fa4, (q15_t)0x46cf, (q15_t)0x3fa3, - (q15_t)0x46dc, (q15_t)0x3fa2, (q15_t)0x46e8, (q15_t)0x3fa0, (q15_t)0x46f5, (q15_t)0x3f9f, (q15_t)0x4701, (q15_t)0x3f9e, - (q15_t)0x470e, (q15_t)0x3f9c, (q15_t)0x471a, (q15_t)0x3f9b, (q15_t)0x4727, (q15_t)0x3f99, (q15_t)0x4733, (q15_t)0x3f98, - (q15_t)0x4740, (q15_t)0x3f97, (q15_t)0x474c, (q15_t)0x3f95, (q15_t)0x4759, (q15_t)0x3f94, (q15_t)0x4765, (q15_t)0x3f92, - (q15_t)0x4772, (q15_t)0x3f91, (q15_t)0x477e, (q15_t)0x3f8f, (q15_t)0x478b, (q15_t)0x3f8e, (q15_t)0x4797, (q15_t)0x3f8c, - (q15_t)0x47a4, (q15_t)0x3f8b, (q15_t)0x47b0, (q15_t)0x3f89, (q15_t)0x47bd, (q15_t)0x3f88, (q15_t)0x47c9, (q15_t)0x3f86, - (q15_t)0x47d6, (q15_t)0x3f85, (q15_t)0x47e2, (q15_t)0x3f83, (q15_t)0x47ef, (q15_t)0x3f82, (q15_t)0x47fb, (q15_t)0x3f80, - (q15_t)0x4807, (q15_t)0x3f7f, (q15_t)0x4814, (q15_t)0x3f7d, (q15_t)0x4820, (q15_t)0x3f7b, (q15_t)0x482d, (q15_t)0x3f7a, - (q15_t)0x4839, (q15_t)0x3f78, (q15_t)0x4846, (q15_t)0x3f77, (q15_t)0x4852, (q15_t)0x3f75, (q15_t)0x485f, (q15_t)0x3f73, - (q15_t)0x486b, (q15_t)0x3f72, (q15_t)0x4878, (q15_t)0x3f70, (q15_t)0x4884, (q15_t)0x3f6e, (q15_t)0x4891, (q15_t)0x3f6d, - (q15_t)0x489d, (q15_t)0x3f6b, (q15_t)0x48a9, (q15_t)0x3f69, (q15_t)0x48b6, (q15_t)0x3f68, (q15_t)0x48c2, (q15_t)0x3f66, - (q15_t)0x48cf, (q15_t)0x3f64, (q15_t)0x48db, (q15_t)0x3f62, (q15_t)0x48e8, (q15_t)0x3f61, (q15_t)0x48f4, (q15_t)0x3f5f, - (q15_t)0x4901, (q15_t)0x3f5d, (q15_t)0x490d, (q15_t)0x3f5b, (q15_t)0x4919, (q15_t)0x3f5a, (q15_t)0x4926, (q15_t)0x3f58, - (q15_t)0x4932, (q15_t)0x3f56, (q15_t)0x493f, (q15_t)0x3f54, (q15_t)0x494b, (q15_t)0x3f52, (q15_t)0x4958, (q15_t)0x3f51, - (q15_t)0x4964, (q15_t)0x3f4f, (q15_t)0x4970, (q15_t)0x3f4d, (q15_t)0x497d, (q15_t)0x3f4b, (q15_t)0x4989, (q15_t)0x3f49, - (q15_t)0x4996, (q15_t)0x3f47, (q15_t)0x49a2, (q15_t)0x3f45, (q15_t)0x49af, (q15_t)0x3f43, (q15_t)0x49bb, (q15_t)0x3f42, - (q15_t)0x49c7, (q15_t)0x3f40, (q15_t)0x49d4, (q15_t)0x3f3e, (q15_t)0x49e0, (q15_t)0x3f3c, (q15_t)0x49ed, (q15_t)0x3f3a, - (q15_t)0x49f9, (q15_t)0x3f38, (q15_t)0x4a06, (q15_t)0x3f36, (q15_t)0x4a12, (q15_t)0x3f34, (q15_t)0x4a1e, (q15_t)0x3f32, - (q15_t)0x4a2b, (q15_t)0x3f30, (q15_t)0x4a37, (q15_t)0x3f2e, (q15_t)0x4a44, (q15_t)0x3f2c, (q15_t)0x4a50, (q15_t)0x3f2a, - (q15_t)0x4a5c, (q15_t)0x3f28, (q15_t)0x4a69, (q15_t)0x3f26, (q15_t)0x4a75, (q15_t)0x3f24, (q15_t)0x4a82, (q15_t)0x3f22, - (q15_t)0x4a8e, (q15_t)0x3f20, (q15_t)0x4a9a, (q15_t)0x3f1e, (q15_t)0x4aa7, (q15_t)0x3f1c, (q15_t)0x4ab3, (q15_t)0x3f19, - (q15_t)0x4ac0, (q15_t)0x3f17, (q15_t)0x4acc, (q15_t)0x3f15, (q15_t)0x4ad8, (q15_t)0x3f13, (q15_t)0x4ae5, (q15_t)0x3f11, - (q15_t)0x4af1, (q15_t)0x3f0f, (q15_t)0x4afd, (q15_t)0x3f0d, (q15_t)0x4b0a, (q15_t)0x3f0a, (q15_t)0x4b16, (q15_t)0x3f08, - (q15_t)0x4b23, (q15_t)0x3f06, (q15_t)0x4b2f, (q15_t)0x3f04, (q15_t)0x4b3b, (q15_t)0x3f02, (q15_t)0x4b48, (q15_t)0x3f00, - (q15_t)0x4b54, (q15_t)0x3efd, (q15_t)0x4b60, (q15_t)0x3efb, (q15_t)0x4b6d, (q15_t)0x3ef9, (q15_t)0x4b79, (q15_t)0x3ef7, - (q15_t)0x4b85, (q15_t)0x3ef4, (q15_t)0x4b92, (q15_t)0x3ef2, (q15_t)0x4b9e, (q15_t)0x3ef0, (q15_t)0x4bab, (q15_t)0x3eed, - (q15_t)0x4bb7, (q15_t)0x3eeb, (q15_t)0x4bc3, (q15_t)0x3ee9, (q15_t)0x4bd0, (q15_t)0x3ee7, (q15_t)0x4bdc, (q15_t)0x3ee4, - (q15_t)0x4be8, (q15_t)0x3ee2, (q15_t)0x4bf5, (q15_t)0x3ee0, (q15_t)0x4c01, (q15_t)0x3edd, (q15_t)0x4c0d, (q15_t)0x3edb, - (q15_t)0x4c1a, (q15_t)0x3ed8, (q15_t)0x4c26, (q15_t)0x3ed6, (q15_t)0x4c32, (q15_t)0x3ed4, (q15_t)0x4c3f, (q15_t)0x3ed1, - (q15_t)0x4c4b, (q15_t)0x3ecf, (q15_t)0x4c57, (q15_t)0x3ecc, (q15_t)0x4c64, (q15_t)0x3eca, (q15_t)0x4c70, (q15_t)0x3ec8, - (q15_t)0x4c7c, (q15_t)0x3ec5, (q15_t)0x4c89, (q15_t)0x3ec3, (q15_t)0x4c95, (q15_t)0x3ec0, (q15_t)0x4ca1, (q15_t)0x3ebe, - (q15_t)0x4cae, (q15_t)0x3ebb, (q15_t)0x4cba, (q15_t)0x3eb9, (q15_t)0x4cc6, (q15_t)0x3eb6, (q15_t)0x4cd3, (q15_t)0x3eb4, - (q15_t)0x4cdf, (q15_t)0x3eb1, (q15_t)0x4ceb, (q15_t)0x3eaf, (q15_t)0x4cf8, (q15_t)0x3eac, (q15_t)0x4d04, (q15_t)0x3eaa, - (q15_t)0x4d10, (q15_t)0x3ea7, (q15_t)0x4d1c, (q15_t)0x3ea5, (q15_t)0x4d29, (q15_t)0x3ea2, (q15_t)0x4d35, (q15_t)0x3e9f, - (q15_t)0x4d41, (q15_t)0x3e9d, (q15_t)0x4d4e, (q15_t)0x3e9a, (q15_t)0x4d5a, (q15_t)0x3e98, (q15_t)0x4d66, (q15_t)0x3e95, - (q15_t)0x4d72, (q15_t)0x3e92, (q15_t)0x4d7f, (q15_t)0x3e90, (q15_t)0x4d8b, (q15_t)0x3e8d, (q15_t)0x4d97, (q15_t)0x3e8a, - (q15_t)0x4da4, (q15_t)0x3e88, (q15_t)0x4db0, (q15_t)0x3e85, (q15_t)0x4dbc, (q15_t)0x3e82, (q15_t)0x4dc8, (q15_t)0x3e80, - (q15_t)0x4dd5, (q15_t)0x3e7d, (q15_t)0x4de1, (q15_t)0x3e7a, (q15_t)0x4ded, (q15_t)0x3e77, (q15_t)0x4df9, (q15_t)0x3e75, - (q15_t)0x4e06, (q15_t)0x3e72, (q15_t)0x4e12, (q15_t)0x3e6f, (q15_t)0x4e1e, (q15_t)0x3e6c, (q15_t)0x4e2b, (q15_t)0x3e6a, - (q15_t)0x4e37, (q15_t)0x3e67, (q15_t)0x4e43, (q15_t)0x3e64, (q15_t)0x4e4f, (q15_t)0x3e61, (q15_t)0x4e5c, (q15_t)0x3e5e, - (q15_t)0x4e68, (q15_t)0x3e5c, (q15_t)0x4e74, (q15_t)0x3e59, (q15_t)0x4e80, (q15_t)0x3e56, (q15_t)0x4e8c, (q15_t)0x3e53, - (q15_t)0x4e99, (q15_t)0x3e50, (q15_t)0x4ea5, (q15_t)0x3e4d, (q15_t)0x4eb1, (q15_t)0x3e4a, (q15_t)0x4ebd, (q15_t)0x3e48, - (q15_t)0x4eca, (q15_t)0x3e45, (q15_t)0x4ed6, (q15_t)0x3e42, (q15_t)0x4ee2, (q15_t)0x3e3f, (q15_t)0x4eee, (q15_t)0x3e3c, - (q15_t)0x4efb, (q15_t)0x3e39, (q15_t)0x4f07, (q15_t)0x3e36, (q15_t)0x4f13, (q15_t)0x3e33, (q15_t)0x4f1f, (q15_t)0x3e30, - (q15_t)0x4f2b, (q15_t)0x3e2d, (q15_t)0x4f38, (q15_t)0x3e2a, (q15_t)0x4f44, (q15_t)0x3e27, (q15_t)0x4f50, (q15_t)0x3e24, - (q15_t)0x4f5c, (q15_t)0x3e21, (q15_t)0x4f68, (q15_t)0x3e1e, (q15_t)0x4f75, (q15_t)0x3e1b, (q15_t)0x4f81, (q15_t)0x3e18, - (q15_t)0x4f8d, (q15_t)0x3e15, (q15_t)0x4f99, (q15_t)0x3e12, (q15_t)0x4fa5, (q15_t)0x3e0f, (q15_t)0x4fb2, (q15_t)0x3e0c, - (q15_t)0x4fbe, (q15_t)0x3e09, (q15_t)0x4fca, (q15_t)0x3e06, (q15_t)0x4fd6, (q15_t)0x3e03, (q15_t)0x4fe2, (q15_t)0x3dff, - (q15_t)0x4fee, (q15_t)0x3dfc, (q15_t)0x4ffb, (q15_t)0x3df9, (q15_t)0x5007, (q15_t)0x3df6, (q15_t)0x5013, (q15_t)0x3df3, - (q15_t)0x501f, (q15_t)0x3df0, (q15_t)0x502b, (q15_t)0x3ded, (q15_t)0x5037, (q15_t)0x3de9, (q15_t)0x5044, (q15_t)0x3de6, - (q15_t)0x5050, (q15_t)0x3de3, (q15_t)0x505c, (q15_t)0x3de0, (q15_t)0x5068, (q15_t)0x3ddd, (q15_t)0x5074, (q15_t)0x3dd9, - (q15_t)0x5080, (q15_t)0x3dd6, (q15_t)0x508c, (q15_t)0x3dd3, (q15_t)0x5099, (q15_t)0x3dd0, (q15_t)0x50a5, (q15_t)0x3dcc, - (q15_t)0x50b1, (q15_t)0x3dc9, (q15_t)0x50bd, (q15_t)0x3dc6, (q15_t)0x50c9, (q15_t)0x3dc2, (q15_t)0x50d5, (q15_t)0x3dbf, - (q15_t)0x50e1, (q15_t)0x3dbc, (q15_t)0x50ed, (q15_t)0x3db9, (q15_t)0x50fa, (q15_t)0x3db5, (q15_t)0x5106, (q15_t)0x3db2, - (q15_t)0x5112, (q15_t)0x3daf, (q15_t)0x511e, (q15_t)0x3dab, (q15_t)0x512a, (q15_t)0x3da8, (q15_t)0x5136, (q15_t)0x3da4, - (q15_t)0x5142, (q15_t)0x3da1, (q15_t)0x514e, (q15_t)0x3d9e, (q15_t)0x515a, (q15_t)0x3d9a, (q15_t)0x5167, (q15_t)0x3d97, - (q15_t)0x5173, (q15_t)0x3d93, (q15_t)0x517f, (q15_t)0x3d90, (q15_t)0x518b, (q15_t)0x3d8d, (q15_t)0x5197, (q15_t)0x3d89, - (q15_t)0x51a3, (q15_t)0x3d86, (q15_t)0x51af, (q15_t)0x3d82, (q15_t)0x51bb, (q15_t)0x3d7f, (q15_t)0x51c7, (q15_t)0x3d7b, - (q15_t)0x51d3, (q15_t)0x3d78, (q15_t)0x51df, (q15_t)0x3d74, (q15_t)0x51eb, (q15_t)0x3d71, (q15_t)0x51f7, (q15_t)0x3d6d, - (q15_t)0x5204, (q15_t)0x3d6a, (q15_t)0x5210, (q15_t)0x3d66, (q15_t)0x521c, (q15_t)0x3d63, (q15_t)0x5228, (q15_t)0x3d5f, - (q15_t)0x5234, (q15_t)0x3d5b, (q15_t)0x5240, (q15_t)0x3d58, (q15_t)0x524c, (q15_t)0x3d54, (q15_t)0x5258, (q15_t)0x3d51, - (q15_t)0x5264, (q15_t)0x3d4d, (q15_t)0x5270, (q15_t)0x3d49, (q15_t)0x527c, (q15_t)0x3d46, (q15_t)0x5288, (q15_t)0x3d42, - (q15_t)0x5294, (q15_t)0x3d3f, (q15_t)0x52a0, (q15_t)0x3d3b, (q15_t)0x52ac, (q15_t)0x3d37, (q15_t)0x52b8, (q15_t)0x3d34, - (q15_t)0x52c4, (q15_t)0x3d30, (q15_t)0x52d0, (q15_t)0x3d2c, (q15_t)0x52dc, (q15_t)0x3d28, (q15_t)0x52e8, (q15_t)0x3d25, - (q15_t)0x52f4, (q15_t)0x3d21, (q15_t)0x5300, (q15_t)0x3d1d, (q15_t)0x530c, (q15_t)0x3d1a, (q15_t)0x5318, (q15_t)0x3d16, - (q15_t)0x5324, (q15_t)0x3d12, (q15_t)0x5330, (q15_t)0x3d0e, (q15_t)0x533c, (q15_t)0x3d0b, (q15_t)0x5348, (q15_t)0x3d07, - (q15_t)0x5354, (q15_t)0x3d03, (q15_t)0x5360, (q15_t)0x3cff, (q15_t)0x536c, (q15_t)0x3cfb, (q15_t)0x5378, (q15_t)0x3cf8, - (q15_t)0x5384, (q15_t)0x3cf4, (q15_t)0x5390, (q15_t)0x3cf0, (q15_t)0x539c, (q15_t)0x3cec, (q15_t)0x53a8, (q15_t)0x3ce8, - (q15_t)0x53b4, (q15_t)0x3ce4, (q15_t)0x53c0, (q15_t)0x3ce0, (q15_t)0x53cc, (q15_t)0x3cdd, (q15_t)0x53d8, (q15_t)0x3cd9, - (q15_t)0x53e4, (q15_t)0x3cd5, (q15_t)0x53f0, (q15_t)0x3cd1, (q15_t)0x53fb, (q15_t)0x3ccd, (q15_t)0x5407, (q15_t)0x3cc9, - (q15_t)0x5413, (q15_t)0x3cc5, (q15_t)0x541f, (q15_t)0x3cc1, (q15_t)0x542b, (q15_t)0x3cbd, (q15_t)0x5437, (q15_t)0x3cb9, - (q15_t)0x5443, (q15_t)0x3cb5, (q15_t)0x544f, (q15_t)0x3cb1, (q15_t)0x545b, (q15_t)0x3cad, (q15_t)0x5467, (q15_t)0x3ca9, - (q15_t)0x5473, (q15_t)0x3ca5, (q15_t)0x547f, (q15_t)0x3ca1, (q15_t)0x548b, (q15_t)0x3c9d, (q15_t)0x5496, (q15_t)0x3c99, - (q15_t)0x54a2, (q15_t)0x3c95, (q15_t)0x54ae, (q15_t)0x3c91, (q15_t)0x54ba, (q15_t)0x3c8d, (q15_t)0x54c6, (q15_t)0x3c89, - (q15_t)0x54d2, (q15_t)0x3c85, (q15_t)0x54de, (q15_t)0x3c81, (q15_t)0x54ea, (q15_t)0x3c7d, (q15_t)0x54f6, (q15_t)0x3c79, - (q15_t)0x5501, (q15_t)0x3c74, (q15_t)0x550d, (q15_t)0x3c70, (q15_t)0x5519, (q15_t)0x3c6c, (q15_t)0x5525, (q15_t)0x3c68, - (q15_t)0x5531, (q15_t)0x3c64, (q15_t)0x553d, (q15_t)0x3c60, (q15_t)0x5549, (q15_t)0x3c5b, (q15_t)0x5554, (q15_t)0x3c57, - (q15_t)0x5560, (q15_t)0x3c53, (q15_t)0x556c, (q15_t)0x3c4f, (q15_t)0x5578, (q15_t)0x3c4b, (q15_t)0x5584, (q15_t)0x3c46, - (q15_t)0x5590, (q15_t)0x3c42, (q15_t)0x559b, (q15_t)0x3c3e, (q15_t)0x55a7, (q15_t)0x3c3a, (q15_t)0x55b3, (q15_t)0x3c36, - (q15_t)0x55bf, (q15_t)0x3c31, (q15_t)0x55cb, (q15_t)0x3c2d, (q15_t)0x55d7, (q15_t)0x3c29, (q15_t)0x55e2, (q15_t)0x3c24, - (q15_t)0x55ee, (q15_t)0x3c20, (q15_t)0x55fa, (q15_t)0x3c1c, (q15_t)0x5606, (q15_t)0x3c17, (q15_t)0x5612, (q15_t)0x3c13, - (q15_t)0x561d, (q15_t)0x3c0f, (q15_t)0x5629, (q15_t)0x3c0a, (q15_t)0x5635, (q15_t)0x3c06, (q15_t)0x5641, (q15_t)0x3c02, - (q15_t)0x564c, (q15_t)0x3bfd, (q15_t)0x5658, (q15_t)0x3bf9, (q15_t)0x5664, (q15_t)0x3bf5, (q15_t)0x5670, (q15_t)0x3bf0, - (q15_t)0x567c, (q15_t)0x3bec, (q15_t)0x5687, (q15_t)0x3be7, (q15_t)0x5693, (q15_t)0x3be3, (q15_t)0x569f, (q15_t)0x3bde, - (q15_t)0x56ab, (q15_t)0x3bda, (q15_t)0x56b6, (q15_t)0x3bd6, (q15_t)0x56c2, (q15_t)0x3bd1, (q15_t)0x56ce, (q15_t)0x3bcd, - (q15_t)0x56da, (q15_t)0x3bc8, (q15_t)0x56e5, (q15_t)0x3bc4, (q15_t)0x56f1, (q15_t)0x3bbf, (q15_t)0x56fd, (q15_t)0x3bbb, - (q15_t)0x5709, (q15_t)0x3bb6, (q15_t)0x5714, (q15_t)0x3bb2, (q15_t)0x5720, (q15_t)0x3bad, (q15_t)0x572c, (q15_t)0x3ba9, - (q15_t)0x5737, (q15_t)0x3ba4, (q15_t)0x5743, (q15_t)0x3b9f, (q15_t)0x574f, (q15_t)0x3b9b, (q15_t)0x575b, (q15_t)0x3b96, - (q15_t)0x5766, (q15_t)0x3b92, (q15_t)0x5772, (q15_t)0x3b8d, (q15_t)0x577e, (q15_t)0x3b88, (q15_t)0x5789, (q15_t)0x3b84, - (q15_t)0x5795, (q15_t)0x3b7f, (q15_t)0x57a1, (q15_t)0x3b7b, (q15_t)0x57ac, (q15_t)0x3b76, (q15_t)0x57b8, (q15_t)0x3b71, - (q15_t)0x57c4, (q15_t)0x3b6d, (q15_t)0x57cf, (q15_t)0x3b68, (q15_t)0x57db, (q15_t)0x3b63, (q15_t)0x57e7, (q15_t)0x3b5f, - (q15_t)0x57f2, (q15_t)0x3b5a, (q15_t)0x57fe, (q15_t)0x3b55, (q15_t)0x580a, (q15_t)0x3b50, (q15_t)0x5815, (q15_t)0x3b4c, - (q15_t)0x5821, (q15_t)0x3b47, (q15_t)0x582d, (q15_t)0x3b42, (q15_t)0x5838, (q15_t)0x3b3e, (q15_t)0x5844, (q15_t)0x3b39, - (q15_t)0x584f, (q15_t)0x3b34, (q15_t)0x585b, (q15_t)0x3b2f, (q15_t)0x5867, (q15_t)0x3b2a, (q15_t)0x5872, (q15_t)0x3b26, - (q15_t)0x587e, (q15_t)0x3b21, (q15_t)0x5889, (q15_t)0x3b1c, (q15_t)0x5895, (q15_t)0x3b17, (q15_t)0x58a1, (q15_t)0x3b12, - (q15_t)0x58ac, (q15_t)0x3b0e, (q15_t)0x58b8, (q15_t)0x3b09, (q15_t)0x58c3, (q15_t)0x3b04, (q15_t)0x58cf, (q15_t)0x3aff, - (q15_t)0x58db, (q15_t)0x3afa, (q15_t)0x58e6, (q15_t)0x3af5, (q15_t)0x58f2, (q15_t)0x3af0, (q15_t)0x58fd, (q15_t)0x3aeb, - (q15_t)0x5909, (q15_t)0x3ae6, (q15_t)0x5914, (q15_t)0x3ae2, (q15_t)0x5920, (q15_t)0x3add, (q15_t)0x592c, (q15_t)0x3ad8, - (q15_t)0x5937, (q15_t)0x3ad3, (q15_t)0x5943, (q15_t)0x3ace, (q15_t)0x594e, (q15_t)0x3ac9, (q15_t)0x595a, (q15_t)0x3ac4, - (q15_t)0x5965, (q15_t)0x3abf, (q15_t)0x5971, (q15_t)0x3aba, (q15_t)0x597c, (q15_t)0x3ab5, (q15_t)0x5988, (q15_t)0x3ab0, - (q15_t)0x5993, (q15_t)0x3aab, (q15_t)0x599f, (q15_t)0x3aa6, (q15_t)0x59aa, (q15_t)0x3aa1, (q15_t)0x59b6, (q15_t)0x3a9c, - (q15_t)0x59c1, (q15_t)0x3a97, (q15_t)0x59cd, (q15_t)0x3a92, (q15_t)0x59d8, (q15_t)0x3a8d, (q15_t)0x59e4, (q15_t)0x3a88, - (q15_t)0x59ef, (q15_t)0x3a82, (q15_t)0x59fb, (q15_t)0x3a7d, (q15_t)0x5a06, (q15_t)0x3a78, (q15_t)0x5a12, (q15_t)0x3a73, - (q15_t)0x5a1d, (q15_t)0x3a6e, (q15_t)0x5a29, (q15_t)0x3a69, (q15_t)0x5a34, (q15_t)0x3a64, (q15_t)0x5a40, (q15_t)0x3a5f, - (q15_t)0x5a4b, (q15_t)0x3a59, (q15_t)0x5a57, (q15_t)0x3a54, (q15_t)0x5a62, (q15_t)0x3a4f, (q15_t)0x5a6e, (q15_t)0x3a4a, - (q15_t)0x5a79, (q15_t)0x3a45, (q15_t)0x5a84, (q15_t)0x3a3f, (q15_t)0x5a90, (q15_t)0x3a3a, (q15_t)0x5a9b, (q15_t)0x3a35, - (q15_t)0x5aa7, (q15_t)0x3a30, (q15_t)0x5ab2, (q15_t)0x3a2b, (q15_t)0x5abe, (q15_t)0x3a25, (q15_t)0x5ac9, (q15_t)0x3a20, - (q15_t)0x5ad4, (q15_t)0x3a1b, (q15_t)0x5ae0, (q15_t)0x3a16, (q15_t)0x5aeb, (q15_t)0x3a10, (q15_t)0x5af7, (q15_t)0x3a0b, - (q15_t)0x5b02, (q15_t)0x3a06, (q15_t)0x5b0d, (q15_t)0x3a00, (q15_t)0x5b19, (q15_t)0x39fb, (q15_t)0x5b24, (q15_t)0x39f6, - (q15_t)0x5b30, (q15_t)0x39f0, (q15_t)0x5b3b, (q15_t)0x39eb, (q15_t)0x5b46, (q15_t)0x39e6, (q15_t)0x5b52, (q15_t)0x39e0, - (q15_t)0x5b5d, (q15_t)0x39db, (q15_t)0x5b68, (q15_t)0x39d6, (q15_t)0x5b74, (q15_t)0x39d0, (q15_t)0x5b7f, (q15_t)0x39cb, - (q15_t)0x5b8a, (q15_t)0x39c5, (q15_t)0x5b96, (q15_t)0x39c0, (q15_t)0x5ba1, (q15_t)0x39bb, (q15_t)0x5bac, (q15_t)0x39b5, - (q15_t)0x5bb8, (q15_t)0x39b0, (q15_t)0x5bc3, (q15_t)0x39aa, (q15_t)0x5bce, (q15_t)0x39a5, (q15_t)0x5bda, (q15_t)0x399f, - (q15_t)0x5be5, (q15_t)0x399a, (q15_t)0x5bf0, (q15_t)0x3994, (q15_t)0x5bfc, (q15_t)0x398f, (q15_t)0x5c07, (q15_t)0x3989, - (q15_t)0x5c12, (q15_t)0x3984, (q15_t)0x5c1e, (q15_t)0x397e, (q15_t)0x5c29, (q15_t)0x3979, (q15_t)0x5c34, (q15_t)0x3973, - (q15_t)0x5c3f, (q15_t)0x396e, (q15_t)0x5c4b, (q15_t)0x3968, (q15_t)0x5c56, (q15_t)0x3963, (q15_t)0x5c61, (q15_t)0x395d, - (q15_t)0x5c6c, (q15_t)0x3958, (q15_t)0x5c78, (q15_t)0x3952, (q15_t)0x5c83, (q15_t)0x394c, (q15_t)0x5c8e, (q15_t)0x3947, - (q15_t)0x5c99, (q15_t)0x3941, (q15_t)0x5ca5, (q15_t)0x393b, (q15_t)0x5cb0, (q15_t)0x3936, (q15_t)0x5cbb, (q15_t)0x3930, - (q15_t)0x5cc6, (q15_t)0x392b, (q15_t)0x5cd2, (q15_t)0x3925, (q15_t)0x5cdd, (q15_t)0x391f, (q15_t)0x5ce8, (q15_t)0x391a, - (q15_t)0x5cf3, (q15_t)0x3914, (q15_t)0x5cff, (q15_t)0x390e, (q15_t)0x5d0a, (q15_t)0x3909, (q15_t)0x5d15, (q15_t)0x3903, - (q15_t)0x5d20, (q15_t)0x38fd, (q15_t)0x5d2b, (q15_t)0x38f7, (q15_t)0x5d36, (q15_t)0x38f2, (q15_t)0x5d42, (q15_t)0x38ec, - (q15_t)0x5d4d, (q15_t)0x38e6, (q15_t)0x5d58, (q15_t)0x38e0, (q15_t)0x5d63, (q15_t)0x38db, (q15_t)0x5d6e, (q15_t)0x38d5, - (q15_t)0x5d79, (q15_t)0x38cf, (q15_t)0x5d85, (q15_t)0x38c9, (q15_t)0x5d90, (q15_t)0x38c3, (q15_t)0x5d9b, (q15_t)0x38be, - (q15_t)0x5da6, (q15_t)0x38b8, (q15_t)0x5db1, (q15_t)0x38b2, (q15_t)0x5dbc, (q15_t)0x38ac, (q15_t)0x5dc7, (q15_t)0x38a6, - (q15_t)0x5dd3, (q15_t)0x38a1, (q15_t)0x5dde, (q15_t)0x389b, (q15_t)0x5de9, (q15_t)0x3895, (q15_t)0x5df4, (q15_t)0x388f, - (q15_t)0x5dff, (q15_t)0x3889, (q15_t)0x5e0a, (q15_t)0x3883, (q15_t)0x5e15, (q15_t)0x387d, (q15_t)0x5e20, (q15_t)0x3877, - (q15_t)0x5e2b, (q15_t)0x3871, (q15_t)0x5e36, (q15_t)0x386b, (q15_t)0x5e42, (q15_t)0x3866, (q15_t)0x5e4d, (q15_t)0x3860, - (q15_t)0x5e58, (q15_t)0x385a, (q15_t)0x5e63, (q15_t)0x3854, (q15_t)0x5e6e, (q15_t)0x384e, (q15_t)0x5e79, (q15_t)0x3848, - (q15_t)0x5e84, (q15_t)0x3842, (q15_t)0x5e8f, (q15_t)0x383c, (q15_t)0x5e9a, (q15_t)0x3836, (q15_t)0x5ea5, (q15_t)0x3830, - (q15_t)0x5eb0, (q15_t)0x382a, (q15_t)0x5ebb, (q15_t)0x3824, (q15_t)0x5ec6, (q15_t)0x381e, (q15_t)0x5ed1, (q15_t)0x3818, - (q15_t)0x5edc, (q15_t)0x3812, (q15_t)0x5ee7, (q15_t)0x380b, (q15_t)0x5ef2, (q15_t)0x3805, (q15_t)0x5efd, (q15_t)0x37ff, - (q15_t)0x5f08, (q15_t)0x37f9, (q15_t)0x5f13, (q15_t)0x37f3, (q15_t)0x5f1e, (q15_t)0x37ed, (q15_t)0x5f29, (q15_t)0x37e7, - (q15_t)0x5f34, (q15_t)0x37e1, (q15_t)0x5f3f, (q15_t)0x37db, (q15_t)0x5f4a, (q15_t)0x37d5, (q15_t)0x5f55, (q15_t)0x37ce, - (q15_t)0x5f60, (q15_t)0x37c8, (q15_t)0x5f6b, (q15_t)0x37c2, (q15_t)0x5f76, (q15_t)0x37bc, (q15_t)0x5f81, (q15_t)0x37b6, - (q15_t)0x5f8c, (q15_t)0x37b0, (q15_t)0x5f97, (q15_t)0x37a9, (q15_t)0x5fa2, (q15_t)0x37a3, (q15_t)0x5fac, (q15_t)0x379d, - (q15_t)0x5fb7, (q15_t)0x3797, (q15_t)0x5fc2, (q15_t)0x3790, (q15_t)0x5fcd, (q15_t)0x378a, (q15_t)0x5fd8, (q15_t)0x3784, - (q15_t)0x5fe3, (q15_t)0x377e, (q15_t)0x5fee, (q15_t)0x3777, (q15_t)0x5ff9, (q15_t)0x3771, (q15_t)0x6004, (q15_t)0x376b, - (q15_t)0x600f, (q15_t)0x3765, (q15_t)0x6019, (q15_t)0x375e, (q15_t)0x6024, (q15_t)0x3758, (q15_t)0x602f, (q15_t)0x3752, - (q15_t)0x603a, (q15_t)0x374b, (q15_t)0x6045, (q15_t)0x3745, (q15_t)0x6050, (q15_t)0x373f, (q15_t)0x605b, (q15_t)0x3738, - (q15_t)0x6065, (q15_t)0x3732, (q15_t)0x6070, (q15_t)0x372c, (q15_t)0x607b, (q15_t)0x3725, (q15_t)0x6086, (q15_t)0x371f, - (q15_t)0x6091, (q15_t)0x3718, (q15_t)0x609b, (q15_t)0x3712, (q15_t)0x60a6, (q15_t)0x370c, (q15_t)0x60b1, (q15_t)0x3705, - (q15_t)0x60bc, (q15_t)0x36ff, (q15_t)0x60c7, (q15_t)0x36f8, (q15_t)0x60d1, (q15_t)0x36f2, (q15_t)0x60dc, (q15_t)0x36eb, - (q15_t)0x60e7, (q15_t)0x36e5, (q15_t)0x60f2, (q15_t)0x36df, (q15_t)0x60fd, (q15_t)0x36d8, (q15_t)0x6107, (q15_t)0x36d2, - (q15_t)0x6112, (q15_t)0x36cb, (q15_t)0x611d, (q15_t)0x36c5, (q15_t)0x6128, (q15_t)0x36be, (q15_t)0x6132, (q15_t)0x36b8, - (q15_t)0x613d, (q15_t)0x36b1, (q15_t)0x6148, (q15_t)0x36ab, (q15_t)0x6153, (q15_t)0x36a4, (q15_t)0x615d, (q15_t)0x369d, - (q15_t)0x6168, (q15_t)0x3697, (q15_t)0x6173, (q15_t)0x3690, (q15_t)0x617d, (q15_t)0x368a, (q15_t)0x6188, (q15_t)0x3683, - (q15_t)0x6193, (q15_t)0x367d, (q15_t)0x619e, (q15_t)0x3676, (q15_t)0x61a8, (q15_t)0x366f, (q15_t)0x61b3, (q15_t)0x3669, - (q15_t)0x61be, (q15_t)0x3662, (q15_t)0x61c8, (q15_t)0x365c, (q15_t)0x61d3, (q15_t)0x3655, (q15_t)0x61de, (q15_t)0x364e, - (q15_t)0x61e8, (q15_t)0x3648, (q15_t)0x61f3, (q15_t)0x3641, (q15_t)0x61fe, (q15_t)0x363a, (q15_t)0x6208, (q15_t)0x3634, - (q15_t)0x6213, (q15_t)0x362d, (q15_t)0x621e, (q15_t)0x3626, (q15_t)0x6228, (q15_t)0x3620, (q15_t)0x6233, (q15_t)0x3619, - (q15_t)0x623d, (q15_t)0x3612, (q15_t)0x6248, (q15_t)0x360b, (q15_t)0x6253, (q15_t)0x3605, (q15_t)0x625d, (q15_t)0x35fe, - (q15_t)0x6268, (q15_t)0x35f7, (q15_t)0x6272, (q15_t)0x35f0, (q15_t)0x627d, (q15_t)0x35ea, (q15_t)0x6288, (q15_t)0x35e3, - (q15_t)0x6292, (q15_t)0x35dc, (q15_t)0x629d, (q15_t)0x35d5, (q15_t)0x62a7, (q15_t)0x35ce, (q15_t)0x62b2, (q15_t)0x35c8, - (q15_t)0x62bc, (q15_t)0x35c1, (q15_t)0x62c7, (q15_t)0x35ba, (q15_t)0x62d2, (q15_t)0x35b3, (q15_t)0x62dc, (q15_t)0x35ac, - (q15_t)0x62e7, (q15_t)0x35a5, (q15_t)0x62f1, (q15_t)0x359f, (q15_t)0x62fc, (q15_t)0x3598, (q15_t)0x6306, (q15_t)0x3591, - (q15_t)0x6311, (q15_t)0x358a, (q15_t)0x631b, (q15_t)0x3583, (q15_t)0x6326, (q15_t)0x357c, (q15_t)0x6330, (q15_t)0x3575, - (q15_t)0x633b, (q15_t)0x356e, (q15_t)0x6345, (q15_t)0x3567, (q15_t)0x6350, (q15_t)0x3561, (q15_t)0x635a, (q15_t)0x355a, - (q15_t)0x6365, (q15_t)0x3553, (q15_t)0x636f, (q15_t)0x354c, (q15_t)0x637a, (q15_t)0x3545, (q15_t)0x6384, (q15_t)0x353e, - (q15_t)0x638e, (q15_t)0x3537, (q15_t)0x6399, (q15_t)0x3530, (q15_t)0x63a3, (q15_t)0x3529, (q15_t)0x63ae, (q15_t)0x3522, - (q15_t)0x63b8, (q15_t)0x351b, (q15_t)0x63c3, (q15_t)0x3514, (q15_t)0x63cd, (q15_t)0x350d, (q15_t)0x63d7, (q15_t)0x3506, - (q15_t)0x63e2, (q15_t)0x34ff, (q15_t)0x63ec, (q15_t)0x34f8, (q15_t)0x63f7, (q15_t)0x34f1, (q15_t)0x6401, (q15_t)0x34ea, - (q15_t)0x640b, (q15_t)0x34e2, (q15_t)0x6416, (q15_t)0x34db, (q15_t)0x6420, (q15_t)0x34d4, (q15_t)0x642b, (q15_t)0x34cd, - (q15_t)0x6435, (q15_t)0x34c6, (q15_t)0x643f, (q15_t)0x34bf, (q15_t)0x644a, (q15_t)0x34b8, (q15_t)0x6454, (q15_t)0x34b1, - (q15_t)0x645e, (q15_t)0x34aa, (q15_t)0x6469, (q15_t)0x34a2, (q15_t)0x6473, (q15_t)0x349b, (q15_t)0x647d, (q15_t)0x3494, - (q15_t)0x6488, (q15_t)0x348d, (q15_t)0x6492, (q15_t)0x3486, (q15_t)0x649c, (q15_t)0x347f, (q15_t)0x64a7, (q15_t)0x3477, - (q15_t)0x64b1, (q15_t)0x3470, (q15_t)0x64bb, (q15_t)0x3469, (q15_t)0x64c5, (q15_t)0x3462, (q15_t)0x64d0, (q15_t)0x345b, - (q15_t)0x64da, (q15_t)0x3453, (q15_t)0x64e4, (q15_t)0x344c, (q15_t)0x64ef, (q15_t)0x3445, (q15_t)0x64f9, (q15_t)0x343e, - (q15_t)0x6503, (q15_t)0x3436, (q15_t)0x650d, (q15_t)0x342f, (q15_t)0x6518, (q15_t)0x3428, (q15_t)0x6522, (q15_t)0x3420, - (q15_t)0x652c, (q15_t)0x3419, (q15_t)0x6536, (q15_t)0x3412, (q15_t)0x6541, (q15_t)0x340b, (q15_t)0x654b, (q15_t)0x3403, - (q15_t)0x6555, (q15_t)0x33fc, (q15_t)0x655f, (q15_t)0x33f5, (q15_t)0x6569, (q15_t)0x33ed, (q15_t)0x6574, (q15_t)0x33e6, - (q15_t)0x657e, (q15_t)0x33df, (q15_t)0x6588, (q15_t)0x33d7, (q15_t)0x6592, (q15_t)0x33d0, (q15_t)0x659c, (q15_t)0x33c8, - (q15_t)0x65a6, (q15_t)0x33c1, (q15_t)0x65b1, (q15_t)0x33ba, (q15_t)0x65bb, (q15_t)0x33b2, (q15_t)0x65c5, (q15_t)0x33ab, - (q15_t)0x65cf, (q15_t)0x33a3, (q15_t)0x65d9, (q15_t)0x339c, (q15_t)0x65e3, (q15_t)0x3395, (q15_t)0x65ed, (q15_t)0x338d, - (q15_t)0x65f8, (q15_t)0x3386, (q15_t)0x6602, (q15_t)0x337e, (q15_t)0x660c, (q15_t)0x3377, (q15_t)0x6616, (q15_t)0x336f, - (q15_t)0x6620, (q15_t)0x3368, (q15_t)0x662a, (q15_t)0x3360, (q15_t)0x6634, (q15_t)0x3359, (q15_t)0x663e, (q15_t)0x3351, - (q15_t)0x6648, (q15_t)0x334a, (q15_t)0x6652, (q15_t)0x3342, (q15_t)0x665c, (q15_t)0x333b, (q15_t)0x6666, (q15_t)0x3333, - (q15_t)0x6671, (q15_t)0x332c, (q15_t)0x667b, (q15_t)0x3324, (q15_t)0x6685, (q15_t)0x331d, (q15_t)0x668f, (q15_t)0x3315, - (q15_t)0x6699, (q15_t)0x330d, (q15_t)0x66a3, (q15_t)0x3306, (q15_t)0x66ad, (q15_t)0x32fe, (q15_t)0x66b7, (q15_t)0x32f7, - (q15_t)0x66c1, (q15_t)0x32ef, (q15_t)0x66cb, (q15_t)0x32e7, (q15_t)0x66d5, (q15_t)0x32e0, (q15_t)0x66df, (q15_t)0x32d8, - (q15_t)0x66e9, (q15_t)0x32d0, (q15_t)0x66f3, (q15_t)0x32c9, (q15_t)0x66fd, (q15_t)0x32c1, (q15_t)0x6707, (q15_t)0x32ba, - (q15_t)0x6711, (q15_t)0x32b2, (q15_t)0x671a, (q15_t)0x32aa, (q15_t)0x6724, (q15_t)0x32a3, (q15_t)0x672e, (q15_t)0x329b, - (q15_t)0x6738, (q15_t)0x3293, (q15_t)0x6742, (q15_t)0x328b, (q15_t)0x674c, (q15_t)0x3284, (q15_t)0x6756, (q15_t)0x327c, - (q15_t)0x6760, (q15_t)0x3274, (q15_t)0x676a, (q15_t)0x326d, (q15_t)0x6774, (q15_t)0x3265, (q15_t)0x677e, (q15_t)0x325d, - (q15_t)0x6788, (q15_t)0x3255, (q15_t)0x6791, (q15_t)0x324e, (q15_t)0x679b, (q15_t)0x3246, (q15_t)0x67a5, (q15_t)0x323e, - (q15_t)0x67af, (q15_t)0x3236, (q15_t)0x67b9, (q15_t)0x322e, (q15_t)0x67c3, (q15_t)0x3227, (q15_t)0x67cd, (q15_t)0x321f, - (q15_t)0x67d6, (q15_t)0x3217, (q15_t)0x67e0, (q15_t)0x320f, (q15_t)0x67ea, (q15_t)0x3207, (q15_t)0x67f4, (q15_t)0x31ff, - (q15_t)0x67fe, (q15_t)0x31f8, (q15_t)0x6808, (q15_t)0x31f0, (q15_t)0x6811, (q15_t)0x31e8, (q15_t)0x681b, (q15_t)0x31e0, - (q15_t)0x6825, (q15_t)0x31d8, (q15_t)0x682f, (q15_t)0x31d0, (q15_t)0x6838, (q15_t)0x31c8, (q15_t)0x6842, (q15_t)0x31c0, - (q15_t)0x684c, (q15_t)0x31b9, (q15_t)0x6856, (q15_t)0x31b1, (q15_t)0x6860, (q15_t)0x31a9, (q15_t)0x6869, (q15_t)0x31a1, - (q15_t)0x6873, (q15_t)0x3199, (q15_t)0x687d, (q15_t)0x3191, (q15_t)0x6886, (q15_t)0x3189, (q15_t)0x6890, (q15_t)0x3181, - (q15_t)0x689a, (q15_t)0x3179, (q15_t)0x68a4, (q15_t)0x3171, (q15_t)0x68ad, (q15_t)0x3169, (q15_t)0x68b7, (q15_t)0x3161, - (q15_t)0x68c1, (q15_t)0x3159, (q15_t)0x68ca, (q15_t)0x3151, (q15_t)0x68d4, (q15_t)0x3149, (q15_t)0x68de, (q15_t)0x3141, - (q15_t)0x68e7, (q15_t)0x3139, (q15_t)0x68f1, (q15_t)0x3131, (q15_t)0x68fb, (q15_t)0x3129, (q15_t)0x6904, (q15_t)0x3121, - (q15_t)0x690e, (q15_t)0x3119, (q15_t)0x6918, (q15_t)0x3111, (q15_t)0x6921, (q15_t)0x3109, (q15_t)0x692b, (q15_t)0x3101, - (q15_t)0x6935, (q15_t)0x30f9, (q15_t)0x693e, (q15_t)0x30f0, (q15_t)0x6948, (q15_t)0x30e8, (q15_t)0x6951, (q15_t)0x30e0, - (q15_t)0x695b, (q15_t)0x30d8, (q15_t)0x6965, (q15_t)0x30d0, (q15_t)0x696e, (q15_t)0x30c8, (q15_t)0x6978, (q15_t)0x30c0, - (q15_t)0x6981, (q15_t)0x30b8, (q15_t)0x698b, (q15_t)0x30af, (q15_t)0x6994, (q15_t)0x30a7, (q15_t)0x699e, (q15_t)0x309f, - (q15_t)0x69a7, (q15_t)0x3097, (q15_t)0x69b1, (q15_t)0x308f, (q15_t)0x69bb, (q15_t)0x3087, (q15_t)0x69c4, (q15_t)0x307e, - (q15_t)0x69ce, (q15_t)0x3076, (q15_t)0x69d7, (q15_t)0x306e, (q15_t)0x69e1, (q15_t)0x3066, (q15_t)0x69ea, (q15_t)0x305d, - (q15_t)0x69f4, (q15_t)0x3055, (q15_t)0x69fd, (q15_t)0x304d, (q15_t)0x6a07, (q15_t)0x3045, (q15_t)0x6a10, (q15_t)0x303c, - (q15_t)0x6a1a, (q15_t)0x3034, (q15_t)0x6a23, (q15_t)0x302c, (q15_t)0x6a2c, (q15_t)0x3024, (q15_t)0x6a36, (q15_t)0x301b, - (q15_t)0x6a3f, (q15_t)0x3013, (q15_t)0x6a49, (q15_t)0x300b, (q15_t)0x6a52, (q15_t)0x3002, (q15_t)0x6a5c, (q15_t)0x2ffa, - (q15_t)0x6a65, (q15_t)0x2ff2, (q15_t)0x6a6e, (q15_t)0x2fea, (q15_t)0x6a78, (q15_t)0x2fe1, (q15_t)0x6a81, (q15_t)0x2fd9, - (q15_t)0x6a8b, (q15_t)0x2fd0, (q15_t)0x6a94, (q15_t)0x2fc8, (q15_t)0x6a9d, (q15_t)0x2fc0, (q15_t)0x6aa7, (q15_t)0x2fb7, - (q15_t)0x6ab0, (q15_t)0x2faf, (q15_t)0x6ab9, (q15_t)0x2fa7, (q15_t)0x6ac3, (q15_t)0x2f9e, (q15_t)0x6acc, (q15_t)0x2f96, - (q15_t)0x6ad6, (q15_t)0x2f8d, (q15_t)0x6adf, (q15_t)0x2f85, (q15_t)0x6ae8, (q15_t)0x2f7d, (q15_t)0x6af2, (q15_t)0x2f74, - (q15_t)0x6afb, (q15_t)0x2f6c, (q15_t)0x6b04, (q15_t)0x2f63, (q15_t)0x6b0d, (q15_t)0x2f5b, (q15_t)0x6b17, (q15_t)0x2f52, - (q15_t)0x6b20, (q15_t)0x2f4a, (q15_t)0x6b29, (q15_t)0x2f41, (q15_t)0x6b33, (q15_t)0x2f39, (q15_t)0x6b3c, (q15_t)0x2f30, - (q15_t)0x6b45, (q15_t)0x2f28, (q15_t)0x6b4e, (q15_t)0x2f20, (q15_t)0x6b58, (q15_t)0x2f17, (q15_t)0x6b61, (q15_t)0x2f0e, - (q15_t)0x6b6a, (q15_t)0x2f06, (q15_t)0x6b73, (q15_t)0x2efd, (q15_t)0x6b7d, (q15_t)0x2ef5, (q15_t)0x6b86, (q15_t)0x2eec, - (q15_t)0x6b8f, (q15_t)0x2ee4, (q15_t)0x6b98, (q15_t)0x2edb, (q15_t)0x6ba1, (q15_t)0x2ed3, (q15_t)0x6bab, (q15_t)0x2eca, - (q15_t)0x6bb4, (q15_t)0x2ec2, (q15_t)0x6bbd, (q15_t)0x2eb9, (q15_t)0x6bc6, (q15_t)0x2eb0, (q15_t)0x6bcf, (q15_t)0x2ea8, - (q15_t)0x6bd8, (q15_t)0x2e9f, (q15_t)0x6be2, (q15_t)0x2e97, (q15_t)0x6beb, (q15_t)0x2e8e, (q15_t)0x6bf4, (q15_t)0x2e85, - (q15_t)0x6bfd, (q15_t)0x2e7d, (q15_t)0x6c06, (q15_t)0x2e74, (q15_t)0x6c0f, (q15_t)0x2e6b, (q15_t)0x6c18, (q15_t)0x2e63, - (q15_t)0x6c21, (q15_t)0x2e5a, (q15_t)0x6c2b, (q15_t)0x2e51, (q15_t)0x6c34, (q15_t)0x2e49, (q15_t)0x6c3d, (q15_t)0x2e40, - (q15_t)0x6c46, (q15_t)0x2e37, (q15_t)0x6c4f, (q15_t)0x2e2f, (q15_t)0x6c58, (q15_t)0x2e26, (q15_t)0x6c61, (q15_t)0x2e1d, - (q15_t)0x6c6a, (q15_t)0x2e15, (q15_t)0x6c73, (q15_t)0x2e0c, (q15_t)0x6c7c, (q15_t)0x2e03, (q15_t)0x6c85, (q15_t)0x2dfa, - (q15_t)0x6c8e, (q15_t)0x2df2, (q15_t)0x6c97, (q15_t)0x2de9, (q15_t)0x6ca0, (q15_t)0x2de0, (q15_t)0x6ca9, (q15_t)0x2dd7, - (q15_t)0x6cb2, (q15_t)0x2dcf, (q15_t)0x6cbb, (q15_t)0x2dc6, (q15_t)0x6cc4, (q15_t)0x2dbd, (q15_t)0x6ccd, (q15_t)0x2db4, - (q15_t)0x6cd6, (q15_t)0x2dab, (q15_t)0x6cdf, (q15_t)0x2da3, (q15_t)0x6ce8, (q15_t)0x2d9a, (q15_t)0x6cf1, (q15_t)0x2d91, - (q15_t)0x6cfa, (q15_t)0x2d88, (q15_t)0x6d03, (q15_t)0x2d7f, (q15_t)0x6d0c, (q15_t)0x2d76, (q15_t)0x6d15, (q15_t)0x2d6e, - (q15_t)0x6d1e, (q15_t)0x2d65, (q15_t)0x6d27, (q15_t)0x2d5c, (q15_t)0x6d2f, (q15_t)0x2d53, (q15_t)0x6d38, (q15_t)0x2d4a, - (q15_t)0x6d41, (q15_t)0x2d41, (q15_t)0x6d4a, (q15_t)0x2d38, (q15_t)0x6d53, (q15_t)0x2d2f, (q15_t)0x6d5c, (q15_t)0x2d27, - (q15_t)0x6d65, (q15_t)0x2d1e, (q15_t)0x6d6e, (q15_t)0x2d15, (q15_t)0x6d76, (q15_t)0x2d0c, (q15_t)0x6d7f, (q15_t)0x2d03, - (q15_t)0x6d88, (q15_t)0x2cfa, (q15_t)0x6d91, (q15_t)0x2cf1, (q15_t)0x6d9a, (q15_t)0x2ce8, (q15_t)0x6da3, (q15_t)0x2cdf, - (q15_t)0x6dab, (q15_t)0x2cd6, (q15_t)0x6db4, (q15_t)0x2ccd, (q15_t)0x6dbd, (q15_t)0x2cc4, (q15_t)0x6dc6, (q15_t)0x2cbb, - (q15_t)0x6dcf, (q15_t)0x2cb2, (q15_t)0x6dd7, (q15_t)0x2ca9, (q15_t)0x6de0, (q15_t)0x2ca0, (q15_t)0x6de9, (q15_t)0x2c97, - (q15_t)0x6df2, (q15_t)0x2c8e, (q15_t)0x6dfa, (q15_t)0x2c85, (q15_t)0x6e03, (q15_t)0x2c7c, (q15_t)0x6e0c, (q15_t)0x2c73, - (q15_t)0x6e15, (q15_t)0x2c6a, (q15_t)0x6e1d, (q15_t)0x2c61, (q15_t)0x6e26, (q15_t)0x2c58, (q15_t)0x6e2f, (q15_t)0x2c4f, - (q15_t)0x6e37, (q15_t)0x2c46, (q15_t)0x6e40, (q15_t)0x2c3d, (q15_t)0x6e49, (q15_t)0x2c34, (q15_t)0x6e51, (q15_t)0x2c2b, - (q15_t)0x6e5a, (q15_t)0x2c21, (q15_t)0x6e63, (q15_t)0x2c18, (q15_t)0x6e6b, (q15_t)0x2c0f, (q15_t)0x6e74, (q15_t)0x2c06, - (q15_t)0x6e7d, (q15_t)0x2bfd, (q15_t)0x6e85, (q15_t)0x2bf4, (q15_t)0x6e8e, (q15_t)0x2beb, (q15_t)0x6e97, (q15_t)0x2be2, - (q15_t)0x6e9f, (q15_t)0x2bd8, (q15_t)0x6ea8, (q15_t)0x2bcf, (q15_t)0x6eb0, (q15_t)0x2bc6, (q15_t)0x6eb9, (q15_t)0x2bbd, - (q15_t)0x6ec2, (q15_t)0x2bb4, (q15_t)0x6eca, (q15_t)0x2bab, (q15_t)0x6ed3, (q15_t)0x2ba1, (q15_t)0x6edb, (q15_t)0x2b98, - (q15_t)0x6ee4, (q15_t)0x2b8f, (q15_t)0x6eec, (q15_t)0x2b86, (q15_t)0x6ef5, (q15_t)0x2b7d, (q15_t)0x6efd, (q15_t)0x2b73, - (q15_t)0x6f06, (q15_t)0x2b6a, (q15_t)0x6f0e, (q15_t)0x2b61, (q15_t)0x6f17, (q15_t)0x2b58, (q15_t)0x6f20, (q15_t)0x2b4e, - (q15_t)0x6f28, (q15_t)0x2b45, (q15_t)0x6f30, (q15_t)0x2b3c, (q15_t)0x6f39, (q15_t)0x2b33, (q15_t)0x6f41, (q15_t)0x2b29, - (q15_t)0x6f4a, (q15_t)0x2b20, (q15_t)0x6f52, (q15_t)0x2b17, (q15_t)0x6f5b, (q15_t)0x2b0d, (q15_t)0x6f63, (q15_t)0x2b04, - (q15_t)0x6f6c, (q15_t)0x2afb, (q15_t)0x6f74, (q15_t)0x2af2, (q15_t)0x6f7d, (q15_t)0x2ae8, (q15_t)0x6f85, (q15_t)0x2adf, - (q15_t)0x6f8d, (q15_t)0x2ad6, (q15_t)0x6f96, (q15_t)0x2acc, (q15_t)0x6f9e, (q15_t)0x2ac3, (q15_t)0x6fa7, (q15_t)0x2ab9, - (q15_t)0x6faf, (q15_t)0x2ab0, (q15_t)0x6fb7, (q15_t)0x2aa7, (q15_t)0x6fc0, (q15_t)0x2a9d, (q15_t)0x6fc8, (q15_t)0x2a94, - (q15_t)0x6fd0, (q15_t)0x2a8b, (q15_t)0x6fd9, (q15_t)0x2a81, (q15_t)0x6fe1, (q15_t)0x2a78, (q15_t)0x6fea, (q15_t)0x2a6e, - (q15_t)0x6ff2, (q15_t)0x2a65, (q15_t)0x6ffa, (q15_t)0x2a5c, (q15_t)0x7002, (q15_t)0x2a52, (q15_t)0x700b, (q15_t)0x2a49, - (q15_t)0x7013, (q15_t)0x2a3f, (q15_t)0x701b, (q15_t)0x2a36, (q15_t)0x7024, (q15_t)0x2a2c, (q15_t)0x702c, (q15_t)0x2a23, - (q15_t)0x7034, (q15_t)0x2a1a, (q15_t)0x703c, (q15_t)0x2a10, (q15_t)0x7045, (q15_t)0x2a07, (q15_t)0x704d, (q15_t)0x29fd, - (q15_t)0x7055, (q15_t)0x29f4, (q15_t)0x705d, (q15_t)0x29ea, (q15_t)0x7066, (q15_t)0x29e1, (q15_t)0x706e, (q15_t)0x29d7, - (q15_t)0x7076, (q15_t)0x29ce, (q15_t)0x707e, (q15_t)0x29c4, (q15_t)0x7087, (q15_t)0x29bb, (q15_t)0x708f, (q15_t)0x29b1, - (q15_t)0x7097, (q15_t)0x29a7, (q15_t)0x709f, (q15_t)0x299e, (q15_t)0x70a7, (q15_t)0x2994, (q15_t)0x70af, (q15_t)0x298b, - (q15_t)0x70b8, (q15_t)0x2981, (q15_t)0x70c0, (q15_t)0x2978, (q15_t)0x70c8, (q15_t)0x296e, (q15_t)0x70d0, (q15_t)0x2965, - (q15_t)0x70d8, (q15_t)0x295b, (q15_t)0x70e0, (q15_t)0x2951, (q15_t)0x70e8, (q15_t)0x2948, (q15_t)0x70f0, (q15_t)0x293e, - (q15_t)0x70f9, (q15_t)0x2935, (q15_t)0x7101, (q15_t)0x292b, (q15_t)0x7109, (q15_t)0x2921, (q15_t)0x7111, (q15_t)0x2918, - (q15_t)0x7119, (q15_t)0x290e, (q15_t)0x7121, (q15_t)0x2904, (q15_t)0x7129, (q15_t)0x28fb, (q15_t)0x7131, (q15_t)0x28f1, - (q15_t)0x7139, (q15_t)0x28e7, (q15_t)0x7141, (q15_t)0x28de, (q15_t)0x7149, (q15_t)0x28d4, (q15_t)0x7151, (q15_t)0x28ca, - (q15_t)0x7159, (q15_t)0x28c1, (q15_t)0x7161, (q15_t)0x28b7, (q15_t)0x7169, (q15_t)0x28ad, (q15_t)0x7171, (q15_t)0x28a4, - (q15_t)0x7179, (q15_t)0x289a, (q15_t)0x7181, (q15_t)0x2890, (q15_t)0x7189, (q15_t)0x2886, (q15_t)0x7191, (q15_t)0x287d, - (q15_t)0x7199, (q15_t)0x2873, (q15_t)0x71a1, (q15_t)0x2869, (q15_t)0x71a9, (q15_t)0x2860, (q15_t)0x71b1, (q15_t)0x2856, - (q15_t)0x71b9, (q15_t)0x284c, (q15_t)0x71c0, (q15_t)0x2842, (q15_t)0x71c8, (q15_t)0x2838, (q15_t)0x71d0, (q15_t)0x282f, - (q15_t)0x71d8, (q15_t)0x2825, (q15_t)0x71e0, (q15_t)0x281b, (q15_t)0x71e8, (q15_t)0x2811, (q15_t)0x71f0, (q15_t)0x2808, - (q15_t)0x71f8, (q15_t)0x27fe, (q15_t)0x71ff, (q15_t)0x27f4, (q15_t)0x7207, (q15_t)0x27ea, (q15_t)0x720f, (q15_t)0x27e0, - (q15_t)0x7217, (q15_t)0x27d6, (q15_t)0x721f, (q15_t)0x27cd, (q15_t)0x7227, (q15_t)0x27c3, (q15_t)0x722e, (q15_t)0x27b9, - (q15_t)0x7236, (q15_t)0x27af, (q15_t)0x723e, (q15_t)0x27a5, (q15_t)0x7246, (q15_t)0x279b, (q15_t)0x724e, (q15_t)0x2791, - (q15_t)0x7255, (q15_t)0x2788, (q15_t)0x725d, (q15_t)0x277e, (q15_t)0x7265, (q15_t)0x2774, (q15_t)0x726d, (q15_t)0x276a, - (q15_t)0x7274, (q15_t)0x2760, (q15_t)0x727c, (q15_t)0x2756, (q15_t)0x7284, (q15_t)0x274c, (q15_t)0x728b, (q15_t)0x2742, - (q15_t)0x7293, (q15_t)0x2738, (q15_t)0x729b, (q15_t)0x272e, (q15_t)0x72a3, (q15_t)0x2724, (q15_t)0x72aa, (q15_t)0x271a, - (q15_t)0x72b2, (q15_t)0x2711, (q15_t)0x72ba, (q15_t)0x2707, (q15_t)0x72c1, (q15_t)0x26fd, (q15_t)0x72c9, (q15_t)0x26f3, - (q15_t)0x72d0, (q15_t)0x26e9, (q15_t)0x72d8, (q15_t)0x26df, (q15_t)0x72e0, (q15_t)0x26d5, (q15_t)0x72e7, (q15_t)0x26cb, - (q15_t)0x72ef, (q15_t)0x26c1, (q15_t)0x72f7, (q15_t)0x26b7, (q15_t)0x72fe, (q15_t)0x26ad, (q15_t)0x7306, (q15_t)0x26a3, - (q15_t)0x730d, (q15_t)0x2699, (q15_t)0x7315, (q15_t)0x268f, (q15_t)0x731d, (q15_t)0x2685, (q15_t)0x7324, (q15_t)0x267b, - (q15_t)0x732c, (q15_t)0x2671, (q15_t)0x7333, (q15_t)0x2666, (q15_t)0x733b, (q15_t)0x265c, (q15_t)0x7342, (q15_t)0x2652, - (q15_t)0x734a, (q15_t)0x2648, (q15_t)0x7351, (q15_t)0x263e, (q15_t)0x7359, (q15_t)0x2634, (q15_t)0x7360, (q15_t)0x262a, - (q15_t)0x7368, (q15_t)0x2620, (q15_t)0x736f, (q15_t)0x2616, (q15_t)0x7377, (q15_t)0x260c, (q15_t)0x737e, (q15_t)0x2602, - (q15_t)0x7386, (q15_t)0x25f8, (q15_t)0x738d, (q15_t)0x25ed, (q15_t)0x7395, (q15_t)0x25e3, (q15_t)0x739c, (q15_t)0x25d9, - (q15_t)0x73a3, (q15_t)0x25cf, (q15_t)0x73ab, (q15_t)0x25c5, (q15_t)0x73b2, (q15_t)0x25bb, (q15_t)0x73ba, (q15_t)0x25b1, - (q15_t)0x73c1, (q15_t)0x25a6, (q15_t)0x73c8, (q15_t)0x259c, (q15_t)0x73d0, (q15_t)0x2592, (q15_t)0x73d7, (q15_t)0x2588, - (q15_t)0x73df, (q15_t)0x257e, (q15_t)0x73e6, (q15_t)0x2574, (q15_t)0x73ed, (q15_t)0x2569, (q15_t)0x73f5, (q15_t)0x255f, - (q15_t)0x73fc, (q15_t)0x2555, (q15_t)0x7403, (q15_t)0x254b, (q15_t)0x740b, (q15_t)0x2541, (q15_t)0x7412, (q15_t)0x2536, - (q15_t)0x7419, (q15_t)0x252c, (q15_t)0x7420, (q15_t)0x2522, (q15_t)0x7428, (q15_t)0x2518, (q15_t)0x742f, (q15_t)0x250d, - (q15_t)0x7436, (q15_t)0x2503, (q15_t)0x743e, (q15_t)0x24f9, (q15_t)0x7445, (q15_t)0x24ef, (q15_t)0x744c, (q15_t)0x24e4, - (q15_t)0x7453, (q15_t)0x24da, (q15_t)0x745b, (q15_t)0x24d0, (q15_t)0x7462, (q15_t)0x24c5, (q15_t)0x7469, (q15_t)0x24bb, - (q15_t)0x7470, (q15_t)0x24b1, (q15_t)0x7477, (q15_t)0x24a7, (q15_t)0x747f, (q15_t)0x249c, (q15_t)0x7486, (q15_t)0x2492, - (q15_t)0x748d, (q15_t)0x2488, (q15_t)0x7494, (q15_t)0x247d, (q15_t)0x749b, (q15_t)0x2473, (q15_t)0x74a2, (q15_t)0x2469, - (q15_t)0x74aa, (q15_t)0x245e, (q15_t)0x74b1, (q15_t)0x2454, (q15_t)0x74b8, (q15_t)0x244a, (q15_t)0x74bf, (q15_t)0x243f, - (q15_t)0x74c6, (q15_t)0x2435, (q15_t)0x74cd, (q15_t)0x242b, (q15_t)0x74d4, (q15_t)0x2420, (q15_t)0x74db, (q15_t)0x2416, - (q15_t)0x74e2, (q15_t)0x240b, (q15_t)0x74ea, (q15_t)0x2401, (q15_t)0x74f1, (q15_t)0x23f7, (q15_t)0x74f8, (q15_t)0x23ec, - (q15_t)0x74ff, (q15_t)0x23e2, (q15_t)0x7506, (q15_t)0x23d7, (q15_t)0x750d, (q15_t)0x23cd, (q15_t)0x7514, (q15_t)0x23c3, - (q15_t)0x751b, (q15_t)0x23b8, (q15_t)0x7522, (q15_t)0x23ae, (q15_t)0x7529, (q15_t)0x23a3, (q15_t)0x7530, (q15_t)0x2399, - (q15_t)0x7537, (q15_t)0x238e, (q15_t)0x753e, (q15_t)0x2384, (q15_t)0x7545, (q15_t)0x237a, (q15_t)0x754c, (q15_t)0x236f, - (q15_t)0x7553, (q15_t)0x2365, (q15_t)0x755a, (q15_t)0x235a, (q15_t)0x7561, (q15_t)0x2350, (q15_t)0x7567, (q15_t)0x2345, - (q15_t)0x756e, (q15_t)0x233b, (q15_t)0x7575, (q15_t)0x2330, (q15_t)0x757c, (q15_t)0x2326, (q15_t)0x7583, (q15_t)0x231b, - (q15_t)0x758a, (q15_t)0x2311, (q15_t)0x7591, (q15_t)0x2306, (q15_t)0x7598, (q15_t)0x22fc, (q15_t)0x759f, (q15_t)0x22f1, - (q15_t)0x75a5, (q15_t)0x22e7, (q15_t)0x75ac, (q15_t)0x22dc, (q15_t)0x75b3, (q15_t)0x22d2, (q15_t)0x75ba, (q15_t)0x22c7, - (q15_t)0x75c1, (q15_t)0x22bc, (q15_t)0x75c8, (q15_t)0x22b2, (q15_t)0x75ce, (q15_t)0x22a7, (q15_t)0x75d5, (q15_t)0x229d, - (q15_t)0x75dc, (q15_t)0x2292, (q15_t)0x75e3, (q15_t)0x2288, (q15_t)0x75ea, (q15_t)0x227d, (q15_t)0x75f0, (q15_t)0x2272, - (q15_t)0x75f7, (q15_t)0x2268, (q15_t)0x75fe, (q15_t)0x225d, (q15_t)0x7605, (q15_t)0x2253, (q15_t)0x760b, (q15_t)0x2248, - (q15_t)0x7612, (q15_t)0x223d, (q15_t)0x7619, (q15_t)0x2233, (q15_t)0x7620, (q15_t)0x2228, (q15_t)0x7626, (q15_t)0x221e, - (q15_t)0x762d, (q15_t)0x2213, (q15_t)0x7634, (q15_t)0x2208, (q15_t)0x763a, (q15_t)0x21fe, (q15_t)0x7641, (q15_t)0x21f3, - (q15_t)0x7648, (q15_t)0x21e8, (q15_t)0x764e, (q15_t)0x21de, (q15_t)0x7655, (q15_t)0x21d3, (q15_t)0x765c, (q15_t)0x21c8, - (q15_t)0x7662, (q15_t)0x21be, (q15_t)0x7669, (q15_t)0x21b3, (q15_t)0x766f, (q15_t)0x21a8, (q15_t)0x7676, (q15_t)0x219e, - (q15_t)0x767d, (q15_t)0x2193, (q15_t)0x7683, (q15_t)0x2188, (q15_t)0x768a, (q15_t)0x217d, (q15_t)0x7690, (q15_t)0x2173, - (q15_t)0x7697, (q15_t)0x2168, (q15_t)0x769d, (q15_t)0x215d, (q15_t)0x76a4, (q15_t)0x2153, (q15_t)0x76ab, (q15_t)0x2148, - (q15_t)0x76b1, (q15_t)0x213d, (q15_t)0x76b8, (q15_t)0x2132, (q15_t)0x76be, (q15_t)0x2128, (q15_t)0x76c5, (q15_t)0x211d, - (q15_t)0x76cb, (q15_t)0x2112, (q15_t)0x76d2, (q15_t)0x2107, (q15_t)0x76d8, (q15_t)0x20fd, (q15_t)0x76df, (q15_t)0x20f2, - (q15_t)0x76e5, (q15_t)0x20e7, (q15_t)0x76eb, (q15_t)0x20dc, (q15_t)0x76f2, (q15_t)0x20d1, (q15_t)0x76f8, (q15_t)0x20c7, - (q15_t)0x76ff, (q15_t)0x20bc, (q15_t)0x7705, (q15_t)0x20b1, (q15_t)0x770c, (q15_t)0x20a6, (q15_t)0x7712, (q15_t)0x209b, - (q15_t)0x7718, (q15_t)0x2091, (q15_t)0x771f, (q15_t)0x2086, (q15_t)0x7725, (q15_t)0x207b, (q15_t)0x772c, (q15_t)0x2070, - (q15_t)0x7732, (q15_t)0x2065, (q15_t)0x7738, (q15_t)0x205b, (q15_t)0x773f, (q15_t)0x2050, (q15_t)0x7745, (q15_t)0x2045, - (q15_t)0x774b, (q15_t)0x203a, (q15_t)0x7752, (q15_t)0x202f, (q15_t)0x7758, (q15_t)0x2024, (q15_t)0x775e, (q15_t)0x2019, - (q15_t)0x7765, (q15_t)0x200f, (q15_t)0x776b, (q15_t)0x2004, (q15_t)0x7771, (q15_t)0x1ff9, (q15_t)0x7777, (q15_t)0x1fee, - (q15_t)0x777e, (q15_t)0x1fe3, (q15_t)0x7784, (q15_t)0x1fd8, (q15_t)0x778a, (q15_t)0x1fcd, (q15_t)0x7790, (q15_t)0x1fc2, - (q15_t)0x7797, (q15_t)0x1fb7, (q15_t)0x779d, (q15_t)0x1fac, (q15_t)0x77a3, (q15_t)0x1fa2, (q15_t)0x77a9, (q15_t)0x1f97, - (q15_t)0x77b0, (q15_t)0x1f8c, (q15_t)0x77b6, (q15_t)0x1f81, (q15_t)0x77bc, (q15_t)0x1f76, (q15_t)0x77c2, (q15_t)0x1f6b, - (q15_t)0x77c8, (q15_t)0x1f60, (q15_t)0x77ce, (q15_t)0x1f55, (q15_t)0x77d5, (q15_t)0x1f4a, (q15_t)0x77db, (q15_t)0x1f3f, - (q15_t)0x77e1, (q15_t)0x1f34, (q15_t)0x77e7, (q15_t)0x1f29, (q15_t)0x77ed, (q15_t)0x1f1e, (q15_t)0x77f3, (q15_t)0x1f13, - (q15_t)0x77f9, (q15_t)0x1f08, (q15_t)0x77ff, (q15_t)0x1efd, (q15_t)0x7805, (q15_t)0x1ef2, (q15_t)0x780b, (q15_t)0x1ee7, - (q15_t)0x7812, (q15_t)0x1edc, (q15_t)0x7818, (q15_t)0x1ed1, (q15_t)0x781e, (q15_t)0x1ec6, (q15_t)0x7824, (q15_t)0x1ebb, - (q15_t)0x782a, (q15_t)0x1eb0, (q15_t)0x7830, (q15_t)0x1ea5, (q15_t)0x7836, (q15_t)0x1e9a, (q15_t)0x783c, (q15_t)0x1e8f, - (q15_t)0x7842, (q15_t)0x1e84, (q15_t)0x7848, (q15_t)0x1e79, (q15_t)0x784e, (q15_t)0x1e6e, (q15_t)0x7854, (q15_t)0x1e63, - (q15_t)0x785a, (q15_t)0x1e58, (q15_t)0x7860, (q15_t)0x1e4d, (q15_t)0x7866, (q15_t)0x1e42, (q15_t)0x786b, (q15_t)0x1e36, - (q15_t)0x7871, (q15_t)0x1e2b, (q15_t)0x7877, (q15_t)0x1e20, (q15_t)0x787d, (q15_t)0x1e15, (q15_t)0x7883, (q15_t)0x1e0a, - (q15_t)0x7889, (q15_t)0x1dff, (q15_t)0x788f, (q15_t)0x1df4, (q15_t)0x7895, (q15_t)0x1de9, (q15_t)0x789b, (q15_t)0x1dde, - (q15_t)0x78a1, (q15_t)0x1dd3, (q15_t)0x78a6, (q15_t)0x1dc7, (q15_t)0x78ac, (q15_t)0x1dbc, (q15_t)0x78b2, (q15_t)0x1db1, - (q15_t)0x78b8, (q15_t)0x1da6, (q15_t)0x78be, (q15_t)0x1d9b, (q15_t)0x78c3, (q15_t)0x1d90, (q15_t)0x78c9, (q15_t)0x1d85, - (q15_t)0x78cf, (q15_t)0x1d79, (q15_t)0x78d5, (q15_t)0x1d6e, (q15_t)0x78db, (q15_t)0x1d63, (q15_t)0x78e0, (q15_t)0x1d58, - (q15_t)0x78e6, (q15_t)0x1d4d, (q15_t)0x78ec, (q15_t)0x1d42, (q15_t)0x78f2, (q15_t)0x1d36, (q15_t)0x78f7, (q15_t)0x1d2b, - (q15_t)0x78fd, (q15_t)0x1d20, (q15_t)0x7903, (q15_t)0x1d15, (q15_t)0x7909, (q15_t)0x1d0a, (q15_t)0x790e, (q15_t)0x1cff, - (q15_t)0x7914, (q15_t)0x1cf3, (q15_t)0x791a, (q15_t)0x1ce8, (q15_t)0x791f, (q15_t)0x1cdd, (q15_t)0x7925, (q15_t)0x1cd2, - (q15_t)0x792b, (q15_t)0x1cc6, (q15_t)0x7930, (q15_t)0x1cbb, (q15_t)0x7936, (q15_t)0x1cb0, (q15_t)0x793b, (q15_t)0x1ca5, - (q15_t)0x7941, (q15_t)0x1c99, (q15_t)0x7947, (q15_t)0x1c8e, (q15_t)0x794c, (q15_t)0x1c83, (q15_t)0x7952, (q15_t)0x1c78, - (q15_t)0x7958, (q15_t)0x1c6c, (q15_t)0x795d, (q15_t)0x1c61, (q15_t)0x7963, (q15_t)0x1c56, (q15_t)0x7968, (q15_t)0x1c4b, - (q15_t)0x796e, (q15_t)0x1c3f, (q15_t)0x7973, (q15_t)0x1c34, (q15_t)0x7979, (q15_t)0x1c29, (q15_t)0x797e, (q15_t)0x1c1e, - (q15_t)0x7984, (q15_t)0x1c12, (q15_t)0x7989, (q15_t)0x1c07, (q15_t)0x798f, (q15_t)0x1bfc, (q15_t)0x7994, (q15_t)0x1bf0, - (q15_t)0x799a, (q15_t)0x1be5, (q15_t)0x799f, (q15_t)0x1bda, (q15_t)0x79a5, (q15_t)0x1bce, (q15_t)0x79aa, (q15_t)0x1bc3, - (q15_t)0x79b0, (q15_t)0x1bb8, (q15_t)0x79b5, (q15_t)0x1bac, (q15_t)0x79bb, (q15_t)0x1ba1, (q15_t)0x79c0, (q15_t)0x1b96, - (q15_t)0x79c5, (q15_t)0x1b8a, (q15_t)0x79cb, (q15_t)0x1b7f, (q15_t)0x79d0, (q15_t)0x1b74, (q15_t)0x79d6, (q15_t)0x1b68, - (q15_t)0x79db, (q15_t)0x1b5d, (q15_t)0x79e0, (q15_t)0x1b52, (q15_t)0x79e6, (q15_t)0x1b46, (q15_t)0x79eb, (q15_t)0x1b3b, - (q15_t)0x79f0, (q15_t)0x1b30, (q15_t)0x79f6, (q15_t)0x1b24, (q15_t)0x79fb, (q15_t)0x1b19, (q15_t)0x7a00, (q15_t)0x1b0d, - (q15_t)0x7a06, (q15_t)0x1b02, (q15_t)0x7a0b, (q15_t)0x1af7, (q15_t)0x7a10, (q15_t)0x1aeb, (q15_t)0x7a16, (q15_t)0x1ae0, - (q15_t)0x7a1b, (q15_t)0x1ad4, (q15_t)0x7a20, (q15_t)0x1ac9, (q15_t)0x7a25, (q15_t)0x1abe, (q15_t)0x7a2b, (q15_t)0x1ab2, - (q15_t)0x7a30, (q15_t)0x1aa7, (q15_t)0x7a35, (q15_t)0x1a9b, (q15_t)0x7a3a, (q15_t)0x1a90, (q15_t)0x7a3f, (q15_t)0x1a84, - (q15_t)0x7a45, (q15_t)0x1a79, (q15_t)0x7a4a, (q15_t)0x1a6e, (q15_t)0x7a4f, (q15_t)0x1a62, (q15_t)0x7a54, (q15_t)0x1a57, - (q15_t)0x7a59, (q15_t)0x1a4b, (q15_t)0x7a5f, (q15_t)0x1a40, (q15_t)0x7a64, (q15_t)0x1a34, (q15_t)0x7a69, (q15_t)0x1a29, - (q15_t)0x7a6e, (q15_t)0x1a1d, (q15_t)0x7a73, (q15_t)0x1a12, (q15_t)0x7a78, (q15_t)0x1a06, (q15_t)0x7a7d, (q15_t)0x19fb, - (q15_t)0x7a82, (q15_t)0x19ef, (q15_t)0x7a88, (q15_t)0x19e4, (q15_t)0x7a8d, (q15_t)0x19d8, (q15_t)0x7a92, (q15_t)0x19cd, - (q15_t)0x7a97, (q15_t)0x19c1, (q15_t)0x7a9c, (q15_t)0x19b6, (q15_t)0x7aa1, (q15_t)0x19aa, (q15_t)0x7aa6, (q15_t)0x199f, - (q15_t)0x7aab, (q15_t)0x1993, (q15_t)0x7ab0, (q15_t)0x1988, (q15_t)0x7ab5, (q15_t)0x197c, (q15_t)0x7aba, (q15_t)0x1971, - (q15_t)0x7abf, (q15_t)0x1965, (q15_t)0x7ac4, (q15_t)0x195a, (q15_t)0x7ac9, (q15_t)0x194e, (q15_t)0x7ace, (q15_t)0x1943, - (q15_t)0x7ad3, (q15_t)0x1937, (q15_t)0x7ad8, (q15_t)0x192c, (q15_t)0x7add, (q15_t)0x1920, (q15_t)0x7ae2, (q15_t)0x1914, - (q15_t)0x7ae6, (q15_t)0x1909, (q15_t)0x7aeb, (q15_t)0x18fd, (q15_t)0x7af0, (q15_t)0x18f2, (q15_t)0x7af5, (q15_t)0x18e6, - (q15_t)0x7afa, (q15_t)0x18db, (q15_t)0x7aff, (q15_t)0x18cf, (q15_t)0x7b04, (q15_t)0x18c3, (q15_t)0x7b09, (q15_t)0x18b8, - (q15_t)0x7b0e, (q15_t)0x18ac, (q15_t)0x7b12, (q15_t)0x18a1, (q15_t)0x7b17, (q15_t)0x1895, (q15_t)0x7b1c, (q15_t)0x1889, - (q15_t)0x7b21, (q15_t)0x187e, (q15_t)0x7b26, (q15_t)0x1872, (q15_t)0x7b2a, (q15_t)0x1867, (q15_t)0x7b2f, (q15_t)0x185b, - (q15_t)0x7b34, (q15_t)0x184f, (q15_t)0x7b39, (q15_t)0x1844, (q15_t)0x7b3e, (q15_t)0x1838, (q15_t)0x7b42, (q15_t)0x182d, - (q15_t)0x7b47, (q15_t)0x1821, (q15_t)0x7b4c, (q15_t)0x1815, (q15_t)0x7b50, (q15_t)0x180a, (q15_t)0x7b55, (q15_t)0x17fe, - (q15_t)0x7b5a, (q15_t)0x17f2, (q15_t)0x7b5f, (q15_t)0x17e7, (q15_t)0x7b63, (q15_t)0x17db, (q15_t)0x7b68, (q15_t)0x17cf, - (q15_t)0x7b6d, (q15_t)0x17c4, (q15_t)0x7b71, (q15_t)0x17b8, (q15_t)0x7b76, (q15_t)0x17ac, (q15_t)0x7b7b, (q15_t)0x17a1, - (q15_t)0x7b7f, (q15_t)0x1795, (q15_t)0x7b84, (q15_t)0x1789, (q15_t)0x7b88, (q15_t)0x177e, (q15_t)0x7b8d, (q15_t)0x1772, - (q15_t)0x7b92, (q15_t)0x1766, (q15_t)0x7b96, (q15_t)0x175b, (q15_t)0x7b9b, (q15_t)0x174f, (q15_t)0x7b9f, (q15_t)0x1743, - (q15_t)0x7ba4, (q15_t)0x1737, (q15_t)0x7ba9, (q15_t)0x172c, (q15_t)0x7bad, (q15_t)0x1720, (q15_t)0x7bb2, (q15_t)0x1714, - (q15_t)0x7bb6, (q15_t)0x1709, (q15_t)0x7bbb, (q15_t)0x16fd, (q15_t)0x7bbf, (q15_t)0x16f1, (q15_t)0x7bc4, (q15_t)0x16e5, - (q15_t)0x7bc8, (q15_t)0x16da, (q15_t)0x7bcd, (q15_t)0x16ce, (q15_t)0x7bd1, (q15_t)0x16c2, (q15_t)0x7bd6, (q15_t)0x16b6, - (q15_t)0x7bda, (q15_t)0x16ab, (q15_t)0x7bde, (q15_t)0x169f, (q15_t)0x7be3, (q15_t)0x1693, (q15_t)0x7be7, (q15_t)0x1687, - (q15_t)0x7bec, (q15_t)0x167c, (q15_t)0x7bf0, (q15_t)0x1670, (q15_t)0x7bf5, (q15_t)0x1664, (q15_t)0x7bf9, (q15_t)0x1658, - (q15_t)0x7bfd, (q15_t)0x164c, (q15_t)0x7c02, (q15_t)0x1641, (q15_t)0x7c06, (q15_t)0x1635, (q15_t)0x7c0a, (q15_t)0x1629, - (q15_t)0x7c0f, (q15_t)0x161d, (q15_t)0x7c13, (q15_t)0x1612, (q15_t)0x7c17, (q15_t)0x1606, (q15_t)0x7c1c, (q15_t)0x15fa, - (q15_t)0x7c20, (q15_t)0x15ee, (q15_t)0x7c24, (q15_t)0x15e2, (q15_t)0x7c29, (q15_t)0x15d7, (q15_t)0x7c2d, (q15_t)0x15cb, - (q15_t)0x7c31, (q15_t)0x15bf, (q15_t)0x7c36, (q15_t)0x15b3, (q15_t)0x7c3a, (q15_t)0x15a7, (q15_t)0x7c3e, (q15_t)0x159b, - (q15_t)0x7c42, (q15_t)0x1590, (q15_t)0x7c46, (q15_t)0x1584, (q15_t)0x7c4b, (q15_t)0x1578, (q15_t)0x7c4f, (q15_t)0x156c, - (q15_t)0x7c53, (q15_t)0x1560, (q15_t)0x7c57, (q15_t)0x1554, (q15_t)0x7c5b, (q15_t)0x1549, (q15_t)0x7c60, (q15_t)0x153d, - (q15_t)0x7c64, (q15_t)0x1531, (q15_t)0x7c68, (q15_t)0x1525, (q15_t)0x7c6c, (q15_t)0x1519, (q15_t)0x7c70, (q15_t)0x150d, - (q15_t)0x7c74, (q15_t)0x1501, (q15_t)0x7c79, (q15_t)0x14f6, (q15_t)0x7c7d, (q15_t)0x14ea, (q15_t)0x7c81, (q15_t)0x14de, - (q15_t)0x7c85, (q15_t)0x14d2, (q15_t)0x7c89, (q15_t)0x14c6, (q15_t)0x7c8d, (q15_t)0x14ba, (q15_t)0x7c91, (q15_t)0x14ae, - (q15_t)0x7c95, (q15_t)0x14a2, (q15_t)0x7c99, (q15_t)0x1496, (q15_t)0x7c9d, (q15_t)0x148b, (q15_t)0x7ca1, (q15_t)0x147f, - (q15_t)0x7ca5, (q15_t)0x1473, (q15_t)0x7ca9, (q15_t)0x1467, (q15_t)0x7cad, (q15_t)0x145b, (q15_t)0x7cb1, (q15_t)0x144f, - (q15_t)0x7cb5, (q15_t)0x1443, (q15_t)0x7cb9, (q15_t)0x1437, (q15_t)0x7cbd, (q15_t)0x142b, (q15_t)0x7cc1, (q15_t)0x141f, - (q15_t)0x7cc5, (q15_t)0x1413, (q15_t)0x7cc9, (q15_t)0x1407, (q15_t)0x7ccd, (q15_t)0x13fb, (q15_t)0x7cd1, (q15_t)0x13f0, - (q15_t)0x7cd5, (q15_t)0x13e4, (q15_t)0x7cd9, (q15_t)0x13d8, (q15_t)0x7cdd, (q15_t)0x13cc, (q15_t)0x7ce0, (q15_t)0x13c0, - (q15_t)0x7ce4, (q15_t)0x13b4, (q15_t)0x7ce8, (q15_t)0x13a8, (q15_t)0x7cec, (q15_t)0x139c, (q15_t)0x7cf0, (q15_t)0x1390, - (q15_t)0x7cf4, (q15_t)0x1384, (q15_t)0x7cf8, (q15_t)0x1378, (q15_t)0x7cfb, (q15_t)0x136c, (q15_t)0x7cff, (q15_t)0x1360, - (q15_t)0x7d03, (q15_t)0x1354, (q15_t)0x7d07, (q15_t)0x1348, (q15_t)0x7d0b, (q15_t)0x133c, (q15_t)0x7d0e, (q15_t)0x1330, - (q15_t)0x7d12, (q15_t)0x1324, (q15_t)0x7d16, (q15_t)0x1318, (q15_t)0x7d1a, (q15_t)0x130c, (q15_t)0x7d1d, (q15_t)0x1300, - (q15_t)0x7d21, (q15_t)0x12f4, (q15_t)0x7d25, (q15_t)0x12e8, (q15_t)0x7d28, (q15_t)0x12dc, (q15_t)0x7d2c, (q15_t)0x12d0, - (q15_t)0x7d30, (q15_t)0x12c4, (q15_t)0x7d34, (q15_t)0x12b8, (q15_t)0x7d37, (q15_t)0x12ac, (q15_t)0x7d3b, (q15_t)0x12a0, - (q15_t)0x7d3f, (q15_t)0x1294, (q15_t)0x7d42, (q15_t)0x1288, (q15_t)0x7d46, (q15_t)0x127c, (q15_t)0x7d49, (q15_t)0x1270, - (q15_t)0x7d4d, (q15_t)0x1264, (q15_t)0x7d51, (q15_t)0x1258, (q15_t)0x7d54, (q15_t)0x124c, (q15_t)0x7d58, (q15_t)0x1240, - (q15_t)0x7d5b, (q15_t)0x1234, (q15_t)0x7d5f, (q15_t)0x1228, (q15_t)0x7d63, (q15_t)0x121c, (q15_t)0x7d66, (q15_t)0x1210, - (q15_t)0x7d6a, (q15_t)0x1204, (q15_t)0x7d6d, (q15_t)0x11f7, (q15_t)0x7d71, (q15_t)0x11eb, (q15_t)0x7d74, (q15_t)0x11df, - (q15_t)0x7d78, (q15_t)0x11d3, (q15_t)0x7d7b, (q15_t)0x11c7, (q15_t)0x7d7f, (q15_t)0x11bb, (q15_t)0x7d82, (q15_t)0x11af, - (q15_t)0x7d86, (q15_t)0x11a3, (q15_t)0x7d89, (q15_t)0x1197, (q15_t)0x7d8d, (q15_t)0x118b, (q15_t)0x7d90, (q15_t)0x117f, - (q15_t)0x7d93, (q15_t)0x1173, (q15_t)0x7d97, (q15_t)0x1167, (q15_t)0x7d9a, (q15_t)0x115a, (q15_t)0x7d9e, (q15_t)0x114e, - (q15_t)0x7da1, (q15_t)0x1142, (q15_t)0x7da4, (q15_t)0x1136, (q15_t)0x7da8, (q15_t)0x112a, (q15_t)0x7dab, (q15_t)0x111e, - (q15_t)0x7daf, (q15_t)0x1112, (q15_t)0x7db2, (q15_t)0x1106, (q15_t)0x7db5, (q15_t)0x10fa, (q15_t)0x7db9, (q15_t)0x10ed, - (q15_t)0x7dbc, (q15_t)0x10e1, (q15_t)0x7dbf, (q15_t)0x10d5, (q15_t)0x7dc2, (q15_t)0x10c9, (q15_t)0x7dc6, (q15_t)0x10bd, - (q15_t)0x7dc9, (q15_t)0x10b1, (q15_t)0x7dcc, (q15_t)0x10a5, (q15_t)0x7dd0, (q15_t)0x1099, (q15_t)0x7dd3, (q15_t)0x108c, - (q15_t)0x7dd6, (q15_t)0x1080, (q15_t)0x7dd9, (q15_t)0x1074, (q15_t)0x7ddd, (q15_t)0x1068, (q15_t)0x7de0, (q15_t)0x105c, - (q15_t)0x7de3, (q15_t)0x1050, (q15_t)0x7de6, (q15_t)0x1044, (q15_t)0x7de9, (q15_t)0x1037, (q15_t)0x7ded, (q15_t)0x102b, - (q15_t)0x7df0, (q15_t)0x101f, (q15_t)0x7df3, (q15_t)0x1013, (q15_t)0x7df6, (q15_t)0x1007, (q15_t)0x7df9, (q15_t)0xffb, - (q15_t)0x7dfc, (q15_t)0xfee, (q15_t)0x7dff, (q15_t)0xfe2, (q15_t)0x7e03, (q15_t)0xfd6, (q15_t)0x7e06, (q15_t)0xfca, - (q15_t)0x7e09, (q15_t)0xfbe, (q15_t)0x7e0c, (q15_t)0xfb2, (q15_t)0x7e0f, (q15_t)0xfa5, (q15_t)0x7e12, (q15_t)0xf99, - (q15_t)0x7e15, (q15_t)0xf8d, (q15_t)0x7e18, (q15_t)0xf81, (q15_t)0x7e1b, (q15_t)0xf75, (q15_t)0x7e1e, (q15_t)0xf68, - (q15_t)0x7e21, (q15_t)0xf5c, (q15_t)0x7e24, (q15_t)0xf50, (q15_t)0x7e27, (q15_t)0xf44, (q15_t)0x7e2a, (q15_t)0xf38, - (q15_t)0x7e2d, (q15_t)0xf2b, (q15_t)0x7e30, (q15_t)0xf1f, (q15_t)0x7e33, (q15_t)0xf13, (q15_t)0x7e36, (q15_t)0xf07, - (q15_t)0x7e39, (q15_t)0xefb, (q15_t)0x7e3c, (q15_t)0xeee, (q15_t)0x7e3f, (q15_t)0xee2, (q15_t)0x7e42, (q15_t)0xed6, - (q15_t)0x7e45, (q15_t)0xeca, (q15_t)0x7e48, (q15_t)0xebd, (q15_t)0x7e4a, (q15_t)0xeb1, (q15_t)0x7e4d, (q15_t)0xea5, - (q15_t)0x7e50, (q15_t)0xe99, (q15_t)0x7e53, (q15_t)0xe8c, (q15_t)0x7e56, (q15_t)0xe80, (q15_t)0x7e59, (q15_t)0xe74, - (q15_t)0x7e5c, (q15_t)0xe68, (q15_t)0x7e5e, (q15_t)0xe5c, (q15_t)0x7e61, (q15_t)0xe4f, (q15_t)0x7e64, (q15_t)0xe43, - (q15_t)0x7e67, (q15_t)0xe37, (q15_t)0x7e6a, (q15_t)0xe2b, (q15_t)0x7e6c, (q15_t)0xe1e, (q15_t)0x7e6f, (q15_t)0xe12, - (q15_t)0x7e72, (q15_t)0xe06, (q15_t)0x7e75, (q15_t)0xdf9, (q15_t)0x7e77, (q15_t)0xded, (q15_t)0x7e7a, (q15_t)0xde1, - (q15_t)0x7e7d, (q15_t)0xdd5, (q15_t)0x7e80, (q15_t)0xdc8, (q15_t)0x7e82, (q15_t)0xdbc, (q15_t)0x7e85, (q15_t)0xdb0, - (q15_t)0x7e88, (q15_t)0xda4, (q15_t)0x7e8a, (q15_t)0xd97, (q15_t)0x7e8d, (q15_t)0xd8b, (q15_t)0x7e90, (q15_t)0xd7f, - (q15_t)0x7e92, (q15_t)0xd72, (q15_t)0x7e95, (q15_t)0xd66, (q15_t)0x7e98, (q15_t)0xd5a, (q15_t)0x7e9a, (q15_t)0xd4e, - (q15_t)0x7e9d, (q15_t)0xd41, (q15_t)0x7e9f, (q15_t)0xd35, (q15_t)0x7ea2, (q15_t)0xd29, (q15_t)0x7ea5, (q15_t)0xd1c, - (q15_t)0x7ea7, (q15_t)0xd10, (q15_t)0x7eaa, (q15_t)0xd04, (q15_t)0x7eac, (q15_t)0xcf8, (q15_t)0x7eaf, (q15_t)0xceb, - (q15_t)0x7eb1, (q15_t)0xcdf, (q15_t)0x7eb4, (q15_t)0xcd3, (q15_t)0x7eb6, (q15_t)0xcc6, (q15_t)0x7eb9, (q15_t)0xcba, - (q15_t)0x7ebb, (q15_t)0xcae, (q15_t)0x7ebe, (q15_t)0xca1, (q15_t)0x7ec0, (q15_t)0xc95, (q15_t)0x7ec3, (q15_t)0xc89, - (q15_t)0x7ec5, (q15_t)0xc7c, (q15_t)0x7ec8, (q15_t)0xc70, (q15_t)0x7eca, (q15_t)0xc64, (q15_t)0x7ecc, (q15_t)0xc57, - (q15_t)0x7ecf, (q15_t)0xc4b, (q15_t)0x7ed1, (q15_t)0xc3f, (q15_t)0x7ed4, (q15_t)0xc32, (q15_t)0x7ed6, (q15_t)0xc26, - (q15_t)0x7ed8, (q15_t)0xc1a, (q15_t)0x7edb, (q15_t)0xc0d, (q15_t)0x7edd, (q15_t)0xc01, (q15_t)0x7ee0, (q15_t)0xbf5, - (q15_t)0x7ee2, (q15_t)0xbe8, (q15_t)0x7ee4, (q15_t)0xbdc, (q15_t)0x7ee7, (q15_t)0xbd0, (q15_t)0x7ee9, (q15_t)0xbc3, - (q15_t)0x7eeb, (q15_t)0xbb7, (q15_t)0x7eed, (q15_t)0xbab, (q15_t)0x7ef0, (q15_t)0xb9e, (q15_t)0x7ef2, (q15_t)0xb92, - (q15_t)0x7ef4, (q15_t)0xb85, (q15_t)0x7ef7, (q15_t)0xb79, (q15_t)0x7ef9, (q15_t)0xb6d, (q15_t)0x7efb, (q15_t)0xb60, - (q15_t)0x7efd, (q15_t)0xb54, (q15_t)0x7f00, (q15_t)0xb48, (q15_t)0x7f02, (q15_t)0xb3b, (q15_t)0x7f04, (q15_t)0xb2f, - (q15_t)0x7f06, (q15_t)0xb23, (q15_t)0x7f08, (q15_t)0xb16, (q15_t)0x7f0a, (q15_t)0xb0a, (q15_t)0x7f0d, (q15_t)0xafd, - (q15_t)0x7f0f, (q15_t)0xaf1, (q15_t)0x7f11, (q15_t)0xae5, (q15_t)0x7f13, (q15_t)0xad8, (q15_t)0x7f15, (q15_t)0xacc, - (q15_t)0x7f17, (q15_t)0xac0, (q15_t)0x7f19, (q15_t)0xab3, (q15_t)0x7f1c, (q15_t)0xaa7, (q15_t)0x7f1e, (q15_t)0xa9a, - (q15_t)0x7f20, (q15_t)0xa8e, (q15_t)0x7f22, (q15_t)0xa82, (q15_t)0x7f24, (q15_t)0xa75, (q15_t)0x7f26, (q15_t)0xa69, - (q15_t)0x7f28, (q15_t)0xa5c, (q15_t)0x7f2a, (q15_t)0xa50, (q15_t)0x7f2c, (q15_t)0xa44, (q15_t)0x7f2e, (q15_t)0xa37, - (q15_t)0x7f30, (q15_t)0xa2b, (q15_t)0x7f32, (q15_t)0xa1e, (q15_t)0x7f34, (q15_t)0xa12, (q15_t)0x7f36, (q15_t)0xa06, - (q15_t)0x7f38, (q15_t)0x9f9, (q15_t)0x7f3a, (q15_t)0x9ed, (q15_t)0x7f3c, (q15_t)0x9e0, (q15_t)0x7f3e, (q15_t)0x9d4, - (q15_t)0x7f40, (q15_t)0x9c7, (q15_t)0x7f42, (q15_t)0x9bb, (q15_t)0x7f43, (q15_t)0x9af, (q15_t)0x7f45, (q15_t)0x9a2, - (q15_t)0x7f47, (q15_t)0x996, (q15_t)0x7f49, (q15_t)0x989, (q15_t)0x7f4b, (q15_t)0x97d, (q15_t)0x7f4d, (q15_t)0x970, - (q15_t)0x7f4f, (q15_t)0x964, (q15_t)0x7f51, (q15_t)0x958, (q15_t)0x7f52, (q15_t)0x94b, (q15_t)0x7f54, (q15_t)0x93f, - (q15_t)0x7f56, (q15_t)0x932, (q15_t)0x7f58, (q15_t)0x926, (q15_t)0x7f5a, (q15_t)0x919, (q15_t)0x7f5b, (q15_t)0x90d, - (q15_t)0x7f5d, (q15_t)0x901, (q15_t)0x7f5f, (q15_t)0x8f4, (q15_t)0x7f61, (q15_t)0x8e8, (q15_t)0x7f62, (q15_t)0x8db, - (q15_t)0x7f64, (q15_t)0x8cf, (q15_t)0x7f66, (q15_t)0x8c2, (q15_t)0x7f68, (q15_t)0x8b6, (q15_t)0x7f69, (q15_t)0x8a9, - (q15_t)0x7f6b, (q15_t)0x89d, (q15_t)0x7f6d, (q15_t)0x891, (q15_t)0x7f6e, (q15_t)0x884, (q15_t)0x7f70, (q15_t)0x878, - (q15_t)0x7f72, (q15_t)0x86b, (q15_t)0x7f73, (q15_t)0x85f, (q15_t)0x7f75, (q15_t)0x852, (q15_t)0x7f77, (q15_t)0x846, - (q15_t)0x7f78, (q15_t)0x839, (q15_t)0x7f7a, (q15_t)0x82d, (q15_t)0x7f7b, (q15_t)0x820, (q15_t)0x7f7d, (q15_t)0x814, - (q15_t)0x7f7f, (q15_t)0x807, (q15_t)0x7f80, (q15_t)0x7fb, (q15_t)0x7f82, (q15_t)0x7ef, (q15_t)0x7f83, (q15_t)0x7e2, - (q15_t)0x7f85, (q15_t)0x7d6, (q15_t)0x7f86, (q15_t)0x7c9, (q15_t)0x7f88, (q15_t)0x7bd, (q15_t)0x7f89, (q15_t)0x7b0, - (q15_t)0x7f8b, (q15_t)0x7a4, (q15_t)0x7f8c, (q15_t)0x797, (q15_t)0x7f8e, (q15_t)0x78b, (q15_t)0x7f8f, (q15_t)0x77e, - (q15_t)0x7f91, (q15_t)0x772, (q15_t)0x7f92, (q15_t)0x765, (q15_t)0x7f94, (q15_t)0x759, (q15_t)0x7f95, (q15_t)0x74c, - (q15_t)0x7f97, (q15_t)0x740, (q15_t)0x7f98, (q15_t)0x733, (q15_t)0x7f99, (q15_t)0x727, (q15_t)0x7f9b, (q15_t)0x71a, - (q15_t)0x7f9c, (q15_t)0x70e, (q15_t)0x7f9e, (q15_t)0x701, (q15_t)0x7f9f, (q15_t)0x6f5, (q15_t)0x7fa0, (q15_t)0x6e8, - (q15_t)0x7fa2, (q15_t)0x6dc, (q15_t)0x7fa3, (q15_t)0x6cf, (q15_t)0x7fa4, (q15_t)0x6c3, (q15_t)0x7fa6, (q15_t)0x6b6, - (q15_t)0x7fa7, (q15_t)0x6aa, (q15_t)0x7fa8, (q15_t)0x69d, (q15_t)0x7faa, (q15_t)0x691, (q15_t)0x7fab, (q15_t)0x684, - (q15_t)0x7fac, (q15_t)0x678, (q15_t)0x7fad, (q15_t)0x66b, (q15_t)0x7faf, (q15_t)0x65f, (q15_t)0x7fb0, (q15_t)0x652, - (q15_t)0x7fb1, (q15_t)0x646, (q15_t)0x7fb2, (q15_t)0x639, (q15_t)0x7fb4, (q15_t)0x62d, (q15_t)0x7fb5, (q15_t)0x620, - (q15_t)0x7fb6, (q15_t)0x614, (q15_t)0x7fb7, (q15_t)0x607, (q15_t)0x7fb8, (q15_t)0x5fb, (q15_t)0x7fb9, (q15_t)0x5ee, - (q15_t)0x7fbb, (q15_t)0x5e2, (q15_t)0x7fbc, (q15_t)0x5d5, (q15_t)0x7fbd, (q15_t)0x5c9, (q15_t)0x7fbe, (q15_t)0x5bc, - (q15_t)0x7fbf, (q15_t)0x5b0, (q15_t)0x7fc0, (q15_t)0x5a3, (q15_t)0x7fc1, (q15_t)0x597, (q15_t)0x7fc3, (q15_t)0x58a, - (q15_t)0x7fc4, (q15_t)0x57e, (q15_t)0x7fc5, (q15_t)0x571, (q15_t)0x7fc6, (q15_t)0x565, (q15_t)0x7fc7, (q15_t)0x558, - (q15_t)0x7fc8, (q15_t)0x54c, (q15_t)0x7fc9, (q15_t)0x53f, (q15_t)0x7fca, (q15_t)0x533, (q15_t)0x7fcb, (q15_t)0x526, - (q15_t)0x7fcc, (q15_t)0x51a, (q15_t)0x7fcd, (q15_t)0x50d, (q15_t)0x7fce, (q15_t)0x500, (q15_t)0x7fcf, (q15_t)0x4f4, - (q15_t)0x7fd0, (q15_t)0x4e7, (q15_t)0x7fd1, (q15_t)0x4db, (q15_t)0x7fd2, (q15_t)0x4ce, (q15_t)0x7fd3, (q15_t)0x4c2, - (q15_t)0x7fd4, (q15_t)0x4b5, (q15_t)0x7fd5, (q15_t)0x4a9, (q15_t)0x7fd5, (q15_t)0x49c, (q15_t)0x7fd6, (q15_t)0x490, - (q15_t)0x7fd7, (q15_t)0x483, (q15_t)0x7fd8, (q15_t)0x477, (q15_t)0x7fd9, (q15_t)0x46a, (q15_t)0x7fda, (q15_t)0x45e, - (q15_t)0x7fdb, (q15_t)0x451, (q15_t)0x7fdc, (q15_t)0x444, (q15_t)0x7fdc, (q15_t)0x438, (q15_t)0x7fdd, (q15_t)0x42b, - (q15_t)0x7fde, (q15_t)0x41f, (q15_t)0x7fdf, (q15_t)0x412, (q15_t)0x7fe0, (q15_t)0x406, (q15_t)0x7fe0, (q15_t)0x3f9, - (q15_t)0x7fe1, (q15_t)0x3ed, (q15_t)0x7fe2, (q15_t)0x3e0, (q15_t)0x7fe3, (q15_t)0x3d4, (q15_t)0x7fe3, (q15_t)0x3c7, - (q15_t)0x7fe4, (q15_t)0x3bb, (q15_t)0x7fe5, (q15_t)0x3ae, (q15_t)0x7fe6, (q15_t)0x3a1, (q15_t)0x7fe6, (q15_t)0x395, - (q15_t)0x7fe7, (q15_t)0x388, (q15_t)0x7fe8, (q15_t)0x37c, (q15_t)0x7fe8, (q15_t)0x36f, (q15_t)0x7fe9, (q15_t)0x363, - (q15_t)0x7fea, (q15_t)0x356, (q15_t)0x7fea, (q15_t)0x34a, (q15_t)0x7feb, (q15_t)0x33d, (q15_t)0x7fec, (q15_t)0x330, - (q15_t)0x7fec, (q15_t)0x324, (q15_t)0x7fed, (q15_t)0x317, (q15_t)0x7fed, (q15_t)0x30b, (q15_t)0x7fee, (q15_t)0x2fe, - (q15_t)0x7fef, (q15_t)0x2f2, (q15_t)0x7fef, (q15_t)0x2e5, (q15_t)0x7ff0, (q15_t)0x2d9, (q15_t)0x7ff0, (q15_t)0x2cc, - (q15_t)0x7ff1, (q15_t)0x2c0, (q15_t)0x7ff1, (q15_t)0x2b3, (q15_t)0x7ff2, (q15_t)0x2a6, (q15_t)0x7ff2, (q15_t)0x29a, - (q15_t)0x7ff3, (q15_t)0x28d, (q15_t)0x7ff3, (q15_t)0x281, (q15_t)0x7ff4, (q15_t)0x274, (q15_t)0x7ff4, (q15_t)0x268, - (q15_t)0x7ff5, (q15_t)0x25b, (q15_t)0x7ff5, (q15_t)0x24e, (q15_t)0x7ff6, (q15_t)0x242, (q15_t)0x7ff6, (q15_t)0x235, - (q15_t)0x7ff7, (q15_t)0x229, (q15_t)0x7ff7, (q15_t)0x21c, (q15_t)0x7ff7, (q15_t)0x210, (q15_t)0x7ff8, (q15_t)0x203, - (q15_t)0x7ff8, (q15_t)0x1f7, (q15_t)0x7ff9, (q15_t)0x1ea, (q15_t)0x7ff9, (q15_t)0x1dd, (q15_t)0x7ff9, (q15_t)0x1d1, - (q15_t)0x7ffa, (q15_t)0x1c4, (q15_t)0x7ffa, (q15_t)0x1b8, (q15_t)0x7ffa, (q15_t)0x1ab, (q15_t)0x7ffb, (q15_t)0x19f, - (q15_t)0x7ffb, (q15_t)0x192, (q15_t)0x7ffb, (q15_t)0x186, (q15_t)0x7ffc, (q15_t)0x179, (q15_t)0x7ffc, (q15_t)0x16c, - (q15_t)0x7ffc, (q15_t)0x160, (q15_t)0x7ffc, (q15_t)0x153, (q15_t)0x7ffd, (q15_t)0x147, (q15_t)0x7ffd, (q15_t)0x13a, - (q15_t)0x7ffd, (q15_t)0x12e, (q15_t)0x7ffd, (q15_t)0x121, (q15_t)0x7ffe, (q15_t)0x114, (q15_t)0x7ffe, (q15_t)0x108, - (q15_t)0x7ffe, (q15_t)0xfb, (q15_t)0x7ffe, (q15_t)0xef, (q15_t)0x7ffe, (q15_t)0xe2, (q15_t)0x7fff, (q15_t)0xd6, - (q15_t)0x7fff, (q15_t)0xc9, (q15_t)0x7fff, (q15_t)0xbc, (q15_t)0x7fff, (q15_t)0xb0, (q15_t)0x7fff, (q15_t)0xa3, - (q15_t)0x7fff, (q15_t)0x97, (q15_t)0x7fff, (q15_t)0x8a, (q15_t)0x7fff, (q15_t)0x7e, (q15_t)0x7fff, (q15_t)0x71, - (q15_t)0x7fff, (q15_t)0x65, (q15_t)0x7fff, (q15_t)0x58, (q15_t)0x7fff, (q15_t)0x4b, (q15_t)0x7fff, (q15_t)0x3f, - (q15_t)0x7fff, (q15_t)0x32, (q15_t)0x7fff, (q15_t)0x26, (q15_t)0x7fff, (q15_t)0x19, (q15_t)0x7fff, (q15_t)0xd, - (q15_t)0x7fff, (q15_t)0x0, (q15_t)0x7fff, (q15_t)0xfff3, (q15_t)0x7fff, (q15_t)0xffe7, (q15_t)0x7fff, (q15_t)0xffda, - (q15_t)0x7fff, (q15_t)0xffce, (q15_t)0x7fff, (q15_t)0xffc1, (q15_t)0x7fff, (q15_t)0xffb5, (q15_t)0x7fff, (q15_t)0xffa8, - (q15_t)0x7fff, (q15_t)0xff9b, (q15_t)0x7fff, (q15_t)0xff8f, (q15_t)0x7fff, (q15_t)0xff82, (q15_t)0x7fff, (q15_t)0xff76, - (q15_t)0x7fff, (q15_t)0xff69, (q15_t)0x7fff, (q15_t)0xff5d, (q15_t)0x7fff, (q15_t)0xff50, (q15_t)0x7fff, (q15_t)0xff44, - (q15_t)0x7fff, (q15_t)0xff37, (q15_t)0x7fff, (q15_t)0xff2a, (q15_t)0x7ffe, (q15_t)0xff1e, (q15_t)0x7ffe, (q15_t)0xff11, - (q15_t)0x7ffe, (q15_t)0xff05, (q15_t)0x7ffe, (q15_t)0xfef8, (q15_t)0x7ffe, (q15_t)0xfeec, (q15_t)0x7ffd, (q15_t)0xfedf, - (q15_t)0x7ffd, (q15_t)0xfed2, (q15_t)0x7ffd, (q15_t)0xfec6, (q15_t)0x7ffd, (q15_t)0xfeb9, (q15_t)0x7ffc, (q15_t)0xfead, - (q15_t)0x7ffc, (q15_t)0xfea0, (q15_t)0x7ffc, (q15_t)0xfe94, (q15_t)0x7ffc, (q15_t)0xfe87, (q15_t)0x7ffb, (q15_t)0xfe7a, - (q15_t)0x7ffb, (q15_t)0xfe6e, (q15_t)0x7ffb, (q15_t)0xfe61, (q15_t)0x7ffa, (q15_t)0xfe55, (q15_t)0x7ffa, (q15_t)0xfe48, - (q15_t)0x7ffa, (q15_t)0xfe3c, (q15_t)0x7ff9, (q15_t)0xfe2f, (q15_t)0x7ff9, (q15_t)0xfe23, (q15_t)0x7ff9, (q15_t)0xfe16, - (q15_t)0x7ff8, (q15_t)0xfe09, (q15_t)0x7ff8, (q15_t)0xfdfd, (q15_t)0x7ff7, (q15_t)0xfdf0, (q15_t)0x7ff7, (q15_t)0xfde4, - (q15_t)0x7ff7, (q15_t)0xfdd7, (q15_t)0x7ff6, (q15_t)0xfdcb, (q15_t)0x7ff6, (q15_t)0xfdbe, (q15_t)0x7ff5, (q15_t)0xfdb2, - (q15_t)0x7ff5, (q15_t)0xfda5, (q15_t)0x7ff4, (q15_t)0xfd98, (q15_t)0x7ff4, (q15_t)0xfd8c, (q15_t)0x7ff3, (q15_t)0xfd7f, - (q15_t)0x7ff3, (q15_t)0xfd73, (q15_t)0x7ff2, (q15_t)0xfd66, (q15_t)0x7ff2, (q15_t)0xfd5a, (q15_t)0x7ff1, (q15_t)0xfd4d, - (q15_t)0x7ff1, (q15_t)0xfd40, (q15_t)0x7ff0, (q15_t)0xfd34, (q15_t)0x7ff0, (q15_t)0xfd27, (q15_t)0x7fef, (q15_t)0xfd1b, - (q15_t)0x7fef, (q15_t)0xfd0e, (q15_t)0x7fee, (q15_t)0xfd02, (q15_t)0x7fed, (q15_t)0xfcf5, (q15_t)0x7fed, (q15_t)0xfce9, - (q15_t)0x7fec, (q15_t)0xfcdc, (q15_t)0x7fec, (q15_t)0xfcd0, (q15_t)0x7feb, (q15_t)0xfcc3, (q15_t)0x7fea, (q15_t)0xfcb6, - (q15_t)0x7fea, (q15_t)0xfcaa, (q15_t)0x7fe9, (q15_t)0xfc9d, (q15_t)0x7fe8, (q15_t)0xfc91, (q15_t)0x7fe8, (q15_t)0xfc84, - (q15_t)0x7fe7, (q15_t)0xfc78, (q15_t)0x7fe6, (q15_t)0xfc6b, (q15_t)0x7fe6, (q15_t)0xfc5f, (q15_t)0x7fe5, (q15_t)0xfc52, - (q15_t)0x7fe4, (q15_t)0xfc45, (q15_t)0x7fe3, (q15_t)0xfc39, (q15_t)0x7fe3, (q15_t)0xfc2c, (q15_t)0x7fe2, (q15_t)0xfc20, - (q15_t)0x7fe1, (q15_t)0xfc13, (q15_t)0x7fe0, (q15_t)0xfc07, (q15_t)0x7fe0, (q15_t)0xfbfa, (q15_t)0x7fdf, (q15_t)0xfbee, - (q15_t)0x7fde, (q15_t)0xfbe1, (q15_t)0x7fdd, (q15_t)0xfbd5, (q15_t)0x7fdc, (q15_t)0xfbc8, (q15_t)0x7fdc, (q15_t)0xfbbc, - (q15_t)0x7fdb, (q15_t)0xfbaf, (q15_t)0x7fda, (q15_t)0xfba2, (q15_t)0x7fd9, (q15_t)0xfb96, (q15_t)0x7fd8, (q15_t)0xfb89, - (q15_t)0x7fd7, (q15_t)0xfb7d, (q15_t)0x7fd6, (q15_t)0xfb70, (q15_t)0x7fd5, (q15_t)0xfb64, (q15_t)0x7fd5, (q15_t)0xfb57, - (q15_t)0x7fd4, (q15_t)0xfb4b, (q15_t)0x7fd3, (q15_t)0xfb3e, (q15_t)0x7fd2, (q15_t)0xfb32, (q15_t)0x7fd1, (q15_t)0xfb25, - (q15_t)0x7fd0, (q15_t)0xfb19, (q15_t)0x7fcf, (q15_t)0xfb0c, (q15_t)0x7fce, (q15_t)0xfb00, (q15_t)0x7fcd, (q15_t)0xfaf3, - (q15_t)0x7fcc, (q15_t)0xfae6, (q15_t)0x7fcb, (q15_t)0xfada, (q15_t)0x7fca, (q15_t)0xfacd, (q15_t)0x7fc9, (q15_t)0xfac1, - (q15_t)0x7fc8, (q15_t)0xfab4, (q15_t)0x7fc7, (q15_t)0xfaa8, (q15_t)0x7fc6, (q15_t)0xfa9b, (q15_t)0x7fc5, (q15_t)0xfa8f, - (q15_t)0x7fc4, (q15_t)0xfa82, (q15_t)0x7fc3, (q15_t)0xfa76, (q15_t)0x7fc1, (q15_t)0xfa69, (q15_t)0x7fc0, (q15_t)0xfa5d, - (q15_t)0x7fbf, (q15_t)0xfa50, (q15_t)0x7fbe, (q15_t)0xfa44, (q15_t)0x7fbd, (q15_t)0xfa37, (q15_t)0x7fbc, (q15_t)0xfa2b, - (q15_t)0x7fbb, (q15_t)0xfa1e, (q15_t)0x7fb9, (q15_t)0xfa12, (q15_t)0x7fb8, (q15_t)0xfa05, (q15_t)0x7fb7, (q15_t)0xf9f9, - (q15_t)0x7fb6, (q15_t)0xf9ec, (q15_t)0x7fb5, (q15_t)0xf9e0, (q15_t)0x7fb4, (q15_t)0xf9d3, (q15_t)0x7fb2, (q15_t)0xf9c7, - (q15_t)0x7fb1, (q15_t)0xf9ba, (q15_t)0x7fb0, (q15_t)0xf9ae, (q15_t)0x7faf, (q15_t)0xf9a1, (q15_t)0x7fad, (q15_t)0xf995, - (q15_t)0x7fac, (q15_t)0xf988, (q15_t)0x7fab, (q15_t)0xf97c, (q15_t)0x7faa, (q15_t)0xf96f, (q15_t)0x7fa8, (q15_t)0xf963, - (q15_t)0x7fa7, (q15_t)0xf956, (q15_t)0x7fa6, (q15_t)0xf94a, (q15_t)0x7fa4, (q15_t)0xf93d, (q15_t)0x7fa3, (q15_t)0xf931, - (q15_t)0x7fa2, (q15_t)0xf924, (q15_t)0x7fa0, (q15_t)0xf918, (q15_t)0x7f9f, (q15_t)0xf90b, (q15_t)0x7f9e, (q15_t)0xf8ff, - (q15_t)0x7f9c, (q15_t)0xf8f2, (q15_t)0x7f9b, (q15_t)0xf8e6, (q15_t)0x7f99, (q15_t)0xf8d9, (q15_t)0x7f98, (q15_t)0xf8cd, - (q15_t)0x7f97, (q15_t)0xf8c0, (q15_t)0x7f95, (q15_t)0xf8b4, (q15_t)0x7f94, (q15_t)0xf8a7, (q15_t)0x7f92, (q15_t)0xf89b, - (q15_t)0x7f91, (q15_t)0xf88e, (q15_t)0x7f8f, (q15_t)0xf882, (q15_t)0x7f8e, (q15_t)0xf875, (q15_t)0x7f8c, (q15_t)0xf869, - (q15_t)0x7f8b, (q15_t)0xf85c, (q15_t)0x7f89, (q15_t)0xf850, (q15_t)0x7f88, (q15_t)0xf843, (q15_t)0x7f86, (q15_t)0xf837, - (q15_t)0x7f85, (q15_t)0xf82a, (q15_t)0x7f83, (q15_t)0xf81e, (q15_t)0x7f82, (q15_t)0xf811, (q15_t)0x7f80, (q15_t)0xf805, - (q15_t)0x7f7f, (q15_t)0xf7f9, (q15_t)0x7f7d, (q15_t)0xf7ec, (q15_t)0x7f7b, (q15_t)0xf7e0, (q15_t)0x7f7a, (q15_t)0xf7d3, - (q15_t)0x7f78, (q15_t)0xf7c7, (q15_t)0x7f77, (q15_t)0xf7ba, (q15_t)0x7f75, (q15_t)0xf7ae, (q15_t)0x7f73, (q15_t)0xf7a1, - (q15_t)0x7f72, (q15_t)0xf795, (q15_t)0x7f70, (q15_t)0xf788, (q15_t)0x7f6e, (q15_t)0xf77c, (q15_t)0x7f6d, (q15_t)0xf76f, - (q15_t)0x7f6b, (q15_t)0xf763, (q15_t)0x7f69, (q15_t)0xf757, (q15_t)0x7f68, (q15_t)0xf74a, (q15_t)0x7f66, (q15_t)0xf73e, - (q15_t)0x7f64, (q15_t)0xf731, (q15_t)0x7f62, (q15_t)0xf725, (q15_t)0x7f61, (q15_t)0xf718, (q15_t)0x7f5f, (q15_t)0xf70c, - (q15_t)0x7f5d, (q15_t)0xf6ff, (q15_t)0x7f5b, (q15_t)0xf6f3, (q15_t)0x7f5a, (q15_t)0xf6e7, (q15_t)0x7f58, (q15_t)0xf6da, - (q15_t)0x7f56, (q15_t)0xf6ce, (q15_t)0x7f54, (q15_t)0xf6c1, (q15_t)0x7f52, (q15_t)0xf6b5, (q15_t)0x7f51, (q15_t)0xf6a8, - (q15_t)0x7f4f, (q15_t)0xf69c, (q15_t)0x7f4d, (q15_t)0xf690, (q15_t)0x7f4b, (q15_t)0xf683, (q15_t)0x7f49, (q15_t)0xf677, - (q15_t)0x7f47, (q15_t)0xf66a, (q15_t)0x7f45, (q15_t)0xf65e, (q15_t)0x7f43, (q15_t)0xf651, (q15_t)0x7f42, (q15_t)0xf645, - (q15_t)0x7f40, (q15_t)0xf639, (q15_t)0x7f3e, (q15_t)0xf62c, (q15_t)0x7f3c, (q15_t)0xf620, (q15_t)0x7f3a, (q15_t)0xf613, - (q15_t)0x7f38, (q15_t)0xf607, (q15_t)0x7f36, (q15_t)0xf5fa, (q15_t)0x7f34, (q15_t)0xf5ee, (q15_t)0x7f32, (q15_t)0xf5e2, - (q15_t)0x7f30, (q15_t)0xf5d5, (q15_t)0x7f2e, (q15_t)0xf5c9, (q15_t)0x7f2c, (q15_t)0xf5bc, (q15_t)0x7f2a, (q15_t)0xf5b0, - (q15_t)0x7f28, (q15_t)0xf5a4, (q15_t)0x7f26, (q15_t)0xf597, (q15_t)0x7f24, (q15_t)0xf58b, (q15_t)0x7f22, (q15_t)0xf57e, - (q15_t)0x7f20, (q15_t)0xf572, (q15_t)0x7f1e, (q15_t)0xf566, (q15_t)0x7f1c, (q15_t)0xf559, (q15_t)0x7f19, (q15_t)0xf54d, - (q15_t)0x7f17, (q15_t)0xf540, (q15_t)0x7f15, (q15_t)0xf534, (q15_t)0x7f13, (q15_t)0xf528, (q15_t)0x7f11, (q15_t)0xf51b, - (q15_t)0x7f0f, (q15_t)0xf50f, (q15_t)0x7f0d, (q15_t)0xf503, (q15_t)0x7f0a, (q15_t)0xf4f6, (q15_t)0x7f08, (q15_t)0xf4ea, - (q15_t)0x7f06, (q15_t)0xf4dd, (q15_t)0x7f04, (q15_t)0xf4d1, (q15_t)0x7f02, (q15_t)0xf4c5, (q15_t)0x7f00, (q15_t)0xf4b8, - (q15_t)0x7efd, (q15_t)0xf4ac, (q15_t)0x7efb, (q15_t)0xf4a0, (q15_t)0x7ef9, (q15_t)0xf493, (q15_t)0x7ef7, (q15_t)0xf487, - (q15_t)0x7ef4, (q15_t)0xf47b, (q15_t)0x7ef2, (q15_t)0xf46e, (q15_t)0x7ef0, (q15_t)0xf462, (q15_t)0x7eed, (q15_t)0xf455, - (q15_t)0x7eeb, (q15_t)0xf449, (q15_t)0x7ee9, (q15_t)0xf43d, (q15_t)0x7ee7, (q15_t)0xf430, (q15_t)0x7ee4, (q15_t)0xf424, - (q15_t)0x7ee2, (q15_t)0xf418, (q15_t)0x7ee0, (q15_t)0xf40b, (q15_t)0x7edd, (q15_t)0xf3ff, (q15_t)0x7edb, (q15_t)0xf3f3, - (q15_t)0x7ed8, (q15_t)0xf3e6, (q15_t)0x7ed6, (q15_t)0xf3da, (q15_t)0x7ed4, (q15_t)0xf3ce, (q15_t)0x7ed1, (q15_t)0xf3c1, - (q15_t)0x7ecf, (q15_t)0xf3b5, (q15_t)0x7ecc, (q15_t)0xf3a9, (q15_t)0x7eca, (q15_t)0xf39c, (q15_t)0x7ec8, (q15_t)0xf390, - (q15_t)0x7ec5, (q15_t)0xf384, (q15_t)0x7ec3, (q15_t)0xf377, (q15_t)0x7ec0, (q15_t)0xf36b, (q15_t)0x7ebe, (q15_t)0xf35f, - (q15_t)0x7ebb, (q15_t)0xf352, (q15_t)0x7eb9, (q15_t)0xf346, (q15_t)0x7eb6, (q15_t)0xf33a, (q15_t)0x7eb4, (q15_t)0xf32d, - (q15_t)0x7eb1, (q15_t)0xf321, (q15_t)0x7eaf, (q15_t)0xf315, (q15_t)0x7eac, (q15_t)0xf308, (q15_t)0x7eaa, (q15_t)0xf2fc, - (q15_t)0x7ea7, (q15_t)0xf2f0, (q15_t)0x7ea5, (q15_t)0xf2e4, (q15_t)0x7ea2, (q15_t)0xf2d7, (q15_t)0x7e9f, (q15_t)0xf2cb, - (q15_t)0x7e9d, (q15_t)0xf2bf, (q15_t)0x7e9a, (q15_t)0xf2b2, (q15_t)0x7e98, (q15_t)0xf2a6, (q15_t)0x7e95, (q15_t)0xf29a, - (q15_t)0x7e92, (q15_t)0xf28e, (q15_t)0x7e90, (q15_t)0xf281, (q15_t)0x7e8d, (q15_t)0xf275, (q15_t)0x7e8a, (q15_t)0xf269, - (q15_t)0x7e88, (q15_t)0xf25c, (q15_t)0x7e85, (q15_t)0xf250, (q15_t)0x7e82, (q15_t)0xf244, (q15_t)0x7e80, (q15_t)0xf238, - (q15_t)0x7e7d, (q15_t)0xf22b, (q15_t)0x7e7a, (q15_t)0xf21f, (q15_t)0x7e77, (q15_t)0xf213, (q15_t)0x7e75, (q15_t)0xf207, - (q15_t)0x7e72, (q15_t)0xf1fa, (q15_t)0x7e6f, (q15_t)0xf1ee, (q15_t)0x7e6c, (q15_t)0xf1e2, (q15_t)0x7e6a, (q15_t)0xf1d5, - (q15_t)0x7e67, (q15_t)0xf1c9, (q15_t)0x7e64, (q15_t)0xf1bd, (q15_t)0x7e61, (q15_t)0xf1b1, (q15_t)0x7e5e, (q15_t)0xf1a4, - (q15_t)0x7e5c, (q15_t)0xf198, (q15_t)0x7e59, (q15_t)0xf18c, (q15_t)0x7e56, (q15_t)0xf180, (q15_t)0x7e53, (q15_t)0xf174, - (q15_t)0x7e50, (q15_t)0xf167, (q15_t)0x7e4d, (q15_t)0xf15b, (q15_t)0x7e4a, (q15_t)0xf14f, (q15_t)0x7e48, (q15_t)0xf143, - (q15_t)0x7e45, (q15_t)0xf136, (q15_t)0x7e42, (q15_t)0xf12a, (q15_t)0x7e3f, (q15_t)0xf11e, (q15_t)0x7e3c, (q15_t)0xf112, - (q15_t)0x7e39, (q15_t)0xf105, (q15_t)0x7e36, (q15_t)0xf0f9, (q15_t)0x7e33, (q15_t)0xf0ed, (q15_t)0x7e30, (q15_t)0xf0e1, - (q15_t)0x7e2d, (q15_t)0xf0d5, (q15_t)0x7e2a, (q15_t)0xf0c8, (q15_t)0x7e27, (q15_t)0xf0bc, (q15_t)0x7e24, (q15_t)0xf0b0, - (q15_t)0x7e21, (q15_t)0xf0a4, (q15_t)0x7e1e, (q15_t)0xf098, (q15_t)0x7e1b, (q15_t)0xf08b, (q15_t)0x7e18, (q15_t)0xf07f, - (q15_t)0x7e15, (q15_t)0xf073, (q15_t)0x7e12, (q15_t)0xf067, (q15_t)0x7e0f, (q15_t)0xf05b, (q15_t)0x7e0c, (q15_t)0xf04e, - (q15_t)0x7e09, (q15_t)0xf042, (q15_t)0x7e06, (q15_t)0xf036, (q15_t)0x7e03, (q15_t)0xf02a, (q15_t)0x7dff, (q15_t)0xf01e, - (q15_t)0x7dfc, (q15_t)0xf012, (q15_t)0x7df9, (q15_t)0xf005, (q15_t)0x7df6, (q15_t)0xeff9, (q15_t)0x7df3, (q15_t)0xefed, - (q15_t)0x7df0, (q15_t)0xefe1, (q15_t)0x7ded, (q15_t)0xefd5, (q15_t)0x7de9, (q15_t)0xefc9, (q15_t)0x7de6, (q15_t)0xefbc, - (q15_t)0x7de3, (q15_t)0xefb0, (q15_t)0x7de0, (q15_t)0xefa4, (q15_t)0x7ddd, (q15_t)0xef98, (q15_t)0x7dd9, (q15_t)0xef8c, - (q15_t)0x7dd6, (q15_t)0xef80, (q15_t)0x7dd3, (q15_t)0xef74, (q15_t)0x7dd0, (q15_t)0xef67, (q15_t)0x7dcc, (q15_t)0xef5b, - (q15_t)0x7dc9, (q15_t)0xef4f, (q15_t)0x7dc6, (q15_t)0xef43, (q15_t)0x7dc2, (q15_t)0xef37, (q15_t)0x7dbf, (q15_t)0xef2b, - (q15_t)0x7dbc, (q15_t)0xef1f, (q15_t)0x7db9, (q15_t)0xef13, (q15_t)0x7db5, (q15_t)0xef06, (q15_t)0x7db2, (q15_t)0xeefa, - (q15_t)0x7daf, (q15_t)0xeeee, (q15_t)0x7dab, (q15_t)0xeee2, (q15_t)0x7da8, (q15_t)0xeed6, (q15_t)0x7da4, (q15_t)0xeeca, - (q15_t)0x7da1, (q15_t)0xeebe, (q15_t)0x7d9e, (q15_t)0xeeb2, (q15_t)0x7d9a, (q15_t)0xeea6, (q15_t)0x7d97, (q15_t)0xee99, - (q15_t)0x7d93, (q15_t)0xee8d, (q15_t)0x7d90, (q15_t)0xee81, (q15_t)0x7d8d, (q15_t)0xee75, (q15_t)0x7d89, (q15_t)0xee69, - (q15_t)0x7d86, (q15_t)0xee5d, (q15_t)0x7d82, (q15_t)0xee51, (q15_t)0x7d7f, (q15_t)0xee45, (q15_t)0x7d7b, (q15_t)0xee39, - (q15_t)0x7d78, (q15_t)0xee2d, (q15_t)0x7d74, (q15_t)0xee21, (q15_t)0x7d71, (q15_t)0xee15, (q15_t)0x7d6d, (q15_t)0xee09, - (q15_t)0x7d6a, (q15_t)0xedfc, (q15_t)0x7d66, (q15_t)0xedf0, (q15_t)0x7d63, (q15_t)0xede4, (q15_t)0x7d5f, (q15_t)0xedd8, - (q15_t)0x7d5b, (q15_t)0xedcc, (q15_t)0x7d58, (q15_t)0xedc0, (q15_t)0x7d54, (q15_t)0xedb4, (q15_t)0x7d51, (q15_t)0xeda8, - (q15_t)0x7d4d, (q15_t)0xed9c, (q15_t)0x7d49, (q15_t)0xed90, (q15_t)0x7d46, (q15_t)0xed84, (q15_t)0x7d42, (q15_t)0xed78, - (q15_t)0x7d3f, (q15_t)0xed6c, (q15_t)0x7d3b, (q15_t)0xed60, (q15_t)0x7d37, (q15_t)0xed54, (q15_t)0x7d34, (q15_t)0xed48, - (q15_t)0x7d30, (q15_t)0xed3c, (q15_t)0x7d2c, (q15_t)0xed30, (q15_t)0x7d28, (q15_t)0xed24, (q15_t)0x7d25, (q15_t)0xed18, - (q15_t)0x7d21, (q15_t)0xed0c, (q15_t)0x7d1d, (q15_t)0xed00, (q15_t)0x7d1a, (q15_t)0xecf4, (q15_t)0x7d16, (q15_t)0xece8, - (q15_t)0x7d12, (q15_t)0xecdc, (q15_t)0x7d0e, (q15_t)0xecd0, (q15_t)0x7d0b, (q15_t)0xecc4, (q15_t)0x7d07, (q15_t)0xecb8, - (q15_t)0x7d03, (q15_t)0xecac, (q15_t)0x7cff, (q15_t)0xeca0, (q15_t)0x7cfb, (q15_t)0xec94, (q15_t)0x7cf8, (q15_t)0xec88, - (q15_t)0x7cf4, (q15_t)0xec7c, (q15_t)0x7cf0, (q15_t)0xec70, (q15_t)0x7cec, (q15_t)0xec64, (q15_t)0x7ce8, (q15_t)0xec58, - (q15_t)0x7ce4, (q15_t)0xec4c, (q15_t)0x7ce0, (q15_t)0xec40, (q15_t)0x7cdd, (q15_t)0xec34, (q15_t)0x7cd9, (q15_t)0xec28, - (q15_t)0x7cd5, (q15_t)0xec1c, (q15_t)0x7cd1, (q15_t)0xec10, (q15_t)0x7ccd, (q15_t)0xec05, (q15_t)0x7cc9, (q15_t)0xebf9, - (q15_t)0x7cc5, (q15_t)0xebed, (q15_t)0x7cc1, (q15_t)0xebe1, (q15_t)0x7cbd, (q15_t)0xebd5, (q15_t)0x7cb9, (q15_t)0xebc9, - (q15_t)0x7cb5, (q15_t)0xebbd, (q15_t)0x7cb1, (q15_t)0xebb1, (q15_t)0x7cad, (q15_t)0xeba5, (q15_t)0x7ca9, (q15_t)0xeb99, - (q15_t)0x7ca5, (q15_t)0xeb8d, (q15_t)0x7ca1, (q15_t)0xeb81, (q15_t)0x7c9d, (q15_t)0xeb75, (q15_t)0x7c99, (q15_t)0xeb6a, - (q15_t)0x7c95, (q15_t)0xeb5e, (q15_t)0x7c91, (q15_t)0xeb52, (q15_t)0x7c8d, (q15_t)0xeb46, (q15_t)0x7c89, (q15_t)0xeb3a, - (q15_t)0x7c85, (q15_t)0xeb2e, (q15_t)0x7c81, (q15_t)0xeb22, (q15_t)0x7c7d, (q15_t)0xeb16, (q15_t)0x7c79, (q15_t)0xeb0a, - (q15_t)0x7c74, (q15_t)0xeaff, (q15_t)0x7c70, (q15_t)0xeaf3, (q15_t)0x7c6c, (q15_t)0xeae7, (q15_t)0x7c68, (q15_t)0xeadb, - (q15_t)0x7c64, (q15_t)0xeacf, (q15_t)0x7c60, (q15_t)0xeac3, (q15_t)0x7c5b, (q15_t)0xeab7, (q15_t)0x7c57, (q15_t)0xeaac, - (q15_t)0x7c53, (q15_t)0xeaa0, (q15_t)0x7c4f, (q15_t)0xea94, (q15_t)0x7c4b, (q15_t)0xea88, (q15_t)0x7c46, (q15_t)0xea7c, - (q15_t)0x7c42, (q15_t)0xea70, (q15_t)0x7c3e, (q15_t)0xea65, (q15_t)0x7c3a, (q15_t)0xea59, (q15_t)0x7c36, (q15_t)0xea4d, - (q15_t)0x7c31, (q15_t)0xea41, (q15_t)0x7c2d, (q15_t)0xea35, (q15_t)0x7c29, (q15_t)0xea29, (q15_t)0x7c24, (q15_t)0xea1e, - (q15_t)0x7c20, (q15_t)0xea12, (q15_t)0x7c1c, (q15_t)0xea06, (q15_t)0x7c17, (q15_t)0xe9fa, (q15_t)0x7c13, (q15_t)0xe9ee, - (q15_t)0x7c0f, (q15_t)0xe9e3, (q15_t)0x7c0a, (q15_t)0xe9d7, (q15_t)0x7c06, (q15_t)0xe9cb, (q15_t)0x7c02, (q15_t)0xe9bf, - (q15_t)0x7bfd, (q15_t)0xe9b4, (q15_t)0x7bf9, (q15_t)0xe9a8, (q15_t)0x7bf5, (q15_t)0xe99c, (q15_t)0x7bf0, (q15_t)0xe990, - (q15_t)0x7bec, (q15_t)0xe984, (q15_t)0x7be7, (q15_t)0xe979, (q15_t)0x7be3, (q15_t)0xe96d, (q15_t)0x7bde, (q15_t)0xe961, - (q15_t)0x7bda, (q15_t)0xe955, (q15_t)0x7bd6, (q15_t)0xe94a, (q15_t)0x7bd1, (q15_t)0xe93e, (q15_t)0x7bcd, (q15_t)0xe932, - (q15_t)0x7bc8, (q15_t)0xe926, (q15_t)0x7bc4, (q15_t)0xe91b, (q15_t)0x7bbf, (q15_t)0xe90f, (q15_t)0x7bbb, (q15_t)0xe903, - (q15_t)0x7bb6, (q15_t)0xe8f7, (q15_t)0x7bb2, (q15_t)0xe8ec, (q15_t)0x7bad, (q15_t)0xe8e0, (q15_t)0x7ba9, (q15_t)0xe8d4, - (q15_t)0x7ba4, (q15_t)0xe8c9, (q15_t)0x7b9f, (q15_t)0xe8bd, (q15_t)0x7b9b, (q15_t)0xe8b1, (q15_t)0x7b96, (q15_t)0xe8a5, - (q15_t)0x7b92, (q15_t)0xe89a, (q15_t)0x7b8d, (q15_t)0xe88e, (q15_t)0x7b88, (q15_t)0xe882, (q15_t)0x7b84, (q15_t)0xe877, - (q15_t)0x7b7f, (q15_t)0xe86b, (q15_t)0x7b7b, (q15_t)0xe85f, (q15_t)0x7b76, (q15_t)0xe854, (q15_t)0x7b71, (q15_t)0xe848, - (q15_t)0x7b6d, (q15_t)0xe83c, (q15_t)0x7b68, (q15_t)0xe831, (q15_t)0x7b63, (q15_t)0xe825, (q15_t)0x7b5f, (q15_t)0xe819, - (q15_t)0x7b5a, (q15_t)0xe80e, (q15_t)0x7b55, (q15_t)0xe802, (q15_t)0x7b50, (q15_t)0xe7f6, (q15_t)0x7b4c, (q15_t)0xe7eb, - (q15_t)0x7b47, (q15_t)0xe7df, (q15_t)0x7b42, (q15_t)0xe7d3, (q15_t)0x7b3e, (q15_t)0xe7c8, (q15_t)0x7b39, (q15_t)0xe7bc, - (q15_t)0x7b34, (q15_t)0xe7b1, (q15_t)0x7b2f, (q15_t)0xe7a5, (q15_t)0x7b2a, (q15_t)0xe799, (q15_t)0x7b26, (q15_t)0xe78e, - (q15_t)0x7b21, (q15_t)0xe782, (q15_t)0x7b1c, (q15_t)0xe777, (q15_t)0x7b17, (q15_t)0xe76b, (q15_t)0x7b12, (q15_t)0xe75f, - (q15_t)0x7b0e, (q15_t)0xe754, (q15_t)0x7b09, (q15_t)0xe748, (q15_t)0x7b04, (q15_t)0xe73d, (q15_t)0x7aff, (q15_t)0xe731, - (q15_t)0x7afa, (q15_t)0xe725, (q15_t)0x7af5, (q15_t)0xe71a, (q15_t)0x7af0, (q15_t)0xe70e, (q15_t)0x7aeb, (q15_t)0xe703, - (q15_t)0x7ae6, (q15_t)0xe6f7, (q15_t)0x7ae2, (q15_t)0xe6ec, (q15_t)0x7add, (q15_t)0xe6e0, (q15_t)0x7ad8, (q15_t)0xe6d4, - (q15_t)0x7ad3, (q15_t)0xe6c9, (q15_t)0x7ace, (q15_t)0xe6bd, (q15_t)0x7ac9, (q15_t)0xe6b2, (q15_t)0x7ac4, (q15_t)0xe6a6, - (q15_t)0x7abf, (q15_t)0xe69b, (q15_t)0x7aba, (q15_t)0xe68f, (q15_t)0x7ab5, (q15_t)0xe684, (q15_t)0x7ab0, (q15_t)0xe678, - (q15_t)0x7aab, (q15_t)0xe66d, (q15_t)0x7aa6, (q15_t)0xe661, (q15_t)0x7aa1, (q15_t)0xe656, (q15_t)0x7a9c, (q15_t)0xe64a, - (q15_t)0x7a97, (q15_t)0xe63f, (q15_t)0x7a92, (q15_t)0xe633, (q15_t)0x7a8d, (q15_t)0xe628, (q15_t)0x7a88, (q15_t)0xe61c, - (q15_t)0x7a82, (q15_t)0xe611, (q15_t)0x7a7d, (q15_t)0xe605, (q15_t)0x7a78, (q15_t)0xe5fa, (q15_t)0x7a73, (q15_t)0xe5ee, - (q15_t)0x7a6e, (q15_t)0xe5e3, (q15_t)0x7a69, (q15_t)0xe5d7, (q15_t)0x7a64, (q15_t)0xe5cc, (q15_t)0x7a5f, (q15_t)0xe5c0, - (q15_t)0x7a59, (q15_t)0xe5b5, (q15_t)0x7a54, (q15_t)0xe5a9, (q15_t)0x7a4f, (q15_t)0xe59e, (q15_t)0x7a4a, (q15_t)0xe592, - (q15_t)0x7a45, (q15_t)0xe587, (q15_t)0x7a3f, (q15_t)0xe57c, (q15_t)0x7a3a, (q15_t)0xe570, (q15_t)0x7a35, (q15_t)0xe565, - (q15_t)0x7a30, (q15_t)0xe559, (q15_t)0x7a2b, (q15_t)0xe54e, (q15_t)0x7a25, (q15_t)0xe542, (q15_t)0x7a20, (q15_t)0xe537, - (q15_t)0x7a1b, (q15_t)0xe52c, (q15_t)0x7a16, (q15_t)0xe520, (q15_t)0x7a10, (q15_t)0xe515, (q15_t)0x7a0b, (q15_t)0xe509, - (q15_t)0x7a06, (q15_t)0xe4fe, (q15_t)0x7a00, (q15_t)0xe4f3, (q15_t)0x79fb, (q15_t)0xe4e7, (q15_t)0x79f6, (q15_t)0xe4dc, - (q15_t)0x79f0, (q15_t)0xe4d0, (q15_t)0x79eb, (q15_t)0xe4c5, (q15_t)0x79e6, (q15_t)0xe4ba, (q15_t)0x79e0, (q15_t)0xe4ae, - (q15_t)0x79db, (q15_t)0xe4a3, (q15_t)0x79d6, (q15_t)0xe498, (q15_t)0x79d0, (q15_t)0xe48c, (q15_t)0x79cb, (q15_t)0xe481, - (q15_t)0x79c5, (q15_t)0xe476, (q15_t)0x79c0, (q15_t)0xe46a, (q15_t)0x79bb, (q15_t)0xe45f, (q15_t)0x79b5, (q15_t)0xe454, - (q15_t)0x79b0, (q15_t)0xe448, (q15_t)0x79aa, (q15_t)0xe43d, (q15_t)0x79a5, (q15_t)0xe432, (q15_t)0x799f, (q15_t)0xe426, - (q15_t)0x799a, (q15_t)0xe41b, (q15_t)0x7994, (q15_t)0xe410, (q15_t)0x798f, (q15_t)0xe404, (q15_t)0x7989, (q15_t)0xe3f9, - (q15_t)0x7984, (q15_t)0xe3ee, (q15_t)0x797e, (q15_t)0xe3e2, (q15_t)0x7979, (q15_t)0xe3d7, (q15_t)0x7973, (q15_t)0xe3cc, - (q15_t)0x796e, (q15_t)0xe3c1, (q15_t)0x7968, (q15_t)0xe3b5, (q15_t)0x7963, (q15_t)0xe3aa, (q15_t)0x795d, (q15_t)0xe39f, - (q15_t)0x7958, (q15_t)0xe394, (q15_t)0x7952, (q15_t)0xe388, (q15_t)0x794c, (q15_t)0xe37d, (q15_t)0x7947, (q15_t)0xe372, - (q15_t)0x7941, (q15_t)0xe367, (q15_t)0x793b, (q15_t)0xe35b, (q15_t)0x7936, (q15_t)0xe350, (q15_t)0x7930, (q15_t)0xe345, - (q15_t)0x792b, (q15_t)0xe33a, (q15_t)0x7925, (q15_t)0xe32e, (q15_t)0x791f, (q15_t)0xe323, (q15_t)0x791a, (q15_t)0xe318, - (q15_t)0x7914, (q15_t)0xe30d, (q15_t)0x790e, (q15_t)0xe301, (q15_t)0x7909, (q15_t)0xe2f6, (q15_t)0x7903, (q15_t)0xe2eb, - (q15_t)0x78fd, (q15_t)0xe2e0, (q15_t)0x78f7, (q15_t)0xe2d5, (q15_t)0x78f2, (q15_t)0xe2ca, (q15_t)0x78ec, (q15_t)0xe2be, - (q15_t)0x78e6, (q15_t)0xe2b3, (q15_t)0x78e0, (q15_t)0xe2a8, (q15_t)0x78db, (q15_t)0xe29d, (q15_t)0x78d5, (q15_t)0xe292, - (q15_t)0x78cf, (q15_t)0xe287, (q15_t)0x78c9, (q15_t)0xe27b, (q15_t)0x78c3, (q15_t)0xe270, (q15_t)0x78be, (q15_t)0xe265, - (q15_t)0x78b8, (q15_t)0xe25a, (q15_t)0x78b2, (q15_t)0xe24f, (q15_t)0x78ac, (q15_t)0xe244, (q15_t)0x78a6, (q15_t)0xe239, - (q15_t)0x78a1, (q15_t)0xe22d, (q15_t)0x789b, (q15_t)0xe222, (q15_t)0x7895, (q15_t)0xe217, (q15_t)0x788f, (q15_t)0xe20c, - (q15_t)0x7889, (q15_t)0xe201, (q15_t)0x7883, (q15_t)0xe1f6, (q15_t)0x787d, (q15_t)0xe1eb, (q15_t)0x7877, (q15_t)0xe1e0, - (q15_t)0x7871, (q15_t)0xe1d5, (q15_t)0x786b, (q15_t)0xe1ca, (q15_t)0x7866, (q15_t)0xe1be, (q15_t)0x7860, (q15_t)0xe1b3, - (q15_t)0x785a, (q15_t)0xe1a8, (q15_t)0x7854, (q15_t)0xe19d, (q15_t)0x784e, (q15_t)0xe192, (q15_t)0x7848, (q15_t)0xe187, - (q15_t)0x7842, (q15_t)0xe17c, (q15_t)0x783c, (q15_t)0xe171, (q15_t)0x7836, (q15_t)0xe166, (q15_t)0x7830, (q15_t)0xe15b, - (q15_t)0x782a, (q15_t)0xe150, (q15_t)0x7824, (q15_t)0xe145, (q15_t)0x781e, (q15_t)0xe13a, (q15_t)0x7818, (q15_t)0xe12f, - (q15_t)0x7812, (q15_t)0xe124, (q15_t)0x780b, (q15_t)0xe119, (q15_t)0x7805, (q15_t)0xe10e, (q15_t)0x77ff, (q15_t)0xe103, - (q15_t)0x77f9, (q15_t)0xe0f8, (q15_t)0x77f3, (q15_t)0xe0ed, (q15_t)0x77ed, (q15_t)0xe0e2, (q15_t)0x77e7, (q15_t)0xe0d7, - (q15_t)0x77e1, (q15_t)0xe0cc, (q15_t)0x77db, (q15_t)0xe0c1, (q15_t)0x77d5, (q15_t)0xe0b6, (q15_t)0x77ce, (q15_t)0xe0ab, - (q15_t)0x77c8, (q15_t)0xe0a0, (q15_t)0x77c2, (q15_t)0xe095, (q15_t)0x77bc, (q15_t)0xe08a, (q15_t)0x77b6, (q15_t)0xe07f, - (q15_t)0x77b0, (q15_t)0xe074, (q15_t)0x77a9, (q15_t)0xe069, (q15_t)0x77a3, (q15_t)0xe05e, (q15_t)0x779d, (q15_t)0xe054, - (q15_t)0x7797, (q15_t)0xe049, (q15_t)0x7790, (q15_t)0xe03e, (q15_t)0x778a, (q15_t)0xe033, (q15_t)0x7784, (q15_t)0xe028, - (q15_t)0x777e, (q15_t)0xe01d, (q15_t)0x7777, (q15_t)0xe012, (q15_t)0x7771, (q15_t)0xe007, (q15_t)0x776b, (q15_t)0xdffc, - (q15_t)0x7765, (q15_t)0xdff1, (q15_t)0x775e, (q15_t)0xdfe7, (q15_t)0x7758, (q15_t)0xdfdc, (q15_t)0x7752, (q15_t)0xdfd1, - (q15_t)0x774b, (q15_t)0xdfc6, (q15_t)0x7745, (q15_t)0xdfbb, (q15_t)0x773f, (q15_t)0xdfb0, (q15_t)0x7738, (q15_t)0xdfa5, - (q15_t)0x7732, (q15_t)0xdf9b, (q15_t)0x772c, (q15_t)0xdf90, (q15_t)0x7725, (q15_t)0xdf85, (q15_t)0x771f, (q15_t)0xdf7a, - (q15_t)0x7718, (q15_t)0xdf6f, (q15_t)0x7712, (q15_t)0xdf65, (q15_t)0x770c, (q15_t)0xdf5a, (q15_t)0x7705, (q15_t)0xdf4f, - (q15_t)0x76ff, (q15_t)0xdf44, (q15_t)0x76f8, (q15_t)0xdf39, (q15_t)0x76f2, (q15_t)0xdf2f, (q15_t)0x76eb, (q15_t)0xdf24, - (q15_t)0x76e5, (q15_t)0xdf19, (q15_t)0x76df, (q15_t)0xdf0e, (q15_t)0x76d8, (q15_t)0xdf03, (q15_t)0x76d2, (q15_t)0xdef9, - (q15_t)0x76cb, (q15_t)0xdeee, (q15_t)0x76c5, (q15_t)0xdee3, (q15_t)0x76be, (q15_t)0xded8, (q15_t)0x76b8, (q15_t)0xdece, - (q15_t)0x76b1, (q15_t)0xdec3, (q15_t)0x76ab, (q15_t)0xdeb8, (q15_t)0x76a4, (q15_t)0xdead, (q15_t)0x769d, (q15_t)0xdea3, - (q15_t)0x7697, (q15_t)0xde98, (q15_t)0x7690, (q15_t)0xde8d, (q15_t)0x768a, (q15_t)0xde83, (q15_t)0x7683, (q15_t)0xde78, - (q15_t)0x767d, (q15_t)0xde6d, (q15_t)0x7676, (q15_t)0xde62, (q15_t)0x766f, (q15_t)0xde58, (q15_t)0x7669, (q15_t)0xde4d, - (q15_t)0x7662, (q15_t)0xde42, (q15_t)0x765c, (q15_t)0xde38, (q15_t)0x7655, (q15_t)0xde2d, (q15_t)0x764e, (q15_t)0xde22, - (q15_t)0x7648, (q15_t)0xde18, (q15_t)0x7641, (q15_t)0xde0d, (q15_t)0x763a, (q15_t)0xde02, (q15_t)0x7634, (q15_t)0xddf8, - (q15_t)0x762d, (q15_t)0xdded, (q15_t)0x7626, (q15_t)0xdde2, (q15_t)0x7620, (q15_t)0xddd8, (q15_t)0x7619, (q15_t)0xddcd, - (q15_t)0x7612, (q15_t)0xddc3, (q15_t)0x760b, (q15_t)0xddb8, (q15_t)0x7605, (q15_t)0xddad, (q15_t)0x75fe, (q15_t)0xdda3, - (q15_t)0x75f7, (q15_t)0xdd98, (q15_t)0x75f0, (q15_t)0xdd8e, (q15_t)0x75ea, (q15_t)0xdd83, (q15_t)0x75e3, (q15_t)0xdd78, - (q15_t)0x75dc, (q15_t)0xdd6e, (q15_t)0x75d5, (q15_t)0xdd63, (q15_t)0x75ce, (q15_t)0xdd59, (q15_t)0x75c8, (q15_t)0xdd4e, - (q15_t)0x75c1, (q15_t)0xdd44, (q15_t)0x75ba, (q15_t)0xdd39, (q15_t)0x75b3, (q15_t)0xdd2e, (q15_t)0x75ac, (q15_t)0xdd24, - (q15_t)0x75a5, (q15_t)0xdd19, (q15_t)0x759f, (q15_t)0xdd0f, (q15_t)0x7598, (q15_t)0xdd04, (q15_t)0x7591, (q15_t)0xdcfa, - (q15_t)0x758a, (q15_t)0xdcef, (q15_t)0x7583, (q15_t)0xdce5, (q15_t)0x757c, (q15_t)0xdcda, (q15_t)0x7575, (q15_t)0xdcd0, - (q15_t)0x756e, (q15_t)0xdcc5, (q15_t)0x7567, (q15_t)0xdcbb, (q15_t)0x7561, (q15_t)0xdcb0, (q15_t)0x755a, (q15_t)0xdca6, - (q15_t)0x7553, (q15_t)0xdc9b, (q15_t)0x754c, (q15_t)0xdc91, (q15_t)0x7545, (q15_t)0xdc86, (q15_t)0x753e, (q15_t)0xdc7c, - (q15_t)0x7537, (q15_t)0xdc72, (q15_t)0x7530, (q15_t)0xdc67, (q15_t)0x7529, (q15_t)0xdc5d, (q15_t)0x7522, (q15_t)0xdc52, - (q15_t)0x751b, (q15_t)0xdc48, (q15_t)0x7514, (q15_t)0xdc3d, (q15_t)0x750d, (q15_t)0xdc33, (q15_t)0x7506, (q15_t)0xdc29, - (q15_t)0x74ff, (q15_t)0xdc1e, (q15_t)0x74f8, (q15_t)0xdc14, (q15_t)0x74f1, (q15_t)0xdc09, (q15_t)0x74ea, (q15_t)0xdbff, - (q15_t)0x74e2, (q15_t)0xdbf5, (q15_t)0x74db, (q15_t)0xdbea, (q15_t)0x74d4, (q15_t)0xdbe0, (q15_t)0x74cd, (q15_t)0xdbd5, - (q15_t)0x74c6, (q15_t)0xdbcb, (q15_t)0x74bf, (q15_t)0xdbc1, (q15_t)0x74b8, (q15_t)0xdbb6, (q15_t)0x74b1, (q15_t)0xdbac, - (q15_t)0x74aa, (q15_t)0xdba2, (q15_t)0x74a2, (q15_t)0xdb97, (q15_t)0x749b, (q15_t)0xdb8d, (q15_t)0x7494, (q15_t)0xdb83, - (q15_t)0x748d, (q15_t)0xdb78, (q15_t)0x7486, (q15_t)0xdb6e, (q15_t)0x747f, (q15_t)0xdb64, (q15_t)0x7477, (q15_t)0xdb59, - (q15_t)0x7470, (q15_t)0xdb4f, (q15_t)0x7469, (q15_t)0xdb45, (q15_t)0x7462, (q15_t)0xdb3b, (q15_t)0x745b, (q15_t)0xdb30, - (q15_t)0x7453, (q15_t)0xdb26, (q15_t)0x744c, (q15_t)0xdb1c, (q15_t)0x7445, (q15_t)0xdb11, (q15_t)0x743e, (q15_t)0xdb07, - (q15_t)0x7436, (q15_t)0xdafd, (q15_t)0x742f, (q15_t)0xdaf3, (q15_t)0x7428, (q15_t)0xdae8, (q15_t)0x7420, (q15_t)0xdade, - (q15_t)0x7419, (q15_t)0xdad4, (q15_t)0x7412, (q15_t)0xdaca, (q15_t)0x740b, (q15_t)0xdabf, (q15_t)0x7403, (q15_t)0xdab5, - (q15_t)0x73fc, (q15_t)0xdaab, (q15_t)0x73f5, (q15_t)0xdaa1, (q15_t)0x73ed, (q15_t)0xda97, (q15_t)0x73e6, (q15_t)0xda8c, - (q15_t)0x73df, (q15_t)0xda82, (q15_t)0x73d7, (q15_t)0xda78, (q15_t)0x73d0, (q15_t)0xda6e, (q15_t)0x73c8, (q15_t)0xda64, - (q15_t)0x73c1, (q15_t)0xda5a, (q15_t)0x73ba, (q15_t)0xda4f, (q15_t)0x73b2, (q15_t)0xda45, (q15_t)0x73ab, (q15_t)0xda3b, - (q15_t)0x73a3, (q15_t)0xda31, (q15_t)0x739c, (q15_t)0xda27, (q15_t)0x7395, (q15_t)0xda1d, (q15_t)0x738d, (q15_t)0xda13, - (q15_t)0x7386, (q15_t)0xda08, (q15_t)0x737e, (q15_t)0xd9fe, (q15_t)0x7377, (q15_t)0xd9f4, (q15_t)0x736f, (q15_t)0xd9ea, - (q15_t)0x7368, (q15_t)0xd9e0, (q15_t)0x7360, (q15_t)0xd9d6, (q15_t)0x7359, (q15_t)0xd9cc, (q15_t)0x7351, (q15_t)0xd9c2, - (q15_t)0x734a, (q15_t)0xd9b8, (q15_t)0x7342, (q15_t)0xd9ae, (q15_t)0x733b, (q15_t)0xd9a4, (q15_t)0x7333, (q15_t)0xd99a, - (q15_t)0x732c, (q15_t)0xd98f, (q15_t)0x7324, (q15_t)0xd985, (q15_t)0x731d, (q15_t)0xd97b, (q15_t)0x7315, (q15_t)0xd971, - (q15_t)0x730d, (q15_t)0xd967, (q15_t)0x7306, (q15_t)0xd95d, (q15_t)0x72fe, (q15_t)0xd953, (q15_t)0x72f7, (q15_t)0xd949, - (q15_t)0x72ef, (q15_t)0xd93f, (q15_t)0x72e7, (q15_t)0xd935, (q15_t)0x72e0, (q15_t)0xd92b, (q15_t)0x72d8, (q15_t)0xd921, - (q15_t)0x72d0, (q15_t)0xd917, (q15_t)0x72c9, (q15_t)0xd90d, (q15_t)0x72c1, (q15_t)0xd903, (q15_t)0x72ba, (q15_t)0xd8f9, - (q15_t)0x72b2, (q15_t)0xd8ef, (q15_t)0x72aa, (q15_t)0xd8e6, (q15_t)0x72a3, (q15_t)0xd8dc, (q15_t)0x729b, (q15_t)0xd8d2, - (q15_t)0x7293, (q15_t)0xd8c8, (q15_t)0x728b, (q15_t)0xd8be, (q15_t)0x7284, (q15_t)0xd8b4, (q15_t)0x727c, (q15_t)0xd8aa, - (q15_t)0x7274, (q15_t)0xd8a0, (q15_t)0x726d, (q15_t)0xd896, (q15_t)0x7265, (q15_t)0xd88c, (q15_t)0x725d, (q15_t)0xd882, - (q15_t)0x7255, (q15_t)0xd878, (q15_t)0x724e, (q15_t)0xd86f, (q15_t)0x7246, (q15_t)0xd865, (q15_t)0x723e, (q15_t)0xd85b, - (q15_t)0x7236, (q15_t)0xd851, (q15_t)0x722e, (q15_t)0xd847, (q15_t)0x7227, (q15_t)0xd83d, (q15_t)0x721f, (q15_t)0xd833, - (q15_t)0x7217, (q15_t)0xd82a, (q15_t)0x720f, (q15_t)0xd820, (q15_t)0x7207, (q15_t)0xd816, (q15_t)0x71ff, (q15_t)0xd80c, - (q15_t)0x71f8, (q15_t)0xd802, (q15_t)0x71f0, (q15_t)0xd7f8, (q15_t)0x71e8, (q15_t)0xd7ef, (q15_t)0x71e0, (q15_t)0xd7e5, - (q15_t)0x71d8, (q15_t)0xd7db, (q15_t)0x71d0, (q15_t)0xd7d1, (q15_t)0x71c8, (q15_t)0xd7c8, (q15_t)0x71c0, (q15_t)0xd7be, - (q15_t)0x71b9, (q15_t)0xd7b4, (q15_t)0x71b1, (q15_t)0xd7aa, (q15_t)0x71a9, (q15_t)0xd7a0, (q15_t)0x71a1, (q15_t)0xd797, - (q15_t)0x7199, (q15_t)0xd78d, (q15_t)0x7191, (q15_t)0xd783, (q15_t)0x7189, (q15_t)0xd77a, (q15_t)0x7181, (q15_t)0xd770, - (q15_t)0x7179, (q15_t)0xd766, (q15_t)0x7171, (q15_t)0xd75c, (q15_t)0x7169, (q15_t)0xd753, (q15_t)0x7161, (q15_t)0xd749, - (q15_t)0x7159, (q15_t)0xd73f, (q15_t)0x7151, (q15_t)0xd736, (q15_t)0x7149, (q15_t)0xd72c, (q15_t)0x7141, (q15_t)0xd722, - (q15_t)0x7139, (q15_t)0xd719, (q15_t)0x7131, (q15_t)0xd70f, (q15_t)0x7129, (q15_t)0xd705, (q15_t)0x7121, (q15_t)0xd6fc, - (q15_t)0x7119, (q15_t)0xd6f2, (q15_t)0x7111, (q15_t)0xd6e8, (q15_t)0x7109, (q15_t)0xd6df, (q15_t)0x7101, (q15_t)0xd6d5, - (q15_t)0x70f9, (q15_t)0xd6cb, (q15_t)0x70f0, (q15_t)0xd6c2, (q15_t)0x70e8, (q15_t)0xd6b8, (q15_t)0x70e0, (q15_t)0xd6af, - (q15_t)0x70d8, (q15_t)0xd6a5, (q15_t)0x70d0, (q15_t)0xd69b, (q15_t)0x70c8, (q15_t)0xd692, (q15_t)0x70c0, (q15_t)0xd688, - (q15_t)0x70b8, (q15_t)0xd67f, (q15_t)0x70af, (q15_t)0xd675, (q15_t)0x70a7, (q15_t)0xd66c, (q15_t)0x709f, (q15_t)0xd662, - (q15_t)0x7097, (q15_t)0xd659, (q15_t)0x708f, (q15_t)0xd64f, (q15_t)0x7087, (q15_t)0xd645, (q15_t)0x707e, (q15_t)0xd63c, - (q15_t)0x7076, (q15_t)0xd632, (q15_t)0x706e, (q15_t)0xd629, (q15_t)0x7066, (q15_t)0xd61f, (q15_t)0x705d, (q15_t)0xd616, - (q15_t)0x7055, (q15_t)0xd60c, (q15_t)0x704d, (q15_t)0xd603, (q15_t)0x7045, (q15_t)0xd5f9, (q15_t)0x703c, (q15_t)0xd5f0, - (q15_t)0x7034, (q15_t)0xd5e6, (q15_t)0x702c, (q15_t)0xd5dd, (q15_t)0x7024, (q15_t)0xd5d4, (q15_t)0x701b, (q15_t)0xd5ca, - (q15_t)0x7013, (q15_t)0xd5c1, (q15_t)0x700b, (q15_t)0xd5b7, (q15_t)0x7002, (q15_t)0xd5ae, (q15_t)0x6ffa, (q15_t)0xd5a4, - (q15_t)0x6ff2, (q15_t)0xd59b, (q15_t)0x6fea, (q15_t)0xd592, (q15_t)0x6fe1, (q15_t)0xd588, (q15_t)0x6fd9, (q15_t)0xd57f, - (q15_t)0x6fd0, (q15_t)0xd575, (q15_t)0x6fc8, (q15_t)0xd56c, (q15_t)0x6fc0, (q15_t)0xd563, (q15_t)0x6fb7, (q15_t)0xd559, - (q15_t)0x6faf, (q15_t)0xd550, (q15_t)0x6fa7, (q15_t)0xd547, (q15_t)0x6f9e, (q15_t)0xd53d, (q15_t)0x6f96, (q15_t)0xd534, - (q15_t)0x6f8d, (q15_t)0xd52a, (q15_t)0x6f85, (q15_t)0xd521, (q15_t)0x6f7d, (q15_t)0xd518, (q15_t)0x6f74, (q15_t)0xd50e, - (q15_t)0x6f6c, (q15_t)0xd505, (q15_t)0x6f63, (q15_t)0xd4fc, (q15_t)0x6f5b, (q15_t)0xd4f3, (q15_t)0x6f52, (q15_t)0xd4e9, - (q15_t)0x6f4a, (q15_t)0xd4e0, (q15_t)0x6f41, (q15_t)0xd4d7, (q15_t)0x6f39, (q15_t)0xd4cd, (q15_t)0x6f30, (q15_t)0xd4c4, - (q15_t)0x6f28, (q15_t)0xd4bb, (q15_t)0x6f20, (q15_t)0xd4b2, (q15_t)0x6f17, (q15_t)0xd4a8, (q15_t)0x6f0e, (q15_t)0xd49f, - (q15_t)0x6f06, (q15_t)0xd496, (q15_t)0x6efd, (q15_t)0xd48d, (q15_t)0x6ef5, (q15_t)0xd483, (q15_t)0x6eec, (q15_t)0xd47a, - (q15_t)0x6ee4, (q15_t)0xd471, (q15_t)0x6edb, (q15_t)0xd468, (q15_t)0x6ed3, (q15_t)0xd45f, (q15_t)0x6eca, (q15_t)0xd455, - (q15_t)0x6ec2, (q15_t)0xd44c, (q15_t)0x6eb9, (q15_t)0xd443, (q15_t)0x6eb0, (q15_t)0xd43a, (q15_t)0x6ea8, (q15_t)0xd431, - (q15_t)0x6e9f, (q15_t)0xd428, (q15_t)0x6e97, (q15_t)0xd41e, (q15_t)0x6e8e, (q15_t)0xd415, (q15_t)0x6e85, (q15_t)0xd40c, - (q15_t)0x6e7d, (q15_t)0xd403, (q15_t)0x6e74, (q15_t)0xd3fa, (q15_t)0x6e6b, (q15_t)0xd3f1, (q15_t)0x6e63, (q15_t)0xd3e8, - (q15_t)0x6e5a, (q15_t)0xd3df, (q15_t)0x6e51, (q15_t)0xd3d5, (q15_t)0x6e49, (q15_t)0xd3cc, (q15_t)0x6e40, (q15_t)0xd3c3, - (q15_t)0x6e37, (q15_t)0xd3ba, (q15_t)0x6e2f, (q15_t)0xd3b1, (q15_t)0x6e26, (q15_t)0xd3a8, (q15_t)0x6e1d, (q15_t)0xd39f, - (q15_t)0x6e15, (q15_t)0xd396, (q15_t)0x6e0c, (q15_t)0xd38d, (q15_t)0x6e03, (q15_t)0xd384, (q15_t)0x6dfa, (q15_t)0xd37b, - (q15_t)0x6df2, (q15_t)0xd372, (q15_t)0x6de9, (q15_t)0xd369, (q15_t)0x6de0, (q15_t)0xd360, (q15_t)0x6dd7, (q15_t)0xd357, - (q15_t)0x6dcf, (q15_t)0xd34e, (q15_t)0x6dc6, (q15_t)0xd345, (q15_t)0x6dbd, (q15_t)0xd33c, (q15_t)0x6db4, (q15_t)0xd333, - (q15_t)0x6dab, (q15_t)0xd32a, (q15_t)0x6da3, (q15_t)0xd321, (q15_t)0x6d9a, (q15_t)0xd318, (q15_t)0x6d91, (q15_t)0xd30f, - (q15_t)0x6d88, (q15_t)0xd306, (q15_t)0x6d7f, (q15_t)0xd2fd, (q15_t)0x6d76, (q15_t)0xd2f4, (q15_t)0x6d6e, (q15_t)0xd2eb, - (q15_t)0x6d65, (q15_t)0xd2e2, (q15_t)0x6d5c, (q15_t)0xd2d9, (q15_t)0x6d53, (q15_t)0xd2d1, (q15_t)0x6d4a, (q15_t)0xd2c8, - (q15_t)0x6d41, (q15_t)0xd2bf, (q15_t)0x6d38, (q15_t)0xd2b6, (q15_t)0x6d2f, (q15_t)0xd2ad, (q15_t)0x6d27, (q15_t)0xd2a4, - (q15_t)0x6d1e, (q15_t)0xd29b, (q15_t)0x6d15, (q15_t)0xd292, (q15_t)0x6d0c, (q15_t)0xd28a, (q15_t)0x6d03, (q15_t)0xd281, - (q15_t)0x6cfa, (q15_t)0xd278, (q15_t)0x6cf1, (q15_t)0xd26f, (q15_t)0x6ce8, (q15_t)0xd266, (q15_t)0x6cdf, (q15_t)0xd25d, - (q15_t)0x6cd6, (q15_t)0xd255, (q15_t)0x6ccd, (q15_t)0xd24c, (q15_t)0x6cc4, (q15_t)0xd243, (q15_t)0x6cbb, (q15_t)0xd23a, - (q15_t)0x6cb2, (q15_t)0xd231, (q15_t)0x6ca9, (q15_t)0xd229, (q15_t)0x6ca0, (q15_t)0xd220, (q15_t)0x6c97, (q15_t)0xd217, - (q15_t)0x6c8e, (q15_t)0xd20e, (q15_t)0x6c85, (q15_t)0xd206, (q15_t)0x6c7c, (q15_t)0xd1fd, (q15_t)0x6c73, (q15_t)0xd1f4, - (q15_t)0x6c6a, (q15_t)0xd1eb, (q15_t)0x6c61, (q15_t)0xd1e3, (q15_t)0x6c58, (q15_t)0xd1da, (q15_t)0x6c4f, (q15_t)0xd1d1, - (q15_t)0x6c46, (q15_t)0xd1c9, (q15_t)0x6c3d, (q15_t)0xd1c0, (q15_t)0x6c34, (q15_t)0xd1b7, (q15_t)0x6c2b, (q15_t)0xd1af, - (q15_t)0x6c21, (q15_t)0xd1a6, (q15_t)0x6c18, (q15_t)0xd19d, (q15_t)0x6c0f, (q15_t)0xd195, (q15_t)0x6c06, (q15_t)0xd18c, - (q15_t)0x6bfd, (q15_t)0xd183, (q15_t)0x6bf4, (q15_t)0xd17b, (q15_t)0x6beb, (q15_t)0xd172, (q15_t)0x6be2, (q15_t)0xd169, - (q15_t)0x6bd8, (q15_t)0xd161, (q15_t)0x6bcf, (q15_t)0xd158, (q15_t)0x6bc6, (q15_t)0xd150, (q15_t)0x6bbd, (q15_t)0xd147, - (q15_t)0x6bb4, (q15_t)0xd13e, (q15_t)0x6bab, (q15_t)0xd136, (q15_t)0x6ba1, (q15_t)0xd12d, (q15_t)0x6b98, (q15_t)0xd125, - (q15_t)0x6b8f, (q15_t)0xd11c, (q15_t)0x6b86, (q15_t)0xd114, (q15_t)0x6b7d, (q15_t)0xd10b, (q15_t)0x6b73, (q15_t)0xd103, - (q15_t)0x6b6a, (q15_t)0xd0fa, (q15_t)0x6b61, (q15_t)0xd0f2, (q15_t)0x6b58, (q15_t)0xd0e9, (q15_t)0x6b4e, (q15_t)0xd0e0, - (q15_t)0x6b45, (q15_t)0xd0d8, (q15_t)0x6b3c, (q15_t)0xd0d0, (q15_t)0x6b33, (q15_t)0xd0c7, (q15_t)0x6b29, (q15_t)0xd0bf, - (q15_t)0x6b20, (q15_t)0xd0b6, (q15_t)0x6b17, (q15_t)0xd0ae, (q15_t)0x6b0d, (q15_t)0xd0a5, (q15_t)0x6b04, (q15_t)0xd09d, - (q15_t)0x6afb, (q15_t)0xd094, (q15_t)0x6af2, (q15_t)0xd08c, (q15_t)0x6ae8, (q15_t)0xd083, (q15_t)0x6adf, (q15_t)0xd07b, - (q15_t)0x6ad6, (q15_t)0xd073, (q15_t)0x6acc, (q15_t)0xd06a, (q15_t)0x6ac3, (q15_t)0xd062, (q15_t)0x6ab9, (q15_t)0xd059, - (q15_t)0x6ab0, (q15_t)0xd051, (q15_t)0x6aa7, (q15_t)0xd049, (q15_t)0x6a9d, (q15_t)0xd040, (q15_t)0x6a94, (q15_t)0xd038, - (q15_t)0x6a8b, (q15_t)0xd030, (q15_t)0x6a81, (q15_t)0xd027, (q15_t)0x6a78, (q15_t)0xd01f, (q15_t)0x6a6e, (q15_t)0xd016, - (q15_t)0x6a65, (q15_t)0xd00e, (q15_t)0x6a5c, (q15_t)0xd006, (q15_t)0x6a52, (q15_t)0xcffe, (q15_t)0x6a49, (q15_t)0xcff5, - (q15_t)0x6a3f, (q15_t)0xcfed, (q15_t)0x6a36, (q15_t)0xcfe5, (q15_t)0x6a2c, (q15_t)0xcfdc, (q15_t)0x6a23, (q15_t)0xcfd4, - (q15_t)0x6a1a, (q15_t)0xcfcc, (q15_t)0x6a10, (q15_t)0xcfc4, (q15_t)0x6a07, (q15_t)0xcfbb, (q15_t)0x69fd, (q15_t)0xcfb3, - (q15_t)0x69f4, (q15_t)0xcfab, (q15_t)0x69ea, (q15_t)0xcfa3, (q15_t)0x69e1, (q15_t)0xcf9a, (q15_t)0x69d7, (q15_t)0xcf92, - (q15_t)0x69ce, (q15_t)0xcf8a, (q15_t)0x69c4, (q15_t)0xcf82, (q15_t)0x69bb, (q15_t)0xcf79, (q15_t)0x69b1, (q15_t)0xcf71, - (q15_t)0x69a7, (q15_t)0xcf69, (q15_t)0x699e, (q15_t)0xcf61, (q15_t)0x6994, (q15_t)0xcf59, (q15_t)0x698b, (q15_t)0xcf51, - (q15_t)0x6981, (q15_t)0xcf48, (q15_t)0x6978, (q15_t)0xcf40, (q15_t)0x696e, (q15_t)0xcf38, (q15_t)0x6965, (q15_t)0xcf30, - (q15_t)0x695b, (q15_t)0xcf28, (q15_t)0x6951, (q15_t)0xcf20, (q15_t)0x6948, (q15_t)0xcf18, (q15_t)0x693e, (q15_t)0xcf10, - (q15_t)0x6935, (q15_t)0xcf07, (q15_t)0x692b, (q15_t)0xceff, (q15_t)0x6921, (q15_t)0xcef7, (q15_t)0x6918, (q15_t)0xceef, - (q15_t)0x690e, (q15_t)0xcee7, (q15_t)0x6904, (q15_t)0xcedf, (q15_t)0x68fb, (q15_t)0xced7, (q15_t)0x68f1, (q15_t)0xcecf, - (q15_t)0x68e7, (q15_t)0xcec7, (q15_t)0x68de, (q15_t)0xcebf, (q15_t)0x68d4, (q15_t)0xceb7, (q15_t)0x68ca, (q15_t)0xceaf, - (q15_t)0x68c1, (q15_t)0xcea7, (q15_t)0x68b7, (q15_t)0xce9f, (q15_t)0x68ad, (q15_t)0xce97, (q15_t)0x68a4, (q15_t)0xce8f, - (q15_t)0x689a, (q15_t)0xce87, (q15_t)0x6890, (q15_t)0xce7f, (q15_t)0x6886, (q15_t)0xce77, (q15_t)0x687d, (q15_t)0xce6f, - (q15_t)0x6873, (q15_t)0xce67, (q15_t)0x6869, (q15_t)0xce5f, (q15_t)0x6860, (q15_t)0xce57, (q15_t)0x6856, (q15_t)0xce4f, - (q15_t)0x684c, (q15_t)0xce47, (q15_t)0x6842, (q15_t)0xce40, (q15_t)0x6838, (q15_t)0xce38, (q15_t)0x682f, (q15_t)0xce30, - (q15_t)0x6825, (q15_t)0xce28, (q15_t)0x681b, (q15_t)0xce20, (q15_t)0x6811, (q15_t)0xce18, (q15_t)0x6808, (q15_t)0xce10, - (q15_t)0x67fe, (q15_t)0xce08, (q15_t)0x67f4, (q15_t)0xce01, (q15_t)0x67ea, (q15_t)0xcdf9, (q15_t)0x67e0, (q15_t)0xcdf1, - (q15_t)0x67d6, (q15_t)0xcde9, (q15_t)0x67cd, (q15_t)0xcde1, (q15_t)0x67c3, (q15_t)0xcdd9, (q15_t)0x67b9, (q15_t)0xcdd2, - (q15_t)0x67af, (q15_t)0xcdca, (q15_t)0x67a5, (q15_t)0xcdc2, (q15_t)0x679b, (q15_t)0xcdba, (q15_t)0x6791, (q15_t)0xcdb2, - (q15_t)0x6788, (q15_t)0xcdab, (q15_t)0x677e, (q15_t)0xcda3, (q15_t)0x6774, (q15_t)0xcd9b, (q15_t)0x676a, (q15_t)0xcd93, - (q15_t)0x6760, (q15_t)0xcd8c, (q15_t)0x6756, (q15_t)0xcd84, (q15_t)0x674c, (q15_t)0xcd7c, (q15_t)0x6742, (q15_t)0xcd75, - (q15_t)0x6738, (q15_t)0xcd6d, (q15_t)0x672e, (q15_t)0xcd65, (q15_t)0x6724, (q15_t)0xcd5d, (q15_t)0x671a, (q15_t)0xcd56, - (q15_t)0x6711, (q15_t)0xcd4e, (q15_t)0x6707, (q15_t)0xcd46, (q15_t)0x66fd, (q15_t)0xcd3f, (q15_t)0x66f3, (q15_t)0xcd37, - (q15_t)0x66e9, (q15_t)0xcd30, (q15_t)0x66df, (q15_t)0xcd28, (q15_t)0x66d5, (q15_t)0xcd20, (q15_t)0x66cb, (q15_t)0xcd19, - (q15_t)0x66c1, (q15_t)0xcd11, (q15_t)0x66b7, (q15_t)0xcd09, (q15_t)0x66ad, (q15_t)0xcd02, (q15_t)0x66a3, (q15_t)0xccfa, - (q15_t)0x6699, (q15_t)0xccf3, (q15_t)0x668f, (q15_t)0xcceb, (q15_t)0x6685, (q15_t)0xcce3, (q15_t)0x667b, (q15_t)0xccdc, - (q15_t)0x6671, (q15_t)0xccd4, (q15_t)0x6666, (q15_t)0xcccd, (q15_t)0x665c, (q15_t)0xccc5, (q15_t)0x6652, (q15_t)0xccbe, - (q15_t)0x6648, (q15_t)0xccb6, (q15_t)0x663e, (q15_t)0xccaf, (q15_t)0x6634, (q15_t)0xcca7, (q15_t)0x662a, (q15_t)0xcca0, - (q15_t)0x6620, (q15_t)0xcc98, (q15_t)0x6616, (q15_t)0xcc91, (q15_t)0x660c, (q15_t)0xcc89, (q15_t)0x6602, (q15_t)0xcc82, - (q15_t)0x65f8, (q15_t)0xcc7a, (q15_t)0x65ed, (q15_t)0xcc73, (q15_t)0x65e3, (q15_t)0xcc6b, (q15_t)0x65d9, (q15_t)0xcc64, - (q15_t)0x65cf, (q15_t)0xcc5d, (q15_t)0x65c5, (q15_t)0xcc55, (q15_t)0x65bb, (q15_t)0xcc4e, (q15_t)0x65b1, (q15_t)0xcc46, - (q15_t)0x65a6, (q15_t)0xcc3f, (q15_t)0x659c, (q15_t)0xcc38, (q15_t)0x6592, (q15_t)0xcc30, (q15_t)0x6588, (q15_t)0xcc29, - (q15_t)0x657e, (q15_t)0xcc21, (q15_t)0x6574, (q15_t)0xcc1a, (q15_t)0x6569, (q15_t)0xcc13, (q15_t)0x655f, (q15_t)0xcc0b, - (q15_t)0x6555, (q15_t)0xcc04, (q15_t)0x654b, (q15_t)0xcbfd, (q15_t)0x6541, (q15_t)0xcbf5, (q15_t)0x6536, (q15_t)0xcbee, - (q15_t)0x652c, (q15_t)0xcbe7, (q15_t)0x6522, (q15_t)0xcbe0, (q15_t)0x6518, (q15_t)0xcbd8, (q15_t)0x650d, (q15_t)0xcbd1, - (q15_t)0x6503, (q15_t)0xcbca, (q15_t)0x64f9, (q15_t)0xcbc2, (q15_t)0x64ef, (q15_t)0xcbbb, (q15_t)0x64e4, (q15_t)0xcbb4, - (q15_t)0x64da, (q15_t)0xcbad, (q15_t)0x64d0, (q15_t)0xcba5, (q15_t)0x64c5, (q15_t)0xcb9e, (q15_t)0x64bb, (q15_t)0xcb97, - (q15_t)0x64b1, (q15_t)0xcb90, (q15_t)0x64a7, (q15_t)0xcb89, (q15_t)0x649c, (q15_t)0xcb81, (q15_t)0x6492, (q15_t)0xcb7a, - (q15_t)0x6488, (q15_t)0xcb73, (q15_t)0x647d, (q15_t)0xcb6c, (q15_t)0x6473, (q15_t)0xcb65, (q15_t)0x6469, (q15_t)0xcb5e, - (q15_t)0x645e, (q15_t)0xcb56, (q15_t)0x6454, (q15_t)0xcb4f, (q15_t)0x644a, (q15_t)0xcb48, (q15_t)0x643f, (q15_t)0xcb41, - (q15_t)0x6435, (q15_t)0xcb3a, (q15_t)0x642b, (q15_t)0xcb33, (q15_t)0x6420, (q15_t)0xcb2c, (q15_t)0x6416, (q15_t)0xcb25, - (q15_t)0x640b, (q15_t)0xcb1e, (q15_t)0x6401, (q15_t)0xcb16, (q15_t)0x63f7, (q15_t)0xcb0f, (q15_t)0x63ec, (q15_t)0xcb08, - (q15_t)0x63e2, (q15_t)0xcb01, (q15_t)0x63d7, (q15_t)0xcafa, (q15_t)0x63cd, (q15_t)0xcaf3, (q15_t)0x63c3, (q15_t)0xcaec, - (q15_t)0x63b8, (q15_t)0xcae5, (q15_t)0x63ae, (q15_t)0xcade, (q15_t)0x63a3, (q15_t)0xcad7, (q15_t)0x6399, (q15_t)0xcad0, - (q15_t)0x638e, (q15_t)0xcac9, (q15_t)0x6384, (q15_t)0xcac2, (q15_t)0x637a, (q15_t)0xcabb, (q15_t)0x636f, (q15_t)0xcab4, - (q15_t)0x6365, (q15_t)0xcaad, (q15_t)0x635a, (q15_t)0xcaa6, (q15_t)0x6350, (q15_t)0xca9f, (q15_t)0x6345, (q15_t)0xca99, - (q15_t)0x633b, (q15_t)0xca92, (q15_t)0x6330, (q15_t)0xca8b, (q15_t)0x6326, (q15_t)0xca84, (q15_t)0x631b, (q15_t)0xca7d, - (q15_t)0x6311, (q15_t)0xca76, (q15_t)0x6306, (q15_t)0xca6f, (q15_t)0x62fc, (q15_t)0xca68, (q15_t)0x62f1, (q15_t)0xca61, - (q15_t)0x62e7, (q15_t)0xca5b, (q15_t)0x62dc, (q15_t)0xca54, (q15_t)0x62d2, (q15_t)0xca4d, (q15_t)0x62c7, (q15_t)0xca46, - (q15_t)0x62bc, (q15_t)0xca3f, (q15_t)0x62b2, (q15_t)0xca38, (q15_t)0x62a7, (q15_t)0xca32, (q15_t)0x629d, (q15_t)0xca2b, - (q15_t)0x6292, (q15_t)0xca24, (q15_t)0x6288, (q15_t)0xca1d, (q15_t)0x627d, (q15_t)0xca16, (q15_t)0x6272, (q15_t)0xca10, - (q15_t)0x6268, (q15_t)0xca09, (q15_t)0x625d, (q15_t)0xca02, (q15_t)0x6253, (q15_t)0xc9fb, (q15_t)0x6248, (q15_t)0xc9f5, - (q15_t)0x623d, (q15_t)0xc9ee, (q15_t)0x6233, (q15_t)0xc9e7, (q15_t)0x6228, (q15_t)0xc9e0, (q15_t)0x621e, (q15_t)0xc9da, - (q15_t)0x6213, (q15_t)0xc9d3, (q15_t)0x6208, (q15_t)0xc9cc, (q15_t)0x61fe, (q15_t)0xc9c6, (q15_t)0x61f3, (q15_t)0xc9bf, - (q15_t)0x61e8, (q15_t)0xc9b8, (q15_t)0x61de, (q15_t)0xc9b2, (q15_t)0x61d3, (q15_t)0xc9ab, (q15_t)0x61c8, (q15_t)0xc9a4, - (q15_t)0x61be, (q15_t)0xc99e, (q15_t)0x61b3, (q15_t)0xc997, (q15_t)0x61a8, (q15_t)0xc991, (q15_t)0x619e, (q15_t)0xc98a, - (q15_t)0x6193, (q15_t)0xc983, (q15_t)0x6188, (q15_t)0xc97d, (q15_t)0x617d, (q15_t)0xc976, (q15_t)0x6173, (q15_t)0xc970, - (q15_t)0x6168, (q15_t)0xc969, (q15_t)0x615d, (q15_t)0xc963, (q15_t)0x6153, (q15_t)0xc95c, (q15_t)0x6148, (q15_t)0xc955, - (q15_t)0x613d, (q15_t)0xc94f, (q15_t)0x6132, (q15_t)0xc948, (q15_t)0x6128, (q15_t)0xc942, (q15_t)0x611d, (q15_t)0xc93b, - (q15_t)0x6112, (q15_t)0xc935, (q15_t)0x6107, (q15_t)0xc92e, (q15_t)0x60fd, (q15_t)0xc928, (q15_t)0x60f2, (q15_t)0xc921, - (q15_t)0x60e7, (q15_t)0xc91b, (q15_t)0x60dc, (q15_t)0xc915, (q15_t)0x60d1, (q15_t)0xc90e, (q15_t)0x60c7, (q15_t)0xc908, - (q15_t)0x60bc, (q15_t)0xc901, (q15_t)0x60b1, (q15_t)0xc8fb, (q15_t)0x60a6, (q15_t)0xc8f4, (q15_t)0x609b, (q15_t)0xc8ee, - (q15_t)0x6091, (q15_t)0xc8e8, (q15_t)0x6086, (q15_t)0xc8e1, (q15_t)0x607b, (q15_t)0xc8db, (q15_t)0x6070, (q15_t)0xc8d4, - (q15_t)0x6065, (q15_t)0xc8ce, (q15_t)0x605b, (q15_t)0xc8c8, (q15_t)0x6050, (q15_t)0xc8c1, (q15_t)0x6045, (q15_t)0xc8bb, - (q15_t)0x603a, (q15_t)0xc8b5, (q15_t)0x602f, (q15_t)0xc8ae, (q15_t)0x6024, (q15_t)0xc8a8, (q15_t)0x6019, (q15_t)0xc8a2, - (q15_t)0x600f, (q15_t)0xc89b, (q15_t)0x6004, (q15_t)0xc895, (q15_t)0x5ff9, (q15_t)0xc88f, (q15_t)0x5fee, (q15_t)0xc889, - (q15_t)0x5fe3, (q15_t)0xc882, (q15_t)0x5fd8, (q15_t)0xc87c, (q15_t)0x5fcd, (q15_t)0xc876, (q15_t)0x5fc2, (q15_t)0xc870, - (q15_t)0x5fb7, (q15_t)0xc869, (q15_t)0x5fac, (q15_t)0xc863, (q15_t)0x5fa2, (q15_t)0xc85d, (q15_t)0x5f97, (q15_t)0xc857, - (q15_t)0x5f8c, (q15_t)0xc850, (q15_t)0x5f81, (q15_t)0xc84a, (q15_t)0x5f76, (q15_t)0xc844, (q15_t)0x5f6b, (q15_t)0xc83e, - (q15_t)0x5f60, (q15_t)0xc838, (q15_t)0x5f55, (q15_t)0xc832, (q15_t)0x5f4a, (q15_t)0xc82b, (q15_t)0x5f3f, (q15_t)0xc825, - (q15_t)0x5f34, (q15_t)0xc81f, (q15_t)0x5f29, (q15_t)0xc819, (q15_t)0x5f1e, (q15_t)0xc813, (q15_t)0x5f13, (q15_t)0xc80d, - (q15_t)0x5f08, (q15_t)0xc807, (q15_t)0x5efd, (q15_t)0xc801, (q15_t)0x5ef2, (q15_t)0xc7fb, (q15_t)0x5ee7, (q15_t)0xc7f5, - (q15_t)0x5edc, (q15_t)0xc7ee, (q15_t)0x5ed1, (q15_t)0xc7e8, (q15_t)0x5ec6, (q15_t)0xc7e2, (q15_t)0x5ebb, (q15_t)0xc7dc, - (q15_t)0x5eb0, (q15_t)0xc7d6, (q15_t)0x5ea5, (q15_t)0xc7d0, (q15_t)0x5e9a, (q15_t)0xc7ca, (q15_t)0x5e8f, (q15_t)0xc7c4, - (q15_t)0x5e84, (q15_t)0xc7be, (q15_t)0x5e79, (q15_t)0xc7b8, (q15_t)0x5e6e, (q15_t)0xc7b2, (q15_t)0x5e63, (q15_t)0xc7ac, - (q15_t)0x5e58, (q15_t)0xc7a6, (q15_t)0x5e4d, (q15_t)0xc7a0, (q15_t)0x5e42, (q15_t)0xc79a, (q15_t)0x5e36, (q15_t)0xc795, - (q15_t)0x5e2b, (q15_t)0xc78f, (q15_t)0x5e20, (q15_t)0xc789, (q15_t)0x5e15, (q15_t)0xc783, (q15_t)0x5e0a, (q15_t)0xc77d, - (q15_t)0x5dff, (q15_t)0xc777, (q15_t)0x5df4, (q15_t)0xc771, (q15_t)0x5de9, (q15_t)0xc76b, (q15_t)0x5dde, (q15_t)0xc765, - (q15_t)0x5dd3, (q15_t)0xc75f, (q15_t)0x5dc7, (q15_t)0xc75a, (q15_t)0x5dbc, (q15_t)0xc754, (q15_t)0x5db1, (q15_t)0xc74e, - (q15_t)0x5da6, (q15_t)0xc748, (q15_t)0x5d9b, (q15_t)0xc742, (q15_t)0x5d90, (q15_t)0xc73d, (q15_t)0x5d85, (q15_t)0xc737, - (q15_t)0x5d79, (q15_t)0xc731, (q15_t)0x5d6e, (q15_t)0xc72b, (q15_t)0x5d63, (q15_t)0xc725, (q15_t)0x5d58, (q15_t)0xc720, - (q15_t)0x5d4d, (q15_t)0xc71a, (q15_t)0x5d42, (q15_t)0xc714, (q15_t)0x5d36, (q15_t)0xc70e, (q15_t)0x5d2b, (q15_t)0xc709, - (q15_t)0x5d20, (q15_t)0xc703, (q15_t)0x5d15, (q15_t)0xc6fd, (q15_t)0x5d0a, (q15_t)0xc6f7, (q15_t)0x5cff, (q15_t)0xc6f2, - (q15_t)0x5cf3, (q15_t)0xc6ec, (q15_t)0x5ce8, (q15_t)0xc6e6, (q15_t)0x5cdd, (q15_t)0xc6e1, (q15_t)0x5cd2, (q15_t)0xc6db, - (q15_t)0x5cc6, (q15_t)0xc6d5, (q15_t)0x5cbb, (q15_t)0xc6d0, (q15_t)0x5cb0, (q15_t)0xc6ca, (q15_t)0x5ca5, (q15_t)0xc6c5, - (q15_t)0x5c99, (q15_t)0xc6bf, (q15_t)0x5c8e, (q15_t)0xc6b9, (q15_t)0x5c83, (q15_t)0xc6b4, (q15_t)0x5c78, (q15_t)0xc6ae, - (q15_t)0x5c6c, (q15_t)0xc6a8, (q15_t)0x5c61, (q15_t)0xc6a3, (q15_t)0x5c56, (q15_t)0xc69d, (q15_t)0x5c4b, (q15_t)0xc698, - (q15_t)0x5c3f, (q15_t)0xc692, (q15_t)0x5c34, (q15_t)0xc68d, (q15_t)0x5c29, (q15_t)0xc687, (q15_t)0x5c1e, (q15_t)0xc682, - (q15_t)0x5c12, (q15_t)0xc67c, (q15_t)0x5c07, (q15_t)0xc677, (q15_t)0x5bfc, (q15_t)0xc671, (q15_t)0x5bf0, (q15_t)0xc66c, - (q15_t)0x5be5, (q15_t)0xc666, (q15_t)0x5bda, (q15_t)0xc661, (q15_t)0x5bce, (q15_t)0xc65b, (q15_t)0x5bc3, (q15_t)0xc656, - (q15_t)0x5bb8, (q15_t)0xc650, (q15_t)0x5bac, (q15_t)0xc64b, (q15_t)0x5ba1, (q15_t)0xc645, (q15_t)0x5b96, (q15_t)0xc640, - (q15_t)0x5b8a, (q15_t)0xc63b, (q15_t)0x5b7f, (q15_t)0xc635, (q15_t)0x5b74, (q15_t)0xc630, (q15_t)0x5b68, (q15_t)0xc62a, - (q15_t)0x5b5d, (q15_t)0xc625, (q15_t)0x5b52, (q15_t)0xc620, (q15_t)0x5b46, (q15_t)0xc61a, (q15_t)0x5b3b, (q15_t)0xc615, - (q15_t)0x5b30, (q15_t)0xc610, (q15_t)0x5b24, (q15_t)0xc60a, (q15_t)0x5b19, (q15_t)0xc605, (q15_t)0x5b0d, (q15_t)0xc600, - (q15_t)0x5b02, (q15_t)0xc5fa, (q15_t)0x5af7, (q15_t)0xc5f5, (q15_t)0x5aeb, (q15_t)0xc5f0, (q15_t)0x5ae0, (q15_t)0xc5ea, - (q15_t)0x5ad4, (q15_t)0xc5e5, (q15_t)0x5ac9, (q15_t)0xc5e0, (q15_t)0x5abe, (q15_t)0xc5db, (q15_t)0x5ab2, (q15_t)0xc5d5, - (q15_t)0x5aa7, (q15_t)0xc5d0, (q15_t)0x5a9b, (q15_t)0xc5cb, (q15_t)0x5a90, (q15_t)0xc5c6, (q15_t)0x5a84, (q15_t)0xc5c1, - (q15_t)0x5a79, (q15_t)0xc5bb, (q15_t)0x5a6e, (q15_t)0xc5b6, (q15_t)0x5a62, (q15_t)0xc5b1, (q15_t)0x5a57, (q15_t)0xc5ac, - (q15_t)0x5a4b, (q15_t)0xc5a7, (q15_t)0x5a40, (q15_t)0xc5a1, (q15_t)0x5a34, (q15_t)0xc59c, (q15_t)0x5a29, (q15_t)0xc597, - (q15_t)0x5a1d, (q15_t)0xc592, (q15_t)0x5a12, (q15_t)0xc58d, (q15_t)0x5a06, (q15_t)0xc588, (q15_t)0x59fb, (q15_t)0xc583, - (q15_t)0x59ef, (q15_t)0xc57e, (q15_t)0x59e4, (q15_t)0xc578, (q15_t)0x59d8, (q15_t)0xc573, (q15_t)0x59cd, (q15_t)0xc56e, - (q15_t)0x59c1, (q15_t)0xc569, (q15_t)0x59b6, (q15_t)0xc564, (q15_t)0x59aa, (q15_t)0xc55f, (q15_t)0x599f, (q15_t)0xc55a, - (q15_t)0x5993, (q15_t)0xc555, (q15_t)0x5988, (q15_t)0xc550, (q15_t)0x597c, (q15_t)0xc54b, (q15_t)0x5971, (q15_t)0xc546, - (q15_t)0x5965, (q15_t)0xc541, (q15_t)0x595a, (q15_t)0xc53c, (q15_t)0x594e, (q15_t)0xc537, (q15_t)0x5943, (q15_t)0xc532, - (q15_t)0x5937, (q15_t)0xc52d, (q15_t)0x592c, (q15_t)0xc528, (q15_t)0x5920, (q15_t)0xc523, (q15_t)0x5914, (q15_t)0xc51e, - (q15_t)0x5909, (q15_t)0xc51a, (q15_t)0x58fd, (q15_t)0xc515, (q15_t)0x58f2, (q15_t)0xc510, (q15_t)0x58e6, (q15_t)0xc50b, - (q15_t)0x58db, (q15_t)0xc506, (q15_t)0x58cf, (q15_t)0xc501, (q15_t)0x58c3, (q15_t)0xc4fc, (q15_t)0x58b8, (q15_t)0xc4f7, - (q15_t)0x58ac, (q15_t)0xc4f2, (q15_t)0x58a1, (q15_t)0xc4ee, (q15_t)0x5895, (q15_t)0xc4e9, (q15_t)0x5889, (q15_t)0xc4e4, - (q15_t)0x587e, (q15_t)0xc4df, (q15_t)0x5872, (q15_t)0xc4da, (q15_t)0x5867, (q15_t)0xc4d6, (q15_t)0x585b, (q15_t)0xc4d1, - (q15_t)0x584f, (q15_t)0xc4cc, (q15_t)0x5844, (q15_t)0xc4c7, (q15_t)0x5838, (q15_t)0xc4c2, (q15_t)0x582d, (q15_t)0xc4be, - (q15_t)0x5821, (q15_t)0xc4b9, (q15_t)0x5815, (q15_t)0xc4b4, (q15_t)0x580a, (q15_t)0xc4b0, (q15_t)0x57fe, (q15_t)0xc4ab, - (q15_t)0x57f2, (q15_t)0xc4a6, (q15_t)0x57e7, (q15_t)0xc4a1, (q15_t)0x57db, (q15_t)0xc49d, (q15_t)0x57cf, (q15_t)0xc498, - (q15_t)0x57c4, (q15_t)0xc493, (q15_t)0x57b8, (q15_t)0xc48f, (q15_t)0x57ac, (q15_t)0xc48a, (q15_t)0x57a1, (q15_t)0xc485, - (q15_t)0x5795, (q15_t)0xc481, (q15_t)0x5789, (q15_t)0xc47c, (q15_t)0x577e, (q15_t)0xc478, (q15_t)0x5772, (q15_t)0xc473, - (q15_t)0x5766, (q15_t)0xc46e, (q15_t)0x575b, (q15_t)0xc46a, (q15_t)0x574f, (q15_t)0xc465, (q15_t)0x5743, (q15_t)0xc461, - (q15_t)0x5737, (q15_t)0xc45c, (q15_t)0x572c, (q15_t)0xc457, (q15_t)0x5720, (q15_t)0xc453, (q15_t)0x5714, (q15_t)0xc44e, - (q15_t)0x5709, (q15_t)0xc44a, (q15_t)0x56fd, (q15_t)0xc445, (q15_t)0x56f1, (q15_t)0xc441, (q15_t)0x56e5, (q15_t)0xc43c, - (q15_t)0x56da, (q15_t)0xc438, (q15_t)0x56ce, (q15_t)0xc433, (q15_t)0x56c2, (q15_t)0xc42f, (q15_t)0x56b6, (q15_t)0xc42a, - (q15_t)0x56ab, (q15_t)0xc426, (q15_t)0x569f, (q15_t)0xc422, (q15_t)0x5693, (q15_t)0xc41d, (q15_t)0x5687, (q15_t)0xc419, - (q15_t)0x567c, (q15_t)0xc414, (q15_t)0x5670, (q15_t)0xc410, (q15_t)0x5664, (q15_t)0xc40b, (q15_t)0x5658, (q15_t)0xc407, - (q15_t)0x564c, (q15_t)0xc403, (q15_t)0x5641, (q15_t)0xc3fe, (q15_t)0x5635, (q15_t)0xc3fa, (q15_t)0x5629, (q15_t)0xc3f6, - (q15_t)0x561d, (q15_t)0xc3f1, (q15_t)0x5612, (q15_t)0xc3ed, (q15_t)0x5606, (q15_t)0xc3e9, (q15_t)0x55fa, (q15_t)0xc3e4, - (q15_t)0x55ee, (q15_t)0xc3e0, (q15_t)0x55e2, (q15_t)0xc3dc, (q15_t)0x55d7, (q15_t)0xc3d7, (q15_t)0x55cb, (q15_t)0xc3d3, - (q15_t)0x55bf, (q15_t)0xc3cf, (q15_t)0x55b3, (q15_t)0xc3ca, (q15_t)0x55a7, (q15_t)0xc3c6, (q15_t)0x559b, (q15_t)0xc3c2, - (q15_t)0x5590, (q15_t)0xc3be, (q15_t)0x5584, (q15_t)0xc3ba, (q15_t)0x5578, (q15_t)0xc3b5, (q15_t)0x556c, (q15_t)0xc3b1, - (q15_t)0x5560, (q15_t)0xc3ad, (q15_t)0x5554, (q15_t)0xc3a9, (q15_t)0x5549, (q15_t)0xc3a5, (q15_t)0x553d, (q15_t)0xc3a0, - (q15_t)0x5531, (q15_t)0xc39c, (q15_t)0x5525, (q15_t)0xc398, (q15_t)0x5519, (q15_t)0xc394, (q15_t)0x550d, (q15_t)0xc390, - (q15_t)0x5501, (q15_t)0xc38c, (q15_t)0x54f6, (q15_t)0xc387, (q15_t)0x54ea, (q15_t)0xc383, (q15_t)0x54de, (q15_t)0xc37f, - (q15_t)0x54d2, (q15_t)0xc37b, (q15_t)0x54c6, (q15_t)0xc377, (q15_t)0x54ba, (q15_t)0xc373, (q15_t)0x54ae, (q15_t)0xc36f, - (q15_t)0x54a2, (q15_t)0xc36b, (q15_t)0x5496, (q15_t)0xc367, (q15_t)0x548b, (q15_t)0xc363, (q15_t)0x547f, (q15_t)0xc35f, - (q15_t)0x5473, (q15_t)0xc35b, (q15_t)0x5467, (q15_t)0xc357, (q15_t)0x545b, (q15_t)0xc353, (q15_t)0x544f, (q15_t)0xc34f, - (q15_t)0x5443, (q15_t)0xc34b, (q15_t)0x5437, (q15_t)0xc347, (q15_t)0x542b, (q15_t)0xc343, (q15_t)0x541f, (q15_t)0xc33f, - (q15_t)0x5413, (q15_t)0xc33b, (q15_t)0x5407, (q15_t)0xc337, (q15_t)0x53fb, (q15_t)0xc333, (q15_t)0x53f0, (q15_t)0xc32f, - (q15_t)0x53e4, (q15_t)0xc32b, (q15_t)0x53d8, (q15_t)0xc327, (q15_t)0x53cc, (q15_t)0xc323, (q15_t)0x53c0, (q15_t)0xc320, - (q15_t)0x53b4, (q15_t)0xc31c, (q15_t)0x53a8, (q15_t)0xc318, (q15_t)0x539c, (q15_t)0xc314, (q15_t)0x5390, (q15_t)0xc310, - (q15_t)0x5384, (q15_t)0xc30c, (q15_t)0x5378, (q15_t)0xc308, (q15_t)0x536c, (q15_t)0xc305, (q15_t)0x5360, (q15_t)0xc301, - (q15_t)0x5354, (q15_t)0xc2fd, (q15_t)0x5348, (q15_t)0xc2f9, (q15_t)0x533c, (q15_t)0xc2f5, (q15_t)0x5330, (q15_t)0xc2f2, - (q15_t)0x5324, (q15_t)0xc2ee, (q15_t)0x5318, (q15_t)0xc2ea, (q15_t)0x530c, (q15_t)0xc2e6, (q15_t)0x5300, (q15_t)0xc2e3, - (q15_t)0x52f4, (q15_t)0xc2df, (q15_t)0x52e8, (q15_t)0xc2db, (q15_t)0x52dc, (q15_t)0xc2d8, (q15_t)0x52d0, (q15_t)0xc2d4, - (q15_t)0x52c4, (q15_t)0xc2d0, (q15_t)0x52b8, (q15_t)0xc2cc, (q15_t)0x52ac, (q15_t)0xc2c9, (q15_t)0x52a0, (q15_t)0xc2c5, - (q15_t)0x5294, (q15_t)0xc2c1, (q15_t)0x5288, (q15_t)0xc2be, (q15_t)0x527c, (q15_t)0xc2ba, (q15_t)0x5270, (q15_t)0xc2b7, - (q15_t)0x5264, (q15_t)0xc2b3, (q15_t)0x5258, (q15_t)0xc2af, (q15_t)0x524c, (q15_t)0xc2ac, (q15_t)0x5240, (q15_t)0xc2a8, - (q15_t)0x5234, (q15_t)0xc2a5, (q15_t)0x5228, (q15_t)0xc2a1, (q15_t)0x521c, (q15_t)0xc29d, (q15_t)0x5210, (q15_t)0xc29a, - (q15_t)0x5204, (q15_t)0xc296, (q15_t)0x51f7, (q15_t)0xc293, (q15_t)0x51eb, (q15_t)0xc28f, (q15_t)0x51df, (q15_t)0xc28c, - (q15_t)0x51d3, (q15_t)0xc288, (q15_t)0x51c7, (q15_t)0xc285, (q15_t)0x51bb, (q15_t)0xc281, (q15_t)0x51af, (q15_t)0xc27e, - (q15_t)0x51a3, (q15_t)0xc27a, (q15_t)0x5197, (q15_t)0xc277, (q15_t)0x518b, (q15_t)0xc273, (q15_t)0x517f, (q15_t)0xc270, - (q15_t)0x5173, (q15_t)0xc26d, (q15_t)0x5167, (q15_t)0xc269, (q15_t)0x515a, (q15_t)0xc266, (q15_t)0x514e, (q15_t)0xc262, - (q15_t)0x5142, (q15_t)0xc25f, (q15_t)0x5136, (q15_t)0xc25c, (q15_t)0x512a, (q15_t)0xc258, (q15_t)0x511e, (q15_t)0xc255, - (q15_t)0x5112, (q15_t)0xc251, (q15_t)0x5106, (q15_t)0xc24e, (q15_t)0x50fa, (q15_t)0xc24b, (q15_t)0x50ed, (q15_t)0xc247, - (q15_t)0x50e1, (q15_t)0xc244, (q15_t)0x50d5, (q15_t)0xc241, (q15_t)0x50c9, (q15_t)0xc23e, (q15_t)0x50bd, (q15_t)0xc23a, - (q15_t)0x50b1, (q15_t)0xc237, (q15_t)0x50a5, (q15_t)0xc234, (q15_t)0x5099, (q15_t)0xc230, (q15_t)0x508c, (q15_t)0xc22d, - (q15_t)0x5080, (q15_t)0xc22a, (q15_t)0x5074, (q15_t)0xc227, (q15_t)0x5068, (q15_t)0xc223, (q15_t)0x505c, (q15_t)0xc220, - (q15_t)0x5050, (q15_t)0xc21d, (q15_t)0x5044, (q15_t)0xc21a, (q15_t)0x5037, (q15_t)0xc217, (q15_t)0x502b, (q15_t)0xc213, - (q15_t)0x501f, (q15_t)0xc210, (q15_t)0x5013, (q15_t)0xc20d, (q15_t)0x5007, (q15_t)0xc20a, (q15_t)0x4ffb, (q15_t)0xc207, - (q15_t)0x4fee, (q15_t)0xc204, (q15_t)0x4fe2, (q15_t)0xc201, (q15_t)0x4fd6, (q15_t)0xc1fd, (q15_t)0x4fca, (q15_t)0xc1fa, - (q15_t)0x4fbe, (q15_t)0xc1f7, (q15_t)0x4fb2, (q15_t)0xc1f4, (q15_t)0x4fa5, (q15_t)0xc1f1, (q15_t)0x4f99, (q15_t)0xc1ee, - (q15_t)0x4f8d, (q15_t)0xc1eb, (q15_t)0x4f81, (q15_t)0xc1e8, (q15_t)0x4f75, (q15_t)0xc1e5, (q15_t)0x4f68, (q15_t)0xc1e2, - (q15_t)0x4f5c, (q15_t)0xc1df, (q15_t)0x4f50, (q15_t)0xc1dc, (q15_t)0x4f44, (q15_t)0xc1d9, (q15_t)0x4f38, (q15_t)0xc1d6, - (q15_t)0x4f2b, (q15_t)0xc1d3, (q15_t)0x4f1f, (q15_t)0xc1d0, (q15_t)0x4f13, (q15_t)0xc1cd, (q15_t)0x4f07, (q15_t)0xc1ca, - (q15_t)0x4efb, (q15_t)0xc1c7, (q15_t)0x4eee, (q15_t)0xc1c4, (q15_t)0x4ee2, (q15_t)0xc1c1, (q15_t)0x4ed6, (q15_t)0xc1be, - (q15_t)0x4eca, (q15_t)0xc1bb, (q15_t)0x4ebd, (q15_t)0xc1b8, (q15_t)0x4eb1, (q15_t)0xc1b6, (q15_t)0x4ea5, (q15_t)0xc1b3, - (q15_t)0x4e99, (q15_t)0xc1b0, (q15_t)0x4e8c, (q15_t)0xc1ad, (q15_t)0x4e80, (q15_t)0xc1aa, (q15_t)0x4e74, (q15_t)0xc1a7, - (q15_t)0x4e68, (q15_t)0xc1a4, (q15_t)0x4e5c, (q15_t)0xc1a2, (q15_t)0x4e4f, (q15_t)0xc19f, (q15_t)0x4e43, (q15_t)0xc19c, - (q15_t)0x4e37, (q15_t)0xc199, (q15_t)0x4e2b, (q15_t)0xc196, (q15_t)0x4e1e, (q15_t)0xc194, (q15_t)0x4e12, (q15_t)0xc191, - (q15_t)0x4e06, (q15_t)0xc18e, (q15_t)0x4df9, (q15_t)0xc18b, (q15_t)0x4ded, (q15_t)0xc189, (q15_t)0x4de1, (q15_t)0xc186, - (q15_t)0x4dd5, (q15_t)0xc183, (q15_t)0x4dc8, (q15_t)0xc180, (q15_t)0x4dbc, (q15_t)0xc17e, (q15_t)0x4db0, (q15_t)0xc17b, - (q15_t)0x4da4, (q15_t)0xc178, (q15_t)0x4d97, (q15_t)0xc176, (q15_t)0x4d8b, (q15_t)0xc173, (q15_t)0x4d7f, (q15_t)0xc170, - (q15_t)0x4d72, (q15_t)0xc16e, (q15_t)0x4d66, (q15_t)0xc16b, (q15_t)0x4d5a, (q15_t)0xc168, (q15_t)0x4d4e, (q15_t)0xc166, - (q15_t)0x4d41, (q15_t)0xc163, (q15_t)0x4d35, (q15_t)0xc161, (q15_t)0x4d29, (q15_t)0xc15e, (q15_t)0x4d1c, (q15_t)0xc15b, - (q15_t)0x4d10, (q15_t)0xc159, (q15_t)0x4d04, (q15_t)0xc156, (q15_t)0x4cf8, (q15_t)0xc154, (q15_t)0x4ceb, (q15_t)0xc151, - (q15_t)0x4cdf, (q15_t)0xc14f, (q15_t)0x4cd3, (q15_t)0xc14c, (q15_t)0x4cc6, (q15_t)0xc14a, (q15_t)0x4cba, (q15_t)0xc147, - (q15_t)0x4cae, (q15_t)0xc145, (q15_t)0x4ca1, (q15_t)0xc142, (q15_t)0x4c95, (q15_t)0xc140, (q15_t)0x4c89, (q15_t)0xc13d, - (q15_t)0x4c7c, (q15_t)0xc13b, (q15_t)0x4c70, (q15_t)0xc138, (q15_t)0x4c64, (q15_t)0xc136, (q15_t)0x4c57, (q15_t)0xc134, - (q15_t)0x4c4b, (q15_t)0xc131, (q15_t)0x4c3f, (q15_t)0xc12f, (q15_t)0x4c32, (q15_t)0xc12c, (q15_t)0x4c26, (q15_t)0xc12a, - (q15_t)0x4c1a, (q15_t)0xc128, (q15_t)0x4c0d, (q15_t)0xc125, (q15_t)0x4c01, (q15_t)0xc123, (q15_t)0x4bf5, (q15_t)0xc120, - (q15_t)0x4be8, (q15_t)0xc11e, (q15_t)0x4bdc, (q15_t)0xc11c, (q15_t)0x4bd0, (q15_t)0xc119, (q15_t)0x4bc3, (q15_t)0xc117, - (q15_t)0x4bb7, (q15_t)0xc115, (q15_t)0x4bab, (q15_t)0xc113, (q15_t)0x4b9e, (q15_t)0xc110, (q15_t)0x4b92, (q15_t)0xc10e, - (q15_t)0x4b85, (q15_t)0xc10c, (q15_t)0x4b79, (q15_t)0xc109, (q15_t)0x4b6d, (q15_t)0xc107, (q15_t)0x4b60, (q15_t)0xc105, - (q15_t)0x4b54, (q15_t)0xc103, (q15_t)0x4b48, (q15_t)0xc100, (q15_t)0x4b3b, (q15_t)0xc0fe, (q15_t)0x4b2f, (q15_t)0xc0fc, - (q15_t)0x4b23, (q15_t)0xc0fa, (q15_t)0x4b16, (q15_t)0xc0f8, (q15_t)0x4b0a, (q15_t)0xc0f6, (q15_t)0x4afd, (q15_t)0xc0f3, - (q15_t)0x4af1, (q15_t)0xc0f1, (q15_t)0x4ae5, (q15_t)0xc0ef, (q15_t)0x4ad8, (q15_t)0xc0ed, (q15_t)0x4acc, (q15_t)0xc0eb, - (q15_t)0x4ac0, (q15_t)0xc0e9, (q15_t)0x4ab3, (q15_t)0xc0e7, (q15_t)0x4aa7, (q15_t)0xc0e4, (q15_t)0x4a9a, (q15_t)0xc0e2, - (q15_t)0x4a8e, (q15_t)0xc0e0, (q15_t)0x4a82, (q15_t)0xc0de, (q15_t)0x4a75, (q15_t)0xc0dc, (q15_t)0x4a69, (q15_t)0xc0da, - (q15_t)0x4a5c, (q15_t)0xc0d8, (q15_t)0x4a50, (q15_t)0xc0d6, (q15_t)0x4a44, (q15_t)0xc0d4, (q15_t)0x4a37, (q15_t)0xc0d2, - (q15_t)0x4a2b, (q15_t)0xc0d0, (q15_t)0x4a1e, (q15_t)0xc0ce, (q15_t)0x4a12, (q15_t)0xc0cc, (q15_t)0x4a06, (q15_t)0xc0ca, - (q15_t)0x49f9, (q15_t)0xc0c8, (q15_t)0x49ed, (q15_t)0xc0c6, (q15_t)0x49e0, (q15_t)0xc0c4, (q15_t)0x49d4, (q15_t)0xc0c2, - (q15_t)0x49c7, (q15_t)0xc0c0, (q15_t)0x49bb, (q15_t)0xc0be, (q15_t)0x49af, (q15_t)0xc0bd, (q15_t)0x49a2, (q15_t)0xc0bb, - (q15_t)0x4996, (q15_t)0xc0b9, (q15_t)0x4989, (q15_t)0xc0b7, (q15_t)0x497d, (q15_t)0xc0b5, (q15_t)0x4970, (q15_t)0xc0b3, - (q15_t)0x4964, (q15_t)0xc0b1, (q15_t)0x4958, (q15_t)0xc0af, (q15_t)0x494b, (q15_t)0xc0ae, (q15_t)0x493f, (q15_t)0xc0ac, - (q15_t)0x4932, (q15_t)0xc0aa, (q15_t)0x4926, (q15_t)0xc0a8, (q15_t)0x4919, (q15_t)0xc0a6, (q15_t)0x490d, (q15_t)0xc0a5, - (q15_t)0x4901, (q15_t)0xc0a3, (q15_t)0x48f4, (q15_t)0xc0a1, (q15_t)0x48e8, (q15_t)0xc09f, (q15_t)0x48db, (q15_t)0xc09e, - (q15_t)0x48cf, (q15_t)0xc09c, (q15_t)0x48c2, (q15_t)0xc09a, (q15_t)0x48b6, (q15_t)0xc098, (q15_t)0x48a9, (q15_t)0xc097, - (q15_t)0x489d, (q15_t)0xc095, (q15_t)0x4891, (q15_t)0xc093, (q15_t)0x4884, (q15_t)0xc092, (q15_t)0x4878, (q15_t)0xc090, - (q15_t)0x486b, (q15_t)0xc08e, (q15_t)0x485f, (q15_t)0xc08d, (q15_t)0x4852, (q15_t)0xc08b, (q15_t)0x4846, (q15_t)0xc089, - (q15_t)0x4839, (q15_t)0xc088, (q15_t)0x482d, (q15_t)0xc086, (q15_t)0x4820, (q15_t)0xc085, (q15_t)0x4814, (q15_t)0xc083, - (q15_t)0x4807, (q15_t)0xc081, (q15_t)0x47fb, (q15_t)0xc080, (q15_t)0x47ef, (q15_t)0xc07e, (q15_t)0x47e2, (q15_t)0xc07d, - (q15_t)0x47d6, (q15_t)0xc07b, (q15_t)0x47c9, (q15_t)0xc07a, (q15_t)0x47bd, (q15_t)0xc078, (q15_t)0x47b0, (q15_t)0xc077, - (q15_t)0x47a4, (q15_t)0xc075, (q15_t)0x4797, (q15_t)0xc074, (q15_t)0x478b, (q15_t)0xc072, (q15_t)0x477e, (q15_t)0xc071, - (q15_t)0x4772, (q15_t)0xc06f, (q15_t)0x4765, (q15_t)0xc06e, (q15_t)0x4759, (q15_t)0xc06c, (q15_t)0x474c, (q15_t)0xc06b, - (q15_t)0x4740, (q15_t)0xc069, (q15_t)0x4733, (q15_t)0xc068, (q15_t)0x4727, (q15_t)0xc067, (q15_t)0x471a, (q15_t)0xc065, - (q15_t)0x470e, (q15_t)0xc064, (q15_t)0x4701, (q15_t)0xc062, (q15_t)0x46f5, (q15_t)0xc061, (q15_t)0x46e8, (q15_t)0xc060, - (q15_t)0x46dc, (q15_t)0xc05e, (q15_t)0x46cf, (q15_t)0xc05d, (q15_t)0x46c3, (q15_t)0xc05c, (q15_t)0x46b6, (q15_t)0xc05a, - (q15_t)0x46aa, (q15_t)0xc059, (q15_t)0x469d, (q15_t)0xc058, (q15_t)0x4691, (q15_t)0xc056, (q15_t)0x4684, (q15_t)0xc055, - (q15_t)0x4678, (q15_t)0xc054, (q15_t)0x466b, (q15_t)0xc053, (q15_t)0x465f, (q15_t)0xc051, (q15_t)0x4652, (q15_t)0xc050, - (q15_t)0x4646, (q15_t)0xc04f, (q15_t)0x4639, (q15_t)0xc04e, (q15_t)0x462d, (q15_t)0xc04c, (q15_t)0x4620, (q15_t)0xc04b, - (q15_t)0x4614, (q15_t)0xc04a, (q15_t)0x4607, (q15_t)0xc049, (q15_t)0x45fb, (q15_t)0xc048, (q15_t)0x45ee, (q15_t)0xc047, - (q15_t)0x45e2, (q15_t)0xc045, (q15_t)0x45d5, (q15_t)0xc044, (q15_t)0x45c9, (q15_t)0xc043, (q15_t)0x45bc, (q15_t)0xc042, - (q15_t)0x45b0, (q15_t)0xc041, (q15_t)0x45a3, (q15_t)0xc040, (q15_t)0x4597, (q15_t)0xc03f, (q15_t)0x458a, (q15_t)0xc03d, - (q15_t)0x457e, (q15_t)0xc03c, (q15_t)0x4571, (q15_t)0xc03b, (q15_t)0x4565, (q15_t)0xc03a, (q15_t)0x4558, (q15_t)0xc039, - (q15_t)0x454c, (q15_t)0xc038, (q15_t)0x453f, (q15_t)0xc037, (q15_t)0x4533, (q15_t)0xc036, (q15_t)0x4526, (q15_t)0xc035, - (q15_t)0x451a, (q15_t)0xc034, (q15_t)0x450d, (q15_t)0xc033, (q15_t)0x4500, (q15_t)0xc032, (q15_t)0x44f4, (q15_t)0xc031, - (q15_t)0x44e7, (q15_t)0xc030, (q15_t)0x44db, (q15_t)0xc02f, (q15_t)0x44ce, (q15_t)0xc02e, (q15_t)0x44c2, (q15_t)0xc02d, - (q15_t)0x44b5, (q15_t)0xc02c, (q15_t)0x44a9, (q15_t)0xc02b, (q15_t)0x449c, (q15_t)0xc02b, (q15_t)0x4490, (q15_t)0xc02a, - (q15_t)0x4483, (q15_t)0xc029, (q15_t)0x4477, (q15_t)0xc028, (q15_t)0x446a, (q15_t)0xc027, (q15_t)0x445e, (q15_t)0xc026, - (q15_t)0x4451, (q15_t)0xc025, (q15_t)0x4444, (q15_t)0xc024, (q15_t)0x4438, (q15_t)0xc024, (q15_t)0x442b, (q15_t)0xc023, - (q15_t)0x441f, (q15_t)0xc022, (q15_t)0x4412, (q15_t)0xc021, (q15_t)0x4406, (q15_t)0xc020, (q15_t)0x43f9, (q15_t)0xc020, - (q15_t)0x43ed, (q15_t)0xc01f, (q15_t)0x43e0, (q15_t)0xc01e, (q15_t)0x43d4, (q15_t)0xc01d, (q15_t)0x43c7, (q15_t)0xc01d, - (q15_t)0x43bb, (q15_t)0xc01c, (q15_t)0x43ae, (q15_t)0xc01b, (q15_t)0x43a1, (q15_t)0xc01a, (q15_t)0x4395, (q15_t)0xc01a, - (q15_t)0x4388, (q15_t)0xc019, (q15_t)0x437c, (q15_t)0xc018, (q15_t)0x436f, (q15_t)0xc018, (q15_t)0x4363, (q15_t)0xc017, - (q15_t)0x4356, (q15_t)0xc016, (q15_t)0x434a, (q15_t)0xc016, (q15_t)0x433d, (q15_t)0xc015, (q15_t)0x4330, (q15_t)0xc014, - (q15_t)0x4324, (q15_t)0xc014, (q15_t)0x4317, (q15_t)0xc013, (q15_t)0x430b, (q15_t)0xc013, (q15_t)0x42fe, (q15_t)0xc012, - (q15_t)0x42f2, (q15_t)0xc011, (q15_t)0x42e5, (q15_t)0xc011, (q15_t)0x42d9, (q15_t)0xc010, (q15_t)0x42cc, (q15_t)0xc010, - (q15_t)0x42c0, (q15_t)0xc00f, (q15_t)0x42b3, (q15_t)0xc00f, (q15_t)0x42a6, (q15_t)0xc00e, (q15_t)0x429a, (q15_t)0xc00e, - (q15_t)0x428d, (q15_t)0xc00d, (q15_t)0x4281, (q15_t)0xc00d, (q15_t)0x4274, (q15_t)0xc00c, (q15_t)0x4268, (q15_t)0xc00c, - (q15_t)0x425b, (q15_t)0xc00b, (q15_t)0x424e, (q15_t)0xc00b, (q15_t)0x4242, (q15_t)0xc00a, (q15_t)0x4235, (q15_t)0xc00a, - (q15_t)0x4229, (q15_t)0xc009, (q15_t)0x421c, (q15_t)0xc009, (q15_t)0x4210, (q15_t)0xc009, (q15_t)0x4203, (q15_t)0xc008, - (q15_t)0x41f7, (q15_t)0xc008, (q15_t)0x41ea, (q15_t)0xc007, (q15_t)0x41dd, (q15_t)0xc007, (q15_t)0x41d1, (q15_t)0xc007, - (q15_t)0x41c4, (q15_t)0xc006, (q15_t)0x41b8, (q15_t)0xc006, (q15_t)0x41ab, (q15_t)0xc006, (q15_t)0x419f, (q15_t)0xc005, - (q15_t)0x4192, (q15_t)0xc005, (q15_t)0x4186, (q15_t)0xc005, (q15_t)0x4179, (q15_t)0xc004, (q15_t)0x416c, (q15_t)0xc004, - (q15_t)0x4160, (q15_t)0xc004, (q15_t)0x4153, (q15_t)0xc004, (q15_t)0x4147, (q15_t)0xc003, (q15_t)0x413a, (q15_t)0xc003, - (q15_t)0x412e, (q15_t)0xc003, (q15_t)0x4121, (q15_t)0xc003, (q15_t)0x4114, (q15_t)0xc002, (q15_t)0x4108, (q15_t)0xc002, - (q15_t)0x40fb, (q15_t)0xc002, (q15_t)0x40ef, (q15_t)0xc002, (q15_t)0x40e2, (q15_t)0xc002, (q15_t)0x40d6, (q15_t)0xc001, - (q15_t)0x40c9, (q15_t)0xc001, (q15_t)0x40bc, (q15_t)0xc001, (q15_t)0x40b0, (q15_t)0xc001, (q15_t)0x40a3, (q15_t)0xc001, - (q15_t)0x4097, (q15_t)0xc001, (q15_t)0x408a, (q15_t)0xc001, (q15_t)0x407e, (q15_t)0xc000, (q15_t)0x4071, (q15_t)0xc000, - (q15_t)0x4065, (q15_t)0xc000, (q15_t)0x4058, (q15_t)0xc000, (q15_t)0x404b, (q15_t)0xc000, (q15_t)0x403f, (q15_t)0xc000, - (q15_t)0x4032, (q15_t)0xc000, (q15_t)0x4026, (q15_t)0xc000, (q15_t)0x4019, (q15_t)0xc000, (q15_t)0x400d, (q15_t)0xc000, + (q15_t)0x4000, (q15_t)0x4000, (q15_t)0x400d, (q15_t)0x4000, (q15_t)0x4019, + (q15_t)0x4000, (q15_t)0x4026, (q15_t)0x4000, (q15_t)0x4032, (q15_t)0x4000, + (q15_t)0x403f, (q15_t)0x4000, (q15_t)0x404b, (q15_t)0x4000, (q15_t)0x4058, + (q15_t)0x4000, (q15_t)0x4065, (q15_t)0x4000, (q15_t)0x4071, (q15_t)0x4000, + (q15_t)0x407e, (q15_t)0x4000, (q15_t)0x408a, (q15_t)0x3fff, (q15_t)0x4097, + (q15_t)0x3fff, (q15_t)0x40a3, (q15_t)0x3fff, (q15_t)0x40b0, (q15_t)0x3fff, + (q15_t)0x40bc, (q15_t)0x3fff, (q15_t)0x40c9, (q15_t)0x3fff, (q15_t)0x40d6, + (q15_t)0x3fff, (q15_t)0x40e2, (q15_t)0x3ffe, (q15_t)0x40ef, (q15_t)0x3ffe, + (q15_t)0x40fb, (q15_t)0x3ffe, (q15_t)0x4108, (q15_t)0x3ffe, (q15_t)0x4114, + (q15_t)0x3ffe, (q15_t)0x4121, (q15_t)0x3ffd, (q15_t)0x412e, (q15_t)0x3ffd, + (q15_t)0x413a, (q15_t)0x3ffd, (q15_t)0x4147, (q15_t)0x3ffd, (q15_t)0x4153, + (q15_t)0x3ffc, (q15_t)0x4160, (q15_t)0x3ffc, (q15_t)0x416c, (q15_t)0x3ffc, + (q15_t)0x4179, (q15_t)0x3ffc, (q15_t)0x4186, (q15_t)0x3ffb, (q15_t)0x4192, + (q15_t)0x3ffb, (q15_t)0x419f, (q15_t)0x3ffb, (q15_t)0x41ab, (q15_t)0x3ffa, + (q15_t)0x41b8, (q15_t)0x3ffa, (q15_t)0x41c4, (q15_t)0x3ffa, (q15_t)0x41d1, + (q15_t)0x3ff9, (q15_t)0x41dd, (q15_t)0x3ff9, (q15_t)0x41ea, (q15_t)0x3ff9, + (q15_t)0x41f7, (q15_t)0x3ff8, (q15_t)0x4203, (q15_t)0x3ff8, (q15_t)0x4210, + (q15_t)0x3ff7, (q15_t)0x421c, (q15_t)0x3ff7, (q15_t)0x4229, (q15_t)0x3ff7, + (q15_t)0x4235, (q15_t)0x3ff6, (q15_t)0x4242, (q15_t)0x3ff6, (q15_t)0x424e, + (q15_t)0x3ff5, (q15_t)0x425b, (q15_t)0x3ff5, (q15_t)0x4268, (q15_t)0x3ff4, + (q15_t)0x4274, (q15_t)0x3ff4, (q15_t)0x4281, (q15_t)0x3ff3, (q15_t)0x428d, + (q15_t)0x3ff3, (q15_t)0x429a, (q15_t)0x3ff2, (q15_t)0x42a6, (q15_t)0x3ff2, + (q15_t)0x42b3, (q15_t)0x3ff1, (q15_t)0x42c0, (q15_t)0x3ff1, (q15_t)0x42cc, + (q15_t)0x3ff0, (q15_t)0x42d9, (q15_t)0x3ff0, (q15_t)0x42e5, (q15_t)0x3fef, + (q15_t)0x42f2, (q15_t)0x3fef, (q15_t)0x42fe, (q15_t)0x3fee, (q15_t)0x430b, + (q15_t)0x3fed, (q15_t)0x4317, (q15_t)0x3fed, (q15_t)0x4324, (q15_t)0x3fec, + (q15_t)0x4330, (q15_t)0x3fec, (q15_t)0x433d, (q15_t)0x3feb, (q15_t)0x434a, + (q15_t)0x3fea, (q15_t)0x4356, (q15_t)0x3fea, (q15_t)0x4363, (q15_t)0x3fe9, + (q15_t)0x436f, (q15_t)0x3fe8, (q15_t)0x437c, (q15_t)0x3fe8, (q15_t)0x4388, + (q15_t)0x3fe7, (q15_t)0x4395, (q15_t)0x3fe6, (q15_t)0x43a1, (q15_t)0x3fe6, + (q15_t)0x43ae, (q15_t)0x3fe5, (q15_t)0x43bb, (q15_t)0x3fe4, (q15_t)0x43c7, + (q15_t)0x3fe3, (q15_t)0x43d4, (q15_t)0x3fe3, (q15_t)0x43e0, (q15_t)0x3fe2, + (q15_t)0x43ed, (q15_t)0x3fe1, (q15_t)0x43f9, (q15_t)0x3fe0, (q15_t)0x4406, + (q15_t)0x3fe0, (q15_t)0x4412, (q15_t)0x3fdf, (q15_t)0x441f, (q15_t)0x3fde, + (q15_t)0x442b, (q15_t)0x3fdd, (q15_t)0x4438, (q15_t)0x3fdc, (q15_t)0x4444, + (q15_t)0x3fdc, (q15_t)0x4451, (q15_t)0x3fdb, (q15_t)0x445e, (q15_t)0x3fda, + (q15_t)0x446a, (q15_t)0x3fd9, (q15_t)0x4477, (q15_t)0x3fd8, (q15_t)0x4483, + (q15_t)0x3fd7, (q15_t)0x4490, (q15_t)0x3fd6, (q15_t)0x449c, (q15_t)0x3fd5, + (q15_t)0x44a9, (q15_t)0x3fd5, (q15_t)0x44b5, (q15_t)0x3fd4, (q15_t)0x44c2, + (q15_t)0x3fd3, (q15_t)0x44ce, (q15_t)0x3fd2, (q15_t)0x44db, (q15_t)0x3fd1, + (q15_t)0x44e7, (q15_t)0x3fd0, (q15_t)0x44f4, (q15_t)0x3fcf, (q15_t)0x4500, + (q15_t)0x3fce, (q15_t)0x450d, (q15_t)0x3fcd, (q15_t)0x451a, (q15_t)0x3fcc, + (q15_t)0x4526, (q15_t)0x3fcb, (q15_t)0x4533, (q15_t)0x3fca, (q15_t)0x453f, + (q15_t)0x3fc9, (q15_t)0x454c, (q15_t)0x3fc8, (q15_t)0x4558, (q15_t)0x3fc7, + (q15_t)0x4565, (q15_t)0x3fc6, (q15_t)0x4571, (q15_t)0x3fc5, (q15_t)0x457e, + (q15_t)0x3fc4, (q15_t)0x458a, (q15_t)0x3fc3, (q15_t)0x4597, (q15_t)0x3fc1, + (q15_t)0x45a3, (q15_t)0x3fc0, (q15_t)0x45b0, (q15_t)0x3fbf, (q15_t)0x45bc, + (q15_t)0x3fbe, (q15_t)0x45c9, (q15_t)0x3fbd, (q15_t)0x45d5, (q15_t)0x3fbc, + (q15_t)0x45e2, (q15_t)0x3fbb, (q15_t)0x45ee, (q15_t)0x3fb9, (q15_t)0x45fb, + (q15_t)0x3fb8, (q15_t)0x4607, (q15_t)0x3fb7, (q15_t)0x4614, (q15_t)0x3fb6, + (q15_t)0x4620, (q15_t)0x3fb5, (q15_t)0x462d, (q15_t)0x3fb4, (q15_t)0x4639, + (q15_t)0x3fb2, (q15_t)0x4646, (q15_t)0x3fb1, (q15_t)0x4652, (q15_t)0x3fb0, + (q15_t)0x465f, (q15_t)0x3faf, (q15_t)0x466b, (q15_t)0x3fad, (q15_t)0x4678, + (q15_t)0x3fac, (q15_t)0x4684, (q15_t)0x3fab, (q15_t)0x4691, (q15_t)0x3faa, + (q15_t)0x469d, (q15_t)0x3fa8, (q15_t)0x46aa, (q15_t)0x3fa7, (q15_t)0x46b6, + (q15_t)0x3fa6, (q15_t)0x46c3, (q15_t)0x3fa4, (q15_t)0x46cf, (q15_t)0x3fa3, + (q15_t)0x46dc, (q15_t)0x3fa2, (q15_t)0x46e8, (q15_t)0x3fa0, (q15_t)0x46f5, + (q15_t)0x3f9f, (q15_t)0x4701, (q15_t)0x3f9e, (q15_t)0x470e, (q15_t)0x3f9c, + (q15_t)0x471a, (q15_t)0x3f9b, (q15_t)0x4727, (q15_t)0x3f99, (q15_t)0x4733, + (q15_t)0x3f98, (q15_t)0x4740, (q15_t)0x3f97, (q15_t)0x474c, (q15_t)0x3f95, + (q15_t)0x4759, (q15_t)0x3f94, (q15_t)0x4765, (q15_t)0x3f92, (q15_t)0x4772, + (q15_t)0x3f91, (q15_t)0x477e, (q15_t)0x3f8f, (q15_t)0x478b, (q15_t)0x3f8e, + (q15_t)0x4797, (q15_t)0x3f8c, (q15_t)0x47a4, (q15_t)0x3f8b, (q15_t)0x47b0, + (q15_t)0x3f89, (q15_t)0x47bd, (q15_t)0x3f88, (q15_t)0x47c9, (q15_t)0x3f86, + (q15_t)0x47d6, (q15_t)0x3f85, (q15_t)0x47e2, (q15_t)0x3f83, (q15_t)0x47ef, + (q15_t)0x3f82, (q15_t)0x47fb, (q15_t)0x3f80, (q15_t)0x4807, (q15_t)0x3f7f, + (q15_t)0x4814, (q15_t)0x3f7d, (q15_t)0x4820, (q15_t)0x3f7b, (q15_t)0x482d, + (q15_t)0x3f7a, (q15_t)0x4839, (q15_t)0x3f78, (q15_t)0x4846, (q15_t)0x3f77, + (q15_t)0x4852, (q15_t)0x3f75, (q15_t)0x485f, (q15_t)0x3f73, (q15_t)0x486b, + (q15_t)0x3f72, (q15_t)0x4878, (q15_t)0x3f70, (q15_t)0x4884, (q15_t)0x3f6e, + (q15_t)0x4891, (q15_t)0x3f6d, (q15_t)0x489d, (q15_t)0x3f6b, (q15_t)0x48a9, + (q15_t)0x3f69, (q15_t)0x48b6, (q15_t)0x3f68, (q15_t)0x48c2, (q15_t)0x3f66, + (q15_t)0x48cf, (q15_t)0x3f64, (q15_t)0x48db, (q15_t)0x3f62, (q15_t)0x48e8, + (q15_t)0x3f61, (q15_t)0x48f4, (q15_t)0x3f5f, (q15_t)0x4901, (q15_t)0x3f5d, + (q15_t)0x490d, (q15_t)0x3f5b, (q15_t)0x4919, (q15_t)0x3f5a, (q15_t)0x4926, + (q15_t)0x3f58, (q15_t)0x4932, (q15_t)0x3f56, (q15_t)0x493f, (q15_t)0x3f54, + (q15_t)0x494b, (q15_t)0x3f52, (q15_t)0x4958, (q15_t)0x3f51, (q15_t)0x4964, + (q15_t)0x3f4f, (q15_t)0x4970, (q15_t)0x3f4d, (q15_t)0x497d, (q15_t)0x3f4b, + (q15_t)0x4989, (q15_t)0x3f49, (q15_t)0x4996, (q15_t)0x3f47, (q15_t)0x49a2, + (q15_t)0x3f45, (q15_t)0x49af, (q15_t)0x3f43, (q15_t)0x49bb, (q15_t)0x3f42, + (q15_t)0x49c7, (q15_t)0x3f40, (q15_t)0x49d4, (q15_t)0x3f3e, (q15_t)0x49e0, + (q15_t)0x3f3c, (q15_t)0x49ed, (q15_t)0x3f3a, (q15_t)0x49f9, (q15_t)0x3f38, + (q15_t)0x4a06, (q15_t)0x3f36, (q15_t)0x4a12, (q15_t)0x3f34, (q15_t)0x4a1e, + (q15_t)0x3f32, (q15_t)0x4a2b, (q15_t)0x3f30, (q15_t)0x4a37, (q15_t)0x3f2e, + (q15_t)0x4a44, (q15_t)0x3f2c, (q15_t)0x4a50, (q15_t)0x3f2a, (q15_t)0x4a5c, + (q15_t)0x3f28, (q15_t)0x4a69, (q15_t)0x3f26, (q15_t)0x4a75, (q15_t)0x3f24, + (q15_t)0x4a82, (q15_t)0x3f22, (q15_t)0x4a8e, (q15_t)0x3f20, (q15_t)0x4a9a, + (q15_t)0x3f1e, (q15_t)0x4aa7, (q15_t)0x3f1c, (q15_t)0x4ab3, (q15_t)0x3f19, + (q15_t)0x4ac0, (q15_t)0x3f17, (q15_t)0x4acc, (q15_t)0x3f15, (q15_t)0x4ad8, + (q15_t)0x3f13, (q15_t)0x4ae5, (q15_t)0x3f11, (q15_t)0x4af1, (q15_t)0x3f0f, + (q15_t)0x4afd, (q15_t)0x3f0d, (q15_t)0x4b0a, (q15_t)0x3f0a, (q15_t)0x4b16, + (q15_t)0x3f08, (q15_t)0x4b23, (q15_t)0x3f06, (q15_t)0x4b2f, (q15_t)0x3f04, + (q15_t)0x4b3b, (q15_t)0x3f02, (q15_t)0x4b48, (q15_t)0x3f00, (q15_t)0x4b54, + (q15_t)0x3efd, (q15_t)0x4b60, (q15_t)0x3efb, (q15_t)0x4b6d, (q15_t)0x3ef9, + (q15_t)0x4b79, (q15_t)0x3ef7, (q15_t)0x4b85, (q15_t)0x3ef4, (q15_t)0x4b92, + (q15_t)0x3ef2, (q15_t)0x4b9e, (q15_t)0x3ef0, (q15_t)0x4bab, (q15_t)0x3eed, + (q15_t)0x4bb7, (q15_t)0x3eeb, (q15_t)0x4bc3, (q15_t)0x3ee9, (q15_t)0x4bd0, + (q15_t)0x3ee7, (q15_t)0x4bdc, (q15_t)0x3ee4, (q15_t)0x4be8, (q15_t)0x3ee2, + (q15_t)0x4bf5, (q15_t)0x3ee0, (q15_t)0x4c01, (q15_t)0x3edd, (q15_t)0x4c0d, + (q15_t)0x3edb, (q15_t)0x4c1a, (q15_t)0x3ed8, (q15_t)0x4c26, (q15_t)0x3ed6, + (q15_t)0x4c32, (q15_t)0x3ed4, (q15_t)0x4c3f, (q15_t)0x3ed1, (q15_t)0x4c4b, + (q15_t)0x3ecf, (q15_t)0x4c57, (q15_t)0x3ecc, (q15_t)0x4c64, (q15_t)0x3eca, + (q15_t)0x4c70, (q15_t)0x3ec8, (q15_t)0x4c7c, (q15_t)0x3ec5, (q15_t)0x4c89, + (q15_t)0x3ec3, (q15_t)0x4c95, (q15_t)0x3ec0, (q15_t)0x4ca1, (q15_t)0x3ebe, + (q15_t)0x4cae, (q15_t)0x3ebb, (q15_t)0x4cba, (q15_t)0x3eb9, (q15_t)0x4cc6, + (q15_t)0x3eb6, (q15_t)0x4cd3, (q15_t)0x3eb4, (q15_t)0x4cdf, (q15_t)0x3eb1, + (q15_t)0x4ceb, (q15_t)0x3eaf, (q15_t)0x4cf8, (q15_t)0x3eac, (q15_t)0x4d04, + (q15_t)0x3eaa, (q15_t)0x4d10, (q15_t)0x3ea7, (q15_t)0x4d1c, (q15_t)0x3ea5, + (q15_t)0x4d29, (q15_t)0x3ea2, (q15_t)0x4d35, (q15_t)0x3e9f, (q15_t)0x4d41, + (q15_t)0x3e9d, (q15_t)0x4d4e, (q15_t)0x3e9a, (q15_t)0x4d5a, (q15_t)0x3e98, + (q15_t)0x4d66, (q15_t)0x3e95, (q15_t)0x4d72, (q15_t)0x3e92, (q15_t)0x4d7f, + (q15_t)0x3e90, (q15_t)0x4d8b, (q15_t)0x3e8d, (q15_t)0x4d97, (q15_t)0x3e8a, + (q15_t)0x4da4, (q15_t)0x3e88, (q15_t)0x4db0, (q15_t)0x3e85, (q15_t)0x4dbc, + (q15_t)0x3e82, (q15_t)0x4dc8, (q15_t)0x3e80, (q15_t)0x4dd5, (q15_t)0x3e7d, + (q15_t)0x4de1, (q15_t)0x3e7a, (q15_t)0x4ded, (q15_t)0x3e77, (q15_t)0x4df9, + (q15_t)0x3e75, (q15_t)0x4e06, (q15_t)0x3e72, (q15_t)0x4e12, (q15_t)0x3e6f, + (q15_t)0x4e1e, (q15_t)0x3e6c, (q15_t)0x4e2b, (q15_t)0x3e6a, (q15_t)0x4e37, + (q15_t)0x3e67, (q15_t)0x4e43, (q15_t)0x3e64, (q15_t)0x4e4f, (q15_t)0x3e61, + (q15_t)0x4e5c, (q15_t)0x3e5e, (q15_t)0x4e68, (q15_t)0x3e5c, (q15_t)0x4e74, + (q15_t)0x3e59, (q15_t)0x4e80, (q15_t)0x3e56, (q15_t)0x4e8c, (q15_t)0x3e53, + (q15_t)0x4e99, (q15_t)0x3e50, (q15_t)0x4ea5, (q15_t)0x3e4d, (q15_t)0x4eb1, + (q15_t)0x3e4a, (q15_t)0x4ebd, (q15_t)0x3e48, (q15_t)0x4eca, (q15_t)0x3e45, + (q15_t)0x4ed6, (q15_t)0x3e42, (q15_t)0x4ee2, (q15_t)0x3e3f, (q15_t)0x4eee, + (q15_t)0x3e3c, (q15_t)0x4efb, (q15_t)0x3e39, (q15_t)0x4f07, (q15_t)0x3e36, + (q15_t)0x4f13, (q15_t)0x3e33, (q15_t)0x4f1f, (q15_t)0x3e30, (q15_t)0x4f2b, + (q15_t)0x3e2d, (q15_t)0x4f38, (q15_t)0x3e2a, (q15_t)0x4f44, (q15_t)0x3e27, + (q15_t)0x4f50, (q15_t)0x3e24, (q15_t)0x4f5c, (q15_t)0x3e21, (q15_t)0x4f68, + (q15_t)0x3e1e, (q15_t)0x4f75, (q15_t)0x3e1b, (q15_t)0x4f81, (q15_t)0x3e18, + (q15_t)0x4f8d, (q15_t)0x3e15, (q15_t)0x4f99, (q15_t)0x3e12, (q15_t)0x4fa5, + (q15_t)0x3e0f, (q15_t)0x4fb2, (q15_t)0x3e0c, (q15_t)0x4fbe, (q15_t)0x3e09, + (q15_t)0x4fca, (q15_t)0x3e06, (q15_t)0x4fd6, (q15_t)0x3e03, (q15_t)0x4fe2, + (q15_t)0x3dff, (q15_t)0x4fee, (q15_t)0x3dfc, (q15_t)0x4ffb, (q15_t)0x3df9, + (q15_t)0x5007, (q15_t)0x3df6, (q15_t)0x5013, (q15_t)0x3df3, (q15_t)0x501f, + (q15_t)0x3df0, (q15_t)0x502b, (q15_t)0x3ded, (q15_t)0x5037, (q15_t)0x3de9, + (q15_t)0x5044, (q15_t)0x3de6, (q15_t)0x5050, (q15_t)0x3de3, (q15_t)0x505c, + (q15_t)0x3de0, (q15_t)0x5068, (q15_t)0x3ddd, (q15_t)0x5074, (q15_t)0x3dd9, + (q15_t)0x5080, (q15_t)0x3dd6, (q15_t)0x508c, (q15_t)0x3dd3, (q15_t)0x5099, + (q15_t)0x3dd0, (q15_t)0x50a5, (q15_t)0x3dcc, (q15_t)0x50b1, (q15_t)0x3dc9, + (q15_t)0x50bd, (q15_t)0x3dc6, (q15_t)0x50c9, (q15_t)0x3dc2, (q15_t)0x50d5, + (q15_t)0x3dbf, (q15_t)0x50e1, (q15_t)0x3dbc, (q15_t)0x50ed, (q15_t)0x3db9, + (q15_t)0x50fa, (q15_t)0x3db5, (q15_t)0x5106, (q15_t)0x3db2, (q15_t)0x5112, + (q15_t)0x3daf, (q15_t)0x511e, (q15_t)0x3dab, (q15_t)0x512a, (q15_t)0x3da8, + (q15_t)0x5136, (q15_t)0x3da4, (q15_t)0x5142, (q15_t)0x3da1, (q15_t)0x514e, + (q15_t)0x3d9e, (q15_t)0x515a, (q15_t)0x3d9a, (q15_t)0x5167, (q15_t)0x3d97, + (q15_t)0x5173, (q15_t)0x3d93, (q15_t)0x517f, (q15_t)0x3d90, (q15_t)0x518b, + (q15_t)0x3d8d, (q15_t)0x5197, (q15_t)0x3d89, (q15_t)0x51a3, (q15_t)0x3d86, + (q15_t)0x51af, (q15_t)0x3d82, (q15_t)0x51bb, (q15_t)0x3d7f, (q15_t)0x51c7, + (q15_t)0x3d7b, (q15_t)0x51d3, (q15_t)0x3d78, (q15_t)0x51df, (q15_t)0x3d74, + (q15_t)0x51eb, (q15_t)0x3d71, (q15_t)0x51f7, (q15_t)0x3d6d, (q15_t)0x5204, + (q15_t)0x3d6a, (q15_t)0x5210, (q15_t)0x3d66, (q15_t)0x521c, (q15_t)0x3d63, + (q15_t)0x5228, (q15_t)0x3d5f, (q15_t)0x5234, (q15_t)0x3d5b, (q15_t)0x5240, + (q15_t)0x3d58, (q15_t)0x524c, (q15_t)0x3d54, (q15_t)0x5258, (q15_t)0x3d51, + (q15_t)0x5264, (q15_t)0x3d4d, (q15_t)0x5270, (q15_t)0x3d49, (q15_t)0x527c, + (q15_t)0x3d46, (q15_t)0x5288, (q15_t)0x3d42, (q15_t)0x5294, (q15_t)0x3d3f, + (q15_t)0x52a0, (q15_t)0x3d3b, (q15_t)0x52ac, (q15_t)0x3d37, (q15_t)0x52b8, + (q15_t)0x3d34, (q15_t)0x52c4, (q15_t)0x3d30, (q15_t)0x52d0, (q15_t)0x3d2c, + (q15_t)0x52dc, (q15_t)0x3d28, (q15_t)0x52e8, (q15_t)0x3d25, (q15_t)0x52f4, + (q15_t)0x3d21, (q15_t)0x5300, (q15_t)0x3d1d, (q15_t)0x530c, (q15_t)0x3d1a, + (q15_t)0x5318, (q15_t)0x3d16, (q15_t)0x5324, (q15_t)0x3d12, (q15_t)0x5330, + (q15_t)0x3d0e, (q15_t)0x533c, (q15_t)0x3d0b, (q15_t)0x5348, (q15_t)0x3d07, + (q15_t)0x5354, (q15_t)0x3d03, (q15_t)0x5360, (q15_t)0x3cff, (q15_t)0x536c, + (q15_t)0x3cfb, (q15_t)0x5378, (q15_t)0x3cf8, (q15_t)0x5384, (q15_t)0x3cf4, + (q15_t)0x5390, (q15_t)0x3cf0, (q15_t)0x539c, (q15_t)0x3cec, (q15_t)0x53a8, + (q15_t)0x3ce8, (q15_t)0x53b4, (q15_t)0x3ce4, (q15_t)0x53c0, (q15_t)0x3ce0, + (q15_t)0x53cc, (q15_t)0x3cdd, (q15_t)0x53d8, (q15_t)0x3cd9, (q15_t)0x53e4, + (q15_t)0x3cd5, (q15_t)0x53f0, (q15_t)0x3cd1, (q15_t)0x53fb, (q15_t)0x3ccd, + (q15_t)0x5407, (q15_t)0x3cc9, (q15_t)0x5413, (q15_t)0x3cc5, (q15_t)0x541f, + (q15_t)0x3cc1, (q15_t)0x542b, (q15_t)0x3cbd, (q15_t)0x5437, (q15_t)0x3cb9, + (q15_t)0x5443, (q15_t)0x3cb5, (q15_t)0x544f, (q15_t)0x3cb1, (q15_t)0x545b, + (q15_t)0x3cad, (q15_t)0x5467, (q15_t)0x3ca9, (q15_t)0x5473, (q15_t)0x3ca5, + (q15_t)0x547f, (q15_t)0x3ca1, (q15_t)0x548b, (q15_t)0x3c9d, (q15_t)0x5496, + (q15_t)0x3c99, (q15_t)0x54a2, (q15_t)0x3c95, (q15_t)0x54ae, (q15_t)0x3c91, + (q15_t)0x54ba, (q15_t)0x3c8d, (q15_t)0x54c6, (q15_t)0x3c89, (q15_t)0x54d2, + (q15_t)0x3c85, (q15_t)0x54de, (q15_t)0x3c81, (q15_t)0x54ea, (q15_t)0x3c7d, + (q15_t)0x54f6, (q15_t)0x3c79, (q15_t)0x5501, (q15_t)0x3c74, (q15_t)0x550d, + (q15_t)0x3c70, (q15_t)0x5519, (q15_t)0x3c6c, (q15_t)0x5525, (q15_t)0x3c68, + (q15_t)0x5531, (q15_t)0x3c64, (q15_t)0x553d, (q15_t)0x3c60, (q15_t)0x5549, + (q15_t)0x3c5b, (q15_t)0x5554, (q15_t)0x3c57, (q15_t)0x5560, (q15_t)0x3c53, + (q15_t)0x556c, (q15_t)0x3c4f, (q15_t)0x5578, (q15_t)0x3c4b, (q15_t)0x5584, + (q15_t)0x3c46, (q15_t)0x5590, (q15_t)0x3c42, (q15_t)0x559b, (q15_t)0x3c3e, + (q15_t)0x55a7, (q15_t)0x3c3a, (q15_t)0x55b3, (q15_t)0x3c36, (q15_t)0x55bf, + (q15_t)0x3c31, (q15_t)0x55cb, (q15_t)0x3c2d, (q15_t)0x55d7, (q15_t)0x3c29, + (q15_t)0x55e2, (q15_t)0x3c24, (q15_t)0x55ee, (q15_t)0x3c20, (q15_t)0x55fa, + (q15_t)0x3c1c, (q15_t)0x5606, (q15_t)0x3c17, (q15_t)0x5612, (q15_t)0x3c13, + (q15_t)0x561d, (q15_t)0x3c0f, (q15_t)0x5629, (q15_t)0x3c0a, (q15_t)0x5635, + (q15_t)0x3c06, (q15_t)0x5641, (q15_t)0x3c02, (q15_t)0x564c, (q15_t)0x3bfd, + (q15_t)0x5658, (q15_t)0x3bf9, (q15_t)0x5664, (q15_t)0x3bf5, (q15_t)0x5670, + (q15_t)0x3bf0, (q15_t)0x567c, (q15_t)0x3bec, (q15_t)0x5687, (q15_t)0x3be7, + (q15_t)0x5693, (q15_t)0x3be3, (q15_t)0x569f, (q15_t)0x3bde, (q15_t)0x56ab, + (q15_t)0x3bda, (q15_t)0x56b6, (q15_t)0x3bd6, (q15_t)0x56c2, (q15_t)0x3bd1, + (q15_t)0x56ce, (q15_t)0x3bcd, (q15_t)0x56da, (q15_t)0x3bc8, (q15_t)0x56e5, + (q15_t)0x3bc4, (q15_t)0x56f1, (q15_t)0x3bbf, (q15_t)0x56fd, (q15_t)0x3bbb, + (q15_t)0x5709, (q15_t)0x3bb6, (q15_t)0x5714, (q15_t)0x3bb2, (q15_t)0x5720, + (q15_t)0x3bad, (q15_t)0x572c, (q15_t)0x3ba9, (q15_t)0x5737, (q15_t)0x3ba4, + (q15_t)0x5743, (q15_t)0x3b9f, (q15_t)0x574f, (q15_t)0x3b9b, (q15_t)0x575b, + (q15_t)0x3b96, (q15_t)0x5766, (q15_t)0x3b92, (q15_t)0x5772, (q15_t)0x3b8d, + (q15_t)0x577e, (q15_t)0x3b88, (q15_t)0x5789, (q15_t)0x3b84, (q15_t)0x5795, + (q15_t)0x3b7f, (q15_t)0x57a1, (q15_t)0x3b7b, (q15_t)0x57ac, (q15_t)0x3b76, + (q15_t)0x57b8, (q15_t)0x3b71, (q15_t)0x57c4, (q15_t)0x3b6d, (q15_t)0x57cf, + (q15_t)0x3b68, (q15_t)0x57db, (q15_t)0x3b63, (q15_t)0x57e7, (q15_t)0x3b5f, + (q15_t)0x57f2, (q15_t)0x3b5a, (q15_t)0x57fe, (q15_t)0x3b55, (q15_t)0x580a, + (q15_t)0x3b50, (q15_t)0x5815, (q15_t)0x3b4c, (q15_t)0x5821, (q15_t)0x3b47, + (q15_t)0x582d, (q15_t)0x3b42, (q15_t)0x5838, (q15_t)0x3b3e, (q15_t)0x5844, + (q15_t)0x3b39, (q15_t)0x584f, (q15_t)0x3b34, (q15_t)0x585b, (q15_t)0x3b2f, + (q15_t)0x5867, (q15_t)0x3b2a, (q15_t)0x5872, (q15_t)0x3b26, (q15_t)0x587e, + (q15_t)0x3b21, (q15_t)0x5889, (q15_t)0x3b1c, (q15_t)0x5895, (q15_t)0x3b17, + (q15_t)0x58a1, (q15_t)0x3b12, (q15_t)0x58ac, (q15_t)0x3b0e, (q15_t)0x58b8, + (q15_t)0x3b09, (q15_t)0x58c3, (q15_t)0x3b04, (q15_t)0x58cf, (q15_t)0x3aff, + (q15_t)0x58db, (q15_t)0x3afa, (q15_t)0x58e6, (q15_t)0x3af5, (q15_t)0x58f2, + (q15_t)0x3af0, (q15_t)0x58fd, (q15_t)0x3aeb, (q15_t)0x5909, (q15_t)0x3ae6, + (q15_t)0x5914, (q15_t)0x3ae2, (q15_t)0x5920, (q15_t)0x3add, (q15_t)0x592c, + (q15_t)0x3ad8, (q15_t)0x5937, (q15_t)0x3ad3, (q15_t)0x5943, (q15_t)0x3ace, + (q15_t)0x594e, (q15_t)0x3ac9, (q15_t)0x595a, (q15_t)0x3ac4, (q15_t)0x5965, + (q15_t)0x3abf, (q15_t)0x5971, (q15_t)0x3aba, (q15_t)0x597c, (q15_t)0x3ab5, + (q15_t)0x5988, (q15_t)0x3ab0, (q15_t)0x5993, (q15_t)0x3aab, (q15_t)0x599f, + (q15_t)0x3aa6, (q15_t)0x59aa, (q15_t)0x3aa1, (q15_t)0x59b6, (q15_t)0x3a9c, + (q15_t)0x59c1, (q15_t)0x3a97, (q15_t)0x59cd, (q15_t)0x3a92, (q15_t)0x59d8, + (q15_t)0x3a8d, (q15_t)0x59e4, (q15_t)0x3a88, (q15_t)0x59ef, (q15_t)0x3a82, + (q15_t)0x59fb, (q15_t)0x3a7d, (q15_t)0x5a06, (q15_t)0x3a78, (q15_t)0x5a12, + (q15_t)0x3a73, (q15_t)0x5a1d, (q15_t)0x3a6e, (q15_t)0x5a29, (q15_t)0x3a69, + (q15_t)0x5a34, (q15_t)0x3a64, (q15_t)0x5a40, (q15_t)0x3a5f, (q15_t)0x5a4b, + (q15_t)0x3a59, (q15_t)0x5a57, (q15_t)0x3a54, (q15_t)0x5a62, (q15_t)0x3a4f, + (q15_t)0x5a6e, (q15_t)0x3a4a, (q15_t)0x5a79, (q15_t)0x3a45, (q15_t)0x5a84, + (q15_t)0x3a3f, (q15_t)0x5a90, (q15_t)0x3a3a, (q15_t)0x5a9b, (q15_t)0x3a35, + (q15_t)0x5aa7, (q15_t)0x3a30, (q15_t)0x5ab2, (q15_t)0x3a2b, (q15_t)0x5abe, + (q15_t)0x3a25, (q15_t)0x5ac9, (q15_t)0x3a20, (q15_t)0x5ad4, (q15_t)0x3a1b, + (q15_t)0x5ae0, (q15_t)0x3a16, (q15_t)0x5aeb, (q15_t)0x3a10, (q15_t)0x5af7, + (q15_t)0x3a0b, (q15_t)0x5b02, (q15_t)0x3a06, (q15_t)0x5b0d, (q15_t)0x3a00, + (q15_t)0x5b19, (q15_t)0x39fb, (q15_t)0x5b24, (q15_t)0x39f6, (q15_t)0x5b30, + (q15_t)0x39f0, (q15_t)0x5b3b, (q15_t)0x39eb, (q15_t)0x5b46, (q15_t)0x39e6, + (q15_t)0x5b52, (q15_t)0x39e0, (q15_t)0x5b5d, (q15_t)0x39db, (q15_t)0x5b68, + (q15_t)0x39d6, (q15_t)0x5b74, (q15_t)0x39d0, (q15_t)0x5b7f, (q15_t)0x39cb, + (q15_t)0x5b8a, (q15_t)0x39c5, (q15_t)0x5b96, (q15_t)0x39c0, (q15_t)0x5ba1, + (q15_t)0x39bb, (q15_t)0x5bac, (q15_t)0x39b5, (q15_t)0x5bb8, (q15_t)0x39b0, + (q15_t)0x5bc3, (q15_t)0x39aa, (q15_t)0x5bce, (q15_t)0x39a5, (q15_t)0x5bda, + (q15_t)0x399f, (q15_t)0x5be5, (q15_t)0x399a, (q15_t)0x5bf0, (q15_t)0x3994, + (q15_t)0x5bfc, (q15_t)0x398f, (q15_t)0x5c07, (q15_t)0x3989, (q15_t)0x5c12, + (q15_t)0x3984, (q15_t)0x5c1e, (q15_t)0x397e, (q15_t)0x5c29, (q15_t)0x3979, + (q15_t)0x5c34, (q15_t)0x3973, (q15_t)0x5c3f, (q15_t)0x396e, (q15_t)0x5c4b, + (q15_t)0x3968, (q15_t)0x5c56, (q15_t)0x3963, (q15_t)0x5c61, (q15_t)0x395d, + (q15_t)0x5c6c, (q15_t)0x3958, (q15_t)0x5c78, (q15_t)0x3952, (q15_t)0x5c83, + (q15_t)0x394c, (q15_t)0x5c8e, (q15_t)0x3947, (q15_t)0x5c99, (q15_t)0x3941, + (q15_t)0x5ca5, (q15_t)0x393b, (q15_t)0x5cb0, (q15_t)0x3936, (q15_t)0x5cbb, + (q15_t)0x3930, (q15_t)0x5cc6, (q15_t)0x392b, (q15_t)0x5cd2, (q15_t)0x3925, + (q15_t)0x5cdd, (q15_t)0x391f, (q15_t)0x5ce8, (q15_t)0x391a, (q15_t)0x5cf3, + (q15_t)0x3914, (q15_t)0x5cff, (q15_t)0x390e, (q15_t)0x5d0a, (q15_t)0x3909, + (q15_t)0x5d15, (q15_t)0x3903, (q15_t)0x5d20, (q15_t)0x38fd, (q15_t)0x5d2b, + (q15_t)0x38f7, (q15_t)0x5d36, (q15_t)0x38f2, (q15_t)0x5d42, (q15_t)0x38ec, + (q15_t)0x5d4d, (q15_t)0x38e6, (q15_t)0x5d58, (q15_t)0x38e0, (q15_t)0x5d63, + (q15_t)0x38db, (q15_t)0x5d6e, (q15_t)0x38d5, (q15_t)0x5d79, (q15_t)0x38cf, + (q15_t)0x5d85, (q15_t)0x38c9, (q15_t)0x5d90, (q15_t)0x38c3, (q15_t)0x5d9b, + (q15_t)0x38be, (q15_t)0x5da6, (q15_t)0x38b8, (q15_t)0x5db1, (q15_t)0x38b2, + (q15_t)0x5dbc, (q15_t)0x38ac, (q15_t)0x5dc7, (q15_t)0x38a6, (q15_t)0x5dd3, + (q15_t)0x38a1, (q15_t)0x5dde, (q15_t)0x389b, (q15_t)0x5de9, (q15_t)0x3895, + (q15_t)0x5df4, (q15_t)0x388f, (q15_t)0x5dff, (q15_t)0x3889, (q15_t)0x5e0a, + (q15_t)0x3883, (q15_t)0x5e15, (q15_t)0x387d, (q15_t)0x5e20, (q15_t)0x3877, + (q15_t)0x5e2b, (q15_t)0x3871, (q15_t)0x5e36, (q15_t)0x386b, (q15_t)0x5e42, + (q15_t)0x3866, (q15_t)0x5e4d, (q15_t)0x3860, (q15_t)0x5e58, (q15_t)0x385a, + (q15_t)0x5e63, (q15_t)0x3854, (q15_t)0x5e6e, (q15_t)0x384e, (q15_t)0x5e79, + (q15_t)0x3848, (q15_t)0x5e84, (q15_t)0x3842, (q15_t)0x5e8f, (q15_t)0x383c, + (q15_t)0x5e9a, (q15_t)0x3836, (q15_t)0x5ea5, (q15_t)0x3830, (q15_t)0x5eb0, + (q15_t)0x382a, (q15_t)0x5ebb, (q15_t)0x3824, (q15_t)0x5ec6, (q15_t)0x381e, + (q15_t)0x5ed1, (q15_t)0x3818, (q15_t)0x5edc, (q15_t)0x3812, (q15_t)0x5ee7, + (q15_t)0x380b, (q15_t)0x5ef2, (q15_t)0x3805, (q15_t)0x5efd, (q15_t)0x37ff, + (q15_t)0x5f08, (q15_t)0x37f9, (q15_t)0x5f13, (q15_t)0x37f3, (q15_t)0x5f1e, + (q15_t)0x37ed, (q15_t)0x5f29, (q15_t)0x37e7, (q15_t)0x5f34, (q15_t)0x37e1, + (q15_t)0x5f3f, (q15_t)0x37db, (q15_t)0x5f4a, (q15_t)0x37d5, (q15_t)0x5f55, + (q15_t)0x37ce, (q15_t)0x5f60, (q15_t)0x37c8, (q15_t)0x5f6b, (q15_t)0x37c2, + (q15_t)0x5f76, (q15_t)0x37bc, (q15_t)0x5f81, (q15_t)0x37b6, (q15_t)0x5f8c, + (q15_t)0x37b0, (q15_t)0x5f97, (q15_t)0x37a9, (q15_t)0x5fa2, (q15_t)0x37a3, + (q15_t)0x5fac, (q15_t)0x379d, (q15_t)0x5fb7, (q15_t)0x3797, (q15_t)0x5fc2, + (q15_t)0x3790, (q15_t)0x5fcd, (q15_t)0x378a, (q15_t)0x5fd8, (q15_t)0x3784, + (q15_t)0x5fe3, (q15_t)0x377e, (q15_t)0x5fee, (q15_t)0x3777, (q15_t)0x5ff9, + (q15_t)0x3771, (q15_t)0x6004, (q15_t)0x376b, (q15_t)0x600f, (q15_t)0x3765, + (q15_t)0x6019, (q15_t)0x375e, (q15_t)0x6024, (q15_t)0x3758, (q15_t)0x602f, + (q15_t)0x3752, (q15_t)0x603a, (q15_t)0x374b, (q15_t)0x6045, (q15_t)0x3745, + (q15_t)0x6050, (q15_t)0x373f, (q15_t)0x605b, (q15_t)0x3738, (q15_t)0x6065, + (q15_t)0x3732, (q15_t)0x6070, (q15_t)0x372c, (q15_t)0x607b, (q15_t)0x3725, + (q15_t)0x6086, (q15_t)0x371f, (q15_t)0x6091, (q15_t)0x3718, (q15_t)0x609b, + (q15_t)0x3712, (q15_t)0x60a6, (q15_t)0x370c, (q15_t)0x60b1, (q15_t)0x3705, + (q15_t)0x60bc, (q15_t)0x36ff, (q15_t)0x60c7, (q15_t)0x36f8, (q15_t)0x60d1, + (q15_t)0x36f2, (q15_t)0x60dc, (q15_t)0x36eb, (q15_t)0x60e7, (q15_t)0x36e5, + (q15_t)0x60f2, (q15_t)0x36df, (q15_t)0x60fd, (q15_t)0x36d8, (q15_t)0x6107, + (q15_t)0x36d2, (q15_t)0x6112, (q15_t)0x36cb, (q15_t)0x611d, (q15_t)0x36c5, + (q15_t)0x6128, (q15_t)0x36be, (q15_t)0x6132, (q15_t)0x36b8, (q15_t)0x613d, + (q15_t)0x36b1, (q15_t)0x6148, (q15_t)0x36ab, (q15_t)0x6153, (q15_t)0x36a4, + (q15_t)0x615d, (q15_t)0x369d, (q15_t)0x6168, (q15_t)0x3697, (q15_t)0x6173, + (q15_t)0x3690, (q15_t)0x617d, (q15_t)0x368a, (q15_t)0x6188, (q15_t)0x3683, + (q15_t)0x6193, (q15_t)0x367d, (q15_t)0x619e, (q15_t)0x3676, (q15_t)0x61a8, + (q15_t)0x366f, (q15_t)0x61b3, (q15_t)0x3669, (q15_t)0x61be, (q15_t)0x3662, + (q15_t)0x61c8, (q15_t)0x365c, (q15_t)0x61d3, (q15_t)0x3655, (q15_t)0x61de, + (q15_t)0x364e, (q15_t)0x61e8, (q15_t)0x3648, (q15_t)0x61f3, (q15_t)0x3641, + (q15_t)0x61fe, (q15_t)0x363a, (q15_t)0x6208, (q15_t)0x3634, (q15_t)0x6213, + (q15_t)0x362d, (q15_t)0x621e, (q15_t)0x3626, (q15_t)0x6228, (q15_t)0x3620, + (q15_t)0x6233, (q15_t)0x3619, (q15_t)0x623d, (q15_t)0x3612, (q15_t)0x6248, + (q15_t)0x360b, (q15_t)0x6253, (q15_t)0x3605, (q15_t)0x625d, (q15_t)0x35fe, + (q15_t)0x6268, (q15_t)0x35f7, (q15_t)0x6272, (q15_t)0x35f0, (q15_t)0x627d, + (q15_t)0x35ea, (q15_t)0x6288, (q15_t)0x35e3, (q15_t)0x6292, (q15_t)0x35dc, + (q15_t)0x629d, (q15_t)0x35d5, (q15_t)0x62a7, (q15_t)0x35ce, (q15_t)0x62b2, + (q15_t)0x35c8, (q15_t)0x62bc, (q15_t)0x35c1, (q15_t)0x62c7, (q15_t)0x35ba, + (q15_t)0x62d2, (q15_t)0x35b3, (q15_t)0x62dc, (q15_t)0x35ac, (q15_t)0x62e7, + (q15_t)0x35a5, (q15_t)0x62f1, (q15_t)0x359f, (q15_t)0x62fc, (q15_t)0x3598, + (q15_t)0x6306, (q15_t)0x3591, (q15_t)0x6311, (q15_t)0x358a, (q15_t)0x631b, + (q15_t)0x3583, (q15_t)0x6326, (q15_t)0x357c, (q15_t)0x6330, (q15_t)0x3575, + (q15_t)0x633b, (q15_t)0x356e, (q15_t)0x6345, (q15_t)0x3567, (q15_t)0x6350, + (q15_t)0x3561, (q15_t)0x635a, (q15_t)0x355a, (q15_t)0x6365, (q15_t)0x3553, + (q15_t)0x636f, (q15_t)0x354c, (q15_t)0x637a, (q15_t)0x3545, (q15_t)0x6384, + (q15_t)0x353e, (q15_t)0x638e, (q15_t)0x3537, (q15_t)0x6399, (q15_t)0x3530, + (q15_t)0x63a3, (q15_t)0x3529, (q15_t)0x63ae, (q15_t)0x3522, (q15_t)0x63b8, + (q15_t)0x351b, (q15_t)0x63c3, (q15_t)0x3514, (q15_t)0x63cd, (q15_t)0x350d, + (q15_t)0x63d7, (q15_t)0x3506, (q15_t)0x63e2, (q15_t)0x34ff, (q15_t)0x63ec, + (q15_t)0x34f8, (q15_t)0x63f7, (q15_t)0x34f1, (q15_t)0x6401, (q15_t)0x34ea, + (q15_t)0x640b, (q15_t)0x34e2, (q15_t)0x6416, (q15_t)0x34db, (q15_t)0x6420, + (q15_t)0x34d4, (q15_t)0x642b, (q15_t)0x34cd, (q15_t)0x6435, (q15_t)0x34c6, + (q15_t)0x643f, (q15_t)0x34bf, (q15_t)0x644a, (q15_t)0x34b8, (q15_t)0x6454, + (q15_t)0x34b1, (q15_t)0x645e, (q15_t)0x34aa, (q15_t)0x6469, (q15_t)0x34a2, + (q15_t)0x6473, (q15_t)0x349b, (q15_t)0x647d, (q15_t)0x3494, (q15_t)0x6488, + (q15_t)0x348d, (q15_t)0x6492, (q15_t)0x3486, (q15_t)0x649c, (q15_t)0x347f, + (q15_t)0x64a7, (q15_t)0x3477, (q15_t)0x64b1, (q15_t)0x3470, (q15_t)0x64bb, + (q15_t)0x3469, (q15_t)0x64c5, (q15_t)0x3462, (q15_t)0x64d0, (q15_t)0x345b, + (q15_t)0x64da, (q15_t)0x3453, (q15_t)0x64e4, (q15_t)0x344c, (q15_t)0x64ef, + (q15_t)0x3445, (q15_t)0x64f9, (q15_t)0x343e, (q15_t)0x6503, (q15_t)0x3436, + (q15_t)0x650d, (q15_t)0x342f, (q15_t)0x6518, (q15_t)0x3428, (q15_t)0x6522, + (q15_t)0x3420, (q15_t)0x652c, (q15_t)0x3419, (q15_t)0x6536, (q15_t)0x3412, + (q15_t)0x6541, (q15_t)0x340b, (q15_t)0x654b, (q15_t)0x3403, (q15_t)0x6555, + (q15_t)0x33fc, (q15_t)0x655f, (q15_t)0x33f5, (q15_t)0x6569, (q15_t)0x33ed, + (q15_t)0x6574, (q15_t)0x33e6, (q15_t)0x657e, (q15_t)0x33df, (q15_t)0x6588, + (q15_t)0x33d7, (q15_t)0x6592, (q15_t)0x33d0, (q15_t)0x659c, (q15_t)0x33c8, + (q15_t)0x65a6, (q15_t)0x33c1, (q15_t)0x65b1, (q15_t)0x33ba, (q15_t)0x65bb, + (q15_t)0x33b2, (q15_t)0x65c5, (q15_t)0x33ab, (q15_t)0x65cf, (q15_t)0x33a3, + (q15_t)0x65d9, (q15_t)0x339c, (q15_t)0x65e3, (q15_t)0x3395, (q15_t)0x65ed, + (q15_t)0x338d, (q15_t)0x65f8, (q15_t)0x3386, (q15_t)0x6602, (q15_t)0x337e, + (q15_t)0x660c, (q15_t)0x3377, (q15_t)0x6616, (q15_t)0x336f, (q15_t)0x6620, + (q15_t)0x3368, (q15_t)0x662a, (q15_t)0x3360, (q15_t)0x6634, (q15_t)0x3359, + (q15_t)0x663e, (q15_t)0x3351, (q15_t)0x6648, (q15_t)0x334a, (q15_t)0x6652, + (q15_t)0x3342, (q15_t)0x665c, (q15_t)0x333b, (q15_t)0x6666, (q15_t)0x3333, + (q15_t)0x6671, (q15_t)0x332c, (q15_t)0x667b, (q15_t)0x3324, (q15_t)0x6685, + (q15_t)0x331d, (q15_t)0x668f, (q15_t)0x3315, (q15_t)0x6699, (q15_t)0x330d, + (q15_t)0x66a3, (q15_t)0x3306, (q15_t)0x66ad, (q15_t)0x32fe, (q15_t)0x66b7, + (q15_t)0x32f7, (q15_t)0x66c1, (q15_t)0x32ef, (q15_t)0x66cb, (q15_t)0x32e7, + (q15_t)0x66d5, (q15_t)0x32e0, (q15_t)0x66df, (q15_t)0x32d8, (q15_t)0x66e9, + (q15_t)0x32d0, (q15_t)0x66f3, (q15_t)0x32c9, (q15_t)0x66fd, (q15_t)0x32c1, + (q15_t)0x6707, (q15_t)0x32ba, (q15_t)0x6711, (q15_t)0x32b2, (q15_t)0x671a, + (q15_t)0x32aa, (q15_t)0x6724, (q15_t)0x32a3, (q15_t)0x672e, (q15_t)0x329b, + (q15_t)0x6738, (q15_t)0x3293, (q15_t)0x6742, (q15_t)0x328b, (q15_t)0x674c, + (q15_t)0x3284, (q15_t)0x6756, (q15_t)0x327c, (q15_t)0x6760, (q15_t)0x3274, + (q15_t)0x676a, (q15_t)0x326d, (q15_t)0x6774, (q15_t)0x3265, (q15_t)0x677e, + (q15_t)0x325d, (q15_t)0x6788, (q15_t)0x3255, (q15_t)0x6791, (q15_t)0x324e, + (q15_t)0x679b, (q15_t)0x3246, (q15_t)0x67a5, (q15_t)0x323e, (q15_t)0x67af, + (q15_t)0x3236, (q15_t)0x67b9, (q15_t)0x322e, (q15_t)0x67c3, (q15_t)0x3227, + (q15_t)0x67cd, (q15_t)0x321f, (q15_t)0x67d6, (q15_t)0x3217, (q15_t)0x67e0, + (q15_t)0x320f, (q15_t)0x67ea, (q15_t)0x3207, (q15_t)0x67f4, (q15_t)0x31ff, + (q15_t)0x67fe, (q15_t)0x31f8, (q15_t)0x6808, (q15_t)0x31f0, (q15_t)0x6811, + (q15_t)0x31e8, (q15_t)0x681b, (q15_t)0x31e0, (q15_t)0x6825, (q15_t)0x31d8, + (q15_t)0x682f, (q15_t)0x31d0, (q15_t)0x6838, (q15_t)0x31c8, (q15_t)0x6842, + (q15_t)0x31c0, (q15_t)0x684c, (q15_t)0x31b9, (q15_t)0x6856, (q15_t)0x31b1, + (q15_t)0x6860, (q15_t)0x31a9, (q15_t)0x6869, (q15_t)0x31a1, (q15_t)0x6873, + (q15_t)0x3199, (q15_t)0x687d, (q15_t)0x3191, (q15_t)0x6886, (q15_t)0x3189, + (q15_t)0x6890, (q15_t)0x3181, (q15_t)0x689a, (q15_t)0x3179, (q15_t)0x68a4, + (q15_t)0x3171, (q15_t)0x68ad, (q15_t)0x3169, (q15_t)0x68b7, (q15_t)0x3161, + (q15_t)0x68c1, (q15_t)0x3159, (q15_t)0x68ca, (q15_t)0x3151, (q15_t)0x68d4, + (q15_t)0x3149, (q15_t)0x68de, (q15_t)0x3141, (q15_t)0x68e7, (q15_t)0x3139, + (q15_t)0x68f1, (q15_t)0x3131, (q15_t)0x68fb, (q15_t)0x3129, (q15_t)0x6904, + (q15_t)0x3121, (q15_t)0x690e, (q15_t)0x3119, (q15_t)0x6918, (q15_t)0x3111, + (q15_t)0x6921, (q15_t)0x3109, (q15_t)0x692b, (q15_t)0x3101, (q15_t)0x6935, + (q15_t)0x30f9, (q15_t)0x693e, (q15_t)0x30f0, (q15_t)0x6948, (q15_t)0x30e8, + (q15_t)0x6951, (q15_t)0x30e0, (q15_t)0x695b, (q15_t)0x30d8, (q15_t)0x6965, + (q15_t)0x30d0, (q15_t)0x696e, (q15_t)0x30c8, (q15_t)0x6978, (q15_t)0x30c0, + (q15_t)0x6981, (q15_t)0x30b8, (q15_t)0x698b, (q15_t)0x30af, (q15_t)0x6994, + (q15_t)0x30a7, (q15_t)0x699e, (q15_t)0x309f, (q15_t)0x69a7, (q15_t)0x3097, + (q15_t)0x69b1, (q15_t)0x308f, (q15_t)0x69bb, (q15_t)0x3087, (q15_t)0x69c4, + (q15_t)0x307e, (q15_t)0x69ce, (q15_t)0x3076, (q15_t)0x69d7, (q15_t)0x306e, + (q15_t)0x69e1, (q15_t)0x3066, (q15_t)0x69ea, (q15_t)0x305d, (q15_t)0x69f4, + (q15_t)0x3055, (q15_t)0x69fd, (q15_t)0x304d, (q15_t)0x6a07, (q15_t)0x3045, + (q15_t)0x6a10, (q15_t)0x303c, (q15_t)0x6a1a, (q15_t)0x3034, (q15_t)0x6a23, + (q15_t)0x302c, (q15_t)0x6a2c, (q15_t)0x3024, (q15_t)0x6a36, (q15_t)0x301b, + (q15_t)0x6a3f, (q15_t)0x3013, (q15_t)0x6a49, (q15_t)0x300b, (q15_t)0x6a52, + (q15_t)0x3002, (q15_t)0x6a5c, (q15_t)0x2ffa, (q15_t)0x6a65, (q15_t)0x2ff2, + (q15_t)0x6a6e, (q15_t)0x2fea, (q15_t)0x6a78, (q15_t)0x2fe1, (q15_t)0x6a81, + (q15_t)0x2fd9, (q15_t)0x6a8b, (q15_t)0x2fd0, (q15_t)0x6a94, (q15_t)0x2fc8, + (q15_t)0x6a9d, (q15_t)0x2fc0, (q15_t)0x6aa7, (q15_t)0x2fb7, (q15_t)0x6ab0, + (q15_t)0x2faf, (q15_t)0x6ab9, (q15_t)0x2fa7, (q15_t)0x6ac3, (q15_t)0x2f9e, + (q15_t)0x6acc, (q15_t)0x2f96, (q15_t)0x6ad6, (q15_t)0x2f8d, (q15_t)0x6adf, + (q15_t)0x2f85, (q15_t)0x6ae8, (q15_t)0x2f7d, (q15_t)0x6af2, (q15_t)0x2f74, + (q15_t)0x6afb, (q15_t)0x2f6c, (q15_t)0x6b04, (q15_t)0x2f63, (q15_t)0x6b0d, + (q15_t)0x2f5b, (q15_t)0x6b17, (q15_t)0x2f52, (q15_t)0x6b20, (q15_t)0x2f4a, + (q15_t)0x6b29, (q15_t)0x2f41, (q15_t)0x6b33, (q15_t)0x2f39, (q15_t)0x6b3c, + (q15_t)0x2f30, (q15_t)0x6b45, (q15_t)0x2f28, (q15_t)0x6b4e, (q15_t)0x2f20, + (q15_t)0x6b58, (q15_t)0x2f17, (q15_t)0x6b61, (q15_t)0x2f0e, (q15_t)0x6b6a, + (q15_t)0x2f06, (q15_t)0x6b73, (q15_t)0x2efd, (q15_t)0x6b7d, (q15_t)0x2ef5, + (q15_t)0x6b86, (q15_t)0x2eec, (q15_t)0x6b8f, (q15_t)0x2ee4, (q15_t)0x6b98, + (q15_t)0x2edb, (q15_t)0x6ba1, (q15_t)0x2ed3, (q15_t)0x6bab, (q15_t)0x2eca, + (q15_t)0x6bb4, (q15_t)0x2ec2, (q15_t)0x6bbd, (q15_t)0x2eb9, (q15_t)0x6bc6, + (q15_t)0x2eb0, (q15_t)0x6bcf, (q15_t)0x2ea8, (q15_t)0x6bd8, (q15_t)0x2e9f, + (q15_t)0x6be2, (q15_t)0x2e97, (q15_t)0x6beb, (q15_t)0x2e8e, (q15_t)0x6bf4, + (q15_t)0x2e85, (q15_t)0x6bfd, (q15_t)0x2e7d, (q15_t)0x6c06, (q15_t)0x2e74, + (q15_t)0x6c0f, (q15_t)0x2e6b, (q15_t)0x6c18, (q15_t)0x2e63, (q15_t)0x6c21, + (q15_t)0x2e5a, (q15_t)0x6c2b, (q15_t)0x2e51, (q15_t)0x6c34, (q15_t)0x2e49, + (q15_t)0x6c3d, (q15_t)0x2e40, (q15_t)0x6c46, (q15_t)0x2e37, (q15_t)0x6c4f, + (q15_t)0x2e2f, (q15_t)0x6c58, (q15_t)0x2e26, (q15_t)0x6c61, (q15_t)0x2e1d, + (q15_t)0x6c6a, (q15_t)0x2e15, (q15_t)0x6c73, (q15_t)0x2e0c, (q15_t)0x6c7c, + (q15_t)0x2e03, (q15_t)0x6c85, (q15_t)0x2dfa, (q15_t)0x6c8e, (q15_t)0x2df2, + (q15_t)0x6c97, (q15_t)0x2de9, (q15_t)0x6ca0, (q15_t)0x2de0, (q15_t)0x6ca9, + (q15_t)0x2dd7, (q15_t)0x6cb2, (q15_t)0x2dcf, (q15_t)0x6cbb, (q15_t)0x2dc6, + (q15_t)0x6cc4, (q15_t)0x2dbd, (q15_t)0x6ccd, (q15_t)0x2db4, (q15_t)0x6cd6, + (q15_t)0x2dab, (q15_t)0x6cdf, (q15_t)0x2da3, (q15_t)0x6ce8, (q15_t)0x2d9a, + (q15_t)0x6cf1, (q15_t)0x2d91, (q15_t)0x6cfa, (q15_t)0x2d88, (q15_t)0x6d03, + (q15_t)0x2d7f, (q15_t)0x6d0c, (q15_t)0x2d76, (q15_t)0x6d15, (q15_t)0x2d6e, + (q15_t)0x6d1e, (q15_t)0x2d65, (q15_t)0x6d27, (q15_t)0x2d5c, (q15_t)0x6d2f, + (q15_t)0x2d53, (q15_t)0x6d38, (q15_t)0x2d4a, (q15_t)0x6d41, (q15_t)0x2d41, + (q15_t)0x6d4a, (q15_t)0x2d38, (q15_t)0x6d53, (q15_t)0x2d2f, (q15_t)0x6d5c, + (q15_t)0x2d27, (q15_t)0x6d65, (q15_t)0x2d1e, (q15_t)0x6d6e, (q15_t)0x2d15, + (q15_t)0x6d76, (q15_t)0x2d0c, (q15_t)0x6d7f, (q15_t)0x2d03, (q15_t)0x6d88, + (q15_t)0x2cfa, (q15_t)0x6d91, (q15_t)0x2cf1, (q15_t)0x6d9a, (q15_t)0x2ce8, + (q15_t)0x6da3, (q15_t)0x2cdf, (q15_t)0x6dab, (q15_t)0x2cd6, (q15_t)0x6db4, + (q15_t)0x2ccd, (q15_t)0x6dbd, (q15_t)0x2cc4, (q15_t)0x6dc6, (q15_t)0x2cbb, + (q15_t)0x6dcf, (q15_t)0x2cb2, (q15_t)0x6dd7, (q15_t)0x2ca9, (q15_t)0x6de0, + (q15_t)0x2ca0, (q15_t)0x6de9, (q15_t)0x2c97, (q15_t)0x6df2, (q15_t)0x2c8e, + (q15_t)0x6dfa, (q15_t)0x2c85, (q15_t)0x6e03, (q15_t)0x2c7c, (q15_t)0x6e0c, + (q15_t)0x2c73, (q15_t)0x6e15, (q15_t)0x2c6a, (q15_t)0x6e1d, (q15_t)0x2c61, + (q15_t)0x6e26, (q15_t)0x2c58, (q15_t)0x6e2f, (q15_t)0x2c4f, (q15_t)0x6e37, + (q15_t)0x2c46, (q15_t)0x6e40, (q15_t)0x2c3d, (q15_t)0x6e49, (q15_t)0x2c34, + (q15_t)0x6e51, (q15_t)0x2c2b, (q15_t)0x6e5a, (q15_t)0x2c21, (q15_t)0x6e63, + (q15_t)0x2c18, (q15_t)0x6e6b, (q15_t)0x2c0f, (q15_t)0x6e74, (q15_t)0x2c06, + (q15_t)0x6e7d, (q15_t)0x2bfd, (q15_t)0x6e85, (q15_t)0x2bf4, (q15_t)0x6e8e, + (q15_t)0x2beb, (q15_t)0x6e97, (q15_t)0x2be2, (q15_t)0x6e9f, (q15_t)0x2bd8, + (q15_t)0x6ea8, (q15_t)0x2bcf, (q15_t)0x6eb0, (q15_t)0x2bc6, (q15_t)0x6eb9, + (q15_t)0x2bbd, (q15_t)0x6ec2, (q15_t)0x2bb4, (q15_t)0x6eca, (q15_t)0x2bab, + (q15_t)0x6ed3, (q15_t)0x2ba1, (q15_t)0x6edb, (q15_t)0x2b98, (q15_t)0x6ee4, + (q15_t)0x2b8f, (q15_t)0x6eec, (q15_t)0x2b86, (q15_t)0x6ef5, (q15_t)0x2b7d, + (q15_t)0x6efd, (q15_t)0x2b73, (q15_t)0x6f06, (q15_t)0x2b6a, (q15_t)0x6f0e, + (q15_t)0x2b61, (q15_t)0x6f17, (q15_t)0x2b58, (q15_t)0x6f20, (q15_t)0x2b4e, + (q15_t)0x6f28, (q15_t)0x2b45, (q15_t)0x6f30, (q15_t)0x2b3c, (q15_t)0x6f39, + (q15_t)0x2b33, (q15_t)0x6f41, (q15_t)0x2b29, (q15_t)0x6f4a, (q15_t)0x2b20, + (q15_t)0x6f52, (q15_t)0x2b17, (q15_t)0x6f5b, (q15_t)0x2b0d, (q15_t)0x6f63, + (q15_t)0x2b04, (q15_t)0x6f6c, (q15_t)0x2afb, (q15_t)0x6f74, (q15_t)0x2af2, + (q15_t)0x6f7d, (q15_t)0x2ae8, (q15_t)0x6f85, (q15_t)0x2adf, (q15_t)0x6f8d, + (q15_t)0x2ad6, (q15_t)0x6f96, (q15_t)0x2acc, (q15_t)0x6f9e, (q15_t)0x2ac3, + (q15_t)0x6fa7, (q15_t)0x2ab9, (q15_t)0x6faf, (q15_t)0x2ab0, (q15_t)0x6fb7, + (q15_t)0x2aa7, (q15_t)0x6fc0, (q15_t)0x2a9d, (q15_t)0x6fc8, (q15_t)0x2a94, + (q15_t)0x6fd0, (q15_t)0x2a8b, (q15_t)0x6fd9, (q15_t)0x2a81, (q15_t)0x6fe1, + (q15_t)0x2a78, (q15_t)0x6fea, (q15_t)0x2a6e, (q15_t)0x6ff2, (q15_t)0x2a65, + (q15_t)0x6ffa, (q15_t)0x2a5c, (q15_t)0x7002, (q15_t)0x2a52, (q15_t)0x700b, + (q15_t)0x2a49, (q15_t)0x7013, (q15_t)0x2a3f, (q15_t)0x701b, (q15_t)0x2a36, + (q15_t)0x7024, (q15_t)0x2a2c, (q15_t)0x702c, (q15_t)0x2a23, (q15_t)0x7034, + (q15_t)0x2a1a, (q15_t)0x703c, (q15_t)0x2a10, (q15_t)0x7045, (q15_t)0x2a07, + (q15_t)0x704d, (q15_t)0x29fd, (q15_t)0x7055, (q15_t)0x29f4, (q15_t)0x705d, + (q15_t)0x29ea, (q15_t)0x7066, (q15_t)0x29e1, (q15_t)0x706e, (q15_t)0x29d7, + (q15_t)0x7076, (q15_t)0x29ce, (q15_t)0x707e, (q15_t)0x29c4, (q15_t)0x7087, + (q15_t)0x29bb, (q15_t)0x708f, (q15_t)0x29b1, (q15_t)0x7097, (q15_t)0x29a7, + (q15_t)0x709f, (q15_t)0x299e, (q15_t)0x70a7, (q15_t)0x2994, (q15_t)0x70af, + (q15_t)0x298b, (q15_t)0x70b8, (q15_t)0x2981, (q15_t)0x70c0, (q15_t)0x2978, + (q15_t)0x70c8, (q15_t)0x296e, (q15_t)0x70d0, (q15_t)0x2965, (q15_t)0x70d8, + (q15_t)0x295b, (q15_t)0x70e0, (q15_t)0x2951, (q15_t)0x70e8, (q15_t)0x2948, + (q15_t)0x70f0, (q15_t)0x293e, (q15_t)0x70f9, (q15_t)0x2935, (q15_t)0x7101, + (q15_t)0x292b, (q15_t)0x7109, (q15_t)0x2921, (q15_t)0x7111, (q15_t)0x2918, + (q15_t)0x7119, (q15_t)0x290e, (q15_t)0x7121, (q15_t)0x2904, (q15_t)0x7129, + (q15_t)0x28fb, (q15_t)0x7131, (q15_t)0x28f1, (q15_t)0x7139, (q15_t)0x28e7, + (q15_t)0x7141, (q15_t)0x28de, (q15_t)0x7149, (q15_t)0x28d4, (q15_t)0x7151, + (q15_t)0x28ca, (q15_t)0x7159, (q15_t)0x28c1, (q15_t)0x7161, (q15_t)0x28b7, + (q15_t)0x7169, (q15_t)0x28ad, (q15_t)0x7171, (q15_t)0x28a4, (q15_t)0x7179, + (q15_t)0x289a, (q15_t)0x7181, (q15_t)0x2890, (q15_t)0x7189, (q15_t)0x2886, + (q15_t)0x7191, (q15_t)0x287d, (q15_t)0x7199, (q15_t)0x2873, (q15_t)0x71a1, + (q15_t)0x2869, (q15_t)0x71a9, (q15_t)0x2860, (q15_t)0x71b1, (q15_t)0x2856, + (q15_t)0x71b9, (q15_t)0x284c, (q15_t)0x71c0, (q15_t)0x2842, (q15_t)0x71c8, + (q15_t)0x2838, (q15_t)0x71d0, (q15_t)0x282f, (q15_t)0x71d8, (q15_t)0x2825, + (q15_t)0x71e0, (q15_t)0x281b, (q15_t)0x71e8, (q15_t)0x2811, (q15_t)0x71f0, + (q15_t)0x2808, (q15_t)0x71f8, (q15_t)0x27fe, (q15_t)0x71ff, (q15_t)0x27f4, + (q15_t)0x7207, (q15_t)0x27ea, (q15_t)0x720f, (q15_t)0x27e0, (q15_t)0x7217, + (q15_t)0x27d6, (q15_t)0x721f, (q15_t)0x27cd, (q15_t)0x7227, (q15_t)0x27c3, + (q15_t)0x722e, (q15_t)0x27b9, (q15_t)0x7236, (q15_t)0x27af, (q15_t)0x723e, + (q15_t)0x27a5, (q15_t)0x7246, (q15_t)0x279b, (q15_t)0x724e, (q15_t)0x2791, + (q15_t)0x7255, (q15_t)0x2788, (q15_t)0x725d, (q15_t)0x277e, (q15_t)0x7265, + (q15_t)0x2774, (q15_t)0x726d, (q15_t)0x276a, (q15_t)0x7274, (q15_t)0x2760, + (q15_t)0x727c, (q15_t)0x2756, (q15_t)0x7284, (q15_t)0x274c, (q15_t)0x728b, + (q15_t)0x2742, (q15_t)0x7293, (q15_t)0x2738, (q15_t)0x729b, (q15_t)0x272e, + (q15_t)0x72a3, (q15_t)0x2724, (q15_t)0x72aa, (q15_t)0x271a, (q15_t)0x72b2, + (q15_t)0x2711, (q15_t)0x72ba, (q15_t)0x2707, (q15_t)0x72c1, (q15_t)0x26fd, + (q15_t)0x72c9, (q15_t)0x26f3, (q15_t)0x72d0, (q15_t)0x26e9, (q15_t)0x72d8, + (q15_t)0x26df, (q15_t)0x72e0, (q15_t)0x26d5, (q15_t)0x72e7, (q15_t)0x26cb, + (q15_t)0x72ef, (q15_t)0x26c1, (q15_t)0x72f7, (q15_t)0x26b7, (q15_t)0x72fe, + (q15_t)0x26ad, (q15_t)0x7306, (q15_t)0x26a3, (q15_t)0x730d, (q15_t)0x2699, + (q15_t)0x7315, (q15_t)0x268f, (q15_t)0x731d, (q15_t)0x2685, (q15_t)0x7324, + (q15_t)0x267b, (q15_t)0x732c, (q15_t)0x2671, (q15_t)0x7333, (q15_t)0x2666, + (q15_t)0x733b, (q15_t)0x265c, (q15_t)0x7342, (q15_t)0x2652, (q15_t)0x734a, + (q15_t)0x2648, (q15_t)0x7351, (q15_t)0x263e, (q15_t)0x7359, (q15_t)0x2634, + (q15_t)0x7360, (q15_t)0x262a, (q15_t)0x7368, (q15_t)0x2620, (q15_t)0x736f, + (q15_t)0x2616, (q15_t)0x7377, (q15_t)0x260c, (q15_t)0x737e, (q15_t)0x2602, + (q15_t)0x7386, (q15_t)0x25f8, (q15_t)0x738d, (q15_t)0x25ed, (q15_t)0x7395, + (q15_t)0x25e3, (q15_t)0x739c, (q15_t)0x25d9, (q15_t)0x73a3, (q15_t)0x25cf, + (q15_t)0x73ab, (q15_t)0x25c5, (q15_t)0x73b2, (q15_t)0x25bb, (q15_t)0x73ba, + (q15_t)0x25b1, (q15_t)0x73c1, (q15_t)0x25a6, (q15_t)0x73c8, (q15_t)0x259c, + (q15_t)0x73d0, (q15_t)0x2592, (q15_t)0x73d7, (q15_t)0x2588, (q15_t)0x73df, + (q15_t)0x257e, (q15_t)0x73e6, (q15_t)0x2574, (q15_t)0x73ed, (q15_t)0x2569, + (q15_t)0x73f5, (q15_t)0x255f, (q15_t)0x73fc, (q15_t)0x2555, (q15_t)0x7403, + (q15_t)0x254b, (q15_t)0x740b, (q15_t)0x2541, (q15_t)0x7412, (q15_t)0x2536, + (q15_t)0x7419, (q15_t)0x252c, (q15_t)0x7420, (q15_t)0x2522, (q15_t)0x7428, + (q15_t)0x2518, (q15_t)0x742f, (q15_t)0x250d, (q15_t)0x7436, (q15_t)0x2503, + (q15_t)0x743e, (q15_t)0x24f9, (q15_t)0x7445, (q15_t)0x24ef, (q15_t)0x744c, + (q15_t)0x24e4, (q15_t)0x7453, (q15_t)0x24da, (q15_t)0x745b, (q15_t)0x24d0, + (q15_t)0x7462, (q15_t)0x24c5, (q15_t)0x7469, (q15_t)0x24bb, (q15_t)0x7470, + (q15_t)0x24b1, (q15_t)0x7477, (q15_t)0x24a7, (q15_t)0x747f, (q15_t)0x249c, + (q15_t)0x7486, (q15_t)0x2492, (q15_t)0x748d, (q15_t)0x2488, (q15_t)0x7494, + (q15_t)0x247d, (q15_t)0x749b, (q15_t)0x2473, (q15_t)0x74a2, (q15_t)0x2469, + (q15_t)0x74aa, (q15_t)0x245e, (q15_t)0x74b1, (q15_t)0x2454, (q15_t)0x74b8, + (q15_t)0x244a, (q15_t)0x74bf, (q15_t)0x243f, (q15_t)0x74c6, (q15_t)0x2435, + (q15_t)0x74cd, (q15_t)0x242b, (q15_t)0x74d4, (q15_t)0x2420, (q15_t)0x74db, + (q15_t)0x2416, (q15_t)0x74e2, (q15_t)0x240b, (q15_t)0x74ea, (q15_t)0x2401, + (q15_t)0x74f1, (q15_t)0x23f7, (q15_t)0x74f8, (q15_t)0x23ec, (q15_t)0x74ff, + (q15_t)0x23e2, (q15_t)0x7506, (q15_t)0x23d7, (q15_t)0x750d, (q15_t)0x23cd, + (q15_t)0x7514, (q15_t)0x23c3, (q15_t)0x751b, (q15_t)0x23b8, (q15_t)0x7522, + (q15_t)0x23ae, (q15_t)0x7529, (q15_t)0x23a3, (q15_t)0x7530, (q15_t)0x2399, + (q15_t)0x7537, (q15_t)0x238e, (q15_t)0x753e, (q15_t)0x2384, (q15_t)0x7545, + (q15_t)0x237a, (q15_t)0x754c, (q15_t)0x236f, (q15_t)0x7553, (q15_t)0x2365, + (q15_t)0x755a, (q15_t)0x235a, (q15_t)0x7561, (q15_t)0x2350, (q15_t)0x7567, + (q15_t)0x2345, (q15_t)0x756e, (q15_t)0x233b, (q15_t)0x7575, (q15_t)0x2330, + (q15_t)0x757c, (q15_t)0x2326, (q15_t)0x7583, (q15_t)0x231b, (q15_t)0x758a, + (q15_t)0x2311, (q15_t)0x7591, (q15_t)0x2306, (q15_t)0x7598, (q15_t)0x22fc, + (q15_t)0x759f, (q15_t)0x22f1, (q15_t)0x75a5, (q15_t)0x22e7, (q15_t)0x75ac, + (q15_t)0x22dc, (q15_t)0x75b3, (q15_t)0x22d2, (q15_t)0x75ba, (q15_t)0x22c7, + (q15_t)0x75c1, (q15_t)0x22bc, (q15_t)0x75c8, (q15_t)0x22b2, (q15_t)0x75ce, + (q15_t)0x22a7, (q15_t)0x75d5, (q15_t)0x229d, (q15_t)0x75dc, (q15_t)0x2292, + (q15_t)0x75e3, (q15_t)0x2288, (q15_t)0x75ea, (q15_t)0x227d, (q15_t)0x75f0, + (q15_t)0x2272, (q15_t)0x75f7, (q15_t)0x2268, (q15_t)0x75fe, (q15_t)0x225d, + (q15_t)0x7605, (q15_t)0x2253, (q15_t)0x760b, (q15_t)0x2248, (q15_t)0x7612, + (q15_t)0x223d, (q15_t)0x7619, (q15_t)0x2233, (q15_t)0x7620, (q15_t)0x2228, + (q15_t)0x7626, (q15_t)0x221e, (q15_t)0x762d, (q15_t)0x2213, (q15_t)0x7634, + (q15_t)0x2208, (q15_t)0x763a, (q15_t)0x21fe, (q15_t)0x7641, (q15_t)0x21f3, + (q15_t)0x7648, (q15_t)0x21e8, (q15_t)0x764e, (q15_t)0x21de, (q15_t)0x7655, + (q15_t)0x21d3, (q15_t)0x765c, (q15_t)0x21c8, (q15_t)0x7662, (q15_t)0x21be, + (q15_t)0x7669, (q15_t)0x21b3, (q15_t)0x766f, (q15_t)0x21a8, (q15_t)0x7676, + (q15_t)0x219e, (q15_t)0x767d, (q15_t)0x2193, (q15_t)0x7683, (q15_t)0x2188, + (q15_t)0x768a, (q15_t)0x217d, (q15_t)0x7690, (q15_t)0x2173, (q15_t)0x7697, + (q15_t)0x2168, (q15_t)0x769d, (q15_t)0x215d, (q15_t)0x76a4, (q15_t)0x2153, + (q15_t)0x76ab, (q15_t)0x2148, (q15_t)0x76b1, (q15_t)0x213d, (q15_t)0x76b8, + (q15_t)0x2132, (q15_t)0x76be, (q15_t)0x2128, (q15_t)0x76c5, (q15_t)0x211d, + (q15_t)0x76cb, (q15_t)0x2112, (q15_t)0x76d2, (q15_t)0x2107, (q15_t)0x76d8, + (q15_t)0x20fd, (q15_t)0x76df, (q15_t)0x20f2, (q15_t)0x76e5, (q15_t)0x20e7, + (q15_t)0x76eb, (q15_t)0x20dc, (q15_t)0x76f2, (q15_t)0x20d1, (q15_t)0x76f8, + (q15_t)0x20c7, (q15_t)0x76ff, (q15_t)0x20bc, (q15_t)0x7705, (q15_t)0x20b1, + (q15_t)0x770c, (q15_t)0x20a6, (q15_t)0x7712, (q15_t)0x209b, (q15_t)0x7718, + (q15_t)0x2091, (q15_t)0x771f, (q15_t)0x2086, (q15_t)0x7725, (q15_t)0x207b, + (q15_t)0x772c, (q15_t)0x2070, (q15_t)0x7732, (q15_t)0x2065, (q15_t)0x7738, + (q15_t)0x205b, (q15_t)0x773f, (q15_t)0x2050, (q15_t)0x7745, (q15_t)0x2045, + (q15_t)0x774b, (q15_t)0x203a, (q15_t)0x7752, (q15_t)0x202f, (q15_t)0x7758, + (q15_t)0x2024, (q15_t)0x775e, (q15_t)0x2019, (q15_t)0x7765, (q15_t)0x200f, + (q15_t)0x776b, (q15_t)0x2004, (q15_t)0x7771, (q15_t)0x1ff9, (q15_t)0x7777, + (q15_t)0x1fee, (q15_t)0x777e, (q15_t)0x1fe3, (q15_t)0x7784, (q15_t)0x1fd8, + (q15_t)0x778a, (q15_t)0x1fcd, (q15_t)0x7790, (q15_t)0x1fc2, (q15_t)0x7797, + (q15_t)0x1fb7, (q15_t)0x779d, (q15_t)0x1fac, (q15_t)0x77a3, (q15_t)0x1fa2, + (q15_t)0x77a9, (q15_t)0x1f97, (q15_t)0x77b0, (q15_t)0x1f8c, (q15_t)0x77b6, + (q15_t)0x1f81, (q15_t)0x77bc, (q15_t)0x1f76, (q15_t)0x77c2, (q15_t)0x1f6b, + (q15_t)0x77c8, (q15_t)0x1f60, (q15_t)0x77ce, (q15_t)0x1f55, (q15_t)0x77d5, + (q15_t)0x1f4a, (q15_t)0x77db, (q15_t)0x1f3f, (q15_t)0x77e1, (q15_t)0x1f34, + (q15_t)0x77e7, (q15_t)0x1f29, (q15_t)0x77ed, (q15_t)0x1f1e, (q15_t)0x77f3, + (q15_t)0x1f13, (q15_t)0x77f9, (q15_t)0x1f08, (q15_t)0x77ff, (q15_t)0x1efd, + (q15_t)0x7805, (q15_t)0x1ef2, (q15_t)0x780b, (q15_t)0x1ee7, (q15_t)0x7812, + (q15_t)0x1edc, (q15_t)0x7818, (q15_t)0x1ed1, (q15_t)0x781e, (q15_t)0x1ec6, + (q15_t)0x7824, (q15_t)0x1ebb, (q15_t)0x782a, (q15_t)0x1eb0, (q15_t)0x7830, + (q15_t)0x1ea5, (q15_t)0x7836, (q15_t)0x1e9a, (q15_t)0x783c, (q15_t)0x1e8f, + (q15_t)0x7842, (q15_t)0x1e84, (q15_t)0x7848, (q15_t)0x1e79, (q15_t)0x784e, + (q15_t)0x1e6e, (q15_t)0x7854, (q15_t)0x1e63, (q15_t)0x785a, (q15_t)0x1e58, + (q15_t)0x7860, (q15_t)0x1e4d, (q15_t)0x7866, (q15_t)0x1e42, (q15_t)0x786b, + (q15_t)0x1e36, (q15_t)0x7871, (q15_t)0x1e2b, (q15_t)0x7877, (q15_t)0x1e20, + (q15_t)0x787d, (q15_t)0x1e15, (q15_t)0x7883, (q15_t)0x1e0a, (q15_t)0x7889, + (q15_t)0x1dff, (q15_t)0x788f, (q15_t)0x1df4, (q15_t)0x7895, (q15_t)0x1de9, + (q15_t)0x789b, (q15_t)0x1dde, (q15_t)0x78a1, (q15_t)0x1dd3, (q15_t)0x78a6, + (q15_t)0x1dc7, (q15_t)0x78ac, (q15_t)0x1dbc, (q15_t)0x78b2, (q15_t)0x1db1, + (q15_t)0x78b8, (q15_t)0x1da6, (q15_t)0x78be, (q15_t)0x1d9b, (q15_t)0x78c3, + (q15_t)0x1d90, (q15_t)0x78c9, (q15_t)0x1d85, (q15_t)0x78cf, (q15_t)0x1d79, + (q15_t)0x78d5, (q15_t)0x1d6e, (q15_t)0x78db, (q15_t)0x1d63, (q15_t)0x78e0, + (q15_t)0x1d58, (q15_t)0x78e6, (q15_t)0x1d4d, (q15_t)0x78ec, (q15_t)0x1d42, + (q15_t)0x78f2, (q15_t)0x1d36, (q15_t)0x78f7, (q15_t)0x1d2b, (q15_t)0x78fd, + (q15_t)0x1d20, (q15_t)0x7903, (q15_t)0x1d15, (q15_t)0x7909, (q15_t)0x1d0a, + (q15_t)0x790e, (q15_t)0x1cff, (q15_t)0x7914, (q15_t)0x1cf3, (q15_t)0x791a, + (q15_t)0x1ce8, (q15_t)0x791f, (q15_t)0x1cdd, (q15_t)0x7925, (q15_t)0x1cd2, + (q15_t)0x792b, (q15_t)0x1cc6, (q15_t)0x7930, (q15_t)0x1cbb, (q15_t)0x7936, + (q15_t)0x1cb0, (q15_t)0x793b, (q15_t)0x1ca5, (q15_t)0x7941, (q15_t)0x1c99, + (q15_t)0x7947, (q15_t)0x1c8e, (q15_t)0x794c, (q15_t)0x1c83, (q15_t)0x7952, + (q15_t)0x1c78, (q15_t)0x7958, (q15_t)0x1c6c, (q15_t)0x795d, (q15_t)0x1c61, + (q15_t)0x7963, (q15_t)0x1c56, (q15_t)0x7968, (q15_t)0x1c4b, (q15_t)0x796e, + (q15_t)0x1c3f, (q15_t)0x7973, (q15_t)0x1c34, (q15_t)0x7979, (q15_t)0x1c29, + (q15_t)0x797e, (q15_t)0x1c1e, (q15_t)0x7984, (q15_t)0x1c12, (q15_t)0x7989, + (q15_t)0x1c07, (q15_t)0x798f, (q15_t)0x1bfc, (q15_t)0x7994, (q15_t)0x1bf0, + (q15_t)0x799a, (q15_t)0x1be5, (q15_t)0x799f, (q15_t)0x1bda, (q15_t)0x79a5, + (q15_t)0x1bce, (q15_t)0x79aa, (q15_t)0x1bc3, (q15_t)0x79b0, (q15_t)0x1bb8, + (q15_t)0x79b5, (q15_t)0x1bac, (q15_t)0x79bb, (q15_t)0x1ba1, (q15_t)0x79c0, + (q15_t)0x1b96, (q15_t)0x79c5, (q15_t)0x1b8a, (q15_t)0x79cb, (q15_t)0x1b7f, + (q15_t)0x79d0, (q15_t)0x1b74, (q15_t)0x79d6, (q15_t)0x1b68, (q15_t)0x79db, + (q15_t)0x1b5d, (q15_t)0x79e0, (q15_t)0x1b52, (q15_t)0x79e6, (q15_t)0x1b46, + (q15_t)0x79eb, (q15_t)0x1b3b, (q15_t)0x79f0, (q15_t)0x1b30, (q15_t)0x79f6, + (q15_t)0x1b24, (q15_t)0x79fb, (q15_t)0x1b19, (q15_t)0x7a00, (q15_t)0x1b0d, + (q15_t)0x7a06, (q15_t)0x1b02, (q15_t)0x7a0b, (q15_t)0x1af7, (q15_t)0x7a10, + (q15_t)0x1aeb, (q15_t)0x7a16, (q15_t)0x1ae0, (q15_t)0x7a1b, (q15_t)0x1ad4, + (q15_t)0x7a20, (q15_t)0x1ac9, (q15_t)0x7a25, (q15_t)0x1abe, (q15_t)0x7a2b, + (q15_t)0x1ab2, (q15_t)0x7a30, (q15_t)0x1aa7, (q15_t)0x7a35, (q15_t)0x1a9b, + (q15_t)0x7a3a, (q15_t)0x1a90, (q15_t)0x7a3f, (q15_t)0x1a84, (q15_t)0x7a45, + (q15_t)0x1a79, (q15_t)0x7a4a, (q15_t)0x1a6e, (q15_t)0x7a4f, (q15_t)0x1a62, + (q15_t)0x7a54, (q15_t)0x1a57, (q15_t)0x7a59, (q15_t)0x1a4b, (q15_t)0x7a5f, + (q15_t)0x1a40, (q15_t)0x7a64, (q15_t)0x1a34, (q15_t)0x7a69, (q15_t)0x1a29, + (q15_t)0x7a6e, (q15_t)0x1a1d, (q15_t)0x7a73, (q15_t)0x1a12, (q15_t)0x7a78, + (q15_t)0x1a06, (q15_t)0x7a7d, (q15_t)0x19fb, (q15_t)0x7a82, (q15_t)0x19ef, + (q15_t)0x7a88, (q15_t)0x19e4, (q15_t)0x7a8d, (q15_t)0x19d8, (q15_t)0x7a92, + (q15_t)0x19cd, (q15_t)0x7a97, (q15_t)0x19c1, (q15_t)0x7a9c, (q15_t)0x19b6, + (q15_t)0x7aa1, (q15_t)0x19aa, (q15_t)0x7aa6, (q15_t)0x199f, (q15_t)0x7aab, + (q15_t)0x1993, (q15_t)0x7ab0, (q15_t)0x1988, (q15_t)0x7ab5, (q15_t)0x197c, + (q15_t)0x7aba, (q15_t)0x1971, (q15_t)0x7abf, (q15_t)0x1965, (q15_t)0x7ac4, + (q15_t)0x195a, (q15_t)0x7ac9, (q15_t)0x194e, (q15_t)0x7ace, (q15_t)0x1943, + (q15_t)0x7ad3, (q15_t)0x1937, (q15_t)0x7ad8, (q15_t)0x192c, (q15_t)0x7add, + (q15_t)0x1920, (q15_t)0x7ae2, (q15_t)0x1914, (q15_t)0x7ae6, (q15_t)0x1909, + (q15_t)0x7aeb, (q15_t)0x18fd, (q15_t)0x7af0, (q15_t)0x18f2, (q15_t)0x7af5, + (q15_t)0x18e6, (q15_t)0x7afa, (q15_t)0x18db, (q15_t)0x7aff, (q15_t)0x18cf, + (q15_t)0x7b04, (q15_t)0x18c3, (q15_t)0x7b09, (q15_t)0x18b8, (q15_t)0x7b0e, + (q15_t)0x18ac, (q15_t)0x7b12, (q15_t)0x18a1, (q15_t)0x7b17, (q15_t)0x1895, + (q15_t)0x7b1c, (q15_t)0x1889, (q15_t)0x7b21, (q15_t)0x187e, (q15_t)0x7b26, + (q15_t)0x1872, (q15_t)0x7b2a, (q15_t)0x1867, (q15_t)0x7b2f, (q15_t)0x185b, + (q15_t)0x7b34, (q15_t)0x184f, (q15_t)0x7b39, (q15_t)0x1844, (q15_t)0x7b3e, + (q15_t)0x1838, (q15_t)0x7b42, (q15_t)0x182d, (q15_t)0x7b47, (q15_t)0x1821, + (q15_t)0x7b4c, (q15_t)0x1815, (q15_t)0x7b50, (q15_t)0x180a, (q15_t)0x7b55, + (q15_t)0x17fe, (q15_t)0x7b5a, (q15_t)0x17f2, (q15_t)0x7b5f, (q15_t)0x17e7, + (q15_t)0x7b63, (q15_t)0x17db, (q15_t)0x7b68, (q15_t)0x17cf, (q15_t)0x7b6d, + (q15_t)0x17c4, (q15_t)0x7b71, (q15_t)0x17b8, (q15_t)0x7b76, (q15_t)0x17ac, + (q15_t)0x7b7b, (q15_t)0x17a1, (q15_t)0x7b7f, (q15_t)0x1795, (q15_t)0x7b84, + (q15_t)0x1789, (q15_t)0x7b88, (q15_t)0x177e, (q15_t)0x7b8d, (q15_t)0x1772, + (q15_t)0x7b92, (q15_t)0x1766, (q15_t)0x7b96, (q15_t)0x175b, (q15_t)0x7b9b, + (q15_t)0x174f, (q15_t)0x7b9f, (q15_t)0x1743, (q15_t)0x7ba4, (q15_t)0x1737, + (q15_t)0x7ba9, (q15_t)0x172c, (q15_t)0x7bad, (q15_t)0x1720, (q15_t)0x7bb2, + (q15_t)0x1714, (q15_t)0x7bb6, (q15_t)0x1709, (q15_t)0x7bbb, (q15_t)0x16fd, + (q15_t)0x7bbf, (q15_t)0x16f1, (q15_t)0x7bc4, (q15_t)0x16e5, (q15_t)0x7bc8, + (q15_t)0x16da, (q15_t)0x7bcd, (q15_t)0x16ce, (q15_t)0x7bd1, (q15_t)0x16c2, + (q15_t)0x7bd6, (q15_t)0x16b6, (q15_t)0x7bda, (q15_t)0x16ab, (q15_t)0x7bde, + (q15_t)0x169f, (q15_t)0x7be3, (q15_t)0x1693, (q15_t)0x7be7, (q15_t)0x1687, + (q15_t)0x7bec, (q15_t)0x167c, (q15_t)0x7bf0, (q15_t)0x1670, (q15_t)0x7bf5, + (q15_t)0x1664, (q15_t)0x7bf9, (q15_t)0x1658, (q15_t)0x7bfd, (q15_t)0x164c, + (q15_t)0x7c02, (q15_t)0x1641, (q15_t)0x7c06, (q15_t)0x1635, (q15_t)0x7c0a, + (q15_t)0x1629, (q15_t)0x7c0f, (q15_t)0x161d, (q15_t)0x7c13, (q15_t)0x1612, + (q15_t)0x7c17, (q15_t)0x1606, (q15_t)0x7c1c, (q15_t)0x15fa, (q15_t)0x7c20, + (q15_t)0x15ee, (q15_t)0x7c24, (q15_t)0x15e2, (q15_t)0x7c29, (q15_t)0x15d7, + (q15_t)0x7c2d, (q15_t)0x15cb, (q15_t)0x7c31, (q15_t)0x15bf, (q15_t)0x7c36, + (q15_t)0x15b3, (q15_t)0x7c3a, (q15_t)0x15a7, (q15_t)0x7c3e, (q15_t)0x159b, + (q15_t)0x7c42, (q15_t)0x1590, (q15_t)0x7c46, (q15_t)0x1584, (q15_t)0x7c4b, + (q15_t)0x1578, (q15_t)0x7c4f, (q15_t)0x156c, (q15_t)0x7c53, (q15_t)0x1560, + (q15_t)0x7c57, (q15_t)0x1554, (q15_t)0x7c5b, (q15_t)0x1549, (q15_t)0x7c60, + (q15_t)0x153d, (q15_t)0x7c64, (q15_t)0x1531, (q15_t)0x7c68, (q15_t)0x1525, + (q15_t)0x7c6c, (q15_t)0x1519, (q15_t)0x7c70, (q15_t)0x150d, (q15_t)0x7c74, + (q15_t)0x1501, (q15_t)0x7c79, (q15_t)0x14f6, (q15_t)0x7c7d, (q15_t)0x14ea, + (q15_t)0x7c81, (q15_t)0x14de, (q15_t)0x7c85, (q15_t)0x14d2, (q15_t)0x7c89, + (q15_t)0x14c6, (q15_t)0x7c8d, (q15_t)0x14ba, (q15_t)0x7c91, (q15_t)0x14ae, + (q15_t)0x7c95, (q15_t)0x14a2, (q15_t)0x7c99, (q15_t)0x1496, (q15_t)0x7c9d, + (q15_t)0x148b, (q15_t)0x7ca1, (q15_t)0x147f, (q15_t)0x7ca5, (q15_t)0x1473, + (q15_t)0x7ca9, (q15_t)0x1467, (q15_t)0x7cad, (q15_t)0x145b, (q15_t)0x7cb1, + (q15_t)0x144f, (q15_t)0x7cb5, (q15_t)0x1443, (q15_t)0x7cb9, (q15_t)0x1437, + (q15_t)0x7cbd, (q15_t)0x142b, (q15_t)0x7cc1, (q15_t)0x141f, (q15_t)0x7cc5, + (q15_t)0x1413, (q15_t)0x7cc9, (q15_t)0x1407, (q15_t)0x7ccd, (q15_t)0x13fb, + (q15_t)0x7cd1, (q15_t)0x13f0, (q15_t)0x7cd5, (q15_t)0x13e4, (q15_t)0x7cd9, + (q15_t)0x13d8, (q15_t)0x7cdd, (q15_t)0x13cc, (q15_t)0x7ce0, (q15_t)0x13c0, + (q15_t)0x7ce4, (q15_t)0x13b4, (q15_t)0x7ce8, (q15_t)0x13a8, (q15_t)0x7cec, + (q15_t)0x139c, (q15_t)0x7cf0, (q15_t)0x1390, (q15_t)0x7cf4, (q15_t)0x1384, + (q15_t)0x7cf8, (q15_t)0x1378, (q15_t)0x7cfb, (q15_t)0x136c, (q15_t)0x7cff, + (q15_t)0x1360, (q15_t)0x7d03, (q15_t)0x1354, (q15_t)0x7d07, (q15_t)0x1348, + (q15_t)0x7d0b, (q15_t)0x133c, (q15_t)0x7d0e, (q15_t)0x1330, (q15_t)0x7d12, + (q15_t)0x1324, (q15_t)0x7d16, (q15_t)0x1318, (q15_t)0x7d1a, (q15_t)0x130c, + (q15_t)0x7d1d, (q15_t)0x1300, (q15_t)0x7d21, (q15_t)0x12f4, (q15_t)0x7d25, + (q15_t)0x12e8, (q15_t)0x7d28, (q15_t)0x12dc, (q15_t)0x7d2c, (q15_t)0x12d0, + (q15_t)0x7d30, (q15_t)0x12c4, (q15_t)0x7d34, (q15_t)0x12b8, (q15_t)0x7d37, + (q15_t)0x12ac, (q15_t)0x7d3b, (q15_t)0x12a0, (q15_t)0x7d3f, (q15_t)0x1294, + (q15_t)0x7d42, (q15_t)0x1288, (q15_t)0x7d46, (q15_t)0x127c, (q15_t)0x7d49, + (q15_t)0x1270, (q15_t)0x7d4d, (q15_t)0x1264, (q15_t)0x7d51, (q15_t)0x1258, + (q15_t)0x7d54, (q15_t)0x124c, (q15_t)0x7d58, (q15_t)0x1240, (q15_t)0x7d5b, + (q15_t)0x1234, (q15_t)0x7d5f, (q15_t)0x1228, (q15_t)0x7d63, (q15_t)0x121c, + (q15_t)0x7d66, (q15_t)0x1210, (q15_t)0x7d6a, (q15_t)0x1204, (q15_t)0x7d6d, + (q15_t)0x11f7, (q15_t)0x7d71, (q15_t)0x11eb, (q15_t)0x7d74, (q15_t)0x11df, + (q15_t)0x7d78, (q15_t)0x11d3, (q15_t)0x7d7b, (q15_t)0x11c7, (q15_t)0x7d7f, + (q15_t)0x11bb, (q15_t)0x7d82, (q15_t)0x11af, (q15_t)0x7d86, (q15_t)0x11a3, + (q15_t)0x7d89, (q15_t)0x1197, (q15_t)0x7d8d, (q15_t)0x118b, (q15_t)0x7d90, + (q15_t)0x117f, (q15_t)0x7d93, (q15_t)0x1173, (q15_t)0x7d97, (q15_t)0x1167, + (q15_t)0x7d9a, (q15_t)0x115a, (q15_t)0x7d9e, (q15_t)0x114e, (q15_t)0x7da1, + (q15_t)0x1142, (q15_t)0x7da4, (q15_t)0x1136, (q15_t)0x7da8, (q15_t)0x112a, + (q15_t)0x7dab, (q15_t)0x111e, (q15_t)0x7daf, (q15_t)0x1112, (q15_t)0x7db2, + (q15_t)0x1106, (q15_t)0x7db5, (q15_t)0x10fa, (q15_t)0x7db9, (q15_t)0x10ed, + (q15_t)0x7dbc, (q15_t)0x10e1, (q15_t)0x7dbf, (q15_t)0x10d5, (q15_t)0x7dc2, + (q15_t)0x10c9, (q15_t)0x7dc6, (q15_t)0x10bd, (q15_t)0x7dc9, (q15_t)0x10b1, + (q15_t)0x7dcc, (q15_t)0x10a5, (q15_t)0x7dd0, (q15_t)0x1099, (q15_t)0x7dd3, + (q15_t)0x108c, (q15_t)0x7dd6, (q15_t)0x1080, (q15_t)0x7dd9, (q15_t)0x1074, + (q15_t)0x7ddd, (q15_t)0x1068, (q15_t)0x7de0, (q15_t)0x105c, (q15_t)0x7de3, + (q15_t)0x1050, (q15_t)0x7de6, (q15_t)0x1044, (q15_t)0x7de9, (q15_t)0x1037, + (q15_t)0x7ded, (q15_t)0x102b, (q15_t)0x7df0, (q15_t)0x101f, (q15_t)0x7df3, + (q15_t)0x1013, (q15_t)0x7df6, (q15_t)0x1007, (q15_t)0x7df9, (q15_t)0xffb, + (q15_t)0x7dfc, (q15_t)0xfee, (q15_t)0x7dff, (q15_t)0xfe2, (q15_t)0x7e03, + (q15_t)0xfd6, (q15_t)0x7e06, (q15_t)0xfca, (q15_t)0x7e09, (q15_t)0xfbe, + (q15_t)0x7e0c, (q15_t)0xfb2, (q15_t)0x7e0f, (q15_t)0xfa5, (q15_t)0x7e12, + (q15_t)0xf99, (q15_t)0x7e15, (q15_t)0xf8d, (q15_t)0x7e18, (q15_t)0xf81, + (q15_t)0x7e1b, (q15_t)0xf75, (q15_t)0x7e1e, (q15_t)0xf68, (q15_t)0x7e21, + (q15_t)0xf5c, (q15_t)0x7e24, (q15_t)0xf50, (q15_t)0x7e27, (q15_t)0xf44, + (q15_t)0x7e2a, (q15_t)0xf38, (q15_t)0x7e2d, (q15_t)0xf2b, (q15_t)0x7e30, + (q15_t)0xf1f, (q15_t)0x7e33, (q15_t)0xf13, (q15_t)0x7e36, (q15_t)0xf07, + (q15_t)0x7e39, (q15_t)0xefb, (q15_t)0x7e3c, (q15_t)0xeee, (q15_t)0x7e3f, + (q15_t)0xee2, (q15_t)0x7e42, (q15_t)0xed6, (q15_t)0x7e45, (q15_t)0xeca, + (q15_t)0x7e48, (q15_t)0xebd, (q15_t)0x7e4a, (q15_t)0xeb1, (q15_t)0x7e4d, + (q15_t)0xea5, (q15_t)0x7e50, (q15_t)0xe99, (q15_t)0x7e53, (q15_t)0xe8c, + (q15_t)0x7e56, (q15_t)0xe80, (q15_t)0x7e59, (q15_t)0xe74, (q15_t)0x7e5c, + (q15_t)0xe68, (q15_t)0x7e5e, (q15_t)0xe5c, (q15_t)0x7e61, (q15_t)0xe4f, + (q15_t)0x7e64, (q15_t)0xe43, (q15_t)0x7e67, (q15_t)0xe37, (q15_t)0x7e6a, + (q15_t)0xe2b, (q15_t)0x7e6c, (q15_t)0xe1e, (q15_t)0x7e6f, (q15_t)0xe12, + (q15_t)0x7e72, (q15_t)0xe06, (q15_t)0x7e75, (q15_t)0xdf9, (q15_t)0x7e77, + (q15_t)0xded, (q15_t)0x7e7a, (q15_t)0xde1, (q15_t)0x7e7d, (q15_t)0xdd5, + (q15_t)0x7e80, (q15_t)0xdc8, (q15_t)0x7e82, (q15_t)0xdbc, (q15_t)0x7e85, + (q15_t)0xdb0, (q15_t)0x7e88, (q15_t)0xda4, (q15_t)0x7e8a, (q15_t)0xd97, + (q15_t)0x7e8d, (q15_t)0xd8b, (q15_t)0x7e90, (q15_t)0xd7f, (q15_t)0x7e92, + (q15_t)0xd72, (q15_t)0x7e95, (q15_t)0xd66, (q15_t)0x7e98, (q15_t)0xd5a, + (q15_t)0x7e9a, (q15_t)0xd4e, (q15_t)0x7e9d, (q15_t)0xd41, (q15_t)0x7e9f, + (q15_t)0xd35, (q15_t)0x7ea2, (q15_t)0xd29, (q15_t)0x7ea5, (q15_t)0xd1c, + (q15_t)0x7ea7, (q15_t)0xd10, (q15_t)0x7eaa, (q15_t)0xd04, (q15_t)0x7eac, + (q15_t)0xcf8, (q15_t)0x7eaf, (q15_t)0xceb, (q15_t)0x7eb1, (q15_t)0xcdf, + (q15_t)0x7eb4, (q15_t)0xcd3, (q15_t)0x7eb6, (q15_t)0xcc6, (q15_t)0x7eb9, + (q15_t)0xcba, (q15_t)0x7ebb, (q15_t)0xcae, (q15_t)0x7ebe, (q15_t)0xca1, + (q15_t)0x7ec0, (q15_t)0xc95, (q15_t)0x7ec3, (q15_t)0xc89, (q15_t)0x7ec5, + (q15_t)0xc7c, (q15_t)0x7ec8, (q15_t)0xc70, (q15_t)0x7eca, (q15_t)0xc64, + (q15_t)0x7ecc, (q15_t)0xc57, (q15_t)0x7ecf, (q15_t)0xc4b, (q15_t)0x7ed1, + (q15_t)0xc3f, (q15_t)0x7ed4, (q15_t)0xc32, (q15_t)0x7ed6, (q15_t)0xc26, + (q15_t)0x7ed8, (q15_t)0xc1a, (q15_t)0x7edb, (q15_t)0xc0d, (q15_t)0x7edd, + (q15_t)0xc01, (q15_t)0x7ee0, (q15_t)0xbf5, (q15_t)0x7ee2, (q15_t)0xbe8, + (q15_t)0x7ee4, (q15_t)0xbdc, (q15_t)0x7ee7, (q15_t)0xbd0, (q15_t)0x7ee9, + (q15_t)0xbc3, (q15_t)0x7eeb, (q15_t)0xbb7, (q15_t)0x7eed, (q15_t)0xbab, + (q15_t)0x7ef0, (q15_t)0xb9e, (q15_t)0x7ef2, (q15_t)0xb92, (q15_t)0x7ef4, + (q15_t)0xb85, (q15_t)0x7ef7, (q15_t)0xb79, (q15_t)0x7ef9, (q15_t)0xb6d, + (q15_t)0x7efb, (q15_t)0xb60, (q15_t)0x7efd, (q15_t)0xb54, (q15_t)0x7f00, + (q15_t)0xb48, (q15_t)0x7f02, (q15_t)0xb3b, (q15_t)0x7f04, (q15_t)0xb2f, + (q15_t)0x7f06, (q15_t)0xb23, (q15_t)0x7f08, (q15_t)0xb16, (q15_t)0x7f0a, + (q15_t)0xb0a, (q15_t)0x7f0d, (q15_t)0xafd, (q15_t)0x7f0f, (q15_t)0xaf1, + (q15_t)0x7f11, (q15_t)0xae5, (q15_t)0x7f13, (q15_t)0xad8, (q15_t)0x7f15, + (q15_t)0xacc, (q15_t)0x7f17, (q15_t)0xac0, (q15_t)0x7f19, (q15_t)0xab3, + (q15_t)0x7f1c, (q15_t)0xaa7, (q15_t)0x7f1e, (q15_t)0xa9a, (q15_t)0x7f20, + (q15_t)0xa8e, (q15_t)0x7f22, (q15_t)0xa82, (q15_t)0x7f24, (q15_t)0xa75, + (q15_t)0x7f26, (q15_t)0xa69, (q15_t)0x7f28, (q15_t)0xa5c, (q15_t)0x7f2a, + (q15_t)0xa50, (q15_t)0x7f2c, (q15_t)0xa44, (q15_t)0x7f2e, (q15_t)0xa37, + (q15_t)0x7f30, (q15_t)0xa2b, (q15_t)0x7f32, (q15_t)0xa1e, (q15_t)0x7f34, + (q15_t)0xa12, (q15_t)0x7f36, (q15_t)0xa06, (q15_t)0x7f38, (q15_t)0x9f9, + (q15_t)0x7f3a, (q15_t)0x9ed, (q15_t)0x7f3c, (q15_t)0x9e0, (q15_t)0x7f3e, + (q15_t)0x9d4, (q15_t)0x7f40, (q15_t)0x9c7, (q15_t)0x7f42, (q15_t)0x9bb, + (q15_t)0x7f43, (q15_t)0x9af, (q15_t)0x7f45, (q15_t)0x9a2, (q15_t)0x7f47, + (q15_t)0x996, (q15_t)0x7f49, (q15_t)0x989, (q15_t)0x7f4b, (q15_t)0x97d, + (q15_t)0x7f4d, (q15_t)0x970, (q15_t)0x7f4f, (q15_t)0x964, (q15_t)0x7f51, + (q15_t)0x958, (q15_t)0x7f52, (q15_t)0x94b, (q15_t)0x7f54, (q15_t)0x93f, + (q15_t)0x7f56, (q15_t)0x932, (q15_t)0x7f58, (q15_t)0x926, (q15_t)0x7f5a, + (q15_t)0x919, (q15_t)0x7f5b, (q15_t)0x90d, (q15_t)0x7f5d, (q15_t)0x901, + (q15_t)0x7f5f, (q15_t)0x8f4, (q15_t)0x7f61, (q15_t)0x8e8, (q15_t)0x7f62, + (q15_t)0x8db, (q15_t)0x7f64, (q15_t)0x8cf, (q15_t)0x7f66, (q15_t)0x8c2, + (q15_t)0x7f68, (q15_t)0x8b6, (q15_t)0x7f69, (q15_t)0x8a9, (q15_t)0x7f6b, + (q15_t)0x89d, (q15_t)0x7f6d, (q15_t)0x891, (q15_t)0x7f6e, (q15_t)0x884, + (q15_t)0x7f70, (q15_t)0x878, (q15_t)0x7f72, (q15_t)0x86b, (q15_t)0x7f73, + (q15_t)0x85f, (q15_t)0x7f75, (q15_t)0x852, (q15_t)0x7f77, (q15_t)0x846, + (q15_t)0x7f78, (q15_t)0x839, (q15_t)0x7f7a, (q15_t)0x82d, (q15_t)0x7f7b, + (q15_t)0x820, (q15_t)0x7f7d, (q15_t)0x814, (q15_t)0x7f7f, (q15_t)0x807, + (q15_t)0x7f80, (q15_t)0x7fb, (q15_t)0x7f82, (q15_t)0x7ef, (q15_t)0x7f83, + (q15_t)0x7e2, (q15_t)0x7f85, (q15_t)0x7d6, (q15_t)0x7f86, (q15_t)0x7c9, + (q15_t)0x7f88, (q15_t)0x7bd, (q15_t)0x7f89, (q15_t)0x7b0, (q15_t)0x7f8b, + (q15_t)0x7a4, (q15_t)0x7f8c, (q15_t)0x797, (q15_t)0x7f8e, (q15_t)0x78b, + (q15_t)0x7f8f, (q15_t)0x77e, (q15_t)0x7f91, (q15_t)0x772, (q15_t)0x7f92, + (q15_t)0x765, (q15_t)0x7f94, (q15_t)0x759, (q15_t)0x7f95, (q15_t)0x74c, + (q15_t)0x7f97, (q15_t)0x740, (q15_t)0x7f98, (q15_t)0x733, (q15_t)0x7f99, + (q15_t)0x727, (q15_t)0x7f9b, (q15_t)0x71a, (q15_t)0x7f9c, (q15_t)0x70e, + (q15_t)0x7f9e, (q15_t)0x701, (q15_t)0x7f9f, (q15_t)0x6f5, (q15_t)0x7fa0, + (q15_t)0x6e8, (q15_t)0x7fa2, (q15_t)0x6dc, (q15_t)0x7fa3, (q15_t)0x6cf, + (q15_t)0x7fa4, (q15_t)0x6c3, (q15_t)0x7fa6, (q15_t)0x6b6, (q15_t)0x7fa7, + (q15_t)0x6aa, (q15_t)0x7fa8, (q15_t)0x69d, (q15_t)0x7faa, (q15_t)0x691, + (q15_t)0x7fab, (q15_t)0x684, (q15_t)0x7fac, (q15_t)0x678, (q15_t)0x7fad, + (q15_t)0x66b, (q15_t)0x7faf, (q15_t)0x65f, (q15_t)0x7fb0, (q15_t)0x652, + (q15_t)0x7fb1, (q15_t)0x646, (q15_t)0x7fb2, (q15_t)0x639, (q15_t)0x7fb4, + (q15_t)0x62d, (q15_t)0x7fb5, (q15_t)0x620, (q15_t)0x7fb6, (q15_t)0x614, + (q15_t)0x7fb7, (q15_t)0x607, (q15_t)0x7fb8, (q15_t)0x5fb, (q15_t)0x7fb9, + (q15_t)0x5ee, (q15_t)0x7fbb, (q15_t)0x5e2, (q15_t)0x7fbc, (q15_t)0x5d5, + (q15_t)0x7fbd, (q15_t)0x5c9, (q15_t)0x7fbe, (q15_t)0x5bc, (q15_t)0x7fbf, + (q15_t)0x5b0, (q15_t)0x7fc0, (q15_t)0x5a3, (q15_t)0x7fc1, (q15_t)0x597, + (q15_t)0x7fc3, (q15_t)0x58a, (q15_t)0x7fc4, (q15_t)0x57e, (q15_t)0x7fc5, + (q15_t)0x571, (q15_t)0x7fc6, (q15_t)0x565, (q15_t)0x7fc7, (q15_t)0x558, + (q15_t)0x7fc8, (q15_t)0x54c, (q15_t)0x7fc9, (q15_t)0x53f, (q15_t)0x7fca, + (q15_t)0x533, (q15_t)0x7fcb, (q15_t)0x526, (q15_t)0x7fcc, (q15_t)0x51a, + (q15_t)0x7fcd, (q15_t)0x50d, (q15_t)0x7fce, (q15_t)0x500, (q15_t)0x7fcf, + (q15_t)0x4f4, (q15_t)0x7fd0, (q15_t)0x4e7, (q15_t)0x7fd1, (q15_t)0x4db, + (q15_t)0x7fd2, (q15_t)0x4ce, (q15_t)0x7fd3, (q15_t)0x4c2, (q15_t)0x7fd4, + (q15_t)0x4b5, (q15_t)0x7fd5, (q15_t)0x4a9, (q15_t)0x7fd5, (q15_t)0x49c, + (q15_t)0x7fd6, (q15_t)0x490, (q15_t)0x7fd7, (q15_t)0x483, (q15_t)0x7fd8, + (q15_t)0x477, (q15_t)0x7fd9, (q15_t)0x46a, (q15_t)0x7fda, (q15_t)0x45e, + (q15_t)0x7fdb, (q15_t)0x451, (q15_t)0x7fdc, (q15_t)0x444, (q15_t)0x7fdc, + (q15_t)0x438, (q15_t)0x7fdd, (q15_t)0x42b, (q15_t)0x7fde, (q15_t)0x41f, + (q15_t)0x7fdf, (q15_t)0x412, (q15_t)0x7fe0, (q15_t)0x406, (q15_t)0x7fe0, + (q15_t)0x3f9, (q15_t)0x7fe1, (q15_t)0x3ed, (q15_t)0x7fe2, (q15_t)0x3e0, + (q15_t)0x7fe3, (q15_t)0x3d4, (q15_t)0x7fe3, (q15_t)0x3c7, (q15_t)0x7fe4, + (q15_t)0x3bb, (q15_t)0x7fe5, (q15_t)0x3ae, (q15_t)0x7fe6, (q15_t)0x3a1, + (q15_t)0x7fe6, (q15_t)0x395, (q15_t)0x7fe7, (q15_t)0x388, (q15_t)0x7fe8, + (q15_t)0x37c, (q15_t)0x7fe8, (q15_t)0x36f, (q15_t)0x7fe9, (q15_t)0x363, + (q15_t)0x7fea, (q15_t)0x356, (q15_t)0x7fea, (q15_t)0x34a, (q15_t)0x7feb, + (q15_t)0x33d, (q15_t)0x7fec, (q15_t)0x330, (q15_t)0x7fec, (q15_t)0x324, + (q15_t)0x7fed, (q15_t)0x317, (q15_t)0x7fed, (q15_t)0x30b, (q15_t)0x7fee, + (q15_t)0x2fe, (q15_t)0x7fef, (q15_t)0x2f2, (q15_t)0x7fef, (q15_t)0x2e5, + (q15_t)0x7ff0, (q15_t)0x2d9, (q15_t)0x7ff0, (q15_t)0x2cc, (q15_t)0x7ff1, + (q15_t)0x2c0, (q15_t)0x7ff1, (q15_t)0x2b3, (q15_t)0x7ff2, (q15_t)0x2a6, + (q15_t)0x7ff2, (q15_t)0x29a, (q15_t)0x7ff3, (q15_t)0x28d, (q15_t)0x7ff3, + (q15_t)0x281, (q15_t)0x7ff4, (q15_t)0x274, (q15_t)0x7ff4, (q15_t)0x268, + (q15_t)0x7ff5, (q15_t)0x25b, (q15_t)0x7ff5, (q15_t)0x24e, (q15_t)0x7ff6, + (q15_t)0x242, (q15_t)0x7ff6, (q15_t)0x235, (q15_t)0x7ff7, (q15_t)0x229, + (q15_t)0x7ff7, (q15_t)0x21c, (q15_t)0x7ff7, (q15_t)0x210, (q15_t)0x7ff8, + (q15_t)0x203, (q15_t)0x7ff8, (q15_t)0x1f7, (q15_t)0x7ff9, (q15_t)0x1ea, + (q15_t)0x7ff9, (q15_t)0x1dd, (q15_t)0x7ff9, (q15_t)0x1d1, (q15_t)0x7ffa, + (q15_t)0x1c4, (q15_t)0x7ffa, (q15_t)0x1b8, (q15_t)0x7ffa, (q15_t)0x1ab, + (q15_t)0x7ffb, (q15_t)0x19f, (q15_t)0x7ffb, (q15_t)0x192, (q15_t)0x7ffb, + (q15_t)0x186, (q15_t)0x7ffc, (q15_t)0x179, (q15_t)0x7ffc, (q15_t)0x16c, + (q15_t)0x7ffc, (q15_t)0x160, (q15_t)0x7ffc, (q15_t)0x153, (q15_t)0x7ffd, + (q15_t)0x147, (q15_t)0x7ffd, (q15_t)0x13a, (q15_t)0x7ffd, (q15_t)0x12e, + (q15_t)0x7ffd, (q15_t)0x121, (q15_t)0x7ffe, (q15_t)0x114, (q15_t)0x7ffe, + (q15_t)0x108, (q15_t)0x7ffe, (q15_t)0xfb, (q15_t)0x7ffe, (q15_t)0xef, + (q15_t)0x7ffe, (q15_t)0xe2, (q15_t)0x7fff, (q15_t)0xd6, (q15_t)0x7fff, + (q15_t)0xc9, (q15_t)0x7fff, (q15_t)0xbc, (q15_t)0x7fff, (q15_t)0xb0, + (q15_t)0x7fff, (q15_t)0xa3, (q15_t)0x7fff, (q15_t)0x97, (q15_t)0x7fff, + (q15_t)0x8a, (q15_t)0x7fff, (q15_t)0x7e, (q15_t)0x7fff, (q15_t)0x71, + (q15_t)0x7fff, (q15_t)0x65, (q15_t)0x7fff, (q15_t)0x58, (q15_t)0x7fff, + (q15_t)0x4b, (q15_t)0x7fff, (q15_t)0x3f, (q15_t)0x7fff, (q15_t)0x32, + (q15_t)0x7fff, (q15_t)0x26, (q15_t)0x7fff, (q15_t)0x19, (q15_t)0x7fff, + (q15_t)0xd, (q15_t)0x7fff, (q15_t)0x0, (q15_t)0x7fff, (q15_t)0xfff3, + (q15_t)0x7fff, (q15_t)0xffe7, (q15_t)0x7fff, (q15_t)0xffda, (q15_t)0x7fff, + (q15_t)0xffce, (q15_t)0x7fff, (q15_t)0xffc1, (q15_t)0x7fff, (q15_t)0xffb5, + (q15_t)0x7fff, (q15_t)0xffa8, (q15_t)0x7fff, (q15_t)0xff9b, (q15_t)0x7fff, + (q15_t)0xff8f, (q15_t)0x7fff, (q15_t)0xff82, (q15_t)0x7fff, (q15_t)0xff76, + (q15_t)0x7fff, (q15_t)0xff69, (q15_t)0x7fff, (q15_t)0xff5d, (q15_t)0x7fff, + (q15_t)0xff50, (q15_t)0x7fff, (q15_t)0xff44, (q15_t)0x7fff, (q15_t)0xff37, + (q15_t)0x7fff, (q15_t)0xff2a, (q15_t)0x7ffe, (q15_t)0xff1e, (q15_t)0x7ffe, + (q15_t)0xff11, (q15_t)0x7ffe, (q15_t)0xff05, (q15_t)0x7ffe, (q15_t)0xfef8, + (q15_t)0x7ffe, (q15_t)0xfeec, (q15_t)0x7ffd, (q15_t)0xfedf, (q15_t)0x7ffd, + (q15_t)0xfed2, (q15_t)0x7ffd, (q15_t)0xfec6, (q15_t)0x7ffd, (q15_t)0xfeb9, + (q15_t)0x7ffc, (q15_t)0xfead, (q15_t)0x7ffc, (q15_t)0xfea0, (q15_t)0x7ffc, + (q15_t)0xfe94, (q15_t)0x7ffc, (q15_t)0xfe87, (q15_t)0x7ffb, (q15_t)0xfe7a, + (q15_t)0x7ffb, (q15_t)0xfe6e, (q15_t)0x7ffb, (q15_t)0xfe61, (q15_t)0x7ffa, + (q15_t)0xfe55, (q15_t)0x7ffa, (q15_t)0xfe48, (q15_t)0x7ffa, (q15_t)0xfe3c, + (q15_t)0x7ff9, (q15_t)0xfe2f, (q15_t)0x7ff9, (q15_t)0xfe23, (q15_t)0x7ff9, + (q15_t)0xfe16, (q15_t)0x7ff8, (q15_t)0xfe09, (q15_t)0x7ff8, (q15_t)0xfdfd, + (q15_t)0x7ff7, (q15_t)0xfdf0, (q15_t)0x7ff7, (q15_t)0xfde4, (q15_t)0x7ff7, + (q15_t)0xfdd7, (q15_t)0x7ff6, (q15_t)0xfdcb, (q15_t)0x7ff6, (q15_t)0xfdbe, + (q15_t)0x7ff5, (q15_t)0xfdb2, (q15_t)0x7ff5, (q15_t)0xfda5, (q15_t)0x7ff4, + (q15_t)0xfd98, (q15_t)0x7ff4, (q15_t)0xfd8c, (q15_t)0x7ff3, (q15_t)0xfd7f, + (q15_t)0x7ff3, (q15_t)0xfd73, (q15_t)0x7ff2, (q15_t)0xfd66, (q15_t)0x7ff2, + (q15_t)0xfd5a, (q15_t)0x7ff1, (q15_t)0xfd4d, (q15_t)0x7ff1, (q15_t)0xfd40, + (q15_t)0x7ff0, (q15_t)0xfd34, (q15_t)0x7ff0, (q15_t)0xfd27, (q15_t)0x7fef, + (q15_t)0xfd1b, (q15_t)0x7fef, (q15_t)0xfd0e, (q15_t)0x7fee, (q15_t)0xfd02, + (q15_t)0x7fed, (q15_t)0xfcf5, (q15_t)0x7fed, (q15_t)0xfce9, (q15_t)0x7fec, + (q15_t)0xfcdc, (q15_t)0x7fec, (q15_t)0xfcd0, (q15_t)0x7feb, (q15_t)0xfcc3, + (q15_t)0x7fea, (q15_t)0xfcb6, (q15_t)0x7fea, (q15_t)0xfcaa, (q15_t)0x7fe9, + (q15_t)0xfc9d, (q15_t)0x7fe8, (q15_t)0xfc91, (q15_t)0x7fe8, (q15_t)0xfc84, + (q15_t)0x7fe7, (q15_t)0xfc78, (q15_t)0x7fe6, (q15_t)0xfc6b, (q15_t)0x7fe6, + (q15_t)0xfc5f, (q15_t)0x7fe5, (q15_t)0xfc52, (q15_t)0x7fe4, (q15_t)0xfc45, + (q15_t)0x7fe3, (q15_t)0xfc39, (q15_t)0x7fe3, (q15_t)0xfc2c, (q15_t)0x7fe2, + (q15_t)0xfc20, (q15_t)0x7fe1, (q15_t)0xfc13, (q15_t)0x7fe0, (q15_t)0xfc07, + (q15_t)0x7fe0, (q15_t)0xfbfa, (q15_t)0x7fdf, (q15_t)0xfbee, (q15_t)0x7fde, + (q15_t)0xfbe1, (q15_t)0x7fdd, (q15_t)0xfbd5, (q15_t)0x7fdc, (q15_t)0xfbc8, + (q15_t)0x7fdc, (q15_t)0xfbbc, (q15_t)0x7fdb, (q15_t)0xfbaf, (q15_t)0x7fda, + (q15_t)0xfba2, (q15_t)0x7fd9, (q15_t)0xfb96, (q15_t)0x7fd8, (q15_t)0xfb89, + (q15_t)0x7fd7, (q15_t)0xfb7d, (q15_t)0x7fd6, (q15_t)0xfb70, (q15_t)0x7fd5, + (q15_t)0xfb64, (q15_t)0x7fd5, (q15_t)0xfb57, (q15_t)0x7fd4, (q15_t)0xfb4b, + (q15_t)0x7fd3, (q15_t)0xfb3e, (q15_t)0x7fd2, (q15_t)0xfb32, (q15_t)0x7fd1, + (q15_t)0xfb25, (q15_t)0x7fd0, (q15_t)0xfb19, (q15_t)0x7fcf, (q15_t)0xfb0c, + (q15_t)0x7fce, (q15_t)0xfb00, (q15_t)0x7fcd, (q15_t)0xfaf3, (q15_t)0x7fcc, + (q15_t)0xfae6, (q15_t)0x7fcb, (q15_t)0xfada, (q15_t)0x7fca, (q15_t)0xfacd, + (q15_t)0x7fc9, (q15_t)0xfac1, (q15_t)0x7fc8, (q15_t)0xfab4, (q15_t)0x7fc7, + (q15_t)0xfaa8, (q15_t)0x7fc6, (q15_t)0xfa9b, (q15_t)0x7fc5, (q15_t)0xfa8f, + (q15_t)0x7fc4, (q15_t)0xfa82, (q15_t)0x7fc3, (q15_t)0xfa76, (q15_t)0x7fc1, + (q15_t)0xfa69, (q15_t)0x7fc0, (q15_t)0xfa5d, (q15_t)0x7fbf, (q15_t)0xfa50, + (q15_t)0x7fbe, (q15_t)0xfa44, (q15_t)0x7fbd, (q15_t)0xfa37, (q15_t)0x7fbc, + (q15_t)0xfa2b, (q15_t)0x7fbb, (q15_t)0xfa1e, (q15_t)0x7fb9, (q15_t)0xfa12, + (q15_t)0x7fb8, (q15_t)0xfa05, (q15_t)0x7fb7, (q15_t)0xf9f9, (q15_t)0x7fb6, + (q15_t)0xf9ec, (q15_t)0x7fb5, (q15_t)0xf9e0, (q15_t)0x7fb4, (q15_t)0xf9d3, + (q15_t)0x7fb2, (q15_t)0xf9c7, (q15_t)0x7fb1, (q15_t)0xf9ba, (q15_t)0x7fb0, + (q15_t)0xf9ae, (q15_t)0x7faf, (q15_t)0xf9a1, (q15_t)0x7fad, (q15_t)0xf995, + (q15_t)0x7fac, (q15_t)0xf988, (q15_t)0x7fab, (q15_t)0xf97c, (q15_t)0x7faa, + (q15_t)0xf96f, (q15_t)0x7fa8, (q15_t)0xf963, (q15_t)0x7fa7, (q15_t)0xf956, + (q15_t)0x7fa6, (q15_t)0xf94a, (q15_t)0x7fa4, (q15_t)0xf93d, (q15_t)0x7fa3, + (q15_t)0xf931, (q15_t)0x7fa2, (q15_t)0xf924, (q15_t)0x7fa0, (q15_t)0xf918, + (q15_t)0x7f9f, (q15_t)0xf90b, (q15_t)0x7f9e, (q15_t)0xf8ff, (q15_t)0x7f9c, + (q15_t)0xf8f2, (q15_t)0x7f9b, (q15_t)0xf8e6, (q15_t)0x7f99, (q15_t)0xf8d9, + (q15_t)0x7f98, (q15_t)0xf8cd, (q15_t)0x7f97, (q15_t)0xf8c0, (q15_t)0x7f95, + (q15_t)0xf8b4, (q15_t)0x7f94, (q15_t)0xf8a7, (q15_t)0x7f92, (q15_t)0xf89b, + (q15_t)0x7f91, (q15_t)0xf88e, (q15_t)0x7f8f, (q15_t)0xf882, (q15_t)0x7f8e, + (q15_t)0xf875, (q15_t)0x7f8c, (q15_t)0xf869, (q15_t)0x7f8b, (q15_t)0xf85c, + (q15_t)0x7f89, (q15_t)0xf850, (q15_t)0x7f88, (q15_t)0xf843, (q15_t)0x7f86, + (q15_t)0xf837, (q15_t)0x7f85, (q15_t)0xf82a, (q15_t)0x7f83, (q15_t)0xf81e, + (q15_t)0x7f82, (q15_t)0xf811, (q15_t)0x7f80, (q15_t)0xf805, (q15_t)0x7f7f, + (q15_t)0xf7f9, (q15_t)0x7f7d, (q15_t)0xf7ec, (q15_t)0x7f7b, (q15_t)0xf7e0, + (q15_t)0x7f7a, (q15_t)0xf7d3, (q15_t)0x7f78, (q15_t)0xf7c7, (q15_t)0x7f77, + (q15_t)0xf7ba, (q15_t)0x7f75, (q15_t)0xf7ae, (q15_t)0x7f73, (q15_t)0xf7a1, + (q15_t)0x7f72, (q15_t)0xf795, (q15_t)0x7f70, (q15_t)0xf788, (q15_t)0x7f6e, + (q15_t)0xf77c, (q15_t)0x7f6d, (q15_t)0xf76f, (q15_t)0x7f6b, (q15_t)0xf763, + (q15_t)0x7f69, (q15_t)0xf757, (q15_t)0x7f68, (q15_t)0xf74a, (q15_t)0x7f66, + (q15_t)0xf73e, (q15_t)0x7f64, (q15_t)0xf731, (q15_t)0x7f62, (q15_t)0xf725, + (q15_t)0x7f61, (q15_t)0xf718, (q15_t)0x7f5f, (q15_t)0xf70c, (q15_t)0x7f5d, + (q15_t)0xf6ff, (q15_t)0x7f5b, (q15_t)0xf6f3, (q15_t)0x7f5a, (q15_t)0xf6e7, + (q15_t)0x7f58, (q15_t)0xf6da, (q15_t)0x7f56, (q15_t)0xf6ce, (q15_t)0x7f54, + (q15_t)0xf6c1, (q15_t)0x7f52, (q15_t)0xf6b5, (q15_t)0x7f51, (q15_t)0xf6a8, + (q15_t)0x7f4f, (q15_t)0xf69c, (q15_t)0x7f4d, (q15_t)0xf690, (q15_t)0x7f4b, + (q15_t)0xf683, (q15_t)0x7f49, (q15_t)0xf677, (q15_t)0x7f47, (q15_t)0xf66a, + (q15_t)0x7f45, (q15_t)0xf65e, (q15_t)0x7f43, (q15_t)0xf651, (q15_t)0x7f42, + (q15_t)0xf645, (q15_t)0x7f40, (q15_t)0xf639, (q15_t)0x7f3e, (q15_t)0xf62c, + (q15_t)0x7f3c, (q15_t)0xf620, (q15_t)0x7f3a, (q15_t)0xf613, (q15_t)0x7f38, + (q15_t)0xf607, (q15_t)0x7f36, (q15_t)0xf5fa, (q15_t)0x7f34, (q15_t)0xf5ee, + (q15_t)0x7f32, (q15_t)0xf5e2, (q15_t)0x7f30, (q15_t)0xf5d5, (q15_t)0x7f2e, + (q15_t)0xf5c9, (q15_t)0x7f2c, (q15_t)0xf5bc, (q15_t)0x7f2a, (q15_t)0xf5b0, + (q15_t)0x7f28, (q15_t)0xf5a4, (q15_t)0x7f26, (q15_t)0xf597, (q15_t)0x7f24, + (q15_t)0xf58b, (q15_t)0x7f22, (q15_t)0xf57e, (q15_t)0x7f20, (q15_t)0xf572, + (q15_t)0x7f1e, (q15_t)0xf566, (q15_t)0x7f1c, (q15_t)0xf559, (q15_t)0x7f19, + (q15_t)0xf54d, (q15_t)0x7f17, (q15_t)0xf540, (q15_t)0x7f15, (q15_t)0xf534, + (q15_t)0x7f13, (q15_t)0xf528, (q15_t)0x7f11, (q15_t)0xf51b, (q15_t)0x7f0f, + (q15_t)0xf50f, (q15_t)0x7f0d, (q15_t)0xf503, (q15_t)0x7f0a, (q15_t)0xf4f6, + (q15_t)0x7f08, (q15_t)0xf4ea, (q15_t)0x7f06, (q15_t)0xf4dd, (q15_t)0x7f04, + (q15_t)0xf4d1, (q15_t)0x7f02, (q15_t)0xf4c5, (q15_t)0x7f00, (q15_t)0xf4b8, + (q15_t)0x7efd, (q15_t)0xf4ac, (q15_t)0x7efb, (q15_t)0xf4a0, (q15_t)0x7ef9, + (q15_t)0xf493, (q15_t)0x7ef7, (q15_t)0xf487, (q15_t)0x7ef4, (q15_t)0xf47b, + (q15_t)0x7ef2, (q15_t)0xf46e, (q15_t)0x7ef0, (q15_t)0xf462, (q15_t)0x7eed, + (q15_t)0xf455, (q15_t)0x7eeb, (q15_t)0xf449, (q15_t)0x7ee9, (q15_t)0xf43d, + (q15_t)0x7ee7, (q15_t)0xf430, (q15_t)0x7ee4, (q15_t)0xf424, (q15_t)0x7ee2, + (q15_t)0xf418, (q15_t)0x7ee0, (q15_t)0xf40b, (q15_t)0x7edd, (q15_t)0xf3ff, + (q15_t)0x7edb, (q15_t)0xf3f3, (q15_t)0x7ed8, (q15_t)0xf3e6, (q15_t)0x7ed6, + (q15_t)0xf3da, (q15_t)0x7ed4, (q15_t)0xf3ce, (q15_t)0x7ed1, (q15_t)0xf3c1, + (q15_t)0x7ecf, (q15_t)0xf3b5, (q15_t)0x7ecc, (q15_t)0xf3a9, (q15_t)0x7eca, + (q15_t)0xf39c, (q15_t)0x7ec8, (q15_t)0xf390, (q15_t)0x7ec5, (q15_t)0xf384, + (q15_t)0x7ec3, (q15_t)0xf377, (q15_t)0x7ec0, (q15_t)0xf36b, (q15_t)0x7ebe, + (q15_t)0xf35f, (q15_t)0x7ebb, (q15_t)0xf352, (q15_t)0x7eb9, (q15_t)0xf346, + (q15_t)0x7eb6, (q15_t)0xf33a, (q15_t)0x7eb4, (q15_t)0xf32d, (q15_t)0x7eb1, + (q15_t)0xf321, (q15_t)0x7eaf, (q15_t)0xf315, (q15_t)0x7eac, (q15_t)0xf308, + (q15_t)0x7eaa, (q15_t)0xf2fc, (q15_t)0x7ea7, (q15_t)0xf2f0, (q15_t)0x7ea5, + (q15_t)0xf2e4, (q15_t)0x7ea2, (q15_t)0xf2d7, (q15_t)0x7e9f, (q15_t)0xf2cb, + (q15_t)0x7e9d, (q15_t)0xf2bf, (q15_t)0x7e9a, (q15_t)0xf2b2, (q15_t)0x7e98, + (q15_t)0xf2a6, (q15_t)0x7e95, (q15_t)0xf29a, (q15_t)0x7e92, (q15_t)0xf28e, + (q15_t)0x7e90, (q15_t)0xf281, (q15_t)0x7e8d, (q15_t)0xf275, (q15_t)0x7e8a, + (q15_t)0xf269, (q15_t)0x7e88, (q15_t)0xf25c, (q15_t)0x7e85, (q15_t)0xf250, + (q15_t)0x7e82, (q15_t)0xf244, (q15_t)0x7e80, (q15_t)0xf238, (q15_t)0x7e7d, + (q15_t)0xf22b, (q15_t)0x7e7a, (q15_t)0xf21f, (q15_t)0x7e77, (q15_t)0xf213, + (q15_t)0x7e75, (q15_t)0xf207, (q15_t)0x7e72, (q15_t)0xf1fa, (q15_t)0x7e6f, + (q15_t)0xf1ee, (q15_t)0x7e6c, (q15_t)0xf1e2, (q15_t)0x7e6a, (q15_t)0xf1d5, + (q15_t)0x7e67, (q15_t)0xf1c9, (q15_t)0x7e64, (q15_t)0xf1bd, (q15_t)0x7e61, + (q15_t)0xf1b1, (q15_t)0x7e5e, (q15_t)0xf1a4, (q15_t)0x7e5c, (q15_t)0xf198, + (q15_t)0x7e59, (q15_t)0xf18c, (q15_t)0x7e56, (q15_t)0xf180, (q15_t)0x7e53, + (q15_t)0xf174, (q15_t)0x7e50, (q15_t)0xf167, (q15_t)0x7e4d, (q15_t)0xf15b, + (q15_t)0x7e4a, (q15_t)0xf14f, (q15_t)0x7e48, (q15_t)0xf143, (q15_t)0x7e45, + (q15_t)0xf136, (q15_t)0x7e42, (q15_t)0xf12a, (q15_t)0x7e3f, (q15_t)0xf11e, + (q15_t)0x7e3c, (q15_t)0xf112, (q15_t)0x7e39, (q15_t)0xf105, (q15_t)0x7e36, + (q15_t)0xf0f9, (q15_t)0x7e33, (q15_t)0xf0ed, (q15_t)0x7e30, (q15_t)0xf0e1, + (q15_t)0x7e2d, (q15_t)0xf0d5, (q15_t)0x7e2a, (q15_t)0xf0c8, (q15_t)0x7e27, + (q15_t)0xf0bc, (q15_t)0x7e24, (q15_t)0xf0b0, (q15_t)0x7e21, (q15_t)0xf0a4, + (q15_t)0x7e1e, (q15_t)0xf098, (q15_t)0x7e1b, (q15_t)0xf08b, (q15_t)0x7e18, + (q15_t)0xf07f, (q15_t)0x7e15, (q15_t)0xf073, (q15_t)0x7e12, (q15_t)0xf067, + (q15_t)0x7e0f, (q15_t)0xf05b, (q15_t)0x7e0c, (q15_t)0xf04e, (q15_t)0x7e09, + (q15_t)0xf042, (q15_t)0x7e06, (q15_t)0xf036, (q15_t)0x7e03, (q15_t)0xf02a, + (q15_t)0x7dff, (q15_t)0xf01e, (q15_t)0x7dfc, (q15_t)0xf012, (q15_t)0x7df9, + (q15_t)0xf005, (q15_t)0x7df6, (q15_t)0xeff9, (q15_t)0x7df3, (q15_t)0xefed, + (q15_t)0x7df0, (q15_t)0xefe1, (q15_t)0x7ded, (q15_t)0xefd5, (q15_t)0x7de9, + (q15_t)0xefc9, (q15_t)0x7de6, (q15_t)0xefbc, (q15_t)0x7de3, (q15_t)0xefb0, + (q15_t)0x7de0, (q15_t)0xefa4, (q15_t)0x7ddd, (q15_t)0xef98, (q15_t)0x7dd9, + (q15_t)0xef8c, (q15_t)0x7dd6, (q15_t)0xef80, (q15_t)0x7dd3, (q15_t)0xef74, + (q15_t)0x7dd0, (q15_t)0xef67, (q15_t)0x7dcc, (q15_t)0xef5b, (q15_t)0x7dc9, + (q15_t)0xef4f, (q15_t)0x7dc6, (q15_t)0xef43, (q15_t)0x7dc2, (q15_t)0xef37, + (q15_t)0x7dbf, (q15_t)0xef2b, (q15_t)0x7dbc, (q15_t)0xef1f, (q15_t)0x7db9, + (q15_t)0xef13, (q15_t)0x7db5, (q15_t)0xef06, (q15_t)0x7db2, (q15_t)0xeefa, + (q15_t)0x7daf, (q15_t)0xeeee, (q15_t)0x7dab, (q15_t)0xeee2, (q15_t)0x7da8, + (q15_t)0xeed6, (q15_t)0x7da4, (q15_t)0xeeca, (q15_t)0x7da1, (q15_t)0xeebe, + (q15_t)0x7d9e, (q15_t)0xeeb2, (q15_t)0x7d9a, (q15_t)0xeea6, (q15_t)0x7d97, + (q15_t)0xee99, (q15_t)0x7d93, (q15_t)0xee8d, (q15_t)0x7d90, (q15_t)0xee81, + (q15_t)0x7d8d, (q15_t)0xee75, (q15_t)0x7d89, (q15_t)0xee69, (q15_t)0x7d86, + (q15_t)0xee5d, (q15_t)0x7d82, (q15_t)0xee51, (q15_t)0x7d7f, (q15_t)0xee45, + (q15_t)0x7d7b, (q15_t)0xee39, (q15_t)0x7d78, (q15_t)0xee2d, (q15_t)0x7d74, + (q15_t)0xee21, (q15_t)0x7d71, (q15_t)0xee15, (q15_t)0x7d6d, (q15_t)0xee09, + (q15_t)0x7d6a, (q15_t)0xedfc, (q15_t)0x7d66, (q15_t)0xedf0, (q15_t)0x7d63, + (q15_t)0xede4, (q15_t)0x7d5f, (q15_t)0xedd8, (q15_t)0x7d5b, (q15_t)0xedcc, + (q15_t)0x7d58, (q15_t)0xedc0, (q15_t)0x7d54, (q15_t)0xedb4, (q15_t)0x7d51, + (q15_t)0xeda8, (q15_t)0x7d4d, (q15_t)0xed9c, (q15_t)0x7d49, (q15_t)0xed90, + (q15_t)0x7d46, (q15_t)0xed84, (q15_t)0x7d42, (q15_t)0xed78, (q15_t)0x7d3f, + (q15_t)0xed6c, (q15_t)0x7d3b, (q15_t)0xed60, (q15_t)0x7d37, (q15_t)0xed54, + (q15_t)0x7d34, (q15_t)0xed48, (q15_t)0x7d30, (q15_t)0xed3c, (q15_t)0x7d2c, + (q15_t)0xed30, (q15_t)0x7d28, (q15_t)0xed24, (q15_t)0x7d25, (q15_t)0xed18, + (q15_t)0x7d21, (q15_t)0xed0c, (q15_t)0x7d1d, (q15_t)0xed00, (q15_t)0x7d1a, + (q15_t)0xecf4, (q15_t)0x7d16, (q15_t)0xece8, (q15_t)0x7d12, (q15_t)0xecdc, + (q15_t)0x7d0e, (q15_t)0xecd0, (q15_t)0x7d0b, (q15_t)0xecc4, (q15_t)0x7d07, + (q15_t)0xecb8, (q15_t)0x7d03, (q15_t)0xecac, (q15_t)0x7cff, (q15_t)0xeca0, + (q15_t)0x7cfb, (q15_t)0xec94, (q15_t)0x7cf8, (q15_t)0xec88, (q15_t)0x7cf4, + (q15_t)0xec7c, (q15_t)0x7cf0, (q15_t)0xec70, (q15_t)0x7cec, (q15_t)0xec64, + (q15_t)0x7ce8, (q15_t)0xec58, (q15_t)0x7ce4, (q15_t)0xec4c, (q15_t)0x7ce0, + (q15_t)0xec40, (q15_t)0x7cdd, (q15_t)0xec34, (q15_t)0x7cd9, (q15_t)0xec28, + (q15_t)0x7cd5, (q15_t)0xec1c, (q15_t)0x7cd1, (q15_t)0xec10, (q15_t)0x7ccd, + (q15_t)0xec05, (q15_t)0x7cc9, (q15_t)0xebf9, (q15_t)0x7cc5, (q15_t)0xebed, + (q15_t)0x7cc1, (q15_t)0xebe1, (q15_t)0x7cbd, (q15_t)0xebd5, (q15_t)0x7cb9, + (q15_t)0xebc9, (q15_t)0x7cb5, (q15_t)0xebbd, (q15_t)0x7cb1, (q15_t)0xebb1, + (q15_t)0x7cad, (q15_t)0xeba5, (q15_t)0x7ca9, (q15_t)0xeb99, (q15_t)0x7ca5, + (q15_t)0xeb8d, (q15_t)0x7ca1, (q15_t)0xeb81, (q15_t)0x7c9d, (q15_t)0xeb75, + (q15_t)0x7c99, (q15_t)0xeb6a, (q15_t)0x7c95, (q15_t)0xeb5e, (q15_t)0x7c91, + (q15_t)0xeb52, (q15_t)0x7c8d, (q15_t)0xeb46, (q15_t)0x7c89, (q15_t)0xeb3a, + (q15_t)0x7c85, (q15_t)0xeb2e, (q15_t)0x7c81, (q15_t)0xeb22, (q15_t)0x7c7d, + (q15_t)0xeb16, (q15_t)0x7c79, (q15_t)0xeb0a, (q15_t)0x7c74, (q15_t)0xeaff, + (q15_t)0x7c70, (q15_t)0xeaf3, (q15_t)0x7c6c, (q15_t)0xeae7, (q15_t)0x7c68, + (q15_t)0xeadb, (q15_t)0x7c64, (q15_t)0xeacf, (q15_t)0x7c60, (q15_t)0xeac3, + (q15_t)0x7c5b, (q15_t)0xeab7, (q15_t)0x7c57, (q15_t)0xeaac, (q15_t)0x7c53, + (q15_t)0xeaa0, (q15_t)0x7c4f, (q15_t)0xea94, (q15_t)0x7c4b, (q15_t)0xea88, + (q15_t)0x7c46, (q15_t)0xea7c, (q15_t)0x7c42, (q15_t)0xea70, (q15_t)0x7c3e, + (q15_t)0xea65, (q15_t)0x7c3a, (q15_t)0xea59, (q15_t)0x7c36, (q15_t)0xea4d, + (q15_t)0x7c31, (q15_t)0xea41, (q15_t)0x7c2d, (q15_t)0xea35, (q15_t)0x7c29, + (q15_t)0xea29, (q15_t)0x7c24, (q15_t)0xea1e, (q15_t)0x7c20, (q15_t)0xea12, + (q15_t)0x7c1c, (q15_t)0xea06, (q15_t)0x7c17, (q15_t)0xe9fa, (q15_t)0x7c13, + (q15_t)0xe9ee, (q15_t)0x7c0f, (q15_t)0xe9e3, (q15_t)0x7c0a, (q15_t)0xe9d7, + (q15_t)0x7c06, (q15_t)0xe9cb, (q15_t)0x7c02, (q15_t)0xe9bf, (q15_t)0x7bfd, + (q15_t)0xe9b4, (q15_t)0x7bf9, (q15_t)0xe9a8, (q15_t)0x7bf5, (q15_t)0xe99c, + (q15_t)0x7bf0, (q15_t)0xe990, (q15_t)0x7bec, (q15_t)0xe984, (q15_t)0x7be7, + (q15_t)0xe979, (q15_t)0x7be3, (q15_t)0xe96d, (q15_t)0x7bde, (q15_t)0xe961, + (q15_t)0x7bda, (q15_t)0xe955, (q15_t)0x7bd6, (q15_t)0xe94a, (q15_t)0x7bd1, + (q15_t)0xe93e, (q15_t)0x7bcd, (q15_t)0xe932, (q15_t)0x7bc8, (q15_t)0xe926, + (q15_t)0x7bc4, (q15_t)0xe91b, (q15_t)0x7bbf, (q15_t)0xe90f, (q15_t)0x7bbb, + (q15_t)0xe903, (q15_t)0x7bb6, (q15_t)0xe8f7, (q15_t)0x7bb2, (q15_t)0xe8ec, + (q15_t)0x7bad, (q15_t)0xe8e0, (q15_t)0x7ba9, (q15_t)0xe8d4, (q15_t)0x7ba4, + (q15_t)0xe8c9, (q15_t)0x7b9f, (q15_t)0xe8bd, (q15_t)0x7b9b, (q15_t)0xe8b1, + (q15_t)0x7b96, (q15_t)0xe8a5, (q15_t)0x7b92, (q15_t)0xe89a, (q15_t)0x7b8d, + (q15_t)0xe88e, (q15_t)0x7b88, (q15_t)0xe882, (q15_t)0x7b84, (q15_t)0xe877, + (q15_t)0x7b7f, (q15_t)0xe86b, (q15_t)0x7b7b, (q15_t)0xe85f, (q15_t)0x7b76, + (q15_t)0xe854, (q15_t)0x7b71, (q15_t)0xe848, (q15_t)0x7b6d, (q15_t)0xe83c, + (q15_t)0x7b68, (q15_t)0xe831, (q15_t)0x7b63, (q15_t)0xe825, (q15_t)0x7b5f, + (q15_t)0xe819, (q15_t)0x7b5a, (q15_t)0xe80e, (q15_t)0x7b55, (q15_t)0xe802, + (q15_t)0x7b50, (q15_t)0xe7f6, (q15_t)0x7b4c, (q15_t)0xe7eb, (q15_t)0x7b47, + (q15_t)0xe7df, (q15_t)0x7b42, (q15_t)0xe7d3, (q15_t)0x7b3e, (q15_t)0xe7c8, + (q15_t)0x7b39, (q15_t)0xe7bc, (q15_t)0x7b34, (q15_t)0xe7b1, (q15_t)0x7b2f, + (q15_t)0xe7a5, (q15_t)0x7b2a, (q15_t)0xe799, (q15_t)0x7b26, (q15_t)0xe78e, + (q15_t)0x7b21, (q15_t)0xe782, (q15_t)0x7b1c, (q15_t)0xe777, (q15_t)0x7b17, + (q15_t)0xe76b, (q15_t)0x7b12, (q15_t)0xe75f, (q15_t)0x7b0e, (q15_t)0xe754, + (q15_t)0x7b09, (q15_t)0xe748, (q15_t)0x7b04, (q15_t)0xe73d, (q15_t)0x7aff, + (q15_t)0xe731, (q15_t)0x7afa, (q15_t)0xe725, (q15_t)0x7af5, (q15_t)0xe71a, + (q15_t)0x7af0, (q15_t)0xe70e, (q15_t)0x7aeb, (q15_t)0xe703, (q15_t)0x7ae6, + (q15_t)0xe6f7, (q15_t)0x7ae2, (q15_t)0xe6ec, (q15_t)0x7add, (q15_t)0xe6e0, + (q15_t)0x7ad8, (q15_t)0xe6d4, (q15_t)0x7ad3, (q15_t)0xe6c9, (q15_t)0x7ace, + (q15_t)0xe6bd, (q15_t)0x7ac9, (q15_t)0xe6b2, (q15_t)0x7ac4, (q15_t)0xe6a6, + (q15_t)0x7abf, (q15_t)0xe69b, (q15_t)0x7aba, (q15_t)0xe68f, (q15_t)0x7ab5, + (q15_t)0xe684, (q15_t)0x7ab0, (q15_t)0xe678, (q15_t)0x7aab, (q15_t)0xe66d, + (q15_t)0x7aa6, (q15_t)0xe661, (q15_t)0x7aa1, (q15_t)0xe656, (q15_t)0x7a9c, + (q15_t)0xe64a, (q15_t)0x7a97, (q15_t)0xe63f, (q15_t)0x7a92, (q15_t)0xe633, + (q15_t)0x7a8d, (q15_t)0xe628, (q15_t)0x7a88, (q15_t)0xe61c, (q15_t)0x7a82, + (q15_t)0xe611, (q15_t)0x7a7d, (q15_t)0xe605, (q15_t)0x7a78, (q15_t)0xe5fa, + (q15_t)0x7a73, (q15_t)0xe5ee, (q15_t)0x7a6e, (q15_t)0xe5e3, (q15_t)0x7a69, + (q15_t)0xe5d7, (q15_t)0x7a64, (q15_t)0xe5cc, (q15_t)0x7a5f, (q15_t)0xe5c0, + (q15_t)0x7a59, (q15_t)0xe5b5, (q15_t)0x7a54, (q15_t)0xe5a9, (q15_t)0x7a4f, + (q15_t)0xe59e, (q15_t)0x7a4a, (q15_t)0xe592, (q15_t)0x7a45, (q15_t)0xe587, + (q15_t)0x7a3f, (q15_t)0xe57c, (q15_t)0x7a3a, (q15_t)0xe570, (q15_t)0x7a35, + (q15_t)0xe565, (q15_t)0x7a30, (q15_t)0xe559, (q15_t)0x7a2b, (q15_t)0xe54e, + (q15_t)0x7a25, (q15_t)0xe542, (q15_t)0x7a20, (q15_t)0xe537, (q15_t)0x7a1b, + (q15_t)0xe52c, (q15_t)0x7a16, (q15_t)0xe520, (q15_t)0x7a10, (q15_t)0xe515, + (q15_t)0x7a0b, (q15_t)0xe509, (q15_t)0x7a06, (q15_t)0xe4fe, (q15_t)0x7a00, + (q15_t)0xe4f3, (q15_t)0x79fb, (q15_t)0xe4e7, (q15_t)0x79f6, (q15_t)0xe4dc, + (q15_t)0x79f0, (q15_t)0xe4d0, (q15_t)0x79eb, (q15_t)0xe4c5, (q15_t)0x79e6, + (q15_t)0xe4ba, (q15_t)0x79e0, (q15_t)0xe4ae, (q15_t)0x79db, (q15_t)0xe4a3, + (q15_t)0x79d6, (q15_t)0xe498, (q15_t)0x79d0, (q15_t)0xe48c, (q15_t)0x79cb, + (q15_t)0xe481, (q15_t)0x79c5, (q15_t)0xe476, (q15_t)0x79c0, (q15_t)0xe46a, + (q15_t)0x79bb, (q15_t)0xe45f, (q15_t)0x79b5, (q15_t)0xe454, (q15_t)0x79b0, + (q15_t)0xe448, (q15_t)0x79aa, (q15_t)0xe43d, (q15_t)0x79a5, (q15_t)0xe432, + (q15_t)0x799f, (q15_t)0xe426, (q15_t)0x799a, (q15_t)0xe41b, (q15_t)0x7994, + (q15_t)0xe410, (q15_t)0x798f, (q15_t)0xe404, (q15_t)0x7989, (q15_t)0xe3f9, + (q15_t)0x7984, (q15_t)0xe3ee, (q15_t)0x797e, (q15_t)0xe3e2, (q15_t)0x7979, + (q15_t)0xe3d7, (q15_t)0x7973, (q15_t)0xe3cc, (q15_t)0x796e, (q15_t)0xe3c1, + (q15_t)0x7968, (q15_t)0xe3b5, (q15_t)0x7963, (q15_t)0xe3aa, (q15_t)0x795d, + (q15_t)0xe39f, (q15_t)0x7958, (q15_t)0xe394, (q15_t)0x7952, (q15_t)0xe388, + (q15_t)0x794c, (q15_t)0xe37d, (q15_t)0x7947, (q15_t)0xe372, (q15_t)0x7941, + (q15_t)0xe367, (q15_t)0x793b, (q15_t)0xe35b, (q15_t)0x7936, (q15_t)0xe350, + (q15_t)0x7930, (q15_t)0xe345, (q15_t)0x792b, (q15_t)0xe33a, (q15_t)0x7925, + (q15_t)0xe32e, (q15_t)0x791f, (q15_t)0xe323, (q15_t)0x791a, (q15_t)0xe318, + (q15_t)0x7914, (q15_t)0xe30d, (q15_t)0x790e, (q15_t)0xe301, (q15_t)0x7909, + (q15_t)0xe2f6, (q15_t)0x7903, (q15_t)0xe2eb, (q15_t)0x78fd, (q15_t)0xe2e0, + (q15_t)0x78f7, (q15_t)0xe2d5, (q15_t)0x78f2, (q15_t)0xe2ca, (q15_t)0x78ec, + (q15_t)0xe2be, (q15_t)0x78e6, (q15_t)0xe2b3, (q15_t)0x78e0, (q15_t)0xe2a8, + (q15_t)0x78db, (q15_t)0xe29d, (q15_t)0x78d5, (q15_t)0xe292, (q15_t)0x78cf, + (q15_t)0xe287, (q15_t)0x78c9, (q15_t)0xe27b, (q15_t)0x78c3, (q15_t)0xe270, + (q15_t)0x78be, (q15_t)0xe265, (q15_t)0x78b8, (q15_t)0xe25a, (q15_t)0x78b2, + (q15_t)0xe24f, (q15_t)0x78ac, (q15_t)0xe244, (q15_t)0x78a6, (q15_t)0xe239, + (q15_t)0x78a1, (q15_t)0xe22d, (q15_t)0x789b, (q15_t)0xe222, (q15_t)0x7895, + (q15_t)0xe217, (q15_t)0x788f, (q15_t)0xe20c, (q15_t)0x7889, (q15_t)0xe201, + (q15_t)0x7883, (q15_t)0xe1f6, (q15_t)0x787d, (q15_t)0xe1eb, (q15_t)0x7877, + (q15_t)0xe1e0, (q15_t)0x7871, (q15_t)0xe1d5, (q15_t)0x786b, (q15_t)0xe1ca, + (q15_t)0x7866, (q15_t)0xe1be, (q15_t)0x7860, (q15_t)0xe1b3, (q15_t)0x785a, + (q15_t)0xe1a8, (q15_t)0x7854, (q15_t)0xe19d, (q15_t)0x784e, (q15_t)0xe192, + (q15_t)0x7848, (q15_t)0xe187, (q15_t)0x7842, (q15_t)0xe17c, (q15_t)0x783c, + (q15_t)0xe171, (q15_t)0x7836, (q15_t)0xe166, (q15_t)0x7830, (q15_t)0xe15b, + (q15_t)0x782a, (q15_t)0xe150, (q15_t)0x7824, (q15_t)0xe145, (q15_t)0x781e, + (q15_t)0xe13a, (q15_t)0x7818, (q15_t)0xe12f, (q15_t)0x7812, (q15_t)0xe124, + (q15_t)0x780b, (q15_t)0xe119, (q15_t)0x7805, (q15_t)0xe10e, (q15_t)0x77ff, + (q15_t)0xe103, (q15_t)0x77f9, (q15_t)0xe0f8, (q15_t)0x77f3, (q15_t)0xe0ed, + (q15_t)0x77ed, (q15_t)0xe0e2, (q15_t)0x77e7, (q15_t)0xe0d7, (q15_t)0x77e1, + (q15_t)0xe0cc, (q15_t)0x77db, (q15_t)0xe0c1, (q15_t)0x77d5, (q15_t)0xe0b6, + (q15_t)0x77ce, (q15_t)0xe0ab, (q15_t)0x77c8, (q15_t)0xe0a0, (q15_t)0x77c2, + (q15_t)0xe095, (q15_t)0x77bc, (q15_t)0xe08a, (q15_t)0x77b6, (q15_t)0xe07f, + (q15_t)0x77b0, (q15_t)0xe074, (q15_t)0x77a9, (q15_t)0xe069, (q15_t)0x77a3, + (q15_t)0xe05e, (q15_t)0x779d, (q15_t)0xe054, (q15_t)0x7797, (q15_t)0xe049, + (q15_t)0x7790, (q15_t)0xe03e, (q15_t)0x778a, (q15_t)0xe033, (q15_t)0x7784, + (q15_t)0xe028, (q15_t)0x777e, (q15_t)0xe01d, (q15_t)0x7777, (q15_t)0xe012, + (q15_t)0x7771, (q15_t)0xe007, (q15_t)0x776b, (q15_t)0xdffc, (q15_t)0x7765, + (q15_t)0xdff1, (q15_t)0x775e, (q15_t)0xdfe7, (q15_t)0x7758, (q15_t)0xdfdc, + (q15_t)0x7752, (q15_t)0xdfd1, (q15_t)0x774b, (q15_t)0xdfc6, (q15_t)0x7745, + (q15_t)0xdfbb, (q15_t)0x773f, (q15_t)0xdfb0, (q15_t)0x7738, (q15_t)0xdfa5, + (q15_t)0x7732, (q15_t)0xdf9b, (q15_t)0x772c, (q15_t)0xdf90, (q15_t)0x7725, + (q15_t)0xdf85, (q15_t)0x771f, (q15_t)0xdf7a, (q15_t)0x7718, (q15_t)0xdf6f, + (q15_t)0x7712, (q15_t)0xdf65, (q15_t)0x770c, (q15_t)0xdf5a, (q15_t)0x7705, + (q15_t)0xdf4f, (q15_t)0x76ff, (q15_t)0xdf44, (q15_t)0x76f8, (q15_t)0xdf39, + (q15_t)0x76f2, (q15_t)0xdf2f, (q15_t)0x76eb, (q15_t)0xdf24, (q15_t)0x76e5, + (q15_t)0xdf19, (q15_t)0x76df, (q15_t)0xdf0e, (q15_t)0x76d8, (q15_t)0xdf03, + (q15_t)0x76d2, (q15_t)0xdef9, (q15_t)0x76cb, (q15_t)0xdeee, (q15_t)0x76c5, + (q15_t)0xdee3, (q15_t)0x76be, (q15_t)0xded8, (q15_t)0x76b8, (q15_t)0xdece, + (q15_t)0x76b1, (q15_t)0xdec3, (q15_t)0x76ab, (q15_t)0xdeb8, (q15_t)0x76a4, + (q15_t)0xdead, (q15_t)0x769d, (q15_t)0xdea3, (q15_t)0x7697, (q15_t)0xde98, + (q15_t)0x7690, (q15_t)0xde8d, (q15_t)0x768a, (q15_t)0xde83, (q15_t)0x7683, + (q15_t)0xde78, (q15_t)0x767d, (q15_t)0xde6d, (q15_t)0x7676, (q15_t)0xde62, + (q15_t)0x766f, (q15_t)0xde58, (q15_t)0x7669, (q15_t)0xde4d, (q15_t)0x7662, + (q15_t)0xde42, (q15_t)0x765c, (q15_t)0xde38, (q15_t)0x7655, (q15_t)0xde2d, + (q15_t)0x764e, (q15_t)0xde22, (q15_t)0x7648, (q15_t)0xde18, (q15_t)0x7641, + (q15_t)0xde0d, (q15_t)0x763a, (q15_t)0xde02, (q15_t)0x7634, (q15_t)0xddf8, + (q15_t)0x762d, (q15_t)0xdded, (q15_t)0x7626, (q15_t)0xdde2, (q15_t)0x7620, + (q15_t)0xddd8, (q15_t)0x7619, (q15_t)0xddcd, (q15_t)0x7612, (q15_t)0xddc3, + (q15_t)0x760b, (q15_t)0xddb8, (q15_t)0x7605, (q15_t)0xddad, (q15_t)0x75fe, + (q15_t)0xdda3, (q15_t)0x75f7, (q15_t)0xdd98, (q15_t)0x75f0, (q15_t)0xdd8e, + (q15_t)0x75ea, (q15_t)0xdd83, (q15_t)0x75e3, (q15_t)0xdd78, (q15_t)0x75dc, + (q15_t)0xdd6e, (q15_t)0x75d5, (q15_t)0xdd63, (q15_t)0x75ce, (q15_t)0xdd59, + (q15_t)0x75c8, (q15_t)0xdd4e, (q15_t)0x75c1, (q15_t)0xdd44, (q15_t)0x75ba, + (q15_t)0xdd39, (q15_t)0x75b3, (q15_t)0xdd2e, (q15_t)0x75ac, (q15_t)0xdd24, + (q15_t)0x75a5, (q15_t)0xdd19, (q15_t)0x759f, (q15_t)0xdd0f, (q15_t)0x7598, + (q15_t)0xdd04, (q15_t)0x7591, (q15_t)0xdcfa, (q15_t)0x758a, (q15_t)0xdcef, + (q15_t)0x7583, (q15_t)0xdce5, (q15_t)0x757c, (q15_t)0xdcda, (q15_t)0x7575, + (q15_t)0xdcd0, (q15_t)0x756e, (q15_t)0xdcc5, (q15_t)0x7567, (q15_t)0xdcbb, + (q15_t)0x7561, (q15_t)0xdcb0, (q15_t)0x755a, (q15_t)0xdca6, (q15_t)0x7553, + (q15_t)0xdc9b, (q15_t)0x754c, (q15_t)0xdc91, (q15_t)0x7545, (q15_t)0xdc86, + (q15_t)0x753e, (q15_t)0xdc7c, (q15_t)0x7537, (q15_t)0xdc72, (q15_t)0x7530, + (q15_t)0xdc67, (q15_t)0x7529, (q15_t)0xdc5d, (q15_t)0x7522, (q15_t)0xdc52, + (q15_t)0x751b, (q15_t)0xdc48, (q15_t)0x7514, (q15_t)0xdc3d, (q15_t)0x750d, + (q15_t)0xdc33, (q15_t)0x7506, (q15_t)0xdc29, (q15_t)0x74ff, (q15_t)0xdc1e, + (q15_t)0x74f8, (q15_t)0xdc14, (q15_t)0x74f1, (q15_t)0xdc09, (q15_t)0x74ea, + (q15_t)0xdbff, (q15_t)0x74e2, (q15_t)0xdbf5, (q15_t)0x74db, (q15_t)0xdbea, + (q15_t)0x74d4, (q15_t)0xdbe0, (q15_t)0x74cd, (q15_t)0xdbd5, (q15_t)0x74c6, + (q15_t)0xdbcb, (q15_t)0x74bf, (q15_t)0xdbc1, (q15_t)0x74b8, (q15_t)0xdbb6, + (q15_t)0x74b1, (q15_t)0xdbac, (q15_t)0x74aa, (q15_t)0xdba2, (q15_t)0x74a2, + (q15_t)0xdb97, (q15_t)0x749b, (q15_t)0xdb8d, (q15_t)0x7494, (q15_t)0xdb83, + (q15_t)0x748d, (q15_t)0xdb78, (q15_t)0x7486, (q15_t)0xdb6e, (q15_t)0x747f, + (q15_t)0xdb64, (q15_t)0x7477, (q15_t)0xdb59, (q15_t)0x7470, (q15_t)0xdb4f, + (q15_t)0x7469, (q15_t)0xdb45, (q15_t)0x7462, (q15_t)0xdb3b, (q15_t)0x745b, + (q15_t)0xdb30, (q15_t)0x7453, (q15_t)0xdb26, (q15_t)0x744c, (q15_t)0xdb1c, + (q15_t)0x7445, (q15_t)0xdb11, (q15_t)0x743e, (q15_t)0xdb07, (q15_t)0x7436, + (q15_t)0xdafd, (q15_t)0x742f, (q15_t)0xdaf3, (q15_t)0x7428, (q15_t)0xdae8, + (q15_t)0x7420, (q15_t)0xdade, (q15_t)0x7419, (q15_t)0xdad4, (q15_t)0x7412, + (q15_t)0xdaca, (q15_t)0x740b, (q15_t)0xdabf, (q15_t)0x7403, (q15_t)0xdab5, + (q15_t)0x73fc, (q15_t)0xdaab, (q15_t)0x73f5, (q15_t)0xdaa1, (q15_t)0x73ed, + (q15_t)0xda97, (q15_t)0x73e6, (q15_t)0xda8c, (q15_t)0x73df, (q15_t)0xda82, + (q15_t)0x73d7, (q15_t)0xda78, (q15_t)0x73d0, (q15_t)0xda6e, (q15_t)0x73c8, + (q15_t)0xda64, (q15_t)0x73c1, (q15_t)0xda5a, (q15_t)0x73ba, (q15_t)0xda4f, + (q15_t)0x73b2, (q15_t)0xda45, (q15_t)0x73ab, (q15_t)0xda3b, (q15_t)0x73a3, + (q15_t)0xda31, (q15_t)0x739c, (q15_t)0xda27, (q15_t)0x7395, (q15_t)0xda1d, + (q15_t)0x738d, (q15_t)0xda13, (q15_t)0x7386, (q15_t)0xda08, (q15_t)0x737e, + (q15_t)0xd9fe, (q15_t)0x7377, (q15_t)0xd9f4, (q15_t)0x736f, (q15_t)0xd9ea, + (q15_t)0x7368, (q15_t)0xd9e0, (q15_t)0x7360, (q15_t)0xd9d6, (q15_t)0x7359, + (q15_t)0xd9cc, (q15_t)0x7351, (q15_t)0xd9c2, (q15_t)0x734a, (q15_t)0xd9b8, + (q15_t)0x7342, (q15_t)0xd9ae, (q15_t)0x733b, (q15_t)0xd9a4, (q15_t)0x7333, + (q15_t)0xd99a, (q15_t)0x732c, (q15_t)0xd98f, (q15_t)0x7324, (q15_t)0xd985, + (q15_t)0x731d, (q15_t)0xd97b, (q15_t)0x7315, (q15_t)0xd971, (q15_t)0x730d, + (q15_t)0xd967, (q15_t)0x7306, (q15_t)0xd95d, (q15_t)0x72fe, (q15_t)0xd953, + (q15_t)0x72f7, (q15_t)0xd949, (q15_t)0x72ef, (q15_t)0xd93f, (q15_t)0x72e7, + (q15_t)0xd935, (q15_t)0x72e0, (q15_t)0xd92b, (q15_t)0x72d8, (q15_t)0xd921, + (q15_t)0x72d0, (q15_t)0xd917, (q15_t)0x72c9, (q15_t)0xd90d, (q15_t)0x72c1, + (q15_t)0xd903, (q15_t)0x72ba, (q15_t)0xd8f9, (q15_t)0x72b2, (q15_t)0xd8ef, + (q15_t)0x72aa, (q15_t)0xd8e6, (q15_t)0x72a3, (q15_t)0xd8dc, (q15_t)0x729b, + (q15_t)0xd8d2, (q15_t)0x7293, (q15_t)0xd8c8, (q15_t)0x728b, (q15_t)0xd8be, + (q15_t)0x7284, (q15_t)0xd8b4, (q15_t)0x727c, (q15_t)0xd8aa, (q15_t)0x7274, + (q15_t)0xd8a0, (q15_t)0x726d, (q15_t)0xd896, (q15_t)0x7265, (q15_t)0xd88c, + (q15_t)0x725d, (q15_t)0xd882, (q15_t)0x7255, (q15_t)0xd878, (q15_t)0x724e, + (q15_t)0xd86f, (q15_t)0x7246, (q15_t)0xd865, (q15_t)0x723e, (q15_t)0xd85b, + (q15_t)0x7236, (q15_t)0xd851, (q15_t)0x722e, (q15_t)0xd847, (q15_t)0x7227, + (q15_t)0xd83d, (q15_t)0x721f, (q15_t)0xd833, (q15_t)0x7217, (q15_t)0xd82a, + (q15_t)0x720f, (q15_t)0xd820, (q15_t)0x7207, (q15_t)0xd816, (q15_t)0x71ff, + (q15_t)0xd80c, (q15_t)0x71f8, (q15_t)0xd802, (q15_t)0x71f0, (q15_t)0xd7f8, + (q15_t)0x71e8, (q15_t)0xd7ef, (q15_t)0x71e0, (q15_t)0xd7e5, (q15_t)0x71d8, + (q15_t)0xd7db, (q15_t)0x71d0, (q15_t)0xd7d1, (q15_t)0x71c8, (q15_t)0xd7c8, + (q15_t)0x71c0, (q15_t)0xd7be, (q15_t)0x71b9, (q15_t)0xd7b4, (q15_t)0x71b1, + (q15_t)0xd7aa, (q15_t)0x71a9, (q15_t)0xd7a0, (q15_t)0x71a1, (q15_t)0xd797, + (q15_t)0x7199, (q15_t)0xd78d, (q15_t)0x7191, (q15_t)0xd783, (q15_t)0x7189, + (q15_t)0xd77a, (q15_t)0x7181, (q15_t)0xd770, (q15_t)0x7179, (q15_t)0xd766, + (q15_t)0x7171, (q15_t)0xd75c, (q15_t)0x7169, (q15_t)0xd753, (q15_t)0x7161, + (q15_t)0xd749, (q15_t)0x7159, (q15_t)0xd73f, (q15_t)0x7151, (q15_t)0xd736, + (q15_t)0x7149, (q15_t)0xd72c, (q15_t)0x7141, (q15_t)0xd722, (q15_t)0x7139, + (q15_t)0xd719, (q15_t)0x7131, (q15_t)0xd70f, (q15_t)0x7129, (q15_t)0xd705, + (q15_t)0x7121, (q15_t)0xd6fc, (q15_t)0x7119, (q15_t)0xd6f2, (q15_t)0x7111, + (q15_t)0xd6e8, (q15_t)0x7109, (q15_t)0xd6df, (q15_t)0x7101, (q15_t)0xd6d5, + (q15_t)0x70f9, (q15_t)0xd6cb, (q15_t)0x70f0, (q15_t)0xd6c2, (q15_t)0x70e8, + (q15_t)0xd6b8, (q15_t)0x70e0, (q15_t)0xd6af, (q15_t)0x70d8, (q15_t)0xd6a5, + (q15_t)0x70d0, (q15_t)0xd69b, (q15_t)0x70c8, (q15_t)0xd692, (q15_t)0x70c0, + (q15_t)0xd688, (q15_t)0x70b8, (q15_t)0xd67f, (q15_t)0x70af, (q15_t)0xd675, + (q15_t)0x70a7, (q15_t)0xd66c, (q15_t)0x709f, (q15_t)0xd662, (q15_t)0x7097, + (q15_t)0xd659, (q15_t)0x708f, (q15_t)0xd64f, (q15_t)0x7087, (q15_t)0xd645, + (q15_t)0x707e, (q15_t)0xd63c, (q15_t)0x7076, (q15_t)0xd632, (q15_t)0x706e, + (q15_t)0xd629, (q15_t)0x7066, (q15_t)0xd61f, (q15_t)0x705d, (q15_t)0xd616, + (q15_t)0x7055, (q15_t)0xd60c, (q15_t)0x704d, (q15_t)0xd603, (q15_t)0x7045, + (q15_t)0xd5f9, (q15_t)0x703c, (q15_t)0xd5f0, (q15_t)0x7034, (q15_t)0xd5e6, + (q15_t)0x702c, (q15_t)0xd5dd, (q15_t)0x7024, (q15_t)0xd5d4, (q15_t)0x701b, + (q15_t)0xd5ca, (q15_t)0x7013, (q15_t)0xd5c1, (q15_t)0x700b, (q15_t)0xd5b7, + (q15_t)0x7002, (q15_t)0xd5ae, (q15_t)0x6ffa, (q15_t)0xd5a4, (q15_t)0x6ff2, + (q15_t)0xd59b, (q15_t)0x6fea, (q15_t)0xd592, (q15_t)0x6fe1, (q15_t)0xd588, + (q15_t)0x6fd9, (q15_t)0xd57f, (q15_t)0x6fd0, (q15_t)0xd575, (q15_t)0x6fc8, + (q15_t)0xd56c, (q15_t)0x6fc0, (q15_t)0xd563, (q15_t)0x6fb7, (q15_t)0xd559, + (q15_t)0x6faf, (q15_t)0xd550, (q15_t)0x6fa7, (q15_t)0xd547, (q15_t)0x6f9e, + (q15_t)0xd53d, (q15_t)0x6f96, (q15_t)0xd534, (q15_t)0x6f8d, (q15_t)0xd52a, + (q15_t)0x6f85, (q15_t)0xd521, (q15_t)0x6f7d, (q15_t)0xd518, (q15_t)0x6f74, + (q15_t)0xd50e, (q15_t)0x6f6c, (q15_t)0xd505, (q15_t)0x6f63, (q15_t)0xd4fc, + (q15_t)0x6f5b, (q15_t)0xd4f3, (q15_t)0x6f52, (q15_t)0xd4e9, (q15_t)0x6f4a, + (q15_t)0xd4e0, (q15_t)0x6f41, (q15_t)0xd4d7, (q15_t)0x6f39, (q15_t)0xd4cd, + (q15_t)0x6f30, (q15_t)0xd4c4, (q15_t)0x6f28, (q15_t)0xd4bb, (q15_t)0x6f20, + (q15_t)0xd4b2, (q15_t)0x6f17, (q15_t)0xd4a8, (q15_t)0x6f0e, (q15_t)0xd49f, + (q15_t)0x6f06, (q15_t)0xd496, (q15_t)0x6efd, (q15_t)0xd48d, (q15_t)0x6ef5, + (q15_t)0xd483, (q15_t)0x6eec, (q15_t)0xd47a, (q15_t)0x6ee4, (q15_t)0xd471, + (q15_t)0x6edb, (q15_t)0xd468, (q15_t)0x6ed3, (q15_t)0xd45f, (q15_t)0x6eca, + (q15_t)0xd455, (q15_t)0x6ec2, (q15_t)0xd44c, (q15_t)0x6eb9, (q15_t)0xd443, + (q15_t)0x6eb0, (q15_t)0xd43a, (q15_t)0x6ea8, (q15_t)0xd431, (q15_t)0x6e9f, + (q15_t)0xd428, (q15_t)0x6e97, (q15_t)0xd41e, (q15_t)0x6e8e, (q15_t)0xd415, + (q15_t)0x6e85, (q15_t)0xd40c, (q15_t)0x6e7d, (q15_t)0xd403, (q15_t)0x6e74, + (q15_t)0xd3fa, (q15_t)0x6e6b, (q15_t)0xd3f1, (q15_t)0x6e63, (q15_t)0xd3e8, + (q15_t)0x6e5a, (q15_t)0xd3df, (q15_t)0x6e51, (q15_t)0xd3d5, (q15_t)0x6e49, + (q15_t)0xd3cc, (q15_t)0x6e40, (q15_t)0xd3c3, (q15_t)0x6e37, (q15_t)0xd3ba, + (q15_t)0x6e2f, (q15_t)0xd3b1, (q15_t)0x6e26, (q15_t)0xd3a8, (q15_t)0x6e1d, + (q15_t)0xd39f, (q15_t)0x6e15, (q15_t)0xd396, (q15_t)0x6e0c, (q15_t)0xd38d, + (q15_t)0x6e03, (q15_t)0xd384, (q15_t)0x6dfa, (q15_t)0xd37b, (q15_t)0x6df2, + (q15_t)0xd372, (q15_t)0x6de9, (q15_t)0xd369, (q15_t)0x6de0, (q15_t)0xd360, + (q15_t)0x6dd7, (q15_t)0xd357, (q15_t)0x6dcf, (q15_t)0xd34e, (q15_t)0x6dc6, + (q15_t)0xd345, (q15_t)0x6dbd, (q15_t)0xd33c, (q15_t)0x6db4, (q15_t)0xd333, + (q15_t)0x6dab, (q15_t)0xd32a, (q15_t)0x6da3, (q15_t)0xd321, (q15_t)0x6d9a, + (q15_t)0xd318, (q15_t)0x6d91, (q15_t)0xd30f, (q15_t)0x6d88, (q15_t)0xd306, + (q15_t)0x6d7f, (q15_t)0xd2fd, (q15_t)0x6d76, (q15_t)0xd2f4, (q15_t)0x6d6e, + (q15_t)0xd2eb, (q15_t)0x6d65, (q15_t)0xd2e2, (q15_t)0x6d5c, (q15_t)0xd2d9, + (q15_t)0x6d53, (q15_t)0xd2d1, (q15_t)0x6d4a, (q15_t)0xd2c8, (q15_t)0x6d41, + (q15_t)0xd2bf, (q15_t)0x6d38, (q15_t)0xd2b6, (q15_t)0x6d2f, (q15_t)0xd2ad, + (q15_t)0x6d27, (q15_t)0xd2a4, (q15_t)0x6d1e, (q15_t)0xd29b, (q15_t)0x6d15, + (q15_t)0xd292, (q15_t)0x6d0c, (q15_t)0xd28a, (q15_t)0x6d03, (q15_t)0xd281, + (q15_t)0x6cfa, (q15_t)0xd278, (q15_t)0x6cf1, (q15_t)0xd26f, (q15_t)0x6ce8, + (q15_t)0xd266, (q15_t)0x6cdf, (q15_t)0xd25d, (q15_t)0x6cd6, (q15_t)0xd255, + (q15_t)0x6ccd, (q15_t)0xd24c, (q15_t)0x6cc4, (q15_t)0xd243, (q15_t)0x6cbb, + (q15_t)0xd23a, (q15_t)0x6cb2, (q15_t)0xd231, (q15_t)0x6ca9, (q15_t)0xd229, + (q15_t)0x6ca0, (q15_t)0xd220, (q15_t)0x6c97, (q15_t)0xd217, (q15_t)0x6c8e, + (q15_t)0xd20e, (q15_t)0x6c85, (q15_t)0xd206, (q15_t)0x6c7c, (q15_t)0xd1fd, + (q15_t)0x6c73, (q15_t)0xd1f4, (q15_t)0x6c6a, (q15_t)0xd1eb, (q15_t)0x6c61, + (q15_t)0xd1e3, (q15_t)0x6c58, (q15_t)0xd1da, (q15_t)0x6c4f, (q15_t)0xd1d1, + (q15_t)0x6c46, (q15_t)0xd1c9, (q15_t)0x6c3d, (q15_t)0xd1c0, (q15_t)0x6c34, + (q15_t)0xd1b7, (q15_t)0x6c2b, (q15_t)0xd1af, (q15_t)0x6c21, (q15_t)0xd1a6, + (q15_t)0x6c18, (q15_t)0xd19d, (q15_t)0x6c0f, (q15_t)0xd195, (q15_t)0x6c06, + (q15_t)0xd18c, (q15_t)0x6bfd, (q15_t)0xd183, (q15_t)0x6bf4, (q15_t)0xd17b, + (q15_t)0x6beb, (q15_t)0xd172, (q15_t)0x6be2, (q15_t)0xd169, (q15_t)0x6bd8, + (q15_t)0xd161, (q15_t)0x6bcf, (q15_t)0xd158, (q15_t)0x6bc6, (q15_t)0xd150, + (q15_t)0x6bbd, (q15_t)0xd147, (q15_t)0x6bb4, (q15_t)0xd13e, (q15_t)0x6bab, + (q15_t)0xd136, (q15_t)0x6ba1, (q15_t)0xd12d, (q15_t)0x6b98, (q15_t)0xd125, + (q15_t)0x6b8f, (q15_t)0xd11c, (q15_t)0x6b86, (q15_t)0xd114, (q15_t)0x6b7d, + (q15_t)0xd10b, (q15_t)0x6b73, (q15_t)0xd103, (q15_t)0x6b6a, (q15_t)0xd0fa, + (q15_t)0x6b61, (q15_t)0xd0f2, (q15_t)0x6b58, (q15_t)0xd0e9, (q15_t)0x6b4e, + (q15_t)0xd0e0, (q15_t)0x6b45, (q15_t)0xd0d8, (q15_t)0x6b3c, (q15_t)0xd0d0, + (q15_t)0x6b33, (q15_t)0xd0c7, (q15_t)0x6b29, (q15_t)0xd0bf, (q15_t)0x6b20, + (q15_t)0xd0b6, (q15_t)0x6b17, (q15_t)0xd0ae, (q15_t)0x6b0d, (q15_t)0xd0a5, + (q15_t)0x6b04, (q15_t)0xd09d, (q15_t)0x6afb, (q15_t)0xd094, (q15_t)0x6af2, + (q15_t)0xd08c, (q15_t)0x6ae8, (q15_t)0xd083, (q15_t)0x6adf, (q15_t)0xd07b, + (q15_t)0x6ad6, (q15_t)0xd073, (q15_t)0x6acc, (q15_t)0xd06a, (q15_t)0x6ac3, + (q15_t)0xd062, (q15_t)0x6ab9, (q15_t)0xd059, (q15_t)0x6ab0, (q15_t)0xd051, + (q15_t)0x6aa7, (q15_t)0xd049, (q15_t)0x6a9d, (q15_t)0xd040, (q15_t)0x6a94, + (q15_t)0xd038, (q15_t)0x6a8b, (q15_t)0xd030, (q15_t)0x6a81, (q15_t)0xd027, + (q15_t)0x6a78, (q15_t)0xd01f, (q15_t)0x6a6e, (q15_t)0xd016, (q15_t)0x6a65, + (q15_t)0xd00e, (q15_t)0x6a5c, (q15_t)0xd006, (q15_t)0x6a52, (q15_t)0xcffe, + (q15_t)0x6a49, (q15_t)0xcff5, (q15_t)0x6a3f, (q15_t)0xcfed, (q15_t)0x6a36, + (q15_t)0xcfe5, (q15_t)0x6a2c, (q15_t)0xcfdc, (q15_t)0x6a23, (q15_t)0xcfd4, + (q15_t)0x6a1a, (q15_t)0xcfcc, (q15_t)0x6a10, (q15_t)0xcfc4, (q15_t)0x6a07, + (q15_t)0xcfbb, (q15_t)0x69fd, (q15_t)0xcfb3, (q15_t)0x69f4, (q15_t)0xcfab, + (q15_t)0x69ea, (q15_t)0xcfa3, (q15_t)0x69e1, (q15_t)0xcf9a, (q15_t)0x69d7, + (q15_t)0xcf92, (q15_t)0x69ce, (q15_t)0xcf8a, (q15_t)0x69c4, (q15_t)0xcf82, + (q15_t)0x69bb, (q15_t)0xcf79, (q15_t)0x69b1, (q15_t)0xcf71, (q15_t)0x69a7, + (q15_t)0xcf69, (q15_t)0x699e, (q15_t)0xcf61, (q15_t)0x6994, (q15_t)0xcf59, + (q15_t)0x698b, (q15_t)0xcf51, (q15_t)0x6981, (q15_t)0xcf48, (q15_t)0x6978, + (q15_t)0xcf40, (q15_t)0x696e, (q15_t)0xcf38, (q15_t)0x6965, (q15_t)0xcf30, + (q15_t)0x695b, (q15_t)0xcf28, (q15_t)0x6951, (q15_t)0xcf20, (q15_t)0x6948, + (q15_t)0xcf18, (q15_t)0x693e, (q15_t)0xcf10, (q15_t)0x6935, (q15_t)0xcf07, + (q15_t)0x692b, (q15_t)0xceff, (q15_t)0x6921, (q15_t)0xcef7, (q15_t)0x6918, + (q15_t)0xceef, (q15_t)0x690e, (q15_t)0xcee7, (q15_t)0x6904, (q15_t)0xcedf, + (q15_t)0x68fb, (q15_t)0xced7, (q15_t)0x68f1, (q15_t)0xcecf, (q15_t)0x68e7, + (q15_t)0xcec7, (q15_t)0x68de, (q15_t)0xcebf, (q15_t)0x68d4, (q15_t)0xceb7, + (q15_t)0x68ca, (q15_t)0xceaf, (q15_t)0x68c1, (q15_t)0xcea7, (q15_t)0x68b7, + (q15_t)0xce9f, (q15_t)0x68ad, (q15_t)0xce97, (q15_t)0x68a4, (q15_t)0xce8f, + (q15_t)0x689a, (q15_t)0xce87, (q15_t)0x6890, (q15_t)0xce7f, (q15_t)0x6886, + (q15_t)0xce77, (q15_t)0x687d, (q15_t)0xce6f, (q15_t)0x6873, (q15_t)0xce67, + (q15_t)0x6869, (q15_t)0xce5f, (q15_t)0x6860, (q15_t)0xce57, (q15_t)0x6856, + (q15_t)0xce4f, (q15_t)0x684c, (q15_t)0xce47, (q15_t)0x6842, (q15_t)0xce40, + (q15_t)0x6838, (q15_t)0xce38, (q15_t)0x682f, (q15_t)0xce30, (q15_t)0x6825, + (q15_t)0xce28, (q15_t)0x681b, (q15_t)0xce20, (q15_t)0x6811, (q15_t)0xce18, + (q15_t)0x6808, (q15_t)0xce10, (q15_t)0x67fe, (q15_t)0xce08, (q15_t)0x67f4, + (q15_t)0xce01, (q15_t)0x67ea, (q15_t)0xcdf9, (q15_t)0x67e0, (q15_t)0xcdf1, + (q15_t)0x67d6, (q15_t)0xcde9, (q15_t)0x67cd, (q15_t)0xcde1, (q15_t)0x67c3, + (q15_t)0xcdd9, (q15_t)0x67b9, (q15_t)0xcdd2, (q15_t)0x67af, (q15_t)0xcdca, + (q15_t)0x67a5, (q15_t)0xcdc2, (q15_t)0x679b, (q15_t)0xcdba, (q15_t)0x6791, + (q15_t)0xcdb2, (q15_t)0x6788, (q15_t)0xcdab, (q15_t)0x677e, (q15_t)0xcda3, + (q15_t)0x6774, (q15_t)0xcd9b, (q15_t)0x676a, (q15_t)0xcd93, (q15_t)0x6760, + (q15_t)0xcd8c, (q15_t)0x6756, (q15_t)0xcd84, (q15_t)0x674c, (q15_t)0xcd7c, + (q15_t)0x6742, (q15_t)0xcd75, (q15_t)0x6738, (q15_t)0xcd6d, (q15_t)0x672e, + (q15_t)0xcd65, (q15_t)0x6724, (q15_t)0xcd5d, (q15_t)0x671a, (q15_t)0xcd56, + (q15_t)0x6711, (q15_t)0xcd4e, (q15_t)0x6707, (q15_t)0xcd46, (q15_t)0x66fd, + (q15_t)0xcd3f, (q15_t)0x66f3, (q15_t)0xcd37, (q15_t)0x66e9, (q15_t)0xcd30, + (q15_t)0x66df, (q15_t)0xcd28, (q15_t)0x66d5, (q15_t)0xcd20, (q15_t)0x66cb, + (q15_t)0xcd19, (q15_t)0x66c1, (q15_t)0xcd11, (q15_t)0x66b7, (q15_t)0xcd09, + (q15_t)0x66ad, (q15_t)0xcd02, (q15_t)0x66a3, (q15_t)0xccfa, (q15_t)0x6699, + (q15_t)0xccf3, (q15_t)0x668f, (q15_t)0xcceb, (q15_t)0x6685, (q15_t)0xcce3, + (q15_t)0x667b, (q15_t)0xccdc, (q15_t)0x6671, (q15_t)0xccd4, (q15_t)0x6666, + (q15_t)0xcccd, (q15_t)0x665c, (q15_t)0xccc5, (q15_t)0x6652, (q15_t)0xccbe, + (q15_t)0x6648, (q15_t)0xccb6, (q15_t)0x663e, (q15_t)0xccaf, (q15_t)0x6634, + (q15_t)0xcca7, (q15_t)0x662a, (q15_t)0xcca0, (q15_t)0x6620, (q15_t)0xcc98, + (q15_t)0x6616, (q15_t)0xcc91, (q15_t)0x660c, (q15_t)0xcc89, (q15_t)0x6602, + (q15_t)0xcc82, (q15_t)0x65f8, (q15_t)0xcc7a, (q15_t)0x65ed, (q15_t)0xcc73, + (q15_t)0x65e3, (q15_t)0xcc6b, (q15_t)0x65d9, (q15_t)0xcc64, (q15_t)0x65cf, + (q15_t)0xcc5d, (q15_t)0x65c5, (q15_t)0xcc55, (q15_t)0x65bb, (q15_t)0xcc4e, + (q15_t)0x65b1, (q15_t)0xcc46, (q15_t)0x65a6, (q15_t)0xcc3f, (q15_t)0x659c, + (q15_t)0xcc38, (q15_t)0x6592, (q15_t)0xcc30, (q15_t)0x6588, (q15_t)0xcc29, + (q15_t)0x657e, (q15_t)0xcc21, (q15_t)0x6574, (q15_t)0xcc1a, (q15_t)0x6569, + (q15_t)0xcc13, (q15_t)0x655f, (q15_t)0xcc0b, (q15_t)0x6555, (q15_t)0xcc04, + (q15_t)0x654b, (q15_t)0xcbfd, (q15_t)0x6541, (q15_t)0xcbf5, (q15_t)0x6536, + (q15_t)0xcbee, (q15_t)0x652c, (q15_t)0xcbe7, (q15_t)0x6522, (q15_t)0xcbe0, + (q15_t)0x6518, (q15_t)0xcbd8, (q15_t)0x650d, (q15_t)0xcbd1, (q15_t)0x6503, + (q15_t)0xcbca, (q15_t)0x64f9, (q15_t)0xcbc2, (q15_t)0x64ef, (q15_t)0xcbbb, + (q15_t)0x64e4, (q15_t)0xcbb4, (q15_t)0x64da, (q15_t)0xcbad, (q15_t)0x64d0, + (q15_t)0xcba5, (q15_t)0x64c5, (q15_t)0xcb9e, (q15_t)0x64bb, (q15_t)0xcb97, + (q15_t)0x64b1, (q15_t)0xcb90, (q15_t)0x64a7, (q15_t)0xcb89, (q15_t)0x649c, + (q15_t)0xcb81, (q15_t)0x6492, (q15_t)0xcb7a, (q15_t)0x6488, (q15_t)0xcb73, + (q15_t)0x647d, (q15_t)0xcb6c, (q15_t)0x6473, (q15_t)0xcb65, (q15_t)0x6469, + (q15_t)0xcb5e, (q15_t)0x645e, (q15_t)0xcb56, (q15_t)0x6454, (q15_t)0xcb4f, + (q15_t)0x644a, (q15_t)0xcb48, (q15_t)0x643f, (q15_t)0xcb41, (q15_t)0x6435, + (q15_t)0xcb3a, (q15_t)0x642b, (q15_t)0xcb33, (q15_t)0x6420, (q15_t)0xcb2c, + (q15_t)0x6416, (q15_t)0xcb25, (q15_t)0x640b, (q15_t)0xcb1e, (q15_t)0x6401, + (q15_t)0xcb16, (q15_t)0x63f7, (q15_t)0xcb0f, (q15_t)0x63ec, (q15_t)0xcb08, + (q15_t)0x63e2, (q15_t)0xcb01, (q15_t)0x63d7, (q15_t)0xcafa, (q15_t)0x63cd, + (q15_t)0xcaf3, (q15_t)0x63c3, (q15_t)0xcaec, (q15_t)0x63b8, (q15_t)0xcae5, + (q15_t)0x63ae, (q15_t)0xcade, (q15_t)0x63a3, (q15_t)0xcad7, (q15_t)0x6399, + (q15_t)0xcad0, (q15_t)0x638e, (q15_t)0xcac9, (q15_t)0x6384, (q15_t)0xcac2, + (q15_t)0x637a, (q15_t)0xcabb, (q15_t)0x636f, (q15_t)0xcab4, (q15_t)0x6365, + (q15_t)0xcaad, (q15_t)0x635a, (q15_t)0xcaa6, (q15_t)0x6350, (q15_t)0xca9f, + (q15_t)0x6345, (q15_t)0xca99, (q15_t)0x633b, (q15_t)0xca92, (q15_t)0x6330, + (q15_t)0xca8b, (q15_t)0x6326, (q15_t)0xca84, (q15_t)0x631b, (q15_t)0xca7d, + (q15_t)0x6311, (q15_t)0xca76, (q15_t)0x6306, (q15_t)0xca6f, (q15_t)0x62fc, + (q15_t)0xca68, (q15_t)0x62f1, (q15_t)0xca61, (q15_t)0x62e7, (q15_t)0xca5b, + (q15_t)0x62dc, (q15_t)0xca54, (q15_t)0x62d2, (q15_t)0xca4d, (q15_t)0x62c7, + (q15_t)0xca46, (q15_t)0x62bc, (q15_t)0xca3f, (q15_t)0x62b2, (q15_t)0xca38, + (q15_t)0x62a7, (q15_t)0xca32, (q15_t)0x629d, (q15_t)0xca2b, (q15_t)0x6292, + (q15_t)0xca24, (q15_t)0x6288, (q15_t)0xca1d, (q15_t)0x627d, (q15_t)0xca16, + (q15_t)0x6272, (q15_t)0xca10, (q15_t)0x6268, (q15_t)0xca09, (q15_t)0x625d, + (q15_t)0xca02, (q15_t)0x6253, (q15_t)0xc9fb, (q15_t)0x6248, (q15_t)0xc9f5, + (q15_t)0x623d, (q15_t)0xc9ee, (q15_t)0x6233, (q15_t)0xc9e7, (q15_t)0x6228, + (q15_t)0xc9e0, (q15_t)0x621e, (q15_t)0xc9da, (q15_t)0x6213, (q15_t)0xc9d3, + (q15_t)0x6208, (q15_t)0xc9cc, (q15_t)0x61fe, (q15_t)0xc9c6, (q15_t)0x61f3, + (q15_t)0xc9bf, (q15_t)0x61e8, (q15_t)0xc9b8, (q15_t)0x61de, (q15_t)0xc9b2, + (q15_t)0x61d3, (q15_t)0xc9ab, (q15_t)0x61c8, (q15_t)0xc9a4, (q15_t)0x61be, + (q15_t)0xc99e, (q15_t)0x61b3, (q15_t)0xc997, (q15_t)0x61a8, (q15_t)0xc991, + (q15_t)0x619e, (q15_t)0xc98a, (q15_t)0x6193, (q15_t)0xc983, (q15_t)0x6188, + (q15_t)0xc97d, (q15_t)0x617d, (q15_t)0xc976, (q15_t)0x6173, (q15_t)0xc970, + (q15_t)0x6168, (q15_t)0xc969, (q15_t)0x615d, (q15_t)0xc963, (q15_t)0x6153, + (q15_t)0xc95c, (q15_t)0x6148, (q15_t)0xc955, (q15_t)0x613d, (q15_t)0xc94f, + (q15_t)0x6132, (q15_t)0xc948, (q15_t)0x6128, (q15_t)0xc942, (q15_t)0x611d, + (q15_t)0xc93b, (q15_t)0x6112, (q15_t)0xc935, (q15_t)0x6107, (q15_t)0xc92e, + (q15_t)0x60fd, (q15_t)0xc928, (q15_t)0x60f2, (q15_t)0xc921, (q15_t)0x60e7, + (q15_t)0xc91b, (q15_t)0x60dc, (q15_t)0xc915, (q15_t)0x60d1, (q15_t)0xc90e, + (q15_t)0x60c7, (q15_t)0xc908, (q15_t)0x60bc, (q15_t)0xc901, (q15_t)0x60b1, + (q15_t)0xc8fb, (q15_t)0x60a6, (q15_t)0xc8f4, (q15_t)0x609b, (q15_t)0xc8ee, + (q15_t)0x6091, (q15_t)0xc8e8, (q15_t)0x6086, (q15_t)0xc8e1, (q15_t)0x607b, + (q15_t)0xc8db, (q15_t)0x6070, (q15_t)0xc8d4, (q15_t)0x6065, (q15_t)0xc8ce, + (q15_t)0x605b, (q15_t)0xc8c8, (q15_t)0x6050, (q15_t)0xc8c1, (q15_t)0x6045, + (q15_t)0xc8bb, (q15_t)0x603a, (q15_t)0xc8b5, (q15_t)0x602f, (q15_t)0xc8ae, + (q15_t)0x6024, (q15_t)0xc8a8, (q15_t)0x6019, (q15_t)0xc8a2, (q15_t)0x600f, + (q15_t)0xc89b, (q15_t)0x6004, (q15_t)0xc895, (q15_t)0x5ff9, (q15_t)0xc88f, + (q15_t)0x5fee, (q15_t)0xc889, (q15_t)0x5fe3, (q15_t)0xc882, (q15_t)0x5fd8, + (q15_t)0xc87c, (q15_t)0x5fcd, (q15_t)0xc876, (q15_t)0x5fc2, (q15_t)0xc870, + (q15_t)0x5fb7, (q15_t)0xc869, (q15_t)0x5fac, (q15_t)0xc863, (q15_t)0x5fa2, + (q15_t)0xc85d, (q15_t)0x5f97, (q15_t)0xc857, (q15_t)0x5f8c, (q15_t)0xc850, + (q15_t)0x5f81, (q15_t)0xc84a, (q15_t)0x5f76, (q15_t)0xc844, (q15_t)0x5f6b, + (q15_t)0xc83e, (q15_t)0x5f60, (q15_t)0xc838, (q15_t)0x5f55, (q15_t)0xc832, + (q15_t)0x5f4a, (q15_t)0xc82b, (q15_t)0x5f3f, (q15_t)0xc825, (q15_t)0x5f34, + (q15_t)0xc81f, (q15_t)0x5f29, (q15_t)0xc819, (q15_t)0x5f1e, (q15_t)0xc813, + (q15_t)0x5f13, (q15_t)0xc80d, (q15_t)0x5f08, (q15_t)0xc807, (q15_t)0x5efd, + (q15_t)0xc801, (q15_t)0x5ef2, (q15_t)0xc7fb, (q15_t)0x5ee7, (q15_t)0xc7f5, + (q15_t)0x5edc, (q15_t)0xc7ee, (q15_t)0x5ed1, (q15_t)0xc7e8, (q15_t)0x5ec6, + (q15_t)0xc7e2, (q15_t)0x5ebb, (q15_t)0xc7dc, (q15_t)0x5eb0, (q15_t)0xc7d6, + (q15_t)0x5ea5, (q15_t)0xc7d0, (q15_t)0x5e9a, (q15_t)0xc7ca, (q15_t)0x5e8f, + (q15_t)0xc7c4, (q15_t)0x5e84, (q15_t)0xc7be, (q15_t)0x5e79, (q15_t)0xc7b8, + (q15_t)0x5e6e, (q15_t)0xc7b2, (q15_t)0x5e63, (q15_t)0xc7ac, (q15_t)0x5e58, + (q15_t)0xc7a6, (q15_t)0x5e4d, (q15_t)0xc7a0, (q15_t)0x5e42, (q15_t)0xc79a, + (q15_t)0x5e36, (q15_t)0xc795, (q15_t)0x5e2b, (q15_t)0xc78f, (q15_t)0x5e20, + (q15_t)0xc789, (q15_t)0x5e15, (q15_t)0xc783, (q15_t)0x5e0a, (q15_t)0xc77d, + (q15_t)0x5dff, (q15_t)0xc777, (q15_t)0x5df4, (q15_t)0xc771, (q15_t)0x5de9, + (q15_t)0xc76b, (q15_t)0x5dde, (q15_t)0xc765, (q15_t)0x5dd3, (q15_t)0xc75f, + (q15_t)0x5dc7, (q15_t)0xc75a, (q15_t)0x5dbc, (q15_t)0xc754, (q15_t)0x5db1, + (q15_t)0xc74e, (q15_t)0x5da6, (q15_t)0xc748, (q15_t)0x5d9b, (q15_t)0xc742, + (q15_t)0x5d90, (q15_t)0xc73d, (q15_t)0x5d85, (q15_t)0xc737, (q15_t)0x5d79, + (q15_t)0xc731, (q15_t)0x5d6e, (q15_t)0xc72b, (q15_t)0x5d63, (q15_t)0xc725, + (q15_t)0x5d58, (q15_t)0xc720, (q15_t)0x5d4d, (q15_t)0xc71a, (q15_t)0x5d42, + (q15_t)0xc714, (q15_t)0x5d36, (q15_t)0xc70e, (q15_t)0x5d2b, (q15_t)0xc709, + (q15_t)0x5d20, (q15_t)0xc703, (q15_t)0x5d15, (q15_t)0xc6fd, (q15_t)0x5d0a, + (q15_t)0xc6f7, (q15_t)0x5cff, (q15_t)0xc6f2, (q15_t)0x5cf3, (q15_t)0xc6ec, + (q15_t)0x5ce8, (q15_t)0xc6e6, (q15_t)0x5cdd, (q15_t)0xc6e1, (q15_t)0x5cd2, + (q15_t)0xc6db, (q15_t)0x5cc6, (q15_t)0xc6d5, (q15_t)0x5cbb, (q15_t)0xc6d0, + (q15_t)0x5cb0, (q15_t)0xc6ca, (q15_t)0x5ca5, (q15_t)0xc6c5, (q15_t)0x5c99, + (q15_t)0xc6bf, (q15_t)0x5c8e, (q15_t)0xc6b9, (q15_t)0x5c83, (q15_t)0xc6b4, + (q15_t)0x5c78, (q15_t)0xc6ae, (q15_t)0x5c6c, (q15_t)0xc6a8, (q15_t)0x5c61, + (q15_t)0xc6a3, (q15_t)0x5c56, (q15_t)0xc69d, (q15_t)0x5c4b, (q15_t)0xc698, + (q15_t)0x5c3f, (q15_t)0xc692, (q15_t)0x5c34, (q15_t)0xc68d, (q15_t)0x5c29, + (q15_t)0xc687, (q15_t)0x5c1e, (q15_t)0xc682, (q15_t)0x5c12, (q15_t)0xc67c, + (q15_t)0x5c07, (q15_t)0xc677, (q15_t)0x5bfc, (q15_t)0xc671, (q15_t)0x5bf0, + (q15_t)0xc66c, (q15_t)0x5be5, (q15_t)0xc666, (q15_t)0x5bda, (q15_t)0xc661, + (q15_t)0x5bce, (q15_t)0xc65b, (q15_t)0x5bc3, (q15_t)0xc656, (q15_t)0x5bb8, + (q15_t)0xc650, (q15_t)0x5bac, (q15_t)0xc64b, (q15_t)0x5ba1, (q15_t)0xc645, + (q15_t)0x5b96, (q15_t)0xc640, (q15_t)0x5b8a, (q15_t)0xc63b, (q15_t)0x5b7f, + (q15_t)0xc635, (q15_t)0x5b74, (q15_t)0xc630, (q15_t)0x5b68, (q15_t)0xc62a, + (q15_t)0x5b5d, (q15_t)0xc625, (q15_t)0x5b52, (q15_t)0xc620, (q15_t)0x5b46, + (q15_t)0xc61a, (q15_t)0x5b3b, (q15_t)0xc615, (q15_t)0x5b30, (q15_t)0xc610, + (q15_t)0x5b24, (q15_t)0xc60a, (q15_t)0x5b19, (q15_t)0xc605, (q15_t)0x5b0d, + (q15_t)0xc600, (q15_t)0x5b02, (q15_t)0xc5fa, (q15_t)0x5af7, (q15_t)0xc5f5, + (q15_t)0x5aeb, (q15_t)0xc5f0, (q15_t)0x5ae0, (q15_t)0xc5ea, (q15_t)0x5ad4, + (q15_t)0xc5e5, (q15_t)0x5ac9, (q15_t)0xc5e0, (q15_t)0x5abe, (q15_t)0xc5db, + (q15_t)0x5ab2, (q15_t)0xc5d5, (q15_t)0x5aa7, (q15_t)0xc5d0, (q15_t)0x5a9b, + (q15_t)0xc5cb, (q15_t)0x5a90, (q15_t)0xc5c6, (q15_t)0x5a84, (q15_t)0xc5c1, + (q15_t)0x5a79, (q15_t)0xc5bb, (q15_t)0x5a6e, (q15_t)0xc5b6, (q15_t)0x5a62, + (q15_t)0xc5b1, (q15_t)0x5a57, (q15_t)0xc5ac, (q15_t)0x5a4b, (q15_t)0xc5a7, + (q15_t)0x5a40, (q15_t)0xc5a1, (q15_t)0x5a34, (q15_t)0xc59c, (q15_t)0x5a29, + (q15_t)0xc597, (q15_t)0x5a1d, (q15_t)0xc592, (q15_t)0x5a12, (q15_t)0xc58d, + (q15_t)0x5a06, (q15_t)0xc588, (q15_t)0x59fb, (q15_t)0xc583, (q15_t)0x59ef, + (q15_t)0xc57e, (q15_t)0x59e4, (q15_t)0xc578, (q15_t)0x59d8, (q15_t)0xc573, + (q15_t)0x59cd, (q15_t)0xc56e, (q15_t)0x59c1, (q15_t)0xc569, (q15_t)0x59b6, + (q15_t)0xc564, (q15_t)0x59aa, (q15_t)0xc55f, (q15_t)0x599f, (q15_t)0xc55a, + (q15_t)0x5993, (q15_t)0xc555, (q15_t)0x5988, (q15_t)0xc550, (q15_t)0x597c, + (q15_t)0xc54b, (q15_t)0x5971, (q15_t)0xc546, (q15_t)0x5965, (q15_t)0xc541, + (q15_t)0x595a, (q15_t)0xc53c, (q15_t)0x594e, (q15_t)0xc537, (q15_t)0x5943, + (q15_t)0xc532, (q15_t)0x5937, (q15_t)0xc52d, (q15_t)0x592c, (q15_t)0xc528, + (q15_t)0x5920, (q15_t)0xc523, (q15_t)0x5914, (q15_t)0xc51e, (q15_t)0x5909, + (q15_t)0xc51a, (q15_t)0x58fd, (q15_t)0xc515, (q15_t)0x58f2, (q15_t)0xc510, + (q15_t)0x58e6, (q15_t)0xc50b, (q15_t)0x58db, (q15_t)0xc506, (q15_t)0x58cf, + (q15_t)0xc501, (q15_t)0x58c3, (q15_t)0xc4fc, (q15_t)0x58b8, (q15_t)0xc4f7, + (q15_t)0x58ac, (q15_t)0xc4f2, (q15_t)0x58a1, (q15_t)0xc4ee, (q15_t)0x5895, + (q15_t)0xc4e9, (q15_t)0x5889, (q15_t)0xc4e4, (q15_t)0x587e, (q15_t)0xc4df, + (q15_t)0x5872, (q15_t)0xc4da, (q15_t)0x5867, (q15_t)0xc4d6, (q15_t)0x585b, + (q15_t)0xc4d1, (q15_t)0x584f, (q15_t)0xc4cc, (q15_t)0x5844, (q15_t)0xc4c7, + (q15_t)0x5838, (q15_t)0xc4c2, (q15_t)0x582d, (q15_t)0xc4be, (q15_t)0x5821, + (q15_t)0xc4b9, (q15_t)0x5815, (q15_t)0xc4b4, (q15_t)0x580a, (q15_t)0xc4b0, + (q15_t)0x57fe, (q15_t)0xc4ab, (q15_t)0x57f2, (q15_t)0xc4a6, (q15_t)0x57e7, + (q15_t)0xc4a1, (q15_t)0x57db, (q15_t)0xc49d, (q15_t)0x57cf, (q15_t)0xc498, + (q15_t)0x57c4, (q15_t)0xc493, (q15_t)0x57b8, (q15_t)0xc48f, (q15_t)0x57ac, + (q15_t)0xc48a, (q15_t)0x57a1, (q15_t)0xc485, (q15_t)0x5795, (q15_t)0xc481, + (q15_t)0x5789, (q15_t)0xc47c, (q15_t)0x577e, (q15_t)0xc478, (q15_t)0x5772, + (q15_t)0xc473, (q15_t)0x5766, (q15_t)0xc46e, (q15_t)0x575b, (q15_t)0xc46a, + (q15_t)0x574f, (q15_t)0xc465, (q15_t)0x5743, (q15_t)0xc461, (q15_t)0x5737, + (q15_t)0xc45c, (q15_t)0x572c, (q15_t)0xc457, (q15_t)0x5720, (q15_t)0xc453, + (q15_t)0x5714, (q15_t)0xc44e, (q15_t)0x5709, (q15_t)0xc44a, (q15_t)0x56fd, + (q15_t)0xc445, (q15_t)0x56f1, (q15_t)0xc441, (q15_t)0x56e5, (q15_t)0xc43c, + (q15_t)0x56da, (q15_t)0xc438, (q15_t)0x56ce, (q15_t)0xc433, (q15_t)0x56c2, + (q15_t)0xc42f, (q15_t)0x56b6, (q15_t)0xc42a, (q15_t)0x56ab, (q15_t)0xc426, + (q15_t)0x569f, (q15_t)0xc422, (q15_t)0x5693, (q15_t)0xc41d, (q15_t)0x5687, + (q15_t)0xc419, (q15_t)0x567c, (q15_t)0xc414, (q15_t)0x5670, (q15_t)0xc410, + (q15_t)0x5664, (q15_t)0xc40b, (q15_t)0x5658, (q15_t)0xc407, (q15_t)0x564c, + (q15_t)0xc403, (q15_t)0x5641, (q15_t)0xc3fe, (q15_t)0x5635, (q15_t)0xc3fa, + (q15_t)0x5629, (q15_t)0xc3f6, (q15_t)0x561d, (q15_t)0xc3f1, (q15_t)0x5612, + (q15_t)0xc3ed, (q15_t)0x5606, (q15_t)0xc3e9, (q15_t)0x55fa, (q15_t)0xc3e4, + (q15_t)0x55ee, (q15_t)0xc3e0, (q15_t)0x55e2, (q15_t)0xc3dc, (q15_t)0x55d7, + (q15_t)0xc3d7, (q15_t)0x55cb, (q15_t)0xc3d3, (q15_t)0x55bf, (q15_t)0xc3cf, + (q15_t)0x55b3, (q15_t)0xc3ca, (q15_t)0x55a7, (q15_t)0xc3c6, (q15_t)0x559b, + (q15_t)0xc3c2, (q15_t)0x5590, (q15_t)0xc3be, (q15_t)0x5584, (q15_t)0xc3ba, + (q15_t)0x5578, (q15_t)0xc3b5, (q15_t)0x556c, (q15_t)0xc3b1, (q15_t)0x5560, + (q15_t)0xc3ad, (q15_t)0x5554, (q15_t)0xc3a9, (q15_t)0x5549, (q15_t)0xc3a5, + (q15_t)0x553d, (q15_t)0xc3a0, (q15_t)0x5531, (q15_t)0xc39c, (q15_t)0x5525, + (q15_t)0xc398, (q15_t)0x5519, (q15_t)0xc394, (q15_t)0x550d, (q15_t)0xc390, + (q15_t)0x5501, (q15_t)0xc38c, (q15_t)0x54f6, (q15_t)0xc387, (q15_t)0x54ea, + (q15_t)0xc383, (q15_t)0x54de, (q15_t)0xc37f, (q15_t)0x54d2, (q15_t)0xc37b, + (q15_t)0x54c6, (q15_t)0xc377, (q15_t)0x54ba, (q15_t)0xc373, (q15_t)0x54ae, + (q15_t)0xc36f, (q15_t)0x54a2, (q15_t)0xc36b, (q15_t)0x5496, (q15_t)0xc367, + (q15_t)0x548b, (q15_t)0xc363, (q15_t)0x547f, (q15_t)0xc35f, (q15_t)0x5473, + (q15_t)0xc35b, (q15_t)0x5467, (q15_t)0xc357, (q15_t)0x545b, (q15_t)0xc353, + (q15_t)0x544f, (q15_t)0xc34f, (q15_t)0x5443, (q15_t)0xc34b, (q15_t)0x5437, + (q15_t)0xc347, (q15_t)0x542b, (q15_t)0xc343, (q15_t)0x541f, (q15_t)0xc33f, + (q15_t)0x5413, (q15_t)0xc33b, (q15_t)0x5407, (q15_t)0xc337, (q15_t)0x53fb, + (q15_t)0xc333, (q15_t)0x53f0, (q15_t)0xc32f, (q15_t)0x53e4, (q15_t)0xc32b, + (q15_t)0x53d8, (q15_t)0xc327, (q15_t)0x53cc, (q15_t)0xc323, (q15_t)0x53c0, + (q15_t)0xc320, (q15_t)0x53b4, (q15_t)0xc31c, (q15_t)0x53a8, (q15_t)0xc318, + (q15_t)0x539c, (q15_t)0xc314, (q15_t)0x5390, (q15_t)0xc310, (q15_t)0x5384, + (q15_t)0xc30c, (q15_t)0x5378, (q15_t)0xc308, (q15_t)0x536c, (q15_t)0xc305, + (q15_t)0x5360, (q15_t)0xc301, (q15_t)0x5354, (q15_t)0xc2fd, (q15_t)0x5348, + (q15_t)0xc2f9, (q15_t)0x533c, (q15_t)0xc2f5, (q15_t)0x5330, (q15_t)0xc2f2, + (q15_t)0x5324, (q15_t)0xc2ee, (q15_t)0x5318, (q15_t)0xc2ea, (q15_t)0x530c, + (q15_t)0xc2e6, (q15_t)0x5300, (q15_t)0xc2e3, (q15_t)0x52f4, (q15_t)0xc2df, + (q15_t)0x52e8, (q15_t)0xc2db, (q15_t)0x52dc, (q15_t)0xc2d8, (q15_t)0x52d0, + (q15_t)0xc2d4, (q15_t)0x52c4, (q15_t)0xc2d0, (q15_t)0x52b8, (q15_t)0xc2cc, + (q15_t)0x52ac, (q15_t)0xc2c9, (q15_t)0x52a0, (q15_t)0xc2c5, (q15_t)0x5294, + (q15_t)0xc2c1, (q15_t)0x5288, (q15_t)0xc2be, (q15_t)0x527c, (q15_t)0xc2ba, + (q15_t)0x5270, (q15_t)0xc2b7, (q15_t)0x5264, (q15_t)0xc2b3, (q15_t)0x5258, + (q15_t)0xc2af, (q15_t)0x524c, (q15_t)0xc2ac, (q15_t)0x5240, (q15_t)0xc2a8, + (q15_t)0x5234, (q15_t)0xc2a5, (q15_t)0x5228, (q15_t)0xc2a1, (q15_t)0x521c, + (q15_t)0xc29d, (q15_t)0x5210, (q15_t)0xc29a, (q15_t)0x5204, (q15_t)0xc296, + (q15_t)0x51f7, (q15_t)0xc293, (q15_t)0x51eb, (q15_t)0xc28f, (q15_t)0x51df, + (q15_t)0xc28c, (q15_t)0x51d3, (q15_t)0xc288, (q15_t)0x51c7, (q15_t)0xc285, + (q15_t)0x51bb, (q15_t)0xc281, (q15_t)0x51af, (q15_t)0xc27e, (q15_t)0x51a3, + (q15_t)0xc27a, (q15_t)0x5197, (q15_t)0xc277, (q15_t)0x518b, (q15_t)0xc273, + (q15_t)0x517f, (q15_t)0xc270, (q15_t)0x5173, (q15_t)0xc26d, (q15_t)0x5167, + (q15_t)0xc269, (q15_t)0x515a, (q15_t)0xc266, (q15_t)0x514e, (q15_t)0xc262, + (q15_t)0x5142, (q15_t)0xc25f, (q15_t)0x5136, (q15_t)0xc25c, (q15_t)0x512a, + (q15_t)0xc258, (q15_t)0x511e, (q15_t)0xc255, (q15_t)0x5112, (q15_t)0xc251, + (q15_t)0x5106, (q15_t)0xc24e, (q15_t)0x50fa, (q15_t)0xc24b, (q15_t)0x50ed, + (q15_t)0xc247, (q15_t)0x50e1, (q15_t)0xc244, (q15_t)0x50d5, (q15_t)0xc241, + (q15_t)0x50c9, (q15_t)0xc23e, (q15_t)0x50bd, (q15_t)0xc23a, (q15_t)0x50b1, + (q15_t)0xc237, (q15_t)0x50a5, (q15_t)0xc234, (q15_t)0x5099, (q15_t)0xc230, + (q15_t)0x508c, (q15_t)0xc22d, (q15_t)0x5080, (q15_t)0xc22a, (q15_t)0x5074, + (q15_t)0xc227, (q15_t)0x5068, (q15_t)0xc223, (q15_t)0x505c, (q15_t)0xc220, + (q15_t)0x5050, (q15_t)0xc21d, (q15_t)0x5044, (q15_t)0xc21a, (q15_t)0x5037, + (q15_t)0xc217, (q15_t)0x502b, (q15_t)0xc213, (q15_t)0x501f, (q15_t)0xc210, + (q15_t)0x5013, (q15_t)0xc20d, (q15_t)0x5007, (q15_t)0xc20a, (q15_t)0x4ffb, + (q15_t)0xc207, (q15_t)0x4fee, (q15_t)0xc204, (q15_t)0x4fe2, (q15_t)0xc201, + (q15_t)0x4fd6, (q15_t)0xc1fd, (q15_t)0x4fca, (q15_t)0xc1fa, (q15_t)0x4fbe, + (q15_t)0xc1f7, (q15_t)0x4fb2, (q15_t)0xc1f4, (q15_t)0x4fa5, (q15_t)0xc1f1, + (q15_t)0x4f99, (q15_t)0xc1ee, (q15_t)0x4f8d, (q15_t)0xc1eb, (q15_t)0x4f81, + (q15_t)0xc1e8, (q15_t)0x4f75, (q15_t)0xc1e5, (q15_t)0x4f68, (q15_t)0xc1e2, + (q15_t)0x4f5c, (q15_t)0xc1df, (q15_t)0x4f50, (q15_t)0xc1dc, (q15_t)0x4f44, + (q15_t)0xc1d9, (q15_t)0x4f38, (q15_t)0xc1d6, (q15_t)0x4f2b, (q15_t)0xc1d3, + (q15_t)0x4f1f, (q15_t)0xc1d0, (q15_t)0x4f13, (q15_t)0xc1cd, (q15_t)0x4f07, + (q15_t)0xc1ca, (q15_t)0x4efb, (q15_t)0xc1c7, (q15_t)0x4eee, (q15_t)0xc1c4, + (q15_t)0x4ee2, (q15_t)0xc1c1, (q15_t)0x4ed6, (q15_t)0xc1be, (q15_t)0x4eca, + (q15_t)0xc1bb, (q15_t)0x4ebd, (q15_t)0xc1b8, (q15_t)0x4eb1, (q15_t)0xc1b6, + (q15_t)0x4ea5, (q15_t)0xc1b3, (q15_t)0x4e99, (q15_t)0xc1b0, (q15_t)0x4e8c, + (q15_t)0xc1ad, (q15_t)0x4e80, (q15_t)0xc1aa, (q15_t)0x4e74, (q15_t)0xc1a7, + (q15_t)0x4e68, (q15_t)0xc1a4, (q15_t)0x4e5c, (q15_t)0xc1a2, (q15_t)0x4e4f, + (q15_t)0xc19f, (q15_t)0x4e43, (q15_t)0xc19c, (q15_t)0x4e37, (q15_t)0xc199, + (q15_t)0x4e2b, (q15_t)0xc196, (q15_t)0x4e1e, (q15_t)0xc194, (q15_t)0x4e12, + (q15_t)0xc191, (q15_t)0x4e06, (q15_t)0xc18e, (q15_t)0x4df9, (q15_t)0xc18b, + (q15_t)0x4ded, (q15_t)0xc189, (q15_t)0x4de1, (q15_t)0xc186, (q15_t)0x4dd5, + (q15_t)0xc183, (q15_t)0x4dc8, (q15_t)0xc180, (q15_t)0x4dbc, (q15_t)0xc17e, + (q15_t)0x4db0, (q15_t)0xc17b, (q15_t)0x4da4, (q15_t)0xc178, (q15_t)0x4d97, + (q15_t)0xc176, (q15_t)0x4d8b, (q15_t)0xc173, (q15_t)0x4d7f, (q15_t)0xc170, + (q15_t)0x4d72, (q15_t)0xc16e, (q15_t)0x4d66, (q15_t)0xc16b, (q15_t)0x4d5a, + (q15_t)0xc168, (q15_t)0x4d4e, (q15_t)0xc166, (q15_t)0x4d41, (q15_t)0xc163, + (q15_t)0x4d35, (q15_t)0xc161, (q15_t)0x4d29, (q15_t)0xc15e, (q15_t)0x4d1c, + (q15_t)0xc15b, (q15_t)0x4d10, (q15_t)0xc159, (q15_t)0x4d04, (q15_t)0xc156, + (q15_t)0x4cf8, (q15_t)0xc154, (q15_t)0x4ceb, (q15_t)0xc151, (q15_t)0x4cdf, + (q15_t)0xc14f, (q15_t)0x4cd3, (q15_t)0xc14c, (q15_t)0x4cc6, (q15_t)0xc14a, + (q15_t)0x4cba, (q15_t)0xc147, (q15_t)0x4cae, (q15_t)0xc145, (q15_t)0x4ca1, + (q15_t)0xc142, (q15_t)0x4c95, (q15_t)0xc140, (q15_t)0x4c89, (q15_t)0xc13d, + (q15_t)0x4c7c, (q15_t)0xc13b, (q15_t)0x4c70, (q15_t)0xc138, (q15_t)0x4c64, + (q15_t)0xc136, (q15_t)0x4c57, (q15_t)0xc134, (q15_t)0x4c4b, (q15_t)0xc131, + (q15_t)0x4c3f, (q15_t)0xc12f, (q15_t)0x4c32, (q15_t)0xc12c, (q15_t)0x4c26, + (q15_t)0xc12a, (q15_t)0x4c1a, (q15_t)0xc128, (q15_t)0x4c0d, (q15_t)0xc125, + (q15_t)0x4c01, (q15_t)0xc123, (q15_t)0x4bf5, (q15_t)0xc120, (q15_t)0x4be8, + (q15_t)0xc11e, (q15_t)0x4bdc, (q15_t)0xc11c, (q15_t)0x4bd0, (q15_t)0xc119, + (q15_t)0x4bc3, (q15_t)0xc117, (q15_t)0x4bb7, (q15_t)0xc115, (q15_t)0x4bab, + (q15_t)0xc113, (q15_t)0x4b9e, (q15_t)0xc110, (q15_t)0x4b92, (q15_t)0xc10e, + (q15_t)0x4b85, (q15_t)0xc10c, (q15_t)0x4b79, (q15_t)0xc109, (q15_t)0x4b6d, + (q15_t)0xc107, (q15_t)0x4b60, (q15_t)0xc105, (q15_t)0x4b54, (q15_t)0xc103, + (q15_t)0x4b48, (q15_t)0xc100, (q15_t)0x4b3b, (q15_t)0xc0fe, (q15_t)0x4b2f, + (q15_t)0xc0fc, (q15_t)0x4b23, (q15_t)0xc0fa, (q15_t)0x4b16, (q15_t)0xc0f8, + (q15_t)0x4b0a, (q15_t)0xc0f6, (q15_t)0x4afd, (q15_t)0xc0f3, (q15_t)0x4af1, + (q15_t)0xc0f1, (q15_t)0x4ae5, (q15_t)0xc0ef, (q15_t)0x4ad8, (q15_t)0xc0ed, + (q15_t)0x4acc, (q15_t)0xc0eb, (q15_t)0x4ac0, (q15_t)0xc0e9, (q15_t)0x4ab3, + (q15_t)0xc0e7, (q15_t)0x4aa7, (q15_t)0xc0e4, (q15_t)0x4a9a, (q15_t)0xc0e2, + (q15_t)0x4a8e, (q15_t)0xc0e0, (q15_t)0x4a82, (q15_t)0xc0de, (q15_t)0x4a75, + (q15_t)0xc0dc, (q15_t)0x4a69, (q15_t)0xc0da, (q15_t)0x4a5c, (q15_t)0xc0d8, + (q15_t)0x4a50, (q15_t)0xc0d6, (q15_t)0x4a44, (q15_t)0xc0d4, (q15_t)0x4a37, + (q15_t)0xc0d2, (q15_t)0x4a2b, (q15_t)0xc0d0, (q15_t)0x4a1e, (q15_t)0xc0ce, + (q15_t)0x4a12, (q15_t)0xc0cc, (q15_t)0x4a06, (q15_t)0xc0ca, (q15_t)0x49f9, + (q15_t)0xc0c8, (q15_t)0x49ed, (q15_t)0xc0c6, (q15_t)0x49e0, (q15_t)0xc0c4, + (q15_t)0x49d4, (q15_t)0xc0c2, (q15_t)0x49c7, (q15_t)0xc0c0, (q15_t)0x49bb, + (q15_t)0xc0be, (q15_t)0x49af, (q15_t)0xc0bd, (q15_t)0x49a2, (q15_t)0xc0bb, + (q15_t)0x4996, (q15_t)0xc0b9, (q15_t)0x4989, (q15_t)0xc0b7, (q15_t)0x497d, + (q15_t)0xc0b5, (q15_t)0x4970, (q15_t)0xc0b3, (q15_t)0x4964, (q15_t)0xc0b1, + (q15_t)0x4958, (q15_t)0xc0af, (q15_t)0x494b, (q15_t)0xc0ae, (q15_t)0x493f, + (q15_t)0xc0ac, (q15_t)0x4932, (q15_t)0xc0aa, (q15_t)0x4926, (q15_t)0xc0a8, + (q15_t)0x4919, (q15_t)0xc0a6, (q15_t)0x490d, (q15_t)0xc0a5, (q15_t)0x4901, + (q15_t)0xc0a3, (q15_t)0x48f4, (q15_t)0xc0a1, (q15_t)0x48e8, (q15_t)0xc09f, + (q15_t)0x48db, (q15_t)0xc09e, (q15_t)0x48cf, (q15_t)0xc09c, (q15_t)0x48c2, + (q15_t)0xc09a, (q15_t)0x48b6, (q15_t)0xc098, (q15_t)0x48a9, (q15_t)0xc097, + (q15_t)0x489d, (q15_t)0xc095, (q15_t)0x4891, (q15_t)0xc093, (q15_t)0x4884, + (q15_t)0xc092, (q15_t)0x4878, (q15_t)0xc090, (q15_t)0x486b, (q15_t)0xc08e, + (q15_t)0x485f, (q15_t)0xc08d, (q15_t)0x4852, (q15_t)0xc08b, (q15_t)0x4846, + (q15_t)0xc089, (q15_t)0x4839, (q15_t)0xc088, (q15_t)0x482d, (q15_t)0xc086, + (q15_t)0x4820, (q15_t)0xc085, (q15_t)0x4814, (q15_t)0xc083, (q15_t)0x4807, + (q15_t)0xc081, (q15_t)0x47fb, (q15_t)0xc080, (q15_t)0x47ef, (q15_t)0xc07e, + (q15_t)0x47e2, (q15_t)0xc07d, (q15_t)0x47d6, (q15_t)0xc07b, (q15_t)0x47c9, + (q15_t)0xc07a, (q15_t)0x47bd, (q15_t)0xc078, (q15_t)0x47b0, (q15_t)0xc077, + (q15_t)0x47a4, (q15_t)0xc075, (q15_t)0x4797, (q15_t)0xc074, (q15_t)0x478b, + (q15_t)0xc072, (q15_t)0x477e, (q15_t)0xc071, (q15_t)0x4772, (q15_t)0xc06f, + (q15_t)0x4765, (q15_t)0xc06e, (q15_t)0x4759, (q15_t)0xc06c, (q15_t)0x474c, + (q15_t)0xc06b, (q15_t)0x4740, (q15_t)0xc069, (q15_t)0x4733, (q15_t)0xc068, + (q15_t)0x4727, (q15_t)0xc067, (q15_t)0x471a, (q15_t)0xc065, (q15_t)0x470e, + (q15_t)0xc064, (q15_t)0x4701, (q15_t)0xc062, (q15_t)0x46f5, (q15_t)0xc061, + (q15_t)0x46e8, (q15_t)0xc060, (q15_t)0x46dc, (q15_t)0xc05e, (q15_t)0x46cf, + (q15_t)0xc05d, (q15_t)0x46c3, (q15_t)0xc05c, (q15_t)0x46b6, (q15_t)0xc05a, + (q15_t)0x46aa, (q15_t)0xc059, (q15_t)0x469d, (q15_t)0xc058, (q15_t)0x4691, + (q15_t)0xc056, (q15_t)0x4684, (q15_t)0xc055, (q15_t)0x4678, (q15_t)0xc054, + (q15_t)0x466b, (q15_t)0xc053, (q15_t)0x465f, (q15_t)0xc051, (q15_t)0x4652, + (q15_t)0xc050, (q15_t)0x4646, (q15_t)0xc04f, (q15_t)0x4639, (q15_t)0xc04e, + (q15_t)0x462d, (q15_t)0xc04c, (q15_t)0x4620, (q15_t)0xc04b, (q15_t)0x4614, + (q15_t)0xc04a, (q15_t)0x4607, (q15_t)0xc049, (q15_t)0x45fb, (q15_t)0xc048, + (q15_t)0x45ee, (q15_t)0xc047, (q15_t)0x45e2, (q15_t)0xc045, (q15_t)0x45d5, + (q15_t)0xc044, (q15_t)0x45c9, (q15_t)0xc043, (q15_t)0x45bc, (q15_t)0xc042, + (q15_t)0x45b0, (q15_t)0xc041, (q15_t)0x45a3, (q15_t)0xc040, (q15_t)0x4597, + (q15_t)0xc03f, (q15_t)0x458a, (q15_t)0xc03d, (q15_t)0x457e, (q15_t)0xc03c, + (q15_t)0x4571, (q15_t)0xc03b, (q15_t)0x4565, (q15_t)0xc03a, (q15_t)0x4558, + (q15_t)0xc039, (q15_t)0x454c, (q15_t)0xc038, (q15_t)0x453f, (q15_t)0xc037, + (q15_t)0x4533, (q15_t)0xc036, (q15_t)0x4526, (q15_t)0xc035, (q15_t)0x451a, + (q15_t)0xc034, (q15_t)0x450d, (q15_t)0xc033, (q15_t)0x4500, (q15_t)0xc032, + (q15_t)0x44f4, (q15_t)0xc031, (q15_t)0x44e7, (q15_t)0xc030, (q15_t)0x44db, + (q15_t)0xc02f, (q15_t)0x44ce, (q15_t)0xc02e, (q15_t)0x44c2, (q15_t)0xc02d, + (q15_t)0x44b5, (q15_t)0xc02c, (q15_t)0x44a9, (q15_t)0xc02b, (q15_t)0x449c, + (q15_t)0xc02b, (q15_t)0x4490, (q15_t)0xc02a, (q15_t)0x4483, (q15_t)0xc029, + (q15_t)0x4477, (q15_t)0xc028, (q15_t)0x446a, (q15_t)0xc027, (q15_t)0x445e, + (q15_t)0xc026, (q15_t)0x4451, (q15_t)0xc025, (q15_t)0x4444, (q15_t)0xc024, + (q15_t)0x4438, (q15_t)0xc024, (q15_t)0x442b, (q15_t)0xc023, (q15_t)0x441f, + (q15_t)0xc022, (q15_t)0x4412, (q15_t)0xc021, (q15_t)0x4406, (q15_t)0xc020, + (q15_t)0x43f9, (q15_t)0xc020, (q15_t)0x43ed, (q15_t)0xc01f, (q15_t)0x43e0, + (q15_t)0xc01e, (q15_t)0x43d4, (q15_t)0xc01d, (q15_t)0x43c7, (q15_t)0xc01d, + (q15_t)0x43bb, (q15_t)0xc01c, (q15_t)0x43ae, (q15_t)0xc01b, (q15_t)0x43a1, + (q15_t)0xc01a, (q15_t)0x4395, (q15_t)0xc01a, (q15_t)0x4388, (q15_t)0xc019, + (q15_t)0x437c, (q15_t)0xc018, (q15_t)0x436f, (q15_t)0xc018, (q15_t)0x4363, + (q15_t)0xc017, (q15_t)0x4356, (q15_t)0xc016, (q15_t)0x434a, (q15_t)0xc016, + (q15_t)0x433d, (q15_t)0xc015, (q15_t)0x4330, (q15_t)0xc014, (q15_t)0x4324, + (q15_t)0xc014, (q15_t)0x4317, (q15_t)0xc013, (q15_t)0x430b, (q15_t)0xc013, + (q15_t)0x42fe, (q15_t)0xc012, (q15_t)0x42f2, (q15_t)0xc011, (q15_t)0x42e5, + (q15_t)0xc011, (q15_t)0x42d9, (q15_t)0xc010, (q15_t)0x42cc, (q15_t)0xc010, + (q15_t)0x42c0, (q15_t)0xc00f, (q15_t)0x42b3, (q15_t)0xc00f, (q15_t)0x42a6, + (q15_t)0xc00e, (q15_t)0x429a, (q15_t)0xc00e, (q15_t)0x428d, (q15_t)0xc00d, + (q15_t)0x4281, (q15_t)0xc00d, (q15_t)0x4274, (q15_t)0xc00c, (q15_t)0x4268, + (q15_t)0xc00c, (q15_t)0x425b, (q15_t)0xc00b, (q15_t)0x424e, (q15_t)0xc00b, + (q15_t)0x4242, (q15_t)0xc00a, (q15_t)0x4235, (q15_t)0xc00a, (q15_t)0x4229, + (q15_t)0xc009, (q15_t)0x421c, (q15_t)0xc009, (q15_t)0x4210, (q15_t)0xc009, + (q15_t)0x4203, (q15_t)0xc008, (q15_t)0x41f7, (q15_t)0xc008, (q15_t)0x41ea, + (q15_t)0xc007, (q15_t)0x41dd, (q15_t)0xc007, (q15_t)0x41d1, (q15_t)0xc007, + (q15_t)0x41c4, (q15_t)0xc006, (q15_t)0x41b8, (q15_t)0xc006, (q15_t)0x41ab, + (q15_t)0xc006, (q15_t)0x419f, (q15_t)0xc005, (q15_t)0x4192, (q15_t)0xc005, + (q15_t)0x4186, (q15_t)0xc005, (q15_t)0x4179, (q15_t)0xc004, (q15_t)0x416c, + (q15_t)0xc004, (q15_t)0x4160, (q15_t)0xc004, (q15_t)0x4153, (q15_t)0xc004, + (q15_t)0x4147, (q15_t)0xc003, (q15_t)0x413a, (q15_t)0xc003, (q15_t)0x412e, + (q15_t)0xc003, (q15_t)0x4121, (q15_t)0xc003, (q15_t)0x4114, (q15_t)0xc002, + (q15_t)0x4108, (q15_t)0xc002, (q15_t)0x40fb, (q15_t)0xc002, (q15_t)0x40ef, + (q15_t)0xc002, (q15_t)0x40e2, (q15_t)0xc002, (q15_t)0x40d6, (q15_t)0xc001, + (q15_t)0x40c9, (q15_t)0xc001, (q15_t)0x40bc, (q15_t)0xc001, (q15_t)0x40b0, + (q15_t)0xc001, (q15_t)0x40a3, (q15_t)0xc001, (q15_t)0x4097, (q15_t)0xc001, + (q15_t)0x408a, (q15_t)0xc001, (q15_t)0x407e, (q15_t)0xc000, (q15_t)0x4071, + (q15_t)0xc000, (q15_t)0x4065, (q15_t)0xc000, (q15_t)0x4058, (q15_t)0xc000, + (q15_t)0x404b, (q15_t)0xc000, (q15_t)0x403f, (q15_t)0xc000, (q15_t)0x4032, + (q15_t)0xc000, (q15_t)0x4026, (q15_t)0xc000, (q15_t)0x4019, (q15_t)0xc000, + (q15_t)0x400d, (q15_t)0xc000, }; /** @@ -2132,102 +3364,103 @@ const q15_t __ALIGNED(4) realCoefBQ15[8192] = { /** @brief Initialization function for the Q15 RFFT/RIFFT. - @param[in,out] S points to an instance of the Q15 RFFT/RIFFT structure + @param[in,out] S points to an instance of the Q15 RFFT/RIFFT + structure @param[in] fftLenReal length of the FFT @param[in] ifftFlagR flag that selects transform direction - value = 0: forward transform - value = 1: inverse transform - @param[in] bitReverseFlag flag that enables / disables bit reversal of output + @param[in] bitReverseFlag flag that enables / disables bit reversal of + output - value = 0: disables bit reversal of output - value = 1: enables bit reversal of output @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : fftLenReal is not a supported length + - \ref ARM_MATH_ARGUMENT_ERROR : fftLenReal is + not a supported length @par Details - The parameter fftLenReal specifies length of RFFT/RIFFT Process. - Supported FFT Lengths are 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192. + The parameter fftLenReal specifies length of + RFFT/RIFFT Process. Supported FFT Lengths are 32, 64, 128, 256, 512, 1024, + 2048, 4096, 8192. @par - The parameter ifftFlagR controls whether a forward or inverse transform is computed. - Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT is calculated. + The parameter ifftFlagR controls whether a + forward or inverse transform is computed. Set(=1) ifftFlagR to calculate + RIFFT, otherwise RFFT is calculated. @par - The parameter bitReverseFlag controls whether output is in normal order or bit reversed order. - Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order. + The parameter bitReverseFlag controls whether + output is in normal order or bit reversed order. Set(=1) bitReverseFlag for + output to be in normal order otherwise output is in bit reversed order. @par This function also initializes Twiddle factor table. */ -arm_status arm_rfft_init_q15( - arm_rfft_instance_q15 * S, - uint32_t fftLenReal, - uint32_t ifftFlagR, - uint32_t bitReverseFlag) -{ - /* Initialise the default arm status */ - arm_status status = ARM_MATH_SUCCESS; +arm_status arm_rfft_init_q15(arm_rfft_instance_q15 *S, uint32_t fftLenReal, + uint32_t ifftFlagR, uint32_t bitReverseFlag) { + /* Initialise the default arm status */ + arm_status status = ARM_MATH_SUCCESS; - /* Initialize the Real FFT length */ - S->fftLenReal = (uint16_t) fftLenReal; + /* Initialize the Real FFT length */ + S->fftLenReal = (uint16_t)fftLenReal; - /* Initialize the Twiddle coefficientA pointer */ - S->pTwiddleAReal = (q15_t *) realCoefAQ15; + /* Initialize the Twiddle coefficientA pointer */ + S->pTwiddleAReal = (q15_t *)realCoefAQ15; - /* Initialize the Twiddle coefficientB pointer */ - S->pTwiddleBReal = (q15_t *) realCoefBQ15; + /* Initialize the Twiddle coefficientB pointer */ + S->pTwiddleBReal = (q15_t *)realCoefBQ15; - /* Initialize the Flag for selection of RFFT or RIFFT */ - S->ifftFlagR = (uint8_t) ifftFlagR; + /* Initialize the Flag for selection of RFFT or RIFFT */ + S->ifftFlagR = (uint8_t)ifftFlagR; - /* Initialize the Flag for calculation Bit reversal or not */ - S->bitReverseFlagR = (uint8_t) bitReverseFlag; + /* Initialize the Flag for calculation Bit reversal or not */ + S->bitReverseFlagR = (uint8_t)bitReverseFlag; - /* Initialization of coef modifier depending on the FFT length */ - switch (S->fftLenReal) - { - case 8192U: - S->twidCoefRModifier = 1U; - S->pCfft = &arm_cfft_sR_q15_len4096; - break; - case 4096U: - S->twidCoefRModifier = 2U; - S->pCfft = &arm_cfft_sR_q15_len2048; - break; - case 2048U: - S->twidCoefRModifier = 4U; - S->pCfft = &arm_cfft_sR_q15_len1024; - break; - case 1024U: - S->twidCoefRModifier = 8U; - S->pCfft = &arm_cfft_sR_q15_len512; - break; - case 512U: - S->twidCoefRModifier = 16U; - S->pCfft = &arm_cfft_sR_q15_len256; - break; - case 256U: - S->twidCoefRModifier = 32U; - S->pCfft = &arm_cfft_sR_q15_len128; - break; - case 128U: - S->twidCoefRModifier = 64U; - S->pCfft = &arm_cfft_sR_q15_len64; - break; - case 64U: - S->twidCoefRModifier = 128U; - S->pCfft = &arm_cfft_sR_q15_len32; - break; - case 32U: - S->twidCoefRModifier = 256U; - S->pCfft = &arm_cfft_sR_q15_len16; - break; - default: - /* Reporting argument error if rfftSize is not valid value */ - status = ARM_MATH_ARGUMENT_ERROR; - break; - } + /* Initialization of coef modifier depending on the FFT length */ + switch (S->fftLenReal) { + case 8192U: + S->twidCoefRModifier = 1U; + S->pCfft = &arm_cfft_sR_q15_len4096; + break; + case 4096U: + S->twidCoefRModifier = 2U; + S->pCfft = &arm_cfft_sR_q15_len2048; + break; + case 2048U: + S->twidCoefRModifier = 4U; + S->pCfft = &arm_cfft_sR_q15_len1024; + break; + case 1024U: + S->twidCoefRModifier = 8U; + S->pCfft = &arm_cfft_sR_q15_len512; + break; + case 512U: + S->twidCoefRModifier = 16U; + S->pCfft = &arm_cfft_sR_q15_len256; + break; + case 256U: + S->twidCoefRModifier = 32U; + S->pCfft = &arm_cfft_sR_q15_len128; + break; + case 128U: + S->twidCoefRModifier = 64U; + S->pCfft = &arm_cfft_sR_q15_len64; + break; + case 64U: + S->twidCoefRModifier = 128U; + S->pCfft = &arm_cfft_sR_q15_len32; + break; + case 32U: + S->twidCoefRModifier = 256U; + S->pCfft = &arm_cfft_sR_q15_len16; + break; + default: + /* Reporting argument error if rfftSize is not valid value */ + status = ARM_MATH_ARGUMENT_ERROR; + break; + } - /* return the status of RFFT Init function */ - return (status); + /* return the status of RFFT Init function */ + return (status); } /** diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_init_q31.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_init_q31.c index 34cb63d..4b0ad3e 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_init_q31.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_init_q31.c @@ -26,9 +26,9 @@ * limitations under the License. */ -#include "arm_math.h" #include "arm_common_tables.h" #include "arm_const_structs.h" +#include "arm_math.h" /** @ingroup RealFFT @@ -46,8 +46,9 @@ n = 4096
for (i = 0; i < n; i++)
   {
-     pATable[2 * i]     = 0.5 * ( 1.0 - sin (2 * PI / (double) (2 * n) * (double) i));
-     pATable[2 * i + 1] = 0.5 * (-1.0 * cos (2 * PI / (double) (2 * n) * (double) i));
+     pATable[2 * i]     = 0.5 * ( 1.0 - sin (2 * PI / (double) (2 * n) *
+  (double) i)); pATable[2 * i + 1] = 0.5 * (-1.0 * cos (2 * PI / (double) (2 *
+  n) * (double) i));
   }
@par Convert to fixed point Q31 format @@ -607,949 +608,949 @@ const q31_t realCoefAQ31[8192] = { (q31_t)0x102f80f1, (q31_t)0xd5756016, (q31_t)0x1027277e, (q31_t)0xd57ec452, (q31_t)0x101ecfe4, (q31_t)0xd5882a32, (q31_t)0x10167a22, (q31_t)0xd59191b5, (q31_t)0x100e2639, (q31_t)0xd59afadb, (q31_t)0x1005d42a, (q31_t)0xd5a465a3, - (q31_t)0xffd83f4, (q31_t)0xd5add20d, (q31_t)0xff53597, (q31_t)0xd5b74019, - (q31_t)0xfece915, (q31_t)0xd5c0afc6, (q31_t)0xfe49e6d, (q31_t)0xd5ca2115, - (q31_t)0xfdc55a1, (q31_t)0xd5d39403, (q31_t)0xfd40eaf, (q31_t)0xd5dd0892, - (q31_t)0xfcbc999, (q31_t)0xd5e67ec1, (q31_t)0xfc3865e, (q31_t)0xd5eff690, - (q31_t)0xfbb4500, (q31_t)0xd5f96ffd, (q31_t)0xfb3057d, (q31_t)0xd602eb0a, - (q31_t)0xfaac7d8, (q31_t)0xd60c67b4, (q31_t)0xfa28c10, (q31_t)0xd615e5fd, - (q31_t)0xf9a5225, (q31_t)0xd61f65e4, (q31_t)0xf921a17, (q31_t)0xd628e767, - (q31_t)0xf89e3e8, (q31_t)0xd6326a88, (q31_t)0xf81af97, (q31_t)0xd63bef46, - (q31_t)0xf797d24, (q31_t)0xd645759f, (q31_t)0xf714c91, (q31_t)0xd64efd94, - (q31_t)0xf691ddd, (q31_t)0xd6588725, (q31_t)0xf60f108, (q31_t)0xd6621251, - (q31_t)0xf58c613, (q31_t)0xd66b9f18, (q31_t)0xf509cfe, (q31_t)0xd6752d79, - (q31_t)0xf4875ca, (q31_t)0xd67ebd74, (q31_t)0xf405077, (q31_t)0xd6884f09, - (q31_t)0xf382d05, (q31_t)0xd691e237, (q31_t)0xf300b74, (q31_t)0xd69b76fe, - (q31_t)0xf27ebc5, (q31_t)0xd6a50d5d, (q31_t)0xf1fcdf8, (q31_t)0xd6aea555, - (q31_t)0xf17b20d, (q31_t)0xd6b83ee4, (q31_t)0xf0f9805, (q31_t)0xd6c1da0b, - (q31_t)0xf077fe1, (q31_t)0xd6cb76c9, (q31_t)0xeff699f, (q31_t)0xd6d5151d, - (q31_t)0xef75541, (q31_t)0xd6deb508, (q31_t)0xeef42c7, (q31_t)0xd6e85689, - (q31_t)0xee73231, (q31_t)0xd6f1f99f, (q31_t)0xedf2380, (q31_t)0xd6fb9e4b, - (q31_t)0xed716b4, (q31_t)0xd705448b, (q31_t)0xecf0bcd, (q31_t)0xd70eec60, - (q31_t)0xec702cb, (q31_t)0xd71895c9, (q31_t)0xebefbb0, (q31_t)0xd72240c5, - (q31_t)0xeb6f67a, (q31_t)0xd72bed55, (q31_t)0xeaef32b, (q31_t)0xd7359b78, - (q31_t)0xea6f1c2, (q31_t)0xd73f4b2e, (q31_t)0xe9ef241, (q31_t)0xd748fc75, - (q31_t)0xe96f4a7, (q31_t)0xd752af4f, (q31_t)0xe8ef8f4, (q31_t)0xd75c63ba, - (q31_t)0xe86ff2a, (q31_t)0xd76619b6, (q31_t)0xe7f0748, (q31_t)0xd76fd143, - (q31_t)0xe77114e, (q31_t)0xd7798a60, (q31_t)0xe6f1d3d, (q31_t)0xd783450d, - (q31_t)0xe672b16, (q31_t)0xd78d014a, (q31_t)0xe5f3ad8, (q31_t)0xd796bf16, - (q31_t)0xe574c84, (q31_t)0xd7a07e70, (q31_t)0xe4f6019, (q31_t)0xd7aa3f5a, - (q31_t)0xe47759a, (q31_t)0xd7b401d1, (q31_t)0xe3f8d05, (q31_t)0xd7bdc5d6, - (q31_t)0xe37a65b, (q31_t)0xd7c78b68, (q31_t)0xe2fc19c, (q31_t)0xd7d15288, - (q31_t)0xe27dec9, (q31_t)0xd7db1b34, (q31_t)0xe1ffde2, (q31_t)0xd7e4e56c, - (q31_t)0xe181ee8, (q31_t)0xd7eeb130, (q31_t)0xe1041d9, (q31_t)0xd7f87e7f, - (q31_t)0xe0866b8, (q31_t)0xd8024d59, (q31_t)0xe008d84, (q31_t)0xd80c1dbf, - (q31_t)0xdf8b63d, (q31_t)0xd815efae, (q31_t)0xdf0e0e4, (q31_t)0xd81fc328, - (q31_t)0xde90d79, (q31_t)0xd829982b, (q31_t)0xde13bfd, (q31_t)0xd8336eb7, - (q31_t)0xdd96c6f, (q31_t)0xd83d46cc, (q31_t)0xdd19ed0, (q31_t)0xd8472069, - (q31_t)0xdc9d320, (q31_t)0xd850fb8e, (q31_t)0xdc20960, (q31_t)0xd85ad83c, - (q31_t)0xdba4190, (q31_t)0xd864b670, (q31_t)0xdb27bb0, (q31_t)0xd86e962b, - (q31_t)0xdaab7c0, (q31_t)0xd878776d, (q31_t)0xda2f5c2, (q31_t)0xd8825a35, - (q31_t)0xd9b35b4, (q31_t)0xd88c3e83, (q31_t)0xd937798, (q31_t)0xd8962456, - (q31_t)0xd8bbb6d, (q31_t)0xd8a00bae, (q31_t)0xd840134, (q31_t)0xd8a9f48a, - (q31_t)0xd7c48ee, (q31_t)0xd8b3deeb, (q31_t)0xd74929a, (q31_t)0xd8bdcad0, - (q31_t)0xd6cde39, (q31_t)0xd8c7b838, (q31_t)0xd652bcb, (q31_t)0xd8d1a724, - (q31_t)0xd5d7b50, (q31_t)0xd8db9792, (q31_t)0xd55ccca, (q31_t)0xd8e58982, - (q31_t)0xd4e2037, (q31_t)0xd8ef7cf4, (q31_t)0xd467599, (q31_t)0xd8f971e8, - (q31_t)0xd3eccef, (q31_t)0xd903685d, (q31_t)0xd37263a, (q31_t)0xd90d6053, - (q31_t)0xd2f817b, (q31_t)0xd91759c9, (q31_t)0xd27deb0, (q31_t)0xd92154bf, - (q31_t)0xd203ddc, (q31_t)0xd92b5135, (q31_t)0xd189efe, (q31_t)0xd9354f2a, - (q31_t)0xd110216, (q31_t)0xd93f4e9e, (q31_t)0xd096725, (q31_t)0xd9494f90, - (q31_t)0xd01ce2b, (q31_t)0xd9535201, (q31_t)0xcfa3729, (q31_t)0xd95d55ef, - (q31_t)0xcf2a21d, (q31_t)0xd9675b5a, (q31_t)0xceb0f0a, (q31_t)0xd9716243, - (q31_t)0xce37def, (q31_t)0xd97b6aa8, (q31_t)0xcdbeecc, (q31_t)0xd9857489, - (q31_t)0xcd461a2, (q31_t)0xd98f7fe6, (q31_t)0xcccd671, (q31_t)0xd9998cbe, - (q31_t)0xcc54d3a, (q31_t)0xd9a39b11, (q31_t)0xcbdc5fc, (q31_t)0xd9adaadf, - (q31_t)0xcb640b8, (q31_t)0xd9b7bc27, (q31_t)0xcaebd6e, (q31_t)0xd9c1cee9, - (q31_t)0xca73c1e, (q31_t)0xd9cbe325, (q31_t)0xc9fbcca, (q31_t)0xd9d5f8d9, - (q31_t)0xc983f70, (q31_t)0xd9e01006, (q31_t)0xc90c412, (q31_t)0xd9ea28ac, - (q31_t)0xc894aaf, (q31_t)0xd9f442c9, (q31_t)0xc81d349, (q31_t)0xd9fe5e5e, - (q31_t)0xc7a5dde, (q31_t)0xda087b69, (q31_t)0xc72ea70, (q31_t)0xda1299ec, - (q31_t)0xc6b78ff, (q31_t)0xda1cb9e5, (q31_t)0xc64098b, (q31_t)0xda26db54, - (q31_t)0xc5c9c14, (q31_t)0xda30fe38, (q31_t)0xc55309b, (q31_t)0xda3b2292, - (q31_t)0xc4dc720, (q31_t)0xda454860, (q31_t)0xc465fa3, (q31_t)0xda4f6fa3, - (q31_t)0xc3efa25, (q31_t)0xda599859, (q31_t)0xc3796a5, (q31_t)0xda63c284, - (q31_t)0xc303524, (q31_t)0xda6dee21, (q31_t)0xc28d5a3, (q31_t)0xda781b31, - (q31_t)0xc217822, (q31_t)0xda8249b4, (q31_t)0xc1a1ca0, (q31_t)0xda8c79a9, - (q31_t)0xc12c31f, (q31_t)0xda96ab0f, (q31_t)0xc0b6b9e, (q31_t)0xdaa0dde7, - (q31_t)0xc04161e, (q31_t)0xdaab122f, (q31_t)0xbfcc29f, (q31_t)0xdab547e8, - (q31_t)0xbf57121, (q31_t)0xdabf7f11, (q31_t)0xbee21a5, (q31_t)0xdac9b7a9, - (q31_t)0xbe6d42b, (q31_t)0xdad3f1b1, (q31_t)0xbdf88b3, (q31_t)0xdade2d28, - (q31_t)0xbd83f3d, (q31_t)0xdae86a0d, (q31_t)0xbd0f7ca, (q31_t)0xdaf2a860, - (q31_t)0xbc9b25a, (q31_t)0xdafce821, (q31_t)0xbc26eee, (q31_t)0xdb072950, - (q31_t)0xbbb2d85, (q31_t)0xdb116beb, (q31_t)0xbb3ee20, (q31_t)0xdb1baff2, - (q31_t)0xbacb0bf, (q31_t)0xdb25f566, (q31_t)0xba57563, (q31_t)0xdb303c46, - (q31_t)0xb9e3c0b, (q31_t)0xdb3a8491, (q31_t)0xb9704b9, (q31_t)0xdb44ce46, - (q31_t)0xb8fcf6b, (q31_t)0xdb4f1967, (q31_t)0xb889c23, (q31_t)0xdb5965f1, - (q31_t)0xb816ae1, (q31_t)0xdb63b3e5, (q31_t)0xb7a3ba5, (q31_t)0xdb6e0342, - (q31_t)0xb730e70, (q31_t)0xdb785409, (q31_t)0xb6be341, (q31_t)0xdb82a638, - (q31_t)0xb64ba19, (q31_t)0xdb8cf9cf, (q31_t)0xb5d92f8, (q31_t)0xdb974ece, - (q31_t)0xb566ddf, (q31_t)0xdba1a534, (q31_t)0xb4f4acd, (q31_t)0xdbabfd01, - (q31_t)0xb4829c4, (q31_t)0xdbb65634, (q31_t)0xb410ac3, (q31_t)0xdbc0b0ce, - (q31_t)0xb39edca, (q31_t)0xdbcb0cce, (q31_t)0xb32d2da, (q31_t)0xdbd56a32, - (q31_t)0xb2bb9f4, (q31_t)0xdbdfc8fc, (q31_t)0xb24a316, (q31_t)0xdbea292b, - (q31_t)0xb1d8e43, (q31_t)0xdbf48abd, (q31_t)0xb167b79, (q31_t)0xdbfeedb3, - (q31_t)0xb0f6aba, (q31_t)0xdc09520d, (q31_t)0xb085c05, (q31_t)0xdc13b7c9, - (q31_t)0xb014f5b, (q31_t)0xdc1e1ee9, (q31_t)0xafa44bc, (q31_t)0xdc28876a, - (q31_t)0xaf33c28, (q31_t)0xdc32f14d, (q31_t)0xaec35a0, (q31_t)0xdc3d5c91, - (q31_t)0xae53123, (q31_t)0xdc47c936, (q31_t)0xade2eb3, (q31_t)0xdc52373c, - (q31_t)0xad72e4f, (q31_t)0xdc5ca6a2, (q31_t)0xad02ff8, (q31_t)0xdc671768, - (q31_t)0xac933ae, (q31_t)0xdc71898d, (q31_t)0xac23971, (q31_t)0xdc7bfd11, - (q31_t)0xabb4141, (q31_t)0xdc8671f3, (q31_t)0xab44b1f, (q31_t)0xdc90e834, - (q31_t)0xaad570c, (q31_t)0xdc9b5fd2, (q31_t)0xaa66506, (q31_t)0xdca5d8cd, - (q31_t)0xa9f750f, (q31_t)0xdcb05326, (q31_t)0xa988727, (q31_t)0xdcbacedb, - (q31_t)0xa919b4e, (q31_t)0xdcc54bec, (q31_t)0xa8ab184, (q31_t)0xdccfca59, - (q31_t)0xa83c9ca, (q31_t)0xdcda4a21, (q31_t)0xa7ce420, (q31_t)0xdce4cb44, - (q31_t)0xa760086, (q31_t)0xdcef4dc2, (q31_t)0xa6f1efc, (q31_t)0xdcf9d199, - (q31_t)0xa683f83, (q31_t)0xdd0456ca, (q31_t)0xa61621b, (q31_t)0xdd0edd55, - (q31_t)0xa5a86c4, (q31_t)0xdd196538, (q31_t)0xa53ad7e, (q31_t)0xdd23ee74, - (q31_t)0xa4cd64b, (q31_t)0xdd2e7908, (q31_t)0xa460129, (q31_t)0xdd3904f4, - (q31_t)0xa3f2e19, (q31_t)0xdd439236, (q31_t)0xa385d1d, (q31_t)0xdd4e20d0, - (q31_t)0xa318e32, (q31_t)0xdd58b0c0, (q31_t)0xa2ac15b, (q31_t)0xdd634206, - (q31_t)0xa23f698, (q31_t)0xdd6dd4a2, (q31_t)0xa1d2de7, (q31_t)0xdd786892, - (q31_t)0xa16674b, (q31_t)0xdd82fdd8, (q31_t)0xa0fa2c3, (q31_t)0xdd8d9472, - (q31_t)0xa08e04f, (q31_t)0xdd982c60, (q31_t)0xa021fef, (q31_t)0xdda2c5a2, - (q31_t)0x9fb61a5, (q31_t)0xddad6036, (q31_t)0x9f4a570, (q31_t)0xddb7fc1e, - (q31_t)0x9edeb50, (q31_t)0xddc29958, (q31_t)0x9e73346, (q31_t)0xddcd37e4, - (q31_t)0x9e07d51, (q31_t)0xddd7d7c1, (q31_t)0x9d9c973, (q31_t)0xdde278ef, - (q31_t)0x9d317ab, (q31_t)0xdded1b6e, (q31_t)0x9cc67fa, (q31_t)0xddf7bf3e, - (q31_t)0x9c5ba60, (q31_t)0xde02645d, (q31_t)0x9bf0edd, (q31_t)0xde0d0acc, - (q31_t)0x9b86572, (q31_t)0xde17b28a, (q31_t)0x9b1be1e, (q31_t)0xde225b96, - (q31_t)0x9ab18e3, (q31_t)0xde2d05f1, (q31_t)0x9a475bf, (q31_t)0xde37b199, - (q31_t)0x99dd4b4, (q31_t)0xde425e8f, (q31_t)0x99735c2, (q31_t)0xde4d0cd2, - (q31_t)0x99098e9, (q31_t)0xde57bc62, (q31_t)0x989fe29, (q31_t)0xde626d3e, - (q31_t)0x9836582, (q31_t)0xde6d1f65, (q31_t)0x97ccef5, (q31_t)0xde77d2d8, - (q31_t)0x9763a83, (q31_t)0xde828796, (q31_t)0x96fa82a, (q31_t)0xde8d3d9e, - (q31_t)0x96917ec, (q31_t)0xde97f4f1, (q31_t)0x96289c9, (q31_t)0xdea2ad8d, - (q31_t)0x95bfdc1, (q31_t)0xdead6773, (q31_t)0x95573d4, (q31_t)0xdeb822a1, - (q31_t)0x94eec03, (q31_t)0xdec2df18, (q31_t)0x948664d, (q31_t)0xdecd9cd7, - (q31_t)0x941e2b4, (q31_t)0xded85bdd, (q31_t)0x93b6137, (q31_t)0xdee31c2b, - (q31_t)0x934e1d6, (q31_t)0xdeedddc0, (q31_t)0x92e6492, (q31_t)0xdef8a09b, - (q31_t)0x927e96b, (q31_t)0xdf0364bc, (q31_t)0x9217062, (q31_t)0xdf0e2a22, - (q31_t)0x91af976, (q31_t)0xdf18f0ce, (q31_t)0x91484a8, (q31_t)0xdf23b8be, - (q31_t)0x90e11f7, (q31_t)0xdf2e81f3, (q31_t)0x907a166, (q31_t)0xdf394c6b, - (q31_t)0x90132f2, (q31_t)0xdf441828, (q31_t)0x8fac69e, (q31_t)0xdf4ee527, - (q31_t)0x8f45c68, (q31_t)0xdf59b369, (q31_t)0x8edf452, (q31_t)0xdf6482ed, - (q31_t)0x8e78e5b, (q31_t)0xdf6f53b3, (q31_t)0x8e12a84, (q31_t)0xdf7a25ba, - (q31_t)0x8dac8cd, (q31_t)0xdf84f902, (q31_t)0x8d46936, (q31_t)0xdf8fcd8b, - (q31_t)0x8ce0bc0, (q31_t)0xdf9aa354, (q31_t)0x8c7b06b, (q31_t)0xdfa57a5d, - (q31_t)0x8c15736, (q31_t)0xdfb052a5, (q31_t)0x8bb0023, (q31_t)0xdfbb2c2c, - (q31_t)0x8b4ab32, (q31_t)0xdfc606f1, (q31_t)0x8ae5862, (q31_t)0xdfd0e2f5, - (q31_t)0x8a807b4, (q31_t)0xdfdbc036, (q31_t)0x8a1b928, (q31_t)0xdfe69eb4, - (q31_t)0x89b6cbf, (q31_t)0xdff17e70, (q31_t)0x8952278, (q31_t)0xdffc5f67, - (q31_t)0x88eda54, (q31_t)0xe007419b, (q31_t)0x8889454, (q31_t)0xe012250a, - (q31_t)0x8825077, (q31_t)0xe01d09b4, (q31_t)0x87c0ebd, (q31_t)0xe027ef99, - (q31_t)0x875cf28, (q31_t)0xe032d6b8, (q31_t)0x86f91b7, (q31_t)0xe03dbf11, - (q31_t)0x869566a, (q31_t)0xe048a8a4, (q31_t)0x8631d42, (q31_t)0xe053936f, - (q31_t)0x85ce63e, (q31_t)0xe05e7f74, (q31_t)0x856b160, (q31_t)0xe0696cb0, - (q31_t)0x8507ea7, (q31_t)0xe0745b24, (q31_t)0x84a4e14, (q31_t)0xe07f4acf, - (q31_t)0x8441fa6, (q31_t)0xe08a3bb2, (q31_t)0x83df35f, (q31_t)0xe0952dcb, - (q31_t)0x837c93e, (q31_t)0xe0a0211a, (q31_t)0x831a143, (q31_t)0xe0ab159e, - (q31_t)0x82b7b70, (q31_t)0xe0b60b58, (q31_t)0x82557c3, (q31_t)0xe0c10247, - (q31_t)0x81f363d, (q31_t)0xe0cbfa6a, (q31_t)0x81916df, (q31_t)0xe0d6f3c1, - (q31_t)0x812f9a9, (q31_t)0xe0e1ee4b, (q31_t)0x80cde9b, (q31_t)0xe0ecea09, - (q31_t)0x806c5b5, (q31_t)0xe0f7e6f9, (q31_t)0x800aef7, (q31_t)0xe102e51c, - (q31_t)0x7fa9a62, (q31_t)0xe10de470, (q31_t)0x7f487f6, (q31_t)0xe118e4f6, - (q31_t)0x7ee77b3, (q31_t)0xe123e6ad, (q31_t)0x7e8699a, (q31_t)0xe12ee995, - (q31_t)0x7e25daa, (q31_t)0xe139edac, (q31_t)0x7dc53e3, (q31_t)0xe144f2f3, - (q31_t)0x7d64c47, (q31_t)0xe14ff96a, (q31_t)0x7d046d6, (q31_t)0xe15b0110, - (q31_t)0x7ca438f, (q31_t)0xe16609e3, (q31_t)0x7c44272, (q31_t)0xe17113e5, - (q31_t)0x7be4381, (q31_t)0xe17c1f15, (q31_t)0x7b846ba, (q31_t)0xe1872b72, - (q31_t)0x7b24c20, (q31_t)0xe19238fb, (q31_t)0x7ac53b1, (q31_t)0xe19d47b1, - (q31_t)0x7a65d6e, (q31_t)0xe1a85793, (q31_t)0x7a06957, (q31_t)0xe1b368a0, - (q31_t)0x79a776c, (q31_t)0xe1be7ad8, (q31_t)0x79487ae, (q31_t)0xe1c98e3b, - (q31_t)0x78e9a1d, (q31_t)0xe1d4a2c8, (q31_t)0x788aeb9, (q31_t)0xe1dfb87f, - (q31_t)0x782c582, (q31_t)0xe1eacf5f, (q31_t)0x77cde79, (q31_t)0xe1f5e768, - (q31_t)0x776f99d, (q31_t)0xe2010099, (q31_t)0x77116f0, (q31_t)0xe20c1af3, - (q31_t)0x76b3671, (q31_t)0xe2173674, (q31_t)0x7655820, (q31_t)0xe222531c, - (q31_t)0x75f7bfe, (q31_t)0xe22d70eb, (q31_t)0x759a20a, (q31_t)0xe2388fe1, - (q31_t)0x753ca46, (q31_t)0xe243affc, (q31_t)0x74df4b1, (q31_t)0xe24ed13d, - (q31_t)0x748214c, (q31_t)0xe259f3a3, (q31_t)0x7425016, (q31_t)0xe265172e, - (q31_t)0x73c8111, (q31_t)0xe2703bdc, (q31_t)0x736b43c, (q31_t)0xe27b61af, - (q31_t)0x730e997, (q31_t)0xe28688a4, (q31_t)0x72b2123, (q31_t)0xe291b0bd, - (q31_t)0x7255ae0, (q31_t)0xe29cd9f8, (q31_t)0x71f96ce, (q31_t)0xe2a80456, - (q31_t)0x719d4ed, (q31_t)0xe2b32fd4, (q31_t)0x714153e, (q31_t)0xe2be5c74, - (q31_t)0x70e57c0, (q31_t)0xe2c98a35, (q31_t)0x7089c75, (q31_t)0xe2d4b916, - (q31_t)0x702e35c, (q31_t)0xe2dfe917, (q31_t)0x6fd2c75, (q31_t)0xe2eb1a37, - (q31_t)0x6f777c1, (q31_t)0xe2f64c77, (q31_t)0x6f1c540, (q31_t)0xe3017fd5, - (q31_t)0x6ec14f2, (q31_t)0xe30cb451, (q31_t)0x6e666d7, (q31_t)0xe317e9eb, - (q31_t)0x6e0baf0, (q31_t)0xe32320a2, (q31_t)0x6db113d, (q31_t)0xe32e5876, - (q31_t)0x6d569be, (q31_t)0xe3399167, (q31_t)0x6cfc472, (q31_t)0xe344cb73, - (q31_t)0x6ca215c, (q31_t)0xe350069b, (q31_t)0x6c4807a, (q31_t)0xe35b42df, - (q31_t)0x6bee1cd, (q31_t)0xe366803c, (q31_t)0x6b94554, (q31_t)0xe371beb5, - (q31_t)0x6b3ab12, (q31_t)0xe37cfe47, (q31_t)0x6ae1304, (q31_t)0xe3883ef2, - (q31_t)0x6a87d2d, (q31_t)0xe39380b6, (q31_t)0x6a2e98b, (q31_t)0xe39ec393, - (q31_t)0x69d5820, (q31_t)0xe3aa0788, (q31_t)0x697c8eb, (q31_t)0xe3b54c95, - (q31_t)0x6923bec, (q31_t)0xe3c092b9, (q31_t)0x68cb124, (q31_t)0xe3cbd9f4, - (q31_t)0x6872894, (q31_t)0xe3d72245, (q31_t)0x681a23a, (q31_t)0xe3e26bac, - (q31_t)0x67c1e18, (q31_t)0xe3edb628, (q31_t)0x6769c2e, (q31_t)0xe3f901ba, - (q31_t)0x6711c7b, (q31_t)0xe4044e60, (q31_t)0x66b9f01, (q31_t)0xe40f9c1a, - (q31_t)0x66623be, (q31_t)0xe41aeae8, (q31_t)0x660aab5, (q31_t)0xe4263ac9, - (q31_t)0x65b33e4, (q31_t)0xe4318bbe, (q31_t)0x655bf4c, (q31_t)0xe43cddc4, - (q31_t)0x6504ced, (q31_t)0xe44830dd, (q31_t)0x64adcc7, (q31_t)0xe4538507, - (q31_t)0x6456edb, (q31_t)0xe45eda43, (q31_t)0x6400329, (q31_t)0xe46a308f, - (q31_t)0x63a99b1, (q31_t)0xe47587eb, (q31_t)0x6353273, (q31_t)0xe480e057, - (q31_t)0x62fcd6f, (q31_t)0xe48c39d3, (q31_t)0x62a6aa6, (q31_t)0xe497945d, - (q31_t)0x6250a18, (q31_t)0xe4a2eff6, (q31_t)0x61fabc4, (q31_t)0xe4ae4c9d, - (q31_t)0x61a4fac, (q31_t)0xe4b9aa52, (q31_t)0x614f5cf, (q31_t)0xe4c50914, - (q31_t)0x60f9e2e, (q31_t)0xe4d068e2, (q31_t)0x60a48c9, (q31_t)0xe4dbc9bd, - (q31_t)0x604f5a0, (q31_t)0xe4e72ba4, (q31_t)0x5ffa4b3, (q31_t)0xe4f28e96, - (q31_t)0x5fa5603, (q31_t)0xe4fdf294, (q31_t)0x5f5098f, (q31_t)0xe509579b, - (q31_t)0x5efbf58, (q31_t)0xe514bdad, (q31_t)0x5ea775e, (q31_t)0xe52024c9, - (q31_t)0x5e531a1, (q31_t)0xe52b8cee, (q31_t)0x5dfee22, (q31_t)0xe536f61b, - (q31_t)0x5daace1, (q31_t)0xe5426051, (q31_t)0x5d56ddd, (q31_t)0xe54dcb8f, - (q31_t)0x5d03118, (q31_t)0xe55937d5, (q31_t)0x5caf690, (q31_t)0xe564a521, - (q31_t)0x5c5be47, (q31_t)0xe5701374, (q31_t)0x5c0883d, (q31_t)0xe57b82cd, - (q31_t)0x5bb5472, (q31_t)0xe586f32c, (q31_t)0x5b622e6, (q31_t)0xe5926490, - (q31_t)0x5b0f399, (q31_t)0xe59dd6f9, (q31_t)0x5abc68c, (q31_t)0xe5a94a67, - (q31_t)0x5a69bbe, (q31_t)0xe5b4bed8, (q31_t)0x5a17330, (q31_t)0xe5c0344d, - (q31_t)0x59c4ce3, (q31_t)0xe5cbaac5, (q31_t)0x59728d5, (q31_t)0xe5d72240, - (q31_t)0x5920708, (q31_t)0xe5e29abc, (q31_t)0x58ce77c, (q31_t)0xe5ee143b, - (q31_t)0x587ca31, (q31_t)0xe5f98ebb, (q31_t)0x582af26, (q31_t)0xe6050a3b, - (q31_t)0x57d965d, (q31_t)0xe61086bc, (q31_t)0x5787fd6, (q31_t)0xe61c043d, - (q31_t)0x5736b90, (q31_t)0xe62782be, (q31_t)0x56e598c, (q31_t)0xe633023e, - (q31_t)0x56949ca, (q31_t)0xe63e82bc, (q31_t)0x5643c4a, (q31_t)0xe64a0438, - (q31_t)0x55f310d, (q31_t)0xe65586b3, (q31_t)0x55a2812, (q31_t)0xe6610a2a, - (q31_t)0x555215a, (q31_t)0xe66c8e9f, (q31_t)0x5501ce5, (q31_t)0xe6781410, - (q31_t)0x54b1ab4, (q31_t)0xe6839a7c, (q31_t)0x5461ac6, (q31_t)0xe68f21e5, - (q31_t)0x5411d1b, (q31_t)0xe69aaa48, (q31_t)0x53c21b4, (q31_t)0xe6a633a6, - (q31_t)0x5372891, (q31_t)0xe6b1bdff, (q31_t)0x53231b3, (q31_t)0xe6bd4951, - (q31_t)0x52d3d18, (q31_t)0xe6c8d59c, (q31_t)0x5284ac3, (q31_t)0xe6d462e1, - (q31_t)0x5235ab2, (q31_t)0xe6dff11d, (q31_t)0x51e6ce6, (q31_t)0xe6eb8052, - (q31_t)0x519815f, (q31_t)0xe6f7107e, (q31_t)0x514981d, (q31_t)0xe702a1a1, - (q31_t)0x50fb121, (q31_t)0xe70e33bb, (q31_t)0x50acc6b, (q31_t)0xe719c6cb, - (q31_t)0x505e9fb, (q31_t)0xe7255ad1, (q31_t)0x50109d0, (q31_t)0xe730efcc, - (q31_t)0x4fc2bec, (q31_t)0xe73c85bc, (q31_t)0x4f7504e, (q31_t)0xe7481ca1, - (q31_t)0x4f276f7, (q31_t)0xe753b479, (q31_t)0x4ed9fe7, (q31_t)0xe75f4d45, - (q31_t)0x4e8cb1e, (q31_t)0xe76ae704, (q31_t)0x4e3f89c, (q31_t)0xe77681b6, - (q31_t)0x4df2862, (q31_t)0xe7821d59, (q31_t)0x4da5a6f, (q31_t)0xe78db9ef, - (q31_t)0x4d58ec3, (q31_t)0xe7995776, (q31_t)0x4d0c560, (q31_t)0xe7a4f5ed, - (q31_t)0x4cbfe45, (q31_t)0xe7b09555, (q31_t)0x4c73972, (q31_t)0xe7bc35ad, - (q31_t)0x4c276e8, (q31_t)0xe7c7d6f4, (q31_t)0x4bdb6a6, (q31_t)0xe7d3792b, - (q31_t)0x4b8f8ad, (q31_t)0xe7df1c50, (q31_t)0x4b43cfd, (q31_t)0xe7eac063, - (q31_t)0x4af8397, (q31_t)0xe7f66564, (q31_t)0x4aacc7a, (q31_t)0xe8020b52, - (q31_t)0x4a617a6, (q31_t)0xe80db22d, (q31_t)0x4a1651c, (q31_t)0xe81959f4, - (q31_t)0x49cb4dd, (q31_t)0xe82502a7, (q31_t)0x49806e7, (q31_t)0xe830ac45, - (q31_t)0x4935b3c, (q31_t)0xe83c56cf, (q31_t)0x48eb1db, (q31_t)0xe8480243, - (q31_t)0x48a0ac4, (q31_t)0xe853aea1, (q31_t)0x48565f9, (q31_t)0xe85f5be9, - (q31_t)0x480c379, (q31_t)0xe86b0a1a, (q31_t)0x47c2344, (q31_t)0xe876b934, - (q31_t)0x477855a, (q31_t)0xe8826936, (q31_t)0x472e9bc, (q31_t)0xe88e1a20, - (q31_t)0x46e5069, (q31_t)0xe899cbf1, (q31_t)0x469b963, (q31_t)0xe8a57ea9, - (q31_t)0x46524a9, (q31_t)0xe8b13248, (q31_t)0x460923b, (q31_t)0xe8bce6cd, - (q31_t)0x45c0219, (q31_t)0xe8c89c37, (q31_t)0x4577444, (q31_t)0xe8d45286, - (q31_t)0x452e8bc, (q31_t)0xe8e009ba, (q31_t)0x44e5f80, (q31_t)0xe8ebc1d3, - (q31_t)0x449d892, (q31_t)0xe8f77acf, (q31_t)0x44553f2, (q31_t)0xe90334af, - (q31_t)0x440d19e, (q31_t)0xe90eef71, (q31_t)0x43c5199, (q31_t)0xe91aab16, - (q31_t)0x437d3e1, (q31_t)0xe926679c, (q31_t)0x4335877, (q31_t)0xe9322505, - (q31_t)0x42edf5c, (q31_t)0xe93de34e, (q31_t)0x42a688f, (q31_t)0xe949a278, - (q31_t)0x425f410, (q31_t)0xe9556282, (q31_t)0x42181e0, (q31_t)0xe961236c, - (q31_t)0x41d11ff, (q31_t)0xe96ce535, (q31_t)0x418a46d, (q31_t)0xe978a7dd, - (q31_t)0x414392b, (q31_t)0xe9846b63, (q31_t)0x40fd037, (q31_t)0xe9902fc7, - (q31_t)0x40b6994, (q31_t)0xe99bf509, (q31_t)0x4070540, (q31_t)0xe9a7bb28, - (q31_t)0x402a33c, (q31_t)0xe9b38223, (q31_t)0x3fe4388, (q31_t)0xe9bf49fa, - (q31_t)0x3f9e624, (q31_t)0xe9cb12ad, (q31_t)0x3f58b10, (q31_t)0xe9d6dc3b, - (q31_t)0x3f1324e, (q31_t)0xe9e2a6a3, (q31_t)0x3ecdbdc, (q31_t)0xe9ee71e6, - (q31_t)0x3e887bb, (q31_t)0xe9fa3e03, (q31_t)0x3e435ea, (q31_t)0xea060af9, - (q31_t)0x3dfe66c, (q31_t)0xea11d8c8, (q31_t)0x3db993e, (q31_t)0xea1da770, - (q31_t)0x3d74e62, (q31_t)0xea2976ef, (q31_t)0x3d305d8, (q31_t)0xea354746, - (q31_t)0x3cebfa0, (q31_t)0xea411874, (q31_t)0x3ca7bba, (q31_t)0xea4cea79, - (q31_t)0x3c63a26, (q31_t)0xea58bd54, (q31_t)0x3c1fae5, (q31_t)0xea649105, - (q31_t)0x3bdbdf6, (q31_t)0xea70658a, (q31_t)0x3b9835a, (q31_t)0xea7c3ae5, - (q31_t)0x3b54b11, (q31_t)0xea881114, (q31_t)0x3b1151b, (q31_t)0xea93e817, - (q31_t)0x3ace178, (q31_t)0xea9fbfed, (q31_t)0x3a8b028, (q31_t)0xeaab9896, - (q31_t)0x3a4812c, (q31_t)0xeab77212, (q31_t)0x3a05484, (q31_t)0xeac34c60, - (q31_t)0x39c2a2f, (q31_t)0xeacf277f, (q31_t)0x398022f, (q31_t)0xeadb0370, - (q31_t)0x393dc82, (q31_t)0xeae6e031, (q31_t)0x38fb92a, (q31_t)0xeaf2bdc3, - (q31_t)0x38b9827, (q31_t)0xeafe9c24, (q31_t)0x3877978, (q31_t)0xeb0a7b54, - (q31_t)0x3835d1e, (q31_t)0xeb165b54, (q31_t)0x37f4319, (q31_t)0xeb223c22, - (q31_t)0x37b2b6a, (q31_t)0xeb2e1dbe, (q31_t)0x377160f, (q31_t)0xeb3a0027, - (q31_t)0x373030a, (q31_t)0xeb45e35d, (q31_t)0x36ef25b, (q31_t)0xeb51c760, - (q31_t)0x36ae401, (q31_t)0xeb5dac2f, (q31_t)0x366d7fd, (q31_t)0xeb6991ca, - (q31_t)0x362ce50, (q31_t)0xeb75782f, (q31_t)0x35ec6f8, (q31_t)0xeb815f60, - (q31_t)0x35ac1f7, (q31_t)0xeb8d475b, (q31_t)0x356bf4d, (q31_t)0xeb99301f, - (q31_t)0x352bef9, (q31_t)0xeba519ad, (q31_t)0x34ec0fc, (q31_t)0xebb10404, - (q31_t)0x34ac556, (q31_t)0xebbcef23, (q31_t)0x346cc07, (q31_t)0xebc8db0b, - (q31_t)0x342d510, (q31_t)0xebd4c7ba, (q31_t)0x33ee070, (q31_t)0xebe0b52f, - (q31_t)0x33aee27, (q31_t)0xebeca36c, (q31_t)0x336fe37, (q31_t)0xebf8926f, - (q31_t)0x333109e, (q31_t)0xec048237, (q31_t)0x32f255e, (q31_t)0xec1072c4, - (q31_t)0x32b3c75, (q31_t)0xec1c6417, (q31_t)0x32755e5, (q31_t)0xec28562d, - (q31_t)0x32371ae, (q31_t)0xec344908, (q31_t)0x31f8fcf, (q31_t)0xec403ca5, - (q31_t)0x31bb049, (q31_t)0xec4c3106, (q31_t)0x317d31c, (q31_t)0xec582629, - (q31_t)0x313f848, (q31_t)0xec641c0e, (q31_t)0x3101fce, (q31_t)0xec7012b5, - (q31_t)0x30c49ad, (q31_t)0xec7c0a1d, (q31_t)0x30875e5, (q31_t)0xec880245, - (q31_t)0x304a477, (q31_t)0xec93fb2e, (q31_t)0x300d563, (q31_t)0xec9ff4d6, - (q31_t)0x2fd08a9, (q31_t)0xecabef3d, (q31_t)0x2f93e4a, (q31_t)0xecb7ea63, - (q31_t)0x2f57644, (q31_t)0xecc3e648, (q31_t)0x2f1b099, (q31_t)0xeccfe2ea, - (q31_t)0x2eded49, (q31_t)0xecdbe04a, (q31_t)0x2ea2c53, (q31_t)0xece7de66, - (q31_t)0x2e66db8, (q31_t)0xecf3dd3f, (q31_t)0x2e2b178, (q31_t)0xecffdcd4, - (q31_t)0x2def794, (q31_t)0xed0bdd25, (q31_t)0x2db400a, (q31_t)0xed17de31, - (q31_t)0x2d78add, (q31_t)0xed23dff7, (q31_t)0x2d3d80a, (q31_t)0xed2fe277, - (q31_t)0x2d02794, (q31_t)0xed3be5b1, (q31_t)0x2cc7979, (q31_t)0xed47e9a5, - (q31_t)0x2c8cdbb, (q31_t)0xed53ee51, (q31_t)0x2c52459, (q31_t)0xed5ff3b5, - (q31_t)0x2c17d52, (q31_t)0xed6bf9d1, (q31_t)0x2bdd8a9, (q31_t)0xed7800a5, - (q31_t)0x2ba365c, (q31_t)0xed84082f, (q31_t)0x2b6966c, (q31_t)0xed901070, - (q31_t)0x2b2f8d8, (q31_t)0xed9c1967, (q31_t)0x2af5da2, (q31_t)0xeda82313, - (q31_t)0x2abc4c9, (q31_t)0xedb42d74, (q31_t)0x2a82e4d, (q31_t)0xedc0388a, - (q31_t)0x2a49a2e, (q31_t)0xedcc4454, (q31_t)0x2a1086d, (q31_t)0xedd850d2, - (q31_t)0x29d790a, (q31_t)0xede45e03, (q31_t)0x299ec05, (q31_t)0xedf06be6, - (q31_t)0x296615d, (q31_t)0xedfc7a7c, (q31_t)0x292d914, (q31_t)0xee0889c4, - (q31_t)0x28f5329, (q31_t)0xee1499bd, (q31_t)0x28bcf9c, (q31_t)0xee20aa67, - (q31_t)0x2884e6e, (q31_t)0xee2cbbc1, (q31_t)0x284cf9f, (q31_t)0xee38cdcb, - (q31_t)0x281532e, (q31_t)0xee44e084, (q31_t)0x27dd91c, (q31_t)0xee50f3ed, - (q31_t)0x27a616a, (q31_t)0xee5d0804, (q31_t)0x276ec16, (q31_t)0xee691cc9, - (q31_t)0x2737922, (q31_t)0xee75323c, (q31_t)0x270088e, (q31_t)0xee81485c, - (q31_t)0x26c9a58, (q31_t)0xee8d5f29, (q31_t)0x2692e83, (q31_t)0xee9976a1, - (q31_t)0x265c50e, (q31_t)0xeea58ec6, (q31_t)0x2625df8, (q31_t)0xeeb1a796, - (q31_t)0x25ef943, (q31_t)0xeebdc110, (q31_t)0x25b96ee, (q31_t)0xeec9db35, - (q31_t)0x25836f9, (q31_t)0xeed5f604, (q31_t)0x254d965, (q31_t)0xeee2117c, - (q31_t)0x2517e31, (q31_t)0xeeee2d9d, (q31_t)0x24e255e, (q31_t)0xeefa4a67, - (q31_t)0x24aceed, (q31_t)0xef0667d9, (q31_t)0x2477adc, (q31_t)0xef1285f2, - (q31_t)0x244292c, (q31_t)0xef1ea4b2, (q31_t)0x240d9de, (q31_t)0xef2ac419, - (q31_t)0x23d8cf1, (q31_t)0xef36e426, (q31_t)0x23a4265, (q31_t)0xef4304d8, - (q31_t)0x236fa3b, (q31_t)0xef4f2630, (q31_t)0x233b473, (q31_t)0xef5b482d, - (q31_t)0x230710d, (q31_t)0xef676ace, (q31_t)0x22d3009, (q31_t)0xef738e12, - (q31_t)0x229f167, (q31_t)0xef7fb1fa, (q31_t)0x226b528, (q31_t)0xef8bd685, - (q31_t)0x2237b4b, (q31_t)0xef97fbb2, (q31_t)0x22043d0, (q31_t)0xefa42181, - (q31_t)0x21d0eb8, (q31_t)0xefb047f2, (q31_t)0x219dc03, (q31_t)0xefbc6f03, - (q31_t)0x216abb1, (q31_t)0xefc896b5, (q31_t)0x2137dc2, (q31_t)0xefd4bf08, - (q31_t)0x2105236, (q31_t)0xefe0e7f9, (q31_t)0x20d290d, (q31_t)0xefed118a, - (q31_t)0x20a0248, (q31_t)0xeff93bba, (q31_t)0x206dde6, (q31_t)0xf0056687, - (q31_t)0x203bbe8, (q31_t)0xf01191f3, (q31_t)0x2009c4e, (q31_t)0xf01dbdfb, - (q31_t)0x1fd7f17, (q31_t)0xf029eaa1, (q31_t)0x1fa6445, (q31_t)0xf03617e2, - (q31_t)0x1f74bd6, (q31_t)0xf04245c0, (q31_t)0x1f435cc, (q31_t)0xf04e7438, - (q31_t)0x1f12227, (q31_t)0xf05aa34c, (q31_t)0x1ee10e5, (q31_t)0xf066d2fa, - (q31_t)0x1eb0209, (q31_t)0xf0730342, (q31_t)0x1e7f591, (q31_t)0xf07f3424, - (q31_t)0x1e4eb7e, (q31_t)0xf08b659f, (q31_t)0x1e1e3d0, (q31_t)0xf09797b2, - (q31_t)0x1dede87, (q31_t)0xf0a3ca5d, (q31_t)0x1dbdba3, (q31_t)0xf0affda0, - (q31_t)0x1d8db25, (q31_t)0xf0bc317a, (q31_t)0x1d5dd0c, (q31_t)0xf0c865ea, - (q31_t)0x1d2e158, (q31_t)0xf0d49af1, (q31_t)0x1cfe80a, (q31_t)0xf0e0d08d, - (q31_t)0x1ccf122, (q31_t)0xf0ed06bf, (q31_t)0x1c9fca0, (q31_t)0xf0f93d86, - (q31_t)0x1c70a84, (q31_t)0xf10574e0, (q31_t)0x1c41ace, (q31_t)0xf111accf, - (q31_t)0x1c12d7e, (q31_t)0xf11de551, (q31_t)0x1be4294, (q31_t)0xf12a1e66, - (q31_t)0x1bb5a11, (q31_t)0xf136580d, (q31_t)0x1b873f5, (q31_t)0xf1429247, - (q31_t)0x1b5903f, (q31_t)0xf14ecd11, (q31_t)0x1b2aef0, (q31_t)0xf15b086d, - (q31_t)0x1afd007, (q31_t)0xf1674459, (q31_t)0x1acf386, (q31_t)0xf17380d6, - (q31_t)0x1aa196c, (q31_t)0xf17fbde2, (q31_t)0x1a741b9, (q31_t)0xf18bfb7d, - (q31_t)0x1a46c6e, (q31_t)0xf19839a6, (q31_t)0x1a1998a, (q31_t)0xf1a4785e, - (q31_t)0x19ec90d, (q31_t)0xf1b0b7a4, (q31_t)0x19bfaf9, (q31_t)0xf1bcf777, - (q31_t)0x1992f4c, (q31_t)0xf1c937d6, (q31_t)0x1966606, (q31_t)0xf1d578c2, - (q31_t)0x1939f29, (q31_t)0xf1e1ba3a, (q31_t)0x190dab4, (q31_t)0xf1edfc3d, - (q31_t)0x18e18a7, (q31_t)0xf1fa3ecb, (q31_t)0x18b5903, (q31_t)0xf20681e3, - (q31_t)0x1889bc6, (q31_t)0xf212c585, (q31_t)0x185e0f3, (q31_t)0xf21f09b1, - (q31_t)0x1832888, (q31_t)0xf22b4e66, (q31_t)0x1807285, (q31_t)0xf23793a3, - (q31_t)0x17dbeec, (q31_t)0xf243d968, (q31_t)0x17b0dbb, (q31_t)0xf2501fb5, - (q31_t)0x1785ef4, (q31_t)0xf25c6688, (q31_t)0x175b296, (q31_t)0xf268ade3, - (q31_t)0x17308a1, (q31_t)0xf274f5c3, (q31_t)0x1706115, (q31_t)0xf2813e2a, - (q31_t)0x16dbbf3, (q31_t)0xf28d8715, (q31_t)0x16b193a, (q31_t)0xf299d085, - (q31_t)0x16878eb, (q31_t)0xf2a61a7a, (q31_t)0x165db05, (q31_t)0xf2b264f2, - (q31_t)0x1633f8a, (q31_t)0xf2beafed, (q31_t)0x160a678, (q31_t)0xf2cafb6b, - (q31_t)0x15e0fd1, (q31_t)0xf2d7476c, (q31_t)0x15b7b94, (q31_t)0xf2e393ef, - (q31_t)0x158e9c1, (q31_t)0xf2efe0f2, (q31_t)0x1565a58, (q31_t)0xf2fc2e77, - (q31_t)0x153cd5a, (q31_t)0xf3087c7d, (q31_t)0x15142c6, (q31_t)0xf314cb02, - (q31_t)0x14eba9d, (q31_t)0xf3211a07, (q31_t)0x14c34df, (q31_t)0xf32d698a, - (q31_t)0x149b18b, (q31_t)0xf339b98d, (q31_t)0x14730a3, (q31_t)0xf3460a0d, - (q31_t)0x144b225, (q31_t)0xf3525b0b, (q31_t)0x1423613, (q31_t)0xf35eac86, - (q31_t)0x13fbc6c, (q31_t)0xf36afe7e, (q31_t)0x13d4530, (q31_t)0xf37750f2, - (q31_t)0x13ad060, (q31_t)0xf383a3e2, (q31_t)0x1385dfb, (q31_t)0xf38ff74d, - (q31_t)0x135ee02, (q31_t)0xf39c4b32, (q31_t)0x1338075, (q31_t)0xf3a89f92, - (q31_t)0x1311553, (q31_t)0xf3b4f46c, (q31_t)0x12eac9d, (q31_t)0xf3c149bf, - (q31_t)0x12c4653, (q31_t)0xf3cd9f8b, (q31_t)0x129e276, (q31_t)0xf3d9f5cf, - (q31_t)0x1278104, (q31_t)0xf3e64c8c, (q31_t)0x12521ff, (q31_t)0xf3f2a3bf, - (q31_t)0x122c566, (q31_t)0xf3fefb6a, (q31_t)0x1206b39, (q31_t)0xf40b538b, - (q31_t)0x11e1379, (q31_t)0xf417ac22, (q31_t)0x11bbe26, (q31_t)0xf424052f, - (q31_t)0x1196b3f, (q31_t)0xf4305eb0, (q31_t)0x1171ac6, (q31_t)0xf43cb8a7, - (q31_t)0x114ccb9, (q31_t)0xf4491311, (q31_t)0x1128119, (q31_t)0xf4556def, - (q31_t)0x11037e6, (q31_t)0xf461c940, (q31_t)0x10df120, (q31_t)0xf46e2504, - (q31_t)0x10bacc8, (q31_t)0xf47a8139, (q31_t)0x1096add, (q31_t)0xf486dde1, - (q31_t)0x1072b5f, (q31_t)0xf4933afa, (q31_t)0x104ee4f, (q31_t)0xf49f9884, - (q31_t)0x102b3ac, (q31_t)0xf4abf67e, (q31_t)0x1007b77, (q31_t)0xf4b854e7, - (q31_t)0xfe45b0, (q31_t)0xf4c4b3c0, (q31_t)0xfc1257, (q31_t)0xf4d11308, - (q31_t)0xf9e16b, (q31_t)0xf4dd72be, (q31_t)0xf7b2ee, (q31_t)0xf4e9d2e3, - (q31_t)0xf586df, (q31_t)0xf4f63374, (q31_t)0xf35d3e, (q31_t)0xf5029473, - (q31_t)0xf1360b, (q31_t)0xf50ef5de, (q31_t)0xef1147, (q31_t)0xf51b57b5, - (q31_t)0xeceef1, (q31_t)0xf527b9f7, (q31_t)0xeacf09, (q31_t)0xf5341ca5, - (q31_t)0xe8b190, (q31_t)0xf5407fbd, (q31_t)0xe69686, (q31_t)0xf54ce33f, - (q31_t)0xe47deb, (q31_t)0xf559472b, (q31_t)0xe267be, (q31_t)0xf565ab80, - (q31_t)0xe05401, (q31_t)0xf572103d, (q31_t)0xde42b2, (q31_t)0xf57e7563, - (q31_t)0xdc33d2, (q31_t)0xf58adaf0, (q31_t)0xda2762, (q31_t)0xf59740e5, - (q31_t)0xd81d61, (q31_t)0xf5a3a740, (q31_t)0xd615cf, (q31_t)0xf5b00e02, - (q31_t)0xd410ad, (q31_t)0xf5bc7529, (q31_t)0xd20dfa, (q31_t)0xf5c8dcb6, - (q31_t)0xd00db6, (q31_t)0xf5d544a7, (q31_t)0xce0fe3, (q31_t)0xf5e1acfd, - (q31_t)0xcc147f, (q31_t)0xf5ee15b7, (q31_t)0xca1b8a, (q31_t)0xf5fa7ed4, - (q31_t)0xc82506, (q31_t)0xf606e854, (q31_t)0xc630f2, (q31_t)0xf6135237, - (q31_t)0xc43f4d, (q31_t)0xf61fbc7b, (q31_t)0xc25019, (q31_t)0xf62c2721, - (q31_t)0xc06355, (q31_t)0xf6389228, (q31_t)0xbe7901, (q31_t)0xf644fd8f, - (q31_t)0xbc911d, (q31_t)0xf6516956, (q31_t)0xbaabaa, (q31_t)0xf65dd57d, - (q31_t)0xb8c8a7, (q31_t)0xf66a4203, (q31_t)0xb6e815, (q31_t)0xf676aee8, - (q31_t)0xb509f3, (q31_t)0xf6831c2b, (q31_t)0xb32e42, (q31_t)0xf68f89cb, - (q31_t)0xb15502, (q31_t)0xf69bf7c9, (q31_t)0xaf7e33, (q31_t)0xf6a86623, - (q31_t)0xada9d4, (q31_t)0xf6b4d4d9, (q31_t)0xabd7e6, (q31_t)0xf6c143ec, - (q31_t)0xaa086a, (q31_t)0xf6cdb359, (q31_t)0xa83b5e, (q31_t)0xf6da2321, - (q31_t)0xa670c4, (q31_t)0xf6e69344, (q31_t)0xa4a89b, (q31_t)0xf6f303c0, - (q31_t)0xa2e2e3, (q31_t)0xf6ff7496, (q31_t)0xa11f9d, (q31_t)0xf70be5c4, - (q31_t)0x9f5ec8, (q31_t)0xf718574b, (q31_t)0x9da065, (q31_t)0xf724c92a, - (q31_t)0x9be473, (q31_t)0xf7313b60, (q31_t)0x9a2af3, (q31_t)0xf73daded, - (q31_t)0x9873e4, (q31_t)0xf74a20d0, (q31_t)0x96bf48, (q31_t)0xf756940a, - (q31_t)0x950d1d, (q31_t)0xf7630799, (q31_t)0x935d64, (q31_t)0xf76f7b7d, - (q31_t)0x91b01d, (q31_t)0xf77befb5, (q31_t)0x900548, (q31_t)0xf7886442, - (q31_t)0x8e5ce5, (q31_t)0xf794d922, (q31_t)0x8cb6f5, (q31_t)0xf7a14e55, - (q31_t)0x8b1376, (q31_t)0xf7adc3db, (q31_t)0x89726a, (q31_t)0xf7ba39b3, - (q31_t)0x87d3d0, (q31_t)0xf7c6afdc, (q31_t)0x8637a9, (q31_t)0xf7d32657, - (q31_t)0x849df4, (q31_t)0xf7df9d22, (q31_t)0x8306b2, (q31_t)0xf7ec143e, - (q31_t)0x8171e2, (q31_t)0xf7f88ba9, (q31_t)0x7fdf85, (q31_t)0xf8050364, - (q31_t)0x7e4f9b, (q31_t)0xf8117b6d, (q31_t)0x7cc223, (q31_t)0xf81df3c5, - (q31_t)0x7b371e, (q31_t)0xf82a6c6a, (q31_t)0x79ae8c, (q31_t)0xf836e55d, - (q31_t)0x78286e, (q31_t)0xf8435e9d, (q31_t)0x76a4c2, (q31_t)0xf84fd829, - (q31_t)0x752389, (q31_t)0xf85c5201, (q31_t)0x73a4c3, (q31_t)0xf868cc24, - (q31_t)0x722871, (q31_t)0xf8754692, (q31_t)0x70ae92, (q31_t)0xf881c14b, - (q31_t)0x6f3726, (q31_t)0xf88e3c4d, (q31_t)0x6dc22e, (q31_t)0xf89ab799, - (q31_t)0x6c4fa8, (q31_t)0xf8a7332e, (q31_t)0x6adf97, (q31_t)0xf8b3af0c, - (q31_t)0x6971f9, (q31_t)0xf8c02b31, (q31_t)0x6806ce, (q31_t)0xf8cca79e, - (q31_t)0x669e18, (q31_t)0xf8d92452, (q31_t)0x6537d4, (q31_t)0xf8e5a14d, - (q31_t)0x63d405, (q31_t)0xf8f21e8e, (q31_t)0x6272aa, (q31_t)0xf8fe9c15, - (q31_t)0x6113c2, (q31_t)0xf90b19e0, (q31_t)0x5fb74e, (q31_t)0xf91797f0, - (q31_t)0x5e5d4e, (q31_t)0xf9241645, (q31_t)0x5d05c3, (q31_t)0xf93094dd, - (q31_t)0x5bb0ab, (q31_t)0xf93d13b8, (q31_t)0x5a5e07, (q31_t)0xf94992d7, - (q31_t)0x590dd8, (q31_t)0xf9561237, (q31_t)0x57c01d, (q31_t)0xf96291d9, - (q31_t)0x5674d6, (q31_t)0xf96f11bc, (q31_t)0x552c03, (q31_t)0xf97b91e1, - (q31_t)0x53e5a5, (q31_t)0xf9881245, (q31_t)0x52a1bb, (q31_t)0xf99492ea, - (q31_t)0x516045, (q31_t)0xf9a113cd, (q31_t)0x502145, (q31_t)0xf9ad94f0, - (q31_t)0x4ee4b8, (q31_t)0xf9ba1651, (q31_t)0x4daaa1, (q31_t)0xf9c697f0, - (q31_t)0x4c72fe, (q31_t)0xf9d319cc, (q31_t)0x4b3dcf, (q31_t)0xf9df9be6, - (q31_t)0x4a0b16, (q31_t)0xf9ec1e3b, (q31_t)0x48dad1, (q31_t)0xf9f8a0cd, - (q31_t)0x47ad01, (q31_t)0xfa05239a, (q31_t)0x4681a6, (q31_t)0xfa11a6a3, - (q31_t)0x4558c0, (q31_t)0xfa1e29e5, (q31_t)0x44324f, (q31_t)0xfa2aad62, - (q31_t)0x430e53, (q31_t)0xfa373119, (q31_t)0x41eccc, (q31_t)0xfa43b508, - (q31_t)0x40cdba, (q31_t)0xfa503930, (q31_t)0x3fb11d, (q31_t)0xfa5cbd91, - (q31_t)0x3e96f6, (q31_t)0xfa694229, (q31_t)0x3d7f44, (q31_t)0xfa75c6f8, - (q31_t)0x3c6a07, (q31_t)0xfa824bfd, (q31_t)0x3b573f, (q31_t)0xfa8ed139, - (q31_t)0x3a46ed, (q31_t)0xfa9b56ab, (q31_t)0x393910, (q31_t)0xfaa7dc52, - (q31_t)0x382da8, (q31_t)0xfab4622d, (q31_t)0x3724b6, (q31_t)0xfac0e83d, - (q31_t)0x361e3a, (q31_t)0xfacd6e81, (q31_t)0x351a33, (q31_t)0xfad9f4f8, - (q31_t)0x3418a2, (q31_t)0xfae67ba2, (q31_t)0x331986, (q31_t)0xfaf3027e, - (q31_t)0x321ce0, (q31_t)0xfaff898c, (q31_t)0x3122b0, (q31_t)0xfb0c10cb, - (q31_t)0x302af5, (q31_t)0xfb18983b, (q31_t)0x2f35b1, (q31_t)0xfb251fdc, - (q31_t)0x2e42e2, (q31_t)0xfb31a7ac, (q31_t)0x2d5289, (q31_t)0xfb3e2fac, - (q31_t)0x2c64a6, (q31_t)0xfb4ab7db, (q31_t)0x2b7939, (q31_t)0xfb574039, - (q31_t)0x2a9042, (q31_t)0xfb63c8c4, (q31_t)0x29a9c1, (q31_t)0xfb70517d, - (q31_t)0x28c5b6, (q31_t)0xfb7cda63, (q31_t)0x27e421, (q31_t)0xfb896375, - (q31_t)0x270502, (q31_t)0xfb95ecb4, (q31_t)0x262859, (q31_t)0xfba2761e, - (q31_t)0x254e27, (q31_t)0xfbaeffb3, (q31_t)0x24766a, (q31_t)0xfbbb8973, - (q31_t)0x23a124, (q31_t)0xfbc8135c, (q31_t)0x22ce54, (q31_t)0xfbd49d70, - (q31_t)0x21fdfb, (q31_t)0xfbe127ac, (q31_t)0x213018, (q31_t)0xfbedb212, - (q31_t)0x2064ab, (q31_t)0xfbfa3c9f, (q31_t)0x1f9bb5, (q31_t)0xfc06c754, - (q31_t)0x1ed535, (q31_t)0xfc135231, (q31_t)0x1e112b, (q31_t)0xfc1fdd34, - (q31_t)0x1d4f99, (q31_t)0xfc2c685d, (q31_t)0x1c907c, (q31_t)0xfc38f3ac, - (q31_t)0x1bd3d6, (q31_t)0xfc457f21, (q31_t)0x1b19a7, (q31_t)0xfc520aba, - (q31_t)0x1a61ee, (q31_t)0xfc5e9678, (q31_t)0x19acac, (q31_t)0xfc6b2259, - (q31_t)0x18f9e1, (q31_t)0xfc77ae5e, (q31_t)0x18498c, (q31_t)0xfc843a85, - (q31_t)0x179bae, (q31_t)0xfc90c6cf, (q31_t)0x16f047, (q31_t)0xfc9d533b, - (q31_t)0x164757, (q31_t)0xfca9dfc8, (q31_t)0x15a0dd, (q31_t)0xfcb66c77, - (q31_t)0x14fcda, (q31_t)0xfcc2f945, (q31_t)0x145b4e, (q31_t)0xfccf8634, - (q31_t)0x13bc39, (q31_t)0xfcdc1342, (q31_t)0x131f9b, (q31_t)0xfce8a06f, - (q31_t)0x128574, (q31_t)0xfcf52dbb, (q31_t)0x11edc3, (q31_t)0xfd01bb24, - (q31_t)0x11588a, (q31_t)0xfd0e48ab, (q31_t)0x10c5c7, (q31_t)0xfd1ad650, - (q31_t)0x10357c, (q31_t)0xfd276410, (q31_t)0xfa7a8, (q31_t)0xfd33f1ed, - (q31_t)0xf1c4a, (q31_t)0xfd407fe6, (q31_t)0xe9364, (q31_t)0xfd4d0df9, - (q31_t)0xe0cf5, (q31_t)0xfd599c28, (q31_t)0xd88fd, (q31_t)0xfd662a70, - (q31_t)0xd077c, (q31_t)0xfd72b8d2, (q31_t)0xc8872, (q31_t)0xfd7f474d, - (q31_t)0xc0be0, (q31_t)0xfd8bd5e1, (q31_t)0xb91c4, (q31_t)0xfd98648d, - (q31_t)0xb1a20, (q31_t)0xfda4f351, (q31_t)0xaa4f3, (q31_t)0xfdb1822c, - (q31_t)0xa323d, (q31_t)0xfdbe111e, (q31_t)0x9c1ff, (q31_t)0xfdcaa027, - (q31_t)0x95438, (q31_t)0xfdd72f45, (q31_t)0x8e8e8, (q31_t)0xfde3be78, - (q31_t)0x8800f, (q31_t)0xfdf04dc0, (q31_t)0x819ae, (q31_t)0xfdfcdd1d, - (q31_t)0x7b5c4, (q31_t)0xfe096c8d, (q31_t)0x75452, (q31_t)0xfe15fc11, - (q31_t)0x6f556, (q31_t)0xfe228ba7, (q31_t)0x698d3, (q31_t)0xfe2f1b50, - (q31_t)0x63ec6, (q31_t)0xfe3bab0b, (q31_t)0x5e731, (q31_t)0xfe483ad8, - (q31_t)0x59214, (q31_t)0xfe54cab5, (q31_t)0x53f6e, (q31_t)0xfe615aa3, - (q31_t)0x4ef3f, (q31_t)0xfe6deaa1, (q31_t)0x4a188, (q31_t)0xfe7a7aae, - (q31_t)0x45648, (q31_t)0xfe870aca, (q31_t)0x40d80, (q31_t)0xfe939af5, - (q31_t)0x3c72f, (q31_t)0xfea02b2e, (q31_t)0x38356, (q31_t)0xfeacbb74, - (q31_t)0x341f4, (q31_t)0xfeb94bc8, (q31_t)0x3030a, (q31_t)0xfec5dc28, - (q31_t)0x2c697, (q31_t)0xfed26c94, (q31_t)0x28c9c, (q31_t)0xfedefd0c, - (q31_t)0x25519, (q31_t)0xfeeb8d8f, (q31_t)0x2200d, (q31_t)0xfef81e1d, - (q31_t)0x1ed78, (q31_t)0xff04aeb5, (q31_t)0x1bd5c, (q31_t)0xff113f56, - (q31_t)0x18fb6, (q31_t)0xff1dd001, (q31_t)0x16489, (q31_t)0xff2a60b4, - (q31_t)0x13bd3, (q31_t)0xff36f170, (q31_t)0x11594, (q31_t)0xff438234, - (q31_t)0xf1ce, (q31_t)0xff5012fe, (q31_t)0xd07e, (q31_t)0xff5ca3d0, - (q31_t)0xb1a7, (q31_t)0xff6934a8, (q31_t)0x9547, (q31_t)0xff75c585, - (q31_t)0x7b5f, (q31_t)0xff825668, (q31_t)0x63ee, (q31_t)0xff8ee750, - (q31_t)0x4ef5, (q31_t)0xff9b783c, (q31_t)0x3c74, (q31_t)0xffa8092c, - (q31_t)0x2c6a, (q31_t)0xffb49a1f, (q31_t)0x1ed8, (q31_t)0xffc12b16, - (q31_t)0x13bd, (q31_t)0xffcdbc0f, (q31_t)0xb1a, (q31_t)0xffda4d09, - (q31_t)0x4ef, (q31_t)0xffe6de05, (q31_t)0x13c, (q31_t)0xfff36f02, - (q31_t)0x0, (q31_t)0x0, (q31_t)0x13c, (q31_t)0xc90fe, - (q31_t)0x4ef, (q31_t)0x1921fb, (q31_t)0xb1a, (q31_t)0x25b2f7, - (q31_t)0x13bd, (q31_t)0x3243f1, (q31_t)0x1ed8, (q31_t)0x3ed4ea, - (q31_t)0x2c6a, (q31_t)0x4b65e1, (q31_t)0x3c74, (q31_t)0x57f6d4, - (q31_t)0x4ef5, (q31_t)0x6487c4, (q31_t)0x63ee, (q31_t)0x7118b0, - (q31_t)0x7b5f, (q31_t)0x7da998, (q31_t)0x9547, (q31_t)0x8a3a7b, - (q31_t)0xb1a7, (q31_t)0x96cb58, (q31_t)0xd07e, (q31_t)0xa35c30, - (q31_t)0xf1ce, (q31_t)0xafed02, (q31_t)0x11594, (q31_t)0xbc7dcc, - (q31_t)0x13bd3, (q31_t)0xc90e90, (q31_t)0x16489, (q31_t)0xd59f4c, - (q31_t)0x18fb6, (q31_t)0xe22fff, (q31_t)0x1bd5c, (q31_t)0xeec0aa, - (q31_t)0x1ed78, (q31_t)0xfb514b, (q31_t)0x2200d, (q31_t)0x107e1e3, - (q31_t)0x25519, (q31_t)0x1147271, (q31_t)0x28c9c, (q31_t)0x12102f4, - (q31_t)0x2c697, (q31_t)0x12d936c, (q31_t)0x3030a, (q31_t)0x13a23d8, - (q31_t)0x341f4, (q31_t)0x146b438, (q31_t)0x38356, (q31_t)0x153448c, - (q31_t)0x3c72f, (q31_t)0x15fd4d2, (q31_t)0x40d80, (q31_t)0x16c650b, - (q31_t)0x45648, (q31_t)0x178f536, (q31_t)0x4a188, (q31_t)0x1858552, - (q31_t)0x4ef3f, (q31_t)0x192155f, (q31_t)0x53f6e, (q31_t)0x19ea55d, - (q31_t)0x59214, (q31_t)0x1ab354b, (q31_t)0x5e731, (q31_t)0x1b7c528, - (q31_t)0x63ec6, (q31_t)0x1c454f5, (q31_t)0x698d3, (q31_t)0x1d0e4b0, - (q31_t)0x6f556, (q31_t)0x1dd7459, (q31_t)0x75452, (q31_t)0x1ea03ef, - (q31_t)0x7b5c4, (q31_t)0x1f69373, (q31_t)0x819ae, (q31_t)0x20322e3, - (q31_t)0x8800f, (q31_t)0x20fb240, (q31_t)0x8e8e8, (q31_t)0x21c4188, - (q31_t)0x95438, (q31_t)0x228d0bb, (q31_t)0x9c1ff, (q31_t)0x2355fd9, - (q31_t)0xa323d, (q31_t)0x241eee2, (q31_t)0xaa4f3, (q31_t)0x24e7dd4, - (q31_t)0xb1a20, (q31_t)0x25b0caf, (q31_t)0xb91c4, (q31_t)0x2679b73, - (q31_t)0xc0be0, (q31_t)0x2742a1f, (q31_t)0xc8872, (q31_t)0x280b8b3, - (q31_t)0xd077c, (q31_t)0x28d472e, (q31_t)0xd88fd, (q31_t)0x299d590, - (q31_t)0xe0cf5, (q31_t)0x2a663d8, (q31_t)0xe9364, (q31_t)0x2b2f207, - (q31_t)0xf1c4a, (q31_t)0x2bf801a, (q31_t)0xfa7a8, (q31_t)0x2cc0e13, - (q31_t)0x10357c, (q31_t)0x2d89bf0, (q31_t)0x10c5c7, (q31_t)0x2e529b0, - (q31_t)0x11588a, (q31_t)0x2f1b755, (q31_t)0x11edc3, (q31_t)0x2fe44dc, - (q31_t)0x128574, (q31_t)0x30ad245, (q31_t)0x131f9b, (q31_t)0x3175f91, - (q31_t)0x13bc39, (q31_t)0x323ecbe, (q31_t)0x145b4e, (q31_t)0x33079cc, - (q31_t)0x14fcda, (q31_t)0x33d06bb, (q31_t)0x15a0dd, (q31_t)0x3499389, - (q31_t)0x164757, (q31_t)0x3562038, (q31_t)0x16f047, (q31_t)0x362acc5, - (q31_t)0x179bae, (q31_t)0x36f3931, (q31_t)0x18498c, (q31_t)0x37bc57b, - (q31_t)0x18f9e1, (q31_t)0x38851a2, (q31_t)0x19acac, (q31_t)0x394dda7, - (q31_t)0x1a61ee, (q31_t)0x3a16988, (q31_t)0x1b19a7, (q31_t)0x3adf546, - (q31_t)0x1bd3d6, (q31_t)0x3ba80df, (q31_t)0x1c907c, (q31_t)0x3c70c54, - (q31_t)0x1d4f99, (q31_t)0x3d397a3, (q31_t)0x1e112b, (q31_t)0x3e022cc, - (q31_t)0x1ed535, (q31_t)0x3ecadcf, (q31_t)0x1f9bb5, (q31_t)0x3f938ac, - (q31_t)0x2064ab, (q31_t)0x405c361, (q31_t)0x213018, (q31_t)0x4124dee, - (q31_t)0x21fdfb, (q31_t)0x41ed854, (q31_t)0x22ce54, (q31_t)0x42b6290, - (q31_t)0x23a124, (q31_t)0x437eca4, (q31_t)0x24766a, (q31_t)0x444768d, - (q31_t)0x254e27, (q31_t)0x451004d, (q31_t)0x262859, (q31_t)0x45d89e2, - (q31_t)0x270502, (q31_t)0x46a134c, (q31_t)0x27e421, (q31_t)0x4769c8b, - (q31_t)0x28c5b6, (q31_t)0x483259d, (q31_t)0x29a9c1, (q31_t)0x48fae83, - (q31_t)0x2a9042, (q31_t)0x49c373c, (q31_t)0x2b7939, (q31_t)0x4a8bfc7, - (q31_t)0x2c64a6, (q31_t)0x4b54825, (q31_t)0x2d5289, (q31_t)0x4c1d054, - (q31_t)0x2e42e2, (q31_t)0x4ce5854, (q31_t)0x2f35b1, (q31_t)0x4dae024, - (q31_t)0x302af5, (q31_t)0x4e767c5, (q31_t)0x3122b0, (q31_t)0x4f3ef35, - (q31_t)0x321ce0, (q31_t)0x5007674, (q31_t)0x331986, (q31_t)0x50cfd82, - (q31_t)0x3418a2, (q31_t)0x519845e, (q31_t)0x351a33, (q31_t)0x5260b08, - (q31_t)0x361e3a, (q31_t)0x532917f, (q31_t)0x3724b6, (q31_t)0x53f17c3, - (q31_t)0x382da8, (q31_t)0x54b9dd3, (q31_t)0x393910, (q31_t)0x55823ae, - (q31_t)0x3a46ed, (q31_t)0x564a955, (q31_t)0x3b573f, (q31_t)0x5712ec7, - (q31_t)0x3c6a07, (q31_t)0x57db403, (q31_t)0x3d7f44, (q31_t)0x58a3908, - (q31_t)0x3e96f6, (q31_t)0x596bdd7, (q31_t)0x3fb11d, (q31_t)0x5a3426f, - (q31_t)0x40cdba, (q31_t)0x5afc6d0, (q31_t)0x41eccc, (q31_t)0x5bc4af8, - (q31_t)0x430e53, (q31_t)0x5c8cee7, (q31_t)0x44324f, (q31_t)0x5d5529e, - (q31_t)0x4558c0, (q31_t)0x5e1d61b, (q31_t)0x4681a6, (q31_t)0x5ee595d, - (q31_t)0x47ad01, (q31_t)0x5fadc66, (q31_t)0x48dad1, (q31_t)0x6075f33, - (q31_t)0x4a0b16, (q31_t)0x613e1c5, (q31_t)0x4b3dcf, (q31_t)0x620641a, - (q31_t)0x4c72fe, (q31_t)0x62ce634, (q31_t)0x4daaa1, (q31_t)0x6396810, - (q31_t)0x4ee4b8, (q31_t)0x645e9af, (q31_t)0x502145, (q31_t)0x6526b10, - (q31_t)0x516045, (q31_t)0x65eec33, (q31_t)0x52a1bb, (q31_t)0x66b6d16, - (q31_t)0x53e5a5, (q31_t)0x677edbb, (q31_t)0x552c03, (q31_t)0x6846e1f, - (q31_t)0x5674d6, (q31_t)0x690ee44, (q31_t)0x57c01d, (q31_t)0x69d6e27, - (q31_t)0x590dd8, (q31_t)0x6a9edc9, (q31_t)0x5a5e07, (q31_t)0x6b66d29, - (q31_t)0x5bb0ab, (q31_t)0x6c2ec48, (q31_t)0x5d05c3, (q31_t)0x6cf6b23, - (q31_t)0x5e5d4e, (q31_t)0x6dbe9bb, (q31_t)0x5fb74e, (q31_t)0x6e86810, - (q31_t)0x6113c2, (q31_t)0x6f4e620, (q31_t)0x6272aa, (q31_t)0x70163eb, - (q31_t)0x63d405, (q31_t)0x70de172, (q31_t)0x6537d4, (q31_t)0x71a5eb3, - (q31_t)0x669e18, (q31_t)0x726dbae, (q31_t)0x6806ce, (q31_t)0x7335862, - (q31_t)0x6971f9, (q31_t)0x73fd4cf, (q31_t)0x6adf97, (q31_t)0x74c50f4, - (q31_t)0x6c4fa8, (q31_t)0x758ccd2, (q31_t)0x6dc22e, (q31_t)0x7654867, - (q31_t)0x6f3726, (q31_t)0x771c3b3, (q31_t)0x70ae92, (q31_t)0x77e3eb5, - (q31_t)0x722871, (q31_t)0x78ab96e, (q31_t)0x73a4c3, (q31_t)0x79733dc, - (q31_t)0x752389, (q31_t)0x7a3adff, (q31_t)0x76a4c2, (q31_t)0x7b027d7, - (q31_t)0x78286e, (q31_t)0x7bca163, (q31_t)0x79ae8c, (q31_t)0x7c91aa3, - (q31_t)0x7b371e, (q31_t)0x7d59396, (q31_t)0x7cc223, (q31_t)0x7e20c3b, - (q31_t)0x7e4f9b, (q31_t)0x7ee8493, (q31_t)0x7fdf85, (q31_t)0x7fafc9c, - (q31_t)0x8171e2, (q31_t)0x8077457, (q31_t)0x8306b2, (q31_t)0x813ebc2, - (q31_t)0x849df4, (q31_t)0x82062de, (q31_t)0x8637a9, (q31_t)0x82cd9a9, - (q31_t)0x87d3d0, (q31_t)0x8395024, (q31_t)0x89726a, (q31_t)0x845c64d, - (q31_t)0x8b1376, (q31_t)0x8523c25, (q31_t)0x8cb6f5, (q31_t)0x85eb1ab, - (q31_t)0x8e5ce5, (q31_t)0x86b26de, (q31_t)0x900548, (q31_t)0x8779bbe, - (q31_t)0x91b01d, (q31_t)0x884104b, (q31_t)0x935d64, (q31_t)0x8908483, - (q31_t)0x950d1d, (q31_t)0x89cf867, (q31_t)0x96bf48, (q31_t)0x8a96bf6, - (q31_t)0x9873e4, (q31_t)0x8b5df30, (q31_t)0x9a2af3, (q31_t)0x8c25213, - (q31_t)0x9be473, (q31_t)0x8cec4a0, (q31_t)0x9da065, (q31_t)0x8db36d6, - (q31_t)0x9f5ec8, (q31_t)0x8e7a8b5, (q31_t)0xa11f9d, (q31_t)0x8f41a3c, - (q31_t)0xa2e2e3, (q31_t)0x9008b6a, (q31_t)0xa4a89b, (q31_t)0x90cfc40, - (q31_t)0xa670c4, (q31_t)0x9196cbc, (q31_t)0xa83b5e, (q31_t)0x925dcdf, - (q31_t)0xaa086a, (q31_t)0x9324ca7, (q31_t)0xabd7e6, (q31_t)0x93ebc14, - (q31_t)0xada9d4, (q31_t)0x94b2b27, (q31_t)0xaf7e33, (q31_t)0x95799dd, - (q31_t)0xb15502, (q31_t)0x9640837, (q31_t)0xb32e42, (q31_t)0x9707635, - (q31_t)0xb509f3, (q31_t)0x97ce3d5, (q31_t)0xb6e815, (q31_t)0x9895118, - (q31_t)0xb8c8a7, (q31_t)0x995bdfd, (q31_t)0xbaabaa, (q31_t)0x9a22a83, - (q31_t)0xbc911d, (q31_t)0x9ae96aa, (q31_t)0xbe7901, (q31_t)0x9bb0271, - (q31_t)0xc06355, (q31_t)0x9c76dd8, (q31_t)0xc25019, (q31_t)0x9d3d8df, - (q31_t)0xc43f4d, (q31_t)0x9e04385, (q31_t)0xc630f2, (q31_t)0x9ecadc9, - (q31_t)0xc82506, (q31_t)0x9f917ac, (q31_t)0xca1b8a, (q31_t)0xa05812c, - (q31_t)0xcc147f, (q31_t)0xa11ea49, (q31_t)0xce0fe3, (q31_t)0xa1e5303, - (q31_t)0xd00db6, (q31_t)0xa2abb59, (q31_t)0xd20dfa, (q31_t)0xa37234a, - (q31_t)0xd410ad, (q31_t)0xa438ad7, (q31_t)0xd615cf, (q31_t)0xa4ff1fe, - (q31_t)0xd81d61, (q31_t)0xa5c58c0, (q31_t)0xda2762, (q31_t)0xa68bf1b, - (q31_t)0xdc33d2, (q31_t)0xa752510, (q31_t)0xde42b2, (q31_t)0xa818a9d, - (q31_t)0xe05401, (q31_t)0xa8defc3, (q31_t)0xe267be, (q31_t)0xa9a5480, - (q31_t)0xe47deb, (q31_t)0xaa6b8d5, (q31_t)0xe69686, (q31_t)0xab31cc1, - (q31_t)0xe8b190, (q31_t)0xabf8043, (q31_t)0xeacf09, (q31_t)0xacbe35b, - (q31_t)0xeceef1, (q31_t)0xad84609, (q31_t)0xef1147, (q31_t)0xae4a84b, - (q31_t)0xf1360b, (q31_t)0xaf10a22, (q31_t)0xf35d3e, (q31_t)0xafd6b8d, - (q31_t)0xf586df, (q31_t)0xb09cc8c, (q31_t)0xf7b2ee, (q31_t)0xb162d1d, - (q31_t)0xf9e16b, (q31_t)0xb228d42, (q31_t)0xfc1257, (q31_t)0xb2eecf8, - (q31_t)0xfe45b0, (q31_t)0xb3b4c40, (q31_t)0x1007b77, (q31_t)0xb47ab19, - (q31_t)0x102b3ac, (q31_t)0xb540982, (q31_t)0x104ee4f, (q31_t)0xb60677c, - (q31_t)0x1072b5f, (q31_t)0xb6cc506, (q31_t)0x1096add, (q31_t)0xb79221f, - (q31_t)0x10bacc8, (q31_t)0xb857ec7, (q31_t)0x10df120, (q31_t)0xb91dafc, - (q31_t)0x11037e6, (q31_t)0xb9e36c0, (q31_t)0x1128119, (q31_t)0xbaa9211, - (q31_t)0x114ccb9, (q31_t)0xbb6ecef, (q31_t)0x1171ac6, (q31_t)0xbc34759, - (q31_t)0x1196b3f, (q31_t)0xbcfa150, (q31_t)0x11bbe26, (q31_t)0xbdbfad1, - (q31_t)0x11e1379, (q31_t)0xbe853de, (q31_t)0x1206b39, (q31_t)0xbf4ac75, - (q31_t)0x122c566, (q31_t)0xc010496, (q31_t)0x12521ff, (q31_t)0xc0d5c41, - (q31_t)0x1278104, (q31_t)0xc19b374, (q31_t)0x129e276, (q31_t)0xc260a31, - (q31_t)0x12c4653, (q31_t)0xc326075, (q31_t)0x12eac9d, (q31_t)0xc3eb641, - (q31_t)0x1311553, (q31_t)0xc4b0b94, (q31_t)0x1338075, (q31_t)0xc57606e, - (q31_t)0x135ee02, (q31_t)0xc63b4ce, (q31_t)0x1385dfb, (q31_t)0xc7008b3, - (q31_t)0x13ad060, (q31_t)0xc7c5c1e, (q31_t)0x13d4530, (q31_t)0xc88af0e, - (q31_t)0x13fbc6c, (q31_t)0xc950182, (q31_t)0x1423613, (q31_t)0xca1537a, - (q31_t)0x144b225, (q31_t)0xcada4f5, (q31_t)0x14730a3, (q31_t)0xcb9f5f3, - (q31_t)0x149b18b, (q31_t)0xcc64673, (q31_t)0x14c34df, (q31_t)0xcd29676, - (q31_t)0x14eba9d, (q31_t)0xcdee5f9, (q31_t)0x15142c6, (q31_t)0xceb34fe, - (q31_t)0x153cd5a, (q31_t)0xcf78383, (q31_t)0x1565a58, (q31_t)0xd03d189, - (q31_t)0x158e9c1, (q31_t)0xd101f0e, (q31_t)0x15b7b94, (q31_t)0xd1c6c11, - (q31_t)0x15e0fd1, (q31_t)0xd28b894, (q31_t)0x160a678, (q31_t)0xd350495, - (q31_t)0x1633f8a, (q31_t)0xd415013, (q31_t)0x165db05, (q31_t)0xd4d9b0e, - (q31_t)0x16878eb, (q31_t)0xd59e586, (q31_t)0x16b193a, (q31_t)0xd662f7b, - (q31_t)0x16dbbf3, (q31_t)0xd7278eb, (q31_t)0x1706115, (q31_t)0xd7ec1d6, - (q31_t)0x17308a1, (q31_t)0xd8b0a3d, (q31_t)0x175b296, (q31_t)0xd97521d, - (q31_t)0x1785ef4, (q31_t)0xda39978, (q31_t)0x17b0dbb, (q31_t)0xdafe04b, - (q31_t)0x17dbeec, (q31_t)0xdbc2698, (q31_t)0x1807285, (q31_t)0xdc86c5d, - (q31_t)0x1832888, (q31_t)0xdd4b19a, (q31_t)0x185e0f3, (q31_t)0xde0f64f, - (q31_t)0x1889bc6, (q31_t)0xded3a7b, (q31_t)0x18b5903, (q31_t)0xdf97e1d, - (q31_t)0x18e18a7, (q31_t)0xe05c135, (q31_t)0x190dab4, (q31_t)0xe1203c3, - (q31_t)0x1939f29, (q31_t)0xe1e45c6, (q31_t)0x1966606, (q31_t)0xe2a873e, - (q31_t)0x1992f4c, (q31_t)0xe36c82a, (q31_t)0x19bfaf9, (q31_t)0xe430889, - (q31_t)0x19ec90d, (q31_t)0xe4f485c, (q31_t)0x1a1998a, (q31_t)0xe5b87a2, - (q31_t)0x1a46c6e, (q31_t)0xe67c65a, (q31_t)0x1a741b9, (q31_t)0xe740483, - (q31_t)0x1aa196c, (q31_t)0xe80421e, (q31_t)0x1acf386, (q31_t)0xe8c7f2a, - (q31_t)0x1afd007, (q31_t)0xe98bba7, (q31_t)0x1b2aef0, (q31_t)0xea4f793, - (q31_t)0x1b5903f, (q31_t)0xeb132ef, (q31_t)0x1b873f5, (q31_t)0xebd6db9, - (q31_t)0x1bb5a11, (q31_t)0xec9a7f3, (q31_t)0x1be4294, (q31_t)0xed5e19a, - (q31_t)0x1c12d7e, (q31_t)0xee21aaf, (q31_t)0x1c41ace, (q31_t)0xeee5331, - (q31_t)0x1c70a84, (q31_t)0xefa8b20, (q31_t)0x1c9fca0, (q31_t)0xf06c27a, - (q31_t)0x1ccf122, (q31_t)0xf12f941, (q31_t)0x1cfe80a, (q31_t)0xf1f2f73, - (q31_t)0x1d2e158, (q31_t)0xf2b650f, (q31_t)0x1d5dd0c, (q31_t)0xf379a16, - (q31_t)0x1d8db25, (q31_t)0xf43ce86, (q31_t)0x1dbdba3, (q31_t)0xf500260, - (q31_t)0x1dede87, (q31_t)0xf5c35a3, (q31_t)0x1e1e3d0, (q31_t)0xf68684e, - (q31_t)0x1e4eb7e, (q31_t)0xf749a61, (q31_t)0x1e7f591, (q31_t)0xf80cbdc, - (q31_t)0x1eb0209, (q31_t)0xf8cfcbe, (q31_t)0x1ee10e5, (q31_t)0xf992d06, - (q31_t)0x1f12227, (q31_t)0xfa55cb4, (q31_t)0x1f435cc, (q31_t)0xfb18bc8, - (q31_t)0x1f74bd6, (q31_t)0xfbdba40, (q31_t)0x1fa6445, (q31_t)0xfc9e81e, - (q31_t)0x1fd7f17, (q31_t)0xfd6155f, (q31_t)0x2009c4e, (q31_t)0xfe24205, - (q31_t)0x203bbe8, (q31_t)0xfee6e0d, (q31_t)0x206dde6, (q31_t)0xffa9979, - (q31_t)0x20a0248, (q31_t)0x1006c446, (q31_t)0x20d290d, (q31_t)0x1012ee76, - (q31_t)0x2105236, (q31_t)0x101f1807, (q31_t)0x2137dc2, (q31_t)0x102b40f8, - (q31_t)0x216abb1, (q31_t)0x1037694b, (q31_t)0x219dc03, (q31_t)0x104390fd, - (q31_t)0x21d0eb8, (q31_t)0x104fb80e, (q31_t)0x22043d0, (q31_t)0x105bde7f, - (q31_t)0x2237b4b, (q31_t)0x1068044e, (q31_t)0x226b528, (q31_t)0x1074297b, - (q31_t)0x229f167, (q31_t)0x10804e06, (q31_t)0x22d3009, (q31_t)0x108c71ee, - (q31_t)0x230710d, (q31_t)0x10989532, (q31_t)0x233b473, (q31_t)0x10a4b7d3, - (q31_t)0x236fa3b, (q31_t)0x10b0d9d0, (q31_t)0x23a4265, (q31_t)0x10bcfb28, - (q31_t)0x23d8cf1, (q31_t)0x10c91bda, (q31_t)0x240d9de, (q31_t)0x10d53be7, - (q31_t)0x244292c, (q31_t)0x10e15b4e, (q31_t)0x2477adc, (q31_t)0x10ed7a0e, - (q31_t)0x24aceed, (q31_t)0x10f99827, (q31_t)0x24e255e, (q31_t)0x1105b599, - (q31_t)0x2517e31, (q31_t)0x1111d263, (q31_t)0x254d965, (q31_t)0x111dee84, - (q31_t)0x25836f9, (q31_t)0x112a09fc, (q31_t)0x25b96ee, (q31_t)0x113624cb, - (q31_t)0x25ef943, (q31_t)0x11423ef0, (q31_t)0x2625df8, (q31_t)0x114e586a, - (q31_t)0x265c50e, (q31_t)0x115a713a, (q31_t)0x2692e83, (q31_t)0x1166895f, - (q31_t)0x26c9a58, (q31_t)0x1172a0d7, (q31_t)0x270088e, (q31_t)0x117eb7a4, - (q31_t)0x2737922, (q31_t)0x118acdc4, (q31_t)0x276ec16, (q31_t)0x1196e337, - (q31_t)0x27a616a, (q31_t)0x11a2f7fc, (q31_t)0x27dd91c, (q31_t)0x11af0c13, - (q31_t)0x281532e, (q31_t)0x11bb1f7c, (q31_t)0x284cf9f, (q31_t)0x11c73235, - (q31_t)0x2884e6e, (q31_t)0x11d3443f, (q31_t)0x28bcf9c, (q31_t)0x11df5599, - (q31_t)0x28f5329, (q31_t)0x11eb6643, (q31_t)0x292d914, (q31_t)0x11f7763c, - (q31_t)0x296615d, (q31_t)0x12038584, (q31_t)0x299ec05, (q31_t)0x120f941a, - (q31_t)0x29d790a, (q31_t)0x121ba1fd, (q31_t)0x2a1086d, (q31_t)0x1227af2e, - (q31_t)0x2a49a2e, (q31_t)0x1233bbac, (q31_t)0x2a82e4d, (q31_t)0x123fc776, - (q31_t)0x2abc4c9, (q31_t)0x124bd28c, (q31_t)0x2af5da2, (q31_t)0x1257dced, - (q31_t)0x2b2f8d8, (q31_t)0x1263e699, (q31_t)0x2b6966c, (q31_t)0x126fef90, - (q31_t)0x2ba365c, (q31_t)0x127bf7d1, (q31_t)0x2bdd8a9, (q31_t)0x1287ff5b, - (q31_t)0x2c17d52, (q31_t)0x1294062f, (q31_t)0x2c52459, (q31_t)0x12a00c4b, - (q31_t)0x2c8cdbb, (q31_t)0x12ac11af, (q31_t)0x2cc7979, (q31_t)0x12b8165b, - (q31_t)0x2d02794, (q31_t)0x12c41a4f, (q31_t)0x2d3d80a, (q31_t)0x12d01d89, - (q31_t)0x2d78add, (q31_t)0x12dc2009, (q31_t)0x2db400a, (q31_t)0x12e821cf, - (q31_t)0x2def794, (q31_t)0x12f422db, (q31_t)0x2e2b178, (q31_t)0x1300232c, - (q31_t)0x2e66db8, (q31_t)0x130c22c1, (q31_t)0x2ea2c53, (q31_t)0x1318219a, - (q31_t)0x2eded49, (q31_t)0x13241fb6, (q31_t)0x2f1b099, (q31_t)0x13301d16, - (q31_t)0x2f57644, (q31_t)0x133c19b8, (q31_t)0x2f93e4a, (q31_t)0x1348159d, - (q31_t)0x2fd08a9, (q31_t)0x135410c3, (q31_t)0x300d563, (q31_t)0x13600b2a, - (q31_t)0x304a477, (q31_t)0x136c04d2, (q31_t)0x30875e5, (q31_t)0x1377fdbb, - (q31_t)0x30c49ad, (q31_t)0x1383f5e3, (q31_t)0x3101fce, (q31_t)0x138fed4b, - (q31_t)0x313f848, (q31_t)0x139be3f2, (q31_t)0x317d31c, (q31_t)0x13a7d9d7, - (q31_t)0x31bb049, (q31_t)0x13b3cefa, (q31_t)0x31f8fcf, (q31_t)0x13bfc35b, - (q31_t)0x32371ae, (q31_t)0x13cbb6f8, (q31_t)0x32755e5, (q31_t)0x13d7a9d3, - (q31_t)0x32b3c75, (q31_t)0x13e39be9, (q31_t)0x32f255e, (q31_t)0x13ef8d3c, - (q31_t)0x333109e, (q31_t)0x13fb7dc9, (q31_t)0x336fe37, (q31_t)0x14076d91, - (q31_t)0x33aee27, (q31_t)0x14135c94, (q31_t)0x33ee070, (q31_t)0x141f4ad1, - (q31_t)0x342d510, (q31_t)0x142b3846, (q31_t)0x346cc07, (q31_t)0x143724f5, - (q31_t)0x34ac556, (q31_t)0x144310dd, (q31_t)0x34ec0fc, (q31_t)0x144efbfc, - (q31_t)0x352bef9, (q31_t)0x145ae653, (q31_t)0x356bf4d, (q31_t)0x1466cfe1, - (q31_t)0x35ac1f7, (q31_t)0x1472b8a5, (q31_t)0x35ec6f8, (q31_t)0x147ea0a0, - (q31_t)0x362ce50, (q31_t)0x148a87d1, (q31_t)0x366d7fd, (q31_t)0x14966e36, - (q31_t)0x36ae401, (q31_t)0x14a253d1, (q31_t)0x36ef25b, (q31_t)0x14ae38a0, - (q31_t)0x373030a, (q31_t)0x14ba1ca3, (q31_t)0x377160f, (q31_t)0x14c5ffd9, - (q31_t)0x37b2b6a, (q31_t)0x14d1e242, (q31_t)0x37f4319, (q31_t)0x14ddc3de, - (q31_t)0x3835d1e, (q31_t)0x14e9a4ac, (q31_t)0x3877978, (q31_t)0x14f584ac, - (q31_t)0x38b9827, (q31_t)0x150163dc, (q31_t)0x38fb92a, (q31_t)0x150d423d, - (q31_t)0x393dc82, (q31_t)0x15191fcf, (q31_t)0x398022f, (q31_t)0x1524fc90, - (q31_t)0x39c2a2f, (q31_t)0x1530d881, (q31_t)0x3a05484, (q31_t)0x153cb3a0, - (q31_t)0x3a4812c, (q31_t)0x15488dee, (q31_t)0x3a8b028, (q31_t)0x1554676a, - (q31_t)0x3ace178, (q31_t)0x15604013, (q31_t)0x3b1151b, (q31_t)0x156c17e9, - (q31_t)0x3b54b11, (q31_t)0x1577eeec, (q31_t)0x3b9835a, (q31_t)0x1583c51b, - (q31_t)0x3bdbdf6, (q31_t)0x158f9a76, (q31_t)0x3c1fae5, (q31_t)0x159b6efb, - (q31_t)0x3c63a26, (q31_t)0x15a742ac, (q31_t)0x3ca7bba, (q31_t)0x15b31587, - (q31_t)0x3cebfa0, (q31_t)0x15bee78c, (q31_t)0x3d305d8, (q31_t)0x15cab8ba, - (q31_t)0x3d74e62, (q31_t)0x15d68911, (q31_t)0x3db993e, (q31_t)0x15e25890, - (q31_t)0x3dfe66c, (q31_t)0x15ee2738, (q31_t)0x3e435ea, (q31_t)0x15f9f507, - (q31_t)0x3e887bb, (q31_t)0x1605c1fd, (q31_t)0x3ecdbdc, (q31_t)0x16118e1a, - (q31_t)0x3f1324e, (q31_t)0x161d595d, (q31_t)0x3f58b10, (q31_t)0x162923c5, - (q31_t)0x3f9e624, (q31_t)0x1634ed53, (q31_t)0x3fe4388, (q31_t)0x1640b606, - (q31_t)0x402a33c, (q31_t)0x164c7ddd, (q31_t)0x4070540, (q31_t)0x165844d8, - (q31_t)0x40b6994, (q31_t)0x16640af7, (q31_t)0x40fd037, (q31_t)0x166fd039, - (q31_t)0x414392b, (q31_t)0x167b949d, (q31_t)0x418a46d, (q31_t)0x16875823, - (q31_t)0x41d11ff, (q31_t)0x16931acb, (q31_t)0x42181e0, (q31_t)0x169edc94, - (q31_t)0x425f410, (q31_t)0x16aa9d7e, (q31_t)0x42a688f, (q31_t)0x16b65d88, - (q31_t)0x42edf5c, (q31_t)0x16c21cb2, (q31_t)0x4335877, (q31_t)0x16cddafb, - (q31_t)0x437d3e1, (q31_t)0x16d99864, (q31_t)0x43c5199, (q31_t)0x16e554ea, - (q31_t)0x440d19e, (q31_t)0x16f1108f, (q31_t)0x44553f2, (q31_t)0x16fccb51, - (q31_t)0x449d892, (q31_t)0x17088531, (q31_t)0x44e5f80, (q31_t)0x17143e2d, - (q31_t)0x452e8bc, (q31_t)0x171ff646, (q31_t)0x4577444, (q31_t)0x172bad7a, - (q31_t)0x45c0219, (q31_t)0x173763c9, (q31_t)0x460923b, (q31_t)0x17431933, - (q31_t)0x46524a9, (q31_t)0x174ecdb8, (q31_t)0x469b963, (q31_t)0x175a8157, - (q31_t)0x46e5069, (q31_t)0x1766340f, (q31_t)0x472e9bc, (q31_t)0x1771e5e0, - (q31_t)0x477855a, (q31_t)0x177d96ca, (q31_t)0x47c2344, (q31_t)0x178946cc, - (q31_t)0x480c379, (q31_t)0x1794f5e6, (q31_t)0x48565f9, (q31_t)0x17a0a417, - (q31_t)0x48a0ac4, (q31_t)0x17ac515f, (q31_t)0x48eb1db, (q31_t)0x17b7fdbd, - (q31_t)0x4935b3c, (q31_t)0x17c3a931, (q31_t)0x49806e7, (q31_t)0x17cf53bb, - (q31_t)0x49cb4dd, (q31_t)0x17dafd59, (q31_t)0x4a1651c, (q31_t)0x17e6a60c, - (q31_t)0x4a617a6, (q31_t)0x17f24dd3, (q31_t)0x4aacc7a, (q31_t)0x17fdf4ae, - (q31_t)0x4af8397, (q31_t)0x18099a9c, (q31_t)0x4b43cfd, (q31_t)0x18153f9d, - (q31_t)0x4b8f8ad, (q31_t)0x1820e3b0, (q31_t)0x4bdb6a6, (q31_t)0x182c86d5, - (q31_t)0x4c276e8, (q31_t)0x1838290c, (q31_t)0x4c73972, (q31_t)0x1843ca53, - (q31_t)0x4cbfe45, (q31_t)0x184f6aab, (q31_t)0x4d0c560, (q31_t)0x185b0a13, - (q31_t)0x4d58ec3, (q31_t)0x1866a88a, (q31_t)0x4da5a6f, (q31_t)0x18724611, - (q31_t)0x4df2862, (q31_t)0x187de2a7, (q31_t)0x4e3f89c, (q31_t)0x18897e4a, - (q31_t)0x4e8cb1e, (q31_t)0x189518fc, (q31_t)0x4ed9fe7, (q31_t)0x18a0b2bb, - (q31_t)0x4f276f7, (q31_t)0x18ac4b87, (q31_t)0x4f7504e, (q31_t)0x18b7e35f, - (q31_t)0x4fc2bec, (q31_t)0x18c37a44, (q31_t)0x50109d0, (q31_t)0x18cf1034, - (q31_t)0x505e9fb, (q31_t)0x18daa52f, (q31_t)0x50acc6b, (q31_t)0x18e63935, - (q31_t)0x50fb121, (q31_t)0x18f1cc45, (q31_t)0x514981d, (q31_t)0x18fd5e5f, - (q31_t)0x519815f, (q31_t)0x1908ef82, (q31_t)0x51e6ce6, (q31_t)0x19147fae, - (q31_t)0x5235ab2, (q31_t)0x19200ee3, (q31_t)0x5284ac3, (q31_t)0x192b9d1f, - (q31_t)0x52d3d18, (q31_t)0x19372a64, (q31_t)0x53231b3, (q31_t)0x1942b6af, - (q31_t)0x5372891, (q31_t)0x194e4201, (q31_t)0x53c21b4, (q31_t)0x1959cc5a, - (q31_t)0x5411d1b, (q31_t)0x196555b8, (q31_t)0x5461ac6, (q31_t)0x1970de1b, - (q31_t)0x54b1ab4, (q31_t)0x197c6584, (q31_t)0x5501ce5, (q31_t)0x1987ebf0, - (q31_t)0x555215a, (q31_t)0x19937161, (q31_t)0x55a2812, (q31_t)0x199ef5d6, - (q31_t)0x55f310d, (q31_t)0x19aa794d, (q31_t)0x5643c4a, (q31_t)0x19b5fbc8, - (q31_t)0x56949ca, (q31_t)0x19c17d44, (q31_t)0x56e598c, (q31_t)0x19ccfdc2, - (q31_t)0x5736b90, (q31_t)0x19d87d42, (q31_t)0x5787fd6, (q31_t)0x19e3fbc3, - (q31_t)0x57d965d, (q31_t)0x19ef7944, (q31_t)0x582af26, (q31_t)0x19faf5c5, - (q31_t)0x587ca31, (q31_t)0x1a067145, (q31_t)0x58ce77c, (q31_t)0x1a11ebc5, - (q31_t)0x5920708, (q31_t)0x1a1d6544, (q31_t)0x59728d5, (q31_t)0x1a28ddc0, - (q31_t)0x59c4ce3, (q31_t)0x1a34553b, (q31_t)0x5a17330, (q31_t)0x1a3fcbb3, - (q31_t)0x5a69bbe, (q31_t)0x1a4b4128, (q31_t)0x5abc68c, (q31_t)0x1a56b599, - (q31_t)0x5b0f399, (q31_t)0x1a622907, (q31_t)0x5b622e6, (q31_t)0x1a6d9b70, - (q31_t)0x5bb5472, (q31_t)0x1a790cd4, (q31_t)0x5c0883d, (q31_t)0x1a847d33, - (q31_t)0x5c5be47, (q31_t)0x1a8fec8c, (q31_t)0x5caf690, (q31_t)0x1a9b5adf, - (q31_t)0x5d03118, (q31_t)0x1aa6c82b, (q31_t)0x5d56ddd, (q31_t)0x1ab23471, - (q31_t)0x5daace1, (q31_t)0x1abd9faf, (q31_t)0x5dfee22, (q31_t)0x1ac909e5, - (q31_t)0x5e531a1, (q31_t)0x1ad47312, (q31_t)0x5ea775e, (q31_t)0x1adfdb37, - (q31_t)0x5efbf58, (q31_t)0x1aeb4253, (q31_t)0x5f5098f, (q31_t)0x1af6a865, - (q31_t)0x5fa5603, (q31_t)0x1b020d6c, (q31_t)0x5ffa4b3, (q31_t)0x1b0d716a, - (q31_t)0x604f5a0, (q31_t)0x1b18d45c, (q31_t)0x60a48c9, (q31_t)0x1b243643, - (q31_t)0x60f9e2e, (q31_t)0x1b2f971e, (q31_t)0x614f5cf, (q31_t)0x1b3af6ec, - (q31_t)0x61a4fac, (q31_t)0x1b4655ae, (q31_t)0x61fabc4, (q31_t)0x1b51b363, - (q31_t)0x6250a18, (q31_t)0x1b5d100a, (q31_t)0x62a6aa6, (q31_t)0x1b686ba3, - (q31_t)0x62fcd6f, (q31_t)0x1b73c62d, (q31_t)0x6353273, (q31_t)0x1b7f1fa9, - (q31_t)0x63a99b1, (q31_t)0x1b8a7815, (q31_t)0x6400329, (q31_t)0x1b95cf71, - (q31_t)0x6456edb, (q31_t)0x1ba125bd, (q31_t)0x64adcc7, (q31_t)0x1bac7af9, - (q31_t)0x6504ced, (q31_t)0x1bb7cf23, (q31_t)0x655bf4c, (q31_t)0x1bc3223c, - (q31_t)0x65b33e4, (q31_t)0x1bce7442, (q31_t)0x660aab5, (q31_t)0x1bd9c537, - (q31_t)0x66623be, (q31_t)0x1be51518, (q31_t)0x66b9f01, (q31_t)0x1bf063e6, - (q31_t)0x6711c7b, (q31_t)0x1bfbb1a0, (q31_t)0x6769c2e, (q31_t)0x1c06fe46, - (q31_t)0x67c1e18, (q31_t)0x1c1249d8, (q31_t)0x681a23a, (q31_t)0x1c1d9454, - (q31_t)0x6872894, (q31_t)0x1c28ddbb, (q31_t)0x68cb124, (q31_t)0x1c34260c, - (q31_t)0x6923bec, (q31_t)0x1c3f6d47, (q31_t)0x697c8eb, (q31_t)0x1c4ab36b, - (q31_t)0x69d5820, (q31_t)0x1c55f878, (q31_t)0x6a2e98b, (q31_t)0x1c613c6d, - (q31_t)0x6a87d2d, (q31_t)0x1c6c7f4a, (q31_t)0x6ae1304, (q31_t)0x1c77c10e, - (q31_t)0x6b3ab12, (q31_t)0x1c8301b9, (q31_t)0x6b94554, (q31_t)0x1c8e414b, - (q31_t)0x6bee1cd, (q31_t)0x1c997fc4, (q31_t)0x6c4807a, (q31_t)0x1ca4bd21, - (q31_t)0x6ca215c, (q31_t)0x1caff965, (q31_t)0x6cfc472, (q31_t)0x1cbb348d, - (q31_t)0x6d569be, (q31_t)0x1cc66e99, (q31_t)0x6db113d, (q31_t)0x1cd1a78a, - (q31_t)0x6e0baf0, (q31_t)0x1cdcdf5e, (q31_t)0x6e666d7, (q31_t)0x1ce81615, - (q31_t)0x6ec14f2, (q31_t)0x1cf34baf, (q31_t)0x6f1c540, (q31_t)0x1cfe802b, - (q31_t)0x6f777c1, (q31_t)0x1d09b389, (q31_t)0x6fd2c75, (q31_t)0x1d14e5c9, - (q31_t)0x702e35c, (q31_t)0x1d2016e9, (q31_t)0x7089c75, (q31_t)0x1d2b46ea, - (q31_t)0x70e57c0, (q31_t)0x1d3675cb, (q31_t)0x714153e, (q31_t)0x1d41a38c, - (q31_t)0x719d4ed, (q31_t)0x1d4cd02c, (q31_t)0x71f96ce, (q31_t)0x1d57fbaa, - (q31_t)0x7255ae0, (q31_t)0x1d632608, (q31_t)0x72b2123, (q31_t)0x1d6e4f43, - (q31_t)0x730e997, (q31_t)0x1d79775c, (q31_t)0x736b43c, (q31_t)0x1d849e51, - (q31_t)0x73c8111, (q31_t)0x1d8fc424, (q31_t)0x7425016, (q31_t)0x1d9ae8d2, - (q31_t)0x748214c, (q31_t)0x1da60c5d, (q31_t)0x74df4b1, (q31_t)0x1db12ec3, - (q31_t)0x753ca46, (q31_t)0x1dbc5004, (q31_t)0x759a20a, (q31_t)0x1dc7701f, - (q31_t)0x75f7bfe, (q31_t)0x1dd28f15, (q31_t)0x7655820, (q31_t)0x1dddace4, - (q31_t)0x76b3671, (q31_t)0x1de8c98c, (q31_t)0x77116f0, (q31_t)0x1df3e50d, - (q31_t)0x776f99d, (q31_t)0x1dfeff67, (q31_t)0x77cde79, (q31_t)0x1e0a1898, - (q31_t)0x782c582, (q31_t)0x1e1530a1, (q31_t)0x788aeb9, (q31_t)0x1e204781, - (q31_t)0x78e9a1d, (q31_t)0x1e2b5d38, (q31_t)0x79487ae, (q31_t)0x1e3671c5, - (q31_t)0x79a776c, (q31_t)0x1e418528, (q31_t)0x7a06957, (q31_t)0x1e4c9760, - (q31_t)0x7a65d6e, (q31_t)0x1e57a86d, (q31_t)0x7ac53b1, (q31_t)0x1e62b84f, - (q31_t)0x7b24c20, (q31_t)0x1e6dc705, (q31_t)0x7b846ba, (q31_t)0x1e78d48e, - (q31_t)0x7be4381, (q31_t)0x1e83e0eb, (q31_t)0x7c44272, (q31_t)0x1e8eec1b, - (q31_t)0x7ca438f, (q31_t)0x1e99f61d, (q31_t)0x7d046d6, (q31_t)0x1ea4fef0, - (q31_t)0x7d64c47, (q31_t)0x1eb00696, (q31_t)0x7dc53e3, (q31_t)0x1ebb0d0d, - (q31_t)0x7e25daa, (q31_t)0x1ec61254, (q31_t)0x7e8699a, (q31_t)0x1ed1166b, - (q31_t)0x7ee77b3, (q31_t)0x1edc1953, (q31_t)0x7f487f6, (q31_t)0x1ee71b0a, - (q31_t)0x7fa9a62, (q31_t)0x1ef21b90, (q31_t)0x800aef7, (q31_t)0x1efd1ae4, - (q31_t)0x806c5b5, (q31_t)0x1f081907, (q31_t)0x80cde9b, (q31_t)0x1f1315f7, - (q31_t)0x812f9a9, (q31_t)0x1f1e11b5, (q31_t)0x81916df, (q31_t)0x1f290c3f, - (q31_t)0x81f363d, (q31_t)0x1f340596, (q31_t)0x82557c3, (q31_t)0x1f3efdb9, - (q31_t)0x82b7b70, (q31_t)0x1f49f4a8, (q31_t)0x831a143, (q31_t)0x1f54ea62, - (q31_t)0x837c93e, (q31_t)0x1f5fdee6, (q31_t)0x83df35f, (q31_t)0x1f6ad235, - (q31_t)0x8441fa6, (q31_t)0x1f75c44e, (q31_t)0x84a4e14, (q31_t)0x1f80b531, - (q31_t)0x8507ea7, (q31_t)0x1f8ba4dc, (q31_t)0x856b160, (q31_t)0x1f969350, - (q31_t)0x85ce63e, (q31_t)0x1fa1808c, (q31_t)0x8631d42, (q31_t)0x1fac6c91, - (q31_t)0x869566a, (q31_t)0x1fb7575c, (q31_t)0x86f91b7, (q31_t)0x1fc240ef, - (q31_t)0x875cf28, (q31_t)0x1fcd2948, (q31_t)0x87c0ebd, (q31_t)0x1fd81067, - (q31_t)0x8825077, (q31_t)0x1fe2f64c, (q31_t)0x8889454, (q31_t)0x1feddaf6, - (q31_t)0x88eda54, (q31_t)0x1ff8be65, (q31_t)0x8952278, (q31_t)0x2003a099, - (q31_t)0x89b6cbf, (q31_t)0x200e8190, (q31_t)0x8a1b928, (q31_t)0x2019614c, - (q31_t)0x8a807b4, (q31_t)0x20243fca, (q31_t)0x8ae5862, (q31_t)0x202f1d0b, - (q31_t)0x8b4ab32, (q31_t)0x2039f90f, (q31_t)0x8bb0023, (q31_t)0x2044d3d4, - (q31_t)0x8c15736, (q31_t)0x204fad5b, (q31_t)0x8c7b06b, (q31_t)0x205a85a3, - (q31_t)0x8ce0bc0, (q31_t)0x20655cac, (q31_t)0x8d46936, (q31_t)0x20703275, - (q31_t)0x8dac8cd, (q31_t)0x207b06fe, (q31_t)0x8e12a84, (q31_t)0x2085da46, - (q31_t)0x8e78e5b, (q31_t)0x2090ac4d, (q31_t)0x8edf452, (q31_t)0x209b7d13, - (q31_t)0x8f45c68, (q31_t)0x20a64c97, (q31_t)0x8fac69e, (q31_t)0x20b11ad9, - (q31_t)0x90132f2, (q31_t)0x20bbe7d8, (q31_t)0x907a166, (q31_t)0x20c6b395, - (q31_t)0x90e11f7, (q31_t)0x20d17e0d, (q31_t)0x91484a8, (q31_t)0x20dc4742, - (q31_t)0x91af976, (q31_t)0x20e70f32, (q31_t)0x9217062, (q31_t)0x20f1d5de, - (q31_t)0x927e96b, (q31_t)0x20fc9b44, (q31_t)0x92e6492, (q31_t)0x21075f65, - (q31_t)0x934e1d6, (q31_t)0x21122240, (q31_t)0x93b6137, (q31_t)0x211ce3d5, - (q31_t)0x941e2b4, (q31_t)0x2127a423, (q31_t)0x948664d, (q31_t)0x21326329, - (q31_t)0x94eec03, (q31_t)0x213d20e8, (q31_t)0x95573d4, (q31_t)0x2147dd5f, - (q31_t)0x95bfdc1, (q31_t)0x2152988d, (q31_t)0x96289c9, (q31_t)0x215d5273, - (q31_t)0x96917ec, (q31_t)0x21680b0f, (q31_t)0x96fa82a, (q31_t)0x2172c262, - (q31_t)0x9763a83, (q31_t)0x217d786a, (q31_t)0x97ccef5, (q31_t)0x21882d28, - (q31_t)0x9836582, (q31_t)0x2192e09b, (q31_t)0x989fe29, (q31_t)0x219d92c2, - (q31_t)0x99098e9, (q31_t)0x21a8439e, (q31_t)0x99735c2, (q31_t)0x21b2f32e, - (q31_t)0x99dd4b4, (q31_t)0x21bda171, (q31_t)0x9a475bf, (q31_t)0x21c84e67, - (q31_t)0x9ab18e3, (q31_t)0x21d2fa0f, (q31_t)0x9b1be1e, (q31_t)0x21dda46a, - (q31_t)0x9b86572, (q31_t)0x21e84d76, (q31_t)0x9bf0edd, (q31_t)0x21f2f534, - (q31_t)0x9c5ba60, (q31_t)0x21fd9ba3, (q31_t)0x9cc67fa, (q31_t)0x220840c2, - (q31_t)0x9d317ab, (q31_t)0x2212e492, (q31_t)0x9d9c973, (q31_t)0x221d8711, - (q31_t)0x9e07d51, (q31_t)0x2228283f, (q31_t)0x9e73346, (q31_t)0x2232c81c, - (q31_t)0x9edeb50, (q31_t)0x223d66a8, (q31_t)0x9f4a570, (q31_t)0x224803e2, - (q31_t)0x9fb61a5, (q31_t)0x22529fca, (q31_t)0xa021fef, (q31_t)0x225d3a5e, - (q31_t)0xa08e04f, (q31_t)0x2267d3a0, (q31_t)0xa0fa2c3, (q31_t)0x22726b8e, - (q31_t)0xa16674b, (q31_t)0x227d0228, (q31_t)0xa1d2de7, (q31_t)0x2287976e, - (q31_t)0xa23f698, (q31_t)0x22922b5e, (q31_t)0xa2ac15b, (q31_t)0x229cbdfa, - (q31_t)0xa318e32, (q31_t)0x22a74f40, (q31_t)0xa385d1d, (q31_t)0x22b1df30, - (q31_t)0xa3f2e19, (q31_t)0x22bc6dca, (q31_t)0xa460129, (q31_t)0x22c6fb0c, - (q31_t)0xa4cd64b, (q31_t)0x22d186f8, (q31_t)0xa53ad7e, (q31_t)0x22dc118c, - (q31_t)0xa5a86c4, (q31_t)0x22e69ac8, (q31_t)0xa61621b, (q31_t)0x22f122ab, - (q31_t)0xa683f83, (q31_t)0x22fba936, (q31_t)0xa6f1efc, (q31_t)0x23062e67, - (q31_t)0xa760086, (q31_t)0x2310b23e, (q31_t)0xa7ce420, (q31_t)0x231b34bc, - (q31_t)0xa83c9ca, (q31_t)0x2325b5df, (q31_t)0xa8ab184, (q31_t)0x233035a7, - (q31_t)0xa919b4e, (q31_t)0x233ab414, (q31_t)0xa988727, (q31_t)0x23453125, - (q31_t)0xa9f750f, (q31_t)0x234facda, (q31_t)0xaa66506, (q31_t)0x235a2733, - (q31_t)0xaad570c, (q31_t)0x2364a02e, (q31_t)0xab44b1f, (q31_t)0x236f17cc, - (q31_t)0xabb4141, (q31_t)0x23798e0d, (q31_t)0xac23971, (q31_t)0x238402ef, - (q31_t)0xac933ae, (q31_t)0x238e7673, (q31_t)0xad02ff8, (q31_t)0x2398e898, - (q31_t)0xad72e4f, (q31_t)0x23a3595e, (q31_t)0xade2eb3, (q31_t)0x23adc8c4, - (q31_t)0xae53123, (q31_t)0x23b836ca, (q31_t)0xaec35a0, (q31_t)0x23c2a36f, - (q31_t)0xaf33c28, (q31_t)0x23cd0eb3, (q31_t)0xafa44bc, (q31_t)0x23d77896, - (q31_t)0xb014f5b, (q31_t)0x23e1e117, (q31_t)0xb085c05, (q31_t)0x23ec4837, - (q31_t)0xb0f6aba, (q31_t)0x23f6adf3, (q31_t)0xb167b79, (q31_t)0x2401124d, - (q31_t)0xb1d8e43, (q31_t)0x240b7543, (q31_t)0xb24a316, (q31_t)0x2415d6d5, - (q31_t)0xb2bb9f4, (q31_t)0x24203704, (q31_t)0xb32d2da, (q31_t)0x242a95ce, - (q31_t)0xb39edca, (q31_t)0x2434f332, (q31_t)0xb410ac3, (q31_t)0x243f4f32, - (q31_t)0xb4829c4, (q31_t)0x2449a9cc, (q31_t)0xb4f4acd, (q31_t)0x245402ff, - (q31_t)0xb566ddf, (q31_t)0x245e5acc, (q31_t)0xb5d92f8, (q31_t)0x2468b132, - (q31_t)0xb64ba19, (q31_t)0x24730631, (q31_t)0xb6be341, (q31_t)0x247d59c8, - (q31_t)0xb730e70, (q31_t)0x2487abf7, (q31_t)0xb7a3ba5, (q31_t)0x2491fcbe, - (q31_t)0xb816ae1, (q31_t)0x249c4c1b, (q31_t)0xb889c23, (q31_t)0x24a69a0f, - (q31_t)0xb8fcf6b, (q31_t)0x24b0e699, (q31_t)0xb9704b9, (q31_t)0x24bb31ba, - (q31_t)0xb9e3c0b, (q31_t)0x24c57b6f, (q31_t)0xba57563, (q31_t)0x24cfc3ba, - (q31_t)0xbacb0bf, (q31_t)0x24da0a9a, (q31_t)0xbb3ee20, (q31_t)0x24e4500e, - (q31_t)0xbbb2d85, (q31_t)0x24ee9415, (q31_t)0xbc26eee, (q31_t)0x24f8d6b0, - (q31_t)0xbc9b25a, (q31_t)0x250317df, (q31_t)0xbd0f7ca, (q31_t)0x250d57a0, - (q31_t)0xbd83f3d, (q31_t)0x251795f3, (q31_t)0xbdf88b3, (q31_t)0x2521d2d8, - (q31_t)0xbe6d42b, (q31_t)0x252c0e4f, (q31_t)0xbee21a5, (q31_t)0x25364857, - (q31_t)0xbf57121, (q31_t)0x254080ef, (q31_t)0xbfcc29f, (q31_t)0x254ab818, - (q31_t)0xc04161e, (q31_t)0x2554edd1, (q31_t)0xc0b6b9e, (q31_t)0x255f2219, - (q31_t)0xc12c31f, (q31_t)0x256954f1, (q31_t)0xc1a1ca0, (q31_t)0x25738657, - (q31_t)0xc217822, (q31_t)0x257db64c, (q31_t)0xc28d5a3, (q31_t)0x2587e4cf, - (q31_t)0xc303524, (q31_t)0x259211df, (q31_t)0xc3796a5, (q31_t)0x259c3d7c, - (q31_t)0xc3efa25, (q31_t)0x25a667a7, (q31_t)0xc465fa3, (q31_t)0x25b0905d, - (q31_t)0xc4dc720, (q31_t)0x25bab7a0, (q31_t)0xc55309b, (q31_t)0x25c4dd6e, - (q31_t)0xc5c9c14, (q31_t)0x25cf01c8, (q31_t)0xc64098b, (q31_t)0x25d924ac, - (q31_t)0xc6b78ff, (q31_t)0x25e3461b, (q31_t)0xc72ea70, (q31_t)0x25ed6614, - (q31_t)0xc7a5dde, (q31_t)0x25f78497, (q31_t)0xc81d349, (q31_t)0x2601a1a2, - (q31_t)0xc894aaf, (q31_t)0x260bbd37, (q31_t)0xc90c412, (q31_t)0x2615d754, - (q31_t)0xc983f70, (q31_t)0x261feffa, (q31_t)0xc9fbcca, (q31_t)0x262a0727, - (q31_t)0xca73c1e, (q31_t)0x26341cdb, (q31_t)0xcaebd6e, (q31_t)0x263e3117, - (q31_t)0xcb640b8, (q31_t)0x264843d9, (q31_t)0xcbdc5fc, (q31_t)0x26525521, - (q31_t)0xcc54d3a, (q31_t)0x265c64ef, (q31_t)0xcccd671, (q31_t)0x26667342, - (q31_t)0xcd461a2, (q31_t)0x2670801a, (q31_t)0xcdbeecc, (q31_t)0x267a8b77, - (q31_t)0xce37def, (q31_t)0x26849558, (q31_t)0xceb0f0a, (q31_t)0x268e9dbd, - (q31_t)0xcf2a21d, (q31_t)0x2698a4a6, (q31_t)0xcfa3729, (q31_t)0x26a2aa11, - (q31_t)0xd01ce2b, (q31_t)0x26acadff, (q31_t)0xd096725, (q31_t)0x26b6b070, - (q31_t)0xd110216, (q31_t)0x26c0b162, (q31_t)0xd189efe, (q31_t)0x26cab0d6, - (q31_t)0xd203ddc, (q31_t)0x26d4aecb, (q31_t)0xd27deb0, (q31_t)0x26deab41, - (q31_t)0xd2f817b, (q31_t)0x26e8a637, (q31_t)0xd37263a, (q31_t)0x26f29fad, - (q31_t)0xd3eccef, (q31_t)0x26fc97a3, (q31_t)0xd467599, (q31_t)0x27068e18, - (q31_t)0xd4e2037, (q31_t)0x2710830c, (q31_t)0xd55ccca, (q31_t)0x271a767e, - (q31_t)0xd5d7b50, (q31_t)0x2724686e, (q31_t)0xd652bcb, (q31_t)0x272e58dc, - (q31_t)0xd6cde39, (q31_t)0x273847c8, (q31_t)0xd74929a, (q31_t)0x27423530, - (q31_t)0xd7c48ee, (q31_t)0x274c2115, (q31_t)0xd840134, (q31_t)0x27560b76, - (q31_t)0xd8bbb6d, (q31_t)0x275ff452, (q31_t)0xd937798, (q31_t)0x2769dbaa, - (q31_t)0xd9b35b4, (q31_t)0x2773c17d, (q31_t)0xda2f5c2, (q31_t)0x277da5cb, - (q31_t)0xdaab7c0, (q31_t)0x27878893, (q31_t)0xdb27bb0, (q31_t)0x279169d5, - (q31_t)0xdba4190, (q31_t)0x279b4990, (q31_t)0xdc20960, (q31_t)0x27a527c4, - (q31_t)0xdc9d320, (q31_t)0x27af0472, (q31_t)0xdd19ed0, (q31_t)0x27b8df97, - (q31_t)0xdd96c6f, (q31_t)0x27c2b934, (q31_t)0xde13bfd, (q31_t)0x27cc9149, - (q31_t)0xde90d79, (q31_t)0x27d667d5, (q31_t)0xdf0e0e4, (q31_t)0x27e03cd8, - (q31_t)0xdf8b63d, (q31_t)0x27ea1052, (q31_t)0xe008d84, (q31_t)0x27f3e241, - (q31_t)0xe0866b8, (q31_t)0x27fdb2a7, (q31_t)0xe1041d9, (q31_t)0x28078181, - (q31_t)0xe181ee8, (q31_t)0x28114ed0, (q31_t)0xe1ffde2, (q31_t)0x281b1a94, - (q31_t)0xe27dec9, (q31_t)0x2824e4cc, (q31_t)0xe2fc19c, (q31_t)0x282ead78, - (q31_t)0xe37a65b, (q31_t)0x28387498, (q31_t)0xe3f8d05, (q31_t)0x28423a2a, - (q31_t)0xe47759a, (q31_t)0x284bfe2f, (q31_t)0xe4f6019, (q31_t)0x2855c0a6, - (q31_t)0xe574c84, (q31_t)0x285f8190, (q31_t)0xe5f3ad8, (q31_t)0x286940ea, - (q31_t)0xe672b16, (q31_t)0x2872feb6, (q31_t)0xe6f1d3d, (q31_t)0x287cbaf3, - (q31_t)0xe77114e, (q31_t)0x288675a0, (q31_t)0xe7f0748, (q31_t)0x28902ebd, - (q31_t)0xe86ff2a, (q31_t)0x2899e64a, (q31_t)0xe8ef8f4, (q31_t)0x28a39c46, - (q31_t)0xe96f4a7, (q31_t)0x28ad50b1, (q31_t)0xe9ef241, (q31_t)0x28b7038b, - (q31_t)0xea6f1c2, (q31_t)0x28c0b4d2, (q31_t)0xeaef32b, (q31_t)0x28ca6488, - (q31_t)0xeb6f67a, (q31_t)0x28d412ab, (q31_t)0xebefbb0, (q31_t)0x28ddbf3b, - (q31_t)0xec702cb, (q31_t)0x28e76a37, (q31_t)0xecf0bcd, (q31_t)0x28f113a0, - (q31_t)0xed716b4, (q31_t)0x28fabb75, (q31_t)0xedf2380, (q31_t)0x290461b5, - (q31_t)0xee73231, (q31_t)0x290e0661, (q31_t)0xeef42c7, (q31_t)0x2917a977, - (q31_t)0xef75541, (q31_t)0x29214af8, (q31_t)0xeff699f, (q31_t)0x292aeae3, - (q31_t)0xf077fe1, (q31_t)0x29348937, (q31_t)0xf0f9805, (q31_t)0x293e25f5, - (q31_t)0xf17b20d, (q31_t)0x2947c11c, (q31_t)0xf1fcdf8, (q31_t)0x29515aab, - (q31_t)0xf27ebc5, (q31_t)0x295af2a3, (q31_t)0xf300b74, (q31_t)0x29648902, - (q31_t)0xf382d05, (q31_t)0x296e1dc9, (q31_t)0xf405077, (q31_t)0x2977b0f7, - (q31_t)0xf4875ca, (q31_t)0x2981428c, (q31_t)0xf509cfe, (q31_t)0x298ad287, - (q31_t)0xf58c613, (q31_t)0x299460e8, (q31_t)0xf60f108, (q31_t)0x299dedaf, - (q31_t)0xf691ddd, (q31_t)0x29a778db, (q31_t)0xf714c91, (q31_t)0x29b1026c, - (q31_t)0xf797d24, (q31_t)0x29ba8a61, (q31_t)0xf81af97, (q31_t)0x29c410ba, - (q31_t)0xf89e3e8, (q31_t)0x29cd9578, (q31_t)0xf921a17, (q31_t)0x29d71899, - (q31_t)0xf9a5225, (q31_t)0x29e09a1c, (q31_t)0xfa28c10, (q31_t)0x29ea1a03, - (q31_t)0xfaac7d8, (q31_t)0x29f3984c, (q31_t)0xfb3057d, (q31_t)0x29fd14f6, - (q31_t)0xfbb4500, (q31_t)0x2a069003, (q31_t)0xfc3865e, (q31_t)0x2a100970, - (q31_t)0xfcbc999, (q31_t)0x2a19813f, (q31_t)0xfd40eaf, (q31_t)0x2a22f76e, - (q31_t)0xfdc55a1, (q31_t)0x2a2c6bfd, (q31_t)0xfe49e6d, (q31_t)0x2a35deeb, - (q31_t)0xfece915, (q31_t)0x2a3f503a, (q31_t)0xff53597, (q31_t)0x2a48bfe7, - (q31_t)0xffd83f4, (q31_t)0x2a522df3, (q31_t)0x1005d42a, (q31_t)0x2a5b9a5d, + (q31_t)0xffd83f4, (q31_t)0xd5add20d, (q31_t)0xff53597, (q31_t)0xd5b74019, + (q31_t)0xfece915, (q31_t)0xd5c0afc6, (q31_t)0xfe49e6d, (q31_t)0xd5ca2115, + (q31_t)0xfdc55a1, (q31_t)0xd5d39403, (q31_t)0xfd40eaf, (q31_t)0xd5dd0892, + (q31_t)0xfcbc999, (q31_t)0xd5e67ec1, (q31_t)0xfc3865e, (q31_t)0xd5eff690, + (q31_t)0xfbb4500, (q31_t)0xd5f96ffd, (q31_t)0xfb3057d, (q31_t)0xd602eb0a, + (q31_t)0xfaac7d8, (q31_t)0xd60c67b4, (q31_t)0xfa28c10, (q31_t)0xd615e5fd, + (q31_t)0xf9a5225, (q31_t)0xd61f65e4, (q31_t)0xf921a17, (q31_t)0xd628e767, + (q31_t)0xf89e3e8, (q31_t)0xd6326a88, (q31_t)0xf81af97, (q31_t)0xd63bef46, + (q31_t)0xf797d24, (q31_t)0xd645759f, (q31_t)0xf714c91, (q31_t)0xd64efd94, + (q31_t)0xf691ddd, (q31_t)0xd6588725, (q31_t)0xf60f108, (q31_t)0xd6621251, + (q31_t)0xf58c613, (q31_t)0xd66b9f18, (q31_t)0xf509cfe, (q31_t)0xd6752d79, + (q31_t)0xf4875ca, (q31_t)0xd67ebd74, (q31_t)0xf405077, (q31_t)0xd6884f09, + (q31_t)0xf382d05, (q31_t)0xd691e237, (q31_t)0xf300b74, (q31_t)0xd69b76fe, + (q31_t)0xf27ebc5, (q31_t)0xd6a50d5d, (q31_t)0xf1fcdf8, (q31_t)0xd6aea555, + (q31_t)0xf17b20d, (q31_t)0xd6b83ee4, (q31_t)0xf0f9805, (q31_t)0xd6c1da0b, + (q31_t)0xf077fe1, (q31_t)0xd6cb76c9, (q31_t)0xeff699f, (q31_t)0xd6d5151d, + (q31_t)0xef75541, (q31_t)0xd6deb508, (q31_t)0xeef42c7, (q31_t)0xd6e85689, + (q31_t)0xee73231, (q31_t)0xd6f1f99f, (q31_t)0xedf2380, (q31_t)0xd6fb9e4b, + (q31_t)0xed716b4, (q31_t)0xd705448b, (q31_t)0xecf0bcd, (q31_t)0xd70eec60, + (q31_t)0xec702cb, (q31_t)0xd71895c9, (q31_t)0xebefbb0, (q31_t)0xd72240c5, + (q31_t)0xeb6f67a, (q31_t)0xd72bed55, (q31_t)0xeaef32b, (q31_t)0xd7359b78, + (q31_t)0xea6f1c2, (q31_t)0xd73f4b2e, (q31_t)0xe9ef241, (q31_t)0xd748fc75, + (q31_t)0xe96f4a7, (q31_t)0xd752af4f, (q31_t)0xe8ef8f4, (q31_t)0xd75c63ba, + (q31_t)0xe86ff2a, (q31_t)0xd76619b6, (q31_t)0xe7f0748, (q31_t)0xd76fd143, + (q31_t)0xe77114e, (q31_t)0xd7798a60, (q31_t)0xe6f1d3d, (q31_t)0xd783450d, + (q31_t)0xe672b16, (q31_t)0xd78d014a, (q31_t)0xe5f3ad8, (q31_t)0xd796bf16, + (q31_t)0xe574c84, (q31_t)0xd7a07e70, (q31_t)0xe4f6019, (q31_t)0xd7aa3f5a, + (q31_t)0xe47759a, (q31_t)0xd7b401d1, (q31_t)0xe3f8d05, (q31_t)0xd7bdc5d6, + (q31_t)0xe37a65b, (q31_t)0xd7c78b68, (q31_t)0xe2fc19c, (q31_t)0xd7d15288, + (q31_t)0xe27dec9, (q31_t)0xd7db1b34, (q31_t)0xe1ffde2, (q31_t)0xd7e4e56c, + (q31_t)0xe181ee8, (q31_t)0xd7eeb130, (q31_t)0xe1041d9, (q31_t)0xd7f87e7f, + (q31_t)0xe0866b8, (q31_t)0xd8024d59, (q31_t)0xe008d84, (q31_t)0xd80c1dbf, + (q31_t)0xdf8b63d, (q31_t)0xd815efae, (q31_t)0xdf0e0e4, (q31_t)0xd81fc328, + (q31_t)0xde90d79, (q31_t)0xd829982b, (q31_t)0xde13bfd, (q31_t)0xd8336eb7, + (q31_t)0xdd96c6f, (q31_t)0xd83d46cc, (q31_t)0xdd19ed0, (q31_t)0xd8472069, + (q31_t)0xdc9d320, (q31_t)0xd850fb8e, (q31_t)0xdc20960, (q31_t)0xd85ad83c, + (q31_t)0xdba4190, (q31_t)0xd864b670, (q31_t)0xdb27bb0, (q31_t)0xd86e962b, + (q31_t)0xdaab7c0, (q31_t)0xd878776d, (q31_t)0xda2f5c2, (q31_t)0xd8825a35, + (q31_t)0xd9b35b4, (q31_t)0xd88c3e83, (q31_t)0xd937798, (q31_t)0xd8962456, + (q31_t)0xd8bbb6d, (q31_t)0xd8a00bae, (q31_t)0xd840134, (q31_t)0xd8a9f48a, + (q31_t)0xd7c48ee, (q31_t)0xd8b3deeb, (q31_t)0xd74929a, (q31_t)0xd8bdcad0, + (q31_t)0xd6cde39, (q31_t)0xd8c7b838, (q31_t)0xd652bcb, (q31_t)0xd8d1a724, + (q31_t)0xd5d7b50, (q31_t)0xd8db9792, (q31_t)0xd55ccca, (q31_t)0xd8e58982, + (q31_t)0xd4e2037, (q31_t)0xd8ef7cf4, (q31_t)0xd467599, (q31_t)0xd8f971e8, + (q31_t)0xd3eccef, (q31_t)0xd903685d, (q31_t)0xd37263a, (q31_t)0xd90d6053, + (q31_t)0xd2f817b, (q31_t)0xd91759c9, (q31_t)0xd27deb0, (q31_t)0xd92154bf, + (q31_t)0xd203ddc, (q31_t)0xd92b5135, (q31_t)0xd189efe, (q31_t)0xd9354f2a, + (q31_t)0xd110216, (q31_t)0xd93f4e9e, (q31_t)0xd096725, (q31_t)0xd9494f90, + (q31_t)0xd01ce2b, (q31_t)0xd9535201, (q31_t)0xcfa3729, (q31_t)0xd95d55ef, + (q31_t)0xcf2a21d, (q31_t)0xd9675b5a, (q31_t)0xceb0f0a, (q31_t)0xd9716243, + (q31_t)0xce37def, (q31_t)0xd97b6aa8, (q31_t)0xcdbeecc, (q31_t)0xd9857489, + (q31_t)0xcd461a2, (q31_t)0xd98f7fe6, (q31_t)0xcccd671, (q31_t)0xd9998cbe, + (q31_t)0xcc54d3a, (q31_t)0xd9a39b11, (q31_t)0xcbdc5fc, (q31_t)0xd9adaadf, + (q31_t)0xcb640b8, (q31_t)0xd9b7bc27, (q31_t)0xcaebd6e, (q31_t)0xd9c1cee9, + (q31_t)0xca73c1e, (q31_t)0xd9cbe325, (q31_t)0xc9fbcca, (q31_t)0xd9d5f8d9, + (q31_t)0xc983f70, (q31_t)0xd9e01006, (q31_t)0xc90c412, (q31_t)0xd9ea28ac, + (q31_t)0xc894aaf, (q31_t)0xd9f442c9, (q31_t)0xc81d349, (q31_t)0xd9fe5e5e, + (q31_t)0xc7a5dde, (q31_t)0xda087b69, (q31_t)0xc72ea70, (q31_t)0xda1299ec, + (q31_t)0xc6b78ff, (q31_t)0xda1cb9e5, (q31_t)0xc64098b, (q31_t)0xda26db54, + (q31_t)0xc5c9c14, (q31_t)0xda30fe38, (q31_t)0xc55309b, (q31_t)0xda3b2292, + (q31_t)0xc4dc720, (q31_t)0xda454860, (q31_t)0xc465fa3, (q31_t)0xda4f6fa3, + (q31_t)0xc3efa25, (q31_t)0xda599859, (q31_t)0xc3796a5, (q31_t)0xda63c284, + (q31_t)0xc303524, (q31_t)0xda6dee21, (q31_t)0xc28d5a3, (q31_t)0xda781b31, + (q31_t)0xc217822, (q31_t)0xda8249b4, (q31_t)0xc1a1ca0, (q31_t)0xda8c79a9, + (q31_t)0xc12c31f, (q31_t)0xda96ab0f, (q31_t)0xc0b6b9e, (q31_t)0xdaa0dde7, + (q31_t)0xc04161e, (q31_t)0xdaab122f, (q31_t)0xbfcc29f, (q31_t)0xdab547e8, + (q31_t)0xbf57121, (q31_t)0xdabf7f11, (q31_t)0xbee21a5, (q31_t)0xdac9b7a9, + (q31_t)0xbe6d42b, (q31_t)0xdad3f1b1, (q31_t)0xbdf88b3, (q31_t)0xdade2d28, + (q31_t)0xbd83f3d, (q31_t)0xdae86a0d, (q31_t)0xbd0f7ca, (q31_t)0xdaf2a860, + (q31_t)0xbc9b25a, (q31_t)0xdafce821, (q31_t)0xbc26eee, (q31_t)0xdb072950, + (q31_t)0xbbb2d85, (q31_t)0xdb116beb, (q31_t)0xbb3ee20, (q31_t)0xdb1baff2, + (q31_t)0xbacb0bf, (q31_t)0xdb25f566, (q31_t)0xba57563, (q31_t)0xdb303c46, + (q31_t)0xb9e3c0b, (q31_t)0xdb3a8491, (q31_t)0xb9704b9, (q31_t)0xdb44ce46, + (q31_t)0xb8fcf6b, (q31_t)0xdb4f1967, (q31_t)0xb889c23, (q31_t)0xdb5965f1, + (q31_t)0xb816ae1, (q31_t)0xdb63b3e5, (q31_t)0xb7a3ba5, (q31_t)0xdb6e0342, + (q31_t)0xb730e70, (q31_t)0xdb785409, (q31_t)0xb6be341, (q31_t)0xdb82a638, + (q31_t)0xb64ba19, (q31_t)0xdb8cf9cf, (q31_t)0xb5d92f8, (q31_t)0xdb974ece, + (q31_t)0xb566ddf, (q31_t)0xdba1a534, (q31_t)0xb4f4acd, (q31_t)0xdbabfd01, + (q31_t)0xb4829c4, (q31_t)0xdbb65634, (q31_t)0xb410ac3, (q31_t)0xdbc0b0ce, + (q31_t)0xb39edca, (q31_t)0xdbcb0cce, (q31_t)0xb32d2da, (q31_t)0xdbd56a32, + (q31_t)0xb2bb9f4, (q31_t)0xdbdfc8fc, (q31_t)0xb24a316, (q31_t)0xdbea292b, + (q31_t)0xb1d8e43, (q31_t)0xdbf48abd, (q31_t)0xb167b79, (q31_t)0xdbfeedb3, + (q31_t)0xb0f6aba, (q31_t)0xdc09520d, (q31_t)0xb085c05, (q31_t)0xdc13b7c9, + (q31_t)0xb014f5b, (q31_t)0xdc1e1ee9, (q31_t)0xafa44bc, (q31_t)0xdc28876a, + (q31_t)0xaf33c28, (q31_t)0xdc32f14d, (q31_t)0xaec35a0, (q31_t)0xdc3d5c91, + (q31_t)0xae53123, (q31_t)0xdc47c936, (q31_t)0xade2eb3, (q31_t)0xdc52373c, + (q31_t)0xad72e4f, (q31_t)0xdc5ca6a2, (q31_t)0xad02ff8, (q31_t)0xdc671768, + (q31_t)0xac933ae, (q31_t)0xdc71898d, (q31_t)0xac23971, (q31_t)0xdc7bfd11, + (q31_t)0xabb4141, (q31_t)0xdc8671f3, (q31_t)0xab44b1f, (q31_t)0xdc90e834, + (q31_t)0xaad570c, (q31_t)0xdc9b5fd2, (q31_t)0xaa66506, (q31_t)0xdca5d8cd, + (q31_t)0xa9f750f, (q31_t)0xdcb05326, (q31_t)0xa988727, (q31_t)0xdcbacedb, + (q31_t)0xa919b4e, (q31_t)0xdcc54bec, (q31_t)0xa8ab184, (q31_t)0xdccfca59, + (q31_t)0xa83c9ca, (q31_t)0xdcda4a21, (q31_t)0xa7ce420, (q31_t)0xdce4cb44, + (q31_t)0xa760086, (q31_t)0xdcef4dc2, (q31_t)0xa6f1efc, (q31_t)0xdcf9d199, + (q31_t)0xa683f83, (q31_t)0xdd0456ca, (q31_t)0xa61621b, (q31_t)0xdd0edd55, + (q31_t)0xa5a86c4, (q31_t)0xdd196538, (q31_t)0xa53ad7e, (q31_t)0xdd23ee74, + (q31_t)0xa4cd64b, (q31_t)0xdd2e7908, (q31_t)0xa460129, (q31_t)0xdd3904f4, + (q31_t)0xa3f2e19, (q31_t)0xdd439236, (q31_t)0xa385d1d, (q31_t)0xdd4e20d0, + (q31_t)0xa318e32, (q31_t)0xdd58b0c0, (q31_t)0xa2ac15b, (q31_t)0xdd634206, + (q31_t)0xa23f698, (q31_t)0xdd6dd4a2, (q31_t)0xa1d2de7, (q31_t)0xdd786892, + (q31_t)0xa16674b, (q31_t)0xdd82fdd8, (q31_t)0xa0fa2c3, (q31_t)0xdd8d9472, + (q31_t)0xa08e04f, (q31_t)0xdd982c60, (q31_t)0xa021fef, (q31_t)0xdda2c5a2, + (q31_t)0x9fb61a5, (q31_t)0xddad6036, (q31_t)0x9f4a570, (q31_t)0xddb7fc1e, + (q31_t)0x9edeb50, (q31_t)0xddc29958, (q31_t)0x9e73346, (q31_t)0xddcd37e4, + (q31_t)0x9e07d51, (q31_t)0xddd7d7c1, (q31_t)0x9d9c973, (q31_t)0xdde278ef, + (q31_t)0x9d317ab, (q31_t)0xdded1b6e, (q31_t)0x9cc67fa, (q31_t)0xddf7bf3e, + (q31_t)0x9c5ba60, (q31_t)0xde02645d, (q31_t)0x9bf0edd, (q31_t)0xde0d0acc, + (q31_t)0x9b86572, (q31_t)0xde17b28a, (q31_t)0x9b1be1e, (q31_t)0xde225b96, + (q31_t)0x9ab18e3, (q31_t)0xde2d05f1, (q31_t)0x9a475bf, (q31_t)0xde37b199, + (q31_t)0x99dd4b4, (q31_t)0xde425e8f, (q31_t)0x99735c2, (q31_t)0xde4d0cd2, + (q31_t)0x99098e9, (q31_t)0xde57bc62, (q31_t)0x989fe29, (q31_t)0xde626d3e, + (q31_t)0x9836582, (q31_t)0xde6d1f65, (q31_t)0x97ccef5, (q31_t)0xde77d2d8, + (q31_t)0x9763a83, (q31_t)0xde828796, (q31_t)0x96fa82a, (q31_t)0xde8d3d9e, + (q31_t)0x96917ec, (q31_t)0xde97f4f1, (q31_t)0x96289c9, (q31_t)0xdea2ad8d, + (q31_t)0x95bfdc1, (q31_t)0xdead6773, (q31_t)0x95573d4, (q31_t)0xdeb822a1, + (q31_t)0x94eec03, (q31_t)0xdec2df18, (q31_t)0x948664d, (q31_t)0xdecd9cd7, + (q31_t)0x941e2b4, (q31_t)0xded85bdd, (q31_t)0x93b6137, (q31_t)0xdee31c2b, + (q31_t)0x934e1d6, (q31_t)0xdeedddc0, (q31_t)0x92e6492, (q31_t)0xdef8a09b, + (q31_t)0x927e96b, (q31_t)0xdf0364bc, (q31_t)0x9217062, (q31_t)0xdf0e2a22, + (q31_t)0x91af976, (q31_t)0xdf18f0ce, (q31_t)0x91484a8, (q31_t)0xdf23b8be, + (q31_t)0x90e11f7, (q31_t)0xdf2e81f3, (q31_t)0x907a166, (q31_t)0xdf394c6b, + (q31_t)0x90132f2, (q31_t)0xdf441828, (q31_t)0x8fac69e, (q31_t)0xdf4ee527, + (q31_t)0x8f45c68, (q31_t)0xdf59b369, (q31_t)0x8edf452, (q31_t)0xdf6482ed, + (q31_t)0x8e78e5b, (q31_t)0xdf6f53b3, (q31_t)0x8e12a84, (q31_t)0xdf7a25ba, + (q31_t)0x8dac8cd, (q31_t)0xdf84f902, (q31_t)0x8d46936, (q31_t)0xdf8fcd8b, + (q31_t)0x8ce0bc0, (q31_t)0xdf9aa354, (q31_t)0x8c7b06b, (q31_t)0xdfa57a5d, + (q31_t)0x8c15736, (q31_t)0xdfb052a5, (q31_t)0x8bb0023, (q31_t)0xdfbb2c2c, + (q31_t)0x8b4ab32, (q31_t)0xdfc606f1, (q31_t)0x8ae5862, (q31_t)0xdfd0e2f5, + (q31_t)0x8a807b4, (q31_t)0xdfdbc036, (q31_t)0x8a1b928, (q31_t)0xdfe69eb4, + (q31_t)0x89b6cbf, (q31_t)0xdff17e70, (q31_t)0x8952278, (q31_t)0xdffc5f67, + (q31_t)0x88eda54, (q31_t)0xe007419b, (q31_t)0x8889454, (q31_t)0xe012250a, + (q31_t)0x8825077, (q31_t)0xe01d09b4, (q31_t)0x87c0ebd, (q31_t)0xe027ef99, + (q31_t)0x875cf28, (q31_t)0xe032d6b8, (q31_t)0x86f91b7, (q31_t)0xe03dbf11, + (q31_t)0x869566a, (q31_t)0xe048a8a4, (q31_t)0x8631d42, (q31_t)0xe053936f, + (q31_t)0x85ce63e, (q31_t)0xe05e7f74, (q31_t)0x856b160, (q31_t)0xe0696cb0, + (q31_t)0x8507ea7, (q31_t)0xe0745b24, (q31_t)0x84a4e14, (q31_t)0xe07f4acf, + (q31_t)0x8441fa6, (q31_t)0xe08a3bb2, (q31_t)0x83df35f, (q31_t)0xe0952dcb, + (q31_t)0x837c93e, (q31_t)0xe0a0211a, (q31_t)0x831a143, (q31_t)0xe0ab159e, + (q31_t)0x82b7b70, (q31_t)0xe0b60b58, (q31_t)0x82557c3, (q31_t)0xe0c10247, + (q31_t)0x81f363d, (q31_t)0xe0cbfa6a, (q31_t)0x81916df, (q31_t)0xe0d6f3c1, + (q31_t)0x812f9a9, (q31_t)0xe0e1ee4b, (q31_t)0x80cde9b, (q31_t)0xe0ecea09, + (q31_t)0x806c5b5, (q31_t)0xe0f7e6f9, (q31_t)0x800aef7, (q31_t)0xe102e51c, + (q31_t)0x7fa9a62, (q31_t)0xe10de470, (q31_t)0x7f487f6, (q31_t)0xe118e4f6, + (q31_t)0x7ee77b3, (q31_t)0xe123e6ad, (q31_t)0x7e8699a, (q31_t)0xe12ee995, + (q31_t)0x7e25daa, (q31_t)0xe139edac, (q31_t)0x7dc53e3, (q31_t)0xe144f2f3, + (q31_t)0x7d64c47, (q31_t)0xe14ff96a, (q31_t)0x7d046d6, (q31_t)0xe15b0110, + (q31_t)0x7ca438f, (q31_t)0xe16609e3, (q31_t)0x7c44272, (q31_t)0xe17113e5, + (q31_t)0x7be4381, (q31_t)0xe17c1f15, (q31_t)0x7b846ba, (q31_t)0xe1872b72, + (q31_t)0x7b24c20, (q31_t)0xe19238fb, (q31_t)0x7ac53b1, (q31_t)0xe19d47b1, + (q31_t)0x7a65d6e, (q31_t)0xe1a85793, (q31_t)0x7a06957, (q31_t)0xe1b368a0, + (q31_t)0x79a776c, (q31_t)0xe1be7ad8, (q31_t)0x79487ae, (q31_t)0xe1c98e3b, + (q31_t)0x78e9a1d, (q31_t)0xe1d4a2c8, (q31_t)0x788aeb9, (q31_t)0xe1dfb87f, + (q31_t)0x782c582, (q31_t)0xe1eacf5f, (q31_t)0x77cde79, (q31_t)0xe1f5e768, + (q31_t)0x776f99d, (q31_t)0xe2010099, (q31_t)0x77116f0, (q31_t)0xe20c1af3, + (q31_t)0x76b3671, (q31_t)0xe2173674, (q31_t)0x7655820, (q31_t)0xe222531c, + (q31_t)0x75f7bfe, (q31_t)0xe22d70eb, (q31_t)0x759a20a, (q31_t)0xe2388fe1, + (q31_t)0x753ca46, (q31_t)0xe243affc, (q31_t)0x74df4b1, (q31_t)0xe24ed13d, + (q31_t)0x748214c, (q31_t)0xe259f3a3, (q31_t)0x7425016, (q31_t)0xe265172e, + (q31_t)0x73c8111, (q31_t)0xe2703bdc, (q31_t)0x736b43c, (q31_t)0xe27b61af, + (q31_t)0x730e997, (q31_t)0xe28688a4, (q31_t)0x72b2123, (q31_t)0xe291b0bd, + (q31_t)0x7255ae0, (q31_t)0xe29cd9f8, (q31_t)0x71f96ce, (q31_t)0xe2a80456, + (q31_t)0x719d4ed, (q31_t)0xe2b32fd4, (q31_t)0x714153e, (q31_t)0xe2be5c74, + (q31_t)0x70e57c0, (q31_t)0xe2c98a35, (q31_t)0x7089c75, (q31_t)0xe2d4b916, + (q31_t)0x702e35c, (q31_t)0xe2dfe917, (q31_t)0x6fd2c75, (q31_t)0xe2eb1a37, + (q31_t)0x6f777c1, (q31_t)0xe2f64c77, (q31_t)0x6f1c540, (q31_t)0xe3017fd5, + (q31_t)0x6ec14f2, (q31_t)0xe30cb451, (q31_t)0x6e666d7, (q31_t)0xe317e9eb, + (q31_t)0x6e0baf0, (q31_t)0xe32320a2, (q31_t)0x6db113d, (q31_t)0xe32e5876, + (q31_t)0x6d569be, (q31_t)0xe3399167, (q31_t)0x6cfc472, (q31_t)0xe344cb73, + (q31_t)0x6ca215c, (q31_t)0xe350069b, (q31_t)0x6c4807a, (q31_t)0xe35b42df, + (q31_t)0x6bee1cd, (q31_t)0xe366803c, (q31_t)0x6b94554, (q31_t)0xe371beb5, + (q31_t)0x6b3ab12, (q31_t)0xe37cfe47, (q31_t)0x6ae1304, (q31_t)0xe3883ef2, + (q31_t)0x6a87d2d, (q31_t)0xe39380b6, (q31_t)0x6a2e98b, (q31_t)0xe39ec393, + (q31_t)0x69d5820, (q31_t)0xe3aa0788, (q31_t)0x697c8eb, (q31_t)0xe3b54c95, + (q31_t)0x6923bec, (q31_t)0xe3c092b9, (q31_t)0x68cb124, (q31_t)0xe3cbd9f4, + (q31_t)0x6872894, (q31_t)0xe3d72245, (q31_t)0x681a23a, (q31_t)0xe3e26bac, + (q31_t)0x67c1e18, (q31_t)0xe3edb628, (q31_t)0x6769c2e, (q31_t)0xe3f901ba, + (q31_t)0x6711c7b, (q31_t)0xe4044e60, (q31_t)0x66b9f01, (q31_t)0xe40f9c1a, + (q31_t)0x66623be, (q31_t)0xe41aeae8, (q31_t)0x660aab5, (q31_t)0xe4263ac9, + (q31_t)0x65b33e4, (q31_t)0xe4318bbe, (q31_t)0x655bf4c, (q31_t)0xe43cddc4, + (q31_t)0x6504ced, (q31_t)0xe44830dd, (q31_t)0x64adcc7, (q31_t)0xe4538507, + (q31_t)0x6456edb, (q31_t)0xe45eda43, (q31_t)0x6400329, (q31_t)0xe46a308f, + (q31_t)0x63a99b1, (q31_t)0xe47587eb, (q31_t)0x6353273, (q31_t)0xe480e057, + (q31_t)0x62fcd6f, (q31_t)0xe48c39d3, (q31_t)0x62a6aa6, (q31_t)0xe497945d, + (q31_t)0x6250a18, (q31_t)0xe4a2eff6, (q31_t)0x61fabc4, (q31_t)0xe4ae4c9d, + (q31_t)0x61a4fac, (q31_t)0xe4b9aa52, (q31_t)0x614f5cf, (q31_t)0xe4c50914, + (q31_t)0x60f9e2e, (q31_t)0xe4d068e2, (q31_t)0x60a48c9, (q31_t)0xe4dbc9bd, + (q31_t)0x604f5a0, (q31_t)0xe4e72ba4, (q31_t)0x5ffa4b3, (q31_t)0xe4f28e96, + (q31_t)0x5fa5603, (q31_t)0xe4fdf294, (q31_t)0x5f5098f, (q31_t)0xe509579b, + (q31_t)0x5efbf58, (q31_t)0xe514bdad, (q31_t)0x5ea775e, (q31_t)0xe52024c9, + (q31_t)0x5e531a1, (q31_t)0xe52b8cee, (q31_t)0x5dfee22, (q31_t)0xe536f61b, + (q31_t)0x5daace1, (q31_t)0xe5426051, (q31_t)0x5d56ddd, (q31_t)0xe54dcb8f, + (q31_t)0x5d03118, (q31_t)0xe55937d5, (q31_t)0x5caf690, (q31_t)0xe564a521, + (q31_t)0x5c5be47, (q31_t)0xe5701374, (q31_t)0x5c0883d, (q31_t)0xe57b82cd, + (q31_t)0x5bb5472, (q31_t)0xe586f32c, (q31_t)0x5b622e6, (q31_t)0xe5926490, + (q31_t)0x5b0f399, (q31_t)0xe59dd6f9, (q31_t)0x5abc68c, (q31_t)0xe5a94a67, + (q31_t)0x5a69bbe, (q31_t)0xe5b4bed8, (q31_t)0x5a17330, (q31_t)0xe5c0344d, + (q31_t)0x59c4ce3, (q31_t)0xe5cbaac5, (q31_t)0x59728d5, (q31_t)0xe5d72240, + (q31_t)0x5920708, (q31_t)0xe5e29abc, (q31_t)0x58ce77c, (q31_t)0xe5ee143b, + (q31_t)0x587ca31, (q31_t)0xe5f98ebb, (q31_t)0x582af26, (q31_t)0xe6050a3b, + (q31_t)0x57d965d, (q31_t)0xe61086bc, (q31_t)0x5787fd6, (q31_t)0xe61c043d, + (q31_t)0x5736b90, (q31_t)0xe62782be, (q31_t)0x56e598c, (q31_t)0xe633023e, + (q31_t)0x56949ca, (q31_t)0xe63e82bc, (q31_t)0x5643c4a, (q31_t)0xe64a0438, + (q31_t)0x55f310d, (q31_t)0xe65586b3, (q31_t)0x55a2812, (q31_t)0xe6610a2a, + (q31_t)0x555215a, (q31_t)0xe66c8e9f, (q31_t)0x5501ce5, (q31_t)0xe6781410, + (q31_t)0x54b1ab4, (q31_t)0xe6839a7c, (q31_t)0x5461ac6, (q31_t)0xe68f21e5, + (q31_t)0x5411d1b, (q31_t)0xe69aaa48, (q31_t)0x53c21b4, (q31_t)0xe6a633a6, + (q31_t)0x5372891, (q31_t)0xe6b1bdff, (q31_t)0x53231b3, (q31_t)0xe6bd4951, + (q31_t)0x52d3d18, (q31_t)0xe6c8d59c, (q31_t)0x5284ac3, (q31_t)0xe6d462e1, + (q31_t)0x5235ab2, (q31_t)0xe6dff11d, (q31_t)0x51e6ce6, (q31_t)0xe6eb8052, + (q31_t)0x519815f, (q31_t)0xe6f7107e, (q31_t)0x514981d, (q31_t)0xe702a1a1, + (q31_t)0x50fb121, (q31_t)0xe70e33bb, (q31_t)0x50acc6b, (q31_t)0xe719c6cb, + (q31_t)0x505e9fb, (q31_t)0xe7255ad1, (q31_t)0x50109d0, (q31_t)0xe730efcc, + (q31_t)0x4fc2bec, (q31_t)0xe73c85bc, (q31_t)0x4f7504e, (q31_t)0xe7481ca1, + (q31_t)0x4f276f7, (q31_t)0xe753b479, (q31_t)0x4ed9fe7, (q31_t)0xe75f4d45, + (q31_t)0x4e8cb1e, (q31_t)0xe76ae704, (q31_t)0x4e3f89c, (q31_t)0xe77681b6, + (q31_t)0x4df2862, (q31_t)0xe7821d59, (q31_t)0x4da5a6f, (q31_t)0xe78db9ef, + (q31_t)0x4d58ec3, (q31_t)0xe7995776, (q31_t)0x4d0c560, (q31_t)0xe7a4f5ed, + (q31_t)0x4cbfe45, (q31_t)0xe7b09555, (q31_t)0x4c73972, (q31_t)0xe7bc35ad, + (q31_t)0x4c276e8, (q31_t)0xe7c7d6f4, (q31_t)0x4bdb6a6, (q31_t)0xe7d3792b, + (q31_t)0x4b8f8ad, (q31_t)0xe7df1c50, (q31_t)0x4b43cfd, (q31_t)0xe7eac063, + (q31_t)0x4af8397, (q31_t)0xe7f66564, (q31_t)0x4aacc7a, (q31_t)0xe8020b52, + (q31_t)0x4a617a6, (q31_t)0xe80db22d, (q31_t)0x4a1651c, (q31_t)0xe81959f4, + (q31_t)0x49cb4dd, (q31_t)0xe82502a7, (q31_t)0x49806e7, (q31_t)0xe830ac45, + (q31_t)0x4935b3c, (q31_t)0xe83c56cf, (q31_t)0x48eb1db, (q31_t)0xe8480243, + (q31_t)0x48a0ac4, (q31_t)0xe853aea1, (q31_t)0x48565f9, (q31_t)0xe85f5be9, + (q31_t)0x480c379, (q31_t)0xe86b0a1a, (q31_t)0x47c2344, (q31_t)0xe876b934, + (q31_t)0x477855a, (q31_t)0xe8826936, (q31_t)0x472e9bc, (q31_t)0xe88e1a20, + (q31_t)0x46e5069, (q31_t)0xe899cbf1, (q31_t)0x469b963, (q31_t)0xe8a57ea9, + (q31_t)0x46524a9, (q31_t)0xe8b13248, (q31_t)0x460923b, (q31_t)0xe8bce6cd, + (q31_t)0x45c0219, (q31_t)0xe8c89c37, (q31_t)0x4577444, (q31_t)0xe8d45286, + (q31_t)0x452e8bc, (q31_t)0xe8e009ba, (q31_t)0x44e5f80, (q31_t)0xe8ebc1d3, + (q31_t)0x449d892, (q31_t)0xe8f77acf, (q31_t)0x44553f2, (q31_t)0xe90334af, + (q31_t)0x440d19e, (q31_t)0xe90eef71, (q31_t)0x43c5199, (q31_t)0xe91aab16, + (q31_t)0x437d3e1, (q31_t)0xe926679c, (q31_t)0x4335877, (q31_t)0xe9322505, + (q31_t)0x42edf5c, (q31_t)0xe93de34e, (q31_t)0x42a688f, (q31_t)0xe949a278, + (q31_t)0x425f410, (q31_t)0xe9556282, (q31_t)0x42181e0, (q31_t)0xe961236c, + (q31_t)0x41d11ff, (q31_t)0xe96ce535, (q31_t)0x418a46d, (q31_t)0xe978a7dd, + (q31_t)0x414392b, (q31_t)0xe9846b63, (q31_t)0x40fd037, (q31_t)0xe9902fc7, + (q31_t)0x40b6994, (q31_t)0xe99bf509, (q31_t)0x4070540, (q31_t)0xe9a7bb28, + (q31_t)0x402a33c, (q31_t)0xe9b38223, (q31_t)0x3fe4388, (q31_t)0xe9bf49fa, + (q31_t)0x3f9e624, (q31_t)0xe9cb12ad, (q31_t)0x3f58b10, (q31_t)0xe9d6dc3b, + (q31_t)0x3f1324e, (q31_t)0xe9e2a6a3, (q31_t)0x3ecdbdc, (q31_t)0xe9ee71e6, + (q31_t)0x3e887bb, (q31_t)0xe9fa3e03, (q31_t)0x3e435ea, (q31_t)0xea060af9, + (q31_t)0x3dfe66c, (q31_t)0xea11d8c8, (q31_t)0x3db993e, (q31_t)0xea1da770, + (q31_t)0x3d74e62, (q31_t)0xea2976ef, (q31_t)0x3d305d8, (q31_t)0xea354746, + (q31_t)0x3cebfa0, (q31_t)0xea411874, (q31_t)0x3ca7bba, (q31_t)0xea4cea79, + (q31_t)0x3c63a26, (q31_t)0xea58bd54, (q31_t)0x3c1fae5, (q31_t)0xea649105, + (q31_t)0x3bdbdf6, (q31_t)0xea70658a, (q31_t)0x3b9835a, (q31_t)0xea7c3ae5, + (q31_t)0x3b54b11, (q31_t)0xea881114, (q31_t)0x3b1151b, (q31_t)0xea93e817, + (q31_t)0x3ace178, (q31_t)0xea9fbfed, (q31_t)0x3a8b028, (q31_t)0xeaab9896, + (q31_t)0x3a4812c, (q31_t)0xeab77212, (q31_t)0x3a05484, (q31_t)0xeac34c60, + (q31_t)0x39c2a2f, (q31_t)0xeacf277f, (q31_t)0x398022f, (q31_t)0xeadb0370, + (q31_t)0x393dc82, (q31_t)0xeae6e031, (q31_t)0x38fb92a, (q31_t)0xeaf2bdc3, + (q31_t)0x38b9827, (q31_t)0xeafe9c24, (q31_t)0x3877978, (q31_t)0xeb0a7b54, + (q31_t)0x3835d1e, (q31_t)0xeb165b54, (q31_t)0x37f4319, (q31_t)0xeb223c22, + (q31_t)0x37b2b6a, (q31_t)0xeb2e1dbe, (q31_t)0x377160f, (q31_t)0xeb3a0027, + (q31_t)0x373030a, (q31_t)0xeb45e35d, (q31_t)0x36ef25b, (q31_t)0xeb51c760, + (q31_t)0x36ae401, (q31_t)0xeb5dac2f, (q31_t)0x366d7fd, (q31_t)0xeb6991ca, + (q31_t)0x362ce50, (q31_t)0xeb75782f, (q31_t)0x35ec6f8, (q31_t)0xeb815f60, + (q31_t)0x35ac1f7, (q31_t)0xeb8d475b, (q31_t)0x356bf4d, (q31_t)0xeb99301f, + (q31_t)0x352bef9, (q31_t)0xeba519ad, (q31_t)0x34ec0fc, (q31_t)0xebb10404, + (q31_t)0x34ac556, (q31_t)0xebbcef23, (q31_t)0x346cc07, (q31_t)0xebc8db0b, + (q31_t)0x342d510, (q31_t)0xebd4c7ba, (q31_t)0x33ee070, (q31_t)0xebe0b52f, + (q31_t)0x33aee27, (q31_t)0xebeca36c, (q31_t)0x336fe37, (q31_t)0xebf8926f, + (q31_t)0x333109e, (q31_t)0xec048237, (q31_t)0x32f255e, (q31_t)0xec1072c4, + (q31_t)0x32b3c75, (q31_t)0xec1c6417, (q31_t)0x32755e5, (q31_t)0xec28562d, + (q31_t)0x32371ae, (q31_t)0xec344908, (q31_t)0x31f8fcf, (q31_t)0xec403ca5, + (q31_t)0x31bb049, (q31_t)0xec4c3106, (q31_t)0x317d31c, (q31_t)0xec582629, + (q31_t)0x313f848, (q31_t)0xec641c0e, (q31_t)0x3101fce, (q31_t)0xec7012b5, + (q31_t)0x30c49ad, (q31_t)0xec7c0a1d, (q31_t)0x30875e5, (q31_t)0xec880245, + (q31_t)0x304a477, (q31_t)0xec93fb2e, (q31_t)0x300d563, (q31_t)0xec9ff4d6, + (q31_t)0x2fd08a9, (q31_t)0xecabef3d, (q31_t)0x2f93e4a, (q31_t)0xecb7ea63, + (q31_t)0x2f57644, (q31_t)0xecc3e648, (q31_t)0x2f1b099, (q31_t)0xeccfe2ea, + (q31_t)0x2eded49, (q31_t)0xecdbe04a, (q31_t)0x2ea2c53, (q31_t)0xece7de66, + (q31_t)0x2e66db8, (q31_t)0xecf3dd3f, (q31_t)0x2e2b178, (q31_t)0xecffdcd4, + (q31_t)0x2def794, (q31_t)0xed0bdd25, (q31_t)0x2db400a, (q31_t)0xed17de31, + (q31_t)0x2d78add, (q31_t)0xed23dff7, (q31_t)0x2d3d80a, (q31_t)0xed2fe277, + (q31_t)0x2d02794, (q31_t)0xed3be5b1, (q31_t)0x2cc7979, (q31_t)0xed47e9a5, + (q31_t)0x2c8cdbb, (q31_t)0xed53ee51, (q31_t)0x2c52459, (q31_t)0xed5ff3b5, + (q31_t)0x2c17d52, (q31_t)0xed6bf9d1, (q31_t)0x2bdd8a9, (q31_t)0xed7800a5, + (q31_t)0x2ba365c, (q31_t)0xed84082f, (q31_t)0x2b6966c, (q31_t)0xed901070, + (q31_t)0x2b2f8d8, (q31_t)0xed9c1967, (q31_t)0x2af5da2, (q31_t)0xeda82313, + (q31_t)0x2abc4c9, (q31_t)0xedb42d74, (q31_t)0x2a82e4d, (q31_t)0xedc0388a, + (q31_t)0x2a49a2e, (q31_t)0xedcc4454, (q31_t)0x2a1086d, (q31_t)0xedd850d2, + (q31_t)0x29d790a, (q31_t)0xede45e03, (q31_t)0x299ec05, (q31_t)0xedf06be6, + (q31_t)0x296615d, (q31_t)0xedfc7a7c, (q31_t)0x292d914, (q31_t)0xee0889c4, + (q31_t)0x28f5329, (q31_t)0xee1499bd, (q31_t)0x28bcf9c, (q31_t)0xee20aa67, + (q31_t)0x2884e6e, (q31_t)0xee2cbbc1, (q31_t)0x284cf9f, (q31_t)0xee38cdcb, + (q31_t)0x281532e, (q31_t)0xee44e084, (q31_t)0x27dd91c, (q31_t)0xee50f3ed, + (q31_t)0x27a616a, (q31_t)0xee5d0804, (q31_t)0x276ec16, (q31_t)0xee691cc9, + (q31_t)0x2737922, (q31_t)0xee75323c, (q31_t)0x270088e, (q31_t)0xee81485c, + (q31_t)0x26c9a58, (q31_t)0xee8d5f29, (q31_t)0x2692e83, (q31_t)0xee9976a1, + (q31_t)0x265c50e, (q31_t)0xeea58ec6, (q31_t)0x2625df8, (q31_t)0xeeb1a796, + (q31_t)0x25ef943, (q31_t)0xeebdc110, (q31_t)0x25b96ee, (q31_t)0xeec9db35, + (q31_t)0x25836f9, (q31_t)0xeed5f604, (q31_t)0x254d965, (q31_t)0xeee2117c, + (q31_t)0x2517e31, (q31_t)0xeeee2d9d, (q31_t)0x24e255e, (q31_t)0xeefa4a67, + (q31_t)0x24aceed, (q31_t)0xef0667d9, (q31_t)0x2477adc, (q31_t)0xef1285f2, + (q31_t)0x244292c, (q31_t)0xef1ea4b2, (q31_t)0x240d9de, (q31_t)0xef2ac419, + (q31_t)0x23d8cf1, (q31_t)0xef36e426, (q31_t)0x23a4265, (q31_t)0xef4304d8, + (q31_t)0x236fa3b, (q31_t)0xef4f2630, (q31_t)0x233b473, (q31_t)0xef5b482d, + (q31_t)0x230710d, (q31_t)0xef676ace, (q31_t)0x22d3009, (q31_t)0xef738e12, + (q31_t)0x229f167, (q31_t)0xef7fb1fa, (q31_t)0x226b528, (q31_t)0xef8bd685, + (q31_t)0x2237b4b, (q31_t)0xef97fbb2, (q31_t)0x22043d0, (q31_t)0xefa42181, + (q31_t)0x21d0eb8, (q31_t)0xefb047f2, (q31_t)0x219dc03, (q31_t)0xefbc6f03, + (q31_t)0x216abb1, (q31_t)0xefc896b5, (q31_t)0x2137dc2, (q31_t)0xefd4bf08, + (q31_t)0x2105236, (q31_t)0xefe0e7f9, (q31_t)0x20d290d, (q31_t)0xefed118a, + (q31_t)0x20a0248, (q31_t)0xeff93bba, (q31_t)0x206dde6, (q31_t)0xf0056687, + (q31_t)0x203bbe8, (q31_t)0xf01191f3, (q31_t)0x2009c4e, (q31_t)0xf01dbdfb, + (q31_t)0x1fd7f17, (q31_t)0xf029eaa1, (q31_t)0x1fa6445, (q31_t)0xf03617e2, + (q31_t)0x1f74bd6, (q31_t)0xf04245c0, (q31_t)0x1f435cc, (q31_t)0xf04e7438, + (q31_t)0x1f12227, (q31_t)0xf05aa34c, (q31_t)0x1ee10e5, (q31_t)0xf066d2fa, + (q31_t)0x1eb0209, (q31_t)0xf0730342, (q31_t)0x1e7f591, (q31_t)0xf07f3424, + (q31_t)0x1e4eb7e, (q31_t)0xf08b659f, (q31_t)0x1e1e3d0, (q31_t)0xf09797b2, + (q31_t)0x1dede87, (q31_t)0xf0a3ca5d, (q31_t)0x1dbdba3, (q31_t)0xf0affda0, + (q31_t)0x1d8db25, (q31_t)0xf0bc317a, (q31_t)0x1d5dd0c, (q31_t)0xf0c865ea, + (q31_t)0x1d2e158, (q31_t)0xf0d49af1, (q31_t)0x1cfe80a, (q31_t)0xf0e0d08d, + (q31_t)0x1ccf122, (q31_t)0xf0ed06bf, (q31_t)0x1c9fca0, (q31_t)0xf0f93d86, + (q31_t)0x1c70a84, (q31_t)0xf10574e0, (q31_t)0x1c41ace, (q31_t)0xf111accf, + (q31_t)0x1c12d7e, (q31_t)0xf11de551, (q31_t)0x1be4294, (q31_t)0xf12a1e66, + (q31_t)0x1bb5a11, (q31_t)0xf136580d, (q31_t)0x1b873f5, (q31_t)0xf1429247, + (q31_t)0x1b5903f, (q31_t)0xf14ecd11, (q31_t)0x1b2aef0, (q31_t)0xf15b086d, + (q31_t)0x1afd007, (q31_t)0xf1674459, (q31_t)0x1acf386, (q31_t)0xf17380d6, + (q31_t)0x1aa196c, (q31_t)0xf17fbde2, (q31_t)0x1a741b9, (q31_t)0xf18bfb7d, + (q31_t)0x1a46c6e, (q31_t)0xf19839a6, (q31_t)0x1a1998a, (q31_t)0xf1a4785e, + (q31_t)0x19ec90d, (q31_t)0xf1b0b7a4, (q31_t)0x19bfaf9, (q31_t)0xf1bcf777, + (q31_t)0x1992f4c, (q31_t)0xf1c937d6, (q31_t)0x1966606, (q31_t)0xf1d578c2, + (q31_t)0x1939f29, (q31_t)0xf1e1ba3a, (q31_t)0x190dab4, (q31_t)0xf1edfc3d, + (q31_t)0x18e18a7, (q31_t)0xf1fa3ecb, (q31_t)0x18b5903, (q31_t)0xf20681e3, + (q31_t)0x1889bc6, (q31_t)0xf212c585, (q31_t)0x185e0f3, (q31_t)0xf21f09b1, + (q31_t)0x1832888, (q31_t)0xf22b4e66, (q31_t)0x1807285, (q31_t)0xf23793a3, + (q31_t)0x17dbeec, (q31_t)0xf243d968, (q31_t)0x17b0dbb, (q31_t)0xf2501fb5, + (q31_t)0x1785ef4, (q31_t)0xf25c6688, (q31_t)0x175b296, (q31_t)0xf268ade3, + (q31_t)0x17308a1, (q31_t)0xf274f5c3, (q31_t)0x1706115, (q31_t)0xf2813e2a, + (q31_t)0x16dbbf3, (q31_t)0xf28d8715, (q31_t)0x16b193a, (q31_t)0xf299d085, + (q31_t)0x16878eb, (q31_t)0xf2a61a7a, (q31_t)0x165db05, (q31_t)0xf2b264f2, + (q31_t)0x1633f8a, (q31_t)0xf2beafed, (q31_t)0x160a678, (q31_t)0xf2cafb6b, + (q31_t)0x15e0fd1, (q31_t)0xf2d7476c, (q31_t)0x15b7b94, (q31_t)0xf2e393ef, + (q31_t)0x158e9c1, (q31_t)0xf2efe0f2, (q31_t)0x1565a58, (q31_t)0xf2fc2e77, + (q31_t)0x153cd5a, (q31_t)0xf3087c7d, (q31_t)0x15142c6, (q31_t)0xf314cb02, + (q31_t)0x14eba9d, (q31_t)0xf3211a07, (q31_t)0x14c34df, (q31_t)0xf32d698a, + (q31_t)0x149b18b, (q31_t)0xf339b98d, (q31_t)0x14730a3, (q31_t)0xf3460a0d, + (q31_t)0x144b225, (q31_t)0xf3525b0b, (q31_t)0x1423613, (q31_t)0xf35eac86, + (q31_t)0x13fbc6c, (q31_t)0xf36afe7e, (q31_t)0x13d4530, (q31_t)0xf37750f2, + (q31_t)0x13ad060, (q31_t)0xf383a3e2, (q31_t)0x1385dfb, (q31_t)0xf38ff74d, + (q31_t)0x135ee02, (q31_t)0xf39c4b32, (q31_t)0x1338075, (q31_t)0xf3a89f92, + (q31_t)0x1311553, (q31_t)0xf3b4f46c, (q31_t)0x12eac9d, (q31_t)0xf3c149bf, + (q31_t)0x12c4653, (q31_t)0xf3cd9f8b, (q31_t)0x129e276, (q31_t)0xf3d9f5cf, + (q31_t)0x1278104, (q31_t)0xf3e64c8c, (q31_t)0x12521ff, (q31_t)0xf3f2a3bf, + (q31_t)0x122c566, (q31_t)0xf3fefb6a, (q31_t)0x1206b39, (q31_t)0xf40b538b, + (q31_t)0x11e1379, (q31_t)0xf417ac22, (q31_t)0x11bbe26, (q31_t)0xf424052f, + (q31_t)0x1196b3f, (q31_t)0xf4305eb0, (q31_t)0x1171ac6, (q31_t)0xf43cb8a7, + (q31_t)0x114ccb9, (q31_t)0xf4491311, (q31_t)0x1128119, (q31_t)0xf4556def, + (q31_t)0x11037e6, (q31_t)0xf461c940, (q31_t)0x10df120, (q31_t)0xf46e2504, + (q31_t)0x10bacc8, (q31_t)0xf47a8139, (q31_t)0x1096add, (q31_t)0xf486dde1, + (q31_t)0x1072b5f, (q31_t)0xf4933afa, (q31_t)0x104ee4f, (q31_t)0xf49f9884, + (q31_t)0x102b3ac, (q31_t)0xf4abf67e, (q31_t)0x1007b77, (q31_t)0xf4b854e7, + (q31_t)0xfe45b0, (q31_t)0xf4c4b3c0, (q31_t)0xfc1257, (q31_t)0xf4d11308, + (q31_t)0xf9e16b, (q31_t)0xf4dd72be, (q31_t)0xf7b2ee, (q31_t)0xf4e9d2e3, + (q31_t)0xf586df, (q31_t)0xf4f63374, (q31_t)0xf35d3e, (q31_t)0xf5029473, + (q31_t)0xf1360b, (q31_t)0xf50ef5de, (q31_t)0xef1147, (q31_t)0xf51b57b5, + (q31_t)0xeceef1, (q31_t)0xf527b9f7, (q31_t)0xeacf09, (q31_t)0xf5341ca5, + (q31_t)0xe8b190, (q31_t)0xf5407fbd, (q31_t)0xe69686, (q31_t)0xf54ce33f, + (q31_t)0xe47deb, (q31_t)0xf559472b, (q31_t)0xe267be, (q31_t)0xf565ab80, + (q31_t)0xe05401, (q31_t)0xf572103d, (q31_t)0xde42b2, (q31_t)0xf57e7563, + (q31_t)0xdc33d2, (q31_t)0xf58adaf0, (q31_t)0xda2762, (q31_t)0xf59740e5, + (q31_t)0xd81d61, (q31_t)0xf5a3a740, (q31_t)0xd615cf, (q31_t)0xf5b00e02, + (q31_t)0xd410ad, (q31_t)0xf5bc7529, (q31_t)0xd20dfa, (q31_t)0xf5c8dcb6, + (q31_t)0xd00db6, (q31_t)0xf5d544a7, (q31_t)0xce0fe3, (q31_t)0xf5e1acfd, + (q31_t)0xcc147f, (q31_t)0xf5ee15b7, (q31_t)0xca1b8a, (q31_t)0xf5fa7ed4, + (q31_t)0xc82506, (q31_t)0xf606e854, (q31_t)0xc630f2, (q31_t)0xf6135237, + (q31_t)0xc43f4d, (q31_t)0xf61fbc7b, (q31_t)0xc25019, (q31_t)0xf62c2721, + (q31_t)0xc06355, (q31_t)0xf6389228, (q31_t)0xbe7901, (q31_t)0xf644fd8f, + (q31_t)0xbc911d, (q31_t)0xf6516956, (q31_t)0xbaabaa, (q31_t)0xf65dd57d, + (q31_t)0xb8c8a7, (q31_t)0xf66a4203, (q31_t)0xb6e815, (q31_t)0xf676aee8, + (q31_t)0xb509f3, (q31_t)0xf6831c2b, (q31_t)0xb32e42, (q31_t)0xf68f89cb, + (q31_t)0xb15502, (q31_t)0xf69bf7c9, (q31_t)0xaf7e33, (q31_t)0xf6a86623, + (q31_t)0xada9d4, (q31_t)0xf6b4d4d9, (q31_t)0xabd7e6, (q31_t)0xf6c143ec, + (q31_t)0xaa086a, (q31_t)0xf6cdb359, (q31_t)0xa83b5e, (q31_t)0xf6da2321, + (q31_t)0xa670c4, (q31_t)0xf6e69344, (q31_t)0xa4a89b, (q31_t)0xf6f303c0, + (q31_t)0xa2e2e3, (q31_t)0xf6ff7496, (q31_t)0xa11f9d, (q31_t)0xf70be5c4, + (q31_t)0x9f5ec8, (q31_t)0xf718574b, (q31_t)0x9da065, (q31_t)0xf724c92a, + (q31_t)0x9be473, (q31_t)0xf7313b60, (q31_t)0x9a2af3, (q31_t)0xf73daded, + (q31_t)0x9873e4, (q31_t)0xf74a20d0, (q31_t)0x96bf48, (q31_t)0xf756940a, + (q31_t)0x950d1d, (q31_t)0xf7630799, (q31_t)0x935d64, (q31_t)0xf76f7b7d, + (q31_t)0x91b01d, (q31_t)0xf77befb5, (q31_t)0x900548, (q31_t)0xf7886442, + (q31_t)0x8e5ce5, (q31_t)0xf794d922, (q31_t)0x8cb6f5, (q31_t)0xf7a14e55, + (q31_t)0x8b1376, (q31_t)0xf7adc3db, (q31_t)0x89726a, (q31_t)0xf7ba39b3, + (q31_t)0x87d3d0, (q31_t)0xf7c6afdc, (q31_t)0x8637a9, (q31_t)0xf7d32657, + (q31_t)0x849df4, (q31_t)0xf7df9d22, (q31_t)0x8306b2, (q31_t)0xf7ec143e, + (q31_t)0x8171e2, (q31_t)0xf7f88ba9, (q31_t)0x7fdf85, (q31_t)0xf8050364, + (q31_t)0x7e4f9b, (q31_t)0xf8117b6d, (q31_t)0x7cc223, (q31_t)0xf81df3c5, + (q31_t)0x7b371e, (q31_t)0xf82a6c6a, (q31_t)0x79ae8c, (q31_t)0xf836e55d, + (q31_t)0x78286e, (q31_t)0xf8435e9d, (q31_t)0x76a4c2, (q31_t)0xf84fd829, + (q31_t)0x752389, (q31_t)0xf85c5201, (q31_t)0x73a4c3, (q31_t)0xf868cc24, + (q31_t)0x722871, (q31_t)0xf8754692, (q31_t)0x70ae92, (q31_t)0xf881c14b, + (q31_t)0x6f3726, (q31_t)0xf88e3c4d, (q31_t)0x6dc22e, (q31_t)0xf89ab799, + (q31_t)0x6c4fa8, (q31_t)0xf8a7332e, (q31_t)0x6adf97, (q31_t)0xf8b3af0c, + (q31_t)0x6971f9, (q31_t)0xf8c02b31, (q31_t)0x6806ce, (q31_t)0xf8cca79e, + (q31_t)0x669e18, (q31_t)0xf8d92452, (q31_t)0x6537d4, (q31_t)0xf8e5a14d, + (q31_t)0x63d405, (q31_t)0xf8f21e8e, (q31_t)0x6272aa, (q31_t)0xf8fe9c15, + (q31_t)0x6113c2, (q31_t)0xf90b19e0, (q31_t)0x5fb74e, (q31_t)0xf91797f0, + (q31_t)0x5e5d4e, (q31_t)0xf9241645, (q31_t)0x5d05c3, (q31_t)0xf93094dd, + (q31_t)0x5bb0ab, (q31_t)0xf93d13b8, (q31_t)0x5a5e07, (q31_t)0xf94992d7, + (q31_t)0x590dd8, (q31_t)0xf9561237, (q31_t)0x57c01d, (q31_t)0xf96291d9, + (q31_t)0x5674d6, (q31_t)0xf96f11bc, (q31_t)0x552c03, (q31_t)0xf97b91e1, + (q31_t)0x53e5a5, (q31_t)0xf9881245, (q31_t)0x52a1bb, (q31_t)0xf99492ea, + (q31_t)0x516045, (q31_t)0xf9a113cd, (q31_t)0x502145, (q31_t)0xf9ad94f0, + (q31_t)0x4ee4b8, (q31_t)0xf9ba1651, (q31_t)0x4daaa1, (q31_t)0xf9c697f0, + (q31_t)0x4c72fe, (q31_t)0xf9d319cc, (q31_t)0x4b3dcf, (q31_t)0xf9df9be6, + (q31_t)0x4a0b16, (q31_t)0xf9ec1e3b, (q31_t)0x48dad1, (q31_t)0xf9f8a0cd, + (q31_t)0x47ad01, (q31_t)0xfa05239a, (q31_t)0x4681a6, (q31_t)0xfa11a6a3, + (q31_t)0x4558c0, (q31_t)0xfa1e29e5, (q31_t)0x44324f, (q31_t)0xfa2aad62, + (q31_t)0x430e53, (q31_t)0xfa373119, (q31_t)0x41eccc, (q31_t)0xfa43b508, + (q31_t)0x40cdba, (q31_t)0xfa503930, (q31_t)0x3fb11d, (q31_t)0xfa5cbd91, + (q31_t)0x3e96f6, (q31_t)0xfa694229, (q31_t)0x3d7f44, (q31_t)0xfa75c6f8, + (q31_t)0x3c6a07, (q31_t)0xfa824bfd, (q31_t)0x3b573f, (q31_t)0xfa8ed139, + (q31_t)0x3a46ed, (q31_t)0xfa9b56ab, (q31_t)0x393910, (q31_t)0xfaa7dc52, + (q31_t)0x382da8, (q31_t)0xfab4622d, (q31_t)0x3724b6, (q31_t)0xfac0e83d, + (q31_t)0x361e3a, (q31_t)0xfacd6e81, (q31_t)0x351a33, (q31_t)0xfad9f4f8, + (q31_t)0x3418a2, (q31_t)0xfae67ba2, (q31_t)0x331986, (q31_t)0xfaf3027e, + (q31_t)0x321ce0, (q31_t)0xfaff898c, (q31_t)0x3122b0, (q31_t)0xfb0c10cb, + (q31_t)0x302af5, (q31_t)0xfb18983b, (q31_t)0x2f35b1, (q31_t)0xfb251fdc, + (q31_t)0x2e42e2, (q31_t)0xfb31a7ac, (q31_t)0x2d5289, (q31_t)0xfb3e2fac, + (q31_t)0x2c64a6, (q31_t)0xfb4ab7db, (q31_t)0x2b7939, (q31_t)0xfb574039, + (q31_t)0x2a9042, (q31_t)0xfb63c8c4, (q31_t)0x29a9c1, (q31_t)0xfb70517d, + (q31_t)0x28c5b6, (q31_t)0xfb7cda63, (q31_t)0x27e421, (q31_t)0xfb896375, + (q31_t)0x270502, (q31_t)0xfb95ecb4, (q31_t)0x262859, (q31_t)0xfba2761e, + (q31_t)0x254e27, (q31_t)0xfbaeffb3, (q31_t)0x24766a, (q31_t)0xfbbb8973, + (q31_t)0x23a124, (q31_t)0xfbc8135c, (q31_t)0x22ce54, (q31_t)0xfbd49d70, + (q31_t)0x21fdfb, (q31_t)0xfbe127ac, (q31_t)0x213018, (q31_t)0xfbedb212, + (q31_t)0x2064ab, (q31_t)0xfbfa3c9f, (q31_t)0x1f9bb5, (q31_t)0xfc06c754, + (q31_t)0x1ed535, (q31_t)0xfc135231, (q31_t)0x1e112b, (q31_t)0xfc1fdd34, + (q31_t)0x1d4f99, (q31_t)0xfc2c685d, (q31_t)0x1c907c, (q31_t)0xfc38f3ac, + (q31_t)0x1bd3d6, (q31_t)0xfc457f21, (q31_t)0x1b19a7, (q31_t)0xfc520aba, + (q31_t)0x1a61ee, (q31_t)0xfc5e9678, (q31_t)0x19acac, (q31_t)0xfc6b2259, + (q31_t)0x18f9e1, (q31_t)0xfc77ae5e, (q31_t)0x18498c, (q31_t)0xfc843a85, + (q31_t)0x179bae, (q31_t)0xfc90c6cf, (q31_t)0x16f047, (q31_t)0xfc9d533b, + (q31_t)0x164757, (q31_t)0xfca9dfc8, (q31_t)0x15a0dd, (q31_t)0xfcb66c77, + (q31_t)0x14fcda, (q31_t)0xfcc2f945, (q31_t)0x145b4e, (q31_t)0xfccf8634, + (q31_t)0x13bc39, (q31_t)0xfcdc1342, (q31_t)0x131f9b, (q31_t)0xfce8a06f, + (q31_t)0x128574, (q31_t)0xfcf52dbb, (q31_t)0x11edc3, (q31_t)0xfd01bb24, + (q31_t)0x11588a, (q31_t)0xfd0e48ab, (q31_t)0x10c5c7, (q31_t)0xfd1ad650, + (q31_t)0x10357c, (q31_t)0xfd276410, (q31_t)0xfa7a8, (q31_t)0xfd33f1ed, + (q31_t)0xf1c4a, (q31_t)0xfd407fe6, (q31_t)0xe9364, (q31_t)0xfd4d0df9, + (q31_t)0xe0cf5, (q31_t)0xfd599c28, (q31_t)0xd88fd, (q31_t)0xfd662a70, + (q31_t)0xd077c, (q31_t)0xfd72b8d2, (q31_t)0xc8872, (q31_t)0xfd7f474d, + (q31_t)0xc0be0, (q31_t)0xfd8bd5e1, (q31_t)0xb91c4, (q31_t)0xfd98648d, + (q31_t)0xb1a20, (q31_t)0xfda4f351, (q31_t)0xaa4f3, (q31_t)0xfdb1822c, + (q31_t)0xa323d, (q31_t)0xfdbe111e, (q31_t)0x9c1ff, (q31_t)0xfdcaa027, + (q31_t)0x95438, (q31_t)0xfdd72f45, (q31_t)0x8e8e8, (q31_t)0xfde3be78, + (q31_t)0x8800f, (q31_t)0xfdf04dc0, (q31_t)0x819ae, (q31_t)0xfdfcdd1d, + (q31_t)0x7b5c4, (q31_t)0xfe096c8d, (q31_t)0x75452, (q31_t)0xfe15fc11, + (q31_t)0x6f556, (q31_t)0xfe228ba7, (q31_t)0x698d3, (q31_t)0xfe2f1b50, + (q31_t)0x63ec6, (q31_t)0xfe3bab0b, (q31_t)0x5e731, (q31_t)0xfe483ad8, + (q31_t)0x59214, (q31_t)0xfe54cab5, (q31_t)0x53f6e, (q31_t)0xfe615aa3, + (q31_t)0x4ef3f, (q31_t)0xfe6deaa1, (q31_t)0x4a188, (q31_t)0xfe7a7aae, + (q31_t)0x45648, (q31_t)0xfe870aca, (q31_t)0x40d80, (q31_t)0xfe939af5, + (q31_t)0x3c72f, (q31_t)0xfea02b2e, (q31_t)0x38356, (q31_t)0xfeacbb74, + (q31_t)0x341f4, (q31_t)0xfeb94bc8, (q31_t)0x3030a, (q31_t)0xfec5dc28, + (q31_t)0x2c697, (q31_t)0xfed26c94, (q31_t)0x28c9c, (q31_t)0xfedefd0c, + (q31_t)0x25519, (q31_t)0xfeeb8d8f, (q31_t)0x2200d, (q31_t)0xfef81e1d, + (q31_t)0x1ed78, (q31_t)0xff04aeb5, (q31_t)0x1bd5c, (q31_t)0xff113f56, + (q31_t)0x18fb6, (q31_t)0xff1dd001, (q31_t)0x16489, (q31_t)0xff2a60b4, + (q31_t)0x13bd3, (q31_t)0xff36f170, (q31_t)0x11594, (q31_t)0xff438234, + (q31_t)0xf1ce, (q31_t)0xff5012fe, (q31_t)0xd07e, (q31_t)0xff5ca3d0, + (q31_t)0xb1a7, (q31_t)0xff6934a8, (q31_t)0x9547, (q31_t)0xff75c585, + (q31_t)0x7b5f, (q31_t)0xff825668, (q31_t)0x63ee, (q31_t)0xff8ee750, + (q31_t)0x4ef5, (q31_t)0xff9b783c, (q31_t)0x3c74, (q31_t)0xffa8092c, + (q31_t)0x2c6a, (q31_t)0xffb49a1f, (q31_t)0x1ed8, (q31_t)0xffc12b16, + (q31_t)0x13bd, (q31_t)0xffcdbc0f, (q31_t)0xb1a, (q31_t)0xffda4d09, + (q31_t)0x4ef, (q31_t)0xffe6de05, (q31_t)0x13c, (q31_t)0xfff36f02, + (q31_t)0x0, (q31_t)0x0, (q31_t)0x13c, (q31_t)0xc90fe, + (q31_t)0x4ef, (q31_t)0x1921fb, (q31_t)0xb1a, (q31_t)0x25b2f7, + (q31_t)0x13bd, (q31_t)0x3243f1, (q31_t)0x1ed8, (q31_t)0x3ed4ea, + (q31_t)0x2c6a, (q31_t)0x4b65e1, (q31_t)0x3c74, (q31_t)0x57f6d4, + (q31_t)0x4ef5, (q31_t)0x6487c4, (q31_t)0x63ee, (q31_t)0x7118b0, + (q31_t)0x7b5f, (q31_t)0x7da998, (q31_t)0x9547, (q31_t)0x8a3a7b, + (q31_t)0xb1a7, (q31_t)0x96cb58, (q31_t)0xd07e, (q31_t)0xa35c30, + (q31_t)0xf1ce, (q31_t)0xafed02, (q31_t)0x11594, (q31_t)0xbc7dcc, + (q31_t)0x13bd3, (q31_t)0xc90e90, (q31_t)0x16489, (q31_t)0xd59f4c, + (q31_t)0x18fb6, (q31_t)0xe22fff, (q31_t)0x1bd5c, (q31_t)0xeec0aa, + (q31_t)0x1ed78, (q31_t)0xfb514b, (q31_t)0x2200d, (q31_t)0x107e1e3, + (q31_t)0x25519, (q31_t)0x1147271, (q31_t)0x28c9c, (q31_t)0x12102f4, + (q31_t)0x2c697, (q31_t)0x12d936c, (q31_t)0x3030a, (q31_t)0x13a23d8, + (q31_t)0x341f4, (q31_t)0x146b438, (q31_t)0x38356, (q31_t)0x153448c, + (q31_t)0x3c72f, (q31_t)0x15fd4d2, (q31_t)0x40d80, (q31_t)0x16c650b, + (q31_t)0x45648, (q31_t)0x178f536, (q31_t)0x4a188, (q31_t)0x1858552, + (q31_t)0x4ef3f, (q31_t)0x192155f, (q31_t)0x53f6e, (q31_t)0x19ea55d, + (q31_t)0x59214, (q31_t)0x1ab354b, (q31_t)0x5e731, (q31_t)0x1b7c528, + (q31_t)0x63ec6, (q31_t)0x1c454f5, (q31_t)0x698d3, (q31_t)0x1d0e4b0, + (q31_t)0x6f556, (q31_t)0x1dd7459, (q31_t)0x75452, (q31_t)0x1ea03ef, + (q31_t)0x7b5c4, (q31_t)0x1f69373, (q31_t)0x819ae, (q31_t)0x20322e3, + (q31_t)0x8800f, (q31_t)0x20fb240, (q31_t)0x8e8e8, (q31_t)0x21c4188, + (q31_t)0x95438, (q31_t)0x228d0bb, (q31_t)0x9c1ff, (q31_t)0x2355fd9, + (q31_t)0xa323d, (q31_t)0x241eee2, (q31_t)0xaa4f3, (q31_t)0x24e7dd4, + (q31_t)0xb1a20, (q31_t)0x25b0caf, (q31_t)0xb91c4, (q31_t)0x2679b73, + (q31_t)0xc0be0, (q31_t)0x2742a1f, (q31_t)0xc8872, (q31_t)0x280b8b3, + (q31_t)0xd077c, (q31_t)0x28d472e, (q31_t)0xd88fd, (q31_t)0x299d590, + (q31_t)0xe0cf5, (q31_t)0x2a663d8, (q31_t)0xe9364, (q31_t)0x2b2f207, + (q31_t)0xf1c4a, (q31_t)0x2bf801a, (q31_t)0xfa7a8, (q31_t)0x2cc0e13, + (q31_t)0x10357c, (q31_t)0x2d89bf0, (q31_t)0x10c5c7, (q31_t)0x2e529b0, + (q31_t)0x11588a, (q31_t)0x2f1b755, (q31_t)0x11edc3, (q31_t)0x2fe44dc, + (q31_t)0x128574, (q31_t)0x30ad245, (q31_t)0x131f9b, (q31_t)0x3175f91, + (q31_t)0x13bc39, (q31_t)0x323ecbe, (q31_t)0x145b4e, (q31_t)0x33079cc, + (q31_t)0x14fcda, (q31_t)0x33d06bb, (q31_t)0x15a0dd, (q31_t)0x3499389, + (q31_t)0x164757, (q31_t)0x3562038, (q31_t)0x16f047, (q31_t)0x362acc5, + (q31_t)0x179bae, (q31_t)0x36f3931, (q31_t)0x18498c, (q31_t)0x37bc57b, + (q31_t)0x18f9e1, (q31_t)0x38851a2, (q31_t)0x19acac, (q31_t)0x394dda7, + (q31_t)0x1a61ee, (q31_t)0x3a16988, (q31_t)0x1b19a7, (q31_t)0x3adf546, + (q31_t)0x1bd3d6, (q31_t)0x3ba80df, (q31_t)0x1c907c, (q31_t)0x3c70c54, + (q31_t)0x1d4f99, (q31_t)0x3d397a3, (q31_t)0x1e112b, (q31_t)0x3e022cc, + (q31_t)0x1ed535, (q31_t)0x3ecadcf, (q31_t)0x1f9bb5, (q31_t)0x3f938ac, + (q31_t)0x2064ab, (q31_t)0x405c361, (q31_t)0x213018, (q31_t)0x4124dee, + (q31_t)0x21fdfb, (q31_t)0x41ed854, (q31_t)0x22ce54, (q31_t)0x42b6290, + (q31_t)0x23a124, (q31_t)0x437eca4, (q31_t)0x24766a, (q31_t)0x444768d, + (q31_t)0x254e27, (q31_t)0x451004d, (q31_t)0x262859, (q31_t)0x45d89e2, + (q31_t)0x270502, (q31_t)0x46a134c, (q31_t)0x27e421, (q31_t)0x4769c8b, + (q31_t)0x28c5b6, (q31_t)0x483259d, (q31_t)0x29a9c1, (q31_t)0x48fae83, + (q31_t)0x2a9042, (q31_t)0x49c373c, (q31_t)0x2b7939, (q31_t)0x4a8bfc7, + (q31_t)0x2c64a6, (q31_t)0x4b54825, (q31_t)0x2d5289, (q31_t)0x4c1d054, + (q31_t)0x2e42e2, (q31_t)0x4ce5854, (q31_t)0x2f35b1, (q31_t)0x4dae024, + (q31_t)0x302af5, (q31_t)0x4e767c5, (q31_t)0x3122b0, (q31_t)0x4f3ef35, + (q31_t)0x321ce0, (q31_t)0x5007674, (q31_t)0x331986, (q31_t)0x50cfd82, + (q31_t)0x3418a2, (q31_t)0x519845e, (q31_t)0x351a33, (q31_t)0x5260b08, + (q31_t)0x361e3a, (q31_t)0x532917f, (q31_t)0x3724b6, (q31_t)0x53f17c3, + (q31_t)0x382da8, (q31_t)0x54b9dd3, (q31_t)0x393910, (q31_t)0x55823ae, + (q31_t)0x3a46ed, (q31_t)0x564a955, (q31_t)0x3b573f, (q31_t)0x5712ec7, + (q31_t)0x3c6a07, (q31_t)0x57db403, (q31_t)0x3d7f44, (q31_t)0x58a3908, + (q31_t)0x3e96f6, (q31_t)0x596bdd7, (q31_t)0x3fb11d, (q31_t)0x5a3426f, + (q31_t)0x40cdba, (q31_t)0x5afc6d0, (q31_t)0x41eccc, (q31_t)0x5bc4af8, + (q31_t)0x430e53, (q31_t)0x5c8cee7, (q31_t)0x44324f, (q31_t)0x5d5529e, + (q31_t)0x4558c0, (q31_t)0x5e1d61b, (q31_t)0x4681a6, (q31_t)0x5ee595d, + (q31_t)0x47ad01, (q31_t)0x5fadc66, (q31_t)0x48dad1, (q31_t)0x6075f33, + (q31_t)0x4a0b16, (q31_t)0x613e1c5, (q31_t)0x4b3dcf, (q31_t)0x620641a, + (q31_t)0x4c72fe, (q31_t)0x62ce634, (q31_t)0x4daaa1, (q31_t)0x6396810, + (q31_t)0x4ee4b8, (q31_t)0x645e9af, (q31_t)0x502145, (q31_t)0x6526b10, + (q31_t)0x516045, (q31_t)0x65eec33, (q31_t)0x52a1bb, (q31_t)0x66b6d16, + (q31_t)0x53e5a5, (q31_t)0x677edbb, (q31_t)0x552c03, (q31_t)0x6846e1f, + (q31_t)0x5674d6, (q31_t)0x690ee44, (q31_t)0x57c01d, (q31_t)0x69d6e27, + (q31_t)0x590dd8, (q31_t)0x6a9edc9, (q31_t)0x5a5e07, (q31_t)0x6b66d29, + (q31_t)0x5bb0ab, (q31_t)0x6c2ec48, (q31_t)0x5d05c3, (q31_t)0x6cf6b23, + (q31_t)0x5e5d4e, (q31_t)0x6dbe9bb, (q31_t)0x5fb74e, (q31_t)0x6e86810, + (q31_t)0x6113c2, (q31_t)0x6f4e620, (q31_t)0x6272aa, (q31_t)0x70163eb, + (q31_t)0x63d405, (q31_t)0x70de172, (q31_t)0x6537d4, (q31_t)0x71a5eb3, + (q31_t)0x669e18, (q31_t)0x726dbae, (q31_t)0x6806ce, (q31_t)0x7335862, + (q31_t)0x6971f9, (q31_t)0x73fd4cf, (q31_t)0x6adf97, (q31_t)0x74c50f4, + (q31_t)0x6c4fa8, (q31_t)0x758ccd2, (q31_t)0x6dc22e, (q31_t)0x7654867, + (q31_t)0x6f3726, (q31_t)0x771c3b3, (q31_t)0x70ae92, (q31_t)0x77e3eb5, + (q31_t)0x722871, (q31_t)0x78ab96e, (q31_t)0x73a4c3, (q31_t)0x79733dc, + (q31_t)0x752389, (q31_t)0x7a3adff, (q31_t)0x76a4c2, (q31_t)0x7b027d7, + (q31_t)0x78286e, (q31_t)0x7bca163, (q31_t)0x79ae8c, (q31_t)0x7c91aa3, + (q31_t)0x7b371e, (q31_t)0x7d59396, (q31_t)0x7cc223, (q31_t)0x7e20c3b, + (q31_t)0x7e4f9b, (q31_t)0x7ee8493, (q31_t)0x7fdf85, (q31_t)0x7fafc9c, + (q31_t)0x8171e2, (q31_t)0x8077457, (q31_t)0x8306b2, (q31_t)0x813ebc2, + (q31_t)0x849df4, (q31_t)0x82062de, (q31_t)0x8637a9, (q31_t)0x82cd9a9, + (q31_t)0x87d3d0, (q31_t)0x8395024, (q31_t)0x89726a, (q31_t)0x845c64d, + (q31_t)0x8b1376, (q31_t)0x8523c25, (q31_t)0x8cb6f5, (q31_t)0x85eb1ab, + (q31_t)0x8e5ce5, (q31_t)0x86b26de, (q31_t)0x900548, (q31_t)0x8779bbe, + (q31_t)0x91b01d, (q31_t)0x884104b, (q31_t)0x935d64, (q31_t)0x8908483, + (q31_t)0x950d1d, (q31_t)0x89cf867, (q31_t)0x96bf48, (q31_t)0x8a96bf6, + (q31_t)0x9873e4, (q31_t)0x8b5df30, (q31_t)0x9a2af3, (q31_t)0x8c25213, + (q31_t)0x9be473, (q31_t)0x8cec4a0, (q31_t)0x9da065, (q31_t)0x8db36d6, + (q31_t)0x9f5ec8, (q31_t)0x8e7a8b5, (q31_t)0xa11f9d, (q31_t)0x8f41a3c, + (q31_t)0xa2e2e3, (q31_t)0x9008b6a, (q31_t)0xa4a89b, (q31_t)0x90cfc40, + (q31_t)0xa670c4, (q31_t)0x9196cbc, (q31_t)0xa83b5e, (q31_t)0x925dcdf, + (q31_t)0xaa086a, (q31_t)0x9324ca7, (q31_t)0xabd7e6, (q31_t)0x93ebc14, + (q31_t)0xada9d4, (q31_t)0x94b2b27, (q31_t)0xaf7e33, (q31_t)0x95799dd, + (q31_t)0xb15502, (q31_t)0x9640837, (q31_t)0xb32e42, (q31_t)0x9707635, + (q31_t)0xb509f3, (q31_t)0x97ce3d5, (q31_t)0xb6e815, (q31_t)0x9895118, + (q31_t)0xb8c8a7, (q31_t)0x995bdfd, (q31_t)0xbaabaa, (q31_t)0x9a22a83, + (q31_t)0xbc911d, (q31_t)0x9ae96aa, (q31_t)0xbe7901, (q31_t)0x9bb0271, + (q31_t)0xc06355, (q31_t)0x9c76dd8, (q31_t)0xc25019, (q31_t)0x9d3d8df, + (q31_t)0xc43f4d, (q31_t)0x9e04385, (q31_t)0xc630f2, (q31_t)0x9ecadc9, + (q31_t)0xc82506, (q31_t)0x9f917ac, (q31_t)0xca1b8a, (q31_t)0xa05812c, + (q31_t)0xcc147f, (q31_t)0xa11ea49, (q31_t)0xce0fe3, (q31_t)0xa1e5303, + (q31_t)0xd00db6, (q31_t)0xa2abb59, (q31_t)0xd20dfa, (q31_t)0xa37234a, + (q31_t)0xd410ad, (q31_t)0xa438ad7, (q31_t)0xd615cf, (q31_t)0xa4ff1fe, + (q31_t)0xd81d61, (q31_t)0xa5c58c0, (q31_t)0xda2762, (q31_t)0xa68bf1b, + (q31_t)0xdc33d2, (q31_t)0xa752510, (q31_t)0xde42b2, (q31_t)0xa818a9d, + (q31_t)0xe05401, (q31_t)0xa8defc3, (q31_t)0xe267be, (q31_t)0xa9a5480, + (q31_t)0xe47deb, (q31_t)0xaa6b8d5, (q31_t)0xe69686, (q31_t)0xab31cc1, + (q31_t)0xe8b190, (q31_t)0xabf8043, (q31_t)0xeacf09, (q31_t)0xacbe35b, + (q31_t)0xeceef1, (q31_t)0xad84609, (q31_t)0xef1147, (q31_t)0xae4a84b, + (q31_t)0xf1360b, (q31_t)0xaf10a22, (q31_t)0xf35d3e, (q31_t)0xafd6b8d, + (q31_t)0xf586df, (q31_t)0xb09cc8c, (q31_t)0xf7b2ee, (q31_t)0xb162d1d, + (q31_t)0xf9e16b, (q31_t)0xb228d42, (q31_t)0xfc1257, (q31_t)0xb2eecf8, + (q31_t)0xfe45b0, (q31_t)0xb3b4c40, (q31_t)0x1007b77, (q31_t)0xb47ab19, + (q31_t)0x102b3ac, (q31_t)0xb540982, (q31_t)0x104ee4f, (q31_t)0xb60677c, + (q31_t)0x1072b5f, (q31_t)0xb6cc506, (q31_t)0x1096add, (q31_t)0xb79221f, + (q31_t)0x10bacc8, (q31_t)0xb857ec7, (q31_t)0x10df120, (q31_t)0xb91dafc, + (q31_t)0x11037e6, (q31_t)0xb9e36c0, (q31_t)0x1128119, (q31_t)0xbaa9211, + (q31_t)0x114ccb9, (q31_t)0xbb6ecef, (q31_t)0x1171ac6, (q31_t)0xbc34759, + (q31_t)0x1196b3f, (q31_t)0xbcfa150, (q31_t)0x11bbe26, (q31_t)0xbdbfad1, + (q31_t)0x11e1379, (q31_t)0xbe853de, (q31_t)0x1206b39, (q31_t)0xbf4ac75, + (q31_t)0x122c566, (q31_t)0xc010496, (q31_t)0x12521ff, (q31_t)0xc0d5c41, + (q31_t)0x1278104, (q31_t)0xc19b374, (q31_t)0x129e276, (q31_t)0xc260a31, + (q31_t)0x12c4653, (q31_t)0xc326075, (q31_t)0x12eac9d, (q31_t)0xc3eb641, + (q31_t)0x1311553, (q31_t)0xc4b0b94, (q31_t)0x1338075, (q31_t)0xc57606e, + (q31_t)0x135ee02, (q31_t)0xc63b4ce, (q31_t)0x1385dfb, (q31_t)0xc7008b3, + (q31_t)0x13ad060, (q31_t)0xc7c5c1e, (q31_t)0x13d4530, (q31_t)0xc88af0e, + (q31_t)0x13fbc6c, (q31_t)0xc950182, (q31_t)0x1423613, (q31_t)0xca1537a, + (q31_t)0x144b225, (q31_t)0xcada4f5, (q31_t)0x14730a3, (q31_t)0xcb9f5f3, + (q31_t)0x149b18b, (q31_t)0xcc64673, (q31_t)0x14c34df, (q31_t)0xcd29676, + (q31_t)0x14eba9d, (q31_t)0xcdee5f9, (q31_t)0x15142c6, (q31_t)0xceb34fe, + (q31_t)0x153cd5a, (q31_t)0xcf78383, (q31_t)0x1565a58, (q31_t)0xd03d189, + (q31_t)0x158e9c1, (q31_t)0xd101f0e, (q31_t)0x15b7b94, (q31_t)0xd1c6c11, + (q31_t)0x15e0fd1, (q31_t)0xd28b894, (q31_t)0x160a678, (q31_t)0xd350495, + (q31_t)0x1633f8a, (q31_t)0xd415013, (q31_t)0x165db05, (q31_t)0xd4d9b0e, + (q31_t)0x16878eb, (q31_t)0xd59e586, (q31_t)0x16b193a, (q31_t)0xd662f7b, + (q31_t)0x16dbbf3, (q31_t)0xd7278eb, (q31_t)0x1706115, (q31_t)0xd7ec1d6, + (q31_t)0x17308a1, (q31_t)0xd8b0a3d, (q31_t)0x175b296, (q31_t)0xd97521d, + (q31_t)0x1785ef4, (q31_t)0xda39978, (q31_t)0x17b0dbb, (q31_t)0xdafe04b, + (q31_t)0x17dbeec, (q31_t)0xdbc2698, (q31_t)0x1807285, (q31_t)0xdc86c5d, + (q31_t)0x1832888, (q31_t)0xdd4b19a, (q31_t)0x185e0f3, (q31_t)0xde0f64f, + (q31_t)0x1889bc6, (q31_t)0xded3a7b, (q31_t)0x18b5903, (q31_t)0xdf97e1d, + (q31_t)0x18e18a7, (q31_t)0xe05c135, (q31_t)0x190dab4, (q31_t)0xe1203c3, + (q31_t)0x1939f29, (q31_t)0xe1e45c6, (q31_t)0x1966606, (q31_t)0xe2a873e, + (q31_t)0x1992f4c, (q31_t)0xe36c82a, (q31_t)0x19bfaf9, (q31_t)0xe430889, + (q31_t)0x19ec90d, (q31_t)0xe4f485c, (q31_t)0x1a1998a, (q31_t)0xe5b87a2, + (q31_t)0x1a46c6e, (q31_t)0xe67c65a, (q31_t)0x1a741b9, (q31_t)0xe740483, + (q31_t)0x1aa196c, (q31_t)0xe80421e, (q31_t)0x1acf386, (q31_t)0xe8c7f2a, + (q31_t)0x1afd007, (q31_t)0xe98bba7, (q31_t)0x1b2aef0, (q31_t)0xea4f793, + (q31_t)0x1b5903f, (q31_t)0xeb132ef, (q31_t)0x1b873f5, (q31_t)0xebd6db9, + (q31_t)0x1bb5a11, (q31_t)0xec9a7f3, (q31_t)0x1be4294, (q31_t)0xed5e19a, + (q31_t)0x1c12d7e, (q31_t)0xee21aaf, (q31_t)0x1c41ace, (q31_t)0xeee5331, + (q31_t)0x1c70a84, (q31_t)0xefa8b20, (q31_t)0x1c9fca0, (q31_t)0xf06c27a, + (q31_t)0x1ccf122, (q31_t)0xf12f941, (q31_t)0x1cfe80a, (q31_t)0xf1f2f73, + (q31_t)0x1d2e158, (q31_t)0xf2b650f, (q31_t)0x1d5dd0c, (q31_t)0xf379a16, + (q31_t)0x1d8db25, (q31_t)0xf43ce86, (q31_t)0x1dbdba3, (q31_t)0xf500260, + (q31_t)0x1dede87, (q31_t)0xf5c35a3, (q31_t)0x1e1e3d0, (q31_t)0xf68684e, + (q31_t)0x1e4eb7e, (q31_t)0xf749a61, (q31_t)0x1e7f591, (q31_t)0xf80cbdc, + (q31_t)0x1eb0209, (q31_t)0xf8cfcbe, (q31_t)0x1ee10e5, (q31_t)0xf992d06, + (q31_t)0x1f12227, (q31_t)0xfa55cb4, (q31_t)0x1f435cc, (q31_t)0xfb18bc8, + (q31_t)0x1f74bd6, (q31_t)0xfbdba40, (q31_t)0x1fa6445, (q31_t)0xfc9e81e, + (q31_t)0x1fd7f17, (q31_t)0xfd6155f, (q31_t)0x2009c4e, (q31_t)0xfe24205, + (q31_t)0x203bbe8, (q31_t)0xfee6e0d, (q31_t)0x206dde6, (q31_t)0xffa9979, + (q31_t)0x20a0248, (q31_t)0x1006c446, (q31_t)0x20d290d, (q31_t)0x1012ee76, + (q31_t)0x2105236, (q31_t)0x101f1807, (q31_t)0x2137dc2, (q31_t)0x102b40f8, + (q31_t)0x216abb1, (q31_t)0x1037694b, (q31_t)0x219dc03, (q31_t)0x104390fd, + (q31_t)0x21d0eb8, (q31_t)0x104fb80e, (q31_t)0x22043d0, (q31_t)0x105bde7f, + (q31_t)0x2237b4b, (q31_t)0x1068044e, (q31_t)0x226b528, (q31_t)0x1074297b, + (q31_t)0x229f167, (q31_t)0x10804e06, (q31_t)0x22d3009, (q31_t)0x108c71ee, + (q31_t)0x230710d, (q31_t)0x10989532, (q31_t)0x233b473, (q31_t)0x10a4b7d3, + (q31_t)0x236fa3b, (q31_t)0x10b0d9d0, (q31_t)0x23a4265, (q31_t)0x10bcfb28, + (q31_t)0x23d8cf1, (q31_t)0x10c91bda, (q31_t)0x240d9de, (q31_t)0x10d53be7, + (q31_t)0x244292c, (q31_t)0x10e15b4e, (q31_t)0x2477adc, (q31_t)0x10ed7a0e, + (q31_t)0x24aceed, (q31_t)0x10f99827, (q31_t)0x24e255e, (q31_t)0x1105b599, + (q31_t)0x2517e31, (q31_t)0x1111d263, (q31_t)0x254d965, (q31_t)0x111dee84, + (q31_t)0x25836f9, (q31_t)0x112a09fc, (q31_t)0x25b96ee, (q31_t)0x113624cb, + (q31_t)0x25ef943, (q31_t)0x11423ef0, (q31_t)0x2625df8, (q31_t)0x114e586a, + (q31_t)0x265c50e, (q31_t)0x115a713a, (q31_t)0x2692e83, (q31_t)0x1166895f, + (q31_t)0x26c9a58, (q31_t)0x1172a0d7, (q31_t)0x270088e, (q31_t)0x117eb7a4, + (q31_t)0x2737922, (q31_t)0x118acdc4, (q31_t)0x276ec16, (q31_t)0x1196e337, + (q31_t)0x27a616a, (q31_t)0x11a2f7fc, (q31_t)0x27dd91c, (q31_t)0x11af0c13, + (q31_t)0x281532e, (q31_t)0x11bb1f7c, (q31_t)0x284cf9f, (q31_t)0x11c73235, + (q31_t)0x2884e6e, (q31_t)0x11d3443f, (q31_t)0x28bcf9c, (q31_t)0x11df5599, + (q31_t)0x28f5329, (q31_t)0x11eb6643, (q31_t)0x292d914, (q31_t)0x11f7763c, + (q31_t)0x296615d, (q31_t)0x12038584, (q31_t)0x299ec05, (q31_t)0x120f941a, + (q31_t)0x29d790a, (q31_t)0x121ba1fd, (q31_t)0x2a1086d, (q31_t)0x1227af2e, + (q31_t)0x2a49a2e, (q31_t)0x1233bbac, (q31_t)0x2a82e4d, (q31_t)0x123fc776, + (q31_t)0x2abc4c9, (q31_t)0x124bd28c, (q31_t)0x2af5da2, (q31_t)0x1257dced, + (q31_t)0x2b2f8d8, (q31_t)0x1263e699, (q31_t)0x2b6966c, (q31_t)0x126fef90, + (q31_t)0x2ba365c, (q31_t)0x127bf7d1, (q31_t)0x2bdd8a9, (q31_t)0x1287ff5b, + (q31_t)0x2c17d52, (q31_t)0x1294062f, (q31_t)0x2c52459, (q31_t)0x12a00c4b, + (q31_t)0x2c8cdbb, (q31_t)0x12ac11af, (q31_t)0x2cc7979, (q31_t)0x12b8165b, + (q31_t)0x2d02794, (q31_t)0x12c41a4f, (q31_t)0x2d3d80a, (q31_t)0x12d01d89, + (q31_t)0x2d78add, (q31_t)0x12dc2009, (q31_t)0x2db400a, (q31_t)0x12e821cf, + (q31_t)0x2def794, (q31_t)0x12f422db, (q31_t)0x2e2b178, (q31_t)0x1300232c, + (q31_t)0x2e66db8, (q31_t)0x130c22c1, (q31_t)0x2ea2c53, (q31_t)0x1318219a, + (q31_t)0x2eded49, (q31_t)0x13241fb6, (q31_t)0x2f1b099, (q31_t)0x13301d16, + (q31_t)0x2f57644, (q31_t)0x133c19b8, (q31_t)0x2f93e4a, (q31_t)0x1348159d, + (q31_t)0x2fd08a9, (q31_t)0x135410c3, (q31_t)0x300d563, (q31_t)0x13600b2a, + (q31_t)0x304a477, (q31_t)0x136c04d2, (q31_t)0x30875e5, (q31_t)0x1377fdbb, + (q31_t)0x30c49ad, (q31_t)0x1383f5e3, (q31_t)0x3101fce, (q31_t)0x138fed4b, + (q31_t)0x313f848, (q31_t)0x139be3f2, (q31_t)0x317d31c, (q31_t)0x13a7d9d7, + (q31_t)0x31bb049, (q31_t)0x13b3cefa, (q31_t)0x31f8fcf, (q31_t)0x13bfc35b, + (q31_t)0x32371ae, (q31_t)0x13cbb6f8, (q31_t)0x32755e5, (q31_t)0x13d7a9d3, + (q31_t)0x32b3c75, (q31_t)0x13e39be9, (q31_t)0x32f255e, (q31_t)0x13ef8d3c, + (q31_t)0x333109e, (q31_t)0x13fb7dc9, (q31_t)0x336fe37, (q31_t)0x14076d91, + (q31_t)0x33aee27, (q31_t)0x14135c94, (q31_t)0x33ee070, (q31_t)0x141f4ad1, + (q31_t)0x342d510, (q31_t)0x142b3846, (q31_t)0x346cc07, (q31_t)0x143724f5, + (q31_t)0x34ac556, (q31_t)0x144310dd, (q31_t)0x34ec0fc, (q31_t)0x144efbfc, + (q31_t)0x352bef9, (q31_t)0x145ae653, (q31_t)0x356bf4d, (q31_t)0x1466cfe1, + (q31_t)0x35ac1f7, (q31_t)0x1472b8a5, (q31_t)0x35ec6f8, (q31_t)0x147ea0a0, + (q31_t)0x362ce50, (q31_t)0x148a87d1, (q31_t)0x366d7fd, (q31_t)0x14966e36, + (q31_t)0x36ae401, (q31_t)0x14a253d1, (q31_t)0x36ef25b, (q31_t)0x14ae38a0, + (q31_t)0x373030a, (q31_t)0x14ba1ca3, (q31_t)0x377160f, (q31_t)0x14c5ffd9, + (q31_t)0x37b2b6a, (q31_t)0x14d1e242, (q31_t)0x37f4319, (q31_t)0x14ddc3de, + (q31_t)0x3835d1e, (q31_t)0x14e9a4ac, (q31_t)0x3877978, (q31_t)0x14f584ac, + (q31_t)0x38b9827, (q31_t)0x150163dc, (q31_t)0x38fb92a, (q31_t)0x150d423d, + (q31_t)0x393dc82, (q31_t)0x15191fcf, (q31_t)0x398022f, (q31_t)0x1524fc90, + (q31_t)0x39c2a2f, (q31_t)0x1530d881, (q31_t)0x3a05484, (q31_t)0x153cb3a0, + (q31_t)0x3a4812c, (q31_t)0x15488dee, (q31_t)0x3a8b028, (q31_t)0x1554676a, + (q31_t)0x3ace178, (q31_t)0x15604013, (q31_t)0x3b1151b, (q31_t)0x156c17e9, + (q31_t)0x3b54b11, (q31_t)0x1577eeec, (q31_t)0x3b9835a, (q31_t)0x1583c51b, + (q31_t)0x3bdbdf6, (q31_t)0x158f9a76, (q31_t)0x3c1fae5, (q31_t)0x159b6efb, + (q31_t)0x3c63a26, (q31_t)0x15a742ac, (q31_t)0x3ca7bba, (q31_t)0x15b31587, + (q31_t)0x3cebfa0, (q31_t)0x15bee78c, (q31_t)0x3d305d8, (q31_t)0x15cab8ba, + (q31_t)0x3d74e62, (q31_t)0x15d68911, (q31_t)0x3db993e, (q31_t)0x15e25890, + (q31_t)0x3dfe66c, (q31_t)0x15ee2738, (q31_t)0x3e435ea, (q31_t)0x15f9f507, + (q31_t)0x3e887bb, (q31_t)0x1605c1fd, (q31_t)0x3ecdbdc, (q31_t)0x16118e1a, + (q31_t)0x3f1324e, (q31_t)0x161d595d, (q31_t)0x3f58b10, (q31_t)0x162923c5, + (q31_t)0x3f9e624, (q31_t)0x1634ed53, (q31_t)0x3fe4388, (q31_t)0x1640b606, + (q31_t)0x402a33c, (q31_t)0x164c7ddd, (q31_t)0x4070540, (q31_t)0x165844d8, + (q31_t)0x40b6994, (q31_t)0x16640af7, (q31_t)0x40fd037, (q31_t)0x166fd039, + (q31_t)0x414392b, (q31_t)0x167b949d, (q31_t)0x418a46d, (q31_t)0x16875823, + (q31_t)0x41d11ff, (q31_t)0x16931acb, (q31_t)0x42181e0, (q31_t)0x169edc94, + (q31_t)0x425f410, (q31_t)0x16aa9d7e, (q31_t)0x42a688f, (q31_t)0x16b65d88, + (q31_t)0x42edf5c, (q31_t)0x16c21cb2, (q31_t)0x4335877, (q31_t)0x16cddafb, + (q31_t)0x437d3e1, (q31_t)0x16d99864, (q31_t)0x43c5199, (q31_t)0x16e554ea, + (q31_t)0x440d19e, (q31_t)0x16f1108f, (q31_t)0x44553f2, (q31_t)0x16fccb51, + (q31_t)0x449d892, (q31_t)0x17088531, (q31_t)0x44e5f80, (q31_t)0x17143e2d, + (q31_t)0x452e8bc, (q31_t)0x171ff646, (q31_t)0x4577444, (q31_t)0x172bad7a, + (q31_t)0x45c0219, (q31_t)0x173763c9, (q31_t)0x460923b, (q31_t)0x17431933, + (q31_t)0x46524a9, (q31_t)0x174ecdb8, (q31_t)0x469b963, (q31_t)0x175a8157, + (q31_t)0x46e5069, (q31_t)0x1766340f, (q31_t)0x472e9bc, (q31_t)0x1771e5e0, + (q31_t)0x477855a, (q31_t)0x177d96ca, (q31_t)0x47c2344, (q31_t)0x178946cc, + (q31_t)0x480c379, (q31_t)0x1794f5e6, (q31_t)0x48565f9, (q31_t)0x17a0a417, + (q31_t)0x48a0ac4, (q31_t)0x17ac515f, (q31_t)0x48eb1db, (q31_t)0x17b7fdbd, + (q31_t)0x4935b3c, (q31_t)0x17c3a931, (q31_t)0x49806e7, (q31_t)0x17cf53bb, + (q31_t)0x49cb4dd, (q31_t)0x17dafd59, (q31_t)0x4a1651c, (q31_t)0x17e6a60c, + (q31_t)0x4a617a6, (q31_t)0x17f24dd3, (q31_t)0x4aacc7a, (q31_t)0x17fdf4ae, + (q31_t)0x4af8397, (q31_t)0x18099a9c, (q31_t)0x4b43cfd, (q31_t)0x18153f9d, + (q31_t)0x4b8f8ad, (q31_t)0x1820e3b0, (q31_t)0x4bdb6a6, (q31_t)0x182c86d5, + (q31_t)0x4c276e8, (q31_t)0x1838290c, (q31_t)0x4c73972, (q31_t)0x1843ca53, + (q31_t)0x4cbfe45, (q31_t)0x184f6aab, (q31_t)0x4d0c560, (q31_t)0x185b0a13, + (q31_t)0x4d58ec3, (q31_t)0x1866a88a, (q31_t)0x4da5a6f, (q31_t)0x18724611, + (q31_t)0x4df2862, (q31_t)0x187de2a7, (q31_t)0x4e3f89c, (q31_t)0x18897e4a, + (q31_t)0x4e8cb1e, (q31_t)0x189518fc, (q31_t)0x4ed9fe7, (q31_t)0x18a0b2bb, + (q31_t)0x4f276f7, (q31_t)0x18ac4b87, (q31_t)0x4f7504e, (q31_t)0x18b7e35f, + (q31_t)0x4fc2bec, (q31_t)0x18c37a44, (q31_t)0x50109d0, (q31_t)0x18cf1034, + (q31_t)0x505e9fb, (q31_t)0x18daa52f, (q31_t)0x50acc6b, (q31_t)0x18e63935, + (q31_t)0x50fb121, (q31_t)0x18f1cc45, (q31_t)0x514981d, (q31_t)0x18fd5e5f, + (q31_t)0x519815f, (q31_t)0x1908ef82, (q31_t)0x51e6ce6, (q31_t)0x19147fae, + (q31_t)0x5235ab2, (q31_t)0x19200ee3, (q31_t)0x5284ac3, (q31_t)0x192b9d1f, + (q31_t)0x52d3d18, (q31_t)0x19372a64, (q31_t)0x53231b3, (q31_t)0x1942b6af, + (q31_t)0x5372891, (q31_t)0x194e4201, (q31_t)0x53c21b4, (q31_t)0x1959cc5a, + (q31_t)0x5411d1b, (q31_t)0x196555b8, (q31_t)0x5461ac6, (q31_t)0x1970de1b, + (q31_t)0x54b1ab4, (q31_t)0x197c6584, (q31_t)0x5501ce5, (q31_t)0x1987ebf0, + (q31_t)0x555215a, (q31_t)0x19937161, (q31_t)0x55a2812, (q31_t)0x199ef5d6, + (q31_t)0x55f310d, (q31_t)0x19aa794d, (q31_t)0x5643c4a, (q31_t)0x19b5fbc8, + (q31_t)0x56949ca, (q31_t)0x19c17d44, (q31_t)0x56e598c, (q31_t)0x19ccfdc2, + (q31_t)0x5736b90, (q31_t)0x19d87d42, (q31_t)0x5787fd6, (q31_t)0x19e3fbc3, + (q31_t)0x57d965d, (q31_t)0x19ef7944, (q31_t)0x582af26, (q31_t)0x19faf5c5, + (q31_t)0x587ca31, (q31_t)0x1a067145, (q31_t)0x58ce77c, (q31_t)0x1a11ebc5, + (q31_t)0x5920708, (q31_t)0x1a1d6544, (q31_t)0x59728d5, (q31_t)0x1a28ddc0, + (q31_t)0x59c4ce3, (q31_t)0x1a34553b, (q31_t)0x5a17330, (q31_t)0x1a3fcbb3, + (q31_t)0x5a69bbe, (q31_t)0x1a4b4128, (q31_t)0x5abc68c, (q31_t)0x1a56b599, + (q31_t)0x5b0f399, (q31_t)0x1a622907, (q31_t)0x5b622e6, (q31_t)0x1a6d9b70, + (q31_t)0x5bb5472, (q31_t)0x1a790cd4, (q31_t)0x5c0883d, (q31_t)0x1a847d33, + (q31_t)0x5c5be47, (q31_t)0x1a8fec8c, (q31_t)0x5caf690, (q31_t)0x1a9b5adf, + (q31_t)0x5d03118, (q31_t)0x1aa6c82b, (q31_t)0x5d56ddd, (q31_t)0x1ab23471, + (q31_t)0x5daace1, (q31_t)0x1abd9faf, (q31_t)0x5dfee22, (q31_t)0x1ac909e5, + (q31_t)0x5e531a1, (q31_t)0x1ad47312, (q31_t)0x5ea775e, (q31_t)0x1adfdb37, + (q31_t)0x5efbf58, (q31_t)0x1aeb4253, (q31_t)0x5f5098f, (q31_t)0x1af6a865, + (q31_t)0x5fa5603, (q31_t)0x1b020d6c, (q31_t)0x5ffa4b3, (q31_t)0x1b0d716a, + (q31_t)0x604f5a0, (q31_t)0x1b18d45c, (q31_t)0x60a48c9, (q31_t)0x1b243643, + (q31_t)0x60f9e2e, (q31_t)0x1b2f971e, (q31_t)0x614f5cf, (q31_t)0x1b3af6ec, + (q31_t)0x61a4fac, (q31_t)0x1b4655ae, (q31_t)0x61fabc4, (q31_t)0x1b51b363, + (q31_t)0x6250a18, (q31_t)0x1b5d100a, (q31_t)0x62a6aa6, (q31_t)0x1b686ba3, + (q31_t)0x62fcd6f, (q31_t)0x1b73c62d, (q31_t)0x6353273, (q31_t)0x1b7f1fa9, + (q31_t)0x63a99b1, (q31_t)0x1b8a7815, (q31_t)0x6400329, (q31_t)0x1b95cf71, + (q31_t)0x6456edb, (q31_t)0x1ba125bd, (q31_t)0x64adcc7, (q31_t)0x1bac7af9, + (q31_t)0x6504ced, (q31_t)0x1bb7cf23, (q31_t)0x655bf4c, (q31_t)0x1bc3223c, + (q31_t)0x65b33e4, (q31_t)0x1bce7442, (q31_t)0x660aab5, (q31_t)0x1bd9c537, + (q31_t)0x66623be, (q31_t)0x1be51518, (q31_t)0x66b9f01, (q31_t)0x1bf063e6, + (q31_t)0x6711c7b, (q31_t)0x1bfbb1a0, (q31_t)0x6769c2e, (q31_t)0x1c06fe46, + (q31_t)0x67c1e18, (q31_t)0x1c1249d8, (q31_t)0x681a23a, (q31_t)0x1c1d9454, + (q31_t)0x6872894, (q31_t)0x1c28ddbb, (q31_t)0x68cb124, (q31_t)0x1c34260c, + (q31_t)0x6923bec, (q31_t)0x1c3f6d47, (q31_t)0x697c8eb, (q31_t)0x1c4ab36b, + (q31_t)0x69d5820, (q31_t)0x1c55f878, (q31_t)0x6a2e98b, (q31_t)0x1c613c6d, + (q31_t)0x6a87d2d, (q31_t)0x1c6c7f4a, (q31_t)0x6ae1304, (q31_t)0x1c77c10e, + (q31_t)0x6b3ab12, (q31_t)0x1c8301b9, (q31_t)0x6b94554, (q31_t)0x1c8e414b, + (q31_t)0x6bee1cd, (q31_t)0x1c997fc4, (q31_t)0x6c4807a, (q31_t)0x1ca4bd21, + (q31_t)0x6ca215c, (q31_t)0x1caff965, (q31_t)0x6cfc472, (q31_t)0x1cbb348d, + (q31_t)0x6d569be, (q31_t)0x1cc66e99, (q31_t)0x6db113d, (q31_t)0x1cd1a78a, + (q31_t)0x6e0baf0, (q31_t)0x1cdcdf5e, (q31_t)0x6e666d7, (q31_t)0x1ce81615, + (q31_t)0x6ec14f2, (q31_t)0x1cf34baf, (q31_t)0x6f1c540, (q31_t)0x1cfe802b, + (q31_t)0x6f777c1, (q31_t)0x1d09b389, (q31_t)0x6fd2c75, (q31_t)0x1d14e5c9, + (q31_t)0x702e35c, (q31_t)0x1d2016e9, (q31_t)0x7089c75, (q31_t)0x1d2b46ea, + (q31_t)0x70e57c0, (q31_t)0x1d3675cb, (q31_t)0x714153e, (q31_t)0x1d41a38c, + (q31_t)0x719d4ed, (q31_t)0x1d4cd02c, (q31_t)0x71f96ce, (q31_t)0x1d57fbaa, + (q31_t)0x7255ae0, (q31_t)0x1d632608, (q31_t)0x72b2123, (q31_t)0x1d6e4f43, + (q31_t)0x730e997, (q31_t)0x1d79775c, (q31_t)0x736b43c, (q31_t)0x1d849e51, + (q31_t)0x73c8111, (q31_t)0x1d8fc424, (q31_t)0x7425016, (q31_t)0x1d9ae8d2, + (q31_t)0x748214c, (q31_t)0x1da60c5d, (q31_t)0x74df4b1, (q31_t)0x1db12ec3, + (q31_t)0x753ca46, (q31_t)0x1dbc5004, (q31_t)0x759a20a, (q31_t)0x1dc7701f, + (q31_t)0x75f7bfe, (q31_t)0x1dd28f15, (q31_t)0x7655820, (q31_t)0x1dddace4, + (q31_t)0x76b3671, (q31_t)0x1de8c98c, (q31_t)0x77116f0, (q31_t)0x1df3e50d, + (q31_t)0x776f99d, (q31_t)0x1dfeff67, (q31_t)0x77cde79, (q31_t)0x1e0a1898, + (q31_t)0x782c582, (q31_t)0x1e1530a1, (q31_t)0x788aeb9, (q31_t)0x1e204781, + (q31_t)0x78e9a1d, (q31_t)0x1e2b5d38, (q31_t)0x79487ae, (q31_t)0x1e3671c5, + (q31_t)0x79a776c, (q31_t)0x1e418528, (q31_t)0x7a06957, (q31_t)0x1e4c9760, + (q31_t)0x7a65d6e, (q31_t)0x1e57a86d, (q31_t)0x7ac53b1, (q31_t)0x1e62b84f, + (q31_t)0x7b24c20, (q31_t)0x1e6dc705, (q31_t)0x7b846ba, (q31_t)0x1e78d48e, + (q31_t)0x7be4381, (q31_t)0x1e83e0eb, (q31_t)0x7c44272, (q31_t)0x1e8eec1b, + (q31_t)0x7ca438f, (q31_t)0x1e99f61d, (q31_t)0x7d046d6, (q31_t)0x1ea4fef0, + (q31_t)0x7d64c47, (q31_t)0x1eb00696, (q31_t)0x7dc53e3, (q31_t)0x1ebb0d0d, + (q31_t)0x7e25daa, (q31_t)0x1ec61254, (q31_t)0x7e8699a, (q31_t)0x1ed1166b, + (q31_t)0x7ee77b3, (q31_t)0x1edc1953, (q31_t)0x7f487f6, (q31_t)0x1ee71b0a, + (q31_t)0x7fa9a62, (q31_t)0x1ef21b90, (q31_t)0x800aef7, (q31_t)0x1efd1ae4, + (q31_t)0x806c5b5, (q31_t)0x1f081907, (q31_t)0x80cde9b, (q31_t)0x1f1315f7, + (q31_t)0x812f9a9, (q31_t)0x1f1e11b5, (q31_t)0x81916df, (q31_t)0x1f290c3f, + (q31_t)0x81f363d, (q31_t)0x1f340596, (q31_t)0x82557c3, (q31_t)0x1f3efdb9, + (q31_t)0x82b7b70, (q31_t)0x1f49f4a8, (q31_t)0x831a143, (q31_t)0x1f54ea62, + (q31_t)0x837c93e, (q31_t)0x1f5fdee6, (q31_t)0x83df35f, (q31_t)0x1f6ad235, + (q31_t)0x8441fa6, (q31_t)0x1f75c44e, (q31_t)0x84a4e14, (q31_t)0x1f80b531, + (q31_t)0x8507ea7, (q31_t)0x1f8ba4dc, (q31_t)0x856b160, (q31_t)0x1f969350, + (q31_t)0x85ce63e, (q31_t)0x1fa1808c, (q31_t)0x8631d42, (q31_t)0x1fac6c91, + (q31_t)0x869566a, (q31_t)0x1fb7575c, (q31_t)0x86f91b7, (q31_t)0x1fc240ef, + (q31_t)0x875cf28, (q31_t)0x1fcd2948, (q31_t)0x87c0ebd, (q31_t)0x1fd81067, + (q31_t)0x8825077, (q31_t)0x1fe2f64c, (q31_t)0x8889454, (q31_t)0x1feddaf6, + (q31_t)0x88eda54, (q31_t)0x1ff8be65, (q31_t)0x8952278, (q31_t)0x2003a099, + (q31_t)0x89b6cbf, (q31_t)0x200e8190, (q31_t)0x8a1b928, (q31_t)0x2019614c, + (q31_t)0x8a807b4, (q31_t)0x20243fca, (q31_t)0x8ae5862, (q31_t)0x202f1d0b, + (q31_t)0x8b4ab32, (q31_t)0x2039f90f, (q31_t)0x8bb0023, (q31_t)0x2044d3d4, + (q31_t)0x8c15736, (q31_t)0x204fad5b, (q31_t)0x8c7b06b, (q31_t)0x205a85a3, + (q31_t)0x8ce0bc0, (q31_t)0x20655cac, (q31_t)0x8d46936, (q31_t)0x20703275, + (q31_t)0x8dac8cd, (q31_t)0x207b06fe, (q31_t)0x8e12a84, (q31_t)0x2085da46, + (q31_t)0x8e78e5b, (q31_t)0x2090ac4d, (q31_t)0x8edf452, (q31_t)0x209b7d13, + (q31_t)0x8f45c68, (q31_t)0x20a64c97, (q31_t)0x8fac69e, (q31_t)0x20b11ad9, + (q31_t)0x90132f2, (q31_t)0x20bbe7d8, (q31_t)0x907a166, (q31_t)0x20c6b395, + (q31_t)0x90e11f7, (q31_t)0x20d17e0d, (q31_t)0x91484a8, (q31_t)0x20dc4742, + (q31_t)0x91af976, (q31_t)0x20e70f32, (q31_t)0x9217062, (q31_t)0x20f1d5de, + (q31_t)0x927e96b, (q31_t)0x20fc9b44, (q31_t)0x92e6492, (q31_t)0x21075f65, + (q31_t)0x934e1d6, (q31_t)0x21122240, (q31_t)0x93b6137, (q31_t)0x211ce3d5, + (q31_t)0x941e2b4, (q31_t)0x2127a423, (q31_t)0x948664d, (q31_t)0x21326329, + (q31_t)0x94eec03, (q31_t)0x213d20e8, (q31_t)0x95573d4, (q31_t)0x2147dd5f, + (q31_t)0x95bfdc1, (q31_t)0x2152988d, (q31_t)0x96289c9, (q31_t)0x215d5273, + (q31_t)0x96917ec, (q31_t)0x21680b0f, (q31_t)0x96fa82a, (q31_t)0x2172c262, + (q31_t)0x9763a83, (q31_t)0x217d786a, (q31_t)0x97ccef5, (q31_t)0x21882d28, + (q31_t)0x9836582, (q31_t)0x2192e09b, (q31_t)0x989fe29, (q31_t)0x219d92c2, + (q31_t)0x99098e9, (q31_t)0x21a8439e, (q31_t)0x99735c2, (q31_t)0x21b2f32e, + (q31_t)0x99dd4b4, (q31_t)0x21bda171, (q31_t)0x9a475bf, (q31_t)0x21c84e67, + (q31_t)0x9ab18e3, (q31_t)0x21d2fa0f, (q31_t)0x9b1be1e, (q31_t)0x21dda46a, + (q31_t)0x9b86572, (q31_t)0x21e84d76, (q31_t)0x9bf0edd, (q31_t)0x21f2f534, + (q31_t)0x9c5ba60, (q31_t)0x21fd9ba3, (q31_t)0x9cc67fa, (q31_t)0x220840c2, + (q31_t)0x9d317ab, (q31_t)0x2212e492, (q31_t)0x9d9c973, (q31_t)0x221d8711, + (q31_t)0x9e07d51, (q31_t)0x2228283f, (q31_t)0x9e73346, (q31_t)0x2232c81c, + (q31_t)0x9edeb50, (q31_t)0x223d66a8, (q31_t)0x9f4a570, (q31_t)0x224803e2, + (q31_t)0x9fb61a5, (q31_t)0x22529fca, (q31_t)0xa021fef, (q31_t)0x225d3a5e, + (q31_t)0xa08e04f, (q31_t)0x2267d3a0, (q31_t)0xa0fa2c3, (q31_t)0x22726b8e, + (q31_t)0xa16674b, (q31_t)0x227d0228, (q31_t)0xa1d2de7, (q31_t)0x2287976e, + (q31_t)0xa23f698, (q31_t)0x22922b5e, (q31_t)0xa2ac15b, (q31_t)0x229cbdfa, + (q31_t)0xa318e32, (q31_t)0x22a74f40, (q31_t)0xa385d1d, (q31_t)0x22b1df30, + (q31_t)0xa3f2e19, (q31_t)0x22bc6dca, (q31_t)0xa460129, (q31_t)0x22c6fb0c, + (q31_t)0xa4cd64b, (q31_t)0x22d186f8, (q31_t)0xa53ad7e, (q31_t)0x22dc118c, + (q31_t)0xa5a86c4, (q31_t)0x22e69ac8, (q31_t)0xa61621b, (q31_t)0x22f122ab, + (q31_t)0xa683f83, (q31_t)0x22fba936, (q31_t)0xa6f1efc, (q31_t)0x23062e67, + (q31_t)0xa760086, (q31_t)0x2310b23e, (q31_t)0xa7ce420, (q31_t)0x231b34bc, + (q31_t)0xa83c9ca, (q31_t)0x2325b5df, (q31_t)0xa8ab184, (q31_t)0x233035a7, + (q31_t)0xa919b4e, (q31_t)0x233ab414, (q31_t)0xa988727, (q31_t)0x23453125, + (q31_t)0xa9f750f, (q31_t)0x234facda, (q31_t)0xaa66506, (q31_t)0x235a2733, + (q31_t)0xaad570c, (q31_t)0x2364a02e, (q31_t)0xab44b1f, (q31_t)0x236f17cc, + (q31_t)0xabb4141, (q31_t)0x23798e0d, (q31_t)0xac23971, (q31_t)0x238402ef, + (q31_t)0xac933ae, (q31_t)0x238e7673, (q31_t)0xad02ff8, (q31_t)0x2398e898, + (q31_t)0xad72e4f, (q31_t)0x23a3595e, (q31_t)0xade2eb3, (q31_t)0x23adc8c4, + (q31_t)0xae53123, (q31_t)0x23b836ca, (q31_t)0xaec35a0, (q31_t)0x23c2a36f, + (q31_t)0xaf33c28, (q31_t)0x23cd0eb3, (q31_t)0xafa44bc, (q31_t)0x23d77896, + (q31_t)0xb014f5b, (q31_t)0x23e1e117, (q31_t)0xb085c05, (q31_t)0x23ec4837, + (q31_t)0xb0f6aba, (q31_t)0x23f6adf3, (q31_t)0xb167b79, (q31_t)0x2401124d, + (q31_t)0xb1d8e43, (q31_t)0x240b7543, (q31_t)0xb24a316, (q31_t)0x2415d6d5, + (q31_t)0xb2bb9f4, (q31_t)0x24203704, (q31_t)0xb32d2da, (q31_t)0x242a95ce, + (q31_t)0xb39edca, (q31_t)0x2434f332, (q31_t)0xb410ac3, (q31_t)0x243f4f32, + (q31_t)0xb4829c4, (q31_t)0x2449a9cc, (q31_t)0xb4f4acd, (q31_t)0x245402ff, + (q31_t)0xb566ddf, (q31_t)0x245e5acc, (q31_t)0xb5d92f8, (q31_t)0x2468b132, + (q31_t)0xb64ba19, (q31_t)0x24730631, (q31_t)0xb6be341, (q31_t)0x247d59c8, + (q31_t)0xb730e70, (q31_t)0x2487abf7, (q31_t)0xb7a3ba5, (q31_t)0x2491fcbe, + (q31_t)0xb816ae1, (q31_t)0x249c4c1b, (q31_t)0xb889c23, (q31_t)0x24a69a0f, + (q31_t)0xb8fcf6b, (q31_t)0x24b0e699, (q31_t)0xb9704b9, (q31_t)0x24bb31ba, + (q31_t)0xb9e3c0b, (q31_t)0x24c57b6f, (q31_t)0xba57563, (q31_t)0x24cfc3ba, + (q31_t)0xbacb0bf, (q31_t)0x24da0a9a, (q31_t)0xbb3ee20, (q31_t)0x24e4500e, + (q31_t)0xbbb2d85, (q31_t)0x24ee9415, (q31_t)0xbc26eee, (q31_t)0x24f8d6b0, + (q31_t)0xbc9b25a, (q31_t)0x250317df, (q31_t)0xbd0f7ca, (q31_t)0x250d57a0, + (q31_t)0xbd83f3d, (q31_t)0x251795f3, (q31_t)0xbdf88b3, (q31_t)0x2521d2d8, + (q31_t)0xbe6d42b, (q31_t)0x252c0e4f, (q31_t)0xbee21a5, (q31_t)0x25364857, + (q31_t)0xbf57121, (q31_t)0x254080ef, (q31_t)0xbfcc29f, (q31_t)0x254ab818, + (q31_t)0xc04161e, (q31_t)0x2554edd1, (q31_t)0xc0b6b9e, (q31_t)0x255f2219, + (q31_t)0xc12c31f, (q31_t)0x256954f1, (q31_t)0xc1a1ca0, (q31_t)0x25738657, + (q31_t)0xc217822, (q31_t)0x257db64c, (q31_t)0xc28d5a3, (q31_t)0x2587e4cf, + (q31_t)0xc303524, (q31_t)0x259211df, (q31_t)0xc3796a5, (q31_t)0x259c3d7c, + (q31_t)0xc3efa25, (q31_t)0x25a667a7, (q31_t)0xc465fa3, (q31_t)0x25b0905d, + (q31_t)0xc4dc720, (q31_t)0x25bab7a0, (q31_t)0xc55309b, (q31_t)0x25c4dd6e, + (q31_t)0xc5c9c14, (q31_t)0x25cf01c8, (q31_t)0xc64098b, (q31_t)0x25d924ac, + (q31_t)0xc6b78ff, (q31_t)0x25e3461b, (q31_t)0xc72ea70, (q31_t)0x25ed6614, + (q31_t)0xc7a5dde, (q31_t)0x25f78497, (q31_t)0xc81d349, (q31_t)0x2601a1a2, + (q31_t)0xc894aaf, (q31_t)0x260bbd37, (q31_t)0xc90c412, (q31_t)0x2615d754, + (q31_t)0xc983f70, (q31_t)0x261feffa, (q31_t)0xc9fbcca, (q31_t)0x262a0727, + (q31_t)0xca73c1e, (q31_t)0x26341cdb, (q31_t)0xcaebd6e, (q31_t)0x263e3117, + (q31_t)0xcb640b8, (q31_t)0x264843d9, (q31_t)0xcbdc5fc, (q31_t)0x26525521, + (q31_t)0xcc54d3a, (q31_t)0x265c64ef, (q31_t)0xcccd671, (q31_t)0x26667342, + (q31_t)0xcd461a2, (q31_t)0x2670801a, (q31_t)0xcdbeecc, (q31_t)0x267a8b77, + (q31_t)0xce37def, (q31_t)0x26849558, (q31_t)0xceb0f0a, (q31_t)0x268e9dbd, + (q31_t)0xcf2a21d, (q31_t)0x2698a4a6, (q31_t)0xcfa3729, (q31_t)0x26a2aa11, + (q31_t)0xd01ce2b, (q31_t)0x26acadff, (q31_t)0xd096725, (q31_t)0x26b6b070, + (q31_t)0xd110216, (q31_t)0x26c0b162, (q31_t)0xd189efe, (q31_t)0x26cab0d6, + (q31_t)0xd203ddc, (q31_t)0x26d4aecb, (q31_t)0xd27deb0, (q31_t)0x26deab41, + (q31_t)0xd2f817b, (q31_t)0x26e8a637, (q31_t)0xd37263a, (q31_t)0x26f29fad, + (q31_t)0xd3eccef, (q31_t)0x26fc97a3, (q31_t)0xd467599, (q31_t)0x27068e18, + (q31_t)0xd4e2037, (q31_t)0x2710830c, (q31_t)0xd55ccca, (q31_t)0x271a767e, + (q31_t)0xd5d7b50, (q31_t)0x2724686e, (q31_t)0xd652bcb, (q31_t)0x272e58dc, + (q31_t)0xd6cde39, (q31_t)0x273847c8, (q31_t)0xd74929a, (q31_t)0x27423530, + (q31_t)0xd7c48ee, (q31_t)0x274c2115, (q31_t)0xd840134, (q31_t)0x27560b76, + (q31_t)0xd8bbb6d, (q31_t)0x275ff452, (q31_t)0xd937798, (q31_t)0x2769dbaa, + (q31_t)0xd9b35b4, (q31_t)0x2773c17d, (q31_t)0xda2f5c2, (q31_t)0x277da5cb, + (q31_t)0xdaab7c0, (q31_t)0x27878893, (q31_t)0xdb27bb0, (q31_t)0x279169d5, + (q31_t)0xdba4190, (q31_t)0x279b4990, (q31_t)0xdc20960, (q31_t)0x27a527c4, + (q31_t)0xdc9d320, (q31_t)0x27af0472, (q31_t)0xdd19ed0, (q31_t)0x27b8df97, + (q31_t)0xdd96c6f, (q31_t)0x27c2b934, (q31_t)0xde13bfd, (q31_t)0x27cc9149, + (q31_t)0xde90d79, (q31_t)0x27d667d5, (q31_t)0xdf0e0e4, (q31_t)0x27e03cd8, + (q31_t)0xdf8b63d, (q31_t)0x27ea1052, (q31_t)0xe008d84, (q31_t)0x27f3e241, + (q31_t)0xe0866b8, (q31_t)0x27fdb2a7, (q31_t)0xe1041d9, (q31_t)0x28078181, + (q31_t)0xe181ee8, (q31_t)0x28114ed0, (q31_t)0xe1ffde2, (q31_t)0x281b1a94, + (q31_t)0xe27dec9, (q31_t)0x2824e4cc, (q31_t)0xe2fc19c, (q31_t)0x282ead78, + (q31_t)0xe37a65b, (q31_t)0x28387498, (q31_t)0xe3f8d05, (q31_t)0x28423a2a, + (q31_t)0xe47759a, (q31_t)0x284bfe2f, (q31_t)0xe4f6019, (q31_t)0x2855c0a6, + (q31_t)0xe574c84, (q31_t)0x285f8190, (q31_t)0xe5f3ad8, (q31_t)0x286940ea, + (q31_t)0xe672b16, (q31_t)0x2872feb6, (q31_t)0xe6f1d3d, (q31_t)0x287cbaf3, + (q31_t)0xe77114e, (q31_t)0x288675a0, (q31_t)0xe7f0748, (q31_t)0x28902ebd, + (q31_t)0xe86ff2a, (q31_t)0x2899e64a, (q31_t)0xe8ef8f4, (q31_t)0x28a39c46, + (q31_t)0xe96f4a7, (q31_t)0x28ad50b1, (q31_t)0xe9ef241, (q31_t)0x28b7038b, + (q31_t)0xea6f1c2, (q31_t)0x28c0b4d2, (q31_t)0xeaef32b, (q31_t)0x28ca6488, + (q31_t)0xeb6f67a, (q31_t)0x28d412ab, (q31_t)0xebefbb0, (q31_t)0x28ddbf3b, + (q31_t)0xec702cb, (q31_t)0x28e76a37, (q31_t)0xecf0bcd, (q31_t)0x28f113a0, + (q31_t)0xed716b4, (q31_t)0x28fabb75, (q31_t)0xedf2380, (q31_t)0x290461b5, + (q31_t)0xee73231, (q31_t)0x290e0661, (q31_t)0xeef42c7, (q31_t)0x2917a977, + (q31_t)0xef75541, (q31_t)0x29214af8, (q31_t)0xeff699f, (q31_t)0x292aeae3, + (q31_t)0xf077fe1, (q31_t)0x29348937, (q31_t)0xf0f9805, (q31_t)0x293e25f5, + (q31_t)0xf17b20d, (q31_t)0x2947c11c, (q31_t)0xf1fcdf8, (q31_t)0x29515aab, + (q31_t)0xf27ebc5, (q31_t)0x295af2a3, (q31_t)0xf300b74, (q31_t)0x29648902, + (q31_t)0xf382d05, (q31_t)0x296e1dc9, (q31_t)0xf405077, (q31_t)0x2977b0f7, + (q31_t)0xf4875ca, (q31_t)0x2981428c, (q31_t)0xf509cfe, (q31_t)0x298ad287, + (q31_t)0xf58c613, (q31_t)0x299460e8, (q31_t)0xf60f108, (q31_t)0x299dedaf, + (q31_t)0xf691ddd, (q31_t)0x29a778db, (q31_t)0xf714c91, (q31_t)0x29b1026c, + (q31_t)0xf797d24, (q31_t)0x29ba8a61, (q31_t)0xf81af97, (q31_t)0x29c410ba, + (q31_t)0xf89e3e8, (q31_t)0x29cd9578, (q31_t)0xf921a17, (q31_t)0x29d71899, + (q31_t)0xf9a5225, (q31_t)0x29e09a1c, (q31_t)0xfa28c10, (q31_t)0x29ea1a03, + (q31_t)0xfaac7d8, (q31_t)0x29f3984c, (q31_t)0xfb3057d, (q31_t)0x29fd14f6, + (q31_t)0xfbb4500, (q31_t)0x2a069003, (q31_t)0xfc3865e, (q31_t)0x2a100970, + (q31_t)0xfcbc999, (q31_t)0x2a19813f, (q31_t)0xfd40eaf, (q31_t)0x2a22f76e, + (q31_t)0xfdc55a1, (q31_t)0x2a2c6bfd, (q31_t)0xfe49e6d, (q31_t)0x2a35deeb, + (q31_t)0xfece915, (q31_t)0x2a3f503a, (q31_t)0xff53597, (q31_t)0x2a48bfe7, + (q31_t)0xffd83f4, (q31_t)0x2a522df3, (q31_t)0x1005d42a, (q31_t)0x2a5b9a5d, (q31_t)0x100e2639, (q31_t)0x2a650525, (q31_t)0x10167a22, (q31_t)0x2a6e6e4b, (q31_t)0x101ecfe4, (q31_t)0x2a77d5ce, (q31_t)0x1027277e, (q31_t)0x2a813bae, (q31_t)0x102f80f1, (q31_t)0x2a8a9fea, (q31_t)0x1037dc3b, (q31_t)0x2a940283, @@ -2104,7 +2105,6 @@ const q31_t realCoefAQ31[8192] = { (q31_t)0x3fe6de05, (q31_t)0x3ffffb11, (q31_t)0x3ff36f02, (q31_t)0x3ffffec4, }; - /** @par Generation of realCoefBQ31 array: @@ -2112,9 +2112,9 @@ const q31_t realCoefAQ31[8192] = { n = 4096
for (i = 0; i < n; i++)
   {
-     pBTable[2 * i]     = 0.5 * (1.0 + sin (2 * PI / (double) (2 * n) * (double) i));
-     pBTable[2 * i + 1] = 0.5 * (1.0 * cos (2 * PI / (double) (2 * n) * (double) i));
-  } 
+ pBTable[2 * i] = 0.5 * (1.0 + sin (2 * PI / (double) (2 * n) * (double) + i)); pBTable[2 * i + 1] = 0.5 * (1.0 * cos (2 * PI / (double) (2 * n) * + (double) i)); }
@par Convert to fixed point Q31 format round(pBTable[i] * pow(2, 31)) @@ -2981,171 +2981,171 @@ const q31_t realCoefBQ31[8192] = { (q31_t)0x7de9544f, (q31_t)0x1037694b, (q31_t)0x7dec823e, (q31_t)0x102b40f8, (q31_t)0x7defadca, (q31_t)0x101f1807, (q31_t)0x7df2d6f3, (q31_t)0x1012ee76, (q31_t)0x7df5fdb8, (q31_t)0x1006c446, (q31_t)0x7df9221a, (q31_t)0xffa9979, - (q31_t)0x7dfc4418, (q31_t)0xfee6e0d, (q31_t)0x7dff63b2, (q31_t)0xfe24205, - (q31_t)0x7e0280e9, (q31_t)0xfd6155f, (q31_t)0x7e059bbb, (q31_t)0xfc9e81e, - (q31_t)0x7e08b42a, (q31_t)0xfbdba40, (q31_t)0x7e0bca34, (q31_t)0xfb18bc8, - (q31_t)0x7e0eddd9, (q31_t)0xfa55cb4, (q31_t)0x7e11ef1b, (q31_t)0xf992d06, - (q31_t)0x7e14fdf7, (q31_t)0xf8cfcbe, (q31_t)0x7e180a6f, (q31_t)0xf80cbdc, - (q31_t)0x7e1b1482, (q31_t)0xf749a61, (q31_t)0x7e1e1c30, (q31_t)0xf68684e, - (q31_t)0x7e212179, (q31_t)0xf5c35a3, (q31_t)0x7e24245d, (q31_t)0xf500260, - (q31_t)0x7e2724db, (q31_t)0xf43ce86, (q31_t)0x7e2a22f4, (q31_t)0xf379a16, - (q31_t)0x7e2d1ea8, (q31_t)0xf2b650f, (q31_t)0x7e3017f6, (q31_t)0xf1f2f73, - (q31_t)0x7e330ede, (q31_t)0xf12f941, (q31_t)0x7e360360, (q31_t)0xf06c27a, - (q31_t)0x7e38f57c, (q31_t)0xefa8b20, (q31_t)0x7e3be532, (q31_t)0xeee5331, - (q31_t)0x7e3ed282, (q31_t)0xee21aaf, (q31_t)0x7e41bd6c, (q31_t)0xed5e19a, - (q31_t)0x7e44a5ef, (q31_t)0xec9a7f3, (q31_t)0x7e478c0b, (q31_t)0xebd6db9, - (q31_t)0x7e4a6fc1, (q31_t)0xeb132ef, (q31_t)0x7e4d5110, (q31_t)0xea4f793, - (q31_t)0x7e502ff9, (q31_t)0xe98bba7, (q31_t)0x7e530c7a, (q31_t)0xe8c7f2a, - (q31_t)0x7e55e694, (q31_t)0xe80421e, (q31_t)0x7e58be47, (q31_t)0xe740483, - (q31_t)0x7e5b9392, (q31_t)0xe67c65a, (q31_t)0x7e5e6676, (q31_t)0xe5b87a2, - (q31_t)0x7e6136f3, (q31_t)0xe4f485c, (q31_t)0x7e640507, (q31_t)0xe430889, - (q31_t)0x7e66d0b4, (q31_t)0xe36c82a, (q31_t)0x7e6999fa, (q31_t)0xe2a873e, - (q31_t)0x7e6c60d7, (q31_t)0xe1e45c6, (q31_t)0x7e6f254c, (q31_t)0xe1203c3, - (q31_t)0x7e71e759, (q31_t)0xe05c135, (q31_t)0x7e74a6fd, (q31_t)0xdf97e1d, - (q31_t)0x7e77643a, (q31_t)0xded3a7b, (q31_t)0x7e7a1f0d, (q31_t)0xde0f64f, - (q31_t)0x7e7cd778, (q31_t)0xdd4b19a, (q31_t)0x7e7f8d7b, (q31_t)0xdc86c5d, - (q31_t)0x7e824114, (q31_t)0xdbc2698, (q31_t)0x7e84f245, (q31_t)0xdafe04b, - (q31_t)0x7e87a10c, (q31_t)0xda39978, (q31_t)0x7e8a4d6a, (q31_t)0xd97521d, - (q31_t)0x7e8cf75f, (q31_t)0xd8b0a3d, (q31_t)0x7e8f9eeb, (q31_t)0xd7ec1d6, - (q31_t)0x7e92440d, (q31_t)0xd7278eb, (q31_t)0x7e94e6c6, (q31_t)0xd662f7b, - (q31_t)0x7e978715, (q31_t)0xd59e586, (q31_t)0x7e9a24fb, (q31_t)0xd4d9b0e, - (q31_t)0x7e9cc076, (q31_t)0xd415013, (q31_t)0x7e9f5988, (q31_t)0xd350495, - (q31_t)0x7ea1f02f, (q31_t)0xd28b894, (q31_t)0x7ea4846c, (q31_t)0xd1c6c11, - (q31_t)0x7ea7163f, (q31_t)0xd101f0e, (q31_t)0x7ea9a5a8, (q31_t)0xd03d189, - (q31_t)0x7eac32a6, (q31_t)0xcf78383, (q31_t)0x7eaebd3a, (q31_t)0xceb34fe, - (q31_t)0x7eb14563, (q31_t)0xcdee5f9, (q31_t)0x7eb3cb21, (q31_t)0xcd29676, - (q31_t)0x7eb64e75, (q31_t)0xcc64673, (q31_t)0x7eb8cf5d, (q31_t)0xcb9f5f3, - (q31_t)0x7ebb4ddb, (q31_t)0xcada4f5, (q31_t)0x7ebdc9ed, (q31_t)0xca1537a, - (q31_t)0x7ec04394, (q31_t)0xc950182, (q31_t)0x7ec2bad0, (q31_t)0xc88af0e, - (q31_t)0x7ec52fa0, (q31_t)0xc7c5c1e, (q31_t)0x7ec7a205, (q31_t)0xc7008b3, - (q31_t)0x7eca11fe, (q31_t)0xc63b4ce, (q31_t)0x7ecc7f8b, (q31_t)0xc57606e, - (q31_t)0x7eceeaad, (q31_t)0xc4b0b94, (q31_t)0x7ed15363, (q31_t)0xc3eb641, - (q31_t)0x7ed3b9ad, (q31_t)0xc326075, (q31_t)0x7ed61d8a, (q31_t)0xc260a31, - (q31_t)0x7ed87efc, (q31_t)0xc19b374, (q31_t)0x7edade01, (q31_t)0xc0d5c41, - (q31_t)0x7edd3a9a, (q31_t)0xc010496, (q31_t)0x7edf94c7, (q31_t)0xbf4ac75, - (q31_t)0x7ee1ec87, (q31_t)0xbe853de, (q31_t)0x7ee441da, (q31_t)0xbdbfad1, - (q31_t)0x7ee694c1, (q31_t)0xbcfa150, (q31_t)0x7ee8e53a, (q31_t)0xbc34759, - (q31_t)0x7eeb3347, (q31_t)0xbb6ecef, (q31_t)0x7eed7ee7, (q31_t)0xbaa9211, - (q31_t)0x7eefc81a, (q31_t)0xb9e36c0, (q31_t)0x7ef20ee0, (q31_t)0xb91dafc, - (q31_t)0x7ef45338, (q31_t)0xb857ec7, (q31_t)0x7ef69523, (q31_t)0xb79221f, - (q31_t)0x7ef8d4a1, (q31_t)0xb6cc506, (q31_t)0x7efb11b1, (q31_t)0xb60677c, - (q31_t)0x7efd4c54, (q31_t)0xb540982, (q31_t)0x7eff8489, (q31_t)0xb47ab19, - (q31_t)0x7f01ba50, (q31_t)0xb3b4c40, (q31_t)0x7f03eda9, (q31_t)0xb2eecf8, - (q31_t)0x7f061e95, (q31_t)0xb228d42, (q31_t)0x7f084d12, (q31_t)0xb162d1d, - (q31_t)0x7f0a7921, (q31_t)0xb09cc8c, (q31_t)0x7f0ca2c2, (q31_t)0xafd6b8d, - (q31_t)0x7f0ec9f5, (q31_t)0xaf10a22, (q31_t)0x7f10eeb9, (q31_t)0xae4a84b, - (q31_t)0x7f13110f, (q31_t)0xad84609, (q31_t)0x7f1530f7, (q31_t)0xacbe35b, - (q31_t)0x7f174e70, (q31_t)0xabf8043, (q31_t)0x7f19697a, (q31_t)0xab31cc1, - (q31_t)0x7f1b8215, (q31_t)0xaa6b8d5, (q31_t)0x7f1d9842, (q31_t)0xa9a5480, - (q31_t)0x7f1fabff, (q31_t)0xa8defc3, (q31_t)0x7f21bd4e, (q31_t)0xa818a9d, - (q31_t)0x7f23cc2e, (q31_t)0xa752510, (q31_t)0x7f25d89e, (q31_t)0xa68bf1b, - (q31_t)0x7f27e29f, (q31_t)0xa5c58c0, (q31_t)0x7f29ea31, (q31_t)0xa4ff1fe, - (q31_t)0x7f2bef53, (q31_t)0xa438ad7, (q31_t)0x7f2df206, (q31_t)0xa37234a, - (q31_t)0x7f2ff24a, (q31_t)0xa2abb59, (q31_t)0x7f31f01d, (q31_t)0xa1e5303, - (q31_t)0x7f33eb81, (q31_t)0xa11ea49, (q31_t)0x7f35e476, (q31_t)0xa05812c, - (q31_t)0x7f37dafa, (q31_t)0x9f917ac, (q31_t)0x7f39cf0e, (q31_t)0x9ecadc9, - (q31_t)0x7f3bc0b3, (q31_t)0x9e04385, (q31_t)0x7f3dafe7, (q31_t)0x9d3d8df, - (q31_t)0x7f3f9cab, (q31_t)0x9c76dd8, (q31_t)0x7f4186ff, (q31_t)0x9bb0271, - (q31_t)0x7f436ee3, (q31_t)0x9ae96aa, (q31_t)0x7f455456, (q31_t)0x9a22a83, - (q31_t)0x7f473759, (q31_t)0x995bdfd, (q31_t)0x7f4917eb, (q31_t)0x9895118, - (q31_t)0x7f4af60d, (q31_t)0x97ce3d5, (q31_t)0x7f4cd1be, (q31_t)0x9707635, - (q31_t)0x7f4eaafe, (q31_t)0x9640837, (q31_t)0x7f5081cd, (q31_t)0x95799dd, - (q31_t)0x7f52562c, (q31_t)0x94b2b27, (q31_t)0x7f54281a, (q31_t)0x93ebc14, - (q31_t)0x7f55f796, (q31_t)0x9324ca7, (q31_t)0x7f57c4a2, (q31_t)0x925dcdf, - (q31_t)0x7f598f3c, (q31_t)0x9196cbc, (q31_t)0x7f5b5765, (q31_t)0x90cfc40, - (q31_t)0x7f5d1d1d, (q31_t)0x9008b6a, (q31_t)0x7f5ee063, (q31_t)0x8f41a3c, - (q31_t)0x7f60a138, (q31_t)0x8e7a8b5, (q31_t)0x7f625f9b, (q31_t)0x8db36d6, - (q31_t)0x7f641b8d, (q31_t)0x8cec4a0, (q31_t)0x7f65d50d, (q31_t)0x8c25213, - (q31_t)0x7f678c1c, (q31_t)0x8b5df30, (q31_t)0x7f6940b8, (q31_t)0x8a96bf6, - (q31_t)0x7f6af2e3, (q31_t)0x89cf867, (q31_t)0x7f6ca29c, (q31_t)0x8908483, - (q31_t)0x7f6e4fe3, (q31_t)0x884104b, (q31_t)0x7f6ffab8, (q31_t)0x8779bbe, - (q31_t)0x7f71a31b, (q31_t)0x86b26de, (q31_t)0x7f73490b, (q31_t)0x85eb1ab, - (q31_t)0x7f74ec8a, (q31_t)0x8523c25, (q31_t)0x7f768d96, (q31_t)0x845c64d, - (q31_t)0x7f782c30, (q31_t)0x8395024, (q31_t)0x7f79c857, (q31_t)0x82cd9a9, - (q31_t)0x7f7b620c, (q31_t)0x82062de, (q31_t)0x7f7cf94e, (q31_t)0x813ebc2, - (q31_t)0x7f7e8e1e, (q31_t)0x8077457, (q31_t)0x7f80207b, (q31_t)0x7fafc9c, - (q31_t)0x7f81b065, (q31_t)0x7ee8493, (q31_t)0x7f833ddd, (q31_t)0x7e20c3b, - (q31_t)0x7f84c8e2, (q31_t)0x7d59396, (q31_t)0x7f865174, (q31_t)0x7c91aa3, - (q31_t)0x7f87d792, (q31_t)0x7bca163, (q31_t)0x7f895b3e, (q31_t)0x7b027d7, - (q31_t)0x7f8adc77, (q31_t)0x7a3adff, (q31_t)0x7f8c5b3d, (q31_t)0x79733dc, - (q31_t)0x7f8dd78f, (q31_t)0x78ab96e, (q31_t)0x7f8f516e, (q31_t)0x77e3eb5, - (q31_t)0x7f90c8da, (q31_t)0x771c3b3, (q31_t)0x7f923dd2, (q31_t)0x7654867, - (q31_t)0x7f93b058, (q31_t)0x758ccd2, (q31_t)0x7f952069, (q31_t)0x74c50f4, - (q31_t)0x7f968e07, (q31_t)0x73fd4cf, (q31_t)0x7f97f932, (q31_t)0x7335862, - (q31_t)0x7f9961e8, (q31_t)0x726dbae, (q31_t)0x7f9ac82c, (q31_t)0x71a5eb3, - (q31_t)0x7f9c2bfb, (q31_t)0x70de172, (q31_t)0x7f9d8d56, (q31_t)0x70163eb, - (q31_t)0x7f9eec3e, (q31_t)0x6f4e620, (q31_t)0x7fa048b2, (q31_t)0x6e86810, - (q31_t)0x7fa1a2b2, (q31_t)0x6dbe9bb, (q31_t)0x7fa2fa3d, (q31_t)0x6cf6b23, - (q31_t)0x7fa44f55, (q31_t)0x6c2ec48, (q31_t)0x7fa5a1f9, (q31_t)0x6b66d29, - (q31_t)0x7fa6f228, (q31_t)0x6a9edc9, (q31_t)0x7fa83fe3, (q31_t)0x69d6e27, - (q31_t)0x7fa98b2a, (q31_t)0x690ee44, (q31_t)0x7faad3fd, (q31_t)0x6846e1f, - (q31_t)0x7fac1a5b, (q31_t)0x677edbb, (q31_t)0x7fad5e45, (q31_t)0x66b6d16, - (q31_t)0x7fae9fbb, (q31_t)0x65eec33, (q31_t)0x7fafdebb, (q31_t)0x6526b10, - (q31_t)0x7fb11b48, (q31_t)0x645e9af, (q31_t)0x7fb2555f, (q31_t)0x6396810, - (q31_t)0x7fb38d02, (q31_t)0x62ce634, (q31_t)0x7fb4c231, (q31_t)0x620641a, - (q31_t)0x7fb5f4ea, (q31_t)0x613e1c5, (q31_t)0x7fb7252f, (q31_t)0x6075f33, - (q31_t)0x7fb852ff, (q31_t)0x5fadc66, (q31_t)0x7fb97e5a, (q31_t)0x5ee595d, - (q31_t)0x7fbaa740, (q31_t)0x5e1d61b, (q31_t)0x7fbbcdb1, (q31_t)0x5d5529e, - (q31_t)0x7fbcf1ad, (q31_t)0x5c8cee7, (q31_t)0x7fbe1334, (q31_t)0x5bc4af8, - (q31_t)0x7fbf3246, (q31_t)0x5afc6d0, (q31_t)0x7fc04ee3, (q31_t)0x5a3426f, - (q31_t)0x7fc1690a, (q31_t)0x596bdd7, (q31_t)0x7fc280bc, (q31_t)0x58a3908, - (q31_t)0x7fc395f9, (q31_t)0x57db403, (q31_t)0x7fc4a8c1, (q31_t)0x5712ec7, - (q31_t)0x7fc5b913, (q31_t)0x564a955, (q31_t)0x7fc6c6f0, (q31_t)0x55823ae, - (q31_t)0x7fc7d258, (q31_t)0x54b9dd3, (q31_t)0x7fc8db4a, (q31_t)0x53f17c3, - (q31_t)0x7fc9e1c6, (q31_t)0x532917f, (q31_t)0x7fcae5cd, (q31_t)0x5260b08, - (q31_t)0x7fcbe75e, (q31_t)0x519845e, (q31_t)0x7fcce67a, (q31_t)0x50cfd82, - (q31_t)0x7fcde320, (q31_t)0x5007674, (q31_t)0x7fcedd50, (q31_t)0x4f3ef35, - (q31_t)0x7fcfd50b, (q31_t)0x4e767c5, (q31_t)0x7fd0ca4f, (q31_t)0x4dae024, - (q31_t)0x7fd1bd1e, (q31_t)0x4ce5854, (q31_t)0x7fd2ad77, (q31_t)0x4c1d054, - (q31_t)0x7fd39b5a, (q31_t)0x4b54825, (q31_t)0x7fd486c7, (q31_t)0x4a8bfc7, - (q31_t)0x7fd56fbe, (q31_t)0x49c373c, (q31_t)0x7fd6563f, (q31_t)0x48fae83, - (q31_t)0x7fd73a4a, (q31_t)0x483259d, (q31_t)0x7fd81bdf, (q31_t)0x4769c8b, - (q31_t)0x7fd8fafe, (q31_t)0x46a134c, (q31_t)0x7fd9d7a7, (q31_t)0x45d89e2, - (q31_t)0x7fdab1d9, (q31_t)0x451004d, (q31_t)0x7fdb8996, (q31_t)0x444768d, - (q31_t)0x7fdc5edc, (q31_t)0x437eca4, (q31_t)0x7fdd31ac, (q31_t)0x42b6290, - (q31_t)0x7fde0205, (q31_t)0x41ed854, (q31_t)0x7fdecfe8, (q31_t)0x4124dee, - (q31_t)0x7fdf9b55, (q31_t)0x405c361, (q31_t)0x7fe0644b, (q31_t)0x3f938ac, - (q31_t)0x7fe12acb, (q31_t)0x3ecadcf, (q31_t)0x7fe1eed5, (q31_t)0x3e022cc, - (q31_t)0x7fe2b067, (q31_t)0x3d397a3, (q31_t)0x7fe36f84, (q31_t)0x3c70c54, - (q31_t)0x7fe42c2a, (q31_t)0x3ba80df, (q31_t)0x7fe4e659, (q31_t)0x3adf546, - (q31_t)0x7fe59e12, (q31_t)0x3a16988, (q31_t)0x7fe65354, (q31_t)0x394dda7, - (q31_t)0x7fe7061f, (q31_t)0x38851a2, (q31_t)0x7fe7b674, (q31_t)0x37bc57b, - (q31_t)0x7fe86452, (q31_t)0x36f3931, (q31_t)0x7fe90fb9, (q31_t)0x362acc5, - (q31_t)0x7fe9b8a9, (q31_t)0x3562038, (q31_t)0x7fea5f23, (q31_t)0x3499389, - (q31_t)0x7feb0326, (q31_t)0x33d06bb, (q31_t)0x7feba4b2, (q31_t)0x33079cc, - (q31_t)0x7fec43c7, (q31_t)0x323ecbe, (q31_t)0x7fece065, (q31_t)0x3175f91, - (q31_t)0x7fed7a8c, (q31_t)0x30ad245, (q31_t)0x7fee123d, (q31_t)0x2fe44dc, - (q31_t)0x7feea776, (q31_t)0x2f1b755, (q31_t)0x7fef3a39, (q31_t)0x2e529b0, - (q31_t)0x7fefca84, (q31_t)0x2d89bf0, (q31_t)0x7ff05858, (q31_t)0x2cc0e13, - (q31_t)0x7ff0e3b6, (q31_t)0x2bf801a, (q31_t)0x7ff16c9c, (q31_t)0x2b2f207, - (q31_t)0x7ff1f30b, (q31_t)0x2a663d8, (q31_t)0x7ff27703, (q31_t)0x299d590, - (q31_t)0x7ff2f884, (q31_t)0x28d472e, (q31_t)0x7ff3778e, (q31_t)0x280b8b3, - (q31_t)0x7ff3f420, (q31_t)0x2742a1f, (q31_t)0x7ff46e3c, (q31_t)0x2679b73, - (q31_t)0x7ff4e5e0, (q31_t)0x25b0caf, (q31_t)0x7ff55b0d, (q31_t)0x24e7dd4, - (q31_t)0x7ff5cdc3, (q31_t)0x241eee2, (q31_t)0x7ff63e01, (q31_t)0x2355fd9, - (q31_t)0x7ff6abc8, (q31_t)0x228d0bb, (q31_t)0x7ff71718, (q31_t)0x21c4188, - (q31_t)0x7ff77ff1, (q31_t)0x20fb240, (q31_t)0x7ff7e652, (q31_t)0x20322e3, - (q31_t)0x7ff84a3c, (q31_t)0x1f69373, (q31_t)0x7ff8abae, (q31_t)0x1ea03ef, - (q31_t)0x7ff90aaa, (q31_t)0x1dd7459, (q31_t)0x7ff9672d, (q31_t)0x1d0e4b0, - (q31_t)0x7ff9c13a, (q31_t)0x1c454f5, (q31_t)0x7ffa18cf, (q31_t)0x1b7c528, - (q31_t)0x7ffa6dec, (q31_t)0x1ab354b, (q31_t)0x7ffac092, (q31_t)0x19ea55d, - (q31_t)0x7ffb10c1, (q31_t)0x192155f, (q31_t)0x7ffb5e78, (q31_t)0x1858552, - (q31_t)0x7ffba9b8, (q31_t)0x178f536, (q31_t)0x7ffbf280, (q31_t)0x16c650b, - (q31_t)0x7ffc38d1, (q31_t)0x15fd4d2, (q31_t)0x7ffc7caa, (q31_t)0x153448c, - (q31_t)0x7ffcbe0c, (q31_t)0x146b438, (q31_t)0x7ffcfcf6, (q31_t)0x13a23d8, - (q31_t)0x7ffd3969, (q31_t)0x12d936c, (q31_t)0x7ffd7364, (q31_t)0x12102f4, - (q31_t)0x7ffdaae7, (q31_t)0x1147271, (q31_t)0x7ffddff3, (q31_t)0x107e1e3, - (q31_t)0x7ffe1288, (q31_t)0xfb514b, (q31_t)0x7ffe42a4, (q31_t)0xeec0aa, - (q31_t)0x7ffe704a, (q31_t)0xe22fff, (q31_t)0x7ffe9b77, (q31_t)0xd59f4c, - (q31_t)0x7ffec42d, (q31_t)0xc90e90, (q31_t)0x7ffeea6c, (q31_t)0xbc7dcc, - (q31_t)0x7fff0e32, (q31_t)0xafed02, (q31_t)0x7fff2f82, (q31_t)0xa35c30, - (q31_t)0x7fff4e59, (q31_t)0x96cb58, (q31_t)0x7fff6ab9, (q31_t)0x8a3a7b, - (q31_t)0x7fff84a1, (q31_t)0x7da998, (q31_t)0x7fff9c12, (q31_t)0x7118b0, - (q31_t)0x7fffb10b, (q31_t)0x6487c4, (q31_t)0x7fffc38c, (q31_t)0x57f6d4, - (q31_t)0x7fffd396, (q31_t)0x4b65e1, (q31_t)0x7fffe128, (q31_t)0x3ed4ea, - (q31_t)0x7fffec43, (q31_t)0x3243f1, (q31_t)0x7ffff4e6, (q31_t)0x25b2f7, - (q31_t)0x7ffffb11, (q31_t)0x1921fb, (q31_t)0x7ffffec4, (q31_t)0xc90fe, - (q31_t)0x7fffffff, (q31_t)0x0, (q31_t)0x7ffffec4, (q31_t)0xfff36f02, + (q31_t)0x7dfc4418, (q31_t)0xfee6e0d, (q31_t)0x7dff63b2, (q31_t)0xfe24205, + (q31_t)0x7e0280e9, (q31_t)0xfd6155f, (q31_t)0x7e059bbb, (q31_t)0xfc9e81e, + (q31_t)0x7e08b42a, (q31_t)0xfbdba40, (q31_t)0x7e0bca34, (q31_t)0xfb18bc8, + (q31_t)0x7e0eddd9, (q31_t)0xfa55cb4, (q31_t)0x7e11ef1b, (q31_t)0xf992d06, + (q31_t)0x7e14fdf7, (q31_t)0xf8cfcbe, (q31_t)0x7e180a6f, (q31_t)0xf80cbdc, + (q31_t)0x7e1b1482, (q31_t)0xf749a61, (q31_t)0x7e1e1c30, (q31_t)0xf68684e, + (q31_t)0x7e212179, (q31_t)0xf5c35a3, (q31_t)0x7e24245d, (q31_t)0xf500260, + (q31_t)0x7e2724db, (q31_t)0xf43ce86, (q31_t)0x7e2a22f4, (q31_t)0xf379a16, + (q31_t)0x7e2d1ea8, (q31_t)0xf2b650f, (q31_t)0x7e3017f6, (q31_t)0xf1f2f73, + (q31_t)0x7e330ede, (q31_t)0xf12f941, (q31_t)0x7e360360, (q31_t)0xf06c27a, + (q31_t)0x7e38f57c, (q31_t)0xefa8b20, (q31_t)0x7e3be532, (q31_t)0xeee5331, + (q31_t)0x7e3ed282, (q31_t)0xee21aaf, (q31_t)0x7e41bd6c, (q31_t)0xed5e19a, + (q31_t)0x7e44a5ef, (q31_t)0xec9a7f3, (q31_t)0x7e478c0b, (q31_t)0xebd6db9, + (q31_t)0x7e4a6fc1, (q31_t)0xeb132ef, (q31_t)0x7e4d5110, (q31_t)0xea4f793, + (q31_t)0x7e502ff9, (q31_t)0xe98bba7, (q31_t)0x7e530c7a, (q31_t)0xe8c7f2a, + (q31_t)0x7e55e694, (q31_t)0xe80421e, (q31_t)0x7e58be47, (q31_t)0xe740483, + (q31_t)0x7e5b9392, (q31_t)0xe67c65a, (q31_t)0x7e5e6676, (q31_t)0xe5b87a2, + (q31_t)0x7e6136f3, (q31_t)0xe4f485c, (q31_t)0x7e640507, (q31_t)0xe430889, + (q31_t)0x7e66d0b4, (q31_t)0xe36c82a, (q31_t)0x7e6999fa, (q31_t)0xe2a873e, + (q31_t)0x7e6c60d7, (q31_t)0xe1e45c6, (q31_t)0x7e6f254c, (q31_t)0xe1203c3, + (q31_t)0x7e71e759, (q31_t)0xe05c135, (q31_t)0x7e74a6fd, (q31_t)0xdf97e1d, + (q31_t)0x7e77643a, (q31_t)0xded3a7b, (q31_t)0x7e7a1f0d, (q31_t)0xde0f64f, + (q31_t)0x7e7cd778, (q31_t)0xdd4b19a, (q31_t)0x7e7f8d7b, (q31_t)0xdc86c5d, + (q31_t)0x7e824114, (q31_t)0xdbc2698, (q31_t)0x7e84f245, (q31_t)0xdafe04b, + (q31_t)0x7e87a10c, (q31_t)0xda39978, (q31_t)0x7e8a4d6a, (q31_t)0xd97521d, + (q31_t)0x7e8cf75f, (q31_t)0xd8b0a3d, (q31_t)0x7e8f9eeb, (q31_t)0xd7ec1d6, + (q31_t)0x7e92440d, (q31_t)0xd7278eb, (q31_t)0x7e94e6c6, (q31_t)0xd662f7b, + (q31_t)0x7e978715, (q31_t)0xd59e586, (q31_t)0x7e9a24fb, (q31_t)0xd4d9b0e, + (q31_t)0x7e9cc076, (q31_t)0xd415013, (q31_t)0x7e9f5988, (q31_t)0xd350495, + (q31_t)0x7ea1f02f, (q31_t)0xd28b894, (q31_t)0x7ea4846c, (q31_t)0xd1c6c11, + (q31_t)0x7ea7163f, (q31_t)0xd101f0e, (q31_t)0x7ea9a5a8, (q31_t)0xd03d189, + (q31_t)0x7eac32a6, (q31_t)0xcf78383, (q31_t)0x7eaebd3a, (q31_t)0xceb34fe, + (q31_t)0x7eb14563, (q31_t)0xcdee5f9, (q31_t)0x7eb3cb21, (q31_t)0xcd29676, + (q31_t)0x7eb64e75, (q31_t)0xcc64673, (q31_t)0x7eb8cf5d, (q31_t)0xcb9f5f3, + (q31_t)0x7ebb4ddb, (q31_t)0xcada4f5, (q31_t)0x7ebdc9ed, (q31_t)0xca1537a, + (q31_t)0x7ec04394, (q31_t)0xc950182, (q31_t)0x7ec2bad0, (q31_t)0xc88af0e, + (q31_t)0x7ec52fa0, (q31_t)0xc7c5c1e, (q31_t)0x7ec7a205, (q31_t)0xc7008b3, + (q31_t)0x7eca11fe, (q31_t)0xc63b4ce, (q31_t)0x7ecc7f8b, (q31_t)0xc57606e, + (q31_t)0x7eceeaad, (q31_t)0xc4b0b94, (q31_t)0x7ed15363, (q31_t)0xc3eb641, + (q31_t)0x7ed3b9ad, (q31_t)0xc326075, (q31_t)0x7ed61d8a, (q31_t)0xc260a31, + (q31_t)0x7ed87efc, (q31_t)0xc19b374, (q31_t)0x7edade01, (q31_t)0xc0d5c41, + (q31_t)0x7edd3a9a, (q31_t)0xc010496, (q31_t)0x7edf94c7, (q31_t)0xbf4ac75, + (q31_t)0x7ee1ec87, (q31_t)0xbe853de, (q31_t)0x7ee441da, (q31_t)0xbdbfad1, + (q31_t)0x7ee694c1, (q31_t)0xbcfa150, (q31_t)0x7ee8e53a, (q31_t)0xbc34759, + (q31_t)0x7eeb3347, (q31_t)0xbb6ecef, (q31_t)0x7eed7ee7, (q31_t)0xbaa9211, + (q31_t)0x7eefc81a, (q31_t)0xb9e36c0, (q31_t)0x7ef20ee0, (q31_t)0xb91dafc, + (q31_t)0x7ef45338, (q31_t)0xb857ec7, (q31_t)0x7ef69523, (q31_t)0xb79221f, + (q31_t)0x7ef8d4a1, (q31_t)0xb6cc506, (q31_t)0x7efb11b1, (q31_t)0xb60677c, + (q31_t)0x7efd4c54, (q31_t)0xb540982, (q31_t)0x7eff8489, (q31_t)0xb47ab19, + (q31_t)0x7f01ba50, (q31_t)0xb3b4c40, (q31_t)0x7f03eda9, (q31_t)0xb2eecf8, + (q31_t)0x7f061e95, (q31_t)0xb228d42, (q31_t)0x7f084d12, (q31_t)0xb162d1d, + (q31_t)0x7f0a7921, (q31_t)0xb09cc8c, (q31_t)0x7f0ca2c2, (q31_t)0xafd6b8d, + (q31_t)0x7f0ec9f5, (q31_t)0xaf10a22, (q31_t)0x7f10eeb9, (q31_t)0xae4a84b, + (q31_t)0x7f13110f, (q31_t)0xad84609, (q31_t)0x7f1530f7, (q31_t)0xacbe35b, + (q31_t)0x7f174e70, (q31_t)0xabf8043, (q31_t)0x7f19697a, (q31_t)0xab31cc1, + (q31_t)0x7f1b8215, (q31_t)0xaa6b8d5, (q31_t)0x7f1d9842, (q31_t)0xa9a5480, + (q31_t)0x7f1fabff, (q31_t)0xa8defc3, (q31_t)0x7f21bd4e, (q31_t)0xa818a9d, + (q31_t)0x7f23cc2e, (q31_t)0xa752510, (q31_t)0x7f25d89e, (q31_t)0xa68bf1b, + (q31_t)0x7f27e29f, (q31_t)0xa5c58c0, (q31_t)0x7f29ea31, (q31_t)0xa4ff1fe, + (q31_t)0x7f2bef53, (q31_t)0xa438ad7, (q31_t)0x7f2df206, (q31_t)0xa37234a, + (q31_t)0x7f2ff24a, (q31_t)0xa2abb59, (q31_t)0x7f31f01d, (q31_t)0xa1e5303, + (q31_t)0x7f33eb81, (q31_t)0xa11ea49, (q31_t)0x7f35e476, (q31_t)0xa05812c, + (q31_t)0x7f37dafa, (q31_t)0x9f917ac, (q31_t)0x7f39cf0e, (q31_t)0x9ecadc9, + (q31_t)0x7f3bc0b3, (q31_t)0x9e04385, (q31_t)0x7f3dafe7, (q31_t)0x9d3d8df, + (q31_t)0x7f3f9cab, (q31_t)0x9c76dd8, (q31_t)0x7f4186ff, (q31_t)0x9bb0271, + (q31_t)0x7f436ee3, (q31_t)0x9ae96aa, (q31_t)0x7f455456, (q31_t)0x9a22a83, + (q31_t)0x7f473759, (q31_t)0x995bdfd, (q31_t)0x7f4917eb, (q31_t)0x9895118, + (q31_t)0x7f4af60d, (q31_t)0x97ce3d5, (q31_t)0x7f4cd1be, (q31_t)0x9707635, + (q31_t)0x7f4eaafe, (q31_t)0x9640837, (q31_t)0x7f5081cd, (q31_t)0x95799dd, + (q31_t)0x7f52562c, (q31_t)0x94b2b27, (q31_t)0x7f54281a, (q31_t)0x93ebc14, + (q31_t)0x7f55f796, (q31_t)0x9324ca7, (q31_t)0x7f57c4a2, (q31_t)0x925dcdf, + (q31_t)0x7f598f3c, (q31_t)0x9196cbc, (q31_t)0x7f5b5765, (q31_t)0x90cfc40, + (q31_t)0x7f5d1d1d, (q31_t)0x9008b6a, (q31_t)0x7f5ee063, (q31_t)0x8f41a3c, + (q31_t)0x7f60a138, (q31_t)0x8e7a8b5, (q31_t)0x7f625f9b, (q31_t)0x8db36d6, + (q31_t)0x7f641b8d, (q31_t)0x8cec4a0, (q31_t)0x7f65d50d, (q31_t)0x8c25213, + (q31_t)0x7f678c1c, (q31_t)0x8b5df30, (q31_t)0x7f6940b8, (q31_t)0x8a96bf6, + (q31_t)0x7f6af2e3, (q31_t)0x89cf867, (q31_t)0x7f6ca29c, (q31_t)0x8908483, + (q31_t)0x7f6e4fe3, (q31_t)0x884104b, (q31_t)0x7f6ffab8, (q31_t)0x8779bbe, + (q31_t)0x7f71a31b, (q31_t)0x86b26de, (q31_t)0x7f73490b, (q31_t)0x85eb1ab, + (q31_t)0x7f74ec8a, (q31_t)0x8523c25, (q31_t)0x7f768d96, (q31_t)0x845c64d, + (q31_t)0x7f782c30, (q31_t)0x8395024, (q31_t)0x7f79c857, (q31_t)0x82cd9a9, + (q31_t)0x7f7b620c, (q31_t)0x82062de, (q31_t)0x7f7cf94e, (q31_t)0x813ebc2, + (q31_t)0x7f7e8e1e, (q31_t)0x8077457, (q31_t)0x7f80207b, (q31_t)0x7fafc9c, + (q31_t)0x7f81b065, (q31_t)0x7ee8493, (q31_t)0x7f833ddd, (q31_t)0x7e20c3b, + (q31_t)0x7f84c8e2, (q31_t)0x7d59396, (q31_t)0x7f865174, (q31_t)0x7c91aa3, + (q31_t)0x7f87d792, (q31_t)0x7bca163, (q31_t)0x7f895b3e, (q31_t)0x7b027d7, + (q31_t)0x7f8adc77, (q31_t)0x7a3adff, (q31_t)0x7f8c5b3d, (q31_t)0x79733dc, + (q31_t)0x7f8dd78f, (q31_t)0x78ab96e, (q31_t)0x7f8f516e, (q31_t)0x77e3eb5, + (q31_t)0x7f90c8da, (q31_t)0x771c3b3, (q31_t)0x7f923dd2, (q31_t)0x7654867, + (q31_t)0x7f93b058, (q31_t)0x758ccd2, (q31_t)0x7f952069, (q31_t)0x74c50f4, + (q31_t)0x7f968e07, (q31_t)0x73fd4cf, (q31_t)0x7f97f932, (q31_t)0x7335862, + (q31_t)0x7f9961e8, (q31_t)0x726dbae, (q31_t)0x7f9ac82c, (q31_t)0x71a5eb3, + (q31_t)0x7f9c2bfb, (q31_t)0x70de172, (q31_t)0x7f9d8d56, (q31_t)0x70163eb, + (q31_t)0x7f9eec3e, (q31_t)0x6f4e620, (q31_t)0x7fa048b2, (q31_t)0x6e86810, + (q31_t)0x7fa1a2b2, (q31_t)0x6dbe9bb, (q31_t)0x7fa2fa3d, (q31_t)0x6cf6b23, + (q31_t)0x7fa44f55, (q31_t)0x6c2ec48, (q31_t)0x7fa5a1f9, (q31_t)0x6b66d29, + (q31_t)0x7fa6f228, (q31_t)0x6a9edc9, (q31_t)0x7fa83fe3, (q31_t)0x69d6e27, + (q31_t)0x7fa98b2a, (q31_t)0x690ee44, (q31_t)0x7faad3fd, (q31_t)0x6846e1f, + (q31_t)0x7fac1a5b, (q31_t)0x677edbb, (q31_t)0x7fad5e45, (q31_t)0x66b6d16, + (q31_t)0x7fae9fbb, (q31_t)0x65eec33, (q31_t)0x7fafdebb, (q31_t)0x6526b10, + (q31_t)0x7fb11b48, (q31_t)0x645e9af, (q31_t)0x7fb2555f, (q31_t)0x6396810, + (q31_t)0x7fb38d02, (q31_t)0x62ce634, (q31_t)0x7fb4c231, (q31_t)0x620641a, + (q31_t)0x7fb5f4ea, (q31_t)0x613e1c5, (q31_t)0x7fb7252f, (q31_t)0x6075f33, + (q31_t)0x7fb852ff, (q31_t)0x5fadc66, (q31_t)0x7fb97e5a, (q31_t)0x5ee595d, + (q31_t)0x7fbaa740, (q31_t)0x5e1d61b, (q31_t)0x7fbbcdb1, (q31_t)0x5d5529e, + (q31_t)0x7fbcf1ad, (q31_t)0x5c8cee7, (q31_t)0x7fbe1334, (q31_t)0x5bc4af8, + (q31_t)0x7fbf3246, (q31_t)0x5afc6d0, (q31_t)0x7fc04ee3, (q31_t)0x5a3426f, + (q31_t)0x7fc1690a, (q31_t)0x596bdd7, (q31_t)0x7fc280bc, (q31_t)0x58a3908, + (q31_t)0x7fc395f9, (q31_t)0x57db403, (q31_t)0x7fc4a8c1, (q31_t)0x5712ec7, + (q31_t)0x7fc5b913, (q31_t)0x564a955, (q31_t)0x7fc6c6f0, (q31_t)0x55823ae, + (q31_t)0x7fc7d258, (q31_t)0x54b9dd3, (q31_t)0x7fc8db4a, (q31_t)0x53f17c3, + (q31_t)0x7fc9e1c6, (q31_t)0x532917f, (q31_t)0x7fcae5cd, (q31_t)0x5260b08, + (q31_t)0x7fcbe75e, (q31_t)0x519845e, (q31_t)0x7fcce67a, (q31_t)0x50cfd82, + (q31_t)0x7fcde320, (q31_t)0x5007674, (q31_t)0x7fcedd50, (q31_t)0x4f3ef35, + (q31_t)0x7fcfd50b, (q31_t)0x4e767c5, (q31_t)0x7fd0ca4f, (q31_t)0x4dae024, + (q31_t)0x7fd1bd1e, (q31_t)0x4ce5854, (q31_t)0x7fd2ad77, (q31_t)0x4c1d054, + (q31_t)0x7fd39b5a, (q31_t)0x4b54825, (q31_t)0x7fd486c7, (q31_t)0x4a8bfc7, + (q31_t)0x7fd56fbe, (q31_t)0x49c373c, (q31_t)0x7fd6563f, (q31_t)0x48fae83, + (q31_t)0x7fd73a4a, (q31_t)0x483259d, (q31_t)0x7fd81bdf, (q31_t)0x4769c8b, + (q31_t)0x7fd8fafe, (q31_t)0x46a134c, (q31_t)0x7fd9d7a7, (q31_t)0x45d89e2, + (q31_t)0x7fdab1d9, (q31_t)0x451004d, (q31_t)0x7fdb8996, (q31_t)0x444768d, + (q31_t)0x7fdc5edc, (q31_t)0x437eca4, (q31_t)0x7fdd31ac, (q31_t)0x42b6290, + (q31_t)0x7fde0205, (q31_t)0x41ed854, (q31_t)0x7fdecfe8, (q31_t)0x4124dee, + (q31_t)0x7fdf9b55, (q31_t)0x405c361, (q31_t)0x7fe0644b, (q31_t)0x3f938ac, + (q31_t)0x7fe12acb, (q31_t)0x3ecadcf, (q31_t)0x7fe1eed5, (q31_t)0x3e022cc, + (q31_t)0x7fe2b067, (q31_t)0x3d397a3, (q31_t)0x7fe36f84, (q31_t)0x3c70c54, + (q31_t)0x7fe42c2a, (q31_t)0x3ba80df, (q31_t)0x7fe4e659, (q31_t)0x3adf546, + (q31_t)0x7fe59e12, (q31_t)0x3a16988, (q31_t)0x7fe65354, (q31_t)0x394dda7, + (q31_t)0x7fe7061f, (q31_t)0x38851a2, (q31_t)0x7fe7b674, (q31_t)0x37bc57b, + (q31_t)0x7fe86452, (q31_t)0x36f3931, (q31_t)0x7fe90fb9, (q31_t)0x362acc5, + (q31_t)0x7fe9b8a9, (q31_t)0x3562038, (q31_t)0x7fea5f23, (q31_t)0x3499389, + (q31_t)0x7feb0326, (q31_t)0x33d06bb, (q31_t)0x7feba4b2, (q31_t)0x33079cc, + (q31_t)0x7fec43c7, (q31_t)0x323ecbe, (q31_t)0x7fece065, (q31_t)0x3175f91, + (q31_t)0x7fed7a8c, (q31_t)0x30ad245, (q31_t)0x7fee123d, (q31_t)0x2fe44dc, + (q31_t)0x7feea776, (q31_t)0x2f1b755, (q31_t)0x7fef3a39, (q31_t)0x2e529b0, + (q31_t)0x7fefca84, (q31_t)0x2d89bf0, (q31_t)0x7ff05858, (q31_t)0x2cc0e13, + (q31_t)0x7ff0e3b6, (q31_t)0x2bf801a, (q31_t)0x7ff16c9c, (q31_t)0x2b2f207, + (q31_t)0x7ff1f30b, (q31_t)0x2a663d8, (q31_t)0x7ff27703, (q31_t)0x299d590, + (q31_t)0x7ff2f884, (q31_t)0x28d472e, (q31_t)0x7ff3778e, (q31_t)0x280b8b3, + (q31_t)0x7ff3f420, (q31_t)0x2742a1f, (q31_t)0x7ff46e3c, (q31_t)0x2679b73, + (q31_t)0x7ff4e5e0, (q31_t)0x25b0caf, (q31_t)0x7ff55b0d, (q31_t)0x24e7dd4, + (q31_t)0x7ff5cdc3, (q31_t)0x241eee2, (q31_t)0x7ff63e01, (q31_t)0x2355fd9, + (q31_t)0x7ff6abc8, (q31_t)0x228d0bb, (q31_t)0x7ff71718, (q31_t)0x21c4188, + (q31_t)0x7ff77ff1, (q31_t)0x20fb240, (q31_t)0x7ff7e652, (q31_t)0x20322e3, + (q31_t)0x7ff84a3c, (q31_t)0x1f69373, (q31_t)0x7ff8abae, (q31_t)0x1ea03ef, + (q31_t)0x7ff90aaa, (q31_t)0x1dd7459, (q31_t)0x7ff9672d, (q31_t)0x1d0e4b0, + (q31_t)0x7ff9c13a, (q31_t)0x1c454f5, (q31_t)0x7ffa18cf, (q31_t)0x1b7c528, + (q31_t)0x7ffa6dec, (q31_t)0x1ab354b, (q31_t)0x7ffac092, (q31_t)0x19ea55d, + (q31_t)0x7ffb10c1, (q31_t)0x192155f, (q31_t)0x7ffb5e78, (q31_t)0x1858552, + (q31_t)0x7ffba9b8, (q31_t)0x178f536, (q31_t)0x7ffbf280, (q31_t)0x16c650b, + (q31_t)0x7ffc38d1, (q31_t)0x15fd4d2, (q31_t)0x7ffc7caa, (q31_t)0x153448c, + (q31_t)0x7ffcbe0c, (q31_t)0x146b438, (q31_t)0x7ffcfcf6, (q31_t)0x13a23d8, + (q31_t)0x7ffd3969, (q31_t)0x12d936c, (q31_t)0x7ffd7364, (q31_t)0x12102f4, + (q31_t)0x7ffdaae7, (q31_t)0x1147271, (q31_t)0x7ffddff3, (q31_t)0x107e1e3, + (q31_t)0x7ffe1288, (q31_t)0xfb514b, (q31_t)0x7ffe42a4, (q31_t)0xeec0aa, + (q31_t)0x7ffe704a, (q31_t)0xe22fff, (q31_t)0x7ffe9b77, (q31_t)0xd59f4c, + (q31_t)0x7ffec42d, (q31_t)0xc90e90, (q31_t)0x7ffeea6c, (q31_t)0xbc7dcc, + (q31_t)0x7fff0e32, (q31_t)0xafed02, (q31_t)0x7fff2f82, (q31_t)0xa35c30, + (q31_t)0x7fff4e59, (q31_t)0x96cb58, (q31_t)0x7fff6ab9, (q31_t)0x8a3a7b, + (q31_t)0x7fff84a1, (q31_t)0x7da998, (q31_t)0x7fff9c12, (q31_t)0x7118b0, + (q31_t)0x7fffb10b, (q31_t)0x6487c4, (q31_t)0x7fffc38c, (q31_t)0x57f6d4, + (q31_t)0x7fffd396, (q31_t)0x4b65e1, (q31_t)0x7fffe128, (q31_t)0x3ed4ea, + (q31_t)0x7fffec43, (q31_t)0x3243f1, (q31_t)0x7ffff4e6, (q31_t)0x25b2f7, + (q31_t)0x7ffffb11, (q31_t)0x1921fb, (q31_t)0x7ffffec4, (q31_t)0xc90fe, + (q31_t)0x7fffffff, (q31_t)0x0, (q31_t)0x7ffffec4, (q31_t)0xfff36f02, (q31_t)0x7ffffb11, (q31_t)0xffe6de05, (q31_t)0x7ffff4e6, (q31_t)0xffda4d09, (q31_t)0x7fffec43, (q31_t)0xffcdbc0f, (q31_t)0x7fffe128, (q31_t)0xffc12b16, (q31_t)0x7fffd396, (q31_t)0xffb49a1f, (q31_t)0x7fffc38c, (q31_t)0xffa8092c, @@ -4182,102 +4182,103 @@ const q31_t realCoefBQ31[8192] = { /** @brief Initialization function for the Q31 RFFT/RIFFT. - @param[in,out] S points to an instance of the Q31 RFFT/RIFFT structure + @param[in,out] S points to an instance of the Q31 RFFT/RIFFT + structure @param[in] fftLenReal length of the FFT @param[in] ifftFlagR flag that selects transform direction - value = 0: forward transform - value = 1: inverse transform - @param[in] bitReverseFlag flag that enables / disables bit reversal of output + @param[in] bitReverseFlag flag that enables / disables bit reversal of + output - value = 0: disables bit reversal of output - value = 1: enables bit reversal of output @return execution status - \ref ARM_MATH_SUCCESS : Operation successful - - \ref ARM_MATH_ARGUMENT_ERROR : fftLenReal is not a supported length + - \ref ARM_MATH_ARGUMENT_ERROR : fftLenReal is + not a supported length @par Details - The parameter fftLenReal specifies length of RFFT/RIFFT Process. - Supported FFT Lengths are 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192. + The parameter fftLenReal specifies length of + RFFT/RIFFT Process. Supported FFT Lengths are 32, 64, 128, 256, 512, 1024, + 2048, 4096, 8192. @par - The parameter ifftFlagR controls whether a forward or inverse transform is computed. - Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT is calculated. + The parameter ifftFlagR controls whether a + forward or inverse transform is computed. Set(=1) ifftFlagR to calculate + RIFFT, otherwise RFFT is calculated. @par - The parameter bitReverseFlag controls whether output is in normal order or bit reversed order. - Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order. + The parameter bitReverseFlag controls whether + output is in normal order or bit reversed order. Set(=1) bitReverseFlag for + output to be in normal order otherwise output is in bit reversed order. @par This function also initializes Twiddle factor table. */ -arm_status arm_rfft_init_q31( - arm_rfft_instance_q31 * S, - uint32_t fftLenReal, - uint32_t ifftFlagR, - uint32_t bitReverseFlag) -{ - /* Initialise the default arm status */ - arm_status status = ARM_MATH_SUCCESS; +arm_status arm_rfft_init_q31(arm_rfft_instance_q31 *S, uint32_t fftLenReal, + uint32_t ifftFlagR, uint32_t bitReverseFlag) { + /* Initialise the default arm status */ + arm_status status = ARM_MATH_SUCCESS; - /* Initialize the Real FFT length */ - S->fftLenReal = (uint16_t) fftLenReal; + /* Initialize the Real FFT length */ + S->fftLenReal = (uint16_t)fftLenReal; - /* Initialize the Twiddle coefficientA pointer */ - S->pTwiddleAReal = (q31_t *) realCoefAQ31; + /* Initialize the Twiddle coefficientA pointer */ + S->pTwiddleAReal = (q31_t *)realCoefAQ31; - /* Initialize the Twiddle coefficientB pointer */ - S->pTwiddleBReal = (q31_t *) realCoefBQ31; + /* Initialize the Twiddle coefficientB pointer */ + S->pTwiddleBReal = (q31_t *)realCoefBQ31; - /* Initialize the Flag for selection of RFFT or RIFFT */ - S->ifftFlagR = (uint8_t) ifftFlagR; + /* Initialize the Flag for selection of RFFT or RIFFT */ + S->ifftFlagR = (uint8_t)ifftFlagR; - /* Initialize the Flag for calculation Bit reversal or not */ - S->bitReverseFlagR = (uint8_t) bitReverseFlag; + /* Initialize the Flag for calculation Bit reversal or not */ + S->bitReverseFlagR = (uint8_t)bitReverseFlag; - /* Initialization of coef modifier depending on the FFT length */ - switch (S->fftLenReal) - { - case 8192U: - S->twidCoefRModifier = 1U; - S->pCfft = &arm_cfft_sR_q31_len4096; - break; - case 4096U: - S->twidCoefRModifier = 2U; - S->pCfft = &arm_cfft_sR_q31_len2048; - break; - case 2048U: - S->twidCoefRModifier = 4U; - S->pCfft = &arm_cfft_sR_q31_len1024; - break; - case 1024U: - S->twidCoefRModifier = 8U; - S->pCfft = &arm_cfft_sR_q31_len512; - break; - case 512U: - S->twidCoefRModifier = 16U; - S->pCfft = &arm_cfft_sR_q31_len256; - break; - case 256U: - S->twidCoefRModifier = 32U; - S->pCfft = &arm_cfft_sR_q31_len128; - break; - case 128U: - S->twidCoefRModifier = 64U; - S->pCfft = &arm_cfft_sR_q31_len64; - break; - case 64U: - S->twidCoefRModifier = 128U; - S->pCfft = &arm_cfft_sR_q31_len32; - break; - case 32U: - S->twidCoefRModifier = 256U; - S->pCfft = &arm_cfft_sR_q31_len16; - break; - default: - /* Reporting argument error if rfftSize is not valid value */ - status = ARM_MATH_ARGUMENT_ERROR; - break; - } + /* Initialization of coef modifier depending on the FFT length */ + switch (S->fftLenReal) { + case 8192U: + S->twidCoefRModifier = 1U; + S->pCfft = &arm_cfft_sR_q31_len4096; + break; + case 4096U: + S->twidCoefRModifier = 2U; + S->pCfft = &arm_cfft_sR_q31_len2048; + break; + case 2048U: + S->twidCoefRModifier = 4U; + S->pCfft = &arm_cfft_sR_q31_len1024; + break; + case 1024U: + S->twidCoefRModifier = 8U; + S->pCfft = &arm_cfft_sR_q31_len512; + break; + case 512U: + S->twidCoefRModifier = 16U; + S->pCfft = &arm_cfft_sR_q31_len256; + break; + case 256U: + S->twidCoefRModifier = 32U; + S->pCfft = &arm_cfft_sR_q31_len128; + break; + case 128U: + S->twidCoefRModifier = 64U; + S->pCfft = &arm_cfft_sR_q31_len64; + break; + case 64U: + S->twidCoefRModifier = 128U; + S->pCfft = &arm_cfft_sR_q31_len32; + break; + case 32U: + S->twidCoefRModifier = 256U; + S->pCfft = &arm_cfft_sR_q31_len16; + break; + default: + /* Reporting argument error if rfftSize is not valid value */ + status = ARM_MATH_ARGUMENT_ERROR; + break; + } - /* return the status of RFFT Init function */ - return (status); + /* return the status of RFFT Init function */ + return (status); } /** diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_q15.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_q15.c index fdc9bab..67c5ae8 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_q15.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_q15.c @@ -32,21 +32,11 @@ * Internal functions prototypes * -------------------------------------------------------------------- */ -void arm_split_rfft_q15( - q15_t * pSrc, - uint32_t fftLen, - const q15_t * pATable, - const q15_t * pBTable, - q15_t * pDst, - uint32_t modifier); +void arm_split_rfft_q15(q15_t *pSrc, uint32_t fftLen, const q15_t *pATable, + const q15_t *pBTable, q15_t *pDst, uint32_t modifier); -void arm_split_rifft_q15( - q15_t * pSrc, - uint32_t fftLen, - const q15_t * pATable, - const q15_t * pBTable, - q15_t * pDst, - uint32_t modifier); +void arm_split_rifft_q15(q15_t *pSrc, uint32_t fftLen, const q15_t *pATable, + const q15_t *pBTable, q15_t *pDst, uint32_t modifier); /** @addtogroup RealFFT @@ -61,49 +51,46 @@ void arm_split_rifft_q15( @return none @par Input an output formats - Internally input is downscaled by 2 for every stage to avoid saturations inside CFFT/CIFFT process. - Hence the output format is different for different RFFT sizes. - The input and output formats for different RFFT sizes and number of bits to upscale are mentioned in the tables below for RFFT and RIFFT: + Internally input is downscaled by 2 for every stage to avoid + saturations inside CFFT/CIFFT process. Hence the output format is different + for different RFFT sizes. The input and output formats for different RFFT + sizes and number of bits to upscale are mentioned in the tables below for RFFT + and RIFFT: @par - \image html RFFTQ15.gif "Input and Output Formats for Q15 RFFT" + \image html RFFTQ15.gif "Input and Output Formats for Q15 + RFFT" @par - \image html RIFFTQ15.gif "Input and Output Formats for Q15 RIFFT" + \image html RIFFTQ15.gif "Input and Output Formats for Q15 + RIFFT" */ -void arm_rfft_q15( - const arm_rfft_instance_q15 * S, - q15_t * pSrc, - q15_t * pDst) -{ +void arm_rfft_q15(const arm_rfft_instance_q15 *S, q15_t *pSrc, q15_t *pDst) { const arm_cfft_instance_q15 *S_CFFT = S->pCfft; - uint32_t L2 = S->fftLenReal >> 1U; - uint32_t i; + uint32_t L2 = S->fftLenReal >> 1U; + uint32_t i; /* Calculation of RIFFT of input */ - if (S->ifftFlagR == 1U) - { - /* Real IFFT core process */ - arm_split_rifft_q15 (pSrc, L2, S->pTwiddleAReal, S->pTwiddleBReal, pDst, S->twidCoefRModifier); + if (S->ifftFlagR == 1U) { + /* Real IFFT core process */ + arm_split_rifft_q15(pSrc, L2, S->pTwiddleAReal, S->pTwiddleBReal, pDst, + S->twidCoefRModifier); - /* Complex IFFT process */ - arm_cfft_q15 (S_CFFT, pDst, S->ifftFlagR, S->bitReverseFlagR); + /* Complex IFFT process */ + arm_cfft_q15(S_CFFT, pDst, S->ifftFlagR, S->bitReverseFlagR); - for(i = 0; i < S->fftLenReal; i++) - { - pDst[i] = pDst[i] << 1U; - } + for (i = 0; i < S->fftLenReal; i++) { + pDst[i] = pDst[i] << 1U; + } + } else { + /* Calculation of RFFT of input */ + + /* Complex FFT process */ + arm_cfft_q15(S_CFFT, pSrc, S->ifftFlagR, S->bitReverseFlagR); + + /* Real FFT core process */ + arm_split_rfft_q15(pSrc, L2, S->pTwiddleAReal, S->pTwiddleBReal, pDst, + S->twidCoefRModifier); } - else - { - /* Calculation of RFFT of input */ - - /* Complex FFT process */ - arm_cfft_q15 (S_CFFT, pSrc, S->ifftFlagR, S->bitReverseFlagR); - - /* Real FFT core process */ - arm_split_rfft_q15 (pSrc, L2, S->pTwiddleAReal, S->pTwiddleBReal, pDst, S->twidCoefRModifier); - } - } /** @@ -117,27 +104,22 @@ void arm_rfft_q15( @param[in] pATable points to twiddle Coef A buffer @param[in] pBTable points to twiddle Coef B buffer @param[out] pDst points to output buffer - @param[in] modifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table + @param[in] modifier twiddle coefficient modifier that supports different + size FFTs with the same twiddle factor table @return none @par The function implements a Real FFT */ -void arm_split_rfft_q15( - q15_t * pSrc, - uint32_t fftLen, - const q15_t * pATable, - const q15_t * pBTable, - q15_t * pDst, - uint32_t modifier) -{ - uint32_t i; /* Loop Counter */ - q31_t outR, outI; /* Temporary variables for output */ - const q15_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */ - q15_t *pSrc1, *pSrc2; -#if defined (ARM_MATH_DSP) - q15_t *pD1, *pD2; +void arm_split_rfft_q15(q15_t *pSrc, uint32_t fftLen, const q15_t *pATable, + const q15_t *pBTable, q15_t *pDst, uint32_t modifier) { + uint32_t i; /* Loop Counter */ + q31_t outR, outI; /* Temporary variables for output */ + const q15_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */ + q15_t *pSrc1, *pSrc2; +#if defined(ARM_MATH_DSP) + q15_t *pD1, *pD2; #endif /* Init coefficient pointers */ @@ -147,127 +129,125 @@ void arm_split_rfft_q15( pSrc1 = &pSrc[2]; pSrc2 = &pSrc[(2U * fftLen) - 2U]; -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) - i = 1U; - pD1 = pDst + 2; - pD2 = pDst + (4U * fftLen) - 2; + i = 1U; + pD1 = pDst + 2; + pD2 = pDst + (4U * fftLen) - 2; - for (i = fftLen - 1; i > 0; i--) - { - /* - outR = ( pSrc[2 * i] * pATable[2 * i] - - pSrc[2 * i + 1] * pATable[2 * i + 1] - + pSrc[2 * n - 2 * i] * pBTable[2 * i] - + pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1]); - - outI = ( pIn[2 * i + 1] * pATable[2 * i] - + pIn[2 * i] * pATable[2 * i + 1] - + pIn[2 * n - 2 * i] * pBTable[2 * i + 1] - - pIn[2 * n - 2 * i + 1] * pBTable[2 * i]) - */ + for (i = fftLen - 1; i > 0; i--) { + /* + outR = ( pSrc[2 * i] * pATable[2 * i] + - pSrc[2 * i + 1] * pATable[2 * i + 1] + + pSrc[2 * n - 2 * i] * pBTable[2 * i] + + pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1]); + outI = ( pIn[2 * i + 1] * pATable[2 * i] + + pIn[2 * i] * pATable[2 * i + 1] + + pIn[2 * n - 2 * i] * pBTable[2 * i + 1] + - pIn[2 * n - 2 * i + 1] * pBTable[2 * i]) + */ #ifndef ARM_MATH_BIG_ENDIAN - /* pSrc[2 * i] * pATable[2 * i] - pSrc[2 * i + 1] * pATable[2 * i + 1] */ - outR = __SMUSD(read_q15x2 (pSrc1), read_q15x2((q15_t *) pCoefA)); + /* pSrc[2 * i] * pATable[2 * i] - pSrc[2 * i + 1] * pATable[2 * i + 1] */ + outR = __SMUSD(read_q15x2(pSrc1), read_q15x2((q15_t *)pCoefA)); #else - /* -(pSrc[2 * i + 1] * pATable[2 * i + 1] - pSrc[2 * i] * pATable[2 * i]) */ - outR = -(__SMUSD(read_q15x2 (pSrc1), read_q15x2((q15_t *) pCoefA))); + /* -(pSrc[2 * i + 1] * pATable[2 * i + 1] - pSrc[2 * i] * pATable[2 * i]) */ + outR = -(__SMUSD(read_q15x2(pSrc1), read_q15x2((q15_t *)pCoefA))); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ - /* pSrc[2 * n - 2 * i] * pBTable[2 * i] + pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1]) */ - outR = __SMLAD(read_q15x2 (pSrc2), read_q15x2((q15_t *) pCoefB), outR) >> 16U; + /* pSrc[2 * n - 2 * i] * pBTable[2 * i] + pSrc[2 * n - 2 * i + 1] * + * pBTable[2 * i + 1]) */ + outR = __SMLAD(read_q15x2(pSrc2), read_q15x2((q15_t *)pCoefB), outR) >> 16U; - /* pIn[2 * n - 2 * i] * pBTable[2 * i + 1] - pIn[2 * n - 2 * i + 1] * pBTable[2 * i] */ + /* pIn[2 * n - 2 * i] * pBTable[2 * i + 1] - pIn[2 * n - 2 * i + 1] * + * pBTable[2 * i] */ #ifndef ARM_MATH_BIG_ENDIAN - outI = __SMUSDX(read_q15x2_da (&pSrc2), read_q15x2((q15_t *) pCoefB)); + outI = __SMUSDX(read_q15x2_da(&pSrc2), read_q15x2((q15_t *)pCoefB)); #else - outI = __SMUSDX(read_q15x2 ((q15_t *) pCoefB), read_q15x2_da (&pSrc2)); + outI = __SMUSDX(read_q15x2((q15_t *)pCoefB), read_q15x2_da(&pSrc2)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ - /* (pIn[2 * i + 1] * pATable[2 * i] + pIn[2 * i] * pATable[2 * i + 1] */ - outI = __SMLADX(read_q15x2_ia (&pSrc1), read_q15x2 ((q15_t *) pCoefA), outI); + /* (pIn[2 * i + 1] * pATable[2 * i] + pIn[2 * i] * pATable[2 * i + 1] */ + outI = __SMLADX(read_q15x2_ia(&pSrc1), read_q15x2((q15_t *)pCoefA), outI); - /* write output */ - *pD1++ = (q15_t) outR; - *pD1++ = outI >> 16U; + /* write output */ + *pD1++ = (q15_t)outR; + *pD1++ = outI >> 16U; - /* write complex conjugate output */ - pD2[0] = (q15_t) outR; - pD2[1] = -(outI >> 16U); - pD2 -= 2; + /* write complex conjugate output */ + pD2[0] = (q15_t)outR; + pD2[1] = -(outI >> 16U); + pD2 -= 2; - /* update coefficient pointer */ - pCoefB = pCoefB + (2U * modifier); - pCoefA = pCoefA + (2U * modifier); - } + /* update coefficient pointer */ + pCoefB = pCoefB + (2U * modifier); + pCoefA = pCoefA + (2U * modifier); + } - pDst[2U * fftLen] = (pSrc[0] - pSrc[1]) >> 1U; - pDst[2U * fftLen + 1U] = 0; + pDst[2U * fftLen] = (pSrc[0] - pSrc[1]) >> 1U; + pDst[2U * fftLen + 1U] = 0; - pDst[0] = (pSrc[0] + pSrc[1]) >> 1U; - pDst[1] = 0; + pDst[0] = (pSrc[0] + pSrc[1]) >> 1U; + pDst[1] = 0; #else - i = 1U; + i = 1U; - while (i < fftLen) - { - /* - outR = ( pSrc[2 * i] * pATable[2 * i] - - pSrc[2 * i + 1] * pATable[2 * i + 1] - + pSrc[2 * n - 2 * i] * pBTable[2 * i] - + pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1]); - */ + while (i < fftLen) { + /* + outR = ( pSrc[2 * i] * pATable[2 * i] + - pSrc[2 * i + 1] * pATable[2 * i + 1] + + pSrc[2 * n - 2 * i] * pBTable[2 * i] + + pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1]); + */ - outR = *pSrc1 * *pCoefA; - outR = outR - (*(pSrc1 + 1) * *(pCoefA + 1)); - outR = outR + (*pSrc2 * *pCoefB); - outR = (outR + (*(pSrc2 + 1) * *(pCoefB + 1))) >> 16; + outR = *pSrc1 * *pCoefA; + outR = outR - (*(pSrc1 + 1) * *(pCoefA + 1)); + outR = outR + (*pSrc2 * *pCoefB); + outR = (outR + (*(pSrc2 + 1) * *(pCoefB + 1))) >> 16; - /* - outI = ( pIn[2 * i + 1] * pATable[2 * i] - + pIn[2 * i] * pATable[2 * i + 1] - + pIn[2 * n - 2 * i] * pBTable[2 * i + 1] - - pIn[2 * n - 2 * i + 1] * pBTable[2 * i]); - */ + /* + outI = ( pIn[2 * i + 1] * pATable[2 * i] + + pIn[2 * i] * pATable[2 * i + 1] + + pIn[2 * n - 2 * i] * pBTable[2 * i + 1] + - pIn[2 * n - 2 * i + 1] * pBTable[2 * i]); + */ - outI = *pSrc2 * *(pCoefB + 1); - outI = outI - (*(pSrc2 + 1) * *pCoefB); - outI = outI + (*(pSrc1 + 1) * *pCoefA); - outI = outI + (*pSrc1 * *(pCoefA + 1)); + outI = *pSrc2 * *(pCoefB + 1); + outI = outI - (*(pSrc2 + 1) * *pCoefB); + outI = outI + (*(pSrc1 + 1) * *pCoefA); + outI = outI + (*pSrc1 * *(pCoefA + 1)); - /* update input pointers */ - pSrc1 += 2U; - pSrc2 -= 2U; + /* update input pointers */ + pSrc1 += 2U; + pSrc2 -= 2U; - /* write output */ - pDst[2U * i] = (q15_t) outR; - pDst[2U * i + 1U] = outI >> 16U; + /* write output */ + pDst[2U * i] = (q15_t)outR; + pDst[2U * i + 1U] = outI >> 16U; - /* write complex conjugate output */ - pDst[(4U * fftLen) - (2U * i)] = (q15_t) outR; - pDst[((4U * fftLen) - (2U * i)) + 1U] = -(outI >> 16U); + /* write complex conjugate output */ + pDst[(4U * fftLen) - (2U * i)] = (q15_t)outR; + pDst[((4U * fftLen) - (2U * i)) + 1U] = -(outI >> 16U); - /* update coefficient pointer */ - pCoefB = pCoefB + (2U * modifier); - pCoefA = pCoefA + (2U * modifier); + /* update coefficient pointer */ + pCoefB = pCoefB + (2U * modifier); + pCoefA = pCoefA + (2U * modifier); - i++; - } + i++; + } - pDst[2U * fftLen] = (pSrc[0] - pSrc[1]) >> 1; - pDst[2U * fftLen + 1U] = 0; + pDst[2U * fftLen] = (pSrc[0] - pSrc[1]) >> 1; + pDst[2U * fftLen + 1U] = 0; - pDst[0] = (pSrc[0] + pSrc[1]) >> 1; - pDst[1] = 0; + pDst[0] = (pSrc[0] + pSrc[1]) >> 1; + pDst[1] = 0; #endif /* #if defined (ARM_MATH_DSP) */ } - /** @brief Core Real IFFT process @param[in] pSrc points to input buffer @@ -275,26 +255,21 @@ void arm_split_rfft_q15( @param[in] pATable points to twiddle Coef A buffer @param[in] pBTable points to twiddle Coef B buffer @param[out] pDst points to output buffer - @param[in] modifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table + @param[in] modifier twiddle coefficient modifier that supports different + size FFTs with the same twiddle factor table @return none @par The function implements a Real IFFT */ -void arm_split_rifft_q15( - q15_t * pSrc, - uint32_t fftLen, - const q15_t * pATable, - const q15_t * pBTable, - q15_t * pDst, - uint32_t modifier) -{ - uint32_t i; /* Loop Counter */ - q31_t outR, outI; /* Temporary variables for output */ - const q15_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */ - q15_t *pSrc1, *pSrc2; - q15_t *pDst1 = &pDst[0]; +void arm_split_rifft_q15(q15_t *pSrc, uint32_t fftLen, const q15_t *pATable, + const q15_t *pBTable, q15_t *pDst, uint32_t modifier) { + uint32_t i; /* Loop Counter */ + q31_t outR, outI; /* Temporary variables for output */ + const q15_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */ + q15_t *pSrc1, *pSrc2; + q15_t *pDst1 = &pDst[0]; pCoefA = &pATable[0]; pCoefB = &pBTable[0]; @@ -303,78 +278,79 @@ void arm_split_rifft_q15( pSrc2 = &pSrc[2 * fftLen]; i = fftLen; - while (i > 0U) - { - /* - outR = ( pIn[2 * i] * pATable[2 * i] - + pIn[2 * i + 1] * pATable[2 * i + 1] - + pIn[2 * n - 2 * i] * pBTable[2 * i] - - pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1]); + while (i > 0U) { + /* + outR = ( pIn[2 * i] * pATable[2 * i] + + pIn[2 * i + 1] * pATable[2 * i + 1] + + pIn[2 * n - 2 * i] * pBTable[2 * i] + - pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1]); - outI = ( pIn[2 * i + 1] * pATable[2 * i] - - pIn[2 * i] * pATable[2 * i + 1] - - pIn[2 * n - 2 * i] * pBTable[2 * i + 1] - - pIn[2 * n - 2 * i + 1] * pBTable[2 * i]); - */ + outI = ( pIn[2 * i + 1] * pATable[2 * i] + - pIn[2 * i] * pATable[2 * i + 1] + - pIn[2 * n - 2 * i] * pBTable[2 * i + 1] + - pIn[2 * n - 2 * i + 1] * pBTable[2 * i]); + */ -#if defined (ARM_MATH_DSP) +#if defined(ARM_MATH_DSP) #ifndef ARM_MATH_BIG_ENDIAN - /* pIn[2 * n - 2 * i] * pBTable[2 * i] - pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1]) */ - outR = __SMUSD(read_q15x2(pSrc2), read_q15x2((q15_t *) pCoefB)); + /* pIn[2 * n - 2 * i] * pBTable[2 * i] - pIn[2 * n - 2 * i + 1] * pBTable[2 + * * i + 1]) */ + outR = __SMUSD(read_q15x2(pSrc2), read_q15x2((q15_t *)pCoefB)); #else - /* -(-pIn[2 * n - 2 * i] * pBTable[2 * i] + pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1])) */ - outR = -(__SMUSD(read_q15x2(pSrc2), read_q15x2((q15_t *) pCoefB))); + /* -(-pIn[2 * n - 2 * i] * pBTable[2 * i] + pIn[2 * n - 2 * i + 1] * + * pBTable[2 * i + 1])) */ + outR = -(__SMUSD(read_q15x2(pSrc2), read_q15x2((q15_t *)pCoefB))); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ - /* pIn[2 * i] * pATable[2 * i] + pIn[2 * i + 1] * pATable[2 * i + 1] + pIn[2 * n - 2 * i] * pBTable[2 * i] */ - outR = __SMLAD(read_q15x2(pSrc1), read_q15x2 ((q15_t *) pCoefA), outR) >> 16U; + /* pIn[2 * i] * pATable[2 * i] + pIn[2 * i + 1] * pATable[2 * i + 1] + pIn[2 + * * n - 2 * i] * pBTable[2 * i] */ + outR = __SMLAD(read_q15x2(pSrc1), read_q15x2((q15_t *)pCoefA), outR) >> 16U; - /* -pIn[2 * n - 2 * i] * pBTable[2 * i + 1] + pIn[2 * n - 2 * i + 1] * pBTable[2 * i] */ - outI = __SMUADX(read_q15x2_da (&pSrc2), read_q15x2((q15_t *) pCoefB)); + /* -pIn[2 * n - 2 * i] * pBTable[2 * i + 1] + pIn[2 * n - 2 * i + 1] * + * pBTable[2 * i] */ + outI = __SMUADX(read_q15x2_da(&pSrc2), read_q15x2((q15_t *)pCoefB)); - /* pIn[2 * i + 1] * pATable[2 * i] - pIn[2 * i] * pATable[2 * i + 1] */ + /* pIn[2 * i + 1] * pATable[2 * i] - pIn[2 * i] * pATable[2 * i + 1] */ #ifndef ARM_MATH_BIG_ENDIAN - outI = __SMLSDX(read_q15x2 ((q15_t *) pCoefA), read_q15x2_ia (&pSrc1), -outI); + outI = __SMLSDX(read_q15x2((q15_t *)pCoefA), read_q15x2_ia(&pSrc1), -outI); #else - outI = __SMLSDX(read_q15x2_ia (&pSrc1), read_q15x2 ((q15_t *) pCoefA), -outI); + outI = __SMLSDX(read_q15x2_ia(&pSrc1), read_q15x2((q15_t *)pCoefA), -outI); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ - /* write output */ + /* write output */ #ifndef ARM_MATH_BIG_ENDIAN - write_q15x2_ia (&pDst1, __PKHBT(outR, (outI >> 16U), 16)); + write_q15x2_ia(&pDst1, __PKHBT(outR, (outI >> 16U), 16)); #else - write_q15x2_ia (&pDst1, __PKHBT((outI >> 16U), outR, 16)); + write_q15x2_ia(&pDst1, __PKHBT((outI >> 16U), outR, 16)); #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ +#else /* #if defined (ARM_MATH_DSP) */ -#else /* #if defined (ARM_MATH_DSP) */ + outR = *pSrc2 * *pCoefB; + outR = outR - (*(pSrc2 + 1) * *(pCoefB + 1)); + outR = outR + (*pSrc1 * *pCoefA); + outR = (outR + (*(pSrc1 + 1) * *(pCoefA + 1))) >> 16; - outR = *pSrc2 * *pCoefB; - outR = outR - (*(pSrc2 + 1) * *(pCoefB + 1)); - outR = outR + (*pSrc1 * *pCoefA); - outR = (outR + (*(pSrc1 + 1) * *(pCoefA + 1))) >> 16; + outI = *(pSrc1 + 1) * *pCoefA; + outI = outI - (*pSrc1 * *(pCoefA + 1)); + outI = outI - (*pSrc2 * *(pCoefB + 1)); + outI = outI - (*(pSrc2 + 1) * *(pCoefB)); - outI = *(pSrc1 + 1) * *pCoefA; - outI = outI - (*pSrc1 * *(pCoefA + 1)); - outI = outI - (*pSrc2 * *(pCoefB + 1)); - outI = outI - (*(pSrc2 + 1) * *(pCoefB)); + /* update input pointers */ + pSrc1 += 2U; + pSrc2 -= 2U; - /* update input pointers */ - pSrc1 += 2U; - pSrc2 -= 2U; - - /* write output */ - *pDst1++ = (q15_t) outR; - *pDst1++ = (q15_t) (outI >> 16); + /* write output */ + *pDst1++ = (q15_t)outR; + *pDst1++ = (q15_t)(outI >> 16); #endif /* #if defined (ARM_MATH_DSP) */ - /* update coefficient pointer */ - pCoefB = pCoefB + (2 * modifier); - pCoefA = pCoefA + (2 * modifier); + /* update coefficient pointer */ + pCoefB = pCoefB + (2 * modifier); + pCoefA = pCoefA + (2 * modifier); - i--; + i--; } - } diff --git a/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_q31.c b/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_q31.c index d16600d..1779aff 100644 --- a/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_q31.c +++ b/platform/cmsis/DSP_Lib/TransformFunctions/arm_rfft_q31.c @@ -32,21 +32,11 @@ * Internal functions prototypes * -------------------------------------------------------------------- */ -void arm_split_rfft_q31( - q31_t * pSrc, - uint32_t fftLen, - const q31_t * pATable, - const q31_t * pBTable, - q31_t * pDst, - uint32_t modifier); +void arm_split_rfft_q31(q31_t *pSrc, uint32_t fftLen, const q31_t *pATable, + const q31_t *pBTable, q31_t *pDst, uint32_t modifier); -void arm_split_rifft_q31( - q31_t * pSrc, - uint32_t fftLen, - const q31_t * pATable, - const q31_t * pBTable, - q31_t * pDst, - uint32_t modifier); +void arm_split_rifft_q31(q31_t *pSrc, uint32_t fftLen, const q31_t *pATable, + const q31_t *pBTable, q31_t *pDst, uint32_t modifier); /** @addtogroup RealFFT @@ -61,49 +51,46 @@ void arm_split_rifft_q31( @return none @par Input an output formats - Internally input is downscaled by 2 for every stage to avoid saturations inside CFFT/CIFFT process. - Hence the output format is different for different RFFT sizes. - The input and output formats for different RFFT sizes and number of bits to upscale are mentioned in the tables below for RFFT and RIFFT: + Internally input is downscaled by 2 for every stage to avoid + saturations inside CFFT/CIFFT process. Hence the output format is different + for different RFFT sizes. The input and output formats for different RFFT + sizes and number of bits to upscale are mentioned in the tables below for RFFT + and RIFFT: @par - \image html RFFTQ31.gif "Input and Output Formats for Q31 RFFT" + \image html RFFTQ31.gif "Input and Output Formats for Q31 + RFFT" @par - \image html RIFFTQ31.gif "Input and Output Formats for Q31 RIFFT" + \image html RIFFTQ31.gif "Input and Output Formats for Q31 + RIFFT" */ -void arm_rfft_q31( - const arm_rfft_instance_q31 * S, - q31_t * pSrc, - q31_t * pDst) -{ +void arm_rfft_q31(const arm_rfft_instance_q31 *S, q31_t *pSrc, q31_t *pDst) { const arm_cfft_instance_q31 *S_CFFT = S->pCfft; - uint32_t L2 = S->fftLenReal >> 1U; - uint32_t i; + uint32_t L2 = S->fftLenReal >> 1U; + uint32_t i; /* Calculation of RIFFT of input */ - if (S->ifftFlagR == 1U) - { - /* Real IFFT core process */ - arm_split_rifft_q31 (pSrc, L2, S->pTwiddleAReal, S->pTwiddleBReal, pDst, S->twidCoefRModifier); + if (S->ifftFlagR == 1U) { + /* Real IFFT core process */ + arm_split_rifft_q31(pSrc, L2, S->pTwiddleAReal, S->pTwiddleBReal, pDst, + S->twidCoefRModifier); - /* Complex IFFT process */ - arm_cfft_q31 (S_CFFT, pDst, S->ifftFlagR, S->bitReverseFlagR); + /* Complex IFFT process */ + arm_cfft_q31(S_CFFT, pDst, S->ifftFlagR, S->bitReverseFlagR); - for(i = 0; i < S->fftLenReal; i++) - { - pDst[i] = pDst[i] << 1U; - } + for (i = 0; i < S->fftLenReal; i++) { + pDst[i] = pDst[i] << 1U; + } + } else { + /* Calculation of RFFT of input */ + + /* Complex FFT process */ + arm_cfft_q31(S_CFFT, pSrc, S->ifftFlagR, S->bitReverseFlagR); + + /* Real FFT core process */ + arm_split_rfft_q31(pSrc, L2, S->pTwiddleAReal, S->pTwiddleBReal, pDst, + S->twidCoefRModifier); } - else - { - /* Calculation of RFFT of input */ - - /* Complex FFT process */ - arm_cfft_q31 (S_CFFT, pSrc, S->ifftFlagR, S->bitReverseFlagR); - - /* Real FFT core process */ - arm_split_rfft_q31 (pSrc, L2, S->pTwiddleAReal, S->pTwiddleBReal, pDst, S->twidCoefRModifier); - } - } /** @@ -117,24 +104,20 @@ void arm_rfft_q31( @param[in] pATable points to twiddle Coef A buffer @param[in] pBTable points to twiddle Coef B buffer @param[out] pDst points to output buffer - @param[in] modifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table + @param[in] modifier twiddle coefficient modifier that supports different + size FFTs with the same twiddle factor table @return none */ -void arm_split_rfft_q31( - q31_t * pSrc, - uint32_t fftLen, - const q31_t * pATable, - const q31_t * pBTable, - q31_t * pDst, - uint32_t modifier) -{ - uint32_t i; /* Loop Counter */ - q31_t outR, outI; /* Temporary variables for output */ - const q31_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */ - q31_t CoefA1, CoefA2, CoefB1; /* Temporary variables for twiddle coefficients */ - q31_t *pOut1 = &pDst[2], *pOut2 = &pDst[4 * fftLen - 1]; - q31_t *pIn1 = &pSrc[2], *pIn2 = &pSrc[2 * fftLen - 1]; +void arm_split_rfft_q31(q31_t *pSrc, uint32_t fftLen, const q31_t *pATable, + const q31_t *pBTable, q31_t *pDst, uint32_t modifier) { + uint32_t i; /* Loop Counter */ + q31_t outR, outI; /* Temporary variables for output */ + const q31_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */ + q31_t CoefA1, CoefA2, + CoefB1; /* Temporary variables for twiddle coefficients */ + q31_t *pOut1 = &pDst[2], *pOut2 = &pDst[4 * fftLen - 1]; + q31_t *pIn1 = &pSrc[2], *pIn2 = &pSrc[2 * fftLen - 1]; /* Init coefficient pointers */ pCoefA = &pATable[modifier * 2]; @@ -142,72 +125,70 @@ void arm_split_rfft_q31( i = fftLen - 1U; - while (i > 0U) - { - /* - outR = ( pSrc[2 * i] * pATable[2 * i] - - pSrc[2 * i + 1] * pATable[2 * i + 1] - + pSrc[2 * n - 2 * i] * pBTable[2 * i] - + pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1]); + while (i > 0U) { + /* + outR = ( pSrc[2 * i] * pATable[2 * i] + - pSrc[2 * i + 1] * pATable[2 * i + 1] + + pSrc[2 * n - 2 * i] * pBTable[2 * i] + + pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1]); - outI = ( pIn[2 * i + 1] * pATable[2 * i] - + pIn[2 * i] * pATable[2 * i + 1] - + pIn[2 * n - 2 * i] * pBTable[2 * i + 1] - - pIn[2 * n - 2 * i + 1] * pBTable[2 * i]); - */ + outI = ( pIn[2 * i + 1] * pATable[2 * i] + + pIn[2 * i] * pATable[2 * i + 1] + + pIn[2 * n - 2 * i] * pBTable[2 * i + 1] + - pIn[2 * n - 2 * i + 1] * pBTable[2 * i]); + */ - CoefA1 = *pCoefA++; - CoefA2 = *pCoefA; + CoefA1 = *pCoefA++; + CoefA2 = *pCoefA; - /* outR = (pSrc[2 * i] * pATable[2 * i] */ - mult_32x32_keep32_R (outR, *pIn1, CoefA1); + /* outR = (pSrc[2 * i] * pATable[2 * i] */ + mult_32x32_keep32_R(outR, *pIn1, CoefA1); - /* outI = pIn[2 * i] * pATable[2 * i + 1] */ - mult_32x32_keep32_R (outI, *pIn1++, CoefA2); + /* outI = pIn[2 * i] * pATable[2 * i + 1] */ + mult_32x32_keep32_R(outI, *pIn1++, CoefA2); - /* - pSrc[2 * i + 1] * pATable[2 * i + 1] */ - multSub_32x32_keep32_R (outR, *pIn1, CoefA2); + /* - pSrc[2 * i + 1] * pATable[2 * i + 1] */ + multSub_32x32_keep32_R(outR, *pIn1, CoefA2); - /* (pIn[2 * i + 1] * pATable[2 * i] */ - multAcc_32x32_keep32_R (outI, *pIn1++, CoefA1); + /* (pIn[2 * i + 1] * pATable[2 * i] */ + multAcc_32x32_keep32_R(outI, *pIn1++, CoefA1); - /* pSrc[2 * n - 2 * i] * pBTable[2 * i] */ - multSub_32x32_keep32_R (outR, *pIn2, CoefA2); - CoefB1 = *pCoefB; + /* pSrc[2 * n - 2 * i] * pBTable[2 * i] */ + multSub_32x32_keep32_R(outR, *pIn2, CoefA2); + CoefB1 = *pCoefB; - /* pIn[2 * n - 2 * i] * pBTable[2 * i + 1] */ - multSub_32x32_keep32_R (outI, *pIn2--, CoefB1); + /* pIn[2 * n - 2 * i] * pBTable[2 * i + 1] */ + multSub_32x32_keep32_R(outI, *pIn2--, CoefB1); - /* pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1] */ - multAcc_32x32_keep32_R (outR, *pIn2, CoefB1); + /* pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1] */ + multAcc_32x32_keep32_R(outR, *pIn2, CoefB1); - /* pIn[2 * n - 2 * i + 1] * pBTable[2 * i] */ - multSub_32x32_keep32_R (outI, *pIn2--, CoefA2); + /* pIn[2 * n - 2 * i + 1] * pBTable[2 * i] */ + multSub_32x32_keep32_R(outI, *pIn2--, CoefA2); - /* write output */ - *pOut1++ = outR; - *pOut1++ = outI; + /* write output */ + *pOut1++ = outR; + *pOut1++ = outI; - /* write complex conjugate output */ - *pOut2-- = -outI; - *pOut2-- = outR; + /* write complex conjugate output */ + *pOut2-- = -outI; + *pOut2-- = outR; - /* update coefficient pointer */ - pCoefB = pCoefB + (2 * modifier); - pCoefA = pCoefA + (2 * modifier - 1); + /* update coefficient pointer */ + pCoefB = pCoefB + (2 * modifier); + pCoefA = pCoefA + (2 * modifier - 1); - /* Decrement loop count */ - i--; + /* Decrement loop count */ + i--; } - pDst[2 * fftLen] = (pSrc[0] - pSrc[1]) >> 1U; + pDst[2 * fftLen] = (pSrc[0] - pSrc[1]) >> 1U; pDst[2 * fftLen + 1] = 0; pDst[0] = (pSrc[0] + pSrc[1]) >> 1U; pDst[1] = 0; } - /** @brief Core Real IFFT process @param[in] pSrc points to input buffer @@ -215,78 +196,72 @@ void arm_split_rfft_q31( @param[in] pATable points to twiddle Coef A buffer @param[in] pBTable points to twiddle Coef B buffer @param[out] pDst points to output buffer - @param[in] modifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table + @param[in] modifier twiddle coefficient modifier that supports different + size FFTs with the same twiddle factor table @return none */ -void arm_split_rifft_q31( - q31_t * pSrc, - uint32_t fftLen, - const q31_t * pATable, - const q31_t * pBTable, - q31_t * pDst, - uint32_t modifier) -{ - q31_t outR, outI; /* Temporary variables for output */ - const q31_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */ - q31_t CoefA1, CoefA2, CoefB1; /* Temporary variables for twiddle coefficients */ - q31_t *pIn1 = &pSrc[0], *pIn2 = &pSrc[2 * fftLen + 1]; +void arm_split_rifft_q31(q31_t *pSrc, uint32_t fftLen, const q31_t *pATable, + const q31_t *pBTable, q31_t *pDst, uint32_t modifier) { + q31_t outR, outI; /* Temporary variables for output */ + const q31_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */ + q31_t CoefA1, CoefA2, + CoefB1; /* Temporary variables for twiddle coefficients */ + q31_t *pIn1 = &pSrc[0], *pIn2 = &pSrc[2 * fftLen + 1]; pCoefA = &pATable[0]; pCoefB = &pBTable[0]; - while (fftLen > 0U) - { - /* - outR = ( pIn[2 * i] * pATable[2 * i] - + pIn[2 * i + 1] * pATable[2 * i + 1] - + pIn[2 * n - 2 * i] * pBTable[2 * i] - - pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1]); + while (fftLen > 0U) { + /* + outR = ( pIn[2 * i] * pATable[2 * i] + + pIn[2 * i + 1] * pATable[2 * i + 1] + + pIn[2 * n - 2 * i] * pBTable[2 * i] + - pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1]); - outI = ( pIn[2 * i + 1] * pATable[2 * i] - - pIn[2 * i] * pATable[2 * i + 1] - - pIn[2 * n - 2 * i] * pBTable[2 * i + 1] - - pIn[2 * n - 2 * i + 1] * pBTable[2 * i]); - */ + outI = ( pIn[2 * i + 1] * pATable[2 * i] + - pIn[2 * i] * pATable[2 * i + 1] + - pIn[2 * n - 2 * i] * pBTable[2 * i + 1] + - pIn[2 * n - 2 * i + 1] * pBTable[2 * i]); + */ - CoefA1 = *pCoefA++; - CoefA2 = *pCoefA; + CoefA1 = *pCoefA++; + CoefA2 = *pCoefA; - /* outR = (pIn[2 * i] * pATable[2 * i] */ - mult_32x32_keep32_R (outR, *pIn1, CoefA1); + /* outR = (pIn[2 * i] * pATable[2 * i] */ + mult_32x32_keep32_R(outR, *pIn1, CoefA1); - /* - pIn[2 * i] * pATable[2 * i + 1] */ - mult_32x32_keep32_R (outI, *pIn1++, -CoefA2); + /* - pIn[2 * i] * pATable[2 * i + 1] */ + mult_32x32_keep32_R(outI, *pIn1++, -CoefA2); - /* pIn[2 * i + 1] * pATable[2 * i + 1] */ - multAcc_32x32_keep32_R (outR, *pIn1, CoefA2); + /* pIn[2 * i + 1] * pATable[2 * i + 1] */ + multAcc_32x32_keep32_R(outR, *pIn1, CoefA2); - /* pIn[2 * i + 1] * pATable[2 * i] */ - multAcc_32x32_keep32_R (outI, *pIn1++, CoefA1); + /* pIn[2 * i + 1] * pATable[2 * i] */ + multAcc_32x32_keep32_R(outI, *pIn1++, CoefA1); - /* pIn[2 * n - 2 * i] * pBTable[2 * i] */ - multAcc_32x32_keep32_R (outR, *pIn2, CoefA2); - CoefB1 = *pCoefB; + /* pIn[2 * n - 2 * i] * pBTable[2 * i] */ + multAcc_32x32_keep32_R(outR, *pIn2, CoefA2); + CoefB1 = *pCoefB; - /* pIn[2 * n - 2 * i] * pBTable[2 * i + 1] */ - multSub_32x32_keep32_R (outI, *pIn2--, CoefB1); + /* pIn[2 * n - 2 * i] * pBTable[2 * i + 1] */ + multSub_32x32_keep32_R(outI, *pIn2--, CoefB1); - /* pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1] */ - multAcc_32x32_keep32_R (outR, *pIn2, CoefB1); + /* pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1] */ + multAcc_32x32_keep32_R(outR, *pIn2, CoefB1); - /* pIn[2 * n - 2 * i + 1] * pBTable[2 * i] */ - multAcc_32x32_keep32_R (outI, *pIn2--, CoefA2); + /* pIn[2 * n - 2 * i + 1] * pBTable[2 * i] */ + multAcc_32x32_keep32_R(outI, *pIn2--, CoefA2); - /* write output */ - *pDst++ = outR; - *pDst++ = outI; + /* write output */ + *pDst++ = outR; + *pDst++ = outI; - /* update coefficient pointer */ - pCoefB = pCoefB + (modifier * 2); - pCoefA = pCoefA + (modifier * 2 - 1); + /* update coefficient pointer */ + pCoefB = pCoefB + (modifier * 2); + pCoefA = pCoefA + (modifier * 2 - 1); - /* Decrement loop count */ - fftLen--; + /* Decrement loop count */ + fftLen--; } - } diff --git a/platform/cmsis/ca/cmsis_gic.c b/platform/cmsis/ca/cmsis_gic.c index 3a345e7..43eac5b 100644 --- a/platform/cmsis/ca/cmsis_gic.c +++ b/platform/cmsis/ca/cmsis_gic.c @@ -18,9 +18,9 @@ #if defined(__GIC_PRESENT) && (__GIC_PRESENT) #include "cmsis_nvic.h" -#include "plat_types.h" -#include "plat_addr_map.h" #include "hal_location.h" +#include "plat_addr_map.h" +#include "plat_types.h" extern void Reset_Handler(void); extern void Undef_Handler(void); @@ -31,162 +31,152 @@ extern void IRQ_Handler(void); extern void FIQ_Handler(void); struct VECTOR_HDLR_T { - uint32_t reset_hdlr; - uint32_t undef_hdlr; - uint32_t svc_hdlr; - uint32_t pabt_hdlr; - uint32_t dabt_hdlr; - uint32_t hyp_hdlr; - uint32_t irq_hdlr; - uint32_t fiq_hdlr; + uint32_t reset_hdlr; + uint32_t undef_hdlr; + uint32_t svc_hdlr; + uint32_t pabt_hdlr; + uint32_t dabt_hdlr; + uint32_t hyp_hdlr; + uint32_t irq_hdlr; + uint32_t fiq_hdlr; }; -static struct VECTOR_HDLR_T * const exc_vector = (struct VECTOR_HDLR_T *)(DSP_BOOT_REG + 0x20); +static struct VECTOR_HDLR_T *const exc_vector = + (struct VECTOR_HDLR_T *)(DSP_BOOT_REG + 0x20); static IRQn_ID_t cur_act_irq = EXCEPTION_NONE; static uint32_t cur_irq_level; static GIC_FAULT_DUMP_HANDLER_T dump_hdlr; -void c_irq_handler(void) -{ - const IRQn_ID_t irqn = IRQ_GetActiveIRQ(); - const IRQn_ID_t old_irq = cur_act_irq; +void c_irq_handler(void) { + const IRQn_ID_t irqn = IRQ_GetActiveIRQ(); + const IRQn_ID_t old_irq = cur_act_irq; - cur_irq_level++; - cur_act_irq = irqn; + cur_irq_level++; + cur_act_irq = irqn; - IRQHandler_t const handler = IRQ_GetHandler(irqn); - if (handler != NULL) { - __enable_irq(); - handler(); - __disable_irq(); - } - IRQ_EndOfInterrupt(irqn); + IRQHandler_t const handler = IRQ_GetHandler(irqn); + if (handler != NULL) { + __enable_irq(); + handler(); + __disable_irq(); + } + IRQ_EndOfInterrupt(irqn); - cur_act_irq = old_irq; - cur_irq_level--; + cur_act_irq = old_irq; + cur_irq_level--; } -void c_undef_handler(uint32_t opcode, uint32_t state, const struct FAULT_REGS_T *regs) -{ - const IRQn_ID_t old_irq = cur_act_irq; - cur_act_irq = EXCEPTION_UNDEF; +void c_undef_handler(uint32_t opcode, uint32_t state, + const struct FAULT_REGS_T *regs) { + const IRQn_ID_t old_irq = cur_act_irq; + cur_act_irq = EXCEPTION_UNDEF; - if (dump_hdlr) { - struct UNDEF_FAULT_INFO_T info; + if (dump_hdlr) { + struct UNDEF_FAULT_INFO_T info; - info.id = cur_act_irq; - info.opcode = opcode; - info.state = state; - dump_hdlr((uint32_t *)regs, (uint32_t *)&info, sizeof(info)); - } - //ASSERT(false, "Undefined Instruction!"); + info.id = cur_act_irq; + info.opcode = opcode; + info.state = state; + dump_hdlr((uint32_t *)regs, (uint32_t *)&info, sizeof(info)); + } + // ASSERT(false, "Undefined Instruction!"); - cur_act_irq = old_irq; + cur_act_irq = old_irq; } -void c_svc_handler(uint32_t svc_num, const struct FAULT_REGS_T *regs) -{ - const IRQn_ID_t old_irq = cur_act_irq; - cur_act_irq = EXCEPTION_SVC; +void c_svc_handler(uint32_t svc_num, const struct FAULT_REGS_T *regs) { + const IRQn_ID_t old_irq = cur_act_irq; + cur_act_irq = EXCEPTION_SVC; - if (dump_hdlr) { - struct SVC_FAULT_INFO_T info; + if (dump_hdlr) { + struct SVC_FAULT_INFO_T info; - info.id = cur_act_irq; - info.svc_num = svc_num; - dump_hdlr((uint32_t *)regs, (uint32_t *)&info, sizeof(info)); - } - //ASSERT(false, "SVC!"); + info.id = cur_act_irq; + info.svc_num = svc_num; + dump_hdlr((uint32_t *)regs, (uint32_t *)&info, sizeof(info)); + } + // ASSERT(false, "SVC!"); - cur_act_irq = old_irq; + cur_act_irq = old_irq; } -void c_pabt_handler(uint32_t IFSR, uint32_t IFAR, const struct FAULT_REGS_T *regs) -{ - const IRQn_ID_t old_irq = cur_act_irq; - cur_act_irq = EXCEPTION_PABT; +void c_pabt_handler(uint32_t IFSR, uint32_t IFAR, + const struct FAULT_REGS_T *regs) { + const IRQn_ID_t old_irq = cur_act_irq; + cur_act_irq = EXCEPTION_PABT; - if (dump_hdlr) { - struct PABT_FAULT_INFO_T info; + if (dump_hdlr) { + struct PABT_FAULT_INFO_T info; - info.id = cur_act_irq; - info.IFSR = IFSR; - info.IFAR = IFAR; - dump_hdlr((uint32_t *)regs, (uint32_t *)&info, sizeof(info)); - } - //ASSERT(false, "Prefetch Abort!"); + info.id = cur_act_irq; + info.IFSR = IFSR; + info.IFAR = IFAR; + dump_hdlr((uint32_t *)regs, (uint32_t *)&info, sizeof(info)); + } + // ASSERT(false, "Prefetch Abort!"); - cur_act_irq = old_irq; + cur_act_irq = old_irq; } -void c_dabt_handler(uint32_t DFSR, uint32_t DFAR, const struct FAULT_REGS_T *regs) -{ - const IRQn_ID_t old_irq = cur_act_irq; - cur_act_irq = EXCEPTION_DABT; +void c_dabt_handler(uint32_t DFSR, uint32_t DFAR, + const struct FAULT_REGS_T *regs) { + const IRQn_ID_t old_irq = cur_act_irq; + cur_act_irq = EXCEPTION_DABT; - if (dump_hdlr) { - struct DABT_FAULT_INFO_T info; + if (dump_hdlr) { + struct DABT_FAULT_INFO_T info; - info.id = cur_act_irq; - info.DFSR = DFSR; - info.DFAR = DFAR; - dump_hdlr((uint32_t *)regs, (uint32_t *)&info, sizeof(info)); - } - //ASSERT(false, "Data Abort!"); + info.id = cur_act_irq; + info.DFSR = DFSR; + info.DFAR = DFAR; + dump_hdlr((uint32_t *)regs, (uint32_t *)&info, sizeof(info)); + } + // ASSERT(false, "Data Abort!"); - cur_act_irq = old_irq; + cur_act_irq = old_irq; } -void c_fiq_handler(void) -{ - c_irq_handler(); -} +void c_fiq_handler(void) { c_irq_handler(); } -void GIC_DisableAllIRQs(void) -{ - int i; +void GIC_DisableAllIRQs(void) { + int i; - for (i = 0; i < (USER_IRQn_QTY + 31) / 32; i++) { - GICDistributor->ICENABLER[i] = ~0UL; - } + for (i = 0; i < (USER_IRQn_QTY + 31) / 32; i++) { + GICDistributor->ICENABLER[i] = ~0UL; + } } void NVIC_DisableAllIRQs(void) __attribute__((alias("GIC_DisableAllIRQs"))); -void GIC_InitVectors(void) -{ - volatile uint32_t *boot = (volatile uint32_t *)DSP_BOOT_REG; +void GIC_InitVectors(void) { + volatile uint32_t *boot = (volatile uint32_t *)DSP_BOOT_REG; - // Unlock - boot[32] = 0xCAFE0001; - __DMB(); + // Unlock + boot[32] = 0xCAFE0001; + __DMB(); - exc_vector->reset_hdlr = (uint32_t)Reset_Handler; - exc_vector->undef_hdlr = (uint32_t)Undef_Handler; - exc_vector->svc_hdlr = (uint32_t)SVC_Handler; - exc_vector->pabt_hdlr = (uint32_t)PAbt_Handler; - exc_vector->dabt_hdlr = (uint32_t)DAbt_Handler; - exc_vector->irq_hdlr = (uint32_t)IRQ_Handler; - exc_vector->fiq_hdlr = (uint32_t)FIQ_Handler; + exc_vector->reset_hdlr = (uint32_t)Reset_Handler; + exc_vector->undef_hdlr = (uint32_t)Undef_Handler; + exc_vector->svc_hdlr = (uint32_t)SVC_Handler; + exc_vector->pabt_hdlr = (uint32_t)PAbt_Handler; + exc_vector->dabt_hdlr = (uint32_t)DAbt_Handler; + exc_vector->irq_hdlr = (uint32_t)IRQ_Handler; + exc_vector->fiq_hdlr = (uint32_t)FIQ_Handler; - // Lock - __DMB(); - boot[32] = 0xCAFE0000; - __DMB(); + // Lock + __DMB(); + boot[32] = 0xCAFE0000; + __DMB(); } void NVIC_InitVectors(void) __attribute__((alias("GIC_InitVectors"))); -void GIC_SetFaultDumpHandler(GIC_FAULT_DUMP_HANDLER_T handler) -{ - dump_hdlr = handler; +void GIC_SetFaultDumpHandler(GIC_FAULT_DUMP_HANDLER_T handler) { + dump_hdlr = handler; } -IRQn_Type IRQ_GetCurrentActiveIRQ(void) -{ - return cur_act_irq; -} -IRQn_Type NVIC_GetCurrentActiveIRQ(void) __attribute__((alias("IRQ_GetCurrentActiveIRQ"))); +IRQn_Type IRQ_GetCurrentActiveIRQ(void) { return cur_act_irq; } +IRQn_Type NVIC_GetCurrentActiveIRQ(void) + __attribute__((alias("IRQ_GetCurrentActiveIRQ"))); #endif - diff --git a/platform/cmsis/ca/irq_ctrl_gic.c b/platform/cmsis/ca/irq_ctrl_gic.c index ea39380..99b5c27 100644 --- a/platform/cmsis/ca/irq_ctrl_gic.c +++ b/platform/cmsis/ca/irq_ctrl_gic.c @@ -1,9 +1,9 @@ -/**************************************************************************//** - * @file irq_ctrl_gic.c - * @brief Interrupt controller handling implementation for GIC - * @version V1.0.1 - * @date 9. April 2018 - ******************************************************************************/ +/**************************************************************************/ /** + * @file irq_ctrl_gic.c + * @brief Interrupt controller handling implementation for GIC + * @version V1.0.1 + * @date 9. April 2018 + ******************************************************************************/ /* * Copyright (c) 2017 ARM Limited. All rights reserved. * @@ -22,20 +22,20 @@ * limitations under the License. */ -#include #include "cmsis.h" #include "irq_ctrl.h" +#include #if defined(__GIC_PRESENT) && (__GIC_PRESENT == 1U) /// Number of implemented interrupt lines -#define IRQ_GIC_LINE_COUNT USER_IRQn_QTY +#define IRQ_GIC_LINE_COUNT USER_IRQn_QTY -static IRQHandler_t IRQTable[IRQ_GIC_LINE_COUNT] = { 0U }; -static uint32_t IRQ_ID0; +static IRQHandler_t IRQTable[IRQ_GIC_LINE_COUNT] = {0U}; +static uint32_t IRQ_ID0; /// Initialize interrupt controller. -__WEAK int32_t IRQ_Initialize (void) { +__WEAK int32_t IRQ_Initialize(void) { uint32_t i; for (i = 0U; i < IRQ_GIC_LINE_COUNT; i++) { @@ -45,14 +45,13 @@ __WEAK int32_t IRQ_Initialize (void) { return (0); } - /// Register interrupt handler. -__WEAK int32_t IRQ_SetHandler (IRQn_ID_t irqn, IRQHandler_t handler) { +__WEAK int32_t IRQ_SetHandler(IRQn_ID_t irqn, IRQHandler_t handler) { int32_t status; if ((irqn >= 0) && (irqn < (IRQn_ID_t)IRQ_GIC_LINE_COUNT)) { IRQTable[irqn] = handler; - status = 0; + status = 0; } else { status = -1; } @@ -60,9 +59,8 @@ __WEAK int32_t IRQ_SetHandler (IRQn_ID_t irqn, IRQHandler_t handler) { return (status); } - /// Get the registered interrupt handler. -__WEAK IRQHandler_t IRQ_GetHandler (IRQn_ID_t irqn) { +__WEAK IRQHandler_t IRQ_GetHandler(IRQn_ID_t irqn) { IRQHandler_t h; // Ignore CPUID field (software generated interrupts) @@ -77,13 +75,12 @@ __WEAK IRQHandler_t IRQ_GetHandler (IRQn_ID_t irqn) { return (h); } - /// Enable interrupt. -__WEAK int32_t IRQ_Enable (IRQn_ID_t irqn) { +__WEAK int32_t IRQ_Enable(IRQn_ID_t irqn) { int32_t status; if ((irqn >= 0) && (irqn < (IRQn_ID_t)IRQ_GIC_LINE_COUNT)) { - GIC_EnableIRQ ((IRQn_Type)irqn); + GIC_EnableIRQ((IRQn_Type)irqn); status = 0; } else { status = -1; @@ -92,13 +89,12 @@ __WEAK int32_t IRQ_Enable (IRQn_ID_t irqn) { return (status); } - /// Disable interrupt. -__WEAK int32_t IRQ_Disable (IRQn_ID_t irqn) { +__WEAK int32_t IRQ_Disable(IRQn_ID_t irqn) { int32_t status; if ((irqn >= 0) && (irqn < (IRQn_ID_t)IRQ_GIC_LINE_COUNT)) { - GIC_DisableIRQ ((IRQn_Type)irqn); + GIC_DisableIRQ((IRQn_Type)irqn); status = 0; } else { status = -1; @@ -107,9 +103,8 @@ __WEAK int32_t IRQ_Disable (IRQn_ID_t irqn) { return (status); } - /// Get interrupt enable state. -__WEAK uint32_t IRQ_GetEnableState (IRQn_ID_t irqn) { +__WEAK uint32_t IRQ_GetEnableState(IRQn_ID_t irqn) { uint32_t enable; if ((irqn >= 0) && (irqn < (IRQn_ID_t)IRQ_GIC_LINE_COUNT)) { @@ -121,9 +116,8 @@ __WEAK uint32_t IRQ_GetEnableState (IRQn_ID_t irqn) { return (enable); } - /// Configure interrupt request mode. -__WEAK int32_t IRQ_SetMode (IRQn_ID_t irqn, uint32_t mode) { +__WEAK int32_t IRQ_SetMode(IRQn_ID_t irqn, uint32_t mode) { uint32_t val; uint8_t cfg; uint8_t secure; @@ -180,10 +174,10 @@ __WEAK int32_t IRQ_SetMode (IRQn_ID_t irqn, uint32_t mode) { // Apply configuration if no mode error if (status == 0) { GIC_SetConfiguration((IRQn_Type)irqn, cfg); - GIC_SetTarget ((IRQn_Type)irqn, cpu); + GIC_SetTarget((IRQn_Type)irqn, cpu); if (secure != 0U) { - GIC_SetGroup ((IRQn_Type)irqn, secure); + GIC_SetGroup((IRQn_Type)irqn, secure); } } } @@ -191,9 +185,8 @@ __WEAK int32_t IRQ_SetMode (IRQn_ID_t irqn, uint32_t mode) { return (status); } - /// Get interrupt mode configuration. -__WEAK uint32_t IRQ_GetMode (IRQn_ID_t irqn) { +__WEAK uint32_t IRQ_GetMode(IRQn_ID_t irqn) { uint32_t mode; uint32_t val; @@ -212,7 +205,7 @@ __WEAK uint32_t IRQ_GetMode (IRQn_ID_t irqn) { } // Get interrupt CPU targets - mode |= GIC_GetTarget ((IRQn_Type)irqn) << IRQ_MODE_CPU_Pos; + mode |= GIC_GetTarget((IRQn_Type)irqn) << IRQ_MODE_CPU_Pos; } else { mode = IRQ_MODE_ERROR; @@ -221,9 +214,8 @@ __WEAK uint32_t IRQ_GetMode (IRQn_ID_t irqn) { return (mode); } - /// Get ID number of current interrupt request (IRQ). -__WEAK IRQn_ID_t IRQ_GetActiveIRQ (void) { +__WEAK IRQn_ID_t IRQ_GetActiveIRQ(void) { IRQn_ID_t irqn; uint32_t prio; @@ -234,22 +226,27 @@ __WEAK IRQn_ID_t IRQ_GetActiveIRQ (void) { __DSB(); - /* Workaround GIC 390 errata 733075 (GIC-390_Errata_Notice_v6.pdf, 09-Jul-2014) */ - /* The following workaround code is for a single-core system. It would be */ - /* different in a multi-core system. */ - /* If the ID is 0 or 0x3FE or 0x3FF, then the GIC CPU interface may be locked-up */ - /* so unlock it, otherwise service the interrupt as normal. */ - /* Special IDs 1020=0x3FC and 1021=0x3FD are reserved values in GICv1 and GICv2 */ - /* so will not occur here. */ + /* Workaround GIC 390 errata 733075 (GIC-390_Errata_Notice_v6.pdf, + * 09-Jul-2014) */ + /* The following workaround code is for a single-core system. It would be */ + /* different in a multi-core system. */ + /* If the ID is 0 or 0x3FE or 0x3FF, then the GIC CPU interface may be + * locked-up */ + /* so unlock it, otherwise service the interrupt as normal. */ + /* Special IDs 1020=0x3FC and 1021=0x3FD are reserved values in GICv1 and + * GICv2 */ + /* so will not occur here. */ if ((irqn == 0) || (irqn >= 0x3FE)) { - /* Unlock the CPU interface with a dummy write to Interrupt Priority Register */ + /* Unlock the CPU interface with a dummy write to Interrupt Priority + * Register */ prio = GIC_GetPriority((IRQn_Type)0); - GIC_SetPriority ((IRQn_Type)0, prio); + GIC_SetPriority((IRQn_Type)0, prio); __DSB(); - if ((irqn == 0U) && ((GIC_GetIRQStatus ((IRQn_Type)irqn) & 1U) != 0U) && (IRQ_ID0 == 0U)) { + if ((irqn == 0U) && ((GIC_GetIRQStatus((IRQn_Type)irqn) & 1U) != 0U) && + (IRQ_ID0 == 0U)) { /* If the ID is 0, is active and has not been seen before */ IRQ_ID0 = 1U; } @@ -259,22 +256,18 @@ __WEAK IRQn_ID_t IRQ_GetActiveIRQ (void) { return (irqn); } - /// Get ID number of current fast interrupt request (FIQ). -__WEAK IRQn_ID_t IRQ_GetActiveFIQ (void) { - return ((IRQn_ID_t)-1); -} - +__WEAK IRQn_ID_t IRQ_GetActiveFIQ(void) { return ((IRQn_ID_t)-1); } /// Signal end of interrupt processing. -__WEAK int32_t IRQ_EndOfInterrupt (IRQn_ID_t irqn) { +__WEAK int32_t IRQ_EndOfInterrupt(IRQn_ID_t irqn) { int32_t status; IRQn_Type irq = (IRQn_Type)irqn; irqn &= 0x3FFU; if ((irqn >= 0) && (irqn < (IRQn_ID_t)IRQ_GIC_LINE_COUNT)) { - GIC_EndInterrupt (irq); + GIC_EndInterrupt(irq); if (irqn == 0) { IRQ_ID0 = 0U; @@ -288,13 +281,12 @@ __WEAK int32_t IRQ_EndOfInterrupt (IRQn_ID_t irqn) { return (status); } - /// Set interrupt pending flag. -__WEAK int32_t IRQ_SetPending (IRQn_ID_t irqn) { +__WEAK int32_t IRQ_SetPending(IRQn_ID_t irqn) { int32_t status; if ((irqn >= 0) && (irqn < (IRQn_ID_t)IRQ_GIC_LINE_COUNT)) { - GIC_SetPendingIRQ ((IRQn_Type)irqn); + GIC_SetPendingIRQ((IRQn_Type)irqn); status = 0; } else { status = -1; @@ -304,11 +296,11 @@ __WEAK int32_t IRQ_SetPending (IRQn_ID_t irqn) { } /// Get interrupt pending flag. -__WEAK uint32_t IRQ_GetPending (IRQn_ID_t irqn) { +__WEAK uint32_t IRQ_GetPending(IRQn_ID_t irqn) { uint32_t pending; if ((irqn >= 16) && (irqn < (IRQn_ID_t)IRQ_GIC_LINE_COUNT)) { - pending = GIC_GetPendingIRQ ((IRQn_Type)irqn); + pending = GIC_GetPendingIRQ((IRQn_Type)irqn); } else { pending = 0U; } @@ -316,13 +308,12 @@ __WEAK uint32_t IRQ_GetPending (IRQn_ID_t irqn) { return (pending & 1U); } - /// Clear interrupt pending flag. -__WEAK int32_t IRQ_ClearPending (IRQn_ID_t irqn) { +__WEAK int32_t IRQ_ClearPending(IRQn_ID_t irqn) { int32_t status; if ((irqn >= 16) && (irqn < (IRQn_ID_t)IRQ_GIC_LINE_COUNT)) { - GIC_ClearPendingIRQ ((IRQn_Type)irqn); + GIC_ClearPendingIRQ((IRQn_Type)irqn); status = 0; } else { status = -1; @@ -331,13 +322,12 @@ __WEAK int32_t IRQ_ClearPending (IRQn_ID_t irqn) { return (status); } - /// Set interrupt priority value. -__WEAK int32_t IRQ_SetPriority (IRQn_ID_t irqn, uint32_t priority) { +__WEAK int32_t IRQ_SetPriority(IRQn_ID_t irqn, uint32_t priority) { int32_t status; if ((irqn >= 0) && (irqn < (IRQn_ID_t)IRQ_GIC_LINE_COUNT)) { - GIC_SetPriority ((IRQn_Type)irqn, priority); + GIC_SetPriority((IRQn_Type)irqn, priority); status = 0; } else { status = -1; @@ -346,13 +336,12 @@ __WEAK int32_t IRQ_SetPriority (IRQn_ID_t irqn, uint32_t priority) { return (status); } - /// Get interrupt priority. -__WEAK uint32_t IRQ_GetPriority (IRQn_ID_t irqn) { +__WEAK uint32_t IRQ_GetPriority(IRQn_ID_t irqn) { uint32_t priority; if ((irqn >= 0) && (irqn < (IRQn_ID_t)IRQ_GIC_LINE_COUNT)) { - priority = GIC_GetPriority ((IRQn_Type)irqn); + priority = GIC_GetPriority((IRQn_Type)irqn); } else { priority = IRQ_PRIORITY_ERROR; } @@ -360,22 +349,19 @@ __WEAK uint32_t IRQ_GetPriority (IRQn_ID_t irqn) { return (priority); } - /// Set priority masking threshold. -__WEAK int32_t IRQ_SetPriorityMask (uint32_t priority) { - GIC_SetInterfacePriorityMask (priority); +__WEAK int32_t IRQ_SetPriorityMask(uint32_t priority) { + GIC_SetInterfacePriorityMask(priority); return (0); } - /// Get priority masking threshold -__WEAK uint32_t IRQ_GetPriorityMask (void) { +__WEAK uint32_t IRQ_GetPriorityMask(void) { return GIC_GetInterfacePriorityMask(); } - /// Set priority grouping field split point -__WEAK int32_t IRQ_SetPriorityGroupBits (uint32_t bits) { +__WEAK int32_t IRQ_SetPriorityGroupBits(uint32_t bits) { int32_t status; if (bits == IRQ_PRIORITY_Msk) { @@ -383,7 +369,7 @@ __WEAK int32_t IRQ_SetPriorityGroupBits (uint32_t bits) { } if (bits < 8U) { - GIC_SetBinaryPoint (7U - bits); + GIC_SetBinaryPoint(7U - bits); status = 0; } else { status = -1; @@ -392,9 +378,8 @@ __WEAK int32_t IRQ_SetPriorityGroupBits (uint32_t bits) { return (status); } - /// Get priority grouping field split point -__WEAK uint32_t IRQ_GetPriorityGroupBits (void) { +__WEAK uint32_t IRQ_GetPriorityGroupBits(void) { uint32_t bp; bp = GIC_GetBinaryPoint() & 0x07U; diff --git a/platform/cmsis/ca/mmu_ARMCA.c b/platform/cmsis/ca/mmu_ARMCA.c index 4cbc705..4afd3fd 100644 --- a/platform/cmsis/ca/mmu_ARMCA.c +++ b/platform/cmsis/ca/mmu_ARMCA.c @@ -1,12 +1,12 @@ -/**************************************************************************//** - * @file mmu_ARMCA7.c - * @brief MMU Configuration for Arm Cortex-A7 Device Series - * @version V1.2.0 - * @date 15. May 2019 - * - * @note - * - ******************************************************************************/ +/**************************************************************************/ /** + * @file mmu_ARMCA7.c + * @brief MMU Configuration for Arm Cortex-A7 Device Series + * @version V1.2.0 + * @date 15. May 2019 + * + * @note + * + ******************************************************************************/ /* * Copyright (c) 2009-2019 Arm Limited. All rights reserved. * @@ -25,7 +25,8 @@ * limitations under the License. */ -/* Memory map description from: DUI0447G_v2m_p1_trm.pdf 4.2.2 Arm Cortex-A Series memory map +/* Memory map description from: DUI0447G_v2m_p1_trm.pdf 4.2.2 Arm Cortex-A +Series memory map Memory Type 0xffffffff |--------------------------| ------------ @@ -77,27 +78,32 @@ 0x00000000 |--------------------------| */ -// L1 Cache info and restrictions about architecture of the caches (CCSIR register): -// Write-Through support *not* available -// Write-Back support available. -// Read allocation support available. -// Write allocation support available. +// L1 Cache info and restrictions about architecture of the caches (CCSIR +// register): Write-Through support *not* available Write-Back support +// available. Read allocation support available. Write allocation support +// available. -//Note: You should use the Shareable attribute carefully. -//For cores without coherency logic (such as SCU) marking a region as shareable forces the processor to not cache that region regardless of the inner cache settings. -//Cortex-A versions of RTX use LDREX/STREX instructions relying on Local monitors. Local monitors will be used only when the region gets cached, regions that are not cached will use the Global Monitor. -//Some Cortex-A implementations do not include Global Monitors, so wrongly setting the attribute Shareable may cause STREX to fail. +// Note: You should use the Shareable attribute carefully. +// For cores without coherency logic (such as SCU) marking a region as shareable +// forces the processor to not cache that region regardless of the inner cache +// settings. Cortex-A versions of RTX use LDREX/STREX instructions relying on +// Local monitors. Local monitors will be used only when the region gets cached, +// regions that are not cached will use the Global Monitor. Some Cortex-A +// implementations do not include Global Monitors, so wrongly setting the +// attribute Shareable may cause STREX to fail. -//Recall: When the Shareable attribute is applied to a memory region that is not Write-Back, Normal memory, data held in this region is treated as Non-cacheable. -//When SMP bit = 0, Inner WB/WA Cacheable Shareable attributes are treated as Non-cacheable. -//When SMP bit = 1, Inner WB/WA Cacheable Shareable attributes are treated as Cacheable. +// Recall: When the Shareable attribute is applied to a memory region that is +// not Write-Back, Normal memory, data held in this region is treated as +// Non-cacheable. When SMP bit = 0, Inner WB/WA Cacheable Shareable attributes +// are treated as Non-cacheable. When SMP bit = 1, Inner WB/WA Cacheable +// Shareable attributes are treated as Cacheable. - -//Following MMU configuration is expected -//SCTLR.AFE == 1 (Simplified access permissions model - AP[2:1] define access permissions, AP[0] is an access flag) -//SCTLR.TRE == 0 (TEX remap disabled, so memory type and attributes are described directly by bits in the descriptor) -//Domain 0 is always the Client domain -//Descriptors should place all memory in domain 0 +// Following MMU configuration is expected +// SCTLR.AFE == 1 (Simplified access permissions model - AP[2:1] define access +// permissions, AP[0] is an access flag) SCTLR.TRE == 0 (TEX remap disabled, so +// memory type and attributes are described directly by bits in the descriptor) +// Domain 0 is always the Client domain +// Descriptors should place all memory in domain 0 #include "cmsis.h" #include "mem_ARMCA.h" @@ -106,152 +112,183 @@ extern uint32_t __sync_flags_start[]; extern uint32_t __sync_flags_end[]; -#define SECTION_SIZE 0x00100000 -#define SECTION_ADDR(n) ((n) & 0xFFF00000) -#define SECTION_CNT(n) (((n) + SECTION_SIZE - 1) / SECTION_SIZE) +#define SECTION_SIZE 0x00100000 +#define SECTION_ADDR(n) ((n)&0xFFF00000) +#define SECTION_CNT(n) (((n) + SECTION_SIZE - 1) / SECTION_SIZE) -#define PAGE16K_SIZE 0x00004000 -#define PAGE16K_ADDR(n) ((n) & 0xFFFFC000) -#define PAGE16K_CNT(n) (((n) + PAGE16K_SIZE - 1) / PAGE16K_SIZE) +#define PAGE16K_SIZE 0x00004000 +#define PAGE16K_ADDR(n) ((n)&0xFFFFC000) +#define PAGE16K_CNT(n) (((n) + PAGE16K_SIZE - 1) / PAGE16K_SIZE) -#define PAGE4K_SIZE 0x00001000 -#define PAGE4K_ADDR(n) ((n) & 0xFFFFF000) -#define PAGE4K_CNT(n) (((n) + PAGE4K_SIZE - 1) / PAGE4K_SIZE) +#define PAGE4K_SIZE 0x00001000 +#define PAGE4K_ADDR(n) ((n)&0xFFFFF000) +#define PAGE4K_CNT(n) (((n) + PAGE4K_SIZE - 1) / PAGE4K_SIZE) // TTB base address -#define TTB_BASE (l1) +#define TTB_BASE (l1) // L2 table pointers //---------------------------------------- -#define TTB_L1_SIZE (0x00004000) // The L1 translation table divides the full 4GB address space of a 32-bit core - // into 4096 equally sized sections, each of which describes 1MB of virtual memory space. - // The L1 translation table therefore contains 4096 32-bit (word-sized) entries. +#define TTB_L1_SIZE \ + (0x00004000) // The L1 translation table divides the full 4GB address space of + // a 32-bit core into 4096 equally sized sections, each of which + // describes 1MB of virtual memory space. The L1 translation + // table therefore contains 4096 32-bit (word-sized) entries. -#define PRIVATE_TABLE_L2_4K_SIZE (0x400) -#define PERIPHERAL_A_TABLE_L2_4K_SIZE (0x400) -#define PERIPHERAL_B_TABLE_L2_64K_SIZE (0x400) -#define SYNC_FLAGS_TABLE_L2_4K_SIZE (0x400) +#define PRIVATE_TABLE_L2_4K_SIZE (0x400) +#define PERIPHERAL_A_TABLE_L2_4K_SIZE (0x400) +#define PERIPHERAL_B_TABLE_L2_64K_SIZE (0x400) +#define SYNC_FLAGS_TABLE_L2_4K_SIZE (0x400) -#define PRIVATE_TABLE_L2_BASE_4k (l2.pri) // Map 4k Private Address space -#define PERIPHERAL_A_TABLE_L2_BASE_4k (l2.periph_a) // Map 64k Peripheral #1 0x1C000000 - 0x1C00FFFFF -#define PERIPHERAL_B_TABLE_L2_BASE_64k (l2.periph_b) // Map 64k Peripheral #2 0x1C100000 - 0x1C1FFFFFF -#define SYNC_FLAGS_TABLE_L2_BASE_4k (l2.sync) // Map 4k Flag synchronization +#define PRIVATE_TABLE_L2_BASE_4k (l2.pri) // Map 4k Private Address space +#define PERIPHERAL_A_TABLE_L2_BASE_4k \ + (l2.periph_a) // Map 64k Peripheral #1 0x1C000000 - 0x1C00FFFFF +#define PERIPHERAL_B_TABLE_L2_BASE_64k \ + (l2.periph_b) // Map 64k Peripheral #2 0x1C100000 - 0x1C1FFFFFF +#define SYNC_FLAGS_TABLE_L2_BASE_4k (l2.sync) // Map 4k Flag synchronization //--------------------- PERIPHERALS ------------------- -//#define PERIPHERAL_A_FAULT (0x00000000 + 0x1c000000) //0x1C000000-0x1C00FFFF (1M) -//#define PERIPHERAL_B_FAULT (0x00100000 + 0x1c000000) //0x1C100000-0x1C10FFFF (1M) +//#define PERIPHERAL_A_FAULT (0x00000000 + 0x1c000000) //0x1C000000-0x1C00FFFF +//(1M) #define PERIPHERAL_B_FAULT (0x00100000 + 0x1c000000) +////0x1C100000-0x1C10FFFF (1M) //--------------------- SYNC FLAGS -------------------- //#define FLAG_SYNC 0xFFFFF000 //#define F_SYNC_BASE 0xFFF00000 //1M aligned -#define SYNC_FLAG_SIZE ((uint32_t)__sync_flags_end - (uint32_t)__sync_flags_start) -#define FLAG_SYNC ((uint32_t)__sync_flags_start) +#define SYNC_FLAG_SIZE \ + ((uint32_t)__sync_flags_end - (uint32_t)__sync_flags_start) +#define FLAG_SYNC ((uint32_t)__sync_flags_start) -static uint32_t Sect_Normal; //outer & inner wb/wa, non-shareable, executable, rw, domain 0, base addr 0 -static uint32_t Sect_Normal_Cod; //outer & inner wb/wa, non-shareable, executable, ro, domain 0, base addr 0 -static uint32_t Sect_Normal_RO; //as Sect_Normal_Cod, but not executable -static uint32_t Sect_Normal_RW; //as Sect_Normal_Cod, but writeable and not executable -static uint32_t Sect_Device_RO; //device, non-shareable, non-executable, ro, domain 0, base addr 0 -static uint32_t Sect_Device_RW; //as Sect_Device_RO, but writeable +static uint32_t Sect_Normal; // outer & inner wb/wa, non-shareable, executable, + // rw, domain 0, base addr 0 +static uint32_t Sect_Normal_Cod; // outer & inner wb/wa, non-shareable, + // executable, ro, domain 0, base addr 0 +static uint32_t Sect_Normal_RO; // as Sect_Normal_Cod, but not executable +static uint32_t + Sect_Normal_RW; // as Sect_Normal_Cod, but writeable and not executable +static uint32_t Sect_Device_RO; // device, non-shareable, non-executable, ro, + // domain 0, base addr 0 +static uint32_t Sect_Device_RW; // as Sect_Device_RO, but writeable -static uint32_t Sect_Normal_NC; //outer & inner uncached, non-shareable, executable, rw, domain 0, base addr 0 -static uint32_t Sect_Normal_RO_NC; //outer & inner uncached, non-shareable, executable, ro, domain 0, base addr 0 +static uint32_t Sect_Normal_NC; // outer & inner uncached, non-shareable, + // executable, rw, domain 0, base addr 0 +static uint32_t Sect_Normal_RO_NC; // outer & inner uncached, non-shareable, + // executable, ro, domain 0, base addr 0 /* Define global descriptors */ -static uint32_t Page_L1_4k = 0x0; //generic -static uint32_t Page_L1_64k = 0x0; //generic -static uint32_t Page_4k_Device_RW; //Shared device, not executable, rw, domain 0 -static uint32_t Page_64k_Device_RW; //Shared device, not executable, rw, domain 0 +static uint32_t Page_L1_4k = 0x0; // generic +static uint32_t Page_L1_64k = 0x0; // generic +static uint32_t Page_4k_Device_RW; // Shared device, not executable, rw, domain + // 0 +static uint32_t + Page_64k_Device_RW; // Shared device, not executable, rw, domain 0 -static uint32_t Page_4k_Normal; //outer & inner wb/wa, non-shareable, executable, rw, domain 0 +static uint32_t Page_4k_Normal; // outer & inner wb/wa, non-shareable, + // executable, rw, domain 0 struct TTB_L2_T { - uint32_t pri[PRIVATE_TABLE_L2_4K_SIZE / 4]; - uint32_t periph_a[PERIPHERAL_A_TABLE_L2_4K_SIZE / 4]; - uint32_t periph_b[PERIPHERAL_B_TABLE_L2_64K_SIZE / 4]; - uint32_t sync[SYNC_FLAGS_TABLE_L2_4K_SIZE / 4]; + uint32_t pri[PRIVATE_TABLE_L2_4K_SIZE / 4]; + uint32_t periph_a[PERIPHERAL_A_TABLE_L2_4K_SIZE / 4]; + uint32_t periph_b[PERIPHERAL_B_TABLE_L2_64K_SIZE / 4]; + uint32_t sync[SYNC_FLAGS_TABLE_L2_4K_SIZE / 4]; }; -__attribute__((section(".ttb_l1"), aligned(0x4000))) -static uint32_t l1[TTB_L1_SIZE / 4]; -__attribute__((section(".ttb_l2"), aligned(0x400))) -static struct TTB_L2_T l2; +__attribute__((section(".ttb_l1"), + aligned(0x4000))) static uint32_t l1[TTB_L1_SIZE / 4]; +__attribute__((section(".ttb_l2"), aligned(0x400))) static struct TTB_L2_T l2; -void MMU_CreateTranslationTable(void) -{ - mmu_region_attributes_Type region; +void MMU_CreateTranslationTable(void) { + mmu_region_attributes_Type region; - //Create 4GB of faulting entries - MMU_TTSection (TTB_BASE, 0, 4096, DESCRIPTOR_FAULT); + // Create 4GB of faulting entries + MMU_TTSection(TTB_BASE, 0, 4096, DESCRIPTOR_FAULT); - /* - * Generate descriptors. Refer to core_ca.h to get information about attributes - * - */ - //Create descriptors for Vectors, RO, RW, ZI sections - section_normal(Sect_Normal, region); - section_normal_cod(Sect_Normal_Cod, region); - section_normal_ro(Sect_Normal_RO, region); - section_normal_rw(Sect_Normal_RW, region); - //Create descriptors for peripherals - section_device_ro(Sect_Device_RO, region); - section_device_rw(Sect_Device_RW, region); - //Create descriptors for 64k pages - page64k_device_rw(Page_L1_64k, Page_64k_Device_RW, region); - //Create descriptors for 4k pages - page4k_device_rw(Page_L1_4k, Page_4k_Device_RW, region); - page4k_normal(Page_L1_4k, Page_4k_Normal, region); + /* + * Generate descriptors. Refer to core_ca.h to get information about + * attributes + * + */ + // Create descriptors for Vectors, RO, RW, ZI sections + section_normal(Sect_Normal, region); + section_normal_cod(Sect_Normal_Cod, region); + section_normal_ro(Sect_Normal_RO, region); + section_normal_rw(Sect_Normal_RW, region); + // Create descriptors for peripherals + section_device_ro(Sect_Device_RO, region); + section_device_rw(Sect_Device_RW, region); + // Create descriptors for 64k pages + page64k_device_rw(Page_L1_64k, Page_64k_Device_RW, region); + // Create descriptors for 4k pages + page4k_device_rw(Page_L1_4k, Page_4k_Device_RW, region); + page4k_normal(Page_L1_4k, Page_4k_Normal, region); - section_normal_nc(Sect_Normal_NC, region); - section_normal_ro_nc(Sect_Normal_RO_NC, region); + section_normal_nc(Sect_Normal_NC, region); + section_normal_ro_nc(Sect_Normal_RO_NC, region); - /* - * Define MMU flat-map regions and attributes - * - */ + /* + * Define MMU flat-map regions and attributes + * + */ - //Define Image - MMU_TTSection (TTB_BASE, FLASH_BASE , SECTION_CNT(FLASH_SIZE) , Sect_Normal_Cod); // multiple of 1MB sections - MMU_TTSection (TTB_BASE, FLASH_NC_BASE , SECTION_CNT(FLASH_SIZE) , Sect_Normal_RO_NC); // multiple of 1MB sections + // Define Image + MMU_TTSection(TTB_BASE, FLASH_BASE, SECTION_CNT(FLASH_SIZE), + Sect_Normal_Cod); // multiple of 1MB sections + MMU_TTSection(TTB_BASE, FLASH_NC_BASE, SECTION_CNT(FLASH_SIZE), + Sect_Normal_RO_NC); // multiple of 1MB sections #ifdef PSRAM_SIZE - MMU_TTSection (TTB_BASE, PSRAM_BASE , SECTION_CNT(PSRAM_SIZE) , Sect_Normal); // multiple of 1MB sections - MMU_TTSection (TTB_BASE, PSRAM_NC_BASE , SECTION_CNT(PSRAM_SIZE) , Sect_Normal_NC); // multiple of 1MB sections + MMU_TTSection(TTB_BASE, PSRAM_BASE, SECTION_CNT(PSRAM_SIZE), + Sect_Normal); // multiple of 1MB sections + MMU_TTSection(TTB_BASE, PSRAM_NC_BASE, SECTION_CNT(PSRAM_SIZE), + Sect_Normal_NC); // multiple of 1MB sections #endif #ifdef PSRAMUHS_SIZE - MMU_TTSection (TTB_BASE, PSRAMUHS_BASE , SECTION_CNT(PSRAMUHS_SIZE) , Sect_Normal); // multiple of 1MB sections - MMU_TTSection (TTB_BASE, PSRAMUHS_NC_BASE , SECTION_CNT(PSRAMUHS_SIZE) , Sect_Normal_NC); // multiple of 1MB sections - MMU_TTSection (TTB_BASE, PSRAMUHSX_BASE , SECTION_CNT(PSRAMUHS_SIZE) , Sect_Normal_Cod); // multiple of 1MB sections + MMU_TTSection(TTB_BASE, PSRAMUHS_BASE, SECTION_CNT(PSRAMUHS_SIZE), + Sect_Normal); // multiple of 1MB sections + MMU_TTSection(TTB_BASE, PSRAMUHS_NC_BASE, SECTION_CNT(PSRAMUHS_SIZE), + Sect_Normal_NC); // multiple of 1MB sections + MMU_TTSection(TTB_BASE, PSRAMUHSX_BASE, SECTION_CNT(PSRAMUHS_SIZE), + Sect_Normal_Cod); // multiple of 1MB sections #endif - MMU_TTSection (TTB_BASE, DSP_RAM_BASE , SECTION_CNT(MAX_DSP_RAM_SIZE) , Sect_Normal); // multiple of 1MB sections + MMU_TTSection(TTB_BASE, DSP_RAM_BASE, SECTION_CNT(MAX_DSP_RAM_SIZE), + Sect_Normal); // multiple of 1MB sections - MMU_TTSection (TTB_BASE, ROMD_BASE , 1 , Sect_Normal_Cod); // multiple of 1MB sections - MMU_TTSection (TTB_BASE, RAM_BASE , SECTION_CNT(MAX_RAM_SIZE) , Sect_Normal_NC); // multiple of 1MB sections + MMU_TTSection(TTB_BASE, ROMD_BASE, 1, + Sect_Normal_Cod); // multiple of 1MB sections + MMU_TTSection(TTB_BASE, RAM_BASE, SECTION_CNT(MAX_RAM_SIZE), + Sect_Normal_NC); // multiple of 1MB sections + //--------------------- PERIPHERALS ------------------- + // Create (256 * 4k)=1MB faulting entries to cover peripheral range A + MMU_TTPage4k(TTB_BASE, SECTION_ADDR(DSP_BOOT_REG), 256, Page_L1_4k, + (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_4k, DESCRIPTOR_FAULT); + // Define peripheral range A + MMU_TTPage4k(TTB_BASE, DSP_BOOT_REG, 1, Page_L1_4k, + (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_4k, Page_4k_Normal); + MMU_TTPage4k(TTB_BASE, DSP_TRANSQM_BASE, 1, Page_L1_4k, + (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_4k, Page_4k_Device_RW); + MMU_TTPage4k(TTB_BASE, DSP_TIMER0_BASE, 1, Page_L1_4k, + (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_4k, Page_4k_Device_RW); + MMU_TTPage4k(TTB_BASE, DSP_TIMER1_BASE, 1, Page_L1_4k, + (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_4k, Page_4k_Device_RW); + MMU_TTPage4k(TTB_BASE, DSP_WDT_BASE, 1, Page_L1_4k, + (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_4k, Page_4k_Device_RW); + MMU_TTPage4k(TTB_BASE, DSP_DEBUGSYS_APB_BASE, 1, Page_L1_4k, + (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_4k, Page_4k_Device_RW); - //--------------------- PERIPHERALS ------------------- - // Create (256 * 4k)=1MB faulting entries to cover peripheral range A - MMU_TTPage4k(TTB_BASE, SECTION_ADDR(DSP_BOOT_REG),256, Page_L1_4k, (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_4k, DESCRIPTOR_FAULT); - // Define peripheral range A - MMU_TTPage4k(TTB_BASE, DSP_BOOT_REG , 1, Page_L1_4k, (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_4k, Page_4k_Normal); - MMU_TTPage4k(TTB_BASE, DSP_TRANSQM_BASE , 1, Page_L1_4k, (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_4k, Page_4k_Device_RW); - MMU_TTPage4k(TTB_BASE, DSP_TIMER0_BASE , 1, Page_L1_4k, (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_4k, Page_4k_Device_RW); - MMU_TTPage4k(TTB_BASE, DSP_TIMER1_BASE , 1, Page_L1_4k, (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_4k, Page_4k_Device_RW); - MMU_TTPage4k(TTB_BASE, DSP_WDT_BASE , 1, Page_L1_4k, (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_4k, Page_4k_Device_RW); - MMU_TTPage4k(TTB_BASE, DSP_DEBUGSYS_APB_BASE , 1, Page_L1_4k, (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_4k, Page_4k_Device_RW); + MMU_TTSection(TTB_BASE, DSP_XDMA_BASE, 1, + Sect_Device_RW); // multiple of 1MB sections - MMU_TTSection (TTB_BASE, DSP_XDMA_BASE , 1, Sect_Device_RW); // multiple of 1MB sections + MMU_TTSection(TTB_BASE, CMU_BASE, 1, Sect_Device_RW); // AHB0/APB0 + MMU_TTSection(TTB_BASE, CHECKSUM_BASE, 1, Sect_Device_RW); // AHB1 + MMU_TTSection(TTB_BASE, CODEC_BASE, 1, Sect_Device_RW); // CODEC - MMU_TTSection (TTB_BASE, CMU_BASE , 1, Sect_Device_RW); // AHB0/APB0 - MMU_TTSection (TTB_BASE, CHECKSUM_BASE , 1, Sect_Device_RW); // AHB1 - MMU_TTSection (TTB_BASE, CODEC_BASE , 1, Sect_Device_RW); // CODEC + MMU_TTSection(TTB_BASE, BT_RAM_BASE, 1, Sect_Device_RW); + MMU_TTSection(TTB_BASE, BT_CMU_BASE, 1, Sect_Device_RW); - MMU_TTSection (TTB_BASE, BT_RAM_BASE , 1, Sect_Device_RW); - MMU_TTSection (TTB_BASE, BT_CMU_BASE , 1, Sect_Device_RW); - - MMU_TTSection (TTB_BASE, WIFI_RAM_BASE , 1, Sect_Device_RW); - MMU_TTSection (TTB_BASE, WIFI_PAS_BASE , 1, Sect_Device_RW); - MMU_TTSection (TTB_BASE, WIFI_TRANSQM_BASE , 1, Sect_Device_RW); + MMU_TTSection(TTB_BASE, WIFI_RAM_BASE, 1, Sect_Device_RW); + MMU_TTSection(TTB_BASE, WIFI_PAS_BASE, 1, Sect_Device_RW); + MMU_TTSection(TTB_BASE, WIFI_TRANSQM_BASE, 1, Sect_Device_RW); #if 0 MMU_TTSection (TTB_BASE, VE_A7_MP_FLASH_BASE0 , 64, Sect_Device_RO); // 64MB NOR @@ -283,11 +320,14 @@ void MMU_CreateTranslationTable(void) MMU_TTPage64k(TTB_BASE, VE_A7_MP_CLCD_BASE , 1, Page_L1_64k, (uint32_t *)PERIPHERAL_B_TABLE_L2_BASE_64k, Page_64k_Device_RW); #endif - // Create (256 * 4k)=1MB faulting entries to cover private address space. Needs to be marked as Device memory - MMU_TTPage4k (TTB_BASE, __get_CBAR() ,256, Page_L1_4k, (uint32_t *)PRIVATE_TABLE_L2_BASE_4k, DESCRIPTOR_FAULT); - // Define private address space entry. - MMU_TTPage4k (TTB_BASE, __get_CBAR() , 3, Page_L1_4k, (uint32_t *)PRIVATE_TABLE_L2_BASE_4k, Page_4k_Device_RW); -#if 0 //defined(__L2C_PRESENT) && (__L2C_PRESENT) + // Create (256 * 4k)=1MB faulting entries to cover private address space. + // Needs to be marked as Device memory + MMU_TTPage4k(TTB_BASE, __get_CBAR(), 256, Page_L1_4k, + (uint32_t *)PRIVATE_TABLE_L2_BASE_4k, DESCRIPTOR_FAULT); + // Define private address space entry. + MMU_TTPage4k(TTB_BASE, __get_CBAR(), 3, Page_L1_4k, + (uint32_t *)PRIVATE_TABLE_L2_BASE_4k, Page_4k_Device_RW); +#if 0 // defined(__L2C_PRESENT) && (__L2C_PRESENT) // Define L2CC entry. Uncomment if PL310 is present MMU_TTPage4k (TTB_BASE, VE_A5_MP_PL310_BASE , 1, Page_L1_4k, (uint32_t *)PRIVATE_TABLE_L2_BASE_4k, Page_4k_Device_RW); #endif @@ -298,26 +338,25 @@ void MMU_CreateTranslationTable(void) // Define synchronization space entry. MMU_TTPage4k (TTB_BASE, FLAG_SYNC , 1, Page_L1_4k, (uint32_t *)SYNC_FLAGS_TABLE_L2_BASE_4k, Page_4k_Device_RW); #endif - // Define synchronization space entry. - MMU_TTPage4k (TTB_BASE, SECTION_ADDR(FLAG_SYNC) , 256, Page_L1_4k, (uint32_t *)SYNC_FLAGS_TABLE_L2_BASE_4k, Page_4k_Normal); - // Define synchronization space entry. - MMU_TTPage4k (TTB_BASE, FLAG_SYNC , PAGE4K_CNT(SYNC_FLAG_SIZE), Page_L1_4k, (uint32_t *)SYNC_FLAGS_TABLE_L2_BASE_4k, Page_4k_Device_RW); + // Define synchronization space entry. + MMU_TTPage4k(TTB_BASE, SECTION_ADDR(FLAG_SYNC), 256, Page_L1_4k, + (uint32_t *)SYNC_FLAGS_TABLE_L2_BASE_4k, Page_4k_Normal); + // Define synchronization space entry. + MMU_TTPage4k(TTB_BASE, FLAG_SYNC, PAGE4K_CNT(SYNC_FLAG_SIZE), Page_L1_4k, + (uint32_t *)SYNC_FLAGS_TABLE_L2_BASE_4k, Page_4k_Device_RW); - /* Set location of level 1 page table - ; 31:14 - Translation table base addr (31:14-TTBCR.N, TTBCR.N is 0 out of reset) - ; 13:7 - 0x0 - ; 6 - IRGN[0] 0x1 (Inner WB WA) - ; 5 - NOS 0x0 (Non-shared) - ; 4:3 - RGN 0x01 (Outer WB WA) - ; 2 - IMP 0x0 (Implementation Defined) - ; 1 - S 0x0 (Non-shared) - ; 0 - IRGN[1] 0x0 (Inner WB WA) */ - __set_TTBR0((uint32_t)TTB_BASE | 0x48); - __ISB(); + /* Set location of level 1 page table + ; 31:14 - Translation table base addr (31:14-TTBCR.N, TTBCR.N is 0 out of + reset) ; 13:7 - 0x0 ; 6 - IRGN[0] 0x1 (Inner WB WA) ; 5 - NOS 0x0 + (Non-shared) ; 4:3 - RGN 0x01 (Outer WB WA) ; 2 - IMP 0x0 + (Implementation Defined) ; 1 - S 0x0 (Non-shared) + ; 0 - IRGN[1] 0x0 (Inner WB WA) */ + __set_TTBR0((uint32_t)TTB_BASE | 0x48); + __ISB(); - /* Set up domain access control register - ; We set domain 0 to Client and all other domains to No Access. - ; All translation table entries specify domain 0 */ - __set_DACR(1); - __ISB(); + /* Set up domain access control register + ; We set domain 0 to Client and all other domains to No Access. + ; All translation table entries specify domain 0 */ + __set_DACR(1); + __ISB(); } diff --git a/platform/cmsis/ca/startup_ARMCA.c b/platform/cmsis/ca/startup_ARMCA.c index 2779022..e043d2a 100644 --- a/platform/cmsis/ca/startup_ARMCA.c +++ b/platform/cmsis/ca/startup_ARMCA.c @@ -31,53 +31,51 @@ /*---------------------------------------------------------------------------- Definitions *----------------------------------------------------------------------------*/ -#define USR_MODE 0x10 // User mode -#define FIQ_MODE 0x11 // Fast Interrupt Request mode -#define IRQ_MODE 0x12 // Interrupt Request mode -#define SVC_MODE 0x13 // Supervisor mode -#define ABT_MODE 0x17 // Abort mode -#define UND_MODE 0x1B // Undefined Instruction mode -#define SYS_MODE 0x1F // System mode +#define USR_MODE 0x10 // User mode +#define FIQ_MODE 0x11 // Fast Interrupt Request mode +#define IRQ_MODE 0x12 // Interrupt Request mode +#define SVC_MODE 0x13 // Supervisor mode +#define ABT_MODE 0x17 // Abort mode +#define UND_MODE 0x1B // Undefined Instruction mode +#define SYS_MODE 0x1F // System mode /*---------------------------------------------------------------------------- Internal References *----------------------------------------------------------------------------*/ -void Vectors (void) __attribute__ ((naked, target("arm"), section(".vectors"))); -void Reset_Handler (void) __attribute__ ((naked, section(".boot_loader"))); +void Vectors(void) __attribute__((naked, target("arm"), section(".vectors"))); +void Reset_Handler(void) __attribute__((naked, section(".boot_loader"))); /*---------------------------------------------------------------------------- Exception / Interrupt Handler *----------------------------------------------------------------------------*/ -void Undef_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); -void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); -void PAbt_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); -void DAbt_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); -void IRQ_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); -void FIQ_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Undef_Handler(void) __attribute__((weak, alias("Default_Handler"))); +void SVC_Handler(void) __attribute__((weak, alias("Default_Handler"))); +void PAbt_Handler(void) __attribute__((weak, alias("Default_Handler"))); +void DAbt_Handler(void) __attribute__((weak, alias("Default_Handler"))); +void IRQ_Handler(void) __attribute__((weak, alias("Default_Handler"))); +void FIQ_Handler(void) __attribute__((weak, alias("Default_Handler"))); /*---------------------------------------------------------------------------- Exception / Interrupt Vector Table *----------------------------------------------------------------------------*/ void Vectors(void) { - __ASM volatile( - "LDR PC, ResetVectorPtr \n" - "LDR PC, UndefVectorPtr \n" - "LDR PC, SVCVectorPtr \n" - "LDR PC, PAbtVectorPtr \n" - "LDR PC, DAbtVectorPtr \n" - "LDR PC, HypVectorPtr \n" - "LDR PC, IRQVectorPtr \n" - "LDR PC, FIQVectorPtr \n" - "ResetVectorPtr: .LONG Init_Handler \n" - "UndefVectorPtr: .LONG Init_Handler \n" - "SVCVectorPtr: .LONG Init_Handler \n" - "PAbtVectorPtr: .LONG Init_Handler \n" - "DAbtVectorPtr: .LONG Init_Handler \n" - "HypVectorPtr: .LONG Init_Handler \n" - "IRQVectorPtr: .LONG Init_Handler \n" - "FIQVectorPtr: .LONG Init_Handler \n" - "Init_Handler: b Init_Handler \n" - ); + __ASM volatile("LDR PC, ResetVectorPtr \n" + "LDR PC, UndefVectorPtr \n" + "LDR PC, SVCVectorPtr \n" + "LDR PC, PAbtVectorPtr \n" + "LDR PC, DAbtVectorPtr \n" + "LDR PC, HypVectorPtr \n" + "LDR PC, IRQVectorPtr \n" + "LDR PC, FIQVectorPtr \n" + "ResetVectorPtr: .LONG Init_Handler \n" + "UndefVectorPtr: .LONG Init_Handler \n" + "SVCVectorPtr: .LONG Init_Handler \n" + "PAbtVectorPtr: .LONG Init_Handler \n" + "DAbtVectorPtr: .LONG Init_Handler \n" + "HypVectorPtr: .LONG Init_Handler \n" + "IRQVectorPtr: .LONG Init_Handler \n" + "FIQVectorPtr: .LONG Init_Handler \n" + "Init_Handler: b Init_Handler \n"); } /*---------------------------------------------------------------------------- @@ -86,66 +84,82 @@ void Vectors(void) { void Reset_Handler(void) { __ASM volatile( - // Mask interrupts - "CPSID if \n" + // Mask interrupts + "CPSID if \n" - // Put any cores other than 0 to sleep - "MRC p15, 0, R0, c0, c0, 5 \n" // Read MPIDR - "ANDS R0, R0, #3 \n" - "goToSleep: \n" - "IT NE \n" - "WFINE \n" - "BNE goToSleep \n" + // Put any cores other than 0 to sleep + "MRC p15, 0, R0, c0, c0, 5 \n" // Read MPIDR + "ANDS R0, R0, #3 \n" + "goToSleep: \n" + "IT NE \n" + "WFINE \n" + "BNE goToSleep \n" - // Reset SCTLR Settings - "MRC p15, 0, R0, c1, c0, 0 \n" // Read CP15 System Control register - "BIC R0, R0, #(0x1 << 12) \n" // Clear I bit 12 to disable I Cache - "BIC R0, R0, #(0x1 << 2) \n" // Clear C bit 2 to disable D Cache - "BIC R0, R0, #0x1 \n" // Clear M bit 0 to disable MMU - "BIC R0, R0, #(0x1 << 11) \n" // Clear Z bit 11 to disable branch prediction - "BIC R0, R0, #(0x1 << 13) \n" // Clear V bit 13 to disable hivecs - "MCR p15, 0, R0, c1, c0, 0 \n" // Write value back to CP15 System Control register - "ISB \n" + // Reset SCTLR Settings + "MRC p15, 0, R0, c1, c0, 0 \n" // Read CP15 System + // Control register + "BIC R0, R0, #(0x1 << 12) \n" // Clear I bit 12 to + // disable I Cache + "BIC R0, R0, #(0x1 << 2) \n" // Clear C bit 2 to + // disable D Cache + "BIC R0, R0, #0x1 \n" // Clear M bit 0 to + // disable MMU + "BIC R0, R0, #(0x1 << 11) \n" // Clear Z bit 11 to + // disable branch + // prediction + "BIC R0, R0, #(0x1 << 13) \n" // Clear V bit 13 to + // disable hivecs + "MCR p15, 0, R0, c1, c0, 0 \n" // Write value back + // to CP15 System + // Control register + "ISB \n" - // Configure ACTLR - "MRC p15, 0, r0, c1, c0, 1 \n" // Read CP15 Auxiliary Control Register - //"ORR r0, r0, #(1 << 1) \n" // Enable L2 prefetch hint (UNK/WI since r4p1) - "ORR r0, r0, #(1 << 6) \n" // Enable SMP - "MCR p15, 0, r0, c1, c0, 1 \n" // Write CP15 Auxiliary Control Register + // Configure ACTLR + "MRC p15, 0, r0, c1, c0, 1 \n" // Read CP15 + // Auxiliary Control + // Register + //"ORR r0, r0, #(1 << 1) \n" // Enable L2 + // prefetch hint (UNK/WI since r4p1) + "ORR r0, r0, #(1 << 6) \n" // Enable SMP + "MCR p15, 0, r0, c1, c0, 1 \n" // Write CP15 + // Auxiliary Control + // Register - // Set Vector Base Address Register (VBAR) to point to this application's vector table - //"LDR R0, =Vectors \n" - "LDR R0, =" _TO_STRING(DSP_BOOT_REG) " \n" - "MCR p15, 0, R0, c12, c0, 0 \n" + // Set Vector Base Address Register (VBAR) to point to this application's + // vector table + //"LDR R0, =Vectors \n" + "LDR R0, =" _TO_STRING( + DSP_BOOT_REG) " \n" + "MCR p15, 0, R0, c12, c0, 0 \n" - // Setup Stack for each exceptional mode - "CPS #0x11 \n" - "LDR SP, =Image$$FIQ_STACK$$ZI$$Limit \n" - "CPS #0x12 \n" - "LDR SP, =Image$$IRQ_STACK$$ZI$$Limit \n" - "CPS #0x13 \n" - "LDR SP, =Image$$SVC_STACK$$ZI$$Limit \n" - "CPS #0x17 \n" - "LDR SP, =Image$$ABT_STACK$$ZI$$Limit \n" - "CPS #0x1B \n" - "LDR SP, =Image$$UND_STACK$$ZI$$Limit \n" - "CPS #0x1F \n" - "LDR SP, =Image$$SYS_STACK$$ZI$$Limit \n" + // Setup Stack for each exceptional mode + "CPS #0x11 \n" + "LDR SP, =Image$$FIQ_STACK$$ZI$$Limit \n" + "CPS #0x12 \n" + "LDR SP, =Image$$IRQ_STACK$$ZI$$Limit \n" + "CPS #0x13 \n" + "LDR SP, =Image$$SVC_STACK$$ZI$$Limit \n" + "CPS #0x17 \n" + "LDR SP, =Image$$ABT_STACK$$ZI$$Limit \n" + "CPS #0x1B \n" + "LDR SP, =Image$$UND_STACK$$ZI$$Limit \n" + "CPS #0x1F \n" + "LDR SP, =Image$$SYS_STACK$$ZI$$Limit \n" - // Call SystemInit - "BL SystemInit \n" + // Call SystemInit + "BL SystemInit \n" - // Unmask interrupts - "CPSIE if \n" + // Unmask interrupts + "CPSIE if \n" - // Call __main - "BL _start \n" - ); + // Call __main + "BL _start \n"); } /*---------------------------------------------------------------------------- Default Handler for Exceptions / Interrupts *----------------------------------------------------------------------------*/ void Default_Handler(void) { - while(1); + while (1) + ; } diff --git a/platform/cmsis/ca/system_ARMCA.c b/platform/cmsis/ca/system_ARMCA.c index eef3457..52c9cd9 100644 --- a/platform/cmsis/ca/system_ARMCA.c +++ b/platform/cmsis/ca/system_ARMCA.c @@ -25,11 +25,11 @@ * limitations under the License. */ -#include "cmsis_nvic.h" #include "ca/system_ARMCA.h" #include "ca/irq_ctrl.h" -#include "hal_location.h" +#include "cmsis_nvic.h" #include "hal_cmu.h" +#include "hal_location.h" extern uint32_t __sram_text_data_start_load__[]; extern uint32_t __sram_text_data_end_load__[]; @@ -47,44 +47,41 @@ extern uint32_t __psramuhs_text_start[]; /*---------------------------------------------------------------------------- System Initialization *----------------------------------------------------------------------------*/ -void SystemInit (void) -{ - uint32_t *dst, *src; +void SystemInit(void) { + uint32_t *dst, *src; - if (__sram_text_data_start__ != __sram_text_data_start_load__) { - for (dst = __sram_text_data_start__, src = __sram_text_data_start_load__; - src < __sram_text_data_end_load__; - dst++, src++) { - *dst = *src; - } + if (__sram_text_data_start__ != __sram_text_data_start_load__) { + for (dst = __sram_text_data_start__, src = __sram_text_data_start_load__; + src < __sram_text_data_end_load__; dst++, src++) { + *dst = *src; } + } - hal_cmu_dsp_setup(); - /*psramhus_test load region covers sram_bss, and it needs to be copyed first*/ + hal_cmu_dsp_setup(); + /*psramhus_test load region covers sram_bss, and it needs to be copyed first*/ #if defined(CHIP_HAS_PSRAMUHS) && defined(PSRAMUHS_ENABLE) - for (dst = __psramuhs_text_start, src = __psramuhs_text_data_start_load__; - src < __psramuhs_text_data_end_load__; - dst++, src++) { - *dst = *src; - } + for (dst = __psramuhs_text_start, src = __psramuhs_text_data_start_load__; + src < __psramuhs_text_data_end_load__; dst++, src++) { + *dst = *src; + } #endif - for (dst = __sram_bss_start__; dst < __sram_bss_end__; dst++) { - *dst = 0; - } + for (dst = __sram_bss_start__; dst < __sram_bss_end__; dst++) { + *dst = 0; + } #ifdef NOSTD - for (dst = __bss_start__; dst < __bss_end__; dst++) { - *dst = 0; - } + for (dst = __bss_start__; dst < __bss_end__; dst++) { + *dst = 0; + } #endif - for (dst = __sync_flags_start; dst < __sync_flags_end; dst++) { - *dst = 0; - } + for (dst = __sync_flags_start; dst < __sync_flags_end; dst++) { + *dst = 0; + } -/* do not use global variables because this function is called before - reaching pre-main. RW section may be overwritten afterwards. */ + /* do not use global variables because this function is called before + reaching pre-main. RW section may be overwritten afterwards. */ // Init exception vectors GIC_InitVectors(); @@ -129,8 +126,4 @@ void SystemInit (void) IRQ_Initialize(); } -uint32_t BOOT_TEXT_SRAM_DEF(get_cpu_id) (void) -{ - return __get_MPIDR() & 3; -} - +uint32_t BOOT_TEXT_SRAM_DEF(get_cpu_id)(void) { return __get_MPIDR() & 3; } diff --git a/platform/cmsis/cmsis_nvic.c b/platform/cmsis/cmsis_nvic.c index 468a72c..96d747e 100644 --- a/platform/cmsis/cmsis_nvic.c +++ b/platform/cmsis/cmsis_nvic.c @@ -18,53 +18,54 @@ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + *ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + *LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + *CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + *SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + *INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + *CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + *ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + *POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ #ifndef __ARM_ARCH_ISA_ARM #include "cmsis_nvic.h" -#include "plat_types.h" -#include "plat_addr_map.h" #include "hal_location.h" +#include "plat_addr_map.h" +#include "plat_types.h" #ifdef __ARMCC_VERSION #include "link_sym_armclang.h" #endif -STATIC_ASSERT(NVIC_NUM_VECTORS * 4 <= VECTOR_SECTION_SIZE, "ERROR: VECTOR_SECTION_SIZE too small!"); +STATIC_ASSERT(NVIC_NUM_VECTORS * 4 <= VECTOR_SECTION_SIZE, + "ERROR: VECTOR_SECTION_SIZE too small!"); -// The vector table must be aligned to NVIC_NUM_VECTORS-word boundary, rounding up to the next power of two +// The vector table must be aligned to NVIC_NUM_VECTORS-word boundary, rounding +// up to the next power of two // -- 0x100 for 33~64 vectors, and 0x200 for 65~128 vectors #ifdef __ARMCC_VERSION -#define VECTOR_LOC __attribute__((section(".bss.vector_table"))) +#define VECTOR_LOC __attribute__((section(".bss.vector_table"))) #else -#define VECTOR_LOC __attribute__((section(".vector_table"))) +#define VECTOR_LOC __attribute__((section(".vector_table"))) #endif -#define FAULT_HANDLER __attribute__((weak,alias("NVIC_default_handler"))) +#define FAULT_HANDLER __attribute__((weak, alias("NVIC_default_handler"))) static uint32_t VECTOR_LOC vector_table[NVIC_NUM_VECTORS]; -void NVIC_DisableAllIRQs(void) -{ - int i; +void NVIC_DisableAllIRQs(void) { + int i; - for (i = 0; i < (USER_IRQn_QTY + 31) / 32; i++) { - NVIC->ICER[i] = ~0UL; - } - SCB->VTOR = 0; + for (i = 0; i < (USER_IRQn_QTY + 31) / 32; i++) { + NVIC->ICER[i] = ~0UL; + } + SCB->VTOR = 0; } -static void NAKED BOOT_TEXT_FLASH_LOC NVIC_default_handler(void) -{ - asm volatile("_loop:; nop; nop; nop; nop; b _loop;"); +static void NAKED BOOT_TEXT_FLASH_LOC NVIC_default_handler(void) { + asm volatile("_loop:; nop; nop; nop; nop; b _loop;"); } void FAULT_HANDLER Reset_Handler(void); @@ -81,141 +82,132 @@ void FAULT_HANDLER SysTick_Handler(void); extern uint32_t __rom_stack[]; extern uint32_t __stack[]; -static const uint32_t BOOT_RODATA_FLASH_LOC fault_handlers[NVIC_USER_IRQ_OFFSET] = { +static const uint32_t BOOT_RODATA_FLASH_LOC + fault_handlers[NVIC_USER_IRQ_OFFSET] = { #if defined(ROM_BUILD) && !defined(ROM_IN_FLASH) - (uint32_t)__rom_stack, + (uint32_t)__rom_stack, #else (uint32_t)__stack, #endif - (uint32_t)Reset_Handler, - (uint32_t)NMI_Handler, - (uint32_t)HardFault_Handler, - (uint32_t)MemManage_Handler, - (uint32_t)BusFault_Handler, - (uint32_t)UsageFault_Handler, - (uint32_t)SecureFault_Handler, - (uint32_t)NVIC_default_handler, - (uint32_t)NVIC_default_handler, - (uint32_t)NVIC_default_handler, - (uint32_t)SVC_Handler, - (uint32_t)DebugMon_Handler, - (uint32_t)NVIC_default_handler, - (uint32_t)PendSV_Handler, - (uint32_t)SysTick_Handler, + (uint32_t)Reset_Handler, (uint32_t)NMI_Handler, + (uint32_t)HardFault_Handler, (uint32_t)MemManage_Handler, + (uint32_t)BusFault_Handler, (uint32_t)UsageFault_Handler, + (uint32_t)SecureFault_Handler, (uint32_t)NVIC_default_handler, + (uint32_t)NVIC_default_handler, (uint32_t)NVIC_default_handler, + (uint32_t)SVC_Handler, (uint32_t)DebugMon_Handler, + (uint32_t)NVIC_default_handler, (uint32_t)PendSV_Handler, + (uint32_t)SysTick_Handler, }; -void BOOT_TEXT_FLASH_LOC NVIC_InitVectors(void) -{ - int i; +void BOOT_TEXT_FLASH_LOC NVIC_InitVectors(void) { + int i; - for (i = 0; i < NVIC_NUM_VECTORS; i++) { - vector_table[i] = (i < ARRAY_SIZE(fault_handlers)) ? - fault_handlers[i] : (uint32_t)NVIC_default_handler; - } + for (i = 0; i < NVIC_NUM_VECTORS; i++) { + vector_table[i] = (i < ARRAY_SIZE(fault_handlers)) + ? fault_handlers[i] + : (uint32_t)NVIC_default_handler; + } - SCB->VTOR = (uint32_t)vector_table; - __DSB(); + SCB->VTOR = (uint32_t)vector_table; + __DSB(); } -void NVIC_SetDefaultFaultHandler(NVIC_DEFAULT_FAULT_HANDLER_T handler) -{ - int i; +void NVIC_SetDefaultFaultHandler(NVIC_DEFAULT_FAULT_HANDLER_T handler) { + int i; - for (i = 1; i < ARRAY_SIZE(fault_handlers); i++) { - if (vector_table[i] == (uint32_t)NVIC_default_handler) { - vector_table[i] = (uint32_t)handler; - } + for (i = 1; i < ARRAY_SIZE(fault_handlers); i++) { + if (vector_table[i] == (uint32_t)NVIC_default_handler) { + vector_table[i] = (uint32_t)handler; } + } } -IRQn_Type NVIC_GetCurrentActiveIRQ(void) -{ - IRQn_Type irq = (__get_IPSR() & IPSR_ISR_Msk) - NVIC_USER_IRQ_OFFSET; - return irq; +IRQn_Type NVIC_GetCurrentActiveIRQ(void) { + IRQn_Type irq = (__get_IPSR() & IPSR_ISR_Msk) - NVIC_USER_IRQ_OFFSET; + return irq; } #ifdef CORE_SLEEP_POWER_DOWN -void SRAM_TEXT_LOC NVIC_PowerDownSleep(uint32_t *buf, uint32_t cnt) -{ - int i; - uint32_t idx; - __IO uint32_t *regs; +void SRAM_TEXT_LOC NVIC_PowerDownSleep(uint32_t *buf, uint32_t cnt) { + int i; + uint32_t idx; + __IO uint32_t *regs; - idx = 0; - for (i = 0; i < (NVIC_NUM_VECTORS - NVIC_USER_IRQ_OFFSET + 31) / 32; i++) { - buf[idx++] = NVIC->ISER[i]; - } + idx = 0; + for (i = 0; i < (NVIC_NUM_VECTORS - NVIC_USER_IRQ_OFFSET + 31) / 32; i++) { + buf[idx++] = NVIC->ISER[i]; + } #if (__CORTEX_M <= 4) - regs = (__IO uint32_t *)&NVIC->IP[0]; + regs = (__IO uint32_t *)&NVIC->IP[0]; #else - regs = (__IO uint32_t *)&NVIC->IPR[0]; + regs = (__IO uint32_t *)&NVIC->IPR[0]; #endif - for (i = 0; i < (NVIC_NUM_VECTORS - NVIC_USER_IRQ_OFFSET + 3) / 4; i++) { - buf[idx++] = regs[i]; - } - buf[idx++] = SCnSCB->ACTLR; - buf[idx++] = SCB->ICSR; - buf[idx++] = SCB->AIRCR; - buf[idx++] = SCB->SCR; - buf[idx++] = SCB->CCR; + for (i = 0; i < (NVIC_NUM_VECTORS - NVIC_USER_IRQ_OFFSET + 3) / 4; i++) { + buf[idx++] = regs[i]; + } + buf[idx++] = SCnSCB->ACTLR; + buf[idx++] = SCB->ICSR; + buf[idx++] = SCB->AIRCR; + buf[idx++] = SCB->SCR; + buf[idx++] = SCB->CCR; #if (__CORTEX_M <= 4) - regs = (__IO uint32_t *)&SCB->SHP[0]; + regs = (__IO uint32_t *)&SCB->SHP[0]; #else - regs = (__IO uint32_t *)&SCB->SHPR[0]; + regs = (__IO uint32_t *)&SCB->SHPR[0]; #endif - buf[idx++] = regs[0]; - buf[idx++] = regs[1]; - buf[idx++] = regs[2]; - buf[idx++] = SCB->SHCSR; - buf[idx++] = SysTick->CTRL; - buf[idx++] = SysTick->LOAD; + buf[idx++] = regs[0]; + buf[idx++] = regs[1]; + buf[idx++] = regs[2]; + buf[idx++] = SCB->SHCSR; + buf[idx++] = SysTick->CTRL; + buf[idx++] = SysTick->LOAD; - if (idx > cnt) { - do { asm volatile("nop \n nop \n nop \n nop"); } while (1); - } + if (idx > cnt) { + do { + asm volatile("nop \n nop \n nop \n nop"); + } while (1); + } } -void SRAM_TEXT_LOC NVIC_PowerDownWakeup(uint32_t *buf, uint32_t cnt) -{ - int i; - uint32_t idx; - __IO uint32_t *regs; +void SRAM_TEXT_LOC NVIC_PowerDownWakeup(uint32_t *buf, uint32_t cnt) { + int i; + uint32_t idx; + __IO uint32_t *regs; - idx = 0; - for (i = 0; i < (NVIC_NUM_VECTORS - NVIC_USER_IRQ_OFFSET + 31) / 32; i++) { - NVIC->ISER[i] = buf[idx++]; - } + idx = 0; + for (i = 0; i < (NVIC_NUM_VECTORS - NVIC_USER_IRQ_OFFSET + 31) / 32; i++) { + NVIC->ISER[i] = buf[idx++]; + } #if (__CORTEX_M <= 4) - regs = (__IO uint32_t *)&NVIC->IP[0]; + regs = (__IO uint32_t *)&NVIC->IP[0]; #else - regs = (__IO uint32_t *)&NVIC->IPR[0]; + regs = (__IO uint32_t *)&NVIC->IPR[0]; #endif - for (i = 0; i < (NVIC_NUM_VECTORS - NVIC_USER_IRQ_OFFSET + 3) / 4; i++) { - regs[i] = buf[idx++]; - } - SCnSCB->ACTLR = buf[idx++]; - SCB->ICSR = buf[idx++]; - SCB->AIRCR = buf[idx++]; - SCB->SCR = buf[idx++]; - SCB->CCR = buf[idx++]; + for (i = 0; i < (NVIC_NUM_VECTORS - NVIC_USER_IRQ_OFFSET + 3) / 4; i++) { + regs[i] = buf[idx++]; + } + SCnSCB->ACTLR = buf[idx++]; + SCB->ICSR = buf[idx++]; + SCB->AIRCR = buf[idx++]; + SCB->SCR = buf[idx++]; + SCB->CCR = buf[idx++]; #if (__CORTEX_M <= 4) - regs = (__IO uint32_t *)&SCB->SHP[0]; + regs = (__IO uint32_t *)&SCB->SHP[0]; #else - regs = (__IO uint32_t *)&SCB->SHPR[0]; + regs = (__IO uint32_t *)&SCB->SHPR[0]; #endif - regs[0] = buf[idx++]; - regs[1] = buf[idx++]; - regs[2] = buf[idx++]; - SCB->SHCSR = buf[idx++]; - SysTick->CTRL = buf[idx++]; - SysTick->LOAD = buf[idx++]; + regs[0] = buf[idx++]; + regs[1] = buf[idx++]; + regs[2] = buf[idx++]; + SCB->SHCSR = buf[idx++]; + SysTick->CTRL = buf[idx++]; + SysTick->LOAD = buf[idx++]; - SCB->VTOR = (uint32_t)vector_table; - SysTick->VAL = 0; + SCB->VTOR = (uint32_t)vector_table; + SysTick->VAL = 0; } #endif #endif - diff --git a/platform/cmsis/inc/system_ARMCM.h b/platform/cmsis/inc/system_ARMCM.h index 5a987f1..60fe55c 100644 --- a/platform/cmsis/inc/system_ARMCM.h +++ b/platform/cmsis/inc/system_ARMCM.h @@ -15,14 +15,14 @@ ****************************************************************************/ #ifndef __SYSTEM_ARMCM_H__ #define __SYSTEM_ARMCM_H__ - +#include "cmsis_compiler.h" #ifdef __cplusplus extern "C" { #endif #include "stdbool.h" -void SystemInit (void); +void SystemInit(void); #ifdef UNALIGNED_ACCESS @@ -45,4 +45,3 @@ uint32_t get_cpu_id(void); #endif #endif - diff --git a/platform/cmsis/mpu_armv7m.c b/platform/cmsis/mpu_armv7m.c index 8c72883..93f5985 100644 --- a/platform/cmsis/mpu_armv7m.c +++ b/platform/cmsis/mpu_armv7m.c @@ -15,97 +15,94 @@ ****************************************************************************/ #ifndef __ARM_ARCH_ISA_ARM -#include "mpu.h" #include "cmsis.h" #include "hal_trace.h" +#include "mpu.h" -int mpu_open(void) -{ - int i; +int mpu_open(void) { + int i; - if ((MPU->TYPE & MPU_TYPE_DREGION_Msk) == 0) { - return 1; - } + if ((MPU->TYPE & MPU_TYPE_DREGION_Msk) == 0) { + return 1; + } - ARM_MPU_Disable(); + ARM_MPU_Disable(); - for (i = 0; i < MPU_ID_QTY; i++) { - ARM_MPU_ClrRegion(i); - } + for (i = 0; i < MPU_ID_QTY; i++) { + ARM_MPU_ClrRegion(i); + } - ARM_MPU_Enable(MPU_CTRL_PRIVDEFENA_Msk); + ARM_MPU_Enable(MPU_CTRL_PRIVDEFENA_Msk); - return 0; + return 0; } -int mpu_close(void) -{ - ARM_MPU_Disable(); +int mpu_close(void) { + ARM_MPU_Disable(); - return 0; + return 0; } static int mpu_set_armv7(enum MPU_ID_T id, uint32_t addr, uint32_t len, - int srd_bits, enum MPU_ATTR_T attr) -{ - int ret; - uint32_t rbar; - uint32_t rasr; - uint8_t xn; - uint8_t ap; - uint8_t size; + int srd_bits, enum MPU_ATTR_T attr) { + int ret; + uint32_t rbar; + uint32_t rasr; + uint8_t xn; + uint8_t ap; + uint8_t size; - if ((MPU->CTRL & MPU_CTRL_ENABLE_Msk) == 0) { - ret = mpu_open(); - if (ret) { - return ret; - } + if ((MPU->CTRL & MPU_CTRL_ENABLE_Msk) == 0) { + ret = mpu_open(); + if (ret) { + return ret; } + } - if (id >= MPU_ID_QTY) { - return 2; - } - if (len < 32 || (len & (len - 1))) { - return 3; - } - if (addr & (len - 1)) { - return 4; - } - if (attr >= MPU_ATTR_QTY) { - return 5; - } + if (id >= MPU_ID_QTY) { + return 2; + } + if (len < 32 || (len & (len - 1))) { + return 3; + } + if (addr & (len - 1)) { + return 4; + } + if (attr >= MPU_ATTR_QTY) { + return 5; + } - if (attr == MPU_ATTR_READ_WRITE_EXEC || attr == MPU_ATTR_READ_EXEC || - attr == MPU_ATTR_EXEC) { - xn = 0; - } else { - xn = 1; - } + if (attr == MPU_ATTR_READ_WRITE_EXEC || attr == MPU_ATTR_READ_EXEC || + attr == MPU_ATTR_EXEC) { + xn = 0; + } else { + xn = 1; + } - ap = ARM_MPU_AP_NONE; - if (attr == MPU_ATTR_READ_WRITE_EXEC || attr == MPU_ATTR_READ_WRITE) { - ap = ARM_MPU_AP_FULL; - } else if (attr == MPU_ATTR_READ_EXEC || attr == MPU_ATTR_READ) { - ap = ARM_MPU_AP_RO; - } + ap = ARM_MPU_AP_NONE; + if (attr == MPU_ATTR_READ_WRITE_EXEC || attr == MPU_ATTR_READ_WRITE) { + ap = ARM_MPU_AP_FULL; + } else if (attr == MPU_ATTR_READ_EXEC || attr == MPU_ATTR_READ) { + ap = ARM_MPU_AP_RO; + } - size = __CLZ(__RBIT(len)) - 1; + size = __CLZ(__RBIT(len)) - 1; - ARM_MPU_Disable(); - rbar = ARM_MPU_RBAR(id, addr); - // Type Extention: 0 - // Shareable: 1 - // Cacheable: 1 - // Bufferable: 1 - // Subregion: 0 - rasr = ARM_MPU_RASR(xn, ap, 0, 1, 1, 1, srd_bits, size); + ARM_MPU_Disable(); + rbar = ARM_MPU_RBAR(id, addr); + // Type Extention: 0 + // Shareable: 1 + // Cacheable: 1 + // Bufferable: 1 + // Subregion: 0 + rasr = ARM_MPU_RASR(xn, ap, 0, 1, 1, 1, srd_bits, size); - ARM_MPU_SetRegion(rbar, rasr); - ARM_MPU_Enable(MPU_CTRL_PRIVDEFENA_Msk); - __DSB(); - __ISB(); + ARM_MPU_SetRegion(rbar, rasr); + ARM_MPU_Enable(MPU_CTRL_PRIVDEFENA_Msk); + __DSB(); + __ISB(); - return 0; + return 0; } /* @@ -115,52 +112,48 @@ static int mpu_set_armv7(enum MPU_ID_T id, uint32_t addr, uint32_t len, * if it is 0b11110000, the bottom 4 sub region will be disabled. */ static int mpu_get_top_srd(uint32_t rg_end, uint32_t fr_end, - uint32_t sub_rg_sz) -{ - int dis_nums; - uint8_t srd_bits; + uint32_t sub_rg_sz) { + int dis_nums; + uint8_t srd_bits; - dis_nums = (rg_end - fr_end) / sub_rg_sz; - if ((fr_end & (sub_rg_sz - 1)) != 0) - dis_nums += 1; + dis_nums = (rg_end - fr_end) / sub_rg_sz; + if ((fr_end & (sub_rg_sz - 1)) != 0) + dis_nums += 1; - srd_bits = 0xff; - srd_bits &= ~((1UL << (8 - dis_nums)) - 1); + srd_bits = 0xff; + srd_bits &= ~((1UL << (8 - dis_nums)) - 1); - return srd_bits; + return srd_bits; } static int mpu_get_bottom_srd(uint32_t rg_start, uint32_t fr_start, - uint32_t sub_rg_sz) -{ - int dis_nums; - uint8_t srd_bits; + uint32_t sub_rg_sz) { + int dis_nums; + uint8_t srd_bits; - dis_nums = (fr_start - rg_start) / sub_rg_sz; - srd_bits = 0xff; - srd_bits &= ((1UL << dis_nums) - 1); + dis_nums = (fr_start - rg_start) / sub_rg_sz; + srd_bits = 0xff; + srd_bits &= ((1UL << dis_nums) - 1); - return srd_bits; + return srd_bits; } -static int calc_sub_region_size(uint32_t fr_start) -{ - int lsb_bit; - uint32_t sz; +static int calc_sub_region_size(uint32_t fr_start) { + int lsb_bit; + uint32_t sz; - //sub region size aligned to fram start - lsb_bit = get_lsb_pos(fr_start); - sz = 1 << lsb_bit; - if (sz < 0x80) { - /*cortex-m4 doesn't support sub region size less than 128 */ - TRACE(1,"no mpu region for fram start %x", fr_start); - return -1; - } - if (sz > 0x4000) - sz = 0x4000; + // sub region size aligned to fram start + lsb_bit = get_lsb_pos(fr_start); + sz = 1 << lsb_bit; + if (sz < 0x80) { + /*cortex-m4 doesn't support sub region size less than 128 */ + TRACE(1, "no mpu region for fram start %x", fr_start); + return -1; + } + if (sz > 0x4000) + sz = 0x4000; - - return sz; + return sz; } /* @@ -196,115 +189,111 @@ The layout like: If the __fast_sram_text_exec_end__ exceed the region2's end, just leave the rest unprotect. */ -static int mpu_fram_protect_armv7(uint32_t fr_start, uint32_t fr_end) -{ - uint32_t fr_sz; - uint32_t sub_rg_sz; - uint32_t rg_sz; - uint32_t rg_start; - uint32_t rg_end; - int ret = 0; - int srd_bits; - int finished = 0; +static int mpu_fram_protect_armv7(uint32_t fr_start, uint32_t fr_end) { + uint32_t fr_sz; + uint32_t sub_rg_sz; + uint32_t rg_sz; + uint32_t rg_start; + uint32_t rg_end; + int ret = 0; + int srd_bits; + int finished = 0; - fr_sz = fr_end - fr_start; - sub_rg_sz = calc_sub_region_size(fr_start); - if (sub_rg_sz < 0) - return -1; + fr_sz = fr_end - fr_start; + sub_rg_sz = calc_sub_region_size(fr_start); + if (sub_rg_sz < 0) + return -1; - /* according to cortex-m4 spec, the region is divived to 8 sub region*/ - rg_sz = sub_rg_sz * 8; - /*now we just protect two region */ - if (fr_sz > (rg_sz * 2)) { - TRACE(0,"Warning fram is too big, mpu can not protect so much"); - TRACE(2,"region_sz %x, fram size %x", rg_sz, fr_sz); - } + /* according to cortex-m4 spec, the region is divived to 8 sub region*/ + rg_sz = sub_rg_sz * 8; + /*now we just protect two region */ + if (fr_sz > (rg_sz * 2)) { + TRACE(0, "Warning fram is too big, mpu can not protect so much"); + TRACE(2, "region_sz %x, fram size %x", rg_sz, fr_sz); + } - /*aliged the region start to region size according to cortext m4 spec*/ - srd_bits = 0; - rg_start = fr_start & ~(rg_sz - 1); - if (fr_start > rg_start) { - int b_srd_bits = 0; + /*aliged the region start to region size according to cortext m4 spec*/ + srd_bits = 0; + rg_start = fr_start & ~(rg_sz - 1); + if (fr_start > rg_start) { + int b_srd_bits = 0; - b_srd_bits = mpu_get_bottom_srd(rg_start, fr_start, sub_rg_sz); - srd_bits |= b_srd_bits; - } + b_srd_bits = mpu_get_bottom_srd(rg_start, fr_start, sub_rg_sz); + srd_bits |= b_srd_bits; + } - rg_end = rg_start + rg_sz; - if (fr_end < rg_end) { - int t_srd_bits = 0; + rg_end = rg_start + rg_sz; + if (fr_end < rg_end) { + int t_srd_bits = 0; - t_srd_bits = mpu_get_top_srd(rg_end, fr_end, sub_rg_sz); - srd_bits |= t_srd_bits; - finished = 1; - } + t_srd_bits = mpu_get_top_srd(rg_end, fr_end, sub_rg_sz); + srd_bits |= t_srd_bits; + finished = 1; + } - ret = mpu_set(MPU_ID_FRAM_TEXT1, rg_start, rg_sz, srd_bits, MPU_ATTR_READ); - if (ret || finished) - goto out; + ret = mpu_set(MPU_ID_FRAM_TEXT1, rg_start, rg_sz, srd_bits, MPU_ATTR_READ); + if (ret || finished) + goto out; - /* need another section, and start from next region*/ - rg_start += rg_sz; + /* need another section, and start from next region*/ + rg_start += rg_sz; - srd_bits = 0; - rg_end = rg_start + rg_sz; - if (fr_end < rg_end) { - srd_bits = mpu_get_top_srd(rg_end, fr_end, sub_rg_sz); - } + srd_bits = 0; + rg_end = rg_start + rg_sz; + if (fr_end < rg_end) { + srd_bits = mpu_get_top_srd(rg_end, fr_end, sub_rg_sz); + } - ret = mpu_set(MPU_ID_FRAM_TEXT2, rg_start, rg_sz, srd_bits, MPU_ATTR_READ_EXEC); - /* if fr_end large than two section, just pass */ + ret = + mpu_set(MPU_ID_FRAM_TEXT2, rg_start, rg_sz, srd_bits, MPU_ATTR_READ_EXEC); + /* if fr_end large than two section, just pass */ out: - return ret; + return ret; } int mpu_set(enum MPU_ID_T id, uint32_t addr, uint32_t len, int srd_bits, - enum MPU_ATTR_T attr) -{ - return mpu_set_armv7(id, addr, len, srd_bits, attr); + enum MPU_ATTR_T attr) { + return mpu_set_armv7(id, addr, len, srd_bits, attr); } -int mpu_clear(enum MPU_ID_T id) -{ - uint32_t lock; +int mpu_clear(enum MPU_ID_T id) { + uint32_t lock; - if (id >= MPU_ID_QTY) { - return 2; - } + if (id >= MPU_ID_QTY) { + return 2; + } - lock = int_lock(); + lock = int_lock(); - ARM_MPU_ClrRegion(id); - __DSB(); - __ISB(); + ARM_MPU_ClrRegion(id); + __DSB(); + __ISB(); - int_unlock(lock); + int_unlock(lock); - return 0; + return 0; } -static int mpu_null_check_enable(void) -{ +static int mpu_null_check_enable(void) { #ifdef CHIP_BEST1000 - uint32_t len = 0x400; + uint32_t len = 0x400; #else - uint32_t len = 0x800; + uint32_t len = 0x800; #endif - return mpu_set(MPU_ID_NULL_POINTER, 0, len, 0, MPU_ATTR_NO_ACCESS); + return mpu_set(MPU_ID_NULL_POINTER, 0, len, 0, MPU_ATTR_NO_ACCESS); } extern uint32_t __fast_sram_text_exec_start__[]; extern uint32_t __fast_sram_text_exec_end__[]; -static int mpu_fast_ram_protect(void) -{ - uint32_t ramx_start = (uint32_t)__fast_sram_text_exec_start__; - uint32_t ramx_end = (uint32_t)__fast_sram_text_exec_end__; - uint32_t ram_start = RAMX_TO_RAM(ramx_start); - uint32_t ram_end = RAMX_TO_RAM(ramx_end); +static int mpu_fast_ram_protect(void) { + uint32_t ramx_start = (uint32_t)__fast_sram_text_exec_start__; + uint32_t ramx_end = (uint32_t)__fast_sram_text_exec_end__; + uint32_t ram_start = RAMX_TO_RAM(ramx_start); + uint32_t ram_end = RAMX_TO_RAM(ramx_end); - return mpu_fram_protect_armv7(ram_start, ram_end); + return mpu_fram_protect_armv7(ram_start, ram_end); } #if 0 @@ -333,37 +322,35 @@ int mpu_fram_test(void) } #endif -int mpu_setup(void) -{ - mpu_null_check_enable(); - mpu_fast_ram_protect(); +int mpu_setup(void) { + mpu_null_check_enable(); + mpu_fast_ram_protect(); - return 0; + return 0; } -int mpu_setup_cp(const mpu_regions_t *mpu_table, uint32_t region_num) -{ - int ret; - int i; - - ret = mpu_open(); - if (ret) { - return ret; - } - - if (region_num > MPU_ID_QTY) { - return -1; - } - - for (i = 0; i < region_num; i++) { - const mpu_regions_t *region; - region = &mpu_table[i]; - ret = mpu_set(i, region->addr, region->len, 0, region->ap_attr); - if (ret) - break; - } +int mpu_setup_cp(const mpu_regions_t *mpu_table, uint32_t region_num) { + int ret; + int i; + ret = mpu_open(); + if (ret) { return ret; + } + + if (region_num > MPU_ID_QTY) { + return -1; + } + + for (i = 0; i < region_num; i++) { + const mpu_regions_t *region; + region = &mpu_table[i]; + ret = mpu_set(i, region->addr, region->len, 0, region->ap_attr); + if (ret) + break; + } + + return ret; } #endif diff --git a/platform/cmsis/mpu_armv8m.c b/platform/cmsis/mpu_armv8m.c index 1334b61..dab5211 100644 --- a/platform/cmsis/mpu_armv8m.c +++ b/platform/cmsis/mpu_armv8m.c @@ -15,267 +15,261 @@ ****************************************************************************/ #ifndef __ARM_ARCH_ISA_ARM -#include "mpu.h" #include "cmsis.h" #include "hal_trace.h" +#include "mpu.h" -#define NORM_MEM_WT_RA_ATTR ARM_MPU_ATTR_MEMORY_(1, 0, 1, 0) -#define NORM_MEM_WB_WA_ATTR ARM_MPU_ATTR_MEMORY_(1, 1, 1, 1) -#define DEV_MEM_ATTR_OUTER ARM_MPU_ATTR_MEMORY_(0, 0, 0, 0) +#define NORM_MEM_WT_RA_ATTR ARM_MPU_ATTR_MEMORY_(1, 0, 1, 0) +#define NORM_MEM_WB_WA_ATTR ARM_MPU_ATTR_MEMORY_(1, 1, 1, 1) +#define DEV_MEM_ATTR_OUTER ARM_MPU_ATTR_MEMORY_(0, 0, 0, 0) -static void init_mair_attr(void) -{ - ARM_MPU_SetMemAttr(MAIR_ATTR_FLASH, ARM_MPU_ATTR(NORM_MEM_WT_RA_ATTR, NORM_MEM_WT_RA_ATTR)); - ARM_MPU_SetMemAttr(MAIR_ATTR_INT_SRAM, ARM_MPU_ATTR(NORM_MEM_WT_RA_ATTR, NORM_MEM_WT_RA_ATTR)); - ARM_MPU_SetMemAttr(MAIR_ATTR_EXT_SRAM, ARM_MPU_ATTR(NORM_MEM_WB_WA_ATTR, NORM_MEM_WB_WA_ATTR)); - ARM_MPU_SetMemAttr(MAIR_ATTR_DEVICE, ARM_MPU_ATTR(DEV_MEM_ATTR_OUTER, ARM_MPU_ATTR_DEVICE_nGnRnE)); +static void init_mair_attr(void) { + ARM_MPU_SetMemAttr(MAIR_ATTR_FLASH, + ARM_MPU_ATTR(NORM_MEM_WT_RA_ATTR, NORM_MEM_WT_RA_ATTR)); + ARM_MPU_SetMemAttr(MAIR_ATTR_INT_SRAM, + ARM_MPU_ATTR(NORM_MEM_WT_RA_ATTR, NORM_MEM_WT_RA_ATTR)); + ARM_MPU_SetMemAttr(MAIR_ATTR_EXT_SRAM, + ARM_MPU_ATTR(NORM_MEM_WB_WA_ATTR, NORM_MEM_WB_WA_ATTR)); + ARM_MPU_SetMemAttr( + MAIR_ATTR_DEVICE, + ARM_MPU_ATTR(DEV_MEM_ATTR_OUTER, ARM_MPU_ATTR_DEVICE_nGnRnE)); } -static int mpu_enable(void) -{ - int flags = 0; +static int mpu_enable(void) { + int flags = 0; - if (get_cpu_id()) { - /* - * if cpu is CP, we will use different mpu maps, that is, every map needed by CP will - * be mapped, and the memory is not mapped will issue abort when access - */ - flags = MPU_CTRL_HFNMIENA_Msk; - } else { - /* - * mpu maps use default map designed by arm, that is, if the memory is not mapped, - * the mpu attibutes will use the default setting by ARM. - */ - flags = MPU_CTRL_PRIVDEFENA_Msk; - } - ARM_MPU_Enable(flags); - __DSB(); - __ISB(); - return 0; + if (get_cpu_id()) { + /* + * if cpu is CP, we will use different mpu maps, that is, every map needed + * by CP will be mapped, and the memory is not mapped will issue abort when + * access + */ + flags = MPU_CTRL_HFNMIENA_Msk; + } else { + /* + * mpu maps use default map designed by arm, that is, if the memory is not + * mapped, the mpu attibutes will use the default setting by ARM. + */ + flags = MPU_CTRL_PRIVDEFENA_Msk; + } + ARM_MPU_Enable(flags); + __DSB(); + __ISB(); + return 0; } -static int mpu_disable(void) -{ - __DMB(); - ARM_MPU_Disable(); - return 0; +static int mpu_disable(void) { + __DMB(); + ARM_MPU_Disable(); + return 0; } -int mpu_open(void) -{ - int i; +int mpu_open(void) { + int i; - if ((MPU->TYPE & MPU_TYPE_DREGION_Msk) == 0) { - return 1; - } + if ((MPU->TYPE & MPU_TYPE_DREGION_Msk) == 0) { + return 1; + } - for (i = 0; i < MPU_ID_QTY; i++) { - ARM_MPU_ClrRegion(i); - } + for (i = 0; i < MPU_ID_QTY; i++) { + ARM_MPU_ClrRegion(i); + } - init_mair_attr(); + init_mair_attr(); - return 0; + return 0; } -int mpu_close(void) -{ - ARM_MPU_Disable(); +int mpu_close(void) { + ARM_MPU_Disable(); - return 0; + return 0; } static int mpu_set_armv8(enum MPU_ID_T id, uint32_t addr, uint32_t len, - enum MPU_ATTR_T ap_attr, enum MAIR_ATTR_TYPE_T mem_attr) -{ - uint32_t rbar; - uint32_t rlar; - uint8_t xn; - uint8_t ro; - uint32_t lock; + enum MPU_ATTR_T ap_attr, + enum MAIR_ATTR_TYPE_T mem_attr) { + uint32_t rbar; + uint32_t rlar; + uint8_t xn; + uint8_t ro; + uint32_t lock; - if (id >= MPU_ID_QTY) { - return 2; - } - if (len < 32) { - return 3; - } - if (addr & 0x1F) { - return 4; - } - if (ap_attr >= MPU_ATTR_QTY) { - return 5; - } + if (id >= MPU_ID_QTY) { + return 2; + } + if (len < 32) { + return 3; + } + if (addr & 0x1F) { + return 4; + } + if (ap_attr >= MPU_ATTR_QTY) { + return 5; + } - if (ap_attr == MPU_ATTR_READ_WRITE_EXEC || ap_attr == MPU_ATTR_READ_EXEC || - ap_attr == MPU_ATTR_EXEC) { - xn = 0; - } else { - xn = 1; - } + if (ap_attr == MPU_ATTR_READ_WRITE_EXEC || ap_attr == MPU_ATTR_READ_EXEC || + ap_attr == MPU_ATTR_EXEC) { + xn = 0; + } else { + xn = 1; + } - if (ap_attr == MPU_ATTR_READ_WRITE_EXEC || ap_attr == MPU_ATTR_READ_WRITE) { - ro = 0; - } else if (ap_attr == MPU_ATTR_READ_EXEC || ap_attr == MPU_ATTR_READ || ap_attr == MPU_ATTR_EXEC) { - ro = 1; - } else { - // Cannot support no access - return 6; - } + if (ap_attr == MPU_ATTR_READ_WRITE_EXEC || ap_attr == MPU_ATTR_READ_WRITE) { + ro = 0; + } else if (ap_attr == MPU_ATTR_READ_EXEC || ap_attr == MPU_ATTR_READ || + ap_attr == MPU_ATTR_EXEC) { + ro = 1; + } else { + // Cannot support no access + return 6; + } - // Sharebility: Outer Shareable - // Non-privilege Access: Enabled - rbar = ARM_MPU_RBAR(addr, 2, ro, 1, xn); - /* rlar = ARM_MPU_RLAR((addr + len - 1), MAIR_ATTR_INT_SRAM); */ - rlar = ARM_MPU_RLAR((addr + len - 1), mem_attr); + // Sharebility: Outer Shareable + // Non-privilege Access: Enabled + rbar = ARM_MPU_RBAR(addr, 2, ro, 1, xn); + /* rlar = ARM_MPU_RLAR((addr + len - 1), MAIR_ATTR_INT_SRAM); */ + rlar = ARM_MPU_RLAR((addr + len - 1), mem_attr); - lock = int_lock(); + lock = int_lock(); - ARM_MPU_SetRegion(id, rbar, rlar); - int_unlock(lock); + ARM_MPU_SetRegion(id, rbar, rlar); + int_unlock(lock); - return 0; + return 0; } -static inline int mpu_fram_protect_armv8(uint32_t fr_start, uint32_t fr_end) -{ - uint32_t len = fr_end - fr_start; - int ret; +static inline int mpu_fram_protect_armv8(uint32_t fr_start, uint32_t fr_end) { + uint32_t len = fr_end - fr_start; + int ret; - if ((fr_start % 32 != 0) || (len % 32 != 0)) - ASSERT(0, "fr_start %x and len %d must be aligned to 32", fr_start, len); + if ((fr_start % 32 != 0) || (len % 32 != 0)) + ASSERT(0, "fr_start %x and len %d must be aligned to 32", fr_start, len); - mpu_disable(); - ret = mpu_set_armv8(MPU_ID_FRAM_TEXT1, fr_start, len, MPU_ATTR_EXEC, MAIR_ATTR_INT_SRAM); - mpu_enable(); + mpu_disable(); + ret = mpu_set_armv8(MPU_ID_FRAM_TEXT1, fr_start, len, MPU_ATTR_EXEC, + MAIR_ATTR_INT_SRAM); + mpu_enable(); - return ret; + return ret; } -static int mpu_code_region_protect(void) -{ - uint32_t code_start = RAMX_BASE; - uint32_t len = RAM_SIZE; +static int mpu_code_region_protect(void) { + uint32_t code_start = RAMX_BASE; + uint32_t len = RAM_SIZE; - return mpu_set(MPU_ID_CODE, code_start, len, 0, MPU_ATTR_EXEC); + return mpu_set(MPU_ID_CODE, code_start, len, 0, MPU_ATTR_EXEC); } extern uint32_t __sram_text_data_start__[]; -extern uint32_t __sram_text_end__[]; -static int mpu_sram_text_protect(void) -{ - int ret; - uint32_t start = (uint32_t)__sram_text_data_start__; - uint32_t end = RAMX_TO_RAM((uint32_t)__sram_text_end__); - uint32_t len = end - start; +extern uint32_t __sram_text_end__[]; +static int mpu_sram_text_protect(void) { + int ret; + uint32_t start = (uint32_t)__sram_text_data_start__; + uint32_t end = RAMX_TO_RAM((uint32_t)__sram_text_end__); + uint32_t len = end - start; - TRACE(1,"sram start %x size %x", start, len); - if ((start % 32 != 0) || (len % 32 != 0)) - ASSERT(0, "sram start %x and len %d must be aligned to 32", start, len); + TRACE(1, "sram start %x size %x", start, len); + if ((start % 32 != 0) || (len % 32 != 0)) + ASSERT(0, "sram start %x and len %d must be aligned to 32", start, len); - ret = mpu_set(MPU_ID_SRAM_TEXT, start, len, 0, MPU_ATTR_READ_EXEC); - return ret; + ret = mpu_set(MPU_ID_SRAM_TEXT, start, len, 0, MPU_ATTR_READ_EXEC); + return ret; } - int mpu_set(enum MPU_ID_T id, uint32_t addr, uint32_t len, int srd_bits, - enum MPU_ATTR_T attr) -{ - int ret = -1; - uint32_t lock; + enum MPU_ATTR_T attr) { + int ret = -1; + uint32_t lock; - lock = int_lock(); + lock = int_lock(); - mpu_disable(); - ret = mpu_set_armv8(id, addr, len, attr, MAIR_ATTR_INT_SRAM); - mpu_enable(); + mpu_disable(); + ret = mpu_set_armv8(id, addr, len, attr, MAIR_ATTR_INT_SRAM); + mpu_enable(); - int_unlock(lock); + int_unlock(lock); - return ret; + return ret; } -int mpu_clear(enum MPU_ID_T id) -{ - uint32_t lock; +int mpu_clear(enum MPU_ID_T id) { + uint32_t lock; - if (id >= MPU_ID_QTY) { - return 2; - } + if (id >= MPU_ID_QTY) { + return 2; + } - lock = int_lock(); + lock = int_lock(); - mpu_disable(); - ARM_MPU_ClrRegion(id); - __DSB(); - __ISB(); - mpu_enable(); + mpu_disable(); + ARM_MPU_ClrRegion(id); + __DSB(); + __ISB(); + mpu_enable(); - int_unlock(lock); + int_unlock(lock); - return 0; + return 0; } -static int mpu_null_check_enable(void) -{ - return mpu_set(MPU_ID_NULL_POINTER, 0, 0x800, 0, MPU_ATTR_EXEC); +static int mpu_null_check_enable(void) { + return mpu_set(MPU_ID_NULL_POINTER, 0, 0x800, 0, MPU_ATTR_EXEC); } extern uint32_t __fast_sram_text_exec_start__[]; extern uint32_t __fast_sram_text_exec_end__[]; -static int mpu_fast_ram_protect(void) -{ - uint32_t ramx_start = (uint32_t)__fast_sram_text_exec_start__; - uint32_t ramx_end = (uint32_t)__fast_sram_text_exec_end__; - uint32_t ram_start = RAMX_TO_RAM(ramx_start); - uint32_t ram_end = RAMX_TO_RAM(ramx_end); - int ret = -1; +static int mpu_fast_ram_protect(void) { + uint32_t ramx_start = (uint32_t)__fast_sram_text_exec_start__; + uint32_t ramx_end = (uint32_t)__fast_sram_text_exec_end__; + uint32_t ram_start = RAMX_TO_RAM(ramx_start); + uint32_t ram_end = RAMX_TO_RAM(ramx_end); + int ret = -1; - ret = mpu_fram_protect_armv8(ram_start, ram_end); - return ret; + ret = mpu_fram_protect_armv8(ram_start, ram_end); + return ret; } -int mpu_setup(void) -{ - mpu_null_check_enable(); +int mpu_setup(void) { + mpu_null_check_enable(); - mpu_code_region_protect(); - mpu_sram_text_protect(); + mpu_code_region_protect(); + mpu_sram_text_protect(); - mpu_fast_ram_protect(); - return 0; + mpu_fast_ram_protect(); + return 0; } -int mpu_setup_cp(const mpu_regions_t *mpu_table, uint32_t region_num) -{ - int ret; - int i; - uint32_t lock; - - ret = mpu_open(); - if (ret) { - return ret; - } - - if (region_num > MPU_ID_QTY) { - return -1; - } - - lock = int_lock(); - mpu_disable(); - for (i = 0; i < region_num; i++) { - const mpu_regions_t *region; - region = &mpu_table[i]; - ret = mpu_set_armv8(i, region->addr, region->len, region->ap_attr, region->mem_attr); - if (ret) - break; - } - - mpu_enable(); - int_unlock(lock); +int mpu_setup_cp(const mpu_regions_t *mpu_table, uint32_t region_num) { + int ret; + int i; + uint32_t lock; + ret = mpu_open(); + if (ret) { return ret; + } + + if (region_num > MPU_ID_QTY) { + return -1; + } + + lock = int_lock(); + mpu_disable(); + for (i = 0; i < region_num; i++) { + const mpu_regions_t *region; + region = &mpu_table[i]; + ret = mpu_set_armv8(i, region->addr, region->len, region->ap_attr, + region->mem_attr); + if (ret) + break; + } + + mpu_enable(); + int_unlock(lock); + + return ret; } #endif diff --git a/platform/cmsis/patch.c b/platform/cmsis/patch.c index ce95cae..ea38285 100644 --- a/platform/cmsis/patch.c +++ b/platform/cmsis/patch.c @@ -19,198 +19,191 @@ #ifdef PATCH_CTRL_BASE -static struct PATCH_CTRL_T * const patch_ctrl = (struct PATCH_CTRL_T *)PATCH_CTRL_BASE; -static struct PATCH_DATA_T * const patch_data = (struct PATCH_DATA_T *)PATCH_DATA_BASE; +static struct PATCH_CTRL_T *const patch_ctrl = + (struct PATCH_CTRL_T *)PATCH_CTRL_BASE; +static struct PATCH_DATA_T *const patch_data = + (struct PATCH_DATA_T *)PATCH_DATA_BASE; static uint32_t patch_map[(PATCH_ENTRY_NUM + 31) / 32]; -int patch_open(uint32_t remap_addr) -{ - patch_ctrl->CTRL[0] |= PATCH_CTRL_GLOBAL_EN; - return 0; +int patch_open(uint32_t remap_addr) { + patch_ctrl->CTRL[0] |= PATCH_CTRL_GLOBAL_EN; + return 0; } -int patch_code_enable_id(uint32_t id, uint32_t addr, uint32_t data) -{ - if (id >= PATCH_ENTRY_NUM) { - return 1; - } +int patch_code_enable_id(uint32_t id, uint32_t addr, uint32_t data) { + if (id >= PATCH_ENTRY_NUM) { + return 1; + } - patch_data->DATA[id] = data; - patch_ctrl->CTRL[id] = (patch_ctrl->CTRL[id] & ~PATCH_CTRL_ADDR_MASK) | PATCH_CTRL_ADDR(addr) | PATCH_CTRL_ENTRY_EN; - return 0; + patch_data->DATA[id] = data; + patch_ctrl->CTRL[id] = (patch_ctrl->CTRL[id] & ~PATCH_CTRL_ADDR_MASK) | + PATCH_CTRL_ADDR(addr) | PATCH_CTRL_ENTRY_EN; + return 0; } -int patch_code_disable_id(uint32_t id) -{ - if (id >= PATCH_ENTRY_NUM) { - return 1; - } +int patch_code_disable_id(uint32_t id) { + if (id >= PATCH_ENTRY_NUM) { + return 1; + } - patch_ctrl->CTRL[id] &= ~PATCH_CTRL_ENTRY_EN; - return 0; + patch_ctrl->CTRL[id] &= ~PATCH_CTRL_ENTRY_EN; + return 0; } -int patch_data_enable_id(uint32_t id, uint32_t addr, uint32_t data) -{ - return patch_code_enable_id(id, addr, data); +int patch_data_enable_id(uint32_t id, uint32_t addr, uint32_t data) { + return patch_code_enable_id(id, addr, data); } -int patch_data_disable_id(uint32_t id) -{ - return patch_code_disable_id(id); -} +int patch_data_disable_id(uint32_t id) { return patch_code_disable_id(id); } -static uint32_t func_patch_ins(uint32_t old_func, uint32_t new_func) -{ +static uint32_t func_patch_ins(uint32_t old_func, uint32_t new_func) { #if defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_8M_MAIN__) - union { - uint32_t d32; - uint16_t d16[2]; - } ins; - uint32_t immd; - uint8_t j1, j2, s; + union { + uint32_t d32; + uint16_t d16[2]; + } ins; + uint32_t immd; + uint8_t j1, j2, s; - ins.d32 = 0x9000F000; - immd = (new_func & ~1) - ((old_func + 4) & ~1); - s = immd >> 31; - j1 = s ^ !((immd >> 23) & 1); - j2 = s ^ !((immd >> 22) & 1); - ins.d16[0] |= (s << 10) | ((immd >> 12) & 0x3FF); - ins.d16[1] |= (j1 << 13) | (j2 << 11) | ((immd >> 1) & 0x7FF); + ins.d32 = 0x9000F000; + immd = (new_func & ~1) - ((old_func + 4) & ~1); + s = immd >> 31; + j1 = s ^ !((immd >> 23) & 1); + j2 = s ^ !((immd >> 22) & 1); + ins.d16[0] |= (s << 10) | ((immd >> 12) & 0x3FF); + ins.d16[1] |= (j1 << 13) | (j2 << 11) | ((immd >> 1) & 0x7FF); - return ins.d32; + return ins.d32; #else #error "Only ARMv7-M/ARMv8-M function can be patched" #endif } -PATCH_ID patch_enable(enum PATCH_TYPE_T type, uint32_t addr, uint32_t data) -{ - uint8_t id, idfunc; - uint8_t cnt; - uint32_t bit; - uint32_t offset; +PATCH_ID patch_enable(enum PATCH_TYPE_T type, uint32_t addr, uint32_t data) { + uint8_t id, idfunc; + uint8_t cnt; + uint32_t bit; + uint32_t offset; - if (addr < ROM_BASE || addr >= (ROM_BASE + 0x20000000)) { - // Not in code region - return -1; + if (addr < ROM_BASE || addr >= (ROM_BASE + 0x20000000)) { + // Not in code region + return -1; + } + if (type == PATCH_TYPE_FUNC) { + if (data >= addr) { + offset = data - addr; + } else { + offset = addr - data; } - if (type == PATCH_TYPE_FUNC) { - if (data >= addr) { - offset = data - addr; - } else { - offset = addr - data; - } - if (offset >= 0x01000000) { - // Branch distance too long to fit in a 32-bit branch instruction - return -2; - } + if (offset >= 0x01000000) { + // Branch distance too long to fit in a 32-bit branch instruction + return -2; } + } - if (!(type == PATCH_TYPE_CODE || type == PATCH_TYPE_FUNC || type == PATCH_TYPE_DATA)) { - return -3; + if (!(type == PATCH_TYPE_CODE || type == PATCH_TYPE_FUNC || + type == PATCH_TYPE_DATA)) { + return -3; + } + + for (id = 0; id < PATCH_ENTRY_NUM; id++) { + cnt = id / 32; + bit = (1 << (id % 32)); + if ((patch_map[cnt] & bit) == 0) { + patch_map[cnt] |= bit; + break; } + } + if (id >= PATCH_ENTRY_NUM) { + return -4; + } - for (id = 0; id < PATCH_ENTRY_NUM; id++) { - cnt = id / 32; - bit = (1 << (id % 32)); - if ((patch_map[cnt] & bit) == 0) { - patch_map[cnt] |= bit; - break; - } + idfunc = 0xFF; + + if (type == PATCH_TYPE_FUNC && (addr & 2)) { + for (idfunc = id; idfunc < PATCH_ENTRY_NUM; idfunc++) { + cnt = idfunc / 32; + bit = (1 << (idfunc % 32)); + if ((patch_map[cnt] & bit) == 0) { + patch_map[cnt] |= bit; + break; + } } - if (id >= PATCH_ENTRY_NUM) { - return -4; + if (idfunc >= PATCH_ENTRY_NUM) { + // Release previous patch + patch_map[cnt] &= ~bit; + return -5; } + } - idfunc = 0xFF; + if (type == PATCH_TYPE_CODE) { + patch_code_enable_id(id, addr, data); + } else if (type == PATCH_TYPE_DATA) { + patch_data_enable_id(id, addr, data); + } else if (type == PATCH_TYPE_FUNC) { + uint32_t ins; - if (type == PATCH_TYPE_FUNC && (addr & 2)) { - for (idfunc = id; idfunc < PATCH_ENTRY_NUM; idfunc++) { - cnt = idfunc / 32; - bit = (1 << (idfunc % 32)); - if ((patch_map[cnt] & bit) == 0) { - patch_map[cnt] |= bit; - break; - } - } - if (idfunc >= PATCH_ENTRY_NUM) { - // Release previous patch - patch_map[cnt] &= ~bit; - return -5; - } + ins = func_patch_ins(addr, data); + + if (addr & 2) { + uint32_t real_addr[2]; + uint32_t real_data[2]; + + real_addr[0] = addr & ~3; + real_addr[1] = (addr + 4) & ~3; + + real_data[0] = *(volatile uint32_t *)real_addr[0]; + real_data[1] = *(volatile uint32_t *)real_addr[1]; + real_data[0] = (real_data[0] & 0x0000FFFF) | ((ins & 0xFFFF) << 16); + real_data[1] = (real_data[1] & 0xFFFF0000) | ((ins >> 16) & 0xFFFF); + + patch_code_enable_id(id, real_addr[0], real_data[0]); + patch_code_enable_id(idfunc, real_addr[1], real_data[1]); + } else { + patch_code_enable_id(id, addr, ins); } + } - if (type == PATCH_TYPE_CODE) { - patch_code_enable_id(id, addr, data); - } else if (type == PATCH_TYPE_DATA) { - patch_data_enable_id(id, addr, data); - } else if (type == PATCH_TYPE_FUNC) { - uint32_t ins; - - ins = func_patch_ins(addr, data); - - if (addr & 2) { - uint32_t real_addr[2]; - uint32_t real_data[2]; - - real_addr[0] = addr & ~3; - real_addr[1] = (addr + 4) & ~3; - - real_data[0] = *(volatile uint32_t *)real_addr[0]; - real_data[1] = *(volatile uint32_t *)real_addr[1]; - real_data[0] = (real_data[0] & 0x0000FFFF) | ((ins & 0xFFFF) << 16); - real_data[1] = (real_data[1] & 0xFFFF0000) | ((ins >> 16) & 0xFFFF); - - patch_code_enable_id(id, real_addr[0], real_data[0]); - patch_code_enable_id(idfunc, real_addr[1], real_data[1]); - } else { - patch_code_enable_id(id, addr, ins); - } - } - - return ((id + 1) & 0xFF) | (((idfunc + 1) & 0xFF) << 8); + return ((id + 1) & 0xFF) | (((idfunc + 1) & 0xFF) << 8); } -int patch_disable(PATCH_ID patch_id) -{ - uint8_t id; - uint8_t cnt, bit; - int i; +int patch_disable(PATCH_ID patch_id) { + uint8_t id; + uint8_t cnt, bit; + int i; - for (i = 0; i < 2; i++) { - id = (uint8_t)(patch_id >> (8 * i)) - 1; + for (i = 0; i < 2; i++) { + id = (uint8_t)(patch_id >> (8 * i)) - 1; - if (id == 0xFF) { - return 0; - } else if (id >= PATCH_ENTRY_NUM) { - return -1; - } - - patch_code_disable_id(id); - - cnt = id / 32; - bit = (1 << (id % 32)); - patch_map[cnt] &= ~bit; + if (id == 0xFF) { + return 0; + } else if (id >= PATCH_ENTRY_NUM) { + return -1; } - return 0; + patch_code_disable_id(id); + + cnt = id / 32; + bit = (1 << (id % 32)); + patch_map[cnt] &= ~bit; + } + + return 0; } -void patch_close(void) -{ - int i; +void patch_close(void) { + int i; - patch_ctrl->CTRL[0] &= ~PATCH_CTRL_GLOBAL_EN; + patch_ctrl->CTRL[0] &= ~PATCH_CTRL_GLOBAL_EN; - for (i = 0; i < PATCH_ENTRY_NUM; i++) { - patch_code_disable_id(i); - } + for (i = 0; i < PATCH_ENTRY_NUM; i++) { + patch_code_disable_id(i); + } - for (i = 0; i < ARRAY_SIZE(patch_map); i++) { - patch_map[i] = 0; - } + for (i = 0; i < ARRAY_SIZE(patch_map); i++) { + patch_map[i] = 0; + } } #endif #endif diff --git a/platform/cmsis/patch_armv7m.c b/platform/cmsis/patch_armv7m.c index 6cd23aa..0cdc7e0 100644 --- a/platform/cmsis/patch_armv7m.c +++ b/platform/cmsis/patch_armv7m.c @@ -15,256 +15,240 @@ ****************************************************************************/ #ifdef __ARM_ARCH_7EM__ -#include "patch.h" -#include "reg_patch_armv7m.h" -#include "plat_addr_map.h" #include "cmsis.h" +#include "patch.h" +#include "plat_addr_map.h" +#include "reg_patch_armv7m.h" -static struct PATCH_ARMV7M_T * const patch = (struct PATCH_ARMV7M_T *)0xE0002000; +static struct PATCH_ARMV7M_T *const patch = (struct PATCH_ARMV7M_T *)0xE0002000; static uint32_t patch_map[(__NUM_CODE_PATCH + __NUM_LIT_PATCH + 31) / 32]; -static uint32_t get_num_code(void) -{ - return __NUM_CODE_PATCH; +static uint32_t get_num_code(void) { return __NUM_CODE_PATCH; } + +static uint32_t get_num_lit(void) { return __NUM_LIT_PATCH; } + +static uint32_t get_remap_addr(void) { + return GET_BITFIELD(patch->FP_REMAP, REMAP_ADDR) | (RAM_BASE & 0xE0000000); } -static uint32_t get_num_lit(void) -{ - return __NUM_LIT_PATCH; +int patch_open(uint32_t remap_addr) { + patch->FP_REMAP = REMAP_ADDR(remap_addr); + patch->FP_CTRL = FP_CTRL_KEY | FP_CTRL_ENABLE; + return 0; } -static uint32_t get_remap_addr(void) -{ - return GET_BITFIELD(patch->FP_REMAP, REMAP_ADDR) | (RAM_BASE & 0xE0000000); +int patch_code_enable_id(uint32_t id, uint32_t addr, uint32_t data) { + uint32_t *remap_addr; + + if (id >= get_num_code()) { + return 1; + } + + remap_addr = (uint32_t *)get_remap_addr(); + remap_addr[id] = data; + patch->FP_COMP[id] = COMP_REPLACE(0) | COMP_ADDR(addr) | COMP_ENABLE; + return 0; } -int patch_open(uint32_t remap_addr) -{ - patch->FP_REMAP = REMAP_ADDR(remap_addr); - patch->FP_CTRL = FP_CTRL_KEY | FP_CTRL_ENABLE; - return 0; +int patch_code_disable_id(uint32_t id) { + if (id >= get_num_code()) { + return 1; + } + + patch->FP_COMP[id] = 0; + return 0; } -int patch_code_enable_id(uint32_t id, uint32_t addr, uint32_t data) -{ - uint32_t *remap_addr; +int patch_data_enable_id(uint32_t id, uint32_t addr, uint32_t data) { + uint32_t *remap_addr; - if (id >= get_num_code()) { - return 1; - } + if (id >= get_num_lit()) { + return 1; + } + id += get_num_code(); - remap_addr = (uint32_t *)get_remap_addr(); - remap_addr[id] = data; - patch->FP_COMP[id] = COMP_REPLACE(0) | COMP_ADDR(addr) | COMP_ENABLE; - return 0; + remap_addr = (uint32_t *)get_remap_addr(); + remap_addr[id] = data; + patch->FP_COMP[id] = COMP_REPLACE(0) | COMP_ADDR(addr) | COMP_ENABLE; + return 0; } -int patch_code_disable_id(uint32_t id) -{ - if (id >= get_num_code()) { - return 1; - } +int patch_data_disable_id(uint32_t id) { + if (id >= get_num_lit()) { + return 1; + } + id += get_num_code(); - patch->FP_COMP[id] = 0; - return 0; + patch->FP_COMP[id] = 0; + return 0; } -int patch_data_enable_id(uint32_t id, uint32_t addr, uint32_t data) -{ - uint32_t *remap_addr; - - if (id >= get_num_lit()) { - return 1; - } - id += get_num_code(); - - remap_addr = (uint32_t *)get_remap_addr(); - remap_addr[id] = data; - patch->FP_COMP[id] = COMP_REPLACE(0) | COMP_ADDR(addr) | COMP_ENABLE; - return 0; -} - -int patch_data_disable_id(uint32_t id) -{ - if (id >= get_num_lit()) { - return 1; - } - id += get_num_code(); - - patch->FP_COMP[id] = 0; - return 0; -} - -static uint32_t func_patch_ins(uint32_t old_func, uint32_t new_func) -{ +static uint32_t func_patch_ins(uint32_t old_func, uint32_t new_func) { #ifdef __ARM_ARCH_7EM__ - union { - uint32_t d32; - uint16_t d16[2]; - } ins; - uint32_t immd; - uint8_t j1, j2, s; + union { + uint32_t d32; + uint16_t d16[2]; + } ins; + uint32_t immd; + uint8_t j1, j2, s; - ins.d32 = 0x9000F000; - immd = (new_func & ~1) - ((old_func + 4) & ~1); - s = immd >> 31; - j1 = s ^ !((immd >> 23) & 1); - j2 = s ^ !((immd >> 22) & 1); - ins.d16[0] |= (s << 10) | ((immd >> 12) & 0x3FF); - ins.d16[1] |= (j1 << 13) | (j2 << 11) | ((immd >> 1) & 0x7FF); + ins.d32 = 0x9000F000; + immd = (new_func & ~1) - ((old_func + 4) & ~1); + s = immd >> 31; + j1 = s ^ !((immd >> 23) & 1); + j2 = s ^ !((immd >> 22) & 1); + ins.d16[0] |= (s << 10) | ((immd >> 12) & 0x3FF); + ins.d16[1] |= (j1 << 13) | (j2 << 11) | ((immd >> 1) & 0x7FF); - return ins.d32; + return ins.d32; #else #error "Only ARMv7-M function can be patched" #endif } -PATCH_ID patch_enable(enum PATCH_TYPE_T type, uint32_t addr, uint32_t data) -{ - uint8_t start, end; - uint8_t id, idfunc; - uint8_t cnt; - uint32_t bit; - uint32_t offset; +PATCH_ID patch_enable(enum PATCH_TYPE_T type, uint32_t addr, uint32_t data) { + uint8_t start, end; + uint8_t id, idfunc; + uint8_t cnt; + uint32_t bit; + uint32_t offset; - if (addr < ROM_BASE || addr >= (ROM_BASE + 0x20000000)) { - // Not in code region - return -1; - } - if (type == PATCH_TYPE_FUNC) { - if (data >= addr) { - offset = data - addr; - } else { - offset = addr - data; - } - if (offset >= 0x01000000) { - // Branch distance too long to fit in a 32-bit branch instruction - return -2; - } - } - - if (type == PATCH_TYPE_CODE || type == PATCH_TYPE_FUNC) { - start = 0; - end = start + get_num_code(); - } else if (type == PATCH_TYPE_DATA) { - start = get_num_code(); - end = start + get_num_lit(); + if (addr < ROM_BASE || addr >= (ROM_BASE + 0x20000000)) { + // Not in code region + return -1; + } + if (type == PATCH_TYPE_FUNC) { + if (data >= addr) { + offset = data - addr; } else { - return -3; + offset = addr - data; } - - for (id = start; id < end; id++) { - cnt = id / 32; - bit = (1 << (id % 32)); - if ((patch_map[cnt] & bit) == 0) { - patch_map[cnt] |= bit; - break; - } + if (offset >= 0x01000000) { + // Branch distance too long to fit in a 32-bit branch instruction + return -2; } - if (id >= end) { - return -4; + } + + if (type == PATCH_TYPE_CODE || type == PATCH_TYPE_FUNC) { + start = 0; + end = start + get_num_code(); + } else if (type == PATCH_TYPE_DATA) { + start = get_num_code(); + end = start + get_num_lit(); + } else { + return -3; + } + + for (id = start; id < end; id++) { + cnt = id / 32; + bit = (1 << (id % 32)); + if ((patch_map[cnt] & bit) == 0) { + patch_map[cnt] |= bit; + break; } + } + if (id >= end) { + return -4; + } - idfunc = 0xFF; + idfunc = 0xFF; - if (type == PATCH_TYPE_FUNC && (addr & 2)) { - for (idfunc = id; idfunc < end; idfunc++) { - cnt = idfunc / 32; - bit = (1 << (idfunc % 32)); - if ((patch_map[cnt] & bit) == 0) { - patch_map[cnt] |= bit; - break; - } - } - if (idfunc >= end) { - // Release previous patch - patch_map[cnt] &= ~bit; - return -5; - } + if (type == PATCH_TYPE_FUNC && (addr & 2)) { + for (idfunc = id; idfunc < end; idfunc++) { + cnt = idfunc / 32; + bit = (1 << (idfunc % 32)); + if ((patch_map[cnt] & bit) == 0) { + patch_map[cnt] |= bit; + break; + } } - - if (type == PATCH_TYPE_CODE) { - patch_code_enable_id(id - start, addr, data); - } else if (type == PATCH_TYPE_DATA) { - patch_data_enable_id(id - start, addr, data); - } else if (type == PATCH_TYPE_FUNC) { - uint32_t ins; - - ins = func_patch_ins(addr, data); - - if (addr & 2) { - uint32_t real_addr[2]; - uint32_t real_data[2]; - - real_addr[0] = addr & ~3; - real_addr[1] = (addr + 4) & ~3; - - real_data[0] = *(volatile uint32_t *)real_addr[0]; - real_data[1] = *(volatile uint32_t *)real_addr[1]; - real_data[0] = (real_data[0] & 0x0000FFFF) | ((ins & 0xFFFF) << 16); - real_data[1] = (real_data[1] & 0xFFFF0000) | ((ins >> 16) & 0xFFFF); - - patch_code_enable_id(id - start, real_addr[0], real_data[0]); - patch_code_enable_id(idfunc - start, real_addr[1], real_data[1]); - } else { - patch_code_enable_id(id - start, addr, ins); - } + if (idfunc >= end) { + // Release previous patch + patch_map[cnt] &= ~bit; + return -5; } + } - return ((id + 1) & 0xFF) | (((idfunc + 1) & 0xFF) << 8); + if (type == PATCH_TYPE_CODE) { + patch_code_enable_id(id - start, addr, data); + } else if (type == PATCH_TYPE_DATA) { + patch_data_enable_id(id - start, addr, data); + } else if (type == PATCH_TYPE_FUNC) { + uint32_t ins; + + ins = func_patch_ins(addr, data); + + if (addr & 2) { + uint32_t real_addr[2]; + uint32_t real_data[2]; + + real_addr[0] = addr & ~3; + real_addr[1] = (addr + 4) & ~3; + + real_data[0] = *(volatile uint32_t *)real_addr[0]; + real_data[1] = *(volatile uint32_t *)real_addr[1]; + real_data[0] = (real_data[0] & 0x0000FFFF) | ((ins & 0xFFFF) << 16); + real_data[1] = (real_data[1] & 0xFFFF0000) | ((ins >> 16) & 0xFFFF); + + patch_code_enable_id(id - start, real_addr[0], real_data[0]); + patch_code_enable_id(idfunc - start, real_addr[1], real_data[1]); + } else { + patch_code_enable_id(id - start, addr, ins); + } + } + + return ((id + 1) & 0xFF) | (((idfunc + 1) & 0xFF) << 8); } -int patch_disable(PATCH_ID patch_id) -{ - uint8_t id; - uint8_t code_start, code_end, data_start, data_end; - uint8_t cnt, bit; - int i; +int patch_disable(PATCH_ID patch_id) { + uint8_t id; + uint8_t code_start, code_end, data_start, data_end; + uint8_t cnt, bit; + int i; - code_start = 0; - code_end = code_start + get_num_code(); - data_start = code_end; - data_end = data_start + get_num_lit(); + code_start = 0; + code_end = code_start + get_num_code(); + data_start = code_end; + data_end = data_start + get_num_lit(); - for (i = 0; i < 2; i++) { - id = (uint8_t)(patch_id >> (8 * i)) - 1; + for (i = 0; i < 2; i++) { + id = (uint8_t)(patch_id >> (8 * i)) - 1; - if (id == 0xFF) { - return 0; - } else if (id >= code_start && id < code_end) { - patch_code_disable_id(id); - } else if (id >= data_start && id < data_end) { - patch_data_disable_id(id - data_start); - } else { - return -1; - } - - cnt = id / 32; - bit = (1 << (id % 32)); - patch_map[cnt] &= ~bit; + if (id == 0xFF) { + return 0; + } else if (id >= code_start && id < code_end) { + patch_code_disable_id(id); + } else if (id >= data_start && id < data_end) { + patch_data_disable_id(id - data_start); + } else { + return -1; } - return 0; + cnt = id / 32; + bit = (1 << (id % 32)); + patch_map[cnt] &= ~bit; + } + + return 0; } -void patch_close(void) -{ - int i; +void patch_close(void) { + int i; - patch->FP_CTRL = FP_CTRL_KEY; + patch->FP_CTRL = FP_CTRL_KEY; - for (i = 0; i < get_num_code(); i++) { - patch_code_disable_id(i); - } + for (i = 0; i < get_num_code(); i++) { + patch_code_disable_id(i); + } - for (i = get_num_code(); i < (get_num_code() + get_num_lit()); i++) { - patch_data_disable_id(i); - } + for (i = get_num_code(); i < (get_num_code() + get_num_lit()); i++) { + patch_data_disable_id(i); + } - for (i = 0; i < ARRAY_SIZE(patch_map); i++) { - patch_map[i] = 0; - } + for (i = 0; i < ARRAY_SIZE(patch_map); i++) { + patch_map[i] = 0; + } } #endif diff --git a/platform/cmsis/retarget_armclang.cpp b/platform/cmsis/retarget_armclang.cpp index 63b72eb..331bf92 100644 --- a/platform/cmsis/retarget_armclang.cpp +++ b/platform/cmsis/retarget_armclang.cpp @@ -15,74 +15,105 @@ ****************************************************************************/ #ifdef __ARMCC_VERSION -extern "C" -{ +extern "C" { #include "analog.h" +#include "codec_int.h" #include "hal_codec.h" #include "hal_trace.h" -#include "codec_int.h" #include "norflash_drv.h" #include "pmu.h" #ifdef NOSTD -void __rt_raise(int sig, intptr_t type) -{ - ASSERT(false, "__rt_raise: sig=%d type=%p", sig, type); +void __rt_raise(int sig, intptr_t type) { + ASSERT(false, "__rt_raise: sig=%d type=%p", sig, type); } #endif // Stupid armlink WEAK void analog_aud_xtal_tune(float ratio) {} -WEAK void hal_codec_dac_gain_m60db_check(enum HAL_CODEC_PERF_TEST_POWER_T type) {} +WEAK void +hal_codec_dac_gain_m60db_check(enum HAL_CODEC_PERF_TEST_POWER_T type) {} WEAK void hal_codec_set_noise_reduction(bool enable) {} WEAK void hal_codec_tune_both_resample_rate(float ratio) {} -WEAK void hal_codec_set_bt_trigger_callback(HAL_CODEC_BT_TRIGGER_CALLBACK callback) {} -WEAK int hal_codec_bt_trigger_start(void) {return 0;} -WEAK int hal_codec_bt_trigger_stop(void) {return 0;} +WEAK void +hal_codec_set_bt_trigger_callback(HAL_CODEC_BT_TRIGGER_CALLBACK callback) {} +WEAK int hal_codec_bt_trigger_start(void) { return 0; } +WEAK int hal_codec_bt_trigger_stop(void) { return 0; } WEAK void hal_codec_sync_dac_enable(enum HAL_CODEC_SYNC_TYPE_T type) {} WEAK void hal_codec_sync_dac_disable(void) {} WEAK void hal_codec_sync_adc_enable(enum HAL_CODEC_SYNC_TYPE_T type) {} WEAK void hal_codec_sync_adc_disable(void) {} -WEAK void hal_codec_sync_dac_resample_rate_enable(enum HAL_CODEC_SYNC_TYPE_T type) {} +WEAK void +hal_codec_sync_dac_resample_rate_enable(enum HAL_CODEC_SYNC_TYPE_T type) {} WEAK void hal_codec_sync_dac_resample_rate_disable(void) {} -WEAK void hal_codec_sync_adc_resample_rate_enable(enum HAL_CODEC_SYNC_TYPE_T type) {} +WEAK void +hal_codec_sync_adc_resample_rate_enable(enum HAL_CODEC_SYNC_TYPE_T type) {} WEAK void hal_codec_sync_adc_resample_rate_disable(void) {} WEAK void hal_codec_sync_dac_gain_enable(enum HAL_CODEC_SYNC_TYPE_T type) {} WEAK void hal_codec_sync_dac_gain_disable(void) {} WEAK void hal_codec_sync_adc_gain_enable(enum HAL_CODEC_SYNC_TYPE_T type) {} WEAK void hal_codec_sync_adc_gain_disable(void) {} -WEAK int codec_anc_open(enum ANC_TYPE_T type, enum AUD_SAMPRATE_T dac_rate, enum AUD_SAMPRATE_T adc_rate, CODEC_ANC_HANDLER hdlr) {return 0;} -WEAK int codec_anc_close(enum ANC_TYPE_T type) {return 0;} +WEAK int codec_anc_open(enum ANC_TYPE_T type, enum AUD_SAMPRATE_T dac_rate, + enum AUD_SAMPRATE_T adc_rate, CODEC_ANC_HANDLER hdlr) { + return 0; +} +WEAK int codec_anc_close(enum ANC_TYPE_T type) { return 0; } #ifdef ROM_BUILD WEAK void norflash_reset(void) {} -WEAK int norflash_get_size(uint32_t *total_size, uint32_t *block_size, uint32_t *sector_size, uint32_t *page_size) {return HAL_NORFLASH_OK;} -WEAK int norflash_set_mode(uint32_t op) {return HAL_NORFLASH_OK;} -WEAK int norflash_pre_operation(void) {return HAL_NORFLASH_OK;} -WEAK int norflash_post_operation(void) {return HAL_NORFLASH_OK;} -WEAK int norflash_init_sample_delay_by_div(uint32_t div) {return HAL_NORFLASH_OK;} +WEAK int norflash_get_size(uint32_t *total_size, uint32_t *block_size, + uint32_t *sector_size, uint32_t *page_size) { + return HAL_NORFLASH_OK; +} +WEAK int norflash_set_mode(uint32_t op) { return HAL_NORFLASH_OK; } +WEAK int norflash_pre_operation(void) { return HAL_NORFLASH_OK; } +WEAK int norflash_post_operation(void) { return HAL_NORFLASH_OK; } +WEAK int norflash_init_sample_delay_by_div(uint32_t div) { + return HAL_NORFLASH_OK; +} WEAK void norflash_set_sample_delay(uint32_t index) {} -WEAK int norflash_sample_delay_calib(void) {return HAL_NORFLASH_OK;} -WEAK int norflash_init_div(const struct HAL_NORFLASH_CONFIG_T *cfg) {return HAL_NORFLASH_OK;} -WEAK int norflash_match_chip(const uint8_t *id, uint32_t len) {return HAL_NORFLASH_OK;} -WEAK int norflash_get_id(uint8_t *value, uint32_t len) {return HAL_NORFLASH_OK;} -WEAK int norflash_get_unique_id(uint8_t *value, uint32_t len) {return HAL_NORFLASH_OK;} -WEAK enum HAL_NORFLASH_RET_T norflash_erase(uint32_t start_address, enum DRV_NORFLASH_ERASE_T type, int suspend) {return HAL_NORFLASH_OK;} -WEAK enum HAL_NORFLASH_RET_T norflash_write(uint32_t start_address, const uint8_t *buffer, uint32_t len, int suspend) {return HAL_NORFLASH_OK;} -WEAK int norflash_read(uint32_t start_address, uint8_t *buffer, uint32_t len) {return HAL_NORFLASH_OK;} +WEAK int norflash_sample_delay_calib(void) { return HAL_NORFLASH_OK; } +WEAK int norflash_init_div(const struct HAL_NORFLASH_CONFIG_T *cfg) { + return HAL_NORFLASH_OK; +} +WEAK int norflash_match_chip(const uint8_t *id, uint32_t len) { + return HAL_NORFLASH_OK; +} +WEAK int norflash_get_id(uint8_t *value, uint32_t len) { + return HAL_NORFLASH_OK; +} +WEAK int norflash_get_unique_id(uint8_t *value, uint32_t len) { + return HAL_NORFLASH_OK; +} +WEAK enum HAL_NORFLASH_RET_T norflash_erase(uint32_t start_address, + enum DRV_NORFLASH_ERASE_T type, + int suspend) { + return HAL_NORFLASH_OK; +} +WEAK enum HAL_NORFLASH_RET_T norflash_write(uint32_t start_address, + const uint8_t *buffer, uint32_t len, + int suspend) { + return HAL_NORFLASH_OK; +} +WEAK int norflash_read(uint32_t start_address, uint8_t *buffer, uint32_t len) { + return HAL_NORFLASH_OK; +} WEAK void pmu_flash_freq_config(uint32_t freq) {} WEAK void pmu_rs_freq_config(uint32_t freq) {} -WEAK void pmu_led_set_voltage_domains(enum HAL_IOMUX_PIN_T pin, enum HAL_IOMUX_PIN_VOLTAGE_DOMAINS_T volt) {} -WEAK void pmu_led_set_pull_select(enum HAL_IOMUX_PIN_T pin, enum HAL_IOMUX_PIN_PULL_SELECT_T pull_sel) {} +WEAK void +pmu_led_set_voltage_domains(enum HAL_IOMUX_PIN_T pin, + enum HAL_IOMUX_PIN_VOLTAGE_DOMAINS_T volt) {} +WEAK void pmu_led_set_pull_select(enum HAL_IOMUX_PIN_T pin, + enum HAL_IOMUX_PIN_PULL_SELECT_T pull_sel) {} #ifdef SPI_ROM_ONLY -WEAK int hal_ispi_open(const struct HAL_SPI_CFG_T *cfg) {return 0;} -WEAK int hal_ispi_send(const void *data, uint32_t len) {return 0;} -WEAK int hal_ispi_recv(const void *cmd, void *data, uint32_t len) {return 0;} +WEAK int hal_ispi_open(const struct HAL_SPI_CFG_T *cfg) { return 0; } +WEAK int hal_ispi_send(const void *data, uint32_t len) { return 0; } +WEAK int hal_ispi_recv(const void *cmd, void *data, uint32_t len) { return 0; } #endif WEAK void analog_aud_freq_pll_config(uint32_t freq, uint32_t div) {} @@ -90,12 +121,10 @@ WEAK void analog_aud_pll_open(enum ANA_AUD_PLL_USER_T user) {} WEAK void analog_aud_pll_close(enum ANA_AUD_PLL_USER_T user) {} WEAK void analog_aud_codec_speaker_enable(bool en) {} WEAK void analog_aud_set_dac_gain(int32_t v) {} -WEAK uint32_t analog_aud_get_max_dre_gain(void) {return 0;} +WEAK uint32_t analog_aud_get_max_dre_gain(void) { return 0; } WEAK void analog_aud_vad_adc_enable(bool en) {} WEAK void analog_aud_vad_enable(enum AUD_VAD_TYPE_T type, bool en) {} #endif - } #endif // __ARMCC_VERSION - diff --git a/platform/cmsis/retarget_gcc.cpp b/platform/cmsis/retarget_gcc.cpp index 84d6f0a..58cba1a 100644 --- a/platform/cmsis/retarget_gcc.cpp +++ b/platform/cmsis/retarget_gcc.cpp @@ -19,58 +19,51 @@ #define LIBC_HOOKS #endif -#ifdef LIBC_HOOKS +#ifdef LIBC_HOOKS -#include #include "hal_trace.h" +#include #ifndef FILEHANDLE typedef int FILEHANDLE; #endif -#define WEAK __attribute__((weak)) -#define PACKED __attribute__((packed)) +#define WEAK __attribute__((weak)) +#define PACKED __attribute__((packed)) #include -#include #include -#define PREFIX(x) x +#include +#define PREFIX(x) x extern "C" int PREFIX(_write)(FILEHANDLE fh, const unsigned char *buffer, - unsigned int length, int mode) -{ - int n = 0; // n is the number of bytes written - if (fh < 3) { - hal_trace_output(buffer, length); - n = length; - } - return n; + unsigned int length, int mode) { + int n = 0; // n is the number of bytes written + if (fh < 3) { + hal_trace_output(buffer, length); + n = length; + } + return n; } extern "C" int PREFIX(_read)(FILEHANDLE fh, unsigned char *buffer, - unsigned int length, int mode) -{ - int n = 0; // n is the number of bytes read - if (fh < 3) { - // only read a character at a time from stdin - // TODO: Read from trace uart input - n = 1; - } - return n; + unsigned int length, int mode) { + int n = 0; // n is the number of bytes read + if (fh < 3) { + // only read a character at a time from stdin + // TODO: Read from trace uart input + n = 1; + } + return n; } #if defined(__GNUC__) /* prevents the exception handling name demangling code getting pulled in */ namespace __gnu_cxx { - void __verbose_terminate_handler() { - ASSERT(0, "Exception"); - } +void __verbose_terminate_handler() { ASSERT(0, "Exception"); } } extern "C" WEAK void __cxa_pure_virtual(void); -extern "C" WEAK void __cxa_pure_virtual(void) -{ - _exit(1); -} +extern "C" WEAK void __cxa_pure_virtual(void) { _exit(1); } #endif @@ -80,63 +73,64 @@ extern "C" WEAK void __cxa_pure_virtual(void) #if defined(__GNUC__) && defined(__arm__) // Linker defined symbol used by _sbrk to indicate where heap should start. extern "C" int __end__; -extern "C" uint32_t __HeapLimit; +extern "C" uint32_t __HeapLimit; // Turn off the errno macro and use actual global variable instead. #undef errno extern "C" int errno; // For ARM7 only -register unsigned char * stack_ptr __asm ("sp"); +register unsigned char *stack_ptr __asm("sp"); // Dynamic memory allocation related syscall. -extern "C" caddr_t _sbrk(int incr) -{ - static unsigned char* heap = (unsigned char*)&__end__; - unsigned char* prev_heap = heap; - unsigned char* new_heap = heap + incr; +extern "C" caddr_t _sbrk(int incr) { + static unsigned char *heap = (unsigned char *)&__end__; + unsigned char *prev_heap = heap; + unsigned char *new_heap = heap + incr; #if defined(TARGET_ARM7) - if (new_heap >= stack_ptr) { + if (new_heap >= stack_ptr) { #elif defined(TARGET_CORTEX_A) - if (new_heap >= (unsigned char*)&__HeapLimit) { /* __HeapLimit is end of heap section */ + if (new_heap >= + (unsigned char *)&__HeapLimit) { /* __HeapLimit is end of heap section */ #else - if (new_heap >= (unsigned char*)&__HeapLimit) { /* __HeapLimit is end of heap section */ + if (new_heap >= + (unsigned char *)&__HeapLimit) { /* __HeapLimit is end of heap section */ #endif - ASSERT(false, "_sbrk:Heap overflowed: start=%p end=%p cur=%p incr=%d", - (unsigned char*)&__end__, (unsigned char*)&__HeapLimit, heap, incr); - errno = ENOMEM; - return (caddr_t)-1; - } + ASSERT(false, "_sbrk:Heap overflowed: start=%p end=%p cur=%p incr=%d", + (unsigned char *)&__end__, (unsigned char *)&__HeapLimit, heap, + incr); + errno = ENOMEM; + return (caddr_t)-1; + } - TRACE(2,"_sbrk: incr %d cur=%p\n", incr, heap); + TRACE(2, "_sbrk: incr %d cur=%p\n", incr, heap); - heap = new_heap; - return (caddr_t) prev_heap; + heap = new_heap; + return (caddr_t)prev_heap; } #endif - #if defined(__GNUC__) && defined(__arm__) -extern "C" void _exit(int return_code) -{ +extern "C" void _exit(int return_code) { #else namespace std { -extern "C" void exit(int return_code) -{ +extern "C" void exit(int return_code) { #endif - if (return_code) { - ASSERT(false, "system die: %d", return_code); - } + if (return_code) { + ASSERT(false, "system die: %d", return_code); + } - do { volatile int i = 0; i++; } while (1); + do { + volatile int i = 0; + i++; + } while (1); } #if !(defined(__GNUC__) && defined(__arm__)) && !defined(TOOLCHAIN_GCC_CW) -} //namespace std +} // namespace std #endif #endif /*LIBC_HOOKS*/ #endif // __GNUC__ && !__ARMCC_VERSION - diff --git a/platform/cmsis/stack_protector.c b/platform/cmsis/stack_protector.c index fcda603..d3a3de9 100644 --- a/platform/cmsis/stack_protector.c +++ b/platform/cmsis/stack_protector.c @@ -1,22 +1,15 @@ +#include #include #include -#include uint32_t __stack_chk_guard = 0xdeadbeef; -void -__attribute__((__constructor__)) -__stack_chk_init (void) -{ +void __attribute__((__constructor__)) __stack_chk_init(void) { if (__stack_chk_guard != 0) return; } -void -__attribute__((__noreturn__)) -__stack_chk_fail (void) -{ +void __attribute__((__noreturn__)) __stack_chk_fail(void) { const char *msg = "*** stack smashing detected ***: terminated\n"; ASSERT(0, "%s", msg); } - diff --git a/platform/cmsis/system_ARMCM.c b/platform/cmsis/system_ARMCM.c index ceef625..80ac1a9 100644 --- a/platform/cmsis/system_ARMCM.c +++ b/platform/cmsis/system_ARMCM.c @@ -15,72 +15,69 @@ ****************************************************************************/ #ifndef __ARM_ARCH_ISA_ARM +#include "system_ARMCM.h" #include "cmsis.h" #include "hal_location.h" -#include "system_ARMCM.h" -void BOOT_TEXT_FLASH_LOC SystemInit (void) -{ +void BOOT_TEXT_FLASH_LOC SystemInit(void) { #if (__FPU_USED == 1) - SCB->CPACR |= ((3UL << 10*2) | /* set CP10 Full Access */ - (3UL << 11*2) ); /* set CP11 Full Access */ + SCB->CPACR |= ((3UL << 10 * 2) | /* set CP10 Full Access */ + (3UL << 11 * 2)); /* set CP11 Full Access */ #endif - SCB->CCR |= SCB_CCR_DIV_0_TRP_Msk; + SCB->CCR |= SCB_CCR_DIV_0_TRP_Msk; #ifdef __ARM_ARCH_8M_MAIN__ - // Disable stack limit check on hard fault, NMI and reset - // (The check will generate STKOF usage fault) - SCB->CCR |= SCB_CCR_STKOFHFNMIGN_Msk; + // Disable stack limit check on hard fault, NMI and reset + // (The check will generate STKOF usage fault) + SCB->CCR |= SCB_CCR_STKOFHFNMIGN_Msk; #endif #ifdef UNALIGNED_ACCESS - SCB->CCR &= ~SCB_CCR_UNALIGN_TRP_Msk; + SCB->CCR &= ~SCB_CCR_UNALIGN_TRP_Msk; #else - SCB->CCR |= SCB_CCR_UNALIGN_TRP_Msk; + SCB->CCR |= SCB_CCR_UNALIGN_TRP_Msk; #endif #ifdef USAGE_FAULT - SCB->SHCSR |= SCB_SHCSR_USGFAULTENA_Msk; - NVIC_SetPriority(UsageFault_IRQn, IRQ_PRIORITY_REALTIME); + SCB->SHCSR |= SCB_SHCSR_USGFAULTENA_Msk; + NVIC_SetPriority(UsageFault_IRQn, IRQ_PRIORITY_REALTIME); #else - SCB->SHCSR &= ~SCB_SHCSR_USGFAULTENA_Msk; + SCB->SHCSR &= ~SCB_SHCSR_USGFAULTENA_Msk; #endif #ifdef BUS_FAULT - SCB->SHCSR |= SCB_SHCSR_BUSFAULTENA_Msk; - NVIC_SetPriority(BusFault_IRQn, IRQ_PRIORITY_REALTIME); + SCB->SHCSR |= SCB_SHCSR_BUSFAULTENA_Msk; + NVIC_SetPriority(BusFault_IRQn, IRQ_PRIORITY_REALTIME); #else - SCB->SHCSR &= ~SCB_SHCSR_BUSFAULTENA_Msk; + SCB->SHCSR &= ~SCB_SHCSR_BUSFAULTENA_Msk; #endif #ifdef MEM_FAULT - SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; - NVIC_SetPriority(MemoryManagement_IRQn, IRQ_PRIORITY_REALTIME); + SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; + NVIC_SetPriority(MemoryManagement_IRQn, IRQ_PRIORITY_REALTIME); #else - SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; + SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; #endif -#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) - TZ_SAU_Setup(); +#if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + TZ_SAU_Setup(); #endif } #ifndef UNALIGNED_ACCESS -bool get_unaligned_access_status(void) -{ - return !(SCB->CCR & SCB_CCR_UNALIGN_TRP_Msk); +bool get_unaligned_access_status(void) { + return !(SCB->CCR & SCB_CCR_UNALIGN_TRP_Msk); } -bool config_unaligned_access(bool enable) -{ - bool en; +bool config_unaligned_access(bool enable) { + bool en; - en = !(SCB->CCR & SCB_CCR_UNALIGN_TRP_Msk); + en = !(SCB->CCR & SCB_CCR_UNALIGN_TRP_Msk); - if (enable) { - SCB->CCR &= ~SCB_CCR_UNALIGN_TRP_Msk; - } else { - SCB->CCR |= SCB_CCR_UNALIGN_TRP_Msk; - } + if (enable) { + SCB->CCR &= ~SCB_CCR_UNALIGN_TRP_Msk; + } else { + SCB->CCR |= SCB_CCR_UNALIGN_TRP_Msk; + } - return en; + return en; } #endif @@ -89,16 +86,15 @@ bool config_unaligned_access(bool enable) // CPU ID // ----------------------------------------------------------- -uint32_t BOOT_TEXT_SRAM_DEF(get_cpu_id) (void) -{ +uint32_t BOOT_TEXT_SRAM_DEF(get_cpu_id)(void) { #ifdef CHIP_HAS_CP #ifdef __ARM_ARCH_8M_MAIN__ - return (SCB->ID_ADR & 3); -#else /*__ARM_ARCH_8M_MAIN__*/ - return (SCB->ADR & 3); + return (SCB->ID_ADR & 3); +#else /*__ARM_ARCH_8M_MAIN__*/ + return (SCB->ADR & 3); #endif /*__ARM_ARCH_8M_MAIN__*/ #else - return 0; + return 0; #endif } diff --git a/platform/cmsis/system_cp.c b/platform/cmsis/system_cp.c index 217a630..f8a6c39 100644 --- a/platform/cmsis/system_cp.c +++ b/platform/cmsis/system_cp.c @@ -17,29 +17,29 @@ #ifdef CHIP_HAS_CP #include "cmsis_nvic.h" -#include "plat_types.h" -#include "plat_addr_map.h" #include "hal_cache.h" #include "hal_location.h" +#include "plat_addr_map.h" +#include "plat_types.h" #ifdef __ARMCC_VERSION #include "link_sym_armclang.h" #endif -// The vector table must be aligned to NVIC_NUM_VECTORS-word boundary, rounding up to the next power of two +// The vector table must be aligned to NVIC_NUM_VECTORS-word boundary, rounding +// up to the next power of two // -- 0x100 for 33~64 vectors, and 0x200 for 65~128 vectors #if defined(ROM_BUILD) || defined(PROGRAMMER) || (RAMCP_SIZE <= 0) -#define VECTOR_LOC_CP ALIGNED(0x200) +#define VECTOR_LOC_CP ALIGNED(0x200) #else -#define VECTOR_LOC_CP __attribute__((section(".vector_table_cp"))) +#define VECTOR_LOC_CP __attribute__((section(".vector_table_cp"))) #endif -#define FAULT_HANDLER_CP __attribute__((weak,alias("NVIC_default_handler_cp"))) +#define FAULT_HANDLER_CP __attribute__((weak, alias("NVIC_default_handler_cp"))) static uint32_t VECTOR_LOC_CP vector_table_cp[NVIC_NUM_VECTORS]; -static void NAKED NVIC_default_handler_cp(void) -{ - asm volatile("_loop:; nop; nop; nop; nop; b _loop;"); +static void NAKED NVIC_default_handler_cp(void) { + asm volatile("_loop:; nop; nop; nop; nop; b _loop;"); } void FAULT_HANDLER_CP Reset_Handler_cp(void); @@ -72,64 +72,62 @@ static const uint32_t fault_handlers_cp[NVIC_USER_IRQ_OFFSET] = { (uint32_t)SysTick_Handler_cp, }; -void NVIC_InitVectors_cp(void) -{ - int i; +void NVIC_InitVectors_cp(void) { + int i; - for (i = 0; i < NVIC_NUM_VECTORS; i++) { - vector_table_cp[i] = (i < ARRAY_SIZE(fault_handlers_cp)) ? - fault_handlers_cp[i] : (uint32_t)NVIC_default_handler_cp; - } + for (i = 0; i < NVIC_NUM_VECTORS; i++) { + vector_table_cp[i] = (i < ARRAY_SIZE(fault_handlers_cp)) + ? fault_handlers_cp[i] + : (uint32_t)NVIC_default_handler_cp; + } - SCB->VTOR = (uint32_t)vector_table_cp; + SCB->VTOR = (uint32_t)vector_table_cp; } -void NVIC_SetDefaultFaultHandler_cp(NVIC_DEFAULT_FAULT_HANDLER_T handler) -{ - int i; +void NVIC_SetDefaultFaultHandler_cp(NVIC_DEFAULT_FAULT_HANDLER_T handler) { + int i; - for (i = 1; i < ARRAY_SIZE(fault_handlers_cp); i++) { - if (vector_table_cp[i] == (uint32_t)NVIC_default_handler_cp) { - vector_table_cp[i] = (uint32_t)handler; - } + for (i = 1; i < ARRAY_SIZE(fault_handlers_cp); i++) { + if (vector_table_cp[i] == (uint32_t)NVIC_default_handler_cp) { + vector_table_cp[i] = (uint32_t)handler; } + } } -void SystemInit_cp(void) -{ +void SystemInit_cp(void) { #if (__FPU_USED == 1) - SCB->CPACR |= ((3UL << 10*2) | /* set CP10 Full Access */ - (3UL << 11*2) ); /* set CP11 Full Access */ + SCB->CPACR |= ((3UL << 10 * 2) | /* set CP10 Full Access */ + (3UL << 11 * 2)); /* set CP11 Full Access */ #endif - SCB->CCR |= SCB_CCR_DIV_0_TRP_Msk; + SCB->CCR |= SCB_CCR_DIV_0_TRP_Msk; #ifdef __ARM_ARCH_8M_MAIN__ - // Disable stack limit check on hard fault, NMI and reset - // (The check will generate STKOF usage fault) - SCB->CCR |= SCB_CCR_STKOFHFNMIGN_Msk; + // Disable stack limit check on hard fault, NMI and reset + // (The check will generate STKOF usage fault) + SCB->CCR |= SCB_CCR_STKOFHFNMIGN_Msk; #endif #ifdef UNALIGNED_ACCESS - SCB->CCR &= ~SCB_CCR_UNALIGN_TRP_Msk; + SCB->CCR &= ~SCB_CCR_UNALIGN_TRP_Msk; #else - SCB->CCR |= SCB_CCR_UNALIGN_TRP_Msk; + SCB->CCR |= SCB_CCR_UNALIGN_TRP_Msk; #endif #ifdef USAGE_FAULT - SCB->SHCSR |= SCB_SHCSR_USGFAULTENA_Msk; - NVIC_SetPriority(UsageFault_IRQn, IRQ_PRIORITY_REALTIME); + SCB->SHCSR |= SCB_SHCSR_USGFAULTENA_Msk; + NVIC_SetPriority(UsageFault_IRQn, IRQ_PRIORITY_REALTIME); #else - SCB->SHCSR &= ~SCB_SHCSR_USGFAULTENA_Msk; + SCB->SHCSR &= ~SCB_SHCSR_USGFAULTENA_Msk; #endif #ifdef BUS_FAULT - SCB->SHCSR |= SCB_SHCSR_BUSFAULTENA_Msk; - NVIC_SetPriority(BusFault_IRQn, IRQ_PRIORITY_REALTIME); + SCB->SHCSR |= SCB_SHCSR_BUSFAULTENA_Msk; + NVIC_SetPriority(BusFault_IRQn, IRQ_PRIORITY_REALTIME); #else - SCB->SHCSR &= ~SCB_SHCSR_BUSFAULTENA_Msk; + SCB->SHCSR &= ~SCB_SHCSR_BUSFAULTENA_Msk; #endif #ifdef MEM_FAULT - SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; - NVIC_SetPriority(MemoryManagement_IRQn, IRQ_PRIORITY_REALTIME); + SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; + NVIC_SetPriority(MemoryManagement_IRQn, IRQ_PRIORITY_REALTIME); #else - SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; + SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; #endif } @@ -142,97 +140,95 @@ extern uint32_t __cp_data_sram_end[]; extern uint32_t __cp_bss_sram_start[]; extern uint32_t __cp_bss_sram_end[]; -void NAKED system_cp_reset_handler(void) -{ - asm volatile ( +void NAKED system_cp_reset_handler(void) { + asm volatile( #ifdef __ARM_ARCH_8M_MAIN__ - "ldr r0, =" TO_STRING(__cp_stack_limit) ";" - "msr msplim, r0;" + "ldr r0, =" TO_STRING( + __cp_stack_limit) ";" + "msr msplim, r0;" #endif - "ldr r3, =" TO_STRING(__cp_stack_top) ";" - "msr msp, r3;" - "movs r4, 0;" - "mov r5, r4;" - "mov r6, r4;" - "mov r7, r4;" - "mov r8, r4;" - "mov r9, r4;" - "mov r10, r4;" - "mov r11, r4;" - "mov r12, r4;" + "ldr r3, =" TO_STRING( + __cp_stack_top) ";" + "msr msp, r3;" + "movs r4, 0;" + "mov r5, r4;" + "mov r6, r4;" + "mov r7, r4;" + "mov r8, r4;" + "mov r9, r4;" + "mov r10, r4;" + "mov r11, r4;" + "mov r12, r4;" #if !defined(__SOFTFP__) && defined(__ARM_FP) && (__ARM_FP >= 4) - "ldr.w r0, =0xE000ED88;" - "ldr r1, [r0];" - "orr r1, r1, #(0xF << 20);" - "str r1, [r0];" - "dsb;" - "isb;" - "vmov s0, s1, r4, r5;" - "vmov s2, s3, r4, r5;" - "vmov s4, s5, r4, r5;" - "vmov s6, s7, r4, r5;" - "vmov s8, s9, r4, r5;" - "vmov s10, s11, r4, r5;" - "vmov s12, s13, r4, r5;" - "vmov s14, s15, r4, r5;" - "vmov s16, s17, r4, r5;" - "vmov s18, s19, r4, r5;" - "vmov s20, s21, r4, r5;" - "vmov s22, s23, r4, r5;" - "vmov s24, s25, r4, r5;" - "vmov s26, s27, r4, r5;" - "vmov s28, s29, r4, r5;" - "vmov s30, s31, r4, r5;" + "ldr.w r0, =0xE000ED88;" + "ldr r1, [r0];" + "orr r1, r1, #(0xF << 20);" + "str r1, [r0];" + "dsb;" + "isb;" + "vmov s0, s1, r4, r5;" + "vmov s2, s3, r4, r5;" + "vmov s4, s5, r4, r5;" + "vmov s6, s7, r4, r5;" + "vmov s8, s9, r4, r5;" + "vmov s10, s11, r4, r5;" + "vmov s12, s13, r4, r5;" + "vmov s14, s15, r4, r5;" + "vmov s16, s17, r4, r5;" + "vmov s18, s19, r4, r5;" + "vmov s20, s21, r4, r5;" + "vmov s22, s23, r4, r5;" + "vmov s24, s25, r4, r5;" + "vmov s26, s27, r4, r5;" + "vmov s28, s29, r4, r5;" + "vmov s30, s31, r4, r5;" #endif - "bl hal_cmu_cp_get_entry_addr;" - "blx r0;" - ); + "bl hal_cmu_cp_get_entry_addr;" + "blx r0;"); } -void system_cp_init(int load_code) -{ - NVIC_InitVectors_cp(); +void system_cp_init(int load_code) { + NVIC_InitVectors_cp(); - // Enable icache - hal_cachecp_enable(HAL_CACHE_ID_I_CACHE); - // Enable dcache - hal_cachecp_enable(HAL_CACHE_ID_D_CACHE); - // Enable write back - hal_cachecp_writeback_enable(HAL_CACHE_ID_D_CACHE); + // Enable icache + hal_cachecp_enable(HAL_CACHE_ID_I_CACHE); + // Enable dcache + hal_cachecp_enable(HAL_CACHE_ID_D_CACHE); + // Enable write back + hal_cachecp_writeback_enable(HAL_CACHE_ID_D_CACHE); - SystemInit_cp(); + SystemInit_cp(); #if !(defined(ROM_BUILD) || defined(PROGRAMMER)) - uint32_t *dst; - uint32_t *src; + uint32_t *dst; + uint32_t *src; - if (load_code) { - dst = __cp_text_sram_start; - src = __cp_text_sram_start_flash__; - for (; dst < __cp_text_sram_end; dst++, src++) { - *dst = *src; - } + if (load_code) { + dst = __cp_text_sram_start; + src = __cp_text_sram_start_flash__; + for (; dst < __cp_text_sram_end; dst++, src++) { + *dst = *src; } + } - dst = __cp_data_sram_start; - src = __cp_data_sram_start_flash__; - for (; dst < __cp_data_sram_end; dst++, src++) { - *dst = *src; - } + dst = __cp_data_sram_start; + src = __cp_data_sram_start_flash__; + for (; dst < __cp_data_sram_end; dst++, src++) { + *dst = *src; + } - dst = __cp_bss_sram_start; - for (; dst < __cp_bss_sram_end; dst++) { - *dst = 0; - } + dst = __cp_bss_sram_start; + for (; dst < __cp_bss_sram_end; dst++) { + *dst = 0; + } #endif } -void system_cp_term(void) -{ - // Disable dcache - hal_cachecp_disable(HAL_CACHE_ID_D_CACHE); - // Disable icache - hal_cachecp_disable(HAL_CACHE_ID_I_CACHE); +void system_cp_term(void) { + // Disable dcache + hal_cachecp_disable(HAL_CACHE_ID_D_CACHE); + // Disable icache + hal_cachecp_disable(HAL_CACHE_ID_I_CACHE); } #endif diff --git a/platform/cmsis/system_utils.c b/platform/cmsis/system_utils.c index 885b8a1..3243e4e 100644 --- a/platform/cmsis/system_utils.c +++ b/platform/cmsis/system_utils.c @@ -27,17 +27,16 @@ #endif #ifdef BOOT_CODE_IN_RAM -#define MUTEX_CODE_LOC BOOT_TEXT_SRAM_LOC +#define MUTEX_CODE_LOC BOOT_TEXT_SRAM_LOC #else #define MUTEX_CODE_LOC #endif extern uint32_t __got_info_start[]; -void BOOT_TEXT_FLASH_LOC GotBaseInit(void) -{ +void BOOT_TEXT_FLASH_LOC GotBaseInit(void) { #ifndef __ARMCC_VERSION - asm volatile("ldr r9, =__got_info_start"); + asm volatile("ldr r9, =__got_info_start"); #endif } @@ -64,67 +63,63 @@ extern uint32_t __fast_sram_text_data_end__[]; extern uint32_t __fast_sram_text_data_start_flash__[]; extern uint32_t __fast_sram_text_data_end_flash__[]; -void BOOT_TEXT_FLASH_LOC BootInit(void) -{ - uint32_t *dst, *src; +void BOOT_TEXT_FLASH_LOC BootInit(void) { + uint32_t *dst, *src; - // Enable icache - hal_cache_enable(HAL_CACHE_ID_I_CACHE); - // Enable dcache - hal_cache_enable(HAL_CACHE_ID_D_CACHE); - // Enable write buffer - hal_cache_writebuffer_enable(HAL_CACHE_ID_D_CACHE); - // Enable write back - hal_cache_writeback_enable(HAL_CACHE_ID_D_CACHE); + // Enable icache + hal_cache_enable(HAL_CACHE_ID_I_CACHE); + // Enable dcache + hal_cache_enable(HAL_CACHE_ID_D_CACHE); + // Enable write buffer + hal_cache_writebuffer_enable(HAL_CACHE_ID_D_CACHE); + // Enable write back + hal_cache_writeback_enable(HAL_CACHE_ID_D_CACHE); - // Init GOT base register - GotBaseInit(); + // Init GOT base register + GotBaseInit(); - // Init boot sections - for (dst = __boot_sram_start__, src = __boot_sram_start_flash__; - src < __boot_sram_end_flash__; - dst++, src++) { - *dst = *src; - } + // Init boot sections + for (dst = __boot_sram_start__, src = __boot_sram_start_flash__; + src < __boot_sram_end_flash__; dst++, src++) { + *dst = *src; + } - for (dst = __boot_bss_sram_start__; dst < __boot_bss_sram_end__; dst++) { - *dst = 0; - } + for (dst = __boot_bss_sram_start__; dst < __boot_bss_sram_end__; dst++) { + *dst = 0; + } #ifdef FPGA - hal_cmu_fpga_setup(); + hal_cmu_fpga_setup(); #else - hal_cmu_setup(); + hal_cmu_setup(); #endif - for (dst = __sram_text_data_start__, src = __sram_text_data_start_flash__; - src < __sram_text_data_end_flash__; - dst++, src++) { - *dst = *src; - } + for (dst = __sram_text_data_start__, src = __sram_text_data_start_flash__; + src < __sram_text_data_end_flash__; dst++, src++) { + *dst = *src; + } - for (dst = __sram_bss_start__; dst < __sram_bss_end__; dst++) { - *dst = 0; - } + for (dst = __sram_bss_start__; dst < __sram_bss_end__; dst++) { + *dst = 0; + } - for (dst = __fast_sram_text_data_start__, src = __fast_sram_text_data_start_flash__; - src < __fast_sram_text_data_end_flash__; - dst++, src++) { - *dst = *src; - } + for (dst = __fast_sram_text_data_start__, + src = __fast_sram_text_data_start_flash__; + src < __fast_sram_text_data_end_flash__; dst++, src++) { + *dst = *src; + } - // Init psram + // Init psram #if defined(CHIP_HAS_PSRAM) && defined(PSRAM_ENABLE) - hal_psram_init(); + hal_psram_init(); #endif - // Init psramuhs + // Init psramuhs #if defined(CHIP_HAS_PSRAMUHS) && defined(PSRAMUHS_ENABLE) - hal_cmu_dsp_clock_enable(); - hal_cmu_dsp_reset_clear(); - hal_psramuhs_init(); + hal_cmu_dsp_clock_enable(); + hal_cmu_dsp_reset_clear(); + hal_psramuhs_init(); #endif - } #endif @@ -132,143 +127,133 @@ void BOOT_TEXT_FLASH_LOC BootInit(void) // Mutex flag // ----------------------------------------------------------- -int MUTEX_CODE_LOC set_bool_flag(bool *flag) -{ - bool busy; +int MUTEX_CODE_LOC set_bool_flag(bool *flag) { + bool busy; - do { - busy = (bool)__LDREXB((unsigned char *)flag); - if (busy) { - __CLREX(); - return -1; - } - } while (__STREXB(true, (unsigned char *)flag)); - __DMB(); + do { + busy = (bool)__LDREXB((unsigned char *)flag); + if (busy) { + __CLREX(); + return -1; + } + } while (__STREXB(true, (unsigned char *)flag)); + __DMB(); - return 0; + return 0; } -void MUTEX_CODE_LOC clear_bool_flag(bool *flag) -{ - *flag = false; - __DMB(); +void MUTEX_CODE_LOC clear_bool_flag(bool *flag) { + *flag = false; + __DMB(); } // ----------------------------------------------------------- // Misc // ----------------------------------------------------------- -float db_to_float(float db) -{ - float coef; +float db_to_float(float db) { + float coef; #if !defined(NOSTD) && defined(ACCURATE_DB_TO_FLOAT) - // The math lib will consume 4K+ bytes of space - coef = powf(10, db / 20); + // The math lib will consume 4K+ bytes of space + coef = powf(10, db / 20); #else - static const float factor_m9db = 0.354813389234; - static const float factor_m3db = 0.707945784384; - static const float factor_m1db = 0.891250938134; - static const float factor_m0p5db = 0.944060876286; - static const float factor_m0p1db = 0.988553094657; + static const float factor_m9db = 0.354813389234; + static const float factor_m3db = 0.707945784384; + static const float factor_m1db = 0.891250938134; + static const float factor_m0p5db = 0.944060876286; + static const float factor_m0p1db = 0.988553094657; - coef = 1.0; + coef = 1.0; - if (db < 0) { - while (1) { - if (db <= -9.0) { - db += 9.0; - coef *= factor_m9db; - } else if (db <= -3.0) { - db += 3.0; - coef *= factor_m3db; - } else if (db <= -1.0) { - db += 1.0; - coef *= factor_m1db; - } else if (db <= -0.5) { - db += 0.5; - coef *= factor_m0p5db; - } else if (db <= -0.1 / 2) { - db += 0.1; - coef *= factor_m0p1db; - } else { - break; - } - } - } else if (db > 0) { - while (1) { - if (db >= 9.0) { - db -= 9.0; - coef /= factor_m9db; - } else if (db >= 3.0) { - db -= 3.0; - coef /= factor_m3db; - } else if (db >= 1.0) { - db -= 1.0; - coef /= factor_m1db; - } else if (db >= 0.5) { - db -= 0.5; - coef /= factor_m0p5db; - } else if (db >= 0.1 / 2) { - db -= 0.1; - coef /= factor_m0p1db; - } else { - break; - } - } + if (db < 0) { + while (1) { + if (db <= -9.0) { + db += 9.0; + coef *= factor_m9db; + } else if (db <= -3.0) { + db += 3.0; + coef *= factor_m3db; + } else if (db <= -1.0) { + db += 1.0; + coef *= factor_m1db; + } else if (db <= -0.5) { + db += 0.5; + coef *= factor_m0p5db; + } else if (db <= -0.1 / 2) { + db += 0.1; + coef *= factor_m0p1db; + } else { + break; + } } + } else if (db > 0) { + while (1) { + if (db >= 9.0) { + db -= 9.0; + coef /= factor_m9db; + } else if (db >= 3.0) { + db -= 3.0; + coef /= factor_m3db; + } else if (db >= 1.0) { + db -= 1.0; + coef /= factor_m1db; + } else if (db >= 0.5) { + db -= 0.5; + coef /= factor_m0p5db; + } else if (db >= 0.1 / 2) { + db -= 0.1; + coef /= factor_m0p1db; + } else { + break; + } + } + } #endif - return coef; + return coef; } -uint32_t get_msb_pos(uint32_t val) -{ - uint32_t lead_zero; +uint32_t get_msb_pos(uint32_t val) { + uint32_t lead_zero; - lead_zero = __CLZ(val); - return (lead_zero >= 32) ? 32 : 31 - lead_zero; + lead_zero = __CLZ(val); + return (lead_zero >= 32) ? 32 : 31 - lead_zero; } -uint32_t get_lsb_pos(uint32_t val) -{ - return __CLZ(__RBIT(val)); -} +uint32_t get_lsb_pos(uint32_t val) { return __CLZ(__RBIT(val)); } -uint32_t integer_sqrt(uint32_t val) -{ - unsigned int msb; - unsigned int x; - unsigned int y; +uint32_t integer_sqrt(uint32_t val) { + unsigned int msb; + unsigned int x; + unsigned int y; - if (val == 0) { - return 0; + if (val == 0) { + return 0; + } + + for (msb = 31; msb > 0; msb--) { + if (val & (1 << msb)) { + break; } + } - for (msb = 31; msb > 0; msb--) { - if (val & (1 << msb)) { - break; - } + x = ((1 << msb) + 1) / 2; + + while (1) { + y = (x + val / x) / 2; + if (y >= x) { + break; } + x = y; + } - x = ((1 << msb) + 1) / 2; - - while (1) { - y = (x + val / x) / 2; - if (y >= x) { - break; - } - x = y; - } - - return x; + return x; } -uint32_t integer_sqrt_nearest(uint32_t val) -{ - unsigned int s; +uint32_t integer_sqrt_nearest(uint32_t val) { + unsigned int s; - s = integer_sqrt(val * 4); - return (s + 1) / 2; + s = integer_sqrt(val * 4); + return (s + 1) / 2; } - diff --git a/platform/drivers/ana/best2300p/analog_best2300p.c b/platform/drivers/ana/best2300p/analog_best2300p.c index 86e0dfb..3db50ec 100644 --- a/platform/drivers/ana/best2300p/analog_best2300p.c +++ b/platform/drivers/ana/best2300p/analog_best2300p.c @@ -13,9 +13,9 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" #include "analog.h" #include "cmsis.h" +#include "plat_types.h" #ifdef RTOS #include "cmsis_os.h" #endif @@ -27,7 +27,6 @@ #include "pmu.h" #include "tgt_hardware.h" - #define VCM_ON // Not using 1uF @@ -39,788 +38,840 @@ #define LOW_CODEC_BIAS #endif -#define DAC_DC_CALIB_BIT_WIDTH 14 +#define DAC_DC_CALIB_BIT_WIDTH 14 -#define DEFAULT_ANC_FF_ADC_GAIN_DB 6 -#define DEFAULT_ANC_FB_ADC_GAIN_DB 6 -#define DEFAULT_VOICE_ADC_GAIN_DB 12 +#define DEFAULT_ANC_FF_ADC_GAIN_DB 6 +#define DEFAULT_ANC_FB_ADC_GAIN_DB 6 +#define DEFAULT_VOICE_ADC_GAIN_DB 12 #ifndef ANALOG_ADC_A_GAIN_DB -#if defined(ANC_APP) && defined(ANC_FF_ENABLED) && ((ANC_FF_MIC_CH_L == AUD_CHANNEL_MAP_CH0) || (ANC_FF_MIC_CH_R == AUD_CHANNEL_MAP_CH0)) -#define ANALOG_ADC_A_GAIN_DB DEFAULT_ANC_FF_ADC_GAIN_DB -#elif defined(ANC_APP) && defined(ANC_FB_ENABLED) && ((ANC_FB_MIC_CH_L == AUD_CHANNEL_MAP_CH0) || (ANC_FB_MIC_CH_R == AUD_CHANNEL_MAP_CH0)) -#define ANALOG_ADC_A_GAIN_DB DEFAULT_ANC_FB_ADC_GAIN_DB +#if defined(ANC_APP) && defined(ANC_FF_ENABLED) && \ + ((ANC_FF_MIC_CH_L == AUD_CHANNEL_MAP_CH0) || \ + (ANC_FF_MIC_CH_R == AUD_CHANNEL_MAP_CH0)) +#define ANALOG_ADC_A_GAIN_DB DEFAULT_ANC_FF_ADC_GAIN_DB +#elif defined(ANC_APP) && defined(ANC_FB_ENABLED) && \ + ((ANC_FB_MIC_CH_L == AUD_CHANNEL_MAP_CH0) || \ + (ANC_FB_MIC_CH_R == AUD_CHANNEL_MAP_CH0)) +#define ANALOG_ADC_A_GAIN_DB DEFAULT_ANC_FB_ADC_GAIN_DB #else -#define ANALOG_ADC_A_GAIN_DB DEFAULT_VOICE_ADC_GAIN_DB +#define ANALOG_ADC_A_GAIN_DB DEFAULT_VOICE_ADC_GAIN_DB #endif #endif #ifndef ANALOG_ADC_B_GAIN_DB -#if defined(ANC_APP) && defined(ANC_FF_ENABLED) && ((ANC_FF_MIC_CH_L == AUD_CHANNEL_MAP_CH1) || (ANC_FF_MIC_CH_R == AUD_CHANNEL_MAP_CH1)) -#define ANALOG_ADC_B_GAIN_DB DEFAULT_ANC_FF_ADC_GAIN_DB -#elif defined(ANC_APP) && defined(ANC_FB_ENABLED) && ((ANC_FB_MIC_CH_L == AUD_CHANNEL_MAP_CH1) || (ANC_FB_MIC_CH_R == AUD_CHANNEL_MAP_CH1)) -#define ANALOG_ADC_B_GAIN_DB DEFAULT_ANC_FB_ADC_GAIN_DB +#if defined(ANC_APP) && defined(ANC_FF_ENABLED) && \ + ((ANC_FF_MIC_CH_L == AUD_CHANNEL_MAP_CH1) || \ + (ANC_FF_MIC_CH_R == AUD_CHANNEL_MAP_CH1)) +#define ANALOG_ADC_B_GAIN_DB DEFAULT_ANC_FF_ADC_GAIN_DB +#elif defined(ANC_APP) && defined(ANC_FB_ENABLED) && \ + ((ANC_FB_MIC_CH_L == AUD_CHANNEL_MAP_CH1) || \ + (ANC_FB_MIC_CH_R == AUD_CHANNEL_MAP_CH1)) +#define ANALOG_ADC_B_GAIN_DB DEFAULT_ANC_FB_ADC_GAIN_DB #else -#define ANALOG_ADC_B_GAIN_DB DEFAULT_VOICE_ADC_GAIN_DB +#define ANALOG_ADC_B_GAIN_DB DEFAULT_VOICE_ADC_GAIN_DB #endif #endif #ifndef ANALOG_ADC_C_GAIN_DB -#if defined(ANC_APP) && defined(ANC_FF_ENABLED) && ((ANC_FF_MIC_CH_L == AUD_CHANNEL_MAP_CH2) || (ANC_FF_MIC_CH_R == AUD_CHANNEL_MAP_CH2)) -#define ANALOG_ADC_C_GAIN_DB DEFAULT_ANC_FF_ADC_GAIN_DB -#elif defined(ANC_APP) && defined(ANC_FB_ENABLED) && ((ANC_FB_MIC_CH_L == AUD_CHANNEL_MAP_CH2) || (ANC_FB_MIC_CH_R == AUD_CHANNEL_MAP_CH2)) -#define ANALOG_ADC_C_GAIN_DB DEFAULT_ANC_FB_ADC_GAIN_DB +#if defined(ANC_APP) && defined(ANC_FF_ENABLED) && \ + ((ANC_FF_MIC_CH_L == AUD_CHANNEL_MAP_CH2) || \ + (ANC_FF_MIC_CH_R == AUD_CHANNEL_MAP_CH2)) +#define ANALOG_ADC_C_GAIN_DB DEFAULT_ANC_FF_ADC_GAIN_DB +#elif defined(ANC_APP) && defined(ANC_FB_ENABLED) && \ + ((ANC_FB_MIC_CH_L == AUD_CHANNEL_MAP_CH2) || \ + (ANC_FB_MIC_CH_R == AUD_CHANNEL_MAP_CH2)) +#define ANALOG_ADC_C_GAIN_DB DEFAULT_ANC_FB_ADC_GAIN_DB #else -#define ANALOG_ADC_C_GAIN_DB DEFAULT_VOICE_ADC_GAIN_DB +#define ANALOG_ADC_C_GAIN_DB DEFAULT_VOICE_ADC_GAIN_DB #endif #endif #ifndef ANALOG_ADC_D_GAIN_DB -#if defined(ANC_APP) && defined(ANC_FF_ENABLED) && ((ANC_FF_MIC_CH_L == AUD_CHANNEL_MAP_CH3) || (ANC_FF_MIC_CH_R == AUD_CHANNEL_MAP_CH3)) -#define ANALOG_ADC_D_GAIN_DB DEFAULT_ANC_FF_ADC_GAIN_DB -#elif defined(ANC_APP) && defined(ANC_FB_ENABLED) && ((ANC_FB_MIC_CH_L == AUD_CHANNEL_MAP_CH3) || (ANC_FB_MIC_CH_R == AUD_CHANNEL_MAP_CH3)) -#define ANALOG_ADC_D_GAIN_DB DEFAULT_ANC_FB_ADC_GAIN_DB +#if defined(ANC_APP) && defined(ANC_FF_ENABLED) && \ + ((ANC_FF_MIC_CH_L == AUD_CHANNEL_MAP_CH3) || \ + (ANC_FF_MIC_CH_R == AUD_CHANNEL_MAP_CH3)) +#define ANALOG_ADC_D_GAIN_DB DEFAULT_ANC_FF_ADC_GAIN_DB +#elif defined(ANC_APP) && defined(ANC_FB_ENABLED) && \ + ((ANC_FB_MIC_CH_L == AUD_CHANNEL_MAP_CH3) || \ + (ANC_FB_MIC_CH_R == AUD_CHANNEL_MAP_CH3)) +#define ANALOG_ADC_D_GAIN_DB DEFAULT_ANC_FB_ADC_GAIN_DB #else -#define ANALOG_ADC_D_GAIN_DB DEFAULT_VOICE_ADC_GAIN_DB +#define ANALOG_ADC_D_GAIN_DB DEFAULT_VOICE_ADC_GAIN_DB #endif #endif #ifndef ANALOG_ADC_E_GAIN_DB -#if defined(ANC_APP) && defined(ANC_FF_ENABLED) && ((ANC_FF_MIC_CH_L == AUD_CHANNEL_MAP_CH4) || (ANC_FF_MIC_CH_R == AUD_CHANNEL_MAP_CH4)) -#define ANALOG_ADC_E_GAIN_DB DEFAULT_ANC_FF_ADC_GAIN_DB -#elif defined(ANC_APP) && defined(ANC_FB_ENABLED) && ((ANC_FB_MIC_CH_L == AUD_CHANNEL_MAP_CH4) || (ANC_FB_MIC_CH_R == AUD_CHANNEL_MAP_CH4)) -#define ANALOG_ADC_E_GAIN_DB DEFAULT_ANC_FB_ADC_GAIN_DB +#if defined(ANC_APP) && defined(ANC_FF_ENABLED) && \ + ((ANC_FF_MIC_CH_L == AUD_CHANNEL_MAP_CH4) || \ + (ANC_FF_MIC_CH_R == AUD_CHANNEL_MAP_CH4)) +#define ANALOG_ADC_E_GAIN_DB DEFAULT_ANC_FF_ADC_GAIN_DB +#elif defined(ANC_APP) && defined(ANC_FB_ENABLED) && \ + ((ANC_FB_MIC_CH_L == AUD_CHANNEL_MAP_CH4) || \ + (ANC_FB_MIC_CH_R == AUD_CHANNEL_MAP_CH4)) +#define ANALOG_ADC_E_GAIN_DB DEFAULT_ANC_FB_ADC_GAIN_DB #else -#define ANALOG_ADC_E_GAIN_DB DEFAULT_VOICE_ADC_GAIN_DB +#define ANALOG_ADC_E_GAIN_DB DEFAULT_VOICE_ADC_GAIN_DB #endif #endif #ifndef LINEIN_ADC_GAIN_DB -#define LINEIN_ADC_GAIN_DB 0 +#define LINEIN_ADC_GAIN_DB 0 #endif #ifndef CFG_HW_AUD_MICKEY_DEV -#define CFG_HW_AUD_MICKEY_DEV (AUD_VMIC_MAP_VMIC1) +#define CFG_HW_AUD_MICKEY_DEV (AUD_VMIC_MAP_VMIC1) #endif #ifndef ANC_VMIC_CFG -#define ANC_VMIC_CFG (AUD_VMIC_MAP_VMIC1) +#define ANC_VMIC_CFG (AUD_VMIC_MAP_VMIC1) #endif // 61 -#define REG_CODEC_EN_ADCA (1 << 0) -#define REG_CODEC_EN_ADCB (1 << 1) -#define REG_CODEC_EN_ADCC (1 << 2) -#define REG_CODEC_EN_ADCD (1 << 3) -#define REG_CODEC_ADCA_DITHER_EN (1 << 4) -#define REG_CODEC_ADCB_DITHER_EN (1 << 5) -#define REG_CODEC_ADCC_DITHER_EN (1 << 6) -#define REG_CODEC_ADCD_DITHER_EN (1 << 7) -#define REG_CODEC_ADCA_CH_SEL_SHIFT 8 -#define REG_CODEC_ADCA_CH_SEL_MASK (0x3 << REG_CODEC_ADCA_CH_SEL_SHIFT) -#define REG_CODEC_ADCA_CH_SEL(n) BITFIELD_VAL(REG_CODEC_ADCA_CH_SEL, n) -#define REG_CODEC_ADCB_CH_SEL_SHIFT 10 -#define REG_CODEC_ADCB_CH_SEL_MASK (0x3 << REG_CODEC_ADCB_CH_SEL_SHIFT) -#define REG_CODEC_ADCB_CH_SEL(n) BITFIELD_VAL(REG_CODEC_ADCB_CH_SEL, n) -#define REG_CODEC_ADCC_CH_SEL_SHIFT 12 -#define REG_CODEC_ADCC_CH_SEL_MASK (0x3 << REG_CODEC_ADCC_CH_SEL_SHIFT) -#define REG_CODEC_ADCC_CH_SEL(n) BITFIELD_VAL(REG_CODEC_ADCC_CH_SEL, n) -#define REG_CODEC_ADCD_CH_SEL_SHIFT 14 -#define REG_CODEC_ADCD_CH_SEL_MASK (0x3 << REG_CODEC_ADCD_CH_SEL_SHIFT) -#define REG_CODEC_ADCD_CH_SEL(n) BITFIELD_VAL(REG_CODEC_ADCD_CH_SEL, n) +#define REG_CODEC_EN_ADCA (1 << 0) +#define REG_CODEC_EN_ADCB (1 << 1) +#define REG_CODEC_EN_ADCC (1 << 2) +#define REG_CODEC_EN_ADCD (1 << 3) +#define REG_CODEC_ADCA_DITHER_EN (1 << 4) +#define REG_CODEC_ADCB_DITHER_EN (1 << 5) +#define REG_CODEC_ADCC_DITHER_EN (1 << 6) +#define REG_CODEC_ADCD_DITHER_EN (1 << 7) +#define REG_CODEC_ADCA_CH_SEL_SHIFT 8 +#define REG_CODEC_ADCA_CH_SEL_MASK (0x3 << REG_CODEC_ADCA_CH_SEL_SHIFT) +#define REG_CODEC_ADCA_CH_SEL(n) BITFIELD_VAL(REG_CODEC_ADCA_CH_SEL, n) +#define REG_CODEC_ADCB_CH_SEL_SHIFT 10 +#define REG_CODEC_ADCB_CH_SEL_MASK (0x3 << REG_CODEC_ADCB_CH_SEL_SHIFT) +#define REG_CODEC_ADCB_CH_SEL(n) BITFIELD_VAL(REG_CODEC_ADCB_CH_SEL, n) +#define REG_CODEC_ADCC_CH_SEL_SHIFT 12 +#define REG_CODEC_ADCC_CH_SEL_MASK (0x3 << REG_CODEC_ADCC_CH_SEL_SHIFT) +#define REG_CODEC_ADCC_CH_SEL(n) BITFIELD_VAL(REG_CODEC_ADCC_CH_SEL, n) +#define REG_CODEC_ADCD_CH_SEL_SHIFT 14 +#define REG_CODEC_ADCD_CH_SEL_MASK (0x3 << REG_CODEC_ADCD_CH_SEL_SHIFT) +#define REG_CODEC_ADCD_CH_SEL(n) BITFIELD_VAL(REG_CODEC_ADCD_CH_SEL, n) // 62 -#define REG_CODEC_RESET_ADCA (1 << 0) -#define REG_CODEC_RESET_ADCB (1 << 1) -#define REG_CODEC_RESET_ADCC (1 << 2) -#define REG_CODEC_RESET_ADCD (1 << 3) -#define CFG_RESET_ADCA_DR (1 << 4) -#define CFG_RESET_ADCB_DR (1 << 5) -#define CFG_RESET_ADCC_DR (1 << 6) -#define CFG_RESET_ADCD_DR (1 << 7) -#define REG_RX_PGAA_RESET (1 << 8) -#define REG_RX_PGAB_RESET (1 << 9) -#define REG_RX_PGAC_RESET (1 << 10) -#define REG_RX_PGAD_RESET (1 << 11) -#define CFG_RESET_PGAA_DR (1 << 12) -#define CFG_RESET_PGAB_DR (1 << 13) -#define CFG_RESET_PGAC_DR (1 << 14) -#define CFG_RESET_PGAD_DR (1 << 15) +#define REG_CODEC_RESET_ADCA (1 << 0) +#define REG_CODEC_RESET_ADCB (1 << 1) +#define REG_CODEC_RESET_ADCC (1 << 2) +#define REG_CODEC_RESET_ADCD (1 << 3) +#define CFG_RESET_ADCA_DR (1 << 4) +#define CFG_RESET_ADCB_DR (1 << 5) +#define CFG_RESET_ADCC_DR (1 << 6) +#define CFG_RESET_ADCD_DR (1 << 7) +#define REG_RX_PGAA_RESET (1 << 8) +#define REG_RX_PGAB_RESET (1 << 9) +#define REG_RX_PGAC_RESET (1 << 10) +#define REG_RX_PGAD_RESET (1 << 11) +#define CFG_RESET_PGAA_DR (1 << 12) +#define CFG_RESET_PGAB_DR (1 << 13) +#define CFG_RESET_PGAC_DR (1 << 14) +#define CFG_RESET_PGAD_DR (1 << 15) // 63 -#define REG_CODEC_ADCA_GAIN_BIT_SHIFT 0 -#define REG_CODEC_ADCA_GAIN_BIT_MASK (0x7 << REG_CODEC_ADCA_GAIN_BIT_SHIFT) -#define REG_CODEC_ADCA_GAIN_BIT(n) BITFIELD_VAL(REG_CODEC_ADCA_GAIN_BIT, n) -#define REG_CODEC_ADCB_GAIN_BIT_SHIFT 3 -#define REG_CODEC_ADCB_GAIN_BIT_MASK (0x7 << REG_CODEC_ADCB_GAIN_BIT_SHIFT) -#define REG_CODEC_ADCB_GAIN_BIT(n) BITFIELD_VAL(REG_CODEC_ADCB_GAIN_BIT, n) -#define REG_CODEC_ADCC_GAIN_BIT_SHIFT 6 -#define REG_CODEC_ADCC_GAIN_BIT_MASK (0x7 << REG_CODEC_ADCC_GAIN_BIT_SHIFT) -#define REG_CODEC_ADCC_GAIN_BIT(n) BITFIELD_VAL(REG_CODEC_ADCC_GAIN_BIT, n) -#define REG_CODEC_ADCD_GAIN_BIT_SHIFT 9 -#define REG_CODEC_ADCD_GAIN_BIT_MASK (0x7 << REG_CODEC_ADCD_GAIN_BIT_SHIFT) -#define REG_CODEC_ADCD_GAIN_BIT(n) BITFIELD_VAL(REG_CODEC_ADCD_GAIN_BIT, n) -#define REG_CODEC_ADCA_GAIN_UPDATE (1 << 12) -#define REG_CODEC_ADCB_GAIN_UPDATE (1 << 13) -#define REG_CODEC_ADCC_GAIN_UPDATE (1 << 14) -#define REG_CODEC_ADCD_GAIN_UPDATE (1 << 15) +#define REG_CODEC_ADCA_GAIN_BIT_SHIFT 0 +#define REG_CODEC_ADCA_GAIN_BIT_MASK (0x7 << REG_CODEC_ADCA_GAIN_BIT_SHIFT) +#define REG_CODEC_ADCA_GAIN_BIT(n) BITFIELD_VAL(REG_CODEC_ADCA_GAIN_BIT, n) +#define REG_CODEC_ADCB_GAIN_BIT_SHIFT 3 +#define REG_CODEC_ADCB_GAIN_BIT_MASK (0x7 << REG_CODEC_ADCB_GAIN_BIT_SHIFT) +#define REG_CODEC_ADCB_GAIN_BIT(n) BITFIELD_VAL(REG_CODEC_ADCB_GAIN_BIT, n) +#define REG_CODEC_ADCC_GAIN_BIT_SHIFT 6 +#define REG_CODEC_ADCC_GAIN_BIT_MASK (0x7 << REG_CODEC_ADCC_GAIN_BIT_SHIFT) +#define REG_CODEC_ADCC_GAIN_BIT(n) BITFIELD_VAL(REG_CODEC_ADCC_GAIN_BIT, n) +#define REG_CODEC_ADCD_GAIN_BIT_SHIFT 9 +#define REG_CODEC_ADCD_GAIN_BIT_MASK (0x7 << REG_CODEC_ADCD_GAIN_BIT_SHIFT) +#define REG_CODEC_ADCD_GAIN_BIT(n) BITFIELD_VAL(REG_CODEC_ADCD_GAIN_BIT, n) +#define REG_CODEC_ADCA_GAIN_UPDATE (1 << 12) +#define REG_CODEC_ADCB_GAIN_UPDATE (1 << 13) +#define REG_CODEC_ADCC_GAIN_UPDATE (1 << 14) +#define REG_CODEC_ADCD_GAIN_UPDATE (1 << 15) // 67 -#define REG_CODEC_ADC_IBSEL_REG_SHIFT 0 -#define REG_CODEC_ADC_IBSEL_REG_MASK (0xF << REG_CODEC_ADC_IBSEL_REG_SHIFT) -#define REG_CODEC_ADC_IBSEL_REG(n) BITFIELD_VAL(REG_CODEC_ADC_IBSEL_REG, n) -#define REG_CODEC_ADC_IBSEL_VCOMP_SHIFT 4 -#define REG_CODEC_ADC_IBSEL_VCOMP_MASK (0xF << REG_CODEC_ADC_IBSEL_VCOMP_SHIFT) -#define REG_CODEC_ADC_IBSEL_VCOMP(n) BITFIELD_VAL(REG_CODEC_ADC_IBSEL_VCOMP, n) -#define REG_CODEC_ADC_IBSEL_VREF_SHIFT 8 -#define REG_CODEC_ADC_IBSEL_VREF_MASK (0xF << REG_CODEC_ADC_IBSEL_VREF_SHIFT) -#define REG_CODEC_ADC_IBSEL_VREF(n) BITFIELD_VAL(REG_CODEC_ADC_IBSEL_VREF, n) -#define REG_CODEC_ADC_LPFVCM_SW_SHIFT 12 -#define REG_CODEC_ADC_LPFVCM_SW_MASK (0xF << REG_CODEC_ADC_LPFVCM_SW_SHIFT) -#define REG_CODEC_ADC_LPFVCM_SW(n) BITFIELD_VAL(REG_CODEC_ADC_LPFVCM_SW, n) +#define REG_CODEC_ADC_IBSEL_REG_SHIFT 0 +#define REG_CODEC_ADC_IBSEL_REG_MASK (0xF << REG_CODEC_ADC_IBSEL_REG_SHIFT) +#define REG_CODEC_ADC_IBSEL_REG(n) BITFIELD_VAL(REG_CODEC_ADC_IBSEL_REG, n) +#define REG_CODEC_ADC_IBSEL_VCOMP_SHIFT 4 +#define REG_CODEC_ADC_IBSEL_VCOMP_MASK (0xF << REG_CODEC_ADC_IBSEL_VCOMP_SHIFT) +#define REG_CODEC_ADC_IBSEL_VCOMP(n) BITFIELD_VAL(REG_CODEC_ADC_IBSEL_VCOMP, n) +#define REG_CODEC_ADC_IBSEL_VREF_SHIFT 8 +#define REG_CODEC_ADC_IBSEL_VREF_MASK (0xF << REG_CODEC_ADC_IBSEL_VREF_SHIFT) +#define REG_CODEC_ADC_IBSEL_VREF(n) BITFIELD_VAL(REG_CODEC_ADC_IBSEL_VREF, n) +#define REG_CODEC_ADC_LPFVCM_SW_SHIFT 12 +#define REG_CODEC_ADC_LPFVCM_SW_MASK (0xF << REG_CODEC_ADC_LPFVCM_SW_SHIFT) +#define REG_CODEC_ADC_LPFVCM_SW(n) BITFIELD_VAL(REG_CODEC_ADC_LPFVCM_SW, n) // 68 -#define REG_CODEC_ADC_OP1_IBIT_SHIFT 0 -#define REG_CODEC_ADC_OP1_IBIT_MASK (0x3 << REG_CODEC_ADC_OP1_IBIT_SHIFT) -#define REG_CODEC_ADC_OP1_IBIT(n) BITFIELD_VAL(REG_CODEC_ADC_OP1_IBIT, n) -#define REG_CODEC_ADC_OP1_R_SEL (1 << 2) -#define REG_CODEC_ADC_OP2_IBIT_SHIFT 3 -#define REG_CODEC_ADC_OP2_IBIT_MASK (0x3 << REG_CODEC_ADC_OP2_IBIT_SHIFT) -#define REG_CODEC_ADC_OP2_IBIT(n) BITFIELD_VAL(REG_CODEC_ADC_OP2_IBIT, n) -#define REG_CODEC_ADC_OP2_R_SEL (1 << 5) -#define REG_CODEC_ADC_OP3_IBIT_SHIFT 6 -#define REG_CODEC_ADC_OP3_IBIT_MASK (0x3 << REG_CODEC_ADC_OP3_IBIT_SHIFT) -#define REG_CODEC_ADC_OP3_IBIT(n) BITFIELD_VAL(REG_CODEC_ADC_OP3_IBIT, n) -#define REG_CODEC_ADC_OP3_R_SEL (1 << 8) -#define REG_CODEC_ADC_OP4_IBIT_SHIFT 9 -#define REG_CODEC_ADC_OP4_IBIT_MASK (0x3 << REG_CODEC_ADC_OP4_IBIT_SHIFT) -#define REG_CODEC_ADC_OP4_IBIT(n) BITFIELD_VAL(REG_CODEC_ADC_OP4_IBIT, n) -#define REG_CODEC_ADC_OP4_R_SEL (1 << 11) -#define REG_CODEC_ADC_VREF_SEL_SHIFT 12 -#define REG_CODEC_ADC_VREF_SEL_MASK (0xF << REG_CODEC_ADC_VREF_SEL_SHIFT) -#define REG_CODEC_ADC_VREF_SEL(n) BITFIELD_VAL(REG_CODEC_ADC_VREF_SEL, n) +#define REG_CODEC_ADC_OP1_IBIT_SHIFT 0 +#define REG_CODEC_ADC_OP1_IBIT_MASK (0x3 << REG_CODEC_ADC_OP1_IBIT_SHIFT) +#define REG_CODEC_ADC_OP1_IBIT(n) BITFIELD_VAL(REG_CODEC_ADC_OP1_IBIT, n) +#define REG_CODEC_ADC_OP1_R_SEL (1 << 2) +#define REG_CODEC_ADC_OP2_IBIT_SHIFT 3 +#define REG_CODEC_ADC_OP2_IBIT_MASK (0x3 << REG_CODEC_ADC_OP2_IBIT_SHIFT) +#define REG_CODEC_ADC_OP2_IBIT(n) BITFIELD_VAL(REG_CODEC_ADC_OP2_IBIT, n) +#define REG_CODEC_ADC_OP2_R_SEL (1 << 5) +#define REG_CODEC_ADC_OP3_IBIT_SHIFT 6 +#define REG_CODEC_ADC_OP3_IBIT_MASK (0x3 << REG_CODEC_ADC_OP3_IBIT_SHIFT) +#define REG_CODEC_ADC_OP3_IBIT(n) BITFIELD_VAL(REG_CODEC_ADC_OP3_IBIT, n) +#define REG_CODEC_ADC_OP3_R_SEL (1 << 8) +#define REG_CODEC_ADC_OP4_IBIT_SHIFT 9 +#define REG_CODEC_ADC_OP4_IBIT_MASK (0x3 << REG_CODEC_ADC_OP4_IBIT_SHIFT) +#define REG_CODEC_ADC_OP4_IBIT(n) BITFIELD_VAL(REG_CODEC_ADC_OP4_IBIT, n) +#define REG_CODEC_ADC_OP4_R_SEL (1 << 11) +#define REG_CODEC_ADC_VREF_SEL_SHIFT 12 +#define REG_CODEC_ADC_VREF_SEL_MASK (0xF << REG_CODEC_ADC_VREF_SEL_SHIFT) +#define REG_CODEC_ADC_VREF_SEL(n) BITFIELD_VAL(REG_CODEC_ADC_VREF_SEL, n) // 69 -#define REG_CODEC_BIAS_IBSEL_SHIFT 0 -#define REG_CODEC_BIAS_IBSEL_MASK (0xF << REG_CODEC_BIAS_IBSEL_SHIFT) -#define REG_CODEC_BIAS_IBSEL(n) BITFIELD_VAL(REG_CODEC_BIAS_IBSEL, n) -#define REG_CODEC_BIAS_IBSEL_TX_SHIFT 4 -#define REG_CODEC_BIAS_IBSEL_TX_MASK (0xF << REG_CODEC_BIAS_IBSEL_TX_SHIFT) -#define REG_CODEC_BIAS_IBSEL_TX(n) BITFIELD_VAL(REG_CODEC_BIAS_IBSEL_TX, n) -#define REG_CODEC_BIAS_IBSEL_VOICE_SHIFT 8 -#define REG_CODEC_BIAS_IBSEL_VOICE_MASK (0xF << REG_CODEC_BIAS_IBSEL_VOICE_SHIFT) -#define REG_CODEC_BIAS_IBSEL_VOICE(n) BITFIELD_VAL(REG_CODEC_BIAS_IBSEL_VOICE, n) -#define REG_CODEC_BIAS_LOWV (1 << 12) -#define REG_CODEC_BIAS_LOWV_LP (1 << 13) -#define REG_CODEC_BUF_LOWPOWER (1 << 14) -#define REG_CODEC_BUF_LOWPOWER2 (1 << 15) +#define REG_CODEC_BIAS_IBSEL_SHIFT 0 +#define REG_CODEC_BIAS_IBSEL_MASK (0xF << REG_CODEC_BIAS_IBSEL_SHIFT) +#define REG_CODEC_BIAS_IBSEL(n) BITFIELD_VAL(REG_CODEC_BIAS_IBSEL, n) +#define REG_CODEC_BIAS_IBSEL_TX_SHIFT 4 +#define REG_CODEC_BIAS_IBSEL_TX_MASK (0xF << REG_CODEC_BIAS_IBSEL_TX_SHIFT) +#define REG_CODEC_BIAS_IBSEL_TX(n) BITFIELD_VAL(REG_CODEC_BIAS_IBSEL_TX, n) +#define REG_CODEC_BIAS_IBSEL_VOICE_SHIFT 8 +#define REG_CODEC_BIAS_IBSEL_VOICE_MASK \ + (0xF << REG_CODEC_BIAS_IBSEL_VOICE_SHIFT) +#define REG_CODEC_BIAS_IBSEL_VOICE(n) \ + BITFIELD_VAL(REG_CODEC_BIAS_IBSEL_VOICE, n) +#define REG_CODEC_BIAS_LOWV (1 << 12) +#define REG_CODEC_BIAS_LOWV_LP (1 << 13) +#define REG_CODEC_BUF_LOWPOWER (1 << 14) +#define REG_CODEC_BUF_LOWPOWER2 (1 << 15) // 6A -#define REG_CODEC_ADC_REG_VSEL_SHIFT 0 -#define REG_CODEC_ADC_REG_VSEL_MASK (0x7 << REG_CODEC_ADC_REG_VSEL_SHIFT) -#define REG_CODEC_ADC_REG_VSEL(n) BITFIELD_VAL(REG_CODEC_ADC_REG_VSEL, n) -#define REG_CODEC_ADC_RES_SEL_SHIFT 3 -#define REG_CODEC_ADC_RES_SEL_MASK (0x7 << REG_CODEC_ADC_RES_SEL_SHIFT) -#define REG_CODEC_ADC_RES_SEL(n) BITFIELD_VAL(REG_CODEC_ADC_RES_SEL, n) -#define REG_CODEC_BUF_LOWVCM_SHIFT 6 -#define REG_CODEC_BUF_LOWVCM_MASK (0x7 << REG_CODEC_BUF_LOWVCM_SHIFT) -#define REG_CODEC_BUF_LOWVCM(n) BITFIELD_VAL(REG_CODEC_BUF_LOWVCM, n) -#define REG_CODEC_EN_BIAS (1 << 9) -#define REG_CODEC_EN_BIAS_LP (1 << 10) -#define REG_CODEC_EN_RX_EXT (1 << 11) -#define REG_CODEC_EN_TX_EXT (1 << 12) -#define REG_CODEC_DAC_CLK_EDGE_SEL (1 << 13) -#define CFG_TX_CH0_MUTE (1 << 14) -#define CFG_TX_CH1_MUTE (1 << 15) +#define REG_CODEC_ADC_REG_VSEL_SHIFT 0 +#define REG_CODEC_ADC_REG_VSEL_MASK (0x7 << REG_CODEC_ADC_REG_VSEL_SHIFT) +#define REG_CODEC_ADC_REG_VSEL(n) BITFIELD_VAL(REG_CODEC_ADC_REG_VSEL, n) +#define REG_CODEC_ADC_RES_SEL_SHIFT 3 +#define REG_CODEC_ADC_RES_SEL_MASK (0x7 << REG_CODEC_ADC_RES_SEL_SHIFT) +#define REG_CODEC_ADC_RES_SEL(n) BITFIELD_VAL(REG_CODEC_ADC_RES_SEL, n) +#define REG_CODEC_BUF_LOWVCM_SHIFT 6 +#define REG_CODEC_BUF_LOWVCM_MASK (0x7 << REG_CODEC_BUF_LOWVCM_SHIFT) +#define REG_CODEC_BUF_LOWVCM(n) BITFIELD_VAL(REG_CODEC_BUF_LOWVCM, n) +#define REG_CODEC_EN_BIAS (1 << 9) +#define REG_CODEC_EN_BIAS_LP (1 << 10) +#define REG_CODEC_EN_RX_EXT (1 << 11) +#define REG_CODEC_EN_TX_EXT (1 << 12) +#define REG_CODEC_DAC_CLK_EDGE_SEL (1 << 13) +#define CFG_TX_CH0_MUTE (1 << 14) +#define CFG_TX_CH1_MUTE (1 << 15) // 6B -#define REG_CODEC_EN_VCM (1 << 0) -#define REG_CODEC_VCM_EN_LPF (1 << 1) -#define REG_CODEC_LP_VCM (1 << 2) -#define REG_CODEC_VCM_LOW_VCM_SHIFT 3 -#define REG_CODEC_VCM_LOW_VCM_MASK (0xF << REG_CODEC_VCM_LOW_VCM_SHIFT) -#define REG_CODEC_VCM_LOW_VCM(n) BITFIELD_VAL(REG_CODEC_VCM_LOW_VCM, n) -#define REG_CODEC_VCM_LOW_VCM_LP_SHIFT 7 -#define REG_CODEC_VCM_LOW_VCM_LP_MASK (0xF << REG_CODEC_VCM_LOW_VCM_LP_SHIFT) -#define REG_CODEC_VCM_LOW_VCM_LP(n) BITFIELD_VAL(REG_CODEC_VCM_LOW_VCM_LP, n) -#define REG_CODEC_VCM_LOW_VCM_LPF_SHIFT 11 -#define REG_CODEC_VCM_LOW_VCM_LPF_MASK (0xF << REG_CODEC_VCM_LOW_VCM_LPF_SHIFT) -#define REG_CODEC_VCM_LOW_VCM_LPF(n) BITFIELD_VAL(REG_CODEC_VCM_LOW_VCM_LPF, n) -#define REG_CODEC_EN_VCM_BUFFER (1 << 15) +#define REG_CODEC_EN_VCM (1 << 0) +#define REG_CODEC_VCM_EN_LPF (1 << 1) +#define REG_CODEC_LP_VCM (1 << 2) +#define REG_CODEC_VCM_LOW_VCM_SHIFT 3 +#define REG_CODEC_VCM_LOW_VCM_MASK (0xF << REG_CODEC_VCM_LOW_VCM_SHIFT) +#define REG_CODEC_VCM_LOW_VCM(n) BITFIELD_VAL(REG_CODEC_VCM_LOW_VCM, n) +#define REG_CODEC_VCM_LOW_VCM_LP_SHIFT 7 +#define REG_CODEC_VCM_LOW_VCM_LP_MASK (0xF << REG_CODEC_VCM_LOW_VCM_LP_SHIFT) +#define REG_CODEC_VCM_LOW_VCM_LP(n) BITFIELD_VAL(REG_CODEC_VCM_LOW_VCM_LP, n) +#define REG_CODEC_VCM_LOW_VCM_LPF_SHIFT 11 +#define REG_CODEC_VCM_LOW_VCM_LPF_MASK (0xF << REG_CODEC_VCM_LOW_VCM_LPF_SHIFT) +#define REG_CODEC_VCM_LOW_VCM_LPF(n) BITFIELD_VAL(REG_CODEC_VCM_LOW_VCM_LPF, n) +#define REG_CODEC_EN_VCM_BUFFER (1 << 15) // 6C -#define REG_CODEC_RX_EN_VTOI (1 << 0) -#define REG_CODEC_RX_VTOI_I_DAC2_SHIFT 1 -#define REG_CODEC_RX_VTOI_I_DAC2_MASK (0x7 << REG_CODEC_RX_VTOI_I_DAC2_SHIFT) -#define REG_CODEC_RX_VTOI_I_DAC2(n) BITFIELD_VAL(REG_CODEC_RX_VTOI_I_DAC2, n) -#define REG_CODEC_RX_VTOI_IDAC_SEL_SHIFT 4 -#define REG_CODEC_RX_VTOI_IDAC_SEL_MASK (0xF << REG_CODEC_RX_VTOI_IDAC_SEL_SHIFT) -#define REG_CODEC_RX_VTOI_IDAC_SEL(n) BITFIELD_VAL(REG_CODEC_RX_VTOI_IDAC_SEL, n) -#define REG_CODEC_RX_VTOI_VCS_SEL_SHIFT 8 -#define REG_CODEC_RX_VTOI_VCS_SEL_MASK (0x1F << REG_CODEC_RX_VTOI_VCS_SEL_SHIFT) -#define REG_CODEC_RX_VTOI_VCS_SEL(n) BITFIELD_VAL(REG_CODEC_RX_VTOI_VCS_SEL, n) -#define REG_CODEC_ADCA_RES_2P5K_DR (1 << 13) -#define REG_CODEC_ADCB_RES_2P5K_DR (1 << 14) -#define REG_CODEC_ADCC_RES_2P5K_DR (1 << 15) +#define REG_CODEC_RX_EN_VTOI (1 << 0) +#define REG_CODEC_RX_VTOI_I_DAC2_SHIFT 1 +#define REG_CODEC_RX_VTOI_I_DAC2_MASK (0x7 << REG_CODEC_RX_VTOI_I_DAC2_SHIFT) +#define REG_CODEC_RX_VTOI_I_DAC2(n) BITFIELD_VAL(REG_CODEC_RX_VTOI_I_DAC2, n) +#define REG_CODEC_RX_VTOI_IDAC_SEL_SHIFT 4 +#define REG_CODEC_RX_VTOI_IDAC_SEL_MASK \ + (0xF << REG_CODEC_RX_VTOI_IDAC_SEL_SHIFT) +#define REG_CODEC_RX_VTOI_IDAC_SEL(n) \ + BITFIELD_VAL(REG_CODEC_RX_VTOI_IDAC_SEL, n) +#define REG_CODEC_RX_VTOI_VCS_SEL_SHIFT 8 +#define REG_CODEC_RX_VTOI_VCS_SEL_MASK (0x1F << REG_CODEC_RX_VTOI_VCS_SEL_SHIFT) +#define REG_CODEC_RX_VTOI_VCS_SEL(n) BITFIELD_VAL(REG_CODEC_RX_VTOI_VCS_SEL, n) +#define REG_CODEC_ADCA_RES_2P5K_DR (1 << 13) +#define REG_CODEC_ADCB_RES_2P5K_DR (1 << 14) +#define REG_CODEC_ADCC_RES_2P5K_DR (1 << 15) // 6D -#define REG_CODEC_TX_DAC_MUTEL (1 << 0) -#define REG_CODEC_TX_DAC_MUTER (1 << 1) -#define REG_CODEC_TX_DAC_SWR_SHIFT 2 -#define REG_CODEC_TX_DAC_SWR_MASK (0x3 << REG_CODEC_TX_DAC_SWR_SHIFT) -#define REG_CODEC_TX_DAC_SWR(n) BITFIELD_VAL(REG_CODEC_TX_DAC_SWR, n) -#define REG_CODEC_TX_DAC_VREF_L_SHIFT 4 -#define REG_CODEC_TX_DAC_VREF_L_MASK (0xF << REG_CODEC_TX_DAC_VREF_L_SHIFT) -#define REG_CODEC_TX_DAC_VREF_L(n) BITFIELD_VAL(REG_CODEC_TX_DAC_VREF_L, n) -#define REG_CODEC_TX_DAC_VREF_R_SHIFT 8 -#define REG_CODEC_TX_DAC_VREF_R_MASK (0xF << REG_CODEC_TX_DAC_VREF_R_SHIFT) -#define REG_CODEC_TX_DAC_VREF_R(n) BITFIELD_VAL(REG_CODEC_TX_DAC_VREF_R, n) -#define REG_CODEC_TX_EAR_CAS_BIT_SHIFT 12 -#define REG_CODEC_TX_EAR_CAS_BIT_MASK (0x3 << REG_CODEC_TX_EAR_CAS_BIT_SHIFT) -#define REG_CODEC_TX_EAR_CAS_BIT(n) BITFIELD_VAL(REG_CODEC_TX_EAR_CAS_BIT, n) -#define REG_CODEC_TX_EAR_DIS_SHIFT 14 -#define REG_CODEC_TX_EAR_DIS_MASK (0x3 << REG_CODEC_TX_EAR_DIS_SHIFT) -#define REG_CODEC_TX_EAR_DIS(n) BITFIELD_VAL(REG_CODEC_TX_EAR_DIS, n) +#define REG_CODEC_TX_DAC_MUTEL (1 << 0) +#define REG_CODEC_TX_DAC_MUTER (1 << 1) +#define REG_CODEC_TX_DAC_SWR_SHIFT 2 +#define REG_CODEC_TX_DAC_SWR_MASK (0x3 << REG_CODEC_TX_DAC_SWR_SHIFT) +#define REG_CODEC_TX_DAC_SWR(n) BITFIELD_VAL(REG_CODEC_TX_DAC_SWR, n) +#define REG_CODEC_TX_DAC_VREF_L_SHIFT 4 +#define REG_CODEC_TX_DAC_VREF_L_MASK (0xF << REG_CODEC_TX_DAC_VREF_L_SHIFT) +#define REG_CODEC_TX_DAC_VREF_L(n) BITFIELD_VAL(REG_CODEC_TX_DAC_VREF_L, n) +#define REG_CODEC_TX_DAC_VREF_R_SHIFT 8 +#define REG_CODEC_TX_DAC_VREF_R_MASK (0xF << REG_CODEC_TX_DAC_VREF_R_SHIFT) +#define REG_CODEC_TX_DAC_VREF_R(n) BITFIELD_VAL(REG_CODEC_TX_DAC_VREF_R, n) +#define REG_CODEC_TX_EAR_CAS_BIT_SHIFT 12 +#define REG_CODEC_TX_EAR_CAS_BIT_MASK (0x3 << REG_CODEC_TX_EAR_CAS_BIT_SHIFT) +#define REG_CODEC_TX_EAR_CAS_BIT(n) BITFIELD_VAL(REG_CODEC_TX_EAR_CAS_BIT, n) +#define REG_CODEC_TX_EAR_DIS_SHIFT 14 +#define REG_CODEC_TX_EAR_DIS_MASK (0x3 << REG_CODEC_TX_EAR_DIS_SHIFT) +#define REG_CODEC_TX_EAR_DIS(n) BITFIELD_VAL(REG_CODEC_TX_EAR_DIS, n) // 6E -#define REG_CODEC_TX_EAR_COMP_L_SHIFT 0 -#define REG_CODEC_TX_EAR_COMP_L_MASK (0x7 << REG_CODEC_TX_EAR_COMP_L_SHIFT) -#define REG_CODEC_TX_EAR_COMP_L(n) BITFIELD_VAL(REG_CODEC_TX_EAR_COMP_L, n) -#define REG_CODEC_TX_EAR_COMP_R_SHIFT 3 -#define REG_CODEC_TX_EAR_COMP_R_MASK (0x7 << REG_CODEC_TX_EAR_COMP_R_SHIFT) -#define REG_CODEC_TX_EAR_COMP_R(n) BITFIELD_VAL(REG_CODEC_TX_EAR_COMP_R, n) -#define REG_CODEC_TX_EAR_DOUBLEBIAS (1 << 6) -#define REG_CODEC_TX_EAR_DR_EN (1 << 7) -#define REG_CODEC_TX_EAR_DR_ST_SHIFT 8 -#define REG_CODEC_TX_EAR_DR_ST_MASK (0x7 << REG_CODEC_TX_EAR_DR_ST_SHIFT) -#define REG_CODEC_TX_EAR_DR_ST(n) BITFIELD_VAL(REG_CODEC_TX_EAR_DR_ST, n) -#define REG_CODEC_TX_EAR_ENBIAS (1 << 11) -#define REG_CODEC_TX_EAR_FBCAP_SHIFT 12 -#define REG_CODEC_TX_EAR_FBCAP_MASK (0x3 << REG_CODEC_TX_EAR_FBCAP_SHIFT) -#define REG_CODEC_TX_EAR_FBCAP(n) BITFIELD_VAL(REG_CODEC_TX_EAR_FBCAP, n) -#define REG_CODEC_TX_EAR_IBSEL_SHIFT 14 -#define REG_CODEC_TX_EAR_IBSEL_MASK (0x3 << REG_CODEC_TX_EAR_IBSEL_SHIFT) -#define REG_CODEC_TX_EAR_IBSEL(n) BITFIELD_VAL(REG_CODEC_TX_EAR_IBSEL, n) +#define REG_CODEC_TX_EAR_COMP_L_SHIFT 0 +#define REG_CODEC_TX_EAR_COMP_L_MASK (0x7 << REG_CODEC_TX_EAR_COMP_L_SHIFT) +#define REG_CODEC_TX_EAR_COMP_L(n) BITFIELD_VAL(REG_CODEC_TX_EAR_COMP_L, n) +#define REG_CODEC_TX_EAR_COMP_R_SHIFT 3 +#define REG_CODEC_TX_EAR_COMP_R_MASK (0x7 << REG_CODEC_TX_EAR_COMP_R_SHIFT) +#define REG_CODEC_TX_EAR_COMP_R(n) BITFIELD_VAL(REG_CODEC_TX_EAR_COMP_R, n) +#define REG_CODEC_TX_EAR_DOUBLEBIAS (1 << 6) +#define REG_CODEC_TX_EAR_DR_EN (1 << 7) +#define REG_CODEC_TX_EAR_DR_ST_SHIFT 8 +#define REG_CODEC_TX_EAR_DR_ST_MASK (0x7 << REG_CODEC_TX_EAR_DR_ST_SHIFT) +#define REG_CODEC_TX_EAR_DR_ST(n) BITFIELD_VAL(REG_CODEC_TX_EAR_DR_ST, n) +#define REG_CODEC_TX_EAR_ENBIAS (1 << 11) +#define REG_CODEC_TX_EAR_FBCAP_SHIFT 12 +#define REG_CODEC_TX_EAR_FBCAP_MASK (0x3 << REG_CODEC_TX_EAR_FBCAP_SHIFT) +#define REG_CODEC_TX_EAR_FBCAP(n) BITFIELD_VAL(REG_CODEC_TX_EAR_FBCAP, n) +#define REG_CODEC_TX_EAR_IBSEL_SHIFT 14 +#define REG_CODEC_TX_EAR_IBSEL_MASK (0x3 << REG_CODEC_TX_EAR_IBSEL_SHIFT) +#define REG_CODEC_TX_EAR_IBSEL(n) BITFIELD_VAL(REG_CODEC_TX_EAR_IBSEL, n) // 6F -#define REG_CODEC_TX_EAR_DRE_GAIN_L_SHIFT 0 -#define REG_CODEC_TX_EAR_DRE_GAIN_L_MASK (0x1F << REG_CODEC_TX_EAR_DRE_GAIN_L_SHIFT) -#define REG_CODEC_TX_EAR_DRE_GAIN_L(n) BITFIELD_VAL(REG_CODEC_TX_EAR_DRE_GAIN_L, n) -#define REG_CODEC_TX_EAR_DRE_GAIN_R_SHIFT 5 -#define REG_CODEC_TX_EAR_DRE_GAIN_R_MASK (0x1F << REG_CODEC_TX_EAR_DRE_GAIN_R_SHIFT) -#define REG_CODEC_TX_EAR_DRE_GAIN_R(n) BITFIELD_VAL(REG_CODEC_TX_EAR_DRE_GAIN_R, n) -#define DRE_GAIN_SEL_L (1 << 10) -#define DRE_GAIN_SEL_R (1 << 11) -#define REG_CODEC_TX_EAR_DRE_GAIN_L_UPDATE (1 << 12) -#define REG_CODEC_TX_EAR_DRE_GAIN_R_UPDATE (1 << 13) -#define REG_CODEC_TX_EAR_GAIN_SHIFT 14 -#define REG_CODEC_TX_EAR_GAIN_MASK (0x3 << REG_CODEC_TX_EAR_GAIN_SHIFT) -#define REG_CODEC_TX_EAR_GAIN(n) BITFIELD_VAL(REG_CODEC_TX_EAR_GAIN, n) +#define REG_CODEC_TX_EAR_DRE_GAIN_L_SHIFT 0 +#define REG_CODEC_TX_EAR_DRE_GAIN_L_MASK \ + (0x1F << REG_CODEC_TX_EAR_DRE_GAIN_L_SHIFT) +#define REG_CODEC_TX_EAR_DRE_GAIN_L(n) \ + BITFIELD_VAL(REG_CODEC_TX_EAR_DRE_GAIN_L, n) +#define REG_CODEC_TX_EAR_DRE_GAIN_R_SHIFT 5 +#define REG_CODEC_TX_EAR_DRE_GAIN_R_MASK \ + (0x1F << REG_CODEC_TX_EAR_DRE_GAIN_R_SHIFT) +#define REG_CODEC_TX_EAR_DRE_GAIN_R(n) \ + BITFIELD_VAL(REG_CODEC_TX_EAR_DRE_GAIN_R, n) +#define DRE_GAIN_SEL_L (1 << 10) +#define DRE_GAIN_SEL_R (1 << 11) +#define REG_CODEC_TX_EAR_DRE_GAIN_L_UPDATE (1 << 12) +#define REG_CODEC_TX_EAR_DRE_GAIN_R_UPDATE (1 << 13) +#define REG_CODEC_TX_EAR_GAIN_SHIFT 14 +#define REG_CODEC_TX_EAR_GAIN_MASK (0x3 << REG_CODEC_TX_EAR_GAIN_SHIFT) +#define REG_CODEC_TX_EAR_GAIN(n) BITFIELD_VAL(REG_CODEC_TX_EAR_GAIN, n) // 70 -#define REG_CODEC_TX_EAR_LCAL (1 << 0) -#define REG_CODEC_TX_EAR_RCAL (1 << 1) -#define REG_CODEC_TX_EAR_LPBIAS (1 << 2) -#define REG_CODEC_TX_EAR_OCEN (1 << 3) -#define REG_CODEC_TX_EAR_OFFEN (1 << 4) -#define REG_CODEC_TX_EAR_OUTPUTSEL_SHIFT 5 -#define REG_CODEC_TX_EAR_OUTPUTSEL_MASK (0xF << REG_CODEC_TX_EAR_OUTPUTSEL_SHIFT) -#define REG_CODEC_TX_EAR_OUTPUTSEL(n) BITFIELD_VAL(REG_CODEC_TX_EAR_OUTPUTSEL, n) -#define REG_CODEC_TX_EAR_SOFTSTART_SHIFT 9 -#define REG_CODEC_TX_EAR_SOFTSTART_MASK (0x3F << REG_CODEC_TX_EAR_SOFTSTART_SHIFT) -#define REG_CODEC_TX_EAR_SOFTSTART(n) BITFIELD_VAL(REG_CODEC_TX_EAR_SOFTSTART, n) -#define CFG_TX_TREE_EN (1 << 15) +#define REG_CODEC_TX_EAR_LCAL (1 << 0) +#define REG_CODEC_TX_EAR_RCAL (1 << 1) +#define REG_CODEC_TX_EAR_LPBIAS (1 << 2) +#define REG_CODEC_TX_EAR_OCEN (1 << 3) +#define REG_CODEC_TX_EAR_OFFEN (1 << 4) +#define REG_CODEC_TX_EAR_OUTPUTSEL_SHIFT 5 +#define REG_CODEC_TX_EAR_OUTPUTSEL_MASK \ + (0xF << REG_CODEC_TX_EAR_OUTPUTSEL_SHIFT) +#define REG_CODEC_TX_EAR_OUTPUTSEL(n) \ + BITFIELD_VAL(REG_CODEC_TX_EAR_OUTPUTSEL, n) +#define REG_CODEC_TX_EAR_SOFTSTART_SHIFT 9 +#define REG_CODEC_TX_EAR_SOFTSTART_MASK \ + (0x3F << REG_CODEC_TX_EAR_SOFTSTART_SHIFT) +#define REG_CODEC_TX_EAR_SOFTSTART(n) \ + BITFIELD_VAL(REG_CODEC_TX_EAR_SOFTSTART, n) +#define CFG_TX_TREE_EN (1 << 15) // 71 -#define REG_CODEC_TX_EAR_LOWGAINL_SHIFT 0 -#define REG_CODEC_TX_EAR_LOWGAINL_MASK (0x3 << REG_CODEC_TX_EAR_LOWGAINL_SHIFT) -#define REG_CODEC_TX_EAR_LOWGAINL(n) BITFIELD_VAL(REG_CODEC_TX_EAR_LOWGAINL, n) -#define REG_CODEC_TX_EAR_OFF_BITL_SHIFT 2 -#define REG_CODEC_TX_EAR_OFF_BITL_MASK (0x3FFF << REG_CODEC_TX_EAR_OFF_BITL_SHIFT) -#define REG_CODEC_TX_EAR_OFF_BITL(n) BITFIELD_VAL(REG_CODEC_TX_EAR_OFF_BITL, n) +#define REG_CODEC_TX_EAR_LOWGAINL_SHIFT 0 +#define REG_CODEC_TX_EAR_LOWGAINL_MASK (0x3 << REG_CODEC_TX_EAR_LOWGAINL_SHIFT) +#define REG_CODEC_TX_EAR_LOWGAINL(n) BITFIELD_VAL(REG_CODEC_TX_EAR_LOWGAINL, n) +#define REG_CODEC_TX_EAR_OFF_BITL_SHIFT 2 +#define REG_CODEC_TX_EAR_OFF_BITL_MASK \ + (0x3FFF << REG_CODEC_TX_EAR_OFF_BITL_SHIFT) +#define REG_CODEC_TX_EAR_OFF_BITL(n) BITFIELD_VAL(REG_CODEC_TX_EAR_OFF_BITL, n) // 72 -#define REG_CODEC_TX_EAR_LOWGAINR_SHIFT 0 -#define REG_CODEC_TX_EAR_LOWGAINR_MASK (0x3 << REG_CODEC_TX_EAR_LOWGAINR_SHIFT) -#define REG_CODEC_TX_EAR_LOWGAINR(n) BITFIELD_VAL(REG_CODEC_TX_EAR_LOWGAINR, n) -#define REG_CODEC_TX_EAR_OFF_BITR_SHIFT 2 -#define REG_CODEC_TX_EAR_OFF_BITR_MASK (0x3FFF << REG_CODEC_TX_EAR_OFF_BITR_SHIFT) -#define REG_CODEC_TX_EAR_OFF_BITR(n) BITFIELD_VAL(REG_CODEC_TX_EAR_OFF_BITR, n) +#define REG_CODEC_TX_EAR_LOWGAINR_SHIFT 0 +#define REG_CODEC_TX_EAR_LOWGAINR_MASK (0x3 << REG_CODEC_TX_EAR_LOWGAINR_SHIFT) +#define REG_CODEC_TX_EAR_LOWGAINR(n) BITFIELD_VAL(REG_CODEC_TX_EAR_LOWGAINR, n) +#define REG_CODEC_TX_EAR_OFF_BITR_SHIFT 2 +#define REG_CODEC_TX_EAR_OFF_BITR_MASK \ + (0x3FFF << REG_CODEC_TX_EAR_OFF_BITR_SHIFT) +#define REG_CODEC_TX_EAR_OFF_BITR(n) BITFIELD_VAL(REG_CODEC_TX_EAR_OFF_BITR, n) // 73 -#define REG_CODEC_TX_EN_DACLDO (1 << 0) -#define REG_CODEC_TX_EN_EARPA_L (1 << 1) -#define REG_CODEC_TX_EN_EARPA_R (1 << 2) -#define REG_CODEC_TX_EN_LCLK (1 << 3) -#define REG_CODEC_TX_EN_RCLK (1 << 4) -#define REG_CODEC_TX_EN_LDAC (1 << 5) -#define REG_CODEC_TX_EN_RDAC (1 << 6) -#define REG_CODEC_TX_EN_LPPA (1 << 7) -#define REG_CODEC_TX_EN_S1PA (1 << 8) -#define REG_CODEC_TX_EN_S2PA (1 << 9) -#define REG_CODEC_TX_EN_S3PA (1 << 10) -#define REG_CODEC_TX_EN_S4PA (1 << 11) -#define REG_CODEC_TX_EN_S5PA (1 << 12) -#define REG_IDETLEAR_EN (1 << 13) -#define REG_IDETREAR_EN (1 << 14) -#define REG_CODEC_TX_SW_MODE (1 << 15) +#define REG_CODEC_TX_EN_DACLDO (1 << 0) +#define REG_CODEC_TX_EN_EARPA_L (1 << 1) +#define REG_CODEC_TX_EN_EARPA_R (1 << 2) +#define REG_CODEC_TX_EN_LCLK (1 << 3) +#define REG_CODEC_TX_EN_RCLK (1 << 4) +#define REG_CODEC_TX_EN_LDAC (1 << 5) +#define REG_CODEC_TX_EN_RDAC (1 << 6) +#define REG_CODEC_TX_EN_LPPA (1 << 7) +#define REG_CODEC_TX_EN_S1PA (1 << 8) +#define REG_CODEC_TX_EN_S2PA (1 << 9) +#define REG_CODEC_TX_EN_S3PA (1 << 10) +#define REG_CODEC_TX_EN_S4PA (1 << 11) +#define REG_CODEC_TX_EN_S5PA (1 << 12) +#define REG_IDETLEAR_EN (1 << 13) +#define REG_IDETREAR_EN (1 << 14) +#define REG_CODEC_TX_SW_MODE (1 << 15) // 74 -#define REG_CODEC_TX_RVREF_CAP_BIT (1 << 0) -#define REG_DAC_LDO0P9_VSEL_SHIFT 1 -#define REG_DAC_LDO0P9_VSEL_MASK (0x1F << REG_DAC_LDO0P9_VSEL_SHIFT) -#define REG_DAC_LDO0P9_VSEL(n) BITFIELD_VAL(REG_DAC_LDO0P9_VSEL, n) -#define REG_BYPASS_TX_REGULATOR (1 << 6) -#define REG_PU_TX_REGULATOR (1 << 7) -#define REG_TX_REGULATOR_BIT_SHIFT 8 -#define REG_TX_REGULATOR_BIT_MASK (0xF << REG_TX_REGULATOR_BIT_SHIFT) -#define REG_TX_REGULATOR_BIT(n) BITFIELD_VAL(REG_TX_REGULATOR_BIT, n) -#define REG_TX_REG_CAP_BIT (1 << 12) -#define REG_CODEC_TX_EAR_VCM_BIT_SHIFT 13 -#define REG_CODEC_TX_EAR_VCM_BIT_MASK (0x3 << REG_CODEC_TX_EAR_VCM_BIT_SHIFT) -#define REG_CODEC_TX_EAR_VCM_BIT(n) BITFIELD_VAL(REG_CODEC_TX_EAR_VCM_BIT, n) -#define REG_CODEC_TX_EAR_VCM_SEL (1 << 15) +#define REG_CODEC_TX_RVREF_CAP_BIT (1 << 0) +#define REG_DAC_LDO0P9_VSEL_SHIFT 1 +#define REG_DAC_LDO0P9_VSEL_MASK (0x1F << REG_DAC_LDO0P9_VSEL_SHIFT) +#define REG_DAC_LDO0P9_VSEL(n) BITFIELD_VAL(REG_DAC_LDO0P9_VSEL, n) +#define REG_BYPASS_TX_REGULATOR (1 << 6) +#define REG_PU_TX_REGULATOR (1 << 7) +#define REG_TX_REGULATOR_BIT_SHIFT 8 +#define REG_TX_REGULATOR_BIT_MASK (0xF << REG_TX_REGULATOR_BIT_SHIFT) +#define REG_TX_REGULATOR_BIT(n) BITFIELD_VAL(REG_TX_REGULATOR_BIT, n) +#define REG_TX_REG_CAP_BIT (1 << 12) +#define REG_CODEC_TX_EAR_VCM_BIT_SHIFT 13 +#define REG_CODEC_TX_EAR_VCM_BIT_MASK (0x3 << REG_CODEC_TX_EAR_VCM_BIT_SHIFT) +#define REG_CODEC_TX_EAR_VCM_BIT(n) BITFIELD_VAL(REG_CODEC_TX_EAR_VCM_BIT, n) +#define REG_CODEC_TX_EAR_VCM_SEL (1 << 15) // 75 -#define REG_CRYSTAL_SEL_LV (1 << 0) -#define REG_EXTPLL_SEL (1 << 1) -#define REG_AUDPLL_CAL_EN (1 << 2) -#define REG_AUDPLL_CP_IEN_SHIFT 3 -#define REG_AUDPLL_CP_IEN_MASK (0xF << REG_AUDPLL_CP_IEN_SHIFT) -#define REG_AUDPLL_CP_IEN(n) BITFIELD_VAL(REG_AUDPLL_CP_IEN, n) -#define REG_AUDPLL_CP_SWRC_SHIFT 7 -#define REG_AUDPLL_CP_SWRC_MASK (0x3 << REG_AUDPLL_CP_SWRC_SHIFT) -#define REG_AUDPLL_CP_SWRC(n) BITFIELD_VAL(REG_AUDPLL_CP_SWRC, n) -#define REG_AUDPLL_DIG_SWRC_SHIFT 9 -#define REG_AUDPLL_DIG_SWRC_MASK (0x3 << REG_AUDPLL_DIG_SWRC_SHIFT) -#define REG_AUDPLL_DIG_SWRC(n) BITFIELD_VAL(REG_AUDPLL_DIG_SWRC, n) -#define REG_AUDPLL_VCO_SPD_SHIFT 11 -#define REG_AUDPLL_VCO_SPD_MASK (0x7 << REG_AUDPLL_VCO_SPD_SHIFT) -#define REG_AUDPLL_VCO_SPD(n) BITFIELD_VAL(REG_AUDPLL_VCO_SPD, n) -#define REG_AUDPLL_VCO_SWRC_SHIFT 14 -#define REG_AUDPLL_VCO_SWRC_MASK (0x3 << REG_AUDPLL_VCO_SWRC_SHIFT) -#define REG_AUDPLL_VCO_SWRC(n) BITFIELD_VAL(REG_AUDPLL_VCO_SWRC, n) +#define REG_CRYSTAL_SEL_LV (1 << 0) +#define REG_EXTPLL_SEL (1 << 1) +#define REG_AUDPLL_CAL_EN (1 << 2) +#define REG_AUDPLL_CP_IEN_SHIFT 3 +#define REG_AUDPLL_CP_IEN_MASK (0xF << REG_AUDPLL_CP_IEN_SHIFT) +#define REG_AUDPLL_CP_IEN(n) BITFIELD_VAL(REG_AUDPLL_CP_IEN, n) +#define REG_AUDPLL_CP_SWRC_SHIFT 7 +#define REG_AUDPLL_CP_SWRC_MASK (0x3 << REG_AUDPLL_CP_SWRC_SHIFT) +#define REG_AUDPLL_CP_SWRC(n) BITFIELD_VAL(REG_AUDPLL_CP_SWRC, n) +#define REG_AUDPLL_DIG_SWRC_SHIFT 9 +#define REG_AUDPLL_DIG_SWRC_MASK (0x3 << REG_AUDPLL_DIG_SWRC_SHIFT) +#define REG_AUDPLL_DIG_SWRC(n) BITFIELD_VAL(REG_AUDPLL_DIG_SWRC, n) +#define REG_AUDPLL_VCO_SPD_SHIFT 11 +#define REG_AUDPLL_VCO_SPD_MASK (0x7 << REG_AUDPLL_VCO_SPD_SHIFT) +#define REG_AUDPLL_VCO_SPD(n) BITFIELD_VAL(REG_AUDPLL_VCO_SPD, n) +#define REG_AUDPLL_VCO_SWRC_SHIFT 14 +#define REG_AUDPLL_VCO_SWRC_MASK (0x3 << REG_AUDPLL_VCO_SWRC_SHIFT) +#define REG_AUDPLL_VCO_SWRC(n) BITFIELD_VAL(REG_AUDPLL_VCO_SWRC, n) // 7A -#define REG_PU_OSC (1 << 0) -#define REG_BBPLL_TST_EN (1 << 1) -#define REG_AUDPLL_TRIGGER_EN (1 << 2) -#define REG_AUDPLL_FREQ_EN (1 << 3) -#define REG_AUDPLL_CLK_FBC_EDGE (1 << 4) -#define REG_AUDPLL_INT_DEC_SEL_SHIFT 5 -#define REG_AUDPLL_INT_DEC_SEL_MASK (0x7 << REG_AUDPLL_INT_DEC_SEL_SHIFT) -#define REG_AUDPLL_INT_DEC_SEL(n) BITFIELD_VAL(REG_AUDPLL_INT_DEC_SEL, n) -#define REG_AUDPLL_DITHER_BYPASS (1 << 8) -#define REG_AUDPLL_PRESCALER_DEL_SEL_SHIFT 9 -#define REG_AUDPLL_PRESCALER_DEL_SEL_MASK (0xF << REG_AUDPLL_PRESCALER_DEL_SEL_SHIFT) -#define REG_AUDPLL_PRESCALER_DEL_SEL(n) BITFIELD_VAL(REG_AUDPLL_PRESCALER_DEL_SEL, n) -#define REG_AUDPLL_FREQ_34_32_SHIFT 13 -#define REG_AUDPLL_FREQ_34_32_MASK (0x7 << REG_AUDPLL_FREQ_34_32_SHIFT) -#define REG_AUDPLL_FREQ_34_32(n) BITFIELD_VAL(REG_AUDPLL_FREQ_34_32, n) +#define REG_PU_OSC (1 << 0) +#define REG_BBPLL_TST_EN (1 << 1) +#define REG_AUDPLL_TRIGGER_EN (1 << 2) +#define REG_AUDPLL_FREQ_EN (1 << 3) +#define REG_AUDPLL_CLK_FBC_EDGE (1 << 4) +#define REG_AUDPLL_INT_DEC_SEL_SHIFT 5 +#define REG_AUDPLL_INT_DEC_SEL_MASK (0x7 << REG_AUDPLL_INT_DEC_SEL_SHIFT) +#define REG_AUDPLL_INT_DEC_SEL(n) BITFIELD_VAL(REG_AUDPLL_INT_DEC_SEL, n) +#define REG_AUDPLL_DITHER_BYPASS (1 << 8) +#define REG_AUDPLL_PRESCALER_DEL_SEL_SHIFT 9 +#define REG_AUDPLL_PRESCALER_DEL_SEL_MASK \ + (0xF << REG_AUDPLL_PRESCALER_DEL_SEL_SHIFT) +#define REG_AUDPLL_PRESCALER_DEL_SEL(n) \ + BITFIELD_VAL(REG_AUDPLL_PRESCALER_DEL_SEL, n) +#define REG_AUDPLL_FREQ_34_32_SHIFT 13 +#define REG_AUDPLL_FREQ_34_32_MASK (0x7 << REG_AUDPLL_FREQ_34_32_SHIFT) +#define REG_AUDPLL_FREQ_34_32(n) BITFIELD_VAL(REG_AUDPLL_FREQ_34_32, n) // 7E -#define REG_CLKMUX_DVDD_SEL (1 << 0) -#define REG_CLKMUX_LDO0P9_VSEL_SHIFT 1 -#define REG_CLKMUX_LDO0P9_VSEL_MASK (0x1F << REG_CLKMUX_LDO0P9_VSEL_SHIFT) -#define REG_CLKMUX_LDO0P9_VSEL(n) BITFIELD_VAL(REG_CLKMUX_LDO0P9_VSEL, n) -#define REG_PU_CLKMUX_LDO0P9 (1 << 6) -#define REG_AUDPLL_LDO_VREF_SHIFT 7 -#define REG_AUDPLL_LDO_VREF_MASK (0x7 << REG_AUDPLL_LDO_VREF_SHIFT) -#define REG_AUDPLL_LDO_VREF(n) BITFIELD_VAL(REG_AUDPLL_LDO_VREF, n) -#define REG_AUDPLL_LPF_BW_SEL (1 << 10) -#define REG_CODEC_ADC_DITHER0P5_EN (1 << 11) -#define REG_CODEC_ADC_DITHER0P25_EN (1 << 12) -#define REG_CODEC_ADC_DITHER1_EN (1 << 13) -#define REG_CODEC_ADC_DITHER2_EN (1 << 14) -#define REG_CODEC_ADC_DITHER_PHASE_SEL (1 << 15) +#define REG_CLKMUX_DVDD_SEL (1 << 0) +#define REG_CLKMUX_LDO0P9_VSEL_SHIFT 1 +#define REG_CLKMUX_LDO0P9_VSEL_MASK (0x1F << REG_CLKMUX_LDO0P9_VSEL_SHIFT) +#define REG_CLKMUX_LDO0P9_VSEL(n) BITFIELD_VAL(REG_CLKMUX_LDO0P9_VSEL, n) +#define REG_PU_CLKMUX_LDO0P9 (1 << 6) +#define REG_AUDPLL_LDO_VREF_SHIFT 7 +#define REG_AUDPLL_LDO_VREF_MASK (0x7 << REG_AUDPLL_LDO_VREF_SHIFT) +#define REG_AUDPLL_LDO_VREF(n) BITFIELD_VAL(REG_AUDPLL_LDO_VREF, n) +#define REG_AUDPLL_LPF_BW_SEL (1 << 10) +#define REG_CODEC_ADC_DITHER0P5_EN (1 << 11) +#define REG_CODEC_ADC_DITHER0P25_EN (1 << 12) +#define REG_CODEC_ADC_DITHER1_EN (1 << 13) +#define REG_CODEC_ADC_DITHER2_EN (1 << 14) +#define REG_CODEC_ADC_DITHER_PHASE_SEL (1 << 15) // 174 -#define CFG_TX_PEAK_OFF_ADC_EN (1 << 0) -#define CFG_TX_PEAK_OFF_DAC_EN (1 << 1) -#define CFG_PEAK_DET_DR (1 << 2) -#define CFG_TX_PEAK_OFF_ADC (1 << 3) -#define CFG_TX_PEAK_OFF_DAC (1 << 4) -#define CFG_PEAK_DET_DB_DELAY_SHIFT 5 -#define CFG_PEAK_DET_DB_DELAY_MASK (0x7 << CFG_PEAK_DET_DB_DELAY_SHIFT) -#define CFG_PEAK_DET_DB_DELAY(n) BITFIELD_VAL(CFG_PEAK_DET_DB_DELAY, n) -#define REG_CODEC_TX_PEAK_DET_BIT (1 << 8) -#define REG_CODEC_TX_PEAK_NL_EN (1 << 9) -#define REG_CODEC_TX_PEAK_NR_EN (1 << 10) -#define REG_CODEC_TX_PEAK_PL_EN (1 << 11) -#define REG_CODEC_TX_PEAK_PR_EN (1 << 12) -#define CFG_TX_CLK_INV (1 << 13) -#define CFG_CODEC_DIN_L_RST (1 << 14) -#define CFG_CODEC_DIN_R_RST (1 << 15) +#define CFG_TX_PEAK_OFF_ADC_EN (1 << 0) +#define CFG_TX_PEAK_OFF_DAC_EN (1 << 1) +#define CFG_PEAK_DET_DR (1 << 2) +#define CFG_TX_PEAK_OFF_ADC (1 << 3) +#define CFG_TX_PEAK_OFF_DAC (1 << 4) +#define CFG_PEAK_DET_DB_DELAY_SHIFT 5 +#define CFG_PEAK_DET_DB_DELAY_MASK (0x7 << CFG_PEAK_DET_DB_DELAY_SHIFT) +#define CFG_PEAK_DET_DB_DELAY(n) BITFIELD_VAL(CFG_PEAK_DET_DB_DELAY, n) +#define REG_CODEC_TX_PEAK_DET_BIT (1 << 8) +#define REG_CODEC_TX_PEAK_NL_EN (1 << 9) +#define REG_CODEC_TX_PEAK_NR_EN (1 << 10) +#define REG_CODEC_TX_PEAK_PL_EN (1 << 11) +#define REG_CODEC_TX_PEAK_PR_EN (1 << 12) +#define CFG_TX_CLK_INV (1 << 13) +#define CFG_CODEC_DIN_L_RST (1 << 14) +#define CFG_CODEC_DIN_R_RST (1 << 15) // C4 -#define CODEC_RESAMPLE_CLK_BUF_PU (1 << 2) +#define CODEC_RESAMPLE_CLK_BUF_PU (1 << 2) // 16A -#define REG_CODEC_EN_ADCE (1 << 0) -#define DIG_CODEC_ADCE_DITHER_EN (1 << 1) -#define DIG_CODEC_ADCE_CH_SEL_SHIFT 2 -#define DIG_CODEC_ADCE_CH_SEL_MASK (0x3 << DIG_CODEC_ADCE_CH_SEL_SHIFT) -#define DIG_CODEC_ADCE_CH_SEL(n) BITFIELD_VAL(DIG_CODEC_ADCE_CH_SEL, n) -#define REG_CODEC_RESET_ADCE (1 << 4) -#define CFG_RESET_ADCE_DR (1 << 5) -#define REG_CODEC_ADCE_GAIN_BIT_SHIFT 6 -#define REG_CODEC_ADCE_GAIN_BIT_MASK (0x7 << REG_CODEC_ADCE_GAIN_BIT_SHIFT) -#define REG_CODEC_ADCE_GAIN_BIT(n) BITFIELD_VAL(REG_CODEC_ADCE_GAIN_BIT, n) -#define REG_CODEC_ADCE_GAIN_UPDATE (1 << 9) -#define REG_CODEC_ADCE_RES_2P5K (1 << 10) -#define REG_CODEC_ADCE_RES_2P5K_UPDATE (1 << 11) -#define DIG_CODEC_ADCE_IDETE_EN (1 << 12) -#define REG_RX_ADCE_ZERO_DET_EN (1 << 13) -#define CFG_ADCE_DITHER_CLK_INV (1 << 14) -#define DIG_CODEC_ADCE_CLK_SEL (1 << 15) +#define REG_CODEC_EN_ADCE (1 << 0) +#define DIG_CODEC_ADCE_DITHER_EN (1 << 1) +#define DIG_CODEC_ADCE_CH_SEL_SHIFT 2 +#define DIG_CODEC_ADCE_CH_SEL_MASK (0x3 << DIG_CODEC_ADCE_CH_SEL_SHIFT) +#define DIG_CODEC_ADCE_CH_SEL(n) BITFIELD_VAL(DIG_CODEC_ADCE_CH_SEL, n) +#define REG_CODEC_RESET_ADCE (1 << 4) +#define CFG_RESET_ADCE_DR (1 << 5) +#define REG_CODEC_ADCE_GAIN_BIT_SHIFT 6 +#define REG_CODEC_ADCE_GAIN_BIT_MASK (0x7 << REG_CODEC_ADCE_GAIN_BIT_SHIFT) +#define REG_CODEC_ADCE_GAIN_BIT(n) BITFIELD_VAL(REG_CODEC_ADCE_GAIN_BIT, n) +#define REG_CODEC_ADCE_GAIN_UPDATE (1 << 9) +#define REG_CODEC_ADCE_RES_2P5K (1 << 10) +#define REG_CODEC_ADCE_RES_2P5K_UPDATE (1 << 11) +#define DIG_CODEC_ADCE_IDETE_EN (1 << 12) +#define REG_RX_ADCE_ZERO_DET_EN (1 << 13) +#define CFG_ADCE_DITHER_CLK_INV (1 << 14) +#define DIG_CODEC_ADCE_CLK_SEL (1 << 15) // 16B -#define DIG_CODEC_ADCE_IBSEL_OP1_SHIFT 0 -#define DIG_CODEC_ADCE_IBSEL_OP1_MASK (0xF << DIG_CODEC_ADCE_IBSEL_OP1_SHIFT) -#define DIG_CODEC_ADCE_IBSEL_OP1(n) BITFIELD_VAL(DIG_CODEC_ADCE_IBSEL_OP1, n) -#define DIG_CODEC_ADCE_IBSEL_OP2_SHIFT 4 -#define DIG_CODEC_ADCE_IBSEL_OP2_MASK (0xF << DIG_CODEC_ADCE_IBSEL_OP2_SHIFT) -#define DIG_CODEC_ADCE_IBSEL_OP2(n) BITFIELD_VAL(DIG_CODEC_ADCE_IBSEL_OP2, n) -#define DIG_CODEC_ADCE_IBSEL_OP3_SHIFT 8 -#define DIG_CODEC_ADCE_IBSEL_OP3_MASK (0xF << DIG_CODEC_ADCE_IBSEL_OP3_SHIFT) -#define DIG_CODEC_ADCE_IBSEL_OP3(n) BITFIELD_VAL(DIG_CODEC_ADCE_IBSEL_OP3, n) -#define DIG_CODEC_ADCE_IBSEL_OP4_SHIFT 12 -#define DIG_CODEC_ADCE_IBSEL_OP4_MASK (0xF << DIG_CODEC_ADCE_IBSEL_OP4_SHIFT) -#define DIG_CODEC_ADCE_IBSEL_OP4(n) BITFIELD_VAL(DIG_CODEC_ADCE_IBSEL_OP4, n) +#define DIG_CODEC_ADCE_IBSEL_OP1_SHIFT 0 +#define DIG_CODEC_ADCE_IBSEL_OP1_MASK (0xF << DIG_CODEC_ADCE_IBSEL_OP1_SHIFT) +#define DIG_CODEC_ADCE_IBSEL_OP1(n) BITFIELD_VAL(DIG_CODEC_ADCE_IBSEL_OP1, n) +#define DIG_CODEC_ADCE_IBSEL_OP2_SHIFT 4 +#define DIG_CODEC_ADCE_IBSEL_OP2_MASK (0xF << DIG_CODEC_ADCE_IBSEL_OP2_SHIFT) +#define DIG_CODEC_ADCE_IBSEL_OP2(n) BITFIELD_VAL(DIG_CODEC_ADCE_IBSEL_OP2, n) +#define DIG_CODEC_ADCE_IBSEL_OP3_SHIFT 8 +#define DIG_CODEC_ADCE_IBSEL_OP3_MASK (0xF << DIG_CODEC_ADCE_IBSEL_OP3_SHIFT) +#define DIG_CODEC_ADCE_IBSEL_OP3(n) BITFIELD_VAL(DIG_CODEC_ADCE_IBSEL_OP3, n) +#define DIG_CODEC_ADCE_IBSEL_OP4_SHIFT 12 +#define DIG_CODEC_ADCE_IBSEL_OP4_MASK (0xF << DIG_CODEC_ADCE_IBSEL_OP4_SHIFT) +#define DIG_CODEC_ADCE_IBSEL_OP4(n) BITFIELD_VAL(DIG_CODEC_ADCE_IBSEL_OP4, n) // 16C -#define DIG_CODEC_ADCE_IBSEL_REG_SHIFT 0 -#define DIG_CODEC_ADCE_IBSEL_REG_MASK (0xF << DIG_CODEC_ADCE_IBSEL_REG_SHIFT) -#define DIG_CODEC_ADCE_IBSEL_REG(n) BITFIELD_VAL(DIG_CODEC_ADCE_IBSEL_REG, n) -#define DIG_CODEC_ADCE_IBSEL_VCOMP_SHIFT 4 -#define DIG_CODEC_ADCE_IBSEL_VCOMP_MASK (0xF << DIG_CODEC_ADCE_IBSEL_VCOMP_SHIFT) -#define DIG_CODEC_ADCE_IBSEL_VCOMP(n) BITFIELD_VAL(DIG_CODEC_ADCE_IBSEL_VCOMP, n) -#define DIG_CODEC_ADCE_IBSEL_VREF_SHIFT 8 -#define DIG_CODEC_ADCE_IBSEL_VREF_MASK (0xF << DIG_CODEC_ADCE_IBSEL_VREF_SHIFT) -#define DIG_CODEC_ADCE_IBSEL_VREF(n) BITFIELD_VAL(DIG_CODEC_ADCE_IBSEL_VREF, n) -#define DIG_CODEC_ADCE_IBSEL_VREFBUF_SHIFT 12 -#define DIG_CODEC_ADCE_IBSEL_VREFBUF_MASK (0xF << DIG_CODEC_ADCE_IBSEL_VREFBUF_SHIFT) -#define DIG_CODEC_ADCE_IBSEL_VREFBUF(n) BITFIELD_VAL(DIG_CODEC_ADCE_IBSEL_VREFBUF, n) +#define DIG_CODEC_ADCE_IBSEL_REG_SHIFT 0 +#define DIG_CODEC_ADCE_IBSEL_REG_MASK (0xF << DIG_CODEC_ADCE_IBSEL_REG_SHIFT) +#define DIG_CODEC_ADCE_IBSEL_REG(n) BITFIELD_VAL(DIG_CODEC_ADCE_IBSEL_REG, n) +#define DIG_CODEC_ADCE_IBSEL_VCOMP_SHIFT 4 +#define DIG_CODEC_ADCE_IBSEL_VCOMP_MASK \ + (0xF << DIG_CODEC_ADCE_IBSEL_VCOMP_SHIFT) +#define DIG_CODEC_ADCE_IBSEL_VCOMP(n) \ + BITFIELD_VAL(DIG_CODEC_ADCE_IBSEL_VCOMP, n) +#define DIG_CODEC_ADCE_IBSEL_VREF_SHIFT 8 +#define DIG_CODEC_ADCE_IBSEL_VREF_MASK (0xF << DIG_CODEC_ADCE_IBSEL_VREF_SHIFT) +#define DIG_CODEC_ADCE_IBSEL_VREF(n) BITFIELD_VAL(DIG_CODEC_ADCE_IBSEL_VREF, n) +#define DIG_CODEC_ADCE_IBSEL_VREFBUF_SHIFT 12 +#define DIG_CODEC_ADCE_IBSEL_VREFBUF_MASK \ + (0xF << DIG_CODEC_ADCE_IBSEL_VREFBUF_SHIFT) +#define DIG_CODEC_ADCE_IBSEL_VREFBUF(n) \ + BITFIELD_VAL(DIG_CODEC_ADCE_IBSEL_VREFBUF, n) // 16D -#define DIG_CODEC_ADCE_IBSEL_IDAC2_SHIFT 0 -#define DIG_CODEC_ADCE_IBSEL_IDAC2_MASK (0xF << DIG_CODEC_ADCE_IBSEL_IDAC2_SHIFT) -#define DIG_CODEC_ADCE_IBSEL_IDAC2(n) BITFIELD_VAL(DIG_CODEC_ADCE_IBSEL_IDAC2, n) -#define DIG_CODEC_ADCE_OP1_IBIT_SHIFT 4 -#define DIG_CODEC_ADCE_OP1_IBIT_MASK (0x3 << DIG_CODEC_ADCE_OP1_IBIT_SHIFT) -#define DIG_CODEC_ADCE_OP1_IBIT(n) BITFIELD_VAL(DIG_CODEC_ADCE_OP1_IBIT, n) -#define DIG_CODEC_ADCE_OP1_R_SEL (1 << 6) -#define DIG_CODEC_ADCE_OP2_IBIT_SHIFT 7 -#define DIG_CODEC_ADCE_OP2_IBIT_MASK (0x3 << DIG_CODEC_ADCE_OP2_IBIT_SHIFT) -#define DIG_CODEC_ADCE_OP2_IBIT(n) BITFIELD_VAL(DIG_CODEC_ADCE_OP2_IBIT, n) -#define DIG_CODEC_ADCE_OP2_R_SEL (1 << 9) -#define DIG_CODEC_ADCE_OP3_IBIT_SHIFT 10 -#define DIG_CODEC_ADCE_OP3_IBIT_MASK (0x3 << DIG_CODEC_ADCE_OP3_IBIT_SHIFT) -#define DIG_CODEC_ADCE_OP3_IBIT(n) BITFIELD_VAL(DIG_CODEC_ADCE_OP3_IBIT, n) -#define DIG_CODEC_ADCE_OP3_R_SEL (1 << 12) -#define DIG_CODEC_ADCE_OP4_IBIT_SHIFT 13 -#define DIG_CODEC_ADCE_OP4_IBIT_MASK (0x3 << DIG_CODEC_ADCE_OP4_IBIT_SHIFT) -#define DIG_CODEC_ADCE_OP4_IBIT(n) BITFIELD_VAL(DIG_CODEC_ADCE_OP4_IBIT, n) -#define DIG_CODEC_ADCE_OP4_R_SEL (1 << 15) +#define DIG_CODEC_ADCE_IBSEL_IDAC2_SHIFT 0 +#define DIG_CODEC_ADCE_IBSEL_IDAC2_MASK \ + (0xF << DIG_CODEC_ADCE_IBSEL_IDAC2_SHIFT) +#define DIG_CODEC_ADCE_IBSEL_IDAC2(n) \ + BITFIELD_VAL(DIG_CODEC_ADCE_IBSEL_IDAC2, n) +#define DIG_CODEC_ADCE_OP1_IBIT_SHIFT 4 +#define DIG_CODEC_ADCE_OP1_IBIT_MASK (0x3 << DIG_CODEC_ADCE_OP1_IBIT_SHIFT) +#define DIG_CODEC_ADCE_OP1_IBIT(n) BITFIELD_VAL(DIG_CODEC_ADCE_OP1_IBIT, n) +#define DIG_CODEC_ADCE_OP1_R_SEL (1 << 6) +#define DIG_CODEC_ADCE_OP2_IBIT_SHIFT 7 +#define DIG_CODEC_ADCE_OP2_IBIT_MASK (0x3 << DIG_CODEC_ADCE_OP2_IBIT_SHIFT) +#define DIG_CODEC_ADCE_OP2_IBIT(n) BITFIELD_VAL(DIG_CODEC_ADCE_OP2_IBIT, n) +#define DIG_CODEC_ADCE_OP2_R_SEL (1 << 9) +#define DIG_CODEC_ADCE_OP3_IBIT_SHIFT 10 +#define DIG_CODEC_ADCE_OP3_IBIT_MASK (0x3 << DIG_CODEC_ADCE_OP3_IBIT_SHIFT) +#define DIG_CODEC_ADCE_OP3_IBIT(n) BITFIELD_VAL(DIG_CODEC_ADCE_OP3_IBIT, n) +#define DIG_CODEC_ADCE_OP3_R_SEL (1 << 12) +#define DIG_CODEC_ADCE_OP4_IBIT_SHIFT 13 +#define DIG_CODEC_ADCE_OP4_IBIT_MASK (0x3 << DIG_CODEC_ADCE_OP4_IBIT_SHIFT) +#define DIG_CODEC_ADCE_OP4_IBIT(n) BITFIELD_VAL(DIG_CODEC_ADCE_OP4_IBIT, n) +#define DIG_CODEC_ADCE_OP4_R_SEL (1 << 15) // 16E -#define DIG_CODEC_ADCE_VREF_SEL_SHIFT 0 -#define DIG_CODEC_ADCE_VREF_SEL_MASK (0xF << DIG_CODEC_ADCE_VREF_SEL_SHIFT) -#define DIG_CODEC_ADCE_VREF_SEL(n) BITFIELD_VAL(DIG_CODEC_ADCE_VREF_SEL, n) -#define DIG_CODEC_ADCE_VREFBUF_BIT_SHIFT 4 -#define DIG_CODEC_ADCE_VREFBUF_BIT_MASK (0xF << DIG_CODEC_ADCE_VREFBUF_BIT_SHIFT) -#define DIG_CODEC_ADCE_VREFBUF_BIT(n) BITFIELD_VAL(DIG_CODEC_ADCE_VREFBUF_BIT, n) -#define DIG_CODEC_ADCE_REG_VSEL_SHIFT 8 -#define DIG_CODEC_ADCE_REG_VSEL_MASK (0x7 << DIG_CODEC_ADCE_REG_VSEL_SHIFT) -#define DIG_CODEC_ADCE_REG_VSEL(n) BITFIELD_VAL(DIG_CODEC_ADCE_REG_VSEL, n) -#define DIG_CODEC_ADCE_CAP_BIT (1 << 11) -#define REG_VOICE_SEL_VREF_BIN_SHIFT 12 -#define REG_VOICE_SEL_VREF_BIN_MASK (0xF << REG_VOICE_SEL_VREF_BIN_SHIFT) -#define REG_VOICE_SEL_VREF_BIN(n) BITFIELD_VAL(REG_VOICE_SEL_VREF_BIN, n) +#define DIG_CODEC_ADCE_VREF_SEL_SHIFT 0 +#define DIG_CODEC_ADCE_VREF_SEL_MASK (0xF << DIG_CODEC_ADCE_VREF_SEL_SHIFT) +#define DIG_CODEC_ADCE_VREF_SEL(n) BITFIELD_VAL(DIG_CODEC_ADCE_VREF_SEL, n) +#define DIG_CODEC_ADCE_VREFBUF_BIT_SHIFT 4 +#define DIG_CODEC_ADCE_VREFBUF_BIT_MASK \ + (0xF << DIG_CODEC_ADCE_VREFBUF_BIT_SHIFT) +#define DIG_CODEC_ADCE_VREFBUF_BIT(n) \ + BITFIELD_VAL(DIG_CODEC_ADCE_VREFBUF_BIT, n) +#define DIG_CODEC_ADCE_REG_VSEL_SHIFT 8 +#define DIG_CODEC_ADCE_REG_VSEL_MASK (0x7 << DIG_CODEC_ADCE_REG_VSEL_SHIFT) +#define DIG_CODEC_ADCE_REG_VSEL(n) BITFIELD_VAL(DIG_CODEC_ADCE_REG_VSEL, n) +#define DIG_CODEC_ADCE_CAP_BIT (1 << 11) +#define REG_VOICE_SEL_VREF_BIN_SHIFT 12 +#define REG_VOICE_SEL_VREF_BIN_MASK (0xF << REG_VOICE_SEL_VREF_BIN_SHIFT) +#define REG_VOICE_SEL_VREF_BIN(n) BITFIELD_VAL(REG_VOICE_SEL_VREF_BIN, n) // 16F -#define REG_VOICE_LP_COMP_SHIFT 0 -#define REG_VOICE_LP_COMP_MASK (0x7 << REG_VOICE_LP_COMP_SHIFT) -#define REG_VOICE_LP_COMP(n) BITFIELD_VAL(REG_VOICE_LP_COMP, n) -#define REG_VOICE_LP_AMPA_SHIFT 3 -#define REG_VOICE_LP_AMPA_MASK (0x7 << REG_VOICE_LP_AMPA_SHIFT) -#define REG_VOICE_LP_AMPA(n) BITFIELD_VAL(REG_VOICE_LP_AMPA, n) -#define REG_VOICE_LP_AMPB_SHIFT 6 -#define REG_VOICE_LP_AMPB_MASK (0x7 << REG_VOICE_LP_AMPB_SHIFT) -#define REG_VOICE_LP_AMPB(n) BITFIELD_VAL(REG_VOICE_LP_AMPB, n) -#define REG_VOICE_LP_LDO_SHIFT 9 -#define REG_VOICE_LP_LDO_MASK (0x7 << REG_VOICE_LP_LDO_SHIFT) -#define REG_VOICE_LP_LDO(n) BITFIELD_VAL(REG_VOICE_LP_LDO, n) -#define REG_VOICE_LP_VREF_SHIFT 12 -#define REG_VOICE_LP_VREF_MASK (0x7 << REG_VOICE_LP_VREF_SHIFT) -#define REG_VOICE_LP_VREF(n) BITFIELD_VAL(REG_VOICE_LP_VREF, n) -#define CFG_REG_VOICE_TRIG_ADCE_EN (1 << 15) +#define REG_VOICE_LP_COMP_SHIFT 0 +#define REG_VOICE_LP_COMP_MASK (0x7 << REG_VOICE_LP_COMP_SHIFT) +#define REG_VOICE_LP_COMP(n) BITFIELD_VAL(REG_VOICE_LP_COMP, n) +#define REG_VOICE_LP_AMPA_SHIFT 3 +#define REG_VOICE_LP_AMPA_MASK (0x7 << REG_VOICE_LP_AMPA_SHIFT) +#define REG_VOICE_LP_AMPA(n) BITFIELD_VAL(REG_VOICE_LP_AMPA, n) +#define REG_VOICE_LP_AMPB_SHIFT 6 +#define REG_VOICE_LP_AMPB_MASK (0x7 << REG_VOICE_LP_AMPB_SHIFT) +#define REG_VOICE_LP_AMPB(n) BITFIELD_VAL(REG_VOICE_LP_AMPB, n) +#define REG_VOICE_LP_LDO_SHIFT 9 +#define REG_VOICE_LP_LDO_MASK (0x7 << REG_VOICE_LP_LDO_SHIFT) +#define REG_VOICE_LP_LDO(n) BITFIELD_VAL(REG_VOICE_LP_LDO, n) +#define REG_VOICE_LP_VREF_SHIFT 12 +#define REG_VOICE_LP_VREF_MASK (0x7 << REG_VOICE_LP_VREF_SHIFT) +#define REG_VOICE_LP_VREF(n) BITFIELD_VAL(REG_VOICE_LP_VREF, n) +#define CFG_REG_VOICE_TRIG_ADCE_EN (1 << 15) // 170 -#define REG_VOICE_HIGH_TUNE_A_SHIFT 0 -#define REG_VOICE_HIGH_TUNE_A_MASK (0xF << REG_VOICE_HIGH_TUNE_A_SHIFT) -#define REG_VOICE_HIGH_TUNE_A(n) BITFIELD_VAL(REG_VOICE_HIGH_TUNE_A, n) -#define REG_VOICE_HIGH_TUNE_B_SHIFT 4 -#define REG_VOICE_HIGH_TUNE_B_MASK (0xF << REG_VOICE_HIGH_TUNE_B_SHIFT) -#define REG_VOICE_HIGH_TUNE_B(n) BITFIELD_VAL(REG_VOICE_HIGH_TUNE_B, n) -#define REG_VOICE_GAIN_A_SHIFT 8 -#define REG_VOICE_GAIN_A_MASK (0x7 << REG_VOICE_GAIN_A_SHIFT) -#define REG_VOICE_GAIN_A(n) BITFIELD_VAL(REG_VOICE_GAIN_A, n) -#define REG_VOICE_GAIN_B_SHIFT 11 -#define REG_VOICE_GAIN_B_MASK (0x7 << REG_VOICE_GAIN_B_SHIFT) -#define REG_VOICE_GAIN_B(n) BITFIELD_VAL(REG_VOICE_GAIN_B, n) -#define CFG_ADC_START (1 << 14) -#define CFG_VOICE2ADCE (1 << 15) +#define REG_VOICE_HIGH_TUNE_A_SHIFT 0 +#define REG_VOICE_HIGH_TUNE_A_MASK (0xF << REG_VOICE_HIGH_TUNE_A_SHIFT) +#define REG_VOICE_HIGH_TUNE_A(n) BITFIELD_VAL(REG_VOICE_HIGH_TUNE_A, n) +#define REG_VOICE_HIGH_TUNE_B_SHIFT 4 +#define REG_VOICE_HIGH_TUNE_B_MASK (0xF << REG_VOICE_HIGH_TUNE_B_SHIFT) +#define REG_VOICE_HIGH_TUNE_B(n) BITFIELD_VAL(REG_VOICE_HIGH_TUNE_B, n) +#define REG_VOICE_GAIN_A_SHIFT 8 +#define REG_VOICE_GAIN_A_MASK (0x7 << REG_VOICE_GAIN_A_SHIFT) +#define REG_VOICE_GAIN_A(n) BITFIELD_VAL(REG_VOICE_GAIN_A, n) +#define REG_VOICE_GAIN_B_SHIFT 11 +#define REG_VOICE_GAIN_B_MASK (0x7 << REG_VOICE_GAIN_B_SHIFT) +#define REG_VOICE_GAIN_B(n) BITFIELD_VAL(REG_VOICE_GAIN_B, n) +#define CFG_ADC_START (1 << 14) +#define CFG_VOICE2ADCE (1 << 15) // 171 -#define CFG_VOICE_POWER_ON (1 << 0) -#define CFG_VOICE_TRIG_ENABLE (1 << 1) -#define CFG_VOICE_RESET (1 << 2) -#define CFG_VOICE_DR (1 << 3) -#define CFG_VOICE_PU_DELAY_SHIFT 4 -#define CFG_VOICE_PU_DELAY_MASK (0x7 << CFG_VOICE_PU_DELAY_SHIFT) -#define CFG_VOICE_PU_DELAY(n) BITFIELD_VAL(CFG_VOICE_PU_DELAY, n) -#define CFG_VOICE_PRECH_DELAY_SHIFT 7 -#define CFG_VOICE_PRECH_DELAY_MASK (0xFF << CFG_VOICE_PRECH_DELAY_SHIFT) -#define CFG_VOICE_PRECH_DELAY(n) BITFIELD_VAL(CFG_VOICE_PRECH_DELAY, n) -#define REG_VOICE_EN_AGPIO_TEST (1 << 15) +#define CFG_VOICE_POWER_ON (1 << 0) +#define CFG_VOICE_TRIG_ENABLE (1 << 1) +#define CFG_VOICE_RESET (1 << 2) +#define CFG_VOICE_DR (1 << 3) +#define CFG_VOICE_PU_DELAY_SHIFT 4 +#define CFG_VOICE_PU_DELAY_MASK (0x7 << CFG_VOICE_PU_DELAY_SHIFT) +#define CFG_VOICE_PU_DELAY(n) BITFIELD_VAL(CFG_VOICE_PU_DELAY, n) +#define CFG_VOICE_PRECH_DELAY_SHIFT 7 +#define CFG_VOICE_PRECH_DELAY_MASK (0xFF << CFG_VOICE_PRECH_DELAY_SHIFT) +#define CFG_VOICE_PRECH_DELAY(n) BITFIELD_VAL(CFG_VOICE_PRECH_DELAY, n) +#define REG_VOICE_EN_AGPIO_TEST (1 << 15) // 172 -#define REG_VOICE_CLK_EDGE_SEL (1 << 0) -#define REG_VOICE_PRECH (1 << 1) -#define REG_VOICE_PU (1 << 2) -#define REG_VOICE_PU_LDO (1 << 3) -#define REG_VOICE_SEL_VCM0P3_BIN_SHIFT 4 -#define REG_VOICE_SEL_VCM0P3_BIN_MASK (0x7 << REG_VOICE_SEL_VCM0P3_BIN_SHIFT) -#define REG_VOICE_SEL_VCM0P3_BIN(n) BITFIELD_VAL(REG_VOICE_SEL_VCM0P3_BIN, n) -#define REG_VOICE_SEL_VCM_BIN_SHIFT 7 -#define REG_VOICE_SEL_VCM_BIN_MASK (0xF << REG_VOICE_SEL_VCM_BIN_SHIFT) -#define REG_VOICE_SEL_VCM_BIN(n) BITFIELD_VAL(REG_VOICE_SEL_VCM_BIN, n) -#define REG_VOICE_SEL_VCMIN_BIN_SHIFT 11 -#define REG_VOICE_SEL_VCMIN_BIN_MASK (0xF << REG_VOICE_SEL_VCMIN_BIN_SHIFT) -#define REG_VOICE_SEL_VCMIN_BIN(n) BITFIELD_VAL(REG_VOICE_SEL_VCMIN_BIN, n) -#define REG_VOICE_PU_OSC (1 << 15) +#define REG_VOICE_CLK_EDGE_SEL (1 << 0) +#define REG_VOICE_PRECH (1 << 1) +#define REG_VOICE_PU (1 << 2) +#define REG_VOICE_PU_LDO (1 << 3) +#define REG_VOICE_SEL_VCM0P3_BIN_SHIFT 4 +#define REG_VOICE_SEL_VCM0P3_BIN_MASK (0x7 << REG_VOICE_SEL_VCM0P3_BIN_SHIFT) +#define REG_VOICE_SEL_VCM0P3_BIN(n) BITFIELD_VAL(REG_VOICE_SEL_VCM0P3_BIN, n) +#define REG_VOICE_SEL_VCM_BIN_SHIFT 7 +#define REG_VOICE_SEL_VCM_BIN_MASK (0xF << REG_VOICE_SEL_VCM_BIN_SHIFT) +#define REG_VOICE_SEL_VCM_BIN(n) BITFIELD_VAL(REG_VOICE_SEL_VCM_BIN, n) +#define REG_VOICE_SEL_VCMIN_BIN_SHIFT 11 +#define REG_VOICE_SEL_VCMIN_BIN_MASK (0xF << REG_VOICE_SEL_VCMIN_BIN_SHIFT) +#define REG_VOICE_SEL_VCMIN_BIN(n) BITFIELD_VAL(REG_VOICE_SEL_VCMIN_BIN, n) +#define REG_VOICE_PU_OSC (1 << 15) // 173 -#define REG_VOICE_LDO_VBIT_SHIFT 0 -#define REG_VOICE_LDO_VBIT_MASK (0x7 << REG_VOICE_LDO_VBIT_SHIFT) -#define REG_VOICE_LDO_VBIT(n) BITFIELD_VAL(REG_VOICE_LDO_VBIT, n) -#define REG_VOICE_OSC_FR_SHIFT 3 -#define REG_VOICE_OSC_FR_MASK (0x7 << REG_VOICE_OSC_FR_SHIFT) -#define REG_VOICE_OSC_FR(n) BITFIELD_VAL(REG_VOICE_OSC_FR, n) -#define REG_VOICE_OSC_PWR_SHIFT 6 -#define REG_VOICE_OSC_PWR_MASK (0x3 << REG_VOICE_OSC_PWR_SHIFT) -#define REG_VOICE_OSC_PWR(n) BITFIELD_VAL(REG_VOICE_OSC_PWR, n) -#define CFG_VOICE_DET_DELAY_SHIFT 8 -#define CFG_VOICE_DET_DELAY_MASK (0xFF << CFG_VOICE_DET_DELAY_SHIFT) -#define CFG_VOICE_DET_DELAY(n) BITFIELD_VAL(CFG_VOICE_DET_DELAY, n) +#define REG_VOICE_LDO_VBIT_SHIFT 0 +#define REG_VOICE_LDO_VBIT_MASK (0x7 << REG_VOICE_LDO_VBIT_SHIFT) +#define REG_VOICE_LDO_VBIT(n) BITFIELD_VAL(REG_VOICE_LDO_VBIT, n) +#define REG_VOICE_OSC_FR_SHIFT 3 +#define REG_VOICE_OSC_FR_MASK (0x7 << REG_VOICE_OSC_FR_SHIFT) +#define REG_VOICE_OSC_FR(n) BITFIELD_VAL(REG_VOICE_OSC_FR, n) +#define REG_VOICE_OSC_PWR_SHIFT 6 +#define REG_VOICE_OSC_PWR_MASK (0x3 << REG_VOICE_OSC_PWR_SHIFT) +#define REG_VOICE_OSC_PWR(n) BITFIELD_VAL(REG_VOICE_OSC_PWR, n) +#define CFG_VOICE_DET_DELAY_SHIFT 8 +#define CFG_VOICE_DET_DELAY_MASK (0xFF << CFG_VOICE_DET_DELAY_SHIFT) +#define CFG_VOICE_DET_DELAY(n) BITFIELD_VAL(CFG_VOICE_DET_DELAY, n) // 174 -#define CFG_TX_PEAK_OFF_ADC_EN (1 << 0) -#define CFG_TX_PEAK_OFF_DAC_EN (1 << 1) -#define CFG_PEAK_DET_DR (1 << 2) -#define CFG_TX_PEAK_OFF_ADC (1 << 3) -#define CFG_TX_PEAK_OFF_DAC (1 << 4) -#define CFG_PEAK_DET_DB_DELAY_SHIFT 5 -#define CFG_PEAK_DET_DB_DELAY_MASK (0x7 << CFG_PEAK_DET_DB_DELAY_SHIFT) -#define CFG_PEAK_DET_DB_DELAY(n) BITFIELD_VAL(CFG_PEAK_DET_DB_DELAY, n) -#define REG_CODEC_TX_PEAK_DET_BIT (1 << 8) -#define REG_CODEC_TX_PEAK_NL_EN (1 << 9) -#define REG_CODEC_TX_PEAK_NR_EN (1 << 10) -#define REG_CODEC_TX_PEAK_PL_EN (1 << 11) -#define REG_CODEC_TX_PEAK_PR_EN (1 << 12) -#define CFG_TX_CLK_INV (1 << 13) -#define CFG_CODEC_DIN_L_RST (1 << 14) -#define CFG_CODEC_DIN_R_RST (1 << 15) +#define CFG_TX_PEAK_OFF_ADC_EN (1 << 0) +#define CFG_TX_PEAK_OFF_DAC_EN (1 << 1) +#define CFG_PEAK_DET_DR (1 << 2) +#define CFG_TX_PEAK_OFF_ADC (1 << 3) +#define CFG_TX_PEAK_OFF_DAC (1 << 4) +#define CFG_PEAK_DET_DB_DELAY_SHIFT 5 +#define CFG_PEAK_DET_DB_DELAY_MASK (0x7 << CFG_PEAK_DET_DB_DELAY_SHIFT) +#define CFG_PEAK_DET_DB_DELAY(n) BITFIELD_VAL(CFG_PEAK_DET_DB_DELAY, n) +#define REG_CODEC_TX_PEAK_DET_BIT (1 << 8) +#define REG_CODEC_TX_PEAK_NL_EN (1 << 9) +#define REG_CODEC_TX_PEAK_NR_EN (1 << 10) +#define REG_CODEC_TX_PEAK_PL_EN (1 << 11) +#define REG_CODEC_TX_PEAK_PR_EN (1 << 12) +#define CFG_TX_CLK_INV (1 << 13) +#define CFG_CODEC_DIN_L_RST (1 << 14) +#define CFG_CODEC_DIN_R_RST (1 << 15) // 175 -#define CODEC_DIN_L_HI_RSTVAL_SHIFT 0 -#define CODEC_DIN_L_HI_RSTVAL_MASK (0xFFFF << CODEC_DIN_L_HI_RSTVAL_SHIFT) -#define CODEC_DIN_L_HI_RSTVAL(n) BITFIELD_VAL(CODEC_DIN_L_HI_RSTVAL, n) +#define CODEC_DIN_L_HI_RSTVAL_SHIFT 0 +#define CODEC_DIN_L_HI_RSTVAL_MASK (0xFFFF << CODEC_DIN_L_HI_RSTVAL_SHIFT) +#define CODEC_DIN_L_HI_RSTVAL(n) BITFIELD_VAL(CODEC_DIN_L_HI_RSTVAL, n) // 176 -#define CODEC_DIN_L_LO_RSTVAL_SHIFT 0 -#define CODEC_DIN_L_LO_RSTVAL_MASK (0xFFFF << CODEC_DIN_L_LO_RSTVAL_SHIFT) -#define CODEC_DIN_L_LO_RSTVAL(n) BITFIELD_VAL(CODEC_DIN_L_LO_RSTVAL, n) +#define CODEC_DIN_L_LO_RSTVAL_SHIFT 0 +#define CODEC_DIN_L_LO_RSTVAL_MASK (0xFFFF << CODEC_DIN_L_LO_RSTVAL_SHIFT) +#define CODEC_DIN_L_LO_RSTVAL(n) BITFIELD_VAL(CODEC_DIN_L_LO_RSTVAL, n) // 177 -#define CODEC_DIN_R_HI_RSTVAL_SHIFT 0 -#define CODEC_DIN_R_HI_RSTVAL_MASK (0xFFFF << CODEC_DIN_R_HI_RSTVAL_SHIFT) -#define CODEC_DIN_R_HI_RSTVAL(n) BITFIELD_VAL(CODEC_DIN_R_HI_RSTVAL, n) +#define CODEC_DIN_R_HI_RSTVAL_SHIFT 0 +#define CODEC_DIN_R_HI_RSTVAL_MASK (0xFFFF << CODEC_DIN_R_HI_RSTVAL_SHIFT) +#define CODEC_DIN_R_HI_RSTVAL(n) BITFIELD_VAL(CODEC_DIN_R_HI_RSTVAL, n) // 178 -#define CODEC_DIN_R_LO_RSTVAL_SHIFT 0 -#define CODEC_DIN_R_LO_RSTVAL_MASK (0xFFFF << CODEC_DIN_R_LO_RSTVAL_SHIFT) -#define CODEC_DIN_R_LO_RSTVAL(n) BITFIELD_VAL(CODEC_DIN_R_LO_RSTVAL, n) +#define CODEC_DIN_R_LO_RSTVAL_SHIFT 0 +#define CODEC_DIN_R_LO_RSTVAL_MASK (0xFFFF << CODEC_DIN_R_LO_RSTVAL_SHIFT) +#define CODEC_DIN_R_LO_RSTVAL(n) BITFIELD_VAL(CODEC_DIN_R_LO_RSTVAL, n) // 179 -#define REG_AUDPLL_LDOPRECHG_TIMER_SHIFT 0 -#define REG_AUDPLL_LDOPRECHG_TIMER_MASK (0x1F << REG_AUDPLL_LDOPRECHG_TIMER_SHIFT) -#define REG_AUDPLL_LDOPRECHG_TIMER(n) BITFIELD_VAL(REG_AUDPLL_LDOPRECHG_TIMER, n) +#define REG_AUDPLL_LDOPRECHG_TIMER_SHIFT 0 +#define REG_AUDPLL_LDOPRECHG_TIMER_MASK \ + (0x1F << REG_AUDPLL_LDOPRECHG_TIMER_SHIFT) +#define REG_AUDPLL_LDOPRECHG_TIMER(n) \ + BITFIELD_VAL(REG_AUDPLL_LDOPRECHG_TIMER, n) #define REG_AUDPLL_PRECHG_BEGIN_TIMER_SHIFT 5 -#define REG_AUDPLL_PRECHG_BEGIN_TIMER_MASK (0x1F << REG_AUDPLL_PRECHG_BEGIN_TIMER_SHIFT) -#define REG_AUDPLL_PRECHG_BEGIN_TIMER(n) BITFIELD_VAL(REG_AUDPLL_PRECHG_BEGIN_TIMER, n) -#define REG_AUDPLL_PRECHG_END_TIMER_SHIFT 10 -#define REG_AUDPLL_PRECHG_END_TIMER_MASK (0x1F << REG_AUDPLL_PRECHG_END_TIMER_SHIFT) -#define REG_AUDPLL_PRECHG_END_TIMER(n) BITFIELD_VAL(REG_AUDPLL_PRECHG_END_TIMER, n) -#define REG_CODEC_ADCD_RES_2P5K_DR (1 << 15) +#define REG_AUDPLL_PRECHG_BEGIN_TIMER_MASK \ + (0x1F << REG_AUDPLL_PRECHG_BEGIN_TIMER_SHIFT) +#define REG_AUDPLL_PRECHG_BEGIN_TIMER(n) \ + BITFIELD_VAL(REG_AUDPLL_PRECHG_BEGIN_TIMER, n) +#define REG_AUDPLL_PRECHG_END_TIMER_SHIFT 10 +#define REG_AUDPLL_PRECHG_END_TIMER_MASK \ + (0x1F << REG_AUDPLL_PRECHG_END_TIMER_SHIFT) +#define REG_AUDPLL_PRECHG_END_TIMER(n) \ + BITFIELD_VAL(REG_AUDPLL_PRECHG_END_TIMER, n) +#define REG_CODEC_ADCD_RES_2P5K_DR (1 << 15) // 17A -#define CFG_PRE_CHARGE_ADCE_DR (1 << 0) -#define REG_CODEC_ADCE_PRE_CHARGE (1 << 1) -#define ADCE_OPEN_TIMER_DLY_SHIFT 2 -#define ADCE_OPEN_TIMER_DLY_MASK (0xF << ADCE_OPEN_TIMER_DLY_SHIFT) -#define ADCE_OPEN_TIMER_DLY(n) BITFIELD_VAL(ADCE_OPEN_TIMER_DLY, n) -#define ADCE_PRE_CHARGE_TIMER_DLY_SHIFT 6 -#define ADCE_PRE_CHARGE_TIMER_DLY_MASK (0xFF << ADCE_PRE_CHARGE_TIMER_DLY_SHIFT) -#define ADCE_PRE_CHARGE_TIMER_DLY(n) BITFIELD_VAL(ADCE_PRE_CHARGE_TIMER_DLY, n) -#define REG_VOICE_LOW_TUNE_SHIFT 14 -#define REG_VOICE_LOW_TUNE_MASK (0x3 << REG_VOICE_LOW_TUNE_SHIFT) -#define REG_VOICE_LOW_TUNE(n) BITFIELD_VAL(REG_VOICE_LOW_TUNE, n) +#define CFG_PRE_CHARGE_ADCE_DR (1 << 0) +#define REG_CODEC_ADCE_PRE_CHARGE (1 << 1) +#define ADCE_OPEN_TIMER_DLY_SHIFT 2 +#define ADCE_OPEN_TIMER_DLY_MASK (0xF << ADCE_OPEN_TIMER_DLY_SHIFT) +#define ADCE_OPEN_TIMER_DLY(n) BITFIELD_VAL(ADCE_OPEN_TIMER_DLY, n) +#define ADCE_PRE_CHARGE_TIMER_DLY_SHIFT 6 +#define ADCE_PRE_CHARGE_TIMER_DLY_MASK (0xFF << ADCE_PRE_CHARGE_TIMER_DLY_SHIFT) +#define ADCE_PRE_CHARGE_TIMER_DLY(n) BITFIELD_VAL(ADCE_PRE_CHARGE_TIMER_DLY, n) +#define REG_VOICE_LOW_TUNE_SHIFT 14 +#define REG_VOICE_LOW_TUNE_MASK (0x3 << REG_VOICE_LOW_TUNE_SHIFT) +#define REG_VOICE_LOW_TUNE(n) BITFIELD_VAL(REG_VOICE_LOW_TUNE, n) // 17B -#define REG_COARSE_EN (1 << 0) -#define REG_XTAL_FREQ_LLC_SFT_RSTN (1 << 1) -#define REG_COARSE_POLAR_SEL (1 << 2) -#define REG_AUDPLL_RSTB_TIMER_SHIFT 3 -#define REG_AUDPLL_RSTB_TIMER_MASK (0x1F << REG_AUDPLL_RSTB_TIMER_SHIFT) -#define REG_AUDPLL_RSTB_TIMER(n) BITFIELD_VAL(REG_AUDPLL_RSTB_TIMER, n) -#define RX_TIMER_RSTN_DLY_SHIFT 8 -#define RX_TIMER_RSTN_DLY_MASK (0xFF << RX_TIMER_RSTN_DLY_SHIFT) -#define RX_TIMER_RSTN_DLY(n) BITFIELD_VAL(RX_TIMER_RSTN_DLY, n) +#define REG_COARSE_EN (1 << 0) +#define REG_XTAL_FREQ_LLC_SFT_RSTN (1 << 1) +#define REG_COARSE_POLAR_SEL (1 << 2) +#define REG_AUDPLL_RSTB_TIMER_SHIFT 3 +#define REG_AUDPLL_RSTB_TIMER_MASK (0x1F << REG_AUDPLL_RSTB_TIMER_SHIFT) +#define REG_AUDPLL_RSTB_TIMER(n) BITFIELD_VAL(REG_AUDPLL_RSTB_TIMER, n) +#define RX_TIMER_RSTN_DLY_SHIFT 8 +#define RX_TIMER_RSTN_DLY_MASK (0xFF << RX_TIMER_RSTN_DLY_SHIFT) +#define RX_TIMER_RSTN_DLY(n) BITFIELD_VAL(RX_TIMER_RSTN_DLY, n) // 17C -#define REG_CNT_COARSE_MARK_SHIFT 0 -#define REG_CNT_COARSE_MARK_MASK (0xFFFF << REG_CNT_COARSE_MARK_SHIFT) -#define REG_CNT_COARSE_MARK(n) BITFIELD_VAL(REG_CNT_COARSE_MARK, n) +#define REG_CNT_COARSE_MARK_SHIFT 0 +#define REG_CNT_COARSE_MARK_MASK (0xFFFF << REG_CNT_COARSE_MARK_SHIFT) +#define REG_CNT_COARSE_MARK(n) BITFIELD_VAL(REG_CNT_COARSE_MARK, n) // 17D -#define REG_CLK_GOAL_DIV_NUM_SHIFT 0 -#define REG_CLK_GOAL_DIV_NUM_MASK (0x1FF << REG_CLK_GOAL_DIV_NUM_SHIFT) -#define REG_CLK_GOAL_DIV_NUM(n) BITFIELD_VAL(REG_CLK_GOAL_DIV_NUM, n) -#define REG_COARSE_TUN_CODE_SHIFT 9 -#define REG_COARSE_TUN_CODE_MASK (0x3F << REG_COARSE_TUN_CODE_SHIFT) -#define REG_COARSE_TUN_CODE(n) BITFIELD_VAL(REG_COARSE_TUN_CODE, n) -#define REG_COARSE_TUN_CODE_DR (1 << 15) +#define REG_CLK_GOAL_DIV_NUM_SHIFT 0 +#define REG_CLK_GOAL_DIV_NUM_MASK (0x1FF << REG_CLK_GOAL_DIV_NUM_SHIFT) +#define REG_CLK_GOAL_DIV_NUM(n) BITFIELD_VAL(REG_CLK_GOAL_DIV_NUM, n) +#define REG_COARSE_TUN_CODE_SHIFT 9 +#define REG_COARSE_TUN_CODE_MASK (0x3F << REG_COARSE_TUN_CODE_SHIFT) +#define REG_COARSE_TUN_CODE(n) BITFIELD_VAL(REG_COARSE_TUN_CODE, n) +#define REG_COARSE_TUN_CODE_DR (1 << 15) // 17E -#define SSC_ENABLE (1 << 0) -#define TRI_FREQ_OFST_SEL_SHIFT 1 -#define TRI_FREQ_OFST_SEL_MASK (0x7 << TRI_FREQ_OFST_SEL_SHIFT) -#define TRI_FREQ_OFST_SEL(n) BITFIELD_VAL(TRI_FREQ_OFST_SEL, n) -#define TRI_FREQ_SEL_SHIFT 4 -#define TRI_FREQ_SEL_MASK (0x3 << TRI_FREQ_SEL_SHIFT) -#define TRI_FREQ_SEL(n) BITFIELD_VAL(TRI_FREQ_SEL, n) -#define REG_VOICE_EN_REF_TEST (1 << 6) -#define REG_VOICE_GAIN_BASE_SHIFT 7 -#define REG_VOICE_GAIN_BASE_MASK (0x7 << REG_VOICE_GAIN_BASE_SHIFT) -#define REG_VOICE_GAIN_BASE(n) BITFIELD_VAL(REG_VOICE_GAIN_BASE, n) -#define CFG_VOICE_PRECH_DONE_DELAY_SHIFT 10 -#define CFG_VOICE_PRECH_DONE_DELAY_MASK (0x1F << CFG_VOICE_PRECH_DONE_DELAY_SHIFT) -#define CFG_VOICE_PRECH_DONE_DELAY(n) BITFIELD_VAL(CFG_VOICE_PRECH_DONE_DELAY, n) -#define REG_CODEC_LP_VCM_DR (1 << 15) +#define SSC_ENABLE (1 << 0) +#define TRI_FREQ_OFST_SEL_SHIFT 1 +#define TRI_FREQ_OFST_SEL_MASK (0x7 << TRI_FREQ_OFST_SEL_SHIFT) +#define TRI_FREQ_OFST_SEL(n) BITFIELD_VAL(TRI_FREQ_OFST_SEL, n) +#define TRI_FREQ_SEL_SHIFT 4 +#define TRI_FREQ_SEL_MASK (0x3 << TRI_FREQ_SEL_SHIFT) +#define TRI_FREQ_SEL(n) BITFIELD_VAL(TRI_FREQ_SEL, n) +#define REG_VOICE_EN_REF_TEST (1 << 6) +#define REG_VOICE_GAIN_BASE_SHIFT 7 +#define REG_VOICE_GAIN_BASE_MASK (0x7 << REG_VOICE_GAIN_BASE_SHIFT) +#define REG_VOICE_GAIN_BASE(n) BITFIELD_VAL(REG_VOICE_GAIN_BASE, n) +#define CFG_VOICE_PRECH_DONE_DELAY_SHIFT 10 +#define CFG_VOICE_PRECH_DONE_DELAY_MASK \ + (0x1F << CFG_VOICE_PRECH_DONE_DELAY_SHIFT) +#define CFG_VOICE_PRECH_DONE_DELAY(n) \ + BITFIELD_VAL(CFG_VOICE_PRECH_DONE_DELAY, n) +#define REG_CODEC_LP_VCM_DR (1 << 15) // 17F -#define TX_PEAK_DET_STATUS (1 << 0) -#define TX_PEAK_DET_NL_STATUS (1 << 1) -#define TX_PEAK_DET_NR_STATUS (1 << 2) -#define TX_PEAK_DET_PL_STATUS (1 << 3) -#define TX_PEAK_DET_PR_STATUS (1 << 4) -#define DBG_STATE_SHIFT 5 -#define DBG_STATE_MASK (0x3 << DBG_STATE_SHIFT) -#define DBG_STATE(n) BITFIELD_VAL(DBG_STATE, n) +#define TX_PEAK_DET_STATUS (1 << 0) +#define TX_PEAK_DET_NL_STATUS (1 << 1) +#define TX_PEAK_DET_NR_STATUS (1 << 2) +#define TX_PEAK_DET_PL_STATUS (1 << 3) +#define TX_PEAK_DET_PR_STATUS (1 << 4) +#define DBG_STATE_SHIFT 5 +#define DBG_STATE_MASK (0x3 << DBG_STATE_SHIFT) +#define DBG_STATE(n) BITFIELD_VAL(DBG_STATE, n) enum ANA_REG_T { - ANA_REG_61 = 0x61, - ANA_REG_62, - ANA_REG_63, - ANA_REG_64, - ANA_REG_65, - ANA_REG_66, - ANA_REG_67, - ANA_REG_68, - ANA_REG_69, - ANA_REG_6A, - ANA_REG_6B, - ANA_REG_6C, - ANA_REG_6D, - ANA_REG_6E, - ANA_REG_6F, - ANA_REG_70, - ANA_REG_71, - ANA_REG_72, - ANA_REG_73, - ANA_REG_74, - ANA_REG_75, - ANA_REG_76, - ANA_REG_77, - ANA_REG_78, - ANA_REG_79, - ANA_REG_7A, - ANA_REG_7B, - ANA_REG_7C, - ANA_REG_7D, - ANA_REG_7E, - ANA_REG_7F, + ANA_REG_61 = 0x61, + ANA_REG_62, + ANA_REG_63, + ANA_REG_64, + ANA_REG_65, + ANA_REG_66, + ANA_REG_67, + ANA_REG_68, + ANA_REG_69, + ANA_REG_6A, + ANA_REG_6B, + ANA_REG_6C, + ANA_REG_6D, + ANA_REG_6E, + ANA_REG_6F, + ANA_REG_70, + ANA_REG_71, + ANA_REG_72, + ANA_REG_73, + ANA_REG_74, + ANA_REG_75, + ANA_REG_76, + ANA_REG_77, + ANA_REG_78, + ANA_REG_79, + ANA_REG_7A, + ANA_REG_7B, + ANA_REG_7C, + ANA_REG_7D, + ANA_REG_7E, + ANA_REG_7F, - ANA_REG_161 = 0x161, - ANA_REG_162, - ANA_REG_163, - ANA_REG_164, - ANA_REG_165, - ANA_REG_166, - ANA_REG_167, - ANA_REG_168, - ANA_REG_169, - ANA_REG_16A, - ANA_REG_16B, - ANA_REG_16C, - ANA_REG_16D, - ANA_REG_16E, - ANA_REG_16F, - ANA_REG_170, - ANA_REG_171, - ANA_REG_172, - ANA_REG_173, - ANA_REG_174, - ANA_REG_175, - ANA_REG_176, - ANA_REG_177, - ANA_REG_178, - ANA_REG_179, - ANA_REG_17A, - ANA_REG_17B, - ANA_REG_17C, - ANA_REG_17D, - ANA_REG_17E, - ANA_REG_17F, + ANA_REG_161 = 0x161, + ANA_REG_162, + ANA_REG_163, + ANA_REG_164, + ANA_REG_165, + ANA_REG_166, + ANA_REG_167, + ANA_REG_168, + ANA_REG_169, + ANA_REG_16A, + ANA_REG_16B, + ANA_REG_16C, + ANA_REG_16D, + ANA_REG_16E, + ANA_REG_16F, + ANA_REG_170, + ANA_REG_171, + ANA_REG_172, + ANA_REG_173, + ANA_REG_174, + ANA_REG_175, + ANA_REG_176, + ANA_REG_177, + ANA_REG_178, + ANA_REG_179, + ANA_REG_17A, + ANA_REG_17B, + ANA_REG_17C, + ANA_REG_17D, + ANA_REG_17E, + ANA_REG_17F, - ANA_REG_RF_C4 = 0xC4, + ANA_REG_RF_C4 = 0xC4, }; enum ANA_CODEC_USER_T { - ANA_CODEC_USER_DAC = (1 << 0), - ANA_CODEC_USER_ADC = (1 << 1), + ANA_CODEC_USER_DAC = (1 << 0), + ANA_CODEC_USER_ADC = (1 << 1), - ANA_CODEC_USER_CODEC = (1 << 2), - ANA_CODEC_USER_MICKEY = (1 << 3), + ANA_CODEC_USER_CODEC = (1 << 2), + ANA_CODEC_USER_MICKEY = (1 << 3), - ANA_CODEC_USER_ANC_FF = (1 << 4), - ANA_CODEC_USER_ANC_FB = (1 << 5), + ANA_CODEC_USER_ANC_FF = (1 << 4), + ANA_CODEC_USER_ANC_FB = (1 << 5), - ANA_CODEC_USER_VAD = (1 << 6), + ANA_CODEC_USER_VAD = (1 << 6), }; struct ANALOG_PLL_CFG_T { - uint32_t freq; - uint8_t div; - uint64_t val; + uint32_t freq; + uint8_t div; + uint64_t val; }; #ifdef ANC_PROD_TEST #define OPT_TYPE #else -#define OPT_TYPE const +#define OPT_TYPE const #endif static OPT_TYPE uint16_t vcodec_mv = (uint16_t)(VCODEC_VOLT * 1000); @@ -849,1271 +900,1254 @@ static enum ANA_AUD_PLL_USER_T ana_aud_pll_map; static int8_t adc_gain_offset[MAX_ANA_MIC_CH_NUM]; #endif -static const int8_t adc_db[] = { -9, -6, -3, 0, 3, 6, 9, 12, }; +static const int8_t adc_db[] = { + -9, -6, -3, 0, 3, 6, 9, 12, +}; static const int8_t tgt_adc_db[MAX_ANA_MIC_CH_NUM] = { - ANALOG_ADC_A_GAIN_DB, ANALOG_ADC_B_GAIN_DB, - ANALOG_ADC_C_GAIN_DB, ANALOG_ADC_D_GAIN_DB, - ANALOG_ADC_E_GAIN_DB, + ANALOG_ADC_A_GAIN_DB, ANALOG_ADC_B_GAIN_DB, ANALOG_ADC_C_GAIN_DB, + ANALOG_ADC_D_GAIN_DB, ANALOG_ADC_E_GAIN_DB, }; // Max allowed total tune ratio (5000ppm) -#define MAX_TOTAL_TUNE_RATIO 0.005000 +#define MAX_TOTAL_TUNE_RATIO 0.005000 static struct ANALOG_PLL_CFG_T ana_pll_cfg[2]; static int pll_cfg_idx; -void analog_aud_freq_pll_config(uint32_t freq, uint32_t div) -{ - // CODEC_FREQ is likely 24.576M (48K series) or 22.5792M (44.1K series) - // PLL_nominal = CODEC_FREQ * CODEC_DIV - // PLL_cfg_val = ((CODEC_FREQ * CODEC_DIV) / 26M) * (1 << 28) +void analog_aud_freq_pll_config(uint32_t freq, uint32_t div) { + // CODEC_FREQ is likely 24.576M (48K series) or 22.5792M (44.1K series) + // PLL_nominal = CODEC_FREQ * CODEC_DIV + // PLL_cfg_val = ((CODEC_FREQ * CODEC_DIV) / 26M) * (1 << 28) - int i, j; - uint64_t PLL_cfg_val; - uint16_t high, low, bit34_32; - uint16_t val; + int i, j; + uint64_t PLL_cfg_val; + uint16_t high, low, bit34_32; + uint16_t val; - if (pll_cfg_idx < ARRAY_SIZE(ana_pll_cfg) && - ana_pll_cfg[pll_cfg_idx].freq == freq && - ana_pll_cfg[pll_cfg_idx].div == div) { - return; + if (pll_cfg_idx < ARRAY_SIZE(ana_pll_cfg) && + ana_pll_cfg[pll_cfg_idx].freq == freq && + ana_pll_cfg[pll_cfg_idx].div == div) { + return; + } + + j = ARRAY_SIZE(ana_pll_cfg); + for (i = 0; i < ARRAY_SIZE(ana_pll_cfg); i++) { + if (ana_pll_cfg[i].freq == freq && ana_pll_cfg[i].div == div) { + break; } - - j = ARRAY_SIZE(ana_pll_cfg); - for (i = 0; i < ARRAY_SIZE(ana_pll_cfg); i++) { - if (ana_pll_cfg[i].freq == freq && ana_pll_cfg[i].div == div) { - break; - } - if (j == ARRAY_SIZE(ana_pll_cfg) && ana_pll_cfg[i].freq == 0) { - j = i; - } + if (j == ARRAY_SIZE(ana_pll_cfg) && ana_pll_cfg[i].freq == 0) { + j = i; } + } - if (i < ARRAY_SIZE(ana_pll_cfg)) { - pll_cfg_idx = i; - PLL_cfg_val = ana_pll_cfg[pll_cfg_idx].val; + if (i < ARRAY_SIZE(ana_pll_cfg)) { + pll_cfg_idx = i; + PLL_cfg_val = ana_pll_cfg[pll_cfg_idx].val; + } else { + if (j < ARRAY_SIZE(ana_pll_cfg)) { + pll_cfg_idx = j; } else { - if (j < ARRAY_SIZE(ana_pll_cfg)) { - pll_cfg_idx = j; - } else { - pll_cfg_idx = 0; - } - - PLL_cfg_val = ((uint64_t)(1 << 28) * freq * div + 26000000 / 2) / 26000000; - - ana_pll_cfg[pll_cfg_idx].freq = freq; - ana_pll_cfg[pll_cfg_idx].div = div; - ana_pll_cfg[pll_cfg_idx].val = PLL_cfg_val; + pll_cfg_idx = 0; } - low = PLL_cfg_val & 0xFFFF; - high = (PLL_cfg_val >> 16) & 0xFFFF; - bit34_32 = (PLL_cfg_val >> 32) & 0xFFFF; + PLL_cfg_val = ((uint64_t)(1 << 28) * freq * div + 26000000 / 2) / 26000000; - pmu_pll_div_set(HAL_CMU_PLL_AUD, PMU_PLL_DIV_CODEC, div); + ana_pll_cfg[pll_cfg_idx].freq = freq; + ana_pll_cfg[pll_cfg_idx].div = div; + ana_pll_cfg[pll_cfg_idx].val = PLL_cfg_val; + } - analog_write(ANA_REG_7C, low); - analog_write(ANA_REG_7B, high); - analog_read(ANA_REG_7A, &val); - val = SET_BITFIELD(val, REG_AUDPLL_FREQ_34_32, bit34_32) | REG_AUDPLL_FREQ_EN; - analog_write(ANA_REG_7A, val); + low = PLL_cfg_val & 0xFFFF; + high = (PLL_cfg_val >> 16) & 0xFFFF; + bit34_32 = (PLL_cfg_val >> 32) & 0xFFFF; + + pmu_pll_div_set(HAL_CMU_PLL_AUD, PMU_PLL_DIV_CODEC, div); + + analog_write(ANA_REG_7C, low); + analog_write(ANA_REG_7B, high); + analog_read(ANA_REG_7A, &val); + val = SET_BITFIELD(val, REG_AUDPLL_FREQ_34_32, bit34_32) | REG_AUDPLL_FREQ_EN; + analog_write(ANA_REG_7A, val); } -void analog_aud_pll_tune(float ratio) -{ +void analog_aud_pll_tune(float ratio) { #ifdef __AUDIO_RESAMPLE__ - if (hal_cmu_get_audio_resample_status()) { - return; - } + if (hal_cmu_get_audio_resample_status()) { + return; + } #endif - // CODEC_FREQ is likely 24.576M (48K series) or 22.5792M (44.1K series) - // PLL_nominal = CODEC_FREQ * CODEC_DIV - // PLL_cfg_val = ((CODEC_FREQ * CODEC_DIV) / 26M) * (1 << 28) - // Delta = ((SampleDiff / Fs) / TimeDiff) * PLL_cfg_val + // CODEC_FREQ is likely 24.576M (48K series) or 22.5792M (44.1K series) + // PLL_nominal = CODEC_FREQ * CODEC_DIV + // PLL_cfg_val = ((CODEC_FREQ * CODEC_DIV) / 26M) * (1 << 28) + // Delta = ((SampleDiff / Fs) / TimeDiff) * PLL_cfg_val - int64_t delta, new_pll; - uint16_t new_high, new_low; - uint16_t val, new_bit34_32; + int64_t delta, new_pll; + uint16_t new_high, new_low; + uint16_t val, new_bit34_32; - if (pll_cfg_idx >= ARRAY_SIZE(ana_pll_cfg) || - ana_pll_cfg[pll_cfg_idx].freq == 0) { - ANALOG_INFO_TRACE(1,"%s: WARNING: aud pll config cache invalid. Skip tuning", __FUNCTION__); - return; + if (pll_cfg_idx >= ARRAY_SIZE(ana_pll_cfg) || + ana_pll_cfg[pll_cfg_idx].freq == 0) { + ANALOG_INFO_TRACE(1, + "%s: WARNING: aud pll config cache invalid. Skip tuning", + __FUNCTION__); + return; + } + + if (ABS(ratio) > MAX_TOTAL_TUNE_RATIO) { + ANALOG_INFO_TRACE(1, + "\n------\nWARNING: TUNE: ratio=%d is too large and will " + "be cut\n------\n", + FLOAT_TO_PPB_INT(ratio)); + if (ratio > 0) { + ratio = MAX_TOTAL_TUNE_RATIO; + } else { + ratio = -MAX_TOTAL_TUNE_RATIO; } + } - if (ABS(ratio) > MAX_TOTAL_TUNE_RATIO) { - ANALOG_INFO_TRACE(1,"\n------\nWARNING: TUNE: ratio=%d is too large and will be cut\n------\n", FLOAT_TO_PPB_INT(ratio)); - if (ratio > 0) { - ratio = MAX_TOTAL_TUNE_RATIO; - } else { - ratio = -MAX_TOTAL_TUNE_RATIO; - } - } + ANALOG_INFO_TRACE(2, "%s: ratio=%d", __FUNCTION__, FLOAT_TO_PPB_INT(ratio)); - ANALOG_INFO_TRACE(2,"%s: ratio=%d", __FUNCTION__, FLOAT_TO_PPB_INT(ratio)); + new_pll = (int64_t)ana_pll_cfg[pll_cfg_idx].val; + delta = (int64_t)(new_pll * ratio); - new_pll = (int64_t)ana_pll_cfg[pll_cfg_idx].val; - delta = (int64_t)(new_pll * ratio); + new_pll += delta; - new_pll += delta; + new_low = new_pll & 0xFFFF; + new_high = (new_pll >> 16) & 0xFFFF; + new_bit34_32 = (new_pll >> 32) & 0xFFFF; - new_low = new_pll & 0xFFFF; - new_high = (new_pll >> 16) & 0xFFFF; - new_bit34_32 = (new_pll >> 32) & 0xFFFF; - - analog_write(ANA_REG_7C, new_low); - analog_write(ANA_REG_7B, new_high); - analog_read(ANA_REG_7A, &val); - val = SET_BITFIELD(val, REG_AUDPLL_FREQ_34_32, new_bit34_32) | REG_AUDPLL_FREQ_EN; - analog_write(ANA_REG_7A, val); + analog_write(ANA_REG_7C, new_low); + analog_write(ANA_REG_7B, new_high); + analog_read(ANA_REG_7A, &val); + val = SET_BITFIELD(val, REG_AUDPLL_FREQ_34_32, new_bit34_32) | + REG_AUDPLL_FREQ_EN; + analog_write(ANA_REG_7A, val); } -void analog_aud_osc_clk_enable(bool enable) -{ - uint16_t val; +void analog_aud_osc_clk_enable(bool enable) { + uint16_t val; - if (enable) { - analog_read(ANA_REG_RF_C4, &val); - val |= CODEC_RESAMPLE_CLK_BUF_PU; - analog_write(ANA_REG_RF_C4, val); + if (enable) { + analog_read(ANA_REG_RF_C4, &val); + val |= CODEC_RESAMPLE_CLK_BUF_PU; + analog_write(ANA_REG_RF_C4, val); - analog_read(ANA_REG_7A, &val); - val |= REG_PU_OSC; - analog_write(ANA_REG_7A, val); + analog_read(ANA_REG_7A, &val); + val |= REG_PU_OSC; + analog_write(ANA_REG_7A, val); - analog_read(ANA_REG_75, &val); - val |= REG_CRYSTAL_SEL_LV; - analog_write(ANA_REG_75, val); + analog_read(ANA_REG_75, &val); + val |= REG_CRYSTAL_SEL_LV; + analog_write(ANA_REG_75, val); #if 0 analog_read(ANA_REG_174, &val); val |= CFG_TX_CLK_INV; analog_write(ANA_REG_174, val); #endif - } else { + } else { #if 0 analog_read(ANA_REG_174, &val); val &= ~CFG_TX_CLK_INV; analog_write(ANA_REG_174, val); #endif - analog_read(ANA_REG_75, &val); - val &= ~REG_CRYSTAL_SEL_LV; - analog_write(ANA_REG_75, val); + analog_read(ANA_REG_75, &val); + val &= ~REG_CRYSTAL_SEL_LV; + analog_write(ANA_REG_75, val); - analog_read(ANA_REG_7A, &val); - val &= ~REG_PU_OSC; - analog_write(ANA_REG_7A, val); + analog_read(ANA_REG_7A, &val); + val &= ~REG_PU_OSC; + analog_write(ANA_REG_7A, val); - analog_read(ANA_REG_RF_C4, &val); - val &= ~CODEC_RESAMPLE_CLK_BUF_PU; - analog_write(ANA_REG_RF_C4, val); - } + analog_read(ANA_REG_RF_C4, &val); + val &= ~CODEC_RESAMPLE_CLK_BUF_PU; + analog_write(ANA_REG_RF_C4, val); + } } -void analog_aud_pll_open(enum ANA_AUD_PLL_USER_T user) -{ - if (user >= ANA_AUD_PLL_USER_END) { - return; - } +void analog_aud_pll_open(enum ANA_AUD_PLL_USER_T user) { + if (user >= ANA_AUD_PLL_USER_END) { + return; + } #ifdef __AUDIO_RESAMPLE__ - if (user == ANA_AUD_PLL_USER_CODEC && - hal_cmu_get_audio_resample_status()) { + if (user == ANA_AUD_PLL_USER_CODEC && hal_cmu_get_audio_resample_status()) { - analog_aud_osc_clk_enable(true); - return; - } + analog_aud_osc_clk_enable(true); + return; + } #endif - if (ana_aud_pll_map == 0) { - hal_cmu_pll_enable(HAL_CMU_PLL_AUD, HAL_CMU_PLL_USER_AUD); - } - ana_aud_pll_map |= user; + if (ana_aud_pll_map == 0) { + hal_cmu_pll_enable(HAL_CMU_PLL_AUD, HAL_CMU_PLL_USER_AUD); + } + ana_aud_pll_map |= user; } -void analog_aud_pll_close(enum ANA_AUD_PLL_USER_T user) -{ - if (user >= ANA_AUD_PLL_USER_END) { - return; - } +void analog_aud_pll_close(enum ANA_AUD_PLL_USER_T user) { + if (user >= ANA_AUD_PLL_USER_END) { + return; + } #ifdef __AUDIO_RESAMPLE__ - if (user == ANA_AUD_PLL_USER_CODEC && - hal_cmu_get_audio_resample_status()) { + if (user == ANA_AUD_PLL_USER_CODEC && hal_cmu_get_audio_resample_status()) { - analog_aud_osc_clk_enable(false); - return; - } + analog_aud_osc_clk_enable(false); + return; + } #endif - ana_aud_pll_map &= ~user; - if (ana_aud_pll_map == 0) { - hal_cmu_pll_disable(HAL_CMU_PLL_AUD, HAL_CMU_PLL_USER_AUD); - } + ana_aud_pll_map &= ~user; + if (ana_aud_pll_map == 0) { + hal_cmu_pll_disable(HAL_CMU_PLL_AUD, HAL_CMU_PLL_USER_AUD); + } } -static void analog_aud_enable_dac(uint32_t dac) -{ - uint16_t val_6e; - uint16_t val_70; - uint16_t val_73; +static void analog_aud_enable_dac(uint32_t dac) { + uint16_t val_6e; + uint16_t val_70; + uint16_t val_73; - analog_read(ANA_REG_6E, &val_6e); - analog_read(ANA_REG_70, &val_70); + analog_read(ANA_REG_6E, &val_6e); + analog_read(ANA_REG_70, &val_70); - if (dac & (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1)) { - val_6e |= REG_CODEC_TX_EAR_DR_EN | REG_CODEC_TX_EAR_ENBIAS; - analog_write(ANA_REG_6E, val_6e); - osDelay(1); - val_70 |= CFG_TX_TREE_EN; - analog_write(ANA_REG_70, val_70); - osDelay(1); + if (dac & (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1)) { + val_6e |= REG_CODEC_TX_EAR_DR_EN | REG_CODEC_TX_EAR_ENBIAS; + analog_write(ANA_REG_6E, val_6e); + osDelay(1); + val_70 |= CFG_TX_TREE_EN; + analog_write(ANA_REG_70, val_70); + osDelay(1); - val_73 = 0; - if (dac & AUD_CHANNEL_MAP_CH0) { - val_73 |= REG_CODEC_TX_EN_EARPA_L | REG_CODEC_TX_EN_LCLK | REG_CODEC_TX_EN_LDAC; - } - if (dac & AUD_CHANNEL_MAP_CH1) { - val_73 |= REG_CODEC_TX_EN_EARPA_R | REG_CODEC_TX_EN_RCLK | REG_CODEC_TX_EN_RDAC - | REG_CODEC_TX_EN_LDAC; - } - val_73 |= REG_CODEC_TX_EN_DACLDO | REG_CODEC_TX_EN_LPPA; - analog_write(ANA_REG_73, val_73); - osDelay(1); - val_73 |= REG_CODEC_TX_EN_S1PA; - analog_write(ANA_REG_73, val_73); - // Ensure 1ms delay before enabling dac_pa - osDelay(1); - } else { - // Ensure 1ms delay after disabling dac_pa - osDelay(1); - analog_read(ANA_REG_73, &val_73); - val_73 &= ~REG_CODEC_TX_EN_S1PA; - analog_write(ANA_REG_73, val_73); - osDelay(1); - val_73 = 0; - analog_write(ANA_REG_73, val_73); - osDelay(1); - - val_70 &= ~CFG_TX_TREE_EN; - analog_write(ANA_REG_70, val_70); - osDelay(1); - - val_6e &= ~(REG_CODEC_TX_EAR_DR_EN | REG_CODEC_TX_EAR_ENBIAS); - analog_write(ANA_REG_6E, val_6e); + val_73 = 0; + if (dac & AUD_CHANNEL_MAP_CH0) { + val_73 |= + REG_CODEC_TX_EN_EARPA_L | REG_CODEC_TX_EN_LCLK | REG_CODEC_TX_EN_LDAC; } -} - -static void analog_aud_enable_dac_pa(uint32_t dac) -{ - uint16_t val_73; - + if (dac & AUD_CHANNEL_MAP_CH1) { + val_73 |= REG_CODEC_TX_EN_EARPA_R | REG_CODEC_TX_EN_RCLK | + REG_CODEC_TX_EN_RDAC | REG_CODEC_TX_EN_LDAC; + } + val_73 |= REG_CODEC_TX_EN_DACLDO | REG_CODEC_TX_EN_LPPA; + analog_write(ANA_REG_73, val_73); + osDelay(1); + val_73 |= REG_CODEC_TX_EN_S1PA; + analog_write(ANA_REG_73, val_73); + // Ensure 1ms delay before enabling dac_pa + osDelay(1); + } else { + // Ensure 1ms delay after disabling dac_pa + osDelay(1); analog_read(ANA_REG_73, &val_73); + val_73 &= ~REG_CODEC_TX_EN_S1PA; + analog_write(ANA_REG_73, val_73); + osDelay(1); + val_73 = 0; + analog_write(ANA_REG_73, val_73); + osDelay(1); - if (dac & (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1)) { - val_73 |= REG_CODEC_TX_EN_S4PA; - analog_write(ANA_REG_73, val_73); + val_70 &= ~CFG_TX_TREE_EN; + analog_write(ANA_REG_70, val_70); + osDelay(1); -#ifdef AUDIO_OUTPUT_DC_CALIB_ANA - hal_codec_dac_sdm_reset_clear(); -#endif - } else { -#ifdef AUDIO_OUTPUT_DC_CALIB_ANA - hal_codec_dac_sdm_reset_set(); -#endif - - val_73 &= ~REG_CODEC_TX_EN_S4PA; - analog_write(ANA_REG_73, val_73); - } + val_6e &= ~(REG_CODEC_TX_EAR_DR_EN | REG_CODEC_TX_EAR_ENBIAS); + analog_write(ANA_REG_6E, val_6e); + } } -static void analog_aud_enable_adc(enum ANA_CODEC_USER_T user, enum AUD_CHANNEL_MAP_T ch_map, bool en) -{ - int i; - uint16_t val_61, val_6c, val_16a; - enum ANA_CODEC_USER_T old_map; - bool set; - bool global_update; +static void analog_aud_enable_dac_pa(uint32_t dac) { + uint16_t val_73; - ANALOG_DEBUG_TRACE(3,"[%s] user=%d ch_map=0x%x", __func__, user, ch_map); + analog_read(ANA_REG_73, &val_73); - global_update = false; + if (dac & (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1)) { + val_73 |= REG_CODEC_TX_EN_S4PA; + analog_write(ANA_REG_73, val_73); - analog_read(ANA_REG_61, &val_61); - analog_read(ANA_REG_16A, &val_16a); +#ifdef AUDIO_OUTPUT_DC_CALIB_ANA + hal_codec_dac_sdm_reset_clear(); +#endif + } else { +#ifdef AUDIO_OUTPUT_DC_CALIB_ANA + hal_codec_dac_sdm_reset_set(); +#endif - for (i = 0; i < MAX_ANA_MIC_CH_NUM; i++) { - if (ch_map & (AUD_CHANNEL_MAP_CH0 << i)) { - set = false; - if (en) { - if (adc_map[i] == 0) { - set = true; - } - adc_map[i] |= user; - } else { - old_map = adc_map[i]; - adc_map[i] &= ~user; - if (old_map != 0 && adc_map[i] == 0) { - set = true; - } - } - if (set) { - global_update = true; - if (i == 4) { - if (adc_map[i]) { - val_16a |= REG_CODEC_EN_ADCE; - } else { - val_16a &= ~REG_CODEC_EN_ADCE; - } - } else { - if (adc_map[i]) { - val_61 |= (REG_CODEC_EN_ADCA << i); - } else { - val_61 &= ~(REG_CODEC_EN_ADCA << i); - } - } - } + val_73 &= ~REG_CODEC_TX_EN_S4PA; + analog_write(ANA_REG_73, val_73); + } +} + +static void analog_aud_enable_adc(enum ANA_CODEC_USER_T user, + enum AUD_CHANNEL_MAP_T ch_map, bool en) { + int i; + uint16_t val_61, val_6c, val_16a; + enum ANA_CODEC_USER_T old_map; + bool set; + bool global_update; + + ANALOG_DEBUG_TRACE(3, "[%s] user=%d ch_map=0x%x", __func__, user, ch_map); + + global_update = false; + + analog_read(ANA_REG_61, &val_61); + analog_read(ANA_REG_16A, &val_16a); + + for (i = 0; i < MAX_ANA_MIC_CH_NUM; i++) { + if (ch_map & (AUD_CHANNEL_MAP_CH0 << i)) { + set = false; + if (en) { + if (adc_map[i] == 0) { + set = true; } - } - - analog_write(ANA_REG_61, val_61); - analog_write(ANA_REG_16A, val_16a); - - if (global_update) { - for (i = 0; i < MAX_ANA_MIC_CH_NUM; i++) { - if (adc_map[i]) { - break; - } + adc_map[i] |= user; + } else { + old_map = adc_map[i]; + adc_map[i] &= ~user; + if (old_map != 0 && adc_map[i] == 0) { + set = true; } - analog_read(ANA_REG_6C, &val_6c); - if (i < MAX_ANA_MIC_CH_NUM) { - val_6c |= REG_CODEC_RX_EN_VTOI; + } + if (set) { + global_update = true; + if (i == 4) { + if (adc_map[i]) { + val_16a |= REG_CODEC_EN_ADCE; + } else { + val_16a &= ~REG_CODEC_EN_ADCE; + } } else { - val_6c &= ~REG_CODEC_RX_EN_VTOI; + if (adc_map[i]) { + val_61 |= (REG_CODEC_EN_ADCA << i); + } else { + val_61 &= ~(REG_CODEC_EN_ADCA << i); + } } - analog_write(ANA_REG_6C, val_6c); + } } -} + } -static uint32_t db_to_adc_gain(int db) -{ - int i; - uint8_t cnt; - const int8_t *list; + analog_write(ANA_REG_61, val_61); + analog_write(ANA_REG_16A, val_16a); - list = adc_db; - cnt = ARRAY_SIZE(adc_db); - - for (i = 0; i < cnt - 1; i++) { - if (db < list[i + 1]) { - break; - } + if (global_update) { + for (i = 0; i < MAX_ANA_MIC_CH_NUM; i++) { + if (adc_map[i]) { + break; + } } - - if (i == cnt - 1) { - return i; - } - else if (db * 2 < list[i] + list[i + 1]) { - return i; + analog_read(ANA_REG_6C, &val_6c); + if (i < MAX_ANA_MIC_CH_NUM) { + val_6c |= REG_CODEC_RX_EN_VTOI; } else { - return i + 1; + val_6c &= ~REG_CODEC_RX_EN_VTOI; } + analog_write(ANA_REG_6C, val_6c); + } } -static int8_t get_chan_adc_gain(uint32_t i) -{ - int8_t gain; +static uint32_t db_to_adc_gain(int db) { + int i; + uint8_t cnt; + const int8_t *list; - gain = tgt_adc_db[i]; + list = adc_db; + cnt = ARRAY_SIZE(adc_db); + + for (i = 0; i < cnt - 1; i++) { + if (db < list[i + 1]) { + break; + } + } + + if (i == cnt - 1) { + return i; + } else if (db * 2 < list[i] + list[i + 1]) { + return i; + } else { + return i + 1; + } +} + +static int8_t get_chan_adc_gain(uint32_t i) { + int8_t gain; + + gain = tgt_adc_db[i]; #ifdef DYN_ADC_GAIN - if (adc_gain_offset[i] < 0 && -adc_gain_offset[i] > gain) { - gain = 0; - } else { - gain += adc_gain_offset[i]; - } + if (adc_gain_offset[i] < 0 && -adc_gain_offset[i] > gain) { + gain = 0; + } else { + gain += adc_gain_offset[i]; + } #endif - return gain; + return gain; } -static void analog_aud_set_adc_gain(enum AUD_IO_PATH_T input_path, enum AUD_CHANNEL_MAP_T ch_map) -{ - int i; - int gain; - uint16_t gain_val; - uint16_t val, val_16a; +static void analog_aud_set_adc_gain(enum AUD_IO_PATH_T input_path, + enum AUD_CHANNEL_MAP_T ch_map) { + int i; + int gain; + uint16_t gain_val; + uint16_t val, val_16a; - analog_read(ANA_REG_63, &val); - if (ch_map & AUD_CHANNEL_MAP_CH4) { - analog_read(ANA_REG_16A, &val_16a); - } else { - val_16a = 0; - } + analog_read(ANA_REG_63, &val); + if (ch_map & AUD_CHANNEL_MAP_CH4) { + analog_read(ANA_REG_16A, &val_16a); + } else { + val_16a = 0; + } - for (i = 0; i < MAX_ANA_MIC_CH_NUM; i++) { - if (ch_map & (AUD_CHANNEL_MAP_CH0 << i)) { - if (0) { + for (i = 0; i < MAX_ANA_MIC_CH_NUM; i++) { + if (ch_map & (AUD_CHANNEL_MAP_CH0 << i)) { + if (0) { #ifdef ANC_APP #ifdef ANC_FF_ENABLED - } else if ((ANC_FF_MIC_CH_L | ANC_FF_MIC_CH_R) & (AUD_CHANNEL_MAP_CH0 << i)) { - gain = get_chan_adc_gain(i); + } else if ((ANC_FF_MIC_CH_L | ANC_FF_MIC_CH_R) & + (AUD_CHANNEL_MAP_CH0 << i)) { + gain = get_chan_adc_gain(i); #endif #ifdef ANC_FB_ENABLED - } else if ((ANC_FB_MIC_CH_L | ANC_FB_MIC_CH_R) & (AUD_CHANNEL_MAP_CH0 << i)) { - gain = get_chan_adc_gain(i); + } else if ((ANC_FB_MIC_CH_L | ANC_FB_MIC_CH_R) & + (AUD_CHANNEL_MAP_CH0 << i)) { + gain = get_chan_adc_gain(i); #endif #endif - } else if (input_path == AUD_INPUT_PATH_LINEIN) { - gain = LINEIN_ADC_GAIN_DB; - } else { - gain = get_chan_adc_gain(i); - } - gain_val = db_to_adc_gain(gain); - if (i < MAX_ANA_MIC_CH_NUM - 1) { - val = (val & ~(REG_CODEC_ADCA_GAIN_BIT_MASK << 3 * i)) | (REG_CODEC_ADCA_GAIN_BIT(gain_val) << 3 * i); - } else { - val_16a = SET_BITFIELD(val_16a, REG_CODEC_ADCE_GAIN_BIT, gain_val); - } - } + } else if (input_path == AUD_INPUT_PATH_LINEIN) { + gain = LINEIN_ADC_GAIN_DB; + } else { + gain = get_chan_adc_gain(i); + } + gain_val = db_to_adc_gain(gain); + if (i < MAX_ANA_MIC_CH_NUM - 1) { + val = (val & ~(REG_CODEC_ADCA_GAIN_BIT_MASK << 3 * i)) | + (REG_CODEC_ADCA_GAIN_BIT(gain_val) << 3 * i); + } else { + val_16a = SET_BITFIELD(val_16a, REG_CODEC_ADCE_GAIN_BIT, gain_val); + } } + } - analog_write(ANA_REG_63, val); - if (ch_map & AUD_CHANNEL_MAP_CH4) { - analog_write(ANA_REG_16A, val_16a); - } + analog_write(ANA_REG_63, val); + if (ch_map & AUD_CHANNEL_MAP_CH4) { + analog_write(ANA_REG_16A, val_16a); + } } #ifdef ANC_APP -void analog_aud_apply_anc_adc_gain_offset(enum ANC_TYPE_T type, int16_t offset_l, int16_t offset_r) -{ - enum ANC_TYPE_T single_type; - enum AUD_CHANNEL_MAP_T ch_map; - uint32_t l, r; - int8_t org_l, adj_l; - int8_t org_r, adj_r; +void analog_aud_apply_anc_adc_gain_offset(enum ANC_TYPE_T type, + int16_t offset_l, int16_t offset_r) { + enum ANC_TYPE_T single_type; + enum AUD_CHANNEL_MAP_T ch_map; + uint32_t l, r; + int8_t org_l, adj_l; + int8_t org_r, adj_r; - // qdb to db - offset_l /= 4; - offset_r /= 4; + // qdb to db + offset_l /= 4; + offset_r /= 4; - while (type) { - l = get_msb_pos(type); - single_type = (1 << l); - type &= ~single_type; + while (type) { + l = get_msb_pos(type); + single_type = (1 << l); + type &= ~single_type; - ch_map = 0; - l = r = 32; - if (0) { + ch_map = 0; + l = r = 32; + if (0) { #if defined(ANC_FF_MIC_CH_L) || defined(ANC_FF_MIC_CH_R) - } else if (single_type == ANC_FEEDFORWARD) { - ch_map |= ANC_FF_MIC_CH_L | ANC_FF_MIC_CH_R; - l = get_msb_pos(ANC_FF_MIC_CH_L); - r = get_msb_pos(ANC_FF_MIC_CH_R); + } else if (single_type == ANC_FEEDFORWARD) { + ch_map |= ANC_FF_MIC_CH_L | ANC_FF_MIC_CH_R; + l = get_msb_pos(ANC_FF_MIC_CH_L); + r = get_msb_pos(ANC_FF_MIC_CH_R); #endif #if defined(ANC_FB_MIC_CH_L) || defined(ANC_FB_MIC_CH_R) - } else if (single_type == ANC_FEEDBACK) { - ch_map = ANC_FB_MIC_CH_L | ANC_FB_MIC_CH_R; - l = get_msb_pos(ANC_FB_MIC_CH_L); - r = get_msb_pos(ANC_FB_MIC_CH_R); + } else if (single_type == ANC_FEEDBACK) { + ch_map = ANC_FB_MIC_CH_L | ANC_FB_MIC_CH_R; + l = get_msb_pos(ANC_FB_MIC_CH_L); + r = get_msb_pos(ANC_FB_MIC_CH_R); #endif - } else { - continue; - } - - if ((l >= MAX_ANA_MIC_CH_NUM || adc_gain_offset[l] == offset_l) && - (r >= MAX_ANA_MIC_CH_NUM || adc_gain_offset[r] == offset_r)) { - continue; - } - - ANALOG_INFO_TRACE(0, "ana: apply anc adc gain offset: type=%d offset=%d/%d", single_type, offset_l, offset_r); - - org_l = adj_l = 0; - if (l < MAX_ANA_MIC_CH_NUM) { - adc_gain_offset[l] = 0; - if (offset_l) { - org_l = adc_db[db_to_adc_gain(get_chan_adc_gain(l))]; - adc_gain_offset[l] = offset_l; - adj_l = adc_db[db_to_adc_gain(get_chan_adc_gain(l))]; - } - } - - org_r = adj_r = 0; - if (r < MAX_ANA_MIC_CH_NUM) { - adc_gain_offset[r] = 0; - if (offset_r) { - org_r = adc_db[db_to_adc_gain(get_chan_adc_gain(r))]; - adc_gain_offset[r] = offset_r; - adj_r = adc_db[db_to_adc_gain(get_chan_adc_gain(r))]; - } - } - - hal_codec_apply_anc_adc_gain_offset(single_type, (org_l - adj_l), (org_r - adj_r)); - analog_aud_set_adc_gain(AUD_INPUT_PATH_MAINMIC, ch_map); + } else { + continue; } + + if ((l >= MAX_ANA_MIC_CH_NUM || adc_gain_offset[l] == offset_l) && + (r >= MAX_ANA_MIC_CH_NUM || adc_gain_offset[r] == offset_r)) { + continue; + } + + ANALOG_INFO_TRACE(0, "ana: apply anc adc gain offset: type=%d offset=%d/%d", + single_type, offset_l, offset_r); + + org_l = adj_l = 0; + if (l < MAX_ANA_MIC_CH_NUM) { + adc_gain_offset[l] = 0; + if (offset_l) { + org_l = adc_db[db_to_adc_gain(get_chan_adc_gain(l))]; + adc_gain_offset[l] = offset_l; + adj_l = adc_db[db_to_adc_gain(get_chan_adc_gain(l))]; + } + } + + org_r = adj_r = 0; + if (r < MAX_ANA_MIC_CH_NUM) { + adc_gain_offset[r] = 0; + if (offset_r) { + org_r = adc_db[db_to_adc_gain(get_chan_adc_gain(r))]; + adc_gain_offset[r] = offset_r; + adj_r = adc_db[db_to_adc_gain(get_chan_adc_gain(r))]; + } + } + + hal_codec_apply_anc_adc_gain_offset(single_type, (org_l - adj_l), + (org_r - adj_r)); + analog_aud_set_adc_gain(AUD_INPUT_PATH_MAINMIC, ch_map); + } } #endif #ifdef DYN_ADC_GAIN -void analog_aud_apply_adc_gain_offset(enum AUD_CHANNEL_MAP_T ch_map, int16_t offset) -{ - enum AUD_CHANNEL_MAP_T map; - int i; +void analog_aud_apply_adc_gain_offset(enum AUD_CHANNEL_MAP_T ch_map, + int16_t offset) { + enum AUD_CHANNEL_MAP_T map; + int i; #ifdef ANC_APP #ifdef ANC_FF_ENABLED - ch_map &= ~(ANC_FF_MIC_CH_L | ANC_FF_MIC_CH_R); + ch_map &= ~(ANC_FF_MIC_CH_L | ANC_FF_MIC_CH_R); #endif #ifdef ANC_FB_ENABLED - ch_map &= ~(ANC_FB_MIC_CH_L | ANC_FB_MIC_CH_R); + ch_map &= ~(ANC_FB_MIC_CH_L | ANC_FB_MIC_CH_R); #endif #endif - if (ch_map) { - map = ch_map; + if (ch_map) { + map = ch_map; - while (map) { - i = get_msb_pos(map); - map &= ~(1 << i); - if (i < MAX_ANA_MIC_CH_NUM) { - adc_gain_offset[i] = offset; - } - } - - ANALOG_INFO_TRACE(2,"ana: apply adc gain offset: ch_map=0x%X offset=%d", ch_map, offset); - - analog_aud_set_adc_gain(AUD_INPUT_PATH_MAINMIC, ch_map); - } -} -#endif - -void analog_aud_set_dac_gain(int32_t v) -{ -} - -uint32_t analog_codec_get_dac_gain(void) -{ - return 0; -} - -uint32_t analog_codec_dac_gain_to_db(int32_t gain) -{ - return 0; -} - -int32_t analog_codec_dac_max_attn_db(void) -{ - return 0; -} - -static int POSSIBLY_UNUSED dc_calib_checksum_valid(uint32_t efuse) -{ - int i; - uint32_t cnt = 0; - uint32_t chksum_mask = (1 << (16 - DAC_DC_CALIB_BIT_WIDTH)) - 1; - - for (i = 0; i < DAC_DC_CALIB_BIT_WIDTH; i++) { - if (efuse & (1 << i)) { - cnt++; - } + while (map) { + i = get_msb_pos(map); + map &= ~(1 << i); + if (i < MAX_ANA_MIC_CH_NUM) { + adc_gain_offset[i] = offset; + } } - return (((~cnt) & chksum_mask) == ((efuse >> DAC_DC_CALIB_BIT_WIDTH) & chksum_mask)); + ANALOG_INFO_TRACE(2, "ana: apply adc gain offset: ch_map=0x%X offset=%d", + ch_map, offset); + + analog_aud_set_adc_gain(AUD_INPUT_PATH_MAINMIC, ch_map); + } +} +#endif + +void analog_aud_set_dac_gain(int32_t v) {} + +uint32_t analog_codec_get_dac_gain(void) { return 0; } + +uint32_t analog_codec_dac_gain_to_db(int32_t gain) { return 0; } + +int32_t analog_codec_dac_max_attn_db(void) { return 0; } + +static int POSSIBLY_UNUSED dc_calib_checksum_valid(uint32_t efuse) { + int i; + uint32_t cnt = 0; + uint32_t chksum_mask = (1 << (16 - DAC_DC_CALIB_BIT_WIDTH)) - 1; + + for (i = 0; i < DAC_DC_CALIB_BIT_WIDTH; i++) { + if (efuse & (1 << i)) { + cnt++; + } + } + + return (((~cnt) & chksum_mask) == + ((efuse >> DAC_DC_CALIB_BIT_WIDTH) & chksum_mask)); } -static int16_t dc_calib_val_decode(int16_t val) -{ +static int16_t dc_calib_val_decode(int16_t val) { #ifdef AUDIO_OUTPUT_DC_CALIB_ANA - uint32_t sign_bit = (1 << (DAC_DC_CALIB_BIT_WIDTH - 1)); - uint32_t num_mask = sign_bit - 1; + uint32_t sign_bit = (1 << (DAC_DC_CALIB_BIT_WIDTH - 1)); + uint32_t num_mask = sign_bit - 1; - if (val & sign_bit) { - val = -(val & num_mask); - } + if (val & sign_bit) { + val = -(val & num_mask); + } #endif - return val; + return val; } -void analog_aud_get_dc_calib_value(int16_t *dc_l, int16_t *dc_r) -{ - static const uint8_t EFUSE_PAGE_DIFF_1P7V[2] = { PMU_EFUSE_PAGE_DCCALIB2_L, PMU_EFUSE_PAGE_DCCALIB2_R, }; - static const uint8_t EFUSE_PAGE_DIFF_1P95V[2] = { PMU_EFUSE_PAGE_DCCALIB_L, PMU_EFUSE_PAGE_DCCALIB_R, }; - const uint8_t *page; - uint16_t efuse; +void analog_aud_get_dc_calib_value(int16_t *dc_l, int16_t *dc_r) { + static const uint8_t EFUSE_PAGE_DIFF_1P7V[2] = { + PMU_EFUSE_PAGE_DCCALIB2_L, + PMU_EFUSE_PAGE_DCCALIB2_R, + }; + static const uint8_t EFUSE_PAGE_DIFF_1P95V[2] = { + PMU_EFUSE_PAGE_DCCALIB_L, + PMU_EFUSE_PAGE_DCCALIB_R, + }; + const uint8_t *page; + uint16_t efuse; - union DC_EFUSE_T { - struct DC_VALUE_T { - int16_t dc : DAC_DC_CALIB_BIT_WIDTH; - uint16_t checksum : (16 - DAC_DC_CALIB_BIT_WIDTH); - } val; - uint16_t reg; - }; - union DC_EFUSE_T dc; + union DC_EFUSE_T { + struct DC_VALUE_T { + int16_t dc : DAC_DC_CALIB_BIT_WIDTH; + uint16_t checksum : (16 - DAC_DC_CALIB_BIT_WIDTH); + } val; + uint16_t reg; + }; + union DC_EFUSE_T dc; - if (vcodec_mv >= 1900) { - page = EFUSE_PAGE_DIFF_1P95V; - } else { - page = EFUSE_PAGE_DIFF_1P7V; - } + if (vcodec_mv >= 1900) { + page = EFUSE_PAGE_DIFF_1P95V; + } else { + page = EFUSE_PAGE_DIFF_1P7V; + } - pmu_get_efuse(page[0], &efuse); - if (dc_calib_checksum_valid(efuse)) { - ANALOG_INFO_TRACE(1,"Dc calib L OK: 0x%04x", efuse); - dc.reg = efuse; - *dc_l = dc.val.dc; - } else { - ANALOG_INFO_TRACE(1,"Warning: Bad dc calib efuse L: 0x%04x", efuse); - *dc_l = 0; - } + pmu_get_efuse(page[0], &efuse); + if (dc_calib_checksum_valid(efuse)) { + ANALOG_INFO_TRACE(1, "Dc calib L OK: 0x%04x", efuse); + dc.reg = efuse; + *dc_l = dc.val.dc; + } else { + ANALOG_INFO_TRACE(1, "Warning: Bad dc calib efuse L: 0x%04x", efuse); + *dc_l = 0; + } - pmu_get_efuse(page[1], &efuse); - if (dc_calib_checksum_valid(efuse)) { - ANALOG_INFO_TRACE(1,"Dc calib R OK: 0x%04x", efuse); - dc.reg = efuse; - *dc_r = dc.val.dc; - } else { - ANALOG_INFO_TRACE(1,"Warning: Bad dc calib efuse R: 0x%04x", efuse); - *dc_r = 0; - } + pmu_get_efuse(page[1], &efuse); + if (dc_calib_checksum_valid(efuse)) { + ANALOG_INFO_TRACE(1, "Dc calib R OK: 0x%04x", efuse); + dc.reg = efuse; + *dc_r = dc.val.dc; + } else { + ANALOG_INFO_TRACE(1, "Warning: Bad dc calib efuse R: 0x%04x", efuse); + *dc_r = 0; + } - ANALOG_INFO_TRACE(2,"ANA: DC CALIB L=0x%04hX/%d R=0x%04hX/%d", *dc_l, dc_calib_val_decode(*dc_l), *dc_r, dc_calib_val_decode(*dc_r)); + ANALOG_INFO_TRACE(2, "ANA: DC CALIB L=0x%04hX/%d R=0x%04hX/%d", *dc_l, + dc_calib_val_decode(*dc_l), *dc_r, + dc_calib_val_decode(*dc_r)); #if defined(ANA_DC_CALIB_L) || defined(ANA_DC_CALIB_R) #ifdef ANA_DC_CALIB_L - *dc_l = ANA_DC_CALIB_L; + *dc_l = ANA_DC_CALIB_L; #endif #ifdef ANA_DC_CALIB_R - *dc_r = ANA_DC_CALIB_R; + *dc_r = ANA_DC_CALIB_R; #endif - ANALOG_INFO_TRACE(2,"ANA: OVERRIDE DC CALIB L=0x%04hX/%d R=0x%04hX/%d", *dc_l, dc_calib_val_decode(*dc_l), *dc_r, dc_calib_val_decode(*dc_r)); + ANALOG_INFO_TRACE(2, "ANA: OVERRIDE DC CALIB L=0x%04hX/%d R=0x%04hX/%d", + *dc_l, dc_calib_val_decode(*dc_l), *dc_r, + dc_calib_val_decode(*dc_r)); #endif - return; + return; } #ifdef AUDIO_OUTPUT_DC_CALIB_ANA -static void analog_aud_dc_calib_init(void) -{ - uint16_t val; - int16_t dc_l, dc_r; +static void analog_aud_dc_calib_init(void) { + uint16_t val; + int16_t dc_l, dc_r; - analog_aud_get_dc_calib_value(&dc_l, &dc_r); + analog_aud_get_dc_calib_value(&dc_l, &dc_r); - analog_read(ANA_REG_71, &val); - val = SET_BITFIELD(val, REG_CODEC_TX_EAR_OFF_BITL, dc_l); - analog_write(ANA_REG_71, val); + analog_read(ANA_REG_71, &val); + val = SET_BITFIELD(val, REG_CODEC_TX_EAR_OFF_BITL, dc_l); + analog_write(ANA_REG_71, val); - analog_read(ANA_REG_72, &val); - val = SET_BITFIELD(val, REG_CODEC_TX_EAR_OFF_BITR, dc_r); - analog_write(ANA_REG_72, val); + analog_read(ANA_REG_72, &val); + val = SET_BITFIELD(val, REG_CODEC_TX_EAR_OFF_BITR, dc_r); + analog_write(ANA_REG_72, val); } -static void analog_aud_dc_calib_enable(bool en) -{ - uint16_t val; +static void analog_aud_dc_calib_enable(bool en) { + uint16_t val; - analog_read(ANA_REG_70, &val); - val |= REG_CODEC_TX_EAR_OFFEN; - analog_write(ANA_REG_70, val); + analog_read(ANA_REG_70, &val); + val |= REG_CODEC_TX_EAR_OFFEN; + analog_write(ANA_REG_70, val); } #endif -static void analog_aud_vcodec_enable(enum ANA_CODEC_USER_T user, bool en) -{ - uint32_t lock; - bool set = false; +static void analog_aud_vcodec_enable(enum ANA_CODEC_USER_T user, bool en) { + uint32_t lock; + bool set = false; - lock = int_lock(); - if (en) { - if (vcodec_map == 0) { - set = true; - } - vcodec_map |= user; - } else { - vcodec_map &= ~user; - if (vcodec_map == 0) { - set = true; - } + lock = int_lock(); + if (en) { + if (vcodec_map == 0) { + set = true; } - int_unlock(lock); + vcodec_map |= user; + } else { + vcodec_map &= ~user; + if (vcodec_map == 0) { + set = true; + } + } + int_unlock(lock); - if (set) { - pmu_codec_config(!!vcodec_map); - } + if (set) { + pmu_codec_config(!!vcodec_map); + } } -static void analog_aud_enable_common_internal(enum ANA_CODEC_USER_T user, bool en) -{ - uint32_t lock; - uint16_t val_6b; - bool set = false; +static void analog_aud_enable_common_internal(enum ANA_CODEC_USER_T user, + bool en) { + uint32_t lock; + uint16_t val_6b; + bool set = false; - lock = int_lock(); - if (en) { - if (codec_common_map == 0) { - set = true; - } - codec_common_map |= user; - } else { - codec_common_map &= ~user; - if (codec_common_map == 0) { - set = true; - } + lock = int_lock(); + if (en) { + if (codec_common_map == 0) { + set = true; } - int_unlock(lock); + codec_common_map |= user; + } else { + codec_common_map &= ~user; + if (codec_common_map == 0) { + set = true; + } + } + int_unlock(lock); - if (set) { - analog_read(ANA_REG_6B, &val_6b); - if (codec_common_map) { - val_6b |= REG_CODEC_EN_VCM; - } else { - val_6b &= ~(REG_CODEC_EN_VCM | REG_CODEC_VCM_EN_LPF); - } - if (codec_common_map) { - // RTOS application startup time is long enougth for VCM charging + if (set) { + analog_read(ANA_REG_6B, &val_6b); + if (codec_common_map) { + val_6b |= REG_CODEC_EN_VCM; + } else { + val_6b &= ~(REG_CODEC_EN_VCM | REG_CODEC_VCM_EN_LPF); + } + if (codec_common_map) { + // RTOS application startup time is long enougth for VCM charging #if !(defined(VCM_ON) && defined(RTOS)) - // VCM fully stable time is about 60ms/1.95V or 150ms/1.7V - // Quick startup: - // 1) Disable VCM LPF and target to a higher voltage than the required one - // 2) Wait for a short time when VCM is in quick charge (high voltage) - // 3) Enable VCM LPF and target to the required VCM LPF voltage - analog_write(ANA_REG_6B, SET_BITFIELD(val_6b, REG_CODEC_VCM_LOW_VCM, 0)); - uint32_t delay; + // VCM fully stable time is about 60ms/1.95V or 150ms/1.7V + // Quick startup: + // 1) Disable VCM LPF and target to a higher voltage than the required one + // 2) Wait for a short time when VCM is in quick charge (high voltage) + // 3) Enable VCM LPF and target to the required VCM LPF voltage + analog_write(ANA_REG_6B, SET_BITFIELD(val_6b, REG_CODEC_VCM_LOW_VCM, 0)); + uint32_t delay; #if defined(VCM_CAP_100NF) - if (vcodec_mv >= 1900) { - delay = 6; - } else { - delay = 10; - } + if (vcodec_mv >= 1900) { + delay = 6; + } else { + delay = 10; + } #else - if (vcodec_mv >= 1900) { - delay = 25; - } else { - delay = 100; - } + if (vcodec_mv >= 1900) { + delay = 25; + } else { + delay = 100; + } #endif - osDelay(delay); + osDelay(delay); #if 0 // Target to a voltage near the required one analog_write(ANA_REG_6B, val_6b); osDelay(10); #endif #endif // !(VCM_ON && RTOS) - val_6b |= REG_CODEC_VCM_EN_LPF; - } - analog_write(ANA_REG_6B, val_6b); + val_6b |= REG_CODEC_VCM_EN_LPF; } + analog_write(ANA_REG_6B, val_6b); + } } -static void analog_aud_enable_codec_common(enum ANA_CODEC_USER_T user, bool en) -{ +static void analog_aud_enable_codec_common(enum ANA_CODEC_USER_T user, + bool en) { #ifndef VCM_ON - analog_aud_enable_common_internal(user, en); + analog_aud_enable_common_internal(user, en); #endif } -static void analog_aud_enable_adda_common(enum ANA_CODEC_USER_T user, bool en) -{ - uint32_t lock; - uint16_t val_6a, val_6b, val_74, val_7e; - bool set = false; +static void analog_aud_enable_adda_common(enum ANA_CODEC_USER_T user, bool en) { + uint32_t lock; + uint16_t val_6a, val_6b, val_74, val_7e; + bool set = false; - lock = int_lock(); - if (en) { - if (adda_common_map == 0) { - set = true; - } - adda_common_map |= user; + lock = int_lock(); + if (en) { + if (adda_common_map == 0) { + set = true; + } + adda_common_map |= user; + } else { + adda_common_map &= ~user; + if (adda_common_map == 0) { + set = true; + } + } + int_unlock(lock); + + if (set) { + analog_read(ANA_REG_6A, &val_6a); + analog_read(ANA_REG_6B, &val_6b); + if (vcodec_mv >= 1700) { + analog_read(ANA_REG_74, &val_74); } else { - adda_common_map &= ~user; - if (adda_common_map == 0) { - set = true; - } + val_74 = 0; } - int_unlock(lock); - - if (set) { - analog_read(ANA_REG_6A, &val_6a); - analog_read(ANA_REG_6B, &val_6b); - if (vcodec_mv >= 1700) { - analog_read(ANA_REG_74, &val_74); - } else { - val_74 = 0; - } - analog_read(ANA_REG_7E, &val_7e); - if (adda_common_map) { - val_6a |= REG_CODEC_EN_BIAS; - analog_write(ANA_REG_6A, val_6a); - if (vcodec_mv >= 1700) { - val_74 |= REG_PU_TX_REGULATOR; - analog_write(ANA_REG_74, val_74); - hal_sys_timer_delay_us(10); - val_74 &= ~REG_BYPASS_TX_REGULATOR; - analog_write(ANA_REG_74, val_74); - } - val_6b |= REG_CODEC_EN_VCM_BUFFER; - val_7e |= REG_PU_CLKMUX_LDO0P9; - } else { - val_6b &= ~REG_CODEC_EN_VCM_BUFFER; - val_7e &= ~REG_PU_CLKMUX_LDO0P9; - if (vcodec_mv >= 1700) { - val_74 |= REG_BYPASS_TX_REGULATOR; - analog_write(ANA_REG_74, val_74); - val_74 &= ~REG_PU_TX_REGULATOR; - analog_write(ANA_REG_74, val_74); - } - val_6a &= ~REG_CODEC_EN_BIAS; - analog_write(ANA_REG_6A, val_6a); - } - analog_write(ANA_REG_6B, val_6b); - analog_write(ANA_REG_7E, val_7e); + analog_read(ANA_REG_7E, &val_7e); + if (adda_common_map) { + val_6a |= REG_CODEC_EN_BIAS; + analog_write(ANA_REG_6A, val_6a); + if (vcodec_mv >= 1700) { + val_74 |= REG_PU_TX_REGULATOR; + analog_write(ANA_REG_74, val_74); + hal_sys_timer_delay_us(10); + val_74 &= ~REG_BYPASS_TX_REGULATOR; + analog_write(ANA_REG_74, val_74); + } + val_6b |= REG_CODEC_EN_VCM_BUFFER; + val_7e |= REG_PU_CLKMUX_LDO0P9; + } else { + val_6b &= ~REG_CODEC_EN_VCM_BUFFER; + val_7e &= ~REG_PU_CLKMUX_LDO0P9; + if (vcodec_mv >= 1700) { + val_74 |= REG_BYPASS_TX_REGULATOR; + analog_write(ANA_REG_74, val_74); + val_74 &= ~REG_PU_TX_REGULATOR; + analog_write(ANA_REG_74, val_74); + } + val_6a &= ~REG_CODEC_EN_BIAS; + analog_write(ANA_REG_6A, val_6a); } + analog_write(ANA_REG_6B, val_6b); + analog_write(ANA_REG_7E, val_7e); + } } -static void analog_aud_enable_vmic(enum ANA_CODEC_USER_T user, uint32_t dev) -{ - uint32_t lock; - enum ANA_CODEC_USER_T old_map; - bool set = false; - int i; - uint32_t pmu_map = 0; +static void analog_aud_enable_vmic(enum ANA_CODEC_USER_T user, uint32_t dev) { + uint32_t lock; + enum ANA_CODEC_USER_T old_map; + bool set = false; + int i; + uint32_t pmu_map = 0; - lock = int_lock(); + lock = int_lock(); - for (i = 0; i < MAX_ANA_MIC_CH_NUM; i++) { - if (dev & (AUD_VMIC_MAP_VMIC1 << i)) { - if (vmic_map[i] == 0) { - set = true; - } - vmic_map[i] |= user; - } else { - old_map = vmic_map[i]; - vmic_map[i] &= ~user; - if (old_map != 0 && vmic_map[i] == 0) { - set = true; - } - } - - if (vmic_map[i]) { - pmu_map |= (AUD_VMIC_MAP_VMIC1 << i); - } + for (i = 0; i < MAX_ANA_MIC_CH_NUM; i++) { + if (dev & (AUD_VMIC_MAP_VMIC1 << i)) { + if (vmic_map[i] == 0) { + set = true; + } + vmic_map[i] |= user; + } else { + old_map = vmic_map[i]; + vmic_map[i] &= ~user; + if (old_map != 0 && vmic_map[i] == 0) { + set = true; + } } - int_unlock(lock); + if (vmic_map[i]) { + pmu_map |= (AUD_VMIC_MAP_VMIC1 << i); + } + } - if (set) { - pmu_codec_mic_bias_enable(pmu_map); + int_unlock(lock); + + if (set) { + pmu_codec_mic_bias_enable(pmu_map); #ifdef VOICE_DETECTOR_EN - pmu_codec_mic_bias_lowpower_mode(pmu_map); + pmu_codec_mic_bias_lowpower_mode(pmu_map); #endif - if (pmu_map) { - osDelay(1); - } + if (pmu_map) { + osDelay(1); } + } } -uint32_t analog_aud_get_max_dre_gain(void) -{ - if (vcodec_mv >= 1900) { - return 0x11; - } else { - return 0xF; - } +uint32_t analog_aud_get_max_dre_gain(void) { + if (vcodec_mv >= 1900) { + return 0x11; + } else { + return 0xF; + } } -int analog_reset(void) -{ - return 0; -} +int analog_reset(void) { return 0; } -void analog_open(void) -{ - uint16_t val; +void analog_open(void) { + uint16_t val; - val = REG_CODEC_ADCA_CH_SEL(1) | REG_CODEC_ADCB_CH_SEL(1) | REG_CODEC_ADCC_CH_SEL(1) | REG_CODEC_ADCD_CH_SEL(1); - analog_write(ANA_REG_61, val); + val = REG_CODEC_ADCA_CH_SEL(1) | REG_CODEC_ADCB_CH_SEL(1) | + REG_CODEC_ADCC_CH_SEL(1) | REG_CODEC_ADCD_CH_SEL(1); + analog_write(ANA_REG_61, val); - val = CFG_RESET_PGAA_DR | CFG_RESET_PGAB_DR | CFG_RESET_PGAC_DR | CFG_RESET_PGAD_DR; - analog_write(ANA_REG_62, val); + val = CFG_RESET_PGAA_DR | CFG_RESET_PGAB_DR | CFG_RESET_PGAC_DR | + CFG_RESET_PGAD_DR; + analog_write(ANA_REG_62, val); - val = 0; //REG_CODEC_ADCA_GAIN_UPDATE | REG_CODEC_ADCB_GAIN_UPDATE | REG_CODEC_ADCC_GAIN_UPDATE | REG_CODEC_ADCD_GAIN_UPDATE; - analog_write(ANA_REG_63, val); + val = 0; // REG_CODEC_ADCA_GAIN_UPDATE | REG_CODEC_ADCB_GAIN_UPDATE | + // REG_CODEC_ADCC_GAIN_UPDATE | REG_CODEC_ADCD_GAIN_UPDATE; + analog_write(ANA_REG_63, val); - val = REG_CODEC_ADC_IBSEL_REG(8) | REG_CODEC_ADC_IBSEL_VCOMP(8) | REG_CODEC_ADC_IBSEL_VREF(8) | REG_CODEC_ADC_LPFVCM_SW(7); - analog_write(ANA_REG_67, val); + val = REG_CODEC_ADC_IBSEL_REG(8) | REG_CODEC_ADC_IBSEL_VCOMP(8) | + REG_CODEC_ADC_IBSEL_VREF(8) | REG_CODEC_ADC_LPFVCM_SW(7); + analog_write(ANA_REG_67, val); - val = REG_CODEC_ADC_OP1_IBIT(2) | REG_CODEC_ADC_VREF_SEL(4); - analog_write(ANA_REG_68, val); + val = REG_CODEC_ADC_OP1_IBIT(2) | REG_CODEC_ADC_VREF_SEL(4); + analog_write(ANA_REG_68, val); - val = REG_CODEC_BIAS_IBSEL(8) | REG_CODEC_BIAS_IBSEL_VOICE(8); - if (vcodec_mv >= 1900) { - val |= REG_CODEC_BIAS_IBSEL_TX(5); - } else { + val = REG_CODEC_BIAS_IBSEL(8) | REG_CODEC_BIAS_IBSEL_VOICE(8); + if (vcodec_mv >= 1900) { + val |= REG_CODEC_BIAS_IBSEL_TX(5); + } else { #ifdef LOW_CODEC_BIAS - val |= REG_CODEC_BIAS_IBSEL_TX(1); + val |= REG_CODEC_BIAS_IBSEL_TX(1); #else - val |= REG_CODEC_BIAS_IBSEL_TX(3); + val |= REG_CODEC_BIAS_IBSEL_TX(3); #endif - } - analog_write(ANA_REG_69, val); + } + analog_write(ANA_REG_69, val); - val = REG_CODEC_ADC_REG_VSEL(3) | REG_CODEC_BUF_LOWVCM(4) | REG_CODEC_EN_RX_EXT | REG_CODEC_EN_TX_EXT | REG_CODEC_DAC_CLK_EDGE_SEL; - val |= REG_CODEC_EN_BIAS_LP; - analog_write(ANA_REG_6A, val); + val = REG_CODEC_ADC_REG_VSEL(3) | REG_CODEC_BUF_LOWVCM(4) | + REG_CODEC_EN_RX_EXT | REG_CODEC_EN_TX_EXT | REG_CODEC_DAC_CLK_EDGE_SEL; + val |= REG_CODEC_EN_BIAS_LP; + analog_write(ANA_REG_6A, val); - uint16_t vcm, vcm_lpf; - if (vcodec_mv >= 1900) { - vcm = 7; - vcm_lpf = 0xA; - } else if (vcodec_mv >= 1800) { - vcm = vcm_lpf = 7; - } else { - vcm = vcm_lpf = 7; - } - val = REG_CODEC_VCM_LOW_VCM(vcm) | REG_CODEC_VCM_LOW_VCM_LP(vcm) | REG_CODEC_VCM_LOW_VCM_LPF(vcm_lpf); - analog_write(ANA_REG_6B, val); + uint16_t vcm, vcm_lpf; + if (vcodec_mv >= 1900) { + vcm = 7; + vcm_lpf = 0xA; + } else if (vcodec_mv >= 1800) { + vcm = vcm_lpf = 7; + } else { + vcm = vcm_lpf = 7; + } + val = REG_CODEC_VCM_LOW_VCM(vcm) | REG_CODEC_VCM_LOW_VCM_LP(vcm) | + REG_CODEC_VCM_LOW_VCM_LPF(vcm_lpf); + analog_write(ANA_REG_6B, val); - val = REG_CODEC_RX_VTOI_I_DAC2(4) | REG_CODEC_RX_VTOI_IDAC_SEL(8) | REG_CODEC_RX_VTOI_VCS_SEL(0x10); - analog_write(ANA_REG_6C, val); + val = REG_CODEC_RX_VTOI_I_DAC2(4) | REG_CODEC_RX_VTOI_IDAC_SEL(8) | + REG_CODEC_RX_VTOI_VCS_SEL(0x10); + analog_write(ANA_REG_6C, val); - if (vcodec_mv > 1900) { - val = REG_CODEC_TX_DAC_VREF_L(9) | REG_CODEC_TX_DAC_VREF_R(9) | REG_CODEC_TX_EAR_CAS_BIT(3); - } else if (vcodec_mv == 1900) { - val = REG_CODEC_TX_DAC_VREF_L(0xA) | REG_CODEC_TX_DAC_VREF_R(0xA) | REG_CODEC_TX_EAR_CAS_BIT(3); - } else { - val = REG_CODEC_TX_DAC_VREF_L(2) | REG_CODEC_TX_DAC_VREF_R(2) | REG_CODEC_TX_EAR_CAS_BIT(1); - } - analog_write(ANA_REG_6D, val); + if (vcodec_mv > 1900) { + val = REG_CODEC_TX_DAC_VREF_L(9) | REG_CODEC_TX_DAC_VREF_R(9) | + REG_CODEC_TX_EAR_CAS_BIT(3); + } else if (vcodec_mv == 1900) { + val = REG_CODEC_TX_DAC_VREF_L(0xA) | REG_CODEC_TX_DAC_VREF_R(0xA) | + REG_CODEC_TX_EAR_CAS_BIT(3); + } else { + val = REG_CODEC_TX_DAC_VREF_L(2) | REG_CODEC_TX_DAC_VREF_R(2) | + REG_CODEC_TX_EAR_CAS_BIT(1); + } + analog_write(ANA_REG_6D, val); - val = REG_CODEC_TX_EAR_IBSEL(2); + val = REG_CODEC_TX_EAR_IBSEL(2); #ifdef LOW_CODEC_BIAS - if (vcodec_mv < 1900) { - val = REG_CODEC_TX_EAR_IBSEL(0); - } + if (vcodec_mv < 1900) { + val = REG_CODEC_TX_EAR_IBSEL(0); + } #endif - val |= REG_CODEC_TX_EAR_COMP_L(7) | REG_CODEC_TX_EAR_COMP_R(7) | REG_CODEC_TX_EAR_DR_ST(1) | REG_CODEC_TX_EAR_FBCAP(3); - analog_write(ANA_REG_6E, val); + val |= REG_CODEC_TX_EAR_COMP_L(7) | REG_CODEC_TX_EAR_COMP_R(7) | + REG_CODEC_TX_EAR_DR_ST(1) | REG_CODEC_TX_EAR_FBCAP(3); + analog_write(ANA_REG_6E, val); - val = REG_CODEC_TX_EAR_DRE_GAIN_L(0xF) | REG_CODEC_TX_EAR_DRE_GAIN_R(0xF) | DRE_GAIN_SEL_L | DRE_GAIN_SEL_R | REG_CODEC_TX_EAR_GAIN(1); + val = REG_CODEC_TX_EAR_DRE_GAIN_L(0xF) | REG_CODEC_TX_EAR_DRE_GAIN_R(0xF) | + DRE_GAIN_SEL_L | DRE_GAIN_SEL_R | REG_CODEC_TX_EAR_GAIN(1); #ifdef DAC_DRE_GAIN_DC_UPDATE - val |= REG_CODEC_TX_EAR_DRE_GAIN_L_UPDATE | REG_CODEC_TX_EAR_DRE_GAIN_R_UPDATE; + val |= + REG_CODEC_TX_EAR_DRE_GAIN_L_UPDATE | REG_CODEC_TX_EAR_DRE_GAIN_R_UPDATE; #endif - analog_write(ANA_REG_6F, val); + analog_write(ANA_REG_6F, val); - val = REG_CODEC_TX_EAR_OUTPUTSEL(1) | REG_CODEC_TX_EAR_SOFTSTART(8) | REG_CODEC_TX_EAR_OCEN | REG_CODEC_TX_EAR_LPBIAS; - analog_write(ANA_REG_70, val); + val = REG_CODEC_TX_EAR_OUTPUTSEL(1) | REG_CODEC_TX_EAR_SOFTSTART(8) | + REG_CODEC_TX_EAR_OCEN | REG_CODEC_TX_EAR_LPBIAS; + analog_write(ANA_REG_70, val); - val = REG_DAC_LDO0P9_VSEL(2) | REG_BYPASS_TX_REGULATOR | REG_CODEC_TX_EAR_VCM_BIT(3) | REG_CODEC_TX_EAR_VCM_SEL; - if (vcodec_mv >= 1900) { - val |= REG_CODEC_TX_RVREF_CAP_BIT | REG_TX_REGULATOR_BIT(0xD); - } else { - val |= REG_TX_REGULATOR_BIT(4); - } - analog_write(ANA_REG_74, val); + val = REG_DAC_LDO0P9_VSEL(2) | REG_BYPASS_TX_REGULATOR | + REG_CODEC_TX_EAR_VCM_BIT(3) | REG_CODEC_TX_EAR_VCM_SEL; + if (vcodec_mv >= 1900) { + val |= REG_CODEC_TX_RVREF_CAP_BIT | REG_TX_REGULATOR_BIT(0xD); + } else { + val |= REG_TX_REGULATOR_BIT(4); + } + analog_write(ANA_REG_74, val); - val = REG_CLKMUX_DVDD_SEL | REG_CLKMUX_LDO0P9_VSEL(2) | REG_AUDPLL_LDO_VREF(4) | REG_AUDPLL_LPF_BW_SEL; - analog_write(ANA_REG_7E, val); + val = REG_CLKMUX_DVDD_SEL | REG_CLKMUX_LDO0P9_VSEL(2) | + REG_AUDPLL_LDO_VREF(4) | REG_AUDPLL_LPF_BW_SEL; + analog_write(ANA_REG_7E, val); - //Optimize bottom noise, dig_codec_adcE_vref_sel[3:0] should be 0x4 ————by jeff 20200916 - analog_read(ANA_REG_16E, &val); - val = SET_BITFIELD(val, DIG_CODEC_ADCE_VREF_SEL, 0x4); - analog_write(ANA_REG_16E, val); + // Optimize bottom noise, dig_codec_adcE_vref_sel[3:0] should be 0x4 ————by + // jeff 20200916 + analog_read(ANA_REG_16E, &val); + val = SET_BITFIELD(val, DIG_CODEC_ADCE_VREF_SEL, 0x4); + analog_write(ANA_REG_16E, val); #ifdef AUDIO_OUTPUT_DC_CALIB_ANA - analog_aud_dc_calib_init(); - analog_aud_dc_calib_enable(true); + analog_aud_dc_calib_init(); + analog_aud_dc_calib_enable(true); #endif #ifdef VCM_ON - analog_aud_enable_common_internal(ANA_CODEC_USER_DAC, true); + analog_aud_enable_common_internal(ANA_CODEC_USER_DAC, true); #endif } -void analog_sleep(void) -{ +void analog_sleep(void) { #ifdef VOICE_DETECTOR_EN - if ((adda_common_map & ANA_CODEC_USER_VAD) && (adc_map[4] & ANA_CODEC_USER_VAD) == 0) { - uint16_t val; + if ((adda_common_map & ANA_CODEC_USER_VAD) && + (adc_map[4] & ANA_CODEC_USER_VAD) == 0) { + uint16_t val; - analog_read(ANA_REG_6B, &val); - val = (val & ~REG_CODEC_EN_VCM_BUFFER) | REG_CODEC_LP_VCM; - analog_write(ANA_REG_6B, val); - } + analog_read(ANA_REG_6B, &val); + val = (val & ~REG_CODEC_EN_VCM_BUFFER) | REG_CODEC_LP_VCM; + analog_write(ANA_REG_6B, val); + } #endif } -void analog_wakeup(void) -{ +void analog_wakeup(void) { #ifdef VOICE_DETECTOR_EN - if ((adda_common_map & ANA_CODEC_USER_VAD) && (adc_map[4] & ANA_CODEC_USER_VAD) == 0) { - uint16_t val; + if ((adda_common_map & ANA_CODEC_USER_VAD) && + (adc_map[4] & ANA_CODEC_USER_VAD) == 0) { + uint16_t val; - analog_read(ANA_REG_6B, &val); - val = (val & ~REG_CODEC_LP_VCM) | REG_CODEC_EN_VCM_BUFFER; - analog_write(ANA_REG_6B, val); - } + analog_read(ANA_REG_6B, &val); + val = (val & ~REG_CODEC_LP_VCM) | REG_CODEC_EN_VCM_BUFFER; + analog_write(ANA_REG_6B, val); + } #endif } -void analog_aud_codec_anc_enable(enum ANC_TYPE_T type, bool en) -{ - enum ANA_CODEC_USER_T user; - enum AUD_CHANNEL_MAP_T ch_map; +void analog_aud_codec_anc_enable(enum ANC_TYPE_T type, bool en) { + enum ANA_CODEC_USER_T user; + enum AUD_CHANNEL_MAP_T ch_map; - user = 0; - ch_map = 0; + user = 0; + ch_map = 0; #if defined(ANC_FF_MIC_CH_L) || defined(ANC_FF_MIC_CH_R) - if (type & ANC_FEEDFORWARD) { - user |= ANA_CODEC_USER_ANC_FF; - ch_map |= ANC_FF_MIC_CH_L | ANC_FF_MIC_CH_R; - } + if (type & ANC_FEEDFORWARD) { + user |= ANA_CODEC_USER_ANC_FF; + ch_map |= ANC_FF_MIC_CH_L | ANC_FF_MIC_CH_R; + } #endif #if defined(ANC_FB_MIC_CH_L) || defined(ANC_FB_MIC_CH_R) - if (type & ANC_FEEDFORWARD) { - user |= ANA_CODEC_USER_ANC_FB; - ch_map |= ANC_FB_MIC_CH_L | ANC_FB_MIC_CH_R; - } + if (type & ANC_FEEDFORWARD) { + user |= ANA_CODEC_USER_ANC_FB; + ch_map |= ANC_FB_MIC_CH_L | ANC_FB_MIC_CH_R; + } #endif - ANALOG_DEBUG_TRACE(0, "%s: type=%d en=%d ch_map=0x%x", __func__, type, en, ch_map); + ANALOG_DEBUG_TRACE(0, "%s: type=%d en=%d ch_map=0x%x", __func__, type, en, + ch_map); - if (en) { - analog_aud_enable_vmic(user, ANC_VMIC_CFG); - analog_aud_enable_codec_common(user, true); - analog_aud_enable_adda_common(user, true); - analog_aud_set_adc_gain(AUD_INPUT_PATH_MAINMIC, ch_map); - analog_aud_enable_adc(user, ch_map, true); - } else { - analog_aud_apply_anc_adc_gain_offset(type, 0, 0); - analog_aud_enable_adc(user, ch_map, false); - analog_aud_enable_adda_common(user, false); - analog_aud_enable_codec_common(user, false); - analog_aud_enable_vmic(user, 0); - } + if (en) { + analog_aud_enable_vmic(user, ANC_VMIC_CFG); + analog_aud_enable_codec_common(user, true); + analog_aud_enable_adda_common(user, true); + analog_aud_set_adc_gain(AUD_INPUT_PATH_MAINMIC, ch_map); + analog_aud_enable_adc(user, ch_map, true); + } else { + analog_aud_apply_anc_adc_gain_offset(type, 0, 0); + analog_aud_enable_adc(user, ch_map, false); + analog_aud_enable_adda_common(user, false); + analog_aud_enable_codec_common(user, false); + analog_aud_enable_vmic(user, 0); + } } -void analog_aud_codec_anc_boost(bool en, ANALOG_ANC_BOOST_DELAY_FUNC delay_func) -{ - uint16_t val; - int ret; +void analog_aud_codec_anc_boost(bool en, + ANALOG_ANC_BOOST_DELAY_FUNC delay_func) { + uint16_t val; + int ret; - if (vcodec_mv >= 1800) { - return; - } + if (vcodec_mv >= 1800) { + return; + } - if (delay_func == NULL) { - delay_func = (ANALOG_ANC_BOOST_DELAY_FUNC)osDelay; - } + if (delay_func == NULL) { + delay_func = (ANALOG_ANC_BOOST_DELAY_FUNC)osDelay; + } + if (en) { + // -2.1 dB + hal_codec_set_anc_boost_gain_attn(0.78523563f); + delay_func(1); + } + + analog_read(ANA_REG_6B, &val); + val &= ~REG_CODEC_VCM_EN_LPF; + analog_write(ANA_REG_6B, val); + osDelay(1); + + do { if (en) { - // -2.1 dB - hal_codec_set_anc_boost_gain_attn(0.78523563f); - delay_func(1); + ret = pmu_codec_volt_ramp_up(); + } else { + ret = pmu_codec_volt_ramp_down(); } + delay_func(1); + } while (ret); - analog_read(ANA_REG_6B, &val); - val &= ~REG_CODEC_VCM_EN_LPF; - analog_write(ANA_REG_6B, val); + analog_read(ANA_REG_6B, &val); + val |= REG_CODEC_VCM_EN_LPF; + analog_write(ANA_REG_6B, val); + + if (!en) { + delay_func(1); + // 0 dB + hal_codec_set_anc_boost_gain_attn(1.0f); + } +} + +void analog_aud_mickey_enable(bool en) { + if (en) { + analog_aud_vcodec_enable(ANA_CODEC_USER_MICKEY, true); + analog_aud_enable_vmic(ANA_CODEC_USER_MICKEY, CFG_HW_AUD_MICKEY_DEV); + analog_aud_enable_codec_common(ANA_CODEC_USER_MICKEY, true); + } else { + analog_aud_enable_codec_common(ANA_CODEC_USER_MICKEY, false); + analog_aud_enable_vmic(ANA_CODEC_USER_MICKEY, 0); + analog_aud_vcodec_enable(ANA_CODEC_USER_MICKEY, false); + } +} + +void analog_aud_codec_adc_enable(enum AUD_IO_PATH_T input_path, + enum AUD_CHANNEL_MAP_T ch_map, bool en) { + uint32_t dev; + + if (en) { + dev = hal_codec_get_input_path_cfg(input_path); + // Enable vmic first to overlap vmic stable time with codec vcm stable time + analog_aud_enable_vmic(ANA_CODEC_USER_ADC, dev); + analog_aud_enable_codec_common(ANA_CODEC_USER_ADC, true); + analog_aud_enable_adda_common(ANA_CODEC_USER_ADC, true); + analog_aud_set_adc_gain(input_path, ch_map); + analog_aud_enable_adc(ANA_CODEC_USER_ADC, ch_map, true); + } else { + analog_aud_enable_adc(ANA_CODEC_USER_ADC, ch_map, false); + analog_aud_enable_adda_common(ANA_CODEC_USER_ADC, false); + analog_aud_enable_codec_common(ANA_CODEC_USER_ADC, false); + analog_aud_enable_vmic(ANA_CODEC_USER_ADC, 0); + } +} + +static void analog_aud_codec_config_speaker(void) { + bool en; + + if (ana_spk_req && !ana_spk_muted) { + en = true; + } else { + en = false; + } + + if (ana_spk_enabled != en) { + ana_spk_enabled = en; + if (en) { + analog_aud_enable_dac_pa(CFG_HW_AUD_OUTPUT_PATH_SPEAKER_DEV); + } else { + analog_aud_enable_dac_pa(0); + } + } +} + +void analog_aud_codec_speaker_enable(bool en) { + ana_spk_req = en; + analog_aud_codec_config_speaker(); +} + +void analog_aud_codec_dac_enable(bool en) { + if (en) { + analog_aud_enable_codec_common(ANA_CODEC_USER_DAC, true); + analog_aud_enable_adda_common(ANA_CODEC_USER_DAC, true); + pmu_codec_hppa_enable(1); + analog_aud_enable_dac(CFG_HW_AUD_OUTPUT_PATH_SPEAKER_DEV); +#if !defined(AUDIO_OUTPUT_DC_CALIB_ANA) && !defined(AUDIO_OUTPUT_DC_CALIB) osDelay(1); - - do { - if (en) { - ret = pmu_codec_volt_ramp_up(); - } else { - ret = pmu_codec_volt_ramp_down(); - } - delay_func(1); - } while (ret); - - analog_read(ANA_REG_6B, &val); - val |= REG_CODEC_VCM_EN_LPF; - analog_write(ANA_REG_6B, val); - - if (!en) { - delay_func(1); - // 0 dB - hal_codec_set_anc_boost_gain_attn(1.0f); - } -} - -void analog_aud_mickey_enable(bool en) -{ - if (en) { - analog_aud_vcodec_enable(ANA_CODEC_USER_MICKEY, true); - analog_aud_enable_vmic(ANA_CODEC_USER_MICKEY, CFG_HW_AUD_MICKEY_DEV); - analog_aud_enable_codec_common(ANA_CODEC_USER_MICKEY, true); - } else { - analog_aud_enable_codec_common(ANA_CODEC_USER_MICKEY, false); - analog_aud_enable_vmic(ANA_CODEC_USER_MICKEY, 0); - analog_aud_vcodec_enable(ANA_CODEC_USER_MICKEY, false); - } -} - -void analog_aud_codec_adc_enable(enum AUD_IO_PATH_T input_path, enum AUD_CHANNEL_MAP_T ch_map, bool en) -{ - uint32_t dev; - - if (en) { - dev = hal_codec_get_input_path_cfg(input_path); - // Enable vmic first to overlap vmic stable time with codec vcm stable time - analog_aud_enable_vmic(ANA_CODEC_USER_ADC, dev); - analog_aud_enable_codec_common(ANA_CODEC_USER_ADC, true); - analog_aud_enable_adda_common(ANA_CODEC_USER_ADC, true); - analog_aud_set_adc_gain(input_path, ch_map); - analog_aud_enable_adc(ANA_CODEC_USER_ADC, ch_map, true); - } else { - analog_aud_enable_adc(ANA_CODEC_USER_ADC, ch_map, false); - analog_aud_enable_adda_common(ANA_CODEC_USER_ADC, false); - analog_aud_enable_codec_common(ANA_CODEC_USER_ADC, false); - analog_aud_enable_vmic(ANA_CODEC_USER_ADC, 0); - } -} - -static void analog_aud_codec_config_speaker(void) -{ - bool en; - - if (ana_spk_req && !ana_spk_muted) { - en = true; - } else { - en = false; - } - - if (ana_spk_enabled != en) { - ana_spk_enabled = en; - if (en) { - analog_aud_enable_dac_pa(CFG_HW_AUD_OUTPUT_PATH_SPEAKER_DEV); - } else { - analog_aud_enable_dac_pa(0); - } - } -} - -void analog_aud_codec_speaker_enable(bool en) -{ - ana_spk_req = en; - analog_aud_codec_config_speaker(); -} - -void analog_aud_codec_dac_enable(bool en) -{ - if (en) { - analog_aud_enable_codec_common(ANA_CODEC_USER_DAC, true); - analog_aud_enable_adda_common(ANA_CODEC_USER_DAC, true); - pmu_codec_hppa_enable(1); - analog_aud_enable_dac(CFG_HW_AUD_OUTPUT_PATH_SPEAKER_DEV); + analog_aud_codec_speaker_enable(true); +#endif + } else { #if !defined(AUDIO_OUTPUT_DC_CALIB_ANA) && !defined(AUDIO_OUTPUT_DC_CALIB) - osDelay(1); - analog_aud_codec_speaker_enable(true); -#endif - } else { -#if !defined(AUDIO_OUTPUT_DC_CALIB_ANA) && !defined(AUDIO_OUTPUT_DC_CALIB) - analog_aud_codec_speaker_enable(false); - osDelay(1); -#endif - analog_aud_enable_dac(0); - pmu_codec_hppa_enable(0); - analog_aud_enable_adda_common(ANA_CODEC_USER_DAC, false); - analog_aud_enable_codec_common(ANA_CODEC_USER_DAC, false); - } -} - -void analog_aud_codec_open(void) -{ - analog_aud_vcodec_enable(ANA_CODEC_USER_CODEC, true); - -#ifdef _AUTO_SWITCH_POWER_MODE__ - //pmu_mode_change(PMU_POWER_MODE_DIG_DCDC); -#endif -} - -void analog_aud_codec_close(void) -{ - static const enum AUD_CHANNEL_MAP_T all_ch = AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1 | - AUD_CHANNEL_MAP_CH2 | AUD_CHANNEL_MAP_CH3 | AUD_CHANNEL_MAP_CH4; - analog_aud_codec_speaker_enable(false); osDelay(1); - analog_aud_codec_dac_enable(false); +#endif + analog_aud_enable_dac(0); + pmu_codec_hppa_enable(0); + analog_aud_enable_adda_common(ANA_CODEC_USER_DAC, false); + analog_aud_enable_codec_common(ANA_CODEC_USER_DAC, false); + } +} - analog_aud_codec_adc_enable(AUD_IO_PATH_NULL, all_ch, false); +void analog_aud_codec_open(void) { + analog_aud_vcodec_enable(ANA_CODEC_USER_CODEC, true); #ifdef _AUTO_SWITCH_POWER_MODE__ - //pmu_mode_change(PMU_POWER_MODE_ANA_DCDC); + // pmu_mode_change(PMU_POWER_MODE_DIG_DCDC); #endif - - analog_aud_vcodec_enable(ANA_CODEC_USER_CODEC, false); } -void analog_aud_codec_mute(void) -{ +void analog_aud_codec_close(void) { + static const enum AUD_CHANNEL_MAP_T all_ch = + AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1 | AUD_CHANNEL_MAP_CH2 | + AUD_CHANNEL_MAP_CH3 | AUD_CHANNEL_MAP_CH4; + + analog_aud_codec_speaker_enable(false); + osDelay(1); + analog_aud_codec_dac_enable(false); + + analog_aud_codec_adc_enable(AUD_IO_PATH_NULL, all_ch, false); + +#ifdef _AUTO_SWITCH_POWER_MODE__ + // pmu_mode_change(PMU_POWER_MODE_ANA_DCDC); +#endif + + analog_aud_vcodec_enable(ANA_CODEC_USER_CODEC, false); +} + +void analog_aud_codec_mute(void) { #ifndef AUDIO_OUTPUT_DC_CALIB - //analog_codec_tx_pa_gain_sel(0); + // analog_codec_tx_pa_gain_sel(0); #endif - ana_spk_muted = true; - analog_aud_codec_config_speaker(); + ana_spk_muted = true; + analog_aud_codec_config_speaker(); } -void analog_aud_codec_nomute(void) -{ - ana_spk_muted = false; - analog_aud_codec_config_speaker(); +void analog_aud_codec_nomute(void) { + ana_spk_muted = false; + analog_aud_codec_config_speaker(); #ifndef AUDIO_OUTPUT_DC_CALIB - //analog_aud_set_dac_gain(dac_gain); + // analog_aud_set_dac_gain(dac_gain); #endif } -int analog_debug_config_audio_output(bool diff) -{ - return 0; -} +int analog_debug_config_audio_output(bool diff) { return 0; } -int analog_debug_config_codec(uint16_t mv) -{ +int analog_debug_config_codec(uint16_t mv) { #ifdef ANC_PROD_TEST - int ret; + int ret; - ret = pmu_debug_config_codec(mv); - if (ret) { - return ret; - } + ret = pmu_debug_config_codec(mv); + if (ret) { + return ret; + } - vcodec_mv = mv; + vcodec_mv = mv; #endif - return 0; + return 0; } -int analog_debug_config_low_power_adc(bool enable) -{ - return 0; +int analog_debug_config_low_power_adc(bool enable) { return 0; } + +void analog_debug_config_anc_calib_mode(bool enable) { + anc_calib_mode = enable; } -void analog_debug_config_anc_calib_mode(bool enable) -{ - anc_calib_mode = enable; -} - -bool analog_debug_get_anc_calib_mode(void) -{ - return anc_calib_mode; -} - -int analog_debug_config_vad_mic(bool enable) -{ - return 0; -} +bool analog_debug_get_anc_calib_mode(void) { return anc_calib_mode; } +int analog_debug_config_vad_mic(bool enable) { return 0; } #ifdef VOICE_DETECTOR_EN -static void analog_aud_codec_vad_ini(void) -{ +static void analog_aud_codec_vad_ini(void) { #if 1 - unsigned short v; + unsigned short v; #if 0 //0x6a,0x0503 @@ -2155,141 +2189,130 @@ static void analog_aud_codec_vad_ini(void) analog_write(ANA_REG_74, v); #endif - //0x173, 0x0805 - v = REG_VOICE_LDO_VBIT(5) - | CFG_VOICE_DET_DELAY(8); - analog_write(ANA_REG_173, v); + // 0x173, 0x0805 + v = REG_VOICE_LDO_VBIT(5) | CFG_VOICE_DET_DELAY(8); + analog_write(ANA_REG_173, v); - //0x17d,0x817f - v = REG_CLK_GOAL_DIV_NUM(0x17f) - | REG_COARSE_TUN_CODE_DR; - analog_write(ANA_REG_17D, v); + // 0x17d,0x817f + v = REG_CLK_GOAL_DIV_NUM(0x17f) | REG_COARSE_TUN_CODE_DR; + analog_write(ANA_REG_17D, v); #if 1 - //0x171,0x1047 - v = CFG_VOICE_RESET - | CFG_VOICE_PU_DELAY(4) - | CFG_VOICE_PRECH_DELAY(0x7f); - analog_write(ANA_REG_171, v); + // 0x171,0x1047 + v = CFG_VOICE_RESET | CFG_VOICE_PU_DELAY(4) | CFG_VOICE_PRECH_DELAY(0x7f); + analog_write(ANA_REG_171, v); #endif - //0x17a - analog_read(ANA_REG_17A, &v); - v = SET_BITFIELD(v, REG_VOICE_LOW_TUNE, 0x3); - analog_write(ANA_REG_17A, v); + // 0x17a + analog_read(ANA_REG_17A, &v); + v = SET_BITFIELD(v, REG_VOICE_LOW_TUNE, 0x3); + analog_write(ANA_REG_17A, v); + // 0x161[15] = 1; //cfg_reg_clkmux_dvdd_sel + analog_read(ANA_REG_161, &v); + v |= 1 << 15; + analog_write(ANA_REG_161, v); - //0x161[15] = 1; //cfg_reg_clkmux_dvdd_sel - analog_read(ANA_REG_161, &v); - v |= 1 << 15; - analog_write(ANA_REG_161, v); + // 0x170[15] = 1; //cfg_voice2adcE + analog_read(ANA_REG_170, &v); + v = SET_BITFIELD(v, REG_VOICE_GAIN_A, 0x3); + v = SET_BITFIELD(v, REG_VOICE_GAIN_B, 0x3); + v = SET_BITFIELD(v, REG_VOICE_HIGH_TUNE_A, 0xa); + v = SET_BITFIELD(v, REG_VOICE_HIGH_TUNE_B, 0x4); + v |= CFG_VOICE2ADCE; + analog_write(ANA_REG_170, v); - //0x170[15] = 1; //cfg_voice2adcE - analog_read(ANA_REG_170, &v); - v = SET_BITFIELD(v, REG_VOICE_GAIN_A, 0x3); - v = SET_BITFIELD(v, REG_VOICE_GAIN_B, 0x3); - v = SET_BITFIELD(v, REG_VOICE_HIGH_TUNE_A, 0xa); - v = SET_BITFIELD(v, REG_VOICE_HIGH_TUNE_B, 0x4); - v |= CFG_VOICE2ADCE; - analog_write(ANA_REG_170, v); - - osDelay(1); + osDelay(1); #endif } -static void analog_aud_codec_vad_fin(void) -{ - unsigned short v; +static void analog_aud_codec_vad_fin(void) { + unsigned short v; - analog_read(ANA_REG_170, &v); - v &= ~CFG_VOICE2ADCE; - analog_write(ANA_REG_170, v); + analog_read(ANA_REG_170, &v); + v &= ~CFG_VOICE2ADCE; + analog_write(ANA_REG_170, v); } -static void analog_aud_codec_vad_trig_en(bool en) -{ +static void analog_aud_codec_vad_trig_en(bool en) { #if 1 - unsigned short v; - uint32_t lock; + unsigned short v; + uint32_t lock; - lock = int_lock(); - analog_read(ANA_REG_171, &v); - if (en) - v |= CFG_VOICE_TRIG_ENABLE; - else - v &= ~CFG_VOICE_TRIG_ENABLE; + lock = int_lock(); + analog_read(ANA_REG_171, &v); + if (en) + v |= CFG_VOICE_TRIG_ENABLE; + else + v &= ~CFG_VOICE_TRIG_ENABLE; - analog_write(ANA_REG_171, v); + analog_write(ANA_REG_171, v); - int_unlock(lock); + int_unlock(lock); #endif } -static void analog_aud_codec_vad_pu(bool en) -{ +static void analog_aud_codec_vad_pu(bool en) { #if 1 - unsigned short v; - uint32_t lock; + unsigned short v; + uint32_t lock; - lock = int_lock(); - analog_read(ANA_REG_171, &v); - if (en) - v |= CFG_VOICE_POWER_ON; - else - v &= ~CFG_VOICE_POWER_ON; + lock = int_lock(); + analog_read(ANA_REG_171, &v); + if (en) + v |= CFG_VOICE_POWER_ON; + else + v &= ~CFG_VOICE_POWER_ON; - analog_write(ANA_REG_171, v); - int_unlock(lock); + analog_write(ANA_REG_171, v); + int_unlock(lock); #endif } -void analog_aud_vad_enable(enum AUD_VAD_TYPE_T type, bool en) -{ - if (type == AUD_VAD_TYPE_DIG) { - uint32_t dev; - enum AUD_CHANNEL_MAP_T ch_map; - - dev = hal_codec_get_input_path_cfg(AUD_INPUT_PATH_VADMIC); - ch_map = dev & AUD_CHANNEL_MAP_ANA_ALL; - analog_aud_enable_adc(ANA_CODEC_USER_VAD, ch_map, en); - } else if (type == AUD_VAD_TYPE_MIX || type == AUD_VAD_TYPE_ANA) { - if (en) { - analog_aud_codec_vad_ini(); - analog_aud_codec_vad_pu(true); - osDelay(1); - analog_aud_codec_vad_trig_en(true); - //pmu_codec_vad_save_power(); - } else { - //pmu_codec_vad_restore_power(); - // Must power off before disabling trigger - analog_aud_codec_vad_pu(false); - osDelay(1); - analog_aud_codec_vad_trig_en(false); - analog_aud_codec_vad_fin(); - } - } -} - -void analog_aud_vad_adc_enable(bool en) -{ +void analog_aud_vad_enable(enum AUD_VAD_TYPE_T type, bool en) { + if (type == AUD_VAD_TYPE_DIG) { uint32_t dev; enum AUD_CHANNEL_MAP_T ch_map; dev = hal_codec_get_input_path_cfg(AUD_INPUT_PATH_VADMIC); ch_map = dev & AUD_CHANNEL_MAP_ANA_ALL; - + analog_aud_enable_adc(ANA_CODEC_USER_VAD, ch_map, en); + } else if (type == AUD_VAD_TYPE_MIX || type == AUD_VAD_TYPE_ANA) { if (en) { - // Enable vmic first to overlap vmic stable time with codec vcm stable time - analog_aud_enable_vmic(ANA_CODEC_USER_VAD, dev); - analog_aud_enable_codec_common(ANA_CODEC_USER_VAD, true); - analog_aud_enable_adda_common(ANA_CODEC_USER_VAD, true); - analog_aud_set_adc_gain(AUD_INPUT_PATH_VADMIC, ch_map); + analog_aud_codec_vad_ini(); + analog_aud_codec_vad_pu(true); + osDelay(1); + analog_aud_codec_vad_trig_en(true); + // pmu_codec_vad_save_power(); } else { - analog_aud_enable_adda_common(ANA_CODEC_USER_VAD, false); - analog_aud_enable_codec_common(ANA_CODEC_USER_VAD, false); - analog_aud_enable_vmic(ANA_CODEC_USER_VAD, 0); + // pmu_codec_vad_restore_power(); + // Must power off before disabling trigger + analog_aud_codec_vad_pu(false); + osDelay(1); + analog_aud_codec_vad_trig_en(false); + analog_aud_codec_vad_fin(); } + } +} + +void analog_aud_vad_adc_enable(bool en) { + uint32_t dev; + enum AUD_CHANNEL_MAP_T ch_map; + + dev = hal_codec_get_input_path_cfg(AUD_INPUT_PATH_VADMIC); + ch_map = dev & AUD_CHANNEL_MAP_ANA_ALL; + + if (en) { + // Enable vmic first to overlap vmic stable time with codec vcm stable time + analog_aud_enable_vmic(ANA_CODEC_USER_VAD, dev); + analog_aud_enable_codec_common(ANA_CODEC_USER_VAD, true); + analog_aud_enable_adda_common(ANA_CODEC_USER_VAD, true); + analog_aud_set_adc_gain(AUD_INPUT_PATH_VADMIC, ch_map); + } else { + analog_aud_enable_adda_common(ANA_CODEC_USER_VAD, false); + analog_aud_enable_codec_common(ANA_CODEC_USER_VAD, false); + analog_aud_enable_vmic(ANA_CODEC_USER_VAD, 0); + } } #endif - diff --git a/platform/drivers/ana/best2300p/pmu_best2300p.c b/platform/drivers/ana/best2300p/pmu_best2300p.c index f4bedd3..01d4b70 100644 --- a/platform/drivers/ana/best2300p/pmu_best2300p.c +++ b/platform/drivers/ana/best2300p/pmu_best2300p.c @@ -13,7 +13,6 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "pmu.h" #include "analog.h" #include "cmsis.h" #include "cmsis_nvic.h" @@ -22,1142 +21,1150 @@ #include "hal_chipid.h" #include "hal_cmu.h" #include "hal_location.h" +#include "hal_psc.h" +#include "hal_sysfreq.h" #include "hal_timer.h" #include "hal_trace.h" -#include "hal_sysfreq.h" +#include "pmu.h" #include "tgt_hardware.h" #include "usbphy.h" -#include "hal_psc.h" #define PMU_LED_VIA_PWM #define DCDC_ULP_LP_ON // LDO soft start interval is about 1000 us -#define PMU_LDO_PU_STABLE_TIME_US 1800 -#define PMU_DCDC_PU_STABLE_TIME_US 100 -#define PMU_VANA_STABLE_TIME_US 10 -#define PMU_VCORE_STABLE_TIME_US 10 +#define PMU_LDO_PU_STABLE_TIME_US 1800 +#define PMU_DCDC_PU_STABLE_TIME_US 100 +#define PMU_VANA_STABLE_TIME_US 10 +#define PMU_VCORE_STABLE_TIME_US 10 #ifdef __PMU_VIO_DYNAMIC_CTRL_MODE__ -#define IO_VOLT_ACTIVE_NORMAL PMU_IO_2_6V +#define IO_VOLT_ACTIVE_NORMAL PMU_IO_2_6V #else -#define IO_VOLT_ACTIVE_NORMAL PMU_IO_2_6V +#define IO_VOLT_ACTIVE_NORMAL PMU_IO_2_6V #endif #ifdef DIGMIC_HIGH_VOLT -#define IO_VOLT_ACTIVE_RISE PMU_IO_3_0V +#define IO_VOLT_ACTIVE_RISE PMU_IO_3_0V #else -#define IO_VOLT_ACTIVE_RISE PMU_IO_2_8V +#define IO_VOLT_ACTIVE_RISE PMU_IO_2_8V #endif -#define IO_VOLT_SLEEP PMU_IO_2_6V +#define IO_VOLT_SLEEP PMU_IO_2_6V -#define HPPA_RAMP_UP_VOLT_MV 1950 +#define HPPA_RAMP_UP_VOLT_MV 1950 -#define PMU_DCDC_ANA_2_1V 0xF0 -#define PMU_DCDC_ANA_2_0V 0xE0 -#define PMU_DCDC_ANA_1_9V 0xD0 -#define PMU_DCDC_ANA_1_8V 0xC0 -#define PMU_DCDC_ANA_1_7V 0xB0 -#define PMU_DCDC_ANA_1_6V 0xA0 -#define PMU_DCDC_ANA_1_5V 0x90 -#define PMU_DCDC_ANA_1_4V 0x80 -#define PMU_DCDC_ANA_1_35V 0x77 -#define PMU_DCDC_ANA_1_3V 0x70 -#define PMU_DCDC_ANA_1_2V 0x60 -#define PMU_DCDC_ANA_1_1V 0x50 -#define PMU_DCDC_ANA_1_0V 0x40 +#define PMU_DCDC_ANA_2_1V 0xF0 +#define PMU_DCDC_ANA_2_0V 0xE0 +#define PMU_DCDC_ANA_1_9V 0xD0 +#define PMU_DCDC_ANA_1_8V 0xC0 +#define PMU_DCDC_ANA_1_7V 0xB0 +#define PMU_DCDC_ANA_1_6V 0xA0 +#define PMU_DCDC_ANA_1_5V 0x90 +#define PMU_DCDC_ANA_1_4V 0x80 +#define PMU_DCDC_ANA_1_35V 0x77 +#define PMU_DCDC_ANA_1_3V 0x70 +#define PMU_DCDC_ANA_1_2V 0x60 +#define PMU_DCDC_ANA_1_1V 0x50 +#define PMU_DCDC_ANA_1_0V 0x40 -#define PMU_DCDC_ANA_SLEEP_1_3V PMU_DCDC_ANA_1_3V -#define PMU_DCDC_ANA_SLEEP_1_2V PMU_DCDC_ANA_1_2V -#define PMU_DCDC_ANA_SLEEP_1_1V PMU_DCDC_ANA_1_1V -#define PMU_DCDC_ANA_SLEEP_1_0V PMU_DCDC_ANA_1_0V +#define PMU_DCDC_ANA_SLEEP_1_3V PMU_DCDC_ANA_1_3V +#define PMU_DCDC_ANA_SLEEP_1_2V PMU_DCDC_ANA_1_2V +#define PMU_DCDC_ANA_SLEEP_1_1V PMU_DCDC_ANA_1_1V +#define PMU_DCDC_ANA_SLEEP_1_0V PMU_DCDC_ANA_1_0V -#define PMU_VBUCK2ANA_1_5V 0x30 -#define PMU_VBUCK2ANA_1_4V 0x2C -#define PMU_VBUCK2ANA_1_3V 0x28 -#define PMU_VBUCK2ANA_1_2V 0x24 -#define PMU_VBUCK2ANA_1_1V 0x20 -#define PMU_VBUCK2ANA_1_0V 0x1C +#define PMU_VBUCK2ANA_1_5V 0x30 +#define PMU_VBUCK2ANA_1_4V 0x2C +#define PMU_VBUCK2ANA_1_3V 0x28 +#define PMU_VBUCK2ANA_1_2V 0x24 +#define PMU_VBUCK2ANA_1_1V 0x20 +#define PMU_VBUCK2ANA_1_0V 0x1C -#define PMU_DCDC_DIG_1_1V 0xFF -#define PMU_DCDC_DIG_1_05V 0xF0 -#define PMU_DCDC_DIG_1_0V 0xE0 -#define PMU_DCDC_DIG_0_95V 0xD0 -#define PMU_DCDC_DIG_0_9V 0xC0 -#define PMU_DCDC_DIG_0_85V 0xB0 -#define PMU_DCDC_DIG_0_8V 0xA0 -#define PMU_DCDC_DIG_0_75V 0x90 -#define PMU_DCDC_DIG_0_7V 0x80 -#define PMU_DCDC_DIG_0_65V 0x70 -#define PMU_DCDC_DIG_0_6V 0x60 -#define PMU_DCDC_DIG_0_55V 0x50 -#define PMU_DCDC_DIG_0_5V 0x40 -#define PMU_DCDC_DIG_0_45V 0x30 -#define PMU_DCDC_DIG_0_4V 0x20 +#define PMU_DCDC_DIG_1_1V 0xFF +#define PMU_DCDC_DIG_1_05V 0xF0 +#define PMU_DCDC_DIG_1_0V 0xE0 +#define PMU_DCDC_DIG_0_95V 0xD0 +#define PMU_DCDC_DIG_0_9V 0xC0 +#define PMU_DCDC_DIG_0_85V 0xB0 +#define PMU_DCDC_DIG_0_8V 0xA0 +#define PMU_DCDC_DIG_0_75V 0x90 +#define PMU_DCDC_DIG_0_7V 0x80 +#define PMU_DCDC_DIG_0_65V 0x70 +#define PMU_DCDC_DIG_0_6V 0x60 +#define PMU_DCDC_DIG_0_55V 0x50 +#define PMU_DCDC_DIG_0_5V 0x40 +#define PMU_DCDC_DIG_0_45V 0x30 +#define PMU_DCDC_DIG_0_4V 0x20 -#define PMU_VDIG_1_2V 0x24 -#define PMU_VDIG_1_1V 0x20 -#define PMU_VDIG_1_05V 0x1E -#define PMU_VDIG_1_0V 0x1C -#define PMU_VDIG_0_95V 0x1A -#define PMU_VDIG_0_9V 0x18 -#define PMU_VDIG_0_85V 0x16 -#define PMU_VDIG_0_8V 0x14 -#define PMU_VDIG_0_75V 0x12 -#define PMU_VDIG_0_7V 0x10 -#define PMU_VDIG_0_65V 0x0E -#define PMU_VDIG_0_6V 0x0C -#define PMU_VDIG_0_55V 0x0A -#define PMU_VDIG_0_5V 0x08 -#define PMU_VDIG_0_45V 0x06 -#define PMU_VDIG_0_4V 0x04 -#define PMU_VDIG_MAX PMU_VDIG_1_2V +#define PMU_VDIG_1_2V 0x24 +#define PMU_VDIG_1_1V 0x20 +#define PMU_VDIG_1_05V 0x1E +#define PMU_VDIG_1_0V 0x1C +#define PMU_VDIG_0_95V 0x1A +#define PMU_VDIG_0_9V 0x18 +#define PMU_VDIG_0_85V 0x16 +#define PMU_VDIG_0_8V 0x14 +#define PMU_VDIG_0_75V 0x12 +#define PMU_VDIG_0_7V 0x10 +#define PMU_VDIG_0_65V 0x0E +#define PMU_VDIG_0_6V 0x0C +#define PMU_VDIG_0_55V 0x0A +#define PMU_VDIG_0_5V 0x08 +#define PMU_VDIG_0_45V 0x06 +#define PMU_VDIG_0_4V 0x04 +#define PMU_VDIG_MAX PMU_VDIG_1_2V -#define PMU_IO_3_3V 0x15 -#define PMU_IO_3_2V 0x14 -#define PMU_IO_3_1V 0x13 -#define PMU_IO_3_0V 0x12 -#define PMU_IO_2_9V 0x11 -#define PMU_IO_2_8V 0x10 -#define PMU_IO_2_7V 0xF -#define PMU_IO_2_6V 0xE -#define PMU_IO_2_5V 0xD -#define PMU_IO_2_4V 0xC -#define PMU_IO_2_3V 0xB -#define PMU_IO_2_2V 0xA -#define PMU_IO_2_1V 0x9 -#define PMU_IO_2_0V 0x8 -#define PMU_IO_1_9V 0x7 -#define PMU_IO_1_8V 0x6 -#define PMU_IO_1_7V 0x5 +#define PMU_IO_3_3V 0x15 +#define PMU_IO_3_2V 0x14 +#define PMU_IO_3_1V 0x13 +#define PMU_IO_3_0V 0x12 +#define PMU_IO_2_9V 0x11 +#define PMU_IO_2_8V 0x10 +#define PMU_IO_2_7V 0xF +#define PMU_IO_2_6V 0xE +#define PMU_IO_2_5V 0xD +#define PMU_IO_2_4V 0xC +#define PMU_IO_2_3V 0xB +#define PMU_IO_2_2V 0xA +#define PMU_IO_2_1V 0x9 +#define PMU_IO_2_0V 0x8 +#define PMU_IO_1_9V 0x7 +#define PMU_IO_1_8V 0x6 +#define PMU_IO_1_7V 0x5 -#define PMU_VMEM_2_8V 0x10 -#define PMU_VMEM_2_0V 0x8 -#define PMU_VMEM_1_9V 0x7 -#define PMU_VMEM_1_8V 0x6 -#define PMU_VMEM_1_7V 0x5 -#define PMU_VMEM_1_6V 0x4 +#define PMU_VMEM_2_8V 0x10 +#define PMU_VMEM_2_0V 0x8 +#define PMU_VMEM_1_9V 0x7 +#define PMU_VMEM_1_8V 0x6 +#define PMU_VMEM_1_7V 0x5 +#define PMU_VMEM_1_6V 0x4 -#define PMU_CODEC_2_7V 0xF -#define PMU_CODEC_2_6V 0xE -#define PMU_CODEC_2_5V 0xD -#define PMU_CODEC_2_4V 0xC -#define PMU_CODEC_2_3V 0xB -#define PMU_CODEC_2_2V 0xA -#define PMU_CODEC_2_1V 0x9 -#define PMU_CODEC_2_0V 0x8 -#define PMU_CODEC_1_9V 0x7 -#define PMU_CODEC_1_8V 0x6 -#define PMU_CODEC_1_7V 0x5 -#define PMU_CODEC_1_6V 0x4 -#define PMU_CODEC_1_5V 0x3 +#define PMU_CODEC_2_7V 0xF +#define PMU_CODEC_2_6V 0xE +#define PMU_CODEC_2_5V 0xD +#define PMU_CODEC_2_4V 0xC +#define PMU_CODEC_2_3V 0xB +#define PMU_CODEC_2_2V 0xA +#define PMU_CODEC_2_1V 0x9 +#define PMU_CODEC_2_0V 0x8 +#define PMU_CODEC_1_9V 0x7 +#define PMU_CODEC_1_8V 0x6 +#define PMU_CODEC_1_7V 0x5 +#define PMU_CODEC_1_6V 0x4 +#define PMU_CODEC_1_5V 0x3 -#define PMU_HPPA2CODEC_2_3V 0x1C -#define PMU_HPPA2CODEC_2_2V 0x18 -#define PMU_HPPA2CODEC_2_1V 0x14 -#define PMU_HPPA2CODEC_2_0V 0x10 -#define PMU_HPPA2CODEC_1_95V 0xE -#define PMU_HPPA2CODEC_1_9V 0xC -#define PMU_HPPA2CODEC_1_8V 0x8 -#define PMU_HPPA2CODEC_1_7V 0x4 -#define PMU_HPPA2CODEC_1_6V 0x0 +#define PMU_HPPA2CODEC_2_3V 0x1C +#define PMU_HPPA2CODEC_2_2V 0x18 +#define PMU_HPPA2CODEC_2_1V 0x14 +#define PMU_HPPA2CODEC_2_0V 0x10 +#define PMU_HPPA2CODEC_1_95V 0xE +#define PMU_HPPA2CODEC_1_9V 0xC +#define PMU_HPPA2CODEC_1_8V 0x8 +#define PMU_HPPA2CODEC_1_7V 0x4 +#define PMU_HPPA2CODEC_1_6V 0x0 -#define PMU_USB_3_4V 0xA -#define PMU_USB_3_3V 0x9 -#define PMU_USB_3_2V 0x8 -#define PMU_USB_3_1V 0x7 -#define PMU_USB_3_0V 0x6 -#define PMU_USB_2_9V 0x5 -#define PMU_USB_2_8V 0x4 -#define PMU_USB_2_7V 0x3 -#define PMU_USB_2_6V 0x2 +#define PMU_USB_3_4V 0xA +#define PMU_USB_3_3V 0x9 +#define PMU_USB_3_2V 0x8 +#define PMU_USB_3_1V 0x7 +#define PMU_USB_3_0V 0x6 +#define PMU_USB_2_9V 0x5 +#define PMU_USB_2_8V 0x4 +#define PMU_USB_2_7V 0x3 +#define PMU_USB_2_6V 0x2 -#define PMU_VHPPA_2_0V 0x8 -#define PMU_VHPPA_1_9V 0x7 -#define PMU_VHPPA_1_8V 0x6 -#define PMU_VHPPA_1_7V 0x5 -#define PMU_VHPPA_1_6V 0x4 -#define PMU_VHPPA_1_5V 0x3 +#define PMU_VHPPA_2_0V 0x8 +#define PMU_VHPPA_1_9V 0x7 +#define PMU_VHPPA_1_8V 0x6 +#define PMU_VHPPA_1_7V 0x5 +#define PMU_VHPPA_1_6V 0x4 +#define PMU_VHPPA_1_5V 0x3 -#define PMU_DCDC_HPPA_2_1V 0xF0 -#define PMU_DCDC_HPPA_2_0V 0xE0 -#define PMU_DCDC_HPPA_1_95V 0xD8 -#define PMU_DCDC_HPPA_1_9V 0xD0 -#define PMU_DCDC_HPPA_1_8V 0xC0 -#define PMU_DCDC_HPPA_1_7V 0xB0 -#define PMU_DCDC_HPPA_1_6V 0xA0 -#define PMU_DCDC_HPPA_1_5V 0x90 -#define PMU_DCDC_HPPA_1_4V 0x80 -#define PMU_DCDC_HPPA_1_3V 0x70 -#define PMU_DCDC_HPPA_1_2V 0x60 +#define PMU_DCDC_HPPA_2_1V 0xF0 +#define PMU_DCDC_HPPA_2_0V 0xE0 +#define PMU_DCDC_HPPA_1_95V 0xD8 +#define PMU_DCDC_HPPA_1_9V 0xD0 +#define PMU_DCDC_HPPA_1_8V 0xC0 +#define PMU_DCDC_HPPA_1_7V 0xB0 +#define PMU_DCDC_HPPA_1_6V 0xA0 +#define PMU_DCDC_HPPA_1_5V 0x90 +#define PMU_DCDC_HPPA_1_4V 0x80 +#define PMU_DCDC_HPPA_1_3V 0x70 +#define PMU_DCDC_HPPA_1_2V 0x60 -#define PMU_VMIC_3_3V 0x14 -#define PMU_VMIC_3_2V 0x13 -#define PMU_VMIC_3_1V 0x12 -#define PMU_VMIC_3_0V 0x11 -#define PMU_VMIC_2_9V 0x10 -#define PMU_VMIC_2_8V 0xF -#define PMU_VMIC_2_7V 0xF -#define PMU_VMIC_2_6V 0xE -#define PMU_VMIC_2_5V 0xD -#define PMU_VMIC_2_4V 0xC -#define PMU_VMIC_2_3V 0xB -#define PMU_VMIC_2_2V 0xA -#define PMU_VMIC_2_1V 0x9 -#define PMU_VMIC_2_0V 0x8 -#define PMU_VMIC_1_9V 0x7 -#define PMU_VMIC_1_8V 0x6 -#define PMU_VMIC_1_7V 0x5 -#define PMU_VMIC_1_6V 0x4 +#define PMU_VMIC_3_3V 0x14 +#define PMU_VMIC_3_2V 0x13 +#define PMU_VMIC_3_1V 0x12 +#define PMU_VMIC_3_0V 0x11 +#define PMU_VMIC_2_9V 0x10 +#define PMU_VMIC_2_8V 0xF +#define PMU_VMIC_2_7V 0xF +#define PMU_VMIC_2_6V 0xE +#define PMU_VMIC_2_5V 0xD +#define PMU_VMIC_2_4V 0xC +#define PMU_VMIC_2_3V 0xB +#define PMU_VMIC_2_2V 0xA +#define PMU_VMIC_2_1V 0x9 +#define PMU_VMIC_2_0V 0x8 +#define PMU_VMIC_1_9V 0x7 +#define PMU_VMIC_1_8V 0x6 +#define PMU_VMIC_1_7V 0x5 +#define PMU_VMIC_1_6V 0x4 -#define PMU_VMIC_RES_3_3V 0xF -#define PMU_VMIC_RES_2_8V 0xA -#define PMU_VMIC_RES_2_2V 0x4 +#define PMU_VMIC_RES_3_3V 0xF +#define PMU_VMIC_RES_2_8V 0xA +#define PMU_VMIC_RES_2_2V 0x4 // 00 PMU_REG_METAL_ID -#define PMU_METAL_ID_SHIFT 0 -#define PMU_METAL_ID_MASK (0xF << PMU_METAL_ID_SHIFT) -#define PMU_METAL_ID(n) (((n) & 0xF) << PMU_METAL_ID_SHIFT) +#define PMU_METAL_ID_SHIFT 0 +#define PMU_METAL_ID_MASK (0xF << PMU_METAL_ID_SHIFT) +#define PMU_METAL_ID(n) (((n)&0xF) << PMU_METAL_ID_SHIFT) // 02 PMU_REG_POWER_KEY_CFG -#define REG_PU_VBAT_DIV (1 << 15) -#define PU_LPO_DR (1 << 14) -#define PU_LPO_REG (1 << 13) -#define POWERKEY_WAKEUP_OSC_EN (1 << 12) -#define RTC_POWER_ON_EN (1 << 11) -#define PU_ALL_REG (1 << 10) -#define CLK_32K_SEL_SHIFT 8 -#define CLK_32K_SEL_MASK (0x3 << CLK_32K_SEL_SHIFT) -#define CLK_32K_SEL(n) BITFIELD_VAL(CLK_32K_SEL, n) -#define DEEPSLEEP_MODE_DIGI_DR (1 << 7) -#define DEEPSLEEP_MODE_DIGI_REG (1 << 6) -#define REG_VCORE_SSTIME_MODE_SHIFT 4 -#define REG_VCORE_SSTIME_MODE_MASK (0x3 << REG_VCORE_SSTIME_MODE_SHIFT) -#define REG_VCORE_SSTIME_MODE(n) BITFIELD_VAL(REG_VCORE_SSTIME_MODE, n) -#define REG_LDO_SS_BIAS_EN_DR (1 << 3) -#define REG_LDO_SS_BIAS_EN (1 << 2) -#define REG_LP_EN_VHPPA_DSLEEP (1 << 1) -#define REG_LP_EN_VHPPA_NORMAL (1 << 0) +#define REG_PU_VBAT_DIV (1 << 15) +#define PU_LPO_DR (1 << 14) +#define PU_LPO_REG (1 << 13) +#define POWERKEY_WAKEUP_OSC_EN (1 << 12) +#define RTC_POWER_ON_EN (1 << 11) +#define PU_ALL_REG (1 << 10) +#define CLK_32K_SEL_SHIFT 8 +#define CLK_32K_SEL_MASK (0x3 << CLK_32K_SEL_SHIFT) +#define CLK_32K_SEL(n) BITFIELD_VAL(CLK_32K_SEL, n) +#define DEEPSLEEP_MODE_DIGI_DR (1 << 7) +#define DEEPSLEEP_MODE_DIGI_REG (1 << 6) +#define REG_VCORE_SSTIME_MODE_SHIFT 4 +#define REG_VCORE_SSTIME_MODE_MASK (0x3 << REG_VCORE_SSTIME_MODE_SHIFT) +#define REG_VCORE_SSTIME_MODE(n) BITFIELD_VAL(REG_VCORE_SSTIME_MODE, n) +#define REG_LDO_SS_BIAS_EN_DR (1 << 3) +#define REG_LDO_SS_BIAS_EN (1 << 2) +#define REG_LP_EN_VHPPA_DSLEEP (1 << 1) +#define REG_LP_EN_VHPPA_NORMAL (1 << 0) // 03 PMU_REG_BIAS_CFG -#define REG_VSENSE_SEL_VMEM (1 << 15) -#define PU_LP_BIAS_LDO_DSLEEP (1 << 14) -#define PU_LP_BIAS_LDO_DR (1 << 13) -#define PU_LP_BIAS_LDO_REG (1 << 12) -#define PU_BIAS_LDO_DR (1 << 11) -#define PU_BIAS_LDO_REG (1 << 10) -#define BG_VBG_SEL_DR (1 << 9) -#define BG_VBG_SEL_REG (1 << 8) -#define BG_CONSTANT_GM_BIAS_DR (1 << 7) -#define BG_CONSTANT_GM_BIAS_REG (1 << 6) -#define BG_CORE_EN_DR (1 << 5) -#define BG_CORE_EN_REG (1 << 4) -#define REG_PU_LDO_VANA_DR (1 << 3) -#define REG_PU_LDO_VANA (1 << 2) -#define BG_NOTCH_EN_DR (1 << 1) -#define BG_NOTCH_EN_REG (1 << 0) +#define REG_VSENSE_SEL_VMEM (1 << 15) +#define PU_LP_BIAS_LDO_DSLEEP (1 << 14) +#define PU_LP_BIAS_LDO_DR (1 << 13) +#define PU_LP_BIAS_LDO_REG (1 << 12) +#define PU_BIAS_LDO_DR (1 << 11) +#define PU_BIAS_LDO_REG (1 << 10) +#define BG_VBG_SEL_DR (1 << 9) +#define BG_VBG_SEL_REG (1 << 8) +#define BG_CONSTANT_GM_BIAS_DR (1 << 7) +#define BG_CONSTANT_GM_BIAS_REG (1 << 6) +#define BG_CORE_EN_DR (1 << 5) +#define BG_CORE_EN_REG (1 << 4) +#define REG_PU_LDO_VANA_DR (1 << 3) +#define REG_PU_LDO_VANA (1 << 2) +#define BG_NOTCH_EN_DR (1 << 1) +#define BG_NOTCH_EN_REG (1 << 0) -#define REG_PU_LDO_VANA_REG REG_PU_LDO_VANA +#define REG_PU_LDO_VANA_REG REG_PU_LDO_VANA // 05 PMU_REG_CHARGER_CFG -#define REG_PU_LDO_VRTC_RF_DSLEEP (1 << 15) -#define REG_PU_LDO_VRTC_RF_DR (1 << 14) -#define REG_PU_LDO_VRTC_RF_REG (1 << 13) -#define REG_CHARGE_OUT_INTR_MSK (1 << 12) -#define REG_CHARGE_IN_INTR_MSK (1 << 11) -#define REG_AC_ON_OUT_EN (1 << 10) -#define REG_AC_ON_IN_EN (1 << 9) -#define REG_CHARGE_INTR_EN (1 << 8) -#define REG_AC_ON_DB_VALUE_SHIFT 0 -#define REG_AC_ON_DB_VALUE_MASK (0xFF << REG_AC_ON_DB_VALUE_SHIFT) -#define REG_AC_ON_DB_VALUE(n) BITFIELD_VAL(REG_AC_ON_DB_VALUE, n) +#define REG_PU_LDO_VRTC_RF_DSLEEP (1 << 15) +#define REG_PU_LDO_VRTC_RF_DR (1 << 14) +#define REG_PU_LDO_VRTC_RF_REG (1 << 13) +#define REG_CHARGE_OUT_INTR_MSK (1 << 12) +#define REG_CHARGE_IN_INTR_MSK (1 << 11) +#define REG_AC_ON_OUT_EN (1 << 10) +#define REG_AC_ON_IN_EN (1 << 9) +#define REG_CHARGE_INTR_EN (1 << 8) +#define REG_AC_ON_DB_VALUE_SHIFT 0 +#define REG_AC_ON_DB_VALUE_MASK (0xFF << REG_AC_ON_DB_VALUE_SHIFT) +#define REG_AC_ON_DB_VALUE(n) BITFIELD_VAL(REG_AC_ON_DB_VALUE, n) // 07 PMU_REG_ANA_CFG -#define REG_LIGHT_LOAD_VANA_BUCK_LDO (1 << 15) -#define REG_PULLDOWN_VANA_LDO (1 << 14) -#define LP_EN_VANA_LDO_DSLEEP (1 << 13) -#define LP_EN_VANA_LDO_DR (1 << 12) -#define LP_EN_VANA_LDO_REG (1 << 11) -#define REG_PU_LDO_VANA_DSLEEP (1 << 10) -#define LDO_ANA_VBIT_DSLEEP_SHIFT 5 -#define LDO_ANA_VBIT_DSLEEP_MASK (0x1F << LDO_ANA_VBIT_DSLEEP_SHIFT) -#define LDO_ANA_VBIT_DSLEEP(n) BITFIELD_VAL(LDO_ANA_VBIT_DSLEEP, n) -#define LDO_ANA_VBIT_NORMAL_SHIFT 0 -#define LDO_ANA_VBIT_NORMAL_MASK (0x1F << LDO_ANA_VBIT_NORMAL_SHIFT) -#define LDO_ANA_VBIT_NORMAL(n) BITFIELD_VAL(LDO_ANA_VBIT_NORMAL, n) +#define REG_LIGHT_LOAD_VANA_BUCK_LDO (1 << 15) +#define REG_PULLDOWN_VANA_LDO (1 << 14) +#define LP_EN_VANA_LDO_DSLEEP (1 << 13) +#define LP_EN_VANA_LDO_DR (1 << 12) +#define LP_EN_VANA_LDO_REG (1 << 11) +#define REG_PU_LDO_VANA_DSLEEP (1 << 10) +#define LDO_ANA_VBIT_DSLEEP_SHIFT 5 +#define LDO_ANA_VBIT_DSLEEP_MASK (0x1F << LDO_ANA_VBIT_DSLEEP_SHIFT) +#define LDO_ANA_VBIT_DSLEEP(n) BITFIELD_VAL(LDO_ANA_VBIT_DSLEEP, n) +#define LDO_ANA_VBIT_NORMAL_SHIFT 0 +#define LDO_ANA_VBIT_NORMAL_MASK (0x1F << LDO_ANA_VBIT_NORMAL_SHIFT) +#define LDO_ANA_VBIT_NORMAL(n) BITFIELD_VAL(LDO_ANA_VBIT_NORMAL, n) -#define LDO_VANA_VBIT_DSLEEP_SHIFT LDO_ANA_VBIT_DSLEEP_SHIFT -#define LDO_VANA_VBIT_DSLEEP_MASK LDO_ANA_VBIT_DSLEEP_MASK -#define LDO_VANA_VBIT_NORMAL_SHIFT LDO_ANA_VBIT_NORMAL_SHIFT -#define LDO_VANA_VBIT_NORMAL_MASK LDO_ANA_VBIT_NORMAL_MASK +#define LDO_VANA_VBIT_DSLEEP_SHIFT LDO_ANA_VBIT_DSLEEP_SHIFT +#define LDO_VANA_VBIT_DSLEEP_MASK LDO_ANA_VBIT_DSLEEP_MASK +#define LDO_VANA_VBIT_NORMAL_SHIFT LDO_ANA_VBIT_NORMAL_SHIFT +#define LDO_VANA_VBIT_NORMAL_MASK LDO_ANA_VBIT_NORMAL_MASK // 08 PMU_REG_DIG_CFG -#define REG_DCDC_CLK_SE_EN (1 << 15) -#define LP_EN_VCORE_LDO_DSLEEP (1 << 14) -#define LP_EN_VCORE_LDO_DR (1 << 13) -#define LP_EN_VCORE_LDO_REG (1 << 12) -#define LDO_DIG_VBIT_DSLEEP_SHIFT 6 -#define LDO_DIG_VBIT_DSLEEP_MASK (0x3F << LDO_DIG_VBIT_DSLEEP_SHIFT) -#define LDO_DIG_VBIT_DSLEEP(n) BITFIELD_VAL(LDO_DIG_VBIT_DSLEEP, n) -#define LDO_DIG_VBIT_NORMAL_SHIFT 0 -#define LDO_DIG_VBIT_NORMAL_MASK (0x3F << LDO_DIG_VBIT_NORMAL_SHIFT) -#define LDO_DIG_VBIT_NORMAL(n) BITFIELD_VAL(LDO_DIG_VBIT_NORMAL, n) +#define REG_DCDC_CLK_SE_EN (1 << 15) +#define LP_EN_VCORE_LDO_DSLEEP (1 << 14) +#define LP_EN_VCORE_LDO_DR (1 << 13) +#define LP_EN_VCORE_LDO_REG (1 << 12) +#define LDO_DIG_VBIT_DSLEEP_SHIFT 6 +#define LDO_DIG_VBIT_DSLEEP_MASK (0x3F << LDO_DIG_VBIT_DSLEEP_SHIFT) +#define LDO_DIG_VBIT_DSLEEP(n) BITFIELD_VAL(LDO_DIG_VBIT_DSLEEP, n) +#define LDO_DIG_VBIT_NORMAL_SHIFT 0 +#define LDO_DIG_VBIT_NORMAL_MASK (0x3F << LDO_DIG_VBIT_NORMAL_SHIFT) +#define LDO_DIG_VBIT_NORMAL(n) BITFIELD_VAL(LDO_DIG_VBIT_NORMAL, n) -#define LDO_VCORE_VBIT_DSLEEP_SHIFT LDO_DIG_VBIT_DSLEEP_SHIFT -#define LDO_VCORE_VBIT_DSLEEP_MASK LDO_DIG_VBIT_DSLEEP_MASK -#define LDO_VCORE_VBIT_NORMAL_SHIFT LDO_DIG_VBIT_NORMAL_SHIFT -#define LDO_VCORE_VBIT_NORMAL_MASK LDO_DIG_VBIT_NORMAL_MASK +#define LDO_VCORE_VBIT_DSLEEP_SHIFT LDO_DIG_VBIT_DSLEEP_SHIFT +#define LDO_VCORE_VBIT_DSLEEP_MASK LDO_DIG_VBIT_DSLEEP_MASK +#define LDO_VCORE_VBIT_NORMAL_SHIFT LDO_DIG_VBIT_NORMAL_SHIFT +#define LDO_VCORE_VBIT_NORMAL_MASK LDO_DIG_VBIT_NORMAL_MASK // Real bit is in REG_101 -- but we never change the default value -#define REG_PU_LDO_VCORE_DSLEEP 0 +#define REG_PU_LDO_VCORE_DSLEEP 0 // 09 PMU_REG_IO_CFG -#define LP_EN_VIO_LDO_DSLEEP (1 << 15) -#define LP_EN_VIO_LDO_DR (1 << 14) -#define LP_EN_VIO_LDO_REG (1 << 13) -#define REG_PU_LDO_VIO_DSLEEP (1 << 12) -#define REG_PU_LDO_VIO_DR (1 << 11) -#define REG_PU_LDO_VIO (1 << 10) -#define LDO_VIO_VBIT_NORMAL_SHIFT 5 -#define LDO_VIO_VBIT_NORMAL_MASK (0x1F << LDO_VIO_VBIT_NORMAL_SHIFT) -#define LDO_VIO_VBIT_NORMAL(n) BITFIELD_VAL(LDO_VIO_VBIT_NORMAL, n) -#define LDO_VIO_VBIT_DSLEEP_SHIFT 0 -#define LDO_VIO_VBIT_DSLEEP_MASK (0x1F << LDO_VIO_VBIT_DSLEEP_SHIFT) -#define LDO_VIO_VBIT_DSLEEP(n) BITFIELD_VAL(LDO_VIO_VBIT_DSLEEP, n) +#define LP_EN_VIO_LDO_DSLEEP (1 << 15) +#define LP_EN_VIO_LDO_DR (1 << 14) +#define LP_EN_VIO_LDO_REG (1 << 13) +#define REG_PU_LDO_VIO_DSLEEP (1 << 12) +#define REG_PU_LDO_VIO_DR (1 << 11) +#define REG_PU_LDO_VIO (1 << 10) +#define LDO_VIO_VBIT_NORMAL_SHIFT 5 +#define LDO_VIO_VBIT_NORMAL_MASK (0x1F << LDO_VIO_VBIT_NORMAL_SHIFT) +#define LDO_VIO_VBIT_NORMAL(n) BITFIELD_VAL(LDO_VIO_VBIT_NORMAL, n) +#define LDO_VIO_VBIT_DSLEEP_SHIFT 0 +#define LDO_VIO_VBIT_DSLEEP_MASK (0x1F << LDO_VIO_VBIT_DSLEEP_SHIFT) +#define LDO_VIO_VBIT_DSLEEP(n) BITFIELD_VAL(LDO_VIO_VBIT_DSLEEP, n) -#define REG_PU_LDO_VIO_REG REG_PU_LDO_VIO +#define REG_PU_LDO_VIO_REG REG_PU_LDO_VIO // 0A PMU_REG_MEM_CFG -#define LP_EN_VMEM_LDO_DSLEEP (1 << 15) -#define LP_EN_VMEM_LDO_DR (1 << 14) -#define LP_EN_VMEM_LDO_REG (1 << 13) -#define REG_PU_LDO_VMEM_DSLEEP (1 << 12) -#define REG_PU_LDO_VMEM_DR (1 << 11) -#define REG_PU_LDO_VMEM_REG (1 << 10) -#define LDO_VMEM_VBIT_NORMAL_SHIFT 5 -#define LDO_VMEM_VBIT_NORMAL_MASK (0x1F << LDO_VMEM_VBIT_NORMAL_SHIFT) -#define LDO_VMEM_VBIT_NORMAL(n) BITFIELD_VAL(LDO_VMEM_VBIT_NORMAL, n) -#define LDO_VMEM_VBIT_DSLEEP_SHIFT 0 -#define LDO_VMEM_VBIT_DSLEEP_MASK (0x1F << LDO_VMEM_VBIT_DSLEEP_SHIFT) -#define LDO_VMEM_VBIT_DSLEEP(n) BITFIELD_VAL(LDO_VMEM_VBIT_DSLEEP, n) +#define LP_EN_VMEM_LDO_DSLEEP (1 << 15) +#define LP_EN_VMEM_LDO_DR (1 << 14) +#define LP_EN_VMEM_LDO_REG (1 << 13) +#define REG_PU_LDO_VMEM_DSLEEP (1 << 12) +#define REG_PU_LDO_VMEM_DR (1 << 11) +#define REG_PU_LDO_VMEM_REG (1 << 10) +#define LDO_VMEM_VBIT_NORMAL_SHIFT 5 +#define LDO_VMEM_VBIT_NORMAL_MASK (0x1F << LDO_VMEM_VBIT_NORMAL_SHIFT) +#define LDO_VMEM_VBIT_NORMAL(n) BITFIELD_VAL(LDO_VMEM_VBIT_NORMAL, n) +#define LDO_VMEM_VBIT_DSLEEP_SHIFT 0 +#define LDO_VMEM_VBIT_DSLEEP_MASK (0x1F << LDO_VMEM_VBIT_DSLEEP_SHIFT) +#define LDO_VMEM_VBIT_DSLEEP(n) BITFIELD_VAL(LDO_VMEM_VBIT_DSLEEP, n) // 0B PMU_REG_GP_CFG -#define LP_EN_VGP_LDO_DSLEEP (1 << 15) -#define LP_EN_VGP_LDO_DR (1 << 14) -#define LP_EN_VGP_LDO_REG (1 << 13) -#define REG_PU_LDO_VGP_DSLEEP (1 << 12) -#define REG_PU_LDO_VGP_DR (1 << 11) -#define REG_PU_LDO_VGP_REG (1 << 10) -#define LDO_VGP_VBIT_NORMAL_SHIFT 5 -#define LDO_VGP_VBIT_NORMAL_MASK (0x1F << LDO_VGP_VBIT_NORMAL_SHIFT) -#define LDO_VGP_VBIT_NORMAL(n) BITFIELD_VAL(LDO_VGP_VBIT_NORMAL, n) -#define LDO_VGP_VBIT_DSLEEP_SHIFT 0 -#define LDO_VGP_VBIT_DSLEEP_MASK (0x1F << LDO_VGP_VBIT_DSLEEP_SHIFT) -#define LDO_VGP_VBIT_DSLEEP(n) BITFIELD_VAL(LDO_VGP_VBIT_DSLEEP, n) +#define LP_EN_VGP_LDO_DSLEEP (1 << 15) +#define LP_EN_VGP_LDO_DR (1 << 14) +#define LP_EN_VGP_LDO_REG (1 << 13) +#define REG_PU_LDO_VGP_DSLEEP (1 << 12) +#define REG_PU_LDO_VGP_DR (1 << 11) +#define REG_PU_LDO_VGP_REG (1 << 10) +#define LDO_VGP_VBIT_NORMAL_SHIFT 5 +#define LDO_VGP_VBIT_NORMAL_MASK (0x1F << LDO_VGP_VBIT_NORMAL_SHIFT) +#define LDO_VGP_VBIT_NORMAL(n) BITFIELD_VAL(LDO_VGP_VBIT_NORMAL, n) +#define LDO_VGP_VBIT_DSLEEP_SHIFT 0 +#define LDO_VGP_VBIT_DSLEEP_MASK (0x1F << LDO_VGP_VBIT_DSLEEP_SHIFT) +#define LDO_VGP_VBIT_DSLEEP(n) BITFIELD_VAL(LDO_VGP_VBIT_DSLEEP, n) // 0C PMU_REG_USB_CFG -#define REG_LDO_VANA_LV_MODE (1 << 15) -#define REG_PULLDOWN_VUSB (1 << 14) -#define LP_EN_VUSB_LDO_DSLEEP (1 << 13) -#define LP_EN_VUSB_LDO_DR (1 << 12) -#define LP_EN_VUSB_LDO_REG (1 << 11) -#define PU_LDO_VUSB_DSLEEP (1 << 10) -#define PU_LDO_VUSB_DR (1 << 9) -#define PU_LDO_VUSB_REG (1 << 8) -#define LDO_VUSB_VBIT_NORMAL_SHIFT 4 -#define LDO_VUSB_VBIT_NORMAL_MASK (0xF << LDO_VUSB_VBIT_NORMAL_SHIFT) -#define LDO_VUSB_VBIT_NORMAL(n) BITFIELD_VAL(LDO_VUSB_VBIT_NORMAL, n) -#define LDO_VUSB_VBIT_DSLEEP_SHIFT 0 -#define LDO_VUSB_VBIT_DSLEEP_MASK (0xF << LDO_VUSB_VBIT_DSLEEP_SHIFT) -#define LDO_VUSB_VBIT_DSLEEP(n) BITFIELD_VAL(LDO_VUSB_VBIT_DSLEEP, n) +#define REG_LDO_VANA_LV_MODE (1 << 15) +#define REG_PULLDOWN_VUSB (1 << 14) +#define LP_EN_VUSB_LDO_DSLEEP (1 << 13) +#define LP_EN_VUSB_LDO_DR (1 << 12) +#define LP_EN_VUSB_LDO_REG (1 << 11) +#define PU_LDO_VUSB_DSLEEP (1 << 10) +#define PU_LDO_VUSB_DR (1 << 9) +#define PU_LDO_VUSB_REG (1 << 8) +#define LDO_VUSB_VBIT_NORMAL_SHIFT 4 +#define LDO_VUSB_VBIT_NORMAL_MASK (0xF << LDO_VUSB_VBIT_NORMAL_SHIFT) +#define LDO_VUSB_VBIT_NORMAL(n) BITFIELD_VAL(LDO_VUSB_VBIT_NORMAL, n) +#define LDO_VUSB_VBIT_DSLEEP_SHIFT 0 +#define LDO_VUSB_VBIT_DSLEEP_MASK (0xF << LDO_VUSB_VBIT_DSLEEP_SHIFT) +#define LDO_VUSB_VBIT_DSLEEP(n) BITFIELD_VAL(LDO_VUSB_VBIT_DSLEEP, n) -#define REG_PU_LDO_VUSB_DSLEEP PU_LDO_VUSB_DSLEEP -#define REG_PU_LDO_VUSB_DR PU_LDO_VUSB_DR -#define REG_PU_LDO_VUSB_REG PU_LDO_VUSB_REG +#define REG_PU_LDO_VUSB_DSLEEP PU_LDO_VUSB_DSLEEP +#define REG_PU_LDO_VUSB_DR PU_LDO_VUSB_DR +#define REG_PU_LDO_VUSB_REG PU_LDO_VUSB_REG // 0D PMU_REG_BAT2DIG_CFG -#define LP_EN_VBAT2VCORE_LDO_DR (1 << 15) -#define LP_EN_VBAT2VCORE_LDO (1 << 14) -#define REG_PU_VBAT2VCORE_LDO_DR (1 << 13) -#define REG_PU_VBAT2VCORE_LDO (1 << 12) -#define LDO_VBAT2VCORE_VBIT_DSLEEP_SHIFT 6 -#define LDO_VBAT2VCORE_VBIT_DSLEEP_MASK (0x3F << LDO_VBAT2VCORE_VBIT_DSLEEP_SHIFT) -#define LDO_VBAT2VCORE_VBIT_DSLEEP(n) BITFIELD_VAL(LDO_VBAT2VCORE_VBIT_DSLEEP, n) -#define LDO_VBAT2VCORE_VBIT_NORMAL_SHIFT 0 -#define LDO_VBAT2VCORE_VBIT_NORMAL_MASK (0x3F << LDO_VBAT2VCORE_VBIT_NORMAL_SHIFT) -#define LDO_VBAT2VCORE_VBIT_NORMAL(n) BITFIELD_VAL(LDO_VBAT2VCORE_VBIT_NORMAL, n) +#define LP_EN_VBAT2VCORE_LDO_DR (1 << 15) +#define LP_EN_VBAT2VCORE_LDO (1 << 14) +#define REG_PU_VBAT2VCORE_LDO_DR (1 << 13) +#define REG_PU_VBAT2VCORE_LDO (1 << 12) +#define LDO_VBAT2VCORE_VBIT_DSLEEP_SHIFT 6 +#define LDO_VBAT2VCORE_VBIT_DSLEEP_MASK \ + (0x3F << LDO_VBAT2VCORE_VBIT_DSLEEP_SHIFT) +#define LDO_VBAT2VCORE_VBIT_DSLEEP(n) \ + BITFIELD_VAL(LDO_VBAT2VCORE_VBIT_DSLEEP, n) +#define LDO_VBAT2VCORE_VBIT_NORMAL_SHIFT 0 +#define LDO_VBAT2VCORE_VBIT_NORMAL_MASK \ + (0x3F << LDO_VBAT2VCORE_VBIT_NORMAL_SHIFT) +#define LDO_VBAT2VCORE_VBIT_NORMAL(n) \ + BITFIELD_VAL(LDO_VBAT2VCORE_VBIT_NORMAL, n) -#define LP_EN_VBAT2VCORE_LDO_REG LP_EN_VBAT2VCORE_LDO -#define REG_PU_LDO_VBAT2VCORE_DR REG_PU_VBAT2VCORE_LDO_DR -#define REG_PU_LDO_VBAT2VCORE_REG REG_PU_VBAT2VCORE_LDO +#define LP_EN_VBAT2VCORE_LDO_REG LP_EN_VBAT2VCORE_LDO +#define REG_PU_LDO_VBAT2VCORE_DR REG_PU_VBAT2VCORE_LDO_DR +#define REG_PU_LDO_VBAT2VCORE_REG REG_PU_VBAT2VCORE_LDO // Real bit is in REG_101 -- but we never change the default value -#define REG_PU_LDO_VBAT2VCORE_DSLEEP 0 +#define REG_PU_LDO_VBAT2VCORE_DSLEEP 0 // 0E PMU_REG_HPPA_LDO_EN -#define REG_PULL_DOWN_VHPPA (1 << 15) -#define REG_PU_LDO_VHPPA_DSLEEP (1 << 14) -#define REG_PU_LDO_VHPPA_EN (1 << 13) -#define REG_RES_SEL_VHPPA_SHIFT 8 -#define REG_RES_SEL_VHPPA_MASK (0x1F << REG_RES_SEL_VHPPA_SHIFT) -#define REG_RES_SEL_VHPPA(n) BITFIELD_VAL(REG_RES_SEL_VHPPA, n) -#define REG_LP_BIAS_SEL_LDO_SHIFT 6 -#define REG_LP_BIAS_SEL_LDO_MASK (0x3 << REG_LP_BIAS_SEL_LDO_SHIFT) -#define REG_LP_BIAS_SEL_LDO(n) BITFIELD_VAL(REG_LP_BIAS_SEL_LDO, n) -#define REG_BYPASS_VBUCK2ANA (1 << 5) -#define REG_PULLDOWN_VBUCK2ANA (1 << 4) -#define REG_PULLDOWN_VIO (1 << 3) -#define REG_PULLDOWN_VMEM (1 << 2) -#define REG_PULLDOWN_VCORE (1 << 1) -#define REG_PULLDOWN_VHPPA2VCODEC (1 << 0) +#define REG_PULL_DOWN_VHPPA (1 << 15) +#define REG_PU_LDO_VHPPA_DSLEEP (1 << 14) +#define REG_PU_LDO_VHPPA_EN (1 << 13) +#define REG_RES_SEL_VHPPA_SHIFT 8 +#define REG_RES_SEL_VHPPA_MASK (0x1F << REG_RES_SEL_VHPPA_SHIFT) +#define REG_RES_SEL_VHPPA(n) BITFIELD_VAL(REG_RES_SEL_VHPPA, n) +#define REG_LP_BIAS_SEL_LDO_SHIFT 6 +#define REG_LP_BIAS_SEL_LDO_MASK (0x3 << REG_LP_BIAS_SEL_LDO_SHIFT) +#define REG_LP_BIAS_SEL_LDO(n) BITFIELD_VAL(REG_LP_BIAS_SEL_LDO, n) +#define REG_BYPASS_VBUCK2ANA (1 << 5) +#define REG_PULLDOWN_VBUCK2ANA (1 << 4) +#define REG_PULLDOWN_VIO (1 << 3) +#define REG_PULLDOWN_VMEM (1 << 2) +#define REG_PULLDOWN_VCORE (1 << 1) +#define REG_PULLDOWN_VHPPA2VCODEC (1 << 0) // 0F PMU_REG_HPPA2CODEC_CFG -#define PU_LDO_VCODEC_DSLEEP (1 << 15) -#define REG_BYPASS_VCORE (1 << 14) -#define REG_PU_LDO_VHPPA2VCODEC_DR (1 << 13) -#define REG_PU_LDO_VHPPA2VCODEC (1 << 12) -#define LP_EN_VHPPA2VCODEC_LDO_DR (1 << 11) -#define LP_EN_VHPPA2VCODEC_LDO (1 << 10) -#define LDO_VHPPA2VCODEC_VBIT_DSLEEP_SHIFT 5 -#define LDO_VHPPA2VCODEC_VBIT_DSLEEP_MASK (0x1F << LDO_VHPPA2VCODEC_VBIT_DSLEEP_SHIFT) -#define LDO_VHPPA2VCODEC_VBIT_DSLEEP(n) BITFIELD_VAL(LDO_VHPPA2VCODEC_VBIT_DSLEEP, n) -#define LDO_VHPPA2VCODEC_VBIT_NORMAL_SHIFT 0 -#define LDO_VHPPA2VCODEC_VBIT_NORMAL_MASK (0x1F << LDO_VHPPA2VCODEC_VBIT_NORMAL_SHIFT) -#define LDO_VHPPA2VCODEC_VBIT_NORMAL(n) BITFIELD_VAL(LDO_VHPPA2VCODEC_VBIT_NORMAL, n) +#define PU_LDO_VCODEC_DSLEEP (1 << 15) +#define REG_BYPASS_VCORE (1 << 14) +#define REG_PU_LDO_VHPPA2VCODEC_DR (1 << 13) +#define REG_PU_LDO_VHPPA2VCODEC (1 << 12) +#define LP_EN_VHPPA2VCODEC_LDO_DR (1 << 11) +#define LP_EN_VHPPA2VCODEC_LDO (1 << 10) +#define LDO_VHPPA2VCODEC_VBIT_DSLEEP_SHIFT 5 +#define LDO_VHPPA2VCODEC_VBIT_DSLEEP_MASK \ + (0x1F << LDO_VHPPA2VCODEC_VBIT_DSLEEP_SHIFT) +#define LDO_VHPPA2VCODEC_VBIT_DSLEEP(n) \ + BITFIELD_VAL(LDO_VHPPA2VCODEC_VBIT_DSLEEP, n) +#define LDO_VHPPA2VCODEC_VBIT_NORMAL_SHIFT 0 +#define LDO_VHPPA2VCODEC_VBIT_NORMAL_MASK \ + (0x1F << LDO_VHPPA2VCODEC_VBIT_NORMAL_SHIFT) +#define LDO_VHPPA2VCODEC_VBIT_NORMAL(n) \ + BITFIELD_VAL(LDO_VHPPA2VCODEC_VBIT_NORMAL, n) -#define REG_PU_LDO_VHPPA2VCODEC_REG REG_PU_LDO_VHPPA2VCODEC -#define LP_EN_VHPPA2VCODEC_LDO_REG LP_EN_VHPPA2VCODEC_LDO -#define REG_PU_LDO_VCODEC_DSLEEP PU_LDO_VCODEC_DSLEEP +#define REG_PU_LDO_VHPPA2VCODEC_REG REG_PU_LDO_VHPPA2VCODEC +#define LP_EN_VHPPA2VCODEC_LDO_REG LP_EN_VHPPA2VCODEC_LDO +#define REG_PU_LDO_VCODEC_DSLEEP PU_LDO_VCODEC_DSLEEP // 10 PMU_REG_CODEC_CFG -#define PU_LDO_VCODEC_DR (1 << 15) -#define PU_LDO_VCODEC_REG (1 << 14) -#define LP_EN_VCODEC_LDO_DSLEEP (1 << 13) -#define LP_EN_VCODEC_LDO_DR (1 << 12) -#define LP_EN_VCODEC_LDO_REG (1 << 11) -#define REG_PULLDOWN_VCODEC (1 << 10) -#define LDO_VCODEC_VBIT_NORMAL_SHIFT 5 -#define LDO_VCODEC_VBIT_NORMAL_MASK (0x1F << LDO_VCODEC_VBIT_NORMAL_SHIFT) -#define LDO_VCODEC_VBIT_NORMAL(n) BITFIELD_VAL(LDO_VCODEC_VBIT_NORMAL, n) -#define LDO_VCODEC_VBIT_DSLEEP_SHIFT 0 -#define LDO_VCODEC_VBIT_DSLEEP_MASK (0x1F << LDO_VCODEC_VBIT_DSLEEP_SHIFT) -#define LDO_VCODEC_VBIT_DSLEEP(n) BITFIELD_VAL(LDO_VCODEC_VBIT_DSLEEP, n) +#define PU_LDO_VCODEC_DR (1 << 15) +#define PU_LDO_VCODEC_REG (1 << 14) +#define LP_EN_VCODEC_LDO_DSLEEP (1 << 13) +#define LP_EN_VCODEC_LDO_DR (1 << 12) +#define LP_EN_VCODEC_LDO_REG (1 << 11) +#define REG_PULLDOWN_VCODEC (1 << 10) +#define LDO_VCODEC_VBIT_NORMAL_SHIFT 5 +#define LDO_VCODEC_VBIT_NORMAL_MASK (0x1F << LDO_VCODEC_VBIT_NORMAL_SHIFT) +#define LDO_VCODEC_VBIT_NORMAL(n) BITFIELD_VAL(LDO_VCODEC_VBIT_NORMAL, n) +#define LDO_VCODEC_VBIT_DSLEEP_SHIFT 0 +#define LDO_VCODEC_VBIT_DSLEEP_MASK (0x1F << LDO_VCODEC_VBIT_DSLEEP_SHIFT) +#define LDO_VCODEC_VBIT_DSLEEP(n) BITFIELD_VAL(LDO_VCODEC_VBIT_DSLEEP, n) -#define REG_PU_LDO_VCODEC_DR PU_LDO_VCODEC_DR -#define REG_PU_LDO_VCODEC_REG PU_LDO_VCODEC_REG +#define REG_PU_LDO_VCODEC_DR PU_LDO_VCODEC_DR +#define REG_PU_LDO_VCODEC_REG PU_LDO_VCODEC_REG // 15 PMU_REG_DCDC_DIG_EN -#define REG_UVLO_SEL_SHIFT 14 -#define REG_UVLO_SEL_MASK (0x3 << REG_UVLO_SEL_SHIFT) -#define REG_UVLO_SEL(n) BITFIELD_VAL(REG_UVLO_SEL, n) -#define REG_PU_LDO_DIG_DR (1 << 13) -#define REG_PU_LDO_DIG_REG (1 << 12) -#define REG_DCDC1_PFM_SEL_DSLEEP (1 << 11) -#define REG_DCDC1_PFM_SEL_NORMAL (1 << 10) -#define REG_DCDC1_ULP_MODE_DSLEEP (1 << 9) -#define REG_DCDC1_ULP_MODE_NORMAL (1 << 8) -#define REG_DCDC1_BURST_MODE_SEL_DSLEEP (1 << 7) -#define REG_DCDC1_BURST_MODE_SEL_NORMAL (1 << 6) -#define REG_DCDC1_VREF_SEL_DSLEEP_SHIFT 4 -#define REG_DCDC1_VREF_SEL_DSLEEP_MASK (0x3 << REG_DCDC1_VREF_SEL_DSLEEP_SHIFT) -#define REG_DCDC1_VREF_SEL_DSLEEP(n) BITFIELD_VAL(REG_DCDC1_VREF_SEL_DSLEEP, n) -#define REG_DCDC1_VREF_SEL_NORMAL_SHIFT 2 -#define REG_DCDC1_VREF_SEL_NORMAL_MASK (0x3 << REG_DCDC1_VREF_SEL_NORMAL_SHIFT) -#define REG_DCDC1_VREF_SEL_NORMAL(n) BITFIELD_VAL(REG_DCDC1_VREF_SEL_NORMAL, n) -#define REG_PU_DCDC1_DR (1 << 1) -#define REG_PU_DCDC1 (1 << 0) +#define REG_UVLO_SEL_SHIFT 14 +#define REG_UVLO_SEL_MASK (0x3 << REG_UVLO_SEL_SHIFT) +#define REG_UVLO_SEL(n) BITFIELD_VAL(REG_UVLO_SEL, n) +#define REG_PU_LDO_DIG_DR (1 << 13) +#define REG_PU_LDO_DIG_REG (1 << 12) +#define REG_DCDC1_PFM_SEL_DSLEEP (1 << 11) +#define REG_DCDC1_PFM_SEL_NORMAL (1 << 10) +#define REG_DCDC1_ULP_MODE_DSLEEP (1 << 9) +#define REG_DCDC1_ULP_MODE_NORMAL (1 << 8) +#define REG_DCDC1_BURST_MODE_SEL_DSLEEP (1 << 7) +#define REG_DCDC1_BURST_MODE_SEL_NORMAL (1 << 6) +#define REG_DCDC1_VREF_SEL_DSLEEP_SHIFT 4 +#define REG_DCDC1_VREF_SEL_DSLEEP_MASK (0x3 << REG_DCDC1_VREF_SEL_DSLEEP_SHIFT) +#define REG_DCDC1_VREF_SEL_DSLEEP(n) BITFIELD_VAL(REG_DCDC1_VREF_SEL_DSLEEP, n) +#define REG_DCDC1_VREF_SEL_NORMAL_SHIFT 2 +#define REG_DCDC1_VREF_SEL_NORMAL_MASK (0x3 << REG_DCDC1_VREF_SEL_NORMAL_SHIFT) +#define REG_DCDC1_VREF_SEL_NORMAL(n) BITFIELD_VAL(REG_DCDC1_VREF_SEL_NORMAL, n) +#define REG_PU_DCDC1_DR (1 << 1) +#define REG_PU_DCDC1 (1 << 0) -#define REG_PU_LDO_VCORE_DR REG_PU_LDO_DIG_DR -#define REG_PU_LDO_VCORE_REG REG_PU_LDO_DIG_REG +#define REG_PU_LDO_VCORE_DR REG_PU_LDO_DIG_DR +#define REG_PU_LDO_VCORE_REG REG_PU_LDO_DIG_REG // 19 PMU_REG_DCDC_ANA_CFG_19 -#define DCDC2_IX2_ERR (1 << 15) -#define DCDC2_IX2_IRCOMP (1 << 14) -#define DCDC2_LP_ERR (1 << 13) -#define DCDC2_LP_VCOMP (1 << 12) -#define DCDC2_PULLDOWN_EN (1 << 11) -#define DCDC2_SLOPE_DOUBLE (1 << 10) -#define DCDC2_SLOPE_EN_BURST (1 << 9) -#define DCDC2_SOFT_START_EN (1 << 8) -#define DCDC2_SS_TIME_SEL (1 << 7) -#define DCDC2_SYNC_DISABLE (1 << 6) -#define DCDC2_TEST_MODE_EN (1 << 5) -#define DCDC2_ZCD_CAL_BIT_SHIFT 1 -#define DCDC2_ZCD_CAL_BIT_MASK (0xF << DCDC2_ZCD_CAL_BIT_SHIFT) -#define DCDC2_ZCD_CAL_BIT(n) BITFIELD_VAL(DCDC2_ZCD_CAL_BIT, n) -#define DCDC2_REG_BYPASS (1 << 0) +#define DCDC2_IX2_ERR (1 << 15) +#define DCDC2_IX2_IRCOMP (1 << 14) +#define DCDC2_LP_ERR (1 << 13) +#define DCDC2_LP_VCOMP (1 << 12) +#define DCDC2_PULLDOWN_EN (1 << 11) +#define DCDC2_SLOPE_DOUBLE (1 << 10) +#define DCDC2_SLOPE_EN_BURST (1 << 9) +#define DCDC2_SOFT_START_EN (1 << 8) +#define DCDC2_SS_TIME_SEL (1 << 7) +#define DCDC2_SYNC_DISABLE (1 << 6) +#define DCDC2_TEST_MODE_EN (1 << 5) +#define DCDC2_ZCD_CAL_BIT_SHIFT 1 +#define DCDC2_ZCD_CAL_BIT_MASK (0xF << DCDC2_ZCD_CAL_BIT_SHIFT) +#define DCDC2_ZCD_CAL_BIT(n) BITFIELD_VAL(DCDC2_ZCD_CAL_BIT, n) +#define DCDC2_REG_BYPASS (1 << 0) // 1D PMU_REG_DCDC_HPPA_CFG_1D -#define DCDC3_IX2_ERR (1 << 15) -#define DCDC3_IX2_IRCOMP (1 << 14) -#define DCDC3_LP_ERR (1 << 13) -#define DCDC3_LP_VCOMP (1 << 12) -#define DCDC3_PULLDOWN_EN (1 << 11) -#define DCDC3_SLOPE_DOUBLE (1 << 10) -#define DCDC3_SLOPE_EN_BURST (1 << 9) -#define DCDC3_SOFT_START_EN (1 << 8) -#define DCDC3_SS_TIME_SEL (1 << 7) -#define DCDC3_SYNC_DISABLE (1 << 6) -#define DCDC3_TEST_MODE_EN (1 << 5) -#define DCDC3_ZCD_CAL_BIT_SHIFT 1 -#define DCDC3_ZCD_CAL_BIT_MASK (0xF << DCDC3_ZCD_CAL_BIT_SHIFT) -#define DCDC3_ZCD_CAL_BIT(n) BITFIELD_VAL(DCDC3_ZCD_CAL_BIT, n) -#define DCDC3_REG_BYPASS (1 << 0) +#define DCDC3_IX2_ERR (1 << 15) +#define DCDC3_IX2_IRCOMP (1 << 14) +#define DCDC3_LP_ERR (1 << 13) +#define DCDC3_LP_VCOMP (1 << 12) +#define DCDC3_PULLDOWN_EN (1 << 11) +#define DCDC3_SLOPE_DOUBLE (1 << 10) +#define DCDC3_SLOPE_EN_BURST (1 << 9) +#define DCDC3_SOFT_START_EN (1 << 8) +#define DCDC3_SS_TIME_SEL (1 << 7) +#define DCDC3_SYNC_DISABLE (1 << 6) +#define DCDC3_TEST_MODE_EN (1 << 5) +#define DCDC3_ZCD_CAL_BIT_SHIFT 1 +#define DCDC3_ZCD_CAL_BIT_MASK (0xF << DCDC3_ZCD_CAL_BIT_SHIFT) +#define DCDC3_ZCD_CAL_BIT(n) BITFIELD_VAL(DCDC3_ZCD_CAL_BIT, n) +#define DCDC3_REG_BYPASS (1 << 0) // 21 PMU_REG_PWR_SEL -#define REG_PMU_VSEL1_SHIFT 13 -#define REG_PMU_VSEL1_MASK (0x7 << REG_PMU_VSEL1_SHIFT) -#define REG_PMU_VSEL1(n) BITFIELD_VAL(REG_PMU_VSEL1, n) -#define REG_POWER_SEL_CNT_SHIFT 8 -#define REG_POWER_SEL_CNT_MASK (0x1F << REG_POWER_SEL_CNT_SHIFT) -#define REG_POWER_SEL_CNT(n) BITFIELD_VAL(REG_POWER_SEL_CNT, n) -#define REG_PWR_SEL_DR (1 << 7) -#define REG_PWR_SEL (1 << 6) -#define CLK_BG_EN (1 << 5) -#define CLK_BG_DIV_VALUE_SHIFT 0 -#define CLK_BG_DIV_VALUE_MASK (0x1F << CLK_BG_DIV_VALUE_SHIFT) -#define CLK_BG_DIV_VALUE(n) BITFIELD_VAL(CLK_BG_DIV_VALUE, n) +#define REG_PMU_VSEL1_SHIFT 13 +#define REG_PMU_VSEL1_MASK (0x7 << REG_PMU_VSEL1_SHIFT) +#define REG_PMU_VSEL1(n) BITFIELD_VAL(REG_PMU_VSEL1, n) +#define REG_POWER_SEL_CNT_SHIFT 8 +#define REG_POWER_SEL_CNT_MASK (0x1F << REG_POWER_SEL_CNT_SHIFT) +#define REG_POWER_SEL_CNT(n) BITFIELD_VAL(REG_POWER_SEL_CNT, n) +#define REG_PWR_SEL_DR (1 << 7) +#define REG_PWR_SEL (1 << 6) +#define CLK_BG_EN (1 << 5) +#define CLK_BG_DIV_VALUE_SHIFT 0 +#define CLK_BG_DIV_VALUE_MASK (0x1F << CLK_BG_DIV_VALUE_SHIFT) +#define CLK_BG_DIV_VALUE(n) BITFIELD_VAL(CLK_BG_DIV_VALUE, n) // 26 PMU_REG_INT_MASK -#define RESET_EN_VCORE_LOW (1 << 15) -#define RTC_INT1_MSK (1 << 14) -#define RTC_INT0_MSK (1 << 13) -#define KEY_ERR1_INTR_MSK (1 << 12) -#define KEY_ERR0_INTR_MSK (1 << 11) -#define KEY_PRESS_INTR_MSK (1 << 10) -#define KEY_RELEASE_INTR_MSK (1 << 9) -#define SAMPLE_DONE_INTR_MSK (1 << 8) -#define CHAN_DATA_INTR_MSK_SHIFT 0 -#define CHAN_DATA_INTR_MSK_MASK (0xFF << CHAN_DATA_INTR_MSK_SHIFT) -#define CHAN_DATA_INTR_MSK(n) BITFIELD_VAL(CHAN_DATA_INTR_MSK, n) +#define RESET_EN_VCORE_LOW (1 << 15) +#define RTC_INT1_MSK (1 << 14) +#define RTC_INT0_MSK (1 << 13) +#define KEY_ERR1_INTR_MSK (1 << 12) +#define KEY_ERR0_INTR_MSK (1 << 11) +#define KEY_PRESS_INTR_MSK (1 << 10) +#define KEY_RELEASE_INTR_MSK (1 << 9) +#define SAMPLE_DONE_INTR_MSK (1 << 8) +#define CHAN_DATA_INTR_MSK_SHIFT 0 +#define CHAN_DATA_INTR_MSK_MASK (0xFF << CHAN_DATA_INTR_MSK_SHIFT) +#define CHAN_DATA_INTR_MSK(n) BITFIELD_VAL(CHAN_DATA_INTR_MSK, n) // 27 PMU_REG_INT_EN -#define REG_BG_SLEEP_MSK (1 << 15) -#define RTC_INT_EN_1 (1 << 14) -#define RTC_INT_EN_0 (1 << 13) -#define KEY_ERR1_INTR_EN (1 << 12) -#define KEY_ERR0_INTR_EN (1 << 11) -#define KEY_PRESS_INTR_EN (1 << 10) -#define KEY_RELEASE_INTR_EN (1 << 9) -#define SAMPLE_DONE_INTR_EN (1 << 8) -#define CHAN_DATA_INTR_EN_SHIFT 0 -#define CHAN_DATA_INTR_EN_MASK (0xFF << CHAN_DATA_INTR_EN_SHIFT) -#define CHAN_DATA_INTR_EN(n) BITFIELD_VAL(CHAN_DATA_INTR_EN, n) +#define REG_BG_SLEEP_MSK (1 << 15) +#define RTC_INT_EN_1 (1 << 14) +#define RTC_INT_EN_0 (1 << 13) +#define KEY_ERR1_INTR_EN (1 << 12) +#define KEY_ERR0_INTR_EN (1 << 11) +#define KEY_PRESS_INTR_EN (1 << 10) +#define KEY_RELEASE_INTR_EN (1 << 9) +#define SAMPLE_DONE_INTR_EN (1 << 8) +#define CHAN_DATA_INTR_EN_SHIFT 0 +#define CHAN_DATA_INTR_EN_MASK (0xFF << CHAN_DATA_INTR_EN_SHIFT) +#define CHAN_DATA_INTR_EN(n) BITFIELD_VAL(CHAN_DATA_INTR_EN, n) // 36 PMU_REG_DCDC_DIG_CFG_36 -#define DCDC1_IX2_ERR (1 << 15) -#define DCDC1_IX2_IRCOMP (1 << 14) -#define DCDC1_LP_ERR (1 << 13) -#define DCDC1_LP_VCOMP (1 << 12) -#define DCDC1_PULLDOWN_EN (1 << 11) -#define DCDC1_SLOPE_DOUBLE (1 << 10) -#define DCDC1_SLOPE_EN_BURST (1 << 9) -#define DCDC1_SOFT_START_EN (1 << 8) -#define DCDC1_SS_TIME_SEL (1 << 7) -#define DCDC1_SYNC_DISABLE (1 << 6) -#define DCDC1_TEST_MODE_EN (1 << 5) -#define DCDC1_ZCD_CAL_BIT_SHIFT 1 -#define DCDC1_ZCD_CAL_BIT_MASK (0xF << DCDC1_ZCD_CAL_BIT_SHIFT) -#define DCDC1_ZCD_CAL_BIT(n) BITFIELD_VAL(DCDC1_ZCD_CAL_BIT, n) -#define DCDC1_REG_BYPASS (1 << 0) +#define DCDC1_IX2_ERR (1 << 15) +#define DCDC1_IX2_IRCOMP (1 << 14) +#define DCDC1_LP_ERR (1 << 13) +#define DCDC1_LP_VCOMP (1 << 12) +#define DCDC1_PULLDOWN_EN (1 << 11) +#define DCDC1_SLOPE_DOUBLE (1 << 10) +#define DCDC1_SLOPE_EN_BURST (1 << 9) +#define DCDC1_SOFT_START_EN (1 << 8) +#define DCDC1_SS_TIME_SEL (1 << 7) +#define DCDC1_SYNC_DISABLE (1 << 6) +#define DCDC1_TEST_MODE_EN (1 << 5) +#define DCDC1_ZCD_CAL_BIT_SHIFT 1 +#define DCDC1_ZCD_CAL_BIT_MASK (0xF << DCDC1_ZCD_CAL_BIT_SHIFT) +#define DCDC1_ZCD_CAL_BIT(n) BITFIELD_VAL(DCDC1_ZCD_CAL_BIT, n) +#define DCDC1_REG_BYPASS (1 << 0) // 38 PMU_REG_MIC_BIAS_E -#define REG_MIC_BIASE_CHANSEL_SHIFT 14 -#define REG_MIC_BIASE_CHANSEL_MASK (0x3 << REG_MIC_BIASE_CHANSEL_SHIFT) -#define REG_MIC_BIASE_CHANSEL(n) BITFIELD_VAL(REG_MIC_BIASE_CHANSEL, n) -#define REG_MIC_BIASE_EN (1 << 13) -#define REG_MIC_BIASE_ENLPF (1 << 12) -#define REG_MIC_BIASE_LPFSEL_SHIFT 10 -#define REG_MIC_BIASE_LPFSEL_MASK (0x3 << REG_MIC_BIASE_LPFSEL_SHIFT) -#define REG_MIC_BIASE_LPFSEL(n) BITFIELD_VAL(REG_MIC_BIASE_LPFSEL, n) -#define REG_MIC_BIASE_VSEL_SHIFT 5 -#define REG_MIC_BIASE_VSEL_MASK (0x1F << REG_MIC_BIASE_VSEL_SHIFT) -#define REG_MIC_BIASE_VSEL(n) BITFIELD_VAL(REG_MIC_BIASE_VSEL, n) -#define REG_MIC_LDOE_RES_SHIFT 1 -#define REG_MIC_LDOE_RES_MASK (0xF << REG_MIC_LDOE_RES_SHIFT) -#define REG_MIC_LDOE_RES(n) BITFIELD_VAL(REG_MIC_LDOE_RES, n) -#define REG_MIC_LDOE_LOOPCTRL (1 << 0) +#define REG_MIC_BIASE_CHANSEL_SHIFT 14 +#define REG_MIC_BIASE_CHANSEL_MASK (0x3 << REG_MIC_BIASE_CHANSEL_SHIFT) +#define REG_MIC_BIASE_CHANSEL(n) BITFIELD_VAL(REG_MIC_BIASE_CHANSEL, n) +#define REG_MIC_BIASE_EN (1 << 13) +#define REG_MIC_BIASE_ENLPF (1 << 12) +#define REG_MIC_BIASE_LPFSEL_SHIFT 10 +#define REG_MIC_BIASE_LPFSEL_MASK (0x3 << REG_MIC_BIASE_LPFSEL_SHIFT) +#define REG_MIC_BIASE_LPFSEL(n) BITFIELD_VAL(REG_MIC_BIASE_LPFSEL, n) +#define REG_MIC_BIASE_VSEL_SHIFT 5 +#define REG_MIC_BIASE_VSEL_MASK (0x1F << REG_MIC_BIASE_VSEL_SHIFT) +#define REG_MIC_BIASE_VSEL(n) BITFIELD_VAL(REG_MIC_BIASE_VSEL, n) +#define REG_MIC_LDOE_RES_SHIFT 1 +#define REG_MIC_LDOE_RES_MASK (0xF << REG_MIC_LDOE_RES_SHIFT) +#define REG_MIC_LDOE_RES(n) BITFIELD_VAL(REG_MIC_LDOE_RES, n) +#define REG_MIC_LDOE_LOOPCTRL (1 << 0) // 39 PMU_REG_MIC_LDO_EN -#define REG_LED_IO1_AIO_EN (1 << 15) -#define REG_LED_IO2_AIO_EN (1 << 14) -#define REG_LED_IO1_RX_EN (1 << 13) -#define REG_LED_IO2_RX_EN (1 << 12) -#define REG_MIC_LDOA_EN (1 << 11) -#define REG_MIC_LDOB_EN (1 << 10) -#define REG_MIC_LDOC_EN (1 << 9) -#define REG_MIC_LDOD_EN (1 << 8) -#define REG_MIC_LDOE_EN (1 << 7) -#define DCDC1_OFFSET_CURRENT_EN (1 << 6) -#define DCDC2_OFFSET_CURRENT_EN (1 << 5) -#define DCDC3_OFFSET_CURRENT_EN (1 << 4) -#define DCDC4_OFFSET_CURRENT_EN (1 << 3) +#define REG_LED_IO1_AIO_EN (1 << 15) +#define REG_LED_IO2_AIO_EN (1 << 14) +#define REG_LED_IO1_RX_EN (1 << 13) +#define REG_LED_IO2_RX_EN (1 << 12) +#define REG_MIC_LDOA_EN (1 << 11) +#define REG_MIC_LDOB_EN (1 << 10) +#define REG_MIC_LDOC_EN (1 << 9) +#define REG_MIC_LDOD_EN (1 << 8) +#define REG_MIC_LDOE_EN (1 << 7) +#define DCDC1_OFFSET_CURRENT_EN (1 << 6) +#define DCDC2_OFFSET_CURRENT_EN (1 << 5) +#define DCDC3_OFFSET_CURRENT_EN (1 << 4) +#define DCDC4_OFFSET_CURRENT_EN (1 << 3) // 3A PMU_REG_LED_CFG -#define REG_LED_IO1_IBIT_SHIFT 14 -#define REG_LED_IO1_IBIT_MASK (0x3 << REG_LED_IO1_IBIT_SHIFT) -#define REG_LED_IO1_IBIT(n) BITFIELD_VAL(REG_LED_IO1_IBIT, n) -#define REG_LED_IO1_OENB (1 << 13) -#define REG_LED_IO1_PDEN (1 << 12) -#define REG_LED_IO1_PU (1 << 11) -#define REG_LED_IO1_PUEN (1 << 10) -#define REG_LED_IO1_SEL_SHIFT 8 -#define REG_LED_IO1_SEL_MASK (0x3 << REG_LED_IO1_SEL_SHIFT) -#define REG_LED_IO1_SEL(n) BITFIELD_VAL(REG_LED_IO1_SEL, n) -#define REG_LED_IO2_IBIT_SHIFT 6 -#define REG_LED_IO2_IBIT_MASK (0x3 << REG_LED_IO2_IBIT_SHIFT) -#define REG_LED_IO2_IBIT(n) BITFIELD_VAL(REG_LED_IO2_IBIT, n) -#define REG_LED_IO2_OENB (1 << 5) -#define REG_LED_IO2_PDEN (1 << 4) -#define REG_LED_IO2_PU (1 << 3) -#define REG_LED_IO2_PUEN (1 << 2) -#define REG_LED_IO2_SEL_SHIFT 0 -#define REG_LED_IO2_SEL_MASK (0x3 << REG_LED_IO2_SEL_SHIFT) -#define REG_LED_IO2_SEL(n) BITFIELD_VAL(REG_LED_IO2_SEL, n) +#define REG_LED_IO1_IBIT_SHIFT 14 +#define REG_LED_IO1_IBIT_MASK (0x3 << REG_LED_IO1_IBIT_SHIFT) +#define REG_LED_IO1_IBIT(n) BITFIELD_VAL(REG_LED_IO1_IBIT, n) +#define REG_LED_IO1_OENB (1 << 13) +#define REG_LED_IO1_PDEN (1 << 12) +#define REG_LED_IO1_PU (1 << 11) +#define REG_LED_IO1_PUEN (1 << 10) +#define REG_LED_IO1_SEL_SHIFT 8 +#define REG_LED_IO1_SEL_MASK (0x3 << REG_LED_IO1_SEL_SHIFT) +#define REG_LED_IO1_SEL(n) BITFIELD_VAL(REG_LED_IO1_SEL, n) +#define REG_LED_IO2_IBIT_SHIFT 6 +#define REG_LED_IO2_IBIT_MASK (0x3 << REG_LED_IO2_IBIT_SHIFT) +#define REG_LED_IO2_IBIT(n) BITFIELD_VAL(REG_LED_IO2_IBIT, n) +#define REG_LED_IO2_OENB (1 << 5) +#define REG_LED_IO2_PDEN (1 << 4) +#define REG_LED_IO2_PU (1 << 3) +#define REG_LED_IO2_PUEN (1 << 2) +#define REG_LED_IO2_SEL_SHIFT 0 +#define REG_LED_IO2_SEL_MASK (0x3 << REG_LED_IO2_SEL_SHIFT) +#define REG_LED_IO2_SEL(n) BITFIELD_VAL(REG_LED_IO2_SEL, n) // 3B PMU_REG_MIC_BIAS_A -#define REG_MIC_BIASA_CHANSEL_SHIFT 14 -#define REG_MIC_BIASA_CHANSEL_MASK (0x3 << REG_MIC_BIASA_CHANSEL_SHIFT) -#define REG_MIC_BIASA_CHANSEL(n) BITFIELD_VAL(REG_MIC_BIASA_CHANSEL, n) -#define REG_MIC_BIASA_EN (1 << 13) -#define REG_MIC_BIASA_ENLPF (1 << 12) -#define REG_MIC_BIASA_LPFSEL_SHIFT 10 -#define REG_MIC_BIASA_LPFSEL_MASK (0x3 << REG_MIC_BIASA_LPFSEL_SHIFT) -#define REG_MIC_BIASA_LPFSEL(n) BITFIELD_VAL(REG_MIC_BIASA_LPFSEL, n) -#define REG_MIC_BIASA_VSEL_SHIFT 5 -#define REG_MIC_BIASA_VSEL_MASK (0x1F << REG_MIC_BIASA_VSEL_SHIFT) -#define REG_MIC_BIASA_VSEL(n) BITFIELD_VAL(REG_MIC_BIASA_VSEL, n) -#define REG_MIC_LDOA_RES_SHIFT 1 -#define REG_MIC_LDOA_RES_MASK (0xF << REG_MIC_LDOA_RES_SHIFT) -#define REG_MIC_LDOA_RES(n) BITFIELD_VAL(REG_MIC_LDOA_RES, n) -#define REG_MIC_LDOA_LOOPCTRL (1 << 0) +#define REG_MIC_BIASA_CHANSEL_SHIFT 14 +#define REG_MIC_BIASA_CHANSEL_MASK (0x3 << REG_MIC_BIASA_CHANSEL_SHIFT) +#define REG_MIC_BIASA_CHANSEL(n) BITFIELD_VAL(REG_MIC_BIASA_CHANSEL, n) +#define REG_MIC_BIASA_EN (1 << 13) +#define REG_MIC_BIASA_ENLPF (1 << 12) +#define REG_MIC_BIASA_LPFSEL_SHIFT 10 +#define REG_MIC_BIASA_LPFSEL_MASK (0x3 << REG_MIC_BIASA_LPFSEL_SHIFT) +#define REG_MIC_BIASA_LPFSEL(n) BITFIELD_VAL(REG_MIC_BIASA_LPFSEL, n) +#define REG_MIC_BIASA_VSEL_SHIFT 5 +#define REG_MIC_BIASA_VSEL_MASK (0x1F << REG_MIC_BIASA_VSEL_SHIFT) +#define REG_MIC_BIASA_VSEL(n) BITFIELD_VAL(REG_MIC_BIASA_VSEL, n) +#define REG_MIC_LDOA_RES_SHIFT 1 +#define REG_MIC_LDOA_RES_MASK (0xF << REG_MIC_LDOA_RES_SHIFT) +#define REG_MIC_LDOA_RES(n) BITFIELD_VAL(REG_MIC_LDOA_RES, n) +#define REG_MIC_LDOA_LOOPCTRL (1 << 0) // 3C PMU_REG_MIC_BIAS_B -#define REG_MIC_BIASB_CHANSEL_SHIFT 14 -#define REG_MIC_BIASB_CHANSEL_MASK (0x3 << REG_MIC_BIASB_CHANSEL_SHIFT) -#define REG_MIC_BIASB_CHANSEL(n) BITFIELD_VAL(REG_MIC_BIASB_CHANSEL, n) -#define REG_MIC_BIASB_EN (1 << 13) -#define REG_MIC_BIASB_ENLPF (1 << 12) -#define REG_MIC_BIASB_LPFSEL_SHIFT 10 -#define REG_MIC_BIASB_LPFSEL_MASK (0x3 << REG_MIC_BIASB_LPFSEL_SHIFT) -#define REG_MIC_BIASB_LPFSEL(n) BITFIELD_VAL(REG_MIC_BIASB_LPFSEL, n) -#define REG_MIC_BIASB_VSEL_SHIFT 5 -#define REG_MIC_BIASB_VSEL_MASK (0x1F << REG_MIC_BIASB_VSEL_SHIFT) -#define REG_MIC_BIASB_VSEL(n) BITFIELD_VAL(REG_MIC_BIASB_VSEL, n) -#define REG_MIC_LDOB_RES_SHIFT 1 -#define REG_MIC_LDOB_RES_MASK (0xF << REG_MIC_LDOB_RES_SHIFT) -#define REG_MIC_LDOB_RES(n) BITFIELD_VAL(REG_MIC_LDOB_RES, n) -#define REG_MIC_LDOB_LOOPCTRL (1 << 0) +#define REG_MIC_BIASB_CHANSEL_SHIFT 14 +#define REG_MIC_BIASB_CHANSEL_MASK (0x3 << REG_MIC_BIASB_CHANSEL_SHIFT) +#define REG_MIC_BIASB_CHANSEL(n) BITFIELD_VAL(REG_MIC_BIASB_CHANSEL, n) +#define REG_MIC_BIASB_EN (1 << 13) +#define REG_MIC_BIASB_ENLPF (1 << 12) +#define REG_MIC_BIASB_LPFSEL_SHIFT 10 +#define REG_MIC_BIASB_LPFSEL_MASK (0x3 << REG_MIC_BIASB_LPFSEL_SHIFT) +#define REG_MIC_BIASB_LPFSEL(n) BITFIELD_VAL(REG_MIC_BIASB_LPFSEL, n) +#define REG_MIC_BIASB_VSEL_SHIFT 5 +#define REG_MIC_BIASB_VSEL_MASK (0x1F << REG_MIC_BIASB_VSEL_SHIFT) +#define REG_MIC_BIASB_VSEL(n) BITFIELD_VAL(REG_MIC_BIASB_VSEL, n) +#define REG_MIC_LDOB_RES_SHIFT 1 +#define REG_MIC_LDOB_RES_MASK (0xF << REG_MIC_LDOB_RES_SHIFT) +#define REG_MIC_LDOB_RES(n) BITFIELD_VAL(REG_MIC_LDOB_RES, n) +#define REG_MIC_LDOB_LOOPCTRL (1 << 0) // 3D PMU_REG_MIC_BIAS_C -#define REG_MIC_BIASC_CHANSEL_SHIFT 14 -#define REG_MIC_BIASC_CHANSEL_MASK (0x3 << REG_MIC_BIASC_CHANSEL_SHIFT) -#define REG_MIC_BIASC_CHANSEL(n) BITFIELD_VAL(REG_MIC_BIASC_CHANSEL, n) -#define REG_MIC_BIASC_EN (1 << 13) -#define REG_MIC_BIASC_ENLPF (1 << 12) -#define REG_MIC_BIASC_LPFSEL_SHIFT 10 -#define REG_MIC_BIASC_LPFSEL_MASK (0x3 << REG_MIC_BIASC_LPFSEL_SHIFT) -#define REG_MIC_BIASC_LPFSEL(n) BITFIELD_VAL(REG_MIC_BIASC_LPFSEL, n) -#define REG_MIC_BIASC_VSEL_SHIFT 5 -#define REG_MIC_BIASC_VSEL_MASK (0x1F << REG_MIC_BIASC_VSEL_SHIFT) -#define REG_MIC_BIASC_VSEL(n) BITFIELD_VAL(REG_MIC_BIASC_VSEL, n) -#define REG_MIC_LDOC_RES_SHIFT 1 -#define REG_MIC_LDOC_RES_MASK (0xF << REG_MIC_LDOC_RES_SHIFT) -#define REG_MIC_LDOC_RES(n) BITFIELD_VAL(REG_MIC_LDOC_RES, n) -#define REG_MIC_LDOC_LOOPCTRL (1 << 0) +#define REG_MIC_BIASC_CHANSEL_SHIFT 14 +#define REG_MIC_BIASC_CHANSEL_MASK (0x3 << REG_MIC_BIASC_CHANSEL_SHIFT) +#define REG_MIC_BIASC_CHANSEL(n) BITFIELD_VAL(REG_MIC_BIASC_CHANSEL, n) +#define REG_MIC_BIASC_EN (1 << 13) +#define REG_MIC_BIASC_ENLPF (1 << 12) +#define REG_MIC_BIASC_LPFSEL_SHIFT 10 +#define REG_MIC_BIASC_LPFSEL_MASK (0x3 << REG_MIC_BIASC_LPFSEL_SHIFT) +#define REG_MIC_BIASC_LPFSEL(n) BITFIELD_VAL(REG_MIC_BIASC_LPFSEL, n) +#define REG_MIC_BIASC_VSEL_SHIFT 5 +#define REG_MIC_BIASC_VSEL_MASK (0x1F << REG_MIC_BIASC_VSEL_SHIFT) +#define REG_MIC_BIASC_VSEL(n) BITFIELD_VAL(REG_MIC_BIASC_VSEL, n) +#define REG_MIC_LDOC_RES_SHIFT 1 +#define REG_MIC_LDOC_RES_MASK (0xF << REG_MIC_LDOC_RES_SHIFT) +#define REG_MIC_LDOC_RES(n) BITFIELD_VAL(REG_MIC_LDOC_RES, n) +#define REG_MIC_LDOC_LOOPCTRL (1 << 0) // 3E PMU_REG_MIC_BIAS_D -#define REG_MIC_BIASD_CHANSEL_SHIFT 14 -#define REG_MIC_BIASD_CHANSEL_MASK (0x3 << REG_MIC_BIASD_CHANSEL_SHIFT) -#define REG_MIC_BIASD_CHANSEL(n) BITFIELD_VAL(REG_MIC_BIASD_CHANSEL, n) -#define REG_MIC_BIASD_EN (1 << 13) -#define REG_MIC_BIASD_ENLPF (1 << 12) -#define REG_MIC_BIASD_LPFSEL_SHIFT 10 -#define REG_MIC_BIASD_LPFSEL_MASK (0x3 << REG_MIC_BIASD_LPFSEL_SHIFT) -#define REG_MIC_BIASD_LPFSEL(n) BITFIELD_VAL(REG_MIC_BIASD_LPFSEL, n) -#define REG_MIC_BIASD_VSEL_SHIFT 5 -#define REG_MIC_BIASD_VSEL_MASK (0x1F << REG_MIC_BIASD_VSEL_SHIFT) -#define REG_MIC_BIASD_VSEL(n) BITFIELD_VAL(REG_MIC_BIASD_VSEL, n) -#define REG_MIC_LDOD_RES_SHIFT 1 -#define REG_MIC_LDOD_RES_MASK (0xF << REG_MIC_LDOD_RES_SHIFT) -#define REG_MIC_LDOD_RES(n) BITFIELD_VAL(REG_MIC_LDOD_RES, n) -#define REG_MIC_LDOD_LOOPCTRL (1 << 0) +#define REG_MIC_BIASD_CHANSEL_SHIFT 14 +#define REG_MIC_BIASD_CHANSEL_MASK (0x3 << REG_MIC_BIASD_CHANSEL_SHIFT) +#define REG_MIC_BIASD_CHANSEL(n) BITFIELD_VAL(REG_MIC_BIASD_CHANSEL, n) +#define REG_MIC_BIASD_EN (1 << 13) +#define REG_MIC_BIASD_ENLPF (1 << 12) +#define REG_MIC_BIASD_LPFSEL_SHIFT 10 +#define REG_MIC_BIASD_LPFSEL_MASK (0x3 << REG_MIC_BIASD_LPFSEL_SHIFT) +#define REG_MIC_BIASD_LPFSEL(n) BITFIELD_VAL(REG_MIC_BIASD_LPFSEL, n) +#define REG_MIC_BIASD_VSEL_SHIFT 5 +#define REG_MIC_BIASD_VSEL_MASK (0x1F << REG_MIC_BIASD_VSEL_SHIFT) +#define REG_MIC_BIASD_VSEL(n) BITFIELD_VAL(REG_MIC_BIASD_VSEL, n) +#define REG_MIC_LDOD_RES_SHIFT 1 +#define REG_MIC_LDOD_RES_MASK (0xF << REG_MIC_LDOD_RES_SHIFT) +#define REG_MIC_LDOD_RES(n) BITFIELD_VAL(REG_MIC_LDOD_RES, n) +#define REG_MIC_LDOD_LOOPCTRL (1 << 0) // 3F PMU_REG_EFUSE_CTRL -#define TSMC_EFUSE_A_SHIFT 0 -#define TSMC_EFUSE_A_MASK (0x3F << TSMC_EFUSE_A_SHIFT) -#define TSMC_EFUSE_A(n) BITFIELD_VAL(TSMC_EFUSE_A, n) -#define TSMC_EFUSE_CLK_EN (1 << 8) -#define TSMC_EFUSE_NR (1 << 9) -#define TSMC_EFUSE_MR (1 << 10) -#define MANUAL_MODE (1 << 11) -#define TSMC_EFUSE_PGENB (1 << 12) -#define REG_MARGIN_READ (1 << 13) +#define TSMC_EFUSE_A_SHIFT 0 +#define TSMC_EFUSE_A_MASK (0x3F << TSMC_EFUSE_A_SHIFT) +#define TSMC_EFUSE_A(n) BITFIELD_VAL(TSMC_EFUSE_A, n) +#define TSMC_EFUSE_CLK_EN (1 << 8) +#define TSMC_EFUSE_NR (1 << 9) +#define TSMC_EFUSE_MR (1 << 10) +#define MANUAL_MODE (1 << 11) +#define TSMC_EFUSE_PGENB (1 << 12) +#define REG_MARGIN_READ (1 << 13) // 40 PMU_REG_EFUSE_SEL -#define TSMC_EFUSE_STROBE_TRIG (1 << 0) -#define TSMC_EFUSE_STROBE_WIDTH_SHIFT 1 -#define TSMC_EFUSE_STROBE_WIDTH_MASK (0xFF << TSMC_EFUSE_STROBE_WIDTH_SHIFT) -#define TSMC_EFUSE_STROBE_WIDTH(n) BITFIELD_VAL(TSMC_EFUSE_STROBE_WIDTH, n) -#define REG_READ_STROBE_WIDTH_SHIFT 9 -#define REG_READ_STROBE_WIDTH_MASK (0xF << REG_READ_STROBE_WIDTH_SHIFT) -#define REG_READ_STROBE_WIDTH(n) BITFIELD_VAL(REG_READ_STROBE_WIDTH, n) -#define EFUSE_SEL_SHIFT 13 -#define EFUSE_SEL_MASK (0x7 << EFUSE_SEL_SHIFT) -#define EFUSE_SEL(n) BITFIELD_VAL(EFUSE_SEL, n) +#define TSMC_EFUSE_STROBE_TRIG (1 << 0) +#define TSMC_EFUSE_STROBE_WIDTH_SHIFT 1 +#define TSMC_EFUSE_STROBE_WIDTH_MASK (0xFF << TSMC_EFUSE_STROBE_WIDTH_SHIFT) +#define TSMC_EFUSE_STROBE_WIDTH(n) BITFIELD_VAL(TSMC_EFUSE_STROBE_WIDTH, n) +#define REG_READ_STROBE_WIDTH_SHIFT 9 +#define REG_READ_STROBE_WIDTH_MASK (0xF << REG_READ_STROBE_WIDTH_SHIFT) +#define REG_READ_STROBE_WIDTH(n) BITFIELD_VAL(REG_READ_STROBE_WIDTH, n) +#define EFUSE_SEL_SHIFT 13 +#define EFUSE_SEL_MASK (0x7 << EFUSE_SEL_SHIFT) +#define EFUSE_SEL(n) BITFIELD_VAL(EFUSE_SEL, n) // 41 PMU_REG_DCDC1_OFFSET -#define DCDC1_OFFSET_BIT_SHIFT 8 -#define DCDC1_OFFSET_BIT_MASK (0xFF << DCDC1_OFFSET_BIT_SHIFT) -#define DCDC1_OFFSET_BIT(n) BITFIELD_VAL(DCDC1_OFFSET_BIT, n) -#define DCDC2_OFFSET_BIT_SHIFT 0 -#define DCDC2_OFFSET_BIT_MASK (0xFF << DCDC2_OFFSET_BIT_SHIFT) -#define DCDC2_OFFSET_BIT(n) BITFIELD_VAL(DCDC2_OFFSET_BIT, n) +#define DCDC1_OFFSET_BIT_SHIFT 8 +#define DCDC1_OFFSET_BIT_MASK (0xFF << DCDC1_OFFSET_BIT_SHIFT) +#define DCDC1_OFFSET_BIT(n) BITFIELD_VAL(DCDC1_OFFSET_BIT, n) +#define DCDC2_OFFSET_BIT_SHIFT 0 +#define DCDC2_OFFSET_BIT_MASK (0xFF << DCDC2_OFFSET_BIT_SHIFT) +#define DCDC2_OFFSET_BIT(n) BITFIELD_VAL(DCDC2_OFFSET_BIT, n) // 43 PMU_REG_BUCK2ANA_CFG -#define REG_PU_VBUCK2ANA_LDO_DR (1 << 15) -#define REG_PU_VBUCK2ANA_LDO (1 << 14) -#define LP_EN_VBUCK2ANA_LDO_DR (1 << 13) -#define LP_EN_VBUCK2ANA_LDO (1 << 12) -#define LDO_VBUCK2ANA_VBIT_DSLEEP_SHIFT 6 -#define LDO_VBUCK2ANA_VBIT_DSLEEP_MASK (0x3F << LDO_VBUCK2ANA_VBIT_DSLEEP_SHIFT) -#define LDO_VBUCK2ANA_VBIT_DSLEEP(n) BITFIELD_VAL(LDO_VBUCK2ANA_VBIT_DSLEEP, n) -#define LDO_VBUCK2ANA_VBIT_NORMAL_SHIFT 0 -#define LDO_VBUCK2ANA_VBIT_NORMAL_MASK (0x3F << LDO_VBUCK2ANA_VBIT_NORMAL_SHIFT) -#define LDO_VBUCK2ANA_VBIT_NORMAL(n) BITFIELD_VAL(LDO_VBUCK2ANA_VBIT_NORMAL, n) +#define REG_PU_VBUCK2ANA_LDO_DR (1 << 15) +#define REG_PU_VBUCK2ANA_LDO (1 << 14) +#define LP_EN_VBUCK2ANA_LDO_DR (1 << 13) +#define LP_EN_VBUCK2ANA_LDO (1 << 12) +#define LDO_VBUCK2ANA_VBIT_DSLEEP_SHIFT 6 +#define LDO_VBUCK2ANA_VBIT_DSLEEP_MASK (0x3F << LDO_VBUCK2ANA_VBIT_DSLEEP_SHIFT) +#define LDO_VBUCK2ANA_VBIT_DSLEEP(n) BITFIELD_VAL(LDO_VBUCK2ANA_VBIT_DSLEEP, n) +#define LDO_VBUCK2ANA_VBIT_NORMAL_SHIFT 0 +#define LDO_VBUCK2ANA_VBIT_NORMAL_MASK (0x3F << LDO_VBUCK2ANA_VBIT_NORMAL_SHIFT) +#define LDO_VBUCK2ANA_VBIT_NORMAL(n) BITFIELD_VAL(LDO_VBUCK2ANA_VBIT_NORMAL, n) -#define REG_PU_LDO_VBUCK2ANA_DR REG_PU_VBUCK2ANA_LDO_DR -#define REG_PU_LDO_VBUCK2ANA_REG REG_PU_VBUCK2ANA_LDO -#define LP_EN_VBUCK2ANA_LDO_REG LP_EN_VBUCK2ANA_LDO +#define REG_PU_LDO_VBUCK2ANA_DR REG_PU_VBUCK2ANA_LDO_DR +#define REG_PU_LDO_VBUCK2ANA_REG REG_PU_VBUCK2ANA_LDO +#define LP_EN_VBUCK2ANA_LDO_REG LP_EN_VBUCK2ANA_LDO // No pu dsleep cfg -#define REG_PU_LDO_VBUCK2ANA_DSLEEP 0 +#define REG_PU_LDO_VBUCK2ANA_DSLEEP 0 // 44 PMU_REG_SLEEP_CFG -#define PMIC_TMODE_1300_SHIFT 0 -#define PMIC_TMODE_1300_MASK (0x7 << PMIC_TMODE_1300_SHIFT) -#define PMIC_TMODE_1300(n) BITFIELD_VAL(PMIC_TMODE_1300, n) -#define POWERON_PRESS_EN (1 << 3) -#define POWERON_RELEASE_EN (1 << 4) -#define SLEEP_ALLOW (1 << 5) -#define REG_VHPPA2VCODEC_SLP_ON (1 << 6) +#define PMIC_TMODE_1300_SHIFT 0 +#define PMIC_TMODE_1300_MASK (0x7 << PMIC_TMODE_1300_SHIFT) +#define PMIC_TMODE_1300(n) BITFIELD_VAL(PMIC_TMODE_1300, n) +#define POWERON_PRESS_EN (1 << 3) +#define POWERON_RELEASE_EN (1 << 4) +#define SLEEP_ALLOW (1 << 5) +#define REG_VHPPA2VCODEC_SLP_ON (1 << 6) -#define REG_PU_LDO_VHPPA2VCODEC_DSLEEP REG_VHPPA2VCODEC_SLP_ON +#define REG_PU_LDO_VHPPA2VCODEC_DSLEEP REG_VHPPA2VCODEC_SLP_ON // 46 PMU_REG_DCDC_DIG_VOLT -#define REG_DCDC1_VBIT_DSLEEP_SHIFT 8 -#define REG_DCDC1_VBIT_DSLEEP_MASK (0xFF << REG_DCDC1_VBIT_DSLEEP_SHIFT) -#define REG_DCDC1_VBIT_DSLEEP(n) BITFIELD_VAL(REG_DCDC1_VBIT_DSLEEP, n) -#define REG_DCDC1_VBIT_NORMAL_SHIFT 0 -#define REG_DCDC1_VBIT_NORMAL_MASK (0xFF << REG_DCDC1_VBIT_NORMAL_SHIFT) -#define REG_DCDC1_VBIT_NORMAL(n) BITFIELD_VAL(REG_DCDC1_VBIT_NORMAL, n) -#define MAX_DCDC1_VBIT_VAL (REG_DCDC1_VBIT_NORMAL_MASK >> REG_DCDC1_VBIT_NORMAL_SHIFT) +#define REG_DCDC1_VBIT_DSLEEP_SHIFT 8 +#define REG_DCDC1_VBIT_DSLEEP_MASK (0xFF << REG_DCDC1_VBIT_DSLEEP_SHIFT) +#define REG_DCDC1_VBIT_DSLEEP(n) BITFIELD_VAL(REG_DCDC1_VBIT_DSLEEP, n) +#define REG_DCDC1_VBIT_NORMAL_SHIFT 0 +#define REG_DCDC1_VBIT_NORMAL_MASK (0xFF << REG_DCDC1_VBIT_NORMAL_SHIFT) +#define REG_DCDC1_VBIT_NORMAL(n) BITFIELD_VAL(REG_DCDC1_VBIT_NORMAL, n) +#define MAX_DCDC1_VBIT_VAL \ + (REG_DCDC1_VBIT_NORMAL_MASK >> REG_DCDC1_VBIT_NORMAL_SHIFT) // 47 PMU_REG_DCDC_ANA_VOLT -#define REG_DCDC2_VBIT_DSLEEP_SHIFT 8 -#define REG_DCDC2_VBIT_DSLEEP_MASK (0xFF << REG_DCDC2_VBIT_DSLEEP_SHIFT) -#define REG_DCDC2_VBIT_DSLEEP(n) BITFIELD_VAL(REG_DCDC2_VBIT_DSLEEP, n) -#define REG_DCDC2_VBIT_NORMAL_SHIFT 0 -#define REG_DCDC2_VBIT_NORMAL_MASK (0xFF << REG_DCDC2_VBIT_NORMAL_SHIFT) -#define REG_DCDC2_VBIT_NORMAL(n) BITFIELD_VAL(REG_DCDC2_VBIT_NORMAL, n) -#define MAX_DCDC2_VBIT_VAL (REG_DCDC2_VBIT_NORMAL_MASK >> REG_DCDC2_VBIT_NORMAL_SHIFT) +#define REG_DCDC2_VBIT_DSLEEP_SHIFT 8 +#define REG_DCDC2_VBIT_DSLEEP_MASK (0xFF << REG_DCDC2_VBIT_DSLEEP_SHIFT) +#define REG_DCDC2_VBIT_DSLEEP(n) BITFIELD_VAL(REG_DCDC2_VBIT_DSLEEP, n) +#define REG_DCDC2_VBIT_NORMAL_SHIFT 0 +#define REG_DCDC2_VBIT_NORMAL_MASK (0xFF << REG_DCDC2_VBIT_NORMAL_SHIFT) +#define REG_DCDC2_VBIT_NORMAL(n) BITFIELD_VAL(REG_DCDC2_VBIT_NORMAL, n) +#define MAX_DCDC2_VBIT_VAL \ + (REG_DCDC2_VBIT_NORMAL_MASK >> REG_DCDC2_VBIT_NORMAL_SHIFT) // 48 PMU_REG_DCDC_HPPA_VOLT -#define REG_DCDC3_VBIT_DSLEEP_SHIFT 8 -#define REG_DCDC3_VBIT_DSLEEP_MASK (0xFF << REG_DCDC3_VBIT_DSLEEP_SHIFT) -#define REG_DCDC3_VBIT_DSLEEP(n) BITFIELD_VAL(REG_DCDC3_VBIT_DSLEEP, n) -#define REG_DCDC3_VBIT_NORMAL_SHIFT 0 -#define REG_DCDC3_VBIT_NORMAL_MASK (0xFF << REG_DCDC3_VBIT_NORMAL_SHIFT) -#define REG_DCDC3_VBIT_NORMAL(n) BITFIELD_VAL(REG_DCDC3_VBIT_NORMAL, n) -#define MAX_DCDC3_VBIT_VAL (REG_DCDC3_VBIT_NORMAL_MASK >> REG_DCDC3_VBIT_NORMAL_SHIFT) +#define REG_DCDC3_VBIT_DSLEEP_SHIFT 8 +#define REG_DCDC3_VBIT_DSLEEP_MASK (0xFF << REG_DCDC3_VBIT_DSLEEP_SHIFT) +#define REG_DCDC3_VBIT_DSLEEP(n) BITFIELD_VAL(REG_DCDC3_VBIT_DSLEEP, n) +#define REG_DCDC3_VBIT_NORMAL_SHIFT 0 +#define REG_DCDC3_VBIT_NORMAL_MASK (0xFF << REG_DCDC3_VBIT_NORMAL_SHIFT) +#define REG_DCDC3_VBIT_NORMAL(n) BITFIELD_VAL(REG_DCDC3_VBIT_NORMAL, n) +#define MAX_DCDC3_VBIT_VAL \ + (REG_DCDC3_VBIT_NORMAL_MASK >> REG_DCDC3_VBIT_NORMAL_SHIFT) // 49 PMU_REG_DCDC4_VOLT -#define REG_DCDC4_VBIT_DSLEEP_SHIFT 8 -#define REG_DCDC4_VBIT_DSLEEP_MASK (0xFF << REG_DCDC4_VBIT_DSLEEP_SHIFT) -#define REG_DCDC4_VBIT_DSLEEP(n) BITFIELD_VAL(REG_DCDC4_VBIT_DSLEEP, n) -#define REG_DCDC4_VBIT_NORMAL_SHIFT 0 -#define REG_DCDC4_VBIT_NORMAL_MASK (0xFF << REG_DCDC4_VBIT_NORMAL_SHIFT) -#define REG_DCDC4_VBIT_NORMAL(n) BITFIELD_VAL(REG_DCDC4_VBIT_NORMAL, n) +#define REG_DCDC4_VBIT_DSLEEP_SHIFT 8 +#define REG_DCDC4_VBIT_DSLEEP_MASK (0xFF << REG_DCDC4_VBIT_DSLEEP_SHIFT) +#define REG_DCDC4_VBIT_DSLEEP(n) BITFIELD_VAL(REG_DCDC4_VBIT_DSLEEP, n) +#define REG_DCDC4_VBIT_NORMAL_SHIFT 0 +#define REG_DCDC4_VBIT_NORMAL_MASK (0xFF << REG_DCDC4_VBIT_NORMAL_SHIFT) +#define REG_DCDC4_VBIT_NORMAL(n) BITFIELD_VAL(REG_DCDC4_VBIT_NORMAL, n) // 4A PMU_REG_DCDC_ANA_EN -#define REG_DCDC2_PFM_SEL_DSLEEP (1 << 11) -#define REG_DCDC2_PFM_SEL_NORMAL (1 << 10) -#define REG_DCDC2_ULP_MODE_DSLEEP (1 << 9) -#define REG_DCDC2_ULP_MODE_NORMAL (1 << 8) -#define REG_DCDC2_BURST_MODE_SEL_DSLEEP (1 << 7) -#define REG_DCDC2_BURST_MODE_SEL_NORMAL (1 << 6) -#define REG_DCDC2_VREF_SEL_DSLEEP_SHIFT 4 -#define REG_DCDC2_VREF_SEL_DSLEEP_MASK (0x3 << REG_DCDC2_VREF_SEL_DSLEEP_SHIFT) -#define REG_DCDC2_VREF_SEL_DSLEEP(n) BITFIELD_VAL(REG_DCDC2_VREF_SEL_DSLEEP, n) -#define REG_DCDC2_VREF_SEL_NORMAL_SHIFT 2 -#define REG_DCDC2_VREF_SEL_NORMAL_MASK (0x3 << REG_DCDC2_VREF_SEL_NORMAL_SHIFT) -#define REG_DCDC2_VREF_SEL_NORMAL(n) BITFIELD_VAL(REG_DCDC2_VREF_SEL_NORMAL, n) -#define REG_PU_DCDC2_DR (1 << 1) -#define REG_PU_DCDC2 (1 << 0) +#define REG_DCDC2_PFM_SEL_DSLEEP (1 << 11) +#define REG_DCDC2_PFM_SEL_NORMAL (1 << 10) +#define REG_DCDC2_ULP_MODE_DSLEEP (1 << 9) +#define REG_DCDC2_ULP_MODE_NORMAL (1 << 8) +#define REG_DCDC2_BURST_MODE_SEL_DSLEEP (1 << 7) +#define REG_DCDC2_BURST_MODE_SEL_NORMAL (1 << 6) +#define REG_DCDC2_VREF_SEL_DSLEEP_SHIFT 4 +#define REG_DCDC2_VREF_SEL_DSLEEP_MASK (0x3 << REG_DCDC2_VREF_SEL_DSLEEP_SHIFT) +#define REG_DCDC2_VREF_SEL_DSLEEP(n) BITFIELD_VAL(REG_DCDC2_VREF_SEL_DSLEEP, n) +#define REG_DCDC2_VREF_SEL_NORMAL_SHIFT 2 +#define REG_DCDC2_VREF_SEL_NORMAL_MASK (0x3 << REG_DCDC2_VREF_SEL_NORMAL_SHIFT) +#define REG_DCDC2_VREF_SEL_NORMAL(n) BITFIELD_VAL(REG_DCDC2_VREF_SEL_NORMAL, n) +#define REG_PU_DCDC2_DR (1 << 1) +#define REG_PU_DCDC2 (1 << 0) // 4B PMU_REG_DCDC_HPPA_EN -#define REG_DCDC3_PFM_SEL_DSLEEP (1 << 11) -#define REG_DCDC3_PFM_SEL_NORMAL (1 << 10) -#define REG_DCDC3_ULP_MODE_DSLEEP (1 << 9) -#define REG_DCDC3_ULP_MODE_NORMAL (1 << 8) -#define REG_DCDC3_BURST_MODE_SEL_DSLEEP (1 << 7) -#define REG_DCDC3_BURST_MODE_SEL_NORMAL (1 << 6) -#define REG_DCDC3_VREF_SEL_DSLEEP_SHIFT 4 -#define REG_DCDC3_VREF_SEL_DSLEEP_MASK (0x3 << REG_DCDC3_VREF_SEL_DSLEEP_SHIFT) -#define REG_DCDC3_VREF_SEL_DSLEEP(n) BITFIELD_VAL(REG_DCDC3_VREF_SEL_DSLEEP, n) -#define REG_DCDC3_VREF_SEL_NORMAL_SHIFT 2 -#define REG_DCDC3_VREF_SEL_NORMAL_MASK (0x3 << REG_DCDC3_VREF_SEL_NORMAL_SHIFT) -#define REG_DCDC3_VREF_SEL_NORMAL(n) BITFIELD_VAL(REG_DCDC3_VREF_SEL_NORMAL, n) -#define REG_PU_DCDC3_DR (1 << 1) -#define REG_PU_DCDC3 (1 << 0) +#define REG_DCDC3_PFM_SEL_DSLEEP (1 << 11) +#define REG_DCDC3_PFM_SEL_NORMAL (1 << 10) +#define REG_DCDC3_ULP_MODE_DSLEEP (1 << 9) +#define REG_DCDC3_ULP_MODE_NORMAL (1 << 8) +#define REG_DCDC3_BURST_MODE_SEL_DSLEEP (1 << 7) +#define REG_DCDC3_BURST_MODE_SEL_NORMAL (1 << 6) +#define REG_DCDC3_VREF_SEL_DSLEEP_SHIFT 4 +#define REG_DCDC3_VREF_SEL_DSLEEP_MASK (0x3 << REG_DCDC3_VREF_SEL_DSLEEP_SHIFT) +#define REG_DCDC3_VREF_SEL_DSLEEP(n) BITFIELD_VAL(REG_DCDC3_VREF_SEL_DSLEEP, n) +#define REG_DCDC3_VREF_SEL_NORMAL_SHIFT 2 +#define REG_DCDC3_VREF_SEL_NORMAL_MASK (0x3 << REG_DCDC3_VREF_SEL_NORMAL_SHIFT) +#define REG_DCDC3_VREF_SEL_NORMAL(n) BITFIELD_VAL(REG_DCDC3_VREF_SEL_NORMAL, n) +#define REG_PU_DCDC3_DR (1 << 1) +#define REG_PU_DCDC3 (1 << 0) // 4C PMU_REG_DCDC4_EN -#define REG_DCDC4_PFM_SEL_DSLEEP (1 << 11) -#define REG_DCDC4_PFM_SEL_NORMAL (1 << 10) -#define REG_DCDC4_ULP_MODE_DSLEEP (1 << 9) -#define REG_DCDC4_ULP_MODE_NORMAL (1 << 8) -#define REG_DCDC4_BURST_MODE_SEL_DSLEEP (1 << 7) -#define REG_DCDC4_BURST_MODE_SEL_NORMAL (1 << 6) -#define REG_DCDC4_VREF_SEL_DSLEEP_SHIFT 4 -#define REG_DCDC4_VREF_SEL_DSLEEP_MASK (0x3 << REG_DCDC4_VREF_SEL_DSLEEP_SHIFT) -#define REG_DCDC4_VREF_SEL_DSLEEP(n) BITFIELD_VAL(REG_DCDC4_VREF_SEL_DSLEEP, n) -#define REG_DCDC4_VREF_SEL_NORMAL_SHIFT 2 -#define REG_DCDC4_VREF_SEL_NORMAL_MASK (0x3 << REG_DCDC4_VREF_SEL_NORMAL_SHIFT) -#define REG_DCDC4_VREF_SEL_NORMAL(n) BITFIELD_VAL(REG_DCDC4_VREF_SEL_NORMAL, n) -#define REG_PU_DCDC4_DR (1 << 1) -#define REG_PU_DCDC4 (1 << 0) +#define REG_DCDC4_PFM_SEL_DSLEEP (1 << 11) +#define REG_DCDC4_PFM_SEL_NORMAL (1 << 10) +#define REG_DCDC4_ULP_MODE_DSLEEP (1 << 9) +#define REG_DCDC4_ULP_MODE_NORMAL (1 << 8) +#define REG_DCDC4_BURST_MODE_SEL_DSLEEP (1 << 7) +#define REG_DCDC4_BURST_MODE_SEL_NORMAL (1 << 6) +#define REG_DCDC4_VREF_SEL_DSLEEP_SHIFT 4 +#define REG_DCDC4_VREF_SEL_DSLEEP_MASK (0x3 << REG_DCDC4_VREF_SEL_DSLEEP_SHIFT) +#define REG_DCDC4_VREF_SEL_DSLEEP(n) BITFIELD_VAL(REG_DCDC4_VREF_SEL_DSLEEP, n) +#define REG_DCDC4_VREF_SEL_NORMAL_SHIFT 2 +#define REG_DCDC4_VREF_SEL_NORMAL_MASK (0x3 << REG_DCDC4_VREF_SEL_NORMAL_SHIFT) +#define REG_DCDC4_VREF_SEL_NORMAL(n) BITFIELD_VAL(REG_DCDC4_VREF_SEL_NORMAL, n) +#define REG_PU_DCDC4_DR (1 << 1) +#define REG_PU_DCDC4 (1 << 0) // 4F PMU_REG_POWER_OFF -#define SOFT_POWER_OFF (1 << 0) -#define HARDWARE_POWER_OFF_EN (1 << 1) -#define AC_ON_EN (1 << 2) -#define RC_CAL_READY (1 << 3) -#define KEY_START (1 << 4) -#define GPADC_START (1 << 5) -#define EFUSE_READ_DONE (1 << 6) -#define EFUSE_READ_BUSY (1 << 7) -#define VBAT_OVP (1 << 8) -#define VCORE_LOW (1 << 9) -#define REG_LED_IO1_DATA_IN (1 << 10) -#define REG_LED_IO2_DATA_IN (1 << 11) -#define RD_EFUSE_REG (1 << 12) -#define REG_WDT_LOAD (1 << 13) +#define SOFT_POWER_OFF (1 << 0) +#define HARDWARE_POWER_OFF_EN (1 << 1) +#define AC_ON_EN (1 << 2) +#define RC_CAL_READY (1 << 3) +#define KEY_START (1 << 4) +#define GPADC_START (1 << 5) +#define EFUSE_READ_DONE (1 << 6) +#define EFUSE_READ_BUSY (1 << 7) +#define VBAT_OVP (1 << 8) +#define VCORE_LOW (1 << 9) +#define REG_LED_IO1_DATA_IN (1 << 10) +#define REG_LED_IO2_DATA_IN (1 << 11) +#define RD_EFUSE_REG (1 << 12) +#define REG_WDT_LOAD (1 << 13) -#define EFUSE_READ_TRIG_SHIFT (12) -#define EFUSE_READ_TRIG_MASK (0xF << EFUSE_READ_TRIG_SHIFT) -#define EFUSE_READ_TRIG(n) BITFIELD_VAL(EFUSE_READ_TRIG, n) -#define EFUSE_READ_TRIG_WORD (0xA) +#define EFUSE_READ_TRIG_SHIFT (12) +#define EFUSE_READ_TRIG_MASK (0xF << EFUSE_READ_TRIG_SHIFT) +#define EFUSE_READ_TRIG(n) BITFIELD_VAL(EFUSE_READ_TRIG, n) +#define EFUSE_READ_TRIG_WORD (0xA) // 52 PMU_REG_INT_STATUS -#define RD_RES1 (1 << 15) -#define RTC_INT_1 (1 << 14) -#define RTC_INT_0 (1 << 13) -#define KEY_ERR1_INTR (1 << 12) -#define KEY_ERR0_INTR (1 << 11) -#define KEY_PRESS_INTR (1 << 10) -#define KEY_RELEASE_INTR (1 << 9) -#define SAMPLE_PERIOD_DONE_INTR (1 << 8) -#define CHAN_DATA_VALID_INTR_SHIFT 0 -#define CHAN_DATA_VALID_INTR_MASK (0xFF << CHAN_DATA_VALID_INTR_SHIFT) -#define CHAN_DATA_VALID_INTR(n) BITFIELD_VAL(CHAN_DATA_VALID_INTR, n) +#define RD_RES1 (1 << 15) +#define RTC_INT_1 (1 << 14) +#define RTC_INT_0 (1 << 13) +#define KEY_ERR1_INTR (1 << 12) +#define KEY_ERR0_INTR (1 << 11) +#define KEY_PRESS_INTR (1 << 10) +#define KEY_RELEASE_INTR (1 << 9) +#define SAMPLE_PERIOD_DONE_INTR (1 << 8) +#define CHAN_DATA_VALID_INTR_SHIFT 0 +#define CHAN_DATA_VALID_INTR_MASK (0xFF << CHAN_DATA_VALID_INTR_SHIFT) +#define CHAN_DATA_VALID_INTR(n) BITFIELD_VAL(CHAN_DATA_VALID_INTR, n) // 53 PMU_REG_INT_MSKED_STATUS // 51 PMU_REG_INT_CLR -#define PMIC_CODEC_PWM (1 << 15) -#define RTC_INT1_MSKED (1 << 14) -#define RTC_INT0_MSKED (1 << 13) -#define KEY_ERR1_INTR_MSKED (1 << 12) -#define KEY_ERR0_INTR_MSKED (1 << 11) -#define KEY_PRESS_INTR_MSKED (1 << 10) -#define KEY_RELEASE_INTR_MSKED (1 << 9) -#define SAMPLE_DONE_INTR_MSKED (1 << 8) -#define CHAN_DATA_INTR_MSKED_SHIFT 0 -#define CHAN_DATA_INTR_MSKED_MASK (0xFF << CHAN_DATA_INTR_MSKED_SHIFT) -#define CHAN_DATA_INTR_MSKED(n) BITFIELD_VAL(CHAN_DATA_INTR_MSKED, n) +#define PMIC_CODEC_PWM (1 << 15) +#define RTC_INT1_MSKED (1 << 14) +#define RTC_INT0_MSKED (1 << 13) +#define KEY_ERR1_INTR_MSKED (1 << 12) +#define KEY_ERR0_INTR_MSKED (1 << 11) +#define KEY_PRESS_INTR_MSKED (1 << 10) +#define KEY_RELEASE_INTR_MSKED (1 << 9) +#define SAMPLE_DONE_INTR_MSKED (1 << 8) +#define CHAN_DATA_INTR_MSKED_SHIFT 0 +#define CHAN_DATA_INTR_MSKED_MASK (0xFF << CHAN_DATA_INTR_MSKED_SHIFT) +#define CHAN_DATA_INTR_MSKED(n) BITFIELD_VAL(CHAN_DATA_INTR_MSKED, n) // 5E PMU_REG_CHARGER_STATUS -#define DIG_PU_VHPPA (1 << 15) -#define DIG_PU_VRTC_RF (1 << 14) -#define DIG_PU_VCODEC (1 << 13) -#define DIG_PU_VUSB (1 << 12) -#define POWER_ON_RELEASE (1 << 11) -#define POWER_ON_PRESS (1 << 10) -#define POWER_ON (1 << 9) -#define DEEPSLEEP_MODE (1 << 8) +#define DIG_PU_VHPPA (1 << 15) +#define DIG_PU_VRTC_RF (1 << 14) +#define DIG_PU_VCODEC (1 << 13) +#define DIG_PU_VUSB (1 << 12) +#define POWER_ON_RELEASE (1 << 11) +#define POWER_ON_PRESS (1 << 10) +#define POWER_ON (1 << 9) +#define DEEPSLEEP_MODE (1 << 8) //#define PMU_LDO_ON (1 << 7) -#define PU_OSC_OUT (1 << 6) -#define UVLO_LV (1 << 5) -#define AC_ON_DET_OUT_MASKED (1 << 4) -#define AC_ON_DET_IN_MASKED (1 << 3) -#define AC_ON (1 << 2) -#define AC_ON_DET_OUT (1 << 1) -#define AC_ON_DET_IN (1 << 0) +#define PU_OSC_OUT (1 << 6) +#define UVLO_LV (1 << 5) +#define AC_ON_DET_OUT_MASKED (1 << 4) +#define AC_ON_DET_IN_MASKED (1 << 3) +#define AC_ON (1 << 2) +#define AC_ON_DET_OUT (1 << 1) +#define AC_ON_DET_IN (1 << 0) // 77 PMU_REG_ANA_77 -#define REG_AUDPLL_DIVN_SHIFT 0 -#define REG_AUDPLL_DIVN_MASK (0x1F << REG_AUDPLL_DIVN_SHIFT) -#define REG_AUDPLL_DIVN(n) BITFIELD_VAL(REG_AUDPLL_DIVN, n) -#define REG_AUDPLL_DIVN_RST (1 << 5) -#define REG_AUDPLL_DIV_DR (1 << 6) -#define REG_AUDPLL_EN_CLKA (1 << 7) -#define REG_AUDPLL_EN_CLKD (1 << 8) -#define REG_AUDPLL_FORCE_LK (1 << 9) -#define REG_AUDPLL_LK_ERR23 (1 << 10) -#define REG_AUDPLL_LK_LONG (1 << 11) -#define REG_AUDPLL_LK_RSTB (1 << 12) -#define REG_AUDPLL_LK_WIN_SHIFT 13 -#define REG_AUDPLL_LK_WIN_MASK (0x7 << REG_AUDPLL_LK_WIN_SHIFT) -#define REG_AUDPLL_LK_WIN(n) BITFIELD_VAL(REG_AUDPLL_LK_WIN, n) +#define REG_AUDPLL_DIVN_SHIFT 0 +#define REG_AUDPLL_DIVN_MASK (0x1F << REG_AUDPLL_DIVN_SHIFT) +#define REG_AUDPLL_DIVN(n) BITFIELD_VAL(REG_AUDPLL_DIVN, n) +#define REG_AUDPLL_DIVN_RST (1 << 5) +#define REG_AUDPLL_DIV_DR (1 << 6) +#define REG_AUDPLL_EN_CLKA (1 << 7) +#define REG_AUDPLL_EN_CLKD (1 << 8) +#define REG_AUDPLL_FORCE_LK (1 << 9) +#define REG_AUDPLL_LK_ERR23 (1 << 10) +#define REG_AUDPLL_LK_LONG (1 << 11) +#define REG_AUDPLL_LK_RSTB (1 << 12) +#define REG_AUDPLL_LK_WIN_SHIFT 13 +#define REG_AUDPLL_LK_WIN_MASK (0x7 << REG_AUDPLL_LK_WIN_SHIFT) +#define REG_AUDPLL_LK_WIN(n) BITFIELD_VAL(REG_AUDPLL_LK_WIN, n) // 101 PMU_REG_DCDC_RAMP_EN -#define REG_MIC_BIASA_IX2 (1 << 15) -#define REG_MIC_BIASB_IX2 (1 << 14) -#define REG_MIC_BIASC_IX2 (1 << 13) -#define REG_MIC_BIASD_IX2 (1 << 12) -#define REG_MIC_BIASE_IX2 (1 << 11) -#define REG_PULLDOWN_VGP (1 << 10) -#define REG_PU_LDO_DIG_DSLEEP (1 << 9) -#define LDO_VHPPA2VCODEC_BYPASS (1 << 8) -#define LDO_VGP_LV_MODE (1 << 7) -#define IPTAT_EN (1 << 6) -#define REG_PU_AVDD25_ANA (1 << 5) -#define REG_DCDC1_RAMP_EN (1 << 4) -#define REG_DCDC2_RAMP_EN (1 << 3) -#define REG_DCDC3_RAMP_EN (1 << 2) -#define REG_PU_VMEM_DELAY_DR (1 << 1) -#define REG_PU_VMEM_DELAY (1 << 0) +#define REG_MIC_BIASA_IX2 (1 << 15) +#define REG_MIC_BIASB_IX2 (1 << 14) +#define REG_MIC_BIASC_IX2 (1 << 13) +#define REG_MIC_BIASD_IX2 (1 << 12) +#define REG_MIC_BIASE_IX2 (1 << 11) +#define REG_PULLDOWN_VGP (1 << 10) +#define REG_PU_LDO_DIG_DSLEEP (1 << 9) +#define LDO_VHPPA2VCODEC_BYPASS (1 << 8) +#define LDO_VGP_LV_MODE (1 << 7) +#define IPTAT_EN (1 << 6) +#define REG_PU_AVDD25_ANA (1 << 5) +#define REG_DCDC1_RAMP_EN (1 << 4) +#define REG_DCDC2_RAMP_EN (1 << 3) +#define REG_DCDC3_RAMP_EN (1 << 2) +#define REG_PU_VMEM_DELAY_DR (1 << 1) +#define REG_PU_VMEM_DELAY (1 << 0) // 107 PMU_REG_SUBCNT_DATA -#define SUBCNT_DATA2_SHIFT 8 -#define SUBCNT_DATA2_MASK (0xFF << SUBCNT_DATA2_SHIFT) -#define SUBCNT_DATA2(n) BITFIELD_VAL(SUBCNT_DATA2, n) -#define SUBCNT_DATA3_SHIFT 0 -#define SUBCNT_DATA3_MASK (0xFF << SUBCNT_DATA3_SHIFT) -#define SUBCNT_DATA3(n) BITFIELD_VAL(SUBCNT_DATA3, n) +#define SUBCNT_DATA2_SHIFT 8 +#define SUBCNT_DATA2_MASK (0xFF << SUBCNT_DATA2_SHIFT) +#define SUBCNT_DATA2(n) BITFIELD_VAL(SUBCNT_DATA2, n) +#define SUBCNT_DATA3_SHIFT 0 +#define SUBCNT_DATA3_MASK (0xFF << SUBCNT_DATA3_SHIFT) +#define SUBCNT_DATA3(n) BITFIELD_VAL(SUBCNT_DATA3, n) // 108 PMU_REG_PWM_BR_EN -#define TG_SUBCNT_D2_ST_SHIFT 9 -#define TG_SUBCNT_D2_ST_MASK (0x7F << TG_SUBCNT_D2_ST_SHIFT) -#define TG_SUBCNT_D2_ST(n) BITFIELD_VAL(TG_SUBCNT_D2_ST, n) -#define REG_PWM2_BR_EN (1 << 8) -#define TG_SUBCNT_D3_ST_SHIFT 1 -#define TG_SUBCNT_D3_ST_MASK (0x7F << TG_SUBCNT_D3_ST_SHIFT) -#define TG_SUBCNT_D3_ST(n) BITFIELD_VAL(TG_SUBCNT_D3_ST, n) -#define REG_PWM3_BR_EN (1 << 0) +#define TG_SUBCNT_D2_ST_SHIFT 9 +#define TG_SUBCNT_D2_ST_MASK (0x7F << TG_SUBCNT_D2_ST_SHIFT) +#define TG_SUBCNT_D2_ST(n) BITFIELD_VAL(TG_SUBCNT_D2_ST, n) +#define REG_PWM2_BR_EN (1 << 8) +#define TG_SUBCNT_D3_ST_SHIFT 1 +#define TG_SUBCNT_D3_ST_MASK (0x7F << TG_SUBCNT_D3_ST_SHIFT) +#define TG_SUBCNT_D3_ST(n) BITFIELD_VAL(TG_SUBCNT_D3_ST, n) +#define REG_PWM3_BR_EN (1 << 0) // 109 PMU_REG_PWM_EN -#define REG_LED0_OUT (1 << 15) -#define REG_LED1_OUT (1 << 14) -#define PWM_SELECT_EN_SHIFT 12 -#define PWM_SELECT_EN_MASK (0x3 << PWM_SELECT_EN_SHIFT) -#define PWM_SELECT_EN(n) BITFIELD_VAL(PWM_SELECT_EN, n) -#define PWM_SELECT_INV_SHIFT 10 -#define PWM_SELECT_INV_MASK (0x3 << PWM_SELECT_INV_SHIFT) -#define PWM_SELECT_INV(n) BITFIELD_VAL(PWM_SELECT_INV, n) -#define REG_CLK_PWM_DIV_SHIFT 5 -#define REG_CLK_PWM_DIV_MASK (0x1F << REG_CLK_PWM_DIV_SHIFT) -#define REG_CLK_PWM_DIV(n) BITFIELD_VAL(REG_CLK_PWM_DIV, n) +#define REG_LED0_OUT (1 << 15) +#define REG_LED1_OUT (1 << 14) +#define PWM_SELECT_EN_SHIFT 12 +#define PWM_SELECT_EN_MASK (0x3 << PWM_SELECT_EN_SHIFT) +#define PWM_SELECT_EN(n) BITFIELD_VAL(PWM_SELECT_EN, n) +#define PWM_SELECT_INV_SHIFT 10 +#define PWM_SELECT_INV_MASK (0x3 << PWM_SELECT_INV_SHIFT) +#define PWM_SELECT_INV(n) BITFIELD_VAL(PWM_SELECT_INV, n) +#define REG_CLK_PWM_DIV_SHIFT 5 +#define REG_CLK_PWM_DIV_MASK (0x1F << REG_CLK_PWM_DIV_SHIFT) +#define REG_CLK_PWM_DIV(n) BITFIELD_VAL(REG_CLK_PWM_DIV, n) // 10B PMU_REG_WDT_TIMER -#define REG_WDT_TIMER_SHIFT 0 -#define REG_WDT_TIMER_MASK (0xFFFF << REG_WDT_TIMER_SHIFT) -#define REG_WDT_TIMER(n) BITFIELD_VAL(REG_WDT_TIMER, n) +#define REG_WDT_TIMER_SHIFT 0 +#define REG_WDT_TIMER_MASK (0xFFFF << REG_WDT_TIMER_SHIFT) +#define REG_WDT_TIMER(n) BITFIELD_VAL(REG_WDT_TIMER, n) // 10C PMU_REG_WDT_CFG -#define REG_HW_RESET_TIME_SHIFT 10 -#define REG_HW_RESET_TIME_MASK (0x3F << REG_HW_RESET_TIME_SHIFT) -#define REG_HW_RESET_TIME(n) BITFIELD_VAL(REG_HW_RESET_TIME, n) -#define REG_HW_RESET_EN (1 << 9) -#define REG_WDT_RESET_EN (1 << 8) -#define REG_WDT_EN (1 << 7) -#define BG_R_TEMP_SHIFT 4 -#define BG_R_TEMP_MASK (0x7 << BG_R_TEMP_SHIFT) -#define BG_R_TEMP(n) BITFIELD_VAL(BG_R_TEMP, n) -#define BG_TRIM_VBG_SHIFT 1 -#define BG_TRIM_VBG_MASK (0x7 << BG_TRIM_VBG_SHIFT) -#define BG_TRIM_VBG(n) BITFIELD_VAL(BG_TRIM_VBG, n) -#define SAR_PU_OVP (1 << 0) +#define REG_HW_RESET_TIME_SHIFT 10 +#define REG_HW_RESET_TIME_MASK (0x3F << REG_HW_RESET_TIME_SHIFT) +#define REG_HW_RESET_TIME(n) BITFIELD_VAL(REG_HW_RESET_TIME, n) +#define REG_HW_RESET_EN (1 << 9) +#define REG_WDT_RESET_EN (1 << 8) +#define REG_WDT_EN (1 << 7) +#define BG_R_TEMP_SHIFT 4 +#define BG_R_TEMP_MASK (0x7 << BG_R_TEMP_SHIFT) +#define BG_R_TEMP(n) BITFIELD_VAL(BG_R_TEMP, n) +#define BG_TRIM_VBG_SHIFT 1 +#define BG_TRIM_VBG_MASK (0x7 << BG_TRIM_VBG_SHIFT) +#define BG_TRIM_VBG(n) BITFIELD_VAL(BG_TRIM_VBG, n) +#define SAR_PU_OVP (1 << 0) // 80 PMU_REG_RF_80 -#define RF_80_PAGE_IDX (1 << 15) -#define RF_80_S_DONE_SHIFT 4 -#define RF_80_S_DONE_MASK (0x7FF << RF_80_S_DONE_SHIFT) -#define RF_80_S_DONE(n) BITFIELD_VAL(RF_80_S_DONE, n) -#define RF_80_REVID_SHIFT 0 -#define RF_80_REVID_MASK (0xF << RF_80_REVID_SHIFT) -#define RF_80_REVID(n) BITFIELD_VAL(RF_80_REVID, n) +#define RF_80_PAGE_IDX (1 << 15) +#define RF_80_S_DONE_SHIFT 4 +#define RF_80_S_DONE_MASK (0x7FF << RF_80_S_DONE_SHIFT) +#define RF_80_S_DONE(n) BITFIELD_VAL(RF_80_S_DONE, n) +#define RF_80_REVID_SHIFT 0 +#define RF_80_REVID_MASK (0xF << RF_80_REVID_SHIFT) +#define RF_80_REVID(n) BITFIELD_VAL(RF_80_REVID, n) // BD PMU_REG_RF_BD -#define REG_BBPLL_FREQ_34_32_SHIFT 0 -#define REG_BBPLL_FREQ_34_32_MASK (0x7 << REG_BBPLL_FREQ_34_32_SHIFT) -#define REG_BBPLL_FREQ_34_32(n) BITFIELD_VAL(REG_BBPLL_FREQ_34_32, n) -#define REG_BBPLL_FREQ_EN (1 << 3) +#define REG_BBPLL_FREQ_34_32_SHIFT 0 +#define REG_BBPLL_FREQ_34_32_MASK (0x7 << REG_BBPLL_FREQ_34_32_SHIFT) +#define REG_BBPLL_FREQ_34_32(n) BITFIELD_VAL(REG_BBPLL_FREQ_34_32, n) +#define REG_BBPLL_FREQ_EN (1 << 3) enum PMU_REG_T { - PMU_REG_METAL_ID = 0x00, - PMU_REG_POWER_KEY_CFG = 0x02, - PMU_REG_BIAS_CFG = 0x03, - PMU_REG_CHARGER_CFG = 0x05, - PMU_REG_ANA_CFG = 0x07, - PMU_REG_DIG_CFG = 0x08, - PMU_REG_IO_CFG = 0x09, - PMU_REG_MEM_CFG = 0x0A, - PMU_REG_GP_CFG = 0x0B, - PMU_REG_USB_CFG = 0x0C, - PMU_REG_BAT2DIG_CFG = 0x0D, - PMU_REG_HPPA_LDO_EN = 0x0E, - PMU_REG_HPPA2CODEC_CFG = 0x0F, - PMU_REG_CODEC_CFG = 0x10, - PMU_REG_DCDC_DIG_EN = 0x15, - PMU_REG_DCDC_ANA_CFG_16 = 0x16, - PMU_REG_DCDC_ANA_CFG_17 = 0x17, - PMU_REG_DCDC_ANA_CFG_18 = 0x18, - PMU_REG_DCDC_ANA_CFG_19 = 0x19, - PMU_REG_DCDC_HPPA_CFG_1A = 0x1A, - PMU_REG_DCDC_HPPA_CFG_1B = 0x1B, - PMU_REG_DCDC_HPPA_CFG_1C = 0x1C, - PMU_REG_DCDC_HPPA_CFG_1D = 0x1D, - PMU_REG_PWR_SEL = 0x21, - PMU_REG_INT_MASK = 0x26, - PMU_REG_INT_EN = 0x27, - PMU_REG_RTC_LOAD_LOW = 0x2D, - PMU_REG_RTC_LOAD_HIGH = 0x2E, - PMU_REG_RTC_MATCH1_LOW = 0x31, - PMU_REG_RTC_MATCH1_HIGH = 0x32, - PMU_REG_DCDC_DIG_CFG_33 = 0x33, - PMU_REG_DCDC_DIG_CFG_34 = 0x34, - PMU_REG_DCDC_DIG_CFG_35 = 0x35, - PMU_REG_DCDC_DIG_CFG_36 = 0x36, - PMU_REG_RTC_DIV_1HZ = 0x37, - PMU_REG_MIC_BIAS_E = 0x38, - PMU_REG_MIC_LDO_EN = 0x39, - PMU_REG_LED_CFG = 0x3A, - PMU_REG_MIC_BIAS_A = 0x3B, - PMU_REG_MIC_BIAS_B = 0x3C, - PMU_REG_MIC_BIAS_C = 0x3D, - PMU_REG_MIC_BIAS_D = 0x3E, - PMU_REG_EFUSE_CTRL = 0x3F, - PMU_REG_EFUSE_SEL = 0x40, - PMU_REG_DCDC1_OFFSET = 0x41, - PMU_REG_BUCK2ANA_CFG = 0x43, - PMU_REG_SLEEP_CFG = 0x44, - PMU_REG_DCDC_DIG_VOLT = 0x46, - PMU_REG_DCDC_ANA_VOLT = 0x47, - PMU_REG_DCDC_HPPA_VOLT = 0x48, - PMU_REG_DCDC4_VOLT = 0x49, - PMU_REG_DCDC_ANA_EN = 0x4A, - PMU_REG_DCDC_HPPA_EN = 0x4B, - PMU_REG_POWER_OFF = 0x4F, - PMU_REG_INT_CLR = 0x51, - PMU_REG_INT_STATUS = 0x52, - PMU_REG_INT_MSKED_STATUS = 0x53, - PMU_REG_RTC_VAL_LOW = 0x54, - PMU_REG_RTC_VAL_HIGH = 0x55, - PMU_REG_CHARGER_STATUS = 0x5E, + PMU_REG_METAL_ID = 0x00, + PMU_REG_POWER_KEY_CFG = 0x02, + PMU_REG_BIAS_CFG = 0x03, + PMU_REG_CHARGER_CFG = 0x05, + PMU_REG_ANA_CFG = 0x07, + PMU_REG_DIG_CFG = 0x08, + PMU_REG_IO_CFG = 0x09, + PMU_REG_MEM_CFG = 0x0A, + PMU_REG_GP_CFG = 0x0B, + PMU_REG_USB_CFG = 0x0C, + PMU_REG_BAT2DIG_CFG = 0x0D, + PMU_REG_HPPA_LDO_EN = 0x0E, + PMU_REG_HPPA2CODEC_CFG = 0x0F, + PMU_REG_CODEC_CFG = 0x10, + PMU_REG_DCDC_DIG_EN = 0x15, + PMU_REG_DCDC_ANA_CFG_16 = 0x16, + PMU_REG_DCDC_ANA_CFG_17 = 0x17, + PMU_REG_DCDC_ANA_CFG_18 = 0x18, + PMU_REG_DCDC_ANA_CFG_19 = 0x19, + PMU_REG_DCDC_HPPA_CFG_1A = 0x1A, + PMU_REG_DCDC_HPPA_CFG_1B = 0x1B, + PMU_REG_DCDC_HPPA_CFG_1C = 0x1C, + PMU_REG_DCDC_HPPA_CFG_1D = 0x1D, + PMU_REG_PWR_SEL = 0x21, + PMU_REG_INT_MASK = 0x26, + PMU_REG_INT_EN = 0x27, + PMU_REG_RTC_LOAD_LOW = 0x2D, + PMU_REG_RTC_LOAD_HIGH = 0x2E, + PMU_REG_RTC_MATCH1_LOW = 0x31, + PMU_REG_RTC_MATCH1_HIGH = 0x32, + PMU_REG_DCDC_DIG_CFG_33 = 0x33, + PMU_REG_DCDC_DIG_CFG_34 = 0x34, + PMU_REG_DCDC_DIG_CFG_35 = 0x35, + PMU_REG_DCDC_DIG_CFG_36 = 0x36, + PMU_REG_RTC_DIV_1HZ = 0x37, + PMU_REG_MIC_BIAS_E = 0x38, + PMU_REG_MIC_LDO_EN = 0x39, + PMU_REG_LED_CFG = 0x3A, + PMU_REG_MIC_BIAS_A = 0x3B, + PMU_REG_MIC_BIAS_B = 0x3C, + PMU_REG_MIC_BIAS_C = 0x3D, + PMU_REG_MIC_BIAS_D = 0x3E, + PMU_REG_EFUSE_CTRL = 0x3F, + PMU_REG_EFUSE_SEL = 0x40, + PMU_REG_DCDC1_OFFSET = 0x41, + PMU_REG_BUCK2ANA_CFG = 0x43, + PMU_REG_SLEEP_CFG = 0x44, + PMU_REG_DCDC_DIG_VOLT = 0x46, + PMU_REG_DCDC_ANA_VOLT = 0x47, + PMU_REG_DCDC_HPPA_VOLT = 0x48, + PMU_REG_DCDC4_VOLT = 0x49, + PMU_REG_DCDC_ANA_EN = 0x4A, + PMU_REG_DCDC_HPPA_EN = 0x4B, + PMU_REG_POWER_OFF = 0x4F, + PMU_REG_INT_CLR = 0x51, + PMU_REG_INT_STATUS = 0x52, + PMU_REG_INT_MSKED_STATUS = 0x53, + PMU_REG_RTC_VAL_LOW = 0x54, + PMU_REG_RTC_VAL_HIGH = 0x55, + PMU_REG_CHARGER_STATUS = 0x5E, - PMU_REG_DCDC_RAMP_EN = 0x101, + PMU_REG_DCDC_RAMP_EN = 0x101, - PMU_REG_PWM2_TOGGLE = 0x103, - PMU_REG_PWM3_TOGGLE = 0x104, - PMU_REG_PWM2_ST1 = 0x105, - PMU_REG_PWM3_ST1 = 0x106, - PMU_REG_SUBCNT_DATA = 0x107, - PMU_REG_PWM_BR_EN = 0x108, - PMU_REG_PWM_EN = 0x109, + PMU_REG_PWM2_TOGGLE = 0x103, + PMU_REG_PWM3_TOGGLE = 0x104, + PMU_REG_PWM2_ST1 = 0x105, + PMU_REG_PWM3_ST1 = 0x106, + PMU_REG_SUBCNT_DATA = 0x107, + PMU_REG_PWM_BR_EN = 0x108, + PMU_REG_PWM_EN = 0x109, - PMU_REG_WDT_TIMER = 0x10B, - PMU_REG_WDT_CFG = 0x10C, + PMU_REG_WDT_TIMER = 0x10B, + PMU_REG_WDT_CFG = 0x10C, - PMU_REG_MODULE_START = PMU_REG_ANA_CFG, - PMU_REG_EFUSE_VAL_START = 0x148, + PMU_REG_MODULE_START = PMU_REG_ANA_CFG, + PMU_REG_EFUSE_VAL_START = 0x148, - PMU_REG_ANA_60 = 0x60, - PMU_REG_ANA_77 = 0x77, + PMU_REG_ANA_60 = 0x60, + PMU_REG_ANA_77 = 0x77, - PMU_REG_RF_80 = 0x80, - PMU_REG_RF_B5 = 0xB5, - PMU_REG_RF_BB = 0xBB, - PMU_REG_RF_BC = 0xBC, - PMU_REG_RF_BD = 0xBD, + PMU_REG_RF_80 = 0x80, + PMU_REG_RF_B5 = 0xB5, + PMU_REG_RF_BB = 0xBB, + PMU_REG_RF_BC = 0xBC, + PMU_REG_RF_BD = 0xBD, }; enum PMU_VCORE_REQ_T { - PMU_VCORE_FLASH_WRITE_ENABLED = (1 << 0), - PMU_VCORE_FLASH_FREQ_HIGH = (1 << 1), - PMU_VCORE_PSRAM_FREQ_HIGH = (1 << 2), - PMU_VCORE_USB_HS_ENABLED = (1 << 3), - PMU_VCORE_RS_FREQ_HIGH = (1 << 4), - PMU_VCORE_SYS_FREQ_MEDIUM = (1 << 5), - PMU_VCORE_SYS_FREQ_HIGH = (1 << 6), + PMU_VCORE_FLASH_WRITE_ENABLED = (1 << 0), + PMU_VCORE_FLASH_FREQ_HIGH = (1 << 1), + PMU_VCORE_PSRAM_FREQ_HIGH = (1 << 2), + PMU_VCORE_USB_HS_ENABLED = (1 << 3), + PMU_VCORE_RS_FREQ_HIGH = (1 << 4), + PMU_VCORE_SYS_FREQ_MEDIUM = (1 << 5), + PMU_VCORE_SYS_FREQ_HIGH = (1 << 6), }; enum PMU_VUSB_REQ_T { - PMU_VUSB_REQ_INIT = (1 << 0), - PMU_VUSB_REQ_USB = (1 << 1), - PMU_VUSB_REQ_LBRT = (1 << 2), + PMU_VUSB_REQ_INIT = (1 << 0), + PMU_VUSB_REQ_USB = (1 << 1), + PMU_VUSB_REQ_LBRT = (1 << 2), }; union BOOT_SETTINGS_T { - struct { - unsigned short usb_dld_dis :1; - unsigned short uart_dld_en :1; - unsigned short uart_trace_en :1; - unsigned short pll_dis :1; - unsigned short uart_baud_div2 :1; - unsigned short sec_freq_div2 :1; - unsigned short crystal_freq :2; - unsigned short reserved :4; - unsigned short chksum :4; - }; - unsigned short reg; + struct { + unsigned short usb_dld_dis : 1; + unsigned short uart_dld_en : 1; + unsigned short uart_trace_en : 1; + unsigned short pll_dis : 1; + unsigned short uart_baud_div2 : 1; + unsigned short sec_freq_div2 : 1; + unsigned short crystal_freq : 2; + unsigned short reserved : 4; + unsigned short chksum : 4; + }; + unsigned short reg; }; enum PMU_MODUAL_T { - PMU_ANA, - PMU_DIG, - PMU_IO, - PMU_MEM, - PMU_GP, - PMU_USB, - PMU_BAT2DIG, - PMU_HPPA2CODEC, - PMU_CODEC, - PMU_BUCK2ANA, + PMU_ANA, + PMU_DIG, + PMU_IO, + PMU_MEM, + PMU_GP, + PMU_USB, + PMU_BAT2DIG, + PMU_HPPA2CODEC, + PMU_CODEC, + PMU_BUCK2ANA, }; struct PMU_MODULE_CFG_T { - unsigned short pu_dr; - unsigned short pu; - unsigned short lp_en_dr; - unsigned short lp_en; - unsigned short pu_dsleep; - unsigned short vbit_dsleep_mask; - unsigned short vbit_dsleep_shift; - unsigned short vbit_normal_mask; - unsigned short vbit_normal_shift; + unsigned short pu_dr; + unsigned short pu; + unsigned short lp_en_dr; + unsigned short lp_en; + unsigned short pu_dsleep; + unsigned short vbit_dsleep_mask; + unsigned short vbit_dsleep_shift; + unsigned short vbit_normal_mask; + unsigned short vbit_normal_shift; }; -#define PMU_MOD_CFG_VAL(m) { \ - REG_PU_LDO_V##m##_DR, REG_PU_LDO_V##m##_REG, \ - LP_EN_V##m##_LDO_DR, LP_EN_V##m##_LDO_REG, \ - REG_PU_LDO_V##m##_DSLEEP, \ - LDO_V##m##_VBIT_DSLEEP_MASK, LDO_V##m##_VBIT_DSLEEP_SHIFT, \ - LDO_V##m##_VBIT_NORMAL_MASK, LDO_V##m##_VBIT_NORMAL_SHIFT } +#define PMU_MOD_CFG_VAL(m) \ + { \ + REG_PU_LDO_V##m##_DR, REG_PU_LDO_V##m##_REG, LP_EN_V##m##_LDO_DR, \ + LP_EN_V##m##_LDO_REG, REG_PU_LDO_V##m##_DSLEEP, \ + LDO_V##m##_VBIT_DSLEEP_MASK, LDO_V##m##_VBIT_DSLEEP_SHIFT, \ + LDO_V##m##_VBIT_NORMAL_MASK, LDO_V##m##_VBIT_NORMAL_SHIFT \ + } static const struct PMU_MODULE_CFG_T pmu_module_cfg[] = { - PMU_MOD_CFG_VAL(ANA), - PMU_MOD_CFG_VAL(CORE), - PMU_MOD_CFG_VAL(IO), - PMU_MOD_CFG_VAL(MEM), - PMU_MOD_CFG_VAL(GP), - PMU_MOD_CFG_VAL(USB), - PMU_MOD_CFG_VAL(BAT2VCORE), - PMU_MOD_CFG_VAL(HPPA2VCODEC), - PMU_MOD_CFG_VAL(CODEC), - PMU_MOD_CFG_VAL(BUCK2ANA), + PMU_MOD_CFG_VAL(ANA), PMU_MOD_CFG_VAL(CORE), + PMU_MOD_CFG_VAL(IO), PMU_MOD_CFG_VAL(MEM), + PMU_MOD_CFG_VAL(GP), PMU_MOD_CFG_VAL(USB), + PMU_MOD_CFG_VAL(BAT2VCORE), PMU_MOD_CFG_VAL(HPPA2VCODEC), + PMU_MOD_CFG_VAL(CODEC), PMU_MOD_CFG_VAL(BUCK2ANA), }; #ifdef ANC_PROD_TEST #define OPT_TYPE #else -#define OPT_TYPE const +#define OPT_TYPE const #endif static OPT_TYPE bool vcodec_off = @@ -1172,16 +1179,18 @@ static OPT_TYPE uint8_t ana_act_dcdc = #elif defined(VANA_1P35V) PMU_DCDC_ANA_1_35V; #elif defined(VANA_1P4V) - PMU_DCDC_ANA_1_4V; + PMU_DCDC_ANA_1_4V; #elif defined(VANA_1P5V) - PMU_DCDC_ANA_1_5V; + PMU_DCDC_ANA_1_5V; #elif defined(VANA_1P6V) - PMU_DCDC_ANA_1_6V; + PMU_DCDC_ANA_1_6V; #else - PMU_DCDC_ANA_1_3V; + PMU_DCDC_ANA_1_3V; #endif -static OPT_TYPE POSSIBLY_UNUSED uint16_t vcodec_mv = (uint16_t)(VCODEC_VOLT * 1000); -static OPT_TYPE POSSIBLY_UNUSED uint16_t vhppa_mv = (uint16_t)(VHPPA_VOLT * 1000); +static OPT_TYPE POSSIBLY_UNUSED uint16_t vcodec_mv = + (uint16_t)(VCODEC_VOLT * 1000); +static OPT_TYPE POSSIBLY_UNUSED uint16_t vhppa_mv = + (uint16_t)(VHPPA_VOLT * 1000); static enum HAL_CHIP_METAL_ID_T BOOT_BSS_LOC pmu_metal_id; @@ -1201,7 +1210,8 @@ static PMU_CHARGER_IRQ_HANDLER_T charger_irq_handler; static PMU_IRQ_UNIFIED_HANDLER_T pmu_irq_hdlrs[PMU_IRQ_TYPE_QTY]; static uint8_t SRAM_BSS_DEF(vio_risereq_map); -STATIC_ASSERT(sizeof(vio_risereq_map) * 8 >= PMU_VIORISE_REQ_USER_QTY, "vio_risereq_map size too small"); +STATIC_ASSERT(sizeof(vio_risereq_map) * 8 >= PMU_VIORISE_REQ_USER_QTY, + "vio_risereq_map size too small"); static uint8_t SRAM_DATA_DEF(vio_act_normal) = IO_VOLT_ACTIVE_NORMAL; static uint8_t SRAM_DATA_DEF(vio_act_rise) = IO_VOLT_ACTIVE_RISE; @@ -1245,277 +1255,270 @@ static void pmu_hppa_dcdc_to_ldo(void); #if defined(_AUTO_TEST_) static bool at_skip_shutdown = false; -void pmu_at_skip_shutdown(bool enable) -{ - at_skip_shutdown = enable; -} +void pmu_at_skip_shutdown(bool enable) { at_skip_shutdown = enable; } #endif #ifdef RTC_ENABLE struct PMU_RTC_CTX_T { - bool enabled; - bool alarm_set; - uint32_t alarm_val; + bool enabled; + bool alarm_set; + uint32_t alarm_val; }; static struct PMU_RTC_CTX_T BOOT_BSS_LOC rtc_ctx; static PMU_RTC_IRQ_HANDLER_T rtc_irq_handler; -static void BOOT_TEXT_SRAM_LOC pmu_rtc_save_context(void) -{ - if (pmu_rtc_enabled()) { - rtc_ctx.enabled = true; - if (pmu_rtc_alarm_status_set()) { - rtc_ctx.alarm_set = true; - rtc_ctx.alarm_val = pmu_rtc_get_alarm(); - } - } else { - rtc_ctx.enabled = false; +static void BOOT_TEXT_SRAM_LOC pmu_rtc_save_context(void) { + if (pmu_rtc_enabled()) { + rtc_ctx.enabled = true; + if (pmu_rtc_alarm_status_set()) { + rtc_ctx.alarm_set = true; + rtc_ctx.alarm_val = pmu_rtc_get_alarm(); } + } else { + rtc_ctx.enabled = false; + } } -static void pmu_rtc_restore_context(void) -{ - uint32_t rtc_val; +static void pmu_rtc_restore_context(void) { + uint32_t rtc_val; - if (rtc_ctx.enabled) { - pmu_rtc_enable(); - if (rtc_ctx.alarm_set) { - rtc_val = pmu_rtc_get(); - if (rtc_val - rtc_ctx.alarm_val <= 1 || rtc_ctx.alarm_val - rtc_val < 5) { - rtc_ctx.alarm_val = rtc_val + 5; - } - pmu_rtc_set_alarm(rtc_ctx.alarm_val); - } + if (rtc_ctx.enabled) { + pmu_rtc_enable(); + if (rtc_ctx.alarm_set) { + rtc_val = pmu_rtc_get(); + if (rtc_val - rtc_ctx.alarm_val <= 1 || rtc_ctx.alarm_val - rtc_val < 5) { + rtc_ctx.alarm_val = rtc_val + 5; + } + pmu_rtc_set_alarm(rtc_ctx.alarm_val); } + } } #endif #ifdef PMU_DCDC_CALIB union VOLT_COMP_T { - struct VOLT_COMP_FIELD_T { - uint16_t dcdc1_v: 5; //bit[4:0]: 0 ~ 31 - uint16_t dcdc1_f: 1; //bit[5] : 1: negative, 0: positive; - uint16_t dcdc2_v: 4; //bit[9:6]: 0 ~ 15 - uint16_t dcdc2_f: 1; //bit[10] : - uint16_t dcdc3_v: 4; //bit[14:11]: 0 ~ 15 - uint16_t dcdc3_f: 1; //bit[15] - } f; - uint16_t v; + struct VOLT_COMP_FIELD_T { + uint16_t dcdc1_v : 5; // bit[4:0]: 0 ~ 31 + uint16_t dcdc1_f : 1; // bit[5] : 1: negative, 0: positive; + uint16_t dcdc2_v : 4; // bit[9:6]: 0 ~ 15 + uint16_t dcdc2_f : 1; // bit[10] : + uint16_t dcdc3_v : 4; // bit[14:11]: 0 ~ 15 + uint16_t dcdc3_f : 1; // bit[15] + } f; + uint16_t v; }; static int8_t pmu_dcdc_dig_comp = 0; static int8_t pmu_dcdc_ana_comp = 0; static int8_t pmu_dcdc_hppa_comp = 0; -static POSSIBLY_UNUSED void pmu_get_dcdc_calib_value(void) -{ - union VOLT_COMP_T cv; +static POSSIBLY_UNUSED void pmu_get_dcdc_calib_value(void) { + union VOLT_COMP_T cv; - pmu_get_efuse(PMU_EFUSE_PAGE_RESERVED_7, &cv.v); - if (cv.f.dcdc1_f) { //digital - pmu_dcdc_dig_comp = -(int8_t)(cv.f.dcdc1_v); - } else { - pmu_dcdc_dig_comp = (int8_t)(cv.f.dcdc1_v); - } - if (cv.f.dcdc2_f) { //ana - pmu_dcdc_ana_comp = -(int8_t)(cv.f.dcdc2_v); - } else { - pmu_dcdc_ana_comp = (int8_t)(cv.f.dcdc2_v); - } - if (cv.f.dcdc3_f) { //hppa - pmu_dcdc_hppa_comp = -(int8_t)(cv.f.dcdc3_v); - } else { - pmu_dcdc_hppa_comp = (int8_t)(cv.f.dcdc3_v); - } + pmu_get_efuse(PMU_EFUSE_PAGE_RESERVED_7, &cv.v); + if (cv.f.dcdc1_f) { // digital + pmu_dcdc_dig_comp = -(int8_t)(cv.f.dcdc1_v); + } else { + pmu_dcdc_dig_comp = (int8_t)(cv.f.dcdc1_v); + } + if (cv.f.dcdc2_f) { // ana + pmu_dcdc_ana_comp = -(int8_t)(cv.f.dcdc2_v); + } else { + pmu_dcdc_ana_comp = (int8_t)(cv.f.dcdc2_v); + } + if (cv.f.dcdc3_f) { // hppa + pmu_dcdc_hppa_comp = -(int8_t)(cv.f.dcdc3_v); + } else { + pmu_dcdc_hppa_comp = (int8_t)(cv.f.dcdc3_v); + } } -static POSSIBLY_UNUSED unsigned short pmu_reg_val_add(unsigned short val, int delta, unsigned short max) -{ - int result = val + delta; +static POSSIBLY_UNUSED unsigned short +pmu_reg_val_add(unsigned short val, int delta, unsigned short max) { + int result = val + delta; - if (result > max) { - result = max; - } else if (result < 0) { - result = 0; - } + if (result > max) { + result = max; + } else if (result < 0) { + result = 0; + } - return (unsigned short)result; + return (unsigned short)result; } #endif -static unsigned int NOINLINE BOOT_TEXT_SRAM_LOC pmu_count_zeros(unsigned int val, unsigned int bits) -{ - int cnt = 0; - int i; +static unsigned int NOINLINE BOOT_TEXT_SRAM_LOC +pmu_count_zeros(unsigned int val, unsigned int bits) { + int cnt = 0; + int i; - for (i = 0; i < bits; i++) { - if ((val & (1 << i)) == 0) { - cnt++; - } + for (i = 0; i < bits; i++) { + if ((val & (1 << i)) == 0) { + cnt++; } + } - return cnt; + return cnt; } -static int BOOT_TEXT_FLASH_LOC pmu_read_efuse_block(unsigned int block) -{ - int ret; - unsigned short val; - uint32_t start; - uint32_t timeout = MS_TO_TICKS(50); +static int BOOT_TEXT_FLASH_LOC pmu_read_efuse_block(unsigned int block) { + int ret; + unsigned short val; + uint32_t start; + uint32_t timeout = MS_TO_TICKS(50); - val = TSMC_EFUSE_PGENB | TSMC_EFUSE_CLK_EN; - ret = pmu_write(PMU_REG_EFUSE_CTRL, val); - if (ret) { - return ret; - } + val = TSMC_EFUSE_PGENB | TSMC_EFUSE_CLK_EN; + ret = pmu_write(PMU_REG_EFUSE_CTRL, val); + if (ret) { + return ret; + } - val = TSMC_EFUSE_STROBE_WIDTH(20) | REG_READ_STROBE_WIDTH(4) | EFUSE_SEL(block); - ret = pmu_write(PMU_REG_EFUSE_SEL, val); - if (ret) { - return ret; - } + val = + TSMC_EFUSE_STROBE_WIDTH(20) | REG_READ_STROBE_WIDTH(4) | EFUSE_SEL(block); + ret = pmu_write(PMU_REG_EFUSE_SEL, val); + if (ret) { + return ret; + } + ret = pmu_read(PMU_REG_POWER_OFF, &val); + if (ret) { + return ret; + } + val = SET_BITFIELD(val, EFUSE_READ_TRIG, EFUSE_READ_TRIG_WORD); + ret = pmu_write(PMU_REG_POWER_OFF, val); + if (ret) { + return ret; + } + + hal_sys_timer_delay(US_TO_TICKS(500)); + + start = hal_sys_timer_get(); + do { ret = pmu_read(PMU_REG_POWER_OFF, &val); if (ret) { - return ret; + return ret; } - val = SET_BITFIELD(val, EFUSE_READ_TRIG, EFUSE_READ_TRIG_WORD); - ret = pmu_write(PMU_REG_POWER_OFF, val); - if (ret) { - return ret; + if (hal_sys_timer_get() - start > timeout) { + return -2; } + } while ((val & (EFUSE_READ_DONE | EFUSE_READ_BUSY)) != EFUSE_READ_DONE); - hal_sys_timer_delay(US_TO_TICKS(500)); + val = TSMC_EFUSE_PGENB; + ret = pmu_write(PMU_REG_EFUSE_CTRL, val); + if (ret) { + return ret; + } - start = hal_sys_timer_get(); - do { - ret = pmu_read(PMU_REG_POWER_OFF, &val); - if (ret) { - return ret; - } - if (hal_sys_timer_get() - start > timeout) { - return -2; - } - } while ((val & (EFUSE_READ_DONE | EFUSE_READ_BUSY)) != EFUSE_READ_DONE); - - val = TSMC_EFUSE_PGENB; - ret = pmu_write(PMU_REG_EFUSE_CTRL, val); - if (ret) { - return ret; - } - - return 0; + return 0; } -void BOOT_TEXT_FLASH_LOC bbpll_freq_pll_config(uint32_t freq) -{ - int ret; - uint64_t PLL_cfg_val; - uint16_t v[3]; - uint16_t val; - uint32_t crystal = hal_cmu_get_crystal_freq(); +void BOOT_TEXT_FLASH_LOC bbpll_freq_pll_config(uint32_t freq) { + int ret; + uint64_t PLL_cfg_val; + uint16_t v[3]; + uint16_t val; + uint32_t crystal = hal_cmu_get_crystal_freq(); - PLL_cfg_val = ((uint64_t)(1 << 28) * (freq / 2) + crystal / 2) / crystal; - v[0] = PLL_cfg_val & 0xFFFF; - v[1] = (PLL_cfg_val >> 16) & 0xFFFF; - v[2] = (PLL_cfg_val >> 32) & 0xFFFF; + PLL_cfg_val = ((uint64_t)(1 << 28) * (freq / 2) + crystal / 2) / crystal; + v[0] = PLL_cfg_val & 0xFFFF; + v[1] = (PLL_cfg_val >> 16) & 0xFFFF; + v[2] = (PLL_cfg_val >> 32) & 0xFFFF; - ret = pmu_write(PMU_REG_RF_BB, v[0]); - if (ret) { - return; - } + ret = pmu_write(PMU_REG_RF_BB, v[0]); + if (ret) { + return; + } - ret = pmu_write(PMU_REG_RF_BC, v[1]); - if (ret) { - return; - } + ret = pmu_write(PMU_REG_RF_BC, v[1]); + if (ret) { + return; + } - ret = pmu_read(PMU_REG_RF_BD, &val); - if (ret) { - return; - } - val = SET_BITFIELD(val, REG_BBPLL_FREQ_34_32, v[2]) | REG_BBPLL_FREQ_EN; - ret = pmu_write(PMU_REG_RF_BD, val); - if (ret) { - return; - } + ret = pmu_read(PMU_REG_RF_BD, &val); + if (ret) { + return; + } + val = SET_BITFIELD(val, REG_BBPLL_FREQ_34_32, v[2]) | REG_BBPLL_FREQ_EN; + ret = pmu_write(PMU_REG_RF_BD, val); + if (ret) { + return; + } - // Delay at least for 7us - hal_sys_timer_delay(US_TO_TICKS(100)); + // Delay at least for 7us + hal_sys_timer_delay(US_TO_TICKS(100)); } -uint32_t BOOT_TEXT_FLASH_LOC read_hw_metal_id(void) -{ - int ret; - uint16_t val; - uint32_t metal_id; - int i; - union BOOT_SETTINGS_T boot; +uint32_t BOOT_TEXT_FLASH_LOC read_hw_metal_id(void) { + int ret; + uint16_t val; + uint32_t metal_id; + int i; + union BOOT_SETTINGS_T boot; #ifdef RTC_ENABLE - // RTC will be restored in pmu_open() - pmu_rtc_save_context(); + // RTC will be restored in pmu_open() + pmu_rtc_save_context(); #endif - pmu_wdt_save_context(); + pmu_wdt_save_context(); - pmu_charger_save_context(); + pmu_charger_save_context(); - // Reset PMU (to recover from a possible insane state, e.g., ESD reset) - pmu_write(PMU_REG_METAL_ID, 0xCAFE); - pmu_write(PMU_REG_METAL_ID, 0x5FEE); - hal_sys_timer_delay(US_TO_TICKS(500)); + // Reset PMU (to recover from a possible insane state, e.g., ESD reset) + pmu_write(PMU_REG_METAL_ID, 0xCAFE); + pmu_write(PMU_REG_METAL_ID, 0x5FEE); + hal_sys_timer_delay(US_TO_TICKS(500)); #if defined(PMU_FULL_INIT) || (!defined(FPGA) && !defined(PROGRAMMER)) - // Reset RF - pmu_write(PMU_REG_RF_80, 0xCAFE); - pmu_write(PMU_REG_RF_80, 0x5FEE); - hal_sys_timer_delay(US_TO_TICKS(500)); + // Reset RF + pmu_write(PMU_REG_RF_80, 0xCAFE); + pmu_write(PMU_REG_RF_80, 0x5FEE); + hal_sys_timer_delay(US_TO_TICKS(500)); - // Reset ANA - pmu_write(PMU_REG_ANA_60, 0xCAFE); - pmu_write(PMU_REG_ANA_60, 0x5FEE); - hal_sys_timer_delay(US_TO_TICKS(500)); + // Reset ANA + pmu_write(PMU_REG_ANA_60, 0xCAFE); + pmu_write(PMU_REG_ANA_60, 0x5FEE); + hal_sys_timer_delay(US_TO_TICKS(500)); #endif #ifdef __WATCHER_DOG_RESET__ - pmu_wdt_restore_context(); + pmu_wdt_restore_context(); #endif #ifndef EFUSE_BLOCK_NUM -#define EFUSE_BLOCK_NUM 6 +#define EFUSE_BLOCK_NUM 6 #endif - for (i = 0; i < EFUSE_BLOCK_NUM; i++) { - ret = pmu_read_efuse_block(i); - if (ret) { - SAFE_PROGRAM_STOP(); - } - } - - ret = pmu_get_efuse(PMU_EFUSE_PAGE_BOOT, &boot.reg); + for (i = 0; i < EFUSE_BLOCK_NUM; i++) { + ret = pmu_read_efuse_block(i); if (ret) { - boot.reg = 0; - } else { - if (pmu_count_zeros(boot.reg, 12) != boot.chksum) { - boot.reg = 0; - } - } - hal_cmu_set_crystal_freq_index(boot.crystal_freq); - // Update ISPI cfg - ret = hal_analogif_open(); - if (ret) { - SAFE_PROGRAM_STOP(); + SAFE_PROGRAM_STOP(); } + } -#if !defined(FPGA) && !defined(PROGRAMMER) && !defined(MCU_HIGH_PERFORMANCE_MODE) - if (hal_cmu_get_crystal_freq() != hal_cmu_get_default_crystal_freq()) { - // Update bbpll freq after resetting RF and getting crystal freq - bbpll_freq_pll_config(384000000); + ret = pmu_get_efuse(PMU_EFUSE_PAGE_BOOT, &boot.reg); + if (ret) { + boot.reg = 0; + } else { + if (pmu_count_zeros(boot.reg, 12) != boot.chksum) { + boot.reg = 0; } + } + hal_cmu_set_crystal_freq_index(boot.crystal_freq); + // Update ISPI cfg + ret = hal_analogif_open(); + if (ret) { + SAFE_PROGRAM_STOP(); + } + +#if !defined(FPGA) && !defined(PROGRAMMER) && \ + !defined(MCU_HIGH_PERFORMANCE_MODE) + if (hal_cmu_get_crystal_freq() != hal_cmu_get_default_crystal_freq()) { + // Update bbpll freq after resetting RF and getting crystal freq + bbpll_freq_pll_config(384000000); + } #endif #if 0 @@ -1527,182 +1530,175 @@ uint32_t BOOT_TEXT_FLASH_LOC read_hw_metal_id(void) #endif #endif - //enhance xtal drv - pmu_write(0x9d,0x886c); - // Enable 26M doubler (52M) - pmu_write(0xB5, 0x8000); + // enhance xtal drv + pmu_write(0x9d, 0x886c); + // Enable 26M doubler (52M) + pmu_write(0xB5, 0x8000); #ifdef ANA_26M_X4_ENABLE - pmu_write(0xBF, 0x0400); + pmu_write(0xBF, 0x0400); #endif - // Power up bbpll and audpll clk buf - // Clk buf bits: - // 0-rfpll 1-bt_dac 2-codec_resample&audpll_prechr 3-bbpll 4-audpll 5-usbhspll 6-lbrt 7-dig - pmu_read(0xC4, &val); - val &= ~0xFF; - val |= (1 << 2) | (1 << 3) | (1 << 4) | (1 << 7); + // Power up bbpll and audpll clk buf + // Clk buf bits: + // 0-rfpll 1-bt_dac 2-codec_resample&audpll_prechr 3-bbpll 4-audpll 5-usbhspll + // 6-lbrt 7-dig + pmu_read(0xC4, &val); + val &= ~0xFF; + val |= (1 << 2) | (1 << 3) | (1 << 4) | (1 << 7); #if defined(USB_HIGH_SPEED) || defined(USB_USE_USBPLL) - val |= (1 << 5); + val |= (1 << 5); #endif - pmu_write(0xC4, val); + pmu_write(0xC4, val); - // Cfg bbpll - pmu_write(0x9F, 0xC22F); - pmu_write(0xA0, 0x2788); + // Cfg bbpll + pmu_write(0x9F, 0xC22F); + pmu_write(0xA0, 0x2788); - // Cfg audpll - pmu_write(0x79, 0x0011); - pmu_write(0x77, 0x71B1); + // Cfg audpll + pmu_write(0x79, 0x0011); + pmu_write(0x77, 0x71B1); - // Set audpll to 24.576M*17 - pmu_write(0x7C, 0x4F16); - pmu_write(0x7B, 0x011A); - pmu_write(0x7A, 0x2008); + // Set audpll to 24.576M*17 + pmu_write(0x7C, 0x4F16); + pmu_write(0x7B, 0x011A); + pmu_write(0x7A, 0x2008); - // Clear reg_bt_tst_buf_sel_in/out to avoid impacting P00-P03 and P30-P33 pins - pmu_write(0xA2, 0x01C2); + // Clear reg_bt_tst_buf_sel_in/out to avoid impacting P00-P03 and P30-P33 pins + pmu_write(0xA2, 0x01C2); - // Enable SWD debug mode - pmu_read(PMU_REG_SLEEP_CFG, &val); - val = SET_BITFIELD(val, PMIC_TMODE_1300, 2); - pmu_write(PMU_REG_SLEEP_CFG, val); + // Enable SWD debug mode + pmu_read(PMU_REG_SLEEP_CFG, &val); + val = SET_BITFIELD(val, PMIC_TMODE_1300, 2); + pmu_write(PMU_REG_SLEEP_CFG, val); - pmu_read(PMU_REG_METAL_ID, &val); - pmu_metal_id = GET_BITFIELD(val, PMU_METAL_ID); + pmu_read(PMU_REG_METAL_ID, &val); + pmu_metal_id = GET_BITFIELD(val, PMU_METAL_ID); - metal_id = hal_cmu_get_aon_revision_id(); + metal_id = hal_cmu_get_aon_revision_id(); - if (metal_id == HAL_CHIP_METAL_ID_1) { - uint32_t data; + if (metal_id == HAL_CHIP_METAL_ID_1) { + uint32_t data; - hal_psc_bt_enable(); - hal_cmu_bt_clock_enable(); - hal_cmu_bt_reset_clear(); - data = *(volatile uint32_t *)0xA0000004; - hal_cmu_bt_reset_set(); - hal_cmu_bt_clock_disable(); - hal_psc_bt_disable(); + hal_psc_bt_enable(); + hal_cmu_bt_clock_enable(); + hal_cmu_bt_reset_clear(); + data = *(volatile uint32_t *)0xA0000004; + hal_cmu_bt_reset_set(); + hal_cmu_bt_clock_disable(); + hal_psc_bt_disable(); - if (data == 0xA0007471) { - metal_id = HAL_CHIP_METAL_ID_2; - } + if (data == 0xA0007471) { + metal_id = HAL_CHIP_METAL_ID_2; } + } - // Init pll dividers + // Init pll dividers + pmu_read(PMU_REG_ANA_77, &val); + val = SET_BITFIELD(val, REG_AUDPLL_DIVN, audpll_codec_div); + pmu_write(PMU_REG_ANA_77, val); + + return metal_id; +} + +void BOOT_TEXT_SRAM_LOC pmu_pll_div_reset_set(enum HAL_CMU_PLL_T pll) { + uint32_t lock; + uint16_t val; + + lock = int_lock(); + if (pll == HAL_CMU_PLL_AUD) { pmu_read(PMU_REG_ANA_77, &val); + val |= REG_AUDPLL_DIVN_MASK | REG_AUDPLL_DIVN_RST; + pmu_write(PMU_REG_ANA_77, val); + } else if (pll == HAL_CMU_PLL_USB) { + // In fact bbpll +#ifdef AUDIO_USE_BBPLL + // 0xD2, bit13 (reset) + // 0xF5, bit[4:0] (div) +#endif + } else if (pll == HAL_CMU_PLL_QTY) { + // In fact usbhspll + } + int_unlock(lock); +} + +void BOOT_TEXT_SRAM_LOC pmu_pll_div_reset_clear(enum HAL_CMU_PLL_T pll) { + uint32_t lock; + uint16_t val; + + lock = int_lock(); + if (pll == HAL_CMU_PLL_AUD) { + pmu_read(PMU_REG_ANA_77, &val); + val &= ~REG_AUDPLL_DIVN_RST; + pmu_write(PMU_REG_ANA_77, val); val = SET_BITFIELD(val, REG_AUDPLL_DIVN, audpll_codec_div); pmu_write(PMU_REG_ANA_77, val); - - return metal_id; -} - -void BOOT_TEXT_SRAM_LOC pmu_pll_div_reset_set(enum HAL_CMU_PLL_T pll) -{ - uint32_t lock; - uint16_t val; - - lock = int_lock(); - if (pll == HAL_CMU_PLL_AUD) { - pmu_read(PMU_REG_ANA_77, &val); - val |= REG_AUDPLL_DIVN_MASK | REG_AUDPLL_DIVN_RST; - pmu_write(PMU_REG_ANA_77, val); - } else if (pll == HAL_CMU_PLL_USB) { - // In fact bbpll + } else if (pll == HAL_CMU_PLL_USB) { + // In fact bbpll #ifdef AUDIO_USE_BBPLL - // 0xD2, bit13 (reset) - // 0xF5, bit[4:0] (div) #endif - } else if (pll == HAL_CMU_PLL_QTY) { - // In fact usbhspll - } - int_unlock(lock); + } else if (pll == HAL_CMU_PLL_QTY) { + // In fact usbhspll + } + int_unlock(lock); } -void BOOT_TEXT_SRAM_LOC pmu_pll_div_reset_clear(enum HAL_CMU_PLL_T pll) -{ - uint32_t lock; - uint16_t val; +void pmu_pll_div_set(enum HAL_CMU_PLL_T pll, enum PMU_PLL_DIV_TYPE_T type, + uint32_t div) { + uint32_t lock; + uint16_t val; - lock = int_lock(); - if (pll == HAL_CMU_PLL_AUD) { - pmu_read(PMU_REG_ANA_77, &val); - val &= ~REG_AUDPLL_DIVN_RST; - pmu_write(PMU_REG_ANA_77, val); + if (type != PMU_PLL_DIV_CODEC) { + return; + } + + lock = int_lock(); + if (pll == HAL_CMU_PLL_AUD) { + if (div != audpll_codec_div) { + audpll_codec_div = div; + pmu_read(PMU_REG_ANA_77, &val); + val |= REG_AUDPLL_DIVN_MASK; + pmu_write(PMU_REG_ANA_77, val); + if (div != (REG_AUDPLL_DIVN_MASK >> REG_AUDPLL_DIVN_SHIFT)) { val = SET_BITFIELD(val, REG_AUDPLL_DIVN, audpll_codec_div); pmu_write(PMU_REG_ANA_77, val); - } else if (pll == HAL_CMU_PLL_USB) { - // In fact bbpll + } + } + } else if (pll == HAL_CMU_PLL_USB) { + // In fact bbpll #ifdef AUDIO_USE_BBPLL #endif - } else if (pll == HAL_CMU_PLL_QTY) { - // In fact usbhspll - } - int_unlock(lock); -} - -void pmu_pll_div_set(enum HAL_CMU_PLL_T pll, enum PMU_PLL_DIV_TYPE_T type, uint32_t div) -{ - uint32_t lock; - uint16_t val; - - if (type != PMU_PLL_DIV_CODEC) { - return; - } - - lock = int_lock(); - if (pll == HAL_CMU_PLL_AUD) { - if (div != audpll_codec_div) { - audpll_codec_div = div; - pmu_read(PMU_REG_ANA_77, &val); - val |= REG_AUDPLL_DIVN_MASK; - pmu_write(PMU_REG_ANA_77, val); - if (div != (REG_AUDPLL_DIVN_MASK >> REG_AUDPLL_DIVN_SHIFT)) { - val = SET_BITFIELD(val, REG_AUDPLL_DIVN, audpll_codec_div); - pmu_write(PMU_REG_ANA_77, val); - } - } - } else if (pll == HAL_CMU_PLL_USB) { - // In fact bbpll -#ifdef AUDIO_USE_BBPLL -#endif - } else if (pll == HAL_CMU_PLL_QTY) { - // In fact usbhspll - } - int_unlock(lock); + } else if (pll == HAL_CMU_PLL_QTY) { + // In fact usbhspll + } + int_unlock(lock); } #if defined(USE_CYBERON) static uint32_t BOOT_BSS_LOC cyb_hack_efuse_check = 0; -void cyb_efuse_check_enable(int enabled) -{ - cyb_hack_efuse_check = enabled; -} +void cyb_efuse_check_enable(int enabled) { cyb_hack_efuse_check = enabled; } -int cyb_efuse_check_status(void) -{ - return cyb_hack_efuse_check; -} +int cyb_efuse_check_status(void) { return cyb_hack_efuse_check; } #if 1 -int BOOT_TEXT_SRAM_LOC Cyb_pmu_get_efuse(enum PMU_EFUSE_PAGE_T page, unsigned short *efuse) -{ -// PMU_DEBUG_TRACE(2,"page %x, efuse %x", page, efuse); - if(page==0XE){ - *efuse=0x1B9C; - } - if(page==0xF){ - *efuse = 0x098B; - } +int BOOT_TEXT_SRAM_LOC Cyb_pmu_get_efuse(enum PMU_EFUSE_PAGE_T page, + unsigned short *efuse) { + // PMU_DEBUG_TRACE(2,"page %x, efuse %x", page, efuse); + if (page == 0XE) { + *efuse = 0x1B9C; + } + if (page == 0xF) { + *efuse = 0x098B; + } - return 0; + return 0; } #endif #endif -int BOOT_TEXT_SRAM_LOC pmu_get_efuse(enum PMU_EFUSE_PAGE_T page, unsigned short *efuse) -{ - int ret; +int BOOT_TEXT_SRAM_LOC pmu_get_efuse(enum PMU_EFUSE_PAGE_T page, + unsigned short *efuse) { + int ret; //#if defined(USE_CYBERON) #if 0 @@ -1719,544 +1715,570 @@ int BOOT_TEXT_SRAM_LOC pmu_get_efuse(enum PMU_EFUSE_PAGE_T page, unsigned short } #endif - ret = pmu_read(PMU_REG_EFUSE_VAL_START + page, efuse); + ret = pmu_read(PMU_REG_EFUSE_VAL_START + page, efuse); - return ret; + return ret; } -int pmu_get_security_value(union SECURITY_VALUE_T *val) -{ - int ret; +int pmu_get_security_value(union SECURITY_VALUE_T *val) { + int ret; - ret = pmu_get_efuse(PMU_EFUSE_PAGE_SECURITY, &val->reg); - if (ret) { - // Error - goto _no_security; - } - - if (!val->security_en) { - // OK - goto _no_security; - } - ret = 1; - if (pmu_count_zeros(val->key_id, 3) != val->key_chksum) { - // Error - goto _no_security; - } - if (pmu_count_zeros(val->vendor_id, 6) != val->vendor_chksum) { - // Error - goto _no_security; - } - if ((pmu_count_zeros(val->reg, 15) & 1) != val->chksum) { - // Error - goto _no_security; - } + ret = pmu_get_efuse(PMU_EFUSE_PAGE_SECURITY, &val->reg); + if (ret) { + // Error + goto _no_security; + } + if (!val->security_en) { // OK - return 0; + goto _no_security; + } + ret = 1; + if (pmu_count_zeros(val->key_id, 3) != val->key_chksum) { + // Error + goto _no_security; + } + if (pmu_count_zeros(val->vendor_id, 6) != val->vendor_chksum) { + // Error + goto _no_security; + } + if ((pmu_count_zeros(val->reg, 15) & 1) != val->chksum) { + // Error + goto _no_security; + } + + // OK + return 0; _no_security: - val->reg = 0; + val->reg = 0; - return ret; + return ret; } -static void pmu_sys_ctrl(bool shutdown) -{ - uint16_t val; - uint32_t lock = int_lock(); +static void pmu_sys_ctrl(bool shutdown) { + uint16_t val; + uint32_t lock = int_lock(); - PMU_INFO_TRACE_IMM(0, "Start pmu %s", shutdown ? "shutdown" : "reboot"); + PMU_INFO_TRACE_IMM(0, "Start pmu %s", shutdown ? "shutdown" : "reboot"); #if defined(PMU_INIT) || (!defined(FPGA) && !defined(PROGRAMMER)) #if defined(MCU_HIGH_PERFORMANCE_MODE) - // Default vcore might not be high enough to support high performance mode - pmu_high_performance_mode_enable(false); - hal_cmu_sys_set_freq(HAL_CMU_FREQ_26M); + // Default vcore might not be high enough to support high performance mode + pmu_high_performance_mode_enable(false); + hal_cmu_sys_set_freq(HAL_CMU_FREQ_26M); #endif - pmu_hppa_dcdc_to_ldo(); - pmu_mode_change(PMU_POWER_MODE_LDO); - hal_sys_timer_delay(MS_TO_TICKS(1)); + pmu_hppa_dcdc_to_ldo(); + pmu_mode_change(PMU_POWER_MODE_LDO); + hal_sys_timer_delay(MS_TO_TICKS(1)); #endif #ifdef RTC_ENABLE - pmu_rtc_save_context(); + pmu_rtc_save_context(); #endif - // Reset PMU - pmu_write(PMU_REG_METAL_ID, 0xCAFE); - pmu_write(PMU_REG_METAL_ID, 0x5FEE); - hal_sys_timer_delay(4); + // Reset PMU + pmu_write(PMU_REG_METAL_ID, 0xCAFE); + pmu_write(PMU_REG_METAL_ID, 0x5FEE); + hal_sys_timer_delay(4); #ifdef RTC_ENABLE - pmu_rtc_restore_context(); + pmu_rtc_restore_context(); #endif - if (shutdown) { + if (shutdown) { #if defined(_AUTO_TEST_) - if (at_skip_shutdown) { - hal_cmu_sys_reboot(); - return; - } + if (at_skip_shutdown) { + hal_cmu_sys_reboot(); + return; + } #endif #if defined(PMU_INIT) || (!defined(FPGA) && !defined(PROGRAMMER)) - pmu_wdt_config(3*1000,3*1000); - pmu_wdt_start(); - pmu_charger_shutdown_config(); + pmu_wdt_config(3 * 1000, 3 * 1000); + pmu_wdt_start(); + pmu_charger_shutdown_config(); #endif - // Power off - pmu_read(PMU_REG_POWER_OFF,&val); - val |= SOFT_POWER_OFF; - for (int i = 0; i < 100; i++) { - pmu_write(PMU_REG_POWER_OFF,val); - hal_sys_timer_delay(MS_TO_TICKS(5)); - } + // Power off + pmu_read(PMU_REG_POWER_OFF, &val); + val |= SOFT_POWER_OFF; + for (int i = 0; i < 100; i++) { + pmu_write(PMU_REG_POWER_OFF, val); + hal_sys_timer_delay(MS_TO_TICKS(5)); + } - hal_sys_timer_delay(MS_TO_TICKS(50)); + hal_sys_timer_delay(MS_TO_TICKS(50)); - //can't reach here - PMU_INFO_TRACE_IMM(0, "\nError: pmu shutdown failed!\n"); - hal_sys_timer_delay(MS_TO_TICKS(5)); - } else { + // can't reach here + PMU_INFO_TRACE_IMM(0, "\nError: pmu shutdown failed!\n"); + hal_sys_timer_delay(MS_TO_TICKS(5)); + } else { #if defined(PMU_FULL_INIT) || (!defined(FPGA) && !defined(PROGRAMMER)) - // CAUTION: - // 1) Never reset RF because system or flash might be using X2/X4, which are off by default - // 2) Never reset RF/ANA because system or flash might be using PLL, and the reset might cause clock glitch - // TODO: - // Restore BBPLL settings in RF + // CAUTION: + // 1) Never reset RF because system or flash might be using X2/X4, which are + // off by default 2) Never reset RF/ANA because system or flash might be + // using PLL, and the reset might cause clock glitch + // TODO: + // Restore BBPLL settings in RF #endif - } + } - hal_cmu_sys_reboot(); + hal_cmu_sys_reboot(); - int_unlock(lock); + int_unlock(lock); } -void pmu_shutdown(void) -{ - pmu_sys_ctrl(true); +void pmu_shutdown(void) { pmu_sys_ctrl(true); } + +void pmu_reboot(void) { pmu_sys_ctrl(false); } + +static inline uint16_t pmu_get_module_addr(enum PMU_MODUAL_T module) { + if (module == PMU_HPPA2CODEC || module == PMU_CODEC) { + return PMU_REG_MODULE_START + module + 1; + } else if (module == PMU_BUCK2ANA) { + return PMU_REG_BUCK2ANA_CFG; + } else { + return PMU_REG_MODULE_START + module; + } } -void pmu_reboot(void) -{ - pmu_sys_ctrl(false); -} +void pmu_module_config(enum PMU_MODUAL_T module, unsigned short is_manual, + unsigned short ldo_on, unsigned short lp_mode, + unsigned short dpmode) { + unsigned short val; + unsigned char module_address; + const struct PMU_MODULE_CFG_T *module_cfg_p = &pmu_module_cfg[module]; -static inline uint16_t pmu_get_module_addr(enum PMU_MODUAL_T module) -{ - if (module == PMU_HPPA2CODEC || module == PMU_CODEC) { - return PMU_REG_MODULE_START + module + 1; - } else if (module == PMU_BUCK2ANA) { - return PMU_REG_BUCK2ANA_CFG; + module_address = pmu_get_module_addr(module); + + if (module == PMU_ANA) { + pmu_read(PMU_REG_BIAS_CFG, &val); + if (is_manual) { + val |= module_cfg_p->pu_dr; } else { - return PMU_REG_MODULE_START + module; - } -} - -void pmu_module_config(enum PMU_MODUAL_T module,unsigned short is_manual,unsigned short ldo_on,unsigned short lp_mode,unsigned short dpmode) -{ - unsigned short val; - unsigned char module_address; - const struct PMU_MODULE_CFG_T *module_cfg_p = &pmu_module_cfg[module]; - - module_address = pmu_get_module_addr(module); - - if (module == PMU_ANA) { - pmu_read(PMU_REG_BIAS_CFG, &val); - if(is_manual) { - val |= module_cfg_p->pu_dr; - } else { - val &= ~module_cfg_p->pu_dr; - } - - if(ldo_on) { - val |= module_cfg_p->pu; - } else { - val &= ~module_cfg_p->pu; - } - pmu_write(PMU_REG_BIAS_CFG, val); - } else if (module == PMU_DIG) { - pmu_read(PMU_REG_DCDC_DIG_EN, &val); - if(is_manual) { - val |= module_cfg_p->pu_dr; - } else { - val &= ~module_cfg_p->pu_dr; - } - - if(ldo_on) { - val |= module_cfg_p->pu; - } else { - val &= ~module_cfg_p->pu; - } - pmu_write(PMU_REG_DCDC_DIG_EN, val); - } else if (module == PMU_HPPA2CODEC) { - pmu_read(PMU_REG_SLEEP_CFG, &val); - if(dpmode) { - val |= module_cfg_p->pu_dsleep; - } else { - val &= ~module_cfg_p->pu_dsleep; - } - pmu_write(PMU_REG_SLEEP_CFG, val); - } else if (module == PMU_CODEC) { - pmu_read(PMU_REG_HPPA2CODEC_CFG, &val); - if(dpmode) { - val |= module_cfg_p->pu_dsleep; - } else { - val &= ~module_cfg_p->pu_dsleep; - } - pmu_write(PMU_REG_HPPA2CODEC_CFG, val); + val &= ~module_cfg_p->pu_dr; } - pmu_read(module_address, &val); - - if (module != PMU_ANA && module != PMU_DIG) { - if(is_manual) { - val |= module_cfg_p->pu_dr; - } else { - val &= ~module_cfg_p->pu_dr; - } - - if(ldo_on) { - val |= module_cfg_p->pu; - } else { - val &= ~module_cfg_p->pu; - } - } - - if (lp_mode) { - val &= ~module_cfg_p->lp_en_dr; + if (ldo_on) { + val |= module_cfg_p->pu; } else { - val = (val & ~module_cfg_p->lp_en) | module_cfg_p->lp_en_dr; + val &= ~module_cfg_p->pu; + } + pmu_write(PMU_REG_BIAS_CFG, val); + } else if (module == PMU_DIG) { + pmu_read(PMU_REG_DCDC_DIG_EN, &val); + if (is_manual) { + val |= module_cfg_p->pu_dr; + } else { + val &= ~module_cfg_p->pu_dr; } - if (module != PMU_HPPA2CODEC && module != PMU_CODEC) { - if(dpmode) { - val |= module_cfg_p->pu_dsleep; - } else { - val &= ~module_cfg_p->pu_dsleep; - } + if (ldo_on) { + val |= module_cfg_p->pu; + } else { + val &= ~module_cfg_p->pu; + } + pmu_write(PMU_REG_DCDC_DIG_EN, val); + } else if (module == PMU_HPPA2CODEC) { + pmu_read(PMU_REG_SLEEP_CFG, &val); + if (dpmode) { + val |= module_cfg_p->pu_dsleep; + } else { + val &= ~module_cfg_p->pu_dsleep; + } + pmu_write(PMU_REG_SLEEP_CFG, val); + } else if (module == PMU_CODEC) { + pmu_read(PMU_REG_HPPA2CODEC_CFG, &val); + if (dpmode) { + val |= module_cfg_p->pu_dsleep; + } else { + val &= ~module_cfg_p->pu_dsleep; + } + pmu_write(PMU_REG_HPPA2CODEC_CFG, val); + } + + pmu_read(module_address, &val); + + if (module != PMU_ANA && module != PMU_DIG) { + if (is_manual) { + val |= module_cfg_p->pu_dr; + } else { + val &= ~module_cfg_p->pu_dr; } - pmu_write(module_address, val); + if (ldo_on) { + val |= module_cfg_p->pu; + } else { + val &= ~module_cfg_p->pu; + } + } + + if (lp_mode) { + val &= ~module_cfg_p->lp_en_dr; + } else { + val = (val & ~module_cfg_p->lp_en) | module_cfg_p->lp_en_dr; + } + + if (module != PMU_HPPA2CODEC && module != PMU_CODEC) { + if (dpmode) { + val |= module_cfg_p->pu_dsleep; + } else { + val &= ~module_cfg_p->pu_dsleep; + } + } + + pmu_write(module_address, val); } -void pmu_module_set_volt(unsigned char module, unsigned short sleep_v,unsigned short normal_v) -{ - unsigned short val; - unsigned char module_address; - const struct PMU_MODULE_CFG_T *module_cfg_p = &pmu_module_cfg[module]; +void pmu_module_set_volt(unsigned char module, unsigned short sleep_v, + unsigned short normal_v) { + unsigned short val; + unsigned char module_address; + const struct PMU_MODULE_CFG_T *module_cfg_p = &pmu_module_cfg[module]; - module_address = pmu_get_module_addr(module); + module_address = pmu_get_module_addr(module); - pmu_read(module_address, &val); - val &= ~module_cfg_p->vbit_normal_mask; - val |= (normal_v << module_cfg_p->vbit_normal_shift) & module_cfg_p->vbit_normal_mask; - val &= ~module_cfg_p->vbit_dsleep_mask; - val |= (sleep_v << module_cfg_p->vbit_dsleep_shift) & module_cfg_p->vbit_dsleep_mask; - pmu_write(module_address, val); + pmu_read(module_address, &val); + val &= ~module_cfg_p->vbit_normal_mask; + val |= (normal_v << module_cfg_p->vbit_normal_shift) & + module_cfg_p->vbit_normal_mask; + val &= ~module_cfg_p->vbit_dsleep_mask; + val |= (sleep_v << module_cfg_p->vbit_dsleep_shift) & + module_cfg_p->vbit_dsleep_mask; + pmu_write(module_address, val); } -int pmu_module_get_volt(unsigned char module, unsigned short *sleep_vp,unsigned short *normal_vp) -{ - unsigned short val; - unsigned char module_address; - const struct PMU_MODULE_CFG_T *module_cfg_p = &pmu_module_cfg[module]; +int pmu_module_get_volt(unsigned char module, unsigned short *sleep_vp, + unsigned short *normal_vp) { + unsigned short val; + unsigned char module_address; + const struct PMU_MODULE_CFG_T *module_cfg_p = &pmu_module_cfg[module]; - module_address = pmu_get_module_addr(module); + module_address = pmu_get_module_addr(module); - pmu_read(module_address, &val); - if (normal_vp) { - *normal_vp = (val & module_cfg_p->vbit_normal_mask) >> module_cfg_p->vbit_normal_shift; - } - if (sleep_vp) { - *sleep_vp = (val & module_cfg_p->vbit_dsleep_mask) >> module_cfg_p->vbit_dsleep_shift; - } + pmu_read(module_address, &val); + if (normal_vp) { + *normal_vp = (val & module_cfg_p->vbit_normal_mask) >> + module_cfg_p->vbit_normal_shift; + } + if (sleep_vp) { + *sleep_vp = (val & module_cfg_p->vbit_dsleep_mask) >> + module_cfg_p->vbit_dsleep_shift; + } - return 0; + return 0; } -static void pmu_module_ramp_volt(unsigned char module, unsigned short sleep_v, unsigned short normal_v) -{ - uint16_t old_normal_v; - uint16_t old_sleep_v; +static void pmu_module_ramp_volt(unsigned char module, unsigned short sleep_v, + unsigned short normal_v) { + uint16_t old_normal_v; + uint16_t old_sleep_v; - pmu_module_get_volt(module, &old_sleep_v, &old_normal_v); + pmu_module_get_volt(module, &old_sleep_v, &old_normal_v); - if (old_normal_v < normal_v) { - while (old_normal_v++ < normal_v) { - pmu_module_set_volt(module, sleep_v, old_normal_v); - } - } else if (old_normal_v != normal_v || old_sleep_v != sleep_v) { - pmu_module_set_volt(module, sleep_v, normal_v); + if (old_normal_v < normal_v) { + while (old_normal_v++ < normal_v) { + pmu_module_set_volt(module, sleep_v, old_normal_v); } + } else if (old_normal_v != normal_v || old_sleep_v != sleep_v) { + pmu_module_set_volt(module, sleep_v, normal_v); + } } -static void pmu_dcdc_ana_get_volt(unsigned short *normal_vp, unsigned short *dsleep_vp) -{ - unsigned short val; +static void pmu_dcdc_ana_get_volt(unsigned short *normal_vp, + unsigned short *dsleep_vp) { + unsigned short val; - pmu_read(PMU_REG_DCDC_ANA_VOLT, &val); - if (normal_vp) { - *normal_vp = GET_BITFIELD(val, REG_DCDC2_VBIT_NORMAL); - } - if (dsleep_vp) { - *dsleep_vp = GET_BITFIELD(val, REG_DCDC2_VBIT_DSLEEP); - } + pmu_read(PMU_REG_DCDC_ANA_VOLT, &val); + if (normal_vp) { + *normal_vp = GET_BITFIELD(val, REG_DCDC2_VBIT_NORMAL); + } + if (dsleep_vp) { + *dsleep_vp = GET_BITFIELD(val, REG_DCDC2_VBIT_DSLEEP); + } #ifdef PMU_DCDC_CALIB - if (normal_vp) { - *normal_vp = pmu_reg_val_add(*normal_vp, -pmu_dcdc_ana_comp, MAX_DCDC2_VBIT_VAL); - } - if (dsleep_vp) { - *dsleep_vp = pmu_reg_val_add(*dsleep_vp, -pmu_dcdc_ana_comp, MAX_DCDC2_VBIT_VAL); - } + if (normal_vp) { + *normal_vp = + pmu_reg_val_add(*normal_vp, -pmu_dcdc_ana_comp, MAX_DCDC2_VBIT_VAL); + } + if (dsleep_vp) { + *dsleep_vp = + pmu_reg_val_add(*dsleep_vp, -pmu_dcdc_ana_comp, MAX_DCDC2_VBIT_VAL); + } #endif } -static void pmu_dcdc_ana_set_volt(unsigned short normal_v,unsigned short dsleep_v) -{ - unsigned short val; +static void pmu_dcdc_ana_set_volt(unsigned short normal_v, + unsigned short dsleep_v) { + unsigned short val; #ifdef PMU_DCDC_CALIB - normal_v = pmu_reg_val_add(normal_v, pmu_dcdc_ana_comp, MAX_DCDC2_VBIT_VAL); - dsleep_v = pmu_reg_val_add(dsleep_v, pmu_dcdc_ana_comp, MAX_DCDC2_VBIT_VAL); + normal_v = pmu_reg_val_add(normal_v, pmu_dcdc_ana_comp, MAX_DCDC2_VBIT_VAL); + dsleep_v = pmu_reg_val_add(dsleep_v, pmu_dcdc_ana_comp, MAX_DCDC2_VBIT_VAL); #endif - pmu_read(PMU_REG_DCDC_ANA_VOLT, &val); - val &= ~REG_DCDC2_VBIT_DSLEEP_MASK; - val &= ~REG_DCDC2_VBIT_NORMAL_MASK; - val |= REG_DCDC2_VBIT_DSLEEP(dsleep_v); - val |= REG_DCDC2_VBIT_NORMAL(normal_v); - pmu_write(PMU_REG_DCDC_ANA_VOLT, val); + pmu_read(PMU_REG_DCDC_ANA_VOLT, &val); + val &= ~REG_DCDC2_VBIT_DSLEEP_MASK; + val &= ~REG_DCDC2_VBIT_NORMAL_MASK; + val |= REG_DCDC2_VBIT_DSLEEP(dsleep_v); + val |= REG_DCDC2_VBIT_NORMAL(normal_v); + pmu_write(PMU_REG_DCDC_ANA_VOLT, val); - if (normal_v > dsleep_v) { - dcdc_ramp_map |= REG_DCDC2_RAMP_EN; - } else { - dcdc_ramp_map &= ~REG_DCDC2_RAMP_EN; - } + if (normal_v > dsleep_v) { + dcdc_ramp_map |= REG_DCDC2_RAMP_EN; + } else { + dcdc_ramp_map &= ~REG_DCDC2_RAMP_EN; + } } -static void pmu_ana_set_volt(int mode_change, enum PMU_POWER_MODE_T mode) -{ - uint16_t old_act_dcdc; - uint16_t old_lp_dcdc; - uint16_t new_act_dcdc; +static void pmu_ana_set_volt(int mode_change, enum PMU_POWER_MODE_T mode) { + uint16_t old_act_dcdc; + uint16_t old_lp_dcdc; + uint16_t new_act_dcdc; - if (mode == PMU_POWER_MODE_ANA_DCDC || mode == PMU_POWER_MODE_DIG_DCDC) { - pmu_dcdc_ana_get_volt(&old_act_dcdc, &old_lp_dcdc); - new_act_dcdc = ana_act_dcdc; - if (old_act_dcdc < new_act_dcdc) { - while (old_act_dcdc++ < new_act_dcdc) { - pmu_dcdc_ana_set_volt(old_act_dcdc, ana_lp_dcdc); - } - hal_sys_timer_delay_us(PMU_VANA_STABLE_TIME_US); - } else if (old_act_dcdc != new_act_dcdc || old_lp_dcdc != ana_lp_dcdc) { - pmu_dcdc_ana_set_volt(new_act_dcdc, ana_lp_dcdc); - } + if (mode == PMU_POWER_MODE_ANA_DCDC || mode == PMU_POWER_MODE_DIG_DCDC) { + pmu_dcdc_ana_get_volt(&old_act_dcdc, &old_lp_dcdc); + new_act_dcdc = ana_act_dcdc; + if (old_act_dcdc < new_act_dcdc) { + while (old_act_dcdc++ < new_act_dcdc) { + pmu_dcdc_ana_set_volt(old_act_dcdc, ana_lp_dcdc); + } + hal_sys_timer_delay_us(PMU_VANA_STABLE_TIME_US); + } else if (old_act_dcdc != new_act_dcdc || old_lp_dcdc != ana_lp_dcdc) { + pmu_dcdc_ana_set_volt(new_act_dcdc, ana_lp_dcdc); } + } } -static void pmu_dcdc_dig_get_volt(unsigned short *normal_vp, unsigned short *dsleep_vp) -{ - unsigned short val; +static void pmu_dcdc_dig_get_volt(unsigned short *normal_vp, + unsigned short *dsleep_vp) { + unsigned short val; - pmu_read(PMU_REG_DCDC_DIG_VOLT, &val); - if (normal_vp) { - *normal_vp = GET_BITFIELD(val, REG_DCDC1_VBIT_NORMAL); - } - if (dsleep_vp) { - *dsleep_vp = GET_BITFIELD(val, REG_DCDC1_VBIT_DSLEEP); - } + pmu_read(PMU_REG_DCDC_DIG_VOLT, &val); + if (normal_vp) { + *normal_vp = GET_BITFIELD(val, REG_DCDC1_VBIT_NORMAL); + } + if (dsleep_vp) { + *dsleep_vp = GET_BITFIELD(val, REG_DCDC1_VBIT_DSLEEP); + } #ifdef PMU_DCDC_CALIB - if (normal_vp) { - *normal_vp = pmu_reg_val_add(*normal_vp, -pmu_dcdc_dig_comp, MAX_DCDC1_VBIT_VAL); - } - if (dsleep_vp) { - *dsleep_vp = pmu_reg_val_add(*dsleep_vp, -pmu_dcdc_dig_comp, MAX_DCDC1_VBIT_VAL); - } + if (normal_vp) { + *normal_vp = + pmu_reg_val_add(*normal_vp, -pmu_dcdc_dig_comp, MAX_DCDC1_VBIT_VAL); + } + if (dsleep_vp) { + *dsleep_vp = + pmu_reg_val_add(*dsleep_vp, -pmu_dcdc_dig_comp, MAX_DCDC1_VBIT_VAL); + } #endif } -static void pmu_dcdc_dig_set_volt(unsigned short normal_v,unsigned short dsleep_v) -{ - unsigned short val; +static void pmu_dcdc_dig_set_volt(unsigned short normal_v, + unsigned short dsleep_v) { + unsigned short val; #ifdef PMU_DCDC_CALIB - normal_v = pmu_reg_val_add(normal_v, pmu_dcdc_dig_comp, MAX_DCDC1_VBIT_VAL); - dsleep_v = pmu_reg_val_add(dsleep_v, pmu_dcdc_dig_comp, MAX_DCDC1_VBIT_VAL); + normal_v = pmu_reg_val_add(normal_v, pmu_dcdc_dig_comp, MAX_DCDC1_VBIT_VAL); + dsleep_v = pmu_reg_val_add(dsleep_v, pmu_dcdc_dig_comp, MAX_DCDC1_VBIT_VAL); #endif - pmu_read(PMU_REG_DCDC_DIG_VOLT, &val); - val &= ~REG_DCDC1_VBIT_DSLEEP_MASK; - val &= ~REG_DCDC1_VBIT_NORMAL_MASK; - val |= REG_DCDC1_VBIT_DSLEEP(dsleep_v); - val |= REG_DCDC1_VBIT_NORMAL(normal_v); - pmu_write(PMU_REG_DCDC_DIG_VOLT, val); + pmu_read(PMU_REG_DCDC_DIG_VOLT, &val); + val &= ~REG_DCDC1_VBIT_DSLEEP_MASK; + val &= ~REG_DCDC1_VBIT_NORMAL_MASK; + val |= REG_DCDC1_VBIT_DSLEEP(dsleep_v); + val |= REG_DCDC1_VBIT_NORMAL(normal_v); + pmu_write(PMU_REG_DCDC_DIG_VOLT, val); - if (normal_v > dsleep_v) { - dcdc_ramp_map |= REG_DCDC1_RAMP_EN; - } else { - dcdc_ramp_map &= ~REG_DCDC1_RAMP_EN; - } + if (normal_v > dsleep_v) { + dcdc_ramp_map |= REG_DCDC1_RAMP_EN; + } else { + dcdc_ramp_map &= ~REG_DCDC1_RAMP_EN; + } } -static void BOOT_TEXT_SRAM_LOC pmu_dig_get_target_volt(uint16_t *ldo, uint16_t *dcdc) -{ - uint16_t ldo_volt; - uint16_t dcdc_volt; +static void BOOT_TEXT_SRAM_LOC pmu_dig_get_target_volt(uint16_t *ldo, + uint16_t *dcdc) { + uint16_t ldo_volt; + uint16_t dcdc_volt; - if (0) { + if (0) { #if defined(MCU_HIGH_PERFORMANCE_MODE) - } else if (pmu_vcore_req & (PMU_VCORE_SYS_FREQ_HIGH)) { - if (high_perf_freq_mhz <= 260) { - ldo_volt = PMU_VDIG_1_05V; - dcdc_volt = PMU_DCDC_DIG_1_05V; - } else if (high_perf_freq_mhz <= 300) { - ldo_volt = PMU_VDIG_1_1V; - dcdc_volt = PMU_DCDC_DIG_1_1V; - } else { - ldo_volt = PMU_VDIG_1_2V; - dcdc_volt = PMU_DCDC_DIG_1_1V; - } -#endif - } else if (pmu_vcore_req & (PMU_VCORE_USB_HS_ENABLED | PMU_VCORE_RS_FREQ_HIGH | PMU_VCORE_SYS_FREQ_MEDIUM)) { - ldo_volt = PMU_VDIG_0_9V; - dcdc_volt = PMU_DCDC_DIG_0_9V; - } else if (pmu_vcore_req & (PMU_VCORE_FLASH_FREQ_HIGH | PMU_VCORE_PSRAM_FREQ_HIGH | - PMU_VCORE_FLASH_WRITE_ENABLED)) { - ldo_volt = PMU_VDIG_0_8V; - dcdc_volt = PMU_DCDC_DIG_0_8V; + } else if (pmu_vcore_req & (PMU_VCORE_SYS_FREQ_HIGH)) { + if (high_perf_freq_mhz <= 260) { + ldo_volt = PMU_VDIG_1_05V; + dcdc_volt = PMU_DCDC_DIG_1_05V; + } else if (high_perf_freq_mhz <= 300) { + ldo_volt = PMU_VDIG_1_1V; + dcdc_volt = PMU_DCDC_DIG_1_1V; } else { - // Common cases - if (high_vcore) { - ldo_volt = PMU_VDIG_0_8V; - dcdc_volt = PMU_DCDC_DIG_0_8V; - } else { - ldo_volt = PMU_VDIG_0_75V; - dcdc_volt = PMU_DCDC_DIG_0_75V; - } -#ifdef __SAVE_POWER_MODE__ - ldo_volt = PMU_VDIG_0_75V; - dcdc_volt = PMU_DCDC_DIG_0_75V; -#endif + ldo_volt = PMU_VDIG_1_2V; + dcdc_volt = PMU_DCDC_DIG_1_1V; } +#endif + } else if (pmu_vcore_req & + (PMU_VCORE_USB_HS_ENABLED | PMU_VCORE_RS_FREQ_HIGH | + PMU_VCORE_SYS_FREQ_MEDIUM)) { + ldo_volt = PMU_VDIG_0_9V; + dcdc_volt = PMU_DCDC_DIG_0_9V; + } else if (pmu_vcore_req & + (PMU_VCORE_FLASH_FREQ_HIGH | PMU_VCORE_PSRAM_FREQ_HIGH | + PMU_VCORE_FLASH_WRITE_ENABLED)) { + ldo_volt = PMU_VDIG_0_8V; + dcdc_volt = PMU_DCDC_DIG_0_8V; + } else { + // Common cases + if (high_vcore) { + ldo_volt = PMU_VDIG_0_8V; + dcdc_volt = PMU_DCDC_DIG_0_8V; + } else { + ldo_volt = PMU_VDIG_0_75V; + dcdc_volt = PMU_DCDC_DIG_0_75V; + } +#ifdef __SAVE_POWER_MODE__ + ldo_volt = PMU_VDIG_0_75V; + dcdc_volt = PMU_DCDC_DIG_0_75V; +#endif + } #if defined(PROGRAMMER) || defined(__BES_OTA_MODE__) && !defined(PMU_FULL_INIT) - // Try to keep the same vcore voltage as ROM (hardware default) - if (ldo_volt < PMU_VDIG_0_9V) { - ldo_volt = PMU_VDIG_0_9V; - } - if (dcdc_volt < PMU_DCDC_DIG_0_9V) { - dcdc_volt = PMU_DCDC_DIG_0_9V; - } + // Try to keep the same vcore voltage as ROM (hardware default) + if (ldo_volt < PMU_VDIG_0_9V) { + ldo_volt = PMU_VDIG_0_9V; + } + if (dcdc_volt < PMU_DCDC_DIG_0_9V) { + dcdc_volt = PMU_DCDC_DIG_0_9V; + } #endif #if defined(MTEST_ENABLED) && defined(MTEST_VOLT) #ifdef DIG_DCDC_MODE - dcdc_volt = MTEST_VOLT; + dcdc_volt = MTEST_VOLT; #else - ldo_volt = MTEST_VOLT; + ldo_volt = MTEST_VOLT; #endif #endif - if (ldo) { - *ldo = ldo_volt; - } - if (dcdc) { - *dcdc = dcdc_volt; - } + if (ldo) { + *ldo = ldo_volt; + } + if (dcdc) { + *dcdc = dcdc_volt; + } } -static void pmu_dig_set_volt(int mode_change, enum PMU_POWER_MODE_T mode) -{ - uint32_t lock; - uint16_t dcdc_volt, old_act_dcdc, old_lp_dcdc; - uint16_t ldo_volt, old_act_ldo, old_lp_ldo; - uint16_t ldo_real, dcdc_real; - bool volt_inc = false; +static void pmu_dig_set_volt(int mode_change, enum PMU_POWER_MODE_T mode) { + uint32_t lock; + uint16_t dcdc_volt, old_act_dcdc, old_lp_dcdc; + uint16_t ldo_volt, old_act_ldo, old_lp_ldo; + uint16_t ldo_real, dcdc_real; + bool volt_inc = false; - lock = int_lock(); + lock = int_lock(); - if (mode == PMU_POWER_MODE_NONE) { - mode = pmu_power_mode; + if (mode == PMU_POWER_MODE_NONE) { + mode = pmu_power_mode; + } + + pmu_dig_get_target_volt(&ldo_volt, &dcdc_volt); + + pmu_module_get_volt(PMU_DIG, &old_lp_ldo, &old_act_ldo); + pmu_dcdc_dig_get_volt(&old_act_dcdc, &old_lp_dcdc); + + if (mode_change) { + // Both DCDC and LDO might have been enabled + ldo_real = (old_act_ldo - PMU_VDIG_0_4V) / 0x2; + dcdc_real = (old_act_dcdc - PMU_DCDC_DIG_0_4V) / 0x10; + if (dcdc_real < ldo_real) { + dcdc_real = ldo_real; } + ldo_real = PMU_VDIG_0_4V + dcdc_real * 0x2; + dcdc_real = PMU_DCDC_DIG_0_4V + dcdc_real * 0x10; - pmu_dig_get_target_volt(&ldo_volt, &dcdc_volt); - - pmu_module_get_volt(PMU_DIG, &old_lp_ldo, &old_act_ldo); - pmu_dcdc_dig_get_volt(&old_act_dcdc, &old_lp_dcdc); - - if (mode_change) { - // Both DCDC and LDO might have been enabled - ldo_real = (old_act_ldo - PMU_VDIG_0_4V) / 0x2; - dcdc_real = (old_act_dcdc - PMU_DCDC_DIG_0_4V) / 0x10; - if (dcdc_real < ldo_real) { - dcdc_real = ldo_real; - } - ldo_real = PMU_VDIG_0_4V + dcdc_real * 0x2; - dcdc_real = PMU_DCDC_DIG_0_4V + dcdc_real * 0x10; - - // Set the voltage to current real voltage - if (old_act_ldo < ldo_real) { - old_act_ldo = ldo_real; - old_lp_ldo = dig_lp_ldo; - pmu_module_set_volt(PMU_DIG, old_lp_ldo, old_act_ldo); - } - if (old_act_dcdc < dcdc_real) { - old_act_dcdc = dcdc_real; - old_lp_dcdc = dig_lp_dcdc; - pmu_dcdc_dig_set_volt(old_act_dcdc, old_lp_dcdc); - } + // Set the voltage to current real voltage + if (old_act_ldo < ldo_real) { + old_act_ldo = ldo_real; + old_lp_ldo = dig_lp_ldo; + pmu_module_set_volt(PMU_DIG, old_lp_ldo, old_act_ldo); } - - if (mode_change || mode == PMU_POWER_MODE_DIG_DCDC) { - if (old_act_dcdc < dcdc_volt) { - volt_inc = true; - while (old_act_dcdc++ < dcdc_volt) { - pmu_dcdc_dig_set_volt(old_act_dcdc, dig_lp_dcdc); - } - } else if (old_act_dcdc != dcdc_volt || old_lp_dcdc != dig_lp_dcdc) { - pmu_dcdc_dig_set_volt(dcdc_volt, dig_lp_dcdc); - } + if (old_act_dcdc < dcdc_real) { + old_act_dcdc = dcdc_real; + old_lp_dcdc = dig_lp_dcdc; + pmu_dcdc_dig_set_volt(old_act_dcdc, old_lp_dcdc); } + } - if (mode_change || mode != PMU_POWER_MODE_DIG_DCDC) { - if (old_act_ldo < ldo_volt) { - volt_inc = true; - } - pmu_module_ramp_volt(PMU_DIG, dig_lp_ldo, ldo_volt); + if (mode_change || mode == PMU_POWER_MODE_DIG_DCDC) { + if (old_act_dcdc < dcdc_volt) { + volt_inc = true; + while (old_act_dcdc++ < dcdc_volt) { + pmu_dcdc_dig_set_volt(old_act_dcdc, dig_lp_dcdc); + } + } else if (old_act_dcdc != dcdc_volt || old_lp_dcdc != dig_lp_dcdc) { + pmu_dcdc_dig_set_volt(dcdc_volt, dig_lp_dcdc); } + } - if (mode_change == 0) { - // Update the voltage of the other mode - if (mode == PMU_POWER_MODE_DIG_DCDC) { - pmu_module_set_volt(PMU_DIG, dig_lp_ldo, ldo_volt); - } else { - pmu_dcdc_dig_set_volt(dcdc_volt, dig_lp_dcdc); - } + if (mode_change || mode != PMU_POWER_MODE_DIG_DCDC) { + if (old_act_ldo < ldo_volt) { + volt_inc = true; } + pmu_module_ramp_volt(PMU_DIG, dig_lp_ldo, ldo_volt); + } - if (volt_inc) { - hal_sys_timer_delay_us(PMU_VCORE_STABLE_TIME_US); + if (mode_change == 0) { + // Update the voltage of the other mode + if (mode == PMU_POWER_MODE_DIG_DCDC) { + pmu_module_set_volt(PMU_DIG, dig_lp_ldo, ldo_volt); + } else { + pmu_dcdc_dig_set_volt(dcdc_volt, dig_lp_dcdc); } + } - int_unlock(lock); + if (volt_inc) { + hal_sys_timer_delay_us(PMU_VCORE_STABLE_TIME_US); + } + + int_unlock(lock); } -static void pmu_ldo_mode_en(void) -{ - unsigned short val; +static void pmu_ldo_mode_en(void) { + unsigned short val; - // Enable vana ldo - pmu_module_config(PMU_ANA,PMU_AUTO_MODE,PMU_LDO_ON,PMU_LP_MODE_ON,PMU_DSLEEP_MODE_ON); + // Enable vana ldo + pmu_module_config(PMU_ANA, PMU_AUTO_MODE, PMU_LDO_ON, PMU_LP_MODE_ON, + PMU_DSLEEP_MODE_ON); + // Enable vcore ldo + pmu_module_config(PMU_DIG, PMU_AUTO_MODE, PMU_LDO_ON, PMU_LP_MODE_ON, + PMU_DSLEEP_MODE_ON); + + pmu_ana_set_volt(1, PMU_POWER_MODE_LDO); + pmu_dig_set_volt(1, PMU_POWER_MODE_LDO); + + hal_sys_timer_delay_us(PMU_LDO_PU_STABLE_TIME_US); + + // Disable vcore dcdc + pmu_read(PMU_REG_DCDC_DIG_EN, &val); + val = (val & ~REG_PU_DCDC1) | REG_PU_DCDC1_DR; + pmu_write(PMU_REG_DCDC_DIG_EN, val); + // Disable vana dcdc + pmu_read(PMU_REG_DCDC_ANA_EN, &val); + val = (val & ~REG_PU_DCDC2) | REG_PU_DCDC2_DR; + pmu_write(PMU_REG_DCDC_ANA_EN, val); +} + +static void pmu_dcdc_ana_mode_en(void) { + unsigned short val; + + if (pmu_power_mode == PMU_POWER_MODE_DIG_DCDC) { // Enable vcore ldo - pmu_module_config(PMU_DIG,PMU_AUTO_MODE,PMU_LDO_ON,PMU_LP_MODE_ON,PMU_DSLEEP_MODE_ON); + pmu_module_config(PMU_DIG, PMU_AUTO_MODE, PMU_LDO_ON, PMU_LP_MODE_ON, + PMU_DSLEEP_MODE_ON); - pmu_ana_set_volt(1, PMU_POWER_MODE_LDO); - pmu_dig_set_volt(1, PMU_POWER_MODE_LDO); + pmu_ana_set_volt(1, PMU_POWER_MODE_ANA_DCDC); + pmu_dig_set_volt(1, PMU_POWER_MODE_ANA_DCDC); hal_sys_timer_delay_us(PMU_LDO_PU_STABLE_TIME_US); @@ -2264,2024 +2286,1939 @@ static void pmu_ldo_mode_en(void) pmu_read(PMU_REG_DCDC_DIG_EN, &val); val = (val & ~REG_PU_DCDC1) | REG_PU_DCDC1_DR; pmu_write(PMU_REG_DCDC_DIG_EN, val); - // Disable vana dcdc - pmu_read(PMU_REG_DCDC_ANA_EN, &val); - val = (val & ~REG_PU_DCDC2) | REG_PU_DCDC2_DR; - pmu_write(PMU_REG_DCDC_ANA_EN, val); -} - -static void pmu_dcdc_ana_mode_en(void) -{ - unsigned short val; - - if (pmu_power_mode == PMU_POWER_MODE_DIG_DCDC) { - // Enable vcore ldo - pmu_module_config(PMU_DIG,PMU_AUTO_MODE,PMU_LDO_ON,PMU_LP_MODE_ON,PMU_DSLEEP_MODE_ON); - - pmu_ana_set_volt(1, PMU_POWER_MODE_ANA_DCDC); - pmu_dig_set_volt(1, PMU_POWER_MODE_ANA_DCDC); - - hal_sys_timer_delay_us(PMU_LDO_PU_STABLE_TIME_US); - - // Disable vcore dcdc - pmu_read(PMU_REG_DCDC_DIG_EN, &val); - val = (val & ~REG_PU_DCDC1) | REG_PU_DCDC1_DR; - pmu_write(PMU_REG_DCDC_DIG_EN, val); - } else { - pmu_read(PMU_REG_DCDC_ANA_CFG_19, &val); - val |= DCDC2_REG_BYPASS; - pmu_write(PMU_REG_DCDC_ANA_CFG_19, val); - - // Enable vana dcdc - pmu_read(PMU_REG_DCDC_ANA_EN, &val); -#ifdef DCDC_ULP_LP_ON - val = (val & ~REG_DCDC2_ULP_MODE_NORMAL) | REG_DCDC2_ULP_MODE_DSLEEP | REG_PU_DCDC2_DR | REG_PU_DCDC2; -#else - val = (val & ~REG_DCDC2_ULP_MODE_NORMAL) | REG_PU_DCDC2_DR | REG_PU_DCDC2; -#endif - pmu_write(PMU_REG_DCDC_ANA_EN, val); - - pmu_ana_set_volt(1, PMU_POWER_MODE_ANA_DCDC); - pmu_dig_set_volt(1, PMU_POWER_MODE_ANA_DCDC); - - hal_sys_timer_delay_us(PMU_DCDC_PU_STABLE_TIME_US); - - // Disable vana ldo - pmu_module_config(PMU_ANA,PMU_MANUAL_MODE,PMU_LDO_OFF,PMU_LP_MODE_ON,PMU_DSLEEP_MODE_OFF); - - pmu_read(PMU_REG_DCDC_ANA_CFG_19, &val); - val &= ~DCDC2_REG_BYPASS; - pmu_write(PMU_REG_DCDC_ANA_CFG_19, val); - } -} - -static void pmu_dcdc_dual_mode_en(void) -{ - unsigned short val; - + } else { pmu_read(PMU_REG_DCDC_ANA_CFG_19, &val); val |= DCDC2_REG_BYPASS; pmu_write(PMU_REG_DCDC_ANA_CFG_19, val); - pmu_read(PMU_REG_DCDC_DIG_CFG_36, &val); - val |= DCDC1_REG_BYPASS; - pmu_write(PMU_REG_DCDC_DIG_CFG_36, val); // Enable vana dcdc pmu_read(PMU_REG_DCDC_ANA_EN, &val); #ifdef DCDC_ULP_LP_ON - val = (val & ~REG_DCDC2_ULP_MODE_NORMAL) | REG_DCDC2_ULP_MODE_DSLEEP | REG_PU_DCDC2_DR | REG_PU_DCDC2; + val = (val & ~REG_DCDC2_ULP_MODE_NORMAL) | REG_DCDC2_ULP_MODE_DSLEEP | + REG_PU_DCDC2_DR | REG_PU_DCDC2; #else - val = (val & ~(REG_DCDC2_ULP_MODE_NORMAL | REG_DCDC2_ULP_MODE_DSLEEP)) | REG_PU_DCDC2_DR | REG_PU_DCDC2; + val = (val & ~REG_DCDC2_ULP_MODE_NORMAL) | REG_PU_DCDC2_DR | REG_PU_DCDC2; #endif pmu_write(PMU_REG_DCDC_ANA_EN, val); - // Enable vcore dcdc - pmu_read(PMU_REG_DCDC_DIG_EN, &val); -#ifdef DCDC_ULP_LP_ON - val = (val & ~REG_DCDC1_ULP_MODE_NORMAL) | REG_DCDC1_ULP_MODE_DSLEEP | REG_PU_DCDC1_DR | REG_PU_DCDC1; -#else - val = (val & ~(REG_DCDC1_ULP_MODE_NORMAL | REG_DCDC1_ULP_MODE_DSLEEP)) | REG_PU_DCDC1_DR | REG_PU_DCDC1; -#endif - pmu_write(PMU_REG_DCDC_DIG_EN, val); - pmu_ana_set_volt(1, PMU_POWER_MODE_DIG_DCDC); - pmu_dig_set_volt(1, PMU_POWER_MODE_DIG_DCDC); + pmu_ana_set_volt(1, PMU_POWER_MODE_ANA_DCDC); + pmu_dig_set_volt(1, PMU_POWER_MODE_ANA_DCDC); hal_sys_timer_delay_us(PMU_DCDC_PU_STABLE_TIME_US); // Disable vana ldo - pmu_module_config(PMU_ANA,PMU_MANUAL_MODE,PMU_LDO_OFF,PMU_LP_MODE_ON,PMU_DSLEEP_MODE_OFF); - // Disable vcore ldo - pmu_module_config(PMU_DIG,PMU_MANUAL_MODE,PMU_LDO_OFF,PMU_LP_MODE_ON,PMU_DSLEEP_MODE_OFF); + pmu_module_config(PMU_ANA, PMU_MANUAL_MODE, PMU_LDO_OFF, PMU_LP_MODE_ON, + PMU_DSLEEP_MODE_OFF); pmu_read(PMU_REG_DCDC_ANA_CFG_19, &val); val &= ~DCDC2_REG_BYPASS; pmu_write(PMU_REG_DCDC_ANA_CFG_19, val); - pmu_read(PMU_REG_DCDC_DIG_CFG_36, &val); - val &= ~DCDC1_REG_BYPASS; - pmu_write(PMU_REG_DCDC_DIG_CFG_36, val); + } } -void pmu_mode_change(enum PMU_POWER_MODE_T mode) -{ - uint32_t lock; +static void pmu_dcdc_dual_mode_en(void) { + unsigned short val; - if (pmu_power_mode == mode || mode == PMU_POWER_MODE_NONE) { - return; - } + pmu_read(PMU_REG_DCDC_ANA_CFG_19, &val); + val |= DCDC2_REG_BYPASS; + pmu_write(PMU_REG_DCDC_ANA_CFG_19, val); + pmu_read(PMU_REG_DCDC_DIG_CFG_36, &val); + val |= DCDC1_REG_BYPASS; + pmu_write(PMU_REG_DCDC_DIG_CFG_36, val); - lock = int_lock(); + // Enable vana dcdc + pmu_read(PMU_REG_DCDC_ANA_EN, &val); +#ifdef DCDC_ULP_LP_ON + val = (val & ~REG_DCDC2_ULP_MODE_NORMAL) | REG_DCDC2_ULP_MODE_DSLEEP | + REG_PU_DCDC2_DR | REG_PU_DCDC2; +#else + val = (val & ~(REG_DCDC2_ULP_MODE_NORMAL | REG_DCDC2_ULP_MODE_DSLEEP)) | + REG_PU_DCDC2_DR | REG_PU_DCDC2; +#endif + pmu_write(PMU_REG_DCDC_ANA_EN, val); + // Enable vcore dcdc + pmu_read(PMU_REG_DCDC_DIG_EN, &val); +#ifdef DCDC_ULP_LP_ON + val = (val & ~REG_DCDC1_ULP_MODE_NORMAL) | REG_DCDC1_ULP_MODE_DSLEEP | + REG_PU_DCDC1_DR | REG_PU_DCDC1; +#else + val = (val & ~(REG_DCDC1_ULP_MODE_NORMAL | REG_DCDC1_ULP_MODE_DSLEEP)) | + REG_PU_DCDC1_DR | REG_PU_DCDC1; +#endif + pmu_write(PMU_REG_DCDC_DIG_EN, val); - if (mode == PMU_POWER_MODE_ANA_DCDC) { - pmu_dcdc_ana_mode_en(); - } else if (mode == PMU_POWER_MODE_DIG_DCDC) { - pmu_dcdc_dual_mode_en(); - } else if (mode == PMU_POWER_MODE_LDO) { - pmu_ldo_mode_en(); - } + pmu_ana_set_volt(1, PMU_POWER_MODE_DIG_DCDC); + pmu_dig_set_volt(1, PMU_POWER_MODE_DIG_DCDC); - pmu_power_mode = mode; + hal_sys_timer_delay_us(PMU_DCDC_PU_STABLE_TIME_US); - int_unlock(lock); + // Disable vana ldo + pmu_module_config(PMU_ANA, PMU_MANUAL_MODE, PMU_LDO_OFF, PMU_LP_MODE_ON, + PMU_DSLEEP_MODE_OFF); + // Disable vcore ldo + pmu_module_config(PMU_DIG, PMU_MANUAL_MODE, PMU_LDO_OFF, PMU_LP_MODE_ON, + PMU_DSLEEP_MODE_OFF); + + pmu_read(PMU_REG_DCDC_ANA_CFG_19, &val); + val &= ~DCDC2_REG_BYPASS; + pmu_write(PMU_REG_DCDC_ANA_CFG_19, val); + pmu_read(PMU_REG_DCDC_DIG_CFG_36, &val); + val &= ~DCDC1_REG_BYPASS; + pmu_write(PMU_REG_DCDC_DIG_CFG_36, val); } -void pmu_sleep_en(unsigned char sleep_en) -{ - unsigned short val; +void pmu_mode_change(enum PMU_POWER_MODE_T mode) { + uint32_t lock; - pmu_read(PMU_REG_SLEEP_CFG, &val); - if (sleep_en) { - val |= SLEEP_ALLOW; - } else { - val &= ~SLEEP_ALLOW; - } - pmu_write(PMU_REG_SLEEP_CFG, val); + if (pmu_power_mode == mode || mode == PMU_POWER_MODE_NONE) { + return; + } + + lock = int_lock(); + + if (mode == PMU_POWER_MODE_ANA_DCDC) { + pmu_dcdc_ana_mode_en(); + } else if (mode == PMU_POWER_MODE_DIG_DCDC) { + pmu_dcdc_dual_mode_en(); + } else if (mode == PMU_POWER_MODE_LDO) { + pmu_ldo_mode_en(); + } + + pmu_power_mode = mode; + + int_unlock(lock); +} + +void pmu_sleep_en(unsigned char sleep_en) { + unsigned short val; + + pmu_read(PMU_REG_SLEEP_CFG, &val); + if (sleep_en) { + val |= SLEEP_ALLOW; + } else { + val &= ~SLEEP_ALLOW; + } + pmu_write(PMU_REG_SLEEP_CFG, val); } #if defined(PMU_INIT) || (!defined(FPGA) && !defined(PROGRAMMER)) -static uint32_t pmu_vcodec_mv_to_val(uint16_t mv) -{ - uint32_t val; +static uint32_t pmu_vcodec_mv_to_val(uint16_t mv) { + uint32_t val; #ifdef VHPPA2VCODEC - if (mv == 1900) { - val = PMU_HPPA2CODEC_1_9V; - } else if (mv >= 1950) { - val = PMU_HPPA2CODEC_1_95V; - } else { - val = PMU_HPPA2CODEC_1_7V; - } + if (mv == 1900) { + val = PMU_HPPA2CODEC_1_9V; + } else if (mv >= 1950) { + val = PMU_HPPA2CODEC_1_95V; + } else { + val = PMU_HPPA2CODEC_1_7V; + } #else - if (mv == 1900) { - val = PMU_CODEC_1_9V; - } else if (mv >= 1950) { - val = PMU_CODEC_1_9V; - } else { - val = PMU_CODEC_1_7V; - } + if (mv == 1900) { + val = PMU_CODEC_1_9V; + } else if (mv >= 1950) { + val = PMU_CODEC_1_9V; + } else { + val = PMU_CODEC_1_7V; + } #endif - return val; + return val; } -static uint32_t pmu_ldo_hppa_mv_to_val(uint16_t mv) -{ - uint32_t val; +static uint32_t pmu_ldo_hppa_mv_to_val(uint16_t mv) { + uint32_t val; - if (mv == 1600) { - val = PMU_VHPPA_1_6V; - } else if (mv == 1700) { - val = PMU_VHPPA_1_7V; - } else if (mv >= 1900) { - val = PMU_VHPPA_1_9V; - } else { - val = PMU_VHPPA_1_8V; - } + if (mv == 1600) { + val = PMU_VHPPA_1_6V; + } else if (mv == 1700) { + val = PMU_VHPPA_1_7V; + } else if (mv >= 1900) { + val = PMU_VHPPA_1_9V; + } else { + val = PMU_VHPPA_1_8V; + } - return val; + return val; } -static void POSSIBLY_UNUSED pmu_ldo_hppa_get_volt(unsigned short *normal_vp, unsigned short *dsleep_vp) -{ - uint16_t val; +static void POSSIBLY_UNUSED pmu_ldo_hppa_get_volt(unsigned short *normal_vp, + unsigned short *dsleep_vp) { + uint16_t val; - pmu_read(PMU_REG_HPPA_LDO_EN, &val); - val = GET_BITFIELD(val, REG_RES_SEL_VHPPA); - if (normal_vp) { - *normal_vp = val; - } - if (dsleep_vp) { - *dsleep_vp = val; - } + pmu_read(PMU_REG_HPPA_LDO_EN, &val); + val = GET_BITFIELD(val, REG_RES_SEL_VHPPA); + if (normal_vp) { + *normal_vp = val; + } + if (dsleep_vp) { + *dsleep_vp = val; + } } -static void pmu_ldo_hppa_set_volt(unsigned short normal_v,unsigned short dsleep_v) -{ - uint16_t val; +static void pmu_ldo_hppa_set_volt(unsigned short normal_v, + unsigned short dsleep_v) { + uint16_t val; - pmu_read(PMU_REG_HPPA_LDO_EN, &val); - val = SET_BITFIELD(val, REG_RES_SEL_VHPPA, normal_v); - pmu_write(PMU_REG_HPPA_LDO_EN, val); + pmu_read(PMU_REG_HPPA_LDO_EN, &val); + val = SET_BITFIELD(val, REG_RES_SEL_VHPPA, normal_v); + pmu_write(PMU_REG_HPPA_LDO_EN, val); } -static void pmu_ldo_hppa_en(int enable) -{ - uint16_t val; +static void pmu_ldo_hppa_en(int enable) { + uint16_t val; - pmu_read(PMU_REG_HPPA_LDO_EN, &val); - if (enable) { - val |= (REG_PU_LDO_VHPPA_DSLEEP | REG_PU_LDO_VHPPA_EN); - } else { - val &= ~(REG_PU_LDO_VHPPA_DSLEEP | REG_PU_LDO_VHPPA_EN); - } - pmu_write(PMU_REG_HPPA_LDO_EN, val); + pmu_read(PMU_REG_HPPA_LDO_EN, &val); + if (enable) { + val |= (REG_PU_LDO_VHPPA_DSLEEP | REG_PU_LDO_VHPPA_EN); + } else { + val &= ~(REG_PU_LDO_VHPPA_DSLEEP | REG_PU_LDO_VHPPA_EN); + } + pmu_write(PMU_REG_HPPA_LDO_EN, val); } #ifndef HPPA_LDO_ON -static uint32_t pmu_dcdc_hppa_mv_to_val(uint16_t mv) -{ - uint32_t val; +static uint32_t pmu_dcdc_hppa_mv_to_val(uint16_t mv) { + uint32_t val; - if (mv == 1600) { - val = PMU_DCDC_HPPA_1_6V; - } else if (mv == 1700) { - val = PMU_DCDC_HPPA_1_7V; - } else if (mv == 1900) { - val = PMU_DCDC_HPPA_1_9V; - } else if (mv >= 1950) { - val = PMU_DCDC_HPPA_1_95V; - } else { - val = PMU_DCDC_HPPA_1_8V; - } + if (mv == 1600) { + val = PMU_DCDC_HPPA_1_6V; + } else if (mv == 1700) { + val = PMU_DCDC_HPPA_1_7V; + } else if (mv == 1900) { + val = PMU_DCDC_HPPA_1_9V; + } else if (mv >= 1950) { + val = PMU_DCDC_HPPA_1_95V; + } else { + val = PMU_DCDC_HPPA_1_8V; + } - return val; + return val; } -static void pmu_dcdc_hppa_get_volt(unsigned short *normal_vp, unsigned short *dsleep_vp) -{ - unsigned short val; +static void pmu_dcdc_hppa_get_volt(unsigned short *normal_vp, + unsigned short *dsleep_vp) { + unsigned short val; - pmu_read(PMU_REG_DCDC_HPPA_VOLT, &val); - if (normal_vp) { - *normal_vp = GET_BITFIELD(val, REG_DCDC3_VBIT_NORMAL); - } - if (dsleep_vp) { - *dsleep_vp = GET_BITFIELD(val, REG_DCDC3_VBIT_DSLEEP); - } + pmu_read(PMU_REG_DCDC_HPPA_VOLT, &val); + if (normal_vp) { + *normal_vp = GET_BITFIELD(val, REG_DCDC3_VBIT_NORMAL); + } + if (dsleep_vp) { + *dsleep_vp = GET_BITFIELD(val, REG_DCDC3_VBIT_DSLEEP); + } #ifdef PMU_DCDC_CALIB - if (normal_vp) { - *normal_vp = pmu_reg_val_add(*normal_vp, -pmu_dcdc_hppa_comp, MAX_DCDC3_VBIT_VAL); - } - if (dsleep_vp) { - *dsleep_vp = pmu_reg_val_add(*dsleep_vp, -pmu_dcdc_hppa_comp, MAX_DCDC3_VBIT_VAL); - } + if (normal_vp) { + *normal_vp = + pmu_reg_val_add(*normal_vp, -pmu_dcdc_hppa_comp, MAX_DCDC3_VBIT_VAL); + } + if (dsleep_vp) { + *dsleep_vp = + pmu_reg_val_add(*dsleep_vp, -pmu_dcdc_hppa_comp, MAX_DCDC3_VBIT_VAL); + } #endif } -static void pmu_dcdc_hppa_set_volt(unsigned short normal_v,unsigned short dsleep_v) -{ - unsigned short val; +static void pmu_dcdc_hppa_set_volt(unsigned short normal_v, + unsigned short dsleep_v) { + unsigned short val; #ifdef PMU_DCDC_CALIB - normal_v = pmu_reg_val_add(normal_v, pmu_dcdc_hppa_comp, MAX_DCDC3_VBIT_VAL); - dsleep_v = pmu_reg_val_add(dsleep_v, pmu_dcdc_hppa_comp, MAX_DCDC3_VBIT_VAL); + normal_v = pmu_reg_val_add(normal_v, pmu_dcdc_hppa_comp, MAX_DCDC3_VBIT_VAL); + dsleep_v = pmu_reg_val_add(dsleep_v, pmu_dcdc_hppa_comp, MAX_DCDC3_VBIT_VAL); #endif - pmu_read(PMU_REG_DCDC_HPPA_VOLT, &val); - val &= ~REG_DCDC3_VBIT_DSLEEP_MASK; - val &= ~REG_DCDC3_VBIT_NORMAL_MASK; - val |= REG_DCDC3_VBIT_DSLEEP(dsleep_v); - val |= REG_DCDC3_VBIT_NORMAL(normal_v); - pmu_write(PMU_REG_DCDC_HPPA_VOLT, val); + pmu_read(PMU_REG_DCDC_HPPA_VOLT, &val); + val &= ~REG_DCDC3_VBIT_DSLEEP_MASK; + val &= ~REG_DCDC3_VBIT_NORMAL_MASK; + val |= REG_DCDC3_VBIT_DSLEEP(dsleep_v); + val |= REG_DCDC3_VBIT_NORMAL(normal_v); + pmu_write(PMU_REG_DCDC_HPPA_VOLT, val); - if (normal_v > dsleep_v) { - dcdc_ramp_map |= REG_DCDC3_RAMP_EN; - } else { - dcdc_ramp_map &= ~REG_DCDC3_RAMP_EN; - } + if (normal_v > dsleep_v) { + dcdc_ramp_map |= REG_DCDC3_RAMP_EN; + } else { + dcdc_ramp_map &= ~REG_DCDC3_RAMP_EN; + } } -static void pmu_dcdc_hppa_en(int enable) -{ - uint16_t val; +static void pmu_dcdc_hppa_en(int enable) { + uint16_t val; - if (enable) { - pmu_read(PMU_REG_DCDC_HPPA_CFG_1D, &val); - val |= DCDC3_REG_BYPASS; - pmu_write(PMU_REG_DCDC_HPPA_CFG_1D, val); - } + if (enable) { + pmu_read(PMU_REG_DCDC_HPPA_CFG_1D, &val); + val |= DCDC3_REG_BYPASS; + pmu_write(PMU_REG_DCDC_HPPA_CFG_1D, val); + } - pmu_read(PMU_REG_DCDC_HPPA_EN, &val); - if (enable) { + pmu_read(PMU_REG_DCDC_HPPA_EN, &val); + if (enable) { #ifdef DCDC_ULP_LP_ON - val = (val & ~REG_DCDC3_ULP_MODE_NORMAL) | REG_DCDC3_ULP_MODE_DSLEEP | REG_PU_DCDC3_DR | REG_PU_DCDC3; + val = (val & ~REG_DCDC3_ULP_MODE_NORMAL) | REG_DCDC3_ULP_MODE_DSLEEP | + REG_PU_DCDC3_DR | REG_PU_DCDC3; #else - val = (val & ~REG_DCDC3_ULP_MODE_NORMAL) | REG_PU_DCDC3_DR | REG_PU_DCDC3; + val = (val & ~REG_DCDC3_ULP_MODE_NORMAL) | REG_PU_DCDC3_DR | REG_PU_DCDC3; #endif - } else { - val = (val & ~(REG_DCDC3_ULP_MODE_NORMAL | REG_PU_DCDC3)) | REG_PU_DCDC3_DR; - } - pmu_write(PMU_REG_DCDC_HPPA_EN, val); + } else { + val = (val & ~(REG_DCDC3_ULP_MODE_NORMAL | REG_PU_DCDC3)) | REG_PU_DCDC3_DR; + } + pmu_write(PMU_REG_DCDC_HPPA_EN, val); - if (enable) { - hal_sys_timer_delay_us(PMU_DCDC_PU_STABLE_TIME_US); - pmu_read(PMU_REG_DCDC_HPPA_CFG_1D, &val); - val &= ~DCDC3_REG_BYPASS; - pmu_write(PMU_REG_DCDC_HPPA_CFG_1D, val); - } + if (enable) { + hal_sys_timer_delay_us(PMU_DCDC_PU_STABLE_TIME_US); + pmu_read(PMU_REG_DCDC_HPPA_CFG_1D, &val); + val &= ~DCDC3_REG_BYPASS; + pmu_write(PMU_REG_DCDC_HPPA_CFG_1D, val); + } } #endif -static uint32_t pmu_vhppa_mv_to_val(uint16_t mv) -{ +static uint32_t pmu_vhppa_mv_to_val(uint16_t mv) { #ifdef HPPA_LDO_ON - return pmu_ldo_hppa_mv_to_val(mv); + return pmu_ldo_hppa_mv_to_val(mv); #else - return pmu_dcdc_hppa_mv_to_val(mv); + return pmu_dcdc_hppa_mv_to_val(mv); #endif } -static void POSSIBLY_UNUSED pmu_hppa_get_volt(unsigned short *normal_vp, unsigned short *dsleep_vp) -{ +static void POSSIBLY_UNUSED pmu_hppa_get_volt(unsigned short *normal_vp, + unsigned short *dsleep_vp) { #ifdef HPPA_LDO_ON - pmu_ldo_hppa_get_volt(normal_vp, dsleep_vp); + pmu_ldo_hppa_get_volt(normal_vp, dsleep_vp); #else - pmu_dcdc_hppa_get_volt(normal_vp, dsleep_vp); + pmu_dcdc_hppa_get_volt(normal_vp, dsleep_vp); #endif } -static void pmu_hppa_set_volt(unsigned short normal_v,unsigned short dsleep_v) -{ +static void pmu_hppa_set_volt(unsigned short normal_v, + unsigned short dsleep_v) { #ifdef HPPA_LDO_ON - pmu_ldo_hppa_set_volt(normal_v, dsleep_v); + pmu_ldo_hppa_set_volt(normal_v, dsleep_v); #else - pmu_dcdc_hppa_set_volt(normal_v, dsleep_v); + pmu_dcdc_hppa_set_volt(normal_v, dsleep_v); #endif } -static void pmu_hppa_en(int enable) -{ +static void pmu_hppa_en(int enable) { #ifdef HPPA_LDO_ON - pmu_ldo_hppa_en(enable); + pmu_ldo_hppa_en(enable); #else - pmu_dcdc_hppa_en(enable); + pmu_dcdc_hppa_en(enable); #endif } -static void pmu_hppa_dcdc_to_ldo(void) -{ +static void pmu_hppa_dcdc_to_ldo(void) { #ifndef HPPA_LDO_ON - uint16_t val; - uint16_t act_volt; + uint16_t val; + uint16_t act_volt; - pmu_ldo_hppa_en(true); + pmu_ldo_hppa_en(true); - val = pmu_dcdc_hppa_mv_to_val(vhppa_mv); - pmu_dcdc_hppa_get_volt(&act_volt, NULL); - if (val < act_volt) { - val = pmu_ldo_hppa_mv_to_val(HPPA_RAMP_UP_VOLT_MV); - } else { - val = pmu_ldo_hppa_mv_to_val(vhppa_mv); - } - pmu_ldo_hppa_set_volt(val, val); + val = pmu_dcdc_hppa_mv_to_val(vhppa_mv); + pmu_dcdc_hppa_get_volt(&act_volt, NULL); + if (val < act_volt) { + val = pmu_ldo_hppa_mv_to_val(HPPA_RAMP_UP_VOLT_MV); + } else { + val = pmu_ldo_hppa_mv_to_val(vhppa_mv); + } + pmu_ldo_hppa_set_volt(val, val); - hal_sys_timer_delay_us(PMU_LDO_PU_STABLE_TIME_US); + hal_sys_timer_delay_us(PMU_LDO_PU_STABLE_TIME_US); #endif } -static void BOOT_TEXT_FLASH_LOC pmu_dig_init_volt(void) -{ - uint16_t ldo_volt; - uint16_t val; +static void BOOT_TEXT_FLASH_LOC pmu_dig_init_volt(void) { + uint16_t ldo_volt; + uint16_t val; - pmu_dig_get_target_volt(&ldo_volt, NULL); + pmu_dig_get_target_volt(&ldo_volt, NULL); - pmu_read(PMU_REG_DIG_CFG, &val); - if (GET_BITFIELD(val, LDO_DIG_VBIT_NORMAL) < ldo_volt) { - val = SET_BITFIELD(val, LDO_DIG_VBIT_NORMAL, ldo_volt); - pmu_write(PMU_REG_DIG_CFG, val); - } + pmu_read(PMU_REG_DIG_CFG, &val); + if (GET_BITFIELD(val, LDO_DIG_VBIT_NORMAL) < ldo_volt) { + val = SET_BITFIELD(val, LDO_DIG_VBIT_NORMAL, ldo_volt); + pmu_write(PMU_REG_DIG_CFG, val); + } } -int pmu_codec_volt_ramp_up(void) -{ +int pmu_codec_volt_ramp_up(void) { #ifndef VMEM_ON - unsigned short normal, dsleep; - unsigned short target; - const unsigned short step = + unsigned short normal, dsleep; + unsigned short target; + const unsigned short step = #ifdef HPPA_LDO_ON - 1; + 1; #else - 8; + 8; #endif - if (vcodec_off) { - target = pmu_vhppa_mv_to_val(HPPA_RAMP_UP_VOLT_MV); + if (vcodec_off) { + target = pmu_vhppa_mv_to_val(HPPA_RAMP_UP_VOLT_MV); - pmu_hppa_get_volt(&normal, &dsleep); + pmu_hppa_get_volt(&normal, &dsleep); - if (normal < target) { - if (normal + step < target) { - normal += step; - } else { - normal = target; - } + if (normal < target) { + if (normal + step < target) { + normal += step; + } else { + normal = target; + } - pmu_hppa_set_volt(normal, dsleep); + pmu_hppa_set_volt(normal, dsleep); - return 1; - } + return 1; } + } - return 0; + return 0; #endif } -int pmu_codec_volt_ramp_down(void) -{ +int pmu_codec_volt_ramp_down(void) { #ifndef VMEM_ON - unsigned short normal, dsleep; - unsigned short target; - const unsigned short step = + unsigned short normal, dsleep; + unsigned short target; + const unsigned short step = #ifdef HPPA_LDO_ON - 1; + 1; #else - 8; + 8; #endif - if (vcodec_off) { - target = pmu_vhppa_mv_to_val(vhppa_mv); + if (vcodec_off) { + target = pmu_vhppa_mv_to_val(vhppa_mv); - pmu_hppa_get_volt(&normal, &dsleep); + pmu_hppa_get_volt(&normal, &dsleep); - if (normal > target) { - if (normal - step > target) { - normal -= step; - } else { - normal = target; - } + if (normal > target) { + if (normal - step > target) { + normal -= step; + } else { + normal = target; + } - pmu_hppa_set_volt(normal, dsleep); + pmu_hppa_set_volt(normal, dsleep); - return 1; - } + return 1; } + } - return 0; + return 0; #endif } #endif -int BOOT_TEXT_FLASH_LOC pmu_open(void) -{ +int BOOT_TEXT_FLASH_LOC pmu_open(void) { #if defined(PMU_INIT) || (!defined(FPGA) && !defined(PROGRAMMER)) - uint16_t val; - enum PMU_POWER_MODE_T mode; - enum PMU_MODUAL_T codec; + uint16_t val; + enum PMU_POWER_MODE_T mode; + enum PMU_MODUAL_T codec; - ASSERT(!vcodec_off || vcodec_mv == vhppa_mv, - "Invalid vcodec/vhppa cfg: vcodec_off=%d vcodec_mv=%u vhppa_mv=%u", vcodec_off, vcodec_mv, vhppa_mv); - ASSERT(vcodec_mv == 1600 || vcodec_mv == 1700 || vcodec_mv == 1800 || vcodec_mv == 1900 || vcodec_mv == 1950, - "Invalid vcodec cfg: vcodec_mv=%u", vcodec_mv); - ASSERT(vhppa_mv == 1600 || vhppa_mv == 1700 || vhppa_mv == 1800 || vhppa_mv == 1900 || vhppa_mv == 1950, - "Invalid vhppa cfg: vhppa_mv=%u", vhppa_mv); + ASSERT(!vcodec_off || vcodec_mv == vhppa_mv, + "Invalid vcodec/vhppa cfg: vcodec_off=%d vcodec_mv=%u vhppa_mv=%u", + vcodec_off, vcodec_mv, vhppa_mv); + ASSERT(vcodec_mv == 1600 || vcodec_mv == 1700 || vcodec_mv == 1800 || + vcodec_mv == 1900 || vcodec_mv == 1950, + "Invalid vcodec cfg: vcodec_mv=%u", vcodec_mv); + ASSERT(vhppa_mv == 1600 || vhppa_mv == 1700 || vhppa_mv == 1800 || + vhppa_mv == 1900 || vhppa_mv == 1950, + "Invalid vhppa cfg: vhppa_mv=%u", vhppa_mv); - // Disable and clear all PMU irqs by default - pmu_write(PMU_REG_INT_MASK, 0); - pmu_write(PMU_REG_INT_EN, 0); - // PMU irqs cannot be cleared by PMU soft reset - pmu_read(PMU_REG_CHARGER_STATUS, &val); - pmu_write(PMU_REG_CHARGER_STATUS, val); - pmu_read(PMU_REG_INT_STATUS, &val); - pmu_write(PMU_REG_INT_CLR, val); + // Disable and clear all PMU irqs by default + pmu_write(PMU_REG_INT_MASK, 0); + pmu_write(PMU_REG_INT_EN, 0); + // PMU irqs cannot be cleared by PMU soft reset + pmu_read(PMU_REG_CHARGER_STATUS, &val); + pmu_write(PMU_REG_CHARGER_STATUS, val); + pmu_read(PMU_REG_INT_STATUS, &val); + pmu_write(PMU_REG_INT_CLR, val); - pmu_read(PMU_REG_POWER_KEY_CFG, &val); - // Allow PMU to sleep when power key is pressed - val &= ~POWERKEY_WAKEUP_OSC_EN; - // Increase big bandgap startup time (stable time) - val = SET_BITFIELD(val, REG_VCORE_SSTIME_MODE, 2); - pmu_write(PMU_REG_POWER_KEY_CFG, val); + pmu_read(PMU_REG_POWER_KEY_CFG, &val); + // Allow PMU to sleep when power key is pressed + val &= ~POWERKEY_WAKEUP_OSC_EN; + // Increase big bandgap startup time (stable time) + val = SET_BITFIELD(val, REG_VCORE_SSTIME_MODE, 2); + pmu_write(PMU_REG_POWER_KEY_CFG, val); #ifdef FORCE_BIG_BANDGAP - // Force big bandgap - pmu_read(PMU_REG_INT_EN, &val); - val |= REG_BG_SLEEP_MSK; - pmu_write(PMU_REG_INT_EN, val); - pmu_read(PMU_REG_BIAS_CFG, &val); - val |= BG_CONSTANT_GM_BIAS_DR | BG_CONSTANT_GM_BIAS_REG; - val |= BG_CORE_EN_DR | BG_CORE_EN_REG; - pmu_write(PMU_REG_BIAS_CFG, val); - hal_sys_timer_delay_us(20); - val |= BG_VBG_SEL_DR | BG_VBG_SEL_REG; - pmu_write(PMU_REG_BIAS_CFG, val); + // Force big bandgap + pmu_read(PMU_REG_INT_EN, &val); + val |= REG_BG_SLEEP_MSK; + pmu_write(PMU_REG_INT_EN, val); + pmu_read(PMU_REG_BIAS_CFG, &val); + val |= BG_CONSTANT_GM_BIAS_DR | BG_CONSTANT_GM_BIAS_REG; + val |= BG_CORE_EN_DR | BG_CORE_EN_REG; + pmu_write(PMU_REG_BIAS_CFG, val); + hal_sys_timer_delay_us(20); + val |= BG_VBG_SEL_DR | BG_VBG_SEL_REG; + pmu_write(PMU_REG_BIAS_CFG, val); #else - // Allow low power bandgap - pmu_read(PMU_REG_BIAS_CFG, &val); - val &= ~BG_VBG_SEL_DR; - pmu_write(PMU_REG_BIAS_CFG, val); + // Allow low power bandgap + pmu_read(PMU_REG_BIAS_CFG, &val); + val &= ~BG_VBG_SEL_DR; + pmu_write(PMU_REG_BIAS_CFG, val); #endif - // Init DCDC settings part 1 - if (pmu_metal_id >= HAL_CHIP_METAL_ID_1) { - pmu_write(PMU_REG_DCDC_ANA_CFG_16, 0x8E0F); - pmu_write(PMU_REG_DCDC_ANA_CFG_17, 0x0211); - pmu_write(PMU_REG_DCDC_ANA_CFG_18, 0xA484); - pmu_write(PMU_REG_DCDC_ANA_CFG_19, 0xE210); + // Init DCDC settings part 1 + if (pmu_metal_id >= HAL_CHIP_METAL_ID_1) { + pmu_write(PMU_REG_DCDC_ANA_CFG_16, 0x8E0F); + pmu_write(PMU_REG_DCDC_ANA_CFG_17, 0x0211); + pmu_write(PMU_REG_DCDC_ANA_CFG_18, 0xA484); + pmu_write(PMU_REG_DCDC_ANA_CFG_19, 0xE210); - pmu_write(PMU_REG_DCDC_HPPA_CFG_1A, 0x8E0F); - pmu_write(PMU_REG_DCDC_HPPA_CFG_1B, 0x0211); - pmu_write(PMU_REG_DCDC_HPPA_CFG_1C, 0xA484); - pmu_write(PMU_REG_DCDC_HPPA_CFG_1D, 0xE210); + pmu_write(PMU_REG_DCDC_HPPA_CFG_1A, 0x8E0F); + pmu_write(PMU_REG_DCDC_HPPA_CFG_1B, 0x0211); + pmu_write(PMU_REG_DCDC_HPPA_CFG_1C, 0xA484); + pmu_write(PMU_REG_DCDC_HPPA_CFG_1D, 0xE210); - pmu_write(PMU_REG_DCDC_DIG_CFG_33, 0x8E0F); - pmu_write(PMU_REG_DCDC_DIG_CFG_34, 0x0211); - pmu_write(PMU_REG_DCDC_DIG_CFG_35, 0xA484); - pmu_write(PMU_REG_DCDC_DIG_CFG_36, 0xE210); + pmu_write(PMU_REG_DCDC_DIG_CFG_33, 0x8E0F); + pmu_write(PMU_REG_DCDC_DIG_CFG_34, 0x0211); + pmu_write(PMU_REG_DCDC_DIG_CFG_35, 0xA484); + pmu_write(PMU_REG_DCDC_DIG_CFG_36, 0xE210); - pmu_read(PMU_REG_MIC_LDO_EN, &val); - val |= DCDC1_OFFSET_CURRENT_EN; - pmu_write(PMU_REG_MIC_LDO_EN, val); + pmu_read(PMU_REG_MIC_LDO_EN, &val); + val |= DCDC1_OFFSET_CURRENT_EN; + pmu_write(PMU_REG_MIC_LDO_EN, val); - pmu_read(PMU_REG_DCDC1_OFFSET, &val); - val = SET_BITFIELD(val, DCDC1_OFFSET_BIT, 0xE0); - pmu_write(PMU_REG_DCDC1_OFFSET, val); - } + pmu_read(PMU_REG_DCDC1_OFFSET, &val); + val = SET_BITFIELD(val, DCDC1_OFFSET_BIT, 0xE0); + pmu_write(PMU_REG_DCDC1_OFFSET, val); + } #ifdef PMU_DCDC_CALIB - pmu_get_dcdc_calib_value(); + pmu_get_dcdc_calib_value(); #endif #ifndef NO_SLEEP - pmu_sleep_en(true); + pmu_sleep_en(true); #endif - // Disable vbat2vcore - pmu_module_config(PMU_BAT2DIG,PMU_MANUAL_MODE,PMU_LDO_OFF,PMU_LP_MODE_ON,PMU_DSLEEP_MODE_OFF); + // Disable vbat2vcore + pmu_module_config(PMU_BAT2DIG, PMU_MANUAL_MODE, PMU_LDO_OFF, PMU_LP_MODE_ON, + PMU_DSLEEP_MODE_OFF); #ifdef LBRT - // Enable vbuck2ana - pmu_module_config(PMU_BUCK2ANA,PMU_MANUAL_MODE,PMU_LDO_ON,PMU_LP_MODE_ON,PMU_DSLEEP_MODE_ON); - pmu_module_set_volt(PMU_BUCK2ANA, PMU_VBUCK2ANA_1_3V, PMU_VBUCK2ANA_1_3V); - // Disable vana dcdc - pmu_read(PMU_REG_HPPA_LDO_EN, &val); - val &= ~REG_BYPASS_VBUCK2ANA; - pmu_write(PMU_REG_HPPA_LDO_EN, val); + // Enable vbuck2ana + pmu_module_config(PMU_BUCK2ANA, PMU_MANUAL_MODE, PMU_LDO_ON, PMU_LP_MODE_ON, + PMU_DSLEEP_MODE_ON); + pmu_module_set_volt(PMU_BUCK2ANA, PMU_VBUCK2ANA_1_3V, PMU_VBUCK2ANA_1_3V); + // Disable vana dcdc + pmu_read(PMU_REG_HPPA_LDO_EN, &val); + val &= ~REG_BYPASS_VBUCK2ANA; + pmu_write(PMU_REG_HPPA_LDO_EN, val); #else - // Disable vbuck2ana - pmu_module_config(PMU_BUCK2ANA,PMU_MANUAL_MODE,PMU_LDO_OFF,PMU_LP_MODE_ON,PMU_DSLEEP_MODE_OFF); + // Disable vbuck2ana + pmu_module_config(PMU_BUCK2ANA, PMU_MANUAL_MODE, PMU_LDO_OFF, PMU_LP_MODE_ON, + PMU_DSLEEP_MODE_OFF); #endif - // Disable vhppa ldo - pmu_ldo_hppa_en(false); + // Disable vhppa ldo + pmu_ldo_hppa_en(false); #ifdef VMEM_ON - pmu_module_config(PMU_MEM,PMU_MANUAL_MODE,PMU_LDO_ON,PMU_LP_MODE_ON,PMU_DSLEEP_MODE_ON); - pmu_module_ramp_volt(PMU_MEM, PMU_VMEM_1_8V, PMU_VMEM_1_8V); - pmu_hppa_en(false); - // VHPPA will be enabled/disabled dynamically. Enable soft start. - pmu_read(PMU_REG_DCDC_HPPA_CFG_1D, &val); - val |= DCDC3_SOFT_START_EN; - pmu_write(PMU_REG_DCDC_HPPA_CFG_1D, val); + pmu_module_config(PMU_MEM, PMU_MANUAL_MODE, PMU_LDO_ON, PMU_LP_MODE_ON, + PMU_DSLEEP_MODE_ON); + pmu_module_ramp_volt(PMU_MEM, PMU_VMEM_1_8V, PMU_VMEM_1_8V); + pmu_hppa_en(false); + // VHPPA will be enabled/disabled dynamically. Enable soft start. + pmu_read(PMU_REG_DCDC_HPPA_CFG_1D, &val); + val |= DCDC3_SOFT_START_EN; + pmu_write(PMU_REG_DCDC_HPPA_CFG_1D, val); #else - // vmem and vhppa is shorted -- enable vhppa dcdc and disable vmem ldo - val = pmu_vhppa_mv_to_val(1800); - pmu_hppa_set_volt(val, val); - pmu_hppa_en(true); - pmu_module_config(PMU_MEM,PMU_MANUAL_MODE,PMU_LDO_OFF,PMU_LP_MODE_ON,PMU_DSLEEP_MODE_OFF); + // vmem and vhppa is shorted -- enable vhppa dcdc and disable vmem ldo + val = pmu_vhppa_mv_to_val(1800); + pmu_hppa_set_volt(val, val); + pmu_hppa_en(true); + pmu_module_config(PMU_MEM, PMU_MANUAL_MODE, PMU_LDO_OFF, PMU_LP_MODE_ON, + PMU_DSLEEP_MODE_OFF); #endif - pmu_module_config(PMU_GP,PMU_MANUAL_MODE,PMU_LDO_OFF,PMU_LP_MODE_ON,PMU_DSLEEP_MODE_OFF); + pmu_module_config(PMU_GP, PMU_MANUAL_MODE, PMU_LDO_OFF, PMU_LP_MODE_ON, + PMU_DSLEEP_MODE_OFF); #ifndef PROGRAMMER #ifdef VUSB_ON - pmu_vusb_req |= PMU_VUSB_REQ_INIT; + pmu_vusb_req |= PMU_VUSB_REQ_INIT; #endif - // Disable usbphy power, and vusb if possible - pmu_usb_config(PMU_USB_CONFIG_TYPE_NONE); + // Disable usbphy power, and vusb if possible + pmu_usb_config(PMU_USB_CONFIG_TYPE_NONE); #ifdef VUSB_ON - pmu_vusb_req &= ~PMU_VUSB_REQ_INIT; + pmu_vusb_req &= ~PMU_VUSB_REQ_INIT; #endif #endif #ifdef __BEST_FLASH_VIA_ANA__ - pmu_module_config(PMU_IO,PMU_AUTO_MODE,PMU_LDO_ON,PMU_LP_MODE_ON,PMU_DSLEEP_MODE_OFF); + pmu_module_config(PMU_IO, PMU_AUTO_MODE, PMU_LDO_ON, PMU_LP_MODE_ON, + PMU_DSLEEP_MODE_OFF); #else - pmu_module_config(PMU_IO,PMU_AUTO_MODE,PMU_LDO_ON,PMU_LP_MODE_ON,PMU_DSLEEP_MODE_ON); + pmu_module_config(PMU_IO, PMU_AUTO_MODE, PMU_LDO_ON, PMU_LP_MODE_ON, + PMU_DSLEEP_MODE_ON); #endif - pmu_module_ramp_volt(PMU_IO, vio_lp, vio_act_normal); + pmu_module_ramp_volt(PMU_IO, vio_lp, vio_act_normal); - // Disable vcodec - pmu_module_config(PMU_CODEC,PMU_MANUAL_MODE,PMU_LDO_OFF,PMU_LP_MODE_ON,PMU_DSLEEP_MODE_OFF); - // Disable vhppa2vcodec - pmu_module_config(PMU_HPPA2CODEC,PMU_MANUAL_MODE,PMU_LDO_OFF,PMU_LP_MODE_ON,PMU_DSLEEP_MODE_OFF); + // Disable vcodec + pmu_module_config(PMU_CODEC, PMU_MANUAL_MODE, PMU_LDO_OFF, PMU_LP_MODE_ON, + PMU_DSLEEP_MODE_OFF); + // Disable vhppa2vcodec + pmu_module_config(PMU_HPPA2CODEC, PMU_MANUAL_MODE, PMU_LDO_OFF, + PMU_LP_MODE_ON, PMU_DSLEEP_MODE_OFF); #ifdef VHPPA2VCODEC - codec = PMU_HPPA2CODEC; + codec = PMU_HPPA2CODEC; #else - codec = PMU_CODEC; + codec = PMU_CODEC; #endif - val = pmu_vcodec_mv_to_val(vcodec_mv); - // No need to ramp because the LDO is disabled (and its soft start is enabled) - pmu_module_set_volt(codec, val, val); + val = pmu_vcodec_mv_to_val(vcodec_mv); + // No need to ramp because the LDO is disabled (and its soft start is enabled) + pmu_module_set_volt(codec, val, val); - val = pmu_vhppa_mv_to_val(vhppa_mv); + val = pmu_vhppa_mv_to_val(vhppa_mv); #ifdef VMEM_ON - // No need to ramp because VHPPA is disabled (and its soft start is enabled) - pmu_hppa_set_volt(val, val); + // No need to ramp because VHPPA is disabled (and its soft start is enabled) + pmu_hppa_set_volt(val, val); #else - uint16_t old_act_volt; - uint16_t old_lp_volt; + uint16_t old_act_volt; + uint16_t old_lp_volt; - // VHPPA is on. Ramp is needed. - pmu_hppa_get_volt(&old_act_volt, &old_lp_volt); - if (old_act_volt < val) { - while (old_act_volt++ < val) { - pmu_hppa_set_volt(old_act_volt, val); - } - } else if (old_act_volt != val || old_lp_volt != val) { - pmu_hppa_set_volt(val, val); + // VHPPA is on. Ramp is needed. + pmu_hppa_get_volt(&old_act_volt, &old_lp_volt); + if (old_act_volt < val) { + while (old_act_volt++ < val) { + pmu_hppa_set_volt(old_act_volt, val); } + } else if (old_act_volt != val || old_lp_volt != val) { + pmu_hppa_set_volt(val, val); + } #endif #ifdef DIG_DCDC_MODE - mode = PMU_POWER_MODE_DIG_DCDC; + mode = PMU_POWER_MODE_DIG_DCDC; #elif defined(ANA_DCDC_MODE) - mode = PMU_POWER_MODE_ANA_DCDC; + mode = PMU_POWER_MODE_ANA_DCDC; #else // LDO_MODE - mode = PMU_POWER_MODE_LDO; + mode = PMU_POWER_MODE_LDO; #endif - pmu_mode_change(mode); + pmu_mode_change(mode); #ifdef RTC_ENABLE - pmu_rtc_restore_context(); + pmu_rtc_restore_context(); #endif #if defined(MCU_HIGH_PERFORMANCE_MODE) - // Increase bbpll voltage - pmu_write(0xA0, 0x3FE8); // div=2 (bit14=0) - pmu_write(0xA1, 0xF918); + // Increase bbpll voltage + pmu_write(0xA0, 0x3FE8); // div=2 (bit14=0) + pmu_write(0xA1, 0xF918); - pmu_high_performance_mode_enable(true); + pmu_high_performance_mode_enable(true); #endif - // Init DCDC settings part 2 - if (pmu_metal_id >= HAL_CHIP_METAL_ID_1) { - hal_sys_timer_delay_us(5000); - pmu_write(PMU_REG_DCDC_ANA_CFG_16, 0x8E1F); - pmu_write(PMU_REG_DCDC_HPPA_CFG_1A, 0x8E1F); - pmu_write(PMU_REG_DCDC_DIG_CFG_33, 0x8E1F); - } + // Init DCDC settings part 2 + if (pmu_metal_id >= HAL_CHIP_METAL_ID_1) { + hal_sys_timer_delay_us(5000); + pmu_write(PMU_REG_DCDC_ANA_CFG_16, 0x8E1F); + pmu_write(PMU_REG_DCDC_HPPA_CFG_1A, 0x8E1F); + pmu_write(PMU_REG_DCDC_DIG_CFG_33, 0x8E1F); + } #endif // PMU_INIT || (!FPGA && !PROGRAMMER) - return 0; + return 0; } -void pmu_codec_vad_save_power(void) -{ - uint16_t val; +void pmu_codec_vad_save_power(void) { + uint16_t val; - // reduce ldo power supply + // reduce ldo power supply + pmu_read(PMU_REG_DCDC_RAMP_EN, &val); + val &= ~REG_MIC_BIASA_IX2; + pmu_write(PMU_REG_DCDC_RAMP_EN, val); + + // enable dcdc1 low power mode + pmu_read(PMU_REG_DCDC_DIG_EN, &val); + val |= REG_DCDC1_ULP_MODE_NORMAL; + pmu_write(PMU_REG_DCDC_DIG_EN, val); + + // enable dcdc2 low power mode + pmu_read(PMU_REG_DCDC_ANA_EN, &val); + val |= REG_DCDC2_ULP_MODE_NORMAL; + pmu_write(PMU_REG_DCDC_ANA_EN, val); + + // enable dcdc3 low power mode + pmu_read(PMU_REG_DCDC_HPPA_EN, &val); + val |= REG_DCDC3_ULP_MODE_NORMAL; + pmu_write(PMU_REG_DCDC_HPPA_EN, val); +} + +void pmu_codec_vad_restore_power(void) { + uint16_t val; + + // restore ldo power supply + pmu_read(PMU_REG_DCDC_RAMP_EN, &val); + val |= REG_MIC_BIASA_IX2; + pmu_write(PMU_REG_DCDC_RAMP_EN, val); + + // disable dcdc1 low power mode + pmu_read(PMU_REG_DCDC_DIG_EN, &val); + val &= ~REG_DCDC1_ULP_MODE_NORMAL; + pmu_write(PMU_REG_DCDC_DIG_EN, val); + + // disable dcdc2 low power mode + pmu_read(PMU_REG_DCDC_ANA_EN, &val); + val &= ~REG_DCDC2_ULP_MODE_NORMAL; + pmu_write(PMU_REG_DCDC_ANA_EN, val); + + // disable dcdc3 low power mode + pmu_read(PMU_REG_DCDC_HPPA_EN, &val); + val &= ~REG_DCDC3_ULP_MODE_NORMAL; + pmu_write(PMU_REG_DCDC_HPPA_EN, val); +} + +void pmu_sleep(void) { + uint16_t val; + + if (dcdc_ramp_map) { + // Enable DCDC ramp pmu_read(PMU_REG_DCDC_RAMP_EN, &val); - val &= ~REG_MIC_BIASA_IX2; + val |= dcdc_ramp_map; pmu_write(PMU_REG_DCDC_RAMP_EN, val); + } - // enable dcdc1 low power mode - pmu_read(PMU_REG_DCDC_DIG_EN, &val); - val |= REG_DCDC1_ULP_MODE_NORMAL; - pmu_write(PMU_REG_DCDC_DIG_EN, val); - - // enable dcdc2 low power mode - pmu_read(PMU_REG_DCDC_ANA_EN, &val); - val |= REG_DCDC2_ULP_MODE_NORMAL; - pmu_write(PMU_REG_DCDC_ANA_EN, val); - - // enable dcdc3 low power mode - pmu_read(PMU_REG_DCDC_HPPA_EN, &val); - val |= REG_DCDC3_ULP_MODE_NORMAL; - pmu_write(PMU_REG_DCDC_HPPA_EN, val); + return; } -void pmu_codec_vad_restore_power(void) -{ - uint16_t val; +void pmu_wakeup(void) { + uint16_t val; - // restore ldo power supply + if (dcdc_ramp_map) { + // Disable DCDC ramp so that s/w can control the voltages freely pmu_read(PMU_REG_DCDC_RAMP_EN, &val); - val |= REG_MIC_BIASA_IX2; + val &= ~dcdc_ramp_map; pmu_write(PMU_REG_DCDC_RAMP_EN, val); + } - // disable dcdc1 low power mode - pmu_read(PMU_REG_DCDC_DIG_EN, &val); - val &= ~REG_DCDC1_ULP_MODE_NORMAL; - pmu_write(PMU_REG_DCDC_DIG_EN, val); - - // disable dcdc2 low power mode - pmu_read(PMU_REG_DCDC_ANA_EN, &val); - val &= ~REG_DCDC2_ULP_MODE_NORMAL; - pmu_write(PMU_REG_DCDC_ANA_EN, val); - - // disable dcdc3 low power mode - pmu_read(PMU_REG_DCDC_HPPA_EN, &val); - val &= ~REG_DCDC3_ULP_MODE_NORMAL; - pmu_write(PMU_REG_DCDC_HPPA_EN, val); + return; } -void pmu_sleep(void) -{ - uint16_t val; - - if (dcdc_ramp_map) { - // Enable DCDC ramp - pmu_read(PMU_REG_DCDC_RAMP_EN, &val); - val |= dcdc_ramp_map; - pmu_write(PMU_REG_DCDC_RAMP_EN, val); - } - - return; -} - -void pmu_wakeup(void) -{ - uint16_t val; - - if (dcdc_ramp_map) { - // Disable DCDC ramp so that s/w can control the voltages freely - pmu_read(PMU_REG_DCDC_RAMP_EN, &val); - val &= ~dcdc_ramp_map; - pmu_write(PMU_REG_DCDC_RAMP_EN, val); - } - - return; -} - -void pmu_codec_config(int enable) -{ - enum PMU_MODUAL_T codec; +void pmu_codec_config(int enable) { + enum PMU_MODUAL_T codec; #ifdef VHPPA2VCODEC - codec = PMU_HPPA2CODEC; + codec = PMU_HPPA2CODEC; #else - codec = PMU_CODEC; + codec = PMU_CODEC; #endif - if (vcodec_off) { + if (vcodec_off) { #ifdef VMEM_ON - pmu_hppa_en(enable); + pmu_hppa_en(enable); #endif + } else { + if (enable) { + pmu_module_config(codec, PMU_MANUAL_MODE, PMU_LDO_ON, PMU_LP_MODE_ON, + PMU_DSLEEP_MODE_OFF); } else { - if (enable) { - pmu_module_config(codec,PMU_MANUAL_MODE,PMU_LDO_ON,PMU_LP_MODE_ON,PMU_DSLEEP_MODE_OFF); - } else { - pmu_module_config(codec,PMU_MANUAL_MODE,PMU_LDO_OFF,PMU_LP_MODE_ON,PMU_DSLEEP_MODE_OFF); - } + pmu_module_config(codec, PMU_MANUAL_MODE, PMU_LDO_OFF, PMU_LP_MODE_ON, + PMU_DSLEEP_MODE_OFF); } + } } -void pmu_codec_hppa_enable(int enable) -{ - if (!vcodec_off) { +void pmu_codec_hppa_enable(int enable) { + if (!vcodec_off) { #ifdef VMEM_ON - pmu_hppa_en(enable); + pmu_hppa_en(enable); #endif - } + } } -static uint32_t mic_bias_remap(uint32_t map) -{ - // The vmic1 pin has been replaced by the vmic3 pin in package bonding for all chip models since ver-B - if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) { - if (map & AUD_VMIC_MAP_VMIC1) { - map = (map & ~AUD_VMIC_MAP_VMIC1) | AUD_VMIC_MAP_VMIC3; - } +static uint32_t mic_bias_remap(uint32_t map) { + // The vmic1 pin has been replaced by the vmic3 pin in package bonding for all + // chip models since ver-B + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) { + if (map & AUD_VMIC_MAP_VMIC1) { + map = (map & ~AUD_VMIC_MAP_VMIC1) | AUD_VMIC_MAP_VMIC3; } + } - return map; + return map; } -void pmu_codec_mic_bias_enable(uint32_t map) -{ - uint16_t val; - int i; - enum PMU_REG_T bias_reg; - uint16_t ldo_en; - uint8_t volt; - uint8_t res; - static const uint16_t ldo_mask = REG_MIC_LDOA_EN | REG_MIC_LDOB_EN | REG_MIC_LDOC_EN | REG_MIC_LDOD_EN | REG_MIC_LDOE_EN; +void pmu_codec_mic_bias_enable(uint32_t map) { + uint16_t val; + int i; + enum PMU_REG_T bias_reg; + uint16_t ldo_en; + uint8_t volt; + uint8_t res; + static const uint16_t ldo_mask = REG_MIC_LDOA_EN | REG_MIC_LDOB_EN | + REG_MIC_LDOC_EN | REG_MIC_LDOD_EN | + REG_MIC_LDOE_EN; - map = mic_bias_remap(map); + map = mic_bias_remap(map); #ifdef DIGMIC_HIGH_VOLT - volt = PMU_VMIC_3_3V; + volt = PMU_VMIC_3_3V; #else - volt = PMU_VMIC_2_2V; + volt = PMU_VMIC_2_2V; #endif - if (vcodec_mv < 1900) { - if (volt >= 0x1F) { - volt = 0x1F; - } else { - volt += 1; - } + if (vcodec_mv < 1900) { + if (volt >= 0x1F) { + volt = 0x1F; + } else { + volt += 1; } + } - res = PMU_VMIC_RES_3_3V; + res = PMU_VMIC_RES_3_3V; - ldo_en = 0; - for (i = 0; i < MAX_ANA_MIC_CH_NUM; i++) { - if (i == MAX_ANA_MIC_CH_NUM - 1) { - bias_reg = PMU_REG_MIC_BIAS_E; - } else { - bias_reg = PMU_REG_MIC_BIAS_A + i; - } - pmu_read(bias_reg, &val); - if (map & (AUD_VMIC_MAP_VMIC1 << i)) { - ldo_en |= (REG_MIC_LDOA_EN >> i); - val = (val & ~(REG_MIC_BIASA_VSEL_MASK | REG_MIC_LDOA_RES_MASK)) | - REG_MIC_BIASA_VSEL(volt) | REG_MIC_LDOA_RES(res) | REG_MIC_BIASA_EN; - } else { - val &= ~REG_MIC_BIASA_EN; - } - pmu_write(bias_reg, val); + ldo_en = 0; + for (i = 0; i < MAX_ANA_MIC_CH_NUM; i++) { + if (i == MAX_ANA_MIC_CH_NUM - 1) { + bias_reg = PMU_REG_MIC_BIAS_E; + } else { + bias_reg = PMU_REG_MIC_BIAS_A + i; } - pmu_read(PMU_REG_MIC_LDO_EN, &val); - val = (val & ~ldo_mask) | ldo_en; - pmu_write(PMU_REG_MIC_LDO_EN, val); -} - -void pmu_codec_mic_bias_lowpower_mode(uint32_t map) -{ - uint16_t val; - - map = mic_bias_remap(map); - - if (map & AUD_VMIC_MAP_VMIC3) { - pmu_read(PMU_REG_DCDC_RAMP_EN, &val); - val &= ~REG_MIC_BIASC_IX2; - pmu_write(PMU_REG_DCDC_RAMP_EN, val); - - pmu_read(PMU_REG_MIC_BIAS_C, &val); - val = SET_BITFIELD(val, REG_MIC_BIASC_CHANSEL, 0x3); - pmu_write(PMU_REG_MIC_BIAS_C, val); + pmu_read(bias_reg, &val); + if (map & (AUD_VMIC_MAP_VMIC1 << i)) { + ldo_en |= (REG_MIC_LDOA_EN >> i); + val = (val & ~(REG_MIC_BIASA_VSEL_MASK | REG_MIC_LDOA_RES_MASK)) | + REG_MIC_BIASA_VSEL(volt) | REG_MIC_LDOA_RES(res) | REG_MIC_BIASA_EN; + } else { + val &= ~REG_MIC_BIASA_EN; } + pmu_write(bias_reg, val); + } + pmu_read(PMU_REG_MIC_LDO_EN, &val); + val = (val & ~ldo_mask) | ldo_en; + pmu_write(PMU_REG_MIC_LDO_EN, val); } -void pmu_codec_adc_pre_start(void) -{ +void pmu_codec_mic_bias_lowpower_mode(uint32_t map) { + uint16_t val; + + map = mic_bias_remap(map); + + if (map & AUD_VMIC_MAP_VMIC3) { + pmu_read(PMU_REG_DCDC_RAMP_EN, &val); + val &= ~REG_MIC_BIASC_IX2; + pmu_write(PMU_REG_DCDC_RAMP_EN, val); + + pmu_read(PMU_REG_MIC_BIAS_C, &val); + val = SET_BITFIELD(val, REG_MIC_BIASC_CHANSEL, 0x3); + pmu_write(PMU_REG_MIC_BIAS_C, val); + } } -void pmu_codec_adc_post_start(void (*delay_ms)(uint32_t)) -{ -} +void pmu_codec_adc_pre_start(void) {} -void pmu_codec_dac_pre_start(void) -{ -} +void pmu_codec_adc_post_start(void (*delay_ms)(uint32_t)) {} -void pmu_codec_dac_post_start(void (*delay_ms)(uint32_t)) -{ -} +void pmu_codec_dac_pre_start(void) {} -SRAM_TEXT_LOC void pmu_flash_write_config(void) -{ +void pmu_codec_dac_post_start(void (*delay_ms)(uint32_t)) {} + +SRAM_TEXT_LOC void pmu_flash_write_config(void) { #ifdef FLASH_WRITE_AT_HIGH_VCORE - uint32_t lock; + uint32_t lock; - if (pmu_vcore_req & PMU_VCORE_FLASH_WRITE_ENABLED) { - return; - } + if (pmu_vcore_req & PMU_VCORE_FLASH_WRITE_ENABLED) { + return; + } #if defined(__PMU_VIO_DYNAMIC_CTRL_MODE__) - pmu_viorise_req(PMU_VIORISE_REQ_USER_FLASH, true); + pmu_viorise_req(PMU_VIORISE_REQ_USER_FLASH, true); #endif - lock = int_lock(); - pmu_vcore_req |= PMU_VCORE_FLASH_WRITE_ENABLED; - int_unlock(lock); + lock = int_lock(); + pmu_vcore_req |= PMU_VCORE_FLASH_WRITE_ENABLED; + int_unlock(lock); - pmu_dig_set_volt(0, PMU_POWER_MODE_NONE); + pmu_dig_set_volt(0, PMU_POWER_MODE_NONE); #endif } -SRAM_TEXT_LOC void pmu_flash_read_config(void) -{ +SRAM_TEXT_LOC void pmu_flash_read_config(void) { #ifdef FLASH_WRITE_AT_HIGH_VCORE - uint32_t lock; + uint32_t lock; - if ((pmu_vcore_req & PMU_VCORE_FLASH_WRITE_ENABLED) == 0) { - return; - } + if ((pmu_vcore_req & PMU_VCORE_FLASH_WRITE_ENABLED) == 0) { + return; + } - lock = int_lock(); - pmu_vcore_req &= ~PMU_VCORE_FLASH_WRITE_ENABLED; - int_unlock(lock); + lock = int_lock(); + pmu_vcore_req &= ~PMU_VCORE_FLASH_WRITE_ENABLED; + int_unlock(lock); - pmu_dig_set_volt(0, PMU_POWER_MODE_NONE); + pmu_dig_set_volt(0, PMU_POWER_MODE_NONE); #if defined(__PMU_VIO_DYNAMIC_CTRL_MODE__) - pmu_viorise_req(PMU_VIORISE_REQ_USER_FLASH, false); + pmu_viorise_req(PMU_VIORISE_REQ_USER_FLASH, false); #endif #endif } -void BOOT_TEXT_FLASH_LOC pmu_flash_freq_config(uint32_t freq) -{ +void BOOT_TEXT_FLASH_LOC pmu_flash_freq_config(uint32_t freq) { #if defined(PMU_INIT) || (!defined(FPGA) && !defined(PROGRAMMER)) - uint32_t lock; + uint32_t lock; - lock = int_lock(); - if (freq > 52000000) { - // The real max freq is 120M - //pmu_vcore_req |= PMU_VCORE_FLASH_FREQ_HIGH; - } else { - pmu_vcore_req &= ~PMU_VCORE_FLASH_FREQ_HIGH; - } - int_unlock(lock); + lock = int_lock(); + if (freq > 52000000) { + // The real max freq is 120M + // pmu_vcore_req |= PMU_VCORE_FLASH_FREQ_HIGH; + } else { + pmu_vcore_req &= ~PMU_VCORE_FLASH_FREQ_HIGH; + } + int_unlock(lock); - if (pmu_power_mode == PMU_POWER_MODE_NONE) { - // PMU not init yet - pmu_dig_init_volt(); - return; - } + if (pmu_power_mode == PMU_POWER_MODE_NONE) { + // PMU not init yet + pmu_dig_init_volt(); + return; + } - pmu_dig_set_volt(0, PMU_POWER_MODE_NONE); + pmu_dig_set_volt(0, PMU_POWER_MODE_NONE); #endif } -void BOOT_TEXT_FLASH_LOC pmu_psram_freq_config(uint32_t freq) -{ +void BOOT_TEXT_FLASH_LOC pmu_psram_freq_config(uint32_t freq) { #if defined(PMU_INIT) || (!defined(FPGA) && !defined(PROGRAMMER)) - uint32_t lock; + uint32_t lock; - lock = int_lock(); - if (freq > 52000000) { - pmu_vcore_req |= PMU_VCORE_PSRAM_FREQ_HIGH; - } else { - pmu_vcore_req &= ~PMU_VCORE_PSRAM_FREQ_HIGH; - } - int_unlock(lock); + lock = int_lock(); + if (freq > 52000000) { + pmu_vcore_req |= PMU_VCORE_PSRAM_FREQ_HIGH; + } else { + pmu_vcore_req &= ~PMU_VCORE_PSRAM_FREQ_HIGH; + } + int_unlock(lock); - if (pmu_power_mode == PMU_POWER_MODE_NONE) { - // PMU not init yet - pmu_dig_init_volt(); - return; - } + if (pmu_power_mode == PMU_POWER_MODE_NONE) { + // PMU not init yet + pmu_dig_init_volt(); + return; + } - pmu_dig_set_volt(0, PMU_POWER_MODE_NONE); + pmu_dig_set_volt(0, PMU_POWER_MODE_NONE); #endif } -void pmu_anc_config(int enable) -{ +void pmu_anc_config(int enable) {} + +void pmu_fir_high_speed_config(int enable) {} + +void pmu_iir_freq_config(uint32_t freq) {} + +void pmu_rs_freq_config(uint32_t freq) { + uint32_t lock; + + lock = int_lock(); + if (freq >= 60000000) { + pmu_vcore_req |= PMU_VCORE_RS_FREQ_HIGH; + } else { + pmu_vcore_req &= ~PMU_VCORE_RS_FREQ_HIGH; + } + int_unlock(lock); + + pmu_dig_set_volt(0, PMU_POWER_MODE_NONE); } -void pmu_fir_high_speed_config(int enable) -{ -} - -void pmu_iir_freq_config(uint32_t freq) -{ -} - -void pmu_rs_freq_config(uint32_t freq) -{ - uint32_t lock; - - lock = int_lock(); - if (freq >= 60000000) { - pmu_vcore_req |= PMU_VCORE_RS_FREQ_HIGH; - } else { - pmu_vcore_req &= ~PMU_VCORE_RS_FREQ_HIGH; - } - int_unlock(lock); - - pmu_dig_set_volt(0, PMU_POWER_MODE_NONE); -} - -void BOOT_TEXT_SRAM_LOC pmu_sys_freq_config(enum HAL_CMU_FREQ_T freq) -{ +void BOOT_TEXT_SRAM_LOC pmu_sys_freq_config(enum HAL_CMU_FREQ_T freq) { #if defined(PMU_INIT) || (!defined(FPGA) && !defined(PROGRAMMER)) -#if defined(MCU_HIGH_PERFORMANCE_MODE) || defined(ULTRA_LOW_POWER) || !defined(OSC_26M_X4_AUD2BB) - uint32_t lock; - enum PMU_VCORE_REQ_T old_req; - bool update = false; +#if defined(MCU_HIGH_PERFORMANCE_MODE) || defined(ULTRA_LOW_POWER) || \ + !defined(OSC_26M_X4_AUD2BB) + uint32_t lock; + enum PMU_VCORE_REQ_T old_req; + bool update = false; - lock = int_lock(); - old_req = pmu_vcore_req; - pmu_vcore_req &= ~(PMU_VCORE_SYS_FREQ_HIGH | PMU_VCORE_SYS_FREQ_MEDIUM); + lock = int_lock(); + old_req = pmu_vcore_req; + pmu_vcore_req &= ~(PMU_VCORE_SYS_FREQ_HIGH | PMU_VCORE_SYS_FREQ_MEDIUM); #if defined(MCU_HIGH_PERFORMANCE_MODE) - if (freq > HAL_CMU_FREQ_104M) { - if (high_perf_on) { - // The real freq is 350M - pmu_vcore_req |= PMU_VCORE_SYS_FREQ_HIGH; - } else { - pmu_vcore_req |= PMU_VCORE_SYS_FREQ_MEDIUM; - } + if (freq > HAL_CMU_FREQ_104M) { + if (high_perf_on) { + // The real freq is 350M + pmu_vcore_req |= PMU_VCORE_SYS_FREQ_HIGH; } else { + pmu_vcore_req |= PMU_VCORE_SYS_FREQ_MEDIUM; + } + } else { #ifndef OSC_26M_X4_AUD2BB - if (freq == HAL_CMU_FREQ_104M) { - // The real freq is 200M - pmu_vcore_req |= PMU_VCORE_SYS_FREQ_MEDIUM; - } -#endif + if (freq == HAL_CMU_FREQ_104M) { + // The real freq is 200M + pmu_vcore_req |= PMU_VCORE_SYS_FREQ_MEDIUM; } +#endif + } #else - if (freq > HAL_CMU_FREQ_104M) { - pmu_vcore_req |= PMU_VCORE_SYS_FREQ_MEDIUM; - } + if (freq > HAL_CMU_FREQ_104M) { + pmu_vcore_req |= PMU_VCORE_SYS_FREQ_MEDIUM; + } #endif - if (old_req != pmu_vcore_req) { - update = true; - } - int_unlock(lock); + if (old_req != pmu_vcore_req) { + update = true; + } + int_unlock(lock); - if (!update) { - // Nothing changes - return; - } + if (!update) { + // Nothing changes + return; + } - if (pmu_power_mode == PMU_POWER_MODE_NONE) { - // PMU not init yet - pmu_dig_init_volt(); - return; - } + if (pmu_power_mode == PMU_POWER_MODE_NONE) { + // PMU not init yet + pmu_dig_init_volt(); + return; + } - pmu_dig_set_volt(0, PMU_POWER_MODE_NONE); + pmu_dig_set_volt(0, PMU_POWER_MODE_NONE); #endif #endif } -void pmu_high_performance_mode_enable(bool enable) -{ +void pmu_high_performance_mode_enable(bool enable) { #if defined(MCU_HIGH_PERFORMANCE_MODE) - uint16_t val; + uint16_t val; - if (high_perf_on == enable) { - return; + if (high_perf_on == enable) { + return; + } + high_perf_on = enable; + + if (!enable) { + if (high_perf_freq_mhz > 300) { + // Switch to 52M to avoid using PLL + hal_cmu_sys_set_freq(HAL_CMU_FREQ_52M); + // Restore the default div + pmu_read(0xA0, &val); + val &= ~(1 << 14); // div=2 (bit14=0) + pmu_write(0xA0, val); + // Restore the sys freq + hal_cmu_sys_set_freq(hal_sysfreq_get_hw_freq()); } - high_perf_on = enable; + // Restore the default PLL freq (384M) + bbpll_freq_pll_config(192 * 1000000 * 2); + } - if (!enable) { - if (high_perf_freq_mhz > 300) { - // Switch to 52M to avoid using PLL - hal_cmu_sys_set_freq(HAL_CMU_FREQ_52M); - // Restore the default div - pmu_read(0xA0, &val); - val &= ~(1 << 14); // div=2 (bit14=0) - pmu_write(0xA0, val); - // Restore the sys freq - hal_cmu_sys_set_freq(hal_sysfreq_get_hw_freq()); - } - // Restore the default PLL freq (384M) - bbpll_freq_pll_config(192 * 1000000 * 2); + pmu_sys_freq_config(hal_sysfreq_get_hw_freq()); + + if (enable) { + uint32_t pll_freq; + + // Change freq first, and then change divider. + // Otherwise there will be an instant very high freq sent to digital domain. + + if (high_perf_freq_mhz <= 300) { + pll_freq = high_perf_freq_mhz * 1000000 * 2; + } else { + pll_freq = high_perf_freq_mhz * 1000000; } + bbpll_freq_pll_config(pll_freq); - pmu_sys_freq_config(hal_sysfreq_get_hw_freq()); - - if (enable) { - uint32_t pll_freq; - - // Change freq first, and then change divider. - // Otherwise there will be an instant very high freq sent to digital domain. - - if (high_perf_freq_mhz <= 300) { - pll_freq = high_perf_freq_mhz * 1000000 * 2; - } else { - pll_freq = high_perf_freq_mhz * 1000000; - } - bbpll_freq_pll_config(pll_freq); - - if (high_perf_freq_mhz > 300) { - // Switch to 52M to avoid using PLL - hal_cmu_sys_set_freq(HAL_CMU_FREQ_52M); - pmu_read(0xA0, &val); - val |= (1 << 14); // div=1 (bit14=1) - pmu_write(0xA0, val); - // Restore the sys freq - hal_cmu_sys_set_freq(hal_sysfreq_get_hw_freq()); - } + if (high_perf_freq_mhz > 300) { + // Switch to 52M to avoid using PLL + hal_cmu_sys_set_freq(HAL_CMU_FREQ_52M); + pmu_read(0xA0, &val); + val |= (1 << 14); // div=1 (bit14=1) + pmu_write(0xA0, val); + // Restore the sys freq + hal_cmu_sys_set_freq(hal_sysfreq_get_hw_freq()); } + } #endif } -void pmu_usb_config(enum PMU_USB_CONFIG_TYPE_T type) -{ - uint32_t lock; - bool update; - unsigned short ldo_on, deep_sleep_on; +void pmu_usb_config(enum PMU_USB_CONFIG_TYPE_T type) { + uint32_t lock; + bool update; + unsigned short ldo_on, deep_sleep_on; - update = false; + update = false; - if (type == PMU_USB_CONFIG_TYPE_NONE) { - usbphy_ldo_config(false); + if (type == PMU_USB_CONFIG_TYPE_NONE) { + usbphy_ldo_config(false); - ldo_on = PMU_LDO_OFF; - deep_sleep_on = PMU_DSLEEP_MODE_OFF; - } else { - ldo_on = PMU_LDO_ON; - deep_sleep_on = PMU_DSLEEP_MODE_ON; + ldo_on = PMU_LDO_OFF; + deep_sleep_on = PMU_DSLEEP_MODE_OFF; + } else { + ldo_on = PMU_LDO_ON; + deep_sleep_on = PMU_DSLEEP_MODE_ON; + } + + lock = int_lock(); + + if (type == PMU_USB_CONFIG_TYPE_NONE) { + pmu_vusb_req &= ~PMU_VUSB_REQ_USB; + if (pmu_vusb_req == 0) { + update = true; } - - lock = int_lock(); - - if (type == PMU_USB_CONFIG_TYPE_NONE) { - pmu_vusb_req &= ~PMU_VUSB_REQ_USB; - if (pmu_vusb_req == 0) { - update = true; - } - } else { - if (pmu_vusb_req == 0) { - update = true; - } - pmu_vusb_req |= PMU_VUSB_REQ_USB; + } else { + if (pmu_vusb_req == 0) { + update = true; } + pmu_vusb_req |= PMU_VUSB_REQ_USB; + } - if (update) { - pmu_module_config(PMU_USB, PMU_MANUAL_MODE, ldo_on, PMU_LP_MODE_ON, deep_sleep_on); - } + if (update) { + pmu_module_config(PMU_USB, PMU_MANUAL_MODE, ldo_on, PMU_LP_MODE_ON, + deep_sleep_on); + } #ifdef USB_HIGH_SPEED - if (type == PMU_USB_CONFIG_TYPE_NONE) { - pmu_vcore_req &= ~PMU_VCORE_USB_HS_ENABLED; - } else { - pmu_vcore_req |= PMU_VCORE_USB_HS_ENABLED; - } + if (type == PMU_USB_CONFIG_TYPE_NONE) { + pmu_vcore_req &= ~PMU_VCORE_USB_HS_ENABLED; + } else { + pmu_vcore_req |= PMU_VCORE_USB_HS_ENABLED; + } #endif - int_unlock(lock); + int_unlock(lock); - if (pmu_power_mode != PMU_POWER_MODE_NONE) { - // PMU has been inited - pmu_dig_set_volt(0, PMU_POWER_MODE_NONE); - } + if (pmu_power_mode != PMU_POWER_MODE_NONE) { + // PMU has been inited + pmu_dig_set_volt(0, PMU_POWER_MODE_NONE); + } - if (type != PMU_USB_CONFIG_TYPE_NONE) { - usbphy_ldo_config(true); - } + if (type != PMU_USB_CONFIG_TYPE_NONE) { + usbphy_ldo_config(true); + } } -void pmu_lbrt_config(int enable) -{ - uint32_t lock; - bool update; - unsigned short ldo_on, deep_sleep_on; +void pmu_lbrt_config(int enable) { + uint32_t lock; + bool update; + unsigned short ldo_on, deep_sleep_on; - update = false; + update = false; - if (enable) { - ldo_on = PMU_LDO_ON; - deep_sleep_on = PMU_DSLEEP_MODE_ON; - } else { - ldo_on = PMU_LDO_OFF; - deep_sleep_on = PMU_DSLEEP_MODE_OFF; + if (enable) { + ldo_on = PMU_LDO_ON; + deep_sleep_on = PMU_DSLEEP_MODE_ON; + } else { + ldo_on = PMU_LDO_OFF; + deep_sleep_on = PMU_DSLEEP_MODE_OFF; + } + + lock = int_lock(); + + if (enable) { + if (pmu_vusb_req == 0) { + update = true; } - - lock = int_lock(); - - if (enable) { - if (pmu_vusb_req == 0) { - update = true; - } - pmu_vusb_req |= PMU_VUSB_REQ_LBRT; - } else { - pmu_vusb_req &= ~PMU_VUSB_REQ_LBRT; - if (pmu_vusb_req == 0) { - update = true; - } + pmu_vusb_req |= PMU_VUSB_REQ_LBRT; + } else { + pmu_vusb_req &= ~PMU_VUSB_REQ_LBRT; + if (pmu_vusb_req == 0) { + update = true; } + } - if (update) { - pmu_module_config(PMU_USB, PMU_MANUAL_MODE, ldo_on, PMU_LP_MODE_ON, deep_sleep_on); - } + if (update) { + pmu_module_config(PMU_USB, PMU_MANUAL_MODE, ldo_on, PMU_LP_MODE_ON, + deep_sleep_on); + } - int_unlock(lock); + int_unlock(lock); } struct PMU_CHG_CTX_T { - uint16_t pmu_chg_status; + uint16_t pmu_chg_status; }; struct PMU_CHG_CTX_T BOOT_BSS_LOC pmu_chg_ctx; -void BOOT_TEXT_SRAM_LOC pmu_charger_save_context(void) -{ - pmu_read(PMU_REG_CHARGER_STATUS, &pmu_chg_ctx.pmu_chg_status); +void BOOT_TEXT_SRAM_LOC pmu_charger_save_context(void) { + pmu_read(PMU_REG_CHARGER_STATUS, &pmu_chg_ctx.pmu_chg_status); } -enum PMU_POWER_ON_CAUSE_T pmu_charger_poweron_status(void) -{ - enum PMU_POWER_ON_CAUSE_T pmu_power_on_cause = PMU_POWER_ON_CAUSE_NONE; +enum PMU_POWER_ON_CAUSE_T pmu_charger_poweron_status(void) { + enum PMU_POWER_ON_CAUSE_T pmu_power_on_cause = PMU_POWER_ON_CAUSE_NONE; - if (pmu_chg_ctx.pmu_chg_status & AC_ON_DET_OUT){ - pmu_power_on_cause = PMU_POWER_ON_CAUSE_CHARGER_ACOFF; - }else if (pmu_chg_ctx.pmu_chg_status & AC_ON){ - pmu_power_on_cause = PMU_POWER_ON_CAUSE_CHARGER_ACON; - } - return pmu_power_on_cause; + if (pmu_chg_ctx.pmu_chg_status & AC_ON_DET_OUT) { + pmu_power_on_cause = PMU_POWER_ON_CAUSE_CHARGER_ACOFF; + } else if (pmu_chg_ctx.pmu_chg_status & AC_ON) { + pmu_power_on_cause = PMU_POWER_ON_CAUSE_CHARGER_ACON; + } + return pmu_power_on_cause; } -void pmu_charger_init(void) -{ - unsigned short readval_cfg; - uint32_t lock; +void pmu_charger_init(void) { + unsigned short readval_cfg; + uint32_t lock; - lock = int_lock(); - pmu_read(PMU_REG_CHARGER_CFG, &readval_cfg); - readval_cfg &= ~(REG_CHARGE_IN_INTR_MSK | REG_CHARGE_OUT_INTR_MSK | - REG_AC_ON_OUT_EN | REG_AC_ON_IN_EN | REG_CHARGE_INTR_EN); - pmu_write(PMU_REG_CHARGER_CFG ,readval_cfg); - int_unlock(lock); + lock = int_lock(); + pmu_read(PMU_REG_CHARGER_CFG, &readval_cfg); + readval_cfg &= ~(REG_CHARGE_IN_INTR_MSK | REG_CHARGE_OUT_INTR_MSK | + REG_AC_ON_OUT_EN | REG_AC_ON_IN_EN | REG_CHARGE_INTR_EN); + pmu_write(PMU_REG_CHARGER_CFG, readval_cfg); + int_unlock(lock); - // PMU irqs cannot be cleared by PMU soft reset - pmu_read(PMU_REG_CHARGER_STATUS, &readval_cfg); - pmu_write(PMU_REG_CHARGER_STATUS, readval_cfg); - pmu_read(PMU_REG_INT_STATUS, &readval_cfg); - pmu_write(PMU_REG_INT_CLR, readval_cfg); + // PMU irqs cannot be cleared by PMU soft reset + pmu_read(PMU_REG_CHARGER_STATUS, &readval_cfg); + pmu_write(PMU_REG_CHARGER_STATUS, readval_cfg); + pmu_read(PMU_REG_INT_STATUS, &readval_cfg); + pmu_write(PMU_REG_INT_CLR, readval_cfg); - hal_sys_timer_delay(MS_TO_TICKS(1)); + hal_sys_timer_delay(MS_TO_TICKS(1)); - lock = int_lock(); - pmu_read(PMU_REG_CHARGER_CFG, &readval_cfg); - readval_cfg |= REG_AC_ON_OUT_EN | REG_AC_ON_IN_EN | REG_CHARGE_INTR_EN; - readval_cfg = SET_BITFIELD(readval_cfg, REG_AC_ON_DB_VALUE, 8); - pmu_write(PMU_REG_CHARGER_CFG ,readval_cfg); - int_unlock(lock); + lock = int_lock(); + pmu_read(PMU_REG_CHARGER_CFG, &readval_cfg); + readval_cfg |= REG_AC_ON_OUT_EN | REG_AC_ON_IN_EN | REG_CHARGE_INTR_EN; + readval_cfg = SET_BITFIELD(readval_cfg, REG_AC_ON_DB_VALUE, 8); + pmu_write(PMU_REG_CHARGER_CFG, readval_cfg); + int_unlock(lock); #ifdef PMU_ACON_CAUSE_POWER_UP - pmu_read(0x102 ,&readval_cfg); - readval_cfg |= 1; - pmu_write(0x102,readval_cfg); + pmu_read(0x102, &readval_cfg); + readval_cfg |= 1; + pmu_write(0x102, readval_cfg); #endif } -void pmu_charger_shutdown_config(void) -{ +void pmu_charger_shutdown_config(void) { #ifdef PMU_ACON_CAUSE_POWER_UP - pmu_wdt_stop(); - pmu_charger_init(); + pmu_wdt_stop(); + pmu_charger_init(); #endif } -static void pmu_charger_irq_handler(uint16_t irq_status) -{ - enum PMU_CHARGER_STATUS_T status = PMU_CHARGER_UNKNOWN; +static void pmu_charger_irq_handler(uint16_t irq_status) { + enum PMU_CHARGER_STATUS_T status = PMU_CHARGER_UNKNOWN; - PMU_DEBUG_TRACE(3,"%s REG_%02X=0x%04X", __func__, PMU_REG_CHARGER_STATUS, irq_status); + PMU_DEBUG_TRACE(3, "%s REG_%02X=0x%04X", __func__, PMU_REG_CHARGER_STATUS, + irq_status); - if ((irq_status & (AC_ON_DET_IN_MASKED | AC_ON_DET_OUT_MASKED)) == 0){ - PMU_DEBUG_TRACE(1,"%s SKIP", __func__); - return; - } else if ((irq_status & (AC_ON_DET_IN_MASKED | AC_ON_DET_OUT_MASKED)) == - (AC_ON_DET_IN_MASKED | AC_ON_DET_OUT_MASKED)) { - PMU_DEBUG_TRACE(1,"%s DITHERING", __func__); - hal_sys_timer_delay(2); - } else { - PMU_DEBUG_TRACE(1,"%s NORMAL", __func__); - } + if ((irq_status & (AC_ON_DET_IN_MASKED | AC_ON_DET_OUT_MASKED)) == 0) { + PMU_DEBUG_TRACE(1, "%s SKIP", __func__); + return; + } else if ((irq_status & (AC_ON_DET_IN_MASKED | AC_ON_DET_OUT_MASKED)) == + (AC_ON_DET_IN_MASKED | AC_ON_DET_OUT_MASKED)) { + PMU_DEBUG_TRACE(1, "%s DITHERING", __func__); + hal_sys_timer_delay(2); + } else { + PMU_DEBUG_TRACE(1, "%s NORMAL", __func__); + } - status = pmu_charger_get_status(); + status = pmu_charger_get_status(); - if (charger_irq_handler) { - charger_irq_handler(status); - } + if (charger_irq_handler) { + charger_irq_handler(status); + } } -void pmu_charger_set_irq_handler(PMU_CHARGER_IRQ_HANDLER_T handler) -{ - uint32_t lock; - uint16_t val; +void pmu_charger_set_irq_handler(PMU_CHARGER_IRQ_HANDLER_T handler) { + uint32_t lock; + uint16_t val; - charger_irq_handler = handler; + charger_irq_handler = handler; - lock = int_lock(); - pmu_read(PMU_REG_CHARGER_CFG, &val); - if (handler) { - val |= REG_CHARGE_IN_INTR_MSK | REG_CHARGE_OUT_INTR_MSK; - } else { - val &= ~(REG_CHARGE_IN_INTR_MSK | REG_CHARGE_OUT_INTR_MSK); - } - pmu_write(PMU_REG_CHARGER_CFG, val); - pmu_set_irq_unified_handler(PMU_IRQ_TYPE_CHARGER, handler ? pmu_charger_irq_handler : NULL); - int_unlock(lock); + lock = int_lock(); + pmu_read(PMU_REG_CHARGER_CFG, &val); + if (handler) { + val |= REG_CHARGE_IN_INTR_MSK | REG_CHARGE_OUT_INTR_MSK; + } else { + val &= ~(REG_CHARGE_IN_INTR_MSK | REG_CHARGE_OUT_INTR_MSK); + } + pmu_write(PMU_REG_CHARGER_CFG, val); + pmu_set_irq_unified_handler(PMU_IRQ_TYPE_CHARGER, + handler ? pmu_charger_irq_handler : NULL); + int_unlock(lock); } -void pmu_charger_plugin_config(void) -{ - if (IO_VOLT_ACTIVE_RISE < PMU_IO_3_1V) { - vio_act_rise = PMU_IO_3_1V; - } - if (IO_VOLT_SLEEP < PMU_IO_3_2V) { - vio_lp = PMU_IO_3_2V; - } - pmu_viorise_req(PMU_VIORISE_REQ_USER_CHARGER, true); +void pmu_charger_plugin_config(void) { + if (IO_VOLT_ACTIVE_RISE < PMU_IO_3_1V) { + vio_act_rise = PMU_IO_3_1V; + } + if (IO_VOLT_SLEEP < PMU_IO_3_2V) { + vio_lp = PMU_IO_3_2V; + } + pmu_viorise_req(PMU_VIORISE_REQ_USER_CHARGER, true); } -void pmu_charger_plugout_config(void) -{ - vio_act_rise = IO_VOLT_ACTIVE_RISE; - vio_lp = IO_VOLT_SLEEP; - pmu_viorise_req(PMU_VIORISE_REQ_USER_CHARGER, false); +void pmu_charger_plugout_config(void) { + vio_act_rise = IO_VOLT_ACTIVE_RISE; + vio_lp = IO_VOLT_SLEEP; + pmu_viorise_req(PMU_VIORISE_REQ_USER_CHARGER, false); } -enum PMU_CHARGER_STATUS_T pmu_charger_get_status(void) -{ - unsigned short readval; - enum PMU_CHARGER_STATUS_T status; +enum PMU_CHARGER_STATUS_T pmu_charger_get_status(void) { + unsigned short readval; + enum PMU_CHARGER_STATUS_T status; - pmu_read(PMU_REG_CHARGER_STATUS, &readval); - if (readval & AC_ON) - status = PMU_CHARGER_PLUGIN; - else - status = PMU_CHARGER_PLUGOUT; + pmu_read(PMU_REG_CHARGER_STATUS, &readval); + if (readval & AC_ON) + status = PMU_CHARGER_PLUGIN; + else + status = PMU_CHARGER_PLUGOUT; - return status; + return status; } #ifdef RTC_ENABLE -void pmu_rtc_enable(void) -{ - uint16_t readval; - uint32_t lock; +void pmu_rtc_enable(void) { + uint16_t readval; + uint32_t lock; #ifdef SIMU - // Set RTC counter to 1KHz - pmu_write(PMU_REG_RTC_DIV_1HZ, 32 - 2); + // Set RTC counter to 1KHz + pmu_write(PMU_REG_RTC_DIV_1HZ, 32 - 2); #else - // Set RTC counter to 1Hz - pmu_write(PMU_REG_RTC_DIV_1HZ, CONFIG_SYSTICK_HZ * 2 - 2); + // Set RTC counter to 1Hz + pmu_write(PMU_REG_RTC_DIV_1HZ, CONFIG_SYSTICK_HZ * 2 - 2); #endif - lock = int_lock(); - pmu_read(PMU_REG_POWER_KEY_CFG, &readval); - readval |= RTC_POWER_ON_EN | PU_LPO_DR | PU_LPO_REG; - pmu_write(PMU_REG_POWER_KEY_CFG, readval); - int_unlock(lock); + lock = int_lock(); + pmu_read(PMU_REG_POWER_KEY_CFG, &readval); + readval |= RTC_POWER_ON_EN | PU_LPO_DR | PU_LPO_REG; + pmu_write(PMU_REG_POWER_KEY_CFG, readval); + int_unlock(lock); } -void pmu_rtc_disable(void) -{ - uint16_t readval; - uint32_t lock; +void pmu_rtc_disable(void) { + uint16_t readval; + uint32_t lock; + pmu_rtc_clear_alarm(); + + lock = int_lock(); + pmu_read(PMU_REG_POWER_KEY_CFG, &readval); + readval &= ~(RTC_POWER_ON_EN | PU_LPO_DR); + pmu_write(PMU_REG_POWER_KEY_CFG, readval); + int_unlock(lock); +} + +int BOOT_TEXT_SRAM_LOC pmu_rtc_enabled(void) { + uint16_t readval; + + pmu_read(PMU_REG_POWER_KEY_CFG, &readval); + + return !!(readval & RTC_POWER_ON_EN); +} + +void pmu_rtc_set(uint32_t seconds) { + uint16_t high, low; + + // Need 3 seconds to load a new value + seconds += 3; + + high = seconds >> 16; + low = seconds & 0xFFFF; + + pmu_write(PMU_REG_RTC_LOAD_LOW, low); + pmu_write(PMU_REG_RTC_LOAD_HIGH, high); +} + +uint32_t pmu_rtc_get(void) { + uint16_t high, low, high2; + + pmu_read(PMU_REG_RTC_VAL_HIGH, &high); + pmu_read(PMU_REG_RTC_VAL_LOW, &low); + // Handle counter wrap + pmu_read(PMU_REG_RTC_VAL_HIGH, &high2); + if (high != high2) { + high = high2; + pmu_read(PMU_REG_RTC_VAL_LOW, &low); + } + + return (high << 16) | low; +} + +void pmu_rtc_set_alarm(uint32_t seconds) { + uint16_t readval; + uint16_t high, low; + uint32_t lock; + + // Need 1 second to raise the interrupt + if (seconds > 0) { + seconds -= 1; + } + + high = seconds >> 16; + low = seconds & 0xFFFF; + + pmu_write(PMU_REG_INT_CLR, RTC_INT1_MSKED); + + pmu_write(PMU_REG_RTC_MATCH1_LOW, low); + pmu_write(PMU_REG_RTC_MATCH1_HIGH, high); + + lock = int_lock(); + pmu_read(PMU_REG_INT_EN, &readval); + readval |= RTC_INT_EN_1; + pmu_write(PMU_REG_INT_EN, readval); + int_unlock(lock); +} + +uint32_t BOOT_TEXT_SRAM_LOC pmu_rtc_get_alarm(void) { + uint16_t high, low; + + pmu_read(PMU_REG_RTC_MATCH1_LOW, &low); + pmu_read(PMU_REG_RTC_MATCH1_HIGH, &high); + + // Compensate the alarm offset + return (uint32_t)((high << 16) | low) + 1; +} + +void pmu_rtc_clear_alarm(void) { + uint16_t readval; + uint32_t lock; + + lock = int_lock(); + pmu_read(PMU_REG_INT_EN, &readval); + readval &= ~RTC_INT_EN_1; + pmu_write(PMU_REG_INT_EN, readval); + int_unlock(lock); + + pmu_write(PMU_REG_INT_CLR, RTC_INT1_MSKED); +} + +int BOOT_TEXT_SRAM_LOC pmu_rtc_alarm_status_set(void) { + uint16_t readval; + + pmu_read(PMU_REG_INT_EN, &readval); + + return !!(readval & RTC_INT_EN_1); +} + +int pmu_rtc_alarm_alerted() { + uint16_t readval; + + pmu_read(PMU_REG_INT_STATUS, &readval); + + return !!(readval & RTC_INT_1); +} + +static void pmu_rtc_irq_handler(uint16_t irq_status) { + uint32_t seconds; + + if (irq_status & RTC_INT1_MSKED) { pmu_rtc_clear_alarm(); - lock = int_lock(); - pmu_read(PMU_REG_POWER_KEY_CFG, &readval); - readval &= ~(RTC_POWER_ON_EN | PU_LPO_DR); - pmu_write(PMU_REG_POWER_KEY_CFG, readval); - int_unlock(lock); -} - -int BOOT_TEXT_SRAM_LOC pmu_rtc_enabled(void) -{ - uint16_t readval; - - pmu_read(PMU_REG_POWER_KEY_CFG, &readval); - - return !!(readval & RTC_POWER_ON_EN); -} - -void pmu_rtc_set(uint32_t seconds) -{ - uint16_t high, low; - - // Need 3 seconds to load a new value - seconds += 3; - - high = seconds >> 16; - low = seconds & 0xFFFF; - - pmu_write(PMU_REG_RTC_LOAD_LOW, low); - pmu_write(PMU_REG_RTC_LOAD_HIGH, high); -} - -uint32_t pmu_rtc_get(void) -{ - uint16_t high, low, high2; - - pmu_read(PMU_REG_RTC_VAL_HIGH, &high); - pmu_read(PMU_REG_RTC_VAL_LOW, &low); - // Handle counter wrap - pmu_read(PMU_REG_RTC_VAL_HIGH, &high2); - if (high != high2) { - high = high2; - pmu_read(PMU_REG_RTC_VAL_LOW, &low); + if (rtc_irq_handler) { + seconds = pmu_rtc_get(); + rtc_irq_handler(seconds); } - - return (high << 16) | low; + } } -void pmu_rtc_set_alarm(uint32_t seconds) -{ - uint16_t readval; - uint16_t high, low; - uint32_t lock; +void pmu_rtc_set_irq_handler(PMU_RTC_IRQ_HANDLER_T handler) { + uint16_t readval; + uint32_t lock; - // Need 1 second to raise the interrupt - if (seconds > 0) { - seconds -= 1; - } + rtc_irq_handler = handler; - high = seconds >> 16; - low = seconds & 0xFFFF; - - pmu_write(PMU_REG_INT_CLR, RTC_INT1_MSKED); - - pmu_write(PMU_REG_RTC_MATCH1_LOW, low); - pmu_write(PMU_REG_RTC_MATCH1_HIGH, high); - - lock = int_lock(); - pmu_read(PMU_REG_INT_EN, &readval); - readval |= RTC_INT_EN_1; - pmu_write(PMU_REG_INT_EN, readval); - int_unlock(lock); -} - -uint32_t BOOT_TEXT_SRAM_LOC pmu_rtc_get_alarm(void) -{ - uint16_t high, low; - - pmu_read(PMU_REG_RTC_MATCH1_LOW, &low); - pmu_read(PMU_REG_RTC_MATCH1_HIGH, &high); - - // Compensate the alarm offset - return (uint32_t)((high << 16) | low) + 1; -} - -void pmu_rtc_clear_alarm(void) -{ - uint16_t readval; - uint32_t lock; - - lock = int_lock(); - pmu_read(PMU_REG_INT_EN, &readval); - readval &= ~RTC_INT_EN_1; - pmu_write(PMU_REG_INT_EN, readval); - int_unlock(lock); - - pmu_write(PMU_REG_INT_CLR, RTC_INT1_MSKED); -} - -int BOOT_TEXT_SRAM_LOC pmu_rtc_alarm_status_set(void) -{ - uint16_t readval; - - pmu_read(PMU_REG_INT_EN, &readval); - - return !!(readval & RTC_INT_EN_1); -} - -int pmu_rtc_alarm_alerted() -{ - uint16_t readval; - - pmu_read(PMU_REG_INT_STATUS, &readval); - - return !!(readval & RTC_INT_1); -} - -static void pmu_rtc_irq_handler(uint16_t irq_status) -{ - uint32_t seconds; - - if (irq_status & RTC_INT1_MSKED) { - pmu_rtc_clear_alarm(); - - if (rtc_irq_handler) { - seconds = pmu_rtc_get(); - rtc_irq_handler(seconds); - } - } -} - -void pmu_rtc_set_irq_handler(PMU_RTC_IRQ_HANDLER_T handler) -{ - uint16_t readval; - uint32_t lock; - - rtc_irq_handler = handler; - - lock = int_lock(); - pmu_read(PMU_REG_INT_MASK, &readval); - if (handler) { - readval |= RTC_INT1_MSK; - } else { - readval &= ~RTC_INT1_MSK; - } - pmu_write(PMU_REG_INT_MASK, readval); - pmu_set_irq_unified_handler(PMU_IRQ_TYPE_RTC, handler ? pmu_rtc_irq_handler : NULL); - int_unlock(lock); + lock = int_lock(); + pmu_read(PMU_REG_INT_MASK, &readval); + if (handler) { + readval |= RTC_INT1_MSK; + } else { + readval &= ~RTC_INT1_MSK; + } + pmu_write(PMU_REG_INT_MASK, readval); + pmu_set_irq_unified_handler(PMU_IRQ_TYPE_RTC, + handler ? pmu_rtc_irq_handler : NULL); + int_unlock(lock); } #endif -int pmu_pwrkey_set_irq(enum HAL_PWRKEY_IRQ_T type) -{ - uint16_t val; - uint16_t int_en; +int pmu_pwrkey_set_irq(enum HAL_PWRKEY_IRQ_T type) { + uint16_t val; + uint16_t int_en; - if (type == HAL_PWRKEY_IRQ_NONE) { - // Clear existing IRQs - pmu_write(PMU_REG_CHARGER_STATUS, (POWER_ON_PRESS | POWER_ON_RELEASE)); - // Disable future IRQs - int_en = 0; - } else if (type == HAL_PWRKEY_IRQ_FALLING_EDGE) { - int_en = POWERON_PRESS_EN; - } else if (type == HAL_PWRKEY_IRQ_RISING_EDGE) { - int_en = POWERON_RELEASE_EN; - } else if (type == HAL_PWRKEY_IRQ_BOTH_EDGE) { - int_en = POWERON_PRESS_EN | POWERON_RELEASE_EN; - } else { - return 1; - } + if (type == HAL_PWRKEY_IRQ_NONE) { + // Clear existing IRQs + pmu_write(PMU_REG_CHARGER_STATUS, (POWER_ON_PRESS | POWER_ON_RELEASE)); + // Disable future IRQs + int_en = 0; + } else if (type == HAL_PWRKEY_IRQ_FALLING_EDGE) { + int_en = POWERON_PRESS_EN; + } else if (type == HAL_PWRKEY_IRQ_RISING_EDGE) { + int_en = POWERON_RELEASE_EN; + } else if (type == HAL_PWRKEY_IRQ_BOTH_EDGE) { + int_en = POWERON_PRESS_EN | POWERON_RELEASE_EN; + } else { + return 1; + } - pmu_read(PMU_REG_SLEEP_CFG, &val); - val = (val & ~(POWERON_PRESS_EN | POWERON_RELEASE_EN)) | int_en; - pmu_write(PMU_REG_SLEEP_CFG, val); + pmu_read(PMU_REG_SLEEP_CFG, &val); + val = (val & ~(POWERON_PRESS_EN | POWERON_RELEASE_EN)) | int_en; + pmu_write(PMU_REG_SLEEP_CFG, val); - return 0; + return 0; } -int hal_pwrkey_set_irq(enum HAL_PWRKEY_IRQ_T type) __attribute__((alias("pmu_pwrkey_set_irq"))); +int hal_pwrkey_set_irq(enum HAL_PWRKEY_IRQ_T type) + __attribute__((alias("pmu_pwrkey_set_irq"))); -bool pmu_pwrkey_pressed(void) -{ - uint16_t val; +bool pmu_pwrkey_pressed(void) { + uint16_t val; - pmu_read(PMU_REG_CHARGER_STATUS, &val); + pmu_read(PMU_REG_CHARGER_STATUS, &val); - return !!(val & POWER_ON); + return !!(val & POWER_ON); } bool hal_pwrkey_pressed(void) __attribute__((alias("pmu_pwrkey_pressed"))); -enum HAL_PWRKEY_IRQ_T pmu_pwrkey_irq_value_to_state(uint16_t irq_status) -{ - enum HAL_PWRKEY_IRQ_T state = HAL_PWRKEY_IRQ_NONE; +enum HAL_PWRKEY_IRQ_T pmu_pwrkey_irq_value_to_state(uint16_t irq_status) { + enum HAL_PWRKEY_IRQ_T state = HAL_PWRKEY_IRQ_NONE; - if (irq_status & POWER_ON_PRESS) { - state |= HAL_PWRKEY_IRQ_FALLING_EDGE; - } + if (irq_status & POWER_ON_PRESS) { + state |= HAL_PWRKEY_IRQ_FALLING_EDGE; + } - if (irq_status & POWER_ON_RELEASE) { - state |= HAL_PWRKEY_IRQ_RISING_EDGE; - } + if (irq_status & POWER_ON_RELEASE) { + state |= HAL_PWRKEY_IRQ_RISING_EDGE; + } - return state; + return state; } -static void pmu_general_irq_handler(void) -{ - uint32_t lock; - uint16_t val; - bool pwrkey, charger, gpadc, rtc; +static void pmu_general_irq_handler(void) { + uint32_t lock; + uint16_t val; + bool pwrkey, charger, gpadc, rtc; - pwrkey = false; - charger = false; - gpadc = false; - rtc = false; + pwrkey = false; + charger = false; + gpadc = false; + rtc = false; - lock = int_lock(); - pmu_read(PMU_REG_CHARGER_STATUS, &val); - if (val & (POWER_ON_PRESS | POWER_ON_RELEASE)) { - pwrkey = true; - } - if (val & (AC_ON_DET_OUT_MASKED | AC_ON_DET_IN_MASKED)) { - charger = true; - } - if (pwrkey || charger) { - pmu_write(PMU_REG_CHARGER_STATUS, val); - } - int_unlock(lock); + lock = int_lock(); + pmu_read(PMU_REG_CHARGER_STATUS, &val); + if (val & (POWER_ON_PRESS | POWER_ON_RELEASE)) { + pwrkey = true; + } + if (val & (AC_ON_DET_OUT_MASKED | AC_ON_DET_IN_MASKED)) { + charger = true; + } + if (pwrkey || charger) { + pmu_write(PMU_REG_CHARGER_STATUS, val); + } + int_unlock(lock); - if (pwrkey) { - if (pmu_irq_hdlrs[PMU_IRQ_TYPE_PWRKEY]) { - pmu_irq_hdlrs[PMU_IRQ_TYPE_PWRKEY](val); - } + if (pwrkey) { + if (pmu_irq_hdlrs[PMU_IRQ_TYPE_PWRKEY]) { + pmu_irq_hdlrs[PMU_IRQ_TYPE_PWRKEY](val); } - if (charger) { - if (pmu_irq_hdlrs[PMU_IRQ_TYPE_CHARGER]) { - pmu_irq_hdlrs[PMU_IRQ_TYPE_CHARGER](val); - } + } + if (charger) { + if (pmu_irq_hdlrs[PMU_IRQ_TYPE_CHARGER]) { + pmu_irq_hdlrs[PMU_IRQ_TYPE_CHARGER](val); } + } - lock = int_lock(); - pmu_read(PMU_REG_INT_MSKED_STATUS, &val); - if (val & (KEY_ERR1_INTR_MSKED | KEY_ERR0_INTR_MSKED | KEY_PRESS_INTR_MSKED | KEY_RELEASE_INTR_MSKED | - SAMPLE_DONE_INTR_MSKED | CHAN_DATA_INTR_MSKED_MASK)) { - gpadc = true; - } - if (val & (RTC_INT1_MSKED | RTC_INT0_MSKED)) { - rtc = true; - } - if (gpadc || rtc) { - pmu_write(PMU_REG_INT_CLR, val); - } - int_unlock(lock); + lock = int_lock(); + pmu_read(PMU_REG_INT_MSKED_STATUS, &val); + if (val & (KEY_ERR1_INTR_MSKED | KEY_ERR0_INTR_MSKED | KEY_PRESS_INTR_MSKED | + KEY_RELEASE_INTR_MSKED | SAMPLE_DONE_INTR_MSKED | + CHAN_DATA_INTR_MSKED_MASK)) { + gpadc = true; + } + if (val & (RTC_INT1_MSKED | RTC_INT0_MSKED)) { + rtc = true; + } + if (gpadc || rtc) { + pmu_write(PMU_REG_INT_CLR, val); + } + int_unlock(lock); - if (gpadc) { - if (pmu_irq_hdlrs[PMU_IRQ_TYPE_GPADC]) { - pmu_irq_hdlrs[PMU_IRQ_TYPE_GPADC](val); - } + if (gpadc) { + if (pmu_irq_hdlrs[PMU_IRQ_TYPE_GPADC]) { + pmu_irq_hdlrs[PMU_IRQ_TYPE_GPADC](val); } - if (rtc) { - if (pmu_irq_hdlrs[PMU_IRQ_TYPE_RTC]) { - pmu_irq_hdlrs[PMU_IRQ_TYPE_RTC](val); - } + } + if (rtc) { + if (pmu_irq_hdlrs[PMU_IRQ_TYPE_RTC]) { + pmu_irq_hdlrs[PMU_IRQ_TYPE_RTC](val); } + } } -int pmu_set_irq_unified_handler(enum PMU_IRQ_TYPE_T type, PMU_IRQ_UNIFIED_HANDLER_T hdlr) -{ - bool update; - uint32_t lock; - int i; +int pmu_set_irq_unified_handler(enum PMU_IRQ_TYPE_T type, + PMU_IRQ_UNIFIED_HANDLER_T hdlr) { + bool update; + uint32_t lock; + int i; - if (type >= PMU_IRQ_TYPE_QTY) { - return 1; + if (type >= PMU_IRQ_TYPE_QTY) { + return 1; + } + + update = false; + + lock = int_lock(); + + for (i = 0; i < PMU_IRQ_TYPE_QTY; i++) { + if (pmu_irq_hdlrs[i]) { + break; } + } - update = false; + pmu_irq_hdlrs[type] = hdlr; - lock = int_lock(); - - for (i = 0; i < PMU_IRQ_TYPE_QTY; i++) { + if (hdlr) { + update = (i >= PMU_IRQ_TYPE_QTY); + } else { + if (i == type) { + for (; i < PMU_IRQ_TYPE_QTY; i++) { if (pmu_irq_hdlrs[i]) { - break; + break; } + } + update = (i >= PMU_IRQ_TYPE_QTY); } + } - pmu_irq_hdlrs[type] = hdlr; - + if (update) { if (hdlr) { - update = (i >= PMU_IRQ_TYPE_QTY); + NVIC_SetVector(PMU_IRQn, (uint32_t)pmu_general_irq_handler); + NVIC_SetPriority(PMU_IRQn, IRQ_PRIORITY_NORMAL); + NVIC_ClearPendingIRQ(PMU_IRQn); + NVIC_EnableIRQ(PMU_IRQn); } else { - if (i == type) { - for (; i < PMU_IRQ_TYPE_QTY; i++) { - if (pmu_irq_hdlrs[i]) { - break; - } - } - update = (i >= PMU_IRQ_TYPE_QTY); - } + NVIC_DisableIRQ(PMU_IRQn); } + } - if (update) { - if (hdlr) { - NVIC_SetVector(PMU_IRQn, (uint32_t)pmu_general_irq_handler); - NVIC_SetPriority(PMU_IRQn, IRQ_PRIORITY_NORMAL); - NVIC_ClearPendingIRQ(PMU_IRQn); - NVIC_EnableIRQ(PMU_IRQn); - } else { - NVIC_DisableIRQ(PMU_IRQn); - } + int_unlock(lock); + + return 0; +} + +enum PMU_POWER_ON_CAUSE_T pmu_get_power_on_cause(void) { + enum PMU_POWER_ON_CAUSE_T pmu_power_on_cause = PMU_POWER_ON_CAUSE_NONE; + + pmu_power_on_cause = pmu_charger_poweron_status(); + if (pmu_power_on_cause == PMU_POWER_ON_CAUSE_NONE) { + pmu_power_on_cause = PMU_POWER_ON_CAUSE_POWER_KEY; + } + + return pmu_power_on_cause; +} + +void pmu_viorise_req(enum PMU_VIORISE_REQ_USER_T user, bool rise) { + uint32_t lock; + + lock = int_lock(); + if (rise) { + if (vio_risereq_map == 0) { + pmu_module_ramp_volt(PMU_IO, vio_lp, vio_act_rise); } + vio_risereq_map |= (1 << user); + } else { + vio_risereq_map &= ~(1 << user); + if (vio_risereq_map == 0) { + pmu_module_ramp_volt(PMU_IO, vio_lp, vio_act_normal); + } + } + int_unlock(lock); +} +int pmu_debug_config_ana(uint16_t volt) { return 0; } + +int pmu_debug_config_codec(uint16_t volt) { +#ifdef ANC_PROD_TEST + if (volt == 1600 || volt == 1700 || volt == 1800 || volt == 1900 || + volt == 1950) { + vhppa_mv = vcodec_mv = volt; + vcodec_off = true; + } else { + vcodec_off = false; + return 1; + } +#endif + return 0; +} + +int pmu_debug_config_vcrystal(bool on) { return 0; } + +int pmu_debug_config_audio_output(bool diff) { return 0; } + +void pmu_debug_reliability_test(int stage) { + uint16_t volt; + + if (stage == 0) { + volt = PMU_DCDC_ANA_1_2V; + } else { + volt = PMU_DCDC_ANA_1_3V; + } + pmu_dcdc_ana_set_volt(volt, ana_lp_dcdc); +} + +void pmu_led_set_hiz(enum HAL_GPIO_PIN_T pin) { + uint16_t val1, val2; + uint32_t lock; + + if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) { + lock = int_lock(); + pmu_read(PMU_REG_MIC_LDO_EN, &val1); + pmu_read(PMU_REG_LED_CFG, &val2); + if (pin == HAL_GPIO_PIN_LED1) { + val1 &= ~REG_LED_IO1_RX_EN; + val2 = (val2 | REG_LED_IO1_PU | REG_LED_IO1_OENB) & + ~(REG_LED_IO1_PUEN | REG_LED_IO1_PDEN); + } else { + val1 &= ~REG_LED_IO2_RX_EN; + val2 = (val2 | REG_LED_IO2_PU | REG_LED_IO2_OENB) & + ~(REG_LED_IO2_PUEN | REG_LED_IO2_PDEN); + } + pmu_write(PMU_REG_MIC_LDO_EN, val1); + pmu_write(PMU_REG_LED_CFG, val2); int_unlock(lock); - - return 0; + } } -enum PMU_POWER_ON_CAUSE_T pmu_get_power_on_cause(void) -{ - enum PMU_POWER_ON_CAUSE_T pmu_power_on_cause = PMU_POWER_ON_CAUSE_NONE; +void pmu_led_set_direction(enum HAL_GPIO_PIN_T pin, enum HAL_GPIO_DIR_T dir) { + uint16_t val; + uint16_t val_rx; + uint32_t lock; - pmu_power_on_cause = pmu_charger_poweron_status(); - if (pmu_power_on_cause == PMU_POWER_ON_CAUSE_NONE){ - pmu_power_on_cause = PMU_POWER_ON_CAUSE_POWER_KEY; + if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) { + lock = int_lock(); + pmu_read(PMU_REG_LED_CFG, &val); + pmu_read(PMU_REG_MIC_LDO_EN, &val_rx); + if (pin == HAL_GPIO_PIN_LED1) { + val |= REG_LED_IO1_PU; + if (dir == HAL_GPIO_DIR_IN) { + val |= REG_LED_IO1_OENB; + val_rx |= REG_LED_IO1_RX_EN; + } else { + val &= ~REG_LED_IO1_OENB; + val_rx &= ~REG_LED_IO1_RX_EN; + } + } else { + val |= REG_LED_IO2_PU; + if (dir == HAL_GPIO_DIR_IN) { + val |= REG_LED_IO2_OENB; + val_rx |= REG_LED_IO2_RX_EN; + } else { + val &= ~REG_LED_IO2_OENB; + val_rx &= ~REG_LED_IO2_RX_EN; + } } - - return pmu_power_on_cause; + pmu_write(PMU_REG_LED_CFG, val); + pmu_write(PMU_REG_MIC_LDO_EN, val_rx); + ; + int_unlock(lock); + } } -void pmu_viorise_req(enum PMU_VIORISE_REQ_USER_T user, bool rise) -{ - uint32_t lock; +enum HAL_GPIO_DIR_T pmu_led_get_direction(enum HAL_GPIO_PIN_T pin) { + uint16_t val; + + if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) { + pmu_read(PMU_REG_LED_CFG, &val); + if (pin == HAL_GPIO_PIN_LED1) { + return (val & REG_LED_IO1_OENB) ? HAL_GPIO_DIR_IN : HAL_GPIO_DIR_OUT; + } else { + return (val & REG_LED_IO2_OENB) ? HAL_GPIO_DIR_IN : HAL_GPIO_DIR_OUT; + } + } else { + return HAL_GPIO_DIR_IN; + } +} + +void pmu_led_set_voltage_domains(enum HAL_IOMUX_PIN_T pin, + enum HAL_IOMUX_PIN_VOLTAGE_DOMAINS_T volt) { + enum PMU_LED_VOLT_T { + PMU_LED_VOLT_VBAT, + PMU_LED_VOLT_VMEM, + PMU_LED_VOLT_VIO, + }; + enum PMU_LED_VOLT_T sel; + uint16_t val; + uint32_t lock; + + if (pin == HAL_IOMUX_PIN_LED1 || pin == HAL_IOMUX_PIN_LED2) { + if (volt == HAL_IOMUX_PIN_VOLTAGE_VIO) { + sel = PMU_LED_VOLT_VIO; + } else if (volt == HAL_IOMUX_PIN_VOLTAGE_MEM) { + sel = PMU_LED_VOLT_VMEM; + } else { + sel = PMU_LED_VOLT_VBAT; + } lock = int_lock(); - if (rise) { - if (vio_risereq_map == 0) { - pmu_module_ramp_volt(PMU_IO,vio_lp,vio_act_rise); - } - vio_risereq_map |= (1 << user); + pmu_read(PMU_REG_LED_CFG, &val); + if (pin == HAL_IOMUX_PIN_LED1) { + val = SET_BITFIELD(val, REG_LED_IO1_SEL, sel); } else { - vio_risereq_map &= ~(1 << user); - if (vio_risereq_map == 0) { - pmu_module_ramp_volt(PMU_IO,vio_lp,vio_act_normal); - } + val = SET_BITFIELD(val, REG_LED_IO2_SEL, sel); } + pmu_write(PMU_REG_LED_CFG, val); int_unlock(lock); + } } -int pmu_debug_config_ana(uint16_t volt) -{ - return 0; -} +void pmu_led_set_pull_select(enum HAL_IOMUX_PIN_T pin, + enum HAL_IOMUX_PIN_PULL_SELECT_T pull_sel) { + uint16_t val; + uint32_t lock; -int pmu_debug_config_codec(uint16_t volt) -{ -#ifdef ANC_PROD_TEST - if (volt == 1600 || volt == 1700 || volt == 1800 || volt == 1900 || volt == 1950) { - vhppa_mv = vcodec_mv = volt; - vcodec_off = true; + if (pin == HAL_IOMUX_PIN_LED1 || pin == HAL_IOMUX_PIN_LED2) { + lock = int_lock(); + pmu_read(PMU_REG_LED_CFG, &val); + if (pin == HAL_IOMUX_PIN_LED1) { + val &= ~(REG_LED_IO1_PDEN | REG_LED_IO1_PUEN); + if (pull_sel == HAL_IOMUX_PIN_PULLUP_ENABLE) { + val |= REG_LED_IO1_PUEN; + } else if (pull_sel == HAL_IOMUX_PIN_PULLDOWN_ENABLE) { + val |= REG_LED_IO1_PDEN; + } } else { - vcodec_off = false; - return 1; + val &= ~(REG_LED_IO2_PDEN | REG_LED_IO2_PUEN); + if (pull_sel == HAL_IOMUX_PIN_PULLUP_ENABLE) { + val |= REG_LED_IO2_PUEN; + } else if (pull_sel == HAL_IOMUX_PIN_PULLDOWN_ENABLE) { + val |= REG_LED_IO2_PDEN; + } } -#endif - return 0; + pmu_write(PMU_REG_LED_CFG, val); + int_unlock(lock); + } } -int pmu_debug_config_vcrystal(bool on) -{ - return 0; -} - -int pmu_debug_config_audio_output(bool diff) -{ - return 0; -} - -void pmu_debug_reliability_test(int stage) -{ - uint16_t volt; - - if (stage == 0) { - volt = PMU_DCDC_ANA_1_2V; - } else { - volt = PMU_DCDC_ANA_1_3V; - } - pmu_dcdc_ana_set_volt(volt, ana_lp_dcdc); -} - -void pmu_led_set_hiz(enum HAL_GPIO_PIN_T pin) -{ - uint16_t val1, val2; - uint32_t lock; - - if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) { - lock = int_lock(); - pmu_read(PMU_REG_MIC_LDO_EN, &val1); - pmu_read(PMU_REG_LED_CFG, &val2); - if (pin == HAL_GPIO_PIN_LED1) { - val1 &= ~REG_LED_IO1_RX_EN; - val2 = (val2 | REG_LED_IO1_PU | REG_LED_IO1_OENB) & ~(REG_LED_IO1_PUEN | REG_LED_IO1_PDEN); - } else { - val1 &= ~REG_LED_IO2_RX_EN; - val2 = (val2 | REG_LED_IO2_PU | REG_LED_IO2_OENB) & ~(REG_LED_IO2_PUEN | REG_LED_IO2_PDEN); - } - pmu_write(PMU_REG_MIC_LDO_EN, val1); - pmu_write(PMU_REG_LED_CFG, val2); - int_unlock(lock); - } -} - -void pmu_led_set_direction(enum HAL_GPIO_PIN_T pin, enum HAL_GPIO_DIR_T dir) -{ - uint16_t val; - uint16_t val_rx; - uint32_t lock; - - if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) { - lock = int_lock(); - pmu_read(PMU_REG_LED_CFG, &val); - pmu_read(PMU_REG_MIC_LDO_EN, &val_rx); - if (pin == HAL_GPIO_PIN_LED1) { - val |= REG_LED_IO1_PU; - if (dir == HAL_GPIO_DIR_IN) { - val |= REG_LED_IO1_OENB; - val_rx |= REG_LED_IO1_RX_EN; - } else { - val &= ~REG_LED_IO1_OENB; - val_rx &= ~REG_LED_IO1_RX_EN; - } - } else { - val |= REG_LED_IO2_PU; - if (dir == HAL_GPIO_DIR_IN) { - val |= REG_LED_IO2_OENB; - val_rx |= REG_LED_IO2_RX_EN; - } else { - val &= ~REG_LED_IO2_OENB; - val_rx &= ~REG_LED_IO2_RX_EN; - } - } - pmu_write(PMU_REG_LED_CFG, val); - pmu_write(PMU_REG_MIC_LDO_EN, val_rx);; - int_unlock(lock); - } -} - -enum HAL_GPIO_DIR_T pmu_led_get_direction(enum HAL_GPIO_PIN_T pin) -{ - uint16_t val; - - if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) { - pmu_read(PMU_REG_LED_CFG, &val); - if (pin == HAL_GPIO_PIN_LED1) { - return (val & REG_LED_IO1_OENB) ? HAL_GPIO_DIR_IN : HAL_GPIO_DIR_OUT; - } else { - return (val & REG_LED_IO2_OENB) ? HAL_GPIO_DIR_IN : HAL_GPIO_DIR_OUT; - } - } else { - return HAL_GPIO_DIR_IN; - } -} - -void pmu_led_set_voltage_domains(enum HAL_IOMUX_PIN_T pin, enum HAL_IOMUX_PIN_VOLTAGE_DOMAINS_T volt) -{ - enum PMU_LED_VOLT_T { - PMU_LED_VOLT_VBAT, - PMU_LED_VOLT_VMEM, - PMU_LED_VOLT_VIO, - }; - enum PMU_LED_VOLT_T sel; - uint16_t val; - uint32_t lock; - - if (pin == HAL_IOMUX_PIN_LED1 || pin == HAL_IOMUX_PIN_LED2) { - if (volt == HAL_IOMUX_PIN_VOLTAGE_VIO) { - sel = PMU_LED_VOLT_VIO; - } else if (volt == HAL_IOMUX_PIN_VOLTAGE_MEM) { - sel = PMU_LED_VOLT_VMEM; - } else { - sel = PMU_LED_VOLT_VBAT; - } - - lock = int_lock(); - pmu_read(PMU_REG_LED_CFG, &val); - if (pin == HAL_IOMUX_PIN_LED1) { - val = SET_BITFIELD(val, REG_LED_IO1_SEL, sel); - } else { - val = SET_BITFIELD(val, REG_LED_IO2_SEL, sel); - } - pmu_write(PMU_REG_LED_CFG, val); - int_unlock(lock); - } -} - -void pmu_led_set_pull_select(enum HAL_IOMUX_PIN_T pin, enum HAL_IOMUX_PIN_PULL_SELECT_T pull_sel) -{ - uint16_t val; - uint32_t lock; - - if (pin == HAL_IOMUX_PIN_LED1 || pin == HAL_IOMUX_PIN_LED2) { - lock = int_lock(); - pmu_read(PMU_REG_LED_CFG, &val); - if (pin == HAL_IOMUX_PIN_LED1) { - val &= ~(REG_LED_IO1_PDEN | REG_LED_IO1_PUEN); - if (pull_sel == HAL_IOMUX_PIN_PULLUP_ENABLE) { - val |= REG_LED_IO1_PUEN; - } else if (pull_sel == HAL_IOMUX_PIN_PULLDOWN_ENABLE) { - val |= REG_LED_IO1_PDEN; - } - } else { - val &= ~(REG_LED_IO2_PDEN | REG_LED_IO2_PUEN); - if (pull_sel == HAL_IOMUX_PIN_PULLUP_ENABLE) { - val |= REG_LED_IO2_PUEN; - } else if (pull_sel == HAL_IOMUX_PIN_PULLDOWN_ENABLE) { - val |= REG_LED_IO2_PDEN; - } - } - pmu_write(PMU_REG_LED_CFG, val); - int_unlock(lock); - } -} - -void pmu_led_set_value(enum HAL_GPIO_PIN_T pin, int data) -{ - uint16_t val; - uint32_t lock; +void pmu_led_set_value(enum HAL_GPIO_PIN_T pin, int data) { + uint16_t val; + uint32_t lock; #ifdef PMU_LED_VIA_PWM - uint16_t br_val; + uint16_t br_val; #endif - if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) { - lock = int_lock(); + if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) { + lock = int_lock(); #ifdef PMU_LED_VIA_PWM - pmu_read(PMU_REG_PWM_BR_EN, &br_val); + pmu_read(PMU_REG_PWM_BR_EN, &br_val); #endif - pmu_read(PMU_REG_PWM_EN, &val); - if (pin == HAL_GPIO_PIN_LED1) { + pmu_read(PMU_REG_PWM_EN, &val); + if (pin == HAL_GPIO_PIN_LED1) { #ifdef PMU_LED_VIA_PWM - pmu_write(PMU_REG_PWM2_TOGGLE, 0xFFFF); - br_val &= ~REG_PWM2_BR_EN; - val |= PWM_SELECT_EN(1 << 0); - if (data) { - val &= ~PWM_SELECT_INV(1 << 0); - } else { - val |= PWM_SELECT_INV(1 << 0); - } + pmu_write(PMU_REG_PWM2_TOGGLE, 0xFFFF); + br_val &= ~REG_PWM2_BR_EN; + val |= PWM_SELECT_EN(1 << 0); + if (data) { + val &= ~PWM_SELECT_INV(1 << 0); + } else { + val |= PWM_SELECT_INV(1 << 0); + } #else - if (data) { - val |= REG_LED0_OUT; - } else { - val &= ~REG_LED0_OUT; - } + if (data) { + val |= REG_LED0_OUT; + } else { + val &= ~REG_LED0_OUT; + } #endif - } else { + } else { #ifdef PMU_LED_VIA_PWM - pmu_write(PMU_REG_PWM3_TOGGLE, 0xFFFF); - br_val &= ~REG_PWM3_BR_EN; - val |= PWM_SELECT_EN(1 << 1); - if (data) { - val &= ~PWM_SELECT_INV(1 << 1); - } else { - val |= PWM_SELECT_INV(1 << 1); - } + pmu_write(PMU_REG_PWM3_TOGGLE, 0xFFFF); + br_val &= ~REG_PWM3_BR_EN; + val |= PWM_SELECT_EN(1 << 1); + if (data) { + val &= ~PWM_SELECT_INV(1 << 1); + } else { + val |= PWM_SELECT_INV(1 << 1); + } #else - if (data) { - val |= REG_LED1_OUT; - } else { - val &= ~REG_LED1_OUT; - } + if (data) { + val |= REG_LED1_OUT; + } else { + val &= ~REG_LED1_OUT; + } #endif - } -#ifdef PMU_LED_VIA_PWM - pmu_write(PMU_REG_PWM_BR_EN, br_val); -#endif - pmu_write(PMU_REG_PWM_EN, val); - int_unlock(lock); } +#ifdef PMU_LED_VIA_PWM + pmu_write(PMU_REG_PWM_BR_EN, br_val); +#endif + pmu_write(PMU_REG_PWM_EN, val); + int_unlock(lock); + } } -int pmu_led_get_value(enum HAL_GPIO_PIN_T pin) -{ - uint16_t val; - int data = 0; +int pmu_led_get_value(enum HAL_GPIO_PIN_T pin) { + uint16_t val; + int data = 0; - if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) { - pmu_read(PMU_REG_POWER_OFF, &val); - if (pin == HAL_GPIO_PIN_LED1) { - data = REG_LED_IO1_DATA_IN; - } else { - data = REG_LED_IO2_DATA_IN; - } - data &= val; + if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) { + pmu_read(PMU_REG_POWER_OFF, &val); + if (pin == HAL_GPIO_PIN_LED1) { + data = REG_LED_IO1_DATA_IN; + } else { + data = REG_LED_IO2_DATA_IN; } + data &= val; + } - return !!data; + return !!data; } struct PMU_WDT_CTX_T { - bool enabled; - uint16_t wdt_timer; - uint16_t wdt_cfg; + bool enabled; + uint16_t wdt_timer; + uint16_t wdt_cfg; }; static struct PMU_WDT_CTX_T BOOT_BSS_LOC wdt_ctx; -void BOOT_TEXT_SRAM_LOC pmu_wdt_save_context(void) -{ - uint16_t wdt_cfg = 0, wdt_timer = 0; - pmu_read(PMU_REG_WDT_CFG, &wdt_cfg); - if (wdt_cfg & (REG_WDT_RESET_EN | REG_WDT_EN)){ - wdt_ctx.enabled = true; - wdt_ctx.wdt_cfg = wdt_cfg; - pmu_read(PMU_REG_WDT_TIMER, &wdt_timer); - wdt_ctx.wdt_timer = wdt_timer; - } +void BOOT_TEXT_SRAM_LOC pmu_wdt_save_context(void) { + uint16_t wdt_cfg = 0, wdt_timer = 0; + pmu_read(PMU_REG_WDT_CFG, &wdt_cfg); + if (wdt_cfg & (REG_WDT_RESET_EN | REG_WDT_EN)) { + wdt_ctx.enabled = true; + wdt_ctx.wdt_cfg = wdt_cfg; + pmu_read(PMU_REG_WDT_TIMER, &wdt_timer); + wdt_ctx.wdt_timer = wdt_timer; + } } -void BOOT_TEXT_SRAM_LOC pmu_wdt_restore_context(void) -{ - if (wdt_ctx.enabled) { - pmu_write(PMU_REG_WDT_TIMER, wdt_ctx.wdt_timer); - pmu_write(PMU_REG_WDT_CFG, wdt_ctx.wdt_cfg); - } +void BOOT_TEXT_SRAM_LOC pmu_wdt_restore_context(void) { + if (wdt_ctx.enabled) { + pmu_write(PMU_REG_WDT_TIMER, wdt_ctx.wdt_timer); + pmu_write(PMU_REG_WDT_CFG, wdt_ctx.wdt_cfg); + } } -void pmu_wdt_set_irq_handler(PMU_WDT_IRQ_HANDLER_T handler) -{ +void pmu_wdt_set_irq_handler(PMU_WDT_IRQ_HANDLER_T handler) {} + +int pmu_wdt_config(uint32_t irq_ms, uint32_t reset_ms) { + // No wdt irq on best2300 + if (irq_ms + reset_ms > 0xFFFF) { + return 1; + } + wdt_timer = irq_ms + reset_ms; + + pmu_write(PMU_REG_WDT_TIMER, wdt_timer); + + return 0; } -int pmu_wdt_config(uint32_t irq_ms, uint32_t reset_ms) -{ - // No wdt irq on best2300 - if (irq_ms + reset_ms > 0xFFFF) { - return 1; - } - wdt_timer = irq_ms + reset_ms; +void pmu_wdt_start(void) { + uint16_t val; - pmu_write(PMU_REG_WDT_TIMER, wdt_timer); + if (wdt_timer == 0) { + return; + } - return 0; + pmu_read(PMU_REG_WDT_CFG, &val); + val |= (REG_WDT_RESET_EN | REG_WDT_EN); + pmu_write(PMU_REG_WDT_CFG, val); } -void pmu_wdt_start(void) -{ - uint16_t val; +void pmu_wdt_stop(void) { + uint16_t val; - if (wdt_timer == 0) { - return; - } + if (wdt_timer == 0) { + return; + } - pmu_read(PMU_REG_WDT_CFG, &val); - val |= (REG_WDT_RESET_EN | REG_WDT_EN); - pmu_write(PMU_REG_WDT_CFG, val); + pmu_read(PMU_REG_WDT_CFG, &val); + val &= ~(REG_WDT_RESET_EN | REG_WDT_EN); + pmu_write(PMU_REG_WDT_CFG, val); } -void pmu_wdt_stop(void) -{ - uint16_t val; +void pmu_wdt_feed(void) { + if (wdt_timer == 0) { + return; + } - if (wdt_timer == 0) { - return; - } - - pmu_read(PMU_REG_WDT_CFG, &val); - val &= ~(REG_WDT_RESET_EN | REG_WDT_EN); - pmu_write(PMU_REG_WDT_CFG, val); + pmu_write(PMU_REG_WDT_TIMER, wdt_timer); } -void pmu_wdt_feed(void) -{ - if (wdt_timer == 0) { - return; - } - - pmu_write(PMU_REG_WDT_TIMER, wdt_timer); -} - -void pmu_ntc_capture_enable(void) -{ -} - -void pmu_ntc_capture_disable(void) -{ -} +void pmu_ntc_capture_enable(void) {} +void pmu_ntc_capture_disable(void) {} diff --git a/platform/drivers/ana/best2300p/usbphy_best2300p.c b/platform/drivers/ana/best2300p/usbphy_best2300p.c index 1975859..6744157 100644 --- a/platform/drivers/ana/best2300p/usbphy_best2300p.c +++ b/platform/drivers/ana/best2300p/usbphy_best2300p.c @@ -13,243 +13,236 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "usbphy.h" #include "cmsis_nvic.h" #include "hal_cmu.h" #include "hal_phyif.h" #include "hal_timer.h" #include "hal_trace.h" #include "pmu.h" +#include "usbphy.h" #include CHIP_SPECIFIC_HDR(reg_usbphy) #ifdef CHIP_HAS_SPIPHY //#define USBPHY_SERIAL_ITF -void usbphy_ldo_config(int enable) -{ - int ret; - uint16_t val; +void usbphy_ldo_config(int enable) { + int ret; + uint16_t val; - ret = hal_phyif_open(SPIPHY_USB_CS); - if (ret) { - hal_phyif_close(SPIPHY_USB_CS); - return; - } + ret = hal_phyif_open(SPIPHY_USB_CS); + if (ret) { + hal_phyif_close(SPIPHY_USB_CS); + return; + } - if (enable) { + if (enable) { #ifdef USB_HIGH_SPEED - // USB ldo voltage should match with vcore (now 0.9V) - usbphy_write(0x61, 0x1118); + // USB ldo voltage should match with vcore (now 0.9V) + usbphy_write(0x61, 0x1118); #else - usbphy_write(0x61, 0x1116); + usbphy_write(0x61, 0x1116); #endif - usbphy_write(0x62, 0x2229); - usbphy_write(0x63, 0x0D82); + usbphy_write(0x62, 0x2229); + usbphy_write(0x63, 0x0D82); - hal_sys_timer_delay(MS_TO_TICKS(1)); - } else { - usbphy_write(0x63, 0x0000); - usbphy_write(0x62, 0x0000); + hal_sys_timer_delay(MS_TO_TICKS(1)); + } else { + usbphy_write(0x63, 0x0000); + usbphy_write(0x62, 0x0000); - usbphy_read(0x61, &val); - val &= (0x1 << 8); - usbphy_write(0x61, val); + usbphy_read(0x61, &val); + val &= (0x1 << 8); + usbphy_write(0x61, val); - hal_sys_timer_delay(2); - hal_phyif_close(SPIPHY_USB_CS); - } + hal_sys_timer_delay(2); + hal_phyif_close(SPIPHY_USB_CS); + } } -void usbphy_open(void) -{ - unsigned short val_01, val; +void usbphy_open(void) { + unsigned short val_01, val; #ifdef USB_HIGH_SPEED - usbphy_read(0x01, &val_01); - val_01 &= ~((1 << 0) | (1 << 11)); - usbphy_write(0x01, val_01); - val_01 |= (1 << 1) | (1 << 2) | (1 << 3) | (1 << 13); + usbphy_read(0x01, &val_01); + val_01 &= ~((1 << 0) | (1 << 11)); + usbphy_write(0x01, val_01); + val_01 |= (1 << 1) | (1 << 2) | (1 << 3) | (1 << 13); #ifdef USBPHY_SERIAL_ITF - // cdr_clk polariy=1 - val_01 |= (1 << 4); + // cdr_clk polariy=1 + val_01 |= (1 << 4); #else - // cdr_clk polariy=0 - val_01 &= ~(1 << 4); + // cdr_clk polariy=0 + val_01 &= ~(1 << 4); #endif - usbphy_write(0x01, val_01); + usbphy_write(0x01, val_01); - usbphy_read(0x02, &val); - val = (val & ~(0x1F << 10)) | (0xC << 10); - usbphy_write(0x02, val); + usbphy_read(0x02, &val); + val = (val & ~(0x1F << 10)) | (0xC << 10); + usbphy_write(0x02, val); - usbphy_read(0x05, &val); - val |= (1 << 8); - usbphy_write(0x05, val); + usbphy_read(0x05, &val); + val |= (1 << 8); + usbphy_write(0x05, val); #ifdef USBPHY_SERIAL_ITF - usbphy_write(0x06, 0x4EE9); + usbphy_write(0x06, 0x4EE9); #else - usbphy_write(0x06, 0xCEE8); + usbphy_write(0x06, 0xCEE8); #endif - usbphy_write(0x07, 0x9813); + usbphy_write(0x07, 0x9813); - usbphy_read(0x08, &val); - usbphy_write(0x08, val); + usbphy_read(0x08, &val); + usbphy_write(0x08, val); - usbphy_read(0x09, &val); - usbphy_write(0x09, val); + usbphy_read(0x09, &val); + usbphy_write(0x09, val); #ifdef USBPHY_SERIAL_ITF - usbphy_write(0x0D, 0x2B1E); + usbphy_write(0x0D, 0x2B1E); #else - usbphy_write(0x0D, 0x2A1E); + usbphy_write(0x0D, 0x2A1E); #endif - // Disable force clocks, and disable hs son signal - usbphy_write(0x22, 0x030F); + // Disable force clocks, and disable hs son signal + usbphy_write(0x22, 0x030F); - // Ignore all UTMI errors - usbphy_write(0x12, 0x0003); + // Ignore all UTMI errors + usbphy_write(0x12, 0x0003); - hal_sys_timer_delay(MS_TO_TICKS(1)); + hal_sys_timer_delay(MS_TO_TICKS(1)); - val_01 |= (1 << 0); - usbphy_write(0x01, val_01); + val_01 |= (1 << 0); + usbphy_write(0x01, val_01); #ifdef USB_HS_LOOPBACK_TEST - usbphy_read(0x0A, &val); - val |= (1 << 3) | (1 << 4) | (1 << 6); - usbphy_write(0x0A, val); - usbphy_read(0x0B, &val); - val &= ~((1 << 3) | (1 << 4) | (3 << 6)); - usbphy_write(0x0B, val); - usbphy_read(0x09, &val); - usbphy_write(0x09, val); - usbphy_read(0x06, &val); - usbphy_write(0x06, val); + usbphy_read(0x0A, &val); + val |= (1 << 3) | (1 << 4) | (1 << 6); + usbphy_write(0x0A, val); + usbphy_read(0x0B, &val); + val &= ~((1 << 3) | (1 << 4) | (3 << 6)); + usbphy_write(0x0B, val); + usbphy_read(0x09, &val); + usbphy_write(0x09, val); + usbphy_read(0x06, &val); + usbphy_write(0x06, val); - hal_sys_timer_delay(MS_TO_TICKS(1)); + hal_sys_timer_delay(MS_TO_TICKS(1)); -#define LOOPBACK_PATTERN (*(volatile uint8_t *)0x20000004) +#define LOOPBACK_PATTERN (*(volatile uint8_t *)0x20000004) - LOOPBACK_PATTERN = 0; - uint8_t pattern = LOOPBACK_PATTERN; + LOOPBACK_PATTERN = 0; + uint8_t pattern = LOOPBACK_PATTERN; - // Set tx pattern - usbphy_read(0x03, &val); - val = (val & ~(0xFF << 8)) | (pattern << 8); - usbphy_write(0x03, val); + // Set tx pattern + usbphy_read(0x03, &val); + val = (val & ~(0xFF << 8)) | (pattern << 8); + usbphy_write(0x03, val); - // Enable force clocks - usbphy_read(0x22, &val); - val |= (1 << 4) | (1 << 5) | (1 << 6); - usbphy_write(0x22, val); + // Enable force clocks + usbphy_read(0x22, &val); + val |= (1 << 4) | (1 << 5) | (1 << 6); + usbphy_write(0x22, val); - // Enable tx - usbphy_read(0x04, &val); - val |= (1 << 1); - usbphy_write(0x04, val); + // Enable tx + usbphy_read(0x04, &val); + val |= (1 << 1); + usbphy_write(0x04, val); - // Update tx pattern - while (1) { - if (pattern != LOOPBACK_PATTERN) { - pattern = LOOPBACK_PATTERN; - usbphy_read(0x03, &val); - val = (val & ~(0xFF << 8)) | (pattern << 8); - usbphy_write(0x03, val); - } + // Update tx pattern + while (1) { + if (pattern != LOOPBACK_PATTERN) { + pattern = LOOPBACK_PATTERN; + usbphy_read(0x03, &val); + val = (val & ~(0xFF << 8)) | (pattern << 8); + usbphy_write(0x03, val); } + } #endif #else // !USB_HIGH_SPEED - usbphy_read(0x01, &val_01); - val_01 &= ~(1 << 0); - usbphy_write(0x01, val_01); - val_01 |= (1 << 3); - usbphy_write(0x01, val_01); + usbphy_read(0x01, &val_01); + val_01 &= ~(1 << 0); + usbphy_write(0x01, val_01); + val_01 |= (1 << 3); + usbphy_write(0x01, val_01); #ifdef USB_USE_USBPLL - val_01 |= (1 << 2) | (1 << 12); - usbphy_write(0x01, val_01); + val_01 |= (1 << 2) | (1 << 12); + usbphy_write(0x01, val_01); - usbphy_read(0x33, &val); - val |= (1 << 0); - usbphy_write(0x33, val); + usbphy_read(0x33, &val); + val |= (1 << 0); + usbphy_write(0x33, val); #endif - val = 0; - usbphy_write(0x06, val); + val = 0; + usbphy_write(0x06, val); - usbphy_read(0x07, &val); - usbphy_write(0x07, val); + usbphy_read(0x07, &val); + usbphy_write(0x07, val); - val = 0; - usbphy_write(0x08, val); + val = 0; + usbphy_write(0x08, val); - val = 0; - usbphy_write(0x09, val); + val = 0; + usbphy_write(0x09, val); - val_01 |= (1 << 0); - usbphy_write(0x01, val_01); + val_01 |= (1 << 0); + usbphy_write(0x01, val_01); #endif // USB_HIGH_SPEED - } -void usbphy_close(void) -{ -} +void usbphy_close(void) {} -void usbphy_sleep(void) -{ - uint16_t val; +void usbphy_sleep(void) { + uint16_t val; - usbphy_read(0x01, &val); + usbphy_read(0x01, &val); #ifdef USB_HIGH_SPEED - val &= ~((1 << 1) | (1 << 2) | (1 << 3)); + val &= ~((1 << 1) | (1 << 2) | (1 << 3)); #elif defined(USB_USE_USBPLL) - val &= ~((1 << 2) | (1 << 3)); + val &= ~((1 << 2) | (1 << 3)); #else - val &= ~(1 << 3); + val &= ~(1 << 3); #endif - usbphy_write(0x01, val); + usbphy_write(0x01, val); #if !defined(USB_HIGH_SPEED) && defined(USB_USE_USBPLL) - usbphy_read(0x33, &val); - val &= ~(1 << 0); - usbphy_write(0x33, val); + usbphy_read(0x33, &val); + val &= ~(1 << 0); + usbphy_write(0x33, val); #endif - usbphy_write(0x62, 0x0000); - usbphy_write(0x63, 0x0000); + usbphy_write(0x62, 0x0000); + usbphy_write(0x63, 0x0000); } -void usbphy_wakeup(void) -{ - uint16_t val; +void usbphy_wakeup(void) { + uint16_t val; - usbphy_write(0x62, 0x2229); - usbphy_write(0x63, 0x0D82); + usbphy_write(0x62, 0x2229); + usbphy_write(0x63, 0x0D82); #if !defined(USB_HIGH_SPEED) && defined(USB_USE_USBPLL) - usbphy_read(0x33, &val); - val |= (1 << 0); - usbphy_write(0x33, val); + usbphy_read(0x33, &val); + val |= (1 << 0); + usbphy_write(0x33, val); #endif - usbphy_read(0x01, &val); + usbphy_read(0x01, &val); #ifdef USB_HIGH_SPEED - val |= (1 << 1) | (1 << 2) | (1 << 3); + val |= (1 << 1) | (1 << 2) | (1 << 3); #elif defined(USB_USE_USBPLL) - val |= (1 << 2) | (1 << 3); + val |= (1 << 2) | (1 << 3); #else - val |= (1 << 3); + val |= (1 << 3); #endif - usbphy_write(0x01, val); + usbphy_write(0x01, val); } //============================================================================================ @@ -260,151 +253,149 @@ static enum PMU_USB_PIN_CHK_STATUS_T usb_pin_status; static PMU_USB_PIN_CHK_CALLBACK usb_pin_callback; -static int pmu_usb_check_pin_status(enum PMU_USB_PIN_CHK_STATUS_T status) -{ - int dp, dm; +static int pmu_usb_check_pin_status(enum PMU_USB_PIN_CHK_STATUS_T status) { + int dp, dm; - pmu_usb_get_pin_status(&dp, &dm); + pmu_usb_get_pin_status(&dp, &dm); - //TRACE(5,"[%X] %s: status=%d dp=%d dm=%d", hal_sys_timer_get(), __FUNCTION__, status, dp, dm); + // TRACE(5,"[%X] %s: status=%d dp=%d dm=%d", hal_sys_timer_get(), + // __FUNCTION__, status, dp, dm); - // HOST_RESUME: (resume) dp == 0 && dm == 1, (reset) dp == 0 && dm == 0 + // HOST_RESUME: (resume) dp == 0 && dm == 1, (reset) dp == 0 && dm == 0 - if ( (status == PMU_USB_PIN_CHK_DEV_CONN && (dp == 1 && dm == 0)) || - (status == PMU_USB_PIN_CHK_DEV_DISCONN && (dp == 0 && dm == 0)) || - (status == PMU_USB_PIN_CHK_HOST_RESUME && dp == 0) ) { - return 1; - } + if ((status == PMU_USB_PIN_CHK_DEV_CONN && (dp == 1 && dm == 0)) || + (status == PMU_USB_PIN_CHK_DEV_DISCONN && (dp == 0 && dm == 0)) || + (status == PMU_USB_PIN_CHK_HOST_RESUME && dp == 0)) { + return 1; + } - return 0; + return 0; } -static void pmu_usb_pin_irq_handler(void) -{ - uint16_t val; - uint32_t lock; +static void pmu_usb_pin_irq_handler(void) { + uint16_t val; + uint32_t lock; - //TRACE(2,"[%X] %s", hal_sys_timer_get(), __FUNCTION__); + // TRACE(2,"[%X] %s", hal_sys_timer_get(), __FUNCTION__); + lock = int_lock(); + usbphy_read(USBPHY_REG_1A, &val); + val |= REG_1A_INTR_CLR; + usbphy_write(USBPHY_REG_1A, val); + int_unlock(lock); + + if (usb_pin_callback) { + if (pmu_usb_check_pin_status(usb_pin_status)) { + pmu_usb_disable_pin_status_check(); + usb_pin_callback(usb_pin_status); + } + } +} + +int pmu_usb_config_pin_status_check(enum PMU_USB_PIN_CHK_STATUS_T status, + PMU_USB_PIN_CHK_CALLBACK callback, + int enable) { + uint16_t val; + uint32_t lock; + + // TRACE(3,"[%X] %s: status=%d", hal_sys_timer_get(), __FUNCTION__, status); + + if (status >= PMU_USB_PIN_CHK_STATUS_QTY) { + return 1; + } + + NVIC_DisableIRQ(USB_PIN_IRQn); + + lock = int_lock(); + + usb_pin_status = status; + usb_pin_callback = callback; + + usbphy_read(USBPHY_REG_1A, &val); + + // Mask the irq + val &= ~REG_1A_USB_INSERT_INTR_MSK; + + // Config pin check + val |= REG_1A_DEBOUNCE_EN | REG_1A_NOLS_MODE | REG_1A_USBINSERT_DET_EN; + + val &= ~(REG_1A_POL_USB_RX_DP | REG_1A_POL_USB_RX_DM); + if (status == PMU_USB_PIN_CHK_DEV_CONN) { + // Check dp 0->1, dm x->0 + } else if (status == PMU_USB_PIN_CHK_DEV_DISCONN) { + // Check dp 1->0, dm x->0 + val |= REG_1A_POL_USB_RX_DP; + } else if (status == PMU_USB_PIN_CHK_HOST_RESUME) { + // Check dp 1->0, dm 0->1 (resume) or dm 0->0 (reset) + val |= REG_1A_POL_USB_RX_DP; + } + + if (status != PMU_USB_PIN_CHK_NONE && callback) { + val |= + REG_1A_USBINSERT_INTR_EN | REG_1A_USB_INSERT_INTR_MSK | REG_1A_INTR_CLR; + } + + usbphy_write(USBPHY_REG_1A, val); + + int_unlock(lock); + + if (enable) { + // Wait at least 10 cycles of 32K clock for the new status when signal + // checking polarity is changed + hal_sys_timer_delay(5); + pmu_usb_enable_pin_status_check(); + } + + return 0; +} + +void pmu_usb_enable_pin_status_check(void) { + uint16_t val; + uint32_t lock; + + if (usb_pin_status != PMU_USB_PIN_CHK_NONE && usb_pin_callback) { lock = int_lock(); usbphy_read(USBPHY_REG_1A, &val); val |= REG_1A_INTR_CLR; usbphy_write(USBPHY_REG_1A, val); int_unlock(lock); + NVIC_ClearPendingIRQ(USB_PIN_IRQn); - if (usb_pin_callback) { - if (pmu_usb_check_pin_status(usb_pin_status)) { - pmu_usb_disable_pin_status_check(); - usb_pin_callback(usb_pin_status); - } + if (pmu_usb_check_pin_status(usb_pin_status)) { + pmu_usb_disable_pin_status_check(); + usb_pin_callback(usb_pin_status); + return; } + + NVIC_SetVector(USB_PIN_IRQn, (uint32_t)pmu_usb_pin_irq_handler); + NVIC_SetPriority(USB_PIN_IRQn, IRQ_PRIORITY_NORMAL); + NVIC_EnableIRQ(USB_PIN_IRQn); + } } -int pmu_usb_config_pin_status_check(enum PMU_USB_PIN_CHK_STATUS_T status, PMU_USB_PIN_CHK_CALLBACK callback, int enable) -{ - uint16_t val; - uint32_t lock; +void pmu_usb_disable_pin_status_check(void) { + uint16_t val; + uint32_t lock; - //TRACE(3,"[%X] %s: status=%d", hal_sys_timer_get(), __FUNCTION__, status); + NVIC_DisableIRQ(USB_PIN_IRQn); - if (status >= PMU_USB_PIN_CHK_STATUS_QTY) { - return 1; - } + lock = int_lock(); - NVIC_DisableIRQ(USB_PIN_IRQn); + usbphy_read(USBPHY_REG_1A, &val); + val &= ~(REG_1A_USBINSERT_INTR_EN | REG_1A_USBINSERT_DET_EN); + usbphy_write(USBPHY_REG_1A, val); - lock = int_lock(); - - usb_pin_status = status; - usb_pin_callback = callback; - - usbphy_read(USBPHY_REG_1A, &val); - - // Mask the irq - val &= ~REG_1A_USB_INSERT_INTR_MSK; - - // Config pin check - val |= REG_1A_DEBOUNCE_EN | REG_1A_NOLS_MODE | REG_1A_USBINSERT_DET_EN; - - val &= ~(REG_1A_POL_USB_RX_DP | REG_1A_POL_USB_RX_DM); - if (status == PMU_USB_PIN_CHK_DEV_CONN) { - // Check dp 0->1, dm x->0 - } else if (status == PMU_USB_PIN_CHK_DEV_DISCONN) { - // Check dp 1->0, dm x->0 - val |= REG_1A_POL_USB_RX_DP; - } else if (status == PMU_USB_PIN_CHK_HOST_RESUME) { - // Check dp 1->0, dm 0->1 (resume) or dm 0->0 (reset) - val |= REG_1A_POL_USB_RX_DP; - } - - if (status != PMU_USB_PIN_CHK_NONE && callback) { - val |= REG_1A_USBINSERT_INTR_EN | REG_1A_USB_INSERT_INTR_MSK | REG_1A_INTR_CLR; - } - - usbphy_write(USBPHY_REG_1A, val); - - int_unlock(lock); - - if (enable) { - // Wait at least 10 cycles of 32K clock for the new status when signal checking polarity is changed - hal_sys_timer_delay(5); - pmu_usb_enable_pin_status_check(); - } - - return 0; + int_unlock(lock); } -void pmu_usb_enable_pin_status_check(void) -{ - uint16_t val; - uint32_t lock; +void pmu_usb_get_pin_status(int *dp, int *dm) { + uint16_t pol, val; - if (usb_pin_status != PMU_USB_PIN_CHK_NONE && usb_pin_callback) { - lock = int_lock(); - usbphy_read(USBPHY_REG_1A, &val); - val |= REG_1A_INTR_CLR; - usbphy_write(USBPHY_REG_1A, val); - int_unlock(lock); - NVIC_ClearPendingIRQ(USB_PIN_IRQn); + usbphy_read(USBPHY_REG_1A, &pol); + usbphy_read(USBPHY_REG_25, &val); - if (pmu_usb_check_pin_status(usb_pin_status)) { - pmu_usb_disable_pin_status_check(); - usb_pin_callback(usb_pin_status); - return; - } - - NVIC_SetVector(USB_PIN_IRQn, (uint32_t)pmu_usb_pin_irq_handler); - NVIC_SetPriority(USB_PIN_IRQn, IRQ_PRIORITY_NORMAL); - NVIC_EnableIRQ(USB_PIN_IRQn); - } -} - -void pmu_usb_disable_pin_status_check(void) -{ - uint16_t val; - uint32_t lock; - - NVIC_DisableIRQ(USB_PIN_IRQn); - - lock = int_lock(); - - usbphy_read(USBPHY_REG_1A, &val); - val &= ~(REG_1A_USBINSERT_INTR_EN | REG_1A_USBINSERT_DET_EN); - usbphy_write(USBPHY_REG_1A, val); - - int_unlock(lock); -} - -void pmu_usb_get_pin_status(int *dp, int *dm) -{ - uint16_t pol, val; - - usbphy_read(USBPHY_REG_1A, &pol); - usbphy_read(USBPHY_REG_25, &val); - - *dp = (!(pol & REG_1A_POL_USB_RX_DP)) ^ (!(val & REG_25_USB_STATUS_RX_DP)); - *dm = (!(pol & REG_1A_POL_USB_RX_DM)) ^ (!(val & REG_25_USB_STATUS_RX_DM)); + *dp = (!(pol & REG_1A_POL_USB_RX_DP)) ^ (!(val & REG_25_USB_STATUS_RX_DP)); + *dm = (!(pol & REG_1A_POL_USB_RX_DM)) ^ (!(val & REG_25_USB_STATUS_RX_DM)); } #endif - diff --git a/platform/drivers/bt/best2300p/bt_drv.cpp b/platform/drivers/bt/best2300p/bt_drv.cpp index 10f37f3..0de186a 100644 --- a/platform/drivers/bt/best2300p/bt_drv.cpp +++ b/platform/drivers/bt/best2300p/bt_drv.cpp @@ -13,828 +13,737 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "string.h" -#include "plat_types.h" -#include "plat_addr_map.h" -#include "hal_i2c.h" -#include "hal_uart.h" #include "bt_drv.h" -#include "bt_drv_internal.h" #include "bt_drv_2300p_internal.h" -#include "bt_drv_reg_op.h" #include "bt_drv_interface.h" -#include "hal_timer.h" -#include "hal_intersys.h" -#include "hal_trace.h" -#include "hal_psc.h" -#include "hal_cmu.h" -#include "hal_sysfreq.h" +#include "bt_drv_internal.h" +#include "bt_drv_reg_op.h" #include "hal_chipid.h" -#include "hal_iomux.h" +#include "hal_cmu.h" #include "hal_gpio.h" -#include "pmu.h" +#include "hal_i2c.h" +#include "hal_intersys.h" +#include "hal_iomux.h" +#include "hal_psc.h" +#include "hal_sysfreq.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" #include "nvrecord_dev.h" - +#include "plat_addr_map.h" +#include "plat_types.h" +#include "pmu.h" +#include "string.h" +#include bool btdrv_dut_mode_enable = false; static volatile uint32_t btdrv_tx_flag = 1; -void btdrv_tx(const unsigned char *data, unsigned int len) -{ -// HciPacketSent(intersys_tx_pkt); - BT_DRV_TRACE(0,"tx"); -// osSignalSet(btdrv_intersys_tx_thread_id, 0x1); - btdrv_tx_flag = 1; +void btdrv_tx(const unsigned char *data, unsigned int len) { + // HciPacketSent(intersys_tx_pkt); + BT_DRV_TRACE(0, "tx"); + // osSignalSet(btdrv_intersys_tx_thread_id, 0x1); + btdrv_tx_flag = 1; } void btdrv_dut_accessible_mode_manager(const unsigned char *data); -static unsigned int btdrv_rx(const unsigned char *data, unsigned int len) -{ - hal_intersys_stop_recv(HAL_INTERSYS_ID_0); +static unsigned int btdrv_rx(const unsigned char *data, unsigned int len) { + hal_intersys_stop_recv(HAL_INTERSYS_ID_0); - BT_DRV_TRACE(2,"%s len:%d", __func__, len); - BT_DRV_DUMP("%02x ", data, len>7?7:len); - btdrv_dut_accessible_mode_manager(data); - hal_intersys_start_recv(HAL_INTERSYS_ID_0); + BT_DRV_TRACE(2, "%s len:%d", __func__, len); + BT_DRV_DUMP("%02x ", data, len > 7 ? 7 : len); + btdrv_dut_accessible_mode_manager(data); + hal_intersys_start_recv(HAL_INTERSYS_ID_0); - return len; + return len; } -void btdrv_SendData(const uint8_t *buff,uint8_t len) -{ - btdrv_tx_flag = 0; +void btdrv_SendData(const uint8_t *buff, uint8_t len) { + btdrv_tx_flag = 0; - hal_intersys_send(HAL_INTERSYS_ID_0, HAL_INTERSYS_MSG_HCI, buff, len); - BT_DRV_TRACE(1,"%s", __func__); - BT_DRV_DUMP("%02x ", buff, len); -// btdrv_delay(1); - while( (btdrv_dut_mode_enable==0) && btdrv_tx_flag == 0); + hal_intersys_send(HAL_INTERSYS_ID_0, HAL_INTERSYS_MSG_HCI, buff, len); + BT_DRV_TRACE(1, "%s", __func__); + BT_DRV_DUMP("%02x ", buff, len); + // btdrv_delay(1); + while ((btdrv_dut_mode_enable == 0) && btdrv_tx_flag == 0) + ; } - - ////open intersys interface for hci data transfer static bool hci_has_opened = false; -void btdrv_hciopen(void) -{ - int ret = 0; +void btdrv_hciopen(void) { + int ret = 0; - if (hci_has_opened) - { - return; - } + if (hci_has_opened) { + return; + } - hci_has_opened = true; + hci_has_opened = true; - ret = hal_intersys_open(HAL_INTERSYS_ID_0, HAL_INTERSYS_MSG_HCI, btdrv_rx, btdrv_tx, false); + ret = hal_intersys_open(HAL_INTERSYS_ID_0, HAL_INTERSYS_MSG_HCI, btdrv_rx, + btdrv_tx, false); - if (ret) - { - BT_DRV_TRACE(0,"Failed to open intersys"); - return; - } + if (ret) { + BT_DRV_TRACE(0, "Failed to open intersys"); + return; + } - hal_intersys_start_recv(HAL_INTERSYS_ID_0); + hal_intersys_start_recv(HAL_INTERSYS_ID_0); } ////open intersys interface for hci data transfer -void btdrv_hcioff(void) -{ - if (!hci_has_opened) - { - return; - } - hci_has_opened = false; +void btdrv_hcioff(void) { + if (!hci_has_opened) { + return; + } + hci_has_opened = false; - hal_intersys_close(HAL_INTERSYS_ID_0,HAL_INTERSYS_MSG_HCI); + hal_intersys_close(HAL_INTERSYS_ID_0, HAL_INTERSYS_MSG_HCI); } - - /* btdrv power on or off the bt controller*/ -void btdrv_poweron(uint8_t en) -{ - //power on bt controller - if(en) - { - hal_psc_bt_enable(); - hal_cmu_bt_clock_enable(); - hal_cmu_bt_reset_clear(); - hal_cmu_bt_module_init(); - btdrv_delay(10); - // BTDM mode 4.2 - BTDIGITAL_REG(0xC0000050) = 0x42; - btdrv_delay(100); - } - else - { - btdrv_delay(10); - hal_cmu_bt_reset_set(); - hal_cmu_bt_clock_disable(); - hal_psc_bt_disable(); - } +void btdrv_poweron(uint8_t en) { + // power on bt controller + if (en) { + hal_psc_bt_enable(); + hal_cmu_bt_clock_enable(); + hal_cmu_bt_reset_clear(); + hal_cmu_bt_module_init(); + btdrv_delay(10); + // BTDM mode 4.2 + BTDIGITAL_REG(0xC0000050) = 0x42; + btdrv_delay(100); + } else { + btdrv_delay(10); + hal_cmu_bt_reset_set(); + hal_cmu_bt_clock_disable(); + hal_psc_bt_disable(); + } } -void btdrv_rf_init_ext(void) -{ - unsigned int xtal_fcap; +void btdrv_rf_init_ext(void) { + unsigned int xtal_fcap; - if (!nvrec_dev_get_xtal_fcap(&xtal_fcap)) - { - btdrv_rf_init_xtal_fcap(xtal_fcap); - btdrv_delay(1); - BT_DRV_TRACE(2,"%s 0xc2=0x%x", __func__, xtal_fcap); - } - else - { - btdrv_rf_init_xtal_fcap(DEFAULT_XTAL_FCAP); - BT_DRV_TRACE(1,"%s failed", __func__); - } + if (!nvrec_dev_get_xtal_fcap(&xtal_fcap)) { + btdrv_rf_init_xtal_fcap(xtal_fcap); + btdrv_delay(1); + BT_DRV_TRACE(2, "%s 0xc2=0x%x", __func__, xtal_fcap); + } else { + btdrv_rf_init_xtal_fcap(DEFAULT_XTAL_FCAP); + BT_DRV_TRACE(1, "%s failed", __func__); + } } -void tx_ramp_new(void) -{ - return; +void tx_ramp_new(void) { return; } - -} - -void bt_drv_extra_config_after_init(void) -{ +void bt_drv_extra_config_after_init(void) { #ifdef BT_RF_OLD_CORR_MODE - BTDIGITAL_REG(0xD03503A0) &= (~0x01); //clear bit 0 avoid slave lost data + BTDIGITAL_REG(0xD03503A0) &= (~0x01); // clear bit 0 avoid slave lost data #endif - bt_drv_reg_op_afh_env_reset(); + bt_drv_reg_op_afh_env_reset(); } #ifdef __HW_AGC__ -uint16_t btdrv_2300_get_10bit_add_val(uint32_t val, uint8_t count) -{ - uint8_t i; - uint32_t new_val[32]; - uint16_t add_val = 0; +uint16_t btdrv_2300_get_10bit_add_val(uint32_t val, uint8_t count) { + uint8_t i; + uint32_t new_val[32]; + uint16_t add_val = 0; - for(i=0; i<32 ; i++) - { - new_val[i] = (val & 1); - val = (val >> 1); - }//get val's each bit to new_val + for (i = 0; i < 32; i++) { + new_val[i] = (val & 1); + val = (val >> 1); + } // get val's each bit to new_val - for(i=(0+count); i<(10+count) ; i++) - { - add_val |= (new_val[i] << (i-count)); - } + for (i = (0 + count); i < (10 + count); i++) { + add_val |= (new_val[i] << (i - count)); + } - return add_val; + return add_val; } +uint16_t btdrv_2300_val_get_max_min_num(uint16_t *val) { + uint8_t i = 0; + uint8_t j = 0; + uint8_t k = 0; + uint16_t max = val[0]; + uint16_t min = val[0]; -uint16_t btdrv_2300_val_get_max_min_num(uint16_t *val) -{ - uint8_t i = 0; - uint8_t j = 0; - uint8_t k = 0; - uint16_t max = val[0]; - uint16_t min = val[0]; - - for(i=1; i<10; i++) - { - if(max < val[i]) - { - max = val[i]; - j = i; - } - else if(min > val[i]) - { - min = val[i]; - k = i; - } + for (i = 1; i < 10; i++) { + if (max < val[i]) { + max = val[i]; + j = i; + } else if (min > val[i]) { + min = val[i]; + k = i; } - BT_DRV_TRACE(2,"The max is:%x, j:%d\n", max,j); - BT_DRV_TRACE(2,"The min is:%x, k:%d\n", min,k); - return ((j<<8) | k); + } + BT_DRV_TRACE(2, "The max is:%x, j:%d\n", max, j); + BT_DRV_TRACE(2, "The min is:%x, k:%d\n", min, k); + return ((j << 8) | k); } -uint16_t btdrv_2300_get_average_val(uint16_t *val) -{ - uint8_t i=0; - uint16_t num; - uint8_t max_num,min_num; - uint16_t add_val = 0; - uint16_t average_val; +uint16_t btdrv_2300_get_average_val(uint16_t *val) { + uint8_t i = 0; + uint16_t num; + uint8_t max_num, min_num; + uint16_t add_val = 0; + uint16_t average_val; - num = btdrv_2300_val_get_max_min_num(val); + num = btdrv_2300_val_get_max_min_num(val); - max_num = (uint8_t)((num & 0xff00)>>8); - min_num = (uint8_t)(num & 0x00ff); - BT_DRV_TRACE(1,"max_num:%d\n", max_num); - BT_DRV_TRACE(1,"min_num:%d\n", min_num); + max_num = (uint8_t)((num & 0xff00) >> 8); + min_num = (uint8_t)(num & 0x00ff); + BT_DRV_TRACE(1, "max_num:%d\n", max_num); + BT_DRV_TRACE(1, "min_num:%d\n", min_num); - for(i=0; i<10 ; i++) - { - BT_DRV_TRACE(2,"val[%x]:%x\n",i,val[i]); - add_val += val[i]; - } - add_val = (add_val-val[max_num]-val[min_num]); - BT_DRV_TRACE(1,"add_val:%x\n",add_val); + for (i = 0; i < 10; i++) { + BT_DRV_TRACE(2, "val[%x]:%x\n", i, val[i]); + add_val += val[i]; + } + add_val = (add_val - val[max_num] - val[min_num]); + BT_DRV_TRACE(1, "add_val:%x\n", add_val); - average_val = add_val / 8; - return average_val; + average_val = add_val / 8; + return average_val; } -union cal_val -{ - struct - { - int32_t val1 :10; - int32_t val2 :10; - int32_t val3 :10; - uint32_t reverd_bit :2; - }; - volatile uint32_t reg; +union cal_val { + struct { + int32_t val1 : 10; + int32_t val2 : 10; + int32_t val3 : 10; + uint32_t reverd_bit : 2; + }; + volatile uint32_t reg; }; -void btdrv_2300_hwagc_dc_cal_1(void) -{ - uint32_t first_val; - volatile uint32_t value = 0; -// int16_t bit_value1[10],bit_value2[10],bit_value3[10];//10bit - int32_t bit_average_val1=0,bit_average_val2=0,bit_average_val3=0; - uint32_t real_val; +void btdrv_2300_hwagc_dc_cal_1(void) { + uint32_t first_val; + volatile uint32_t value = 0; + // int16_t bit_value1[10],bit_value2[10],bit_value3[10];//10bit + int32_t bit_average_val1 = 0, bit_average_val2 = 0, bit_average_val3 = 0; + uint32_t real_val; - union cal_val dccal_val; + union cal_val dccal_val; - btdrv_write_rf_reg(0xf3,0x2c41);//i2v reset dr=1 + btdrv_write_rf_reg(0xf3, 0x2c41); // i2v reset dr=1 - btdrv_write_rf_reg(0xcf,0xff32);//lna gain dr=1 - btdrv_write_rf_reg(0xdf,0x210f);//lna gain dr=1 //210f - btdrv_write_rf_reg(0xcd,0x0040);//lna pdt gain + btdrv_write_rf_reg(0xcf, 0xff32); // lna gain dr=1 + btdrv_write_rf_reg(0xdf, 0x210f); // lna gain dr=1 //210f + btdrv_write_rf_reg(0xcd, 0x0040); // lna pdt gain - btdrv_write_rf_reg(0xd0,0xf99f);//i2v flt gain dr=1 + btdrv_write_rf_reg(0xd0, 0xf99f); // i2v flt gain dr=1 - btdrv_write_rf_reg(0xaf, 0x00c0);//rx input pull down + btdrv_write_rf_reg(0xaf, 0x00c0); // rx input pull down - //BTDIGITAL_REG(0xc000033c) = 0x00000100; + // BTDIGITAL_REG(0xc000033c) = 0x00000100; - BTDIGITAL_REG(0xd02201e4) = 0x00000000;//rx continue - btdrv_delay(10); - BTDIGITAL_REG(0xd02201e4) = 0x000a0080; - btdrv_delay(10); + BTDIGITAL_REG(0xd02201e4) = 0x00000000; // rx continue + btdrv_delay(10); + BTDIGITAL_REG(0xd02201e4) = 0x000a0080; + btdrv_delay(10); - for(uint8_t i = 0; i < 10; i++) - { - BTDIGITAL_REG(0xd03503b0) = 0x80000000; - btdrv_delay(1); - first_val = BTDIGITAL_REG(0xd03503b4); - BT_DRV_TRACE(1,"first_val:%x\n",first_val); - BTDIGITAL_REG(0xd03503b0) = 0x80000000; - } + for (uint8_t i = 0; i < 10; i++) { + BTDIGITAL_REG(0xd03503b0) = 0x80000000; + btdrv_delay(1); + first_val = BTDIGITAL_REG(0xd03503b4); + BT_DRV_TRACE(1, "first_val:%x\n", first_val); + BTDIGITAL_REG(0xd03503b0) = 0x80000000; + } - for(uint8_t i = 0; i < 10; i++) - { - BTDIGITAL_REG(0xd03503b0) = 0x80000000; - btdrv_delay(1); - BT_DRV_TRACE(1,"BTDIGITAL_REG(0xd03503b4):%x\n",BTDIGITAL_REG(0xd03503b4)); - value = BTDIGITAL_REG(0xd03503b4); - BT_DRV_TRACE(2,"%x: value:%x\n",i,value); - dccal_val.reg = value; - bit_average_val1 +=dccal_val.val1; - bit_average_val2 +=dccal_val.val2; - bit_average_val3 +=dccal_val.val3; - BT_DRV_TRACE(2,"val1=%d,val3=%d",dccal_val.val1, dccal_val.val3); - } + for (uint8_t i = 0; i < 10; i++) { + BTDIGITAL_REG(0xd03503b0) = 0x80000000; + btdrv_delay(1); + BT_DRV_TRACE(1, "BTDIGITAL_REG(0xd03503b4):%x\n", + BTDIGITAL_REG(0xd03503b4)); + value = BTDIGITAL_REG(0xd03503b4); + BT_DRV_TRACE(2, "%x: value:%x\n", i, value); + dccal_val.reg = value; + bit_average_val1 += dccal_val.val1; + bit_average_val2 += dccal_val.val2; + bit_average_val3 += dccal_val.val3; + BT_DRV_TRACE(2, "val1=%d,val3=%d", dccal_val.val1, dccal_val.val3); + } - bit_average_val1 /= 10; + bit_average_val1 /= 10; #ifdef __HW_AGC_I2V_DISABLE_DC_CAL__ - bit_average_val2 = 0; + bit_average_val2 = 0; #else - bit_average_val2 /=10; + bit_average_val2 /= 10; #endif - bit_average_val3 /= 10; + bit_average_val3 /= 10; - BT_DRV_TRACE(3,"vaer1=%d,vaer2=%d,vaer3=%d",bit_average_val1, bit_average_val2, bit_average_val3); + BT_DRV_TRACE(3, "vaer1=%d,vaer2=%d,vaer3=%d", bit_average_val1, + bit_average_val2, bit_average_val3); - dccal_val.val1 = bit_average_val1; - dccal_val.val2 = bit_average_val2; - dccal_val.val3 = bit_average_val3; - dccal_val.reverd_bit = 0; - // real_val = (bit_average_val1 | (bit_average_val2 << 10) | (bit_average_val3 << 20)); - real_val = dccal_val.reg; - BT_DRV_TRACE(1,"real_val:%x\n",real_val); - BTDIGITAL_REG(0xd03503b0) = real_val; + dccal_val.val1 = bit_average_val1; + dccal_val.val2 = bit_average_val2; + dccal_val.val3 = bit_average_val3; + dccal_val.reverd_bit = 0; + // real_val = (bit_average_val1 | (bit_average_val2 << 10) | + // (bit_average_val3 << 20)); + real_val = dccal_val.reg; + BT_DRV_TRACE(1, "real_val:%x\n", real_val); + BTDIGITAL_REG(0xd03503b0) = real_val; - BTDIGITAL_REG(0xd02201e4) = 0x00000000; + BTDIGITAL_REG(0xd02201e4) = 0x00000000; - btdrv_write_rf_reg(0xaf, 0x0000); + btdrv_write_rf_reg(0xaf, 0x0000); - btdrv_write_rf_reg(0xf3,0x0c41);//i2v reset dr=0 + btdrv_write_rf_reg(0xf3, 0x0c41); // i2v reset dr=0 - btdrv_write_rf_reg(0xcf,0x7f32);//lna gain dr=0 - btdrv_write_rf_reg(0xdf,0x2006);//lna gain dr=0 - btdrv_write_rf_reg(0xd0,0xe91f);//i2v flt gain dr=0 + btdrv_write_rf_reg(0xcf, 0x7f32); // lna gain dr=0 + btdrv_write_rf_reg(0xdf, 0x2006); // lna gain dr=0 + btdrv_write_rf_reg(0xd0, 0xe91f); // i2v flt gain dr=0 } - - #endif -void btdrv_2300_rccal(void) -{ - uint16_t value; - uint16_t value_tmp; - uint16_t val_tmp1; - uint16_t val_tmp2; +void btdrv_2300_rccal(void) { + uint16_t value; + uint16_t value_tmp; + uint16_t val_tmp1; + uint16_t val_tmp2; - btdrv_write_rf_reg(0x80, 0xa010); - btdrv_write_rf_reg(0xc4, 0xffff);//[5:4]=11,open rcosc bias - btdrv_write_rf_reg(0x80, 0xa000); + btdrv_write_rf_reg(0x80, 0xa010); + btdrv_write_rf_reg(0xc4, 0xffff); //[5:4]=11,open rcosc bias + btdrv_write_rf_reg(0x80, 0xa000); - btdrv_write_rf_reg(0xb3,0x33f3);//[9:8]=11,pwup rcosc + btdrv_write_rf_reg(0xb3, 0x33f3); //[9:8]=11,pwup rcosc - btdrv_delay(1); + btdrv_delay(1); - BTDIGITAL_REG(0xd02201e4) = 0x00000000; - btdrv_delay(10); - BTDIGITAL_REG(0xd02201e4) = 0x000a0080; - btdrv_delay(10); + BTDIGITAL_REG(0xd02201e4) = 0x00000000; + btdrv_delay(10); + BTDIGITAL_REG(0xd02201e4) = 0x000a0080; + btdrv_delay(10); - btdrv_write_rf_reg(0x80, 0xa010); - btdrv_write_rf_reg(0xd6,0xf858);//[15]=1,enable clk counter - btdrv_write_rf_reg(0x80, 0xa000); + btdrv_write_rf_reg(0x80, 0xa010); + btdrv_write_rf_reg(0xd6, 0xf858); //[15]=1,enable clk counter + btdrv_write_rf_reg(0x80, 0xa000); - btdrv_delay(10); + btdrv_delay(10); - btdrv_read_rf_reg(0xc0,&value); - BT_DRV_TRACE(1,"btdrv_rccal 0xc0 value:%x\n",value); + btdrv_read_rf_reg(0xc0, &value); + BT_DRV_TRACE(1, "btdrv_rccal 0xc0 value:%x\n", value); - btdrv_read_rf_reg(0x8b,&val_tmp1); - BT_DRV_TRACE(1,"0x8b val_tmp1=%x\n",val_tmp1); + btdrv_read_rf_reg(0x8b, &val_tmp1); + BT_DRV_TRACE(1, "0x8b val_tmp1=%x\n", val_tmp1); - btdrv_read_rf_reg(0x8d,&val_tmp2); - BT_DRV_TRACE(1,"0x8d val_tmp2=%x\n",val_tmp2); + btdrv_read_rf_reg(0x8d, &val_tmp2); + BT_DRV_TRACE(1, "0x8d val_tmp2=%x\n", val_tmp2); - value_tmp = value & 0x0fff; - if((value_tmp < 0x0ff0)&&(value_tmp > 0x0200)&&((value|0xefff)==0xffff)) - { - BT_DRV_TRACE(0,"0xc0 0x200 < value < 0xff0 done \n"); - btdrv_write_rf_reg(0x8b,(((( 0x7c4 * 1000 / (value & 0x0fff)) * 0x90 / 1000) << 8) | (val_tmp1 & 0x00ff))); - BT_DRV_TRACE(1,"0x8b:%x\n",(((( 0x7c4 * 1000 / (value & 0x0fff)) * 0x90 / 1000) << 8) | (val_tmp1 & 0x00ff))); - btdrv_read_rf_reg(0x8b,&val_tmp1); - BT_DRV_TRACE(1,"chk 0x8b val_tmp1=%x\n",val_tmp1); - btdrv_write_rf_reg(0x8d,((((0x7c4 * 1000 / (value & 0x0fff)) * 0x28 / 1000) << 10) | (val_tmp2 & 0x03ff))); - BT_DRV_TRACE(1,"0x8d:%x\n",((((0x7c4 * 1000 / (value & 0x0fff)) * 0x28 / 1000) << 10) | (val_tmp2 & 0x03ff))); - btdrv_read_rf_reg(0x8d,&val_tmp2); - BT_DRV_TRACE(1,"chk 0x8d val_tmp2=%x\n",val_tmp2); - } - else - { - btdrv_write_rf_reg(0x8b,((0x9c << 8) | (val_tmp1 & 0x00ff))); - BT_DRV_TRACE(1,"0x8b:%x\n",((0x9c << 8) | (val_tmp1 & 0x00ff))); - btdrv_write_rf_reg(0x8d,((0x28 << 10) | (val_tmp2 & 0x03ff))); - BT_DRV_TRACE(1,"0x8d:%x\n",((0x28 << 10) | (val_tmp2 & 0x03ff))); - } + value_tmp = value & 0x0fff; + if ((value_tmp < 0x0ff0) && (value_tmp > 0x0200) && + ((value | 0xefff) == 0xffff)) { + BT_DRV_TRACE(0, "0xc0 0x200 < value < 0xff0 done \n"); + btdrv_write_rf_reg( + 0x8b, ((((0x7c4 * 1000 / (value & 0x0fff)) * 0x90 / 1000) << 8) | + (val_tmp1 & 0x00ff))); + BT_DRV_TRACE(1, "0x8b:%x\n", + ((((0x7c4 * 1000 / (value & 0x0fff)) * 0x90 / 1000) << 8) | + (val_tmp1 & 0x00ff))); + btdrv_read_rf_reg(0x8b, &val_tmp1); + BT_DRV_TRACE(1, "chk 0x8b val_tmp1=%x\n", val_tmp1); + btdrv_write_rf_reg( + 0x8d, ((((0x7c4 * 1000 / (value & 0x0fff)) * 0x28 / 1000) << 10) | + (val_tmp2 & 0x03ff))); + BT_DRV_TRACE(1, "0x8d:%x\n", + ((((0x7c4 * 1000 / (value & 0x0fff)) * 0x28 / 1000) << 10) | + (val_tmp2 & 0x03ff))); + btdrv_read_rf_reg(0x8d, &val_tmp2); + BT_DRV_TRACE(1, "chk 0x8d val_tmp2=%x\n", val_tmp2); + } else { + btdrv_write_rf_reg(0x8b, ((0x9c << 8) | (val_tmp1 & 0x00ff))); + BT_DRV_TRACE(1, "0x8b:%x\n", ((0x9c << 8) | (val_tmp1 & 0x00ff))); + btdrv_write_rf_reg(0x8d, ((0x28 << 10) | (val_tmp2 & 0x03ff))); + BT_DRV_TRACE(1, "0x8d:%x\n", ((0x28 << 10) | (val_tmp2 & 0x03ff))); + } - BTDIGITAL_REG(0xd02201e4) = 0x00000000; + BTDIGITAL_REG(0xd02201e4) = 0x00000000; - btdrv_write_rf_reg(0x80, 0xa010); - btdrv_write_rf_reg(0xc4, 0xffcf);//[5:4]=00,close rcosc bias - btdrv_write_rf_reg(0x80, 0xa000); + btdrv_write_rf_reg(0x80, 0xa010); + btdrv_write_rf_reg(0xc4, 0xffcf); //[5:4]=00,close rcosc bias + btdrv_write_rf_reg(0x80, 0xa000); - btdrv_write_rf_reg(0xb3,0x30f3);//[9:8]=00,pwup rcosc + btdrv_write_rf_reg(0xb3, 0x30f3); //[9:8]=00,pwup rcosc } - #ifdef __PWR_FLATNESS__ -#define PWR_FLATNESS_CONST_VAL 0xF -void btdrv_2300p_channel_pwr_flatness(void) -{ - uint16_t read_value; - uint16_t tmp_val; +#define PWR_FLATNESS_CONST_VAL 0xF +void btdrv_2300p_channel_pwr_flatness(void) { + uint16_t read_value; + uint16_t tmp_val; - btdrv_read_rf_reg(0xc0,&read_value); - BT_DRV_TRACE(1,"btdrv_2300p_channel_pwr_flatness 0xc0=%x\n",read_value); + btdrv_read_rf_reg(0xc0, &read_value); + BT_DRV_TRACE(1, "btdrv_2300p_channel_pwr_flatness 0xc0=%x\n", read_value); - read_value = (read_value & 0x0f00)>>8;//[11:8] - int16_t calib_val = PWR_FLATNESS_CONST_VAL - read_value; - if(calib_val<0) - { - BT_DRV_TRACE(2,"calib_val<0 const_val=%d,read_val=%x",PWR_FLATNESS_CONST_VAL,read_value); - btdrv_read_rf_reg(0x92,&tmp_val); - tmp_val &= 0xf0ff;//[11:8] - BT_DRV_TRACE(1,"0x92=%x\n",tmp_val); - btdrv_write_rf_reg(0x92,tmp_val); - return; - } - else - { - BT_DRV_TRACE(2,"const_val=%d,calib_val =%x",PWR_FLATNESS_CONST_VAL,calib_val); - } + read_value = (read_value & 0x0f00) >> 8; //[11:8] + int16_t calib_val = PWR_FLATNESS_CONST_VAL - read_value; + if (calib_val < 0) { + BT_DRV_TRACE(2, "calib_val<0 const_val=%d,read_val=%x", + PWR_FLATNESS_CONST_VAL, read_value); + btdrv_read_rf_reg(0x92, &tmp_val); + tmp_val &= 0xf0ff; //[11:8] + BT_DRV_TRACE(1, "0x92=%x\n", tmp_val); + btdrv_write_rf_reg(0x92, tmp_val); + return; + } else { + BT_DRV_TRACE(2, "const_val=%d,calib_val =%x", PWR_FLATNESS_CONST_VAL, + calib_val); + } - //write calibrated value into 0x92 register - btdrv_read_rf_reg(0x92,&tmp_val); - tmp_val &= 0xf0ff; - tmp_val |= ((calib_val & 0xffff)<<8); - BT_DRV_TRACE(1,"write reg 0x92 val=%x",tmp_val); - btdrv_write_rf_reg(0x92,tmp_val); + // write calibrated value into 0x92 register + btdrv_read_rf_reg(0x92, &tmp_val); + tmp_val &= 0xf0ff; + tmp_val |= ((calib_val & 0xffff) << 8); + BT_DRV_TRACE(1, "write reg 0x92 val=%x", tmp_val); + btdrv_write_rf_reg(0x92, tmp_val); } #endif +void btdrv_enable_jtag(void) { + *(uint32_t *)0x400000F8 &= 0x7FFFFFFF; // clear bit31 - -void btdrv_enable_jtag(void) -{ - *(uint32_t*)0x400000F8 &= 0x7FFFFFFF;//clear bit31 - - hal_iomux_set_jtag(); - hal_cmu_jtag_enable(); - hal_cmu_jtag_clock_enable(); + hal_iomux_set_jtag(); + hal_cmu_jtag_enable(); + hal_cmu_jtag_clock_enable(); } -///start active bt controller +/// start active bt controller //#define BT_DRV_ENABLE_LMP_TRACE -void btdrv_start_bt(void) -{ - hal_sysfreq_req(HAL_SYSFREQ_USER_BT, HAL_CMU_FREQ_26M); +void btdrv_start_bt(void) { + hal_sysfreq_req(HAL_SYSFREQ_USER_BT, HAL_CMU_FREQ_26M); #if INTERSYS_DEBUG #ifdef BT_DRV_ENABLE_LMP_TRACE - btdrv_trace_config(BT_CONTROLER_TRACE_TYPE_INTERSYS | - BT_CONTROLER_TRACE_TYPE_CONTROLLER | - BT_CONTROLER_FILTER_TRACE_TYPE_A2DP_STREAM | - BT_CONTROLER_TRACE_TYPE_LMP_TRACE); + btdrv_trace_config(BT_CONTROLER_TRACE_TYPE_INTERSYS | + BT_CONTROLER_TRACE_TYPE_CONTROLLER | + BT_CONTROLER_FILTER_TRACE_TYPE_A2DP_STREAM | + BT_CONTROLER_TRACE_TYPE_LMP_TRACE); #else - btdrv_trace_config(BT_CONTROLER_TRACE_TYPE_INTERSYS | - BT_CONTROLER_TRACE_TYPE_CONTROLLER | - BT_CONTROLER_FILTER_TRACE_TYPE_A2DP_STREAM); + btdrv_trace_config(BT_CONTROLER_TRACE_TYPE_INTERSYS | + BT_CONTROLER_TRACE_TYPE_CONTROLLER | + BT_CONTROLER_FILTER_TRACE_TYPE_A2DP_STREAM); #endif #endif #if defined(BLE_ONLY_ENABLED) - btdrv_enable_sleep_checker(false); + btdrv_enable_sleep_checker(false); #else - btdrv_enable_sleep_checker(true); + btdrv_enable_sleep_checker(true); #endif - hal_iomux_ispi_access_enable(HAL_IOMUX_ISPI_MCU_RF); + hal_iomux_ispi_access_enable(HAL_IOMUX_ISPI_MCU_RF); #ifndef NO_SLEEP - pmu_sleep_en(0); + pmu_sleep_en(0); #endif - bt_drv_reg_op_global_symbols_init(); + bt_drv_reg_op_global_symbols_init(); - btdrv_poweron(BT_POWERON); + btdrv_poweron(BT_POWERON); - btdrv_hciopen(); + btdrv_hciopen(); - btdrv_rf_init(); + btdrv_rf_init(); - btdrv_rf_init_ext(); + btdrv_rf_init_ext(); - btdrv_config_init(); - //rom patch init - btdrv_ins_patch_init(); - btdrv_data_patch_init(); - btdrv_patch_en(1); + btdrv_config_init(); + // rom patch init + btdrv_ins_patch_init(); + btdrv_data_patch_init(); + btdrv_patch_en(1); #ifdef __HW_AGC__ - btdrv_2300_hwagc_dc_cal_1(); + btdrv_2300_hwagc_dc_cal_1(); #endif - btdrv_2300_rccal(); + btdrv_2300_rccal(); #ifdef __PWR_FLATNESS__ - btdrv_2300p_channel_pwr_flatness(); + btdrv_2300p_channel_pwr_flatness(); #endif - btdrv_txpower_calib(); + btdrv_txpower_calib(); #ifdef BT_XTAL_SYNC // btdrv_bt_spi_xtal_init(); #endif - btdrv_sync_config(); + btdrv_sync_config(); #ifdef BT_EXT_LNA_PA - int LNA_flag = 0,PA_flag = 0; + int LNA_flag = 0, PA_flag = 0; #ifdef BT_EXT_LNA - LNA_flag = 1; + LNA_flag = 1; #endif #ifdef BT_EXT_PA - PA_flag = 1; + PA_flag = 1; #endif - btdrv_enable_rf_sw(LNA_flag,PA_flag); + btdrv_enable_rf_sw(LNA_flag, PA_flag); #endif - bt_drv_reg_op_dgb_link_gain_ctrl_init(); - btdrv_fast_lock_config(0); + bt_drv_reg_op_dgb_link_gain_ctrl_init(); + btdrv_fast_lock_config(0); #ifdef __FASTACK_ECC_ENABLE__ - btdrv_ecc_config(); + btdrv_ecc_config(); #endif - //regist bt switch agc cb function - struct bt_cb_tag* bt_drv_func_cb = bt_drv_get_func_cb_ptr(); - bt_drv_func_cb->bt_switch_agc = bt_drv_select_agc_mode; + // regist bt switch agc cb function + struct bt_cb_tag *bt_drv_func_cb = bt_drv_get_func_cb_ptr(); + bt_drv_func_cb->bt_switch_agc = bt_drv_select_agc_mode; - //initialize agc mode - if(bt_drv_func_cb->bt_switch_agc != NULL) - { - bt_drv_func_cb->bt_switch_agc(BT_IDLE_MODE); - } - btdrv_hcioff(); + // initialize agc mode + if (bt_drv_func_cb->bt_switch_agc != NULL) { + bt_drv_func_cb->bt_switch_agc(BT_IDLE_MODE); + } + btdrv_hcioff(); - /*reg controller crash dump*/ - hal_trace_crash_dump_register(HAL_TRACE_CRASH_DUMP_MODULE_BT, bt_drv_reg_op_crash_dump); + /*reg controller crash dump*/ + hal_trace_crash_dump_register(HAL_TRACE_CRASH_DUMP_MODULE_BT, + bt_drv_reg_op_crash_dump); #ifndef NO_SLEEP - pmu_sleep_en(1); + pmu_sleep_en(1); #endif - hal_iomux_ispi_access_enable(HAL_IOMUX_ISPI_MCU_RF); + hal_iomux_ispi_access_enable(HAL_IOMUX_ISPI_MCU_RF); - hal_sysfreq_req(HAL_SYSFREQ_USER_BT, HAL_CMU_FREQ_32K); + hal_sysfreq_req(HAL_SYSFREQ_USER_BT, HAL_CMU_FREQ_32K); } -const uint8_t hci_cmd_enable_dut[] = -{ - 0x01,0x03, 0x18, 0x00 -}; -const uint8_t hci_cmd_enable_allscan[] = -{ - 0x01, 0x1a, 0x0c, 0x01, 0x03 -}; -const uint8_t hci_cmd_disable_scan[] = -{ - 0x01, 0x1a, 0x0c, 0x01, 0x00 -}; -const uint8_t hci_cmd_enable_pagescan[] = -{ - 0x01, 0x1a, 0x0c, 0x01, 0x02 -}; -const uint8_t hci_cmd_autoaccept_connect[] = -{ - 0x01,0x05, 0x0c, 0x03, 0x02, 0x00, 0x02 -}; -const uint8_t hci_cmd_hci_reset[] = -{ - 0x01,0x03,0x0c,0x00 -}; +const uint8_t hci_cmd_enable_dut[] = {0x01, 0x03, 0x18, 0x00}; +const uint8_t hci_cmd_enable_allscan[] = {0x01, 0x1a, 0x0c, 0x01, 0x03}; +const uint8_t hci_cmd_disable_scan[] = {0x01, 0x1a, 0x0c, 0x01, 0x00}; +const uint8_t hci_cmd_enable_pagescan[] = {0x01, 0x1a, 0x0c, 0x01, 0x02}; +const uint8_t hci_cmd_autoaccept_connect[] = {0x01, 0x05, 0x0c, 0x03, + 0x02, 0x00, 0x02}; +const uint8_t hci_cmd_hci_reset[] = {0x01, 0x03, 0x0c, 0x00}; +const uint8_t hci_cmd_nonsig_tx_dh1_pn9[] = { + 0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x04, 0x04, 0x1b, 0x00}; +const uint8_t hci_cmd_nonsig_tx_2dh1_pn9[] = { + 0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x04, 0x04, 0x36, 0x00}; +const uint8_t hci_cmd_nonsig_tx_3dh1_pn9[] = { + 0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x08, 0x04, 0x53, 0x00}; +const uint8_t hci_cmd_nonsig_tx_2dh3_pn9[] = { + 0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0a, 0x04, 0x6f, 0x01}; +const uint8_t hci_cmd_nonsig_tx_3dh3_pn9[] = { + 0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0b, 0x04, 0x28, 0x02}; -const uint8_t hci_cmd_nonsig_tx_dh1_pn9[] = -{ - 0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x04, 0x04, 0x1b, 0x00 -}; -const uint8_t hci_cmd_nonsig_tx_2dh1_pn9[] = -{ - 0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x04, 0x04, 0x36, 0x00 -}; -const uint8_t hci_cmd_nonsig_tx_3dh1_pn9[] = -{ - 0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x08, 0x04, 0x53, 0x00 -}; -const uint8_t hci_cmd_nonsig_tx_2dh3_pn9[] = -{ - 0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0a, 0x04, 0x6f, 0x01 -}; -const uint8_t hci_cmd_nonsig_tx_3dh3_pn9[] = -{ - 0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0b, 0x04, 0x28, 0x02 -}; +const uint8_t hci_cmd_nonsig_rx_dh1_pn9[] = { + 0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x04, 0x00, 0x1b, 0x00}; +const uint8_t hci_cmd_nonsig_rx_2dh1_pn9[] = { + 0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x04, 0x00, 0x36, 0x00}; +const uint8_t hci_cmd_nonsig_rx_3dh1_pn9[] = { + 0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x08, 0x00, 0x53, 0x00}; +const uint8_t hci_cmd_nonsig_rx_2dh3_pn9[] = { + 0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0a, 0x00, 0x6f, 0x01}; +const uint8_t hci_cmd_nonsig_rx_3dh3_pn9[] = { + 0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0b, 0x00, 0x28, 0x02}; -const uint8_t hci_cmd_nonsig_rx_dh1_pn9[] = -{ - 0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x04, 0x00, 0x1b, 0x00 -}; -const uint8_t hci_cmd_nonsig_rx_2dh1_pn9[] = -{ - 0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x04, 0x00, 0x36, 0x00 -}; -const uint8_t hci_cmd_nonsig_rx_3dh1_pn9[] = -{ - 0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x08, 0x00, 0x53, 0x00 -}; -const uint8_t hci_cmd_nonsig_rx_2dh3_pn9[] = -{ - 0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0a, 0x00, 0x6f, 0x01 -}; -const uint8_t hci_cmd_nonsig_rx_3dh3_pn9[] = -{ - 0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0b, 0x00, 0x28, 0x02 -}; +const uint8_t hci_cmd_nonsig_tx_dh1_pn9_t2[] = { + 0x01, 0x87, 0xfc, 0x1c, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x04, 0x04, + 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff}; +const uint8_t hci_cmd_nonsig_tx_2dh1_pn9_t2[] = { + 0x01, 0x87, 0xfc, 0x1c, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x04, 0x04, + 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff}; +const uint8_t hci_cmd_nonsig_tx_3dh1_pn9_t2[] = { + 0x01, 0x87, 0xfc, 0x1c, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x08, 0x04, + 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff}; +const uint8_t hci_cmd_nonsig_tx_2dh3_pn9_t2[] = { + 0x01, 0x87, 0xfc, 0x1c, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0a, 0x04, + 0x6f, 0x01, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff}; +const uint8_t hci_cmd_nonsig_tx_3dh3_pn9_t2[] = { + 0x01, 0x87, 0xfc, 0x1c, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0b, 0x04, + 0x28, 0x02, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff}; -const uint8_t hci_cmd_nonsig_tx_dh1_pn9_t2[] = -{ - 0x01, 0x87, 0xfc, 0x1c, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x04, 0x04, 0x1b, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff -}; -const uint8_t hci_cmd_nonsig_tx_2dh1_pn9_t2[] = -{ - 0x01, 0x87, 0xfc, 0x1c, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x04, 0x04, 0x36, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff -}; -const uint8_t hci_cmd_nonsig_tx_3dh1_pn9_t2[] = -{ - 0x01, 0x87, 0xfc, 0x1c, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x08, 0x04, 0x53, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff -}; -const uint8_t hci_cmd_nonsig_tx_2dh3_pn9_t2[] = -{ - 0x01, 0x87, 0xfc, 0x1c, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0a, 0x04, 0x6f, 0x01, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff -}; -const uint8_t hci_cmd_nonsig_tx_3dh3_pn9_t2[] = -{ - 0x01, 0x87, 0xfc, 0x1c, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0b, 0x04, 0x28, 0x02, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff -}; +const uint8_t hci_cmd_nonsig_rx_dh1_pn9_t2[] = { + 0x01, 0x87, 0xfc, 0x1c, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x04, 0x00, + 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff}; +const uint8_t hci_cmd_nonsig_rx_2dh1_pn9_t2[] = { + 0x01, 0x87, 0xfc, 0x1c, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x04, 0x00, + 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff}; +const uint8_t hci_cmd_nonsig_rx_3dh1_pn9_t2[] = { + 0x01, 0x87, 0xfc, 0x1c, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x08, 0x00, + 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff}; +const uint8_t hci_cmd_nonsig_rx_2dh3_pn9_t2[] = { + 0x01, 0x87, 0xfc, 0x1c, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0a, 0x00, + 0x6f, 0x01, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff}; +const uint8_t hci_cmd_nonsig_rx_3dh3_pn9_t2[] = { + 0x01, 0x87, 0xfc, 0x1c, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0b, 0x00, + 0x28, 0x02, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff}; -const uint8_t hci_cmd_nonsig_rx_dh1_pn9_t2[] = -{ - 0x01, 0x87, 0xfc, 0x1c, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x04, 0x00, 0x1b, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff -}; -const uint8_t hci_cmd_nonsig_rx_2dh1_pn9_t2[] = -{ - 0x01, 0x87, 0xfc, 0x1c, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x04, 0x00, 0x36, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff -}; -const uint8_t hci_cmd_nonsig_rx_3dh1_pn9_t2[] = -{ - 0x01, 0x87, 0xfc, 0x1c, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x08, 0x00, 0x53, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff -}; -const uint8_t hci_cmd_nonsig_rx_2dh3_pn9_t2[] = -{ - 0x01, 0x87, 0xfc, 0x1c, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0a, 0x00, 0x6f, 0x01, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff -}; -const uint8_t hci_cmd_nonsig_rx_3dh3_pn9_t2[] = -{ - 0x01, 0x87, 0xfc, 0x1c, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0b, 0x00, 0x28, 0x02, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff -}; +// vco test +const uint8_t hci_cmd_start_bt_vco_test[] = {0x01, 0xaa, 0xfc, + 0x02, 0x00, 0x02}; +const uint8_t hci_cmd_stop_bt_vco_test[] = {0x01, 0xaa, 0xfc, 0x02, 0x00, 0x04}; -//vco test -const uint8_t hci_cmd_start_bt_vco_test[] = -{ - 0x01, 0xaa, 0xfc, 0x02, 0x00,0x02 -}; -const uint8_t hci_cmd_stop_bt_vco_test[] = -{ - 0x01, 0xaa, 0xfc, 0x02, 0x00,0x04 -}; +void btdrv_testmode_start(void) { + struct bt_cb_tag *bt_drv_func_cb = bt_drv_get_func_cb_ptr(); -void btdrv_testmode_start(void) -{ - struct bt_cb_tag* bt_drv_func_cb = bt_drv_get_func_cb_ptr(); - - if(bt_drv_func_cb->bt_switch_agc != NULL) - { - bt_drv_func_cb->bt_switch_agc(BT_A2DP_WORK_MODE); - } - bt_drv_tx_pwr_init_for_testmode(); + if (bt_drv_func_cb->bt_switch_agc != NULL) { + bt_drv_func_cb->bt_switch_agc(BT_A2DP_WORK_MODE); + } + bt_drv_tx_pwr_init_for_testmode(); } -void btdrv_write_localinfo(const char *name, uint8_t len, const uint8_t *addr) -{ - uint8_t hci_cmd_write_addr[5+6] = - { - 0x01, 0x72, 0xfc, 0x07, 0x00 - }; +void btdrv_write_localinfo(const char *name, uint8_t len, const uint8_t *addr) { + uint8_t hci_cmd_write_addr[5 + 6] = {0x01, 0x72, 0xfc, 0x07, 0x00}; - uint8_t hci_cmd_write_name[248+4] = - { - 0x01, 0x13, 0x0c, 0xF8 - }; - memset(&hci_cmd_write_name[4], 0, sizeof(hci_cmd_write_name)-4); - memcpy(&hci_cmd_write_name[4], name, len); - btdrv_SendData(hci_cmd_write_name, sizeof(hci_cmd_write_name)); - btdrv_delay(50); - memcpy(&hci_cmd_write_addr[5], addr, 6); - btdrv_SendData(hci_cmd_write_addr, sizeof(hci_cmd_write_addr)); - btdrv_delay(20); + uint8_t hci_cmd_write_name[248 + 4] = {0x01, 0x13, 0x0c, 0xF8}; + memset(&hci_cmd_write_name[4], 0, sizeof(hci_cmd_write_name) - 4); + memcpy(&hci_cmd_write_name[4], name, len); + btdrv_SendData(hci_cmd_write_name, sizeof(hci_cmd_write_name)); + btdrv_delay(50); + memcpy(&hci_cmd_write_addr[5], addr, 6); + btdrv_SendData(hci_cmd_write_addr, sizeof(hci_cmd_write_addr)); + btdrv_delay(20); } -void btdrv_enable_dut(void) -{ - btdrv_SendData(hci_cmd_enable_dut, sizeof(hci_cmd_enable_dut)); - btdrv_delay(20); - btdrv_SendData(hci_cmd_enable_allscan, sizeof(hci_cmd_enable_allscan)); - btdrv_delay(20); - btdrv_SendData(hci_cmd_autoaccept_connect, sizeof(hci_cmd_autoaccept_connect)); - btdrv_delay(20); - bt_drv_reg_op_set_accessible_mode(3); +void btdrv_enable_dut(void) { + btdrv_SendData(hci_cmd_enable_dut, sizeof(hci_cmd_enable_dut)); + btdrv_delay(20); + btdrv_SendData(hci_cmd_enable_allscan, sizeof(hci_cmd_enable_allscan)); + btdrv_delay(20); + btdrv_SendData(hci_cmd_autoaccept_connect, + sizeof(hci_cmd_autoaccept_connect)); + btdrv_delay(20); + bt_drv_reg_op_set_accessible_mode(3); #ifdef LAURENT_ALGORITHM - btdrv_bt_laurent_algorithm_enable(); + btdrv_bt_laurent_algorithm_enable(); #endif - btdrv_dut_mode_enable = true; + btdrv_dut_mode_enable = true; } -void btdrv_disable_scan(void) -{ - btdrv_SendData(hci_cmd_disable_scan, sizeof(hci_cmd_disable_scan)); - btdrv_delay(20); +void btdrv_disable_scan(void) { + btdrv_SendData(hci_cmd_disable_scan, sizeof(hci_cmd_disable_scan)); + btdrv_delay(20); } static uint32_t dut_connect_status = DUT_CONNECT_STATUS_DISCONNECTED; -uint32_t btdrv_dut_get_connect_status(void) -{ - return dut_connect_status; -} +uint32_t btdrv_dut_get_connect_status(void) { return dut_connect_status; } -void btdrv_dut_accessible_mode_manager(const unsigned char *data) -{ - if(btdrv_dut_mode_enable) - { - if(data[0]==0x04&&data[1]==0x03&&data[2]==0x0b&&data[3]==0x00) - { - bt_drv_reg_op_set_accessible_mode(0); - btdrv_disable_scan(); - dut_connect_status = DUT_CONNECT_STATUS_CONNECTED; - } - else if(data[0]==0x04&&data[1]==0x05&&data[2]==0x04&&data[3]==0x00) - { - btdrv_enable_dut(); - dut_connect_status = DUT_CONNECT_STATUS_DISCONNECTED; - } +void btdrv_dut_accessible_mode_manager(const unsigned char *data) { + if (btdrv_dut_mode_enable) { + if (data[0] == 0x04 && data[1] == 0x03 && data[2] == 0x0b && + data[3] == 0x00) { + bt_drv_reg_op_set_accessible_mode(0); + btdrv_disable_scan(); + dut_connect_status = DUT_CONNECT_STATUS_CONNECTED; + } else if (data[0] == 0x04 && data[1] == 0x05 && data[2] == 0x04 && + data[3] == 0x00) { + btdrv_enable_dut(); + dut_connect_status = DUT_CONNECT_STATUS_DISCONNECTED; } + } } -void btdrv_hci_reset(void) -{ - btdrv_SendData(hci_cmd_hci_reset, sizeof(hci_cmd_hci_reset)); - btdrv_delay(350); +void btdrv_hci_reset(void) { + btdrv_SendData(hci_cmd_hci_reset, sizeof(hci_cmd_hci_reset)); + btdrv_delay(350); } -void btdrv_enable_nonsig_tx(uint8_t index) -{ - BT_DRV_TRACE(1,"%s\n", __func__); +void btdrv_enable_nonsig_tx(uint8_t index) { + BT_DRV_TRACE(1, "%s\n", __func__); - if (hal_get_chip_metal_id() < HAL_CHIP_METAL_ID_1) - { - if (index == 0) - btdrv_SendData(hci_cmd_nonsig_tx_2dh1_pn9, sizeof(hci_cmd_nonsig_tx_2dh1_pn9)); - else if (index == 1) - btdrv_SendData(hci_cmd_nonsig_tx_3dh1_pn9, sizeof(hci_cmd_nonsig_tx_3dh1_pn9)); - else if (index == 2) - btdrv_SendData(hci_cmd_nonsig_tx_2dh3_pn9, sizeof(hci_cmd_nonsig_tx_2dh1_pn9)); - else if (index == 3) - btdrv_SendData(hci_cmd_nonsig_tx_3dh3_pn9, sizeof(hci_cmd_nonsig_tx_3dh1_pn9)); - else - btdrv_SendData(hci_cmd_nonsig_tx_dh1_pn9, sizeof(hci_cmd_nonsig_tx_dh1_pn9)); - } + if (hal_get_chip_metal_id() < HAL_CHIP_METAL_ID_1) { + if (index == 0) + btdrv_SendData(hci_cmd_nonsig_tx_2dh1_pn9, + sizeof(hci_cmd_nonsig_tx_2dh1_pn9)); + else if (index == 1) + btdrv_SendData(hci_cmd_nonsig_tx_3dh1_pn9, + sizeof(hci_cmd_nonsig_tx_3dh1_pn9)); + else if (index == 2) + btdrv_SendData(hci_cmd_nonsig_tx_2dh3_pn9, + sizeof(hci_cmd_nonsig_tx_2dh1_pn9)); + else if (index == 3) + btdrv_SendData(hci_cmd_nonsig_tx_3dh3_pn9, + sizeof(hci_cmd_nonsig_tx_3dh1_pn9)); else - { - if (index == 0) - btdrv_SendData(hci_cmd_nonsig_tx_2dh1_pn9_t2, sizeof(hci_cmd_nonsig_tx_2dh1_pn9_t2)); - else if (index == 1) - btdrv_SendData(hci_cmd_nonsig_tx_3dh1_pn9_t2, sizeof(hci_cmd_nonsig_tx_3dh1_pn9_t2)); - else if (index == 2) - btdrv_SendData(hci_cmd_nonsig_tx_2dh3_pn9_t2, sizeof(hci_cmd_nonsig_tx_2dh1_pn9_t2)); - else if (index == 3) - btdrv_SendData(hci_cmd_nonsig_tx_3dh3_pn9_t2, sizeof(hci_cmd_nonsig_tx_3dh1_pn9_t2)); - else - btdrv_SendData(hci_cmd_nonsig_tx_dh1_pn9_t2, sizeof(hci_cmd_nonsig_tx_dh1_pn9_t2)); - } - - btdrv_delay(20); + btdrv_SendData(hci_cmd_nonsig_tx_dh1_pn9, + sizeof(hci_cmd_nonsig_tx_dh1_pn9)); + } else { + if (index == 0) + btdrv_SendData(hci_cmd_nonsig_tx_2dh1_pn9_t2, + sizeof(hci_cmd_nonsig_tx_2dh1_pn9_t2)); + else if (index == 1) + btdrv_SendData(hci_cmd_nonsig_tx_3dh1_pn9_t2, + sizeof(hci_cmd_nonsig_tx_3dh1_pn9_t2)); + else if (index == 2) + btdrv_SendData(hci_cmd_nonsig_tx_2dh3_pn9_t2, + sizeof(hci_cmd_nonsig_tx_2dh1_pn9_t2)); + else if (index == 3) + btdrv_SendData(hci_cmd_nonsig_tx_3dh3_pn9_t2, + sizeof(hci_cmd_nonsig_tx_3dh1_pn9_t2)); + else + btdrv_SendData(hci_cmd_nonsig_tx_dh1_pn9_t2, + sizeof(hci_cmd_nonsig_tx_dh1_pn9_t2)); + } + btdrv_delay(20); } -void btdrv_enable_nonsig_rx(uint8_t index) -{ - BT_DRV_TRACE(1,"%s\n", __func__); +void btdrv_enable_nonsig_rx(uint8_t index) { + BT_DRV_TRACE(1, "%s\n", __func__); - if (hal_get_chip_metal_id() < HAL_CHIP_METAL_ID_1) - { - if (index == 0) - btdrv_SendData(hci_cmd_nonsig_rx_2dh1_pn9, sizeof(hci_cmd_nonsig_rx_2dh1_pn9)); - else if (index == 1) - btdrv_SendData(hci_cmd_nonsig_rx_3dh1_pn9, sizeof(hci_cmd_nonsig_rx_3dh1_pn9)); - else if (index == 2) - btdrv_SendData(hci_cmd_nonsig_rx_2dh3_pn9, sizeof(hci_cmd_nonsig_rx_2dh1_pn9)); - else if (index == 3) - btdrv_SendData(hci_cmd_nonsig_rx_3dh3_pn9, sizeof(hci_cmd_nonsig_rx_3dh1_pn9)); - else - btdrv_SendData(hci_cmd_nonsig_rx_dh1_pn9, sizeof(hci_cmd_nonsig_rx_dh1_pn9)); - } + if (hal_get_chip_metal_id() < HAL_CHIP_METAL_ID_1) { + if (index == 0) + btdrv_SendData(hci_cmd_nonsig_rx_2dh1_pn9, + sizeof(hci_cmd_nonsig_rx_2dh1_pn9)); + else if (index == 1) + btdrv_SendData(hci_cmd_nonsig_rx_3dh1_pn9, + sizeof(hci_cmd_nonsig_rx_3dh1_pn9)); + else if (index == 2) + btdrv_SendData(hci_cmd_nonsig_rx_2dh3_pn9, + sizeof(hci_cmd_nonsig_rx_2dh1_pn9)); + else if (index == 3) + btdrv_SendData(hci_cmd_nonsig_rx_3dh3_pn9, + sizeof(hci_cmd_nonsig_rx_3dh1_pn9)); else - { - if (index == 0) - btdrv_SendData(hci_cmd_nonsig_rx_2dh1_pn9_t2, sizeof(hci_cmd_nonsig_rx_2dh1_pn9_t2)); - else if (index == 1) - btdrv_SendData(hci_cmd_nonsig_rx_3dh1_pn9_t2, sizeof(hci_cmd_nonsig_rx_3dh1_pn9_t2)); - else if (index == 2) - btdrv_SendData(hci_cmd_nonsig_rx_2dh3_pn9_t2, sizeof(hci_cmd_nonsig_rx_2dh1_pn9_t2)); - else if (index == 3) - btdrv_SendData(hci_cmd_nonsig_rx_3dh3_pn9_t2, sizeof(hci_cmd_nonsig_rx_3dh1_pn9_t2)); - else - btdrv_SendData(hci_cmd_nonsig_rx_dh1_pn9_t2, sizeof(hci_cmd_nonsig_rx_dh1_pn9_t2)); - } + btdrv_SendData(hci_cmd_nonsig_rx_dh1_pn9, + sizeof(hci_cmd_nonsig_rx_dh1_pn9)); + } else { + if (index == 0) + btdrv_SendData(hci_cmd_nonsig_rx_2dh1_pn9_t2, + sizeof(hci_cmd_nonsig_rx_2dh1_pn9_t2)); + else if (index == 1) + btdrv_SendData(hci_cmd_nonsig_rx_3dh1_pn9_t2, + sizeof(hci_cmd_nonsig_rx_3dh1_pn9_t2)); + else if (index == 2) + btdrv_SendData(hci_cmd_nonsig_rx_2dh3_pn9_t2, + sizeof(hci_cmd_nonsig_rx_2dh1_pn9_t2)); + else if (index == 3) + btdrv_SendData(hci_cmd_nonsig_rx_3dh3_pn9_t2, + sizeof(hci_cmd_nonsig_rx_3dh1_pn9_t2)); + else + btdrv_SendData(hci_cmd_nonsig_rx_dh1_pn9_t2, + sizeof(hci_cmd_nonsig_rx_dh1_pn9_t2)); + } - btdrv_delay(20); + btdrv_delay(20); } static bool btdrv_vco_test_running = false; @@ -844,345 +753,292 @@ static unsigned short vco_test_reg_val_1f3 = 0; static unsigned short vco_test_hack_flag = 0; static unsigned short vco_test_channel = 0xff; -unsigned short btdrv_get_vco_test_process_flag(void) -{ - return vco_test_hack_flag; +unsigned short btdrv_get_vco_test_process_flag(void) { + return vco_test_hack_flag; } -bool btdrv_vco_test_bridge_intsys_callback(const unsigned char *data) -{ - bool status = false; - if(data[0]==0x01 &&data[1]==0xaa&&data[2]==0xfc &&data[3]==0x02) - { - status = true; - vco_test_hack_flag = data[5]; - vco_test_channel = data[4]; - } +bool btdrv_vco_test_bridge_intsys_callback(const unsigned char *data) { + bool status = false; + if (data[0] == 0x01 && data[1] == 0xaa && data[2] == 0xfc && + data[3] == 0x02) { + status = true; + vco_test_hack_flag = data[5]; + vco_test_channel = data[4]; + } - return status; + return status; } -void btdrv_vco_test_process(uint8_t op) -{ - if(op == 0x02)//vco test start - { - if(vco_test_channel != 0xff) - btdrv_vco_test_start(vco_test_channel); - } - else if(op ==0x04)//vco test stop - { - btdrv_vco_test_stop(); - } - vco_test_channel =0xff; - vco_test_hack_flag = 0; +void btdrv_vco_test_process(uint8_t op) { + if (op == 0x02) // vco test start + { + if (vco_test_channel != 0xff) + btdrv_vco_test_start(vco_test_channel); + } else if (op == 0x04) // vco test stop + { + btdrv_vco_test_stop(); + } + vco_test_channel = 0xff; + vco_test_hack_flag = 0; } #endif -void btdrv_vco_test_start(uint8_t chnl) -{ - if (!btdrv_vco_test_running) - { - btdrv_vco_test_running = true; - hal_analogif_reg_read(0xb6, &vco_test_reg_val_b6); - hal_analogif_reg_read(0x1f3, &vco_test_reg_val_1f3); - hal_analogif_reg_write(0x1f3, 0); - hal_analogif_reg_write(0xb6, vco_test_reg_val_b6|(0x03<<14)); - hal_analogif_reg_write(0x1d7, 0xc4f8); +void btdrv_vco_test_start(uint8_t chnl) { + if (!btdrv_vco_test_running) { + btdrv_vco_test_running = true; + hal_analogif_reg_read(0xb6, &vco_test_reg_val_b6); + hal_analogif_reg_read(0x1f3, &vco_test_reg_val_1f3); + hal_analogif_reg_write(0x1f3, 0); + hal_analogif_reg_write(0xb6, vco_test_reg_val_b6 | (0x03 << 14)); + hal_analogif_reg_write(0x1d7, 0xc4f8); - BTDIGITAL_REG(0xd02201e4) = (chnl & 0x7f) | 0xa0000; - btdrv_delay(10); - BTDIGITAL_REG(0xd02201e4) = 0; - btdrv_delay(10); - BTDIGITAL_REG(0xd0340020) &= (~0x7); - BTDIGITAL_REG(0xd0340020) |= 6; - btdrv_delay(10); - } + BTDIGITAL_REG(0xd02201e4) = (chnl & 0x7f) | 0xa0000; + btdrv_delay(10); + BTDIGITAL_REG(0xd02201e4) = 0; + btdrv_delay(10); + BTDIGITAL_REG(0xd0340020) &= (~0x7); + BTDIGITAL_REG(0xd0340020) |= 6; + btdrv_delay(10); + } } -void btdrv_vco_test_stop(void) -{ - if (btdrv_vco_test_running) - { - btdrv_vco_test_running = false; - BTDIGITAL_REG(0xd02201bc) = 0; - BTDIGITAL_REG(0xd0340020) &=(~0x7); - if (vco_test_reg_val_b6 != 0) - { - hal_analogif_reg_write(0xb6, vco_test_reg_val_b6); - } - if (vco_test_reg_val_1f3 != 0) - { - hal_analogif_reg_write(0x1f3, vco_test_reg_val_1f3); - } - btdrv_delay(10); +void btdrv_vco_test_stop(void) { + if (btdrv_vco_test_running) { + btdrv_vco_test_running = false; + BTDIGITAL_REG(0xd02201bc) = 0; + BTDIGITAL_REG(0xd0340020) &= (~0x7); + if (vco_test_reg_val_b6 != 0) { + hal_analogif_reg_write(0xb6, vco_test_reg_val_b6); } + if (vco_test_reg_val_1f3 != 0) { + hal_analogif_reg_write(0x1f3, vco_test_reg_val_1f3); + } + btdrv_delay(10); + } } #ifdef LAURENT_ALGORITHM -void btdrv_ble_test_bridge_intsys_callback(const unsigned char *data) -{ - if(data[0]==0x01 &&data[1]==0x03&&data[2]==0x0c &&data[3]==0x00) - { - //reset - btdrv_bt_laurent_algorithm_enable(); - } - else if(data[0]==0x01 &&(data[1]==0x1d || data[1]==0x1e)) - { - //enter ble test mode - btdrv_bt_laurent_algorithm_enable(); - btdrv_ble_laurent_algorithm_enable(); - } - else if(data[0]==0x01 &&data[1]==0x1f) - { - //exit ble tes mode - btdrv_bt_laurent_algorithm_enable(); - } +void btdrv_ble_test_bridge_intsys_callback(const unsigned char *data) { + if (data[0] == 0x01 && data[1] == 0x03 && data[2] == 0x0c && + data[3] == 0x00) { + // reset + btdrv_bt_laurent_algorithm_enable(); + } else if (data[0] == 0x01 && (data[1] == 0x1d || data[1] == 0x1e)) { + // enter ble test mode + btdrv_bt_laurent_algorithm_enable(); + btdrv_ble_laurent_algorithm_enable(); + } else if (data[0] == 0x01 && data[1] == 0x1f) { + // exit ble tes mode + btdrv_bt_laurent_algorithm_enable(); + } } #endif -void btdrv_stop_bt(void) -{ - btdrv_poweron(BT_POWEROFF); +void btdrv_stop_bt(void) { btdrv_poweron(BT_POWEROFF); } +void btdrv_write_memory(uint8_t wr_type, uint32_t address, const uint8_t *value, + uint8_t length) { + uint8_t buff[256]; + if (length == 0 || length > 128) + return; + buff[0] = 0x01; + buff[1] = 0x02; + buff[2] = 0xfc; + buff[3] = length + 6; + buff[4] = address & 0xff; + buff[5] = (address & 0xff00) >> 8; + buff[6] = (address & 0xff0000) >> 16; + buff[7] = address >> 24; + buff[8] = wr_type; + buff[9] = length; + memcpy(&buff[10], value, length); + btdrv_SendData(buff, length + 10); + btdrv_delay(2); } -void btdrv_write_memory(uint8_t wr_type,uint32_t address,const uint8_t *value,uint8_t length) -{ - uint8_t buff[256]; - if(length ==0 || length >128) - return; - buff[0] = 0x01; - buff[1] = 0x02; - buff[2] = 0xfc; - buff[3] = length + 6; - buff[4] = address & 0xff; - buff[5] = (address &0xff00)>>8; - buff[6] = (address &0xff0000)>>16; - buff[7] = address>>24; - buff[8] = wr_type; - buff[9] = length; - memcpy(&buff[10],value,length); - btdrv_SendData(buff,length+10); - btdrv_delay(2); - - +void btdrv_send_cmd(uint16_t opcode, uint8_t cmdlen, const uint8_t *param) { + uint8_t buff[256]; + buff[0] = 0x01; + buff[1] = opcode & 0xff; + buff[2] = (opcode & 0xff00) >> 8; + buff[3] = cmdlen; + if (cmdlen > 0) + memcpy(&buff[4], param, cmdlen); + btdrv_SendData(buff, cmdlen + 4); } -void btdrv_send_cmd(uint16_t opcode,uint8_t cmdlen,const uint8_t *param) -{ - uint8_t buff[256]; - buff[0] = 0x01; - buff[1] = opcode & 0xff; - buff[2] = (opcode &0xff00)>>8; - buff[3] = cmdlen; - if(cmdlen>0) - memcpy(&buff[4],param,cmdlen); - btdrv_SendData(buff,cmdlen+4); -} +void btdrv_rxdpd_sample_init(void) {} -void btdrv_rxdpd_sample_init(void) -{ -} - -void btdrv_rxdpd_sample_deinit(void) -{ -} +void btdrv_rxdpd_sample_deinit(void) {} #define BTTX_PATTEN (1) -#define BTTX_FREQ(freq) ((freq-2402)&0x7f) +#define BTTX_FREQ(freq) ((freq - 2402) & 0x7f) -void btdrv_rxdpd_sample_init_tx(void) -{ -} +void btdrv_rxdpd_sample_init_tx(void) {} -void btdrv_rxdpd_sample_enable(uint8_t rxon, uint8_t txon) -{ -} -void btdrv_btcore_extwakeup_irq_enable(bool on) -{ - if (on) - { - *(volatile uint32_t *)(0xd033003c) |= (1<<14); - } - else - { - *(volatile uint32_t *)(0xd033003c) &= ~(1<<14); - } +void btdrv_rxdpd_sample_enable(uint8_t rxon, uint8_t txon) {} +void btdrv_btcore_extwakeup_irq_enable(bool on) { + if (on) { + *(volatile uint32_t *)(0xd033003c) |= (1 << 14); + } else { + *(volatile uint32_t *)(0xd033003c) &= ~(1 << 14); + } } //[26:0] 0x07ffffff //[27:0] 0x0fffffff -uint32_t btdrv_syn_get_curr_ticks(void) -{ - uint32_t value; +uint32_t btdrv_syn_get_curr_ticks(void) { + uint32_t value; - value = BTDIGITAL_REG(0xd0220490) & 0x0fffffff; - return value; + value = BTDIGITAL_REG(0xd0220490) & 0x0fffffff; + return value; } -static int32_t btdrv_syn_get_offset_ticks(uint16_t conidx) -{ - int32_t offset; - uint32_t local_offset; - uint16_t offset0; - uint16_t offset1; - offset0 = BTDIGITAL_BT_EM(EM_BT_CLKOFF0_ADDR + conidx*110); - offset1 = BTDIGITAL_BT_EM(EM_BT_CLKOFF1_ADDR + conidx*110); +static int32_t btdrv_syn_get_offset_ticks(uint16_t conidx) { + int32_t offset; + uint32_t local_offset; + uint16_t offset0; + uint16_t offset1; + offset0 = BTDIGITAL_BT_EM(EM_BT_CLKOFF0_ADDR + conidx * 110); + offset1 = BTDIGITAL_BT_EM(EM_BT_CLKOFF1_ADDR + conidx * 110); - local_offset = (offset0 | offset1 << 16) & 0x07ffffff; - offset = local_offset; - offset = (offset << 5)>>5; - - if (offset) - { - return offset*2; - } - else - { - return 0; - } + local_offset = (offset0 | offset1 << 16) & 0x07ffffff; + offset = local_offset; + offset = (offset << 5) >> 5; + if (offset) { + return offset * 2; + } else { + return 0; + } } // Clear trigger signal with software -void btdrv_syn_clr_trigger(void) -{ - BTDIGITAL_REG(0xd02201f0) = BTDIGITAL_REG(0xd02201f0) | (1<<31); +void btdrv_syn_clr_trigger(void) { + BTDIGITAL_REG(0xd02201f0) = BTDIGITAL_REG(0xd02201f0) | (1 << 31); } -static void btdrv_syn_set_tg_ticks(uint32_t num, uint8_t mode) -{ - if (mode == BT_TRIG_MASTER_ROLE) - { - BTDIGITAL_REG(0xd02204a4) = 0x80000006; - BTDIGITAL_REG(0xd02201f0) = (BTDIGITAL_REG(0xd02201f0) & 0x70000000) | (num & 0x0fffffff) | 0x10000000; - //BT_DRV_TRACE(1,"master mode d02201f0:0x%x\n",BTDIGITAL_REG(0xd02201f0)); - } - else - { - BTDIGITAL_REG(0xd02204a4) = 0x80000006; - BTDIGITAL_REG(0xd02201f0) = (BTDIGITAL_REG(0xd02201f0) & 0x60000000) | (num & 0x0fffffff); - //BT_DRV_TRACE(1,"slave mode d02201f0:0x%x\n",BTDIGITAL_REG(0xd02201f0)); - } +static void btdrv_syn_set_tg_ticks(uint32_t num, uint8_t mode) { + if (mode == BT_TRIG_MASTER_ROLE) { + BTDIGITAL_REG(0xd02204a4) = 0x80000006; + BTDIGITAL_REG(0xd02201f0) = (BTDIGITAL_REG(0xd02201f0) & 0x70000000) | + (num & 0x0fffffff) | 0x10000000; + // BT_DRV_TRACE(1,"master mode d02201f0:0x%x\n",BTDIGITAL_REG(0xd02201f0)); + } else { + BTDIGITAL_REG(0xd02204a4) = 0x80000006; + BTDIGITAL_REG(0xd02201f0) = + (BTDIGITAL_REG(0xd02201f0) & 0x60000000) | (num & 0x0fffffff); + // BT_DRV_TRACE(1,"slave mode d02201f0:0x%x\n",BTDIGITAL_REG(0xd02201f0)); + } } -void btdrv_syn_trigger_codec_en(uint32_t v) -{ -} - - -uint32_t btdrv_get_syn_trigger_codec_en(void) -{ - return BTDIGITAL_REG(0xd02201f0); -} - - -uint32_t btdrv_get_trigger_ticks(void) -{ - return BTDIGITAL_REG(0xd02201f0); +void btdrv_syn_trigger_codec_en(uint32_t v) {} + +uint32_t btdrv_get_syn_trigger_codec_en(void) { + return BTDIGITAL_REG(0xd02201f0); } +uint32_t btdrv_get_trigger_ticks(void) { return BTDIGITAL_REG(0xd02201f0); } // Can be used by master or slave // Ref: Master bt clk -uint32_t bt_syn_get_curr_ticks(uint16_t conhdl) -{ - int32_t curr,offset; +uint32_t bt_syn_get_curr_ticks(uint16_t conhdl) { + int32_t curr, offset; - curr = btdrv_syn_get_curr_ticks(); + curr = btdrv_syn_get_curr_ticks(); - if (btdrv_is_link_index_valid(btdrv_conhdl_to_linkid(conhdl))) - offset = btdrv_syn_get_offset_ticks(btdrv_conhdl_to_linkid(conhdl)); - else - offset = 0; -// BT_DRV_TRACE(4,"[%s] curr(%d) + offset(%d) = %d", __func__, curr , offset,curr + offset); - return (curr + offset) & 0x0fffffff; + if (btdrv_is_link_index_valid(btdrv_conhdl_to_linkid(conhdl))) + offset = btdrv_syn_get_offset_ticks(btdrv_conhdl_to_linkid(conhdl)); + else + offset = 0; + // BT_DRV_TRACE(4,"[%s] curr(%d) + offset(%d) = %d", __func__, curr , + // offset,curr + offset); + return (curr + offset) & 0x0fffffff; } -int32_t bt_syn_get_offset_ticks(uint16_t conhdl) -{ - int32_t offset; +int32_t bt_syn_get_offset_ticks(uint16_t conhdl) { + int32_t offset; - if (btdrv_is_link_index_valid(btdrv_conhdl_to_linkid(conhdl))) - offset = btdrv_syn_get_offset_ticks(btdrv_conhdl_to_linkid(conhdl)); - else - offset = 0; -// BT_DRV_TRACE(4,"[%s] curr(%d) + offset(%d) = %d", __func__, curr , offset,curr + offset); - return offset; + if (btdrv_is_link_index_valid(btdrv_conhdl_to_linkid(conhdl))) + offset = btdrv_syn_get_offset_ticks(btdrv_conhdl_to_linkid(conhdl)); + else + offset = 0; + // BT_DRV_TRACE(4,"[%s] curr(%d) + offset(%d) = %d", __func__, curr , + // offset,curr + offset); + return offset; } -void bt_syn_trig_checker(uint16_t conhdl) -{ - int32_t clock_offset; - uint16_t bit_offset; - bt_drv_reg_op_piconet_clk_offset_get(conhdl, &clock_offset, &bit_offset); +void bt_syn_trig_checker(uint16_t conhdl) { + int32_t clock_offset; + uint16_t bit_offset; + bt_drv_reg_op_piconet_clk_offset_get(conhdl, &clock_offset, &bit_offset); - BT_DRV_TRACE(3,"bt_syn_set_tg_tick checker d0220498=0x%08x d02204a4=0x%08x d02201f0=0x%08x", BTDIGITAL_REG(0xd0220498), BTDIGITAL_REG(0xd02204a4), BTDIGITAL_REG(0xd02201f0)); - BT_DRV_TRACE(3,"bt_syn_set_tg_tick checker curr_ticks:0x%08x bitoffset=0x%04x rxbit=0x%04x", btdrv_syn_get_curr_ticks(), - BTDIGITAL_REG(EM_BT_BITOFF_ADDR+(conhdl - 0x80)*BT_EM_SIZE) & 0x3ff, - BTDIGITAL_REG(EM_BT_RXBIT_ADDR+(conhdl - 0x80)*BT_EM_SIZE) & 0x3ff); - BT_DRV_TRACE(2,"bt_syn_set_tg_tick checker clock_offset:0x%08x bit_offset=0x%04x", clock_offset, bit_offset); + BT_DRV_TRACE(3, + "bt_syn_set_tg_tick checker d0220498=0x%08x d02204a4=0x%08x " + "d02201f0=0x%08x", + BTDIGITAL_REG(0xd0220498), BTDIGITAL_REG(0xd02204a4), + BTDIGITAL_REG(0xd02201f0)); + BT_DRV_TRACE( + 3, + "bt_syn_set_tg_tick checker curr_ticks:0x%08x bitoffset=0x%04x " + "rxbit=0x%04x", + btdrv_syn_get_curr_ticks(), + BTDIGITAL_REG(EM_BT_BITOFF_ADDR + (conhdl - 0x80) * BT_EM_SIZE) & 0x3ff, + BTDIGITAL_REG(EM_BT_RXBIT_ADDR + (conhdl - 0x80) * BT_EM_SIZE) & 0x3ff); + BT_DRV_TRACE( + 2, "bt_syn_set_tg_tick checker clock_offset:0x%08x bit_offset=0x%04x", + clock_offset, bit_offset); } // Can be used by master or slave // Ref: Master bt clk -void bt_syn_set_tg_ticks(uint32_t val,uint16_t conhdl, uint8_t mode) -{ - int32_t offset; +void bt_syn_set_tg_ticks(uint32_t val, uint16_t conhdl, uint8_t mode) { + int32_t offset; - if (btdrv_is_link_index_valid(btdrv_conhdl_to_linkid(conhdl))) - offset = btdrv_syn_get_offset_ticks(btdrv_conhdl_to_linkid(conhdl)); - else - offset = 0; + if (btdrv_is_link_index_valid(btdrv_conhdl_to_linkid(conhdl))) + offset = btdrv_syn_get_offset_ticks(btdrv_conhdl_to_linkid(conhdl)); + else + offset = 0; - if(conhdl==0x80) - { - BTDIGITAL_REG(0xd0220498)=(BTDIGITAL_REG(0xd0220498)&0xfffffff0)|0x1; - } - else if(conhdl==0x81) - { - BTDIGITAL_REG(0xd0220498)=(BTDIGITAL_REG(0xd0220498)&0xfffffff0)|0x2; - } - else if(conhdl==0x82) - { - BTDIGITAL_REG(0xd0220498)=(BTDIGITAL_REG(0xd0220498)&0xfffffff0)|0x3; - } + if (conhdl == 0x80) { + BTDIGITAL_REG(0xd0220498) = (BTDIGITAL_REG(0xd0220498) & 0xfffffff0) | 0x1; + } else if (conhdl == 0x81) { + BTDIGITAL_REG(0xd0220498) = (BTDIGITAL_REG(0xd0220498) & 0xfffffff0) | 0x2; + } else if (conhdl == 0x82) { + BTDIGITAL_REG(0xd0220498) = (BTDIGITAL_REG(0xd0220498) & 0xfffffff0) | 0x3; + } - if ((mode == BT_TRIG_MASTER_ROLE) && (offset !=0)) - BT_DRV_TRACE(0,"ERROR OFFSET !!"); + if ((mode == BT_TRIG_MASTER_ROLE) && (offset != 0)) + BT_DRV_TRACE(0, "ERROR OFFSET !!"); - val = val>>1; - val = val<<1; - val += 1; + val = val >> 1; + val = val << 1; + val += 1; - BT_DRV_TRACE(4,"bt_syn_set_tg_ticks val:%d num:%d mode:%d conhdl:%02x", val, val - offset, mode, conhdl); - btdrv_syn_set_tg_ticks(val - offset, mode); - bt_syn_trig_checker(conhdl); + BT_DRV_TRACE(4, "bt_syn_set_tg_ticks val:%d num:%d mode:%d conhdl:%02x", val, + val - offset, mode, conhdl); + btdrv_syn_set_tg_ticks(val - offset, mode); + bt_syn_trig_checker(conhdl); } -void btdrv_enable_playback_triggler(uint8_t triggle_mode) -{ - if(triggle_mode == ACL_TRIGGLE_MODE) - { - //clear SCO trigger - BTDIGITAL_REG(0xd02201f0) &= (~0x60000000); - //set ACL trigger - BTDIGITAL_REG(0xd02201f0) |= 0x20000000; - } - else if(triggle_mode == SCO_TRIGGLE_MODE) - { - //clear ACL trigger - BTDIGITAL_REG(0xd02201f0) &= (~0x60000000); - //set SCO trigger - BTDIGITAL_REG(0xd02201f0) |= 0x40000000; - } -} - -void btdrv_disable_playback_triggler(void) -{ - //clear ACL and SOC trigger +void btdrv_enable_playback_triggler(uint8_t triggle_mode) { + if (triggle_mode == ACL_TRIGGLE_MODE) { + // clear SCO trigger BTDIGITAL_REG(0xd02201f0) &= (~0x60000000); + // set ACL trigger + BTDIGITAL_REG(0xd02201f0) |= 0x20000000; + } else if (triggle_mode == SCO_TRIGGLE_MODE) { + // clear ACL trigger + BTDIGITAL_REG(0xd02201f0) &= (~0x60000000); + // set SCO trigger + BTDIGITAL_REG(0xd02201f0) |= 0x40000000; + } +} + +void btdrv_disable_playback_triggler(void) { + // clear ACL and SOC trigger + BTDIGITAL_REG(0xd02201f0) &= (~0x60000000); } /* @@ -1192,200 +1048,167 @@ bit28 1:master 0:slave // local mode = 0 */ -void btdrv_set_tws_role_triggler(uint8_t tws_mode) -{ - BT_DRV_TRACE(1,"btdrv_set_tws_role_triggler tws_mode:%d", tws_mode); - - if(tws_mode == BT_TRIG_MASTER_ROLE) - { - BTDIGITAL_REG(0xd02201f0) |= 0x10000000; - } - else if(tws_mode == BT_TRIG_SLAVE_ROLE) - { - BTDIGITAL_REG(0xd02201f0) &= (~0x10000000); - } +void btdrv_set_tws_role_triggler(uint8_t tws_mode) { + BT_DRV_TRACE(1, "btdrv_set_tws_role_triggler tws_mode:%d", tws_mode); + if (tws_mode == BT_TRIG_MASTER_ROLE) { + BTDIGITAL_REG(0xd02201f0) |= 0x10000000; + } else if (tws_mode == BT_TRIG_SLAVE_ROLE) { + BTDIGITAL_REG(0xd02201f0) &= (~0x10000000); + } } -void btdrv_set_bt_pcm_triggler_en(uint8_t en) -{ - if(en) - { - BTDIGITAL_REG(0xd022046c) &= (~0x1); - } - else - { - BTDIGITAL_REG(0xd022046c) |= 0x1; - } +void btdrv_set_bt_pcm_triggler_en(uint8_t en) { + if (en) { + BTDIGITAL_REG(0xd022046c) &= (~0x1); + } else { + BTDIGITAL_REG(0xd022046c) |= 0x1; + } } -void btdrv_set_bt_pcm_triggler_delay(uint8_t delay) -{ - if(delay > 0x3f) - { - BT_DRV_TRACE(0,"delay is error value"); - return; - } - BT_DRV_TRACE(1,"0XD022045c=%x",BTDIGITAL_REG(0xd022045c)); - BTDIGITAL_REG(0xd022045c) &= ~0x7f; - BTDIGITAL_REG(0xd022045c) |= (delay); - BT_DRV_TRACE(1,"exit :0XD022045c=%x",BTDIGITAL_REG(0xd022045c)); +void btdrv_set_bt_pcm_triggler_delay(uint8_t delay) { + if (delay > 0x3f) { + BT_DRV_TRACE(0, "delay is error value"); + return; + } + BT_DRV_TRACE(1, "0XD022045c=%x", BTDIGITAL_REG(0xd022045c)); + BTDIGITAL_REG(0xd022045c) &= ~0x7f; + BTDIGITAL_REG(0xd022045c) |= (delay); + BT_DRV_TRACE(1, "exit :0XD022045c=%x", BTDIGITAL_REG(0xd022045c)); } - -void btdrv_set_bt_pcm_en(uint8_t en) -{ - if(en) - BTDIGITAL_REG(0xd02201b0) |= 1; - else - BTDIGITAL_REG(0xd02201b0) &= (~1); +void btdrv_set_bt_pcm_en(uint8_t en) { + if (en) + BTDIGITAL_REG(0xd02201b0) |= 1; + else + BTDIGITAL_REG(0xd02201b0) &= (~1); } - -void btdrv_set_bt_pcm_triggler_delay_reset(uint8_t delay) -{ - if(delay > 0x3f) - { - BT_DRV_TRACE(0,"delay is error value"); - return; - } - BT_DRV_TRACE(1,"0XD022045c=%x",BTDIGITAL_REG(0xd0224024)); - BTDIGITAL_REG(0XD022045c) &= ~0x3f; - BTDIGITAL_REG(0XD022045c) |= delay|1; - // BTDIGITAL_REG(0xd0224024) |= 6; //bypass sco trig - BT_DRV_TRACE(1,"exit :0xd022045c=%x",BTDIGITAL_REG(0xd022045c)); +void btdrv_set_bt_pcm_triggler_delay_reset(uint8_t delay) { + if (delay > 0x3f) { + BT_DRV_TRACE(0, "delay is error value"); + return; + } + BT_DRV_TRACE(1, "0XD022045c=%x", BTDIGITAL_REG(0xd0224024)); + BTDIGITAL_REG(0XD022045c) &= ~0x3f; + BTDIGITAL_REG(0XD022045c) |= delay | 1; + // BTDIGITAL_REG(0xd0224024) |= 6; //bypass sco trig + BT_DRV_TRACE(1, "exit :0xd022045c=%x", BTDIGITAL_REG(0xd022045c)); } -void btdrv_set_pcm_data_ignore_crc(void) -{ +void btdrv_set_pcm_data_ignore_crc(void) { - BTDIGITAL_REG(0xD0220144) &= ~0x800000; + BTDIGITAL_REG(0xD0220144) &= ~0x800000; } -//pealse use btdrv_is_link_index_valid() check link index whether valid -uint8_t btdrv_conhdl_to_linkid(uint16_t connect_hdl) -{ - //invalid hci handle,such as link disconnected - if(connect_hdl < HCI_HANDLE_MIN || connect_hdl > HCI_HANDLE_MAX) - { - TRACE(0, "ERROR Connect Handle=0x%x",connect_hdl); - return HCI_LINK_INDEX_INVALID; - } - else - { - return (connect_hdl - HCI_HANDLE_MIN); - } +// pealse use btdrv_is_link_index_valid() check link index whether valid +uint8_t btdrv_conhdl_to_linkid(uint16_t connect_hdl) { + // invalid hci handle,such as link disconnected + if (connect_hdl < HCI_HANDLE_MIN || connect_hdl > HCI_HANDLE_MAX) { + TRACE(0, "ERROR Connect Handle=0x%x", connect_hdl); + return HCI_LINK_INDEX_INVALID; + } else { + return (connect_hdl - HCI_HANDLE_MIN); + } } -void btdrv_linear_format_16bit_set(void) -{ - *(volatile uint32_t *)(0xd02201a0) |= 0x00300000; +void btdrv_linear_format_16bit_set(void) { + *(volatile uint32_t *)(0xd02201a0) |= 0x00300000; } -void btdrv_pcm_enable(void) -{ - *(volatile uint32_t *)(0xd02201b0) |= 0x01; //pcm enable +void btdrv_pcm_enable(void) { + *(volatile uint32_t *)(0xd02201b0) |= 0x01; // pcm enable } -void btdrv_pcm_disable(void) -{ - *(volatile uint32_t *)(0xd02201b0) &= 0xfffffffe; //pcm disable +void btdrv_pcm_disable(void) { + *(volatile uint32_t *)(0xd02201b0) &= 0xfffffffe; // pcm disable } // Trace tport -static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_tport[] = -{ - {HAL_IOMUX_PIN_P0_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}, +static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_tport[] = { + {HAL_IOMUX_PIN_P0_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}, }; -int btdrv_host_gpio_tport_open(void) -{ - uint32_t i; +int btdrv_host_gpio_tport_open(void) { + uint32_t i; - for (i=0; i=HAL_CHIP_METAL_ID_0) - { - BT_DRV_TRACE(0,"pcm fast mode\n"); - *(volatile uint32_t *)(0xd0220464) |= 1<<22;///pcm fast mode en bit22 - *(volatile uint32_t *)(0xd02201b8) = (*(volatile uint32_t *)(0xd02201b8)&0xFFFFFF00)|0x8;///pcm clk [8:0] - *(volatile uint32_t *)(0xd0220460) = (*(volatile uint32_t *)(0xd0220460)&0xFFFE03FF)|0x0000EC00;///sample num in one frame [16:10] - } +void btdrv_open_pcm_fast_mode_enable(void) { + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_0) { + BT_DRV_TRACE(0, "pcm fast mode\n"); + *(volatile uint32_t *)(0xd0220464) |= 1 << 22; /// pcm fast mode en bit22 + *(volatile uint32_t *)(0xd02201b8) = + (*(volatile uint32_t *)(0xd02201b8) & 0xFFFFFF00) | + 0x8; /// pcm clk [8:0] + *(volatile uint32_t *)(0xd0220460) = + (*(volatile uint32_t *)(0xd0220460) & 0xFFFE03FF) | + 0x0000EC00; /// sample num in one frame [16:10] + } } -void btdrv_open_pcm_fast_mode_disable(void) -{ - if(hal_get_chip_metal_id()>=HAL_CHIP_METAL_ID_0) - { - BT_DRV_TRACE(0,"pcm fast mode disable\n"); - *(volatile uint32_t *)(0xd0220464) = (*(volatile uint32_t *)(0xd0220464)&0xFFBFFFFF);///disable pcm fast mode - *(volatile uint32_t *)(0xd02201b8) = (*(volatile uint32_t *)(0xd02201b8)&0xFFFFFF00); - } +void btdrv_open_pcm_fast_mode_disable(void) { + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_0) { + BT_DRV_TRACE(0, "pcm fast mode disable\n"); + *(volatile uint32_t *)(0xd0220464) = (*(volatile uint32_t *)(0xd0220464) & + 0xFFBFFFFF); /// disable pcm fast mode + *(volatile uint32_t *)(0xd02201b8) = + (*(volatile uint32_t *)(0xd02201b8) & 0xFFFFFF00); + } } #endif #if defined(CVSD_BYPASS) -void btdrv_cvsd_bypass_enable(uint8_t is_msbc) -{ - BTDIGITAL_REG(0xD0220144) &= ~0xffff; +void btdrv_cvsd_bypass_enable(uint8_t is_msbc) { + BTDIGITAL_REG(0xD0220144) &= ~0xffff; - BTDIGITAL_REG(0xD0220144) |= 0x5555; - // BTDIGITAL_REG(0xD02201E8) |= 0x04000000; //test sequecy - BTDIGITAL_REG(0xD02201A0) &= ~(1<<7); //soft cvsd - //BTDIGITAL_REG(0xD02201b8) |= (1<<31); //revert clk + BTDIGITAL_REG(0xD0220144) |= 0x5555; + // BTDIGITAL_REG(0xD02201E8) |= 0x04000000; //test sequecy + BTDIGITAL_REG(0xD02201A0) &= ~(1 << 7); // soft cvsd + // BTDIGITAL_REG(0xD02201b8) |= (1<<31); //revert clk } #endif -void btdrv_enable_rf_sw(int rx_on, int tx_on) -{ - hal_iomux_set_bt_rf_sw(rx_on, tx_on); - BTDIGITAL_REG(0xD0340000) = (BTDIGITAL_REG(0xD0340000) & ~(1<<24)); - BTDIGITAL_REG(0xD0220050) = (BTDIGITAL_REG(0xD0220050) & ~0xFF) | 0xA6; +void btdrv_enable_rf_sw(int rx_on, int tx_on) { + hal_iomux_set_bt_rf_sw(rx_on, tx_on); + BTDIGITAL_REG(0xD0340000) = (BTDIGITAL_REG(0xD0340000) & ~(1 << 24)); + BTDIGITAL_REG(0xD0220050) = (BTDIGITAL_REG(0xD0220050) & ~0xFF) | 0xA6; } - diff --git a/platform/drivers/bt/best2300p/bt_drv_calibration.cpp b/platform/drivers/bt/best2300p/bt_drv_calibration.cpp index f8f3ba7..9afb405 100644 --- a/platform/drivers/bt/best2300p/bt_drv_calibration.cpp +++ b/platform/drivers/bt/best2300p/bt_drv_calibration.cpp @@ -15,33 +15,31 @@ ****************************************************************************/ #ifdef RTOS -#include "plat_types.h" #include "bt_drv.h" #include "bt_drv_2300p_internal.h" -#include "hal_intersys.h" -#include "hal_i2c.h" -#include "hal_uart.h" -#include "hal_iomux.h" -#include "hal_chipid.h" -#include "string.h" #include "bt_drv_interface.h" +#include "hal_chipid.h" +#include "hal_i2c.h" +#include "hal_intersys.h" +#include "hal_iomux.h" +#include "hal_uart.h" +#include "plat_types.h" +#include "string.h" -struct dbg_nonsig_tester_result_tag -{ - uint16_t pkt_counters; - uint16_t head_errors; - uint16_t payload_errors; - int16_t avg_estsw; - int16_t avg_esttpl; - uint32_t payload_bit_errors; +struct dbg_nonsig_tester_result_tag { + uint16_t pkt_counters; + uint16_t head_errors; + uint16_t payload_errors; + int16_t avg_estsw; + int16_t avg_esttpl; + uint32_t payload_bit_errors; }; -struct bt_drv_capval_calc_t -{ - int16_t estsw_a; - int16_t estsw_b; - uint8_t cdac_a; - uint8_t cdac_b; +struct bt_drv_capval_calc_t { + int16_t estsw_a; + int16_t estsw_b; + uint8_t cdac_a; + uint8_t cdac_b; }; static struct dbg_nonsig_tester_result_tag nonsig_tester_result; @@ -51,499 +49,479 @@ static osThreadId calib_thread_tid = NULL; static bool calib_thread_tid = false; #endif static bool calib_running = false; -static struct bt_drv_capval_calc_t capval_calc ={ - .estsw_a = 0, - .estsw_b = 0, - .cdac_a = 0, - .cdac_b = 0, - }; +static struct bt_drv_capval_calc_t capval_calc = { + .estsw_a = 0, + .estsw_b = 0, + .cdac_a = 0, + .cdac_b = 0, +}; -#define bt_drv_calib_capval_calc_reset() do{ \ - memset(&capval_calc, 0, sizeof(capval_calc)); \ - }while(0) +#define bt_drv_calib_capval_calc_reset() \ + do { \ + memset(&capval_calc, 0, sizeof(capval_calc)); \ + } while (0) #ifdef RTOS -#define BT_DRV_MUTUX_WAIT(evt) do{ \ - if (calib_thread_tid){ \ - osSignalClear(calib_thread_tid, 0x4); \ - evt = osSignalWait(0x4, 4000); \ - }\ - }while(0) +#define BT_DRV_MUTUX_WAIT(evt) \ + do { \ + if (calib_thread_tid) { \ + osSignalClear(calib_thread_tid, 0x4); \ + evt = osSignalWait(0x4, 4000); \ + } \ + } while (0) -#define BT_DRV_MUTUX_SET() do{ \ - if (calib_thread_tid){ \ - osSignalSet(calib_thread_tid, 0x4); \ - } \ - }while(0) +#define BT_DRV_MUTUX_SET() \ + do { \ + if (calib_thread_tid) { \ + osSignalSet(calib_thread_tid, 0x4); \ + } \ + } while (0) #else -typedef enum { - osOK = 0, ///< function completed; no error or event occurred. - osEventSignal = 0x08, ///< function completed; signal event occurred. - osErrorOS = 0xFF, ///< unspecified RTOS error: run-time error but no other error message fits. - os_status_reserved = 0x7FFFFFFF ///< prevent from enum down-size compiler optimization. +typedef enum { + osOK = 0, ///< function completed; no error or event occurred. + osEventSignal = 0x08, ///< function completed; signal event occurred. + osErrorOS = 0xFF, ///< unspecified RTOS error: run-time error but no other + ///< error message fits. + os_status_reserved = + 0x7FFFFFFF ///< prevent from enum down-size compiler optimization. } osStatus; -typedef struct { - osStatus status; ///< status code: event or error information +typedef struct { + osStatus status; ///< status code: event or error information } osEvent; -#define BT_DRV_MUTUX_WAIT(evt) do{ \ - uint8_t i=16; \ - evt.status = osErrorOS; \ - do{ \ - if (calib_thread_tid){ \ - calib_thread_tid = false; \ - evt.status = osEventSignal; \ - break; \ - }else{ \ - btdrv_delay(500); \ - } \ - }while(i--);\ - }while(0) +#define BT_DRV_MUTUX_WAIT(evt) \ + do { \ + uint8_t i = 16; \ + evt.status = osErrorOS; \ + do { \ + if (calib_thread_tid) { \ + calib_thread_tid = false; \ + evt.status = osEventSignal; \ + break; \ + } else { \ + btdrv_delay(500); \ + } \ + } while (i--); \ + } while (0) -#define BT_DRV_MUTUX_SET() do{ \ - calib_thread_tid = true; \ - }while(0) +#define BT_DRV_MUTUX_SET() \ + do { \ + calib_thread_tid = true; \ + } while (0) #endif #define BT_DRV_CALIB_BTANA_CAPVAL_CALC_BOTTOM (50) #define BT_DRV_CALIB_BTANA_CAPVAL_CALC_TOP (200) #define BT_DRV_CALIB_BTANA_CAPVAL_MIN (20) -#define BT_DRV_CALIB_BTANA_CAPVAL_MAX (255-BT_DRV_CALIB_BTANA_CAPVAL_MIN) +#define BT_DRV_CALIB_BTANA_CAPVAL_MAX (255 - BT_DRV_CALIB_BTANA_CAPVAL_MIN) #define BT_DRV_CALIB_BTANA_CAPVAL_STEP_HZ (200) #define BT_DRV_CALIB_RETRY_CNT (10) #define BT_DRV_CALIB_SKIP_RESULT_CNT (2) #define BT_DRV_CALIB_MDM_FREQ_REFERENCE (-12) #define BT_DRV_CALIB_MDM_FREQ_STEP_HZ (500) -#define BT_DRV_CALIB_MDM_BIT_TO_FREQ(n, step) ((n)*(step)) -#define BT_DRV_CALIB_MDM_FREQ_TO_BIT(n, step) ((uint32_t)n/step) +#define BT_DRV_CALIB_MDM_BIT_TO_FREQ(n, step) ((n) * (step)) +#define BT_DRV_CALIB_MDM_FREQ_TO_BIT(n, step) ((uint32_t)n / step) static int16_t calib_mdm_freq_reference = BT_DRV_CALIB_MDM_FREQ_REFERENCE; enum HAL_IOMUX_ISPI_ACCESS_T ispi_access; static void bt_drv_rfcal_timer_handler(void const *param); -osTimerDef (BT_DRV_RFCAL_TIMER, bt_drv_rfcal_timer_handler); +osTimerDef(BT_DRV_RFCAL_TIMER, bt_drv_rfcal_timer_handler); static osTimerId bt_drv_rfcal_timer = NULL; -static void bt_drv_calib_stop_timer(void) -{ - if (NULL != bt_drv_rfcal_timer) - { - osTimerStop(bt_drv_rfcal_timer); - } -} - -static void bt_drv_rfcal_timer_handler(void const *start) -{ - static int start_nonsig_rx = 0; - - if (NULL == bt_drv_rfcal_timer) - { - bt_drv_rfcal_timer = osTimerCreate(osTimer(BT_DRV_RFCAL_TIMER), osTimerOnce, NULL); - } - +static void bt_drv_calib_stop_timer(void) { + if (NULL != bt_drv_rfcal_timer) { osTimerStop(bt_drv_rfcal_timer); - - if (start_nonsig_rx || start) { - start_nonsig_rx = 0; - - const uint8_t hci_cmd_hci_reset[] = {0x01, 0x03, 0x0c, 0x00}; - const uint8_t calib_hci_cmd_nonsig_rx_2dh1_pn9_t5[] = { - 0x01, 0x87, 0xfc, 0x1c, 0x01, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x01, 0x01, 0x04, 0x00, 0x36, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff - }; - - /* start nonsig rx again */ - btdrv_SendData(hci_cmd_hci_reset, sizeof(hci_cmd_hci_reset)); - btdrv_delay(2); - btdrv_SendData(calib_hci_cmd_nonsig_rx_2dh1_pn9_t5, sizeof(calib_hci_cmd_nonsig_rx_2dh1_pn9_t5)); - btdrv_delay(100); - - BT_DRV_TRACE(0,"bt_drv_cal start nonsig rx\n"); - - BTDIGITAL_REG(0xd0210040) &= 0xff; - BTDIGITAL_REG(0xd0210040) |= 0x55; - - osTimerStart(bt_drv_rfcal_timer, 1500); - } else { - start_nonsig_rx = 1; - - const uint8_t stop_nonsig_rx_cmd[] = { - 0x01, 0x87, 0xfc, 0x1c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; - - /* stop nonsig rx and let report cal result */ - btdrv_SendData(stop_nonsig_rx_cmd, sizeof(stop_nonsig_rx_cmd)); - btdrv_delay(2); - - BT_DRV_TRACE(0,"bt_drv_cal stop nonsig rx\n"); - - osTimerStart(bt_drv_rfcal_timer, 300); - } + } } +static void bt_drv_rfcal_timer_handler(void const *start) { + static int start_nonsig_rx = 0; -void bt_drv_start_calib(void) -{ - if (hal_get_chip_metal_id() < HAL_CHIP_METAL_ID_1) - { - const uint8_t calib_hci_cmd_nonsig_rx_2dh1_pn9[] = { - 0x01, 0x87, 0xfc, 0x14, 0x01, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x01, 0x01, 0x04, 0x00, 0x36, 0x00 - }; + if (NULL == bt_drv_rfcal_timer) { + bt_drv_rfcal_timer = + osTimerCreate(osTimer(BT_DRV_RFCAL_TIMER), osTimerOnce, NULL); + } - if (!calib_running){ - btdrv_SendData(calib_hci_cmd_nonsig_rx_2dh1_pn9, sizeof(calib_hci_cmd_nonsig_rx_2dh1_pn9)); - btdrv_delay(500); - BTDIGITAL_REG(0xd0210040) &= 0xff; - BTDIGITAL_REG(0xd0210040) |= 0x55; - calib_running = true; - } - } - else - { - bt_drv_rfcal_timer_handler((void*)1); - calib_running = true; - } + osTimerStop(bt_drv_rfcal_timer); + + if (start_nonsig_rx || start) { + start_nonsig_rx = 0; + + const uint8_t hci_cmd_hci_reset[] = {0x01, 0x03, 0x0c, 0x00}; + const uint8_t calib_hci_cmd_nonsig_rx_2dh1_pn9_t5[] = { + 0x01, 0x87, 0xfc, 0x1c, 0x01, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x01, 0x01, 0x04, 0x00, + 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff}; + + /* start nonsig rx again */ + btdrv_SendData(hci_cmd_hci_reset, sizeof(hci_cmd_hci_reset)); + btdrv_delay(2); + btdrv_SendData(calib_hci_cmd_nonsig_rx_2dh1_pn9_t5, + sizeof(calib_hci_cmd_nonsig_rx_2dh1_pn9_t5)); + btdrv_delay(100); + + BT_DRV_TRACE(0, "bt_drv_cal start nonsig rx\n"); + + BTDIGITAL_REG(0xd0210040) &= 0xff; + BTDIGITAL_REG(0xd0210040) |= 0x55; + + osTimerStart(bt_drv_rfcal_timer, 1500); + } else { + start_nonsig_rx = 1; + + const uint8_t stop_nonsig_rx_cmd[] = { + 0x01, 0x87, 0xfc, 0x1c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + /* stop nonsig rx and let report cal result */ + btdrv_SendData(stop_nonsig_rx_cmd, sizeof(stop_nonsig_rx_cmd)); + btdrv_delay(2); + + BT_DRV_TRACE(0, "bt_drv_cal stop nonsig rx\n"); + + osTimerStart(bt_drv_rfcal_timer, 300); + } } -void bt_drv_stop_calib(void) -{ - if (calib_running){ - btdrv_hci_reset(); - btdrv_delay(200); - calib_running = false; - } +void bt_drv_start_calib(void) { + if (hal_get_chip_metal_id() < HAL_CHIP_METAL_ID_1) { + const uint8_t calib_hci_cmd_nonsig_rx_2dh1_pn9[] = { + 0x01, 0x87, 0xfc, 0x14, 0x01, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x01, 0x01, 0x04, 0x00, 0x36, 0x00}; - if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) - { - bt_drv_calib_stop_timer(); + if (!calib_running) { + btdrv_SendData(calib_hci_cmd_nonsig_rx_2dh1_pn9, + sizeof(calib_hci_cmd_nonsig_rx_2dh1_pn9)); + btdrv_delay(500); + BTDIGITAL_REG(0xd0210040) &= 0xff; + BTDIGITAL_REG(0xd0210040) |= 0x55; + calib_running = true; } + } else { + bt_drv_rfcal_timer_handler((void *)1); + calib_running = true; + } +} + +void bt_drv_stop_calib(void) { + if (calib_running) { + btdrv_hci_reset(); + btdrv_delay(200); + calib_running = false; + } + + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) { + bt_drv_calib_stop_timer(); + } } const uint8_t calib_hci_cmd_nonsig_tx_2dh1_pn9_t0[] = { - 0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x01, 0x01, 0x04, 0x04, 0x36, 0x00 -}; + 0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x01, 0x01, 0x04, 0x04, 0x36, 0x00}; const uint8_t calib_hci_cmd_nonsig_tx_2dh1_pn9_t1[] = { - 0x01, 0x87, 0xfc, 0x1c, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x01, 0x01, 0x04, 0x04, 0x36, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff -}; + 0x01, 0x87, 0xfc, 0x1c, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x01, 0x01, 0x04, 0x04, + 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff}; -void bt_drv_check_calib(void) -{ - const uint8_t* calib_hci_cmd_nonsig_tx_2dh1_pn9 = NULL; - uint8_t len = 0; +void bt_drv_check_calib(void) { + const uint8_t *calib_hci_cmd_nonsig_tx_2dh1_pn9 = NULL; + uint8_t len = 0; - if (hal_get_chip_metal_id() < HAL_CHIP_METAL_ID_1) - { - calib_hci_cmd_nonsig_tx_2dh1_pn9 = calib_hci_cmd_nonsig_tx_2dh1_pn9_t0; - len = sizeof(calib_hci_cmd_nonsig_tx_2dh1_pn9_t0); - } - else - { - calib_hci_cmd_nonsig_tx_2dh1_pn9 = calib_hci_cmd_nonsig_tx_2dh1_pn9_t1; - len = sizeof(calib_hci_cmd_nonsig_tx_2dh1_pn9_t1); - } + if (hal_get_chip_metal_id() < HAL_CHIP_METAL_ID_1) { + calib_hci_cmd_nonsig_tx_2dh1_pn9 = calib_hci_cmd_nonsig_tx_2dh1_pn9_t0; + len = sizeof(calib_hci_cmd_nonsig_tx_2dh1_pn9_t0); + } else { + calib_hci_cmd_nonsig_tx_2dh1_pn9 = calib_hci_cmd_nonsig_tx_2dh1_pn9_t1; + len = sizeof(calib_hci_cmd_nonsig_tx_2dh1_pn9_t1); + } - btdrv_SendData(calib_hci_cmd_nonsig_tx_2dh1_pn9, len); - btdrv_delay(3000); - BTDIGITAL_REG(0xd0210040) &= 0xff; - BTDIGITAL_REG(0xd0210040) |= 39; + btdrv_SendData(calib_hci_cmd_nonsig_tx_2dh1_pn9, len); + btdrv_delay(3000); + BTDIGITAL_REG(0xd0210040) &= 0xff; + BTDIGITAL_REG(0xd0210040) |= 39; } -static bool bt_drv_calib_capval_calc_run(uint16_t *capval_step_hz, int16_t estsw, uint8_t cdac) -{ - bool nRet = false; - int16_t estsw_diff; - int16_t cdac_diff; +static bool bt_drv_calib_capval_calc_run(uint16_t *capval_step_hz, + int16_t estsw, uint8_t cdac) { + bool nRet = false; + int16_t estsw_diff; + int16_t cdac_diff; - if (!capval_calc.estsw_a && - !capval_calc.estsw_b){ - capval_calc.estsw_a = estsw; - }else if (capval_calc.estsw_a && - !capval_calc.estsw_b){ - capval_calc.estsw_b = estsw; - } + if (!capval_calc.estsw_a && !capval_calc.estsw_b) { + capval_calc.estsw_a = estsw; + } else if (capval_calc.estsw_a && !capval_calc.estsw_b) { + capval_calc.estsw_b = estsw; + } - if (!capval_calc.cdac_a && - !capval_calc.cdac_b){ - capval_calc.cdac_a = cdac; - }else if (capval_calc.cdac_a && - !capval_calc.cdac_b){ - capval_calc.cdac_b = cdac; - } + if (!capval_calc.cdac_a && !capval_calc.cdac_b) { + capval_calc.cdac_a = cdac; + } else if (capval_calc.cdac_a && !capval_calc.cdac_b) { + capval_calc.cdac_b = cdac; + } - if (capval_calc.estsw_a && - capval_calc.estsw_b && - capval_calc.cdac_a && - capval_calc.cdac_b){ + if (capval_calc.estsw_a && capval_calc.estsw_b && capval_calc.cdac_a && + capval_calc.cdac_b) { - estsw_diff = ABS(capval_calc.estsw_b - capval_calc.estsw_a); - cdac_diff = ABS((int16_t)(capval_calc.cdac_b) - (int16_t)(capval_calc.cdac_a)); - *capval_step_hz = estsw_diff*BT_DRV_CALIB_MDM_FREQ_STEP_HZ/cdac_diff; - BT_DRV_TRACE(7,"%d/%d %d/%d estsw_diff:%d cdac_diff:%d capval_step_hz:%d", - capval_calc.estsw_a, - capval_calc.estsw_b, - capval_calc.cdac_a, - capval_calc.cdac_b, - estsw_diff, - cdac_diff, - *capval_step_hz); - nRet = true; - } - return nRet; + estsw_diff = ABS(capval_calc.estsw_b - capval_calc.estsw_a); + cdac_diff = + ABS((int16_t)(capval_calc.cdac_b) - (int16_t)(capval_calc.cdac_a)); + *capval_step_hz = estsw_diff * BT_DRV_CALIB_MDM_FREQ_STEP_HZ / cdac_diff; + BT_DRV_TRACE(7, "%d/%d %d/%d estsw_diff:%d cdac_diff:%d capval_step_hz:%d", + capval_calc.estsw_a, capval_calc.estsw_b, capval_calc.cdac_a, + capval_calc.cdac_b, estsw_diff, cdac_diff, *capval_step_hz); + nRet = true; + } + return nRet; } -void bt_drv_calib_rxonly_porc(void) -{ - osEvent evt; +void bt_drv_calib_rxonly_porc(void) { + osEvent evt; - evt.status = os_status_reserved; - /*[set tmx] */ - btdrv_write_rf_reg(0xb0,0x0f00); /* turn off tmx */ + evt.status = os_status_reserved; + /*[set tmx] */ + btdrv_write_rf_reg(0xb0, 0x0f00); /* turn off tmx */ - bt_drv_start_calib(); + bt_drv_start_calib(); + while (1) { + BT_DRV_MUTUX_WAIT(evt); + if (evt.status != osEventSignal) { + break; + } + btdrv_delay(10); + BT_DRV_TRACE( + 7, "result cnt:%d head:%d payload:%d estsw:%d esttpl:%d bit:%d est:%d", + nonsig_tester_result.pkt_counters, nonsig_tester_result.head_errors, + nonsig_tester_result.payload_errors, nonsig_tester_result.avg_estsw, + nonsig_tester_result.avg_esttpl, + nonsig_tester_result.payload_bit_errors, + nonsig_tester_result.avg_estsw + nonsig_tester_result.avg_esttpl); + }; - while(1){ - BT_DRV_MUTUX_WAIT(evt); - if(evt.status != osEventSignal){ - break; - } - btdrv_delay(10); - BT_DRV_TRACE(7,"result cnt:%d head:%d payload:%d estsw:%d esttpl:%d bit:%d est:%d", nonsig_tester_result.pkt_counters, - nonsig_tester_result.head_errors, - nonsig_tester_result.payload_errors, - nonsig_tester_result.avg_estsw, - nonsig_tester_result.avg_esttpl, - nonsig_tester_result.payload_bit_errors, - nonsig_tester_result.avg_estsw+nonsig_tester_result.avg_esttpl); - - - - }; - - bt_drv_stop_calib(); + bt_drv_stop_calib(); } -int bt_drv_calib_result_porc(uint32_t *capval) -{ - osEvent evt; +int bt_drv_calib_result_porc(uint32_t *capval) { + osEvent evt; - uint16_t read_val = 0; - uint8_t cdac = 0; - uint8_t cnt = 0; - uint8_t skip_cnt = 0; - int diff = 0; - int est = 0; - uint8_t next_step = 0; - uint16_t capval_step_hz = BT_DRV_CALIB_BTANA_CAPVAL_STEP_HZ; - int nRet = -1; - int chk_flag = 0; - bool need_capval_calc = true; - evt.status = os_status_reserved; + uint16_t read_val = 0; + uint8_t cdac = 0; + uint8_t cnt = 0; + uint8_t skip_cnt = 0; + int diff = 0; + int est = 0; + uint8_t next_step = 0; + uint16_t capval_step_hz = BT_DRV_CALIB_BTANA_CAPVAL_STEP_HZ; + int nRet = -1; + int chk_flag = 0; + bool need_capval_calc = true; + evt.status = os_status_reserved; - /*[set to capval_min] */ - btdrv_read_rf_reg(0xE9, &read_val); - cdac = BT_DRV_CALIB_BTANA_CAPVAL_CALC_BOTTOM; - read_val = (read_val & 0xff00)|(cdac);; - btdrv_write_rf_reg(0xE9,read_val); + /*[set to capval_min] */ + btdrv_read_rf_reg(0xE9, &read_val); + cdac = BT_DRV_CALIB_BTANA_CAPVAL_CALC_BOTTOM; + read_val = (read_val & 0xff00) | (cdac); + ; + btdrv_write_rf_reg(0xE9, read_val); - /*[set tmx] */ - btdrv_write_rf_reg(0xb0,0x0f00); /* turn off tmx */ + /*[set tmx] */ + btdrv_write_rf_reg(0xb0, 0x0f00); /* turn off tmx */ - bt_drv_calib_capval_calc_reset(); + bt_drv_calib_capval_calc_reset(); - bt_drv_start_calib(); + bt_drv_start_calib(); check_again: - BT_DRV_TRACE(0,"calib run !!!"); - do{ -calib_again: - BT_DRV_MUTUX_WAIT(evt); - if(evt.status != osEventSignal){ - nRet = -1; - BT_DRV_TRACE(1,"evt:%d", evt.status); - goto exit; - } - if (hal_get_chip_metal_id() < HAL_CHIP_METAL_ID_1) - { - BT_DRV_MUTUX_WAIT(evt); - if(evt.status != osEventSignal) - { - nRet = -1; - BT_DRV_TRACE(1,"evt:%d", evt.status); - goto exit; - } - BT_DRV_MUTUX_WAIT(evt); - if(evt.status != osEventSignal) - { - nRet = -1; - BT_DRV_TRACE(1,"evt:%d", evt.status); - goto exit; - } - } - BT_DRV_TRACE(7,"result cnt:%d head:%d payload:%d estsw:%d esttpl:%d bit:%d est:%d", nonsig_tester_result.pkt_counters, - nonsig_tester_result.head_errors, - nonsig_tester_result.payload_errors, - nonsig_tester_result.avg_estsw, - nonsig_tester_result.avg_esttpl, - nonsig_tester_result.payload_bit_errors, - nonsig_tester_result.avg_estsw+nonsig_tester_result.avg_esttpl); + BT_DRV_TRACE(0, "calib run !!!"); + do { + calib_again: + BT_DRV_MUTUX_WAIT(evt); + if (evt.status != osEventSignal) { + nRet = -1; + BT_DRV_TRACE(1, "evt:%d", evt.status); + goto exit; + } + if (hal_get_chip_metal_id() < HAL_CHIP_METAL_ID_1) { + BT_DRV_MUTUX_WAIT(evt); + if (evt.status != osEventSignal) { + nRet = -1; + BT_DRV_TRACE(1, "evt:%d", evt.status); + goto exit; + } + BT_DRV_MUTUX_WAIT(evt); + if (evt.status != osEventSignal) { + nRet = -1; + BT_DRV_TRACE(1, "evt:%d", evt.status); + goto exit; + } + } + BT_DRV_TRACE( + 7, "result cnt:%d head:%d payload:%d estsw:%d esttpl:%d bit:%d est:%d", + nonsig_tester_result.pkt_counters, nonsig_tester_result.head_errors, + nonsig_tester_result.payload_errors, nonsig_tester_result.avg_estsw, + nonsig_tester_result.avg_esttpl, + nonsig_tester_result.payload_bit_errors, + nonsig_tester_result.avg_estsw + nonsig_tester_result.avg_esttpl); + if (nonsig_tester_result.head_errors > 15) { + if (++skip_cnt > BT_DRV_CALIB_SKIP_RESULT_CNT) + break; + else + goto calib_again; + } + skip_cnt = 0; - if (nonsig_tester_result.head_errors>15){ - if (++skip_cnt>BT_DRV_CALIB_SKIP_RESULT_CNT) - break; - else - goto calib_again; - } - skip_cnt = 0; + btdrv_read_rf_reg(0xE9, &read_val); + cdac = read_val & 0x00ff; - btdrv_read_rf_reg(0xE9, &read_val); - cdac = read_val & 0x00ff; + est = nonsig_tester_result.avg_estsw; + diff = est - calib_mdm_freq_reference; - est = nonsig_tester_result.avg_estsw; - diff = est-calib_mdm_freq_reference; + if (need_capval_calc) { + if (bt_drv_calib_capval_calc_run(&capval_step_hz, est, cdac)) { + need_capval_calc = false; + } + if (cdac == BT_DRV_CALIB_BTANA_CAPVAL_CALC_BOTTOM) { + cdac = BT_DRV_CALIB_BTANA_CAPVAL_CALC_TOP; + read_val = (read_val & 0xff00) | (cdac); + btdrv_write_rf_reg(0xE9, read_val); + } + goto calib_again; + } - if (need_capval_calc){ - if (bt_drv_calib_capval_calc_run(&capval_step_hz, est, cdac)){ - need_capval_calc = false; - } - if (cdac == BT_DRV_CALIB_BTANA_CAPVAL_CALC_BOTTOM){ - cdac = BT_DRV_CALIB_BTANA_CAPVAL_CALC_TOP; - read_val = (read_val & 0xff00)|(cdac); - btdrv_write_rf_reg(0xE9,read_val); - } - goto calib_again; - } + if ((BT_DRV_CALIB_MDM_BIT_TO_FREQ(ABS(diff), + BT_DRV_CALIB_MDM_FREQ_STEP_HZ) < 1500) && + diff > 0) { + if (!chk_flag) { + chk_flag = 1; + cnt = 0; + next_step = 2; + goto check_again; + } else if (chk_flag && cnt > 4) { + break; + } + nRet = 0; + break; + } else if (next_step == 2) { - if ((BT_DRV_CALIB_MDM_BIT_TO_FREQ(ABS(diff), BT_DRV_CALIB_MDM_FREQ_STEP_HZ) < 1500) && diff>0){ - if (!chk_flag){ - chk_flag = 1; - cnt = 0; - next_step = 2; - goto check_again; - }else if(chk_flag && cnt>4){ - break; - } - nRet = 0; - break; - }else if (next_step == 2){ + } else if (BT_DRV_CALIB_MDM_BIT_TO_FREQ( + ABS(diff), BT_DRV_CALIB_MDM_FREQ_STEP_HZ) < 2500) { + next_step = 2; + } else { + next_step = BT_DRV_CALIB_MDM_BIT_TO_FREQ(ABS(diff), + BT_DRV_CALIB_MDM_FREQ_STEP_HZ) / + capval_step_hz; + if (next_step == 0) { + next_step = 2; + } + if (next_step > 200) { + next_step = 200; + } + } + BT_DRV_TRACE(4, "diff:%d read_val:%x cdac:%d next_step:%d", diff, read_val, + cdac, next_step); + if (est == calib_mdm_freq_reference) { + if (!chk_flag) { + chk_flag = 1; + cnt = 0; + next_step = 2; + goto check_again; + } else if (chk_flag && cnt > 4) { + break; + } + nRet = 0; + break; + } else if (est > calib_mdm_freq_reference) { + if (cdac < (BT_DRV_CALIB_BTANA_CAPVAL_MIN + next_step)) { + if (cdac == BT_DRV_CALIB_BTANA_CAPVAL_MIN) + break; + else + cdac = BT_DRV_CALIB_BTANA_CAPVAL_MIN; + } else { + cdac -= next_step; + } + read_val = (read_val & 0xff00) | (cdac); - }else if (BT_DRV_CALIB_MDM_BIT_TO_FREQ(ABS(diff), BT_DRV_CALIB_MDM_FREQ_STEP_HZ) < 2500){ - next_step = 2; - }else{ - next_step = BT_DRV_CALIB_MDM_BIT_TO_FREQ(ABS(diff), BT_DRV_CALIB_MDM_FREQ_STEP_HZ)/capval_step_hz; - if (next_step == 0){ - next_step = 2; - } - if (next_step>200){ - next_step = 200; - } - } - BT_DRV_TRACE(4,"diff:%d read_val:%x cdac:%d next_step:%d", diff,read_val, cdac, next_step); - if (est == calib_mdm_freq_reference){ - if (!chk_flag){ - chk_flag = 1; - cnt = 0; - next_step = 2; - goto check_again; - }else if(chk_flag && cnt>4){ - break; - } - nRet = 0; - break; - }else if (est > calib_mdm_freq_reference){ - if (cdac < (BT_DRV_CALIB_BTANA_CAPVAL_MIN+next_step)){ - if (cdac == BT_DRV_CALIB_BTANA_CAPVAL_MIN) - break; - else - cdac = BT_DRV_CALIB_BTANA_CAPVAL_MIN; - }else{ - cdac -= next_step; - } - read_val = (read_val & 0xff00)|(cdac); + BT_DRV_TRACE(2, "-----:%x cdac:%d", read_val, cdac); + } else if (est < calib_mdm_freq_reference) { + if (cdac > (BT_DRV_CALIB_BTANA_CAPVAL_MAX - next_step)) { + if (cdac == BT_DRV_CALIB_BTANA_CAPVAL_MAX) + break; + else + cdac = BT_DRV_CALIB_BTANA_CAPVAL_MAX; + } else { + cdac += next_step; + } + read_val = (read_val & 0xff00) | (cdac); - BT_DRV_TRACE(2,"-----:%x cdac:%d", read_val, cdac); - }else if (est < calib_mdm_freq_reference){ - if (cdac>(BT_DRV_CALIB_BTANA_CAPVAL_MAX-next_step)){ - if (cdac == BT_DRV_CALIB_BTANA_CAPVAL_MAX) - break; - else - cdac = BT_DRV_CALIB_BTANA_CAPVAL_MAX; - }else{ - cdac += next_step; - } - read_val = (read_val & 0xff00)|(cdac); + BT_DRV_TRACE(2, "+++++:%x cdac:%d", read_val, cdac); + } - BT_DRV_TRACE(2,"+++++:%x cdac:%d", read_val, cdac); - } - - btdrv_write_rf_reg(0xE9,read_val); - }while(cnt++pkt_counters != 0) - { - memcpy(&nonsig_tester_result, pResult, sizeof(nonsig_tester_result)); - BT_DRV_MUTUX_SET(); - } + // BT_DRV_TRACE(2,"%s len:%d", __func__, len); + BT_DRV_DUMP("%02x ", data, len); + if (0 == memcmp(data, nonsig_test_report, sizeof(nonsig_test_report))) { + // BT_DRV_TRACE(0,"dbg_nonsig_tester_result !!!!!"); + pResult = (struct dbg_nonsig_tester_result_tag *)(data + 7); + if (pResult->pkt_counters != 0) { + memcpy(&nonsig_tester_result, pResult, sizeof(nonsig_tester_result)); + BT_DRV_MUTUX_SET(); } - hal_intersys_start_recv(HAL_INTERSYS_ID_0); + } + hal_intersys_start_recv(HAL_INTERSYS_ID_0); - return len; + return len; } void btdrv_tx(const unsigned char *data, unsigned int len); -void bt_drv_calib_open(void) -{ - int ret = 0; - BT_DRV_TRACE(1,"%s", __func__); +void bt_drv_calib_open(void) { + int ret = 0; + BT_DRV_TRACE(1, "%s", __func__); #ifdef RTOS - if (calib_thread_tid == NULL){ - calib_thread_tid = osThreadGetId(); - } + if (calib_thread_tid == NULL) { + calib_thread_tid = osThreadGetId(); + } #endif - ispi_access = hal_iomux_ispi_access_enable(HAL_IOMUX_ISPI_MCU_RF); + ispi_access = hal_iomux_ispi_access_enable(HAL_IOMUX_ISPI_MCU_RF); - ret = hal_intersys_open(HAL_INTERSYS_ID_0, HAL_INTERSYS_MSG_HCI, bt_drv_calib_rx, btdrv_tx, false); + ret = hal_intersys_open(HAL_INTERSYS_ID_0, HAL_INTERSYS_MSG_HCI, + bt_drv_calib_rx, btdrv_tx, false); - if (ret) { - BT_DRV_TRACE(0,"Failed to open intersys"); - return; - } - hal_intersys_start_recv(HAL_INTERSYS_ID_0); + if (ret) { + BT_DRV_TRACE(0, "Failed to open intersys"); + return; + } + hal_intersys_start_recv(HAL_INTERSYS_ID_0); } -void bt_drv_calib_close(void) -{ - btdrv_hci_reset(); - btdrv_delay(200); - hal_intersys_close(HAL_INTERSYS_ID_0,HAL_INTERSYS_MSG_HCI); +void bt_drv_calib_close(void) { + btdrv_hci_reset(); + btdrv_delay(200); + hal_intersys_close(HAL_INTERSYS_ID_0, HAL_INTERSYS_MSG_HCI); } #endif diff --git a/platform/drivers/bt/best2300p/bt_drv_config.c b/platform/drivers/bt/best2300p/bt_drv_config.c index fc6a9f8..8ae8cea 100644 --- a/platform/drivers/bt/best2300p/bt_drv_config.c +++ b/platform/drivers/bt/best2300p/bt_drv_config.c @@ -13,37 +13,37 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "plat_types.h" -#include "tgt_hardware.h" -#include "hal_i2c.h" -#include "hal_uart.h" #include "bt_drv.h" -#include "hal_timer.h" -#include "hal_chipid.h" #include "bt_drv_2300p_internal.h" #include "bt_drv_interface.h" -#include "bt_drv_reg_op.h" #include "bt_drv_internal.h" -//typedef void (*btdrv_config_func_t)(uint8_t parlen, uint8_t *param); +#include "bt_drv_reg_op.h" +#include "hal_chipid.h" +#include "hal_i2c.h" +#include "hal_timer.h" +#include "hal_uart.h" +#include "plat_types.h" +#include "tgt_hardware.h" +#include +// typedef void (*btdrv_config_func_t)(uint8_t parlen, uint8_t *param); -extern void btdrv_send_cmd(uint16_t opcode,uint8_t cmdlen,const uint8_t *param); -extern void btdrv_write_memory(uint8_t wr_type,uint32_t address,const uint8_t *value,uint8_t length); +extern void btdrv_send_cmd(uint16_t opcode, uint8_t cmdlen, + const uint8_t *param); +extern void btdrv_write_memory(uint8_t wr_type, uint32_t address, + const uint8_t *value, uint8_t length); -typedef struct -{ -// btdrv_config_func_t func; - uint8_t is_act; - uint16_t opcode; - uint8_t parlen; - const uint8_t *param; +typedef struct { + // btdrv_config_func_t func; + uint8_t is_act; + uint16_t opcode; + uint8_t parlen; + const uint8_t *param; } BTDRV_CFG_TBL_STRUCT; - -#define BTDRV_CONFIG_ACTIVE 1 +#define BTDRV_CONFIG_ACTIVE 1 #define BTDRV_CONFIG_INACTIVE 0 -#define BTDRV_INVALID_TRACE_LEVEL 0xFF +#define BTDRV_INVALID_TRACE_LEVEL 0xFF /* [0][0] = 63, [0][1] = 0,[0][2] = (-80), 472d [1][0] = 51, [2][1] = 0,[2][2] = (-80), 472b @@ -56,987 +56,857 @@ typedef struct [8][0] = -3,[14][1] = 0,[14][2] = 0x7f}; c0c2 */ static uint8_t g_controller_trace_level = BTDRV_INVALID_TRACE_LEVEL; -static bool g_lmp_trace_enable = false; -const int8_t btdrv_rf_env_2300p[]= -{ - 0x01,0x00, //rf api - 0x01, //rf env - 185, //rf length - 0x2, //txpwr_max +static bool g_lmp_trace_enable = false; +const int8_t btdrv_rf_env_2300p[] = { + 0x01, 0x00, // rf api + 0x01, // rf env + 185, // rf length + 0x2, // txpwr_max #ifdef __HW_AGC__ - -1, //high - -2, //low - -100, //interf + -1, // high + -2, // low + -100, // interf #else - -1, ///rssi high thr - -2, //rssi low thr - -100, //rssi interf thr + -1, /// rssi high thr + -2, // rssi low thr + -100, // rssi interf thr #endif - 0xf, //rssi interf gain thr - 2, //wakeup delay - 0xe, 0, //skew - 0xe8,0x3, //ble agc inv thr + 0xf, // rssi interf gain thr + 2, // wakeup delay + 0xe, 0, // skew + 0xe8, 0x3, // ble agc inv thr #ifdef __HW_AGC__ - 0x1,//hw_sw_agc_flag + 0x1, // hw_sw_agc_flag #else - 0x0,// + 0x0, // #endif - 0xff,//sw gain set - 0xff, //sw gain set - -70,//bt_inq_page_iscan_pscan_dbm - 0x7f,//ble_scan_adv_dbm - 1, //sw gain reset factor - 1, //bt sw gain cntl enable - 0, //ble sw gain cntl en - 1, //bt interfere detector en - 0, //ble interfere detector en + 0xff, // sw gain set + 0xff, // sw gain set + -70, // bt_inq_page_iscan_pscan_dbm + 0x7f, // ble_scan_adv_dbm + 1, // sw gain reset factor + 1, // bt sw gain cntl enable + 0, // ble sw gain cntl en + 1, // bt interfere detector en + 0, // ble interfere detector en - -21,-27,-19, - -18,-24,-13, - -15,-21,-10, - -12,-18,-10, - -9,-15,-10, - -6,-12,-10, - -3,-9,-10, - 0,-6,0, - 0x7f,-3,0x7f, - 0x7f,0,0x7f, - 0x7f,0x7f,0x7f, - 0x7f,0x7f,0x7f, - 0x7f,0x7f,0x7f, - 0x7f,0x7f,0x7f, - 0x7f,0x7f,0x7f, //rx hwgain tbl ptr + -21, -27, -19, -18, -24, -13, -15, -21, -10, -12, -18, -10, -9, -15, -10, + -6, -12, -10, -3, -9, -10, 0, -6, 0, 0x7f, -3, 0x7f, 0x7f, 0, 0x7f, 0x7f, + 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, + 0x7f, 0x7f, // rx hwgain tbl ptr -//zhangzhd agc config use default 1216 - 50,0,-80, - 42,0,-80, - 38,0,-80, - 32,0,-80, - 26,0,-80, - 21,0,-80, - 15,0,-80, - 9,0,-80, -//zhangzhd agc config end + // zhangzhd agc config use default 1216 + 50, 0, -80, 42, 0, -80, 38, 0, -80, 32, 0, -80, 26, 0, -80, 21, 0, -80, 15, + 0, -80, 9, 0, -80, + // zhangzhd agc config end + 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, + 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, // rx gain tbl ptr + // zhangzhd agc config use default 1216 + -80, -73, -75, -68, -70, -63, -65, -58, -60, -53, -55, -48, -50, -15, + // zhangzhd agc config end - 0x7f,0x7f,0x7f, - 0x7f,0x7f,0x7f, - 0x7f,0x7f,0x7f, - 0x7f,0x7f,0x7f, - 0x7f,0x7f,0x7f, - 0x7f,0x7f,0x7f, - 0x7f,0x7f,0x7f, //rx gain tbl ptr -//zhangzhd agc config use default 1216 - -80,-73, - -75,-68, - -70,-63, - -65,-58, - -60,-53, - -55,-48, - -50,-15, -//zhangzhd agc config end + 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, + 0x7f, 0x7f, 0x7f, 0x7f, // rx gain ths tbl ptr - 0x7f,0x7f, - 0x7f,0x7f, - 0x7f,0x7f, - 0x7f,0x7f, - 0x7f,0x7f, - 0x7f,0x7f, - 0x7f,0x7f, - 0x7f,0x7f, //rx gain ths tbl ptr - - 0,0, - 0,0, - 0,0, - 0,0, - 0,0, - 0,1, - 0,2, - 0,2, - 0,2, - 0x7f,0x7f, - 0x7f,0x7f, - 0x7f,0x7f, - 0x7f,0x7f, - 0x7f,0x7f, - 0x7f,0x7f, //flpha filter factor ptr - -23,-20,-17,-14,-11,-8,-5,-2,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f, //tx pw onv tbl ptr + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 2, 0, 2, 0x7f, 0x7f, 0x7f, + 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, + 0x7f, // flpha filter factor ptr + -23, -20, -17, -14, -11, -8, -5, -2, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, + 0x7f, // tx pw onv tbl ptr }; -const int8_t btdrv_afh_env[] = -{ - 0x02,0x00, //afh env - 0x00, //ignore - 33, //length - 5, //nb_reass_chnl - 10, //win_len - -70, //rf_rssi_interf_thr - 10, //per_thres_bad - 20, //reass_int - 20, //n_min - 20, //afh_rep_intv_max - 96, //ths_min - 2, //chnl_assess_report_style - 15, //chnl_assess_diff_thres - 60, // chnl_assess_interfere_per_thres_bad - 9, //chnl_assess_stat_cnt_max - -9, //chnl_assess_stat_cnt_min - 1,2,3,2,1, //chnl_assess_stat_cnt_inc_mask[5] - 1,2,3,2,1, //chnl_assess_stat_cnt_dec_mask - 0xd0,0x7, //chnl_assess_timer - -48, //chnl_assess_min_rssi - 0x64,0, //chnl_assess_nb_pkt - 0x32,0, //chnl_assess_nb_bad_pkt - 6, //chnl_reassess_cnt_val - 0x3c,0, //chnl_assess_interfere_per_thres_bad +const int8_t btdrv_afh_env[] = { + 0x02, 0x00, // afh env + 0x00, // ignore + 33, // length + 5, // nb_reass_chnl + 10, // win_len + -70, // rf_rssi_interf_thr + 10, // per_thres_bad + 20, // reass_int + 20, // n_min + 20, // afh_rep_intv_max + 96, // ths_min + 2, // chnl_assess_report_style + 15, // chnl_assess_diff_thres + 60, // chnl_assess_interfere_per_thres_bad + 9, // chnl_assess_stat_cnt_max + -9, // chnl_assess_stat_cnt_min + 1, 2, 3, 2, 1, // chnl_assess_stat_cnt_inc_mask[5] + 1, 2, 3, 2, 1, // chnl_assess_stat_cnt_dec_mask + 0xd0, 0x7, // chnl_assess_timer + -48, // chnl_assess_min_rssi + 0x64, 0, // chnl_assess_nb_pkt + 0x32, 0, // chnl_assess_nb_bad_pkt + 6, // chnl_reassess_cnt_val + 0x3c, 0, // chnl_assess_interfere_per_thres_bad }; -const uint8_t lpclk_drift_jitter[] = -{ - 0xfa,0x00, // drift 250ppm - 0x0a,0x00 //jitter +-10us +const uint8_t lpclk_drift_jitter[] = { + 0xfa, 0x00, // drift 250ppm + 0x0a, 0x00 // jitter +-10us }; -const uint8_t wakeup_timing[] = -{ - 0xe8,0x3, //exernal_wakeup_time 600us - 0xe8,0x3, //oscillater_wakeup_time 600us - 0xe8,0x3, //radio_wakeup_time 600us - //0xa0,0xf, //wakeup_delay_time +const uint8_t wakeup_timing[] = { + 0xe8, 0x3, // exernal_wakeup_time 600us + 0xe8, 0x3, // oscillater_wakeup_time 600us + 0xe8, 0x3, // radio_wakeup_time 600us + // 0xa0,0xf, //wakeup_delay_time }; - -uint8_t sleep_param[] = -{ - 1, // sleep_en; - 0, // exwakeup_en; - 0xc8,0, // lpo_calib_interval; lpo calibration interval - 0x32,0,0,0, // lpo_calib_time; lpo count lpc times +uint8_t sleep_param[] = { + 1, // sleep_en; + 0, // exwakeup_en; + 0xc8, 0, // lpo_calib_interval; lpo calibration interval + 0x32, 0, 0, 0, // lpo_calib_time; lpo count lpc times }; -uint8_t unsleep_param[] = -{ - 0, // sleep_en; - 0, // exwakeup_en; - 0xc8,0, // lpo_calib_interval; lpo calibration interval - 0x32,0,0,0, // lpo_calib_time; lpo count lpc times +uint8_t unsleep_param[] = { + 0, // sleep_en; + 0, // exwakeup_en; + 0xc8, 0, // lpo_calib_interval; lpo calibration interval + 0x32, 0, 0, 0, // lpo_calib_time; lpo count lpc times }; -static const uint32_t me_init_param[][2] = -{ +static const uint32_t me_init_param[][2] = { {0xffffffff, 0xffffffff}, }; const uint16_t me_bt_default_page_timeout = 0x2000; -const uint8_t sync_config[] = -{ - 1,1, //sco path config 0:hci 1:pcm - 0, //sync use max buff length 0:sync data length= packet length 1:sync data length = host sync buff len - 0, //cvsd bypass 0:cvsd2pcm 1:cvsd transparent +const uint8_t sync_config[] = { + 1, 1, // sco path config 0:hci 1:pcm + 0, // sync use max buff length 0:sync data length= packet length 1:sync + // data length = host sync buff len + 0, // cvsd bypass 0:cvsd2pcm 1:cvsd transparent }; +// pcm general ctrl +#define PCM_PCMEN_POS 15 +#define PCM_LOOPBCK_POS 14 +#define PCM_MIXERDSBPOL_POS 11 +#define PCM_MIXERMODE_POS 10 +#define PCM_STUTTERDSBPOL_POS 9 +#define PCM_STUTTERMODE_POS 8 +#define PCM_CHSEL_POS 6 +#define PCM_MSTSLV_POS 5 +#define PCM_PCMIRQEN_POS 4 +#define PCM_DATASRC_POS 0 -//pcm general ctrl -#define PCM_PCMEN_POS 15 -#define PCM_LOOPBCK_POS 14 -#define PCM_MIXERDSBPOL_POS 11 -#define PCM_MIXERMODE_POS 10 -#define PCM_STUTTERDSBPOL_POS 9 -#define PCM_STUTTERMODE_POS 8 -#define PCM_CHSEL_POS 6 -#define PCM_MSTSLV_POS 5 -#define PCM_PCMIRQEN_POS 4 -#define PCM_DATASRC_POS 0 - - -//pcm phy ctrl -#define PCM_LRCHPOL_POS 15 -#define PCM_CLKINV_POS 14 -#define PCM_IOM_PCM_POS 13 -#define PCM_BUSSPEED_LSB 10 -#define PCM_SLOTEN_MASK ((uint32_t)0x00000380) -#define PCM_SLOTEN_LSB 7 -#define PCM_WORDSIZE_MASK ((uint32_t)0x00000060) -#define PCM_WORDSIZE_LSB 5 -#define PCM_DOUTCFG_MASK ((uint32_t)0x00000018) -#define PCM_DOUTCFG_LSB 3 -#define PCM_FSYNCSHP_MASK ((uint32_t)0x00000007) -#define PCM_FSYNCSHP_LSB 0 +// pcm phy ctrl +#define PCM_LRCHPOL_POS 15 +#define PCM_CLKINV_POS 14 +#define PCM_IOM_PCM_POS 13 +#define PCM_BUSSPEED_LSB 10 +#define PCM_SLOTEN_MASK ((uint32_t)0x00000380) +#define PCM_SLOTEN_LSB 7 +#define PCM_WORDSIZE_MASK ((uint32_t)0x00000060) +#define PCM_WORDSIZE_LSB 5 +#define PCM_DOUTCFG_MASK ((uint32_t)0x00000018) +#define PCM_DOUTCFG_LSB 3 +#define PCM_FSYNCSHP_MASK ((uint32_t)0x00000007) +#define PCM_FSYNCSHP_LSB 0 /// Enumeration of PCM status -enum PCM_STAT -{ - PCM_DISABLE = 0, - PCM_ENABLE -}; +enum PCM_STAT { PCM_DISABLE = 0, PCM_ENABLE }; /// Enumeration of PCM channel selection -enum PCM_CHANNEL -{ - PCM_CH_0 = 0, - PCM_CH_1 -}; +enum PCM_CHANNEL { PCM_CH_0 = 0, PCM_CH_1 }; /// Enumeration of PCM role -enum PCM_MSTSLV -{ - PCM_SLAVE = 0, - PCM_MASTER -}; +enum PCM_MSTSLV { PCM_SLAVE = 0, PCM_MASTER }; /// Enumeration of PCM data source -enum PCM_SRC -{ - PCM_SRC_DPV = 0, - PCM_SRC_REG -}; +enum PCM_SRC { PCM_SRC_DPV = 0, PCM_SRC_REG }; /// Enumeration of PCM left/right channel selection versus frame sync polarity -enum PCM_LR_CH_POL -{ - PCM_LR_CH_POL_RIGHT_LEFT = 0, - PCM_LR_CH_POL_LEFT_RIGHT -}; +enum PCM_LR_CH_POL { PCM_LR_CH_POL_RIGHT_LEFT = 0, PCM_LR_CH_POL_LEFT_RIGHT }; /// Enumeration of PCM clock inversion -enum PCM_CLK_INV -{ - PCM_CLK_RISING_EDGE = 0, - PCM_CLK_FALLING_EDGE -}; +enum PCM_CLK_INV { PCM_CLK_RISING_EDGE = 0, PCM_CLK_FALLING_EDGE }; /// Enumeration of PCM mode selection -enum PCM_MODE -{ - PCM_MODE_PCM = 0, - PCM_MODE_IOM -}; +enum PCM_MODE { PCM_MODE_PCM = 0, PCM_MODE_IOM }; /// Enumeration of PCM bus speed -enum PCM_BUS_SPEED -{ - PCM_BUS_SPEED_128k = 0, - PCM_BUS_SPEED_256k, - PCM_BUS_SPEED_512k, - PCM_BUS_SPEED_1024k, - PCM_BUS_SPEED_2048k +enum PCM_BUS_SPEED { + PCM_BUS_SPEED_128k = 0, + PCM_BUS_SPEED_256k, + PCM_BUS_SPEED_512k, + PCM_BUS_SPEED_1024k, + PCM_BUS_SPEED_2048k }; /// Enumeration of PCM slot enable -enum PCM_SLOT -{ - PCM_SLOT_NONE = 0, - PCM_SLOT_0, - PCM_SLOT_0_1, - PCM_SLOT_0_2, - PCM_SLOT_0_3 +enum PCM_SLOT { + PCM_SLOT_NONE = 0, + PCM_SLOT_0, + PCM_SLOT_0_1, + PCM_SLOT_0_2, + PCM_SLOT_0_3 }; /// Enumeration of PCM word size -enum PCM_WORD_SIZE -{ - PCM_8_BITS = 0, - PCM_13_BITS, - PCM_14_BITS, - PCM_16_BITS -}; +enum PCM_WORD_SIZE { PCM_8_BITS = 0, PCM_13_BITS, PCM_14_BITS, PCM_16_BITS }; /// Enumeration of PCM DOUT pad configuration -enum PCM_DOUT_CFG -{ - PCM_OPEN_DRAIN = 0, - PCM_PUSH_PULL_HZ, - PCM_PUSH_PULL_0 -}; +enum PCM_DOUT_CFG { PCM_OPEN_DRAIN = 0, PCM_PUSH_PULL_HZ, PCM_PUSH_PULL_0 }; /// Enumeration of PCM FSYNC physical shape -enum PCM_FSYNC -{ - PCM_FSYNC_LF = 0, - PCM_FSYNC_FR, - PCM_FSYNC_FF, - PCM_FSYNC_LONG, - PCM_FSYNC_LONG_16 +enum PCM_FSYNC { + PCM_FSYNC_LF = 0, + PCM_FSYNC_FR, + PCM_FSYNC_FF, + PCM_FSYNC_LONG, + PCM_FSYNC_LONG_16 }; -const uint32_t pcm_setting[] = -{ -//pcm_general_ctrl - (PCM_DISABLE<= HAL_CHIP_METAL_ID_1) - { - BT_DRV_TRACE(1,"BT_DRV_CONFIG:accept_new_mobile enable=%d", bt_setting_2300p_t2[97]); - ret = bt_setting_2300p_t2[97]; - } - return ret; +bool btdrv_get_accept_new_mobile_enable(void) { + bool ret = false; + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) { + BT_DRV_TRACE(1, "BT_DRV_CONFIG:accept_new_mobile enable=%d", + bt_setting_2300p_t2[97]); + ret = bt_setting_2300p_t2[97]; + } + return ret; } -bool btdrv_get_page_pscan_coex_enable(void) -{ - bool ret = false; - if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) - { - BT_DRV_TRACE(1,"BT_DRV_CONFIG:page_pscan_coex enable=%d", bt_setting_2300p_t2[96]); - ret = bt_setting_2300p_t2[96]; - } - return ret; +bool btdrv_get_page_pscan_coex_enable(void) { + bool ret = false; + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) { + BT_DRV_TRACE(1, "BT_DRV_CONFIG:page_pscan_coex enable=%d", + bt_setting_2300p_t2[96]); + ret = bt_setting_2300p_t2[96]; + } + return ret; } -const uint8_t bt_edr_thr[] = -{ - 30,0,60,0,5,0,60,0,0,1, - 30,0,60,0,5,0,60,0,1,1, - 30,0,60,0,5,0,60,0,1,1, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +const uint8_t bt_edr_thr[] = { + 30, 0, 60, 0, 5, 0, 60, 0, 0, 1, 30, 0, + 60, 0, 5, 0, 60, 0, 1, 1, 30, 0, 60, 0, + 5, 0, 60, 0, 1, 1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }; -const uint8_t bt_edr_algo[]= -{ - 0,0,1, - 8,0,3, - 16,0,0, - 0xff,0xff,0xff, - 0xff,0xff,0xff, - 0xff,0xff,0xff, - 0xff,0xff,0xff, +const uint8_t bt_edr_algo[] = { + 0, 0, 1, 8, 0, 3, 16, 0, 0, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }; -const uint8_t bt_rssi_thr[]= -{ - -1, //high - -2, //low - -100, //interf +const uint8_t bt_rssi_thr[] = { + -1, // high + -2, // low + -100, // interf }; - -const uint8_t ble_dle_dft_value[]= -{ - 0xfb,0x00, ///tx octets - 0x48,0x08, ///tx time - 0xfb,0x00, ///rx octets - 0x48,0x08, ///rx time +const uint8_t ble_dle_dft_value[] = { + 0xfb, 0x00, /// tx octets + 0x48, 0x08, /// tx time + 0xfb, 0x00, /// rx octets + 0x48, 0x08, /// rx time }; - -uint8_t bt_lmp_record[]= -{ - 0, //en - 0, //only opcode +uint8_t bt_lmp_record[] = { + 0, // en + 0, // only opcode }; - -static BTDRV_CFG_TBL_STRUCT btdrv_cfg_tbl[] = -{ - {BTDRV_CONFIG_INACTIVE,HCI_DBG_LMP_MESSAGE_RECORD_CMD_OPCODE,sizeof(bt_lmp_record),(uint8_t *)&bt_lmp_record}, - {BTDRV_CONFIG_ACTIVE,HCI_DBG_SET_LOCAL_FEATURE_CMD_OPCODE,sizeof(local_feature),local_feature}, - {BTDRV_CONFIG_INACTIVE,HCI_DBG_SET_BT_SETTING_CMD_OPCODE,sizeof(bt_setting_2300p),bt_setting_2300p}, - {BTDRV_CONFIG_INACTIVE,HCI_DBG_SET_BT_SETTING_CMD_OPCODE,sizeof(bt_setting_2300p_t2),bt_setting_2300p_t2}, - {BTDRV_CONFIG_INACTIVE,HCI_DBG_SET_BT_SETTING_EXT1_CMD_OPCODE,sizeof(bt_setting_ext1_2300p_t3),bt_setting_ext1_2300p_t3}, - {BTDRV_CONFIG_ACTIVE,HCI_DBG_SET_SLEEP_SETTING_CMD_OPCODE,sizeof(sleep_param),sleep_param}, - {BTDRV_CONFIG_ACTIVE,HCI_DBG_SET_CUSTOM_PARAM_CMD_OPCODE,189,(uint8_t *)&btdrv_rf_env_2300p}, - //{BTDRV_CONFIG_ACTIVE,HCI_DBG_SET_CUSTOM_PARAM_CMD_OPCODE,sizeof(btdrv_afh_env),(uint8_t *)&btdrv_afh_env}, - // {BTDRV_CONFIG_INACTIVE,HCI_DBG_SET_LPCLK_DRIFT_JITTER_CMD_OPCODE,sizeof(lpclk_drift_jitter),(uint8_t *)&lpclk_drift_jitter}, - // {BTDRV_CONFIG_ACTIVE,HCI_DBG_SET_WAKEUP_TIME_CMD_OPCODE,sizeof(wakeup_timing),(uint8_t *)&wakeup_timing}, +static BTDRV_CFG_TBL_STRUCT btdrv_cfg_tbl[] = { + {BTDRV_CONFIG_INACTIVE, HCI_DBG_LMP_MESSAGE_RECORD_CMD_OPCODE, + sizeof(bt_lmp_record), (uint8_t *)&bt_lmp_record}, + {BTDRV_CONFIG_ACTIVE, HCI_DBG_SET_LOCAL_FEATURE_CMD_OPCODE, + sizeof(local_feature), local_feature}, + {BTDRV_CONFIG_INACTIVE, HCI_DBG_SET_BT_SETTING_CMD_OPCODE, + sizeof(bt_setting_2300p), bt_setting_2300p}, + {BTDRV_CONFIG_INACTIVE, HCI_DBG_SET_BT_SETTING_CMD_OPCODE, + sizeof(bt_setting_2300p_t2), bt_setting_2300p_t2}, + {BTDRV_CONFIG_INACTIVE, HCI_DBG_SET_BT_SETTING_EXT1_CMD_OPCODE, + sizeof(bt_setting_ext1_2300p_t3), bt_setting_ext1_2300p_t3}, + {BTDRV_CONFIG_ACTIVE, HCI_DBG_SET_SLEEP_SETTING_CMD_OPCODE, + sizeof(sleep_param), sleep_param}, + {BTDRV_CONFIG_ACTIVE, HCI_DBG_SET_CUSTOM_PARAM_CMD_OPCODE, 189, + (uint8_t *)&btdrv_rf_env_2300p}, +//{BTDRV_CONFIG_ACTIVE,HCI_DBG_SET_CUSTOM_PARAM_CMD_OPCODE,sizeof(btdrv_afh_env),(uint8_t +//*)&btdrv_afh_env}, +// {BTDRV_CONFIG_INACTIVE,HCI_DBG_SET_LPCLK_DRIFT_JITTER_CMD_OPCODE,sizeof(lpclk_drift_jitter),(uint8_t +// *)&lpclk_drift_jitter}, +// {BTDRV_CONFIG_ACTIVE,HCI_DBG_SET_WAKEUP_TIME_CMD_OPCODE,sizeof(wakeup_timing),(uint8_t +// *)&wakeup_timing}, #ifdef _SCO_BTPCM_CHANNEL_ - {BTDRV_CONFIG_ACTIVE,HCI_DBG_SET_SYNC_CONFIG_CMD_OPCODE,sizeof(sync_config),(uint8_t *)&sync_config}, - {BTDRV_CONFIG_ACTIVE,HCI_DBG_SET_PCM_SETTING_CMD_OPCODE,sizeof(pcm_setting),(uint8_t *)&pcm_setting}, + {BTDRV_CONFIG_ACTIVE, HCI_DBG_SET_SYNC_CONFIG_CMD_OPCODE, + sizeof(sync_config), (uint8_t *)&sync_config}, + {BTDRV_CONFIG_ACTIVE, HCI_DBG_SET_PCM_SETTING_CMD_OPCODE, + sizeof(pcm_setting), (uint8_t *)&pcm_setting}, #endif - {BTDRV_CONFIG_ACTIVE,HCI_DBG_SET_RSSI_THRHLD_CMD_OPCODE,sizeof(bt_rssi_thr),(uint8_t *)&bt_rssi_thr}, - {BTDRV_CONFIG_ACTIVE,HCI_DBG_SET_LOCAL_EX_FEATURE_CMD_OPCODE,sizeof(local_ex_feature_page2),(uint8_t *)&local_ex_feature_page2}, - {BTDRV_CONFIG_ACTIVE,HCI_DBG_SET_BT_RF_TIMING_CMD_OPCODE,sizeof(bt_rf_timing),(uint8_t *)&bt_rf_timing}, - {BTDRV_CONFIG_ACTIVE,HCI_DBG_SET_BLE_RF_TIMING_CMD_OPCODE,sizeof(ble_rf_timing),(uint8_t *)&ble_rf_timing}, + {BTDRV_CONFIG_ACTIVE, HCI_DBG_SET_RSSI_THRHLD_CMD_OPCODE, + sizeof(bt_rssi_thr), (uint8_t *)&bt_rssi_thr}, + {BTDRV_CONFIG_ACTIVE, HCI_DBG_SET_LOCAL_EX_FEATURE_CMD_OPCODE, + sizeof(local_ex_feature_page2), (uint8_t *)&local_ex_feature_page2}, + {BTDRV_CONFIG_ACTIVE, HCI_DBG_SET_BT_RF_TIMING_CMD_OPCODE, + sizeof(bt_rf_timing), (uint8_t *)&bt_rf_timing}, + {BTDRV_CONFIG_ACTIVE, HCI_DBG_SET_BLE_RF_TIMING_CMD_OPCODE, + sizeof(ble_rf_timing), (uint8_t *)&ble_rf_timing}, }; - -const static POSSIBLY_UNUSED BTDRV_CFG_TBL_STRUCT btdrv_cfg_tbl_2[] = -{ +const static POSSIBLY_UNUSED BTDRV_CFG_TBL_STRUCT btdrv_cfg_tbl_2[] = { }; -const static POSSIBLY_UNUSED uint32_t mem_config_2300p[][2] = -{ +const static POSSIBLY_UNUSED uint32_t mem_config_2300p[][2] = { }; -void bt_drv_digital_config_for_ble_adv(bool en) -{ +void bt_drv_digital_config_for_ble_adv(bool en) { #ifdef __HW_AGC__ - btdrv_hw_agc_stop_mode(BT_SYNCMODE_REQ_USER_BLE,en); + btdrv_hw_agc_stop_mode(BT_SYNCMODE_REQ_USER_BLE, en); #endif } -void btdrv_digital_config_init_2300p_t2(void) -{ - //common - BTDIGITAL_REG(0xd0350370)|= (1<<29);//lowpass flt enable - BTDIGITAL_REG(0xd0330038)|=(1<<11); //sel 26m sys - BTDIGITAL_REG(0xd0330038)&=0xffffff3f; //sel 26m sys - BTDIGITAL_REG(0xd03300f0)&=~0x1; // sel 26m sys +void btdrv_digital_config_init_2300p_t2(void) { + // common + BTDIGITAL_REG(0xd0350370) |= (1 << 29); // lowpass flt enable + BTDIGITAL_REG(0xd0330038) |= (1 << 11); // sel 26m sys + BTDIGITAL_REG(0xd0330038) &= 0xffffff3f; // sel 26m sys + BTDIGITAL_REG(0xd03300f0) &= ~0x1; // sel 26m sys - BTDIGITAL_REG(0xd0350398)=0x6e4ef79c; - BTDIGITAL_REG(0xd03503a8)=0x15A64E88; + BTDIGITAL_REG(0xd0350398) = 0x6e4ef79c; + BTDIGITAL_REG(0xd03503a8) = 0x15A64E88; - //IBRT - BTDIGITAL_REG(0xd0220464) &= 0xdfffffff;//fast ack 2M mode dis + // IBRT + BTDIGITAL_REG(0xd0220464) &= 0xdfffffff; // fast ack 2M mode dis #ifdef __FASTACK_ECC_ENABLE__ - BTDIGITAL_REG(0xd0220468)=0x04401914;//fast ack timings & fastlock en + BTDIGITAL_REG(0xd0220468) = 0x04401914; // fast ack timings & fastlock en #else - BTDIGITAL_REG(0xd0220468)=0x10423528;//fast ack timings + BTDIGITAL_REG(0xd0220468) = 0x10423528; // fast ack timings #endif //__FASTACK_ECC_ENABLE__ #ifdef __FA_RX_GAIN_CTRL__ - BTDIGITAL_REG(0xd0220080) &= 0xff00ffff; - BTDIGITAL_REG(0xd0220080) |= 0x00770000;//trx pwrup/dn - BTDIGITAL_REG(0xd02201e8)|=1;//second rf spi en - BTDIGITAL_REG(0xd0220480) = (BTDIGITAL_REG(0xd0220480)&(~0xff))|0xbf; - BTDIGITAL_REG(0xd0220484) = (BTDIGITAL_REG(0xd0220484)&(~0xffff))|0x9403; //lxd 20191102 fixed ecc receive gain to 1 level + BTDIGITAL_REG(0xd0220080) &= 0xff00ffff; + BTDIGITAL_REG(0xd0220080) |= 0x00770000; // trx pwrup/dn + BTDIGITAL_REG(0xd02201e8) |= 1; // second rf spi en + BTDIGITAL_REG(0xd0220480) = (BTDIGITAL_REG(0xd0220480) & (~0xff)) | 0xbf; + BTDIGITAL_REG(0xd0220484) = + (BTDIGITAL_REG(0xd0220484) & (~0xffff)) | + 0x9403; // lxd 20191102 fixed ecc receive gain to 1 level #endif #ifdef __CLK_GATE_DISABLE__ - BTDIGITAL_REG(0xD0330024) &=(~0x00020); - BTDIGITAL_REG(0xD0330024) |=0x40000; - BTDIGITAL_REG(0xD0330038) |=0x200000; + BTDIGITAL_REG(0xD0330024) &= (~0x00020); + BTDIGITAL_REG(0xD0330024) |= 0x40000; + BTDIGITAL_REG(0xD0330038) |= 0x200000; #endif } -void btdrv_digital_config_init_2300p_t1(void) -{ +void btdrv_digital_config_init_2300p_t1(void) { #ifdef BT_RF_OLD_CORR_MODE - BTDIGITAL_REG(0xD03503A0)&=(~0x01); //clear bit 0 avoid slave lost data + BTDIGITAL_REG(0xD03503A0) &= (~0x01); // clear bit 0 avoid slave lost data #else - BTDIGITAL_REG(0xD03503A0)|=(0x01); + BTDIGITAL_REG(0xD03503A0) |= (0x01); #endif - BTDIGITAL_REG(0x40000074)=0x00003100; - BTDIGITAL_REG(0x400000F0)=0xFFFF0002;//open slot en + BTDIGITAL_REG(0x40000074) = 0x00003100; + BTDIGITAL_REG(0x400000F0) = 0xFFFF0002; // open slot en - BTDIGITAL_REG(0xd0350240)=0x0001a407; - BTDIGITAL_REG(0xd03502c8)=0x00000080;//for old ramp - BTDIGITAL_REG(0xd03502cc)=0x00000015;//for old ramp + BTDIGITAL_REG(0xd0350240) = 0x0001a407; + BTDIGITAL_REG(0xd03502c8) = 0x00000080; // for old ramp + BTDIGITAL_REG(0xd03502cc) = 0x00000015; // for old ramp #ifdef __HW_AGC__ - BTDIGITAL_REG(0xd0350208)=0x7fffffff; - btdrv_delay(10); - BTDIGITAL_REG(0xd0350228)=0x7f7fffff; - BTDIGITAL_REG(0xd03300f0)=0xffff0008;//hwagc config - BTDIGITAL_REG(0xd03503b8)=0x08000d80;//hwagc config + BTDIGITAL_REG(0xd0350208) = 0x7fffffff; + btdrv_delay(10); + BTDIGITAL_REG(0xd0350228) = 0x7f7fffff; + BTDIGITAL_REG(0xd03300f0) = 0xffff0008; // hwagc config + BTDIGITAL_REG(0xd03503b8) = 0x08000d80; // hwagc config #endif - BTDIGITAL_REG(0xd02201e8) = (BTDIGITAL_REG(0xd02201e8)&(~0x7c0))|0x380; - BTDIGITAL_REG(0xd0350360)=0x003fe040; - BTDIGITAL_REG(0xd0220470) |=0x40; + BTDIGITAL_REG(0xd02201e8) = (BTDIGITAL_REG(0xd02201e8) & (~0x7c0)) | 0x380; + BTDIGITAL_REG(0xd0350360) = 0x003fe040; + BTDIGITAL_REG(0xd0220470) |= 0x40; #ifdef __CLK_GATE_DISABLE__ - BTDIGITAL_REG(0xD0330024) &=(~0x00020); - BTDIGITAL_REG(0xD0330024) |=0x40000; - BTDIGITAL_REG(0xD0330038) |=0x200000; + BTDIGITAL_REG(0xD0330024) &= (~0x00020); + BTDIGITAL_REG(0xD0330024) |= 0x40000; + BTDIGITAL_REG(0xD0330038) |= 0x200000; #endif #ifdef LBRT - BTDIGITAL_REG(0xd0350300) = 0x00000000; - BTDIGITAL_REG(0xd0350340) = 0x00000000; + BTDIGITAL_REG(0xd0350300) = 0x00000000; + BTDIGITAL_REG(0xd0350340) = 0x00000000; #else #ifdef __BDR_EDR_2DB__ - BTDIGITAL_REG(0xd0350300) = 0x55; - BTDIGITAL_REG(0xd0350308) = 0x00003C0F; + BTDIGITAL_REG(0xd0350300) = 0x55; + BTDIGITAL_REG(0xd0350308) = 0x00003C0F; #else - BTDIGITAL_REG(0xd0350300) = 0x11; + BTDIGITAL_REG(0xd0350300) = 0x11; #endif - BTDIGITAL_REG(0xd0350340) = 0x1; + BTDIGITAL_REG(0xd0350340) = 0x1; #endif - //0x07 will affect Bluetooth sensitivity - //0x06 will lead to LBRT rx bad in close distance - BTDIGITAL_REG(0xd0350280) = 0x00000006; - BTDIGITAL_REG(0xd035031c) = 0x00050004;//modulation factor 17/16 - BTDIGITAL_REG(0xd0350320) = 0x00350011;//added by xrz 2018.10.10 - BTDIGITAL_REG(0xd0220080) = 0x0e571439;//trx pwrup/dn - BTDIGITAL_REG(0xd0220280) = 0x0e471445;//add by luobin 2019/05/23 + // 0x07 will affect Bluetooth sensitivity + // 0x06 will lead to LBRT rx bad in close distance + BTDIGITAL_REG(0xd0350280) = 0x00000006; + BTDIGITAL_REG(0xd035031c) = 0x00050004; // modulation factor 17/16 + BTDIGITAL_REG(0xd0350320) = 0x00350011; // added by xrz 2018.10.10 + BTDIGITAL_REG(0xd0220080) = 0x0e571439; // trx pwrup/dn + BTDIGITAL_REG(0xd0220280) = 0x0e471445; // add by luobin 2019/05/23 - BTDIGITAL_REG(0xd0350210) = 0x00f10040;//add by walker 2018/12/27 - BTDIGITAL_REG(0xd03502c4) = 0x127f02ef;// 2M TE time init - BTDIGITAL_REG(0xd0350284) = 0x02000200; - BTDIGITAL_REG_SET_FIELD(0xd0220200,7,0,3); + BTDIGITAL_REG(0xd0350210) = 0x00f10040; // add by walker 2018/12/27 + BTDIGITAL_REG(0xd03502c4) = 0x127f02ef; // 2M TE time init + BTDIGITAL_REG(0xd0350284) = 0x02000200; + BTDIGITAL_REG_SET_FIELD(0xd0220200, 7, 0, 3); - BTDIGITAL_REG(0xd0350398)=0xD25EF79C; - BTDIGITAL_REG(0xd035039c)=0x60C6C061;//hwagc config + BTDIGITAL_REG(0xd0350398) = 0xD25EF79C; + BTDIGITAL_REG(0xd035039c) = 0x60C6C061; // hwagc config - BTDIGITAL_REG(0xd03503a8)=0x14666E88;//hwagc config - BTDIGITAL_REG(0xd0350364)=0x002EB948;//data sign and iq swap - BTDIGITAL_REG(0xd03503a0)=0x1c070055 ;//improve 1M RX sensitivity by jiangpeng + BTDIGITAL_REG(0xd03503a8) = 0x14666E88; // hwagc config + BTDIGITAL_REG(0xd0350364) = 0x002EB948; // data sign and iq swap + BTDIGITAL_REG(0xd03503a0) = + 0x1c070055; // improve 1M RX sensitivity by jiangpeng - //for system 2M Band Wide - BTDIGITAL_REG(0x4008003c)|=1; - BTDIGITAL_REG(0x40080018)|=1; - BTDIGITAL_REG(0x40080004)|=(1<<15)|(1<<30);//osc x4 enable - BTDIGITAL_REG(0xd0330038)|=(3<<6)|(1<<11); - BTDIGITAL_REG(0xd03300f0)|=1; + // for system 2M Band Wide + BTDIGITAL_REG(0x4008003c) |= 1; + BTDIGITAL_REG(0x40080018) |= 1; + BTDIGITAL_REG(0x40080004) |= (1 << 15) | (1 << 30); // osc x4 enable + BTDIGITAL_REG(0xd0330038) |= (3 << 6) | (1 << 11); + BTDIGITAL_REG(0xd03300f0) |= 1; - //for IBRT fast ack - BTDIGITAL_REG(0xd0220464) |= 1<<29;//fast ack 2M mode enable - BTDIGITAL_REG(0xd0220468)=0x00403832;// 2M fast ack timings - BTDIGITAL_REG(0xd022046c)&=~(1<<31);//enable DM1 empty fastack - BTDIGITAL_REG(0xd035020C)=0x00f1002c; - BTDIGITAL_REG(0xD0350210)=0x00f1082c;//tx guard - BTDIGITAL_REG(0xd0220498)=0x00A01991;//fast ack timeout + // for IBRT fast ack + BTDIGITAL_REG(0xd0220464) |= 1 << 29; // fast ack 2M mode enable + BTDIGITAL_REG(0xd0220468) = 0x00403832; // 2M fast ack timings + BTDIGITAL_REG(0xd022046c) &= ~(1 << 31); // enable DM1 empty fastack + BTDIGITAL_REG(0xd035020C) = 0x00f1002c; + BTDIGITAL_REG(0xD0350210) = 0x00f1082c; // tx guard + BTDIGITAL_REG(0xd0220498) = 0x00A01991; // fast ack timeout } extern const uint8_t lmp_sniffer_filter_tab[51]; extern const uint8_t lmp_ext_sniffer_filter_tab[18]; extern const uint8_t lmp_ext_sniffer_fast_cfm_tab[4]; -void bt_drv_config_lmp_filter_table(void) -{ - if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_1) - { - BTDIGITAL_REG(0xc0000300) = 0xc00070f4; - BT_DRV_TRACE(2,"%s: 0x%x",__func__, BTDIGITAL_REG(0xc0000300)); - memcpy((uint8_t *)(0xc00070f4), lmp_sniffer_filter_tab, sizeof(lmp_sniffer_filter_tab)); - } - else if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) - { - BTDIGITAL_REG(0xc0000314+4) = 0xC0006e40; - memcpy((uint8_t *)(0xC0006e40), lmp_ext_sniffer_filter_tab, sizeof(lmp_ext_sniffer_filter_tab)); - BTDIGITAL_REG(0xc0000314+0xc) = 0xC0006c9c; - BT_DRV_TRACE(3, "%s: 0x%x, 0x%x",__func__, BTDIGITAL_REG(0xc0000314+4),BTDIGITAL_REG(0xc0000314+0xc)); - memcpy((uint8_t *)(0xC0006c9c), lmp_ext_sniffer_fast_cfm_tab, sizeof(lmp_ext_sniffer_fast_cfm_tab)); - } +void bt_drv_config_lmp_filter_table(void) { + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_1) { + BTDIGITAL_REG(0xc0000300) = 0xc00070f4; + BT_DRV_TRACE(2, "%s: 0x%x", __func__, BTDIGITAL_REG(0xc0000300)); + memcpy((uint8_t *)(0xc00070f4), lmp_sniffer_filter_tab, + sizeof(lmp_sniffer_filter_tab)); + } else if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) { + BTDIGITAL_REG(0xc0000314 + 4) = 0xC0006e40; + memcpy((uint8_t *)(0xC0006e40), lmp_ext_sniffer_filter_tab, + sizeof(lmp_ext_sniffer_filter_tab)); + BTDIGITAL_REG(0xc0000314 + 0xc) = 0xC0006c9c; + BT_DRV_TRACE(3, "%s: 0x%x, 0x%x", __func__, BTDIGITAL_REG(0xc0000314 + 4), + BTDIGITAL_REG(0xc0000314 + 0xc)); + memcpy((uint8_t *)(0xC0006c9c), lmp_ext_sniffer_fast_cfm_tab, + sizeof(lmp_ext_sniffer_fast_cfm_tab)); + } } -uint32_t ld_ibrt_sco_req_filter_patch[]= -{ - 0x7981b470,/*76c0*/ - 0xf1034b0b, - 0xe0020410, - 0x42a33304, - 0x785ad00c, - 0xd1f9428a, - 0x789a7a06, - 0xd1f54296, - 0x78da8946, - 0xd1f14296, - 0xe0002001, - 0xbc702000, - 0xbf004770, - 0xc0007450,//sniffer_sco_filter +uint32_t ld_ibrt_sco_req_filter_patch[] = { + 0x7981b470, /*76c0*/ + 0xf1034b0b, 0xe0020410, 0x42a33304, 0x785ad00c, 0xd1f9428a, 0x789a7a06, + 0xd1f54296, 0x78da8946, 0xd1f14296, 0xe0002001, 0xbc702000, 0xbf004770, + 0xc0007450, // sniffer_sco_filter }; -void bt_drv_func_ld_ibrt_sco_req_filter(void) -{ - if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) - { - memcpy((uint32_t *)(0xc00076c0), ld_ibrt_sco_req_filter_patch, sizeof(ld_ibrt_sco_req_filter_patch)); - } +void bt_drv_func_ld_ibrt_sco_req_filter(void) { + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) { + memcpy((uint32_t *)(0xc00076c0), ld_ibrt_sco_req_filter_patch, + sizeof(ld_ibrt_sco_req_filter_patch)); + } } extern void bt_drv_reg_op_controller_mem_log_config(void); -void btdrv_config_init(void) -{ - BT_DRV_TRACE(1,"%s",__func__); +void btdrv_config_init(void) { + BT_DRV_TRACE(1, "%s", __func__); - if (btdrv_get_lmp_trace_enable()) - { - //enable lmp trace - bt_lmp_record[0] = 1; - bt_lmp_record[1] = 1; - btdrv_cfg_tbl[0].is_act= BTDRV_CONFIG_ACTIVE; - ASSERT((btdrv_cfg_tbl[0].opcode == HCI_DBG_LMP_MESSAGE_RECORD_CMD_OPCODE), "lmp config not match"); - } + if (btdrv_get_lmp_trace_enable()) { + // enable lmp trace + bt_lmp_record[0] = 1; + bt_lmp_record[1] = 1; + btdrv_cfg_tbl[0].is_act = BTDRV_CONFIG_ACTIVE; + ASSERT((btdrv_cfg_tbl[0].opcode == HCI_DBG_LMP_MESSAGE_RECORD_CMD_OPCODE), + "lmp config not match"); + } - if (btdrv_get_controller_trace_level() != BTDRV_INVALID_TRACE_LEVEL) - { - //enable controller trace - bt_setting_2300p[28] = btdrv_get_controller_trace_level(); - bt_setting_2300p_t2[28] = btdrv_get_controller_trace_level(); - } + if (btdrv_get_controller_trace_level() != BTDRV_INVALID_TRACE_LEVEL) { + // enable controller trace + bt_setting_2300p[28] = btdrv_get_controller_trace_level(); + bt_setting_2300p_t2[28] = btdrv_get_controller_trace_level(); + } - for(uint8_t i=0; i= HAL_CHIP_METAL_ID_1 && btdrv_cfg_tbl[i].parlen == sizeof(bt_setting_2300p_t2)) - { - btdrv_send_cmd(btdrv_cfg_tbl[i].opcode,btdrv_cfg_tbl[i].parlen,btdrv_cfg_tbl[i].param); - btdrv_delay(1); - } - } - - if(btdrv_cfg_tbl[i].opcode == HCI_DBG_SET_BT_SETTING_EXT1_CMD_OPCODE) - { - if(hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_2 && btdrv_cfg_tbl[i].parlen == sizeof(bt_setting_ext1_2300p_t3)) - { - btdrv_send_cmd(btdrv_cfg_tbl[i].opcode,btdrv_cfg_tbl[i].parlen,btdrv_cfg_tbl[i].param); - btdrv_delay(1); - } - } - //BT other config - if(btdrv_cfg_tbl[i].is_act == BTDRV_CONFIG_ACTIVE) - { - btdrv_send_cmd(btdrv_cfg_tbl[i].opcode,btdrv_cfg_tbl[i].parlen,btdrv_cfg_tbl[i].param); - btdrv_delay(1); - } - } - - - //BT registers config - for(uint8_t i=0; i= HAL_CHIP_METAL_ID_1 && + btdrv_cfg_tbl[i].parlen == sizeof(bt_setting_2300p_t2)) { + btdrv_send_cmd(btdrv_cfg_tbl[i].opcode, btdrv_cfg_tbl[i].parlen, + btdrv_cfg_tbl[i].param); + btdrv_delay(1); + } } - if(hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_0) - { - btdrv_digital_config_init_2300p_t1(); - if(hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) - { - btdrv_digital_config_init_2300p_t2(); - } + if (btdrv_cfg_tbl[i].opcode == HCI_DBG_SET_BT_SETTING_EXT1_CMD_OPCODE) { + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_2 && + btdrv_cfg_tbl[i].parlen == sizeof(bt_setting_ext1_2300p_t3)) { + btdrv_send_cmd(btdrv_cfg_tbl[i].opcode, btdrv_cfg_tbl[i].parlen, + btdrv_cfg_tbl[i].param); + btdrv_delay(1); + } } - - if(btdrv_get_controller_trace_dump_enable()) - { - bt_drv_reg_op_controller_mem_log_config(); + // BT other config + if (btdrv_cfg_tbl[i].is_act == BTDRV_CONFIG_ACTIVE) { + btdrv_send_cmd(btdrv_cfg_tbl[i].opcode, btdrv_cfg_tbl[i].parlen, + btdrv_cfg_tbl[i].param); + btdrv_delay(1); } + } - bt_drv_config_lmp_filter_table(); - bt_drv_func_ld_ibrt_sco_req_filter(); - bt_drv_set_fa_invert_enable(BT_FA_INVERT_EN); + // BT registers config + for (uint8_t i = 0; + i < sizeof(mem_config_2300p) / sizeof(mem_config_2300p[0]); i++) { + btdrv_write_memory(_32_Bit, mem_config_2300p[i][0], + (uint8_t *)&mem_config_2300p[i][1], 4); + btdrv_delay(1); + } + + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_0) { + btdrv_digital_config_init_2300p_t1(); + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) { + btdrv_digital_config_init_2300p_t2(); + } + } + + if (btdrv_get_controller_trace_dump_enable()) { + bt_drv_reg_op_controller_mem_log_config(); + } + + bt_drv_config_lmp_filter_table(); + bt_drv_func_ld_ibrt_sco_req_filter(); + bt_drv_set_fa_invert_enable(BT_FA_INVERT_EN); } -//zhangzhd agc config use default 1216 +// zhangzhd agc config use default 1216 #define RX_GAIN_STEP0 -77 #define RX_GAIN_STEP1 -72 @@ -1045,647 +915,568 @@ void btdrv_config_init(void) #define RX_GAIN_STEP4 -57 #define RX_GAIN_STEP5 -52 #define RX_GAIN_STEP6 -47 -//zhangzhd agc config use default 1216 end +// zhangzhd agc config use default 1216 end -void bt_drv_adaptive_fa_rx_gain(int8_t rssi) -{ +void bt_drv_adaptive_fa_rx_gain(int8_t rssi) { #ifdef __FA_RX_GAIN_CTRL__ - uint8_t gain_step = 0xff; - static uint8_t old_step = 0xff; + uint8_t gain_step = 0xff; + static uint8_t old_step = 0xff; - if(rssi <= RX_GAIN_STEP0) - { - gain_step = 0; - } - else if(rssi <= RX_GAIN_STEP1) - { - gain_step = 1; - } - else if(rssi <= RX_GAIN_STEP2) - { - gain_step = 2; - } - else if(rssi <= RX_GAIN_STEP3) - { - gain_step = 3; - } - else if(rssi <= RX_GAIN_STEP4) - { - gain_step = 4; - } - else if(rssi <= RX_GAIN_STEP5) - { - gain_step = 5; - } - else if(rssi <= RX_GAIN_STEP6) - { - gain_step = 6; - } - else - { - gain_step = 7; - } + if (rssi <= RX_GAIN_STEP0) { + gain_step = 0; + } else if (rssi <= RX_GAIN_STEP1) { + gain_step = 1; + } else if (rssi <= RX_GAIN_STEP2) { + gain_step = 2; + } else if (rssi <= RX_GAIN_STEP3) { + gain_step = 3; + } else if (rssi <= RX_GAIN_STEP4) { + gain_step = 4; + } else if (rssi <= RX_GAIN_STEP5) { + gain_step = 5; + } else if (rssi <= RX_GAIN_STEP6) { + gain_step = 6; + } else { + gain_step = 7; + } - if(old_step != gain_step) - { - BT_DRV_TRACE(2,"if rssi = %d,then set fa %d level ",rssi,gain_step); - BT_DRV_REG_OP_ENTER(); - bt_drv_reg_op_fa_gain_direct_set(gain_step); - BT_DRV_REG_OP_EXIT(); - old_step = gain_step; - } + if (old_step != gain_step) { + BT_DRV_TRACE(2, "if rssi = %d,then set fa %d level ", rssi, gain_step); + BT_DRV_REG_OP_ENTER(); + bt_drv_reg_op_fa_gain_direct_set(gain_step); + BT_DRV_REG_OP_EXIT(); + old_step = gain_step; + } #endif } -bool btdrv_is_ecc_enable(void) -{ - bool ret = false; -#ifdef __FASTACK_ECC_ENABLE__ - ret = true; +bool btdrv_is_ecc_enable(void) { + bool ret = false; +#ifdef __FASTACK_ECC_ENABLE__ + ret = true; #endif - return ret; + return ret; } #ifdef LAURENT_ALGORITHM -void btdrv_bt_laurent_algorithm_enable(void) -{ - if(hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_0) - { - BT_DRV_TRACE(1,"%s",__func__); - BTDIGITAL_REG(0xd03503a8)=0x14664E88; - BTDIGITAL_REG(0xd0350240)= 0x0001A40F; - BTDIGITAL_REG(0xd0350364)= 0x202EB948;//lau_gain - BTDIGITAL_REG(0xd0350374)= 0x00A40DCD;//c1c2 0x06001e0 - BTDIGITAL_REG(0xd0350228)= 0x12040800;//clkmode - BTDIGITAL_REG(0xd03503C8)= 0x00840CCD;//train c1c2 - BTDIGITAL_REG(0xd03503A0)= 0x1C070065;//new corr en - BTDIGITAL_REG(0xd0220460)= 0x039EF088;//mac laurent_en - BTDIGITAL_REG(0xd0350370)= 0x6B240A3D;//laurent_en 0x - BTDIGITAL_REG(0xd0350280)= 0x00000007;//bt_dfe_forcera - BTDIGITAL_REG(0xd03502C4)= 0x127F02E8;//te_timeinit - } +void btdrv_bt_laurent_algorithm_enable(void) { + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_0) { + BT_DRV_TRACE(1, "%s", __func__); + BTDIGITAL_REG(0xd03503a8) = 0x14664E88; + BTDIGITAL_REG(0xd0350240) = 0x0001A40F; + BTDIGITAL_REG(0xd0350364) = 0x202EB948; // lau_gain + BTDIGITAL_REG(0xd0350374) = 0x00A40DCD; // c1c2 0x06001e0 + BTDIGITAL_REG(0xd0350228) = 0x12040800; // clkmode + BTDIGITAL_REG(0xd03503C8) = 0x00840CCD; // train c1c2 + BTDIGITAL_REG(0xd03503A0) = 0x1C070065; // new corr en + BTDIGITAL_REG(0xd0220460) = 0x039EF088; // mac laurent_en + BTDIGITAL_REG(0xd0350370) = 0x6B240A3D; // laurent_en 0x + BTDIGITAL_REG(0xd0350280) = 0x00000007; // bt_dfe_forcera + BTDIGITAL_REG(0xd03502C4) = 0x127F02E8; // te_timeinit + } } -void btdrv_ble_laurent_algorithm_enable(void) -{ - if(hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_0) - { - BT_DRV_TRACE(1,"%s",__func__); - BTDIGITAL_REG(0xd0350370)= 0x63240A3D;//lp disable - BTDIGITAL_REG(0xd0350280)= 0x00000007;//dfe_forceraw=0 psd_avgen=1 - } +void btdrv_ble_laurent_algorithm_enable(void) { + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_0) { + BT_DRV_TRACE(1, "%s", __func__); + BTDIGITAL_REG(0xd0350370) = 0x63240A3D; // lp disable + BTDIGITAL_REG(0xd0350280) = 0x00000007; // dfe_forceraw=0 psd_avgen=1 + } } #endif -////////////////////////////////////////test mode//////////////////////////////////////////// +////////////////////////////////////////test +/// mode//////////////////////////////////////////// - - - -void btdrv_sleep_config(uint8_t sleep_en) -{ - sleep_param[0] = sleep_en; - btdrv_send_cmd(HCI_DBG_SET_SLEEP_SETTING_CMD_OPCODE,8,sleep_param); - btdrv_delay(1); +void btdrv_sleep_config(uint8_t sleep_en) { + sleep_param[0] = sleep_en; + btdrv_send_cmd(HCI_DBG_SET_SLEEP_SETTING_CMD_OPCODE, 8, sleep_param); + btdrv_delay(1); } -void btdrv_feature_default(void) -{ - const uint8_t feature[] = {0xBF, 0xeE, 0xCD,0xFe,0xc3,0xFf,0x7b,0x87}; - btdrv_send_cmd(HCI_DBG_SET_LOCAL_FEATURE_CMD_OPCODE,8,feature); - btdrv_delay(1); +void btdrv_feature_default(void) { + const uint8_t feature[] = {0xBF, 0xeE, 0xCD, 0xFe, 0xc3, 0xFf, 0x7b, 0x87}; + btdrv_send_cmd(HCI_DBG_SET_LOCAL_FEATURE_CMD_OPCODE, 8, feature); + btdrv_delay(1); } -const uint8_t test_mode_addr[6] = {0x77,0x77,0x77,0x77,0x77,0x77}; -void btdrv_test_mode_addr_set(void) -{ - return; +const uint8_t test_mode_addr[6] = {0x77, 0x77, 0x77, 0x77, 0x77, 0x77}; +void btdrv_test_mode_addr_set(void) { + return; - btdrv_send_cmd(HCI_DBG_SET_BD_ADDR_CMD_OPCODE,sizeof(test_mode_addr),test_mode_addr); - btdrv_delay(1); + btdrv_send_cmd(HCI_DBG_SET_BD_ADDR_CMD_OPCODE, sizeof(test_mode_addr), + test_mode_addr); + btdrv_delay(1); } uint8_t meInit_param_get_entry_idx = 0; -int btdrv_meinit_param_init(void) -{ - int size = 0; - if ((me_init_param[0][0] == 0xffffffff) && - (me_init_param[0][1] == 0xffffffff)) - { - size = -1; - } - meInit_param_get_entry_idx = 0; - return size; +int btdrv_meinit_param_init(void) { + int size = 0; + if ((me_init_param[0][0] == 0xffffffff) && + (me_init_param[0][1] == 0xffffffff)) { + size = -1; + } + meInit_param_get_entry_idx = 0; + return size; } -int btdrv_meinit_param_remain_size_get(void) -{ - int remain_size; - if ((me_init_param[0][0] == 0xffffffff) && - (me_init_param[0][1] == 0xffffffff)) - { - return -1; - } - remain_size = ARRAY_SIZE(me_init_param) - meInit_param_get_entry_idx; - return remain_size; +int btdrv_meinit_param_remain_size_get(void) { + int remain_size; + if ((me_init_param[0][0] == 0xffffffff) && + (me_init_param[0][1] == 0xffffffff)) { + return -1; + } + remain_size = ARRAY_SIZE(me_init_param) - meInit_param_get_entry_idx; + return remain_size; } -int btdrv_meinit_param_next_entry_get(uint32_t *addr, uint32_t *val) -{ - if (meInit_param_get_entry_idx > (ARRAY_SIZE(me_init_param) - 1)) - return -1; - *addr = me_init_param[meInit_param_get_entry_idx][0]; - *val = me_init_param[meInit_param_get_entry_idx][1]; - meInit_param_get_entry_idx++; - return 0; +int btdrv_meinit_param_next_entry_get(uint32_t *addr, uint32_t *val) { + if (meInit_param_get_entry_idx > (ARRAY_SIZE(me_init_param) - 1)) + return -1; + *addr = me_init_param[meInit_param_get_entry_idx][0]; + *val = me_init_param[meInit_param_get_entry_idx][1]; + meInit_param_get_entry_idx++; + return 0; } -enum -{ - SYNC_IDLE, - SYNC_64_ORG, - SYNC_68_ORG, - SYNC_72_ORG, - SYNC_64_NEW, - SYNC_68_NEW, - SYNC_72_NEW, +enum { + SYNC_IDLE, + SYNC_64_ORG, + SYNC_68_ORG, + SYNC_72_ORG, + SYNC_64_NEW, + SYNC_68_NEW, + SYNC_72_NEW, }; -enum -{ - SYNC_64_BIT, - SYNC_68_BIT, - SYNC_72_BIT, +enum { + SYNC_64_BIT, + SYNC_68_BIT, + SYNC_72_BIT, }; uint32_t bt_sync_type = SYNC_IDLE; -void btdrv_sync_config(void) -{ - uint32_t corr_mode = BTDIGITAL_REG(0xd0220460); - uint32_t dfe_mode = BTDIGITAL_REG(0xd0350360); - uint32_t timeinit = BTDIGITAL_REG(0xd03502c4); - if(bt_sync_type == SYNC_IDLE) - return; +void btdrv_sync_config(void) { + uint32_t corr_mode = BTDIGITAL_REG(0xd0220460); + uint32_t dfe_mode = BTDIGITAL_REG(0xd0350360); + uint32_t timeinit = BTDIGITAL_REG(0xd03502c4); + if (bt_sync_type == SYNC_IDLE) + return; - corr_mode = (corr_mode & 0xfffffff8);//bit2: enh dfe; [1:0]: bt_corr_mode - dfe_mode = (dfe_mode & 0xffffffe0);//bit4: dfe_header_mode_bt; [3:0]: dfe_delay_cycle - timeinit = (timeinit & 0xfffff800);//[10:0]: tetimeinit value + corr_mode = (corr_mode & 0xfffffff8); // bit2: enh dfe; [1:0]: bt_corr_mode + dfe_mode = (dfe_mode & + 0xffffffe0); // bit4: dfe_header_mode_bt; [3:0]: dfe_delay_cycle + timeinit = (timeinit & 0xfffff800); //[10:0]: tetimeinit value - switch(bt_sync_type) - { - case SYNC_64_ORG: - corr_mode |= 0x0; - dfe_mode |= 0x00; - timeinit |= 0x2eb; - break; - case SYNC_68_ORG: - corr_mode |= 0x1; - dfe_mode |= 0x00; - timeinit |= 0x2eb; - break; - case SYNC_72_ORG: - corr_mode |= 0x2; - dfe_mode |= 0x00; - timeinit |= 0x2b7; - break; - case SYNC_64_NEW: - corr_mode |= 0x4; - dfe_mode |= 0x14; - timeinit |= 0x2eb; - break; - case SYNC_68_NEW: - corr_mode |= 0x5; - dfe_mode |= 0x14; - timeinit |= 0x2eb; - break; - case SYNC_72_NEW: - corr_mode |= 0x6; - dfe_mode |= 0x10; - timeinit |= 0x2b7; - break; - } - BTDIGITAL_REG(0xd0220460) = corr_mode; - BTDIGITAL_REG(0xd0350360) = dfe_mode; - BTDIGITAL_REG(0xd03502c4) = timeinit; + switch (bt_sync_type) { + case SYNC_64_ORG: + corr_mode |= 0x0; + dfe_mode |= 0x00; + timeinit |= 0x2eb; + break; + case SYNC_68_ORG: + corr_mode |= 0x1; + dfe_mode |= 0x00; + timeinit |= 0x2eb; + break; + case SYNC_72_ORG: + corr_mode |= 0x2; + dfe_mode |= 0x00; + timeinit |= 0x2b7; + break; + case SYNC_64_NEW: + corr_mode |= 0x4; + dfe_mode |= 0x14; + timeinit |= 0x2eb; + break; + case SYNC_68_NEW: + corr_mode |= 0x5; + dfe_mode |= 0x14; + timeinit |= 0x2eb; + break; + case SYNC_72_NEW: + corr_mode |= 0x6; + dfe_mode |= 0x10; + timeinit |= 0x2b7; + break; + } + BTDIGITAL_REG(0xd0220460) = corr_mode; + BTDIGITAL_REG(0xd0350360) = dfe_mode; + BTDIGITAL_REG(0xd03502c4) = timeinit; } -//HW SPI TRIG +// HW SPI TRIG -#define REG_SPI_TRIG_SELECT_LINK0_ADDR EM_BT_BT_EXT1_ADDR //114a+66 -#define REG_SPI_TRIG_SELECT_LINK1_ADDR (EM_BT_BT_EXT1_ADDR+BT_EM_SIZE) //11b8+66 +#define REG_SPI_TRIG_SELECT_LINK0_ADDR EM_BT_BT_EXT1_ADDR // 114a+66 +#define REG_SPI_TRIG_SELECT_LINK1_ADDR \ + (EM_BT_BT_EXT1_ADDR + BT_EM_SIZE) // 11b8+66 #define REG_SPI_TRIG_NUM_ADDR 0xd0220400 #define REG_SPI0_TRIG_POS_ADDR 0xd0220454 #define REG_SPI1_TRIG_POS_ADDR 0xd0220458 -struct SPI_TRIG_NUM_T -{ - uint32_t spi0_txon_num:3;//spi0 number of tx rising edge - uint32_t spi0_txoff_num:3;//spi0 number of tx falling edge - uint32_t spi0_rxon_num:2;//spi0 number of rx rising edge - uint32_t spi0_rxoff_num:2;//spi0 number of rx falling edge - uint32_t spi0_fast_mode:1; - uint32_t spi0_gap:4; - uint32_t hwspi0_en:1; - uint32_t spi1_txon_num:3;//spi1 number of tx rising edge - uint32_t spi1_txoff_num:3;//spi1 number of tx falling edge - uint32_t spi1_rxon_num:2;//spi1 number of rx rising edge - uint32_t spi1_rxoff_num:2;//spi1 number of rx falling edge - uint32_t spi1_fast_mode:1; - uint32_t spi1_gap:4; - uint32_t hwspi1_en:1; +struct SPI_TRIG_NUM_T { + uint32_t spi0_txon_num : 3; // spi0 number of tx rising edge + uint32_t spi0_txoff_num : 3; // spi0 number of tx falling edge + uint32_t spi0_rxon_num : 2; // spi0 number of rx rising edge + uint32_t spi0_rxoff_num : 2; // spi0 number of rx falling edge + uint32_t spi0_fast_mode : 1; + uint32_t spi0_gap : 4; + uint32_t hwspi0_en : 1; + uint32_t spi1_txon_num : 3; // spi1 number of tx rising edge + uint32_t spi1_txoff_num : 3; // spi1 number of tx falling edge + uint32_t spi1_rxon_num : 2; // spi1 number of rx rising edge + uint32_t spi1_rxoff_num : 2; // spi1 number of rx falling edge + uint32_t spi1_fast_mode : 1; + uint32_t spi1_gap : 4; + uint32_t hwspi1_en : 1; }; -struct SPI_TRIG_POS_T -{ - uint32_t spi_txon_pos:7; - uint32_t spi_txoff_pos:9; - uint32_t spi_rxon_pos:7; - uint32_t spi_rxoff_pos:9; +struct SPI_TRIG_POS_T { + uint32_t spi_txon_pos : 7; + uint32_t spi_txoff_pos : 9; + uint32_t spi_rxon_pos : 7; + uint32_t spi_rxoff_pos : 9; }; -struct spi_trig_data -{ - uint32_t reg; - uint32_t value; +struct spi_trig_data { + uint32_t reg; + uint32_t value; }; -static const struct spi_trig_data spi0_trig_data_tbl[] = -{ +static const struct spi_trig_data spi0_trig_data_tbl[] = { //{addr,data([23:0])} - {0xd0220404,0x8080e9},//spi0_trig_txdata1 - {0xd0220408,0x000000},//spi0_trig_txdata2 - {0xd022040c,0x000000},//spi0_trig_txdata3 - {0xd0220410,0x000000},//spi0_trig_txdata4 + {0xd0220404, 0x8080e9}, // spi0_trig_txdata1 + {0xd0220408, 0x000000}, // spi0_trig_txdata2 + {0xd022040c, 0x000000}, // spi0_trig_txdata3 + {0xd0220410, 0x000000}, // spi0_trig_txdata4 #ifdef __FA_RX_GAIN_CTRL__ - {0xd022041c,0x0094bf},//spi0_trig_rxdata1 + {0xd022041c, 0x0094bf}, // spi0_trig_rxdata1 #else - {0xd022041c,0x000000},//spi0_trig_rxdata1 + {0xd022041c, 0x000000}, // spi0_trig_rxdata1 #endif - {0xd0220420,0x000000},//spi0_trig_rxdata2 - {0xd0220424,0x000000},//spi0_trig_rxdata3 - {0xd0220428,0x000000},//spi0_trig_rxdata4 - {0xd0220414,0x000000},//spi0_trig_trxdata5 - {0xd0220418,0x000000},//spi0_trig_trxdata6 + {0xd0220420, 0x000000}, // spi0_trig_rxdata2 + {0xd0220424, 0x000000}, // spi0_trig_rxdata3 + {0xd0220428, 0x000000}, // spi0_trig_rxdata4 + {0xd0220414, 0x000000}, // spi0_trig_trxdata5 + {0xd0220418, 0x000000}, // spi0_trig_trxdata6 }; -static const struct spi_trig_data spi1_trig_data_tbl[] = -{ - //{addr,data([23:0])} +static const struct spi_trig_data spi1_trig_data_tbl[] = { +//{addr,data([23:0])} #ifdef __FA_RX_GAIN_CTRL__ - {0xd022042c,0x8080e9},//spi1_trig_txdata1 + {0xd022042c, 0x8080e9}, // spi1_trig_txdata1 #else - {0xd022042c,0x000000},//spi1_trig_txdata1 + {0xd022042c, 0x000000}, // spi1_trig_txdata1 #endif - {0xd0220430,0x000000},//spi1_trig_txdata2 - {0xd0220434,0x000000},//spi1_trig_txdata3 - {0xd0220438,0x000000},//spi1_trig_txdata4 + {0xd0220430, 0x000000}, // spi1_trig_txdata2 + {0xd0220434, 0x000000}, // spi1_trig_txdata3 + {0xd0220438, 0x000000}, // spi1_trig_txdata4 #ifdef __FA_RX_GAIN_CTRL__ - {0xd0220444,0x0094bf},//spi1_trig_rxdata1 + {0xd0220444, 0x0094bf}, // spi1_trig_rxdata1 #else - {0xd0220444,0x000000},//spi1_trig_rxdata1 + {0xd0220444, 0x000000}, // spi1_trig_rxdata1 #endif - {0xd0220448,0x000000},//spi1_trig_rxdata2 - {0xd022044c,0x000000},//spi1_trig_rxdata3 - {0xd0220450,0x000000},//spi1_trig_rxdata4 - {0xd022043c,0x000000},//spi1_trig_trxdata5 - {0xd0220440,0x000000},//spi1_trig_trxdata6 + {0xd0220448, 0x000000}, // spi1_trig_rxdata2 + {0xd022044c, 0x000000}, // spi1_trig_rxdata3 + {0xd0220450, 0x000000}, // spi1_trig_rxdata4 + {0xd022043c, 0x000000}, // spi1_trig_trxdata5 + {0xd0220440, 0x000000}, // spi1_trig_trxdata6 }; -void btdrv_spi_trig_data_change(uint8_t spi_sel, uint8_t index, uint32_t value) -{ - if(!spi_sel) - { - BTDIGITAL_REG(spi0_trig_data_tbl[index].reg) = value & 0xFFFFFF; - } - else - { - BTDIGITAL_REG(spi1_trig_data_tbl[index].reg) = value & 0xFFFFFF; - } +void btdrv_spi_trig_data_change(uint8_t spi_sel, uint8_t index, + uint32_t value) { + if (!spi_sel) { + BTDIGITAL_REG(spi0_trig_data_tbl[index].reg) = value & 0xFFFFFF; + } else { + BTDIGITAL_REG(spi1_trig_data_tbl[index].reg) = value & 0xFFFFFF; + } } -void btdrv_spi_trig_data_set(uint8_t spi_sel) -{ - if(!spi_sel) - { - for(uint8_t i = 0; i < ARRAY_SIZE(spi0_trig_data_tbl); i++) - { - BTDIGITAL_REG(spi0_trig_data_tbl[i].reg) = spi0_trig_data_tbl[i].value; - } +void btdrv_spi_trig_data_set(uint8_t spi_sel) { + if (!spi_sel) { + for (uint8_t i = 0; i < ARRAY_SIZE(spi0_trig_data_tbl); i++) { + BTDIGITAL_REG(spi0_trig_data_tbl[i].reg) = spi0_trig_data_tbl[i].value; } - else - { - for(uint8_t i = 0; i < ARRAY_SIZE(spi1_trig_data_tbl); i++) - { - BTDIGITAL_REG(spi1_trig_data_tbl[i].reg) = spi1_trig_data_tbl[i].value; - } + } else { + for (uint8_t i = 0; i < ARRAY_SIZE(spi1_trig_data_tbl); i++) { + BTDIGITAL_REG(spi1_trig_data_tbl[i].reg) = spi1_trig_data_tbl[i].value; } + } } -void btdrv_spi_trig_num_set(uint8_t spi_sel, struct SPI_TRIG_NUM_T *spi_trig_num) -{ - uint8_t tx_onoff_total_num; - uint8_t rx_onoff_total_num; +void btdrv_spi_trig_num_set(uint8_t spi_sel, + struct SPI_TRIG_NUM_T *spi_trig_num) { + uint8_t tx_onoff_total_num; + uint8_t rx_onoff_total_num; - if(!spi_sel) - { - tx_onoff_total_num = spi_trig_num->spi0_txon_num + spi_trig_num->spi0_txoff_num; - rx_onoff_total_num = spi_trig_num->spi0_rxon_num + spi_trig_num->spi0_rxoff_num; - } - else - { - tx_onoff_total_num = spi_trig_num->spi1_txon_num + spi_trig_num->spi1_txoff_num; - rx_onoff_total_num = spi_trig_num->spi1_rxon_num + spi_trig_num->spi1_rxoff_num; - } - ASSERT((tx_onoff_total_num <= 6), "spi trig tx_onoff_total_num>6"); - ASSERT((rx_onoff_total_num <= 6), "spi trig rx_onoff_total_num>6"); + if (!spi_sel) { + tx_onoff_total_num = + spi_trig_num->spi0_txon_num + spi_trig_num->spi0_txoff_num; + rx_onoff_total_num = + spi_trig_num->spi0_rxon_num + spi_trig_num->spi0_rxoff_num; + } else { + tx_onoff_total_num = + spi_trig_num->spi1_txon_num + spi_trig_num->spi1_txoff_num; + rx_onoff_total_num = + spi_trig_num->spi1_rxon_num + spi_trig_num->spi1_rxoff_num; + } + ASSERT((tx_onoff_total_num <= 6), "spi trig tx_onoff_total_num>6"); + ASSERT((rx_onoff_total_num <= 6), "spi trig rx_onoff_total_num>6"); - BTDIGITAL_REG(REG_SPI_TRIG_NUM_ADDR) = *(uint32_t *)spi_trig_num; + BTDIGITAL_REG(REG_SPI_TRIG_NUM_ADDR) = *(uint32_t *)spi_trig_num; } -void btdrv_spi_trig_pos_set(uint8_t spi_sel, struct SPI_TRIG_POS_T *spi_trig_pos) -{ - if(!spi_sel) - { - BTDIGITAL_REG(REG_SPI0_TRIG_POS_ADDR) = *(uint32_t *)spi_trig_pos; - } - else - { - BTDIGITAL_REG(REG_SPI1_TRIG_POS_ADDR) = *(uint32_t *)spi_trig_pos; - } +void btdrv_spi_trig_pos_set(uint8_t spi_sel, + struct SPI_TRIG_POS_T *spi_trig_pos) { + if (!spi_sel) { + BTDIGITAL_REG(REG_SPI0_TRIG_POS_ADDR) = *(uint32_t *)spi_trig_pos; + } else { + BTDIGITAL_REG(REG_SPI1_TRIG_POS_ADDR) = *(uint32_t *)spi_trig_pos; + } } #ifdef __FA_RX_GAIN_CTRL__ -void btdrv_spi_trig_init(void) -{ - struct SPI_TRIG_NUM_T spi_trig_num; - struct SPI_TRIG_POS_T spi0_trig_pos; - struct SPI_TRIG_POS_T spi1_trig_pos; +void btdrv_spi_trig_init(void) { + struct SPI_TRIG_NUM_T spi_trig_num; + struct SPI_TRIG_POS_T spi0_trig_pos; + struct SPI_TRIG_POS_T spi1_trig_pos; - spi_trig_num.spi0_txon_num = 0; - spi_trig_num.spi0_txoff_num = 0; - spi_trig_num.spi0_rxon_num = 1; - spi_trig_num.spi0_rxoff_num = 0; - spi_trig_num.spi0_fast_mode = 0; - spi_trig_num.spi0_gap = 4; - spi_trig_num.hwspi0_en = 1; + spi_trig_num.spi0_txon_num = 0; + spi_trig_num.spi0_txoff_num = 0; + spi_trig_num.spi0_rxon_num = 1; + spi_trig_num.spi0_rxoff_num = 0; + spi_trig_num.spi0_fast_mode = 0; + spi_trig_num.spi0_gap = 4; + spi_trig_num.hwspi0_en = 1; - spi_trig_num.spi1_txon_num = 0; - spi_trig_num.spi1_txoff_num = 1; - spi_trig_num.spi1_rxon_num = 1; - spi_trig_num.spi1_rxoff_num = 0; - spi_trig_num.spi1_fast_mode = 0; - spi_trig_num.spi1_gap = 4; - spi_trig_num.hwspi1_en = 1; + spi_trig_num.spi1_txon_num = 0; + spi_trig_num.spi1_txoff_num = 1; + spi_trig_num.spi1_rxon_num = 1; + spi_trig_num.spi1_rxoff_num = 0; + spi_trig_num.spi1_fast_mode = 0; + spi_trig_num.spi1_gap = 4; + spi_trig_num.hwspi1_en = 1; - btdrv_spi_trig_num_set(0,&spi_trig_num); - btdrv_spi_trig_num_set(1,&spi_trig_num); + btdrv_spi_trig_num_set(0, &spi_trig_num); + btdrv_spi_trig_num_set(1, &spi_trig_num); - spi0_trig_pos.spi_txon_pos = 0; - spi0_trig_pos.spi_txoff_pos = 0; - spi0_trig_pos.spi_rxon_pos = 25; - spi0_trig_pos.spi_rxoff_pos = 0; + spi0_trig_pos.spi_txon_pos = 0; + spi0_trig_pos.spi_txoff_pos = 0; + spi0_trig_pos.spi_rxon_pos = 25; + spi0_trig_pos.spi_rxoff_pos = 0; - spi1_trig_pos.spi_txon_pos = 0; - spi1_trig_pos.spi_txoff_pos = 0; - spi1_trig_pos.spi_rxon_pos = 110; - spi1_trig_pos.spi_rxoff_pos = 0; + spi1_trig_pos.spi_txon_pos = 0; + spi1_trig_pos.spi_txoff_pos = 0; + spi1_trig_pos.spi_rxon_pos = 110; + spi1_trig_pos.spi_rxoff_pos = 0; - btdrv_spi_trig_pos_set(0,&spi0_trig_pos); - btdrv_spi_trig_pos_set(1,&spi1_trig_pos); + btdrv_spi_trig_pos_set(0, &spi0_trig_pos); + btdrv_spi_trig_pos_set(1, &spi1_trig_pos); - btdrv_spi_trig_data_set(0); - btdrv_spi_trig_data_set(1); + btdrv_spi_trig_data_set(0); + btdrv_spi_trig_data_set(1); } #else -void btdrv_spi_trig_init(void) -{ - struct SPI_TRIG_NUM_T spi_trig_num; - struct SPI_TRIG_POS_T spi0_trig_pos; - struct SPI_TRIG_POS_T spi1_trig_pos; +void btdrv_spi_trig_init(void) { + struct SPI_TRIG_NUM_T spi_trig_num; + struct SPI_TRIG_POS_T spi0_trig_pos; + struct SPI_TRIG_POS_T spi1_trig_pos; - spi_trig_num.spi0_txon_num = 0; - spi_trig_num.spi0_txoff_num = 1; - spi_trig_num.spi0_rxon_num = 0; - spi_trig_num.spi0_rxoff_num = 0; - spi_trig_num.spi0_fast_mode = 0; - spi_trig_num.spi0_gap = 4; - spi_trig_num.hwspi0_en = 0; + spi_trig_num.spi0_txon_num = 0; + spi_trig_num.spi0_txoff_num = 1; + spi_trig_num.spi0_rxon_num = 0; + spi_trig_num.spi0_rxoff_num = 0; + spi_trig_num.spi0_fast_mode = 0; + spi_trig_num.spi0_gap = 4; + spi_trig_num.hwspi0_en = 0; - spi_trig_num.spi1_txon_num = 0; - spi_trig_num.spi1_txoff_num = 0; - spi_trig_num.spi1_rxon_num = 0; - spi_trig_num.spi1_rxoff_num = 0; - spi_trig_num.spi1_fast_mode = 0; - spi_trig_num.spi1_gap = 0; - spi_trig_num.hwspi1_en = 0; + spi_trig_num.spi1_txon_num = 0; + spi_trig_num.spi1_txoff_num = 0; + spi_trig_num.spi1_rxon_num = 0; + spi_trig_num.spi1_rxoff_num = 0; + spi_trig_num.spi1_fast_mode = 0; + spi_trig_num.spi1_gap = 0; + spi_trig_num.hwspi1_en = 0; - btdrv_spi_trig_num_set(0,&spi_trig_num); - btdrv_spi_trig_num_set(1,&spi_trig_num); + btdrv_spi_trig_num_set(0, &spi_trig_num); + btdrv_spi_trig_num_set(1, &spi_trig_num); - spi0_trig_pos.spi_txon_pos = 0; - spi0_trig_pos.spi_txoff_pos = 20; - spi0_trig_pos.spi_rxon_pos = 0; - spi0_trig_pos.spi_rxoff_pos = 0; + spi0_trig_pos.spi_txon_pos = 0; + spi0_trig_pos.spi_txoff_pos = 20; + spi0_trig_pos.spi_rxon_pos = 0; + spi0_trig_pos.spi_rxoff_pos = 0; - spi1_trig_pos.spi_txon_pos = 0; - spi1_trig_pos.spi_txoff_pos = 0; - spi1_trig_pos.spi_rxon_pos = 0; - spi1_trig_pos.spi_rxoff_pos = 0; + spi1_trig_pos.spi_txon_pos = 0; + spi1_trig_pos.spi_txoff_pos = 0; + spi1_trig_pos.spi_rxon_pos = 0; + spi1_trig_pos.spi_rxoff_pos = 0; - btdrv_spi_trig_pos_set(0,&spi0_trig_pos); - btdrv_spi_trig_pos_set(1,&spi1_trig_pos); + btdrv_spi_trig_pos_set(0, &spi0_trig_pos); + btdrv_spi_trig_pos_set(1, &spi1_trig_pos); - btdrv_spi_trig_data_set(0); - btdrv_spi_trig_data_set(1); + btdrv_spi_trig_data_set(0); + btdrv_spi_trig_data_set(1); } #endif -void btdrv_spi_trig_select(uint8_t link_id, bool spi_set) -{ - BTDIGITAL_BT_EM(EM_BT_BT_EXT1_ADDR+link_id*BT_EM_SIZE) |= (spi_set<<14); +void btdrv_spi_trig_select(uint8_t link_id, bool spi_set) { + BTDIGITAL_BT_EM(EM_BT_BT_EXT1_ADDR + link_id * BT_EM_SIZE) |= (spi_set << 14); } -uint8_t btdrv_get_spi_trig_enable(uint8_t spi_sel) -{ - if(!spi_sel) - { - return ((BTDIGITAL_REG(REG_SPI_TRIG_NUM_ADDR) & 0x8000) >> 15); - } - else - { - return ((BTDIGITAL_REG(REG_SPI_TRIG_NUM_ADDR) & 0x80000000) >> 31); - } +uint8_t btdrv_get_spi_trig_enable(uint8_t spi_sel) { + if (!spi_sel) { + return ((BTDIGITAL_REG(REG_SPI_TRIG_NUM_ADDR) & 0x8000) >> 15); + } else { + return ((BTDIGITAL_REG(REG_SPI_TRIG_NUM_ADDR) & 0x80000000) >> 31); + } } -void btdrv_set_spi_trig_enable(uint8_t spi_sel) -{ - if(!spi_sel) - { - BTDIGITAL_REG(REG_SPI_TRIG_NUM_ADDR) |= (1<<15);//spi0 - } - else - { - BTDIGITAL_REG(REG_SPI_TRIG_NUM_ADDR) |= (1<<31);//spi1 - } +void btdrv_set_spi_trig_enable(uint8_t spi_sel) { + if (!spi_sel) { + BTDIGITAL_REG(REG_SPI_TRIG_NUM_ADDR) |= (1 << 15); // spi0 + } else { + BTDIGITAL_REG(REG_SPI_TRIG_NUM_ADDR) |= (1 << 31); // spi1 + } } -void btdrv_clear_spi_trig_enable(uint8_t spi_sel) -{ - if(!spi_sel) - { - BTDIGITAL_REG(REG_SPI_TRIG_NUM_ADDR) &= ~0x8000; - } - else - { - BTDIGITAL_REG(REG_SPI_TRIG_NUM_ADDR) &= ~0x80000000; - } +void btdrv_clear_spi_trig_enable(uint8_t spi_sel) { + if (!spi_sel) { + BTDIGITAL_REG(REG_SPI_TRIG_NUM_ADDR) &= ~0x8000; + } else { + BTDIGITAL_REG(REG_SPI_TRIG_NUM_ADDR) &= ~0x80000000; + } } -bool btdrv_get_lmp_trace_enable(void) -{ - return g_lmp_trace_enable; -} -void btdrv_set_lmp_trace_enable(void) -{ - g_lmp_trace_enable = true; -} -void btdrv_set_controller_trace_enable(uint8_t trace_level) -{ - g_controller_trace_level = trace_level; +bool btdrv_get_lmp_trace_enable(void) { return g_lmp_trace_enable; } +void btdrv_set_lmp_trace_enable(void) { g_lmp_trace_enable = true; } +void btdrv_set_controller_trace_enable(uint8_t trace_level) { + g_controller_trace_level = trace_level; } -uint8_t btdrv_get_controller_trace_level(void) -{ - return g_controller_trace_level; +uint8_t btdrv_get_controller_trace_level(void) { + return g_controller_trace_level; } -void btdrv_fast_lock_config(bool fastlock_on) -{ - uint16_t val = 0; +void btdrv_fast_lock_config(bool fastlock_on) { + uint16_t val = 0; - if (fastlock_on){ - btdrv_read_rf_reg(0x1AE, &val); - btdrv_write_rf_reg(0x1AE, val | (1 << 9) | (1 << 11)); - BTDIGITAL_REG(0xd0220468) |= 1 << 26; //fast lock enable - }else{ - btdrv_read_rf_reg(0x1AE, &val); - btdrv_write_rf_reg(0x1AE, val & (~((1 << 9) | (1 << 11)))); - BTDIGITAL_REG(0xd0220468) &= (~(1 << 26)); //fast lock disable - } + if (fastlock_on) { + btdrv_read_rf_reg(0x1AE, &val); + btdrv_write_rf_reg(0x1AE, val | (1 << 9) | (1 << 11)); + BTDIGITAL_REG(0xd0220468) |= 1 << 26; // fast lock enable + } else { + btdrv_read_rf_reg(0x1AE, &val); + btdrv_write_rf_reg(0x1AE, val & (~((1 << 9) | (1 << 11)))); + BTDIGITAL_REG(0xd0220468) &= (~(1 << 26)); // fast lock disable + } } #ifdef __FASTACK_ECC_ENABLE__ -void btdrv_ecc_config(void) -{ - #define INVALID 0xff - #define ECC_8PSK 0 - #define ECC_DPSK 1 - #define ECC_GFSK 2 +void btdrv_ecc_config(void) { +#define INVALID 0xff +#define ECC_8PSK 0 +#define ECC_DPSK 1 +#define ECC_GFSK 2 - #define ECC_1BLOCK 0 - #define ECC_2BLOCK 1 - #define ECC_3BLOCK 2 +#define ECC_1BLOCK 0 +#define ECC_2BLOCK 1 +#define ECC_3BLOCK 2 - const uint32_t fa_2m = 0; - const uint32_t fastlock_on = 0; - const uint32_t bt_sys_52m_en = 0; - const uint32_t ecc_mode_enable = 0; - const uint32_t ecc_psk_mode = ECC_DPSK; - const uint32_t ecc_blk_mode = ECC_3BLOCK; + const uint32_t fa_2m = 0; + const uint32_t fastlock_on = 0; + const uint32_t bt_sys_52m_en = 0; + const uint32_t ecc_mode_enable = 0; + const uint32_t ecc_psk_mode = ECC_DPSK; + const uint32_t ecc_blk_mode = ECC_3BLOCK; - if (bt_sys_52m_en){ - BTDIGITAL_REG(0x4008003c) |= 1; - BTDIGITAL_REG(0x40080018) |= 1; - BTDIGITAL_REG(0x40080004) |= (1 << 15) | (1 << 30); //osc x4 enable - BTDIGITAL_REG(0xd0330038) |= (3 << 6) | (1 << 11); - BTDIGITAL_REG(0xd03300f0) |= 1; + if (bt_sys_52m_en) { + BTDIGITAL_REG(0x4008003c) |= 1; + BTDIGITAL_REG(0x40080018) |= 1; + BTDIGITAL_REG(0x40080004) |= (1 << 15) | (1 << 30); // osc x4 enable + BTDIGITAL_REG(0xd0330038) |= (3 << 6) | (1 << 11); + BTDIGITAL_REG(0xd03300f0) |= 1; + } + + if (fa_2m) { + BTDIGITAL_REG(0xd0220464) |= 1 << 29; // fast ack 2M mode enable 1, disable + // 0 + } else { + BTDIGITAL_REG(0xd0220464) &= + (~(1 << 29)); // fast ack 2M mode enable 1, disable 0 + } + + // 1302: RF 0x1AE[9] = 1; + // 1402: RF 0x64[15] = 1; + + BTDIGITAL_REG(0xd0330038) |= (1 << 9); // jiangpeng test result ok + btdrv_fast_lock_config(fastlock_on); + if (fastlock_on) { + if (fa_2m) + BTDIGITAL_REG_SET_FIELD(0xd0220468, 0xffff, 0, 0x1914); + else + BTDIGITAL_REG_SET_FIELD(0xd0220468, 0xffff, 0, 0x1e14); + } else { + if (fa_2m) + BTDIGITAL_REG_SET_FIELD(0xd0220468, 0xffff, 0, 0x3530); + else + BTDIGITAL_REG_SET_FIELD(0xd0220468, 0xffff, 0, 0x3528); + } + + if (ecc_mode_enable) { + BTDIGITAL_REG(0xd0220464) |= (0x1 << 15); ////enable ecc mode + BTDIGITAL_REG(0xd0220464) &= ~(0x1F << 24); // ecc time adj + BTDIGITAL_REG(0xd0220464) |= (0x1 << 25); ////en ecc time adj + + if (ecc_psk_mode == ECC_8PSK) { + BTDIGITAL_REG_SET_FIELD(0xd02204a8, 3, 13, 3); // ECC 8PSK + } else if (ecc_psk_mode == ECC_DPSK) { + BTDIGITAL_REG_SET_FIELD(0xd02204a8, 3, 13, 2); // ECC DPSK + } else if (ecc_psk_mode == ECC_GFSK) { + BTDIGITAL_REG_SET_FIELD(0xd02204a8, 3, 13, 1); // ECC GFSK } - if (fa_2m){ - BTDIGITAL_REG(0xd0220464) |= 1 << 29; //fast ack 2M mode enable 1, disable 0 - } - else{ - BTDIGITAL_REG(0xd0220464) &= (~(1 << 29)); //fast ack 2M mode enable 1, disable 0 - } - - //1302: RF 0x1AE[9] = 1; - //1402: RF 0x64[15] = 1; - - BTDIGITAL_REG(0xd0330038) |= (1 << 9); //jiangpeng test result ok - btdrv_fast_lock_config(fastlock_on); - if (fastlock_on){ - if (fa_2m) - BTDIGITAL_REG_SET_FIELD(0xd0220468, 0xffff, 0, 0x1914); - else - BTDIGITAL_REG_SET_FIELD(0xd0220468, 0xffff, 0, 0x1e14); - } - else{ - if (fa_2m) - BTDIGITAL_REG_SET_FIELD(0xd0220468, 0xffff, 0, 0x3530); - else - BTDIGITAL_REG_SET_FIELD(0xd0220468, 0xffff, 0, 0x3528); - } - - if (ecc_mode_enable){ - BTDIGITAL_REG(0xd0220464) |= (0x1 << 15); ////enable ecc mode - BTDIGITAL_REG(0xd0220464) &= ~(0x1F << 24); //ecc time adj - BTDIGITAL_REG(0xd0220464) |= (0x1 << 25); ////en ecc time adj - - if (ecc_psk_mode == ECC_8PSK){ - BTDIGITAL_REG_SET_FIELD(0xd02204a8, 3, 13, 3); //ECC 8PSK - } - else if (ecc_psk_mode == ECC_DPSK){ - BTDIGITAL_REG_SET_FIELD(0xd02204a8, 3, 13, 2); //ECC DPSK - } - else if (ecc_psk_mode == ECC_GFSK){ - BTDIGITAL_REG_SET_FIELD(0xd02204a8, 3, 13, 1); //ECC GFSK - } - - if (ecc_blk_mode == ECC_1BLOCK){ - BTDIGITAL_REG(0xd022048c) &= ~0x3ff; - BTDIGITAL_REG(0xd022048c) |= 0xef; //set ecc len ECC 1 block - } - else if (ecc_blk_mode == ECC_2BLOCK){ - BTDIGITAL_REG(0xd022048c) &= ~0x3ff; - BTDIGITAL_REG(0xd022048c) |= 0x1de; //set ecc len, ECC 2 block - } - else if (ecc_blk_mode == ECC_3BLOCK){ - BTDIGITAL_REG(0xd022048c) &= ~0x3ff; - BTDIGITAL_REG(0xd022048c) |= 0x2cd; //set ecc len ECC 3 block - } - } - else{ - BTDIGITAL_REG(0xd0220464) &= (~(0x1 << 15)); ////disable ecc mode + if (ecc_blk_mode == ECC_1BLOCK) { + BTDIGITAL_REG(0xd022048c) &= ~0x3ff; + BTDIGITAL_REG(0xd022048c) |= 0xef; // set ecc len ECC 1 block + } else if (ecc_blk_mode == ECC_2BLOCK) { + BTDIGITAL_REG(0xd022048c) &= ~0x3ff; + BTDIGITAL_REG(0xd022048c) |= 0x1de; // set ecc len, ECC 2 block + } else if (ecc_blk_mode == ECC_3BLOCK) { + BTDIGITAL_REG(0xd022048c) &= ~0x3ff; + BTDIGITAL_REG(0xd022048c) |= 0x2cd; // set ecc len ECC 3 block } + } else { + BTDIGITAL_REG(0xd0220464) &= (~(0x1 << 15)); ////disable ecc mode + } } #endif -void btdrv_hw_agc_stop_mode(enum BT_SYNCMODE_REQ_USER_T user, bool hw_agc_mode) -{ +void btdrv_hw_agc_stop_mode(enum BT_SYNCMODE_REQ_USER_T user, + bool hw_agc_mode) { #ifdef __HW_AGC__ - static uint8_t bt_syncmode_map = 0; + static uint8_t bt_syncmode_map = 0; - uint32_t lock; + uint32_t lock; - lock = int_lock(); - uint32_t reg_val = BTDIGITAL_REG(0xd03503a8); + lock = int_lock(); + uint32_t reg_val = BTDIGITAL_REG(0xd03503a8); - if (hw_agc_mode) { - if (bt_syncmode_map == 0) { - //set bit28 0 : rx win timeout, stop agc - reg_val &= ~(1 << 28); - BTDIGITAL_REG(0xd03503a8) = reg_val; - } - bt_syncmode_map |= (1 << user); - } else { - bt_syncmode_map &= ~(1 << user); - if (bt_syncmode_map == 0) { - //set bit28 1 : sync find, stop agc - reg_val |= (1 << 28); - BTDIGITAL_REG(0xd03503a8) = reg_val; - } + if (hw_agc_mode) { + if (bt_syncmode_map == 0) { + // set bit28 0 : rx win timeout, stop agc + reg_val &= ~(1 << 28); + BTDIGITAL_REG(0xd03503a8) = reg_val; } - int_unlock(lock); + bt_syncmode_map |= (1 << user); + } else { + bt_syncmode_map &= ~(1 << user); + if (bt_syncmode_map == 0) { + // set bit28 1 : sync find, stop agc + reg_val |= (1 << 28); + BTDIGITAL_REG(0xd03503a8) = reg_val; + } + } + int_unlock(lock); #endif } diff --git a/platform/drivers/bt/best2300p/bt_drv_patch.c b/platform/drivers/bt/best2300p/bt_drv_patch.c index 7ddcfd7..35cffd1 100644 --- a/platform/drivers/bt/best2300p/bt_drv_patch.c +++ b/platform/drivers/bt/best2300p/bt_drv_patch.c @@ -13,45 +13,45 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" +#include "bt_drv.h" +#include "bt_drv_2300p_internal.h" +#include "bt_drv_interface.h" +#include "hal_chipid.h" #include "hal_i2c.h" #include "hal_uart.h" -#include "hal_chipid.h" -#include "bt_drv.h" -#include "bt_drv_interface.h" -#include "bt_drv_2300p_internal.h" +#include "plat_types.h" -extern void btdrv_write_memory(uint8_t wr_type,uint32_t address,const uint8_t *value,uint8_t length); +extern void btdrv_write_memory(uint8_t wr_type, uint32_t address, + const uint8_t *value, uint8_t length); -///enable m4 patch func -#define BTDRV_PATCH_EN_REG 0xe0002000 +/// enable m4 patch func +#define BTDRV_PATCH_EN_REG 0xe0002000 -//set m4 patch remap adress -#define BTDRV_PATCH_REMAP_REG 0xe0002004 +// set m4 patch remap adress +#define BTDRV_PATCH_REMAP_REG 0xe0002004 -//instruction patch compare src address -#define BTDRV_PATCH_INS_COMP_ADDR_START 0xe0002008 +// instruction patch compare src address +#define BTDRV_PATCH_INS_COMP_ADDR_START 0xe0002008 -#define BTDRV_PATCH_INS_REMAP_ADDR_START 0xc0000100 +#define BTDRV_PATCH_INS_REMAP_ADDR_START 0xc0000100 -//data patch compare src address -#define BTDRV_PATCH_DATA_COMP_ADDR_START 0xe00020e8 +// data patch compare src address +#define BTDRV_PATCH_DATA_COMP_ADDR_START 0xe00020e8 -#define BTDRV_PATCH_DATA_REMAP_ADDR_START 0xc00001e0 +#define BTDRV_PATCH_DATA_REMAP_ADDR_START 0xc00001e0 +#define BTDRV_PATCH_ACT 0x1 +#define BTDRV_PATCH_INACT 0x0 -#define BTDRV_PATCH_ACT 0x1 -#define BTDRV_PATCH_INACT 0x0 - -typedef struct -{ - uint8_t patch_index; //patch position - uint8_t patch_state; //is patch active - uint16_t patch_length; //patch length 0:one instrution replace other:jump to ram to run more instruction - uint32_t patch_remap_address; //patch occured address - uint32_t patch_remap_value; //patch replaced instuction - uint32_t patch_start_address; //ram patch address for lenth>0 - uint8_t *patch_data; //ram patch date for length >0 +typedef struct { + uint8_t patch_index; // patch position + uint8_t patch_state; // is patch active + uint16_t patch_length; // patch length 0:one instrution replace other:jump to + // ram to run more instruction + uint32_t patch_remap_address; // patch occured address + uint32_t patch_remap_value; // patch replaced instuction + uint32_t patch_start_address; // ram patch address for lenth>0 + uint8_t *patch_data; // ram patch date for length >0 } BTDRV_PATCH_STRUCT; @@ -109,298 +109,210 @@ typedef struct ****************************************************************************/ //#define BT_CONTROLLER_DEBUG 1 -const uint32_t bes2300p_patch0_ibrt_ins_data_t3[] = -{ - 0x400fe92d, /*0xc0007758L*/ - 0xf0004630, /*0xc000775cL*/ - 0xe8bdf805, /*0xc0007760L*/ - 0xf634400f, /*0xc0007764L*/ - 0x0000bb51, /*0xc0007768L*/ - 0x4604b510, /*0xc000776cL*/ - 0x47984b0c, /*0xc0007770L*/ - 0x60184b0c, /*0xc0007774L*/ - 0x781b3304, /*0xc0007778L*/ - 0x2b03b2db, /*0xc000777cL*/ - 0x2c02d005, /*0xc0007780L*/ - 0x2c10d009, /*0xc0007784L*/ - 0x2004d10a, /*0xc0007788L*/ - 0x4b07e006, /*0xc000778cL*/ - 0xb2db781b, /*0xc0007790L*/ - 0x70134a06, /*0xc0007794L*/ - 0x2002e7f3, /*0xc0007798L*/ - 0x47984b05, /*0xc000779cL*/ - 0xbf00bd10, /*0xc00077a0L*/ - 0xa0026ded, /*0xc00077a4L*/ - 0xc000653c, /*0xc00077a8L*/ - 0xc00064da, /*0xc00077acL*/ - 0xc0006541, /*0xc00077b0L*/ - 0xa003bcc1, /*0xc00077b4L*/ +const uint32_t bes2300p_patch0_ibrt_ins_data_t3[] = { + 0x400fe92d, /*0xc0007758L*/ + 0xf0004630, /*0xc000775cL*/ + 0xe8bdf805, /*0xc0007760L*/ + 0xf634400f, /*0xc0007764L*/ + 0x0000bb51, /*0xc0007768L*/ + 0x4604b510, /*0xc000776cL*/ + 0x47984b0c, /*0xc0007770L*/ + 0x60184b0c, /*0xc0007774L*/ + 0x781b3304, /*0xc0007778L*/ + 0x2b03b2db, /*0xc000777cL*/ + 0x2c02d005, /*0xc0007780L*/ + 0x2c10d009, /*0xc0007784L*/ + 0x2004d10a, /*0xc0007788L*/ + 0x4b07e006, /*0xc000778cL*/ + 0xb2db781b, /*0xc0007790L*/ + 0x70134a06, /*0xc0007794L*/ + 0x2002e7f3, /*0xc0007798L*/ + 0x47984b05, /*0xc000779cL*/ + 0xbf00bd10, /*0xc00077a0L*/ + 0xa0026ded, /*0xc00077a4L*/ + 0xc000653c, /*0xc00077a8L*/ + 0xc00064da, /*0xc00077acL*/ + 0xc0006541, /*0xc00077b0L*/ + 0xa003bcc1, /*0xc00077b4L*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch0 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch0 = { 0, BTDRV_PATCH_ACT, sizeof(bes2300p_patch0_ibrt_ins_data_t3), 0x0003bdc0, 0xbccaf1cb, 0xc0007758, - (uint8_t *)bes2300p_patch0_ibrt_ins_data_t3 -};//ibrt sco auto accept (slave) + (uint8_t *) + bes2300p_patch0_ibrt_ins_data_t3}; // ibrt sco auto accept (slave) -const uint32_t bes2300p_patch1_ibrt_ins_data_t3[] = -{ - 0x681b4b08, - 0xf632b933, - 0x2800ffdb, - 0x2001bf0c, - 0xe0002004, - 0xf6352001, - 0x2000f84d, - 0x60184b01, - 0xb809f60a, - 0xc0007434,/*6c30*/ +const uint32_t bes2300p_patch1_ibrt_ins_data_t3[] = { + 0x681b4b08, 0xf632b933, 0x2800ffdb, 0x2001bf0c, 0xe0002004, + 0xf6352001, 0x2000f84d, 0x60184b01, 0xb809f60a, 0xc0007434, /*6c30*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch1 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch1 = { 1, BTDRV_PATCH_ACT, sizeof(bes2300p_patch1_ibrt_ins_data_t3), 0x00010c3c, 0xbfe6f1f5, 0xc0006c0c, - (uint8_t *)bes2300p_patch1_ibrt_ins_data_t3 -};//ibrt sco auto accept (master) + (uint8_t *) + bes2300p_patch1_ibrt_ins_data_t3}; // ibrt sco auto accept (master) -const uint32_t bes2300p_patch2_ibrt_ins_data_t3[] = -{ - 0x4b04b508, - 0x2b01681b, - 0x2001d102, - 0xfb00f5fa, - 0xbf00bd08, - 0xc0007668, - 0xfd56f60d, - 0xfff0f7ff, - 0xbe7af60f,/*6c58*/ +const uint32_t bes2300p_patch2_ibrt_ins_data_t3[] = { + 0x4b04b508, 0x2b01681b, 0x2001d102, 0xfb00f5fa, 0xbf00bd08, + 0xc0007668, 0xfd56f60d, 0xfff0f7ff, 0xbe7af60f, /*6c58*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch2 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch2 = { 2, BTDRV_PATCH_ACT, sizeof(bes2300p_patch2_ibrt_ins_data_t3), 0x0001694c, 0xb980f1f0, 0xc0006c38, - (uint8_t *)bes2300p_patch2_ibrt_ins_data_t3 -};// tws unsniff update ke state + (uint8_t *)bes2300p_patch2_ibrt_ins_data_t3}; // tws unsniff update ke state -const uint32_t bes2300p_patch3_ibrt_ins_data_t3[] = -{ - 0xbf004628, - 0xfdc4f60d, - 0x21144628, - 0xba4af60f,/*6c94*/ +const uint32_t bes2300p_patch3_ibrt_ins_data_t3[] = { + 0xbf004628, 0xfdc4f60d, 0x21144628, 0xba4af60f, /*6c94*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch3 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch3 = { 3, BTDRV_PATCH_ACT, sizeof(bes2300p_patch3_ibrt_ins_data_t3), 0x00016128, 0xbdaef1f0, 0xc0006c88, - (uint8_t *)bes2300p_patch3_ibrt_ins_data_t3 -};//start lmp to before sending LMP_HostConnectionReq + (uint8_t *)bes2300p_patch3_ibrt_ins_data_t3}; // start lmp to before sending + // LMP_HostConnectionReq -const uint32_t bes2300p_patch4_ibrt_ins_data_t3[] = -{ - 0xf633b940,/*69b8*/ - 0x2801f86d, - 0xf633d104, - 0x2800f903, - 0xbf00d102, - 0xbd84f62b, - 0xbe02f62b,/*69d0*/ +const uint32_t bes2300p_patch4_ibrt_ins_data_t3[] = { + 0xf633b940, /*69b8*/ + 0x2801f86d, 0xf633d104, 0x2800f903, + 0xbf00d102, 0xbd84f62b, 0xbe02f62b, /*69d0*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch4 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch4 = { 4, BTDRV_PATCH_ACT, sizeof(bes2300p_patch4_ibrt_ins_data_t3), 0x000324d4, 0xba70f1d4, 0xc00069b8, - (uint8_t *)bes2300p_patch4_ibrt_ins_data_t3 -};//filter afh map + (uint8_t *)bes2300p_patch4_ibrt_ins_data_t3}; // filter afh map -const uint32_t bes2300p_patch5_ibrt_ins_data_t3[] = -{ - 0x79ab4688,/*69d4*/ - 0x6383ea6f, - 0x4578f023, - 0xf8d39b09, - 0x9906308c, - 0x402b440b, - 0xbf004641, - 0xb8bdf62d,/*69f0*/ +const uint32_t bes2300p_patch5_ibrt_ins_data_t3[] = { + 0x79ab4688, /*69d4*/ + 0x6383ea6f, 0x4578f023, 0xf8d39b09, 0x9906308c, + 0x402b440b, 0xbf004641, 0xb8bdf62d, /*69f0*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch5 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch5 = { 5, BTDRV_PATCH_ACT, sizeof(bes2300p_patch5_ibrt_ins_data_t3), 0x00033b60, 0xbf38f1d2, 0xc00069d4, - (uint8_t *)bes2300p_patch5_ibrt_ins_data_t3 -};//sco param init + (uint8_t *)bes2300p_patch5_ibrt_ins_data_t3}; // sco param init -const uint32_t bes2300p_patch6_ibrt_ins_data_t3[] = -{ - 0x4a033304,/*69f8*/ - 0xbf008153, - 0x12c4f640, - 0xbeb9f632, - 0xc00062c0,/*6a08*/ +const uint32_t bes2300p_patch6_ibrt_ins_data_t3[] = { + 0x4a033304, /*69f8*/ + 0xbf008153, 0x12c4f640, 0xbeb9f632, 0xc00062c0, /*6a08*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch6 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch6 = { 6, BTDRV_PATCH_ACT, sizeof(bes2300p_patch6_ibrt_ins_data_t3), 0x00039770, 0xb942f1cd, 0xc00069f8, - (uint8_t *)bes2300p_patch6_ibrt_ins_data_t3 -};//pscan duration + (uint8_t *)bes2300p_patch6_ibrt_ins_data_t3}; // pscan duration -const uint32_t bes2300p_patch7_ibrt_ins_data_t3[] = -{ - 0x71ab2300,/*6a10*/ - 0x0000f8d9, - 0x380cb110, - 0xf8f6f5fa, - 0xbf002300, - 0xbf3ef608,/*6a24*/ +const uint32_t bes2300p_patch7_ibrt_ins_data_t3[] = { + 0x71ab2300, /*6a10*/ + 0x0000f8d9, 0x380cb110, 0xf8f6f5fa, 0xbf002300, 0xbf3ef608, /*6a24*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch7 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch7 = { 7, BTDRV_PATCH_ACT, sizeof(bes2300p_patch7_ibrt_ins_data_t3), 0x0000f8a0, 0xb8b6f1f7, 0xc0006a10, - (uint8_t *)bes2300p_patch7_ibrt_ins_data_t3 -};//lm_page_scan_end_ind free msg + (uint8_t *) + bes2300p_patch7_ibrt_ins_data_t3}; // lm_page_scan_end_ind free msg -const uint32_t bes2300p_patch8_ibrt_ins_data_t3[] = -{ +const uint32_t bes2300p_patch8_ibrt_ins_data_t3[] = { 0xf8862001, 0xf8860060, 0xbf000061, 0xbba3f611, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch8 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch8 = { 8, BTDRV_PATCH_ACT, sizeof(bes2300p_patch8_ibrt_ins_data_t3), 0x00018f1c, 0xbc62f1ee, 0xc00077e4, - (uint8_t *)bes2300p_patch8_ibrt_ins_data_t3 -};//ignore 0x5d sm + (uint8_t *)bes2300p_patch8_ibrt_ins_data_t3}; // ignore 0x5d sm -const uint32_t bes2300p_patch9_ibrt_ins_data_t3[] = -{ - 0xf62a4628,/*6a2c*/ - 0x4620fef7, - 0xff76f60f, - 0xf8534b04, - 0x46203025, - 0x135ef893, - 0xfc68f5fa, - 0xbd702000, - 0xc0005de4,/*6a4c*/ +const uint32_t bes2300p_patch9_ibrt_ins_data_t3[] = { + 0xf62a4628, /*6a2c*/ + 0x4620fef7, 0xff76f60f, 0xf8534b04, 0x46203025, + 0x135ef893, 0xfc68f5fa, 0xbd702000, 0xc0005de4, /*6a4c*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch9 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch9 = { 9, BTDRV_PATCH_ACT, sizeof(bes2300p_patch9_ibrt_ins_data_t3), 0x0002347c, 0xbad6f1e3, 0xc0006a2c, - (uint8_t *)bes2300p_patch9_ibrt_ins_data_t3 -}; + (uint8_t *)bes2300p_patch9_ibrt_ins_data_t3}; -const uint32_t bes2300p_patch10_ibrt_ins_data_t3[] = -{ +const uint32_t bes2300p_patch10_ibrt_ins_data_t3[] = { 0x0818f104, 0xbb9ff634, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch10 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch10 = { 10, BTDRV_PATCH_ACT, sizeof(bes2300p_patch10_ibrt_ins_data_t3), 0x0003b184, 0xbc66f1cb, 0xc0006a54, - (uint8_t *)bes2300p_patch10_ibrt_ins_data_t3 -};//set afh + (uint8_t *)bes2300p_patch10_ibrt_ins_data_t3}; // set afh -const uint32_t bes2300p_patch11_ibrt_ins_data_t3[] = -{ - 0xf8934b09,/*6a68*/ - 0xf0133084, - 0xd0050f06, - 0xf6374620, - 0x4601f805, - 0xe0052400, - 0xf8934b03, - 0xbf003084, - 0xb941f636, - 0xb987f636, - 0xc0006568,/*6a90*/ +const uint32_t bes2300p_patch11_ibrt_ins_data_t3[] = { + 0xf8934b09, /*6a68*/ + 0xf0133084, 0xd0050f06, 0xf6374620, 0x4601f805, 0xe0052400, + 0xf8934b03, 0xbf003084, 0xb941f636, 0xb987f636, 0xc0006568, /*6a90*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch11 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch11 = { 11, BTDRV_PATCH_ACT, sizeof(bes2300p_patch11_ibrt_ins_data_t3), 0x0003cd08, 0xbeaef1c9, 0xc0006a68, - (uint8_t *)bes2300p_patch11_ibrt_ins_data_t3 -};// set ble adv data + (uint8_t *)bes2300p_patch11_ibrt_ins_data_t3}; // set ble adv data -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch12 = -{ - 12, - BTDRV_PATCH_ACT, - 0, - 0x0003cbf0, - 0xbf00e004, - 0, - NULL -};// set ble scan response data +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch12 = { + 12, BTDRV_PATCH_ACT, 0, 0x0003cbf0, 0xbf00e004, 0, + NULL}; // set ble scan response data -const uint32_t bes2300p_patch13_ibrt_ins_data_t3[] = -{ +const uint32_t bes2300p_patch13_ibrt_ins_data_t3[] = { /*6a98*/ 0x99049803, /*6a9c*/ 0x4b12b470, /*6aa0*/ 0x010e5c5a, @@ -420,13 +332,13 @@ const uint32_t bes2300p_patch13_ibrt_ins_data_t3[] = /*6ad8*/ 0xf0f4fb93, /*6adc*/ 0xbc70b240, /*6ae0*/ 0x22019904, - /*6ae4*/ 0xba00f626, //jump a0206ae4 -> a002cee8 - /*6ae8*/ 0xc0006af8, //addr of rssi_idx_for_agc - /*6aec*/ 0xc0006afc, //addr of rssi_set_for_agc - /*6af0*/ 0xc0006af4, //addr of N - /*6af4*/ 0x00000005, //N : 1 ~ 16 - /*6af8*/ 0x00000000, //rssi_idx_for_agc[3] - /*6afc*/ 0xbabababa, //rssi_set_for_agc[3*16] + /*6ae4*/ 0xba00f626, // jump a0206ae4 -> a002cee8 + /*6ae8*/ 0xc0006af8, // addr of rssi_idx_for_agc + /*6aec*/ 0xc0006afc, // addr of rssi_set_for_agc + /*6af0*/ 0xc0006af4, // addr of N + /*6af4*/ 0x00000005, // N : 1 ~ 16 + /*6af8*/ 0x00000000, // rssi_idx_for_agc[3] + /*6afc*/ 0xbabababa, // rssi_set_for_agc[3*16] /*6b00*/ 0xbabababa, /*6b04*/ 0xbabababa, /*6b08*/ 0xbabababa, @@ -441,162 +353,100 @@ const uint32_t bes2300p_patch13_ibrt_ins_data_t3[] = /*6b2c*/ 0xbabababa, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch13 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch13 = { 13, BTDRV_PATCH_ACT, sizeof(bes2300p_patch13_ibrt_ins_data_t3), 0x0002cee4, - 0xbdd8f1d9, //jump a002cee4 -> a0206a98 + 0xbdd8f1d9, // jump a002cee4 -> a0206a98 0xc0006a98, - (uint8_t *)bes2300p_patch13_ibrt_ins_data_t3 -};//ld_acl_rx() average rssi + (uint8_t *)bes2300p_patch13_ibrt_ins_data_t3}; // ld_acl_rx() average rssi -const uint32_t bes2300p_patch14_ibrt_ins_data_t3[] = -{ - 0x305af893, - 0xd1032b00, - 0x12f4f240, - 0xbf00e002, - 0x32b8f640, - 0xbe30f60d,/*6bdc*/ +const uint32_t bes2300p_patch14_ibrt_ins_data_t3[] = { + 0x305af893, 0xd1032b00, 0x12f4f240, + 0xbf00e002, 0x32b8f640, 0xbe30f60d, /*6bdc*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch14 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch14 = { 14, BTDRV_PATCH_ACT, sizeof(bes2300p_patch14_ibrt_ins_data_t3), 0x0001483c, 0xb9c4f1f2, 0xc0006bc8, - (uint8_t *)bes2300p_patch14_ibrt_ins_data_t3 -};//lmp to 5s before connection cmp sent + (uint8_t *)bes2300p_patch14_ibrt_ins_data_t3}; // lmp to 5s before + // connection cmp sent -const uint32_t bes2300p_patch15_ibrt_ins_data_t3[] = -{ - 0x2028f843,/*6b3c*/ - 0xf8434b08, - 0x4b052028, - 0x4b0e701a, - 0x2201701a, - 0xf8434b08, - 0xbf002028, - 0xba32f624, - 0xc0006b60, - 0x00000000, - 0xc0006b68, - 0x00000000, - 0x00000000, - 0x00000000, - 0xc0006b78, - 0x00000001, - 0x00000001, - 0x00000001, - 0xc0006b88, - 0x00000000,/*6b88*/ +const uint32_t bes2300p_patch15_ibrt_ins_data_t3[] = { + 0x2028f843, /*6b3c*/ + 0xf8434b08, 0x4b052028, 0x4b0e701a, 0x2201701a, 0xf8434b08, + 0xbf002028, 0xba32f624, 0xc0006b60, 0x00000000, 0xc0006b68, + 0x00000000, 0x00000000, 0x00000000, 0xc0006b78, 0x00000001, + 0x00000001, 0x00000001, 0xc0006b88, 0x00000000, /*6b88*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch15 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch15 = { 15, BTDRV_PATCH_ACT, sizeof(bes2300p_patch15_ibrt_ins_data_t3), 0x0002afbc, 0xbdbef1db, 0xc0006b3c, - (uint8_t *)bes2300p_patch15_ibrt_ins_data_t3 -};//sync clear count + (uint8_t *)bes2300p_patch15_ibrt_ins_data_t3}; // sync clear count -const uint32_t bes2300p_patch16_ibrt_ins_data_t3[] = -{ - 0x0046f894,/*6b90*/ - 0xfe94f625, - 0xd8012802, - 0xba3ef629, - 0xba57f629,/*6ba0*/ +const uint32_t bes2300p_patch16_ibrt_ins_data_t3[] = { + 0x0046f894, /*6b90*/ + 0xfe94f625, 0xd8012802, 0xba3ef629, 0xba57f629, /*6ba0*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch16 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch16 = { 16, BTDRV_PATCH_ACT, sizeof(bes2300p_patch16_ibrt_ins_data_t3), 0x00030014, 0xbdbcf1d6, 0xc0006b90, - (uint8_t *)bes2300p_patch16_ibrt_ins_data_t3 -};//ld_sco_evt_start_cbk + (uint8_t *)bes2300p_patch16_ibrt_ins_data_t3}; // ld_sco_evt_start_cbk -const uint32_t bes2300p_patch17_ibrt_ins_data_t3[] = -{ - 0xf6062002,/*6ba4*/ - 0x2802f937, - 0xf898d108, - 0xf62500b2, - 0x2802fe85, - 0xbf00d802, - 0xbc93f629, - 0xbc98f629,/*6bc0*/ +const uint32_t bes2300p_patch17_ibrt_ins_data_t3[] = { + 0xf6062002, /*6ba4*/ + 0x2802f937, 0xf898d108, 0xf62500b2, 0x2802fe85, + 0xbf00d802, 0xbc93f629, 0xbc98f629, /*6bc0*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch17 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch17 = { 17, BTDRV_PATCH_ACT, sizeof(bes2300p_patch17_ibrt_ins_data_t3), 0x000304d4, 0xbb66f1d6, 0xc0006ba4, - (uint8_t *)bes2300p_patch17_ibrt_ins_data_t3 -};//ld_calculate_event_timestamp + (uint8_t *) + bes2300p_patch17_ibrt_ins_data_t3}; // ld_calculate_event_timestamp #ifdef BT_CONTROLLER_DEBUG -const uint32_t bes2300p_patch18_ibrt_ins_data_t3[] = -{ - 0x68124a0e, - 0x2084f8c3, - 0x68124a0d, - 0x2088f8c3, - 0x68124a0c, - 0x208cf8c3, - 0x68124a0b, - 0x2090f8c3, - 0x68124a0a, - 0x2094f8c3, - 0x68124a09, - 0x2098f8c3, - 0x68124a08, - 0x209cf8c3, - 0xbf004770, - 0xe000ed04, - 0xe000ed0c, - 0xe000ed10, - 0xe000ed14, - 0xe000ed24, - 0xe000ed3c, - 0xe000ed34,/*6d10*/ +const uint32_t bes2300p_patch18_ibrt_ins_data_t3[] = { + 0x68124a0e, 0x2084f8c3, 0x68124a0d, 0x2088f8c3, 0x68124a0c, 0x208cf8c3, + 0x68124a0b, 0x2090f8c3, 0x68124a0a, 0x2094f8c3, 0x68124a09, 0x2098f8c3, + 0x68124a08, 0x209cf8c3, 0xbf004770, 0xe000ed04, 0xe000ed0c, 0xe000ed10, + 0xe000ed14, 0xe000ed24, 0xe000ed3c, 0xe000ed34, /*6d10*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch18 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch18 = { 18, BTDRV_PATCH_ACT, sizeof(bes2300p_patch18_ibrt_ins_data_t3), 0x000077fc, 0xba5ef1ff, 0xc0006cbc, - (uint8_t *)bes2300p_patch18_ibrt_ins_data_t3 -};//correct crash dump + (uint8_t *)bes2300p_patch18_ibrt_ins_data_t3}; // correct crash dump #else -const uint32_t bes2300p_patch18_ibrt_ins_data_t3[] = -{ - 0x2271f240,/*6cc0*/ - 0x4080f8b0,/*6cc4*/ +const uint32_t bes2300p_patch18_ibrt_ins_data_t3[] = { + 0x2271f240, /*6cc0*/ + 0x4080f8b0, /*6cc4*/ 0xb9f9f63f, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch18 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch18 = { 18, BTDRV_PATCH_ACT, sizeof(bes2300p_patch18_ibrt_ins_data_t3), @@ -605,373 +455,232 @@ const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch18 = 0xc0006cc0, (uint8_t *)bes2300p_patch18_ibrt_ins_data_t3 -};//BT avoid ble +}; // BT avoid ble #endif -const uint32_t bes2300p_patch19_ibrt_ins_data_t3[] = -{ - 0x4603b508, - 0x8210f3ef, - 0x0f01f012, - 0xb672d112, - 0xf5a34811, - 0x3b285343, - 0xfba14910, - 0xf3c32303, - 0xeb032387, - 0xeb000343, - 0x31940183, - 0xfdd0f5fc, - 0xbd08b662, - 0xf5a34808, - 0x3b285343, - 0xfba14907, - 0xf3c32303, - 0xeb032387, - 0xeb000343, - 0x31940183, - 0xfdbef5fc, - 0xbf00bd08, - 0xc0005b4c, - 0xff00ff01, +const uint32_t bes2300p_patch19_ibrt_ins_data_t3[] = { + 0x4603b508, 0x8210f3ef, 0x0f01f012, 0xb672d112, 0xf5a34811, 0x3b285343, + 0xfba14910, 0xf3c32303, 0xeb032387, 0xeb000343, 0x31940183, 0xfdd0f5fc, + 0xbd08b662, 0xf5a34808, 0x3b285343, 0xfba14907, 0xf3c32303, 0xeb032387, + 0xeb000343, 0x31940183, 0xfdbef5fc, 0xbf00bd08, 0xc0005b4c, 0xff00ff01, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch19 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch19 = { 19, BTDRV_PATCH_ACT, sizeof(bes2300p_patch19_ibrt_ins_data_t3), 0x00008b24, 0xb8f8f1fe, 0xc0006d18, - (uint8_t *)bes2300p_patch19_ibrt_ins_data_t3 -};//add lock interrupt when free acl buf + (uint8_t *)bes2300p_patch19_ibrt_ins_data_t3}; // add lock interrupt when + // free acl buf -const uint32_t bes2300p_patch20_ibrt_ins_data_t3[] = -{ - 0x460cb510, - 0xfafaf5fa, - 0xd9042870, - 0x007ef1b4, - 0x2001bf18, - 0x2000bd10, - 0xbf00bd10, - 0xf7ff4621, - 0x2800ffef, - 0x4628d104, - 0xfae8f5fa, - 0xbd9af61c, - 0xb85ff61d,/*6df4*/ +const uint32_t bes2300p_patch20_ibrt_ins_data_t3[] = { + 0x460cb510, 0xfafaf5fa, 0xd9042870, 0x007ef1b4, 0x2001bf18, + 0x2000bd10, 0xbf00bd10, 0xf7ff4621, 0x2800ffef, 0x4628d104, + 0xfae8f5fa, 0xbd9af61c, 0xb85ff61d, /*6df4*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch20 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch20 = { 20, BTDRV_PATCH_ACT, sizeof(bes2300p_patch20_ibrt_ins_data_t3), 0x00023924, 0xba5cf1e3, 0xc0006dc4, - (uint8_t *)bes2300p_patch20_ibrt_ins_data_t3 -};//protect ext3 lmp tx cfm + (uint8_t *)bes2300p_patch20_ibrt_ins_data_t3}; // protect ext3 lmp tx cfm -const uint32_t bes2300p_patch21_ibrt_ins_data_t3[] = -{ - 0x2040f897,/*6e00*/ - 0xd1112a01, - 0x0109f106, - 0xf5fc4608, - 0x2813fd4b, - 0x221ed802, - 0xbc54f614, - 0x2a017a32, - 0xf614d801, - 0x221ebbf6, - 0xbc4cf614, - 0xbc47f614,/*6e2c*/ +const uint32_t bes2300p_patch21_ibrt_ins_data_t3[] = { + 0x2040f897, /*6e00*/ + 0xd1112a01, 0x0109f106, 0xf5fc4608, 0x2813fd4b, 0x221ed802, 0xbc54f614, + 0x2a017a32, 0xf614d801, 0x221ebbf6, 0xbc4cf614, 0xbc47f614, /*6e2c*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch21 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch21 = { 21, BTDRV_PATCH_ACT, sizeof(bes2300p_patch21_ibrt_ins_data_t3), 0x0001b604, 0xbbfcf1eb, 0xc0006e00, - (uint8_t *)bes2300p_patch21_ibrt_ins_data_t3 -};//reject set afh lmp when channel number less than 20 + (uint8_t *) + bes2300p_patch21_ibrt_ins_data_t3}; // reject set afh lmp when + // channel number less than 20 -const uint32_t bes2300p_patch22_ibrt_ins_data_t3[] = -{ - 0x2202729a,/*6e34*/ - 0xbd38719a,/*6e38*/ +const uint32_t bes2300p_patch22_ibrt_ins_data_t3[] = { + 0x2202729a, /*6e34*/ + 0xbd38719a, /*6e38*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch22 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch22 = { 22, BTDRV_PATCH_ACT, sizeof(bes2300p_patch22_ibrt_ins_data_t3), 0x00011c90, 0xb8d0f1f5, 0xc0006e34, - (uint8_t *)bes2300p_patch22_ibrt_ins_data_t3 -};//update sco sync type + (uint8_t *)bes2300p_patch22_ibrt_ins_data_t3}; // update sco sync type -const uint32_t bes2300p_patch2a_ibrt_ins_data_t3[] = -{ +const uint32_t bes2300p_patch2a_ibrt_ins_data_t3[] = { /*6e5c*/ 0xb10b4b04, - /*6e60*/ 0xbb84f615, //jump a001c56c + /*6e60*/ 0xbb84f615, // jump a001c56c /*6e64*/ 0x783b2300, /*6e68*/ 0x0301f003, - /*6e6c*/ 0xbb5ef615, //jump a001c52c - /*6e70*/ 0x00000000, //reject sniff -};//LMP_MSG_HANDLER(sniff_req) LC_CONNECTED + /*6e6c*/ 0xbb5ef615, // jump a001c52c + /*6e70*/ 0x00000000, // reject sniff +}; // LMP_MSG_HANDLER(sniff_req) LC_CONNECTED -const uint32_t bes2300p_patch23_ibrt_ins_data_t3[] = -{ - 0xf9c6f632,/*7744*/ - 0x02194603, - 0x417ff401, - 0xbeeff632,/*7750*/ +const uint32_t bes2300p_patch23_ibrt_ins_data_t3[] = { + 0xf9c6f632, /*7744*/ + 0x02194603, 0x417ff401, 0xbeeff632, /*7750*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch23 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch23 = { 23, BTDRV_PATCH_ACT, sizeof(bes2300p_patch23_ibrt_ins_data_t3), 0x0003a52c, 0xb90af1cd, 0xc0007744, - (uint8_t *)bes2300p_patch23_ibrt_ins_data_t3 -};//fix sco success index + (uint8_t *)bes2300p_patch23_ibrt_ins_data_t3}; // fix sco success index -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch24 = -{ - 24, - BTDRV_PATCH_ACT, - 0, - 0x00002490, - 0xbf00e012, - 0, - NULL, -};//stop ibrt directly +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch24 = { + 24, BTDRV_PATCH_ACT, 0, 0x00002490, 0xbf00e012, 0, NULL, +}; // stop ibrt directly -const uint32_t bes2300p_patch25_ibrt_ins_data_t3[] = -{ - 0x2a020a02, - 0xbf00d804, - 0x427ff400, - 0xbf44f61c, - 0xb807f61d, +const uint32_t bes2300p_patch25_ibrt_ins_data_t3[] = { + 0x2a020a02, 0xbf00d804, 0x427ff400, 0xbf44f61c, 0xb807f61d, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch25 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch25 = { 25, BTDRV_PATCH_ACT, sizeof(bes2300p_patch25_ibrt_ins_data_t3), 0x00023d28, 0xb8b4f1e3, 0xc0006e94, - (uint8_t *)bes2300p_patch25_ibrt_ins_data_t3 -};//enc update2 idx error + (uint8_t *)bes2300p_patch25_ibrt_ins_data_t3}; // enc update2 idx error #if 1 -const uint32_t bes2300p_patch26_ibrt_ins_data_t3[] = -{ - 0x68134a05, - 0x2380f043, - 0xf5a26013, - 0x68137206, - 0x0301f043, - 0xbd386013, - 0xd0220400, +const uint32_t bes2300p_patch26_ibrt_ins_data_t3[] = { + 0x68134a05, 0x2380f043, 0xf5a26013, 0x68137206, + 0x0301f043, 0xbd386013, 0xd0220400, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch26 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch26 = { 26, BTDRV_PATCH_ACT, sizeof(bes2300p_patch26_ibrt_ins_data_t3), 0x00048200, 0xba8ef1bf, 0xc0007720, - (uint8_t *)bes2300p_patch26_ibrt_ins_data_t3 -};//enable hw spiin BLE lld_evt_rx_isr + (uint8_t *)bes2300p_patch26_ibrt_ins_data_t3}; // enable hw spiin BLE + // lld_evt_rx_isr #elif 0 -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch26 = -{ - 26, - BTDRV_PATCH_ACT, - 0, - 0x00013f44, - 0xbf00bd38, - 0, - NULL -};//assert +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch26 = { + 26, BTDRV_PATCH_ACT, 0, 0x00013f44, 0xbf00bd38, 0, NULL}; // assert #else -const uint32_t bes2300p_patch26_ibrt_ins_data_t3[] = -{ - 0xf6324607, - 0xb120fa87, - 0x63a6f640, - 0xf63e827b, - 0x4638bd94, - 0x2080f8d0, - 0xbd86f63e, +const uint32_t bes2300p_patch26_ibrt_ins_data_t3[] = { + 0xf6324607, 0xb120fa87, 0x63a6f640, 0xf63e827b, + 0x4638bd94, 0x2080f8d0, 0xbd86f63e, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch26 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch26 = { 26, BTDRV_PATCH_ACT, sizeof(bes2300p_patch26_ibrt_ins_data_t3), 0x000461dc, 0xba6cf1c1, 0xc00076b8, - (uint8_t *)bes2300p_patch26_ibrt_ins_data_t3 -};//ble con slave duration in snoop mode + (uint8_t *)bes2300p_patch26_ibrt_ins_data_t3}; // ble con slave duration in + // snoop mode #endif #if defined(SYNC_BT_CTLR_PROFILE) -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch27 = -{ - 27, - BTDRV_PATCH_ACT, - 0, - 0x000187b8, - 0x4628b123, - 0, - NULL -};//send profile via ble +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch27 = { + 27, BTDRV_PATCH_ACT, 0, 0x000187b8, 0x4628b123, 0, + NULL}; // send profile via ble #else -const uint32_t bes2300p_patch27_ibrt_ins_data_t3[] = -{ - 0xfe88f632, - 0xffe8f7ff, - 0xb9a2f625,/*6c68*/ +const uint32_t bes2300p_patch27_ibrt_ins_data_t3[] = { + 0xfe88f632, 0xffe8f7ff, 0xb9a2f625, /*6c68*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch27 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch27 = { 27, BTDRV_PATCH_ACT, sizeof(bes2300p_patch27_ibrt_ins_data_t3), 0x0002bfac, 0xbe58f1da, 0xc0006c60, - (uint8_t *)bes2300p_patch27_ibrt_ins_data_t3 -};//disconnect update ke state + (uint8_t *)bes2300p_patch27_ibrt_ins_data_t3}; // disconnect update ke state #endif #if 1 // for ble master update con param with large winsize -const uint32_t bes2300p_patch28_ibrt_ins_data_t3[] = -{ - 0x4630bf00, - 0x109ef894, - 0xf958f63f, - 0x309cf894, - 0x2271f240, - 0x0003fb02, - 0xbcf1f63f, +const uint32_t bes2300p_patch28_ibrt_ins_data_t3[] = { + 0x4630bf00, 0x109ef894, 0xf958f63f, 0x309cf894, + 0x2271f240, 0x0003fb02, 0xbcf1f63f, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch28 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch28 = { 28, BTDRV_PATCH_ACT, sizeof(bes2300p_patch28_ibrt_ins_data_t3), 0x000471e4, 0xbb08f1c0, 0xc00077f8, - (uint8_t *)bes2300p_patch28_ibrt_ins_data_t3 -}; + (uint8_t *)bes2300p_patch28_ibrt_ins_data_t3}; #else // only for search UI -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch28 = -{ - 28, - BTDRV_PATCH_ACT, - 0, - 0x0000e47a, - 0xe0027b20, - 0, - NULL -};//lm_inq_res_ind_handler() rssi +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch28 = { + 28, BTDRV_PATCH_ACT, 0, 0x0000e47a, 0xe0027b20, 0, + NULL}; // lm_inq_res_ind_handler() rssi #endif -const uint32_t bes2300p_patch29_ibrt_ins_data_t3[] = -{ - 0xf8934b04, - 0x2b0231c2, - 0x230fbf0c, - 0x75ab2314, - 0xbac2f629, - 0xc0005ea8,/*6ec4*/ +const uint32_t bes2300p_patch29_ibrt_ins_data_t3[] = { + 0xf8934b04, 0x2b0231c2, 0x230fbf0c, + 0x75ab2314, 0xbac2f629, 0xc0005ea8, /*6ec4*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch29 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch29 = { 29, BTDRV_PATCH_ACT, sizeof(bes2300p_patch29_ibrt_ins_data_t3), 0x00030444, 0xbd34f1d6, 0xc0006eb0, - (uint8_t *)bes2300p_patch29_ibrt_ins_data_t3 -};///fix acl interv priority + (uint8_t *)bes2300p_patch29_ibrt_ins_data_t3}; /// fix acl interv priority -const uint32_t bes2300p_patch30_ibrt_ins_data_t3[] = -{ - 0xd80a2802, - 0x4b05b508, - 0x3020f853, - 0xf893b123, - 0x220510c4, - 0xfe86f61d, - 0x4770bd08, - 0xc00009d4, - 0xffeef7ff, - 0xbda8f634,/*6ef0*/ +const uint32_t bes2300p_patch30_ibrt_ins_data_t3[] = { + 0xd80a2802, 0x4b05b508, 0x3020f853, 0xf893b123, 0x220510c4, + 0xfe86f61d, 0x4770bd08, 0xc00009d4, 0xffeef7ff, 0xbda8f634, /*6ef0*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch30 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch30 = { 30, BTDRV_PATCH_ACT, sizeof(bes2300p_patch30_ibrt_ins_data_t3), 0x0003ba40, 0xba54f1cb, 0xc0006ecc, - (uint8_t *)bes2300p_patch30_ibrt_ins_data_t3 -};///send max slot req when start ibrt + (uint8_t *)bes2300p_patch30_ibrt_ins_data_t3}; /// send max slot req when + /// start ibrt -const uint32_t bes2300p_patch31_ibrt_ins_data_t3[] = -{ - 0xf632b920, - 0x2800fdc1, - 0xbf00d002, - 0xbb3af629, - 0xbba2f629,/*6f08*/ +const uint32_t bes2300p_patch31_ibrt_ins_data_t3[] = { + 0xf632b920, 0x2800fdc1, 0xbf00d002, 0xbb3af629, 0xbba2f629, /*6f08*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch31 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch31 = { 31, BTDRV_PATCH_ACT, sizeof(bes2300p_patch31_ibrt_ins_data_t3), 0x00030578, 0xbcbef1d6, 0xc0006ef8, - (uint8_t *)bes2300p_patch31_ibrt_ins_data_t3 -};//modify start ibrt timing + (uint8_t *)bes2300p_patch31_ibrt_ins_data_t3}; // modify start ibrt timing -#if 0//def BT_CONTROLLER_DEBUG +#if 0 // def BT_CONTROLLER_DEBUG const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch32= { 32, @@ -984,338 +693,147 @@ const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch32= };///lmp trace #else -const uint32_t bes2300p_patch32_ibrt_ins_data_t3[] = -{ - 0xfe4af5f9, - 0xbf002300, - 0x30c8f884, - 0xbaf8f624,/*6f18*/ +const uint32_t bes2300p_patch32_ibrt_ins_data_t3[] = { + 0xfe4af5f9, 0xbf002300, 0x30c8f884, 0xbaf8f624, /*6f18*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch32 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch32 = { 32, BTDRV_PATCH_ACT, sizeof(bes2300p_patch32_ibrt_ins_data_t3), 0x0002b508, 0xbd00f1db, 0xc0006f0c, - (uint8_t *)bes2300p_patch32_ibrt_ins_data_t3 -};///role switch fail + (uint8_t *)bes2300p_patch32_ibrt_ins_data_t3}; /// role switch fail #endif -const uint32_t bes2300p_patch33_ibrt_ins_data_t3[] = -{ - 0x2300b430, - 0x4d072103, - 0x4290b2da, - 0xf855d004, - 0x2c004023, - 0x4611bf18, - 0x2b033301, - 0x4608d1f4, - 0x4770bc30, - 0xc00009d4,/*6f50*/ +const uint32_t bes2300p_patch33_ibrt_ins_data_t3[] = { + 0x2300b430, 0x4d072103, 0x4290b2da, 0xf855d004, 0x2c004023, + 0x4611bf18, 0x2b033301, 0x4608d1f4, 0x4770bc30, 0xc00009d4, /*6f50*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch33 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch33 = { 33, BTDRV_PATCH_ACT, sizeof(bes2300p_patch33_ibrt_ins_data_t3), 0x0002c8c0, 0xbb2ef1da, 0xc0006f20, - (uint8_t *)bes2300p_patch33_ibrt_ins_data_t3 -};//find_other_acl_link + (uint8_t *)bes2300p_patch33_ibrt_ins_data_t3}; // find_other_acl_link -const uint32_t bes2300p_patch34_ibrt_ins_data_t3[] = -{ - 0xfe38f632, - 0xd0052800, - 0xbf002002, - 0xfcb0f61c, - 0xbb2ff634, - 0xbb25f634,/*6f6c*/ +const uint32_t bes2300p_patch34_ibrt_ins_data_t3[] = { + 0xfe38f632, 0xd0052800, 0xbf002002, + 0xfcb0f61c, 0xbb2ff634, 0xbb25f634, /*6f6c*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch34 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch34 = { 34, BTDRV_PATCH_ACT, sizeof(bes2300p_patch34_ibrt_ins_data_t3), 0x0003b5b4, 0xbcd0f1cb, 0xc0006f58, - (uint8_t *)bes2300p_patch34_ibrt_ins_data_t3 -};//do not trans afh after IBRT switch + (uint8_t *)bes2300p_patch34_ibrt_ins_data_t3}; // do not trans afh after + // IBRT switch -const uint32_t bes2300p_patch35_ibrt_ins_data_t3[] = -{ - 0xfd92f632,/*6f70*/ - 0xd1092801, - 0xfe28f632, - 0xd0052800, - 0xfd9cf632, - 0xd10142a0, - 0xbc77f611, - 0x68294620, - 0xbc70f611,/*6f90*/ +const uint32_t bes2300p_patch35_ibrt_ins_data_t3[] = { + 0xfd92f632, /*6f70*/ + 0xd1092801, 0xfe28f632, 0xd0052800, 0xfd9cf632, + 0xd10142a0, 0xbc77f611, 0x68294620, 0xbc70f611, /*6f90*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch35 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch35 = { 35, BTDRV_PATCH_ACT, sizeof(bes2300p_patch35_ibrt_ins_data_t3), 0x00018870, 0xbb7ef1ee, 0xc0006f70, - (uint8_t *)bes2300p_patch35_ibrt_ins_data_t3 -};//acl data tx cfm + (uint8_t *)bes2300p_patch35_ibrt_ins_data_t3}; // acl data tx cfm -const uint32_t bes2300p_patch36_ibrt_ins_data_t3[] = -{ - 0x460db538, - 0x78034614, - 0x7842085b, - 0x2b7f78c1, - 0x2a01d10a, - 0x290dd11e, - 0xf632d11c, - 0x4601fd45, - 0xf6342000, - 0xe015ff1f, - 0xd1132b03, - 0xd1112a18, - 0xd80f2d02, - 0xf6104628, - 0xb158fcb3, - 0x3047f890, - 0xd1072b02, - 0xf62a4628, - 0x0228fc0b, - 0x0001f040, - 0xfc88f60f, - 0x000cf1a4, - 0xfdf8f5f9, - 0xbf00bd38, - 0xd1072800, - 0x4620bf00, - 0x46524639, - 0xffc8f7ff, - 0xbbd8f61a, - 0xbb62f61a,/*7034*/ +const uint32_t bes2300p_patch36_ibrt_ins_data_t3[] = { + 0x460db538, 0x78034614, 0x7842085b, 0x2b7f78c1, 0x2a01d10a, + 0x290dd11e, 0xf632d11c, 0x4601fd45, 0xf6342000, 0xe015ff1f, + 0xd1132b03, 0xd1112a18, 0xd80f2d02, 0xf6104628, 0xb158fcb3, + 0x3047f890, 0xd1072b02, 0xf62a4628, 0x0228fc0b, 0x0001f040, + 0xfc88f60f, 0x000cf1a4, 0xfdf8f5f9, 0xbf00bd38, 0xd1072800, + 0x4620bf00, 0x46524639, 0xffc8f7ff, 0xbbd8f61a, 0xbb62f61a, /*7034*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch36 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch36 = { 36, BTDRV_PATCH_ACT, sizeof(bes2300p_patch36_ibrt_ins_data_t3), 0x000216f8, 0xbc92f1e5, 0xc0006fc0, - (uint8_t *)bes2300p_patch36_ibrt_ins_data_t3 -};//lmp filter + (uint8_t *)bes2300p_patch36_ibrt_ins_data_t3}; // lmp filter -const uint32_t bes2300p_patch37_ibrt_ins_data_t3[] = -{ - 0x47f0e92d,/*7050*/ - 0x4b97b082, - 0x236e5c1e, - 0xf300fb03, - 0x5a9b4a95, - 0x4f00f413, - 0x8120f040, - 0x46044689, - 0x1800ea4f, - 0xeb084f91, - 0x4b910507, - 0xa020f853, - 0xf8524a90, - 0x33013020, - 0x3020f842, - 0xf860f635, - 0x42a04601, - 0x8088f040, - 0xf8534b8a, - 0x4b8a2024, - 0x429a681b, - 0xf8dad817, - 0xebc22084, - 0xf0230309, - 0xf1b34378, - 0xd9046f80, - 0x0302ebc9, - 0x4378f023, - 0x4a82425b, - 0x0024f852, - 0x68124a81, - 0xf200fb02, - 0xf2404293, - 0x4b7f80eb, - 0x3000f993, - 0x4b7eb9c3, - 0xc000f893, - 0x0f00f1bc, - 0x462ad00a, - 0x0e0ceb05, - 0xf9122300, - 0x44030b01, - 0xd1fa4572, - 0xe0014662, - 0x46132200, - 0xfcfcfb93, - 0xf8804872, - 0xe001c000, - 0x46132200, - 0xf890486f, - 0x4870e000, - 0x9000f890, - 0xf890486f, - 0xfa4fc000, - 0xebc9f08e, - 0xfa4f0000, - 0x4550fa8c, - 0xebc9dd05, - 0x48660e0e, - 0xe000f880, - 0x4864e002, - 0xc000f880, - 0x0e00f04f, - 0xf840485d, - 0xf8dfe024, - 0xf85ee178, - 0x30010024, - 0x0024f84e, - 0x7800485d, - 0xd2054286, - 0x783f4f5a, - 0x360155af, - 0xe004b2f6, - 0x78364e57, - 0x6007f808, - 0x4f4d2601, - 0x4282553e, - 0x442ada06, - 0xf9124405, - 0x44234b01, - 0xd1fa42aa, - 0xfb934a53, - 0x9200f0f0, - 0xb2406a14, - 0x23002201, - 0xe08147a0, - 0xf8534b46, - 0x4b4e2024, - 0x429a681b, - 0xf8dad816, - 0xebc22084, - 0xf0230309, - 0xf1b34378, - 0xd9046f80, - 0x0302ebc9, - 0x4378f023, - 0x4a3e425b, - 0x1024f852, - 0x68124a44, - 0xf201fb02, - 0xd9634293, - 0xf9934b42, - 0xb9c33000, - 0xf8934b3a, - 0xf1bee000, - 0xd00a0f00, - 0xeb05462a, - 0x2300000e, - 0x1b01f912, - 0x4282440b, - 0x4672d1fa, - 0x2200e001, - 0xfb934613, - 0x4936fefe, - 0xe000f881, - 0x2200e001, - 0x49334613, - 0x49337808, - 0xc000f891, - 0xf8914932, - 0xb241e000, - 0x0101ebcc, - 0xf98efa4f, - 0xdd044549, - 0x0000ebcc, - 0x7008492a, - 0x4929e002, - 0xe000f881, - 0x491c2000, - 0x0024f841, - 0xf850481c, - 0x31011024, - 0x1024f840, - 0x7808491c, - 0xd2054286, - 0x78094920, - 0x360155a9, - 0xe004b2f6, - 0x7809491d, - 0x1007f808, - 0x490c2601, - 0x4282550e, - 0x442ada06, - 0xf9124405, - 0x440b1b01, - 0xd1fa42aa, - 0xfb934a12, - 0x9200f0f0, - 0xb2406a15, - 0x22014621, - 0x47a82300, - 0xe8bdb002, - 0xbf0087f0, - 0xc0006af8,//rssi_idx_for_agc[link_id] shenxin - 0xd02111f8,//EM_BT_RD(EM_BT_RXBIT_ADDR - 0xc0006afc,//rssi_set_for_agc shenxin - 0xc00009d4,//ld_acl_env[link_id] - 0xc0006b68,//link_no_sync_count[link_id] - 0xc00072fc,//link_agc_thd_tws - 0xc0006b78,//link_no_sync_count_time[link_id] - 0xc0007300,//link_agc_thd_tws_time - 0xc0006b60,//rssi_store_tws - 0xc0006af4,//n shenxin - 0xc0007304,//rssi_tws_step - 0xc0007308,//rssi_min_value_tws - 0xc0004268,//rwip_rf.rxgain_cntl - 0xc000730c,//link_agc_thd_mobile - 0xc0007310,//link_agc_thd_mobile_time - 0xc0006b88,//rssi_store_mobile - 0xc0007314,//rssi_mobile_step - 0xc0007318,//rssi_min_value_mobile - 0xffffffff,//link_agc_thd_tws - 0x00000030,//link_agc_thd_tws_time - 0x00000014,//rssi_tws_step - 0x0000009c,//rssi_min_value_tws - 0xffffffff,//link_agc_thd_mobile - 0x00000030,//link_agc_thd_mobile_time - 0x00000014,//rssi_mobile_step - 0x000000a1,//rssi_min_value_mobile - 0x99029804, - 0xfe96f7ff, - 0xfc48f632, - 0xb898f626,/*7328*/ +const uint32_t bes2300p_patch37_ibrt_ins_data_t3[] = { + 0x47f0e92d, /*7050*/ + 0x4b97b082, 0x236e5c1e, 0xf300fb03, 0x5a9b4a95, 0x4f00f413, 0x8120f040, + 0x46044689, 0x1800ea4f, 0xeb084f91, 0x4b910507, 0xa020f853, 0xf8524a90, + 0x33013020, 0x3020f842, 0xf860f635, 0x42a04601, 0x8088f040, 0xf8534b8a, + 0x4b8a2024, 0x429a681b, 0xf8dad817, 0xebc22084, 0xf0230309, 0xf1b34378, + 0xd9046f80, 0x0302ebc9, 0x4378f023, 0x4a82425b, 0x0024f852, 0x68124a81, + 0xf200fb02, 0xf2404293, 0x4b7f80eb, 0x3000f993, 0x4b7eb9c3, 0xc000f893, + 0x0f00f1bc, 0x462ad00a, 0x0e0ceb05, 0xf9122300, 0x44030b01, 0xd1fa4572, + 0xe0014662, 0x46132200, 0xfcfcfb93, 0xf8804872, 0xe001c000, 0x46132200, + 0xf890486f, 0x4870e000, 0x9000f890, 0xf890486f, 0xfa4fc000, 0xebc9f08e, + 0xfa4f0000, 0x4550fa8c, 0xebc9dd05, 0x48660e0e, 0xe000f880, 0x4864e002, + 0xc000f880, 0x0e00f04f, 0xf840485d, 0xf8dfe024, 0xf85ee178, 0x30010024, + 0x0024f84e, 0x7800485d, 0xd2054286, 0x783f4f5a, 0x360155af, 0xe004b2f6, + 0x78364e57, 0x6007f808, 0x4f4d2601, 0x4282553e, 0x442ada06, 0xf9124405, + 0x44234b01, 0xd1fa42aa, 0xfb934a53, 0x9200f0f0, 0xb2406a14, 0x23002201, + 0xe08147a0, 0xf8534b46, 0x4b4e2024, 0x429a681b, 0xf8dad816, 0xebc22084, + 0xf0230309, 0xf1b34378, 0xd9046f80, 0x0302ebc9, 0x4378f023, 0x4a3e425b, + 0x1024f852, 0x68124a44, 0xf201fb02, 0xd9634293, 0xf9934b42, 0xb9c33000, + 0xf8934b3a, 0xf1bee000, 0xd00a0f00, 0xeb05462a, 0x2300000e, 0x1b01f912, + 0x4282440b, 0x4672d1fa, 0x2200e001, 0xfb934613, 0x4936fefe, 0xe000f881, + 0x2200e001, 0x49334613, 0x49337808, 0xc000f891, 0xf8914932, 0xb241e000, + 0x0101ebcc, 0xf98efa4f, 0xdd044549, 0x0000ebcc, 0x7008492a, 0x4929e002, + 0xe000f881, 0x491c2000, 0x0024f841, 0xf850481c, 0x31011024, 0x1024f840, + 0x7808491c, 0xd2054286, 0x78094920, 0x360155a9, 0xe004b2f6, 0x7809491d, + 0x1007f808, 0x490c2601, 0x4282550e, 0x442ada06, 0xf9124405, 0x440b1b01, + 0xd1fa42aa, 0xfb934a12, 0x9200f0f0, 0xb2406a15, 0x22014621, 0x47a82300, + 0xe8bdb002, 0xbf0087f0, + 0xc0006af8, // rssi_idx_for_agc[link_id] shenxin + 0xd02111f8, // EM_BT_RD(EM_BT_RXBIT_ADDR + 0xc0006afc, // rssi_set_for_agc shenxin + 0xc00009d4, // ld_acl_env[link_id] + 0xc0006b68, // link_no_sync_count[link_id] + 0xc00072fc, // link_agc_thd_tws + 0xc0006b78, // link_no_sync_count_time[link_id] + 0xc0007300, // link_agc_thd_tws_time + 0xc0006b60, // rssi_store_tws + 0xc0006af4, // n shenxin + 0xc0007304, // rssi_tws_step + 0xc0007308, // rssi_min_value_tws + 0xc0004268, // rwip_rf.rxgain_cntl + 0xc000730c, // link_agc_thd_mobile + 0xc0007310, // link_agc_thd_mobile_time + 0xc0006b88, // rssi_store_mobile + 0xc0007314, // rssi_mobile_step + 0xc0007318, // rssi_min_value_mobile + 0xffffffff, // link_agc_thd_tws + 0x00000030, // link_agc_thd_tws_time + 0x00000014, // rssi_tws_step + 0x0000009c, // rssi_min_value_tws + 0xffffffff, // link_agc_thd_mobile + 0x00000030, // link_agc_thd_mobile_time + 0x00000014, // rssi_mobile_step + 0x000000a1, // rssi_min_value_mobile + 0x99029804, 0xfe96f7ff, 0xfc48f632, 0xb898f626, /*7328*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch37 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch37 = { 37, BTDRV_PATCH_ACT, sizeof(bes2300p_patch37_ibrt_ins_data_t3), 0x0002d458, 0xbf60f1d9, 0xc0007050, - (uint8_t *)bes2300p_patch37_ibrt_ins_data_t3 -};//swagc no sync + (uint8_t *)bes2300p_patch37_ibrt_ins_data_t3}; // swagc no sync #if 0 const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch38 = @@ -1329,500 +847,245 @@ const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch38 = NULL, };//ld_sco_stop #elif 1 -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch38 = -{ - 38, - BTDRV_PATCH_ACT, - 0, - 0x00039ecc, - 0xbf00e001, - 0, - NULL, -};//remove lc_start_lmp_to +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch38 = { + 38, BTDRV_PATCH_ACT, 0, 0x00039ecc, 0xbf00e001, 0, NULL, +}; // remove lc_start_lmp_to #else -const uint32_t bes2300p_patch38_ibrt_ins_data_t3[] = -{ - 0x30d8f8c4, - 0xfed6f61f, - 0xd2014283, - 0xbca7f62a, - 0xbcbaf62a,/*7048*/ +const uint32_t bes2300p_patch38_ibrt_ins_data_t3[] = { + 0x30d8f8c4, 0xfed6f61f, 0xd2014283, 0xbca7f62a, 0xbcbaf62a, /*7048*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch38 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch38 = { 38, BTDRV_PATCH_ACT, sizeof(bes2300p_patch38_ibrt_ins_data_t3), 0x000319a4, 0xbb48f1d5, 0xc0007038, - (uint8_t *)bes2300p_patch38_ibrt_ins_data_t3 -};//ble first connection anchor + (uint8_t *) + bes2300p_patch38_ibrt_ins_data_t3}; // ble first connection anchor #endif -const uint32_t bes2300p_patch39_ibrt_ins_data_t3[] = -{ - 0x681b4b05,/*732c*/ - 0xd1032b00, - 0x781a9b12, - 0xbeb8f60b, - 0xbec3f60b, - 0xbf00bf00, +const uint32_t bes2300p_patch39_ibrt_ins_data_t3[] = { + 0x681b4b05, /*732c*/ + 0xd1032b00, 0x781a9b12, 0xbeb8f60b, 0xbec3f60b, 0xbf00bf00, - 0xc0007348,//sniffer_sco_auto_accept - 0x00000000,/*7348*/ + 0xc0007348, // sniffer_sco_auto_accept + 0x00000000, /*7348*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch39 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch39 = { 39, BTDRV_PATCH_ACT, sizeof(bes2300p_patch39_ibrt_ins_data_t3), 0x000130a8, 0xb940f1f4, 0xc000732c, - (uint8_t *)bes2300p_patch39_ibrt_ins_data_t3 -};//lm_get_sync_param_hl_rsp + (uint8_t *)bes2300p_patch39_ibrt_ins_data_t3}; // lm_get_sync_param_hl_rsp -const uint32_t bes2300p_patch40_ibrt_ins_data_t3[] = -{ - 0xfba2f632, - 0xd11d2801, - 0xfc38f632, - 0x4b33b1d0, - 0x2b00681b, - 0xf632d013, - 0x4606fba9, - 0xd10e42b8, - 0xfb98f632, - 0xd15f2800, - 0xfb76f632, - 0x7a224605, - 0x42937a63, - 0x4620d103, - 0xf99af000,// - 0x2000b9d0, - 0xbdeff614, - 0xfb80f632, - 0xd10d2802, - 0xfc16f632, - 0x4b22b150, - 0x2b00681b, - 0x4620d006, - 0xf988f000,// - 0x4b1fb910, - 0x601a2201, - 0xf0037823, - 0xbf000301, - 0xbda9f614, - 0xf8852602, - 0x79a36054, - 0x3055f885, - 0xf844f5fc, - 0x7c4279e3, - 0xd802429a, - 0xf83ef5fc, - 0xf8857c43, - 0x79633056, - 0x3057f885, - 0xf3c37923, - 0xf8850340, - 0x7a233058, - 0x3059f885, - 0xf8a58963, - 0x7ba3305a, - 0x305cf885, - 0xf88578e3, - 0x78a3305d, - 0x305ff885, - 0xfb28f632, - 0x46384603, - 0xf1052110, - 0xf6340252, - 0x2000fc65, +const uint32_t bes2300p_patch40_ibrt_ins_data_t3[] = { + 0xfba2f632, 0xd11d2801, 0xfc38f632, 0x4b33b1d0, 0x2b00681b, 0xf632d013, + 0x4606fba9, 0xd10e42b8, 0xfb98f632, 0xd15f2800, 0xfb76f632, 0x7a224605, + 0x42937a63, 0x4620d103, + 0xf99af000, // + 0x2000b9d0, 0xbdeff614, 0xfb80f632, 0xd10d2802, 0xfc16f632, 0x4b22b150, + 0x2b00681b, 0x4620d006, + 0xf988f000, // + 0x4b1fb910, 0x601a2201, 0xf0037823, 0xbf000301, 0xbda9f614, 0xf8852602, + 0x79a36054, 0x3055f885, 0xf844f5fc, 0x7c4279e3, 0xd802429a, 0xf83ef5fc, + 0xf8857c43, 0x79633056, 0x3057f885, 0xf3c37923, 0xf8850340, 0x7a233058, + 0x3059f885, 0xf8a58963, 0x7ba3305a, 0x305cf885, 0xf88578e3, 0x78a3305d, + 0x305ff885, 0xfb28f632, 0x46384603, 0xf1052110, 0xf6340252, 0x2000fc65, 0xbda3f614, - 0xc0007348,//sniffer_sco_auto_accept - 0xc0007434,//sco_param_filter_status - 0x00000000, - 0xfc3cf634, - 0xb2c33801, - 0xd8022b02, - 0xf6342004, - 0x2000fc3b, - 0xbd91f614, - 0x3c260cff, - 0x5a3712ff, - 0xffffffff, - 0xffffffff, + 0xc0007348, // sniffer_sco_auto_accept + 0xc0007434, // sco_param_filter_status + 0x00000000, 0xfc3cf634, 0xb2c33801, 0xd8022b02, 0xf6342004, 0x2000fc3b, + 0xbd91f614, 0x3c260cff, 0x5a3712ff, 0xffffffff, 0xffffffff, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch40 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch40 = { 40, BTDRV_PATCH_ACT, sizeof(bes2300p_patch40_ibrt_ins_data_t3), 0x0001bf10, 0xba1ef1eb, 0xc0007350, - (uint8_t *)bes2300p_patch40_ibrt_ins_data_t3 -};//LMP_MSG_HANDLER(esco_link_req) + (uint8_t *) + bes2300p_patch40_ibrt_ins_data_t3}; // LMP_MSG_HANDLER(esco_link_req) -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch41 = -{ - 41, - BTDRV_PATCH_ACT, - 0, - 0x0003b818, - 0xfb1be001, - 0, - NULL, -};//config fastack none mode +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch41 = { + 41, BTDRV_PATCH_ACT, 0, 0x0003b818, 0xfb1be001, 0, NULL, +}; // config fastack none mode -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch42 = -{ - 42, - BTDRV_PATCH_ACT, - 0, - 0x0002ceb4, - 0xe00b0f0f, - 0, - NULL -};//ld_acl_rx() average rssi +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch42 = { + 42, BTDRV_PATCH_ACT, 0, 0x0002ceb4, 0xe00b0f0f, 0, + NULL}; // ld_acl_rx() average rssi -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch43 = -{ - 43, - BTDRV_PATCH_ACT, - 0, - 0x0002a51c, - 0x3300f443, - 0, - NULL, -};//bt_e_scoltcntl_retxnb_setf 2 +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch43 = { + 43, BTDRV_PATCH_ACT, 0, 0x0002a51c, 0x3300f443, 0, NULL, +}; // bt_e_scoltcntl_retxnb_setf 2 -const uint32_t bes2300p_patch44_ibrt_ins_data_t3[] = -{ - 0xbf00686b, - 0xd00f42b3, - 0x4a212100, - 0x6863e004, - 0x42b34629, - 0x4625d00a, - 0xd9264293, - 0xd8242e01, - 0x462c461e, - 0xe001460d, - 0x2500462c, - 0x8008f8d4, - 0xa00cf894, - 0x900df894, - 0x46384f16, - 0x46224629, - 0xfb12f5fc, - 0x0014f1a7, - 0xf5fc4621, - 0xf1b8fa1d, - 0xd0050f00, - 0x46514630, - 0x2300464a, - 0xe00847c0, - 0x21ff480d, - 0xfffaf5ff, - 0x682ce003, - 0xd1ce2c00, - 0xb924e000, - 0xf44f4808, - 0xf5ff7185, - 0xe8bdffef, - 0xbf0087f0, - 0xc0000954, - 0xd02200bc, - 0xa00508ec, - 0x07fffffc, - 0xc0000968, - 0xa00508b4, +const uint32_t bes2300p_patch44_ibrt_ins_data_t3[] = { + 0xbf00686b, 0xd00f42b3, 0x4a212100, 0x6863e004, 0x42b34629, 0x4625d00a, + 0xd9264293, 0xd8242e01, 0x462c461e, 0xe001460d, 0x2500462c, 0x8008f8d4, + 0xa00cf894, 0x900df894, 0x46384f16, 0x46224629, 0xfb12f5fc, 0x0014f1a7, + 0xf5fc4621, 0xf1b8fa1d, 0xd0050f00, 0x46514630, 0x2300464a, 0xe00847c0, + 0x21ff480d, 0xfffaf5ff, 0x682ce003, 0xd1ce2c00, 0xb924e000, 0xf44f4808, + 0xf5ff7185, 0xe8bdffef, 0xbf0087f0, 0xc0000954, 0xd02200bc, 0xa00508ec, + 0x07fffffc, 0xc0000968, 0xa00508b4, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch44 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch44 = { 44, BTDRV_PATCH_ACT, sizeof(bes2300p_patch44_ibrt_ins_data_t3), 0x0002706c, 0xb9f8f1e0, 0xc0007460, - (uint8_t *)bes2300p_patch44_ibrt_ins_data_t3 + (uint8_t *)bes2300p_patch44_ibrt_ins_data_t3}; + +const uint32_t bes2300p_patch45_ibrt_ins_data_t3[] = { + 0x4b05b508, 0x2b01681b, 0x2200d104, 0x601a4b02, + 0xfe6cf633, 0xbf00bd08, 0xc00076a4, 0x00000000, + 0xffeef7ff, 0xd1012b04, 0xbff0f5ff, 0xbff5f5ff, /*76b4*/ }; -const uint32_t bes2300p_patch45_ibrt_ins_data_t3[] = -{ - 0x4b05b508, - 0x2b01681b, - 0x2200d104, - 0x601a4b02, - 0xfe6cf633, - 0xbf00bd08, - 0xc00076a4, - 0x00000000, - 0xffeef7ff, - 0xd1012b04, - 0xbff0f5ff, - 0xbff5f5ff,/*76b4*/ -}; - -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch45 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch45 = { 45, BTDRV_PATCH_ACT, sizeof(bes2300p_patch45_ibrt_ins_data_t3), 0x00007690, 0xb80af200, 0xc0007688, - (uint8_t *)bes2300p_patch45_ibrt_ins_data_t3 -};//dbg state + (uint8_t *)bes2300p_patch45_ibrt_ins_data_t3}; // dbg state -const uint32_t bes2300p_patch46_ibrt_ins_data_t3[] = -{ - 0x4b06b508, - 0x02007a98, - 0x0001f040, - 0xfb70f5fa, - 0xbf183801, - 0x30fff04f, - 0xbf00bd08, - 0xc00064d0, - 0xffeef7ff, - 0x781bb918, - 0xf6342b02, - 0xbd08bc89, +const uint32_t bes2300p_patch46_ibrt_ins_data_t3[] = { + 0x4b06b508, 0x02007a98, 0x0001f040, 0xfb70f5fa, 0xbf183801, 0x30fff04f, + 0xbf00bd08, 0xc00064d0, 0xffeef7ff, 0x781bb918, 0xf6342b02, 0xbd08bc89, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch46 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch46 = { 46, BTDRV_PATCH_ACT, sizeof(bes2300p_patch46_ibrt_ins_data_t3), 0x0003b60c, 0xbb70f1cb, 0xc0006cd0, - (uint8_t *)bes2300p_patch46_ibrt_ins_data_t3 -}; + (uint8_t *)bes2300p_patch46_ibrt_ins_data_t3}; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch47 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch47 = { 47, BTDRV_PATCH_ACT, sizeof(bes2300p_patch2a_ibrt_ins_data_t3), 0x0001c528, - 0xbc98f1ea, //a001c528 -> a0206e5c + 0xbc98f1ea, // a001c528 -> a0206e5c 0xc0006e5c, - (uint8_t *)bes2300p_patch2a_ibrt_ins_data_t3 -};//LMP_MSG_HANDLER(sniff_req) LC_CONNECTED + (uint8_t *)bes2300p_patch2a_ibrt_ins_data_t3}; // LMP_MSG_HANDLER(sniff_req) + // LC_CONNECTED -const uint32_t bes2300p_patch48_ibrt_ins_data_t3[] = -{ - 0x681b4b1d, - 0xd1352b00, - 0xb083b530, - 0x8310f3ef, - 0x0f01f013, - 0xb672d117, - 0x25004c18, - 0x95019500, - 0xf1044620, - 0x2208013c, - 0xf5fc2307, - 0x9500f9ed, - 0xf5049501, - 0xf5047080, - 0x2208718a, - 0xf5fc2307, - 0xb662f9e3, - 0x4c0de014, - 0x95002500, - 0x46209501, - 0x013cf104, - 0x23072208, - 0xf9d6f5fc, - 0x95019500, - 0x7080f504, - 0x718af504, - 0x23072208, - 0xf9ccf5fc, - 0xbd30b003, - 0xbf004770, - 0xc0005df0, - 0xc0005b24, - 0xffbef7ff, - 0xe8bdb004, - 0xbf0081f0,/*75a4*/ +const uint32_t bes2300p_patch48_ibrt_ins_data_t3[] = { + 0x681b4b1d, 0xd1352b00, 0xb083b530, 0x8310f3ef, 0x0f01f013, 0xb672d117, + 0x25004c18, 0x95019500, 0xf1044620, 0x2208013c, 0xf5fc2307, 0x9500f9ed, + 0xf5049501, 0xf5047080, 0x2208718a, 0xf5fc2307, 0xb662f9e3, 0x4c0de014, + 0x95002500, 0x46209501, 0x013cf104, 0x23072208, 0xf9d6f5fc, 0x95019500, + 0x7080f504, 0x718af504, 0x23072208, 0xf9ccf5fc, 0xbd30b003, 0xbf004770, + 0xc0005df0, 0xc0005b24, 0xffbef7ff, 0xe8bdb004, 0xbf0081f0, /*75a4*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch48 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch48 = { 48, BTDRV_PATCH_ACT, sizeof(bes2300p_patch48_ibrt_ins_data_t3), 0x000013b0, 0xb8f2f206, 0xc0007518, - (uint8_t *)bes2300p_patch48_ibrt_ins_data_t3 -}; + (uint8_t *)bes2300p_patch48_ibrt_ins_data_t3}; #if 1 -const uint32_t bes2300p_patch49_ibrt_ins_data_t3[] = -{ - 0x78004804, - 0xbf00b120, - 0xfd8cf632, - 0xba1af609, - 0xba1af609, - 0xc0006221, +const uint32_t bes2300p_patch49_ibrt_ins_data_t3[] = { + 0x78004804, 0xbf00b120, 0xfd8cf632, 0xba1af609, 0xba1af609, 0xc0006221, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch49 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch49 = { 49, BTDRV_PATCH_ACT, sizeof(bes2300p_patch49_ibrt_ins_data_t3), 0x000103d8, 0xbddef1f6, 0xc0006f98, - (uint8_t *)bes2300p_patch49_ibrt_ins_data_t3 -};//lc_sco_ind + (uint8_t *)bes2300p_patch49_ibrt_ins_data_t3}; // lc_sco_ind #else -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch49 = -{ - 49, - BTDRV_PATCH_ACT, - 0, - 0x000103d8, - 0xbf00e002, - 0, - NULL, -};//lc_sco_ind +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch49 = { + 49, BTDRV_PATCH_ACT, 0, 0x000103d8, 0xbf00e002, 0, NULL, +}; // lc_sco_ind #endif -const uint32_t bes2300p_patch50_ibrt_ins_data_t3[] = -{ - 0xf632d806, - 0x2801fb0b, - 0x0209d002, - 0xbbeef632, - 0xbf00bd08,/*75d0*/ +const uint32_t bes2300p_patch50_ibrt_ins_data_t3[] = { + 0xf632d806, 0x2801fb0b, 0x0209d002, 0xbbeef632, 0xbf00bd08, /*75d0*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch50 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch50 = { 50, BTDRV_PATCH_ACT, sizeof(bes2300p_patch50_ibrt_ins_data_t3), 0x00039d98, 0xbc0af1cd, 0xc00075b0, - (uint8_t *)bes2300p_patch50_ibrt_ins_data_t3 -};//do not trans stop SCO + (uint8_t *)bes2300p_patch50_ibrt_ins_data_t3}; // do not trans stop SCO -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch51 = -{ - 51, - BTDRV_PATCH_ACT, - 0, - 0x0002ea00, - 0x8ff8e8bd, - 0, - NULL, -};//remove lmp flush +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch51 = { + 51, BTDRV_PATCH_ACT, 0, 0x0002ea00, 0x8ff8e8bd, 0, NULL, +}; // remove lmp flush -const uint32_t bes2300p_patch52_ibrt_ins_data_t3[] = -{ - 0x4605b5f8, - 0xf8544c19, - 0xf6327020, - 0x4606fb05, - 0x4020f854, - 0xfaecf632, - 0xf632b320, - 0x42a8fa61, - 0xf897d120, - 0x2b023047, - 0x2e02d11c, - 0xb1ccd81a, - 0x3047f894, - 0xd1152b02, - 0x3040f894, - 0x0234b973, - 0x0401f044, - 0x4620b2a4, - 0xfeccf5f9, - 0xd0052836, - 0x60a2f44f, - 0x46224621, - 0xfadaf5f9, - 0x4b042001, - 0xbdf86018, - 0x4b022000, - 0xbdf86018, - 0xc0005de4, - 0xc0007668, - 0x4638bf00, - 0xffc2f7ff, - 0x4628d104, - 0xfeb0f5f9, - 0xfc38f614, - 0xbc84f614, - 0x00000000,/*7668*/ +const uint32_t bes2300p_patch52_ibrt_ins_data_t3[] = { + 0x4605b5f8, 0xf8544c19, 0xf6327020, 0x4606fb05, 0x4020f854, + 0xfaecf632, 0xf632b320, 0x42a8fa61, 0xf897d120, 0x2b023047, + 0x2e02d11c, 0xb1ccd81a, 0x3047f894, 0xd1152b02, 0x3040f894, + 0x0234b973, 0x0401f044, 0x4620b2a4, 0xfeccf5f9, 0xd0052836, + 0x60a2f44f, 0x46224621, 0xfadaf5f9, 0x4b042001, 0xbdf86018, + 0x4b022000, 0xbdf86018, 0xc0005de4, 0xc0007668, 0x4638bf00, + 0xffc2f7ff, 0x4628d104, 0xfeb0f5f9, 0xfc38f614, 0xbc84f614, + 0x00000000, /*7668*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch52 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch52 = { 52, BTDRV_PATCH_ACT, sizeof(bes2300p_patch52_ibrt_ins_data_t3), 0x0001bed0, 0xbbbef1eb, 0xc00075dc, - (uint8_t *)bes2300p_patch52_ibrt_ins_data_t3 -};//delay mobile unsniff lmp + (uint8_t *)bes2300p_patch52_ibrt_ins_data_t3}; // delay mobile unsniff lmp -const uint32_t bes2300p_patch53_ibrt_ins_data_t3[] = -{ - 0x681b4b03,/*76fc*/ - 0xd1012b01,/*7700*/ - 0xfb06f632,/*7704*/ - 0x81f0e8bd,/*7708*/ - 0xc0007434,/*770c*/ +const uint32_t bes2300p_patch53_ibrt_ins_data_t3[] = { + 0x681b4b03, /*76fc*/ + 0xd1012b01, /*7700*/ + 0xfb06f632, /*7704*/ + 0x81f0e8bd, /*7708*/ + 0xc0007434, /*770c*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch53 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch53 = { 53, BTDRV_PATCH_ACT, sizeof(bes2300p_patch53_ibrt_ins_data_t3), 0x0003a088, 0xbb38f1cd, 0xc00076fc, - (uint8_t *)bes2300p_patch53_ibrt_ins_data_t3 -};//don not trans start ibrt sco + (uint8_t *) + bes2300p_patch53_ibrt_ins_data_t3}; // don not trans start ibrt sco -const uint32_t bes2300p_patch54_ibrt_ins_data_t3[] = -{ - 0xbf000a28, - 0xffc6f626, - 0x0a210a28, - 0xb8a4f611,/*767c*/ +const uint32_t bes2300p_patch54_ibrt_ins_data_t3[] = { + 0xbf000a28, 0xffc6f626, 0x0a210a28, 0xb8a4f611, /*767c*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch54 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch54 = { 54, BTDRV_PATCH_ACT, sizeof(bes2300p_patch54_ibrt_ins_data_t3), 0x000187c4, 0xbf54f1ee, 0xc0007670, - (uint8_t *)bes2300p_patch54_ibrt_ins_data_t3 -};//protect tws tx type + (uint8_t *)bes2300p_patch54_ibrt_ins_data_t3}; // protect tws tx type #if 0 const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch55 = @@ -1836,33 +1099,23 @@ const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch55 = NULL, };//decrease the connection time of TWS link in SCO #else -const uint32_t bes2300p_patch55_ibrt_ins_data_t3[] = -{ - 0x68134a06, - 0x2380f023, - 0xf5a26013, - 0x68137206, - 0x0301f023, - 0xbf006013, - 0xbdaff63e, - 0xd0220400,/*77dc*/ +const uint32_t bes2300p_patch55_ibrt_ins_data_t3[] = { + 0x68134a06, 0x2380f023, 0xf5a26013, 0x68137206, + 0x0301f023, 0xbf006013, 0xbdaff63e, 0xd0220400, /*77dc*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch55 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ibrt_ins_patch55 = { 55, BTDRV_PATCH_ACT, sizeof(bes2300p_patch55_ibrt_ins_data_t3), 0x00046330, 0xba46f1c1, 0xc00077c0, - (uint8_t *)bes2300p_patch55_ibrt_ins_data_t3 -};//disable hw spi in BLE push + (uint8_t *)bes2300p_patch55_ibrt_ins_data_t3}; // disable hw spi in BLE push #endif /////2300p t3 ibrt patch (chip id =2) -static const uint32_t best2300p_t3_ibrt_ins_patch_config[] = -{ +static const uint32_t best2300p_t3_ibrt_ins_patch_config[] = { 56, (uint32_t)&bes2300p_t3_ibrt_ins_patch0, (uint32_t)&bes2300p_t3_ibrt_ins_patch1, @@ -1923,56 +1176,29 @@ static const uint32_t best2300p_t3_ibrt_ins_patch_config[] = }; #else -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch0 = -{ - 0, - BTDRV_PATCH_ACT, - 0, - 0x000324d4, - 0xbf00bf00, - 0, - NULL -};// afh filter disable +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch0 = { + 0, BTDRV_PATCH_ACT, 0, 0x000324d4, 0xbf00bf00, 0, + NULL}; // afh filter disable -const uint32_t bes2300p_patch1_ins_data_t3[] = -{ - 0xf8934b09, - 0xf0133084, - 0xd0050f06, - 0xf6374620, - 0x4601f839, - 0xe0052400, - 0xf8934b03, - 0xbf003084, - 0xb975f636, - 0xb9bbf636, - 0xc0006568, +const uint32_t bes2300p_patch1_ins_data_t3[] = { + 0xf8934b09, 0xf0133084, 0xd0050f06, 0xf6374620, 0x4601f839, 0xe0052400, + 0xf8934b03, 0xbf003084, 0xb975f636, 0xb9bbf636, 0xc0006568, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch1 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch1 = { 1, BTDRV_PATCH_ACT, sizeof(bes2300p_patch1_ins_data_t3), 0x0003cd08, 0xbe7af1c9, 0xc0006a00, - (uint8_t *)bes2300p_patch1_ins_data_t3 -};// set ble adv data + (uint8_t *)bes2300p_patch1_ins_data_t3}; // set ble adv data -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch2 = -{ - 2, - BTDRV_PATCH_ACT, - 0, - 0x0003cbf0, - 0xbf00e004, - 0, - NULL -};// set ble scan response data +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch2 = { + 2, BTDRV_PATCH_ACT, 0, 0x0003cbf0, 0xbf00e004, 0, + NULL}; // set ble scan response data -const uint32_t bes2300p_patch3_ins_data_t3[] = -{ +const uint32_t bes2300p_patch3_ins_data_t3[] = { /*6a98*/ 0x99049803, /*6a9c*/ 0x4b12b470, /*6aa0*/ 0x010e5c5a, @@ -1992,13 +1218,13 @@ const uint32_t bes2300p_patch3_ins_data_t3[] = /*6ad8*/ 0xf0f4fb93, /*6adc*/ 0xbc70b240, /*6ae0*/ 0x22019904, - /*6ae4*/ 0xba00f626, //jump a0206ae4 -> a002cee8 - /*6ae8*/ 0xc0006af8, //addr of rssi_idx_for_agc - /*6aec*/ 0xc0006afc, //addr of rssi_set_for_agc - /*6af0*/ 0xc0006af4, //addr of N - /*6af4*/ 0x00000005, //N : 1 ~ 16 - /*6af8*/ 0x00000000, //rssi_idx_for_agc[3] - /*6afc*/ 0xbabababa, //rssi_set_for_agc[3*16] + /*6ae4*/ 0xba00f626, // jump a0206ae4 -> a002cee8 + /*6ae8*/ 0xc0006af8, // addr of rssi_idx_for_agc + /*6aec*/ 0xc0006afc, // addr of rssi_set_for_agc + /*6af0*/ 0xc0006af4, // addr of N + /*6af4*/ 0x00000005, // N : 1 ~ 16 + /*6af8*/ 0x00000000, // rssi_idx_for_agc[3] + /*6afc*/ 0xbabababa, // rssi_set_for_agc[3*16] /*6b00*/ 0xbabababa, /*6b04*/ 0xbabababa, /*6b08*/ 0xbabababa, @@ -2013,787 +1239,400 @@ const uint32_t bes2300p_patch3_ins_data_t3[] = /*6b2c*/ 0xbabababa, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch3 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch3 = { 3, BTDRV_PATCH_ACT, sizeof(bes2300p_patch3_ins_data_t3), 0x0002cee4, - 0xbdd8f1d9, //jump a002cee4 -> a0206a98 + 0xbdd8f1d9, // jump a002cee4 -> a0206a98 0xc0006a98, - (uint8_t *)bes2300p_patch3_ins_data_t3 -};//ld_acl_rx() average rssi + (uint8_t *)bes2300p_patch3_ins_data_t3}; // ld_acl_rx() average rssi -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch4 = -{ - 4, - BTDRV_PATCH_ACT, - 0, - 0x0002ceb4, - 0xe00b0f0f, - 0, - NULL -};//ld_acl_rx() average rssi +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch4 = { + 4, BTDRV_PATCH_ACT, 0, 0x0002ceb4, 0xe00b0f0f, 0, + NULL}; // ld_acl_rx() average rssi -const uint32_t bes2300p_patch5_ins_data_t3[] = -{ - 0x2028f843,/*6b3c*/ - 0xf8434b08, - 0x4b052028, - 0x4b0e701a, - 0x2201701a, - 0xf8434b08, - 0xbf002028, - 0xba32f624, - 0xc0006b60, - 0x00000000, - 0xc0006b68, - 0x00000000, - 0x00000000, - 0x00000000, - 0xc0006b78, - 0x00000001, - 0x00000001, - 0x00000001, - 0xc0006b88, - 0x00000000,/*6b88*/ +const uint32_t bes2300p_patch5_ins_data_t3[] = { + 0x2028f843, /*6b3c*/ + 0xf8434b08, 0x4b052028, 0x4b0e701a, 0x2201701a, 0xf8434b08, + 0xbf002028, 0xba32f624, 0xc0006b60, 0x00000000, 0xc0006b68, + 0x00000000, 0x00000000, 0x00000000, 0xc0006b78, 0x00000001, + 0x00000001, 0x00000001, 0xc0006b88, 0x00000000, /*6b88*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch5 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch5 = { 5, BTDRV_PATCH_ACT, sizeof(bes2300p_patch5_ins_data_t3), 0x0002afbc, 0xbdbef1db, 0xc0006b3c, - (uint8_t *)bes2300p_patch5_ins_data_t3 -};//sync clear count + (uint8_t *)bes2300p_patch5_ins_data_t3}; // sync clear count -const uint32_t bes2300p_patch6_ins_data_t3[] = -{ - 0x47f0e92d,/*7050*/ - 0x4b97b082, - 0x236e5c1e, - 0xf300fb03, - 0x5a9b4a95, - 0x4f00f413, - 0x8120f040, - 0x46044689, - 0x1800ea4f, - 0xeb084f91, - 0x4b910507, - 0xa020f853, - 0xf8524a90, - 0x33013020, - 0x3020f842, - 0xf860f635, - 0x42a04601, - 0x8088f040, - 0xf8534b8a, - 0x4b8a2024, - 0x429a681b, - 0xf8dad817, - 0xebc22084, - 0xf0230309, - 0xf1b34378, - 0xd9046f80, - 0x0302ebc9, - 0x4378f023, - 0x4a82425b, - 0x0024f852, - 0x68124a81, - 0xf200fb02, - 0xf2404293, - 0x4b7f80eb, - 0x3000f993, - 0x4b7eb9c3, - 0xc000f893, - 0x0f00f1bc, - 0x462ad00a, - 0x0e0ceb05, - 0xf9122300, - 0x44030b01, - 0xd1fa4572, - 0xe0014662, - 0x46132200, - 0xfcfcfb93, - 0xf8804872, - 0xe001c000, - 0x46132200, - 0xf890486f, - 0x4870e000, - 0x9000f890, - 0xf890486f, - 0xfa4fc000, - 0xebc9f08e, - 0xfa4f0000, - 0x4550fa8c, - 0xebc9dd05, - 0x48660e0e, - 0xe000f880, - 0x4864e002, - 0xc000f880, - 0x0e00f04f, - 0xf840485d, - 0xf8dfe024, - 0xf85ee178, - 0x30010024, - 0x0024f84e, - 0x7800485d, - 0xd2054286, - 0x783f4f5a, - 0x360155af, - 0xe004b2f6, - 0x78364e57, - 0x6007f808, - 0x4f4d2601, - 0x4282553e, - 0x442ada06, - 0xf9124405, - 0x44234b01, - 0xd1fa42aa, - 0xfb934a53, - 0x9200f0f0, - 0xb2406a14, - 0x23002201, - 0xe08147a0, - 0xf8534b46, - 0x4b4e2024, - 0x429a681b, - 0xf8dad816, - 0xebc22084, - 0xf0230309, - 0xf1b34378, - 0xd9046f80, - 0x0302ebc9, - 0x4378f023, - 0x4a3e425b, - 0x1024f852, - 0x68124a44, - 0xf201fb02, - 0xd9634293, - 0xf9934b42, - 0xb9c33000, - 0xf8934b3a, - 0xf1bee000, - 0xd00a0f00, - 0xeb05462a, - 0x2300000e, - 0x1b01f912, - 0x4282440b, - 0x4672d1fa, - 0x2200e001, - 0xfb934613, - 0x4936fefe, - 0xe000f881, - 0x2200e001, - 0x49334613, - 0x49337808, - 0xc000f891, - 0xf8914932, - 0xb241e000, - 0x0101ebcc, - 0xf98efa4f, - 0xdd044549, - 0x0000ebcc, - 0x7008492a, - 0x4929e002, - 0xe000f881, - 0x491c2000, - 0x0024f841, - 0xf850481c, - 0x31011024, - 0x1024f840, - 0x7808491c, - 0xd2054286, - 0x78094920, - 0x360155a9, - 0xe004b2f6, - 0x7809491d, - 0x1007f808, - 0x490c2601, - 0x4282550e, - 0x442ada06, - 0xf9124405, - 0x440b1b01, - 0xd1fa42aa, - 0xfb934a12, - 0x9200f0f0, - 0xb2406a15, - 0x22014621, - 0x47a82300, - 0xe8bdb002, - 0xbf0087f0, - 0xc0006af8,//rssi_idx_for_agc[link_id] shenxin - 0xd02111f8,//EM_BT_RD(EM_BT_RXBIT_ADDR - 0xc0006afc,//rssi_set_for_agc shenxin - 0xc00009d4,//ld_acl_env[link_id] - 0xc0006b68,//link_no_sync_count[link_id] - 0xc00072fc,//link_agc_thd_tws - 0xc0006b78,//link_no_sync_count_time[link_id] - 0xc0007300,//link_agc_thd_tws_time - 0xc0006b60,//rssi_store_tws - 0xc0006af4,//n shenxin - 0xc0007304,//rssi_tws_step - 0xc0007308,//rssi_min_value_tws - 0xc0004268,//rwip_rf.rxgain_cntl - 0xc000730c,//link_agc_thd_mobile - 0xc0007310,//link_agc_thd_mobile_time - 0xc0006b88,//rssi_store_mobile - 0xc0007314,//rssi_mobile_step - 0xc0007318,//rssi_min_value_mobile - 0xffffffff,//link_agc_thd_tws - 0x00000030,//link_agc_thd_tws_time - 0x00000014,//rssi_tws_step - 0x0000009c,//rssi_min_value_tws - 0xffffffff,//link_agc_thd_mobile - 0x00000030,//link_agc_thd_mobile_time - 0x00000014,//rssi_mobile_step - 0x000000a1,//rssi_min_value_mobile - 0x99029804, - 0xfe96f7ff, - 0xfc48f632, - 0xb898f626,/*7328*/ +const uint32_t bes2300p_patch6_ins_data_t3[] = { + 0x47f0e92d, /*7050*/ + 0x4b97b082, 0x236e5c1e, 0xf300fb03, 0x5a9b4a95, 0x4f00f413, 0x8120f040, + 0x46044689, 0x1800ea4f, 0xeb084f91, 0x4b910507, 0xa020f853, 0xf8524a90, + 0x33013020, 0x3020f842, 0xf860f635, 0x42a04601, 0x8088f040, 0xf8534b8a, + 0x4b8a2024, 0x429a681b, 0xf8dad817, 0xebc22084, 0xf0230309, 0xf1b34378, + 0xd9046f80, 0x0302ebc9, 0x4378f023, 0x4a82425b, 0x0024f852, 0x68124a81, + 0xf200fb02, 0xf2404293, 0x4b7f80eb, 0x3000f993, 0x4b7eb9c3, 0xc000f893, + 0x0f00f1bc, 0x462ad00a, 0x0e0ceb05, 0xf9122300, 0x44030b01, 0xd1fa4572, + 0xe0014662, 0x46132200, 0xfcfcfb93, 0xf8804872, 0xe001c000, 0x46132200, + 0xf890486f, 0x4870e000, 0x9000f890, 0xf890486f, 0xfa4fc000, 0xebc9f08e, + 0xfa4f0000, 0x4550fa8c, 0xebc9dd05, 0x48660e0e, 0xe000f880, 0x4864e002, + 0xc000f880, 0x0e00f04f, 0xf840485d, 0xf8dfe024, 0xf85ee178, 0x30010024, + 0x0024f84e, 0x7800485d, 0xd2054286, 0x783f4f5a, 0x360155af, 0xe004b2f6, + 0x78364e57, 0x6007f808, 0x4f4d2601, 0x4282553e, 0x442ada06, 0xf9124405, + 0x44234b01, 0xd1fa42aa, 0xfb934a53, 0x9200f0f0, 0xb2406a14, 0x23002201, + 0xe08147a0, 0xf8534b46, 0x4b4e2024, 0x429a681b, 0xf8dad816, 0xebc22084, + 0xf0230309, 0xf1b34378, 0xd9046f80, 0x0302ebc9, 0x4378f023, 0x4a3e425b, + 0x1024f852, 0x68124a44, 0xf201fb02, 0xd9634293, 0xf9934b42, 0xb9c33000, + 0xf8934b3a, 0xf1bee000, 0xd00a0f00, 0xeb05462a, 0x2300000e, 0x1b01f912, + 0x4282440b, 0x4672d1fa, 0x2200e001, 0xfb934613, 0x4936fefe, 0xe000f881, + 0x2200e001, 0x49334613, 0x49337808, 0xc000f891, 0xf8914932, 0xb241e000, + 0x0101ebcc, 0xf98efa4f, 0xdd044549, 0x0000ebcc, 0x7008492a, 0x4929e002, + 0xe000f881, 0x491c2000, 0x0024f841, 0xf850481c, 0x31011024, 0x1024f840, + 0x7808491c, 0xd2054286, 0x78094920, 0x360155a9, 0xe004b2f6, 0x7809491d, + 0x1007f808, 0x490c2601, 0x4282550e, 0x442ada06, 0xf9124405, 0x440b1b01, + 0xd1fa42aa, 0xfb934a12, 0x9200f0f0, 0xb2406a15, 0x22014621, 0x47a82300, + 0xe8bdb002, 0xbf0087f0, + 0xc0006af8, // rssi_idx_for_agc[link_id] shenxin + 0xd02111f8, // EM_BT_RD(EM_BT_RXBIT_ADDR + 0xc0006afc, // rssi_set_for_agc shenxin + 0xc00009d4, // ld_acl_env[link_id] + 0xc0006b68, // link_no_sync_count[link_id] + 0xc00072fc, // link_agc_thd_tws + 0xc0006b78, // link_no_sync_count_time[link_id] + 0xc0007300, // link_agc_thd_tws_time + 0xc0006b60, // rssi_store_tws + 0xc0006af4, // n shenxin + 0xc0007304, // rssi_tws_step + 0xc0007308, // rssi_min_value_tws + 0xc0004268, // rwip_rf.rxgain_cntl + 0xc000730c, // link_agc_thd_mobile + 0xc0007310, // link_agc_thd_mobile_time + 0xc0006b88, // rssi_store_mobile + 0xc0007314, // rssi_mobile_step + 0xc0007318, // rssi_min_value_mobile + 0xffffffff, // link_agc_thd_tws + 0x00000030, // link_agc_thd_tws_time + 0x00000014, // rssi_tws_step + 0x0000009c, // rssi_min_value_tws + 0xffffffff, // link_agc_thd_mobile + 0x00000030, // link_agc_thd_mobile_time + 0x00000014, // rssi_mobile_step + 0x000000a1, // rssi_min_value_mobile + 0x99029804, 0xfe96f7ff, 0xfc48f632, 0xb898f626, /*7328*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch6 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch6 = { 6, BTDRV_PATCH_ACT, sizeof(bes2300p_patch6_ins_data_t3), 0x0002d458, 0xbf60f1d9, 0xc0007050, - (uint8_t *)bes2300p_patch6_ins_data_t3 -};//swagc no sync + (uint8_t *)bes2300p_patch6_ins_data_t3}; // swagc no sync -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch7 = -{ - 7, - BTDRV_PATCH_ACT, - 0, - 0x0000e47a, - 0xe0027b20, - 0, - NULL -};//lm_inq_res_ind_handler() rssi +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch7 = { + 7, BTDRV_PATCH_ACT, 0, 0x0000e47a, 0xe0027b20, 0, + NULL}; // lm_inq_res_ind_handler() rssi -const uint32_t bes2300p_patch8_ins_data_t3[] = -{ - 0x2300b430, - 0x4d072103, - 0x4290b2da, - 0xf855d004, - 0x2c004023, - 0x4611bf18, - 0x2b033301, - 0x4608d1f4, - 0x4770bc30, - 0xc00009d4, +const uint32_t bes2300p_patch8_ins_data_t3[] = { + 0x2300b430, 0x4d072103, 0x4290b2da, 0xf855d004, 0x2c004023, + 0x4611bf18, 0x2b033301, 0x4608d1f4, 0x4770bc30, 0xc00009d4, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch8 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch8 = { 8, BTDRV_PATCH_ACT, sizeof(bes2300p_patch8_ins_data_t3), 0x0002c8c0, 0xbb2ef1da, 0xc0006f20, - (uint8_t *)bes2300p_patch8_ins_data_t3 -};//find_other_acl_link + (uint8_t *)bes2300p_patch8_ins_data_t3}; // find_other_acl_link -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch9 = -{ - 9, - BTDRV_PATCH_ACT, - 0, - 0x000123e8, - 0xf7f1bf00, - 0, - NULL -};//ignore lm_get_nb_acl(MASTER_FLAG|SLAVE_FLAG) > 1 when cal wesco +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch9 = { + 9, BTDRV_PATCH_ACT, 0, 0x000123e8, 0xf7f1bf00, 0, + NULL}; // ignore lm_get_nb_acl(MASTER_FLAG|SLAVE_FLAG) > 1 when cal wesco -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch10 = -{ - 10, - BTDRV_PATCH_ACT, - 0, - 0x0002ff48, - 0xd9590f05, - 0, - NULL, -};//ignore bld_sco_retransmit_dec function +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch10 = { + 10, BTDRV_PATCH_ACT, 0, 0x0002ff48, 0xd9590f05, 0, NULL, +}; // ignore bld_sco_retransmit_dec function -const uint32_t bes2300p_patch11_ins_data_t3[] = -{ +const uint32_t bes2300p_patch11_ins_data_t3[] = { 0x304bf996, 0x44233302, 0xbbfcf629, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch11 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch11 = { 11, BTDRV_PATCH_ACT, sizeof(bes2300p_patch11_ins_data_t3), 0x00030748, 0xbbfef1d6, 0xc0006f48, - (uint8_t *)bes2300p_patch11_ins_data_t3 -};//ld_calculate_timestamp + (uint8_t *)bes2300p_patch11_ins_data_t3}; // ld_calculate_timestamp -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch12 = -{ - 12, - BTDRV_PATCH_ACT, - 0, - 0x0001bcf4, - 0xbf00e004, - 0, - NULL, -};//LMP_MSG_HANDLER(max_slot_req) +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch12 = { + 12, BTDRV_PATCH_ACT, 0, 0x0001bcf4, 0xbf00e004, 0, NULL, +}; // LMP_MSG_HANDLER(max_slot_req) -const uint32_t bes2300p_patch13_ins_data_t3[] = -{ - 0x3040f894, - 0xd1032b00, - 0x222a210b, - 0xbe00f616, - 0xbd06f616 -}; +const uint32_t bes2300p_patch13_ins_data_t3[] = { + 0x3040f894, 0xd1032b00, 0x222a210b, 0xbe00f616, 0xbd06f616}; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch13 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch13 = { 13, BTDRV_PATCH_ACT, sizeof(bes2300p_patch13_ins_data_t3), 0x0001d63c, 0xb9f8f1e9, 0xc0006a30, - (uint8_t *)bes2300p_patch13_ins_data_t3 -};//LMP_MSG_HANDLER(aurand) + (uint8_t *)bes2300p_patch13_ins_data_t3}; // LMP_MSG_HANDLER(aurand) -const uint32_t bes2300p_patch14_ins_data_t3[] = -{ - 0xf8534b04, - 0x46283026, - 0x135ef893, - 0xfc62f5fa, - 0xbd55f616, - 0xc0005de4 -}; +const uint32_t bes2300p_patch14_ins_data_t3[] = { + 0xf8534b04, 0x46283026, 0x135ef893, 0xfc62f5fa, 0xbd55f616, 0xc0005de4}; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch14 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch14 = { 14, BTDRV_PATCH_ACT, sizeof(bes2300p_patch14_ins_data_t3), 0x0001d4f4, 0xbaa6f1e9, 0xc0006a44, - (uint8_t *)bes2300p_patch14_ins_data_t3 -};//LMP_MSG_HANDLER(aurand) + (uint8_t *)bes2300p_patch14_ins_data_t3}; // LMP_MSG_HANDLER(aurand) -const uint32_t bes2300p_patch15_ins_data_t3[] = -{ - 0x3040f897, - 0xd1032b00, - 0xbbacf617, - 0x21234620, - 0xf836f610, - 0xbc8bf617/*0xc0006a74*/ +const uint32_t bes2300p_patch15_ins_data_t3[] = { + 0x3040f897, 0xd1032b00, 0xbbacf617, + 0x21234620, 0xf836f610, 0xbc8bf617 /*0xc0006a74*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch15 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch15 = { 15, BTDRV_PATCH_ACT, sizeof(bes2300p_patch15_ins_data_t3), 0x0001e1c0, 0xbc4ef1e8, 0xc0006a60, - (uint8_t *)bes2300p_patch15_ins_data_t3 -};//LMP_MSG_HANDLER(not_accepted) + (uint8_t *)bes2300p_patch15_ins_data_t3}; // LMP_MSG_HANDLER(not_accepted) -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch16 = -{ - 16, - BTDRV_PATCH_ACT, - 0, - 0x0002ea00, - 0x8ff8e8bd, - 0, - NULL, -};//remove lmp flush +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch16 = { + 16, BTDRV_PATCH_ACT, 0, 0x0002ea00, 0x8ff8e8bd, 0, NULL, +}; // remove lmp flush -const uint32_t bes2300p_patch17_ins_data_t3[] = -{ - 0xfe4af5f9, - 0xbf002300, - 0x30c8f884, - 0xbaf8f624,/*6f18*/ +const uint32_t bes2300p_patch17_ins_data_t3[] = { + 0xfe4af5f9, 0xbf002300, 0x30c8f884, 0xbaf8f624, /*6f18*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch17 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch17 = { 17, BTDRV_PATCH_ACT, sizeof(bes2300p_patch17_ins_data_t3), 0x0002b508, 0xbd00f1db, 0xc0006f0c, - (uint8_t *)bes2300p_patch17_ins_data_t3 -};///role switch fail + (uint8_t *)bes2300p_patch17_ins_data_t3}; /// role switch fail -const uint32_t bes2300p_patch18_ins_data_t3[] = -{ - 0xbf004628, - 0xfdc4f60d, - 0x21144628, - 0xba4af60f,/*6c94*/ +const uint32_t bes2300p_patch18_ins_data_t3[] = { + 0xbf004628, 0xfdc4f60d, 0x21144628, 0xba4af60f, /*6c94*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch18 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch18 = { 18, BTDRV_PATCH_ACT, sizeof(bes2300p_patch18_ins_data_t3), 0x00016128, 0xbdaef1f0, 0xc0006c88, - (uint8_t *)bes2300p_patch18_ins_data_t3 -};//start lmp to before sending LMP_HostConnectionReq + (uint8_t *)bes2300p_patch18_ins_data_t3}; // start lmp to before sending + // LMP_HostConnectionReq -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch19 = -{ - 19, - BTDRV_PATCH_ACT, - 0, - 0x00020640, - 0xe00dbf00, - 0, - NULL, -};//detach directly +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch19 = { + 19, BTDRV_PATCH_ACT, 0, 0x00020640, 0xe00dbf00, 0, NULL, +}; // detach directly -const uint32_t bes2300p_patch20_ins_data_t3[] = -{ - 0x305af893, - 0xd1032b00, - 0x12f4f240, - 0xbf00e002, - 0x32b8f640, - 0xbe30f60d,/*6bdc*/ +const uint32_t bes2300p_patch20_ins_data_t3[] = { + 0x305af893, 0xd1032b00, 0x12f4f240, + 0xbf00e002, 0x32b8f640, 0xbe30f60d, /*6bdc*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch20 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch20 = { 20, BTDRV_PATCH_ACT, sizeof(bes2300p_patch20_ins_data_t3), 0x0001483c, 0xb9c4f1f2, 0xc0006bc8, - (uint8_t *)bes2300p_patch20_ins_data_t3 -};//lmp to 5s before connection cmp sent + (uint8_t *)bes2300p_patch20_ins_data_t3}; // lmp to 5s before connection cmp + // sent -const uint32_t bes2300p_patch21_ins_data_t3[] = -{ - 0x4603b508, - 0x8210f3ef, - 0x0f01f012, - 0xb672d112, - 0xf5a34811, - 0x3b285343, - 0xfba14910, - 0xf3c32303, - 0xeb032387, - 0xeb000343, - 0x31940183, - 0xfdd0f5fc, - 0xbd08b662, - 0xf5a34808, - 0x3b285343, - 0xfba14907, - 0xf3c32303, - 0xeb032387, - 0xeb000343, - 0x31940183, - 0xfdbef5fc, - 0xbf00bd08, - 0xc0005b4c, - 0xff00ff01, +const uint32_t bes2300p_patch21_ins_data_t3[] = { + 0x4603b508, 0x8210f3ef, 0x0f01f012, 0xb672d112, 0xf5a34811, 0x3b285343, + 0xfba14910, 0xf3c32303, 0xeb032387, 0xeb000343, 0x31940183, 0xfdd0f5fc, + 0xbd08b662, 0xf5a34808, 0x3b285343, 0xfba14907, 0xf3c32303, 0xeb032387, + 0xeb000343, 0x31940183, 0xfdbef5fc, 0xbf00bd08, 0xc0005b4c, 0xff00ff01, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch21 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch21 = { 21, BTDRV_PATCH_ACT, sizeof(bes2300p_patch21_ins_data_t3), 0x00008b24, 0xb8f8f1fe, 0xc0006d18, - (uint8_t *)bes2300p_patch21_ins_data_t3 -};//add lock interrupt when free acl buf + (uint8_t *)bes2300p_patch21_ins_data_t3}; // add lock interrupt when free + // acl buf -const uint32_t bes2300p_patch22_ins_data_t3[] = -{ - 0x2040f897,/*6e00*/ - 0xd1112a01, - 0x0109f106, - 0xf5fc4608, - 0x2813fd4b, - 0x221ed802, - 0xbc54f614, - 0x2a017a32, - 0xf614d801, - 0x221ebbf6, - 0xbc4cf614, - 0xbc47f614,/*6e2c*/ +const uint32_t bes2300p_patch22_ins_data_t3[] = { + 0x2040f897, /*6e00*/ + 0xd1112a01, 0x0109f106, 0xf5fc4608, 0x2813fd4b, 0x221ed802, 0xbc54f614, + 0x2a017a32, 0xf614d801, 0x221ebbf6, 0xbc4cf614, 0xbc47f614, /*6e2c*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch22 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch22 = { 22, BTDRV_PATCH_ACT, sizeof(bes2300p_patch22_ins_data_t3), 0x0001b604, 0xbbfcf1eb, 0xc0006e00, - (uint8_t *)bes2300p_patch22_ins_data_t3 -};//reject set afh lmp when channel number less than 20 + (uint8_t *)bes2300p_patch22_ins_data_t3}; // reject set afh lmp when channel + // number less than 20 -/*patch 23,24 for HiSilicon,BCS4.2,ver0x608 and Broadcom,BCS4.2,ver0x6106 Enhanced Data Rate problem*/ -const uint32_t bes2300p_patch23_ins_data_t3[] = -{ - 0x0a00b538,/*c0006b90*/ - 0xf8534b08, - 0xb2c45020, - 0xf6274620, - 0x4620fdaf, - 0xf895210b, - 0xf61d2046, - 0x2201ff63, - 0x701a4b02, - 0xbf00bd38, - 0xc0005de4, - 0xc0006bc0, - 0x00000000 /*c0006bc0*/ +/*patch 23,24 for HiSilicon,BCS4.2,ver0x608 and Broadcom,BCS4.2,ver0x6106 + * Enhanced Data Rate problem*/ +const uint32_t bes2300p_patch23_ins_data_t3[] = { + 0x0a00b538, /*c0006b90*/ + 0xf8534b08, 0xb2c45020, 0xf6274620, 0x4620fdaf, + 0xf895210b, 0xf61d2046, 0x2201ff63, 0x701a4b02, + 0xbf00bd38, 0xc0005de4, 0xc0006bc0, 0x00000000 /*c0006bc0*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch23 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch23 = { 23, BTDRV_PATCH_ACT, sizeof(bes2300p_patch23_ins_data_t3), 0x000144fc, 0xbb48f1f2, 0xc0006b90, - (uint8_t *)bes2300p_patch23_ins_data_t3 -};//table request + (uint8_t *)bes2300p_patch23_ins_data_t3}; // table request -const uint32_t bes2300p_patch24_ins_data_t3[] = -{ - 0x0a00b538,/*c0006be0*/ - 0xf8534b0f, - 0xb2c45020, - 0x104df895, - 0x31004620, - 0x2101bf18, - 0xfab8f628, - 0x8d298ea8, - 0xf61d2201, - 0x4601f9f7, - 0xf6284620, - 0x2301fae5, - 0x3062f885, - 0xf6274620, - 0x2200fd7f, - 0x701a4b02, - 0xbf00bd38, - 0xc0005de4, - 0xc0006bc0, - 0x78244c04, - 0x4628b114, - 0xffd4f7ff, - 0xb00d2000, - 0x83f0e8bd, - 0xc0006bc0 /*c0006c40*/ +const uint32_t bes2300p_patch24_ins_data_t3[] = { + 0x0a00b538, /*c0006be0*/ + 0xf8534b0f, 0xb2c45020, 0x104df895, 0x31004620, 0x2101bf18, + 0xfab8f628, 0x8d298ea8, 0xf61d2201, 0x4601f9f7, 0xf6284620, + 0x2301fae5, 0x3062f885, 0xf6274620, 0x2200fd7f, 0x701a4b02, + 0xbf00bd38, 0xc0005de4, 0xc0006bc0, 0x78244c04, 0x4628b114, + 0xffd4f7ff, 0xb00d2000, 0x83f0e8bd, 0xc0006bc0 /*c0006c40*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch24 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch24 = { 24, BTDRV_PATCH_ACT, sizeof(bes2300p_patch24_ins_data_t3), 0x00023eb8, 0xbeb8f1e2, 0xc0006be0, - (uint8_t *)bes2300p_patch24_ins_data_t3 -};//table request configure -/*end patch 23,24 for HiSilicon,BCS4.2,ver0x608 and Broadcom,BCS4.2,ver0x6106 Enhanced Data Rate problem*/ + (uint8_t *)bes2300p_patch24_ins_data_t3}; // table request configure +/*end patch 23,24 for HiSilicon,BCS4.2,ver0x608 and Broadcom,BCS4.2,ver0x6106 + * Enhanced Data Rate problem*/ -const uint32_t bes2300p_patch25_ins_data_t3[] = -{ - 0xfa80f5fc,/*c0006f58*/ - 0xb9737f43, - 0x2b01786b, - 0x2b03d01a, - 0x2b05d010, - 0xf896d00e, - 0x22203044, - 0x4620212e, - 0xfd90f61d, - 0xf896e010, - 0x212e2044, - 0xf61d4620, - 0xe009fd65, - 0xfd70f60c, - 0xd1ec2800, - 0x325ef896, - 0xd1e82b00, - 0xbeb0f614, - 0xbec1f614,/*c0006fa0*/ +const uint32_t bes2300p_patch25_ins_data_t3[] = { + 0xfa80f5fc, /*c0006f58*/ + 0xb9737f43, 0x2b01786b, 0x2b03d01a, 0x2b05d010, 0xf896d00e, + 0x22203044, 0x4620212e, 0xfd90f61d, 0xf896e010, 0x212e2044, + 0xf61d4620, 0xe009fd65, 0xfd70f60c, 0xd1ec2800, 0x325ef896, + 0xd1e82b00, 0xbeb0f614, 0xbec1f614, /*c0006fa0*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch25 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch25 = { 25, BTDRV_PATCH_ACT, sizeof(bes2300p_patch25_ins_data_t3), 0x0001bcb8, 0xb94ef1eb, 0xc0006f58, - (uint8_t *)bes2300p_patch25_ins_data_t3 -};//LMP_MSG_HANDLER(max_slot_req) + (uint8_t *)bes2300p_patch25_ins_data_t3}; // LMP_MSG_HANDLER(max_slot_req) -const uint32_t bes2300p_patch26_ins_data_t3[] = -{ - 0x681b4b16, - 0xd0222b00, - 0xf8b34b16, - 0xf01331c0, - 0xd1000f18, - 0x4b13e020, - 0x71c2f893, - 0xff12f61f, - 0xd0192f02, - 0xf8534b10, - 0x2b003027, - 0x6b5ad014, - 0xd9074282, - 0xf8931a10, - 0xeb033042, - 0x42980343, - 0x2200d80a, - 0x46204611, - 0xfa62f629, - 0x4620e004, - 0xbf002100, - 0xbe0cf629, - 0xbe0df629, +const uint32_t bes2300p_patch26_ins_data_t3[] = { + 0x681b4b16, 0xd0222b00, 0xf8b34b16, 0xf01331c0, 0xd1000f18, 0x4b13e020, + 0x71c2f893, 0xff12f61f, 0xd0192f02, 0xf8534b10, 0x2b003027, 0x6b5ad014, + 0xd9074282, 0xf8931a10, 0xeb033042, 0x42980343, 0x2200d80a, 0x46204611, + 0xfa62f629, 0x4620e004, 0xbf002100, 0xbe0cf629, 0xbe0df629, - 0xc0007008,//sco_start_delay_flag + 0xc0007008, // sco_start_delay_flag 0x00000000, - 0xc0005ea8,//ld_env - 0xc00009e4,//ld_sco_env + 0xc0005ea8, // ld_env + 0xc00009e4, // ld_sco_env }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch26 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch26 = { 26, BTDRV_PATCH_ACT, sizeof(bes2300p_patch26_ins_data_t3), 0x00030c14, 0xb9c8f1d6, 0xc0006fa8, - (uint8_t *)bes2300p_patch26_ins_data_t3 -};//ld_acl_sched + (uint8_t *)bes2300p_patch26_ins_data_t3}; // ld_acl_sched -const uint32_t bes2300p_patch27_ins_data_t3[] = -{ - 0xf0234413, - 0x63634378, - 0x68094904, - 0x4904b121, - 0xfb016809, - 0x63633300, - 0xba5af62c, +const uint32_t bes2300p_patch27_ins_data_t3[] = { + 0xf0234413, 0x63634378, 0x68094904, 0x4904b121, + 0xfb016809, 0x63633300, 0xba5af62c, - 0xc0007008,//sco_start_delay_flag - 0xc000703c,//sco_anchor_start_add + 0xc0007008, // sco_start_delay_flag + 0xc000703c, // sco_anchor_start_add 0x0000000a, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch27 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch27 = { 27, BTDRV_PATCH_ACT, sizeof(bes2300p_patch27_ins_data_t3), 0x000334e0, 0xbd9af1d3, 0xc0007018, - (uint8_t *)bes2300p_patch27_ins_data_t3 -};//ld_sco_start + (uint8_t *)bes2300p_patch27_ins_data_t3}; // ld_sco_start -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch28 = -{ - 28, - BTDRV_PATCH_ACT, - 0, - 0x00019f54, - 0xbf00e00b, - 0, - NULL, -};//lc_sync_ind -//send max_slot anyway +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch28 = { + 28, BTDRV_PATCH_ACT, 0, 0x00019f54, 0xbf00e00b, 0, NULL, +}; // lc_sync_ind +// send max_slot anyway -const uint32_t bes2300p_patch29_ins_data_t3[] = -{ +const uint32_t bes2300p_patch29_ins_data_t3[] = { 0xf8862001, 0xf8860060, 0xbf000061, 0xbba3f611, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch29 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch29 = { 29, BTDRV_PATCH_ACT, sizeof(bes2300p_patch29_ins_data_t3), 0x00018f1c, 0xbc62f1ee, 0xc00077e4, - (uint8_t *)bes2300p_patch29_ins_data_t3 -};//ignore 0x5d sm + (uint8_t *)bes2300p_patch29_ins_data_t3}; // ignore 0x5d sm // for ble master update con param with large winsize -const uint32_t bes2300p_patch30_ins_data_t3[] = -{ - 0x4630bf00, - 0x109ef894, - 0xf958f63f, - 0x309cf894, - 0x2271f240, - 0x0003fb02, - 0xbcf1f63f, +const uint32_t bes2300p_patch30_ins_data_t3[] = { + 0x4630bf00, 0x109ef894, 0xf958f63f, 0x309cf894, + 0x2271f240, 0x0003fb02, 0xbcf1f63f, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch30 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch30 = { 30, BTDRV_PATCH_ACT, sizeof(bes2300p_patch30_ins_data_t3), 0x000471e4, 0xbb08f1c0, 0xc00077f8, - (uint8_t *)bes2300p_patch30_ins_data_t3 -}; + (uint8_t *)bes2300p_patch30_ins_data_t3}; -static const uint32_t best2300p_t3_ins_patch_config[] = -{ +static const uint32_t best2300p_t3_ins_patch_config[] = { 31, (uint32_t)&bes2300p_t3_ins_patch0, (uint32_t)&bes2300p_t3_ins_patch1, @@ -2841,437 +1680,273 @@ static const uint32_t best2300p_t3_ins_patch_config[] = * ****************************************************************************/ -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch0 = -{ - 0, - BTDRV_PATCH_ACT, - 0, - 0x00030d48, - 0xbf00bf00, - 0, - NULL -};// set lsto when there is no connect +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch0 = { + 0, BTDRV_PATCH_ACT, 0, 0x00030d48, 0xbf00bf00, 0, + NULL}; // set lsto when there is no connect -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch1 = -{ - 1, - BTDRV_PATCH_ACT, - 0, - 0x00019acc, - 0xbf00e003, - 0, - NULL -};////iocap rsp +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch1 = { + 1, BTDRV_PATCH_ACT, 0, 0x00019acc, 0xbf00e003, 0, NULL}; ////iocap rsp -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch2 = -{ - 2, - BTDRV_PATCH_ACT, - 0, - 0x0001a7a4, - 0xbf00e003, - 0, - NULL -};//pwer rsp in wrong state +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch2 = { + 2, BTDRV_PATCH_ACT, 0, 0x0001a7a4, 0xbf00e003, 0, + NULL}; // pwer rsp in wrong state -const uint32_t bes2300p_patch3_ins_data_t2[] = -{ - 0xf5fa4620, /*6900*/ - 0x285dfd4b, - 0xf240d10e, - 0x46215005, - 0xf84cf5fa, /*6910*/ - 0xf8534b05, - 0x46203026, - 0x135ef893, - 0xfcd0f5fa, /*6920*/ - 0xb9f3f617, - 0xb9ebf617, - 0xc0005cd8, /*692c*/ +const uint32_t bes2300p_patch3_ins_data_t2[] = { + 0xf5fa4620, /*6900*/ + 0x285dfd4b, 0xf240d10e, 0x46215005, 0xf84cf5fa, /*6910*/ + 0xf8534b05, 0x46203026, 0x135ef893, 0xfcd0f5fa, /*6920*/ + 0xb9f3f617, 0xb9ebf617, 0xc0005cd8, /*692c*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch3 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch3 = { 3, BTDRV_PATCH_ACT, sizeof(bes2300p_patch3_ins_data_t2), 0x0001dcfc, 0xbe00f1e8, 0xc0006900, - (uint8_t *)bes2300p_patch3_ins_data_t2 -};//not accept + (uint8_t *)bes2300p_patch3_ins_data_t2}; // not accept -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch4 = -{ - 4, - BTDRV_PATCH_ACT, - 0, - 0x0002a4a4, - 0xbf8c7f80, - 0, - NULL -};//LD_ACL_STOP_NOTIF_BIT_OFF_THR +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch4 = { + 4, BTDRV_PATCH_ACT, 0, 0x0002a4a4, 0xbf8c7f80, 0, + NULL}; // LD_ACL_STOP_NOTIF_BIT_OFF_THR -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch5 = -{ - 5, - BTDRV_PATCH_ACT, - 0, - 0x0002a7e4, - 0x7f80f5b3, - 0, - NULL -};//LD_ACL_STOP_NOTIF_BIT_OFF_THR +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch5 = { + 5, BTDRV_PATCH_ACT, 0, 0x0002a7e4, 0x7f80f5b3, 0, + NULL}; // LD_ACL_STOP_NOTIF_BIT_OFF_THR -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch6 = -{ - 6, - BTDRV_PATCH_ACT, - 0, - 0x0002a69c, - 0xbf947f80, - 0, - NULL -};//LD_ACL_STOP_NOTIF_BIT_OFF_THR +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch6 = { + 6, BTDRV_PATCH_ACT, 0, 0x0002a69c, 0xbf947f80, 0, + NULL}; // LD_ACL_STOP_NOTIF_BIT_OFF_THR -const uint32_t bes2300p_patch7_ins_data_t2[] = -{ - 0xd01e0fdb, /*6930*/ - 0x6307f44f, - 0xf304fb03, - 0x48168f6a, - 0x93011810, /*6940*/ - 0x49154418, - 0xfea0f644, - 0x58fb4b14, - 0x4301f3c3, /*6950*/ - 0xf1028f2a, - 0xf5024250, - 0xf2021205, - 0x8f6942fc, /*6960*/ - 0x0241eb02, - 0x440a9901, - 0x600a490d, - 0xf44fe010, /*6970*/ - 0xfb036307, - 0x9301f304, - 0x18184806, - 0x8f6a4906, /*6980*/ - 0xfe82f644, - 0x58fb4b05, - 0x4381f3c3, - 0xba27f62e, /*6990*/ +const uint32_t bes2300p_patch7_ins_data_t2[] = { + 0xd01e0fdb, /*6930*/ + 0x6307f44f, 0xf304fb03, 0x48168f6a, 0x93011810, /*6940*/ + 0x49154418, 0xfea0f644, 0x58fb4b14, 0x4301f3c3, /*6950*/ + 0xf1028f2a, 0xf5024250, 0xf2021205, 0x8f6942fc, /*6960*/ + 0x0241eb02, 0x440a9901, 0x600a490d, 0xf44fe010, /*6970*/ + 0xfb036307, 0x9301f304, 0x18184806, 0x8f6a4906, /*6980*/ + 0xfe82f644, 0x58fb4b05, 0x4381f3c3, 0xba27f62e, /*6990*/ 0xba2df62e, - 0xd02144fc, - 0xc000593c, - 0xd0220144, /*69a0*/ - 0xc000005c, /*69a4*/ + 0xd02144fc, 0xc000593c, 0xd0220144, /*69a0*/ + 0xc000005c, /*69a4*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch7 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch7 = { 7, BTDRV_PATCH_ACT, sizeof(bes2300p_patch7_ins_data_t2), 0x00034d80, 0xbdd6f1d1, 0xc0006930, - (uint8_t *)bes2300p_patch7_ins_data_t2 -};//ld_sco_frm_isr + (uint8_t *)bes2300p_patch7_ins_data_t2}; // ld_sco_frm_isr -const uint32_t bes2300p_patch8_ins_data_t2[] = -{ - 0xf6052002, /*69a8*/ - 0x2802ffbf, - 0xf898d110, /*69b0*/ - 0x230120b2, - 0x4a074093, - 0x21c0f8b2, - 0x0303ea22, /*69c0*/ - 0x0341f3c3, - 0xf8524a04, - 0xbf003023, - 0xbbecf625, /*69d0*/ +const uint32_t bes2300p_patch8_ins_data_t2[] = { + 0xf6052002, /*69a8*/ + 0x2802ffbf, 0xf898d110, /*69b0*/ + 0x230120b2, 0x4a074093, 0x21c0f8b2, 0x0303ea22, /*69c0*/ + 0x0341f3c3, 0xf8524a04, 0xbf003023, 0xbbecf625, /*69d0*/ 0xbbeef625, - 0xc0005d9c,//ld_env - 0xc0000998,//ld_acl_env /*69dc*/ + 0xc0005d9c, // ld_env + 0xc0000998, // ld_acl_env /*69dc*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch8 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch8 = { 8, BTDRV_PATCH_ACT, sizeof(bes2300p_patch8_ins_data_t2), 0x0002c188, 0xbc0ef1da, 0xc00069a8, - (uint8_t *)bes2300p_patch8_ins_data_t2 -};//ld_event_timestamp_calculate + (uint8_t *)bes2300p_patch8_ins_data_t2}; // ld_event_timestamp_calculate -const uint32_t bes2300p_patch9_ins_data_t2[] = -{ - 0xf8934b07, /*69e0*/ - 0xf0133084, - 0xd0070f06, - 0xf6364620, - 0x4601fa4b, /*69f0*/ - 0xbf002400, - 0xbbd2f635, - 0xbb91f635, +const uint32_t bes2300p_patch9_ins_data_t2[] = { + 0xf8934b07, /*69e0*/ + 0xf0133084, 0xd0070f06, 0xf6364620, 0x4601fa4b, /*69f0*/ + 0xbf002400, 0xbbd2f635, 0xbb91f635, - 0xc0006460,//llm_le_env /*6a00*/ + 0xc0006460, // llm_le_env /*6a00*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch9 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch9 = { 9, BTDRV_PATCH_ACT, sizeof(bes2300p_patch9_ins_data_t2), 0x0003c11c, 0xbc60f1ca, 0xc00069e0, - (uint8_t *)bes2300p_patch9_ins_data_t2 -};//hci_le_set_adv_data_cmd_handler + (uint8_t *)bes2300p_patch9_ins_data_t2}; // hci_le_set_adv_data_cmd_handler -const uint32_t bes2300p_patch10_ins_data_t2[] = -{ - 0x123ff240, /*6a04*/ - 0xd006421a, - 0x2b007aab, - 0x2201d003, /*6a10*/ - 0x601a4b05, - 0x2201e002, - 0x601a4b03, - 0xf240892b, /*6a20*/ - 0xbf00123f, - 0xbc1af63e, +const uint32_t bes2300p_patch10_ins_data_t2[] = { + 0x123ff240, /*6a04*/ + 0xd006421a, 0x2b007aab, 0x2201d003, /*6a10*/ + 0x601a4b05, 0x2201e002, 0x601a4b03, 0xf240892b, /*6a20*/ + 0xbf00123f, 0xbc1af63e, - 0xc0006a30,//le_wrong_packet + 0xc0006a30, // le_wrong_packet 0x00000000, /*6a30*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch10 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch10 = { 10, BTDRV_PATCH_ACT, sizeof(bes2300p_patch10_ins_data_t2), 0x0004525c, 0xbbd2f1c1, 0xc0006a04, - (uint8_t *)bes2300p_patch10_ins_data_t2 -};//lld_pdu_rx_handler + (uint8_t *)bes2300p_patch10_ins_data_t2}; // lld_pdu_rx_handler -const uint32_t bes2300p_patch11_ins_data_t2[] = -{ - 0xf894b952, /*6a34*/ - 0xf01330ae, - 0xd1050f09, - 0x209ff894, /*6a40*/ - 0x4a03b912, - 0xb10a6812, - 0xbc05f63f, - 0xbc09f63f, /*6a50*/ +const uint32_t bes2300p_patch11_ins_data_t2[] = { + 0xf894b952, /*6a34*/ + 0xf01330ae, 0xd1050f09, 0x209ff894, /*6a40*/ + 0x4a03b912, 0xb10a6812, 0xbc05f63f, 0xbc09f63f, /*6a50*/ 0xc0006a30, /*6a54*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch11 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch11 = { 11, BTDRV_PATCH_ACT, sizeof(bes2300p_patch11_ins_data_t2), 0x00046248, 0xbbf4f1c0, 0xc0006a34, - (uint8_t *)bes2300p_patch11_ins_data_t2 -};//lld_evt_restart + (uint8_t *)bes2300p_patch11_ins_data_t2}; // lld_evt_restart -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch12 = //from bes2300p_t2_ibrt_ins_patch2 -{ - 12, - BTDRV_PATCH_ACT, - 0, - 0x00007024, - 0xbf00e011, - 0, - NULL -};//dont call rwip_assert_err when assert error +const BTDRV_PATCH_STRUCT + bes2300p_t2_ins_patch12 = // from bes2300p_t2_ibrt_ins_patch2 + {12, BTDRV_PATCH_ACT, 0, 0x00007024, 0xbf00e011, 0, + NULL}; // dont call rwip_assert_err when assert error -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch13 = //from bes2300p_t2_ibrt_ins_patch4 -{ - 13, - BTDRV_PATCH_ACT, - 0, - 0x0002be90, - 0xbd702000, - 0, - NULL -}; //ld_check_if_need_protect_sniff retrun 0 +const BTDRV_PATCH_STRUCT + bes2300p_t2_ins_patch13 = // from bes2300p_t2_ibrt_ins_patch4 + {13, BTDRV_PATCH_ACT, 0, 0x0002be90, 0xbd702000, 0, + NULL}; // ld_check_if_need_protect_sniff retrun 0 -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch14 = //from bes2300p_t2_ibrt_ins_patch9 -{ - 14, - BTDRV_PATCH_ACT, - 0, - 0x0002d82c, - 0x2b006013, - 0, - NULL, -};//ld_acl_rsw_rx +const BTDRV_PATCH_STRUCT + bes2300p_t2_ins_patch14 = // from bes2300p_t2_ibrt_ins_patch9 + { + 14, BTDRV_PATCH_ACT, 0, 0x0002d82c, 0x2b006013, 0, NULL, +}; // ld_acl_rsw_rx -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch15 = //from bes2300p_t2_ibrt_ins_patch10 -{ - 15, - BTDRV_PATCH_ACT, - 0, - 0x0002fe60, - 0xbf00e001, - 0, - NULL, -};//ld_acl_flow_on +const BTDRV_PATCH_STRUCT + bes2300p_t2_ins_patch15 = // from bes2300p_t2_ibrt_ins_patch10 + { + 15, BTDRV_PATCH_ACT, 0, 0x0002fe60, 0xbf00e001, 0, NULL, +}; // ld_acl_flow_on -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch16 = //from bes2300p_t2_ibrt_ins_patch12 -{ - 16, - BTDRV_PATCH_ACT, - 0, - 0x0002a41c, - 0xbf000f01, - 0, - NULL -};//mode == SYNC2_SCO_MODE +const BTDRV_PATCH_STRUCT + bes2300p_t2_ins_patch16 = // from bes2300p_t2_ibrt_ins_patch12 + {16, BTDRV_PATCH_ACT, 0, 0x0002a41c, 0xbf000f01, 0, + NULL}; // mode == SYNC2_SCO_MODE -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch17 = //from bes2300p_t2_ibrt_ins_patch17 -{ - 17, - BTDRV_PATCH_ACT, - 0, - 0x00007010, //a0007010 - 0xb9bef000, //jump a0007390 - 0, - NULL, -};//DEF_IRQHandler +const BTDRV_PATCH_STRUCT + bes2300p_t2_ins_patch17 = // from bes2300p_t2_ibrt_ins_patch17 + { + 17, BTDRV_PATCH_ACT, + 0, + 0x00007010, // a0007010 + 0xb9bef000, // jump a0007390 + 0, NULL, +}; // DEF_IRQHandler -const uint32_t bes2300p_patch18_ins_data_t2[] = -{ - 0x4681b083,/*6b30*/ - 0x4b022200, - 0x2020f843, - 0xbddcf623, - 0xc0006b44, - 0x00000000, - 0x00000000, - 0x00000000,/*6b4c*/ +const uint32_t bes2300p_patch18_ins_data_t2[] = { + 0x4681b083, /*6b30*/ + 0x4b022200, 0x2020f843, 0xbddcf623, 0xc0006b44, + 0x00000000, 0x00000000, 0x00000000, /*6b4c*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch18 = //from bes2300p_t2_ibrt_ins_patch22 -{ - 18, - BTDRV_PATCH_ACT, - sizeof(bes2300p_patch18_ins_data_t2), - 0x0002a6f4, - 0xba1cf1dc, - 0xc0006b30, - (uint8_t *)bes2300p_patch18_ins_data_t2 -};//sync clear count +const BTDRV_PATCH_STRUCT + bes2300p_t2_ins_patch18 = // from bes2300p_t2_ibrt_ins_patch22 + {18, + BTDRV_PATCH_ACT, + sizeof(bes2300p_patch18_ins_data_t2), + 0x0002a6f4, + 0xba1cf1dc, + 0xc0006b30, + (uint8_t *)bes2300p_patch18_ins_data_t2}; // sync clear count -const uint32_t bes2300p_patch19_ins_data_t2[] = -{ +const uint32_t bes2300p_patch19_ins_data_t2[] = { /*6ba0*/ 0xbf0080c6, /*6ba4*/ 0x71022200, - /*6ba8*/ 0xbb2af619, //jump a0020200 + /*6ba8*/ 0xbb2af619, // jump a0020200 }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch19 = //from bes2300p_t2_ibrt_ins_patch29 -{ - 19, - BTDRV_PATCH_ACT, - sizeof(bes2300p_patch19_ins_data_t2), - 0x000201f8, - 0xbcd2f1e6, //jump a00201f8 -> a0206ba0 - 0xc0006ba0, - (uint8_t *)bes2300p_patch19_ins_data_t2 -};//KE_MSG_HANDLER(lc_op_loc_sniff_req, void) +const BTDRV_PATCH_STRUCT + bes2300p_t2_ins_patch19 = // from bes2300p_t2_ibrt_ins_patch29 + {19, + BTDRV_PATCH_ACT, + sizeof(bes2300p_patch19_ins_data_t2), + 0x000201f8, + 0xbcd2f1e6, // jump a00201f8 -> a0206ba0 + 0xc0006ba0, + (uint8_t *) + bes2300p_patch19_ins_data_t2}; // KE_MSG_HANDLER(lc_op_loc_sniff_req, + // void) -const uint32_t bes2300p_patch20_ins_data_t2[] = -{ +const uint32_t bes2300p_patch20_ins_data_t2[] = { /*6bac*/ 0x46286825, /*6bb0*/ 0x303ef895, /*6bb4*/ 0xd0012b02, - /*6bb8*/ 0xbda2f622, //jump a0029700 + /*6bb8*/ 0xbda2f622, // jump a0029700 /*6bbc*/ 0xbf002300, /*6bc0*/ 0x303ef885, - /*6bc4*/ 0xfea6f622, //call a0029914 - /*6bc8*/ 0xbdc1f622, //jump a002974e + /*6bc4*/ 0xfea6f622, // call a0029914 + /*6bc8*/ 0xbdc1f622, // jump a002974e }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch20 = //from bes2300p_t2_ibrt_ins_patch30 -{ - 20, - BTDRV_PATCH_ACT, - sizeof(bes2300p_patch20_ins_data_t2), - 0x000296fc, - 0xba56f1dd, //jump a00296fc -> a0206bac - 0xc0006bac, - (uint8_t *)bes2300p_patch20_ins_data_t2 -};//ld_pscan_frm_cbk +const BTDRV_PATCH_STRUCT + bes2300p_t2_ins_patch20 = // from bes2300p_t2_ibrt_ins_patch30 + {20, + BTDRV_PATCH_ACT, + sizeof(bes2300p_patch20_ins_data_t2), + 0x000296fc, + 0xba56f1dd, // jump a00296fc -> a0206bac + 0xc0006bac, + (uint8_t *)bes2300p_patch20_ins_data_t2}; // ld_pscan_frm_cbk - -const uint32_t bes2300p_patch21_ins_data_t2[] = -{ - 0x4620461d, /*6d00*/ - 0x463a4629, - 0xf5f94633, - 0xbdf8fc2b, /*6d0c*/ +const uint32_t bes2300p_patch21_ins_data_t2[] = { + 0x4620461d, /*6d00*/ + 0x463a4629, 0xf5f94633, 0xbdf8fc2b, /*6d0c*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch21 = //from bes2300p_t2_ibrt_ins_patch0 -{ - 21, - BTDRV_PATCH_ACT, - sizeof(bes2300p_patch21_ins_data_t2), - 0x000070ec, - 0xbe08f1ff, - 0xc0006d00, - (uint8_t *)bes2300p_patch21_ins_data_t2 -};//assert warn +const BTDRV_PATCH_STRUCT + bes2300p_t2_ins_patch21 = // from bes2300p_t2_ibrt_ins_patch0 + {21, + BTDRV_PATCH_ACT, + sizeof(bes2300p_patch21_ins_data_t2), + 0x000070ec, + 0xbe08f1ff, + 0xc0006d00, + (uint8_t *)bes2300p_patch21_ins_data_t2}; // assert warn -const uint32_t bes2300p_patch22_ins_data_t2[] = -{ - 0x4630461f, /*6d14*/ - 0x462a4639, - 0xf5f94623, - 0xbdf8fc21, /*6d20*/ +const uint32_t bes2300p_patch22_ins_data_t2[] = { + 0x4630461f, /*6d14*/ + 0x462a4639, 0xf5f94623, 0xbdf8fc21, /*6d20*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch22 = //from bes2300p_t2_ibrt_ins_patch1 -{ - 22, - BTDRV_PATCH_ACT, - sizeof(bes2300p_patch22_ins_data_t2), - 0x00007070, - 0xbe50f1ff, - 0xc0006d14, - (uint8_t *)bes2300p_patch22_ins_data_t2 -};//assert param +const BTDRV_PATCH_STRUCT + bes2300p_t2_ins_patch22 = // from bes2300p_t2_ibrt_ins_patch1 + {22, + BTDRV_PATCH_ACT, + sizeof(bes2300p_patch22_ins_data_t2), + 0x00007070, + 0xbe50f1ff, + 0xc0006d14, + (uint8_t *)bes2300p_patch22_ins_data_t2}; // assert param -const uint32_t bes2300p_patch23_ins_data_t2[] = -{ - 0x2a140c92, /*6d30*/ - 0x2214bf28, - 0xbf004691, - 0xbc44f623, /*6d3c*/ +const uint32_t bes2300p_patch23_ins_data_t2[] = { + 0x2a140c92, /*6d30*/ + 0x2214bf28, 0xbf004691, 0xbc44f623, /*6d3c*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch23 = //from bes2300p_t2_ibrt_ins_patch40 -{ - 23, - BTDRV_PATCH_ACT, - sizeof(bes2300p_patch23_ins_data_t2), - 0x0002a5c4, - 0xbbb4f1dc, - 0xc0006d30, - (uint8_t *)bes2300p_patch23_ins_data_t2 -};//max_drift limit +const BTDRV_PATCH_STRUCT + bes2300p_t2_ins_patch23 = // from bes2300p_t2_ibrt_ins_patch40 + {23, + BTDRV_PATCH_ACT, + sizeof(bes2300p_patch23_ins_data_t2), + 0x0002a5c4, + 0xbbb4f1dc, + 0xc0006d30, + (uint8_t *)bes2300p_patch23_ins_data_t2}; // max_drift limit -const uint32_t bes2300p_patch24_ins_data_t2[] = -{ +const uint32_t bes2300p_patch24_ins_data_t2[] = { /*6d9c*/ 0x4b179a0b, /*6da0*/ 0xd023429a, /*6da4*/ 0x20b5f894, @@ -3298,26 +1973,24 @@ const uint32_t bes2300p_patch24_ins_data_t2[] = /*6df8*/ 0x00000032, // 50 /*6dfc*/ 0xa003477b, // ld_acl_sniff_frm_isr lr }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch24 = //from bes2300p_t2_ibrt_ins_patch46 -{ - 24, - BTDRV_PATCH_ACT, - sizeof(bes2300p_patch24_ins_data_t2), - 0x0002a7b8, - 0xbaf0f1dc, // jump a002a7b8 -> a0206d9c - 0xc0006d9c, - (uint8_t *)bes2300p_patch24_ins_data_t2 -};//ld_acl_rx_sync clk_off cal active mode +const BTDRV_PATCH_STRUCT + bes2300p_t2_ins_patch24 = // from bes2300p_t2_ibrt_ins_patch46 + {24, + BTDRV_PATCH_ACT, + sizeof(bes2300p_patch24_ins_data_t2), + 0x0002a7b8, + 0xbaf0f1dc, // jump a002a7b8 -> a0206d9c + 0xc0006d9c, + (uint8_t *)bes2300p_patch24_ins_data_t2}; // ld_acl_rx_sync clk_off cal + // active mode - -const uint32_t bes2300p_patch25_ins_data_t2[] = -{ +const uint32_t bes2300p_patch25_ins_data_t2[] = { /*6e10*/ 0xbf00669a, - /*6e14*/ 0x66da466a,//mov r2, sp; str r2, [r3, #108] - /*6e18*/ 0x8208f3ef,//mrs r2, MSP - /*6e1c*/ 0xbf00671a,//str r2, [r3, #112] - /*6e20*/ 0x8209f3ef,//mrs r2, PSP - /*6e24*/ 0xbf00675a,//str r2, [r3, #116] + /*6e14*/ 0x66da466a, // mov r2, sp; str r2, [r3, #108] + /*6e18*/ 0x8208f3ef, // mrs r2, MSP + /*6e1c*/ 0xbf00671a, // str r2, [r3, #112] + /*6e20*/ 0x8209f3ef, // mrs r2, PSP + /*6e24*/ 0xbf00675a, // str r2, [r3, #116] /*6e28*/ 0xbf00bf00, /*6e2c*/ 0xbf00bf00, /*6e30*/ 0xbf00bf00, @@ -3328,104 +2001,72 @@ const uint32_t bes2300p_patch25_ins_data_t2[] = /*6e44*/ 0xbf00bf00, /*6e48*/ 0xbf00bf00, /*6e4c*/ 0xbf00bf00, - /*6e50*/ 0xba90f600,//jump a0206e50 -> a0007374 + /*6e50*/ 0xba90f600, // jump a0206e50 -> a0007374 }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch25 = //from bes2300p_t2_ibrt_ins_patch15 -{ - 25, - BTDRV_PATCH_ACT, - sizeof(bes2300p_patch25_ins_data_t2), - 0x00007360, - 0xbd56f1ff, // jump a0007360 -> a0206e10 - 0xc0006e10, - (uint8_t *)bes2300p_patch25_ins_data_t2 -};//bt_assert_crash_dump +const BTDRV_PATCH_STRUCT + bes2300p_t2_ins_patch25 = // from bes2300p_t2_ibrt_ins_patch15 + {25, + BTDRV_PATCH_ACT, + sizeof(bes2300p_patch25_ins_data_t2), + 0x00007360, + 0xbd56f1ff, // jump a0007360 -> a0206e10 + 0xc0006e10, + (uint8_t *)bes2300p_patch25_ins_data_t2}; // bt_assert_crash_dump #define PATCH_IN_EXTRA_SPACE 1 #if PATCH_IN_EXTRA_SPACE -const uint32_t bes2300p_patch26_ins_data_t2[] = -{ - 0xd8092b01,/*70d0*/ - 0xfb03236e, - 0x4a04f308, - 0xf4135a9b, - 0xd1016f00,/*70e0*/ - 0xb919f629, - 0xb9aef629, - 0xd0211200,/*70ec*/ +const uint32_t bes2300p_patch26_ins_data_t2[] = { + 0xd8092b01, /*70d0*/ + 0xfb03236e, 0x4a04f308, 0xf4135a9b, 0xd1016f00, /*70e0*/ + 0xb919f629, 0xb9aef629, 0xd0211200, /*70ec*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch26 = //from bes2300p_t2_ibrt_ins_patch44 -{ - 26, - BTDRV_PATCH_ACT, - sizeof(bes2300p_patch26_ins_data_t2), - 0x00030314, - 0xbedcf1d6, - 0xc00070d0, - (uint8_t *)bes2300p_patch26_ins_data_t2 -};//lmp tx for tx desc error +const BTDRV_PATCH_STRUCT + bes2300p_t2_ins_patch26 = // from bes2300p_t2_ibrt_ins_patch44 + {26, + BTDRV_PATCH_ACT, + sizeof(bes2300p_patch26_ins_data_t2), + 0x00030314, + 0xbedcf1d6, + 0xc00070d0, + (uint8_t *)bes2300p_patch26_ins_data_t2}; // lmp tx for tx desc error -const uint32_t bes2300p_patch27_ins_data_t2[] = -{ - 0xfeecf5f8, /*7300*/ - 0xbf00bf00, - 0x8310f3ef, - 0x0401f013, - 0xb672d108, /*7310*/ - 0xff22f5f8, - 0xbf30b110, - 0xd1ef2c00, - 0xe7edb662, /*7320*/ - 0xff1af5f8, - 0xd1f62800, - 0xbf00e7e8, /*732c*/ -}; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch27 = //from bes2300p_t2_ibrt_ins_patch13 -{ - 27, - BTDRV_PATCH_ACT, - sizeof(bes2300p_patch27_ins_data_t2), - 0x0000721c, - 0xb870f200, - 0xc0007300, - (uint8_t *)bes2300p_patch27_ins_data_t2 +const uint32_t bes2300p_patch27_ins_data_t2[] = { + 0xfeecf5f8, /*7300*/ + 0xbf00bf00, 0x8310f3ef, 0x0401f013, 0xb672d108, /*7310*/ + 0xff22f5f8, 0xbf30b110, 0xd1ef2c00, 0xe7edb662, /*7320*/ + 0xff1af5f8, 0xd1f62800, 0xbf00e7e8, /*732c*/ }; +const BTDRV_PATCH_STRUCT + bes2300p_t2_ins_patch27 = // from bes2300p_t2_ibrt_ins_patch13 + {27, + BTDRV_PATCH_ACT, + sizeof(bes2300p_patch27_ins_data_t2), + 0x0000721c, + 0xb870f200, + 0xc0007300, + (uint8_t *)bes2300p_patch27_ins_data_t2}; -const uint32_t bes2300p_patch28_ins_data_t2[] = -{ - 0xf885b2db, /*7338*/ - 0xf89530bd, - 0x2a0220b4, /*7340*/ - 0xb98bd114, - 0xf8534b0a, - 0xf6430024, - 0xf895fd15, /*7350*/ - 0x2b0430b5, - 0x4620d103, - 0xf6232116, - 0x4620fc61, /*7360*/ - 0xf6242116, - 0xbf00f961, - 0xbc6bf62d, - 0xbc53f62d, /*7370*/ - 0xc0000998, /*7374*/ +const uint32_t bes2300p_patch28_ins_data_t2[] = { + 0xf885b2db, /*7338*/ + 0xf89530bd, 0x2a0220b4, /*7340*/ + 0xb98bd114, 0xf8534b0a, 0xf6430024, 0xf895fd15, /*7350*/ + 0x2b0430b5, 0x4620d103, 0xf6232116, 0x4620fc61, /*7360*/ + 0xf6242116, 0xbf00f961, 0xbc6bf62d, 0xbc53f62d, /*7370*/ + 0xc0000998, /*7374*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch28 = //from bes2300p_t2_ibrt_ins_patch15 -{ - 28, - BTDRV_PATCH_ACT, - sizeof(bes2300p_patch28_ins_data_t2), - 0x00034c14, - 0xbb90f1d2, - 0xc0007338, - (uint8_t *)bes2300p_patch28_ins_data_t2 -};//no disconnect evt -#endif /* PATCH_IN_EXTRA_SPACE */ - +const BTDRV_PATCH_STRUCT + bes2300p_t2_ins_patch28 = // from bes2300p_t2_ibrt_ins_patch15 + {28, + BTDRV_PATCH_ACT, + sizeof(bes2300p_patch28_ins_data_t2), + 0x00034c14, + 0xbb90f1d2, + 0xc0007338, + (uint8_t *)bes2300p_patch28_ins_data_t2}; // no disconnect evt +#endif /* PATCH_IN_EXTRA_SPACE */ /////2300p t2 patch -static const uint32_t best2300p_t2_ins_patch_config[] = -{ +static const uint32_t best2300p_t2_ins_patch_config[] = { 29, (uint32_t)&bes2300p_t2_ins_patch0, (uint32_t)&bes2300p_t2_ins_patch1, @@ -3513,40 +2154,31 @@ static const uint32_t best2300p_t2_ins_patch_config[] = ****************************************************************************/ //#define ECC_LL_MONITOR -const uint32_t bes2300p_patch0_ibrt_ins_data_t2[] = -{ +const uint32_t bes2300p_patch0_ibrt_ins_data_t2[] = { /*6d00*/ 0x4673b408, /*6d04*/ 0x0f20f013, /*6d08*/ 0xbc08d002, - /*6d0c*/ 0xb9e5f600, //jump a00070da + /*6d0c*/ 0xb9e5f600, // jump a00070da /*6d10*/ 0xbf00bc08, /*6d14*/ 0x4b014699, - /*6d18*/ 0xbaeaf600, //jump a00072f0 + /*6d18*/ 0xbaeaf600, // jump a00072f0 /*6d1c*/ 0xc0000050, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch0 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch0 = { 0, BTDRV_PATCH_ACT, sizeof(bes2300p_patch0_ibrt_ins_data_t2), 0x000072ec, - 0xbd08f1ff, //jump a00072ec -> a0206d00 + 0xbd08f1ff, // jump a00072ec -> a0206d00 0xc0006d00, - (uint8_t *)bes2300p_patch0_ibrt_ins_data_t2 -};//assert warn, assert param - -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch1 = -{ - 1, - BTDRV_PATCH_ACT, - 0, - 0x0001ff2c, - 0xb81af000, //jump a001ff2c -> a001ff64 - 0, - NULL -};//KE_MSG_HANDLER(lc_op_loc_unsniff_req) + (uint8_t *)bes2300p_patch0_ibrt_ins_data_t2}; // assert warn, assert param +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch1 = { + 1, BTDRV_PATCH_ACT, + 0, 0x0001ff2c, + 0xb81af000, // jump a001ff2c -> a001ff64 + 0, NULL}; // KE_MSG_HANDLER(lc_op_loc_unsniff_req) #if 0 const uint32_t bes2300p_patch2_ibrt_ins_data_t2[] = @@ -3584,73 +2216,47 @@ const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch2 = NULL };//dont call rwip_assert_err when assert error #else -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch2 = -{ - 2, - BTDRV_PATCH_ACT, +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch2 = { + 2, BTDRV_PATCH_ACT, 0, - 0x0002d8b0, //0xa002d8b0 - 0xbf00bf00, - 0, - NULL -};//ld_acl_rsw_frm_isr + 0x0002d8b0, // 0xa002d8b0 + 0xbf00bf00, 0, + NULL}; // ld_acl_rsw_frm_isr #endif #else -const uint32_t bes2300p_patch2_ibrt_ins_data_t2[] = -{ - 0xfc12f631,/*7780*/ - 0xb1337843, - 0x0518f100, - 0xf5fb4628, - 0x2813fed9, - 0xf605d804, - 0xbf00fba1, - 0xba24f60c, - 0xba23f60c /*77a0*/ +const uint32_t bes2300p_patch2_ibrt_ins_data_t2[] = { + 0xfc12f631, /*7780*/ + 0xb1337843, 0x0518f100, 0xf5fb4628, 0x2813fed9, + 0xf605d804, 0xbf00fba1, 0xba24f60c, 0xba23f60c /*77a0*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch2 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch2 = { 2, BTDRV_PATCH_INACT, sizeof(bes2300p_patch2_ibrt_ins_data_t2), 0x00013be4, 0xbdccf1f3, 0xc0007780, - (uint8_t *)bes2300p_patch2_ibrt_ins_data_t2 -};//lc_afh_set use mobile afh + (uint8_t *)bes2300p_patch2_ibrt_ins_data_t2}; // lc_afh_set use mobile afh #endif -const uint32_t bes2300p_patch3_ibrt_ins_data_t2[] = -{ - 0xd1052800,/*6900*/ - 0x000cf1aa, - 0xf97af5fa, - 0xbc48f61a, - 0xbbd2f61a,/*6910*/ +const uint32_t bes2300p_patch3_ibrt_ins_data_t2[] = { + 0xd1052800, /*6900*/ + 0x000cf1aa, 0xf97af5fa, 0xbc48f61a, 0xbbd2f61a, /*6910*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch3 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch3 = { 3, BTDRV_PATCH_ACT, sizeof(bes2300p_patch3_ibrt_ins_data_t2), 0x000210b4, 0xbc24f1e5, 0xc0006900, - (uint8_t *)bes2300p_patch3_ibrt_ins_data_t2 -};//lmp filter free heap + (uint8_t *)bes2300p_patch3_ibrt_ins_data_t2}; // lmp filter free heap -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch4 = -{ - 4, - BTDRV_PATCH_ACT, - 0, - 0x0002be90, - 0xbd702000, - 0, - NULL -}; //ld_check_if_need_protect_sniff retrun 0 +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch4 = { + 4, BTDRV_PATCH_ACT, 0, 0x0002be90, 0xbd702000, 0, + NULL}; // ld_check_if_need_protect_sniff retrun 0 #if 0 const uint32_t bes2300p_patch5_ibrt_ins_data_t2[] = @@ -3696,8 +2302,7 @@ const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch6 = (uint8_t *)bes2300p_patch6_ibrt_ins_data_t2 };//protect null ptr when send afh #else -const uint32_t bes2300p_patch5_ibrt_ins_data_t2[] = -{ +const uint32_t bes2300p_patch5_ibrt_ins_data_t2[] = { /*694c*/ 0xf632b1c0, /*6950*/ 0xb1a8fc1b, /*6954*/ 0x70b2f898, @@ -3714,56 +2319,41 @@ const uint32_t bes2300p_patch5_ibrt_ins_data_t2[] = /*6980*/ 0xbcc9f625, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch5 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch5 = { 5, BTDRV_PATCH_ACT, sizeof(bes2300p_patch5_ibrt_ins_data_t2), 0x0002c230, 0xbb8cf1da, // jump a002c230 -> a020694c 0xc000694c, - (uint8_t *)bes2300p_patch5_ibrt_ins_data_t2 -};//ld_cal_timestamp + (uint8_t *)bes2300p_patch5_ibrt_ins_data_t2}; // ld_cal_timestamp #if 1 -const uint32_t bes2300p_patch6_ibrt_ins_data_t2[] = -{ - 0x79ab4688, - 0x6383ea6f, - 0x4578f023, - 0xf8d39b09, - 0x9906308c, - 0x402b440b, - 0xbf004641, - 0xbb87f62c, +const uint32_t bes2300p_patch6_ibrt_ins_data_t2[] = { + 0x79ab4688, 0x6383ea6f, 0x4578f023, 0xf8d39b09, + 0x9906308c, 0x402b440b, 0xbf004641, 0xbb87f62c, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch6 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch6 = { 6, BTDRV_PATCH_ACT, sizeof(bes2300p_patch6_ibrt_ins_data_t2), 0x000330f4, 0xbc6ef1d3, // jump a00330f4 -> a02069d4 0xc00069d4, - (uint8_t *)bes2300p_patch6_ibrt_ins_data_t2 -};//sco param init + (uint8_t *)bes2300p_patch6_ibrt_ins_data_t2}; // sco param init #else -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch6 = -{ - 6, - BTDRV_PATCH_ACT, +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch6 = { + 6, BTDRV_PATCH_ACT, 0, - 0x00007010, //a0007010 - 0xb9bef000, //jump a0007390 - 0, - NULL, -};//DEF_IRQHandler + 0x00007010, // a0007010 + 0xb9bef000, // jump a0007390 + 0, NULL, +}; // DEF_IRQHandler #endif #endif -const uint32_t bes2300p_patch7_ibrt_ins_data_t2[] = -{ +const uint32_t bes2300p_patch7_ibrt_ins_data_t2[] = { /*7138*/ 0x28024604, /*713c*/ 0xf89ad812, /*7140*/ 0x28020046, @@ -3778,152 +2368,73 @@ const uint32_t bes2300p_patch7_ibrt_ins_data_t2[] = /*7164*/ 0xbad8f633, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch7 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch7 = { 7, BTDRV_PATCH_ACT, sizeof(bes2300p_patch7_ibrt_ins_data_t2), 0x0003a5f8, 0xbd9ef1cc, // jump a003a5f8 -> a0207138 0xc0007138, - (uint8_t *)bes2300p_patch7_ibrt_ins_data_t2 -};//start simu link check linkid + (uint8_t *) + bes2300p_patch7_ibrt_ins_data_t2}; // start simu link check linkid -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch8 = -{ - 8, - BTDRV_PATCH_ACT, - 0, - 0x0002e720, - 0xf8a62308, - 0, - NULL, -};//ld_acl_start t_poll +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch8 = { + 8, BTDRV_PATCH_ACT, 0, 0x0002e720, 0xf8a62308, 0, NULL, +}; // ld_acl_start t_poll -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch9 = -{ - 9, - BTDRV_PATCH_ACT, - 0, - 0x0002d82c, - 0x2b006013, - 0, - NULL, -};//ld_acl_rsw_rx +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch9 = { + 9, BTDRV_PATCH_ACT, 0, 0x0002d82c, 0x2b006013, 0, NULL, +}; // ld_acl_rsw_rx -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch10 = -{ - 10, - BTDRV_PATCH_ACT, - 0, - 0x0002fe60, - 0xbf00e001, - 0, - NULL, -};//ld_acl_flow_on +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch10 = { + 10, BTDRV_PATCH_ACT, 0, 0x0002fe60, 0xbf00e001, 0, NULL, +}; // ld_acl_flow_on #ifdef ECC_LL_MONITOR ////patch 11 12 13 used for ecc count by set it to ll monitor parameter -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch11 = -{ - 11, - BTDRV_PATCH_ACT, - 0, - 0x0002dc94, - 0x7000f400, - 0, - NULL -};////wrong flag +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch11 = { + 11, BTDRV_PATCH_ACT, 0, 0x0002dc94, 0x7000f400, 0, NULL}; ////wrong flag -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch12 = -{ - 12, - BTDRV_PATCH_ACT, - 0, - 0x0002dc98, - 0x2800bf00, - 0, - NULL -}; +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch12 = { + 12, BTDRV_PATCH_ACT, 0, 0x0002dc98, 0x2800bf00, 0, NULL}; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch13 = -{ - 13, - BTDRV_PATCH_ACT, - 0, - 0x0002f78c, - 0x46288113, - 0, - NULL -}; +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch13 = { + 13, BTDRV_PATCH_ACT, 0, 0x0002f78c, 0x46288113, 0, NULL}; #else -const uint32_t bes2300p_patch11_ibrt_ins_data_t2[] = -{ - 0x0034f104, - 0x220a4649, - 0xfd86f644, - 0xf632b940, - 0x2801fa39, - 0xf632d104, - 0x2800fb0d, - 0xbf00d104, - 0x00c5f894, - 0xb97cf62b, - 0xb9eaf62b, +const uint32_t bes2300p_patch11_ibrt_ins_data_t2[] = { + 0x0034f104, 0x220a4649, 0xfd86f644, 0xf632b940, 0x2801fa39, 0xf632d104, + 0x2800fb0d, 0xbf00d104, 0x00c5f894, 0xb97cf62b, 0xb9eaf62b, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch11 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch11 = { 11, BTDRV_PATCH_ACT, sizeof(bes2300p_patch11_ibrt_ins_data_t2), 0x00031e70, 0xbe70f1d4, 0xc0006b54, - (uint8_t *)bes2300p_patch11_ibrt_ins_data_t2 -};//filter afh map + (uint8_t *)bes2300p_patch11_ibrt_ins_data_t2}; // filter afh map -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch12 = -{ - 12, - BTDRV_PATCH_ACT, - 0, - 0x0002a41c, - 0xbf000f01, - 0, - NULL -};//mode == SYNC2_SCO_MODE +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch12 = { + 12, BTDRV_PATCH_ACT, 0, 0x0002a41c, 0xbf000f01, 0, + NULL}; // mode == SYNC2_SCO_MODE -const uint32_t bes2300p_patch13_ibrt_ins_data_t2[] = -{ - 0xfeecf5f8, - 0xbf00bf00, - 0x8310f3ef, - 0x0401f013, - 0xb672d108, - 0xff22f5f8, - 0xbf30b110, - 0xd1ef2c00, - 0xe7edb662, - 0xff1af5f8, - 0xd1f62800, - 0xbf00e7e8, +const uint32_t bes2300p_patch13_ibrt_ins_data_t2[] = { + 0xfeecf5f8, 0xbf00bf00, 0x8310f3ef, 0x0401f013, 0xb672d108, 0xff22f5f8, + 0xbf30b110, 0xd1ef2c00, 0xe7edb662, 0xff1af5f8, 0xd1f62800, 0xbf00e7e8, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch13 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch13 = { 13, BTDRV_PATCH_ACT, sizeof(bes2300p_patch13_ibrt_ins_data_t2), 0x0000721c, 0xb870f200, 0xc0007300, - (uint8_t *)bes2300p_patch13_ibrt_ins_data_t2 -}; + (uint8_t *)bes2300p_patch13_ibrt_ins_data_t2}; #endif -const uint32_t bes2300p_patch14_ibrt_ins_data_t2[] = -{ +const uint32_t bes2300p_patch14_ibrt_ins_data_t2[] = { /*698c*/ 0x4604b510, /*6990*/ 0xfc0ef632, /*6994*/ 0xd00542a0, @@ -3943,16 +2454,15 @@ const uint32_t bes2300p_patch14_ibrt_ins_data_t2[] = /*69cc*/ 0xbf00bdf8, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch14 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch14 = { 14, BTDRV_PATCH_ACT, sizeof(bes2300p_patch14_ibrt_ins_data_t2), 0x0003b498, 0xba88f1cb, // jump a003b498 -> a02069ac 0xc000698c, - (uint8_t *)bes2300p_patch14_ibrt_ins_data_t2 -};//protect idx when snoop disconnect + (uint8_t *) + bes2300p_patch14_ibrt_ins_data_t2}; // protect idx when snoop disconnect #if 0 const uint32_t bes2300p_patch15_ibrt_ins_data_t2[] = @@ -3988,58 +2498,37 @@ const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch15 = };//bt_assert_crash_dump #else -const uint32_t bes2300p_patch15_ibrt_ins_data_t2[] = -{ - 0xf885b2db,/*7338*/ - 0xf89530bd, - 0x2a0220b4, - 0xb98bd114, - 0xf8534b0a,/*7348*/ - 0xf6430024, - 0xf895fd15, - 0x2b0430b5, - 0x4620d103,/*7358*/ - 0xf6232116, - 0x4620fc61, - 0xf6242116, - 0xbf00f961,/*7368*/ - 0xbc6bf62d, - 0xbc53f62d, - 0xc0000998,/*7374*/ +const uint32_t bes2300p_patch15_ibrt_ins_data_t2[] = { + 0xf885b2db, /*7338*/ + 0xf89530bd, 0x2a0220b4, 0xb98bd114, 0xf8534b0a, /*7348*/ + 0xf6430024, 0xf895fd15, 0x2b0430b5, 0x4620d103, /*7358*/ + 0xf6232116, 0x4620fc61, 0xf6242116, 0xbf00f961, /*7368*/ + 0xbc6bf62d, 0xbc53f62d, 0xc0000998, /*7374*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch15 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch15 = { 15, BTDRV_PATCH_ACT, sizeof(bes2300p_patch15_ibrt_ins_data_t2), 0x00034c14, 0xbb90f1d2, 0xc0007338, - (uint8_t *)bes2300p_patch15_ibrt_ins_data_t2 -};//no disconnect evt + (uint8_t *)bes2300p_patch15_ibrt_ins_data_t2}; // no disconnect evt #endif -const uint32_t bes2300p_patch16_ibrt_ins_data_t2[] = -{ - 0x71ab2300, - 0x0000f8d9, - 0x380cb110, - 0xf96cf5fa, - 0xbf002300, - 0xbce2f608, +const uint32_t bes2300p_patch16_ibrt_ins_data_t2[] = { + 0x71ab2300, 0x0000f8d9, 0x380cb110, 0xf96cf5fa, 0xbf002300, 0xbce2f608, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch16 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch16 = { 16, BTDRV_PATCH_ACT, sizeof(bes2300p_patch16_ibrt_ins_data_t2), 0x0000f2f0, 0xbb12f1f7, 0xc0006918, - (uint8_t *)bes2300p_patch16_ibrt_ins_data_t2 -};//lm_page_scan_end_ind free msg + (uint8_t *) + bes2300p_patch16_ibrt_ins_data_t2}; // lm_page_scan_end_ind free msg #if 0 const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch17 = @@ -4053,145 +2542,81 @@ const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch17 = NULL, };//DEF_IRQHandler #elif 1 -const uint32_t bes2300p_patch17_ibrt_ins_data_t2[] = -{ - 0x4605b538,/*72b4*/ - 0xfe76f631, - 0x7a834604, - 0x2f15ebb3, - 0x7803d10a,/*72c4*/ - 0xd1072b02, - 0xff5cf631, - 0xf894b120, - 0x2101004f,/*72d4*/ - 0xfc78f61d, - 0xbf00bd38, - 0x3312f886, - 0xbf004620,/*72e4*/ - 0xffe4f7ff, - 0xbcfaf614, +const uint32_t bes2300p_patch17_ibrt_ins_data_t2[] = { + 0x4605b538, /*72b4*/ + 0xfe76f631, 0x7a834604, 0x2f15ebb3, 0x7803d10a, /*72c4*/ + 0xd1072b02, 0xff5cf631, 0xf894b120, 0x2101004f, /*72d4*/ + 0xfc78f61d, 0xbf00bd38, 0x3312f886, 0xbf004620, /*72e4*/ + 0xffe4f7ff, 0xbcfaf614, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch17 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch17 = { 17, BTDRV_PATCH_ACT, sizeof(bes2300p_patch17_ibrt_ins_data_t2), 0x0001bce0, 0xbafef1eb, 0xc00072b4, - (uint8_t *)bes2300p_patch17_ibrt_ins_data_t2 -};//send unsniff cmd + (uint8_t *)bes2300p_patch17_ibrt_ins_data_t2}; // send unsniff cmd #else -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch17 = -{ - 17, - BTDRV_PATCH_ACT, - 0, - 0x0002e674, - 0x53faf44f, - 0, - NULL, -};//lc start lsto 5s +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch17 = { + 17, BTDRV_PATCH_ACT, 0, 0x0002e674, 0x53faf44f, 0, NULL, +}; // lc start lsto 5s #endif -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch18 = -{ - 18, - BTDRV_PATCH_ACT, - 0, - 0x0002f264, - 0xbf00e001, - 0, - NULL, -};//close tx seq force set after start IBRT +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch18 = { + 18, BTDRV_PATCH_ACT, 0, 0x0002f264, 0xbf00e001, 0, NULL, +}; // close tx seq force set after start IBRT -const uint32_t bes2300p_patch19_ibrt_ins_data_t2[] = -{ - 0xd01e0fdb,/*6a2c*/ - 0x6307f44f, - 0xf304fb03, - 0x48168f6a, - 0x93011810, - 0x49154418, - 0xfe22f644, - 0x58fb4b14, - 0x4301f3c3, - 0xf1028f2a, - 0xf5024250, - 0xf2021205, - 0x8f6942fc, - 0x0241eb02, - 0x440a9901, - 0x600a490d, - 0xf44fe010, - 0xfb036307, - 0x9301f304, - 0x18184806, - 0x8f6a4906, - 0xfe04f644, - 0x58fb4b05, - 0x4381f3c3, - 0xb9a9f62e, - 0xb9aff62e, - 0xd02144fc, - 0xc000593c, - 0xd0220144, - 0xc000005c,/*6a9c*/ +const uint32_t bes2300p_patch19_ibrt_ins_data_t2[] = { + 0xd01e0fdb, /*6a2c*/ + 0x6307f44f, 0xf304fb03, 0x48168f6a, 0x93011810, 0x49154418, 0xfe22f644, + 0x58fb4b14, 0x4301f3c3, 0xf1028f2a, 0xf5024250, 0xf2021205, 0x8f6942fc, + 0x0241eb02, 0x440a9901, 0x600a490d, 0xf44fe010, 0xfb036307, 0x9301f304, + 0x18184806, 0x8f6a4906, 0xfe04f644, 0x58fb4b05, 0x4381f3c3, 0xb9a9f62e, + 0xb9aff62e, 0xd02144fc, 0xc000593c, 0xd0220144, 0xc000005c, /*6a9c*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch19 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch19 = { 19, BTDRV_PATCH_ACT, sizeof(bes2300p_patch19_ibrt_ins_data_t2), 0x00034d80, 0xbe54f1d1, 0xc0006a2c, - (uint8_t *)bes2300p_patch19_ibrt_ins_data_t2 -};//ld_sco_frm_isr + (uint8_t *)bes2300p_patch19_ibrt_ins_data_t2}; // ld_sco_frm_isr -const uint32_t bes2300p_patch20_ibrt_ins_data_t2[] = -{ - 0xbf002004,/*6aa4*/ - 0xfb5cf634,/*6aa8*/ - 0xb8c4f618,/*6aac*/ +const uint32_t bes2300p_patch20_ibrt_ins_data_t2[] = { + 0xbf002004, /*6aa4*/ + 0xfb5cf634, /*6aa8*/ + 0xb8c4f618, /*6aac*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch20 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch20 = { 20, BTDRV_PATCH_ACT, sizeof(bes2300p_patch20_ibrt_ins_data_t2), 0x0001ec10, 0xbf48f1e7, 0xc0006aa4, - (uint8_t *)bes2300p_patch20_ibrt_ins_data_t2 -};//ibrt sco status update + (uint8_t *)bes2300p_patch20_ibrt_ins_data_t2}; // ibrt sco status update -const uint32_t bes2300p_patch21_ibrt_ins_data_t2[] = -{ - 0xf6414631, - 0x4620fc1b, - 0xf6064631, - 0x4a03faaf, - 0xf4436813, - 0x60130380, - 0xbdddf633, - 0xd0220468, +const uint32_t bes2300p_patch21_ibrt_ins_data_t2[] = { + 0xf6414631, 0x4620fc1b, 0xf6064631, 0x4a03faaf, + 0xf4436813, 0x60130380, 0xbdddf633, 0xd0220468, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch21 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch21 = { 21, BTDRV_PATCH_ACT, sizeof(bes2300p_patch21_ibrt_ins_data_t2), 0x0003a684, 0xba16f1cc, // jump a003a684 -> a0206ab4 0xc0006ab4, - (uint8_t *)bes2300p_patch21_ibrt_ins_data_t2 -};//register address at LM layer and open fa en register + (uint8_t *) + bes2300p_patch21_ibrt_ins_data_t2}; // register address at LM layer and + // open fa en register #if 0 const uint32_t bes2300p_patch22_ibrt_ins_data_t2[] = @@ -4217,40 +2642,31 @@ const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch22 = (uint8_t *)bes2300p_patch22_ibrt_ins_data_t2 };//sync clear count #else -const uint32_t bes2300p_patch22_ibrt_ins_data_t2[] = -{ - 0x4681b083, - 0x4b042200, - 0x2020f843, - 0x601a4b0d, - 0x601a4b0d, - 0xb8b0f623, - 0xc000759c, - 0x00000000,//link_no_sync_count - 0x00000000, - 0x00000000, - 0x00000018,//link_agc_thd - 0x00000000, //rssi_store_tws - 0x00000006, //rssi_tws_step - 0x00000000, //rssi_store_mobile - 0x00000006, //rssi_mobile_step - 0x0000009c, //rssi_min_value_tws - 0x0000009c, //rssi_min_value_mobile - 0xc00075ac, //rssi_store_tws - 0xc00075b4, //rssi_store_mobile +const uint32_t bes2300p_patch22_ibrt_ins_data_t2[] = { + 0x4681b083, 0x4b042200, 0x2020f843, 0x601a4b0d, + 0x601a4b0d, 0xb8b0f623, 0xc000759c, + 0x00000000, // link_no_sync_count + 0x00000000, 0x00000000, + 0x00000018, // link_agc_thd + 0x00000000, // rssi_store_tws + 0x00000006, // rssi_tws_step + 0x00000000, // rssi_store_mobile + 0x00000006, // rssi_mobile_step + 0x0000009c, // rssi_min_value_tws + 0x0000009c, // rssi_min_value_mobile + 0xc00075ac, // rssi_store_tws + 0xc00075b4, // rssi_store_mobile }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch22 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch22 = { 22, BTDRV_PATCH_ACT, sizeof(bes2300p_patch22_ibrt_ins_data_t2), 0x0002a6f4, 0xbf44f1dc, 0xc0007580, - (uint8_t *)bes2300p_patch22_ibrt_ins_data_t2 -};//sync clear count + (uint8_t *)bes2300p_patch22_ibrt_ins_data_t2}; // sync clear count #endif #if 0 @@ -4289,169 +2705,59 @@ const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch23 = };////swagc no sync #elif 0 -const uint32_t bes2300p_patch23_ibrt_ins_data_t2[] = -{ - 0xf6324620, - 0xb480fce9, - 0xfb07276e, - 0x4a1ff704, - 0xf837bf00, - 0xf4133002, - 0xd12b4f00, - 0xf8524a17, - 0x33013024, - 0x3024f842, - 0x68124a15, - 0xd8124293, - 0x3084f8d5, - 0xf0221af2, - 0xf1b14178, - 0xd9066f80, - 0xf0231b9b, - 0x425b4378, - 0xdc042b64, - 0xf022e012, - 0x2a644278, - 0x2300dd0e, - 0xf8424a08, - 0xb0823024, - 0x92004a09, - 0xc020f8d2, -// 0x0036f06f, - 0x004cf06f, - 0x22014621, - 0xb00247e0, - 0xbf00bc80, - 0xbbeff62d, - 0xc0006b44, - 0xc0007204, - 0x0000003c, - 0xc00041b4, - 0xd02111f8,//720c +const uint32_t bes2300p_patch23_ibrt_ins_data_t2[] = { + 0xf6324620, 0xb480fce9, 0xfb07276e, 0x4a1ff704, 0xf837bf00, 0xf4133002, + 0xd12b4f00, 0xf8524a17, 0x33013024, 0x3024f842, 0x68124a15, 0xd8124293, + 0x3084f8d5, 0xf0221af2, 0xf1b14178, 0xd9066f80, 0xf0231b9b, 0x425b4378, + 0xdc042b64, 0xf022e012, 0x2a644278, 0x2300dd0e, 0xf8424a08, 0xb0823024, + 0x92004a09, 0xc020f8d2, + // 0x0036f06f, + 0x004cf06f, 0x22014621, 0xb00247e0, 0xbf00bc80, 0xbbeff62d, 0xc0006b44, + 0xc0007204, 0x0000003c, 0xc00041b4, + 0xd02111f8, // 720c }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch23 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch23 = { 23, BTDRV_PATCH_ACT, sizeof(bes2300p_patch23_ibrt_ins_data_t2), 0x000349d4, 0xbbd4f1d2, 0xc0007180, - (uint8_t *)bes2300p_patch23_ibrt_ins_data_t2 -};////swagc no sync + (uint8_t *)bes2300p_patch23_ibrt_ins_data_t2}; ////swagc no sync #else -const uint32_t bes2300p_patch23_ibrt_ins_data_t2[] = -{ - 0xfb03236e, - 0x4a3ef300, - 0xf4135a9b, - 0xd1764f00, - 0xb082b570, - 0xf8534b3b, - 0x4a3b4020, - 0x3020f852, - 0xf8423301, - 0x4a393020, - 0x42936812, - 0xf8d4d812, - 0x1aca3084, - 0x4578f022, - 0x6f80f1b5, - 0x1a5bd906, - 0x4378f023, - 0x2b64425b, - 0xe04ddc04, - 0x4278f022, - 0xdd492a64, - 0x681b4b2e, - 0xd11d4298, - 0xf9934b2d, - 0xb93b3000, - 0x30acf9b4, - 0x20aef894, - 0xf3f2fb93, - 0x70134a28, - 0x78134a27, - 0x78094927, - 0xb2db1a5b, - 0x4a267013, - 0xb25b7812, - 0x428bb251, - 0x4b21bfbc, - 0x4b20701a, - 0xe01c781e, - 0xf9934b21, - 0xb93b3000, - 0x30acf9b4, - 0x20aef894, - 0xf3f2fb93, - 0x70134a1c, - 0x78134a1b, - 0x7809491b, - 0xb2db1a5b, - 0x4a1a7013, - 0xb25b7812, - 0x428bb251, - 0x4b15bfbc, - 0x4b14701a, - 0x4601781e, - 0x4a0c2300, - 0x3020f842, - 0x92004a13, - 0xb2706a15, - 0x47a82201, - 0x30aef894, - 0xd9042b95, - 0xf8a42300, - 0xf88430ac, - 0xb00230ae, - 0x4770bd70, - 0xd02111f8, - 0xc0000998, - 0xc000759c, - 0xc00075a8, - 0xc0006e2c, - 0xc00075ac, - 0xc00075b0, - 0xc00075bc, - 0xc00075b4, - 0xc00075b8, - 0xc00075c0, - 0xc00041b4, - 0xf6324620, - 0x4620f9f7, - 0xf7ff4631, - 0xbf00ff61, - 0xb931f62d -}; +const uint32_t bes2300p_patch23_ibrt_ins_data_t2[] = { + 0xfb03236e, 0x4a3ef300, 0xf4135a9b, 0xd1764f00, 0xb082b570, 0xf8534b3b, + 0x4a3b4020, 0x3020f852, 0xf8423301, 0x4a393020, 0x42936812, 0xf8d4d812, + 0x1aca3084, 0x4578f022, 0x6f80f1b5, 0x1a5bd906, 0x4378f023, 0x2b64425b, + 0xe04ddc04, 0x4278f022, 0xdd492a64, 0x681b4b2e, 0xd11d4298, 0xf9934b2d, + 0xb93b3000, 0x30acf9b4, 0x20aef894, 0xf3f2fb93, 0x70134a28, 0x78134a27, + 0x78094927, 0xb2db1a5b, 0x4a267013, 0xb25b7812, 0x428bb251, 0x4b21bfbc, + 0x4b20701a, 0xe01c781e, 0xf9934b21, 0xb93b3000, 0x30acf9b4, 0x20aef894, + 0xf3f2fb93, 0x70134a1c, 0x78134a1b, 0x7809491b, 0xb2db1a5b, 0x4a1a7013, + 0xb25b7812, 0x428bb251, 0x4b15bfbc, 0x4b14701a, 0x4601781e, 0x4a0c2300, + 0x3020f842, 0x92004a13, 0xb2706a15, 0x47a82201, 0x30aef894, 0xd9042b95, + 0xf8a42300, 0xf88430ac, 0xb00230ae, 0x4770bd70, 0xd02111f8, 0xc0000998, + 0xc000759c, 0xc00075a8, 0xc0006e2c, 0xc00075ac, 0xc00075b0, 0xc00075bc, + 0xc00075b4, 0xc00075b8, 0xc00075c0, 0xc00041b4, 0xf6324620, 0x4620f9f7, + 0xf7ff4631, 0xbf00ff61, 0xb931f62d}; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch23 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch23 = { 23, BTDRV_PATCH_ACT, sizeof(bes2300p_patch23_ibrt_ins_data_t2), 0x000349d4, 0xbec6f1d2, 0xc0007634, - (uint8_t *)bes2300p_patch23_ibrt_ins_data_t2 -};////swagc no sync + (uint8_t *)bes2300p_patch23_ibrt_ins_data_t2}; ////swagc no sync #endif -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch24 = -{ - 24, - BTDRV_PATCH_ACT, - 0, - 0x0000fe0c, - 0xf029bf00, - 0, - NULL, -};//filter tws link lc_sco_ind ke message +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch24 = { + 24, BTDRV_PATCH_ACT, 0, 0x0000fe0c, 0xf029bf00, 0, NULL, +}; // filter tws link lc_sco_ind ke message -const uint32_t bes2300p_patch25_ibrt_ins_data_t2[] = -{ +const uint32_t bes2300p_patch25_ibrt_ins_data_t2[] = { /*6f90*/ 0xbf009904, /*6f94*/ 0x4b12b470, /*6f98*/ 0x010e5c5a, @@ -4471,13 +2777,13 @@ const uint32_t bes2300p_patch25_ibrt_ins_data_t2[] = /*6fd0*/ 0xf0f4fb93, /*6fd4*/ 0xbc70b240, /*6fd8*/ 0x22019904, - /*6fdc*/ 0xbb8cf628, //jump a002f6f8 - /*6fe0*/ 0xc0006ff0, //addr of rssi_idx_for_agc - /*6fe4*/ 0xc0006ff4, //addr of rssi_set_for_agc - /*6fe8*/ 0xc0006fec, //addr of N - /*6fec*/ 0x00000005, //N : 1 ~ 16 - /*6ff0*/ 0x00000000, //rssi_idx_for_agc[3] - /*6ff4*/ 0xbabababa, //rssi_set_for_agc[3*16] + /*6fdc*/ 0xbb8cf628, // jump a002f6f8 + /*6fe0*/ 0xc0006ff0, // addr of rssi_idx_for_agc + /*6fe4*/ 0xc0006ff4, // addr of rssi_set_for_agc + /*6fe8*/ 0xc0006fec, // addr of N + /*6fec*/ 0x00000005, // N : 1 ~ 16 + /*6ff0*/ 0x00000000, // rssi_idx_for_agc[3] + /*6ff4*/ 0xbabababa, // rssi_set_for_agc[3*16] /*6ff8*/ 0xbabababa, /*6ffc*/ 0xbabababa, /*7000*/ 0xbabababa, @@ -4492,19 +2798,16 @@ const uint32_t bes2300p_patch25_ibrt_ins_data_t2[] = /*7024*/ 0xbabababa, /*7028*/ 0xbabababa, /*702c*/ 0xbabababa, -};//0xc0006f90--->0xc0007074 +}; // 0xc0006f90--->0xc0007074 -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch25 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch25 = { 25, BTDRV_PATCH_ACT, sizeof(bes2300p_patch25_ibrt_ins_data_t2), 0x0002f6f4, - 0xbc4cf1d7, //jump a002f6f4 -> a0206f90 + 0xbc4cf1d7, // jump a002f6f4 -> a0206f90 0xc0006f90, - (uint8_t *)bes2300p_patch25_ibrt_ins_data_t2 -}; //ld_acl_rx() average rssi - + (uint8_t *)bes2300p_patch25_ibrt_ins_data_t2}; // ld_acl_rx() average rssi #if 0 //ECC patch 1 @@ -4519,39 +2822,18 @@ const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch26 = NULL, };//ld_acl_sniff_frm_isr ld_get_rx_isr_counter ignore #else -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch26 = -{ - 26, - BTDRV_PATCH_ACT, - 0, - 0x00029d50, - 0x3300f443, - 0, - NULL, -};//bt_e_scoltcntl_retxnb_setf +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch26 = { + 26, BTDRV_PATCH_ACT, 0, 0x00029d50, 0x3300f443, 0, NULL, +}; // bt_e_scoltcntl_retxnb_setf #endif -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch27 = -{ - 27, - BTDRV_PATCH_ACT, - 0, - 0x000236e0, - 0xf0172004, - 0, - NULL, -};//LC_WAIT_EXCHANGE_SCO_STATUS_CFM +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch27 = { + 27, BTDRV_PATCH_ACT, 0, 0x000236e0, 0xf0172004, 0, NULL, +}; // LC_WAIT_EXCHANGE_SCO_STATUS_CFM -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch28 = -{ - 28, - BTDRV_PATCH_ACT, - 0, - 0x00039144, - 0x47702001, - 0, - NULL -};//ld_get_sniffer_enter_sniff_flag() forece return 1 +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch28 = { + 28, BTDRV_PATCH_ACT, 0, 0x00039144, 0x47702001, 0, + NULL}; // ld_get_sniffer_enter_sniff_flag() forece return 1 #if 0 const uint32_t bes2300p_patch29_ibrt_ins_data_t2[] = @@ -4572,68 +2854,46 @@ const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch29 = };//KE_MSG_HANDLER(lc_op_loc_sniff_req, void) #else -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch29 = -{ - 29, - BTDRV_PATCH_ACT, - 0, - 0x00020024, - 0xe00dbf00, - 0, - NULL, -};//detach directly +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch29 = { + 29, BTDRV_PATCH_ACT, 0, 0x00020024, 0xe00dbf00, 0, NULL, +}; // detach directly #endif -const uint32_t bes2300p_patch30_ibrt_ins_data_t2[] = -{ +const uint32_t bes2300p_patch30_ibrt_ins_data_t2[] = { /*6bac*/ 0x46286825, /*6bb0*/ 0x303ef895, /*6bb4*/ 0xd0012b02, - /*6bb8*/ 0xbda2f622, //jump a0029700 + /*6bb8*/ 0xbda2f622, // jump a0029700 /*6bbc*/ 0xbf002300, /*6bc0*/ 0x303ef885, - /*6bc4*/ 0xfea6f622, //call a0029914 - /*6bc8*/ 0xbdc1f622, //jump a002974e + /*6bc4*/ 0xfea6f622, // call a0029914 + /*6bc8*/ 0xbdc1f622, // jump a002974e }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch30 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch30 = { 30, BTDRV_PATCH_ACT, sizeof(bes2300p_patch30_ibrt_ins_data_t2), 0x000296fc, - 0xba56f1dd, //jump a00296fc -> a0206bac + 0xba56f1dd, // jump a00296fc -> a0206bac 0xc0006bac, - (uint8_t *)bes2300p_patch30_ibrt_ins_data_t2 -};//ld_pscan_frm_cbk + (uint8_t *)bes2300p_patch30_ibrt_ins_data_t2}; // ld_pscan_frm_cbk -const uint32_t bes2300p_patch31_ibrt_ins_data_t2[] = -{ - 0x7021f853, - 0xb12fb136, - 0x017ff000, - 0xf8534b06, - 0xb93b3021, - 0x210c20ff, - 0xfda8f61b, - 0xbf002004, - 0xbffcf62b, - 0xbf76f62b, - 0xc0005cd8, +const uint32_t bes2300p_patch31_ibrt_ins_data_t2[] = { + 0x7021f853, 0xb12fb136, 0x017ff000, 0xf8534b06, 0xb93b3021, 0x210c20ff, + 0xfda8f61b, 0xbf002004, 0xbffcf62b, 0xbf76f62b, 0xc0005cd8, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch31 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch31 = { 31, BTDRV_PATCH_ACT, sizeof(bes2300p_patch31_ibrt_ins_data_t2), 0x0003328c, 0xb876f1d4, // jump a003328c -> a020737c 0xc000737c, - (uint8_t *)bes2300p_patch31_ibrt_ins_data_t2 -}; //protect null ptr when acl tws switch + (uint8_t *)bes2300p_patch31_ibrt_ins_data_t2}; // protect null ptr when acl + // tws switch -const uint32_t bes2300p_patch32_ibrt_ins_data_t2[] = -{ +const uint32_t bes2300p_patch32_ibrt_ins_data_t2[] = { /*6be8*/ 0x46514620, /*6bec*/ 0x4b09464a, /*6bf0*/ 0x3022f853, @@ -4643,24 +2903,21 @@ const uint32_t bes2300p_patch32_ibrt_ins_data_t2[] = /*6c00*/ 0xfd34f644, /*6c04*/ 0xbf00b920, /*6c08*/ 0x0802f05f, - /*6c0c*/ 0xba4af641, //jump a00480a4 - /*6c10*/ 0xbaf6f641, //jump a0048200 + /*6c0c*/ 0xba4af641, // jump a00480a4 + /*6c10*/ 0xbaf6f641, // jump a0048200 /*6c14*/ 0xc0005cd8, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch32 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch32 = { 32, BTDRV_PATCH_ACT, sizeof(bes2300p_patch32_ibrt_ins_data_t2), 0x00048008, 0xbdeef1be, // jump a0048008 -> a0206be8 0xc0006be8, - (uint8_t *)bes2300p_patch32_ibrt_ins_data_t2 -};//hci_evt_filter_con_check + (uint8_t *)bes2300p_patch32_ibrt_ins_data_t2}; // hci_evt_filter_con_check -const uint32_t bes2300p_patch33_ibrt_ins_data_t2[] = -{ +const uint32_t bes2300p_patch33_ibrt_ins_data_t2[] = { /*6c1c*/ 0x0024f855, /*6c20*/ 0xbf003038, /*6c24*/ 0xfd9ef643, @@ -4668,19 +2925,16 @@ const uint32_t bes2300p_patch33_ibrt_ins_data_t2[] = /*6c2c*/ 0xbe9ef60c, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch33 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch33 = { 33, BTDRV_PATCH_ACT, sizeof(bes2300p_patch33_ibrt_ins_data_t2), 0x00013968, 0xb958f1f3, // jump a0013968 -> a0206c1c 0xc0006c1c, - (uint8_t *)bes2300p_patch33_ibrt_ins_data_t2 -};//ea_interval_remove + (uint8_t *)bes2300p_patch33_ibrt_ins_data_t2}; // ea_interval_remove -const uint32_t bes2300p_patch34_ibrt_ins_data_t2[] = -{ +const uint32_t bes2300p_patch34_ibrt_ins_data_t2[] = { /*6c30*/ 0xf632d108, /*6c34*/ 0x2100f9e3, /*6c38*/ 0xf802f634, @@ -4689,19 +2943,17 @@ const uint32_t bes2300p_patch34_ibrt_ins_data_t2[] = /*6c44*/ 0xbbc3f5fb, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch34 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch34 = { 34, BTDRV_PATCH_ACT, sizeof(bes2300p_patch34_ibrt_ins_data_t2), 0x00002354, 0xbc6cf204, // jump a0002354 -> a0206c30 0xc0006c30, - (uint8_t *)bes2300p_patch34_ibrt_ins_data_t2 -};//close fastack when stop ibrt + (uint8_t *) + bes2300p_patch34_ibrt_ins_data_t2}; // close fastack when stop ibrt -const uint32_t bes2300p_patch35_ibrt_ins_data_t2[] = -{ +const uint32_t bes2300p_patch35_ibrt_ins_data_t2[] = { /*6c48*/ 0x4b0a0a02, /*6c4c*/ 0x3022f853, /*6c50*/ 0xb500b173, @@ -4717,19 +2969,17 @@ const uint32_t bes2300p_patch35_ibrt_ins_data_t2[] = /*6c78*/ 0xbf000230, /*6c7c*/ 0x0001f040, /*6c80*/ 0xffe2f7ff, - /*6c84*/ 0xbc5df634 -}; + /*6c84*/ 0xbc5df634}; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch35 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch35 = { 35, BTDRV_PATCH_ACT, sizeof(bes2300p_patch35_ibrt_ins_data_t2), 0x0003b538, 0xbb9ef1cb, // jump a003b538 -> a0206c78 0xc0006c48, - (uint8_t *)bes2300p_patch35_ibrt_ins_data_t2 -};//snoop disconnect lc_release + (uint8_t *) + bes2300p_patch35_ibrt_ins_data_t2}; // snoop disconnect lc_release #if 0 //ECC patch 2 @@ -4753,39 +3003,25 @@ const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch36 = (uint8_t *)bes2300p_patch36_ibrt_ins_data_t2 };//ld_acl_rx_isr set_ecc_recheck_link_id #else -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch36 = -{ - 36, - BTDRV_PATCH_ACT, - 0, - 0x0002ddc0, - 0x4a07bf00, - 0, - NULL, -};// 1st ibrt ok, ignore sniffer role +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch36 = { + 36, BTDRV_PATCH_ACT, 0, 0x0002ddc0, 0x4a07bf00, 0, NULL, +}; // 1st ibrt ok, ignore sniffer role #endif -const uint32_t bes2300p_patch37_ibrt_ins_data_t2[] = -{ - 0x4605b538,/*6ca0*/ - 0xf643460c, - 0x6a00fc79, - 0xd2034285, - 0x28061b40,/*6cb0*/ - 0x2402bf98, - 0xb9fdf627, +const uint32_t bes2300p_patch37_ibrt_ins_data_t2[] = { + 0x4605b538, /*6ca0*/ + 0xf643460c, 0x6a00fc79, 0xd2034285, 0x28061b40, /*6cb0*/ + 0x2402bf98, 0xb9fdf627, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch37 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch37 = { 37, BTDRV_PATCH_ACT, sizeof(bes2300p_patch37_ibrt_ins_data_t2), 0x0002e0b0, 0xbdf6f1d8, 0xc0006ca0, - (uint8_t *)bes2300p_patch37_ibrt_ins_data_t2 -};//decrease retx + (uint8_t *)bes2300p_patch37_ibrt_ins_data_t2}; // decrease retx #if 0 const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch38 = @@ -4799,142 +3035,83 @@ const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch38 = NULL };//SLEEP EN #else -const uint32_t bes2300p_patch38_ibrt_ins_data_t2[] = -{ - 0x4604b510,/*6cc0*/ - 0xf6104608, - 0x2c03fd25, - 0x2803d001, - 0x200cd104,/*6cd0*/ - 0xfa4ef61c, - 0xbd102001, - 0xbd102000, - 0xfd18f610,/*6ce0*/ - 0xf1044605, - 0x46280145, - 0xffe8f7ff, - 0xd1012800,/*6cf0*/ - 0xbeb7f633, - 0xbf19f633,/*6cf8*/ +const uint32_t bes2300p_patch38_ibrt_ins_data_t2[] = { + 0x4604b510, /*6cc0*/ + 0xf6104608, 0x2c03fd25, 0x2803d001, 0x200cd104, /*6cd0*/ + 0xfa4ef61c, 0xbd102001, 0xbd102000, 0xfd18f610, /*6ce0*/ + 0xf1044605, 0x46280145, 0xffe8f7ff, 0xd1012800, /*6cf0*/ + 0xbeb7f633, 0xbf19f633, /*6cf8*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch38 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch38 = { 38, BTDRV_PATCH_ACT, sizeof(bes2300p_patch38_ibrt_ins_data_t2), 0x0003aa60, 0xb93ef1cc, // jump a003aa60 -> a0206cc0 0xc0006cc0, - (uint8_t *)bes2300p_patch38_ibrt_ins_data_t2 -};//set env + (uint8_t *)bes2300p_patch38_ibrt_ins_data_t2}; // set env #endif -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch39 = -{ - 39, - BTDRV_PATCH_ACT, - 0, - 0x0003b450, - 0xbf00bd08, - 0, - NULL -};//do not send ld_sniffer_connect_sco_forward +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch39 = { + 39, BTDRV_PATCH_ACT, 0, 0x0003b450, 0xbf00bd08, 0, + NULL}; // do not send ld_sniffer_connect_sco_forward -const uint32_t bes2300p_patch40_ibrt_ins_data_t2[] = -{ - 0x2a140c92, - 0x2214bf28, - 0xbf004691, - 0xbc44f623,/*6d40*/ +const uint32_t bes2300p_patch40_ibrt_ins_data_t2[] = { + 0x2a140c92, 0x2214bf28, 0xbf004691, 0xbc44f623, /*6d40*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch40 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch40 = { 40, BTDRV_PATCH_ACT, sizeof(bes2300p_patch40_ibrt_ins_data_t2), 0x0002a5c4, 0xbbb4f1dc, 0xc0006d30, - (uint8_t *)bes2300p_patch40_ibrt_ins_data_t2 -};//max_drift limit + (uint8_t *)bes2300p_patch40_ibrt_ins_data_t2}; // max_drift limit -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch41 = -{ - 41, - BTDRV_PATCH_ACT, - 0, - 0x0003acd8, - 0xbf00e005, - 0, - NULL -};///acl tx silence +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch41 = { + 41, BTDRV_PATCH_ACT, 0, 0x0003acd8, 0xbf00e005, 0, NULL}; /// acl tx silence -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch42 = -{ - 42, - BTDRV_PATCH_ACT, - 0, - 0x00033668, - 0xbf00e001, - 0, - NULL -};///do not clear acl env during sco stop +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch42 = { + 42, BTDRV_PATCH_ACT, 0, 0x00033668, 0xbf00e001, 0, + NULL}; /// do not clear acl env during sco stop -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch43 = -{ - 43, - BTDRV_PATCH_ACT, - 0, - 0x0002a62c, - 0xe001021a, - 0, - NULL -};//rx window adjust for start ibrt +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch43 = { + 43, BTDRV_PATCH_ACT, 0, 0x0002a62c, 0xe001021a, 0, + NULL}; // rx window adjust for start ibrt #if defined(SYNC_BT_CTLR_PROFILE) -const uint32_t bes2300p_patch44_ibrt_ins_data_t2[] = -{ +const uint32_t bes2300p_patch44_ibrt_ins_data_t2[] = { /*6d24*/ 0xbf004628, /*6d28*/ 0xfff8f633, /*6d2c*/ 0xb8f7f611, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch44 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch44 = { 44, BTDRV_PATCH_ACT, sizeof(bes2300p_patch44_ibrt_ins_data_t2), 0x00017f10, 0xbf08f1ee, // jump a0017f10 -> a0206d24 0xc0006d24, - (uint8_t *)bes2300p_patch44_ibrt_ins_data_t2 -};//send profile via BLE + (uint8_t *)bes2300p_patch44_ibrt_ins_data_t2}; // send profile via BLE #else -const uint32_t bes2300p_patch44_ibrt_ins_data_t2[] = -{ - 0xd8092b01,/*70d0*/ - 0xfb03236e, - 0x4a04f308, - 0xf4135a9b, - 0xd1016f00,/*70e0*/ - 0xb919f629, - 0xb9aef629, - 0xd0211200,/*70ec*/ +const uint32_t bes2300p_patch44_ibrt_ins_data_t2[] = { + 0xd8092b01, /*70d0*/ + 0xfb03236e, 0x4a04f308, 0xf4135a9b, 0xd1016f00, /*70e0*/ + 0xb919f629, 0xb9aef629, 0xd0211200, /*70ec*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch44 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch44 = { 44, BTDRV_PATCH_ACT, sizeof(bes2300p_patch44_ibrt_ins_data_t2), 0x00030314, 0xbedcf1d6, 0xc00070d0, - (uint8_t *)bes2300p_patch44_ibrt_ins_data_t2 -};//lmp tx for tx desc error + (uint8_t *)bes2300p_patch44_ibrt_ins_data_t2}; // lmp tx for tx desc error #endif #if 0 @@ -4972,29 +3149,22 @@ const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch45 = (uint8_t *)bes2300p_patch45_ibrt_ins_data_t2 };//RSSI AVERAGE 10 #else -const uint32_t bes2300p_patch45_ibrt_ins_data_t2[] = -{ - 0x4a033304,/*6930*/ - 0xbf008153, - 0x12c4f640, - 0xb9bdf632, - 0xc00061b8,/*6940*/ +const uint32_t bes2300p_patch45_ibrt_ins_data_t2[] = { + 0x4a033304, /*6930*/ + 0xbf008153, 0x12c4f640, 0xb9bdf632, 0xc00061b8, /*6940*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch45 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch45 = { 45, BTDRV_PATCH_ACT, sizeof(bes2300p_patch45_ibrt_ins_data_t2), 0x00038cb0, 0xbe3ef1cd, 0xc0006930, - (uint8_t *)bes2300p_patch45_ibrt_ins_data_t2 -};//pscan duration + (uint8_t *)bes2300p_patch45_ibrt_ins_data_t2}; // pscan duration #endif -const uint32_t bes2300p_patch46_ibrt_ins_data_t2[] = -{ +const uint32_t bes2300p_patch46_ibrt_ins_data_t2[] = { /*6d9c*/ 0x4b179a0b, /*6da0*/ 0xd023429a, /*6da4*/ 0x20b5f894, @@ -5022,88 +3192,51 @@ const uint32_t bes2300p_patch46_ibrt_ins_data_t2[] = /*6dfc*/ 0xa003477b, // ld_acl_sniff_frm_isr lr }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch46 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch46 = { 46, BTDRV_PATCH_ACT, sizeof(bes2300p_patch46_ibrt_ins_data_t2), 0x0002a7b8, 0xbaf0f1dc, // jump a002a7b8 -> a0206d9c 0xc0006d9c, - (uint8_t *)bes2300p_patch46_ibrt_ins_data_t2 -};//ld_acl_rx_sync clk_off cal active mode + (uint8_t *)bes2300p_patch46_ibrt_ins_data_t2}; // ld_acl_rx_sync clk_off cal + // active mode -const uint32_t bes2300p_patch47_ibrt_ins_data_t2[] = -{ - 0xd10b2800,/*6e00*/ - 0x0f00f1ba, - 0x4a07d10a, - 0x2aff7812, - 0x4615d006,/*6e10*/ - 0x30b2f894, - 0xd10342ab, - 0xb8aff625, - 0xb974f625,/*6e20*/ - 0xb952f625, - 0xc0006e2c, - 0x000000ff,/*6e28*/ +const uint32_t bes2300p_patch47_ibrt_ins_data_t2[] = { + 0xd10b2800, /*6e00*/ + 0x0f00f1ba, 0x4a07d10a, 0x2aff7812, 0x4615d006, /*6e10*/ + 0x30b2f894, 0xd10342ab, 0xb8aff625, 0xb974f625, /*6e20*/ + 0xb952f625, 0xc0006e2c, 0x000000ff, /*6e28*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch47 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch47 = { 47, BTDRV_PATCH_ACT, sizeof(bes2300p_patch47_ibrt_ins_data_t2), 0x0002bf78, 0xbf42f1da, 0xc0006e00, - (uint8_t *)bes2300p_patch47_ibrt_ins_data_t2 -};///adjust slot share for tws without ibrt + (uint8_t *)bes2300p_patch47_ibrt_ins_data_t2}; /// adjust slot share for tws + /// without ibrt -const uint32_t bes2300p_patch48_ibrt_ins_data_t2[] = -{ - 0x781b4b13, - 0xd0212bff, - 0x4604b510, - 0xf946f632, - 0x4b0fb1d8, - 0x4b0f781a, - 0x3022f853, - 0x0f28f113, - 0xf893d013, - 0xeb0330c1, - 0xb2db0342, - 0x0383eb03, - 0x4a09005b, - 0xf3c35a9b, - 0x2b5303c9, - 0x7ea2d905, - 0x441368e3, - 0x4378f023, - 0xbd1060e3, - 0xbf004770, - 0xc0006e2c, - 0xc0000998, - 0xd0211632, - 0x0028f104, - 0xffcef7ff, - 0x60a36b63, - 0xb9fcf627, +const uint32_t bes2300p_patch48_ibrt_ins_data_t2[] = { + 0x781b4b13, 0xd0212bff, 0x4604b510, 0xf946f632, 0x4b0fb1d8, 0x4b0f781a, + 0x3022f853, 0x0f28f113, 0xf893d013, 0xeb0330c1, 0xb2db0342, 0x0383eb03, + 0x4a09005b, 0xf3c35a9b, 0x2b5303c9, 0x7ea2d905, 0x441368e3, 0x4378f023, + 0xbd1060e3, 0xbf004770, 0xc0006e2c, 0xc0000998, 0xd0211632, 0x0028f104, + 0xffcef7ff, 0x60a36b63, 0xb9fcf627, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch48 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch48 = { 48, BTDRV_PATCH_ACT, sizeof(bes2300p_patch48_ibrt_ins_data_t2), 0x0002e290, 0xbdfcf1d8, 0xc0006e30, - (uint8_t *)bes2300p_patch48_ibrt_ins_data_t2 -};//big packet send in sco v1 + (uint8_t *)bes2300p_patch48_ibrt_ins_data_t2}; // big packet send in sco v1 -const uint32_t bes2300p_patch49_ibrt_ins_data_t2[] = -{ +const uint32_t bes2300p_patch49_ibrt_ins_data_t2[] = { /*6ec0*/ 0xf6232100, /*6ec4*/ 0xf643feaf, /*6ec8*/ 0x2300fb69, @@ -5111,16 +3244,15 @@ const uint32_t bes2300p_patch49_ibrt_ins_data_t2[] = /*6ed0*/ 0xbcf4f626, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch49 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch49 = { 49, BTDRV_PATCH_ACT, sizeof(bes2300p_patch49_ibrt_ins_data_t2), 0x0002d88c, 0xbb18f1d9, // jump a0018188 -> a0206978 0xc0006ec0, - (uint8_t *)bes2300p_patch49_ibrt_ins_data_t2 -};///role switch fail to disconnect + (uint8_t *) + bes2300p_patch49_ibrt_ins_data_t2}; /// role switch fail to disconnect #if 0 const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch50 = @@ -5134,105 +3266,63 @@ const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch50 = NULL };//ble channel map disable #elif 0 -const uint32_t bes2300p_patch50_ibrt_ins_data_t2[] = -{ - 0xf8948263, - 0xbf0030b3, - 0xbf00bf00, - 0xbf00bf00, - 0xbf002304, - 0xb8b8f625, +const uint32_t bes2300p_patch50_ibrt_ins_data_t2[] = { + 0xf8948263, 0xbf0030b3, 0xbf00bf00, 0xbf00bf00, 0xbf002304, 0xb8b8f625, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch50 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch50 = { 50, BTDRV_PATCH_ACT, sizeof(bes2300p_patch50_ibrt_ins_data_t2), 0x0002c024, 0xbf3cf1da, 0xc0006ea0, - (uint8_t *)bes2300p_patch50_ibrt_ins_data_t2 -}; + (uint8_t *)bes2300p_patch50_ibrt_ins_data_t2}; #else -const uint32_t bes2300p_patch50_ibrt_ins_data_t2[] = -{ - 0x75a32312,/*6ed8*/ - 0x001bf898, - 0x1088f8d1, - 0x300cf8d8, - 0xf023440b,/*6ee8*/ - 0xea834378, - 0xf8986380, - 0x1a5b1019, - 0x101af898,/*6ef8*/ - 0xf3f1fbb3, - 0xfbb3b2db, - 0xfb02f1f2, - 0x1ad23311,/*6f08*/ - 0xf894b2d6, - 0xb91330b3, - 0xf8842301, - 0xf5fc30bb,/*6f18*/ - 0xf890fa05, - 0xf5c33025, - 0x3304631c, - 0x23048263,/*6f28*/ - 0xb87cf625,/*6f2c*/ +const uint32_t bes2300p_patch50_ibrt_ins_data_t2[] = { + 0x75a32312, /*6ed8*/ + 0x001bf898, 0x1088f8d1, 0x300cf8d8, 0xf023440b, /*6ee8*/ + 0xea834378, 0xf8986380, 0x1a5b1019, 0x101af898, /*6ef8*/ + 0xf3f1fbb3, 0xfbb3b2db, 0xfb02f1f2, 0x1ad23311, /*6f08*/ + 0xf894b2d6, 0xb91330b3, 0xf8842301, 0xf5fc30bb, /*6f18*/ + 0xf890fa05, 0xf5c33025, 0x3304631c, 0x23048263, /*6f28*/ + 0xb87cf625, /*6f2c*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch50 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch50 = { 50, BTDRV_PATCH_ACT, sizeof(bes2300p_patch50_ibrt_ins_data_t2), 0x0002bfc4, 0xbf88f1da, 0xc0006ed8, - (uint8_t *)bes2300p_patch50_ibrt_ins_data_t2 -};////ibrt connect slot adjust in sco + (uint8_t *) + bes2300p_patch50_ibrt_ins_data_t2}; ////ibrt connect slot adjust in sco #endif -const uint32_t bes2300p_patch51_ibrt_ins_data_t2[] = -{ - 0x490a60e3,/*6f30*/ - 0x428f6809, - 0x4620d10c, - 0x22002100, - 0xf914f625,/*6f40*/ - 0x429d68a3, - 0x60a5bf38, - 0x134cf640, - 0x3012f8a4,/*6f50*/ - 0xbf004620, - 0xbc20f624, - 0xc0006e2c,/*6f5c*/ +const uint32_t bes2300p_patch51_ibrt_ins_data_t2[] = { + 0x490a60e3, /*6f30*/ + 0x428f6809, 0x4620d10c, 0x22002100, 0xf914f625, /*6f40*/ + 0x429d68a3, 0x60a5bf38, 0x134cf640, 0x3012f8a4, /*6f50*/ + 0xbf004620, 0xbc20f624, 0xc0006e2c, /*6f5c*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch51 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch51 = { 51, BTDRV_PATCH_ACT, sizeof(bes2300p_patch51_ibrt_ins_data_t2), 0x0002b798, 0xbbcaf1db, 0xc0006f30, - (uint8_t *)bes2300p_patch51_ibrt_ins_data_t2 -};//sniff trans mode timing + (uint8_t *)bes2300p_patch51_ibrt_ins_data_t2}; // sniff trans mode timing -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch52 = -{ - 52, - BTDRV_PATCH_ACT, - 0, - 0x0001bf54, - 0xbff2f7ff, //jump a001bf54 -> a001bf3c - 0, - NULL -};//LMP_MSG_HANDLER(switch_req) LC_CONNECTED +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch52 = { + 52, BTDRV_PATCH_ACT, + 0, 0x0001bf54, + 0xbff2f7ff, // jump a001bf54 -> a001bf3c + 0, NULL}; // LMP_MSG_HANDLER(switch_req) LC_CONNECTED -const uint32_t bes2300p_patch53_ibrt_ins_data_t2[] = -{ +const uint32_t bes2300p_patch53_ibrt_ins_data_t2[] = { /*6f74*/ 0xf632b140, /*6f78*/ 0x42b0f841, /*6f7c*/ 0xf632d104, @@ -5242,16 +3332,14 @@ const uint32_t bes2300p_patch53_ibrt_ins_data_t2[] = /*6f8c*/ 0xbf08f619, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch53 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch53 = { 53, BTDRV_PATCH_ACT, sizeof(bes2300p_patch53_ibrt_ins_data_t2), 0x00020cd8, 0xb94cf1e6, // jump a0020cd8 -> a0206f74 0xc0006f74, - (uint8_t *)bes2300p_patch53_ibrt_ins_data_t2 -};//disconnect cmp + (uint8_t *)bes2300p_patch53_ibrt_ins_data_t2}; // disconnect cmp #if 0 const uint32_t bes2300p_patch54_ibrt_ins_data_t2[] = @@ -5304,145 +3392,54 @@ const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch54 = (uint8_t *)bes2300p_patch54_ibrt_ins_data_t2 };//msg filter #else -const uint32_t bes2300p_patch54_ibrt_ins_data_t2[] = -{ - 0x8885b5f8,//73cc - 0x2b050a2b, - 0x4b49d121, - 0x0428f103, - 0x4f48b2e9, - 0x428a781a, - 0x785ad116, - 0x0f01f012, - 0x88c6d007, - 0x2e020a36, - 0xf857d86b, - 0x2e006026, - 0xf012d069, - 0xd0070f02, - 0x0a128902, - 0xd8642a02, - 0x2022f857, - 0xd0622a00, - 0x42a33302, - 0xf240d1e2, - 0x429d5335, - 0x4605d15d, - 0x08637b44, - 0xd1142b04, - 0xf5f988c0, - 0x2832ffb5, - 0xf240d155, - 0x88e95006, - 0xfb2ef5f9, - 0x0a0288e8, - 0xf8534b2e, - 0xf8933022, - 0xf5f9135e, - 0x2401ff39, - 0x2b18e050, - 0x88c0d126, - 0xff9ef5f9, - 0xd1402836, - 0x02fef004, - 0x0a3688ee, - 0xf8534b24, - 0xf8844026, - 0xb2f62044, - 0x21184630, - 0xff1cf61c, - 0x4040f894, - 0xd1302c01, - 0xf6294630, - 0x88e8fa29, - 0xf800f60f, - 0x0a0288e8, - 0xf8534b19, - 0xf8933022, - 0xf5f9135e, - 0xe027ff0f, - 0xd1202b7e, - 0x3b097b83, - 0x2b01b2db, - 0xf631d81d, - 0x7a83fd77, - 0xd81a2b02, - 0xf8524a0f, - 0xfab44023, - 0x0964f484, - 0x2401e014, - 0x2401e012, - 0x2401e010, - 0x2401e00e, - 0x2400e00c, - 0x2400e00a, - 0x2400e008, - 0x2401e006, - 0x2400e004, - 0x2400e002, - 0x2401e000, - 0xbdf84620, - 0xa0207520, - 0xc0005cd8, - 0xb1484606, - 0xf7ff4620, - 0x2801ff5f, - 0xbf00d102, - 0xbe56f5f9, - 0xbe49f5f9, - 0xbe40f5f9, - 0x0327032a, - 0x010e0326, - 0x0000010f, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, +const uint32_t bes2300p_patch54_ibrt_ins_data_t2[] = { + 0x8885b5f8, // 73cc + 0x2b050a2b, 0x4b49d121, 0x0428f103, 0x4f48b2e9, 0x428a781a, 0x785ad116, + 0x0f01f012, 0x88c6d007, 0x2e020a36, 0xf857d86b, 0x2e006026, 0xf012d069, + 0xd0070f02, 0x0a128902, 0xd8642a02, 0x2022f857, 0xd0622a00, 0x42a33302, + 0xf240d1e2, 0x429d5335, 0x4605d15d, 0x08637b44, 0xd1142b04, 0xf5f988c0, + 0x2832ffb5, 0xf240d155, 0x88e95006, 0xfb2ef5f9, 0x0a0288e8, 0xf8534b2e, + 0xf8933022, 0xf5f9135e, 0x2401ff39, 0x2b18e050, 0x88c0d126, 0xff9ef5f9, + 0xd1402836, 0x02fef004, 0x0a3688ee, 0xf8534b24, 0xf8844026, 0xb2f62044, + 0x21184630, 0xff1cf61c, 0x4040f894, 0xd1302c01, 0xf6294630, 0x88e8fa29, + 0xf800f60f, 0x0a0288e8, 0xf8534b19, 0xf8933022, 0xf5f9135e, 0xe027ff0f, + 0xd1202b7e, 0x3b097b83, 0x2b01b2db, 0xf631d81d, 0x7a83fd77, 0xd81a2b02, + 0xf8524a0f, 0xfab44023, 0x0964f484, 0x2401e014, 0x2401e012, 0x2401e010, + 0x2401e00e, 0x2400e00c, 0x2400e00a, 0x2400e008, 0x2401e006, 0x2400e004, + 0x2400e002, 0x2401e000, 0xbdf84620, 0xa0207520, 0xc0005cd8, 0xb1484606, + 0xf7ff4620, 0x2801ff5f, 0xbf00d102, 0xbe56f5f9, 0xbe49f5f9, 0xbe40f5f9, + 0x0327032a, 0x010e0326, 0x0000010f, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch54 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch54 = { 54, BTDRV_PATCH_ACT, sizeof(bes2300p_patch54_ibrt_ins_data_t2), 0x0000119c, 0xb9b2f206, 0xc00073cc, - (uint8_t *)bes2300p_patch54_ibrt_ins_data_t2 -};//msg filter + (uint8_t *)bes2300p_patch54_ibrt_ins_data_t2}; // msg filter #endif -const uint32_t bes2300p_patch55_ibrt_ins_data_t2[] = -{ - 0x49079804,/*70a4*/ - 0x42886809, - 0xf632d103, - 0x2800f86b, - 0x3301d004,/*70b4*/ - 0xf88bb2db, - 0xbf0030bb, - 0xbaf4f628, - 0xc0006e2c,/*70c4*/ +const uint32_t bes2300p_patch55_ibrt_ins_data_t2[] = { + 0x49079804, /*70a4*/ + 0x42886809, 0xf632d103, 0x2800f86b, 0x3301d004, /*70b4*/ + 0xf88bb2db, 0xbf0030bb, 0xbaf4f628, 0xc0006e2c, /*70c4*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch55 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ibrt_ins_patch55 = { 55, BTDRV_PATCH_ACT, sizeof(bes2300p_patch55_ibrt_ins_data_t2), 0x0002f6a4, 0xbcfef1d7, 0xc00070a4, - (uint8_t *)bes2300p_patch55_ibrt_ins_data_t2 -};//tws link dont rx traffic++ + (uint8_t *)bes2300p_patch55_ibrt_ins_data_t2}; // tws link dont rx traffic++ /////2300p t2 ibrt patch (chip id =1) -static const uint32_t best2300p_t2_ibrt_ins_patch_config[] = -{ +static const uint32_t best2300p_t2_ibrt_ins_patch_config[] = { 56, (uint32_t)&bes2300p_t2_ibrt_ins_patch0, (uint32_t)&bes2300p_t2_ibrt_ins_patch1, @@ -5534,19 +3531,11 @@ static const uint32_t best2300p_t2_ibrt_ins_patch_config[] = * patch 29: in used: 0xC0006D14--->0xC0006D30 ****************************************************************************/ -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch0 = -{ - 0, - BTDRV_PATCH_ACT, - 0, - 0x00025ef4, - 0xbf00bf00, - 0, - NULL -};///remove the memset of ldenv +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch0 = { + 0, BTDRV_PATCH_ACT, 0, 0x00025ef4, 0xbf00bf00, 0, + NULL}; /// remove the memset of ldenv -const uint32_t bes2300p_t1_patch_0a_ins_data[] = -{ +const uint32_t bes2300p_t1_patch_0a_ins_data[] = { /*6810*/ 0x681b4b0e, /*6814*/ 0x4b0eb1ab, /*6818*/ 0x31cbf893, @@ -5574,366 +3563,235 @@ const uint32_t bes2300p_t1_patch_0a_ins_data[] = /*6870*/ 0xbd62f628, // jump a002f338 /*6874*/ 0x22802107, /*6878*/ 0xbe22f628, // jump a002f4c0 -}; // ld_acl_rx ld_sw_seqn_filter +}; // ld_acl_rx ld_sw_seqn_filter -const uint32_t bes2300p_t1_patch_0b_ins_data[] = -{ +const uint32_t bes2300p_t1_patch_0b_ins_data[] = { /*6880*/ 0x328af885, /*6884*/ 0x22024b02, /*6888*/ 0xbf00559a, /*688c*/ 0xbe90f614, // jump a001b5b0 /*6890*/ 0xc0006860, // link_id_seq -}; // lc_rsw_end_ind link_id_seq[link_id]=2 +}; // lc_rsw_end_ind link_id_seq[link_id]=2 -const uint32_t bes2300p_t1_patch_1_ins_data[] = -{ - 0x2c021b64, - 0x2009d101, - 0x3402e002, - 0xbc4af63c, - 0xbca6f63c, +const uint32_t bes2300p_t1_patch_1_ins_data[] = { + 0x2c021b64, 0x2009d101, 0x3402e002, 0xbc4af63c, 0xbca6f63c, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch1 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch1 = { 1, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_patch_1_ins_data), 0x000431a0, 0xbbaef1c3, 0xc0006900, - (uint8_t *)bes2300p_t1_patch_1_ins_data -};//for ble and sco: OVERLAP_RESERVE2 in lld_check_conflict_with_ble + (uint8_t *)bes2300p_t1_patch_1_ins_data}; // for ble and sco: + // OVERLAP_RESERVE2 in + // lld_check_conflict_with_ble -const uint32_t bes2300p_t1_patch_2_ins_data[] = -{ - 0x781b4b05, - 0xd1032b09, - 0x4b032200, - 0x2704701a, - 0x60eb1be3, - 0xb8ecf627, - 0xc000693c,////prev_conflict_type_record +const uint32_t bes2300p_t1_patch_2_ins_data[] = { + 0x781b4b05, 0xd1032b09, 0x4b032200, 0x2704701a, 0x60eb1be3, 0xb8ecf627, + 0xc000693c, ////prev_conflict_type_record 0x00000000, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch2 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch2 = { 2, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_patch_2_ins_data), 0x0002db0c, 0xbf08f1d8, 0xc0006920, - (uint8_t *)bes2300p_t1_patch_2_ins_data -};//for ble and sco: prev_conflict_type_record in ld_sco_avoid_ble_connect + (uint8_t *)bes2300p_t1_patch_2_ins_data}; // for ble and sco: + // prev_conflict_type_record in + // ld_sco_avoid_ble_connect -const uint32_t bes2300p_t1_patch_3_ins_data[] = -{ - 0xd1084298, - 0x3047f894, - 0x92004a0e, - 0x22024631, - 0xfd42f61f, - 0x4b0ce014, - 0xb143781b, - 0x3047f894, - 0x92004a08, - 0x22024631, - 0xfd36f61f, - 0xf894e008, - 0x4a043047, - 0x46319200, - 0xbf002204, - 0xfd2cf61f, - 0xbaa2f62b, - 0xa002fce5, - 0xc000699c,///ble_sco_need_move_flag +const uint32_t bes2300p_t1_patch_3_ins_data[] = { + 0xd1084298, 0x3047f894, 0x92004a0e, 0x22024631, 0xfd42f61f, 0x4b0ce014, + 0xb143781b, 0x3047f894, 0x92004a08, 0x22024631, 0xfd36f61f, 0xf894e008, + 0x4a043047, 0x46319200, 0xbf002204, 0xfd2cf61f, 0xbaa2f62b, 0xa002fce5, + 0xc000699c, /// ble_sco_need_move_flag 0x00000000, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch3 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch3 = { 3, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_patch_3_ins_data), 0x00031ec4, 0xbd44f1d4, 0xc0006950, - (uint8_t *)bes2300p_t1_patch_3_ins_data -};//for ble and sco: ld_fm_prog_push LD_FRAME_TYPE_ESCO when ble_sco_need_move_flag in ld_sco_evt_start_cbk + (uint8_t *)bes2300p_t1_patch_3_ins_data}; // for ble and sco: + // ld_fm_prog_push + // LD_FRAME_TYPE_ESCO when + // ble_sco_need_move_flag in + // ld_sco_evt_start_cbk - -const uint32_t bes2300p_t1_patch_4_ins_data[] = -{ - 0x781b4b18, - 0x2200b113, - 0x701a4b16, - 0x781b4b18, - 0xd0232b00, - 0x4b162201, - 0xbf00701a, - 0xb1e84680, - 0x781b4b11, - 0xd1192b00, - 0x0304f1a8, - 0x2b01b2db, - 0xf1b8d903, - 0xd1130f09, - 0x2201e00c, - 0x701a4b09, - 0x0f09f1b8, - 0x2209d103, - 0x701a4b08, - 0x68eb2704, - 0xb8a6f627, - 0x4b032201, - 0xe7f4701a, - 0xb8c2f627, - 0xb8aff627, - 0xc000699c,///ble_sco_need_move_flag +const uint32_t bes2300p_t1_patch_4_ins_data[] = { + 0x781b4b18, 0x2200b113, 0x701a4b16, 0x781b4b18, 0xd0232b00, + 0x4b162201, 0xbf00701a, 0xb1e84680, 0x781b4b11, 0xd1192b00, + 0x0304f1a8, 0x2b01b2db, 0xf1b8d903, 0xd1130f09, 0x2201e00c, + 0x701a4b09, 0x0f09f1b8, 0x2209d103, 0x701a4b08, 0x68eb2704, + 0xb8a6f627, 0x4b032201, 0xe7f4701a, 0xb8c2f627, 0xb8aff627, + 0xc000699c, /// ble_sco_need_move_flag 0xc000099f, - 0xc000693c,///prev_conflict_type_record - 0xc0006a18,///sco_find_sync_flag + 0xc000693c, /// prev_conflict_type_record + 0xc0006a18, /// sco_find_sync_flag 0x00000000, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch4 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch4 = { 4, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_patch_4_ins_data), 0x0002db30, 0xbf38f1d8, 0xc00069a4, - (uint8_t *)bes2300p_t1_patch_4_ins_data -};//for ble and sco: ble_sco_need_move_flag = 1,need_move=4 in ld_sco_avoid_ble_connect + (uint8_t *)bes2300p_t1_patch_4_ins_data}; // for ble and sco: + // ble_sco_need_move_flag = + // 1,need_move=4 in + // ld_sco_avoid_ble_connect -const uint32_t bes2300p_t1_patch_5_ins_data[] = -{ +const uint32_t bes2300p_t1_patch_5_ins_data[] = { 0xfbb24a02, 0xf5f9f3f3, 0xbf00bec6, 0x9af8da00, }; - -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch5 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch5 = { 5, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_patch_5_ins_data), 0x00000650, 0xb936f206, 0xc00068c0, - (uint8_t *)bes2300p_t1_patch_5_ins_data -};//lpclk + (uint8_t *)bes2300p_t1_patch_5_ins_data}; // lpclk - -const uint32_t bes2300p_t1_patch_6_ins_data[] = -{ - 0xd00d2b00, - 0xf8384b07, - 0xf4133003, - 0xd0024f00, - 0x4b052201, - 0xf899701a, - 0x2b0130b3, - 0xba5af629, - 0xbaccf629, - 0xd02111f8, - 0xc0006a18,////sco_find_sync_flag +const uint32_t bes2300p_t1_patch_6_ins_data[] = { + 0xd00d2b00, 0xf8384b07, 0xf4133003, 0xd0024f00, 0x4b052201, + 0xf899701a, 0x2b0130b3, 0xba5af629, 0xbaccf629, 0xd02111f8, + 0xc0006a18, ////sco_find_sync_flag }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch6 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch6 = { 6, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_patch_6_ins_data), 0x0002feec, 0xbd98f1d6, 0xc0006a20, - (uint8_t *)bes2300p_t1_patch_6_ins_data -};///for ble and sco: sco_find_sync_flag = 1 in ld_sco_frm_isr + (uint8_t *)bes2300p_t1_patch_6_ins_data}; /// for ble and sco: + /// sco_find_sync_flag = 1 in + /// ld_sco_frm_isr -const uint32_t bes2300p_t1_patch_7_ins_data[] = -{ - 0xd10f2f03, - 0xfd16f642, - 0x4008f8d8, - 0x46216940, - 0xf6242220, - 0xb128fff5, - 0x0320f104, - 0x4378f023, - 0x3008f8c8, - 0xbf002000, - 0xbc7df625, +const uint32_t bes2300p_t1_patch_7_ins_data[] = { + 0xd10f2f03, 0xfd16f642, 0x4008f8d8, 0x46216940, 0xf6242220, 0xb128fff5, + 0x0320f104, 0x4378f023, 0x3008f8c8, 0xbf002000, 0xbc7df625, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch7 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch7 = { 7, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_patch_7_ins_data), 0x0002c32c, 0xbb90f1da, 0xc0006A50, - (uint8_t *)bes2300p_t1_patch_7_ins_data -};//ble avoid role switch + (uint8_t *)bes2300p_t1_patch_7_ins_data}; // ble avoid role switch -const uint32_t bes2300p_t1_patch_8_ins_data[] = -{ +const uint32_t bes2300p_t1_patch_8_ins_data[] = { 0xf855b2e6, 0xb1091b04, 0xbc71f610, 0xbc78f610, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch8 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch8 = { 8, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_patch_8_ins_data), 0x00017378, 0xbb8af1ef, 0xc0006A90, - (uint8_t *)bes2300p_t1_patch_8_ins_data -};//lc_check_bt_device_conected + (uint8_t *)bes2300p_t1_patch_8_ins_data}; // lc_check_bt_device_conected -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch9 = -{ - 9, - BTDRV_PATCH_ACT, - 0, - 0x00043238, - 0xbf342c09, - 0, - NULL -};//check conflict 8 slot 1 +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch9 = { + 9, BTDRV_PATCH_ACT, 0, 0x00043238, 0xbf342c09, 0, + NULL}; // check conflict 8 slot 1 -const uint32_t bes2300p_t1_patch_10_ins_data[] = -{ - 0xf8934b07, - 0x98053078, - 0xd1074298, - 0xd0052b03, - 0x681b4b04, - 0x2201b913, - 0x601a4b02, - 0xbc3ff628, - 0xc0006358, - 0xc0006AC8, - 0x00000000, +const uint32_t bes2300p_t1_patch_10_ins_data[] = { + 0xf8934b07, 0x98053078, 0xd1074298, 0xd0052b03, 0x681b4b04, 0x2201b913, + 0x601a4b02, 0xbc3ff628, 0xc0006358, 0xc0006AC8, 0x00000000, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch10 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch10 = { 10, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_patch_10_ins_data), 0x0002f338, 0xbbb2f1d7, 0xc0006AA0, - (uint8_t *)bes2300p_t1_patch_10_ins_data -};//ibrt snoop success + (uint8_t *)bes2300p_t1_patch_10_ins_data}; // ibrt snoop success -const uint32_t bes2300p_t1_patch_11_ins_data[] = -{ - 0xb149d208, - 0x681b4b05, - 0x2200b133, - 0x601a4b03, - 0xbce4f632, - 0xbcf2f632, - 0xbcfff632, - 0xc0006AC8, +const uint32_t bes2300p_t1_patch_11_ins_data[] = { + 0xb149d208, 0x681b4b05, 0x2200b133, 0x601a4b03, + 0xbce4f632, 0xbcf2f632, 0xbcfff632, 0xc0006AC8, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch11 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch11 = { 11, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_patch_11_ins_data), 0x000394a8, 0xbb12f1cd, 0xc0006AD0, - (uint8_t *)bes2300p_t1_patch_11_ins_data -};//ibrt snoop success 2 + (uint8_t *)bes2300p_t1_patch_11_ins_data}; // ibrt snoop success 2 -const uint32_t bes2300p_t1_patch_12_ins_data[] = -{ - 0x46032102, - 0xf9b4f633, - 0xbf004618, - 0x22012105, - 0xfa28f61d, - 0xba4ff633, +const uint32_t bes2300p_t1_patch_12_ins_data[] = { + 0x46032102, 0xf9b4f633, 0xbf004618, 0x22012105, 0xfa28f61d, 0xba4ff633, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch12 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch12 = { 12, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_patch_12_ins_data), 0x00039fa0, 0xbda6f1cc, 0xc0006AF0, - (uint8_t *)bes2300p_t1_patch_12_ins_data -};// hack tws switch tx seqn error + (uint8_t *)bes2300p_t1_patch_12_ins_data}; // hack tws switch tx seqn error -const uint32_t bes2300p_t1_patch_13_ins_data[] = -{ - 0xfc6ef631, - 0xfcbaf631, - 0xbf004620, - 0xfcc2f631, - 0xbfb2f62a, +const uint32_t bes2300p_t1_patch_13_ins_data[] = { + 0xfc6ef631, 0xfcbaf631, 0xbf004620, 0xfcc2f631, 0xbfb2f62a, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch13 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch13 = { 13, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_patch_13_ins_data), 0x00031a7c, 0xb844f1d5, 0xc0006B08, - (uint8_t *)bes2300p_t1_patch_13_ins_data -};// lmp filter enable + (uint8_t *)bes2300p_t1_patch_13_ins_data}; // lmp filter enable -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch14 = -{ - 14, - BTDRV_PATCH_ACT, - 0, - 0x000388a8, - 0xbf00e001, - 0, - NULL -};//open afh update +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch14 = { + 14, BTDRV_PATCH_ACT, 0, 0x000388a8, 0xbf00e001, 0, NULL}; // open afh update -const uint32_t bes2300p_t1_patch_15_ins_data[] = -{ +const uint32_t bes2300p_t1_patch_15_ins_data[] = { 0xfbd0f631, 0x20004601, 0xfbb8f633, 0xba9ef618, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch15 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch15 = { 15, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_patch_15_ins_data), 0x0001f0bc, 0xbd5af1e7, 0xc0006B74, - (uint8_t *)bes2300p_t1_patch_15_ins_data -};//ibrt slave stop sco + (uint8_t *)bes2300p_t1_patch_15_ins_data}; // ibrt slave stop sco -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch16 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch16 = { 16, #if defined(IBRT) BTDRV_PATCH_ACT, @@ -5945,10 +3803,9 @@ const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch16 = 0x7a22d206, 0, NULL, -};//check afh mismatch 1 +}; // check afh mismatch 1 -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch17 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch17 = { 17, #if defined(IBRT) BTDRV_PATCH_ACT, @@ -5960,107 +3817,51 @@ const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch17 = 0xbf00e00e, 0, NULL, -};//check afh mismatch 2 +}; // check afh mismatch 2 -const uint32_t bes2300p_t1_patch_18_ins_data[] = -{ - 0x4606b570, - 0x7e8d460c, - 0xf5f5fb92, - 0x2114b2e8, - 0x68e175b1, - 0xf023440b, - 0x7ee14378, - 0x6381ea83, - 0x1a5b7e61, - 0xfbb37ea1, - 0xb2dbf3f1, - 0xf1f0fbb3, - 0x3311fb00, - 0xb2c31ac0, - 0xd8042a3c, - 0x622ef640, - 0x22048272, - 0xf640e003, - 0x8272124c, - 0x7ea02206, - 0xfb0068e1, - 0x44101003, - 0x4078f020, - 0x210060b0, - 0xfab4f63c, - 0xd9072806, - 0xb2ed7ea3, - 0xfb0568b2, - 0xf0252503, - 0x60b54578, - 0xbf00bd70, - 0x46514620, - 0x2042f8b8, - 0x3088f8d3, - 0xffbaf7ff, - 0xbfcbf624, +const uint32_t bes2300p_t1_patch_18_ins_data[] = { + 0x4606b570, 0x7e8d460c, 0xf5f5fb92, 0x2114b2e8, 0x68e175b1, 0xf023440b, + 0x7ee14378, 0x6381ea83, 0x1a5b7e61, 0xfbb37ea1, 0xb2dbf3f1, 0xf1f0fbb3, + 0x3311fb00, 0xb2c31ac0, 0xd8042a3c, 0x622ef640, 0x22048272, 0xf640e003, + 0x8272124c, 0x7ea02206, 0xfb0068e1, 0x44101003, 0x4078f020, 0x210060b0, + 0xfab4f63c, 0xd9072806, 0xb2ed7ea3, 0xfb0568b2, 0xf0252503, 0x60b54578, + 0xbf00bd70, 0x46514620, 0x2042f8b8, 0x3088f8d3, 0xffbaf7ff, 0xbfcbf624, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch18 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch18 = { 18, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_patch_18_ins_data), 0x0002bad8, - 0xb894f1db, //jump a002bad8 -> A0206C04 + 0xb894f1db, // jump a002bad8 -> A0206C04 0xc0006B88, - (uint8_t *)bes2300p_t1_patch_18_ins_data + (uint8_t *)bes2300p_t1_patch_18_ins_data}; + +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch19 = { + 19, BTDRV_PATCH_ACT, 0, 0x00039d78, 0xd13b2902, 0, NULL}; // ibrt switch op + +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch20 = { + 20, BTDRV_PATCH_ACT, 0, 0x00030240, 0xe0022000, 0, NULL}; // acl end assert + +const uint32_t bes2300p_t1_patch_21_ins_data[] = { + 0x781b4b03, 0xd1012b01, 0xbc5cf633, 0xbc63f633, 0xc0006358, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch19 = -{ - 19, - BTDRV_PATCH_ACT, - 0, - 0x00039d78, - 0xd13b2902, - 0, - NULL -};//ibrt switch op - -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch20 = -{ - 20, - BTDRV_PATCH_ACT, - 0, - 0x00030240, - 0xe0022000, - 0, - NULL -};//acl end assert - -const uint32_t bes2300p_t1_patch_21_ins_data[] = -{ - 0x781b4b03, - 0xd1012b01, - 0xbc5cf633, - 0xbc63f633, - 0xc0006358, -}; - -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch21 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch21 = { 21, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_patch_21_ins_data), 0x0003a528, 0xbba6f1cc, 0xc0006C78, - (uint8_t *)bes2300p_t1_patch_21_ins_data -};//snoop disconnect + (uint8_t *)bes2300p_t1_patch_21_ins_data}; // snoop disconnect -// __SW_SEQ_FILTER__ - add software seqn filter to protect recive identical repeating packages +// __SW_SEQ_FILTER__ - add software seqn filter to protect recive identical +// repeating packages #if defined(IBRT) #define __SW_SEQ_FILTER__ #endif -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch22 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch22 = { 22, #ifdef __SW_SEQ_FILTER__ BTDRV_PATCH_INACT, @@ -6071,11 +3872,9 @@ const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch22 = 0x0002f334, 0xba96f1d7, // jump a002f334 -> a0206864 0xc0006810, - (uint8_t *)bes2300p_t1_patch_0a_ins_data -}; + (uint8_t *)bes2300p_t1_patch_0a_ins_data}; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch23 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch23 = { 23, #ifdef __SW_SEQ_FILTER__ BTDRV_PATCH_INACT, @@ -6086,31 +3885,26 @@ const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch23 = 0x0001b5ac, 0xb968f1eb, // jump a001b5ac -> a0206880 0xc0006880, - (uint8_t *)bes2300p_t1_patch_0b_ins_data -}; // lc_rsw_end_ind link_id_seq[link_id]=2 + (uint8_t *) + bes2300p_t1_patch_0b_ins_data}; // lc_rsw_end_ind link_id_seq[link_id]=2 - -const uint32_t bes2300p_t1_patch_24_ins_data[] = -{ +const uint32_t bes2300p_t1_patch_24_ins_data[] = { 0x0f01f1b8, 0x380ebf0c, 0xb280301c, 0xbb30f632, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch24 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch24 = { 24, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_patch_24_ins_data), 0x000392d8, 0xbcdaf1cd, 0xc0006c90, - (uint8_t *)bes2300p_t1_patch_24_ins_data -};//start snoop using bitoff + (uint8_t *)bes2300p_t1_patch_24_ins_data}; // start snoop using bitoff -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch25 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch25 = { 25, #if defined(IBRT) BTDRV_PATCH_ACT, @@ -6122,160 +3916,84 @@ const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch25 = 0xf8a6230a, 0, NULL, -};//ld_acl_start t_poll +}; // ld_acl_start t_poll -const uint32_t bes2300p_t1_patch_26_ins_data[] = -{ - 0x5040f898, - 0xd80d2d14, - 0xfbecf642, - 0x690068a6, - 0xb2ea4631, - 0xfeccf624, - 0xf106b120, - 0xf0230364, - 0x60a34378, - 0xfbdef642, - 0xbfb2f624, +const uint32_t bes2300p_t1_patch_26_ins_data[] = { + 0x5040f898, 0xd80d2d14, 0xfbecf642, 0x690068a6, 0xb2ea4631, 0xfeccf624, + 0xf106b120, 0xf0230364, 0x60a34378, 0xfbdef642, 0xbfb2f624, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch26 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch26 = { 26, BTDRV_PATCH_INACT, sizeof(bes2300p_t1_patch_26_ins_data), 0x0002bc2c, 0xb838f1db, 0xc0006CA0, - (uint8_t *)bes2300p_t1_patch_26_ins_data -};//mobile link avoid tws link when send profile + (uint8_t *)bes2300p_t1_patch_26_ins_data}; // mobile link avoid tws link + // when send profile -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch27 = -{ - 27, - BTDRV_PATCH_ACT, - 0, - 0x0003890c, - 0xbf00e008, - 0, - NULL, -};// ld_sniffer_update_status: SNIFFER_EVT_SCO_CONNECTED +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch27 = { + 27, BTDRV_PATCH_ACT, 0, 0x0003890c, 0xbf00e008, 0, NULL, +}; // ld_sniffer_update_status: SNIFFER_EVT_SCO_CONNECTED -const uint32_t bes2300p_t1_patch_28_ins_data[] = -{ - 0xfa58f63f, - 0x4b034a02, - 0xbf00601a, - 0xbb66f63f, - 0xffff0009, - 0xd03300f0, +const uint32_t bes2300p_t1_patch_28_ins_data[] = { + 0xfa58f63f, 0x4b034a02, 0xbf00601a, 0xbb66f63f, 0xffff0009, 0xd03300f0, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch28 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch28 = { 28, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_patch_28_ins_data), 0x000463d0, 0xbc92f1c0, 0xc0006CF8, - (uint8_t *)bes2300p_t1_patch_28_ins_data -};//lld_evt_end_isr:SYS 2M + (uint8_t *)bes2300p_t1_patch_28_ins_data}; // lld_evt_end_isr:SYS 2M -const uint32_t bes2300p_t1_patch_29_ins_data[] = -{ - 0x681b4b0a, - 0x0301f033, - 0xbf00d106, - 0x4b044a03, - 0x4a04601a, - 0x601a4b04, - 0xbc96f63d, - 0x04007107, - 0xD0220000, - 0xffff0008, - 0xd03300f0, - 0xd0220054, +const uint32_t bes2300p_t1_patch_29_ins_data[] = { + 0x681b4b0a, 0x0301f033, 0xbf00d106, 0x4b044a03, 0x4a04601a, 0x601a4b04, + 0xbc96f63d, 0x04007107, 0xD0220000, 0xffff0008, 0xd03300f0, 0xd0220054, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch29 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch29 = { 29, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_patch_29_ins_data), 0x00044658, 0xbb5cf1c2, 0xc0006d14, - (uint8_t *)bes2300p_t1_patch_29_ins_data -};//lld_evt_schedule:SYS 1M + (uint8_t *)bes2300p_t1_patch_29_ins_data}; // lld_evt_schedule:SYS 1M -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch30 = -{ - 30, - BTDRV_PATCH_ACT, - 0, - 0x00029e70, - 0xbf8c7fb9, - 0, - NULL, -};//ld_acl_rx_sync2 +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch30 = { + 30, BTDRV_PATCH_ACT, 0, 0x00029e70, 0xbf8c7fb9, 0, NULL, +}; // ld_acl_rx_sync2 -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch31 = -{ - 31, - BTDRV_PATCH_ACT, - 0, - 0x0002a068, - 0xbf947fb9, - 0, - NULL, -};//ld_acl_rx_no_sync +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch31 = { + 31, BTDRV_PATCH_ACT, 0, 0x0002a068, 0xbf947fb9, 0, NULL, +}; // ld_acl_rx_no_sync -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch32 = -{ - 32, - BTDRV_PATCH_ACT, - 0, - 0x0002a1b0, - 0x7fb9f5b3, - 0, - NULL, -};//ld_acl_rx_sync +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch32 = { + 32, BTDRV_PATCH_ACT, 0, 0x0002a1b0, 0x7fb9f5b3, 0, NULL, +}; // ld_acl_rx_sync -const uint32_t bes2300p_t1_patch_33_ins_data[] = -{ - 0xfdf6f624, - 0x4638b920, - 0xf63c2100, - 0xb108fa01, - 0xbf2bf628, - 0xbf3df628, +const uint32_t bes2300p_t1_patch_33_ins_data[] = { + 0xfdf6f624, 0x4638b920, 0xf63c2100, 0xb108fa01, 0xbf2bf628, 0xbf3df628, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch33 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch33 = { 33, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_patch_33_ins_data), 0x0002fba8, 0xb8ccf1d7, 0xc0006d44, - (uint8_t *)bes2300p_t1_patch_33_ins_data -};//protect ble 8 slot + (uint8_t *)bes2300p_t1_patch_33_ins_data}; // protect ble 8 slot -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch34 = -{ - 34, - BTDRV_PATCH_ACT, - 0, - 0x00043248, - 0xbf8c2c08, - 0, - NULL, -};//check conflict 8 slot 2 +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch34 = { + 34, BTDRV_PATCH_ACT, 0, 0x00043248, 0xbf8c2c08, 0, NULL, +}; // check conflict 8 slot 2 -const uint32_t bes2300p_t1_patch_35_ins_data[] = -{ +const uint32_t bes2300p_t1_patch_35_ins_data[] = { /*6d54*/ 0xf8534b02, /*6d58*/ 0xb11b3020, /*6d5c*/ 0xbafdf610, @@ -6283,31 +4001,21 @@ const uint32_t bes2300p_t1_patch_35_ins_data[] = /*6d64*/ 0x47702000, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch35 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch35 = { 35, BTDRV_PATCH_INACT, sizeof(bes2300p_t1_patch_35_ins_data), 0x00017354, 0xbcfef1ef, 0xc0006d54, - (uint8_t *)bes2300p_t1_patch_35_ins_data -};//is_in_sniff_mode use NULL ptr + (uint8_t *)bes2300p_t1_patch_35_ins_data}; // is_in_sniff_mode use NULL ptr -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch36 = -{ - 36, - BTDRV_PATCH_INACT, - 0, - 0x00039b58, - 0xf2002802, - 0, - NULL, -};//ld_sniffer_start_monitored_link(link_id >= MAX_NB_ACTIVE_ACL) +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch36 = { + 36, BTDRV_PATCH_INACT, 0, 0x00039b58, 0xf2002802, 0, NULL, +}; // ld_sniffer_start_monitored_link(link_id >= MAX_NB_ACTIVE_ACL) /////2300p t1 patch -static const uint32_t best2300p_t1_ins_patch_config[] = -{ +static const uint32_t best2300p_t1_ins_patch_config[] = { 37, (uint32_t)&bes2300p_t1_ins_patch0, (uint32_t)&bes2300p_t1_ins_patch1, @@ -6348,121 +4056,111 @@ static const uint32_t best2300p_t1_ins_patch_config[] = (uint32_t)&bes2300p_t1_ins_patch36, }; -void btdrv_ins_patch_write(BTDRV_PATCH_STRUCT *ins_patch_p) -{ - uint32_t remap_addr; - /// uint8_t i=0; - remap_addr = ins_patch_p->patch_remap_address | 1; - btdrv_write_memory(_32_Bit,(BTDRV_PATCH_INS_REMAP_ADDR_START + ins_patch_p->patch_index*4), - (uint8_t *)&ins_patch_p->patch_remap_value,4); - if(ins_patch_p->patch_length != 0) //have ram patch data - { - btdrv_memory_copy((uint32_t *)ins_patch_p->patch_start_address,(uint32_t *)ins_patch_p->patch_data,ins_patch_p->patch_length); - } - - btdrv_write_memory(_32_Bit,(BTDRV_PATCH_INS_COMP_ADDR_START + ins_patch_p->patch_index*4), - (uint8_t *)&remap_addr,4); +void btdrv_ins_patch_write(BTDRV_PATCH_STRUCT *ins_patch_p) { + uint32_t remap_addr; + /// uint8_t i=0; + remap_addr = ins_patch_p->patch_remap_address | 1; + btdrv_write_memory( + _32_Bit, + (BTDRV_PATCH_INS_REMAP_ADDR_START + ins_patch_p->patch_index * 4), + (uint8_t *)&ins_patch_p->patch_remap_value, 4); + if (ins_patch_p->patch_length != 0) // have ram patch data + { + btdrv_memory_copy((uint32_t *)ins_patch_p->patch_start_address, + (uint32_t *)ins_patch_p->patch_data, + ins_patch_p->patch_length); + } + btdrv_write_memory( + _32_Bit, (BTDRV_PATCH_INS_COMP_ADDR_START + ins_patch_p->patch_index * 4), + (uint8_t *)&remap_addr, 4); } -void btdrv_ins_patch_init(void) -{ - const BTDRV_PATCH_STRUCT *ins_patch_p; - if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_0) - { - for(uint8_t i=0; ipatch_state ==BTDRV_PATCH_ACT) - btdrv_ins_patch_write((BTDRV_PATCH_STRUCT *)best2300p_t1_ins_patch_config[i+1]); - } +void btdrv_ins_patch_init(void) { + const BTDRV_PATCH_STRUCT *ins_patch_p; + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_0) { + for (uint8_t i = 0; i < best2300p_t1_ins_patch_config[0]; i++) { + ins_patch_p = (BTDRV_PATCH_STRUCT *)best2300p_t1_ins_patch_config[i + 1]; + if (ins_patch_p->patch_state == BTDRV_PATCH_ACT) + btdrv_ins_patch_write( + (BTDRV_PATCH_STRUCT *)best2300p_t1_ins_patch_config[i + 1]); } - else if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_1) - { + } else if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_1) { #ifndef IBRT - for(uint8_t i=0; ipatch_state ==BTDRV_PATCH_ACT) - btdrv_ins_patch_write((BTDRV_PATCH_STRUCT *)best2300p_t2_ins_patch_config[i+1]); - } -#else - for(uint8_t i=0; ipatch_state ==BTDRV_PATCH_ACT) - btdrv_ins_patch_write((BTDRV_PATCH_STRUCT *)best2300p_t2_ibrt_ins_patch_config[i+1]); - } -#endif + for (uint8_t i = 0; i < best2300p_t2_ins_patch_config[0]; i++) { + ins_patch_p = (BTDRV_PATCH_STRUCT *)best2300p_t2_ins_patch_config[i + 1]; + if (ins_patch_p->patch_state == BTDRV_PATCH_ACT) + btdrv_ins_patch_write( + (BTDRV_PATCH_STRUCT *)best2300p_t2_ins_patch_config[i + 1]); } - else if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) - { +#else + for (uint8_t i = 0; i < best2300p_t2_ibrt_ins_patch_config[0]; i++) { + ins_patch_p = + (BTDRV_PATCH_STRUCT *)best2300p_t2_ibrt_ins_patch_config[i + 1]; + if (ins_patch_p->patch_state == BTDRV_PATCH_ACT) + btdrv_ins_patch_write( + (BTDRV_PATCH_STRUCT *)best2300p_t2_ibrt_ins_patch_config[i + 1]); + } +#endif + } else if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) { #ifdef IBRT - for(uint8_t i=0; ipatch_state ==BTDRV_PATCH_ACT) - btdrv_ins_patch_write((BTDRV_PATCH_STRUCT *)best2300p_t3_ibrt_ins_patch_config[i+1]); - } + for (uint8_t i = 0; i < best2300p_t3_ibrt_ins_patch_config[0]; i++) { + ins_patch_p = + (BTDRV_PATCH_STRUCT *)best2300p_t3_ibrt_ins_patch_config[i + 1]; + if (ins_patch_p->patch_state == BTDRV_PATCH_ACT) + btdrv_ins_patch_write( + (BTDRV_PATCH_STRUCT *)best2300p_t3_ibrt_ins_patch_config[i + 1]); + } #else - for(uint8_t i=0; ipatch_state ==BTDRV_PATCH_ACT) - btdrv_ins_patch_write((BTDRV_PATCH_STRUCT *)best2300p_t3_ins_patch_config[i+1]); - } + for (uint8_t i = 0; i < best2300p_t3_ins_patch_config[0]; i++) { + ins_patch_p = (BTDRV_PATCH_STRUCT *)best2300p_t3_ins_patch_config[i + 1]; + if (ins_patch_p->patch_state == BTDRV_PATCH_ACT) + btdrv_ins_patch_write( + (BTDRV_PATCH_STRUCT *)best2300p_t3_ins_patch_config[i + 1]); + } #endif - } - else - { - ASSERT(0, "%s:error chip id=%d", __func__, hal_get_chip_metal_id()); - } + } else { + ASSERT(0, "%s:error chip id=%d", __func__, hal_get_chip_metal_id()); + } } ///////////////////data patch ..//////////////////////////////////// -static const POSSIBLY_UNUSED uint32_t best2300p_t2_data_patch_config[] = -{ -}; +static const POSSIBLY_UNUSED uint32_t best2300p_t2_data_patch_config[] = {}; -void btdrv_data_patch_write(const BTDRV_PATCH_STRUCT *d_patch_p) -{ +void btdrv_data_patch_write(const BTDRV_PATCH_STRUCT *d_patch_p) { - uint32_t remap_addr; - uint8_t i=0; + uint32_t remap_addr; + uint8_t i = 0; - remap_addr = d_patch_p->patch_remap_address |1; - btdrv_write_memory(_32_Bit,(BTDRV_PATCH_DATA_COMP_ADDR_START + d_patch_p->patch_index*4), - (uint8_t *)&remap_addr,4); - btdrv_write_memory(_32_Bit,(BTDRV_PATCH_DATA_REMAP_ADDR_START + d_patch_p->patch_index*4), - (uint8_t *)&d_patch_p->patch_remap_value,4); + remap_addr = d_patch_p->patch_remap_address | 1; + btdrv_write_memory( + _32_Bit, (BTDRV_PATCH_DATA_COMP_ADDR_START + d_patch_p->patch_index * 4), + (uint8_t *)&remap_addr, 4); + btdrv_write_memory( + _32_Bit, (BTDRV_PATCH_DATA_REMAP_ADDR_START + d_patch_p->patch_index * 4), + (uint8_t *)&d_patch_p->patch_remap_value, 4); - if(d_patch_p->patch_length != 0) //have ram patch data - { - for( ; i<(d_patch_p->patch_length-1)/128; i++) - { - btdrv_write_memory(_32_Bit,d_patch_p->patch_start_address+i*128, - (d_patch_p->patch_data+i*128),128); - - } - - btdrv_write_memory(_32_Bit,d_patch_p->patch_start_address+i*128,d_patch_p->patch_data+i*128, - d_patch_p->patch_length%128); + if (d_patch_p->patch_length != 0) // have ram patch data + { + for (; i < (d_patch_p->patch_length - 1) / 128; i++) { + btdrv_write_memory(_32_Bit, d_patch_p->patch_start_address + i * 128, + (d_patch_p->patch_data + i * 128), 128); } + btdrv_write_memory(_32_Bit, d_patch_p->patch_start_address + i * 128, + d_patch_p->patch_data + i * 128, + d_patch_p->patch_length % 128); + } } - -void btdrv_ins_patch_disable(uint8_t index) -{ - uint32_t addr=0; - btdrv_write_memory(_32_Bit,(BTDRV_PATCH_INS_COMP_ADDR_START + index*4), - (uint8_t *)&addr,4); - +void btdrv_ins_patch_disable(uint8_t index) { + uint32_t addr = 0; + btdrv_write_memory(_32_Bit, (BTDRV_PATCH_INS_COMP_ADDR_START + index * 4), + (uint8_t *)&addr, 4); } -void btdrv_data_patch_init(void) -{ +void btdrv_data_patch_init(void) { #if 0 const BTDRV_PATCH_STRUCT *data_patch_p; if(hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) @@ -6477,35 +4175,25 @@ void btdrv_data_patch_init(void) #endif } - //////////////////////////////patch enable//////////////////////// -void btdrv_patch_en(uint8_t en) -{ - uint32_t value[2]; +void btdrv_patch_en(uint8_t en) { + uint32_t value[2]; - //set patch enable - value[0] = 0x2f02 | en; - //set patch remap address to 0xc0000100 - value[1] = 0x20000100; - btdrv_write_memory(_32_Bit,BTDRV_PATCH_EN_REG,(uint8_t *)&value,8); + // set patch enable + value[0] = 0x2f02 | en; + // set patch remap address to 0xc0000100 + value[1] = 0x20000100; + btdrv_write_memory(_32_Bit, BTDRV_PATCH_EN_REG, (uint8_t *)&value, 8); } /////////////2300p t3 test mode patch/////////////////////// -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch_testmode_0 = -{ - 0, - BTDRV_PATCH_ACT, - 0, - 0x0002ceb4, - 0xe00b0f0f, - 0, - NULL -};//ld_acl_rx() average rssi +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch_testmode_0 = { + 0, BTDRV_PATCH_ACT, 0, 0x0002ceb4, 0xe00b0f0f, 0, + NULL}; // ld_acl_rx() average rssi -const uint32_t bes2300p_t3_ins_patch_data_testmode_1[] = -{ +const uint32_t bes2300p_t3_ins_patch_data_testmode_1[] = { /*6a98*/ 0x99049803, /*6a9c*/ 0x4b12b470, /*6aa0*/ 0x010e5c5a, @@ -6525,13 +4213,13 @@ const uint32_t bes2300p_t3_ins_patch_data_testmode_1[] = /*6ad8*/ 0xf0f4fb93, /*6adc*/ 0xbc70b240, /*6ae0*/ 0x22019904, - /*6ae4*/ 0xba00f626, //jump a0206ae4 -> a002cee8 - /*6ae8*/ 0xc0006af8, //addr of rssi_idx_for_agc - /*6aec*/ 0xc0006afc, //addr of rssi_set_for_agc - /*6af0*/ 0xc0006af4, //addr of N - /*6af4*/ 0x00000005, //N : 1 ~ 16 - /*6af8*/ 0x00000000, //rssi_idx_for_agc[3] - /*6afc*/ 0xbabababa, //rssi_set_for_agc[3*16] + /*6ae4*/ 0xba00f626, // jump a0206ae4 -> a002cee8 + /*6ae8*/ 0xc0006af8, // addr of rssi_idx_for_agc + /*6aec*/ 0xc0006afc, // addr of rssi_set_for_agc + /*6af0*/ 0xc0006af4, // addr of N + /*6af4*/ 0x00000005, // N : 1 ~ 16 + /*6af8*/ 0x00000000, // rssi_idx_for_agc[3] + /*6afc*/ 0xbabababa, // rssi_set_for_agc[3*16] /*6b00*/ 0xbabababa, /*6b04*/ 0xbabababa, /*6b08*/ 0xbabababa, @@ -6546,305 +4234,126 @@ const uint32_t bes2300p_t3_ins_patch_data_testmode_1[] = /*6b2c*/ 0xbabababa, }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch_testmode_1 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch_testmode_1 = { 1, BTDRV_PATCH_ACT, sizeof(bes2300p_t3_ins_patch_data_testmode_1), 0x0002cee4, - 0xbdd8f1d9, //jump a002cee4 -> a0206a98 + 0xbdd8f1d9, // jump a002cee4 -> a0206a98 0xc0006a98, - (uint8_t *)bes2300p_t3_ins_patch_data_testmode_1 -};//ld_acl_rx() average rssi + (uint8_t *) + bes2300p_t3_ins_patch_data_testmode_1}; // ld_acl_rx() average rssi -const uint32_t bes2300p_t3_ins_patch_data_testmode_2[] = -{ - 0x2028f843,/*6b3c*/ - 0xf8434b08, - 0x4b052028, - 0x4b0e701a, - 0x2201701a, - 0xf8434b08, - 0xbf002028, - 0xba32f624, - 0xc0006b60, - 0x00000000, - 0xc0006b68, - 0x00000000, - 0x00000000, - 0x00000000, - 0xc0006b78, - 0x00000001, - 0x00000001, - 0x00000001, - 0xc0006b88, - 0x00000000,/*6b88*/ +const uint32_t bes2300p_t3_ins_patch_data_testmode_2[] = { + 0x2028f843, /*6b3c*/ + 0xf8434b08, 0x4b052028, 0x4b0e701a, 0x2201701a, 0xf8434b08, + 0xbf002028, 0xba32f624, 0xc0006b60, 0x00000000, 0xc0006b68, + 0x00000000, 0x00000000, 0x00000000, 0xc0006b78, 0x00000001, + 0x00000001, 0x00000001, 0xc0006b88, 0x00000000, /*6b88*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch_testmode_2 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch_testmode_2 = { 2, BTDRV_PATCH_ACT, sizeof(bes2300p_t3_ins_patch_data_testmode_2), 0x0002afbc, 0xbdbef1db, 0xc0006b3c, - (uint8_t *)bes2300p_t3_ins_patch_data_testmode_2 -};//sync clear count + (uint8_t *)bes2300p_t3_ins_patch_data_testmode_2}; // sync clear count -const uint32_t bes2300p_t3_ins_patch_data_testmode_3[] = -{ - 0x47f0e92d,/*7050*/ - 0x4b97b082, - 0x236e5c1e, - 0xf300fb03, - 0x5a9b4a95, - 0x4f00f413, - 0x8120f040, - 0x46044689, - 0x1800ea4f, - 0xeb084f91, - 0x4b910507, - 0xa020f853, - 0xf8524a90, - 0x33013020, - 0x3020f842, - 0xf860f635, - 0x42a04601, - 0x8088f040, - 0xf8534b8a, - 0x4b8a2024, - 0x429a681b, - 0xf8dad817, - 0xebc22084, - 0xf0230309, - 0xf1b34378, - 0xd9046f80, - 0x0302ebc9, - 0x4378f023, - 0x4a82425b, - 0x0024f852, - 0x68124a81, - 0xf200fb02, - 0xf2404293, - 0x4b7f80eb, - 0x3000f993, - 0x4b7eb9c3, - 0xc000f893, - 0x0f00f1bc, - 0x462ad00a, - 0x0e0ceb05, - 0xf9122300, - 0x44030b01, - 0xd1fa4572, - 0xe0014662, - 0x46132200, - 0xfcfcfb93, - 0xf8804872, - 0xe001c000, - 0x46132200, - 0xf890486f, - 0x4870e000, - 0x9000f890, - 0xf890486f, - 0xfa4fc000, - 0xebc9f08e, - 0xfa4f0000, - 0x4550fa8c, - 0xebc9dd05, - 0x48660e0e, - 0xe000f880, - 0x4864e002, - 0xc000f880, - 0x0e00f04f, - 0xf840485d, - 0xf8dfe024, - 0xf85ee178, - 0x30010024, - 0x0024f84e, - 0x7800485d, - 0xd2054286, - 0x783f4f5a, - 0x360155af, - 0xe004b2f6, - 0x78364e57, - 0x6007f808, - 0x4f4d2601, - 0x4282553e, - 0x442ada06, - 0xf9124405, - 0x44234b01, - 0xd1fa42aa, - 0xfb934a53, - 0x9200f0f0, - 0xb2406a14, - 0x23002201, - 0xe08147a0, - 0xf8534b46, - 0x4b4e2024, - 0x429a681b, - 0xf8dad816, - 0xebc22084, - 0xf0230309, - 0xf1b34378, - 0xd9046f80, - 0x0302ebc9, - 0x4378f023, - 0x4a3e425b, - 0x1024f852, - 0x68124a44, - 0xf201fb02, - 0xd9634293, - 0xf9934b42, - 0xb9c33000, - 0xf8934b3a, - 0xf1bee000, - 0xd00a0f00, - 0xeb05462a, - 0x2300000e, - 0x1b01f912, - 0x4282440b, - 0x4672d1fa, - 0x2200e001, - 0xfb934613, - 0x4936fefe, - 0xe000f881, - 0x2200e001, - 0x49334613, - 0x49337808, - 0xc000f891, - 0xf8914932, - 0xb241e000, - 0x0101ebcc, - 0xf98efa4f, - 0xdd044549, - 0x0000ebcc, - 0x7008492a, - 0x4929e002, - 0xe000f881, - 0x491c2000, - 0x0024f841, - 0xf850481c, - 0x31011024, - 0x1024f840, - 0x7808491c, - 0xd2054286, - 0x78094920, - 0x360155a9, - 0xe004b2f6, - 0x7809491d, - 0x1007f808, - 0x490c2601, - 0x4282550e, - 0x442ada06, - 0xf9124405, - 0x440b1b01, - 0xd1fa42aa, - 0xfb934a12, - 0x9200f0f0, - 0xb2406a15, - 0x22014621, - 0x47a82300, - 0xe8bdb002, - 0xbf0087f0, - 0xc0006af8,//rssi_idx_for_agc[link_id] shenxin - 0xd02111f8,//EM_BT_RD(EM_BT_RXBIT_ADDR - 0xc0006afc,//rssi_set_for_agc shenxin - 0xc00009d4,//ld_acl_env[link_id] - 0xc0006b68,//link_no_sync_count[link_id] - 0xc00072fc,//link_agc_thd_tws - 0xc0006b78,//link_no_sync_count_time[link_id] - 0xc0007300,//link_agc_thd_tws_time - 0xc0006b60,//rssi_store_tws - 0xc0006af4,//n shenxin - 0xc0007304,//rssi_tws_step - 0xc0007308,//rssi_min_value_tws - 0xc0004268,//rwip_rf.rxgain_cntl - 0xc000730c,//link_agc_thd_mobile - 0xc0007310,//link_agc_thd_mobile_time - 0xc0006b88,//rssi_store_mobile - 0xc0007314,//rssi_mobile_step - 0xc0007318,//rssi_min_value_mobile - 0xffffffff,//link_agc_thd_tws - 0x00000030,//link_agc_thd_tws_time - 0x00000014,//rssi_tws_step - 0x0000009c,//rssi_min_value_tws - 0xffffffff,//link_agc_thd_mobile - 0x00000030,//link_agc_thd_mobile_time - 0x00000014,//rssi_mobile_step - 0x000000a1,//rssi_min_value_mobile - 0x99029804, - 0xfe96f7ff, - 0xfc48f632, - 0xb898f626,/*7328*/ +const uint32_t bes2300p_t3_ins_patch_data_testmode_3[] = { + 0x47f0e92d, /*7050*/ + 0x4b97b082, 0x236e5c1e, 0xf300fb03, 0x5a9b4a95, 0x4f00f413, 0x8120f040, + 0x46044689, 0x1800ea4f, 0xeb084f91, 0x4b910507, 0xa020f853, 0xf8524a90, + 0x33013020, 0x3020f842, 0xf860f635, 0x42a04601, 0x8088f040, 0xf8534b8a, + 0x4b8a2024, 0x429a681b, 0xf8dad817, 0xebc22084, 0xf0230309, 0xf1b34378, + 0xd9046f80, 0x0302ebc9, 0x4378f023, 0x4a82425b, 0x0024f852, 0x68124a81, + 0xf200fb02, 0xf2404293, 0x4b7f80eb, 0x3000f993, 0x4b7eb9c3, 0xc000f893, + 0x0f00f1bc, 0x462ad00a, 0x0e0ceb05, 0xf9122300, 0x44030b01, 0xd1fa4572, + 0xe0014662, 0x46132200, 0xfcfcfb93, 0xf8804872, 0xe001c000, 0x46132200, + 0xf890486f, 0x4870e000, 0x9000f890, 0xf890486f, 0xfa4fc000, 0xebc9f08e, + 0xfa4f0000, 0x4550fa8c, 0xebc9dd05, 0x48660e0e, 0xe000f880, 0x4864e002, + 0xc000f880, 0x0e00f04f, 0xf840485d, 0xf8dfe024, 0xf85ee178, 0x30010024, + 0x0024f84e, 0x7800485d, 0xd2054286, 0x783f4f5a, 0x360155af, 0xe004b2f6, + 0x78364e57, 0x6007f808, 0x4f4d2601, 0x4282553e, 0x442ada06, 0xf9124405, + 0x44234b01, 0xd1fa42aa, 0xfb934a53, 0x9200f0f0, 0xb2406a14, 0x23002201, + 0xe08147a0, 0xf8534b46, 0x4b4e2024, 0x429a681b, 0xf8dad816, 0xebc22084, + 0xf0230309, 0xf1b34378, 0xd9046f80, 0x0302ebc9, 0x4378f023, 0x4a3e425b, + 0x1024f852, 0x68124a44, 0xf201fb02, 0xd9634293, 0xf9934b42, 0xb9c33000, + 0xf8934b3a, 0xf1bee000, 0xd00a0f00, 0xeb05462a, 0x2300000e, 0x1b01f912, + 0x4282440b, 0x4672d1fa, 0x2200e001, 0xfb934613, 0x4936fefe, 0xe000f881, + 0x2200e001, 0x49334613, 0x49337808, 0xc000f891, 0xf8914932, 0xb241e000, + 0x0101ebcc, 0xf98efa4f, 0xdd044549, 0x0000ebcc, 0x7008492a, 0x4929e002, + 0xe000f881, 0x491c2000, 0x0024f841, 0xf850481c, 0x31011024, 0x1024f840, + 0x7808491c, 0xd2054286, 0x78094920, 0x360155a9, 0xe004b2f6, 0x7809491d, + 0x1007f808, 0x490c2601, 0x4282550e, 0x442ada06, 0xf9124405, 0x440b1b01, + 0xd1fa42aa, 0xfb934a12, 0x9200f0f0, 0xb2406a15, 0x22014621, 0x47a82300, + 0xe8bdb002, 0xbf0087f0, + 0xc0006af8, // rssi_idx_for_agc[link_id] shenxin + 0xd02111f8, // EM_BT_RD(EM_BT_RXBIT_ADDR + 0xc0006afc, // rssi_set_for_agc shenxin + 0xc00009d4, // ld_acl_env[link_id] + 0xc0006b68, // link_no_sync_count[link_id] + 0xc00072fc, // link_agc_thd_tws + 0xc0006b78, // link_no_sync_count_time[link_id] + 0xc0007300, // link_agc_thd_tws_time + 0xc0006b60, // rssi_store_tws + 0xc0006af4, // n shenxin + 0xc0007304, // rssi_tws_step + 0xc0007308, // rssi_min_value_tws + 0xc0004268, // rwip_rf.rxgain_cntl + 0xc000730c, // link_agc_thd_mobile + 0xc0007310, // link_agc_thd_mobile_time + 0xc0006b88, // rssi_store_mobile + 0xc0007314, // rssi_mobile_step + 0xc0007318, // rssi_min_value_mobile + 0xffffffff, // link_agc_thd_tws + 0x00000030, // link_agc_thd_tws_time + 0x00000014, // rssi_tws_step + 0x0000009c, // rssi_min_value_tws + 0xffffffff, // link_agc_thd_mobile + 0x00000030, // link_agc_thd_mobile_time + 0x00000014, // rssi_mobile_step + 0x000000a1, // rssi_min_value_mobile + 0x99029804, 0xfe96f7ff, 0xfc48f632, 0xb898f626, /*7328*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch_testmode_3 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch_testmode_3 = { 3, BTDRV_PATCH_ACT, sizeof(bes2300p_t3_ins_patch_data_testmode_3), 0x0002d458, 0xbf60f1d9, 0xc0007050, - (uint8_t *)bes2300p_t3_ins_patch_data_testmode_3 -};//swagc no sync + (uint8_t *)bes2300p_t3_ins_patch_data_testmode_3}; // swagc no sync -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch_testmode_4 = -{ - 4, - BTDRV_PATCH_ACT, - 0, - 0x0000e47a, - 0xe0027b20, - 0, - NULL -};//lm_inq_res_ind_handler() rssi +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch_testmode_4 = { + 4, BTDRV_PATCH_ACT, 0, 0x0000e47a, 0xe0027b20, 0, + NULL}; // lm_inq_res_ind_handler() rssi -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch_testmode_5 = -{ - 5, - BTDRV_PATCH_INACT, - 0, - 0x0002ad78, - 0xbf00e009, - 0, - NULL -};//ld_acl_rx_no_sync() rssi +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch_testmode_5 = { + 5, BTDRV_PATCH_INACT, 0, 0x0002ad78, 0xbf00e009, 0, + NULL}; // ld_acl_rx_no_sync() rssi -const uint32_t bes2300p_t3_ins_patch_data_testmode_6[] = -{ - 0xf8802300, - 0xf8803024, - 0xbf003025, - 0x30b3f894, - 0xbc18f62d, -};/* 6b90-6ba0 */ +const uint32_t bes2300p_t3_ins_patch_data_testmode_6[] = { + 0xf8802300, 0xf8803024, 0xbf003025, 0x30b3f894, 0xbc18f62d, +}; /* 6b90-6ba0 */ -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch_testmode_6 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch_testmode_6 = { 6, BTDRV_PATCH_ACT, sizeof(bes2300p_t3_ins_patch_data_testmode_6), 0x000343d0, 0xbbdef1d2, 0xc0006b90, - (uint8_t *)bes2300p_t3_ins_patch_data_testmode_6 -};//nosig test pattern problem + (uint8_t *) + bes2300p_t3_ins_patch_data_testmode_6}; // nosig test pattern problem -const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch_testmode_7 = -{ - 7, - BTDRV_PATCH_ACT, - 0, - 0x00000880, - 0x26004c0e, - 0, - NULL, -};//rwip_env.sleep_enable=false after hci reset +const BTDRV_PATCH_STRUCT bes2300p_t3_ins_patch_testmode_7 = { + 7, BTDRV_PATCH_ACT, 0, 0x00000880, 0x26004c0e, 0, NULL, +}; // rwip_env.sleep_enable=false after hci reset -static const uint32_t ins_patch_2300p_t3_config_testmode[] = -{ +static const uint32_t ins_patch_2300p_t3_config_testmode[] = { 8, (uint32_t)&bes2300p_t3_ins_patch_testmode_0, (uint32_t)&bes2300p_t3_ins_patch_testmode_1, @@ -6857,76 +4366,42 @@ static const uint32_t ins_patch_2300p_t3_config_testmode[] = }; /////////////2300p t2 test mode patch/////////////////////// -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch_testmode_0 = -{ - 0, - BTDRV_PATCH_ACT, - 0, - 0x00000874, - 0x26004c0e, - 0, - NULL, -};////rwip_env.sleep_enable=false after hci reset +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch_testmode_0 = { + 0, BTDRV_PATCH_ACT, 0, 0x00000874, 0x26004c0e, 0, NULL, +}; ////rwip_env.sleep_enable=false after hci reset -const uint32_t bes2300p_t2_ins_patch_data_testmode_1[] = -{ - 0x4681b083,/*6b30*/ - 0x4b022200, - 0x2020f843, - 0xbddcf623, - 0xc0006b44, - 0x00000000, - 0x00000000, - 0x00000000,/*6b4c*/ +const uint32_t bes2300p_t2_ins_patch_data_testmode_1[] = { + 0x4681b083, /*6b30*/ + 0x4b022200, 0x2020f843, 0xbddcf623, 0xc0006b44, + 0x00000000, 0x00000000, 0x00000000, /*6b4c*/ }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch_testmode_1 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch_testmode_1 = { 1, BTDRV_PATCH_ACT, sizeof(bes2300p_t2_ins_patch_data_testmode_1), 0x0002a6f4, 0xba1cf1dc, 0xc0006b30, - (uint8_t *)bes2300p_t2_ins_patch_data_testmode_1 -};//sync clear count + (uint8_t *)bes2300p_t2_ins_patch_data_testmode_1}; // sync clear count -const uint32_t bes2300p_t2_ins_patch_data_testmode_2[] = -{ - 0x6020f853, - 0xf8524a0d, - 0x33013020, - 0x3020f842, - 0x68124a0b, - 0xd90f4293, - 0x4a082300, - 0x3020f842, - 0xb082b402, - 0x92004a08, - 0xf06f6a14, - 0x46290059, - 0x47a02201, - 0xbc02b002, - 0xbce4f623, - 0xc0006b44, - 0xc0006b94, - 0x00000010, - 0xc00041b4, +const uint32_t bes2300p_t2_ins_patch_data_testmode_2[] = { + 0x6020f853, 0xf8524a0d, 0x33013020, 0x3020f842, 0x68124a0b, + 0xd90f4293, 0x4a082300, 0x3020f842, 0xb082b402, 0x92004a08, + 0xf06f6a14, 0x46290059, 0x47a02201, 0xbc02b002, 0xbce4f623, + 0xc0006b44, 0xc0006b94, 0x00000010, 0xc00041b4, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch_testmode_2 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch_testmode_2 = { 2, BTDRV_PATCH_ACT, sizeof(bes2300p_t2_ins_patch_data_testmode_2), 0x0002a550, 0xbafef1dc, 0xc0006b50, - (uint8_t *)bes2300p_t2_ins_patch_data_testmode_2 -}; + (uint8_t *)bes2300p_t2_ins_patch_data_testmode_2}; -const uint32_t bes2300p_t2_ins_patch_data_testmode_3[] = -{ +const uint32_t bes2300p_t2_ins_patch_data_testmode_3[] = { /*6f90*/ 0xbf009904, /*6f94*/ 0x4b12b470, /*6f98*/ 0x010e5c5a, @@ -6946,13 +4421,13 @@ const uint32_t bes2300p_t2_ins_patch_data_testmode_3[] = /*6fd0*/ 0xf0f4fb93, /*6fd4*/ 0xbc70b240, /*6fd8*/ 0x22019904, - /*6fdc*/ 0xbb8cf628, //jump a002f6f8 - /*6fe0*/ 0xc0006ff0, //addr of rssi_idx_for_agc - /*6fe4*/ 0xc0006ff4, //addr of rssi_set_for_agc - /*6fe8*/ 0xc0006fec, //addr of N - /*6fec*/ 0x00000005, //N : 1 ~ 16 - /*6ff0*/ 0x00000000, //rssi_idx_for_agc[3] - /*6ff4*/ 0xbabababa, //rssi_set_for_agc[3*16] + /*6fdc*/ 0xbb8cf628, // jump a002f6f8 + /*6fe0*/ 0xc0006ff0, // addr of rssi_idx_for_agc + /*6fe4*/ 0xc0006ff4, // addr of rssi_set_for_agc + /*6fe8*/ 0xc0006fec, // addr of N + /*6fec*/ 0x00000005, // N : 1 ~ 16 + /*6ff0*/ 0x00000000, // rssi_idx_for_agc[3] + /*6ff4*/ 0xbabababa, // rssi_set_for_agc[3*16] /*6ff8*/ 0xbabababa, /*6ffc*/ 0xbabababa, /*7000*/ 0xbabababa, @@ -6967,90 +4442,69 @@ const uint32_t bes2300p_t2_ins_patch_data_testmode_3[] = /*7024*/ 0xbabababa, /*7028*/ 0xbabababa, /*702c*/ 0xbabababa, -};//0xc0006f90--->0xc0007074 +}; // 0xc0006f90--->0xc0007074 -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch_testmode_3 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch_testmode_3 = { 3, BTDRV_PATCH_ACT, sizeof(bes2300p_t2_ins_patch_data_testmode_3), 0x0002f6f4, - 0xbc4cf1d7, //jump a002f6f4 -> a0206f90 + 0xbc4cf1d7, // jump a002f6f4 -> a0206f90 0xc0006f90, - (uint8_t *)bes2300p_t2_ins_patch_data_testmode_3 -}; //ld_acl_rx() average rssi + (uint8_t *) + bes2300p_t2_ins_patch_data_testmode_3}; // ld_acl_rx() average rssi -const uint32_t bes2300p_t2_ins_patch_data_testmode_4[] = -{ +const uint32_t bes2300p_t2_ins_patch_data_testmode_4[] = { 0x4620461d, 0x463a4629, 0xf5f94633, 0xbdf8fc2b, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch_testmode_4 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch_testmode_4 = { 4, BTDRV_PATCH_ACT, sizeof(bes2300p_t2_ins_patch_data_testmode_4), 0x000070ec, 0xbe08f1ff, 0xc0006d00, - (uint8_t *)bes2300p_t2_ins_patch_data_testmode_4 -};//assert warn + (uint8_t *)bes2300p_t2_ins_patch_data_testmode_4}; // assert warn -const uint32_t bes2300p_t2_ins_patch_data_testmode_5[] = -{ +const uint32_t bes2300p_t2_ins_patch_data_testmode_5[] = { 0x4630461f, 0x462a4639, 0xf5f94623, 0xbdf8fc21, }; -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch_testmode_5 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch_testmode_5 = { 5, BTDRV_PATCH_ACT, sizeof(bes2300p_t2_ins_patch_data_testmode_5), 0x00007070, 0xbe50f1ff, 0xc0006d14, - (uint8_t *)bes2300p_t2_ins_patch_data_testmode_5 -};//assert param + (uint8_t *)bes2300p_t2_ins_patch_data_testmode_5}; // assert param -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch_testmode_6 = -{ - 6, - BTDRV_PATCH_ACT, - 0, - 0x0003bbe0, - 0xf7c52100, - 0, - NULL, -};///ble tx test mode switch freq channel problem +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch_testmode_6 = { + 6, BTDRV_PATCH_ACT, 0, 0x0003bbe0, 0xf7c52100, 0, NULL, +}; /// ble tx test mode switch freq channel problem -const uint32_t bes2300p_t2_ins_patch_data_testmode_7[] = -{ - 0xf8802300, - 0xf8803024, - 0xbf003025, - 0x30b3f894, - 0xbe0ef62c, -};/* 6d30-6d40 */ +const uint32_t bes2300p_t2_ins_patch_data_testmode_7[] = { + 0xf8802300, 0xf8803024, 0xbf003025, 0x30b3f894, 0xbe0ef62c, +}; /* 6d30-6d40 */ -const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch_testmode_7 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t2_ins_patch_testmode_7 = { 7, BTDRV_PATCH_ACT, sizeof(bes2300p_t2_ins_patch_data_testmode_7), 0x0003395c, 0xb9e8f1d3, 0xc0006d30, - (uint8_t *)bes2300p_t2_ins_patch_data_testmode_7 -};//nosig test pattern problem + (uint8_t *) + bes2300p_t2_ins_patch_data_testmode_7}; // nosig test pattern problem -static const uint32_t ins_patch_2300p_t2_config_testmode[] = -{ +static const uint32_t ins_patch_2300p_t2_config_testmode[] = { 8, (uint32_t)&bes2300p_t2_ins_patch_testmode_0, (uint32_t)&bes2300p_t2_ins_patch_testmode_1, @@ -7064,103 +4518,53 @@ static const uint32_t ins_patch_2300p_t2_config_testmode[] = /////////////2300p t1 test mode patch/////////////////////// -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch_testmode_0 = -{ - 0, - BTDRV_PATCH_ACT, - 0, - 0x0002f440, - 0x789abf00, - 0, - NULL -};///test mode: remove rxllid's judging condition in ld_acl_rx +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch_testmode_0 = { + 0, BTDRV_PATCH_ACT, 0, 0x0002f440, 0x789abf00, 0, + NULL}; /// test mode: remove rxllid's judging condition in ld_acl_rx -const uint32_t bes2300p_t1_ins_patch_data_testmode_1[] = -{ - 0x20fcf8d5, - 0xf8928811, - 0xf0088007, - 0xb909080f, - 0x88194b11, - 0x0484eb04, - 0x3014f837, - 0xf423b29b, - 0x4a0f7300, - 0xea438812, - 0xb29b2342, - 0x3014f827, - 0x3014f837, - 0xf023b29b, - 0xea430378, - 0xf82708c8, - 0x4b068014, - 0xf043781b, - 0xea430304, - 0xb28b01c1, - 0x3014f82a, - 0xbe8ef627, - 0xc000099c,////loopback_length - 0xc000097d,////loopback_llid - 0xc0006964,////rxseq_flag +const uint32_t bes2300p_t1_ins_patch_data_testmode_1[] = { + 0x20fcf8d5, 0xf8928811, 0xf0088007, 0xb909080f, 0x88194b11, 0x0484eb04, + 0x3014f837, 0xf423b29b, 0x4a0f7300, 0xea438812, 0xb29b2342, 0x3014f827, + 0x3014f837, 0xf023b29b, 0xea430378, 0xf82708c8, 0x4b068014, 0xf043781b, + 0xea430304, 0xb28b01c1, 0x3014f82a, 0xbe8ef627, + 0xc000099c, ////loopback_length + 0xc000097d, ////loopback_llid + 0xc0006964, ////rxseq_flag 0x00000000, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch_testmode_1 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch_testmode_1 = { 1, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_ins_patch_data_testmode_1), 0x0002e60c, 0xb978f1d8, 0xc0006900, - (uint8_t*)bes2300p_t1_ins_patch_data_testmode_1 -};///test mode: ld_acl_tx_prog + (uint8_t *) + bes2300p_t1_ins_patch_data_testmode_1}; /// test mode: ld_acl_tx_prog - -const uint32_t bes2300p_t1_ins_patch_data_testmode_2[] = -{ - 0xfbdcf5fc, - 0x3060f890, - 0xd01f2b00, - 0x30fcf8db, - 0xd01b2b00, - 0x0f03f1b9, - 0xf1b9d018, - 0xd0150f08, - 0xf8934b0b, - 0x011b31cb, - 0x5a9b4a0a, - 0x7f80f413, - 0x4b09d10a, - 0x4b0a781a, - 0x4b08601a, - 0x4b09881a, - 0x2201601a, - 0x601a4b08, - 0xbc32f628, - 0xbc2ef628, - 0xc0005d34, - 0xd02115f2, - 0xc000097d,////loopback_llid - 0xc000099c,////loopback_length - 0xc0006a8c,////rxllid_flag - 0xc0006a90,////rxlength_flag - 0xc0006a94,////unack_seqerr_flag - 0x00000000, - 0x00000000, - 0x00000000, +const uint32_t bes2300p_t1_ins_patch_data_testmode_2[] = { + 0xfbdcf5fc, 0x3060f890, 0xd01f2b00, 0x30fcf8db, 0xd01b2b00, 0x0f03f1b9, + 0xf1b9d018, 0xd0150f08, 0xf8934b0b, 0x011b31cb, 0x5a9b4a0a, 0x7f80f413, + 0x4b09d10a, 0x4b0a781a, 0x4b08601a, 0x4b09881a, 0x2201601a, 0x601a4b08, + 0xbc32f628, 0xbc2ef628, 0xc0005d34, 0xd02115f2, + 0xc000097d, ////loopback_llid + 0xc000099c, ////loopback_length + 0xc0006a8c, ////rxllid_flag + 0xc0006a90, ////rxlength_flag + 0xc0006a94, ////unack_seqerr_flag + 0x00000000, 0x00000000, 0x00000000, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch_testmode_2 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch_testmode_2 = { 2, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_ins_patch_data_testmode_2), 0x0002f2c8, 0xbbaaf1d7, 0xc0006a20, - (uint8_t*)bes2300p_t1_ins_patch_data_testmode_2 -};///test mode: skip rx seq err in ld_acl_rx + (uint8_t *)bes2300p_t1_ins_patch_data_testmode_2}; /// test mode: skip rx + /// seq err in ld_acl_rx #if 0 const uint32_t bes2300p_t1_ins_patch_data_testmode_3[] = @@ -7182,79 +4586,48 @@ const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch_testmode_3 = (uint8_t*)bes2300p_t1_ins_patch_data_testmode_3 };///test mode: skip crc err in ld_acl_rx #else -const uint32_t bes2300p_t1_ins_patch_data_testmode_3[] = -{ - 0xf015d006, - 0xd0050f24, - 0x0f03f1b9, - 0xbf00d002, - 0xbc16f628, - 0xbcf8f628, +const uint32_t bes2300p_t1_ins_patch_data_testmode_3[] = { + 0xf015d006, 0xd0050f24, 0x0f03f1b9, 0xbf00d002, 0xbc16f628, 0xbcf8f628, }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch_testmode_3 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch_testmode_3 = { 3, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_ins_patch_data_testmode_3), 0x0002f2d4, 0xbbe0f1d7, 0xc0006a98, - (uint8_t*)bes2300p_t1_ins_patch_data_testmode_3 -};///test mode: skip crc err in ld_acl_rx + (uint8_t *)bes2300p_t1_ins_patch_data_testmode_3}; /// test mode: skip crc + /// err in ld_acl_rx #endif -const uint32_t bes2300p_t1_ins_patch_data_testmode_4[] = -{ - 0x700d4914, - 0xf891490c, - 0x010911cb, - 0x5a8a4a0b, - 0x2240f3c2, - 0x6002480a, - 0x6800480a, - 0x2100b150, - 0x60014808, - 0x68014808, - 0x80014808, - 0x68014808, - 0x70014808, - 0xbcbaf628, - 0xc0005d34, - 0xd02115f2, - 0xc0006964,////rxseq_flag - 0xc0006a94,////unack_seqerr_flag - 0xc0006a90,////rxlength_flag - 0xc000099c,////loopback_length - 0xc0006a8c,////rxllid_flag - 0xc000097d,////loopback_llid +const uint32_t bes2300p_t1_ins_patch_data_testmode_4[] = { + 0x700d4914, 0xf891490c, 0x010911cb, 0x5a8a4a0b, 0x2240f3c2, 0x6002480a, + 0x6800480a, 0x2100b150, 0x60014808, 0x68014808, 0x80014808, 0x68014808, + 0x70014808, 0xbcbaf628, 0xc0005d34, 0xd02115f2, + 0xc0006964, ////rxseq_flag + 0xc0006a94, ////unack_seqerr_flag + 0xc0006a90, ////rxlength_flag + 0xc000099c, ////loopback_length + 0xc0006a8c, ////rxllid_flag + 0xc000097d, ////loopback_llid }; -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch_testmode_4 = -{ +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch_testmode_4 = { 4, BTDRV_PATCH_ACT, sizeof(bes2300p_t1_ins_patch_data_testmode_4), 0x0002f464, 0xbb2af1d7, 0xc0006abc, - (uint8_t*)bes2300p_t1_ins_patch_data_testmode_4 -};///test mode: ld_acl_rx + (uint8_t *)bes2300p_t1_ins_patch_data_testmode_4}; /// test mode: ld_acl_rx -const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch_testmode_5 = -{ - 5, - BTDRV_PATCH_ACT, - 0, - 0x00000100, - 0x20004b15, - 0, - NULL, -};////rwip_env.sleep_enable=false after hci reset +const BTDRV_PATCH_STRUCT bes2300p_t1_ins_patch_testmode_5 = { + 5, BTDRV_PATCH_ACT, 0, 0x00000100, 0x20004b15, 0, NULL, +}; ////rwip_env.sleep_enable=false after hci reset -static const uint32_t ins_patch_2300p_t1_config_testmode[] = -{ +static const uint32_t ins_patch_2300p_t1_config_testmode[] = { 6, (uint32_t)&bes2300p_t1_ins_patch_testmode_0, (uint32_t)&bes2300p_t1_ins_patch_testmode_1, @@ -7264,51 +4637,45 @@ static const uint32_t ins_patch_2300p_t1_config_testmode[] = (uint32_t)&bes2300p_t1_ins_patch_testmode_5, }; -void btdrv_ins_patch_test_init(void) -{ - const BTDRV_PATCH_STRUCT *ins_patch_p; +void btdrv_ins_patch_test_init(void) { + const BTDRV_PATCH_STRUCT *ins_patch_p; - btdrv_patch_en(0); + btdrv_patch_en(0); - for(uint8_t i=0; i<56; i++) - { - btdrv_ins_patch_disable(i); - } - bt_drv_reg_op_for_test_mode_disable(); + for (uint8_t i = 0; i < 56; i++) { + btdrv_ins_patch_disable(i); + } + bt_drv_reg_op_for_test_mode_disable(); - if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_0 ) - { - for(uint8_t i=0; ipatch_state ==BTDRV_PATCH_ACT) - btdrv_ins_patch_write((BTDRV_PATCH_STRUCT *)ins_patch_2300p_t1_config_testmode[i+1]); - } + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_0) { + for (uint8_t i = 0; i < ins_patch_2300p_t1_config_testmode[0]; i++) { + ins_patch_p = + (BTDRV_PATCH_STRUCT *)ins_patch_2300p_t1_config_testmode[i + 1]; + if (ins_patch_p->patch_state == BTDRV_PATCH_ACT) + btdrv_ins_patch_write( + (BTDRV_PATCH_STRUCT *)ins_patch_2300p_t1_config_testmode[i + 1]); } - else if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_1 ) - { - for(uint8_t i=0; ipatch_state ==BTDRV_PATCH_ACT) - btdrv_ins_patch_write((BTDRV_PATCH_STRUCT *)ins_patch_2300p_t2_config_testmode[i+1]); - } - - } - else if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2 ) - { - for(uint8_t i=0; ipatch_state ==BTDRV_PATCH_ACT) - btdrv_ins_patch_write((BTDRV_PATCH_STRUCT *)ins_patch_2300p_t3_config_testmode[i+1]); - } - bt_drv_reg_op_disable_swagc_nosync_count(); - } - else - { - ASSERT(0, "%s:error chip id=%d", __func__, hal_get_chip_metal_id()); + } else if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_1) { + for (uint8_t i = 0; i < ins_patch_2300p_t2_config_testmode[0]; i++) { + ins_patch_p = + (BTDRV_PATCH_STRUCT *)ins_patch_2300p_t2_config_testmode[i + 1]; + if (ins_patch_p->patch_state == BTDRV_PATCH_ACT) + btdrv_ins_patch_write( + (BTDRV_PATCH_STRUCT *)ins_patch_2300p_t2_config_testmode[i + 1]); } - btdrv_patch_en(1); + } else if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) { + for (uint8_t i = 0; i < ins_patch_2300p_t3_config_testmode[0]; i++) { + ins_patch_p = + (BTDRV_PATCH_STRUCT *)ins_patch_2300p_t3_config_testmode[i + 1]; + if (ins_patch_p->patch_state == BTDRV_PATCH_ACT) + btdrv_ins_patch_write( + (BTDRV_PATCH_STRUCT *)ins_patch_2300p_t3_config_testmode[i + 1]); + } + bt_drv_reg_op_disable_swagc_nosync_count(); + } else { + ASSERT(0, "%s:error chip id=%d", __func__, hal_get_chip_metal_id()); + } + + btdrv_patch_en(1); } diff --git a/platform/drivers/bt/best2300p/bt_drv_reg_op.cpp b/platform/drivers/bt/best2300p/bt_drv_reg_op.cpp index dfe84ad..fbd0c7c 100644 --- a/platform/drivers/bt/best2300p/bt_drv_reg_op.cpp +++ b/platform/drivers/bt/best2300p/bt_drv_reg_op.cpp @@ -13,540 +13,466 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "cmsis.h" #include "bt_drv_reg_op.h" -#include "bt_drv_internal.h" +#include "CrashCatcher.h" +#include "bt_drv.h" #include "bt_drv_2300p_internal.h" #include "bt_drv_interface.h" -#include "bt_drv.h" -#include "hal_sysfreq.h" -#include "hal_chipid.h" -#include "hal_trace.h" -#include "hal_iomux.h" -#include -#include "CrashCatcher.h" #include "bt_drv_internal.h" +#include "cmsis.h" +#include "hal_chipid.h" +#include "hal_iomux.h" +#include "hal_sysfreq.h" +#include "hal_trace.h" +#include +static uint32_t bt_ram_start_addr = 0; +static uint32_t hci_fc_env_addr = 0; +static uint32_t ld_acl_env_addr = 0; +static uint32_t bt_util_buf_env_addr = 0; +static uint32_t em_buf_env_addr = 0; +static uint32_t sniffer_env_addr = 0; +static uint32_t dbg_state_addr = 0; +static uint32_t lc_state_addr = 0; +static uint32_t task_message_buffer_addr = 0; +static uint32_t lmp_message_buffer_addr = 0; +static uint32_t ld_sco_env_addr = 0; +static uint32_t rx_monitor_addr = 0; +static uint32_t lc_env_addr = 0; +static uint32_t dbg_bt_setting_addr = 0; +static uint32_t lm_nb_sync_active_addr = 0; +static uint32_t lm_env_addr = 0; +static uint32_t pending_seq_error_link_addr = 0; +static uint32_t hci_env_addr = 0; +static uint32_t lc_sco_env_addr = 0; +static uint32_t llm_le_env_addr = 0; +static uint32_t ld_env_addr = 0; +static uint32_t rwip_env_addr = 0; +static uint32_t MIC_BUFF_addr = 0; +static uint32_t g_mem_dump_ctrl_addr = 0; +static uint32_t ble_rx_monitor_addr = 0; +static uint32_t reconnecting_flag_addr = 0; +static uint32_t link_connect_bak_addr = 0; +static uint32_t tws_link_id_addr = 0; +static uint32_t llc_env_addr = 0; +static uint32_t dbg_bt_setting_ext1_addr = 0; +static uint32_t rwip_rf_addr = 0; +void bt_drv_reg_op_global_symbols_init(void) { + bt_ram_start_addr = 0xc0000000; + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_0) { + hci_fc_env_addr = 0xC00067c4; + ld_acl_env_addr = 0xc000098c; + bt_util_buf_env_addr = 0xc00059fc; + em_buf_env_addr = 0xc000656c; + sniffer_env_addr = 0xc0006358; + dbg_state_addr = 0xc00058c4; + lc_state_addr = 0xc0005c7c; + task_message_buffer_addr = 0xc00007cc; + lmp_message_buffer_addr = 0xc0000834; + ld_sco_env_addr = 0xc0000980; + rx_monitor_addr = 0xc00058fc; + lc_env_addr = 0xc0005c70; + dbg_bt_setting_addr = 0xc0005854; + lm_nb_sync_active_addr = 0xc00007c0; + lm_env_addr = 0xc0005afc; + hci_env_addr = 0xc0006764; + lc_sco_env_addr = 0xc00007a4; + llm_le_env_addr = 0xc00063f0; + ld_env_addr = 0xc0005d34; + rwip_env_addr = 0xc00003d4; + MIC_BUFF_addr = 0xc0005920; + ble_rx_monitor_addr = 0xc00058ec; + llc_env_addr = 0xc00064f8; + rwip_rf_addr = 0xc00041a0; -static uint32_t bt_ram_start_addr=0; -static uint32_t hci_fc_env_addr=0; -static uint32_t ld_acl_env_addr=0; -static uint32_t bt_util_buf_env_addr=0; -static uint32_t em_buf_env_addr=0; -static uint32_t sniffer_env_addr=0; -static uint32_t dbg_state_addr=0; -static uint32_t lc_state_addr=0; -static uint32_t task_message_buffer_addr=0; -static uint32_t lmp_message_buffer_addr=0; -static uint32_t ld_sco_env_addr=0; -static uint32_t rx_monitor_addr=0; -static uint32_t lc_env_addr=0; -static uint32_t dbg_bt_setting_addr=0; -static uint32_t lm_nb_sync_active_addr=0; -static uint32_t lm_env_addr=0; -static uint32_t pending_seq_error_link_addr=0; -static uint32_t hci_env_addr=0; -static uint32_t lc_sco_env_addr=0; -static uint32_t llm_le_env_addr=0; -static uint32_t ld_env_addr=0; -static uint32_t rwip_env_addr=0; -static uint32_t MIC_BUFF_addr=0; -static uint32_t g_mem_dump_ctrl_addr=0; -static uint32_t ble_rx_monitor_addr=0; -static uint32_t reconnecting_flag_addr=0; -static uint32_t link_connect_bak_addr=0; -static uint32_t tws_link_id_addr=0; -static uint32_t llc_env_addr=0; -static uint32_t dbg_bt_setting_ext1_addr=0; -static uint32_t rwip_rf_addr=0; -void bt_drv_reg_op_global_symbols_init(void) -{ - bt_ram_start_addr = 0xc0000000; - if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_0) - { - hci_fc_env_addr = 0xC00067c4; - ld_acl_env_addr = 0xc000098c; - bt_util_buf_env_addr = 0xc00059fc; - em_buf_env_addr = 0xc000656c; - sniffer_env_addr = 0xc0006358; - dbg_state_addr = 0xc00058c4; - lc_state_addr = 0xc0005c7c; - task_message_buffer_addr = 0xc00007cc; - lmp_message_buffer_addr = 0xc0000834; - ld_sco_env_addr = 0xc0000980; - rx_monitor_addr = 0xc00058fc; - lc_env_addr = 0xc0005c70; - dbg_bt_setting_addr = 0xc0005854; - lm_nb_sync_active_addr = 0xc00007c0; - lm_env_addr = 0xc0005afc; - hci_env_addr = 0xc0006764; - lc_sco_env_addr = 0xc00007a4; - llm_le_env_addr = 0xc00063f0; - ld_env_addr = 0xc0005d34; - rwip_env_addr = 0xc00003d4; - MIC_BUFF_addr = 0xc0005920; - ble_rx_monitor_addr = 0xc00058ec; - llc_env_addr = 0xc00064f8; - rwip_rf_addr = 0xc00041a0; + } else if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_1) { + hci_fc_env_addr = 0xC0006838; + ld_acl_env_addr = 0xc0000998; + bt_util_buf_env_addr = 0xc0005a18; + em_buf_env_addr = 0xc00065e0; + sniffer_env_addr = 0xc00063c8; + dbg_state_addr = 0xc00058e0; + lc_state_addr = 0xc0005ce4; + task_message_buffer_addr = 0xc00007c4; + lmp_message_buffer_addr = 0xc000082c; + ld_sco_env_addr = 0xc000098c; + rx_monitor_addr = 0xc0005918; + lc_env_addr = 0xc0005cd8; + dbg_bt_setting_addr = 0xc0005868; + lm_nb_sync_active_addr = 0xc00007b8; + lm_env_addr = 0xc0005b64; + pending_seq_error_link_addr = 0xc0000335; + hci_env_addr = 0xc00067d8; + lc_sco_env_addr = 0xc000079c; + llm_le_env_addr = 0xc0006460; + ld_env_addr = 0xc0005d9c; + rwip_env_addr = 0xc00003c8; + MIC_BUFF_addr = 0xc000593c; + ble_rx_monitor_addr = 0xc0005908; + link_connect_bak_addr = 0xc00061c8; + llc_env_addr = 0xc0006568; + rwip_rf_addr = 0xc00041b4; - } - else if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_1) - { - hci_fc_env_addr = 0xC0006838; - ld_acl_env_addr = 0xc0000998; - bt_util_buf_env_addr = 0xc0005a18; - em_buf_env_addr = 0xc00065e0; - sniffer_env_addr = 0xc00063c8; - dbg_state_addr = 0xc00058e0; - lc_state_addr = 0xc0005ce4; - task_message_buffer_addr = 0xc00007c4; - lmp_message_buffer_addr = 0xc000082c; - ld_sco_env_addr = 0xc000098c; - rx_monitor_addr = 0xc0005918; - lc_env_addr = 0xc0005cd8; - dbg_bt_setting_addr = 0xc0005868; - lm_nb_sync_active_addr = 0xc00007b8; - lm_env_addr = 0xc0005b64; - pending_seq_error_link_addr = 0xc0000335; - hci_env_addr = 0xc00067d8; - lc_sco_env_addr = 0xc000079c; - llm_le_env_addr = 0xc0006460; - ld_env_addr = 0xc0005d9c; - rwip_env_addr = 0xc00003c8; - MIC_BUFF_addr = 0xc000593c; - ble_rx_monitor_addr = 0xc0005908; - link_connect_bak_addr = 0xc00061c8; - llc_env_addr = 0xc0006568; - rwip_rf_addr = 0xc00041b4; - - } - else if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) - { - hci_fc_env_addr = 0xC0006940; - ld_acl_env_addr = 0xc00009d4; - bt_util_buf_env_addr = 0xc0005b24; - em_buf_env_addr = 0xc00066e8; - sniffer_env_addr = 0xc00064d0; - dbg_state_addr = 0xc00059b0; - lc_state_addr = 0xc0005df0; - task_message_buffer_addr = 0xc0000820; - lmp_message_buffer_addr = 0xc0000888; - ld_sco_env_addr = 0xc00009e4; - rx_monitor_addr = 0xc0005a24; - lc_env_addr = 0xc0005de4; - dbg_bt_setting_addr = 0xc0005938; - lm_nb_sync_active_addr = 0xc0000814; - lm_env_addr = 0xc0005c70; - pending_seq_error_link_addr = 0xc000034f; - hci_env_addr = 0xc00068e0; - lc_sco_env_addr = 0xc00007f8; - llm_le_env_addr = 0xc0006568; - ld_env_addr = 0xc0005ea8; - rwip_env_addr = 0xc00003dc; - MIC_BUFF_addr = 0xc0005a48; - g_mem_dump_ctrl_addr = 0xc00059d4; - ble_rx_monitor_addr = 0xc0005a14; - reconnecting_flag_addr = 0xc0000a1c; - link_connect_bak_addr = 0xc00062d0; - tws_link_id_addr = 0xc000034e; - llc_env_addr = 0xc0006670; - dbg_bt_setting_ext1_addr = 0xc000591c; - rwip_rf_addr = 0xc0004268; - - } + } else if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) { + hci_fc_env_addr = 0xC0006940; + ld_acl_env_addr = 0xc00009d4; + bt_util_buf_env_addr = 0xc0005b24; + em_buf_env_addr = 0xc00066e8; + sniffer_env_addr = 0xc00064d0; + dbg_state_addr = 0xc00059b0; + lc_state_addr = 0xc0005df0; + task_message_buffer_addr = 0xc0000820; + lmp_message_buffer_addr = 0xc0000888; + ld_sco_env_addr = 0xc00009e4; + rx_monitor_addr = 0xc0005a24; + lc_env_addr = 0xc0005de4; + dbg_bt_setting_addr = 0xc0005938; + lm_nb_sync_active_addr = 0xc0000814; + lm_env_addr = 0xc0005c70; + pending_seq_error_link_addr = 0xc000034f; + hci_env_addr = 0xc00068e0; + lc_sco_env_addr = 0xc00007f8; + llm_le_env_addr = 0xc0006568; + ld_env_addr = 0xc0005ea8; + rwip_env_addr = 0xc00003dc; + MIC_BUFF_addr = 0xc0005a48; + g_mem_dump_ctrl_addr = 0xc00059d4; + ble_rx_monitor_addr = 0xc0005a14; + reconnecting_flag_addr = 0xc0000a1c; + link_connect_bak_addr = 0xc00062d0; + tws_link_id_addr = 0xc000034e; + llc_env_addr = 0xc0006670; + dbg_bt_setting_ext1_addr = 0xc000591c; + rwip_rf_addr = 0xc0004268; + } } +void bt_drv_reg_op_rssi_set(uint16_t rssi) {} +void bt_drv_reg_op_scan_intv_set(uint32_t scan_intv) {} -void bt_drv_reg_op_rssi_set(uint16_t rssi) -{ +void bt_drv_reg_op_encryptchange_errcode_reset(uint16_t hci_handle) {} + +void bt_drv_reg_op_sco_sniffer_checker(void) {} + +void bt_drv_reg_op_trigger_time_checker(void) { + BT_DRV_REG_OP_ENTER(); + BT_DRV_TRACE(1, "BT_REG_OP:0xd02201f0 = %x", + *(volatile uint32_t *)0xd02201f0); + BT_DRV_REG_OP_EXIT(); } -void bt_drv_reg_op_scan_intv_set(uint32_t scan_intv) -{ -} +void bt_drv_reg_op_tws_output_power_fix_separate(uint16_t hci_handle, + uint16_t pwr) {} -void bt_drv_reg_op_encryptchange_errcode_reset(uint16_t hci_handle) -{ - -} - -void bt_drv_reg_op_sco_sniffer_checker(void) -{ -} - -void bt_drv_reg_op_trigger_time_checker(void) -{ - BT_DRV_REG_OP_ENTER(); - BT_DRV_TRACE(1,"BT_REG_OP:0xd02201f0 = %x",*(volatile uint32_t *)0xd02201f0); - BT_DRV_REG_OP_EXIT(); -} - -void bt_drv_reg_op_tws_output_power_fix_separate(uint16_t hci_handle, uint16_t pwr) -{ -} - -#define SNIFF_IN_SCO 2 -///BD Address structure -struct bd_addr -{ - ///6-byte array address value - uint8_t addr[6]; +#define SNIFF_IN_SCO 2 +/// BD Address structure +struct bd_addr { + /// 6-byte array address value + uint8_t addr[6]; }; -///device info structure -struct ld_device_info -{ - struct bd_addr bd_addr; - uint8_t link_id; - uint8_t state; +/// device info structure +struct ld_device_info { + struct bd_addr bd_addr; + uint8_t link_id; + uint8_t state; }; -bool bt_drv_reg_op_ld_sniffer_env_monitored_dev_state_get(void) -{ - return false; +bool bt_drv_reg_op_ld_sniffer_env_monitored_dev_state_get(void) { + return false; } -void bt_drv_reg_op_ld_sniffer_env_monitored_dev_state_set(bool state) -{ +void bt_drv_reg_op_ld_sniffer_env_monitored_dev_state_set(bool state) {} + +void bt_drv_reg_op_ibrt_env_reset(void) { + struct ld_device_info *mobile_device_info; + BT_DRV_REG_OP_ENTER(); + bool status = false; + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_0) { + mobile_device_info = (struct ld_device_info *)(sniffer_env_addr + 4); + status = true; + } + + if (status) { + mobile_device_info->link_id = 3; + mobile_device_info->state = 0; + } + BT_DRV_REG_OP_EXIT(); } -void bt_drv_reg_op_ibrt_env_reset(void) -{ - struct ld_device_info * mobile_device_info; - BT_DRV_REG_OP_ENTER(); - bool status = false; - if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_0) - { - mobile_device_info = (struct ld_device_info *)(sniffer_env_addr+4); - status = true; - } - - if(status) - { - mobile_device_info->link_id = 3; - mobile_device_info->state = 0; - } - BT_DRV_REG_OP_EXIT(); -} - -int bt_drv_reg_op_currentfreeaclbuf_get(void) -{ - BT_DRV_REG_OP_ENTER(); - //ACL packert number of host set - ACL number of controller has been send to host - //hci_fc_env.host_set.acl_pkt_nb - hci_fc_env.cntr.acl_pkt_sent - if(hci_fc_env_addr != 0) - { - return (*(volatile uint16_t *)(hci_fc_env_addr+0x4) - *(volatile uint16_t *)(hci_fc_env_addr+0xc)); - } - else - { - return 0; - } - BT_DRV_REG_OP_EXIT(); +int bt_drv_reg_op_currentfreeaclbuf_get(void) { + BT_DRV_REG_OP_ENTER(); + // ACL packert number of host set - ACL number of controller has been send to + // host hci_fc_env.host_set.acl_pkt_nb - hci_fc_env.cntr.acl_pkt_sent + if (hci_fc_env_addr != 0) { + return (*(volatile uint16_t *)(hci_fc_env_addr + 0x4) - + *(volatile uint16_t *)(hci_fc_env_addr + 0xc)); + } else { + return 0; + } + BT_DRV_REG_OP_EXIT(); } static uint16_t mobile_sync_info; -void bt_drv_reg_op_save_mobile_airpath_info(uint16_t hciHandle) -{ - BT_DRV_REG_OP_ENTER(); +void bt_drv_reg_op_save_mobile_airpath_info(uint16_t hciHandle) { + BT_DRV_REG_OP_ENTER(); - uint8_t link_id = btdrv_conhdl_to_linkid(hciHandle); + uint8_t link_id = btdrv_conhdl_to_linkid(hciHandle); - if (btdrv_is_link_index_valid(link_id)) - { - mobile_sync_info = BT_DRIVER_GET_U16_REG_VAL(EM_BT_BTADDR1_ADDR + BT_EM_SIZE*link_id); - BT_DRV_TRACE(1,"BT_REG_OP: save xfer mobile sync info 0x%x ", mobile_sync_info); + if (btdrv_is_link_index_valid(link_id)) { + mobile_sync_info = + BT_DRIVER_GET_U16_REG_VAL(EM_BT_BTADDR1_ADDR + BT_EM_SIZE * link_id); + BT_DRV_TRACE(1, "BT_REG_OP: save xfer mobile sync info 0x%x ", + mobile_sync_info); + } + + BT_DRV_REG_OP_EXIT(); +} + +void bt_drv_reg_op_block_xfer_with_mobile(uint16_t hciHandle) { + BT_DRV_REG_OP_ENTER(); + + uint8_t link_id = btdrv_conhdl_to_linkid(hciHandle); + + if (btdrv_is_link_index_valid(link_id)) { + BT_DRIVER_PUT_U16_REG_VAL((EM_BT_BTADDR1_ADDR + BT_EM_SIZE * link_id), + mobile_sync_info ^ 0x8000); + BT_DRV_TRACE(2, + "BT_REG_OP: block xfer with mobile, save hci handle 0x%x sync " + "info as 0x%x", + hciHandle, mobile_sync_info ^ 0x8000); + } + + BT_DRV_REG_OP_EXIT(); +} + +void bt_drv_reg_op_resume_xfer_with_mobile(uint16_t hciHandle) { + BT_DRV_REG_OP_ENTER(); + uint8_t link_id = btdrv_conhdl_to_linkid(hciHandle); + + if (btdrv_is_link_index_valid(link_id)) { + BT_DRIVER_PUT_U16_REG_VAL((EM_BT_BTADDR1_ADDR + BT_EM_SIZE * link_id), + mobile_sync_info); + BT_DRV_TRACE(2, + "BT_REG_OP:resume xfer with mobile, hci handle 0x%x as 0x%x", + hciHandle, mobile_sync_info); + } + + BT_DRV_REG_OP_EXIT(); +} + +void bt_drv_reg_op_block_fast_ack_with_mobile(void) { + /* + * ibrt master set its fast ack sync bit wrong,let itself NACK mobile link + * always + */ + + BT_DRV_REG_OP_ENTER(); + + bt_drv_set_fa_invert_enable(BT_FA_INVERT_DISABLE); + + BT_DRV_REG_OP_EXIT(); +} + +void bt_drv_reg_op_resume_fast_ack_with_mobile(void) { + + /* + * old master recovery its fast ack sync bit right + */ + + BT_DRV_REG_OP_ENTER(); + + bt_drv_set_fa_invert_enable(BT_FA_INVERT_EN); + + BT_DRV_REG_OP_EXIT(); +} + +int bt_drv_reg_op_packet_type_checker(uint16_t hciHandle) { return 0; } + +void bt_drv_reg_op_max_slot_setting_checker(uint16_t hciHandle) {} + +void bt_drv_reg_op_force_task_dbg_idle(void) {} + +void bt_drv_reg_op_afh_follow_mobile_mobileidx_set(uint16_t hciHandle) {} + +void bt_drv_reg_op_afh_follow_mobile_twsidx_set(uint16_t hciHandle) {} + +void bt_drv_reg_op_afh_bak_reset(void) {} + +void bt_drv_reg_op_afh_bak_save(uint8_t role, uint16_t mobileHciHandle) {} + +void bt_drv_reg_op_connection_checker(void) {} + +void bt_drv_reg_op_sco_status_store(void) {} + +void bt_drv_reg_op_sco_status_restore(void) {} + +void bt_drv_reg_op_afh_set_default(void) {} + +void bt_drv_reg_op_ld_sniffer_master_addr_set(uint8_t *addr) {} + +void bt_drv_reg_op_lsto_hack(uint16_t hciHandle, uint16_t lsto) { + uint32_t acl_par_ptr = 0; + // ld_acl_env + + if (ld_acl_env_addr) { + acl_par_ptr = *(uint32_t *)(ld_acl_env_addr + (hciHandle - 0x80) * 4); + } + + if (acl_par_ptr) { + BT_DRV_TRACE(3, + "BT_REG_OP:Set the lsto for hciHandle=0x%x, from:0x%x to 0x%x", + hciHandle, *(uint16_t *)(acl_par_ptr + 154), lsto); + + *(uint16_t *)(acl_par_ptr + 154) = lsto; + } else { + BT_DRV_TRACE(0, "BT_REG_OP:ERROR,acl par address error"); + } +} + +uint16_t bt_drv_reg_op_get_lsto(uint16_t hciHandle) { + uint32_t acl_par_ptr = 0; + uint16_t lsto = 0; + // ld_acl_env + + if (ld_acl_env_addr) { + acl_par_ptr = *(uint32_t *)(ld_acl_env_addr + (hciHandle - 0x80) * 4); + } + + if (acl_par_ptr) { + lsto = *(uint16_t *)(acl_par_ptr + 154); + BT_DRV_TRACE(2, "BT_REG_OP:lsto=0x%x for hciHandle=0x%x", lsto, hciHandle); + } else { + lsto = 0xffff; + BT_DRV_TRACE(0, "BT_REG_OP:ERROR,acl par null ptr"); + } + + return lsto; +} + +uint8_t bt_drv_reg_opmsbc_find_tx_sync(uint8_t *buff) { + BT_DRV_REG_OP_ENTER(); + + uint8_t i; + for (i = 0; i < 60; i++) { + if (buff[i] == 0x1 && buff[(i + 2) % 60] == 0xad) { + // BT_DRV_TRACE(1,"MSBC tx sync find =%d",i); + return i; } + } + BT_DRV_TRACE(0, "BT_REG_OP:TX No pACKET"); - BT_DRV_REG_OP_EXIT(); + BT_DRV_REG_OP_EXIT(); + return 0; } -void bt_drv_reg_op_block_xfer_with_mobile(uint16_t hciHandle) -{ - BT_DRV_REG_OP_ENTER(); +bool bt_drv_reg_op_sco_tx_buf_restore(uint8_t *trigger_test) { + uint8_t offset; + bool nRet = false; - uint8_t link_id = btdrv_conhdl_to_linkid(hciHandle); + BT_DRV_REG_OP_ENTER(); - if (btdrv_is_link_index_valid(link_id)) - { - BT_DRIVER_PUT_U16_REG_VAL((EM_BT_BTADDR1_ADDR + BT_EM_SIZE*link_id), mobile_sync_info^0x8000); - BT_DRV_TRACE(2,"BT_REG_OP: block xfer with mobile, save hci handle 0x%x sync info as 0x%x", hciHandle, mobile_sync_info^0x8000); - } - - BT_DRV_REG_OP_EXIT(); -} - -void bt_drv_reg_op_resume_xfer_with_mobile(uint16_t hciHandle) -{ - BT_DRV_REG_OP_ENTER(); - uint8_t link_id = btdrv_conhdl_to_linkid(hciHandle); - - if (btdrv_is_link_index_valid(link_id)) - { - BT_DRIVER_PUT_U16_REG_VAL((EM_BT_BTADDR1_ADDR + BT_EM_SIZE*link_id), mobile_sync_info); - BT_DRV_TRACE(2,"BT_REG_OP:resume xfer with mobile, hci handle 0x%x as 0x%x", hciHandle, mobile_sync_info); - } - - BT_DRV_REG_OP_EXIT(); -} - -void bt_drv_reg_op_block_fast_ack_with_mobile(void) -{ - /* - * ibrt master set its fast ack sync bit wrong,let itself NACK mobile link always - */ - - BT_DRV_REG_OP_ENTER(); - - bt_drv_set_fa_invert_enable(BT_FA_INVERT_DISABLE); - - BT_DRV_REG_OP_EXIT(); -} - -void bt_drv_reg_op_resume_fast_ack_with_mobile(void) -{ - - /* - * old master recovery its fast ack sync bit right - */ - - BT_DRV_REG_OP_ENTER(); - - bt_drv_set_fa_invert_enable(BT_FA_INVERT_EN); - - BT_DRV_REG_OP_EXIT(); -} - -int bt_drv_reg_op_packet_type_checker(uint16_t hciHandle) -{ - return 0; -} - -void bt_drv_reg_op_max_slot_setting_checker(uint16_t hciHandle) -{} - -void bt_drv_reg_op_force_task_dbg_idle(void) -{ -} - -void bt_drv_reg_op_afh_follow_mobile_mobileidx_set(uint16_t hciHandle) -{} - - -void bt_drv_reg_op_afh_follow_mobile_twsidx_set(uint16_t hciHandle) -{} - -void bt_drv_reg_op_afh_bak_reset(void) -{} - -void bt_drv_reg_op_afh_bak_save(uint8_t role, uint16_t mobileHciHandle) -{} - -void bt_drv_reg_op_connection_checker(void) -{} - -void bt_drv_reg_op_sco_status_store(void) -{} - -void bt_drv_reg_op_sco_status_restore(void) -{} - -void bt_drv_reg_op_afh_set_default(void) -{ -} - -void bt_drv_reg_op_ld_sniffer_master_addr_set(uint8_t * addr) -{ -} - -void bt_drv_reg_op_lsto_hack(uint16_t hciHandle, uint16_t lsto) -{ - uint32_t acl_par_ptr = 0; - //ld_acl_env - - if(ld_acl_env_addr) - { - acl_par_ptr = *(uint32_t *)(ld_acl_env_addr+(hciHandle-0x80)*4); - } - - if(acl_par_ptr) - { - BT_DRV_TRACE(3,"BT_REG_OP:Set the lsto for hciHandle=0x%x, from:0x%x to 0x%x", - hciHandle,*(uint16_t *)(acl_par_ptr+154),lsto); - - *(uint16_t *)(acl_par_ptr+154) = lsto; - } - else - { - BT_DRV_TRACE(0,"BT_REG_OP:ERROR,acl par address error"); - } -} - -uint16_t bt_drv_reg_op_get_lsto(uint16_t hciHandle) -{ - uint32_t acl_par_ptr = 0; - uint16_t lsto = 0; - //ld_acl_env - - if(ld_acl_env_addr) - { - acl_par_ptr = *(uint32_t *)(ld_acl_env_addr+(hciHandle-0x80)*4); - } - - - if(acl_par_ptr) - { - lsto = *(uint16_t *)(acl_par_ptr+154) ; - BT_DRV_TRACE(2,"BT_REG_OP:lsto=0x%x for hciHandle=0x%x",lsto,hciHandle); - } - else - { - lsto= 0xffff; - BT_DRV_TRACE(0,"BT_REG_OP:ERROR,acl par null ptr"); - } - - return lsto; -} - -uint8_t bt_drv_reg_opmsbc_find_tx_sync(uint8_t *buff) -{ - BT_DRV_REG_OP_ENTER(); - - uint8_t i; - for(i=0; i<60; i++) - { - if(buff[i]==0x1 && buff[(i+2)%60] == 0xad) - { - // BT_DRV_TRACE(1,"MSBC tx sync find =%d",i); - return i; - } - } - BT_DRV_TRACE(0,"BT_REG_OP:TX No pACKET"); - - BT_DRV_REG_OP_EXIT(); - return 0; -} - -bool bt_drv_reg_op_sco_tx_buf_restore(uint8_t *trigger_test) -{ - uint8_t offset; - bool nRet = false; - - BT_DRV_REG_OP_ENTER(); - - offset = bt_drv_reg_opmsbc_find_tx_sync((uint8_t *)EM_BT_AUDIOBUF_OFF); - if(offset !=0) - { + offset = bt_drv_reg_opmsbc_find_tx_sync((uint8_t *)EM_BT_AUDIOBUF_OFF); + if (offset != 0) { #ifndef APB_PCM - *trigger_test = (((BTDIGITAL_REG(0xd022045c) & 0x3f)) +(60-offset))%64; + *trigger_test = (((BTDIGITAL_REG(0xd022045c) & 0x3f)) + (60 - offset)) % 64; #endif - BT_DRV_TRACE(2,"BT_REG_OP:TX BUF ERROR trigger_test=%p,offset=%x", trigger_test,offset); - DUMP8("%02x ",(uint8_t *)EM_BT_AUDIOBUF_OFF,10); -// BT_DRV_TRACE(2,"pcm reg=%x %x",*(uint32_t *)0xd0220468,*(uint32_t *)0x400000f0); - nRet = true; - } + BT_DRV_TRACE(2, "BT_REG_OP:TX BUF ERROR trigger_test=%p,offset=%x", + trigger_test, offset); + DUMP8("%02x ", (uint8_t *)EM_BT_AUDIOBUF_OFF, 10); + // BT_DRV_TRACE(2,"pcm reg=%x %x",*(uint32_t *)0xd0220468,*(uint32_t + // *)0x400000f0); + nRet = true; + } - BT_DRV_REG_OP_EXIT(); + BT_DRV_REG_OP_EXIT(); - return nRet; + return nRet; } -int bt_drv_reg_op_acl_chnmap(uint16_t hciHandle, uint8_t *chnmap, uint8_t chnmap_len) -{ - uint32_t acl_evt_ptr = 0; - uint8_t *chnmap_ptr = 0; - uint8_t link_id = btdrv_conhdl_to_linkid(hciHandle); +int bt_drv_reg_op_acl_chnmap(uint16_t hciHandle, uint8_t *chnmap, + uint8_t chnmap_len) { + uint32_t acl_evt_ptr = 0; + uint8_t *chnmap_ptr = 0; + uint8_t link_id = btdrv_conhdl_to_linkid(hciHandle); - if (!btdrv_is_link_index_valid(link_id)) - { - memset(chnmap, 0, chnmap_len); - return -1; - } - if (chnmap_len < 10) - { - memset(chnmap, 0, chnmap_len); - return -1; - } + if (!btdrv_is_link_index_valid(link_id)) { + memset(chnmap, 0, chnmap_len); + return -1; + } + if (chnmap_len < 10) { + memset(chnmap, 0, chnmap_len); + return -1; + } + if (ld_acl_env_addr) { + acl_evt_ptr = *(volatile uint32_t *)(ld_acl_env_addr + link_id * 4); + } - if(ld_acl_env_addr) - { - acl_evt_ptr = *(volatile uint32_t *)(ld_acl_env_addr+link_id*4); - } + if (acl_evt_ptr != 0) { + chnmap_ptr = (uint8_t *)(acl_evt_ptr + 0x34); + } + if (!chnmap_ptr) { + memset(chnmap, 0, chnmap_len); + return -1; + } else { + memcpy(chnmap, chnmap_ptr, chnmap_len); + } - if(acl_evt_ptr != 0) - { - chnmap_ptr = (uint8_t *)(acl_evt_ptr+0x34); - } - - if (!chnmap_ptr) - { - memset(chnmap, 0, chnmap_len); - return -1; - } - else - { - memcpy(chnmap, chnmap_ptr, chnmap_len); - } - - return 0; + return 0; } extern "C" uint32_t hci_current_left_tx_packets_left(void); extern "C" uint32_t hci_current_left_rx_packets_left(void); extern "C" uint32_t hci_current_rx_packet_complete(void); extern "C" uint8_t hci_current_rx_aclfreelist_cnt(void); -void bt_drv_reg_op_bt_info_checker(void) -{ +void bt_drv_reg_op_bt_info_checker(void) { #ifdef __CLK_GATE_DISABLE__ - uint32_t *rx_buf_ptr=NULL; - uint32_t *tx_buf_ptr=NULL; - uint8_t rx_free_buf_count=0, i=0; - uint8_t tx_free_buf_count=0; - uint16_t em_buf ; + uint32_t *rx_buf_ptr = NULL; + uint32_t *tx_buf_ptr = NULL; + uint8_t rx_free_buf_count = 0, i = 0; + uint8_t tx_free_buf_count = 0; + uint16_t em_buf; - BT_DRV_REG_OP_ENTER(); + BT_DRV_REG_OP_ENTER(); - if(bt_util_buf_env_addr) - { - rx_buf_ptr = (uint32_t *)(bt_util_buf_env_addr+0x14); //bt_util_buf_env.acl_rx_free - tx_buf_ptr = (uint32_t *)(bt_util_buf_env_addr+0x28); //bt_util_buf_env.acl_tx_free + if (bt_util_buf_env_addr) { + rx_buf_ptr = (uint32_t *)(bt_util_buf_env_addr + + 0x14); // bt_util_buf_env.acl_rx_free + tx_buf_ptr = (uint32_t *)(bt_util_buf_env_addr + + 0x28); // bt_util_buf_env.acl_tx_free + } - } + while (rx_buf_ptr && *rx_buf_ptr) { + rx_free_buf_count++; + rx_buf_ptr = (uint32_t *)(*rx_buf_ptr); + } - while(rx_buf_ptr && *rx_buf_ptr) - { - rx_free_buf_count++; - rx_buf_ptr = (uint32_t *)(*rx_buf_ptr); - } + uint8_t em_buf_count = 0; + for (i = 0; i < 4; i++) { + em_buf = BT_DRIVER_GET_U16_REG_VAL(EM_BT_RXACLBUFPTR_ADDR + + i * REG_EM_BT_RXDESC_SIZE); + if (em_buf != 0) + em_buf_count++; + } + BT_DRV_TRACE( + 4, + "BT_REG_OP: rxbuff = %x,embuff =%x , host rx buff in controller = %x,%x", + rx_free_buf_count, em_buf_count, hci_current_left_rx_packets_left(), + bt_drv_reg_op_currentfreeaclbuf_get()); - uint8_t em_buf_count = 0; - for(i=0; i<4; i++) - { - em_buf = BT_DRIVER_GET_U16_REG_VAL(EM_BT_RXACLBUFPTR_ADDR + i*REG_EM_BT_RXDESC_SIZE); - if(em_buf != 0) - em_buf_count++; - } - BT_DRV_TRACE(4,"BT_REG_OP: rxbuff = %x,embuff =%x , host rx buff in controller = %x,%x", \ - rx_free_buf_count, \ - em_buf_count, \ - hci_current_left_rx_packets_left(), \ - bt_drv_reg_op_currentfreeaclbuf_get()); + // check tx buff + while (tx_buf_ptr && *tx_buf_ptr) { + tx_free_buf_count++; + tx_buf_ptr = (uint32_t *)(*tx_buf_ptr); + } - //check tx buff - while(tx_buf_ptr && *tx_buf_ptr) - { - tx_free_buf_count++; - tx_buf_ptr = (uint32_t *)(*tx_buf_ptr); - } + BT_DRV_TRACE(2, "BT_REG_OP:txbuff = %x,acl tx host in controller = %x ", + tx_free_buf_count, hci_current_left_tx_packets_left()); - BT_DRV_TRACE(2,"BT_REG_OP:txbuff = %x,acl tx host in controller = %x ", \ - tx_free_buf_count, \ - hci_current_left_tx_packets_left()); - - bt_drv_reg_op_controller_state_checker(); - BT_DRV_REG_OP_EXIT(); + bt_drv_reg_op_controller_state_checker(); + BT_DRV_REG_OP_EXIT(); #endif } @@ -556,1285 +482,1168 @@ uint16_t *send_count; uint16_t *free_count; uint16_t *bt_send_count; #endif -void bt_drv_reg_op_ble_buffer_cleanup(void) -{ -} +void bt_drv_reg_op_ble_buffer_cleanup(void) {} -struct ke_timer -{ - /// next ke timer - struct ke_timer *next; - /// message identifier - uint16_t id; - /// task identifier - uint16_t task; - /// time value - uint32_t time; +struct ke_timer { + /// next ke timer + struct ke_timer *next; + /// message identifier + uint16_t id; + /// task identifier + uint16_t task; + /// time value + uint32_t time; }; -struct co_list_hdr -{ - /// Pointer to next co_list_hdr - struct co_list_hdr *next; +struct co_list_hdr { + /// Pointer to next co_list_hdr + struct co_list_hdr *next; }; /// structure of a list -struct co_list_con -{ - /// pointer to first element of the list - struct co_list_hdr *first; - /// pointer to the last element - struct co_list_hdr *last; +struct co_list_con { + /// pointer to first element of the list + struct co_list_hdr *first; + /// pointer to the last element + struct co_list_hdr *last; - /// number of element in the list - uint32_t cnt; - /// max number of element in the list - uint32_t maxcnt; - /// min number of element in the list - uint32_t mincnt; + /// number of element in the list + uint32_t cnt; + /// max number of element in the list + uint32_t maxcnt; + /// min number of element in the list + uint32_t mincnt; }; -struct mblock_free -{ - /// Next free block pointer - struct mblock_free* next; - /// Previous free block pointer - struct mblock_free* previous; - /// Size of the current free block (including delimiter) - uint16_t free_size; - /// Used to check if memory block has been corrupted or not - uint16_t corrupt_check; +struct mblock_free { + /// Next free block pointer + struct mblock_free *next; + /// Previous free block pointer + struct mblock_free *previous; + /// Size of the current free block (including delimiter) + uint16_t free_size; + /// Used to check if memory block has been corrupted or not + uint16_t corrupt_check; }; -bool bt_drv_reg_op_get_dbg_state(void) -{ - //dbg_state +bool bt_drv_reg_op_get_dbg_state(void) { + // dbg_state - if(dbg_state_addr) - { - return (*(uint8_t *)dbg_state_addr); - } - else - { - return false; - } + if (dbg_state_addr) { + return (*(uint8_t *)dbg_state_addr); + } else { + return false; + } } -uint8_t bt_drv_reg_op_get_controller_tx_free_buffer(void) -{ - uint32_t *tx_buf_ptr=NULL; - uint8_t tx_free_buf_count=0; +uint8_t bt_drv_reg_op_get_controller_tx_free_buffer(void) { + uint32_t *tx_buf_ptr = NULL; + uint8_t tx_free_buf_count = 0; - if(bt_util_buf_env_addr) - { - tx_buf_ptr = (uint32_t *)(bt_util_buf_env_addr+0x28); //bt_util_buf_env.acl_tx_free - } - else - { - BT_DRV_TRACE(1, "REG_OP: please fix %s", __func__); - return 0; - } - - //check tx buff - while(tx_buf_ptr && *tx_buf_ptr) - { - tx_free_buf_count++; - tx_buf_ptr = (uint32_t *)(*tx_buf_ptr); - } - return tx_free_buf_count; -} - -uint8_t bt_drv_reg_op_get_controller_ble_tx_free_buffer(void) -{ - uint32_t *tx_buf_ptr=NULL; - uint8_t tx_free_buf_count=0; - - if(em_buf_env_addr) - { - tx_buf_ptr = (uint32_t *)(em_buf_env_addr+0x14); //em_buf_env.tx_buff_free - } - else - { - BT_DRV_TRACE(1, "REG_OP: please fix %s", __func__); - return 0; - } - - //check tx buff - while(tx_buf_ptr && *tx_buf_ptr) - { - tx_free_buf_count++; - tx_buf_ptr = (uint32_t *)(*tx_buf_ptr); - } - - return tx_free_buf_count; -} - -void bt_drv_reg_op_controller_state_checker(void) -{ - BT_DRV_REG_OP_ENTER(); - - if(lc_state_addr != 0) - { - BT_DRV_TRACE(1,"BT_REG_OP: LC_STATE=0x%x",*(uint32_t *)lc_state_addr); - } - BT_DRV_REG_OP_EXIT(); -} - -void bt_drv_reg_op_tx_flow_checker(void) -{ - BT_DRV_REG_OP_ENTER(); - uint8_t link_id = 0; - uint32_t acl_par_ptr = 0; - for(link_id=0; link_id<3; link_id++) - { - if(ld_acl_env_addr) - { - acl_par_ptr = *(volatile uint32_t *)(ld_acl_env_addr+link_id*4); - } - - if (acl_par_ptr) - { - BT_DRV_TRACE(2,"linkid =%d, tx flow=%d",link_id, *(uint8_t *)(acl_par_ptr+0xc0)); - } - } - BT_DRV_REG_OP_EXIT(); -} - -void bt_drv_reg_op_controller_ble_flow_checker(void) -{ - uint8_t link_id = 0; - uint32_t llc_env_tag_ptr = 0; - uint32_t ea_elt_tag_ptr = 0; - uint32_t *tx_acl_rdy_ptr = NULL; - uint32_t *tx_acl_tofree_ptr = NULL; - uint32_t tx_acl_rdy_count = 0; - uint32_t tx_acl_tofree_count = 0; - - if(!llc_env_addr) - { - BT_DRV_TRACE(1, "REG_OP: please fix %s", __func__); - return; - } - - for (link_id = 0; link_id < 3; link_id += 1) - { - llc_env_tag_ptr = *(volatile uint32_t *)(llc_env_addr + link_id * 4); - if (!llc_env_tag_ptr) - { - continue; - } - - ea_elt_tag_ptr = *(volatile uint32_t *)(((uint32_t)llc_env_tag_ptr) + 16); - if (!ea_elt_tag_ptr) - { - continue; - } - - tx_acl_rdy_ptr = (uint32_t *)(((uint32_t)ea_elt_tag_ptr) + 48); - tx_acl_rdy_count = 0; - while(tx_acl_rdy_ptr && *tx_acl_rdy_ptr) - { - tx_acl_rdy_count++; - tx_acl_rdy_ptr = (uint32_t *)(*tx_acl_rdy_ptr); - } - - tx_acl_tofree_ptr = (uint32_t *)(((uint32_t)ea_elt_tag_ptr) + 68); - tx_acl_tofree_count = 0; - while(tx_acl_tofree_ptr && *tx_acl_tofree_ptr) - { - tx_acl_tofree_count++; - tx_acl_tofree_ptr = (uint32_t *)(*tx_acl_tofree_ptr); - } - - BT_DRV_TRACE(3, "linkid =%d, ble tx alloc=%d tofree=%d", link_id, tx_acl_rdy_count, tx_acl_tofree_count); - } -} - -uint8_t bt_drv_reg_op_force_get_lc_state(uint16_t conhdl) -{ - if(lc_state_addr != 0) - { - //BT_DRV_TRACE(1,"BT_REG_OP: read LC_STATE=0x%x",*(uint32_t *)lc_state_addr); - uint8_t idx = btdrv_conhdl_to_linkid(conhdl); - - if (btdrv_is_link_index_valid(idx)) - { - uint8_t * lc_state = (uint8_t *)lc_state_addr; - return lc_state[idx]; - } - } + if (bt_util_buf_env_addr) { + tx_buf_ptr = (uint32_t *)(bt_util_buf_env_addr + + 0x28); // bt_util_buf_env.acl_tx_free + } else { + BT_DRV_TRACE(1, "REG_OP: please fix %s", __func__); return 0; -} -void bt_drv_reg_op_force_set_lc_state(uint16_t conhdl, uint8_t state) -{ - //lc_state + } - if(lc_state_addr != 0) - { - BT_DRV_TRACE(1,"BT_REG_OP: read LC_STATE=0x%x",*(uint32_t *)lc_state_addr); - uint8_t idx = btdrv_conhdl_to_linkid(conhdl); - - if (btdrv_is_link_index_valid(idx)) - { - uint8_t * lc_state = (uint8_t *)lc_state_addr; - lc_state[idx] = state; - } - } + // check tx buff + while (tx_buf_ptr && *tx_buf_ptr) { + tx_free_buf_count++; + tx_buf_ptr = (uint32_t *)(*tx_buf_ptr); + } + return tx_free_buf_count; } -void bt_drv_reg_op_crash_dump(void) -{ - if(hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_0) - { - uint8_t *bt_dump_mem_start = (uint8_t*)bt_ram_start_addr; - uint32_t bt_dump_len_max = 0x8000; +uint8_t bt_drv_reg_op_get_controller_ble_tx_free_buffer(void) { + uint32_t *tx_buf_ptr = NULL; + uint8_t tx_free_buf_count = 0; - //uint8_t *mcu_dump_mem_start = (uint8_t*)0x20000000; - //uint32_t mcu_dump_len_max = RAM_SIZE; + if (em_buf_env_addr) { + tx_buf_ptr = + (uint32_t *)(em_buf_env_addr + 0x14); // em_buf_env.tx_buff_free + } else { + BT_DRV_TRACE(1, "REG_OP: please fix %s", __func__); + return 0; + } - //uint8_t *em_dump_area_1_start = (uint8_t*)0xd0220000; - //uint32_t em_area_1_len_max = 0x04A8; + // check tx buff + while (tx_buf_ptr && *tx_buf_ptr) { + tx_free_buf_count++; + tx_buf_ptr = (uint32_t *)(*tx_buf_ptr); + } - uint8_t *em_dump_area_2_start = (uint8_t*)0xd0210000; - uint32_t em_area_2_len_max = 0x8000; - - BT_DRV_TRACE(1,"BT_REG_OP:BT 2300p: metal id=%d", hal_get_chip_metal_id()); - //first move R3 to R9, lost R9 - BT_DRV_TRACE(1,"BT controller BusFault_Handler:\nREG:[LR] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE)); - BT_DRV_TRACE(1,"REG:[R0] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +120)); - BT_DRV_TRACE(1,"REG:[R1] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +124)); - BT_DRV_TRACE(1,"REG:[R2] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +128)); - BT_DRV_TRACE(1,"REG:[R3] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +132)); - BT_DRV_TRACE(1,"REG:[R4] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +4)); - BT_DRV_TRACE(1,"REG:[R5] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +8)); - BT_DRV_TRACE(1,"REG:[R6] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +12)); - BT_DRV_TRACE(1,"REG:[R7] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +16)); - BT_DRV_TRACE(1,"REG:[R8] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +20)); - hal_sys_timer_delay(MS_TO_TICKS(100)); - - //BT_DRV_TRACE(1,"REG:[R9] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +24)); - BT_DRV_TRACE(1,"REG:[sl] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +28)); - BT_DRV_TRACE(1,"REG:[fp] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +32)); - BT_DRV_TRACE(1,"REG:[ip] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +36)); - BT_DRV_TRACE(1,"REG:[SP,#0] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +40)); - BT_DRV_TRACE(1,"REG:[SP,#4] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +44)); - BT_DRV_TRACE(1,"REG:[SP,#8] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +48)); - BT_DRV_TRACE(1,"REG:[SP,#12] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +52)); - BT_DRV_TRACE(1,"REG:[SP,#16] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +56)); - BT_DRV_TRACE(1,"REG:[SP,#20] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +60)); - BT_DRV_TRACE(1,"REG:[SP,#24] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +64)); - BT_DRV_TRACE(1,"REG:[SP,#28] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +68)); - hal_sys_timer_delay(MS_TO_TICKS(100)); - - BT_DRV_TRACE(1,"REG:[SP,#32] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +72)); - BT_DRV_TRACE(1,"REG:[SP,#36] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +76)); - BT_DRV_TRACE(1,"REG:[SP,#40] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +80)); - BT_DRV_TRACE(1,"REG:[SP,#44] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +84)); - BT_DRV_TRACE(1,"REG:[SP,#48] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +88)); - BT_DRV_TRACE(1,"REG:[SP,#52] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +92)); - BT_DRV_TRACE(1,"REG:[SP,#56] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +96)); - BT_DRV_TRACE(1,"REG:[SP,#60] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +100)); - BT_DRV_TRACE(1,"REG:[SP,#64] = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +104)); - BT_DRV_TRACE(1,"REG:SP = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +108)); - BT_DRV_TRACE(1,"REG:MSP = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +112)); - BT_DRV_TRACE(1,"REG:PSP = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +116)); - BT_DRV_TRACE(1,"REG:CFSR = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +120)); - BT_DRV_TRACE(1,"REG:BFAR = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +124)); - BT_DRV_TRACE(1,"REG:HFSR = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +128)); - BT_DRV_TRACE(1,"REG:ICSR = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +132)); - BT_DRV_TRACE(1,"REG:AIRCR = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +136)); - BT_DRV_TRACE(1,"REG:SCR = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +140)); - BT_DRV_TRACE(1,"REG:CCR = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +144)); - BT_DRV_TRACE(1,"REG:SHCSR = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +148)); - BT_DRV_TRACE(1,"REG:AFSR = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +152)); - BT_DRV_TRACE(1,"REG:MMFAR = 0x%08x", BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +156)); - hal_sys_timer_delay(MS_TO_TICKS(100)); - //task_message_buffer - uint32_t buff_addr = 0; - - if(task_message_buffer_addr) - { - buff_addr = task_message_buffer_addr; - } - - BT_DRV_TRACE(2,"0xd0330050: 0x%x, 54:0x%x",*(uint32_t *)0xd0330050,*(uint32_t *)0xd0330054); - BT_DRV_TRACE(2,"0x400000a0: 0x%x, a4:0x%x",*(uint32_t *)0x400000a0,*(uint32_t *)0x400000a4); - - if(g_mem_dump_ctrl_addr) - { - BT_DRV_TRACE(1,"LMP addr=0x%x",*(uint32_t *)(g_mem_dump_ctrl_addr+4)); - BT_DRV_TRACE(1,"STA addr=0x%x",*(uint32_t *)(g_mem_dump_ctrl_addr+0x10)); - BT_DRV_TRACE(1,"MSG addr=0x%x",*(uint32_t *)(g_mem_dump_ctrl_addr+0x1c)); - BT_DRV_TRACE(1,"SCH addr=0x%x",*(uint32_t *)(g_mem_dump_ctrl_addr+0x28)); - BT_DRV_TRACE(1,"ISR addr=0x%x",*(uint32_t *)(g_mem_dump_ctrl_addr+0x34)); - } - - BT_DRV_TRACE(0,"task msg buff:"); - if(buff_addr != 0) - { - for(uint8_t j=0; j<5; j++) - { - DUMP8("%02x ", (uint8_t *)(buff_addr+j*20), 20); - } - } - hal_sys_timer_delay(MS_TO_TICKS(100)); - - BT_DRV_TRACE(0," "); - BT_DRV_TRACE(0,"lmp buff:"); - //lmp_message_buffer - - if(lmp_message_buffer_addr) - { - buff_addr = lmp_message_buffer_addr; - } - - if(buff_addr != 0) - { - for(uint8_t j=0; j<10; j++) - { - DUMP8("%02x ",(uint8_t *)(buff_addr+j*20), 20); - } - } - hal_sys_timer_delay(MS_TO_TICKS(100)); - - uint8_t link_id = 0; - uint32_t evt_ptr = 0; - uint32_t acl_par_ptr = 0; - for(link_id=0; link_id<3; link_id++) - { - BT_DRV_TRACE(1,"acl_par: link id %d",link_id); - - if(ld_acl_env_addr) - { - evt_ptr = *(uint32_t *)(ld_acl_env_addr+link_id*4); - } - - - if (evt_ptr) - { - acl_par_ptr = evt_ptr; - BT_DRV_TRACE(5,"acl_par: acl_par_ptr 0x%x, clk off 0x%x, bit off 0x%x, last sync clk off 0x%x, last sync bit off 0x%x", - acl_par_ptr, *(uint32_t *)(acl_par_ptr+140),*(uint16_t *)(acl_par_ptr+150), - *(uint32_t *)(acl_par_ptr+136),((*(uint32_t *)(acl_par_ptr+150))&0xFFFF0000)>>16); - } - } - hal_sys_timer_delay(MS_TO_TICKS(100)); - - //ld_sco_env - evt_ptr = 0; - - if(ld_sco_env_addr) - { - evt_ptr = *(uint32_t *)ld_sco_env_addr; - } - - if(evt_ptr != 0) - { - BT_DRV_TRACE(1,"esco linkid :%d",*(uint8_t *)(evt_ptr+70)); - for(link_id=0; link_id<3; link_id++) - { - BT_DRV_TRACE(2,"bt_linkcntl_linklbl 0x%x: link id %d",*(uint16_t *)(EM_BT_LINKCNTL_ADDR+link_id*BT_EM_SIZE),link_id); - BT_DRV_TRACE(1,"rxcount :%x",*(uint16_t *)(EM_BT_RXDESCCNT_ADDR+link_id*BT_EM_SIZE)); - } - } - btdrv_dump_mem(bt_dump_mem_start, bt_dump_len_max, BT_SUB_SYS_TYPE); - //btdrv_dump_mem(em_dump_area_1_start, em_area_1_len_max, BT_EM_AREA_1_TYPE); - btdrv_dump_mem(em_dump_area_2_start, em_area_2_len_max, BT_EM_AREA_2_TYPE); - //btdrv_dump_mem(mcu_dump_mem_start, mcu_dump_len_max, MCU_SYS_TYPE); - } + return tx_free_buf_count; } -uint8_t bt_drv_reg_op_get_tx_pwr(uint16_t connHandle) -{ - uint8_t idx; - uint16_t localVal; - uint8_t tx_pwr = 0; +void bt_drv_reg_op_controller_state_checker(void) { + BT_DRV_REG_OP_ENTER(); - idx = btdrv_conhdl_to_linkid(connHandle); + if (lc_state_addr != 0) { + BT_DRV_TRACE(1, "BT_REG_OP: LC_STATE=0x%x", *(uint32_t *)lc_state_addr); + } + BT_DRV_REG_OP_EXIT(); +} - if (btdrv_is_link_index_valid(idx)) - { - localVal = BT_DRIVER_GET_U16_REG_VAL(EM_BT_PWRCNTL_ADDR + idx * BT_EM_SIZE); - tx_pwr = ((localVal & ((uint16_t)0x000000FF)) >> 0); +void bt_drv_reg_op_tx_flow_checker(void) { + BT_DRV_REG_OP_ENTER(); + uint8_t link_id = 0; + uint32_t acl_par_ptr = 0; + for (link_id = 0; link_id < 3; link_id++) { + if (ld_acl_env_addr) { + acl_par_ptr = *(volatile uint32_t *)(ld_acl_env_addr + link_id * 4); } - return tx_pwr; + if (acl_par_ptr) { + BT_DRV_TRACE(2, "linkid =%d, tx flow=%d", link_id, + *(uint8_t *)(acl_par_ptr + 0xc0)); + } + } + BT_DRV_REG_OP_EXIT(); } -void bt_drv_reg_op_set_tx_pwr(uint16_t connHandle, uint8_t txpwr) -{ - BT_DRV_REG_OP_ENTER(); +void bt_drv_reg_op_controller_ble_flow_checker(void) { + uint8_t link_id = 0; + uint32_t llc_env_tag_ptr = 0; + uint32_t ea_elt_tag_ptr = 0; + uint32_t *tx_acl_rdy_ptr = NULL; + uint32_t *tx_acl_tofree_ptr = NULL; + uint32_t tx_acl_rdy_count = 0; + uint32_t tx_acl_tofree_count = 0; - uint8_t idx = btdrv_conhdl_to_linkid(connHandle); + if (!llc_env_addr) { + BT_DRV_TRACE(1, "REG_OP: please fix %s", __func__); + return; + } - if (btdrv_is_link_index_valid(idx)) - { - BT_DRIVER_PUT_U16_REG_VAL(EM_BT_PWRCNTL_ADDR + idx * BT_EM_SIZE, - (BT_DRIVER_GET_U16_REG_VAL(EM_BT_PWRCNTL_ADDR + idx * BT_EM_SIZE) & ~((uint16_t)0x000000FF)) | ((uint16_t)txpwr << 0)); + for (link_id = 0; link_id < 3; link_id += 1) { + llc_env_tag_ptr = *(volatile uint32_t *)(llc_env_addr + link_id * 4); + if (!llc_env_tag_ptr) { + continue; } - BT_DRV_REG_OP_EXIT(); + ea_elt_tag_ptr = *(volatile uint32_t *)(((uint32_t)llc_env_tag_ptr) + 16); + if (!ea_elt_tag_ptr) { + continue; + } + + tx_acl_rdy_ptr = (uint32_t *)(((uint32_t)ea_elt_tag_ptr) + 48); + tx_acl_rdy_count = 0; + while (tx_acl_rdy_ptr && *tx_acl_rdy_ptr) { + tx_acl_rdy_count++; + tx_acl_rdy_ptr = (uint32_t *)(*tx_acl_rdy_ptr); + } + + tx_acl_tofree_ptr = (uint32_t *)(((uint32_t)ea_elt_tag_ptr) + 68); + tx_acl_tofree_count = 0; + while (tx_acl_tofree_ptr && *tx_acl_tofree_ptr) { + tx_acl_tofree_count++; + tx_acl_tofree_ptr = (uint32_t *)(*tx_acl_tofree_ptr); + } + + BT_DRV_TRACE(3, "linkid =%d, ble tx alloc=%d tofree=%d", link_id, + tx_acl_rdy_count, tx_acl_tofree_count); + } } -void bt_drv_reg_op_fix_tx_pwr(uint16_t connHandle) -{ - BT_DRV_REG_OP_ENTER(); - bt_drv_reg_op_set_tx_pwr(connHandle, LBRT_TX_PWR_FIX); - BT_DRV_REG_OP_EXIT(); +uint8_t bt_drv_reg_op_force_get_lc_state(uint16_t conhdl) { + if (lc_state_addr != 0) { + // BT_DRV_TRACE(1,"BT_REG_OP: read LC_STATE=0x%x",*(uint32_t + // *)lc_state_addr); + uint8_t idx = btdrv_conhdl_to_linkid(conhdl); + + if (btdrv_is_link_index_valid(idx)) { + uint8_t *lc_state = (uint8_t *)lc_state_addr; + return lc_state[idx]; + } + } + return 0; +} +void bt_drv_reg_op_force_set_lc_state(uint16_t conhdl, uint8_t state) { + // lc_state + + if (lc_state_addr != 0) { + BT_DRV_TRACE(1, "BT_REG_OP: read LC_STATE=0x%x", + *(uint32_t *)lc_state_addr); + uint8_t idx = btdrv_conhdl_to_linkid(conhdl); + + if (btdrv_is_link_index_valid(idx)) { + uint8_t *lc_state = (uint8_t *)lc_state_addr; + lc_state[idx] = state; + } + } +} + +void bt_drv_reg_op_crash_dump(void) { + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_0) { + uint8_t *bt_dump_mem_start = (uint8_t *)bt_ram_start_addr; + uint32_t bt_dump_len_max = 0x8000; + + // uint8_t *mcu_dump_mem_start = (uint8_t*)0x20000000; + // uint32_t mcu_dump_len_max = RAM_SIZE; + + // uint8_t *em_dump_area_1_start = (uint8_t*)0xd0220000; + // uint32_t em_area_1_len_max = 0x04A8; + + uint8_t *em_dump_area_2_start = (uint8_t *)0xd0210000; + uint32_t em_area_2_len_max = 0x8000; + + BT_DRV_TRACE(1, "BT_REG_OP:BT 2300p: metal id=%d", hal_get_chip_metal_id()); + // first move R3 to R9, lost R9 + BT_DRV_TRACE(1, "BT controller BusFault_Handler:\nREG:[LR] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE)); + BT_DRV_TRACE(1, "REG:[R0] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 120)); + BT_DRV_TRACE(1, "REG:[R1] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 124)); + BT_DRV_TRACE(1, "REG:[R2] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 128)); + BT_DRV_TRACE(1, "REG:[R3] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 132)); + BT_DRV_TRACE(1, "REG:[R4] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 4)); + BT_DRV_TRACE(1, "REG:[R5] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 8)); + BT_DRV_TRACE(1, "REG:[R6] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 12)); + BT_DRV_TRACE(1, "REG:[R7] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 16)); + BT_DRV_TRACE(1, "REG:[R8] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 20)); + hal_sys_timer_delay(MS_TO_TICKS(100)); + + // BT_DRV_TRACE(1,"REG:[R9] = 0x%08x", + // BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +24)); + BT_DRV_TRACE(1, "REG:[sl] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 28)); + BT_DRV_TRACE(1, "REG:[fp] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 32)); + BT_DRV_TRACE(1, "REG:[ip] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 36)); + BT_DRV_TRACE(1, "REG:[SP,#0] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 40)); + BT_DRV_TRACE(1, "REG:[SP,#4] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 44)); + BT_DRV_TRACE(1, "REG:[SP,#8] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 48)); + BT_DRV_TRACE(1, "REG:[SP,#12] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 52)); + BT_DRV_TRACE(1, "REG:[SP,#16] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 56)); + BT_DRV_TRACE(1, "REG:[SP,#20] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 60)); + BT_DRV_TRACE(1, "REG:[SP,#24] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 64)); + BT_DRV_TRACE(1, "REG:[SP,#28] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 68)); + hal_sys_timer_delay(MS_TO_TICKS(100)); + + BT_DRV_TRACE(1, "REG:[SP,#32] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 72)); + BT_DRV_TRACE(1, "REG:[SP,#36] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 76)); + BT_DRV_TRACE(1, "REG:[SP,#40] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 80)); + BT_DRV_TRACE(1, "REG:[SP,#44] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 84)); + BT_DRV_TRACE(1, "REG:[SP,#48] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 88)); + BT_DRV_TRACE(1, "REG:[SP,#52] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 92)); + BT_DRV_TRACE(1, "REG:[SP,#56] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 96)); + BT_DRV_TRACE(1, "REG:[SP,#60] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 100)); + BT_DRV_TRACE(1, "REG:[SP,#64] = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 104)); + BT_DRV_TRACE(1, "REG:SP = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 108)); + BT_DRV_TRACE(1, "REG:MSP = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 112)); + BT_DRV_TRACE(1, "REG:PSP = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 116)); + BT_DRV_TRACE(1, "REG:CFSR = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 120)); + BT_DRV_TRACE(1, "REG:BFAR = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 124)); + BT_DRV_TRACE(1, "REG:HFSR = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 128)); + BT_DRV_TRACE(1, "REG:ICSR = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 132)); + BT_DRV_TRACE(1, "REG:AIRCR = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 136)); + BT_DRV_TRACE(1, "REG:SCR = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 140)); + BT_DRV_TRACE(1, "REG:CCR = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 144)); + BT_DRV_TRACE(1, "REG:SHCSR = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 148)); + BT_DRV_TRACE(1, "REG:AFSR = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 152)); + BT_DRV_TRACE(1, "REG:MMFAR = 0x%08x", + BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 156)); + hal_sys_timer_delay(MS_TO_TICKS(100)); + // task_message_buffer + uint32_t buff_addr = 0; + + if (task_message_buffer_addr) { + buff_addr = task_message_buffer_addr; + } + + BT_DRV_TRACE(2, "0xd0330050: 0x%x, 54:0x%x", *(uint32_t *)0xd0330050, + *(uint32_t *)0xd0330054); + BT_DRV_TRACE(2, "0x400000a0: 0x%x, a4:0x%x", *(uint32_t *)0x400000a0, + *(uint32_t *)0x400000a4); + + if (g_mem_dump_ctrl_addr) { + BT_DRV_TRACE(1, "LMP addr=0x%x", *(uint32_t *)(g_mem_dump_ctrl_addr + 4)); + BT_DRV_TRACE(1, "STA addr=0x%x", + *(uint32_t *)(g_mem_dump_ctrl_addr + 0x10)); + BT_DRV_TRACE(1, "MSG addr=0x%x", + *(uint32_t *)(g_mem_dump_ctrl_addr + 0x1c)); + BT_DRV_TRACE(1, "SCH addr=0x%x", + *(uint32_t *)(g_mem_dump_ctrl_addr + 0x28)); + BT_DRV_TRACE(1, "ISR addr=0x%x", + *(uint32_t *)(g_mem_dump_ctrl_addr + 0x34)); + } + + BT_DRV_TRACE(0, "task msg buff:"); + if (buff_addr != 0) { + for (uint8_t j = 0; j < 5; j++) { + DUMP8("%02x ", (uint8_t *)(buff_addr + j * 20), 20); + } + } + hal_sys_timer_delay(MS_TO_TICKS(100)); + + BT_DRV_TRACE(0, " "); + BT_DRV_TRACE(0, "lmp buff:"); + // lmp_message_buffer + + if (lmp_message_buffer_addr) { + buff_addr = lmp_message_buffer_addr; + } + + if (buff_addr != 0) { + for (uint8_t j = 0; j < 10; j++) { + DUMP8("%02x ", (uint8_t *)(buff_addr + j * 20), 20); + } + } + hal_sys_timer_delay(MS_TO_TICKS(100)); + + uint8_t link_id = 0; + uint32_t evt_ptr = 0; + uint32_t acl_par_ptr = 0; + for (link_id = 0; link_id < 3; link_id++) { + BT_DRV_TRACE(1, "acl_par: link id %d", link_id); + + if (ld_acl_env_addr) { + evt_ptr = *(uint32_t *)(ld_acl_env_addr + link_id * 4); + } + + if (evt_ptr) { + acl_par_ptr = evt_ptr; + BT_DRV_TRACE(5, + "acl_par: acl_par_ptr 0x%x, clk off 0x%x, bit off 0x%x, " + "last sync clk off 0x%x, last sync bit off 0x%x", + acl_par_ptr, *(uint32_t *)(acl_par_ptr + 140), + *(uint16_t *)(acl_par_ptr + 150), + *(uint32_t *)(acl_par_ptr + 136), + ((*(uint32_t *)(acl_par_ptr + 150)) & 0xFFFF0000) >> 16); + } + } + hal_sys_timer_delay(MS_TO_TICKS(100)); + + // ld_sco_env + evt_ptr = 0; + + if (ld_sco_env_addr) { + evt_ptr = *(uint32_t *)ld_sco_env_addr; + } + + if (evt_ptr != 0) { + BT_DRV_TRACE(1, "esco linkid :%d", *(uint8_t *)(evt_ptr + 70)); + for (link_id = 0; link_id < 3; link_id++) { + BT_DRV_TRACE(2, "bt_linkcntl_linklbl 0x%x: link id %d", + *(uint16_t *)(EM_BT_LINKCNTL_ADDR + link_id * BT_EM_SIZE), + link_id); + BT_DRV_TRACE( + 1, "rxcount :%x", + *(uint16_t *)(EM_BT_RXDESCCNT_ADDR + link_id * BT_EM_SIZE)); + } + } + btdrv_dump_mem(bt_dump_mem_start, bt_dump_len_max, BT_SUB_SYS_TYPE); + // btdrv_dump_mem(em_dump_area_1_start, em_area_1_len_max, + // BT_EM_AREA_1_TYPE); + btdrv_dump_mem(em_dump_area_2_start, em_area_2_len_max, BT_EM_AREA_2_TYPE); + // btdrv_dump_mem(mcu_dump_mem_start, mcu_dump_len_max, MCU_SYS_TYPE); + } +} + +uint8_t bt_drv_reg_op_get_tx_pwr(uint16_t connHandle) { + uint8_t idx; + uint16_t localVal; + uint8_t tx_pwr = 0; + + idx = btdrv_conhdl_to_linkid(connHandle); + + if (btdrv_is_link_index_valid(idx)) { + localVal = BT_DRIVER_GET_U16_REG_VAL(EM_BT_PWRCNTL_ADDR + idx * BT_EM_SIZE); + tx_pwr = ((localVal & ((uint16_t)0x000000FF)) >> 0); + } + + return tx_pwr; +} + +void bt_drv_reg_op_set_tx_pwr(uint16_t connHandle, uint8_t txpwr) { + BT_DRV_REG_OP_ENTER(); + + uint8_t idx = btdrv_conhdl_to_linkid(connHandle); + + if (btdrv_is_link_index_valid(idx)) { + BT_DRIVER_PUT_U16_REG_VAL( + EM_BT_PWRCNTL_ADDR + idx * BT_EM_SIZE, + (BT_DRIVER_GET_U16_REG_VAL(EM_BT_PWRCNTL_ADDR + idx * BT_EM_SIZE) & + ~((uint16_t)0x000000FF)) | + ((uint16_t)txpwr << 0)); + } + + BT_DRV_REG_OP_EXIT(); +} + +void bt_drv_reg_op_fix_tx_pwr(uint16_t connHandle) { + BT_DRV_REG_OP_ENTER(); + bt_drv_reg_op_set_tx_pwr(connHandle, LBRT_TX_PWR_FIX); + BT_DRV_REG_OP_EXIT(); } //#define __ACCESS_MODE_ADJUST_GAIN__ //#define __SWAGC_MODE_ADJUST_GAIN__ #define __REBOOT_PAIRING_MODE_ADJUST_GAIN__ -void bt_drv_reg_op_set_accessible_mode(uint8_t mode) -{ -} +void bt_drv_reg_op_set_accessible_mode(uint8_t mode) {} -void bt_drv_reg_op_set_swagc_mode(uint8_t mode) -{ -} +void bt_drv_reg_op_set_swagc_mode(uint8_t mode) {} -void bt_drv_reg_op_set_reboot_pairing_mode(uint8_t mode) -{ -} +void bt_drv_reg_op_set_reboot_pairing_mode(uint8_t mode) {} -void bt_drv_reg_op_force_sco_retrans(bool enable) -{ +void bt_drv_reg_op_force_sco_retrans(bool enable) { #ifdef __FORCE_SCO_MAX_RETX__ - BT_DRV_REG_OP_ENTER(); - if (enable) - { - BTDIGITAL_REG_SET_FIELD(0xd0220468,3,24,3); - } - else - { - BTDIGITAL_REG_SET_FIELD(0xd0220468,3,24,0); - } - BT_DRV_REG_OP_EXIT(); + BT_DRV_REG_OP_ENTER(); + if (enable) { + BTDIGITAL_REG_SET_FIELD(0xd0220468, 3, 24, 3); + } else { + BTDIGITAL_REG_SET_FIELD(0xd0220468, 3, 24, 0); + } + BT_DRV_REG_OP_EXIT(); #endif } -void bt_drv_reg_op_enable_pcm_tx_hw_cal(void) -{ - BT_DRV_REG_OP_ENTER(); - *(volatile uint32_t *)0xd0220468 |= 1<<22; - *(volatile uint32_t *)0x400000f0 |= 1; - BT_DRV_REG_OP_EXIT(); +void bt_drv_reg_op_enable_pcm_tx_hw_cal(void) { + BT_DRV_REG_OP_ENTER(); + *(volatile uint32_t *)0xd0220468 |= 1 << 22; + *(volatile uint32_t *)0x400000f0 |= 1; + BT_DRV_REG_OP_EXIT(); } +void bt_drv_reg_op_monitor_clk(void) { + BT_DRV_REG_OP_ENTER(); + uint32_t env0 = 0; + uint32_t env1 = 0; + uint32_t env2 = 0; + if (ld_acl_env_addr) { + env0 = *(uint32_t *)ld_acl_env_addr; + env1 = *(uint32_t *)(ld_acl_env_addr + 4); + env1 = *(uint32_t *)(ld_acl_env_addr + 8); + } -void bt_drv_reg_op_monitor_clk(void) -{ - BT_DRV_REG_OP_ENTER(); - uint32_t env0 =0; - uint32_t env1 =0; - uint32_t env2 =0; + if (env0 & bt_ram_start_addr) { + env0 += 0x8c; + BT_DRV_TRACE(2, "BT_REG_OP:env0 clk off=%x %x", *(uint32_t *)env0, + *(uint16_t *)EM_BT_CLKOFF0_ADDR | + (*(uint16_t *)EM_BT_CLKOFF1_ADDR << 16)); + } + if (env1 & bt_ram_start_addr) { + env1 += 0x8c; + BT_DRV_TRACE(2, "BT_REG_OP:env1 clk off=%x %x", *(uint32_t *)env1, + *(uint16_t *)(EM_BT_CLKOFF0_ADDR + BT_EM_SIZE) | + (*(uint16_t *)(EM_BT_CLKOFF1_ADDR + BT_EM_SIZE) << 16)); + } + if (env2 & bt_ram_start_addr) { + env2 += 0x8c; + BT_DRV_TRACE( + 2, "BT_REG_OP:env2 clk off=%x %x", *(uint32_t *)env2, + *(uint16_t *)(EM_BT_CLKOFF0_ADDR + BT_EM_SIZE * 2) | + (*(uint16_t *)(EM_BT_CLKOFF1_ADDR + BT_EM_SIZE * 2) << 16)); + } - - if(ld_acl_env_addr) - { - env0 = *(uint32_t *)ld_acl_env_addr; - env1 = *(uint32_t *)(ld_acl_env_addr+4); - env1 = *(uint32_t *)(ld_acl_env_addr+8); - - } - - - if(env0 & bt_ram_start_addr) - { - env0 +=0x8c; - BT_DRV_TRACE(2,"BT_REG_OP:env0 clk off=%x %x",*(uint32_t *)env0,*(uint16_t *)EM_BT_CLKOFF0_ADDR | (*(uint16_t *)EM_BT_CLKOFF1_ADDR <<16)); - } - if(env1 & bt_ram_start_addr) - { - env1 +=0x8c; - BT_DRV_TRACE(2,"BT_REG_OP:env1 clk off=%x %x",*(uint32_t *)env1,*(uint16_t *)(EM_BT_CLKOFF0_ADDR+BT_EM_SIZE) | (*(uint16_t *)(EM_BT_CLKOFF1_ADDR+BT_EM_SIZE) <<16)); - } - if(env2 & bt_ram_start_addr) - { - env2 +=0x8c; - BT_DRV_TRACE(2,"BT_REG_OP:env2 clk off=%x %x",*(uint32_t *)env2,*(uint16_t *)(EM_BT_CLKOFF0_ADDR+BT_EM_SIZE*2)| (*(uint16_t *)(EM_BT_CLKOFF1_ADDR+BT_EM_SIZE*2) <<16)); - } - - BT_DRV_REG_OP_EXIT(); + BT_DRV_REG_OP_EXIT(); } -bool bt_drv_reg_op_read_rssi_in_dbm(uint16_t connHandle,rx_agc_t* rx_val) -{ +bool bt_drv_reg_op_read_rssi_in_dbm(uint16_t connHandle, rx_agc_t *rx_val) { #ifdef BT_RSSI_MONITOR - BT_DRV_REG_OP_ENTER(); + BT_DRV_REG_OP_ENTER(); - if (connHandle == 0xFFFF) - return false; - - if(hal_get_chip_metal_id()>=HAL_CHIP_METAL_ID_0) - { - uint8_t idx = btdrv_conhdl_to_linkid(connHandle); - /// Accumulated RSSI (to compute an average value) - int16_t rssi_acc = 0; - /// Counter of received packets used in RSSI average - uint8_t rssi_avg_cnt = 1; - rx_agc_t * rx_monitor_env = NULL; - - if (!btdrv_is_link_index_valid(idx)) - { - return false; - } - - //rx_monitor - if(rx_monitor_addr) - { - rx_monitor_env = (rx_agc_t*)rx_monitor_addr; - } - - if(rx_monitor_env != NULL) - { - for(int i=0; i< rssi_avg_cnt; i++) - { - rssi_acc += rx_monitor_env[idx].rssi; - } - rx_val->rssi = rssi_acc / rssi_avg_cnt; - rx_val->rxgain = rx_monitor_env[idx].rxgain; - } - } - - BT_DRV_REG_OP_EXIT(); - return true; -#else + if (connHandle == 0xFFFF) return false; -#endif -} - -bool bt_drv_reg_op_read_ble_rssi_in_dbm(uint16_t connHandle,rx_agc_t* rx_val) -{ -#ifdef BT_RSSI_MONITOR - BT_DRV_REG_OP_ENTER(); - - if (connHandle == 0xFFFF) - return false; - - if(hal_get_chip_metal_id()>=HAL_CHIP_METAL_ID_0) - { - uint8_t idx = connHandle; - /// Accumulated RSSI (to compute an average value) - int16_t rssi_acc = 0; - /// Counter of received packets used in RSSI average - uint8_t rssi_avg_cnt = 1; - rx_agc_t * rx_monitor_env = NULL; - if(idx > 2) - return false;//invalid idx - - //rx_monitor - - if(ble_rx_monitor_addr) - { - rx_monitor_env = (rx_agc_t*)ble_rx_monitor_addr; - } - - if(rx_monitor_env != NULL) - { - for(int i=0; i< rssi_avg_cnt; i++) - { - rssi_acc += rx_monitor_env[idx].rssi; - } - rx_val->rssi = rssi_acc / rssi_avg_cnt; - rx_val->rxgain = rx_monitor_env[idx].rxgain; - } - } - - BT_DRV_REG_OP_EXIT(); - return true; -#else - return false; -#endif -} - -void bt_drv_reg_op_acl_silence(uint16_t connHandle, uint8_t silence) -{ - BT_DRV_REG_OP_ENTER(); + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_0) { uint8_t idx = btdrv_conhdl_to_linkid(connHandle); + /// Accumulated RSSI (to compute an average value) + int16_t rssi_acc = 0; + /// Counter of received packets used in RSSI average + uint8_t rssi_avg_cnt = 1; + rx_agc_t *rx_monitor_env = NULL; - if (btdrv_is_link_index_valid(idx)) - { - BT_DRIVER_PUT_U16_REG_VAL(EM_BT_BT_EXT1_ADDR + idx * BT_EM_SIZE, - (BT_DRIVER_GET_U16_REG_VAL(EM_BT_BT_EXT1_ADDR + idx * BT_EM_SIZE) & ~((uint16_t)0x00008000)) | ((uint16_t)silence << 15)); + if (!btdrv_is_link_index_valid(idx)) { + return false; } - BT_DRV_REG_OP_EXIT(); + // rx_monitor + if (rx_monitor_addr) { + rx_monitor_env = (rx_agc_t *)rx_monitor_addr; + } + + if (rx_monitor_env != NULL) { + for (int i = 0; i < rssi_avg_cnt; i++) { + rssi_acc += rx_monitor_env[idx].rssi; + } + rx_val->rssi = rssi_acc / rssi_avg_cnt; + rx_val->rxgain = rx_monitor_env[idx].rxgain; + } + } + + BT_DRV_REG_OP_EXIT(); + return true; +#else + return false; +#endif } -///sniffer connect information environment structure -struct ld_sniffer_connect_env -{ - /// - uint16_t bitoff; - /// - uint32_t clk_offset; - /// - uint8_t map[10]; - /// - uint32_t afh_instant; - /// - uint8_t afh_mode; - /// - uint8_t enc_mode; - /// - uint8_t ltk[16]; - /// - uint8_t role; +bool bt_drv_reg_op_read_ble_rssi_in_dbm(uint16_t connHandle, rx_agc_t *rx_val) { +#ifdef BT_RSSI_MONITOR + BT_DRV_REG_OP_ENTER(); + + if (connHandle == 0xFFFF) + return false; + + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_0) { + uint8_t idx = connHandle; + /// Accumulated RSSI (to compute an average value) + int16_t rssi_acc = 0; + /// Counter of received packets used in RSSI average + uint8_t rssi_avg_cnt = 1; + rx_agc_t *rx_monitor_env = NULL; + if (idx > 2) + return false; // invalid idx + + // rx_monitor + + if (ble_rx_monitor_addr) { + rx_monitor_env = (rx_agc_t *)ble_rx_monitor_addr; + } + + if (rx_monitor_env != NULL) { + for (int i = 0; i < rssi_avg_cnt; i++) { + rssi_acc += rx_monitor_env[idx].rssi; + } + rx_val->rssi = rssi_acc / rssi_avg_cnt; + rx_val->rxgain = rx_monitor_env[idx].rxgain; + } + } + + BT_DRV_REG_OP_EXIT(); + return true; +#else + return false; +#endif +} + +void bt_drv_reg_op_acl_silence(uint16_t connHandle, uint8_t silence) { + BT_DRV_REG_OP_ENTER(); + + uint8_t idx = btdrv_conhdl_to_linkid(connHandle); + + if (btdrv_is_link_index_valid(idx)) { + BT_DRIVER_PUT_U16_REG_VAL( + EM_BT_BT_EXT1_ADDR + idx * BT_EM_SIZE, + (BT_DRIVER_GET_U16_REG_VAL(EM_BT_BT_EXT1_ADDR + idx * BT_EM_SIZE) & + ~((uint16_t)0x00008000)) | + ((uint16_t)silence << 15)); + } + + BT_DRV_REG_OP_EXIT(); +} + +/// sniffer connect information environment structure +struct ld_sniffer_connect_env { + /// + uint16_t bitoff; + /// + uint32_t clk_offset; + /// + uint8_t map[10]; + /// + uint32_t afh_instant; + /// + uint8_t afh_mode; + /// + uint8_t enc_mode; + /// + uint8_t ltk[16]; + /// + uint8_t role; }; -void bt_drv_reg_op_call_monitor(uint16_t connHandle, uint8_t tws_role) -{ -} +void bt_drv_reg_op_call_monitor(uint16_t connHandle, uint8_t tws_role) {} -void bt_drv_reg_op_lock_sniffer_sco_resync(void) -{ +void bt_drv_reg_op_lock_sniffer_sco_resync(void) {} -} +void bt_drv_reg_op_unlock_sniffer_sco_resync(void) {} -void bt_drv_reg_op_unlock_sniffer_sco_resync(void) -{ +void bt_drv_reg_op_ibrt_retx_att_nb_set(uint8_t retx_nb) { + BT_DRV_REG_OP_ENTER(); -} + int ret = -1; + uint32_t sco_evt_ptr = 0x0; + // TODO: [ld_sco_env address] based on CHIP id -void bt_drv_reg_op_ibrt_retx_att_nb_set(uint8_t retx_nb) -{ - BT_DRV_REG_OP_ENTER(); + if (ld_sco_env_addr) { + sco_evt_ptr = *(volatile uint32_t *)ld_sco_env_addr; + ret = 0; + } - int ret = -1; - uint32_t sco_evt_ptr = 0x0; - // TODO: [ld_sco_env address] based on CHIP id - - if(ld_sco_env_addr) - { - sco_evt_ptr = *(volatile uint32_t *)ld_sco_env_addr; - ret = 0; + if (ret == 0) { + uint32_t retx_ptr = 0x0; + if (sco_evt_ptr != 0) { + // offsetof(struct ea_elt_tag, env) + sizeof(struct ld_sco_evt_params) + retx_ptr = sco_evt_ptr + 0x44; + } else { + BT_DRV_TRACE(0, "BT_REG_OP:Error, ld_sco_env[0].evt ==NULL"); + ret = -2; } - if(ret == 0) - { - uint32_t retx_ptr=0x0; - if(sco_evt_ptr !=0) - { - //offsetof(struct ea_elt_tag, env) + sizeof(struct ld_sco_evt_params) - retx_ptr =sco_evt_ptr+0x44; - } - else - { - BT_DRV_TRACE(0,"BT_REG_OP:Error, ld_sco_env[0].evt ==NULL"); - ret = -2; - } - - if(ret == 0) - { - *(volatile uint8_t *)retx_ptr = retx_nb; - } + if (ret == 0) { + *(volatile uint8_t *)retx_ptr = retx_nb; } + } - BT_DRV_TRACE(3,"BT_REG_OP:%s,ret=%d,retx nb=%d",__func__,ret,retx_nb); - BT_DRV_REG_OP_EXIT(); + BT_DRV_TRACE(3, "BT_REG_OP:%s,ret=%d,retx nb=%d", __func__, ret, retx_nb); + BT_DRV_REG_OP_EXIT(); } -void bt_drv_reg_op_acl_tx_type_set(uint16_t hciHandle, uint8_t slot_sel) -{ - uint32_t lc_ptr=0; - uint32_t acl_par_ptr = 0; - uint32_t packet_type_addr = 0; - //lc_env and ld_acl_env - - if(lc_env_addr) - { - lc_ptr = *(uint32_t *)(lc_env_addr+(hciHandle-0x80)*4); - } - - if(ld_acl_env_addr) - { - acl_par_ptr = *(uint32_t *)(ld_acl_env_addr+(hciHandle-0x80)*4); - } - - //sanity check - if(lc_ptr == 0) - { - return; - } - else - { - packet_type_addr = (uint32_t)(acl_par_ptr+176); - BT_DRV_TRACE(3,"BT_REG_OP:%s hdl=0x%x packet_types=0x%x",__func__,hciHandle, *(uint16_t *)(packet_type_addr)); - BT_DRV_TRACE(2,"BT_REG_OP:lc_ptr 0x%x, acl_par_ptr 0x%x",lc_ptr,acl_par_ptr); - uint16_t edr_type = 0; - if(slot_sel == USE_1_SLOT_PACKET) - { -#if defined(__3M_PACK__) - edr_type = (1 << DM1_IDX) | (1 << DH1_2_IDX) | (1 << DH1_3_IDX); -#else - edr_type = (1 << DM1_IDX) | (1 << DH1_2_IDX); -#endif - } - else if(slot_sel == USE_3_SLOT_PACKET) - { -#if defined(__3M_PACK__) - edr_type = (1 << DM1_IDX) | (1 << DH1_2_IDX) | (1 << DH1_3_IDX) | \ - (1 << DH3_2_IDX) |(1 << DH3_3_IDX); -#else - edr_type = (1 << DM1_IDX) | (1 << DH1_2_IDX) | (1 << DH3_2_IDX); -#endif - } - else if(slot_sel == USE_5_SLOT_PACKET) - { -#if defined(__3M_PACK__) - edr_type = (1 << DM1_IDX) | (1 << DH1_2_IDX) | (1 << DH1_3_IDX) | \ - (1 << DH3_2_IDX) |(1 << DH3_3_IDX) |(1 << DH5_2_IDX) | (1 << DH5_3_IDX); -#else - edr_type = (1 << DM1_IDX) | (1 << DH1_2_IDX) | (1 << DH3_2_IDX)|(1 << DH5_2_IDX); -#endif - } - *(uint16_t *)(packet_type_addr) = ((edr_type<<8)|(*(uint16_t *)(packet_type_addr)&0xff)); - - BT_DRV_TRACE(1,"BT_REG_OP:After op,packet_types 0x%x",*(uint16_t *)(packet_type_addr)); - } -} - -void bt_drv_reg_op_acl_tx_type_trace(uint16_t hciHandle) -{ - uint32_t acl_par_ptr = 0; - uint32_t packet_type_addr = 0; - //ld_acl_env - - if(ld_acl_env_addr) - { - acl_par_ptr = *(uint32_t *)(ld_acl_env_addr+(hciHandle-0x80)*4); - } - - //sanity check - if(acl_par_ptr == 0) - { - return; - } - else - { - packet_type_addr = (uint32_t)(acl_par_ptr+176); - BT_DRV_TRACE(1,"BT_REG_OP:tx packet_types=0x%x",*(uint16_t *)(packet_type_addr)); - } -} - -uint8_t bt_drv_reg_op_acl_tx_type_get(uint16_t hciHandle, uint8_t* br_type, uint8_t* edr_type) -{ - uint8_t status = 0xff; - uint32_t lc_ptr=0; - uint32_t acl_par_ptr = 0; - uint32_t packet_type_addr = 0; - - - if(lc_env_addr) - { - lc_ptr = *(uint32_t *)(lc_env_addr+(hciHandle-0x80)*4); - } - - if(ld_acl_env_addr) - { - acl_par_ptr = *(uint32_t *)(ld_acl_env_addr+(hciHandle-0x80)*4); - } - - - //sanity check - if(lc_ptr == 0) - { - BT_DRV_TRACE(2,"BT_REG_OP:%s hdl=0x%x,lc_env_ptr = NULL",__func__,hciHandle); - } - else - { - packet_type_addr = (uint32_t)(acl_par_ptr+176); - uint16_t packet_type = *(uint16_t *)(packet_type_addr); - if(br_type) - { - *br_type = packet_type&0xff; - } - if(edr_type) - { - *br_type = (packet_type>>8)&0xff; - } - status = 0; - BT_DRV_TRACE(3,"BT_REG_OP:%s hdl=0x%x packet_types=0x%x",__func__,hciHandle, packet_type); - } - - return status; -} - -uint16_t em_bt_bitoff_getf(int elt_idx) -{ - uint16_t localVal = BTDIGITAL_BT_EM(EM_BT_BITOFF_ADDR + elt_idx * BT_EM_SIZE); - ASSERT_ERR((localVal & ~((uint16_t)0x000003FF)) == 0); - return (localVal >> 0); -} - -void em_bt_bitoff_setf(int elt_idx, uint16_t bitoff) -{ - ASSERT_ERR((((uint16_t)bitoff << 0) & ~((uint16_t)0x000003FF)) == 0); - BTDIGITAL_EM_BT_WR(EM_BT_BITOFF_ADDR + elt_idx * BT_EM_SIZE, (uint16_t)bitoff << 0); -} - -void em_bt_clkoff0_setf(int elt_idx, uint16_t clkoff0) -{ - ASSERT_ERR((((uint16_t)clkoff0 << 0) & ~((uint16_t)0x0000FFFF)) == 0); - BTDIGITAL_EM_BT_WR(EM_BT_CLKOFF0_ADDR + elt_idx * BT_EM_SIZE, (uint16_t)clkoff0 << 0); -} - -uint16_t em_bt_clkoff0_getf(int elt_idx) -{ - uint16_t localVal = BTDIGITAL_BT_EM(EM_BT_CLKOFF0_ADDR + elt_idx * BT_EM_SIZE); - ASSERT_ERR((localVal & ~((uint16_t)0x0000FFFF)) == 0); - return (localVal >> 0); -} -void em_bt_clkoff1_setf(int elt_idx, uint16_t clkoff1) -{ - ASSERT_ERR((((uint16_t)clkoff1 << 0) & ~((uint16_t)0x000007FF)) == 0); - BTDIGITAL_EM_BT_WR(EM_BT_CLKOFF1_ADDR + elt_idx * BT_EM_SIZE, (uint16_t)clkoff1 << 0); -} - -uint16_t em_bt_clkoff1_getf(int elt_idx) -{ - uint16_t localVal = BTDIGITAL_BT_EM(EM_BT_CLKOFF1_ADDR + elt_idx * BT_EM_SIZE); - ASSERT_ERR((localVal & ~((uint16_t)0x000007FF)) == 0); - return (localVal >> 0); -} - -void em_bt_wincntl_pack(int elt_idx, uint8_t rxwide, uint16_t rxwinsz) -{ - ASSERT_ERR((((uint16_t)rxwide << 15) & ~((uint16_t)0x00008000)) == 0); - ASSERT_ERR((((uint16_t)rxwinsz << 0) & ~((uint16_t)0x00000FFF)) == 0); - BTDIGITAL_EM_BT_WR(EM_BT_WINCNTL_ADDR + elt_idx * BT_EM_SIZE, ((uint16_t)rxwide << 15) | ((uint16_t)rxwinsz << 0)); -} - -void bt_drv_reg_op_update_sniffer_bitoffset(uint16_t mobile_conhdl,uint16_t master_conhdl) -{ -} - -void bt_drv_reg_op_modify_bitoff_timer(uint16_t time_out) -{ -} - -void bt_drv_reg_op_cs_monitor(void) -{ - uint32_t addr; - addr = BT_EM_ADDR_BASE+0x1e; - BT_DRV_TRACE(0,"BT_REG_OP:AFH 0:"); - DUMP8("%02x ",(uint8_t *)addr,10); - addr = BT_EM_ADDR_BASE + 0x1e + 110; - BT_DRV_TRACE(0,"AFH 1:"); - DUMP8("%02x ",(uint8_t *)addr,10); - addr = BT_EM_ADDR_BASE + 0x1e + 220; - BT_DRV_TRACE(0,"AFH 2:"); - DUMP8("%02x ",(uint8_t *)addr,10); - uint32_t tmp1,tmp2,tmp3; - tmp1 = BT_EM_ADDR_BASE+0x8; - tmp2 = BT_EM_ADDR_BASE+0x8+110; - tmp3 = BT_EM_ADDR_BASE+0x8+220; - BT_DRV_TRACE(3,"AFH EN:%x %x %x ",*(uint16_t *)tmp1,*(uint16_t *)tmp2,*(uint16_t *)tmp3); - tmp1 = BT_EM_ADDR_BASE+0x28; - tmp2 = BT_EM_ADDR_BASE+0x28+110; - tmp3 = BT_EM_ADDR_BASE+0x28+220; - BT_DRV_TRACE(3,"AFH ch num:%x %x %x ",*(uint16_t *)tmp1,*(uint16_t *)tmp2,*(uint16_t *)tmp3); - - tmp1 = BT_EM_ADDR_BASE+0x4; - tmp2 = BT_EM_ADDR_BASE+0x4 + 110; - tmp3 = BT_EM_ADDR_BASE+0x4 + 220; - BT_DRV_TRACE(3,"clk off:%x %x %x ",*(uint32_t *)tmp1,*(uint32_t *)tmp2,*(uint32_t *)tmp3); - - tmp1 = BT_EM_ADDR_BASE+0x2; - tmp2 = BT_EM_ADDR_BASE+0x2+110; - tmp3 = BT_EM_ADDR_BASE+0x2+220; - BT_DRV_TRACE(3,"bitoff:%x %x %x ",*(uint16_t *)tmp1,*(uint16_t *)tmp2,*(uint16_t *)tmp3); - -} - -void bt_drv_reg_op_ble_llm_substate_hacker(void) -{ - -} - -bool bt_drv_reg_op_check_esco_acl_sniff_conflict(uint16_t hciHandle) -{ - return false; -} - -void bt_drv_reg_op_esco_acl_sniff_delay_cal(uint16_t hciHandle,bool enable) -{ -} - -uint8_t bt_drv_reg_op_get_role(uint8_t linkid) -{ - uint32_t lc_evt_ptr=0; - uint32_t role_ptr = 0; - - if(lc_env_addr) - { - lc_evt_ptr = *(volatile uint32_t *)(lc_env_addr+linkid*4);//lc_env - } - - if(lc_evt_ptr !=0) - { - role_ptr = lc_evt_ptr+0x40; - } - else - { - BT_DRV_TRACE(1,"BT_REG_OP:ERROR LINKID =%x",linkid); - return 0xFF; - } - return *(uint8_t *)role_ptr; -} - -void bt_drv_reg_op_set_tpoll(uint8_t linkid,uint16_t poll_interval) -{ - uint32_t acl_evt_ptr = 0x0; - uint32_t poll_addr; - - - if(ld_acl_env_addr) - { - acl_evt_ptr = *(uint32_t *)(ld_acl_env_addr+linkid*4); - } - - - - if (acl_evt_ptr != 0) - { - poll_addr = acl_evt_ptr + 0xb8; - *(uint16_t *)poll_addr = poll_interval; - } - else - { - BT_DRV_TRACE(1,"BT_REG_OP:ERROR LINK ID FOR TPOLL %x", linkid); - } -} - -int8_t bt_drv_reg_op_rssi_correction(int8_t rssi) -{ -#ifdef __HW_AGC__ - if(hal_get_chip_metal_id()>=HAL_CHIP_METAL_ID_0) - { - //the rssi is already corrected - return rssi; - } -#endif - - return rssi; -} - -void bt_drv_reg_op_set_music_link(uint8_t link_id) -{ - //dbg_bt_setting.music_playing_link - if(dbg_bt_setting_addr) - { - *(uint8_t *)(dbg_bt_setting_addr+0x10) = link_id; - } - -} - -void bt_drv_reg_op_set_music_link_duration_extra(uint8_t slot) -{ - if(dbg_bt_setting_addr) - { - *(uint32_t *)(dbg_bt_setting_addr+0x14) = slot*625; - } -} - - -void bt_drv_reg_op_set_hwagc_read_en(uint8_t en) -{ - -} -uint32_t bt_drv_reg_op_get_reconnecting_flag() -{ - uint32_t ret = 0; - - if(reconnecting_flag_addr) - { - ret = *(uint32_t *)reconnecting_flag_addr; - } - return ret; -} - -void bt_drv_reg_op_set_reconnecting_flag() -{ - - if(reconnecting_flag_addr) - { - *(uint32_t *)reconnecting_flag_addr = 1; - } - -} - -void bt_drv_reg_op_clear_reconnecting_flag() -{ - - if(reconnecting_flag_addr) - { - *(uint32_t *)reconnecting_flag_addr = 0; - } -} - -void bt_drv_reg_op_music_link_config(uint16_t active_link,uint8_t active_role,uint16_t inactive_link,uint8_t inactive_role) -{ - BT_DRV_TRACE(4,"BT_REG_OP:bt_drv_reg_op_music_link_config %x %d %x %d",active_link,active_role,inactive_link,inactive_role); - if (active_role == 0) //MASTER - { - bt_drv_reg_op_set_tpoll(active_link-0x80, 0x10); - if (inactive_role == 0) - { - bt_drv_reg_op_set_tpoll(inactive_link-0x80, 0x40); - } - } - else - { - bt_drv_reg_op_set_music_link(active_link-0x80); - bt_drv_reg_op_set_music_link_duration_extra(11); - if (inactive_role == 0) - { - bt_drv_reg_op_set_tpoll(inactive_link-0x80, 0x40); - } - } -} - -bool bt_drv_reg_op_check_bt_controller_state(void) -{ - bool ret=true; - BT_DRV_REG_OP_ENTER(); - if(hal_sysfreq_get() <= HAL_CMU_FREQ_32K) - return ret; - - - if((BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +0)==0x00) - &&(BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE +8)==MIC_BUFF_addr)) - ret = true; - else - ret = false; - - if (false == ret) - { - BT_DRV_TRACE(0,"controller dead!!!"); - btdrv_trigger_coredump(); - } - - BT_DRV_REG_OP_EXIT(); - return ret; -} - -void bt_drv_reg_op_piconet_clk_offset_get(uint16_t connHandle, int32_t *clock_offset, uint16_t *bit_offset) -{ - uint8_t index = 0; - uint32_t clock_offset_raw = 0; - - BT_DRV_REG_OP_ENTER(); - if(hal_get_chip_metal_id()>=HAL_CHIP_METAL_ID_0) - { - if (connHandle) - { - index = btdrv_conhdl_to_linkid(connHandle); - - if (btdrv_is_link_index_valid(index)) - { - *bit_offset = em_bt_bitoff_getf(index); - clock_offset_raw = (em_bt_clkoff1_getf(index) << 16) | em_bt_clkoff0_getf(index); - *clock_offset = clock_offset_raw; - *clock_offset = (*clock_offset << 5) >> 5; - } - else - { - *bit_offset = 0; - *clock_offset = 0; - } - } - else - { - *bit_offset = 0; - *clock_offset = 0; - } - } - BT_DRV_REG_OP_EXIT(); -} - -void bt_drv_reg_op_afh_env_reset(void) -{ - BT_DRV_REG_OP_ENTER(); - int ret = -1; - uint32_t ld_afh_env_addr = 0x0; - - if(hal_get_chip_metal_id()==HAL_CHIP_METAL_ID_0) - { - ld_afh_env_addr = ld_env_addr+0x198; - ret = 0; - - if(ret == 0) - { - struct ld_afh_env* ld_afh_env = (struct ld_afh_env*)ld_afh_env_addr; - if(ld_afh_env) - { - BT_DRV_TRACE(0,"BT_REG_OP:reset ld_afh_env"); - ld_afh_env->rf_rssi_interf_thr = BT_AFH_RSSI_INTERF_THR; - ld_afh_env->afh_update_period = BT_AFH_UPDATE_PERIOD; - ld_afh_env->afh_access_valid_to = BT_AFH_ASSESS_VALID_TO; - ld_afh_env->afh_reaccess_to = BT_AFH_REASSESS_TO; - ld_afh_env->afh_access_count_max = BT_AFH_ASSESS_COUNT_MAX; - ld_afh_env->afh_access_count_thr_good = BT_AFH_ASSESS_COUNT_THR_GOOD; - ld_afh_env->afh_access_count_thr_bad = BT_AFH_ASSESS_COUNT_THR_BAD; - ld_afh_env->afh_access_count_min = BT_AFH_ASSESS_COUNT_MIN; - } - } - } - - BT_DRV_REG_OP_EXIT(); -} - -void bt_drv_reg_op_dma_tc_clkcnt_get(uint32_t *btclk, uint16_t *btcnt) -{ - BT_DRV_REG_OP_ENTER(); - *btclk = *((volatile uint32_t*)0xd02201fc); - *btcnt = *((volatile uint32_t*)0xd02201f8); - BT_DRV_REG_OP_EXIT(); -} - -void em_bt_bt_ext1_tx_silence_setf(int elt_idx, uint8_t txsilence) -{ - ASSERT_ERR((((uint16_t)txsilence << 15) & ~((uint16_t)0x00008000)) == 0); - BTDIGITAL_EM_BT_WR(EM_BT_BT_EXT1_ADDR + elt_idx * BT_EM_SIZE, - (BTDIGITAL_BT_EM(EM_BT_BT_EXT1_ADDR + elt_idx * BT_EM_SIZE) & ~((uint16_t)0x00008000)) | ((uint16_t)txsilence << 15)); -} - -void em_bt_bt_ext1_bw_2m_setf(int elt_idx, uint8_t bw2m) -{ - ASSERT_ERR((((uint16_t)bw2m << 11) & ~((uint16_t)0x00000800)) == 0); - BTDIGITAL_EM_BT_WR(EM_BT_BT_EXT1_ADDR + elt_idx * BT_EM_SIZE, - (BTDIGITAL_BT_EM(EM_BT_BT_EXT1_ADDR + elt_idx * BT_EM_SIZE) & ~((uint16_t)0x00000800)) | ((uint16_t)bw2m << 11)); -} - -void em_bt_bt_ext1_sco_tx_silence_setf(int elt_idx, uint8_t scotxsilence) -{ - ASSERT_ERR((((uint16_t)scotxsilence << 13) & ~((uint16_t)0x00002000)) == 0); - BTDIGITAL_EM_BT_WR(EM_BT_BT_EXT1_ADDR + elt_idx * BT_EM_SIZE, - (BTDIGITAL_BT_EM(EM_BT_BT_EXT1_ADDR + elt_idx * BT_EM_SIZE) & ~((uint16_t)0x00002000)) | ((uint16_t)scotxsilence << 13)); -} - -void bt_drv_reg_op_acl_tx_silence(uint16_t connHandle, uint8_t on) -{ +void bt_drv_reg_op_acl_tx_type_set(uint16_t hciHandle, uint8_t slot_sel) { + uint32_t lc_ptr = 0; + uint32_t acl_par_ptr = 0; + uint32_t packet_type_addr = 0; + // lc_env and ld_acl_env + + if (lc_env_addr) { + lc_ptr = *(uint32_t *)(lc_env_addr + (hciHandle - 0x80) * 4); + } + + if (ld_acl_env_addr) { + acl_par_ptr = *(uint32_t *)(ld_acl_env_addr + (hciHandle - 0x80) * 4); + } + + // sanity check + if (lc_ptr == 0) { return; - BT_DRV_REG_OP_ENTER(); - uint8_t idx = btdrv_conhdl_to_linkid(connHandle); - BT_DRV_TRACE(2,"BT_REG_OP:BT ACL tx silence idx=%d,on=%d\n",idx,on); - - if (btdrv_is_link_index_valid(idx)) - { - if(TX_SILENCE_ON == on) - { - //config ACL silence cs - em_bt_bt_ext1_tx_silence_setf(idx, TX_SILENCE_ON); - if(hal_get_chip_metal_id()>= HAL_CHIP_METAL_ID_1) - { - //config SCO silence cs - em_bt_bt_ext1_sco_tx_silence_setf(idx, TX_SILENCE_ON); - //select ACL silence - BTDIGITAL_REG_SET_FIELD(0xd02204a8,3,2,2); - } - } - else if(TX_SILENCE_OFF == on) - { - //config ACL silence cs - em_bt_bt_ext1_tx_silence_setf(idx, TX_SILENCE_OFF); - if(hal_get_chip_metal_id()>= HAL_CHIP_METAL_ID_1) - { - //config SCO silence cs - em_bt_bt_ext1_sco_tx_silence_setf(idx, TX_SILENCE_OFF); - //select ACL silence - BTDIGITAL_REG_SET_FIELD(0xd02204a8,3,2,3); - } - } + } else { + packet_type_addr = (uint32_t)(acl_par_ptr + 176); + BT_DRV_TRACE(3, "BT_REG_OP:%s hdl=0x%x packet_types=0x%x", __func__, + hciHandle, *(uint16_t *)(packet_type_addr)); + BT_DRV_TRACE(2, "BT_REG_OP:lc_ptr 0x%x, acl_par_ptr 0x%x", lc_ptr, + acl_par_ptr); + uint16_t edr_type = 0; + if (slot_sel == USE_1_SLOT_PACKET) { +#if defined(__3M_PACK__) + edr_type = (1 << DM1_IDX) | (1 << DH1_2_IDX) | (1 << DH1_3_IDX); +#else + edr_type = (1 << DM1_IDX) | (1 << DH1_2_IDX); +#endif + } else if (slot_sel == USE_3_SLOT_PACKET) { +#if defined(__3M_PACK__) + edr_type = (1 << DM1_IDX) | (1 << DH1_2_IDX) | (1 << DH1_3_IDX) | + (1 << DH3_2_IDX) | (1 << DH3_3_IDX); +#else + edr_type = (1 << DM1_IDX) | (1 << DH1_2_IDX) | (1 << DH3_2_IDX); +#endif + } else if (slot_sel == USE_5_SLOT_PACKET) { +#if defined(__3M_PACK__) + edr_type = (1 << DM1_IDX) | (1 << DH1_2_IDX) | (1 << DH1_3_IDX) | + (1 << DH3_2_IDX) | (1 << DH3_3_IDX) | (1 << DH5_2_IDX) | + (1 << DH5_3_IDX); +#else + edr_type = (1 << DM1_IDX) | (1 << DH1_2_IDX) | (1 << DH3_2_IDX) | + (1 << DH5_2_IDX); +#endif } - BT_DRV_REG_OP_EXIT(); + *(uint16_t *)(packet_type_addr) = + ((edr_type << 8) | (*(uint16_t *)(packet_type_addr)&0xff)); + + BT_DRV_TRACE(1, "BT_REG_OP:After op,packet_types 0x%x", + *(uint16_t *)(packet_type_addr)); + } } -void bt_drv_reg_op_acl_tx_silence_clear(uint16_t connHandle) -{ - uint8_t idx = btdrv_conhdl_to_linkid(connHandle); +void bt_drv_reg_op_acl_tx_type_trace(uint16_t hciHandle) { + uint32_t acl_par_ptr = 0; + uint32_t packet_type_addr = 0; + // ld_acl_env - BT_DRV_TRACE(1,"BT_REG_OP:ACL tx silence clear idx=%d\n",idx); + if (ld_acl_env_addr) { + acl_par_ptr = *(uint32_t *)(ld_acl_env_addr + (hciHandle - 0x80) * 4); + } - if (btdrv_is_link_index_valid(idx)) - { - em_bt_bt_ext1_tx_silence_setf(idx, TX_SILENCE_OFF); - if(hal_get_chip_metal_id()>= HAL_CHIP_METAL_ID_1) - { - //config SCO silence cs - em_bt_bt_ext1_sco_tx_silence_setf(idx, TX_SILENCE_OFF); - //select ACL silence - BTDIGITAL_REG_SET_FIELD(0xd02204a8,3,2,3); - } + // sanity check + if (acl_par_ptr == 0) { + return; + } else { + packet_type_addr = (uint32_t)(acl_par_ptr + 176); + BT_DRV_TRACE(1, "BT_REG_OP:tx packet_types=0x%x", + *(uint16_t *)(packet_type_addr)); + } +} + +uint8_t bt_drv_reg_op_acl_tx_type_get(uint16_t hciHandle, uint8_t *br_type, + uint8_t *edr_type) { + uint8_t status = 0xff; + uint32_t lc_ptr = 0; + uint32_t acl_par_ptr = 0; + uint32_t packet_type_addr = 0; + + if (lc_env_addr) { + lc_ptr = *(uint32_t *)(lc_env_addr + (hciHandle - 0x80) * 4); + } + + if (ld_acl_env_addr) { + acl_par_ptr = *(uint32_t *)(ld_acl_env_addr + (hciHandle - 0x80) * 4); + } + + // sanity check + if (lc_ptr == 0) { + BT_DRV_TRACE(2, "BT_REG_OP:%s hdl=0x%x,lc_env_ptr = NULL", __func__, + hciHandle); + } else { + packet_type_addr = (uint32_t)(acl_par_ptr + 176); + uint16_t packet_type = *(uint16_t *)(packet_type_addr); + if (br_type) { + *br_type = packet_type & 0xff; } - bt_drv_reg_op_resume_fast_ack_with_mobile(); -} - -void bt_drv_reg_op_sw_seq_filter(uint16_t connHandle) -{ -} - -void bt_drv_reg_op_pcm_set(uint8_t en) -{ - if(hal_get_chip_metal_id()>=HAL_CHIP_METAL_ID_1) - { - if(en) - *(volatile unsigned int *)(0xd02204a8) &= 0xffffffdf; - else - *(volatile unsigned int *)(0xd02204a8) |= 1<<5; + if (edr_type) { + *br_type = (packet_type >> 8) & 0xff; } -} -uint8_t bt_drv_reg_op_pcm_get() -{ - uint8_t ret = 1; - if(hal_get_chip_metal_id()>=HAL_CHIP_METAL_ID_1) - { - ret = (*(volatile unsigned int *)(0xd02204a8) &0x00000020)>>5; - } - return ~ret; -} -void bt_drv_reg_op_clear_skip_flag() -{ + status = 0; + BT_DRV_TRACE(3, "BT_REG_OP:%s hdl=0x%x packet_types=0x%x", __func__, + hciHandle, packet_type); + } + + return status; } -void bt_drv_reg_op_clean_flags_of_ble_and_sco(void) -{ - if(hal_get_chip_metal_id()==HAL_CHIP_METAL_ID_0) - { - //0xc0006a18,////sco_find_sync_flag - //0xc000699c,///ble_sco_need_move_flag - //0xc000693c,///prev_conflict_type_record - //0xc000099f,///anchor_resume_flag - ASSERT(*(uint32_t *)0xc0006a14 ==0xc0006a18,"ERROR 2300pt1 sco_find_sync_flag!"); - ASSERT(*(uint32_t *)0xc0006998 ==0xc000699c,"ERROR 2300pt1 ble_sco_need_move_flag!"); - ASSERT(*(uint32_t *)0xc0006938 ==0xc000693c,"ERROR 2300pt1 prev_conflict_type_record!"); - //BT_DRV_TRACE(4,"0xc0006a18=%x,0xc000699c=%x,0xc000693c=%x,0xc000099f=%x\n",*(volatile uint32_t *)0xc0006a18,*(volatile uint32_t *)0xc000699c,*(volatile uint32_t *)0xc000693c,*(volatile uint32_t *)0xc000099f); - *(volatile uint32_t *)0xc0006a18 = 0; - *(volatile uint32_t *)0xc0006a88 = 0; - *(volatile uint32_t *)0xc000693c = 0; - *(volatile uint32_t *)0xc000099f = 0; - } +uint16_t em_bt_bitoff_getf(int elt_idx) { + uint16_t localVal = BTDIGITAL_BT_EM(EM_BT_BITOFF_ADDR + elt_idx * BT_EM_SIZE); + ASSERT_ERR((localVal & ~((uint16_t)0x000003FF)) == 0); + return (localVal >> 0); } -const uint8_t msbc_mute_patten[]= -{ - 0x01,0x38, - 0xad, 0x0, 0x0, 0xc5, 0x0, 0x0, 0x0, 0x0, - 0x77, 0x6d, 0xb6, 0xdd, 0xdb, 0x6d, 0xb7, - 0x76, 0xdb, 0x6d, 0xdd, 0xb6, 0xdb, 0x77, - 0x6d, 0xb6, 0xdd, 0xdb, 0x6d, 0xb7, 0x76, - 0xdb, 0x6d, 0xdd, 0xb6, 0xdb, 0x77, 0x6d, - 0xb6, 0xdd, 0xdb, 0x6d, 0xb7, 0x76, 0xdb, - 0x6d, 0xdd, 0xb6, 0xdb, 0x77, 0x6d, 0xb6, - 0xdd, 0xdb, 0x6d, 0xb7, 0x76, 0xdb, 0x6c, - 0x00 -}; +void em_bt_bitoff_setf(int elt_idx, uint16_t bitoff) { + ASSERT_ERR((((uint16_t)bitoff << 0) & ~((uint16_t)0x000003FF)) == 0); + BTDIGITAL_EM_BT_WR(EM_BT_BITOFF_ADDR + elt_idx * BT_EM_SIZE, + (uint16_t)bitoff << 0); +} + +void em_bt_clkoff0_setf(int elt_idx, uint16_t clkoff0) { + ASSERT_ERR((((uint16_t)clkoff0 << 0) & ~((uint16_t)0x0000FFFF)) == 0); + BTDIGITAL_EM_BT_WR(EM_BT_CLKOFF0_ADDR + elt_idx * BT_EM_SIZE, + (uint16_t)clkoff0 << 0); +} + +uint16_t em_bt_clkoff0_getf(int elt_idx) { + uint16_t localVal = + BTDIGITAL_BT_EM(EM_BT_CLKOFF0_ADDR + elt_idx * BT_EM_SIZE); + ASSERT_ERR((localVal & ~((uint16_t)0x0000FFFF)) == 0); + return (localVal >> 0); +} +void em_bt_clkoff1_setf(int elt_idx, uint16_t clkoff1) { + ASSERT_ERR((((uint16_t)clkoff1 << 0) & ~((uint16_t)0x000007FF)) == 0); + BTDIGITAL_EM_BT_WR(EM_BT_CLKOFF1_ADDR + elt_idx * BT_EM_SIZE, + (uint16_t)clkoff1 << 0); +} + +uint16_t em_bt_clkoff1_getf(int elt_idx) { + uint16_t localVal = + BTDIGITAL_BT_EM(EM_BT_CLKOFF1_ADDR + elt_idx * BT_EM_SIZE); + ASSERT_ERR((localVal & ~((uint16_t)0x000007FF)) == 0); + return (localVal >> 0); +} + +void em_bt_wincntl_pack(int elt_idx, uint8_t rxwide, uint16_t rxwinsz) { + ASSERT_ERR((((uint16_t)rxwide << 15) & ~((uint16_t)0x00008000)) == 0); + ASSERT_ERR((((uint16_t)rxwinsz << 0) & ~((uint16_t)0x00000FFF)) == 0); + BTDIGITAL_EM_BT_WR(EM_BT_WINCNTL_ADDR + elt_idx * BT_EM_SIZE, + ((uint16_t)rxwide << 15) | ((uint16_t)rxwinsz << 0)); +} + +void bt_drv_reg_op_update_sniffer_bitoffset(uint16_t mobile_conhdl, + uint16_t master_conhdl) {} + +void bt_drv_reg_op_modify_bitoff_timer(uint16_t time_out) {} + +void bt_drv_reg_op_cs_monitor(void) { + uint32_t addr; + addr = BT_EM_ADDR_BASE + 0x1e; + BT_DRV_TRACE(0, "BT_REG_OP:AFH 0:"); + DUMP8("%02x ", (uint8_t *)addr, 10); + addr = BT_EM_ADDR_BASE + 0x1e + 110; + BT_DRV_TRACE(0, "AFH 1:"); + DUMP8("%02x ", (uint8_t *)addr, 10); + addr = BT_EM_ADDR_BASE + 0x1e + 220; + BT_DRV_TRACE(0, "AFH 2:"); + DUMP8("%02x ", (uint8_t *)addr, 10); + uint32_t tmp1, tmp2, tmp3; + tmp1 = BT_EM_ADDR_BASE + 0x8; + tmp2 = BT_EM_ADDR_BASE + 0x8 + 110; + tmp3 = BT_EM_ADDR_BASE + 0x8 + 220; + BT_DRV_TRACE(3, "AFH EN:%x %x %x ", *(uint16_t *)tmp1, *(uint16_t *)tmp2, + *(uint16_t *)tmp3); + tmp1 = BT_EM_ADDR_BASE + 0x28; + tmp2 = BT_EM_ADDR_BASE + 0x28 + 110; + tmp3 = BT_EM_ADDR_BASE + 0x28 + 220; + BT_DRV_TRACE(3, "AFH ch num:%x %x %x ", *(uint16_t *)tmp1, *(uint16_t *)tmp2, + *(uint16_t *)tmp3); + + tmp1 = BT_EM_ADDR_BASE + 0x4; + tmp2 = BT_EM_ADDR_BASE + 0x4 + 110; + tmp3 = BT_EM_ADDR_BASE + 0x4 + 220; + BT_DRV_TRACE(3, "clk off:%x %x %x ", *(uint32_t *)tmp1, *(uint32_t *)tmp2, + *(uint32_t *)tmp3); + + tmp1 = BT_EM_ADDR_BASE + 0x2; + tmp2 = BT_EM_ADDR_BASE + 0x2 + 110; + tmp3 = BT_EM_ADDR_BASE + 0x2 + 220; + BT_DRV_TRACE(3, "bitoff:%x %x %x ", *(uint16_t *)tmp1, *(uint16_t *)tmp2, + *(uint16_t *)tmp3); +} + +void bt_drv_reg_op_ble_llm_substate_hacker(void) {} + +bool bt_drv_reg_op_check_esco_acl_sniff_conflict(uint16_t hciHandle) { + return false; +} + +void bt_drv_reg_op_esco_acl_sniff_delay_cal(uint16_t hciHandle, bool enable) {} + +uint8_t bt_drv_reg_op_get_role(uint8_t linkid) { + uint32_t lc_evt_ptr = 0; + uint32_t role_ptr = 0; + + if (lc_env_addr) { + lc_evt_ptr = *(volatile uint32_t *)(lc_env_addr + linkid * 4); // lc_env + } + + if (lc_evt_ptr != 0) { + role_ptr = lc_evt_ptr + 0x40; + } else { + BT_DRV_TRACE(1, "BT_REG_OP:ERROR LINKID =%x", linkid); + return 0xFF; + } + return *(uint8_t *)role_ptr; +} + +void bt_drv_reg_op_set_tpoll(uint8_t linkid, uint16_t poll_interval) { + uint32_t acl_evt_ptr = 0x0; + uint32_t poll_addr; + + if (ld_acl_env_addr) { + acl_evt_ptr = *(uint32_t *)(ld_acl_env_addr + linkid * 4); + } + + if (acl_evt_ptr != 0) { + poll_addr = acl_evt_ptr + 0xb8; + *(uint16_t *)poll_addr = poll_interval; + } else { + BT_DRV_TRACE(1, "BT_REG_OP:ERROR LINK ID FOR TPOLL %x", linkid); + } +} + +int8_t bt_drv_reg_op_rssi_correction(int8_t rssi) { +#ifdef __HW_AGC__ + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_0) { + // the rssi is already corrected + return rssi; + } +#endif + + return rssi; +} + +void bt_drv_reg_op_set_music_link(uint8_t link_id) { + // dbg_bt_setting.music_playing_link + if (dbg_bt_setting_addr) { + *(uint8_t *)(dbg_bt_setting_addr + 0x10) = link_id; + } +} + +void bt_drv_reg_op_set_music_link_duration_extra(uint8_t slot) { + if (dbg_bt_setting_addr) { + *(uint32_t *)(dbg_bt_setting_addr + 0x14) = slot * 625; + } +} + +void bt_drv_reg_op_set_hwagc_read_en(uint8_t en) {} +uint32_t bt_drv_reg_op_get_reconnecting_flag() { + uint32_t ret = 0; + + if (reconnecting_flag_addr) { + ret = *(uint32_t *)reconnecting_flag_addr; + } + return ret; +} + +void bt_drv_reg_op_set_reconnecting_flag() { + + if (reconnecting_flag_addr) { + *(uint32_t *)reconnecting_flag_addr = 1; + } +} + +void bt_drv_reg_op_clear_reconnecting_flag() { + + if (reconnecting_flag_addr) { + *(uint32_t *)reconnecting_flag_addr = 0; + } +} + +void bt_drv_reg_op_music_link_config(uint16_t active_link, uint8_t active_role, + uint16_t inactive_link, + uint8_t inactive_role) { + BT_DRV_TRACE(4, "BT_REG_OP:bt_drv_reg_op_music_link_config %x %d %x %d", + active_link, active_role, inactive_link, inactive_role); + if (active_role == 0) // MASTER + { + bt_drv_reg_op_set_tpoll(active_link - 0x80, 0x10); + if (inactive_role == 0) { + bt_drv_reg_op_set_tpoll(inactive_link - 0x80, 0x40); + } + } else { + bt_drv_reg_op_set_music_link(active_link - 0x80); + bt_drv_reg_op_set_music_link_duration_extra(11); + if (inactive_role == 0) { + bt_drv_reg_op_set_tpoll(inactive_link - 0x80, 0x40); + } + } +} + +bool bt_drv_reg_op_check_bt_controller_state(void) { + bool ret = true; + BT_DRV_REG_OP_ENTER(); + if (hal_sysfreq_get() <= HAL_CMU_FREQ_32K) + return ret; + + if ((BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 0) == 0x00) && + (BTDIGITAL_REG(BT_CONTROLLER_CRASH_DUMP_ADDR_BASE + 8) == MIC_BUFF_addr)) + ret = true; + else + ret = false; + + if (false == ret) { + BT_DRV_TRACE(0, "controller dead!!!"); + btdrv_trigger_coredump(); + } + + BT_DRV_REG_OP_EXIT(); + return ret; +} + +void bt_drv_reg_op_piconet_clk_offset_get(uint16_t connHandle, + int32_t *clock_offset, + uint16_t *bit_offset) { + uint8_t index = 0; + uint32_t clock_offset_raw = 0; + + BT_DRV_REG_OP_ENTER(); + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_0) { + if (connHandle) { + index = btdrv_conhdl_to_linkid(connHandle); + + if (btdrv_is_link_index_valid(index)) { + *bit_offset = em_bt_bitoff_getf(index); + clock_offset_raw = + (em_bt_clkoff1_getf(index) << 16) | em_bt_clkoff0_getf(index); + *clock_offset = clock_offset_raw; + *clock_offset = (*clock_offset << 5) >> 5; + } else { + *bit_offset = 0; + *clock_offset = 0; + } + } else { + *bit_offset = 0; + *clock_offset = 0; + } + } + BT_DRV_REG_OP_EXIT(); +} + +void bt_drv_reg_op_afh_env_reset(void) { + BT_DRV_REG_OP_ENTER(); + int ret = -1; + uint32_t ld_afh_env_addr = 0x0; + + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_0) { + ld_afh_env_addr = ld_env_addr + 0x198; + ret = 0; + + if (ret == 0) { + struct ld_afh_env *ld_afh_env = (struct ld_afh_env *)ld_afh_env_addr; + if (ld_afh_env) { + BT_DRV_TRACE(0, "BT_REG_OP:reset ld_afh_env"); + ld_afh_env->rf_rssi_interf_thr = BT_AFH_RSSI_INTERF_THR; + ld_afh_env->afh_update_period = BT_AFH_UPDATE_PERIOD; + ld_afh_env->afh_access_valid_to = BT_AFH_ASSESS_VALID_TO; + ld_afh_env->afh_reaccess_to = BT_AFH_REASSESS_TO; + ld_afh_env->afh_access_count_max = BT_AFH_ASSESS_COUNT_MAX; + ld_afh_env->afh_access_count_thr_good = BT_AFH_ASSESS_COUNT_THR_GOOD; + ld_afh_env->afh_access_count_thr_bad = BT_AFH_ASSESS_COUNT_THR_BAD; + ld_afh_env->afh_access_count_min = BT_AFH_ASSESS_COUNT_MIN; + } + } + } + + BT_DRV_REG_OP_EXIT(); +} + +void bt_drv_reg_op_dma_tc_clkcnt_get(uint32_t *btclk, uint16_t *btcnt) { + BT_DRV_REG_OP_ENTER(); + *btclk = *((volatile uint32_t *)0xd02201fc); + *btcnt = *((volatile uint32_t *)0xd02201f8); + BT_DRV_REG_OP_EXIT(); +} + +void em_bt_bt_ext1_tx_silence_setf(int elt_idx, uint8_t txsilence) { + ASSERT_ERR((((uint16_t)txsilence << 15) & ~((uint16_t)0x00008000)) == 0); + BTDIGITAL_EM_BT_WR( + EM_BT_BT_EXT1_ADDR + elt_idx * BT_EM_SIZE, + (BTDIGITAL_BT_EM(EM_BT_BT_EXT1_ADDR + elt_idx * BT_EM_SIZE) & + ~((uint16_t)0x00008000)) | + ((uint16_t)txsilence << 15)); +} + +void em_bt_bt_ext1_bw_2m_setf(int elt_idx, uint8_t bw2m) { + ASSERT_ERR((((uint16_t)bw2m << 11) & ~((uint16_t)0x00000800)) == 0); + BTDIGITAL_EM_BT_WR( + EM_BT_BT_EXT1_ADDR + elt_idx * BT_EM_SIZE, + (BTDIGITAL_BT_EM(EM_BT_BT_EXT1_ADDR + elt_idx * BT_EM_SIZE) & + ~((uint16_t)0x00000800)) | + ((uint16_t)bw2m << 11)); +} + +void em_bt_bt_ext1_sco_tx_silence_setf(int elt_idx, uint8_t scotxsilence) { + ASSERT_ERR((((uint16_t)scotxsilence << 13) & ~((uint16_t)0x00002000)) == 0); + BTDIGITAL_EM_BT_WR( + EM_BT_BT_EXT1_ADDR + elt_idx * BT_EM_SIZE, + (BTDIGITAL_BT_EM(EM_BT_BT_EXT1_ADDR + elt_idx * BT_EM_SIZE) & + ~((uint16_t)0x00002000)) | + ((uint16_t)scotxsilence << 13)); +} + +void bt_drv_reg_op_acl_tx_silence(uint16_t connHandle, uint8_t on) { + return; + BT_DRV_REG_OP_ENTER(); + uint8_t idx = btdrv_conhdl_to_linkid(connHandle); + BT_DRV_TRACE(2, "BT_REG_OP:BT ACL tx silence idx=%d,on=%d\n", idx, on); + + if (btdrv_is_link_index_valid(idx)) { + if (TX_SILENCE_ON == on) { + // config ACL silence cs + em_bt_bt_ext1_tx_silence_setf(idx, TX_SILENCE_ON); + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) { + // config SCO silence cs + em_bt_bt_ext1_sco_tx_silence_setf(idx, TX_SILENCE_ON); + // select ACL silence + BTDIGITAL_REG_SET_FIELD(0xd02204a8, 3, 2, 2); + } + } else if (TX_SILENCE_OFF == on) { + // config ACL silence cs + em_bt_bt_ext1_tx_silence_setf(idx, TX_SILENCE_OFF); + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) { + // config SCO silence cs + em_bt_bt_ext1_sco_tx_silence_setf(idx, TX_SILENCE_OFF); + // select ACL silence + BTDIGITAL_REG_SET_FIELD(0xd02204a8, 3, 2, 3); + } + } + } + BT_DRV_REG_OP_EXIT(); +} + +void bt_drv_reg_op_acl_tx_silence_clear(uint16_t connHandle) { + uint8_t idx = btdrv_conhdl_to_linkid(connHandle); + + BT_DRV_TRACE(1, "BT_REG_OP:ACL tx silence clear idx=%d\n", idx); + + if (btdrv_is_link_index_valid(idx)) { + em_bt_bt_ext1_tx_silence_setf(idx, TX_SILENCE_OFF); + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) { + // config SCO silence cs + em_bt_bt_ext1_sco_tx_silence_setf(idx, TX_SILENCE_OFF); + // select ACL silence + BTDIGITAL_REG_SET_FIELD(0xd02204a8, 3, 2, 3); + } + } + bt_drv_reg_op_resume_fast_ack_with_mobile(); +} + +void bt_drv_reg_op_sw_seq_filter(uint16_t connHandle) {} + +void bt_drv_reg_op_pcm_set(uint8_t en) { + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) { + if (en) + *(volatile unsigned int *)(0xd02204a8) &= 0xffffffdf; + else + *(volatile unsigned int *)(0xd02204a8) |= 1 << 5; + } +} +uint8_t bt_drv_reg_op_pcm_get() { + uint8_t ret = 1; + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) { + ret = (*(volatile unsigned int *)(0xd02204a8) & 0x00000020) >> 5; + } + return ~ret; +} +void bt_drv_reg_op_clear_skip_flag() {} + +void bt_drv_reg_op_clean_flags_of_ble_and_sco(void) { + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_0) { + // 0xc0006a18,////sco_find_sync_flag + // 0xc000699c,///ble_sco_need_move_flag + // 0xc000693c,///prev_conflict_type_record + // 0xc000099f,///anchor_resume_flag + ASSERT(*(uint32_t *)0xc0006a14 == 0xc0006a18, + "ERROR 2300pt1 sco_find_sync_flag!"); + ASSERT(*(uint32_t *)0xc0006998 == 0xc000699c, + "ERROR 2300pt1 ble_sco_need_move_flag!"); + ASSERT(*(uint32_t *)0xc0006938 == 0xc000693c, + "ERROR 2300pt1 prev_conflict_type_record!"); + // BT_DRV_TRACE(4,"0xc0006a18=%x,0xc000699c=%x,0xc000693c=%x,0xc000099f=%x\n",*(volatile + // uint32_t *)0xc0006a18,*(volatile uint32_t *)0xc000699c,*(volatile + // uint32_t + // *)0xc000693c,*(volatile uint32_t *)0xc000099f); + *(volatile uint32_t *)0xc0006a18 = 0; + *(volatile uint32_t *)0xc0006a88 = 0; + *(volatile uint32_t *)0xc000693c = 0; + *(volatile uint32_t *)0xc000099f = 0; + } +} + +const uint8_t msbc_mute_patten[] = { + 0x01, 0x38, 0xad, 0x0, 0x0, 0xc5, 0x0, 0x0, 0x0, 0x0, 0x77, 0x6d, + 0xb6, 0xdd, 0xdb, 0x6d, 0xb7, 0x76, 0xdb, 0x6d, 0xdd, 0xb6, 0xdb, 0x77, + 0x6d, 0xb6, 0xdd, 0xdb, 0x6d, 0xb7, 0x76, 0xdb, 0x6d, 0xdd, 0xb6, 0xdb, + 0x77, 0x6d, 0xb6, 0xdd, 0xdb, 0x6d, 0xb7, 0x76, 0xdb, 0x6d, 0xdd, 0xb6, + 0xdb, 0x77, 0x6d, 0xb6, 0xdd, 0xdb, 0x6d, 0xb7, 0x76, 0xdb, 0x6c, 0x00}; #define SCO_TX_FIFO_BASE (0xd0210000) #if defined(CVSD_BYPASS) @@ -1843,32 +1652,26 @@ const uint8_t msbc_mute_patten[]= #define SCO_TX_MUTE_PATTERN (0x0000) #endif -void bt_drv_reg_op_sco_txfifo_reset(uint16_t codec_id) -{ - uint32_t reg_val = BTDIGITAL_REG(0xd0220148); - uint32_t reg_offset0, reg_offset1; - uint16_t *patten_p = (uint16_t *)msbc_mute_patten; +void bt_drv_reg_op_sco_txfifo_reset(uint16_t codec_id) { + uint32_t reg_val = BTDIGITAL_REG(0xd0220148); + uint32_t reg_offset0, reg_offset1; + uint16_t *patten_p = (uint16_t *)msbc_mute_patten; - reg_offset0 = (reg_val & 0xffff); - reg_offset1 = (reg_val >> 16) & 0xffff; + reg_offset0 = (reg_val & 0xffff); + reg_offset1 = (reg_val >> 16) & 0xffff; - if (codec_id == 2) - { - for (uint8_t i=0; i<60; i+=2) - { - BTDIGITAL_BT_EM(SCO_TX_FIFO_BASE+reg_offset0+i) = *patten_p; - BTDIGITAL_BT_EM(SCO_TX_FIFO_BASE+reg_offset1+i) = *patten_p; - patten_p++; - } + if (codec_id == 2) { + for (uint8_t i = 0; i < 60; i += 2) { + BTDIGITAL_BT_EM(SCO_TX_FIFO_BASE + reg_offset0 + i) = *patten_p; + BTDIGITAL_BT_EM(SCO_TX_FIFO_BASE + reg_offset1 + i) = *patten_p; + patten_p++; } - else - { - for (uint8_t i=0; i<120; i+=2) - { - BTDIGITAL_BT_EM(SCO_TX_FIFO_BASE+reg_offset0+i) = SCO_TX_MUTE_PATTERN; - BTDIGITAL_BT_EM(SCO_TX_FIFO_BASE+reg_offset1+i) = SCO_TX_MUTE_PATTERN; - } + } else { + for (uint8_t i = 0; i < 120; i += 2) { + BTDIGITAL_BT_EM(SCO_TX_FIFO_BASE + reg_offset0 + i) = SCO_TX_MUTE_PATTERN; + BTDIGITAL_BT_EM(SCO_TX_FIFO_BASE + reg_offset1 + i) = SCO_TX_MUTE_PATTERN; } + } } /***************************************************************************** @@ -1886,86 +1689,74 @@ void bt_drv_reg_op_sco_txfifo_reset(uint16_t codec_id) Modification : Created function *****************************************************************************/ -void btdrv_reg_op_set_private_tws_poll_interval(uint16_t poll_interval, uint16_t poll_interval_in_sco) -{ - BT_DRV_TRACE(2,"BT_REG_OP:Set private tws interval,acl interv=%d,acl interv insco =%d", \ - poll_interval,poll_interval_in_sco); - - if(dbg_bt_setting_addr) - { - *(volatile uint16_t *)(dbg_bt_setting_addr+0x40) = poll_interval; - *(volatile uint16_t *)(dbg_bt_setting_addr+0x42) = poll_interval_in_sco; - } - +void btdrv_reg_op_set_private_tws_poll_interval(uint16_t poll_interval, + uint16_t poll_interval_in_sco) { + BT_DRV_TRACE( + 2, + "BT_REG_OP:Set private tws interval,acl interv=%d,acl interv insco =%d", + poll_interval, poll_interval_in_sco); + if (dbg_bt_setting_addr) { + *(volatile uint16_t *)(dbg_bt_setting_addr + 0x40) = poll_interval; + *(volatile uint16_t *)(dbg_bt_setting_addr + 0x42) = poll_interval_in_sco; + } } -void btdrv_reg_op_set_tws_link_duration(uint8_t slot_num) -{ - BT_DRV_REG_OP_ENTER(); - //dbg_setting address - uint32_t op_addr = 0; +void btdrv_reg_op_set_tws_link_duration(uint8_t slot_num) { + BT_DRV_REG_OP_ENTER(); + // dbg_setting address + uint32_t op_addr = 0; + if (dbg_bt_setting_addr) { + op_addr = dbg_bt_setting_addr; + } - if(dbg_bt_setting_addr) - { - op_addr = dbg_bt_setting_addr; - } - - - if(op_addr != 0) - { - //uint16_t acl_slot = dbg_setting->acl_slot_in_snoop_mode; - uint16_t val = *(volatile uint16_t *)(op_addr+0x44); - val&=0xff00; - val|= slot_num; - *(volatile uint16_t *)(op_addr+0x44) = val; - BT_DRV_TRACE(1,"BT_REG_OP:Set private tws link duration,val=%d",*((volatile uint16_t*)(op_addr+0x44))&0xff); - } - BT_DRV_REG_OP_EXIT(); + if (op_addr != 0) { + // uint16_t acl_slot = dbg_setting->acl_slot_in_snoop_mode; + uint16_t val = *(volatile uint16_t *)(op_addr + 0x44); + val &= 0xff00; + val |= slot_num; + *(volatile uint16_t *)(op_addr + 0x44) = val; + BT_DRV_TRACE(1, "BT_REG_OP:Set private tws link duration,val=%d", + *((volatile uint16_t *)(op_addr + 0x44)) & 0xff); + } + BT_DRV_REG_OP_EXIT(); } -void btdrv_reg_op_enable_private_tws_schedule(bool enable) -{ - BT_DRV_REG_OP_ENTER(); - //sniffer_env - uint32_t op_addr = 0; +void btdrv_reg_op_enable_private_tws_schedule(bool enable) { + BT_DRV_REG_OP_ENTER(); + // sniffer_env + uint32_t op_addr = 0; - if(sniffer_env_addr) - { - op_addr = sniffer_env_addr; - } + if (sniffer_env_addr) { + op_addr = sniffer_env_addr; + } - if(op_addr!=0) - { - //sniffer_env.acl_switch_flag.in_process - uint16_t val = *((volatile uint16_t*)(op_addr+0x7e)); - val&=0xff; - if(enable) - { - val|=1<<8; - } - *((volatile uint16_t*)(op_addr+0x7e)) = val; - BT_DRV_TRACE(1,"BT_REG_OP:Enable private tws function,flag=%d", (*((volatile uint16_t*)(op_addr+0x7e)))>>8); + if (op_addr != 0) { + // sniffer_env.acl_switch_flag.in_process + uint16_t val = *((volatile uint16_t *)(op_addr + 0x7e)); + val &= 0xff; + if (enable) { + val |= 1 << 8; } - BT_DRV_REG_OP_EXIT(); + *((volatile uint16_t *)(op_addr + 0x7e)) = val; + BT_DRV_TRACE(1, "BT_REG_OP:Enable private tws function,flag=%d", + (*((volatile uint16_t *)(op_addr + 0x7e))) >> 8); + } + BT_DRV_REG_OP_EXIT(); } -void bt_drv_reg_op_decrease_tx_pwr_when_reconnect(bool enable) -{ +void bt_drv_reg_op_decrease_tx_pwr_when_reconnect(bool enable) { - if(enable) - { - BT_DRV_TRACE(0,"BT_REG_OP:Decrese tx pwr"); - //drease defualt TX pwr - BTDIGITAL_REG(0xd0350300) = 0x33; - } - else - { - BT_DRV_TRACE(0,"BT_REG_OP:Increase tx pwr"); - //resume defualt TX pwr - BTDIGITAL_REG(0xd0350300) = 0x11; - } + if (enable) { + BT_DRV_TRACE(0, "BT_REG_OP:Decrese tx pwr"); + // drease defualt TX pwr + BTDIGITAL_REG(0xd0350300) = 0x33; + } else { + BT_DRV_TRACE(0, "BT_REG_OP:Increase tx pwr"); + // resume defualt TX pwr + BTDIGITAL_REG(0xd0350300) = 0x11; + } } /* rwip_heap_env @@ -1973,1306 +1764,1110 @@ void bt_drv_reg_op_decrease_tx_pwr_when_reconnect(bool enable) rwip_heap_non_ret from addr=0xc00052b8 left_length=1.5K */ -void bt_drv_reg_op_controller_mem_log_config(void) -{ - if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) - { - uint32_t each_log_length = 0x200;//512Byte - uint32_t lmp_mem_addr = 0xc00027b8+0x64;//lmp:each_log_length - uint32_t msg_mem_addr = lmp_mem_addr+each_log_length+0x64;//msg:each_log_length - uint32_t sta_mem_addr = msg_mem_addr+each_log_length+0x64;//sta:each_log_length - uint32_t sch_mem_addr = sta_mem_addr+each_log_length+0x64;//sch:each_log_length - uint32_t isr_mem_addr = sch_mem_addr+each_log_length+0x64;//isr:each_log_length +void bt_drv_reg_op_controller_mem_log_config(void) { + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) { + uint32_t each_log_length = 0x200; // 512Byte + uint32_t lmp_mem_addr = 0xc00027b8 + 0x64; // lmp:each_log_length + uint32_t msg_mem_addr = + lmp_mem_addr + each_log_length + 0x64; // msg:each_log_length + uint32_t sta_mem_addr = + msg_mem_addr + each_log_length + 0x64; // sta:each_log_length + uint32_t sch_mem_addr = + sta_mem_addr + each_log_length + 0x64; // sch:each_log_length + uint32_t isr_mem_addr = + sch_mem_addr + each_log_length + 0x64; // isr:each_log_length - //LMP_DUMP_TRACE - *(uint32_t *)g_mem_dump_ctrl_addr= each_log_length; //g_mem_dump_ctrl[0].len_max default:1024 - *(uint32_t *)(g_mem_dump_ctrl_addr+4) = lmp_mem_addr; //g_mem_dump_ctrl[0].start_addr - *(uint8_t *)(g_mem_dump_ctrl_addr+8) = 0x01; //g_mem_dump_ctrl[0].trace_enable + // LMP_DUMP_TRACE + *(uint32_t *)g_mem_dump_ctrl_addr = + each_log_length; // g_mem_dump_ctrl[0].len_max default:1024 + *(uint32_t *)(g_mem_dump_ctrl_addr + 4) = + lmp_mem_addr; // g_mem_dump_ctrl[0].start_addr + *(uint8_t *)(g_mem_dump_ctrl_addr + 8) = + 0x01; // g_mem_dump_ctrl[0].trace_enable - //MSG_DUMP_TRACE - *(uint32_t *)(g_mem_dump_ctrl_addr+0xc) = each_log_length; //g_mem_dump_ctrl[1].len_max default:1024 - *(uint32_t *)(g_mem_dump_ctrl_addr+0x10) = msg_mem_addr; //g_mem_dump_ctrl[1].start_addr - *(uint8_t *)(g_mem_dump_ctrl_addr+0x14) = 0x01; //g_mem_dump_ctrl[1].trace_enable + // MSG_DUMP_TRACE + *(uint32_t *)(g_mem_dump_ctrl_addr + 0xc) = + each_log_length; // g_mem_dump_ctrl[1].len_max default:1024 + *(uint32_t *)(g_mem_dump_ctrl_addr + 0x10) = + msg_mem_addr; // g_mem_dump_ctrl[1].start_addr + *(uint8_t *)(g_mem_dump_ctrl_addr + 0x14) = + 0x01; // g_mem_dump_ctrl[1].trace_enable - //STA_DUMP_TRACE - *(uint32_t *)(g_mem_dump_ctrl_addr+0x18) = each_log_length; //g_mem_dump_ctrl[2].len_max default:1024 - *(uint32_t *)(g_mem_dump_ctrl_addr+0x1c) = sta_mem_addr; //g_mem_dump_ctrl[2].start_addr - *(uint8_t *)(g_mem_dump_ctrl_addr+0x20) = 0x01; //g_mem_dump_ctrl[2].trace_enable + // STA_DUMP_TRACE + *(uint32_t *)(g_mem_dump_ctrl_addr + 0x18) = + each_log_length; // g_mem_dump_ctrl[2].len_max default:1024 + *(uint32_t *)(g_mem_dump_ctrl_addr + 0x1c) = + sta_mem_addr; // g_mem_dump_ctrl[2].start_addr + *(uint8_t *)(g_mem_dump_ctrl_addr + 0x20) = + 0x01; // g_mem_dump_ctrl[2].trace_enable - //SCH_DUMP_TRACE - *(uint32_t *)(g_mem_dump_ctrl_addr+0x24) = each_log_length; //g_mem_dump_ctrl[3].len_max default:1024 - *(uint32_t *)(g_mem_dump_ctrl_addr+0x28) = sch_mem_addr; //g_mem_dump_ctrl[3].start_addr - *(uint8_t *)(g_mem_dump_ctrl_addr+0x2c) = 0x01; //g_mem_dump_ctrl[3].trace_enable + // SCH_DUMP_TRACE + *(uint32_t *)(g_mem_dump_ctrl_addr + 0x24) = + each_log_length; // g_mem_dump_ctrl[3].len_max default:1024 + *(uint32_t *)(g_mem_dump_ctrl_addr + 0x28) = + sch_mem_addr; // g_mem_dump_ctrl[3].start_addr + *(uint8_t *)(g_mem_dump_ctrl_addr + 0x2c) = + 0x01; // g_mem_dump_ctrl[3].trace_enable - //ISR_DUMP_TRACE - *(uint32_t *)(g_mem_dump_ctrl_addr+0x30) = each_log_length; //g_mem_dump_ctrl[4].len_max default:1024 - *(uint32_t *)(g_mem_dump_ctrl_addr+0x34) = isr_mem_addr; //g_mem_dump_ctrl[4].start_addr - *(uint8_t *)(g_mem_dump_ctrl_addr+0x38) = 0x01; //g_mem_dump_ctrl[4].trace_enable - } + // ISR_DUMP_TRACE + *(uint32_t *)(g_mem_dump_ctrl_addr + 0x30) = + each_log_length; // g_mem_dump_ctrl[4].len_max default:1024 + *(uint32_t *)(g_mem_dump_ctrl_addr + 0x34) = + isr_mem_addr; // g_mem_dump_ctrl[4].start_addr + *(uint8_t *)(g_mem_dump_ctrl_addr + 0x38) = + 0x01; // g_mem_dump_ctrl[4].trace_enable + } } -void bt_drv_reg_op_lm_nb_sync_hacker(uint8_t sco_status) -{ - BT_DRV_REG_OP_ENTER(); - //lm_nb_sync_active - uint32_t op_addr = 0; +void bt_drv_reg_op_lm_nb_sync_hacker(uint8_t sco_status) { + BT_DRV_REG_OP_ENTER(); + // lm_nb_sync_active + uint32_t op_addr = 0; - if(lm_nb_sync_active_addr) - { - op_addr = lm_nb_sync_active_addr; - } + if (lm_nb_sync_active_addr) { + op_addr = lm_nb_sync_active_addr; + } - if(op_addr != 0) - { - uint8_t org_val = *(volatile uint8_t *)(op_addr); - //sanity check - if(org_val > 0xf0) - org_val = 0; + if (op_addr != 0) { + uint8_t org_val = *(volatile uint8_t *)(op_addr); + // sanity check + if (org_val > 0xf0) + org_val = 0; - if((sco_status == SNIFFER_SCO_STOP ||sco_status == SNIFFER_SCO_START|| - sco_status == SNIFFER_ACL_DISCONNECT_STOP_SCO) - && (org_val >= 0 && org_val <= 2 )) - { - if(sco_status == SNIFFER_SCO_STOP || - sco_status == SNIFFER_ACL_DISCONNECT_STOP_SCO) - { - if(org_val>0) - { - *(volatile uint8_t *)(op_addr) = org_val -1; - } - } - else if(sco_status == SNIFFER_SCO_START) - { - *(volatile uint8_t *)(op_addr) = org_val + 1; - } - BT_DRV_TRACE(3,"BT_REG_OP:modify lm_nb_sync org val=%d, modify val=%d, status=%d", - org_val,*(volatile uint8_t *)(op_addr), sco_status); - } - else - { - BT_DRV_TRACE(2,"BT_REG_OP:do not need modify lm_nb_sync val=%d, status=%d",org_val, sco_status); + if ((sco_status == SNIFFER_SCO_STOP || sco_status == SNIFFER_SCO_START || + sco_status == SNIFFER_ACL_DISCONNECT_STOP_SCO) && + (org_val >= 0 && org_val <= 2)) { + if (sco_status == SNIFFER_SCO_STOP || + sco_status == SNIFFER_ACL_DISCONNECT_STOP_SCO) { + if (org_val > 0) { + *(volatile uint8_t *)(op_addr) = org_val - 1; } + } else if (sco_status == SNIFFER_SCO_START) { + *(volatile uint8_t *)(op_addr) = org_val + 1; + } + BT_DRV_TRACE( + 3, "BT_REG_OP:modify lm_nb_sync org val=%d, modify val=%d, status=%d", + org_val, *(volatile uint8_t *)(op_addr), sco_status); + } else { + BT_DRV_TRACE(2, + "BT_REG_OP:do not need modify lm_nb_sync val=%d, status=%d", + org_val, sco_status); } - BT_DRV_REG_OP_EXIT(); + } + BT_DRV_REG_OP_EXIT(); } -#define BT_FASTACK_ADDR 0xD0220468 -#define BT_SCO_TRIGGER_BYPASS_ADDR 0xD022046C -void bt_drv_reg_op_fastack_status_checker(uint16_t conhdl) -{ - BT_DRV_REG_OP_ENTER(); +#define BT_FASTACK_ADDR 0xD0220468 +#define BT_SCO_TRIGGER_BYPASS_ADDR 0xD022046C +void bt_drv_reg_op_fastack_status_checker(uint16_t conhdl) { + BT_DRV_REG_OP_ENTER(); - uint8_t elt_idx = btdrv_conhdl_to_linkid(conhdl); + uint8_t elt_idx = btdrv_conhdl_to_linkid(conhdl); - if (btdrv_is_link_index_valid(elt_idx)) - { - uint32_t fast_cs_addr = EM_BT_BT_EXT1_ADDR + elt_idx * BT_EM_SIZE; + if (btdrv_is_link_index_valid(elt_idx)) { + uint32_t fast_cs_addr = EM_BT_BT_EXT1_ADDR + elt_idx * BT_EM_SIZE; - BT_DRV_TRACE(3,"BT_DRV_REG: fastack cs=0x%x,fast ack reg=0x%x,Seq filter by pass=0x%x", - *(volatile uint16_t *)(fast_cs_addr), //fa rx bit10,tx bit9 - *(volatile uint32_t *)(BT_FASTACK_ADDR),//fast ack reg bit22 - *(volatile uint32_t *)(BT_SCO_TRIGGER_BYPASS_ADDR));//seq bypass reg bit 18 - } + BT_DRV_TRACE( + 3, + "BT_DRV_REG: fastack cs=0x%x,fast ack reg=0x%x,Seq filter by pass=0x%x", + *(volatile uint16_t *)(fast_cs_addr), // fa rx bit10,tx bit9 + *(volatile uint32_t *)(BT_FASTACK_ADDR), // fast ack reg bit22 + *(volatile uint32_t + *)(BT_SCO_TRIGGER_BYPASS_ADDR)); // seq bypass reg bit 18 + } - bt_drv_reg_op_bt_info_checker(); + bt_drv_reg_op_bt_info_checker(); - BT_DRV_REG_OP_EXIT(); + BT_DRV_REG_OP_EXIT(); } -void bt_drv_reg_op_clear_ibrt_snoop_status(void) -{ - BT_DRV_REG_OP_ENTER(); +void bt_drv_reg_op_clear_ibrt_snoop_status(void) { + BT_DRV_REG_OP_ENTER(); - //sniffer_env.snoop_status - uint32_t op_addr = 0; + // sniffer_env.snoop_status + uint32_t op_addr = 0; - if(sniffer_env_addr) - { - op_addr = sniffer_env_addr+0x84; - } + if (sniffer_env_addr) { + op_addr = sniffer_env_addr + 0x84; + } - if(op_addr!=0) - { - BT_DRV_TRACE(0,"BT_REG_OP:clear snoop_status"); - *(volatile uint8_t *)(op_addr) = 0; - } - //close fastack register - bt_drv_reg_op_fa_set(0); - //clear fastack cs - for(uint8_t idx=0; idx<3; idx++) - { - //fastack cs: rx bit10,tx bit9 - uint32_t fast_cs_addr = EM_BT_BT_EXT1_ADDR + idx * BT_EM_SIZE; - *(volatile uint16_t *)(fast_cs_addr)&=~0x600; - } + if (op_addr != 0) { + BT_DRV_TRACE(0, "BT_REG_OP:clear snoop_status"); + *(volatile uint8_t *)(op_addr) = 0; + } + // close fastack register + bt_drv_reg_op_fa_set(0); + // clear fastack cs + for (uint8_t idx = 0; idx < 3; idx++) { + // fastack cs: rx bit10,tx bit9 + uint32_t fast_cs_addr = EM_BT_BT_EXT1_ADDR + idx * BT_EM_SIZE; + *(volatile uint16_t *)(fast_cs_addr) &= ~0x600; + } - BT_DRV_REG_OP_EXIT(); + BT_DRV_REG_OP_EXIT(); } -uint8_t bt_drv_reg_op_linkcntl_aclltaddr_getf(uint16_t conhdl) -{ - uint8_t elt_idx = btdrv_conhdl_to_linkid(conhdl); +uint8_t bt_drv_reg_op_linkcntl_aclltaddr_getf(uint16_t conhdl) { + uint8_t elt_idx = btdrv_conhdl_to_linkid(conhdl); - if (btdrv_is_link_index_valid(elt_idx)) - { - uint16_t localVal = BTDIGITAL_BT_EM(EM_BT_LINKCNTL_ADDR + elt_idx * BT_EM_SIZE); - return ((localVal & ((uint16_t)0x00000700)) >> 8); - } - else - { - return 0; - } + if (btdrv_is_link_index_valid(elt_idx)) { + uint16_t localVal = + BTDIGITAL_BT_EM(EM_BT_LINKCNTL_ADDR + elt_idx * BT_EM_SIZE); + return ((localVal & ((uint16_t)0x00000700)) >> 8); + } else { + return 0; + } } -uint8_t bt_drv_reg_op_sync_bt_param(uint8_t* param, uint16_t len) -{ - uint8_t status = 0xff; - BT_DRV_REG_OP_ENTER(); - //link_connect_bak - uint32_t op_addr = 0; +uint8_t bt_drv_reg_op_sync_bt_param(uint8_t *param, uint16_t len) { + uint8_t status = 0xff; + BT_DRV_REG_OP_ENTER(); + // link_connect_bak + uint32_t op_addr = 0; + if (link_connect_bak_addr) { + op_addr = link_connect_bak_addr; + } - if(link_connect_bak_addr) - { - op_addr = link_connect_bak_addr; - } + if (op_addr != 0) { + BT_DRV_TRACE(1, "BT_REG_OP:sync bt param len=%d", len); - if(op_addr!=0) - { - BT_DRV_TRACE(1,"BT_REG_OP:sync bt param len=%d",len); + memcpy((uint8_t *)(op_addr), param, len); + status = 0; + } - memcpy((uint8_t *)(op_addr),param, len); - status = 0; - } - - BT_DRV_REG_OP_EXIT(); - return status; + BT_DRV_REG_OP_EXIT(); + return status; } -uint32_t bt_drv_reg_op_get_lc_env_ptr(uint16_t conhdl, uint8_t type) -{ - uint32_t lc_ptr = 0; - uint32_t op_ptr = 0; - BT_DRV_REG_OP_ENTER(); +uint32_t bt_drv_reg_op_get_lc_env_ptr(uint16_t conhdl, uint8_t type) { + uint32_t lc_ptr = 0; + uint32_t op_ptr = 0; + BT_DRV_REG_OP_ENTER(); + if (lc_env_addr) { + lc_ptr = *(uint32_t *)(lc_env_addr + (conhdl - 0x80) * 4); + } + BT_DRV_TRACE(3, "BT_REG_OP:lc_env_ptr =0x%x, conhdl=0x%x,type=%d", lc_ptr, + conhdl, type); - if(lc_env_addr) - { - lc_ptr = *(uint32_t *)(lc_env_addr+(conhdl-0x80)*4); - } + if (lc_ptr == 0) + return 0; - BT_DRV_TRACE(3,"BT_REG_OP:lc_env_ptr =0x%x, conhdl=0x%x,type=%d",lc_ptr,conhdl,type); + switch (type) { + case LC_LINK_TAG: + // link tag len=108 + op_ptr = lc_ptr; + break; + case LC_INFO_TAG: + op_ptr = lc_ptr + 0x6c; + break; + case LC_ENC_TAG: + // enc tag len=166 + op_ptr = lc_ptr + 0x196; + break; + case LC_AFH_TAG: + op_ptr = lc_ptr + 0x26c; + break; + case LC_SP_TAG: + // link tag len=108 + op_ptr = lc_ptr + 0x28c; + break; + case LC_EPR_TAG: + op_ptr = lc_ptr + 0x2f8; + break; + case LC_EPC_TAG: + op_ptr = lc_ptr + 0x2fc; + break; + default: + break; + } - if(lc_ptr == 0) - return 0; - - switch(type) - { - case LC_LINK_TAG: - //link tag len=108 - op_ptr = lc_ptr; - break; - case LC_INFO_TAG: - op_ptr = lc_ptr +0x6c; - break; - case LC_ENC_TAG: - //enc tag len=166 - op_ptr = lc_ptr +0x196; - break; - case LC_AFH_TAG: - op_ptr = lc_ptr +0x26c; - break; - case LC_SP_TAG: - //link tag len=108 - op_ptr = lc_ptr +0x28c; - break; - case LC_EPR_TAG: - op_ptr = lc_ptr +0x2f8; - break; - case LC_EPC_TAG: - op_ptr = lc_ptr +0x2fc; - break; - default: - break; - } - - BT_DRV_REG_OP_EXIT(); - return op_ptr; + BT_DRV_REG_OP_EXIT(); + return op_ptr; } #ifdef __BT_ONE_BRING_TWO__ -void bt_drv_reg_op_set_music_ongong_flag() -{ -} +void bt_drv_reg_op_set_music_ongong_flag() {} -void bt_drv_reg_op_clear_music_ongong_flag() -{ -} +void bt_drv_reg_op_clear_music_ongong_flag() {} #endif -uint16_t bt_drv_reg_op_get_ble_conn_latency(uint16_t ble_conhdl) -{ - uint16_t curr_conn_latency = 0xffff; - return curr_conn_latency; +uint16_t bt_drv_reg_op_get_ble_conn_latency(uint16_t ble_conhdl) { + uint16_t curr_conn_latency = 0xffff; + return curr_conn_latency; } -bool bt_drv_reg_op_set_ble_conn_latency(uint16_t ble_conhdl, uint16_t conn_latency) -{ - return false; +bool bt_drv_reg_op_set_ble_conn_latency(uint16_t ble_conhdl, + uint16_t conn_latency) { + return false; } -void bt_drv_reg_op_write_private_public_key(uint8_t* private_key,uint8_t* public_key) -{ - uint8_t* lm_env_ptr = 0; - uint8_t* lm_private_key_ptr = 0; - uint8_t* lm_public_key_ptr = 0; - //lm_env - if(lm_env_addr) - { - lm_env_ptr = (uint8_t*)lm_env_addr; - } - else - { - return; - } - - lm_private_key_ptr = lm_env_ptr + 0x6c; - lm_public_key_ptr = lm_private_key_ptr + 0x18; - memcpy(lm_private_key_ptr,private_key,24); - memcpy(lm_public_key_ptr,public_key,48); - BT_DRV_TRACE(0,"private key"); - DUMP8("%02x",lm_private_key_ptr,24); - BT_DRV_TRACE(0,"public key"); - DUMP8("%02x",lm_public_key_ptr,48); +void bt_drv_reg_op_write_private_public_key(uint8_t *private_key, + uint8_t *public_key) { + uint8_t *lm_env_ptr = 0; + uint8_t *lm_private_key_ptr = 0; + uint8_t *lm_public_key_ptr = 0; + // lm_env + if (lm_env_addr) { + lm_env_ptr = (uint8_t *)lm_env_addr; + } else { + return; + } + lm_private_key_ptr = lm_env_ptr + 0x6c; + lm_public_key_ptr = lm_private_key_ptr + 0x18; + memcpy(lm_private_key_ptr, private_key, 24); + memcpy(lm_public_key_ptr, public_key, 48); + BT_DRV_TRACE(0, "private key"); + DUMP8("%02x", lm_private_key_ptr, 24); + BT_DRV_TRACE(0, "public key"); + DUMP8("%02x", lm_public_key_ptr, 48); } -void bt_drv_reg_op_for_test_mode_disable(void) -{ - - if(dbg_bt_setting_addr) - { - *(volatile uint32_t *)(dbg_bt_setting_addr+0x64) &= ~(1<<8);////sw_seq_filter_en set 0 - *(volatile uint32_t *)(dbg_bt_setting_addr+0x64) &= ~(1<<0);////ecc_enable set 0 - *(volatile uint32_t *)(dbg_bt_setting_addr+0x1c) &= 0x00ffffff;////dbg_trace_level set 0 - } - +void bt_drv_reg_op_for_test_mode_disable(void) { + if (dbg_bt_setting_addr) { + *(volatile uint32_t *)(dbg_bt_setting_addr + 0x64) &= + ~(1 << 8); ////sw_seq_filter_en set 0 + *(volatile uint32_t *)(dbg_bt_setting_addr + 0x64) &= + ~(1 << 0); ////ecc_enable set 0 + *(volatile uint32_t *)(dbg_bt_setting_addr + 0x1c) &= + 0x00ffffff; ////dbg_trace_level set 0 + } } -uint16_t bt_drv_reg_op_get_ibrt_sco_hdl(uint16_t acl_hdl) -{ - // FIXME - return acl_hdl|0x100; +uint16_t bt_drv_reg_op_get_ibrt_sco_hdl(uint16_t acl_hdl) { + // FIXME + return acl_hdl | 0x100; } -void bt_drv_reg_op_get_ibrt_address(uint8_t *addr) -{ - struct ld_device_info * mobile_device_info=0; - BT_DRV_REG_OP_ENTER(); +void bt_drv_reg_op_get_ibrt_address(uint8_t *addr) { + struct ld_device_info *mobile_device_info = 0; + BT_DRV_REG_OP_ENTER(); - if(sniffer_env_addr) - { - mobile_device_info = (struct ld_device_info *)(sniffer_env_addr+4); + if (sniffer_env_addr) { + mobile_device_info = (struct ld_device_info *)(sniffer_env_addr + 4); + } + + if (mobile_device_info) { + if (addr != NULL) { + memcpy(addr, (uint8_t *)mobile_device_info->bd_addr.addr, 6); + BT_DRV_TRACE(0, "BT_REG_OP:get mobile address"); + DUMP8("%02x ", addr, 6); } + } - if(mobile_device_info) - { - if (addr != NULL) - { - memcpy(addr, (uint8_t *)mobile_device_info->bd_addr.addr, 6); - BT_DRV_TRACE(0,"BT_REG_OP:get mobile address"); - DUMP8("%02x ",addr,6); - } - } - - BT_DRV_REG_OP_EXIT(); + BT_DRV_REG_OP_EXIT(); } - -void bt_drv_reg_op_set_tws_link_id(uint8_t link_id) -{ - //ASSERT(); - BT_DRV_TRACE(1,"set tws link id =%x",link_id); - ASSERT(link_id <3 || link_id == 0xff,"error tws link id set"); - if(hal_get_chip_metal_id()==HAL_CHIP_METAL_ID_1) - { - ASSERT(*(uint32_t *)0xc0006e28 == 0xc0006e2c,"PATCH ERROR!!"); - *(uint32_t *)0xc0006e2c = link_id; - } - else if(tws_link_id_addr) - { - if(link_id == 0xff) - { - link_id = 3; - } - *(uint8_t *)tws_link_id_addr = link_id; +void bt_drv_reg_op_set_tws_link_id(uint8_t link_id) { + // ASSERT(); + BT_DRV_TRACE(1, "set tws link id =%x", link_id); + ASSERT(link_id < 3 || link_id == 0xff, "error tws link id set"); + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_1) { + ASSERT(*(uint32_t *)0xc0006e28 == 0xc0006e2c, "PATCH ERROR!!"); + *(uint32_t *)0xc0006e2c = link_id; + } else if (tws_link_id_addr) { + if (link_id == 0xff) { + link_id = 3; } + *(uint8_t *)tws_link_id_addr = link_id; + } } -void bt_drv_reg_op_hack_max_slot(uint8_t link_id,uint8_t slot) -{ - uint32_t acl_evt_ptr = 0x0; - uint32_t slot_addr; - uint32_t stop_lantency_addr=0; - BT_DRV_TRACE(2,"hack slot id=%d,slot=%d",link_id,slot); - if(link_id>=3) - return; +void bt_drv_reg_op_hack_max_slot(uint8_t link_id, uint8_t slot) { + uint32_t acl_evt_ptr = 0x0; + uint32_t slot_addr; + uint32_t stop_lantency_addr = 0; + BT_DRV_TRACE(2, "hack slot id=%d,slot=%d", link_id, slot); + if (link_id >= 3) + return; + if (ld_acl_env_addr) { + acl_evt_ptr = *(uint32_t *)(ld_acl_env_addr + link_id * 4); + } - if(ld_acl_env_addr) - { - acl_evt_ptr = *(uint32_t *)(ld_acl_env_addr+link_id*4); - } - - - - if(acl_evt_ptr) - { - slot_addr = acl_evt_ptr+0xc4; - stop_lantency_addr = acl_evt_ptr+0x18; - *(uint8_t *)slot_addr = slot; - *(uint8_t *)stop_lantency_addr = slot+3+(*(uint16_t *)(acl_evt_ptr+150)>128?1:0); - } + if (acl_evt_ptr) { + slot_addr = acl_evt_ptr + 0xc4; + stop_lantency_addr = acl_evt_ptr + 0x18; + *(uint8_t *)slot_addr = slot; + *(uint8_t *)stop_lantency_addr = + slot + 3 + (*(uint16_t *)(acl_evt_ptr + 150) > 128 ? 1 : 0); + } } -void bt_drv_reg_op_rx_slot_stop_lantency_checker(void) -{ - uint32_t acl_evt_ptr = 0x0; - uint32_t slot_addr; - uint32_t stop_addr; +void bt_drv_reg_op_rx_slot_stop_lantency_checker(void) { + uint32_t acl_evt_ptr = 0x0; + uint32_t slot_addr; + uint32_t stop_addr; + for (uint8_t i = 0; i < 3; i++) { - for(uint8_t i=0; i<3; i++) - { - - - if(ld_acl_env_addr) - { - acl_evt_ptr = *(uint32_t *)(ld_acl_env_addr+i*4); - } - - if(acl_evt_ptr) - { - slot_addr = acl_evt_ptr+0xc4; - stop_addr = acl_evt_ptr+0x18; - BT_DRV_TRACE(5,"id=%d,rx slot=%d stop=%d,acl_par: clk off 0x%x, bit off 0x%x",i,*(uint8_t *)slot_addr, - *(uint8_t *)stop_addr,*(uint32_t *)(acl_evt_ptr+140),*(uint16_t *)(acl_evt_ptr+150)); - } + if (ld_acl_env_addr) { + acl_evt_ptr = *(uint32_t *)(ld_acl_env_addr + i * 4); } + + if (acl_evt_ptr) { + slot_addr = acl_evt_ptr + 0xc4; + stop_addr = acl_evt_ptr + 0x18; + BT_DRV_TRACE( + 5, "id=%d,rx slot=%d stop=%d,acl_par: clk off 0x%x, bit off 0x%x", i, + *(uint8_t *)slot_addr, *(uint8_t *)stop_addr, + *(uint32_t *)(acl_evt_ptr + 140), *(uint16_t *)(acl_evt_ptr + 150)); + } + } } -void bt_drv_reg_op_fa_set(uint8_t en) -{ - if(hal_get_chip_metal_id()>=HAL_CHIP_METAL_ID_1) - { - if(en) - { - *(uint32_t *)0xd0220468 |=0x00400000; - BT_DRV_TRACE(1,"%s", __func__); - } - else - { - *(uint32_t *)0xd0220468 &= ~0x00400000; - } +void bt_drv_reg_op_fa_set(uint8_t en) { + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) { + if (en) { + *(uint32_t *)0xd0220468 |= 0x00400000; + BT_DRV_TRACE(1, "%s", __func__); + } else { + *(uint32_t *)0xd0220468 &= ~0x00400000; } + } } //////return true means controller had received a data packet -bool bt_drv_reg_op_check_seq_pending_status(void) -{ +bool bt_drv_reg_op_check_seq_pending_status(void) { - if(pending_seq_error_link_addr) - { - return (*(uint8_t *)pending_seq_error_link_addr == 3); - } - else - { - return TRUE; - } + if (pending_seq_error_link_addr) { + return (*(uint8_t *)pending_seq_error_link_addr == 3); + } else { + return TRUE; + } } -///if the flag is not clear when disconnect happened call this function -void bt_drv_reg_op_clear_seq_pending_status(void) -{ - if(pending_seq_error_link_addr) - { - *(uint8_t *)pending_seq_error_link_addr = 3; - } - +/// if the flag is not clear when disconnect happened call this function +void bt_drv_reg_op_clear_seq_pending_status(void) { + if (pending_seq_error_link_addr) { + *(uint8_t *)pending_seq_error_link_addr = 3; + } } +void bt_drv_reg_op_rssi_checker(void) { + // BT_DRV_TRACE(1,"rssi thd=%x",*(uint32_t *)0xc00041e4); -void bt_drv_reg_op_rssi_checker(void) -{ - // BT_DRV_TRACE(1,"rssi thd=%x",*(uint32_t *)0xc00041e4); + uint32_t acl_evt_ptr = 0x0; + uint32_t rssi_acc_addr; + uint32_t rssi_count_addr; - uint32_t acl_evt_ptr = 0x0; - uint32_t rssi_acc_addr; - uint32_t rssi_count_addr; - - - for(uint8_t i=0; i<3; i++) - { - - if(ld_acl_env_addr) - { - acl_evt_ptr = *(uint32_t *)(ld_acl_env_addr+i*4); - } - - if(acl_evt_ptr) - { - rssi_acc_addr = acl_evt_ptr+0xac; - rssi_count_addr = acl_evt_ptr+0xae; - BT_DRV_TRACE(3,"id=%d,rssi acc=%d count=%d",i,*(int16_t *)rssi_acc_addr,*(uint8_t *)rssi_count_addr); - } + for (uint8_t i = 0; i < 3; i++) { + if (ld_acl_env_addr) { + acl_evt_ptr = *(uint32_t *)(ld_acl_env_addr + i * 4); } - uint32_t lc_evt_ptr = 0x0; - uint32_t recv_addr; - for(uint8_t i=0; i<3; i++) - { - if(lc_env_addr) - { - lc_evt_ptr = *(volatile uint32_t *)(lc_env_addr+i*4);//lc_env - } - if(lc_evt_ptr) - { - recv_addr = lc_evt_ptr+0x60; - BT_DRV_TRACE(2,"id=%d,recv=%x",i,*(uint32_t *)recv_addr); - } + if (acl_evt_ptr) { + rssi_acc_addr = acl_evt_ptr + 0xac; + rssi_count_addr = acl_evt_ptr + 0xae; + BT_DRV_TRACE(3, "id=%d,rssi acc=%d count=%d", i, + *(int16_t *)rssi_acc_addr, *(uint8_t *)rssi_count_addr); } + } + uint32_t lc_evt_ptr = 0x0; + uint32_t recv_addr; + + for (uint8_t i = 0; i < 3; i++) { + if (lc_env_addr) { + lc_evt_ptr = *(volatile uint32_t *)(lc_env_addr + i * 4); // lc_env + } + if (lc_evt_ptr) { + recv_addr = lc_evt_ptr + 0x60; + BT_DRV_TRACE(2, "id=%d,recv=%x", i, *(uint32_t *)recv_addr); + } + } } -void bt_drv_reg_op_set_link_policy(uint8_t linkid, uint8_t policy) -{ - BT_DRV_REG_OP_ENTER(); - uint32_t lc_evt_ptr = 0x0; - uint32_t policy_addr; - if(linkid>=0x3) - return; +void bt_drv_reg_op_set_link_policy(uint8_t linkid, uint8_t policy) { + BT_DRV_REG_OP_ENTER(); + uint32_t lc_evt_ptr = 0x0; + uint32_t policy_addr; + if (linkid >= 0x3) + return; - BT_DRV_TRACE(2,"REG_OP: set link=%d, policy=%d",linkid,policy); + BT_DRV_TRACE(2, "REG_OP: set link=%d, policy=%d", linkid, policy); + if (lc_env_addr) { + lc_evt_ptr = *(volatile uint32_t *)(lc_env_addr + linkid * 4); // lc_env + } - if(lc_env_addr) - { - lc_evt_ptr = *(volatile uint32_t *)(lc_env_addr+linkid*4);//lc_env - } - - if(lc_evt_ptr) - { - policy_addr = lc_evt_ptr+0x2c; - *(uint8_t *)policy_addr = policy; - } - BT_DRV_REG_OP_EXIT(); + if (lc_evt_ptr) { + policy_addr = lc_evt_ptr + 0x2c; + *(uint8_t *)policy_addr = policy; + } + BT_DRV_REG_OP_EXIT(); } -void bt_drv_reg_op_voice_settings_set(uint16_t voice_settings) -{ - uint32_t voice_settings_addr = 0; +void bt_drv_reg_op_voice_settings_set(uint16_t voice_settings) { + uint32_t voice_settings_addr = 0; + if (hci_env_addr) { + voice_settings_addr = hci_env_addr + 90; + } - if(hci_env_addr) - { - voice_settings_addr = hci_env_addr+90; - } - - if(voice_settings_addr != 0) - { - BT_DRV_TRACE(2,"Fast_bt_init1:%s %d",__func__,voice_settings); - *(uint16_t *)voice_settings_addr = voice_settings; - } + if (voice_settings_addr != 0) { + BT_DRV_TRACE(2, "Fast_bt_init1:%s %d", __func__, voice_settings); + *(uint16_t *)voice_settings_addr = voice_settings; + } } -uint8_t bt_drv_reg_op_lmp_sco_hdl_get(uint16_t sco_handle) -{ - if (sco_handle == 0xffff) - { - return 0; - } - - if(hal_get_chip_metal_id()==HAL_CHIP_METAL_ID_1) - { - // uint32_t lc_sco_env_addr = 0xc000079c; - uint16_t sco_link_id = ((sco_handle >> 8) - 1); - uint32_t link_params_addr = *((uint32_t *)(lc_sco_env_addr + sco_link_id * 8)); - uint8_t sync_hdl = 0; - - if (sco_link_id > 2 || link_params_addr == 0) - { - return 0; - } - - sync_hdl = *((uint8_t *)(link_params_addr + 4)); - - return sync_hdl; - } - else - { - BT_DRV_TRACE(0,"BT_DRV:no need to get sco hdl\n"); - } - +uint8_t bt_drv_reg_op_lmp_sco_hdl_get(uint16_t sco_handle) { + if (sco_handle == 0xffff) { return 0; + } + + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_1) { + // uint32_t lc_sco_env_addr = 0xc000079c; + uint16_t sco_link_id = ((sco_handle >> 8) - 1); + uint32_t link_params_addr = + *((uint32_t *)(lc_sco_env_addr + sco_link_id * 8)); + uint8_t sync_hdl = 0; + + if (sco_link_id > 2 || link_params_addr == 0) { + return 0; + } + + sync_hdl = *((uint8_t *)(link_params_addr + 4)); + + return sync_hdl; + } else { + BT_DRV_TRACE(0, "BT_DRV:no need to get sco hdl\n"); + } + + return 0; } -bool bt_drv_reg_op_lmp_sco_hdl_set(uint16_t sco_handle, uint8_t lmp_hdl) -{ - if (sco_handle == 0xffff || lmp_hdl == 0x00) - { - return false; - } - - if(hal_get_chip_metal_id()==HAL_CHIP_METAL_ID_1) - { - // uint32_t lc_sco_env_addr = 0xc000079c; - uint16_t sco_link_id = ((sco_handle >> 8) - 1); - uint32_t link_params_addr = *((uint32_t *)(lc_sco_env_addr + sco_link_id * 8)); - uint8_t *p_sync_hdl = 0; - - if (sco_link_id > 2 || link_params_addr == 0) - { - return false; - } - - p_sync_hdl = (uint8_t *)(link_params_addr + 4); - - *p_sync_hdl = lmp_hdl; - return true; - } - else - { - BT_DRV_TRACE(0,"BT_DRV:no need to set sco hdl\n"); - } - +bool bt_drv_reg_op_lmp_sco_hdl_set(uint16_t sco_handle, uint8_t lmp_hdl) { + if (sco_handle == 0xffff || lmp_hdl == 0x00) { return false; + } + + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_1) { + // uint32_t lc_sco_env_addr = 0xc000079c; + uint16_t sco_link_id = ((sco_handle >> 8) - 1); + uint32_t link_params_addr = + *((uint32_t *)(lc_sco_env_addr + sco_link_id * 8)); + uint8_t *p_sync_hdl = 0; + + if (sco_link_id > 2 || link_params_addr == 0) { + return false; + } + + p_sync_hdl = (uint8_t *)(link_params_addr + 4); + + *p_sync_hdl = lmp_hdl; + return true; + } else { + BT_DRV_TRACE(0, "BT_DRV:no need to set sco hdl\n"); + } + + return false; } -void bt_drv_reg_op_host_buff_and_flow_ctl_set -(uint16_t acl_pkt_len, uint16_t acl_pkt_num,uint16_t sync_pkt_len, uint16_t sync_pkt_num,bool flow_ctl_en) -{ - uint32_t acl_pkt_len_addr = 0; - uint32_t acl_pkt_num_addr = 0; - uint32_t sync_pkt_len_addr = 0; - uint32_t sync_pkt_num_addr = 0; - uint32_t flow_ctl_addr = 0; +void bt_drv_reg_op_host_buff_and_flow_ctl_set(uint16_t acl_pkt_len, + uint16_t acl_pkt_num, + uint16_t sync_pkt_len, + uint16_t sync_pkt_num, + bool flow_ctl_en) { + uint32_t acl_pkt_len_addr = 0; + uint32_t acl_pkt_num_addr = 0; + uint32_t sync_pkt_len_addr = 0; + uint32_t sync_pkt_num_addr = 0; + uint32_t flow_ctl_addr = 0; + if (hci_fc_env_addr) { + flow_ctl_addr = hci_fc_env_addr; + } - if(hci_fc_env_addr) - { - flow_ctl_addr = hci_fc_env_addr; - } + if (flow_ctl_addr != 0) { + // hci_fc_env.host_set.acl_pkt_len + acl_pkt_len_addr = flow_ctl_addr + 2; + // hci_fc_env.host_set.acl_pkt_num + acl_pkt_num_addr = flow_ctl_addr + 4; + // hci_fc_env.host_set.sync_pkt_len; + sync_pkt_len_addr = flow_ctl_addr + 9; + // hci_fc_env.host_set.sync_pkt_nb; + sync_pkt_num_addr = flow_ctl_addr + 10; - if(flow_ctl_addr != 0) - { - //hci_fc_env.host_set.acl_pkt_len - acl_pkt_len_addr = flow_ctl_addr+2; - //hci_fc_env.host_set.acl_pkt_num - acl_pkt_num_addr = flow_ctl_addr+4; - //hci_fc_env.host_set.sync_pkt_len; - sync_pkt_len_addr = flow_ctl_addr+9; - //hci_fc_env.host_set.sync_pkt_nb; - sync_pkt_num_addr = flow_ctl_addr+10; + BT_DRV_TRACE(6, + "Fast_bt_init2:%s,acl len=%x,acl num=%x,sync len=%x sync " + "num=%x,fl_ctl=%d", + __func__, acl_pkt_len, acl_pkt_num, sync_pkt_len, sync_pkt_num, + flow_ctl_en); - BT_DRV_TRACE(6,"Fast_bt_init2:%s,acl len=%x,acl num=%x,sync len=%x sync num=%x,fl_ctl=%d", - __func__,acl_pkt_len,acl_pkt_num,sync_pkt_len,sync_pkt_num,flow_ctl_en); - - *(uint8_t *)flow_ctl_addr = flow_ctl_en; - *(uint16_t *)acl_pkt_len_addr = acl_pkt_len; - *(uint16_t *)acl_pkt_num_addr = acl_pkt_num; - *(uint8_t *)sync_pkt_len_addr = sync_pkt_len; - *(uint16_t *)sync_pkt_num_addr = sync_pkt_num; - } + *(uint8_t *)flow_ctl_addr = flow_ctl_en; + *(uint16_t *)acl_pkt_len_addr = acl_pkt_len; + *(uint16_t *)acl_pkt_num_addr = acl_pkt_num; + *(uint8_t *)sync_pkt_len_addr = sync_pkt_len; + *(uint16_t *)sync_pkt_num_addr = sync_pkt_num; + } } -void bt_drv_reg_op_page_to_set(uint16_t page_to) -{ - BT_DRV_REG_OP_ENTER(); - uint32_t page_to_addr = 0; +void bt_drv_reg_op_page_to_set(uint16_t page_to) { + BT_DRV_REG_OP_ENTER(); + uint32_t page_to_addr = 0; + if (lm_env_addr) { + page_to_addr = lm_env_addr + 20; + } - if(lm_env_addr) - { - page_to_addr = lm_env_addr + 20; - } - - if(page_to_addr != 0) - { - BT_DRV_TRACE(2,"Fast_bt_init3:%s,to=%x",__func__,page_to); - *(uint16_t *)page_to_addr = page_to; - } - BT_DRV_REG_OP_EXIT(); + if (page_to_addr != 0) { + BT_DRV_TRACE(2, "Fast_bt_init3:%s,to=%x", __func__, page_to); + *(uint16_t *)page_to_addr = page_to; + } + BT_DRV_REG_OP_EXIT(); } -void bt_drv_reg_op_btdm_address_set(uint8_t* bt_addr, uint8_t* ble_addr) -{ - BT_DRV_REG_OP_ENTER(); - uint32_t btaddr_addr = 0; - uint32_t bleaddr_addr = 0; - uint32_t bch_addr = 0; +void bt_drv_reg_op_btdm_address_set(uint8_t *bt_addr, uint8_t *ble_addr) { + BT_DRV_REG_OP_ENTER(); + uint32_t btaddr_addr = 0; + uint32_t bleaddr_addr = 0; + uint32_t bch_addr = 0; + if (llm_le_env_addr) { + bleaddr_addr = llm_le_env_addr + 0x8f; + } - if(llm_le_env_addr) - { - bleaddr_addr = llm_le_env_addr+0x8f; + if (ld_env_addr) { + btaddr_addr = ld_env_addr; + bch_addr = btaddr_addr + 451; + } + + if (bleaddr_addr != 0) { + BT_DRV_TRACE(1, "Fast_bt_init4:%s", __func__); + DUMP8("%02x ", bt_addr, 6); + DUMP8("%02x ", ble_addr, 6); + + for (uint8_t i = 0; i < 6; i++) { + *(uint8_t *)(bleaddr_addr + i) = ble_addr[i]; } - if(ld_env_addr) - { - btaddr_addr = ld_env_addr; - bch_addr = btaddr_addr+451; - + for (uint8_t i = 0; i < 6; i++) { + *(uint8_t *)(btaddr_addr + i) = bt_addr[i]; } - - if(bleaddr_addr != 0) - { - BT_DRV_TRACE(1,"Fast_bt_init4:%s",__func__); - DUMP8("%02x ",bt_addr,6); - DUMP8("%02x ",ble_addr,6); - - for(uint8_t i=0; i<6; i++) - { - *(uint8_t *)(bleaddr_addr+i) = ble_addr[i]; - } - - for(uint8_t i=0; i<6; i++) - { - *(uint8_t *)(btaddr_addr+i) = bt_addr[i]; - } - ld_util_bch_create(bt_addr,(uint8_t *)bch_addr); - } - BT_DRV_REG_OP_EXIT(); + ld_util_bch_create(bt_addr, (uint8_t *)bch_addr); + } + BT_DRV_REG_OP_EXIT(); } -void bt_drv_reg_op_evtmask_set(uint8_t ble_en) -{ - BT_DRV_REG_OP_ENTER(); - uint32_t bt_evtmsk_addr = 0; - uint32_t ble_evtmask_addr = 0; +void bt_drv_reg_op_evtmask_set(uint8_t ble_en) { + BT_DRV_REG_OP_ENTER(); + uint32_t bt_evtmsk_addr = 0; + uint32_t ble_evtmask_addr = 0; - if(llm_le_env_addr) - { - ble_evtmask_addr = llm_le_env_addr+0x64; + if (llm_le_env_addr) { + ble_evtmask_addr = llm_le_env_addr + 0x64; + } + + if (hci_env_addr) { + bt_evtmsk_addr = hci_env_addr; + } + + if (bt_evtmsk_addr != 0) { + BT_DRV_TRACE(2, "Fast_bt_init5:%s,ble enable=%x", __func__, ble_en); + uint8_t bt_mask[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f}; + if (ble_en) { + bt_mask[7] = 0x3f; } + memcpy((uint8_t *)bt_evtmsk_addr, bt_mask, 8); - - if(hci_env_addr) - { - bt_evtmsk_addr = hci_env_addr; - } - - if(bt_evtmsk_addr != 0) - { - BT_DRV_TRACE(2,"Fast_bt_init5:%s,ble enable=%x",__func__,ble_en); - uint8_t bt_mask[8]= {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f}; - if(ble_en) - { - bt_mask[7] = 0x3f; - } - memcpy((uint8_t *)bt_evtmsk_addr,bt_mask,8); - - uint8_t ble_mask[8]= {0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; - memcpy((uint8_t *)ble_evtmask_addr,ble_mask,8); - } - BT_DRV_REG_OP_EXIT(); + uint8_t ble_mask[8] = {0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + memcpy((uint8_t *)ble_evtmask_addr, ble_mask, 8); + } + BT_DRV_REG_OP_EXIT(); } -void bt_drv_reg_op_simplepair_mode_set(uint8_t en) -{ - BT_DRV_REG_OP_ENTER(); +void bt_drv_reg_op_simplepair_mode_set(uint8_t en) { + BT_DRV_REG_OP_ENTER(); - if(lm_env_addr) - { - *(uint8_t *)(lm_env_addr+44) = en; - } + if (lm_env_addr) { + *(uint8_t *)(lm_env_addr + 44) = en; + } - BT_DRV_REG_OP_EXIT(); + BT_DRV_REG_OP_EXIT(); } -void bt_drv_reg_op_class_of_dev_set(uint8_t* class_of_dev,uint8_t len) -{ - BT_DRV_REG_OP_ENTER(); - uint32_t class_of_dev_addr = 0; +void bt_drv_reg_op_class_of_dev_set(uint8_t *class_of_dev, uint8_t len) { + BT_DRV_REG_OP_ENTER(); + uint32_t class_of_dev_addr = 0; + if (ld_env_addr) { + // ld_env.class_of_dev.A + class_of_dev_addr = ld_env_addr + 6; + } - - if(ld_env_addr) - { - //ld_env.class_of_dev.A - class_of_dev_addr = ld_env_addr+6; - } - - if(class_of_dev_addr != 0) - { - BT_DRV_TRACE(1,"Fast_bt_init7:%s",__func__); - DUMP8("%02x ",class_of_dev,3); - memcpy((uint8_t *)class_of_dev_addr, class_of_dev, 3); - } - BT_DRV_REG_OP_EXIT(); + if (class_of_dev_addr != 0) { + BT_DRV_TRACE(1, "Fast_bt_init7:%s", __func__); + DUMP8("%02x ", class_of_dev, 3); + memcpy((uint8_t *)class_of_dev_addr, class_of_dev, 3); + } + BT_DRV_REG_OP_EXIT(); } -void bt_drv_reg_op_sleep_set(bool en) -{ - BT_DRV_REG_OP_ENTER(); - uint32_t sleep_addr = 0; +void bt_drv_reg_op_sleep_set(bool en) { + BT_DRV_REG_OP_ENTER(); + uint32_t sleep_addr = 0; - if(rwip_env_addr) - { - sleep_addr = rwip_env_addr+12; - } + if (rwip_env_addr) { + sleep_addr = rwip_env_addr + 12; + } - if(sleep_addr != 0) - { - BT_DRV_TRACE(2,"Fast_bt_init:%s en=%d",__func__,en); - *(uint8_t *)(sleep_addr) = en; - } - BT_DRV_REG_OP_EXIT(); + if (sleep_addr != 0) { + BT_DRV_TRACE(2, "Fast_bt_init:%s en=%d", __func__, en); + *(uint8_t *)(sleep_addr) = en; + } + BT_DRV_REG_OP_EXIT(); } -void bt_drv_reg_op_sco_fifo_reset(void) -{ - uint16_t sco_ptr0 = 0, sco_ptr1 = 0; - uint8_t *em_area_base = (uint8_t*)0xd0210000; +void bt_drv_reg_op_sco_fifo_reset(void) { + uint16_t sco_ptr0 = 0, sco_ptr1 = 0; + uint8_t *em_area_base = (uint8_t *)0xd0210000; - BT_DRV_REG_OP_ENTER(); - BTDIGITAL_REG_GET_FIELD(0xd02201cc, 0xffff, 0, sco_ptr0); - BTDIGITAL_REG_GET_FIELD(0xd02201cc, 0xffff, 16, sco_ptr1); - BT_DRV_TRACE(3,"bt_drv_reg_op_sco_fifo_reset %d/%d %08x",sco_ptr0, sco_ptr1, BTDIGITAL_REG(0xd02201cc)); - memset(em_area_base+sco_ptr0, 0x55, 60); - memset(em_area_base+sco_ptr1, 0x55, 60); - BT_DRV_REG_OP_EXIT(); + BT_DRV_REG_OP_ENTER(); + BTDIGITAL_REG_GET_FIELD(0xd02201cc, 0xffff, 0, sco_ptr0); + BTDIGITAL_REG_GET_FIELD(0xd02201cc, 0xffff, 16, sco_ptr1); + BT_DRV_TRACE(3, "bt_drv_reg_op_sco_fifo_reset %d/%d %08x", sco_ptr0, sco_ptr1, + BTDIGITAL_REG(0xd02201cc)); + memset(em_area_base + sco_ptr0, 0x55, 60); + memset(em_area_base + sco_ptr1, 0x55, 60); + BT_DRV_REG_OP_EXIT(); } -void bt_drv_reg_sco_fifo_dump(void) -{ - uint16_t sco_ptr0 = 0, sco_ptr1 = 0; - uint8_t *em_area_base = (uint8_t*)0xd0210000; - BT_DRV_REG_OP_ENTER(); - BTDIGITAL_REG_GET_FIELD(0xd02201cc, 0xffff, 0, sco_ptr0); - BTDIGITAL_REG_GET_FIELD(0xd02201cc, 0xffff, 16, sco_ptr1); - BT_DRV_TRACE(3,"bt_drv_reg_op_sco_fifo_reset %d/%d %08x",sco_ptr0, sco_ptr1, BTDIGITAL_REG(0xd02201cc)); - DUMP8("%02x ", em_area_base+sco_ptr0, 10); - DUMP8("%02x ", em_area_base+sco_ptr1, 10); - BT_DRV_REG_OP_EXIT(); +void bt_drv_reg_sco_fifo_dump(void) { + uint16_t sco_ptr0 = 0, sco_ptr1 = 0; + uint8_t *em_area_base = (uint8_t *)0xd0210000; + BT_DRV_REG_OP_ENTER(); + BTDIGITAL_REG_GET_FIELD(0xd02201cc, 0xffff, 0, sco_ptr0); + BTDIGITAL_REG_GET_FIELD(0xd02201cc, 0xffff, 16, sco_ptr1); + BT_DRV_TRACE(3, "bt_drv_reg_op_sco_fifo_reset %d/%d %08x", sco_ptr0, sco_ptr1, + BTDIGITAL_REG(0xd02201cc)); + DUMP8("%02x ", em_area_base + sco_ptr0, 10); + DUMP8("%02x ", em_area_base + sco_ptr1, 10); + BT_DRV_REG_OP_EXIT(); } -uint8_t bt_drv_reg_op_get_sync_id_op(uint8_t op, uint8_t sync_id) -{ - uint8_t sync_link_id = 0xff; - BT_DRV_REG_OP_ENTER(); +uint8_t bt_drv_reg_op_get_sync_id_op(uint8_t op, uint8_t sync_id) { + uint8_t sync_link_id = 0xff; + BT_DRV_REG_OP_ENTER(); - uint32_t sync_id_addr = 0; - //only 2300P chip id =1 need this hack - if(hal_get_chip_metal_id()==HAL_CHIP_METAL_ID_1) - { - sync_id_addr =(sniffer_env_addr+ 0x3c); + uint32_t sync_id_addr = 0; + // only 2300P chip id =1 need this hack + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_1) { + sync_id_addr = (sniffer_env_addr + 0x3c); + } + + if (sync_id_addr != 0) { + if (READ_OP == op) { + sync_link_id = *(uint8_t *)(sync_id_addr); + } else if (WRITE_OP == op) { + *(uint8_t *)(sync_id_addr) = sync_id; } + } + BT_DRV_REG_OP_EXIT(); - if(sync_id_addr != 0) - { - if(READ_OP == op) - { - sync_link_id = *(uint8_t *)(sync_id_addr); - } - else if(WRITE_OP == op) - { - *(uint8_t *)(sync_id_addr) = sync_id; - } - } - BT_DRV_REG_OP_EXIT(); - - return sync_link_id; + return sync_link_id; } -void bt_drv_reg_op_disable_reporting_en(uint16_t conhdl) -{ - BT_DRV_REG_OP_ENTER(); - uint32_t lc_evt_ptr = 0x0; - uint32_t report_en_addr; - uint8_t linkid = btdrv_conhdl_to_linkid(conhdl); +void bt_drv_reg_op_disable_reporting_en(uint16_t conhdl) { + BT_DRV_REG_OP_ENTER(); + uint32_t lc_evt_ptr = 0x0; + uint32_t report_en_addr; + uint8_t linkid = btdrv_conhdl_to_linkid(conhdl); - if (btdrv_is_link_index_valid(linkid)) - { - if(lc_env_addr) - { - lc_evt_ptr = *(volatile uint32_t *)(lc_env_addr+linkid*4);//lc_env - report_en_addr = lc_evt_ptr+0x28a; - *(uint8_t *)report_en_addr = 0; - BT_DRV_TRACE(0,"REG_OP:disable afh report"); - } + if (btdrv_is_link_index_valid(linkid)) { + if (lc_env_addr) { + lc_evt_ptr = *(volatile uint32_t *)(lc_env_addr + linkid * 4); // lc_env + report_en_addr = lc_evt_ptr + 0x28a; + *(uint8_t *)report_en_addr = 0; + BT_DRV_TRACE(0, "REG_OP:disable afh report"); } - BT_DRV_REG_OP_EXIT(); + } + BT_DRV_REG_OP_EXIT(); } -uint8_t bt_drv_reg_opcheck_controller_ld_lc_layer_mismatch(void) -{ - uint8_t cnt = 0; - BT_DRV_REG_OP_ENTER(); - if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_1) - { - for(uint8_t link_id=0; link_id<3; link_id++) - { - uint32_t ld_acl_evt_ptr = 0; - uint32_t lc_evt_ptr = 0; - ld_acl_evt_ptr= *(uint32_t *)(ld_acl_env_addr+link_id*4); - lc_evt_ptr = *(volatile uint32_t *)(lc_env_addr+link_id*4); - if((ld_acl_evt_ptr && !lc_evt_ptr) || - (!ld_acl_evt_ptr && lc_evt_ptr) ) - { - cnt ++; - } - } +uint8_t bt_drv_reg_opcheck_controller_ld_lc_layer_mismatch(void) { + uint8_t cnt = 0; + BT_DRV_REG_OP_ENTER(); + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_1) { + for (uint8_t link_id = 0; link_id < 3; link_id++) { + uint32_t ld_acl_evt_ptr = 0; + uint32_t lc_evt_ptr = 0; + ld_acl_evt_ptr = *(uint32_t *)(ld_acl_env_addr + link_id * 4); + lc_evt_ptr = *(volatile uint32_t *)(lc_env_addr + link_id * 4); + if ((ld_acl_evt_ptr && !lc_evt_ptr) || (!ld_acl_evt_ptr && lc_evt_ptr)) { + cnt++; + } } - BT_DRV_REG_OP_EXIT(); - return cnt; + } + BT_DRV_REG_OP_EXIT(); + return cnt; } -void bt_drv_reg_op_ble_sup_timeout_set(uint16_t ble_conhdl, uint16_t sup_to) -{ - uint32_t llc_env_ptr = 0; +void bt_drv_reg_op_ble_sup_timeout_set(uint16_t ble_conhdl, uint16_t sup_to) { + uint32_t llc_env_ptr = 0; - if(llc_env_addr) - { - uint32_t llc_env_address = llc_env_addr+ble_conhdl*4; - llc_env_ptr = *(volatile uint32_t *)llc_env_address; - } + if (llc_env_addr) { + uint32_t llc_env_address = llc_env_addr + ble_conhdl * 4; + llc_env_ptr = *(volatile uint32_t *)llc_env_address; + } - if(llc_env_ptr != 0) - { - uint32_t llc_env_sup_to_address = llc_env_ptr + 0x54; - *(volatile uint16_t *)llc_env_sup_to_address = sup_to; - BT_DRV_TRACE(1,"BT_DRV:set ble sup_timeout to %d",sup_to); - } + if (llc_env_ptr != 0) { + uint32_t llc_env_sup_to_address = llc_env_ptr + 0x54; + *(volatile uint16_t *)llc_env_sup_to_address = sup_to; + BT_DRV_TRACE(1, "BT_DRV:set ble sup_timeout to %d", sup_to); + } } -void bt_drv_reg_op_disable_swagc_nosync_count(void) -{ - if(dbg_bt_setting_ext1_addr) - { - *(uint16_t *)(dbg_bt_setting_ext1_addr+0x14) = 0xa604; - } +void bt_drv_reg_op_disable_swagc_nosync_count(void) { + if (dbg_bt_setting_ext1_addr) { + *(uint16_t *)(dbg_bt_setting_ext1_addr + 0x14) = 0xa604; + } } -void bt_drv_reg_op_hw_sw_agc_select(uint8_t agc_mode) -{ - uint32_t hw_agc_select_addr = 0; - BT_DRV_REG_OP_ENTER(); +void bt_drv_reg_op_hw_sw_agc_select(uint8_t agc_mode) { + uint32_t hw_agc_select_addr = 0; + BT_DRV_REG_OP_ENTER(); + if (rwip_rf_addr) { + hw_agc_select_addr = rwip_rf_addr + 0x37; + } + if (hw_agc_select_addr != 0) { + *(volatile uint8_t *)hw_agc_select_addr = agc_mode; + } - if(rwip_rf_addr) - { - hw_agc_select_addr = rwip_rf_addr+0x37; - } - if(hw_agc_select_addr != 0) - { - *(volatile uint8_t *)hw_agc_select_addr = agc_mode; - } - - BT_DRV_REG_OP_EXIT(); + BT_DRV_REG_OP_EXIT(); } -void ble_maxevtime_set(int elt_idx, uint16_t value) -{ - BTDIGITAL_EM_BT_WR(BLE_MAXEVTIME_ADDR + elt_idx * BLE_EM_CS_SIZE, value); +void ble_maxevtime_set(int elt_idx, uint16_t value) { + BTDIGITAL_EM_BT_WR(BLE_MAXEVTIME_ADDR + elt_idx * BLE_EM_CS_SIZE, value); } -uint16_t ble_maxevtime_get(int elt_idx) -{ - return BTDIGITAL_BT_EM(BLE_MAXEVTIME_ADDR + elt_idx * BLE_EM_CS_SIZE); +uint16_t ble_maxevtime_get(int elt_idx) { + return BTDIGITAL_BT_EM(BLE_MAXEVTIME_ADDR + elt_idx * BLE_EM_CS_SIZE); } -void bt_drv_reg_op_afh_follow_en(bool enable, uint8_t be_followed_link_id, uint8_t follow_link_id) -{ +void bt_drv_reg_op_afh_follow_en(bool enable, uint8_t be_followed_link_id, + uint8_t follow_link_id) { #if BT_AFH_FOLLOW - if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) - { - *(uint8_t *)(lm_env_addr+0x168) = be_followed_link_id;//be follow follow link id - *(uint8_t *)(lm_env_addr+0x169) = follow_link_id;//follow link id - *(uint8_t *)(lm_env_addr+0x167) = enable; //afh follow enable - } + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) { + *(uint8_t *)(lm_env_addr + 0x168) = + be_followed_link_id; // be follow follow link id + *(uint8_t *)(lm_env_addr + 0x169) = follow_link_id; // follow link id + *(uint8_t *)(lm_env_addr + 0x167) = enable; // afh follow enable + } #endif } -void bt_drv_reg_op_set_agc_thd(bool isMaster, bool isSco) -{ - BT_DRV_REG_OP_ENTER(); - if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) - { - ASSERT(*(uint32_t *)0xc00072ec ==0xc0007310,"patch ERROR 2300p t2 bt_drv_reg_op_set_agc_thd!"); - BT_DRV_TRACE(1,"isMaster: %d, isSco: %d ",isMaster,isSco); - if(isMaster) - { - if(isSco) - { - BTDIGITAL_REG(0xc0007310)=0x00000020;//link_agc_thd_mobile_time£¬ reg address£º0xc0007310 - BTDIGITAL_REG(0xc0007300)=0x00000020;//link_agc_thd_tws_time£¬ reg address£º0xc0007300 - } - else - { - BTDIGITAL_REG(0xc0007310)=0x00000038;//link_agc_thd_mobile_time£¬ reg address£º0xc0007310 - BTDIGITAL_REG(0xc0007300)=0x00000038;//link_agc_thd_tws_time£¬ reg address£º0xc0007300 - } - } - else - { - if(isSco) - { - BTDIGITAL_REG(0xc0007310)=0x00000020;//link_agc_thd_mobile_time£¬ reg address£º0xc0007310 - BTDIGITAL_REG(0xc0007300)=0x00000020;//link_agc_thd_tws_time£¬ reg address£º0xc0007300 - } - else - { - BTDIGITAL_REG(0xc0007310)=0x00000038;//link_agc_thd_mobile_time£¬ reg address£º0xc0007310 - BTDIGITAL_REG(0xc0007300)=0x00000038;//link_agc_thd_tws_time£¬ reg address£º0xc0007300 - } - } +void bt_drv_reg_op_set_agc_thd(bool isMaster, bool isSco) { + BT_DRV_REG_OP_ENTER(); + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) { + ASSERT(*(uint32_t *)0xc00072ec == 0xc0007310, + "patch ERROR 2300p t2 bt_drv_reg_op_set_agc_thd!"); + BT_DRV_TRACE(1, "isMaster: %d, isSco: %d ", isMaster, isSco); + if (isMaster) { + if (isSco) { + BTDIGITAL_REG(0xc0007310) = + 0x00000020; // link_agc_thd_mobile_time£¬ reg address£º0xc0007310 + BTDIGITAL_REG(0xc0007300) = + 0x00000020; // link_agc_thd_tws_time£¬ reg address£º0xc0007300 + } else { + BTDIGITAL_REG(0xc0007310) = + 0x00000038; // link_agc_thd_mobile_time£¬ reg address£º0xc0007310 + BTDIGITAL_REG(0xc0007300) = + 0x00000038; // link_agc_thd_tws_time£¬ reg address£º0xc0007300 + } + } else { + if (isSco) { + BTDIGITAL_REG(0xc0007310) = + 0x00000020; // link_agc_thd_mobile_time£¬ reg address£º0xc0007310 + BTDIGITAL_REG(0xc0007300) = + 0x00000020; // link_agc_thd_tws_time£¬ reg address£º0xc0007300 + } else { + BTDIGITAL_REG(0xc0007310) = + 0x00000038; // link_agc_thd_mobile_time£¬ reg address£º0xc0007310 + BTDIGITAL_REG(0xc0007300) = + 0x00000038; // link_agc_thd_tws_time£¬ reg address£º0xc0007300 + } } - BT_DRV_REG_OP_EXIT(); + } + BT_DRV_REG_OP_EXIT(); } -void bt_drv_reg_op_force_set_sniff_att(uint16_t conhdle) -{ - BT_DRV_REG_OP_ENTER(); - uint8_t linkid = btdrv_conhdl_to_linkid(conhdle); - uint32_t acl_evt_ptr = 0x0; +void bt_drv_reg_op_force_set_sniff_att(uint16_t conhdle) { + BT_DRV_REG_OP_ENTER(); + uint8_t linkid = btdrv_conhdl_to_linkid(conhdle); + uint32_t acl_evt_ptr = 0x0; - if (btdrv_is_link_index_valid(linkid)) - { - if(hal_get_chip_metal_id()==HAL_CHIP_METAL_ID_1) - { - acl_evt_ptr=*(volatile uint32_t *)(0xc0000998+linkid*4);//ld_acl_env - } - else if(hal_get_chip_metal_id()==HAL_CHIP_METAL_ID_2) - { - acl_evt_ptr=*(volatile uint32_t *)(0xc00009d4+linkid*4);//ld_acl_env - } - - if (acl_evt_ptr != 0) - { - uint32_t sniff_att_addr = acl_evt_ptr + 0xe2; - if(BT_DRIVER_GET_U16_REG_VAL(sniff_att_addr) <3) - { - BT_DRIVER_PUT_U16_REG_VAL(sniff_att_addr, 3); - } - //set sniff timeout to 0 - BT_DRIVER_PUT_U16_REG_VAL(sniff_att_addr+4, 0); - - BT_DRV_TRACE(0,"BT_REG_OP:force set sniff att"); - } + if (btdrv_is_link_index_valid(linkid)) { + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_1) { + acl_evt_ptr = + *(volatile uint32_t *)(0xc0000998 + linkid * 4); // ld_acl_env + } else if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) { + acl_evt_ptr = + *(volatile uint32_t *)(0xc00009d4 + linkid * 4); // ld_acl_env } - BT_DRV_REG_OP_EXIT(); + + if (acl_evt_ptr != 0) { + uint32_t sniff_att_addr = acl_evt_ptr + 0xe2; + if (BT_DRIVER_GET_U16_REG_VAL(sniff_att_addr) < 3) { + BT_DRIVER_PUT_U16_REG_VAL(sniff_att_addr, 3); + } + // set sniff timeout to 0 + BT_DRIVER_PUT_U16_REG_VAL(sniff_att_addr + 4, 0); + + BT_DRV_TRACE(0, "BT_REG_OP:force set sniff att"); + } + } + BT_DRV_REG_OP_EXIT(); } -void bt_drv_reg_op_fa_gain_direct_set(uint8_t gain_idx) -{ - BTDIGITAL_REG(0xd0220484) = (BTDIGITAL_REG(0xd0220484)&(~0xffff))|0x9401|(gain_idx << 1); //lxd 20191105 fixed ecc receive gain +void bt_drv_reg_op_fa_gain_direct_set(uint8_t gain_idx) { + BTDIGITAL_REG(0xd0220484) = + (BTDIGITAL_REG(0xd0220484) & (~0xffff)) | 0x9401 | + (gain_idx << 1); // lxd 20191105 fixed ecc receive gain } -uint8_t bt_drv_reg_op_fa_gain_direct_get(void) -{ - uint32_t raw_reg = BTDIGITAL_REG(0xd0220484); - return (raw_reg >> 1)&0x07; +uint8_t bt_drv_reg_op_fa_gain_direct_get(void) { + uint32_t raw_reg = BTDIGITAL_REG(0xd0220484); + return (raw_reg >> 1) & 0x07; } -struct rx_gain_fixed_t -{ - uint8_t enable;//enable or disable - uint8_t bt_or_ble;//0:bt 1:ble - uint8_t cs_id;//link id - uint8_t gain_idx;//gain index +struct rx_gain_fixed_t { + uint8_t enable; // enable or disable + uint8_t bt_or_ble; // 0:bt 1:ble + uint8_t cs_id; // link id + uint8_t gain_idx; // gain index }; -void bt_drv_reg_op_dgb_link_gain_ctrl_set(uint16_t connHandle, uint8_t bt_ble_mode, uint8_t gain_idx, uint8_t enable) -{ - if(hal_get_chip_metal_id() <= HAL_CHIP_METAL_ID_1) - { - TRACE(1,"%s to all link", __func__); - uint16_t raw_reg = *((volatile uint16_t*)0xc00041ec); - if (bt_ble_mode) - { - raw_reg = raw_reg & (~0xff<<8); - raw_reg = raw_reg | (gain_idx<<8); - } - else - { - raw_reg = raw_reg & ~0xff; - raw_reg = raw_reg | gain_idx; - } - *((volatile uint16_t*)0xc00041ec) = raw_reg; +void bt_drv_reg_op_dgb_link_gain_ctrl_set(uint16_t connHandle, + uint8_t bt_ble_mode, uint8_t gain_idx, + uint8_t enable) { + if (hal_get_chip_metal_id() <= HAL_CHIP_METAL_ID_1) { + TRACE(1, "%s to all link", __func__); + uint16_t raw_reg = *((volatile uint16_t *)0xc00041ec); + if (bt_ble_mode) { + raw_reg = raw_reg & (~0xff << 8); + raw_reg = raw_reg | (gain_idx << 8); + } else { + raw_reg = raw_reg & ~0xff; + raw_reg = raw_reg | gain_idx; } + *((volatile uint16_t *)0xc00041ec) = raw_reg; + } - struct rx_gain_fixed_t *rx_gain_fixed_p = (struct rx_gain_fixed_t *)0xc00004dc; - uint8_t cs_id = btdrv_conhdl_to_linkid(connHandle); + struct rx_gain_fixed_t *rx_gain_fixed_p = + (struct rx_gain_fixed_t *)0xc00004dc; + uint8_t cs_id = btdrv_conhdl_to_linkid(connHandle); - if (btdrv_is_link_index_valid(cs_id)) - { - for (uint8_t i=0; i<3; i++) - { - if ((rx_gain_fixed_p->cs_id == cs_id) && - (rx_gain_fixed_p->bt_or_ble == bt_ble_mode)) - { - rx_gain_fixed_p->enable = enable; - rx_gain_fixed_p->bt_or_ble = bt_ble_mode; - rx_gain_fixed_p->gain_idx = gain_idx; - BT_DRV_TRACE(5,"%s hdl:%x/%x mode:%d idx:%d", __func__, connHandle, cs_id, rx_gain_fixed_p->bt_or_ble, gain_idx); - } - rx_gain_fixed_p++; - } + if (btdrv_is_link_index_valid(cs_id)) { + for (uint8_t i = 0; i < 3; i++) { + if ((rx_gain_fixed_p->cs_id == cs_id) && + (rx_gain_fixed_p->bt_or_ble == bt_ble_mode)) { + rx_gain_fixed_p->enable = enable; + rx_gain_fixed_p->bt_or_ble = bt_ble_mode; + rx_gain_fixed_p->gain_idx = gain_idx; + BT_DRV_TRACE(5, "%s hdl:%x/%x mode:%d idx:%d", __func__, connHandle, + cs_id, rx_gain_fixed_p->bt_or_ble, gain_idx); + } + rx_gain_fixed_p++; } + } } -void bt_drv_reg_op_dgb_link_gain_ctrl_clear(uint16_t connHandle, uint8_t bt_ble_mode) -{ - if(hal_get_chip_metal_id() <= HAL_CHIP_METAL_ID_1) - { - BT_DRV_TRACE(1,"%s REG_OP: not support", __func__); - } +void bt_drv_reg_op_dgb_link_gain_ctrl_clear(uint16_t connHandle, + uint8_t bt_ble_mode) { + if (hal_get_chip_metal_id() <= HAL_CHIP_METAL_ID_1) { + BT_DRV_TRACE(1, "%s REG_OP: not support", __func__); + } - struct rx_gain_fixed_t *rx_gain_fixed_p = (struct rx_gain_fixed_t *)0xc00004dc; - uint8_t cs_id = btdrv_conhdl_to_linkid(connHandle); + struct rx_gain_fixed_t *rx_gain_fixed_p = + (struct rx_gain_fixed_t *)0xc00004dc; + uint8_t cs_id = btdrv_conhdl_to_linkid(connHandle); - if (btdrv_is_link_index_valid(cs_id)) - { - for (uint8_t i=0; i<3; i++) - { - if ((rx_gain_fixed_p->cs_id == cs_id) && - (rx_gain_fixed_p->bt_or_ble == bt_ble_mode)) - { - rx_gain_fixed_p->enable = 0; - rx_gain_fixed_p->bt_or_ble = bt_ble_mode; - rx_gain_fixed_p->gain_idx = 0; - } - rx_gain_fixed_p++; - } + if (btdrv_is_link_index_valid(cs_id)) { + for (uint8_t i = 0; i < 3; i++) { + if ((rx_gain_fixed_p->cs_id == cs_id) && + (rx_gain_fixed_p->bt_or_ble == bt_ble_mode)) { + rx_gain_fixed_p->enable = 0; + rx_gain_fixed_p->bt_or_ble = bt_ble_mode; + rx_gain_fixed_p->gain_idx = 0; + } + rx_gain_fixed_p++; } + } } -void bt_drv_reg_op_dgb_link_gain_ctrl_init(void) -{ - if(hal_get_chip_metal_id() <= HAL_CHIP_METAL_ID_1) - { - BT_DRV_TRACE(1,"%s REG_OP: not support", __func__); - } +void bt_drv_reg_op_dgb_link_gain_ctrl_init(void) { + if (hal_get_chip_metal_id() <= HAL_CHIP_METAL_ID_1) { + BT_DRV_TRACE(1, "%s REG_OP: not support", __func__); + } - struct rx_gain_fixed_t *rx_gain_fixed_p = (struct rx_gain_fixed_t *)0xc00004dc; + struct rx_gain_fixed_t *rx_gain_fixed_p = + (struct rx_gain_fixed_t *)0xc00004dc; - for (uint8_t i=0; i<3; i++) - { - rx_gain_fixed_p->cs_id = i; - rx_gain_fixed_p++; - } + for (uint8_t i = 0; i < 3; i++) { + rx_gain_fixed_p->cs_id = i; + rx_gain_fixed_p++; + } } -void bt_drv_reg_op_rx_gain_fix(uint16_t connHandle, uint8_t bt_ble_mode, uint8_t gain_idx, uint8_t enable, uint8_t table_idx) -{ - if(hal_get_chip_metal_id() <= HAL_CHIP_METAL_ID_1) - { - BT_DRV_TRACE(1,"%s REG_OP: not support", __func__); - } +void bt_drv_reg_op_rx_gain_fix(uint16_t connHandle, uint8_t bt_ble_mode, + uint8_t gain_idx, uint8_t enable, + uint8_t table_idx) { + if (hal_get_chip_metal_id() <= HAL_CHIP_METAL_ID_1) { + BT_DRV_TRACE(1, "%s REG_OP: not support", __func__); + } - struct rx_gain_fixed_t *rx_gain_fixed_p = (struct rx_gain_fixed_t *)0xc00004dc; - uint8_t cs_id; + struct rx_gain_fixed_t *rx_gain_fixed_p = + (struct rx_gain_fixed_t *)0xc00004dc; + uint8_t cs_id; - if(bt_ble_mode == 0)//bt - { - cs_id = btdrv_conhdl_to_linkid(connHandle); - } - else if(bt_ble_mode == 1)//ble - { - cs_id = connHandle; - } - else - { - BT_DRV_TRACE(1,"%s:fix gain fail",__func__); - return; - } + if (bt_ble_mode == 0) // bt + { + cs_id = btdrv_conhdl_to_linkid(connHandle); + } else if (bt_ble_mode == 1) // ble + { + cs_id = connHandle; + } else { + BT_DRV_TRACE(1, "%s:fix gain fail", __func__); + return; + } - if(table_idx < 3) - { - rx_gain_fixed_p[table_idx].enable = enable; - rx_gain_fixed_p[table_idx].bt_or_ble = bt_ble_mode; - rx_gain_fixed_p[table_idx].cs_id = cs_id; - rx_gain_fixed_p[table_idx].gain_idx = gain_idx; - } + if (table_idx < 3) { + rx_gain_fixed_p[table_idx].enable = enable; + rx_gain_fixed_p[table_idx].bt_or_ble = bt_ble_mode; + rx_gain_fixed_p[table_idx].cs_id = cs_id; + rx_gain_fixed_p[table_idx].gain_idx = gain_idx; + } } -void bt_drv_reg_op_set_ibrt_auto_accept_sco(bool en) -{ - if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) - { - ASSERT(*(uint32_t *)0xc0007344 == 0xc0007348,"ibrt_auto_accept_sco PATCH ERROR!!"); - if(en) - { - BTDIGITAL_REG(0xc0007348) = 1; - BT_DRV_TRACE(0,"BT_REG_OP:enable ibrt_auto_accept_sco"); - } - else - { - BTDIGITAL_REG(0xc0007348) = 0; - } +void bt_drv_reg_op_set_ibrt_auto_accept_sco(bool en) { + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) { + ASSERT(*(uint32_t *)0xc0007344 == 0xc0007348, + "ibrt_auto_accept_sco PATCH ERROR!!"); + if (en) { + BTDIGITAL_REG(0xc0007348) = 1; + BT_DRV_TRACE(0, "BT_REG_OP:enable ibrt_auto_accept_sco"); + } else { + BTDIGITAL_REG(0xc0007348) = 0; } + } } -void bt_drv_reg_op_update_dbg_state(void) -{ - if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) - { - ASSERT(*(uint32_t *)0xc00076a0 == 0xc00076a4,"update_dbg_state PATCH ERROR!!"); - BTDIGITAL_REG(0xc00076a4) = 1; - BT_DRV_TRACE(0,"BT_REG_OP:update_dbg_state"); - } +void bt_drv_reg_op_update_dbg_state(void) { + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) { + ASSERT(*(uint32_t *)0xc00076a0 == 0xc00076a4, + "update_dbg_state PATCH ERROR!!"); + BTDIGITAL_REG(0xc00076a4) = 1; + BT_DRV_TRACE(0, "BT_REG_OP:update_dbg_state"); + } } -void bt_drv_reg_op_set_ibrt_reject_sniff_req(bool en) -{ - if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) - { - ASSERT(*(uint32_t *)0xc0006e6c == 0xbb5ef615, "ibrt_reject_sniff_req PATCH ERROR!!"); - BTDIGITAL_REG(0xc0006e70) = en ? 1 : 0; - //BT_DRV_TRACE(1,"BT_REG_OP:ibrt reject sniff %d", en); - } +void bt_drv_reg_op_set_ibrt_reject_sniff_req(bool en) { + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) { + ASSERT(*(uint32_t *)0xc0006e6c == 0xbb5ef615, + "ibrt_reject_sniff_req PATCH ERROR!!"); + BTDIGITAL_REG(0xc0006e70) = en ? 1 : 0; + // BT_DRV_TRACE(1,"BT_REG_OP:ibrt reject sniff %d", en); + } } -uint8_t bt_drv_reg_op_get_esco_nego_airmode(uint8_t sco_link_id) -{ - BT_DRV_REG_OP_ENTER(); +uint8_t bt_drv_reg_op_get_esco_nego_airmode(uint8_t sco_link_id) { + BT_DRV_REG_OP_ENTER(); - if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) - { - // uint32_t lc_sco_env_addr = 0xc000079c; - uint32_t p_nego_params_addr = *((uint32_t *)(lc_sco_env_addr + 4 + sco_link_id * 8)); - uint8_t airmode = 0; + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) { + // uint32_t lc_sco_env_addr = 0xc000079c; + uint32_t p_nego_params_addr = + *((uint32_t *)(lc_sco_env_addr + 4 + sco_link_id * 8)); + uint8_t airmode = 0; - if (sco_link_id > 2 || p_nego_params_addr == 0) - { - return 0xff; - } - - airmode = *((uint8_t *)(p_nego_params_addr + 0x5e)); - - BT_DRV_TRACE(1,"BT_REG_OP:Get nego esco airmode=%d",airmode); - return airmode; + if (sco_link_id > 2 || p_nego_params_addr == 0) { + return 0xff; } - BT_DRV_REG_OP_EXIT(); + airmode = *((uint8_t *)(p_nego_params_addr + 0x5e)); - return 0; + BT_DRV_TRACE(1, "BT_REG_OP:Get nego esco airmode=%d", airmode); + return airmode; + } + BT_DRV_REG_OP_EXIT(); + + return 0; } -void bt_drv_reg_op_set_max_pwr_rcv(uint16_t connHandle) -{ - BT_DRV_REG_OP_ENTER(); - uint32_t lc_evt_ptr = 0x0; - uint32_t max_power_rcv_addr; - uint8_t linkid = btdrv_conhdl_to_linkid(connHandle); +void bt_drv_reg_op_set_max_pwr_rcv(uint16_t connHandle) { + BT_DRV_REG_OP_ENTER(); + uint32_t lc_evt_ptr = 0x0; + uint32_t max_power_rcv_addr; + uint8_t linkid = btdrv_conhdl_to_linkid(connHandle); - if(lc_env_addr) - { - lc_evt_ptr = *(volatile uint32_t *)(lc_env_addr+linkid*4);//lc_env + if (lc_env_addr) { + lc_evt_ptr = *(volatile uint32_t *)(lc_env_addr + linkid * 4); // lc_env + } + + if (lc_evt_ptr) { + // lc_env_ptr->link.MaxPowerRcv + max_power_rcv_addr = lc_evt_ptr + 0x61; + *(bool *)max_power_rcv_addr = true; + BT_DRV_TRACE(1, "BT_REG_OP:conhdl=%x, max pwr recieve", connHandle); + } + BT_DRV_REG_OP_EXIT(); +} + +void bt_drv_reg_op_set_rand_seed(uint32_t seed) { + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_1) { + *(volatile uint32_t *)(0xc0006890) = seed; + } else if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) { + *(volatile uint32_t *)(0xc0006998) = seed; + } +} + +uint32_t bt_drv_reg_op_get_host_ref_clk(void) { return 0; } + +void bt_drv_reg_op_hci_vender_ibrt_ll_monitor(uint8_t *ptr, uint16_t *p_sum_err, + uint16_t *p_rx_total) { + const char *monitor_str[29] = { + "TX DM1", "TX DH1", "TX DM3", "TX DH3", "TX DM5", + "TX DH5", "TX 2DH1", "TX 3DH1", "TX 2DH3", "TX 3DH3", + "TX 2DH5", "TX 3DH5", + + "RX DM1", "RX DH1", "RX DM3", "RX DH3", "RX DM5", + "RX DH5", "RX 2DH1", "RX 3DH1", "RX 2DH3", "RX 3DH3", + "RX 2DH5", "RX 3DH5", "hec error", "crc error", "fec error", + "gard error", "ecc count", + }; + + uint32_t *p = (uint32_t *)ptr; + uint32_t sum_err = 0; + uint32_t rx_data_sum = 0; + uint32_t val; + + TRACE(0, "ibrt_ui_log:ll_monitor"); + for (uint8_t i = 0; i < 29; i++) { + val = co_read32p(p); + if (val) { + if (i >= 12 && i <= 23) { + rx_data_sum += val; + } + if (i > 23) { + sum_err += val; + } + TRACE(2, "%s %d", monitor_str[i], val); } - - if(lc_evt_ptr) - { - //lc_env_ptr->link.MaxPowerRcv - max_power_rcv_addr = lc_evt_ptr+0x61; - *(bool *)max_power_rcv_addr = true; - BT_DRV_TRACE(1,"BT_REG_OP:conhdl=%x, max pwr recieve",connHandle); - } - BT_DRV_REG_OP_EXIT(); + p += 4; + } + *p_sum_err = sum_err; + *p_rx_total = rx_data_sum; } -void bt_drv_reg_op_set_rand_seed(uint32_t seed) -{ - if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_1) - { - *(volatile uint32_t*)(0xc0006890)=seed; - } - else if(hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_2) - { - *(volatile uint32_t*)(0xc0006998)=seed; - } -} - -uint32_t bt_drv_reg_op_get_host_ref_clk(void) -{ - return 0; -} - -void bt_drv_reg_op_hci_vender_ibrt_ll_monitor(uint8_t* ptr, uint16_t* p_sum_err,uint16_t* p_rx_total) -{ - const char *monitor_str[29] = - { - "TX DM1", - "TX DH1", - "TX DM3", - "TX DH3", - "TX DM5", - "TX DH5", - "TX 2DH1", - "TX 3DH1", - "TX 2DH3", - "TX 3DH3", - "TX 2DH5", - "TX 3DH5", - - "RX DM1", - "RX DH1", - "RX DM3", - "RX DH3", - "RX DM5", - "RX DH5", - "RX 2DH1", - "RX 3DH1", - "RX 2DH3", - "RX 3DH3", - "RX 2DH5", - "RX 3DH5", - "hec error", - "crc error", - "fec error", - "gard error", - "ecc count", - }; - - uint32_t *p = ( uint32_t * )ptr; - uint32_t sum_err = 0; - uint32_t rx_data_sum = 0; - uint32_t val; - - TRACE(0,"ibrt_ui_log:ll_monitor"); - for (uint8_t i = 0; i < 29; i++) - { - val = co_read32p(p); - if (val) - { - if(i>= 12 && i<=23){ - rx_data_sum += val; - } - if(i>23) - { - sum_err += val; - } - TRACE(2,"%s %d", monitor_str[i], val); - } - p+=4; - } - *p_sum_err = sum_err; - *p_rx_total = rx_data_sum; -} - -uint8_t bt_drv_reg_op_bt_sync_swagc_en_get(void) -{ - return 0; -} -void bt_drv_reg_op_ecc_softbit_process(uint16_t* p_conn_handle1, uint16_t* p_conn_handle2, uint16_t length, uint8_t *data) -{ -} +uint8_t bt_drv_reg_op_bt_sync_swagc_en_get(void) { return 0; } +void bt_drv_reg_op_ecc_softbit_process(uint16_t *p_conn_handle1, + uint16_t *p_conn_handle2, + uint16_t length, uint8_t *data) {} #if defined(PCM_FAST_MODE) && defined(PCM_PRIVATE_DATA_FLAG) -void bt_drv_reg_op_set_pcm_flag() -{ -} +void bt_drv_reg_op_set_pcm_flag() {} #endif -void bt_drv_reg_op_key_gen_after_reset(bool enable) -{ -} +void bt_drv_reg_op_key_gen_after_reset(bool enable) {} diff --git a/platform/drivers/bt/best2300p/bt_drv_rfconfig.c b/platform/drivers/bt/best2300p/bt_drv_rfconfig.c index f79fc6b..1c49c15 100644 --- a/platform/drivers/bt/best2300p/bt_drv_rfconfig.c +++ b/platform/drivers/bt/best2300p/bt_drv_rfconfig.c @@ -13,100 +13,91 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" +#include "bt_drv.h" #include "hal_i2c.h" #include "hal_uart.h" -#include "bt_drv.h" +#include "plat_types.h" #ifdef RTOS #include "cmsis_os.h" #endif -#include "cmsis.h" -#include "hal_cmu.h" -#include "hal_trace.h" -#include "hal_timer.h" -#include "tgt_hardware.h" -#include "bt_drv_internal.h" #include "bt_drv_2300p_internal.h" -#include "hal_chipid.h" #include "bt_drv_interface.h" +#include "bt_drv_internal.h" #include "bt_drv_reg_op.h" -#include "pmu.h" -#include "iqcorrect.h" +#include "cmsis.h" #include "hal_btdump.h" +#include "hal_chipid.h" +#include "hal_cmu.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "iqcorrect.h" +#include "pmu.h" +#include "tgt_hardware.h" -#define AUTO_CAL 0 +#define AUTO_CAL 0 #ifndef BT_RF_MAX_XTAL_TUNE_PPB // Default 10 ppm/bit or 10000 ppb/bit -#define BT_RF_MAX_XTAL_TUNE_PPB 10000 +#define BT_RF_MAX_XTAL_TUNE_PPB 10000 #endif #ifndef BT_RF_XTAL_TUNE_FACTOR // Default 0.2 ppm/bit or 200 ppb/bit -#define BT_RF_XTAL_TUNE_FACTOR 200 +#define BT_RF_XTAL_TUNE_FACTOR 200 #endif -#define DEFAULT_XTAL_FCAP 0x8080 +#define DEFAULT_XTAL_FCAP 0x8080 -#define XTAL_FCAP_NORMAL_SHIFT 0 -#define XTAL_FCAP_NORMAL_MASK (0xFF << XTAL_FCAP_NORMAL_SHIFT) -#define XTAL_FCAP_NORMAL(n) BITFIELD_VAL(XTAL_FCAP_NORMAL, n) +#define XTAL_FCAP_NORMAL_SHIFT 0 +#define XTAL_FCAP_NORMAL_MASK (0xFF << XTAL_FCAP_NORMAL_SHIFT) +#define XTAL_FCAP_NORMAL(n) BITFIELD_VAL(XTAL_FCAP_NORMAL, n) -#define BT_XTAL_CMOM_DR (1 << 13) +#define BT_XTAL_CMOM_DR (1 << 13) -#define RF_REG_XTAL_FCAP 0xE9 -#define RF_REG_XTAL_CMOM_DR 0xE8 +#define RF_REG_XTAL_FCAP 0xE9 +#define RF_REG_XTAL_CMOM_DR 0xE8 /* ljh add for sync modify rf RF_REG_XTAL_FCAP value*/ -#define SPI_TRIG_RX_NEG_TIMEOUT MS_TO_TICKS(3) +#define SPI_TRIG_RX_NEG_TIMEOUT MS_TO_TICKS(3) -#define SPI_TRIG_NEG_TIMEOUT SPI_TRIG_RX_NEG_TIMEOUT +#define SPI_TRIG_NEG_TIMEOUT SPI_TRIG_RX_NEG_TIMEOUT - -enum BIT_OFFSET_CMD_TYPE_T -{ - BIT_OFFSET_CMD_STOP = 0, - BIT_OFFSET_CMD_START, - BIT_OFFSET_CMD_ACK, +enum BIT_OFFSET_CMD_TYPE_T { + BIT_OFFSET_CMD_STOP = 0, + BIT_OFFSET_CMD_START, + BIT_OFFSET_CMD_ACK, }; static uint16_t xtal_fcap = DEFAULT_XTAL_FCAP; static uint16_t init_xtal_fcap = DEFAULT_XTAL_FCAP; +// rampup start 1--->2->3 rampup ok +// rampdown start 3-->2-->1-->0 rampdown ok -//rampup start 1--->2->3 rampup ok -//rampdown start 3-->2-->1-->0 rampdown ok - - -//3a06=3b3f -//for pa@1.8v -struct bt_drv_tx_table_t -{ - uint16_t tbl[16][3]; +// 3a06=3b3f +// for pa@1.8v +struct bt_drv_tx_table_t { + uint16_t tbl[16][3]; }; - -struct RF_SYS_INIT_ITEM -{ - uint16_t reg; - uint16_t set; - uint16_t mask; - uint16_t delay; +struct RF_SYS_INIT_ITEM { + uint16_t reg; + uint16_t set; + uint16_t mask; + uint16_t delay; }; -static const struct RF_SYS_INIT_ITEM rf_sys_init_tbl[] = -{ - {0xb5,0x8000,0x8000,0}, - {0xc2,0x7188,0x7fff,0}, +static const struct RF_SYS_INIT_ITEM rf_sys_init_tbl[] = { + {0xb5, 0x8000, 0x8000, 0}, + {0xc2, 0x7188, 0x7fff, 0}, #ifdef LBRT - {0xc4,0x0043,0x0043,0},//enable lbrt adc clk[6] + {0xc4, 0x0043, 0x0043, 0}, // enable lbrt adc clk[6] #else - {0xc4,0x0003,0x0003,0}, + {0xc4, 0x0003, 0x0003, 0}, #endif }; - -//zhangzhd agc config use default 1216 +// zhangzhd agc config use default 1216 #define REG_EB_VAL 0x000c #define REG_181_VAL (0x00bf) #define REG_EC_VAL 0x000d @@ -124,553 +115,488 @@ static const struct RF_SYS_INIT_ITEM rf_sys_init_tbl[] = #define REG_F2_VAL 0x0007 #define REG_188_VAL 0x008f -//zhangzhd agc config end -const uint16_t rf_init_tbl_1[][3] = -{ - {0x88,0x8640,0}, - {0x8b,0x8a4a,0},//set rx flt cap,filter start up +// zhangzhd agc config end +const uint16_t rf_init_tbl_1[][3] = { + {0x88, 0x8640, 0}, + {0x8b, 0x8a4a, 0}, // set rx flt cap,filter start up #if defined(__FANG_HW_AGC_CFG_ADC__) - {0xd1,0x8401,0},//set ra adc gain -3db - {0x8e,0x0D28,0},//adc noise reduction + {0xd1, 0x8401, 0}, // set ra adc gain -3db + {0x8e, 0x0D28, 0}, // adc noise reduction #else - {0xd1,0x8403,0},//set gain - {0x8e,0x0128,0},//adc noise reduction + {0xd1, 0x8403, 0}, // set gain + {0x8e, 0x0128, 0}, // adc noise reduction #endif - {0x90,0x8e1f,0},//enlarge txflt BW - {0x91,0x05c0,0},//by walker 20180427 - {0x92,0x668e,0},//update by luobin 2019/3/22 - {0x97,0x2523,0},//update by luobin 2019.0523 - {0x98,0x1324,0},//update by walker 2019.01.14, modify for yield - {0x9a,0x4470,0},//div2 rc - {0x9b,0xfd52,0},//update by walker 2018.10.24 - {0x9c,0x180f,0},/////////luobin - {0xa3,0x0789,0}, - {0xb0,0x0000,0}, - {0xb1,0x0000,0}, - {0xb3,0x31f3,0},// - {0xb4,0x883c,0}, - {0xb6,0x3156,0}, - {0xb7,0x183f,0},//update by walker 2018.07.30 - {0xb9,0x8000,0},//cap3g6 off - {0xba,0x104e,0}, + {0x90, 0x8e1f, 0}, // enlarge txflt BW + {0x91, 0x05c0, 0}, // by walker 20180427 + {0x92, 0x668e, 0}, // update by luobin 2019/3/22 + {0x97, 0x2523, 0}, // update by luobin 2019.0523 + {0x98, 0x1324, 0}, // update by walker 2019.01.14, modify for yield + {0x9a, 0x4470, 0}, // div2 rc + {0x9b, 0xfd52, 0}, // update by walker 2018.10.24 + {0x9c, 0x180f, 0}, /////////luobin + {0xa3, 0x0789, 0}, + {0xb0, 0x0000, 0}, + {0xb1, 0x0000, 0}, + {0xb3, 0x31f3, 0}, // + {0xb4, 0x883c, 0}, + {0xb6, 0x3156, 0}, + {0xb7, 0x183f, 0}, // update by walker 2018.07.30 + {0xb9, 0x8000, 0}, // cap3g6 off + {0xba, 0x104e, 0}, #if defined(__FANG_LNA_CFG__) - {0xac,0x080e,0},//pre-charge set to 5us - {0x85,0x7f00,0},//NFMI RXADC LDO rise up + {0xac, 0x080e, 0}, // pre-charge set to 5us + {0x85, 0x7f00, 0}, // NFMI RXADC LDO rise up // {0xc3,0x0068,0},//add by xrz increase pll cal time 2018/10/20 - {0xc3,0x0044,0}, + {0xc3, 0x0044, 0}, #else - {0xc3,0x0050,0}, + {0xc3, 0x0050, 0}, #endif - {0xc5,0x4b50,0},//vco ictrl dr - {0xc9,0x3a08,0},//vco ictrl - {0xd3,0xc1c1,0}, - {0xd4,0x000f,0}, - {0xd5,0x4000,0}, - {0xd6,0x7980,0}, - {0xe8,0xe000,0}, - {0xf3,0x0c41,0},//by fang - {0x1a6,0x0600,0}, - {0x1ae,0x6a00,0},//fastlock en - {0x1d4,0x0000,0}, - {0x1d7,0xc4ff,0},//update by walker 2018.10.10 - {0x1de,0x2000,0}, - {0x1df,0x2087,0}, - {0x1f4,0x2241,0},//by walker 20180427 - {0x1fa,0x03df,0},//rst needed - {0x1fa,0x83df,0}, - {0xeb,REG_EB_VAL,0},//gain_idx:0 - {0x181,REG_181_VAL,0}, - {0xec,REG_EC_VAL,0},//gain_idx:1 - {0x182,REG_182_VAL,0}, - {0xed,REG_ED_VAL,0},//gain_idx:2 - {0x183,REG_183_VAL,0}, - {0xee,REG_EE_VAL,0},//gain_idx:3 - {0x184,REG_184_VAL,0}, - {0xef,REG_EF_VAL,0},//gain_idx:4 - {0x185,REG_185_VAL,0}, - {0xf0,REG_F0_VAL,0},//gain_idx:5 - {0x186,REG_186_VAL,0}, - {0xf1,REG_F1_VAL,0},//gain_idx:6 - {0x187,REG_187_VAL,0}, - {0xf2,REG_F2_VAL,0},//gain_idx:7 - {0x188,REG_188_VAL,0}, - {0x1d6,0x7e58,0},//set lbrt rxflt dccal_ready=1 - {0x1c8,0xdfc0,0},//en rfpll bias in lbrt mode - {0x1c9,0xa0cf,0},//en log bias - {0x82,0x0caa,0}, // select rfpll and cplx_dir=0 and en rxflt test - {0xf4,0x2181,0}, // set flt_cap to match flt_gain - {0x86,0xdc99,0},//set nfmi tmix - {0xdf,0x2006,0},//set nfmi tmix vcm + {0xc5, 0x4b50, 0}, // vco ictrl dr + {0xc9, 0x3a08, 0}, // vco ictrl + {0xd3, 0xc1c1, 0}, + {0xd4, 0x000f, 0}, + {0xd5, 0x4000, 0}, + {0xd6, 0x7980, 0}, + {0xe8, 0xe000, 0}, + {0xf3, 0x0c41, 0}, // by fang + {0x1a6, 0x0600, 0}, + {0x1ae, 0x6a00, 0}, // fastlock en + {0x1d4, 0x0000, 0}, + {0x1d7, 0xc4ff, 0}, // update by walker 2018.10.10 + {0x1de, 0x2000, 0}, + {0x1df, 0x2087, 0}, + {0x1f4, 0x2241, 0}, // by walker 20180427 + {0x1fa, 0x03df, 0}, // rst needed + {0x1fa, 0x83df, 0}, + {0xeb, REG_EB_VAL, 0}, // gain_idx:0 + {0x181, REG_181_VAL, 0}, + {0xec, REG_EC_VAL, 0}, // gain_idx:1 + {0x182, REG_182_VAL, 0}, + {0xed, REG_ED_VAL, 0}, // gain_idx:2 + {0x183, REG_183_VAL, 0}, + {0xee, REG_EE_VAL, 0}, // gain_idx:3 + {0x184, REG_184_VAL, 0}, + {0xef, REG_EF_VAL, 0}, // gain_idx:4 + {0x185, REG_185_VAL, 0}, + {0xf0, REG_F0_VAL, 0}, // gain_idx:5 + {0x186, REG_186_VAL, 0}, + {0xf1, REG_F1_VAL, 0}, // gain_idx:6 + {0x187, REG_187_VAL, 0}, + {0xf2, REG_F2_VAL, 0}, // gain_idx:7 + {0x188, REG_188_VAL, 0}, + {0x1d6, 0x7e58, 0}, // set lbrt rxflt dccal_ready=1 + {0x1c8, 0xdfc0, 0}, // en rfpll bias in lbrt mode + {0x1c9, 0xa0cf, 0}, // en log bias + {0x82, 0x0caa, 0}, // select rfpll and cplx_dir=0 and en rxflt test + {0xf4, 0x2181, 0}, // set flt_cap to match flt_gain + {0x86, 0xdc99, 0}, // set nfmi tmix + {0xdf, 0x2006, 0}, // set nfmi tmix vcm #ifdef __HW_AGC__ - {0x1c7,0x007d,0},//open lbrt adc and vcm bias current + {0x1c7, 0x007d, 0}, // open lbrt adc and vcm bias current #endif - {0x18c,0x0000,0},//max tx gain lbrt - //air @ LBRT 31.5m - {0x1d8,0x9162,0},//lbrt tx freqword - {0x1d9,0x9162,0},//lbrt tx freqword - {0x1da,0x9162,0},//lbrt tx freqword - {0x1db,0x9162,0},//lbrt tx freqword - {0x1dc,0x0000,0},//txlccap - {0x1dd,0x0000,0},//txlccap - {0x1ed,0x0000,0},//rxlccap - {0x1ee,0x0000,0},//rxlccap - {0x1e9,0x0a0a,0},//set rfpll divn in lbrt tx mode - {0x1ea,0x0a0a,0}, - {0x1eb,0x0a0a,0},//set rfpll divn in lbrt rx mode - {0x1ec,0x0a0a,0}, - {0x1ef,0x8a76,0},//lbrt rx freqword - {0x1f0,0x8a76,0},//lbrt rx freqword - {0x1f1,0x8a76,0},//lbrt rx freqword - {0x1f2,0x8a76,0},//lbrt rx freqword - {0x87,0x9f00,0},//{0x87,0x9f40,0} - {0x81,0x9207,0}, - {0xce,0xfc08,0}, - {0x8A,0x4EA4,0},// use rfpll for nfmi adclk + {0x18c, 0x0000, 0}, // max tx gain lbrt + // air @ LBRT 31.5m + {0x1d8, 0x9162, 0}, // lbrt tx freqword + {0x1d9, 0x9162, 0}, // lbrt tx freqword + {0x1da, 0x9162, 0}, // lbrt tx freqword + {0x1db, 0x9162, 0}, // lbrt tx freqword + {0x1dc, 0x0000, 0}, // txlccap + {0x1dd, 0x0000, 0}, // txlccap + {0x1ed, 0x0000, 0}, // rxlccap + {0x1ee, 0x0000, 0}, // rxlccap + {0x1e9, 0x0a0a, 0}, // set rfpll divn in lbrt tx mode + {0x1ea, 0x0a0a, 0}, + {0x1eb, 0x0a0a, 0}, // set rfpll divn in lbrt rx mode + {0x1ec, 0x0a0a, 0}, + {0x1ef, 0x8a76, 0}, // lbrt rx freqword + {0x1f0, 0x8a76, 0}, // lbrt rx freqword + {0x1f1, 0x8a76, 0}, // lbrt rx freqword + {0x1f2, 0x8a76, 0}, // lbrt rx freqword + {0x87, 0x9f00, 0}, //{0x87,0x9f40,0} + {0x81, 0x9207, 0}, + {0xce, 0xfc08, 0}, + {0x8A, 0x4EA4, 0}, // use rfpll for nfmi adclk //[below for ibrt] - {0x8c,0x9100,0}, - {0xab,0x1c0c,0}, //2019.05.08 by luofei - {0xa5,0x0404,0}, //rfpll pu time - {0xa6,0x2D20,0}, //2019.05.23 by luobin - {0xa8,0x2D22,0}, //2019.05.23 by luobin - {0x1b7,0x2c00,0}, //2019.05.08 by luofei - {0x1ad,0x9000,0}, // 2M tx filter baseband - {0xdc,0x8820,0}, //fa pa pwrup time - {0x8f,0x71b8,0},//tx dac by luobin + {0x8c, 0x9100, 0}, + {0xab, 0x1c0c, 0}, // 2019.05.08 by luofei + {0xa5, 0x0404, 0}, // rfpll pu time + {0xa6, 0x2D20, 0}, // 2019.05.23 by luobin + {0xa8, 0x2D22, 0}, // 2019.05.23 by luobin + {0x1b7, 0x2c00, 0}, // 2019.05.08 by luofei + {0x1ad, 0x9000, 0}, // 2M tx filter baseband + {0xdc, 0x8820, 0}, // fa pa pwrup time + {0x8f, 0x71b8, 0}, // tx dac by luobin }; #ifdef __HW_AGC__ -const uint16_t rf_init_tbl_1_hw_agc[][3] = //hw agc table -{ - {0xad,0xa04a,1},//hwagc en=1 - {0xCD,0x0040,0},//default 0x0000 - {0xcf,0x7f32,0},//lna gain dr=0 //default 0x0000 - {0xd0,0xe91f,0},//i2v flt gain dr=0 //default 0x0000 +const uint16_t rf_init_tbl_1_hw_agc[][3] = // hw agc table + { + {0xad, 0xa04a, 1}, // hwagc en=1 + {0xCD, 0x0040, 0}, // default 0x0000 + {0xcf, 0x7f32, 0}, // lna gain dr=0 //default 0x0000 + {0xd0, 0xe91f, 0}, // i2v flt gain dr=0 //default 0x0000 - {0xeb,0x0007,0},//gain_idx:0 - {0xec,0x0007,0},//gain_idx:1 - {0xed,0x0007,0},//gain_idx:2 - {0xee,0x000d,0},//gain_idx:3 - {0xef,0x000d,0},//gain_idx:4 - {0xf0,0x000d,0},//gain_idx:5 - {0xf1,0x000d,0},//gain_idx:6 - {0xf2,0x000c,0},//gain_idx:7 + {0xeb, 0x0007, 0}, // gain_idx:0 + {0xec, 0x0007, 0}, // gain_idx:1 + {0xed, 0x0007, 0}, // gain_idx:2 + {0xee, 0x000d, 0}, // gain_idx:3 + {0xef, 0x000d, 0}, // gain_idx:4 + {0xf0, 0x000d, 0}, // gain_idx:5 + {0xf1, 0x000d, 0}, // gain_idx:6 + {0xf2, 0x000c, 0}, // gain_idx:7 }; #endif //__HW_AGC__ -const uint16_t rf_init_tbl_1_sw_agc[][3] = //sw agc table -{ - {0xad,0xa00a,1},//hwagc en=0 - {0xCD,0x0000,0},//default 0x0000 - {0xcf,0x0000,0},//lna gain dr=0 //default 0x0000 - {0xd0,0x0000,0},//i2v flt gain dr=0 //default 0x0000 - {0xeb,REG_EB_VAL,0},//gain_idx:0 - {0xec,REG_EC_VAL,0},//gain_idx:1 - {0xed,REG_ED_VAL,0},//gain_idx:2 - {0xee,REG_EE_VAL,0},//gain_idx:3 - {0xef,REG_EF_VAL,0},//gain_idx:4 - {0xf0,REG_F0_VAL,0},//gain_idx:5 - {0xf1,REG_F1_VAL,0},//gain_idx:6 - {0xf2,REG_F2_VAL,0},//gain_idx:7 +const uint16_t rf_init_tbl_1_sw_agc[][3] = // sw agc table + { + {0xad, 0xa00a, 1}, // hwagc en=0 + {0xCD, 0x0000, 0}, // default 0x0000 + {0xcf, 0x0000, 0}, // lna gain dr=0 //default 0x0000 + {0xd0, 0x0000, 0}, // i2v flt gain dr=0 //default 0x0000 + {0xeb, REG_EB_VAL, 0}, // gain_idx:0 + {0xec, REG_EC_VAL, 0}, // gain_idx:1 + {0xed, REG_ED_VAL, 0}, // gain_idx:2 + {0xee, REG_EE_VAL, 0}, // gain_idx:3 + {0xef, REG_EF_VAL, 0}, // gain_idx:4 + {0xf0, REG_F0_VAL, 0}, // gain_idx:5 + {0xf1, REG_F1_VAL, 0}, // gain_idx:6 + {0xf2, REG_F2_VAL, 0}, // gain_idx:7 }; -uint32_t btdrv_rf_get_max_xtal_tune_ppb(void) -{ - return BT_RF_MAX_XTAL_TUNE_PPB; +uint32_t btdrv_rf_get_max_xtal_tune_ppb(void) { + return BT_RF_MAX_XTAL_TUNE_PPB; } -uint32_t btdrv_rf_get_xtal_tune_factor(void) -{ - return BT_RF_XTAL_TUNE_FACTOR; +uint32_t btdrv_rf_get_xtal_tune_factor(void) { return BT_RF_XTAL_TUNE_FACTOR; } + +void btdrv_rf_init_xtal_fcap(uint32_t fcap) { + xtal_fcap = SET_BITFIELD(xtal_fcap, XTAL_FCAP_NORMAL, fcap); + btdrv_write_rf_reg(RF_REG_XTAL_FCAP, xtal_fcap); + init_xtal_fcap = xtal_fcap; } -void btdrv_rf_init_xtal_fcap(uint32_t fcap) -{ - xtal_fcap = SET_BITFIELD(xtal_fcap, XTAL_FCAP_NORMAL, fcap); - btdrv_write_rf_reg(RF_REG_XTAL_FCAP, xtal_fcap); - init_xtal_fcap = xtal_fcap; +uint32_t btdrv_rf_get_init_xtal_fcap(void) { + return GET_BITFIELD(init_xtal_fcap, XTAL_FCAP_NORMAL); } -uint32_t btdrv_rf_get_init_xtal_fcap(void) -{ - return GET_BITFIELD(init_xtal_fcap, XTAL_FCAP_NORMAL); +uint32_t btdrv_rf_get_xtal_fcap(void) { + return GET_BITFIELD(xtal_fcap, XTAL_FCAP_NORMAL); } -uint32_t btdrv_rf_get_xtal_fcap(void) -{ - return GET_BITFIELD(xtal_fcap, XTAL_FCAP_NORMAL); +void btdrv_rf_set_xtal_fcap(uint32_t fcap, uint8_t is_direct) { + xtal_fcap = SET_BITFIELD(xtal_fcap, XTAL_FCAP_NORMAL, fcap); + btdrv_write_rf_reg(RF_REG_XTAL_FCAP, xtal_fcap); } -void btdrv_rf_set_xtal_fcap(uint32_t fcap, uint8_t is_direct) -{ - xtal_fcap = SET_BITFIELD(xtal_fcap, XTAL_FCAP_NORMAL, fcap); - btdrv_write_rf_reg(RF_REG_XTAL_FCAP, xtal_fcap); +int btdrv_rf_xtal_fcap_busy(uint8_t is_direct) { return 0; } + +void btdrv_rf_bit_offset_track_enable(bool enable) { return; } + +uint32_t btdrv_rf_bit_offset_get(void) { return 0; } + +uint16_t btdrv_rf_bitoffset_get(uint8_t conidx) { + uint16_t bitoffset; + bitoffset = BTDIGITAL_REG(EM_BT_BITOFF_ADDR + conidx * BT_EM_SIZE) & 0x3ff; + return bitoffset; } +void btdrv_rf_log_delay_cal(void) { + unsigned short read_value; + unsigned short write_value; + BT_DRV_TRACE(0, "btdrv_rf_log_delay_cal\n"); -int btdrv_rf_xtal_fcap_busy(uint8_t is_direct) -{ - return 0; + btdrv_write_rf_reg(0xa7, 0x0028); + + btdrv_write_rf_reg(0xd4, 0x0000); + btdrv_write_rf_reg(0xd5, 0x4002); + // *(volatile uint32_t*)(0xd02201e4) = 0x000a00b0; + *(volatile uint32_t *)(0xd0340020) = 0x030e01c1; + BT_DRV_TRACE(1, "0xd0340020 =%x\n", *(volatile uint32_t *)(0xd0340020)); + + btdrv_delay(1); + + btdrv_write_rf_reg(0xd2, 0x5003); + + btdrv_delay(1); + + btdrv_read_rf_reg(0x1e2, &read_value); + BT_DRV_TRACE(1, "0x1e2 read_value:%x\n", read_value); + if (read_value == 0xff80) { + btdrv_write_rf_reg(0xd3, 0xffff); + } else { + write_value = ((read_value >> 7) & 0x0001) | ((read_value & 0x007f) << 1) | + ((read_value & 0x8000) >> 7) | ((read_value & 0x7f00) << 1); + BT_DRV_TRACE(1, "d3 write_value:%x\n", write_value); + btdrv_write_rf_reg(0xd3, write_value); + } + btdrv_delay(1); + + // *(volatile uint32_t*)(0xd02201e4) = 0x00000000; + *(volatile uint32_t *)(0xd0340020) = 0x010e01c0; + BT_DRV_TRACE(1, "0xd0340020 =%x\n", *(volatile uint32_t *)(0xd0340020)); + + btdrv_write_rf_reg(0xd4, 0x000f); + btdrv_write_rf_reg(0xd2, 0x1003); + btdrv_write_rf_reg(0xd5, 0x4000); } -void btdrv_rf_bit_offset_track_enable(bool enable) -{ +void btdrv_rf_rx_gain_adjust_req(uint32_t user, bool lowgain) { return; } + +// rf Image calib +void btdtv_rf_image_calib(void) { + + uint16_t read_val; + // read calibrated val from efuse 0x05 register + pmu_get_efuse(PMU_EFUSE_PAGE_SW_CFG, &read_val); + // check if bit 11 has been set + uint8_t calb_done_flag = ((read_val & 0x800) >> 11); + if (calb_done_flag) { + BT_DRV_TRACE(1, "EFUSE REG[5]=%x", read_val); + } else { + BT_DRV_TRACE(0, "EFUSE REG[5] rf image has not been calibrated!"); return; -} + } + //[bit 12] calib flag + uint8_t calib_val = ((read_val & 0x1000) >> 12); + btdrv_read_rf_reg(0x9b, &read_val); + read_val &= 0xfcff; -uint32_t btdrv_rf_bit_offset_get(void) -{ - return 0; -} + if (calib_val == 0) { + read_val |= 1 << 8; + } else if (calib_val == 1) { + read_val |= 1 << 9; + } -uint16_t btdrv_rf_bitoffset_get(uint8_t conidx) -{ - uint16_t bitoffset; - bitoffset = BTDIGITAL_REG(EM_BT_BITOFF_ADDR+conidx*BT_EM_SIZE) & 0x3ff; - return bitoffset; -} - -void btdrv_rf_log_delay_cal(void) -{ - unsigned short read_value; - unsigned short write_value; - BT_DRV_TRACE(0,"btdrv_rf_log_delay_cal\n"); - - btdrv_write_rf_reg(0xa7, 0x0028); - - btdrv_write_rf_reg(0xd4, 0x0000); - btdrv_write_rf_reg(0xd5, 0x4002); -// *(volatile uint32_t*)(0xd02201e4) = 0x000a00b0; - *(volatile uint32_t*)(0xd0340020) = 0x030e01c1; - BT_DRV_TRACE(1,"0xd0340020 =%x\n",*(volatile uint32_t*)(0xd0340020) ); - - btdrv_delay(1); - - btdrv_write_rf_reg(0xd2, 0x5003); - - btdrv_delay(1); - - btdrv_read_rf_reg(0x1e2, &read_value); - BT_DRV_TRACE(1,"0x1e2 read_value:%x\n",read_value); - if(read_value == 0xff80) - { - btdrv_write_rf_reg(0xd3, 0xffff); - } - else - { - write_value = ((read_value>>7)&0x0001) | ((read_value & 0x007f)<<1) | ((read_value&0x8000)>>7) | ((read_value&0x7f00)<<1); - BT_DRV_TRACE(1,"d3 write_value:%x\n",write_value); - btdrv_write_rf_reg(0xd3, write_value); - } - btdrv_delay(1); - -// *(volatile uint32_t*)(0xd02201e4) = 0x00000000; - *(volatile uint32_t*)(0xd0340020) = 0x010e01c0; - BT_DRV_TRACE(1,"0xd0340020 =%x\n",*(volatile uint32_t*)(0xd0340020) ); - - - btdrv_write_rf_reg(0xd4, 0x000f); - btdrv_write_rf_reg(0xd2, 0x1003); - btdrv_write_rf_reg(0xd5, 0x4000); - -} - -void btdrv_rf_rx_gain_adjust_req(uint32_t user, bool lowgain) -{ - return; -} - -//rf Image calib -void btdtv_rf_image_calib(void) -{ - - uint16_t read_val; - //read calibrated val from efuse 0x05 register - pmu_get_efuse(PMU_EFUSE_PAGE_SW_CFG, &read_val); - //check if bit 11 has been set - uint8_t calb_done_flag = ((read_val &0x800)>>11); - if(calb_done_flag) - { - BT_DRV_TRACE(1,"EFUSE REG[5]=%x",read_val); - } - else - { - BT_DRV_TRACE(0,"EFUSE REG[5] rf image has not been calibrated!"); - return; - } - //[bit 12] calib flag - uint8_t calib_val = ((read_val &0x1000)>>12); - btdrv_read_rf_reg(0x9b,&read_val); - read_val&=0xfcff; - - if(calib_val==0) - { - read_val|= 1<<8; - } - else if(calib_val== 1) - { - read_val|= 1<<9; - } - - BT_DRV_TRACE(1,"write rf image calib val=%x in REG[0x9b]", read_val); - btdrv_write_rf_reg(0x9b,read_val); + BT_DRV_TRACE(1, "write rf image calib val=%x in REG[0x9b]", read_val); + btdrv_write_rf_reg(0x9b, read_val); } #ifdef TX_IQ_CAL -const uint16_t tx_cal_rfreg_set[][3] = -{ - //iq cal path - {0x1c4,0xffcf,0}, - {0x1c5,0xf8ff,0}, - {0x1c6,0x007f,0}, - {0x1c7,0x03ff,0}, - {0x1d6,0x7a58,0}, - {0x1d7,0xc0f7,0}, - {0x1f4,0x2481,0}, - {0x94,0x11c3,0}, - {0x95,0xe5c0,0}, - {0xd1,0x846b,0}, - {0xae,0x0403,0}, - {0x86,0xccd9,0}, - {0xf3,0x0c75,0}, - {0xf4,0x0309,0}, - {0xcf,0x8090,0}, - {0x82,0x2cab,0}, +const uint16_t tx_cal_rfreg_set[][3] = { + // iq cal path + {0x1c4, 0xffcf, 0}, + {0x1c5, 0xf8ff, 0}, + {0x1c6, 0x007f, 0}, + {0x1c7, 0x03ff, 0}, + {0x1d6, 0x7a58, 0}, + {0x1d7, 0xc0f7, 0}, + {0x1f4, 0x2481, 0}, + {0x94, 0x11c3, 0}, + {0x95, 0xe5c0, 0}, + {0xd1, 0x846b, 0}, + {0xae, 0x0403, 0}, + {0x86, 0xccd9, 0}, + {0xf3, 0x0c75, 0}, + {0xf4, 0x0309, 0}, + {0xcf, 0x8090, 0}, + {0x82, 0x2cab, 0}, - //nfmi adc - {0xc4,0x00c3,0}, - {0xae,0x07ff,0}, - {0x85,0x470f,0}, - {0x82,0x4aab,0}, - {0x82,0xecab,0}, - {0x87,0xa211,0}, - {0x87,0xe211,0}, - {0x84,0xfff8,0}, + // nfmi adc + {0xc4, 0x00c3, 0}, + {0xae, 0x07ff, 0}, + {0x85, 0x470f, 0}, + {0x82, 0x4aab, 0}, + {0x82, 0xecab, 0}, + {0x87, 0xa211, 0}, + {0x87, 0xe211, 0}, + {0x84, 0xfff8, 0}, }; -const uint16_t tx_cal_rfreg_store[][1] = -{ - {0x1c4}, - {0x1c5}, - {0x1c6}, - {0x1c7}, - {0x1d6}, - {0x1d7}, - {0x1f4}, - {0x94}, - {0x95}, - {0xd1}, - {0xae}, - {0x86}, - {0xf3}, - {0xf4}, - {0xcf}, - {0x82}, - {0xc4}, - {0x85}, - {0x87}, - {0x84}, +const uint16_t tx_cal_rfreg_store[][1] = { + {0x1c4}, {0x1c5}, {0x1c6}, {0x1c7}, {0x1d6}, {0x1d7}, {0x1f4}, + {0x94}, {0x95}, {0xd1}, {0xae}, {0x86}, {0xf3}, {0xf4}, + {0xcf}, {0x82}, {0xc4}, {0x85}, {0x87}, {0x84}, }; -int bt_iqimb_ini (); -int bt_iqimb_test_ex (int mismatch_type); -void btdrv_tx_iq_cal(void) -{ - uint8_t i; - const uint16_t (*tx_cal_rfreg_set_p)[3]; - const uint16_t (*tx_cal_rfreg_store_p)[1]; - uint32_t reg_set_tbl_size; - uint32_t reg_store_tbl_size; - uint16_t value; - uint32_t tx_cal_digreg_store[5]; +int bt_iqimb_ini(); +int bt_iqimb_test_ex(int mismatch_type); +void btdrv_tx_iq_cal(void) { + uint8_t i; + const uint16_t(*tx_cal_rfreg_set_p)[3]; + const uint16_t(*tx_cal_rfreg_store_p)[1]; + uint32_t reg_set_tbl_size; + uint32_t reg_store_tbl_size; + uint16_t value; + uint32_t tx_cal_digreg_store[5]; - tx_cal_rfreg_store_p = &tx_cal_rfreg_store[0]; - reg_store_tbl_size = sizeof(tx_cal_rfreg_store)/sizeof(tx_cal_rfreg_store[0]); - uint16_t tx_cal_rfreg_store[reg_store_tbl_size]; - BT_DRV_TRACE(0,"reg_store:\n"); - for(i=0; i< reg_store_tbl_size; i++) - { - btdrv_read_rf_reg(tx_cal_rfreg_store_p[i][0],&value); - tx_cal_rfreg_store[i] = value; - BT_DRV_TRACE(2,"reg=%x,v=%x",tx_cal_rfreg_store_p[i][0],value); - } - tx_cal_digreg_store[0] = *(volatile uint32_t*)(0xd0330038); - tx_cal_digreg_store[1] = *(volatile uint32_t*)(0xd0350364); - tx_cal_digreg_store[2] = *(volatile uint32_t*)(0xd0350360); - tx_cal_digreg_store[3] = *(volatile uint32_t*)(0xd035037c); - tx_cal_digreg_store[4] = *(volatile uint32_t*)(0xd02201e4); - BT_DRV_TRACE(1,"0xd0330038:%x\n",tx_cal_digreg_store[0]); - BT_DRV_TRACE(1,"0xd0350364:%x\n",tx_cal_digreg_store[1]); - BT_DRV_TRACE(1,"0xd0350360:%x\n",tx_cal_digreg_store[2]); - BT_DRV_TRACE(1,"0xd035037c:%x\n",tx_cal_digreg_store[3]); - BT_DRV_TRACE(1,"0xd02201e4:%x\n",tx_cal_digreg_store[4]); + tx_cal_rfreg_store_p = &tx_cal_rfreg_store[0]; + reg_store_tbl_size = + sizeof(tx_cal_rfreg_store) / sizeof(tx_cal_rfreg_store[0]); + uint16_t tx_cal_rfreg_store[reg_store_tbl_size]; + BT_DRV_TRACE(0, "reg_store:\n"); + for (i = 0; i < reg_store_tbl_size; i++) { + btdrv_read_rf_reg(tx_cal_rfreg_store_p[i][0], &value); + tx_cal_rfreg_store[i] = value; + BT_DRV_TRACE(2, "reg=%x,v=%x", tx_cal_rfreg_store_p[i][0], value); + } + tx_cal_digreg_store[0] = *(volatile uint32_t *)(0xd0330038); + tx_cal_digreg_store[1] = *(volatile uint32_t *)(0xd0350364); + tx_cal_digreg_store[2] = *(volatile uint32_t *)(0xd0350360); + tx_cal_digreg_store[3] = *(volatile uint32_t *)(0xd035037c); + tx_cal_digreg_store[4] = *(volatile uint32_t *)(0xd02201e4); + BT_DRV_TRACE(1, "0xd0330038:%x\n", tx_cal_digreg_store[0]); + BT_DRV_TRACE(1, "0xd0350364:%x\n", tx_cal_digreg_store[1]); + BT_DRV_TRACE(1, "0xd0350360:%x\n", tx_cal_digreg_store[2]); + BT_DRV_TRACE(1, "0xd035037c:%x\n", tx_cal_digreg_store[3]); + BT_DRV_TRACE(1, "0xd02201e4:%x\n", tx_cal_digreg_store[4]); + tx_cal_rfreg_set_p = &tx_cal_rfreg_set[0]; + reg_set_tbl_size = sizeof(tx_cal_rfreg_set) / sizeof(tx_cal_rfreg_set[0]); + BT_DRV_TRACE(0, "reg_set:\n"); + for (i = 0; i < reg_set_tbl_size; i++) { + btdrv_write_rf_reg(tx_cal_rfreg_set_p[i][0], tx_cal_rfreg_set_p[i][1]); + if (tx_cal_rfreg_set_p[i][2] != 0) + btdrv_delay(tx_cal_rfreg_set_p[i][2]); // delay + btdrv_read_rf_reg(tx_cal_rfreg_set_p[i][0], &value); + BT_DRV_TRACE(2, "reg=%x,v=%x", tx_cal_rfreg_set_p[i][0], value); + } + // iq cal cordic + *(volatile uint32_t *)(0xd0330038) = 0x0020010d; + btdrv_delay(1); + *(volatile uint32_t *)(0xd0350364) = 0x002eb948; + *(volatile uint32_t *)(0xd0350360) = 0x007fc240; + *(volatile uint32_t *)(0xd035037c) = 0x00020405; + *(volatile uint32_t *)(0xd02201e4) = 0x000a0000; + BT_DRV_TRACE(1, "0xd0330038:%x\n", *(volatile uint32_t *)(0xd0330038)); + BT_DRV_TRACE(1, "0xd0350364:%x\n", *(volatile uint32_t *)(0xd0350364)); + BT_DRV_TRACE(1, "0xd0350360:%x\n", *(volatile uint32_t *)(0xd0350360)); + BT_DRV_TRACE(1, "0xd035037c:%x\n", *(volatile uint32_t *)(0xd035037c)); + BT_DRV_TRACE(1, "0xd02201e4:%x\n", *(volatile uint32_t *)(0xd02201e4)); - tx_cal_rfreg_set_p = &tx_cal_rfreg_set[0]; - reg_set_tbl_size = sizeof(tx_cal_rfreg_set)/sizeof(tx_cal_rfreg_set[0]); - BT_DRV_TRACE(0,"reg_set:\n"); - for(i=0; i< reg_set_tbl_size; i++) - { - btdrv_write_rf_reg(tx_cal_rfreg_set_p[i][0],tx_cal_rfreg_set_p[i][1]); - if(tx_cal_rfreg_set_p[i][2] !=0) - btdrv_delay(tx_cal_rfreg_set_p[i][2]);//delay - btdrv_read_rf_reg(tx_cal_rfreg_set_p[i][0],&value); - BT_DRV_TRACE(2,"reg=%x,v=%x",tx_cal_rfreg_set_p[i][0],value); - } - //iq cal cordic - *(volatile uint32_t*)(0xd0330038) = 0x0020010d; - btdrv_delay(1); - *(volatile uint32_t*)(0xd0350364) = 0x002eb948; - *(volatile uint32_t*)(0xd0350360) = 0x007fc240; - *(volatile uint32_t*)(0xd035037c) = 0x00020405; - *(volatile uint32_t*)(0xd02201e4) = 0x000a0000; - BT_DRV_TRACE(1,"0xd0330038:%x\n",*(volatile uint32_t*)(0xd0330038)); - BT_DRV_TRACE(1,"0xd0350364:%x\n",*(volatile uint32_t*)(0xd0350364)); - BT_DRV_TRACE(1,"0xd0350360:%x\n",*(volatile uint32_t*)(0xd0350360)); - BT_DRV_TRACE(1,"0xd035037c:%x\n",*(volatile uint32_t*)(0xd035037c)); - BT_DRV_TRACE(1,"0xd02201e4:%x\n",*(volatile uint32_t*)(0xd02201e4)); + bt_iqimb_ini(); + bt_iqimb_test_ex(1); - bt_iqimb_ini(); - bt_iqimb_test_ex(1); - - BT_DRV_TRACE(0,"reg_reset:\n"); - for(i=0; i< reg_store_tbl_size; i++) - { - btdrv_write_rf_reg(tx_cal_rfreg_store_p[i][0],tx_cal_rfreg_store[i]); - - btdrv_read_rf_reg(tx_cal_rfreg_store_p[i][0],&value); - BT_DRV_TRACE(2,"reg=%x,v=%x",tx_cal_rfreg_store_p[i][0],value); - } - *(volatile uint32_t*)(0xd0330038) = tx_cal_digreg_store[0]; - *(volatile uint32_t*)(0xd0350364) = tx_cal_digreg_store[1]; - *(volatile uint32_t*)(0xd0350360) = tx_cal_digreg_store[2]; - *(volatile uint32_t*)(0xd035037c) = tx_cal_digreg_store[3]; - *(volatile uint32_t*)(0xd02201e4) = tx_cal_digreg_store[4]; - BT_DRV_TRACE(1,"0xd0330038:%x\n",*(volatile uint32_t*)(0xd0330038)); - BT_DRV_TRACE(1,"0xd0350364:%x\n",*(volatile uint32_t*)(0xd0350364)); - BT_DRV_TRACE(1,"0xd0350360:%x\n",*(volatile uint32_t*)(0xd0350360)); - BT_DRV_TRACE(1,"0xd035037c:%x\n",*(volatile uint32_t*)(0xd035037c)); - BT_DRV_TRACE(1,"0xd02201e4:%x\n",*(volatile uint32_t*)(0xd02201e4)); + BT_DRV_TRACE(0, "reg_reset:\n"); + for (i = 0; i < reg_store_tbl_size; i++) { + btdrv_write_rf_reg(tx_cal_rfreg_store_p[i][0], tx_cal_rfreg_store[i]); + btdrv_read_rf_reg(tx_cal_rfreg_store_p[i][0], &value); + BT_DRV_TRACE(2, "reg=%x,v=%x", tx_cal_rfreg_store_p[i][0], value); + } + *(volatile uint32_t *)(0xd0330038) = tx_cal_digreg_store[0]; + *(volatile uint32_t *)(0xd0350364) = tx_cal_digreg_store[1]; + *(volatile uint32_t *)(0xd0350360) = tx_cal_digreg_store[2]; + *(volatile uint32_t *)(0xd035037c) = tx_cal_digreg_store[3]; + *(volatile uint32_t *)(0xd02201e4) = tx_cal_digreg_store[4]; + BT_DRV_TRACE(1, "0xd0330038:%x\n", *(volatile uint32_t *)(0xd0330038)); + BT_DRV_TRACE(1, "0xd0350364:%x\n", *(volatile uint32_t *)(0xd0350364)); + BT_DRV_TRACE(1, "0xd0350360:%x\n", *(volatile uint32_t *)(0xd0350360)); + BT_DRV_TRACE(1, "0xd035037c:%x\n", *(volatile uint32_t *)(0xd035037c)); + BT_DRV_TRACE(1, "0xd02201e4:%x\n", *(volatile uint32_t *)(0xd02201e4)); } #endif -uint8_t btdrv_rf_init(void) -{ - uint16_t value; - const uint16_t (*rf_init_tbl_p)[3]; - uint32_t tbl_size; - //uint8_t ret; - uint8_t i; +uint8_t btdrv_rf_init(void) { + uint16_t value; + const uint16_t(*rf_init_tbl_p)[3]; + uint32_t tbl_size; + // uint8_t ret; + uint8_t i; - for (i = 0; i < ARRAY_SIZE(rf_sys_init_tbl); i++) - { - btdrv_read_rf_reg(rf_sys_init_tbl[i].reg, &value); - value = (value & ~rf_sys_init_tbl[i].mask) | (rf_sys_init_tbl[i].set & rf_sys_init_tbl[i].mask); - if (rf_sys_init_tbl[i].delay) - { - btdrv_delay(rf_sys_init_tbl[i].delay); - } - btdrv_write_rf_reg(rf_sys_init_tbl[i].reg, value); + for (i = 0; i < ARRAY_SIZE(rf_sys_init_tbl); i++) { + btdrv_read_rf_reg(rf_sys_init_tbl[i].reg, &value); + value = (value & ~rf_sys_init_tbl[i].mask) | + (rf_sys_init_tbl[i].set & rf_sys_init_tbl[i].mask); + if (rf_sys_init_tbl[i].delay) { + btdrv_delay(rf_sys_init_tbl[i].delay); } + btdrv_write_rf_reg(rf_sys_init_tbl[i].reg, value); + } - rf_init_tbl_p = &rf_init_tbl_1[0]; - tbl_size = sizeof(rf_init_tbl_1)/sizeof(rf_init_tbl_1[0]); + rf_init_tbl_p = &rf_init_tbl_1[0]; + tbl_size = sizeof(rf_init_tbl_1) / sizeof(rf_init_tbl_1[0]); - for(i=0; i< tbl_size; i++) - { - btdrv_write_rf_reg(rf_init_tbl_p[i][0],rf_init_tbl_p[i][1]); - if(rf_init_tbl_p[i][2] !=0) - btdrv_delay(rf_init_tbl_p[i][2]);//delay - } + for (i = 0; i < tbl_size; i++) { + btdrv_write_rf_reg(rf_init_tbl_p[i][0], rf_init_tbl_p[i][1]); + if (rf_init_tbl_p[i][2] != 0) + btdrv_delay(rf_init_tbl_p[i][2]); // delay + } - bt_drv_tx_pwr_init(); + bt_drv_tx_pwr_init(); #ifdef __HW_AGC__ - for(i=0; i< sizeof(rf_init_tbl_1_hw_agc)/sizeof(rf_init_tbl_1_hw_agc[0]); i++) - { - btdrv_write_rf_reg(rf_init_tbl_1_hw_agc[i][0],rf_init_tbl_1_hw_agc[i][1]); - if(rf_init_tbl_1_hw_agc[i][2] !=0) - btdrv_delay(rf_init_tbl_1_hw_agc[i][2]);//delay - } + for (i = 0; + i < sizeof(rf_init_tbl_1_hw_agc) / sizeof(rf_init_tbl_1_hw_agc[0]); + i++) { + btdrv_write_rf_reg(rf_init_tbl_1_hw_agc[i][0], rf_init_tbl_1_hw_agc[i][1]); + if (rf_init_tbl_1_hw_agc[i][2] != 0) + btdrv_delay(rf_init_tbl_1_hw_agc[i][2]); // delay + } #endif - //need before rf log delay cal - btdtv_rf_image_calib(); + // need before rf log delay cal + btdtv_rf_image_calib(); - btdrv_rf_log_delay_cal(); + btdrv_rf_log_delay_cal(); - btdrv_spi_trig_init(); + btdrv_spi_trig_init(); #ifdef TX_IQ_CAL - hal_btdump_clk_enable(); - bt_iq_calibration_setup(); - hal_btdump_clk_disable(); + hal_btdump_clk_enable(); + bt_iq_calibration_setup(); + hal_btdump_clk_disable(); #endif - return 1; + return 1; } -void bt_drv_rf_reset(void) -{ - btdrv_write_rf_reg(0x80,0xcafe); - btdrv_write_rf_reg(0x80,0x5fee); +void bt_drv_rf_reset(void) { + btdrv_write_rf_reg(0x80, 0xcafe); + btdrv_write_rf_reg(0x80, 0x5fee); } -static void bt_drv_switch_hw_sw_agc(enum BT_AGC_MODE_T agc_mode) -{ - static enum BT_AGC_MODE_T agc_mode_bak = BT_AGC_MODE_NONE; - uint16_t i = 0; +static void bt_drv_switch_hw_sw_agc(enum BT_AGC_MODE_T agc_mode) { + static enum BT_AGC_MODE_T agc_mode_bak = BT_AGC_MODE_NONE; + uint16_t i = 0; - if(agc_mode_bak != agc_mode) - { - agc_mode_bak = agc_mode; - BT_DRV_TRACE(1,"BT_DRV:use AGC mode=%d[1:HW,0:SW]",agc_mode); - uint32_t lock = int_lock_global(); - if(agc_mode == BT_AGC_MODE_HW) - { + if (agc_mode_bak != agc_mode) { + agc_mode_bak = agc_mode; + BT_DRV_TRACE(1, "BT_DRV:use AGC mode=%d[1:HW,0:SW]", agc_mode); + uint32_t lock = int_lock_global(); + if (agc_mode == BT_AGC_MODE_HW) { #ifdef __HW_AGC__ - bt_drv_reg_op_hw_sw_agc_select(BT_AGC_MODE_HW); - for(i=0; i< sizeof(rf_init_tbl_1_hw_agc)/sizeof(rf_init_tbl_1_hw_agc[0]); i++) - { - btdrv_write_rf_reg(rf_init_tbl_1_hw_agc[i][0],rf_init_tbl_1_hw_agc[i][1]); - if(rf_init_tbl_1_hw_agc[i][2] !=0) - btdrv_delay(rf_init_tbl_1_hw_agc[i][2]);//delay - } + bt_drv_reg_op_hw_sw_agc_select(BT_AGC_MODE_HW); + for (i = 0; + i < sizeof(rf_init_tbl_1_hw_agc) / sizeof(rf_init_tbl_1_hw_agc[0]); + i++) { + btdrv_write_rf_reg(rf_init_tbl_1_hw_agc[i][0], + rf_init_tbl_1_hw_agc[i][1]); + if (rf_init_tbl_1_hw_agc[i][2] != 0) + btdrv_delay(rf_init_tbl_1_hw_agc[i][2]); // delay + } #endif - } - else - { - bt_drv_reg_op_hw_sw_agc_select(BT_AGC_MODE_SW); - for(i=0; i< sizeof(rf_init_tbl_1_sw_agc)/sizeof(rf_init_tbl_1_sw_agc[0]); i++) - { - btdrv_write_rf_reg(rf_init_tbl_1_sw_agc[i][0],rf_init_tbl_1_sw_agc[i][1]); - if(rf_init_tbl_1_sw_agc[i][2] !=0) - btdrv_delay(rf_init_tbl_1_sw_agc[i][2]);//delay - } - } - int_unlock_global(lock); + } else { + bt_drv_reg_op_hw_sw_agc_select(BT_AGC_MODE_SW); + for (i = 0; + i < sizeof(rf_init_tbl_1_sw_agc) / sizeof(rf_init_tbl_1_sw_agc[0]); + i++) { + btdrv_write_rf_reg(rf_init_tbl_1_sw_agc[i][0], + rf_init_tbl_1_sw_agc[i][1]); + if (rf_init_tbl_1_sw_agc[i][2] != 0) + btdrv_delay(rf_init_tbl_1_sw_agc[i][2]); // delay + } } + int_unlock_global(lock); + } } -void bt_drv_select_agc_mode(enum BT_WORK_MODE_T mode) -{ +void bt_drv_select_agc_mode(enum BT_WORK_MODE_T mode) { #ifdef __HYBIRD_AGC__ - enum BT_AGC_MODE_T agc_mode = BT_AGC_MODE_SW; - switch(mode) - { - case BT_IDLE_MODE: - agc_mode = BT_AGC_MODE_HW; - break; - case BT_A2DP_WORK_MODE: - case BT_HFP_WORK_MODE: - agc_mode = BT_AGC_MODE_SW; - break; - default: - BT_DRV_TRACE(1,"BT_DRV:set error mork mode=%d",mode); - break; - } + enum BT_AGC_MODE_T agc_mode = BT_AGC_MODE_SW; + switch (mode) { + case BT_IDLE_MODE: + agc_mode = BT_AGC_MODE_HW; + break; + case BT_A2DP_WORK_MODE: + case BT_HFP_WORK_MODE: + agc_mode = BT_AGC_MODE_SW; + break; + default: + BT_DRV_TRACE(1, "BT_DRV:set error mork mode=%d", mode); + break; + } - bt_drv_switch_hw_sw_agc(agc_mode); + bt_drv_switch_hw_sw_agc(agc_mode); #endif } @@ -678,119 +604,106 @@ static uint16_t efuse; static int16_t rf18b_6_4, rf18b_10_8, rf18b_14_12; #define TX_POWET_CALIB_FACTOR 0x2 -static int check_btpower_efuse_invalid(void) -{ - pmu_get_efuse(PMU_EFUSE_PAGE_BT_POWER, &efuse); - BT_DRV_TRACE(1,"efuse_8=0x%x",efuse); +static int check_btpower_efuse_invalid(void) { + pmu_get_efuse(PMU_EFUSE_PAGE_BT_POWER, &efuse); + BT_DRV_TRACE(1, "efuse_8=0x%x", efuse); - rf18b_6_4 = (efuse & 0x70) >> 4; //address_8 [6:4] - rf18b_10_8 = (efuse & 0x700) >> 8; //address_8 [10:8] - rf18b_14_12 = (efuse & 0x7000) >> 12; //address_8 [14:12] + rf18b_6_4 = (efuse & 0x70) >> 4; // address_8 [6:4] + rf18b_10_8 = (efuse & 0x700) >> 8; // address_8 [10:8] + rf18b_14_12 = (efuse & 0x7000) >> 12; // address_8 [14:12] - if((0 == efuse) || - (rf18b_6_4 > 5) || - (rf18b_10_8 > 5) || - (rf18b_14_12 > 5)) + if ((0 == efuse) || (rf18b_6_4 > 5) || (rf18b_10_8 > 5) || + (rf18b_14_12 > 5)) { + BT_DRV_TRACE(0, "invalid efuse value."); + return 0; + } + + return 1; +} + +void bt_drv_tx_pwr_init(void) { + // ble txpower need modify ble tx idx @ bt_drv_config.c + // modify bit4~7 to change ble tx gain + btdrv_write_rf_reg(0x189, 0x0071); // min tx gain 2019.02.26 + btdrv_write_rf_reg(0x18a, 0x0071); // mid tx gain 2019.02.26 + if (0 == check_btpower_efuse_invalid()) + btdrv_write_rf_reg(0x18b, 0x0071); // max tx gain 2019.02.26 +} + +void bt_drv_tx_pwr_init_for_testmode(void) { + // ble txpower need modify ble tx idx @ bt_drv_config.c + // modify bit4~7 to change ble tx gain + btdrv_write_rf_reg(0x189, 0x007a); // min tx gain 2019.02.26 + btdrv_write_rf_reg(0x18a, 0x0076); // mid tx gain 2019.02.26 + if (0 == check_btpower_efuse_invalid()) + btdrv_write_rf_reg(0x18b, 0x0071); // max tx gain 2019.02.26 +} + +void btdrv_txpower_calib(void) { + uint16_t rf92_11_8; + uint16_t tmp_val; + int16_t average_value; // may be negative, so use signed numbers + uint16_t read_value; + + uint16_t bit7_symbol, bit11_symbol, bit15_symbol; + + if (0 == check_btpower_efuse_invalid()) + return; + + bit7_symbol = (efuse & 0x80) >> 4; + bit11_symbol = (efuse & 0x800) >> 8; + bit15_symbol = (efuse & 0x8000) >> 12; + rf92_11_8 = efuse & 0xf; // address_8 [3:0] + + BT_DRV_TRACE(3, "bit7_symbol=%d, bit11_symbol=%d, bit15_symbol=%d", + bit7_symbol, bit11_symbol, bit15_symbol); + BT_DRV_TRACE(4, "rf92_11_8=%x, rf18b_6_4=%x, rf18b_10_8=%x, rf18b_14_12=%x", + rf92_11_8, rf18b_6_4, rf18b_10_8, rf18b_14_12); + + rf18b_6_4 = (bit7_symbol == 0) ? rf18b_6_4 : -rf18b_6_4; + rf18b_10_8 = (bit11_symbol == 0) ? rf18b_10_8 : -rf18b_10_8; + rf18b_14_12 = (bit15_symbol == 0) ? rf18b_14_12 : -rf18b_14_12; + + // set 0x92[11:8] begin + btdrv_read_rf_reg(0x92, &tmp_val); + BT_DRV_TRACE(1, "read reg 0x92 val=%x", tmp_val); + tmp_val &= 0xf0ff; // clear [11:8] + tmp_val |= ((rf92_11_8 & 0xffff) << 8); // set efuse[3:0] to rf_92 [11:8] + BT_DRV_TRACE(2, "%d write reg 0x92 val=%x", __LINE__, tmp_val); + btdrv_write_rf_reg(0x92, tmp_val); + // set 0x92[11:8] end + + // set 0x18b[3:0] begin + btdrv_read_rf_reg(0x18b, &read_value); // 0x18b + + average_value = + (int16_t)(((float)(rf18b_6_4 + rf18b_10_8 + rf18b_14_12) / 6.f) + 0.5f); + BT_DRV_TRACE(2, "calc average_value=0x%x, dec:%d", average_value, + average_value); + + if (0 < average_value) { + btdrv_read_rf_reg(0x92, &tmp_val); + tmp_val &= 0x0fff; // clear [15:12] + + if (1 == average_value) { + tmp_val |= ((0x8 & 0xffff) << 12); + } else // average_value [2,~] { - BT_DRV_TRACE(0,"invalid efuse value."); - return 0; + tmp_val |= ((0xA & 0xffff) << 12); } + BT_DRV_TRACE(2, "%d write reg 0x92 val=%x", __LINE__, tmp_val); + btdrv_write_rf_reg(0x92, tmp_val); + } - return 1; -} - -void bt_drv_tx_pwr_init(void) -{ - //ble txpower need modify ble tx idx @ bt_drv_config.c - //modify bit4~7 to change ble tx gain - btdrv_write_rf_reg(0x189, 0x0071); // min tx gain 2019.02.26 - btdrv_write_rf_reg(0x18a, 0x0071); // mid tx gain 2019.02.26 - if (0 == check_btpower_efuse_invalid()) - btdrv_write_rf_reg(0x18b, 0x0071); // max tx gain 2019.02.26 -} - -void bt_drv_tx_pwr_init_for_testmode(void) -{ - //ble txpower need modify ble tx idx @ bt_drv_config.c - //modify bit4~7 to change ble tx gain - btdrv_write_rf_reg(0x189, 0x007a); // min tx gain 2019.02.26 - btdrv_write_rf_reg(0x18a, 0x0076); // mid tx gain 2019.02.26 - if (0 == check_btpower_efuse_invalid()) - btdrv_write_rf_reg(0x18b, 0x0071); // max tx gain 2019.02.26 -} - -void btdrv_txpower_calib(void) -{ - uint16_t rf92_11_8; - uint16_t tmp_val; - int16_t average_value; //may be negative, so use signed numbers - uint16_t read_value; - - uint16_t bit7_symbol, bit11_symbol, bit15_symbol; - - if(0 == check_btpower_efuse_invalid()) - return; - - bit7_symbol = (efuse & 0x80) >> 4; - bit11_symbol = (efuse & 0x800) >> 8; - bit15_symbol = (efuse & 0x8000) >> 12; - rf92_11_8 = efuse & 0xf; //address_8 [3:0] - - BT_DRV_TRACE(3, "bit7_symbol=%d, bit11_symbol=%d, bit15_symbol=%d", - bit7_symbol, - bit11_symbol, - bit15_symbol); - BT_DRV_TRACE(4, "rf92_11_8=%x, rf18b_6_4=%x, rf18b_10_8=%x, rf18b_14_12=%x", - rf92_11_8, - rf18b_6_4, - rf18b_10_8, - rf18b_14_12); - - rf18b_6_4 = (bit7_symbol == 0) ? rf18b_6_4 : -rf18b_6_4; - rf18b_10_8 = (bit11_symbol == 0) ? rf18b_10_8 : -rf18b_10_8; - rf18b_14_12 = (bit15_symbol == 0) ? rf18b_14_12 : -rf18b_14_12; - - //set 0x92[11:8] begin - btdrv_read_rf_reg(0x92,&tmp_val); - BT_DRV_TRACE(1,"read reg 0x92 val=%x",tmp_val); - tmp_val &= 0xf0ff; //clear [11:8] - tmp_val |= ((rf92_11_8 & 0xffff) << 8); //set efuse[3:0] to rf_92 [11:8] - BT_DRV_TRACE(2,"%d write reg 0x92 val=%x",__LINE__,tmp_val); - btdrv_write_rf_reg(0x92,tmp_val); - //set 0x92[11:8] end - - //set 0x18b[3:0] begin - btdrv_read_rf_reg(0x18b, &read_value); //0x18b - - average_value = (int16_t)(( (float)(rf18b_6_4 + rf18b_10_8 + rf18b_14_12) / 6.f) + 0.5f); - BT_DRV_TRACE(2,"calc average_value=0x%x, dec:%d",average_value, average_value); - - if(0 < average_value) - { - btdrv_read_rf_reg(0x92,&tmp_val); - tmp_val &= 0x0fff; //clear [15:12] - - if(1 == average_value) - { - tmp_val |= ((0x8 & 0xffff) << 12); - } - else //average_value [2,~] - { - tmp_val |= ((0xA & 0xffff) << 12); - } - BT_DRV_TRACE(2,"%d write reg 0x92 val=%x",__LINE__,tmp_val); - btdrv_write_rf_reg(0x92,tmp_val); - } - - tmp_val = TX_POWET_CALIB_FACTOR - average_value; - if(average_value > TX_POWET_CALIB_FACTOR) - tmp_val = 0; - - BT_DRV_TRACE(1,"finally tmp_val=%x",tmp_val); - - read_value &= 0xff00; //clear [3:0] & [7:4] - read_value |= (tmp_val | (0x7 << 4)); //get 0x18b [3:0] & [7:4] - btdrv_write_rf_reg(0x18b,read_value); - BT_DRV_TRACE(1,"write reg 0x18b val=0x%x",read_value); - //set 0x18b[3:0] end + tmp_val = TX_POWET_CALIB_FACTOR - average_value; + if (average_value > TX_POWET_CALIB_FACTOR) + tmp_val = 0; + + BT_DRV_TRACE(1, "finally tmp_val=%x", tmp_val); + + read_value &= 0xff00; // clear [3:0] & [7:4] + read_value |= (tmp_val | (0x7 << 4)); // get 0x18b [3:0] & [7:4] + btdrv_write_rf_reg(0x18b, read_value); + BT_DRV_TRACE(1, "write reg 0x18b val=0x%x", read_value); + // set 0x18b[3:0] end } diff --git a/platform/drivers/bt/best2300p/bt_drv_uart_bridge_intsys.c b/platform/drivers/bt/best2300p/bt_drv_uart_bridge_intsys.c index e90b18a..92eabb2 100644 --- a/platform/drivers/bt/best2300p/bt_drv_uart_bridge_intsys.c +++ b/platform/drivers/bt/best2300p/bt_drv_uart_bridge_intsys.c @@ -13,18 +13,17 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "stdbool.h" -#include "hal_intersys.h" -#include "hal_iomux.h" -#include "hal_uart.h" -#include "hal_trace.h" -#include "string.h" -#include "hal_chipid.h" -#include "heap_api.h" #include "bt_drv.h" #include "bt_drv_2300p_internal.h" -#include "bt_drv.h" #include "bt_drv_interface.h" +#include "hal_chipid.h" +#include "hal_intersys.h" +#include "hal_iomux.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "heap_api.h" +#include "stdbool.h" +#include "string.h" #define BT_UART_BRIDGE_BUF_LEN (1024) @@ -59,162 +58,159 @@ static volatile unsigned int uart_rx_len = 0; static unsigned char *bt_rx_data_p; static volatile unsigned int bt_rx_len = 0; -static void uart_rx(uint32_t xfer_size, int dma_error, union HAL_UART_IRQ_T status) -{ - if (dma_error) { - BT_DRV_TRACE(1,"uart_rx dma error: xfer_size=%d", xfer_size); - uart_rx_len = 0; - } else if (status.BE || status.FE || status.OE || status.PE) { - BT_DRV_TRACE(2,"uart_rx uart error: xfer_size=%d, status=0x%08x", xfer_size, status.reg); - uart_rx_len = 0; - } else { - uart_rx_len = xfer_size; - } - uart_rx_done = true; +static void uart_rx(uint32_t xfer_size, int dma_error, + union HAL_UART_IRQ_T status) { + if (dma_error) { + BT_DRV_TRACE(1, "uart_rx dma error: xfer_size=%d", xfer_size); + uart_rx_len = 0; + } else if (status.BE || status.FE || status.OE || status.PE) { + BT_DRV_TRACE(2, "uart_rx uart error: xfer_size=%d, status=0x%08x", + xfer_size, status.reg); + uart_rx_len = 0; + } else { + uart_rx_len = xfer_size; + } + uart_rx_done = true; } -static void uart_tx(uint32_t xfer_size, int dma_error) -{ - if (dma_error) { - BT_DRV_TRACE(1,"uart_tx dma error: xfer_size=%d", xfer_size); - } - uart_tx_done = true; +static void uart_tx(uint32_t xfer_size, int dma_error) { + if (dma_error) { + BT_DRV_TRACE(1, "uart_tx dma error: xfer_size=%d", xfer_size); + } + uart_tx_done = true; } #ifdef VCO_TEST_TOOL static unsigned int bt_rx(const unsigned char *data, unsigned int len); -void vco_test_simu_bt_rx(void) -{ - const unsigned char hci_bt_vco_test_event[] = {0x04, 0x0e, 0x04, 0x05, 0xaa,0xfc,0x00}; - bt_rx(hci_bt_vco_test_event, sizeof(hci_bt_vco_test_event)); +void vco_test_simu_bt_rx(void) { + const unsigned char hci_bt_vco_test_event[] = {0x04, 0x0e, 0x04, 0x05, + 0xaa, 0xfc, 0x00}; + bt_rx(hci_bt_vco_test_event, sizeof(hci_bt_vco_test_event)); } #endif -static unsigned int bt_rx(const unsigned char *data, unsigned int len) -{ - unsigned int processed = len; +static unsigned int bt_rx(const unsigned char *data, unsigned int len) { + unsigned int processed = len; - - hal_intersys_stop_recv(br_intersys); - if (bt_rx_len + processed > BT_UART_BRIDGE_BUF_LEN) { - BT_DRV_TRACE(3,"bt_rx data too long: bt_rx_len=%d, len=%d, limit=%d", bt_rx_len, processed, sizeof(bt_rx_data_p)); - processed = BT_UART_BRIDGE_BUF_LEN-bt_rx_len; + hal_intersys_stop_recv(br_intersys); + if (bt_rx_len + processed > BT_UART_BRIDGE_BUF_LEN) { + BT_DRV_TRACE(3, "bt_rx data too long: bt_rx_len=%d, len=%d, limit=%d", + bt_rx_len, processed, sizeof(bt_rx_data_p)); + processed = BT_UART_BRIDGE_BUF_LEN - bt_rx_len; + } + if (processed > 0) { + memcpy(bt_rx_data_p + bt_rx_len, data, processed); + if ((data[0] == 0x4) && (data[2] == 0xc) && (data[4] == 0x1) && + (data[5] == 0x10)) { + *(uint8_t *)(bt_rx_data_p + bt_rx_len + 7) = 0x09; + *(uint8_t *)(bt_rx_data_p + bt_rx_len + 10) = 0x09; } - if (processed > 0) { - memcpy(bt_rx_data_p + bt_rx_len, data, processed); - if((data[0] == 0x4) && (data[2] == 0xc) && (data[4] == 0x1) && (data[5] == 0x10)) - { - *(uint8_t *)(bt_rx_data_p + bt_rx_len+7) = 0x09; - *(uint8_t *)(bt_rx_data_p + bt_rx_len+10) = 0x09; - } - if(data[0] == 0x4 && data[1] == 0xe && data[4] == 0x3 && data[5] == 0xc) - { - memset((uint32_t *)BT_EM_ADDR_BASE,0,BT_EM_SIZE/4); - *(uint32_t *)0xd02201e4 = 0; - } - BT_DRV_TRACE(0,"[TX]:"); - DUMP8("%02x ",bt_rx_data_p + bt_rx_len,processed); - bt_rx_len += processed; - bt_rx_done = true; + if (data[0] == 0x4 && data[1] == 0xe && data[4] == 0x3 && data[5] == 0xc) { + memset((uint32_t *)BT_EM_ADDR_BASE, 0, BT_EM_SIZE / 4); + *(uint32_t *)0xd02201e4 = 0; } - return len; + BT_DRV_TRACE(0, "[TX]:"); + DUMP8("%02x ", bt_rx_data_p + bt_rx_len, processed); + bt_rx_len += processed; + bt_rx_done = true; + } + return len; } -static void bt_tx(const unsigned char *data, unsigned int len) -{ - bt_tx_done = true; +static void bt_tx(const unsigned char *data, unsigned int len) { + bt_tx_done = true; } -void btdrv_uart_bridge_loop(void) -{ - int ret; - union HAL_UART_IRQ_T mask; +void btdrv_uart_bridge_loop(void) { + int ret; + union HAL_UART_IRQ_T mask; - syspool_init(); + syspool_init(); - syspool_get_buff(&uart_rx_data_p, BT_UART_BRIDGE_BUF_LEN); - syspool_get_buff(&bt_rx_data_p, BT_UART_BRIDGE_BUF_LEN); + syspool_get_buff(&uart_rx_data_p, BT_UART_BRIDGE_BUF_LEN); + syspool_get_buff(&bt_rx_data_p, BT_UART_BRIDGE_BUF_LEN); - if (br_uart == HAL_UART_ID_0) { - hal_iomux_set_uart0(); - hal_trace_switch(HAL_TRACE_TRANSPORT_UART1); - hal_iomux_set_uart1(); - } else { - hal_iomux_set_uart1(); - hal_trace_switch(HAL_TRACE_TRANSPORT_UART0); - //hal_iomux_set_uart0(); - } + if (br_uart == HAL_UART_ID_0) { + hal_iomux_set_uart0(); + hal_trace_switch(HAL_TRACE_TRANSPORT_UART1); + hal_iomux_set_uart1(); + } else { + hal_iomux_set_uart1(); + hal_trace_switch(HAL_TRACE_TRANSPORT_UART0); + // hal_iomux_set_uart0(); + } - ret = hal_uart_open(br_uart, &uart_cfg); - if (ret) { - BT_DRV_TRACE(0,"Failed to open uart"); - return; - } + ret = hal_uart_open(br_uart, &uart_cfg); + if (ret) { + BT_DRV_TRACE(0, "Failed to open uart"); + return; + } - hal_uart_irq_set_dma_handler(br_uart, uart_rx, uart_tx); - mask.reg = 0; - mask.BE = 1; - mask.FE = 1; - mask.OE = 1; - mask.PE = 1; - mask.RT = 1; - hal_uart_dma_recv_mask(br_uart, uart_rx_data_p, BT_UART_BRIDGE_BUF_LEN, NULL, NULL,&mask); + hal_uart_irq_set_dma_handler(br_uart, uart_rx, uart_tx); + mask.reg = 0; + mask.BE = 1; + mask.FE = 1; + mask.OE = 1; + mask.PE = 1; + mask.RT = 1; + hal_uart_dma_recv_mask(br_uart, uart_rx_data_p, BT_UART_BRIDGE_BUF_LEN, NULL, + NULL, &mask); - ret = hal_intersys_open(br_intersys, HAL_INTERSYS_MSG_HCI, bt_rx, bt_tx, false); - if (ret) { - BT_DRV_TRACE(0,"Failed to open intersys"); - return; - } - hal_intersys_start_recv(br_intersys); - BT_DRV_TRACE(0,"Enter bridge mode"); + ret = + hal_intersys_open(br_intersys, HAL_INTERSYS_MSG_HCI, bt_rx, bt_tx, false); + if (ret) { + BT_DRV_TRACE(0, "Failed to open intersys"); + return; + } + hal_intersys_start_recv(br_intersys); + BT_DRV_TRACE(0, "Enter bridge mode"); - while (1) { - if (uart_rx_done) { - uart_rx_done = false; - if (uart_rx_len > 0) { - BT_DRV_TRACE(0,"[RX]:"); - DUMP8("%02x ",uart_rx_data_p,uart_rx_len); + while (1) { + if (uart_rx_done) { + uart_rx_done = false; + if (uart_rx_len > 0) { + BT_DRV_TRACE(0, "[RX]:"); + DUMP8("%02x ", uart_rx_data_p, uart_rx_len); #ifdef LAURENT_ALGORITHM - btdrv_ble_test_bridge_intsys_callback(uart_rx_data_p); + btdrv_ble_test_bridge_intsys_callback(uart_rx_data_p); #endif #ifdef VCO_TEST_TOOL - if(btdrv_vco_test_bridge_intsys_callback(uart_rx_data_p)) - { - uart_rx_len =0; - continue ; - } -#endif - hal_intersys_send(br_intersys, HAL_INTERSYS_MSG_HCI, uart_rx_data_p, uart_rx_len); - } else { - bt_tx_done = true; - } - } - if (uart_tx_done) { - uart_tx_done = false; - bt_rx_len = 0; - hal_intersys_start_recv(br_intersys); - } - if (bt_rx_done) { - bt_rx_done = false; - if (bt_rx_len > 0) { - hal_uart_dma_send(br_uart, bt_rx_data_p, bt_rx_len, NULL, NULL); - } else { - uart_tx_done = true; - } - } - if (bt_tx_done) { - bt_tx_done = false; - hal_uart_dma_recv_mask(br_uart, uart_rx_data_p, BT_UART_BRIDGE_BUF_LEN, NULL, NULL,&mask); - } -#ifdef VCO_TEST_TOOL - if(btdrv_get_vco_test_process_flag()) - { - btdrv_vco_test_process(btdrv_get_vco_test_process_flag()); - vco_test_simu_bt_rx(); + if (btdrv_vco_test_bridge_intsys_callback(uart_rx_data_p)) { + uart_rx_len = 0; + continue; } #endif + hal_intersys_send(br_intersys, HAL_INTERSYS_MSG_HCI, uart_rx_data_p, + uart_rx_len); + } else { + bt_tx_done = true; + } } + if (uart_tx_done) { + uart_tx_done = false; + bt_rx_len = 0; + hal_intersys_start_recv(br_intersys); + } + if (bt_rx_done) { + bt_rx_done = false; + if (bt_rx_len > 0) { + hal_uart_dma_send(br_uart, bt_rx_data_p, bt_rx_len, NULL, NULL); + } else { + uart_tx_done = true; + } + } + if (bt_tx_done) { + bt_tx_done = false; + hal_uart_dma_recv_mask(br_uart, uart_rx_data_p, BT_UART_BRIDGE_BUF_LEN, + NULL, NULL, &mask); + } +#ifdef VCO_TEST_TOOL + if (btdrv_get_vco_test_process_flag()) { + btdrv_vco_test_process(btdrv_get_vco_test_process_flag()); + vco_test_simu_bt_rx(); + } +#endif + } } - diff --git a/platform/drivers/bt/best2300p/iqcorrect.c b/platform/drivers/bt/best2300p/iqcorrect.c index d243a2f..70d01e5 100644 --- a/platform/drivers/bt/best2300p/iqcorrect.c +++ b/platform/drivers/bt/best2300p/iqcorrect.c @@ -8,81 +8,76 @@ #include "hal_trace.h" #include "heap_api.h" -#include "string.h" #include "bt_drv.h" #include "cmsis_os.h" #include "hal_btdump.h" #include "iqcorrect.h" #include "nvrecord.h" -#include "nvrecord_env.h" #include "nvrecord_dev.h" +#include "nvrecord_env.h" +#include "string.h" #ifdef TX_IQ_CAL -#define LOG_MODULE HAL_TRACE_MODULE_APP +#define LOG_MODULE HAL_TRACE_MODULE_APP #define NTbl (1024) #define fftSize 1024 #define bitshift 10 #define pi (3.1415926535898) -#define min(a,b) (((a) < (b)) ? (a) : (b)) +#define min(a, b) (((a) < (b)) ? (a) : (b)) -#define READ_REG(b,a) *(volatile uint32_t *)(b+a) -#define WRITE_REG(v,b,a) *(volatile uint32_t *)(b+a) = v +#define READ_REG(b, a) *(volatile uint32_t *)(b + a) +#define WRITE_REG(v, b, a) *(volatile uint32_t *)(b + a) = v -#define BUF_SIZE (1024) +#define BUF_SIZE (1024) #define MAX_COUNT 5 volatile int iqimb_dma_status = 0; -//short M0data[BUF_SIZE]; -#define MED_MEM_POOL_SIZE (20*1024) +// short M0data[BUF_SIZE]; +#define MED_MEM_POOL_SIZE (20 * 1024) static uint8_t *g_medMemPool = NULL; extern void *rt_malloc(unsigned int size); extern void rt_free(void *rmem); -typedef struct ComplexInt_ -{ - int re; - int im; +typedef struct ComplexInt_ { + int re; + int im; } ComplexInt; -typedef struct Complexflt_ -{ - float re; - float im; +typedef struct Complexflt_ { + float re; + float im; } ComplexFlt; -typedef struct ComplexShort_ -{ - short re; - short im; +typedef struct ComplexShort_ { + short re; + short im; } ComplexShort; #ifdef DCCalib -static void Tblgen(ComplexShort*w0, ComplexShort*w1, ComplexShort*w2,int len) -{ - for (int i=0; iM0data = (short*)med_calloc(fft_size, sizeof(short)); - st->Table0 = (ComplexShort*)med_calloc(fft_size, sizeof(ComplexShort)); - st->Table1 = (ComplexShort*)med_calloc(fft_size, sizeof(ComplexShort)); - st->Table2 = (ComplexShort*)med_calloc(fft_size, sizeof(ComplexShort)); - BT_DRV_TRACE(5,"st:%p, st->M0data:%p, st->Table0:%p, st->Table1:%p, st->Table2:%p", st, st->M0data, st->Table0, st->Table1, st->Table2); - BT_DRV_TRACE(0,"malloc ok"); - return st; +IQMismatchPreprocessState *IQMismatchPreprocessState_init(int fft_size) { + BT_DRV_TRACE(0, "malloc ini"); + IQMismatchPreprocessState *st = (IQMismatchPreprocessState *)med_calloc( + 1, sizeof(IQMismatchPreprocessState)); + st->M0data = (short *)med_calloc(fft_size, sizeof(short)); + st->Table0 = (ComplexShort *)med_calloc(fft_size, sizeof(ComplexShort)); + st->Table1 = (ComplexShort *)med_calloc(fft_size, sizeof(ComplexShort)); + st->Table2 = (ComplexShort *)med_calloc(fft_size, sizeof(ComplexShort)); + BT_DRV_TRACE( + 5, "st:%p, st->M0data:%p, st->Table0:%p, st->Table1:%p, st->Table2:%p", + st, st->M0data, st->Table0, st->Table1, st->Table2); + BT_DRV_TRACE(0, "malloc ok"); + return st; } -int32_t IQMismatchPreprocessState_destroy(IQMismatchPreprocessState *st) -{ - BT_DRV_TRACE(5,"st:%p, st->M0data:%p, st->Table0:%p, st->Table1:%p, st->Table2:%p", st, st->M0data, st->Table0, st->Table1, st->Table2); - med_free(st->M0data); - med_free(st->Table0); - med_free(st->Table1); - med_free(st->Table2); - med_free(st); - return 0; +int32_t IQMismatchPreprocessState_destroy(IQMismatchPreprocessState *st) { + BT_DRV_TRACE( + 5, "st:%p, st->M0data:%p, st->Table0:%p, st->Table1:%p, st->Table2:%p", + st, st->M0data, st->Table0, st->Table1, st->Table2); + med_free(st->M0data); + med_free(st->Table0); + med_free(st->Table1); + med_free(st->Table2); + med_free(st); + return 0; } -int IQMismatchParameterCalc_ex(short *M0data, - short Cohcnt, ComplexShort *Table0, ComplexShort *Table1, ComplexShort *Table2,int fftsize) -{ - int i,j,k; - float M0 = 0; - //ComplexInt tmp0; - ComplexFlt tmp0; - ComplexFlt tmp1; - ComplexFlt tmp2; - for (j = 0; j < Cohcnt; j++) - { - tmp0.re = 0.0f; - tmp0.im = 0.0f; - tmp1.re = 0.0f; - tmp1.im = 0.0f; - tmp2.re = 0.0f; - tmp2.im = 0.0f; +int IQMismatchParameterCalc_ex(short *M0data, short Cohcnt, + ComplexShort *Table0, ComplexShort *Table1, + ComplexShort *Table2, int fftsize) { + int i, j, k; + float M0 = 0; + // ComplexInt tmp0; + ComplexFlt tmp0; + ComplexFlt tmp1; + ComplexFlt tmp2; + for (j = 0; j < Cohcnt; j++) { + tmp0.re = 0.0f; + tmp0.im = 0.0f; + tmp1.re = 0.0f; + tmp1.im = 0.0f; + tmp2.re = 0.0f; + tmp2.im = 0.0f; + k = 0; + for (i = 0; i < fftsize; i++) { + if (k >= fftsize) k = 0; - for (i=0; i=fftsize) - k = 0; - tmp0.re = tmp0.re + (((int)M0data[i] *(int)Table0[k].re) >> 15) ; - tmp0.im = tmp0.im + (((int)M0data[i] * (int)Table0[k].im) >> 15) ; - tmp1.re = tmp1.re + (((int)M0data[i] *(int)Table1[k].re) >> 15) ; - tmp1.im = tmp1.im + (((int)M0data[i] * (int)Table1[k].im) >> 15) ; - tmp2.re = tmp2.re + (((int)M0data[i] *(int)Table2[k].re) >> 15) ; - tmp2.im = tmp2.im + (((int)M0data[i] * (int)Table2[k].im) >> 15) ; - k = k + 1; - } - tmp0.re = tmp0.re/ fftsize;// >> bitshift; - tmp0.im = tmp0.im/ fftsize;// >>bitshift; - tmp1.re = tmp1.re/ fftsize;// >> bitshift; - tmp1.im = tmp1.im/ fftsize;// >>bitshift; - tmp2.re = tmp2.re/ fftsize;// >> bitshift; - tmp2.im = tmp2.im/ fftsize;// >>bitshift; - M0 = M0 + tmp0.re*tmp0.re + tmp0.im*tmp0.im; - M0 = M0 + tmp1.re*tmp1.re + tmp1.im*tmp1.im; - M0 = M0 + tmp2.re*tmp2.re + tmp2.im*tmp2.im; + tmp0.re = tmp0.re + (((int)M0data[i] * (int)Table0[k].re) >> 15); + tmp0.im = tmp0.im + (((int)M0data[i] * (int)Table0[k].im) >> 15); + tmp1.re = tmp1.re + (((int)M0data[i] * (int)Table1[k].re) >> 15); + tmp1.im = tmp1.im + (((int)M0data[i] * (int)Table1[k].im) >> 15); + tmp2.re = tmp2.re + (((int)M0data[i] * (int)Table2[k].re) >> 15); + tmp2.im = tmp2.im + (((int)M0data[i] * (int)Table2[k].im) >> 15); + k = k + 1; } - return (int)(M0/Cohcnt); + tmp0.re = tmp0.re / fftsize; // >> bitshift; + tmp0.im = tmp0.im / fftsize; // >>bitshift; + tmp1.re = tmp1.re / fftsize; // >> bitshift; + tmp1.im = tmp1.im / fftsize; // >>bitshift; + tmp2.re = tmp2.re / fftsize; // >> bitshift; + tmp2.im = tmp2.im / fftsize; // >>bitshift; + M0 = M0 + tmp0.re * tmp0.re + tmp0.im * tmp0.im; + M0 = M0 + tmp1.re * tmp1.re + tmp1.im * tmp1.im; + M0 = M0 + tmp2.re * tmp2.re + tmp2.im * tmp2.im; + } + return (int)(M0 / Cohcnt); } - -void caculate_energy_main_test(IQMismatchPreprocessState *st,int* Energy,int* Energy1,int fftsize) -{ - short Cohcnt = 1; - *Energy1 = IQMismatchParameterCalc_ex(st->M0data, Cohcnt, st->Table0, st->Table1, st->Table2,fftsize); +void caculate_energy_main_test(IQMismatchPreprocessState *st, int *Energy, + int *Energy1, int fftsize) { + short Cohcnt = 1; + *Energy1 = IQMismatchParameterCalc_ex(st->M0data, Cohcnt, st->Table0, + st->Table1, st->Table2, fftsize); } static struct HAL_DMA_DESC_T iqimb_dma_desc[1]; +static void iqimb_dma_dout_handler(uint32_t remains, uint32_t error, + struct HAL_DMA_DESC_T *lli) { + hal_audma_free_chan(0); + hal_btdump_disable(); + iqimb_dma_status = 0; -static void iqimb_dma_dout_handler(uint32_t remains, uint32_t error, struct HAL_DMA_DESC_T *lli) -{ - hal_audma_free_chan(0); - hal_btdump_disable(); - iqimb_dma_status = 0; - - return; + return; } -int bt_iqimb_dma_enable ( short * dma_dst_data, uint16_t size) -{ - struct HAL_DMA_CH_CFG_T iqimb_dma_cfg; - // BT_DRV_TRACE(0,"bt_iqimb_dma_enable :"); +int bt_iqimb_dma_enable(short *dma_dst_data, uint16_t size) { + struct HAL_DMA_CH_CFG_T iqimb_dma_cfg; + // BT_DRV_TRACE(0,"bt_iqimb_dma_enable :"); - iqimb_dma_status = 1; + iqimb_dma_status = 1; - memset(&iqimb_dma_cfg, 0, sizeof(iqimb_dma_cfg)); + memset(&iqimb_dma_cfg, 0, sizeof(iqimb_dma_cfg)); - //iqimb_dma_cfg.ch = hal_audma_get_chan(HAL_AUDMA_DSD_RX,HAL_DMA_HIGH_PRIO); + // iqimb_dma_cfg.ch = hal_audma_get_chan(HAL_AUDMA_DSD_RX,HAL_DMA_HIGH_PRIO); - iqimb_dma_cfg.ch = hal_audma_get_chan(HAL_AUDMA_BTDUMP,HAL_DMA_HIGH_PRIO); - iqimb_dma_cfg.dst_bsize = HAL_DMA_BSIZE_16; - iqimb_dma_cfg.dst_periph = 0; //useless - iqimb_dma_cfg.dst_width = HAL_DMA_WIDTH_WORD; - iqimb_dma_cfg.handler = (HAL_DMA_IRQ_HANDLER_T)iqimb_dma_dout_handler; - iqimb_dma_cfg.src = 0; // useless - iqimb_dma_cfg.src_bsize = HAL_DMA_BSIZE_4; + iqimb_dma_cfg.ch = hal_audma_get_chan(HAL_AUDMA_BTDUMP, HAL_DMA_HIGH_PRIO); + iqimb_dma_cfg.dst_bsize = HAL_DMA_BSIZE_16; + iqimb_dma_cfg.dst_periph = 0; // useless + iqimb_dma_cfg.dst_width = HAL_DMA_WIDTH_WORD; + iqimb_dma_cfg.handler = (HAL_DMA_IRQ_HANDLER_T)iqimb_dma_dout_handler; + iqimb_dma_cfg.src = 0; // useless + iqimb_dma_cfg.src_bsize = HAL_DMA_BSIZE_4; - //iqimb_dma_cfg.src_periph = HAL_AUDMA_DSD_RX; - iqimb_dma_cfg.src_periph = HAL_AUDMA_BTDUMP; - iqimb_dma_cfg.src_tsize = size;//1600; //1600*2/26=123us - iqimb_dma_cfg.src_width = HAL_DMA_WIDTH_WORD; - //iqimb_dma_cfg.src_width = HAL_DMA_WIDTH_HALFWORD; - iqimb_dma_cfg.try_burst = 1; - iqimb_dma_cfg.type = HAL_DMA_FLOW_P2M_DMA; - iqimb_dma_cfg.dst = (uint32_t)(dma_dst_data); + // iqimb_dma_cfg.src_periph = HAL_AUDMA_DSD_RX; + iqimb_dma_cfg.src_periph = HAL_AUDMA_BTDUMP; + iqimb_dma_cfg.src_tsize = size; // 1600; //1600*2/26=123us + iqimb_dma_cfg.src_width = HAL_DMA_WIDTH_WORD; + // iqimb_dma_cfg.src_width = HAL_DMA_WIDTH_HALFWORD; + iqimb_dma_cfg.try_burst = 1; + iqimb_dma_cfg.type = HAL_DMA_FLOW_P2M_DMA; + iqimb_dma_cfg.dst = (uint32_t)(dma_dst_data); - hal_audma_init_desc(&iqimb_dma_desc[0], &iqimb_dma_cfg, 0, 1); + hal_audma_init_desc(&iqimb_dma_desc[0], &iqimb_dma_cfg, 0, 1); - hal_audma_sg_start(&iqimb_dma_desc[0], &iqimb_dma_cfg); + hal_audma_sg_start(&iqimb_dma_desc[0], &iqimb_dma_cfg); - //configed after mismatch parameter done, or apb clock muxed. + // configed after mismatch parameter done, or apb clock muxed. - //wait - for(volatile int i=0; i<5000; i++); - hal_btdump_enable(); - - return 1; + // wait + for (volatile int i = 0; i < 5000; i++) + ; + hal_btdump_enable(); + return 1; } -int bt_iqimb_ini () -{ - uint32_t val; +int bt_iqimb_ini() { + uint32_t val; - BT_DRV_TRACE(0,"bt_iqimb_ini :"); - //config gpadc 26m - val = READ_REG(0xd0350208,0x0); - val &= 0xffefffff; //bit20 - val |= (1<<18); //reg_gclk_en(BTM_CLK_26RXNFMI) - val &= 0xffbfffff; //bit22 - val |= (1<<20); //reg_gclk_en(BTM_CLK_26RXDUMP) - val &= 0xfdffffff; //bit25 - val |= (1<<25); //reg_gclk_en(BTM_CLK_26RXADC) - WRITE_REG(val,0xd0350208,0x0); - BT_DRV_TRACE(1,"0xd0350208 : 0x%08x",val); + BT_DRV_TRACE(0, "bt_iqimb_ini :"); + // config gpadc 26m + val = READ_REG(0xd0350208, 0x0); + val &= 0xffefffff; // bit20 + val |= (1 << 18); // reg_gclk_en(BTM_CLK_26RXNFMI) + val &= 0xffbfffff; // bit22 + val |= (1 << 20); // reg_gclk_en(BTM_CLK_26RXDUMP) + val &= 0xfdffffff; // bit25 + val |= (1 << 25); // reg_gclk_en(BTM_CLK_26RXADC) + WRITE_REG(val, 0xd0350208, 0x0); + BT_DRV_TRACE(1, "0xd0350208 : 0x%08x", val); - val = READ_REG(0xd0350228,0x0); - val &= 0xffefffff; //bit20 - val |= (1<<18); //reg_gclk_mode(BTM_CLK_26RXNFMI) - val &= 0xffbfffff; //bit22 - val |= (1<<20); //reg_gclk_mode(BTM_CLK_26RXDUMP) - val &= 0xfdffffff; //bit25 - val |= (1<<25); //reg_gclk_mode(BTM_CLK_26RXADC) - WRITE_REG(val,0xd0350228,0x0); - BT_DRV_TRACE(1,"0xd0350228 : 0x%08x",val); + val = READ_REG(0xd0350228, 0x0); + val &= 0xffefffff; // bit20 + val |= (1 << 18); // reg_gclk_mode(BTM_CLK_26RXNFMI) + val &= 0xffbfffff; // bit22 + val |= (1 << 20); // reg_gclk_mode(BTM_CLK_26RXDUMP) + val &= 0xfdffffff; // bit25 + val |= (1 << 25); // reg_gclk_mode(BTM_CLK_26RXADC) + WRITE_REG(val, 0xd0350228, 0x0); + BT_DRV_TRACE(1, "0xd0350228 : 0x%08x", val); - //for rx mux to gpadc - val = READ_REG(0xd0350218,0x0); - val &= 0xfffffff0; //bit3:0 1110 reg_diagcntl(3 downto 0) - val |= (0xe<<0); - val &= 0xfffffbff; //bit10 1 reg_diagcntl(10) - val |= (0x1<<10); - WRITE_REG(val,0xd0350218,0x0); + // for rx mux to gpadc + val = READ_REG(0xd0350218, 0x0); + val &= 0xfffffff0; // bit3:0 1110 reg_diagcntl(3 downto 0) + val |= (0xe << 0); + val &= 0xfffffbff; // bit10 1 reg_diagcntl(10) + val |= (0x1 << 10); + WRITE_REG(val, 0xd0350218, 0x0); - BT_DRV_TRACE(1,"0xd0350218 : 0x%08x",val); + BT_DRV_TRACE(1, "0xd0350218 : 0x%08x", val); + val = READ_REG(0xd0330024, 0x0); + val &= 0xfffffff7; // bit3:0 1110 reg_diagcntl(3 downto 0) + val |= (0x1 << 15); + WRITE_REG(val, 0xd0330024, 0x0); + BT_DRV_TRACE(1, "0xd0330024 : 0x%08x", val); - val = READ_REG(0xd0330024,0x0); - val &= 0xfffffff7; //bit3:0 1110 reg_diagcntl(3 downto 0) - val |= (0x1<<15); - WRITE_REG(val,0xd0330024,0x0); - BT_DRV_TRACE(1,"0xd0330024 : 0x%08x",val); + val = READ_REG(0xd0330034, 0x0); + val &= 0x03ffffff; // bit3:0 1110 reg_diagcntl(3 downto 0) + val |= (0x1b << 26); + WRITE_REG(val, 0xd0330034, 0x0); + BT_DRV_TRACE(1, "0xd0330034 : 0x%08x", val); - val = READ_REG(0xd0330034,0x0); - val &= 0x03ffffff; //bit3:0 1110 reg_diagcntl(3 downto 0) - val |= (0x1b<<26); - WRITE_REG(val,0xd0330034,0x0); + WRITE_REG(0x002eb948, 0xd0350364, 0x0); - BT_DRV_TRACE(1,"0xd0330034 : 0x%08x",val); + val = READ_REG(0xd0330038, 0x0); - WRITE_REG(0x002eb948,0xd0350364,0x0); + val |= (0x1 << 24); + WRITE_REG(val, 0xd0330038, 0x0); - - val = READ_REG(0xd0330038,0x0); - - val |= (0x1<<24); - WRITE_REG(val,0xd0330038,0x0); - - - WRITE_REG(0,0xc000033c,0x0); - return 1; + WRITE_REG(0, 0xc000033c, 0x0); + return 1; } -void check_mem_data(void* data, int len) -{ - short* share_mem = (short*)data; - BT_DRV_TRACE(3,"check_mem_data :share_mem= %p, 0x%x, 0x%x",share_mem,share_mem[0],share_mem[1]); +void check_mem_data(void *data, int len) { + short *share_mem = (short *)data; + BT_DRV_TRACE(3, "check_mem_data :share_mem= %p, 0x%x, 0x%x", share_mem, + share_mem[0], share_mem[1]); - int16_t i =0; - int16_t m =0; - int16_t remain = len; - for(m=0; m<32; m++) - { - for(i=0; i<32; i++) - { + int16_t i = 0; + int16_t m = 0; + int16_t remain = len; + for (m = 0; m < 32; m++) { + for (i = 0; i < 32; i++) { - if (remain >16) - { - DUMP16("%04x ",share_mem,16); - share_mem +=16; - remain -= 16; - } - else - { - DUMP16("%04x ",share_mem,remain); + if (remain > 16) { + DUMP16("%04x ", share_mem, 16); + share_mem += 16; + remain -= 16; + } else { + DUMP16("%04x ", share_mem, remain); - remain =0; - return; - } - - } - // BT_DRV_TRACE(0,"\n"); - //BT_DRV_TRACE(1,"addr :0x%08x\n",share_mem); - hal_sys_timer_delay(MS_TO_TICKS(200)); + remain = 0; + return; + } } - - - + // BT_DRV_TRACE(0,"\n"); + // BT_DRV_TRACE(1,"addr :0x%08x\n",share_mem); + hal_sys_timer_delay(MS_TO_TICKS(200)); + } } -int bt_Txdc_cal_set(int ch_num, int dc_add) -{ - uint32_t val; - uint32_t tmp = (uint32_t)dc_add; - //sel apb clock - val = READ_REG(0xd0350348,0x0); - if(ch_num==0) - { - val &= 0xfffffc00; //bit31 1 int_en_mismatch - val |= tmp & 0x3ff; +int bt_Txdc_cal_set(int ch_num, int dc_add) { + uint32_t val; + uint32_t tmp = (uint32_t)dc_add; + // sel apb clock + val = READ_REG(0xd0350348, 0x0); + if (ch_num == 0) { + val &= 0xfffffc00; // bit31 1 int_en_mismatch + val |= tmp & 0x3ff; + } else { + // BT_DRV_TRACE(1,"bt_Txdc_cal_set, dcadd : 0x%08x",tmp); + val &= 0xfc00ffff; // bit31 1 int_en_mismatch + val |= (tmp & 0x3ff) << 16; + } + WRITE_REG(val, 0xd0350348, 0x0); + + // BT_DRV_TRACE(1,"bt_Txdc_cal_set, 0xd0350348 : 0x%08x",val); + + return 1; +} + +// g/p mismatch base addr 0xd0310000 +// dc_i: 0xd0350348 9:0 +// dc_q: 0xd0350348 25:16 +int bt_iqimb_add_mismatch(int ch_num, int gain_mis, int phase_mis, int dc_i, + int dc_q, uint32_t addr) { + uint32_t val; + // sel apb clock + val = READ_REG(0xd0350348, 0x0); + val &= 0x7fffffff; // bit31 1 int_en_mismatch + val |= (0x0 << 31); + WRITE_REG(val, 0xd0350348, 0x0); + + val = (phase_mis << 16) | (gain_mis & 0x0000ffff); + WRITE_REG(val, addr, ch_num * 4); + // tval = READ_REG(addr,0x0); + // BT_DRV_TRACE(1,"bt_iqimb_add_mismatch, iq : 0x%08x",tval); + + WRITE_REG(0x400000, 0xd0350220, 0); + WRITE_REG(0x400000, 0xd0350224, 0); + // bt_Txdc_cal_set(0,dc_i); + // bt_Txdc_cal_set(1,dc_q); + + /* + val = READ_REG(0xd0350348,0x0); + val &= 0xfffffc00; //bit9:0 + val |= dc_i; + val &= 0xfc00ffff; //bit25:16 + val |= (dc_q<<16); + WRITE_REG(val,0xd0350348,0x0); + */ + // sel 26m clock + val = READ_REG(0xd0350348, 0x0); + val &= 0x7fffffff; // bit31 1 int_en_mismatch + val |= (0x1 << 31); + WRITE_REG(val, 0xd0350348, 0x0); + + return 1; +} + +void DC_correction(IQMismatchPreprocessState *st, int *dc_i_r, int *dc_q_r, + int fftsize) { + uint8_t k; + int Energy, Energy1, tmp; + int dc_iters = 2; + int dc_i; + int dc_q; + int dc_step = 4; + int dc_i_base; + int dc_q_base; + int P0, PIplus, PIneg, PQplus, PQneg, PIPQ; + int CI, CQ, tmp_D; + dc_i_base = 0; + dc_q_base = 0; + for (k = 0; k < dc_iters; k++) { + dc_i = dc_i_base; + dc_q = dc_q_base; + bt_Txdc_cal_set(0, dc_i); + bt_Txdc_cal_set(1, dc_q); + bt_iqimb_dma_enable(st->M0data, (BUF_SIZE / 2)); + while (1) { + if (iqimb_dma_status == 0) + break; } - else - { - // BT_DRV_TRACE(1,"bt_Txdc_cal_set, dcadd : 0x%08x",tmp); - val &= 0xfc00ffff; //bit31 1 int_en_mismatch - val |= (tmp & 0x3ff) <<16; + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + P0 = Energy1; + dc_i = dc_i_base + dc_step; + dc_q = dc_q_base; + bt_Txdc_cal_set(0, dc_i); + bt_Txdc_cal_set(1, dc_q); + bt_iqimb_dma_enable(st->M0data, (BUF_SIZE / 2)); + while (1) { + if (iqimb_dma_status == 0) + break; } - WRITE_REG(val,0xd0350348,0x0); - - - // BT_DRV_TRACE(1,"bt_Txdc_cal_set, 0xd0350348 : 0x%08x",val); - - return 1; -} - -//g/p mismatch base addr 0xd0310000 -//dc_i: 0xd0350348 9:0 -//dc_q: 0xd0350348 25:16 -int bt_iqimb_add_mismatch(int ch_num, int gain_mis, int phase_mis, int dc_i, int dc_q, uint32_t addr) -{ - uint32_t val; - //sel apb clock - val = READ_REG(0xd0350348,0x0); - val &= 0x7fffffff; //bit31 1 int_en_mismatch - val |= (0x0<<31); - WRITE_REG(val,0xd0350348,0x0); - - val = (phase_mis << 16) | (gain_mis & 0x0000ffff); - WRITE_REG(val,addr,ch_num*4); - //tval = READ_REG(addr,0x0); - //BT_DRV_TRACE(1,"bt_iqimb_add_mismatch, iq : 0x%08x",tval); - - WRITE_REG(0x400000,0xd0350220,0); - WRITE_REG(0x400000,0xd0350224,0); - // bt_Txdc_cal_set(0,dc_i); - //bt_Txdc_cal_set(1,dc_q); - - /* - val = READ_REG(0xd0350348,0x0); - val &= 0xfffffc00; //bit9:0 - val |= dc_i; - val &= 0xfc00ffff; //bit25:16 - val |= (dc_q<<16); - WRITE_REG(val,0xd0350348,0x0); - */ - //sel 26m clock - val = READ_REG(0xd0350348,0x0); - val &= 0x7fffffff; //bit31 1 int_en_mismatch - val |= (0x1<<31); - WRITE_REG(val,0xd0350348,0x0); - - return 1; -} - -void DC_correction(IQMismatchPreprocessState *st,int *dc_i_r,int *dc_q_r,int fftsize) -{ - uint8_t k; - int Energy,Energy1,tmp; - int dc_iters = 2; - int dc_i; - int dc_q; - int dc_step = 4; - int dc_i_base; - int dc_q_base; - int P0,PIplus,PIneg,PQplus,PQneg,PIPQ; - int CI,CQ,tmp_D; - dc_i_base =0; - dc_q_base = 0; - for(k=0; kM0data,(BUF_SIZE/2)); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); - P0 = Energy1; - dc_i = dc_i_base + dc_step; - dc_q = dc_q_base; - bt_Txdc_cal_set(0,dc_i); - bt_Txdc_cal_set(1,dc_q); - bt_iqimb_dma_enable(st->M0data,(BUF_SIZE/2)); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); - PIplus = Energy1; - dc_i = dc_i_base - dc_step; - dc_q = dc_q_base; - bt_Txdc_cal_set(0,dc_i); - bt_Txdc_cal_set(1,dc_q); - bt_iqimb_dma_enable(st->M0data,(BUF_SIZE/2)); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); - PIneg = Energy1; - dc_i = dc_i_base; - dc_q = dc_q_base + dc_step; - bt_Txdc_cal_set(0,dc_i); - bt_Txdc_cal_set(1,dc_q); - bt_iqimb_dma_enable(st->M0data,(BUF_SIZE/2)); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); - PQplus = Energy1; - dc_i = dc_i_base; - dc_q = dc_q_base - dc_step; - bt_Txdc_cal_set(0,dc_i); - bt_Txdc_cal_set(1,dc_q); - bt_iqimb_dma_enable(st->M0data,(BUF_SIZE/2)); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); - PQneg = Energy1; - dc_i = dc_i_base + dc_step; - dc_q = dc_q_base + dc_step; - bt_Txdc_cal_set(0,dc_i); - bt_Txdc_cal_set(1,dc_q); - bt_iqimb_dma_enable(st->M0data,(BUF_SIZE/2)); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); - PIPQ = Energy1; - tmp = 2*PIplus*PIplus + 2*PQplus*PQplus + 2*PIPQ*PIPQ; - tmp = tmp - 6*P0*P0; - tmp = tmp + 4*P0*(PIneg+PQneg+PIPQ); - tmp = tmp + 2*(PIplus*(PQplus - PQneg)-PIneg*(PQplus+PQneg)); - tmp_D = tmp - 4*PIPQ*(PIplus+PQplus); - tmp = P0*(2*(PIplus - PIneg)+PQplus -PQneg); - tmp = tmp - PIPQ*(PQneg-PQplus)+PIneg*(PQplus+PQneg); - tmp = tmp + PQplus*(PQneg-PQplus-2*PIplus); - CI = -dc_step*tmp; - tmp = P0*(2*(PQplus - PQneg)+PIplus-PIneg); - tmp = tmp - PIPQ*(PIneg-PIplus)+PQneg*(PIplus+PIneg); - tmp = tmp + PIplus*(PIneg-PIplus-2*PQplus); - CQ = -dc_step*tmp; - dc_i_base = dc_i_base + CI/tmp_D; - dc_q_base = dc_q_base + CQ/tmp_D; - //dc_step = dc_step/2; + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + PIplus = Energy1; + dc_i = dc_i_base - dc_step; + dc_q = dc_q_base; + bt_Txdc_cal_set(0, dc_i); + bt_Txdc_cal_set(1, dc_q); + bt_iqimb_dma_enable(st->M0data, (BUF_SIZE / 2)); + while (1) { + if (iqimb_dma_status == 0) + break; } - *dc_i_r = dc_i_base; - *dc_q_r = dc_q_base; -} -int IQ_GAIN_Mismatch_Correction(IQMismatchPreprocessState *st,int phase_mis_base,int fftsize,uint32_t addr) -{ - uint8_t k = 0; - int phase_mis_tmp =0; - int gain_mis_tmp =0; - int tmp = 0; - int energy_ret0_last = 1048576; - int energy_ret0 = 0; - int energy_ret1 = 0; - int energy_ret2 = 0; - int Energy,Energy1 ; - int iters = 4; - int gainstep =8; - int gain_mis_base = 0; - - phase_mis_tmp = phase_mis_base; - energy_ret0_last = 1048576; - for(k=0; kM0data,fftsize); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); - energy_ret0 = Energy1; - if(energy_ret0<50) - break; - if(k>0) - { - if(energy_ret0_last < energy_ret0) - { - gain_mis_base = gain_mis_base + tmp; - gain_mis_tmp = gain_mis_base; - bt_iqimb_add_mismatch(0,gain_mis_tmp,phase_mis_tmp,0,0,addr); - bt_iqimb_dma_enable(st->M0data,fftsize); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); - energy_ret0 = Energy1; - } - } - //BT_DRV_TRACE(1,"IQ gain correct energy_ret0 = %d",energy_ret0); - gainstep = 4;/////////////////// - gain_mis_tmp = gain_mis_base + gainstep; - bt_iqimb_add_mismatch(0,gain_mis_tmp,phase_mis_tmp,0,0,addr); - bt_iqimb_dma_enable(st->M0data,fftsize); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); - energy_ret2 = Energy1; - gain_mis_tmp = gain_mis_base - gainstep; - bt_iqimb_add_mismatch(0,gain_mis_tmp,phase_mis_tmp,0,0,addr); - bt_iqimb_dma_enable(st->M0data,fftsize); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); - energy_ret1 = Energy1; - tmp = energy_ret2 -2*energy_ret0 + energy_ret1; - //BT_DRV_TRACE(1,"IQ gain correct energy_ret2 -2*energy_ret0 + energy_ret1 = %d",tmp); - if(tmp>0) - { - tmp = (energy_ret2-energy_ret1)*gainstep/tmp/2; - tmp = min(tmp,4*gainstep); - gainstep = gainstep/2; - } - else - { - tmp = 0; - iters = iters+1; - } - if(iters>8) - break; - if((gain_mis_base - tmp>60)||(gain_mis_base - tmp<-60)) - tmp = 0; - //BT_DRV_TRACE(2,"IQ gain correct gain_mis = %d ,gain_adj = %d",gain_mis_base,tmp); - gain_mis_base = gain_mis_base - tmp; - energy_ret0_last = energy_ret0; + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + PIneg = Energy1; + dc_i = dc_i_base; + dc_q = dc_q_base + dc_step; + bt_Txdc_cal_set(0, dc_i); + bt_Txdc_cal_set(1, dc_q); + bt_iqimb_dma_enable(st->M0data, (BUF_SIZE / 2)); + while (1) { + if (iqimb_dma_status == 0) + break; } - return gain_mis_base; + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + PQplus = Energy1; + dc_i = dc_i_base; + dc_q = dc_q_base - dc_step; + bt_Txdc_cal_set(0, dc_i); + bt_Txdc_cal_set(1, dc_q); + bt_iqimb_dma_enable(st->M0data, (BUF_SIZE / 2)); + while (1) { + if (iqimb_dma_status == 0) + break; + } + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + PQneg = Energy1; + dc_i = dc_i_base + dc_step; + dc_q = dc_q_base + dc_step; + bt_Txdc_cal_set(0, dc_i); + bt_Txdc_cal_set(1, dc_q); + bt_iqimb_dma_enable(st->M0data, (BUF_SIZE / 2)); + while (1) { + if (iqimb_dma_status == 0) + break; + } + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + PIPQ = Energy1; + tmp = 2 * PIplus * PIplus + 2 * PQplus * PQplus + 2 * PIPQ * PIPQ; + tmp = tmp - 6 * P0 * P0; + tmp = tmp + 4 * P0 * (PIneg + PQneg + PIPQ); + tmp = tmp + 2 * (PIplus * (PQplus - PQneg) - PIneg * (PQplus + PQneg)); + tmp_D = tmp - 4 * PIPQ * (PIplus + PQplus); + tmp = P0 * (2 * (PIplus - PIneg) + PQplus - PQneg); + tmp = tmp - PIPQ * (PQneg - PQplus) + PIneg * (PQplus + PQneg); + tmp = tmp + PQplus * (PQneg - PQplus - 2 * PIplus); + CI = -dc_step * tmp; + tmp = P0 * (2 * (PQplus - PQneg) + PIplus - PIneg); + tmp = tmp - PIPQ * (PIneg - PIplus) + PQneg * (PIplus + PIneg); + tmp = tmp + PIplus * (PIneg - PIplus - 2 * PQplus); + CQ = -dc_step * tmp; + dc_i_base = dc_i_base + CI / tmp_D; + dc_q_base = dc_q_base + CQ / tmp_D; + // dc_step = dc_step/2; + } + *dc_i_r = dc_i_base; + *dc_q_r = dc_q_base; } -int IQ_Phase_Mismatch_Correction(IQMismatchPreprocessState *st,int gain_mis_base,int fftsize,uint32_t addr) -{ - uint8_t k = 0; - int phase_mis_tmp =0; - int gain_mis_tmp =0; - int tmp = 0; - int energy_ret0_last = 1048576; - int energy_ret0 = 0; - int energy_ret1 = 0; - int energy_ret2 = 0; - int Energy,Energy1 ; - int iters = 4; - int phasestep =4; - int phase_mis_base = 0; - tmp = 0; - energy_ret0_last = 1048576; +int IQ_GAIN_Mismatch_Correction(IQMismatchPreprocessState *st, + int phase_mis_base, int fftsize, + uint32_t addr) { + uint8_t k = 0; + int phase_mis_tmp = 0; + int gain_mis_tmp = 0; + int tmp = 0; + int energy_ret0_last = 1048576; + int energy_ret0 = 0; + int energy_ret1 = 0; + int energy_ret2 = 0; + int Energy, Energy1; + int iters = 4; + int gainstep = 8; + int gain_mis_base = 0; + + phase_mis_tmp = phase_mis_base; + energy_ret0_last = 1048576; + for (k = 0; k < iters + 2; k++) { gain_mis_tmp = gain_mis_base; - for(k=0; kM0data,fftsize); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); - energy_ret0 = Energy1; - if(k>0) - { - if(energy_ret0_last < energy_ret0) - { - phase_mis_base = phase_mis_base + tmp; - phase_mis_tmp = phase_mis_base; - bt_iqimb_add_mismatch(0,gain_mis_tmp,phase_mis_tmp,0,0,addr); //no mismatch - bt_iqimb_dma_enable(st->M0data,fftsize); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); - energy_ret0 = Energy1; - } - } - if(energy_ret0<50) - break; - // BT_DRV_TRACE(1,"IQ phase correct energy_ret0 = %d",energy_ret0); - phasestep = 4;////////////////////////// - phase_mis_tmp = phase_mis_base + phasestep; - bt_iqimb_add_mismatch(0,gain_mis_tmp,phase_mis_tmp,0,0,addr); //no mismatch - bt_iqimb_dma_enable(st->M0data,fftsize); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); - energy_ret2 = Energy1; - // BT_DRV_TRACE(1,"IQ phase correct energy_ret2 = %d",energy_ret2); - phase_mis_tmp = phase_mis_base - phasestep; - bt_iqimb_add_mismatch(0,gain_mis_tmp,phase_mis_tmp,0,0,addr); //no mismatch - bt_iqimb_dma_enable(st->M0data,fftsize); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); - energy_ret1 = Energy1; - //BT_DRV_TRACE(1,"IQ phase correct energy_ret1 = %d",energy_ret1); - tmp = energy_ret2 -2*energy_ret0 + energy_ret1; - // BT_DRV_TRACE(1,"IQ phase correct energy_ret2 -2*energy_ret0 + energy_ret1 = %d",tmp); - if(tmp>0) - { - tmp = (energy_ret2-energy_ret1)*phasestep/tmp/2; - tmp = min(tmp,4*phasestep); - phasestep = phasestep/2; - } - else - { - tmp = 0; - iters = iters + 1; - } - if(iters>8) - break; - if((phase_mis_base - tmp>60)||(phase_mis_base - tmp<-60)) - tmp = 0; - // BT_DRV_TRACE(2,"IQ phase correct phase_mis = %d ,phase_adj = %d",phase_mis_base,tmp); - phase_mis_base = phase_mis_base - tmp; - energy_ret0_last = energy_ret0; - + bt_iqimb_add_mismatch(0, gain_mis_tmp, phase_mis_tmp, 0, 0, addr); + bt_iqimb_dma_enable(st->M0data, fftsize); + while (1) { + if (iqimb_dma_status == 0) + break; } - return phase_mis_base; + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + energy_ret0 = Energy1; + if (energy_ret0 < 50) + break; + if (k > 0) { + if (energy_ret0_last < energy_ret0) { + gain_mis_base = gain_mis_base + tmp; + gain_mis_tmp = gain_mis_base; + bt_iqimb_add_mismatch(0, gain_mis_tmp, phase_mis_tmp, 0, 0, addr); + bt_iqimb_dma_enable(st->M0data, fftsize); + while (1) { + if (iqimb_dma_status == 0) + break; + } + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + energy_ret0 = Energy1; + } + } + // BT_DRV_TRACE(1,"IQ gain correct energy_ret0 = %d",energy_ret0); + gainstep = 4; /////////////////// + gain_mis_tmp = gain_mis_base + gainstep; + bt_iqimb_add_mismatch(0, gain_mis_tmp, phase_mis_tmp, 0, 0, addr); + bt_iqimb_dma_enable(st->M0data, fftsize); + while (1) { + if (iqimb_dma_status == 0) + break; + } + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + energy_ret2 = Energy1; + gain_mis_tmp = gain_mis_base - gainstep; + bt_iqimb_add_mismatch(0, gain_mis_tmp, phase_mis_tmp, 0, 0, addr); + bt_iqimb_dma_enable(st->M0data, fftsize); + while (1) { + if (iqimb_dma_status == 0) + break; + } + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + energy_ret1 = Energy1; + tmp = energy_ret2 - 2 * energy_ret0 + energy_ret1; + // BT_DRV_TRACE(1,"IQ gain correct energy_ret2 -2*energy_ret0 + energy_ret1 + // = %d",tmp); + if (tmp > 0) { + tmp = (energy_ret2 - energy_ret1) * gainstep / tmp / 2; + tmp = min(tmp, 4 * gainstep); + gainstep = gainstep / 2; + } else { + tmp = 0; + iters = iters + 1; + } + if (iters > 8) + break; + if ((gain_mis_base - tmp > 60) || (gain_mis_base - tmp < -60)) + tmp = 0; + // BT_DRV_TRACE(2,"IQ gain correct gain_mis = %d ,gain_adj = + // %d",gain_mis_base,tmp); + gain_mis_base = gain_mis_base - tmp; + energy_ret0_last = energy_ret0; + } + return gain_mis_base; +} +int IQ_Phase_Mismatch_Correction(IQMismatchPreprocessState *st, + int gain_mis_base, int fftsize, + uint32_t addr) { + uint8_t k = 0; + int phase_mis_tmp = 0; + int gain_mis_tmp = 0; + int tmp = 0; + int energy_ret0_last = 1048576; + int energy_ret0 = 0; + int energy_ret1 = 0; + int energy_ret2 = 0; + int Energy, Energy1; + int iters = 4; + int phasestep = 4; + int phase_mis_base = 0; + tmp = 0; + energy_ret0_last = 1048576; + gain_mis_tmp = gain_mis_base; + for (k = 0; k < iters; k++) { + phase_mis_tmp = phase_mis_base; + bt_iqimb_add_mismatch(0, gain_mis_tmp, phase_mis_tmp, 0, 0, + addr); // no mismatch + bt_iqimb_dma_enable(st->M0data, fftsize); + while (1) { + if (iqimb_dma_status == 0) + break; + } + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + energy_ret0 = Energy1; + if (k > 0) { + if (energy_ret0_last < energy_ret0) { + phase_mis_base = phase_mis_base + tmp; + phase_mis_tmp = phase_mis_base; + bt_iqimb_add_mismatch(0, gain_mis_tmp, phase_mis_tmp, 0, 0, + addr); // no mismatch + bt_iqimb_dma_enable(st->M0data, fftsize); + while (1) { + if (iqimb_dma_status == 0) + break; + } + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + energy_ret0 = Energy1; + } + } + if (energy_ret0 < 50) + break; + // BT_DRV_TRACE(1,"IQ phase correct energy_ret0 = %d",energy_ret0); + phasestep = 4; ////////////////////////// + phase_mis_tmp = phase_mis_base + phasestep; + bt_iqimb_add_mismatch(0, gain_mis_tmp, phase_mis_tmp, 0, 0, + addr); // no mismatch + bt_iqimb_dma_enable(st->M0data, fftsize); + while (1) { + if (iqimb_dma_status == 0) + break; + } + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + energy_ret2 = Energy1; + // BT_DRV_TRACE(1,"IQ phase correct energy_ret2 = %d",energy_ret2); + phase_mis_tmp = phase_mis_base - phasestep; + bt_iqimb_add_mismatch(0, gain_mis_tmp, phase_mis_tmp, 0, 0, + addr); // no mismatch + bt_iqimb_dma_enable(st->M0data, fftsize); + while (1) { + if (iqimb_dma_status == 0) + break; + } + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + energy_ret1 = Energy1; + // BT_DRV_TRACE(1,"IQ phase correct energy_ret1 = %d",energy_ret1); + tmp = energy_ret2 - 2 * energy_ret0 + energy_ret1; + // BT_DRV_TRACE(1,"IQ phase correct energy_ret2 -2*energy_ret0 + energy_ret1 + // = %d",tmp); + if (tmp > 0) { + tmp = (energy_ret2 - energy_ret1) * phasestep / tmp / 2; + tmp = min(tmp, 4 * phasestep); + phasestep = phasestep / 2; + } else { + tmp = 0; + iters = iters + 1; + } + if (iters > 8) + break; + if ((phase_mis_base - tmp > 60) || (phase_mis_base - tmp < -60)) + tmp = 0; + // BT_DRV_TRACE(2,"IQ phase correct phase_mis = %d ,phase_adj = + // %d",phase_mis_base,tmp); + phase_mis_base = phase_mis_base - tmp; + energy_ret0_last = energy_ret0; + } + return phase_mis_base; } static BT_IQ_CALIBRATION_CONFIG_T config; -static void bt_update_local_iq_calibration_val(uint32_t freq_range, uint16_t gain_cal_val, uint16_t phase_cal_val) -{ - config.validityMagicNum = BT_IQ_VALID_MAGIC_NUM; - config.gain_cal_val[freq_range] = gain_cal_val; - config.phase_cal_val[freq_range] = phase_cal_val; +static void bt_update_local_iq_calibration_val(uint32_t freq_range, + uint16_t gain_cal_val, + uint16_t phase_cal_val) { + config.validityMagicNum = BT_IQ_VALID_MAGIC_NUM; + config.gain_cal_val[freq_range] = gain_cal_val; + config.phase_cal_val[freq_range] = phase_cal_val; } // do QA calibration and get the calibration value -static POSSIBLY_UNUSED void btIqCalibration(void) -{ - btdrv_tx_iq_cal(); - BT_DRV_TRACE(0,"Acquired calibration value:"); - for (uint32_t range = 0;range < BT_FREQENCY_RANGE_NUM;range++) - { - BT_DRV_TRACE(3,"%d: 0x%x - 0x%x", range, - config.gain_cal_val[range], - config.phase_cal_val[range]); - } +static POSSIBLY_UNUSED void btIqCalibration(void) { + btdrv_tx_iq_cal(); + BT_DRV_TRACE(0, "Acquired calibration value:"); + for (uint32_t range = 0; range < BT_FREQENCY_RANGE_NUM; range++) { + BT_DRV_TRACE(3, "%d: 0x%x - 0x%x", range, config.gain_cal_val[range], + config.phase_cal_val[range]); + } } // get IQ calibration from NV -static bool bt_get_iq_calibration_val_from_nv(BT_IQ_CALIBRATION_CONFIG_T* pConfig) -{ - if (nv_record_get_extension_entry_ptr() && - (BT_IQ_VALID_MAGIC_NUM == - nv_record_get_extension_entry_ptr()->btIqCalConfig.validityMagicNum)) - { - *pConfig = nv_record_get_extension_entry_ptr()->btIqCalConfig; - return true; - } - else - { - return false; - } +static bool +bt_get_iq_calibration_val_from_nv(BT_IQ_CALIBRATION_CONFIG_T *pConfig) { + if (nv_record_get_extension_entry_ptr() && + (BT_IQ_VALID_MAGIC_NUM == + nv_record_get_extension_entry_ptr()->btIqCalConfig.validityMagicNum)) { + *pConfig = nv_record_get_extension_entry_ptr()->btIqCalConfig; + return true; + } else { + return false; + } } -void bt_iq_calibration_setup(void) -{ - if (bt_get_iq_calibration_val_from_nv(&config)) - { - BT_DRV_TRACE(0,"Calibration value in NV:"); +void bt_iq_calibration_setup(void) { + if (bt_get_iq_calibration_val_from_nv(&config)) { + BT_DRV_TRACE(0, "Calibration value in NV:"); - for (uint32_t range = 0;range < BT_FREQENCY_RANGE_NUM;range++) - { - BT_DRV_TRACE(3,"%d: 0x%x - 0x%x", range, - config.gain_cal_val[range], - config.phase_cal_val[range]); - } - uint32_t addr = 0xd0310000; - int chs = 27; - - for (uint32_t range = 0;range < 3;range++) - { - if (0 == range) - { - addr = 0xd0310034; - chs= 27; - addr = addr-13*4; - } - - for (uint32_t ch=0;ch < chs;ch++) - { - bt_iqimb_add_mismatch(0, - config.gain_cal_val[range], - config.phase_cal_val[range], - 0,0,addr); - addr = addr +4; - } - } + for (uint32_t range = 0; range < BT_FREQENCY_RANGE_NUM; range++) { + BT_DRV_TRACE(3, "%d: 0x%x - 0x%x", range, config.gain_cal_val[range], + config.phase_cal_val[range]); } - else - { - btIqCalibration(); - uint32_t lock = nv_record_pre_write_operation(); - nv_record_get_extension_entry_ptr()->btIqCalConfig = config; - nv_record_post_write_operation(lock); - - nv_record_extension_update(); - } -} - -void bt_IQ_DC_Mismatch_Correction_Release() -{ - int phase_mis_base; - int gain_mis_base; - int Energy,Energy1; - uint32_t time_start = hal_sys_timer_get(); - int fftsize; uint32_t addr = 0xd0310000; int chs = 27; - IQMismatchPreprocessState *st; - syspool_init(); - syspool_get_buff(&g_medMemPool, MED_MEM_POOL_SIZE); - med_heap_init(&g_medMemPool[0], MED_MEM_POOL_SIZE); - //config gpadc 26m - READ_REG(0xd0310000,0x0); - #ifdef DCCalib - int dc_i_base,dc_q_base; - fftsize = 1024; - st = IQMismatchPreprocessState_init(fftsize); - Tblgen(st->Table0,st->Table1,st->Table2,fftsize); - DC_correction(st,&dc_i_base,&dc_q_base,fftsize); - bt_Txdc_cal_set(0,dc_i_base); //set cal DC I - bt_Txdc_cal_set(1,dc_q_base); - //val = READ_REG(0xd0350348,0x0); - //BT_DRV_TRACE(1,"0xd0350348 = 0x%08x",val); - bt_iqimb_dma_enable(st->M0data,fftsize); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); -// BT_DRV_TRACE(3,"dc cal done!!! dc_i = %d ,dc_q = %d,Energy1 = %d",dc_i_base,dc_q_base,Energy1); - if(Energy1>200) - { - DC_correction(st,&dc_i_base,&dc_q_base,fftsize); - bt_Txdc_cal_set(0,dc_i_base); //set cal DC I - bt_Txdc_cal_set(1,dc_q_base); - //val = READ_REG(0xd0350348,0x0); - //BT_DRV_TRACE(1,"0xd0350348 = 0x%08x",val); - bt_iqimb_dma_enable(st->M0data,fftsize); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); - } - if(Energy1>200) - { - DC_correction(st,&dc_i_base,&dc_q_base,fftsize); - bt_Txdc_cal_set(0,dc_i_base); //set cal DC I - bt_Txdc_cal_set(1,dc_q_base); - //val = READ_REG(0xd0350348,0x0); - //BT_DRV_TRACE(1,"0xd0350348 = 0x%08x",val); - bt_iqimb_dma_enable(st->M0data,fftsize); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); - } - #endif -// BT_DRV_TRACE(1,"use time: %d ticks", (hal_sys_timer_get()-time_start)); -// BT_DRV_TRACE(3,"dc cal done!!! dc_i = %d ,dc_q = %d,Energy1 = %d",dc_i_base,dc_q_base,Energy1); - fftsize = 1024; - st = IQMismatchPreprocessState_init(fftsize); - Tblgen_iq(st->Table0,st->Table1,st->Table2,fftsize); - BT_DRV_TRACE(1,"use time: %d ms", __TICKS_TO_MS(hal_sys_timer_get()-time_start)); - for (int k = 0; k<3; k++) - { - if(k==0) - { - WRITE_REG(0x0,0xD02201E4,0x0); - WRITE_REG(0x000A000D,0xD02201E4,0x0); - //osDelay(1000); - addr = 0xd0310034; - } - else if(k==1) - { - WRITE_REG(0x0,0xD02201E4,0x0); - WRITE_REG(0x000A0027,0xD02201E4,0x0); - addr = 0xd031009c; - } - else - { - WRITE_REG(0x0,0xD02201E4,0x0); - WRITE_REG(0x000A0041,0xD02201E4,0x0); - addr = 0xd0310104; - } - gain_mis_base = IQ_GAIN_Mismatch_Correction(st,0,fftsize,addr); - phase_mis_base = IQ_Phase_Mismatch_Correction(st,gain_mis_base,fftsize,addr); - bt_iqimb_add_mismatch(0,gain_mis_base,phase_mis_base,0,0,addr); //no mismatch - bt_iqimb_dma_enable(st->M0data,fftsize); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); -// BT_DRV_TRACE(4,"IQ phase correct addr = 0x%08x,phase_mis = %d ,gain_mis = %d,Energy = %d",addr,phase_mis_base,gain_mis_base,Energy1); - if(Energy1>500) - { - if(ABS(gain_mis_base)>ABS(phase_mis_base)) - { - gain_mis_base = IQ_GAIN_Mismatch_Correction(st,0,fftsize,addr); - phase_mis_base = IQ_Phase_Mismatch_Correction(st,gain_mis_base,fftsize,addr); - } - else - { - phase_mis_base = IQ_Phase_Mismatch_Correction(st,0,fftsize,addr); - gain_mis_base = IQ_GAIN_Mismatch_Correction(st,phase_mis_base,fftsize,addr); - } - bt_iqimb_add_mismatch(0,gain_mis_base,phase_mis_base,0,0,addr); //no mismatch -// BT_DRV_TRACE(1,"use time: %d ticks", (hal_sys_timer_get()-time_start)); - bt_iqimb_dma_enable(st->M0data,fftsize); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); -// BT_DRV_TRACE(4,"IQ phase correct addr = 0x%08x,phase_mis = %d ,gain_mis = %d,Energy = %d",addr,phase_mis_base,gain_mis_base,Energy1); - } + for (uint32_t range = 0; range < 3; range++) { + if (0 == range) { + addr = 0xd0310034; + chs = 27; + addr = addr - 13 * 4; + } - if(Energy1>500) - { - if(ABS(gain_mis_base)>ABS(phase_mis_base)) - { - gain_mis_base = IQ_GAIN_Mismatch_Correction(st,0,fftsize,addr); - phase_mis_base = IQ_Phase_Mismatch_Correction(st,gain_mis_base,fftsize,addr); - } - else - { - phase_mis_base = IQ_Phase_Mismatch_Correction(st,0,fftsize,addr); - gain_mis_base = IQ_GAIN_Mismatch_Correction(st,phase_mis_base,fftsize,addr); - } - // BT_DRV_TRACE(1,"use time: %d ticks", (hal_sys_timer_get()-time_start)); - bt_iqimb_dma_enable(st->M0data,fftsize); - while(1) - { - if(iqimb_dma_status==0) - break; - } - caculate_energy_main_test(st,&Energy,&Energy1,fftsize); - // BT_DRV_TRACE(4,"IQ phase correct addr = 0x%08x,phase_mis = %d ,gain_mis = %d,Energy = %d",addr,phase_mis_base,gain_mis_base,Energy1); - } - if(k==0) - { - chs= 27; - addr = addr-13*4; - } - else if(k==1) - { - chs = 26; - addr = addr - 12*4; - } - else - { - chs = 26; - addr = addr -12*4; - } - - bt_update_local_iq_calibration_val(k, gain_mis_base, phase_mis_base); - - for (int ch=0; chbtIqCalConfig = config; + nv_record_post_write_operation(lock); + + nv_record_extension_update(); + } } -int bt_iqimb_test_ex (int mismatch_type) -{ - - bt_IQ_DC_Mismatch_Correction_Release(); - - return 1; -} - -#endif//TX_IQ_CAL +void bt_IQ_DC_Mismatch_Correction_Release() { + int phase_mis_base; + int gain_mis_base; + int Energy, Energy1; + uint32_t time_start = hal_sys_timer_get(); + int fftsize; + uint32_t addr = 0xd0310000; + int chs = 27; + IQMismatchPreprocessState *st; + syspool_init(); + syspool_get_buff(&g_medMemPool, MED_MEM_POOL_SIZE); + med_heap_init(&g_medMemPool[0], MED_MEM_POOL_SIZE); + // config gpadc 26m + READ_REG(0xd0310000, 0x0); +#ifdef DCCalib + int dc_i_base, dc_q_base; + fftsize = 1024; + st = IQMismatchPreprocessState_init(fftsize); + Tblgen(st->Table0, st->Table1, st->Table2, fftsize); + DC_correction(st, &dc_i_base, &dc_q_base, fftsize); + bt_Txdc_cal_set(0, dc_i_base); // set cal DC I + bt_Txdc_cal_set(1, dc_q_base); + // val = READ_REG(0xd0350348,0x0); + // BT_DRV_TRACE(1,"0xd0350348 = 0x%08x",val); + bt_iqimb_dma_enable(st->M0data, fftsize); + while (1) { + if (iqimb_dma_status == 0) + break; + } + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + // BT_DRV_TRACE(3,"dc cal done!!! dc_i = %d ,dc_q = %d,Energy1 = + // %d",dc_i_base,dc_q_base,Energy1); + if (Energy1 > 200) { + DC_correction(st, &dc_i_base, &dc_q_base, fftsize); + bt_Txdc_cal_set(0, dc_i_base); // set cal DC I + bt_Txdc_cal_set(1, dc_q_base); + // val = READ_REG(0xd0350348,0x0); + // BT_DRV_TRACE(1,"0xd0350348 = 0x%08x",val); + bt_iqimb_dma_enable(st->M0data, fftsize); + while (1) { + if (iqimb_dma_status == 0) + break; + } + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + } + if (Energy1 > 200) { + DC_correction(st, &dc_i_base, &dc_q_base, fftsize); + bt_Txdc_cal_set(0, dc_i_base); // set cal DC I + bt_Txdc_cal_set(1, dc_q_base); + // val = READ_REG(0xd0350348,0x0); + // BT_DRV_TRACE(1,"0xd0350348 = 0x%08x",val); + bt_iqimb_dma_enable(st->M0data, fftsize); + while (1) { + if (iqimb_dma_status == 0) + break; + } + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + } +#endif + // BT_DRV_TRACE(1,"use time: %d ticks", (hal_sys_timer_get()-time_start)); + // BT_DRV_TRACE(3,"dc cal done!!! dc_i = %d ,dc_q = %d,Energy1 = + // %d",dc_i_base,dc_q_base,Energy1); + fftsize = 1024; + st = IQMismatchPreprocessState_init(fftsize); + Tblgen_iq(st->Table0, st->Table1, st->Table2, fftsize); + BT_DRV_TRACE(1, "use time: %d ms", + __TICKS_TO_MS(hal_sys_timer_get() - time_start)); + for (int k = 0; k < 3; k++) { + if (k == 0) { + WRITE_REG(0x0, 0xD02201E4, 0x0); + WRITE_REG(0x000A000D, 0xD02201E4, 0x0); + // osDelay(1000); + addr = 0xd0310034; + } else if (k == 1) { + WRITE_REG(0x0, 0xD02201E4, 0x0); + WRITE_REG(0x000A0027, 0xD02201E4, 0x0); + addr = 0xd031009c; + } else { + WRITE_REG(0x0, 0xD02201E4, 0x0); + WRITE_REG(0x000A0041, 0xD02201E4, 0x0); + addr = 0xd0310104; + } + gain_mis_base = IQ_GAIN_Mismatch_Correction(st, 0, fftsize, addr); + phase_mis_base = + IQ_Phase_Mismatch_Correction(st, gain_mis_base, fftsize, addr); + bt_iqimb_add_mismatch(0, gain_mis_base, phase_mis_base, 0, 0, + addr); // no mismatch + bt_iqimb_dma_enable(st->M0data, fftsize); + while (1) { + if (iqimb_dma_status == 0) + break; + } + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + // BT_DRV_TRACE(4,"IQ phase correct addr = 0x%08x,phase_mis = %d ,gain_mis + // = %d,Energy = %d",addr,phase_mis_base,gain_mis_base,Energy1); + if (Energy1 > 500) { + if (ABS(gain_mis_base) > ABS(phase_mis_base)) { + gain_mis_base = IQ_GAIN_Mismatch_Correction(st, 0, fftsize, addr); + phase_mis_base = + IQ_Phase_Mismatch_Correction(st, gain_mis_base, fftsize, addr); + } else { + phase_mis_base = IQ_Phase_Mismatch_Correction(st, 0, fftsize, addr); + gain_mis_base = + IQ_GAIN_Mismatch_Correction(st, phase_mis_base, fftsize, addr); + } + + bt_iqimb_add_mismatch(0, gain_mis_base, phase_mis_base, 0, 0, + addr); // no mismatch + // BT_DRV_TRACE(1,"use time: %d ticks", (hal_sys_timer_get()-time_start)); + bt_iqimb_dma_enable(st->M0data, fftsize); + while (1) { + if (iqimb_dma_status == 0) + break; + } + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + // BT_DRV_TRACE(4,"IQ phase correct addr = 0x%08x,phase_mis = %d + // ,gain_mis = %d,Energy = + // %d",addr,phase_mis_base,gain_mis_base,Energy1); + } + + if (Energy1 > 500) { + if (ABS(gain_mis_base) > ABS(phase_mis_base)) { + gain_mis_base = IQ_GAIN_Mismatch_Correction(st, 0, fftsize, addr); + phase_mis_base = + IQ_Phase_Mismatch_Correction(st, gain_mis_base, fftsize, addr); + } else { + phase_mis_base = IQ_Phase_Mismatch_Correction(st, 0, fftsize, addr); + gain_mis_base = + IQ_GAIN_Mismatch_Correction(st, phase_mis_base, fftsize, addr); + } + // BT_DRV_TRACE(1,"use time: %d ticks", (hal_sys_timer_get()-time_start)); + bt_iqimb_dma_enable(st->M0data, fftsize); + while (1) { + if (iqimb_dma_status == 0) + break; + } + caculate_energy_main_test(st, &Energy, &Energy1, fftsize); + // BT_DRV_TRACE(4,"IQ phase correct addr = 0x%08x,phase_mis = %d ,gain_mis + // = %d,Energy = %d",addr,phase_mis_base,gain_mis_base,Energy1); + } + if (k == 0) { + chs = 27; + addr = addr - 13 * 4; + } else if (k == 1) { + chs = 26; + addr = addr - 12 * 4; + } else { + chs = 26; + addr = addr - 12 * 4; + } + + bt_update_local_iq_calibration_val(k, gain_mis_base, phase_mis_base); + + for (int ch = 0; ch < chs; ch++) { + bt_iqimb_add_mismatch(0, gain_mis_base, phase_mis_base, 0, 0, + addr); // no mismatch + // osDelay(1); + // BT_DRV_TRACE(4,"IQ phase correct addr = 0x%08x,phase_mis = %d ,gain_mis + // = %d,Energy = %d",addr,phase_mis_base,gain_mis_base,Energy1); + addr = addr + 4; + } + BT_DRV_TRACE(1, "use time: %d ms", + __TICKS_TO_MS(hal_sys_timer_get() - time_start)); + // BT_DRV_TRACE(4,"IQ phase correct addr = 0x%08x,phase_mis = %d ,gain_mis = + // %d,Energy = %d",addr-4,phase_mis_base,gain_mis_base,Energy1); + } +} + +int bt_iqimb_test_ex(int mismatch_type) { + + bt_IQ_DC_Mismatch_Correction_Release(); + + return 1; +} + +#endif // TX_IQ_CAL #endif diff --git a/platform/drivers/bt/bt_drv_common.c b/platform/drivers/bt/bt_drv_common.c index bdfeb43..9b8a2b6 100644 --- a/platform/drivers/bt/bt_drv_common.c +++ b/platform/drivers/bt/bt_drv_common.c @@ -13,51 +13,48 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" +#include "app_utils.h" +#include "besbt_string.h" +#include "bt_drv.h" +#include "bt_drv_interface.h" +#include "bt_drv_internal.h" +#include "bt_drv_reg_op.h" +#include "hal_chipid.h" #include "hal_i2c.h" #include "hal_uart.h" -#include "hal_chipid.h" -#include "bt_drv.h" -#include "bt_drv_internal.h" -#include "bt_drv_interface.h" -#include "bt_drv_reg_op.h" -#include "app_utils.h" +#include "plat_types.h" #include "string.h" -#include "besbt_string.h" -#define BT_DUMP_LEN_LINE 100 -#define SLOT_SIZE 625 -#define MAX_SLOT_CLOCK ((1L<<27) - 1) -#define CLK_SUB(clock_a, clock_b) ((uint32_t)(((clock_a) - (clock_b)) & MAX_SLOT_CLOCK)) -#define CLK_ADD_2(clock_a, clock_b) ((uint32_t)(((clock_a) + (clock_b)) & MAX_SLOT_CLOCK)) +#define BT_DUMP_LEN_LINE 100 +#define SLOT_SIZE 625 +#define CLK_SUB(clock_a, clock_b) \ + ((uint32_t)(((clock_a) - (clock_b)) & MAX_SLOT_CLOCK)) +#define CLK_ADD_2(clock_a, clock_b) \ + ((uint32_t)(((clock_a) + (clock_b)) & MAX_SLOT_CLOCK)) struct bt_cb_tag bt_drv_func_cb = {NULL}; -struct bt_cb_tag* bt_drv_get_func_cb_ptr(void) -{ - return &bt_drv_func_cb; +struct bt_cb_tag *bt_drv_get_func_cb_ptr(void) { + return &bt_drv_func_cb; } -///only used for bt chip write patch data for speed up -void btdrv_memory_copy(uint32_t *dest,const uint32_t *src,uint16_t length) -{ - // memcpy(dest,src,length); - uint16_t i; - for(i=0; i SLOT_SIZE) - { - new_cnt -= SLOT_SIZE; - new_clk = CLK_SUB(new_clk, 1); - } + if (new_cnt > SLOT_SIZE) { + new_cnt -= SLOT_SIZE; + new_clk = CLK_SUB(new_clk, 1); + } - *master_clk = new_clk; - *master_cnt = new_cnt; - return 0; + *master_clk = new_clk; + *master_cnt = new_cnt; + return 0; } -void bt_drv_set_fa_invert_enable(uint8_t en) -{ - BTDIGITAL_REG_SET_FIELD(0xd0220468, 1, 17, en); - BT_DRV_TRACE(1,"BT_DRV:set fa invert en=%d", en); +void bt_drv_set_fa_invert_enable(uint8_t en) { + BTDIGITAL_REG_SET_FIELD(0xd0220468, 1, 17, en); + BT_DRV_TRACE(1, "BT_DRV:set fa invert en=%d", en); } -void btdrv_trigger_coredump(void) -{ - uint8_t *null_pointer = 0; - *null_pointer = 0;//MPU trigger coredump +void btdrv_trigger_coredump(void) { + uint8_t *null_pointer = 0; + *null_pointer = 0; // MPU trigger coredump } -int btdrv_clkcnt_diff(int32_t clk1, int16_t cnt1, - int32_t clk2, int16_t cnt2, - int32_t *diff_clk, uint16_t *diff_bit) -{ - int32_t new_clk; - int16_t new_cnt; - int diff_us; +int btdrv_clkcnt_diff(int32_t clk1, int16_t cnt1, int32_t clk2, int16_t cnt2, + int32_t *diff_clk, uint16_t *diff_bit) { + int32_t new_clk; + int16_t new_cnt; + int diff_us; - new_clk = (int32_t)clk1 - (int32_t)clk2; - new_cnt = cnt1 - cnt2; - if (new_cnt < 0) - { - new_cnt += SLOT_SIZE; - }else{ - new_clk -= 1; - } + new_clk = (int32_t)clk1 - (int32_t)clk2; + new_cnt = cnt1 - cnt2; + if (new_cnt < 0) { + new_cnt += SLOT_SIZE; + } else { + new_clk -= 1; + } - *diff_clk = new_clk; - *diff_bit = new_cnt; + *diff_clk = new_clk; + *diff_bit = new_cnt; - diff_us = new_clk * SLOT_SIZE + (SLOT_SIZE - new_cnt); + diff_us = new_clk * SLOT_SIZE + (SLOT_SIZE - new_cnt); - return diff_us; + return diff_us; } -void WEAK btdrv_set_controller_trace_enable(uint8_t trace_level) -{ +void WEAK btdrv_set_controller_trace_enable(uint8_t trace_level) {} + +void WEAK btdrv_set_lmp_trace_enable(void) {} +static bool g_controller_trace_dump_enable = false; +bool btdrv_get_controller_trace_dump_enable(void) { + return g_controller_trace_dump_enable; +} +void btdrv_set_controller_trace_dump_enable(void) { + g_controller_trace_dump_enable = true; } -void WEAK btdrv_set_lmp_trace_enable(void) -{ -} -static bool g_controller_trace_dump_enable = false; -bool btdrv_get_controller_trace_dump_enable(void) -{ - return g_controller_trace_dump_enable; -} -void btdrv_set_controller_trace_dump_enable(void) -{ - g_controller_trace_dump_enable = true; +void btdrv_btc_fault_dump(void) { + app_wdt_close(); + bt_drv_reg_op_crash_dump(); } -void btdrv_btc_fault_dump(void) -{ - app_wdt_close(); - bt_drv_reg_op_crash_dump(); -} - -void btdrv_dump_mem(uint8_t *dump_mem_start, uint32_t dump_length, uint8_t dump_type) -{ +void btdrv_dump_mem(uint8_t *dump_mem_start, uint32_t dump_length, + uint8_t dump_type) { #if CONTROLLER_DUMP_ENABLE - uint32_t dump_counter=0; - uint32_t dump_line=0; + uint32_t dump_counter = 0; + uint32_t dump_line = 0; - hal_sys_timer_delay(MS_TO_TICKS(100)); - switch (dump_type) - { - case BT_SUB_SYS_TYPE: - BT_DRV_TRACE(1,"controller dump start, dump len=0x%x",dump_length); - break; + hal_sys_timer_delay(MS_TO_TICKS(100)); + switch (dump_type) { + case BT_SUB_SYS_TYPE: + BT_DRV_TRACE(1, "controller dump start, dump len=0x%x", dump_length); + break; - case MCU_SYS_TYPE: - BT_DRV_TRACE(1,"mcu dump start, dump len=0x%x",dump_length); - break; + case MCU_SYS_TYPE: + BT_DRV_TRACE(1, "mcu dump start, dump len=0x%x", dump_length); + break; - case BT_EM_AREA_1_TYPE: - BT_DRV_TRACE(1,"em_area1 dump start, dump len=0x%x",dump_length); - break; + case BT_EM_AREA_1_TYPE: + BT_DRV_TRACE(1, "em_area1 dump start, dump len=0x%x", dump_length); + break; - case BT_EM_AREA_2_TYPE: - BT_DRV_TRACE(1,"em_area2 dump start, dump len=0x%x",dump_length); - break; + case BT_EM_AREA_2_TYPE: + BT_DRV_TRACE(1, "em_area2 dump start, dump len=0x%x", dump_length); + break; + } + while (dump_counter < dump_length) { + uint32_t data_left = dump_length - dump_counter; + dump_line += 1; + if (data_left >= BT_DUMP_LEN_LINE) { + BT_DRV_TRACE(1, "dump_line=%d", dump_line); + DUMP8("%02x", dump_mem_start, BT_DUMP_LEN_LINE); + hal_trace_flush_buffer(); + dump_mem_start += BT_DUMP_LEN_LINE; + dump_counter += BT_DUMP_LEN_LINE; + hal_sys_timer_delay(MS_TO_TICKS(50)); + } else { + BT_DRV_TRACE(1, "dump_line=%d", dump_line); + DUMP8("%02x", dump_mem_start, data_left); + hal_trace_flush_buffer(); + hal_sys_timer_delay(MS_TO_TICKS(50)); + break; } - while (dump_counter < dump_length) - { - uint32_t data_left = dump_length - dump_counter; - dump_line += 1; - if (data_left >= BT_DUMP_LEN_LINE) - { - BT_DRV_TRACE(1,"dump_line=%d", dump_line); - DUMP8("%02x", dump_mem_start, BT_DUMP_LEN_LINE); - hal_trace_flush_buffer(); - dump_mem_start += BT_DUMP_LEN_LINE; - dump_counter += BT_DUMP_LEN_LINE; - hal_sys_timer_delay(MS_TO_TICKS(50)); - } - else - { - BT_DRV_TRACE(1,"dump_line=%d", dump_line); - DUMP8("%02x", dump_mem_start, data_left); - hal_trace_flush_buffer(); - hal_sys_timer_delay(MS_TO_TICKS(50)); - break; - } - } - switch (dump_type) - { - case BT_SUB_SYS_TYPE: - BT_DRV_TRACE(0,"controller dump end"); - break; + } + switch (dump_type) { + case BT_SUB_SYS_TYPE: + BT_DRV_TRACE(0, "controller dump end"); + break; - case MCU_SYS_TYPE: - BT_DRV_TRACE(0,"mcu dump end"); - break; + case MCU_SYS_TYPE: + BT_DRV_TRACE(0, "mcu dump end"); + break; - case BT_EM_AREA_1_TYPE: - BT_DRV_TRACE(0,"em_area1 dump end"); - break; + case BT_EM_AREA_1_TYPE: + BT_DRV_TRACE(0, "em_area1 dump end"); + break; - case BT_EM_AREA_2_TYPE: - BT_DRV_TRACE(0,"em_area2 dump end"); - break; - } + case BT_EM_AREA_2_TYPE: + BT_DRV_TRACE(0, "em_area2 dump end"); + break; + } #endif } -void btdrv_trace_config(BT_CONTROLER_TRACE_TYPE trace_config) -{ - if (trace_config & BT_CONTROLER_TRACE_TYPE_INTERSYS) - { - btdrv_set_intersys_trace_enable(); - } +void btdrv_trace_config(BT_CONTROLER_TRACE_TYPE trace_config) { + if (trace_config & BT_CONTROLER_TRACE_TYPE_INTERSYS) { + btdrv_set_intersys_trace_enable(); + } - if (trace_config & BT_CONTROLER_TRACE_TYPE_CONTROLLER) - { - btdrv_set_controller_trace_enable(0x00); - } + if (trace_config & BT_CONTROLER_TRACE_TYPE_CONTROLLER) { + btdrv_set_controller_trace_enable(0x00); + } - if (trace_config & BT_CONTROLER_TRACE_TYPE_LMP_TRACE) - { - btdrv_set_lmp_trace_enable(); - } + if (trace_config & BT_CONTROLER_TRACE_TYPE_LMP_TRACE) { + btdrv_set_lmp_trace_enable(); + } - if (trace_config & BT_CONTROLER_TRACE_TYPE_SPUV_HCI_BUFF) - { - btdrv_set_spuv_hci_buff_trace_enable(); - } + if (trace_config & BT_CONTROLER_TRACE_TYPE_SPUV_HCI_BUFF) { + btdrv_set_spuv_hci_buff_trace_enable(); + } - if (trace_config & BT_CONTROLER_FILTER_TRACE_TYPE_A2DP_STREAM) - { - btdrv_set_a2dp_stream_trace_disable(); - } + if (trace_config & BT_CONTROLER_FILTER_TRACE_TYPE_A2DP_STREAM) { + btdrv_set_a2dp_stream_trace_disable(); + } #if CONTROLLER_MEM_LOG_ENABLE - btdrv_set_controller_trace_dump_enable(); + btdrv_set_controller_trace_dump_enable(); #endif } -bool bt_drv_is_enhanced_ibrt_rom(void) -{ - bool ret = false; +bool bt_drv_is_enhanced_ibrt_rom(void) { + bool ret = false; #ifdef CHIP_BEST2300P - if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) - ret = true; + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) + ret = true; #elif CHIP_BEST1400 - if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_2) - ret = true; + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_2) + ret = true; #elif CHIP_BEST1402 - ret = true; + ret = true; #elif CHIP_BEST2300A - ret = true; + ret = true; #elif FPGA - ret = true; + ret = true; #elif CHIP_BEST2300 - ret = true; + ret = true; #endif - return ret; + return ret; } -bool bt_drv_is_esco_auto_accept_support(void) -{ - bool ret = false; +bool bt_drv_is_esco_auto_accept_support(void) { + bool ret = false; #ifdef CHIP_BEST2300P - if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_2) - ret = true; + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_2) + ret = true; #elif CHIP_BEST1400 - if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_4) - ret = true; + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_4) + ret = true; #elif CHIP_BEST1402 - if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) - ret = true; + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) + ret = true; #elif CHIP_BEST2300A - ret = true; + ret = true; #endif - return ret; + return ret; } -bool btdrv_is_acl_ecc_softbit_support(void) -{ - bool ret = false; +bool btdrv_is_acl_ecc_softbit_support(void) { + bool ret = false; #ifdef CHIP_BEST2300A - ret = true; + ret = true; #endif - return ret; + return ret; } - -void btdrv_softbit_enable(uint16_t connhdl, uint8_t type1,uint8_t type2,uint8_t type3, uint8_t num) -{ - if(btdrv_is_acl_ecc_softbit_support()) - { +void btdrv_softbit_enable(uint16_t connhdl, uint8_t type1, uint8_t type2, + uint8_t type3, uint8_t num) { + if (btdrv_is_acl_ecc_softbit_support()) { #if (defined(SOFTBIT_EN)) - btdrv_softbit_config(connhdl, type1, type2, type3, num); + btdrv_softbit_config(connhdl, type1, type2, type3, num); #endif - } + } } -void bt_drv_bt_tport_type_config(void) -{ - uint32_t tport_type = 0xb1b1; +void bt_drv_bt_tport_type_config(void) { + uint32_t tport_type = 0xb1b1; #ifdef __BT_DEBUG_TPORTS__ - tport_type = TPORT_TYPE; + tport_type = TPORT_TYPE; #endif - BTDIGITAL_REG(0xd0220050) = tport_type; - BTDIGITAL_REG(0xd0340000) = 0x23620200; + BTDIGITAL_REG(0xd0220050) = tport_type; + BTDIGITAL_REG(0xd0340000) = 0x23620200; - BT_DRV_TRACE(1,"BT_DRV: tport type=0x%x",tport_type); + BT_DRV_TRACE(1, "BT_DRV: tport type=0x%x", tport_type); } -bool bt_drv_is_bes_fa_mode_en(void) -{ - bool ret = false; +bool bt_drv_is_bes_fa_mode_en(void) { + bool ret = false; #ifdef __BES_FA_MODE__ - ret = true; + ret = true; #endif - return ret; + return ret; } -bool bt_drv_is_support_multipoint_ibrt(void) -{ - bool ret = false; +bool bt_drv_is_support_multipoint_ibrt(void) { + bool ret = false; #ifdef __FPGA_BT_1500__ - ret = true; + ret = true; #endif - return ret; + return ret; } -void bt_drv_enable_hw_spi(uint8_t elt_idx, bool hwspien) -{ +void bt_drv_enable_hw_spi(uint8_t elt_idx, bool hwspien) { #ifdef CHIP_BEST2300A - bt_drv_reg_op_hw_spi_en_setf(elt_idx, hwspien); + bt_drv_reg_op_hw_spi_en_setf(elt_idx, hwspien); #endif } -struct btstack_chip_config_t -{ - uint16_t hci_dbg_set_sync_config_cmd_opcode; - uint16_t hci_dbg_set_sco_switch_cmd_opcode; +struct btstack_chip_config_t { + uint16_t hci_dbg_set_sync_config_cmd_opcode; + uint16_t hci_dbg_set_sco_switch_cmd_opcode; } g_bt_drv_btstack_chip_config = { HCI_DBG_SET_SYNC_CONFIG_CMD_OPCODE, HCI_DBG_SET_SCO_SWITCH_CMD_OPCODE, }; -void* bt_drv_get_btstack_chip_config(void) -{ - return &g_bt_drv_btstack_chip_config; +void *bt_drv_get_btstack_chip_config(void) { + return &g_bt_drv_btstack_chip_config; } -void bt_drv_hwspi_select(uint8_t link_id, uint8_t spi_idx) -{ +void bt_drv_hwspi_select(uint8_t link_id, uint8_t spi_idx) { #ifdef __FA_RX_GAIN_CTRL__ - btdrv_spi_trig_select(link_id, spi_idx); + btdrv_spi_trig_select(link_id, spi_idx); #endif } /// BCH size -#define LD_BCH_SIZE 8 +#define LD_BCH_SIZE 8 -static const uint8_t ld_util_bch_ppolynom[LD_BCH_SIZE] = -{ - 0x83, 0x84, 0x8D, 0x96, 0xBB, 0xCC, 0x54, 0xFC -}; +static const uint8_t ld_util_bch_ppolynom[LD_BCH_SIZE] = { + 0x83, 0x84, 0x8D, 0x96, 0xBB, 0xCC, 0x54, 0xFC}; -static const uint8_t ld_util_bch_gpolynom[LD_BCH_SIZE] = -{ - 0x00, 0x00, 0x00, 0x05, 0x85, 0x71, 0x3D, 0xA9 -}; +static const uint8_t ld_util_bch_gpolynom[LD_BCH_SIZE] = { + 0x00, 0x00, 0x00, 0x05, 0x85, 0x71, 0x3D, 0xA9}; -static void ld_util_bch_modulo(uint8_t *dividend, const uint8_t *divisor, uint8_t *rest) -{ - uint8_t clock; - uint8_t carry; - uint8_t index; - uint8_t dividend_tmp[LD_BCH_SIZE]; +static void ld_util_bch_modulo(uint8_t *dividend, const uint8_t *divisor, + uint8_t *rest) { + uint8_t clock; + uint8_t carry; + uint8_t index; + uint8_t dividend_tmp[LD_BCH_SIZE]; - // Copy dividend vector in a temporary vector - // And reset rest vector - for (index = 0 ; index < LD_BCH_SIZE ; index++) - { - dividend_tmp[index] = dividend[index]; - rest[index] = 0; - } - - // Execute 64 times the LFSR process - for (clock = 0 ; clock < 64 ; clock++) - { - // Store bit Rest(degree-1) in carry (assume degree of G is 32) - carry = rest[3] & 0x02; - - // the rest is shifted of 1 bit Left - // The MSB of rest if lost and the MSB of dividend is shifted in LSB - rest[0] = (rest[0] << 1) | ((rest[1] & 0x80) >> 7); - rest[1] = (rest[1] << 1) | ((rest[2] & 0x80) >> 7); - rest[2] = (rest[2] << 1) | ((rest[3] & 0x80) >> 7); - rest[3] = (rest[3] << 1) | ((rest[4] & 0x80) >> 7); - rest[4] = (rest[4] << 1) | ((rest[5] & 0x80) >> 7); - rest[5] = (rest[5] << 1) | ((rest[6] & 0x80) >> 7); - rest[6] = (rest[6] << 1) | ((rest[7] & 0x80) >> 7); - rest[7] = (rest[7] << 1) | ((dividend_tmp[0] & 0x80) >> 7); - - // the dividend_tmp is shifted of 1 bit Left (a 0 is shifted in LSB) - dividend_tmp[0] = (dividend_tmp[0] << 1) | ((dividend_tmp[1] & 0x80) >> 7); - dividend_tmp[1] = (dividend_tmp[1] << 1) | ((dividend_tmp[2] & 0x80) >> 7); - dividend_tmp[2] = (dividend_tmp[2] << 1) | ((dividend_tmp[3] & 0x80) >> 7); - dividend_tmp[3] = (dividend_tmp[3] << 1) | ((dividend_tmp[4] & 0x80) >> 7); - dividend_tmp[4] = (dividend_tmp[4] << 1) | ((dividend_tmp[5] & 0x80) >> 7); - dividend_tmp[5] = (dividend_tmp[5] << 1) | ((dividend_tmp[6] & 0x80) >> 7); - dividend_tmp[6] = (dividend_tmp[6] << 1) | ((dividend_tmp[7] & 0x80) >> 7); - dividend_tmp[7] = (dividend_tmp[7] << 1); - - // If bit carry value was 1 - if (carry != 0) - { - // rest = rest XOR Divisor - for (index = 0 ; index < LD_BCH_SIZE ; index++) - { - rest[index] ^= divisor[index]; - } - } + // Copy dividend vector in a temporary vector + // And reset rest vector + for (index = 0; index < LD_BCH_SIZE; index++) { + dividend_tmp[index] = dividend[index]; + rest[index] = 0; + } + + // Execute 64 times the LFSR process + for (clock = 0; clock < 64; clock++) { + // Store bit Rest(degree-1) in carry (assume degree of G is 32) + carry = rest[3] & 0x02; + + // the rest is shifted of 1 bit Left + // The MSB of rest if lost and the MSB of dividend is shifted in LSB + rest[0] = (rest[0] << 1) | ((rest[1] & 0x80) >> 7); + rest[1] = (rest[1] << 1) | ((rest[2] & 0x80) >> 7); + rest[2] = (rest[2] << 1) | ((rest[3] & 0x80) >> 7); + rest[3] = (rest[3] << 1) | ((rest[4] & 0x80) >> 7); + rest[4] = (rest[4] << 1) | ((rest[5] & 0x80) >> 7); + rest[5] = (rest[5] << 1) | ((rest[6] & 0x80) >> 7); + rest[6] = (rest[6] << 1) | ((rest[7] & 0x80) >> 7); + rest[7] = (rest[7] << 1) | ((dividend_tmp[0] & 0x80) >> 7); + + // the dividend_tmp is shifted of 1 bit Left (a 0 is shifted in LSB) + dividend_tmp[0] = (dividend_tmp[0] << 1) | ((dividend_tmp[1] & 0x80) >> 7); + dividend_tmp[1] = (dividend_tmp[1] << 1) | ((dividend_tmp[2] & 0x80) >> 7); + dividend_tmp[2] = (dividend_tmp[2] << 1) | ((dividend_tmp[3] & 0x80) >> 7); + dividend_tmp[3] = (dividend_tmp[3] << 1) | ((dividend_tmp[4] & 0x80) >> 7); + dividend_tmp[4] = (dividend_tmp[4] << 1) | ((dividend_tmp[5] & 0x80) >> 7); + dividend_tmp[5] = (dividend_tmp[5] << 1) | ((dividend_tmp[6] & 0x80) >> 7); + dividend_tmp[6] = (dividend_tmp[6] << 1) | ((dividend_tmp[7] & 0x80) >> 7); + dividend_tmp[7] = (dividend_tmp[7] << 1); + + // If bit carry value was 1 + if (carry != 0) { + // rest = rest XOR Divisor + for (index = 0; index < LD_BCH_SIZE; index++) { + rest[index] ^= divisor[index]; + } } + } } -void ld_util_bch_create(uint8_t *lap, uint8_t *bch) -{ - uint8_t vector[LD_BCH_SIZE]; - uint8_t vector2[LD_BCH_SIZE]; - uint8_t index; +void ld_util_bch_create(uint8_t *lap, uint8_t *bch) { + uint8_t vector[LD_BCH_SIZE]; + uint8_t vector2[LD_BCH_SIZE]; + uint8_t index; - // Copy lap and Appended in bch - if (lap[2] & 0x80) - { - vector[0] = 0x4C; // If a23 = 1 - } - else - { - vector[0] = 0xB0; // If a23 = 0 - } + // Copy lap and Appended in bch + if (lap[2] & 0x80) { + vector[0] = 0x4C; // If a23 = 1 + } else { + vector[0] = 0xB0; // If a23 = 0 + } - vector[0] |= lap[2] >> 6; - vector[1] = lap[2] << 2 | lap[1] >> 6; - vector[2] = lap[1] << 2 | lap[0] >> 6; - vector[3] = lap[0] << 2; + vector[0] |= lap[2] >> 6; + vector[1] = lap[2] << 2 | lap[1] >> 6; + vector[2] = lap[1] << 2 | lap[0] >> 6; + vector[3] = lap[0] << 2; - // Xor Vector and PN (Vector contains only 30 significant bits) - for (index = 0 ; index < 4; index++) - { - vector[index] ^= ld_util_bch_ppolynom[index]; - } + // Xor Vector and PN (Vector contains only 30 significant bits) + for (index = 0; index < 4; index++) { + vector[index] ^= ld_util_bch_ppolynom[index]; + } - // Reset 34 last bits - vector[3] &= 0xFC; - vector[4] = 0; - vector[5] = 0; - vector[6] = 0; - vector[7] = 0; + // Reset 34 last bits + vector[3] &= 0xFC; + vector[4] = 0; + vector[5] = 0; + vector[6] = 0; + vector[7] = 0; - // Generate Parity bits Vector Modulo G - ld_util_bch_modulo(vector, ld_util_bch_gpolynom, vector2); + // Generate Parity bits Vector Modulo G + ld_util_bch_modulo(vector, ld_util_bch_gpolynom, vector2); - // Create CodeWord (concatenate Modulo result and Xored Vector) - vector[3] |= vector2[3]; - vector[4] = vector2[4]; - vector[5] = vector2[5]; - vector[6] = vector2[6]; - vector[7] = vector2[7]; + // Create CodeWord (concatenate Modulo result and Xored Vector) + vector[3] |= vector2[3]; + vector[4] = vector2[4]; + vector[5] = vector2[5]; + vector[6] = vector2[6]; + vector[7] = vector2[7]; - // Xor codeWord and PN - for (index = 0 ; index < 8; index++) - { - bch[7-index] = vector[index] ^ ld_util_bch_ppolynom[index]; - } + // Xor codeWord and PN + for (index = 0; index < 8; index++) { + bch[7 - index] = vector[index] ^ ld_util_bch_ppolynom[index]; + } } -void bt_drv_rssi_dump_handler(void) -{ - rx_agc_t bt_agc = {0,0xf}; - for(int i = 0; isample_rate); + if (codec_int_cfg.user_map & CODEC_USER_ANC) { + // Check ANC sample rate + if (codec_anc_handler) { + enum AUD_SAMPRATE_T cfg_rate; + enum AUD_SAMPRATE_T old_rate; + + cfg_rate = hal_codec_anc_convert_rate(cfg->sample_rate); + if (cfg_rate != codec_anc_samp_rate) { + old_rate = codec_anc_samp_rate; + + codec_anc_handler(stream, cfg_rate, NULL, NULL); + + codec_anc_samp_rate = cfg_rate; + TRACE(5, + "%s: ANC sample rate changes from %u to %u due to stream=%d " + "samp_rate=%u", + __func__, old_rate, codec_anc_samp_rate, stream, + cfg->sample_rate); + } + } + } + codec_int_cfg.stream_cfg[stream].codec_cfg.sample_rate = cfg->sample_rate; + codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag |= + HAL_CODEC_CONFIG_SAMPLE_RATE; + + if (codec_int_cfg.stream_cfg[stream].codec_cfg.bits != cfg->bits) { + CODEC_TRACE(2, "[bits]old=%d new=%d", + codec_int_cfg.stream_cfg[stream].codec_cfg.bits, cfg->bits); + codec_int_cfg.stream_cfg[stream].codec_cfg.bits = cfg->bits; + codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag |= + HAL_CODEC_CONFIG_BITS; + } + + if (codec_int_cfg.stream_cfg[stream].codec_cfg.channel_num != + cfg->channel_num) { + CODEC_TRACE(2, "[channel_num]old=%d new=%d", + codec_int_cfg.stream_cfg[stream].codec_cfg.channel_num, + cfg->channel_num); + codec_int_cfg.stream_cfg[stream].codec_cfg.channel_num = cfg->channel_num; + codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag |= + HAL_CODEC_CONFIG_CHANNEL_NUM; + } + + ch_map = cfg->channel_map; + if (ch_map == 0) { + if (stream == AUD_STREAM_PLAYBACK) { + ch_map = (enum AUD_CHANNEL_MAP_T)CODEC_OUTPUT_DEV; } else { - // Codec initialized before -- only different config items need to be set - codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag = HAL_CODEC_CONFIG_NULL; + ch_map = + (enum AUD_CHANNEL_MAP_T)hal_codec_get_input_path_cfg(cfg->io_path); } + ch_map &= AUD_CHANNEL_MAP_ALL; + } - // Always config sample rate, for the pll setting might have been changed by the other stream - CODEC_TRACE(2,"[sample_rate]old=%d new=%d", codec_int_cfg.stream_cfg[stream].codec_cfg.sample_rate, cfg->sample_rate); - if (codec_int_cfg.user_map & CODEC_USER_ANC) { - // Check ANC sample rate - if (codec_anc_handler) { - enum AUD_SAMPRATE_T cfg_rate; - enum AUD_SAMPRATE_T old_rate; + if (codec_int_cfg.stream_cfg[stream].codec_cfg.channel_map != ch_map) { + CODEC_TRACE(2, "[channel_map]old=0x%x new=0x%x", + codec_int_cfg.stream_cfg[stream].codec_cfg.channel_map, ch_map); + codec_int_cfg.stream_cfg[stream].codec_cfg.channel_map = ch_map; + codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag |= + HAL_CODEC_CONFIG_CHANNEL_MAP | HAL_CODEC_CONFIG_VOL | + HAL_CODEC_CONFIG_BITS; + } - cfg_rate = hal_codec_anc_convert_rate(cfg->sample_rate); - if (cfg_rate != codec_anc_samp_rate) { - old_rate = codec_anc_samp_rate; + if (codec_int_cfg.stream_cfg[stream].codec_cfg.use_dma != cfg->use_dma) { + CODEC_TRACE(2, "[use_dma]old=%d new=%d", + codec_int_cfg.stream_cfg[stream].codec_cfg.use_dma, + cfg->use_dma); + codec_int_cfg.stream_cfg[stream].codec_cfg.use_dma = cfg->use_dma; + } - codec_anc_handler(stream, cfg_rate, NULL, NULL); - - codec_anc_samp_rate = cfg_rate; - TRACE(5,"%s: ANC sample rate changes from %u to %u due to stream=%d samp_rate=%u", - __func__, old_rate, codec_anc_samp_rate, stream, cfg->sample_rate); - } - } + if (codec_int_cfg.stream_cfg[stream].codec_cfg.vol != cfg->vol) { + CODEC_TRACE(3, "[vol]old=%d new=%d chan_vol_set=%d", + codec_int_cfg.stream_cfg[stream].codec_cfg.vol, cfg->vol, + codec_int_cfg.chan_vol_set[stream]); + codec_int_cfg.stream_cfg[stream].codec_cfg.vol = cfg->vol; + if (!codec_int_cfg.chan_vol_set[stream]) { + codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag |= + HAL_CODEC_CONFIG_VOL; } - codec_int_cfg.stream_cfg[stream].codec_cfg.sample_rate = cfg->sample_rate; - codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag |= HAL_CODEC_CONFIG_SAMPLE_RATE; + } - if(codec_int_cfg.stream_cfg[stream].codec_cfg.bits != cfg->bits) - { - CODEC_TRACE(2,"[bits]old=%d new=%d", codec_int_cfg.stream_cfg[stream].codec_cfg.bits, cfg->bits); - codec_int_cfg.stream_cfg[stream].codec_cfg.bits = cfg->bits; - codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag |= HAL_CODEC_CONFIG_BITS; - } + if (codec_int_cfg.stream_cfg[stream].codec_cfg.io_path != cfg->io_path) { + CODEC_TRACE(2, "[io_path]old=%d new=%d", + codec_int_cfg.stream_cfg[stream].codec_cfg.io_path, + cfg->io_path); + codec_int_cfg.stream_cfg[stream].codec_cfg.io_path = cfg->io_path; + } - if(codec_int_cfg.stream_cfg[stream].codec_cfg.channel_num != cfg->channel_num) - { - CODEC_TRACE(2,"[channel_num]old=%d new=%d", codec_int_cfg.stream_cfg[stream].codec_cfg.channel_num, cfg->channel_num); - codec_int_cfg.stream_cfg[stream].codec_cfg.channel_num = cfg->channel_num; - codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag |= HAL_CODEC_CONFIG_CHANNEL_NUM; - } + CODEC_TRACE(3, "[%s]stream=%d set_flag=0x%x", __func__, stream, + codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag); + hal_codec_setup_stream(CODEC_INT_INST, stream, + &(codec_int_cfg.stream_cfg[stream].codec_cfg)); - ch_map = cfg->channel_map; - if (ch_map == 0) { - if (stream == AUD_STREAM_PLAYBACK) { - ch_map = (enum AUD_CHANNEL_MAP_T)CODEC_OUTPUT_DEV; - } else { - ch_map = (enum AUD_CHANNEL_MAP_T)hal_codec_get_input_path_cfg(cfg->io_path); - } - ch_map &= AUD_CHANNEL_MAP_ALL; - } - - if(codec_int_cfg.stream_cfg[stream].codec_cfg.channel_map != ch_map) - { - CODEC_TRACE(2,"[channel_map]old=0x%x new=0x%x", codec_int_cfg.stream_cfg[stream].codec_cfg.channel_map, ch_map); - codec_int_cfg.stream_cfg[stream].codec_cfg.channel_map = ch_map; - codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag |= HAL_CODEC_CONFIG_CHANNEL_MAP | HAL_CODEC_CONFIG_VOL | HAL_CODEC_CONFIG_BITS; - } - - if(codec_int_cfg.stream_cfg[stream].codec_cfg.use_dma != cfg->use_dma) - { - CODEC_TRACE(2,"[use_dma]old=%d new=%d", codec_int_cfg.stream_cfg[stream].codec_cfg.use_dma, cfg->use_dma); - codec_int_cfg.stream_cfg[stream].codec_cfg.use_dma = cfg->use_dma; - } - - if(codec_int_cfg.stream_cfg[stream].codec_cfg.vol != cfg->vol) - { - CODEC_TRACE(3,"[vol]old=%d new=%d chan_vol_set=%d", codec_int_cfg.stream_cfg[stream].codec_cfg.vol, cfg->vol, codec_int_cfg.chan_vol_set[stream]); - codec_int_cfg.stream_cfg[stream].codec_cfg.vol = cfg->vol; - if (!codec_int_cfg.chan_vol_set[stream]) { - codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag |= HAL_CODEC_CONFIG_VOL; - } - } - - if(codec_int_cfg.stream_cfg[stream].codec_cfg.io_path != cfg->io_path) - { - CODEC_TRACE(2,"[io_path]old=%d new=%d", codec_int_cfg.stream_cfg[stream].codec_cfg.io_path, cfg->io_path); - codec_int_cfg.stream_cfg[stream].codec_cfg.io_path = cfg->io_path; - } - - CODEC_TRACE(3,"[%s]stream=%d set_flag=0x%x",__func__,stream,codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag); - hal_codec_setup_stream(CODEC_INT_INST, stream, &(codec_int_cfg.stream_cfg[stream].codec_cfg)); - - return 0; + return 0; } -void codec_int_stream_mute(enum AUD_STREAM_T stream, bool mute) -{ - bool anc_on; +void codec_int_stream_mute(enum AUD_STREAM_T stream, bool mute) { + bool anc_on; - CODEC_TRACE(3,"%s: stream=%d mute=%d", __func__, stream, mute); + CODEC_TRACE(3, "%s: stream=%d mute=%d", __func__, stream, mute); - if (mute == codec_int_cfg.mute_state[stream]) { - CODEC_TRACE(2,"[%s] Codec already in mute status: %d", __func__, mute); - return; - } + if (mute == codec_int_cfg.mute_state[stream]) { + CODEC_TRACE(2, "[%s] Codec already in mute status: %d", __func__, mute); + return; + } - anc_on = !!(codec_int_cfg.user_map & CODEC_USER_ANC); + anc_on = !!(codec_int_cfg.user_map & CODEC_USER_ANC); - if (stream == AUD_STREAM_PLAYBACK) { - if (mute) { - if (!anc_on) { - analog_aud_codec_mute(); - } - hal_codec_dac_mute(true); - } else { - hal_codec_dac_mute(false); - if (!anc_on) { - analog_aud_codec_nomute(); - } - } + if (stream == AUD_STREAM_PLAYBACK) { + if (mute) { + if (!anc_on) { + analog_aud_codec_mute(); + } + hal_codec_dac_mute(true); } else { - hal_codec_adc_mute(mute); + hal_codec_dac_mute(false); + if (!anc_on) { + analog_aud_codec_nomute(); + } } + } else { + hal_codec_adc_mute(mute); + } - codec_int_cfg.mute_state[stream] = mute; + codec_int_cfg.mute_state[stream] = mute; } -void codec_int_stream_set_chan_vol(enum AUD_STREAM_T stream, enum AUD_CHANNEL_MAP_T ch_map, uint8_t vol) -{ - CODEC_TRACE(4,"%s: stream=%d ch_map=0x%X vol=%u", __func__, stream, ch_map, vol); +void codec_int_stream_set_chan_vol(enum AUD_STREAM_T stream, + enum AUD_CHANNEL_MAP_T ch_map, uint8_t vol) { + CODEC_TRACE(4, "%s: stream=%d ch_map=0x%X vol=%u", __func__, stream, ch_map, + vol); - codec_int_cfg.chan_vol_set[stream] = true; - hal_codec_set_chan_vol(stream, ch_map, vol); + codec_int_cfg.chan_vol_set[stream] = true; + hal_codec_set_chan_vol(stream, ch_map, vol); } -void codec_int_stream_restore_chan_vol(enum AUD_STREAM_T stream) -{ - CODEC_TRACE(2,"%s: stream=%d", __func__, stream); +void codec_int_stream_restore_chan_vol(enum AUD_STREAM_T stream) { + CODEC_TRACE(2, "%s: stream=%d", __func__, stream); - if (codec_int_cfg.chan_vol_set[stream]) { - codec_int_cfg.chan_vol_set[stream] = false; - // Restore normal volume - codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag = HAL_CODEC_CONFIG_VOL; - hal_codec_setup_stream(CODEC_INT_INST, stream, &(codec_int_cfg.stream_cfg[stream].codec_cfg)); - } + if (codec_int_cfg.chan_vol_set[stream]) { + codec_int_cfg.chan_vol_set[stream] = false; + // Restore normal volume + codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag = HAL_CODEC_CONFIG_VOL; + hal_codec_setup_stream(CODEC_INT_INST, stream, + &(codec_int_cfg.stream_cfg[stream].codec_cfg)); + } } -static void codec_hw_start(enum AUD_STREAM_T stream) -{ - CODEC_TRACE(2,"%s: stream=%d", __func__, stream); +static void codec_hw_start(enum AUD_STREAM_T stream) { + CODEC_TRACE(2, "%s: stream=%d", __func__, stream); - if (stream == AUD_STREAM_PLAYBACK) { - // Enable DAC before starting stream (specifically before enabling PA) - analog_aud_codec_dac_enable(true); - } + if (stream == AUD_STREAM_PLAYBACK) { + // Enable DAC before starting stream (specifically before enabling PA) + analog_aud_codec_dac_enable(true); + } - hal_codec_start_stream(CODEC_INT_INST, stream); + hal_codec_start_stream(CODEC_INT_INST, stream); } -static void codec_hw_stop(enum AUD_STREAM_T stream) -{ - CODEC_TRACE(2,"%s: stream=%d", __func__, stream); +static void codec_hw_stop(enum AUD_STREAM_T stream) { + CODEC_TRACE(2, "%s: stream=%d", __func__, stream); - hal_codec_stop_stream(CODEC_INT_INST, stream); + hal_codec_stop_stream(CODEC_INT_INST, stream); - if (stream == AUD_STREAM_PLAYBACK) { - // Disable DAC after stopping stream (specifically after disabling PA) - analog_aud_codec_dac_enable(false); - } + if (stream == AUD_STREAM_PLAYBACK) { + // Disable DAC after stopping stream (specifically after disabling PA) + analog_aud_codec_dac_enable(false); + } } -uint32_t codec_int_stream_start(enum AUD_STREAM_T stream) -{ - CODEC_TRACE(2,"%s: stream=%d", __func__, stream); +uint32_t codec_int_stream_start(enum AUD_STREAM_T stream) { + CODEC_TRACE(2, "%s: stream=%d", __func__, stream); - codec_int_cfg.stream_cfg[stream].started = true; + codec_int_cfg.stream_cfg[stream].started = true; - if (stream == AUD_STREAM_CAPTURE) { - analog_aud_codec_adc_enable(codec_int_cfg.stream_cfg[stream].codec_cfg.io_path, - codec_int_cfg.stream_cfg[stream].codec_cfg.channel_map, true); - } + if (stream == AUD_STREAM_CAPTURE) { + analog_aud_codec_adc_enable( + codec_int_cfg.stream_cfg[stream].codec_cfg.io_path, + codec_int_cfg.stream_cfg[stream].codec_cfg.channel_map, true); + } - hal_codec_start_interface(CODEC_INT_INST, stream, - codec_int_cfg.stream_cfg[stream].codec_cfg.use_dma); + hal_codec_start_interface(CODEC_INT_INST, stream, + codec_int_cfg.stream_cfg[stream].codec_cfg.use_dma); - if ((codec_int_cfg.user_map & CODEC_USER_ANC) == 0) { - codec_hw_start(stream); - } + if ((codec_int_cfg.user_map & CODEC_USER_ANC) == 0) { + codec_hw_start(stream); + } - return 0; + return 0; } -uint32_t codec_int_stream_stop(enum AUD_STREAM_T stream) -{ - CODEC_TRACE(2,"%s: stream=%d", __func__, stream); +uint32_t codec_int_stream_stop(enum AUD_STREAM_T stream) { + CODEC_TRACE(2, "%s: stream=%d", __func__, stream); - hal_codec_stop_interface(CODEC_INT_INST, stream); + hal_codec_stop_interface(CODEC_INT_INST, stream); - if ((codec_int_cfg.user_map & CODEC_USER_ANC) == 0) { - codec_hw_stop(stream); - } + if ((codec_int_cfg.user_map & CODEC_USER_ANC) == 0) { + codec_hw_stop(stream); + } - if (stream == AUD_STREAM_CAPTURE) { - analog_aud_codec_adc_enable(codec_int_cfg.stream_cfg[stream].codec_cfg.io_path, - codec_int_cfg.stream_cfg[stream].codec_cfg.channel_map, false); - } + if (stream == AUD_STREAM_CAPTURE) { + analog_aud_codec_adc_enable( + codec_int_cfg.stream_cfg[stream].codec_cfg.io_path, + codec_int_cfg.stream_cfg[stream].codec_cfg.channel_map, false); + } - codec_int_cfg.stream_cfg[stream].started = false; + codec_int_cfg.stream_cfg[stream].started = false; - return 0; + return 0; } -uint32_t codec_int_stream_close(enum AUD_STREAM_T stream) -{ - //close all stream - CODEC_TRACE(2,"%s: stream=%d", __func__, stream); - if (codec_int_cfg.stream_cfg[stream].started) { - codec_int_stream_stop(stream); - } - codec_int_stream_restore_chan_vol(stream); - codec_int_cfg.stream_cfg[stream].opened = false; - return 0; +uint32_t codec_int_stream_close(enum AUD_STREAM_T stream) { + // close all stream + CODEC_TRACE(2, "%s: stream=%d", __func__, stream); + if (codec_int_cfg.stream_cfg[stream].started) { + codec_int_stream_stop(stream); + } + codec_int_stream_restore_chan_vol(stream); + codec_int_cfg.stream_cfg[stream].opened = false; + return 0; } -static void codec_hw_open(enum CODEC_USER_T user) -{ - enum CODEC_USER_T old_map; +static void codec_hw_open(enum CODEC_USER_T user) { + enum CODEC_USER_T old_map; #ifdef __AUDIO_RESAMPLE__ - bool resample_en = !!hal_cmu_get_audio_resample_status(); + bool resample_en = !!hal_cmu_get_audio_resample_status(); #endif - old_map = codec_int_cfg.user_map; - codec_int_cfg.user_map |= user; + old_map = codec_int_cfg.user_map; + codec_int_cfg.user_map |= user; - if (old_map) { + if (old_map) { #ifdef __AUDIO_RESAMPLE__ - ASSERT(codec_int_cfg.resample_en == resample_en, - "%s: Bad resamp status %d for user 0x%X (old_map=0x%X)", __func__, resample_en, user, old_map); + ASSERT(codec_int_cfg.resample_en == resample_en, + "%s: Bad resamp status %d for user 0x%X (old_map=0x%X)", __func__, + resample_en, user, old_map); #endif - return; - } + return; + } #ifdef __AUDIO_RESAMPLE__ - codec_int_cfg.resample_en = resample_en; + codec_int_cfg.resample_en = resample_en; #endif - CODEC_TRACE(1,"%s", __func__); + CODEC_TRACE(1, "%s", __func__); #ifdef __CODEC_ASYNC_CLOSE__ - if (codec_timer == NULL) { - codec_timer = osTimerCreate (osTimer(CODEC_TIMER), osTimerOnce, NULL); - } - osTimerStop(codec_timer); + if (codec_timer == NULL) { + codec_timer = osTimerCreate(osTimer(CODEC_TIMER), osTimerOnce, NULL); + } + osTimerStop(codec_timer); #endif - // Audio resample: Might have different clock source, so must be reconfigured here - hal_codec_open(CODEC_INT_INST); + // Audio resample: Might have different clock source, so must be reconfigured + // here + hal_codec_open(CODEC_INT_INST); #ifdef __CODEC_ASYNC_CLOSE__ - CODEC_TRACE(2,"%s: codec_hw_state=%d", __func__, codec_hw_state); + CODEC_TRACE(2, "%s: codec_hw_state=%d", __func__, codec_hw_state); - if (codec_hw_state == CODEC_HW_STATE_CLOSED) { - codec_hw_state = CODEC_HW_STATE_OPENED; - // Continue to open the codec hardware - } else if (codec_hw_state == CODEC_HW_STATE_CLOSE_PENDING) { - // Still opened - codec_hw_state = CODEC_HW_STATE_OPENED; - return; - } else { - // Already opened - return; - } + if (codec_hw_state == CODEC_HW_STATE_CLOSED) { + codec_hw_state = CODEC_HW_STATE_OPENED; + // Continue to open the codec hardware + } else if (codec_hw_state == CODEC_HW_STATE_CLOSE_PENDING) { + // Still opened + codec_hw_state = CODEC_HW_STATE_OPENED; + return; + } else { + // Already opened + return; + } #endif - analog_aud_codec_open(); + analog_aud_codec_open(); } -static void codec_hw_close(enum CODEC_CLOSE_TYPE_T type, enum CODEC_USER_T user) -{ - codec_int_cfg.user_map &= ~user; +static void codec_hw_close(enum CODEC_CLOSE_TYPE_T type, + enum CODEC_USER_T user) { + codec_int_cfg.user_map &= ~user; - if (type == CODEC_CLOSE_NORMAL) { - if (codec_int_cfg.user_map) { - return; - } + if (type == CODEC_CLOSE_NORMAL) { + if (codec_int_cfg.user_map) { + return; } + } #ifdef __CODEC_ASYNC_CLOSE__ - CODEC_TRACE(3,"%s: type=%d codec_hw_state=%d", __func__, type, codec_hw_state); + CODEC_TRACE(3, "%s: type=%d codec_hw_state=%d", __func__, type, + codec_hw_state); #else - CODEC_TRACE(2,"%s: type=%d", __func__, type); + CODEC_TRACE(2, "%s: type=%d", __func__, type); #endif - if (type == CODEC_CLOSE_NORMAL) { - // Audio resample: Might have different clock source, so close now and reconfigure when open - hal_codec_close(CODEC_INT_INST); + if (type == CODEC_CLOSE_NORMAL) { + // Audio resample: Might have different clock source, so close now and + // reconfigure when open + hal_codec_close(CODEC_INT_INST); #ifdef CODEC_POWER_DOWN - memset(&codec_int_cfg, 0, sizeof(codec_int_cfg)); + memset(&codec_int_cfg, 0, sizeof(codec_int_cfg)); #endif #ifdef __CODEC_ASYNC_CLOSE__ - ASSERT(codec_hw_state == CODEC_HW_STATE_OPENED, "%s: (type=%d) Bad codec_hw_state=%d", __func__, type, codec_hw_state); - // Start a timer to close the codec hardware - codec_hw_state = CODEC_HW_STATE_CLOSE_PENDING; - osTimerStop(codec_timer); - osTimerStart(codec_timer, CODEC_ASYNC_CLOSE_DELAY); - return; - } else if (type == CODEC_CLOSE_ASYNC_REAL) { - if (codec_hw_state != CODEC_HW_STATE_CLOSE_PENDING) { - // Already closed or reopened - return; - } - codec_hw_state = CODEC_HW_STATE_CLOSED; -#endif - } else if (type == CODEC_CLOSE_FORCED) { - hal_codec_crash_mute(); + ASSERT(codec_hw_state == CODEC_HW_STATE_OPENED, + "%s: (type=%d) Bad codec_hw_state=%d", __func__, type, + codec_hw_state); + // Start a timer to close the codec hardware + codec_hw_state = CODEC_HW_STATE_CLOSE_PENDING; + osTimerStop(codec_timer); + osTimerStart(codec_timer, CODEC_ASYNC_CLOSE_DELAY); + return; + } else if (type == CODEC_CLOSE_ASYNC_REAL) { + if (codec_hw_state != CODEC_HW_STATE_CLOSE_PENDING) { + // Already closed or reopened + return; } + codec_hw_state = CODEC_HW_STATE_CLOSED; +#endif + } else if (type == CODEC_CLOSE_FORCED) { + hal_codec_crash_mute(); + } - analog_aud_codec_close(); + analog_aud_codec_close(); } -uint32_t codec_int_open(void) -{ - CODEC_TRACE(2,"%s: user_map=0x%X", __func__, codec_int_cfg.user_map); +uint32_t codec_int_open(void) { + CODEC_TRACE(2, "%s: user_map=0x%X", __func__, codec_int_cfg.user_map); - codec_hw_open(CODEC_USER_STREAM); + codec_hw_open(CODEC_USER_STREAM); - return 0; + return 0; } -uint32_t codec_int_close(enum CODEC_CLOSE_TYPE_T type) -{ - CODEC_TRACE(3,"%s: type=%d user_map=0x%X", __func__, type, codec_int_cfg.user_map); +uint32_t codec_int_close(enum CODEC_CLOSE_TYPE_T type) { + CODEC_TRACE(3, "%s: type=%d user_map=0x%X", __func__, type, + codec_int_cfg.user_map); - if (type == CODEC_CLOSE_NORMAL) { - if (codec_int_cfg.stream_cfg[AUD_STREAM_PLAYBACK].opened == false && - codec_int_cfg.stream_cfg[AUD_STREAM_CAPTURE].opened == false){ - codec_hw_close(type, CODEC_USER_STREAM); - } + if (type == CODEC_CLOSE_NORMAL) { + if (codec_int_cfg.stream_cfg[AUD_STREAM_PLAYBACK].opened == false && + codec_int_cfg.stream_cfg[AUD_STREAM_CAPTURE].opened == false) { + codec_hw_close(type, CODEC_USER_STREAM); + } + } else { + codec_hw_close(type, CODEC_USER_STREAM); + } + + return 0; +} + +#ifdef __CODEC_ASYNC_CLOSE__ +void codec_int_set_close_handler(CODEC_CLOSE_HANDLER hdlr) { + close_hdlr = hdlr; +} + +static void codec_timehandler(void const *param) { + if (close_hdlr) { + close_hdlr(); + } +} +#endif + +int codec_anc_open(enum ANC_TYPE_T type, enum AUD_SAMPRATE_T dac_rate, + enum AUD_SAMPRATE_T adc_rate, CODEC_ANC_HANDLER hdlr) { + bool anc_running = false; + + CODEC_TRACE(4, "%s: type=%d dac_rate=%d adc_rate=%d", __func__, type, + dac_rate, adc_rate); + + dac_rate = hal_codec_anc_convert_rate(dac_rate); + adc_rate = hal_codec_anc_convert_rate(adc_rate); + ASSERT(dac_rate == adc_rate, "%s: Unmatched rates: dac_rate=%u adc_rate=%u", + __func__, dac_rate, adc_rate); + + if (hdlr && (codec_int_cfg.user_map & CODEC_USER_STREAM)) { + enum AUD_SAMPRATE_T cfg_dac_rate, cfg_adc_rate; + + if (codec_int_cfg.stream_cfg[AUD_STREAM_PLAYBACK].opened) { + cfg_dac_rate = hal_codec_anc_convert_rate( + codec_int_cfg.stream_cfg[AUD_STREAM_PLAYBACK].codec_cfg.sample_rate); } else { - codec_hw_close(type, CODEC_USER_STREAM); + cfg_dac_rate = dac_rate; } - - return 0; -} - -#ifdef __CODEC_ASYNC_CLOSE__ -void codec_int_set_close_handler(CODEC_CLOSE_HANDLER hdlr) -{ - close_hdlr = hdlr; -} - -static void codec_timehandler(void const *param) -{ - if (close_hdlr) { - close_hdlr(); + if (codec_int_cfg.stream_cfg[AUD_STREAM_CAPTURE].opened) { + cfg_adc_rate = hal_codec_anc_convert_rate( + codec_int_cfg.stream_cfg[AUD_STREAM_CAPTURE].codec_cfg.sample_rate); + } else { + cfg_adc_rate = adc_rate; } -} -#endif - -int codec_anc_open(enum ANC_TYPE_T type, enum AUD_SAMPRATE_T dac_rate, enum AUD_SAMPRATE_T adc_rate, CODEC_ANC_HANDLER hdlr) -{ - bool anc_running = false; - - CODEC_TRACE(4,"%s: type=%d dac_rate=%d adc_rate=%d", __func__, type, dac_rate, adc_rate); - - dac_rate = hal_codec_anc_convert_rate(dac_rate); - adc_rate = hal_codec_anc_convert_rate(adc_rate); - ASSERT(dac_rate == adc_rate, "%s: Unmatched rates: dac_rate=%u adc_rate=%u", __func__, dac_rate, adc_rate); - - if (hdlr && (codec_int_cfg.user_map & CODEC_USER_STREAM)) { - enum AUD_SAMPRATE_T cfg_dac_rate, cfg_adc_rate; - - if (codec_int_cfg.stream_cfg[AUD_STREAM_PLAYBACK].opened) { - cfg_dac_rate = hal_codec_anc_convert_rate(codec_int_cfg.stream_cfg[AUD_STREAM_PLAYBACK].codec_cfg.sample_rate); - } else { - cfg_dac_rate = dac_rate; - } - if (codec_int_cfg.stream_cfg[AUD_STREAM_CAPTURE].opened) { - cfg_adc_rate = hal_codec_anc_convert_rate(codec_int_cfg.stream_cfg[AUD_STREAM_CAPTURE].codec_cfg.sample_rate); - } else { - cfg_adc_rate = adc_rate; - } - if (codec_int_cfg.stream_cfg[AUD_STREAM_PLAYBACK].opened && codec_int_cfg.stream_cfg[AUD_STREAM_CAPTURE].opened) { - ASSERT(cfg_dac_rate == cfg_adc_rate, "%s: Unmatched cfg rates: dac_rate=%u adc_rate=%u", __func__, cfg_dac_rate, cfg_adc_rate); - } else if (codec_int_cfg.stream_cfg[AUD_STREAM_CAPTURE].opened) { - cfg_dac_rate = cfg_adc_rate; - } - if (dac_rate != cfg_dac_rate) { - hdlr(AUD_STREAM_PLAYBACK, cfg_dac_rate, NULL, NULL); - TRACE(3,"%s: ANC sample rate changes from %u to %u", __func__, dac_rate, cfg_dac_rate); - dac_rate = cfg_dac_rate; - } + if (codec_int_cfg.stream_cfg[AUD_STREAM_PLAYBACK].opened && + codec_int_cfg.stream_cfg[AUD_STREAM_CAPTURE].opened) { + ASSERT(cfg_dac_rate == cfg_adc_rate, + "%s: Unmatched cfg rates: dac_rate=%u adc_rate=%u", __func__, + cfg_dac_rate, cfg_adc_rate); + } else if (codec_int_cfg.stream_cfg[AUD_STREAM_CAPTURE].opened) { + cfg_dac_rate = cfg_adc_rate; } - - codec_anc_samp_rate = dac_rate; - codec_anc_handler = hdlr; - - if (anc_ff_enabled || anc_fb_enabled) { - anc_running = true; + if (dac_rate != cfg_dac_rate) { + hdlr(AUD_STREAM_PLAYBACK, cfg_dac_rate, NULL, NULL); + TRACE(3, "%s: ANC sample rate changes from %u to %u", __func__, dac_rate, + cfg_dac_rate); + dac_rate = cfg_dac_rate; } + } - if (type == ANC_FEEDFORWARD) { - anc_ff_enabled = true; - } else if (type == ANC_FEEDBACK) { - anc_fb_enabled = true; - } + codec_anc_samp_rate = dac_rate; + codec_anc_handler = hdlr; - if (!anc_running) { - hal_chip_wake_lock(HAL_CHIP_WAKE_LOCK_USER_ANC); + if (anc_ff_enabled || anc_fb_enabled) { + anc_running = true; + } - hal_cmu_anc_enable(HAL_CMU_ANC_CLK_USER_ANC); + if (type == ANC_FEEDFORWARD) { + anc_ff_enabled = true; + } else if (type == ANC_FEEDBACK) { + anc_fb_enabled = true; + } - enum AUD_STREAM_T stream; - enum AUD_CHANNEL_NUM_T play_chan_num; + if (!anc_running) { + hal_chip_wake_lock(HAL_CHIP_WAKE_LOCK_USER_ANC); - codec_hw_open(CODEC_USER_ANC); - - if (CODEC_OUTPUT_DEV == (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1)) { - play_chan_num = AUD_CHANNEL_NUM_2; - } else { - play_chan_num = AUD_CHANNEL_NUM_1; - } - - for (stream = AUD_STREAM_PLAYBACK; stream <= AUD_STREAM_CAPTURE; stream++) { - if (codec_int_cfg.stream_cfg[stream].opened) { - if (stream == AUD_STREAM_PLAYBACK) { - /* ASSERT(codec_int_cfg.stream_cfg[stream].codec_cfg.channel_num == play_chan_num, - "Invalid existing ANC channel num %d != %d for stream %d", - codec_int_cfg.stream_cfg[stream].codec_cfg.channel_num, - play_chan_num, - stream);*/ - } - } else { - codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag = 0; - codec_int_cfg.stream_cfg[stream].codec_cfg.sample_rate = codec_anc_samp_rate; - codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag |= HAL_CODEC_CONFIG_SAMPLE_RATE; - if (stream == AUD_STREAM_PLAYBACK) { - codec_int_cfg.stream_cfg[stream].codec_cfg.vol = TGT_VOLUME_LEVEL_10; - } else { - codec_int_cfg.stream_cfg[stream].codec_cfg.vol = CODEC_SADC_VOL; - } - codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag |= HAL_CODEC_CONFIG_VOL; - if (stream == AUD_STREAM_PLAYBACK) { - codec_int_cfg.stream_cfg[stream].codec_cfg.channel_num = play_chan_num; - codec_int_cfg.stream_cfg[stream].codec_cfg.channel_map = CODEC_OUTPUT_DEV; - } else { - codec_int_cfg.stream_cfg[stream].codec_cfg.channel_num = 0; - codec_int_cfg.stream_cfg[stream].codec_cfg.channel_map = 0; - } - codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag |= HAL_CODEC_CONFIG_CHANNEL_NUM; - - hal_codec_setup_stream(CODEC_INT_INST, stream, &(codec_int_cfg.stream_cfg[stream].codec_cfg)); - } - } - - // Start play first, then start capture last - for (stream = AUD_STREAM_PLAYBACK; stream <= AUD_STREAM_CAPTURE; stream++) { - if (!codec_int_cfg.stream_cfg[stream].started) { - codec_hw_start(stream); - } - } - } - - hal_codec_anc_adc_enable(type); - - analog_aud_codec_anc_enable(type, true); - - if (!anc_running) { - // Enable pa if dac muted before - if (codec_int_cfg.mute_state[AUD_STREAM_PLAYBACK]) { - analog_aud_codec_nomute(); - } - -#ifdef CODEC_ANC_BOOST - analog_aud_codec_anc_boost(true, (ANALOG_ANC_BOOST_DELAY_FUNC)boost_delay); -#endif - } - - return 0; -} - -int codec_anc_close(enum ANC_TYPE_T type) -{ - CODEC_TRACE(2,"%s: type=%d", __func__, type); - - if (type == ANC_FEEDFORWARD) { - anc_ff_enabled = false; - } else if (type == ANC_FEEDBACK) { - anc_fb_enabled = false; - } - - hal_codec_anc_adc_disable(type); - - analog_aud_codec_anc_enable(type, false); - - if (anc_ff_enabled || anc_fb_enabled) { - return 0; - } - -#ifdef CODEC_ANC_BOOST - analog_aud_codec_anc_boost(false, (ANALOG_ANC_BOOST_DELAY_FUNC)boost_delay); -#endif + hal_cmu_anc_enable(HAL_CMU_ANC_CLK_USER_ANC); enum AUD_STREAM_T stream; + enum AUD_CHANNEL_NUM_T play_chan_num; - // Stop capture first, then stop play last - for (stream = AUD_STREAM_CAPTURE; stream >= AUD_STREAM_PLAYBACK && stream <= AUD_STREAM_CAPTURE; stream--) { - if (!codec_int_cfg.stream_cfg[stream].started) { - codec_hw_stop(stream); + codec_hw_open(CODEC_USER_ANC); + + if (CODEC_OUTPUT_DEV == (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1)) { + play_chan_num = AUD_CHANNEL_NUM_2; + } else { + play_chan_num = AUD_CHANNEL_NUM_1; + } + + for (stream = AUD_STREAM_PLAYBACK; stream <= AUD_STREAM_CAPTURE; stream++) { + if (codec_int_cfg.stream_cfg[stream].opened) { + if (stream == AUD_STREAM_PLAYBACK) { + /* ASSERT(codec_int_cfg.stream_cfg[stream].codec_cfg.channel_num == + play_chan_num, "Invalid existing ANC channel num %d != %d for + stream %d", codec_int_cfg.stream_cfg[stream].codec_cfg.channel_num, + play_chan_num, + stream);*/ } + } else { + codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag = 0; + codec_int_cfg.stream_cfg[stream].codec_cfg.sample_rate = + codec_anc_samp_rate; + codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag |= + HAL_CODEC_CONFIG_SAMPLE_RATE; + if (stream == AUD_STREAM_PLAYBACK) { + codec_int_cfg.stream_cfg[stream].codec_cfg.vol = TGT_VOLUME_LEVEL_10; + } else { + codec_int_cfg.stream_cfg[stream].codec_cfg.vol = CODEC_SADC_VOL; + } + codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag |= + HAL_CODEC_CONFIG_VOL; + if (stream == AUD_STREAM_PLAYBACK) { + codec_int_cfg.stream_cfg[stream].codec_cfg.channel_num = + play_chan_num; + codec_int_cfg.stream_cfg[stream].codec_cfg.channel_map = + CODEC_OUTPUT_DEV; + } else { + codec_int_cfg.stream_cfg[stream].codec_cfg.channel_num = 0; + codec_int_cfg.stream_cfg[stream].codec_cfg.channel_map = 0; + } + codec_int_cfg.stream_cfg[stream].codec_cfg.set_flag |= + HAL_CODEC_CONFIG_CHANNEL_NUM; + + hal_codec_setup_stream(CODEC_INT_INST, stream, + &(codec_int_cfg.stream_cfg[stream].codec_cfg)); + } } - codec_hw_close(CODEC_CLOSE_NORMAL, CODEC_USER_ANC); + // Start play first, then start capture last + for (stream = AUD_STREAM_PLAYBACK; stream <= AUD_STREAM_CAPTURE; stream++) { + if (!codec_int_cfg.stream_cfg[stream].started) { + codec_hw_start(stream); + } + } + } - hal_cmu_anc_disable(HAL_CMU_ANC_CLK_USER_ANC); + hal_codec_anc_adc_enable(type); - hal_chip_wake_unlock(HAL_CHIP_WAKE_LOCK_USER_ANC); + analog_aud_codec_anc_enable(type, true); - // Disable pa if dac muted before + if (!anc_running) { + // Enable pa if dac muted before if (codec_int_cfg.mute_state[AUD_STREAM_PLAYBACK]) { - analog_aud_codec_mute(); + analog_aud_codec_nomute(); } - codec_anc_handler = NULL; +#ifdef CODEC_ANC_BOOST + analog_aud_codec_anc_boost(true, (ANALOG_ANC_BOOST_DELAY_FUNC)boost_delay); +#endif + } + return 0; +} + +int codec_anc_close(enum ANC_TYPE_T type) { + CODEC_TRACE(2, "%s: type=%d", __func__, type); + + if (type == ANC_FEEDFORWARD) { + anc_ff_enabled = false; + } else if (type == ANC_FEEDBACK) { + anc_fb_enabled = false; + } + + hal_codec_anc_adc_disable(type); + + analog_aud_codec_anc_enable(type, false); + + if (anc_ff_enabled || anc_fb_enabled) { return 0; + } + +#ifdef CODEC_ANC_BOOST + analog_aud_codec_anc_boost(false, (ANALOG_ANC_BOOST_DELAY_FUNC)boost_delay); +#endif + + enum AUD_STREAM_T stream; + + // Stop capture first, then stop play last + for (stream = AUD_STREAM_CAPTURE; + stream >= AUD_STREAM_PLAYBACK && stream <= AUD_STREAM_CAPTURE; + stream--) { + if (!codec_int_cfg.stream_cfg[stream].started) { + codec_hw_stop(stream); + } + } + + codec_hw_close(CODEC_CLOSE_NORMAL, CODEC_USER_ANC); + + hal_cmu_anc_disable(HAL_CMU_ANC_CLK_USER_ANC); + + hal_chip_wake_unlock(HAL_CHIP_WAKE_LOCK_USER_ANC); + + // Disable pa if dac muted before + if (codec_int_cfg.mute_state[AUD_STREAM_PLAYBACK]) { + analog_aud_codec_mute(); + } + + codec_anc_handler = NULL; + + return 0; } #ifdef VOICE_DETECTOR_EN -int codec_vad_open(const struct AUD_VAD_CONFIG_T *cfg) -{ - if (cfg->type == AUD_VAD_TYPE_NONE) { - return codec_vad_close(); - } - - if (vad_type == cfg->type) { - return 0; - } - - vad_type = cfg->type; - - if (codec_int_cfg.user_map == 0) { - codec_hw_open(CODEC_USER_VAD); - } - - hal_codec_vad_open(cfg); - - codec_int_cfg.user_map |= (1 << CODEC_USER_VAD); +int codec_vad_open(const struct AUD_VAD_CONFIG_T *cfg) { + if (cfg->type == AUD_VAD_TYPE_NONE) { + return codec_vad_close(); + } + if (vad_type == cfg->type) { return 0; + } + + vad_type = cfg->type; + + if (codec_int_cfg.user_map == 0) { + codec_hw_open(CODEC_USER_VAD); + } + + hal_codec_vad_open(cfg); + + codec_int_cfg.user_map |= (1 << CODEC_USER_VAD); + + return 0; } -int codec_vad_close(void) -{ - if (vad_type == AUD_VAD_TYPE_NONE) { - return 0; - } - - vad_type = AUD_VAD_TYPE_NONE; - - codec_int_cfg.user_map &= ~(1 << CODEC_USER_VAD); - - if (codec_int_cfg.user_map == 0) { - codec_hw_close(CODEC_CLOSE_NORMAL, CODEC_USER_VAD); - } - +int codec_vad_close(void) { + if (vad_type == AUD_VAD_TYPE_NONE) { return 0; + } + + vad_type = AUD_VAD_TYPE_NONE; + + codec_int_cfg.user_map &= ~(1 << CODEC_USER_VAD); + + if (codec_int_cfg.user_map == 0) { + codec_hw_close(CODEC_CLOSE_NORMAL, CODEC_USER_VAD); + } + + return 0; } #endif - diff --git a/platform/drivers/codec/codec_tlv32aic32.c b/platform/drivers/codec/codec_tlv32aic32.c index 44e5969..5ebdab7 100644 --- a/platform/drivers/codec/codec_tlv32aic32.c +++ b/platform/drivers/codec/codec_tlv32aic32.c @@ -13,12 +13,12 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" #include "codec_tlv32aic32.h" #include "hal_i2c.h" #include "hal_i2s.h" -#include "hal_uart.h" #include "hal_trace.h" +#include "hal_uart.h" +#include "plat_types.h" #include "string.h" #define TLV32AIC32_INST HAL_I2S_ID_0 @@ -27,26 +27,17 @@ static struct HAL_I2C_CONFIG_T _codec_i2c_cfg; static uint8_t sample_rate_div[] = { 10, /* index is 0 */ - 15, - 20, - 25, - 30, - 35, - 40, - 45, - 50, - 55, - 60, + 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, }; /* i2c write */ -static int codec_write(uint8_t reg_addr, uint8_t value) -{ - uint8_t buf[2]; - buf[0] = reg_addr; - buf[1] = value; +static int codec_write(uint8_t reg_addr, uint8_t value) { + uint8_t buf[2]; + buf[0] = reg_addr; + buf[1] = value; - return hal_i2c_task_send(HAL_I2C_ID_0, TLV32AIC32_I2C_ADDRESS, buf, 1 + 1, 0, 0); + return hal_i2c_task_send(HAL_I2C_ID_0, TLV32AIC32_I2C_ADDRESS, buf, 1 + 1, 0, + 0); } /* i2c read */ @@ -64,176 +55,166 @@ static uint8_t codec_read(uint8_t reg_addr) } #endif -uint32_t tlv32aic32_open(void) -{ - _codec_i2c_cfg.mode = HAL_I2C_API_MODE_TASK; - _codec_i2c_cfg.use_dma = 0; - _codec_i2c_cfg.use_sync = 1; - _codec_i2c_cfg.speed = 20000; - _codec_i2c_cfg.as_master = 1; - hal_i2c_open(HAL_I2C_ID_0, &_codec_i2c_cfg); +uint32_t tlv32aic32_open(void) { + _codec_i2c_cfg.mode = HAL_I2C_API_MODE_TASK; + _codec_i2c_cfg.use_dma = 0; + _codec_i2c_cfg.use_sync = 1; + _codec_i2c_cfg.speed = 20000; + _codec_i2c_cfg.as_master = 1; + hal_i2c_open(HAL_I2C_ID_0, &_codec_i2c_cfg); - return 0; + return 0; } -uint32_t tlv32aic32_stream_open(enum AUD_STREAM_T stream) -{ - hal_i2s_open(TLV32AIC32_INST, stream, HAL_I2S_MODE_MASTER); +uint32_t tlv32aic32_stream_open(enum AUD_STREAM_T stream) { + hal_i2s_open(TLV32AIC32_INST, stream, HAL_I2S_MODE_MASTER); - return 0; + return 0; } -uint32_t tlv32aic32_stream_setup(enum AUD_STREAM_T stream, struct tlv32aic32_config_t *cfg) -{ - uint32_t param = 0, i = 0; +uint32_t tlv32aic32_stream_setup(enum AUD_STREAM_T stream, + struct tlv32aic32_config_t *cfg) { + uint32_t param = 0, i = 0; - /* select page : 0*/ - codec_write(AIC3X_PAGE_SELECT, PAGE0_SELECT); + /* select page : 0*/ + codec_write(AIC3X_PAGE_SELECT, PAGE0_SELECT); - /* soft reset : 1 */ - codec_write(AIC3X_RESET, SOFT_RESET); + /* soft reset : 1 */ + codec_write(AIC3X_RESET, SOFT_RESET); - /* CLKDIV_IN uses mCLK : 102 , PLLDIV_IN use mCLK */ - codec_write(AIC3X_CLKGEN_CTRL_REG, 0x02); + /* CLKDIV_IN uses mCLK : 102 , PLLDIV_IN use mCLK */ + codec_write(AIC3X_CLKGEN_CTRL_REG, 0x02); - /* CODEC_CLK_IN uses CLKDIV : 101, CODEC_CLK_IN use CLKDIV_IN */ - codec_write(101, 0x00); + /* CODEC_CLK_IN uses CLKDIV : 101, CODEC_CLK_IN use CLKDIV_IN */ + codec_write(101, 0x00); - /* PLL R value : 11, R is 1 */ - codec_write(AIC3X_OVRF_STATUS_AND_PLLR_REG, 0x1); + /* PLL R value : 11, R is 1 */ + codec_write(AIC3X_OVRF_STATUS_AND_PLLR_REG, 0x1); - /* PLL J value : 4, J is 8 */ - codec_write(AIC3X_PLL_PROGB_REG, 0x8); + /* PLL J value : 4, J is 8 */ + codec_write(AIC3X_PLL_PROGB_REG, 0x8); - /* PLL D value : 5,6, D is 1920 */ - codec_write(AIC3X_PLL_PROGC_REG, 0x780>>6); + /* PLL D value : 5,6, D is 1920 */ + codec_write(AIC3X_PLL_PROGC_REG, 0x780 >> 6); - codec_write(AIC3X_PLL_PROGD_REG, (0x780&0x3f)<<2); + codec_write(AIC3X_PLL_PROGD_REG, (0x780 & 0x3f) << 2); - /* PLL disable and select Q value : 3, enable pll, Q is 2 */ - codec_write(AIC3X_PLL_PROGA_REG, 0x81); + /* PLL disable and select Q value : 3, enable pll, Q is 2 */ + codec_write(AIC3X_PLL_PROGA_REG, 0x81); - /* left and right DAC open : 7, open codec dac path and fref */ - if ((cfg->sample_rate%8000) == 0) { - /* 48000 */ - codec_write(AIC3X_CODEC_DATAPATH_REG, 0x0a); - param = 480000/cfg->sample_rate; - } - else { - /* 44100 */ - codec_write(AIC3X_CODEC_DATAPATH_REG, 0x8a); - param = 441000/cfg->sample_rate; - } + /* left and right DAC open : 7, open codec dac path and fref */ + if ((cfg->sample_rate % 8000) == 0) { + /* 48000 */ + codec_write(AIC3X_CODEC_DATAPATH_REG, 0x0a); + param = 480000 / cfg->sample_rate; + } else { + /* 44100 */ + codec_write(AIC3X_CODEC_DATAPATH_REG, 0x8a); + param = 441000 / cfg->sample_rate; + } - for (i = 0; i < sizeof(sample_rate_div); ++i) { - if (param == sample_rate_div[i]) - break; - } + for (i = 0; i < sizeof(sample_rate_div); ++i) { + if (param == sample_rate_div[i]) + break; + } - if (i == sizeof(sample_rate_div)) { - i = 0; - } + if (i == sizeof(sample_rate_div)) { + i = 0; + } - /* sample_rate divider : 2, default is /1 */ - codec_write(AIC3X_SAMPLE_RATE_SEL_REG, i<<4|i<<4); + /* sample_rate divider : 2, default is /1 */ + codec_write(AIC3X_SAMPLE_RATE_SEL_REG, i << 4 | i << 4); - /* ctrl mode : 8, bitclock input, word clock input */ - codec_write(AIC3X_ASD_INTF_CTRLA, 0x20); + /* ctrl mode : 8, bitclock input, word clock input */ + codec_write(AIC3X_ASD_INTF_CTRLA, 0x20); - /* Audio Serial Data Interface Control : 9, 16bit i2s mode */ - if (cfg->bits == AUD_BITS_16) - param = 0; - else if (cfg->bits == AUD_BITS_20) - param = 1; - else if (cfg->bits == AUD_BITS_24) - param = 2; - else if (cfg->bits == AUD_BITS_32) - param = 3; - else - param = 0; + /* Audio Serial Data Interface Control : 9, 16bit i2s mode */ + if (cfg->bits == AUD_BITS_16) + param = 0; + else if (cfg->bits == AUD_BITS_20) + param = 1; + else if (cfg->bits == AUD_BITS_24) + param = 2; + else if (cfg->bits == AUD_BITS_32) + param = 3; + else + param = 0; + codec_write(AIC3X_ASD_INTF_CTRLB, 0x00 | param << 4); - codec_write(AIC3X_ASD_INTF_CTRLB, 0x00 | param<<4); + /* out ac-coupled : 14, headset control */ + codec_write(AIC3X_HEADSET_DETECT_CTRL_B, 0x08); - /* out ac-coupled : 14, headset control */ - codec_write(AIC3X_HEADSET_DETECT_CTRL_B, 0x08); + /* left and right DAC power on : 37 */ + // codec_write(DAC_PWR, 0xC0); + codec_write(DAC_PWR, 0xD0); - /* left and right DAC power on : 37 */ - //codec_write(DAC_PWR, 0xC0); - codec_write(DAC_PWR, 0xD0); + /* out common-mode voltage : 40 */ + codec_write(HPOUT_SC, 0x00); - /* out common-mode voltage : 40 */ - codec_write(HPOUT_SC, 0x00); + /* out path select : 41 */ + codec_write(DAC_LINE_MUX, 0xA1); - /* out path select : 41 */ - codec_write(DAC_LINE_MUX, 0xA1); + /* left DAC not muted : 43 */ + codec_write(LDAC_VOL, 0x0f); - /* left DAC not muted : 43 */ - codec_write(LDAC_VOL, 0x0f); + /* right DAC not muted : 44 */ + codec_write(RDAC_VOL, 0x0f); - /* right DAC not muted : 44 */ - codec_write(RDAC_VOL, 0x0f); + /* HPLOUT is not muted : 51 */ + codec_write(HPLOUT_CTRL, 0x9F); - /* HPLOUT is not muted : 51 */ - codec_write(HPLOUT_CTRL, 0x9F); + /* HPROUT is not muted : 65 */ + codec_write(HPROUT_CTRL, 0x9F); - /* HPROUT is not muted : 65 */ - codec_write(HPROUT_CTRL, 0x9F); + /* out short circuit protection : 38 */ + // codec_write(HPRCOM_CFG, 0x3A); + codec_write(HPRCOM_CFG, 0x22); - /* out short circuit protection : 38 */ - //codec_write(HPRCOM_CFG, 0x3A); - codec_write(HPRCOM_CFG, 0x22); + /* input */ + /* mic bias : 25 */ + codec_write(MICBIAS_CTRL, 0x40); + /* left adc power : 19 */ + codec_write(LINE1L_2_LADC_CTRL, 0x04); + /* right adc power : 22 */ + codec_write(LINE1R_2_RADC_CTRL, 0x04); + /* left adc pga mute : 15 */ + codec_write(LADC_VOL, 0x0); + /* right adc pga mute : 16 */ + codec_write(RADC_VOL, 0x0); + /* adc flag : 36 */ + // TRACE(1,"tlv adc flag 0x%x", codec_read(ADC_FLAG)); + /* left adc pga mute : 15 */ + // TRACE(1,"tlv left adc pga 0x%x", codec_read(LADC_VOL)); + /* right adc pga mute : 16 */ + // TRACE(1,"tlv right adc pga 0x%x", codec_read(RADC_VOL)); + /* input end */ - /* input */ - /* mic bias : 25 */ - codec_write(MICBIAS_CTRL, 0x40); - /* left adc power : 19 */ - codec_write(LINE1L_2_LADC_CTRL, 0x04); - /* right adc power : 22 */ - codec_write(LINE1R_2_RADC_CTRL, 0x04); - /* left adc pga mute : 15 */ - codec_write(LADC_VOL, 0x0); - /* right adc pga mute : 16 */ - codec_write(RADC_VOL, 0x0); - /* adc flag : 36 */ - //TRACE(1,"tlv adc flag 0x%x", codec_read(ADC_FLAG)); - /* left adc pga mute : 15 */ - //TRACE(1,"tlv left adc pga 0x%x", codec_read(LADC_VOL)); - /* right adc pga mute : 16 */ - //TRACE(1,"tlv right adc pga 0x%x", codec_read(RADC_VOL)); - /* input end */ + struct HAL_I2S_CONFIG_T i2s_cfg; - struct HAL_I2S_CONFIG_T i2s_cfg; + memset(&i2s_cfg, 0, sizeof(i2s_cfg)); + i2s_cfg.use_dma = cfg->use_dma; + i2s_cfg.chan_sep_buf = cfg->chan_sep_buf; + i2s_cfg.sync_start = cfg->sync_start; + i2s_cfg.cycles = cfg->slot_cycles; + i2s_cfg.bits = cfg->bits; + i2s_cfg.channel_num = cfg->channel_num; + i2s_cfg.channel_map = cfg->channel_map; + i2s_cfg.sample_rate = cfg->sample_rate; + hal_i2s_setup_stream(TLV32AIC32_INST, stream, &i2s_cfg); - memset(&i2s_cfg, 0, sizeof(i2s_cfg)); - i2s_cfg.use_dma = cfg->use_dma; - i2s_cfg.chan_sep_buf = cfg->chan_sep_buf; - i2s_cfg.sync_start = cfg->sync_start; - i2s_cfg.cycles = cfg->slot_cycles; - i2s_cfg.bits = cfg->bits; - i2s_cfg.channel_num = cfg->channel_num; - i2s_cfg.channel_map = cfg->channel_map; - i2s_cfg.sample_rate = cfg->sample_rate; - hal_i2s_setup_stream(TLV32AIC32_INST, stream, &i2s_cfg); - - return 0; + return 0; } -uint32_t tlv32aic32_stream_start(enum AUD_STREAM_T stream) -{ - hal_i2s_start_stream(TLV32AIC32_INST, stream); - return 0; +uint32_t tlv32aic32_stream_start(enum AUD_STREAM_T stream) { + hal_i2s_start_stream(TLV32AIC32_INST, stream); + return 0; } -uint32_t tlv32aic32_stream_stop(enum AUD_STREAM_T stream) -{ - hal_i2s_stop_stream(TLV32AIC32_INST, stream); - return 0; +uint32_t tlv32aic32_stream_stop(enum AUD_STREAM_T stream) { + hal_i2s_stop_stream(TLV32AIC32_INST, stream); + return 0; } -uint32_t tlv32aic32_stream_close(enum AUD_STREAM_T stream) -{ - hal_i2s_close(TLV32AIC32_INST, stream); - return 0; -} -uint32_t tlv32aic32_close(void) -{ - return 0; +uint32_t tlv32aic32_stream_close(enum AUD_STREAM_T stream) { + hal_i2s_close(TLV32AIC32_INST, stream); + return 0; } +uint32_t tlv32aic32_close(void) { return 0; } diff --git a/platform/drivers/norflash/norflash_drv.c b/platform/drivers/norflash/norflash_drv.c index de30d0e..ebd53b5 100644 --- a/platform/drivers/norflash/norflash_drv.c +++ b/platform/drivers/norflash/norflash_drv.c @@ -13,49 +13,51 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" -#include "cmsis.h" #include "norflash_drv.h" #include "cmsis.h" #include "hal_cache.h" -#include "hal_norflaship.h" #include "hal_norflash.h" +#include "hal_norflaship.h" #include "hal_sleep.h" -#include "hal_trace.h" #include "hal_timer.h" +#include "hal_trace.h" #include "norflash_gd25q32c.h" #include "plat_addr_map.h" +#include "plat_types.h" #include "tool_msg.h" #ifdef PROGRAMMER #include "task_schedule.h" #else -#define TASK_SCHEDULE true +#define TASK_SCHEDULE true #endif -#if (CHIP_FLASH_CTRL_VER >= 2) && !defined(ROM_BUILD) && !defined(PROGRAMMER) && !(defined(CHIP_BEST2001) && (defined(PSRAMUHS_ENABLE) || defined(PSRAM_ENABLE))) +#if (CHIP_FLASH_CTRL_VER >= 2) && !defined(ROM_BUILD) && \ + !defined(PROGRAMMER) && \ + !(defined(CHIP_BEST2001) && \ + (defined(PSRAMUHS_ENABLE) || defined(PSRAM_ENABLE))) #define FLASH_BURST_WRAP #endif #define SAMP_DELAY_PRIO_FALLING_EDGE -#define NORFLASH_UNIQUE_ID_LEN 18 +#define NORFLASH_UNIQUE_ID_LEN 18 -#define NORFLASH_MAX_DIV 0xFF +#define NORFLASH_MAX_DIV 0xFF -#define NORFLASH_DEFAULT_MAX_SPEED (104 * 1000 * 1000) +#define NORFLASH_DEFAULT_MAX_SPEED (104 * 1000 * 1000) -#define NORFLASH_DIV1_MAX_SPEED (99 * 1000 * 1000) +#define NORFLASH_DIV1_MAX_SPEED (99 * 1000 * 1000) -#define NORFLASH_SPEED_RATIO_DENOMINATOR 8 +#define NORFLASH_SPEED_RATIO_DENOMINATOR 8 -#define NORFLASH_PUYA_ID_PREFIX 0x85 +#define NORFLASH_PUYA_ID_PREFIX 0x85 -#define NORFLASH_XTS_ID_PREFIX 0x0B +#define NORFLASH_XTS_ID_PREFIX 0x0B -#define XTS_UNIQUE_ID_LEN 16 -#define XTS_UNIQUE_ID_CMD 0x5A -#define XTS_UNIQUE_ID_PARAM 0x00019400 +#define XTS_UNIQUE_ID_LEN 16 +#define XTS_UNIQUE_ID_CMD 0x5A +#define XTS_UNIQUE_ID_PARAM 0x00019400 // GigaDevice extern const struct NORFLASH_CFG_T gd25lq64c_cfg; @@ -86,10 +88,10 @@ extern const struct NORFLASH_CFG_T en25s80b_cfg; extern const struct NORFLASH_CFG_T xm25qh16c_cfg; extern const struct NORFLASH_CFG_T xm25qh80b_cfg; -static const struct NORFLASH_CFG_T * const flash_list[] = { - // ---------------------- - // GigaDevice - // ---------------------- +static const struct NORFLASH_CFG_T *const flash_list[] = { +// ---------------------- +// GigaDevice +// ---------------------- #if defined(__NORFLASH_ALL__) || defined(__NORFLASH_GD25LQ64C__) &gd25lq64c_cfg, #endif @@ -115,9 +117,9 @@ static const struct NORFLASH_CFG_T * const flash_list[] = { &gd25d20c_cfg, #endif - // ---------------------- - // Puya - // ---------------------- +// ---------------------- +// Puya +// ---------------------- #if defined(__NORFLASH_ALL__) || defined(__NORFLASH_P25Q128L__) &p25q128l_cfg, #endif @@ -140,9 +142,9 @@ static const struct NORFLASH_CFG_T * const flash_list[] = { &p25q40h_cfg, #endif - // ---------------------- - // Xinxin - // ---------------------- +// ---------------------- +// Xinxin +// ---------------------- #if defined(__NORFLASH_XM25QH16C__) &xm25qh16c_cfg, #endif @@ -150,16 +152,16 @@ static const struct NORFLASH_CFG_T * const flash_list[] = { &xm25qh80b_cfg, #endif - // ---------------------- - // XTS - // ---------------------- +// ---------------------- +// XTS +// ---------------------- #if defined(__NORFLASH_XT25Q08B__) &xt25q08b_cfg, #endif - // ---------------------- - // EON - // ---------------------- +// ---------------------- +// EON +// ---------------------- #if defined(__NORFLASH_EN25S80B__) &en25s80b_cfg, #endif @@ -187,38 +189,58 @@ static const struct NORFLASH_CFG_T * const flash_list[] = { // Falling edge sample time: one spi_clk cycle (should > flash output time) #ifdef CHIP_BEST2300 -#define FALLING_EDGE_SAMPLE_ADJ_FREQ (110 * 1000 * 1000) // about 9 ns +#define FALLING_EDGE_SAMPLE_ADJ_FREQ (110 * 1000 * 1000) // about 9 ns #else -#define FALLING_EDGE_SAMPLE_ADJ_FREQ (77 * 1000 * 1000) // about 13 ns +#define FALLING_EDGE_SAMPLE_ADJ_FREQ (77 * 1000 * 1000) // about 13 ns #endif #if (CHIP_FLASH_CTRL_VER <= 1) -#define SAM_EDGE_FALLING (1 << 4) -#define SAM_NEG_PHASE (1 << 5) -#define SAMDLY_MASK (0xF << 0) +#define SAM_EDGE_FALLING (1 << 4) +#define SAM_NEG_PHASE (1 << 5) +#define SAMDLY_MASK (0xF << 0) #ifdef SAMP_DELAY_PRIO_FALLING_EDGE -#define DIV2_SAMP_DELAY_FALLING_EDGE_IDX 1 -#define DIVN_SAMP_DELAY_FALLING_EDGE_IDX 2 +#define DIV2_SAMP_DELAY_FALLING_EDGE_IDX 1 +#define DIVN_SAMP_DELAY_FALLING_EDGE_IDX 2 // Sample delays: 1, 1.5, 2, 3 -static const uint8_t samdly_list_divn[] = { 1, SAM_NEG_PHASE | SAM_EDGE_FALLING | 2, 2, 3, }; +static const uint8_t samdly_list_divn[] = { + 1, + SAM_NEG_PHASE | SAM_EDGE_FALLING | 2, + 2, + 3, +}; #else // Sample delays: 0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 7 -static const uint8_t samdly_list_divn[] = { /*0,*/ SAM_EDGE_FALLING | 1, 1, SAM_NEG_PHASE | SAM_EDGE_FALLING | 2, 2, 3, 4, /*5, 6, 7,*/ }; +static const uint8_t samdly_list_divn[] = {/*0,*/ SAM_EDGE_FALLING | 1, + 1, + SAM_NEG_PHASE | SAM_EDGE_FALLING | 2, + 2, + 3, + 4, + /*5, 6, 7,*/}; #endif #else #ifdef SAMP_DELAY_PRIO_FALLING_EDGE #ifdef CHIP_BEST1402 -#define DIV1_SAMP_DELAY_FALLING_EDGE_IDX 2 +#define DIV1_SAMP_DELAY_FALLING_EDGE_IDX 2 #else -#define DIV1_SAMP_DELAY_FALLING_EDGE_IDX 1 +#define DIV1_SAMP_DELAY_FALLING_EDGE_IDX 1 #endif -static const uint8_t samdly_list_div1[] = { 0, 1, 2, 3, }; -#define DIV2_SAMP_DELAY_FALLING_EDGE_IDX 1 -#define DIVN_SAMP_DELAY_FALLING_EDGE_IDX 3 -static const uint8_t samdly_list_divn[] = { 2, 3, 4, 5, 6, 7, 8, 9, }; +static const uint8_t samdly_list_div1[] = { + 0, + 1, + 2, + 3, +}; +#define DIV2_SAMP_DELAY_FALLING_EDGE_IDX 1 +#define DIVN_SAMP_DELAY_FALLING_EDGE_IDX 3 +static const uint8_t samdly_list_divn[] = { + 2, 3, 4, 5, 6, 7, 8, 9, +}; #else -static const uint8_t samdly_list_divn[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, }; +static const uint8_t samdly_list_divn[] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, +}; #endif #endif @@ -243,1378 +265,1334 @@ static uint8_t calib_matched_cnt[DRV_NORFLASH_CALIB_QTY]; static uint8_t calib_final_idx[DRV_NORFLASH_CALIB_QTY]; #endif -static void norflash_delay(uint32_t us) -{ +static void norflash_delay(uint32_t us) { #ifdef CHIP_BEST1000 - hal_sys_timer_delay(US_TO_TICKS(us)); + hal_sys_timer_delay(US_TO_TICKS(us)); #else - hal_sys_timer_delay_us(us); + hal_sys_timer_delay_us(us); #endif } #ifdef FLASH_HPM -static int norflash_set_hpm(uint8_t on) -{ - if (on) { - norflaship_cmd_addr(GD25Q32C_CMD_HIGH_PERFORMANCE, 0); - } else { - norflaship_cmd_addr(GD25Q32C_CMD_RELEASE_FROM_DP, 0); - } - norflaship_busy_wait(); +static int norflash_set_hpm(uint8_t on) { + if (on) { + norflaship_cmd_addr(GD25Q32C_CMD_HIGH_PERFORMANCE, 0); + } else { + norflaship_cmd_addr(GD25Q32C_CMD_RELEASE_FROM_DP, 0); + } + norflaship_busy_wait(); - return 0; + return 0; } #endif #ifdef FLASH_SUSPEND -static int norflash_suspend(void) -{ - norflaship_clear_fifos(); - norflaship_ext_tx_cmd(GD25Q32C_CMD_PROGRAM_ERASE_SUSPEND, 0); - // Suspend time: 20~30 us - norflash_delay(40); - return 0; +static int norflash_suspend(void) { + norflaship_clear_fifos(); + norflaship_ext_tx_cmd(GD25Q32C_CMD_PROGRAM_ERASE_SUSPEND, 0); + // Suspend time: 20~30 us + norflash_delay(40); + return 0; } -static int norflash_resume(void) -{ - norflaship_clear_fifos(); - norflaship_ext_tx_cmd(GD25Q32C_CMD_PROGRAM_ERASE_RESUME, 0); - if (flash_list[flash_idx]->id[0] == NORFLASH_PUYA_ID_PREFIX) { - // PUYA flash requires the mean interval of resume to suspend >= 250us - norflash_delay(250); - } else { - // At least resume the work for 100 us to avoid always staying in suspended state - norflash_delay(100); - } - return 0; +static int norflash_resume(void) { + norflaship_clear_fifos(); + norflaship_ext_tx_cmd(GD25Q32C_CMD_PROGRAM_ERASE_RESUME, 0); + if (flash_list[flash_idx]->id[0] == NORFLASH_PUYA_ID_PREFIX) { + // PUYA flash requires the mean interval of resume to suspend >= 250us + norflash_delay(250); + } else { + // At least resume the work for 100 us to avoid always staying in suspended + // state + norflash_delay(100); + } + return 0; } #endif -uint8_t norflash_read_status_s0_s7(void) -{ - uint8_t val; - norflash_read_reg(GD25Q32C_CMD_READ_STATUS_S0_S7, &val, 1); - return val; +uint8_t norflash_read_status_s0_s7(void) { + uint8_t val; + norflash_read_reg(GD25Q32C_CMD_READ_STATUS_S0_S7, &val, 1); + return val; } -uint8_t norflash_read_status_s8_s15(void) -{ - uint8_t val; - norflash_read_reg(GD25Q32C_CMD_READ_STATUS_S8_S15, &val, 1); - return val; +uint8_t norflash_read_status_s8_s15(void) { + uint8_t val; + norflash_read_reg(GD25Q32C_CMD_READ_STATUS_S8_S15, &val, 1); + return val; } -static int norflash_status_WEL(void) -{ - uint32_t status; - status = norflash_read_status_s0_s7(); - return !!(status & GD25Q32C_WEL_BIT_MASK); +static int norflash_status_WEL(void) { + uint32_t status; + status = norflash_read_status_s0_s7(); + return !!(status & GD25Q32C_WEL_BIT_MASK); } -static int norflash_status_WIP(void) -{ - uint32_t status; - status = norflash_read_status_s0_s7(); - return !!(status & GD25Q32C_WIP_BIT_MASK); +static int norflash_status_WIP(void) { + uint32_t status; + status = norflash_read_status_s0_s7(); + return !!(status & GD25Q32C_WIP_BIT_MASK); } -void norflash_status_WEL_0_wait(void) -{ - while (norflash_status_WEL() == 0 && TASK_SCHEDULE); +void norflash_status_WEL_0_wait(void) { + while (norflash_status_WEL() == 0 && TASK_SCHEDULE) + ; } #ifdef FLASH_SUSPEND -int norflash_suspend_check_irq(uint32_t irq_num) -{ - uint32_t idx; - uint32_t offset; +int norflash_suspend_check_irq(uint32_t irq_num) { + uint32_t idx; + uint32_t offset; - idx = irq_num / 32; - offset = irq_num % 32; + idx = irq_num / 32; + offset = irq_num % 32; - if (idx >= ARRAY_SIZE(check_irq)) { - return 1; - } + if (idx >= ARRAY_SIZE(check_irq)) { + return 1; + } - check_irq[idx] |= (1 << offset); - specific_irq_check = true; + check_irq[idx] |= (1 << offset); + specific_irq_check = true; - return 0; + return 0; } -static int norflash_system_active(void) -{ - if (specific_irq_check) { - return hal_sleep_specific_irq_pending(check_irq, ARRAY_SIZE(check_irq)); - } else { - return hal_sleep_irq_pending(); - } +static int norflash_system_active(void) { + if (specific_irq_check) { + return hal_sleep_specific_irq_pending(check_irq, ARRAY_SIZE(check_irq)); + } else { + return hal_sleep_irq_pending(); + } } #endif -enum HAL_NORFLASH_RET_T norflash_status_WIP_1_wait(int suspend) -{ - while (norflash_status_WIP() && TASK_SCHEDULE) { +enum HAL_NORFLASH_RET_T norflash_status_WIP_1_wait(int suspend) { + while (norflash_status_WIP() && TASK_SCHEDULE) { #ifdef FLASH_SUSPEND - if (suspend && norflash_system_active()) { - norflash_suspend(); - return HAL_NORFLASH_SUSPENDED; - } -#endif + if (suspend && norflash_system_active()) { + norflash_suspend(); + return HAL_NORFLASH_SUSPENDED; } +#endif + } - return HAL_NORFLASH_OK; + return HAL_NORFLASH_OK; } #ifdef FLASH_BURST_WRAP -static int norflash_set_burst_wrap(uint32_t len) -{ - uint8_t val; +static int norflash_set_burst_wrap(uint32_t len) { + uint8_t val; - if (len == 64) { - val = (1 << 6) | (1 << 5); - } else if (len == 32) { - val = (1 << 6); - } else if (len == 16) { - val = (1 << 5); - } else if (len == 8) { - val = 0; - } else if (len == 0) { - // Disable wrap around - val = (1 << 4); - } else { - return 1; - } + if (len == 64) { + val = (1 << 6) | (1 << 5); + } else if (len == 32) { + val = (1 << 6); + } else if (len == 16) { + val = (1 << 5); + } else if (len == 8) { + val = 0; + } else if (len == 0) { + // Disable wrap around + val = (1 << 4); + } else { + return 1; + } - norflaship_clear_txfifo(); - norflaship_write_txfifo(&val, 1); - norflaship_cmd_addr(GD25Q32C_CMD_SET_BURST_WRAP, 0); - norflash_status_WIP_1_wait(0); + norflaship_clear_txfifo(); + norflaship_write_txfifo(&val, 1); + norflaship_cmd_addr(GD25Q32C_CMD_SET_BURST_WRAP, 0); + norflash_status_WIP_1_wait(0); - return 0; + return 0; } #endif -static int norflash_set_continuous_read(uint8_t on) -{ - uint8_t cmd; +static int norflash_set_continuous_read(uint8_t on) { + uint8_t cmd; - if (on) { - norflaship_continuous_read_on(); + if (on) { + norflaship_continuous_read_on(); - norflaship_continuous_read_mode_bit(flash_list[flash_idx]->crm_en_bits); + norflaship_continuous_read_mode_bit(flash_list[flash_idx]->crm_en_bits); - // Continuous Read Mode takes effect after the first read - } else { - norflaship_continuous_read_off(); - - norflaship_continuous_read_mode_bit(flash_list[flash_idx]->crm_dis_bits); - - if (norflash_op_mode & HAL_NORFLASH_OP_MODE_QUAD_IO) { - cmd = GD25Q32C_CMD_FAST_QUAD_IO_READ; - } else { - norflaship_quad_mode(0); - - if (norflash_op_mode & HAL_NORFLASH_OP_MODE_DUAL_IO) { - cmd = GD25Q32C_CMD_FAST_DUAL_IO_READ; - } else { - norflaship_dual_mode(0); - - // Command 0x03 and address 0xFFFFFE will make M4=1 (mode bit 4) - // at both qual and dual continuous read modes, which will disable it. - cmd = GD25Q32C_CMD_STANDARD_READ; - } - } - - norflaship_clear_rxfifo(); - norflaship_busy_wait(); - norflaship_blksize(2); - if (cmd == GD25Q32C_CMD_STANDARD_READ) { - if (div_std_read) { - norflaship_div(div_std_read); - } - } - norflaship_cmd_addr(cmd, 0xFFFFFE); - // Now Continuous Read Mode has been disabled - if (cmd == GD25Q32C_CMD_STANDARD_READ) { - if (div_others) { - norflaship_div(div_others); - } - } - norflaship_clear_rxfifo(); - } - - norflaship_busy_wait(); - - return 0; -} - -static int norflash_set_quad(uint8_t on) -{ - if (flash_list[flash_idx]->write_status == NULL) { - return -1; - } - - if (on) { - flash_list[flash_idx]->write_status(DRV_NORFLASH_W_STATUS_QE, 1); - } else { - flash_list[flash_idx]->write_status(DRV_NORFLASH_W_STATUS_QE, 0); - } - return 0; -} - -static int norflash_set_quad_io_mode(uint8_t on) -{ - norflash_set_quad(on); - if (on) { - norflaship_quad_mode(1); - } else { - norflaship_quad_mode(0); - } - norflaship_busy_wait(); - return 0; -} - -static int norflash_set_quad_output_mode(uint8_t on) -{ - norflash_set_quad(on); - if (on) { - norflaship_rdcmd(GD25Q32C_CMD_FAST_QUAD_OUTPUT_READ); - } else { - norflaship_rdcmd(GD25Q32C_CMD_STANDARD_READ); - } - norflaship_busy_wait(); - return 0; -} - -static uint8_t norflash_set_dual_io_mode(uint8_t on) -{ - if (on) { - norflaship_dual_mode(1); - } else { - norflaship_dual_mode(0); - } - norflaship_busy_wait(); - - return 0; -} - -static uint8_t norflash_set_dual_output_mode(uint8_t on) -{ - if (on) { - norflaship_rdcmd(GD25Q32C_CMD_FAST_DUAL_OUTPUT_READ); - } else { - norflaship_rdcmd(GD25Q32C_CMD_STANDARD_READ); - } - norflaship_busy_wait(); - return 0; -} - -static uint8_t norflash_set_fast_mode(uint8_t on) -{ - if (on) { - norflaship_rdcmd(GD25Q32C_CMD_STANDARD_FAST_READ); - } else { - norflaship_rdcmd(GD25Q32C_CMD_STANDARD_READ); - } - norflaship_busy_wait(); - return 0; -} - -static uint8_t norflash_set_stand_mode(void) -{ - norflaship_rdcmd(GD25Q32C_CMD_STANDARD_READ); - norflaship_busy_wait(); - return 0; -} - -uint32_t norflash_get_supported_mode(void) -{ - return flash_list[flash_idx]->mode; -} - -uint32_t norflash_get_current_mode(void) -{ - return norflash_op_mode; -} - -union DRV_NORFLASH_SEC_REG_CFG_T norflash_get_security_register_config(void) -{ - return flash_list[flash_idx]->sec_reg_cfg; -} - -uint32_t norflash_get_block_protect_mask(void) -{ - return flash_list[flash_idx]->block_protect_mask; -} - -void norflash_reset(void) -{ - norflaship_clear_fifos(); - - // Disable continuous read mode + // Continuous Read Mode takes effect after the first read + } else { norflaship_continuous_read_off(); + + norflaship_continuous_read_mode_bit(flash_list[flash_idx]->crm_dis_bits); + + if (norflash_op_mode & HAL_NORFLASH_OP_MODE_QUAD_IO) { + cmd = GD25Q32C_CMD_FAST_QUAD_IO_READ; + } else { + norflaship_quad_mode(0); + + if (norflash_op_mode & HAL_NORFLASH_OP_MODE_DUAL_IO) { + cmd = GD25Q32C_CMD_FAST_DUAL_IO_READ; + } else { + norflaship_dual_mode(0); + + // Command 0x03 and address 0xFFFFFE will make M4=1 (mode bit 4) + // at both qual and dual continuous read modes, which will disable it. + cmd = GD25Q32C_CMD_STANDARD_READ; + } + } + + norflaship_clear_rxfifo(); norflaship_busy_wait(); norflaship_blksize(2); - // Command 0x03 and address 0xFFFFFE will make M4=1 (mode bit 4) - // at both qual and dual continuous read modes, which will disable it. - norflaship_cmd_addr(GD25Q32C_CMD_STANDARD_READ, 0xFFFFFE); - - // Release from deep power-down - norflaship_cmd_addr(GD25Q32C_CMD_RELEASE_FROM_DP, 0); - // Wait 20us for flash to finish - norflash_delay(40); - - // Software reset - norflaship_ext_tx_cmd(GD25Q32C_CMD_ENABLE_RESET, 0); - norflaship_ext_tx_cmd(GD25Q32C_CMD_RESET, 0); - // Reset recovery time: 20~30 us - norflash_delay(50); - - norflaship_cmd_done(); - - // Reset cfg - flash_idx = 0; - div_read = 0; - div_std_read = 0; - div_others = 0; - norflash_op_mode = 0; - falling_edge_adj = false; -} - -int norflash_get_size(uint32_t *total_size, uint32_t *block_size, uint32_t *sector_size, uint32_t *page_size) -{ - if (total_size) { - *total_size = flash_list[flash_idx]->total_size; + if (cmd == GD25Q32C_CMD_STANDARD_READ) { + if (div_std_read) { + norflaship_div(div_std_read); + } } - if (block_size) { - *block_size = flash_list[flash_idx]->block_size; - } - if (sector_size) { - *sector_size = flash_list[flash_idx]->sector_size; - } - if (page_size) { - *page_size = flash_list[flash_idx]->page_size; - } - - return 0; -} - -static void norflash_set_cfg_div(void) -{ - if (div_others) { + norflaship_cmd_addr(cmd, 0xFFFFFE); + // Now Continuous Read Mode has been disabled + if (cmd == GD25Q32C_CMD_STANDARD_READ) { + if (div_others) { norflaship_div(div_others); + } } + norflaship_clear_rxfifo(); + } + + norflaship_busy_wait(); + + return 0; } -static void norflash_set_read_div(void) -{ - if (norflash_op_mode & HAL_NORFLASH_OP_MODE_STAND_SPI) { - if (div_std_read) { - norflaship_div(div_std_read); - } - } else { - if (div_read) { - norflaship_div(div_read); - } - } +static int norflash_set_quad(uint8_t on) { + if (flash_list[flash_idx]->write_status == NULL) { + return -1; + } + + if (on) { + flash_list[flash_idx]->write_status(DRV_NORFLASH_W_STATUS_QE, 1); + } else { + flash_list[flash_idx]->write_status(DRV_NORFLASH_W_STATUS_QE, 0); + } + return 0; } -int norflash_set_mode(uint32_t op) -{ - uint32_t read_mode = 0; - uint32_t ext_mode = 0; - uint32_t program_mode = 0; - uint32_t self_mode; - uint32_t mode; +static int norflash_set_quad_io_mode(uint8_t on) { + norflash_set_quad(on); + if (on) { + norflaship_quad_mode(1); + } else { + norflaship_quad_mode(0); + } + norflaship_busy_wait(); + return 0; +} - self_mode = norflash_get_supported_mode(); - mode = (self_mode & op); +static int norflash_set_quad_output_mode(uint8_t on) { + norflash_set_quad(on); + if (on) { + norflaship_rdcmd(GD25Q32C_CMD_FAST_QUAD_OUTPUT_READ); + } else { + norflaship_rdcmd(GD25Q32C_CMD_STANDARD_READ); + } + norflaship_busy_wait(); + return 0; +} + +static uint8_t norflash_set_dual_io_mode(uint8_t on) { + if (on) { + norflaship_dual_mode(1); + } else { + norflaship_dual_mode(0); + } + norflaship_busy_wait(); + + return 0; +} + +static uint8_t norflash_set_dual_output_mode(uint8_t on) { + if (on) { + norflaship_rdcmd(GD25Q32C_CMD_FAST_DUAL_OUTPUT_READ); + } else { + norflaship_rdcmd(GD25Q32C_CMD_STANDARD_READ); + } + norflaship_busy_wait(); + return 0; +} + +static uint8_t norflash_set_fast_mode(uint8_t on) { + if (on) { + norflaship_rdcmd(GD25Q32C_CMD_STANDARD_FAST_READ); + } else { + norflaship_rdcmd(GD25Q32C_CMD_STANDARD_READ); + } + norflaship_busy_wait(); + return 0; +} + +static uint8_t norflash_set_stand_mode(void) { + norflaship_rdcmd(GD25Q32C_CMD_STANDARD_READ); + norflaship_busy_wait(); + return 0; +} + +uint32_t norflash_get_supported_mode(void) { + return flash_list[flash_idx]->mode; +} + +uint32_t norflash_get_current_mode(void) { return norflash_op_mode; } + +union DRV_NORFLASH_SEC_REG_CFG_T norflash_get_security_register_config(void) { + return flash_list[flash_idx]->sec_reg_cfg; +} + +uint32_t norflash_get_block_protect_mask(void) { + return flash_list[flash_idx]->block_protect_mask; +} + +void norflash_reset(void) { + norflaship_clear_fifos(); + + // Disable continuous read mode + norflaship_continuous_read_off(); + norflaship_busy_wait(); + norflaship_blksize(2); + // Command 0x03 and address 0xFFFFFE will make M4=1 (mode bit 4) + // at both qual and dual continuous read modes, which will disable it. + norflaship_cmd_addr(GD25Q32C_CMD_STANDARD_READ, 0xFFFFFE); + + // Release from deep power-down + norflaship_cmd_addr(GD25Q32C_CMD_RELEASE_FROM_DP, 0); + // Wait 20us for flash to finish + norflash_delay(40); + + // Software reset + norflaship_ext_tx_cmd(GD25Q32C_CMD_ENABLE_RESET, 0); + norflaship_ext_tx_cmd(GD25Q32C_CMD_RESET, 0); + // Reset recovery time: 20~30 us + norflash_delay(50); + + norflaship_cmd_done(); + + // Reset cfg + flash_idx = 0; + div_read = 0; + div_std_read = 0; + div_others = 0; + norflash_op_mode = 0; + falling_edge_adj = false; +} + +int norflash_get_size(uint32_t *total_size, uint32_t *block_size, + uint32_t *sector_size, uint32_t *page_size) { + if (total_size) { + *total_size = flash_list[flash_idx]->total_size; + } + if (block_size) { + *block_size = flash_list[flash_idx]->block_size; + } + if (sector_size) { + *sector_size = flash_list[flash_idx]->sector_size; + } + if (page_size) { + *page_size = flash_list[flash_idx]->page_size; + } + + return 0; +} + +static void norflash_set_cfg_div(void) { + if (div_others) { + norflaship_div(div_others); + } +} + +static void norflash_set_read_div(void) { + if (norflash_op_mode & HAL_NORFLASH_OP_MODE_STAND_SPI) { + if (div_std_read) { + norflaship_div(div_std_read); + } + } else { + if (div_read) { + norflaship_div(div_read); + } + } +} + +int norflash_set_mode(uint32_t op) { + uint32_t read_mode = 0; + uint32_t ext_mode = 0; + uint32_t program_mode = 0; + uint32_t self_mode; + uint32_t mode; + + self_mode = norflash_get_supported_mode(); + mode = (self_mode & op); + + if (mode & HAL_NORFLASH_OP_MODE_QUAD_IO) { + read_mode = HAL_NORFLASH_OP_MODE_QUAD_IO; + } else if (mode & HAL_NORFLASH_OP_MODE_QUAD_OUTPUT) { + read_mode = HAL_NORFLASH_OP_MODE_QUAD_OUTPUT; + } else if (mode & HAL_NORFLASH_OP_MODE_DUAL_IO) { + read_mode = HAL_NORFLASH_OP_MODE_DUAL_IO; + } else if (mode & HAL_NORFLASH_OP_MODE_DUAL_OUTPUT) { + read_mode = HAL_NORFLASH_OP_MODE_DUAL_OUTPUT; + } else if (mode & HAL_NORFLASH_OP_MODE_FAST_SPI) { + read_mode = HAL_NORFLASH_OP_MODE_FAST_SPI; + } else if (mode & HAL_NORFLASH_OP_MODE_STAND_SPI) { + read_mode = HAL_NORFLASH_OP_MODE_STAND_SPI; + } else { + // Op error + return 1; + } + + if (mode & HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM) { + program_mode = HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM; + } else if (mode & HAL_NORFLASH_OP_MODE_DUAL_PAGE_PROGRAM) { + program_mode = HAL_NORFLASH_OP_MODE_DUAL_PAGE_PROGRAM; + } else if (mode & HAL_NORFLASH_OP_MODE_PAGE_PROGRAM) { + program_mode = HAL_NORFLASH_OP_MODE_PAGE_PROGRAM; + } else { + // Op error + return 1; + } + +#ifdef FLASH_BURST_WRAP + if (mode & HAL_NORFLASH_OP_MODE_READ_WRAP) { + ext_mode |= HAL_NORFLASH_OP_MODE_READ_WRAP; + } +#endif + +#ifdef FLASH_HPM + if (mode & HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE) { + ext_mode |= HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE; + } +#endif + + if (mode & (HAL_NORFLASH_OP_MODE_QUAD_IO | HAL_NORFLASH_OP_MODE_DUAL_IO)) { + if (mode & HAL_NORFLASH_OP_MODE_CONTINUOUS_READ) { + ext_mode |= HAL_NORFLASH_OP_MODE_CONTINUOUS_READ; + } + } + + mode = (read_mode | ext_mode | program_mode); + + if (norflash_op_mode != mode) { + norflash_op_mode = mode; + + // Continuous read off if flash supported + if ((self_mode & + (HAL_NORFLASH_OP_MODE_QUAD_IO | HAL_NORFLASH_OP_MODE_DUAL_IO)) && + (self_mode & HAL_NORFLASH_OP_MODE_CONTINUOUS_READ)) { + norflash_set_continuous_read(0); + } + + norflaship_quad_mode(0); + + norflaship_dual_mode(0); + +#ifdef FLASH_HPM + if (mode & HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE) { + // High performance mode on + norflash_set_hpm(1); + } +#endif if (mode & HAL_NORFLASH_OP_MODE_QUAD_IO) { - read_mode = HAL_NORFLASH_OP_MODE_QUAD_IO; + // Quad io mode + norflash_set_quad_io_mode(1); } else if (mode & HAL_NORFLASH_OP_MODE_QUAD_OUTPUT) { - read_mode = HAL_NORFLASH_OP_MODE_QUAD_OUTPUT; + // Quad output mode + norflash_set_quad_output_mode(1); } else if (mode & HAL_NORFLASH_OP_MODE_DUAL_IO) { - read_mode = HAL_NORFLASH_OP_MODE_DUAL_IO; + // Dual io mode + norflash_set_dual_io_mode(1); } else if (mode & HAL_NORFLASH_OP_MODE_DUAL_OUTPUT) { - read_mode = HAL_NORFLASH_OP_MODE_DUAL_OUTPUT; + // Dual output mode + norflash_set_dual_output_mode(1); } else if (mode & HAL_NORFLASH_OP_MODE_FAST_SPI) { - read_mode = HAL_NORFLASH_OP_MODE_FAST_SPI; - } else if(mode & HAL_NORFLASH_OP_MODE_STAND_SPI) { - read_mode = HAL_NORFLASH_OP_MODE_STAND_SPI; - } else { - // Op error - return 1; - } - - if (mode & HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM) { - program_mode = HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM; - } else if (mode & HAL_NORFLASH_OP_MODE_DUAL_PAGE_PROGRAM) { - program_mode = HAL_NORFLASH_OP_MODE_DUAL_PAGE_PROGRAM; - } else if (mode & HAL_NORFLASH_OP_MODE_PAGE_PROGRAM) { - program_mode = HAL_NORFLASH_OP_MODE_PAGE_PROGRAM; - } else { - // Op error - return 1; + // Fast mode + norflash_set_fast_mode(1); + } else if (mode & HAL_NORFLASH_OP_MODE_STAND_SPI) { + // Standard spi mode + norflash_set_stand_mode(); } #ifdef FLASH_BURST_WRAP if (mode & HAL_NORFLASH_OP_MODE_READ_WRAP) { - ext_mode |= HAL_NORFLASH_OP_MODE_READ_WRAP; + norflash_set_burst_wrap(32); + hal_cache_wrap_enable(HAL_CACHE_ID_I_CACHE); + hal_cache_wrap_enable(HAL_CACHE_ID_D_CACHE); } #endif #ifdef FLASH_HPM - if (mode & HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE) { - ext_mode |= HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE; + if ((self_mode & HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE) && + (mode & HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE) == 0) { + // High performance mode off + norflash_set_hpm(0); } #endif - if (mode & (HAL_NORFLASH_OP_MODE_QUAD_IO | HAL_NORFLASH_OP_MODE_DUAL_IO)) { - if (mode & HAL_NORFLASH_OP_MODE_CONTINUOUS_READ) { - ext_mode |= HAL_NORFLASH_OP_MODE_CONTINUOUS_READ; - } - } - - mode = (read_mode | ext_mode | program_mode); - - if (norflash_op_mode != mode) { - norflash_op_mode = mode; - - // Continuous read off if flash supported - if ((self_mode & (HAL_NORFLASH_OP_MODE_QUAD_IO | HAL_NORFLASH_OP_MODE_DUAL_IO)) && - (self_mode & HAL_NORFLASH_OP_MODE_CONTINUOUS_READ)) { - norflash_set_continuous_read(0); - } - - norflaship_quad_mode(0); - - norflaship_dual_mode(0); - -#ifdef FLASH_HPM - if (mode & HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE) { - // High performance mode on - norflash_set_hpm(1); - } -#endif - - if (mode & HAL_NORFLASH_OP_MODE_QUAD_IO) { - // Quad io mode - norflash_set_quad_io_mode(1); - } else if (mode & HAL_NORFLASH_OP_MODE_QUAD_OUTPUT) { - // Quad output mode - norflash_set_quad_output_mode(1); - } else if (mode & HAL_NORFLASH_OP_MODE_DUAL_IO) { - // Dual io mode - norflash_set_dual_io_mode(1); - } else if (mode & HAL_NORFLASH_OP_MODE_DUAL_OUTPUT) { - // Dual output mode - norflash_set_dual_output_mode(1); - } else if (mode & HAL_NORFLASH_OP_MODE_FAST_SPI) { - // Fast mode - norflash_set_fast_mode(1); - } else if (mode & HAL_NORFLASH_OP_MODE_STAND_SPI) { - // Standard spi mode - norflash_set_stand_mode(); - } - -#ifdef FLASH_BURST_WRAP - if (mode & HAL_NORFLASH_OP_MODE_READ_WRAP) { - norflash_set_burst_wrap(32); - hal_cache_wrap_enable(HAL_CACHE_ID_I_CACHE); - hal_cache_wrap_enable(HAL_CACHE_ID_D_CACHE); - } -#endif - -#ifdef FLASH_HPM - if ((self_mode & HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE) && - (mode & HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE) == 0) { - // High performance mode off - norflash_set_hpm(0); - } -#endif - - if (mode & HAL_NORFLASH_OP_MODE_CONTINUOUS_READ) { - // Continuous read on - norflash_set_continuous_read(1); - } - - norflaship_cmd_done(); - } - - norflash_set_read_div(); - - return 0; -} - -int norflash_pre_operation(void) -{ - norflash_set_cfg_div(); - - if (norflash_op_mode & HAL_NORFLASH_OP_MODE_CONTINUOUS_READ) { - norflash_set_continuous_read(0); - } - - return 0; -} - -int norflash_post_operation(void) -{ - if (norflash_op_mode & HAL_NORFLASH_OP_MODE_CONTINUOUS_READ) { - norflash_set_continuous_read(1); + if (mode & HAL_NORFLASH_OP_MODE_CONTINUOUS_READ) { + // Continuous read on + norflash_set_continuous_read(1); } norflaship_cmd_done(); + } - norflash_set_read_div(); + norflash_set_read_div(); - return 0; + return 0; } -int norflash_read_reg(uint8_t cmd, uint8_t *val, uint32_t len) -{ - int i; +int norflash_pre_operation(void) { + norflash_set_cfg_div(); - norflaship_clear_fifos(); + if (norflash_op_mode & HAL_NORFLASH_OP_MODE_CONTINUOUS_READ) { + norflash_set_continuous_read(0); + } + + return 0; +} + +int norflash_post_operation(void) { + if (norflash_op_mode & HAL_NORFLASH_OP_MODE_CONTINUOUS_READ) { + norflash_set_continuous_read(1); + } + + norflaship_cmd_done(); + + norflash_set_read_div(); + + return 0; +} + +int norflash_read_reg(uint8_t cmd, uint8_t *val, uint32_t len) { + int i; + + norflaship_clear_fifos(); #ifdef TRY_EMBEDDED_CMD - if ((cmd == GD25Q32C_CMD_READ_STATUS_S0_S7 || cmd == GD25Q32C_CMD_READ_STATUS_S8_S15) && len == 1) { - norflaship_cmd_addr(cmd, 0); + if ((cmd == GD25Q32C_CMD_READ_STATUS_S0_S7 || + cmd == GD25Q32C_CMD_READ_STATUS_S8_S15) && + len == 1) { + norflaship_cmd_addr(cmd, 0); + } else { + if (cmd == GD25Q32C_CMD_ID) { + norflaship_blksize(len); + norflaship_cmd_addr(cmd, 0); } else { - if (cmd == GD25Q32C_CMD_ID) { - norflaship_blksize(len); - norflaship_cmd_addr(cmd, 0); - } else { - norflaship_ext_rx_cmd(cmd, 0, len); - } + norflaship_ext_rx_cmd(cmd, 0, len); } + } #else - norflaship_ext_rx_cmd(cmd, 0, len); + norflaship_ext_rx_cmd(cmd, 0, len); #endif - norflaship_rxfifo_count_wait(len); - for (i = 0; i < len; i++) { - val[i] = norflaship_read_rxfifo(); - } + norflaship_rxfifo_count_wait(len); + for (i = 0; i < len; i++) { + val[i] = norflaship_read_rxfifo(); + } - return 0; + return 0; } -int norflash_read_reg_ex(uint8_t cmd, uint8_t *param, uint32_t param_len, uint8_t *val, uint32_t len) -{ - int i; +int norflash_read_reg_ex(uint8_t cmd, uint8_t *param, uint32_t param_len, + uint8_t *val, uint32_t len) { + int i; - norflaship_clear_fifos(); - if (param && param_len > 0) { - norflaship_write_txfifo(param, param_len); - } else { - param_len = 0; - } - norflaship_ext_rx_cmd(cmd, param_len, len); - for (i = 0; i < len; i++) { - norflaship_rxfifo_empty_wait(); - val[i] = norflaship_read_rxfifo(); - } + norflaship_clear_fifos(); + if (param && param_len > 0) { + norflaship_write_txfifo(param, param_len); + } else { + param_len = 0; + } + norflaship_ext_rx_cmd(cmd, param_len, len); + for (i = 0; i < len; i++) { + norflaship_rxfifo_empty_wait(); + val[i] = norflaship_read_rxfifo(); + } - return 0; + return 0; } -int norflash_write_reg(uint8_t cmd, const uint8_t *val, uint32_t len) -{ - norflaship_cmd_addr(GD25Q32C_CMD_WRITE_ENABLE, 0); - norflash_status_WIP_1_wait(0); - norflash_status_WEL_0_wait(); +int norflash_write_reg(uint8_t cmd, const uint8_t *val, uint32_t len) { + norflaship_cmd_addr(GD25Q32C_CMD_WRITE_ENABLE, 0); + norflash_status_WIP_1_wait(0); + norflash_status_WEL_0_wait(); - norflaship_clear_txfifo(); - norflaship_write_txfifo(val, len); + norflaship_clear_txfifo(); + norflaship_write_txfifo(val, len); #ifdef TRY_EMBEDDED_CMD - if (cmd == GD25Q32C_CMD_WRITE_STATUS_S0_S7) { - norflaship_cmd_addr(GD25Q32C_CMD_WRITE_STATUS_S0_S7, 0); - } else { - norflaship_ext_tx_cmd(cmd, len); - } -#else + if (cmd == GD25Q32C_CMD_WRITE_STATUS_S0_S7) { + norflaship_cmd_addr(GD25Q32C_CMD_WRITE_STATUS_S0_S7, 0); + } else { norflaship_ext_tx_cmd(cmd, len); + } +#else + norflaship_ext_tx_cmd(cmd, len); #endif - norflash_status_WIP_1_wait(0); + norflash_status_WIP_1_wait(0); - return 0; + return 0; } -int norflash_get_id(uint8_t *value, uint32_t len) -{ - norflash_pre_operation(); +int norflash_get_id(uint8_t *value, uint32_t len) { + norflash_pre_operation(); - if (len > NORFLASH_ID_LEN) { - len = NORFLASH_ID_LEN; + if (len > NORFLASH_ID_LEN) { + len = NORFLASH_ID_LEN; + } + norflash_read_reg(GD25Q32C_CMD_ID, value, len); + + norflash_post_operation(); + + return 0; +} + +int norflash_get_unique_id(uint8_t *value, uint32_t len) { + uint32_t param; + uint8_t cmd; + + norflash_pre_operation(); + + if (flash_list[flash_idx]->id[0] == NORFLASH_XTS_ID_PREFIX) { + if (len > XTS_UNIQUE_ID_LEN) { + len = XTS_UNIQUE_ID_LEN; } - norflash_read_reg(GD25Q32C_CMD_ID, value, len); + param = XTS_UNIQUE_ID_PARAM; + cmd = XTS_UNIQUE_ID_CMD; + } else { + if (len > NORFLASH_UNIQUE_ID_LEN) { + len = NORFLASH_UNIQUE_ID_LEN; + } + param = 0; + cmd = GD25Q32C_CMD_UNIQUE_ID; + } + norflash_read_reg_ex(cmd, (uint8_t *)¶m, sizeof(param), value, len); - norflash_post_operation(); + norflash_post_operation(); - return 0; + return 0; } -int norflash_get_unique_id(uint8_t *value, uint32_t len) -{ - uint32_t param; - uint8_t cmd; +static void norflash_get_samdly_list(uint32_t div, + const uint8_t **samdly_list_p, + uint32_t *size_p) { + const uint8_t *samdly_list = NULL; + uint32_t size = 0; - norflash_pre_operation(); - - if (flash_list[flash_idx]->id[0] == NORFLASH_XTS_ID_PREFIX) { - if (len > XTS_UNIQUE_ID_LEN) { - len = XTS_UNIQUE_ID_LEN; - } - param = XTS_UNIQUE_ID_PARAM; - cmd = XTS_UNIQUE_ID_CMD; +#if (CHIP_FLASH_CTRL_VER <= 1) + if (div >= 2) { + samdly_list = samdly_list_divn; + size = ARRAY_SIZE(samdly_list_divn); + } +#else + if (div >= 1) { + if (div == 1) { + samdly_list = samdly_list_div1; + size = ARRAY_SIZE(samdly_list_div1); } else { - if (len > NORFLASH_UNIQUE_ID_LEN) { - len = NORFLASH_UNIQUE_ID_LEN; - } - param = 0; - cmd = GD25Q32C_CMD_UNIQUE_ID; + samdly_list = samdly_list_divn; + size = ARRAY_SIZE(samdly_list_divn); } - norflash_read_reg_ex(cmd, (uint8_t *)¶m, sizeof(param), value, len); + } +#endif - norflash_post_operation(); - - return 0; + if (samdly_list_p) { + *samdly_list_p = samdly_list; + } + if (size_p) { + *size_p = size; + } } -static void norflash_get_samdly_list(uint32_t div, const uint8_t **samdly_list_p, uint32_t *size_p) -{ - const uint8_t *samdly_list = NULL; - uint32_t size = 0; +void norflash_set_sample_delay_index(uint32_t index) { + const uint8_t *samdly_list; + uint32_t size; + uint32_t div; + sample_delay_index = index; + + div = norflaship_get_div(); + + norflash_get_samdly_list(div, &samdly_list, &size); + + if (index < size) { #if (CHIP_FLASH_CTRL_VER <= 1) - if (div >= 2) { - samdly_list = samdly_list_divn; - size = ARRAY_SIZE(samdly_list_divn); - } + norflaship_pos_neg(samdly_list[index] & SAM_EDGE_FALLING); + norflaship_neg_phase(samdly_list[index] & SAM_NEG_PHASE); + norflaship_samdly(samdly_list[index] & SAMDLY_MASK); #else - if (div >= 1) { - if (div == 1) { - samdly_list = samdly_list_div1; - size = ARRAY_SIZE(samdly_list_div1); - } else { - samdly_list = samdly_list_divn; - size = ARRAY_SIZE(samdly_list_divn); - } - } + norflaship_samdly(samdly_list[index]); #endif - - if (samdly_list_p) { - *samdly_list_p = samdly_list; - } - if (size_p) { - *size_p = size; - } + } } -void norflash_set_sample_delay_index(uint32_t index) -{ - const uint8_t *samdly_list; - uint32_t size; - uint32_t div; +uint32_t norflash_get_sample_delay_index(void) { return sample_delay_index; } - sample_delay_index = index; +static bool norflash_calib_flash_id_valid(void) { + uint8_t id[HAL_NORFLASH_DEVICE_ID_LEN]; + const uint8_t *cmp_id; - div = norflaship_get_div(); + norflash_get_id(id, sizeof(id)); + cmp_id = flash_list[flash_idx]->id; - norflash_get_samdly_list(div, &samdly_list, &size); - - if (index < size) { -#if (CHIP_FLASH_CTRL_VER <= 1) - norflaship_pos_neg(samdly_list[index] & SAM_EDGE_FALLING); - norflaship_neg_phase(samdly_list[index] & SAM_NEG_PHASE); - norflaship_samdly(samdly_list[index] & SAMDLY_MASK); -#else - norflaship_samdly(samdly_list[index]); -#endif - } + if (id[0] == cmp_id[0] && id[1] == cmp_id[1] && id[2] == cmp_id[2]) { + return true; + } + return false; } -uint32_t norflash_get_sample_delay_index(void) -{ - return sample_delay_index; -} - -static bool norflash_calib_flash_id_valid(void) -{ - uint8_t id[HAL_NORFLASH_DEVICE_ID_LEN]; - const uint8_t *cmp_id; - - norflash_get_id(id, sizeof(id)); - cmp_id = flash_list[flash_idx]->id; - - if (id[0] == cmp_id[0] && id[1] == cmp_id[1] && id[2] == cmp_id[2]) { - return true; - } - return false; -} - -static bool norflash_calib_magic_word_valid(void) -{ - uint32_t magic; +static bool norflash_calib_magic_word_valid(void) { + uint32_t magic; #if (CHIP_FLASH_CTRL_VER <= 1) - norflash_read(FLASH_NC_BASE, NULL, 1); + norflash_read(FLASH_NC_BASE, NULL, 1); #endif - norflaship_clear_rxfifo(); + norflaship_clear_rxfifo(); #if (FLASH_NC_BASE == FLASH_BASE) - hal_cache_invalidate(HAL_CACHE_ID_D_CACHE, FLASH_BASE, sizeof(magic)); - magic = *(volatile uint32_t *)FLASH_BASE; + hal_cache_invalidate(HAL_CACHE_ID_D_CACHE, FLASH_BASE, sizeof(magic)); + magic = *(volatile uint32_t *)FLASH_BASE; #else - magic = *(volatile uint32_t *)FLASH_NC_BASE; + magic = *(volatile uint32_t *)FLASH_NC_BASE; #endif - if (magic == BOOT_MAGIC_NUMBER) { - return true; - } - return false; + if (magic == BOOT_MAGIC_NUMBER) { + return true; + } + return false; } -int norflash_sample_delay_calib(enum DRV_NORFLASH_CALIB_T type) -{ - int i; - uint32_t matched_cnt = 0; - uint32_t matched_idx = 0; - uint32_t div; - uint32_t size; - bool valid; +int norflash_sample_delay_calib(enum DRV_NORFLASH_CALIB_T type) { + int i; + uint32_t matched_cnt = 0; + uint32_t matched_idx = 0; + uint32_t div; + uint32_t size; + bool valid; - if (type >= DRV_NORFLASH_CALIB_QTY) { - return 1; - } + if (type >= DRV_NORFLASH_CALIB_QTY) { + return 1; + } #if defined(ROM_BUILD) || defined(PROGRAMMER) - if (type != DRV_NORFLASH_CALIB_FLASH_ID) { - return 0; - } + if (type != DRV_NORFLASH_CALIB_FLASH_ID) { + return 0; + } #endif - div = norflaship_get_div(); + div = norflaship_get_div(); - if (div == 0) { - return -1; + if (div == 0) { + return -1; #if (CHIP_FLASH_CTRL_VER <= 1) - } else if (div == 1) { - return -2; + } else if (div == 1) { + return -2; #endif + } + + norflash_get_samdly_list(div, NULL, &size); + + for (i = 0; i < size; i++) { + norflaship_busy_wait(); + + norflash_set_sample_delay_index(i); + + if (type == DRV_NORFLASH_CALIB_FLASH_ID) { + valid = norflash_calib_flash_id_valid(); + } else { + valid = norflash_calib_magic_word_valid(); } - norflash_get_samdly_list(div, NULL, &size); - - for (i = 0; i < size; i++) { - norflaship_busy_wait(); - - norflash_set_sample_delay_index(i); - - if (type == DRV_NORFLASH_CALIB_FLASH_ID) { - valid = norflash_calib_flash_id_valid(); - } else { - valid = norflash_calib_magic_word_valid(); - } - - if (valid) { - if (matched_cnt == 0) { - matched_idx = i; - } - matched_cnt++; - } else if (matched_cnt) { - break; - } + if (valid) { + if (matched_cnt == 0) { + matched_idx = i; + } + matched_cnt++; + } else if (matched_cnt) { + break; } + } #ifdef FLASH_CALIB_DEBUG - calib_matched_idx[type] = matched_idx; - calib_matched_cnt[type] = matched_cnt; + calib_matched_idx[type] = matched_idx; + calib_matched_cnt[type] = matched_cnt; #endif - if (matched_cnt) { + if (matched_cnt) { #ifdef SAMP_DELAY_PRIO_FALLING_EDGE - if (matched_cnt == 2) { - uint32_t falling_edge_idx; + if (matched_cnt == 2) { + uint32_t falling_edge_idx; - if (0) { + if (0) { #if (CHIP_FLASH_CTRL_VER >= 2) - } else if (div == 1) { - falling_edge_idx = DIV1_SAMP_DELAY_FALLING_EDGE_IDX; + } else if (div == 1) { + falling_edge_idx = DIV1_SAMP_DELAY_FALLING_EDGE_IDX; #endif - } else if (div == 2) { - falling_edge_idx = DIV2_SAMP_DELAY_FALLING_EDGE_IDX; - if (falling_edge_adj) { - falling_edge_idx++; - } - } else { - falling_edge_idx = DIVN_SAMP_DELAY_FALLING_EDGE_IDX; - } - if (matched_idx <= falling_edge_idx && - falling_edge_idx < matched_idx + matched_cnt) { - matched_idx = falling_edge_idx; - matched_cnt = 1; - } + } else if (div == 2) { + falling_edge_idx = DIV2_SAMP_DELAY_FALLING_EDGE_IDX; + if (falling_edge_adj) { + falling_edge_idx++; } + } else { + falling_edge_idx = DIVN_SAMP_DELAY_FALLING_EDGE_IDX; + } + if (matched_idx <= falling_edge_idx && + falling_edge_idx < matched_idx + matched_cnt) { + matched_idx = falling_edge_idx; + matched_cnt = 1; + } + } #endif - matched_idx += matched_cnt / 2; - norflash_set_sample_delay_index(matched_idx); + matched_idx += matched_cnt / 2; + norflash_set_sample_delay_index(matched_idx); #ifdef FLASH_CALIB_DEBUG - calib_final_idx[type] = matched_idx; + calib_final_idx[type] = matched_idx; #endif - return 0; - } - -#ifdef FLASH_CALIB_DEBUG - calib_final_idx[type] = -1; -#endif - - return 1; -} - -void norflash_show_calib_result(void) -{ -#ifdef FLASH_CALIB_DEBUG - union DRV_NORFLASH_SPEED_RATIO_T ratio; - uint32_t div; - uint32_t size; - const uint8_t *list; - int i; - - TRACE(0, "FLASH_CALIB_RESULT:"); - TRACE(0, "\nsource_clk=%u speed=%u flash_max=%u", norflash_source_clk, norflash_speed, flash_list[flash_idx]->max_speed); - ratio = flash_list[flash_idx]->speed_ratio; - TRACE(0, "\nstd_read=%u/8 others=%u/8", (ratio.s.std_read + 1), (ratio.s.others + 1)); - - div = norflaship_get_div(); - TRACE(0, "
\ndiv=%u", div); - norflash_get_samdly_list(div, &list, &size); - TRACE(0, ""); - if (list == NULL || size == 0) { - TRACE(0, "NONE"); - } else { - DUMP8("%02X ", list, size); - } - TRACE(0, ""); - for (i = 0; i < DRV_NORFLASH_CALIB_QTY; i++) { - TRACE(0, "type=%d idx=%02u cnt=%02u final=%02u", - i, calib_matched_idx[i], calib_matched_cnt[i], calib_final_idx[i]); - } - TRACE(0, "\t"); -#endif -} - -int norflash_init_sample_delay_by_div(uint32_t div) -{ - if (div == 0) { - return -1; - } if (div == 1) { -#if (CHIP_FLASH_CTRL_VER <= 1) - return -2; -#else - norflaship_samdly(1); -#endif - } else if (div == 2 && !falling_edge_adj) { - // Set sample delay to clock falling edge -#if (CHIP_FLASH_CTRL_VER <= 1) - norflaship_pos_neg(1); - norflaship_neg_phase(1); - norflaship_samdly(2); -#else - norflaship_samdly(3); -#endif - } else { - // Set sample delay to nearest to but not later than clock falling edge -#if (CHIP_FLASH_CTRL_VER <= 1) - norflaship_pos_neg(0); - norflaship_neg_phase(0); - norflaship_samdly(2); -#else - norflaship_samdly(4); -#endif - } - return 0; -} - -int norflash_init_div(const struct HAL_NORFLASH_CONFIG_T *cfg) -{ - uint32_t max_speed; - uint32_t std_read_speed; - uint32_t others_speed; - union DRV_NORFLASH_SPEED_RATIO_T ratio; - uint32_t div; + } #ifdef FLASH_CALIB_DEBUG - norflash_source_clk = cfg->source_clk; - norflash_speed = cfg->speed; + calib_final_idx[type] = -1; #endif - max_speed = flash_list[flash_idx]->max_speed; - ratio = flash_list[flash_idx]->speed_ratio; + return 1; +} - if (max_speed == 0) { - max_speed = NORFLASH_DEFAULT_MAX_SPEED; - } - if (max_speed > cfg->speed) { - max_speed = cfg->speed; - } - if (max_speed > cfg->source_clk) { - max_speed = cfg->source_clk; - } - std_read_speed = max_speed * (1 + ratio.s.std_read) / NORFLASH_SPEED_RATIO_DENOMINATOR; - others_speed = max_speed * (1 + ratio.s.others) / NORFLASH_SPEED_RATIO_DENOMINATOR; +void norflash_show_calib_result(void) { +#ifdef FLASH_CALIB_DEBUG + union DRV_NORFLASH_SPEED_RATIO_T ratio; + uint32_t div; + uint32_t size; + const uint8_t *list; + int i; - div = (cfg->source_clk + max_speed - 1) / max_speed; - div_read = (div < NORFLASH_MAX_DIV) ? div : NORFLASH_MAX_DIV; - div = (cfg->source_clk + std_read_speed - 1) / std_read_speed; - div_std_read = (div < NORFLASH_MAX_DIV) ? div : NORFLASH_MAX_DIV; - div = (cfg->source_clk + others_speed - 1) / others_speed; - div_others = (div < NORFLASH_MAX_DIV) ? div : NORFLASH_MAX_DIV; + TRACE(0, "FLASH_CALIB_RESULT:"); + TRACE(0, "\nsource_clk=%u speed=%u flash_max=%u", norflash_source_clk, + norflash_speed, flash_list[flash_idx]->max_speed); + ratio = flash_list[flash_idx]->speed_ratio; + TRACE(0, "\nstd_read=%u/8 others=%u/8", (ratio.s.std_read + 1), + (ratio.s.others + 1)); - if (div_read == 2 && max_speed >= FALLING_EDGE_SAMPLE_ADJ_FREQ) { - falling_edge_adj = true; - } else { - falling_edge_adj = false; - } + div = norflaship_get_div(); + TRACE(0, "
\ndiv=%u", div); + norflash_get_samdly_list(div, &list, &size); + TRACE(0, ""); + if (list == NULL || size == 0) { + TRACE(0, "NONE"); + } else { + DUMP8("%02X ", list, size); + } + TRACE(0, ""); + for (i = 0; i < DRV_NORFLASH_CALIB_QTY; i++) { + TRACE(0, "type=%d idx=%02u cnt=%02u final=%02u", i, calib_matched_idx[i], + calib_matched_cnt[i], calib_final_idx[i]); + } + TRACE(0, "\t"); +#endif +} - if (div_read && div_std_read && div_others) { +int norflash_init_sample_delay_by_div(uint32_t div) { + if (div == 0) { + return -1; + } + if (div == 1) { #if (CHIP_FLASH_CTRL_VER <= 1) - if (div_read == 1) { - return -1; - } + return -2; #else - if (div_read == 1 && max_speed > NORFLASH_DIV1_MAX_SPEED) { - return -1; - } + norflaship_samdly(1); #endif - // Init sample delay according to div_read - norflash_init_sample_delay_by_div(div_read); - // Still in command mode - norflaship_div(div_others); - return 0; - } + } else if (div == 2 && !falling_edge_adj) { + // Set sample delay to clock falling edge +#if (CHIP_FLASH_CTRL_VER <= 1) + norflaship_pos_neg(1); + norflaship_neg_phase(1); + norflaship_samdly(2); +#else + norflaship_samdly(3); +#endif + } else { + // Set sample delay to nearest to but not later than clock falling edge +#if (CHIP_FLASH_CTRL_VER <= 1) + norflaship_pos_neg(0); + norflaship_neg_phase(0); + norflaship_samdly(2); +#else + norflaship_samdly(4); +#endif + } - return 1; + return 0; } -int norflash_match_chip(const uint8_t *id, uint32_t len) -{ - const uint8_t *cmp_id; +int norflash_init_div(const struct HAL_NORFLASH_CONFIG_T *cfg) { + uint32_t max_speed; + uint32_t std_read_speed; + uint32_t others_speed; + union DRV_NORFLASH_SPEED_RATIO_T ratio; + uint32_t div; - if (len == NORFLASH_ID_LEN) { - for (flash_idx = 0; flash_idx < ARRAY_SIZE(flash_list); flash_idx++) { - cmp_id = flash_list[flash_idx]->id; - if (id[0] == cmp_id[0] && id[1] == cmp_id[1] && id[2] == cmp_id[2]) { - return true; - } - } +#ifdef FLASH_CALIB_DEBUG + norflash_source_clk = cfg->source_clk; + norflash_speed = cfg->speed; +#endif + + max_speed = flash_list[flash_idx]->max_speed; + ratio = flash_list[flash_idx]->speed_ratio; + + if (max_speed == 0) { + max_speed = NORFLASH_DEFAULT_MAX_SPEED; + } + if (max_speed > cfg->speed) { + max_speed = cfg->speed; + } + if (max_speed > cfg->source_clk) { + max_speed = cfg->source_clk; + } + std_read_speed = + max_speed * (1 + ratio.s.std_read) / NORFLASH_SPEED_RATIO_DENOMINATOR; + others_speed = + max_speed * (1 + ratio.s.others) / NORFLASH_SPEED_RATIO_DENOMINATOR; + + div = (cfg->source_clk + max_speed - 1) / max_speed; + div_read = (div < NORFLASH_MAX_DIV) ? div : NORFLASH_MAX_DIV; + div = (cfg->source_clk + std_read_speed - 1) / std_read_speed; + div_std_read = (div < NORFLASH_MAX_DIV) ? div : NORFLASH_MAX_DIV; + div = (cfg->source_clk + others_speed - 1) / others_speed; + div_others = (div < NORFLASH_MAX_DIV) ? div : NORFLASH_MAX_DIV; + + if (div_read == 2 && max_speed >= FALLING_EDGE_SAMPLE_ADJ_FREQ) { + falling_edge_adj = true; + } else { + falling_edge_adj = false; + } + + if (div_read && div_std_read && div_others) { +#if (CHIP_FLASH_CTRL_VER <= 1) + if (div_read == 1) { + return -1; } +#else + if (div_read == 1 && max_speed > NORFLASH_DIV1_MAX_SPEED) { + return -1; + } +#endif + // Init sample delay according to div_read + norflash_init_sample_delay_by_div(div_read); + // Still in command mode + norflaship_div(div_others); + return 0; + } - return false; + return 1; +} + +int norflash_match_chip(const uint8_t *id, uint32_t len) { + const uint8_t *cmp_id; + + if (len == NORFLASH_ID_LEN) { + for (flash_idx = 0; flash_idx < ARRAY_SIZE(flash_list); flash_idx++) { + cmp_id = flash_list[flash_idx]->id; + if (id[0] == cmp_id[0] && id[1] == cmp_id[1] && id[2] == cmp_id[2]) { + return true; + } + } + } + + return false; } #ifdef PUYA_FLASH_ERASE_PAGE_ENABLE -static void norflaship_ext_cmd_addr(uint8_t cmd, uint32_t addr) -{ - uint8_t buff[3]; +static void norflaship_ext_cmd_addr(uint8_t cmd, uint32_t addr) { + uint8_t buff[3]; - buff[2] = (uint8_t)(addr & 0xff); - buff[1] = (uint8_t)((addr >> 8) & 0xff); - buff[0] = (uint8_t)((addr >> 16) & 0xff); + buff[2] = (uint8_t)(addr & 0xff); + buff[1] = (uint8_t)((addr >> 8) & 0xff); + buff[0] = (uint8_t)((addr >> 16) & 0xff); - norflaship_clear_txfifo(); - norflaship_write_txfifo(buff, 3); - norflaship_ext_tx_cmd(cmd, 3); + norflaship_clear_txfifo(); + norflaship_write_txfifo(buff, 3); + norflaship_ext_tx_cmd(cmd, 3); } #endif -enum HAL_NORFLASH_RET_T norflash_erase(uint32_t start_address, enum DRV_NORFLASH_ERASE_T type, int suspend) -{ - enum HAL_NORFLASH_RET_T ret; - - if (flash_list[flash_idx]->mode & HAL_NORFLASH_OP_MODE_ERASE_IN_STD) { - if(norflash_op_mode & HAL_NORFLASH_OP_MODE_QUAD_IO) { - norflash_set_quad_io_mode(0); - } else if(norflash_op_mode & HAL_NORFLASH_OP_MODE_QUAD_OUTPUT) { - norflash_set_quad_output_mode(0); - } - } - - norflaship_cmd_addr(GD25Q32C_CMD_WRITE_ENABLE, start_address); - // Need 1us. Or norflash_status_WEL_0_wait(), which needs 6us. - switch(type) { -#ifdef PUYA_FLASH_ERASE_PAGE_ENABLE - case DRV_NORFLASH_ERASE_PAGE: - norflaship_ext_cmd_addr(PUYA_FLASH_CMD_PAGE_ERASE, start_address); - break; -#endif - case DRV_NORFLASH_ERASE_SECTOR: - norflaship_cmd_addr(GD25Q32C_CMD_SECTOR_ERASE, start_address); - break; - case DRV_NORFLASH_ERASE_BLOCK: - norflaship_cmd_addr(GD25Q32C_CMD_BLOCK_ERASE, start_address); - break; - case DRV_NORFLASH_ERASE_CHIP: - norflaship_cmd_addr(GD25Q32C_CMD_CHIP_ERASE, start_address); - break; - } - - norflaship_busy_wait(); - -#ifdef FLASH_SUSPEND - // PUYA flash requires the first delay of erase >= 400us - if (flash_list[flash_idx]->id[0] == NORFLASH_PUYA_ID_PREFIX) { - norflash_delay(400); - } -#endif - - ret = norflash_status_WIP_1_wait(suspend); - - if (flash_list[flash_idx]->mode & HAL_NORFLASH_OP_MODE_ERASE_IN_STD) { - if(norflash_op_mode & HAL_NORFLASH_OP_MODE_QUAD_IO) { - norflash_set_quad_io_mode(1); - } else if(norflash_op_mode & HAL_NORFLASH_OP_MODE_QUAD_OUTPUT) { - norflash_set_quad_output_mode(1); - } - } - - norflaship_cmd_done(); - - return ret; -} - -enum HAL_NORFLASH_RET_T norflash_write(uint32_t start_address, const uint8_t *buffer, uint32_t len, int suspend) -{ - enum HAL_NORFLASH_RET_T ret; - uint32_t POSSIBLY_UNUSED remains; - - if (len > GD25Q32C_PAGE_SIZE) { - return HAL_NORFLASH_ERR; - } - - norflaship_clear_txfifo(); - -#if (CHIP_FLASH_CTRL_VER >= 2) - norflaship_blksize(len); -#endif - - remains = norflaship_write_txfifo(buffer, len); - - norflaship_cmd_addr(GD25Q32C_CMD_WRITE_ENABLE, start_address); - if (norflash_op_mode & HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM) { - norflaship_cmd_addr(GD25Q32C_CMD_QUAD_PAGE_PROGRAM, start_address); - } else if (norflash_op_mode & HAL_NORFLASH_OP_MODE_DUAL_PAGE_PROGRAM) { - norflaship_cmd_addr(GD25Q32C_CMD_DUAL_PAGE_PROGRAM, start_address); - } else { - norflaship_cmd_addr(GD25Q32C_CMD_PAGE_PROGRAM, start_address); - } - -#if (CHIP_FLASH_CTRL_VER >= 2) - while (remains > 0) { - buffer += len - remains; - len = remains; - remains = norflaship_write_txfifo(buffer, len); - } -#endif - - norflaship_busy_wait(); - -#ifdef FLASH_SUSPEND - // PUYA flash requires the first delay of byte program >= 450us - if (flash_list[flash_idx]->id[0] == NORFLASH_PUYA_ID_PREFIX && len < GD25Q32C_PAGE_SIZE) { - norflash_delay(450); - } -#endif - - ret = norflash_status_WIP_1_wait(suspend); - - norflaship_cmd_done(); - - return ret; -} - -#ifdef FLASH_SUSPEND -enum HAL_NORFLASH_RET_T norflash_erase_resume(int suspend) -{ - // TODO: Need to check SUS1 bit in status reg? - - enum HAL_NORFLASH_RET_T ret; - - norflash_pre_operation(); - - norflash_resume(); - - ret = norflash_status_WIP_1_wait(suspend); - - norflash_post_operation(); - - return ret; -} - -enum HAL_NORFLASH_RET_T norflash_write_resume(int suspend) -{ - // TODO: Need to check SUS2 bit in status reg? - - return norflash_erase_resume(suspend); -} -#endif - -int norflash_read(uint32_t start_address, uint8_t *buffer, uint32_t len) -{ - uint32_t index = 0; - uint8_t val; - - if (len > NORFLASHIP_RXFIFO_SIZE) { - return 1; - } - - norflaship_clear_rxfifo(); - - norflaship_busy_wait(); - - norflaship_blksize(len); +enum HAL_NORFLASH_RET_T norflash_erase(uint32_t start_address, + enum DRV_NORFLASH_ERASE_T type, + int suspend) { + enum HAL_NORFLASH_RET_T ret; + if (flash_list[flash_idx]->mode & HAL_NORFLASH_OP_MODE_ERASE_IN_STD) { if (norflash_op_mode & HAL_NORFLASH_OP_MODE_QUAD_IO) { - /* Quad , only fast */ - norflaship_cmd_addr(GD25Q32C_CMD_FAST_QUAD_IO_READ, start_address); + norflash_set_quad_io_mode(0); } else if (norflash_op_mode & HAL_NORFLASH_OP_MODE_QUAD_OUTPUT) { - /* Dual, only fast */ - norflaship_cmd_addr(GD25Q32C_CMD_FAST_QUAD_OUTPUT_READ, start_address); - } else if (norflash_op_mode & HAL_NORFLASH_OP_MODE_DUAL_IO) { - /* Dual, only fast */ - norflaship_cmd_addr(GD25Q32C_CMD_FAST_DUAL_IO_READ, start_address); - } else if (norflash_op_mode & HAL_NORFLASH_OP_MODE_DUAL_OUTPUT) { - /* Dual, only fast */ - norflaship_cmd_addr(GD25Q32C_CMD_FAST_DUAL_OUTPUT_READ, start_address); - } else if (norflash_op_mode & HAL_NORFLASH_OP_MODE_FAST_SPI){ - /* fast */ - norflaship_cmd_addr(GD25Q32C_CMD_STANDARD_FAST_READ, start_address); - } else { - /* normal */ - norflaship_cmd_addr(GD25Q32C_CMD_STANDARD_READ, start_address); + norflash_set_quad_output_mode(0); } + } - while (1) { - norflaship_rxfifo_empty_wait(); - - val = norflaship_read_rxfifo(); - if (buffer) { - buffer[index] = val; - } - - ++index; - if (index >= len) { - break; - } - } - - norflaship_cmd_done(); - - return 0; -} - -void norflash_sleep(void) -{ - norflash_pre_operation(); -#ifdef FLASH_HPM - if (norflash_op_mode & HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE) { - norflash_set_hpm(0); - } + norflaship_cmd_addr(GD25Q32C_CMD_WRITE_ENABLE, start_address); + // Need 1us. Or norflash_status_WEL_0_wait(), which needs 6us. + switch (type) { +#ifdef PUYA_FLASH_ERASE_PAGE_ENABLE + case DRV_NORFLASH_ERASE_PAGE: + norflaship_ext_cmd_addr(PUYA_FLASH_CMD_PAGE_ERASE, start_address); + break; #endif - norflaship_cmd_addr(GD25Q32C_CMD_DEEP_POWER_DOWN, 0); -} + case DRV_NORFLASH_ERASE_SECTOR: + norflaship_cmd_addr(GD25Q32C_CMD_SECTOR_ERASE, start_address); + break; + case DRV_NORFLASH_ERASE_BLOCK: + norflaship_cmd_addr(GD25Q32C_CMD_BLOCK_ERASE, start_address); + break; + case DRV_NORFLASH_ERASE_CHIP: + norflaship_cmd_addr(GD25Q32C_CMD_CHIP_ERASE, start_address); + break; + } -void norflash_wakeup(void) -{ - norflaship_cmd_addr(GD25Q32C_CMD_RELEASE_FROM_DP, 0); - // Wait 20us for flash to finish - norflash_delay(40); -#ifdef FLASH_HPM - if (norflash_op_mode & HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE) { - norflash_set_hpm(1); - } + norflaship_busy_wait(); + +#ifdef FLASH_SUSPEND + // PUYA flash requires the first delay of erase >= 400us + if (flash_list[flash_idx]->id[0] == NORFLASH_PUYA_ID_PREFIX) { + norflash_delay(400); + } #endif - norflash_post_operation(); + + ret = norflash_status_WIP_1_wait(suspend); + + if (flash_list[flash_idx]->mode & HAL_NORFLASH_OP_MODE_ERASE_IN_STD) { + if (norflash_op_mode & HAL_NORFLASH_OP_MODE_QUAD_IO) { + norflash_set_quad_io_mode(1); + } else if (norflash_op_mode & HAL_NORFLASH_OP_MODE_QUAD_OUTPUT) { + norflash_set_quad_output_mode(1); + } + } + + norflaship_cmd_done(); + + return ret; } -int norflash_init_status(uint32_t status) -{ - if (flash_list[flash_idx]->write_status == NULL) { - return -1; - } +enum HAL_NORFLASH_RET_T norflash_write(uint32_t start_address, + const uint8_t *buffer, uint32_t len, + int suspend) { + enum HAL_NORFLASH_RET_T ret; + uint32_t POSSIBLY_UNUSED remains; - flash_list[flash_idx]->write_status(DRV_NORFLASH_W_STATUS_INIT, status); + if (len > GD25Q32C_PAGE_SIZE) { + return HAL_NORFLASH_ERR; + } - return 0; + norflaship_clear_txfifo(); + +#if (CHIP_FLASH_CTRL_VER >= 2) + norflaship_blksize(len); +#endif + + remains = norflaship_write_txfifo(buffer, len); + + norflaship_cmd_addr(GD25Q32C_CMD_WRITE_ENABLE, start_address); + if (norflash_op_mode & HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM) { + norflaship_cmd_addr(GD25Q32C_CMD_QUAD_PAGE_PROGRAM, start_address); + } else if (norflash_op_mode & HAL_NORFLASH_OP_MODE_DUAL_PAGE_PROGRAM) { + norflaship_cmd_addr(GD25Q32C_CMD_DUAL_PAGE_PROGRAM, start_address); + } else { + norflaship_cmd_addr(GD25Q32C_CMD_PAGE_PROGRAM, start_address); + } + +#if (CHIP_FLASH_CTRL_VER >= 2) + while (remains > 0) { + buffer += len - remains; + len = remains; + remains = norflaship_write_txfifo(buffer, len); + } +#endif + + norflaship_busy_wait(); + +#ifdef FLASH_SUSPEND + // PUYA flash requires the first delay of byte program >= 450us + if (flash_list[flash_idx]->id[0] == NORFLASH_PUYA_ID_PREFIX && + len < GD25Q32C_PAGE_SIZE) { + norflash_delay(450); + } +#endif + + ret = norflash_status_WIP_1_wait(suspend); + + norflaship_cmd_done(); + + return ret; } -int norflash_set_block_protection(uint32_t bp) -{ - if (flash_list[flash_idx]->write_status == NULL) { - return -1; +#ifdef FLASH_SUSPEND +enum HAL_NORFLASH_RET_T norflash_erase_resume(int suspend) { + // TODO: Need to check SUS1 bit in status reg? + + enum HAL_NORFLASH_RET_T ret; + + norflash_pre_operation(); + + norflash_resume(); + + ret = norflash_status_WIP_1_wait(suspend); + + norflash_post_operation(); + + return ret; +} + +enum HAL_NORFLASH_RET_T norflash_write_resume(int suspend) { + // TODO: Need to check SUS2 bit in status reg? + + return norflash_erase_resume(suspend); +} +#endif + +int norflash_read(uint32_t start_address, uint8_t *buffer, uint32_t len) { + uint32_t index = 0; + uint8_t val; + + if (len > NORFLASHIP_RXFIFO_SIZE) { + return 1; + } + + norflaship_clear_rxfifo(); + + norflaship_busy_wait(); + + norflaship_blksize(len); + + if (norflash_op_mode & HAL_NORFLASH_OP_MODE_QUAD_IO) { + /* Quad , only fast */ + norflaship_cmd_addr(GD25Q32C_CMD_FAST_QUAD_IO_READ, start_address); + } else if (norflash_op_mode & HAL_NORFLASH_OP_MODE_QUAD_OUTPUT) { + /* Dual, only fast */ + norflaship_cmd_addr(GD25Q32C_CMD_FAST_QUAD_OUTPUT_READ, start_address); + } else if (norflash_op_mode & HAL_NORFLASH_OP_MODE_DUAL_IO) { + /* Dual, only fast */ + norflaship_cmd_addr(GD25Q32C_CMD_FAST_DUAL_IO_READ, start_address); + } else if (norflash_op_mode & HAL_NORFLASH_OP_MODE_DUAL_OUTPUT) { + /* Dual, only fast */ + norflaship_cmd_addr(GD25Q32C_CMD_FAST_DUAL_OUTPUT_READ, start_address); + } else if (norflash_op_mode & HAL_NORFLASH_OP_MODE_FAST_SPI) { + /* fast */ + norflaship_cmd_addr(GD25Q32C_CMD_STANDARD_FAST_READ, start_address); + } else { + /* normal */ + norflaship_cmd_addr(GD25Q32C_CMD_STANDARD_READ, start_address); + } + + while (1) { + norflaship_rxfifo_empty_wait(); + + val = norflaship_read_rxfifo(); + if (buffer) { + buffer[index] = val; } - flash_list[flash_idx]->write_status(DRV_NORFLASH_W_STATUS_BP, bp); + ++index; + if (index >= len) { + break; + } + } - return 0; + norflaship_cmd_done(); + + return 0; +} + +void norflash_sleep(void) { + norflash_pre_operation(); +#ifdef FLASH_HPM + if (norflash_op_mode & HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE) { + norflash_set_hpm(0); + } +#endif + norflaship_cmd_addr(GD25Q32C_CMD_DEEP_POWER_DOWN, 0); +} + +void norflash_wakeup(void) { + norflaship_cmd_addr(GD25Q32C_CMD_RELEASE_FROM_DP, 0); + // Wait 20us for flash to finish + norflash_delay(40); +#ifdef FLASH_HPM + if (norflash_op_mode & HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE) { + norflash_set_hpm(1); + } +#endif + norflash_post_operation(); +} + +int norflash_init_status(uint32_t status) { + if (flash_list[flash_idx]->write_status == NULL) { + return -1; + } + + flash_list[flash_idx]->write_status(DRV_NORFLASH_W_STATUS_INIT, status); + + return 0; +} + +int norflash_set_block_protection(uint32_t bp) { + if (flash_list[flash_idx]->write_status == NULL) { + return -1; + } + + flash_list[flash_idx]->write_status(DRV_NORFLASH_W_STATUS_BP, bp); + + return 0; } #ifdef FLASH_SECURITY_REGISTER -int norflash_security_register_lock(uint32_t id) -{ - if (flash_list[flash_idx]->write_status == NULL) { - return -1; - } +int norflash_security_register_lock(uint32_t id) { + if (flash_list[flash_idx]->write_status == NULL) { + return -1; + } - flash_list[flash_idx]->write_status(DRV_NORFLASH_W_STATUS_LB, id); + flash_list[flash_idx]->write_status(DRV_NORFLASH_W_STATUS_LB, id); - return 0; + return 0; } -enum HAL_NORFLASH_RET_T norflash_security_register_erase(uint32_t start_address) -{ - enum HAL_NORFLASH_RET_T ret; +enum HAL_NORFLASH_RET_T +norflash_security_register_erase(uint32_t start_address) { + enum HAL_NORFLASH_RET_T ret; - norflaship_cmd_addr(GD25Q32C_CMD_WRITE_ENABLE, start_address); - // Need 1us. Or norflash_status_WEL_0_wait(), which needs 6us. + norflaship_cmd_addr(GD25Q32C_CMD_WRITE_ENABLE, start_address); + // Need 1us. Or norflash_status_WEL_0_wait(), which needs 6us. - norflaship_cmd_addr(GD25Q32C_CMD_SECURITY_REGISTER_ERASE, start_address); + norflaship_cmd_addr(GD25Q32C_CMD_SECURITY_REGISTER_ERASE, start_address); - ret = norflash_status_WIP_1_wait(0); + ret = norflash_status_WIP_1_wait(0); - norflaship_cmd_done(); + norflaship_cmd_done(); - return ret; + return ret; } -enum HAL_NORFLASH_RET_T norflash_security_register_write(uint32_t start_address, const uint8_t *buffer, uint32_t len) -{ - enum HAL_NORFLASH_RET_T ret; - uint32_t remains; +enum HAL_NORFLASH_RET_T norflash_security_register_write(uint32_t start_address, + const uint8_t *buffer, + uint32_t len) { + enum HAL_NORFLASH_RET_T ret; + uint32_t remains; - // Security register page size might be larger than normal page size - // E.g., the size of P25Q32L and P25Q64L is 1024 + // Security register page size might be larger than normal page size + // E.g., the size of P25Q32L and P25Q64L is 1024 - norflaship_clear_txfifo(); + norflaship_clear_txfifo(); #if (CHIP_FLASH_CTRL_VER <= 1) - uint32_t div = 0; + uint32_t div = 0; - if (len > NORFLASHIP_TXFIFO_SIZE) { - div = norflaship_get_div(); + if (len > NORFLASHIP_TXFIFO_SIZE) { + div = norflaship_get_div(); - // Slow down to avoid tx fifo underflow (it takes about 10 cpu cycles to fill one byte) - norflaship_div(16); - } + // Slow down to avoid tx fifo underflow (it takes about 10 cpu cycles to + // fill one byte) + norflaship_div(16); + } - remains = norflaship_v1_write_txfifo_safe(buffer, len); + remains = norflaship_v1_write_txfifo_safe(buffer, len); #else - norflaship_blksize(len); + norflaship_blksize(len); + remains = norflaship_write_txfifo(buffer, len); +#endif + + norflaship_cmd_addr(GD25Q32C_CMD_WRITE_ENABLE, start_address); + + norflaship_cmd_addr(GD25Q32C_CMD_SECURITY_REGISTER_PROGRAM, start_address); + +#if (CHIP_FLASH_CTRL_VER <= 1) + if (remains) { + norflaship_v1_write_txfifo_all(buffer, len); + } +#else + while (remains > 0) { + buffer += len - remains; + len = remains; remains = norflaship_write_txfifo(buffer, len); + } #endif - norflaship_cmd_addr(GD25Q32C_CMD_WRITE_ENABLE, start_address); + norflaship_busy_wait(); - norflaship_cmd_addr(GD25Q32C_CMD_SECURITY_REGISTER_PROGRAM, start_address); + ret = norflash_status_WIP_1_wait(0); #if (CHIP_FLASH_CTRL_VER <= 1) - if (remains) { - norflaship_v1_write_txfifo_all(buffer, len); - } -#else - while (remains > 0) { - buffer += len - remains; - len = remains; - remains = norflaship_write_txfifo(buffer, len); - } + if (div) { + // Restore the old div + norflaship_div(div); + } #endif - norflaship_busy_wait(); + norflaship_cmd_done(); - ret = norflash_status_WIP_1_wait(0); - -#if (CHIP_FLASH_CTRL_VER <= 1) - if (div) { - // Restore the old div - norflaship_div(div); - } -#endif - - norflaship_cmd_done(); - - return ret; + return ret; } -int norflash_security_register_read(uint32_t start_address, uint8_t *buffer, uint32_t len) -{ - uint32_t index = 0; +int norflash_security_register_read(uint32_t start_address, uint8_t *buffer, + uint32_t len) { + uint32_t index = 0; - if (len > NORFLASHIP_RXFIFO_SIZE) { - return 1; + if (len > NORFLASHIP_RXFIFO_SIZE) { + return 1; + } + + norflaship_clear_rxfifo(); + + norflaship_busy_wait(); + + norflaship_blksize(len); + + norflaship_cmd_addr(GD25Q32C_CMD_SECURITY_REGISTER_READ, start_address); + + while (1) { + norflaship_rxfifo_empty_wait(); + + buffer[index] = norflaship_read_rxfifo(); + + ++index; + if (index >= len) { + break; } + } - norflaship_clear_rxfifo(); + norflaship_cmd_done(); - norflaship_busy_wait(); - - norflaship_blksize(len); - - norflaship_cmd_addr(GD25Q32C_CMD_SECURITY_REGISTER_READ, start_address); - - while (1) { - norflaship_rxfifo_empty_wait(); - - buffer[index] = norflaship_read_rxfifo(); - - ++index; - if (index >= len) { - break; - } - } - - norflaship_cmd_done(); - - return 0; + return 0; } -uint32_t norflash_security_register_enable_read(void) -{ - uint32_t mode; +uint32_t norflash_security_register_enable_read(void) { + uint32_t mode; - mode = norflash_op_mode; + mode = norflash_op_mode; - norflash_set_mode(0); + norflash_set_mode(0); - norflaship_busy_wait(); + norflaship_busy_wait(); #if (CHIP_FLASH_CTRL_VER <= 1) - norflash_read(FLASH_NC_BASE, NULL, 1); + norflash_read(FLASH_NC_BASE, NULL, 1); #endif - norflaship_clear_rxfifo(); - norflaship_busy_wait(); - norflaship_rdcmd(GD25Q32C_CMD_SECURITY_REGISTER_READ); - norflaship_busy_wait(); + norflaship_clear_rxfifo(); + norflaship_busy_wait(); + norflaship_rdcmd(GD25Q32C_CMD_SECURITY_REGISTER_READ); + norflaship_busy_wait(); - return mode; + return mode; } -void norflash_security_register_disable_read(uint32_t mode) -{ - norflaship_busy_wait(); +void norflash_security_register_disable_read(uint32_t mode) { + norflaship_busy_wait(); #if (CHIP_FLASH_CTRL_VER <= 1) - norflash_read(FLASH_NC_BASE, NULL, 1); + norflash_read(FLASH_NC_BASE, NULL, 1); #endif - norflaship_clear_rxfifo(); - norflaship_busy_wait(); - norflaship_rdcmd(GD25Q32C_CMD_STANDARD_READ); - norflaship_busy_wait(); + norflaship_clear_rxfifo(); + norflaship_busy_wait(); + norflaship_rdcmd(GD25Q32C_CMD_STANDARD_READ); + norflaship_busy_wait(); - norflash_set_mode(mode); + norflash_set_mode(mode); } #endif - diff --git a/platform/drivers/norflash/norflash_en25s80b.c b/platform/drivers/norflash/norflash_en25s80b.c index 38453cf..0af0fd9 100644 --- a/platform/drivers/norflash/norflash_en25s80b.c +++ b/platform/drivers/norflash/norflash_en25s80b.c @@ -13,131 +13,132 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" -#include "norflash_drv.h" -#include "hal_norflaship.h" #include "norflash_en25s80b.h" -#include "hal_trace.h" +#include "hal_norflaship.h" #include "hal_timer.h" +#include "hal_trace.h" +#include "norflash_drv.h" +#include "plat_types.h" -static void POSSIBLY_UNUSED en25s80b_en25s80b_reset(void) -{ - // ip quad mode - norflaship_quad_mode(1); - norflaship_busy_wait(); +static void POSSIBLY_UNUSED en25s80b_en25s80b_reset(void) { + // ip quad mode + norflaship_quad_mode(1); + norflaship_busy_wait(); - hal_sys_timer_delay(20); + hal_sys_timer_delay(20); - // quad reset enable - norflaship_clear_txfifo(); - norflaship_cmd_addr(EN25S80B_CMD_QUAD_RESET_ENABLE, 0); - norflaship_busy_wait(); + // quad reset enable + norflaship_clear_txfifo(); + norflaship_cmd_addr(EN25S80B_CMD_QUAD_RESET_ENABLE, 0); + norflaship_busy_wait(); - hal_sys_timer_delay(20); + hal_sys_timer_delay(20); - // quad reset - norflaship_clear_txfifo(); - norflaship_cmd_addr(EN25S80B_CMD_QUAD_RESET, 0); - norflaship_busy_wait(); + // quad reset + norflaship_clear_txfifo(); + norflaship_cmd_addr(EN25S80B_CMD_QUAD_RESET, 0); + norflaship_busy_wait(); - hal_sys_timer_delay(20); + hal_sys_timer_delay(20); - // ip spi mode - norflaship_quad_mode(0); - norflaship_hold_pin(0); - norflaship_wpr_pin(0); - norflaship_busy_wait(); + // ip spi mode + norflaship_quad_mode(0); + norflaship_hold_pin(0); + norflaship_wpr_pin(0); + norflaship_busy_wait(); - hal_sys_timer_delay(20); + hal_sys_timer_delay(20); - // reset enable - norflaship_clear_txfifo(); - norflaship_cmd_addr(EN25S80B_CMD_SPI_RESET_ENABLE, 0); - norflaship_busy_wait(); + // reset enable + norflaship_clear_txfifo(); + norflaship_cmd_addr(EN25S80B_CMD_SPI_RESET_ENABLE, 0); + norflaship_busy_wait(); - hal_sys_timer_delay(20); + hal_sys_timer_delay(20); - // reset - norflaship_clear_txfifo(); - norflaship_cmd_addr(EN25S80B_CMD_SPI_RESET, 0); - norflaship_busy_wait(); + // reset + norflaship_clear_txfifo(); + norflaship_cmd_addr(EN25S80B_CMD_SPI_RESET, 0); + norflaship_busy_wait(); - hal_sys_timer_delay(20); + hal_sys_timer_delay(20); } -static void en25s80b_enter_OTP(void) -{ - norflaship_clear_txfifo(); - norflaship_cmd_addr(EN25S80B_CMD_ENTER_OTP, 0); - norflash_status_WIP_1_wait(0); +static void en25s80b_enter_OTP(void) { + norflaship_clear_txfifo(); + norflaship_cmd_addr(EN25S80B_CMD_ENTER_OTP, 0); + norflash_status_WIP_1_wait(0); } -static void en25s80b_exit_OTP(void) -{ - norflaship_clear_txfifo(); - norflaship_cmd_addr(EN25S80B_CMD_EXIT_OTP, 0); - norflash_status_WIP_1_wait(0); +static void en25s80b_exit_OTP(void) { + norflaship_clear_txfifo(); + norflaship_cmd_addr(EN25S80B_CMD_EXIT_OTP, 0); + norflash_status_WIP_1_wait(0); } -static void en25s80b_write_status_s0_s7(uint8_t status) -{ - norflash_write_reg(EN25S80B_CMD_WRITE_STATUS, &status, 1); +static void en25s80b_write_status_s0_s7(uint8_t status) { + norflash_write_reg(EN25S80B_CMD_WRITE_STATUS, &status, 1); } -static int en25s80b_write_status(enum DRV_NORFLASH_W_STATUS_T type, uint32_t param) -{ - uint8_t status; +static int en25s80b_write_status(enum DRV_NORFLASH_W_STATUS_T type, + uint32_t param) { + uint8_t status; - if (type == DRV_NORFLASH_W_STATUS_QE) { - en25s80b_enter_OTP(); + if (type == DRV_NORFLASH_W_STATUS_QE) { + en25s80b_enter_OTP(); - status = norflash_read_status_s0_s7(); + status = norflash_read_status_s0_s7(); - if (param) { - status |= (EN25S80B_WHDIS_BIT_MASK); - } else { - status &= ~(EN25S80B_WHDIS_BIT_MASK); - } - - en25s80b_write_status_s0_s7(status); - - en25s80b_exit_OTP(); - - return 0; + if (param) { + status |= (EN25S80B_WHDIS_BIT_MASK); + } else { + status &= ~(EN25S80B_WHDIS_BIT_MASK); } - return 1; + en25s80b_write_status_s0_s7(status); + + en25s80b_exit_OTP(); + + return 0; + } + + return 1; } const struct NORFLASH_CFG_T en25s80b_cfg = { - .id = { 0x1C, 0x38, 0x14, }, - .speed_ratio = { - .s = { - .std_read = SPEED_RATIO_6_EIGHTH, - .others = SPEED_RATIO_6_EIGHTH, + .id = + { + 0x1C, + 0x38, + 0x14, + }, + .speed_ratio = + { + .s = + { + .std_read = SPEED_RATIO_6_EIGHTH, + .others = SPEED_RATIO_6_EIGHTH, + }, }, - }, .crm_en_bits = 0xA5, .crm_dis_bits = 0xAA, - .sec_reg_cfg = { - .s = { - .enabled = false, + .sec_reg_cfg = + { + .s = + { + .enabled = false, + }, }, - }, .page_size = EN25S80B_PAGE_SIZE, .sector_size = EN25S80B_SECTOR_SIZE, .block_size = EN25S80B_BLOCK_SIZE, .total_size = EN25S80B_TOTAL_SIZE, .max_speed = 104 * 1000 * 1000, - .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_DUAL_IO | - HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | - HAL_NORFLASH_OP_MODE_QUAD_IO | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_ERASE_IN_STD), + .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_DUAL_IO | + HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO | + HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_ERASE_IN_STD), .write_status = en25s80b_write_status, }; - diff --git a/platform/drivers/norflash/norflash_gd25lq32c.c b/platform/drivers/norflash/norflash_gd25lq32c.c index 59e088a..869f0d5 100644 --- a/platform/drivers/norflash/norflash_gd25lq32c.c +++ b/platform/drivers/norflash/norflash_gd25lq32c.c @@ -13,83 +13,83 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" -#include "norflash_drv.h" +#include "norflash_gd25lq32c.h" #include "hal_norflaship.h" #include "hal_timer.h" #include "hal_trace.h" #include "norflash_cfg.h" -#include "norflash_gd25lq32c.h" +#include "norflash_drv.h" +#include "plat_types.h" -static void gd25lq32c_write_status_s0_s15(uint16_t status, uint8_t len) -{ - norflash_write_reg(GD25LQ32C_CMD_WRITE_STATUS, (uint8_t *)&status, len); +static void gd25lq32c_write_status_s0_s15(uint16_t status, uint8_t len) { + norflash_write_reg(GD25LQ32C_CMD_WRITE_STATUS, (uint8_t *)&status, len); } -static int gd25lq32c_write_status(enum DRV_NORFLASH_W_STATUS_T type, uint32_t param) -{ - uint8_t status_s0_s7; - uint8_t status_s8_s15; - uint32_t bp_mask = 0; - union DRV_NORFLASH_SEC_REG_CFG_T cfg; - bool has_quad; +static int gd25lq32c_write_status(enum DRV_NORFLASH_W_STATUS_T type, + uint32_t param) { + uint8_t status_s0_s7; + uint8_t status_s8_s15; + uint32_t bp_mask = 0; + union DRV_NORFLASH_SEC_REG_CFG_T cfg; + bool has_quad; - if (type != DRV_NORFLASH_W_STATUS_INIT && type != DRV_NORFLASH_W_STATUS_QE && - type != DRV_NORFLASH_W_STATUS_LB && type != DRV_NORFLASH_W_STATUS_BP) { - return 1; - } + if (type != DRV_NORFLASH_W_STATUS_INIT && type != DRV_NORFLASH_W_STATUS_QE && + type != DRV_NORFLASH_W_STATUS_LB && type != DRV_NORFLASH_W_STATUS_BP) { + return 1; + } - has_quad = !!(norflash_get_supported_mode() & - (HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO)); - - if (type == DRV_NORFLASH_W_STATUS_INIT) { - gd25lq32c_write_status_s0_s15(param, (has_quad ? 2 : 1)); - return 0; - } - - status_s0_s7 = norflash_read_status_s0_s7(); - - if (type == DRV_NORFLASH_W_STATUS_BP) { - bp_mask = norflash_get_block_protect_mask(); - status_s0_s7 = (status_s0_s7 & ~bp_mask) | (param & bp_mask); - } - - if (has_quad) { - status_s8_s15 = norflash_read_status_s8_s15(); - - if (type == DRV_NORFLASH_W_STATUS_QE) { - if (param) { - status_s8_s15 |= GD25LQ32C_QE_BIT_MASK; - } else { - status_s8_s15 &= ~(GD25LQ32C_QE_BIT_MASK); - } - } else if (type == DRV_NORFLASH_W_STATUS_BP) { - param >>= 8; - bp_mask >>= 8; - status_s8_s15 = (status_s8_s15 & ~bp_mask) | (param & bp_mask); - } else if (type == DRV_NORFLASH_W_STATUS_LB) { - cfg = norflash_get_security_register_config(); - if (!cfg.s.enabled) { - return 2; - } - if (cfg.s.lb == SEC_REG_LB_S11_S13) { - if (param >= 3) { - return 3; - } - status_s8_s15 |= (STATUS_S11_LB1_BIT_MASK << param); - } else if (cfg.s.lb == SEC_REG_LB_S10) { - status_s8_s15 |= STATUS_S10_LB_BIT_MASK; - } else { - return 4; - } - } - - gd25lq32c_write_status_s0_s15(status_s0_s7 | (status_s8_s15 << 8), 2); - } else { - gd25lq32c_write_status_s0_s15(status_s0_s7, 1); - } + has_quad = + !!(norflash_get_supported_mode() & + (HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO)); + if (type == DRV_NORFLASH_W_STATUS_INIT) { + gd25lq32c_write_status_s0_s15(param, (has_quad ? 2 : 1)); return 0; + } + + status_s0_s7 = norflash_read_status_s0_s7(); + + if (type == DRV_NORFLASH_W_STATUS_BP) { + bp_mask = norflash_get_block_protect_mask(); + status_s0_s7 = (status_s0_s7 & ~bp_mask) | (param & bp_mask); + } + + if (has_quad) { + status_s8_s15 = norflash_read_status_s8_s15(); + + if (type == DRV_NORFLASH_W_STATUS_QE) { + if (param) { + status_s8_s15 |= GD25LQ32C_QE_BIT_MASK; + } else { + status_s8_s15 &= ~(GD25LQ32C_QE_BIT_MASK); + } + } else if (type == DRV_NORFLASH_W_STATUS_BP) { + param >>= 8; + bp_mask >>= 8; + status_s8_s15 = (status_s8_s15 & ~bp_mask) | (param & bp_mask); + } else if (type == DRV_NORFLASH_W_STATUS_LB) { + cfg = norflash_get_security_register_config(); + if (!cfg.s.enabled) { + return 2; + } + if (cfg.s.lb == SEC_REG_LB_S11_S13) { + if (param >= 3) { + return 3; + } + status_s8_s15 |= (STATUS_S11_LB1_BIT_MASK << param); + } else if (cfg.s.lb == SEC_REG_LB_S10) { + status_s8_s15 |= STATUS_S10_LB_BIT_MASK; + } else { + return 4; + } + } + + gd25lq32c_write_status_s0_s15(status_s0_s7 | (status_s8_s15 << 8), 2); + } else { + gd25lq32c_write_status_s0_s15(status_s0_s7, 1); + } + + return 0; } // ---------------------- @@ -97,191 +97,220 @@ static int gd25lq32c_write_status(enum DRV_NORFLASH_W_STATUS_T type, uint32_t pa // ---------------------- const struct NORFLASH_CFG_T gd25lq64c_cfg = { - .id = { 0xC8, 0x60, 0x17, }, - .speed_ratio = { - .s = { - .std_read = SPEED_RATIO_6_EIGHTH, - .others = SPEED_RATIO_8_EIGHTH, + .id = + { + 0xC8, + 0x60, + 0x17, + }, + .speed_ratio = + { + .s = + { + .std_read = SPEED_RATIO_6_EIGHTH, + .others = SPEED_RATIO_8_EIGHTH, + }, }, - }, .crm_en_bits = (1 << 5) | (0 << 4), .crm_dis_bits = 0, .block_protect_mask = 0x407C, - .sec_reg_cfg = { - .s = { - .enabled = true, - .base = SEC_REG_BASE_0X1000, - .size = SEC_REG_SIZE_1024, - .offset = SEC_REG_OFFSET_0X1000, - .cnt = SEC_REG_CNT_3, - .pp = SEC_REG_PP_256, - .lb = SEC_REG_LB_S11_S13, + .sec_reg_cfg = + { + .s = + { + .enabled = true, + .base = SEC_REG_BASE_0X1000, + .size = SEC_REG_SIZE_1024, + .offset = SEC_REG_OFFSET_0X1000, + .cnt = SEC_REG_CNT_3, + .pp = SEC_REG_PP_256, + .lb = SEC_REG_LB_S11_S13, + }, }, - }, .page_size = GD25LQ32C_PAGE_SIZE, .sector_size = GD25LQ32C_SECTOR_SIZE, .block_size = GD25LQ32C_BLOCK_SIZE, .total_size = GD25LQ64C_TOTAL_SIZE, .max_speed = 104 * 1000 * 1000, - .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_DUAL_IO | - HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | - HAL_NORFLASH_OP_MODE_QUAD_IO | - HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | - HAL_NORFLASH_OP_MODE_READ_WRAP | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_SUSPEND), + .mode = + (HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_DUAL_IO | + HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO | + HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | HAL_NORFLASH_OP_MODE_READ_WRAP | + HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | HAL_NORFLASH_OP_MODE_SUSPEND), .write_status = gd25lq32c_write_status, }; const struct NORFLASH_CFG_T gd25lq32c_cfg = { - .id = { 0xC8, 0x60, 0x16, }, - .speed_ratio = { - .s = { - .std_read = SPEED_RATIO_5_EIGHTH, - .others = SPEED_RATIO_8_EIGHTH, + .id = + { + 0xC8, + 0x60, + 0x16, + }, + .speed_ratio = + { + .s = + { + .std_read = SPEED_RATIO_5_EIGHTH, + .others = SPEED_RATIO_8_EIGHTH, + }, }, - }, .crm_en_bits = (1 << 5) | (0 << 4), .crm_dis_bits = 0, .block_protect_mask = 0x407C, - .sec_reg_cfg = { - .s = { - .enabled = true, - .base = SEC_REG_BASE_0X1000, - .size = SEC_REG_SIZE_1024, - .offset = SEC_REG_OFFSET_0X1000, - .cnt = SEC_REG_CNT_3, - .pp = SEC_REG_PP_256, - .lb = SEC_REG_LB_S11_S13, + .sec_reg_cfg = + { + .s = + { + .enabled = true, + .base = SEC_REG_BASE_0X1000, + .size = SEC_REG_SIZE_1024, + .offset = SEC_REG_OFFSET_0X1000, + .cnt = SEC_REG_CNT_3, + .pp = SEC_REG_PP_256, + .lb = SEC_REG_LB_S11_S13, + }, }, - }, .page_size = GD25LQ32C_PAGE_SIZE, .sector_size = GD25LQ32C_SECTOR_SIZE, .block_size = GD25LQ32C_BLOCK_SIZE, .total_size = GD25LQ32C_TOTAL_SIZE, .max_speed = 120 * 1000 * 1000, - .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_DUAL_IO | - HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | - HAL_NORFLASH_OP_MODE_QUAD_IO | - HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | - HAL_NORFLASH_OP_MODE_READ_WRAP | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_SUSPEND), + .mode = + (HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_DUAL_IO | + HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO | + HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | HAL_NORFLASH_OP_MODE_READ_WRAP | + HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | HAL_NORFLASH_OP_MODE_SUSPEND), .write_status = gd25lq32c_write_status, }; const struct NORFLASH_CFG_T gd25lq16c_cfg = { - .id = { 0xC8, 0x60, 0x15, }, - .speed_ratio = { - .s = { - .std_read = SPEED_RATIO_6_EIGHTH, - .others = SPEED_RATIO_8_EIGHTH, + .id = + { + 0xC8, + 0x60, + 0x15, + }, + .speed_ratio = + { + .s = + { + .std_read = SPEED_RATIO_6_EIGHTH, + .others = SPEED_RATIO_8_EIGHTH, + }, }, - }, .crm_en_bits = (1 << 5) | (0 << 4), .crm_dis_bits = 0, .block_protect_mask = 0x407C, - .sec_reg_cfg = { - .s = { - .enabled = true, - .base = SEC_REG_BASE_0X1000, - .size = SEC_REG_SIZE_512, - .offset = SEC_REG_OFFSET_0X1000, - .cnt = SEC_REG_CNT_3, - .pp = SEC_REG_PP_256, - .lb = SEC_REG_LB_S11_S13, + .sec_reg_cfg = + { + .s = + { + .enabled = true, + .base = SEC_REG_BASE_0X1000, + .size = SEC_REG_SIZE_512, + .offset = SEC_REG_OFFSET_0X1000, + .cnt = SEC_REG_CNT_3, + .pp = SEC_REG_PP_256, + .lb = SEC_REG_LB_S11_S13, + }, }, - }, .page_size = GD25LQ32C_PAGE_SIZE, .sector_size = GD25LQ32C_SECTOR_SIZE, .block_size = GD25LQ32C_BLOCK_SIZE, .total_size = GD25LQ16C_TOTAL_SIZE, .max_speed = 104 * 1000 * 1000, - .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_DUAL_IO | - HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | - HAL_NORFLASH_OP_MODE_QUAD_IO | - HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | - HAL_NORFLASH_OP_MODE_READ_WRAP | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_SUSPEND), + .mode = + (HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_DUAL_IO | + HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO | + HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | HAL_NORFLASH_OP_MODE_READ_WRAP | + HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | HAL_NORFLASH_OP_MODE_SUSPEND), .write_status = gd25lq32c_write_status, }; const struct NORFLASH_CFG_T gd25lq80c_cfg = { - .id = { 0xC8, 0x60, 0x14, }, - .speed_ratio = { - .s = { - .std_read = SPEED_RATIO_6_EIGHTH, - .others = SPEED_RATIO_6_EIGHTH, + .id = + { + 0xC8, + 0x60, + 0x14, + }, + .speed_ratio = + { + .s = + { + .std_read = SPEED_RATIO_6_EIGHTH, + .others = SPEED_RATIO_6_EIGHTH, + }, }, - }, .crm_en_bits = (1 << 5) | (0 << 4), .crm_dis_bits = 0, .block_protect_mask = 0x407C, - .sec_reg_cfg = { - .s = { - .enabled = true, - .base = SEC_REG_BASE_0X1000, - .size = SEC_REG_SIZE_512, - .offset = SEC_REG_OFFSET_0X1000, - .cnt = SEC_REG_CNT_3, - .pp = SEC_REG_PP_256, - .lb = SEC_REG_LB_S11_S13, + .sec_reg_cfg = + { + .s = + { + .enabled = true, + .base = SEC_REG_BASE_0X1000, + .size = SEC_REG_SIZE_512, + .offset = SEC_REG_OFFSET_0X1000, + .cnt = SEC_REG_CNT_3, + .pp = SEC_REG_PP_256, + .lb = SEC_REG_LB_S11_S13, + }, }, - }, .page_size = GD25LQ32C_PAGE_SIZE, .sector_size = GD25LQ32C_SECTOR_SIZE, .block_size = GD25LQ32C_BLOCK_SIZE, .total_size = GD25LQ80C_TOTAL_SIZE, .max_speed = 104 * 1000 * 1000, - .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_DUAL_IO | - HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | - HAL_NORFLASH_OP_MODE_QUAD_IO | - HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | - HAL_NORFLASH_OP_MODE_READ_WRAP | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_SUSPEND), + .mode = + (HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_DUAL_IO | + HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO | + HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | HAL_NORFLASH_OP_MODE_READ_WRAP | + HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | HAL_NORFLASH_OP_MODE_SUSPEND), .write_status = gd25lq32c_write_status, }; const struct NORFLASH_CFG_T gd25q80c_cfg = { - .id = { 0xC8, 0x40, 0x14, }, - .speed_ratio = { - .s = { - .std_read = SPEED_RATIO_5_EIGHTH, - .others = SPEED_RATIO_5_EIGHTH, + .id = + { + 0xC8, + 0x40, + 0x14, + }, + .speed_ratio = + { + .s = + { + .std_read = SPEED_RATIO_5_EIGHTH, + .others = SPEED_RATIO_5_EIGHTH, + }, }, - }, .crm_en_bits = 0xA0, .crm_dis_bits = 0, .block_protect_mask = 0x407C, - .sec_reg_cfg = { - .s = { - .enabled = true, - .base = SEC_REG_BASE_0X0000, - .size = SEC_REG_SIZE_256, - .offset = SEC_REG_OFFSET_0X0100, - .cnt = SEC_REG_CNT_4, - .pp = SEC_REG_PP_256, - .lb = SEC_REG_LB_S10, + .sec_reg_cfg = + { + .s = + { + .enabled = true, + .base = SEC_REG_BASE_0X0000, + .size = SEC_REG_SIZE_256, + .offset = SEC_REG_OFFSET_0X0100, + .cnt = SEC_REG_CNT_4, + .pp = SEC_REG_PP_256, + .lb = SEC_REG_LB_S10, + }, }, - }, .page_size = GD25LQ32C_PAGE_SIZE, .sector_size = GD25LQ32C_SECTOR_SIZE, .block_size = GD25LQ32C_BLOCK_SIZE, @@ -291,76 +320,88 @@ const struct NORFLASH_CFG_T gd25q80c_cfg = { #else .max_speed = 104 * 1000 * 1000, #endif - .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_DUAL_IO | - HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | - HAL_NORFLASH_OP_MODE_QUAD_IO | + .mode = + (HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_DUAL_IO | + HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO | #ifdef FLASH_HPM - HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE | + HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE | #endif - HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | - HAL_NORFLASH_OP_MODE_READ_WRAP | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_SUSPEND), + HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | HAL_NORFLASH_OP_MODE_READ_WRAP | + HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | HAL_NORFLASH_OP_MODE_SUSPEND), .write_status = gd25lq32c_write_status, }; const struct NORFLASH_CFG_T gd25d40c_cfg = { - .id = { 0xC8, 0x40, 0x13, }, - .speed_ratio = { - .s = { - .std_read = SPEED_RATIO_6_EIGHTH, - .others = SPEED_RATIO_6_EIGHTH, + .id = + { + 0xC8, + 0x40, + 0x13, + }, + .speed_ratio = + { + .s = + { + .std_read = SPEED_RATIO_6_EIGHTH, + .others = SPEED_RATIO_6_EIGHTH, + }, }, - }, .crm_en_bits = 0, .crm_dis_bits = 0, .block_protect_mask = 0x1C, - .sec_reg_cfg = { - .s = { - .enabled = false, + .sec_reg_cfg = + { + .s = + { + .enabled = false, + }, }, - }, .page_size = GD25LQ32C_PAGE_SIZE, .sector_size = GD25LQ32C_SECTOR_SIZE, .block_size = GD25LQ32C_BLOCK_SIZE, .total_size = GD25D40C_TOTAL_SIZE, .max_speed = 80 * 1000 * 1000, - .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM), + .mode = + (HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_PAGE_PROGRAM), .write_status = gd25lq32c_write_status, }; const struct NORFLASH_CFG_T gd25d20c_cfg = { - .id = { 0xC8, 0x40, 0x12, }, - .speed_ratio = { - .s = { - .std_read = SPEED_RATIO_6_EIGHTH, - .others = SPEED_RATIO_6_EIGHTH, + .id = + { + 0xC8, + 0x40, + 0x12, + }, + .speed_ratio = + { + .s = + { + .std_read = SPEED_RATIO_6_EIGHTH, + .others = SPEED_RATIO_6_EIGHTH, + }, }, - }, .crm_en_bits = 0, .crm_dis_bits = 0, .block_protect_mask = 0x1C, - .sec_reg_cfg = { - .s = { - .enabled = false, + .sec_reg_cfg = + { + .s = + { + .enabled = false, + }, }, - }, .page_size = GD25LQ32C_PAGE_SIZE, .sector_size = GD25LQ32C_SECTOR_SIZE, .block_size = GD25LQ32C_BLOCK_SIZE, .total_size = GD25D20C_TOTAL_SIZE, .max_speed = 80 * 1000 * 1000, - .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM), + .mode = + (HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_PAGE_PROGRAM), .write_status = gd25lq32c_write_status, }; @@ -369,171 +410,194 @@ const struct NORFLASH_CFG_T gd25d20c_cfg = { // ---------------------- const struct NORFLASH_CFG_T p25q16l_cfg = { - .id = { 0x85, 0x60, 0x15, }, - .speed_ratio = { - .s = { - .std_read = SPEED_RATIO_3_EIGHTH, - .others = SPEED_RATIO_8_EIGHTH, + .id = + { + 0x85, + 0x60, + 0x15, + }, + .speed_ratio = + { + .s = + { + .std_read = SPEED_RATIO_3_EIGHTH, + .others = SPEED_RATIO_8_EIGHTH, + }, }, - }, .crm_en_bits = (1 << 5) | (0 << 4), .crm_dis_bits = 0, .block_protect_mask = 0x407C, - .sec_reg_cfg = { - .s = { - .enabled = true, - .base = SEC_REG_BASE_0X1000, - .size = SEC_REG_SIZE_512, - .offset = SEC_REG_OFFSET_0X1000, - .cnt = SEC_REG_CNT_3, - .pp = SEC_REG_PP_256, - .lb = SEC_REG_LB_S11_S13, + .sec_reg_cfg = + { + .s = + { + .enabled = true, + .base = SEC_REG_BASE_0X1000, + .size = SEC_REG_SIZE_512, + .offset = SEC_REG_OFFSET_0X1000, + .cnt = SEC_REG_CNT_3, + .pp = SEC_REG_PP_256, + .lb = SEC_REG_LB_S11_S13, + }, }, - }, .page_size = GD25LQ32C_PAGE_SIZE, .sector_size = GD25LQ32C_SECTOR_SIZE, .block_size = GD25LQ32C_BLOCK_SIZE, .total_size = P25Q16L_TOTAL_SIZE, - .max_speed = 70 * 1000 * 1000, // P25Q80L=70M, P25Q80H=104M, P25Q80U=70M/104M - .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_DUAL_IO | - HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | - HAL_NORFLASH_OP_MODE_QUAD_IO | - HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | - HAL_NORFLASH_OP_MODE_READ_WRAP | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_DUAL_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_SUSPEND), + .max_speed = + 70 * 1000 * 1000, // P25Q80L=70M, P25Q80H=104M, P25Q80U=70M/104M + .mode = + (HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_DUAL_IO | + HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO | + HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | HAL_NORFLASH_OP_MODE_READ_WRAP | + HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_DUAL_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | HAL_NORFLASH_OP_MODE_SUSPEND), .write_status = gd25lq32c_write_status, }; const struct NORFLASH_CFG_T p25q80h_cfg = { - .id = { 0x85, 0x60, 0x14, }, - .speed_ratio = { - .s = { - .std_read = SPEED_RATIO_3_EIGHTH, - .others = SPEED_RATIO_8_EIGHTH, + .id = + { + 0x85, + 0x60, + 0x14, + }, + .speed_ratio = + { + .s = + { + .std_read = SPEED_RATIO_3_EIGHTH, + .others = SPEED_RATIO_8_EIGHTH, + }, }, - }, .crm_en_bits = (1 << 5) | (0 << 4), .crm_dis_bits = 0, .block_protect_mask = 0x407C, - .sec_reg_cfg = { - .s = { - .enabled = true, - .base = SEC_REG_BASE_0X1000, - .size = SEC_REG_SIZE_512, - .offset = SEC_REG_OFFSET_0X1000, - .cnt = SEC_REG_CNT_3, - .pp = SEC_REG_PP_256, - .lb = SEC_REG_LB_S11_S13, + .sec_reg_cfg = + { + .s = + { + .enabled = true, + .base = SEC_REG_BASE_0X1000, + .size = SEC_REG_SIZE_512, + .offset = SEC_REG_OFFSET_0X1000, + .cnt = SEC_REG_CNT_3, + .pp = SEC_REG_PP_256, + .lb = SEC_REG_LB_S11_S13, + }, }, - }, .page_size = GD25LQ32C_PAGE_SIZE, .sector_size = GD25LQ32C_SECTOR_SIZE, .block_size = GD25LQ32C_BLOCK_SIZE, .total_size = P25Q80H_TOTAL_SIZE, - .max_speed = 70 * 1000 * 1000, // P25Q80L=70M, P25Q80H=104M, P25Q80U=70M/104M - .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_DUAL_IO | - HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | - HAL_NORFLASH_OP_MODE_QUAD_IO | - HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | - HAL_NORFLASH_OP_MODE_READ_WRAP | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_DUAL_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_SUSPEND), + .max_speed = + 70 * 1000 * 1000, // P25Q80L=70M, P25Q80H=104M, P25Q80U=70M/104M + .mode = + (HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_DUAL_IO | + HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO | + HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | HAL_NORFLASH_OP_MODE_READ_WRAP | + HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_DUAL_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | HAL_NORFLASH_OP_MODE_SUSPEND), .write_status = gd25lq32c_write_status, }; const struct NORFLASH_CFG_T p25q40h_cfg = { - .id = { 0x85, 0x60, 0x13, }, - .speed_ratio = { - .s = { - .std_read = SPEED_RATIO_3_EIGHTH, - .others = SPEED_RATIO_8_EIGHTH, + .id = + { + 0x85, + 0x60, + 0x13, + }, + .speed_ratio = + { + .s = + { + .std_read = SPEED_RATIO_3_EIGHTH, + .others = SPEED_RATIO_8_EIGHTH, + }, }, - }, .crm_en_bits = (1 << 5) | (0 << 4), .crm_dis_bits = 0, .block_protect_mask = 0x407C, - .sec_reg_cfg = { - .s = { - .enabled = true, - .base = SEC_REG_BASE_0X1000, - .size = SEC_REG_SIZE_512, - .offset = SEC_REG_OFFSET_0X1000, - .cnt = SEC_REG_CNT_3, - .pp = SEC_REG_PP_256, - .lb = SEC_REG_LB_S11_S13, + .sec_reg_cfg = + { + .s = + { + .enabled = true, + .base = SEC_REG_BASE_0X1000, + .size = SEC_REG_SIZE_512, + .offset = SEC_REG_OFFSET_0X1000, + .cnt = SEC_REG_CNT_3, + .pp = SEC_REG_PP_256, + .lb = SEC_REG_LB_S11_S13, + }, }, - }, .page_size = GD25LQ32C_PAGE_SIZE, .sector_size = GD25LQ32C_SECTOR_SIZE, .block_size = GD25LQ32C_BLOCK_SIZE, .total_size = P25Q40H_TOTAL_SIZE, - .max_speed = 70 * 1000 * 1000, // P25Q21L=70M, P25Q21H=104M, P25Q21U=70M/104M - .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_DUAL_IO | - HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | - HAL_NORFLASH_OP_MODE_QUAD_IO | - HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | - HAL_NORFLASH_OP_MODE_READ_WRAP | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_DUAL_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_SUSPEND), + .max_speed = + 70 * 1000 * 1000, // P25Q21L=70M, P25Q21H=104M, P25Q21U=70M/104M + .mode = + (HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_DUAL_IO | + HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO | + HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | HAL_NORFLASH_OP_MODE_READ_WRAP | + HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_DUAL_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | HAL_NORFLASH_OP_MODE_SUSPEND), .write_status = gd25lq32c_write_status, }; - const struct NORFLASH_CFG_T p25q21h_cfg = { - .id = { 0x85, 0x40, 0x12, }, - .speed_ratio = { - .s = { - .std_read = SPEED_RATIO_3_EIGHTH, - .others = SPEED_RATIO_8_EIGHTH, + .id = + { + 0x85, + 0x40, + 0x12, + }, + .speed_ratio = + { + .s = + { + .std_read = SPEED_RATIO_3_EIGHTH, + .others = SPEED_RATIO_8_EIGHTH, + }, }, - }, .crm_en_bits = (1 << 5) | (0 << 4), .crm_dis_bits = 0, .block_protect_mask = 0x407C, - .sec_reg_cfg = { - .s = { - .enabled = true, - .base = SEC_REG_BASE_0X1000, - .size = SEC_REG_SIZE_512, - .offset = SEC_REG_OFFSET_0X1000, - .cnt = SEC_REG_CNT_3, - .pp = SEC_REG_PP_256, - .lb = SEC_REG_LB_S11_S13, + .sec_reg_cfg = + { + .s = + { + .enabled = true, + .base = SEC_REG_BASE_0X1000, + .size = SEC_REG_SIZE_512, + .offset = SEC_REG_OFFSET_0X1000, + .cnt = SEC_REG_CNT_3, + .pp = SEC_REG_PP_256, + .lb = SEC_REG_LB_S11_S13, + }, }, - }, .page_size = GD25LQ32C_PAGE_SIZE, .sector_size = GD25LQ32C_SECTOR_SIZE, .block_size = GD25LQ32C_BLOCK_SIZE, .total_size = P25Q21H_TOTAL_SIZE, - .max_speed = 70 * 1000 * 1000, // P25Q21L=70M, P25Q21H=104M, P25Q21U=70M/104M - .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_DUAL_IO | - HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | - HAL_NORFLASH_OP_MODE_QUAD_IO | - HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | - HAL_NORFLASH_OP_MODE_READ_WRAP | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_DUAL_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_SUSPEND), + .max_speed = + 70 * 1000 * 1000, // P25Q21L=70M, P25Q21H=104M, P25Q21U=70M/104M + .mode = + (HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_DUAL_IO | + HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO | + HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | HAL_NORFLASH_OP_MODE_READ_WRAP | + HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_DUAL_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | HAL_NORFLASH_OP_MODE_SUSPEND), .write_status = gd25lq32c_write_status, }; @@ -542,42 +606,47 @@ const struct NORFLASH_CFG_T p25q21h_cfg = { // ---------------------- const struct NORFLASH_CFG_T xt25q08b_cfg = { - .id = { 0x0B, 0x60, 0x14, }, - .speed_ratio = { - .s = { - .std_read = SPEED_RATIO_7_EIGHTH, - .others = SPEED_RATIO_7_EIGHTH, + .id = + { + 0x0B, + 0x60, + 0x14, + }, + .speed_ratio = + { + .s = + { + .std_read = SPEED_RATIO_7_EIGHTH, + .others = SPEED_RATIO_7_EIGHTH, + }, }, - }, .crm_en_bits = (1 << 5) | (0 << 4), .crm_dis_bits = 0, .block_protect_mask = 0x403C, - .sec_reg_cfg = { - .s = { - .enabled = true, - .base = SEC_REG_BASE_0X0000, - .size = SEC_REG_SIZE_256, - .offset = SEC_REG_OFFSET_0X0100, - .cnt = SEC_REG_CNT_4, - .pp = SEC_REG_PP_256, - .lb = SEC_REG_LB_S10, + .sec_reg_cfg = + { + .s = + { + .enabled = true, + .base = SEC_REG_BASE_0X0000, + .size = SEC_REG_SIZE_256, + .offset = SEC_REG_OFFSET_0X0100, + .cnt = SEC_REG_CNT_4, + .pp = SEC_REG_PP_256, + .lb = SEC_REG_LB_S10, + }, }, - }, .page_size = GD25LQ32C_PAGE_SIZE, .sector_size = GD25LQ32C_SECTOR_SIZE, .block_size = GD25LQ32C_BLOCK_SIZE, .total_size = XT25Q08B_TOTAL_SIZE, .max_speed = 96 * 1000 * 1000, - .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_DUAL_IO | - HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | - HAL_NORFLASH_OP_MODE_QUAD_IO | - HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_SUSPEND), + .mode = + (HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_DUAL_IO | + HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO | + HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | + HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | HAL_NORFLASH_OP_MODE_SUSPEND), .write_status = gd25lq32c_write_status, }; - diff --git a/platform/drivers/norflash/norflash_gd25q32c.c b/platform/drivers/norflash/norflash_gd25q32c.c index 70d7bc4..789f4fa 100644 --- a/platform/drivers/norflash/norflash_gd25q32c.c +++ b/platform/drivers/norflash/norflash_gd25q32c.c @@ -13,84 +13,82 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" -#include "norflash_drv.h" +#include "norflash_gd25q32c.h" #include "hal_norflaship.h" #include "hal_timer.h" #include "hal_trace.h" #include "norflash_cfg.h" -#include "norflash_gd25q32c.h" +#include "norflash_drv.h" +#include "plat_types.h" -static void gd25q32c_write_status_s8_s15(uint8_t status) -{ - norflash_write_reg(GD25Q32C_CMD_WRITE_STATUS_S8_S15, &status, 1); +static void gd25q32c_write_status_s8_s15(uint8_t status) { + norflash_write_reg(GD25Q32C_CMD_WRITE_STATUS_S8_S15, &status, 1); } -static void gd25q32c_write_status_s0_s7(uint8_t status) -{ - norflash_write_reg(GD25Q32C_CMD_WRITE_STATUS_S0_S7, &status, 1); +static void gd25q32c_write_status_s0_s7(uint8_t status) { + norflash_write_reg(GD25Q32C_CMD_WRITE_STATUS_S0_S7, &status, 1); } -static int gd25q32c_write_status(enum DRV_NORFLASH_W_STATUS_T type, uint32_t param) -{ - uint8_t status_s0_s7; - uint8_t status_s8_s15; - uint32_t bp_mask = 0; - union DRV_NORFLASH_SEC_REG_CFG_T cfg; +static int gd25q32c_write_status(enum DRV_NORFLASH_W_STATUS_T type, + uint32_t param) { + uint8_t status_s0_s7; + uint8_t status_s8_s15; + uint32_t bp_mask = 0; + union DRV_NORFLASH_SEC_REG_CFG_T cfg; - if (type != DRV_NORFLASH_W_STATUS_INIT && type != DRV_NORFLASH_W_STATUS_QE && - type != DRV_NORFLASH_W_STATUS_LB && type != DRV_NORFLASH_W_STATUS_BP) { - return 1; - } - - if (type == DRV_NORFLASH_W_STATUS_INIT) { - gd25q32c_write_status_s0_s7(param & 0xFF); - gd25q32c_write_status_s8_s15((param >> 8) & 0xFF); - return 0; - } - - if (type == DRV_NORFLASH_W_STATUS_BP) { - bp_mask = norflash_get_block_protect_mask(); - status_s0_s7 = norflash_read_status_s0_s7(); - status_s0_s7 = (status_s0_s7 & ~bp_mask) | (param & bp_mask); - gd25q32c_write_status_s0_s7(status_s0_s7); - if ((bp_mask & ~0xFF) == 0) { - return 0; - } - } - - status_s8_s15 = norflash_read_status_s8_s15(); - - if (type == DRV_NORFLASH_W_STATUS_QE) { - if (param) { - status_s8_s15 |= GD25Q32C_QE_BIT_MASK; - } else { - status_s8_s15 &= ~(GD25Q32C_QE_BIT_MASK); - } - } else if (type == DRV_NORFLASH_W_STATUS_BP) { - param >>= 8; - bp_mask >>= 8; - status_s8_s15 = (status_s8_s15 & ~bp_mask) | (param & bp_mask); - } else if (type == DRV_NORFLASH_W_STATUS_LB) { - cfg = norflash_get_security_register_config(); - if (!cfg.s.enabled) { - return 2; - } - if (cfg.s.lb == SEC_REG_LB_S11_S13) { - if (param >= 3) { - return 3; - } - status_s8_s15 |= (STATUS_S11_LB1_BIT_MASK << param); - } else if (cfg.s.lb == SEC_REG_LB_S10) { - status_s8_s15 |= STATUS_S10_LB_BIT_MASK; - } else { - return 4; - } - } - - gd25q32c_write_status_s8_s15(status_s8_s15); + if (type != DRV_NORFLASH_W_STATUS_INIT && type != DRV_NORFLASH_W_STATUS_QE && + type != DRV_NORFLASH_W_STATUS_LB && type != DRV_NORFLASH_W_STATUS_BP) { + return 1; + } + if (type == DRV_NORFLASH_W_STATUS_INIT) { + gd25q32c_write_status_s0_s7(param & 0xFF); + gd25q32c_write_status_s8_s15((param >> 8) & 0xFF); return 0; + } + + if (type == DRV_NORFLASH_W_STATUS_BP) { + bp_mask = norflash_get_block_protect_mask(); + status_s0_s7 = norflash_read_status_s0_s7(); + status_s0_s7 = (status_s0_s7 & ~bp_mask) | (param & bp_mask); + gd25q32c_write_status_s0_s7(status_s0_s7); + if ((bp_mask & ~0xFF) == 0) { + return 0; + } + } + + status_s8_s15 = norflash_read_status_s8_s15(); + + if (type == DRV_NORFLASH_W_STATUS_QE) { + if (param) { + status_s8_s15 |= GD25Q32C_QE_BIT_MASK; + } else { + status_s8_s15 &= ~(GD25Q32C_QE_BIT_MASK); + } + } else if (type == DRV_NORFLASH_W_STATUS_BP) { + param >>= 8; + bp_mask >>= 8; + status_s8_s15 = (status_s8_s15 & ~bp_mask) | (param & bp_mask); + } else if (type == DRV_NORFLASH_W_STATUS_LB) { + cfg = norflash_get_security_register_config(); + if (!cfg.s.enabled) { + return 2; + } + if (cfg.s.lb == SEC_REG_LB_S11_S13) { + if (param >= 3) { + return 3; + } + status_s8_s15 |= (STATUS_S11_LB1_BIT_MASK << param); + } else if (cfg.s.lb == SEC_REG_LB_S10) { + status_s8_s15 |= STATUS_S10_LB_BIT_MASK; + } else { + return 4; + } + } + + gd25q32c_write_status_s8_s15(status_s8_s15); + + return 0; } // ---------------------- @@ -98,27 +96,36 @@ static int gd25q32c_write_status(enum DRV_NORFLASH_W_STATUS_T type, uint32_t par // ---------------------- const struct NORFLASH_CFG_T gd25q32c_cfg = { - .id = { 0xC8, 0x40, 0x16, }, - .speed_ratio = { - .s = { - .std_read = SPEED_RATIO_5_EIGHTH, - .others = SPEED_RATIO_5_EIGHTH, + .id = + { + 0xC8, + 0x40, + 0x16, + }, + .speed_ratio = + { + .s = + { + .std_read = SPEED_RATIO_5_EIGHTH, + .others = SPEED_RATIO_5_EIGHTH, + }, }, - }, .crm_en_bits = (1 << 5) | (0 << 4), .crm_dis_bits = 0, .block_protect_mask = 0x407C, - .sec_reg_cfg = { - .s = { - .enabled = true, - .base = SEC_REG_BASE_0X1000, - .size = SEC_REG_SIZE_1024, - .offset = SEC_REG_OFFSET_0X1000, - .cnt = SEC_REG_CNT_3, - .pp = SEC_REG_PP_256, - .lb = SEC_REG_LB_S11_S13, + .sec_reg_cfg = + { + .s = + { + .enabled = true, + .base = SEC_REG_BASE_0X1000, + .size = SEC_REG_SIZE_1024, + .offset = SEC_REG_OFFSET_0X1000, + .cnt = SEC_REG_CNT_3, + .pp = SEC_REG_PP_256, + .lb = SEC_REG_LB_S11_S13, + }, }, - }, .page_size = GD25Q32C_PAGE_SIZE, .sector_size = GD25Q32C_SECTOR_SIZE, .block_size = GD25Q32C_BLOCK_SIZE, @@ -129,20 +136,16 @@ const struct NORFLASH_CFG_T gd25q32c_cfg = { // No high performance mode for gd25q32e .max_speed = 104 * 1000 * 1000, #endif - .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_DUAL_IO | - HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | - HAL_NORFLASH_OP_MODE_QUAD_IO | + .mode = + (HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_DUAL_IO | + HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO | #ifdef FLASH_HPM - HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE | + HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE | #endif - HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | - HAL_NORFLASH_OP_MODE_READ_WRAP | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_SUSPEND), + HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | HAL_NORFLASH_OP_MODE_READ_WRAP | + HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | HAL_NORFLASH_OP_MODE_SUSPEND), .write_status = gd25q32c_write_status, }; @@ -151,127 +154,144 @@ const struct NORFLASH_CFG_T gd25q32c_cfg = { // ---------------------- const struct NORFLASH_CFG_T p25q128l_cfg = { - .id = { 0x85, 0x60, 0x18, }, - .speed_ratio = { - .s = { - .std_read = SPEED_RATIO_3_EIGHTH, - .others = SPEED_RATIO_8_EIGHTH, + .id = + { + 0x85, + 0x60, + 0x18, + }, + .speed_ratio = + { + .s = + { + .std_read = SPEED_RATIO_3_EIGHTH, + .others = SPEED_RATIO_8_EIGHTH, + }, }, - }, .crm_en_bits = (1 << 5) | (0 << 4), .crm_dis_bits = 0, .block_protect_mask = 0x407C, - .sec_reg_cfg = { - .s = { - .enabled = true, - .base = SEC_REG_BASE_0X1000, - .size = SEC_REG_SIZE_1024, - .offset = SEC_REG_OFFSET_0X1000, - .cnt = SEC_REG_CNT_3, - .pp = SEC_REG_PP_1024, - .lb = SEC_REG_LB_S11_S13, + .sec_reg_cfg = + { + .s = + { + .enabled = true, + .base = SEC_REG_BASE_0X1000, + .size = SEC_REG_SIZE_1024, + .offset = SEC_REG_OFFSET_0X1000, + .cnt = SEC_REG_CNT_3, + .pp = SEC_REG_PP_1024, + .lb = SEC_REG_LB_S11_S13, + }, }, - }, .page_size = GD25Q32C_PAGE_SIZE, .sector_size = GD25Q32C_SECTOR_SIZE, .block_size = GD25Q32C_BLOCK_SIZE, .total_size = P25Q128L_TOTAL_SIZE, - .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_DUAL_IO | - HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | - HAL_NORFLASH_OP_MODE_QUAD_IO | - HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | - HAL_NORFLASH_OP_MODE_READ_WRAP | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_SUSPEND), + .mode = + (HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_DUAL_IO | + HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO | + HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | HAL_NORFLASH_OP_MODE_READ_WRAP | + HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | HAL_NORFLASH_OP_MODE_SUSPEND), .max_speed = 85 * 1000 * 1000, .write_status = gd25q32c_write_status, }; const struct NORFLASH_CFG_T p25q64l_cfg = { - .id = { 0x85, 0x60, 0x17, }, - .speed_ratio = { - .s = { - .std_read = SPEED_RATIO_3_EIGHTH, - .others = SPEED_RATIO_8_EIGHTH, + .id = + { + 0x85, + 0x60, + 0x17, + }, + .speed_ratio = + { + .s = + { + .std_read = SPEED_RATIO_3_EIGHTH, + .others = SPEED_RATIO_8_EIGHTH, + }, }, - }, .crm_en_bits = (1 << 5) | (0 << 4), .crm_dis_bits = 0, .block_protect_mask = 0x407C, - .sec_reg_cfg = { - .s = { - .enabled = true, - .base = SEC_REG_BASE_0X1000, - .size = SEC_REG_SIZE_1024, - .offset = SEC_REG_OFFSET_0X1000, - .cnt = SEC_REG_CNT_3, - .pp = SEC_REG_PP_1024, - .lb = SEC_REG_LB_S11_S13, + .sec_reg_cfg = + { + .s = + { + .enabled = true, + .base = SEC_REG_BASE_0X1000, + .size = SEC_REG_SIZE_1024, + .offset = SEC_REG_OFFSET_0X1000, + .cnt = SEC_REG_CNT_3, + .pp = SEC_REG_PP_1024, + .lb = SEC_REG_LB_S11_S13, + }, }, - }, .page_size = GD25Q32C_PAGE_SIZE, .sector_size = GD25Q32C_SECTOR_SIZE, .block_size = GD25Q32C_BLOCK_SIZE, .total_size = P25Q64L_TOTAL_SIZE, - .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_DUAL_IO | - HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | - HAL_NORFLASH_OP_MODE_QUAD_IO | - HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | - HAL_NORFLASH_OP_MODE_READ_WRAP | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_DUAL_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_SUSPEND), - .max_speed = 70 * 1000 * 1000, // P25Q64L=70M, P25Q64H=120M, P25Q64U=70M/120M + .mode = + (HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_DUAL_IO | + HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO | + HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | HAL_NORFLASH_OP_MODE_READ_WRAP | + HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_DUAL_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | HAL_NORFLASH_OP_MODE_SUSPEND), + .max_speed = + 70 * 1000 * 1000, // P25Q64L=70M, P25Q64H=120M, P25Q64U=70M/120M .write_status = gd25q32c_write_status, }; const struct NORFLASH_CFG_T p25q32l_cfg = { - .id = { 0x85, 0x60, 0x16, }, - .speed_ratio = { - .s = { - .std_read = SPEED_RATIO_4_EIGHTH, - .others = SPEED_RATIO_8_EIGHTH, + .id = + { + 0x85, + 0x60, + 0x16, + }, + .speed_ratio = + { + .s = + { + .std_read = SPEED_RATIO_4_EIGHTH, + .others = SPEED_RATIO_8_EIGHTH, + }, }, - }, .crm_en_bits = (1 << 5) | (0 << 4), .crm_dis_bits = 0, .block_protect_mask = 0x407C, - .sec_reg_cfg = { - .s = { - .enabled = true, - .base = SEC_REG_BASE_0X1000, - .size = SEC_REG_SIZE_1024, - .offset = SEC_REG_OFFSET_0X1000, - .cnt = SEC_REG_CNT_3, - .pp = SEC_REG_PP_1024, - .lb = SEC_REG_LB_S11_S13, + .sec_reg_cfg = + { + .s = + { + .enabled = true, + .base = SEC_REG_BASE_0X1000, + .size = SEC_REG_SIZE_1024, + .offset = SEC_REG_OFFSET_0X1000, + .cnt = SEC_REG_CNT_3, + .pp = SEC_REG_PP_1024, + .lb = SEC_REG_LB_S11_S13, + }, }, - }, .page_size = GD25Q32C_PAGE_SIZE, .sector_size = GD25Q32C_SECTOR_SIZE, .block_size = GD25Q32C_BLOCK_SIZE, .total_size = P25Q32L_TOTAL_SIZE, - .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_DUAL_IO | - HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | - HAL_NORFLASH_OP_MODE_QUAD_IO | - HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | - HAL_NORFLASH_OP_MODE_READ_WRAP | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_DUAL_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_SUSPEND), - .max_speed = 62 * 1000 * 1000, // P25Q32L=62.5M, P25Q32H=104M, P25Q32U=62.5M/104M + .mode = + (HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_DUAL_IO | + HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO | + HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | HAL_NORFLASH_OP_MODE_READ_WRAP | + HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_DUAL_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | HAL_NORFLASH_OP_MODE_SUSPEND), + .max_speed = + 62 * 1000 * 1000, // P25Q32L=62.5M, P25Q32H=104M, P25Q32U=62.5M/104M .write_status = gd25q32c_write_status, }; @@ -279,87 +299,99 @@ const struct NORFLASH_CFG_T p25q32l_cfg = { // Xinxin // ---------------------- -// Additionally, the device supports JEDEC standard manufacturer and device ID and SFDP Register, -// a 64-bit Unique Serial Number and three 256-bytes Security Registers. +// Additionally, the device supports JEDEC standard manufacturer and device ID +// and SFDP Register, a 64-bit Unique Serial Number and three 256-bytes Security +// Registers. const struct NORFLASH_CFG_T xm25qh16c_cfg = { - .id = { 0x20, 0x40, 0x15, }, - .speed_ratio = { - .s = { - .std_read = SPEED_RATIO_3_EIGHTH, - .others = SPEED_RATIO_8_EIGHTH, + .id = + { + 0x20, + 0x40, + 0x15, + }, + .speed_ratio = + { + .s = + { + .std_read = SPEED_RATIO_3_EIGHTH, + .others = SPEED_RATIO_8_EIGHTH, + }, }, - }, .crm_en_bits = (1 << 5) | (0 << 4), .crm_dis_bits = 0, .block_protect_mask = 0x407C, - .sec_reg_cfg = { - .s = { - .enabled = true, - .base = SEC_REG_BASE_0X1000, - .size = SEC_REG_SIZE_256, - .offset = SEC_REG_OFFSET_0X1000, - .cnt = SEC_REG_CNT_3, - .pp = SEC_REG_PP_256, - .lb = SEC_REG_LB_S11_S13, + .sec_reg_cfg = + { + .s = + { + .enabled = true, + .base = SEC_REG_BASE_0X1000, + .size = SEC_REG_SIZE_256, + .offset = SEC_REG_OFFSET_0X1000, + .cnt = SEC_REG_CNT_3, + .pp = SEC_REG_PP_256, + .lb = SEC_REG_LB_S11_S13, + }, }, - }, .page_size = GD25Q32C_PAGE_SIZE, .sector_size = GD25Q32C_SECTOR_SIZE, .block_size = GD25Q32C_BLOCK_SIZE, .total_size = XM25QH16C_TOTAL_SIZE, .max_speed = 108 * 1000 * 1000, - .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_DUAL_IO | - HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | - HAL_NORFLASH_OP_MODE_QUAD_IO | - HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | - HAL_NORFLASH_OP_MODE_READ_WRAP | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_SUSPEND), + .mode = + (HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_DUAL_IO | + HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO | + HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | HAL_NORFLASH_OP_MODE_READ_WRAP | + HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | HAL_NORFLASH_OP_MODE_SUSPEND), .write_status = gd25q32c_write_status, }; const struct NORFLASH_CFG_T xm25qh80b_cfg = { - .id = { 0x20, 0x40, 0x14, }, - .speed_ratio = { - .s = { - .std_read = SPEED_RATIO_7_EIGHTH, - .others = SPEED_RATIO_8_EIGHTH, + .id = + { + 0x20, + 0x40, + 0x14, + }, + .speed_ratio = + { + .s = + { + .std_read = SPEED_RATIO_7_EIGHTH, + .others = SPEED_RATIO_8_EIGHTH, + }, }, - }, .crm_en_bits = (1 << 5) | (0 << 4), .crm_dis_bits = 0, .block_protect_mask = 0x407C, - .sec_reg_cfg = { - .s = { - .enabled = true, - .base = SEC_REG_BASE_0X1000, - .size = SEC_REG_SIZE_256, - .offset = SEC_REG_OFFSET_0X1000, - .cnt = SEC_REG_CNT_3, - .pp = SEC_REG_PP_256, - .lb = SEC_REG_LB_S11_S13, + .sec_reg_cfg = + { + .s = + { + .enabled = true, + .base = SEC_REG_BASE_0X1000, + .size = SEC_REG_SIZE_256, + .offset = SEC_REG_OFFSET_0X1000, + .cnt = SEC_REG_CNT_3, + .pp = SEC_REG_PP_256, + .lb = SEC_REG_LB_S11_S13, + }, }, - }, .page_size = GD25Q32C_PAGE_SIZE, .sector_size = GD25Q32C_SECTOR_SIZE, .block_size = GD25Q32C_BLOCK_SIZE, .total_size = XM25QH80B_TOTAL_SIZE, - .max_speed = 60 * 1000 * 1000, // 104M (std_read=50M or 3/8) when HFM=1 (S20 or SR3-bit4) - .mode = (HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_DUAL_IO | - HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | - HAL_NORFLASH_OP_MODE_QUAD_IO | - HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | - HAL_NORFLASH_OP_MODE_READ_WRAP | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | - HAL_NORFLASH_OP_MODE_SUSPEND), + .max_speed = + 60 * 1000 * + 1000, // 104M (std_read=50M or 3/8) when HFM=1 (S20 or SR3-bit4) + .mode = + (HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_DUAL_IO | + HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO | + HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | HAL_NORFLASH_OP_MODE_READ_WRAP | + HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM | HAL_NORFLASH_OP_MODE_SUSPEND), .write_status = gd25q32c_write_status, }; - diff --git a/platform/drivers/usb/usb_dev/cfg/usb_dev_desc.c b/platform/drivers/usb/usb_dev/cfg/usb_dev_desc.c index d952703..3865dc6 100644 --- a/platform/drivers/usb/usb_dev/cfg/usb_dev_desc.c +++ b/platform/drivers/usb/usb_dev/cfg/usb_dev_desc.c @@ -15,95 +15,98 @@ ****************************************************************************/ #include "usb_dev_desc.h" #include "hal_usb.h" -#include "usb_descriptor.h" #include "tgt_hardware.h" +#include "usb_descriptor.h" #ifdef USB_HIGH_SPEED -#define DEV_QUAL_USB_VER 0x0200 -#define USB_CDC_USB_VER 0x0200 -#define USB_AUDIO_USB_VER 0x0201 -#define USB_CDC_PRODUCT_ID_BASE 0x0120 +#define DEV_QUAL_USB_VER 0x0200 +#define USB_CDC_USB_VER 0x0200 +#define USB_AUDIO_USB_VER 0x0201 +#define USB_CDC_PRODUCT_ID_BASE 0x0120 #ifdef USB_AUDIO_UAC2 -#define USB_AUDIO_PRODUCT_ID_BASE 0x0400 +#define USB_AUDIO_PRODUCT_ID_BASE 0x0400 #else -#define USB_AUDIO_PRODUCT_ID_BASE 0x0300 +#define USB_AUDIO_PRODUCT_ID_BASE 0x0300 #endif #else -#define DEV_QUAL_USB_VER 0x0200 -#define USB_CDC_USB_VER 0x0200 //0x0110 -#define USB_AUDIO_USB_VER 0x0200 //0x0110 -#define USB_CDC_PRODUCT_ID_BASE 0x0100 -#define USB_AUDIO_PRODUCT_ID_BASE 0x0200 +#define DEV_QUAL_USB_VER 0x0200 +#define USB_CDC_USB_VER 0x0200 // 0x0110 +#define USB_AUDIO_USB_VER 0x0200 // 0x0110 +#define USB_CDC_PRODUCT_ID_BASE 0x0100 +#define USB_AUDIO_PRODUCT_ID_BASE 0x0200 #ifdef USB_AUDIO_UAC2 #error "USB_AUDIO_UAC2 should run on USB_HIGH_SPEED" #endif #endif #ifndef USB_CDC_VENDOR_ID -#define USB_CDC_VENDOR_ID 0xBE57 +#define USB_CDC_VENDOR_ID 0xBE57 #endif #ifndef USB_CDC_PRODUCT_ID -#define USB_CDC_PRODUCT_ID (USB_CDC_PRODUCT_ID_BASE + 0x01) +#define USB_CDC_PRODUCT_ID (USB_CDC_PRODUCT_ID_BASE + 0x01) #endif #ifndef USB_AUDIO_VENDOR_ID -#define USB_AUDIO_VENDOR_ID 0xBE57 +#define USB_AUDIO_VENDOR_ID 0xBE57 #endif #ifndef USB_AUDIO_PRODUCT_ID #ifdef USB_AUDIO_DYN_CFG -#define USB_AUDIO_PRODUCT_ID_STEM (USB_AUDIO_PRODUCT_ID_BASE + 0x31) +#define USB_AUDIO_PRODUCT_ID_STEM (USB_AUDIO_PRODUCT_ID_BASE + 0x31) #ifdef USB_AUDIO_32BIT -#define USB_AUDIO_PRODUCT_32BIT_FLAG 0x0004 +#define USB_AUDIO_PRODUCT_32BIT_FLAG 0x0004 #else -#define USB_AUDIO_PRODUCT_32BIT_FLAG 0 +#define USB_AUDIO_PRODUCT_32BIT_FLAG 0 #endif #ifdef USB_AUDIO_24BIT -#define USB_AUDIO_PRODUCT_24BIT_FLAG 0x0002 +#define USB_AUDIO_PRODUCT_24BIT_FLAG 0x0002 #else -#define USB_AUDIO_PRODUCT_24BIT_FLAG 0 +#define USB_AUDIO_PRODUCT_24BIT_FLAG 0 #endif #ifdef USB_AUDIO_16BIT -#define USB_AUDIO_PRODUCT_16BIT_FLAG 0x0001 +#define USB_AUDIO_PRODUCT_16BIT_FLAG 0x0001 #else -#define USB_AUDIO_PRODUCT_16BIT_FLAG 0 +#define USB_AUDIO_PRODUCT_16BIT_FLAG 0 #endif -#define USB_AUDIO_PRODUCT_ID (USB_AUDIO_PRODUCT_ID_STEM + USB_AUDIO_PRODUCT_32BIT_FLAG + \ - USB_AUDIO_PRODUCT_24BIT_FLAG + USB_AUDIO_PRODUCT_16BIT_FLAG) +#define USB_AUDIO_PRODUCT_ID \ + (USB_AUDIO_PRODUCT_ID_STEM + USB_AUDIO_PRODUCT_32BIT_FLAG + \ + USB_AUDIO_PRODUCT_24BIT_FLAG + USB_AUDIO_PRODUCT_16BIT_FLAG) #else // !USB_AUDIO_DYN_CFG #ifdef USB_AUDIO_384K -#define USB_AUDIO_PRODUCT_ID_STEM (USB_AUDIO_PRODUCT_ID_BASE + 0x08) +#define USB_AUDIO_PRODUCT_ID_STEM (USB_AUDIO_PRODUCT_ID_BASE + 0x08) #elif defined(USB_AUDIO_352_8K) -#define USB_AUDIO_PRODUCT_ID_STEM (USB_AUDIO_PRODUCT_ID_BASE + 0x07) +#define USB_AUDIO_PRODUCT_ID_STEM (USB_AUDIO_PRODUCT_ID_BASE + 0x07) #elif defined(USB_AUDIO_192K) -#define USB_AUDIO_PRODUCT_ID_STEM (USB_AUDIO_PRODUCT_ID_BASE + 0x06) +#define USB_AUDIO_PRODUCT_ID_STEM (USB_AUDIO_PRODUCT_ID_BASE + 0x06) #elif defined(USB_AUDIO_176_4K) -#define USB_AUDIO_PRODUCT_ID_STEM (USB_AUDIO_PRODUCT_ID_BASE + 0x05) +#define USB_AUDIO_PRODUCT_ID_STEM (USB_AUDIO_PRODUCT_ID_BASE + 0x05) #elif defined(USB_AUDIO_96K) -#define USB_AUDIO_PRODUCT_ID_STEM (USB_AUDIO_PRODUCT_ID_BASE + 0x04) +#define USB_AUDIO_PRODUCT_ID_STEM (USB_AUDIO_PRODUCT_ID_BASE + 0x04) #elif defined(USB_AUDIO_44_1K) -#define USB_AUDIO_PRODUCT_ID_STEM (USB_AUDIO_PRODUCT_ID_BASE + 0x03) +#define USB_AUDIO_PRODUCT_ID_STEM (USB_AUDIO_PRODUCT_ID_BASE + 0x03) #elif defined(USB_AUDIO_16K) -#define USB_AUDIO_PRODUCT_ID_STEM (USB_AUDIO_PRODUCT_ID_BASE + 0x02) +#define USB_AUDIO_PRODUCT_ID_STEM (USB_AUDIO_PRODUCT_ID_BASE + 0x02) #else // 48K -#define USB_AUDIO_PRODUCT_ID_STEM (USB_AUDIO_PRODUCT_ID_BASE + 0x01) +#define USB_AUDIO_PRODUCT_ID_STEM (USB_AUDIO_PRODUCT_ID_BASE + 0x01) #endif -#define USB_AUDIO_PRODUCT_32BIT_FLAG 0x0020 -#define USB_AUDIO_PRODUCT_24BIT_FLAG 0x0010 +#define USB_AUDIO_PRODUCT_32BIT_FLAG 0x0020 +#define USB_AUDIO_PRODUCT_24BIT_FLAG 0x0010 #ifdef USB_AUDIO_32BIT -#define USB_AUDIO_PRODUCT_ID (USB_AUDIO_PRODUCT_ID_STEM + USB_AUDIO_PRODUCT_32BIT_FLAG) +#define USB_AUDIO_PRODUCT_ID \ + (USB_AUDIO_PRODUCT_ID_STEM + USB_AUDIO_PRODUCT_32BIT_FLAG) #elif defined(USB_AUDIO_24BIT) -#define USB_AUDIO_PRODUCT_ID (USB_AUDIO_PRODUCT_ID_STEM + USB_AUDIO_PRODUCT_24BIT_FLAG) +#define USB_AUDIO_PRODUCT_ID \ + (USB_AUDIO_PRODUCT_ID_STEM + USB_AUDIO_PRODUCT_24BIT_FLAG) #else -#define USB_AUDIO_PRODUCT_ID (USB_AUDIO_PRODUCT_ID_STEM) +#define USB_AUDIO_PRODUCT_ID (USB_AUDIO_PRODUCT_ID_STEM) #endif #endif // !USB_AUDIO_DYN_CFG @@ -115,25 +118,29 @@ //---------------------------------------------------------------- static const uint8_t stringLangidDescriptor[] = { - 0x04, /*bLength*/ - STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ - 0x09,0x04, /*bString Lang ID - 0x0409 - English*/ + 0x04, /*bLength*/ + STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ + 0x09, 0x04, /*bString Lang ID - 0x0409 - English*/ }; static const uint8_t stringIconfigurationDescriptor[] = { - 0x06, /*bLength*/ - STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ - '0',0,'1',0, /*bString iConfiguration - 01*/ + 0x06, /*bLength*/ + STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ + '0', + 0, + '1', + 0, /*bString iConfiguration - 01*/ }; #ifdef USB_HIGH_SPEED static const uint8_t deviceQualifierDescriptor[] = { 10, QUALIFIER_DESCRIPTOR, - LSB(DEV_QUAL_USB_VER), MSB(DEV_QUAL_USB_VER), - 0, // bDeviceClass - 0, // bDeviceSubClass - 0, // bDeviceProtocol + LSB(DEV_QUAL_USB_VER), + MSB(DEV_QUAL_USB_VER), + 0, // bDeviceClass + 0, // bDeviceSubClass + 0, // bDeviceProtocol USB_MAX_PACKET_SIZE_CTRL, // bMaxPacketSize0 0, 0, @@ -142,243 +149,351 @@ static const uint8_t deviceQualifierDescriptor[] = { static const uint8_t bosDescriptor[] = { 5, BOS_DESCRIPTOR, - 12, 0, // wTotalLength - 1, // bNumDeviceCaps - 7, // bLength - 0x10, // bDescriptorType - 0x02, // bDevCapabilityType + 12, + 0, // wTotalLength + 1, // bNumDeviceCaps + 7, // bLength + 0x10, // bDescriptorType + 0x02, // bDevCapabilityType #ifdef USB_LPM #ifdef USB_LPM_DEEP_BESL - 0x1E, // bmAttributes: LPM, BESL, Baseline BESL, Deep BESL + 0x1E, // bmAttributes: LPM, BESL, Baseline BESL, Deep BESL #else - 0x0E, // bmAttributes: LPM, BESL, Baseline BESL + 0x0E, // bmAttributes: LPM, BESL, Baseline BESL #endif (USB_L1_DEEP_SLEEP_BESL << 4) | USB_L1_LIGHT_SLEEP_BESL, #else - 0x00, // bmAttributes: none + 0x00, // bmAttributes: none 0x00, #endif 0x00, - 0x00 -}; + 0x00}; #endif //---------------------------------------------------------------- // USB CDC device description and string descriptions //---------------------------------------------------------------- -const uint8_t *cdc_dev_desc(uint8_t type) -{ - static const uint8_t deviceDescriptor[] = { - 18, // bLength - DEVICE_DESCRIPTOR, // bDescriptorType - LSB(USB_CDC_USB_VER), MSB(USB_CDC_USB_VER), // bcdUSB - 2, // bDeviceClass - 0, // bDeviceSubClass - 0, // bDeviceProtocol - USB_MAX_PACKET_SIZE_CTRL, // bMaxPacketSize0 - LSB(USB_CDC_VENDOR_ID), MSB(USB_CDC_VENDOR_ID), // idVendor - LSB(USB_CDC_PRODUCT_ID), MSB(USB_CDC_PRODUCT_ID), // idProduct - 0x00, 0x01, // bcdDevice - STRING_OFFSET_IMANUFACTURER, // iManufacturer - STRING_OFFSET_IPRODUCT, // iProduct - STRING_OFFSET_ISERIAL, // iSerialNumber - 1 // bNumConfigurations - }; +const uint8_t *cdc_dev_desc(uint8_t type) { + static const uint8_t deviceDescriptor[] = { + 18, // bLength + DEVICE_DESCRIPTOR, // bDescriptorType + LSB(USB_CDC_USB_VER), + MSB(USB_CDC_USB_VER), // bcdUSB + 2, // bDeviceClass + 0, // bDeviceSubClass + 0, // bDeviceProtocol + USB_MAX_PACKET_SIZE_CTRL, // bMaxPacketSize0 + LSB(USB_CDC_VENDOR_ID), + MSB(USB_CDC_VENDOR_ID), // idVendor + LSB(USB_CDC_PRODUCT_ID), + MSB(USB_CDC_PRODUCT_ID), // idProduct + 0x00, + 0x01, // bcdDevice + STRING_OFFSET_IMANUFACTURER, // iManufacturer + STRING_OFFSET_IPRODUCT, // iProduct + STRING_OFFSET_ISERIAL, // iSerialNumber + 1 // bNumConfigurations + }; - if (type == DEVICE_DESCRIPTOR) { - return deviceDescriptor; + if (type == DEVICE_DESCRIPTOR) { + return deviceDescriptor; #ifdef USB_HIGH_SPEED - } else if (type == QUALIFIER_DESCRIPTOR) { - return deviceQualifierDescriptor; - } else if (type == BOS_DESCRIPTOR) { - return bosDescriptor; + } else if (type == QUALIFIER_DESCRIPTOR) { + return deviceQualifierDescriptor; + } else if (type == BOS_DESCRIPTOR) { + return bosDescriptor; #endif - } else { - return NULL; - } + } else { + return NULL; + } } -const uint8_t *cdc_string_desc(uint8_t index) -{ - static const uint8_t stringImanufacturerDescriptor[] = +const uint8_t *cdc_string_desc(uint8_t index) { + static const uint8_t stringImanufacturerDescriptor[] = #ifdef USB_CDC_STR_DESC_MANUFACTURER - USB_CDC_STR_DESC_MANUFACTURER; + USB_CDC_STR_DESC_MANUFACTURER; #else - { - 0x16, /*bLength*/ - STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ - 'b',0,'e',0,'s',0,'t',0,'e',0,'c',0,'h',0,'n',0,'i',0,'c',0 /*bString iManufacturer - bestechnic*/ - }; + { + 0x16, /*bLength*/ + STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ + 'b', + 0, + 'e', + 0, + 's', + 0, + 't', + 0, + 'e', + 0, + 'c', + 0, + 'h', + 0, + 'n', + 0, + 'i', + 0, + 'c', + 0 /*bString iManufacturer - bestechnic*/ + }; #endif - static const uint8_t stringIserialDescriptor[] = + static const uint8_t stringIserialDescriptor[] = #ifdef USB_CDC_STR_DESC_SERIAL - USB_CDC_STR_DESC_SERIAL; + USB_CDC_STR_DESC_SERIAL; #else - { - 0x16, /*bLength*/ - STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ - '2',0,'0',0,'1',0,'5',0,'1',0,'0',0,'0',0,'6',0,'.',0,'1',0, /*bString iSerial - 20151006.1*/ - }; + { + 0x16, /*bLength*/ + STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ + '2', + 0, + '0', + 0, + '1', + 0, + '5', + 0, + '1', + 0, + '0', + 0, + '0', + 0, + '6', + 0, + '.', + 0, + '1', + 0, /*bString iSerial - 20151006.1*/ + }; #endif - static const uint8_t stringIinterfaceDescriptor[] = + static const uint8_t stringIinterfaceDescriptor[] = #ifdef USB_CDC_STR_DESC_INTERFACE - USB_CDC_STR_DESC_INTERFACE; + USB_CDC_STR_DESC_INTERFACE; #else - { - 0x08, - STRING_DESCRIPTOR, - 'C',0,'D',0,'C',0, - }; + { + 0x08, STRING_DESCRIPTOR, 'C', 0, 'D', 0, 'C', 0, + }; #endif - static const uint8_t stringIproductDescriptor[] = + static const uint8_t stringIproductDescriptor[] = #ifdef USB_CDC_STR_DESC_PRODUCT - USB_CDC_STR_DESC_PRODUCT; + USB_CDC_STR_DESC_PRODUCT; #else - { - 0x16, - STRING_DESCRIPTOR, - 'C',0,'D',0,'C',0,' ',0,'D',0,'E',0,'V',0,'I',0,'C',0,'E',0 - }; + {0x16, STRING_DESCRIPTOR, + 'C', 0, + 'D', 0, + 'C', 0, + ' ', 0, + 'D', 0, + 'E', 0, + 'V', 0, + 'I', 0, + 'C', 0, + 'E', 0}; #endif - const uint8_t *data = NULL; + const uint8_t *data = NULL; - switch (index) - { - case STRING_OFFSET_LANGID: - data = stringLangidDescriptor; - break; - case STRING_OFFSET_IMANUFACTURER: - data = stringImanufacturerDescriptor; - break; - case STRING_OFFSET_IPRODUCT: - data = stringIproductDescriptor; - break; - case STRING_OFFSET_ISERIAL: - data = stringIserialDescriptor; - break; - case STRING_OFFSET_ICONFIGURATION: - data = stringIconfigurationDescriptor; - break; - case STRING_OFFSET_IINTERFACE: - data = stringIinterfaceDescriptor; - break; - } + switch (index) { + case STRING_OFFSET_LANGID: + data = stringLangidDescriptor; + break; + case STRING_OFFSET_IMANUFACTURER: + data = stringImanufacturerDescriptor; + break; + case STRING_OFFSET_IPRODUCT: + data = stringIproductDescriptor; + break; + case STRING_OFFSET_ISERIAL: + data = stringIserialDescriptor; + break; + case STRING_OFFSET_ICONFIGURATION: + data = stringIconfigurationDescriptor; + break; + case STRING_OFFSET_IINTERFACE: + data = stringIinterfaceDescriptor; + break; + } - return data; + return data; } //---------------------------------------------------------------- // USB audio device description and string descriptions //---------------------------------------------------------------- -const uint8_t *uaud_dev_desc(uint8_t type) -{ - static const uint8_t deviceDescriptor[] = { - 18, // bLength - DEVICE_DESCRIPTOR, // bDescriptorType - LSB(USB_AUDIO_USB_VER), MSB(USB_AUDIO_USB_VER), // bcdUSB - 0, // bDeviceClass - 0, // bDeviceSubClass - 0, // bDeviceProtocol - USB_MAX_PACKET_SIZE_CTRL, // bMaxPacketSize0 - LSB(USB_AUDIO_VENDOR_ID), MSB(USB_AUDIO_VENDOR_ID), // idVendor - LSB(USB_AUDIO_PRODUCT_ID), MSB(USB_AUDIO_PRODUCT_ID), // idProduct - 0x00, 0x01, // bcdDevice - STRING_OFFSET_IMANUFACTURER, // iManufacturer - STRING_OFFSET_IPRODUCT, // iProduct - STRING_OFFSET_ISERIAL, // iSerialNumber - 1 // bNumConfigurations - }; +const uint8_t *uaud_dev_desc(uint8_t type) { + static const uint8_t deviceDescriptor[] = { + 18, // bLength + DEVICE_DESCRIPTOR, // bDescriptorType + LSB(USB_AUDIO_USB_VER), + MSB(USB_AUDIO_USB_VER), // bcdUSB + 0, // bDeviceClass + 0, // bDeviceSubClass + 0, // bDeviceProtocol + USB_MAX_PACKET_SIZE_CTRL, // bMaxPacketSize0 + LSB(USB_AUDIO_VENDOR_ID), + MSB(USB_AUDIO_VENDOR_ID), // idVendor + LSB(USB_AUDIO_PRODUCT_ID), + MSB(USB_AUDIO_PRODUCT_ID), // idProduct + 0x00, + 0x01, // bcdDevice + STRING_OFFSET_IMANUFACTURER, // iManufacturer + STRING_OFFSET_IPRODUCT, // iProduct + STRING_OFFSET_ISERIAL, // iSerialNumber + 1 // bNumConfigurations + }; - if (type == DEVICE_DESCRIPTOR) { - return deviceDescriptor; + if (type == DEVICE_DESCRIPTOR) { + return deviceDescriptor; #ifdef USB_HIGH_SPEED - } else if (type == QUALIFIER_DESCRIPTOR) { - return deviceQualifierDescriptor; - } else if (type == BOS_DESCRIPTOR) { - return bosDescriptor; + } else if (type == QUALIFIER_DESCRIPTOR) { + return deviceQualifierDescriptor; + } else if (type == BOS_DESCRIPTOR) { + return bosDescriptor; #endif - } else { - return NULL; - } + } else { + return NULL; + } } -const uint8_t *uaud_string_desc(uint8_t index) -{ - static const uint8_t stringImanufacturerDescriptor[] = +const uint8_t *uaud_string_desc(uint8_t index) { + static const uint8_t stringImanufacturerDescriptor[] = #ifdef USB_AUDIO_STR_DESC_MANUFACTURER - USB_AUDIO_STR_DESC_MANUFACTURER; + USB_AUDIO_STR_DESC_MANUFACTURER; #else - { - 0x16, /*bLength*/ - STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ - 'b',0,'e',0,'s',0,'t',0,'e',0,'c',0,'h',0,'n',0,'i',0,'c',0 /*bString iManufacturer - bestechnic*/ - }; + { + 0x16, /*bLength*/ + STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ + 'b', + 0, + 'e', + 0, + 's', + 0, + 't', + 0, + 'e', + 0, + 'c', + 0, + 'h', + 0, + 'n', + 0, + 'i', + 0, + 'c', + 0 /*bString iManufacturer - bestechnic*/ + }; #endif - static const uint8_t stringIserialDescriptor[] = + static const uint8_t stringIserialDescriptor[] = #ifdef USB_AUDIO_STR_DESC_SERIAL - USB_AUDIO_STR_DESC_SERIAL; + USB_AUDIO_STR_DESC_SERIAL; #else - { - 0x16, /*bLength*/ - STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ - '2',0,'0',0,'1',0,'6',0,'0',0,'4',0,'0',0,'6',0,'.',0,'1',0, /*bString iSerial - 20160406.1*/ - }; + { + 0x16, /*bLength*/ + STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ + '2', + 0, + '0', + 0, + '1', + 0, + '6', + 0, + '0', + 0, + '4', + 0, + '0', + 0, + '6', + 0, + '.', + 0, + '1', + 0, /*bString iSerial - 20160406.1*/ + }; #endif - static const uint8_t stringIinterfaceDescriptor[] = + static const uint8_t stringIinterfaceDescriptor[] = #ifdef USB_AUDIO_STR_DESC_INTERFACE - USB_AUDIO_STR_DESC_INTERFACE; + USB_AUDIO_STR_DESC_INTERFACE; #else - { - 0x0c, //bLength - STRING_DESCRIPTOR, //bDescriptorType 0x03 - 'A',0,'u',0,'d',0,'i',0,'o',0 //bString iInterface - Audio - }; + { + 0x0c, // bLength + STRING_DESCRIPTOR, // bDescriptorType 0x03 + 'A', + 0, + 'u', + 0, + 'd', + 0, + 'i', + 0, + 'o', + 0 // bString iInterface - Audio + }; #endif - static const uint8_t stringIproductDescriptor[] = + static const uint8_t stringIproductDescriptor[] = #ifdef USB_AUDIO_STR_DESC_PRODUCT - USB_AUDIO_STR_DESC_PRODUCT; + USB_AUDIO_STR_DESC_PRODUCT; #else - { - 0x16, //bLength - STRING_DESCRIPTOR, //bDescriptorType 0x03 - 'B',0,'e',0,'s',0,'t',0,' ',0,'A',0,'u',0,'d',0,'i',0,'o',0 //bString iProduct - Best Audio - }; + { + 0x16, // bLength + STRING_DESCRIPTOR, // bDescriptorType 0x03 + 'B', + 0, + 'e', + 0, + 's', + 0, + 't', + 0, + ' ', + 0, + 'A', + 0, + 'u', + 0, + 'd', + 0, + 'i', + 0, + 'o', + 0 // bString iProduct - Best Audio + }; #endif - const uint8_t *data = NULL; + const uint8_t *data = NULL; - switch (index) - { - case STRING_OFFSET_LANGID: - data = stringLangidDescriptor; - break; - case STRING_OFFSET_IMANUFACTURER: - data = stringImanufacturerDescriptor; - break; - case STRING_OFFSET_IPRODUCT: - data = stringIproductDescriptor; - break; - case STRING_OFFSET_ISERIAL: - data = stringIserialDescriptor; - break; - case STRING_OFFSET_ICONFIGURATION: - data = stringIconfigurationDescriptor; - break; - case STRING_OFFSET_IINTERFACE: - data = stringIinterfaceDescriptor; - break; - } + switch (index) { + case STRING_OFFSET_LANGID: + data = stringLangidDescriptor; + break; + case STRING_OFFSET_IMANUFACTURER: + data = stringImanufacturerDescriptor; + break; + case STRING_OFFSET_IPRODUCT: + data = stringIproductDescriptor; + break; + case STRING_OFFSET_ISERIAL: + data = stringIserialDescriptor; + break; + case STRING_OFFSET_ICONFIGURATION: + data = stringIconfigurationDescriptor; + break; + case STRING_OFFSET_IINTERFACE: + data = stringIinterfaceDescriptor; + break; + } - return data; + return data; } - - diff --git a/platform/hal/best2300p/hal_analogif_best2300p.c b/platform/hal/best2300p/hal_analogif_best2300p.c index 1cf487e..dbe3b2b 100644 --- a/platform/hal/best2300p/hal_analogif_best2300p.c +++ b/platform/hal/best2300p/hal_analogif_best2300p.c @@ -13,18 +13,18 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" #include "cmsis.h" #include "hal_analogif.h" #include "hal_location.h" #include "hal_spi.h" +#include "plat_types.h" -#define ANA_REG_CHIP_ID 0x00 +#define ANA_REG_CHIP_ID 0x00 -#define ANA_CHIP_ID_SHIFT (4) -#define ANA_CHIP_ID_MASK (0xFFF << ANA_CHIP_ID_SHIFT) -#define ANA_CHIP_ID(n) BITFIELD_VAL(ANA_CHIP_ID, n) -#define ANA_VAL_CHIP_ID 0x18E +#define ANA_CHIP_ID_SHIFT (4) +#define ANA_CHIP_ID_MASK (0xFFF << ANA_CHIP_ID_SHIFT) +#define ANA_CHIP_ID(n) BITFIELD_VAL(ANA_CHIP_ID, n) +#define ANA_VAL_CHIP_ID 0x18E // ISPI_ARBITRATOR_ENABLE should be defined when: // 1) BT and MCU will access RF register at the same time; or @@ -34,20 +34,23 @@ #ifdef ISPI_ARBITRATOR_ENABLE // Min padding OSC cycles needed: BT=0 MCU=6 // When OSC=26M and SPI=6.5M, min padding SPI cycles is BT=0 MCU=2 -#define PADDING_CYCLES 2 +#define PADDING_CYCLES 2 #else -#define PADDING_CYCLES 0 +#define PADDING_CYCLES 0 #endif -#define ANA_READ_CMD(r) (((1 << 24) | (((r) & 0xFF) << 16)) << PADDING_CYCLES) -#define ANA_WRITE_CMD(r, v) (((((r) & 0xFF) << 16) | ((v) & 0xFFFF)) << PADDING_CYCLES) -#define ANA_READ_VAL(v) (((v) >> PADDING_CYCLES) & 0xFFFF) +#define ANA_READ_CMD(r) (((1 << 24) | (((r)&0xFF) << 16)) << PADDING_CYCLES) +#define ANA_WRITE_CMD(r, v) \ + (((((r)&0xFF) << 16) | ((v)&0xFFFF)) << PADDING_CYCLES) +#define ANA_READ_VAL(v) (((v) >> PADDING_CYCLES) & 0xFFFF) -#define ANA_PAGE_1 0xA010 -#define ANA_PAGE_0 0xA000 +#define ANA_PAGE_1 0xA010 +#define ANA_PAGE_0 0xA000 static const BOOT_RODATA_SRAM_LOC uint8_t page_reg[3] = { - 0x00, 0x60, 0x80, + 0x00, + 0x60, + 0x80, }; static const BOOT_RODATA_FLASH_LOC struct HAL_SPI_CFG_T spi_cfg = { @@ -66,146 +69,144 @@ static const BOOT_RODATA_FLASH_LOC struct HAL_SPI_CFG_T spi_cfg = { static bool BOOT_BSS_LOC analogif_inited = false; -static int BOOT_TEXT_SRAM_LOC hal_analogif_rawread(unsigned short reg, unsigned short *val) -{ - int ret; - unsigned int data; - unsigned int cmd; +static int BOOT_TEXT_SRAM_LOC hal_analogif_rawread(unsigned short reg, + unsigned short *val) { + int ret; + unsigned int data; + unsigned int cmd; - data = 0; - cmd = ANA_READ_CMD(reg); - ret = hal_ispi_recv(&cmd, &data, 4); - if (ret) { - return ret; - } - *val = ANA_READ_VAL(data); - return 0; + data = 0; + cmd = ANA_READ_CMD(reg); + ret = hal_ispi_recv(&cmd, &data, 4); + if (ret) { + return ret; + } + *val = ANA_READ_VAL(data); + return 0; } -static int BOOT_TEXT_SRAM_LOC hal_analogif_rawwrite(unsigned short reg, unsigned short val) -{ - int ret; - unsigned int cmd; +static int BOOT_TEXT_SRAM_LOC hal_analogif_rawwrite(unsigned short reg, + unsigned short val) { + int ret; + unsigned int cmd; - cmd = ANA_WRITE_CMD(reg, val); - ret = hal_ispi_send(&cmd, 4); - if (ret) { - return ret; - } - return 0; + cmd = ANA_WRITE_CMD(reg, val); + ret = hal_ispi_send(&cmd, 4); + if (ret) { + return ret; + } + return 0; } -int BOOT_TEXT_SRAM_LOC hal_analogif_reg_read(unsigned short reg, unsigned short *val) -{ - uint32_t lock; - uint32_t idx; - int ret; +int BOOT_TEXT_SRAM_LOC hal_analogif_reg_read(unsigned short reg, + unsigned short *val) { + uint32_t lock; + uint32_t idx; + int ret; #if defined(USE_CYBERON) -extern int cyb_efuse_check_status(void); + extern int cyb_efuse_check_status(void); - if (cyb_efuse_check_status()) { - if (reg == 0x5e) { - *val = 49185; - return 0; - } - if (reg == 0x00) { - *val = 0x20e0; - return 0; - } + if (cyb_efuse_check_status()) { + if (reg == 0x5e) { + *val = 49185; + return 0; } + if (reg == 0x00) { + *val = 0x20e0; + return 0; + } + } #endif - if (reg < 0x100) { - lock = int_lock(); - ret = hal_analogif_rawread(reg, val); - int_unlock(lock); - return ret; - } else if (reg >= 0x100 && reg <= 0x15F) { - idx = 0; - } else if (reg >= 0x160 && reg <= 0x17F) { - idx = 1; - } else if (reg >= 0x180 && reg <= 0x1FF) { - idx = 2; - } else { - return -1; - } - - reg &= 0xFF; - + if (reg < 0x100) { lock = int_lock(); - hal_analogif_rawwrite(page_reg[idx], ANA_PAGE_1); ret = hal_analogif_rawread(reg, val); - hal_analogif_rawwrite(page_reg[idx], ANA_PAGE_0); int_unlock(lock); - return ret; + } else if (reg >= 0x100 && reg <= 0x15F) { + idx = 0; + } else if (reg >= 0x160 && reg <= 0x17F) { + idx = 1; + } else if (reg >= 0x180 && reg <= 0x1FF) { + idx = 2; + } else { + return -1; + } + + reg &= 0xFF; + + lock = int_lock(); + hal_analogif_rawwrite(page_reg[idx], ANA_PAGE_1); + ret = hal_analogif_rawread(reg, val); + hal_analogif_rawwrite(page_reg[idx], ANA_PAGE_0); + int_unlock(lock); + + return ret; } -int BOOT_TEXT_SRAM_LOC hal_analogif_reg_write(unsigned short reg, unsigned short val) -{ - uint32_t lock; - uint32_t idx; - int ret; - - if (reg < 0x100) { - lock = int_lock(); - ret = hal_analogif_rawwrite(reg, val); - int_unlock(lock); - return ret; - } else if (reg >= 0x100 && reg <= 0x15F) { - idx = 0; - } else if (reg >= 0x160 && reg <= 0x17F) { - idx = 1; - } else if (reg >= 0x180 && reg <= 0x1FF) { - idx = 2; - } else { - return -1; - } - - reg &= 0xFF; +int BOOT_TEXT_SRAM_LOC hal_analogif_reg_write(unsigned short reg, + unsigned short val) { + uint32_t lock; + uint32_t idx; + int ret; + if (reg < 0x100) { lock = int_lock(); - hal_analogif_rawwrite(page_reg[idx], ANA_PAGE_1); ret = hal_analogif_rawwrite(reg, val); - hal_analogif_rawwrite(page_reg[idx], ANA_PAGE_0); int_unlock(lock); - return ret; + } else if (reg >= 0x100 && reg <= 0x15F) { + idx = 0; + } else if (reg >= 0x160 && reg <= 0x17F) { + idx = 1; + } else if (reg >= 0x180 && reg <= 0x1FF) { + idx = 2; + } else { + return -1; + } + + reg &= 0xFF; + + lock = int_lock(); + hal_analogif_rawwrite(page_reg[idx], ANA_PAGE_1); + ret = hal_analogif_rawwrite(reg, val); + hal_analogif_rawwrite(page_reg[idx], ANA_PAGE_0); + int_unlock(lock); + + return ret; } -int BOOT_TEXT_FLASH_LOC hal_analogif_open(void) -{ - int ret; - unsigned short chip_id; - const struct HAL_SPI_CFG_T *cfg_ptr; - struct HAL_SPI_CFG_T cfg; +int BOOT_TEXT_FLASH_LOC hal_analogif_open(void) { + int ret; + unsigned short chip_id; + const struct HAL_SPI_CFG_T *cfg_ptr; + struct HAL_SPI_CFG_T cfg; - if (analogif_inited) { - // Restore the nominal rate - cfg_ptr = &spi_cfg; - } else { - analogif_inited = true; - // Crystal freq is unknown yet. Let SPI run on half of the nominal rate - cfg = spi_cfg; - cfg.rate /= 2; - cfg_ptr = &cfg; - } + if (analogif_inited) { + // Restore the nominal rate + cfg_ptr = &spi_cfg; + } else { + analogif_inited = true; + // Crystal freq is unknown yet. Let SPI run on half of the nominal rate + cfg = spi_cfg; + cfg.rate /= 2; + cfg_ptr = &cfg; + } - ret = hal_ispi_open(cfg_ptr); - if (ret) { - return ret; - } + ret = hal_ispi_open(cfg_ptr); + if (ret) { + return ret; + } - ret = hal_analogif_rawread(ANA_REG_CHIP_ID, &chip_id); - if (ret) { - return ret; - } + ret = hal_analogif_rawread(ANA_REG_CHIP_ID, &chip_id); + if (ret) { + return ret; + } - if (GET_BITFIELD(chip_id, ANA_CHIP_ID) != ANA_VAL_CHIP_ID) { - return -1; - } + if (GET_BITFIELD(chip_id, ANA_CHIP_ID) != ANA_VAL_CHIP_ID) { + return -1; + } - return 0; + return 0; } - diff --git a/platform/hal/best2300p/hal_cmu_best2300p.c b/platform/hal/best2300p/hal_cmu_best2300p.c index e66451c..6a5d2ff 100644 --- a/platform/hal/best2300p/hal_cmu_best2300p.c +++ b/platform/hal/best2300p/hal_cmu_best2300p.c @@ -17,10 +17,11 @@ #include CHIP_SPECIFIC_HDR(reg_cmu) #include CHIP_SPECIFIC_HDR(reg_aoncmu) #include CHIP_SPECIFIC_HDR(reg_btcmu) -#include "hal_cmu.h" +#include "cmsis_nvic.h" #include "hal_aud.h" #include "hal_bootmode.h" #include "hal_chipid.h" +#include "hal_cmu.h" #include "hal_codec.h" #include "hal_location.h" #include "hal_psc.h" @@ -28,7 +29,6 @@ #include "hal_sysfreq.h" #include "hal_timer.h" #include "hal_trace.h" -#include "cmsis_nvic.h" #include "pmu.h" #include "system_cp.h" @@ -40,72 +40,75 @@ #define CODEC_CLK_FROM_ANA -#define HAL_CMU_USB_PLL_CLOCK (192 * 1000 * 1000) -#define HAL_CMU_AUD_PLL_CLOCK (CODEC_FREQ_48K_SERIES * CODEC_CMU_DIV) +#define HAL_CMU_USB_PLL_CLOCK (192 * 1000 * 1000) +#define HAL_CMU_AUD_PLL_CLOCK (CODEC_FREQ_48K_SERIES * CODEC_CMU_DIV) -#define HAL_CMU_USB_CLOCK_60M (60 * 1000 * 1000) -#define HAL_CMU_USB_CLOCK_48M (48 * 1000 * 1000) +#define HAL_CMU_USB_CLOCK_60M (60 * 1000 * 1000) +#define HAL_CMU_USB_CLOCK_48M (48 * 1000 * 1000) -#define HAL_CMU_PLL_LOCKED_TIMEOUT US_TO_TICKS(200) -#define HAL_CMU_26M_READY_TIMEOUT MS_TO_TICKS(4) -#define HAL_CMU_LPU_EXTRA_TIMEOUT MS_TO_TICKS(1) +#define HAL_CMU_PLL_LOCKED_TIMEOUT US_TO_TICKS(200) +#define HAL_CMU_26M_READY_TIMEOUT MS_TO_TICKS(4) +#define HAL_CMU_LPU_EXTRA_TIMEOUT MS_TO_TICKS(1) #ifdef CORE_SLEEP_POWER_DOWN -#define TIMER1_SEL_LOC BOOT_TEXT_SRAM_LOC +#define TIMER1_SEL_LOC BOOT_TEXT_SRAM_LOC #else -#define TIMER1_SEL_LOC BOOT_TEXT_FLASH_LOC +#define TIMER1_SEL_LOC BOOT_TEXT_FLASH_LOC #endif enum CMU_USB_CLK_SRC_T { - CMU_USB_CLK_SRC_PLL_60M = 0, - CMU_USB_CLK_SRC_PLL_60M_ALT = 1, - CMU_USB_CLK_SRC_PLL_48M = 2, - CMU_USB_CLK_SRC_TS = 3, - CMU_USB_CLK_SRC_OSC_48M = 4, - CMU_USB_CLK_SRC_OSC_24M_X2 = 5, - CMU_USB_CLK_SRC_OSC_26M_X4 = 6, - CMU_USB_CLK_SRC_OSC_26M_X2 = 7, + CMU_USB_CLK_SRC_PLL_60M = 0, + CMU_USB_CLK_SRC_PLL_60M_ALT = 1, + CMU_USB_CLK_SRC_PLL_48M = 2, + CMU_USB_CLK_SRC_TS = 3, + CMU_USB_CLK_SRC_OSC_48M = 4, + CMU_USB_CLK_SRC_OSC_24M_X2 = 5, + CMU_USB_CLK_SRC_OSC_26M_X4 = 6, + CMU_USB_CLK_SRC_OSC_26M_X2 = 7, }; enum CMU_AUD_26M_X4_USER_T { - CMU_AUD_26M_X4_USER_IIR, - CMU_AUD_26M_X4_USER_RS, + CMU_AUD_26M_X4_USER_IIR, + CMU_AUD_26M_X4_USER_RS, - CMU_AUD_26M_X4_USER_QTY, + CMU_AUD_26M_X4_USER_QTY, }; enum CMU_DEBUG_REG_SEL_T { - CMU_DEBUG_REG_SEL_MCU_PC = 0, - CMU_DEBUG_REG_SEL_MCU_LR = 1, - CMU_DEBUG_REG_SEL_MCU_SP = 2, - CMU_DEBUG_REG_SEL_CP_PC = 3, - CMU_DEBUG_REG_SEL_CP_LR = 4, - CMU_DEBUG_REG_SEL_CP_SP = 5, - CMU_DEBUG_REG_SEL_DEBUG = 7, + CMU_DEBUG_REG_SEL_MCU_PC = 0, + CMU_DEBUG_REG_SEL_MCU_LR = 1, + CMU_DEBUG_REG_SEL_MCU_SP = 2, + CMU_DEBUG_REG_SEL_CP_PC = 3, + CMU_DEBUG_REG_SEL_CP_LR = 4, + CMU_DEBUG_REG_SEL_CP_SP = 5, + CMU_DEBUG_REG_SEL_DEBUG = 7, }; struct CP_STARTUP_CFG_T { - __IO uint32_t stack; - __IO uint32_t reset_hdlr; - __IO uint32_t entry; + __IO uint32_t stack; + __IO uint32_t reset_hdlr; + __IO uint32_t entry; }; -static struct CMU_T * const cmu = (struct CMU_T *)CMU_BASE; +static struct CMU_T *const cmu = (struct CMU_T *)CMU_BASE; -static struct AONCMU_T * const aoncmu = (struct AONCMU_T *)AON_CMU_BASE; +static struct AONCMU_T *const aoncmu = (struct AONCMU_T *)AON_CMU_BASE; -static struct BTCMU_T * const POSSIBLY_UNUSED btcmu = (struct BTCMU_T *)BT_CMU_BASE; +static struct BTCMU_T *const POSSIBLY_UNUSED btcmu = + (struct BTCMU_T *)BT_CMU_BASE; -static struct CP_STARTUP_CFG_T * const cp_cfg = (struct CP_STARTUP_CFG_T *)0x200F7FE0; +static struct CP_STARTUP_CFG_T *const cp_cfg = + (struct CP_STARTUP_CFG_T *)0x200F7FE0; -#define HAL_CMU_PLL_USB_HS HAL_CMU_PLL_QTY +#define HAL_CMU_PLL_USB_HS HAL_CMU_PLL_QTY #ifdef USB_USE_USBPLL -#define PLL_USER_MAP_NUM (HAL_CMU_PLL_QTY + 1) +#define PLL_USER_MAP_NUM (HAL_CMU_PLL_QTY + 1) #else -#define PLL_USER_MAP_NUM HAL_CMU_PLL_QTY +#define PLL_USER_MAP_NUM HAL_CMU_PLL_QTY #endif static uint8_t BOOT_BSS_LOC pll_user_map[PLL_USER_MAP_NUM]; -STATIC_ASSERT(HAL_CMU_PLL_USER_QTY <= sizeof(pll_user_map[0]) * 8, "Too many PLL users"); +STATIC_ASSERT(HAL_CMU_PLL_USER_QTY <= sizeof(pll_user_map[0]) * 8, + "Too many PLL users"); #ifdef ROM_BUILD static enum HAL_CMU_USB_CLOCK_SEL_T usb_clk_sel; @@ -117,7 +120,8 @@ static bool anc_enabled; static bool aud_resample_en = true; #ifdef ANA_26M_X4_ENABLE static uint8_t aud_26m_x4_map; -STATIC_ASSERT(CMU_AUD_26M_X4_USER_QTY <= sizeof(aud_26m_x4_map) * 8, "Too many aud_26m_x4 users"); +STATIC_ASSERT(CMU_AUD_26M_X4_USER_QTY <= sizeof(aud_26m_x4_map) * 8, + "Too many aud_26m_x4 users"); #endif #endif @@ -126,1577 +130,1530 @@ static enum HAL_CMU_LOW_SYS_FREQ_T BOOT_BSS_LOC low_sys_freq; static bool BOOT_BSS_LOC low_sys_freq_en; #endif -void hal_cmu_audio_resample_enable(void) -{ +void hal_cmu_audio_resample_enable(void) { #ifdef __AUDIO_RESAMPLE__ - aud_resample_en = true; + aud_resample_en = true; #endif } -void hal_cmu_audio_resample_disable(void) -{ +void hal_cmu_audio_resample_disable(void) { #ifdef __AUDIO_RESAMPLE__ - aud_resample_en = false; + aud_resample_en = false; #endif } -int hal_cmu_get_audio_resample_status(void) -{ +int hal_cmu_get_audio_resample_status(void) { #ifdef __AUDIO_RESAMPLE__ - return aud_resample_en; + return aud_resample_en; #else - return false; + return false; #endif } -static inline void aocmu_reg_update_wait(void) -{ - // Make sure AOCMU (26M clock domain) write opertions finish before return +static inline void aocmu_reg_update_wait(void) { + // Make sure AOCMU (26M clock domain) write opertions finish before return + aoncmu->CHIP_ID; +} + +int hal_cmu_clock_enable(enum HAL_CMU_MOD_ID_T id) { + if (id >= HAL_CMU_AON_MCU) { + return 1; + } + + if (id < HAL_CMU_MOD_P_CMU) { + cmu->HCLK_ENABLE = (1 << id); + } else if (id < HAL_CMU_MOD_O_SLEEP) { + cmu->PCLK_ENABLE = (1 << (id - HAL_CMU_MOD_P_CMU)); + } else if (id < HAL_CMU_AON_A_CMU) { + cmu->OCLK_ENABLE = (1 << (id - HAL_CMU_MOD_O_SLEEP)); + } else { + aoncmu->MOD_CLK_ENABLE = (1 << (id - HAL_CMU_AON_A_CMU)); + aocmu_reg_update_wait(); + } + + return 0; +} + +int hal_cmu_clock_disable(enum HAL_CMU_MOD_ID_T id) { + if (id >= HAL_CMU_AON_MCU) { + return 1; + } + + if (id < HAL_CMU_MOD_P_CMU) { + cmu->HCLK_DISABLE = (1 << id); + } else if (id < HAL_CMU_MOD_O_SLEEP) { + cmu->PCLK_DISABLE = (1 << (id - HAL_CMU_MOD_P_CMU)); + } else if (id < HAL_CMU_AON_A_CMU) { + cmu->OCLK_DISABLE = (1 << (id - HAL_CMU_MOD_O_SLEEP)); + } else { + aoncmu->MOD_CLK_DISABLE = (1 << (id - HAL_CMU_AON_A_CMU)); + } + + return 0; +} + +enum HAL_CMU_CLK_STATUS_T hal_cmu_clock_get_status(enum HAL_CMU_MOD_ID_T id) { + uint32_t status; + + if (id >= HAL_CMU_AON_MCU) { + return HAL_CMU_CLK_DISABLED; + } + + if (id < HAL_CMU_MOD_P_CMU) { + status = cmu->HCLK_ENABLE & (1 << id); + } else if (id < HAL_CMU_MOD_O_SLEEP) { + status = cmu->PCLK_ENABLE & (1 << (id - HAL_CMU_MOD_P_CMU)); + } else if (id < HAL_CMU_AON_A_CMU) { + status = cmu->OCLK_ENABLE & (1 << (id - HAL_CMU_MOD_O_SLEEP)); + } else { + status = aoncmu->MOD_CLK_ENABLE & (1 << (id - HAL_CMU_AON_A_CMU)); + } + + return status ? HAL_CMU_CLK_ENABLED : HAL_CMU_CLK_DISABLED; +} + +int hal_cmu_clock_set_mode(enum HAL_CMU_MOD_ID_T id, + enum HAL_CMU_CLK_MODE_T mode) { + __IO uint32_t *reg; + uint32_t val; + uint32_t lock; + + if (id >= HAL_CMU_AON_MCU) { + return 1; + } + + if (id < HAL_CMU_MOD_P_CMU) { + reg = &cmu->HCLK_MODE; + val = (1 << id); + } else if (id < HAL_CMU_MOD_O_SLEEP) { + reg = &cmu->PCLK_MODE; + val = (1 << (id - HAL_CMU_MOD_P_CMU)); + } else if (id < HAL_CMU_AON_A_CMU) { + reg = &cmu->OCLK_MODE; + val = (1 << (id - HAL_CMU_MOD_O_SLEEP)); + } else { + reg = &aoncmu->MOD_CLK_MODE; + val = (1 << (id - HAL_CMU_AON_A_CMU)); + } + + lock = int_lock(); + if (mode == HAL_CMU_CLK_MANUAL) { + *reg |= val; + } else { + *reg &= ~val; + } + int_unlock(lock); + + return 0; +} + +enum HAL_CMU_CLK_MODE_T hal_cmu_clock_get_mode(enum HAL_CMU_MOD_ID_T id) { + uint32_t mode; + + if (id >= HAL_CMU_AON_MCU) { + return HAL_CMU_CLK_AUTO; + } + + if (id < HAL_CMU_MOD_P_CMU) { + mode = cmu->HCLK_MODE & (1 << id); + } else if (id < HAL_CMU_MOD_O_SLEEP) { + mode = cmu->PCLK_MODE & (1 << (id - HAL_CMU_MOD_P_CMU)); + } else if (id < HAL_CMU_AON_A_CMU) { + mode = cmu->OCLK_MODE & (1 << (id - HAL_CMU_MOD_O_SLEEP)); + } else { + mode = aoncmu->MOD_CLK_MODE & (1 << (id - HAL_CMU_AON_A_CMU)); + } + + return mode ? HAL_CMU_CLK_MANUAL : HAL_CMU_CLK_AUTO; +} + +int hal_cmu_reset_set(enum HAL_CMU_MOD_ID_T id) { + if (id >= HAL_CMU_MOD_QTY) { + return 1; + } + + if (id < HAL_CMU_MOD_P_CMU) { + cmu->HRESET_SET = (1 << id); + } else if (id < HAL_CMU_MOD_O_SLEEP) { + cmu->PRESET_SET = (1 << (id - HAL_CMU_MOD_P_CMU)); + } else if (id < HAL_CMU_AON_A_CMU) { + cmu->ORESET_SET = (1 << (id - HAL_CMU_MOD_O_SLEEP)); + } else { + aoncmu->RESET_SET = (1 << (id - HAL_CMU_AON_A_CMU)); + } + + return 0; +} + +int hal_cmu_reset_clear(enum HAL_CMU_MOD_ID_T id) { + if (id >= HAL_CMU_MOD_QTY) { + return 1; + } + + if (id < HAL_CMU_MOD_P_CMU) { + cmu->HRESET_CLR = (1 << id); + asm volatile("nop; nop;"); + } else if (id < HAL_CMU_MOD_O_SLEEP) { + cmu->PRESET_CLR = (1 << (id - HAL_CMU_MOD_P_CMU)); + asm volatile("nop; nop; nop; nop;"); + } else if (id < HAL_CMU_AON_A_CMU) { + cmu->ORESET_CLR = (1 << (id - HAL_CMU_MOD_O_SLEEP)); + } else { + aoncmu->RESET_CLR = (1 << (id - HAL_CMU_AON_A_CMU)); + aocmu_reg_update_wait(); + } + + return 0; +} + +enum HAL_CMU_RST_STATUS_T hal_cmu_reset_get_status(enum HAL_CMU_MOD_ID_T id) { + uint32_t status; + + if (id >= HAL_CMU_MOD_QTY) { + return HAL_CMU_RST_SET; + } + + if (id < HAL_CMU_MOD_P_CMU) { + status = cmu->HRESET_SET & (1 << id); + } else if (id < HAL_CMU_MOD_O_SLEEP) { + status = cmu->PRESET_SET & (1 << (id - HAL_CMU_MOD_P_CMU)); + } else if (id < HAL_CMU_AON_A_CMU) { + status = cmu->ORESET_SET & (1 << (id - HAL_CMU_MOD_O_SLEEP)); + } else { + status = aoncmu->RESET_SET & (1 << (id - HAL_CMU_AON_A_CMU)); + } + + return status ? HAL_CMU_RST_CLR : HAL_CMU_RST_SET; +} + +int hal_cmu_reset_pulse(enum HAL_CMU_MOD_ID_T id) { + volatile int i; + + if (id >= HAL_CMU_MOD_QTY) { + return 1; + } + + if (hal_cmu_reset_get_status(id) == HAL_CMU_RST_SET) { + return hal_cmu_reset_clear(id); + } + + if (id < HAL_CMU_MOD_P_CMU) { + cmu->HRESET_PULSE = (1 << id); + } else if (id < HAL_CMU_MOD_O_SLEEP) { + cmu->PRESET_PULSE = (1 << (id - HAL_CMU_MOD_P_CMU)); + } else if (id < HAL_CMU_AON_A_CMU) { + cmu->ORESET_PULSE = (1 << (id - HAL_CMU_MOD_O_SLEEP)); + } else { + aoncmu->RESET_PULSE = (1 << (id - HAL_CMU_AON_A_CMU)); + // Total 3 CLK-26M cycles needed + // AOCMU runs in 26M clock domain and its read operations consume at least 1 + // 26M-clock cycle. (Whereas its write operations will finish at 1 HCLK + // cycle -- finish once in async bridge fifo) aoncmu->CHIP_ID; + aoncmu->CHIP_ID; + aoncmu->CHIP_ID; + } + // Delay 5+ PCLK cycles (10+ HCLK cycles) + for (i = 0; i < 3; i++) + ; + + return 0; } -int hal_cmu_clock_enable(enum HAL_CMU_MOD_ID_T id) -{ - if (id >= HAL_CMU_AON_MCU) { - return 1; - } +int hal_cmu_timer_set_div(enum HAL_CMU_TIMER_ID_T id, uint32_t div) { + uint32_t lock; - if (id < HAL_CMU_MOD_P_CMU) { - cmu->HCLK_ENABLE = (1 << id); - } else if (id < HAL_CMU_MOD_O_SLEEP) { - cmu->PCLK_ENABLE = (1 << (id - HAL_CMU_MOD_P_CMU)); - } else if (id < HAL_CMU_AON_A_CMU) { - cmu->OCLK_ENABLE = (1 << (id - HAL_CMU_MOD_O_SLEEP)); - } else { - aoncmu->MOD_CLK_ENABLE = (1 << (id - HAL_CMU_AON_A_CMU)); - aocmu_reg_update_wait(); - } + if (div < 1) { + return 1; + } - return 0; + div -= 1; + if ((div & (CMU_CFG_DIV_TIMER00_MASK >> CMU_CFG_DIV_TIMER00_SHIFT)) != div) { + return 1; + } + + lock = int_lock(); + if (id == HAL_CMU_TIMER_ID_00) { + cmu->TIMER0_CLK = SET_BITFIELD(cmu->TIMER0_CLK, CMU_CFG_DIV_TIMER00, div); + } else if (id == HAL_CMU_TIMER_ID_01) { + cmu->TIMER0_CLK = SET_BITFIELD(cmu->TIMER0_CLK, CMU_CFG_DIV_TIMER01, div); + } else if (id == HAL_CMU_TIMER_ID_10) { + cmu->TIMER1_CLK = SET_BITFIELD(cmu->TIMER1_CLK, CMU_CFG_DIV_TIMER10, div); + } else if (id == HAL_CMU_TIMER_ID_11) { + cmu->TIMER1_CLK = SET_BITFIELD(cmu->TIMER1_CLK, CMU_CFG_DIV_TIMER11, div); + } else if (id == HAL_CMU_TIMER_ID_20) { + cmu->TIMER2_CLK = SET_BITFIELD(cmu->TIMER2_CLK, CMU_CFG_DIV_TIMER20, div); + } else if (id == HAL_CMU_TIMER_ID_21) { + cmu->TIMER2_CLK = SET_BITFIELD(cmu->TIMER2_CLK, CMU_CFG_DIV_TIMER21, div); + } + int_unlock(lock); + + return 0; } -int hal_cmu_clock_disable(enum HAL_CMU_MOD_ID_T id) -{ - if (id >= HAL_CMU_AON_MCU) { - return 1; - } +void BOOT_TEXT_FLASH_LOC hal_cmu_timer0_select_fast(void) { + uint32_t lock; - if (id < HAL_CMU_MOD_P_CMU) { - cmu->HCLK_DISABLE = (1 << id); - } else if (id < HAL_CMU_MOD_O_SLEEP) { - cmu->PCLK_DISABLE = (1 << (id - HAL_CMU_MOD_P_CMU)); - } else if (id < HAL_CMU_AON_A_CMU) { - cmu->OCLK_DISABLE = (1 << (id - HAL_CMU_MOD_O_SLEEP)); - } else { - aoncmu->MOD_CLK_DISABLE = (1 << (id - HAL_CMU_AON_A_CMU)); - } - - return 0; + lock = int_lock(); + // 6.5M + cmu->PERIPH_CLK |= (1 << CMU_SEL_TIMER_FAST_SHIFT); + // AON Timer + aoncmu->CLK_SELECT |= AON_CMU_SEL_TIMER_FAST; + int_unlock(lock); } -enum HAL_CMU_CLK_STATUS_T hal_cmu_clock_get_status(enum HAL_CMU_MOD_ID_T id) -{ - uint32_t status; +void BOOT_TEXT_FLASH_LOC hal_cmu_timer0_select_slow(void) { + uint32_t lock; - if (id >= HAL_CMU_AON_MCU) { - return HAL_CMU_CLK_DISABLED; - } - - if (id < HAL_CMU_MOD_P_CMU) { - status = cmu->HCLK_ENABLE & (1 << id); - } else if (id < HAL_CMU_MOD_O_SLEEP) { - status = cmu->PCLK_ENABLE & (1 << (id - HAL_CMU_MOD_P_CMU)); - } else if (id < HAL_CMU_AON_A_CMU) { - status = cmu->OCLK_ENABLE & (1 << (id - HAL_CMU_MOD_O_SLEEP)); - } else { - status = aoncmu->MOD_CLK_ENABLE & (1 << (id - HAL_CMU_AON_A_CMU)); - } - - return status ? HAL_CMU_CLK_ENABLED : HAL_CMU_CLK_DISABLED; + lock = int_lock(); + // 16K + cmu->PERIPH_CLK &= ~(1 << CMU_SEL_TIMER_FAST_SHIFT); + // AON Timer + aoncmu->CLK_SELECT &= ~AON_CMU_SEL_TIMER_FAST; + int_unlock(lock); } -int hal_cmu_clock_set_mode(enum HAL_CMU_MOD_ID_T id, enum HAL_CMU_CLK_MODE_T mode) -{ - __IO uint32_t *reg; - uint32_t val; - uint32_t lock; +void TIMER1_SEL_LOC hal_cmu_timer1_select_fast(void) { + uint32_t lock; - if (id >= HAL_CMU_AON_MCU) { - return 1; - } - - if (id < HAL_CMU_MOD_P_CMU) { - reg = &cmu->HCLK_MODE; - val = (1 << id); - } else if (id < HAL_CMU_MOD_O_SLEEP) { - reg = &cmu->PCLK_MODE; - val = (1 << (id - HAL_CMU_MOD_P_CMU)); - } else if (id < HAL_CMU_AON_A_CMU) { - reg = &cmu->OCLK_MODE; - val = (1 << (id - HAL_CMU_MOD_O_SLEEP)); - } else { - reg = &aoncmu->MOD_CLK_MODE; - val = (1 << (id - HAL_CMU_AON_A_CMU)); - } - - lock = int_lock(); - if (mode == HAL_CMU_CLK_MANUAL) { - *reg |= val; - } else { - *reg &= ~val; - } - int_unlock(lock); - - return 0; + lock = int_lock(); + // 6.5M + cmu->PERIPH_CLK |= (1 << (CMU_SEL_TIMER_FAST_SHIFT + 1)); + int_unlock(lock); } -enum HAL_CMU_CLK_MODE_T hal_cmu_clock_get_mode(enum HAL_CMU_MOD_ID_T id) -{ - uint32_t mode; +void TIMER1_SEL_LOC hal_cmu_timer1_select_slow(void) { + uint32_t lock; - if (id >= HAL_CMU_AON_MCU) { - return HAL_CMU_CLK_AUTO; - } - - if (id < HAL_CMU_MOD_P_CMU) { - mode = cmu->HCLK_MODE & (1 << id); - } else if (id < HAL_CMU_MOD_O_SLEEP) { - mode = cmu->PCLK_MODE & (1 << (id - HAL_CMU_MOD_P_CMU)); - } else if (id < HAL_CMU_AON_A_CMU) { - mode = cmu->OCLK_MODE & (1 << (id - HAL_CMU_MOD_O_SLEEP)); - } else { - mode = aoncmu->MOD_CLK_MODE & (1 << (id - HAL_CMU_AON_A_CMU)); - } - - return mode ? HAL_CMU_CLK_MANUAL : HAL_CMU_CLK_AUTO; + lock = int_lock(); + // 16K + cmu->PERIPH_CLK &= ~(1 << (CMU_SEL_TIMER_FAST_SHIFT + 1)); + int_unlock(lock); } -int hal_cmu_reset_set(enum HAL_CMU_MOD_ID_T id) -{ - if (id >= HAL_CMU_MOD_QTY) { - return 1; - } +void hal_cmu_timer2_select_fast(void) { + uint32_t lock; - if (id < HAL_CMU_MOD_P_CMU) { - cmu->HRESET_SET = (1 << id); - } else if (id < HAL_CMU_MOD_O_SLEEP) { - cmu->PRESET_SET = (1 << (id - HAL_CMU_MOD_P_CMU)); - } else if (id < HAL_CMU_AON_A_CMU) { - cmu->ORESET_SET = (1 << (id - HAL_CMU_MOD_O_SLEEP)); - } else { - aoncmu->RESET_SET = (1 << (id - HAL_CMU_AON_A_CMU)); - } - - return 0; + lock = int_lock(); + // 6.5M + cmu->PERIPH_CLK |= (1 << (CMU_SEL_TIMER_FAST_SHIFT + 2)); + int_unlock(lock); } -int hal_cmu_reset_clear(enum HAL_CMU_MOD_ID_T id) -{ - if (id >= HAL_CMU_MOD_QTY) { - return 1; - } +void hal_cmu_timer2_select_slow(void) { + uint32_t lock; - if (id < HAL_CMU_MOD_P_CMU) { - cmu->HRESET_CLR = (1 << id); - asm volatile("nop; nop;"); - } else if (id < HAL_CMU_MOD_O_SLEEP) { - cmu->PRESET_CLR = (1 << (id - HAL_CMU_MOD_P_CMU)); - asm volatile("nop; nop; nop; nop;"); - } else if (id < HAL_CMU_AON_A_CMU) { - cmu->ORESET_CLR = (1 << (id - HAL_CMU_MOD_O_SLEEP)); - } else { - aoncmu->RESET_CLR = (1 << (id - HAL_CMU_AON_A_CMU)); - aocmu_reg_update_wait(); - } - - return 0; + lock = int_lock(); + // 16K + cmu->PERIPH_CLK &= ~(1 << (CMU_SEL_TIMER_FAST_SHIFT + 2)); + int_unlock(lock); } -enum HAL_CMU_RST_STATUS_T hal_cmu_reset_get_status(enum HAL_CMU_MOD_ID_T id) -{ - uint32_t status; - - if (id >= HAL_CMU_MOD_QTY) { - return HAL_CMU_RST_SET; - } - - if (id < HAL_CMU_MOD_P_CMU) { - status = cmu->HRESET_SET & (1 << id); - } else if (id < HAL_CMU_MOD_O_SLEEP) { - status = cmu->PRESET_SET & (1 << (id - HAL_CMU_MOD_P_CMU)); - } else if (id < HAL_CMU_AON_A_CMU) { - status = cmu->ORESET_SET & (1 << (id - HAL_CMU_MOD_O_SLEEP)); - } else { - status = aoncmu->RESET_SET & (1 << (id - HAL_CMU_AON_A_CMU)); - } - - return status ? HAL_CMU_RST_CLR : HAL_CMU_RST_SET; -} - -int hal_cmu_reset_pulse(enum HAL_CMU_MOD_ID_T id) -{ - volatile int i; - - if (id >= HAL_CMU_MOD_QTY) { - return 1; - } - - if (hal_cmu_reset_get_status(id) == HAL_CMU_RST_SET) { - return hal_cmu_reset_clear(id); - } - - if (id < HAL_CMU_MOD_P_CMU) { - cmu->HRESET_PULSE = (1 << id); - } else if (id < HAL_CMU_MOD_O_SLEEP) { - cmu->PRESET_PULSE = (1 << (id - HAL_CMU_MOD_P_CMU)); - } else if (id < HAL_CMU_AON_A_CMU) { - cmu->ORESET_PULSE = (1 << (id - HAL_CMU_MOD_O_SLEEP)); - } else { - aoncmu->RESET_PULSE = (1 << (id - HAL_CMU_AON_A_CMU)); - // Total 3 CLK-26M cycles needed - // AOCMU runs in 26M clock domain and its read operations consume at least 1 26M-clock cycle. - // (Whereas its write operations will finish at 1 HCLK cycle -- finish once in async bridge fifo) - aoncmu->CHIP_ID; - aoncmu->CHIP_ID; - aoncmu->CHIP_ID; - } - // Delay 5+ PCLK cycles (10+ HCLK cycles) - for (i = 0; i < 3; i++); - - return 0; -} - -int hal_cmu_timer_set_div(enum HAL_CMU_TIMER_ID_T id, uint32_t div) -{ - uint32_t lock; - - if (div < 1) { - return 1; - } - - div -= 1; - if ((div & (CMU_CFG_DIV_TIMER00_MASK >> CMU_CFG_DIV_TIMER00_SHIFT)) != div) { - return 1; - } - - lock = int_lock(); - if (id == HAL_CMU_TIMER_ID_00) { - cmu->TIMER0_CLK = SET_BITFIELD(cmu->TIMER0_CLK, CMU_CFG_DIV_TIMER00, div); - } else if (id == HAL_CMU_TIMER_ID_01) { - cmu->TIMER0_CLK = SET_BITFIELD(cmu->TIMER0_CLK, CMU_CFG_DIV_TIMER01, div); - } else if (id == HAL_CMU_TIMER_ID_10) { - cmu->TIMER1_CLK = SET_BITFIELD(cmu->TIMER1_CLK, CMU_CFG_DIV_TIMER10, div); - } else if (id == HAL_CMU_TIMER_ID_11) { - cmu->TIMER1_CLK = SET_BITFIELD(cmu->TIMER1_CLK, CMU_CFG_DIV_TIMER11, div); - } else if (id == HAL_CMU_TIMER_ID_20) { - cmu->TIMER2_CLK = SET_BITFIELD(cmu->TIMER2_CLK, CMU_CFG_DIV_TIMER20, div); - } else if (id == HAL_CMU_TIMER_ID_21) { - cmu->TIMER2_CLK = SET_BITFIELD(cmu->TIMER2_CLK, CMU_CFG_DIV_TIMER21, div); - } - int_unlock(lock); - - return 0; -} - -void BOOT_TEXT_FLASH_LOC hal_cmu_timer0_select_fast(void) -{ - uint32_t lock; - - lock = int_lock(); - // 6.5M - cmu->PERIPH_CLK |= (1 << CMU_SEL_TIMER_FAST_SHIFT); - // AON Timer - aoncmu->CLK_SELECT |= AON_CMU_SEL_TIMER_FAST; - int_unlock(lock); -} - -void BOOT_TEXT_FLASH_LOC hal_cmu_timer0_select_slow(void) -{ - uint32_t lock; - - lock = int_lock(); - // 16K - cmu->PERIPH_CLK &= ~(1 << CMU_SEL_TIMER_FAST_SHIFT); - // AON Timer - aoncmu->CLK_SELECT &= ~AON_CMU_SEL_TIMER_FAST; - int_unlock(lock); -} - -void TIMER1_SEL_LOC hal_cmu_timer1_select_fast(void) -{ - uint32_t lock; - - lock = int_lock(); - // 6.5M - cmu->PERIPH_CLK |= (1 << (CMU_SEL_TIMER_FAST_SHIFT + 1)); - int_unlock(lock); -} - -void TIMER1_SEL_LOC hal_cmu_timer1_select_slow(void) -{ - uint32_t lock; - - lock = int_lock(); - // 16K - cmu->PERIPH_CLK &= ~(1 << (CMU_SEL_TIMER_FAST_SHIFT + 1)); - int_unlock(lock); -} - -void hal_cmu_timer2_select_fast(void) -{ - uint32_t lock; - - lock = int_lock(); - // 6.5M - cmu->PERIPH_CLK |= (1 << (CMU_SEL_TIMER_FAST_SHIFT + 2)); - int_unlock(lock); -} - -void hal_cmu_timer2_select_slow(void) -{ - uint32_t lock; - - lock = int_lock(); - // 16K - cmu->PERIPH_CLK &= ~(1 << (CMU_SEL_TIMER_FAST_SHIFT + 2)); - int_unlock(lock); -} - -int hal_cmu_sdmmc_set_pll_div(uint32_t div) -{ - uint32_t lock; - if (div < 2) { - return 1; - } - div -= 2; - if ((div & (CMU_CFG_DIV_SDMMC_MASK >> CMU_CFG_DIV_SDMMC_SHIFT)) != div) { - return 1; - } - lock = int_lock(); - cmu->PERIPH_CLK = SET_BITFIELD(cmu->PERIPH_CLK, CMU_CFG_DIV_SDMMC, div) | - CMU_SEL_OSCX2_SDMMC | CMU_SEL_PLL_SDMMC | CMU_EN_PLL_SDMMC; - int_unlock(lock); - return 0; +int hal_cmu_sdmmc_set_pll_div(uint32_t div) { + uint32_t lock; + if (div < 2) { + return 1; + } + div -= 2; + if ((div & (CMU_CFG_DIV_SDMMC_MASK >> CMU_CFG_DIV_SDMMC_SHIFT)) != div) { + return 1; + } + lock = int_lock(); + cmu->PERIPH_CLK = SET_BITFIELD(cmu->PERIPH_CLK, CMU_CFG_DIV_SDMMC, div) | + CMU_SEL_OSCX2_SDMMC | CMU_SEL_PLL_SDMMC | CMU_EN_PLL_SDMMC; + int_unlock(lock); + return 0; } #ifdef OSC_26M_X4_AUD2BB // Any of 78M/104M/208M is changed to 26M x4 (104M) -#define SYS_SET_FREQ_FUNC(f, F, CLK_OV) \ -int hal_cmu_ ##f## _set_freq(enum HAL_CMU_FREQ_T freq) \ -{ \ - uint32_t enable; \ - uint32_t disable; \ - if (freq >= HAL_CMU_FREQ_QTY) { \ - return 1; \ - } \ - if (freq == HAL_CMU_FREQ_32K) { \ - enable = 0; \ - disable = CMU_SEL_OSC_ ##F## _DISABLE | CMU_SEL_OSCX2_ ##F## _DISABLE | \ - CMU_SEL_PLL_ ##F## _DISABLE | CMU_RSTN_DIV_ ##F## _DISABLE | CMU_BYPASS_DIV_ ##F## _DISABLE; \ - } else if (freq == HAL_CMU_FREQ_26M) { \ - enable = CMU_SEL_OSC_ ##F## _ENABLE; \ - disable = CMU_SEL_OSCX2_ ##F## _DISABLE | \ - CMU_SEL_PLL_ ##F## _DISABLE | CMU_RSTN_DIV_ ##F## _DISABLE | CMU_BYPASS_DIV_ ##F## _DISABLE; \ - } else if (freq == HAL_CMU_FREQ_52M) { \ - enable = CMU_SEL_OSCX2_ ##F## _ENABLE; \ - disable = CMU_SEL_PLL_ ##F## _DISABLE | CMU_RSTN_DIV_ ##F## _DISABLE | CMU_BYPASS_DIV_ ##F## _DISABLE; \ - } else { \ - enable = CMU_SEL_PLL_ ##F## _ENABLE | CMU_BYPASS_DIV_ ##F## _ENABLE; \ - disable = CMU_RSTN_DIV_ ##F## _DISABLE; \ - } \ - if (enable & CMU_SEL_PLL_ ##F## _ENABLE) { \ - CLK_OV; \ - cmu->SYS_CLK_ENABLE = CMU_RSTN_DIV_ ##F## _ENABLE; \ - if (enable & CMU_BYPASS_DIV_ ##F## _ENABLE) { \ - cmu->SYS_CLK_ENABLE = CMU_BYPASS_DIV_ ##F## _ENABLE; \ - } else { \ - cmu->SYS_CLK_DISABLE = CMU_BYPASS_DIV_ ##F## _DISABLE; \ - } \ - } \ - cmu->SYS_CLK_ENABLE = enable; \ - if (enable & CMU_SEL_PLL_ ##F## _ENABLE) { \ - cmu->SYS_CLK_DISABLE = disable; \ - } else { \ - cmu->SYS_CLK_DISABLE = disable & ~(CMU_RSTN_DIV_ ##F## _DISABLE | CMU_BYPASS_DIV_ ##F## _DISABLE); \ - cmu->SYS_CLK_DISABLE = CMU_BYPASS_DIV_ ##F## _DISABLE; \ - cmu->SYS_CLK_DISABLE = CMU_RSTN_DIV_ ##F## _DISABLE; \ - } \ - return 0; \ -} +#define SYS_SET_FREQ_FUNC(f, F, CLK_OV) \ + int hal_cmu_##f##_set_freq(enum HAL_CMU_FREQ_T freq) { \ + uint32_t enable; \ + uint32_t disable; \ + if (freq >= HAL_CMU_FREQ_QTY) { \ + return 1; \ + } \ + if (freq == HAL_CMU_FREQ_32K) { \ + enable = 0; \ + disable = CMU_SEL_OSC_##F##_DISABLE | CMU_SEL_OSCX2_##F##_DISABLE | \ + CMU_SEL_PLL_##F##_DISABLE | CMU_RSTN_DIV_##F##_DISABLE | \ + CMU_BYPASS_DIV_##F##_DISABLE; \ + } else if (freq == HAL_CMU_FREQ_26M) { \ + enable = CMU_SEL_OSC_##F##_ENABLE; \ + disable = CMU_SEL_OSCX2_##F##_DISABLE | CMU_SEL_PLL_##F##_DISABLE | \ + CMU_RSTN_DIV_##F##_DISABLE | CMU_BYPASS_DIV_##F##_DISABLE; \ + } else if (freq == HAL_CMU_FREQ_52M) { \ + enable = CMU_SEL_OSCX2_##F##_ENABLE; \ + disable = CMU_SEL_PLL_##F##_DISABLE | CMU_RSTN_DIV_##F##_DISABLE | \ + CMU_BYPASS_DIV_##F##_DISABLE; \ + } else { \ + enable = CMU_SEL_PLL_##F##_ENABLE | CMU_BYPASS_DIV_##F##_ENABLE; \ + disable = CMU_RSTN_DIV_##F##_DISABLE; \ + } \ + if (enable & CMU_SEL_PLL_##F##_ENABLE) { \ + CLK_OV; \ + cmu->SYS_CLK_ENABLE = CMU_RSTN_DIV_##F##_ENABLE; \ + if (enable & CMU_BYPASS_DIV_##F##_ENABLE) { \ + cmu->SYS_CLK_ENABLE = CMU_BYPASS_DIV_##F##_ENABLE; \ + } else { \ + cmu->SYS_CLK_DISABLE = CMU_BYPASS_DIV_##F##_DISABLE; \ + } \ + } \ + cmu->SYS_CLK_ENABLE = enable; \ + if (enable & CMU_SEL_PLL_##F##_ENABLE) { \ + cmu->SYS_CLK_DISABLE = disable; \ + } else { \ + cmu->SYS_CLK_DISABLE = disable & ~(CMU_RSTN_DIV_##F##_DISABLE | \ + CMU_BYPASS_DIV_##F##_DISABLE); \ + cmu->SYS_CLK_DISABLE = CMU_BYPASS_DIV_##F##_DISABLE; \ + cmu->SYS_CLK_DISABLE = CMU_RSTN_DIV_##F##_DISABLE; \ + } \ + return 0; \ + } #else // !OSC_26M_X4_AUD2BB -#define SYS_SET_FREQ_FUNC(f, F, CLK_OV) \ -int hal_cmu_ ##f## _set_freq(enum HAL_CMU_FREQ_T freq) \ -{ \ - uint32_t lock; \ - uint32_t enable; \ - uint32_t disable; \ - int div = -1; \ - if (freq >= HAL_CMU_FREQ_QTY) { \ - return 1; \ - } \ - if (freq == HAL_CMU_FREQ_32K) { \ - enable = 0; \ - disable = CMU_SEL_OSC_ ##F## _DISABLE | CMU_SEL_OSCX2_ ##F## _DISABLE | \ - CMU_SEL_PLL_ ##F## _DISABLE | CMU_RSTN_DIV_ ##F## _DISABLE | CMU_BYPASS_DIV_ ##F## _DISABLE; \ - } else if (freq == HAL_CMU_FREQ_26M) { \ - enable = CMU_SEL_OSC_ ##F## _ENABLE; \ - disable = CMU_SEL_OSCX2_ ##F## _DISABLE | \ - CMU_SEL_PLL_ ##F## _DISABLE | CMU_RSTN_DIV_ ##F## _DISABLE | CMU_BYPASS_DIV_ ##F## _DISABLE; \ - } else if (freq == HAL_CMU_FREQ_52M) { \ - enable = CMU_SEL_OSCX2_ ##F## _ENABLE; \ - disable = CMU_SEL_PLL_ ##F## _DISABLE | CMU_RSTN_DIV_ ##F## _DISABLE | CMU_BYPASS_DIV_ ##F## _DISABLE; \ - } else if (freq == HAL_CMU_FREQ_78M) { \ - enable = CMU_SEL_PLL_ ##F## _ENABLE | CMU_RSTN_DIV_ ##F## _ENABLE; \ - disable = CMU_BYPASS_DIV_ ##F## _DISABLE; \ - div = 1; \ - } else if (freq == HAL_CMU_FREQ_104M) { \ - enable = CMU_SEL_PLL_ ##F## _ENABLE | CMU_RSTN_DIV_ ##F## _ENABLE; \ - disable = CMU_BYPASS_DIV_ ##F## _DISABLE; \ - div = 0; \ - } else { \ - enable = CMU_SEL_PLL_ ##F## _ENABLE | CMU_BYPASS_DIV_ ##F## _ENABLE; \ - disable = CMU_RSTN_DIV_ ##F## _DISABLE; \ - } \ - if (div >= 0) { \ - CLK_OV; \ - lock = int_lock(); \ - cmu->SYS_DIV = SET_BITFIELD(cmu->SYS_DIV, CMU_CFG_DIV_ ##F, div); \ - int_unlock(lock); \ - } \ - if (enable & CMU_SEL_PLL_ ##F## _ENABLE) { \ - cmu->SYS_CLK_ENABLE = CMU_RSTN_DIV_ ##F## _ENABLE; \ - if (enable & CMU_BYPASS_DIV_ ##F## _ENABLE) { \ - cmu->SYS_CLK_ENABLE = CMU_BYPASS_DIV_ ##F## _ENABLE; \ - } else { \ - cmu->SYS_CLK_DISABLE = CMU_BYPASS_DIV_ ##F## _DISABLE; \ - } \ - } \ - cmu->SYS_CLK_ENABLE = enable; \ - if (enable & CMU_SEL_PLL_ ##F## _ENABLE) { \ - cmu->SYS_CLK_DISABLE = disable; \ - } else { \ - cmu->SYS_CLK_DISABLE = disable & ~(CMU_RSTN_DIV_ ##F## _DISABLE | CMU_BYPASS_DIV_ ##F## _DISABLE); \ - cmu->SYS_CLK_DISABLE = CMU_BYPASS_DIV_ ##F## _DISABLE; \ - cmu->SYS_CLK_DISABLE = CMU_RSTN_DIV_ ##F## _DISABLE; \ - } \ - return 0; \ -} +#define SYS_SET_FREQ_FUNC(f, F, CLK_OV) \ + int hal_cmu_##f##_set_freq(enum HAL_CMU_FREQ_T freq) { \ + uint32_t lock; \ + uint32_t enable; \ + uint32_t disable; \ + int div = -1; \ + if (freq >= HAL_CMU_FREQ_QTY) { \ + return 1; \ + } \ + if (freq == HAL_CMU_FREQ_32K) { \ + enable = 0; \ + disable = CMU_SEL_OSC_##F##_DISABLE | CMU_SEL_OSCX2_##F##_DISABLE | \ + CMU_SEL_PLL_##F##_DISABLE | CMU_RSTN_DIV_##F##_DISABLE | \ + CMU_BYPASS_DIV_##F##_DISABLE; \ + } else if (freq == HAL_CMU_FREQ_26M) { \ + enable = CMU_SEL_OSC_##F##_ENABLE; \ + disable = CMU_SEL_OSCX2_##F##_DISABLE | CMU_SEL_PLL_##F##_DISABLE | \ + CMU_RSTN_DIV_##F##_DISABLE | CMU_BYPASS_DIV_##F##_DISABLE; \ + } else if (freq == HAL_CMU_FREQ_52M) { \ + enable = CMU_SEL_OSCX2_##F##_ENABLE; \ + disable = CMU_SEL_PLL_##F##_DISABLE | CMU_RSTN_DIV_##F##_DISABLE | \ + CMU_BYPASS_DIV_##F##_DISABLE; \ + } else if (freq == HAL_CMU_FREQ_78M) { \ + enable = CMU_SEL_PLL_##F##_ENABLE | CMU_RSTN_DIV_##F##_ENABLE; \ + disable = CMU_BYPASS_DIV_##F##_DISABLE; \ + div = 1; \ + } else if (freq == HAL_CMU_FREQ_104M) { \ + enable = CMU_SEL_PLL_##F##_ENABLE | CMU_RSTN_DIV_##F##_ENABLE; \ + disable = CMU_BYPASS_DIV_##F##_DISABLE; \ + div = 0; \ + } else { \ + enable = CMU_SEL_PLL_##F##_ENABLE | CMU_BYPASS_DIV_##F##_ENABLE; \ + disable = CMU_RSTN_DIV_##F##_DISABLE; \ + } \ + if (div >= 0) { \ + CLK_OV; \ + lock = int_lock(); \ + cmu->SYS_DIV = SET_BITFIELD(cmu->SYS_DIV, CMU_CFG_DIV_##F, div); \ + int_unlock(lock); \ + } \ + if (enable & CMU_SEL_PLL_##F##_ENABLE) { \ + cmu->SYS_CLK_ENABLE = CMU_RSTN_DIV_##F##_ENABLE; \ + if (enable & CMU_BYPASS_DIV_##F##_ENABLE) { \ + cmu->SYS_CLK_ENABLE = CMU_BYPASS_DIV_##F##_ENABLE; \ + } else { \ + cmu->SYS_CLK_DISABLE = CMU_BYPASS_DIV_##F##_DISABLE; \ + } \ + } \ + cmu->SYS_CLK_ENABLE = enable; \ + if (enable & CMU_SEL_PLL_##F##_ENABLE) { \ + cmu->SYS_CLK_DISABLE = disable; \ + } else { \ + cmu->SYS_CLK_DISABLE = disable & ~(CMU_RSTN_DIV_##F##_DISABLE | \ + CMU_BYPASS_DIV_##F##_DISABLE); \ + cmu->SYS_CLK_DISABLE = CMU_BYPASS_DIV_##F##_DISABLE; \ + cmu->SYS_CLK_DISABLE = CMU_RSTN_DIV_##F##_DISABLE; \ + } \ + return 0; \ + } #endif // !OSC_26M_X4_AUD2BB #ifdef MCU_SYS_CLOCK_400M -#define FLASH_DIV_OFFSET 2 +#define FLASH_DIV_OFFSET 2 #elif defined(MCU_SYS_CLOCK_300M) -#define FLASH_DIV_OFFSET 1 +#define FLASH_DIV_OFFSET 1 #else -#define FLASH_DIV_OFFSET 0 +#define FLASH_DIV_OFFSET 0 #endif #ifdef OSC_26M_X4_AUD2BB -#define FLASH_FREQ_OV { aoncmu->CLK_OUT |= AON_CMU_SEL_X4_FLS; } +#define FLASH_FREQ_OV \ + { aoncmu->CLK_OUT |= AON_CMU_SEL_X4_FLS; } #else -#define FLASH_FREQ_OV { div += FLASH_DIV_OFFSET; } +#define FLASH_FREQ_OV \ + { div += FLASH_DIV_OFFSET; } #endif BOOT_TEXT_SRAM_LOC SYS_SET_FREQ_FUNC(flash, FLS, FLASH_FREQ_OV); #ifdef LOW_SYS_FREQ -void hal_cmu_low_sys_clock_set(enum HAL_CMU_LOW_SYS_FREQ_T freq) -{ - uint32_t lock; +void hal_cmu_low_sys_clock_set(enum HAL_CMU_LOW_SYS_FREQ_T freq) { + uint32_t lock; - if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_0) { - return; - } + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_0) { + return; + } - lock = int_lock(); - low_sys_freq = freq; - hal_cmu_sys_set_freq(hal_sysfreq_get_hw_freq()); - int_unlock(lock); + lock = int_lock(); + low_sys_freq = freq; + hal_cmu_sys_set_freq(hal_sysfreq_get_hw_freq()); + int_unlock(lock); } -int hal_cmu_fast_timer_offline(void) -{ - return low_sys_freq_en && low_sys_freq != HAL_CMU_LOW_SYS_FREQ_13M; +int hal_cmu_fast_timer_offline(void) { + return low_sys_freq_en && low_sys_freq != HAL_CMU_LOW_SYS_FREQ_13M; } -static void hal_cmu_osc_to_dig_x4_enable(void) -{ - aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_X4_ANA_ENABLE; - aoncmu->CLK_SELECT |= AON_CMU_SEL_X4_SYS; - aoncmu->CLK_SELECT |= AON_CMU_SEL_X4_DIG; - aoncmu->RESERVED_03C |= AON_CMU_OSC_TO_DIG_X4; +static void hal_cmu_osc_to_dig_x4_enable(void) { + aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_X4_ANA_ENABLE; + aoncmu->CLK_SELECT |= AON_CMU_SEL_X4_SYS; + aoncmu->CLK_SELECT |= AON_CMU_SEL_X4_DIG; + aoncmu->RESERVED_03C |= AON_CMU_OSC_TO_DIG_X4; } -static void hal_cmu_osc_to_dig_x4_disable(void) -{ - aoncmu->CLK_SELECT &= ~AON_CMU_SEL_X4_DIG; - aoncmu->RESERVED_03C &= ~AON_CMU_OSC_TO_DIG_X4; +static void hal_cmu_osc_to_dig_x4_disable(void) { + aoncmu->CLK_SELECT &= ~AON_CMU_SEL_X4_DIG; + aoncmu->RESERVED_03C &= ~AON_CMU_OSC_TO_DIG_X4; #ifndef OSC_26M_X4_AUD2BB - aoncmu->CLK_SELECT &= ~AON_CMU_SEL_X4_SYS; + aoncmu->CLK_SELECT &= ~AON_CMU_SEL_X4_SYS; #endif #ifndef ANA_26M_X4_ENABLE - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_X4_ANA_DISABLE; + aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_X4_ANA_DISABLE; #endif } -int hal_cmu_sys_set_freq(enum HAL_CMU_FREQ_T freq) -{ - uint32_t lock; - uint32_t enable; - uint32_t disable; - int div = -1; - bool low_sys_set, low_sys_clr; +int hal_cmu_sys_set_freq(enum HAL_CMU_FREQ_T freq) { + uint32_t lock; + uint32_t enable; + uint32_t disable; + int div = -1; + bool low_sys_set, low_sys_clr; - if (freq >= HAL_CMU_FREQ_QTY) { - return 1; + if (freq >= HAL_CMU_FREQ_QTY) { + return 1; + } + + low_sys_set = false; + low_sys_clr = false; + + lock = int_lock(); + + if (low_sys_freq == HAL_CMU_LOW_SYS_FREQ_NONE) { + if (aoncmu->RESERVED_03C & AON_CMU_OSC_TO_DIG_X4) { + low_sys_clr = true; } - - low_sys_set = false; - low_sys_clr = false; - - lock = int_lock(); - - if (low_sys_freq == HAL_CMU_LOW_SYS_FREQ_NONE) { - if (aoncmu->RESERVED_03C & AON_CMU_OSC_TO_DIG_X4) { - low_sys_clr = true; - } - } else { - if (freq == HAL_CMU_FREQ_26M) { - low_sys_set = true; - } else if (freq > HAL_CMU_FREQ_26M) { - if (aoncmu->RESERVED_03C & AON_CMU_OSC_TO_DIG_X4) { - low_sys_clr = true; - } - } + } else { + if (freq == HAL_CMU_FREQ_26M) { + low_sys_set = true; + } else if (freq > HAL_CMU_FREQ_26M) { + if (aoncmu->RESERVED_03C & AON_CMU_OSC_TO_DIG_X4) { + low_sys_clr = true; + } } + } - if (low_sys_clr) { - low_sys_freq_en = false; - cmu->SYS_CLK_ENABLE = CMU_SEL_OSC_SYS_ENABLE; - cmu->SYS_CLK_DISABLE = CMU_SEL_OSCX2_SYS_DISABLE | CMU_SEL_PLL_SYS_DISABLE; - hal_cmu_osc_to_dig_x4_disable(); - } - if (low_sys_set) { - low_sys_freq_en = true; - cmu->SYS_CLK_ENABLE = CMU_SEL_OSC_SYS_ENABLE; - cmu->SYS_CLK_DISABLE = CMU_SEL_OSCX2_SYS_DISABLE | CMU_SEL_PLL_SYS_DISABLE; - hal_cmu_osc_to_dig_x4_enable(); - freq = HAL_CMU_FREQ_208M; - } + if (low_sys_clr) { + low_sys_freq_en = false; + cmu->SYS_CLK_ENABLE = CMU_SEL_OSC_SYS_ENABLE; + cmu->SYS_CLK_DISABLE = CMU_SEL_OSCX2_SYS_DISABLE | CMU_SEL_PLL_SYS_DISABLE; + hal_cmu_osc_to_dig_x4_disable(); + } + if (low_sys_set) { + low_sys_freq_en = true; + cmu->SYS_CLK_ENABLE = CMU_SEL_OSC_SYS_ENABLE; + cmu->SYS_CLK_DISABLE = CMU_SEL_OSCX2_SYS_DISABLE | CMU_SEL_PLL_SYS_DISABLE; + hal_cmu_osc_to_dig_x4_enable(); + freq = HAL_CMU_FREQ_208M; + } - if (freq == HAL_CMU_FREQ_32K) { - enable = 0; - disable = CMU_SEL_OSC_SYS_DISABLE | CMU_SEL_OSCX2_SYS_DISABLE | - CMU_SEL_PLL_SYS_DISABLE | CMU_RSTN_DIV_SYS_DISABLE | CMU_BYPASS_DIV_SYS_DISABLE; - } else if (freq == HAL_CMU_FREQ_26M) { - enable = CMU_SEL_OSC_SYS_ENABLE; - disable = CMU_SEL_OSCX2_SYS_DISABLE | - CMU_SEL_PLL_SYS_DISABLE | CMU_RSTN_DIV_SYS_DISABLE | CMU_BYPASS_DIV_SYS_DISABLE; - } else if (freq == HAL_CMU_FREQ_52M) { - enable = CMU_SEL_OSCX2_SYS_ENABLE; - disable = CMU_SEL_PLL_SYS_DISABLE | CMU_RSTN_DIV_SYS_DISABLE | CMU_BYPASS_DIV_SYS_DISABLE; + if (freq == HAL_CMU_FREQ_32K) { + enable = 0; + disable = CMU_SEL_OSC_SYS_DISABLE | CMU_SEL_OSCX2_SYS_DISABLE | + CMU_SEL_PLL_SYS_DISABLE | CMU_RSTN_DIV_SYS_DISABLE | + CMU_BYPASS_DIV_SYS_DISABLE; + } else if (freq == HAL_CMU_FREQ_26M) { + enable = CMU_SEL_OSC_SYS_ENABLE; + disable = CMU_SEL_OSCX2_SYS_DISABLE | CMU_SEL_PLL_SYS_DISABLE | + CMU_RSTN_DIV_SYS_DISABLE | CMU_BYPASS_DIV_SYS_DISABLE; + } else if (freq == HAL_CMU_FREQ_52M) { + enable = CMU_SEL_OSCX2_SYS_ENABLE; + disable = CMU_SEL_PLL_SYS_DISABLE | CMU_RSTN_DIV_SYS_DISABLE | + CMU_BYPASS_DIV_SYS_DISABLE; #ifndef OSC_26M_X4_AUD2BB - } else if (freq == HAL_CMU_FREQ_78M) { - enable = CMU_SEL_PLL_SYS_ENABLE | CMU_RSTN_DIV_SYS_ENABLE; - disable = CMU_BYPASS_DIV_SYS_DISABLE; - div = 1; - } else if (freq == HAL_CMU_FREQ_104M) { - enable = CMU_SEL_PLL_SYS_ENABLE | CMU_RSTN_DIV_SYS_ENABLE; - disable = CMU_BYPASS_DIV_SYS_DISABLE; - div = 0; + } else if (freq == HAL_CMU_FREQ_78M) { + enable = CMU_SEL_PLL_SYS_ENABLE | CMU_RSTN_DIV_SYS_ENABLE; + disable = CMU_BYPASS_DIV_SYS_DISABLE; + div = 1; + } else if (freq == HAL_CMU_FREQ_104M) { + enable = CMU_SEL_PLL_SYS_ENABLE | CMU_RSTN_DIV_SYS_ENABLE; + disable = CMU_BYPASS_DIV_SYS_DISABLE; + div = 0; #endif - } else { - if (low_sys_set) { - if (low_sys_freq == HAL_CMU_LOW_SYS_FREQ_13M) { - enable = CMU_SEL_PLL_SYS_ENABLE | CMU_BYPASS_DIV_SYS_ENABLE; - disable = CMU_RSTN_DIV_SYS_DISABLE; - } else { - enable = CMU_SEL_PLL_SYS_ENABLE | CMU_RSTN_DIV_SYS_ENABLE; - disable = CMU_BYPASS_DIV_SYS_DISABLE; - if (low_sys_freq == HAL_CMU_LOW_SYS_FREQ_6P5M) { - div = 0; - } else if (low_sys_freq == HAL_CMU_LOW_SYS_FREQ_4P33M) { - div = 1; - } else { - div = 2; - } - } + } else { + if (low_sys_set) { + if (low_sys_freq == HAL_CMU_LOW_SYS_FREQ_13M) { + enable = CMU_SEL_PLL_SYS_ENABLE | CMU_BYPASS_DIV_SYS_ENABLE; + disable = CMU_RSTN_DIV_SYS_DISABLE; + } else { + enable = CMU_SEL_PLL_SYS_ENABLE | CMU_RSTN_DIV_SYS_ENABLE; + disable = CMU_BYPASS_DIV_SYS_DISABLE; + if (low_sys_freq == HAL_CMU_LOW_SYS_FREQ_6P5M) { + div = 0; + } else if (low_sys_freq == HAL_CMU_LOW_SYS_FREQ_4P33M) { + div = 1; } else { - enable = CMU_SEL_PLL_SYS_ENABLE | CMU_BYPASS_DIV_SYS_ENABLE; - disable = CMU_RSTN_DIV_SYS_DISABLE; + div = 2; } - } - if (div >= 0) { - cmu->SYS_DIV = SET_BITFIELD(cmu->SYS_DIV, CMU_CFG_DIV_SYS, div); - } - if (enable & CMU_SEL_PLL_SYS_ENABLE) { - cmu->SYS_CLK_ENABLE = CMU_RSTN_DIV_SYS_ENABLE; - if (enable & CMU_BYPASS_DIV_SYS_ENABLE) { - cmu->SYS_CLK_ENABLE = CMU_BYPASS_DIV_SYS_ENABLE; - } else { - cmu->SYS_CLK_DISABLE = CMU_BYPASS_DIV_SYS_DISABLE; - } - } - cmu->SYS_CLK_ENABLE = enable; - if (enable & CMU_SEL_PLL_SYS_ENABLE) { - cmu->SYS_CLK_DISABLE = disable; + } } else { - cmu->SYS_CLK_DISABLE = disable & ~(CMU_RSTN_DIV_SYS_DISABLE | CMU_BYPASS_DIV_SYS_DISABLE); - cmu->SYS_CLK_DISABLE = CMU_BYPASS_DIV_SYS_DISABLE; - cmu->SYS_CLK_DISABLE = CMU_RSTN_DIV_SYS_DISABLE; + enable = CMU_SEL_PLL_SYS_ENABLE | CMU_BYPASS_DIV_SYS_ENABLE; + disable = CMU_RSTN_DIV_SYS_DISABLE; } + } + if (div >= 0) { + cmu->SYS_DIV = SET_BITFIELD(cmu->SYS_DIV, CMU_CFG_DIV_SYS, div); + } + if (enable & CMU_SEL_PLL_SYS_ENABLE) { + cmu->SYS_CLK_ENABLE = CMU_RSTN_DIV_SYS_ENABLE; + if (enable & CMU_BYPASS_DIV_SYS_ENABLE) { + cmu->SYS_CLK_ENABLE = CMU_BYPASS_DIV_SYS_ENABLE; + } else { + cmu->SYS_CLK_DISABLE = CMU_BYPASS_DIV_SYS_DISABLE; + } + } + cmu->SYS_CLK_ENABLE = enable; + if (enable & CMU_SEL_PLL_SYS_ENABLE) { + cmu->SYS_CLK_DISABLE = disable; + } else { + cmu->SYS_CLK_DISABLE = + disable & ~(CMU_RSTN_DIV_SYS_DISABLE | CMU_BYPASS_DIV_SYS_DISABLE); + cmu->SYS_CLK_DISABLE = CMU_BYPASS_DIV_SYS_DISABLE; + cmu->SYS_CLK_DISABLE = CMU_RSTN_DIV_SYS_DISABLE; + } - int_unlock(lock); + int_unlock(lock); - return 0; + return 0; } #else SYS_SET_FREQ_FUNC(sys, SYS, {}); #endif -int hal_cmu_mem_set_freq(enum HAL_CMU_FREQ_T freq) -{ - return 0; -} +int hal_cmu_mem_set_freq(enum HAL_CMU_FREQ_T freq) { return 0; } -enum HAL_CMU_FREQ_T BOOT_TEXT_SRAM_LOC hal_cmu_sys_get_freq(void) -{ - uint32_t sys_clk; - uint32_t div; +enum HAL_CMU_FREQ_T BOOT_TEXT_SRAM_LOC hal_cmu_sys_get_freq(void) { + uint32_t sys_clk; + uint32_t div; - sys_clk = cmu->SYS_CLK_ENABLE; + sys_clk = cmu->SYS_CLK_ENABLE; - if (sys_clk & CMU_SEL_PLL_SYS_ENABLE) { - if (sys_clk & CMU_BYPASS_DIV_SYS_ENABLE) { - return HAL_CMU_FREQ_208M; - } else { - div = GET_BITFIELD(cmu->SYS_DIV, CMU_CFG_DIV_SYS); - if (div == 0) { - return HAL_CMU_FREQ_104M; - } else if (div == 1) { - // (div == 1): 69M - return HAL_CMU_FREQ_78M; - } else { - // (div == 2): 52M - // (div == 3): 42M - return HAL_CMU_FREQ_52M; - } - } - } else if (sys_clk & CMU_SEL_OSCX2_SYS_ENABLE) { - return HAL_CMU_FREQ_52M; - } else if (sys_clk & CMU_SEL_OSC_SYS_ENABLE) { - return HAL_CMU_FREQ_26M; + if (sys_clk & CMU_SEL_PLL_SYS_ENABLE) { + if (sys_clk & CMU_BYPASS_DIV_SYS_ENABLE) { + return HAL_CMU_FREQ_208M; } else { - return HAL_CMU_FREQ_32K; + div = GET_BITFIELD(cmu->SYS_DIV, CMU_CFG_DIV_SYS); + if (div == 0) { + return HAL_CMU_FREQ_104M; + } else if (div == 1) { + // (div == 1): 69M + return HAL_CMU_FREQ_78M; + } else { + // (div == 2): 52M + // (div == 3): 42M + return HAL_CMU_FREQ_52M; + } } + } else if (sys_clk & CMU_SEL_OSCX2_SYS_ENABLE) { + return HAL_CMU_FREQ_52M; + } else if (sys_clk & CMU_SEL_OSC_SYS_ENABLE) { + return HAL_CMU_FREQ_26M; + } else { + return HAL_CMU_FREQ_32K; + } } -int BOOT_TEXT_SRAM_LOC hal_cmu_flash_select_pll(enum HAL_CMU_PLL_T pll) -{ - return hal_cmu_sys_select_pll(pll); +int BOOT_TEXT_SRAM_LOC hal_cmu_flash_select_pll(enum HAL_CMU_PLL_T pll) { + return hal_cmu_sys_select_pll(pll); } -int hal_cmu_mem_select_pll(enum HAL_CMU_PLL_T pll) -{ - return hal_cmu_sys_select_pll(pll); +int hal_cmu_mem_select_pll(enum HAL_CMU_PLL_T pll) { + return hal_cmu_sys_select_pll(pll); } // hal_cmu_flash_select_pll() requires in BOOT_TEXT_SRAM_LOC -int BOOT_TEXT_SRAM_LOC hal_cmu_sys_select_pll(enum HAL_CMU_PLL_T pll) -{ - uint32_t lock; - uint32_t sel; +int BOOT_TEXT_SRAM_LOC hal_cmu_sys_select_pll(enum HAL_CMU_PLL_T pll) { + uint32_t lock; + uint32_t sel; - if (pll >= HAL_CMU_PLL_QTY) { - return 1; - } + if (pll >= HAL_CMU_PLL_QTY) { + return 1; + } - lock = int_lock(); - // 0/1:bbpll, 2:audpll, 3:usbpll - sel = (pll == HAL_CMU_PLL_AUD) ? 2 : 0; - aoncmu->CLK_SELECT = SET_BITFIELD(aoncmu->CLK_SELECT, AON_CMU_SEL_PLL_SYS, sel); - int_unlock(lock); + lock = int_lock(); + // 0/1:bbpll, 2:audpll, 3:usbpll + sel = (pll == HAL_CMU_PLL_AUD) ? 2 : 0; + aoncmu->CLK_SELECT = + SET_BITFIELD(aoncmu->CLK_SELECT, AON_CMU_SEL_PLL_SYS, sel); + int_unlock(lock); - return 0; + return 0; } -int hal_cmu_get_pll_status(enum HAL_CMU_PLL_T pll) -{ - return !!(aoncmu->TOP_CLK_ENABLE & ((pll == HAL_CMU_PLL_AUD) ? AON_CMU_EN_CLK_TOP_PLLAUD_ENABLE : AON_CMU_EN_CLK_TOP_PLLUSB_ENABLE)); +int hal_cmu_get_pll_status(enum HAL_CMU_PLL_T pll) { + return !!(aoncmu->TOP_CLK_ENABLE & + ((pll == HAL_CMU_PLL_AUD) ? AON_CMU_EN_CLK_TOP_PLLAUD_ENABLE + : AON_CMU_EN_CLK_TOP_PLLUSB_ENABLE)); } -int hal_cmu_pll_enable(enum HAL_CMU_PLL_T pll, enum HAL_CMU_PLL_USER_T user) -{ - uint32_t pu_val; - uint32_t en_val; - uint32_t check; - uint32_t lock; - uint32_t sel; - uint32_t start; - uint32_t timeout; +int hal_cmu_pll_enable(enum HAL_CMU_PLL_T pll, enum HAL_CMU_PLL_USER_T user) { + uint32_t pu_val; + uint32_t en_val; + uint32_t check; + uint32_t lock; + uint32_t sel; + uint32_t start; + uint32_t timeout; - if (pll >= HAL_CMU_PLL_QTY) { - return 1; - } - if (user >= HAL_CMU_PLL_USER_QTY && user != HAL_CMU_PLL_USER_ALL) { - return 2; - } + if (pll >= HAL_CMU_PLL_QTY) { + return 1; + } + if (user >= HAL_CMU_PLL_USER_QTY && user != HAL_CMU_PLL_USER_ALL) { + return 2; + } #ifdef USB_USE_USBPLL - if (pll == HAL_CMU_PLL_USB && user == HAL_CMU_PLL_USER_USB) { - pll = HAL_CMU_PLL_USB_HS; - } + if (pll == HAL_CMU_PLL_USB && user == HAL_CMU_PLL_USER_USB) { + pll = HAL_CMU_PLL_USB_HS; + } #endif - if (pll == HAL_CMU_PLL_AUD) { - pu_val = AON_CMU_PU_PLLAUD_ENABLE; - en_val = AON_CMU_EN_CLK_TOP_PLLAUD_ENABLE; - check = AON_CMU_LOCK_PLLAUD; + if (pll == HAL_CMU_PLL_AUD) { + pu_val = AON_CMU_PU_PLLAUD_ENABLE; + en_val = AON_CMU_EN_CLK_TOP_PLLAUD_ENABLE; + check = AON_CMU_LOCK_PLLAUD; #ifdef USB_USE_USBPLL - } else if (pll == HAL_CMU_PLL_USB_HS) { - pu_val = AON_CMU_PU_PLLUSB_ENABLE; - en_val = AON_CMU_EN_CLK_TOP_PLLUSB_ENABLE; - check = AON_CMU_LOCK_PLLUSB; + } else if (pll == HAL_CMU_PLL_USB_HS) { + pu_val = AON_CMU_PU_PLLUSB_ENABLE; + en_val = AON_CMU_EN_CLK_TOP_PLLUSB_ENABLE; + check = AON_CMU_LOCK_PLLUSB; #endif - } else { - pu_val = AON_CMU_PU_PLLBB_ENABLE; - en_val = AON_CMU_EN_CLK_TOP_PLLBB_ENABLE; - check = AON_CMU_LOCK_PLLBB; - } + } else { + pu_val = AON_CMU_PU_PLLBB_ENABLE; + en_val = AON_CMU_EN_CLK_TOP_PLLBB_ENABLE; + check = AON_CMU_LOCK_PLLBB; + } - lock = int_lock(); - if (pll_user_map[pll] == 0 || user == HAL_CMU_PLL_USER_ALL) { + lock = int_lock(); + if (pll_user_map[pll] == 0 || user == HAL_CMU_PLL_USER_ALL) { #ifndef ROM_BUILD - pmu_pll_div_reset_set(pll); + pmu_pll_div_reset_set(pll); #endif - aoncmu->TOP_CLK_ENABLE = pu_val; + aoncmu->TOP_CLK_ENABLE = pu_val; #ifndef ROM_BUILD - hal_sys_timer_delay_us(20); - pmu_pll_div_reset_clear(pll); - // Wait at least 10us for clock ready + hal_sys_timer_delay_us(20); + pmu_pll_div_reset_clear(pll); + // Wait at least 10us for clock ready #endif + } else { + check = 0; + } + if (user < HAL_CMU_PLL_USER_QTY) { + pll_user_map[pll] |= (1 << user); + } + if (user == HAL_CMU_PLL_USER_AUD) { + // 0/1:audpll, 2:bbpll, 3:usbpll + sel = (pll == HAL_CMU_PLL_AUD) ? 0 : 2; + aoncmu->CLK_SELECT = + SET_BITFIELD(aoncmu->CLK_SELECT, AON_CMU_SEL_PLL_AUD, sel); + } + // HAL_CMU_PLL_USER_SYS selects PLL in hal_cmu_sys_select_pll() + int_unlock(lock); + + start = hal_sys_timer_get(); + timeout = HAL_CMU_PLL_LOCKED_TIMEOUT; + do { + if (check) { + if (aoncmu->CODEC_DIV & check) { + // break; + } } else { - check = 0; + if (aoncmu->TOP_CLK_ENABLE & en_val) { + break; + } } - if (user < HAL_CMU_PLL_USER_QTY) { - pll_user_map[pll] |= (1 << user); - } - if (user == HAL_CMU_PLL_USER_AUD) { - // 0/1:audpll, 2:bbpll, 3:usbpll - sel = (pll == HAL_CMU_PLL_AUD) ? 0 : 2; - aoncmu->CLK_SELECT = SET_BITFIELD(aoncmu->CLK_SELECT, AON_CMU_SEL_PLL_AUD, sel); - } - // HAL_CMU_PLL_USER_SYS selects PLL in hal_cmu_sys_select_pll() - int_unlock(lock); + } while ((hal_sys_timer_get() - start) < timeout); - start = hal_sys_timer_get(); - timeout = HAL_CMU_PLL_LOCKED_TIMEOUT; - do { - if (check) { - if (aoncmu->CODEC_DIV & check) { - //break; - } - } else { - if (aoncmu->TOP_CLK_ENABLE & en_val) { - break; - } - } - } while ((hal_sys_timer_get() - start) < timeout); - - aoncmu->TOP_CLK_ENABLE = en_val; + aoncmu->TOP_CLK_ENABLE = en_val; #ifndef USB_USE_USBPLL - if (pll == HAL_CMU_PLL_USB && user == HAL_CMU_PLL_USER_USB) { - aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_TOP_PLLBB2_ENABLE; - } + if (pll == HAL_CMU_PLL_USB && user == HAL_CMU_PLL_USER_USB) { + aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_TOP_PLLBB2_ENABLE; + } #endif - return (aoncmu->CODEC_DIV & check) ? 0 : 2; + return (aoncmu->CODEC_DIV & check) ? 0 : 2; } -int hal_cmu_pll_disable(enum HAL_CMU_PLL_T pll, enum HAL_CMU_PLL_USER_T user) -{ - uint32_t lock; +int hal_cmu_pll_disable(enum HAL_CMU_PLL_T pll, enum HAL_CMU_PLL_USER_T user) { + uint32_t lock; - if (pll >= HAL_CMU_PLL_QTY) { - return 1; - } - if (user >= HAL_CMU_PLL_USER_QTY && user != HAL_CMU_PLL_USER_ALL) { - return 2; - } + if (pll >= HAL_CMU_PLL_QTY) { + return 1; + } + if (user >= HAL_CMU_PLL_USER_QTY && user != HAL_CMU_PLL_USER_ALL) { + return 2; + } - if (pll == HAL_CMU_PLL_USB && user == HAL_CMU_PLL_USER_USB) { + if (pll == HAL_CMU_PLL_USB && user == HAL_CMU_PLL_USER_USB) { #ifdef USB_USE_USBPLL - pll = HAL_CMU_PLL_USB_HS; + pll = HAL_CMU_PLL_USB_HS; #else - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLBB2_DISABLE; + aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLBB2_DISABLE; #endif - } + } - lock = int_lock(); - if (user < HAL_CMU_PLL_USER_ALL) { - pll_user_map[pll] &= ~(1 << user); - } - if (pll_user_map[pll] == 0 || user == HAL_CMU_PLL_USER_ALL) { - if (pll == HAL_CMU_PLL_AUD) { - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLAUD_DISABLE; - aoncmu->TOP_CLK_DISABLE = AON_CMU_PU_PLLAUD_DISABLE; + lock = int_lock(); + if (user < HAL_CMU_PLL_USER_ALL) { + pll_user_map[pll] &= ~(1 << user); + } + if (pll_user_map[pll] == 0 || user == HAL_CMU_PLL_USER_ALL) { + if (pll == HAL_CMU_PLL_AUD) { + aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLAUD_DISABLE; + aoncmu->TOP_CLK_DISABLE = AON_CMU_PU_PLLAUD_DISABLE; #ifdef USB_USE_USBPLL - } else if (pll == HAL_CMU_PLL_USB_HS) { - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLUSB_DISABLE; - aoncmu->TOP_CLK_DISABLE = AON_CMU_PU_PLLUSB_DISABLE; + } else if (pll == HAL_CMU_PLL_USB_HS) { + aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLUSB_DISABLE; + aoncmu->TOP_CLK_DISABLE = AON_CMU_PU_PLLUSB_DISABLE; #endif - } else { - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLBB_DISABLE; - aoncmu->TOP_CLK_DISABLE = AON_CMU_PU_PLLBB_DISABLE; - } + } else { + aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLBB_DISABLE; + aoncmu->TOP_CLK_DISABLE = AON_CMU_PU_PLLBB_DISABLE; } - int_unlock(lock); + } + int_unlock(lock); - return 0; + return 0; } -void BOOT_TEXT_FLASH_LOC hal_cmu_low_freq_mode_init(void) -{ +void BOOT_TEXT_FLASH_LOC hal_cmu_low_freq_mode_init(void) { #if defined(MCU_HIGH_PERFORMANCE_MODE) - hal_cmu_sys_select_pll(HAL_CMU_PLL_USB); + hal_cmu_sys_select_pll(HAL_CMU_PLL_USB); #else - // No need to switch to USB PLL, for there is a clock gate and a clock mux - // in front of the AUD/USB switch - hal_cmu_sys_select_pll(HAL_CMU_PLL_AUD); + // No need to switch to USB PLL, for there is a clock gate and a clock mux + // in front of the AUD/USB switch + hal_cmu_sys_select_pll(HAL_CMU_PLL_AUD); #endif //#ifdef FLASH_LOW_SPEED #ifdef OSC_26M_X4_AUD2BB + aoncmu->CLK_SELECT &= ~AON_CMU_SEL_X4_SYS; +#endif + //#endif +} + +void hal_cmu_low_freq_mode_enable(enum HAL_CMU_FREQ_T old_freq, + enum HAL_CMU_FREQ_T new_freq) { + // TODO: Need to lock irq? + enum HAL_CMU_PLL_T POSSIBLY_UNUSED pll; + +#if defined(MCU_HIGH_PERFORMANCE_MODE) + pll = HAL_CMU_PLL_USB; +#else + pll = HAL_CMU_PLL_AUD; +#endif + +#ifdef OSC_26M_X4_AUD2BB + if (new_freq <= HAL_CMU_FREQ_52M) { aoncmu->CLK_SELECT &= ~AON_CMU_SEL_X4_SYS; + } + if (new_freq <= HAL_CMU_FREQ_104M && old_freq > HAL_CMU_FREQ_104M) { + if (new_freq > HAL_CMU_FREQ_52M) { + // PLL is in use now. Switch to X2 first. + hal_cmu_sys_set_freq(HAL_CMU_FREQ_52M); + aoncmu->CLK_SELECT |= AON_CMU_SEL_X4_SYS; + // X4 is in use now + hal_cmu_sys_set_freq(new_freq); + } + hal_cmu_pll_disable(pll, HAL_CMU_PLL_USER_SYS); + } +#else +#ifdef FLASH_LOW_SPEED + if (old_freq > HAL_CMU_FREQ_52M && new_freq <= HAL_CMU_FREQ_52M) { + hal_cmu_pll_disable(pll, HAL_CMU_PLL_USER_SYS); + } +#endif #endif -//#endif } -void hal_cmu_low_freq_mode_enable(enum HAL_CMU_FREQ_T old_freq, enum HAL_CMU_FREQ_T new_freq) -{ - // TODO: Need to lock irq? - enum HAL_CMU_PLL_T POSSIBLY_UNUSED pll; +void hal_cmu_low_freq_mode_disable(enum HAL_CMU_FREQ_T old_freq, + enum HAL_CMU_FREQ_T new_freq) { + // TODO: Need to lock irq? + enum HAL_CMU_PLL_T POSSIBLY_UNUSED pll; #if defined(MCU_HIGH_PERFORMANCE_MODE) - pll = HAL_CMU_PLL_USB; + pll = HAL_CMU_PLL_USB; #else - pll = HAL_CMU_PLL_AUD; + pll = HAL_CMU_PLL_AUD; #endif #ifdef OSC_26M_X4_AUD2BB - if (new_freq <= HAL_CMU_FREQ_52M) { - aoncmu->CLK_SELECT &= ~AON_CMU_SEL_X4_SYS; - } - if (new_freq <= HAL_CMU_FREQ_104M && old_freq > HAL_CMU_FREQ_104M) { - if (new_freq > HAL_CMU_FREQ_52M) { - // PLL is in use now. Switch to X2 first. - hal_cmu_sys_set_freq(HAL_CMU_FREQ_52M); - aoncmu->CLK_SELECT |= AON_CMU_SEL_X4_SYS; - // X4 is in use now - hal_cmu_sys_set_freq(new_freq); - } - hal_cmu_pll_disable(pll, HAL_CMU_PLL_USER_SYS); + if (new_freq <= HAL_CMU_FREQ_52M) { + aoncmu->CLK_SELECT &= ~AON_CMU_SEL_X4_SYS; + } else if (new_freq <= HAL_CMU_FREQ_104M) { + aoncmu->CLK_SELECT |= AON_CMU_SEL_X4_SYS; + } else { + if (old_freq <= HAL_CMU_FREQ_104M) { + hal_cmu_pll_enable(pll, HAL_CMU_PLL_USER_SYS); + if (old_freq > HAL_CMU_FREQ_52M) { + // X4 is in use now. Switch to X2 before stopping X4 + hal_cmu_sys_set_freq(HAL_CMU_FREQ_52M); + } + aoncmu->CLK_SELECT &= ~AON_CMU_SEL_X4_SYS; } + } #else #ifdef FLASH_LOW_SPEED - if (old_freq > HAL_CMU_FREQ_52M && new_freq <= HAL_CMU_FREQ_52M) { - hal_cmu_pll_disable(pll, HAL_CMU_PLL_USER_SYS); - } + if (old_freq <= HAL_CMU_FREQ_52M && new_freq > HAL_CMU_FREQ_52M) { + hal_cmu_pll_enable(pll, HAL_CMU_PLL_USER_SYS); + } #endif #endif } -void hal_cmu_low_freq_mode_disable(enum HAL_CMU_FREQ_T old_freq, enum HAL_CMU_FREQ_T new_freq) -{ - // TODO: Need to lock irq? - enum HAL_CMU_PLL_T POSSIBLY_UNUSED pll; +int hal_cmu_codec_adc_set_div(uint32_t div) { + uint32_t lock; -#if defined(MCU_HIGH_PERFORMANCE_MODE) - pll = HAL_CMU_PLL_USB; -#else - pll = HAL_CMU_PLL_AUD; -#endif + if (div < 2) { + return 1; + } -#ifdef OSC_26M_X4_AUD2BB - if (new_freq <= HAL_CMU_FREQ_52M) { - aoncmu->CLK_SELECT &= ~AON_CMU_SEL_X4_SYS; - } else if (new_freq <= HAL_CMU_FREQ_104M) { - aoncmu->CLK_SELECT |= AON_CMU_SEL_X4_SYS; - } else { - if (old_freq <= HAL_CMU_FREQ_104M) { - hal_cmu_pll_enable(pll, HAL_CMU_PLL_USER_SYS); - if (old_freq > HAL_CMU_FREQ_52M) { - // X4 is in use now. Switch to X2 before stopping X4 - hal_cmu_sys_set_freq(HAL_CMU_FREQ_52M); - } - aoncmu->CLK_SELECT &= ~AON_CMU_SEL_X4_SYS; - } - } -#else -#ifdef FLASH_LOW_SPEED - if (old_freq <= HAL_CMU_FREQ_52M && new_freq > HAL_CMU_FREQ_52M) { - hal_cmu_pll_enable(pll, HAL_CMU_PLL_USER_SYS); - } -#endif -#endif + div -= 2; + lock = int_lock(); + aoncmu->CODEC_DIV = + SET_BITFIELD(aoncmu->CODEC_DIV, AON_CMU_CFG_DIV_CODEC, div); + int_unlock(lock); + + return 0; } -int hal_cmu_codec_adc_set_div(uint32_t div) -{ - uint32_t lock; - - if (div < 2) { - return 1; - } - - div -= 2; - lock = int_lock(); - aoncmu->CODEC_DIV = SET_BITFIELD(aoncmu->CODEC_DIV, AON_CMU_CFG_DIV_CODEC, div); - int_unlock(lock); - - return 0; +uint32_t hal_cmu_codec_adc_get_div(void) { + return GET_BITFIELD(aoncmu->CODEC_DIV, AON_CMU_CFG_DIV_CODEC) + 2; } -uint32_t hal_cmu_codec_adc_get_div(void) -{ - return GET_BITFIELD(aoncmu->CODEC_DIV, AON_CMU_CFG_DIV_CODEC) + 2; +int hal_cmu_codec_dac_set_div(uint32_t div) { + return hal_cmu_codec_adc_set_div(div); } -int hal_cmu_codec_dac_set_div(uint32_t div) -{ - return hal_cmu_codec_adc_set_div(div); -} - -uint32_t hal_cmu_codec_dac_get_div(void) -{ - return hal_cmu_codec_adc_get_div();; +uint32_t hal_cmu_codec_dac_get_div(void) { + return hal_cmu_codec_adc_get_div(); + ; } #if defined(__AUDIO_RESAMPLE__) && defined(ANA_26M_X4_ENABLE) -void hal_cmu_audio_26m_x4_enable(enum CMU_AUD_26M_X4_USER_T user) -{ - uint32_t lock; +void hal_cmu_audio_26m_x4_enable(enum CMU_AUD_26M_X4_USER_T user) { + uint32_t lock; - if (user >= CMU_AUD_26M_X4_USER_QTY) { - return; - } + if (user >= CMU_AUD_26M_X4_USER_QTY) { + return; + } - lock = int_lock(); + lock = int_lock(); + if (aud_26m_x4_map == 0) { + aoncmu->CLK_SELECT |= AON_CMU_SEL_X4_AUD; + } + aud_26m_x4_map |= (1 << user); + + int_unlock(lock); +} + +void hal_cmu_audio_26m_x4_disable(enum CMU_AUD_26M_X4_USER_T user) { + uint32_t lock; + + if (user >= CMU_AUD_26M_X4_USER_QTY) { + return; + } + + lock = int_lock(); + + if (aud_26m_x4_map & (1 << user)) { + aud_26m_x4_map &= ~(1 << user); if (aud_26m_x4_map == 0) { - aoncmu->CLK_SELECT |= AON_CMU_SEL_X4_AUD; + aoncmu->CLK_SELECT &= ~AON_CMU_SEL_X4_AUD; } - aud_26m_x4_map |= (1 << user); + } - int_unlock(lock); -} - -void hal_cmu_audio_26m_x4_disable(enum CMU_AUD_26M_X4_USER_T user) -{ - uint32_t lock; - - if (user >= CMU_AUD_26M_X4_USER_QTY) { - return; - } - - lock = int_lock(); - - if (aud_26m_x4_map & (1 << user)) { - aud_26m_x4_map &= ~(1 << user); - if (aud_26m_x4_map == 0) { - aoncmu->CLK_SELECT &= ~AON_CMU_SEL_X4_AUD; - } - } - - int_unlock(lock); + int_unlock(lock); } #endif -void hal_cmu_codec_iir_enable(uint32_t speed) -{ - uint32_t lock; - uint32_t mask; - uint32_t val; - uint32_t div; - uint32_t cfg_speed = 0; +void hal_cmu_codec_iir_enable(uint32_t speed) { + uint32_t lock; + uint32_t mask; + uint32_t val; + uint32_t div; + uint32_t cfg_speed = 0; - mask = AON_CMU_SEL_OSC_CODECIIR | AON_CMU_SEL_OSCX2_CODECIIR | AON_CMU_BYPASS_DIV_CODECIIR; - val = 0; + mask = AON_CMU_SEL_OSC_CODECIIR | AON_CMU_SEL_OSCX2_CODECIIR | + AON_CMU_BYPASS_DIV_CODECIIR; + val = 0; - if (speed <= 26000000) { - val |= AON_CMU_SEL_OSC_CODECIIR | AON_CMU_SEL_OSCX2_CODECIIR; - cfg_speed = 26000000; - } else if (speed <= 52000000) { - val |= AON_CMU_SEL_OSCX2_CODECIIR; - cfg_speed = 52000000; - } else { + if (speed <= 26000000) { + val |= AON_CMU_SEL_OSC_CODECIIR | AON_CMU_SEL_OSCX2_CODECIIR; + cfg_speed = 26000000; + } else if (speed <= 52000000) { + val |= AON_CMU_SEL_OSCX2_CODECIIR; + cfg_speed = 52000000; + } else { #if defined(__AUDIO_RESAMPLE__) && defined(ANA_26M_X4_ENABLE) - if (hal_cmu_get_audio_resample_status()) { - hal_cmu_audio_26m_x4_enable(CMU_AUD_26M_X4_USER_IIR); - val |= AON_CMU_BYPASS_DIV_CODECIIR; - cfg_speed = 104000000; - } - else + if (hal_cmu_get_audio_resample_status()) { + hal_cmu_audio_26m_x4_enable(CMU_AUD_26M_X4_USER_IIR); + val |= AON_CMU_BYPASS_DIV_CODECIIR; + cfg_speed = 104000000; + } else #endif - { - // Assume audio stream is one of 48K series - div = HAL_CMU_AUD_PLL_CLOCK / speed; - if (div >= 2) { - hal_cmu_codec_iir_set_div(div); - cfg_speed = HAL_CMU_AUD_PLL_CLOCK / div; - } else { - val |= AON_CMU_BYPASS_DIV_CODECIIR; - cfg_speed = HAL_CMU_AUD_PLL_CLOCK; - } - } + { + // Assume audio stream is one of 48K series + div = HAL_CMU_AUD_PLL_CLOCK / speed; + if (div >= 2) { + hal_cmu_codec_iir_set_div(div); + cfg_speed = HAL_CMU_AUD_PLL_CLOCK / div; + } else { + val |= AON_CMU_BYPASS_DIV_CODECIIR; + cfg_speed = HAL_CMU_AUD_PLL_CLOCK; + } } + } - ASSERT(speed <= cfg_speed, "%s: speed %u should <= cfg_speed %u", __func__, speed, cfg_speed); + ASSERT(speed <= cfg_speed, "%s: speed %u should <= cfg_speed %u", __func__, + speed, cfg_speed); - lock = int_lock(); - aoncmu->CODEC_IIR = (aoncmu->CODEC_IIR & ~mask) | val; - int_unlock(lock); + lock = int_lock(); + aoncmu->CODEC_IIR = (aoncmu->CODEC_IIR & ~mask) | val; + int_unlock(lock); - aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_CODEC_IIR_ENABLE; + aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_CODEC_IIR_ENABLE; - aocmu_reg_update_wait(); + aocmu_reg_update_wait(); } -void hal_cmu_codec_iir_disable(void) -{ - uint32_t lock; - uint32_t val; +void hal_cmu_codec_iir_disable(void) { + uint32_t lock; + uint32_t val; - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_CODEC_IIR_DISABLE; + aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_CODEC_IIR_DISABLE; #if defined(__AUDIO_RESAMPLE__) && defined(ANA_26M_X4_ENABLE) - hal_cmu_audio_26m_x4_disable(CMU_AUD_26M_X4_USER_IIR); + hal_cmu_audio_26m_x4_disable(CMU_AUD_26M_X4_USER_IIR); #endif - val = AON_CMU_SEL_OSC_CODECIIR | AON_CMU_SEL_OSCX2_CODECIIR; + val = AON_CMU_SEL_OSC_CODECIIR | AON_CMU_SEL_OSCX2_CODECIIR; - lock = int_lock(); - aoncmu->CODEC_IIR |= val; - int_unlock(lock); + lock = int_lock(); + aoncmu->CODEC_IIR |= val; + int_unlock(lock); } -int hal_cmu_codec_iir_set_div(uint32_t div) -{ - uint32_t lock; +int hal_cmu_codec_iir_set_div(uint32_t div) { + uint32_t lock; - if (div < 2) { - return 1; - } + if (div < 2) { + return 1; + } - div -= 2; - lock = int_lock(); - aoncmu->CODEC_IIR = SET_BITFIELD(aoncmu->CODEC_IIR, AON_CMU_CFG_DIV_CODECIIR, div); - int_unlock(lock); + div -= 2; + lock = int_lock(); + aoncmu->CODEC_IIR = + SET_BITFIELD(aoncmu->CODEC_IIR, AON_CMU_CFG_DIV_CODECIIR, div); + int_unlock(lock); - return 0; + return 0; } -void hal_cmu_codec_rs_enable(uint32_t speed) -{ - uint32_t lock; - uint32_t mask; - uint32_t val; - uint32_t div; - uint32_t cfg_speed = 0; +void hal_cmu_codec_rs_enable(uint32_t speed) { + uint32_t lock; + uint32_t mask; + uint32_t val; + uint32_t div; + uint32_t cfg_speed = 0; - mask = AON_CMU_SEL_OSC_CODECRS | AON_CMU_SEL_OSCX2_CODECRS | AON_CMU_BYPASS_DIV_CODECRS; - val = 0; + mask = AON_CMU_SEL_OSC_CODECRS | AON_CMU_SEL_OSCX2_CODECRS | + AON_CMU_BYPASS_DIV_CODECRS; + val = 0; - if (speed <= 26000000) { - val |= AON_CMU_SEL_OSC_CODECRS | AON_CMU_SEL_OSCX2_CODECRS; - cfg_speed = 26000000; - } else if (speed <= 52000000) { - val |= AON_CMU_SEL_OSCX2_CODECRS; - cfg_speed = 52000000; - } else { + if (speed <= 26000000) { + val |= AON_CMU_SEL_OSC_CODECRS | AON_CMU_SEL_OSCX2_CODECRS; + cfg_speed = 26000000; + } else if (speed <= 52000000) { + val |= AON_CMU_SEL_OSCX2_CODECRS; + cfg_speed = 52000000; + } else { #if defined(__AUDIO_RESAMPLE__) && defined(ANA_26M_X4_ENABLE) - if (hal_cmu_get_audio_resample_status()) { - hal_cmu_audio_26m_x4_enable(CMU_AUD_26M_X4_USER_RS); - val |= AON_CMU_BYPASS_DIV_CODECRS; - cfg_speed = 104000000; - } - else + if (hal_cmu_get_audio_resample_status()) { + hal_cmu_audio_26m_x4_enable(CMU_AUD_26M_X4_USER_RS); + val |= AON_CMU_BYPASS_DIV_CODECRS; + cfg_speed = 104000000; + } else #endif - { - // Assume audio stream is one of 48K series - div = HAL_CMU_AUD_PLL_CLOCK / speed; - if (div >= 2) { - hal_cmu_codec_rs_set_div(div); - cfg_speed = HAL_CMU_AUD_PLL_CLOCK / div; - } else { - val |= AON_CMU_BYPASS_DIV_CODECRS; - cfg_speed = HAL_CMU_AUD_PLL_CLOCK; - } - } - - pmu_rs_freq_config(cfg_speed); + { + // Assume audio stream is one of 48K series + div = HAL_CMU_AUD_PLL_CLOCK / speed; + if (div >= 2) { + hal_cmu_codec_rs_set_div(div); + cfg_speed = HAL_CMU_AUD_PLL_CLOCK / div; + } else { + val |= AON_CMU_BYPASS_DIV_CODECRS; + cfg_speed = HAL_CMU_AUD_PLL_CLOCK; + } } - ASSERT(speed <= cfg_speed, "%s: speed %u should <= cfg_speed %u", __func__, speed, cfg_speed); + pmu_rs_freq_config(cfg_speed); + } - lock = int_lock(); - aoncmu->CODEC_IIR = (aoncmu->CODEC_IIR & ~mask) | val; - int_unlock(lock); + ASSERT(speed <= cfg_speed, "%s: speed %u should <= cfg_speed %u", __func__, + speed, cfg_speed); - aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_CODEC_RS_ENABLE; + lock = int_lock(); + aoncmu->CODEC_IIR = (aoncmu->CODEC_IIR & ~mask) | val; + int_unlock(lock); - aocmu_reg_update_wait(); + aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_CODEC_RS_ENABLE; + + aocmu_reg_update_wait(); } -void hal_cmu_codec_rs_disable(void) -{ - uint32_t lock; - bool high_speed; +void hal_cmu_codec_rs_disable(void) { + uint32_t lock; + bool high_speed; - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_CODEC_RS_DISABLE; + aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_CODEC_RS_DISABLE; #if defined(__AUDIO_RESAMPLE__) && defined(ANA_26M_X4_ENABLE) - hal_cmu_audio_26m_x4_disable(CMU_AUD_26M_X4_USER_RS); + hal_cmu_audio_26m_x4_disable(CMU_AUD_26M_X4_USER_RS); #endif - high_speed = !(aoncmu->CODEC_IIR & AON_CMU_SEL_OSC_CODECRS); + high_speed = !(aoncmu->CODEC_IIR & AON_CMU_SEL_OSC_CODECRS); - lock = int_lock(); - aoncmu->CODEC_IIR |= AON_CMU_SEL_OSC_CODECRS | AON_CMU_SEL_OSCX2_CODECRS; - int_unlock(lock); + lock = int_lock(); + aoncmu->CODEC_IIR |= AON_CMU_SEL_OSC_CODECRS | AON_CMU_SEL_OSCX2_CODECRS; + int_unlock(lock); - if (high_speed) { - pmu_rs_freq_config(0); - } + if (high_speed) { + pmu_rs_freq_config(0); + } } -int hal_cmu_codec_rs_set_div(uint32_t div) -{ - uint32_t lock; +int hal_cmu_codec_rs_set_div(uint32_t div) { + uint32_t lock; - if (div < 2) { - return 1; - } + if (div < 2) { + return 1; + } - div -= 2; - lock = int_lock(); - aoncmu->CODEC_IIR = SET_BITFIELD(aoncmu->CODEC_IIR, AON_CMU_CFG_DIV_CODECRS, div); - int_unlock(lock); + div -= 2; + lock = int_lock(); + aoncmu->CODEC_IIR = + SET_BITFIELD(aoncmu->CODEC_IIR, AON_CMU_CFG_DIV_CODECRS, div); + int_unlock(lock); - return 0; + return 0; } -void hal_cmu_anc_enable(enum HAL_CMU_ANC_CLK_USER_T user) -{ - anc_enabled = true; +void hal_cmu_anc_enable(enum HAL_CMU_ANC_CLK_USER_T user) { + anc_enabled = true; } -void hal_cmu_anc_disable(enum HAL_CMU_ANC_CLK_USER_T user) -{ - anc_enabled = false; +void hal_cmu_anc_disable(enum HAL_CMU_ANC_CLK_USER_T user) { + anc_enabled = false; } -int hal_cmu_anc_get_status(enum HAL_CMU_ANC_CLK_USER_T user) -{ - return anc_enabled; +int hal_cmu_anc_get_status(enum HAL_CMU_ANC_CLK_USER_T user) { + return anc_enabled; } -void hal_cmu_codec_clock_enable(void) -{ - uint32_t clk; +void hal_cmu_codec_clock_enable(void) { + uint32_t clk; #ifdef CODEC_CLK_FROM_ANA - // Always use ANA clock - clk = AON_CMU_EN_CLK_CODEC_HCLK_ENABLE | AON_CMU_EN_CLK_CODEC_ENABLE; + // Always use ANA clock + clk = AON_CMU_EN_CLK_CODEC_HCLK_ENABLE | AON_CMU_EN_CLK_CODEC_ENABLE; #else #ifdef __AUDIO_RESAMPLE__ - if (hal_cmu_get_audio_resample_status()) { - uint32_t lock; - lock = int_lock(); - aoncmu->CODEC_DIV |= AON_CMU_SEL_OSC_CODEC; - int_unlock(lock); + if (hal_cmu_get_audio_resample_status()) { + uint32_t lock; + lock = int_lock(); + aoncmu->CODEC_DIV |= AON_CMU_SEL_OSC_CODEC; + int_unlock(lock); #ifdef RESAMPLE_CODEC_CLK_ANA - clk = AON_CMU_EN_CLK_CODEC_HCLK_ENABLE | AON_CMU_EN_CLK_CODEC_ENABLE; + clk = AON_CMU_EN_CLK_CODEC_HCLK_ENABLE | AON_CMU_EN_CLK_CODEC_ENABLE; #else - clk = AON_CMU_EN_CLK_PLL_CODEC_ENABLE | AON_CMU_EN_CLK_CODEC_HCLK_ENABLE | AON_CMU_EN_CLK_CODEC_ENABLE; - if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_0) { - // Force codec to use analog clock - clk &= ~AON_CMU_EN_CLK_PLL_CODEC_ENABLE; - } -#endif - } - else -#endif - { - clk = AON_CMU_EN_CLK_PLL_CODEC_ENABLE | AON_CMU_EN_CLK_CODEC_HCLK_ENABLE | AON_CMU_EN_CLK_CODEC_ENABLE; + clk = AON_CMU_EN_CLK_PLL_CODEC_ENABLE | AON_CMU_EN_CLK_CODEC_HCLK_ENABLE | + AON_CMU_EN_CLK_CODEC_ENABLE; + if (hal_get_chip_metal_id() == HAL_CHIP_METAL_ID_0) { + // Force codec to use analog clock + clk &= ~AON_CMU_EN_CLK_PLL_CODEC_ENABLE; } #endif - aoncmu->TOP_CLK_ENABLE = clk; - hal_cmu_clock_enable(HAL_CMU_MOD_H_CODEC); + } else +#endif + { + clk = AON_CMU_EN_CLK_PLL_CODEC_ENABLE | AON_CMU_EN_CLK_CODEC_HCLK_ENABLE | + AON_CMU_EN_CLK_CODEC_ENABLE; + } +#endif + aoncmu->TOP_CLK_ENABLE = clk; + hal_cmu_clock_enable(HAL_CMU_MOD_H_CODEC); } -void hal_cmu_codec_clock_disable(void) -{ - uint32_t clk; +void hal_cmu_codec_clock_disable(void) { + uint32_t clk; - hal_cmu_clock_disable(HAL_CMU_MOD_H_CODEC); + hal_cmu_clock_disable(HAL_CMU_MOD_H_CODEC); #ifdef CODEC_CLK_FROM_ANA - clk = AON_CMU_EN_CLK_CODEC_HCLK_DISABLE | AON_CMU_EN_CLK_CODEC_DISABLE; + clk = AON_CMU_EN_CLK_CODEC_HCLK_DISABLE | AON_CMU_EN_CLK_CODEC_DISABLE; #else #ifdef __AUDIO_RESAMPLE__ - if (hal_cmu_get_audio_resample_status()) { - uint32_t lock; - lock = int_lock(); - aoncmu->CODEC_DIV &= ~AON_CMU_SEL_OSC_CODEC; - int_unlock(lock); + if (hal_cmu_get_audio_resample_status()) { + uint32_t lock; + lock = int_lock(); + aoncmu->CODEC_DIV &= ~AON_CMU_SEL_OSC_CODEC; + int_unlock(lock); - clk = AON_CMU_EN_CLK_CODEC_HCLK_DISABLE | AON_CMU_EN_CLK_CODEC_DISABLE; - } - else + clk = AON_CMU_EN_CLK_CODEC_HCLK_DISABLE | AON_CMU_EN_CLK_CODEC_DISABLE; + } else #endif - { - clk = AON_CMU_EN_CLK_PLL_CODEC_DISABLE | AON_CMU_EN_CLK_CODEC_HCLK_DISABLE | AON_CMU_EN_CLK_CODEC_DISABLE; - } + { + clk = AON_CMU_EN_CLK_PLL_CODEC_DISABLE | AON_CMU_EN_CLK_CODEC_HCLK_DISABLE | + AON_CMU_EN_CLK_CODEC_DISABLE; + } #endif - aoncmu->TOP_CLK_DISABLE = clk; + aoncmu->TOP_CLK_DISABLE = clk; } -void hal_cmu_codec_vad_clock_enable(uint32_t enabled) -{ - if (enabled) { - aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_TOP_OSC_ENABLE | AON_CMU_EN_CLK_32K_CODEC_ENABLE; - } else { - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_OSC_DISABLE | AON_CMU_EN_CLK_32K_CODEC_DISABLE; - } +void hal_cmu_codec_vad_clock_enable(uint32_t enabled) { + if (enabled) { + aoncmu->TOP_CLK_ENABLE = + AON_CMU_EN_CLK_TOP_OSC_ENABLE | AON_CMU_EN_CLK_32K_CODEC_ENABLE; + } else { + aoncmu->TOP_CLK_DISABLE = + AON_CMU_EN_CLK_TOP_OSC_DISABLE | AON_CMU_EN_CLK_32K_CODEC_DISABLE; + } } -void hal_cmu_codec_reset_set(void) -{ - aoncmu->RESET_SET = AON_CMU_SOFT_RSTN_CODEC_SET; +void hal_cmu_codec_reset_set(void) { + aoncmu->RESET_SET = AON_CMU_SOFT_RSTN_CODEC_SET; } -void hal_cmu_codec_reset_clear(void) -{ - aoncmu->RESET_CLR = AON_CMU_SOFT_RSTN_CODEC_CLR; - aocmu_reg_update_wait(); +void hal_cmu_codec_reset_clear(void) { + aoncmu->RESET_CLR = AON_CMU_SOFT_RSTN_CODEC_CLR; + aocmu_reg_update_wait(); } -void hal_cmu_codec_set_fault_mask(uint32_t msk) -{ - uint32_t lock; +void hal_cmu_codec_set_fault_mask(uint32_t msk) { + uint32_t lock; - lock = int_lock(); - // If bit set 1, DAC will be muted when some faults occur - cmu->PERIPH_CLK = SET_BITFIELD(cmu->PERIPH_CLK, CMU_MASK_OBS, msk); - int_unlock(lock); + lock = int_lock(); + // If bit set 1, DAC will be muted when some faults occur + cmu->PERIPH_CLK = SET_BITFIELD(cmu->PERIPH_CLK, CMU_MASK_OBS, msk); + int_unlock(lock); } -void hal_cmu_i2s_clock_out_enable(enum HAL_I2S_ID_T id) -{ - uint32_t lock; - uint32_t val; +void hal_cmu_i2s_clock_out_enable(enum HAL_I2S_ID_T id) { + uint32_t lock; + uint32_t val; - if (id == HAL_I2S_ID_0) { - val = CMU_EN_CLK_I2S0_OUT; - } else { - val = CMU_EN_CLK_I2S1_OUT; - } + if (id == HAL_I2S_ID_0) { + val = CMU_EN_CLK_I2S0_OUT; + } else { + val = CMU_EN_CLK_I2S1_OUT; + } - lock = int_lock(); - cmu->I2C_CLK |= val; - int_unlock(lock); + lock = int_lock(); + cmu->I2C_CLK |= val; + int_unlock(lock); } -void hal_cmu_i2s_clock_out_disable(enum HAL_I2S_ID_T id) -{ - uint32_t lock; - uint32_t val; +void hal_cmu_i2s_clock_out_disable(enum HAL_I2S_ID_T id) { + uint32_t lock; + uint32_t val; - if (id == HAL_I2S_ID_0) { - val = CMU_EN_CLK_I2S0_OUT; - } else { - val = CMU_EN_CLK_I2S1_OUT; - } + if (id == HAL_I2S_ID_0) { + val = CMU_EN_CLK_I2S0_OUT; + } else { + val = CMU_EN_CLK_I2S1_OUT; + } - lock = int_lock(); - cmu->I2C_CLK &= ~val; - int_unlock(lock); + lock = int_lock(); + cmu->I2C_CLK &= ~val; + int_unlock(lock); } -void hal_cmu_i2s_set_slave_mode(enum HAL_I2S_ID_T id) -{ - uint32_t lock; - uint32_t val; +void hal_cmu_i2s_set_slave_mode(enum HAL_I2S_ID_T id) { + uint32_t lock; + uint32_t val; - if (id == HAL_I2S_ID_0) { - val = CMU_SEL_I2S0_CLKIN; - } else { - val = CMU_SEL_I2S1_CLKIN; - } + if (id == HAL_I2S_ID_0) { + val = CMU_SEL_I2S0_CLKIN; + } else { + val = CMU_SEL_I2S1_CLKIN; + } - lock = int_lock(); - cmu->I2C_CLK |= val; - int_unlock(lock); + lock = int_lock(); + cmu->I2C_CLK |= val; + int_unlock(lock); } -void hal_cmu_i2s_set_master_mode(enum HAL_I2S_ID_T id) -{ - uint32_t lock; - uint32_t val; +void hal_cmu_i2s_set_master_mode(enum HAL_I2S_ID_T id) { + uint32_t lock; + uint32_t val; - if (id == HAL_I2S_ID_0) { - val = CMU_SEL_I2S0_CLKIN; - } else { - val = CMU_SEL_I2S1_CLKIN; - } + if (id == HAL_I2S_ID_0) { + val = CMU_SEL_I2S0_CLKIN; + } else { + val = CMU_SEL_I2S1_CLKIN; + } - lock = int_lock(); - cmu->I2C_CLK &= ~val; - int_unlock(lock); + lock = int_lock(); + cmu->I2C_CLK &= ~val; + int_unlock(lock); } -void hal_cmu_i2s_clock_enable(enum HAL_I2S_ID_T id) -{ - uint32_t lock; - uint32_t val; - volatile uint32_t *reg; +void hal_cmu_i2s_clock_enable(enum HAL_I2S_ID_T id) { + uint32_t lock; + uint32_t val; + volatile uint32_t *reg; - if (id == HAL_I2S_ID_0) { - val = AON_CMU_EN_CLK_PLL_I2S0; - reg = &aoncmu->PCM_I2S_CLK; - } else { - val = AON_CMU_EN_CLK_PLL_I2S1; - reg = &aoncmu->SPDIF_CLK; - } + if (id == HAL_I2S_ID_0) { + val = AON_CMU_EN_CLK_PLL_I2S0; + reg = &aoncmu->PCM_I2S_CLK; + } else { + val = AON_CMU_EN_CLK_PLL_I2S1; + reg = &aoncmu->SPDIF_CLK; + } - lock = int_lock(); - *reg |= val; - int_unlock(lock); + lock = int_lock(); + *reg |= val; + int_unlock(lock); } -void hal_cmu_i2s_clock_disable(enum HAL_I2S_ID_T id) -{ - uint32_t lock; - uint32_t val; - volatile uint32_t *reg; +void hal_cmu_i2s_clock_disable(enum HAL_I2S_ID_T id) { + uint32_t lock; + uint32_t val; + volatile uint32_t *reg; - if (id == HAL_I2S_ID_0) { - val = AON_CMU_EN_CLK_PLL_I2S0; - reg = &aoncmu->PCM_I2S_CLK; - } else { - val = AON_CMU_EN_CLK_PLL_I2S1; - reg = &aoncmu->SPDIF_CLK; - } + if (id == HAL_I2S_ID_0) { + val = AON_CMU_EN_CLK_PLL_I2S0; + reg = &aoncmu->PCM_I2S_CLK; + } else { + val = AON_CMU_EN_CLK_PLL_I2S1; + reg = &aoncmu->SPDIF_CLK; + } - lock = int_lock(); - *reg &= ~val; - int_unlock(lock); + lock = int_lock(); + *reg &= ~val; + int_unlock(lock); } -int hal_cmu_i2s_set_div(enum HAL_I2S_ID_T id, uint32_t div) -{ - uint32_t lock; +int hal_cmu_i2s_set_div(enum HAL_I2S_ID_T id, uint32_t div) { + uint32_t lock; - if (div < 2) { - return 1; - } + if (div < 2) { + return 1; + } - div -= 2; - if ((div & (AON_CMU_CFG_DIV_I2S0_MASK >> AON_CMU_CFG_DIV_I2S0_SHIFT)) != div) { - return 1; - } + div -= 2; + if ((div & (AON_CMU_CFG_DIV_I2S0_MASK >> AON_CMU_CFG_DIV_I2S0_SHIFT)) != + div) { + return 1; + } - lock = int_lock(); - if (id == HAL_I2S_ID_0) { - aoncmu->PCM_I2S_CLK = SET_BITFIELD(aoncmu->PCM_I2S_CLK, AON_CMU_CFG_DIV_I2S0, div); - } else { - aoncmu->SPDIF_CLK = SET_BITFIELD(aoncmu->SPDIF_CLK, AON_CMU_CFG_DIV_I2S1, div); - } - int_unlock(lock); + lock = int_lock(); + if (id == HAL_I2S_ID_0) { + aoncmu->PCM_I2S_CLK = + SET_BITFIELD(aoncmu->PCM_I2S_CLK, AON_CMU_CFG_DIV_I2S0, div); + } else { + aoncmu->SPDIF_CLK = + SET_BITFIELD(aoncmu->SPDIF_CLK, AON_CMU_CFG_DIV_I2S1, div); + } + int_unlock(lock); - return 0; + return 0; } -void hal_cmu_pcm_clock_out_enable(void) -{ - uint32_t lock; +void hal_cmu_pcm_clock_out_enable(void) { + uint32_t lock; - lock = int_lock(); - cmu->I2C_CLK |= CMU_EN_CLK_PCM_OUT; - int_unlock(lock); + lock = int_lock(); + cmu->I2C_CLK |= CMU_EN_CLK_PCM_OUT; + int_unlock(lock); } -void hal_cmu_pcm_clock_out_disable(void) -{ - uint32_t lock; +void hal_cmu_pcm_clock_out_disable(void) { + uint32_t lock; - lock = int_lock(); - cmu->I2C_CLK &= ~CMU_EN_CLK_PCM_OUT; - int_unlock(lock); + lock = int_lock(); + cmu->I2C_CLK &= ~CMU_EN_CLK_PCM_OUT; + int_unlock(lock); } -void hal_cmu_pcm_set_slave_mode(int clk_pol) -{ - uint32_t lock; - uint32_t mask; - uint32_t cfg; +void hal_cmu_pcm_set_slave_mode(int clk_pol) { + uint32_t lock; + uint32_t mask; + uint32_t cfg; - mask = CMU_SEL_PCM_CLKIN | CMU_POL_CLK_PCM_IN; + mask = CMU_SEL_PCM_CLKIN | CMU_POL_CLK_PCM_IN; - if (clk_pol) { - cfg = CMU_SEL_PCM_CLKIN | CMU_POL_CLK_PCM_IN; - } else { - cfg = CMU_SEL_PCM_CLKIN; - } + if (clk_pol) { + cfg = CMU_SEL_PCM_CLKIN | CMU_POL_CLK_PCM_IN; + } else { + cfg = CMU_SEL_PCM_CLKIN; + } - lock = int_lock(); - cmu->I2C_CLK = (cmu->I2C_CLK & ~mask) | cfg; - int_unlock(lock); + lock = int_lock(); + cmu->I2C_CLK = (cmu->I2C_CLK & ~mask) | cfg; + int_unlock(lock); } -void hal_cmu_pcm_set_master_mode(void) -{ - uint32_t lock; +void hal_cmu_pcm_set_master_mode(void) { + uint32_t lock; - lock = int_lock(); - cmu->I2C_CLK &= ~CMU_SEL_PCM_CLKIN; - int_unlock(lock); + lock = int_lock(); + cmu->I2C_CLK &= ~CMU_SEL_PCM_CLKIN; + int_unlock(lock); } -void hal_cmu_pcm_clock_enable(void) -{ - uint32_t lock; +void hal_cmu_pcm_clock_enable(void) { + uint32_t lock; - lock = int_lock(); - aoncmu->PCM_I2S_CLK |= AON_CMU_EN_CLK_PLL_PCM; - int_unlock(lock); + lock = int_lock(); + aoncmu->PCM_I2S_CLK |= AON_CMU_EN_CLK_PLL_PCM; + int_unlock(lock); } -void hal_cmu_pcm_clock_disable(void) -{ - uint32_t lock; +void hal_cmu_pcm_clock_disable(void) { + uint32_t lock; - lock = int_lock(); - aoncmu->PCM_I2S_CLK &= ~AON_CMU_EN_CLK_PLL_PCM; - int_unlock(lock); + lock = int_lock(); + aoncmu->PCM_I2S_CLK &= ~AON_CMU_EN_CLK_PLL_PCM; + int_unlock(lock); } -int hal_cmu_pcm_set_div(uint32_t div) -{ - uint32_t lock; +int hal_cmu_pcm_set_div(uint32_t div) { + uint32_t lock; - if (div < 2) { - return 1; - } + if (div < 2) { + return 1; + } - div -= 2; - if ((div & (AON_CMU_CFG_DIV_PCM_MASK >> AON_CMU_CFG_DIV_PCM_SHIFT)) != div) { - return 1; - } + div -= 2; + if ((div & (AON_CMU_CFG_DIV_PCM_MASK >> AON_CMU_CFG_DIV_PCM_SHIFT)) != div) { + return 1; + } - lock = int_lock(); - aoncmu->PCM_I2S_CLK = SET_BITFIELD(aoncmu->PCM_I2S_CLK, AON_CMU_CFG_DIV_PCM, div); - int_unlock(lock); - return 0; + lock = int_lock(); + aoncmu->PCM_I2S_CLK = + SET_BITFIELD(aoncmu->PCM_I2S_CLK, AON_CMU_CFG_DIV_PCM, div); + int_unlock(lock); + return 0; } -int hal_cmu_spdif_clock_enable(enum HAL_SPDIF_ID_T id) -{ - uint32_t lock; - uint32_t mask; +int hal_cmu_spdif_clock_enable(enum HAL_SPDIF_ID_T id) { + uint32_t lock; + uint32_t mask; - if (id >= HAL_SPDIF_ID_QTY) { - return 1; - } + if (id >= HAL_SPDIF_ID_QTY) { + return 1; + } - mask = AON_CMU_EN_CLK_PLL_SPDIF0; + mask = AON_CMU_EN_CLK_PLL_SPDIF0; - lock = int_lock(); - aoncmu->SPDIF_CLK |= mask; - int_unlock(lock); - return 0; + lock = int_lock(); + aoncmu->SPDIF_CLK |= mask; + int_unlock(lock); + return 0; } -int hal_cmu_spdif_clock_disable(enum HAL_SPDIF_ID_T id) -{ - uint32_t lock; - uint32_t mask; +int hal_cmu_spdif_clock_disable(enum HAL_SPDIF_ID_T id) { + uint32_t lock; + uint32_t mask; - if (id >= HAL_SPDIF_ID_QTY) { - return 1; - } + if (id >= HAL_SPDIF_ID_QTY) { + return 1; + } - mask = AON_CMU_EN_CLK_PLL_SPDIF0; + mask = AON_CMU_EN_CLK_PLL_SPDIF0; - lock = int_lock(); - aoncmu->SPDIF_CLK &= ~mask; - int_unlock(lock); + lock = int_lock(); + aoncmu->SPDIF_CLK &= ~mask; + int_unlock(lock); - return 0; + return 0; } -int hal_cmu_spdif_set_div(enum HAL_SPDIF_ID_T id, uint32_t div) -{ - uint32_t lock; +int hal_cmu_spdif_set_div(enum HAL_SPDIF_ID_T id, uint32_t div) { + uint32_t lock; - if (id >= HAL_SPDIF_ID_QTY) { - return 1; - } + if (id >= HAL_SPDIF_ID_QTY) { + return 1; + } - if (div < 2) { - return 2; - } + if (div < 2) { + return 2; + } - div -= 2; - if ((div & (AON_CMU_CFG_DIV_SPDIF0_MASK >> AON_CMU_CFG_DIV_SPDIF0_SHIFT)) != div) { - return 2; - } + div -= 2; + if ((div & (AON_CMU_CFG_DIV_SPDIF0_MASK >> AON_CMU_CFG_DIV_SPDIF0_SHIFT)) != + div) { + return 2; + } - lock = int_lock(); - aoncmu->SPDIF_CLK = SET_BITFIELD(aoncmu->SPDIF_CLK, AON_CMU_CFG_DIV_SPDIF0, div); - int_unlock(lock); - return 0; + lock = int_lock(); + aoncmu->SPDIF_CLK = + SET_BITFIELD(aoncmu->SPDIF_CLK, AON_CMU_CFG_DIV_SPDIF0, div); + int_unlock(lock); + return 0; } #ifdef CHIP_HAS_USB -void hal_cmu_usb_set_device_mode(void) -{ - uint32_t lock; +void hal_cmu_usb_set_device_mode(void) { + uint32_t lock; - lock = int_lock(); - cmu->SYS_DIV |= CMU_USB_ID; - int_unlock(lock); + lock = int_lock(); + cmu->SYS_DIV |= CMU_USB_ID; + int_unlock(lock); } -void hal_cmu_usb_set_host_mode(void) -{ - uint32_t lock; +void hal_cmu_usb_set_host_mode(void) { + uint32_t lock; - lock = int_lock(); - cmu->SYS_DIV &= ~CMU_USB_ID; - int_unlock(lock); + lock = int_lock(); + cmu->SYS_DIV &= ~CMU_USB_ID; + int_unlock(lock); } #ifdef ROM_BUILD -void hal_cmu_usb_rom_set_clock_source(enum HAL_CMU_USB_CLOCK_SEL_T sel) -{ - usb_clk_sel = sel; +void hal_cmu_usb_rom_set_clock_source(enum HAL_CMU_USB_CLOCK_SEL_T sel) { + usb_clk_sel = sel; } #endif -static uint32_t hal_cmu_usb_get_clock_source(void) -{ - uint32_t src; +static uint32_t hal_cmu_usb_get_clock_source(void) { + uint32_t src; -#if defined(USB_CLK_SRC_26M_X4) || defined(USB_CLK_SRC_26M_X2) || defined(USB_CLK_SRC_24M_X2) || defined(USB_CLK_SRC_48M) +#if defined(USB_CLK_SRC_26M_X4) || defined(USB_CLK_SRC_26M_X2) || \ + defined(USB_CLK_SRC_24M_X2) || defined(USB_CLK_SRC_48M) #ifdef USB_HIGH_SPEED #error "USB HIGH-SPEED must use PLL" #endif @@ -1708,163 +1665,161 @@ static uint32_t hal_cmu_usb_get_clock_source(void) #ifdef ROM_BUILD #ifdef USB_USE_USBPLL - src = CMU_USB_CLK_SRC_PLL_60M; + src = CMU_USB_CLK_SRC_PLL_60M; #else - if (usb_clk_sel == HAL_CMU_USB_CLOCK_SEL_24M_X2) { - src = CMU_USB_CLK_SRC_OSC_24M_X2; - } else if (usb_clk_sel == HAL_CMU_USB_CLOCK_SEL_48M) { - src = CMU_USB_CLK_SRC_OSC_48M; - } else if (usb_clk_sel == HAL_CMU_USB_CLOCK_SEL_26M_X2) { - src = CMU_USB_CLK_SRC_OSC_26M_X2; - } else if (usb_clk_sel == HAL_CMU_USB_CLOCK_SEL_26M_X4) { - src = CMU_USB_CLK_SRC_OSC_26M_X4; - } else { - src = CMU_USB_CLK_SRC_PLL_48M; - } + if (usb_clk_sel == HAL_CMU_USB_CLOCK_SEL_24M_X2) { + src = CMU_USB_CLK_SRC_OSC_24M_X2; + } else if (usb_clk_sel == HAL_CMU_USB_CLOCK_SEL_48M) { + src = CMU_USB_CLK_SRC_OSC_48M; + } else if (usb_clk_sel == HAL_CMU_USB_CLOCK_SEL_26M_X2) { + src = CMU_USB_CLK_SRC_OSC_26M_X2; + } else if (usb_clk_sel == HAL_CMU_USB_CLOCK_SEL_26M_X4) { + src = CMU_USB_CLK_SRC_OSC_26M_X4; + } else { + src = CMU_USB_CLK_SRC_PLL_48M; + } #endif #else // !ROM_BUILD #ifdef USB_USE_USBPLL - src = CMU_USB_CLK_SRC_PLL_60M; + src = CMU_USB_CLK_SRC_PLL_60M; #else #ifdef USB_CLK_SRC_24M_X2 - src = CMU_USB_CLK_SRC_OSC_24M_X2; + src = CMU_USB_CLK_SRC_OSC_24M_X2; #elif defined(USB_CLK_SRC_48M) - src = CMU_USB_CLK_SRC_OSC_48M; + src = CMU_USB_CLK_SRC_OSC_48M; #elif defined(USB_CLK_SRC_26M_X4) - src = CMU_USB_CLK_SRC_OSC_26M_X4; + src = CMU_USB_CLK_SRC_OSC_26M_X4; #elif defined(USB_CLK_SRC_26M_X2) - src = CMU_USB_CLK_SRC_OSC_26M_X2; + src = CMU_USB_CLK_SRC_OSC_26M_X2; #else - src = CMU_USB_CLK_SRC_PLL_48M; + src = CMU_USB_CLK_SRC_PLL_48M; #endif #endif #endif // !ROM_BUILD - return src; + return src; } -void hal_cmu_usb_clock_enable(void) -{ - enum HAL_CMU_PLL_T pll; - uint32_t lock; - uint32_t src; +void hal_cmu_usb_clock_enable(void) { + enum HAL_CMU_PLL_T pll; + uint32_t lock; + uint32_t src; - pll = HAL_CMU_PLL_USB; - src = hal_cmu_usb_get_clock_source(); + pll = HAL_CMU_PLL_USB; + src = hal_cmu_usb_get_clock_source(); - if (src == CMU_USB_CLK_SRC_PLL_60M || src == CMU_USB_CLK_SRC_PLL_60M_ALT || - src == CMU_USB_CLK_SRC_PLL_48M) { - hal_cmu_pll_enable(pll, HAL_CMU_PLL_USER_USB); - } + if (src == CMU_USB_CLK_SRC_PLL_60M || src == CMU_USB_CLK_SRC_PLL_60M_ALT || + src == CMU_USB_CLK_SRC_PLL_48M) { + hal_cmu_pll_enable(pll, HAL_CMU_PLL_USER_USB); + } - lock = int_lock(); + lock = int_lock(); #ifdef USB_CLK_SRC_26M_X4 - aoncmu->CLK_SELECT |= AON_CMU_SEL_X4_USB; + aoncmu->CLK_SELECT |= AON_CMU_SEL_X4_USB; #endif - cmu->SYS_DIV = SET_BITFIELD(cmu->SYS_DIV, CMU_SEL_USB_SRC, src); - int_unlock(lock); - hal_cmu_clock_enable(HAL_CMU_MOD_H_USBC); + cmu->SYS_DIV = SET_BITFIELD(cmu->SYS_DIV, CMU_SEL_USB_SRC, src); + int_unlock(lock); + hal_cmu_clock_enable(HAL_CMU_MOD_H_USBC); #ifdef USB_HIGH_SPEED - hal_cmu_clock_enable(HAL_CMU_MOD_H_USBH); + hal_cmu_clock_enable(HAL_CMU_MOD_H_USBH); #endif - hal_cmu_clock_enable(HAL_CMU_MOD_O_USB32K); - hal_cmu_clock_enable(HAL_CMU_MOD_O_USB); - hal_cmu_reset_set(HAL_CMU_MOD_O_USB); - hal_cmu_reset_set(HAL_CMU_MOD_O_USB32K); + hal_cmu_clock_enable(HAL_CMU_MOD_O_USB32K); + hal_cmu_clock_enable(HAL_CMU_MOD_O_USB); + hal_cmu_reset_set(HAL_CMU_MOD_O_USB); + hal_cmu_reset_set(HAL_CMU_MOD_O_USB32K); #ifdef USB_HIGH_SPEED - hal_cmu_reset_set(HAL_CMU_MOD_H_USBH); + hal_cmu_reset_set(HAL_CMU_MOD_H_USBH); #endif - hal_cmu_reset_set(HAL_CMU_MOD_H_USBC); - hal_sys_timer_delay(US_TO_TICKS(60)); - hal_cmu_reset_clear(HAL_CMU_MOD_H_USBC); + hal_cmu_reset_set(HAL_CMU_MOD_H_USBC); + hal_sys_timer_delay(US_TO_TICKS(60)); + hal_cmu_reset_clear(HAL_CMU_MOD_H_USBC); #ifdef USB_HIGH_SPEED - hal_cmu_reset_clear(HAL_CMU_MOD_H_USBH); + hal_cmu_reset_clear(HAL_CMU_MOD_H_USBH); #endif - hal_cmu_reset_clear(HAL_CMU_MOD_O_USB32K); - hal_cmu_reset_clear(HAL_CMU_MOD_O_USB); + hal_cmu_reset_clear(HAL_CMU_MOD_O_USB32K); + hal_cmu_reset_clear(HAL_CMU_MOD_O_USB); } -void hal_cmu_usb_clock_disable(void) -{ - enum HAL_CMU_PLL_T pll; - uint32_t src; +void hal_cmu_usb_clock_disable(void) { + enum HAL_CMU_PLL_T pll; + uint32_t src; - pll = HAL_CMU_PLL_USB; - src = hal_cmu_usb_get_clock_source(); + pll = HAL_CMU_PLL_USB; + src = hal_cmu_usb_get_clock_source(); - hal_cmu_reset_set(HAL_CMU_MOD_O_USB); - hal_cmu_reset_set(HAL_CMU_MOD_O_USB32K); + hal_cmu_reset_set(HAL_CMU_MOD_O_USB); + hal_cmu_reset_set(HAL_CMU_MOD_O_USB32K); #ifdef USB_HIGH_SPEED - hal_cmu_reset_set(HAL_CMU_MOD_H_USBH); + hal_cmu_reset_set(HAL_CMU_MOD_H_USBH); #endif - hal_cmu_reset_set(HAL_CMU_MOD_H_USBC); - hal_cmu_clock_disable(HAL_CMU_MOD_O_USB); - hal_cmu_clock_disable(HAL_CMU_MOD_O_USB32K); + hal_cmu_reset_set(HAL_CMU_MOD_H_USBC); + hal_cmu_clock_disable(HAL_CMU_MOD_O_USB); + hal_cmu_clock_disable(HAL_CMU_MOD_O_USB32K); #ifdef USB_HIGH_SPEED - hal_cmu_clock_disable(HAL_CMU_MOD_H_USBH); + hal_cmu_clock_disable(HAL_CMU_MOD_H_USBH); #endif - hal_cmu_clock_disable(HAL_CMU_MOD_H_USBC); + hal_cmu_clock_disable(HAL_CMU_MOD_H_USBC); - if (src == CMU_USB_CLK_SRC_PLL_60M || src == CMU_USB_CLK_SRC_PLL_60M_ALT || - src == CMU_USB_CLK_SRC_PLL_48M) { - hal_cmu_pll_disable(pll, HAL_CMU_PLL_USER_USB); + if (src == CMU_USB_CLK_SRC_PLL_60M || src == CMU_USB_CLK_SRC_PLL_60M_ALT || + src == CMU_USB_CLK_SRC_PLL_48M) { + hal_cmu_pll_disable(pll, HAL_CMU_PLL_USER_USB); + } +} +#endif + +void BOOT_TEXT_FLASH_LOC hal_cmu_apb_init_div(void) { + // Divider defaults to 2 (reg_val = div - 2) + // cmu->SYS_DIV = SET_BITFIELD(cmu->SYS_DIV, CMU_CFG_DIV_PCLK, 0); +} + +int hal_cmu_periph_set_div(uint32_t div) { + uint32_t lock; + int ret = 0; + + if (div == 0 || + div > ((AON_CMU_CFG_DIV_PER_MASK >> AON_CMU_CFG_DIV_PER_SHIFT) + 2)) { + aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_PLL_PER_DISABLE; + if (div > ((AON_CMU_CFG_DIV_PER_MASK >> AON_CMU_CFG_DIV_PER_SHIFT) + 2)) { + ret = 1; } -} -#endif - -void BOOT_TEXT_FLASH_LOC hal_cmu_apb_init_div(void) -{ - // Divider defaults to 2 (reg_val = div - 2) - //cmu->SYS_DIV = SET_BITFIELD(cmu->SYS_DIV, CMU_CFG_DIV_PCLK, 0); -} - -int hal_cmu_periph_set_div(uint32_t div) -{ - uint32_t lock; - int ret = 0; - - if (div == 0 || div > ((AON_CMU_CFG_DIV_PER_MASK >> AON_CMU_CFG_DIV_PER_SHIFT) + 2)) { - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_PLL_PER_DISABLE; - if (div > ((AON_CMU_CFG_DIV_PER_MASK >> AON_CMU_CFG_DIV_PER_SHIFT) + 2)) { - ret = 1; - } + } else { + lock = int_lock(); + if (div == 1) { + aoncmu->CLK_SELECT |= AON_CMU_BYPASS_DIV_PER; } else { - lock = int_lock(); - if (div == 1) { - aoncmu->CLK_SELECT |= AON_CMU_BYPASS_DIV_PER; - } else { - div -= 2; - aoncmu->CLK_SELECT = (aoncmu->CLK_SELECT & ~(AON_CMU_CFG_DIV_PER_MASK | AON_CMU_BYPASS_DIV_PER)) | - AON_CMU_CFG_DIV_PER(div); - } - int_unlock(lock); - aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_PLL_PER_ENABLE; + div -= 2; + aoncmu->CLK_SELECT = (aoncmu->CLK_SELECT & ~(AON_CMU_CFG_DIV_PER_MASK | + AON_CMU_BYPASS_DIV_PER)) | + AON_CMU_CFG_DIV_PER(div); } + int_unlock(lock); + aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_PLL_PER_ENABLE; + } - return ret; + return ret; } -#define PERPH_SET_DIV_FUNC(f, F, r) \ -int hal_cmu_ ##f## _set_div(uint32_t div) \ -{ \ - uint32_t lock; \ - int ret = 0; \ - lock = int_lock(); \ - if (div < 2 || div > ((CMU_CFG_DIV_ ##F## _MASK >> CMU_CFG_DIV_ ##F## _SHIFT) + 2)) { \ - cmu->r &= ~(CMU_SEL_OSCX2_ ##F | CMU_SEL_PLL_ ##F | CMU_EN_PLL_ ##F); \ - ret = 1; \ - } else { \ - div -= 2; \ - cmu->r = (cmu->r & ~(CMU_CFG_DIV_ ##F## _MASK)) | CMU_SEL_OSCX2_ ##F | CMU_SEL_PLL_ ##F | \ - CMU_CFG_DIV_ ##F(div); \ - cmu->r |= CMU_EN_PLL_ ##F; \ - } \ - int_unlock(lock); \ - return ret; \ -} +#define PERPH_SET_DIV_FUNC(f, F, r) \ + int hal_cmu_##f##_set_div(uint32_t div) { \ + uint32_t lock; \ + int ret = 0; \ + lock = int_lock(); \ + if (div < 2 || \ + div > ((CMU_CFG_DIV_##F##_MASK >> CMU_CFG_DIV_##F##_SHIFT) + 2)) { \ + cmu->r &= ~(CMU_SEL_OSCX2_##F | CMU_SEL_PLL_##F | CMU_EN_PLL_##F); \ + ret = 1; \ + } else { \ + div -= 2; \ + cmu->r = (cmu->r & ~(CMU_CFG_DIV_##F##_MASK)) | CMU_SEL_OSCX2_##F | \ + CMU_SEL_PLL_##F | CMU_CFG_DIV_##F(div); \ + cmu->r |= CMU_EN_PLL_##F; \ + } \ + int_unlock(lock); \ + return ret; \ + } PERPH_SET_DIV_FUNC(uart0, UART0, UART_CLK); PERPH_SET_DIV_FUNC(uart1, UART1, UART_CLK); @@ -1874,22 +1829,22 @@ PERPH_SET_DIV_FUNC(slcd, SPI0, SYS_DIV); PERPH_SET_DIV_FUNC(sdmmc, SDMMC, PERIPH_CLK); PERPH_SET_DIV_FUNC(i2c, I2C, I2C_CLK); -#define PERPH_SET_FREQ_FUNC(f, F, r) \ -int hal_cmu_ ##f## _set_freq(enum HAL_CMU_PERIPH_FREQ_T freq) \ -{ \ - uint32_t lock; \ - int ret = 0; \ - lock = int_lock(); \ - if (freq == HAL_CMU_PERIPH_FREQ_26M) { \ - cmu->r &= ~(CMU_SEL_OSCX2_ ##F | CMU_SEL_PLL_ ##F | CMU_EN_PLL_ ##F); \ - } else if (freq == HAL_CMU_PERIPH_FREQ_52M) { \ - cmu->r = (cmu->r & ~(CMU_SEL_PLL_ ##F | CMU_EN_PLL_ ##F)) | CMU_SEL_OSCX2_ ##F; \ - } else { \ - ret = 1; \ - } \ - int_unlock(lock); \ - return ret; \ -} +#define PERPH_SET_FREQ_FUNC(f, F, r) \ + int hal_cmu_##f##_set_freq(enum HAL_CMU_PERIPH_FREQ_T freq) { \ + uint32_t lock; \ + int ret = 0; \ + lock = int_lock(); \ + if (freq == HAL_CMU_PERIPH_FREQ_26M) { \ + cmu->r &= ~(CMU_SEL_OSCX2_##F | CMU_SEL_PLL_##F | CMU_EN_PLL_##F); \ + } else if (freq == HAL_CMU_PERIPH_FREQ_52M) { \ + cmu->r = \ + (cmu->r & ~(CMU_SEL_PLL_##F | CMU_EN_PLL_##F)) | CMU_SEL_OSCX2_##F; \ + } else { \ + ret = 1; \ + } \ + int_unlock(lock); \ + return ret; \ + } PERPH_SET_FREQ_FUNC(uart0, UART0, UART_CLK); PERPH_SET_FREQ_FUNC(uart1, UART1, UART_CLK); @@ -1899,886 +1854,912 @@ PERPH_SET_FREQ_FUNC(slcd, SPI0, SYS_DIV); PERPH_SET_FREQ_FUNC(sdmmc, SDMMC, PERIPH_CLK); PERPH_SET_FREQ_FUNC(i2c, I2C, I2C_CLK); -int hal_cmu_ispi_set_freq(enum HAL_CMU_PERIPH_FREQ_T freq) -{ - uint32_t lock; - int ret = 0; +int hal_cmu_ispi_set_freq(enum HAL_CMU_PERIPH_FREQ_T freq) { + uint32_t lock; + int ret = 0; - lock = int_lock(); - if (freq == HAL_CMU_PERIPH_FREQ_26M) { - cmu->SYS_DIV &= ~CMU_SEL_OSCX2_SPI2; - } else if (freq == HAL_CMU_PERIPH_FREQ_52M) { - cmu->SYS_DIV |= CMU_SEL_OSCX2_SPI2; - } else { - ret = 1; - } - int_unlock(lock); + lock = int_lock(); + if (freq == HAL_CMU_PERIPH_FREQ_26M) { + cmu->SYS_DIV &= ~CMU_SEL_OSCX2_SPI2; + } else if (freq == HAL_CMU_PERIPH_FREQ_52M) { + cmu->SYS_DIV |= CMU_SEL_OSCX2_SPI2; + } else { + ret = 1; + } + int_unlock(lock); - return ret; + return ret; } -int hal_cmu_clock_out_enable(enum HAL_CMU_CLOCK_OUT_ID_T id) -{ - uint32_t lock; - uint32_t sel; - uint32_t cfg; +int hal_cmu_clock_out_enable(enum HAL_CMU_CLOCK_OUT_ID_T id) { + uint32_t lock; + uint32_t sel; + uint32_t cfg; - enum CMU_CLK_OUT_SEL_T { - CMU_CLK_OUT_SEL_AON = 0, - CMU_CLK_OUT_SEL_CODEC = 1, - CMU_CLK_OUT_SEL_BT = 2, - CMU_CLK_OUT_SEL_MCU = 3, + enum CMU_CLK_OUT_SEL_T { + CMU_CLK_OUT_SEL_AON = 0, + CMU_CLK_OUT_SEL_CODEC = 1, + CMU_CLK_OUT_SEL_BT = 2, + CMU_CLK_OUT_SEL_MCU = 3, - CMU_CLK_OUT_SEL_QTY - }; + CMU_CLK_OUT_SEL_QTY + }; - sel = CMU_CLK_OUT_SEL_QTY; - cfg = 0; + sel = CMU_CLK_OUT_SEL_QTY; + cfg = 0; - if (id <= HAL_CMU_CLOCK_OUT_AON_SYS) { - sel = CMU_CLK_OUT_SEL_AON; - cfg = id - HAL_CMU_CLOCK_OUT_AON_32K; - } else if (HAL_CMU_CLOCK_OUT_MCU_32K <= id && id <= HAL_CMU_CLOCK_OUT_MCU_SPI1) { - sel = CMU_CLK_OUT_SEL_MCU; - lock = int_lock(); - cmu->PERIPH_CLK = SET_BITFIELD(cmu->PERIPH_CLK, CMU_CFG_CLK_OUT, id - HAL_CMU_CLOCK_OUT_MCU_32K); - int_unlock(lock); - } else if (HAL_CMU_CLOCK_OUT_CODEC_ADC_ANA <= id && id <= HAL_CMU_CLOCK_OUT_CODEC_HCLK) { - sel = CMU_CLK_OUT_SEL_CODEC; - hal_codec_select_clock_out(id - HAL_CMU_CLOCK_OUT_CODEC_ADC_ANA); - } else if (HAL_CMU_CLOCK_OUT_BT_32K <= id && id <= HAL_CMU_CLOCK_OUT_BT_26M) { - sel = CMU_CLK_OUT_SEL_BT; - btcmu->CLK_OUT = SET_BITFIELD(btcmu->CLK_OUT, BT_CMU_CFG_CLK_OUT, id - HAL_CMU_CLOCK_OUT_BT_32K); - } + if (id <= HAL_CMU_CLOCK_OUT_AON_SYS) { + sel = CMU_CLK_OUT_SEL_AON; + cfg = id - HAL_CMU_CLOCK_OUT_AON_32K; + } else if (HAL_CMU_CLOCK_OUT_MCU_32K <= id && + id <= HAL_CMU_CLOCK_OUT_MCU_SPI1) { + sel = CMU_CLK_OUT_SEL_MCU; + lock = int_lock(); + cmu->PERIPH_CLK = SET_BITFIELD(cmu->PERIPH_CLK, CMU_CFG_CLK_OUT, + id - HAL_CMU_CLOCK_OUT_MCU_32K); + int_unlock(lock); + } else if (HAL_CMU_CLOCK_OUT_CODEC_ADC_ANA <= id && + id <= HAL_CMU_CLOCK_OUT_CODEC_HCLK) { + sel = CMU_CLK_OUT_SEL_CODEC; + hal_codec_select_clock_out(id - HAL_CMU_CLOCK_OUT_CODEC_ADC_ANA); + } else if (HAL_CMU_CLOCK_OUT_BT_32K <= id && id <= HAL_CMU_CLOCK_OUT_BT_26M) { + sel = CMU_CLK_OUT_SEL_BT; + btcmu->CLK_OUT = SET_BITFIELD(btcmu->CLK_OUT, BT_CMU_CFG_CLK_OUT, + id - HAL_CMU_CLOCK_OUT_BT_32K); + } - if (sel < CMU_CLK_OUT_SEL_QTY) { - lock = int_lock(); - aoncmu->CLK_OUT = (aoncmu->CLK_OUT & ~(AON_CMU_SEL_CLK_OUT_MASK | AON_CMU_CFG_CLK_OUT_MASK)) | - AON_CMU_SEL_CLK_OUT(sel) | AON_CMU_CFG_CLK_OUT(cfg) | AON_CMU_EN_CLK_OUT; - int_unlock(lock); + if (sel < CMU_CLK_OUT_SEL_QTY) { + lock = int_lock(); + aoncmu->CLK_OUT = (aoncmu->CLK_OUT & + ~(AON_CMU_SEL_CLK_OUT_MASK | AON_CMU_CFG_CLK_OUT_MASK)) | + AON_CMU_SEL_CLK_OUT(sel) | AON_CMU_CFG_CLK_OUT(cfg) | + AON_CMU_EN_CLK_OUT; + int_unlock(lock); - return 0; - } + return 0; + } + return 1; +} + +void hal_cmu_clock_out_disable(void) { + uint32_t lock; + + lock = int_lock(); + aoncmu->CLK_OUT &= ~AON_CMU_EN_CLK_OUT; + int_unlock(lock); +} + +int hal_cmu_i2s_mclk_enable(enum HAL_CMU_I2S_MCLK_ID_T id) { + uint32_t lock; + + lock = int_lock(); + aoncmu->PCM_I2S_CLK = + SET_BITFIELD(aoncmu->PCM_I2S_CLK, AON_CMU_SEL_I2S_MCLK, id) | + AON_CMU_EN_I2S_MCLK; + int_unlock(lock); + + return 0; +} + +void hal_cmu_i2s_mclk_disable(void) { + uint32_t lock; + + lock = int_lock(); + aoncmu->PCM_I2S_CLK &= ~AON_CMU_EN_I2S_MCLK; + int_unlock(lock); +} + +int hal_cmu_pwm_set_freq(enum HAL_PWM_ID_T id, uint32_t freq) { + uint32_t lock; + int clk_32k; + uint32_t div; + + if (id >= HAL_PWM_ID_QTY) { return 1; -} + } -void hal_cmu_clock_out_disable(void) -{ - uint32_t lock; - - lock = int_lock(); - aoncmu->CLK_OUT &= ~AON_CMU_EN_CLK_OUT; - int_unlock(lock); -} - -int hal_cmu_i2s_mclk_enable(enum HAL_CMU_I2S_MCLK_ID_T id) -{ - uint32_t lock; - - lock = int_lock(); - aoncmu->PCM_I2S_CLK = SET_BITFIELD(aoncmu->PCM_I2S_CLK, AON_CMU_SEL_I2S_MCLK, id) | AON_CMU_EN_I2S_MCLK; - int_unlock(lock); - - return 0; -} - -void hal_cmu_i2s_mclk_disable(void) -{ - uint32_t lock; - - lock = int_lock(); - aoncmu->PCM_I2S_CLK &= ~AON_CMU_EN_I2S_MCLK; - int_unlock(lock); -} - -int hal_cmu_pwm_set_freq(enum HAL_PWM_ID_T id, uint32_t freq) -{ - uint32_t lock; - int clk_32k; - uint32_t div; - - if (id >= HAL_PWM_ID_QTY) { - return 1; + if (freq == 0) { + clk_32k = 1; + div = 0; + } else { + clk_32k = 0; + div = hal_cmu_get_crystal_freq() / freq; + if (div < 2) { + return 1; } - if (freq == 0) { - clk_32k = 1; - div = 0; - } else { - clk_32k = 0; - div = hal_cmu_get_crystal_freq() / freq; - if (div < 2) { - return 1; - } - - div -= 2; - if ((div & (AON_CMU_CFG_DIV_PWM0_MASK >> AON_CMU_CFG_DIV_PWM0_SHIFT)) != div) { - return 1; - } + div -= 2; + if ((div & (AON_CMU_CFG_DIV_PWM0_MASK >> AON_CMU_CFG_DIV_PWM0_SHIFT)) != + div) { + return 1; } + } - lock = int_lock(); - if (id == HAL_PWM_ID_0) { - aoncmu->PWM01_CLK = (aoncmu->PWM01_CLK & ~(AON_CMU_CFG_DIV_PWM0_MASK | AON_CMU_SEL_OSC_PWM0 | AON_CMU_EN_OSC_PWM0)) | - AON_CMU_CFG_DIV_PWM0(div) | (clk_32k ? 0 : (AON_CMU_SEL_OSC_PWM0 | AON_CMU_EN_OSC_PWM0)); - } else if (id == HAL_PWM_ID_1) { - aoncmu->PWM01_CLK = (aoncmu->PWM01_CLK & ~(AON_CMU_CFG_DIV_PWM1_MASK | AON_CMU_SEL_OSC_PWM1 | AON_CMU_EN_OSC_PWM1)) | - AON_CMU_CFG_DIV_PWM1(div) | (clk_32k ? 0 : (AON_CMU_SEL_OSC_PWM1 | AON_CMU_EN_OSC_PWM1)); - } else if (id == HAL_PWM_ID_2) { - aoncmu->PWM23_CLK = (aoncmu->PWM23_CLK & ~(AON_CMU_CFG_DIV_PWM2_MASK | AON_CMU_SEL_OSC_PWM2 | AON_CMU_EN_OSC_PWM2)) | - AON_CMU_CFG_DIV_PWM2(div) | (clk_32k ? 0 : (AON_CMU_SEL_OSC_PWM2 | AON_CMU_EN_OSC_PWM2)); - } else { - aoncmu->PWM23_CLK = (aoncmu->PWM23_CLK & ~(AON_CMU_CFG_DIV_PWM3_MASK | AON_CMU_SEL_OSC_PWM3 | AON_CMU_EN_OSC_PWM3)) | - AON_CMU_CFG_DIV_PWM3(div) | (clk_32k ? 0 : (AON_CMU_SEL_OSC_PWM3 | AON_CMU_EN_OSC_PWM3)); - } - int_unlock(lock); - return 0; + lock = int_lock(); + if (id == HAL_PWM_ID_0) { + aoncmu->PWM01_CLK = + (aoncmu->PWM01_CLK & ~(AON_CMU_CFG_DIV_PWM0_MASK | + AON_CMU_SEL_OSC_PWM0 | AON_CMU_EN_OSC_PWM0)) | + AON_CMU_CFG_DIV_PWM0(div) | + (clk_32k ? 0 : (AON_CMU_SEL_OSC_PWM0 | AON_CMU_EN_OSC_PWM0)); + } else if (id == HAL_PWM_ID_1) { + aoncmu->PWM01_CLK = + (aoncmu->PWM01_CLK & ~(AON_CMU_CFG_DIV_PWM1_MASK | + AON_CMU_SEL_OSC_PWM1 | AON_CMU_EN_OSC_PWM1)) | + AON_CMU_CFG_DIV_PWM1(div) | + (clk_32k ? 0 : (AON_CMU_SEL_OSC_PWM1 | AON_CMU_EN_OSC_PWM1)); + } else if (id == HAL_PWM_ID_2) { + aoncmu->PWM23_CLK = + (aoncmu->PWM23_CLK & ~(AON_CMU_CFG_DIV_PWM2_MASK | + AON_CMU_SEL_OSC_PWM2 | AON_CMU_EN_OSC_PWM2)) | + AON_CMU_CFG_DIV_PWM2(div) | + (clk_32k ? 0 : (AON_CMU_SEL_OSC_PWM2 | AON_CMU_EN_OSC_PWM2)); + } else { + aoncmu->PWM23_CLK = + (aoncmu->PWM23_CLK & ~(AON_CMU_CFG_DIV_PWM3_MASK | + AON_CMU_SEL_OSC_PWM3 | AON_CMU_EN_OSC_PWM3)) | + AON_CMU_CFG_DIV_PWM3(div) | + (clk_32k ? 0 : (AON_CMU_SEL_OSC_PWM3 | AON_CMU_EN_OSC_PWM3)); + } + int_unlock(lock); + return 0; } -void hal_cmu_jtag_enable(void) -{ - uint32_t lock; +void hal_cmu_jtag_enable(void) { + uint32_t lock; - lock = int_lock(); - cmu->MCU_TIMER &= ~(CMU_SECURE_BOOT_JTAG | CMU_SECURE_BOOT_I2C); - int_unlock(lock); + lock = int_lock(); + cmu->MCU_TIMER &= ~(CMU_SECURE_BOOT_JTAG | CMU_SECURE_BOOT_I2C); + int_unlock(lock); } -void hal_cmu_jtag_disable(void) -{ - uint32_t lock; +void hal_cmu_jtag_disable(void) { + uint32_t lock; - lock = int_lock(); - cmu->MCU_TIMER |= (CMU_SECURE_BOOT_JTAG | CMU_SECURE_BOOT_I2C); - int_unlock(lock); + lock = int_lock(); + cmu->MCU_TIMER |= (CMU_SECURE_BOOT_JTAG | CMU_SECURE_BOOT_I2C); + int_unlock(lock); } -void hal_cmu_jtag_clock_enable(void) -{ - aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_TOP_JTAG_ENABLE; +void hal_cmu_jtag_clock_enable(void) { + aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_TOP_JTAG_ENABLE; } -void hal_cmu_jtag_clock_disable(void) -{ - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_JTAG_DISABLE; +void hal_cmu_jtag_clock_disable(void) { + aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_JTAG_DISABLE; } -void hal_cmu_rom_clock_init(void) -{ - aoncmu->CODEC_DIV = (aoncmu->CODEC_DIV & ~AON_CMU_SEL_CLK_OSCX2) | - AON_CMU_BYPASS_LOCK_PLLBB | AON_CMU_BYPASS_LOCK_PLLAUD | AON_CMU_SEL_CLK_OSC; - // Enable PMU fast clock - aoncmu->CLK_OUT &= ~(AON_CMU_SEL_DCDC_PLL | AON_CMU_SEL_DCDC_OSCX2); - aoncmu->CLK_OUT |= AON_CMU_BYPASS_DIV_DCDC; - aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_DCDC0_ENABLE; +void hal_cmu_rom_clock_init(void) { + aoncmu->CODEC_DIV = (aoncmu->CODEC_DIV & ~AON_CMU_SEL_CLK_OSCX2) | + AON_CMU_BYPASS_LOCK_PLLBB | AON_CMU_BYPASS_LOCK_PLLAUD | + AON_CMU_SEL_CLK_OSC; + // Enable PMU fast clock + aoncmu->CLK_OUT &= ~(AON_CMU_SEL_DCDC_PLL | AON_CMU_SEL_DCDC_OSCX2); + aoncmu->CLK_OUT |= AON_CMU_BYPASS_DIV_DCDC; + aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_DCDC0_ENABLE; } -void hal_cmu_init_chip_feature(uint16_t feature) -{ - aoncmu->CHIP_FEATURE = feature | AON_CMU_EFUSE_LOCK; +void hal_cmu_init_chip_feature(uint16_t feature) { + aoncmu->CHIP_FEATURE = feature | AON_CMU_EFUSE_LOCK; } -void BOOT_TEXT_FLASH_LOC hal_cmu_osc_x2_enable(void) -{ - // Debug Select CMU REG F4 - cmu->MCU_TIMER = SET_BITFIELD(cmu->MCU_TIMER, CMU_DEBUG_REG_SEL, CMU_DEBUG_REG_SEL_DEBUG); - // Enable OSCX2 for MCU peripheral - aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_OSCX2_MCU_ENABLE; +void BOOT_TEXT_FLASH_LOC hal_cmu_osc_x2_enable(void) { + // Debug Select CMU REG F4 + cmu->MCU_TIMER = + SET_BITFIELD(cmu->MCU_TIMER, CMU_DEBUG_REG_SEL, CMU_DEBUG_REG_SEL_DEBUG); + // Enable OSCX2 for MCU peripheral + aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_OSCX2_MCU_ENABLE; } -void BOOT_TEXT_FLASH_LOC hal_cmu_osc_x4_enable(void) -{ +void BOOT_TEXT_FLASH_LOC hal_cmu_osc_x4_enable(void) { #ifdef ANA_26M_X4_ENABLE - aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_X4_ANA_ENABLE; + aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_X4_ANA_ENABLE; #endif #ifdef OSC_26M_X4_AUD2BB - aoncmu->CLK_SELECT |= AON_CMU_SEL_X4_SYS; - aoncmu->CLK_SELECT &= ~AON_CMU_SEL_X4_DIG; + aoncmu->CLK_SELECT |= AON_CMU_SEL_X4_SYS; + aoncmu->CLK_SELECT &= ~AON_CMU_SEL_X4_DIG; #endif } -void BOOT_TEXT_FLASH_LOC hal_cmu_module_init_state(void) -{ - aoncmu->CODEC_DIV = (aoncmu->CODEC_DIV & ~AON_CMU_SEL_CLK_OSCX2) | - AON_CMU_BYPASS_LOCK_PLLBB | AON_CMU_BYPASS_LOCK_PLLAUD | AON_CMU_SEL_CLK_OSC; - // Slow down PMU fast clock - aoncmu->CLK_OUT = (aoncmu->CLK_OUT & ~(AON_CMU_BYPASS_DIV_DCDC | AON_CMU_CFG_DIV_DCDC_MASK)) | AON_CMU_CFG_DIV_DCDC(2); +void BOOT_TEXT_FLASH_LOC hal_cmu_module_init_state(void) { + aoncmu->CODEC_DIV = (aoncmu->CODEC_DIV & ~AON_CMU_SEL_CLK_OSCX2) | + AON_CMU_BYPASS_LOCK_PLLBB | AON_CMU_BYPASS_LOCK_PLLAUD | + AON_CMU_SEL_CLK_OSC; + // Slow down PMU fast clock + aoncmu->CLK_OUT = (aoncmu->CLK_OUT & + ~(AON_CMU_BYPASS_DIV_DCDC | AON_CMU_CFG_DIV_DCDC_MASK)) | + AON_CMU_CFG_DIV_DCDC(2); - // DMA channel config - cmu->ADMA_CH0_4_REQ = - // codec - CMU_ADMA_CH0_REQ_IDX(0) | CMU_ADMA_CH1_REQ_IDX(1) | + // DMA channel config + cmu->ADMA_CH0_4_REQ = + // codec + CMU_ADMA_CH0_REQ_IDX(0) | CMU_ADMA_CH1_REQ_IDX(1) | #ifdef CODEC_DSD - // codec_dsd - CMU_ADMA_CH2_REQ_IDX(16) | CMU_ADMA_CH3_REQ_IDX(17) | + // codec_dsd + CMU_ADMA_CH2_REQ_IDX(16) | CMU_ADMA_CH3_REQ_IDX(17) | #else - // btpcm - CMU_ADMA_CH2_REQ_IDX(2) | CMU_ADMA_CH3_REQ_IDX(3) | + // btpcm + CMU_ADMA_CH2_REQ_IDX(2) | CMU_ADMA_CH3_REQ_IDX(3) | #endif - // i2s0 - CMU_ADMA_CH4_REQ_IDX(4); - cmu->ADMA_CH5_9_REQ = - // i2s0 - CMU_ADMA_CH5_REQ_IDX(5) | - // fir - CMU_ADMA_CH6_REQ_IDX(6) | CMU_ADMA_CH7_REQ_IDX(7) | - // spdif - CMU_ADMA_CH8_REQ_IDX(8) | CMU_ADMA_CH9_REQ_IDX(9); - cmu->ADMA_CH10_14_REQ = - // iir - CMU_ADMA_CH10_REQ_IDX(10) | CMU_ADMA_CH11_REQ_IDX(11) | - // btdump - CMU_ADMA_CH12_REQ_IDX(12) | - // mc - CMU_ADMA_CH13_REQ_IDX(13) | - // i2s1 - CMU_ADMA_CH14_REQ_IDX(18); - cmu->ADMA_CH15_REQ = - // i2s1 - CMU_ADMA_CH15_REQ_IDX(19); - cmu->GDMA_CH0_4_REQ = - // flash - CMU_GDMA_CH0_REQ_IDX(20) | - // sdmmc - CMU_GDMA_CH1_REQ_IDX(21) | - // i2c0 - CMU_GDMA_CH2_REQ_IDX(22) | CMU_GDMA_CH3_REQ_IDX(23) | - // spi - CMU_GDMA_CH4_REQ_IDX(24); - cmu->GDMA_CH5_9_REQ = - // spi - CMU_GDMA_CH5_REQ_IDX(25) | - // spilcd - CMU_GDMA_CH6_REQ_IDX(26) | CMU_GDMA_CH7_REQ_IDX(27) | - // uart0 - CMU_GDMA_CH8_REQ_IDX(28) | CMU_GDMA_CH9_REQ_IDX(29); - cmu->GDMA_CH10_14_REQ = - // uart1 - CMU_GDMA_CH10_REQ_IDX(30) | CMU_GDMA_CH11_REQ_IDX(31) | - // i2c1 - CMU_GDMA_CH12_REQ_IDX(32) | CMU_GDMA_CH13_REQ_IDX(33) | - // uart2 - CMU_GDMA_CH14_REQ_IDX(34); - cmu->GDMA_CH15_REQ = - // uart2 - CMU_GDMA_CH15_REQ_IDX(35); + // i2s0 + CMU_ADMA_CH4_REQ_IDX(4); + cmu->ADMA_CH5_9_REQ = + // i2s0 + CMU_ADMA_CH5_REQ_IDX(5) | + // fir + CMU_ADMA_CH6_REQ_IDX(6) | CMU_ADMA_CH7_REQ_IDX(7) | + // spdif + CMU_ADMA_CH8_REQ_IDX(8) | CMU_ADMA_CH9_REQ_IDX(9); + cmu->ADMA_CH10_14_REQ = + // iir + CMU_ADMA_CH10_REQ_IDX(10) | CMU_ADMA_CH11_REQ_IDX(11) | + // btdump + CMU_ADMA_CH12_REQ_IDX(12) | + // mc + CMU_ADMA_CH13_REQ_IDX(13) | + // i2s1 + CMU_ADMA_CH14_REQ_IDX(18); + cmu->ADMA_CH15_REQ = + // i2s1 + CMU_ADMA_CH15_REQ_IDX(19); + cmu->GDMA_CH0_4_REQ = + // flash + CMU_GDMA_CH0_REQ_IDX(20) | + // sdmmc + CMU_GDMA_CH1_REQ_IDX(21) | + // i2c0 + CMU_GDMA_CH2_REQ_IDX(22) | CMU_GDMA_CH3_REQ_IDX(23) | + // spi + CMU_GDMA_CH4_REQ_IDX(24); + cmu->GDMA_CH5_9_REQ = + // spi + CMU_GDMA_CH5_REQ_IDX(25) | + // spilcd + CMU_GDMA_CH6_REQ_IDX(26) | CMU_GDMA_CH7_REQ_IDX(27) | + // uart0 + CMU_GDMA_CH8_REQ_IDX(28) | CMU_GDMA_CH9_REQ_IDX(29); + cmu->GDMA_CH10_14_REQ = + // uart1 + CMU_GDMA_CH10_REQ_IDX(30) | CMU_GDMA_CH11_REQ_IDX(31) | + // i2c1 + CMU_GDMA_CH12_REQ_IDX(32) | CMU_GDMA_CH13_REQ_IDX(33) | + // uart2 + CMU_GDMA_CH14_REQ_IDX(34); + cmu->GDMA_CH15_REQ = + // uart2 + CMU_GDMA_CH15_REQ_IDX(35); #ifndef SIMU - cmu->ORESET_SET = SYS_ORST_USB | SYS_ORST_SDMMC | SYS_ORST_WDT | SYS_ORST_TIMER2 | - SYS_ORST_I2C0 | SYS_ORST_I2C1 | SYS_ORST_SPI | SYS_ORST_SLCD | SYS_ORST_SPI_PHY | - SYS_ORST_UART0 | SYS_ORST_UART1 | SYS_ORST_UART2 | SYS_ORST_I2S0 | SYS_ORST_SPDIF0 | SYS_ORST_PCM | - SYS_ORST_USB32K | SYS_ORST_I2S1; - cmu->PRESET_SET = SYS_PRST_WDT | SYS_PRST_TIMER2 | SYS_PRST_I2C0 | SYS_PRST_I2C1 | - SYS_PRST_SPI | SYS_PRST_SLCD | SYS_PRST_SPI_PHY | - SYS_PRST_UART0 | SYS_PRST_UART1 | SYS_PRST_UART2 | - SYS_PRST_PCM | SYS_PRST_I2S0 | SYS_PRST_SPDIF0 | SYS_PRST_I2S1 | SYS_PRST_BCM; - cmu->HRESET_SET = SYS_HRST_SDMMC | SYS_HRST_USBC | SYS_HRST_CODEC | SYS_HRST_FFT | - SYS_HRST_USBH | SYS_HRST_SENSOR_HUB | SYS_HRST_BT_DUMP | SYS_HRST_CP | SYS_HRST_BCM | SYS_HRST_ICACHE0; + cmu->ORESET_SET = SYS_ORST_USB | SYS_ORST_SDMMC | SYS_ORST_WDT | + SYS_ORST_TIMER2 | SYS_ORST_I2C0 | SYS_ORST_I2C1 | + SYS_ORST_SPI | SYS_ORST_SLCD | SYS_ORST_SPI_PHY | + SYS_ORST_UART0 | SYS_ORST_UART1 | SYS_ORST_UART2 | + SYS_ORST_I2S0 | SYS_ORST_SPDIF0 | SYS_ORST_PCM | + SYS_ORST_USB32K | SYS_ORST_I2S1; + cmu->PRESET_SET = SYS_PRST_WDT | SYS_PRST_TIMER2 | SYS_PRST_I2C0 | + SYS_PRST_I2C1 | SYS_PRST_SPI | SYS_PRST_SLCD | + SYS_PRST_SPI_PHY | SYS_PRST_UART0 | SYS_PRST_UART1 | + SYS_PRST_UART2 | SYS_PRST_PCM | SYS_PRST_I2S0 | + SYS_PRST_SPDIF0 | SYS_PRST_I2S1 | SYS_PRST_BCM; + cmu->HRESET_SET = SYS_HRST_SDMMC | SYS_HRST_USBC | SYS_HRST_CODEC | + SYS_HRST_FFT | SYS_HRST_USBH | SYS_HRST_SENSOR_HUB | + SYS_HRST_BT_DUMP | SYS_HRST_CP | SYS_HRST_BCM | + SYS_HRST_ICACHE0; - cmu->OCLK_DISABLE = SYS_OCLK_USB | SYS_OCLK_SDMMC | SYS_OCLK_WDT | SYS_OCLK_TIMER2 | - SYS_OCLK_I2C0 | SYS_OCLK_I2C1 | SYS_OCLK_SPI | SYS_OCLK_SLCD | SYS_OCLK_SPI_PHY | - SYS_OCLK_UART0 | SYS_OCLK_UART1 | SYS_OCLK_UART2 | SYS_OCLK_I2S0 | SYS_OCLK_SPDIF0 | SYS_OCLK_PCM | - SYS_OCLK_USB32K | SYS_OCLK_I2S1; - cmu->PCLK_DISABLE = SYS_PCLK_WDT | SYS_PCLK_TIMER2 | SYS_PCLK_I2C0 | SYS_PCLK_I2C1 | - SYS_PCLK_SPI | SYS_PCLK_SLCD | SYS_PCLK_SPI_PHY | - SYS_PCLK_UART0 | SYS_PCLK_UART1 | SYS_PCLK_UART2 | - SYS_PCLK_PCM | SYS_PCLK_I2S0 | SYS_PCLK_SPDIF0 | SYS_PCLK_I2S1 | SYS_PCLK_BCM; - cmu->HCLK_DISABLE = SYS_HCLK_SDMMC | SYS_HCLK_USBC | SYS_HCLK_CODEC | SYS_HCLK_FFT | - SYS_HCLK_USBH | SYS_HCLK_SENSOR_HUB | SYS_HCLK_BT_DUMP | SYS_HCLK_CP | SYS_HCLK_BCM | SYS_HCLK_ICACHE0; + cmu->OCLK_DISABLE = SYS_OCLK_USB | SYS_OCLK_SDMMC | SYS_OCLK_WDT | + SYS_OCLK_TIMER2 | SYS_OCLK_I2C0 | SYS_OCLK_I2C1 | + SYS_OCLK_SPI | SYS_OCLK_SLCD | SYS_OCLK_SPI_PHY | + SYS_OCLK_UART0 | SYS_OCLK_UART1 | SYS_OCLK_UART2 | + SYS_OCLK_I2S0 | SYS_OCLK_SPDIF0 | SYS_OCLK_PCM | + SYS_OCLK_USB32K | SYS_OCLK_I2S1; + cmu->PCLK_DISABLE = SYS_PCLK_WDT | SYS_PCLK_TIMER2 | SYS_PCLK_I2C0 | + SYS_PCLK_I2C1 | SYS_PCLK_SPI | SYS_PCLK_SLCD | + SYS_PCLK_SPI_PHY | SYS_PCLK_UART0 | SYS_PCLK_UART1 | + SYS_PCLK_UART2 | SYS_PCLK_PCM | SYS_PCLK_I2S0 | + SYS_PCLK_SPDIF0 | SYS_PCLK_I2S1 | SYS_PCLK_BCM; + cmu->HCLK_DISABLE = SYS_HCLK_SDMMC | SYS_HCLK_USBC | SYS_HCLK_CODEC | + SYS_HCLK_FFT | SYS_HCLK_USBH | SYS_HCLK_SENSOR_HUB | + SYS_HCLK_BT_DUMP | SYS_HCLK_CP | SYS_HCLK_BCM | + SYS_HCLK_ICACHE0; - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_PLL_CODEC_DISABLE | AON_CMU_EN_CLK_CODEC_HCLK_DISABLE | AON_CMU_EN_CLK_CODEC_DISABLE | - AON_CMU_EN_CLK_CODEC_IIR_DISABLE | AON_CMU_EN_CLK_PLL_BT_DISABLE | - AON_CMU_EN_CLK_60M_BT_DISABLE | AON_CMU_EN_CLK_OSCX2_BT_DISABLE | AON_CMU_EN_CLK_OSC_BT_DISABLE | - AON_CMU_EN_CLK_32K_BT_DISABLE | AON_CMU_EN_CLK_PLL_PER_DISABLE; + aoncmu->TOP_CLK_DISABLE = + AON_CMU_EN_CLK_PLL_CODEC_DISABLE | AON_CMU_EN_CLK_CODEC_HCLK_DISABLE | + AON_CMU_EN_CLK_CODEC_DISABLE | AON_CMU_EN_CLK_CODEC_IIR_DISABLE | + AON_CMU_EN_CLK_PLL_BT_DISABLE | AON_CMU_EN_CLK_60M_BT_DISABLE | + AON_CMU_EN_CLK_OSCX2_BT_DISABLE | AON_CMU_EN_CLK_OSC_BT_DISABLE | + AON_CMU_EN_CLK_32K_BT_DISABLE | AON_CMU_EN_CLK_PLL_PER_DISABLE; - aoncmu->RESET_SET = AON_CMU_ARESETN_SET(AON_ARST_PWM) | - AON_CMU_ORESETN_SET(AON_ORST_PWM0 | AON_ORST_PWM1 | AON_ORST_PWM2 | AON_ORST_PWM3) | - AON_CMU_SOFT_RSTN_CODEC_SET | AON_CMU_SOFT_RSTN_BT_SET | AON_CMU_SOFT_RSTN_BTCPU_SET; + aoncmu->RESET_SET = AON_CMU_ARESETN_SET(AON_ARST_PWM) | + AON_CMU_ORESETN_SET(AON_ORST_PWM0 | AON_ORST_PWM1 | + AON_ORST_PWM2 | AON_ORST_PWM3) | + AON_CMU_SOFT_RSTN_CODEC_SET | AON_CMU_SOFT_RSTN_BT_SET | + AON_CMU_SOFT_RSTN_BTCPU_SET; - aoncmu->MOD_CLK_DISABLE = AON_CMU_MANUAL_ACLK_DISABLE(AON_ACLK_PWM) | - AON_CMU_MANUAL_OCLK_DISABLE(AON_OCLK_PWM0 | AON_OCLK_PWM1 | AON_OCLK_PWM2 | AON_OCLK_PWM3); + aoncmu->MOD_CLK_DISABLE = + AON_CMU_MANUAL_ACLK_DISABLE(AON_ACLK_PWM) | + AON_CMU_MANUAL_OCLK_DISABLE(AON_OCLK_PWM0 | AON_OCLK_PWM1 | + AON_OCLK_PWM2 | AON_OCLK_PWM3); - aoncmu->MOD_CLK_MODE &= ~AON_CMU_MODE_ACLK(AON_ACLK_CMU | AON_ACLK_GPIO_INT | AON_ACLK_WDT | AON_ACLK_PWM | - AON_ACLK_TIMER | AON_ACLK_PSC | AON_ACLK_IOMUX); - cmu->PCLK_MODE &= ~(SYS_PCLK_CMU | SYS_PCLK_WDT | SYS_PCLK_TIMER0 | SYS_PCLK_TIMER1 | SYS_PCLK_TIMER2); + aoncmu->MOD_CLK_MODE &= ~AON_CMU_MODE_ACLK( + AON_ACLK_CMU | AON_ACLK_GPIO_INT | AON_ACLK_WDT | AON_ACLK_PWM | + AON_ACLK_TIMER | AON_ACLK_PSC | AON_ACLK_IOMUX); + cmu->PCLK_MODE &= ~(SYS_PCLK_CMU | SYS_PCLK_WDT | SYS_PCLK_TIMER0 | + SYS_PCLK_TIMER1 | SYS_PCLK_TIMER2); - //cmu->HCLK_MODE = 0; - //cmu->PCLK_MODE = SYS_PCLK_UART0 | SYS_PCLK_UART1 | SYS_PCLK_UART2; - //cmu->OCLK_MODE = 0; + // cmu->HCLK_MODE = 0; + // cmu->PCLK_MODE = SYS_PCLK_UART0 | SYS_PCLK_UART1 | SYS_PCLK_UART2; + // cmu->OCLK_MODE = 0; #endif #ifdef CORE_SLEEP_POWER_DOWN - hal_cmu_set_wakeup_pc((uint32_t)hal_sleep_core_power_up); + hal_cmu_set_wakeup_pc((uint32_t)hal_sleep_core_power_up); #endif - hal_psc_init(); + hal_psc_init(); } -void BOOT_TEXT_FLASH_LOC hal_cmu_ema_init(void) -{ - // Never change EMA in best2300 +void BOOT_TEXT_FLASH_LOC hal_cmu_ema_init(void) { + // Never change EMA in best2300 } -void hal_cmu_lpu_wait_26m_ready(void) -{ - while ((cmu->WAKEUP_CLK_CFG & CMU_LPU_STATUS_26M) == 0); +void hal_cmu_lpu_wait_26m_ready(void) { + while ((cmu->WAKEUP_CLK_CFG & CMU_LPU_STATUS_26M) == 0) + ; } -int hal_cmu_lpu_busy(void) -{ - if ((cmu->WAKEUP_CLK_CFG & CMU_LPU_AUTO_SWITCH26) && - (cmu->WAKEUP_CLK_CFG & CMU_LPU_STATUS_26M) == 0) { - return 1; - } - if ((cmu->WAKEUP_CLK_CFG & CMU_LPU_AUTO_SWITCHPLL) && - (cmu->WAKEUP_CLK_CFG & CMU_LPU_STATUS_PLL) == 0) { - return 1; - } - return 0; +int hal_cmu_lpu_busy(void) { + if ((cmu->WAKEUP_CLK_CFG & CMU_LPU_AUTO_SWITCH26) && + (cmu->WAKEUP_CLK_CFG & CMU_LPU_STATUS_26M) == 0) { + return 1; + } + if ((cmu->WAKEUP_CLK_CFG & CMU_LPU_AUTO_SWITCHPLL) && + (cmu->WAKEUP_CLK_CFG & CMU_LPU_STATUS_PLL) == 0) { + return 1; + } + return 0; } -int BOOT_TEXT_FLASH_LOC hal_cmu_lpu_init(enum HAL_CMU_LPU_CLK_CFG_T cfg) -{ - uint32_t lpu_clk; - uint32_t timer_26m; - uint32_t timer_pll; +int BOOT_TEXT_FLASH_LOC hal_cmu_lpu_init(enum HAL_CMU_LPU_CLK_CFG_T cfg) { + uint32_t lpu_clk; + uint32_t timer_26m; + uint32_t timer_pll; - timer_26m = LPU_TIMER_US(TICKS_TO_US(HAL_CMU_26M_READY_TIMEOUT)); - timer_pll = LPU_TIMER_US(TICKS_TO_US(HAL_CMU_PLL_LOCKED_TIMEOUT)); + timer_26m = LPU_TIMER_US(TICKS_TO_US(HAL_CMU_26M_READY_TIMEOUT)); + timer_pll = LPU_TIMER_US(TICKS_TO_US(HAL_CMU_PLL_LOCKED_TIMEOUT)); - if (cfg >= HAL_CMU_LPU_CLK_QTY) { - return 1; - } - if ((timer_26m & (CMU_TIMER_WT26_MASK >> CMU_TIMER_WT26_SHIFT)) != timer_26m) { - return 2; - } - if ((timer_pll & (CMU_TIMER_WTPLL_MASK >> CMU_TIMER_WTPLL_SHIFT)) != timer_pll) { - return 3; - } - if (hal_cmu_lpu_busy()) { - return -1; - } + if (cfg >= HAL_CMU_LPU_CLK_QTY) { + return 1; + } + if ((timer_26m & (CMU_TIMER_WT26_MASK >> CMU_TIMER_WT26_SHIFT)) != + timer_26m) { + return 2; + } + if ((timer_pll & (CMU_TIMER_WTPLL_MASK >> CMU_TIMER_WTPLL_SHIFT)) != + timer_pll) { + return 3; + } + if (hal_cmu_lpu_busy()) { + return -1; + } - if (cfg == HAL_CMU_LPU_CLK_26M) { - lpu_clk = CMU_LPU_AUTO_SWITCH26; - } else if (cfg == HAL_CMU_LPU_CLK_PLL) { - lpu_clk = CMU_LPU_AUTO_SWITCHPLL | CMU_LPU_AUTO_SWITCH26; - } else { - lpu_clk = 0; - } + if (cfg == HAL_CMU_LPU_CLK_26M) { + lpu_clk = CMU_LPU_AUTO_SWITCH26; + } else if (cfg == HAL_CMU_LPU_CLK_PLL) { + lpu_clk = CMU_LPU_AUTO_SWITCHPLL | CMU_LPU_AUTO_SWITCH26; + } else { + lpu_clk = 0; + } - if (lpu_clk & CMU_LPU_AUTO_SWITCH26) { - // Disable RAM wakeup early - cmu->MCU_TIMER &= ~CMU_RAM_RETN_UP_EARLY; - // MCU/ROM/RAM auto clock gating (which depends on RAM gating signal) - cmu->HCLK_MODE &= ~(SYS_HCLK_MCU | SYS_HCLK_ROM0 | SYS_HCLK_ROM1 | SYS_HCLK_ROM2 | - SYS_HCLK_RAM0 | SYS_HCLK_RAM1 | SYS_HCLK_RAM2 | SYS_HCLK_RAMRET | SYS_HCLK_RAM3 | - SYS_HCLK_RAM4 | SYS_HCLK_RAM5 | SYS_HCLK_RAM6); - // AON_CMU enable auto switch 26M (AON_CMU must have selected 26M and disabled 52M/32K already) - aoncmu->CLK_SELECT |= AON_CMU_LPU_AUTO_SWITCH26; - } else { - // AON_CMU disable auto switch 26M - aoncmu->CLK_SELECT &= ~AON_CMU_LPU_AUTO_SWITCH26; - } + if (lpu_clk & CMU_LPU_AUTO_SWITCH26) { + // Disable RAM wakeup early + cmu->MCU_TIMER &= ~CMU_RAM_RETN_UP_EARLY; + // MCU/ROM/RAM auto clock gating (which depends on RAM gating signal) + cmu->HCLK_MODE &= + ~(SYS_HCLK_MCU | SYS_HCLK_ROM0 | SYS_HCLK_ROM1 | SYS_HCLK_ROM2 | + SYS_HCLK_RAM0 | SYS_HCLK_RAM1 | SYS_HCLK_RAM2 | SYS_HCLK_RAMRET | + SYS_HCLK_RAM3 | SYS_HCLK_RAM4 | SYS_HCLK_RAM5 | SYS_HCLK_RAM6); + // AON_CMU enable auto switch 26M (AON_CMU must have selected 26M and + // disabled 52M/32K already) + aoncmu->CLK_SELECT |= AON_CMU_LPU_AUTO_SWITCH26; + } else { + // AON_CMU disable auto switch 26M + aoncmu->CLK_SELECT &= ~AON_CMU_LPU_AUTO_SWITCH26; + } - cmu->WAKEUP_CLK_CFG = CMU_TIMER_WT26(timer_26m) | CMU_TIMER_WTPLL(0) | lpu_clk; - if (timer_pll) { - hal_sys_timer_delay(US_TO_TICKS(60)); - cmu->WAKEUP_CLK_CFG = CMU_TIMER_WT26(timer_26m) | CMU_TIMER_WTPLL(timer_pll) | lpu_clk; - } - return 0; + cmu->WAKEUP_CLK_CFG = + CMU_TIMER_WT26(timer_26m) | CMU_TIMER_WTPLL(0) | lpu_clk; + if (timer_pll) { + hal_sys_timer_delay(US_TO_TICKS(60)); + cmu->WAKEUP_CLK_CFG = + CMU_TIMER_WT26(timer_26m) | CMU_TIMER_WTPLL(timer_pll) | lpu_clk; + } + return 0; } #ifdef CORE_SLEEP_POWER_DOWN -static int SRAM_TEXT_LOC hal_cmu_lpu_sleep_pd(void) -{ - uint32_t start; - uint32_t timeout; - uint32_t saved_hclk; - uint32_t saved_oclk; - uint32_t saved_top_clk; - uint32_t saved_clk_cfg; - uint32_t saved_periph_clk; - uint32_t saved_sys_div; - uint32_t saved_uart_clk; - uint32_t saved_codec_div; - uint32_t pll_locked; - uint32_t saved_cpu_regs[50]; - register uint32_t sp asm("sp"); - uint32_t stack_limit; +static int SRAM_TEXT_LOC hal_cmu_lpu_sleep_pd(void) { + uint32_t start; + uint32_t timeout; + uint32_t saved_hclk; + uint32_t saved_oclk; + uint32_t saved_top_clk; + uint32_t saved_clk_cfg; + uint32_t saved_periph_clk; + uint32_t saved_sys_div; + uint32_t saved_uart_clk; + uint32_t saved_codec_div; + uint32_t pll_locked; + uint32_t saved_cpu_regs[50]; + register uint32_t sp asm("sp"); + uint32_t stack_limit; #ifdef ROM_BUILD - extern uint32_t __rom_StackLimit[]; - stack_limit = (uint32_t)__rom_StackLimit; + extern uint32_t __rom_StackLimit[]; + stack_limit = (uint32_t)__rom_StackLimit; #else - extern uint32_t __StackLimit[]; - stack_limit = (uint32_t)__StackLimit; + extern uint32_t __StackLimit[]; + stack_limit = (uint32_t)__StackLimit; #endif - if (sp < stack_limit + 20 * 4) { - do { - asm volatile("nop; nop; nop; nop"); - } while (1); - } + if (sp < stack_limit + 20 * 4) { + do { + asm volatile("nop; nop; nop; nop"); + } while (1); + } - NVIC_PowerDownSleep(saved_cpu_regs, ARRAY_SIZE(saved_cpu_regs)); + NVIC_PowerDownSleep(saved_cpu_regs, ARRAY_SIZE(saved_cpu_regs)); - saved_hclk = cmu->HCLK_ENABLE; - saved_oclk = cmu->OCLK_ENABLE; - saved_periph_clk = cmu->PERIPH_CLK; - saved_sys_div = cmu->SYS_DIV; - saved_uart_clk = cmu->UART_CLK; - saved_codec_div = aoncmu->CODEC_DIV; + saved_hclk = cmu->HCLK_ENABLE; + saved_oclk = cmu->OCLK_ENABLE; + saved_periph_clk = cmu->PERIPH_CLK; + saved_sys_div = cmu->SYS_DIV; + saved_uart_clk = cmu->UART_CLK; + saved_codec_div = aoncmu->CODEC_DIV; - saved_top_clk = aoncmu->TOP_CLK_ENABLE; - saved_clk_cfg = cmu->SYS_CLK_ENABLE; + saved_top_clk = aoncmu->TOP_CLK_ENABLE; + saved_clk_cfg = cmu->SYS_CLK_ENABLE; - // Switch VAD clock to AON and disable codec HCLK - aoncmu->CODEC_DIV |= AON_CMU_SEL_CODEC_HCLK_AON; - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_CODEC_HCLK_DISABLE; + // Switch VAD clock to AON and disable codec HCLK + aoncmu->CODEC_DIV |= AON_CMU_SEL_CODEC_HCLK_AON; + aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_CODEC_HCLK_DISABLE; - // Disable memory/flash clock - cmu->OCLK_DISABLE = SYS_OCLK_FLASH; - cmu->HCLK_DISABLE = SYS_HCLK_FLASH; + // Disable memory/flash clock + cmu->OCLK_DISABLE = SYS_OCLK_FLASH; + cmu->HCLK_DISABLE = SYS_HCLK_FLASH; #ifndef ROM_BUILD - // Reset pll div if pll is enabled - if (saved_top_clk & AON_CMU_PU_PLLAUD_ENABLE) { - pmu_pll_div_reset_set(HAL_CMU_PLL_AUD); - } - if (saved_top_clk & AON_CMU_PU_PLLBB_ENABLE) { - pmu_pll_div_reset_set(HAL_CMU_PLL_USB); - } + // Reset pll div if pll is enabled + if (saved_top_clk & AON_CMU_PU_PLLAUD_ENABLE) { + pmu_pll_div_reset_set(HAL_CMU_PLL_AUD); + } + if (saved_top_clk & AON_CMU_PU_PLLBB_ENABLE) { + pmu_pll_div_reset_set(HAL_CMU_PLL_USB); + } #endif + // Switch system freq to 26M + cmu->SYS_CLK_ENABLE = CMU_SEL_OSC_SYS_ENABLE; + cmu->SYS_CLK_DISABLE = CMU_SEL_OSCX2_SYS_DISABLE | CMU_SEL_PLL_SYS_DISABLE; + cmu->SYS_CLK_DISABLE = CMU_RSTN_DIV_SYS_DISABLE; + + // Shutdown PLLs + if (saved_top_clk & AON_CMU_PU_PLLAUD_ENABLE) { + aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLAUD_DISABLE; + aoncmu->TOP_CLK_DISABLE = AON_CMU_PU_PLLAUD_DISABLE; + } + if (saved_top_clk & AON_CMU_PU_PLLBB_ENABLE) { + aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLBB_DISABLE; + aoncmu->TOP_CLK_DISABLE = AON_CMU_PU_PLLBB_DISABLE; + } + if (saved_top_clk & AON_CMU_PU_PLLUSB_ENABLE) { + aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLUSB_DISABLE; + aoncmu->TOP_CLK_DISABLE = AON_CMU_PU_PLLUSB_DISABLE; + } + + // Set power down wakeup bootmode + aoncmu->BOOTMODE = (aoncmu->BOOTMODE | HAL_SW_BOOTMODE_POWER_DOWN_WAKEUP) & + HAL_SW_BOOTMODE_MASK; + // Set AON_CMU clock to 32K + aoncmu->CODEC_DIV &= ~(AON_CMU_SEL_CLK_OSC | AON_CMU_SEL_CLK_OSCX2); + + hal_sleep_core_power_down(); + + while ((cmu->WAKEUP_CLK_CFG & CMU_LPU_STATUS_26M) == 0) + ; + + // Restore AON_CMU clock + aoncmu->CODEC_DIV = saved_codec_div; + // Clear power down wakeup bootmode + aoncmu->BOOTMODE = (aoncmu->BOOTMODE & ~HAL_SW_BOOTMODE_POWER_DOWN_WAKEUP) & + HAL_SW_BOOTMODE_MASK; + + // Disable memory/flash clock + cmu->OCLK_DISABLE = SYS_OCLK_FLASH; + cmu->HCLK_DISABLE = SYS_HCLK_FLASH; + + // Restore PLLs + if (saved_top_clk & (AON_CMU_PU_PLLAUD_ENABLE | AON_CMU_PU_PLLUSB_ENABLE | + AON_CMU_PU_PLLBB_ENABLE)) { + pll_locked = 0; + if (saved_top_clk & AON_CMU_PU_PLLAUD_ENABLE) { + aoncmu->TOP_CLK_ENABLE = AON_CMU_PU_PLLAUD_ENABLE; + pll_locked |= AON_CMU_LOCK_PLLAUD; + } + if (saved_top_clk & AON_CMU_PU_PLLBB_ENABLE) { + aoncmu->TOP_CLK_ENABLE = AON_CMU_PU_PLLBB_ENABLE; + pll_locked |= AON_CMU_LOCK_PLLBB; + } + if (saved_top_clk & AON_CMU_PU_PLLUSB_ENABLE) { + aoncmu->TOP_CLK_ENABLE = AON_CMU_PU_PLLUSB_ENABLE; + pll_locked |= AON_CMU_LOCK_PLLUSB; + } +#ifndef ROM_BUILD + hal_sys_timer_delay_us(10); + // Clear pll div reset if pll is enabled + if (saved_top_clk & AON_CMU_PU_PLLAUD_ENABLE) { + pmu_pll_div_reset_clear(HAL_CMU_PLL_AUD); + } + if (saved_top_clk & AON_CMU_PU_PLLBB_ENABLE) { + pmu_pll_div_reset_clear(HAL_CMU_PLL_USB); + } +#endif + start = hal_sys_timer_get(); + timeout = HAL_CMU_PLL_LOCKED_TIMEOUT; + while ( //(aoncmu->CODEC_DIV & pll_locked) != pll_locked && + (hal_sys_timer_get() - start) < timeout) + ; + if (saved_top_clk & AON_CMU_EN_CLK_TOP_PLLAUD_ENABLE) { + aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_TOP_PLLAUD_ENABLE; + } + if (saved_top_clk & AON_CMU_EN_CLK_TOP_PLLBB_ENABLE) { + aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_TOP_PLLBB_ENABLE; + } + if (saved_top_clk & AON_CMU_EN_CLK_TOP_PLLUSB_ENABLE) { + aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_TOP_PLLUSB_ENABLE; + } + } + + // Restore system freq + cmu->SYS_CLK_ENABLE = + saved_clk_cfg & (CMU_RSTN_DIV_FLS_ENABLE | CMU_RSTN_DIV_SYS_ENABLE); + cmu->SYS_CLK_ENABLE = saved_clk_cfg; + // The original system freq are at least 26M + // cmu->SYS_CLK_DISABLE = ~saved_clk_cfg; + + cmu->PERIPH_CLK = saved_periph_clk; + cmu->SYS_DIV = saved_sys_div; + cmu->UART_CLK = saved_uart_clk; + + // Switch VAD clock to MCU and enable codec HCLK if it is on before entering + // sleep + // aoncmu->CODEC_DIV &= ~AON_CMU_SEL_CODEC_HCLK_AON; + aoncmu->TOP_CLK_ENABLE = saved_top_clk & AON_CMU_EN_CLK_CODEC_HCLK_ENABLE; + + int_lock(); + + NVIC_PowerDownWakeup(saved_cpu_regs, ARRAY_SIZE(saved_cpu_regs)); + + // TODO: + // 1) Restore hardware modules, e.g., timer, cache, flash, psram, dma, usb, + // uart, spi, i2c, sdmmc, codec 2) Recover system timer in rt_suspend() and + // rt_resume() 3) Dynamically select 32K sleep or power down sleep + + if (saved_oclk & SYS_OCLK_FLASH) { + // Enable memory/flash clock + cmu->HCLK_ENABLE = saved_hclk; + cmu->OCLK_ENABLE = saved_oclk; + // Wait until memory/flash clock ready + hal_sys_timer_delay_us(2); + } + + return 0; +} + +#endif + +__STATIC_FORCEINLINE void cpu_sleep(uint32_t wakeup_cfg) { + __DSB(); + + if (wakeup_cfg & (CMU_LPU_AUTO_SWITCHPLL | CMU_LPU_AUTO_SWITCH26)) { + // 1) Avoid race condition between LPU state machine entry and IRQ wakeup: + // wait 4 (at least 2) cycles of 32K clock, or 3248 cycles of 26M clock + // 2) Avoid race condition between CPU clock gating and RAM access when + // waiting: + // No consecutive RAM access is allowed (all instructions must be 16-bit + // and must have no data access) + asm volatile("wfi;" + "movs.n r0, #0x3;" + "lsls r0, #8;" + "adds.n r0, #0x2c;" + "1:;" + "nop;" + "nop;" + "subs r0, 1;" + "bne.n 1b;" + : + : + : "r0", "cc"); + } else { + __WFI(); + } +} + +static int SRAM_TEXT_LOC +hal_cmu_lpu_sleep_normal(enum HAL_CMU_LPU_SLEEP_MODE_T mode) { + uint32_t start; + uint32_t timeout; + uint32_t saved_hclk; + uint32_t saved_oclk; + uint32_t saved_top_clk; + uint32_t saved_clk_cfg; + uint32_t saved_codec_div; + uint32_t wakeup_cfg; + bool pd_aud_pll; + bool pd_bb_pll; + bool wait_pll_locked; + + pd_aud_pll = true; + pd_bb_pll = true; + + saved_hclk = cmu->HCLK_ENABLE; + saved_oclk = cmu->OCLK_ENABLE; + saved_codec_div = aoncmu->CODEC_DIV; + saved_top_clk = aoncmu->TOP_CLK_ENABLE; + saved_clk_cfg = cmu->SYS_CLK_ENABLE; + + if (mode == HAL_CMU_LPU_SLEEP_MODE_CHIP) { + wakeup_cfg = cmu->WAKEUP_CLK_CFG; + } else { + wakeup_cfg = 0; + if (pll_user_map[HAL_CMU_PLL_AUD] & (1 << HAL_CMU_PLL_USER_AUD)) { + pd_aud_pll = false; + } + if (pll_user_map[HAL_CMU_PLL_USB] & (1 << HAL_CMU_PLL_USER_AUD)) { + pd_bb_pll = false; + } + } + + // Switch VAD clock to AON and disable codec HCLK + aoncmu->CODEC_DIV |= AON_CMU_SEL_CODEC_HCLK_AON; + if (mode == HAL_CMU_LPU_SLEEP_MODE_CHIP) { + aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_CODEC_HCLK_DISABLE; + } + + // Disable memory/flash clock + cmu->OCLK_DISABLE = SYS_OCLK_FLASH; + cmu->HCLK_DISABLE = SYS_HCLK_FLASH; + +#ifndef ROM_BUILD + // Reset pll div if pll is enabled + if (pd_aud_pll && (saved_top_clk & AON_CMU_PU_PLLAUD_ENABLE)) { + pmu_pll_div_reset_set(HAL_CMU_PLL_AUD); + } + if (pd_bb_pll && (saved_top_clk & AON_CMU_PU_PLLBB_ENABLE)) { + pmu_pll_div_reset_set(HAL_CMU_PLL_USB); + } +#endif + + // Setup wakeup mask + cmu->WAKEUP_MASK0 = NVIC->ISER[0]; + cmu->WAKEUP_MASK1 = NVIC->ISER[1]; + + if (wakeup_cfg & CMU_LPU_AUTO_SWITCHPLL) { + // Do nothing + // Hardware will switch system freq to 32K and shutdown PLLs automatically + } else { // Switch system freq to 26M cmu->SYS_CLK_ENABLE = CMU_SEL_OSC_SYS_ENABLE; cmu->SYS_CLK_DISABLE = CMU_SEL_OSCX2_SYS_DISABLE | CMU_SEL_PLL_SYS_DISABLE; cmu->SYS_CLK_DISABLE = CMU_RSTN_DIV_SYS_DISABLE; - // Shutdown PLLs - if (saved_top_clk & AON_CMU_PU_PLLAUD_ENABLE) { - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLAUD_DISABLE; - aoncmu->TOP_CLK_DISABLE = AON_CMU_PU_PLLAUD_DISABLE; + if (pd_aud_pll && (saved_top_clk & AON_CMU_PU_PLLAUD_ENABLE)) { + aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLAUD_DISABLE; + aoncmu->TOP_CLK_DISABLE = AON_CMU_PU_PLLAUD_DISABLE; } - if (saved_top_clk & AON_CMU_PU_PLLBB_ENABLE) { - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLBB_DISABLE; - aoncmu->TOP_CLK_DISABLE = AON_CMU_PU_PLLBB_DISABLE; + if (pd_bb_pll && (saved_top_clk & AON_CMU_PU_PLLBB_ENABLE)) { + aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLBB_DISABLE; + aoncmu->TOP_CLK_DISABLE = AON_CMU_PU_PLLBB_DISABLE; } if (saved_top_clk & AON_CMU_PU_PLLUSB_ENABLE) { - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLUSB_DISABLE; - aoncmu->TOP_CLK_DISABLE = AON_CMU_PU_PLLUSB_DISABLE; + aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLUSB_DISABLE; + aoncmu->TOP_CLK_DISABLE = AON_CMU_PU_PLLUSB_DISABLE; } + if (wakeup_cfg & CMU_LPU_AUTO_SWITCH26) { + // Do nothing + // Hardware will switch system freq to 32K automatically + } else { + // Manually switch AON_CMU clock to 32K + aoncmu->CODEC_DIV &= ~(AON_CMU_SEL_CLK_OSC | AON_CMU_SEL_CLK_OSCX2); + // Switch system freq to 32K + cmu->SYS_CLK_DISABLE = CMU_SEL_OSC_SYS_DISABLE; + } + } - // Set power down wakeup bootmode - aoncmu->BOOTMODE = (aoncmu->BOOTMODE | HAL_SW_BOOTMODE_POWER_DOWN_WAKEUP) & HAL_SW_BOOTMODE_MASK; - // Set AON_CMU clock to 32K - aoncmu->CODEC_DIV &= ~(AON_CMU_SEL_CLK_OSC | AON_CMU_SEL_CLK_OSCX2); + if (wakeup_cfg & CMU_LPU_AUTO_SWITCH26) { + // Enable auto memory retention + cmu->SLEEP = (cmu->SLEEP & ~CMU_MANUAL_RAM_RETN) | CMU_DEEPSLEEP_EN | + CMU_DEEPSLEEP_ROMRAM_EN | CMU_DEEPSLEEP_START; + } else { + // Disable auto memory retention + cmu->SLEEP = (cmu->SLEEP & ~CMU_DEEPSLEEP_ROMRAM_EN) | CMU_DEEPSLEEP_EN | + CMU_MANUAL_RAM_RETN | CMU_DEEPSLEEP_START; + } - hal_sleep_core_power_down(); + if (mode == HAL_CMU_LPU_SLEEP_MODE_CHIP) { + SCB->SCR = SCB_SCR_SLEEPDEEP_Msk; + } else { + SCB->SCR = 0; + } - while ((cmu->WAKEUP_CLK_CFG & CMU_LPU_STATUS_26M) == 0); - - // Restore AON_CMU clock - aoncmu->CODEC_DIV = saved_codec_div; - // Clear power down wakeup bootmode - aoncmu->BOOTMODE = (aoncmu->BOOTMODE & ~HAL_SW_BOOTMODE_POWER_DOWN_WAKEUP) & HAL_SW_BOOTMODE_MASK; - - // Disable memory/flash clock - cmu->OCLK_DISABLE = SYS_OCLK_FLASH; - cmu->HCLK_DISABLE = SYS_HCLK_FLASH; + cpu_sleep(wakeup_cfg); + if (wakeup_cfg & CMU_LPU_AUTO_SWITCHPLL) { + start = hal_sys_timer_get(); + timeout = HAL_CMU_26M_READY_TIMEOUT + HAL_CMU_PLL_LOCKED_TIMEOUT + + HAL_CMU_LPU_EXTRA_TIMEOUT; + while ((cmu->WAKEUP_CLK_CFG & CMU_LPU_STATUS_PLL) == 0 && + (hal_sys_timer_get() - start) < timeout) + ; + // !!! CAUTION !!! + // Hardware will switch system freq to PLL divider and enable PLLs + // automatically +#ifndef ROM_BUILD + hal_sys_timer_delay_us(10); + // Clear pll div reset if pll is enabled + if (saved_top_clk & AON_CMU_PU_PLLAUD_ENABLE) { + pmu_pll_div_reset_clear(HAL_CMU_PLL_AUD); + } + if (saved_top_clk & AON_CMU_PU_PLLBB_ENABLE) { + pmu_pll_div_reset_clear(HAL_CMU_PLL_USB); + } +#endif + } else { + // Wait for 26M ready + if (wakeup_cfg & CMU_LPU_AUTO_SWITCH26) { + start = hal_sys_timer_get(); + timeout = HAL_CMU_26M_READY_TIMEOUT + HAL_CMU_LPU_EXTRA_TIMEOUT; + while ((cmu->WAKEUP_CLK_CFG & CMU_LPU_STATUS_26M) == 0 && + (hal_sys_timer_get() - start) < timeout) + ; + // Hardware will switch system freq to 26M automatically + } else { + if (mode == HAL_CMU_LPU_SLEEP_MODE_CHIP) { + timeout = HAL_CMU_26M_READY_TIMEOUT; + hal_sys_timer_delay(timeout); + } + // Switch system freq to 26M + cmu->SYS_CLK_ENABLE = CMU_SEL_OSC_SYS_ENABLE; + // Restore AON_CMU clock + aoncmu->CODEC_DIV = saved_codec_div; + } + // System freq is 26M now and will be restored later // Restore PLLs - if (saved_top_clk & (AON_CMU_PU_PLLAUD_ENABLE | AON_CMU_PU_PLLUSB_ENABLE | AON_CMU_PU_PLLBB_ENABLE)) { - pll_locked = 0; - if (saved_top_clk & AON_CMU_PU_PLLAUD_ENABLE) { - aoncmu->TOP_CLK_ENABLE = AON_CMU_PU_PLLAUD_ENABLE; - pll_locked |= AON_CMU_LOCK_PLLAUD; - } - if (saved_top_clk & AON_CMU_PU_PLLBB_ENABLE) { - aoncmu->TOP_CLK_ENABLE = AON_CMU_PU_PLLBB_ENABLE; - pll_locked |= AON_CMU_LOCK_PLLBB; - } - if (saved_top_clk & AON_CMU_PU_PLLUSB_ENABLE) { - aoncmu->TOP_CLK_ENABLE = AON_CMU_PU_PLLUSB_ENABLE; - pll_locked |= AON_CMU_LOCK_PLLUSB; - } + if (saved_top_clk & (AON_CMU_PU_PLLAUD_ENABLE | AON_CMU_PU_PLLUSB_ENABLE | + AON_CMU_PU_PLLBB_ENABLE)) { + wait_pll_locked = false; + if (pd_aud_pll && (saved_top_clk & AON_CMU_PU_PLLAUD_ENABLE)) { + aoncmu->TOP_CLK_ENABLE = AON_CMU_PU_PLLAUD_ENABLE; + wait_pll_locked = true; + } + if (pd_bb_pll && (saved_top_clk & AON_CMU_PU_PLLBB_ENABLE)) { + aoncmu->TOP_CLK_ENABLE = AON_CMU_PU_PLLBB_ENABLE; + wait_pll_locked = true; + } + if (saved_top_clk & AON_CMU_PU_PLLUSB_ENABLE) { + aoncmu->TOP_CLK_ENABLE = AON_CMU_PU_PLLUSB_ENABLE; + wait_pll_locked = true; + } + if (wait_pll_locked) { #ifndef ROM_BUILD hal_sys_timer_delay_us(10); // Clear pll div reset if pll is enabled - if (saved_top_clk & AON_CMU_PU_PLLAUD_ENABLE) { - pmu_pll_div_reset_clear(HAL_CMU_PLL_AUD); + if (pd_aud_pll && (saved_top_clk & AON_CMU_PU_PLLAUD_ENABLE)) { + pmu_pll_div_reset_clear(HAL_CMU_PLL_AUD); } - if (saved_top_clk & AON_CMU_PU_PLLBB_ENABLE) { - pmu_pll_div_reset_clear(HAL_CMU_PLL_USB); + if (pd_bb_pll && (saved_top_clk & AON_CMU_PU_PLLBB_ENABLE)) { + pmu_pll_div_reset_clear(HAL_CMU_PLL_USB); } #endif start = hal_sys_timer_get(); timeout = HAL_CMU_PLL_LOCKED_TIMEOUT; - while (//(aoncmu->CODEC_DIV & pll_locked) != pll_locked && - (hal_sys_timer_get() - start) < timeout); - if (saved_top_clk & AON_CMU_EN_CLK_TOP_PLLAUD_ENABLE) { - aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_TOP_PLLAUD_ENABLE; - } - if (saved_top_clk & AON_CMU_EN_CLK_TOP_PLLBB_ENABLE) { - aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_TOP_PLLBB_ENABLE; - } - if (saved_top_clk & AON_CMU_EN_CLK_TOP_PLLUSB_ENABLE) { - aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_TOP_PLLUSB_ENABLE; - } + while ((hal_sys_timer_get() - start) < timeout) + ; + } + if (pd_aud_pll && (saved_top_clk & AON_CMU_EN_CLK_TOP_PLLAUD_ENABLE)) { + aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_TOP_PLLAUD_ENABLE; + } + if (pd_bb_pll && (saved_top_clk & AON_CMU_EN_CLK_TOP_PLLBB_ENABLE)) { + aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_TOP_PLLBB_ENABLE; + } + if (saved_top_clk & AON_CMU_EN_CLK_TOP_PLLUSB_ENABLE) { + aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_TOP_PLLUSB_ENABLE; + } } + } - // Restore system freq - cmu->SYS_CLK_ENABLE = saved_clk_cfg & - (CMU_RSTN_DIV_FLS_ENABLE | CMU_RSTN_DIV_SYS_ENABLE); - cmu->SYS_CLK_ENABLE = saved_clk_cfg; - // The original system freq are at least 26M - //cmu->SYS_CLK_DISABLE = ~saved_clk_cfg; + // Restore system freq + cmu->SYS_CLK_ENABLE = + saved_clk_cfg & (CMU_RSTN_DIV_FLS_ENABLE | CMU_RSTN_DIV_SYS_ENABLE); + cmu->SYS_CLK_ENABLE = saved_clk_cfg; + // The original system freq are at least 26M + // cmu->SYS_CLK_DISABLE = ~saved_clk_cfg; - cmu->PERIPH_CLK = saved_periph_clk; - cmu->SYS_DIV = saved_sys_div; - cmu->UART_CLK = saved_uart_clk; - - // Switch VAD clock to MCU and enable codec HCLK if it is on before entering sleep - //aoncmu->CODEC_DIV &= ~AON_CMU_SEL_CODEC_HCLK_AON; + // Switch VAD clock to MCU and enable codec HCLK if it is on before entering + // sleep + aoncmu->CODEC_DIV &= ~AON_CMU_SEL_CODEC_HCLK_AON; + if (mode == HAL_CMU_LPU_SLEEP_MODE_CHIP) { aoncmu->TOP_CLK_ENABLE = saved_top_clk & AON_CMU_EN_CLK_CODEC_HCLK_ENABLE; + } - int_lock(); + if (saved_oclk & SYS_OCLK_FLASH) { + // Enable memory/flash clock + cmu->HCLK_ENABLE = saved_hclk; + cmu->OCLK_ENABLE = saved_oclk; + // Wait until memory/flash clock ready + hal_sys_timer_delay_us(2); + } - NVIC_PowerDownWakeup(saved_cpu_regs, ARRAY_SIZE(saved_cpu_regs)); - - // TODO: - // 1) Restore hardware modules, e.g., timer, cache, flash, psram, dma, usb, uart, spi, i2c, sdmmc, codec - // 2) Recover system timer in rt_suspend() and rt_resume() - // 3) Dynamically select 32K sleep or power down sleep - - if (saved_oclk & SYS_OCLK_FLASH) { - // Enable memory/flash clock - cmu->HCLK_ENABLE = saved_hclk; - cmu->OCLK_ENABLE = saved_oclk; - // Wait until memory/flash clock ready - hal_sys_timer_delay_us(2); - } - - return 0; + return 0; } -#endif - -__STATIC_FORCEINLINE void cpu_sleep(uint32_t wakeup_cfg) -{ - __DSB(); - - if (wakeup_cfg & (CMU_LPU_AUTO_SWITCHPLL | CMU_LPU_AUTO_SWITCH26)) { - // 1) Avoid race condition between LPU state machine entry and IRQ wakeup: - // wait 4 (at least 2) cycles of 32K clock, or 3248 cycles of 26M clock - // 2) Avoid race condition between CPU clock gating and RAM access when waiting: - // No consecutive RAM access is allowed (all instructions must be 16-bit and must have no data access) - asm volatile ( - "wfi;" - "movs.n r0, #0x3;" - "lsls r0, #8;" - "adds.n r0, #0x2c;" - "1:;" - "nop;" - "nop;" - "subs r0, 1;" - "bne.n 1b;" - : - : - : "r0", "cc" ); - } else { - __WFI(); - } -} - -static int SRAM_TEXT_LOC hal_cmu_lpu_sleep_normal(enum HAL_CMU_LPU_SLEEP_MODE_T mode) -{ - uint32_t start; - uint32_t timeout; - uint32_t saved_hclk; - uint32_t saved_oclk; - uint32_t saved_top_clk; - uint32_t saved_clk_cfg; - uint32_t saved_codec_div; - uint32_t wakeup_cfg; - bool pd_aud_pll; - bool pd_bb_pll; - bool wait_pll_locked; - - pd_aud_pll = true; - pd_bb_pll = true; - - saved_hclk = cmu->HCLK_ENABLE; - saved_oclk = cmu->OCLK_ENABLE; - saved_codec_div = aoncmu->CODEC_DIV; - saved_top_clk = aoncmu->TOP_CLK_ENABLE; - saved_clk_cfg = cmu->SYS_CLK_ENABLE; - - if (mode == HAL_CMU_LPU_SLEEP_MODE_CHIP) { - wakeup_cfg = cmu->WAKEUP_CLK_CFG; - } else { - wakeup_cfg = 0; - if (pll_user_map[HAL_CMU_PLL_AUD] & (1 << HAL_CMU_PLL_USER_AUD)) { - pd_aud_pll = false; - } - if (pll_user_map[HAL_CMU_PLL_USB] & (1 << HAL_CMU_PLL_USER_AUD)) { - pd_bb_pll = false; - } - } - - // Switch VAD clock to AON and disable codec HCLK - aoncmu->CODEC_DIV |= AON_CMU_SEL_CODEC_HCLK_AON; - if (mode == HAL_CMU_LPU_SLEEP_MODE_CHIP) { - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_CODEC_HCLK_DISABLE; - } - - // Disable memory/flash clock - cmu->OCLK_DISABLE = SYS_OCLK_FLASH; - cmu->HCLK_DISABLE = SYS_HCLK_FLASH; - -#ifndef ROM_BUILD - // Reset pll div if pll is enabled - if (pd_aud_pll && (saved_top_clk & AON_CMU_PU_PLLAUD_ENABLE)) { - pmu_pll_div_reset_set(HAL_CMU_PLL_AUD); - } - if (pd_bb_pll && (saved_top_clk & AON_CMU_PU_PLLBB_ENABLE)) { - pmu_pll_div_reset_set(HAL_CMU_PLL_USB); - } -#endif - - // Setup wakeup mask - cmu->WAKEUP_MASK0 = NVIC->ISER[0]; - cmu->WAKEUP_MASK1 = NVIC->ISER[1]; - - if (wakeup_cfg & CMU_LPU_AUTO_SWITCHPLL) { - // Do nothing - // Hardware will switch system freq to 32K and shutdown PLLs automatically - } else { - // Switch system freq to 26M - cmu->SYS_CLK_ENABLE = CMU_SEL_OSC_SYS_ENABLE; - cmu->SYS_CLK_DISABLE = CMU_SEL_OSCX2_SYS_DISABLE | CMU_SEL_PLL_SYS_DISABLE; - cmu->SYS_CLK_DISABLE = CMU_RSTN_DIV_SYS_DISABLE; - // Shutdown PLLs - if (pd_aud_pll && (saved_top_clk & AON_CMU_PU_PLLAUD_ENABLE)) { - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLAUD_DISABLE; - aoncmu->TOP_CLK_DISABLE = AON_CMU_PU_PLLAUD_DISABLE; - } - if (pd_bb_pll && (saved_top_clk & AON_CMU_PU_PLLBB_ENABLE)) { - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLBB_DISABLE; - aoncmu->TOP_CLK_DISABLE = AON_CMU_PU_PLLBB_DISABLE; - } - if (saved_top_clk & AON_CMU_PU_PLLUSB_ENABLE) { - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_TOP_PLLUSB_DISABLE; - aoncmu->TOP_CLK_DISABLE = AON_CMU_PU_PLLUSB_DISABLE; - } - if (wakeup_cfg & CMU_LPU_AUTO_SWITCH26) { - // Do nothing - // Hardware will switch system freq to 32K automatically - } else { - // Manually switch AON_CMU clock to 32K - aoncmu->CODEC_DIV &= ~(AON_CMU_SEL_CLK_OSC | AON_CMU_SEL_CLK_OSCX2); - // Switch system freq to 32K - cmu->SYS_CLK_DISABLE = CMU_SEL_OSC_SYS_DISABLE; - } - } - - if (wakeup_cfg & CMU_LPU_AUTO_SWITCH26) { - // Enable auto memory retention - cmu->SLEEP = (cmu->SLEEP & ~CMU_MANUAL_RAM_RETN) | - CMU_DEEPSLEEP_EN | CMU_DEEPSLEEP_ROMRAM_EN | CMU_DEEPSLEEP_START; - } else { - // Disable auto memory retention - cmu->SLEEP = (cmu->SLEEP & ~CMU_DEEPSLEEP_ROMRAM_EN) | - CMU_DEEPSLEEP_EN | CMU_MANUAL_RAM_RETN | CMU_DEEPSLEEP_START; - } - - if (mode == HAL_CMU_LPU_SLEEP_MODE_CHIP) { - SCB->SCR = SCB_SCR_SLEEPDEEP_Msk; - } else { - SCB->SCR = 0; - } - - cpu_sleep(wakeup_cfg); - - if (wakeup_cfg & CMU_LPU_AUTO_SWITCHPLL) { - start = hal_sys_timer_get(); - timeout = HAL_CMU_26M_READY_TIMEOUT + HAL_CMU_PLL_LOCKED_TIMEOUT + HAL_CMU_LPU_EXTRA_TIMEOUT; - while ((cmu->WAKEUP_CLK_CFG & CMU_LPU_STATUS_PLL) == 0 && - (hal_sys_timer_get() - start) < timeout); - // !!! CAUTION !!! - // Hardware will switch system freq to PLL divider and enable PLLs automatically -#ifndef ROM_BUILD - hal_sys_timer_delay_us(10); - // Clear pll div reset if pll is enabled - if (saved_top_clk & AON_CMU_PU_PLLAUD_ENABLE) { - pmu_pll_div_reset_clear(HAL_CMU_PLL_AUD); - } - if (saved_top_clk & AON_CMU_PU_PLLBB_ENABLE) { - pmu_pll_div_reset_clear(HAL_CMU_PLL_USB); - } -#endif - } else { - // Wait for 26M ready - if (wakeup_cfg & CMU_LPU_AUTO_SWITCH26) { - start = hal_sys_timer_get(); - timeout = HAL_CMU_26M_READY_TIMEOUT + HAL_CMU_LPU_EXTRA_TIMEOUT; - while ((cmu->WAKEUP_CLK_CFG & CMU_LPU_STATUS_26M) == 0 && - (hal_sys_timer_get() - start) < timeout); - // Hardware will switch system freq to 26M automatically - } else { - if (mode == HAL_CMU_LPU_SLEEP_MODE_CHIP) { - timeout = HAL_CMU_26M_READY_TIMEOUT; - hal_sys_timer_delay(timeout); - } - // Switch system freq to 26M - cmu->SYS_CLK_ENABLE = CMU_SEL_OSC_SYS_ENABLE; - // Restore AON_CMU clock - aoncmu->CODEC_DIV = saved_codec_div; - } - // System freq is 26M now and will be restored later - // Restore PLLs - if (saved_top_clk & (AON_CMU_PU_PLLAUD_ENABLE | AON_CMU_PU_PLLUSB_ENABLE | AON_CMU_PU_PLLBB_ENABLE)) { - wait_pll_locked = false; - if (pd_aud_pll && (saved_top_clk & AON_CMU_PU_PLLAUD_ENABLE)) { - aoncmu->TOP_CLK_ENABLE = AON_CMU_PU_PLLAUD_ENABLE; - wait_pll_locked = true; - } - if (pd_bb_pll && (saved_top_clk & AON_CMU_PU_PLLBB_ENABLE)) { - aoncmu->TOP_CLK_ENABLE = AON_CMU_PU_PLLBB_ENABLE; - wait_pll_locked = true; - } - if (saved_top_clk & AON_CMU_PU_PLLUSB_ENABLE) { - aoncmu->TOP_CLK_ENABLE = AON_CMU_PU_PLLUSB_ENABLE; - wait_pll_locked = true; - } - if (wait_pll_locked) { -#ifndef ROM_BUILD - hal_sys_timer_delay_us(10); - // Clear pll div reset if pll is enabled - if (pd_aud_pll && (saved_top_clk & AON_CMU_PU_PLLAUD_ENABLE)) { - pmu_pll_div_reset_clear(HAL_CMU_PLL_AUD); - } - if (pd_bb_pll && (saved_top_clk & AON_CMU_PU_PLLBB_ENABLE)) { - pmu_pll_div_reset_clear(HAL_CMU_PLL_USB); - } -#endif - start = hal_sys_timer_get(); - timeout = HAL_CMU_PLL_LOCKED_TIMEOUT; - while ((hal_sys_timer_get() - start) < timeout); - } - if (pd_aud_pll && (saved_top_clk & AON_CMU_EN_CLK_TOP_PLLAUD_ENABLE)) { - aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_TOP_PLLAUD_ENABLE; - } - if (pd_bb_pll && (saved_top_clk & AON_CMU_EN_CLK_TOP_PLLBB_ENABLE)) { - aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_TOP_PLLBB_ENABLE; - } - if (saved_top_clk & AON_CMU_EN_CLK_TOP_PLLUSB_ENABLE) { - aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_TOP_PLLUSB_ENABLE; - } - } - } - - // Restore system freq - cmu->SYS_CLK_ENABLE = saved_clk_cfg & - (CMU_RSTN_DIV_FLS_ENABLE | CMU_RSTN_DIV_SYS_ENABLE); - cmu->SYS_CLK_ENABLE = saved_clk_cfg; - // The original system freq are at least 26M - //cmu->SYS_CLK_DISABLE = ~saved_clk_cfg; - - // Switch VAD clock to MCU and enable codec HCLK if it is on before entering sleep - aoncmu->CODEC_DIV &= ~AON_CMU_SEL_CODEC_HCLK_AON; - if (mode == HAL_CMU_LPU_SLEEP_MODE_CHIP) { - aoncmu->TOP_CLK_ENABLE = saved_top_clk & AON_CMU_EN_CLK_CODEC_HCLK_ENABLE; - } - - if (saved_oclk & SYS_OCLK_FLASH) { - // Enable memory/flash clock - cmu->HCLK_ENABLE = saved_hclk; - cmu->OCLK_ENABLE = saved_oclk; - // Wait until memory/flash clock ready - hal_sys_timer_delay_us(2); - } - - return 0; -} - -int SRAM_TEXT_LOC hal_cmu_lpu_sleep(enum HAL_CMU_LPU_SLEEP_MODE_T mode) -{ +int SRAM_TEXT_LOC hal_cmu_lpu_sleep(enum HAL_CMU_LPU_SLEEP_MODE_T mode) { #ifdef CORE_SLEEP_POWER_DOWN - if (mode == HAL_CMU_LPU_SLEEP_MODE_POWER_DOWN) { - return hal_cmu_lpu_sleep_pd(); - } + if (mode == HAL_CMU_LPU_SLEEP_MODE_POWER_DOWN) { + return hal_cmu_lpu_sleep_pd(); + } #endif - return hal_cmu_lpu_sleep_normal(mode); + return hal_cmu_lpu_sleep_normal(mode); } -volatile uint32_t *hal_cmu_get_bootmode_addr(void) -{ - return &aoncmu->BOOTMODE; -} +volatile uint32_t *hal_cmu_get_bootmode_addr(void) { return &aoncmu->BOOTMODE; } SRAM_TEXT_LOC -volatile uint32_t *hal_cmu_get_memsc_addr(void) -{ - return &aoncmu->MEMSC[0]; +volatile uint32_t *hal_cmu_get_memsc_addr(void) { return &aoncmu->MEMSC[0]; } + +void hal_cmu_bt_clock_enable(void) { + aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_OSCX2_BT_ENABLE | + AON_CMU_EN_CLK_OSC_BT_ENABLE | + AON_CMU_EN_CLK_32K_BT_ENABLE; + aocmu_reg_update_wait(); } -void hal_cmu_bt_clock_enable(void) -{ - aoncmu->TOP_CLK_ENABLE = AON_CMU_EN_CLK_OSCX2_BT_ENABLE | AON_CMU_EN_CLK_OSC_BT_ENABLE | AON_CMU_EN_CLK_32K_BT_ENABLE; - aocmu_reg_update_wait(); +void hal_cmu_bt_clock_disable(void) { + aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_OSCX2_BT_DISABLE | + AON_CMU_EN_CLK_OSC_BT_DISABLE | + AON_CMU_EN_CLK_32K_BT_DISABLE; } -void hal_cmu_bt_clock_disable(void) -{ - aoncmu->TOP_CLK_DISABLE = AON_CMU_EN_CLK_OSCX2_BT_DISABLE | AON_CMU_EN_CLK_OSC_BT_DISABLE | AON_CMU_EN_CLK_32K_BT_DISABLE; +void hal_cmu_bt_reset_set(void) { + aoncmu->RESET_SET = AON_CMU_SOFT_RSTN_BT_SET | AON_CMU_SOFT_RSTN_BTCPU_SET; } -void hal_cmu_bt_reset_set(void) -{ - aoncmu->RESET_SET = AON_CMU_SOFT_RSTN_BT_SET | AON_CMU_SOFT_RSTN_BTCPU_SET; +void hal_cmu_bt_reset_clear(void) { + aoncmu->RESET_CLR = AON_CMU_SOFT_RSTN_BT_CLR | AON_CMU_SOFT_RSTN_BTCPU_CLR; + aocmu_reg_update_wait(); } -void hal_cmu_bt_reset_clear(void) -{ - aoncmu->RESET_CLR = AON_CMU_SOFT_RSTN_BT_CLR | AON_CMU_SOFT_RSTN_BTCPU_CLR; - aocmu_reg_update_wait(); +void hal_cmu_bt_module_init(void) { + // btcmu->CLK_MODE = 0; } -void hal_cmu_bt_module_init(void) -{ - //btcmu->CLK_MODE = 0; +uint32_t hal_cmu_get_aon_chip_id(void) { return aoncmu->CHIP_ID; } + +uint32_t hal_cmu_get_aon_revision_id(void) { + return GET_BITFIELD(aoncmu->CHIP_ID, AON_CMU_REVISION_ID); } -uint32_t hal_cmu_get_aon_chip_id(void) -{ - return aoncmu->CHIP_ID; +void hal_cmu_cp_enable(uint32_t sp, uint32_t entry) { + cp_cfg->stack = sp; + cp_cfg->reset_hdlr = (uint32_t)system_cp_reset_handler; + cp_cfg->entry = entry; + + hal_cmu_clock_enable(HAL_CMU_MOD_H_CP); + hal_cmu_reset_clear(HAL_CMU_MOD_H_CP); } -uint32_t hal_cmu_get_aon_revision_id(void) -{ - return GET_BITFIELD(aoncmu->CHIP_ID, AON_CMU_REVISION_ID); -} - -void hal_cmu_cp_enable(uint32_t sp, uint32_t entry) -{ - cp_cfg->stack = sp; - cp_cfg->reset_hdlr = (uint32_t)system_cp_reset_handler; - cp_cfg->entry = entry; - - hal_cmu_clock_enable(HAL_CMU_MOD_H_CP); - hal_cmu_reset_clear(HAL_CMU_MOD_H_CP); -} - -void hal_cmu_cp_disable(void) -{ - hal_cmu_reset_set(HAL_CMU_MOD_H_CP); - hal_cmu_clock_disable(HAL_CMU_MOD_H_CP); -} - -uint32_t hal_cmu_cp_get_entry_addr(void) -{ - return cp_cfg->entry; +void hal_cmu_cp_disable(void) { + hal_cmu_reset_set(HAL_CMU_MOD_H_CP); + hal_cmu_clock_disable(HAL_CMU_MOD_H_CP); } +uint32_t hal_cmu_cp_get_entry_addr(void) { return cp_cfg->entry; } diff --git a/platform/hal/best2300p/hal_codec_best2300p.c b/platform/hal/best2300p/hal_codec_best2300p.c index ecb006d..f191612 100644 --- a/platform/hal/best2300p/hal_codec_best2300p.c +++ b/platform/hal/best2300p/hal_codec_best2300p.c @@ -15,14 +15,14 @@ ****************************************************************************/ #include "plat_addr_map.h" #include CHIP_SPECIFIC_HDR(reg_codec) -#include "hal_codec.h" -#include "hal_cmu.h" -#include "hal_psc.h" -#include "hal_aud.h" -#include "hal_trace.h" -#include "hal_timer.h" #include "analog.h" #include "cmsis.h" +#include "hal_aud.h" +#include "hal_cmu.h" +#include "hal_codec.h" +#include "hal_psc.h" +#include "hal_timer.h" +#include "hal_trace.h" #include "string.h" #include "tgt_hardware.h" #ifdef RTOS @@ -35,7 +35,7 @@ #define SDM_MUTE_NOISE_SUPPRESSION #ifndef CODEC_OUTPUT_DEV -#define CODEC_OUTPUT_DEV CFG_HW_AUD_OUTPUT_PATH_SPEAKER_DEV +#define CODEC_OUTPUT_DEV CFG_HW_AUD_OUTPUT_PATH_SPEAKER_DEV #endif #if ((CODEC_OUTPUT_DEV & CFG_HW_AUD_OUTPUT_PATH_SPEAKER_DEV) == 0) #ifndef AUDIO_OUTPUT_SWAP @@ -59,62 +59,70 @@ #endif #endif -#define RS_CLOCK_FACTOR 200 +#define RS_CLOCK_FACTOR 200 // Trigger DMA request when TX-FIFO *empty* count > threshold -#define HAL_CODEC_TX_FIFO_TRIGGER_LEVEL (3) +#define HAL_CODEC_TX_FIFO_TRIGGER_LEVEL (3) // Trigger DMA request when RX-FIFO count >= threshold -#define HAL_CODEC_RX_FIFO_TRIGGER_LEVEL (4) +#define HAL_CODEC_RX_FIFO_TRIGGER_LEVEL (4) -#define MAX_DIG_DBVAL (50) -#define ZERODB_DIG_DBVAL (0) -#define MIN_DIG_DBVAL (-99) +#define MAX_DIG_DBVAL (50) +#define ZERODB_DIG_DBVAL (0) +#define MIN_DIG_DBVAL (-99) -#define MAX_SIDETONE_DBVAL (30) -#define MIN_SIDETONE_DBVAL (-30) -#define SIDETONE_DBVAL_STEP (-2) +#define MAX_SIDETONE_DBVAL (30) +#define MIN_SIDETONE_DBVAL (-30) +#define SIDETONE_DBVAL_STEP (-2) -#define MAX_SIDETONE_REGVAL (0) -#define MIN_SIDETONE_REGVAL (30) -#define MUTE_SIDETONE_REGVAL (31) +#define MAX_SIDETONE_REGVAL (0) +#define MIN_SIDETONE_REGVAL (30) +#define MUTE_SIDETONE_REGVAL (31) #ifndef MC_DELAY_COMMON -#define MC_DELAY_COMMON 28 +#define MC_DELAY_COMMON 28 #endif #ifndef CODEC_DIGMIC_PHASE -#define CODEC_DIGMIC_PHASE 7 +#define CODEC_DIGMIC_PHASE 7 #endif -#define ADC_IIR_CH_NUM 2 +#define ADC_IIR_CH_NUM 2 -#define MAX_DIG_MIC_CH_NUM 5 +#define MAX_DIG_MIC_CH_NUM 5 -#define NORMAL_ADC_CH_NUM 5 +#define NORMAL_ADC_CH_NUM 5 // Echo cancel ADC channel number -#define EC_ADC_CH_NUM 2 -#define MAX_ADC_CH_NUM (NORMAL_ADC_CH_NUM + EC_ADC_CH_NUM) +#define EC_ADC_CH_NUM 2 +#define MAX_ADC_CH_NUM (NORMAL_ADC_CH_NUM + EC_ADC_CH_NUM) -#define MAX_DAC_CH_NUM 2 +#define MAX_DAC_CH_NUM 2 #ifdef CODEC_DSD -#define NORMAL_MIC_MAP (AUD_CHANNEL_MAP_NORMAL_ALL & ~(AUD_CHANNEL_MAP_CH5 | AUD_CHANNEL_MAP_CH6 | AUD_CHANNEL_MAP_CH7 | \ - AUD_CHANNEL_MAP_DIGMIC_CH5 | AUD_CHANNEL_MAP_DIGMIC_CH6 | AUD_CHANNEL_MAP_DIGMIC_CH7 | \ - AUD_CHANNEL_MAP_DIGMIC_CH2 | AUD_CHANNEL_MAP_DIGMIC_CH3)) +#define NORMAL_MIC_MAP \ + (AUD_CHANNEL_MAP_NORMAL_ALL & \ + ~(AUD_CHANNEL_MAP_CH5 | AUD_CHANNEL_MAP_CH6 | AUD_CHANNEL_MAP_CH7 | \ + AUD_CHANNEL_MAP_DIGMIC_CH5 | AUD_CHANNEL_MAP_DIGMIC_CH6 | \ + AUD_CHANNEL_MAP_DIGMIC_CH7 | AUD_CHANNEL_MAP_DIGMIC_CH2 | \ + AUD_CHANNEL_MAP_DIGMIC_CH3)) #else -#define NORMAL_MIC_MAP (AUD_CHANNEL_MAP_NORMAL_ALL & ~(AUD_CHANNEL_MAP_CH5 | AUD_CHANNEL_MAP_CH6 | AUD_CHANNEL_MAP_CH7 | \ - AUD_CHANNEL_MAP_DIGMIC_CH5 | AUD_CHANNEL_MAP_DIGMIC_CH6 | AUD_CHANNEL_MAP_DIGMIC_CH7)) +#define NORMAL_MIC_MAP \ + (AUD_CHANNEL_MAP_NORMAL_ALL & \ + ~(AUD_CHANNEL_MAP_CH5 | AUD_CHANNEL_MAP_CH6 | AUD_CHANNEL_MAP_CH7 | \ + AUD_CHANNEL_MAP_DIGMIC_CH5 | AUD_CHANNEL_MAP_DIGMIC_CH6 | \ + AUD_CHANNEL_MAP_DIGMIC_CH7)) #endif -#define NORMAL_ADC_MAP (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1 | AUD_CHANNEL_MAP_CH2 | AUD_CHANNEL_MAP_CH3 | AUD_CHANNEL_MAP_CH4) +#define NORMAL_ADC_MAP \ + (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1 | AUD_CHANNEL_MAP_CH2 | \ + AUD_CHANNEL_MAP_CH3 | AUD_CHANNEL_MAP_CH4) -#define EC_MIC_MAP (AUD_CHANNEL_MAP_ECMIC_CH0 | AUD_CHANNEL_MAP_ECMIC_CH1) -#define EC_ADC_MAP (AUD_CHANNEL_MAP_CH5 | AUD_CHANNEL_MAP_CH6) +#define EC_MIC_MAP (AUD_CHANNEL_MAP_ECMIC_CH0 | AUD_CHANNEL_MAP_ECMIC_CH1) +#define EC_ADC_MAP (AUD_CHANNEL_MAP_CH5 | AUD_CHANNEL_MAP_CH6) -#define VALID_MIC_MAP (NORMAL_MIC_MAP | EC_MIC_MAP) -#define VALID_ADC_MAP (NORMAL_ADC_MAP | EC_ADC_MAP) +#define VALID_MIC_MAP (NORMAL_MIC_MAP | EC_MIC_MAP) +#define VALID_ADC_MAP (NORMAL_ADC_MAP | EC_ADC_MAP) -#define VALID_SPK_MAP (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1) -#define VALID_DAC_MAP VALID_SPK_MAP +#define VALID_SPK_MAP (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1) +#define VALID_DAC_MAP VALID_SPK_MAP #if (CFG_HW_AUD_OUTPUT_PATH_SPEAKER_DEV & ~VALID_SPK_MAP) #error "Invalid CFG_HW_AUD_OUTPUT_PATH_SPEAKER_DEV" @@ -123,131 +131,161 @@ #error "Invalid CODEC_OUTPUT_DEV" #endif -#define RSTN_ADC_FREE_RUNNING_CLK CODEC_SOFT_RSTN_ADC(1 << NORMAL_ADC_CH_NUM) +#define RSTN_ADC_FREE_RUNNING_CLK CODEC_SOFT_RSTN_ADC(1 << NORMAL_ADC_CH_NUM) -#if defined(SPEECH_SIDETONE) && \ - (defined(CFG_HW_AUD_SIDETONE_MIC_DEV) && (CFG_HW_AUD_SIDETONE_MIC_DEV)) && \ - defined(CFG_HW_AUD_SIDETONE_GAIN_DBVAL) +#if defined(SPEECH_SIDETONE) && \ + (defined(CFG_HW_AUD_SIDETONE_MIC_DEV) && (CFG_HW_AUD_SIDETONE_MIC_DEV)) && \ + defined(CFG_HW_AUD_SIDETONE_GAIN_DBVAL) #define SIDETONE_ENABLE -#if (CFG_HW_AUD_SIDETONE_GAIN_DBVAL > MAX_SIDETONE_DBVAL) || \ - (CFG_HW_AUD_SIDETONE_GAIN_DBVAL < MIN_SIDETONE_DBVAL) || \ - defined(CFG_HW_AUD_SIDETONE_IIR_INDEX) || \ - defined(CFG_HW_AUD_SIDETONE_GAIN_RAMP) +#if (CFG_HW_AUD_SIDETONE_GAIN_DBVAL > MAX_SIDETONE_DBVAL) || \ + (CFG_HW_AUD_SIDETONE_GAIN_DBVAL < MIN_SIDETONE_DBVAL) || \ + defined(CFG_HW_AUD_SIDETONE_IIR_INDEX) || \ + defined(CFG_HW_AUD_SIDETONE_GAIN_RAMP) #define SIDETONE_DEDICATED_ADC_CHAN #define SIDETONE_RESERVED_ADC_CHAN #endif #endif enum CODEC_ADC_EN_REQ_T { - CODEC_ADC_EN_REQ_STREAM, - CODEC_ADC_EN_REQ_MC, - CODEC_ADC_EN_REQ_DSD, + CODEC_ADC_EN_REQ_STREAM, + CODEC_ADC_EN_REQ_MC, + CODEC_ADC_EN_REQ_DSD, - CODEC_ADC_EN_REQ_QTY, + CODEC_ADC_EN_REQ_QTY, }; enum CODEC_IRQ_TYPE_T { - CODEC_IRQ_TYPE_BT_TRIGGER, - CODEC_IRQ_TYPE_VAD, - CODEC_IRQ_TYPE_ANC_FB_CHECK, + CODEC_IRQ_TYPE_BT_TRIGGER, + CODEC_IRQ_TYPE_VAD, + CODEC_IRQ_TYPE_ANC_FB_CHECK, - CODEC_IRQ_TYPE_QTY, + CODEC_IRQ_TYPE_QTY, }; struct CODEC_DAC_DRE_CFG_T { - uint8_t dre_delay; - uint8_t thd_db_offset; - uint8_t step_mode; - uint32_t dre_win; - uint16_t amp_high; + uint8_t dre_delay; + uint8_t thd_db_offset; + uint8_t step_mode; + uint32_t dre_win; + uint16_t amp_high; }; struct CODEC_DAC_SAMPLE_RATE_T { - enum AUD_SAMPRATE_T sample_rate; - uint32_t codec_freq; - uint8_t codec_div; - uint8_t cmu_div; - uint8_t dac_up; - uint8_t bypass_cnt; - uint8_t mc_delay; + enum AUD_SAMPRATE_T sample_rate; + uint32_t codec_freq; + uint8_t codec_div; + uint8_t cmu_div; + uint8_t dac_up; + uint8_t bypass_cnt; + uint8_t mc_delay; }; static const struct CODEC_DAC_SAMPLE_RATE_T codec_dac_sample_rate[] = { #ifdef __AUDIO_RESAMPLE__ - {AUD_SAMPRATE_8463, CODEC_FREQ_CRYSTAL, 1, 1, 6, 0, MC_DELAY_COMMON + 160}, - {AUD_SAMPRATE_16927, CODEC_FREQ_CRYSTAL, 1, 1, 3, 0, MC_DELAY_COMMON + 85}, - {AUD_SAMPRATE_50781, CODEC_FREQ_CRYSTAL, 1, 1, 1, 0, MC_DELAY_COMMON + 29}, + {AUD_SAMPRATE_8463, CODEC_FREQ_CRYSTAL, 1, 1, 6, 0, MC_DELAY_COMMON + 160}, + {AUD_SAMPRATE_16927, CODEC_FREQ_CRYSTAL, 1, 1, 3, 0, MC_DELAY_COMMON + 85}, + {AUD_SAMPRATE_50781, CODEC_FREQ_CRYSTAL, 1, 1, 1, 0, MC_DELAY_COMMON + 29}, #endif - {AUD_SAMPRATE_7350, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 6, 0, MC_DELAY_COMMON + 174}, - {AUD_SAMPRATE_8000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 6, 0, MC_DELAY_COMMON + 168}, // T - {AUD_SAMPRATE_14700, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 3, 0, MC_DELAY_COMMON + 71}, - {AUD_SAMPRATE_16000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 3, 0, MC_DELAY_COMMON + 88}, // T - {AUD_SAMPRATE_22050, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 2, 0, MC_DELAY_COMMON + 60}, - {AUD_SAMPRATE_24000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 2, 0, MC_DELAY_COMMON + 58}, - {AUD_SAMPRATE_44100, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, 0, MC_DELAY_COMMON + 31}, // T - {AUD_SAMPRATE_48000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, 0, MC_DELAY_COMMON + 30}, // T - {AUD_SAMPRATE_88200, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, 1, MC_DELAY_COMMON + 12}, - {AUD_SAMPRATE_96000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, 1, MC_DELAY_COMMON + 12}, // T - {AUD_SAMPRATE_176400, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, 2, MC_DELAY_COMMON + 5}, - {AUD_SAMPRATE_192000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, 2, MC_DELAY_COMMON + 5}, - {AUD_SAMPRATE_352800, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, 3, MC_DELAY_COMMON + 2}, - {AUD_SAMPRATE_384000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, 3, MC_DELAY_COMMON + 2}, + {AUD_SAMPRATE_7350, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, + 6, 0, MC_DELAY_COMMON + 174}, + {AUD_SAMPRATE_8000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 6, + 0, MC_DELAY_COMMON + 168}, // T + {AUD_SAMPRATE_14700, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, + 3, 0, MC_DELAY_COMMON + 71}, + {AUD_SAMPRATE_16000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 3, + 0, MC_DELAY_COMMON + 88}, // T + {AUD_SAMPRATE_22050, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, + 2, 0, MC_DELAY_COMMON + 60}, + {AUD_SAMPRATE_24000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 2, + 0, MC_DELAY_COMMON + 58}, + {AUD_SAMPRATE_44100, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, + 1, 0, MC_DELAY_COMMON + 31}, // T + {AUD_SAMPRATE_48000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, + 0, MC_DELAY_COMMON + 30}, // T + {AUD_SAMPRATE_88200, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, + 1, 1, MC_DELAY_COMMON + 12}, + {AUD_SAMPRATE_96000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, + 1, MC_DELAY_COMMON + 12}, // T + {AUD_SAMPRATE_176400, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, + 1, 2, MC_DELAY_COMMON + 5}, + {AUD_SAMPRATE_192000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, + 1, 2, MC_DELAY_COMMON + 5}, + {AUD_SAMPRATE_352800, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, + 1, 3, MC_DELAY_COMMON + 2}, + {AUD_SAMPRATE_384000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, + 1, 3, MC_DELAY_COMMON + 2}, }; struct CODEC_ADC_SAMPLE_RATE_T { - enum AUD_SAMPRATE_T sample_rate; - uint32_t codec_freq; - uint8_t codec_div; - uint8_t cmu_div; - uint8_t adc_down; - uint8_t bypass_cnt; + enum AUD_SAMPRATE_T sample_rate; + uint32_t codec_freq; + uint8_t codec_div; + uint8_t cmu_div; + uint8_t adc_down; + uint8_t bypass_cnt; }; static const struct CODEC_ADC_SAMPLE_RATE_T codec_adc_sample_rate[] = { #ifdef __AUDIO_RESAMPLE__ - {AUD_SAMPRATE_8463, CODEC_FREQ_CRYSTAL, 1, 1, 6, 0}, - {AUD_SAMPRATE_16927, CODEC_FREQ_CRYSTAL, 1, 1, 3, 0}, - {AUD_SAMPRATE_50781, CODEC_FREQ_CRYSTAL, 1, 1, 1, 0}, + {AUD_SAMPRATE_8463, CODEC_FREQ_CRYSTAL, 1, 1, 6, 0}, + {AUD_SAMPRATE_16927, CODEC_FREQ_CRYSTAL, 1, 1, 3, 0}, + {AUD_SAMPRATE_50781, CODEC_FREQ_CRYSTAL, 1, 1, 1, 0}, #endif - {AUD_SAMPRATE_7350, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 6, 0}, - {AUD_SAMPRATE_8000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 6, 0}, - {AUD_SAMPRATE_14700, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 3, 0}, - {AUD_SAMPRATE_16000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 3, 0}, - {AUD_SAMPRATE_44100, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, 0}, - {AUD_SAMPRATE_48000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, 0}, - {AUD_SAMPRATE_88200, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, 1}, - {AUD_SAMPRATE_96000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, 1}, - {AUD_SAMPRATE_176400, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, 2}, - {AUD_SAMPRATE_192000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, 2}, - {AUD_SAMPRATE_352800, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, 3}, - {AUD_SAMPRATE_384000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, 3}, + {AUD_SAMPRATE_7350, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, + 6, 0}, + {AUD_SAMPRATE_8000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 6, + 0}, + {AUD_SAMPRATE_14700, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, + 3, 0}, + {AUD_SAMPRATE_16000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 3, + 0}, + {AUD_SAMPRATE_44100, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, + 1, 0}, + {AUD_SAMPRATE_48000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, + 0}, + {AUD_SAMPRATE_88200, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, + 1, 1}, + {AUD_SAMPRATE_96000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, 1, + 1}, + {AUD_SAMPRATE_176400, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, + 1, 2}, + {AUD_SAMPRATE_192000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, + 1, 2}, + {AUD_SAMPRATE_352800, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, + 1, 3}, + {AUD_SAMPRATE_384000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, CODEC_CMU_DIV, + 1, 3}, }; const CODEC_ADC_VOL_T WEAK codec_adc_vol[TGT_ADC_VOL_LEVEL_QTY] = { -99, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, }; -static struct CODEC_T * const codec = (struct CODEC_T *)CODEC_BASE; +static struct CODEC_T *const codec = (struct CODEC_T *)CODEC_BASE; -#define CODEC_FIR_CH0_BASE (CODEC_BASE + 0x9000) -#define CODEC_FIR_CH1_BASE (CODEC_BASE + 0xB000) -#define CODEC_FIR_CH2_BASE (CODEC_BASE + 0xD000) -#define CODEC_FIR_CH3_BASE (CODEC_BASE + 0xF000) +#define CODEC_FIR_CH0_BASE (CODEC_BASE + 0x9000) +#define CODEC_FIR_CH1_BASE (CODEC_BASE + 0xB000) +#define CODEC_FIR_CH2_BASE (CODEC_BASE + 0xD000) +#define CODEC_FIR_CH3_BASE (CODEC_BASE + 0xF000) -#define CODEC_FIR_HISTORY_CH0_BASE (CODEC_FIR_CH0_BASE - 0x1000) -#define CODEC_FIR_HISTORY_CH1_BASE (CODEC_FIR_CH1_BASE - 0x1000) -#define CODEC_FIR_HISTORY_CH2_BASE (CODEC_FIR_CH2_BASE - 0x1000) -#define CODEC_FIR_HISTORY_CH3_BASE (CODEC_FIR_CH3_BASE - 0x1000) +#define CODEC_FIR_HISTORY_CH0_BASE (CODEC_FIR_CH0_BASE - 0x1000) +#define CODEC_FIR_HISTORY_CH1_BASE (CODEC_FIR_CH1_BASE - 0x1000) +#define CODEC_FIR_HISTORY_CH2_BASE (CODEC_FIR_CH2_BASE - 0x1000) +#define CODEC_FIR_HISTORY_CH3_BASE (CODEC_FIR_CH3_BASE - 0x1000) #ifdef CODEC_MIN_PHASE -static volatile int32_t * const codec_fir_ch0 = (int32_t *)CODEC_FIR_CH0_BASE; -static volatile int32_t * const codec_fir_ch1 = (int32_t *)CODEC_FIR_CH1_BASE; -static volatile int32_t * const codec_fir_ch2 = (int32_t *)CODEC_FIR_CH2_BASE; -static volatile int32_t * const codec_fir_ch3 = (int32_t *)CODEC_FIR_CH3_BASE; -static volatile int32_t * const codec_fir_history0 = (int32_t *)CODEC_FIR_HISTORY_CH0_BASE; -static volatile int32_t * const codec_fir_history1 = (int32_t *)CODEC_FIR_HISTORY_CH1_BASE; -static volatile int32_t * const codec_fir_history2 = (int32_t *)CODEC_FIR_HISTORY_CH2_BASE; -static volatile int32_t * const codec_fir_history3 = (int32_t *)CODEC_FIR_HISTORY_CH3_BASE; +static volatile int32_t *const codec_fir_ch0 = (int32_t *)CODEC_FIR_CH0_BASE; +static volatile int32_t *const codec_fir_ch1 = (int32_t *)CODEC_FIR_CH1_BASE; +static volatile int32_t *const codec_fir_ch2 = (int32_t *)CODEC_FIR_CH2_BASE; +static volatile int32_t *const codec_fir_ch3 = (int32_t *)CODEC_FIR_CH3_BASE; +static volatile int32_t *const codec_fir_history0 = + (int32_t *)CODEC_FIR_HISTORY_CH0_BASE; +static volatile int32_t *const codec_fir_history1 = + (int32_t *)CODEC_FIR_HISTORY_CH1_BASE; +static volatile int32_t *const codec_fir_history2 = + (int32_t *)CODEC_FIR_HISTORY_CH2_BASE; +static volatile int32_t *const codec_fir_history3 = + (int32_t *)CODEC_FIR_HISTORY_CH3_BASE; #define MAX_FIR_ORDERS (512) @@ -270,44 +308,99 @@ const static int32_t POSSIBLY_UNUSED fir_coef_linear[FIR_DAC_ORDERS] = { const static int32_t POSSIBLY_UNUSED fir_coef_minimun[FIR_DAC_ORDERS] = { #ifdef FIR_LOW_FREQ - 171,1077,4203,12582,31473,68652,133899,237244,385800,579602,807418,1044189,1251727,1383990,1396843,1260694,972640,563948, - 99101,-335381,-650923,-780973,-701927,-443652,-84578,268808,512951,579186,455906,192655,-116310,-364122,-468309,-399443, - -190845,74646,296174,392908,334154,149860,-82526,-269615,-339392,-269328,-94001,110604,259377,293401,203556,32780,-143605, - -250723,-245944,-136029,27365,171442,234497,192404,67901,-80955,-187545,-206431,-132784,-3152,122291,187500,165597,69954, - -53253,-147114,-170196,-114838,-9444,95806,152719,137136,59154,-42785,-120684,-139533,-93024,-5397,80987,126029,110487, - 44131,-39952,-101741,-113290,-71331,2185,71419,104055,86354,28846,-39643,-86369,-90279,-51459,9830,63615,84824,64943,15296, - -39213,-72539,-69912,-34308,15781,55890,67480,46479,4496,-37461,-59466,-52097,-20389,19303,47689,51882,31200,-3160,-34103, - -47104,-36994,-9893,20334,39133,38235,19235,-7752,-29414,-35781,-24769,-2693,19264,30682,26817,10499,-9713,-23968,-25906, - -15440,1619,16733,22882,17788,4668,-9693,-18412,-17788,-8810,3652,13454,16181,11101,1226,-8416,-13305,-11533,-4481,4101, - 10062,10834,6508,-446,-6545,-9016,-7036,-1934,3627,7021,6880,3613,-961,-4595,-5701,-4025,-619,2769,4591,4179,1965,-839, - -2887,-3327,-2140,-46,1903,2850,2488,1144,-458,-1565,-1740,-1020,170,1245,1754,1547,815,-53,-656,-761,-376,288,927,1290, - 1257,878,307,-256,-663,-840,-809,-642,-427,-237,-103,-33, + 171, 1077, 4203, 12582, 31473, 68652, 133899, 237244, + 385800, 579602, 807418, 1044189, 1251727, 1383990, 1396843, 1260694, + 972640, 563948, 99101, -335381, -650923, -780973, -701927, -443652, + -84578, 268808, 512951, 579186, 455906, 192655, -116310, -364122, + -468309, -399443, -190845, 74646, 296174, 392908, 334154, 149860, + -82526, -269615, -339392, -269328, -94001, 110604, 259377, 293401, + 203556, 32780, -143605, -250723, -245944, -136029, 27365, 171442, + 234497, 192404, 67901, -80955, -187545, -206431, -132784, -3152, + 122291, 187500, 165597, 69954, -53253, -147114, -170196, -114838, + -9444, 95806, 152719, 137136, 59154, -42785, -120684, -139533, + -93024, -5397, 80987, 126029, 110487, 44131, -39952, -101741, + -113290, -71331, 2185, 71419, 104055, 86354, 28846, -39643, + -86369, -90279, -51459, 9830, 63615, 84824, 64943, 15296, + -39213, -72539, -69912, -34308, 15781, 55890, 67480, 46479, + 4496, -37461, -59466, -52097, -20389, 19303, 47689, 51882, + 31200, -3160, -34103, -47104, -36994, -9893, 20334, 39133, + 38235, 19235, -7752, -29414, -35781, -24769, -2693, 19264, + 30682, 26817, 10499, -9713, -23968, -25906, -15440, 1619, + 16733, 22882, 17788, 4668, -9693, -18412, -17788, -8810, + 3652, 13454, 16181, 11101, 1226, -8416, -13305, -11533, + -4481, 4101, 10062, 10834, 6508, -446, -6545, -9016, + -7036, -1934, 3627, 7021, 6880, 3613, -961, -4595, + -5701, -4025, -619, 2769, 4591, 4179, 1965, -839, + -2887, -3327, -2140, -46, 1903, 2850, 2488, 1144, + -458, -1565, -1740, -1020, 170, 1245, 1754, 1547, + 815, -53, -656, -761, -376, 288, 927, 1290, + 1257, 878, 307, -256, -663, -840, -809, -642, + -427, -237, -103, -33, #else - 358,2134,7870,22383,53324,110934,206479,349044,541000,773159,1021370,1246556,1399740,1432299,1309745,1025462,609633,129002, - -324731,-656532,-794417,-712592,-443054,-70120,292346,535048,587990,443750,160328,-158614,-400055,-481834,-382027, - -146176,130807,341515,407598,309695,93804,-148511,-318068,-348626,-233320,-26063,182493,304084,290262,152119,-45991, - -215703,-283797,-223953,-67174,113414,236243,248077,147280,-16729,-167204,-235765,-193530,-63427,91650,198950,209932, - 122330,-19887,-148250,-202614,-159367,-41765,92191,178176,176391,90055,-37106,-142792,-176569,-123965,-12686,101744, - 163572,143971,54527,-59287,-141093,-151499,-87091,18628,112527,148481,110037,17958,-80830,-137074,-123736,-49016,48438, - 119432,129027,73750,-17278,-97589,-127045,-91900,-11220,73360,119064,103602,36056,-48313,-106407,-109292,-56617,23738, - 90354,109596,72600,-665,-72105,-105274,-83967,-20135,52732,97141,90877,38119,-33174,-86035,-93649,-52950,14213,72765, - 92702,64465,3511,-58099,-88538,-72655,-19509,42731,81690,77624,33421,-27283,-72714,-79582,-45018,12285,62151,78801,54174, - 1818,-50528,-75615,-60867,-14676,38325,70381,65146,26015,-25988,-63481,-67140,-35653,13901,55293,67020,43473,-2402,-46194, - -65008,-49433,-8237,36534,61346,53542,17793,-26648,-56304,-55870,-26107,16829,50150,56518,33065,-7346,-43163,-55631,-38609, - -1582,35606,53375,42719,9762,-27735,-49938,-45423,-17053,19783,45514,46773,23343,-11967,-40312,-46863,-28563,4471,34530,45798, - 32673,2539,-28370,-43713,-35673,-8936,22017,40746,37582,14610,-15648,-37053,-38453,-19489,9418,32783,38351,23519,-3470,-28096, - -37370,-26681,-2079,23137,35604,28971,7128,-18054,-33170,-30413,-11603,12974,30179,31045,15443,-8023,-26756,-30924,-18617,3302, - 23015,30118,21105,1094,-19077,-28707,-22913,-5093,15046,26776,24054,8635,-11031,-24419,-24565,-11680,7118,21726,24486,14198,-3394, - -18792,-23876,-16181,-76,15704,22793,17629,3230,-12551,-21309,-18559,-6028,9408,19490,18994,8433,-6352,-17414,-18974,-10431,3440, - 15149,18537,12008,-731,-12769,-17737,-13172,-1735,10336,16622,13932,3920,-7916,-15252,-14311,-5805,5559,13680,14335,7371,-3319,-11967, - -14040,-8615,1232,10161,13463,9538,664,-8320,-12648,-10154,-2348,6485,11634,10474,3797,-4703,-10470,-10527,-5006,3007,9196,10334,5966, - -1433,-7856,-9930,-6686,1,6486,9343,7168,1266,-5126,-8610,-7432,-2359,3803,7762,7491,3267,-2551,-6835,-7369,-3991,1387,5858,7087,4531, - -335,-4863,-6673,-4898,-597,3875,6149,5100,1395,-2920,-5545,-5154,-2058,2015,4882,5073,2582,-1181,-4187,-4878,-2974,427,3479,4586,3237, - 234,-2781,-4219,-3383,-799,2107,3793,3420,1262,-1476,-3331,-3363,-1628,894,2845,3224,1895,-375,-2357,-3021,-2074,-79,1875,2764,2167,459, - -1416,-2470,-2186,-771,987,2151,2139,1009,-599,-1823,-2040,-1182,254,1492,1894,1290,40,-1172,-1717,-1342,-286,869,1516,1343,480,-592,-1303, - -1303,-626,342,1084,1226,725,-127,-870,-1124,-784,-55,664,1001,803,200,-475,-869,-794,-313,303,729,756,392,-154,-592,-701,-443,28,458,630,468,74, - -337,-553,-473,-155,226,471,462,215,-130,-394,-443,-263,45,319,420,302,31,-253,-404,-349,-115,181,394,418,237,-74,-375,-536,-472,-196,214,626,935, - 1062,1013,824,581,341,166,55, + 358, 2134, 7870, 22383, 53324, 110934, 206479, 349044, + 541000, 773159, 1021370, 1246556, 1399740, 1432299, 1309745, 1025462, + 609633, 129002, -324731, -656532, -794417, -712592, -443054, -70120, + 292346, 535048, 587990, 443750, 160328, -158614, -400055, -481834, + -382027, -146176, 130807, 341515, 407598, 309695, 93804, -148511, + -318068, -348626, -233320, -26063, 182493, 304084, 290262, 152119, + -45991, -215703, -283797, -223953, -67174, 113414, 236243, 248077, + 147280, -16729, -167204, -235765, -193530, -63427, 91650, 198950, + 209932, 122330, -19887, -148250, -202614, -159367, -41765, 92191, + 178176, 176391, 90055, -37106, -142792, -176569, -123965, -12686, + 101744, 163572, 143971, 54527, -59287, -141093, -151499, -87091, + 18628, 112527, 148481, 110037, 17958, -80830, -137074, -123736, + -49016, 48438, 119432, 129027, 73750, -17278, -97589, -127045, + -91900, -11220, 73360, 119064, 103602, 36056, -48313, -106407, + -109292, -56617, 23738, 90354, 109596, 72600, -665, -72105, + -105274, -83967, -20135, 52732, 97141, 90877, 38119, -33174, + -86035, -93649, -52950, 14213, 72765, 92702, 64465, 3511, + -58099, -88538, -72655, -19509, 42731, 81690, 77624, 33421, + -27283, -72714, -79582, -45018, 12285, 62151, 78801, 54174, + 1818, -50528, -75615, -60867, -14676, 38325, 70381, 65146, + 26015, -25988, -63481, -67140, -35653, 13901, 55293, 67020, + 43473, -2402, -46194, -65008, -49433, -8237, 36534, 61346, + 53542, 17793, -26648, -56304, -55870, -26107, 16829, 50150, + 56518, 33065, -7346, -43163, -55631, -38609, -1582, 35606, + 53375, 42719, 9762, -27735, -49938, -45423, -17053, 19783, + 45514, 46773, 23343, -11967, -40312, -46863, -28563, 4471, + 34530, 45798, 32673, 2539, -28370, -43713, -35673, -8936, + 22017, 40746, 37582, 14610, -15648, -37053, -38453, -19489, + 9418, 32783, 38351, 23519, -3470, -28096, -37370, -26681, + -2079, 23137, 35604, 28971, 7128, -18054, -33170, -30413, + -11603, 12974, 30179, 31045, 15443, -8023, -26756, -30924, + -18617, 3302, 23015, 30118, 21105, 1094, -19077, -28707, + -22913, -5093, 15046, 26776, 24054, 8635, -11031, -24419, + -24565, -11680, 7118, 21726, 24486, 14198, -3394, -18792, + -23876, -16181, -76, 15704, 22793, 17629, 3230, -12551, + -21309, -18559, -6028, 9408, 19490, 18994, 8433, -6352, + -17414, -18974, -10431, 3440, 15149, 18537, 12008, -731, + -12769, -17737, -13172, -1735, 10336, 16622, 13932, 3920, + -7916, -15252, -14311, -5805, 5559, 13680, 14335, 7371, + -3319, -11967, -14040, -8615, 1232, 10161, 13463, 9538, + 664, -8320, -12648, -10154, -2348, 6485, 11634, 10474, + 3797, -4703, -10470, -10527, -5006, 3007, 9196, 10334, + 5966, -1433, -7856, -9930, -6686, 1, 6486, 9343, + 7168, 1266, -5126, -8610, -7432, -2359, 3803, 7762, + 7491, 3267, -2551, -6835, -7369, -3991, 1387, 5858, + 7087, 4531, -335, -4863, -6673, -4898, -597, 3875, + 6149, 5100, 1395, -2920, -5545, -5154, -2058, 2015, + 4882, 5073, 2582, -1181, -4187, -4878, -2974, 427, + 3479, 4586, 3237, 234, -2781, -4219, -3383, -799, + 2107, 3793, 3420, 1262, -1476, -3331, -3363, -1628, + 894, 2845, 3224, 1895, -375, -2357, -3021, -2074, + -79, 1875, 2764, 2167, 459, -1416, -2470, -2186, + -771, 987, 2151, 2139, 1009, -599, -1823, -2040, + -1182, 254, 1492, 1894, 1290, 40, -1172, -1717, + -1342, -286, 869, 1516, 1343, 480, -592, -1303, + -1303, -626, 342, 1084, 1226, 725, -127, -870, + -1124, -784, -55, 664, 1001, 803, 200, -475, + -869, -794, -313, 303, 729, 756, 392, -154, + -592, -701, -443, 28, 458, 630, 468, 74, + -337, -553, -473, -155, 226, 471, 462, 215, + -130, -394, -443, -263, 45, 319, 420, 302, + 31, -253, -404, -349, -115, 181, 394, 418, + 237, -74, -375, -536, -472, -196, 214, 626, + 935, 1062, 1013, 824, 581, 341, 166, 55, #endif }; @@ -342,7 +435,8 @@ static float dac_dc_gain_attn; #endif #ifdef __AUDIO_RESAMPLE__ static uint8_t rs_clk_map; -STATIC_ASSERT(sizeof(rs_clk_map) * 8 >= AUD_STREAM_NUM, "rs_clk_map size too small"); +STATIC_ASSERT(sizeof(rs_clk_map) * 8 >= AUD_STREAM_NUM, + "rs_clk_map size too small"); static uint32_t resample_clk_freq; static uint8_t resample_rate_idx[AUD_STREAM_NUM]; @@ -353,10 +447,11 @@ static uint32_t cur_codec_freq; // EC static uint8_t codec_rate_idx[AUD_STREAM_NUM]; -//static HAL_CODEC_DAC_RESET_CALLBACK dac_reset_callback; +// static HAL_CODEC_DAC_RESET_CALLBACK dac_reset_callback; static uint8_t codec_irq_map; -STATIC_ASSERT(sizeof(codec_irq_map) * 8 >= CODEC_IRQ_TYPE_QTY, "codec_irq_map size too small"); +STATIC_ASSERT(sizeof(codec_irq_map) * 8 >= CODEC_IRQ_TYPE_QTY, + "codec_irq_map size too small"); static HAL_CODEC_IRQ_CALLBACK codec_irq_callback[CODEC_IRQ_TYPE_QTY]; static enum AUD_CHANNEL_MAP_T codec_dac_ch_map; @@ -378,7 +473,7 @@ static uint8_t dac_delay_ms; #ifdef ANC_PROD_TEST #define OPT_TYPE #else -#define OPT_TYPE const +#define OPT_TYPE const #endif static OPT_TYPE uint8_t codec_digmic_phase = CODEC_DIGMIC_PHASE; @@ -399,7 +494,8 @@ static uint8_t dsd_rate_idx; #if defined(AUDIO_ANC_FB_MC) || defined(CODEC_DSD) static uint8_t adc_en_map; -STATIC_ASSERT(sizeof(adc_en_map) * 8 >= CODEC_ADC_EN_REQ_QTY, "adc_en_map size too small"); +STATIC_ASSERT(sizeof(adc_en_map) * 8 >= CODEC_ADC_EN_REQ_QTY, + "adc_en_map size too small"); #endif #ifdef PERF_TEST_POWER_KEY @@ -438,19 +534,23 @@ static struct dac_classg_cfg _dac_classg_cfg = { #ifdef DAC_DRE_ENABLE static const struct CODEC_DAC_DRE_CFG_T dac_dre_cfg = { .dre_delay = 8, - .thd_db_offset = 0xF, //5, + .thd_db_offset = 0xF, // 5, .step_mode = 0, .dre_win = 0x6000, - .amp_high = 2, //0x10, + .amp_high = 2, // 0x10, }; #endif -static void hal_codec_set_dig_adc_gain(enum AUD_CHANNEL_MAP_T map, int32_t gain); -static void hal_codec_set_dig_dac_gain(enum AUD_CHANNEL_MAP_T map, int32_t gain); +static void hal_codec_set_dig_adc_gain(enum AUD_CHANNEL_MAP_T map, + int32_t gain); +static void hal_codec_set_dig_dac_gain(enum AUD_CHANNEL_MAP_T map, + int32_t gain); static void hal_codec_restore_dig_dac_gain(void); -static void hal_codec_set_dac_gain_value(enum AUD_CHANNEL_MAP_T map, uint32_t val); +static void hal_codec_set_dac_gain_value(enum AUD_CHANNEL_MAP_T map, + uint32_t val); static int hal_codec_set_adc_down(enum AUD_CHANNEL_MAP_T map, uint32_t val); -static int hal_codec_set_adc_hbf_bypass_cnt(enum AUD_CHANNEL_MAP_T map, uint32_t cnt); +static int hal_codec_set_adc_hbf_bypass_cnt(enum AUD_CHANNEL_MAP_T map, + uint32_t cnt); static uint32_t hal_codec_get_adc_chan(enum AUD_CHANNEL_MAP_T mic_map); #ifdef AUDIO_OUTPUT_SW_GAIN static void hal_codec_set_sw_gain(int32_t gain); @@ -462,557 +562,586 @@ static uint32_t resample_phase_float_to_value(float phase); static float resample_phase_value_to_float(uint32_t value); #endif -static void hal_codec_reg_update_delay(void) -{ - hal_sys_timer_delay_us(2); -} +static void hal_codec_reg_update_delay(void) { hal_sys_timer_delay_us(2); } #if defined(DAC_CLASSG_ENABLE) -void hal_codec_classg_config(const struct dac_classg_cfg *cfg) -{ - _dac_classg_cfg = *cfg; +void hal_codec_classg_config(const struct dac_classg_cfg *cfg) { + _dac_classg_cfg = *cfg; } -static void hal_codec_classg_enable(bool en) -{ - struct dac_classg_cfg *config; +static void hal_codec_classg_enable(bool en) { + struct dac_classg_cfg *config; - if (en) { - config = &_dac_classg_cfg; + if (en) { + config = &_dac_classg_cfg; - codec->REG_0B4 = SET_BITFIELD(codec->REG_0B4, CODEC_CODEC_CLASSG_THD2, config->thd2); - codec->REG_0B4 = SET_BITFIELD(codec->REG_0B4, CODEC_CODEC_CLASSG_THD1, config->thd1); - codec->REG_0B4 = SET_BITFIELD(codec->REG_0B4, CODEC_CODEC_CLASSG_THD0, config->thd0); + codec->REG_0B4 = + SET_BITFIELD(codec->REG_0B4, CODEC_CODEC_CLASSG_THD2, config->thd2); + codec->REG_0B4 = + SET_BITFIELD(codec->REG_0B4, CODEC_CODEC_CLASSG_THD1, config->thd1); + codec->REG_0B4 = + SET_BITFIELD(codec->REG_0B4, CODEC_CODEC_CLASSG_THD0, config->thd0); - // Make class-g set the lowest gain after several samples. - // Class-g gain will have impact on dc. - codec->REG_0B0 = SET_BITFIELD(codec->REG_0B0, CODEC_CODEC_CLASSG_WINDOW, 6); + // Make class-g set the lowest gain after several samples. + // Class-g gain will have impact on dc. + codec->REG_0B0 = SET_BITFIELD(codec->REG_0B0, CODEC_CODEC_CLASSG_WINDOW, 6); - if (config->lr) - codec->REG_0B0 |= CODEC_CODEC_CLASSG_LR; - else - codec->REG_0B0 &= ~CODEC_CODEC_CLASSG_LR; + if (config->lr) + codec->REG_0B0 |= CODEC_CODEC_CLASSG_LR; + else + codec->REG_0B0 &= ~CODEC_CODEC_CLASSG_LR; - if (config->step_4_3n) - codec->REG_0B0 |= CODEC_CODEC_CLASSG_STEP_3_4N; - else - codec->REG_0B0 &= ~CODEC_CODEC_CLASSG_STEP_3_4N; + if (config->step_4_3n) + codec->REG_0B0 |= CODEC_CODEC_CLASSG_STEP_3_4N; + else + codec->REG_0B0 &= ~CODEC_CODEC_CLASSG_STEP_3_4N; - if (config->quick_down) - codec->REG_0B0 |= CODEC_CODEC_CLASSG_QUICK_DOWN; - else - codec->REG_0B0 &= ~CODEC_CODEC_CLASSG_QUICK_DOWN; + if (config->quick_down) + codec->REG_0B0 |= CODEC_CODEC_CLASSG_QUICK_DOWN; + else + codec->REG_0B0 &= ~CODEC_CODEC_CLASSG_QUICK_DOWN; - codec->REG_0B0 |= CODEC_CODEC_CLASSG_EN; + codec->REG_0B0 |= CODEC_CODEC_CLASSG_EN; - // Restore class-g window after the gain has been updated - hal_codec_reg_update_delay(); - codec->REG_0B0 = SET_BITFIELD(codec->REG_0B0, CODEC_CODEC_CLASSG_WINDOW, config->wind_width); - } else { - codec->REG_0B0 &= ~CODEC_CODEC_CLASSG_QUICK_DOWN; - } + // Restore class-g window after the gain has been updated + hal_codec_reg_update_delay(); + codec->REG_0B0 = SET_BITFIELD(codec->REG_0B0, CODEC_CODEC_CLASSG_WINDOW, + config->wind_width); + } else { + codec->REG_0B0 &= ~CODEC_CODEC_CLASSG_QUICK_DOWN; + } } #endif #if defined(AUDIO_OUTPUT_DC_CALIB) || defined(SDM_MUTE_NOISE_SUPPRESSION) -static void hal_codec_dac_dc_offset_enable(int32_t dc_l, int32_t dc_r) -{ - codec->REG_0E0 &= CODEC_CODEC_DAC_DC_UPDATE_CH0; - hal_codec_reg_update_delay(); - codec->REG_0E8 = SET_BITFIELD(codec->REG_0E8, CODEC_CODEC_DAC_DC_CH1, dc_r); - codec->REG_0E0 = SET_BITFIELD(codec->REG_0E0, CODEC_CODEC_DAC_DC_CH0, dc_l) | CODEC_CODEC_DAC_DC_UPDATE_CH0; +static void hal_codec_dac_dc_offset_enable(int32_t dc_l, int32_t dc_r) { + codec->REG_0E0 &= CODEC_CODEC_DAC_DC_UPDATE_CH0; + hal_codec_reg_update_delay(); + codec->REG_0E8 = SET_BITFIELD(codec->REG_0E8, CODEC_CODEC_DAC_DC_CH1, dc_r); + codec->REG_0E0 = SET_BITFIELD(codec->REG_0E0, CODEC_CODEC_DAC_DC_CH0, dc_l) | + CODEC_CODEC_DAC_DC_UPDATE_CH0; } #endif #ifdef CODEC_MIN_PHASE -static void hal_codec_min_phase_init(void) -{ - int i; +static void hal_codec_min_phase_init(void) { + int i; - // SYS clock should be 52M or above + // SYS clock should be 52M or above - // DAC - codec->REG_108 &= ~(CODEC_STREAM0_FIR1_CH0); - codec->REG_108 = SET_BITFIELD(codec->REG_108,CODEC_FIR_MODE_CH0,0); - codec->REG_108 = SET_BITFIELD(codec->REG_108,CODEC_FIR_ORDER_CH0,FIR_DAC_ORDERS); + // DAC + codec->REG_108 &= ~(CODEC_STREAM0_FIR1_CH0); + codec->REG_108 = SET_BITFIELD(codec->REG_108, CODEC_FIR_MODE_CH0, 0); + codec->REG_108 = + SET_BITFIELD(codec->REG_108, CODEC_FIR_ORDER_CH0, FIR_DAC_ORDERS); - codec->REG_10C = SET_BITFIELD(codec->REG_10C,CODEC_FIR_BURST_LENGTH_CH0,4); - codec->REG_10C = SET_BITFIELD(codec->REG_10C,CODEC_FIR_GAIN_SEL_CH0,4); + codec->REG_10C = SET_BITFIELD(codec->REG_10C, CODEC_FIR_BURST_LENGTH_CH0, 4); + codec->REG_10C = SET_BITFIELD(codec->REG_10C, CODEC_FIR_GAIN_SEL_CH0, 4); - codec->REG_110 &= ~(CODEC_STREAM0_FIR1_CH1); - codec->REG_110 = SET_BITFIELD(codec->REG_110,CODEC_FIR_MODE_CH1,0); - codec->REG_110 = SET_BITFIELD(codec->REG_110,CODEC_FIR_ORDER_CH1,FIR_DAC_ORDERS); + codec->REG_110 &= ~(CODEC_STREAM0_FIR1_CH1); + codec->REG_110 = SET_BITFIELD(codec->REG_110, CODEC_FIR_MODE_CH1, 0); + codec->REG_110 = + SET_BITFIELD(codec->REG_110, CODEC_FIR_ORDER_CH1, FIR_DAC_ORDERS); - codec->REG_114 = SET_BITFIELD(codec->REG_114,CODEC_FIR_BURST_LENGTH_CH1,4); - codec->REG_114 = SET_BITFIELD(codec->REG_114,CODEC_FIR_GAIN_SEL_CH1,4); + codec->REG_114 = SET_BITFIELD(codec->REG_114, CODEC_FIR_BURST_LENGTH_CH1, 4); + codec->REG_114 = SET_BITFIELD(codec->REG_114, CODEC_FIR_GAIN_SEL_CH1, 4); - // ADC - codec->REG_118 &= ~(CODEC_STREAM0_FIR1_CH2); - codec->REG_118 = SET_BITFIELD(codec->REG_118,CODEC_FIR_MODE_CH2,0); - codec->REG_118 = SET_BITFIELD(codec->REG_118,CODEC_FIR_ORDER_CH2,FIR_ADC_ORDERS); + // ADC + codec->REG_118 &= ~(CODEC_STREAM0_FIR1_CH2); + codec->REG_118 = SET_BITFIELD(codec->REG_118, CODEC_FIR_MODE_CH2, 0); + codec->REG_118 = + SET_BITFIELD(codec->REG_118, CODEC_FIR_ORDER_CH2, FIR_ADC_ORDERS); - //codec->REG_11C = SET_BITFIELD(codec->REG_11C,CODEC_FIR_BURST_LENGTH_CH2,4); - codec->REG_11C = SET_BITFIELD(codec->REG_11C,CODEC_FIR_GAIN_SEL_CH2,6); + // codec->REG_11C = SET_BITFIELD(codec->REG_11C,CODEC_FIR_BURST_LENGTH_CH2,4); + codec->REG_11C = SET_BITFIELD(codec->REG_11C, CODEC_FIR_GAIN_SEL_CH2, 6); - codec->REG_120 &= ~(CODEC_STREAM0_FIR1_CH3); - codec->REG_120 = SET_BITFIELD(codec->REG_120,CODEC_FIR_MODE_CH3,0); - codec->REG_120 = SET_BITFIELD(codec->REG_120,CODEC_FIR_ORDER_CH3,FIR_ADC_ORDERS); + codec->REG_120 &= ~(CODEC_STREAM0_FIR1_CH3); + codec->REG_120 = SET_BITFIELD(codec->REG_120, CODEC_FIR_MODE_CH3, 0); + codec->REG_120 = + SET_BITFIELD(codec->REG_120, CODEC_FIR_ORDER_CH3, FIR_ADC_ORDERS); - //codec->REG_124 = SET_BITFIELD(codec->REG_124,CODEC_FIR_BURST_LENGTH_CH3,4); - codec->REG_124 = SET_BITFIELD(codec->REG_124,CODEC_FIR_GAIN_SEL_CH3,6); + // codec->REG_124 = SET_BITFIELD(codec->REG_124,CODEC_FIR_BURST_LENGTH_CH3,4); + codec->REG_124 = SET_BITFIELD(codec->REG_124, CODEC_FIR_GAIN_SEL_CH3, 6); - // DAC - codec->REG_100 |= (CODEC_FIR_UPSAMPLE_CH0 | CODEC_FIR_UPSAMPLE_CH1); + // DAC + codec->REG_100 |= (CODEC_FIR_UPSAMPLE_CH0 | CODEC_FIR_UPSAMPLE_CH1); - for (i = 0; i < FIR_DAC_ORDERS; i++) { - codec_fir_ch0[i] = fir_coef_minimun[i]; - codec_fir_ch1[i] = fir_coef_minimun[i]; - } + for (i = 0; i < FIR_DAC_ORDERS; i++) { + codec_fir_ch0[i] = fir_coef_minimun[i]; + codec_fir_ch1[i] = fir_coef_minimun[i]; + } - // ADC - codec->REG_100 &= ~(CODEC_FIR_UPSAMPLE_CH2 | CODEC_FIR_UPSAMPLE_CH3); + // ADC + codec->REG_100 &= ~(CODEC_FIR_UPSAMPLE_CH2 | CODEC_FIR_UPSAMPLE_CH3); - for (i = 0; i < FIR_DAC_ORDERS; i++) { - codec_fir_ch2[i] = fir_coef_minimun[i]; - codec_fir_ch3[i] = fir_coef_minimun[i]; - } + for (i = 0; i < FIR_DAC_ORDERS; i++) { + codec_fir_ch2[i] = fir_coef_minimun[i]; + codec_fir_ch3[i] = fir_coef_minimun[i]; + } - // Init history buffer - for (i=0; i < MAX_FIR_ORDERS; i++) { - codec_fir_history0[i] = 0; - codec_fir_history1[i] = 0; - codec_fir_history2[i] = 0; - codec_fir_history3[i] = 0; - } + // Init history buffer + for (i = 0; i < MAX_FIR_ORDERS; i++) { + codec_fir_history0[i] = 0; + codec_fir_history1[i] = 0; + codec_fir_history2[i] = 0; + codec_fir_history3[i] = 0; + } } -static void hal_codec_min_phase_term(void) -{ - // Release SYS clock request +static void hal_codec_min_phase_term(void) { + // Release SYS clock request } #endif -int hal_codec_open(enum HAL_CODEC_ID_T id) -{ - int i; - bool first_open; +int hal_codec_open(enum HAL_CODEC_ID_T id) { + int i; + bool first_open; #ifdef CODEC_POWER_DOWN - first_open = true; + first_open = true; #else - first_open = !codec_init; + first_open = !codec_init; #endif - analog_aud_pll_open(ANA_AUD_PLL_USER_CODEC); + analog_aud_pll_open(ANA_AUD_PLL_USER_CODEC); - if (!codec_init) { - for (i = 0; i < CFG_HW_AUD_INPUT_PATH_NUM; i++) { - if (cfg_audio_input_path_cfg[i].cfg & AUD_CHANNEL_MAP_ALL & ~VALID_MIC_MAP) { - ASSERT(false, "Invalid input path cfg: i=%d io_path=%d cfg=0x%X", - i, cfg_audio_input_path_cfg[i].io_path, cfg_audio_input_path_cfg[i].cfg); - } - } + if (!codec_init) { + for (i = 0; i < CFG_HW_AUD_INPUT_PATH_NUM; i++) { + if (cfg_audio_input_path_cfg[i].cfg & AUD_CHANNEL_MAP_ALL & + ~VALID_MIC_MAP) { + ASSERT(false, "Invalid input path cfg: i=%d io_path=%d cfg=0x%X", i, + cfg_audio_input_path_cfg[i].io_path, + cfg_audio_input_path_cfg[i].cfg); + } + } #ifdef ANC_APP - anc_boost_gain_attn = 1.0f; + anc_boost_gain_attn = 1.0f; #endif - codec_init = true; - } - if (first_open) { - // Codec will be powered down first - hal_psc_codec_enable(); - } - hal_cmu_codec_clock_enable(); - hal_cmu_codec_reset_clear(); + codec_init = true; + } + if (first_open) { + // Codec will be powered down first + hal_psc_codec_enable(); + } + hal_cmu_codec_clock_enable(); + hal_cmu_codec_reset_clear(); - codec_opened = true; + codec_opened = true; - codec->REG_060 |= CODEC_EN_CLK_ADC_MASK | CODEC_EN_CLK_ADC_ANA_MASK | CODEC_POL_ADC_ANA_MASK | CODEC_POL_DAC_OUT; - codec->REG_064 |= CODEC_SOFT_RSTN_32K | CODEC_SOFT_RSTN_IIR | CODEC_SOFT_RSTN_RS | - CODEC_SOFT_RSTN_DAC | CODEC_SOFT_RSTN_ADC_MASK | CODEC_SOFT_RSTN_ADC_ANA_MASK; - codec->REG_000 = 0; - codec->REG_04C &= ~CODEC_MC_ENABLE; - codec->REG_004 = ~0UL; - hal_codec_reg_update_delay(); - codec->REG_004 = 0; - codec->REG_000 |= CODEC_CODEC_IF_EN; + codec->REG_060 |= CODEC_EN_CLK_ADC_MASK | CODEC_EN_CLK_ADC_ANA_MASK | + CODEC_POL_ADC_ANA_MASK | CODEC_POL_DAC_OUT; + codec->REG_064 |= CODEC_SOFT_RSTN_32K | CODEC_SOFT_RSTN_IIR | + CODEC_SOFT_RSTN_RS | CODEC_SOFT_RSTN_DAC | + CODEC_SOFT_RSTN_ADC_MASK | CODEC_SOFT_RSTN_ADC_ANA_MASK; + codec->REG_000 = 0; + codec->REG_04C &= ~CODEC_MC_ENABLE; + codec->REG_004 = ~0UL; + hal_codec_reg_update_delay(); + codec->REG_004 = 0; + codec->REG_000 |= CODEC_CODEC_IF_EN; - codec->REG_054 |= CODEC_FAULT_MUTE_DAC_ENABLE; + codec->REG_054 |= CODEC_FAULT_MUTE_DAC_ENABLE; #ifdef AUDIO_OUTPUT_SWAP - if (output_swap) { - codec->REG_0A0 |= CODEC_CODEC_DAC_OUT_SWAP; - } else { - codec->REG_0A0 &= ~CODEC_CODEC_DAC_OUT_SWAP; - } + if (output_swap) { + codec->REG_0A0 |= CODEC_CODEC_DAC_OUT_SWAP; + } else { + codec->REG_0A0 &= ~CODEC_CODEC_DAC_OUT_SWAP; + } #endif - if (first_open) { + if (first_open) { #ifdef AUDIO_ANC_FB_MC - codec->REG_04C = CODEC_DMA_CTRL_MC; - codec->REG_230 |= CODEC_MC_EN_SEL|CODEC_MC_RATE_SRC_SEL; + codec->REG_04C = CODEC_DMA_CTRL_MC; + codec->REG_230 |= CODEC_MC_EN_SEL | CODEC_MC_RATE_SRC_SEL; #endif - // ANC zero-crossing - codec->REG_0D4 |= CODEC_CODEC_ANC_MUTE_GAIN_PASS0_FF_CH0 | CODEC_CODEC_ANC_MUTE_GAIN_PASS0_FF_CH1; - codec->REG_0D8 |= CODEC_CODEC_ANC_MUTE_GAIN_PASS0_FB_CH0 | CODEC_CODEC_ANC_MUTE_GAIN_PASS0_FB_CH1; + // ANC zero-crossing + codec->REG_0D4 |= CODEC_CODEC_ANC_MUTE_GAIN_PASS0_FF_CH0 | + CODEC_CODEC_ANC_MUTE_GAIN_PASS0_FF_CH1; + codec->REG_0D8 |= CODEC_CODEC_ANC_MUTE_GAIN_PASS0_FB_CH0 | + CODEC_CODEC_ANC_MUTE_GAIN_PASS0_FB_CH1; - // Enable ADC zero-crossing gain adjustment - for (i = 0; i < NORMAL_ADC_CH_NUM; i++) { - *(&codec->REG_084 + i) |= CODEC_CODEC_ADC_GAIN_SEL_CH0; - } + // Enable ADC zero-crossing gain adjustment + for (i = 0; i < NORMAL_ADC_CH_NUM; i++) { + *(&codec->REG_084 + i) |= CODEC_CODEC_ADC_GAIN_SEL_CH0; + } - // DRE ini gain and offset - uint8_t max_gain, ini_gain, dre_offset; - max_gain = analog_aud_get_max_dre_gain(); - if (max_gain < 0xF) { - ini_gain = 0xF - max_gain; - } else { - ini_gain = 0; - } - if (max_gain > 0xF) { - dre_offset = max_gain - 0xF; - } else { - dre_offset = 0; - } - codec->REG_0C0 = CODEC_CODEC_DRE_INI_ANA_GAIN_CH0(ini_gain) | CODEC_CODEC_DRE_GAIN_OFFSET_CH0(dre_offset); - codec->REG_0C8 = CODEC_CODEC_DRE_INI_ANA_GAIN_CH1(ini_gain) | CODEC_CODEC_DRE_GAIN_OFFSET_CH1(dre_offset); - codec->REG_0E0 = CODEC_CODEC_DAC_ANA_GAIN_UPDATE_DELAY_CH0(0); - codec->REG_0E8 = CODEC_CODEC_DAC_ANA_GAIN_UPDATE_DELAY_CH1(0); + // DRE ini gain and offset + uint8_t max_gain, ini_gain, dre_offset; + max_gain = analog_aud_get_max_dre_gain(); + if (max_gain < 0xF) { + ini_gain = 0xF - max_gain; + } else { + ini_gain = 0; + } + if (max_gain > 0xF) { + dre_offset = max_gain - 0xF; + } else { + dre_offset = 0; + } + codec->REG_0C0 = CODEC_CODEC_DRE_INI_ANA_GAIN_CH0(ini_gain) | + CODEC_CODEC_DRE_GAIN_OFFSET_CH0(dre_offset); + codec->REG_0C8 = CODEC_CODEC_DRE_INI_ANA_GAIN_CH1(ini_gain) | + CODEC_CODEC_DRE_GAIN_OFFSET_CH1(dre_offset); + codec->REG_0E0 = CODEC_CODEC_DAC_ANA_GAIN_UPDATE_DELAY_CH0(0); + codec->REG_0E8 = CODEC_CODEC_DAC_ANA_GAIN_UPDATE_DELAY_CH1(0); #ifdef ANC_PROD_TEST #ifdef AUDIO_ANC_FB_MC - // Enable ADC + music cancel. - codec->REG_130 |= CODEC_CODEC_FB_CHECK_KEEP_CH0; - codec->REG_134 |= CODEC_CODEC_FB_CHECK_KEEP_CH1; + // Enable ADC + music cancel. + codec->REG_130 |= CODEC_CODEC_FB_CHECK_KEEP_CH0; + codec->REG_134 |= CODEC_CODEC_FB_CHECK_KEEP_CH1; #elif defined(AUDIO_ANC_FB_MC_HW) - // Enable ADC + music cancel. - codec->REG_130 |= CODEC_CODEC_FB_CHECK_KEEP_CH0; + // Enable ADC + music cancel. + codec->REG_130 |= CODEC_CODEC_FB_CHECK_KEEP_CH0; #endif #endif #if defined(FIXED_CODEC_ADC_VOL) && defined(SINGLE_CODEC_ADC_VOL) - const CODEC_ADC_VOL_T *adc_gain_db; + const CODEC_ADC_VOL_T *adc_gain_db; - adc_gain_db = hal_codec_get_adc_volume(CODEC_SADC_VOL); - if (adc_gain_db) { - hal_codec_set_dig_adc_gain(NORMAL_ADC_MAP, *adc_gain_db); + adc_gain_db = hal_codec_get_adc_volume(CODEC_SADC_VOL); + if (adc_gain_db) { + hal_codec_set_dig_adc_gain(NORMAL_ADC_MAP, *adc_gain_db); #ifdef SIDETONE_DEDICATED_ADC_CHAN - sidetone_adc_gain = *adc_gain_db; + sidetone_adc_gain = *adc_gain_db; #endif - } + } #endif #ifdef AUDIO_OUTPUT_DC_CALIB - hal_codec_dac_dc_offset_enable(dac_dc_l, dac_dc_r); + hal_codec_dac_dc_offset_enable(dac_dc_l, dac_dc_r); #elif defined(SDM_MUTE_NOISE_SUPPRESSION) - hal_codec_dac_dc_offset_enable(1, 1); + hal_codec_dac_dc_offset_enable(1, 1); #endif #ifdef AUDIO_OUTPUT_SW_GAIN - const struct CODEC_DAC_VOL_T *vol_tab_ptr; + const struct CODEC_DAC_VOL_T *vol_tab_ptr; - // Init gain settings - vol_tab_ptr = hal_codec_get_dac_volume(0); - if (vol_tab_ptr) { - analog_aud_set_dac_gain(vol_tab_ptr->tx_pa_gain); - hal_codec_set_dig_dac_gain(VALID_DAC_MAP, ZERODB_DIG_DBVAL); - } + // Init gain settings + vol_tab_ptr = hal_codec_get_dac_volume(0); + if (vol_tab_ptr) { + analog_aud_set_dac_gain(vol_tab_ptr->tx_pa_gain); + hal_codec_set_dig_dac_gain(VALID_DAC_MAP, ZERODB_DIG_DBVAL); + } #else - // Enable DAC zero-crossing gain adjustment - codec->REG_09C |= CODEC_CODEC_DAC_GAIN_SEL_CH0; - codec->REG_0A0 |= CODEC_CODEC_DAC_GAIN_SEL_CH1; + // Enable DAC zero-crossing gain adjustment + codec->REG_09C |= CODEC_CODEC_DAC_GAIN_SEL_CH0; + codec->REG_0A0 |= CODEC_CODEC_DAC_GAIN_SEL_CH1; #endif #ifdef AUDIO_OUTPUT_DC_CALIB_ANA - // Reset SDM - hal_codec_set_dac_gain_value(VALID_DAC_MAP, 0); - codec->REG_098 |= CODEC_CODEC_DAC_SDM_CLOSE; + // Reset SDM + hal_codec_set_dac_gain_value(VALID_DAC_MAP, 0); + codec->REG_098 |= CODEC_CODEC_DAC_SDM_CLOSE; #endif #ifdef SDM_MUTE_NOISE_SUPPRESSION - codec->REG_098 = SET_BITFIELD(codec->REG_098, CODEC_CODEC_DAC_DITHER_GAIN, 0x10); + codec->REG_098 = + SET_BITFIELD(codec->REG_098, CODEC_CODEC_DAC_DITHER_GAIN, 0x10); #endif #ifdef __AUDIO_RESAMPLE__ - codec->REG_0E4 &= ~(CODEC_CODEC_RESAMPLE_DAC_ENABLE | CODEC_CODEC_RESAMPLE_ADC_ENABLE | - CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE | CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE); + codec->REG_0E4 &= + ~(CODEC_CODEC_RESAMPLE_DAC_ENABLE | CODEC_CODEC_RESAMPLE_ADC_ENABLE | + CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE | + CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE); #endif #ifdef CODEC_DSD - for(i = 0; i < ARRAY_SIZE(codec_adc_sample_rate); i++) { - if(codec_adc_sample_rate[i].sample_rate == AUD_SAMPRATE_44100) { - break; - } - } - hal_codec_set_adc_down((AUD_CHANNEL_MAP_CH2 | AUD_CHANNEL_MAP_CH3), codec_adc_sample_rate[i].adc_down); - hal_codec_set_adc_hbf_bypass_cnt((AUD_CHANNEL_MAP_CH2 | AUD_CHANNEL_MAP_CH3), codec_adc_sample_rate[i].bypass_cnt); + for (i = 0; i < ARRAY_SIZE(codec_adc_sample_rate); i++) { + if (codec_adc_sample_rate[i].sample_rate == AUD_SAMPRATE_44100) { + break; + } + } + hal_codec_set_adc_down((AUD_CHANNEL_MAP_CH2 | AUD_CHANNEL_MAP_CH3), + codec_adc_sample_rate[i].adc_down); + hal_codec_set_adc_hbf_bypass_cnt( + (AUD_CHANNEL_MAP_CH2 | AUD_CHANNEL_MAP_CH3), + codec_adc_sample_rate[i].bypass_cnt); #endif - // Mute DAC when cpu fault occurs - hal_cmu_codec_set_fault_mask(0x3F); + // Mute DAC when cpu fault occurs + hal_cmu_codec_set_fault_mask(0x3F); #ifdef CODEC_TIMER - // Disable sync stamp auto clear to avoid impacting codec timer capture - codec->REG_054 &= ~CODEC_STAMP_CLR_USED; + // Disable sync stamp auto clear to avoid impacting codec timer capture + codec->REG_054 &= ~CODEC_STAMP_CLR_USED; #else - // Enable sync stamp auto clear - codec->REG_054 |= CODEC_STAMP_CLR_USED; + // Enable sync stamp auto clear + codec->REG_054 |= CODEC_STAMP_CLR_USED; #endif - } + } #ifdef CODEC_MIN_PHASE - if (min_phase_cfg) { - hal_codec_min_phase_init(); - } + if (min_phase_cfg) { + hal_codec_min_phase_init(); + } #endif - return 0; + return 0; } -int hal_codec_close(enum HAL_CODEC_ID_T id) -{ +int hal_codec_close(enum HAL_CODEC_ID_T id) { #ifdef CODEC_MIN_PHASE - if (min_phase_cfg) { - hal_codec_min_phase_term(); - } + if (min_phase_cfg) { + hal_codec_min_phase_term(); + } #endif - codec->REG_054 &= ~CODEC_FAULT_MUTE_DAC_ENABLE; + codec->REG_054 &= ~CODEC_FAULT_MUTE_DAC_ENABLE; - codec->REG_000 &= ~CODEC_CODEC_IF_EN; - codec->REG_064 &= ~(CODEC_SOFT_RSTN_32K | CODEC_SOFT_RSTN_IIR | CODEC_SOFT_RSTN_RS | - CODEC_SOFT_RSTN_DAC | CODEC_SOFT_RSTN_ADC_MASK | CODEC_SOFT_RSTN_ADC_ANA_MASK); - codec->REG_060 &= ~(CODEC_EN_CLK_ADC_MASK | CODEC_EN_CLK_ADC_ANA_MASK); + codec->REG_000 &= ~CODEC_CODEC_IF_EN; + codec->REG_064 &= ~(CODEC_SOFT_RSTN_32K | CODEC_SOFT_RSTN_IIR | + CODEC_SOFT_RSTN_RS | CODEC_SOFT_RSTN_DAC | + CODEC_SOFT_RSTN_ADC_MASK | CODEC_SOFT_RSTN_ADC_ANA_MASK); + codec->REG_060 &= ~(CODEC_EN_CLK_ADC_MASK | CODEC_EN_CLK_ADC_ANA_MASK); - codec_opened = false; + codec_opened = false; #ifdef CODEC_POWER_DOWN - hal_cmu_codec_reset_set(); - hal_cmu_codec_clock_disable(); - hal_psc_codec_disable(); + hal_cmu_codec_reset_set(); + hal_cmu_codec_clock_disable(); + hal_psc_codec_disable(); #else - // NEVER reset or power down CODEC registers, for the CODEC driver expects that last configurations - // still exist in the next stream setup - hal_cmu_codec_clock_disable(); + // NEVER reset or power down CODEC registers, for the CODEC driver expects + // that last configurations still exist in the next stream setup + hal_cmu_codec_clock_disable(); #endif - analog_aud_pll_close(ANA_AUD_PLL_USER_CODEC); + analog_aud_pll_close(ANA_AUD_PLL_USER_CODEC); - return 0; + return 0; } -void hal_codec_crash_mute(void) -{ - if (codec_opened) { - codec->REG_000 &= ~CODEC_CODEC_IF_EN; - } +void hal_codec_crash_mute(void) { + if (codec_opened) { + codec->REG_000 &= ~CODEC_CODEC_IF_EN; + } } #ifdef DAC_DRE_ENABLE -static void hal_codec_dac_dre_enable(void) -{ - codec->REG_0C0 = (codec->REG_0C0 & ~(CODEC_CODEC_DRE_THD_DB_OFFSET_SIGN_CH0 | CODEC_CODEC_DRE_DELAY_CH0_MASK | - CODEC_CODEC_DRE_INI_ANA_GAIN_CH0_MASK | CODEC_CODEC_DRE_THD_DB_OFFSET_CH0_MASK | CODEC_CODEC_DRE_STEP_MODE_CH0_MASK)) | - CODEC_CODEC_DRE_DELAY_CH0(dac_dre_cfg.dre_delay) | - CODEC_CODEC_DRE_INI_ANA_GAIN_CH0(0xF) | CODEC_CODEC_DRE_THD_DB_OFFSET_CH0(dac_dre_cfg.thd_db_offset) | - CODEC_CODEC_DRE_THD_DB_OFFSET_CH0(dac_dre_cfg.step_mode) | CODEC_CODEC_DRE_ENABLE_CH0; - codec->REG_0C4 = (codec->REG_0C4 & ~(CODEC_CODEC_DRE_WINDOW_CH0_MASK | CODEC_CODEC_DRE_AMP_HIGH_CH0_MASK)) | - CODEC_CODEC_DRE_WINDOW_CH0(dac_dre_cfg.dre_win) | CODEC_CODEC_DRE_AMP_HIGH_CH0(dac_dre_cfg.amp_high); +static void hal_codec_dac_dre_enable(void) { + codec->REG_0C0 = + (codec->REG_0C0 & ~(CODEC_CODEC_DRE_THD_DB_OFFSET_SIGN_CH0 | + CODEC_CODEC_DRE_DELAY_CH0_MASK | + CODEC_CODEC_DRE_INI_ANA_GAIN_CH0_MASK | + CODEC_CODEC_DRE_THD_DB_OFFSET_CH0_MASK | + CODEC_CODEC_DRE_STEP_MODE_CH0_MASK)) | + CODEC_CODEC_DRE_DELAY_CH0(dac_dre_cfg.dre_delay) | + CODEC_CODEC_DRE_INI_ANA_GAIN_CH0(0xF) | + CODEC_CODEC_DRE_THD_DB_OFFSET_CH0(dac_dre_cfg.thd_db_offset) | + CODEC_CODEC_DRE_THD_DB_OFFSET_CH0(dac_dre_cfg.step_mode) | + CODEC_CODEC_DRE_ENABLE_CH0; + codec->REG_0C4 = (codec->REG_0C4 & ~(CODEC_CODEC_DRE_WINDOW_CH0_MASK | + CODEC_CODEC_DRE_AMP_HIGH_CH0_MASK)) | + CODEC_CODEC_DRE_WINDOW_CH0(dac_dre_cfg.dre_win) | + CODEC_CODEC_DRE_AMP_HIGH_CH0(dac_dre_cfg.amp_high); - codec->REG_0C8 = (codec->REG_0C8 & ~(CODEC_CODEC_DRE_THD_DB_OFFSET_SIGN_CH1 | CODEC_CODEC_DRE_DELAY_CH1_MASK | - CODEC_CODEC_DRE_INI_ANA_GAIN_CH1_MASK | CODEC_CODEC_DRE_THD_DB_OFFSET_CH1_MASK | CODEC_CODEC_DRE_STEP_MODE_CH1_MASK)) | - CODEC_CODEC_DRE_DELAY_CH1(dac_dre_cfg.dre_delay) | - CODEC_CODEC_DRE_INI_ANA_GAIN_CH1(0xF) | CODEC_CODEC_DRE_THD_DB_OFFSET_CH1(dac_dre_cfg.thd_db_offset) | - CODEC_CODEC_DRE_THD_DB_OFFSET_CH1(dac_dre_cfg.step_mode) | CODEC_CODEC_DRE_ENABLE_CH1; - codec->REG_0CC = (codec->REG_0CC & ~(CODEC_CODEC_DRE_WINDOW_CH1_MASK | CODEC_CODEC_DRE_AMP_HIGH_CH1_MASK)) | - CODEC_CODEC_DRE_WINDOW_CH1(dac_dre_cfg.dre_win) | CODEC_CODEC_DRE_AMP_HIGH_CH1(dac_dre_cfg.amp_high); + codec->REG_0C8 = + (codec->REG_0C8 & ~(CODEC_CODEC_DRE_THD_DB_OFFSET_SIGN_CH1 | + CODEC_CODEC_DRE_DELAY_CH1_MASK | + CODEC_CODEC_DRE_INI_ANA_GAIN_CH1_MASK | + CODEC_CODEC_DRE_THD_DB_OFFSET_CH1_MASK | + CODEC_CODEC_DRE_STEP_MODE_CH1_MASK)) | + CODEC_CODEC_DRE_DELAY_CH1(dac_dre_cfg.dre_delay) | + CODEC_CODEC_DRE_INI_ANA_GAIN_CH1(0xF) | + CODEC_CODEC_DRE_THD_DB_OFFSET_CH1(dac_dre_cfg.thd_db_offset) | + CODEC_CODEC_DRE_THD_DB_OFFSET_CH1(dac_dre_cfg.step_mode) | + CODEC_CODEC_DRE_ENABLE_CH1; + codec->REG_0CC = (codec->REG_0CC & ~(CODEC_CODEC_DRE_WINDOW_CH1_MASK | + CODEC_CODEC_DRE_AMP_HIGH_CH1_MASK)) | + CODEC_CODEC_DRE_WINDOW_CH1(dac_dre_cfg.dre_win) | + CODEC_CODEC_DRE_AMP_HIGH_CH1(dac_dre_cfg.amp_high); } -static void hal_codec_dac_dre_disable(void) -{ - codec->REG_0C0 &= ~CODEC_CODEC_DRE_ENABLE_CH0; - codec->REG_0C8 &= ~CODEC_CODEC_DRE_ENABLE_CH1; +static void hal_codec_dac_dre_disable(void) { + codec->REG_0C0 &= ~CODEC_CODEC_DRE_ENABLE_CH0; + codec->REG_0C8 &= ~CODEC_CODEC_DRE_ENABLE_CH1; } #endif #ifdef PERF_TEST_POWER_KEY -static void hal_codec_update_perf_test_power(void) -{ - int32_t nominal_vol; - uint32_t ini_ana_gain; - int32_t dac_vol; +static void hal_codec_update_perf_test_power(void) { + int32_t nominal_vol; + uint32_t ini_ana_gain; + int32_t dac_vol; - if (!codec_opened) { - return; - } + if (!codec_opened) { + return; + } - dac_vol = 0; - if (cur_perft_power == HAL_CODEC_PERF_TEST_30MW) { - nominal_vol = 0; - ini_ana_gain = 0; - } else if (cur_perft_power == HAL_CODEC_PERF_TEST_10MW) { - nominal_vol = -5; - ini_ana_gain = 6; - } else if (cur_perft_power == HAL_CODEC_PERF_TEST_5MW) { - nominal_vol = -8; - ini_ana_gain = 0xA; - } else if (cur_perft_power == HAL_CODEC_PERF_TEST_M60DB) { - nominal_vol = -60; - ini_ana_gain = 0xF; // about -11 dB - dac_vol = -49; - } else { - return; - } + dac_vol = 0; + if (cur_perft_power == HAL_CODEC_PERF_TEST_30MW) { + nominal_vol = 0; + ini_ana_gain = 0; + } else if (cur_perft_power == HAL_CODEC_PERF_TEST_10MW) { + nominal_vol = -5; + ini_ana_gain = 6; + } else if (cur_perft_power == HAL_CODEC_PERF_TEST_5MW) { + nominal_vol = -8; + ini_ana_gain = 0xA; + } else if (cur_perft_power == HAL_CODEC_PERF_TEST_M60DB) { + nominal_vol = -60; + ini_ana_gain = 0xF; // about -11 dB + dac_vol = -49; + } else { + return; + } - if (codec->REG_0C0 & CODEC_CODEC_DRE_ENABLE_CH0) { - dac_vol = nominal_vol; - } else { - codec->REG_0C0 = SET_BITFIELD(codec->REG_0C0, CODEC_CODEC_DRE_INI_ANA_GAIN_CH0, ini_ana_gain); - codec->REG_0C8 = SET_BITFIELD(codec->REG_0C8, CODEC_CODEC_DRE_INI_ANA_GAIN_CH1, ini_ana_gain); - } + if (codec->REG_0C0 & CODEC_CODEC_DRE_ENABLE_CH0) { + dac_vol = nominal_vol; + } else { + codec->REG_0C0 = SET_BITFIELD( + codec->REG_0C0, CODEC_CODEC_DRE_INI_ANA_GAIN_CH0, ini_ana_gain); + codec->REG_0C8 = SET_BITFIELD( + codec->REG_0C8, CODEC_CODEC_DRE_INI_ANA_GAIN_CH1, ini_ana_gain); + } #ifdef AUDIO_OUTPUT_SW_GAIN - hal_codec_set_sw_gain(dac_vol); + hal_codec_set_sw_gain(dac_vol); #else - hal_codec_set_dig_dac_gain(VALID_DAC_MAP, dac_vol); + hal_codec_set_dig_dac_gain(VALID_DAC_MAP, dac_vol); #endif #if defined(NOISE_GATING) && defined(NOISE_REDUCTION) - if (codec_nr_enabled) { - codec_nr_enabled = false; - hal_codec_set_noise_reduction(true); - } + if (codec_nr_enabled) { + codec_nr_enabled = false; + hal_codec_set_noise_reduction(true); + } #endif } -void hal_codec_dac_gain_m60db_check(enum HAL_CODEC_PERF_TEST_POWER_T type) -{ - cur_perft_power = type; +void hal_codec_dac_gain_m60db_check(enum HAL_CODEC_PERF_TEST_POWER_T type) { + cur_perft_power = type; - if (!codec_opened || (codec->REG_098 & CODEC_CODEC_DAC_EN) == 0) { - return; - } + if (!codec_opened || (codec->REG_098 & CODEC_CODEC_DAC_EN) == 0) { + return; + } - hal_codec_update_perf_test_power(); + hal_codec_update_perf_test_power(); } #endif #if defined(NOISE_GATING) && defined(NOISE_REDUCTION) -void hal_codec_set_noise_reduction(bool enable) -{ - uint32_t ini_ana_gain; +void hal_codec_set_noise_reduction(bool enable) { + uint32_t ini_ana_gain; - if (codec_nr_enabled == enable) { - // Avoid corrupting digdac_gain_offset_nr or using an invalid one - return; - } + if (codec_nr_enabled == enable) { + // Avoid corrupting digdac_gain_offset_nr or using an invalid one + return; + } - codec_nr_enabled = enable; + codec_nr_enabled = enable; - if (!codec_opened) { - return; - } + if (!codec_opened) { + return; + } - // ini_ana_gain=0 --> 0dB - // ini_ana_gain=0xF --> -11dB - if (enable) { - ini_ana_gain = GET_BITFIELD(codec->REG_0C0, CODEC_CODEC_DRE_INI_ANA_GAIN_CH0); - digdac_gain_offset_nr = ((0xF - ini_ana_gain) * 11 + 0xF / 2) / 0xF; - ini_ana_gain = 0xF; - } else { - ini_ana_gain = 0xF - (digdac_gain_offset_nr * 0xF + 11 / 2) / 11; - digdac_gain_offset_nr = 0; - } + // ini_ana_gain=0 --> 0dB + // ini_ana_gain=0xF --> -11dB + if (enable) { + ini_ana_gain = + GET_BITFIELD(codec->REG_0C0, CODEC_CODEC_DRE_INI_ANA_GAIN_CH0); + digdac_gain_offset_nr = ((0xF - ini_ana_gain) * 11 + 0xF / 2) / 0xF; + ini_ana_gain = 0xF; + } else { + ini_ana_gain = 0xF - (digdac_gain_offset_nr * 0xF + 11 / 2) / 11; + digdac_gain_offset_nr = 0; + } - codec->REG_0C0 = SET_BITFIELD(codec->REG_0C0, CODEC_CODEC_DRE_INI_ANA_GAIN_CH0, ini_ana_gain); - codec->REG_0C8 = SET_BITFIELD(codec->REG_0C8, CODEC_CODEC_DRE_INI_ANA_GAIN_CH1, ini_ana_gain); + codec->REG_0C0 = SET_BITFIELD(codec->REG_0C0, + CODEC_CODEC_DRE_INI_ANA_GAIN_CH0, ini_ana_gain); + codec->REG_0C8 = SET_BITFIELD(codec->REG_0C8, + CODEC_CODEC_DRE_INI_ANA_GAIN_CH1, ini_ana_gain); #ifdef AUDIO_OUTPUT_SW_GAIN - hal_codec_set_sw_gain(swdac_gain); + hal_codec_set_sw_gain(swdac_gain); #else - hal_codec_restore_dig_dac_gain(); + hal_codec_restore_dig_dac_gain(); #endif } #endif -void hal_codec_stop_playback_stream(enum HAL_CODEC_ID_T id) -{ -#if (defined(AUDIO_OUTPUT_DC_CALIB_ANA) || defined(AUDIO_OUTPUT_DC_CALIB)) && (!(defined(__TWS__) || defined(IBRT)) || defined(ANC_APP)) - // Disable PA - analog_aud_codec_speaker_enable(false); +void hal_codec_stop_playback_stream(enum HAL_CODEC_ID_T id) { +#if (defined(AUDIO_OUTPUT_DC_CALIB_ANA) || defined(AUDIO_OUTPUT_DC_CALIB)) && \ + (!(defined(__TWS__) || defined(IBRT)) || defined(ANC_APP)) + // Disable PA + analog_aud_codec_speaker_enable(false); #endif - codec->REG_098 &= ~(CODEC_CODEC_DAC_EN | CODEC_CODEC_DAC_EN_CH0 | CODEC_CODEC_DAC_EN_CH1); + codec->REG_098 &= + ~(CODEC_CODEC_DAC_EN | CODEC_CODEC_DAC_EN_CH0 | CODEC_CODEC_DAC_EN_CH1); #ifdef CODEC_TIMER - // Reset codec timer - codec->REG_054 &= ~CODEC_EVENT_FOR_CAPTURE; + // Reset codec timer + codec->REG_054 &= ~CODEC_EVENT_FOR_CAPTURE; #endif #ifdef DAC_DRE_ENABLE - hal_codec_dac_dre_disable(); + hal_codec_dac_dre_disable(); #endif #if defined(DAC_CLASSG_ENABLE) - hal_codec_classg_enable(false); + hal_codec_classg_enable(false); #endif #ifndef NO_DAC_RESET - // Reset DAC - // Avoid DAC outputing noise after it is disabled - codec->REG_064 &= ~CODEC_SOFT_RSTN_DAC; - codec->REG_064 |= CODEC_SOFT_RSTN_DAC; + // Reset DAC + // Avoid DAC outputing noise after it is disabled + codec->REG_064 &= ~CODEC_SOFT_RSTN_DAC; + codec->REG_064 |= CODEC_SOFT_RSTN_DAC; #endif - codec->REG_060 &= ~CODEC_EN_CLK_DAC; + codec->REG_060 &= ~CODEC_EN_CLK_DAC; } -void hal_codec_start_playback_stream(enum HAL_CODEC_ID_T id) -{ - codec->REG_060 |= CODEC_EN_CLK_DAC; +void hal_codec_start_playback_stream(enum HAL_CODEC_ID_T id) { + codec->REG_060 |= CODEC_EN_CLK_DAC; #ifndef NO_DAC_RESET - // Reset DAC - codec->REG_064 &= ~CODEC_SOFT_RSTN_DAC; - codec->REG_064 |= CODEC_SOFT_RSTN_DAC; + // Reset DAC + codec->REG_064 &= ~CODEC_SOFT_RSTN_DAC; + codec->REG_064 |= CODEC_SOFT_RSTN_DAC; #endif #ifdef DAC_DRE_ENABLE - if ( - //(codec->REG_044 & CODEC_MODE_16BIT_DAC) == 0 && + if ( + //(codec->REG_044 & CODEC_MODE_16BIT_DAC) == 0 && #ifdef ANC_APP - anc_adc_ch_map == 0 && + anc_adc_ch_map == 0 && #endif - 1 - ) - { - hal_codec_dac_dre_enable(); - } + 1) { + hal_codec_dac_dre_enable(); + } #endif #ifdef PERF_TEST_POWER_KEY - hal_codec_update_perf_test_power(); + hal_codec_update_perf_test_power(); #endif #if defined(DAC_CLASSG_ENABLE) - hal_codec_classg_enable(true); + hal_codec_classg_enable(true); #endif #ifdef CODEC_TIMER - // Enable codec timer and record time by bt event instead of gpio event - codec->REG_054 = (codec->REG_054 & ~CODEC_EVENT_SEL) | CODEC_EVENT_FOR_CAPTURE; + // Enable codec timer and record time by bt event instead of gpio event + codec->REG_054 = + (codec->REG_054 & ~CODEC_EVENT_SEL) | CODEC_EVENT_FOR_CAPTURE; #endif - if (codec_dac_ch_map & AUD_CHANNEL_MAP_CH0) { - codec->REG_098 |= CODEC_CODEC_DAC_EN_CH0; - } else { - codec->REG_098 &= ~CODEC_CODEC_DAC_EN_CH0; - } - if (codec_dac_ch_map & AUD_CHANNEL_MAP_CH1) { - codec->REG_098 |= CODEC_CODEC_DAC_EN_CH1; - } else { - codec->REG_098 &= ~CODEC_CODEC_DAC_EN_CH1; - } + if (codec_dac_ch_map & AUD_CHANNEL_MAP_CH0) { + codec->REG_098 |= CODEC_CODEC_DAC_EN_CH0; + } else { + codec->REG_098 &= ~CODEC_CODEC_DAC_EN_CH0; + } + if (codec_dac_ch_map & AUD_CHANNEL_MAP_CH1) { + codec->REG_098 |= CODEC_CODEC_DAC_EN_CH1; + } else { + codec->REG_098 &= ~CODEC_CODEC_DAC_EN_CH1; + } -#if (defined(AUDIO_OUTPUT_DC_CALIB_ANA) || defined(AUDIO_OUTPUT_DC_CALIB)) && (!(defined(__TWS__) || defined(IBRT)) || defined(ANC_APP)) +#if (defined(AUDIO_OUTPUT_DC_CALIB_ANA) || defined(AUDIO_OUTPUT_DC_CALIB)) && \ + (!(defined(__TWS__) || defined(IBRT)) || defined(ANC_APP)) #if 0 uint32_t cfg_en; uint32_t anc_ff_gain, anc_fb_gain; @@ -1036,12 +1165,13 @@ void hal_codec_start_playback_stream(enum HAL_CODEC_ID_T id) #endif #endif - codec->REG_098 |= CODEC_CODEC_DAC_EN; + codec->REG_098 |= CODEC_CODEC_DAC_EN; -#if (defined(AUDIO_OUTPUT_DC_CALIB_ANA) || defined(AUDIO_OUTPUT_DC_CALIB)) && (!(defined(__TWS__) || defined(IBRT)) || defined(ANC_APP)) +#if (defined(AUDIO_OUTPUT_DC_CALIB_ANA) || defined(AUDIO_OUTPUT_DC_CALIB)) && \ + (!(defined(__TWS__) || defined(IBRT)) || defined(ANC_APP)) #ifdef AUDIO_OUTPUT_DC_CALIB - // At least delay 4ms for 8K-sample-rate mute data to arrive at DAC PA - osDelay(5); + // At least delay 4ms for 8K-sample-rate mute data to arrive at DAC PA + osDelay(5); #endif #if 0 @@ -1056,18 +1186,18 @@ void hal_codec_start_playback_stream(enum HAL_CODEC_ID_T id) } #endif - // Enable PA - analog_aud_codec_speaker_enable(true); + // Enable PA + analog_aud_codec_speaker_enable(true); #ifdef AUDIO_ANC_FB_MC - if (mc_enabled) { - uint32_t lock; - lock = int_lock(); - // MC FIFO and DAC FIFO must be started at the same time - codec->REG_04C |= CODEC_MC_ENABLE; - codec->REG_000 |= CODEC_DAC_ENABLE; - int_unlock(lock); - } + if (mc_enabled) { + uint32_t lock; + lock = int_lock(); + // MC FIFO and DAC FIFO must be started at the same time + codec->REG_04C |= CODEC_MC_ENABLE; + codec->REG_000 |= CODEC_DAC_ENABLE; + int_unlock(lock); + } #endif #endif } @@ -1075,656 +1205,672 @@ void hal_codec_start_playback_stream(enum HAL_CODEC_ID_T id) #ifdef AF_ADC_I2S_SYNC static bool _hal_codec_capture_enable_delay = false; -void hal_codec_capture_enable_delay(void) -{ - _hal_codec_capture_enable_delay = true; +void hal_codec_capture_enable_delay(void) { + _hal_codec_capture_enable_delay = true; } -void hal_codec_capture_enable(void) -{ - codec->REG_080 |= CODEC_CODEC_ADC_EN; -} +void hal_codec_capture_enable(void) { codec->REG_080 |= CODEC_CODEC_ADC_EN; } #endif -int hal_codec_start_stream(enum HAL_CODEC_ID_T id, enum AUD_STREAM_T stream) -{ - if (stream == AUD_STREAM_PLAYBACK) { - // Reset and start DAC - hal_codec_start_playback_stream(id); - } else { +int hal_codec_start_stream(enum HAL_CODEC_ID_T id, enum AUD_STREAM_T stream) { + if (stream == AUD_STREAM_PLAYBACK) { + // Reset and start DAC + hal_codec_start_playback_stream(id); + } else { #if defined(AUDIO_ANC_FB_MC) || defined(CODEC_DSD) - adc_en_map |= (1 << CODEC_ADC_EN_REQ_STREAM); - if (adc_en_map == (1 << CODEC_ADC_EN_REQ_STREAM)) + adc_en_map |= (1 << CODEC_ADC_EN_REQ_STREAM); + if (adc_en_map == (1 << CODEC_ADC_EN_REQ_STREAM)) #endif - { - // Reset ADC ANA - codec->REG_064 &= ~CODEC_SOFT_RSTN_ADC_ANA_MASK; - codec->REG_064 |= CODEC_SOFT_RSTN_ADC_ANA_MASK; + { + // Reset ADC ANA + codec->REG_064 &= ~CODEC_SOFT_RSTN_ADC_ANA_MASK; + codec->REG_064 |= CODEC_SOFT_RSTN_ADC_ANA_MASK; #ifdef AF_ADC_I2S_SYNC - if (_hal_codec_capture_enable_delay) - { - _hal_codec_capture_enable_delay = false; - } - else - { - hal_codec_capture_enable(); - } + if (_hal_codec_capture_enable_delay) { + _hal_codec_capture_enable_delay = false; + } else { + hal_codec_capture_enable(); + } #else - codec->REG_080 |= CODEC_CODEC_ADC_EN; + codec->REG_080 |= CODEC_CODEC_ADC_EN; #endif - } } + } - return 0; + return 0; } -int hal_codec_stop_stream(enum HAL_CODEC_ID_T id, enum AUD_STREAM_T stream) -{ - if (stream == AUD_STREAM_PLAYBACK) { - // Stop and reset DAC - hal_codec_stop_playback_stream(id); - } else { +int hal_codec_stop_stream(enum HAL_CODEC_ID_T id, enum AUD_STREAM_T stream) { + if (stream == AUD_STREAM_PLAYBACK) { + // Stop and reset DAC + hal_codec_stop_playback_stream(id); + } else { #if defined(AUDIO_ANC_FB_MC) || defined(CODEC_DSD) - adc_en_map &= ~(1 << CODEC_ADC_EN_REQ_STREAM); - if (adc_en_map == 0) + adc_en_map &= ~(1 << CODEC_ADC_EN_REQ_STREAM); + if (adc_en_map == 0) #endif - { - codec->REG_080 &= ~CODEC_CODEC_ADC_EN; + { + codec->REG_080 &= ~CODEC_CODEC_ADC_EN; #ifdef AF_ADC_I2S_SYNC - _hal_codec_capture_enable_delay = false; + _hal_codec_capture_enable_delay = false; #endif - } } + } - return 0; + return 0; } #ifdef CODEC_DSD -void hal_codec_dsd_enable(void) -{ - dsd_enabled = true; -} +void hal_codec_dsd_enable(void) { dsd_enabled = true; } -void hal_codec_dsd_disable(void) -{ - dsd_enabled = false; -} +void hal_codec_dsd_disable(void) { dsd_enabled = false; } -static void hal_codec_dsd_cfg_start(void) -{ +static void hal_codec_dsd_cfg_start(void) { #if !(defined(FIXED_CODEC_ADC_VOL) && defined(SINGLE_CODEC_ADC_VOL)) - uint32_t vol; - const CODEC_ADC_VOL_T *adc_gain_db; + uint32_t vol; + const CODEC_ADC_VOL_T *adc_gain_db; - vol = hal_codec_get_mic_chan_volume_level(AUD_CHANNEL_MAP_DIGMIC_CH2); - adc_gain_db = hal_codec_get_adc_volume(vol); - if (adc_gain_db) { - hal_codec_set_dig_adc_gain((AUD_CHANNEL_MAP_CH2 | AUD_CHANNEL_MAP_CH3), *adc_gain_db); - } + vol = hal_codec_get_mic_chan_volume_level(AUD_CHANNEL_MAP_DIGMIC_CH2); + adc_gain_db = hal_codec_get_adc_volume(vol); + if (adc_gain_db) { + hal_codec_set_dig_adc_gain((AUD_CHANNEL_MAP_CH2 | AUD_CHANNEL_MAP_CH3), + *adc_gain_db); + } #endif - codec->REG_004 |= CODEC_DSD_RX_FIFO_FLUSH | CODEC_DSD_TX_FIFO_FLUSH; - hal_codec_reg_update_delay(); - codec->REG_004 &= ~(CODEC_DSD_RX_FIFO_FLUSH | CODEC_DSD_TX_FIFO_FLUSH); + codec->REG_004 |= CODEC_DSD_RX_FIFO_FLUSH | CODEC_DSD_TX_FIFO_FLUSH; + hal_codec_reg_update_delay(); + codec->REG_004 &= ~(CODEC_DSD_RX_FIFO_FLUSH | CODEC_DSD_TX_FIFO_FLUSH); - codec->REG_0B8 = CODEC_CODEC_DSD_ENABLE_L | CODEC_CODEC_DSD_ENABLE_R | CODEC_CODEC_DSD_SAMPLE_RATE(dsd_rate_idx); - codec->REG_048 = CODEC_DSD_IF_EN | CODEC_DSD_ENABLE | CODEC_DSD_DUAL_CHANNEL | CODEC_MODE_24BIT_DSD | - /* CODEC_DMA_CTRL_RX_DSD | */ CODEC_DMA_CTRL_TX_DSD | CODEC_DSD_IN_16BIT; + codec->REG_0B8 = CODEC_CODEC_DSD_ENABLE_L | CODEC_CODEC_DSD_ENABLE_R | + CODEC_CODEC_DSD_SAMPLE_RATE(dsd_rate_idx); + codec->REG_048 = CODEC_DSD_IF_EN | CODEC_DSD_ENABLE | CODEC_DSD_DUAL_CHANNEL | + CODEC_MODE_24BIT_DSD | + /* CODEC_DMA_CTRL_RX_DSD | */ CODEC_DMA_CTRL_TX_DSD | + CODEC_DSD_IN_16BIT; - codec->REG_080 = (codec->REG_080 & ~(CODEC_CODEC_LOOP_SEL_L_MASK | CODEC_CODEC_LOOP_SEL_R_MASK)) | - CODEC_CODEC_ADC_LOOP | CODEC_CODEC_LOOP_SEL_L(2) | CODEC_CODEC_LOOP_SEL_R(3); + codec->REG_080 = (codec->REG_080 & ~(CODEC_CODEC_LOOP_SEL_L_MASK | + CODEC_CODEC_LOOP_SEL_R_MASK)) | + CODEC_CODEC_ADC_LOOP | CODEC_CODEC_LOOP_SEL_L(2) | + CODEC_CODEC_LOOP_SEL_R(3); - codec->REG_0A8 = SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH2, 2); - codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH2; - codec->REG_0A8 = SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH3, 3); - codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH3; + codec->REG_0A8 = SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH2, 2); + codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH2; + codec->REG_0A8 = SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH3, 3); + codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH3; - codec->REG_064 &= ~(CODEC_SOFT_RSTN_ADC(1 << 2) | CODEC_SOFT_RSTN_ADC(1 << 3)); - codec->REG_064 |= CODEC_SOFT_RSTN_ADC(1 << 2) | CODEC_SOFT_RSTN_ADC(1 << 3); - codec->REG_080 |= CODEC_CODEC_ADC_EN_CH2 | CODEC_CODEC_ADC_EN_CH3; + codec->REG_064 &= + ~(CODEC_SOFT_RSTN_ADC(1 << 2) | CODEC_SOFT_RSTN_ADC(1 << 3)); + codec->REG_064 |= CODEC_SOFT_RSTN_ADC(1 << 2) | CODEC_SOFT_RSTN_ADC(1 << 3); + codec->REG_080 |= CODEC_CODEC_ADC_EN_CH2 | CODEC_CODEC_ADC_EN_CH3; - if (adc_en_map == 0) { - // Reset ADC free running clock and ADC ANA - codec->REG_064 &= ~(RSTN_ADC_FREE_RUNNING_CLK | CODEC_SOFT_RSTN_ADC_ANA_MASK); - codec->REG_064 |= (RSTN_ADC_FREE_RUNNING_CLK | CODEC_SOFT_RSTN_ADC_ANA_MASK); - codec->REG_080 |= CODEC_CODEC_ADC_EN; - } - adc_en_map |= (1 << CODEC_ADC_EN_REQ_DSD); + if (adc_en_map == 0) { + // Reset ADC free running clock and ADC ANA + codec->REG_064 &= + ~(RSTN_ADC_FREE_RUNNING_CLK | CODEC_SOFT_RSTN_ADC_ANA_MASK); + codec->REG_064 |= + (RSTN_ADC_FREE_RUNNING_CLK | CODEC_SOFT_RSTN_ADC_ANA_MASK); + codec->REG_080 |= CODEC_CODEC_ADC_EN; + } + adc_en_map |= (1 << CODEC_ADC_EN_REQ_DSD); } -static void hal_codec_dsd_cfg_stop(void) -{ - adc_en_map &= ~(1 << CODEC_ADC_EN_REQ_DSD); - if (adc_en_map == 0) { - codec->REG_080 &= ~CODEC_CODEC_ADC_EN; - } +static void hal_codec_dsd_cfg_stop(void) { + adc_en_map &= ~(1 << CODEC_ADC_EN_REQ_DSD); + if (adc_en_map == 0) { + codec->REG_080 &= ~CODEC_CODEC_ADC_EN; + } - codec->REG_080 &= ~(CODEC_CODEC_ADC_EN_CH2 | CODEC_CODEC_ADC_EN_CH3); - codec->REG_0A4 &= ~(CODEC_CODEC_PDM_ADC_SEL_CH2 | CODEC_CODEC_PDM_ADC_SEL_CH3); - codec->REG_048 = 0; - codec->REG_0B8 = 0; + codec->REG_080 &= ~(CODEC_CODEC_ADC_EN_CH2 | CODEC_CODEC_ADC_EN_CH3); + codec->REG_0A4 &= + ~(CODEC_CODEC_PDM_ADC_SEL_CH2 | CODEC_CODEC_PDM_ADC_SEL_CH3); + codec->REG_048 = 0; + codec->REG_0B8 = 0; - codec->REG_080 &= ~CODEC_CODEC_ADC_LOOP; + codec->REG_080 &= ~CODEC_CODEC_ADC_LOOP; } #endif #ifdef __AUDIO_RESAMPLE__ -void hal_codec_resample_clock_enable(enum AUD_STREAM_T stream) -{ - uint32_t clk; - bool set = false; +void hal_codec_resample_clock_enable(enum AUD_STREAM_T stream) { + uint32_t clk; + bool set = false; - // 192K-24BIT requires 52M clock, and 384K-24BIT requires 104M clock - if (stream == AUD_STREAM_PLAYBACK) { - clk = codec_dac_sample_rate[resample_rate_idx[AUD_STREAM_PLAYBACK]].sample_rate * RS_CLOCK_FACTOR; - } else { - clk = codec_adc_sample_rate[resample_rate_idx[AUD_STREAM_CAPTURE]].sample_rate * RS_CLOCK_FACTOR; + // 192K-24BIT requires 52M clock, and 384K-24BIT requires 104M clock + if (stream == AUD_STREAM_PLAYBACK) { + clk = codec_dac_sample_rate[resample_rate_idx[AUD_STREAM_PLAYBACK]] + .sample_rate * + RS_CLOCK_FACTOR; + } else { + clk = codec_adc_sample_rate[resample_rate_idx[AUD_STREAM_CAPTURE]] + .sample_rate * + RS_CLOCK_FACTOR; + } + + if (rs_clk_map == 0) { + set = true; + } else { + if (resample_clk_freq < clk) { + set = true; } + } - if (rs_clk_map == 0) { - set = true; - } else { - if (resample_clk_freq < clk) { - set = true; - } - } + if (set) { + resample_clk_freq = clk; + hal_cmu_codec_rs_enable(clk); + } - if (set) { - resample_clk_freq = clk; - hal_cmu_codec_rs_enable(clk); - } - - rs_clk_map |= (1 << stream); + rs_clk_map |= (1 << stream); } -void hal_codec_resample_clock_disable(enum AUD_STREAM_T stream) -{ - if (rs_clk_map == 0) { - return; - } - rs_clk_map &= ~(1 << stream); - if (rs_clk_map == 0) { - hal_cmu_codec_rs_disable(); - } +void hal_codec_resample_clock_disable(enum AUD_STREAM_T stream) { + if (rs_clk_map == 0) { + return; + } + rs_clk_map &= ~(1 << stream); + if (rs_clk_map == 0) { + hal_cmu_codec_rs_disable(); + } } #endif -static void hal_codec_enable_dig_mic(enum AUD_CHANNEL_MAP_T mic_map) -{ - uint32_t phase = 0; - uint32_t line_map = 0; +static void hal_codec_enable_dig_mic(enum AUD_CHANNEL_MAP_T mic_map) { + uint32_t phase = 0; + uint32_t line_map = 0; - phase = codec->REG_0A8; - for (int i = 0; i < MAX_DIG_MIC_CH_NUM; i++) { - if (mic_map & (AUD_CHANNEL_MAP_DIGMIC_CH0 << i)) { - line_map |= (1 << (i / 2)); - } - phase = (phase & ~(CODEC_CODEC_PDM_CAP_PHASE_CH0_MASK << (i * 2))) | + phase = codec->REG_0A8; + for (int i = 0; i < MAX_DIG_MIC_CH_NUM; i++) { + if (mic_map & (AUD_CHANNEL_MAP_DIGMIC_CH0 << i)) { + line_map |= (1 << (i / 2)); + } + phase = (phase & ~(CODEC_CODEC_PDM_CAP_PHASE_CH0_MASK << (i * 2))) | (CODEC_CODEC_PDM_CAP_PHASE_CH0(codec_digmic_phase) << (i * 2)); - } - codec->REG_0A8 = phase; - codec->REG_0A4 |= CODEC_CODEC_PDM_ENABLE; - hal_iomux_set_dig_mic(line_map); + } + codec->REG_0A8 = phase; + codec->REG_0A4 |= CODEC_CODEC_PDM_ENABLE; + hal_iomux_set_dig_mic(line_map); } -static void hal_codec_disable_dig_mic(void) -{ - codec->REG_0A4 &= ~CODEC_CODEC_PDM_ENABLE; +static void hal_codec_disable_dig_mic(void) { + codec->REG_0A4 &= ~CODEC_CODEC_PDM_ENABLE; } -static void hal_codec_set_ec_down_sel(bool dac_rate_valid) -{ - uint8_t dac_factor; - uint8_t adc_factor; - uint8_t d, a; - uint8_t val; - uint8_t sel = 0; - bool err = false; +static void hal_codec_set_ec_down_sel(bool dac_rate_valid) { + uint8_t dac_factor; + uint8_t adc_factor; + uint8_t d, a; + uint8_t val; + uint8_t sel = 0; + bool err = false; - if (dac_rate_valid) { - d = codec_rate_idx[AUD_STREAM_PLAYBACK]; - if (codec_dac_sample_rate[d].sample_rate < AUD_SAMPRATE_44100) { - dac_factor = (6 / codec_dac_sample_rate[d].dac_up) * (codec_dac_sample_rate[d].bypass_cnt + 1); - } else { - // SINC to 48K/44.1K - dac_factor = (6 / 1) * (0 + 1); - } - a = codec_rate_idx[AUD_STREAM_CAPTURE]; - adc_factor = (6 / codec_adc_sample_rate[a].adc_down) * (codec_adc_sample_rate[a].bypass_cnt + 1); - - val = dac_factor / adc_factor; - if (val * adc_factor == dac_factor) { - if (val == 3) { - sel = 0; - } else if (val == 6) { - sel = 1; - } else if (val == 1) { - sel = 2; - } else if (val == 2) { - sel = 3; - } else { - err = true; - } - } else { - err = true; - } - - ASSERT(!err, "%s: Invalid EC sample rate: play=%u cap=%u", __FUNCTION__, - codec_dac_sample_rate[d].sample_rate, codec_adc_sample_rate[a].sample_rate); + if (dac_rate_valid) { + d = codec_rate_idx[AUD_STREAM_PLAYBACK]; + if (codec_dac_sample_rate[d].sample_rate < AUD_SAMPRATE_44100) { + dac_factor = (6 / codec_dac_sample_rate[d].dac_up) * + (codec_dac_sample_rate[d].bypass_cnt + 1); } else { + // SINC to 48K/44.1K + dac_factor = (6 / 1) * (0 + 1); + } + a = codec_rate_idx[AUD_STREAM_CAPTURE]; + adc_factor = (6 / codec_adc_sample_rate[a].adc_down) * + (codec_adc_sample_rate[a].bypass_cnt + 1); + + val = dac_factor / adc_factor; + if (val * adc_factor == dac_factor) { + if (val == 3) { sel = 0; + } else if (val == 6) { + sel = 1; + } else if (val == 1) { + sel = 2; + } else if (val == 2) { + sel = 3; + } else { + err = true; + } + } else { + err = true; } - uint32_t ec_mask, ec_val; + ASSERT(!err, "%s: Invalid EC sample rate: play=%u cap=%u", __FUNCTION__, + codec_dac_sample_rate[d].sample_rate, + codec_adc_sample_rate[a].sample_rate); + } else { + sel = 0; + } - ec_mask = 0; - ec_val = 0; - if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH5) { - ec_mask |= CODEC_CODEC_DOWN_SEL_MC_CH0_MASK; - ec_val |= CODEC_CODEC_DOWN_SEL_MC_CH0(sel); - } - if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH6) { - ec_mask |= CODEC_CODEC_DOWN_SEL_MC_CH1_MASK; - ec_val |= CODEC_CODEC_DOWN_SEL_MC_CH1(sel); - } - codec->REG_228 = (codec->REG_228 & ~ec_mask) | ec_val; + uint32_t ec_mask, ec_val; + + ec_mask = 0; + ec_val = 0; + if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH5) { + ec_mask |= CODEC_CODEC_DOWN_SEL_MC_CH0_MASK; + ec_val |= CODEC_CODEC_DOWN_SEL_MC_CH0(sel); + } + if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH6) { + ec_mask |= CODEC_CODEC_DOWN_SEL_MC_CH1_MASK; + ec_val |= CODEC_CODEC_DOWN_SEL_MC_CH1(sel); + } + codec->REG_228 = (codec->REG_228 & ~ec_mask) | ec_val; } -static void hal_codec_ec_enable(void) -{ - uint32_t ec_val; - bool dac_rate_valid; - uint8_t a; +static void hal_codec_ec_enable(void) { + uint32_t ec_val; + bool dac_rate_valid; + uint8_t a; - dac_rate_valid = !!(codec->REG_000 & CODEC_DAC_ENABLE); + dac_rate_valid = !!(codec->REG_000 & CODEC_DAC_ENABLE); - hal_codec_set_ec_down_sel(dac_rate_valid); + hal_codec_set_ec_down_sel(dac_rate_valid); - // If no normal ADC chan, ADC0 must be enabled - if ((codec_adc_ch_map & ~EC_ADC_MAP) == 0) { - a = codec_rate_idx[AUD_STREAM_CAPTURE]; - hal_codec_set_adc_down(AUD_CHANNEL_MAP_CH0, codec_adc_sample_rate[a].adc_down); - hal_codec_set_adc_hbf_bypass_cnt(AUD_CHANNEL_MAP_CH0, codec_adc_sample_rate[a].bypass_cnt); - codec->REG_080 |= CODEC_CODEC_ADC_EN_CH0; - } + // If no normal ADC chan, ADC0 must be enabled + if ((codec_adc_ch_map & ~EC_ADC_MAP) == 0) { + a = codec_rate_idx[AUD_STREAM_CAPTURE]; + hal_codec_set_adc_down(AUD_CHANNEL_MAP_CH0, + codec_adc_sample_rate[a].adc_down); + hal_codec_set_adc_hbf_bypass_cnt(AUD_CHANNEL_MAP_CH0, + codec_adc_sample_rate[a].bypass_cnt); + codec->REG_080 |= CODEC_CODEC_ADC_EN_CH0; + } - ec_val = 0; - if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH5) { - ec_val |= CODEC_CODEC_MC_ENABLE_CH0; + ec_val = 0; + if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH5) { + ec_val |= CODEC_CODEC_MC_ENABLE_CH0; + } + if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH6) { + ec_val |= CODEC_CODEC_MC_ENABLE_CH1; + } + if (codec->REG_0E4 & CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE) { + ec_val |= CODEC_CODEC_RESAMPLE_MC_ENABLE; + if ((codec_adc_ch_map & EC_ADC_MAP) == EC_ADC_MAP) { + ec_val |= CODEC_CODEC_RESAMPLE_MC_DUAL_CH; } - if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH6) { - ec_val |= CODEC_CODEC_MC_ENABLE_CH1; - } - if (codec->REG_0E4 & CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE) { - ec_val |= CODEC_CODEC_RESAMPLE_MC_ENABLE; - if ((codec_adc_ch_map & EC_ADC_MAP) == EC_ADC_MAP) { - ec_val |= CODEC_CODEC_RESAMPLE_MC_DUAL_CH; - } - } - codec->REG_228 |= ec_val; + } + codec->REG_228 |= ec_val; } -static void hal_codec_ec_disable(void) -{ - codec->REG_228 &= ~(CODEC_CODEC_MC_ENABLE_CH0 | CODEC_CODEC_MC_ENABLE_CH1 | +static void hal_codec_ec_disable(void) { + codec->REG_228 &= + ~(CODEC_CODEC_MC_ENABLE_CH0 | CODEC_CODEC_MC_ENABLE_CH1 | CODEC_CODEC_RESAMPLE_MC_ENABLE | CODEC_CODEC_RESAMPLE_MC_DUAL_CH); - if ((codec_adc_ch_map & ~EC_ADC_MAP) == 0 && (anc_adc_ch_map & AUD_CHANNEL_MAP_CH0) == 0) { - codec->REG_080 &= ~CODEC_CODEC_ADC_EN_CH0; - } + if ((codec_adc_ch_map & ~EC_ADC_MAP) == 0 && + (anc_adc_ch_map & AUD_CHANNEL_MAP_CH0) == 0) { + codec->REG_080 &= ~CODEC_CODEC_ADC_EN_CH0; + } } -int hal_codec_start_interface(enum HAL_CODEC_ID_T id, enum AUD_STREAM_T stream, int dma) -{ - uint32_t fifo_flush = 0; +int hal_codec_start_interface(enum HAL_CODEC_ID_T id, enum AUD_STREAM_T stream, + int dma) { + uint32_t fifo_flush = 0; - if (stream == AUD_STREAM_PLAYBACK) { + if (stream == AUD_STREAM_PLAYBACK) { #ifdef CODEC_DSD - if (dsd_enabled) { - hal_codec_dsd_cfg_start(); - } -#endif -#ifdef CODEC_MIN_PHASE - if (min_phase_cfg & (1 << AUD_STREAM_PLAYBACK)) { - if (codec_dac_ch_map & AUD_CHANNEL_MAP_CH0) { - codec->REG_100 |= CODEC_FIR_STREAM_ENABLE_CH0; - codec->REG_098 |= CODEC_CODEC_DAC_L_FIR_UPSAMPLE; - } - if (codec_dac_ch_map & AUD_CHANNEL_MAP_CH1) { - codec->REG_100 |= CODEC_FIR_STREAM_ENABLE_CH1; - codec->REG_098 |= CODEC_CODEC_DAC_R_FIR_UPSAMPLE; - } - } -#endif -#ifdef __AUDIO_RESAMPLE__ - if (codec->REG_0E4 & CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE) { - hal_codec_resample_clock_enable(stream); -#if (defined(__TWS__) || defined(IBRT)) && defined(ANC_APP) - enum HAL_CODEC_SYNC_TYPE_T sync_type; - - sync_type = GET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_DAC_TRIGGER_SEL); - if (sync_type != HAL_CODEC_SYNC_TYPE_NONE) { - codec->REG_0E4 = SET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_DAC_TRIGGER_SEL, HAL_CODEC_SYNC_TYPE_NONE); - codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; - hal_codec_reg_update_delay(); - codec->REG_0F4 = resample_phase_float_to_value(1.0f); - hal_codec_reg_update_delay(); - codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; - hal_codec_reg_update_delay(); - codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; - codec->REG_0E4 = SET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_DAC_TRIGGER_SEL, sync_type); - hal_codec_reg_update_delay(); - codec->REG_0F4 = resample_phase_float_to_value(get_playback_resample_phase()); - codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; - } -#endif - codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_DAC_ENABLE; - } -#endif - if ((codec->REG_000 & CODEC_ADC_ENABLE) && (codec_adc_ch_map & EC_ADC_MAP)) { - hal_codec_set_ec_down_sel(true); - } -#ifdef AUDIO_ANC_FB_MC - fifo_flush |= CODEC_MC_FIFO_FLUSH; -#endif - fifo_flush |= CODEC_TX_FIFO_FLUSH; - codec->REG_004 |= fifo_flush; - hal_codec_reg_update_delay(); - codec->REG_004 &= ~fifo_flush; - if (dma) { - codec->REG_008 = SET_BITFIELD(codec->REG_008, CODEC_CODEC_TX_THRESHOLD, HAL_CODEC_TX_FIFO_TRIGGER_LEVEL); - codec->REG_000 |= CODEC_DMACTRL_TX; - // Delay a little time for DMA to fill the TX FIFO before sending - for (volatile int i = 0; i < 50; i++); - } -#ifdef AUDIO_ANC_FB_MC - if (mc_dual_chan) { - codec->REG_04C |= CODEC_DUAL_CHANNEL_MC; - } else { - codec->REG_04C &= ~CODEC_DUAL_CHANNEL_MC; - } - if (mc_16bit) { - codec->REG_04C |= CODEC_MODE_16BIT_MC; - } else { - codec->REG_04C &= ~CODEC_MODE_16BIT_MC; - } - if (adc_en_map == 0) { - // Reset ADC free running clock and ADC ANA - codec->REG_064 &= ~(RSTN_ADC_FREE_RUNNING_CLK | CODEC_SOFT_RSTN_ADC_ANA_MASK); - codec->REG_064 |= (RSTN_ADC_FREE_RUNNING_CLK | CODEC_SOFT_RSTN_ADC_ANA_MASK); - codec->REG_080 |= CODEC_CODEC_ADC_EN; - } - adc_en_map |= (1 << CODEC_ADC_EN_REQ_MC); - // If codec function has been enabled, start FIFOs directly; - // otherwise, start FIFOs after PA is enabled - if (codec->REG_098 & CODEC_CODEC_DAC_EN) { - uint32_t lock; - lock = int_lock(); - // MC FIFO and DAC FIFO must be started at the same time - codec->REG_04C |= CODEC_MC_ENABLE; - codec->REG_000 |= CODEC_DAC_ENABLE; - int_unlock(lock); - } - mc_enabled = true; -#else - codec->REG_000 |= CODEC_DAC_ENABLE; -#endif - } else { -#ifdef VOICE_DETECTOR_EN - if ((codec_adc_ch_map & AUD_CHANNEL_MAP_CH4) && - (vad_type == AUD_VAD_TYPE_MIX || vad_type == AUD_VAD_TYPE_DIG)) { - // Stop vad buffering - hal_codec_vad_stop(); - } -#endif -#ifdef CODEC_MIN_PHASE - if (min_phase_cfg & (1 << AUD_STREAM_CAPTURE)) { - if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH2) { - codec->REG_100 |= CODEC_FIR_STREAM_ENABLE_CH2; - codec->REG_0D0 |= CODEC_CODEC_ADC_FIR_DS_EN_CH2; - } - if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH3) { - codec->REG_100 |= CODEC_FIR_STREAM_ENABLE_CH3; - codec->REG_0D0 |= CODEC_CODEC_ADC_FIR_DS_EN_CH3; - } - } -#endif -#ifdef __AUDIO_RESAMPLE__ - if (codec->REG_0E4 & CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE) { - hal_codec_resample_clock_enable(stream); -#if (defined(__TWS__) || defined(IBRT)) && defined(ANC_APP) - enum HAL_CODEC_SYNC_TYPE_T sync_type; - - sync_type = GET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_ADC_TRIGGER_SEL); - if (sync_type != HAL_CODEC_SYNC_TYPE_NONE) { - codec->REG_0E4 = SET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_ADC_TRIGGER_SEL, HAL_CODEC_SYNC_TYPE_NONE); - codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; - hal_codec_reg_update_delay(); - codec->REG_0F8 = resample_phase_float_to_value(1.0f); - hal_codec_reg_update_delay(); - codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; - hal_codec_reg_update_delay(); - codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; - codec->REG_0E4 = SET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_ADC_TRIGGER_SEL, sync_type); - hal_codec_reg_update_delay(); - codec->REG_0F8 = resample_phase_float_to_value(get_capture_resample_phase()); - codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; - } -#endif - codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_ADC_ENABLE; - } -#endif - if (codec_mic_ch_map & AUD_CHANNEL_MAP_DIGMIC_ALL) { - hal_codec_enable_dig_mic(codec_mic_ch_map); - } - if (codec_adc_ch_map & EC_ADC_MAP) { - hal_codec_ec_enable(); - } - for (int i = 0; i < MAX_ADC_CH_NUM; i++) { - if (codec_adc_ch_map & (AUD_CHANNEL_MAP_CH0 << i)) { - if (i < NORMAL_ADC_CH_NUM && - (codec->REG_080 & (CODEC_CODEC_ADC_EN_CH0 << i)) == 0) { - // Reset ADC channel - codec->REG_064 &= ~CODEC_SOFT_RSTN_ADC(1 << i); - codec->REG_064 |= CODEC_SOFT_RSTN_ADC(1 << i); - codec->REG_080 |= (CODEC_CODEC_ADC_EN_CH0 << i); - } - codec->REG_000 |= (CODEC_ADC_ENABLE_CH0 << i); - } - } - fifo_flush = CODEC_RX_FIFO_FLUSH_CH0 | CODEC_RX_FIFO_FLUSH_CH1 | CODEC_RX_FIFO_FLUSH_CH2 | - CODEC_RX_FIFO_FLUSH_CH3 | CODEC_RX_FIFO_FLUSH_CH4 | CODEC_RX_FIFO_FLUSH_CH5 | CODEC_RX_FIFO_FLUSH_CH6; - codec->REG_004 |= fifo_flush; - hal_codec_reg_update_delay(); - codec->REG_004 &= ~fifo_flush; - if (dma) { - codec->REG_008 = SET_BITFIELD(codec->REG_008, CODEC_CODEC_RX_THRESHOLD, HAL_CODEC_RX_FIFO_TRIGGER_LEVEL); - codec->REG_000 |= CODEC_DMACTRL_RX; - } - codec->REG_000 |= CODEC_ADC_ENABLE; + if (dsd_enabled) { + hal_codec_dsd_cfg_start(); } - - return 0; -} - -int hal_codec_stop_interface(enum HAL_CODEC_ID_T id, enum AUD_STREAM_T stream) -{ - uint32_t fifo_flush = 0; - - if (stream == AUD_STREAM_PLAYBACK) { - codec->REG_000 &= ~CODEC_DAC_ENABLE; - codec->REG_000 &= ~CODEC_DMACTRL_TX; -#ifdef __AUDIO_RESAMPLE__ - codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_DAC_ENABLE; - hal_codec_resample_clock_disable(stream); #endif #ifdef CODEC_MIN_PHASE - if (min_phase_cfg & (1 << AUD_STREAM_PLAYBACK)) { - if (codec_dac_ch_map & AUD_CHANNEL_MAP_CH0) { - codec->REG_100 &= ~CODEC_FIR_STREAM_ENABLE_CH0; - codec->REG_098 &= ~CODEC_CODEC_DAC_L_FIR_UPSAMPLE; - } - if (codec_dac_ch_map & AUD_CHANNEL_MAP_CH1) { - codec->REG_100 &= ~CODEC_FIR_STREAM_ENABLE_CH1; - codec->REG_098 &= ~CODEC_CODEC_DAC_R_FIR_UPSAMPLE; - } - } -#endif -#ifdef CODEC_DSD - hal_codec_dsd_cfg_stop(); - dsd_enabled = false; -#endif -#ifdef AUDIO_ANC_FB_MC - mc_enabled = false; - codec->REG_04C &= ~CODEC_MC_ENABLE; - adc_en_map &= ~(1 << CODEC_ADC_EN_REQ_MC); - if (adc_en_map == 0) { - codec->REG_080 &= ~CODEC_CODEC_ADC_EN; - } - fifo_flush |= CODEC_MC_FIFO_FLUSH; -#endif - fifo_flush |= CODEC_TX_FIFO_FLUSH; - codec->REG_004 |= fifo_flush; - hal_codec_reg_update_delay(); - codec->REG_004 &= ~fifo_flush; - // Cancel dac sync request - hal_codec_sync_dac_disable(); - hal_codec_sync_dac_resample_rate_disable(); - hal_codec_sync_dac_gain_disable(); -#ifdef NO_DAC_RESET - // Clean up DAC intermediate states - osDelay(dac_delay_ms); -#endif - } else { - codec->REG_000 &= ~(CODEC_ADC_ENABLE | CODEC_ADC_ENABLE_CH0 | CODEC_ADC_ENABLE_CH1 | CODEC_ADC_ENABLE_CH2 | - CODEC_ADC_ENABLE_CH3 | CODEC_ADC_ENABLE_CH4 | CODEC_ADC_ENABLE_CH5 | CODEC_ADC_ENABLE_CH6); - codec->REG_000 &= ~CODEC_DMACTRL_RX; - for (int i = 0; i < MAX_ADC_CH_NUM; i++) { - if (i < NORMAL_ADC_CH_NUM && - (codec_adc_ch_map & (AUD_CHANNEL_MAP_CH0 << i)) && - (anc_adc_ch_map & (AUD_CHANNEL_MAP_CH0 << i)) == 0) { - codec->REG_080 &= ~(CODEC_CODEC_ADC_EN_CH0 << i); - } - } - if (codec_adc_ch_map & EC_ADC_MAP) { - hal_codec_ec_disable(); - } - if ((codec_mic_ch_map & AUD_CHANNEL_MAP_DIGMIC_ALL) && - (anc_mic_ch_map & AUD_CHANNEL_MAP_DIGMIC_ALL) == 0) { - hal_codec_disable_dig_mic(); - } -#ifdef __AUDIO_RESAMPLE__ - codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_ADC_ENABLE; - hal_codec_resample_clock_disable(stream); -#endif -#ifdef CODEC_MIN_PHASE - if (min_phase_cfg & (1 << AUD_STREAM_CAPTURE)) { - if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH2) { - codec->REG_100 &= ~CODEC_FIR_STREAM_ENABLE_CH2; - codec->REG_0D0 &= ~CODEC_CODEC_ADC_FIR_DS_EN_CH2; - } - if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH3) { - codec->REG_100 &= ~CODEC_FIR_STREAM_ENABLE_CH3; - codec->REG_0D0 &= ~CODEC_CODEC_ADC_FIR_DS_EN_CH3; - } - } -#endif - fifo_flush = CODEC_RX_FIFO_FLUSH_CH0 | CODEC_RX_FIFO_FLUSH_CH1 | CODEC_RX_FIFO_FLUSH_CH2 | - CODEC_RX_FIFO_FLUSH_CH3 | CODEC_RX_FIFO_FLUSH_CH4 | CODEC_RX_FIFO_FLUSH_CH5 | CODEC_RX_FIFO_FLUSH_CH6; - codec->REG_004 |= fifo_flush; - hal_codec_reg_update_delay(); - codec->REG_004 &= ~fifo_flush; - // Cancel adc sync request - hal_codec_sync_adc_disable(); - hal_codec_sync_adc_resample_rate_disable(); - hal_codec_sync_adc_gain_disable(); + if (min_phase_cfg & (1 << AUD_STREAM_PLAYBACK)) { + if (codec_dac_ch_map & AUD_CHANNEL_MAP_CH0) { + codec->REG_100 |= CODEC_FIR_STREAM_ENABLE_CH0; + codec->REG_098 |= CODEC_CODEC_DAC_L_FIR_UPSAMPLE; + } + if (codec_dac_ch_map & AUD_CHANNEL_MAP_CH1) { + codec->REG_100 |= CODEC_FIR_STREAM_ENABLE_CH1; + codec->REG_098 |= CODEC_CODEC_DAC_R_FIR_UPSAMPLE; + } } +#endif +#ifdef __AUDIO_RESAMPLE__ + if (codec->REG_0E4 & CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE) { + hal_codec_resample_clock_enable(stream); +#if (defined(__TWS__) || defined(IBRT)) && defined(ANC_APP) + enum HAL_CODEC_SYNC_TYPE_T sync_type; - return 0; -} - -static void hal_codec_set_dac_gain_value(enum AUD_CHANNEL_MAP_T map, uint32_t val) -{ - codec->REG_09C &= ~CODEC_CODEC_DAC_GAIN_UPDATE; + sync_type = + GET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_DAC_TRIGGER_SEL); + if (sync_type != HAL_CODEC_SYNC_TYPE_NONE) { + codec->REG_0E4 = + SET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_DAC_TRIGGER_SEL, + HAL_CODEC_SYNC_TYPE_NONE); + codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; + hal_codec_reg_update_delay(); + codec->REG_0F4 = resample_phase_float_to_value(1.0f); + hal_codec_reg_update_delay(); + codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; + hal_codec_reg_update_delay(); + codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; + codec->REG_0E4 = SET_BITFIELD( + codec->REG_0E4, CODEC_CODEC_RESAMPLE_DAC_TRIGGER_SEL, sync_type); + hal_codec_reg_update_delay(); + codec->REG_0F4 = + resample_phase_float_to_value(get_playback_resample_phase()); + codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; + } +#endif + codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_DAC_ENABLE; + } +#endif + if ((codec->REG_000 & CODEC_ADC_ENABLE) && + (codec_adc_ch_map & EC_ADC_MAP)) { + hal_codec_set_ec_down_sel(true); + } +#ifdef AUDIO_ANC_FB_MC + fifo_flush |= CODEC_MC_FIFO_FLUSH; +#endif + fifo_flush |= CODEC_TX_FIFO_FLUSH; + codec->REG_004 |= fifo_flush; hal_codec_reg_update_delay(); - if (map & AUD_CHANNEL_MAP_CH0) { - codec->REG_09C = SET_BITFIELD(codec->REG_09C, CODEC_CODEC_DAC_GAIN_CH0, val); + codec->REG_004 &= ~fifo_flush; + if (dma) { + codec->REG_008 = SET_BITFIELD(codec->REG_008, CODEC_CODEC_TX_THRESHOLD, + HAL_CODEC_TX_FIFO_TRIGGER_LEVEL); + codec->REG_000 |= CODEC_DMACTRL_TX; + // Delay a little time for DMA to fill the TX FIFO before sending + for (volatile int i = 0; i < 50; i++) + ; } - if (map & AUD_CHANNEL_MAP_CH1) { - codec->REG_0A0 = SET_BITFIELD(codec->REG_0A0, CODEC_CODEC_DAC_GAIN_CH1, val); +#ifdef AUDIO_ANC_FB_MC + if (mc_dual_chan) { + codec->REG_04C |= CODEC_DUAL_CHANNEL_MC; + } else { + codec->REG_04C &= ~CODEC_DUAL_CHANNEL_MC; } - codec->REG_09C |= CODEC_CODEC_DAC_GAIN_UPDATE; + if (mc_16bit) { + codec->REG_04C |= CODEC_MODE_16BIT_MC; + } else { + codec->REG_04C &= ~CODEC_MODE_16BIT_MC; + } + if (adc_en_map == 0) { + // Reset ADC free running clock and ADC ANA + codec->REG_064 &= + ~(RSTN_ADC_FREE_RUNNING_CLK | CODEC_SOFT_RSTN_ADC_ANA_MASK); + codec->REG_064 |= + (RSTN_ADC_FREE_RUNNING_CLK | CODEC_SOFT_RSTN_ADC_ANA_MASK); + codec->REG_080 |= CODEC_CODEC_ADC_EN; + } + adc_en_map |= (1 << CODEC_ADC_EN_REQ_MC); + // If codec function has been enabled, start FIFOs directly; + // otherwise, start FIFOs after PA is enabled + if (codec->REG_098 & CODEC_CODEC_DAC_EN) { + uint32_t lock; + lock = int_lock(); + // MC FIFO and DAC FIFO must be started at the same time + codec->REG_04C |= CODEC_MC_ENABLE; + codec->REG_000 |= CODEC_DAC_ENABLE; + int_unlock(lock); + } + mc_enabled = true; +#else + codec->REG_000 |= CODEC_DAC_ENABLE; +#endif + } else { +#ifdef VOICE_DETECTOR_EN + if ((codec_adc_ch_map & AUD_CHANNEL_MAP_CH4) && + (vad_type == AUD_VAD_TYPE_MIX || vad_type == AUD_VAD_TYPE_DIG)) { + // Stop vad buffering + hal_codec_vad_stop(); + } +#endif +#ifdef CODEC_MIN_PHASE + if (min_phase_cfg & (1 << AUD_STREAM_CAPTURE)) { + if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH2) { + codec->REG_100 |= CODEC_FIR_STREAM_ENABLE_CH2; + codec->REG_0D0 |= CODEC_CODEC_ADC_FIR_DS_EN_CH2; + } + if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH3) { + codec->REG_100 |= CODEC_FIR_STREAM_ENABLE_CH3; + codec->REG_0D0 |= CODEC_CODEC_ADC_FIR_DS_EN_CH3; + } + } +#endif +#ifdef __AUDIO_RESAMPLE__ + if (codec->REG_0E4 & CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE) { + hal_codec_resample_clock_enable(stream); +#if (defined(__TWS__) || defined(IBRT)) && defined(ANC_APP) + enum HAL_CODEC_SYNC_TYPE_T sync_type; + + sync_type = + GET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_ADC_TRIGGER_SEL); + if (sync_type != HAL_CODEC_SYNC_TYPE_NONE) { + codec->REG_0E4 = + SET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_ADC_TRIGGER_SEL, + HAL_CODEC_SYNC_TYPE_NONE); + codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; + hal_codec_reg_update_delay(); + codec->REG_0F8 = resample_phase_float_to_value(1.0f); + hal_codec_reg_update_delay(); + codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; + hal_codec_reg_update_delay(); + codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; + codec->REG_0E4 = SET_BITFIELD( + codec->REG_0E4, CODEC_CODEC_RESAMPLE_ADC_TRIGGER_SEL, sync_type); + hal_codec_reg_update_delay(); + codec->REG_0F8 = + resample_phase_float_to_value(get_capture_resample_phase()); + codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; + } +#endif + codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_ADC_ENABLE; + } +#endif + if (codec_mic_ch_map & AUD_CHANNEL_MAP_DIGMIC_ALL) { + hal_codec_enable_dig_mic(codec_mic_ch_map); + } + if (codec_adc_ch_map & EC_ADC_MAP) { + hal_codec_ec_enable(); + } + for (int i = 0; i < MAX_ADC_CH_NUM; i++) { + if (codec_adc_ch_map & (AUD_CHANNEL_MAP_CH0 << i)) { + if (i < NORMAL_ADC_CH_NUM && + (codec->REG_080 & (CODEC_CODEC_ADC_EN_CH0 << i)) == 0) { + // Reset ADC channel + codec->REG_064 &= ~CODEC_SOFT_RSTN_ADC(1 << i); + codec->REG_064 |= CODEC_SOFT_RSTN_ADC(1 << i); + codec->REG_080 |= (CODEC_CODEC_ADC_EN_CH0 << i); + } + codec->REG_000 |= (CODEC_ADC_ENABLE_CH0 << i); + } + } + fifo_flush = CODEC_RX_FIFO_FLUSH_CH0 | CODEC_RX_FIFO_FLUSH_CH1 | + CODEC_RX_FIFO_FLUSH_CH2 | CODEC_RX_FIFO_FLUSH_CH3 | + CODEC_RX_FIFO_FLUSH_CH4 | CODEC_RX_FIFO_FLUSH_CH5 | + CODEC_RX_FIFO_FLUSH_CH6; + codec->REG_004 |= fifo_flush; + hal_codec_reg_update_delay(); + codec->REG_004 &= ~fifo_flush; + if (dma) { + codec->REG_008 = SET_BITFIELD(codec->REG_008, CODEC_CODEC_RX_THRESHOLD, + HAL_CODEC_RX_FIFO_TRIGGER_LEVEL); + codec->REG_000 |= CODEC_DMACTRL_RX; + } + codec->REG_000 |= CODEC_ADC_ENABLE; + } + + return 0; } -void hal_codec_get_dac_gain(float *left_gain, float *right_gain) -{ - struct DAC_GAIN_T { - int32_t v : 20; - }; +int hal_codec_stop_interface(enum HAL_CODEC_ID_T id, enum AUD_STREAM_T stream) { + uint32_t fifo_flush = 0; - struct DAC_GAIN_T left; - struct DAC_GAIN_T right; + if (stream == AUD_STREAM_PLAYBACK) { + codec->REG_000 &= ~CODEC_DAC_ENABLE; + codec->REG_000 &= ~CODEC_DMACTRL_TX; +#ifdef __AUDIO_RESAMPLE__ + codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_DAC_ENABLE; + hal_codec_resample_clock_disable(stream); +#endif +#ifdef CODEC_MIN_PHASE + if (min_phase_cfg & (1 << AUD_STREAM_PLAYBACK)) { + if (codec_dac_ch_map & AUD_CHANNEL_MAP_CH0) { + codec->REG_100 &= ~CODEC_FIR_STREAM_ENABLE_CH0; + codec->REG_098 &= ~CODEC_CODEC_DAC_L_FIR_UPSAMPLE; + } + if (codec_dac_ch_map & AUD_CHANNEL_MAP_CH1) { + codec->REG_100 &= ~CODEC_FIR_STREAM_ENABLE_CH1; + codec->REG_098 &= ~CODEC_CODEC_DAC_R_FIR_UPSAMPLE; + } + } +#endif +#ifdef CODEC_DSD + hal_codec_dsd_cfg_stop(); + dsd_enabled = false; +#endif +#ifdef AUDIO_ANC_FB_MC + mc_enabled = false; + codec->REG_04C &= ~CODEC_MC_ENABLE; + adc_en_map &= ~(1 << CODEC_ADC_EN_REQ_MC); + if (adc_en_map == 0) { + codec->REG_080 &= ~CODEC_CODEC_ADC_EN; + } + fifo_flush |= CODEC_MC_FIFO_FLUSH; +#endif + fifo_flush |= CODEC_TX_FIFO_FLUSH; + codec->REG_004 |= fifo_flush; + hal_codec_reg_update_delay(); + codec->REG_004 &= ~fifo_flush; + // Cancel dac sync request + hal_codec_sync_dac_disable(); + hal_codec_sync_dac_resample_rate_disable(); + hal_codec_sync_dac_gain_disable(); +#ifdef NO_DAC_RESET + // Clean up DAC intermediate states + osDelay(dac_delay_ms); +#endif + } else { + codec->REG_000 &= + ~(CODEC_ADC_ENABLE | CODEC_ADC_ENABLE_CH0 | CODEC_ADC_ENABLE_CH1 | + CODEC_ADC_ENABLE_CH2 | CODEC_ADC_ENABLE_CH3 | CODEC_ADC_ENABLE_CH4 | + CODEC_ADC_ENABLE_CH5 | CODEC_ADC_ENABLE_CH6); + codec->REG_000 &= ~CODEC_DMACTRL_RX; + for (int i = 0; i < MAX_ADC_CH_NUM; i++) { + if (i < NORMAL_ADC_CH_NUM && + (codec_adc_ch_map & (AUD_CHANNEL_MAP_CH0 << i)) && + (anc_adc_ch_map & (AUD_CHANNEL_MAP_CH0 << i)) == 0) { + codec->REG_080 &= ~(CODEC_CODEC_ADC_EN_CH0 << i); + } + } + if (codec_adc_ch_map & EC_ADC_MAP) { + hal_codec_ec_disable(); + } + if ((codec_mic_ch_map & AUD_CHANNEL_MAP_DIGMIC_ALL) && + (anc_mic_ch_map & AUD_CHANNEL_MAP_DIGMIC_ALL) == 0) { + hal_codec_disable_dig_mic(); + } +#ifdef __AUDIO_RESAMPLE__ + codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_ADC_ENABLE; + hal_codec_resample_clock_disable(stream); +#endif +#ifdef CODEC_MIN_PHASE + if (min_phase_cfg & (1 << AUD_STREAM_CAPTURE)) { + if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH2) { + codec->REG_100 &= ~CODEC_FIR_STREAM_ENABLE_CH2; + codec->REG_0D0 &= ~CODEC_CODEC_ADC_FIR_DS_EN_CH2; + } + if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH3) { + codec->REG_100 &= ~CODEC_FIR_STREAM_ENABLE_CH3; + codec->REG_0D0 &= ~CODEC_CODEC_ADC_FIR_DS_EN_CH3; + } + } +#endif + fifo_flush = CODEC_RX_FIFO_FLUSH_CH0 | CODEC_RX_FIFO_FLUSH_CH1 | + CODEC_RX_FIFO_FLUSH_CH2 | CODEC_RX_FIFO_FLUSH_CH3 | + CODEC_RX_FIFO_FLUSH_CH4 | CODEC_RX_FIFO_FLUSH_CH5 | + CODEC_RX_FIFO_FLUSH_CH6; + codec->REG_004 |= fifo_flush; + hal_codec_reg_update_delay(); + codec->REG_004 &= ~fifo_flush; + // Cancel adc sync request + hal_codec_sync_adc_disable(); + hal_codec_sync_adc_resample_rate_disable(); + hal_codec_sync_adc_gain_disable(); + } - left.v = GET_BITFIELD(codec->REG_09C, CODEC_CODEC_DAC_GAIN_CH0); - right.v = GET_BITFIELD(codec->REG_0A0, CODEC_CODEC_DAC_GAIN_CH1); - - *left_gain = left.v; - *right_gain = right.v; - - // Gain format: 6.14 - *left_gain /= (1 << 14); - *right_gain /= (1 << 14); + return 0; } -void hal_codec_dac_mute(bool mute) -{ - codec_mute[AUD_STREAM_PLAYBACK] = mute; +static void hal_codec_set_dac_gain_value(enum AUD_CHANNEL_MAP_T map, + uint32_t val) { + codec->REG_09C &= ~CODEC_CODEC_DAC_GAIN_UPDATE; + hal_codec_reg_update_delay(); + if (map & AUD_CHANNEL_MAP_CH0) { + codec->REG_09C = + SET_BITFIELD(codec->REG_09C, CODEC_CODEC_DAC_GAIN_CH0, val); + } + if (map & AUD_CHANNEL_MAP_CH1) { + codec->REG_0A0 = + SET_BITFIELD(codec->REG_0A0, CODEC_CODEC_DAC_GAIN_CH1, val); + } + codec->REG_09C |= CODEC_CODEC_DAC_GAIN_UPDATE; +} + +void hal_codec_get_dac_gain(float *left_gain, float *right_gain) { + struct DAC_GAIN_T { + int32_t v : 20; + }; + + struct DAC_GAIN_T left; + struct DAC_GAIN_T right; + + left.v = GET_BITFIELD(codec->REG_09C, CODEC_CODEC_DAC_GAIN_CH0); + right.v = GET_BITFIELD(codec->REG_0A0, CODEC_CODEC_DAC_GAIN_CH1); + + *left_gain = left.v; + *right_gain = right.v; + + // Gain format: 6.14 + *left_gain /= (1 << 14); + *right_gain /= (1 << 14); +} + +void hal_codec_dac_mute(bool mute) { + codec_mute[AUD_STREAM_PLAYBACK] = mute; #ifdef AUDIO_OUTPUT_SW_GAIN - hal_codec_set_sw_gain(swdac_gain); + hal_codec_set_sw_gain(swdac_gain); #else - if (mute) { - hal_codec_set_dac_gain_value(VALID_DAC_MAP, 0); - } else { - hal_codec_restore_dig_dac_gain(); - } + if (mute) { + hal_codec_set_dac_gain_value(VALID_DAC_MAP, 0); + } else { + hal_codec_restore_dig_dac_gain(); + } #endif } -static float db_to_amplitude_ratio(int32_t db) -{ - float coef; +static float db_to_amplitude_ratio(int32_t db) { + float coef; - if (db == ZERODB_DIG_DBVAL) { - coef = 1; - } else if (db <= MIN_DIG_DBVAL) { - coef = 0; - } else { - if (db > MAX_DIG_DBVAL) { - db = MAX_DIG_DBVAL; - } - coef = db_to_float(db); + if (db == ZERODB_DIG_DBVAL) { + coef = 1; + } else if (db <= MIN_DIG_DBVAL) { + coef = 0; + } else { + if (db > MAX_DIG_DBVAL) { + db = MAX_DIG_DBVAL; } + coef = db_to_float(db); + } - return coef; + return coef; } -static float digdac_gain_to_float(int32_t gain) -{ - float coef; +static float digdac_gain_to_float(int32_t gain) { + float coef; #if defined(NOISE_GATING) && defined(NOISE_REDUCTION) - gain += digdac_gain_offset_nr; + gain += digdac_gain_offset_nr; #endif - coef = db_to_amplitude_ratio(gain); + coef = db_to_amplitude_ratio(gain); #ifdef AUDIO_OUTPUT_DC_CALIB - coef *= dac_dc_gain_attn; + coef *= dac_dc_gain_attn; #endif #ifdef ANC_APP - coef *= anc_boost_gain_attn; + coef *= anc_boost_gain_attn; #endif #if 0 @@ -1736,605 +1882,647 @@ static float digdac_gain_to_float(int32_t gain) } #endif - return coef; + return coef; } -static void hal_codec_set_dig_dac_gain(enum AUD_CHANNEL_MAP_T map, int32_t gain) -{ - uint32_t val; - float coef; - bool mute; +static void hal_codec_set_dig_dac_gain(enum AUD_CHANNEL_MAP_T map, + int32_t gain) { + uint32_t val; + float coef; + bool mute; - if (map & AUD_CHANNEL_MAP_CH0) { - digdac_gain[0] = gain; - } - if (map & AUD_CHANNEL_MAP_CH1) { - digdac_gain[1] = gain; - } + if (map & AUD_CHANNEL_MAP_CH0) { + digdac_gain[0] = gain; + } + if (map & AUD_CHANNEL_MAP_CH1) { + digdac_gain[1] = gain; + } #ifdef AUDIO_OUTPUT_SW_GAIN - mute = false; + mute = false; #else - mute = codec_mute[AUD_STREAM_PLAYBACK]; + mute = codec_mute[AUD_STREAM_PLAYBACK]; #endif #ifdef AUDIO_OUTPUT_DC_CALIB_ANA - if (codec->REG_098 & CODEC_CODEC_DAC_SDM_CLOSE) { - mute = true; - } + if (codec->REG_098 & CODEC_CODEC_DAC_SDM_CLOSE) { + mute = true; + } #endif - if (mute) { - val = 0; - } else { - coef = digdac_gain_to_float(gain); + if (mute) { + val = 0; + } else { + coef = digdac_gain_to_float(gain); - // Gain format: 6.14 - int32_t s_val = (int32_t)(coef * (1 << 14)); - val = __SSAT(s_val, 20); - } + // Gain format: 6.14 + int32_t s_val = (int32_t)(coef * (1 << 14)); + val = __SSAT(s_val, 20); + } - hal_codec_set_dac_gain_value(map, val); + hal_codec_set_dac_gain_value(map, val); } -static void hal_codec_restore_dig_dac_gain(void) -{ - if (digdac_gain[0] == digdac_gain[1]) { - hal_codec_set_dig_dac_gain(VALID_DAC_MAP, digdac_gain[0]); - } else { - hal_codec_set_dig_dac_gain(AUD_CHANNEL_MAP_CH0, digdac_gain[0]); - hal_codec_set_dig_dac_gain(AUD_CHANNEL_MAP_CH1, digdac_gain[1]); - } +static void hal_codec_restore_dig_dac_gain(void) { + if (digdac_gain[0] == digdac_gain[1]) { + hal_codec_set_dig_dac_gain(VALID_DAC_MAP, digdac_gain[0]); + } else { + hal_codec_set_dig_dac_gain(AUD_CHANNEL_MAP_CH0, digdac_gain[0]); + hal_codec_set_dig_dac_gain(AUD_CHANNEL_MAP_CH1, digdac_gain[1]); + } } #ifdef AUDIO_OUTPUT_SW_GAIN -static void hal_codec_set_sw_gain(int32_t gain) -{ - float coef; - bool mute; +static void hal_codec_set_sw_gain(int32_t gain) { + float coef; + bool mute; - swdac_gain = gain; + swdac_gain = gain; - mute = codec_mute[AUD_STREAM_PLAYBACK]; + mute = codec_mute[AUD_STREAM_PLAYBACK]; - if (mute) { - coef = 0; - } else { - coef = digdac_gain_to_float(gain); - } + if (mute) { + coef = 0; + } else { + coef = digdac_gain_to_float(gain); + } - if (sw_output_coef_callback) { - sw_output_coef_callback(coef); - } + if (sw_output_coef_callback) { + sw_output_coef_callback(coef); + } } -void hal_codec_set_sw_output_coef_callback(HAL_CODEC_SW_OUTPUT_COEF_CALLBACK callback) -{ - sw_output_coef_callback = callback; +void hal_codec_set_sw_output_coef_callback( + HAL_CODEC_SW_OUTPUT_COEF_CALLBACK callback) { + sw_output_coef_callback = callback; } #endif -static void hal_codec_set_adc_gain_value(enum AUD_CHANNEL_MAP_T map, uint32_t val) -{ - uint32_t gain_update = 0; +static void hal_codec_set_adc_gain_value(enum AUD_CHANNEL_MAP_T map, + uint32_t val) { + uint32_t gain_update = 0; - for (int i = 0; i < NORMAL_ADC_CH_NUM; i++) { - if (map & (AUD_CHANNEL_MAP_CH0 << i)) { - *(&codec->REG_084 + i) = SET_BITFIELD(*(&codec->REG_084 + i), CODEC_CODEC_ADC_GAIN_CH0, val); - gain_update |= (CODEC_CODEC_ADC_GAIN_UPDATE_CH0 << i); - } + for (int i = 0; i < NORMAL_ADC_CH_NUM; i++) { + if (map & (AUD_CHANNEL_MAP_CH0 << i)) { + *(&codec->REG_084 + i) = + SET_BITFIELD(*(&codec->REG_084 + i), CODEC_CODEC_ADC_GAIN_CH0, val); + gain_update |= (CODEC_CODEC_ADC_GAIN_UPDATE_CH0 << i); } - codec->REG_09C &= ~gain_update; - hal_codec_reg_update_delay(); - codec->REG_09C |= gain_update; + } + codec->REG_09C &= ~gain_update; + hal_codec_reg_update_delay(); + codec->REG_09C |= gain_update; } -static void hal_codec_set_dig_adc_gain(enum AUD_CHANNEL_MAP_T map, int32_t gain) -{ - uint32_t val; - float coef; - bool mute; - int i; - int32_t s_val; +static void hal_codec_set_dig_adc_gain(enum AUD_CHANNEL_MAP_T map, + int32_t gain) { + uint32_t val; + float coef; + bool mute; + int i; + int32_t s_val; - for (i = 0; i < NORMAL_ADC_CH_NUM; i++) { - if (map & (1 << i)) { - digadc_gain[i] = gain; - } + for (i = 0; i < NORMAL_ADC_CH_NUM; i++) { + if (map & (1 << i)) { + digadc_gain[i] = gain; } + } - mute = codec_mute[AUD_STREAM_CAPTURE]; + mute = codec_mute[AUD_STREAM_CAPTURE]; - if (mute) { - val = 0; - } else { + if (mute) { + val = 0; + } else { #ifdef ANC_APP - enum AUD_CHANNEL_MAP_T adj_map; - int32_t anc_gain; + enum AUD_CHANNEL_MAP_T adj_map; + int32_t anc_gain; - adj_map = map & anc_adc_gain_offset_map; - while (adj_map) { - i = get_msb_pos(adj_map); - adj_map &= ~(1 << i); - anc_gain = gain + anc_adc_gain_offset[i]; - coef = db_to_amplitude_ratio(anc_gain); - coef /= anc_boost_gain_attn; - // Gain format: 8.12 - s_val = (int32_t)(coef * (1 << 12)); - val = __SSAT(s_val, 20); - hal_codec_set_adc_gain_value((1 << i), val); - } + adj_map = map & anc_adc_gain_offset_map; + while (adj_map) { + i = get_msb_pos(adj_map); + adj_map &= ~(1 << i); + anc_gain = gain + anc_adc_gain_offset[i]; + coef = db_to_amplitude_ratio(anc_gain); + coef /= anc_boost_gain_attn; + // Gain format: 8.12 + s_val = (int32_t)(coef * (1 << 12)); + val = __SSAT(s_val, 20); + hal_codec_set_adc_gain_value((1 << i), val); + } - map &= ~anc_adc_gain_offset_map; + map &= ~anc_adc_gain_offset_map; #endif - if (map) { - coef = db_to_amplitude_ratio(gain); + if (map) { + coef = db_to_amplitude_ratio(gain); #ifdef ANC_APP - coef /= anc_boost_gain_attn; + coef /= anc_boost_gain_attn; #endif - // Gain format: 8.12 - s_val = (int32_t)(coef * (1 << 12)); - val = __SSAT(s_val, 20); - } else { - val = 0; - } - } - - hal_codec_set_adc_gain_value(map, val); -} - -static void hal_codec_restore_dig_adc_gain(void) -{ - int i; - - for (i = 0; i < NORMAL_ADC_CH_NUM; i++) { - hal_codec_set_dig_adc_gain((1 << i), digadc_gain[i]); - } -} - -static void POSSIBLY_UNUSED hal_codec_get_adc_gain(enum AUD_CHANNEL_MAP_T map, float *gain) -{ - struct ADC_GAIN_T { - int32_t v : 20; - }; - - struct ADC_GAIN_T adc_val; - - for (int i = 0; i < NORMAL_ADC_CH_NUM; i++) { - if (map & (AUD_CHANNEL_MAP_CH0 << i)) { - adc_val.v = GET_BITFIELD(*(&codec->REG_084 + i), CODEC_CODEC_ADC_GAIN_CH0); - - *gain = adc_val.v; - // Gain format: 8.12 - *gain /= (1 << 12); - return; - } - } - - *gain = 0; -} - -void hal_codec_adc_mute(bool mute) -{ - codec_mute[AUD_STREAM_CAPTURE] = mute; - - if (mute) { - hal_codec_set_adc_gain_value(NORMAL_ADC_MAP, 0); + // Gain format: 8.12 + s_val = (int32_t)(coef * (1 << 12)); + val = __SSAT(s_val, 20); } else { - hal_codec_restore_dig_adc_gain(); + val = 0; } + } + + hal_codec_set_adc_gain_value(map, val); } -int hal_codec_set_chan_vol(enum AUD_STREAM_T stream, enum AUD_CHANNEL_MAP_T ch_map, uint8_t vol) -{ - if (stream == AUD_STREAM_PLAYBACK) { +static void hal_codec_restore_dig_adc_gain(void) { + int i; + + for (i = 0; i < NORMAL_ADC_CH_NUM; i++) { + hal_codec_set_dig_adc_gain((1 << i), digadc_gain[i]); + } +} + +static void POSSIBLY_UNUSED hal_codec_get_adc_gain(enum AUD_CHANNEL_MAP_T map, + float *gain) { + struct ADC_GAIN_T { + int32_t v : 20; + }; + + struct ADC_GAIN_T adc_val; + + for (int i = 0; i < NORMAL_ADC_CH_NUM; i++) { + if (map & (AUD_CHANNEL_MAP_CH0 << i)) { + adc_val.v = + GET_BITFIELD(*(&codec->REG_084 + i), CODEC_CODEC_ADC_GAIN_CH0); + + *gain = adc_val.v; + // Gain format: 8.12 + *gain /= (1 << 12); + return; + } + } + + *gain = 0; +} + +void hal_codec_adc_mute(bool mute) { + codec_mute[AUD_STREAM_CAPTURE] = mute; + + if (mute) { + hal_codec_set_adc_gain_value(NORMAL_ADC_MAP, 0); + } else { + hal_codec_restore_dig_adc_gain(); + } +} + +int hal_codec_set_chan_vol(enum AUD_STREAM_T stream, + enum AUD_CHANNEL_MAP_T ch_map, uint8_t vol) { + if (stream == AUD_STREAM_PLAYBACK) { #ifdef AUDIO_OUTPUT_SW_GAIN - ASSERT(false, "%s: Cannot set play chan vol with AUDIO_OUTPUT_SW_GAIN", __func__); + ASSERT(false, "%s: Cannot set play chan vol with AUDIO_OUTPUT_SW_GAIN", + __func__); #else #ifdef SINGLE_CODEC_DAC_VOL - ASSERT(false, "%s: Cannot set play chan vol with SINGLE_CODEC_DAC_VOL", __func__); + ASSERT(false, "%s: Cannot set play chan vol with SINGLE_CODEC_DAC_VOL", + __func__); #else - const struct CODEC_DAC_VOL_T *vol_tab_ptr; + const struct CODEC_DAC_VOL_T *vol_tab_ptr; - vol_tab_ptr = hal_codec_get_dac_volume(vol); - if (vol_tab_ptr) { - if (ch_map & AUD_CHANNEL_MAP_CH0) { - hal_codec_set_dig_dac_gain(AUD_CHANNEL_MAP_CH0, vol_tab_ptr->sdac_volume); - } - if (ch_map & AUD_CHANNEL_MAP_CH1) { - hal_codec_set_dig_dac_gain(AUD_CHANNEL_MAP_CH1, vol_tab_ptr->sdac_volume); - } - } + vol_tab_ptr = hal_codec_get_dac_volume(vol); + if (vol_tab_ptr) { + if (ch_map & AUD_CHANNEL_MAP_CH0) { + hal_codec_set_dig_dac_gain(AUD_CHANNEL_MAP_CH0, + vol_tab_ptr->sdac_volume); + } + if (ch_map & AUD_CHANNEL_MAP_CH1) { + hal_codec_set_dig_dac_gain(AUD_CHANNEL_MAP_CH1, + vol_tab_ptr->sdac_volume); + } + } #endif #endif - } else { + } else { #ifdef SINGLE_CODEC_ADC_VOL - ASSERT(false, "%s: Cannot set cap chan vol with SINGLE_CODEC_ADC_VOL", __func__); + ASSERT(false, "%s: Cannot set cap chan vol with SINGLE_CODEC_ADC_VOL", + __func__); #else - uint8_t mic_ch, adc_ch; - enum AUD_CHANNEL_MAP_T map; - const CODEC_ADC_VOL_T *adc_gain_db; + uint8_t mic_ch, adc_ch; + enum AUD_CHANNEL_MAP_T map; + const CODEC_ADC_VOL_T *adc_gain_db; - adc_gain_db = hal_codec_get_adc_volume(vol); - if (adc_gain_db) { - map = ch_map & ~EC_MIC_MAP; - while (map) { - mic_ch = get_lsb_pos(map); - map &= ~(1 << mic_ch); - adc_ch = hal_codec_get_adc_chan(1 << mic_ch); - ASSERT(adc_ch < NORMAL_ADC_CH_NUM, "%s: Bad cap ch_map=0x%X (ch=%u)", __func__, ch_map, mic_ch); - hal_codec_set_dig_adc_gain((1 << adc_ch), *adc_gain_db); - } - } + adc_gain_db = hal_codec_get_adc_volume(vol); + if (adc_gain_db) { + map = ch_map & ~EC_MIC_MAP; + while (map) { + mic_ch = get_lsb_pos(map); + map &= ~(1 << mic_ch); + adc_ch = hal_codec_get_adc_chan(1 << mic_ch); + ASSERT(adc_ch < NORMAL_ADC_CH_NUM, "%s: Bad cap ch_map=0x%X (ch=%u)", + __func__, ch_map, mic_ch); + hal_codec_set_dig_adc_gain((1 << adc_ch), *adc_gain_db); + } + } #endif - } + } - return 0; + return 0; } -static int hal_codec_set_dac_hbf_bypass_cnt(uint32_t cnt) -{ - uint32_t bypass = 0; - uint32_t bypass_mask = CODEC_CODEC_DAC_HBF1_BYPASS | CODEC_CODEC_DAC_HBF2_BYPASS | CODEC_CODEC_DAC_HBF3_BYPASS; +static int hal_codec_set_dac_hbf_bypass_cnt(uint32_t cnt) { + uint32_t bypass = 0; + uint32_t bypass_mask = CODEC_CODEC_DAC_HBF1_BYPASS | + CODEC_CODEC_DAC_HBF2_BYPASS | + CODEC_CODEC_DAC_HBF3_BYPASS; - if (cnt == 0) { - } else if (cnt == 1) { - bypass = CODEC_CODEC_DAC_HBF3_BYPASS; - } else if (cnt == 2) { - bypass = CODEC_CODEC_DAC_HBF2_BYPASS | CODEC_CODEC_DAC_HBF3_BYPASS; - } else if (cnt == 3) { - bypass = CODEC_CODEC_DAC_HBF1_BYPASS | CODEC_CODEC_DAC_HBF2_BYPASS | CODEC_CODEC_DAC_HBF3_BYPASS; - } else { - ASSERT(false, "%s: Invalid dac bypass cnt: %u", __FUNCTION__, cnt); - } + if (cnt == 0) { + } else if (cnt == 1) { + bypass = CODEC_CODEC_DAC_HBF3_BYPASS; + } else if (cnt == 2) { + bypass = CODEC_CODEC_DAC_HBF2_BYPASS | CODEC_CODEC_DAC_HBF3_BYPASS; + } else if (cnt == 3) { + bypass = CODEC_CODEC_DAC_HBF1_BYPASS | CODEC_CODEC_DAC_HBF2_BYPASS | + CODEC_CODEC_DAC_HBF3_BYPASS; + } else { + ASSERT(false, "%s: Invalid dac bypass cnt: %u", __FUNCTION__, cnt); + } - // OSR is fixed to 512 - //codec->REG_098 = SET_BITFIELD(codec->REG_098, CODEC_CODEC_DAC_OSR_SEL, 2); + // OSR is fixed to 512 + // codec->REG_098 = SET_BITFIELD(codec->REG_098, CODEC_CODEC_DAC_OSR_SEL, 2); - codec->REG_098 = (codec->REG_098 & ~bypass_mask) | bypass; - return 0; + codec->REG_098 = (codec->REG_098 & ~bypass_mask) | bypass; + return 0; } -static int hal_codec_set_dac_up(uint32_t val) -{ - uint32_t sel = 0; +static int hal_codec_set_dac_up(uint32_t val) { + uint32_t sel = 0; - if (val == 2) { - sel = 0; - } else if (val == 3) { - sel = 1; - } else if (val == 4) { - sel = 2; - } else if (val == 6) { - sel = 3; - } else if (val == 1) { - sel = 4; - } else { - ASSERT(false, "%s: Invalid dac up: %u", __FUNCTION__, val); - } - codec->REG_098 = SET_BITFIELD(codec->REG_098, CODEC_CODEC_DAC_UP_SEL, sel); - return 0; + if (val == 2) { + sel = 0; + } else if (val == 3) { + sel = 1; + } else if (val == 4) { + sel = 2; + } else if (val == 6) { + sel = 3; + } else if (val == 1) { + sel = 4; + } else { + ASSERT(false, "%s: Invalid dac up: %u", __FUNCTION__, val); + } + codec->REG_098 = SET_BITFIELD(codec->REG_098, CODEC_CODEC_DAC_UP_SEL, sel); + return 0; } -static uint32_t POSSIBLY_UNUSED hal_codec_get_dac_up(void) -{ - uint32_t sel; +static uint32_t POSSIBLY_UNUSED hal_codec_get_dac_up(void) { + uint32_t sel; - sel = GET_BITFIELD(codec->REG_098, CODEC_CODEC_DAC_UP_SEL); - if (sel == 0) { - return 2; - } else if (sel == 1) { - return 3; - } else if (sel == 2) { - return 4; - } else if (sel == 3) { - return 6; - } else { - return 1; - } + sel = GET_BITFIELD(codec->REG_098, CODEC_CODEC_DAC_UP_SEL); + if (sel == 0) { + return 2; + } else if (sel == 1) { + return 3; + } else if (sel == 2) { + return 4; + } else if (sel == 3) { + return 6; + } else { + return 1; + } } -static int hal_codec_set_adc_down(enum AUD_CHANNEL_MAP_T map, uint32_t val) -{ - uint32_t sel = 0; +static int hal_codec_set_adc_down(enum AUD_CHANNEL_MAP_T map, uint32_t val) { + uint32_t sel = 0; - if (val == 3) { - sel = 0; - } else if (val == 6) { - sel = 1; - } else if (val == 1) { - sel = 2; - } else { - ASSERT(false, "%s: Invalid adc down: %u", __FUNCTION__, val); + if (val == 3) { + sel = 0; + } else if (val == 6) { + sel = 1; + } else if (val == 1) { + sel = 2; + } else { + ASSERT(false, "%s: Invalid adc down: %u", __FUNCTION__, val); + } + for (int i = 0; i < NORMAL_ADC_CH_NUM; i++) { + if (map & (AUD_CHANNEL_MAP_CH0 << i)) { + *(&codec->REG_084 + i) = SET_BITFIELD(*(&codec->REG_084 + i), + CODEC_CODEC_ADC_DOWN_SEL_CH0, sel); } - for (int i = 0; i < NORMAL_ADC_CH_NUM; i++) { - if (map & (AUD_CHANNEL_MAP_CH0 << i)) { - *(&codec->REG_084 + i) = SET_BITFIELD(*(&codec->REG_084 + i), CODEC_CODEC_ADC_DOWN_SEL_CH0, sel); - } - } - return 0; + } + return 0; } -static int hal_codec_set_adc_hbf_bypass_cnt(enum AUD_CHANNEL_MAP_T map, uint32_t cnt) -{ - uint32_t bypass = 0; - uint32_t bypass_mask = CODEC_CODEC_ADC_HBF1_BYPASS_CH0 | CODEC_CODEC_ADC_HBF2_BYPASS_CH0 | CODEC_CODEC_ADC_HBF3_BYPASS_CH0; +static int hal_codec_set_adc_hbf_bypass_cnt(enum AUD_CHANNEL_MAP_T map, + uint32_t cnt) { + uint32_t bypass = 0; + uint32_t bypass_mask = CODEC_CODEC_ADC_HBF1_BYPASS_CH0 | + CODEC_CODEC_ADC_HBF2_BYPASS_CH0 | + CODEC_CODEC_ADC_HBF3_BYPASS_CH0; - if (cnt == 0) { - } else if (cnt == 1) { - bypass = CODEC_CODEC_ADC_HBF3_BYPASS_CH0; - } else if (cnt == 2) { - bypass = CODEC_CODEC_ADC_HBF2_BYPASS_CH0 | CODEC_CODEC_ADC_HBF3_BYPASS_CH0; - } else if (cnt == 3) { - bypass = CODEC_CODEC_ADC_HBF1_BYPASS_CH0 | CODEC_CODEC_ADC_HBF2_BYPASS_CH0 | CODEC_CODEC_ADC_HBF3_BYPASS_CH0; - } else { - ASSERT(false, "%s: Invalid bypass cnt: %u", __FUNCTION__, cnt); + if (cnt == 0) { + } else if (cnt == 1) { + bypass = CODEC_CODEC_ADC_HBF3_BYPASS_CH0; + } else if (cnt == 2) { + bypass = CODEC_CODEC_ADC_HBF2_BYPASS_CH0 | CODEC_CODEC_ADC_HBF3_BYPASS_CH0; + } else if (cnt == 3) { + bypass = CODEC_CODEC_ADC_HBF1_BYPASS_CH0 | CODEC_CODEC_ADC_HBF2_BYPASS_CH0 | + CODEC_CODEC_ADC_HBF3_BYPASS_CH0; + } else { + ASSERT(false, "%s: Invalid bypass cnt: %u", __FUNCTION__, cnt); + } + for (int i = 0; i < NORMAL_ADC_CH_NUM; i++) { + if (map & (AUD_CHANNEL_MAP_CH0 << i)) { + *(&codec->REG_084 + i) = (*(&codec->REG_084 + i) & ~bypass_mask) | bypass; } - for (int i = 0; i < NORMAL_ADC_CH_NUM; i++) { - if (map & (AUD_CHANNEL_MAP_CH0 << i)) { - *(&codec->REG_084 + i) = (*(&codec->REG_084 + i) & ~bypass_mask) | bypass; - } - } - return 0; + } + return 0; } #ifdef __AUDIO_RESAMPLE__ -static float get_playback_resample_phase(void) -{ - return (float)codec_dac_sample_rate[resample_rate_idx[AUD_STREAM_PLAYBACK]].codec_freq / hal_cmu_get_crystal_freq(); +static float get_playback_resample_phase(void) { + return (float)codec_dac_sample_rate[resample_rate_idx[AUD_STREAM_PLAYBACK]] + .codec_freq / + hal_cmu_get_crystal_freq(); } -static float get_capture_resample_phase(void) -{ - return (float)hal_cmu_get_crystal_freq() / codec_adc_sample_rate[resample_rate_idx[AUD_STREAM_CAPTURE]].codec_freq; +static float get_capture_resample_phase(void) { + return (float)hal_cmu_get_crystal_freq() / + codec_adc_sample_rate[resample_rate_idx[AUD_STREAM_CAPTURE]] + .codec_freq; } -static uint32_t resample_phase_float_to_value(float phase) -{ - if (phase >= 4.0) { - return (uint32_t)-1; - } else { - // Phase format: 2.30 - return (uint32_t)(phase * (1 << 30)); - } -} - -static float POSSIBLY_UNUSED resample_phase_value_to_float(uint32_t value) -{ +static uint32_t resample_phase_float_to_value(float phase) { + if (phase >= 4.0) { + return (uint32_t)-1; + } else { // Phase format: 2.30 - return (float)value / (1 << 30); + return (uint32_t)(phase * (1 << 30)); + } +} + +static float POSSIBLY_UNUSED resample_phase_value_to_float(uint32_t value) { + // Phase format: 2.30 + return (float)value / (1 << 30); } #endif #ifdef SIDETONE_ENABLE -static void hal_codec_set_sidetone_adc_chan(enum AUD_CHANNEL_MAP_T chan_map) -{ - if (chan_map == AUD_CHANNEL_MAP_CH0) { - codec->REG_080 &= ~CODEC_CODEC_SIDE_TONE_MIC_SEL; - codec->REG_078 &= ~CODEC_CODEC_SIDE_TONE_CH_SEL; - } else if (chan_map == AUD_CHANNEL_MAP_CH2) { - codec->REG_080 &= ~CODEC_CODEC_SIDE_TONE_MIC_SEL; - codec->REG_078 |= CODEC_CODEC_SIDE_TONE_CH_SEL; - } else if (chan_map == AUD_CHANNEL_MAP_CH4) { - codec->REG_080 |= CODEC_CODEC_SIDE_TONE_MIC_SEL; - } +static void hal_codec_set_sidetone_adc_chan(enum AUD_CHANNEL_MAP_T chan_map) { + if (chan_map == AUD_CHANNEL_MAP_CH0) { + codec->REG_080 &= ~CODEC_CODEC_SIDE_TONE_MIC_SEL; + codec->REG_078 &= ~CODEC_CODEC_SIDE_TONE_CH_SEL; + } else if (chan_map == AUD_CHANNEL_MAP_CH2) { + codec->REG_080 &= ~CODEC_CODEC_SIDE_TONE_MIC_SEL; + codec->REG_078 |= CODEC_CODEC_SIDE_TONE_CH_SEL; + } else if (chan_map == AUD_CHANNEL_MAP_CH4) { + codec->REG_080 |= CODEC_CODEC_SIDE_TONE_MIC_SEL; + } } #endif -int hal_codec_setup_stream(enum HAL_CODEC_ID_T id, enum AUD_STREAM_T stream, const struct HAL_CODEC_CONFIG_T *cfg) -{ - int i; - int rate_idx; - uint32_t ana_dig_div; - enum AUD_SAMPRATE_T sample_rate; +int hal_codec_setup_stream(enum HAL_CODEC_ID_T id, enum AUD_STREAM_T stream, + const struct HAL_CODEC_CONFIG_T *cfg) { + int i; + int rate_idx; + uint32_t ana_dig_div; + enum AUD_SAMPRATE_T sample_rate; - if (stream == AUD_STREAM_PLAYBACK) { - if ((HAL_CODEC_CONFIG_CHANNEL_MAP | HAL_CODEC_CONFIG_CHANNEL_NUM) & cfg->set_flag) { - if (cfg->channel_num == AUD_CHANNEL_NUM_2) { - if (cfg->channel_map != (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1)) { - TRACE(2,"\n!!! WARNING:%s: Bad play stereo ch map: 0x%X\n", __func__, cfg->channel_map); - } - codec->REG_044 |= CODEC_DUAL_CHANNEL_DAC; - } else { - ASSERT(cfg->channel_num == AUD_CHANNEL_NUM_1, "%s: Bad play ch num: %u", __func__, cfg->channel_num); - // Allow to DMA one channel but output 2 channels - ASSERT((cfg->channel_map & ~(AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1)) == 0, - "%s: Bad play mono ch map: 0x%X", __func__, cfg->channel_map); - codec->REG_044 &= ~CODEC_DUAL_CHANNEL_DAC; - } - codec_dac_ch_map = AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1; + if (stream == AUD_STREAM_PLAYBACK) { + if ((HAL_CODEC_CONFIG_CHANNEL_MAP | HAL_CODEC_CONFIG_CHANNEL_NUM) & + cfg->set_flag) { + if (cfg->channel_num == AUD_CHANNEL_NUM_2) { + if (cfg->channel_map != (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1)) { + TRACE(2, "\n!!! WARNING:%s: Bad play stereo ch map: 0x%X\n", __func__, + cfg->channel_map); } + codec->REG_044 |= CODEC_DUAL_CHANNEL_DAC; + } else { + ASSERT(cfg->channel_num == AUD_CHANNEL_NUM_1, "%s: Bad play ch num: %u", + __func__, cfg->channel_num); + // Allow to DMA one channel but output 2 channels + ASSERT((cfg->channel_map & + ~(AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1)) == 0, + "%s: Bad play mono ch map: 0x%X", __func__, cfg->channel_map); + codec->REG_044 &= ~CODEC_DUAL_CHANNEL_DAC; + } + codec_dac_ch_map = AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1; + } - if (HAL_CODEC_CONFIG_BITS & cfg->set_flag) { - if (cfg->bits == AUD_BITS_16) { - codec->REG_044 = (codec->REG_044 & ~CODEC_MODE_32BIT_DAC) | CODEC_MODE_16BIT_DAC; - codec->REG_04C = (codec->REG_04C & ~CODEC_MODE_32BIT_MC) | CODEC_MODE_16BIT_MC; - } else if (cfg->bits == AUD_BITS_24) { - codec->REG_044 &= ~(CODEC_MODE_16BIT_DAC | CODEC_MODE_32BIT_DAC); - codec->REG_04C &= ~(CODEC_MODE_16BIT_MC | CODEC_MODE_32BIT_MC); - } else if (cfg->bits == AUD_BITS_32) { - codec->REG_044 = (codec->REG_044 & ~CODEC_MODE_16BIT_DAC) | CODEC_MODE_32BIT_DAC; - codec->REG_04C = (codec->REG_04C & ~CODEC_MODE_16BIT_MC) | CODEC_MODE_32BIT_MC; - } else { - ASSERT(false, "%s: Bad play bits: %u", __func__, cfg->bits); - } - } + if (HAL_CODEC_CONFIG_BITS & cfg->set_flag) { + if (cfg->bits == AUD_BITS_16) { + codec->REG_044 = + (codec->REG_044 & ~CODEC_MODE_32BIT_DAC) | CODEC_MODE_16BIT_DAC; + codec->REG_04C = + (codec->REG_04C & ~CODEC_MODE_32BIT_MC) | CODEC_MODE_16BIT_MC; + } else if (cfg->bits == AUD_BITS_24) { + codec->REG_044 &= ~(CODEC_MODE_16BIT_DAC | CODEC_MODE_32BIT_DAC); + codec->REG_04C &= ~(CODEC_MODE_16BIT_MC | CODEC_MODE_32BIT_MC); + } else if (cfg->bits == AUD_BITS_32) { + codec->REG_044 = + (codec->REG_044 & ~CODEC_MODE_16BIT_DAC) | CODEC_MODE_32BIT_DAC; + codec->REG_04C = + (codec->REG_04C & ~CODEC_MODE_16BIT_MC) | CODEC_MODE_32BIT_MC; + } else { + ASSERT(false, "%s: Bad play bits: %u", __func__, cfg->bits); + } + } - if (HAL_CODEC_CONFIG_SAMPLE_RATE & cfg->set_flag) { - sample_rate = cfg->sample_rate; + if (HAL_CODEC_CONFIG_SAMPLE_RATE & cfg->set_flag) { + sample_rate = cfg->sample_rate; #ifdef CODEC_DSD - if (dsd_enabled) { - if (sample_rate == AUD_SAMPRATE_176400) { - dsd_rate_idx = 0; - } else if (sample_rate == AUD_SAMPRATE_352800) { - dsd_rate_idx = 1; - } else if (sample_rate == AUD_SAMPRATE_705600) { - dsd_rate_idx = 2; - } else { - ASSERT(false, "%s: Bad DSD sample rate: %u", __func__, sample_rate); - } - sample_rate = AUD_SAMPRATE_44100; - } + if (dsd_enabled) { + if (sample_rate == AUD_SAMPRATE_176400) { + dsd_rate_idx = 0; + } else if (sample_rate == AUD_SAMPRATE_352800) { + dsd_rate_idx = 1; + } else if (sample_rate == AUD_SAMPRATE_705600) { + dsd_rate_idx = 2; + } else { + ASSERT(false, "%s: Bad DSD sample rate: %u", __func__, sample_rate); + } + sample_rate = AUD_SAMPRATE_44100; + } #endif - for (i = 0; i < ARRAY_SIZE(codec_dac_sample_rate); i++) { - if (codec_dac_sample_rate[i].sample_rate == sample_rate) { - break; - } - } - ASSERT(i < ARRAY_SIZE(codec_dac_sample_rate), "%s: Invalid playback sample rate: %u", __func__, sample_rate); - rate_idx = i; - ana_dig_div = codec_dac_sample_rate[rate_idx].codec_div / codec_dac_sample_rate[rate_idx].cmu_div; - ASSERT(ana_dig_div * codec_dac_sample_rate[rate_idx].cmu_div == codec_dac_sample_rate[rate_idx].codec_div, - "%s: Invalid playback div for rate %u: codec_div=%u cmu_div=%u", __func__, sample_rate, - codec_dac_sample_rate[rate_idx].codec_div, codec_dac_sample_rate[rate_idx].cmu_div); + for (i = 0; i < ARRAY_SIZE(codec_dac_sample_rate); i++) { + if (codec_dac_sample_rate[i].sample_rate == sample_rate) { + break; + } + } + ASSERT(i < ARRAY_SIZE(codec_dac_sample_rate), + "%s: Invalid playback sample rate: %u", __func__, sample_rate); + rate_idx = i; + ana_dig_div = codec_dac_sample_rate[rate_idx].codec_div / + codec_dac_sample_rate[rate_idx].cmu_div; + ASSERT(ana_dig_div * codec_dac_sample_rate[rate_idx].cmu_div == + codec_dac_sample_rate[rate_idx].codec_div, + "%s: Invalid playback div for rate %u: codec_div=%u cmu_div=%u", + __func__, sample_rate, codec_dac_sample_rate[rate_idx].codec_div, + codec_dac_sample_rate[rate_idx].cmu_div); - TRACE(2,"[%s] playback sample_rate=%d", __func__, sample_rate); + TRACE(2, "[%s] playback sample_rate=%d", __func__, sample_rate); #ifdef CODEC_TIMER - cur_codec_freq = codec_dac_sample_rate[rate_idx].codec_freq; + cur_codec_freq = codec_dac_sample_rate[rate_idx].codec_freq; #endif - codec_rate_idx[AUD_STREAM_PLAYBACK] = rate_idx; + codec_rate_idx[AUD_STREAM_PLAYBACK] = rate_idx; #ifdef __AUDIO_RESAMPLE__ - uint32_t mask, val; + uint32_t mask, val; - if (hal_cmu_get_audio_resample_status() && codec_dac_sample_rate[rate_idx].codec_freq != CODEC_FREQ_CRYSTAL) { + if (hal_cmu_get_audio_resample_status() && + codec_dac_sample_rate[rate_idx].codec_freq != CODEC_FREQ_CRYSTAL) { #ifdef CODEC_TIMER - cur_codec_freq = CODEC_FREQ_CRYSTAL; -#endif - if ((codec->REG_0E4 & CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE) == 0 || - resample_rate_idx[AUD_STREAM_PLAYBACK] != rate_idx) { - resample_rate_idx[AUD_STREAM_PLAYBACK] = rate_idx; - codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; - hal_codec_reg_update_delay(); - codec->REG_0F4 = resample_phase_float_to_value(get_playback_resample_phase()); - hal_codec_reg_update_delay(); - codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; - } - - mask = CODEC_CODEC_RESAMPLE_DAC_L_ENABLE | CODEC_CODEC_RESAMPLE_DAC_R_ENABLE; - val = 0; - if (codec_dac_ch_map & AUD_CHANNEL_MAP_CH0) { - val |= CODEC_CODEC_RESAMPLE_DAC_L_ENABLE; - } - if (codec_dac_ch_map & AUD_CHANNEL_MAP_CH1) { - val |= CODEC_CODEC_RESAMPLE_DAC_R_ENABLE; - } - } else { - mask = CODEC_CODEC_RESAMPLE_DAC_L_ENABLE | CODEC_CODEC_RESAMPLE_DAC_R_ENABLE | - CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; - val = 0; - } - codec->REG_0E4 = (codec->REG_0E4 & ~mask) | val; -#endif - - // 8K -> 4ms, 16K -> 2ms, ... - dac_delay_ms = 4 / ((sample_rate + AUD_SAMPRATE_8000 / 2) / AUD_SAMPRATE_8000); - if (dac_delay_ms < 2) { - dac_delay_ms = 2; - } - -#ifdef __AUDIO_RESAMPLE__ - if (!hal_cmu_get_audio_resample_status()) -#endif - { -#ifdef __AUDIO_RESAMPLE__ - ASSERT(codec_dac_sample_rate[rate_idx].codec_freq != CODEC_FREQ_CRYSTAL, - "%s: playback sample rate %u is for resample only", __func__, sample_rate); -#endif - analog_aud_freq_pll_config(codec_dac_sample_rate[rate_idx].codec_freq, codec_dac_sample_rate[rate_idx].codec_div); - hal_cmu_codec_dac_set_div(codec_dac_sample_rate[rate_idx].cmu_div * CODEC_FREQ_EXTRA_DIV); - } - hal_codec_set_dac_up(codec_dac_sample_rate[rate_idx].dac_up); - hal_codec_set_dac_hbf_bypass_cnt(codec_dac_sample_rate[rate_idx].bypass_cnt); -#ifdef AUDIO_ANC_FB_MC - codec->REG_04C = SET_BITFIELD(codec->REG_04C, CODEC_MC_DELAY, codec_dac_sample_rate[rate_idx].mc_delay); + cur_codec_freq = CODEC_FREQ_CRYSTAL; #endif + if ((codec->REG_0E4 & CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE) == 0 || + resample_rate_idx[AUD_STREAM_PLAYBACK] != rate_idx) { + resample_rate_idx[AUD_STREAM_PLAYBACK] = rate_idx; + codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; + hal_codec_reg_update_delay(); + codec->REG_0F4 = + resample_phase_float_to_value(get_playback_resample_phase()); + hal_codec_reg_update_delay(); + codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; } - if (HAL_CODEC_CONFIG_VOL & cfg->set_flag) { - const struct CODEC_DAC_VOL_T *vol_tab_ptr; + mask = CODEC_CODEC_RESAMPLE_DAC_L_ENABLE | + CODEC_CODEC_RESAMPLE_DAC_R_ENABLE; + val = 0; + if (codec_dac_ch_map & AUD_CHANNEL_MAP_CH0) { + val |= CODEC_CODEC_RESAMPLE_DAC_L_ENABLE; + } + if (codec_dac_ch_map & AUD_CHANNEL_MAP_CH1) { + val |= CODEC_CODEC_RESAMPLE_DAC_R_ENABLE; + } + } else { + mask = CODEC_CODEC_RESAMPLE_DAC_L_ENABLE | + CODEC_CODEC_RESAMPLE_DAC_R_ENABLE | + CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; + val = 0; + } + codec->REG_0E4 = (codec->REG_0E4 & ~mask) | val; +#endif - vol_tab_ptr = hal_codec_get_dac_volume(cfg->vol); - if (vol_tab_ptr) { + // 8K -> 4ms, 16K -> 2ms, ... + dac_delay_ms = + 4 / ((sample_rate + AUD_SAMPRATE_8000 / 2) / AUD_SAMPRATE_8000); + if (dac_delay_ms < 2) { + dac_delay_ms = 2; + } + +#ifdef __AUDIO_RESAMPLE__ + if (!hal_cmu_get_audio_resample_status()) +#endif + { +#ifdef __AUDIO_RESAMPLE__ + ASSERT(codec_dac_sample_rate[rate_idx].codec_freq != CODEC_FREQ_CRYSTAL, + "%s: playback sample rate %u is for resample only", __func__, + sample_rate); +#endif + analog_aud_freq_pll_config(codec_dac_sample_rate[rate_idx].codec_freq, + codec_dac_sample_rate[rate_idx].codec_div); + hal_cmu_codec_dac_set_div(codec_dac_sample_rate[rate_idx].cmu_div * + CODEC_FREQ_EXTRA_DIV); + } + hal_codec_set_dac_up(codec_dac_sample_rate[rate_idx].dac_up); + hal_codec_set_dac_hbf_bypass_cnt( + codec_dac_sample_rate[rate_idx].bypass_cnt); +#ifdef AUDIO_ANC_FB_MC + codec->REG_04C = SET_BITFIELD(codec->REG_04C, CODEC_MC_DELAY, + codec_dac_sample_rate[rate_idx].mc_delay); +#endif + } + + if (HAL_CODEC_CONFIG_VOL & cfg->set_flag) { + const struct CODEC_DAC_VOL_T *vol_tab_ptr; + + vol_tab_ptr = hal_codec_get_dac_volume(cfg->vol); + if (vol_tab_ptr) { #ifdef AUDIO_OUTPUT_SW_GAIN - hal_codec_set_sw_gain(vol_tab_ptr->sdac_volume); + hal_codec_set_sw_gain(vol_tab_ptr->sdac_volume); #else - analog_aud_set_dac_gain(vol_tab_ptr->tx_pa_gain); - hal_codec_set_dig_dac_gain(VALID_DAC_MAP, vol_tab_ptr->sdac_volume); + analog_aud_set_dac_gain(vol_tab_ptr->tx_pa_gain); + hal_codec_set_dig_dac_gain(VALID_DAC_MAP, vol_tab_ptr->sdac_volume); #endif #ifdef PERF_TEST_POWER_KEY - // Update performance test power after applying new dac volume - hal_codec_update_perf_test_power(); + // Update performance test power after applying new dac volume + hal_codec_update_perf_test_power(); #endif - } - } - } else { - enum AUD_CHANNEL_MAP_T mic_map; - enum AUD_CHANNEL_MAP_T reserv_map; - uint8_t cnt; - uint8_t ch_idx; - uint32_t cfg_set_mask; - uint32_t cfg_clr_mask; + } + } + } else { + enum AUD_CHANNEL_MAP_T mic_map; + enum AUD_CHANNEL_MAP_T reserv_map; + uint8_t cnt; + uint8_t ch_idx; + uint32_t cfg_set_mask; + uint32_t cfg_clr_mask; #ifdef VOICE_DETECTOR_EN - uint32_t adc_channel_en = 0; + uint32_t adc_channel_en = 0; #endif - mic_map = 0; - if ((HAL_CODEC_CONFIG_CHANNEL_MAP | HAL_CODEC_CONFIG_CHANNEL_NUM) & cfg->set_flag) { - codec_adc_ch_map = 0; - codec_mic_ch_map = 0; - mic_map = cfg->channel_map; - } + mic_map = 0; + if ((HAL_CODEC_CONFIG_CHANNEL_MAP | HAL_CODEC_CONFIG_CHANNEL_NUM) & + cfg->set_flag) { + codec_adc_ch_map = 0; + codec_mic_ch_map = 0; + mic_map = cfg->channel_map; + } - if (mic_map) { - codec_mic_ch_map = mic_map; - reserv_map = 0; + if (mic_map) { + codec_mic_ch_map = mic_map; + reserv_map = 0; #ifdef ANC_APP #if defined(ANC_FF_MIC_CH_L) || defined(ANC_FF_MIC_CH_R) #ifdef ANC_PROD_TEST - if ((ANC_FF_MIC_CH_L & ~NORMAL_MIC_MAP) || (ANC_FF_MIC_CH_L & (ANC_FF_MIC_CH_L - 1))) { - ASSERT(false, "Invalid ANC_FF_MIC_CH_L: 0x%04X", ANC_FF_MIC_CH_L); - } - if ((ANC_FF_MIC_CH_R & ~NORMAL_MIC_MAP) || (ANC_FF_MIC_CH_R & (ANC_FF_MIC_CH_R - 1))) { - ASSERT(false, "Invalid ANC_FF_MIC_CH_R: 0x%04X", ANC_FF_MIC_CH_R); - } - if (ANC_FF_MIC_CH_L & ANC_FF_MIC_CH_R) { - ASSERT(false, "Conflicted ANC_FF_MIC_CH_L (0x%04X) and ANC_FF_MIC_CH_R (0x%04X)", ANC_FF_MIC_CH_L, ANC_FF_MIC_CH_R); - } + if ((ANC_FF_MIC_CH_L & ~NORMAL_MIC_MAP) || + (ANC_FF_MIC_CH_L & (ANC_FF_MIC_CH_L - 1))) { + ASSERT(false, "Invalid ANC_FF_MIC_CH_L: 0x%04X", ANC_FF_MIC_CH_L); + } + if ((ANC_FF_MIC_CH_R & ~NORMAL_MIC_MAP) || + (ANC_FF_MIC_CH_R & (ANC_FF_MIC_CH_R - 1))) { + ASSERT(false, "Invalid ANC_FF_MIC_CH_R: 0x%04X", ANC_FF_MIC_CH_R); + } + if (ANC_FF_MIC_CH_L & ANC_FF_MIC_CH_R) { + ASSERT( + false, + "Conflicted ANC_FF_MIC_CH_L (0x%04X) and ANC_FF_MIC_CH_R (0x%04X)", + ANC_FF_MIC_CH_L, ANC_FF_MIC_CH_R); + } #if defined(ANC_FB_MIC_CH_L) || defined(ANC_FB_MIC_CH_R) - if ((ANC_FF_MIC_CH_L & ANC_FB_MIC_CH_L) || (ANC_FF_MIC_CH_L & ANC_FB_MIC_CH_R) || - (ANC_FF_MIC_CH_R & ANC_FB_MIC_CH_L) || (ANC_FF_MIC_CH_R & ANC_FB_MIC_CH_R)) { - ASSERT(false, "Conflicted FF MIC (0x%04X/0x%04X) and FB MIC (0x%04X/0x%04X)", - ANC_FF_MIC_CH_L, ANC_FF_MIC_CH_R, ANC_FB_MIC_CH_L, ANC_FB_MIC_CH_R); - } + if ((ANC_FF_MIC_CH_L & ANC_FB_MIC_CH_L) || + (ANC_FF_MIC_CH_L & ANC_FB_MIC_CH_R) || + (ANC_FF_MIC_CH_R & ANC_FB_MIC_CH_L) || + (ANC_FF_MIC_CH_R & ANC_FB_MIC_CH_R)) { + ASSERT(false, + "Conflicted FF MIC (0x%04X/0x%04X) and FB MIC (0x%04X/0x%04X)", + ANC_FF_MIC_CH_L, ANC_FF_MIC_CH_R, ANC_FB_MIC_CH_L, + ANC_FB_MIC_CH_R); + } #endif #ifdef VOICE_DETECTOR_EN - if (ANC_FF_MIC_CH_L & AUD_CHANNEL_MAP_CH4) { - ASSERT(false, "Conflicted ANC_FF_MIC_CH_L and VAD MIC"); - } - if (ANC_FF_MIC_CH_R & AUD_CHANNEL_MAP_CH4) { - ASSERT(false, "Conflicted ANC_FF_MIC_CH_R and VAD MIC"); - } + if (ANC_FF_MIC_CH_L & AUD_CHANNEL_MAP_CH4) { + ASSERT(false, "Conflicted ANC_FF_MIC_CH_L and VAD MIC"); + } + if (ANC_FF_MIC_CH_R & AUD_CHANNEL_MAP_CH4) { + ASSERT(false, "Conflicted ANC_FF_MIC_CH_R and VAD MIC"); + } #endif #else // !ANC_PROD_TEST -#if (ANC_FF_MIC_CH_L & ~NORMAL_MIC_MAP) || (ANC_FF_MIC_CH_L & (ANC_FF_MIC_CH_L - 1)) +#if (ANC_FF_MIC_CH_L & ~NORMAL_MIC_MAP) || \ + (ANC_FF_MIC_CH_L & (ANC_FF_MIC_CH_L - 1)) #error "Invalid ANC_FF_MIC_CH_L" #endif -#if (ANC_FF_MIC_CH_R & ~NORMAL_MIC_MAP) || (ANC_FF_MIC_CH_R & (ANC_FF_MIC_CH_R - 1)) +#if (ANC_FF_MIC_CH_R & ~NORMAL_MIC_MAP) || \ + (ANC_FF_MIC_CH_R & (ANC_FF_MIC_CH_R - 1)) #error "Invalid ANC_FF_MIC_CH_R" #endif #if (ANC_FF_MIC_CH_L & ANC_FF_MIC_CH_R) #error "Conflicted ANC_FF_MIC_CH_L and ANC_FF_MIC_CH_R" #endif #if defined(ANC_FB_MIC_CH_L) || defined(ANC_FB_MIC_CH_R) -#if (ANC_FF_MIC_CH_L & ANC_FB_MIC_CH_L) || (ANC_FF_MIC_CH_L & ANC_FB_MIC_CH_R) || \ - (ANC_FF_MIC_CH_R & ANC_FB_MIC_CH_L) || (ANC_FF_MIC_CH_R & ANC_FB_MIC_CH_R) -#error "Conflicted ANC_FF_MIC_CH_L and ANC_FF_MIC_CH_R, ANC_FB_MIC_CH_L, ANC_FB_MIC_CH_R" +#if (ANC_FF_MIC_CH_L & ANC_FB_MIC_CH_L) || \ + (ANC_FF_MIC_CH_L & ANC_FB_MIC_CH_R) || \ + (ANC_FF_MIC_CH_R & ANC_FB_MIC_CH_L) || (ANC_FF_MIC_CH_R & ANC_FB_MIC_CH_R) +#error \ + "Conflicted ANC_FF_MIC_CH_L and ANC_FF_MIC_CH_R, ANC_FB_MIC_CH_L, ANC_FB_MIC_CH_R" #endif #endif #ifdef VOICE_DETECTOR_EN @@ -2346,44 +2534,49 @@ int hal_codec_setup_stream(enum HAL_CODEC_ID_T id, enum AUD_STREAM_T stream, con #endif #endif #endif // !ANC_PROD_TEST - if (mic_map & ANC_FF_MIC_CH_L) { - codec_adc_ch_map |= AUD_CHANNEL_MAP_CH0; - mic_map &= ~ANC_FF_MIC_CH_L; - ch_idx = get_msb_pos(ANC_FF_MIC_CH_L); - if (ANC_FF_MIC_CH_L & AUD_CHANNEL_MAP_DIGMIC_ALL) { - ch_idx = hal_codec_get_digmic_hw_index(ch_idx); - codec->REG_0A8 = SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH0, ch_idx); - codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH0; - } else { - codec->REG_084 = SET_BITFIELD(codec->REG_084, CODEC_CODEC_ADC_IN_SEL_CH0, ch_idx); - codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH0; - } - } else if (ANC_FF_MIC_CH_L & AUD_CHANNEL_MAP_ALL) { - reserv_map |= AUD_CHANNEL_MAP_CH0; - } - if (mic_map & ANC_FF_MIC_CH_R) { - codec_adc_ch_map |= AUD_CHANNEL_MAP_CH1; - mic_map &= ~ANC_FF_MIC_CH_R; - ch_idx = get_msb_pos(ANC_FF_MIC_CH_R); - if (ANC_FF_MIC_CH_R & AUD_CHANNEL_MAP_DIGMIC_ALL) { - ch_idx = hal_codec_get_digmic_hw_index(ch_idx); - codec->REG_0A8 = SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH1, ch_idx); - codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH1; - } else { - codec->REG_088 = SET_BITFIELD(codec->REG_088, CODEC_CODEC_ADC_IN_SEL_CH1, ch_idx); - codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH1; - } - } else if (ANC_FF_MIC_CH_R & AUD_CHANNEL_MAP_ALL) { - reserv_map |= AUD_CHANNEL_MAP_CH1; - } + if (mic_map & ANC_FF_MIC_CH_L) { + codec_adc_ch_map |= AUD_CHANNEL_MAP_CH0; + mic_map &= ~ANC_FF_MIC_CH_L; + ch_idx = get_msb_pos(ANC_FF_MIC_CH_L); + if (ANC_FF_MIC_CH_L & AUD_CHANNEL_MAP_DIGMIC_ALL) { + ch_idx = hal_codec_get_digmic_hw_index(ch_idx); + codec->REG_0A8 = + SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH0, ch_idx); + codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH0; + } else { + codec->REG_084 = + SET_BITFIELD(codec->REG_084, CODEC_CODEC_ADC_IN_SEL_CH0, ch_idx); + codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH0; + } + } else if (ANC_FF_MIC_CH_L & AUD_CHANNEL_MAP_ALL) { + reserv_map |= AUD_CHANNEL_MAP_CH0; + } + if (mic_map & ANC_FF_MIC_CH_R) { + codec_adc_ch_map |= AUD_CHANNEL_MAP_CH1; + mic_map &= ~ANC_FF_MIC_CH_R; + ch_idx = get_msb_pos(ANC_FF_MIC_CH_R); + if (ANC_FF_MIC_CH_R & AUD_CHANNEL_MAP_DIGMIC_ALL) { + ch_idx = hal_codec_get_digmic_hw_index(ch_idx); + codec->REG_0A8 = + SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH1, ch_idx); + codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH1; + } else { + codec->REG_088 = + SET_BITFIELD(codec->REG_088, CODEC_CODEC_ADC_IN_SEL_CH1, ch_idx); + codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH1; + } + } else if (ANC_FF_MIC_CH_R & AUD_CHANNEL_MAP_ALL) { + reserv_map |= AUD_CHANNEL_MAP_CH1; + } #if defined(SIDETONE_ENABLE) && !defined(SIDETONE_DEDICATED_ADC_CHAN) - if (CFG_HW_AUD_SIDETONE_MIC_DEV == ANC_FF_MIC_CH_L) { - hal_codec_set_sidetone_adc_chan(AUD_CHANNEL_MAP_CH0); - } + if (CFG_HW_AUD_SIDETONE_MIC_DEV == ANC_FF_MIC_CH_L) { + hal_codec_set_sidetone_adc_chan(AUD_CHANNEL_MAP_CH0); + } #ifdef ANC_PROD_TEST - if (CFG_HW_AUD_SIDETONE_MIC_DEV == ANC_FF_MIC_CH_R) { - ASSERT(false, "SIDETONE MIC cannot be ANC_FF_MIC_CH_R: 0x%X", ANC_FF_MIC_CH_R); - } + if (CFG_HW_AUD_SIDETONE_MIC_DEV == ANC_FF_MIC_CH_R) { + ASSERT(false, "SIDETONE MIC cannot be ANC_FF_MIC_CH_R: 0x%X", + ANC_FF_MIC_CH_R); + } #elif (CFG_HW_AUD_SIDETONE_MIC_DEV == ANC_FF_MIC_CH_R) #error "SIDETONE MIC cannot be ANC_FF_MIC_CH_R" #endif @@ -2392,28 +2585,35 @@ int hal_codec_setup_stream(enum HAL_CODEC_ID_T id, enum AUD_STREAM_T stream, con #if defined(ANC_FB_MIC_CH_L) || defined(ANC_FB_MIC_CH_R) #ifdef ANC_PROD_TEST - if ((ANC_FB_MIC_CH_L & ~NORMAL_MIC_MAP) || (ANC_FB_MIC_CH_L & (ANC_FB_MIC_CH_L - 1))) { - ASSERT(false, "Invalid ANC_FB_MIC_CH_L: 0x%04X", ANC_FB_MIC_CH_L); - } - if ((ANC_FB_MIC_CH_R & ~NORMAL_MIC_MAP) || (ANC_FB_MIC_CH_R & (ANC_FB_MIC_CH_R - 1))) { - ASSERT(false, "Invalid ANC_FB_MIC_CH_R: 0x%04X", ANC_FB_MIC_CH_R); - } - if (ANC_FB_MIC_CH_L & ANC_FB_MIC_CH_R) { - ASSERT(false, "Conflicted ANC_FB_MIC_CH_L (0x%04X) and ANC_FB_MIC_CH_R (0x%04X)", ANC_FB_MIC_CH_L, ANC_FB_MIC_CH_R); - } + if ((ANC_FB_MIC_CH_L & ~NORMAL_MIC_MAP) || + (ANC_FB_MIC_CH_L & (ANC_FB_MIC_CH_L - 1))) { + ASSERT(false, "Invalid ANC_FB_MIC_CH_L: 0x%04X", ANC_FB_MIC_CH_L); + } + if ((ANC_FB_MIC_CH_R & ~NORMAL_MIC_MAP) || + (ANC_FB_MIC_CH_R & (ANC_FB_MIC_CH_R - 1))) { + ASSERT(false, "Invalid ANC_FB_MIC_CH_R: 0x%04X", ANC_FB_MIC_CH_R); + } + if (ANC_FB_MIC_CH_L & ANC_FB_MIC_CH_R) { + ASSERT( + false, + "Conflicted ANC_FB_MIC_CH_L (0x%04X) and ANC_FB_MIC_CH_R (0x%04X)", + ANC_FB_MIC_CH_L, ANC_FB_MIC_CH_R); + } #ifdef VOICE_DETECTOR_EN - if (ANC_FB_MIC_CH_L & AUD_CHANNEL_MAP_CH4) { - ASSERT(false, "Conflicted ANC_FB_MIC_CH_L and VAD MIC"); - } - if (ANC_FB_MIC_CH_R & AUD_CHANNEL_MAP_CH4) { - ASSERT(false, "Conflicted ANC_FB_MIC_CH_R and VAD MIC"); - } + if (ANC_FB_MIC_CH_L & AUD_CHANNEL_MAP_CH4) { + ASSERT(false, "Conflicted ANC_FB_MIC_CH_L and VAD MIC"); + } + if (ANC_FB_MIC_CH_R & AUD_CHANNEL_MAP_CH4) { + ASSERT(false, "Conflicted ANC_FB_MIC_CH_R and VAD MIC"); + } #endif #else // !ANC_PROD_TEST -#if (ANC_FB_MIC_CH_L & ~NORMAL_MIC_MAP) || (ANC_FB_MIC_CH_L & (ANC_FB_MIC_CH_L - 1)) +#if (ANC_FB_MIC_CH_L & ~NORMAL_MIC_MAP) || \ + (ANC_FB_MIC_CH_L & (ANC_FB_MIC_CH_L - 1)) #error "Invalid ANC_FB_MIC_CH_L" #endif -#if (ANC_FB_MIC_CH_R & ~NORMAL_MIC_MAP) || (ANC_FB_MIC_CH_R & (ANC_FB_MIC_CH_R - 1)) +#if (ANC_FB_MIC_CH_R & ~NORMAL_MIC_MAP) || \ + (ANC_FB_MIC_CH_R & (ANC_FB_MIC_CH_R - 1)) #error "Invalid ANC_FB_MIC_CH_R" #endif #if (ANC_FB_MIC_CH_L & ANC_FB_MIC_CH_R) @@ -2428,44 +2628,49 @@ int hal_codec_setup_stream(enum HAL_CODEC_ID_T id, enum AUD_STREAM_T stream, con #endif #endif #endif // !ANC_PROD_TEST - if (mic_map & ANC_FB_MIC_CH_L) { - codec_adc_ch_map |= AUD_CHANNEL_MAP_CH2; - mic_map &= ~ANC_FB_MIC_CH_L; - ch_idx = get_msb_pos(ANC_FB_MIC_CH_L); - if (ANC_FB_MIC_CH_L & AUD_CHANNEL_MAP_DIGMIC_ALL) { - ch_idx = hal_codec_get_digmic_hw_index(ch_idx); - codec->REG_0A8 = SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH2, ch_idx); - codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH2; - } else { - codec->REG_08C = SET_BITFIELD(codec->REG_08C, CODEC_CODEC_ADC_IN_SEL_CH2, ch_idx); - codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH2; - } - } else if (ANC_FB_MIC_CH_L & AUD_CHANNEL_MAP_ALL) { - reserv_map |= AUD_CHANNEL_MAP_CH2; - } - if (mic_map & ANC_FB_MIC_CH_R) { - codec_adc_ch_map |= AUD_CHANNEL_MAP_CH3; - mic_map &= ~ANC_FB_MIC_CH_R; - ch_idx = get_msb_pos(ANC_FB_MIC_CH_R); - if (ANC_FB_MIC_CH_R & AUD_CHANNEL_MAP_DIGMIC_ALL) { - ch_idx = hal_codec_get_digmic_hw_index(ch_idx); - codec->REG_0A8 = SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH3, ch_idx); - codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH3; - } else { - codec->REG_090 = SET_BITFIELD(codec->REG_090, CODEC_CODEC_ADC_IN_SEL_CH3, ch_idx); - codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH3; - } - } else if (ANC_FB_MIC_CH_R & AUD_CHANNEL_MAP_ALL) { - reserv_map |= AUD_CHANNEL_MAP_CH3; - } + if (mic_map & ANC_FB_MIC_CH_L) { + codec_adc_ch_map |= AUD_CHANNEL_MAP_CH2; + mic_map &= ~ANC_FB_MIC_CH_L; + ch_idx = get_msb_pos(ANC_FB_MIC_CH_L); + if (ANC_FB_MIC_CH_L & AUD_CHANNEL_MAP_DIGMIC_ALL) { + ch_idx = hal_codec_get_digmic_hw_index(ch_idx); + codec->REG_0A8 = + SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH2, ch_idx); + codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH2; + } else { + codec->REG_08C = + SET_BITFIELD(codec->REG_08C, CODEC_CODEC_ADC_IN_SEL_CH2, ch_idx); + codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH2; + } + } else if (ANC_FB_MIC_CH_L & AUD_CHANNEL_MAP_ALL) { + reserv_map |= AUD_CHANNEL_MAP_CH2; + } + if (mic_map & ANC_FB_MIC_CH_R) { + codec_adc_ch_map |= AUD_CHANNEL_MAP_CH3; + mic_map &= ~ANC_FB_MIC_CH_R; + ch_idx = get_msb_pos(ANC_FB_MIC_CH_R); + if (ANC_FB_MIC_CH_R & AUD_CHANNEL_MAP_DIGMIC_ALL) { + ch_idx = hal_codec_get_digmic_hw_index(ch_idx); + codec->REG_0A8 = + SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH3, ch_idx); + codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH3; + } else { + codec->REG_090 = + SET_BITFIELD(codec->REG_090, CODEC_CODEC_ADC_IN_SEL_CH3, ch_idx); + codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH3; + } + } else if (ANC_FB_MIC_CH_R & AUD_CHANNEL_MAP_ALL) { + reserv_map |= AUD_CHANNEL_MAP_CH3; + } #if defined(SIDETONE_ENABLE) && !defined(SIDETONE_DEDICATED_ADC_CHAN) - if (CFG_HW_AUD_SIDETONE_MIC_DEV == ANC_FB_MIC_CH_L) { - hal_codec_set_sidetone_adc_chan(AUD_CHANNEL_MAP_CH2); - } + if (CFG_HW_AUD_SIDETONE_MIC_DEV == ANC_FB_MIC_CH_L) { + hal_codec_set_sidetone_adc_chan(AUD_CHANNEL_MAP_CH2); + } #ifdef ANC_PROD_TEST - if (CFG_HW_AUD_SIDETONE_MIC_DEV == ANC_FB_MIC_CH_R) { - ASSERT(false, "SIDETONE MIC cannot be ANC_FB_MIC_CH_R: 0x%X", ANC_FB_MIC_CH_R); - } + if (CFG_HW_AUD_SIDETONE_MIC_DEV == ANC_FB_MIC_CH_R) { + ASSERT(false, "SIDETONE MIC cannot be ANC_FB_MIC_CH_R: 0x%X", + ANC_FB_MIC_CH_R); + } #elif (CFG_HW_AUD_SIDETONE_MIC_DEV == ANC_FB_MIC_CH_R) #error "SIDETONE MIC cannot be ANC_FB_MIC_CH_R" #endif @@ -2474,1211 +2679,1236 @@ int hal_codec_setup_stream(enum HAL_CODEC_ID_T id, enum AUD_STREAM_T stream, con #endif // ANC_APP #ifdef CODEC_DSD - reserv_map |= AUD_CHANNEL_MAP_CH2 | AUD_CHANNEL_MAP_CH3; + reserv_map |= AUD_CHANNEL_MAP_CH2 | AUD_CHANNEL_MAP_CH3; #endif - if (mic_map & AUD_CHANNEL_MAP_CH4) { - codec_adc_ch_map |= AUD_CHANNEL_MAP_CH4; - mic_map &= ~AUD_CHANNEL_MAP_CH4; - codec->REG_094 = SET_BITFIELD(codec->REG_094, CODEC_CODEC_ADC_IN_SEL_CH4, 4); - codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH4; + if (mic_map & AUD_CHANNEL_MAP_CH4) { + codec_adc_ch_map |= AUD_CHANNEL_MAP_CH4; + mic_map &= ~AUD_CHANNEL_MAP_CH4; + codec->REG_094 = + SET_BITFIELD(codec->REG_094, CODEC_CODEC_ADC_IN_SEL_CH4, 4); + codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH4; #if defined(SIDETONE_ENABLE) && !defined(SIDETONE_DEDICATED_ADC_CHAN) - if (CFG_HW_AUD_SIDETONE_MIC_DEV == AUD_CHANNEL_MAP_CH4) { - hal_codec_set_sidetone_adc_chan(AUD_CHANNEL_MAP_CH4); - } + if (CFG_HW_AUD_SIDETONE_MIC_DEV == AUD_CHANNEL_MAP_CH4) { + hal_codec_set_sidetone_adc_chan(AUD_CHANNEL_MAP_CH4); + } #endif - } - if (mic_map & AUD_CHANNEL_MAP_ECMIC_CH0) { - codec_adc_ch_map |= AUD_CHANNEL_MAP_CH5; - mic_map &= ~AUD_CHANNEL_MAP_ECMIC_CH0; - codec->REG_228 &= ~CODEC_CODEC_MC_SEL_CH0; - } - if (mic_map & AUD_CHANNEL_MAP_ECMIC_CH1) { - codec_adc_ch_map |= AUD_CHANNEL_MAP_CH6; - mic_map &= ~AUD_CHANNEL_MAP_ECMIC_CH1; - codec->REG_228 |= CODEC_CODEC_MC_SEL_CH1; - } + } + if (mic_map & AUD_CHANNEL_MAP_ECMIC_CH0) { + codec_adc_ch_map |= AUD_CHANNEL_MAP_CH5; + mic_map &= ~AUD_CHANNEL_MAP_ECMIC_CH0; + codec->REG_228 &= ~CODEC_CODEC_MC_SEL_CH0; + } + if (mic_map & AUD_CHANNEL_MAP_ECMIC_CH1) { + codec_adc_ch_map |= AUD_CHANNEL_MAP_CH6; + mic_map &= ~AUD_CHANNEL_MAP_ECMIC_CH1; + codec->REG_228 |= CODEC_CODEC_MC_SEL_CH1; + } - reserv_map |= codec_adc_ch_map; + reserv_map |= codec_adc_ch_map; #ifdef CODEC_MIN_PHASE - if (min_phase_cfg & (1 << AUD_STREAM_CAPTURE)) { - if (mic_map && (reserv_map & AUD_CHANNEL_MAP_CH2) == 0) { - codec_adc_ch_map |= AUD_CHANNEL_MAP_CH2; - reserv_map |= codec_adc_ch_map; - ch_idx = get_lsb_pos(mic_map); - mic_map &= ~(1 << ch_idx); - if ((1 << ch_idx) & AUD_CHANNEL_MAP_DIGMIC_ALL) { - ch_idx = hal_codec_get_digmic_hw_index(ch_idx); - codec->REG_0A8 = SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH2, ch_idx); - codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH2; - } else { - codec->REG_08C = SET_BITFIELD(codec->REG_08C, CODEC_CODEC_ADC_IN_SEL_CH2, ch_idx); - codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH2; - } - } - if (mic_map && (reserv_map & AUD_CHANNEL_MAP_CH3) == 0) { - codec_adc_ch_map |= AUD_CHANNEL_MAP_CH3; - reserv_map |= codec_adc_ch_map; - ch_idx = get_lsb_pos(mic_map); - mic_map &= ~(1 << ch_idx); - if ((1 << ch_idx) & AUD_CHANNEL_MAP_DIGMIC_ALL) { - ch_idx = hal_codec_get_digmic_hw_index(ch_idx); - codec->REG_0A8 = SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH3, ch_idx); - codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH3; - } else { - codec->REG_090 = SET_BITFIELD(codec->REG_090, CODEC_CODEC_ADC_IN_SEL_CH3, ch_idx); - codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH3; - } - } - } + if (min_phase_cfg & (1 << AUD_STREAM_CAPTURE)) { + if (mic_map && (reserv_map & AUD_CHANNEL_MAP_CH2) == 0) { + codec_adc_ch_map |= AUD_CHANNEL_MAP_CH2; + reserv_map |= codec_adc_ch_map; + ch_idx = get_lsb_pos(mic_map); + mic_map &= ~(1 << ch_idx); + if ((1 << ch_idx) & AUD_CHANNEL_MAP_DIGMIC_ALL) { + ch_idx = hal_codec_get_digmic_hw_index(ch_idx); + codec->REG_0A8 = + SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH2, ch_idx); + codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH2; + } else { + codec->REG_08C = SET_BITFIELD(codec->REG_08C, + CODEC_CODEC_ADC_IN_SEL_CH2, ch_idx); + codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH2; + } + } + if (mic_map && (reserv_map & AUD_CHANNEL_MAP_CH3) == 0) { + codec_adc_ch_map |= AUD_CHANNEL_MAP_CH3; + reserv_map |= codec_adc_ch_map; + ch_idx = get_lsb_pos(mic_map); + mic_map &= ~(1 << ch_idx); + if ((1 << ch_idx) & AUD_CHANNEL_MAP_DIGMIC_ALL) { + ch_idx = hal_codec_get_digmic_hw_index(ch_idx); + codec->REG_0A8 = + SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH3, ch_idx); + codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH3; + } else { + codec->REG_090 = SET_BITFIELD(codec->REG_090, + CODEC_CODEC_ADC_IN_SEL_CH3, ch_idx); + codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH3; + } + } + } #endif #ifdef SIDETONE_ENABLE #if defined(SIDETONE_DEDICATED_ADC_CHAN) || defined(SIDETONE_RESERVED_ADC_CHAN) - if (mic_map & CFG_HW_AUD_SIDETONE_MIC_DEV) { - enum AUD_CHANNEL_MAP_T st_map = 0; + if (mic_map & CFG_HW_AUD_SIDETONE_MIC_DEV) { + enum AUD_CHANNEL_MAP_T st_map = 0; - // Alloc sidetone adc chan - if ((reserv_map & AUD_CHANNEL_MAP_CH0) == 0) { - st_map = AUD_CHANNEL_MAP_CH0; - } else if ((reserv_map & AUD_CHANNEL_MAP_CH2) == 0) { - st_map = AUD_CHANNEL_MAP_CH2; - } else if ((reserv_map & AUD_CHANNEL_MAP_CH4) == 0) { - st_map = AUD_CHANNEL_MAP_CH4; - } else { - ASSERT(false, "%s: Cannot alloc dedicated sidetone adc: reserv_map=0x%X", __func__, reserv_map); - } - // Associate mic and sidetone adc - hal_codec_set_sidetone_adc_chan(st_map); - ch_idx = get_lsb_pos(CFG_HW_AUD_SIDETONE_MIC_DEV); - i = get_lsb_pos(st_map); - if ((1 << ch_idx) & AUD_CHANNEL_MAP_DIGMIC_ALL) { - ch_idx = hal_codec_get_digmic_hw_index(ch_idx); - codec->REG_0A8 = (codec->REG_0A8 & ~(CODEC_CODEC_PDM_MUX_CH0_MASK << (3 * i))) | - (CODEC_CODEC_PDM_MUX_CH0(ch_idx) << (3 * i)); - codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH0 << i; - } else { - *(&codec->REG_084 + i) = SET_BITFIELD(*(&codec->REG_084 + i), CODEC_CODEC_ADC_IN_SEL_CH0, ch_idx); - codec->REG_0A4 &= ~(CODEC_CODEC_PDM_ADC_SEL_CH0 << i); - } + // Alloc sidetone adc chan + if ((reserv_map & AUD_CHANNEL_MAP_CH0) == 0) { + st_map = AUD_CHANNEL_MAP_CH0; + } else if ((reserv_map & AUD_CHANNEL_MAP_CH2) == 0) { + st_map = AUD_CHANNEL_MAP_CH2; + } else if ((reserv_map & AUD_CHANNEL_MAP_CH4) == 0) { + st_map = AUD_CHANNEL_MAP_CH4; + } else { + ASSERT(false, + "%s: Cannot alloc dedicated sidetone adc: reserv_map=0x%X", + __func__, reserv_map); + } + // Associate mic and sidetone adc + hal_codec_set_sidetone_adc_chan(st_map); + ch_idx = get_lsb_pos(CFG_HW_AUD_SIDETONE_MIC_DEV); + i = get_lsb_pos(st_map); + if ((1 << ch_idx) & AUD_CHANNEL_MAP_DIGMIC_ALL) { + ch_idx = hal_codec_get_digmic_hw_index(ch_idx); + codec->REG_0A8 = + (codec->REG_0A8 & ~(CODEC_CODEC_PDM_MUX_CH0_MASK << (3 * i))) | + (CODEC_CODEC_PDM_MUX_CH0(ch_idx) << (3 * i)); + codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH0 << i; + } else { + *(&codec->REG_084 + i) = SET_BITFIELD( + *(&codec->REG_084 + i), CODEC_CODEC_ADC_IN_SEL_CH0, ch_idx); + codec->REG_0A4 &= ~(CODEC_CODEC_PDM_ADC_SEL_CH0 << i); + } #ifdef SIDETONE_DEDICATED_ADC_CHAN - sidetone_adc_ch_map = st_map; + sidetone_adc_ch_map = st_map; #else - mic_map &= ~(1 << ch_idx); - codec_adc_ch_map |= st_map; + mic_map &= ~(1 << ch_idx); + codec_adc_ch_map |= st_map; #endif - // Mark sidetone adc as used - reserv_map |= st_map; - } + // Mark sidetone adc as used + reserv_map |= st_map; + } #endif #endif + i = 0; + while (mic_map && i < NORMAL_ADC_CH_NUM) { + ASSERT(i < MAX_ANA_MIC_CH_NUM || (mic_map & AUD_CHANNEL_MAP_DIGMIC_ALL), + "%s: Not enough ana cap chan: mic_map=0x%X adc_map=0x%X " + "reserv_map=0x%X", + __func__, mic_map, codec_adc_ch_map, reserv_map); + ch_idx = get_lsb_pos(mic_map); + mic_map &= ~(1 << ch_idx); + while ((reserv_map & (AUD_CHANNEL_MAP_CH0 << i)) && + i < NORMAL_ADC_CH_NUM) { + i++; + } +#if defined(SIDETONE_ENABLE) && !(defined(SIDETONE_DEDICATED_ADC_CHAN) || \ + defined(SIDETONE_RESERVED_ADC_CHAN)) + if (CFG_HW_AUD_SIDETONE_MIC_DEV == (1 << ch_idx)) { + if ((reserv_map & AUD_CHANNEL_MAP_CH0) == 0) { i = 0; - while (mic_map && i < NORMAL_ADC_CH_NUM) { - ASSERT(i < MAX_ANA_MIC_CH_NUM || (mic_map & AUD_CHANNEL_MAP_DIGMIC_ALL), - "%s: Not enough ana cap chan: mic_map=0x%X adc_map=0x%X reserv_map=0x%X", - __func__, mic_map, codec_adc_ch_map, reserv_map); - ch_idx = get_lsb_pos(mic_map); - mic_map &= ~(1 << ch_idx); - while ((reserv_map & (AUD_CHANNEL_MAP_CH0 << i)) && i < NORMAL_ADC_CH_NUM) { - i++; - } -#if defined(SIDETONE_ENABLE) && !(defined(SIDETONE_DEDICATED_ADC_CHAN) || defined(SIDETONE_RESERVED_ADC_CHAN)) - if (CFG_HW_AUD_SIDETONE_MIC_DEV == (1 << ch_idx)) { - if ((reserv_map & AUD_CHANNEL_MAP_CH0) == 0) { - i = 0; - } else if ((reserv_map & AUD_CHANNEL_MAP_CH2) == 0) { - i = 2; - } else if ((reserv_map & AUD_CHANNEL_MAP_CH4) == 0) { - i = 4; - } else { - ASSERT(false, "%s: No sidetone adc: reserv_map=0x%X. Try SIDETONE_RESERVED_ADC_CHAN", __func__, reserv_map); - } - hal_codec_set_sidetone_adc_chan((1 << i)); - } -#endif - if (i < NORMAL_ADC_CH_NUM) { - codec_adc_ch_map |= (AUD_CHANNEL_MAP_CH0 << i); - reserv_map |= codec_adc_ch_map; - if ((1 << ch_idx) & AUD_CHANNEL_MAP_DIGMIC_ALL) { - ch_idx = hal_codec_get_digmic_hw_index(ch_idx); - codec->REG_0A8 = (codec->REG_0A8 & ~(CODEC_CODEC_PDM_MUX_CH0_MASK << (3 * i))) | - (CODEC_CODEC_PDM_MUX_CH0(ch_idx) << (3 * i)); - codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH0 << i; - } else { - *(&codec->REG_084 + i) = SET_BITFIELD(*(&codec->REG_084 + i), CODEC_CODEC_ADC_IN_SEL_CH0, ch_idx); - codec->REG_0A4 &= ~(CODEC_CODEC_PDM_ADC_SEL_CH0 << i); - } - i++; - } - } - -#if defined(SIDETONE_ENABLE) && !(defined(SIDETONE_DEDICATED_ADC_CHAN) || defined(SIDETONE_RESERVED_ADC_CHAN)) - if (mic_map) { - if (reserv_map + 1 < (1 << NORMAL_ADC_CH_NUM)) { - ASSERT(false, "%s: No adc due to sidetone mic_map=0x%X reserv_map=0x%X. Try SIDETONE_RESERVED_ADC_CHAN", - __func__, mic_map, reserv_map); - } - } -#endif - ASSERT(mic_map == 0, "%s: Bad cap chan map: 0x%X reserv_map=0x%X", __func__, mic_map, reserv_map); + } else if ((reserv_map & AUD_CHANNEL_MAP_CH2) == 0) { + i = 2; + } else if ((reserv_map & AUD_CHANNEL_MAP_CH4) == 0) { + i = 4; + } else { + ASSERT(false, + "%s: No sidetone adc: reserv_map=0x%X. Try " + "SIDETONE_RESERVED_ADC_CHAN", + __func__, reserv_map); + } + hal_codec_set_sidetone_adc_chan((1 << i)); } +#endif + if (i < NORMAL_ADC_CH_NUM) { + codec_adc_ch_map |= (AUD_CHANNEL_MAP_CH0 << i); + reserv_map |= codec_adc_ch_map; + if ((1 << ch_idx) & AUD_CHANNEL_MAP_DIGMIC_ALL) { + ch_idx = hal_codec_get_digmic_hw_index(ch_idx); + codec->REG_0A8 = + (codec->REG_0A8 & ~(CODEC_CODEC_PDM_MUX_CH0_MASK << (3 * i))) | + (CODEC_CODEC_PDM_MUX_CH0(ch_idx) << (3 * i)); + codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH0 << i; + } else { + *(&codec->REG_084 + i) = SET_BITFIELD( + *(&codec->REG_084 + i), CODEC_CODEC_ADC_IN_SEL_CH0, ch_idx); + codec->REG_0A4 &= ~(CODEC_CODEC_PDM_ADC_SEL_CH0 << i); + } + i++; + } + } - if (HAL_CODEC_CONFIG_BITS & cfg->set_flag) { - cfg_set_mask = 0; - cfg_clr_mask = CODEC_MODE_16BIT_ADC_CH0 | CODEC_MODE_16BIT_ADC_CH1 | CODEC_MODE_16BIT_ADC_CH2 | - CODEC_MODE_16BIT_ADC_CH3 | CODEC_MODE_16BIT_ADC_CH4 | CODEC_MODE_16BIT_ADC_CH5 | CODEC_MODE_16BIT_ADC_CH6 | - CODEC_MODE_24BIT_ADC | CODEC_MODE_32BIT_ADC; - if (cfg->bits == AUD_BITS_16) { - cfg_set_mask |= CODEC_MODE_16BIT_ADC_CH0 | CODEC_MODE_16BIT_ADC_CH1 | CODEC_MODE_16BIT_ADC_CH2 | - CODEC_MODE_16BIT_ADC_CH3 | CODEC_MODE_16BIT_ADC_CH4 | CODEC_MODE_16BIT_ADC_CH5 | CODEC_MODE_16BIT_ADC_CH6; - } else if (cfg->bits == AUD_BITS_24) { - cfg_set_mask |= CODEC_MODE_24BIT_ADC; - } else if (cfg->bits == AUD_BITS_32) { - cfg_set_mask |= CODEC_MODE_32BIT_ADC; - } else { - ASSERT(false, "%s: Bad cap bits: %d", __func__, cfg->bits); - } +#if defined(SIDETONE_ENABLE) && !(defined(SIDETONE_DEDICATED_ADC_CHAN) || \ + defined(SIDETONE_RESERVED_ADC_CHAN)) + if (mic_map) { + if (reserv_map + 1 < (1 << NORMAL_ADC_CH_NUM)) { + ASSERT(false, + "%s: No adc due to sidetone mic_map=0x%X reserv_map=0x%X. Try " + "SIDETONE_RESERVED_ADC_CHAN", + __func__, mic_map, reserv_map); + } + } +#endif + ASSERT(mic_map == 0, "%s: Bad cap chan map: 0x%X reserv_map=0x%X", + __func__, mic_map, reserv_map); + } + + if (HAL_CODEC_CONFIG_BITS & cfg->set_flag) { + cfg_set_mask = 0; + cfg_clr_mask = CODEC_MODE_16BIT_ADC_CH0 | CODEC_MODE_16BIT_ADC_CH1 | + CODEC_MODE_16BIT_ADC_CH2 | CODEC_MODE_16BIT_ADC_CH3 | + CODEC_MODE_16BIT_ADC_CH4 | CODEC_MODE_16BIT_ADC_CH5 | + CODEC_MODE_16BIT_ADC_CH6 | CODEC_MODE_24BIT_ADC | + CODEC_MODE_32BIT_ADC; + if (cfg->bits == AUD_BITS_16) { + cfg_set_mask |= CODEC_MODE_16BIT_ADC_CH0 | CODEC_MODE_16BIT_ADC_CH1 | + CODEC_MODE_16BIT_ADC_CH2 | CODEC_MODE_16BIT_ADC_CH3 | + CODEC_MODE_16BIT_ADC_CH4 | CODEC_MODE_16BIT_ADC_CH5 | + CODEC_MODE_16BIT_ADC_CH6; + } else if (cfg->bits == AUD_BITS_24) { + cfg_set_mask |= CODEC_MODE_24BIT_ADC; + } else if (cfg->bits == AUD_BITS_32) { + cfg_set_mask |= CODEC_MODE_32BIT_ADC; + } else { + ASSERT(false, "%s: Bad cap bits: %d", __func__, cfg->bits); + } #ifdef VOICE_DETECTOR_EN - for (int i = 0; i < MAX_ADC_CH_NUM; i++){ - adc_channel_en |= (CODEC_ADC_ENABLE_CH0 << i); - } + for (int i = 0; i < MAX_ADC_CH_NUM; i++) { + adc_channel_en |= (CODEC_ADC_ENABLE_CH0 << i); + } - if(((codec->REG_000 & adc_channel_en) != 0) && ((codec->REG_040 & cfg_set_mask) == 0)){ - ASSERT(false, "%s: Cap bits conflict: %d", __func__, cfg->bits); - }else + if (((codec->REG_000 & adc_channel_en) != 0) && + ((codec->REG_040 & cfg_set_mask) == 0)) { + ASSERT(false, "%s: Cap bits conflict: %d", __func__, cfg->bits); + } else #endif - codec->REG_040 = (codec->REG_040 & ~cfg_clr_mask) | cfg_set_mask; + codec->REG_040 = (codec->REG_040 & ~cfg_clr_mask) | cfg_set_mask; + } + + cnt = 0; + for (i = 0; i < MAX_ADC_CH_NUM; i++) { + if (codec_adc_ch_map & (AUD_CHANNEL_MAP_CH0 << i)) { + cnt++; + } + } + ASSERT(cnt == cfg->channel_num, + "%s: Invalid capture stream chan cfg: map=0x%X num=%u", __func__, + codec_adc_ch_map, cfg->channel_num); + + if (HAL_CODEC_CONFIG_SAMPLE_RATE & cfg->set_flag) { + sample_rate = cfg->sample_rate; + + for (i = 0; i < ARRAY_SIZE(codec_adc_sample_rate); i++) { + if (codec_adc_sample_rate[i].sample_rate == sample_rate) { + break; + } + } + ASSERT(i < ARRAY_SIZE(codec_adc_sample_rate), + "%s: Invalid capture sample rate: %d", __func__, sample_rate); + rate_idx = i; + ana_dig_div = codec_adc_sample_rate[rate_idx].codec_div / + codec_adc_sample_rate[rate_idx].cmu_div; + ASSERT(ana_dig_div * codec_adc_sample_rate[rate_idx].cmu_div == + codec_adc_sample_rate[rate_idx].codec_div, + "%s: Invalid catpure div for rate %u: codec_div=%u cmu_div=%u", + __func__, sample_rate, codec_adc_sample_rate[rate_idx].codec_div, + codec_adc_sample_rate[rate_idx].cmu_div); + + TRACE(2, "[%s] capture sample_rate=%d", __func__, sample_rate); + +#ifdef CODEC_TIMER + cur_codec_freq = codec_adc_sample_rate[rate_idx].codec_freq; +#endif + + codec_rate_idx[AUD_STREAM_CAPTURE] = rate_idx; + + if (codec_adc_ch_map & EC_ADC_MAP) { + // If EC enabled, init resample-adc-ch0 to adc0 + codec->REG_0E4 = + SET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_ADC_CH0_SEL, 0); + } + + uint32_t normal_chan_num; + + normal_chan_num = cfg->channel_num; + if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH5) { + normal_chan_num--; + } + if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH6) { + normal_chan_num--; + } + +#ifdef __AUDIO_RESAMPLE__ + uint32_t mask, val; + + if (hal_cmu_get_audio_resample_status() && + codec_adc_sample_rate[rate_idx].codec_freq != CODEC_FREQ_CRYSTAL) { + ASSERT(normal_chan_num <= AUD_CHANNEL_NUM_2, + "%s: Invalid capture resample chan num: %d/%d map=0x%X", + __func__, normal_chan_num, cfg->channel_num, cfg->channel_map); +#ifdef CODEC_TIMER + cur_codec_freq = CODEC_FREQ_CRYSTAL; +#endif + if ((codec->REG_0E4 & CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE) == 0 || + resample_rate_idx[AUD_STREAM_CAPTURE] != rate_idx) { + resample_rate_idx[AUD_STREAM_CAPTURE] = rate_idx; + codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; + hal_codec_reg_update_delay(); + codec->REG_0F8 = + resample_phase_float_to_value(get_capture_resample_phase()); + hal_codec_reg_update_delay(); + codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; } + mask = CODEC_CODEC_RESAMPLE_ADC_DUAL_CH | + CODEC_CODEC_RESAMPLE_ADC_CH0_SEL_MASK | + CODEC_CODEC_RESAMPLE_ADC_CH1_SEL_MASK; + val = 0; cnt = 0; - for (i = 0; i < MAX_ADC_CH_NUM; i++) { - if (codec_adc_ch_map & (AUD_CHANNEL_MAP_CH0 << i)) { - cnt++; - } - } - ASSERT(cnt == cfg->channel_num, "%s: Invalid capture stream chan cfg: map=0x%X num=%u", - __func__, codec_adc_ch_map, cfg->channel_num); - - if (HAL_CODEC_CONFIG_SAMPLE_RATE & cfg->set_flag) { - sample_rate = cfg->sample_rate; - - for(i = 0; i < ARRAY_SIZE(codec_adc_sample_rate); i++) { - if(codec_adc_sample_rate[i].sample_rate == sample_rate) { - break; - } - } - ASSERT(i < ARRAY_SIZE(codec_adc_sample_rate), "%s: Invalid capture sample rate: %d", __func__, sample_rate); - rate_idx = i; - ana_dig_div = codec_adc_sample_rate[rate_idx].codec_div / codec_adc_sample_rate[rate_idx].cmu_div; - ASSERT(ana_dig_div * codec_adc_sample_rate[rate_idx].cmu_div == codec_adc_sample_rate[rate_idx].codec_div, - "%s: Invalid catpure div for rate %u: codec_div=%u cmu_div=%u", __func__, sample_rate, - codec_adc_sample_rate[rate_idx].codec_div, codec_adc_sample_rate[rate_idx].cmu_div); - - TRACE(2,"[%s] capture sample_rate=%d", __func__, sample_rate); - -#ifdef CODEC_TIMER - cur_codec_freq = codec_adc_sample_rate[rate_idx].codec_freq; -#endif - - codec_rate_idx[AUD_STREAM_CAPTURE] = rate_idx; - - if (codec_adc_ch_map & EC_ADC_MAP) { - // If EC enabled, init resample-adc-ch0 to adc0 - codec->REG_0E4 = SET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_ADC_CH0_SEL, 0); - } - - uint32_t normal_chan_num; - - normal_chan_num = cfg->channel_num; - if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH5) { - normal_chan_num--; - } - if (codec_adc_ch_map & AUD_CHANNEL_MAP_CH6) { - normal_chan_num--; - } - -#ifdef __AUDIO_RESAMPLE__ - uint32_t mask, val; - - if (hal_cmu_get_audio_resample_status() && codec_adc_sample_rate[rate_idx].codec_freq != CODEC_FREQ_CRYSTAL) { - ASSERT(normal_chan_num <= AUD_CHANNEL_NUM_2, - "%s: Invalid capture resample chan num: %d/%d map=0x%X", __func__, normal_chan_num, cfg->channel_num, cfg->channel_map); -#ifdef CODEC_TIMER - cur_codec_freq = CODEC_FREQ_CRYSTAL; -#endif - if ((codec->REG_0E4 & CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE) == 0 || - resample_rate_idx[AUD_STREAM_CAPTURE] != rate_idx) { - resample_rate_idx[AUD_STREAM_CAPTURE] = rate_idx; - codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; - hal_codec_reg_update_delay(); - codec->REG_0F8 = resample_phase_float_to_value(get_capture_resample_phase()); - hal_codec_reg_update_delay(); - codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; - } - - mask = CODEC_CODEC_RESAMPLE_ADC_DUAL_CH | - CODEC_CODEC_RESAMPLE_ADC_CH0_SEL_MASK | CODEC_CODEC_RESAMPLE_ADC_CH1_SEL_MASK; - val = 0; - cnt = 0; - for (i = 0; i < NORMAL_ADC_CH_NUM; i++) { - if (codec_adc_ch_map & (AUD_CHANNEL_MAP_CH0 << i)) { - if (cnt == 0) { - val |= CODEC_CODEC_RESAMPLE_ADC_CH0_SEL(i); - } else { - val |= CODEC_CODEC_RESAMPLE_ADC_CH1_SEL(i); - } - cnt++; - } - } - if (normal_chan_num == AUD_CHANNEL_NUM_2) { - val |= CODEC_CODEC_RESAMPLE_ADC_DUAL_CH; - } + for (i = 0; i < NORMAL_ADC_CH_NUM; i++) { + if (codec_adc_ch_map & (AUD_CHANNEL_MAP_CH0 << i)) { + if (cnt == 0) { + val |= CODEC_CODEC_RESAMPLE_ADC_CH0_SEL(i); } else { - mask = CODEC_CODEC_RESAMPLE_ADC_DUAL_CH | - CODEC_CODEC_RESAMPLE_ADC_CH0_SEL_MASK | CODEC_CODEC_RESAMPLE_ADC_CH1_SEL_MASK | - CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; - val = 0; + val |= CODEC_CODEC_RESAMPLE_ADC_CH1_SEL(i); } - codec->REG_0E4 = (codec->REG_0E4 & ~mask) | val; -#endif - - // Echo cancel channels will check the enable signal of resample ADC CH0, even when resample is disabled - if (codec_adc_ch_map & EC_ADC_MAP) { - if (normal_chan_num && (codec->REG_0E4 & CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE) == 0) { - for (i = 0; i < NORMAL_ADC_CH_NUM; i++) { - if (codec_adc_ch_map & (AUD_CHANNEL_MAP_CH0 << i)) { - codec->REG_0E4 = SET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_ADC_CH0_SEL, i); - break; - } - } - } - } - -#ifdef __AUDIO_RESAMPLE__ - if (!hal_cmu_get_audio_resample_status()) -#endif - { -#ifdef __AUDIO_RESAMPLE__ - ASSERT(codec_adc_sample_rate[rate_idx].codec_freq != CODEC_FREQ_CRYSTAL, - "%s: capture sample rate %u is for resample only", __func__, sample_rate); -#endif - analog_aud_freq_pll_config(codec_adc_sample_rate[rate_idx].codec_freq, codec_adc_sample_rate[rate_idx].codec_div); - hal_cmu_codec_adc_set_div(codec_adc_sample_rate[rate_idx].cmu_div * CODEC_FREQ_EXTRA_DIV); - } - hal_codec_set_adc_down(codec_adc_ch_map, codec_adc_sample_rate[rate_idx].adc_down); - hal_codec_set_adc_hbf_bypass_cnt(codec_adc_ch_map, codec_adc_sample_rate[rate_idx].bypass_cnt); + cnt++; + } } + if (normal_chan_num == AUD_CHANNEL_NUM_2) { + val |= CODEC_CODEC_RESAMPLE_ADC_DUAL_CH; + } + } else { + mask = CODEC_CODEC_RESAMPLE_ADC_DUAL_CH | + CODEC_CODEC_RESAMPLE_ADC_CH0_SEL_MASK | + CODEC_CODEC_RESAMPLE_ADC_CH1_SEL_MASK | + CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; + val = 0; + } + codec->REG_0E4 = (codec->REG_0E4 & ~mask) | val; +#endif + + // Echo cancel channels will check the enable signal of resample ADC CH0, + // even when resample is disabled + if (codec_adc_ch_map & EC_ADC_MAP) { + if (normal_chan_num && + (codec->REG_0E4 & CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE) == 0) { + for (i = 0; i < NORMAL_ADC_CH_NUM; i++) { + if (codec_adc_ch_map & (AUD_CHANNEL_MAP_CH0 << i)) { + codec->REG_0E4 = SET_BITFIELD( + codec->REG_0E4, CODEC_CODEC_RESAMPLE_ADC_CH0_SEL, i); + break; + } + } + } + } + +#ifdef __AUDIO_RESAMPLE__ + if (!hal_cmu_get_audio_resample_status()) +#endif + { +#ifdef __AUDIO_RESAMPLE__ + ASSERT(codec_adc_sample_rate[rate_idx].codec_freq != CODEC_FREQ_CRYSTAL, + "%s: capture sample rate %u is for resample only", __func__, + sample_rate); +#endif + analog_aud_freq_pll_config(codec_adc_sample_rate[rate_idx].codec_freq, + codec_adc_sample_rate[rate_idx].codec_div); + hal_cmu_codec_adc_set_div(codec_adc_sample_rate[rate_idx].cmu_div * + CODEC_FREQ_EXTRA_DIV); + } + hal_codec_set_adc_down(codec_adc_ch_map, + codec_adc_sample_rate[rate_idx].adc_down); + hal_codec_set_adc_hbf_bypass_cnt( + codec_adc_ch_map, codec_adc_sample_rate[rate_idx].bypass_cnt); + } #if !(defined(FIXED_CODEC_ADC_VOL) && defined(SINGLE_CODEC_ADC_VOL)) - if (HAL_CODEC_CONFIG_VOL & cfg->set_flag) { + if (HAL_CODEC_CONFIG_VOL & cfg->set_flag) { #ifdef SINGLE_CODEC_ADC_VOL - const CODEC_ADC_VOL_T *adc_gain_db; - adc_gain_db = hal_codec_get_adc_volume(cfg->vol); - if (adc_gain_db) { - hal_codec_set_dig_adc_gain(NORMAL_ADC_MAP, *adc_gain_db); + const CODEC_ADC_VOL_T *adc_gain_db; + adc_gain_db = hal_codec_get_adc_volume(cfg->vol); + if (adc_gain_db) { + hal_codec_set_dig_adc_gain(NORMAL_ADC_MAP, *adc_gain_db); #ifdef SIDETONE_DEDICATED_ADC_CHAN - sidetone_adc_gain = *adc_gain_db; - hal_codec_set_dig_adc_gain(sidetone_adc_ch_map, sidetone_adc_gain + sidetone_gain_offset); + sidetone_adc_gain = *adc_gain_db; + hal_codec_set_dig_adc_gain(sidetone_adc_ch_map, + sidetone_adc_gain + sidetone_gain_offset); #endif - } + } #else // !SINGLE_CODEC_ADC_VOL - uint32_t vol; + uint32_t vol; - mic_map = codec_mic_ch_map; - while (mic_map) { - ch_idx = get_lsb_pos(mic_map); - mic_map &= ~(1 << ch_idx); - vol = hal_codec_get_mic_chan_volume_level(1 << ch_idx); - hal_codec_set_chan_vol(AUD_STREAM_CAPTURE, (1 << ch_idx), vol); - } + mic_map = codec_mic_ch_map; + while (mic_map) { + ch_idx = get_lsb_pos(mic_map); + mic_map &= ~(1 << ch_idx); + vol = hal_codec_get_mic_chan_volume_level(1 << ch_idx); + hal_codec_set_chan_vol(AUD_STREAM_CAPTURE, (1 << ch_idx), vol); + } #ifdef SIDETONE_DEDICATED_ADC_CHAN - if (codec_mic_ch_map & CFG_HW_AUD_SIDETONE_MIC_DEV) { - const CODEC_ADC_VOL_T *adc_gain_db; + if (codec_mic_ch_map & CFG_HW_AUD_SIDETONE_MIC_DEV) { + const CODEC_ADC_VOL_T *adc_gain_db; - vol = hal_codec_get_mic_chan_volume_level(CFG_HW_AUD_SIDETONE_MIC_DEV); - adc_gain_db = hal_codec_get_adc_volume(vol); - if (adc_gain_db) { - sidetone_adc_gain = *adc_gain_db; - hal_codec_set_dig_adc_gain(sidetone_adc_ch_map, sidetone_adc_gain + sidetone_gain_offset); - } - } + vol = hal_codec_get_mic_chan_volume_level(CFG_HW_AUD_SIDETONE_MIC_DEV); + adc_gain_db = hal_codec_get_adc_volume(vol); + if (adc_gain_db) { + sidetone_adc_gain = *adc_gain_db; + hal_codec_set_dig_adc_gain(sidetone_adc_ch_map, + sidetone_adc_gain + sidetone_gain_offset); + } + } #endif #endif // !SINGLE_CODEC_ADC_VOL - } -#endif } +#endif + } - return 0; + return 0; } -int hal_codec_anc_adc_enable(enum ANC_TYPE_T type) -{ +int hal_codec_anc_adc_enable(enum ANC_TYPE_T type) { #ifdef ANC_APP - enum AUD_CHANNEL_MAP_T map; - enum AUD_CHANNEL_MAP_T mic_map; - uint8_t ch_idx; + enum AUD_CHANNEL_MAP_T map; + enum AUD_CHANNEL_MAP_T mic_map; + uint8_t ch_idx; - map = 0; - mic_map = 0; - if (type == ANC_FEEDFORWARD) { + map = 0; + mic_map = 0; + if (type == ANC_FEEDFORWARD) { #if defined(ANC_FF_MIC_CH_L) || defined(ANC_FF_MIC_CH_R) - if (ANC_FF_MIC_CH_L) { - ch_idx = get_msb_pos(ANC_FF_MIC_CH_L); - if (ANC_FF_MIC_CH_L & AUD_CHANNEL_MAP_DIGMIC_ALL) { - ch_idx = hal_codec_get_digmic_hw_index(ch_idx); - codec->REG_0A8 = SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH0, ch_idx); - codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH0; - } else { - codec->REG_084 = SET_BITFIELD(codec->REG_084, CODEC_CODEC_ADC_IN_SEL_CH0, ch_idx); - codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH0; - } - map |= AUD_CHANNEL_MAP_CH0; - mic_map |= ANC_FF_MIC_CH_L; - } - if (ANC_FF_MIC_CH_R) { - ch_idx = get_msb_pos(ANC_FF_MIC_CH_R); - if (ANC_FF_MIC_CH_R & AUD_CHANNEL_MAP_DIGMIC_ALL) { - ch_idx = hal_codec_get_digmic_hw_index(ch_idx); - codec->REG_0A8 = SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH1, ch_idx); - codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH1; - } else { - codec->REG_088 = SET_BITFIELD(codec->REG_088, CODEC_CODEC_ADC_IN_SEL_CH1, ch_idx); - codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH1; - } - map |= AUD_CHANNEL_MAP_CH1; - mic_map |= ANC_FF_MIC_CH_R; - } + if (ANC_FF_MIC_CH_L) { + ch_idx = get_msb_pos(ANC_FF_MIC_CH_L); + if (ANC_FF_MIC_CH_L & AUD_CHANNEL_MAP_DIGMIC_ALL) { + ch_idx = hal_codec_get_digmic_hw_index(ch_idx); + codec->REG_0A8 = + SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH0, ch_idx); + codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH0; + } else { + codec->REG_084 = + SET_BITFIELD(codec->REG_084, CODEC_CODEC_ADC_IN_SEL_CH0, ch_idx); + codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH0; + } + map |= AUD_CHANNEL_MAP_CH0; + mic_map |= ANC_FF_MIC_CH_L; + } + if (ANC_FF_MIC_CH_R) { + ch_idx = get_msb_pos(ANC_FF_MIC_CH_R); + if (ANC_FF_MIC_CH_R & AUD_CHANNEL_MAP_DIGMIC_ALL) { + ch_idx = hal_codec_get_digmic_hw_index(ch_idx); + codec->REG_0A8 = + SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH1, ch_idx); + codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH1; + } else { + codec->REG_088 = + SET_BITFIELD(codec->REG_088, CODEC_CODEC_ADC_IN_SEL_CH1, ch_idx); + codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH1; + } + map |= AUD_CHANNEL_MAP_CH1; + mic_map |= ANC_FF_MIC_CH_R; + } #else - ASSERT(false, "No ana adc ff ch defined"); + ASSERT(false, "No ana adc ff ch defined"); #endif - } else if (type == ANC_FEEDBACK) { + } else if (type == ANC_FEEDBACK) { #if defined(ANC_FB_MIC_CH_L) || defined(ANC_FB_MIC_CH_R) - if (ANC_FB_MIC_CH_L) { - ch_idx = get_msb_pos(ANC_FB_MIC_CH_L); - if (ANC_FB_MIC_CH_L & AUD_CHANNEL_MAP_DIGMIC_ALL) { - ch_idx = hal_codec_get_digmic_hw_index(ch_idx); - codec->REG_0A8 = SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH2, ch_idx); - codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH2; - } else { - codec->REG_08C = SET_BITFIELD(codec->REG_08C, CODEC_CODEC_ADC_IN_SEL_CH2, ch_idx); - codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH2; - } - map |= AUD_CHANNEL_MAP_CH2; - mic_map |= ANC_FB_MIC_CH_L; - } - if (ANC_FB_MIC_CH_R) { - ch_idx = get_msb_pos(ANC_FB_MIC_CH_R); - if (ANC_FB_MIC_CH_R & AUD_CHANNEL_MAP_DIGMIC_ALL) { - ch_idx = hal_codec_get_digmic_hw_index(ch_idx); - codec->REG_0A8 = SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH3, ch_idx); - codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH3; - } else { - codec->REG_090 = SET_BITFIELD(codec->REG_090, CODEC_CODEC_ADC_IN_SEL_CH3, ch_idx); - codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH3; - } - map |= AUD_CHANNEL_MAP_CH3; - mic_map |= ANC_FB_MIC_CH_R; - } + if (ANC_FB_MIC_CH_L) { + ch_idx = get_msb_pos(ANC_FB_MIC_CH_L); + if (ANC_FB_MIC_CH_L & AUD_CHANNEL_MAP_DIGMIC_ALL) { + ch_idx = hal_codec_get_digmic_hw_index(ch_idx); + codec->REG_0A8 = + SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH2, ch_idx); + codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH2; + } else { + codec->REG_08C = + SET_BITFIELD(codec->REG_08C, CODEC_CODEC_ADC_IN_SEL_CH2, ch_idx); + codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH2; + } + map |= AUD_CHANNEL_MAP_CH2; + mic_map |= ANC_FB_MIC_CH_L; + } + if (ANC_FB_MIC_CH_R) { + ch_idx = get_msb_pos(ANC_FB_MIC_CH_R); + if (ANC_FB_MIC_CH_R & AUD_CHANNEL_MAP_DIGMIC_ALL) { + ch_idx = hal_codec_get_digmic_hw_index(ch_idx); + codec->REG_0A8 = + SET_BITFIELD(codec->REG_0A8, CODEC_CODEC_PDM_MUX_CH3, ch_idx); + codec->REG_0A4 |= CODEC_CODEC_PDM_ADC_SEL_CH3; + } else { + codec->REG_090 = + SET_BITFIELD(codec->REG_090, CODEC_CODEC_ADC_IN_SEL_CH3, ch_idx); + codec->REG_0A4 &= ~CODEC_CODEC_PDM_ADC_SEL_CH3; + } + map |= AUD_CHANNEL_MAP_CH3; + mic_map |= ANC_FB_MIC_CH_R; + } #else - ASSERT(false, "No ana adc fb ch defined"); + ASSERT(false, "No ana adc fb ch defined"); #endif - } - anc_adc_ch_map |= map; - anc_mic_ch_map |= mic_map; + } + anc_adc_ch_map |= map; + anc_mic_ch_map |= mic_map; - if (anc_mic_ch_map & AUD_CHANNEL_MAP_DIGMIC_ALL) { - hal_codec_enable_dig_mic(anc_mic_ch_map); - } + if (anc_mic_ch_map & AUD_CHANNEL_MAP_DIGMIC_ALL) { + hal_codec_enable_dig_mic(anc_mic_ch_map); + } - for (int i = 0; i < NORMAL_ADC_CH_NUM; i++) { - if (map & (AUD_CHANNEL_MAP_CH0 << i)) { - if ((codec->REG_080 & (CODEC_CODEC_ADC_EN_CH0 << i)) == 0) { - // Reset ADC channel - codec->REG_064 &= ~CODEC_SOFT_RSTN_ADC(1 << i); - codec->REG_064 |= CODEC_SOFT_RSTN_ADC(1 << i); - codec->REG_080 |= (CODEC_CODEC_ADC_EN_CH0 << i); - } - } + for (int i = 0; i < NORMAL_ADC_CH_NUM; i++) { + if (map & (AUD_CHANNEL_MAP_CH0 << i)) { + if ((codec->REG_080 & (CODEC_CODEC_ADC_EN_CH0 << i)) == 0) { + // Reset ADC channel + codec->REG_064 &= ~CODEC_SOFT_RSTN_ADC(1 << i); + codec->REG_064 |= CODEC_SOFT_RSTN_ADC(1 << i); + codec->REG_080 |= (CODEC_CODEC_ADC_EN_CH0 << i); + } } + } #ifdef DAC_DRE_ENABLE - if (anc_adc_ch_map && (codec->REG_098 & CODEC_CODEC_DAC_EN)) { - hal_codec_dac_dre_disable(); - } + if (anc_adc_ch_map && (codec->REG_098 & CODEC_CODEC_DAC_EN)) { + hal_codec_dac_dre_disable(); + } #endif #endif - return 0; + return 0; } -int hal_codec_anc_adc_disable(enum ANC_TYPE_T type) -{ +int hal_codec_anc_adc_disable(enum ANC_TYPE_T type) { #ifdef ANC_APP - enum AUD_CHANNEL_MAP_T map; - enum AUD_CHANNEL_MAP_T mic_map; + enum AUD_CHANNEL_MAP_T map; + enum AUD_CHANNEL_MAP_T mic_map; - map = 0; - mic_map = 0; - if (type == ANC_FEEDFORWARD) { + map = 0; + mic_map = 0; + if (type == ANC_FEEDFORWARD) { #if defined(ANC_FF_MIC_CH_L) || defined(ANC_FF_MIC_CH_R) - if (ANC_FF_MIC_CH_L) { - map |= AUD_CHANNEL_MAP_CH0; - mic_map |= ANC_FF_MIC_CH_L; - } - if (ANC_FF_MIC_CH_R) { - map |= AUD_CHANNEL_MAP_CH1; - mic_map |= ANC_FF_MIC_CH_R; - } + if (ANC_FF_MIC_CH_L) { + map |= AUD_CHANNEL_MAP_CH0; + mic_map |= ANC_FF_MIC_CH_L; + } + if (ANC_FF_MIC_CH_R) { + map |= AUD_CHANNEL_MAP_CH1; + mic_map |= ANC_FF_MIC_CH_R; + } #endif - } else if (type == ANC_FEEDBACK) { + } else if (type == ANC_FEEDBACK) { #if defined(ANC_FB_MIC_CH_L) || defined(ANC_FB_MIC_CH_R) - if (ANC_FB_MIC_CH_L) { - map |= AUD_CHANNEL_MAP_CH2; - mic_map |= ANC_FB_MIC_CH_L; - } - if (ANC_FB_MIC_CH_R) { - map |= AUD_CHANNEL_MAP_CH3; - mic_map |= ANC_FB_MIC_CH_R; - } + if (ANC_FB_MIC_CH_L) { + map |= AUD_CHANNEL_MAP_CH2; + mic_map |= ANC_FB_MIC_CH_L; + } + if (ANC_FB_MIC_CH_R) { + map |= AUD_CHANNEL_MAP_CH3; + mic_map |= ANC_FB_MIC_CH_R; + } #endif - } - anc_adc_ch_map &= ~map; - anc_mic_ch_map &= ~mic_map; + } + anc_adc_ch_map &= ~map; + anc_mic_ch_map &= ~mic_map; - if ((anc_mic_ch_map & AUD_CHANNEL_MAP_DIGMIC_ALL) == 0 && - ((codec_mic_ch_map & AUD_CHANNEL_MAP_DIGMIC_ALL) == 0 || (codec->REG_000 & CODEC_ADC_ENABLE) == 0)) { - hal_codec_disable_dig_mic(); - } + if ((anc_mic_ch_map & AUD_CHANNEL_MAP_DIGMIC_ALL) == 0 && + ((codec_mic_ch_map & AUD_CHANNEL_MAP_DIGMIC_ALL) == 0 || + (codec->REG_000 & CODEC_ADC_ENABLE) == 0)) { + hal_codec_disable_dig_mic(); + } - for (int i = 0; i < NORMAL_ADC_CH_NUM; i++) { - if ((map & (AUD_CHANNEL_MAP_CH0 << i)) == 0) { - continue; - } - if (codec->REG_000 & CODEC_ADC_ENABLE) { - if (codec_adc_ch_map & (AUD_CHANNEL_MAP_CH0 << i)) { - continue; - } - if (i == 0 && - (codec->REG_228 & (CODEC_CODEC_MC_ENABLE_CH0 | CODEC_CODEC_MC_ENABLE_CH1)) && - (codec_adc_ch_map & ~EC_ADC_MAP) == 0) { - continue; - } - } - codec->REG_080 &= ~(CODEC_CODEC_ADC_EN_CH0 << i); + for (int i = 0; i < NORMAL_ADC_CH_NUM; i++) { + if ((map & (AUD_CHANNEL_MAP_CH0 << i)) == 0) { + continue; } + if (codec->REG_000 & CODEC_ADC_ENABLE) { + if (codec_adc_ch_map & (AUD_CHANNEL_MAP_CH0 << i)) { + continue; + } + if (i == 0 && + (codec->REG_228 & + (CODEC_CODEC_MC_ENABLE_CH0 | CODEC_CODEC_MC_ENABLE_CH1)) && + (codec_adc_ch_map & ~EC_ADC_MAP) == 0) { + continue; + } + } + codec->REG_080 &= ~(CODEC_CODEC_ADC_EN_CH0 << i); + } #ifdef DAC_DRE_ENABLE - if (anc_adc_ch_map == 0 && (codec->REG_098 & CODEC_CODEC_DAC_EN) && - //(codec->REG_044 & CODEC_MODE_16BIT_DAC) == 0 && - 1) { - hal_codec_dac_dre_enable(); - } + if (anc_adc_ch_map == 0 && (codec->REG_098 & CODEC_CODEC_DAC_EN) && + //(codec->REG_044 & CODEC_MODE_16BIT_DAC) == 0 && + 1) { + hal_codec_dac_dre_enable(); + } #endif #endif - return 0; + return 0; } -enum AUD_SAMPRATE_T hal_codec_anc_convert_rate(enum AUD_SAMPRATE_T rate) -{ - if (hal_cmu_get_audio_resample_status()) { - return AUD_SAMPRATE_50781; - } else if (CODEC_FREQ_48K_SERIES / rate * rate == CODEC_FREQ_48K_SERIES) { - return AUD_SAMPRATE_48000; - } else /* if (CODEC_FREQ_44_1K_SERIES / rate * rate == CODEC_FREQ_44_1K_SERIES) */ { - return AUD_SAMPRATE_44100; - } +enum AUD_SAMPRATE_T hal_codec_anc_convert_rate(enum AUD_SAMPRATE_T rate) { + if (hal_cmu_get_audio_resample_status()) { + return AUD_SAMPRATE_50781; + } else if (CODEC_FREQ_48K_SERIES / rate * rate == CODEC_FREQ_48K_SERIES) { + return AUD_SAMPRATE_48000; + } else /* if (CODEC_FREQ_44_1K_SERIES / rate * rate == + CODEC_FREQ_44_1K_SERIES) */ + { + return AUD_SAMPRATE_44100; + } } -int hal_codec_anc_dma_enable(enum HAL_CODEC_ID_T id) -{ - return 0; -} +int hal_codec_anc_dma_enable(enum HAL_CODEC_ID_T id) { return 0; } -int hal_codec_anc_dma_disable(enum HAL_CODEC_ID_T id) -{ - return 0; -} +int hal_codec_anc_dma_disable(enum HAL_CODEC_ID_T id) { return 0; } -int hal_codec_aux_mic_dma_enable(enum HAL_CODEC_ID_T id) -{ - return 0; -} +int hal_codec_aux_mic_dma_enable(enum HAL_CODEC_ID_T id) { return 0; } -int hal_codec_aux_mic_dma_disable(enum HAL_CODEC_ID_T id) -{ - return 0; -} +int hal_codec_aux_mic_dma_disable(enum HAL_CODEC_ID_T id) { return 0; } -uint32_t hal_codec_get_alg_dac_shift(void) -{ - return 0; -} +uint32_t hal_codec_get_alg_dac_shift(void) { return 0; } #ifdef ANC_APP -void hal_codec_set_anc_boost_gain_attn(float attn) -{ - anc_boost_gain_attn = attn; +void hal_codec_set_anc_boost_gain_attn(float attn) { + anc_boost_gain_attn = attn; #ifdef AUDIO_OUTPUT_SW_GAIN - hal_codec_set_sw_gain(swdac_gain); + hal_codec_set_sw_gain(swdac_gain); #else - hal_codec_restore_dig_dac_gain(); + hal_codec_restore_dig_dac_gain(); #endif - hal_codec_restore_dig_adc_gain(); + hal_codec_restore_dig_adc_gain(); } -void hal_codec_apply_anc_adc_gain_offset(enum ANC_TYPE_T type, int8_t offset_l, int8_t offset_r) -{ - enum AUD_CHANNEL_MAP_T map_l, map_r; - enum AUD_CHANNEL_MAP_T ch_map; - uint8_t ch_idx; +void hal_codec_apply_anc_adc_gain_offset(enum ANC_TYPE_T type, int8_t offset_l, + int8_t offset_r) { + enum AUD_CHANNEL_MAP_T map_l, map_r; + enum AUD_CHANNEL_MAP_T ch_map; + uint8_t ch_idx; - if (analog_debug_get_anc_calib_mode()) { - return; - } + if (analog_debug_get_anc_calib_mode()) { + return; + } - map_l = 0; - map_r = 0; + map_l = 0; + map_r = 0; #if defined(ANC_FF_MIC_CH_L) || defined(ANC_FF_MIC_CH_R) - if (type & ANC_FEEDFORWARD) { - if (ANC_FF_MIC_CH_L) { - map_l |= AUD_CHANNEL_MAP_CH0; - } - if (ANC_FF_MIC_CH_R) { - map_r |= AUD_CHANNEL_MAP_CH1; - } + if (type & ANC_FEEDFORWARD) { + if (ANC_FF_MIC_CH_L) { + map_l |= AUD_CHANNEL_MAP_CH0; } + if (ANC_FF_MIC_CH_R) { + map_r |= AUD_CHANNEL_MAP_CH1; + } + } #endif #if defined(ANC_FB_MIC_CH_L) || defined(ANC_FB_MIC_CH_R) - if (type & ANC_FEEDBACK) { - if (ANC_FB_MIC_CH_L) { - map_l |= AUD_CHANNEL_MAP_CH2; - } - if (ANC_FB_MIC_CH_R) { - map_r |= AUD_CHANNEL_MAP_CH3; - } + if (type & ANC_FEEDBACK) { + if (ANC_FB_MIC_CH_L) { + map_l |= AUD_CHANNEL_MAP_CH2; } + if (ANC_FB_MIC_CH_R) { + map_r |= AUD_CHANNEL_MAP_CH3; + } + } #endif - if (map_l) { - ch_map = map_l; - while (ch_map) { - ch_idx = get_msb_pos(ch_map); - ch_map &= ~(1 << ch_idx); - anc_adc_gain_offset[ch_idx] = offset_l; - } - if (offset_l) { - anc_adc_gain_offset_map |= map_l; - } else { - anc_adc_gain_offset_map &= ~map_l; - } + if (map_l) { + ch_map = map_l; + while (ch_map) { + ch_idx = get_msb_pos(ch_map); + ch_map &= ~(1 << ch_idx); + anc_adc_gain_offset[ch_idx] = offset_l; } - if (map_r) { - ch_map = map_r; - while (ch_map) { - ch_idx = get_msb_pos(ch_map); - ch_map &= ~(1 << ch_idx); - anc_adc_gain_offset[ch_idx] = offset_r; - } - if (offset_r) { - anc_adc_gain_offset_map |= map_r; - } else { - anc_adc_gain_offset_map &= ~map_r; - } + if (offset_l) { + anc_adc_gain_offset_map |= map_l; + } else { + anc_adc_gain_offset_map &= ~map_l; } - if (map_l || map_r) { - hal_codec_restore_dig_adc_gain(); + } + if (map_r) { + ch_map = map_r; + while (ch_map) { + ch_idx = get_msb_pos(ch_map); + ch_map &= ~(1 << ch_idx); + anc_adc_gain_offset[ch_idx] = offset_r; } + if (offset_r) { + anc_adc_gain_offset_map |= map_r; + } else { + anc_adc_gain_offset_map &= ~map_r; + } + } + if (map_l || map_r) { + hal_codec_restore_dig_adc_gain(); + } } #endif #ifdef AUDIO_OUTPUT_DC_CALIB -void hal_codec_set_dac_dc_gain_attn(float attn) -{ - dac_dc_gain_attn = attn; -} +void hal_codec_set_dac_dc_gain_attn(float attn) { dac_dc_gain_attn = attn; } -void hal_codec_set_dac_dc_offset(int16_t dc_l, int16_t dc_r) -{ - // DC calib values are based on 16-bit, but hardware compensation is based on 24-bit - dac_dc_l = dc_l << 8; - dac_dc_r = dc_r << 8; +void hal_codec_set_dac_dc_offset(int16_t dc_l, int16_t dc_r) { + // DC calib values are based on 16-bit, but hardware compensation is based on + // 24-bit + dac_dc_l = dc_l << 8; + dac_dc_r = dc_r << 8; #ifdef SDM_MUTE_NOISE_SUPPRESSION - if (dac_dc_l == 0) { - dac_dc_l = 1; - } - if (dac_dc_r == 0) { - dac_dc_r = 1; - } + if (dac_dc_l == 0) { + dac_dc_l = 1; + } + if (dac_dc_r == 0) { + dac_dc_r = 1; + } #endif } #endif -void hal_codec_set_dac_reset_callback(HAL_CODEC_DAC_RESET_CALLBACK callback) -{ - //dac_reset_callback = callback; +void hal_codec_set_dac_reset_callback(HAL_CODEC_DAC_RESET_CALLBACK callback) { + // dac_reset_callback = callback; } -static uint32_t POSSIBLY_UNUSED hal_codec_get_adc_chan(enum AUD_CHANNEL_MAP_T mic_map) -{ - uint8_t adc_ch; - uint8_t mic_ch; - uint8_t digmic_ch0; - uint8_t en_ch; - bool digmic; - int i; +static uint32_t POSSIBLY_UNUSED +hal_codec_get_adc_chan(enum AUD_CHANNEL_MAP_T mic_map) { + uint8_t adc_ch; + uint8_t mic_ch; + uint8_t digmic_ch0; + uint8_t en_ch; + bool digmic; + int i; - adc_ch = MAX_ADC_CH_NUM; + adc_ch = MAX_ADC_CH_NUM; - mic_ch = get_lsb_pos(mic_map); - - if (((1 << mic_ch) & codec_mic_ch_map) == 0) { - return adc_ch; - } - - digmic_ch0 = get_lsb_pos(AUD_CHANNEL_MAP_DIGMIC_CH0); - - if (mic_ch >= digmic_ch0) { - mic_ch -= digmic_ch0; - digmic = true; - } else { - digmic = false; - } - - for (i = 0; i < NORMAL_ADC_CH_NUM; i++) { - if (codec_adc_ch_map & (1 << i)) { - if (digmic ^ !!(codec->REG_0A4 & (CODEC_CODEC_PDM_ADC_SEL_CH0 << i))) { - continue; - } - if (digmic) { - en_ch = (codec->REG_0A8 & (CODEC_CODEC_PDM_MUX_CH0_MASK << (3 * i))) >> (CODEC_CODEC_PDM_MUX_CH0_SHIFT + 3 * i); - } else { - en_ch = GET_BITFIELD(*(&codec->REG_084 + i), CODEC_CODEC_ADC_IN_SEL_CH0); - } - if (mic_ch == en_ch) { - adc_ch = i; - break; - } - } - } + mic_ch = get_lsb_pos(mic_map); + if (((1 << mic_ch) & codec_mic_ch_map) == 0) { return adc_ch; + } + + digmic_ch0 = get_lsb_pos(AUD_CHANNEL_MAP_DIGMIC_CH0); + + if (mic_ch >= digmic_ch0) { + mic_ch -= digmic_ch0; + digmic = true; + } else { + digmic = false; + } + + for (i = 0; i < NORMAL_ADC_CH_NUM; i++) { + if (codec_adc_ch_map & (1 << i)) { + if (digmic ^ !!(codec->REG_0A4 & (CODEC_CODEC_PDM_ADC_SEL_CH0 << i))) { + continue; + } + if (digmic) { + en_ch = (codec->REG_0A8 & (CODEC_CODEC_PDM_MUX_CH0_MASK << (3 * i))) >> + (CODEC_CODEC_PDM_MUX_CH0_SHIFT + 3 * i); + } else { + en_ch = + GET_BITFIELD(*(&codec->REG_084 + i), CODEC_CODEC_ADC_IN_SEL_CH0); + } + if (mic_ch == en_ch) { + adc_ch = i; + break; + } + } + } + + return adc_ch; } -void hal_codec_sidetone_enable(void) -{ +void hal_codec_sidetone_enable(void) { #ifdef SIDETONE_ENABLE #if (CFG_HW_AUD_SIDETONE_MIC_DEV & (CFG_HW_AUD_SIDETONE_MIC_DEV - 1)) #error "Invalid CFG_HW_AUD_SIDETONE_MIC_DEV: only 1 mic can be defined" #endif -#if (CFG_HW_AUD_SIDETONE_MIC_DEV == 0) || (CFG_HW_AUD_SIDETONE_MIC_DEV & ~NORMAL_MIC_MAP) +#if (CFG_HW_AUD_SIDETONE_MIC_DEV == 0) || \ + (CFG_HW_AUD_SIDETONE_MIC_DEV & ~NORMAL_MIC_MAP) #error "Invalid CFG_HW_AUD_SIDETONE_MIC_DEV: bad mic channel" #endif - int gain = CFG_HW_AUD_SIDETONE_GAIN_DBVAL; - uint32_t val; + int gain = CFG_HW_AUD_SIDETONE_GAIN_DBVAL; + uint32_t val; #ifdef SIDETONE_DEDICATED_ADC_CHAN - sidetone_gain_offset = 0; - if (gain > MAX_SIDETONE_DBVAL) { - sidetone_gain_offset = gain - MAX_SIDETONE_DBVAL; - } else if (gain < MIN_SIDETONE_DBVAL) { - sidetone_gain_offset = gain - MIN_SIDETONE_DBVAL; - } + sidetone_gain_offset = 0; + if (gain > MAX_SIDETONE_DBVAL) { + sidetone_gain_offset = gain - MAX_SIDETONE_DBVAL; + } else if (gain < MIN_SIDETONE_DBVAL) { + sidetone_gain_offset = gain - MIN_SIDETONE_DBVAL; + } #endif - if (gain > MAX_SIDETONE_DBVAL) { - gain = MAX_SIDETONE_DBVAL; - } else if (gain < MIN_SIDETONE_DBVAL) { - gain = MIN_SIDETONE_DBVAL; - } + if (gain > MAX_SIDETONE_DBVAL) { + gain = MAX_SIDETONE_DBVAL; + } else if (gain < MIN_SIDETONE_DBVAL) { + gain = MIN_SIDETONE_DBVAL; + } - val = MIN_SIDETONE_REGVAL + (gain - MIN_SIDETONE_DBVAL) / SIDETONE_DBVAL_STEP; + val = MIN_SIDETONE_REGVAL + (gain - MIN_SIDETONE_DBVAL) / SIDETONE_DBVAL_STEP; - codec->REG_080 = SET_BITFIELD(codec->REG_080, CODEC_CODEC_SIDE_TONE_GAIN, val); + codec->REG_080 = + SET_BITFIELD(codec->REG_080, CODEC_CODEC_SIDE_TONE_GAIN, val); #ifdef SIDETONE_DEDICATED_ADC_CHAN - uint8_t adc_ch; + uint8_t adc_ch; - adc_ch = get_lsb_pos(sidetone_adc_ch_map); - if (adc_ch >= NORMAL_ADC_CH_NUM) { - return; - } + adc_ch = get_lsb_pos(sidetone_adc_ch_map); + if (adc_ch >= NORMAL_ADC_CH_NUM) { + return; + } - hal_codec_set_dig_adc_gain(sidetone_adc_ch_map, sidetone_adc_gain + sidetone_gain_offset); + hal_codec_set_dig_adc_gain(sidetone_adc_ch_map, + sidetone_adc_gain + sidetone_gain_offset); #ifdef CFG_HW_AUD_SIDETONE_GAIN_RAMP - hal_codec_get_adc_gain(sidetone_adc_ch_map, &sidetone_ded_chan_coef); - hal_codec_set_dig_adc_gain(sidetone_adc_ch_map, MIN_DIG_DBVAL); + hal_codec_get_adc_gain(sidetone_adc_ch_map, &sidetone_ded_chan_coef); + hal_codec_set_dig_adc_gain(sidetone_adc_ch_map, MIN_DIG_DBVAL); #endif - codec->REG_080 |= (CODEC_CODEC_ADC_EN_CH0 << adc_ch); + codec->REG_080 |= (CODEC_CODEC_ADC_EN_CH0 << adc_ch); #ifdef CFG_HW_AUD_SIDETONE_IIR_INDEX #if (CFG_HW_AUD_SIDETONE_IIR_INDEX >= ADC_IIR_CH_NUM + 0UL) #error "Invalid CFG_HW_AUD_SIDETONE_IIR_INDEX" #endif - uint32_t mask; + uint32_t mask; - if (CFG_HW_AUD_SIDETONE_IIR_INDEX == 0) { - mask = CODEC_CODEC_ADC_IIR_CH0_SEL_MASK; - val = CODEC_CODEC_ADC_IIR_CH0_SEL(adc_ch); - } else { - mask = CODEC_CODEC_ADC_IIR_CH1_SEL_MASK; - val = CODEC_CODEC_ADC_IIR_CH1_SEL(adc_ch); - } - codec->REG_078 = (codec->REG_078 & ~mask) | val; + if (CFG_HW_AUD_SIDETONE_IIR_INDEX == 0) { + mask = CODEC_CODEC_ADC_IIR_CH0_SEL_MASK; + val = CODEC_CODEC_ADC_IIR_CH0_SEL(adc_ch); + } else { + mask = CODEC_CODEC_ADC_IIR_CH1_SEL_MASK; + val = CODEC_CODEC_ADC_IIR_CH1_SEL(adc_ch); + } + codec->REG_078 = (codec->REG_078 & ~mask) | val; #endif #endif #endif } -void hal_codec_sidetone_disable(void) -{ +void hal_codec_sidetone_disable(void) { #ifdef SIDETONE_ENABLE - codec->REG_080 = SET_BITFIELD(codec->REG_080, CODEC_CODEC_SIDE_TONE_GAIN, MUTE_SIDETONE_REGVAL); + codec->REG_080 = SET_BITFIELD(codec->REG_080, CODEC_CODEC_SIDE_TONE_GAIN, + MUTE_SIDETONE_REGVAL); #ifdef SIDETONE_DEDICATED_ADC_CHAN - if (sidetone_adc_ch_map) { - uint8_t adc_ch; - - adc_ch = get_lsb_pos(sidetone_adc_ch_map); - codec->REG_080 &= ~(CODEC_CODEC_ADC_EN_CH0 << adc_ch); - } -#endif -#endif -} - -int hal_codec_sidetone_gain_ramp_up(float step) -{ - int ret = 0; -#ifdef CFG_HW_AUD_SIDETONE_GAIN_RAMP - float coef; - uint32_t val; - - hal_codec_get_adc_gain(sidetone_adc_ch_map, &coef); - coef += step; - if (coef >= sidetone_ded_chan_coef) { - coef = sidetone_ded_chan_coef; - ret = 1; - } - // Gain format: 8.12 - int32_t s_val = (int32_t)(coef * (1 << 12)); - val = __SSAT(s_val, 20); - hal_codec_set_adc_gain_value(sidetone_adc_ch_map, val); - -#endif - return ret; -} - -int hal_codec_sidetone_gain_ramp_down(float step) -{ - int ret = 0; -#ifdef CFG_HW_AUD_SIDETONE_GAIN_RAMP - float coef; - uint32_t val; - - hal_codec_get_adc_gain(sidetone_adc_ch_map, &coef); - coef -= step; - if (coef <= 0) { - coef = 0; - ret = 1; - } - - // Gain format: 8.12 - int32_t s_val = (int32_t)(coef * (1 << 12)); - val = __SSAT(s_val, 20); - hal_codec_set_adc_gain_value(sidetone_adc_ch_map, val); -#endif - return ret; -} - -void hal_codec_select_adc_iir_mic(uint32_t index, enum AUD_CHANNEL_MAP_T mic_map) -{ - uint32_t mask, val; + if (sidetone_adc_ch_map) { uint8_t adc_ch; - ASSERT(index < ADC_IIR_CH_NUM, "%s: Bad index=%u", __func__, index); - ASSERT(mic_map && (mic_map & (mic_map - 1)) == 0, "%s: Bad mic_map=0x%X", __func__, mic_map); + adc_ch = get_lsb_pos(sidetone_adc_ch_map); + codec->REG_080 &= ~(CODEC_CODEC_ADC_EN_CH0 << adc_ch); + } +#endif +#endif +} + +int hal_codec_sidetone_gain_ramp_up(float step) { + int ret = 0; +#ifdef CFG_HW_AUD_SIDETONE_GAIN_RAMP + float coef; + uint32_t val; + + hal_codec_get_adc_gain(sidetone_adc_ch_map, &coef); + coef += step; + if (coef >= sidetone_ded_chan_coef) { + coef = sidetone_ded_chan_coef; + ret = 1; + } + // Gain format: 8.12 + int32_t s_val = (int32_t)(coef * (1 << 12)); + val = __SSAT(s_val, 20); + hal_codec_set_adc_gain_value(sidetone_adc_ch_map, val); + +#endif + return ret; +} + +int hal_codec_sidetone_gain_ramp_down(float step) { + int ret = 0; +#ifdef CFG_HW_AUD_SIDETONE_GAIN_RAMP + float coef; + uint32_t val; + + hal_codec_get_adc_gain(sidetone_adc_ch_map, &coef); + coef -= step; + if (coef <= 0) { + coef = 0; + ret = 1; + } + + // Gain format: 8.12 + int32_t s_val = (int32_t)(coef * (1 << 12)); + val = __SSAT(s_val, 20); + hal_codec_set_adc_gain_value(sidetone_adc_ch_map, val); +#endif + return ret; +} + +void hal_codec_select_adc_iir_mic(uint32_t index, + enum AUD_CHANNEL_MAP_T mic_map) { + uint32_t mask, val; + uint8_t adc_ch; + + ASSERT(index < ADC_IIR_CH_NUM, "%s: Bad index=%u", __func__, index); + ASSERT(mic_map && (mic_map & (mic_map - 1)) == 0, "%s: Bad mic_map=0x%X", + __func__, mic_map); #ifdef CFG_HW_AUD_SIDETONE_IIR_INDEX - ASSERT(index != CFG_HW_AUD_SIDETONE_IIR_INDEX, "%s: Adc iir index conflicts with sidetone", __func__); + ASSERT(index != CFG_HW_AUD_SIDETONE_IIR_INDEX, + "%s: Adc iir index conflicts with sidetone", __func__); #endif - adc_ch = hal_codec_get_adc_chan(mic_map); - if (index == 0) { - mask = CODEC_CODEC_ADC_IIR_CH0_SEL_MASK; - val = CODEC_CODEC_ADC_IIR_CH0_SEL(adc_ch); - } else { - mask = CODEC_CODEC_ADC_IIR_CH1_SEL_MASK; - val = CODEC_CODEC_ADC_IIR_CH1_SEL(adc_ch); - } - codec->REG_078 = (codec->REG_078 & ~mask) | val; + adc_ch = hal_codec_get_adc_chan(mic_map); + if (index == 0) { + mask = CODEC_CODEC_ADC_IIR_CH0_SEL_MASK; + val = CODEC_CODEC_ADC_IIR_CH0_SEL(adc_ch); + } else { + mask = CODEC_CODEC_ADC_IIR_CH1_SEL_MASK; + val = CODEC_CODEC_ADC_IIR_CH1_SEL(adc_ch); + } + codec->REG_078 = (codec->REG_078 & ~mask) | val; } -void hal_codec_min_phase_mode_enable(enum AUD_STREAM_T stream) -{ +void hal_codec_min_phase_mode_enable(enum AUD_STREAM_T stream) { #ifdef CODEC_MIN_PHASE - if (min_phase_cfg == 0 && codec_opened) { - hal_codec_min_phase_init(); - } + if (min_phase_cfg == 0 && codec_opened) { + hal_codec_min_phase_init(); + } - min_phase_cfg |= (1 << stream); + min_phase_cfg |= (1 << stream); #endif } -void hal_codec_min_phase_mode_disable(enum AUD_STREAM_T stream) -{ +void hal_codec_min_phase_mode_disable(enum AUD_STREAM_T stream) { #ifdef CODEC_MIN_PHASE - min_phase_cfg &= ~(1 << stream); + min_phase_cfg &= ~(1 << stream); - if (min_phase_cfg == 0 && codec_opened) { - hal_codec_min_phase_term(); - } + if (min_phase_cfg == 0 && codec_opened) { + hal_codec_min_phase_term(); + } #endif } -void hal_codec_sync_dac_enable(enum HAL_CODEC_SYNC_TYPE_T type) -{ +void hal_codec_sync_dac_enable(enum HAL_CODEC_SYNC_TYPE_T type) { #if defined(ANC_APP) - //hal_codec_sync_dac_resample_rate_enable(type); - codec->REG_054 = SET_BITFIELD(codec->REG_054, CODEC_DAC_ENABLE_SEL, type); + // hal_codec_sync_dac_resample_rate_enable(type); + codec->REG_054 = SET_BITFIELD(codec->REG_054, CODEC_DAC_ENABLE_SEL, type); #else - codec->REG_054 = SET_BITFIELD(codec->REG_054, CODEC_CODEC_DAC_ENABLE_SEL, type); + codec->REG_054 = + SET_BITFIELD(codec->REG_054, CODEC_CODEC_DAC_ENABLE_SEL, type); #endif } -void hal_codec_sync_dac_disable(void) -{ +void hal_codec_sync_dac_disable(void) { #if defined(ANC_APP) - //hal_codec_sync_dac_resample_rate_disable(); - codec->REG_054 = SET_BITFIELD(codec->REG_054, CODEC_DAC_ENABLE_SEL, HAL_CODEC_SYNC_TYPE_NONE); + // hal_codec_sync_dac_resample_rate_disable(); + codec->REG_054 = SET_BITFIELD(codec->REG_054, CODEC_DAC_ENABLE_SEL, + HAL_CODEC_SYNC_TYPE_NONE); #else - codec->REG_054 = SET_BITFIELD(codec->REG_054, CODEC_CODEC_DAC_ENABLE_SEL, HAL_CODEC_SYNC_TYPE_NONE); + codec->REG_054 = SET_BITFIELD(codec->REG_054, CODEC_CODEC_DAC_ENABLE_SEL, + HAL_CODEC_SYNC_TYPE_NONE); #endif } -void hal_codec_sync_adc_enable(enum HAL_CODEC_SYNC_TYPE_T type) -{ +void hal_codec_sync_adc_enable(enum HAL_CODEC_SYNC_TYPE_T type) { #if defined(ANC_APP) - //hal_codec_sync_adc_resample_rate_enable(type); - codec->REG_054 = SET_BITFIELD(codec->REG_054, CODEC_ADC_ENABLE_SEL, type); + // hal_codec_sync_adc_resample_rate_enable(type); + codec->REG_054 = SET_BITFIELD(codec->REG_054, CODEC_ADC_ENABLE_SEL, type); #else - codec->REG_054 = SET_BITFIELD(codec->REG_054, CODEC_CODEC_ADC_ENABLE_SEL, type); + codec->REG_054 = + SET_BITFIELD(codec->REG_054, CODEC_CODEC_ADC_ENABLE_SEL, type); #endif } -void hal_codec_sync_adc_disable(void) -{ +void hal_codec_sync_adc_disable(void) { #if defined(ANC_APP) - //hal_codec_sync_adc_resample_rate_disable(); - codec->REG_054 = SET_BITFIELD(codec->REG_054, CODEC_ADC_ENABLE_SEL, HAL_CODEC_SYNC_TYPE_NONE); + // hal_codec_sync_adc_resample_rate_disable(); + codec->REG_054 = SET_BITFIELD(codec->REG_054, CODEC_ADC_ENABLE_SEL, + HAL_CODEC_SYNC_TYPE_NONE); #else - codec->REG_054 = SET_BITFIELD(codec->REG_054, CODEC_CODEC_ADC_ENABLE_SEL, HAL_CODEC_SYNC_TYPE_NONE); + codec->REG_054 = SET_BITFIELD(codec->REG_054, CODEC_CODEC_ADC_ENABLE_SEL, + HAL_CODEC_SYNC_TYPE_NONE); #endif } -void hal_codec_sync_dac_resample_rate_enable(enum HAL_CODEC_SYNC_TYPE_T type) -{ - codec->REG_0E4 = SET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_DAC_TRIGGER_SEL, type); +void hal_codec_sync_dac_resample_rate_enable(enum HAL_CODEC_SYNC_TYPE_T type) { + codec->REG_0E4 = + SET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_DAC_TRIGGER_SEL, type); } -void hal_codec_sync_dac_resample_rate_disable(void) -{ - codec->REG_0E4 = SET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_DAC_TRIGGER_SEL, HAL_CODEC_SYNC_TYPE_NONE); +void hal_codec_sync_dac_resample_rate_disable(void) { + codec->REG_0E4 = + SET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_DAC_TRIGGER_SEL, + HAL_CODEC_SYNC_TYPE_NONE); } -void hal_codec_sync_adc_resample_rate_enable(enum HAL_CODEC_SYNC_TYPE_T type) -{ - codec->REG_0E4 = SET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_ADC_TRIGGER_SEL, type); +void hal_codec_sync_adc_resample_rate_enable(enum HAL_CODEC_SYNC_TYPE_T type) { + codec->REG_0E4 = + SET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_ADC_TRIGGER_SEL, type); } -void hal_codec_sync_adc_resample_rate_disable(void) -{ - codec->REG_0E4 = SET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_ADC_TRIGGER_SEL, HAL_CODEC_SYNC_TYPE_NONE); +void hal_codec_sync_adc_resample_rate_disable(void) { + codec->REG_0E4 = + SET_BITFIELD(codec->REG_0E4, CODEC_CODEC_RESAMPLE_ADC_TRIGGER_SEL, + HAL_CODEC_SYNC_TYPE_NONE); } -void hal_codec_sync_dac_gain_enable(enum HAL_CODEC_SYNC_TYPE_T type) -{ - codec->REG_09C = SET_BITFIELD(codec->REG_09C, CODEC_CODEC_DAC_GAIN_TRIGGER_SEL, type); +void hal_codec_sync_dac_gain_enable(enum HAL_CODEC_SYNC_TYPE_T type) { + codec->REG_09C = + SET_BITFIELD(codec->REG_09C, CODEC_CODEC_DAC_GAIN_TRIGGER_SEL, type); } -void hal_codec_sync_dac_gain_disable(void) -{ - codec->REG_09C = SET_BITFIELD(codec->REG_09C, CODEC_CODEC_DAC_GAIN_TRIGGER_SEL, HAL_CODEC_SYNC_TYPE_NONE); +void hal_codec_sync_dac_gain_disable(void) { + codec->REG_09C = + SET_BITFIELD(codec->REG_09C, CODEC_CODEC_DAC_GAIN_TRIGGER_SEL, + HAL_CODEC_SYNC_TYPE_NONE); } -void hal_codec_sync_adc_gain_enable(enum HAL_CODEC_SYNC_TYPE_T type) -{ +void hal_codec_sync_adc_gain_enable(enum HAL_CODEC_SYNC_TYPE_T type) {} + +void hal_codec_sync_adc_gain_disable(void) {} + +void hal_codec_gpio_trigger_debounce_enable(void) { + if (codec_opened) { + codec->REG_054 |= CODEC_GPIO_TRIGGER_DB_ENABLE; + } } -void hal_codec_sync_adc_gain_disable(void) -{ -} - -void hal_codec_gpio_trigger_debounce_enable(void) -{ - if (codec_opened) { - codec->REG_054 |= CODEC_GPIO_TRIGGER_DB_ENABLE; - } -} - -void hal_codec_gpio_trigger_debounce_disable(void) -{ - if (codec_opened) { - codec->REG_054 &= ~CODEC_GPIO_TRIGGER_DB_ENABLE; - } +void hal_codec_gpio_trigger_debounce_disable(void) { + if (codec_opened) { + codec->REG_054 &= ~CODEC_GPIO_TRIGGER_DB_ENABLE; + } } #ifdef CODEC_TIMER -uint32_t hal_codec_timer_get(void) -{ - if (codec_opened) { - return codec->REG_050; - } +uint32_t hal_codec_timer_get(void) { + if (codec_opened) { + return codec->REG_050; + } - return 0; + return 0; } -uint32_t hal_codec_timer_ticks_to_us(uint32_t ticks) -{ - uint32_t timer_freq; +uint32_t hal_codec_timer_ticks_to_us(uint32_t ticks) { + uint32_t timer_freq; - timer_freq = cur_codec_freq / 4 / CODEC_FREQ_EXTRA_DIV; + timer_freq = cur_codec_freq / 4 / CODEC_FREQ_EXTRA_DIV; - return (uint32_t)((float)ticks * 1000000 / timer_freq); + return (uint32_t)((float)ticks * 1000000 / timer_freq); } -void hal_codec_timer_trigger_read(void) -{ - if (codec_opened) { - codec->REG_078 ^= CODEC_GET_CNT_TRIG; - hal_codec_reg_update_delay(); - } +void hal_codec_timer_trigger_read(void) { + if (codec_opened) { + codec->REG_078 ^= CODEC_GET_CNT_TRIG; + hal_codec_reg_update_delay(); + } } #endif #ifdef AUDIO_OUTPUT_DC_CALIB_ANA -int hal_codec_dac_sdm_reset_set(void) -{ - if (codec_opened) { - hal_codec_set_dac_gain_value(VALID_DAC_MAP, 0); - if (codec->REG_098 & CODEC_CODEC_DAC_EN) { - osDelay(dac_delay_ms); - } - for (int i = 0x200; i >= 0; i -= 0x100) { - hal_codec_dac_dc_offset_enable(i, i); - osDelay(1); - } - codec->REG_098 |= CODEC_CODEC_DAC_SDM_CLOSE; - osDelay(1); +int hal_codec_dac_sdm_reset_set(void) { + if (codec_opened) { + hal_codec_set_dac_gain_value(VALID_DAC_MAP, 0); + if (codec->REG_098 & CODEC_CODEC_DAC_EN) { + osDelay(dac_delay_ms); } + for (int i = 0x200; i >= 0; i -= 0x100) { + hal_codec_dac_dc_offset_enable(i, i); + osDelay(1); + } + codec->REG_098 |= CODEC_CODEC_DAC_SDM_CLOSE; + osDelay(1); + } - return 0; + return 0; } -int hal_codec_dac_sdm_reset_clear(void) -{ - if (codec_opened) { - osDelay(1); - codec->REG_098 &= ~CODEC_CODEC_DAC_SDM_CLOSE; - for (int i = 0x100; i <= 0x300; i += 0x100) { - hal_codec_dac_dc_offset_enable(i, i); - osDelay(1); - } - hal_codec_restore_dig_dac_gain(); +int hal_codec_dac_sdm_reset_clear(void) { + if (codec_opened) { + osDelay(1); + codec->REG_098 &= ~CODEC_CODEC_DAC_SDM_CLOSE; + for (int i = 0x100; i <= 0x300; i += 0x100) { + hal_codec_dac_dc_offset_enable(i, i); + osDelay(1); } + hal_codec_restore_dig_dac_gain(); + } - return 0; + return 0; } #endif -void hal_codec_tune_resample_rate(enum AUD_STREAM_T stream, float ratio) -{ +void hal_codec_tune_resample_rate(enum AUD_STREAM_T stream, float ratio) { #ifdef __AUDIO_RESAMPLE__ - uint32_t val; + uint32_t val; - if (!codec_opened) { - return; - } + if (!codec_opened) { + return; + } - if (stream == AUD_STREAM_PLAYBACK) { - if (codec->REG_0E4 & CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE) { - codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; - hal_codec_reg_update_delay(); - val = resample_phase_float_to_value(get_playback_resample_phase()); - val += (int)(val * ratio); - codec->REG_0F4 = val; - hal_codec_reg_update_delay(); - codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; - } - } else { - if (codec->REG_0E4 & CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE) { - codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; - hal_codec_reg_update_delay(); - val = resample_phase_float_to_value(get_capture_resample_phase()); - val -= (int)(val * ratio); - codec->REG_0F8 = val; - hal_codec_reg_update_delay(); - codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; - } + if (stream == AUD_STREAM_PLAYBACK) { + if (codec->REG_0E4 & CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE) { + codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; + hal_codec_reg_update_delay(); + val = resample_phase_float_to_value(get_playback_resample_phase()); + val += (int)(val * ratio); + codec->REG_0F4 = val; + hal_codec_reg_update_delay(); + codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; } + } else { + if (codec->REG_0E4 & CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE) { + codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; + hal_codec_reg_update_delay(); + val = resample_phase_float_to_value(get_capture_resample_phase()); + val -= (int)(val * ratio); + codec->REG_0F8 = val; + hal_codec_reg_update_delay(); + codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; + } + } #endif } -void hal_codec_tune_both_resample_rate(float ratio) -{ +void hal_codec_tune_both_resample_rate(float ratio) { #ifdef __AUDIO_RESAMPLE__ - bool update[2]; - uint32_t val[2]; - uint32_t lock; + bool update[2]; + uint32_t val[2]; + uint32_t lock; - if (!codec_opened) { - return; - } + if (!codec_opened) { + return; + } - update[0] = !!(codec->REG_0E4 & CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE); - update[1] = !!(codec->REG_0E4 & CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE); + update[0] = !!(codec->REG_0E4 & CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE); + update[1] = !!(codec->REG_0E4 & CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE); - val[0] = val[1] = 0; + val[0] = val[1] = 0; - if (update[0]) { - codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; - val[0] = resample_phase_float_to_value(get_playback_resample_phase()); - val[0] += (int)(val[0] * ratio); - } - if (update[1]) { - codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; - val[1] = resample_phase_float_to_value(get_capture_resample_phase()); - val[1] -= (int)(val[1] * ratio); - } + if (update[0]) { + codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; + val[0] = resample_phase_float_to_value(get_playback_resample_phase()); + val[0] += (int)(val[0] * ratio); + } + if (update[1]) { + codec->REG_0E4 &= ~CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; + val[1] = resample_phase_float_to_value(get_capture_resample_phase()); + val[1] -= (int)(val[1] * ratio); + } - hal_codec_reg_update_delay(); + hal_codec_reg_update_delay(); - if (update[0]) { - codec->REG_0F4 = val[0]; - } - if (update[1]) { - codec->REG_0F8 = val[1]; - } + if (update[0]) { + codec->REG_0F4 = val[0]; + } + if (update[1]) { + codec->REG_0F8 = val[1]; + } - hal_codec_reg_update_delay(); + hal_codec_reg_update_delay(); - lock = int_lock(); - if (update[0]) { - codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; - } - if (update[1]) { - codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; - } - int_unlock(lock); + lock = int_lock(); + if (update[0]) { + codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_DAC_PHASE_UPDATE; + } + if (update[1]) { + codec->REG_0E4 |= CODEC_CODEC_RESAMPLE_ADC_PHASE_UPDATE; + } + int_unlock(lock); #endif } -int hal_codec_select_clock_out(uint32_t cfg) -{ - uint32_t lock; - int ret = 1; +int hal_codec_select_clock_out(uint32_t cfg) { + uint32_t lock; + int ret = 1; - lock = int_lock(); + lock = int_lock(); - if (codec_opened) { - codec->REG_060 = SET_BITFIELD(codec->REG_060, CODEC_CFG_CLK_OUT, cfg); - ret = 0; - } + if (codec_opened) { + codec->REG_060 = SET_BITFIELD(codec->REG_060, CODEC_CFG_CLK_OUT, cfg); + ret = 0; + } - int_unlock(lock); + int_unlock(lock); - return ret; + return ret; } #ifdef AUDIO_ANC_FB_MC -void hal_codec_setup_mc(enum AUD_CHANNEL_NUM_T channel_num, enum AUD_BITS_T bits) -{ - if (channel_num == AUD_CHANNEL_NUM_2) { - mc_dual_chan = true; - } else { - mc_dual_chan = false; - } +void hal_codec_setup_mc(enum AUD_CHANNEL_NUM_T channel_num, + enum AUD_BITS_T bits) { + if (channel_num == AUD_CHANNEL_NUM_2) { + mc_dual_chan = true; + } else { + mc_dual_chan = false; + } - if (bits <= AUD_BITS_16) { - mc_16bit = true; - } else { - mc_16bit = false; - } + if (bits <= AUD_BITS_16) { + mc_16bit = true; + } else { + mc_16bit = false; + } } #endif -void hal_codec_swap_output(bool swap) -{ +void hal_codec_swap_output(bool swap) { #ifdef AUDIO_OUTPUT_SWAP - output_swap = swap; + output_swap = swap; - if (codec_opened) { - if (output_swap) { - codec->REG_0A0 |= CODEC_CODEC_DAC_OUT_SWAP; - } else { - codec->REG_0A0 &= ~CODEC_CODEC_DAC_OUT_SWAP; - } - } -#endif -} - -int hal_codec_config_digmic_phase(uint8_t phase) -{ -#ifdef ANC_PROD_TEST - codec_digmic_phase = phase; -#endif - return 0; -} - -static void hal_codec_general_irq_handler(void) -{ - uint32_t status; - - status = codec->REG_00C; - codec->REG_00C = status; - - status &= codec->REG_010; - - for (int i = 0; i < CODEC_IRQ_TYPE_QTY; i++) { - if (codec_irq_callback[i]) { - codec_irq_callback[i](status); - } - } -} - -static void hal_codec_set_irq_handler(enum CODEC_IRQ_TYPE_T type, HAL_CODEC_IRQ_CALLBACK cb) -{ - uint32_t lock; - - ASSERT(type < CODEC_IRQ_TYPE_QTY, "%s: Bad type=%d", __func__, type); - - lock = int_lock(); - - codec_irq_callback[type] = cb; - - if (cb) { - if (codec_irq_map == 0) { - NVIC_SetVector(CODEC_IRQn, (uint32_t)hal_codec_general_irq_handler); - NVIC_SetPriority(CODEC_IRQn, IRQ_PRIORITY_HIGHPLUSPLUS); - NVIC_ClearPendingIRQ(CODEC_IRQn); - NVIC_EnableIRQ(CODEC_IRQn); - } - codec_irq_map |= (1 << type); + if (codec_opened) { + if (output_swap) { + codec->REG_0A0 |= CODEC_CODEC_DAC_OUT_SWAP; } else { - codec_irq_map &= ~(1 << type); - if (codec_irq_map == 0) { - NVIC_DisableIRQ(CODEC_IRQn); - NVIC_ClearPendingIRQ(CODEC_IRQn); - } + codec->REG_0A0 &= ~CODEC_CODEC_DAC_OUT_SWAP; } - - int_unlock(lock); + } +#endif } -void hal_codec_anc_fb_check_set_irq_handler(HAL_CODEC_IRQ_CALLBACK cb) -{ - hal_codec_set_irq_handler(CODEC_IRQ_TYPE_ANC_FB_CHECK, cb); +int hal_codec_config_digmic_phase(uint8_t phase) { +#ifdef ANC_PROD_TEST + codec_digmic_phase = phase; +#endif + return 0; +} + +static void hal_codec_general_irq_handler(void) { + uint32_t status; + + status = codec->REG_00C; + codec->REG_00C = status; + + status &= codec->REG_010; + + for (int i = 0; i < CODEC_IRQ_TYPE_QTY; i++) { + if (codec_irq_callback[i]) { + codec_irq_callback[i](status); + } + } +} + +static void hal_codec_set_irq_handler(enum CODEC_IRQ_TYPE_T type, + HAL_CODEC_IRQ_CALLBACK cb) { + uint32_t lock; + + ASSERT(type < CODEC_IRQ_TYPE_QTY, "%s: Bad type=%d", __func__, type); + + lock = int_lock(); + + codec_irq_callback[type] = cb; + + if (cb) { + if (codec_irq_map == 0) { + NVIC_SetVector(CODEC_IRQn, (uint32_t)hal_codec_general_irq_handler); + NVIC_SetPriority(CODEC_IRQn, IRQ_PRIORITY_HIGHPLUSPLUS); + NVIC_ClearPendingIRQ(CODEC_IRQn); + NVIC_EnableIRQ(CODEC_IRQn); + } + codec_irq_map |= (1 << type); + } else { + codec_irq_map &= ~(1 << type); + if (codec_irq_map == 0) { + NVIC_DisableIRQ(CODEC_IRQn); + NVIC_ClearPendingIRQ(CODEC_IRQn); + } + } + + int_unlock(lock); +} + +void hal_codec_anc_fb_check_set_irq_handler(HAL_CODEC_IRQ_CALLBACK cb) { + hal_codec_set_irq_handler(CODEC_IRQ_TYPE_ANC_FB_CHECK, cb); } /* AUDIO CODEC VOICE ACTIVE DETECTION DRIVER */ @@ -3686,512 +3916,483 @@ void hal_codec_anc_fb_check_set_irq_handler(HAL_CODEC_IRQ_CALLBACK cb) //#define CODEC_VAD_DEBUG -static inline void hal_codec_vad_set_udc(int v) -{ - codec->REG_14C &= ~CODEC_VAD_U_DC(0xf); - codec->REG_14C |= CODEC_VAD_U_DC(v); +static inline void hal_codec_vad_set_udc(int v) { + codec->REG_14C &= ~CODEC_VAD_U_DC(0xf); + codec->REG_14C |= CODEC_VAD_U_DC(v); } -static inline void hal_codec_vad_set_upre(int v) -{ - codec->REG_14C &= ~CODEC_VAD_U_PRE(0x7); - codec->REG_14C |= CODEC_VAD_U_PRE(v); +static inline void hal_codec_vad_set_upre(int v) { + codec->REG_14C &= ~CODEC_VAD_U_PRE(0x7); + codec->REG_14C |= CODEC_VAD_U_PRE(v); } -static inline void hal_codec_vad_set_frame_len(int v) -{ - codec->REG_14C &= ~CODEC_VAD_FRAME_LEN(0xff); - codec->REG_14C |= CODEC_VAD_FRAME_LEN(v); +static inline void hal_codec_vad_set_frame_len(int v) { + codec->REG_14C &= ~CODEC_VAD_FRAME_LEN(0xff); + codec->REG_14C |= CODEC_VAD_FRAME_LEN(v); } -static inline void hal_codec_vad_set_mvad(int v) -{ - codec->REG_14C &= ~CODEC_VAD_MVAD(0xf); - codec->REG_14C |= CODEC_VAD_MVAD(v); +static inline void hal_codec_vad_set_mvad(int v) { + codec->REG_14C &= ~CODEC_VAD_MVAD(0xf); + codec->REG_14C |= CODEC_VAD_MVAD(v); } -static inline void hal_codec_vad_set_pre_gain(int v) -{ - codec->REG_14C &= ~CODEC_VAD_PRE_GAIN(0x3f); - codec->REG_14C |= CODEC_VAD_PRE_GAIN(v); +static inline void hal_codec_vad_set_pre_gain(int v) { + codec->REG_14C &= ~CODEC_VAD_PRE_GAIN(0x3f); + codec->REG_14C |= CODEC_VAD_PRE_GAIN(v); } -static inline void hal_codec_vad_set_sth(int v) -{ - codec->REG_14C &= ~CODEC_VAD_STH(0x3f); - codec->REG_14C |= CODEC_VAD_STH(v); +static inline void hal_codec_vad_set_sth(int v) { + codec->REG_14C &= ~CODEC_VAD_STH(0x3f); + codec->REG_14C |= CODEC_VAD_STH(v); } -static inline void hal_codec_vad_set_frame_th1(int v) -{ - codec->REG_150 &= ~CODEC_VAD_FRAME_TH1(0xff); - codec->REG_150 |= CODEC_VAD_FRAME_TH1(v); +static inline void hal_codec_vad_set_frame_th1(int v) { + codec->REG_150 &= ~CODEC_VAD_FRAME_TH1(0xff); + codec->REG_150 |= CODEC_VAD_FRAME_TH1(v); } -static inline void hal_codec_vad_set_frame_th2(int v) -{ - codec->REG_150 &= ~CODEC_VAD_FRAME_TH2(0x3ff); - codec->REG_150 |= CODEC_VAD_FRAME_TH2(v); +static inline void hal_codec_vad_set_frame_th2(int v) { + codec->REG_150 &= ~CODEC_VAD_FRAME_TH2(0x3ff); + codec->REG_150 |= CODEC_VAD_FRAME_TH2(v); } -static inline void hal_codec_vad_set_frame_th3(int v) -{ - codec->REG_150 &= ~CODEC_VAD_FRAME_TH3(0x3fff); - codec->REG_150 |= CODEC_VAD_FRAME_TH3(v); +static inline void hal_codec_vad_set_frame_th3(int v) { + codec->REG_150 &= ~CODEC_VAD_FRAME_TH3(0x3fff); + codec->REG_150 |= CODEC_VAD_FRAME_TH3(v); } -static inline void hal_codec_vad_set_range1(int v) -{ - codec->REG_154 &= ~CODEC_VAD_RANGE1(0x1f); - codec->REG_154 |= CODEC_VAD_RANGE1(v); +static inline void hal_codec_vad_set_range1(int v) { + codec->REG_154 &= ~CODEC_VAD_RANGE1(0x1f); + codec->REG_154 |= CODEC_VAD_RANGE1(v); } -static inline void hal_codec_vad_set_range2(int v) -{ - codec->REG_154 &= ~CODEC_VAD_RANGE2(0x7f); - codec->REG_154 |= CODEC_VAD_RANGE2(v); +static inline void hal_codec_vad_set_range2(int v) { + codec->REG_154 &= ~CODEC_VAD_RANGE2(0x7f); + codec->REG_154 |= CODEC_VAD_RANGE2(v); } -static inline void hal_codec_vad_set_range3(int v) -{ - codec->REG_154 &= ~CODEC_VAD_RANGE3(0x1ff); - codec->REG_154 |= CODEC_VAD_RANGE3(v); +static inline void hal_codec_vad_set_range3(int v) { + codec->REG_154 &= ~CODEC_VAD_RANGE3(0x1ff); + codec->REG_154 |= CODEC_VAD_RANGE3(v); } -static inline void hal_codec_vad_set_range4(int v) -{ - codec->REG_154 &= ~CODEC_VAD_RANGE4(0x3ff); - codec->REG_154 |= CODEC_VAD_RANGE4(v); +static inline void hal_codec_vad_set_range4(int v) { + codec->REG_154 &= ~CODEC_VAD_RANGE4(0x3ff); + codec->REG_154 |= CODEC_VAD_RANGE4(v); } -static inline void hal_codec_vad_set_psd_th1(int v) -{ - codec->REG_158 &= ~CODEC_VAD_PSD_TH1(0x7ffffff); - codec->REG_158 |= CODEC_VAD_PSD_TH1(v); +static inline void hal_codec_vad_set_psd_th1(int v) { + codec->REG_158 &= ~CODEC_VAD_PSD_TH1(0x7ffffff); + codec->REG_158 |= CODEC_VAD_PSD_TH1(v); } -static inline void hal_codec_vad_set_psd_th2(int v) -{ - codec->REG_15C &= ~CODEC_VAD_PSD_TH2(0x7ffffff); - codec->REG_15C |= CODEC_VAD_PSD_TH2(v); +static inline void hal_codec_vad_set_psd_th2(int v) { + codec->REG_15C &= ~CODEC_VAD_PSD_TH2(0x7ffffff); + codec->REG_15C |= CODEC_VAD_PSD_TH2(v); } -static inline void hal_codec_vad_en(int enable) -{ - if (enable) { - codec->REG_148 |= CODEC_VAD_EN; //enable vad - } else { - codec->REG_148 &= ~CODEC_VAD_EN; //disable vad - codec->REG_148 |= CODEC_VAD_FINISH; - } +static inline void hal_codec_vad_en(int enable) { + if (enable) { + codec->REG_148 |= CODEC_VAD_EN; // enable vad + } else { + codec->REG_148 &= ~CODEC_VAD_EN; // disable vad + codec->REG_148 |= CODEC_VAD_FINISH; + } } -static inline void hal_codec_vad_bypass_ds(int bypass) -{ - if (bypass) - codec->REG_148 |= CODEC_VAD_DS_BYPASS; //bypass ds - else - codec->REG_148 &= ~CODEC_VAD_DS_BYPASS; //not bypass ds +static inline void hal_codec_vad_bypass_ds(int bypass) { + if (bypass) + codec->REG_148 |= CODEC_VAD_DS_BYPASS; // bypass ds + else + codec->REG_148 &= ~CODEC_VAD_DS_BYPASS; // not bypass ds } -static inline void hal_codec_vad_bypass_dc(int bypass) -{ - if (bypass) - codec->REG_148 |= CODEC_VAD_DC_CANCEL_BYPASS; // bypass dc - else - codec->REG_148 &= ~CODEC_VAD_DC_CANCEL_BYPASS; //not bypass dc +static inline void hal_codec_vad_bypass_dc(int bypass) { + if (bypass) + codec->REG_148 |= CODEC_VAD_DC_CANCEL_BYPASS; // bypass dc + else + codec->REG_148 &= ~CODEC_VAD_DC_CANCEL_BYPASS; // not bypass dc } -static inline void hal_codec_vad_bypass_pre(int bypass) -{ - if (bypass) - codec->REG_148 |= CODEC_VAD_PRE_BYPASS; //bypass pre - else - codec->REG_148 &= ~CODEC_VAD_PRE_BYPASS; //not bypass pre +static inline void hal_codec_vad_bypass_pre(int bypass) { + if (bypass) + codec->REG_148 |= CODEC_VAD_PRE_BYPASS; // bypass pre + else + codec->REG_148 &= ~CODEC_VAD_PRE_BYPASS; // not bypass pre } -static inline void hal_codec_vad_dig_mode(int enable) -{ - if (enable) - codec->REG_148 |= CODEC_VAD_DIG_MODE; //digital mode - else - codec->REG_148 &= ~CODEC_VAD_DIG_MODE; //not digital mode +static inline void hal_codec_vad_dig_mode(int enable) { + if (enable) + codec->REG_148 |= CODEC_VAD_DIG_MODE; // digital mode + else + codec->REG_148 &= ~CODEC_VAD_DIG_MODE; // not digital mode } -static inline void hal_codec_vad_adc_en(int enable) -{ - if (enable) { - codec->REG_080 |= (CODEC_CODEC_ADC_EN | CODEC_CODEC_ADC_EN_CH4); - } else { - uint32_t val; +static inline void hal_codec_vad_adc_en(int enable) { + if (enable) { + codec->REG_080 |= (CODEC_CODEC_ADC_EN | CODEC_CODEC_ADC_EN_CH4); + } else { + uint32_t val; - val = codec->REG_080; - val &= ~CODEC_CODEC_ADC_EN_CH4; - if ((val & (CODEC_CODEC_ADC_EN_CH0 | CODEC_CODEC_ADC_EN_CH1 | + val = codec->REG_080; + val &= ~CODEC_CODEC_ADC_EN_CH4; + if ((val & (CODEC_CODEC_ADC_EN_CH0 | CODEC_CODEC_ADC_EN_CH1 | CODEC_CODEC_ADC_EN_CH2 | CODEC_CODEC_ADC_EN_CH3)) == 0) { - val &= ~CODEC_CODEC_ADC_EN; - } - codec->REG_080 = val; + val &= ~CODEC_CODEC_ADC_EN; } + codec->REG_080 = val; + } } -static inline void hal_codec_vad_irq_en(int enable) -{ - if (enable){ - codec->REG_010 |= (CODEC_VAD_FIND_MSK | CODEC_VAD_NOT_FIND_MSK); - } - else{ - codec->REG_010 &= ~(CODEC_VAD_FIND_MSK | CODEC_VAD_NOT_FIND_MSK); - } +static inline void hal_codec_vad_irq_en(int enable) { + if (enable) { + codec->REG_010 |= (CODEC_VAD_FIND_MSK | CODEC_VAD_NOT_FIND_MSK); + } else { + codec->REG_010 &= ~(CODEC_VAD_FIND_MSK | CODEC_VAD_NOT_FIND_MSK); + } - codec->REG_00C = CODEC_VAD_FIND | CODEC_VAD_NOT_FIND; + codec->REG_00C = CODEC_VAD_FIND | CODEC_VAD_NOT_FIND; } -static inline void hal_codec_vad_adc_if_en(int enable) -{ - if (enable) { - codec->REG_000 |= (CODEC_DMACTRL_RX | CODEC_ADC_ENABLE_CH4 | CODEC_ADC_ENABLE); - } else { - codec->REG_000 &= ~(CODEC_DMACTRL_RX | CODEC_ADC_ENABLE_CH4 | CODEC_ADC_ENABLE); - } +static inline void hal_codec_vad_adc_if_en(int enable) { + if (enable) { + codec->REG_000 |= + (CODEC_DMACTRL_RX | CODEC_ADC_ENABLE_CH4 | CODEC_ADC_ENABLE); + } else { + codec->REG_000 &= + ~(CODEC_DMACTRL_RX | CODEC_ADC_ENABLE_CH4 | CODEC_ADC_ENABLE); + } } -static inline void hal_codec_vad_adc_down(int v) -{ - unsigned int regval = codec->REG_094; +static inline void hal_codec_vad_adc_down(int v) { + unsigned int regval = codec->REG_094; - regval &= ~CODEC_CODEC_ADC_DOWN_SEL_CH4(0x3); - regval |= CODEC_CODEC_ADC_DOWN_SEL_CH4(v); - codec->REG_094 = regval; + regval &= ~CODEC_CODEC_ADC_DOWN_SEL_CH4(0x3); + regval |= CODEC_CODEC_ADC_DOWN_SEL_CH4(v); + codec->REG_094 = regval; } #ifdef CODEC_VAD_DEBUG -void hal_codec_vad_reg_dump(void) -{ - TRACE(1,"codec base = %8x\n", (int)&(codec->REG_000)); - TRACE(1,"codec->REG_000 = %x\n", codec->REG_000); - TRACE(1,"codec->REG_00C = %x\n", codec->REG_00C); - TRACE(1,"codec->REG_010 = %x\n", codec->REG_010); - TRACE(1,"codec->REG_060 = %x\n", codec->REG_060); - TRACE(1,"codec->REG_064 = %x\n", codec->REG_064); - TRACE(1,"codec->REG_080 = %x\n", codec->REG_080); - TRACE(1,"codec->REG_094 = %x\n", codec->REG_094); - TRACE(1,"codec->REG_148 = %x\n", codec->REG_148); - TRACE(1,"codec->REG_14C = %x\n", codec->REG_14C); - TRACE(1,"codec->REG_150 = %x\n", codec->REG_150); - TRACE(1,"codec->REG_154 = %x\n", codec->REG_154); - TRACE(1,"codec->REG_158 = %x\n", codec->REG_158); - TRACE(1,"codec->REG_15C = %x\n", codec->REG_15C); +void hal_codec_vad_reg_dump(void) { + TRACE(1, "codec base = %8x\n", (int)&(codec->REG_000)); + TRACE(1, "codec->REG_000 = %x\n", codec->REG_000); + TRACE(1, "codec->REG_00C = %x\n", codec->REG_00C); + TRACE(1, "codec->REG_010 = %x\n", codec->REG_010); + TRACE(1, "codec->REG_060 = %x\n", codec->REG_060); + TRACE(1, "codec->REG_064 = %x\n", codec->REG_064); + TRACE(1, "codec->REG_080 = %x\n", codec->REG_080); + TRACE(1, "codec->REG_094 = %x\n", codec->REG_094); + TRACE(1, "codec->REG_148 = %x\n", codec->REG_148); + TRACE(1, "codec->REG_14C = %x\n", codec->REG_14C); + TRACE(1, "codec->REG_150 = %x\n", codec->REG_150); + TRACE(1, "codec->REG_154 = %x\n", codec->REG_154); + TRACE(1, "codec->REG_158 = %x\n", codec->REG_158); + TRACE(1, "codec->REG_15C = %x\n", codec->REG_15C); } #endif -static inline void hal_codec_vad_data_info(uint32_t *data_cnt, uint32_t *addr_cnt) -{ - uint32_t regval = codec->REG_160; +static inline void hal_codec_vad_data_info(uint32_t *data_cnt, + uint32_t *addr_cnt) { + uint32_t regval = codec->REG_160; - *data_cnt = GET_BITFIELD(regval, CODEC_VAD_MEM_DATA_CNT) * 2; - if (*data_cnt >= ((CODEC_VAD_MEM_DATA_CNT_MASK >> CODEC_VAD_MEM_DATA_CNT_SHIFT) - 1) * 2) { - *data_cnt = ((CODEC_VAD_MEM_DATA_CNT_MASK >> CODEC_VAD_MEM_DATA_CNT_SHIFT) + 1) * 2; - } - *addr_cnt = GET_BITFIELD(regval, CODEC_VAD_MEM_ADDR_CNT) * 2; + *data_cnt = GET_BITFIELD(regval, CODEC_VAD_MEM_DATA_CNT) * 2; + if (*data_cnt >= + ((CODEC_VAD_MEM_DATA_CNT_MASK >> CODEC_VAD_MEM_DATA_CNT_SHIFT) - 1) * 2) { + *data_cnt = + ((CODEC_VAD_MEM_DATA_CNT_MASK >> CODEC_VAD_MEM_DATA_CNT_SHIFT) + 1) * 2; + } + *addr_cnt = GET_BITFIELD(regval, CODEC_VAD_MEM_ADDR_CNT) * 2; } -uint32_t hal_codec_vad_recv_data(uint8_t *dst, uint32_t dst_size) -{ - uint8_t *src = (uint8_t *)CODEC_VAD_BUF_ADDR; - const uint32_t src_size = CODEC_VAD_BUF_SIZE; - uint32_t len; - uint32_t start_pos; +uint32_t hal_codec_vad_recv_data(uint8_t *dst, uint32_t dst_size) { + uint8_t *src = (uint8_t *)CODEC_VAD_BUF_ADDR; + const uint32_t src_size = CODEC_VAD_BUF_SIZE; + uint32_t len; + uint32_t start_pos; - TRACE(5,"%s, dst=%x, dst_size=%d, vad_data_cnt=%d, vad_addr_cnt=%d", + TRACE(5, "%s, dst=%x, dst_size=%d, vad_data_cnt=%d, vad_addr_cnt=%d", __func__, (uint32_t)dst, dst_size, vad_data_cnt, vad_addr_cnt); - if (vad_data_cnt > src_size || vad_addr_cnt >= src_size) { - return 0; - } + if (vad_data_cnt > src_size || vad_addr_cnt >= src_size) { + return 0; + } - if (dst == NULL) { - return vad_data_cnt; - } + if (dst == NULL) { + return vad_data_cnt; + } - if (vad_addr_cnt >= vad_data_cnt) { - start_pos = vad_addr_cnt - vad_data_cnt; - } else { - // In this case (src_size == vad_data_cnt) - start_pos = vad_addr_cnt + src_size - vad_data_cnt; - } + if (vad_addr_cnt >= vad_data_cnt) { + start_pos = vad_addr_cnt - vad_data_cnt; + } else { + // In this case (src_size == vad_data_cnt) + start_pos = vad_addr_cnt + src_size - vad_data_cnt; + } - len = MIN(dst_size, vad_data_cnt); + len = MIN(dst_size, vad_data_cnt); - if (start_pos + len <= src_size) { - memcpy(dst, src + start_pos, len); - } else { - uint32_t len1, len2; - len1 = src_size - start_pos; - len2 = len - len1; - memcpy(dst, src + start_pos, len1); - memcpy(dst + len1, src, len2); - } + if (start_pos + len <= src_size) { + memcpy(dst, src + start_pos, len); + } else { + uint32_t len1, len2; + len1 = src_size - start_pos; + len2 = len - len1; + memcpy(dst, src + start_pos, len1); + memcpy(dst + len1, src, len2); + } - TRACE(2,"%s, len=%d", __func__, len); - return len; + TRACE(2, "%s, len=%d", __func__, len); + return len; } -void hal_codec_get_vad_data_info(struct CODEC_VAD_BUF_INFO_T* vad_buf_info) -{ - vad_buf_info->base_addr = CODEC_VAD_BUF_ADDR; - vad_buf_info->buf_size = CODEC_VAD_BUF_SIZE; - vad_buf_info->data_count = vad_data_cnt; - vad_buf_info->addr_count = vad_addr_cnt; +void hal_codec_get_vad_data_info(struct CODEC_VAD_BUF_INFO_T *vad_buf_info) { + vad_buf_info->base_addr = CODEC_VAD_BUF_ADDR; + vad_buf_info->buf_size = CODEC_VAD_BUF_SIZE; + vad_buf_info->data_count = vad_data_cnt; + vad_buf_info->addr_count = vad_addr_cnt; } -static void hal_codec_vad_isr(uint32_t irq_status) -{ - if ((irq_status & (CODEC_VAD_FIND | CODEC_VAD_NOT_FIND)) == 0) { - return; - } +static void hal_codec_vad_isr(uint32_t irq_status) { + if ((irq_status & (CODEC_VAD_FIND | CODEC_VAD_NOT_FIND)) == 0) { + return; + } - TRACE(2,"%s VAD_FIND=%d", __func__, !!(irq_status & CODEC_VAD_FIND)); + TRACE(2, "%s VAD_FIND=%d", __func__, !!(irq_status & CODEC_VAD_FIND)); - if (vad_handler) { - vad_handler(!!(irq_status & CODEC_VAD_FIND)); - } + if (vad_handler) { + vad_handler(!!(irq_status & CODEC_VAD_FIND)); + } } -int hal_codec_vad_config(const struct AUD_VAD_CONFIG_T *conf) -{ - unsigned int adc_channel_en = 0; - unsigned int cfg_set_mask = 0; - unsigned int cfg_clr_mask = 0; +int hal_codec_vad_config(const struct AUD_VAD_CONFIG_T *conf) { + unsigned int adc_channel_en = 0; + unsigned int cfg_set_mask = 0; + unsigned int cfg_clr_mask = 0; - if (!conf) - return -1; + if (!conf) + return -1; - vad_handler = conf->handler; + vad_handler = conf->handler; - hal_codec_vad_en(0); - hal_codec_vad_irq_en(0); + hal_codec_vad_en(0); + hal_codec_vad_irq_en(0); - hal_codec_vad_set_udc(conf->udc); - hal_codec_vad_set_upre(conf->upre); - hal_codec_vad_set_frame_len(conf->frame_len); - hal_codec_vad_set_mvad(conf->mvad); - hal_codec_vad_set_pre_gain(conf->pre_gain); - hal_codec_vad_set_sth(conf->sth); - hal_codec_vad_set_frame_th1(conf->frame_th[0]); - hal_codec_vad_set_frame_th2(conf->frame_th[1]); - hal_codec_vad_set_frame_th3(conf->frame_th[2]); - hal_codec_vad_set_range1(conf->range[0]); - hal_codec_vad_set_range2(conf->range[1]); - hal_codec_vad_set_range3(conf->range[2]); - hal_codec_vad_set_range4(conf->range[3]); - hal_codec_vad_set_psd_th1(conf->psd_th[0]); - hal_codec_vad_set_psd_th2(conf->psd_th[1]); - hal_codec_vad_dig_mode(0); - hal_codec_vad_bypass_dc(0); - hal_codec_vad_bypass_pre(0); + hal_codec_vad_set_udc(conf->udc); + hal_codec_vad_set_upre(conf->upre); + hal_codec_vad_set_frame_len(conf->frame_len); + hal_codec_vad_set_mvad(conf->mvad); + hal_codec_vad_set_pre_gain(conf->pre_gain); + hal_codec_vad_set_sth(conf->sth); + hal_codec_vad_set_frame_th1(conf->frame_th[0]); + hal_codec_vad_set_frame_th2(conf->frame_th[1]); + hal_codec_vad_set_frame_th3(conf->frame_th[2]); + hal_codec_vad_set_range1(conf->range[0]); + hal_codec_vad_set_range2(conf->range[1]); + hal_codec_vad_set_range3(conf->range[2]); + hal_codec_vad_set_range4(conf->range[3]); + hal_codec_vad_set_psd_th1(conf->psd_th[0]); + hal_codec_vad_set_psd_th2(conf->psd_th[1]); + hal_codec_vad_dig_mode(0); + hal_codec_vad_bypass_dc(0); + hal_codec_vad_bypass_pre(0); - if (conf->sample_rate == AUD_SAMPRATE_8000) { - // select adc down 8KHz - hal_codec_vad_adc_down(1); - hal_codec_vad_bypass_ds(1); - } else if (conf->sample_rate == AUD_SAMPRATE_16000) { - // select adc down 16KHz - hal_codec_vad_adc_down(0); - hal_codec_vad_bypass_ds(0); - } else { - ASSERT(false, "%s: Bad sample rate: %u", __func__, conf->sample_rate); - } + if (conf->sample_rate == AUD_SAMPRATE_8000) { + // select adc down 8KHz + hal_codec_vad_adc_down(1); + hal_codec_vad_bypass_ds(1); + } else if (conf->sample_rate == AUD_SAMPRATE_16000) { + // select adc down 16KHz + hal_codec_vad_adc_down(0); + hal_codec_vad_bypass_ds(0); + } else { + ASSERT(false, "%s: Bad sample rate: %u", __func__, conf->sample_rate); + } - cfg_clr_mask = CODEC_MODE_16BIT_ADC_CH0 | CODEC_MODE_16BIT_ADC_CH1 | CODEC_MODE_16BIT_ADC_CH2 | - CODEC_MODE_16BIT_ADC_CH3 | CODEC_MODE_16BIT_ADC_CH4 | CODEC_MODE_16BIT_ADC_CH5 | CODEC_MODE_16BIT_ADC_CH6 | - CODEC_MODE_24BIT_ADC | CODEC_MODE_32BIT_ADC; + cfg_clr_mask = CODEC_MODE_16BIT_ADC_CH0 | CODEC_MODE_16BIT_ADC_CH1 | + CODEC_MODE_16BIT_ADC_CH2 | CODEC_MODE_16BIT_ADC_CH3 | + CODEC_MODE_16BIT_ADC_CH4 | CODEC_MODE_16BIT_ADC_CH5 | + CODEC_MODE_16BIT_ADC_CH6 | CODEC_MODE_24BIT_ADC | + CODEC_MODE_32BIT_ADC; - if (conf->bits == AUD_BITS_16) { - cfg_set_mask |= CODEC_MODE_16BIT_ADC_CH0 | CODEC_MODE_16BIT_ADC_CH1 | CODEC_MODE_16BIT_ADC_CH2 | - CODEC_MODE_16BIT_ADC_CH3 | CODEC_MODE_16BIT_ADC_CH4 | CODEC_MODE_16BIT_ADC_CH5 | CODEC_MODE_16BIT_ADC_CH6; - } else if (conf->bits == AUD_BITS_24) { - cfg_set_mask |= CODEC_MODE_24BIT_ADC; - } else if (conf->bits == AUD_BITS_32) { - cfg_set_mask |= CODEC_MODE_32BIT_ADC; - } else { - ASSERT(false, "%s: Bad cap bits: %d", __func__, conf->bits); - } + if (conf->bits == AUD_BITS_16) { + cfg_set_mask |= CODEC_MODE_16BIT_ADC_CH0 | CODEC_MODE_16BIT_ADC_CH1 | + CODEC_MODE_16BIT_ADC_CH2 | CODEC_MODE_16BIT_ADC_CH3 | + CODEC_MODE_16BIT_ADC_CH4 | CODEC_MODE_16BIT_ADC_CH5 | + CODEC_MODE_16BIT_ADC_CH6; + } else if (conf->bits == AUD_BITS_24) { + cfg_set_mask |= CODEC_MODE_24BIT_ADC; + } else if (conf->bits == AUD_BITS_32) { + cfg_set_mask |= CODEC_MODE_32BIT_ADC; + } else { + ASSERT(false, "%s: Bad cap bits: %d", __func__, conf->bits); + } - for (int i = 0; i < MAX_ADC_CH_NUM; i++){ - adc_channel_en |= (CODEC_ADC_ENABLE_CH0 << i); - } + for (int i = 0; i < MAX_ADC_CH_NUM; i++) { + adc_channel_en |= (CODEC_ADC_ENABLE_CH0 << i); + } - if(((codec->REG_000 & adc_channel_en) != 0) && ((codec->REG_040 & cfg_set_mask) == 0)){ - ASSERT(false, "%s: Cap bits conflict: %d", __func__, conf->bits); - }else{ - codec->REG_040 = (codec->REG_040 & ~cfg_clr_mask) | cfg_set_mask; - } + if (((codec->REG_000 & adc_channel_en) != 0) && + ((codec->REG_040 & cfg_set_mask) == 0)) { + ASSERT(false, "%s: Cap bits conflict: %d", __func__, conf->bits); + } else { + codec->REG_040 = (codec->REG_040 & ~cfg_clr_mask) | cfg_set_mask; + } - codec->REG_220 = 320; - codec->REG_224 = 32000*3;//vad timeout value + codec->REG_220 = 320; + codec->REG_224 = 32000 * 3; // vad timeout value #ifdef I2C_VAD - codec->REG_230 |= CODEC_VAD_EXT_EN | CODEC_VAD_SRC_SEL; + codec->REG_230 |= CODEC_VAD_EXT_EN | CODEC_VAD_SRC_SEL; #endif #if !(defined(FIXED_CODEC_ADC_VOL) && defined(SINGLE_CODEC_ADC_VOL)) - const CODEC_ADC_VOL_T *adc_gain_db; + const CODEC_ADC_VOL_T *adc_gain_db; #ifdef SINGLE_CODEC_ADC_VOL - adc_gain_db = hal_codec_get_adc_volume(CODEC_SADC_VOL); + adc_gain_db = hal_codec_get_adc_volume(CODEC_SADC_VOL); #else - adc_gain_db = hal_codec_get_adc_volume(hal_codec_get_mic_chan_volume_level(AUD_CHANNEL_MAP_CH4)); + adc_gain_db = hal_codec_get_adc_volume( + hal_codec_get_mic_chan_volume_level(AUD_CHANNEL_MAP_CH4)); #endif - if (adc_gain_db) { - hal_codec_set_dig_adc_gain(AUD_CHANNEL_MAP_CH4, *adc_gain_db); - } + if (adc_gain_db) { + hal_codec_set_dig_adc_gain(AUD_CHANNEL_MAP_CH4, *adc_gain_db); + } #endif - return 0; + return 0; } -int hal_codec_vad_open(const struct AUD_VAD_CONFIG_T *conf) -{ - vad_type = conf->type; +int hal_codec_vad_open(const struct AUD_VAD_CONFIG_T *conf) { + vad_type = conf->type; - // open analog vad - analog_aud_vad_adc_enable(true); + // open analog vad + analog_aud_vad_adc_enable(true); - // enable vad clock - hal_cmu_codec_vad_clock_enable(1); + // enable vad clock + hal_cmu_codec_vad_clock_enable(1); - hal_codec_vad_config(conf); + hal_codec_vad_config(conf); - return 0; + return 0; } -int hal_codec_vad_close(void) -{ +int hal_codec_vad_close(void) { #ifdef I2C_VAD - codec->REG_230 &= ~(CODEC_VAD_EXT_EN | CODEC_VAD_SRC_SEL); + codec->REG_230 &= ~(CODEC_VAD_EXT_EN | CODEC_VAD_SRC_SEL); #endif - // disable vad clock - hal_cmu_codec_vad_clock_enable(0); + // disable vad clock + hal_cmu_codec_vad_clock_enable(0); - // close analog vad - analog_aud_vad_adc_enable(false); + // close analog vad + analog_aud_vad_adc_enable(false); - vad_type = AUD_VAD_TYPE_NONE; + vad_type = AUD_VAD_TYPE_NONE; - return 0; + return 0; } -int hal_codec_vad_start(void) -{ - if (vad_enabled) { - return 0; - } - vad_enabled = true; - vad_data_cnt = 0; - vad_addr_cnt = 0; - - hal_codec_vad_irq_en(1); - hal_codec_set_irq_handler(CODEC_IRQ_TYPE_VAD, hal_codec_vad_isr); - - if (vad_type == AUD_VAD_TYPE_MIX || vad_type == AUD_VAD_TYPE_DIG) { - // digital vad - hal_codec_vad_en(1); - // enable adc if - hal_codec_vad_adc_if_en(1); - // enable adc - hal_codec_vad_adc_en(1); - } - - analog_aud_vad_enable(vad_type, true); - +int hal_codec_vad_start(void) { + if (vad_enabled) { return 0; + } + vad_enabled = true; + vad_data_cnt = 0; + vad_addr_cnt = 0; + + hal_codec_vad_irq_en(1); + hal_codec_set_irq_handler(CODEC_IRQ_TYPE_VAD, hal_codec_vad_isr); + + if (vad_type == AUD_VAD_TYPE_MIX || vad_type == AUD_VAD_TYPE_DIG) { + // digital vad + hal_codec_vad_en(1); + // enable adc if + hal_codec_vad_adc_if_en(1); + // enable adc + hal_codec_vad_adc_en(1); + } + + analog_aud_vad_enable(vad_type, true); + + return 0; } -int hal_codec_vad_stop(void) -{ - if (!vad_enabled) { - return 0; - } - vad_enabled = false; - hal_codec_vad_data_info(&vad_data_cnt, &vad_addr_cnt); - - analog_aud_vad_enable(vad_type, false); - - hal_codec_vad_irq_en(0); - hal_codec_set_irq_handler(CODEC_IRQ_TYPE_VAD, NULL); - - if (vad_type == AUD_VAD_TYPE_MIX || vad_type == AUD_VAD_TYPE_DIG) { - hal_codec_vad_en(0); - hal_codec_vad_adc_if_en(0); - hal_codec_vad_adc_en(0); - } - +int hal_codec_vad_stop(void) { + if (!vad_enabled) { return 0; + } + vad_enabled = false; + hal_codec_vad_data_info(&vad_data_cnt, &vad_addr_cnt); + + analog_aud_vad_enable(vad_type, false); + + hal_codec_vad_irq_en(0); + hal_codec_set_irq_handler(CODEC_IRQ_TYPE_VAD, NULL); + + if (vad_type == AUD_VAD_TYPE_MIX || vad_type == AUD_VAD_TYPE_DIG) { + hal_codec_vad_en(0); + hal_codec_vad_adc_if_en(0); + hal_codec_vad_adc_en(0); + } + + return 0; } #endif //********************BT trigger functions: START******************** -static void hal_codec_bt_trigger_isr(uint32_t irq_status) -{ - if ((irq_status & CODEC_BT_TRIGGER) == 0) { - return; - } +static void hal_codec_bt_trigger_isr(uint32_t irq_status) { + if ((irq_status & CODEC_BT_TRIGGER) == 0) { + return; + } - if (bt_trigger_callback) { - TRACE(1,"[%s] bt_trigger_callback Start...", __func__); - bt_trigger_callback(); - } else { - TRACE(1,"[%s] bt_trigger_callback = NULL", __func__); - } + if (bt_trigger_callback) { + TRACE(1, "[%s] bt_trigger_callback Start...", __func__); + bt_trigger_callback(); + } else { + TRACE(1, "[%s] bt_trigger_callback = NULL", __func__); + } } -static inline void hal_codec_bt_trigger_irq_en(int enable) -{ - if (enable) - codec->REG_010 |= CODEC_BT_TRIGGER_MSK; - else - codec->REG_010 &= ~CODEC_BT_TRIGGER_MSK; +static inline void hal_codec_bt_trigger_irq_en(int enable) { + if (enable) + codec->REG_010 |= CODEC_BT_TRIGGER_MSK; + else + codec->REG_010 &= ~CODEC_BT_TRIGGER_MSK; - codec->REG_00C = CODEC_BT_TRIGGER; + codec->REG_00C = CODEC_BT_TRIGGER; } -void hal_codec_set_bt_trigger_callback(HAL_CODEC_BT_TRIGGER_CALLBACK callback) -{ - bt_trigger_callback = callback; +void hal_codec_set_bt_trigger_callback(HAL_CODEC_BT_TRIGGER_CALLBACK callback) { + bt_trigger_callback = callback; } -int hal_codec_bt_trigger_start(void) -{ - uint32_t lock; +int hal_codec_bt_trigger_start(void) { + uint32_t lock; - TRACE(1,"[%s] Start", __func__); + TRACE(1, "[%s] Start", __func__); - lock = int_lock(); + lock = int_lock(); - hal_codec_set_irq_handler(CODEC_IRQ_TYPE_BT_TRIGGER, hal_codec_bt_trigger_isr); - hal_codec_bt_trigger_irq_en(1); + hal_codec_set_irq_handler(CODEC_IRQ_TYPE_BT_TRIGGER, + hal_codec_bt_trigger_isr); + hal_codec_bt_trigger_irq_en(1); - int_unlock(lock); + int_unlock(lock); - return 0; + return 0; } -int hal_codec_bt_trigger_stop(void) -{ - uint32_t lock; +int hal_codec_bt_trigger_stop(void) { + uint32_t lock; - TRACE(1,"[%s] Stop", __func__); + TRACE(1, "[%s] Stop", __func__); - lock = int_lock(); + lock = int_lock(); - hal_codec_bt_trigger_irq_en(0); - hal_codec_set_irq_handler(CODEC_IRQ_TYPE_BT_TRIGGER, NULL); + hal_codec_bt_trigger_irq_en(0); + hal_codec_set_irq_handler(CODEC_IRQ_TYPE_BT_TRIGGER, NULL); - int_unlock(lock); + int_unlock(lock); - return 0; + return 0; } //********************BT trigger functions: END******************** - diff --git a/platform/hal/best2300p/hal_iomux_best2300p.c b/platform/hal/best2300p/hal_iomux_best2300p.c index 3d8dc06..b1bd641 100644 --- a/platform/hal/best2300p/hal_iomux_best2300p.c +++ b/platform/hal/best2300p/hal_iomux_best2300p.c @@ -15,240 +15,436 @@ ****************************************************************************/ #include "plat_addr_map.h" #include CHIP_SPECIFIC_HDR(reg_iomux) -#include "hal_iomux.h" #include "hal_chipid.h" #include "hal_gpio.h" +#include "hal_iomux.h" #include "hal_location.h" #include "hal_timer.h" #include "hal_trace.h" #include "pmu.h" #ifdef I2S0_VOLTAGE_VMEM -#define I2S0_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_MEM +#define I2S0_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_MEM #else -#define I2S0_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_VIO +#define I2S0_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_VIO #endif #ifdef I2S1_VOLTAGE_VMEM -#define I2S1_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_MEM +#define I2S1_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_MEM #else -#define I2S1_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_VIO +#define I2S1_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_VIO #endif #ifdef SPDIF0_VOLTAGE_VMEM -#define SPDIF0_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_MEM +#define SPDIF0_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_MEM #else -#define SPDIF0_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_VIO +#define SPDIF0_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_VIO #endif #ifdef DIGMIC_VOLTAGE_VMEM -#define DIGMIC_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_MEM +#define DIGMIC_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_MEM #else -#define DIGMIC_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_VIO +#define DIGMIC_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_VIO #endif #ifdef SPI_VOLTAGE_VMEM -#define SPI_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_MEM +#define SPI_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_MEM #else -#define SPI_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_VIO +#define SPI_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_VIO #endif #ifdef SPILCD_VOLTAGE_VMEM -#define SPILCD_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_MEM +#define SPILCD_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_MEM #else -#define SPILCD_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_VIO +#define SPILCD_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_VIO #endif #ifdef I2C0_VOLTAGE_VMEM -#define I2C0_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_MEM +#define I2C0_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_MEM #else -#define I2C0_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_VIO +#define I2C0_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_VIO #endif #ifdef I2C1_VOLTAGE_VMEM -#define I2C1_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_MEM +#define I2C1_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_MEM #else -#define I2C1_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_VIO +#define I2C1_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_VIO #endif #ifdef CLKOUT_VOLTAGE_VMEM -#define CLKOUT_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_MEM +#define CLKOUT_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_MEM #else -#define CLKOUT_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_VIO +#define CLKOUT_VOLTAGE_SEL HAL_IOMUX_PIN_VOLTAGE_VIO #endif #ifndef I2S0_IOMUX_INDEX -#define I2S0_IOMUX_INDEX 0 +#define I2S0_IOMUX_INDEX 0 #endif #ifndef I2S1_IOMUX_INDEX -#define I2S1_IOMUX_INDEX 0 +#define I2S1_IOMUX_INDEX 0 #endif #ifndef I2S_MCLK_IOMUX_INDEX -#define I2S_MCLK_IOMUX_INDEX 0 +#define I2S_MCLK_IOMUX_INDEX 0 #endif #ifndef SPDIF0_IOMUX_INDEX -#define SPDIF0_IOMUX_INDEX 0 +#define SPDIF0_IOMUX_INDEX 0 #endif #ifndef DIG_MIC2_CK_IOMUX_INDEX -#define DIG_MIC2_CK_IOMUX_INDEX 0 +#define DIG_MIC2_CK_IOMUX_INDEX 0 #endif #ifndef DIG_MIC3_CK_IOMUX_INDEX -#define DIG_MIC3_CK_IOMUX_INDEX 0 +#define DIG_MIC3_CK_IOMUX_INDEX 0 #endif #ifndef DIG_MIC_CK_IOMUX_PIN -#define DIG_MIC_CK_IOMUX_PIN 0 +#define DIG_MIC_CK_IOMUX_PIN 0 #endif #ifndef DIG_MIC_D0_IOMUX_PIN -#define DIG_MIC_D0_IOMUX_PIN 1 +#define DIG_MIC_D0_IOMUX_PIN 1 #endif #ifndef DIG_MIC_D1_IOMUX_PIN -#define DIG_MIC_D1_IOMUX_PIN 2 +#define DIG_MIC_D1_IOMUX_PIN 2 #endif #ifndef DIG_MIC_D2_IOMUX_PIN -#define DIG_MIC_D2_IOMUX_PIN 3 +#define DIG_MIC_D2_IOMUX_PIN 3 #endif #ifndef SPI_IOMUX_INDEX -#define SPI_IOMUX_INDEX 0 +#define SPI_IOMUX_INDEX 0 #endif #ifndef SPILCD_IOMUX_INDEX -#define SPILCD_IOMUX_INDEX 0 +#define SPILCD_IOMUX_INDEX 0 #endif #ifndef I2C0_IOMUX_INDEX -#define I2C0_IOMUX_INDEX 0 +#define I2C0_IOMUX_INDEX 0 #endif #ifndef I2C1_IOMUX_INDEX -#define I2C1_IOMUX_INDEX 0 +#define I2C1_IOMUX_INDEX 0 #endif #ifndef CLKOUT_IOMUX_INDEX -#define CLKOUT_IOMUX_INDEX 0 +#define CLKOUT_IOMUX_INDEX 0 #endif -#define IOMUX_FUNC_VAL_GPIO 0 +#define IOMUX_FUNC_VAL_GPIO 0 -#define IOMUX_ALT_FUNC_NUM 6 +#define IOMUX_ALT_FUNC_NUM 6 -// Other func values: 0 -> gpio, 6 -> rf_ana, 7 -> jtag/btdm, 9 -> clk_req, 10 -> ana_test -static const uint8_t index_to_func_val[IOMUX_ALT_FUNC_NUM] = { 1, 2, 3, 4, 5, 8, }; - -static const enum HAL_IOMUX_FUNCTION_T pin_func_map[HAL_IOMUX_PIN_NUM][IOMUX_ALT_FUNC_NUM] = { - // P0_0 - { HAL_IOMUX_FUNC_I2S0_SDI0, HAL_IOMUX_FUNC_UART2_RX, HAL_IOMUX_FUNC_PCM_DI, HAL_IOMUX_FUNC_SPILCD_DI0, - HAL_IOMUX_FUNC_PDM0_CK, HAL_IOMUX_FUNC_SPILCD_DCN, }, - // P0_1 - { HAL_IOMUX_FUNC_I2S0_SDO, HAL_IOMUX_FUNC_UART2_TX, HAL_IOMUX_FUNC_PCM_DO, HAL_IOMUX_FUNC_SPILCD_DIO, - HAL_IOMUX_FUNC_PDM0_D, HAL_IOMUX_FUNC_NONE, }, - // P0_2 - { HAL_IOMUX_FUNC_I2S0_WS, HAL_IOMUX_FUNC_I2C_M1_SCL, HAL_IOMUX_FUNC_PCM_FSYNC, HAL_IOMUX_FUNC_SPILCD_CS0, - HAL_IOMUX_FUNC_PDM1_D, HAL_IOMUX_FUNC_NONE, }, - // P0_3 - { HAL_IOMUX_FUNC_I2S0_SCK, HAL_IOMUX_FUNC_I2C_M1_SDA, HAL_IOMUX_FUNC_PCM_CLK, HAL_IOMUX_FUNC_SPILCD_CLK, - HAL_IOMUX_FUNC_PDM2_D, HAL_IOMUX_FUNC_NONE, }, - // P0_4 - { HAL_IOMUX_FUNC_SDMMC_DATA7, HAL_IOMUX_FUNC_SPI_DI0, HAL_IOMUX_FUNC_I2S0_MCLK, HAL_IOMUX_FUNC_CLK_OUT, - HAL_IOMUX_FUNC_PDM1_CK, HAL_IOMUX_FUNC_SPI_DCN, }, - // P0_5 - { HAL_IOMUX_FUNC_SDMMC_DATA6, HAL_IOMUX_FUNC_SPI_CLK, HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_SPILCD_CS1, - HAL_IOMUX_FUNC_PDM1_D, HAL_IOMUX_FUNC_NONE, }, - // P0_6 - { HAL_IOMUX_FUNC_SDMMC_DATA5, HAL_IOMUX_FUNC_SPI_CS0, HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_SPILCD_CS2, - HAL_IOMUX_FUNC_PDM0_D, HAL_IOMUX_FUNC_NONE, }, - // P0_7 - { HAL_IOMUX_FUNC_SDMMC_DATA4, HAL_IOMUX_FUNC_SPI_DIO, HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_SPILCD_CS3, - HAL_IOMUX_FUNC_PDM2_D, HAL_IOMUX_FUNC_NONE, }, - // P1_0 - { HAL_IOMUX_FUNC_SDMMC_DATA2, HAL_IOMUX_FUNC_I2S1_SCK, HAL_IOMUX_FUNC_SPILCD_CLK, HAL_IOMUX_FUNC_SPI_CS1, - HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_NONE, }, - // P1_1 - { HAL_IOMUX_FUNC_SDMMC_DATA3, HAL_IOMUX_FUNC_I2S1_WS, HAL_IOMUX_FUNC_SPILCD_CS0, HAL_IOMUX_FUNC_SPI_CS2, - HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_NONE, }, - // P1_2 - { HAL_IOMUX_FUNC_SDMMC_CMD, HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_SPILCD_CS1, HAL_IOMUX_FUNC_SPI_CS3, - HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_NONE, }, - // P1_3 - { HAL_IOMUX_FUNC_SDMMC_CLK, HAL_IOMUX_FUNC_I2S0_MCLK, HAL_IOMUX_FUNC_SPILCD_DCN, HAL_IOMUX_FUNC_CLK_OUT, - HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_NONE, }, - // P1_4 - { HAL_IOMUX_FUNC_SDMMC_DATA0, HAL_IOMUX_FUNC_I2S1_SDI0, HAL_IOMUX_FUNC_SPILCD_DI0, HAL_IOMUX_FUNC_NONE, - HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_NONE, }, - // P1_5 - { HAL_IOMUX_FUNC_SDMMC_DATA1, HAL_IOMUX_FUNC_I2S1_SDO, HAL_IOMUX_FUNC_SPILCD_DIO, HAL_IOMUX_FUNC_I2S0_MCLK, - HAL_IOMUX_FUNC_CLK_OUT, HAL_IOMUX_FUNC_NONE, }, - // P1_6 - { HAL_IOMUX_FUNC_UART0_RX, HAL_IOMUX_FUNC_I2C_M0_SCL, HAL_IOMUX_FUNC_BT_UART_RX, HAL_IOMUX_FUNC_NONE, - HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_NONE, }, - // P1_7 - { HAL_IOMUX_FUNC_UART0_TX, HAL_IOMUX_FUNC_I2C_M0_SDA, HAL_IOMUX_FUNC_BT_UART_TX, HAL_IOMUX_FUNC_NONE, - HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_NONE, }, - // P2_0 - { HAL_IOMUX_FUNC_UART1_RX, HAL_IOMUX_FUNC_I2C_M0_SCL, HAL_IOMUX_FUNC_BT_UART_RX, HAL_IOMUX_FUNC_SPDIF0_DI, - HAL_IOMUX_FUNC_PWM0, HAL_IOMUX_FUNC_I2S0_MCLK, }, - // P2_1 - { HAL_IOMUX_FUNC_UART1_TX, HAL_IOMUX_FUNC_I2C_M0_SDA, HAL_IOMUX_FUNC_BT_UART_TX, HAL_IOMUX_FUNC_SPDIF0_DO, - HAL_IOMUX_FUNC_PWM1, HAL_IOMUX_FUNC_CLK_OUT, }, - // P2_2 - { HAL_IOMUX_FUNC_I2C_M1_SCL, HAL_IOMUX_FUNC_UART2_RX, HAL_IOMUX_FUNC_UART1_CTS, HAL_IOMUX_FUNC_BT_UART_CTS, - HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_I2S0_MCLK, }, - // P2_3 - { HAL_IOMUX_FUNC_I2C_M1_SDA, HAL_IOMUX_FUNC_UART2_TX, HAL_IOMUX_FUNC_UART1_RTS, HAL_IOMUX_FUNC_BT_UART_RTS, - HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_CLK_OUT, }, - // P2_4 - { HAL_IOMUX_FUNC_PWM0, HAL_IOMUX_FUNC_CLK_REQ_OUT, HAL_IOMUX_FUNC_SPI_DI3, HAL_IOMUX_FUNC_NONE, - HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_NONE, }, - // P2_5 - { HAL_IOMUX_FUNC_PWM1, HAL_IOMUX_FUNC_CLK_REQ_IN, HAL_IOMUX_FUNC_SPI_CS3, HAL_IOMUX_FUNC_NONE, - HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_NONE, }, - // P2_6 - { HAL_IOMUX_FUNC_PWM2, HAL_IOMUX_FUNC_SPILCD_DI1, HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_SPDIF0_DI, - HAL_IOMUX_FUNC_CLK_32K_IN, HAL_IOMUX_FUNC_NONE, }, - // P2_7 - { HAL_IOMUX_FUNC_PWM3, HAL_IOMUX_FUNC_SPILCD_CS1, HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_SPDIF0_DO, - HAL_IOMUX_FUNC_CLK_OUT, HAL_IOMUX_FUNC_NONE, }, - // P3_0 - { HAL_IOMUX_FUNC_SPILCD_DI2, HAL_IOMUX_FUNC_I2S1_SCK, HAL_IOMUX_FUNC_SPILCD_CS1, HAL_IOMUX_FUNC_NONE, - HAL_IOMUX_FUNC_PDM0_D, HAL_IOMUX_FUNC_NONE, }, - // P3_1 - { HAL_IOMUX_FUNC_SPILCD_CS2, HAL_IOMUX_FUNC_I2S1_WS, HAL_IOMUX_FUNC_SPILCD_CS3, HAL_IOMUX_FUNC_NONE, - HAL_IOMUX_FUNC_PDM1_D, HAL_IOMUX_FUNC_NONE, }, - // P3_2 - { HAL_IOMUX_FUNC_SPILCD_CS3, HAL_IOMUX_FUNC_I2S1_SDI0, HAL_IOMUX_FUNC_SPILCD_CS3, HAL_IOMUX_FUNC_NONE, - HAL_IOMUX_FUNC_PDM2_D, HAL_IOMUX_FUNC_NONE, }, - // P3_3 - { HAL_IOMUX_FUNC_SPILCD_DI3, HAL_IOMUX_FUNC_I2S1_SDO, HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_NONE, - HAL_IOMUX_FUNC_PDM2_CK, HAL_IOMUX_FUNC_NONE, }, - // P3_4 - { HAL_IOMUX_FUNC_PWM0, HAL_IOMUX_FUNC_SPI_DI1, HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_SPILCD_DI0, - HAL_IOMUX_FUNC_CLK_OUT, HAL_IOMUX_FUNC_SPILCD_DCN, }, - // P3_5 - { HAL_IOMUX_FUNC_PWM1, HAL_IOMUX_FUNC_SPI_CS1, HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_SPILCD_DIO, - HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_NONE, }, - // P3_6 - { HAL_IOMUX_FUNC_PWM2, HAL_IOMUX_FUNC_SPI_DI2, HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_SPILCD_CS0, - HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_NONE, }, - // P3_7 - { HAL_IOMUX_FUNC_PWM3, HAL_IOMUX_FUNC_SPI_CS2, HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_SPILCD_CLK, - HAL_IOMUX_FUNC_NONE, HAL_IOMUX_FUNC_NONE, }, +// Other func values: 0 -> gpio, 6 -> rf_ana, 7 -> jtag/btdm, 9 -> clk_req, 10 +// -> ana_test +static const uint8_t index_to_func_val[IOMUX_ALT_FUNC_NUM] = { + 1, 2, 3, 4, 5, 8, }; -static struct IOMUX_T * const iomux = (struct IOMUX_T *)IOMUX_BASE; +static const enum HAL_IOMUX_FUNCTION_T + pin_func_map[HAL_IOMUX_PIN_NUM][IOMUX_ALT_FUNC_NUM] = { + // P0_0 + { + HAL_IOMUX_FUNC_I2S0_SDI0, + HAL_IOMUX_FUNC_UART2_RX, + HAL_IOMUX_FUNC_PCM_DI, + HAL_IOMUX_FUNC_SPILCD_DI0, + HAL_IOMUX_FUNC_PDM0_CK, + HAL_IOMUX_FUNC_SPILCD_DCN, + }, + // P0_1 + { + HAL_IOMUX_FUNC_I2S0_SDO, + HAL_IOMUX_FUNC_UART2_TX, + HAL_IOMUX_FUNC_PCM_DO, + HAL_IOMUX_FUNC_SPILCD_DIO, + HAL_IOMUX_FUNC_PDM0_D, + HAL_IOMUX_FUNC_NONE, + }, + // P0_2 + { + HAL_IOMUX_FUNC_I2S0_WS, + HAL_IOMUX_FUNC_I2C_M1_SCL, + HAL_IOMUX_FUNC_PCM_FSYNC, + HAL_IOMUX_FUNC_SPILCD_CS0, + HAL_IOMUX_FUNC_PDM1_D, + HAL_IOMUX_FUNC_NONE, + }, + // P0_3 + { + HAL_IOMUX_FUNC_I2S0_SCK, + HAL_IOMUX_FUNC_I2C_M1_SDA, + HAL_IOMUX_FUNC_PCM_CLK, + HAL_IOMUX_FUNC_SPILCD_CLK, + HAL_IOMUX_FUNC_PDM2_D, + HAL_IOMUX_FUNC_NONE, + }, + // P0_4 + { + HAL_IOMUX_FUNC_SDMMC_DATA7, + HAL_IOMUX_FUNC_SPI_DI0, + HAL_IOMUX_FUNC_I2S0_MCLK, + HAL_IOMUX_FUNC_CLK_OUT, + HAL_IOMUX_FUNC_PDM1_CK, + HAL_IOMUX_FUNC_SPI_DCN, + }, + // P0_5 + { + HAL_IOMUX_FUNC_SDMMC_DATA6, + HAL_IOMUX_FUNC_SPI_CLK, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_SPILCD_CS1, + HAL_IOMUX_FUNC_PDM1_D, + HAL_IOMUX_FUNC_NONE, + }, + // P0_6 + { + HAL_IOMUX_FUNC_SDMMC_DATA5, + HAL_IOMUX_FUNC_SPI_CS0, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_SPILCD_CS2, + HAL_IOMUX_FUNC_PDM0_D, + HAL_IOMUX_FUNC_NONE, + }, + // P0_7 + { + HAL_IOMUX_FUNC_SDMMC_DATA4, + HAL_IOMUX_FUNC_SPI_DIO, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_SPILCD_CS3, + HAL_IOMUX_FUNC_PDM2_D, + HAL_IOMUX_FUNC_NONE, + }, + // P1_0 + { + HAL_IOMUX_FUNC_SDMMC_DATA2, + HAL_IOMUX_FUNC_I2S1_SCK, + HAL_IOMUX_FUNC_SPILCD_CLK, + HAL_IOMUX_FUNC_SPI_CS1, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_NONE, + }, + // P1_1 + { + HAL_IOMUX_FUNC_SDMMC_DATA3, + HAL_IOMUX_FUNC_I2S1_WS, + HAL_IOMUX_FUNC_SPILCD_CS0, + HAL_IOMUX_FUNC_SPI_CS2, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_NONE, + }, + // P1_2 + { + HAL_IOMUX_FUNC_SDMMC_CMD, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_SPILCD_CS1, + HAL_IOMUX_FUNC_SPI_CS3, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_NONE, + }, + // P1_3 + { + HAL_IOMUX_FUNC_SDMMC_CLK, + HAL_IOMUX_FUNC_I2S0_MCLK, + HAL_IOMUX_FUNC_SPILCD_DCN, + HAL_IOMUX_FUNC_CLK_OUT, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_NONE, + }, + // P1_4 + { + HAL_IOMUX_FUNC_SDMMC_DATA0, + HAL_IOMUX_FUNC_I2S1_SDI0, + HAL_IOMUX_FUNC_SPILCD_DI0, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_NONE, + }, + // P1_5 + { + HAL_IOMUX_FUNC_SDMMC_DATA1, + HAL_IOMUX_FUNC_I2S1_SDO, + HAL_IOMUX_FUNC_SPILCD_DIO, + HAL_IOMUX_FUNC_I2S0_MCLK, + HAL_IOMUX_FUNC_CLK_OUT, + HAL_IOMUX_FUNC_NONE, + }, + // P1_6 + { + HAL_IOMUX_FUNC_UART0_RX, + HAL_IOMUX_FUNC_I2C_M0_SCL, + HAL_IOMUX_FUNC_BT_UART_RX, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_NONE, + }, + // P1_7 + { + HAL_IOMUX_FUNC_UART0_TX, + HAL_IOMUX_FUNC_I2C_M0_SDA, + HAL_IOMUX_FUNC_BT_UART_TX, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_NONE, + }, + // P2_0 + { + HAL_IOMUX_FUNC_UART1_RX, + HAL_IOMUX_FUNC_I2C_M0_SCL, + HAL_IOMUX_FUNC_BT_UART_RX, + HAL_IOMUX_FUNC_SPDIF0_DI, + HAL_IOMUX_FUNC_PWM0, + HAL_IOMUX_FUNC_I2S0_MCLK, + }, + // P2_1 + { + HAL_IOMUX_FUNC_UART1_TX, + HAL_IOMUX_FUNC_I2C_M0_SDA, + HAL_IOMUX_FUNC_BT_UART_TX, + HAL_IOMUX_FUNC_SPDIF0_DO, + HAL_IOMUX_FUNC_PWM1, + HAL_IOMUX_FUNC_CLK_OUT, + }, + // P2_2 + { + HAL_IOMUX_FUNC_I2C_M1_SCL, + HAL_IOMUX_FUNC_UART2_RX, + HAL_IOMUX_FUNC_UART1_CTS, + HAL_IOMUX_FUNC_BT_UART_CTS, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_I2S0_MCLK, + }, + // P2_3 + { + HAL_IOMUX_FUNC_I2C_M1_SDA, + HAL_IOMUX_FUNC_UART2_TX, + HAL_IOMUX_FUNC_UART1_RTS, + HAL_IOMUX_FUNC_BT_UART_RTS, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_CLK_OUT, + }, + // P2_4 + { + HAL_IOMUX_FUNC_PWM0, + HAL_IOMUX_FUNC_CLK_REQ_OUT, + HAL_IOMUX_FUNC_SPI_DI3, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_NONE, + }, + // P2_5 + { + HAL_IOMUX_FUNC_PWM1, + HAL_IOMUX_FUNC_CLK_REQ_IN, + HAL_IOMUX_FUNC_SPI_CS3, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_NONE, + }, + // P2_6 + { + HAL_IOMUX_FUNC_PWM2, + HAL_IOMUX_FUNC_SPILCD_DI1, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_SPDIF0_DI, + HAL_IOMUX_FUNC_CLK_32K_IN, + HAL_IOMUX_FUNC_NONE, + }, + // P2_7 + { + HAL_IOMUX_FUNC_PWM3, + HAL_IOMUX_FUNC_SPILCD_CS1, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_SPDIF0_DO, + HAL_IOMUX_FUNC_CLK_OUT, + HAL_IOMUX_FUNC_NONE, + }, + // P3_0 + { + HAL_IOMUX_FUNC_SPILCD_DI2, + HAL_IOMUX_FUNC_I2S1_SCK, + HAL_IOMUX_FUNC_SPILCD_CS1, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_PDM0_D, + HAL_IOMUX_FUNC_NONE, + }, + // P3_1 + { + HAL_IOMUX_FUNC_SPILCD_CS2, + HAL_IOMUX_FUNC_I2S1_WS, + HAL_IOMUX_FUNC_SPILCD_CS3, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_PDM1_D, + HAL_IOMUX_FUNC_NONE, + }, + // P3_2 + { + HAL_IOMUX_FUNC_SPILCD_CS3, + HAL_IOMUX_FUNC_I2S1_SDI0, + HAL_IOMUX_FUNC_SPILCD_CS3, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_PDM2_D, + HAL_IOMUX_FUNC_NONE, + }, + // P3_3 + { + HAL_IOMUX_FUNC_SPILCD_DI3, + HAL_IOMUX_FUNC_I2S1_SDO, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_PDM2_CK, + HAL_IOMUX_FUNC_NONE, + }, + // P3_4 + { + HAL_IOMUX_FUNC_PWM0, + HAL_IOMUX_FUNC_SPI_DI1, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_SPILCD_DI0, + HAL_IOMUX_FUNC_CLK_OUT, + HAL_IOMUX_FUNC_SPILCD_DCN, + }, + // P3_5 + { + HAL_IOMUX_FUNC_PWM1, + HAL_IOMUX_FUNC_SPI_CS1, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_SPILCD_DIO, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_NONE, + }, + // P3_6 + { + HAL_IOMUX_FUNC_PWM2, + HAL_IOMUX_FUNC_SPI_DI2, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_SPILCD_CS0, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_NONE, + }, + // P3_7 + { + HAL_IOMUX_FUNC_PWM3, + HAL_IOMUX_FUNC_SPI_CS2, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_SPILCD_CLK, + HAL_IOMUX_FUNC_NONE, + HAL_IOMUX_FUNC_NONE, + }, +}; + +static struct IOMUX_T *const iomux = (struct IOMUX_T *)IOMUX_BASE; #ifdef ANC_PROD_TEST #define OPT_TYPE #else -#define OPT_TYPE const +#define OPT_TYPE const #endif static OPT_TYPE enum HAL_IOMUX_PIN_T digmic_ck_pin = DIG_MIC_CK_IOMUX_PIN; @@ -257,848 +453,900 @@ static OPT_TYPE enum HAL_IOMUX_PIN_T digmic_d0_pin = DIG_MIC_D0_IOMUX_PIN; static OPT_TYPE enum HAL_IOMUX_PIN_T digmic_d1_pin = DIG_MIC_D1_IOMUX_PIN; static OPT_TYPE enum HAL_IOMUX_PIN_T digmic_d2_pin = DIG_MIC_D2_IOMUX_PIN; -static enum HAL_IOMUX_PIN_VOLTAGE_DOMAINS_T BOOT_DATA_LOC uart0_volt = HAL_IOMUX_PIN_VOLTAGE_VIO; +static enum HAL_IOMUX_PIN_VOLTAGE_DOMAINS_T BOOT_DATA_LOC uart0_volt = + HAL_IOMUX_PIN_VOLTAGE_VIO; // UART1 is tied to vmem domain -void hal_iomux_set_default_config(void) -{ - uint32_t i; - // Set all unused GPIOs to pull-down by default - for (i = 0; i < 8; i++) { - if (((iomux->REG_004 & (0xF << (i * 4))) >> (i * 4)) == 0xF) { - iomux->REG_030 |= (1 << i); - } +void hal_iomux_set_default_config(void) { + uint32_t i; + // Set all unused GPIOs to pull-down by default + for (i = 0; i < 8; i++) { + if (((iomux->REG_004 & (0xF << (i * 4))) >> (i * 4)) == 0xF) { + iomux->REG_030 |= (1 << i); } - for (i = 0; i < 6; i++) { - if (((iomux->REG_008 & (0xF << (i * 4))) >> (i * 4)) == 0xF) { - iomux->REG_030 |= (1 << (i + 8)); - } + } + for (i = 0; i < 6; i++) { + if (((iomux->REG_008 & (0xF << (i * 4))) >> (i * 4)) == 0xF) { + iomux->REG_030 |= (1 << (i + 8)); } - for (i = 0; i < 8; i++) { - if (((iomux->REG_00C & (0xF << (i * 4))) >> (i * 4)) == 0xF) { - iomux->REG_030 |= (1 << (i + 16)); - } + } + for (i = 0; i < 8; i++) { + if (((iomux->REG_00C & (0xF << (i * 4))) >> (i * 4)) == 0xF) { + iomux->REG_030 |= (1 << (i + 16)); } - for (i = 0; i < 8; i++) { - if (((iomux->REG_010 & (0xF << (i * 4))) >> (i * 4)) == 0xF) { - iomux->REG_030 |= (1 << (i + 24)); - } + } + for (i = 0; i < 8; i++) { + if (((iomux->REG_010 & (0xF << (i * 4))) >> (i * 4)) == 0xF) { + iomux->REG_030 |= (1 << (i + 24)); } + } } -uint32_t hal_iomux_check(const struct HAL_IOMUX_PIN_FUNCTION_MAP *map, uint32_t count) -{ - uint32_t i; - for (i = 0; i < count; ++i) { - } - return 0; +uint32_t hal_iomux_check(const struct HAL_IOMUX_PIN_FUNCTION_MAP *map, + uint32_t count) { + uint32_t i; + for (i = 0; i < count; ++i) { + } + return 0; } -uint32_t hal_iomux_init(const struct HAL_IOMUX_PIN_FUNCTION_MAP *map, uint32_t count) -{ - uint32_t i; - uint32_t ret; +uint32_t hal_iomux_init(const struct HAL_IOMUX_PIN_FUNCTION_MAP *map, + uint32_t count) { + uint32_t i; + uint32_t ret; - for (i = 0; i < count; ++i) { - ret = hal_iomux_set_function(map[i].pin, map[i].function, HAL_IOMUX_OP_CLEAN_OTHER_FUNC_BIT); - if (ret) { - return (i << 8) + 1; - } - ret = hal_iomux_set_io_voltage_domains(map[i].pin, map[i].volt); - if (ret) { - return (i << 8) + 2; - } - ret = hal_iomux_set_io_pull_select(map[i].pin, map[i].pull_sel); - if (ret) { - return (i << 8) + 3; - } + for (i = 0; i < count; ++i) { + ret = hal_iomux_set_function(map[i].pin, map[i].function, + HAL_IOMUX_OP_CLEAN_OTHER_FUNC_BIT); + if (ret) { + return (i << 8) + 1; } + ret = hal_iomux_set_io_voltage_domains(map[i].pin, map[i].volt); + if (ret) { + return (i << 8) + 2; + } + ret = hal_iomux_set_io_pull_select(map[i].pin, map[i].pull_sel); + if (ret) { + return (i << 8) + 3; + } + } - return 0; + return 0; } #ifdef ANC_PROD_TEST -void hal_iomux_set_dig_mic_clock_pin(enum HAL_IOMUX_PIN_T pin) -{ - digmic_ck_pin = pin; +void hal_iomux_set_dig_mic_clock_pin(enum HAL_IOMUX_PIN_T pin) { + digmic_ck_pin = pin; } -void hal_iomux_set_dig_mic_data0_pin(enum HAL_IOMUX_PIN_T pin) -{ - digmic_d0_pin = pin; +void hal_iomux_set_dig_mic_data0_pin(enum HAL_IOMUX_PIN_T pin) { + digmic_d0_pin = pin; } -void hal_iomux_set_dig_mic_data1_pin(enum HAL_IOMUX_PIN_T pin) -{ - digmic_d1_pin = pin; +void hal_iomux_set_dig_mic_data1_pin(enum HAL_IOMUX_PIN_T pin) { + digmic_d1_pin = pin; } -void hal_iomux_set_dig_mic_data2_pin(enum HAL_IOMUX_PIN_T pin) -{ - digmic_d2_pin = pin; +void hal_iomux_set_dig_mic_data2_pin(enum HAL_IOMUX_PIN_T pin) { + digmic_d2_pin = pin; } #endif +uint32_t hal_iomux_set_function(enum HAL_IOMUX_PIN_T pin, + enum HAL_IOMUX_FUNCTION_T func, + enum HAL_IOMUX_OP_TYPE_T type) { + int i; + uint8_t val; + __IO uint32_t *reg; + uint32_t shift; -uint32_t hal_iomux_set_function(enum HAL_IOMUX_PIN_T pin, enum HAL_IOMUX_FUNCTION_T func, enum HAL_IOMUX_OP_TYPE_T type) -{ - int i; - uint8_t val; - __IO uint32_t *reg; - uint32_t shift; + if (pin >= HAL_IOMUX_PIN_LED_NUM) { + return 1; + } + if (func >= HAL_IOMUX_FUNC_END) { + return 2; + } - if (pin >= HAL_IOMUX_PIN_LED_NUM) { - return 1; - } - if (func >= HAL_IOMUX_FUNC_END) { - return 2; - } - - if (pin == HAL_IOMUX_PIN_P1_6 || pin == HAL_IOMUX_PIN_P1_7) { - if (func == HAL_IOMUX_FUNC_I2C_SCL || func == HAL_IOMUX_FUNC_I2C_SDA) { - // Enable analog I2C slave - iomux->REG_050 &= ~IOMUX_GPIO_I2C_MODE; - // Set mcu GPIO func - iomux->REG_008 = (iomux->REG_008 & ~(IOMUX_GPIO_P16_SEL_MASK | IOMUX_GPIO_P17_SEL_MASK)) | - IOMUX_GPIO_P16_SEL(IOMUX_FUNC_VAL_GPIO) | IOMUX_GPIO_P17_SEL(IOMUX_FUNC_VAL_GPIO); - return 0; - } else { - iomux->REG_050 |= IOMUX_GPIO_I2C_MODE; - // Continue to set the alt func - } - } else if (pin == HAL_IOMUX_PIN_P0_2) { - if (func == HAL_IOMUX_FUNC_SPDIF0_DI) { - iomux->REG_004 = SET_BITFIELD(iomux->REG_004, IOMUX_GPIO_P02_SEL, 6); - return 0; - } - } else if (pin == HAL_IOMUX_PIN_P0_3) { - if (func == HAL_IOMUX_FUNC_SPDIF0_DO) { - iomux->REG_004 = SET_BITFIELD(iomux->REG_004, IOMUX_GPIO_P03_SEL, 6); - return 0; - } - } else if (pin == HAL_IOMUX_PIN_P2_0) { - if (func == HAL_IOMUX_FUNC_CLK_REQ_OUT) { - iomux->REG_00C = SET_BITFIELD(iomux->REG_00C, IOMUX_GPIO_P20_SEL, 9); - return 0; - } - } else if (pin == HAL_IOMUX_PIN_P2_1) { - if (func == HAL_IOMUX_FUNC_CLK_REQ_IN) { - iomux->REG_00C = SET_BITFIELD(iomux->REG_00C, IOMUX_GPIO_P21_SEL, 9); - return 0; - } - } else if (pin == HAL_IOMUX_PIN_LED1 || pin == HAL_IOMUX_PIN_LED2) { - ASSERT(func == HAL_IOMUX_FUNC_GPIO, "Bad func=%d for IOMUX pin=%d", func, pin); - return 0; - } - - if (func == HAL_IOMUX_FUNC_GPIO) { - val = IOMUX_FUNC_VAL_GPIO; + if (pin == HAL_IOMUX_PIN_P1_6 || pin == HAL_IOMUX_PIN_P1_7) { + if (func == HAL_IOMUX_FUNC_I2C_SCL || func == HAL_IOMUX_FUNC_I2C_SDA) { + // Enable analog I2C slave + iomux->REG_050 &= ~IOMUX_GPIO_I2C_MODE; + // Set mcu GPIO func + iomux->REG_008 = (iomux->REG_008 & + ~(IOMUX_GPIO_P16_SEL_MASK | IOMUX_GPIO_P17_SEL_MASK)) | + IOMUX_GPIO_P16_SEL(IOMUX_FUNC_VAL_GPIO) | + IOMUX_GPIO_P17_SEL(IOMUX_FUNC_VAL_GPIO); + return 0; } else { - for (i = 0; i < IOMUX_ALT_FUNC_NUM; i++) { - if (pin_func_map[pin][i] == func) { - break; - } - } - - if (i == IOMUX_ALT_FUNC_NUM) { - return 3; - } - val = index_to_func_val[i]; + iomux->REG_050 |= IOMUX_GPIO_I2C_MODE; + // Continue to set the alt func } - - reg = &iomux->REG_004 + pin / 8; - shift = (pin % 8) * 4; - - *reg = (*reg & ~(0xF << shift)) | (val << shift); - + } else if (pin == HAL_IOMUX_PIN_P0_2) { + if (func == HAL_IOMUX_FUNC_SPDIF0_DI) { + iomux->REG_004 = SET_BITFIELD(iomux->REG_004, IOMUX_GPIO_P02_SEL, 6); + return 0; + } + } else if (pin == HAL_IOMUX_PIN_P0_3) { + if (func == HAL_IOMUX_FUNC_SPDIF0_DO) { + iomux->REG_004 = SET_BITFIELD(iomux->REG_004, IOMUX_GPIO_P03_SEL, 6); + return 0; + } + } else if (pin == HAL_IOMUX_PIN_P2_0) { + if (func == HAL_IOMUX_FUNC_CLK_REQ_OUT) { + iomux->REG_00C = SET_BITFIELD(iomux->REG_00C, IOMUX_GPIO_P20_SEL, 9); + return 0; + } + } else if (pin == HAL_IOMUX_PIN_P2_1) { + if (func == HAL_IOMUX_FUNC_CLK_REQ_IN) { + iomux->REG_00C = SET_BITFIELD(iomux->REG_00C, IOMUX_GPIO_P21_SEL, 9); + return 0; + } + } else if (pin == HAL_IOMUX_PIN_LED1 || pin == HAL_IOMUX_PIN_LED2) { + ASSERT(func == HAL_IOMUX_FUNC_GPIO, "Bad func=%d for IOMUX pin=%d", func, + pin); return 0; -} + } -enum HAL_IOMUX_FUNCTION_T hal_iomux_get_function(enum HAL_IOMUX_PIN_T pin) -{ - return HAL_IOMUX_FUNC_NONE; -} - -uint32_t hal_iomux_set_io_voltage_domains(enum HAL_IOMUX_PIN_T pin, enum HAL_IOMUX_PIN_VOLTAGE_DOMAINS_T volt) -{ - if (pin >= HAL_IOMUX_PIN_LED_NUM) { - return 1; + if (func == HAL_IOMUX_FUNC_GPIO) { + val = IOMUX_FUNC_VAL_GPIO; + } else { + for (i = 0; i < IOMUX_ALT_FUNC_NUM; i++) { + if (pin_func_map[pin][i] == func) { + break; + } } - if (pin == HAL_IOMUX_PIN_LED1 || pin == HAL_IOMUX_PIN_LED2) { - pmu_led_set_voltage_domains(pin, volt); + if (i == IOMUX_ALT_FUNC_NUM) { + return 3; } + val = index_to_func_val[i]; + } - return 0; + reg = &iomux->REG_004 + pin / 8; + shift = (pin % 8) * 4; + + *reg = (*reg & ~(0xF << shift)) | (val << shift); + + return 0; } -uint32_t hal_iomux_set_io_pull_select(enum HAL_IOMUX_PIN_T pin, enum HAL_IOMUX_PIN_PULL_SELECT_T pull_sel) -{ - if (pin >= HAL_IOMUX_PIN_LED_NUM) { - return 1; +enum HAL_IOMUX_FUNCTION_T hal_iomux_get_function(enum HAL_IOMUX_PIN_T pin) { + return HAL_IOMUX_FUNC_NONE; +} + +uint32_t +hal_iomux_set_io_voltage_domains(enum HAL_IOMUX_PIN_T pin, + enum HAL_IOMUX_PIN_VOLTAGE_DOMAINS_T volt) { + if (pin >= HAL_IOMUX_PIN_LED_NUM) { + return 1; + } + + if (pin == HAL_IOMUX_PIN_LED1 || pin == HAL_IOMUX_PIN_LED2) { + pmu_led_set_voltage_domains(pin, volt); + } + + return 0; +} + +uint32_t +hal_iomux_set_io_pull_select(enum HAL_IOMUX_PIN_T pin, + enum HAL_IOMUX_PIN_PULL_SELECT_T pull_sel) { + if (pin >= HAL_IOMUX_PIN_LED_NUM) { + return 1; + } + + if (pin < HAL_IOMUX_PIN_LED1) { + iomux->REG_02C &= ~(1 << pin); + iomux->REG_030 &= ~(1 << pin); + if (pull_sel == HAL_IOMUX_PIN_PULLUP_ENABLE) { + iomux->REG_02C |= (1 << pin); + } else if (pull_sel == HAL_IOMUX_PIN_PULLDOWN_ENABLE) { + iomux->REG_030 |= (1 << pin); } + } else if (pin == HAL_IOMUX_PIN_LED1 || pin == HAL_IOMUX_PIN_LED2) { + pmu_led_set_pull_select(pin, pull_sel); + } - if (pin < HAL_IOMUX_PIN_LED1) { - iomux->REG_02C &= ~(1 << pin); - iomux->REG_030 &= ~(1 << pin); - if (pull_sel == HAL_IOMUX_PIN_PULLUP_ENABLE) { - iomux->REG_02C |= (1 << pin); - } else if (pull_sel == HAL_IOMUX_PIN_PULLDOWN_ENABLE) { - iomux->REG_030 |= (1 << pin); - } - } else if (pin == HAL_IOMUX_PIN_LED1 || pin == HAL_IOMUX_PIN_LED2) { - pmu_led_set_pull_select(pin, pull_sel); - } - - return 0; + return 0; } -void hal_iomux_set_sdmmc_dt_n_out_group(int enable) -{ +void hal_iomux_set_sdmmc_dt_n_out_group(int enable) {} + +void hal_iomux_set_uart0_voltage(enum HAL_IOMUX_PIN_VOLTAGE_DOMAINS_T volt) { + uart0_volt = volt; } -void hal_iomux_set_uart0_voltage(enum HAL_IOMUX_PIN_VOLTAGE_DOMAINS_T volt) -{ - uart0_volt = volt; +void hal_iomux_set_uart1_voltage(enum HAL_IOMUX_PIN_VOLTAGE_DOMAINS_T volt) {} + +bool hal_iomux_uart0_connected(void) { + uint32_t reg_050, reg_008, reg_02c, reg_030; + uint32_t mask; + int val; + + // Save current iomux settings + reg_050 = iomux->REG_050; + reg_008 = iomux->REG_008; + reg_02c = iomux->REG_02C; + reg_030 = iomux->REG_030; + + // Disable analog I2C slave & master + iomux->REG_050 |= IOMUX_GPIO_I2C_MODE | IOMUX_I2C0_M_SEL_GPIO; + // Set uart0-rx as gpio + iomux->REG_008 = + SET_BITFIELD(iomux->REG_008, IOMUX_GPIO_P16_SEL, IOMUX_FUNC_VAL_GPIO); + + mask = (1 << HAL_IOMUX_PIN_P1_6); + // Set voltage domain + if (uart0_volt == HAL_IOMUX_PIN_VOLTAGE_VIO) { + iomux->REG_070 |= (1 << (IOMUX_GPIO_P1_PWS_SHIFT + 1)); + } else { + iomux->REG_070 &= ~(1 << (IOMUX_GPIO_P1_PWS_SHIFT + 1)); + } + // Clear pullup + iomux->REG_02C &= ~mask; + // Setup pulldown + iomux->REG_030 |= mask; + + hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)HAL_IOMUX_PIN_P1_6, HAL_GPIO_DIR_IN, + 0); + + hal_sys_timer_delay(MS_TO_TICKS(2)); + + val = hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)HAL_IOMUX_PIN_P1_6); + + // Restore iomux settings + iomux->REG_030 = reg_030; + iomux->REG_02C = reg_02c; + iomux->REG_008 = reg_008; + iomux->REG_050 = reg_050; + + hal_sys_timer_delay(MS_TO_TICKS(2)); + + return !!val; } -void hal_iomux_set_uart1_voltage(enum HAL_IOMUX_PIN_VOLTAGE_DOMAINS_T volt) -{ +bool hal_iomux_uart1_connected(void) { + uint32_t reg_00c, reg_02c, reg_030; + uint32_t mask; + int val; + + // Save current iomux settings + reg_00c = iomux->REG_00C; + reg_02c = iomux->REG_02C; + reg_030 = iomux->REG_030; + + // Set uart1-rx as gpio + iomux->REG_00C = + SET_BITFIELD(iomux->REG_00C, IOMUX_GPIO_P20_SEL, IOMUX_FUNC_VAL_GPIO); + + mask = (1 << HAL_IOMUX_PIN_P2_0); + // Clear pullup + iomux->REG_02C &= ~mask; + // Setup pulldown + iomux->REG_030 |= mask; + + hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)HAL_IOMUX_PIN_P2_0, HAL_GPIO_DIR_IN, + 0); + + hal_sys_timer_delay(MS_TO_TICKS(2)); + + val = hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)HAL_IOMUX_PIN_P2_0); + + // Restore iomux settings + iomux->REG_030 = reg_030; + iomux->REG_02C = reg_02c; + iomux->REG_00C = reg_00c; + + hal_sys_timer_delay(MS_TO_TICKS(2)); + + return !!val; } -bool hal_iomux_uart0_connected(void) -{ - uint32_t reg_050, reg_008, reg_02c, reg_030; - uint32_t mask; - int val; +void hal_iomux_set_uart0(void) { + uint32_t mask; - // Save current iomux settings - reg_050 = iomux->REG_050; - reg_008 = iomux->REG_008; - reg_02c = iomux->REG_02C; - reg_030 = iomux->REG_030; + // Disable analog I2C slave & master + iomux->REG_050 |= IOMUX_GPIO_I2C_MODE | IOMUX_I2C0_M_SEL_GPIO; + // Set uart0 func + iomux->REG_008 = + (iomux->REG_008 & ~(IOMUX_GPIO_P16_SEL_MASK | IOMUX_GPIO_P17_SEL_MASK)) | + IOMUX_GPIO_P16_SEL(1) | IOMUX_GPIO_P17_SEL(1); - // Disable analog I2C slave & master - iomux->REG_050 |= IOMUX_GPIO_I2C_MODE | IOMUX_I2C0_M_SEL_GPIO; - // Set uart0-rx as gpio - iomux->REG_008 = SET_BITFIELD(iomux->REG_008, IOMUX_GPIO_P16_SEL, IOMUX_FUNC_VAL_GPIO); - - mask = (1 << HAL_IOMUX_PIN_P1_6); - // Set voltage domain - if (uart0_volt == HAL_IOMUX_PIN_VOLTAGE_VIO) { - iomux->REG_070 |= (1 << (IOMUX_GPIO_P1_PWS_SHIFT + 1)); - } else { - iomux->REG_070 &= ~(1 << (IOMUX_GPIO_P1_PWS_SHIFT + 1)); - } - // Clear pullup - iomux->REG_02C &= ~mask; - // Setup pulldown - iomux->REG_030 |= mask; - - hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)HAL_IOMUX_PIN_P1_6, HAL_GPIO_DIR_IN, 0); - - hal_sys_timer_delay(MS_TO_TICKS(2)); - - val = hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)HAL_IOMUX_PIN_P1_6); - - // Restore iomux settings - iomux->REG_030 = reg_030; - iomux->REG_02C = reg_02c; - iomux->REG_008 = reg_008; - iomux->REG_050 = reg_050; - - hal_sys_timer_delay(MS_TO_TICKS(2)); - - return !!val; + mask = (1 << HAL_IOMUX_PIN_P1_6) | (1 << HAL_IOMUX_PIN_P1_7); + // Set voltage domain + if (uart0_volt == HAL_IOMUX_PIN_VOLTAGE_VIO) { + iomux->REG_070 |= (1 << (IOMUX_GPIO_P1_PWS_SHIFT + 1)); + } else { + iomux->REG_070 &= ~(1 << (IOMUX_GPIO_P1_PWS_SHIFT + 1)); + } + // Setup pullup + iomux->REG_02C |= (1 << HAL_IOMUX_PIN_P1_6); + iomux->REG_02C &= ~(1 << HAL_IOMUX_PIN_P1_7); + // Clear pulldown + iomux->REG_030 &= ~mask; } -bool hal_iomux_uart1_connected(void) -{ - uint32_t reg_00c, reg_02c, reg_030; - uint32_t mask; - int val; +void hal_iomux_set_uart1(void) { + uint32_t mask; - // Save current iomux settings - reg_00c = iomux->REG_00C; - reg_02c = iomux->REG_02C; - reg_030 = iomux->REG_030; + // Set uart1 func + iomux->REG_00C = + (iomux->REG_00C & ~(IOMUX_GPIO_P20_SEL_MASK | IOMUX_GPIO_P21_SEL_MASK)) | + IOMUX_GPIO_P20_SEL(1) | IOMUX_GPIO_P21_SEL(1); - // Set uart1-rx as gpio - iomux->REG_00C = SET_BITFIELD(iomux->REG_00C, IOMUX_GPIO_P20_SEL, IOMUX_FUNC_VAL_GPIO); - - mask = (1 << HAL_IOMUX_PIN_P2_0); - // Clear pullup - iomux->REG_02C &= ~mask; - // Setup pulldown - iomux->REG_030 |= mask; - - hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)HAL_IOMUX_PIN_P2_0, HAL_GPIO_DIR_IN, 0); - - hal_sys_timer_delay(MS_TO_TICKS(2)); - - val = hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)HAL_IOMUX_PIN_P2_0); - - // Restore iomux settings - iomux->REG_030 = reg_030; - iomux->REG_02C = reg_02c; - iomux->REG_00C = reg_00c; - - hal_sys_timer_delay(MS_TO_TICKS(2)); - - return !!val; + mask = (1 << HAL_IOMUX_PIN_P2_0) | (1 << HAL_IOMUX_PIN_P2_1); + // Setup pullup + iomux->REG_02C |= (1 << HAL_IOMUX_PIN_P2_0); + iomux->REG_02C &= ~(1 << HAL_IOMUX_PIN_P2_1); + // Clear pulldown + iomux->REG_030 &= ~mask; } -void hal_iomux_set_uart0(void) -{ - uint32_t mask; +void hal_iomux_set_uart2(void) {} - // Disable analog I2C slave & master - iomux->REG_050 |= IOMUX_GPIO_I2C_MODE | IOMUX_I2C0_M_SEL_GPIO; - // Set uart0 func - iomux->REG_008 = (iomux->REG_008 & ~(IOMUX_GPIO_P16_SEL_MASK | IOMUX_GPIO_P17_SEL_MASK)) | - IOMUX_GPIO_P16_SEL(1) | IOMUX_GPIO_P17_SEL(1); +void hal_iomux_set_analog_i2c(void) { + uint32_t mask; - mask = (1 << HAL_IOMUX_PIN_P1_6) | (1 << HAL_IOMUX_PIN_P1_7); - // Set voltage domain - if (uart0_volt == HAL_IOMUX_PIN_VOLTAGE_VIO) { - iomux->REG_070 |= (1 << (IOMUX_GPIO_P1_PWS_SHIFT + 1)); - } else { - iomux->REG_070 &= ~(1 << (IOMUX_GPIO_P1_PWS_SHIFT + 1)); - } - // Setup pullup - iomux->REG_02C |= (1 << HAL_IOMUX_PIN_P1_6); - iomux->REG_02C &= ~(1 << HAL_IOMUX_PIN_P1_7); - // Clear pulldown - iomux->REG_030 &= ~mask; + // Disable analog I2C master + iomux->REG_050 |= IOMUX_I2C0_M_SEL_GPIO; + // Set mcu GPIO func + iomux->REG_008 = + (iomux->REG_008 & ~(IOMUX_GPIO_P16_SEL_MASK | IOMUX_GPIO_P17_SEL_MASK)) | + IOMUX_GPIO_P16_SEL(0) | IOMUX_GPIO_P17_SEL(0); + // Enable analog I2C slave + iomux->REG_050 &= ~IOMUX_GPIO_I2C_MODE; + + mask = (1 << HAL_IOMUX_PIN_P1_6) | (1 << HAL_IOMUX_PIN_P1_7); + // Set voltage domain + if (uart0_volt == HAL_IOMUX_PIN_VOLTAGE_VIO) { + iomux->REG_070 |= (1 << (IOMUX_GPIO_P1_PWS_SHIFT + 1)); + } else { + iomux->REG_070 &= ~(1 << (IOMUX_GPIO_P1_PWS_SHIFT + 1)); + } + // Setup pullup + iomux->REG_02C |= mask; + // Clear pulldown + iomux->REG_030 &= ~mask; } -void hal_iomux_set_uart1(void) -{ - uint32_t mask; +void hal_iomux_set_jtag(void) { + uint32_t mask; + uint32_t val; - // Set uart1 func - iomux->REG_00C = (iomux->REG_00C & ~(IOMUX_GPIO_P20_SEL_MASK | IOMUX_GPIO_P21_SEL_MASK)) | - IOMUX_GPIO_P20_SEL(1) | IOMUX_GPIO_P21_SEL(1); + // SWCLK/TCK, SWDIO/TMS + mask = IOMUX_GPIO_P01_SEL_MASK | IOMUX_GPIO_P02_SEL_MASK; + val = IOMUX_GPIO_P01_SEL(7) | IOMUX_GPIO_P02_SEL(7); - mask = (1 << HAL_IOMUX_PIN_P2_0) | (1 << HAL_IOMUX_PIN_P2_1); - // Setup pullup - iomux->REG_02C |= (1 << HAL_IOMUX_PIN_P2_0); - iomux->REG_02C &= ~(1 << HAL_IOMUX_PIN_P2_1); - // Clear pulldown - iomux->REG_030 &= ~mask; -} - -void hal_iomux_set_uart2(void) -{ -} - -void hal_iomux_set_analog_i2c(void) -{ - uint32_t mask; - - // Disable analog I2C master - iomux->REG_050 |= IOMUX_I2C0_M_SEL_GPIO; - // Set mcu GPIO func - iomux->REG_008 = (iomux->REG_008 & ~(IOMUX_GPIO_P16_SEL_MASK | IOMUX_GPIO_P17_SEL_MASK)) | - IOMUX_GPIO_P16_SEL(0) | IOMUX_GPIO_P17_SEL(0); - // Enable analog I2C slave - iomux->REG_050 &= ~IOMUX_GPIO_I2C_MODE; - - mask = (1 << HAL_IOMUX_PIN_P1_6) | (1 << HAL_IOMUX_PIN_P1_7); - // Set voltage domain - if (uart0_volt == HAL_IOMUX_PIN_VOLTAGE_VIO) { - iomux->REG_070 |= (1 << (IOMUX_GPIO_P1_PWS_SHIFT + 1)); - } else { - iomux->REG_070 &= ~(1 << (IOMUX_GPIO_P1_PWS_SHIFT + 1)); - } - // Setup pullup - iomux->REG_02C |= mask; - // Clear pulldown - iomux->REG_030 &= ~mask; -} - -void hal_iomux_set_jtag(void) -{ - uint32_t mask; - uint32_t val; - - // SWCLK/TCK, SWDIO/TMS - mask = IOMUX_GPIO_P01_SEL_MASK | IOMUX_GPIO_P02_SEL_MASK; - val = IOMUX_GPIO_P01_SEL(7) | IOMUX_GPIO_P02_SEL(7); - - // TDI, TDO + // TDI, TDO #ifdef JTAG_TDI_TDO_PIN - mask |= IOMUX_GPIO_P00_SEL_MASK | IOMUX_GPIO_P03_SEL_MASK; - val |= IOMUX_GPIO_P00_SEL(7) | IOMUX_GPIO_P03_SEL(7); + mask |= IOMUX_GPIO_P00_SEL_MASK | IOMUX_GPIO_P03_SEL_MASK; + val |= IOMUX_GPIO_P00_SEL(7) | IOMUX_GPIO_P03_SEL(7); #endif - iomux->REG_004 = (iomux->REG_004 & ~mask) | val; + iomux->REG_004 = (iomux->REG_004 & ~mask) | val; - // RESET + // RESET #if defined(JTAG_RESET_PIN) || defined(JTAG_TDI_TDO_PIN) - iomux->REG_00C = (iomux->REG_00C & ~(IOMUX_GPIO_P20_SEL_MASK)) | IOMUX_GPIO_P20_SEL(7); + iomux->REG_00C = + (iomux->REG_00C & ~(IOMUX_GPIO_P20_SEL_MASK)) | IOMUX_GPIO_P20_SEL(7); #endif - mask = (1 << HAL_IOMUX_PIN_P0_1) | (1 << HAL_IOMUX_PIN_P0_2); + mask = (1 << HAL_IOMUX_PIN_P0_1) | (1 << HAL_IOMUX_PIN_P0_2); #ifdef JTAG_TDI_TDO_PIN - mask |= (1 << HAL_IOMUX_PIN_P0_0) | (1 << HAL_IOMUX_PIN_P0_3); + mask |= (1 << HAL_IOMUX_PIN_P0_0) | (1 << HAL_IOMUX_PIN_P0_3); #endif #if defined(JTAG_RESET_PIN) || defined(JTAG_TDI_TDO_PIN) - mask |= (1 << HAL_IOMUX_PIN_P2_0); + mask |= (1 << HAL_IOMUX_PIN_P2_0); #endif - // Clear pullup - iomux->REG_02C &= ~mask; - // Clear pulldown - iomux->REG_030 &= ~mask; + // Clear pullup + iomux->REG_02C &= ~mask; + // Clear pulldown + iomux->REG_030 &= ~mask; } -enum HAL_IOMUX_ISPI_ACCESS_T hal_iomux_ispi_access_enable(enum HAL_IOMUX_ISPI_ACCESS_T access) -{ - uint32_t v; +enum HAL_IOMUX_ISPI_ACCESS_T +hal_iomux_ispi_access_enable(enum HAL_IOMUX_ISPI_ACCESS_T access) { + uint32_t v; - v = iomux->REG_044; - iomux->REG_044 |= access; + v = iomux->REG_044; + iomux->REG_044 |= access; - return v; + return v; } -enum HAL_IOMUX_ISPI_ACCESS_T hal_iomux_ispi_access_disable(enum HAL_IOMUX_ISPI_ACCESS_T access) -{ - uint32_t v; +enum HAL_IOMUX_ISPI_ACCESS_T +hal_iomux_ispi_access_disable(enum HAL_IOMUX_ISPI_ACCESS_T access) { + uint32_t v; - v = iomux->REG_044; - iomux->REG_044 &= ~access; + v = iomux->REG_044; + iomux->REG_044 &= ~access; - return v; + return v; } -void hal_iomux_ispi_access_init(void) -{ - // Disable bt spi access ana/pmu interface - hal_iomux_ispi_access_disable(HAL_IOMUX_ISPI_BT_ANA | HAL_IOMUX_ISPI_BT_PMU); +void hal_iomux_ispi_access_init(void) { + // Disable bt spi access ana/pmu interface + hal_iomux_ispi_access_disable(HAL_IOMUX_ISPI_BT_ANA | HAL_IOMUX_ISPI_BT_PMU); } -void hal_iomux_set_i2s0(void) -{ - static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_i2s[] = { - {HAL_IOMUX_PIN_P0_0, HAL_IOMUX_FUNC_I2S0_SDI0, I2S0_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P0_1, HAL_IOMUX_FUNC_I2S0_SDO, I2S0_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_I2S0_WS, I2S0_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_I2S0_SCK, I2S0_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - }; +void hal_iomux_set_i2s0(void) { + static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_i2s[] = { + {HAL_IOMUX_PIN_P0_0, HAL_IOMUX_FUNC_I2S0_SDI0, I2S0_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P0_1, HAL_IOMUX_FUNC_I2S0_SDO, I2S0_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_I2S0_WS, I2S0_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_I2S0_SCK, I2S0_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + }; - hal_iomux_init(pinmux_i2s, ARRAY_SIZE(pinmux_i2s)); + hal_iomux_init(pinmux_i2s, ARRAY_SIZE(pinmux_i2s)); } -void hal_iomux_set_i2s1(void) -{ - static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_i2s[] = { +void hal_iomux_set_i2s1(void) { + static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_i2s[] = { #if (I2S1_IOMUX_INDEX == 30) - {HAL_IOMUX_PIN_P3_2, HAL_IOMUX_FUNC_I2S1_SDI0, I2S1_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P3_3, HAL_IOMUX_FUNC_I2S1_SDO, I2S1_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P3_1, HAL_IOMUX_FUNC_I2S1_WS, I2S1_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P3_0, HAL_IOMUX_FUNC_I2S1_SCK, I2S1_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P3_2, HAL_IOMUX_FUNC_I2S1_SDI0, I2S1_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P3_3, HAL_IOMUX_FUNC_I2S1_SDO, I2S1_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P3_1, HAL_IOMUX_FUNC_I2S1_WS, I2S1_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P3_0, HAL_IOMUX_FUNC_I2S1_SCK, I2S1_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #else - {HAL_IOMUX_PIN_P1_4, HAL_IOMUX_FUNC_I2S1_SDI0, I2S1_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_I2S1_SDO, I2S1_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_I2S1_WS, I2S1_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_I2S1_SCK, I2S1_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - }; + {HAL_IOMUX_PIN_P1_4, HAL_IOMUX_FUNC_I2S1_SDI0, I2S1_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_I2S1_SDO, I2S1_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_I2S1_WS, I2S1_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_I2S1_SCK, I2S1_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + }; #endif hal_iomux_init(pinmux_i2s, ARRAY_SIZE(pinmux_i2s)); } -void hal_iomux_set_i2s_mclk(void) -{ - static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux[] = { +void hal_iomux_set_i2s_mclk(void) { + static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux[] = { #if (I2S_MCLK_IOMUX_INDEX == 13) - {HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_I2S0_MCLK, I2S0_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_I2S0_MCLK, I2S0_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #elif (I2S_MCLK_IOMUX_INDEX == 15) - {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_I2S0_MCLK, I2S0_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_I2S0_MCLK, I2S0_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #elif (I2S_MCLK_IOMUX_INDEX == 20) - {HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_I2S0_MCLK, I2S0_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_I2S0_MCLK, I2S0_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #elif (I2S_MCLK_IOMUX_INDEX == 22) - {HAL_IOMUX_PIN_P2_2, HAL_IOMUX_FUNC_I2S0_MCLK, I2S0_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P2_2, HAL_IOMUX_FUNC_I2S0_MCLK, I2S0_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #else - {HAL_IOMUX_PIN_P0_4, HAL_IOMUX_FUNC_I2S0_MCLK, I2S0_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P0_4, HAL_IOMUX_FUNC_I2S0_MCLK, I2S0_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #endif - }; + }; - hal_iomux_init(pinmux, ARRAY_SIZE(pinmux)); + hal_iomux_init(pinmux, ARRAY_SIZE(pinmux)); } -void hal_iomux_set_spdif0(void) -{ - static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_spdif[] = { +void hal_iomux_set_spdif0(void) { + static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_spdif[] = { #if (SPDIF0_IOMUX_INDEX == 20) - {HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_SPDIF0_DI, SPDIF0_VOLTAGE_SEL, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_SPDIF0_DO, SPDIF0_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_SPDIF0_DI, SPDIF0_VOLTAGE_SEL, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_SPDIF0_DO, SPDIF0_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #elif (SPDIF0_IOMUX_INDEX == 26) - {HAL_IOMUX_PIN_P2_6, HAL_IOMUX_FUNC_SPDIF0_DI, SPDIF0_VOLTAGE_SEL, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_P2_7, HAL_IOMUX_FUNC_SPDIF0_DO, SPDIF0_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P2_6, HAL_IOMUX_FUNC_SPDIF0_DI, SPDIF0_VOLTAGE_SEL, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_P2_7, HAL_IOMUX_FUNC_SPDIF0_DO, SPDIF0_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #else - {HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_SPDIF0_DI, SPDIF0_VOLTAGE_SEL, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_SPDIF0_DO, SPDIF0_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_SPDIF0_DI, SPDIF0_VOLTAGE_SEL, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_SPDIF0_DO, SPDIF0_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #endif - }; + }; - hal_iomux_init(pinmux_spdif, ARRAY_SIZE(pinmux_spdif)); + hal_iomux_init(pinmux_spdif, ARRAY_SIZE(pinmux_spdif)); } -void hal_iomux_set_spdif1(void) -{ +void hal_iomux_set_spdif1(void) {} + +void hal_iomux_set_dig_mic(uint32_t map) { + struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_digitalmic_clk[] = { + {HAL_IOMUX_PIN_P0_0, HAL_IOMUX_FUNC_PDM0_CK, DIGMIC_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + }; + struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_digitalmic0[] = { + {HAL_IOMUX_PIN_P0_1, HAL_IOMUX_FUNC_PDM0_D, DIGMIC_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + }; + struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_digitalmic1[] = { + {HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_PDM1_D, DIGMIC_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + }; + struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_digitalmic2[] = { + {HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_PDM2_D, DIGMIC_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + }; + + if (digmic_ck_pin == HAL_IOMUX_PIN_P0_0) { + pinmux_digitalmic_clk[0].pin = HAL_IOMUX_PIN_P0_0; + pinmux_digitalmic_clk[0].function = HAL_IOMUX_FUNC_PDM0_CK; + } else if (digmic_ck_pin == HAL_IOMUX_PIN_P0_4) { + pinmux_digitalmic_clk[0].pin = HAL_IOMUX_PIN_P0_4; + pinmux_digitalmic_clk[0].function = HAL_IOMUX_FUNC_PDM1_CK; + } else if (digmic_ck_pin == HAL_IOMUX_PIN_P3_3) { + pinmux_digitalmic_clk[0].pin = HAL_IOMUX_PIN_P3_3; + pinmux_digitalmic_clk[0].function = HAL_IOMUX_FUNC_PDM2_CK; + } + + if (digmic_d0_pin == HAL_IOMUX_PIN_P0_1) { + pinmux_digitalmic0[0].pin = HAL_IOMUX_PIN_P0_1; + } else if (digmic_d0_pin == HAL_IOMUX_PIN_P0_6) { + pinmux_digitalmic0[0].pin = HAL_IOMUX_PIN_P0_6; + } else if (digmic_d0_pin == HAL_IOMUX_PIN_P3_0) { + pinmux_digitalmic0[0].pin = HAL_IOMUX_PIN_P3_0; + } + + if (digmic_d1_pin == HAL_IOMUX_PIN_P0_2) { + pinmux_digitalmic1[0].pin = HAL_IOMUX_PIN_P0_2; + } else if (digmic_d1_pin == HAL_IOMUX_PIN_P0_5) { + pinmux_digitalmic1[0].pin = HAL_IOMUX_PIN_P0_5; + } else if (digmic_d1_pin == HAL_IOMUX_PIN_P3_1) { + pinmux_digitalmic1[0].pin = HAL_IOMUX_PIN_P3_1; + } + + if (digmic_d2_pin == HAL_IOMUX_PIN_P0_3) { + pinmux_digitalmic2[0].pin = HAL_IOMUX_PIN_P0_3; + } else if (digmic_d2_pin == HAL_IOMUX_PIN_P0_7) { + pinmux_digitalmic2[0].pin = HAL_IOMUX_PIN_P0_7; + } else if (digmic_d2_pin == HAL_IOMUX_PIN_P3_2) { + pinmux_digitalmic2[0].pin = HAL_IOMUX_PIN_P3_2; + } + + if ((map & 0xF) == 0) { + pinmux_digitalmic_clk[0].function = HAL_IOMUX_FUNC_GPIO; + } + hal_iomux_init(pinmux_digitalmic_clk, ARRAY_SIZE(pinmux_digitalmic_clk)); + if (map & (1 << 0)) { + hal_iomux_init(pinmux_digitalmic0, ARRAY_SIZE(pinmux_digitalmic0)); + } + if (map & (1 << 1)) { + hal_iomux_init(pinmux_digitalmic1, ARRAY_SIZE(pinmux_digitalmic1)); + } + if (map & (1 << 2)) { + hal_iomux_init(pinmux_digitalmic2, ARRAY_SIZE(pinmux_digitalmic2)); + } } -void hal_iomux_set_dig_mic(uint32_t map) -{ - struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_digitalmic_clk[] = { - {HAL_IOMUX_PIN_P0_0, HAL_IOMUX_FUNC_PDM0_CK, DIGMIC_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - }; - struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_digitalmic0[] = { - {HAL_IOMUX_PIN_P0_1, HAL_IOMUX_FUNC_PDM0_D, DIGMIC_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - }; - struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_digitalmic1[] = { - {HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_PDM1_D, DIGMIC_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - }; - struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_digitalmic2[] = { - {HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_PDM2_D, DIGMIC_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - }; - - if (digmic_ck_pin == HAL_IOMUX_PIN_P0_0) { - pinmux_digitalmic_clk[0].pin = HAL_IOMUX_PIN_P0_0; - pinmux_digitalmic_clk[0].function = HAL_IOMUX_FUNC_PDM0_CK; - } else if (digmic_ck_pin == HAL_IOMUX_PIN_P0_4) { - pinmux_digitalmic_clk[0].pin = HAL_IOMUX_PIN_P0_4; - pinmux_digitalmic_clk[0].function = HAL_IOMUX_FUNC_PDM1_CK; - } else if (digmic_ck_pin == HAL_IOMUX_PIN_P3_3) { - pinmux_digitalmic_clk[0].pin = HAL_IOMUX_PIN_P3_3; - pinmux_digitalmic_clk[0].function = HAL_IOMUX_FUNC_PDM2_CK; - } - - if (digmic_d0_pin == HAL_IOMUX_PIN_P0_1) { - pinmux_digitalmic0[0].pin = HAL_IOMUX_PIN_P0_1; - } else if (digmic_d0_pin == HAL_IOMUX_PIN_P0_6) { - pinmux_digitalmic0[0].pin = HAL_IOMUX_PIN_P0_6; - } else if (digmic_d0_pin == HAL_IOMUX_PIN_P3_0) { - pinmux_digitalmic0[0].pin = HAL_IOMUX_PIN_P3_0; - } - - if (digmic_d1_pin == HAL_IOMUX_PIN_P0_2) { - pinmux_digitalmic1[0].pin = HAL_IOMUX_PIN_P0_2; - } else if (digmic_d1_pin == HAL_IOMUX_PIN_P0_5) { - pinmux_digitalmic1[0].pin = HAL_IOMUX_PIN_P0_5; - } else if (digmic_d1_pin == HAL_IOMUX_PIN_P3_1) { - pinmux_digitalmic1[0].pin = HAL_IOMUX_PIN_P3_1; - } - - if (digmic_d2_pin == HAL_IOMUX_PIN_P0_3) { - pinmux_digitalmic2[0].pin = HAL_IOMUX_PIN_P0_3; - } else if (digmic_d2_pin == HAL_IOMUX_PIN_P0_7) { - pinmux_digitalmic2[0].pin = HAL_IOMUX_PIN_P0_7; - } else if (digmic_d2_pin == HAL_IOMUX_PIN_P3_2) { - pinmux_digitalmic2[0].pin = HAL_IOMUX_PIN_P3_2; - } - - if ((map & 0xF) == 0) { - pinmux_digitalmic_clk[0].function = HAL_IOMUX_FUNC_GPIO; - } - hal_iomux_init(pinmux_digitalmic_clk, ARRAY_SIZE(pinmux_digitalmic_clk)); - if (map & (1 << 0)) { - hal_iomux_init(pinmux_digitalmic0, ARRAY_SIZE(pinmux_digitalmic0)); - } - if (map & (1 << 1)) { - hal_iomux_init(pinmux_digitalmic1, ARRAY_SIZE(pinmux_digitalmic1)); - } - if (map & (1 << 2)) { - hal_iomux_init(pinmux_digitalmic2, ARRAY_SIZE(pinmux_digitalmic2)); - } -} - -void hal_iomux_set_spi(void) -{ - static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_spi_3wire[3] = { - {HAL_IOMUX_PIN_P0_5, HAL_IOMUX_FUNC_SPI_CLK, SPI_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P0_6, HAL_IOMUX_FUNC_SPI_CS0, SPI_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P0_7, HAL_IOMUX_FUNC_SPI_DIO, SPI_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, +void hal_iomux_set_spi(void) { + static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_spi_3wire[3] = { + {HAL_IOMUX_PIN_P0_5, HAL_IOMUX_FUNC_SPI_CLK, SPI_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P0_6, HAL_IOMUX_FUNC_SPI_CS0, SPI_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P0_7, HAL_IOMUX_FUNC_SPI_DIO, SPI_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #ifdef SPI_IOMUX_CS1_INDEX #if (SPI_IOMUX_CS1_INDEX == 35) - {HAL_IOMUX_PIN_P3_5, HAL_IOMUX_FUNC_SPI_CS1, SPI_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P3_5, HAL_IOMUX_FUNC_SPI_CS1, SPI_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #else - {HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_SPI_CS1, SPI_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_SPI_CS1, SPI_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #endif #endif #ifdef SPI_IOMUX_CS2_INDEX #if (SPI_IOMUX_CS2_INDEX == 37) - {HAL_IOMUX_PIN_P3_7, HAL_IOMUX_FUNC_SPI_CS2, SPI_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P3_7, HAL_IOMUX_FUNC_SPI_CS2, SPI_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #else - {HAL_IOMUX_PIN_P1_1, HAL_IOMUX_FUNC_SPI_CS2, SPI_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P1_1, HAL_IOMUX_FUNC_SPI_CS2, SPI_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #endif #endif #ifdef SPI_IOMUX_CS3_INDEX #if (SPI_IOMUX_CS3_INDEX == 25) - {HAL_IOMUX_PIN_P2_5, HAL_IOMUX_FUNC_SPI_CS3, SPI_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P2_5, HAL_IOMUX_FUNC_SPI_CS3, SPI_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #else - {HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_SPI_CS3, SPI_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_SPI_CS3, SPI_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #endif #endif - }; + }; #ifdef SPI_IOMUX_4WIRE - static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_spi_4wire[1] = { - {HAL_IOMUX_PIN_P0_4, HAL_IOMUX_FUNC_SPI_DI0, SPI_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_spi_4wire[1] = { + {HAL_IOMUX_PIN_P0_4, HAL_IOMUX_FUNC_SPI_DI0, SPI_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #ifdef SPI_IOMUX_DI1_INDEX - {HAL_IOMUX_PIN_P3_4, HAL_IOMUX_FUNC_SPI_DI1, SPI_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P3_4, HAL_IOMUX_FUNC_SPI_DI1, SPI_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #endif #ifdef SPI_IOMUX_DI2_INDEX - {HAL_IOMUX_PIN_P3_6, HAL_IOMUX_FUNC_SPI_DI2, SPI_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P3_6, HAL_IOMUX_FUNC_SPI_DI2, SPI_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #endif #ifdef SPI_IOMUX_DI3_INDEX - {HAL_IOMUX_PIN_P2_4, HAL_IOMUX_FUNC_SPI_DI3, SPI_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P2_4, HAL_IOMUX_FUNC_SPI_DI3, SPI_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #endif - }; + }; #endif - hal_iomux_init(pinmux_spi_3wire, ARRAY_SIZE(pinmux_spi_3wire)); + hal_iomux_init(pinmux_spi_3wire, ARRAY_SIZE(pinmux_spi_3wire)); #ifdef SPI_IOMUX_4WIRE - hal_iomux_init(pinmux_spi_4wire, ARRAY_SIZE(pinmux_spi_4wire)); + hal_iomux_init(pinmux_spi_4wire, ARRAY_SIZE(pinmux_spi_4wire)); #endif } -void hal_iomux_set_spilcd(void) -{ - static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_spilcd_3wire[] = { +void hal_iomux_set_spilcd(void) { + static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_spilcd_3wire[] = { #if (SPILCD_IOMUX_INDEX == 10) - {HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_SPILCD_CLK, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P1_1, HAL_IOMUX_FUNC_SPILCD_CS0, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_SPILCD_DIO, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_SPILCD_CLK, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P1_1, HAL_IOMUX_FUNC_SPILCD_CS0, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_SPILCD_DIO, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #elif (SPILCD_IOMUX_INDEX == 35) - {HAL_IOMUX_PIN_P3_7, HAL_IOMUX_FUNC_SPILCD_CLK, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P3_6, HAL_IOMUX_FUNC_SPILCD_CS0, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P3_5, HAL_IOMUX_FUNC_SPILCD_DIO, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P3_7, HAL_IOMUX_FUNC_SPILCD_CLK, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P3_6, HAL_IOMUX_FUNC_SPILCD_CS0, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P3_5, HAL_IOMUX_FUNC_SPILCD_DIO, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #else - {HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_SPILCD_CLK, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_SPILCD_CS0, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, - {HAL_IOMUX_PIN_P0_1, HAL_IOMUX_FUNC_SPILCD_DIO, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_SPILCD_CLK, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_SPILCD_CS0, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P0_1, HAL_IOMUX_FUNC_SPILCD_DIO, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #endif #ifdef SPILCD_IOMUX_CS1_INDEX #if (SPILCD_IOMUX_CS1_INDEX == 12) - {HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_SPILCD_CS1, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_SPILCD_CS1, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #elif (SPILCD_IOMUX_CS1_INDEX == 27) - {HAL_IOMUX_PIN_P2_7, HAL_IOMUX_FUNC_SPILCD_CS1, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P2_7, HAL_IOMUX_FUNC_SPILCD_CS1, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #elif (SPILCD_IOMUX_CS1_INDEX == 30) - {HAL_IOMUX_PIN_P3_0, HAL_IOMUX_FUNC_SPILCD_CS1, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P3_0, HAL_IOMUX_FUNC_SPILCD_CS1, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #else - {HAL_IOMUX_PIN_P0_5, HAL_IOMUX_FUNC_SPILCD_CS1, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P0_5, HAL_IOMUX_FUNC_SPILCD_CS1, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #endif #endif #ifdef SPILCD_IOMUX_CS2_INDEX #if (SPILCD_IOMUX_CS2_INDEX == 31) - {HAL_IOMUX_PIN_P3_1, HAL_IOMUX_FUNC_SPILCD_CS2, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P3_1, HAL_IOMUX_FUNC_SPILCD_CS2, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #else - {HAL_IOMUX_PIN_P0_6, HAL_IOMUX_FUNC_SPILCD_CS2, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P0_6, HAL_IOMUX_FUNC_SPILCD_CS2, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #endif #endif #ifdef SPILCD_IOMUX_CS3_INDEX #if (SPILCD_IOMUX_CS3_INDEX == 31) - {HAL_IOMUX_PIN_P3_1, HAL_IOMUX_FUNC_SPILCD_CS3, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P3_1, HAL_IOMUX_FUNC_SPILCD_CS3, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #elif (SPILCD_IOMUX_CS3_INDEX == 32) - {HAL_IOMUX_PIN_P3_2, HAL_IOMUX_FUNC_SPILCD_CS3, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P3_2, HAL_IOMUX_FUNC_SPILCD_CS3, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #else - {HAL_IOMUX_PIN_P0_7, HAL_IOMUX_FUNC_SPILCD_CS3, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P0_7, HAL_IOMUX_FUNC_SPILCD_CS3, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #endif #endif - }; + }; #ifdef SPILCD_IOMUX_4WIRE - static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_spilcd_4wire[] = { + static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_spilcd_4wire[] = { #ifdef SPILCD_IOMUX_DI0_INDEX #if (SPILCD_IOMUX_DI0_INDEX == 14) - {HAL_IOMUX_PIN_P1_4, HAL_IOMUX_FUNC_SPILCD_DI0, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P1_4, HAL_IOMUX_FUNC_SPILCD_DI0, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #elif (SPILCD_IOMUX_DI0_INDEX == 34) - {HAL_IOMUX_PIN_P3_4, HAL_IOMUX_FUNC_SPILCD_DI0, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P3_4, HAL_IOMUX_FUNC_SPILCD_DI0, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #else - {HAL_IOMUX_PIN_P0_0, HAL_IOMUX_FUNC_SPILCD_DI0, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P0_0, HAL_IOMUX_FUNC_SPILCD_DI0, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #endif #endif #ifdef SPILCD_IOMUX_DI1_INDEX - {HAL_IOMUX_PIN_P2_6, HAL_IOMUX_FUNC_SPILCD_DI1, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P2_6, HAL_IOMUX_FUNC_SPILCD_DI1, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #endif #ifdef SPILCD_IOMUX_DI2_INDEX - {HAL_IOMUX_PIN_P3_0, HAL_IOMUX_FUNC_SPILCD_DI2, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P3_0, HAL_IOMUX_FUNC_SPILCD_DI2, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #endif #ifdef SPILCD_IOMUX_DI3_INDEX - {HAL_IOMUX_PIN_P3_3, HAL_IOMUX_FUNC_SPILCD_DI3, SPILCD_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P3_3, HAL_IOMUX_FUNC_SPILCD_DI3, SPILCD_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #endif - }; + }; #endif - hal_iomux_init(pinmux_spilcd_3wire, ARRAY_SIZE(pinmux_spilcd_3wire)); + hal_iomux_init(pinmux_spilcd_3wire, ARRAY_SIZE(pinmux_spilcd_3wire)); #ifdef SPILCD_IOMUX_4WIRE - hal_iomux_init(pinmux_spilcd_4wire, ARRAY_SIZE(pinmux_spilcd_4wire)); + hal_iomux_init(pinmux_spilcd_4wire, ARRAY_SIZE(pinmux_spilcd_4wire)); #endif } -void hal_iomux_set_i2c0(void) -{ +void hal_iomux_set_i2c0(void) { #if (I2C0_IOMUX_INDEX == 16) - hal_iomux_set_analog_i2c(); - // IOMUX_GPIO_I2C_MODE should be kept in disabled state - iomux->REG_050 &= ~IOMUX_I2C0_M_SEL_GPIO; + hal_iomux_set_analog_i2c(); + // IOMUX_GPIO_I2C_MODE should be kept in disabled state + iomux->REG_050 &= ~IOMUX_I2C0_M_SEL_GPIO; #else - static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_i2c[] = { - {HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_I2C_M0_SCL, I2C0_VOLTAGE_SEL, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_I2C_M0_SDA, I2C0_VOLTAGE_SEL, HAL_IOMUX_PIN_PULLUP_ENABLE}, - }; + static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_i2c[] = { + {HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_I2C_M0_SCL, I2C0_VOLTAGE_SEL, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_I2C_M0_SDA, I2C0_VOLTAGE_SEL, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + }; - hal_iomux_init(pinmux_i2c, ARRAY_SIZE(pinmux_i2c)); + hal_iomux_init(pinmux_i2c, ARRAY_SIZE(pinmux_i2c)); #endif } -void hal_iomux_set_i2c1(void) -{ - static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_i2c[] = { +void hal_iomux_set_i2c1(void) { + static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_i2c[] = { #if (I2C1_IOMUX_INDEX == 22) - {HAL_IOMUX_PIN_P2_2, HAL_IOMUX_FUNC_I2C_M1_SCL, I2C1_VOLTAGE_SEL, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_P2_3, HAL_IOMUX_FUNC_I2C_M1_SDA, I2C1_VOLTAGE_SEL, HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_P2_2, HAL_IOMUX_FUNC_I2C_M1_SCL, I2C1_VOLTAGE_SEL, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_P2_3, HAL_IOMUX_FUNC_I2C_M1_SDA, I2C1_VOLTAGE_SEL, + HAL_IOMUX_PIN_PULLUP_ENABLE}, #else - {HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_I2C_M1_SCL, I2C1_VOLTAGE_SEL, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_I2C_M1_SDA, I2C1_VOLTAGE_SEL, HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_I2C_M1_SCL, I2C1_VOLTAGE_SEL, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_I2C_M1_SDA, I2C1_VOLTAGE_SEL, + HAL_IOMUX_PIN_PULLUP_ENABLE}, #endif - }; + }; - hal_iomux_init(pinmux_i2c, ARRAY_SIZE(pinmux_i2c)); - iomux->REG_050 |= IOMUX_I2C1_M_SEL_GPIO; + hal_iomux_init(pinmux_i2c, ARRAY_SIZE(pinmux_i2c)); + iomux->REG_050 |= IOMUX_I2C1_M_SEL_GPIO; } -void hal_iomux_set_clock_out(void) -{ - static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_clkout[] = { +void hal_iomux_set_clock_out(void) { + static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_clkout[] = { #if (CLKOUT_IOMUX_INDEX == 13) - {HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_CLK_OUT, CLKOUT_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_CLK_OUT, CLKOUT_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #elif (CLKOUT_IOMUX_INDEX == 15) - {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_CLK_OUT, CLKOUT_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_CLK_OUT, CLKOUT_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #elif (CLKOUT_IOMUX_INDEX == 21) - {HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_CLK_OUT, CLKOUT_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_CLK_OUT, CLKOUT_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #elif (CLKOUT_IOMUX_INDEX == 23) - {HAL_IOMUX_PIN_P2_3, HAL_IOMUX_FUNC_CLK_OUT, CLKOUT_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P2_3, HAL_IOMUX_FUNC_CLK_OUT, CLKOUT_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #elif (CLKOUT_IOMUX_INDEX == 27) - {HAL_IOMUX_PIN_P2_7, HAL_IOMUX_FUNC_CLK_OUT, CLKOUT_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P2_7, HAL_IOMUX_FUNC_CLK_OUT, CLKOUT_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #elif (CLKOUT_IOMUX_INDEX == 34) - {HAL_IOMUX_PIN_P3_4, HAL_IOMUX_FUNC_CLK_OUT, CLKOUT_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P3_4, HAL_IOMUX_FUNC_CLK_OUT, CLKOUT_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #else - {HAL_IOMUX_PIN_P0_4, HAL_IOMUX_FUNC_CLK_OUT, CLKOUT_VOLTAGE_SEL, HAL_IOMUX_PIN_NOPULL}, + {HAL_IOMUX_PIN_P0_4, HAL_IOMUX_FUNC_CLK_OUT, CLKOUT_VOLTAGE_SEL, + HAL_IOMUX_PIN_NOPULL}, #endif - }; + }; - hal_iomux_init(pinmux_clkout, ARRAY_SIZE(pinmux_clkout)); + hal_iomux_init(pinmux_clkout, ARRAY_SIZE(pinmux_clkout)); } -void hal_iomux_set_mcu_clock_out(void) -{ -} +void hal_iomux_set_mcu_clock_out(void) {} -void hal_iomux_set_bt_clock_out(void) -{ -} +void hal_iomux_set_bt_clock_out(void) {} -void hal_iomux_set_bt_tport(void) -{ - // P0_0 ~ P0_3, - iomux->REG_004 = (iomux->REG_004 & ~(IOMUX_GPIO_P00_SEL_MASK | IOMUX_GPIO_P01_SEL_MASK | IOMUX_GPIO_P02_SEL_MASK | IOMUX_GPIO_P03_SEL_MASK)) | - IOMUX_GPIO_P00_SEL(0xA) | IOMUX_GPIO_P01_SEL(0xA) | IOMUX_GPIO_P02_SEL(0xA) |IOMUX_GPIO_P03_SEL(0xA); +void hal_iomux_set_bt_tport(void) { + // P0_0 ~ P0_3, + iomux->REG_004 = + (iomux->REG_004 & ~(IOMUX_GPIO_P00_SEL_MASK | IOMUX_GPIO_P01_SEL_MASK | + IOMUX_GPIO_P02_SEL_MASK | IOMUX_GPIO_P03_SEL_MASK)) | + IOMUX_GPIO_P00_SEL(0xA) | IOMUX_GPIO_P01_SEL(0xA) | + IOMUX_GPIO_P02_SEL(0xA) | IOMUX_GPIO_P03_SEL(0xA); #ifdef TPORTS_KEY_COEXIST - //P1_1 ~ P1_2, - iomux->REG_008 = (iomux->REG_008 & ~(IOMUX_GPIO_P11_SEL_MASK | IOMUX_GPIO_P12_SEL_MASK)) | - IOMUX_GPIO_P11_SEL(0xA) | IOMUX_GPIO_P12_SEL(0xA); + // P1_1 ~ P1_2, + iomux->REG_008 = + (iomux->REG_008 & ~(IOMUX_GPIO_P11_SEL_MASK | IOMUX_GPIO_P12_SEL_MASK)) | + IOMUX_GPIO_P11_SEL(0xA) | IOMUX_GPIO_P12_SEL(0xA); #else - //P1_0 ~ P1_3, - iomux->REG_008 = (iomux->REG_008 & ~(IOMUX_GPIO_P10_SEL_MASK | IOMUX_GPIO_P11_SEL_MASK | IOMUX_GPIO_P12_SEL_MASK | IOMUX_GPIO_P13_SEL_MASK )) | - IOMUX_GPIO_P10_SEL(0xA) | IOMUX_GPIO_P11_SEL(0xA) | IOMUX_GPIO_P12_SEL(0xA) | IOMUX_GPIO_P13_SEL(0xA); + // P1_0 ~ P1_3, + iomux->REG_008 = + (iomux->REG_008 & ~(IOMUX_GPIO_P10_SEL_MASK | IOMUX_GPIO_P11_SEL_MASK | + IOMUX_GPIO_P12_SEL_MASK | IOMUX_GPIO_P13_SEL_MASK)) | + IOMUX_GPIO_P10_SEL(0xA) | IOMUX_GPIO_P11_SEL(0xA) | + IOMUX_GPIO_P12_SEL(0xA) | IOMUX_GPIO_P13_SEL(0xA); #endif - // ANA TEST DIR - iomux->REG_014 = 0x0f0f; - // ANA TEST SEL - iomux->REG_018 = IOMUX_ANA_TEST_SEL(5); + // ANA TEST DIR + iomux->REG_014 = 0x0f0f; + // ANA TEST SEL + iomux->REG_018 = IOMUX_ANA_TEST_SEL(5); } -void hal_iomux_set_bt_rf_sw(int rx_on, int tx_on) -{ - uint32_t val; - uint32_t dir; +void hal_iomux_set_bt_rf_sw(int rx_on, int tx_on) { + uint32_t val; + uint32_t dir; - //iomux->REG_004 = (iomux->REG_004 & ~(IOMUX_GPIO_P00_SEL_MASK | IOMUX_GPIO_P01_SEL_MASK)) | - // IOMUX_GPIO_P00_SEL(6) | IOMUX_GPIO_P01_SEL(6); + // iomux->REG_004 = (iomux->REG_004 & ~(IOMUX_GPIO_P00_SEL_MASK | + // IOMUX_GPIO_P01_SEL_MASK)) | + // IOMUX_GPIO_P00_SEL(6) | IOMUX_GPIO_P01_SEL(6); - val = iomux->REG_004; - dir = 0; - if (rx_on) { - val = SET_BITFIELD(val, IOMUX_GPIO_P00_SEL, 0xA); - dir = (1 << HAL_IOMUX_PIN_P0_0); - } - if (tx_on) { - val = SET_BITFIELD(val, IOMUX_GPIO_P01_SEL, 0xA); - dir = (1 << HAL_IOMUX_PIN_P0_1); - } - iomux->REG_004 = val; - // ANA TEST DIR - iomux->REG_014 |= dir; - // ANA TEST SEL - iomux->REG_018 = IOMUX_ANA_TEST_SEL(5); + val = iomux->REG_004; + dir = 0; + if (rx_on) { + val = SET_BITFIELD(val, IOMUX_GPIO_P00_SEL, 0xA); + dir = (1 << HAL_IOMUX_PIN_P0_0); + } + if (tx_on) { + val = SET_BITFIELD(val, IOMUX_GPIO_P01_SEL, 0xA); + dir = (1 << HAL_IOMUX_PIN_P0_1); + } + iomux->REG_004 = val; + // ANA TEST DIR + iomux->REG_014 |= dir; + // ANA TEST SEL + iomux->REG_018 = IOMUX_ANA_TEST_SEL(5); } -int WEAK hal_pwrkey_set_irq(enum HAL_PWRKEY_IRQ_T type) -{ - return 0; -} +int WEAK hal_pwrkey_set_irq(enum HAL_PWRKEY_IRQ_T type) { return 0; } -bool WEAK hal_pwrkey_pressed(void) -{ - return 0; -} +bool WEAK hal_pwrkey_pressed(void) { return 0; } -bool hal_pwrkey_startup_pressed(void) -{ - return hal_pwrkey_pressed(); -} +bool hal_pwrkey_startup_pressed(void) { return hal_pwrkey_pressed(); } -enum HAL_PWRKEY_IRQ_T WEAK hal_pwrkey_get_irq_state(void) -{ - enum HAL_PWRKEY_IRQ_T state = HAL_PWRKEY_IRQ_NONE; +enum HAL_PWRKEY_IRQ_T WEAK hal_pwrkey_get_irq_state(void) { + enum HAL_PWRKEY_IRQ_T state = HAL_PWRKEY_IRQ_NONE; - return state; + return state; } const struct HAL_IOMUX_PIN_FUNCTION_MAP iomux_tport[] = { -/* {HAL_IOMUX_PIN_P1_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE},*/ - {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}, + /* {HAL_IOMUX_PIN_P1_1, HAL_IOMUX_FUNC_AS_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE},*/ + {HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}, }; -int hal_iomux_tportopen(void) -{ - int i; +int hal_iomux_tportopen(void) { + int i; - for (i=0;iREG_064 = SET_BITFIELD(iomux->REG_064, IOMUX_CFG_CODEC_TRIG_SEL, pin); - if (polarity) { - iomux->REG_064 &= ~IOMUX_CFG_CODEC_TRIG_POL; - } else { - iomux->REG_064 |= IOMUX_CFG_CODEC_TRIG_POL; - } +void hal_iomux_set_codec_gpio_trigger(enum HAL_IOMUX_PIN_T pin, bool polarity) { + iomux->REG_064 = SET_BITFIELD(iomux->REG_064, IOMUX_CFG_CODEC_TRIG_SEL, pin); + if (polarity) { + iomux->REG_064 &= ~IOMUX_CFG_CODEC_TRIG_POL; + } else { + iomux->REG_064 |= IOMUX_CFG_CODEC_TRIG_POL; + } } - diff --git a/platform/hal/best2300p/hal_psc_best2300p.c b/platform/hal/best2300p/hal_psc_best2300p.c index 1a2d424..9fefbde 100644 --- a/platform/hal/best2300p/hal_psc_best2300p.c +++ b/platform/hal/best2300p/hal_psc_best2300p.c @@ -13,111 +13,92 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_addr_map.h" #include "cmsis.h" -#include "hal_timer.h" #include "hal_location.h" #include "hal_psc.h" +#include "hal_timer.h" +#include "plat_addr_map.h" #include CHIP_SPECIFIC_HDR(reg_psc) -#define PSC_WRITE_ENABLE 0xCAFE0000 +#define PSC_WRITE_ENABLE 0xCAFE0000 -static struct AONPSC_T * const psc = (struct AONPSC_T *)AON_PSC_BASE; +static struct AONPSC_T *const psc = (struct AONPSC_T *)AON_PSC_BASE; -void BOOT_TEXT_FLASH_LOC hal_psc_init(void) -{ - // Setup wakeup mask - psc->REG_080 = 0xFFFFFFFF; - psc->REG_084 = 0xFFFFFFFF; +void BOOT_TEXT_FLASH_LOC hal_psc_init(void) { + // Setup wakeup mask + psc->REG_080 = 0xFFFFFFFF; + psc->REG_084 = 0xFFFFFFFF; } -void SRAM_TEXT_LOC hal_psc_core_auto_power_down(void) -{ - psc->REG_018 = PSC_WRITE_ENABLE | 0; - psc->REG_000 = PSC_WRITE_ENABLE | PSC_AON_MCU_PG_AUTO_EN; - psc->REG_010 = PSC_WRITE_ENABLE | PSC_AON_MCU_POWERDN_START; +void SRAM_TEXT_LOC hal_psc_core_auto_power_down(void) { + psc->REG_018 = PSC_WRITE_ENABLE | 0; + psc->REG_000 = PSC_WRITE_ENABLE | PSC_AON_MCU_PG_AUTO_EN; + psc->REG_010 = PSC_WRITE_ENABLE | PSC_AON_MCU_POWERDN_START; } -void SRAM_TEXT_LOC hal_psc_mcu_auto_power_up(void) -{ - psc->REG_014 = PSC_WRITE_ENABLE | PSC_AON_MCU_POWERUP_START; +void SRAM_TEXT_LOC hal_psc_mcu_auto_power_up(void) { + psc->REG_014 = PSC_WRITE_ENABLE | PSC_AON_MCU_POWERUP_START; } -void BOOT_TEXT_FLASH_LOC hal_psc_codec_enable(void) -{ - psc->REG_078 = PSC_WRITE_ENABLE | - PSC_AON_CODEC_PSW_EN_DR | - PSC_AON_CODEC_RESETN_ASSERT_DR | PSC_AON_CODEC_RESETN_ASSERT_REG | - PSC_AON_CODEC_ISO_EN_DR | PSC_AON_CODEC_ISO_EN_REG | - PSC_AON_CODEC_CLK_STOP_DR | PSC_AON_CODEC_CLK_STOP_REG; - hal_sys_timer_delay(MS_TO_TICKS(1)); - psc->REG_078 = PSC_WRITE_ENABLE | - PSC_AON_CODEC_PSW_EN_DR | - PSC_AON_CODEC_RESETN_ASSERT_DR | - PSC_AON_CODEC_ISO_EN_DR | PSC_AON_CODEC_ISO_EN_REG | - PSC_AON_CODEC_CLK_STOP_DR | PSC_AON_CODEC_CLK_STOP_REG; - psc->REG_078 = PSC_WRITE_ENABLE | - PSC_AON_CODEC_PSW_EN_DR | - PSC_AON_CODEC_RESETN_ASSERT_DR | - PSC_AON_CODEC_ISO_EN_DR | - PSC_AON_CODEC_CLK_STOP_DR | PSC_AON_CODEC_CLK_STOP_REG; - psc->REG_078 = PSC_WRITE_ENABLE | - PSC_AON_CODEC_PSW_EN_DR | - PSC_AON_CODEC_RESETN_ASSERT_DR | - PSC_AON_CODEC_ISO_EN_DR | - PSC_AON_CODEC_CLK_STOP_DR; +void BOOT_TEXT_FLASH_LOC hal_psc_codec_enable(void) { + psc->REG_078 = PSC_WRITE_ENABLE | PSC_AON_CODEC_PSW_EN_DR | + PSC_AON_CODEC_RESETN_ASSERT_DR | + PSC_AON_CODEC_RESETN_ASSERT_REG | PSC_AON_CODEC_ISO_EN_DR | + PSC_AON_CODEC_ISO_EN_REG | PSC_AON_CODEC_CLK_STOP_DR | + PSC_AON_CODEC_CLK_STOP_REG; + hal_sys_timer_delay(MS_TO_TICKS(1)); + psc->REG_078 = PSC_WRITE_ENABLE | PSC_AON_CODEC_PSW_EN_DR | + PSC_AON_CODEC_RESETN_ASSERT_DR | PSC_AON_CODEC_ISO_EN_DR | + PSC_AON_CODEC_ISO_EN_REG | PSC_AON_CODEC_CLK_STOP_DR | + PSC_AON_CODEC_CLK_STOP_REG; + psc->REG_078 = PSC_WRITE_ENABLE | PSC_AON_CODEC_PSW_EN_DR | + PSC_AON_CODEC_RESETN_ASSERT_DR | PSC_AON_CODEC_ISO_EN_DR | + PSC_AON_CODEC_CLK_STOP_DR | PSC_AON_CODEC_CLK_STOP_REG; + psc->REG_078 = PSC_WRITE_ENABLE | PSC_AON_CODEC_PSW_EN_DR | + PSC_AON_CODEC_RESETN_ASSERT_DR | PSC_AON_CODEC_ISO_EN_DR | + PSC_AON_CODEC_CLK_STOP_DR; } -void BOOT_TEXT_FLASH_LOC hal_psc_codec_disable(void) -{ - psc->REG_078 = PSC_WRITE_ENABLE | - PSC_AON_CODEC_PSW_EN_DR | PSC_AON_CODEC_PSW_EN_REG | - PSC_AON_CODEC_RESETN_ASSERT_DR | PSC_AON_CODEC_RESETN_ASSERT_REG | - PSC_AON_CODEC_ISO_EN_DR | PSC_AON_CODEC_ISO_EN_REG | - PSC_AON_CODEC_CLK_STOP_DR | PSC_AON_CODEC_CLK_STOP_REG; +void BOOT_TEXT_FLASH_LOC hal_psc_codec_disable(void) { + psc->REG_078 = PSC_WRITE_ENABLE | PSC_AON_CODEC_PSW_EN_DR | + PSC_AON_CODEC_PSW_EN_REG | PSC_AON_CODEC_RESETN_ASSERT_DR | + PSC_AON_CODEC_RESETN_ASSERT_REG | PSC_AON_CODEC_ISO_EN_DR | + PSC_AON_CODEC_ISO_EN_REG | PSC_AON_CODEC_CLK_STOP_DR | + PSC_AON_CODEC_CLK_STOP_REG; } -void BOOT_TEXT_FLASH_LOC hal_psc_bt_enable(void) -{ - psc->REG_038 = PSC_WRITE_ENABLE | - PSC_AON_BT_PSW_EN_DR | - PSC_AON_BT_RESETN_ASSERT_DR | PSC_AON_BT_RESETN_ASSERT_REG | - PSC_AON_BT_ISO_EN_DR | PSC_AON_BT_ISO_EN_REG | - PSC_AON_BT_CLK_STOP_DR | PSC_AON_BT_CLK_STOP_REG; - hal_sys_timer_delay(MS_TO_TICKS(1)); - psc->REG_038 = PSC_WRITE_ENABLE | - PSC_AON_BT_PSW_EN_DR | - PSC_AON_BT_RESETN_ASSERT_DR | - PSC_AON_BT_ISO_EN_DR | PSC_AON_BT_ISO_EN_REG | - PSC_AON_BT_CLK_STOP_DR | PSC_AON_BT_CLK_STOP_REG; - psc->REG_038 = PSC_WRITE_ENABLE | - PSC_AON_BT_PSW_EN_DR | - PSC_AON_BT_RESETN_ASSERT_DR | - PSC_AON_BT_ISO_EN_DR | - PSC_AON_BT_CLK_STOP_DR | PSC_AON_BT_CLK_STOP_REG; - psc->REG_038 = PSC_WRITE_ENABLE | - PSC_AON_BT_PSW_EN_DR | - PSC_AON_BT_RESETN_ASSERT_DR | - PSC_AON_BT_ISO_EN_DR | - PSC_AON_BT_CLK_STOP_DR; +void BOOT_TEXT_FLASH_LOC hal_psc_bt_enable(void) { + psc->REG_038 = PSC_WRITE_ENABLE | PSC_AON_BT_PSW_EN_DR | + PSC_AON_BT_RESETN_ASSERT_DR | PSC_AON_BT_RESETN_ASSERT_REG | + PSC_AON_BT_ISO_EN_DR | PSC_AON_BT_ISO_EN_REG | + PSC_AON_BT_CLK_STOP_DR | PSC_AON_BT_CLK_STOP_REG; + hal_sys_timer_delay(MS_TO_TICKS(1)); + psc->REG_038 = PSC_WRITE_ENABLE | PSC_AON_BT_PSW_EN_DR | + PSC_AON_BT_RESETN_ASSERT_DR | PSC_AON_BT_ISO_EN_DR | + PSC_AON_BT_ISO_EN_REG | PSC_AON_BT_CLK_STOP_DR | + PSC_AON_BT_CLK_STOP_REG; + psc->REG_038 = PSC_WRITE_ENABLE | PSC_AON_BT_PSW_EN_DR | + PSC_AON_BT_RESETN_ASSERT_DR | PSC_AON_BT_ISO_EN_DR | + PSC_AON_BT_CLK_STOP_DR | PSC_AON_BT_CLK_STOP_REG; + psc->REG_038 = PSC_WRITE_ENABLE | PSC_AON_BT_PSW_EN_DR | + PSC_AON_BT_RESETN_ASSERT_DR | PSC_AON_BT_ISO_EN_DR | + PSC_AON_BT_CLK_STOP_DR; #ifdef JTAG_BT - psc->REG_064 |= PSC_AON_CODEC_RESERVED(1 << 3); - psc->REG_064 &= ~PSC_AON_CODEC_RESERVED(1 << 2); + psc->REG_064 |= PSC_AON_CODEC_RESERVED(1 << 3); + psc->REG_064 &= ~PSC_AON_CODEC_RESERVED(1 << 2); #endif } -void BOOT_TEXT_FLASH_LOC hal_psc_bt_disable(void) -{ +void BOOT_TEXT_FLASH_LOC hal_psc_bt_disable(void) { #ifdef JTAG_BT - psc->REG_064 &= ~PSC_AON_CODEC_RESERVED(1 << 3); - psc->REG_064 |= PSC_AON_CODEC_RESERVED(1 << 2); + psc->REG_064 &= ~PSC_AON_CODEC_RESERVED(1 << 3); + psc->REG_064 |= PSC_AON_CODEC_RESERVED(1 << 2); #endif - psc->REG_038 = PSC_WRITE_ENABLE | - PSC_AON_BT_PSW_EN_DR | PSC_AON_BT_PSW_EN_REG | - PSC_AON_BT_RESETN_ASSERT_DR | PSC_AON_BT_RESETN_ASSERT_REG | - PSC_AON_BT_ISO_EN_DR | PSC_AON_BT_ISO_EN_REG | - PSC_AON_BT_CLK_STOP_DR | PSC_AON_BT_CLK_STOP_REG; + psc->REG_038 = PSC_WRITE_ENABLE | PSC_AON_BT_PSW_EN_DR | + PSC_AON_BT_PSW_EN_REG | PSC_AON_BT_RESETN_ASSERT_DR | + PSC_AON_BT_RESETN_ASSERT_REG | PSC_AON_BT_ISO_EN_DR | + PSC_AON_BT_ISO_EN_REG | PSC_AON_BT_CLK_STOP_DR | + PSC_AON_BT_CLK_STOP_REG; } - diff --git a/platform/hal/best2300p/hal_sensor_eng_best2300p.c b/platform/hal/best2300p/hal_sensor_eng_best2300p.c index 6972742..f137ca3 100644 --- a/platform/hal/best2300p/hal_sensor_eng_best2300p.c +++ b/platform/hal/best2300p/hal_sensor_eng_best2300p.c @@ -1,9 +1,9 @@ -#include "plat_addr_map.h" #include "cmsis_nvic.h" #include "hal_dma.h" #include "hal_sensor_eng.h" #include "hal_timer.h" #include "hal_trace.h" +#include "plat_addr_map.h" #include CHIP_SPECIFIC_HDR(reg_sensor_eng) #include "reg_timer.h" #include "string.h" @@ -13,11 +13,12 @@ #define MAX_RX_FRAME_NUM (5) -static struct SENSOR_ENG_T * const sensor_eng[] = { +static struct SENSOR_ENG_T *const sensor_eng[] = { (struct SENSOR_ENG_T *)SENSOR_ENG_BASE, }; -static struct DUAL_TIMER_T * const sensor_eng_timer = (struct DUAL_TIMER_T *)MCU_TIMER2_BASE; +static struct DUAL_TIMER_T *const sensor_eng_timer = + (struct DUAL_TIMER_T *)MCU_TIMER2_BASE; static struct HAL_DMA_DESC_T tx_dma_desc[1]; static struct HAL_DMA_DESC_T rx_dma_desc[MAX_RX_FRAME_NUM]; @@ -30,196 +31,204 @@ static uint8_t *dma_rx_buf; static uint32_t dma_rx_len; static uint32_t prev_rx_pos; -void hal_sensor_process_rx_buffer(void) -{ - if (dma_rx_len == 0) { - return; +void hal_sensor_process_rx_buffer(void) { + if (dma_rx_len == 0) { + return; + } + + uint8_t *dma_buf_active = (uint8_t *)hal_dma_get_cur_dst_addr(dma_rx_chan); + uint32_t result_len = 0; + uint8_t *curr_pos; + + curr_pos = dma_rx_buf + prev_rx_pos; + + // TRACE(2,"dma_buf_active:%08x curr_pos:%08x", dma_buf_active, curr_pos); + + if (dma_buf_active < curr_pos) { + result_len = dma_rx_buf + dma_rx_len - curr_pos; + // TRACE(2,"1:result_len:%08x, curr_pos:%08x", result_len, curr_pos); + // DUMP8("%02x ", curr_pos, result_len); + if (sensor_eng_handler) { + sensor_eng_handler(HAL_SENSOR_ENGINE_ID_0, HAL_SENSOR_ENGINE_DEVICE_I2C0, + curr_pos, result_len); } + curr_pos = dma_rx_buf; + } - uint8_t *dma_buf_active = (uint8_t *)hal_dma_get_cur_dst_addr(dma_rx_chan); - uint32_t result_len = 0; - uint8_t *curr_pos; - - curr_pos = dma_rx_buf + prev_rx_pos; - - //TRACE(2,"dma_buf_active:%08x curr_pos:%08x", dma_buf_active, curr_pos); - - if (dma_buf_active < curr_pos) { - result_len = dma_rx_buf + dma_rx_len - curr_pos; - //TRACE(2,"1:result_len:%08x, curr_pos:%08x", result_len, curr_pos); - //DUMP8("%02x ", curr_pos, result_len); - if (sensor_eng_handler){ - sensor_eng_handler(HAL_SENSOR_ENGINE_ID_0, HAL_SENSOR_ENGINE_DEVICE_I2C0, curr_pos, result_len); - } - curr_pos = dma_rx_buf; + if (curr_pos < dma_buf_active) { + result_len = dma_buf_active - curr_pos; + // TRACE(2,"2:result_len:%08x, curr_pos:%08x", result_len, curr_pos); + // DUMP8("%02x ", curr_pos, result_len); + if (sensor_eng_handler) { + sensor_eng_handler(HAL_SENSOR_ENGINE_ID_0, HAL_SENSOR_ENGINE_DEVICE_I2C0, + curr_pos, result_len); } + curr_pos = dma_buf_active; + } - if (curr_pos < dma_buf_active) { - result_len = dma_buf_active - curr_pos; - //TRACE(2,"2:result_len:%08x, curr_pos:%08x", result_len, curr_pos); - //DUMP8("%02x ", curr_pos, result_len); - if (sensor_eng_handler){ - sensor_eng_handler(HAL_SENSOR_ENGINE_ID_0, HAL_SENSOR_ENGINE_DEVICE_I2C0, curr_pos, result_len); - } - curr_pos = dma_buf_active; - } - - prev_rx_pos = curr_pos - dma_rx_buf; + prev_rx_pos = curr_pos - dma_rx_buf; } -static void hal_sensor_eng_irq_handler(void) -{ - //TRACE(2,"%s: irq=0x%08x", __func__, sensor_eng[0]->SENSOR_INTR_STS); +static void hal_sensor_eng_irq_handler(void) { + // TRACE(2,"%s: irq=0x%08x", __func__, sensor_eng[0]->SENSOR_INTR_STS); - sensor_eng[0]->SENSOR_INTR_CLR = SENSOR_INTR_CLEAR; + sensor_eng[0]->SENSOR_INTR_CLR = SENSOR_INTR_CLEAR; - hal_sensor_process_rx_buffer(); + hal_sensor_process_rx_buffer(); } -static void hal_sensor_eng_irq_enable(void) -{ - NVIC_SetVector(SENSOR_WKUP_IRQn, (uint32_t)hal_sensor_eng_irq_handler); - NVIC_SetPriority(SENSOR_WKUP_IRQn, IRQ_PRIORITY_HIGH); - NVIC_ClearPendingIRQ(SENSOR_WKUP_IRQn); - NVIC_EnableIRQ(SENSOR_WKUP_IRQn); +static void hal_sensor_eng_irq_enable(void) { + NVIC_SetVector(SENSOR_WKUP_IRQn, (uint32_t)hal_sensor_eng_irq_handler); + NVIC_SetPriority(SENSOR_WKUP_IRQn, IRQ_PRIORITY_HIGH); + NVIC_ClearPendingIRQ(SENSOR_WKUP_IRQn); + NVIC_EnableIRQ(SENSOR_WKUP_IRQn); } -static void hal_sensor_eng_irq_disable(void) -{ - NVIC_DisableIRQ(SENSOR_WKUP_IRQn); +static void hal_sensor_eng_irq_disable(void) { + NVIC_DisableIRQ(SENSOR_WKUP_IRQn); } -static void hal_sensor_eng_timer_stop(void) -{ - sensor_eng_timer->timer[0].Control = 0; - sensor_eng_timer->timer[0].IntClr = 1; +static void hal_sensor_eng_timer_stop(void) { + sensor_eng_timer->timer[0].Control = 0; + sensor_eng_timer->timer[0].IntClr = 1; } -static void hal_sensor_eng_timer_open(uint32_t ticks) -{ - if (ticks > 1) { - ticks -= 1; - } else { - ticks = 1; - } - sensor_eng_timer->timer[0].Load = ticks; - sensor_eng_timer->timer[0].Control = TIMER_CTRL_MODE_PERIODIC | TIMER_CTRL_INTEN | TIMER_CTRL_PRESCALE_DIV_1 | TIMER_CTRL_SIZE_32_BIT; +static void hal_sensor_eng_timer_open(uint32_t ticks) { + if (ticks > 1) { + ticks -= 1; + } else { + ticks = 1; + } + sensor_eng_timer->timer[0].Load = ticks; + sensor_eng_timer->timer[0].Control = + TIMER_CTRL_MODE_PERIODIC | TIMER_CTRL_INTEN | TIMER_CTRL_PRESCALE_DIV_1 | + TIMER_CTRL_SIZE_32_BIT; } -static void hal_sensor_eng_timer_start(void) -{ - sensor_eng_timer->timer[0].Control |= TIMER_CTRL_EN; +static void hal_sensor_eng_timer_start(void) { + sensor_eng_timer->timer[0].Control |= TIMER_CTRL_EN; } -int hal_sensor_engine_open(const struct HAL_SENSOR_ENGINE_CFG_T *cfg) -{ - struct HAL_DMA_CH_CFG_T rx_dma_cfg; - enum HAL_DMA_RET_T dret; - uint32_t i; - uint32_t sx_sel; +int hal_sensor_engine_open(const struct HAL_SENSOR_ENGINE_CFG_T *cfg) { + struct HAL_DMA_CH_CFG_T rx_dma_cfg; + enum HAL_DMA_RET_T dret; + uint32_t i; + uint32_t sx_sel; - ASSERT(cfg->id == HAL_SENSOR_ENGINE_ID_0, "Bad sensor engine id: %d", cfg->id); - ASSERT(cfg->device == HAL_SENSOR_ENGINE_DEVICE_I2C0, "Bad sensor engine device: %d", cfg->device); - ASSERT(cfg->rx_burst_cnt <= MAX_RX_FRAME_NUM, "Bad rx_burst_cnt: %d", cfg->rx_burst_cnt); - ASSERT(cfg->tx_dma_cfg, "Bad tx_dma_cfg"); + ASSERT(cfg->id == HAL_SENSOR_ENGINE_ID_0, "Bad sensor engine id: %d", + cfg->id); + ASSERT(cfg->device == HAL_SENSOR_ENGINE_DEVICE_I2C0, + "Bad sensor engine device: %d", cfg->device); + ASSERT(cfg->rx_burst_cnt <= MAX_RX_FRAME_NUM, "Bad rx_burst_cnt: %d", + cfg->rx_burst_cnt); + ASSERT(cfg->tx_dma_cfg, "Bad tx_dma_cfg"); - sensor_eng_handler = cfg->handler; - dma_rx_chan = cfg->rx_dma_cfg->ch; - dma_rx_buf = (uint8_t *)cfg->rx_dma_cfg->dst; - dma_rx_len = cfg->rx_burst_len * cfg->rx_burst_cnt; - prev_rx_pos = 0; + sensor_eng_handler = cfg->handler; + dma_rx_chan = cfg->rx_dma_cfg->ch; + dma_rx_buf = (uint8_t *)cfg->rx_dma_cfg->dst; + dma_rx_len = cfg->rx_burst_len * cfg->rx_burst_cnt; + prev_rx_pos = 0; - dret = hal_dma_init_desc(&tx_dma_desc[0], cfg->tx_dma_cfg, &tx_dma_desc[0], 0); - ASSERT(dret == HAL_DMA_OK, "SensorEng: Failed to init tx desc 0"); + dret = + hal_dma_init_desc(&tx_dma_desc[0], cfg->tx_dma_cfg, &tx_dma_desc[0], 0); + ASSERT(dret == HAL_DMA_OK, "SensorEng: Failed to init tx desc 0"); - dret = hal_gpdma_sg_start(&tx_dma_desc[0], cfg->tx_dma_cfg); - ASSERT(dret == HAL_DMA_OK, "SensorEng: Failed to start tx dma"); + dret = hal_gpdma_sg_start(&tx_dma_desc[0], cfg->tx_dma_cfg); + ASSERT(dret == HAL_DMA_OK, "SensorEng: Failed to start tx dma"); - if (dma_rx_len) { - ASSERT(cfg->rx_dma_cfg, "Bad rx_dma_cfg"); + if (dma_rx_len) { + ASSERT(cfg->rx_dma_cfg, "Bad rx_dma_cfg"); - rx_dma_cfg = *cfg->rx_dma_cfg; - for (i = 0; i < cfg->rx_burst_cnt; i++) { - rx_dma_cfg.dst = (uint32_t)(dma_rx_buf + cfg->rx_burst_len * i); - if (i + 1 == cfg->rx_burst_cnt) { - dret = hal_dma_init_desc(&rx_dma_desc[i], &rx_dma_cfg, &rx_dma_desc[0], 0); - } else { - dret = hal_dma_init_desc(&rx_dma_desc[i], &rx_dma_cfg, &rx_dma_desc[i + 1], 0); - } - ASSERT(dret == HAL_DMA_OK, "SensorEng: Failed to init rx desc %d", i); - } - hal_gpdma_sg_start(&rx_dma_desc[0], cfg->rx_dma_cfg); - ASSERT(dret == HAL_DMA_OK, "SensorEng: Failed to start rx dma"); + rx_dma_cfg = *cfg->rx_dma_cfg; + for (i = 0; i < cfg->rx_burst_cnt; i++) { + rx_dma_cfg.dst = (uint32_t)(dma_rx_buf + cfg->rx_burst_len * i); + if (i + 1 == cfg->rx_burst_cnt) { + dret = + hal_dma_init_desc(&rx_dma_desc[i], &rx_dma_cfg, &rx_dma_desc[0], 0); + } else { + dret = hal_dma_init_desc(&rx_dma_desc[i], &rx_dma_cfg, + &rx_dma_desc[i + 1], 0); + } + ASSERT(dret == HAL_DMA_OK, "SensorEng: Failed to init rx desc %d", i); } + hal_gpdma_sg_start(&rx_dma_desc[0], cfg->rx_dma_cfg); + ASSERT(dret == HAL_DMA_OK, "SensorEng: Failed to start rx dma"); + } - hal_cmu_clock_enable(HAL_CMU_MOD_H_SENSOR_ENG); - hal_cmu_reset_clear(HAL_CMU_MOD_H_SENSOR_ENG); - hal_cmu_clock_enable(HAL_CMU_MOD_O_TIMER2); - hal_cmu_clock_enable(HAL_CMU_MOD_P_TIMER2); - hal_cmu_reset_clear(HAL_CMU_MOD_O_TIMER2); - hal_cmu_reset_clear(HAL_CMU_MOD_P_TIMER2); + hal_cmu_clock_enable(HAL_CMU_MOD_H_SENSOR_ENG); + hal_cmu_reset_clear(HAL_CMU_MOD_H_SENSOR_ENG); + hal_cmu_clock_enable(HAL_CMU_MOD_O_TIMER2); + hal_cmu_clock_enable(HAL_CMU_MOD_P_TIMER2); + hal_cmu_reset_clear(HAL_CMU_MOD_O_TIMER2); + hal_cmu_reset_clear(HAL_CMU_MOD_P_TIMER2); - sensor_eng[0]->SLV0_CONFIG_REG = SLV_I2C_SPI_SEL(cfg->device) | SLV_SLV_DEV_ID(cfg->device_address) | SLV_ENABLE; - if (dma_rx_len) { - //RX LLI = 1 - sensor_eng[0]->GLOBAL_CFG1_REG = SET_BITFIELD(sensor_eng[0]->GLOBAL_CFG1_REG, NUM_OF_RX_LLI0, 1); - } - //TX LLI = 1 - sensor_eng[0]->GLOBAL_CFG3_REG = SET_BITFIELD(sensor_eng[0]->GLOBAL_CFG3_REG, NUM_OF_TX_LLI0, 1); - if (cfg->trigger_type == HAL_SENSOR_ENGINE_TRIGGER_GPIO) { - sensor_eng[0]->SLV0_INTR_MASK = ~(1 << cfg->trigger_gpio); - } + sensor_eng[0]->SLV0_CONFIG_REG = SLV_I2C_SPI_SEL(cfg->device) | + SLV_SLV_DEV_ID(cfg->device_address) | + SLV_ENABLE; + if (dma_rx_len) { + // RX LLI = 1 + sensor_eng[0]->GLOBAL_CFG1_REG = + SET_BITFIELD(sensor_eng[0]->GLOBAL_CFG1_REG, NUM_OF_RX_LLI0, 1); + } + // TX LLI = 1 + sensor_eng[0]->GLOBAL_CFG3_REG = + SET_BITFIELD(sensor_eng[0]->GLOBAL_CFG3_REG, NUM_OF_TX_LLI0, 1); + if (cfg->trigger_type == HAL_SENSOR_ENGINE_TRIGGER_GPIO) { + sensor_eng[0]->SLV0_INTR_MASK = ~(1 << cfg->trigger_gpio); + } - if (cfg->data_to_vad) { - sx_sel = cfg->id; - } else { - sx_sel = GET_BITFIELD(sensor_eng[0]->GLOBAL_CFG0_REG, GBL_CODEC_SX_SEL); - } - sensor_eng[0]->GLOBAL_CFG0_REG = GBL_CODEC_SX_SEL(sx_sel) | GBL_SENSORHUB_EN | - (cfg->trigger_type == HAL_SENSOR_ENGINE_TRIGGER_GPIO ? GBL_TRIGGER_TYPE : 0); + if (cfg->data_to_vad) { + sx_sel = cfg->id; + } else { + sx_sel = GET_BITFIELD(sensor_eng[0]->GLOBAL_CFG0_REG, GBL_CODEC_SX_SEL); + } + sensor_eng[0]->GLOBAL_CFG0_REG = + GBL_CODEC_SX_SEL(sx_sel) | GBL_SENSORHUB_EN | + (cfg->trigger_type == HAL_SENSOR_ENGINE_TRIGGER_GPIO ? GBL_TRIGGER_TYPE + : 0); - if (cfg->trigger_type == HAL_SENSOR_ENGINE_TRIGGER_TIMER) { - hal_sensor_eng_timer_open(US_TO_TICKS(cfg->period_us)); - hal_sensor_eng_timer_start(); - } + if (cfg->trigger_type == HAL_SENSOR_ENGINE_TRIGGER_TIMER) { + hal_sensor_eng_timer_open(US_TO_TICKS(cfg->period_us)); + hal_sensor_eng_timer_start(); + } - hal_sensor_eng_irq_enable(); + hal_sensor_eng_irq_enable(); - return 0; + return 0; } -int hal_sensor_engine_close(enum HAL_SENSOR_ENGINE_ID_T id) -{ - uint32_t cnt; +int hal_sensor_engine_close(enum HAL_SENSOR_ENGINE_ID_T id) { + uint32_t cnt; - hal_sensor_eng_irq_disable(); + hal_sensor_eng_irq_disable(); - hal_sensor_eng_timer_stop(); + hal_sensor_eng_timer_stop(); - sensor_eng[0]->GLOBAL_CFG0_REG &= ~GBL_SENSORHUB_EN; + sensor_eng[0]->GLOBAL_CFG0_REG &= ~GBL_SENSORHUB_EN; - // Wait until sensor engine becomes idle - cnt = 0; - while ((sensor_eng[0]->SENSOR_STATUS & SENSOR_ENG_FSM_MASK) && cnt < 10) { - osDelay(1); - cnt++; - } - if (sensor_eng[0]->SENSOR_STATUS & SENSOR_ENG_FSM_MASK) { - ASSERT(false, "%s: Sensor engine cannot become idle: 0x%08X", __func__, sensor_eng[0]->SENSOR_STATUS); - } + // Wait until sensor engine becomes idle + cnt = 0; + while ((sensor_eng[0]->SENSOR_STATUS & SENSOR_ENG_FSM_MASK) && cnt < 10) { + osDelay(1); + cnt++; + } + if (sensor_eng[0]->SENSOR_STATUS & SENSOR_ENG_FSM_MASK) { + ASSERT(false, "%s: Sensor engine cannot become idle: 0x%08X", __func__, + sensor_eng[0]->SENSOR_STATUS); + } - sensor_eng[0]->SLV0_INTR_MASK = ~0UL; + sensor_eng[0]->SLV0_INTR_MASK = ~0UL; - dma_rx_len = 0; + dma_rx_len = 0; - hal_cmu_reset_set(HAL_CMU_MOD_P_TIMER2); - hal_cmu_reset_set(HAL_CMU_MOD_O_TIMER2); - hal_cmu_clock_disable(HAL_CMU_MOD_P_TIMER2); - hal_cmu_clock_disable(HAL_CMU_MOD_O_TIMER2); - hal_cmu_reset_set(HAL_CMU_MOD_H_SENSOR_ENG); - hal_cmu_clock_disable(HAL_CMU_MOD_H_SENSOR_ENG); + hal_cmu_reset_set(HAL_CMU_MOD_P_TIMER2); + hal_cmu_reset_set(HAL_CMU_MOD_O_TIMER2); + hal_cmu_clock_disable(HAL_CMU_MOD_P_TIMER2); + hal_cmu_clock_disable(HAL_CMU_MOD_O_TIMER2); + hal_cmu_reset_set(HAL_CMU_MOD_H_SENSOR_ENG); + hal_cmu_clock_disable(HAL_CMU_MOD_H_SENSOR_ENG); - return 0; + return 0; } #if 0 @@ -342,4 +351,3 @@ int hal_sensor_eng_external_input_test(void) return 0; } #endif - diff --git a/platform/hal/hal_bootmode.c b/platform/hal/hal_bootmode.c index 24524de..52ffa05 100644 --- a/platform/hal/hal_bootmode.c +++ b/platform/hal/hal_bootmode.c @@ -13,87 +13,80 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "hal_cmu.h" #include "hal_bootmode.h" -#include "hal_location.h" #include "cmsis.h" +#include "hal_cmu.h" +#include "hal_location.h" // BOOTMODE -#define CMU_BOOTMODE_WATCHDOG (1 << 0) -#define CMU_BOOTMODE_GLOBAL (1 << 1) -#define CMU_BOOTMODE_RTC (1 << 2) -#define CMU_BOOTMODE_CHARGER (1 << 3) +#define CMU_BOOTMODE_WATCHDOG (1 << 0) +#define CMU_BOOTMODE_GLOBAL (1 << 1) +#define CMU_BOOTMODE_RTC (1 << 2) +#define CMU_BOOTMODE_CHARGER (1 << 3) static union HAL_HW_BOOTMODE_T BOOT_BSS_LOC hw_bm; -union HAL_HW_BOOTMODE_T hal_hw_bootmode_get(void) -{ - return hw_bm; +union HAL_HW_BOOTMODE_T hal_hw_bootmode_get(void) { + return hw_bm; } -union HAL_HW_BOOTMODE_T hal_rom_hw_bootmode_get(void) -{ - union HAL_HW_BOOTMODE_T bm; - volatile uint32_t *addr; +union HAL_HW_BOOTMODE_T hal_rom_hw_bootmode_get(void) { + union HAL_HW_BOOTMODE_T bm; + volatile uint32_t *addr; - addr = hal_cmu_get_bootmode_addr(); + addr = hal_cmu_get_bootmode_addr(); - bm.reg = *addr & HAL_HW_BOOTMODE_MASK; - return bm; + bm.reg = *addr & HAL_HW_BOOTMODE_MASK; + return bm; } -void BOOT_TEXT_FLASH_LOC hal_hw_bootmode_init(void) -{ - volatile uint32_t *addr; +void BOOT_TEXT_FLASH_LOC hal_hw_bootmode_init(void) { + volatile uint32_t *addr; - addr = hal_cmu_get_bootmode_addr(); + addr = hal_cmu_get_bootmode_addr(); - hw_bm.reg = *addr & HAL_HW_BOOTMODE_MASK; + hw_bm.reg = *addr & HAL_HW_BOOTMODE_MASK; #if defined(CHIP_BEST3001) || defined(CHIP_BEST3005) - *addr = (*addr | HAL_HW_BOOTMODE_MASK) >> 2; + *addr = (*addr | HAL_HW_BOOTMODE_MASK) >> 2; #else - *addr = *addr | HAL_HW_BOOTMODE_MASK; + *addr = *addr | HAL_HW_BOOTMODE_MASK; #endif } -uint32_t hal_sw_bootmode_get(void) -{ - volatile uint32_t *addr; +uint32_t hal_sw_bootmode_get(void) { + volatile uint32_t *addr; - addr = hal_cmu_get_bootmode_addr(); + addr = hal_cmu_get_bootmode_addr(); - return *addr & HAL_SW_BOOTMODE_MASK; + return *addr & HAL_SW_BOOTMODE_MASK; } -void hal_sw_bootmode_set(uint32_t bm) -{ - uint32_t lock; - volatile uint32_t *addr; +void hal_sw_bootmode_set(uint32_t bm) { + uint32_t lock; + volatile uint32_t *addr; - addr = hal_cmu_get_bootmode_addr(); + addr = hal_cmu_get_bootmode_addr(); - lock = int_lock(); + lock = int_lock(); #if defined(CHIP_BEST3001) || defined(CHIP_BEST3005) - *addr = ((*addr | bm) & HAL_SW_BOOTMODE_MASK) >> 2; + *addr = ((*addr | bm) & HAL_SW_BOOTMODE_MASK) >> 2; #else - *addr = (*addr | bm) & HAL_SW_BOOTMODE_MASK; + *addr = (*addr | bm) & HAL_SW_BOOTMODE_MASK; #endif - int_unlock(lock); + int_unlock(lock); } -void hal_sw_bootmode_clear(uint32_t bm) -{ - uint32_t lock; - volatile uint32_t *addr; +void hal_sw_bootmode_clear(uint32_t bm) { + uint32_t lock; + volatile uint32_t *addr; - addr = hal_cmu_get_bootmode_addr(); + addr = hal_cmu_get_bootmode_addr(); - lock = int_lock(); + lock = int_lock(); #if defined(CHIP_BEST3001) || defined(CHIP_BEST3005) - *addr = ((*addr & ~bm) & HAL_SW_BOOTMODE_MASK) >> 2; + *addr = ((*addr & ~bm) & HAL_SW_BOOTMODE_MASK) >> 2; #else - *addr = (*addr & ~bm) & HAL_SW_BOOTMODE_MASK; + *addr = (*addr & ~bm) & HAL_SW_BOOTMODE_MASK; #endif - int_unlock(lock); + int_unlock(lock); } - diff --git a/platform/hal/hal_btdump.c b/platform/hal/hal_btdump.c index 6d869d8..05b62e0 100644 --- a/platform/hal/hal_btdump.c +++ b/platform/hal/hal_btdump.c @@ -17,67 +17,61 @@ #ifdef BTDUMP_BASE -#include "hal_cmu.h" #include "hal_btdump.h" +#include "hal_cmu.h" -#define BTDUMP_DMA_CTL_REG_OFFSET 0x30 -#define BTDUMP_DMA_CTL_MASK 0xFFFFFFFE -#define BTDUMP_DEVICE_EN_MASK 0xFFFFFFFE -#define BTDUMP_FM_PSD_MASK 0xFFFFFFDF -#define BTDUMP_DEVICE_EN (1 << 0) -#define BTDUMP_DMA_CTL_EN (1 << 0) -#define BTDUMP_FM_PSD_EN (1 << 5) -#define BTDUMP_DMA_CTL_DISABLE (0 << 0) -#define BTDUMP_DEVICE_DISABLE (0 << 0) +#define BTDUMP_DMA_CTL_REG_OFFSET 0x30 +#define BTDUMP_DMA_CTL_MASK 0xFFFFFFFE +#define BTDUMP_DEVICE_EN_MASK 0xFFFFFFFE +#define BTDUMP_FM_PSD_MASK 0xFFFFFFDF +#define BTDUMP_DEVICE_EN (1 << 0) +#define BTDUMP_DMA_CTL_EN (1 << 0) +#define BTDUMP_FM_PSD_EN (1 << 5) +#define BTDUMP_DMA_CTL_DISABLE (0 << 0) +#define BTDUMP_DEVICE_DISABLE (0 << 0) -#define btdump_read32(b,a) \ - (*(volatile uint32_t *)(b+a)) +#define btdump_read32(b, a) (*(volatile uint32_t *)(b + a)) -#define btdump_write32(v,b,a) \ - ((*(volatile uint32_t *)(b+a)) = v) +#define btdump_write32(v, b, a) ((*(volatile uint32_t *)(b + a)) = v) -void hal_btdump_clk_enable(void) -{ - hal_cmu_clock_enable(HAL_CMU_MOD_H_BT_DUMP); - hal_cmu_reset_clear(HAL_CMU_MOD_H_BT_DUMP); +void hal_btdump_clk_enable(void) { + hal_cmu_clock_enable(HAL_CMU_MOD_H_BT_DUMP); + hal_cmu_reset_clear(HAL_CMU_MOD_H_BT_DUMP); } -void hal_btdump_clk_disable(void) -{ - hal_cmu_reset_set(HAL_CMU_MOD_H_BT_DUMP); - hal_cmu_clock_disable(HAL_CMU_MOD_H_BT_DUMP); +void hal_btdump_clk_disable(void) { + hal_cmu_reset_set(HAL_CMU_MOD_H_BT_DUMP); + hal_cmu_clock_disable(HAL_CMU_MOD_H_BT_DUMP); } -void hal_btdump_enable(void) -{ - uint32_t val; +void hal_btdump_enable(void) { + uint32_t val; - val = btdump_read32(BTDUMP_BASE,BTDUMP_DMA_CTL_REG_OFFSET); - val &= BTDUMP_DMA_CTL_MASK; - val |= BTDUMP_DMA_CTL_EN; - btdump_write32(val,BTDUMP_BASE,BTDUMP_DMA_CTL_REG_OFFSET); + val = btdump_read32(BTDUMP_BASE, BTDUMP_DMA_CTL_REG_OFFSET); + val &= BTDUMP_DMA_CTL_MASK; + val |= BTDUMP_DMA_CTL_EN; + btdump_write32(val, BTDUMP_BASE, BTDUMP_DMA_CTL_REG_OFFSET); - val = btdump_read32(BTDUMP_BASE,0); - val &= BTDUMP_DEVICE_EN_MASK; - val |= BTDUMP_DEVICE_EN; - val &= BTDUMP_FM_PSD_MASK; - val |= BTDUMP_FM_PSD_EN; - btdump_write32(val,BTDUMP_BASE,0); + val = btdump_read32(BTDUMP_BASE, 0); + val &= BTDUMP_DEVICE_EN_MASK; + val |= BTDUMP_DEVICE_EN; + val &= BTDUMP_FM_PSD_MASK; + val |= BTDUMP_FM_PSD_EN; + btdump_write32(val, BTDUMP_BASE, 0); } -void hal_btdump_disable(void) -{ - uint32_t val; +void hal_btdump_disable(void) { + uint32_t val; - val = btdump_read32(BTDUMP_BASE,BTDUMP_DMA_CTL_REG_OFFSET); - val &= BTDUMP_DMA_CTL_MASK; - val |= BTDUMP_DMA_CTL_DISABLE; - btdump_write32(val,BTDUMP_BASE,BTDUMP_DMA_CTL_REG_OFFSET); + val = btdump_read32(BTDUMP_BASE, BTDUMP_DMA_CTL_REG_OFFSET); + val &= BTDUMP_DMA_CTL_MASK; + val |= BTDUMP_DMA_CTL_DISABLE; + btdump_write32(val, BTDUMP_BASE, BTDUMP_DMA_CTL_REG_OFFSET); - val = btdump_read32(BTDUMP_BASE,0); - val &= BTDUMP_DEVICE_EN_MASK; - val |= BTDUMP_DEVICE_DISABLE; - btdump_write32(val,BTDUMP_BASE,0); + val = btdump_read32(BTDUMP_BASE, 0); + val &= BTDUMP_DEVICE_EN_MASK; + val |= BTDUMP_DEVICE_DISABLE; + btdump_write32(val, BTDUMP_BASE, 0); } #endif \ No newline at end of file diff --git a/platform/hal/hal_btpcm.c b/platform/hal/hal_btpcm.c index cdc606e..96ca3a6 100644 --- a/platform/hal/hal_btpcm.c +++ b/platform/hal/hal_btpcm.c @@ -17,14 +17,14 @@ #ifdef BTPCM_BASE +#include "hal_btpcm.h" +#include "hal_btpcmip.h" +#include "hal_cmu.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" #include "plat_types.h" #include "reg_btpcmip.h" -#include "hal_btpcmip.h" -#include "hal_btpcm.h" -#include "hal_uart.h" -#include "hal_trace.h" -#include "hal_timer.h" -#include "hal_cmu.h" //#define BTPCM_CLOCK_SOURCE 240000000 #define BTPCM_CLOCK_SOURCE 22579200 @@ -37,175 +37,167 @@ //#define HAL_BTPCM_TX_FIFO_TRIGGER_LEVEL (BTPCMIP_FIFO_DEPTH/2) //#define HAL_BTPCM_RX_FIFO_TRIGGER_LEVEL (BTPCMIP_FIFO_DEPTH/2) -#define HAL_BTPCM_TX_FIFO_TRIGGER_LEVEL (1) -#define HAL_BTPCM_RX_FIFO_TRIGGER_LEVEL (0) +#define HAL_BTPCM_TX_FIFO_TRIGGER_LEVEL (1) +#define HAL_BTPCM_RX_FIFO_TRIGGER_LEVEL (0) #define HAL_BTPCM_YES 1 #define HAL_BTPCM_NO 0 -static const char * const invalid_id = "Invalid BTPCM ID: %d\n"; -//static const char * const invalid_ch = "Invalid BTPCM CH: %d\n"; +static const char *const invalid_id = "Invalid BTPCM ID: %d\n"; +// static const char * const invalid_ch = "Invalid BTPCM CH: %d\n"; static bool btpcm_opened[HAL_BTPCM_ID_NUM][AUD_STREAM_NUM]; -static inline POSSIBLY_UNUSED unsigned char reverse(unsigned char in) -{ - uint8_t out = 0; - uint32_t i = 0; - for (i = 0; i < 8; ++i) { - if((1<= 2)) || (defined(CHIP_HAS_PSRAMUHS) && defined(PSRAMUHS_ENABLE)) - uint32_t val; +#if (defined(CHIP_HAS_PSRAM) && defined(PSRAM_ENABLE) && \ + defined(CHIP_PSRAM_CTRL_VER) && (CHIP_PSRAM_CTRL_VER >= 2)) || \ + (defined(CHIP_HAS_PSRAMUHS) && defined(PSRAMUHS_ENABLE)) + uint32_t val; - val = cacheip_read32(reg_base, WRITEBUFFER_ENABLE_REG_OFFSET); - if (v) { - val |= WRITE_BACK_EN; - } else { - val &= ~WRITE_BACK_EN; - } - cacheip_write32(val, reg_base, WRITEBUFFER_ENABLE_REG_OFFSET); + val = cacheip_read32(reg_base, WRITEBUFFER_ENABLE_REG_OFFSET); + if (v) { + val |= WRITE_BACK_EN; + } else { + val &= ~WRITE_BACK_EN; + } + cacheip_write32(val, reg_base, WRITEBUFFER_ENABLE_REG_OFFSET); #endif #endif } -__STATIC_FORCEINLINE void cacheip_flush_writebuffer(uint32_t reg_base) -{ - cacheip_write32(1, reg_base, WRITEBUFFER_FLUSH_REG_OFFSET); +__STATIC_FORCEINLINE void cacheip_flush_writebuffer(uint32_t reg_base) { + cacheip_write32(1, reg_base, WRITEBUFFER_FLUSH_REG_OFFSET); } -__STATIC_FORCEINLINE void cacheip_set_invalidate_address(uint32_t reg_base, uint32_t v) -{ - cacheip_write32(v, reg_base, INVALIDATE_ADDRESS_REG_OFFSET); +__STATIC_FORCEINLINE void cacheip_set_invalidate_address(uint32_t reg_base, + uint32_t v) { + cacheip_write32(v, reg_base, INVALIDATE_ADDRESS_REG_OFFSET); } -__STATIC_FORCEINLINE void cacheip_trigger_invalidate(uint32_t reg_base) -{ - cacheip_write32(1, reg_base, INVALIDATE_SET_CMD_REG_OFFSET); +__STATIC_FORCEINLINE void cacheip_trigger_invalidate(uint32_t reg_base) { + cacheip_write32(1, reg_base, INVALIDATE_SET_CMD_REG_OFFSET); } -__STATIC_FORCEINLINE void cacheip_trigger_sync(uint32_t reg_base) -{ - cacheip_write32(1, reg_base, SYNC_CMD_REG_OFFSET); +__STATIC_FORCEINLINE void cacheip_trigger_sync(uint32_t reg_base) { + cacheip_write32(1, reg_base, SYNC_CMD_REG_OFFSET); } /* cache controller end */ /* hal api */ -__STATIC_FORCEINLINE uint32_t _cache_get_reg_base(enum HAL_CACHE_ID_T id) -{ - uint32_t base; +__STATIC_FORCEINLINE uint32_t _cache_get_reg_base(enum HAL_CACHE_ID_T id) { + uint32_t base; - if (id == HAL_CACHE_ID_I_CACHE) { - base = ICACHE_CTRL_BASE; - } else if (id == HAL_CACHE_ID_D_CACHE) { + if (id == HAL_CACHE_ID_I_CACHE) { + base = ICACHE_CTRL_BASE; + } else if (id == HAL_CACHE_ID_D_CACHE) { #ifdef DCACHE_CTRL_BASE - base = DCACHE_CTRL_BASE; + base = DCACHE_CTRL_BASE; #else - base = 0; + base = 0; #endif - } else { - base = 0; - } + } else { + base = 0; + } - return base; + return base; } -uint8_t BOOT_TEXT_FLASH_LOC hal_cache_enable(enum HAL_CACHE_ID_T id) -{ - uint32_t reg_base = 0; - - reg_base = _cache_get_reg_base(id); - if (reg_base == 0) { - return 0; - } - - cacheip_init_cache(reg_base); - cacheip_enable_cache(reg_base, HAL_CACHE_YES); +uint8_t BOOT_TEXT_FLASH_LOC hal_cache_enable(enum HAL_CACHE_ID_T id) { + uint32_t reg_base = 0; + reg_base = _cache_get_reg_base(id); + if (reg_base == 0) { return 0; -} -uint8_t SRAM_TEXT_LOC hal_cache_disable(enum HAL_CACHE_ID_T id) -{ - uint32_t reg_base = 0; + } - reg_base = _cache_get_reg_base(id); - if (reg_base == 0) { - return 0; - } + cacheip_init_cache(reg_base); + cacheip_enable_cache(reg_base, HAL_CACHE_YES); + + return 0; +} +uint8_t SRAM_TEXT_LOC hal_cache_disable(enum HAL_CACHE_ID_T id) { + uint32_t reg_base = 0; + + reg_base = _cache_get_reg_base(id); + if (reg_base == 0) { + return 0; + } #if !(defined(ROM_BUILD) || defined(PROGRAMMER)) #if (CHIP_CACHE_VER >= 2) - uint32_t val; + uint32_t val; - do { - val = cacheip_read32(reg_base, STATUS_REG_OFFSET); - } while (val & STATUS_FETCHING); + do { + val = cacheip_read32(reg_base, STATUS_REG_OFFSET); + } while (val & STATUS_FETCHING); #else - uint32_t time; + uint32_t time; - time = hal_sys_timer_get(); - while (hal_norflash_busy() && (hal_sys_timer_get() - time) < MS_TO_TICKS(2)); - // Delay for at least 8 cycles till the cache becomes idle - for (int delay = 0; delay < 8; delay++) { - asm volatile("nop"); - } + time = hal_sys_timer_get(); + while (hal_norflash_busy() && (hal_sys_timer_get() - time) < MS_TO_TICKS(2)) + ; + // Delay for at least 8 cycles till the cache becomes idle + for (int delay = 0; delay < 8; delay++) { + asm volatile("nop"); + } #endif #endif - cacheip_enable_cache(reg_base, HAL_CACHE_NO); + cacheip_enable_cache(reg_base, HAL_CACHE_NO); - return 0; + return 0; } -uint8_t BOOT_TEXT_FLASH_LOC hal_cache_writebuffer_enable(enum HAL_CACHE_ID_T id) -{ - uint32_t reg_base = 0; - - reg_base = _cache_get_reg_base(id); - if (reg_base == 0) { - return 0; - } - - cacheip_enable_writebuffer(reg_base, HAL_CACHE_YES); +uint8_t BOOT_TEXT_FLASH_LOC +hal_cache_writebuffer_enable(enum HAL_CACHE_ID_T id) { + uint32_t reg_base = 0; + reg_base = _cache_get_reg_base(id); + if (reg_base == 0) { return 0; + } + + cacheip_enable_writebuffer(reg_base, HAL_CACHE_YES); + + return 0; } -uint8_t hal_cache_writebuffer_disable(enum HAL_CACHE_ID_T id) -{ - uint32_t reg_base = 0; - - reg_base = _cache_get_reg_base(id); - if (reg_base == 0) { - return 0; - } - - cacheip_enable_writebuffer(reg_base, HAL_CACHE_NO); +uint8_t hal_cache_writebuffer_disable(enum HAL_CACHE_ID_T id) { + uint32_t reg_base = 0; + reg_base = _cache_get_reg_base(id); + if (reg_base == 0) { return 0; + } + + cacheip_enable_writebuffer(reg_base, HAL_CACHE_NO); + + return 0; } -uint8_t hal_cache_writebuffer_flush(enum HAL_CACHE_ID_T id) -{ - uint32_t reg_base = 0; - - reg_base = _cache_get_reg_base(id); - if (reg_base == 0) { - return 0; - } - - cacheip_flush_writebuffer(reg_base); +uint8_t hal_cache_writebuffer_flush(enum HAL_CACHE_ID_T id) { + uint32_t reg_base = 0; + reg_base = _cache_get_reg_base(id); + if (reg_base == 0) { return 0; + } + + cacheip_flush_writebuffer(reg_base); + + return 0; } -uint8_t BOOT_TEXT_FLASH_LOC hal_cache_writeback_enable(enum HAL_CACHE_ID_T id) -{ - uint32_t reg_base = 0; - - reg_base = _cache_get_reg_base(id); - if (reg_base == 0) { - return 0; - } - - cacheip_enable_writeback(reg_base, HAL_CACHE_YES); +uint8_t BOOT_TEXT_FLASH_LOC hal_cache_writeback_enable(enum HAL_CACHE_ID_T id) { + uint32_t reg_base = 0; + reg_base = _cache_get_reg_base(id); + if (reg_base == 0) { return 0; + } + + cacheip_enable_writeback(reg_base, HAL_CACHE_YES); + + return 0; } -uint8_t hal_cache_writeback_disable(enum HAL_CACHE_ID_T id) -{ - uint32_t reg_base = 0; - - reg_base = _cache_get_reg_base(id); - if (reg_base == 0) { - return 0; - } - - cacheip_enable_writeback(reg_base, HAL_CACHE_NO); +uint8_t hal_cache_writeback_disable(enum HAL_CACHE_ID_T id) { + uint32_t reg_base = 0; + reg_base = _cache_get_reg_base(id); + if (reg_base == 0) { return 0; + } + + cacheip_enable_writeback(reg_base, HAL_CACHE_NO); + + return 0; } // Wrap is enabled during flash init -uint8_t BOOT_TEXT_SRAM_LOC hal_cache_wrap_enable(enum HAL_CACHE_ID_T id) -{ - uint32_t reg_base = 0; - - reg_base = _cache_get_reg_base(id); - if (reg_base == 0) { - return 0; - } - - cacheip_enable_wrap(reg_base, HAL_CACHE_YES); +uint8_t BOOT_TEXT_SRAM_LOC hal_cache_wrap_enable(enum HAL_CACHE_ID_T id) { + uint32_t reg_base = 0; + reg_base = _cache_get_reg_base(id); + if (reg_base == 0) { return 0; + } + + cacheip_enable_wrap(reg_base, HAL_CACHE_YES); + + return 0; } -uint8_t hal_cache_wrap_disable(enum HAL_CACHE_ID_T id) -{ - uint32_t reg_base = 0; - - reg_base = _cache_get_reg_base(id); - if (reg_base == 0) { - return 0; - } - - cacheip_enable_wrap(reg_base, HAL_CACHE_NO); +uint8_t hal_cache_wrap_disable(enum HAL_CACHE_ID_T id) { + uint32_t reg_base = 0; + reg_base = _cache_get_reg_base(id); + if (reg_base == 0) { return 0; + } + + cacheip_enable_wrap(reg_base, HAL_CACHE_NO); + + return 0; } // Flash timing calibration might need to invalidate cache -uint8_t BOOT_TEXT_SRAM_LOC hal_cache_invalidate(enum HAL_CACHE_ID_T id, uint32_t start_address, uint32_t len) -{ - uint32_t reg_base; - uint32_t end_address; - uint32_t lock; +uint8_t BOOT_TEXT_SRAM_LOC hal_cache_invalidate(enum HAL_CACHE_ID_T id, + uint32_t start_address, + uint32_t len) { + uint32_t reg_base; + uint32_t end_address; + uint32_t lock; #ifndef DCACHE_CTRL_BASE - if (id == HAL_CACHE_ID_D_CACHE) { - id = HAL_CACHE_ID_I_CACHE; - } + if (id == HAL_CACHE_ID_D_CACHE) { + id = HAL_CACHE_ID_I_CACHE; + } #endif - reg_base = _cache_get_reg_base(id); - if (reg_base == 0) { - return 0; - } + reg_base = _cache_get_reg_base(id); + if (reg_base == 0) { + return 0; + } - lock = int_lock_global(); + lock = int_lock_global(); #if defined(CHIP_BEST2300) || defined(CHIP_BEST1400) - uint32_t time; + uint32_t time; - time = hal_sys_timer_get(); - while (hal_norflash_busy() && (hal_sys_timer_get() - time) < MS_TO_TICKS(2)); - // Delay for at least 8 cycles till the cache becomes idle - for (int delay = 0; delay < 8; delay++) { - asm volatile("nop"); - } + time = hal_sys_timer_get(); + while (hal_norflash_busy() && (hal_sys_timer_get() - time) < MS_TO_TICKS(2)) + ; + // Delay for at least 8 cycles till the cache becomes idle + for (int delay = 0; delay < 8; delay++) { + asm volatile("nop"); + } #endif - if (len >= CACHE_SIZE / 2) { - cacheip_init_cache(reg_base); - cacheip_init_cache(reg_base); - } else { - end_address = start_address + len; - start_address &= (~(CACHE_LINE_SIZE-1)); - while (start_address < end_address) { - cacheip_set_invalidate_address(reg_base, start_address); - cacheip_trigger_invalidate(reg_base); - cacheip_trigger_invalidate(reg_base); - start_address += CACHE_LINE_SIZE; - } + if (len >= CACHE_SIZE / 2) { + cacheip_init_cache(reg_base); + cacheip_init_cache(reg_base); + } else { + end_address = start_address + len; + start_address &= (~(CACHE_LINE_SIZE - 1)); + while (start_address < end_address) { + cacheip_set_invalidate_address(reg_base, start_address); + cacheip_trigger_invalidate(reg_base); + cacheip_trigger_invalidate(reg_base); + start_address += CACHE_LINE_SIZE; } + } - int_unlock_global(lock); + int_unlock_global(lock); - return 0; + return 0; } -uint8_t hal_cache_invalidate_all(enum HAL_CACHE_ID_T id) -{ - uint32_t reg_base = 0; +uint8_t hal_cache_invalidate_all(enum HAL_CACHE_ID_T id) { + uint32_t reg_base = 0; - reg_base = _cache_get_reg_base(id); - if (reg_base == 0) { - return 0; - } - - //warning BEST1501 may change this reg offset to 0x38 - cacheip_write32(1, reg_base, CACHE_INI_CMD_REG_OFFSET); - cacheip_write32(1, reg_base, CACHE_INI_CMD_REG_OFFSET); + reg_base = _cache_get_reg_base(id); + if (reg_base == 0) { return 0; + } + + // warning BEST1501 may change this reg offset to 0x38 + cacheip_write32(1, reg_base, CACHE_INI_CMD_REG_OFFSET); + cacheip_write32(1, reg_base, CACHE_INI_CMD_REG_OFFSET); + return 0; } -uint8_t hal_cache_sync(enum HAL_CACHE_ID_T id) -{ - uint32_t reg_base = 0; - - reg_base = _cache_get_reg_base(id); - if (reg_base == 0) { - return 0; - } - - cacheip_trigger_sync(reg_base); +uint8_t hal_cache_sync(enum HAL_CACHE_ID_T id) { + uint32_t reg_base = 0; + reg_base = _cache_get_reg_base(id); + if (reg_base == 0) { return 0; + } + + cacheip_trigger_sync(reg_base); + + return 0; } #ifdef CHIP_HAS_CP -__STATIC_FORCEINLINE uint32_t _cachecp_get_reg_base(enum HAL_CACHE_ID_T id) -{ - uint32_t base; +__STATIC_FORCEINLINE uint32_t _cachecp_get_reg_base(enum HAL_CACHE_ID_T id) { + uint32_t base; - if (id == HAL_CACHE_ID_I_CACHE) { - base = ICACHECP_CTRL_BASE; - } else if (id == HAL_CACHE_ID_D_CACHE) { + if (id == HAL_CACHE_ID_I_CACHE) { + base = ICACHECP_CTRL_BASE; + } else if (id == HAL_CACHE_ID_D_CACHE) { #ifdef DCACHECP_CTRL_BASE - base = DCACHECP_CTRL_BASE; + base = DCACHECP_CTRL_BASE; #else - base = 0; + base = 0; #endif - } else { - base = 0; - } + } else { + base = 0; + } - return base; + return base; } -uint8_t hal_cachecp_enable(enum HAL_CACHE_ID_T id) -{ - uint32_t reg_base = 0; - uint32_t main_cache_reg_base; - enum HAL_CMU_MOD_ID_T mod; - - reg_base = _cachecp_get_reg_base(id); - if (reg_base == 0) { - return 0; - } - - if (id == HAL_CACHE_ID_D_CACHE) { - mod = HAL_CMU_H_DCACHECP; - } else { - mod = HAL_CMU_H_ICACHECP; - } - hal_cmu_clock_enable(mod); - hal_cmu_reset_clear(mod); - - cacheip_init_cache(reg_base); - cacheip_enable_cache(reg_base, HAL_CACHE_YES); - // Init wrap option - main_cache_reg_base = _cache_get_reg_base(id); - if (main_cache_reg_base == 0) { - return 0; - } - cacheip_enable_wrap(reg_base, cacheip_wrap_enabled(main_cache_reg_base)); +uint8_t hal_cachecp_enable(enum HAL_CACHE_ID_T id) { + uint32_t reg_base = 0; + uint32_t main_cache_reg_base; + enum HAL_CMU_MOD_ID_T mod; + reg_base = _cachecp_get_reg_base(id); + if (reg_base == 0) { return 0; -} -uint8_t CP_TEXT_SRAM_LOC hal_cachecp_disable(enum HAL_CACHE_ID_T id) -{ - uint32_t reg_base = 0; - enum HAL_CMU_MOD_ID_T mod; + } - reg_base = _cachecp_get_reg_base(id); - if (reg_base == 0) { - return 0; - } + if (id == HAL_CACHE_ID_D_CACHE) { + mod = HAL_CMU_H_DCACHECP; + } else { + mod = HAL_CMU_H_ICACHECP; + } + hal_cmu_clock_enable(mod); + hal_cmu_reset_clear(mod); + + cacheip_init_cache(reg_base); + cacheip_enable_cache(reg_base, HAL_CACHE_YES); + // Init wrap option + main_cache_reg_base = _cache_get_reg_base(id); + if (main_cache_reg_base == 0) { + return 0; + } + cacheip_enable_wrap(reg_base, cacheip_wrap_enabled(main_cache_reg_base)); + + return 0; +} +uint8_t CP_TEXT_SRAM_LOC hal_cachecp_disable(enum HAL_CACHE_ID_T id) { + uint32_t reg_base = 0; + enum HAL_CMU_MOD_ID_T mod; + + reg_base = _cachecp_get_reg_base(id); + if (reg_base == 0) { + return 0; + } #if !(defined(ROM_BUILD) || defined(PROGRAMMER)) - uint32_t val; + uint32_t val; - do { - val = cacheip_read32(reg_base, STATUS_REG_OFFSET); - } while (val & STATUS_FETCHING); + do { + val = cacheip_read32(reg_base, STATUS_REG_OFFSET); + } while (val & STATUS_FETCHING); #endif - cacheip_enable_cache(reg_base, HAL_CACHE_NO); + cacheip_enable_cache(reg_base, HAL_CACHE_NO); - if (id == HAL_CACHE_ID_D_CACHE) { - mod = HAL_CMU_H_DCACHECP; - } else { - mod = HAL_CMU_H_ICACHECP; - } - hal_cmu_reset_set(mod); - hal_cmu_clock_disable(mod); + if (id == HAL_CACHE_ID_D_CACHE) { + mod = HAL_CMU_H_DCACHECP; + } else { + mod = HAL_CMU_H_ICACHECP; + } + hal_cmu_reset_set(mod); + hal_cmu_clock_disable(mod); - return 0; + return 0; } -uint8_t hal_cachecp_writebuffer_enable(enum HAL_CACHE_ID_T id) -{ - uint32_t reg_base = 0; - - reg_base = _cachecp_get_reg_base(id); - if (reg_base == 0) { - return 0; - } - - cacheip_enable_writebuffer(reg_base, HAL_CACHE_YES); +uint8_t hal_cachecp_writebuffer_enable(enum HAL_CACHE_ID_T id) { + uint32_t reg_base = 0; + reg_base = _cachecp_get_reg_base(id); + if (reg_base == 0) { return 0; + } + + cacheip_enable_writebuffer(reg_base, HAL_CACHE_YES); + + return 0; } -uint8_t hal_cachecp_writebuffer_disable(enum HAL_CACHE_ID_T id) -{ - uint32_t reg_base = 0; - - reg_base = _cachecp_get_reg_base(id); - if (reg_base == 0) { - return 0; - } - - cacheip_enable_writebuffer(reg_base, HAL_CACHE_NO); +uint8_t hal_cachecp_writebuffer_disable(enum HAL_CACHE_ID_T id) { + uint32_t reg_base = 0; + reg_base = _cachecp_get_reg_base(id); + if (reg_base == 0) { return 0; + } + + cacheip_enable_writebuffer(reg_base, HAL_CACHE_NO); + + return 0; } -uint8_t hal_cachecp_writebuffer_flush(enum HAL_CACHE_ID_T id) -{ - uint32_t reg_base = 0; - - reg_base = _cachecp_get_reg_base(id); - if (reg_base == 0) { - return 0; - } - - cacheip_flush_writebuffer(reg_base); +uint8_t hal_cachecp_writebuffer_flush(enum HAL_CACHE_ID_T id) { + uint32_t reg_base = 0; + reg_base = _cachecp_get_reg_base(id); + if (reg_base == 0) { return 0; + } + + cacheip_flush_writebuffer(reg_base); + + return 0; } -uint8_t hal_cachecp_writeback_enable(enum HAL_CACHE_ID_T id) -{ - uint32_t reg_base = 0; - - reg_base = _cachecp_get_reg_base(id); - if (reg_base == 0) { - return 0; - } - - cacheip_enable_writeback(reg_base, HAL_CACHE_YES); +uint8_t hal_cachecp_writeback_enable(enum HAL_CACHE_ID_T id) { + uint32_t reg_base = 0; + reg_base = _cachecp_get_reg_base(id); + if (reg_base == 0) { return 0; + } + + cacheip_enable_writeback(reg_base, HAL_CACHE_YES); + + return 0; } -uint8_t hal_cachecp_writeback_disable(enum HAL_CACHE_ID_T id) -{ - uint32_t reg_base = 0; - - reg_base = _cachecp_get_reg_base(id); - if (reg_base == 0) { - return 0; - } - - cacheip_enable_writeback(reg_base, HAL_CACHE_NO); +uint8_t hal_cachecp_writeback_disable(enum HAL_CACHE_ID_T id) { + uint32_t reg_base = 0; + reg_base = _cachecp_get_reg_base(id); + if (reg_base == 0) { return 0; + } + + cacheip_enable_writeback(reg_base, HAL_CACHE_NO); + + return 0; } -uint8_t CP_TEXT_SRAM_LOC hal_cachecp_invalidate(enum HAL_CACHE_ID_T id, uint32_t start_address, uint32_t len) -{ - uint32_t reg_base; - uint32_t end_address; +uint8_t CP_TEXT_SRAM_LOC hal_cachecp_invalidate(enum HAL_CACHE_ID_T id, + uint32_t start_address, + uint32_t len) { + uint32_t reg_base; + uint32_t end_address; #ifndef DCACHECP_CTRL_BASE - if (id == HAL_CACHE_ID_D_CACHE) { - id = HAL_CACHE_ID_I_CACHE; - } + if (id == HAL_CACHE_ID_D_CACHE) { + id = HAL_CACHE_ID_I_CACHE; + } #endif - reg_base = _cachecp_get_reg_base(id); - if (reg_base == 0) { - return 0; - } - - if (len >= CACHE_SIZE / 2) { - cacheip_init_cache(reg_base); - cacheip_init_cache(reg_base); - } else { - end_address = start_address + len; - start_address &= (~(CACHE_LINE_SIZE-1)); - while (start_address < end_address) { - cacheip_set_invalidate_address(reg_base, start_address); - cacheip_trigger_invalidate(reg_base); - cacheip_trigger_invalidate(reg_base); - start_address += CACHE_LINE_SIZE; - } - } - + reg_base = _cachecp_get_reg_base(id); + if (reg_base == 0) { return 0; + } + + if (len >= CACHE_SIZE / 2) { + cacheip_init_cache(reg_base); + cacheip_init_cache(reg_base); + } else { + end_address = start_address + len; + start_address &= (~(CACHE_LINE_SIZE - 1)); + while (start_address < end_address) { + cacheip_set_invalidate_address(reg_base, start_address); + cacheip_trigger_invalidate(reg_base); + cacheip_trigger_invalidate(reg_base); + start_address += CACHE_LINE_SIZE; + } + } + + return 0; } -uint8_t hal_cachecp_sync(enum HAL_CACHE_ID_T id) -{ - uint32_t reg_base = 0; - - reg_base = _cachecp_get_reg_base(id); - if (reg_base == 0) { - return 0; - } - - cacheip_trigger_sync(reg_base); +uint8_t hal_cachecp_sync(enum HAL_CACHE_ID_T id) { + uint32_t reg_base = 0; + reg_base = _cachecp_get_reg_base(id); + if (reg_base == 0) { return 0; + } + + cacheip_trigger_sync(reg_base); + + return 0; } #endif - diff --git a/platform/hal/hal_chipid.c b/platform/hal/hal_chipid.c index b0bc820..411011c 100644 --- a/platform/hal/hal_chipid.c +++ b/platform/hal/hal_chipid.c @@ -18,33 +18,29 @@ enum HAL_CHIP_METAL_ID_T BOOT_BSS_LOC metal_id; -uint32_t WEAK BOOT_TEXT_FLASH_LOC read_hw_metal_id(void) -{ - return HAL_CHIP_METAL_ID_0; +uint32_t WEAK BOOT_TEXT_FLASH_LOC read_hw_metal_id(void) { + return HAL_CHIP_METAL_ID_0; } -void BOOT_TEXT_FLASH_LOC hal_chipid_init(void) -{ - metal_id = read_hw_metal_id(); +void BOOT_TEXT_FLASH_LOC hal_chipid_init(void) { + metal_id = read_hw_metal_id(); } -enum HAL_CHIP_METAL_ID_T BOOT_TEXT_SRAM_LOC hal_get_chip_metal_id(void) -{ +enum HAL_CHIP_METAL_ID_T BOOT_TEXT_SRAM_LOC hal_get_chip_metal_id(void) { #ifdef FPGA - return HAL_CHIP_METAL_ID_15; + return HAL_CHIP_METAL_ID_15; #else - return metal_id; + return metal_id; #endif } -enum HAL_BT_CHIP_SERIES_T hal_get_bt_chip_series(void) -{ +enum HAL_BT_CHIP_SERIES_T hal_get_bt_chip_series(void) { #if (defined(CHIP_BEST1000)) || defined(CHIP_BEST2000) - return HAL_BT_CHIP_SERIES_2000; + return HAL_BT_CHIP_SERIES_2000; #elif defined(CHIP_BEST2500) - return HAL_BT_CHIP_SERIES_2500; -#else// (defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST1400) || defined(CHIP_BEST1402)) - return HAL_BT_CHIP_SERIES_2300; + return HAL_BT_CHIP_SERIES_2500; +#else // (defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || + // defined(CHIP_BEST1400) || defined(CHIP_BEST1402)) + return HAL_BT_CHIP_SERIES_2300; #endif } - diff --git a/platform/hal/hal_cmd.c b/platform/hal/hal_cmd.c index 95c543e..b83b6eb 100644 --- a/platform/hal/hal_cmd.c +++ b/platform/hal/hal_cmd.c @@ -13,12 +13,12 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "hal_iomux.h" #include "hal_cmd.h" -#include "hal_uart.h" -#include "hal_trace.h" -#include "string.h" +#include "hal_iomux.h" #include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "string.h" /* |-----|-------|----------------------------------| @@ -38,11 +38,11 @@ |-----|-------|----------------------------------| */ -#define HAL_CMD_PREFIX_SIZE 4 -#define HAL_CMD_CRC_SIZE 4 -#define HAL_CMD_NAME_SIZE 12 -#define HAL_CMD_LEN_SIZE 4 -#define HAL_CMD_DATA_MAX_SIZE 1024 * 3 +#define HAL_CMD_PREFIX_SIZE 4 +#define HAL_CMD_CRC_SIZE 4 +#define HAL_CMD_NAME_SIZE 12 +#define HAL_CMD_LEN_SIZE 4 +#define HAL_CMD_DATA_MAX_SIZE 1024 * 3 // #define HAL_CMD_PREFIX_OFFSET 0 // #define HAL_CMD_TYPE_OFFSET 1 @@ -54,10 +54,12 @@ // #define HAL_CMD_PREFIX 0xFE // #define HAL_CMD_TYPE 0xA0 -#define HAL_CMD_RX_BUF_SIZE (HAL_CMD_PREFIX_SIZE + HAL_CMD_NAME_SIZE + HAL_CMD_CRC_SIZE + HAL_CMD_LEN_SIZE + HAL_CMD_DATA_MAX_SIZE) -#define HAL_CMD_TX_BUF_SIZE (100) +#define HAL_CMD_RX_BUF_SIZE \ + (HAL_CMD_PREFIX_SIZE + HAL_CMD_NAME_SIZE + HAL_CMD_CRC_SIZE + \ + HAL_CMD_LEN_SIZE + HAL_CMD_DATA_MAX_SIZE) +#define HAL_CMD_TX_BUF_SIZE (100) -#define HAL_CMD_LIST_NUM 10 +#define HAL_CMD_LIST_NUM 10 #ifdef USB_EQ_TUNING #define STATIC @@ -72,48 +74,48 @@ #endif typedef struct { - uint32_t len; - uint8_t data[HAL_CMD_TX_BUF_SIZE - 13]; -}hal_cmd_res_payload_t; - -typedef struct{ - int prefix; - int crc; - char name[HAL_CMD_NAME_SIZE]; -}hal_cmd_res_t; - -typedef struct{ - int prefix; - int crc; - char *name; - uint32_t len; - uint8_t *data; -}hal_cmd_cfg_t; - -typedef struct{ - char name[HAL_CMD_NAME_SIZE]; - hal_cmd_callback_t callback; -}hal_cmd_list_t; + uint32_t len; + uint8_t data[HAL_CMD_TX_BUF_SIZE - 13]; +} hal_cmd_res_payload_t; typedef struct { - uint8_t uart_work; - hal_cmd_rx_status_t rx_status; - uint8_t cur_seq; + int prefix; + int crc; + char name[HAL_CMD_NAME_SIZE]; +} hal_cmd_res_t; + +typedef struct { + int prefix; + int crc; + char *name; + uint32_t len; + uint8_t *data; +} hal_cmd_cfg_t; + +typedef struct { + char name[HAL_CMD_NAME_SIZE]; + hal_cmd_callback_t callback; +} hal_cmd_list_t; + +typedef struct { + uint8_t uart_work; + hal_cmd_rx_status_t rx_status; + uint8_t cur_seq; #ifdef __PC_CMD_UART__ - uint8_t rx_len; + uint8_t rx_len; #endif - uint8_t tx_len; + uint8_t tx_len; #ifdef __PC_CMD_UART__ - uint8_t rx_buf[HAL_CMD_RX_BUF_SIZE]; + uint8_t rx_buf[HAL_CMD_RX_BUF_SIZE]; #endif - uint8_t tx_buf[HAL_CMD_TX_BUF_SIZE]; + uint8_t tx_buf[HAL_CMD_TX_BUF_SIZE]; - hal_cmd_res_t res; - hal_cmd_res_payload_t res_payload; + hal_cmd_res_t res; + hal_cmd_res_payload_t res_payload; - uint32_t list_num; - hal_cmd_list_t list[HAL_CMD_LIST_NUM]; + uint32_t list_num; + hal_cmd_list_t list[HAL_CMD_LIST_NUM]; } hal_cmd_t; hal_cmd_t hal_cmd; @@ -121,13 +123,13 @@ CMD_CALLBACK_HANDLER_T hal_cmd_callback = NULL; #ifdef __PC_CMD_UART__ -#define HAL_CMD_ID HAL_UART_ID_0 +#define HAL_CMD_ID HAL_UART_ID_0 static const struct HAL_UART_CFG_T hal_cmd_cfg = { .parity = HAL_UART_PARITY_NONE, .stop = HAL_UART_STOP_BITS_1, .data = HAL_UART_DATA_BITS_8, - .flow = HAL_UART_FLOW_CONTROL_NONE,//HAL_UART_FLOW_CONTROL_RTSCTS, + .flow = HAL_UART_FLOW_CONTROL_NONE, // HAL_UART_FLOW_CONTROL_RTSCTS, .tx_level = HAL_UART_FIFO_LEVEL_1_2, .rx_level = HAL_UART_FIFO_LEVEL_1_2, .baud = 115200, @@ -137,7 +139,7 @@ static const struct HAL_UART_CFG_T hal_cmd_cfg = { }; #endif -#define HAL_CMD_TRACE TRACE +#define HAL_CMD_TRACE TRACE #ifdef __PC_CMD_UART__ STATIC int hal_cmd_list_process(uint8_t *buf); @@ -145,194 +147,177 @@ STATIC int hal_cmd_list_process(uint8_t *buf); static int hal_cmd_list_register(char *name, hal_cmd_callback_t callback); #ifdef __PC_CMD_UART__ -void hal_cmd_break_irq_handler (void) -{ - HAL_CMD_TRACE(1,"%s", __func__); - - // gElCtx.sync_step = EL_SYNC_ERROR; +void hal_cmd_break_irq_handler(void) { + HAL_CMD_TRACE(1, "%s", __func__); + // gElCtx.sync_step = EL_SYNC_ERROR; } -void hal_cmd_dma_rx_irq_handler (uint32_t xfer_size, int dma_error, union HAL_UART_IRQ_T status) -{ - // uint8_t prefix = gpElUartCtx->rx_buf[EL_PREFIX_OFFSET]; - // uint8_t type = gpElUartCtx->rx_buf[EL_TYPE_OFFSET]; - // uint8_t len = gpElUartCtx->rx_buf[EL_LEN_OFFSET]; - // uint8_t cmd = gpElUartCtx->rx_buf[EL_CMD_OFFSET]; - HAL_CMD_TRACE(5,"%s: xfer_size[%d], dma_error[%x], status[%x], rx_status[%d]", - __func__, xfer_size, dma_error, status.reg, hal_cmd.rx_status); +void hal_cmd_dma_rx_irq_handler(uint32_t xfer_size, int dma_error, + union HAL_UART_IRQ_T status) { + // uint8_t prefix = gpElUartCtx->rx_buf[EL_PREFIX_OFFSET]; + // uint8_t type = gpElUartCtx->rx_buf[EL_TYPE_OFFSET]; + // uint8_t len = gpElUartCtx->rx_buf[EL_LEN_OFFSET]; + // uint8_t cmd = gpElUartCtx->rx_buf[EL_CMD_OFFSET]; + HAL_CMD_TRACE(5, + "%s: xfer_size[%d], dma_error[%x], status[%x], rx_status[%d]", + __func__, xfer_size, dma_error, status.reg, hal_cmd.rx_status); - if (status.BE) { - hal_cmd_break_irq_handler(); - return; - } + if (status.BE) { + hal_cmd_break_irq_handler(); + return; + } - if (hal_cmd.rx_status != HAL_CMD_RX_START) - { - return; - } + if (hal_cmd.rx_status != HAL_CMD_RX_START) { + return; + } - if (dma_error || status.FE || status.OE || status.PE || status.BE) - { - // TODO: - ; - } - else - { - // mask.RT = 1 - hal_cmd.rx_len = xfer_size; - hal_cmd.rx_status = HAL_CMD_RX_DONE; - hal_cmd_callback(hal_cmd.rx_status); - } + if (dma_error || status.FE || status.OE || status.PE || status.BE) { + // TODO: + ; + } else { + // mask.RT = 1 + hal_cmd.rx_len = xfer_size; + hal_cmd.rx_status = HAL_CMD_RX_DONE; + hal_cmd_callback(hal_cmd.rx_status); + } } #endif -int hal_cmd_init (void) -{ +int hal_cmd_init(void) { #ifdef __PC_CMD_UART__ - HAL_CMD_TRACE(1,"[%s]", __func__); - if(HAL_CMD_ID == HAL_UART_ID_0) - { - hal_iomux_set_uart0(); - } - else if(HAL_CMD_ID == HAL_UART_ID_1) - { - hal_iomux_set_uart1(); - } - + HAL_CMD_TRACE(1, "[%s]", __func__); + if (HAL_CMD_ID == HAL_UART_ID_0) { + hal_iomux_set_uart0(); + } else if (HAL_CMD_ID == HAL_UART_ID_1) { + hal_iomux_set_uart1(); + } + #endif #ifdef USB_AUDIO_APP - hal_cmd_set_callback(hal_cmd_run); + hal_cmd_set_callback(hal_cmd_run); #endif - return 0; + return 0; } -void hal_cmd_set_callback(CMD_CALLBACK_HANDLER_T handler) -{ - hal_cmd_callback = handler; +void hal_cmd_set_callback(CMD_CALLBACK_HANDLER_T handler) { + hal_cmd_callback = handler; } #ifdef __PC_CMD_UART__ static union HAL_UART_IRQ_T mask; #endif -int hal_cmd_open (void) -{ +int hal_cmd_open(void) { #ifdef __PC_CMD_UART__ - int ret = -1; + int ret = -1; - ret = hal_uart_open(HAL_CMD_ID, &hal_cmd_cfg); - ASSERT(!ret, "!!%s: UART open failed (%d)!!", __func__, ret); + ret = hal_uart_open(HAL_CMD_ID, &hal_cmd_cfg); + ASSERT(!ret, "!!%s: UART open failed (%d)!!", __func__, ret); - hal_uart_irq_set_dma_handler(HAL_CMD_ID, hal_cmd_dma_rx_irq_handler, NULL); + hal_uart_irq_set_dma_handler(HAL_CMD_ID, hal_cmd_dma_rx_irq_handler, NULL); - // Do not enable tx and rx interrupt, use dma - mask.reg = 0; - mask.BE = 1; - mask.FE = 1; - mask.OE = 1; - mask.PE = 1; - mask.RT = 1; - hal_uart_irq_set_mask(HAL_CMD_ID, mask); + // Do not enable tx and rx interrupt, use dma + mask.reg = 0; + mask.BE = 1; + mask.FE = 1; + mask.OE = 1; + mask.PE = 1; + mask.RT = 1; + hal_uart_irq_set_mask(HAL_CMD_ID, mask); - hal_cmd.uart_work = 1; - hal_cmd.rx_status = HAL_CMD_RX_STOP; - hal_cmd_callback(hal_cmd.rx_status); + hal_cmd.uart_work = 1; + hal_cmd.rx_status = HAL_CMD_RX_STOP; + hal_cmd_callback(hal_cmd.rx_status); #endif - return 0; + return 0; } -int hal_cmd_close (void) -{ +int hal_cmd_close(void) { #ifdef __PC_CMD_UART__ - mask.reg = 0; - hal_uart_irq_set_mask(HAL_CMD_ID, mask); - hal_uart_irq_set_dma_handler(HAL_CMD_ID, NULL, NULL); - hal_uart_close(HAL_CMD_ID); + mask.reg = 0; + hal_uart_irq_set_mask(HAL_CMD_ID, mask); + hal_uart_irq_set_dma_handler(HAL_CMD_ID, NULL, NULL); + hal_uart_close(HAL_CMD_ID); - hal_cmd.uart_work = 0; + hal_cmd.uart_work = 0; #endif - return 0; + return 0; } -int hal_cmd_register(char *name, hal_cmd_callback_t callback) -{ - int ret = -1; +int hal_cmd_register(char *name, hal_cmd_callback_t callback) { + int ret = -1; - ASSERT(strlen(name) < HAL_CMD_NAME_SIZE, "[%s] strlen(%s) = %d >= HAL_CMD_NAME_SIZE", __func__, - name, - strlen(name)); + ASSERT(strlen(name) < HAL_CMD_NAME_SIZE, + "[%s] strlen(%s) = %d >= HAL_CMD_NAME_SIZE", __func__, name, + strlen(name)); - ret = hal_cmd_list_register(name, callback); + ret = hal_cmd_list_register(name, callback); - return ret; + return ret; } #ifdef __PC_CMD_UART__ -static int hal_cmd_send (void) -{ - int ret = -1; +static int hal_cmd_send(void) { + int ret = -1; - if (!hal_cmd.uart_work) - { - hal_cmd_open(); - } + if (!hal_cmd.uart_work) { + hal_cmd_open(); + } - ret = hal_uart_dma_send(HAL_CMD_ID, hal_cmd.tx_buf, hal_cmd.tx_len, NULL, NULL); + ret = + hal_uart_dma_send(HAL_CMD_ID, hal_cmd.tx_buf, hal_cmd.tx_len, NULL, NULL); - HAL_CMD_TRACE(4,"%s: %d - %d - %d", __func__, hal_cmd.tx_len, hal_cmd.uart_work, ret); + HAL_CMD_TRACE(4, "%s: %d - %d - %d", __func__, hal_cmd.tx_len, + hal_cmd.uart_work, ret); - return ret; + return ret; } -static int hal_cmd_rx_start (void) -{ - int ret = -1; +static int hal_cmd_rx_start(void) { + int ret = -1; - if (!hal_cmd.uart_work) - { - hal_cmd_open(); - } + if (!hal_cmd.uart_work) { + hal_cmd_open(); + } - ret = hal_uart_dma_recv_mask(HAL_CMD_ID, hal_cmd.rx_buf, HAL_CMD_RX_BUF_SIZE, NULL, NULL, &mask); //HAL_CMD_RX_BUF_SIZE + ret = hal_uart_dma_recv_mask(HAL_CMD_ID, hal_cmd.rx_buf, HAL_CMD_RX_BUF_SIZE, + NULL, NULL, &mask); // HAL_CMD_RX_BUF_SIZE - ASSERT(!ret, "!!%s: UART recv failed (%d)!!", __func__, ret); + ASSERT(!ret, "!!%s: UART recv failed (%d)!!", __func__, ret); - hal_cmd.rx_status = HAL_CMD_RX_START; - hal_cmd_callback(hal_cmd.rx_status); - return ret; + hal_cmd.rx_status = HAL_CMD_RX_START; + hal_cmd_callback(hal_cmd.rx_status); + return ret; } -static int hal_cmd_rx_process (void) -{ - int ret = -1; +static int hal_cmd_rx_process(void) { + int ret = -1; - HAL_CMD_TRACE(1,"[%s] start...", __func__); + HAL_CMD_TRACE(1, "[%s] start...", __func__); - ret = hal_cmd_list_process(hal_cmd.rx_buf); + ret = hal_cmd_list_process(hal_cmd.rx_buf); - hal_cmd.rx_status = HAL_CMD_RX_STOP; - hal_cmd_callback(hal_cmd.rx_status); - return ret; + hal_cmd.rx_status = HAL_CMD_RX_STOP; + hal_cmd_callback(hal_cmd.rx_status); + return ret; } #endif -void hal_cmd_set_res_playload(uint8_t* data, int len) -{ - hal_cmd.res_payload.len = len; - memcpy(hal_cmd.res_payload.data, data, len); +void hal_cmd_set_res_playload(uint8_t *data, int len) { + hal_cmd.res_payload.len = len; + memcpy(hal_cmd.res_payload.data, data, len); } #ifdef __PC_CMD_UART__ -static int hal_cmd_tx_process (void) -{ - int ret = -1; +static int hal_cmd_tx_process(void) { + int ret = -1; - HAL_CMD_TRACE(1,"[%s] start...", __func__); + HAL_CMD_TRACE(1, "[%s] start...", __func__); #if 0 // Test loop @@ -341,51 +326,55 @@ static int hal_cmd_tx_process (void) #endif #if 1 - hal_cmd.tx_len = sizeof(hal_cmd.res); - TRACE(5,"[%s] len : %d, %c, %d, %s", __func__, hal_cmd.tx_len, hal_cmd.res.prefix, hal_cmd.res.crc, hal_cmd.res.name); - memcpy(hal_cmd.tx_buf, &hal_cmd.res, hal_cmd.tx_len); + hal_cmd.tx_len = sizeof(hal_cmd.res); + TRACE(5, "[%s] len : %d, %c, %d, %s", __func__, hal_cmd.tx_len, + hal_cmd.res.prefix, hal_cmd.res.crc, hal_cmd.res.name); + memcpy(hal_cmd.tx_buf, &hal_cmd.res, hal_cmd.tx_len); - if (hal_cmd.res_payload.len) { - memcpy(hal_cmd.tx_buf + hal_cmd.tx_len, &hal_cmd.res_payload.len, sizeof(hal_cmd.res_payload.len)); - hal_cmd.tx_len += sizeof(hal_cmd.res_payload.len); + if (hal_cmd.res_payload.len) { + memcpy(hal_cmd.tx_buf + hal_cmd.tx_len, &hal_cmd.res_payload.len, + sizeof(hal_cmd.res_payload.len)); + hal_cmd.tx_len += sizeof(hal_cmd.res_payload.len); - memcpy(hal_cmd.tx_buf + hal_cmd.tx_len, hal_cmd.res_payload.data, hal_cmd.res_payload.len); - hal_cmd.tx_len += hal_cmd.res_payload.len; + memcpy(hal_cmd.tx_buf + hal_cmd.tx_len, hal_cmd.res_payload.data, + hal_cmd.res_payload.len); + hal_cmd.tx_len += hal_cmd.res_payload.len; - memset(&hal_cmd.res_payload, 0, sizeof(hal_cmd.res_payload)); - } + memset(&hal_cmd.res_payload, 0, sizeof(hal_cmd.res_payload)); + } #else - char send_string[] = "791,"; - hal_cmd.tx_len = sizeof(send_string); - memcpy(hal_cmd.tx_buf, send_string, hal_cmd.tx_len); + char send_string[] = "791,"; + hal_cmd.tx_len = sizeof(send_string); + memcpy(hal_cmd.tx_buf, send_string, hal_cmd.tx_len); #endif - hal_cmd_send(); + hal_cmd_send(); - return ret; + return ret; } #endif #ifdef USB_EQ_TUNING -void hal_cmd_tx_process (uint8_t** ppbuf, uint16_t* plen) -{ - hal_cmd.tx_len = sizeof(hal_cmd.res); +void hal_cmd_tx_process(uint8_t **ppbuf, uint16_t *plen) { + hal_cmd.tx_len = sizeof(hal_cmd.res); - memcpy(hal_cmd.tx_buf, &hal_cmd.res, hal_cmd.tx_len); + memcpy(hal_cmd.tx_buf, &hal_cmd.res, hal_cmd.tx_len); - if (hal_cmd.res_payload.len) { - memcpy(hal_cmd.tx_buf + hal_cmd.tx_len, &hal_cmd.res_payload.len, sizeof(hal_cmd.res_payload.len)); - hal_cmd.tx_len += sizeof(hal_cmd.res_payload.len); + if (hal_cmd.res_payload.len) { + memcpy(hal_cmd.tx_buf + hal_cmd.tx_len, &hal_cmd.res_payload.len, + sizeof(hal_cmd.res_payload.len)); + hal_cmd.tx_len += sizeof(hal_cmd.res_payload.len); - memcpy(hal_cmd.tx_buf + hal_cmd.tx_len, hal_cmd.res_payload.data, hal_cmd.res_payload.len); - hal_cmd.tx_len += hal_cmd.res_payload.len; + memcpy(hal_cmd.tx_buf + hal_cmd.tx_len, hal_cmd.res_payload.data, + hal_cmd.res_payload.len); + hal_cmd.tx_len += hal_cmd.res_payload.len; - memset(&hal_cmd.res_payload, 0, sizeof(hal_cmd.res_payload)); - } + memset(&hal_cmd.res_payload, 0, sizeof(hal_cmd.res_payload)); + } - *ppbuf = hal_cmd.tx_buf; - *plen = hal_cmd.tx_len; + *ppbuf = hal_cmd.tx_buf; + *plen = hal_cmd.tx_len; } #endif @@ -393,153 +382,130 @@ void hal_cmd_tx_process (uint8_t** ppbuf, uint16_t* plen) #ifdef __PC_CMD_UART__ #ifdef USB_AUDIO_APP -void hal_cmd_run (hal_cmd_rx_status_t status) +void hal_cmd_run(hal_cmd_rx_status_t status) #else -int hal_cmd_run (hal_cmd_rx_status_t status) +int hal_cmd_run(hal_cmd_rx_status_t status) #endif { - int ret = -1; + int ret = -1; - // static uint32_t pre_time_ms = 0, curr_ticks = 0, curr_time_ms = 0; + // static uint32_t pre_time_ms = 0, curr_ticks = 0, curr_time_ms = 0; - // curr_ticks = hal_sys_timer_get(); - // curr_time_ms = TICKS_TO_MS(curr_ticks); + // curr_ticks = hal_sys_timer_get(); + // curr_time_ms = TICKS_TO_MS(curr_ticks); + // if(curr_time_ms - pre_time_ms > 1000) + // { + // HAL_CMD_TRACE(1,"[%s] start...", __func__); + // pre_time_ms = curr_time_ms; + // } - // if(curr_time_ms - pre_time_ms > 1000) - // { - // HAL_CMD_TRACE(1,"[%s] start...", __func__); - // pre_time_ms = curr_time_ms; - // } + if (status == HAL_CMD_RX_DONE) { + ret = hal_cmd_rx_process(); - if(status == HAL_CMD_RX_DONE) - { - ret = hal_cmd_rx_process(); - - if (ret) - { - hal_cmd.res.crc = ret; - } - - ret = hal_cmd_tx_process(); + if (ret) { + hal_cmd.res.crc = ret; } - if(status == HAL_CMD_RX_STOP) - { - ret = hal_cmd_rx_start(); - } + ret = hal_cmd_tx_process(); + } + + if (status == HAL_CMD_RX_STOP) { + ret = hal_cmd_rx_start(); + } #ifndef USB_AUDIO_APP - return ret; + return ret; #endif } #endif // List process -static int hal_cmd_list_get_id(char *name) -{ - for(int i=0;iprefix = *((uint32_t *)buf); - HAL_CMD_TRACE(2,"[%s] PREFIX = %c", __func__, cfg->prefix); - buf += HAL_CMD_PREFIX_SIZE; - hal_cmd.res.prefix = cfg->prefix; +static int hal_cmd_list_parse(uint8_t *buf, hal_cmd_cfg_t *cfg) { + cfg->prefix = *((uint32_t *)buf); + HAL_CMD_TRACE(2, "[%s] PREFIX = %c", __func__, cfg->prefix); + buf += HAL_CMD_PREFIX_SIZE; + hal_cmd.res.prefix = cfg->prefix; - cfg->crc = *((uint32_t *)buf); - HAL_CMD_TRACE(2,"[%s] crc = %d", __func__, cfg->crc); - buf += HAL_CMD_CRC_SIZE; - hal_cmd.res.crc = cfg->crc; + cfg->crc = *((uint32_t *)buf); + HAL_CMD_TRACE(2, "[%s] crc = %d", __func__, cfg->crc); + buf += HAL_CMD_CRC_SIZE; + hal_cmd.res.crc = cfg->crc; - cfg->name = (char *)buf; - HAL_CMD_TRACE(2,"[%s] NAME = %s", __func__, cfg->name); - buf += HAL_CMD_NAME_SIZE; - memcpy(hal_cmd.res.name, cfg->name, HAL_CMD_NAME_SIZE); + cfg->name = (char *)buf; + HAL_CMD_TRACE(2, "[%s] NAME = %s", __func__, cfg->name); + buf += HAL_CMD_NAME_SIZE; + memcpy(hal_cmd.res.name, cfg->name, HAL_CMD_NAME_SIZE); - cfg->len = *((uint32_t *)buf); - HAL_CMD_TRACE(2,"[%s] LEN = %d", __func__, cfg->len); - buf += HAL_CMD_LEN_SIZE; + cfg->len = *((uint32_t *)buf); + HAL_CMD_TRACE(2, "[%s] LEN = %d", __func__, cfg->len); + buf += HAL_CMD_LEN_SIZE; - cfg->data = buf; + cfg->data = buf; - return 0; + return 0; } -STATIC int hal_cmd_list_process(uint8_t *buf) -{ - int ret = -1; - int id = 0; - hal_cmd_cfg_t cfg; +STATIC int hal_cmd_list_process(uint8_t *buf) { + int ret = -1; + int id = 0; + hal_cmd_cfg_t cfg; - hal_cmd_list_parse(buf, &cfg); + hal_cmd_list_parse(buf, &cfg); - id = hal_cmd_list_get_id(cfg.name); + id = hal_cmd_list_get_id(cfg.name); - if(id == -1) - { - TRACE(2,"[%s] %s is invalid", __func__, cfg.name); - return -2; - } + if (id == -1) { + TRACE(2, "[%s] %s is invalid", __func__, cfg.name); + return -2; + } - if(hal_cmd.list[id].callback) - { - ret = hal_cmd.list[id].callback(cfg.data, cfg.len); - } - else - { - TRACE(2,"[%s] %s has not callback", __func__, hal_cmd.list[id].name); - ret = -3; - } + if (hal_cmd.list[id].callback) { + ret = hal_cmd.list[id].callback(cfg.data, cfg.len); + } else { + TRACE(2, "[%s] %s has not callback", __func__, hal_cmd.list[id].name); + ret = -3; + } - return ret; + return ret; } #endif diff --git a/platform/hal/hal_cmu_common.c b/platform/hal/hal_cmu_common.c index 147ac9f..7fe2020 100644 --- a/platform/hal/hal_cmu_common.c +++ b/platform/hal/hal_cmu_common.c @@ -13,8 +13,8 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_addr_map.h" #include "hal_cmu.h" +#include "plat_addr_map.h" #include CHIP_SPECIFIC_HDR(reg_cmu) #ifdef AON_CMU_BASE #include CHIP_SPECIFIC_HDR(reg_aoncmu) @@ -32,416 +32,393 @@ #include "hal_timer.h" #include "hal_trace.h" -#if defined(CHIP_HAS_USB) && (defined(MCU_HIGH_PERFORMANCE_MODE) && !(defined(ULTRA_LOW_POWER) || defined(OSC_26M_X4_AUD2BB))) +#if defined(CHIP_HAS_USB) && \ + (defined(MCU_HIGH_PERFORMANCE_MODE) && \ + !(defined(ULTRA_LOW_POWER) || defined(OSC_26M_X4_AUD2BB))) #define USB_PLL_INIT_ON #endif -#if (!defined(ULTRA_LOW_POWER) && !defined(OSC_26M_X4_AUD2BB)) || \ - (!defined(FLASH_LOW_SPEED) && !defined(OSC_26M_X4_AUD2BB)) || \ - (defined(PSRAM_ENABLE) && !defined(PSRAM_LOW_SPEED)) +#if (!defined(ULTRA_LOW_POWER) && !defined(OSC_26M_X4_AUD2BB)) || \ + (!defined(FLASH_LOW_SPEED) && !defined(OSC_26M_X4_AUD2BB)) || \ + (defined(PSRAM_ENABLE) && !defined(PSRAM_LOW_SPEED)) #define AUD_PLL_INIT_ON #endif // SIMU_RES -#define CMU_SIMU_RES_PASSED (0x9A55) -#define CMU_SIMU_RES_FAILED (0xFA11) +#define CMU_SIMU_RES_PASSED (0x9A55) +#define CMU_SIMU_RES_FAILED (0xFA11) typedef void (*HAL_POWER_DOWN_WAKEUP_HANDLER)(void); -static struct CMU_T * const cmu = (struct CMU_T *)CMU_BASE; +static struct CMU_T *const cmu = (struct CMU_T *)CMU_BASE; #ifdef AON_CMU_BASE -static struct AONCMU_T * const POSSIBLY_UNUSED aoncmu = (struct AONCMU_T *)AON_CMU_BASE; +static struct AONCMU_T *const POSSIBLY_UNUSED aoncmu = + (struct AONCMU_T *)AON_CMU_BASE; #endif #ifdef HAL_CMU_VALID_CRYSTAL_FREQ static const uint32_t valid_crystal_freq_list[] = HAL_CMU_VALID_CRYSTAL_FREQ; -#define CRYSTAL_FREQ_ATTR BOOT_DATA_LOC +#define CRYSTAL_FREQ_ATTR BOOT_DATA_LOC #else -#define CRYSTAL_FREQ_ATTR const +#define CRYSTAL_FREQ_ATTR const #endif static uint32_t CRYSTAL_FREQ_ATTR crystal_freq = HAL_CMU_DEFAULT_CRYSTAL_FREQ; -void BOOT_TEXT_FLASH_LOC hal_cmu_set_crystal_freq_index(uint32_t index) -{ +void BOOT_TEXT_FLASH_LOC hal_cmu_set_crystal_freq_index(uint32_t index) { #ifdef HAL_CMU_VALID_CRYSTAL_FREQ - if (index >= ARRAY_SIZE(valid_crystal_freq_list)) { - index %= ARRAY_SIZE(valid_crystal_freq_list); - } - crystal_freq = valid_crystal_freq_list[index]; + if (index >= ARRAY_SIZE(valid_crystal_freq_list)) { + index %= ARRAY_SIZE(valid_crystal_freq_list); + } + crystal_freq = valid_crystal_freq_list[index]; #endif } -uint32_t BOOT_TEXT_SRAM_LOC hal_cmu_get_crystal_freq(void) -{ - return crystal_freq; +uint32_t BOOT_TEXT_SRAM_LOC hal_cmu_get_crystal_freq(void) { + return crystal_freq; } -uint32_t BOOT_TEXT_FLASH_LOC hal_cmu_get_default_crystal_freq(void) -{ - return HAL_CMU_DEFAULT_CRYSTAL_FREQ; +uint32_t BOOT_TEXT_FLASH_LOC hal_cmu_get_default_crystal_freq(void) { + return HAL_CMU_DEFAULT_CRYSTAL_FREQ; } -void hal_cmu_write_lock(void) -{ - cmu->WRITE_UNLOCK = 0xCAFE0000; -} +void hal_cmu_write_lock(void) { cmu->WRITE_UNLOCK = 0xCAFE0000; } -void hal_cmu_write_unlock(void) -{ - cmu->WRITE_UNLOCK = 0xCAFE0001; -} +void hal_cmu_write_unlock(void) { cmu->WRITE_UNLOCK = 0xCAFE0001; } -void hal_cmu_sys_reboot(void) -{ - hal_cmu_reset_set(HAL_CMU_MOD_GLOBAL); -} +void hal_cmu_sys_reboot(void) { hal_cmu_reset_set(HAL_CMU_MOD_GLOBAL); } -void hal_cmu_simu_init(void) -{ - cmu->SIMU_RES = 0; -} +void hal_cmu_simu_init(void) { cmu->SIMU_RES = 0; } -void hal_cmu_simu_pass(void) -{ - cmu->SIMU_RES = CMU_SIMU_RES_PASSED; -} +void hal_cmu_simu_pass(void) { cmu->SIMU_RES = CMU_SIMU_RES_PASSED; } -void hal_cmu_simu_fail(void) -{ - cmu->SIMU_RES = CMU_SIMU_RES_FAILED; -} +void hal_cmu_simu_fail(void) { cmu->SIMU_RES = CMU_SIMU_RES_FAILED; } -void hal_cmu_simu_tag(uint8_t shift) -{ - cmu->SIMU_RES |= (1 << shift); -} +void hal_cmu_simu_tag(uint8_t shift) { cmu->SIMU_RES |= (1 << shift); } -void hal_cmu_simu_set_val(uint32_t val) -{ - cmu->SIMU_RES = val; -} +void hal_cmu_simu_set_val(uint32_t val) { cmu->SIMU_RES = val; } -uint32_t hal_cmu_simu_get_val(void) -{ - return cmu->SIMU_RES; -} +uint32_t hal_cmu_simu_get_val(void) { return cmu->SIMU_RES; } -void hal_cmu_set_wakeup_pc(uint32_t pc) -{ +void hal_cmu_set_wakeup_pc(uint32_t pc) { #ifdef RAMRET_BASE - uint32_t *wake_pc = + uint32_t *wake_pc = #ifdef CHIP_BEST2000 - (uint32_t *)RAMRET_BASE; + (uint32_t *)RAMRET_BASE; #else - (uint32_t *)&aoncmu->WAKEUP_PC; + (uint32_t *)&aoncmu->WAKEUP_PC; - STATIC_ASSERT(sizeof(HAL_POWER_DOWN_WAKEUP_HANDLER) <= sizeof(uint32_t), "Invalid func ptr size"); + STATIC_ASSERT(sizeof(HAL_POWER_DOWN_WAKEUP_HANDLER) <= sizeof(uint32_t), + "Invalid func ptr size"); #endif - *wake_pc = pc; + *wake_pc = pc; #endif } -void hal_cmu_rom_wakeup_check(void) -{ +void hal_cmu_rom_wakeup_check(void) { #ifdef RAMRET_BASE - union HAL_HW_BOOTMODE_T hw; - uint32_t sw; - HAL_POWER_DOWN_WAKEUP_HANDLER *wake_fn = + union HAL_HW_BOOTMODE_T hw; + uint32_t sw; + HAL_POWER_DOWN_WAKEUP_HANDLER *wake_fn = #ifdef CHIP_BEST2000 - (HAL_POWER_DOWN_WAKEUP_HANDLER *)RAMRET_BASE; + (HAL_POWER_DOWN_WAKEUP_HANDLER *)RAMRET_BASE; #else - (HAL_POWER_DOWN_WAKEUP_HANDLER *)&aoncmu->WAKEUP_PC; + (HAL_POWER_DOWN_WAKEUP_HANDLER *)&aoncmu->WAKEUP_PC; #endif - hw = hal_rom_hw_bootmode_get(); - if (hw.watchdog == 0 && hw.global == 0) { - sw = hal_sw_bootmode_get(); - if ((sw & HAL_SW_BOOTMODE_POWER_DOWN_WAKEUP) && *wake_fn) { - (*wake_fn)(); - } + hw = hal_rom_hw_bootmode_get(); + if (hw.watchdog == 0 && hw.global == 0) { + sw = hal_sw_bootmode_get(); + if ((sw & HAL_SW_BOOTMODE_POWER_DOWN_WAKEUP) && *wake_fn) { + (*wake_fn)(); } + } - *wake_fn = NULL; + *wake_fn = NULL; #endif } #ifndef HAL_CMU_PLL_T -void hal_cmu_rom_enable_pll(void) -{ +void hal_cmu_rom_enable_pll(void) { #ifdef CHIP_HAS_USB - hal_cmu_pll_enable(HAL_CMU_PLL_USB, HAL_CMU_PLL_USER_SYS); - hal_cmu_sys_select_pll(HAL_CMU_PLL_USB); - hal_cmu_flash_select_pll(HAL_CMU_PLL_USB); + hal_cmu_pll_enable(HAL_CMU_PLL_USB, HAL_CMU_PLL_USER_SYS); + hal_cmu_sys_select_pll(HAL_CMU_PLL_USB); + hal_cmu_flash_select_pll(HAL_CMU_PLL_USB); #else - hal_cmu_pll_enable(HAL_CMU_PLL_AUD, HAL_CMU_PLL_USER_SYS); - hal_cmu_sys_select_pll(HAL_CMU_PLL_AUD); - hal_cmu_flash_select_pll(HAL_CMU_PLL_AUD); + hal_cmu_pll_enable(HAL_CMU_PLL_AUD, HAL_CMU_PLL_USER_SYS); + hal_cmu_sys_select_pll(HAL_CMU_PLL_AUD); + hal_cmu_flash_select_pll(HAL_CMU_PLL_AUD); #endif } -void hal_cmu_programmer_enable_pll(void) -{ - hal_cmu_pll_enable(HAL_CMU_PLL_AUD, HAL_CMU_PLL_USER_SYS); - hal_cmu_flash_select_pll(HAL_CMU_PLL_AUD); - hal_cmu_sys_select_pll(HAL_CMU_PLL_AUD); +void hal_cmu_programmer_enable_pll(void) { + hal_cmu_pll_enable(HAL_CMU_PLL_AUD, HAL_CMU_PLL_USER_SYS); + hal_cmu_flash_select_pll(HAL_CMU_PLL_AUD); + hal_cmu_sys_select_pll(HAL_CMU_PLL_AUD); } -void BOOT_TEXT_FLASH_LOC hal_cmu_init_pll_selection(void) -{ - // !!!!!! - // CAUTION: - // hal_cmu_pll_enable()/hal_cmu_pll_disable() must be called after hal_chipid_init(), - // for the init div values are extracted in hal_chipid_init(). - // !!!!!! +void BOOT_TEXT_FLASH_LOC hal_cmu_init_pll_selection(void) { + // !!!!!! + // CAUTION: + // hal_cmu_pll_enable()/hal_cmu_pll_disable() must be called after + // hal_chipid_init(), for the init div values are extracted in + // hal_chipid_init(). + // !!!!!! #if defined(CHIP_BEST1000) || defined(CHIP_BEST2000) #ifdef CHIP_HAS_USB - // Enable USB PLL before switching (clock mux requirement) - // -- USB PLL might not be started in ROM - hal_cmu_pll_enable(HAL_CMU_PLL_USB, HAL_CMU_PLL_USER_SYS); + // Enable USB PLL before switching (clock mux requirement) + // -- USB PLL might not be started in ROM + hal_cmu_pll_enable(HAL_CMU_PLL_USB, HAL_CMU_PLL_USER_SYS); #endif - hal_cmu_pll_enable(HAL_CMU_PLL_AUD, HAL_CMU_PLL_USER_SYS); + hal_cmu_pll_enable(HAL_CMU_PLL_AUD, HAL_CMU_PLL_USER_SYS); #else // !(best1000 || best2000) - // Disable the PLL which might be enabled in ROM + // Disable the PLL which might be enabled in ROM #ifdef CHIP_HAS_USB - hal_cmu_pll_disable(HAL_CMU_PLL_USB, HAL_CMU_PLL_USER_ALL); + hal_cmu_pll_disable(HAL_CMU_PLL_USB, HAL_CMU_PLL_USER_ALL); #else - hal_cmu_pll_disable(HAL_CMU_PLL_AUD, HAL_CMU_PLL_USER_ALL); + hal_cmu_pll_disable(HAL_CMU_PLL_AUD, HAL_CMU_PLL_USER_ALL); #endif #endif // !(best1000 || best2000) #ifdef FLASH_LOW_SPEED #ifdef CHIP_HAS_USB - // Switch flash clock to USB PLL, and then shutdown USB PLL, - // to save power consumed in clock divider - hal_cmu_flash_select_pll(HAL_CMU_PLL_USB); + // Switch flash clock to USB PLL, and then shutdown USB PLL, + // to save power consumed in clock divider + hal_cmu_flash_select_pll(HAL_CMU_PLL_USB); #endif #else - // Switch flash clock to audio PLL - hal_cmu_flash_select_pll(HAL_CMU_PLL_AUD); + // Switch flash clock to audio PLL + hal_cmu_flash_select_pll(HAL_CMU_PLL_AUD); #endif #ifdef CHIP_HAS_PSRAM #ifdef PSRAM_LOW_SPEED #ifdef CHIP_HAS_USB - // Switch psram clock to USB PLL, and then shutdown USB PLL, - // to save power consumed in clock divider - hal_cmu_mem_select_pll(HAL_CMU_PLL_USB); + // Switch psram clock to USB PLL, and then shutdown USB PLL, + // to save power consumed in clock divider + hal_cmu_mem_select_pll(HAL_CMU_PLL_USB); #endif #else - // Switch psram clock to audio PLL - hal_cmu_mem_select_pll(HAL_CMU_PLL_AUD); + // Switch psram clock to audio PLL + hal_cmu_mem_select_pll(HAL_CMU_PLL_AUD); #endif #endif - // Select system PLL after selecting flash/psram PLLs + // Select system PLL after selecting flash/psram PLLs #ifdef ULTRA_LOW_POWER - hal_cmu_low_freq_mode_init(); + hal_cmu_low_freq_mode_init(); #else #if defined(MCU_HIGH_PERFORMANCE_MODE) && defined(CHIP_HAS_USB) - // Switch system clocks to USB PLL - hal_cmu_sys_select_pll(HAL_CMU_PLL_USB); + // Switch system clocks to USB PLL + hal_cmu_sys_select_pll(HAL_CMU_PLL_USB); #else - // Switch system clocks to audio PLL - hal_cmu_sys_select_pll(HAL_CMU_PLL_AUD); + // Switch system clocks to audio PLL + hal_cmu_sys_select_pll(HAL_CMU_PLL_AUD); #endif #endif #if defined(CHIP_BEST1000) || defined(CHIP_BEST2000) #ifndef USB_PLL_INIT_ON - // Disable USB PLL after switching (clock mux requirement) - hal_cmu_pll_disable(HAL_CMU_PLL_USB, HAL_CMU_PLL_USER_SYS); + // Disable USB PLL after switching (clock mux requirement) + hal_cmu_pll_disable(HAL_CMU_PLL_USB, HAL_CMU_PLL_USER_SYS); #endif #ifndef AUD_PLL_INIT_ON - hal_cmu_pll_disable(HAL_CMU_PLL_AUD, HAL_CMU_PLL_USER_SYS); + hal_cmu_pll_disable(HAL_CMU_PLL_AUD, HAL_CMU_PLL_USER_SYS); #endif #else // !(best1000 || best2000) #ifdef USB_PLL_INIT_ON - hal_cmu_pll_enable(HAL_CMU_PLL_USB, HAL_CMU_PLL_USER_SYS); + hal_cmu_pll_enable(HAL_CMU_PLL_USB, HAL_CMU_PLL_USER_SYS); #endif #ifdef AUD_PLL_INIT_ON - hal_cmu_pll_enable(HAL_CMU_PLL_AUD, HAL_CMU_PLL_USER_SYS); + hal_cmu_pll_enable(HAL_CMU_PLL_AUD, HAL_CMU_PLL_USER_SYS); #endif #endif // !(best1000 || best2000) -#if defined(MCU_HIGH_PERFORMANCE_MODE) && !defined(ULTRA_LOW_POWER) && defined(OSC_26M_X4_AUD2BB) +#if defined(MCU_HIGH_PERFORMANCE_MODE) && !defined(ULTRA_LOW_POWER) && \ + defined(OSC_26M_X4_AUD2BB) #error "Error configuration: MCU_HIGH_PERFORMANCE_MODE has no effect" #endif } #endif // !HAL_CMU_PLL_T -static void BOOT_TEXT_FLASH_LOC hal_cmu_init_periph_clock(void) -{ +static void BOOT_TEXT_FLASH_LOC hal_cmu_init_periph_clock(void) { #ifdef PERIPH_PLL_FREQ - hal_cmu_periph_set_div(1); + hal_cmu_periph_set_div(1); #endif - // TODO: Move the following SDIO freq setting to hal_sdio.c + // TODO: Move the following SDIO freq setting to hal_sdio.c #ifdef CHIP_HAS_SDIO - hal_cmu_sdio_set_freq(HAL_CMU_PERIPH_FREQ_26M); + hal_cmu_sdio_set_freq(HAL_CMU_PERIPH_FREQ_26M); #endif } -void hal_cmu_rom_setup(void) -{ - hal_cmu_lpu_wait_26m_ready(); - hal_cmu_simu_init(); - hal_cmu_rom_clock_init(); - hal_cmu_timer0_select_slow(); +void hal_cmu_rom_setup(void) { + hal_cmu_lpu_wait_26m_ready(); + hal_cmu_simu_init(); + hal_cmu_rom_clock_init(); + hal_cmu_timer0_select_slow(); #ifdef TIMER1_BASE - hal_cmu_timer1_select_fast(); + hal_cmu_timer1_select_fast(); #endif - hal_sys_timer_open(); + hal_sys_timer_open(); - // Init sys clock - hal_cmu_sys_set_freq(HAL_CMU_FREQ_26M); + // Init sys clock + hal_cmu_sys_set_freq(HAL_CMU_FREQ_26M); - // Init flash clock (this should be done before load_boot_settings, for security register read) - hal_cmu_flash_set_freq(HAL_CMU_FREQ_26M); - // Reset flash controller (for JTAG reset and run) - // Enable flash controller (flash controller is reset by default since BEST1400) - hal_cmu_reset_set(HAL_CMU_MOD_O_FLASH); - hal_cmu_reset_set(HAL_CMU_MOD_H_FLASH); - hal_cmu_reset_clear(HAL_CMU_MOD_H_FLASH); - hal_cmu_reset_clear(HAL_CMU_MOD_O_FLASH); + // Init flash clock (this should be done before load_boot_settings, for + // security register read) + hal_cmu_flash_set_freq(HAL_CMU_FREQ_26M); + // Reset flash controller (for JTAG reset and run) + // Enable flash controller (flash controller is reset by default since + // BEST1400) + hal_cmu_reset_set(HAL_CMU_MOD_O_FLASH); + hal_cmu_reset_set(HAL_CMU_MOD_H_FLASH); + hal_cmu_reset_clear(HAL_CMU_MOD_H_FLASH); + hal_cmu_reset_clear(HAL_CMU_MOD_O_FLASH); - // Disable cache (for JTAG reset and run) - hal_cache_disable(HAL_CACHE_ID_I_CACHE); - hal_cache_disable(HAL_CACHE_ID_D_CACHE); + // Disable cache (for JTAG reset and run) + hal_cache_disable(HAL_CACHE_ID_I_CACHE); + hal_cache_disable(HAL_CACHE_ID_D_CACHE); - // Init APB clock - hal_cmu_apb_init_div(); + // Init APB clock + hal_cmu_apb_init_div(); } -void hal_cmu_programmer_setup(void) -{ - hal_cmu_ema_init(); - hal_sys_timer_open(); +void hal_cmu_programmer_setup(void) { + hal_cmu_ema_init(); + hal_sys_timer_open(); #ifdef JTAG_ENABLE - hal_iomux_set_jtag(); - hal_cmu_jtag_clock_enable(); + hal_iomux_set_jtag(); + hal_cmu_jtag_clock_enable(); #endif #ifndef FPGA - int ret; - // Open analogif (ISPI) - ret = hal_analogif_open(); - if (ret) { - hal_cmu_simu_tag(31); - do { volatile int i = 0; i++; } while (1); - } - // Init chip id - // 1) Read id from ana/rf/pmu - // 2) Init clock settings in ana/rf/pmu if the default h/w register values are bad - hal_chipid_init(); + int ret; + // Open analogif (ISPI) + ret = hal_analogif_open(); + if (ret) { + hal_cmu_simu_tag(31); + do { + volatile int i = 0; + i++; + } while (1); + } + // Init chip id + // 1) Read id from ana/rf/pmu + // 2) Init clock settings in ana/rf/pmu if the default h/w register values are + // bad + hal_chipid_init(); - // Enable OSC X2/X4 in cmu after enabling their source in hal_chipid_init() - hal_cmu_osc_x2_enable(); - hal_cmu_osc_x4_enable(); + // Enable OSC X2/X4 in cmu after enabling their source in hal_chipid_init() + hal_cmu_osc_x2_enable(); + hal_cmu_osc_x4_enable(); #endif } #ifdef FPGA -void BOOT_TEXT_FLASH_LOC hal_cmu_fpga_setup(void) -{ - hal_cmu_timer0_select_slow(); - hal_sys_timer_open(); +void BOOT_TEXT_FLASH_LOC hal_cmu_fpga_setup(void) { + hal_cmu_timer0_select_slow(); + hal_sys_timer_open(); - hal_sysfreq_req(HAL_SYSFREQ_USER_INIT, HAL_CMU_FREQ_52M); + hal_sysfreq_req(HAL_SYSFREQ_USER_INIT, HAL_CMU_FREQ_52M); - hal_cmu_apb_init_div(); - hal_cmu_ispi_set_freq(HAL_CMU_PERIPH_FREQ_26M); + hal_cmu_apb_init_div(); + hal_cmu_ispi_set_freq(HAL_CMU_PERIPH_FREQ_26M); - // Init peripheral clocks - hal_cmu_init_periph_clock(); + // Init peripheral clocks + hal_cmu_init_periph_clock(); - hal_norflash_init(); + hal_norflash_init(); #if defined(CHIP_HAS_PSRAM) && defined(PSRAM_ENABLE) - hal_psram_init(); + hal_psram_init(); #endif } #else // !FPGA -void BOOT_TEXT_FLASH_LOC hal_cmu_setup(void) -{ - int ret; - enum HAL_CMU_FREQ_T freq; +void BOOT_TEXT_FLASH_LOC hal_cmu_setup(void) { + int ret; + enum HAL_CMU_FREQ_T freq; - hal_iomux_set_default_config(); + hal_iomux_set_default_config(); #ifdef JTAG_ENABLE - hal_iomux_set_jtag(); - hal_cmu_jtag_clock_enable(); + hal_iomux_set_jtag(); + hal_cmu_jtag_clock_enable(); #endif - hal_cmu_module_init_state(); - hal_cmu_ema_init(); - hal_cmu_timer0_select_slow(); + hal_cmu_module_init_state(); + hal_cmu_ema_init(); + hal_cmu_timer0_select_slow(); #ifdef TIMER1_BASE - hal_cmu_timer1_select_fast(); + hal_cmu_timer1_select_fast(); #endif - hal_sys_timer_open(); - hal_hw_bootmode_init(); + hal_sys_timer_open(); + hal_hw_bootmode_init(); - // Init system/flash/memory clocks before initializing clock setting - // and before switching PLL - hal_norflash_set_freq(HAL_CMU_FREQ_26M); - hal_cmu_mem_set_freq(HAL_CMU_FREQ_26M); - hal_cmu_sys_set_freq(HAL_CMU_FREQ_26M); + // Init system/flash/memory clocks before initializing clock setting + // and before switching PLL + hal_norflash_set_freq(HAL_CMU_FREQ_26M); + hal_cmu_mem_set_freq(HAL_CMU_FREQ_26M); + hal_cmu_sys_set_freq(HAL_CMU_FREQ_26M); - // Set ISPI module freq - hal_cmu_ispi_set_freq(HAL_CMU_PERIPH_FREQ_26M); - // Open analogif (ISPI) - ret = hal_analogif_open(); - if (ret) { - hal_cmu_simu_tag(31); - do { volatile int i = 0; i++; } while (1); - } - // Init chip id - // 1) Read id from ana/rf/pmu - // 2) Init clock settings in ana/rf/pmu if the default h/w register values are bad - hal_chipid_init(); + // Set ISPI module freq + hal_cmu_ispi_set_freq(HAL_CMU_PERIPH_FREQ_26M); + // Open analogif (ISPI) + ret = hal_analogif_open(); + if (ret) { + hal_cmu_simu_tag(31); + do { + volatile int i = 0; + i++; + } while (1); + } + // Init chip id + // 1) Read id from ana/rf/pmu + // 2) Init clock settings in ana/rf/pmu if the default h/w register values are + // bad + hal_chipid_init(); #ifdef CALIB_SLOW_TIMER - // Calib slow timer after determining the crystal freq - hal_sys_timer_calib(); + // Calib slow timer after determining the crystal freq + hal_sys_timer_calib(); #endif - // Enable OSC X2/X4 in cmu after enabling their source in hal_chipid_init() - hal_cmu_osc_x2_enable(); - hal_cmu_osc_x4_enable(); + // Enable OSC X2/X4 in cmu after enabling their source in hal_chipid_init() + hal_cmu_osc_x2_enable(); + hal_cmu_osc_x4_enable(); - // Init PLL selection - hal_cmu_init_pll_selection(); + // Init PLL selection + hal_cmu_init_pll_selection(); - // Init peripheral clocks - hal_cmu_init_periph_clock(); + // Init peripheral clocks + hal_cmu_init_periph_clock(); - // Sleep setting + // Sleep setting #ifdef NO_LPU_26M - while (hal_cmu_lpu_init(HAL_CMU_LPU_CLK_NONE) == -1); + while (hal_cmu_lpu_init(HAL_CMU_LPU_CLK_NONE) == -1) + ; #else - while (hal_cmu_lpu_init(HAL_CMU_LPU_CLK_26M) == -1); + while (hal_cmu_lpu_init(HAL_CMU_LPU_CLK_26M) == -1) + ; #endif - // Init sys freq after applying the sleep setting (which might change sys freq) + // Init sys freq after applying the sleep setting (which might change sys + // freq) #ifdef NO_LPU_26M - hal_sys_timer_delay(MS_TO_TICKS(20)); + hal_sys_timer_delay(MS_TO_TICKS(20)); #endif - // Init system clock + // Init system clock #ifdef ULTRA_LOW_POWER - freq = HAL_CMU_FREQ_52M; + freq = HAL_CMU_FREQ_52M; #else - freq = HAL_CMU_FREQ_104M; + freq = HAL_CMU_FREQ_104M; #endif - hal_sysfreq_req(HAL_SYSFREQ_USER_INIT, freq); - - // Init flash - hal_norflash_init(); + hal_sysfreq_req(HAL_SYSFREQ_USER_INIT, freq); + // Init flash + hal_norflash_init(); } #endif // !FPGA - diff --git a/platform/hal/hal_codec_common.c b/platform/hal/hal_codec_common.c index 53fd8e4..bec31c7 100644 --- a/platform/hal/hal_codec_common.c +++ b/platform/hal/hal_codec_common.c @@ -21,109 +21,107 @@ extern const CODEC_ADC_VOL_T codec_adc_vol[TGT_ADC_VOL_LEVEL_QTY]; #ifndef CODEC_MIC_CH0_SADC_VOL -#define CODEC_MIC_CH0_SADC_VOL CODEC_SADC_VOL +#define CODEC_MIC_CH0_SADC_VOL CODEC_SADC_VOL #endif #ifndef CODEC_MIC_CH1_SADC_VOL -#define CODEC_MIC_CH1_SADC_VOL CODEC_SADC_VOL +#define CODEC_MIC_CH1_SADC_VOL CODEC_SADC_VOL #endif #ifndef CODEC_MIC_CH2_SADC_VOL -#define CODEC_MIC_CH2_SADC_VOL CODEC_SADC_VOL +#define CODEC_MIC_CH2_SADC_VOL CODEC_SADC_VOL #endif #ifndef CODEC_MIC_CH3_SADC_VOL -#define CODEC_MIC_CH3_SADC_VOL CODEC_SADC_VOL +#define CODEC_MIC_CH3_SADC_VOL CODEC_SADC_VOL #endif #ifndef CODEC_MIC_CH4_SADC_VOL -#define CODEC_MIC_CH4_SADC_VOL CODEC_SADC_VOL +#define CODEC_MIC_CH4_SADC_VOL CODEC_SADC_VOL #endif #ifndef CODEC_MIC_CH5_SADC_VOL -#define CODEC_MIC_CH5_SADC_VOL CODEC_SADC_VOL +#define CODEC_MIC_CH5_SADC_VOL CODEC_SADC_VOL #endif #ifndef CODEC_MIC_CH6_SADC_VOL -#define CODEC_MIC_CH6_SADC_VOL CODEC_SADC_VOL +#define CODEC_MIC_CH6_SADC_VOL CODEC_SADC_VOL #endif #ifndef CODEC_MIC_CH7_SADC_VOL -#define CODEC_MIC_CH7_SADC_VOL CODEC_SADC_VOL +#define CODEC_MIC_CH7_SADC_VOL CODEC_SADC_VOL #endif #ifndef CODEC_DIGMIC_CH0_SADC_VOL -#define CODEC_DIGMIC_CH0_SADC_VOL CODEC_SADC_VOL +#define CODEC_DIGMIC_CH0_SADC_VOL CODEC_SADC_VOL #endif #ifndef CODEC_DIGMIC_CH1_SADC_VOL -#define CODEC_DIGMIC_CH1_SADC_VOL CODEC_SADC_VOL +#define CODEC_DIGMIC_CH1_SADC_VOL CODEC_SADC_VOL #endif #ifndef CODEC_DIGMIC_CH2_SADC_VOL -#define CODEC_DIGMIC_CH2_SADC_VOL CODEC_SADC_VOL +#define CODEC_DIGMIC_CH2_SADC_VOL CODEC_SADC_VOL #endif #ifndef CODEC_DIGMIC_CH3_SADC_VOL -#define CODEC_DIGMIC_CH3_SADC_VOL CODEC_SADC_VOL +#define CODEC_DIGMIC_CH3_SADC_VOL CODEC_SADC_VOL #endif #ifndef CODEC_DIGMIC_CH4_SADC_VOL -#define CODEC_DIGMIC_CH4_SADC_VOL CODEC_SADC_VOL +#define CODEC_DIGMIC_CH4_SADC_VOL CODEC_SADC_VOL #endif #ifndef CODEC_DIGMIC_CH5_SADC_VOL -#define CODEC_DIGMIC_CH5_SADC_VOL CODEC_SADC_VOL +#define CODEC_DIGMIC_CH5_SADC_VOL CODEC_SADC_VOL #endif #ifndef CODEC_DIGMIC_CH6_SADC_VOL -#define CODEC_DIGMIC_CH6_SADC_VOL CODEC_SADC_VOL +#define CODEC_DIGMIC_CH6_SADC_VOL CODEC_SADC_VOL #endif #ifndef CODEC_DIGMIC_CH7_SADC_VOL -#define CODEC_DIGMIC_CH7_SADC_VOL CODEC_SADC_VOL +#define CODEC_DIGMIC_CH7_SADC_VOL CODEC_SADC_VOL #endif static const uint8_t codec_mic_chan_vol[] = { - CODEC_MIC_CH0_SADC_VOL, CODEC_MIC_CH1_SADC_VOL, CODEC_MIC_CH2_SADC_VOL, CODEC_MIC_CH3_SADC_VOL, - CODEC_MIC_CH4_SADC_VOL, CODEC_MIC_CH5_SADC_VOL, CODEC_MIC_CH6_SADC_VOL, CODEC_MIC_CH7_SADC_VOL, - CODEC_DIGMIC_CH0_SADC_VOL, CODEC_DIGMIC_CH1_SADC_VOL, CODEC_DIGMIC_CH2_SADC_VOL, CODEC_DIGMIC_CH3_SADC_VOL, - CODEC_DIGMIC_CH4_SADC_VOL, CODEC_DIGMIC_CH5_SADC_VOL, CODEC_DIGMIC_CH6_SADC_VOL, CODEC_DIGMIC_CH7_SADC_VOL, + CODEC_MIC_CH0_SADC_VOL, CODEC_MIC_CH1_SADC_VOL, + CODEC_MIC_CH2_SADC_VOL, CODEC_MIC_CH3_SADC_VOL, + CODEC_MIC_CH4_SADC_VOL, CODEC_MIC_CH5_SADC_VOL, + CODEC_MIC_CH6_SADC_VOL, CODEC_MIC_CH7_SADC_VOL, + CODEC_DIGMIC_CH0_SADC_VOL, CODEC_DIGMIC_CH1_SADC_VOL, + CODEC_DIGMIC_CH2_SADC_VOL, CODEC_DIGMIC_CH3_SADC_VOL, + CODEC_DIGMIC_CH4_SADC_VOL, CODEC_DIGMIC_CH5_SADC_VOL, + CODEC_DIGMIC_CH6_SADC_VOL, CODEC_DIGMIC_CH7_SADC_VOL, }; -uint32_t hal_codec_get_input_path_cfg(enum AUD_IO_PATH_T io_path) -{ - int i; +uint32_t hal_codec_get_input_path_cfg(enum AUD_IO_PATH_T io_path) { + int i; - for (i = 0; i < CFG_HW_AUD_INPUT_PATH_NUM; i++) { - if (io_path == cfg_audio_input_path_cfg[i].io_path) { - return cfg_audio_input_path_cfg[i].cfg; - } + for (i = 0; i < CFG_HW_AUD_INPUT_PATH_NUM; i++) { + if (io_path == cfg_audio_input_path_cfg[i].io_path) { + return cfg_audio_input_path_cfg[i].cfg; } - ASSERT(false, "%s: Bad input path: %d", __func__, io_path); - return 0; + } + ASSERT(false, "%s: Bad input path: %d", __func__, io_path); + return 0; } -const struct CODEC_DAC_VOL_T *hal_codec_get_dac_volume(uint32_t index) -{ - uint32_t _array_sizeof_vol = ARRAY_SIZE(codec_dac_vol); - if (index < _array_sizeof_vol) { - return &codec_dac_vol[index]; - } else { - return &codec_dac_vol[_array_sizeof_vol-1]; - } +const struct CODEC_DAC_VOL_T *hal_codec_get_dac_volume(uint32_t index) { + uint32_t _array_sizeof_vol = ARRAY_SIZE(codec_dac_vol); + if (index < _array_sizeof_vol) { + return &codec_dac_vol[index]; + } else { + return &codec_dac_vol[_array_sizeof_vol - 1]; + } } -const CODEC_ADC_VOL_T *hal_codec_get_adc_volume(uint32_t index) -{ - uint32_t _array_sizeof_vol = ARRAY_SIZE(codec_adc_vol); - if (index < _array_sizeof_vol) { - return &codec_adc_vol[index]; - } else { - return &codec_adc_vol[_array_sizeof_vol-1]; - } +const CODEC_ADC_VOL_T *hal_codec_get_adc_volume(uint32_t index) { + uint32_t _array_sizeof_vol = ARRAY_SIZE(codec_adc_vol); + if (index < _array_sizeof_vol) { + return &codec_adc_vol[index]; + } else { + return &codec_adc_vol[_array_sizeof_vol - 1]; + } } -uint32_t hal_codec_get_mic_chan_volume_level(uint32_t map) -{ - uint32_t mic_ch; +uint32_t hal_codec_get_mic_chan_volume_level(uint32_t map) { + uint32_t mic_ch; - mic_ch = get_lsb_pos(map); + mic_ch = get_lsb_pos(map); - if (mic_ch < ARRAY_SIZE(codec_mic_chan_vol)) { - return codec_mic_chan_vol[mic_ch]; - } else { - return ARRAY_SIZE(codec_adc_vol); - } + if (mic_ch < ARRAY_SIZE(codec_mic_chan_vol)) { + return codec_mic_chan_vol[mic_ch]; + } else { + return ARRAY_SIZE(codec_adc_vol); + } } -uint8_t hal_codec_get_digmic_hw_index(uint8_t chan) -{ - return chan - get_msb_pos(AUD_CHANNEL_MAP_DIGMIC_CH0); +uint8_t hal_codec_get_digmic_hw_index(uint8_t chan) { + return chan - get_msb_pos(AUD_CHANNEL_MAP_DIGMIC_CH0); } - diff --git a/platform/hal/hal_dma.c b/platform/hal/hal_dma.c index 87d3ccd..38e9e57 100644 --- a/platform/hal/hal_dma.c +++ b/platform/hal/hal_dma.c @@ -13,41 +13,43 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_addr_map.h" +#include "hal_dma.h" #include "cmsis_nvic.h" #include "hal_chipid.h" #include "hal_cmu.h" -#include "hal_dma.h" #include "hal_location.h" #include "hal_timer.h" #include "hal_trace.h" +#include "plat_addr_map.h" #include "reg_dma.h" -#if (defined(CHIP_BEST1000) || defined(CHIP_BEST2000) || defined(CHIP_BEST2300)) && !(defined(ROM_BUILD) || defined(PROGRAMMER)) +#if (defined(CHIP_BEST1000) || defined(CHIP_BEST2000) || \ + defined(CHIP_BEST2300)) && \ + !(defined(ROM_BUILD) || defined(PROGRAMMER)) #define DMA_REMAP #endif enum HAL_DMA_INST_T { - HAL_DMA_INST_AUDMA = 0, + HAL_DMA_INST_AUDMA = 0, #if (CHIP_HAS_DMA == 1) - HAL_DMA_INST_GPDMA = HAL_DMA_INST_AUDMA, + HAL_DMA_INST_GPDMA = HAL_DMA_INST_AUDMA, #else - HAL_DMA_INST_GPDMA, + HAL_DMA_INST_GPDMA, #endif - HAL_DMA_INST_QTY + HAL_DMA_INST_QTY }; struct HAL_DMA_FIFO_ADDR_T { - uint32_t count; - const uint32_t *addr; + uint32_t count; + const uint32_t *addr; }; struct HAL_DMA_FIFO_PERIPH_T { - uint32_t count; - const enum HAL_DMA_PERIPH_T *periph; + uint32_t count; + const enum HAL_DMA_PERIPH_T *periph; #ifdef DMA_REMAP - const enum HAL_DMA_PERIPH_T *periph_remap; + const enum HAL_DMA_PERIPH_T *periph_remap; #endif }; @@ -57,7 +59,7 @@ struct HAL_DMA_FIFO_PERIPH_T { #include CHIP_SPECIFIC_HDR(hal_dmacfg) -static struct DMA_T * const dma[HAL_DMA_INST_QTY] = { +static struct DMA_T *const dma[HAL_DMA_INST_QTY] = { (struct DMA_T *)AUDMA_BASE, #if (CHIP_HAS_DMA > 1) (struct DMA_T *)GPDMA_BASE, @@ -142,9 +144,9 @@ static uint32_t periph_remap_bitmap[HAL_DMA_INST_QTY]; static uint32_t saved_dma_regs[HAL_DMA_INST_QTY]; #endif -static const char * const err_invalid_inst = "Invalid DMA inst: %u"; +static const char *const err_invalid_inst = "Invalid DMA inst: %u"; -static const char * const err_invalid_chan[HAL_DMA_INST_QTY] = { +static const char *const err_invalid_chan[HAL_DMA_INST_QTY] = { "Invalid AUDMA chan: %u", #if (CHIP_HAS_DMA > 1) "Invalid GPDMA chan: %u", @@ -155,7 +157,6 @@ static bool dma_opened = false; static HAL_DMA_DELAY_FUNC dma_delay = NULL; - /***************************************************************************** * Public types/enumerations/variables ****************************************************************************/ @@ -163,244 +164,232 @@ static HAL_DMA_DELAY_FUNC dma_delay = NULL; /***************************************************************************** * Private functions ****************************************************************************/ -static void hal_dma_delay(uint32_t ms) -{ - if (dma_delay && !in_isr()) { - dma_delay(ms); - } else { - hal_sys_timer_delay(MS_TO_TICKS(ms)); +static void hal_dma_delay(uint32_t ms) { + if (dma_delay && !in_isr()) { + dma_delay(ms); + } else { + hal_sys_timer_delay(MS_TO_TICKS(ms)); + } +} + +static inline uint8_t generate_chan(enum HAL_DMA_INST_T inst, uint8_t hwch) { + return ((inst << 4) | (hwch & 0xF)); +} + +static inline enum HAL_DMA_INST_T get_inst_from_chan(uint8_t ch) { + return (enum HAL_DMA_INST_T)(ch >> 4); +} + +static inline uint8_t get_hwch_from_chan(uint8_t ch) { return (ch & 0xF); } + +static inline int get_index_from_periph(enum HAL_DMA_PERIPH_T periph, + enum HAL_DMA_INST_T *pinst, + uint8_t *pidx) { + enum HAL_DMA_INST_T inst; + int i; + + for (inst = 0; inst < HAL_DMA_INST_QTY; inst++) { + for (i = 0; i < fifo_periph[inst].count; i++) { + if (fifo_periph[inst].periph[i] == periph) { + *pinst = inst; + *pidx = i; + return 0; + } } -} + } -static inline uint8_t generate_chan(enum HAL_DMA_INST_T inst, uint8_t hwch) -{ - return ((inst << 4) | (hwch & 0xF)); -} - -static inline enum HAL_DMA_INST_T get_inst_from_chan(uint8_t ch) -{ - return (enum HAL_DMA_INST_T)(ch >> 4); -} - -static inline uint8_t get_hwch_from_chan(uint8_t ch) -{ - return (ch & 0xF); -} - -static inline int get_index_from_periph(enum HAL_DMA_PERIPH_T periph, enum HAL_DMA_INST_T *pinst, uint8_t *pidx) -{ - enum HAL_DMA_INST_T inst; - int i; - - for (inst = 0; inst < HAL_DMA_INST_QTY; inst++) { - for (i = 0; i < fifo_periph[inst].count; i++) { - if (fifo_periph[inst].periph[i] == periph) { - *pinst = inst; - *pidx = i; - return 0; - } - } - } - - return 1; + return 1; } #ifdef DMA_REMAP -static inline int get_remap_index_from_periph(enum HAL_DMA_INST_T inst, enum HAL_DMA_PERIPH_T periph, uint8_t *pidx) -{ - int i; +static inline int get_remap_index_from_periph(enum HAL_DMA_INST_T inst, + enum HAL_DMA_PERIPH_T periph, + uint8_t *pidx) { + int i; - if (fifo_periph[inst].periph_remap == NULL) { - return 1; + if (fifo_periph[inst].periph_remap == NULL) { + return 1; + } + + for (i = 0; i < fifo_periph[inst].count; i++) { + if (fifo_periph[inst].periph_remap[i] == periph) { + *pidx = i; + return 0; } + } - for (i = 0; i < fifo_periph[inst].count; i++) { - if (fifo_periph[inst].periph_remap[i] == periph) { - *pidx = i; - return 0; - } - } - - return 2; + return 2; } #endif -static inline uint32_t hal_dma_get_periph_addr(enum HAL_DMA_PERIPH_T periph) -{ - int ret; - enum HAL_DMA_INST_T inst; - uint8_t index; +static inline uint32_t hal_dma_get_periph_addr(enum HAL_DMA_PERIPH_T periph) { + int ret; + enum HAL_DMA_INST_T inst; + uint8_t index; - ret = get_index_from_periph(periph, &inst, &index); - if (ret) { - return 0; - } + ret = get_index_from_periph(periph, &inst, &index); + if (ret) { + return 0; + } - return fifo_addr[inst].addr[index]; + return fifo_addr[inst].addr[index]; } /* Initialize the DMA */ -static void hal_dma_open_inst(enum HAL_DMA_INST_T inst) -{ - uint8_t i; +static void hal_dma_open_inst(enum HAL_DMA_INST_T inst) { + uint8_t i; - /* Reset all channel configuration register */ - for (i = 0; i < DMA_NUMBER_CHANNELS; i++) { - dma[inst]->CH[i].CONFIG = 0; - } + /* Reset all channel configuration register */ + for (i = 0; i < DMA_NUMBER_CHANNELS; i++) { + dma[inst]->CH[i].CONFIG = 0; + } - /* Clear all DMA interrupt and error flag */ - dma[inst]->INTTCCLR = ~0UL; - dma[inst]->INTERRCLR = ~0UL; + /* Clear all DMA interrupt and error flag */ + dma[inst]->INTTCCLR = ~0UL; + dma[inst]->INTERRCLR = ~0UL; - dma[inst]->DMACONFIG = (dma[inst]->DMACONFIG & ~(DMA_DMACONFIG_AHB1_BIGENDIAN | - DMA_DMACONFIG_AHB2_BIGENDIAN | DMA_DMACONFIG_CLK_EN_MASK)) | - DMA_DMACONFIG_EN | + dma[inst]->DMACONFIG = + (dma[inst]->DMACONFIG & + ~(DMA_DMACONFIG_AHB1_BIGENDIAN | DMA_DMACONFIG_AHB2_BIGENDIAN | + DMA_DMACONFIG_CLK_EN_MASK)) | + DMA_DMACONFIG_EN | #ifdef CHIP_BEST3001 - DMA_DMACONFIG_TC_IRQ_EN_MASK | + DMA_DMACONFIG_TC_IRQ_EN_MASK | #endif - 0; + 0; #ifdef CHIP_BEST1400 - dma[inst]->DMACONFIG &= ~DMA_DMACONFIG_TC_IRQ_EN_MASK; + dma[inst]->DMACONFIG &= ~DMA_DMACONFIG_TC_IRQ_EN_MASK; #endif - /* Reset all channels are free */ - for (i = 0; i < DMA_NUMBER_CHANNELS; i++) { - chan_enabled[inst][i] = false; - } + /* Reset all channels are free */ + for (i = 0; i < DMA_NUMBER_CHANNELS; i++) { + chan_enabled[inst][i] = false; + } - NVIC_SetVector(irq_type[inst], irq_entry[inst]); - if (inst == HAL_DMA_INST_AUDMA) { - NVIC_SetPriority(irq_type[inst], IRQ_PRIORITY_ABOVENORMAL); - } else { - NVIC_SetPriority(irq_type[inst], IRQ_PRIORITY_NORMAL); - } - NVIC_ClearPendingIRQ(irq_type[inst]); - NVIC_EnableIRQ(irq_type[inst]); + NVIC_SetVector(irq_type[inst], irq_entry[inst]); + if (inst == HAL_DMA_INST_AUDMA) { + NVIC_SetPriority(irq_type[inst], IRQ_PRIORITY_ABOVENORMAL); + } else { + NVIC_SetPriority(irq_type[inst], IRQ_PRIORITY_NORMAL); + } + NVIC_ClearPendingIRQ(irq_type[inst]); + NVIC_EnableIRQ(irq_type[inst]); } /* Shutdown the DMA */ -static void hal_dma_close_inst(enum HAL_DMA_INST_T inst) -{ - NVIC_DisableIRQ(irq_type[inst]); - dma[inst]->DMACONFIG = 0; +static void hal_dma_close_inst(enum HAL_DMA_INST_T inst) { + NVIC_DisableIRQ(irq_type[inst]); + dma[inst]->DMACONFIG = 0; } -static bool hal_dma_chan_busy_inst(enum HAL_DMA_INST_T inst, uint8_t hwch) -{ - return !!(dma[inst]->ENBLDCHNS & DMA_STAT_CHAN(hwch)); +static bool hal_dma_chan_busy_inst(enum HAL_DMA_INST_T inst, uint8_t hwch) { + return !!(dma[inst]->ENBLDCHNS & DMA_STAT_CHAN(hwch)); } -static void hal_dma_handle_chan_irq(enum HAL_DMA_INST_T inst, uint8_t hwch) -{ - uint32_t remains; - struct HAL_DMA_DESC_T *lli; - bool tcint, errint; +static void hal_dma_handle_chan_irq(enum HAL_DMA_INST_T inst, uint8_t hwch) { + uint32_t remains; + struct HAL_DMA_DESC_T *lli; + bool tcint, errint; - /* Check counter terminal status */ - tcint = !!(dma[inst]->INTTCSTAT & DMA_STAT_CHAN(hwch)); - /* Check error terminal status */ - errint = !!(dma[inst]->INTERRSTAT & DMA_STAT_CHAN(hwch)); + /* Check counter terminal status */ + tcint = !!(dma[inst]->INTTCSTAT & DMA_STAT_CHAN(hwch)); + /* Check error terminal status */ + errint = !!(dma[inst]->INTERRSTAT & DMA_STAT_CHAN(hwch)); - if (tcint || errint) { - if (tcint) { - /* Clear terminate counter Interrupt pending */ - dma[inst]->INTTCCLR = DMA_STAT_CHAN(hwch); - } - if (errint) { - /* Clear error counter Interrupt pending */ - dma[inst]->INTERRCLR = DMA_STAT_CHAN(hwch); - } - - if (handler[inst][hwch]) { - remains = GET_BITFIELD(dma[inst]->CH[hwch].CONTROL, DMA_CONTROL_TRANSFERSIZE); - lli = (struct HAL_DMA_DESC_T *)dma[inst]->CH[hwch].LLI; - handler[inst][hwch](generate_chan(inst, hwch), remains, errint, lli); - } + if (tcint || errint) { + if (tcint) { + /* Clear terminate counter Interrupt pending */ + dma[inst]->INTTCCLR = DMA_STAT_CHAN(hwch); } -} - -static void hal_dma_irq_handler(enum HAL_DMA_INST_T inst) -{ - uint8_t hwch; - - for (hwch = 0; hwch < DMA_NUMBER_CHANNELS; hwch++) { - if ((dma[inst]->INTSTAT & DMA_STAT_CHAN(hwch)) == 0) { - continue; - } - hal_dma_handle_chan_irq(inst, hwch); + if (errint) { + /* Clear error counter Interrupt pending */ + dma[inst]->INTERRCLR = DMA_STAT_CHAN(hwch); } + + if (handler[inst][hwch]) { + remains = + GET_BITFIELD(dma[inst]->CH[hwch].CONTROL, DMA_CONTROL_TRANSFERSIZE); + lli = (struct HAL_DMA_DESC_T *)dma[inst]->CH[hwch].LLI; + handler[inst][hwch](generate_chan(inst, hwch), remains, errint, lli); + } + } } -static void hal_audma_irq_handler(void) -{ - hal_dma_irq_handler(HAL_DMA_INST_AUDMA); +static void hal_dma_irq_handler(enum HAL_DMA_INST_T inst) { + uint8_t hwch; + + for (hwch = 0; hwch < DMA_NUMBER_CHANNELS; hwch++) { + if ((dma[inst]->INTSTAT & DMA_STAT_CHAN(hwch)) == 0) { + continue; + } + hal_dma_handle_chan_irq(inst, hwch); + } +} + +static void hal_audma_irq_handler(void) { + hal_dma_irq_handler(HAL_DMA_INST_AUDMA); } #if (CHIP_HAS_DMA > 1) -static void hal_gpdma_irq_handler(void) -{ - hal_dma_irq_handler(HAL_DMA_INST_GPDMA); +static void hal_gpdma_irq_handler(void) { + hal_dma_irq_handler(HAL_DMA_INST_GPDMA); } #endif -static enum HAL_DMA_RET_T hal_dma_init_control(uint32_t *ctrl, - const struct HAL_DMA_CH_CFG_T *cfg, - int tc_irq) -{ - uint32_t addr_inc; - enum HAL_DMA_FLOW_CONTROL_T type; +static enum HAL_DMA_RET_T +hal_dma_init_control(uint32_t *ctrl, const struct HAL_DMA_CH_CFG_T *cfg, + int tc_irq) { + uint32_t addr_inc; + enum HAL_DMA_FLOW_CONTROL_T type; - if (cfg->src_tsize > HAL_DMA_MAX_DESC_XFER_SIZE) { - return HAL_DMA_ERR; - } + if (cfg->src_tsize > HAL_DMA_MAX_DESC_XFER_SIZE) { + return HAL_DMA_ERR; + } #ifdef CHIP_BEST1000 - type = cfg->type; + type = cfg->type; #else - type = cfg->type & ~HAL_DMA_FLOW_FLAG_MASK; + type = cfg->type & ~HAL_DMA_FLOW_FLAG_MASK; #endif - switch (type) { - case HAL_DMA_FLOW_M2M_DMA: - addr_inc = DMA_CONTROL_SI | DMA_CONTROL_DI; - break; - case HAL_DMA_FLOW_M2P_DMA: - case HAL_DMA_FLOW_M2P_PERIPH: - addr_inc = DMA_CONTROL_SI; - break; - case HAL_DMA_FLOW_P2M_DMA: - case HAL_DMA_FLOW_P2M_PERIPH: - addr_inc = DMA_CONTROL_DI; - break; - case HAL_DMA_FLOW_P2P_DMA: - case HAL_DMA_FLOW_P2P_DSTPERIPH: - case HAL_DMA_FLOW_P2P_SRCPERIPH: - addr_inc = 0; - break; - default: - return HAL_DMA_ERR; - } + switch (type) { + case HAL_DMA_FLOW_M2M_DMA: + addr_inc = DMA_CONTROL_SI | DMA_CONTROL_DI; + break; + case HAL_DMA_FLOW_M2P_DMA: + case HAL_DMA_FLOW_M2P_PERIPH: + addr_inc = DMA_CONTROL_SI; + break; + case HAL_DMA_FLOW_P2M_DMA: + case HAL_DMA_FLOW_P2M_PERIPH: + addr_inc = DMA_CONTROL_DI; + break; + case HAL_DMA_FLOW_P2P_DMA: + case HAL_DMA_FLOW_P2P_DSTPERIPH: + case HAL_DMA_FLOW_P2P_SRCPERIPH: + addr_inc = 0; + break; + default: + return HAL_DMA_ERR; + } #ifndef CHIP_BEST1000 - if (cfg->type & HAL_DMA_FLOW_FLAG_SI) { - addr_inc |= DMA_CONTROL_SI; - } - if (cfg->type & HAL_DMA_FLOW_FLAG_DI) { - addr_inc |= DMA_CONTROL_DI; - } + if (cfg->type & HAL_DMA_FLOW_FLAG_SI) { + addr_inc |= DMA_CONTROL_SI; + } + if (cfg->type & HAL_DMA_FLOW_FLAG_DI) { + addr_inc |= DMA_CONTROL_DI; + } #endif - *ctrl = DMA_CONTROL_TRANSFERSIZE(cfg->src_tsize) | - DMA_CONTROL_SBSIZE(cfg->src_bsize) | - DMA_CONTROL_DBSIZE(cfg->dst_bsize) | - DMA_CONTROL_SWIDTH(cfg->src_width) | - DMA_CONTROL_DWIDTH(cfg->dst_width) | - (tc_irq ? DMA_CONTROL_TC_IRQ : 0) | - addr_inc; + *ctrl = + DMA_CONTROL_TRANSFERSIZE(cfg->src_tsize) | + DMA_CONTROL_SBSIZE(cfg->src_bsize) | DMA_CONTROL_DBSIZE(cfg->dst_bsize) | + DMA_CONTROL_SWIDTH(cfg->src_width) | DMA_CONTROL_DWIDTH(cfg->dst_width) | + (tc_irq ? DMA_CONTROL_TC_IRQ : 0) | addr_inc; - return HAL_DMA_OK; + return HAL_DMA_OK; } /***************************************************************************** @@ -410,648 +399,643 @@ static enum HAL_DMA_RET_T hal_dma_init_control(uint32_t *ctrl, enum HAL_DMA_RET_T hal_dma_init_desc(struct HAL_DMA_DESC_T *desc, const struct HAL_DMA_CH_CFG_T *cfg, const struct HAL_DMA_DESC_T *next, - int tc_irq) -{ - uint32_t ctrl; - enum HAL_DMA_RET_T ret; - enum HAL_DMA_FLOW_CONTROL_T type; + int tc_irq) { + uint32_t ctrl; + enum HAL_DMA_RET_T ret; + enum HAL_DMA_FLOW_CONTROL_T type; - ret = hal_dma_init_control(&ctrl, cfg, tc_irq); - if (ret != HAL_DMA_OK) { - return ret; - } + ret = hal_dma_init_control(&ctrl, cfg, tc_irq); + if (ret != HAL_DMA_OK) { + return ret; + } #ifdef CHIP_BEST1000 - type = cfg->type; + type = cfg->type; #else - type = cfg->type & ~HAL_DMA_FLOW_FLAG_MASK; + type = cfg->type & ~HAL_DMA_FLOW_FLAG_MASK; #endif - if (type == HAL_DMA_FLOW_M2M_DMA || type == HAL_DMA_FLOW_M2P_DMA || - type == HAL_DMA_FLOW_M2P_PERIPH) { - desc->src = cfg->src; - } else { - desc->src = hal_dma_get_periph_addr(cfg->src_periph); - } - if (type == HAL_DMA_FLOW_M2M_DMA || type == HAL_DMA_FLOW_P2M_DMA || - type == HAL_DMA_FLOW_P2M_PERIPH) { - desc->dst = cfg->dst; - } else { - desc->dst = hal_dma_get_periph_addr(cfg->dst_periph); - } - desc->lli = (uint32_t)next; - desc->ctrl = ctrl; + if (type == HAL_DMA_FLOW_M2M_DMA || type == HAL_DMA_FLOW_M2P_DMA || + type == HAL_DMA_FLOW_M2P_PERIPH) { + desc->src = cfg->src; + } else { + desc->src = hal_dma_get_periph_addr(cfg->src_periph); + } + if (type == HAL_DMA_FLOW_M2M_DMA || type == HAL_DMA_FLOW_P2M_DMA || + type == HAL_DMA_FLOW_P2M_PERIPH) { + desc->dst = cfg->dst; + } else { + desc->dst = hal_dma_get_periph_addr(cfg->dst_periph); + } + desc->lli = (uint32_t)next; + desc->ctrl = ctrl; - return HAL_DMA_OK; + return HAL_DMA_OK; } enum HAL_DMA_RET_T hal_dma_sg_2d_start(const struct HAL_DMA_DESC_T *desc, const struct HAL_DMA_CH_CFG_T *cfg, const struct HAL_DMA_2D_CFG_T *src_2d, - const struct HAL_DMA_2D_CFG_T *dst_2d) -{ - enum HAL_DMA_INST_T inst; - uint8_t hwch; - enum HAL_DMA_FLOW_CONTROL_T type; - uint8_t src_periph, dst_periph; - enum HAL_DMA_INST_T periph_inst; - int ret; - uint32_t irq_mask, try_burst; - uint32_t lock; + const struct HAL_DMA_2D_CFG_T *dst_2d) { + enum HAL_DMA_INST_T inst; + uint8_t hwch; + enum HAL_DMA_FLOW_CONTROL_T type; + uint8_t src_periph, dst_periph; + enum HAL_DMA_INST_T periph_inst; + int ret; + uint32_t irq_mask, try_burst; + uint32_t lock; - inst = get_inst_from_chan(cfg->ch); - hwch = get_hwch_from_chan(cfg->ch); + inst = get_inst_from_chan(cfg->ch); + hwch = get_hwch_from_chan(cfg->ch); - ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); - ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); + ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); + ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); #ifdef CHIP_BEST1000 - type = cfg->type; + type = cfg->type; #else - type = cfg->type & ~HAL_DMA_FLOW_FLAG_MASK; + type = cfg->type & ~HAL_DMA_FLOW_FLAG_MASK; #endif - if (type == HAL_DMA_FLOW_M2M_DMA || type == HAL_DMA_FLOW_M2P_DMA || - type == HAL_DMA_FLOW_M2P_PERIPH) { - src_periph = 0; - } else { - ret = get_index_from_periph(cfg->src_periph, &periph_inst, &src_periph); - ASSERT(ret == 0, "Failed to get src periph: %d", cfg->src_periph); + if (type == HAL_DMA_FLOW_M2M_DMA || type == HAL_DMA_FLOW_M2P_DMA || + type == HAL_DMA_FLOW_M2P_PERIPH) { + src_periph = 0; + } else { + ret = get_index_from_periph(cfg->src_periph, &periph_inst, &src_periph); + ASSERT(ret == 0, "Failed to get src periph: %d", cfg->src_periph); #ifdef DMA_REMAP - if (periph_remap_bitmap[periph_inst] & (1 << src_periph)) { - periph_inst ^= 1; - ret = get_remap_index_from_periph(periph_inst, cfg->src_periph, &src_periph); - ASSERT(ret == 0, "Failed to get remap src periph: %d", cfg->src_periph); - } -#endif - ASSERT(inst == periph_inst, "Mismatch inst in chan=0x%02x and src periph %d", cfg->ch, cfg->src_periph); + if (periph_remap_bitmap[periph_inst] & (1 << src_periph)) { + periph_inst ^= 1; + ret = get_remap_index_from_periph(periph_inst, cfg->src_periph, + &src_periph); + ASSERT(ret == 0, "Failed to get remap src periph: %d", cfg->src_periph); } - if (type == HAL_DMA_FLOW_M2M_DMA || type == HAL_DMA_FLOW_P2M_DMA || - type == HAL_DMA_FLOW_P2M_PERIPH) { - dst_periph = 0; - } else { - ret = get_index_from_periph(cfg->dst_periph, &periph_inst, &dst_periph); - ASSERT(ret == 0, "Failed to get dst periph: %d", cfg->dst_periph); +#endif + ASSERT(inst == periph_inst, + "Mismatch inst in chan=0x%02x and src periph %d", cfg->ch, + cfg->src_periph); + } + if (type == HAL_DMA_FLOW_M2M_DMA || type == HAL_DMA_FLOW_P2M_DMA || + type == HAL_DMA_FLOW_P2M_PERIPH) { + dst_periph = 0; + } else { + ret = get_index_from_periph(cfg->dst_periph, &periph_inst, &dst_periph); + ASSERT(ret == 0, "Failed to get dst periph: %d", cfg->dst_periph); #ifdef DMA_REMAP - if (periph_remap_bitmap[periph_inst] & (1 << dst_periph)) { - periph_inst ^= 1; - ret = get_remap_index_from_periph(periph_inst, cfg->dst_periph, &dst_periph); - ASSERT(ret == 0, "Failed to get remap dst periph: %d", cfg->dst_periph); - } + if (periph_remap_bitmap[periph_inst] & (1 << dst_periph)) { + periph_inst ^= 1; + ret = get_remap_index_from_periph(periph_inst, cfg->dst_periph, + &dst_periph); + ASSERT(ret == 0, "Failed to get remap dst periph: %d", cfg->dst_periph); + } #endif - ASSERT(inst == periph_inst, "Mismatch inst in chan=0x%02x and dst periph %d", cfg->ch, cfg->dst_periph); - } + ASSERT(inst == periph_inst, + "Mismatch inst in chan=0x%02x and dst periph %d", cfg->ch, + cfg->dst_periph); + } - if (!chan_enabled[inst][hwch]) { - // Not acquired - return HAL_DMA_ERR; - } - if (hal_dma_chan_busy_inst(inst, hwch)) { - // Busy - return HAL_DMA_ERR; - } + if (!chan_enabled[inst][hwch]) { + // Not acquired + return HAL_DMA_ERR; + } + if (hal_dma_chan_busy_inst(inst, hwch)) { + // Busy + return HAL_DMA_ERR; + } - if (cfg->handler == NULL) { - irq_mask = 0; - } else { - irq_mask = DMA_CONFIG_ERR_IRQMASK | DMA_CONFIG_TC_IRQMASK; - handler[inst][hwch] = cfg->handler; - } + if (cfg->handler == NULL) { + irq_mask = 0; + } else { + irq_mask = DMA_CONFIG_ERR_IRQMASK | DMA_CONFIG_TC_IRQMASK; + handler[inst][hwch] = cfg->handler; + } - try_burst = cfg->try_burst ? DMA_CONFIG_TRY_BURST : 0; + try_burst = cfg->try_burst ? DMA_CONFIG_TRY_BURST : 0; - /* Reset the Interrupt status */ - dma[inst]->INTTCCLR = DMA_STAT_CHAN(hwch); - dma[inst]->INTERRCLR = DMA_STAT_CHAN(hwch); + /* Reset the Interrupt status */ + dma[inst]->INTTCCLR = DMA_STAT_CHAN(hwch); + dma[inst]->INTERRCLR = DMA_STAT_CHAN(hwch); - dma[inst]->CH[hwch].SRCADDR = desc->src; - dma[inst]->CH[hwch].DSTADDR = desc->dst; - dma[inst]->CH[hwch].LLI = desc->lli; - dma[inst]->CH[hwch].CONTROL = desc->ctrl; - dma[inst]->CH[hwch].CONFIG = DMA_CONFIG_SRCPERIPH(src_periph) | - DMA_CONFIG_DSTPERIPH(dst_periph) | - DMA_CONFIG_TRANSFERTYPE(type) | - irq_mask | - try_burst; + dma[inst]->CH[hwch].SRCADDR = desc->src; + dma[inst]->CH[hwch].DSTADDR = desc->dst; + dma[inst]->CH[hwch].LLI = desc->lli; + dma[inst]->CH[hwch].CONTROL = desc->ctrl; + dma[inst]->CH[hwch].CONFIG = + DMA_CONFIG_SRCPERIPH(src_periph) | DMA_CONFIG_DSTPERIPH(dst_periph) | + DMA_CONFIG_TRANSFERTYPE(type) | irq_mask | try_burst; #ifndef CHIP_BEST1000 - if (src_2d) { - dma[inst]->_2D[hwch].SRCX = DMA_2D_MODIFY(src_2d->xmodify) | DMA_2D_COUNT(src_2d->xcount); - dma[inst]->_2D[hwch].SRCY = DMA_2D_MODIFY(src_2d->ymodify) | DMA_2D_COUNT(src_2d->ycount); - dma[inst]->_2D[hwch].CTRL |= DMA_2D_CTRL_SRC_EN; - } else { - dma[inst]->_2D[hwch].CTRL &= ~DMA_2D_CTRL_SRC_EN; - } - if (dst_2d) { - dma[inst]->_2D[hwch].DSTX = DMA_2D_MODIFY(dst_2d->xmodify) | DMA_2D_COUNT(dst_2d->xcount); - dma[inst]->_2D[hwch].DSTY = DMA_2D_MODIFY(dst_2d->ymodify) | DMA_2D_COUNT(dst_2d->ycount); - dma[inst]->_2D[hwch].CTRL |= DMA_2D_CTRL_DST_EN; - } else { - dma[inst]->_2D[hwch].CTRL &= ~DMA_2D_CTRL_DST_EN; - } + if (src_2d) { + dma[inst]->_2D[hwch].SRCX = + DMA_2D_MODIFY(src_2d->xmodify) | DMA_2D_COUNT(src_2d->xcount); + dma[inst]->_2D[hwch].SRCY = + DMA_2D_MODIFY(src_2d->ymodify) | DMA_2D_COUNT(src_2d->ycount); + dma[inst]->_2D[hwch].CTRL |= DMA_2D_CTRL_SRC_EN; + } else { + dma[inst]->_2D[hwch].CTRL &= ~DMA_2D_CTRL_SRC_EN; + } + if (dst_2d) { + dma[inst]->_2D[hwch].DSTX = + DMA_2D_MODIFY(dst_2d->xmodify) | DMA_2D_COUNT(dst_2d->xcount); + dma[inst]->_2D[hwch].DSTY = + DMA_2D_MODIFY(dst_2d->ymodify) | DMA_2D_COUNT(dst_2d->ycount); + dma[inst]->_2D[hwch].CTRL |= DMA_2D_CTRL_DST_EN; + } else { + dma[inst]->_2D[hwch].CTRL &= ~DMA_2D_CTRL_DST_EN; + } #endif - lock = int_lock(); - if (cfg->start_cb) { - cfg->start_cb(cfg->ch); - } - dma[inst]->CH[hwch].CONFIG |= DMA_CONFIG_EN; - int_unlock(lock); + lock = int_lock(); + if (cfg->start_cb) { + cfg->start_cb(cfg->ch); + } + dma[inst]->CH[hwch].CONFIG |= DMA_CONFIG_EN; + int_unlock(lock); - return HAL_DMA_OK; + return HAL_DMA_OK; } enum HAL_DMA_RET_T hal_dma_sg_start(const struct HAL_DMA_DESC_T *desc, - const struct HAL_DMA_CH_CFG_T *cfg) -{ - return hal_dma_sg_2d_start(desc, cfg, NULL, NULL); + const struct HAL_DMA_CH_CFG_T *cfg) { + return hal_dma_sg_2d_start(desc, cfg, NULL, NULL); } -enum HAL_DMA_RET_T hal_dma_start(const struct HAL_DMA_CH_CFG_T *cfg) -{ - struct HAL_DMA_DESC_T desc; - enum HAL_DMA_RET_T ret; +enum HAL_DMA_RET_T hal_dma_start(const struct HAL_DMA_CH_CFG_T *cfg) { + struct HAL_DMA_DESC_T desc; + enum HAL_DMA_RET_T ret; - ret = hal_dma_init_desc(&desc, cfg, NULL, 1); - if (ret != HAL_DMA_OK) { - return ret; - } + ret = hal_dma_init_desc(&desc, cfg, NULL, 1); + if (ret != HAL_DMA_OK) { + return ret; + } - ret = hal_dma_sg_start(&desc, cfg); - if (ret != HAL_DMA_OK) { - return ret; - } + ret = hal_dma_sg_start(&desc, cfg); + if (ret != HAL_DMA_OK) { + return ret; + } - return HAL_DMA_OK; + return HAL_DMA_OK; } -uint32_t hal_dma_cancel(uint8_t ch) -{ - enum HAL_DMA_INST_T inst; - uint8_t hwch; - uint32_t remains; +uint32_t hal_dma_cancel(uint8_t ch) { + enum HAL_DMA_INST_T inst; + uint8_t hwch; + uint32_t remains; - inst = get_inst_from_chan(ch); - hwch = get_hwch_from_chan(ch); + inst = get_inst_from_chan(ch); + hwch = get_hwch_from_chan(ch); - ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); - ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); + ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); + ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); - dma[inst]->CH[hwch].CONFIG &= ~DMA_CONFIG_EN; - dma[inst]->INTTCCLR = DMA_STAT_CHAN(hwch); - dma[inst]->INTERRCLR = DMA_STAT_CHAN(hwch); + dma[inst]->CH[hwch].CONFIG &= ~DMA_CONFIG_EN; + dma[inst]->INTTCCLR = DMA_STAT_CHAN(hwch); + dma[inst]->INTERRCLR = DMA_STAT_CHAN(hwch); - remains = GET_BITFIELD(dma[inst]->CH[hwch].CONTROL, DMA_CONTROL_TRANSFERSIZE); + remains = GET_BITFIELD(dma[inst]->CH[hwch].CONTROL, DMA_CONTROL_TRANSFERSIZE); - return remains; + return remains; } -uint32_t hal_dma_stop(uint8_t ch) -{ - enum HAL_DMA_INST_T inst; - uint8_t hwch; - uint8_t retry = 0; - const uint8_t max_retry = 10; +uint32_t hal_dma_stop(uint8_t ch) { + enum HAL_DMA_INST_T inst; + uint8_t hwch; + uint8_t retry = 0; + const uint8_t max_retry = 10; - inst = get_inst_from_chan(ch); - hwch = get_hwch_from_chan(ch); + inst = get_inst_from_chan(ch); + hwch = get_hwch_from_chan(ch); - ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); - ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); + ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); + ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); - dma[inst]->CH[hwch].CONFIG |= DMA_CONFIG_HALT; + dma[inst]->CH[hwch].CONFIG |= DMA_CONFIG_HALT; #if 1 - while ((dma[inst]->CH[hwch].CONFIG & DMA_CONFIG_ACTIVE) && (++retry < max_retry)) { - if (retry <= 3) { - hal_sys_timer_delay_us(10); - } else { - hal_dma_delay(1); - } + while ((dma[inst]->CH[hwch].CONFIG & DMA_CONFIG_ACTIVE) && + (++retry < max_retry)) { + if (retry <= 3) { + hal_sys_timer_delay_us(10); + } else { + hal_dma_delay(1); } + } #else - while (dma[inst]->CH[hwch].CONFIG & DMA_CONFIG_ACTIVE); + while (dma[inst]->CH[hwch].CONFIG & DMA_CONFIG_ACTIVE) + ; #endif - return hal_dma_cancel(ch); + return hal_dma_cancel(ch); } -uint8_t hal_dma_get_chan(enum HAL_DMA_PERIPH_T periph, enum HAL_DMA_GET_CHAN_T policy) -{ - enum HAL_DMA_INST_T inst; - int ret; - uint8_t i, hwch; - uint8_t got = HAL_DMA_CHAN_NONE; - uint32_t lock; +uint8_t hal_dma_get_chan(enum HAL_DMA_PERIPH_T periph, + enum HAL_DMA_GET_CHAN_T policy) { + enum HAL_DMA_INST_T inst; + int ret; + uint8_t i, hwch; + uint8_t got = HAL_DMA_CHAN_NONE; + uint32_t lock; - ASSERT(policy == HAL_DMA_HIGH_PRIO || policy == HAL_DMA_LOW_PRIO || policy == HAL_DMA_LOW_PRIO_ONLY, - "Invalid DMA policy: %d", policy); + ASSERT(policy == HAL_DMA_HIGH_PRIO || policy == HAL_DMA_LOW_PRIO || + policy == HAL_DMA_LOW_PRIO_ONLY, + "Invalid DMA policy: %d", policy); - if (periph == HAL_GPDMA_MEM) { - inst = HAL_DMA_INST_GPDMA; - } else if (periph == HAL_AUDMA_MEM) { - inst = HAL_DMA_INST_AUDMA; - } else { - ret = get_index_from_periph(periph, &inst, &i); - ASSERT(ret == 0, "Invalid DMA periph: %d", periph); + if (periph == HAL_GPDMA_MEM) { + inst = HAL_DMA_INST_GPDMA; + } else if (periph == HAL_AUDMA_MEM) { + inst = HAL_DMA_INST_AUDMA; + } else { + ret = get_index_from_periph(periph, &inst, &i); + ASSERT(ret == 0, "Invalid DMA periph: %d", periph); #ifdef DMA_REMAP - if (periph_remap_bitmap[inst] & (1 << i)) { - inst ^= 1; - } + if (periph_remap_bitmap[inst] & (1 << i)) { + inst ^= 1; + } #endif - } + } - lock = int_lock(); - for (i = 0; i < DMA_NUMBER_CHANNELS; i++) { - if (policy == HAL_DMA_HIGH_PRIO) { - hwch = i; - } else if (policy == HAL_DMA_LOW_PRIO) { - hwch = DMA_NUMBER_CHANNELS - 1 - i; - } else { - hwch = DMA_NUMBER_CHANNELS - 1 - i; - if (hwch < 6) { - break; - } - } - - if (!chan_enabled[inst][hwch] && !hal_dma_chan_busy_inst(inst, hwch)) { - chan_enabled[inst][hwch] = true; - got = generate_chan(inst, hwch); - dma[inst]->DMACONFIG |= DMA_DMACONFIG_CLK_EN(1 << hwch); - break; - } - } - int_unlock(lock); - - return got; -} - -void hal_dma_free_chan(uint8_t ch) -{ - enum HAL_DMA_INST_T inst; - uint8_t hwch; - uint32_t lock; - - inst = get_inst_from_chan(ch); - hwch = get_hwch_from_chan(ch); - - ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); - ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); - ASSERT(chan_enabled[inst][hwch], "DMA chan not enabled: inst=%u hwch=%u", inst, hwch); - - hal_dma_cancel(ch); - - lock = int_lock(); - chan_enabled[inst][hwch] = false; - dma[inst]->DMACONFIG &= ~DMA_DMACONFIG_CLK_EN(1 << hwch); - int_unlock(lock); -} - -uint32_t hal_dma_get_cur_src_addr(uint8_t ch) -{ - enum HAL_DMA_INST_T inst; - uint8_t hwch; - - inst = get_inst_from_chan(ch); - hwch = get_hwch_from_chan(ch); - - ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); - ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); - - return dma[inst]->CH[hwch].SRCADDR; -} - -uint32_t hal_dma_get_cur_dst_addr(uint8_t ch) -{ - enum HAL_DMA_INST_T inst; - uint8_t hwch; - - inst = get_inst_from_chan(ch); - hwch = get_hwch_from_chan(ch); - - ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); - ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); - - return dma[inst]->CH[hwch].DSTADDR; -} - -void SRAM_TEXT_LOC hal_dma_get_cur_src_remain_and_addr(uint8_t ch, uint32_t *remain, uint32_t *src) -{ - enum HAL_DMA_INST_T inst; - uint8_t hwch; - uint32_t lock; - uint32_t size[2]; - uint32_t srcaddr[2]; - - inst = get_inst_from_chan(ch); - hwch = get_hwch_from_chan(ch); - - ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); - ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); - - lock = int_lock(); - size[0] = dma[inst]->CH[hwch].CONTROL; - srcaddr[0] = dma[inst]->CH[hwch].SRCADDR; - size[1] = dma[inst]->CH[hwch].CONTROL; - srcaddr[1] = dma[inst]->CH[hwch].SRCADDR; - int_unlock(lock); - - size[0] = GET_BITFIELD(size[0], DMA_CONTROL_TRANSFERSIZE); - size[1] = GET_BITFIELD(size[1], DMA_CONTROL_TRANSFERSIZE); - - if (size[0] == size[1]) { - *remain = size[0]; - *src = srcaddr[0]; + lock = int_lock(); + for (i = 0; i < DMA_NUMBER_CHANNELS; i++) { + if (policy == HAL_DMA_HIGH_PRIO) { + hwch = i; + } else if (policy == HAL_DMA_LOW_PRIO) { + hwch = DMA_NUMBER_CHANNELS - 1 - i; } else { - *remain = size[1]; - *src = srcaddr[1]; + hwch = DMA_NUMBER_CHANNELS - 1 - i; + if (hwch < 6) { + break; + } } + if (!chan_enabled[inst][hwch] && !hal_dma_chan_busy_inst(inst, hwch)) { + chan_enabled[inst][hwch] = true; + got = generate_chan(inst, hwch); + dma[inst]->DMACONFIG |= DMA_DMACONFIG_CLK_EN(1 << hwch); + break; + } + } + int_unlock(lock); + + return got; +} + +void hal_dma_free_chan(uint8_t ch) { + enum HAL_DMA_INST_T inst; + uint8_t hwch; + uint32_t lock; + + inst = get_inst_from_chan(ch); + hwch = get_hwch_from_chan(ch); + + ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); + ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); + ASSERT(chan_enabled[inst][hwch], "DMA chan not enabled: inst=%u hwch=%u", + inst, hwch); + + hal_dma_cancel(ch); + + lock = int_lock(); + chan_enabled[inst][hwch] = false; + dma[inst]->DMACONFIG &= ~DMA_DMACONFIG_CLK_EN(1 << hwch); + int_unlock(lock); +} + +uint32_t hal_dma_get_cur_src_addr(uint8_t ch) { + enum HAL_DMA_INST_T inst; + uint8_t hwch; + + inst = get_inst_from_chan(ch); + hwch = get_hwch_from_chan(ch); + + ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); + ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); + + return dma[inst]->CH[hwch].SRCADDR; +} + +uint32_t hal_dma_get_cur_dst_addr(uint8_t ch) { + enum HAL_DMA_INST_T inst; + uint8_t hwch; + + inst = get_inst_from_chan(ch); + hwch = get_hwch_from_chan(ch); + + ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); + ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); + + return dma[inst]->CH[hwch].DSTADDR; +} + +void SRAM_TEXT_LOC hal_dma_get_cur_src_remain_and_addr(uint8_t ch, + uint32_t *remain, + uint32_t *src) { + enum HAL_DMA_INST_T inst; + uint8_t hwch; + uint32_t lock; + uint32_t size[2]; + uint32_t srcaddr[2]; + + inst = get_inst_from_chan(ch); + hwch = get_hwch_from_chan(ch); + + ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); + ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); + + lock = int_lock(); + size[0] = dma[inst]->CH[hwch].CONTROL; + srcaddr[0] = dma[inst]->CH[hwch].SRCADDR; + size[1] = dma[inst]->CH[hwch].CONTROL; + srcaddr[1] = dma[inst]->CH[hwch].SRCADDR; + int_unlock(lock); + + size[0] = GET_BITFIELD(size[0], DMA_CONTROL_TRANSFERSIZE); + size[1] = GET_BITFIELD(size[1], DMA_CONTROL_TRANSFERSIZE); + + if (size[0] == size[1]) { + *remain = size[0]; + *src = srcaddr[0]; + } else { + *remain = size[1]; + *src = srcaddr[1]; + } + + return; +} + +enum HAL_DMA_RET_T hal_dma_irq_run_chan(uint8_t ch) { + enum HAL_DMA_INST_T inst; + uint8_t hwch; + + inst = get_inst_from_chan(ch); + hwch = get_hwch_from_chan(ch); + + ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); + ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); + + if ((dma[inst]->INTSTAT & DMA_STAT_CHAN(hwch)) == 0) { + return HAL_DMA_ERR; + } + + hal_dma_handle_chan_irq(inst, hwch); + + return HAL_DMA_OK; +} + +bool hal_dma_chan_busy(uint8_t ch) { + enum HAL_DMA_INST_T inst; + uint8_t hwch; + + inst = get_inst_from_chan(ch); + hwch = get_hwch_from_chan(ch); + + ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); + ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); + + return hal_dma_chan_busy_inst(inst, hwch); +} + +bool hal_dma_busy(void) { + enum HAL_DMA_INST_T inst; + int hwch; + + for (inst = HAL_DMA_INST_AUDMA; inst < HAL_DMA_INST_QTY; inst++) { + for (hwch = chan_start[inst]; hwch < chan_num[inst]; hwch++) { + if (hal_dma_chan_busy_inst(inst, hwch)) { + return true; + } + } + } + + return false; +} + +uint32_t hal_dma_get_sg_remain_size(uint8_t ch) { + enum HAL_DMA_INST_T inst; + uint8_t hwch; + uint32_t remains; + const struct HAL_DMA_DESC_T *desc, *first; + + inst = get_inst_from_chan(ch); + hwch = get_hwch_from_chan(ch); + + ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); + ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); + + remains = GET_BITFIELD(dma[inst]->CH[hwch].CONTROL, DMA_CONTROL_TRANSFERSIZE); + first = (const struct HAL_DMA_DESC_T *)dma[inst]->CH[hwch].LLI; + desc = first; + while (desc) { + remains += GET_BITFIELD(desc->ctrl, DMA_CONTROL_TRANSFERSIZE); + desc = (const struct HAL_DMA_DESC_T *)desc->lli; + if (desc == first) { + break; + } + } + + return remains; +} + +void hal_dma_tc_irq_enable(uint8_t ch) { +#if !(defined(CHIP_BEST1000) || defined(CHIP_BEST2000) || \ + defined(CHIP_BEST3001) || defined(CHIP_BEST3005)) + enum HAL_DMA_INST_T inst; + uint8_t hwch; + uint32_t lock; + + inst = get_inst_from_chan(ch); + hwch = get_hwch_from_chan(ch); + + ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); + ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); + + lock = int_lock(); +#ifdef CHIP_BEST2300 + if (inst == HAL_DMA_INST_AUDMA) { + hal_cmu_dma_tc_irq_set_chan(hwch); + } +#else + dma[inst]->DMACONFIG |= DMA_DMACONFIG_TC_IRQ_EN(1 << hwch); +#endif + int_unlock(lock); +#endif +} + +void hal_dma_tc_irq_disable(uint8_t ch) { +#if !(defined(CHIP_BEST1000) || defined(CHIP_BEST2000) || \ + defined(CHIP_BEST3001) || defined(CHIP_BEST3005)) + enum HAL_DMA_INST_T inst; + uint8_t hwch; + uint32_t lock; + + inst = get_inst_from_chan(ch); + hwch = get_hwch_from_chan(ch); + + ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); + ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); + + lock = int_lock(); +#ifdef CHIP_BEST2300 + if (inst == HAL_DMA_INST_AUDMA) { + hal_cmu_dma_tc_irq_clear_chan(hwch); + } +#else + dma[inst]->DMACONFIG &= ~DMA_DMACONFIG_TC_IRQ_EN(1 << hwch); +#endif + int_unlock(lock); +#endif +} + +void hal_dma_set_burst_addr_inc(uint8_t ch, + const struct HAL_DMA_BURST_ADDR_INC_T *inc) { +#if !(defined(CHIP_BEST1000) || defined(CHIP_BEST2000) || \ + defined(CHIP_BEST3001) || defined(CHIP_BEST3005)) + enum HAL_DMA_INST_T inst; + uint8_t hwch; + uint32_t lock; + + inst = get_inst_from_chan(ch); + hwch = get_hwch_from_chan(ch); + + ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); + ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); + + lock = int_lock(); + if (inc && inc->src_inc_en) { + dma[inst]->CH[hwch].CONTROL |= DMA_CONTROL_BURST_SI; + dma[inst]->_2D[hwch].SRC_INC = SET_BITFIELD( + dma[inst]->_2D[hwch].SRC_INC, DMA_BURST_SRC_INC_VAL, inc->src_inc_val); + } else { + dma[inst]->CH[hwch].CONTROL &= ~DMA_CONTROL_BURST_SI; + } + if (inc && inc->dst_inc_en) { + dma[inst]->CH[hwch].CONTROL |= DMA_CONTROL_BURST_DI; + dma[inst]->_2D[hwch].DST_INC = SET_BITFIELD( + dma[inst]->_2D[hwch].DST_INC, DMA_BURST_DST_INC_VAL, inc->dst_inc_val); + } else { + dma[inst]->CH[hwch].CONTROL &= ~DMA_CONTROL_BURST_DI; + } + int_unlock(lock); +#endif +} + +void hal_dma_clear_burst_addr_inc(uint8_t ch) { + hal_dma_set_burst_addr_inc(ch, NULL); +} + +void hal_dma_set_desc_burst_addr_inc( + struct HAL_DMA_DESC_T *desc, const struct HAL_DMA_BURST_ADDR_INC_T *inc) { +#if !(defined(CHIP_BEST1000) || defined(CHIP_BEST2000) || \ + defined(CHIP_BEST3001) || defined(CHIP_BEST3005)) + if (inc && inc->src_inc_en) { + desc->ctrl |= DMA_CONTROL_BURST_SI; + } else { + desc->ctrl &= ~DMA_CONTROL_BURST_SI; + } + if (inc && inc->dst_inc_en) { + desc->ctrl |= DMA_CONTROL_BURST_DI; + } else { + desc->ctrl &= ~DMA_CONTROL_BURST_DI; + } +#endif +} + +void hal_dma_clear_desc_burst_addr_inc(struct HAL_DMA_DESC_T *desc) { + hal_dma_set_desc_burst_addr_inc(desc, NULL); +} + +#ifdef DMA_REMAP +void hal_dma_remap_periph(enum HAL_DMA_PERIPH_T periph, int enable) { + enum HAL_DMA_INST_T inst1, inst2; + uint8_t index1, index2; + int ret; + uint32_t lock; + + // Tag the periph + ret = get_index_from_periph(periph, &inst1, &index1); + ASSERT(ret == 0, "Invalid DMA periph for remap1: %d", periph); + + // Tag the peer periph + inst2 = inst1 ^ 1; + ret = get_remap_index_from_periph(inst2, periph, &index2); + ASSERT(ret == 0, "Invalid DMA periph for remap2: %d", periph); + + lock = int_lock(); + if (enable) { + periph_remap_bitmap[inst1] |= (1 << index1); + periph_remap_bitmap[inst2] |= (1 << index2); +#ifndef CHIP_BEST1000 + // For best2000, index1 == index2 + hal_cmu_dma_swap_enable(index1); +#endif + } else { + periph_remap_bitmap[inst1] &= ~(1 << index1); + periph_remap_bitmap[inst2] &= ~(1 << index2); +#ifndef CHIP_BEST1000 + hal_cmu_dma_swap_disable(index1); +#endif + } + int_unlock(lock); +} +#endif + +void hal_dma_open(void) { + enum HAL_DMA_INST_T inst; + + if (dma_opened) { return; -} + } -enum HAL_DMA_RET_T hal_dma_irq_run_chan(uint8_t ch) -{ - enum HAL_DMA_INST_T inst; - uint8_t hwch; - - inst = get_inst_from_chan(ch); - hwch = get_hwch_from_chan(ch); - - ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); - ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); - - if ((dma[inst]->INTSTAT & DMA_STAT_CHAN(hwch)) == 0) { - return HAL_DMA_ERR; - } - - hal_dma_handle_chan_irq(inst, hwch); - - return HAL_DMA_OK; -} - -bool hal_dma_chan_busy(uint8_t ch) -{ - enum HAL_DMA_INST_T inst; - uint8_t hwch; - - inst = get_inst_from_chan(ch); - hwch = get_hwch_from_chan(ch); - - ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); - ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); - - return hal_dma_chan_busy_inst(inst, hwch); -} - -bool hal_dma_busy(void) -{ - enum HAL_DMA_INST_T inst; - int hwch; - - for (inst = HAL_DMA_INST_AUDMA; inst < HAL_DMA_INST_QTY; inst++) { - for (hwch = chan_start[inst]; hwch < chan_num[inst]; hwch++) { - if (hal_dma_chan_busy_inst(inst, hwch)) { - return true; - } - } - } - - return false; -} - -uint32_t hal_dma_get_sg_remain_size(uint8_t ch) -{ - enum HAL_DMA_INST_T inst; - uint8_t hwch; - uint32_t remains; - const struct HAL_DMA_DESC_T *desc, *first; - - inst = get_inst_from_chan(ch); - hwch = get_hwch_from_chan(ch); - - ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); - ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); - - remains = GET_BITFIELD(dma[inst]->CH[hwch].CONTROL, DMA_CONTROL_TRANSFERSIZE); - first = (const struct HAL_DMA_DESC_T *)dma[inst]->CH[hwch].LLI; - desc = first; - while (desc) { - remains += GET_BITFIELD(desc->ctrl, DMA_CONTROL_TRANSFERSIZE); - desc = (const struct HAL_DMA_DESC_T *)desc->lli; - if (desc == first) { - break; - } - } - - return remains; -} - -void hal_dma_tc_irq_enable(uint8_t ch) -{ -#if !(defined(CHIP_BEST1000) || defined(CHIP_BEST2000) || defined(CHIP_BEST3001) || defined(CHIP_BEST3005)) - enum HAL_DMA_INST_T inst; - uint8_t hwch; - uint32_t lock; - - inst = get_inst_from_chan(ch); - hwch = get_hwch_from_chan(ch); - - ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); - ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); - - lock = int_lock(); -#ifdef CHIP_BEST2300 - if (inst == HAL_DMA_INST_AUDMA) { - hal_cmu_dma_tc_irq_set_chan(hwch); - } -#else - dma[inst]->DMACONFIG |= DMA_DMACONFIG_TC_IRQ_EN(1 << hwch); -#endif - int_unlock(lock); -#endif -} - -void hal_dma_tc_irq_disable(uint8_t ch) -{ -#if !(defined(CHIP_BEST1000) || defined(CHIP_BEST2000) || defined(CHIP_BEST3001) || defined(CHIP_BEST3005)) - enum HAL_DMA_INST_T inst; - uint8_t hwch; - uint32_t lock; - - inst = get_inst_from_chan(ch); - hwch = get_hwch_from_chan(ch); - - ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); - ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); - - lock = int_lock(); -#ifdef CHIP_BEST2300 - if (inst == HAL_DMA_INST_AUDMA) { - hal_cmu_dma_tc_irq_clear_chan(hwch); - } -#else - dma[inst]->DMACONFIG &= ~DMA_DMACONFIG_TC_IRQ_EN(1 << hwch); -#endif - int_unlock(lock); -#endif -} - -void hal_dma_set_burst_addr_inc(uint8_t ch, const struct HAL_DMA_BURST_ADDR_INC_T *inc) -{ -#if !(defined(CHIP_BEST1000) || defined(CHIP_BEST2000) || defined(CHIP_BEST3001) || defined(CHIP_BEST3005)) - enum HAL_DMA_INST_T inst; - uint8_t hwch; - uint32_t lock; - - inst = get_inst_from_chan(ch); - hwch = get_hwch_from_chan(ch); - - ASSERT(inst < HAL_DMA_INST_QTY, err_invalid_inst, inst); - ASSERT(hwch < DMA_NUMBER_CHANNELS, err_invalid_chan[inst], hwch); - - lock = int_lock(); - if (inc && inc->src_inc_en) { - dma[inst]->CH[hwch].CONTROL |= DMA_CONTROL_BURST_SI; - dma[inst]->_2D[hwch].SRC_INC = SET_BITFIELD(dma[inst]->_2D[hwch].SRC_INC, DMA_BURST_SRC_INC_VAL, inc->src_inc_val); - } else { - dma[inst]->CH[hwch].CONTROL &= ~DMA_CONTROL_BURST_SI; - } - if (inc && inc->dst_inc_en) { - dma[inst]->CH[hwch].CONTROL |= DMA_CONTROL_BURST_DI; - dma[inst]->_2D[hwch].DST_INC = SET_BITFIELD(dma[inst]->_2D[hwch].DST_INC, DMA_BURST_DST_INC_VAL, inc->dst_inc_val); - } else { - dma[inst]->CH[hwch].CONTROL &= ~DMA_CONTROL_BURST_DI; - } - int_unlock(lock); -#endif -} - -void hal_dma_clear_burst_addr_inc(uint8_t ch) -{ - hal_dma_set_burst_addr_inc(ch, NULL); -} - -void hal_dma_set_desc_burst_addr_inc(struct HAL_DMA_DESC_T *desc, const struct HAL_DMA_BURST_ADDR_INC_T *inc) -{ -#if !(defined(CHIP_BEST1000) || defined(CHIP_BEST2000) || defined(CHIP_BEST3001) || defined(CHIP_BEST3005)) - if (inc && inc->src_inc_en) { - desc->ctrl |= DMA_CONTROL_BURST_SI; - } else { - desc->ctrl &= ~DMA_CONTROL_BURST_SI; - } - if (inc && inc->dst_inc_en) { - desc->ctrl |= DMA_CONTROL_BURST_DI; - } else { - desc->ctrl &= ~DMA_CONTROL_BURST_DI; - } -#endif -} - -void hal_dma_clear_desc_burst_addr_inc(struct HAL_DMA_DESC_T *desc) -{ - hal_dma_set_desc_burst_addr_inc(desc, NULL); -} - -#ifdef DMA_REMAP -void hal_dma_remap_periph(enum HAL_DMA_PERIPH_T periph, int enable) -{ - enum HAL_DMA_INST_T inst1, inst2; - uint8_t index1, index2; - int ret; - uint32_t lock; - - // Tag the periph - ret = get_index_from_periph(periph, &inst1, &index1); - ASSERT(ret == 0, "Invalid DMA periph for remap1: %d", periph); - - // Tag the peer periph - inst2 = inst1 ^ 1; - ret = get_remap_index_from_periph(inst2, periph, &index2); - ASSERT(ret == 0, "Invalid DMA periph for remap2: %d", periph); - - lock = int_lock(); - if (enable) { - periph_remap_bitmap[inst1] |= (1 << index1); - periph_remap_bitmap[inst2] |= (1 << index2); -#ifndef CHIP_BEST1000 - // For best2000, index1 == index2 - hal_cmu_dma_swap_enable(index1); -#endif - } else { - periph_remap_bitmap[inst1] &= ~(1 << index1); - periph_remap_bitmap[inst2] &= ~(1 << index2); -#ifndef CHIP_BEST1000 - hal_cmu_dma_swap_disable(index1); -#endif - } - int_unlock(lock); -} -#endif - -void hal_dma_open(void) -{ - enum HAL_DMA_INST_T inst; - - if (dma_opened) { - return; - } - - for (inst = 0; inst < HAL_DMA_INST_QTY; inst++) { - hal_dma_open_inst(inst); - } + for (inst = 0; inst < HAL_DMA_INST_QTY; inst++) { + hal_dma_open_inst(inst); + } #ifdef DMA_REMAP #ifdef CHIP_BEST1000 - if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_4) { - hal_dma_remap_periph(HAL_AUDMA_I2S0_RX, 1); - hal_dma_remap_periph(HAL_AUDMA_I2S0_TX, 1); - hal_dma_remap_periph(HAL_AUDMA_SPDIF0_RX, 1); - hal_dma_remap_periph(HAL_AUDMA_SPDIF0_TX, 1); - } + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_4) { + hal_dma_remap_periph(HAL_AUDMA_I2S0_RX, 1); + hal_dma_remap_periph(HAL_AUDMA_I2S0_TX, 1); + hal_dma_remap_periph(HAL_AUDMA_SPDIF0_RX, 1); + hal_dma_remap_periph(HAL_AUDMA_SPDIF0_TX, 1); + } #endif #endif - dma_opened = true; + dma_opened = true; } -void hal_dma_close(void) -{ - enum HAL_DMA_INST_T inst; +void hal_dma_close(void) { + enum HAL_DMA_INST_T inst; - if (!dma_opened) { - return; - } + if (!dma_opened) { + return; + } - for (inst = 0; inst < HAL_DMA_INST_QTY; inst++) { - hal_dma_close_inst(inst); - } + for (inst = 0; inst < HAL_DMA_INST_QTY; inst++) { + hal_dma_close_inst(inst); + } - dma_opened = false; + dma_opened = false; } #ifdef CORE_SLEEP_POWER_DOWN -void hal_dma_sleep(void) -{ - enum HAL_DMA_INST_T inst; +void hal_dma_sleep(void) { + enum HAL_DMA_INST_T inst; - for (inst = 0; inst < HAL_DMA_INST_QTY; inst++) { - saved_dma_regs[inst] = dma[inst]->DMACONFIG; - } + for (inst = 0; inst < HAL_DMA_INST_QTY; inst++) { + saved_dma_regs[inst] = dma[inst]->DMACONFIG; + } } -void hal_dma_wakeup(void) -{ - enum HAL_DMA_INST_T inst; +void hal_dma_wakeup(void) { + enum HAL_DMA_INST_T inst; - for (inst = 0; inst < HAL_DMA_INST_QTY; inst++) { - dma[inst]->DMACONFIG = saved_dma_regs[inst]; - } + for (inst = 0; inst < HAL_DMA_INST_QTY; inst++) { + dma[inst]->DMACONFIG = saved_dma_regs[inst]; + } } #endif -HAL_DMA_DELAY_FUNC hal_dma_set_delay_func(HAL_DMA_DELAY_FUNC new_func) -{ - HAL_DMA_DELAY_FUNC old_func = dma_delay; - dma_delay = new_func; - return old_func; +HAL_DMA_DELAY_FUNC hal_dma_set_delay_func(HAL_DMA_DELAY_FUNC new_func) { + HAL_DMA_DELAY_FUNC old_func = dma_delay; + dma_delay = new_func; + return old_func; } - diff --git a/platform/hal/hal_gpadc.c b/platform/hal/hal_gpadc.c index 7149498..257dded 100644 --- a/platform/hal/hal_gpadc.c +++ b/platform/hal/hal_gpadc.c @@ -17,229 +17,230 @@ #ifndef GPADC_CHIP_SPECIFIC -#include "stddef.h" #include "cmsis_nvic.h" +#include "hal_analogif.h" #include "hal_gpadc.h" #include "hal_trace.h" -#include "hal_analogif.h" #include "pmu.h" +#include "stddef.h" -#define HAL_GPADC_TRACE(n, s, ...) //TRACE(n, s, ##__VA_ARGS__) +#define HAL_GPADC_TRACE(n, s, ...) // TRACE(n, s, ##__VA_ARGS__) #define VBAT_DIV_ALWAYS_ON -#define gpadc_reg_read(reg,val) pmu_read(reg,val) -#define gpadc_reg_write(reg,val) pmu_write(reg,val) +#define gpadc_reg_read(reg, val) pmu_read(reg, val) +#define gpadc_reg_write(reg, val) pmu_write(reg, val) // Battery voltage = gpadc voltage * 4 // adc rate 0~2v(10bit) // Battery_voltage:Adc_rate = 4:1 -#define HAL_GPADC_MVOLT_A 800 -#define HAL_GPADC_MVOLT_B 1050 -#define HAL_GPADC_CALIB_DEFAULT_A 428 -#define HAL_GPADC_CALIB_DEFAULT_B 565 +#define HAL_GPADC_MVOLT_A 800 +#define HAL_GPADC_MVOLT_B 1050 +#define HAL_GPADC_CALIB_DEFAULT_A 428 +#define HAL_GPADC_CALIB_DEFAULT_B 565 #if 0 -#elif defined(CHIP_BEST1400) || defined(CHIP_BEST1402) || \ - defined(CHIP_BEST2000) || defined(CHIP_BEST2001) || \ - defined(CHIP_BEST2300) || defined(CHIP_BEST2300A) || defined(CHIP_BEST2300P) || \ - defined(CHIP_BEST3001) || defined(CHIP_BEST3005) +#elif defined(CHIP_BEST1400) || defined(CHIP_BEST1402) || \ + defined(CHIP_BEST2000) || defined(CHIP_BEST2001) || \ + defined(CHIP_BEST2300) || defined(CHIP_BEST2300A) || \ + defined(CHIP_BEST2300P) || defined(CHIP_BEST3001) || \ + defined(CHIP_BEST3005) #if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) || defined(CHIP_BEST2001) enum GPADC_REG_T { - GPADC_REG_VBAT_EN = 0x02, - GPADC_REG_INTVL_EN = 0x18, - GPADC_REG_INTVL_VAL = 0x1C, - GPADC_REG_START = 0x4F, - GPADC_REG_CH_EN = 0x1D, - GPADC_REG_INT_MASK = 0x1F, - GPADC_REG_INT_EN = 0x20, - GPADC_REG_INT_RAW_STS = 0x50, - GPADC_REG_INT_MSKED_STS = 0x51, - GPADC_REG_INT_CLR = 0x51, - GPADC_REG_CH0_DATA = 0x56, + GPADC_REG_VBAT_EN = 0x02, + GPADC_REG_INTVL_EN = 0x18, + GPADC_REG_INTVL_VAL = 0x1C, + GPADC_REG_START = 0x4F, + GPADC_REG_CH_EN = 0x1D, + GPADC_REG_INT_MASK = 0x1F, + GPADC_REG_INT_EN = 0x20, + GPADC_REG_INT_RAW_STS = 0x50, + GPADC_REG_INT_MSKED_STS = 0x51, + GPADC_REG_INT_CLR = 0x51, + GPADC_REG_CH0_DATA = 0x56, }; #else enum GPADC_REG_T { - GPADC_REG_VBAT_EN = 0x02, - GPADC_REG_INTVL_EN = 0x1F, - GPADC_REG_INTVL_VAL = 0x23, - GPADC_REG_START = 0x4F, - GPADC_REG_CH_EN = 0x24, - GPADC_REG_INT_MASK = 0x26, - GPADC_REG_INT_EN = 0x27, + GPADC_REG_VBAT_EN = 0x02, + GPADC_REG_INTVL_EN = 0x1F, + GPADC_REG_INTVL_VAL = 0x23, + GPADC_REG_START = 0x4F, + GPADC_REG_CH_EN = 0x24, + GPADC_REG_INT_MASK = 0x26, + GPADC_REG_INT_EN = 0x27, #if defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) - GPADC_REG_INT_RAW_STS = 0x52, - GPADC_REG_INT_MSKED_STS = 0x53, - GPADC_REG_INT_CLR = 0x51, + GPADC_REG_INT_RAW_STS = 0x52, + GPADC_REG_INT_MSKED_STS = 0x53, + GPADC_REG_INT_CLR = 0x51, #else - GPADC_REG_INT_RAW_STS = 0x50, - GPADC_REG_INT_MSKED_STS = 0x51, - GPADC_REG_INT_CLR = 0x51, + GPADC_REG_INT_RAW_STS = 0x50, + GPADC_REG_INT_MSKED_STS = 0x51, + GPADC_REG_INT_CLR = 0x51, #endif - GPADC_REG_CH0_DATA = 0x56, + GPADC_REG_CH0_DATA = 0x56, }; #endif // GPADC_REG_VBAT_EN -#define REG_PU_VBAT_DIV (1 << 15) +#define REG_PU_VBAT_DIV (1 << 15) // GPADC_REG_INTVL_EN -#define GPADC_INTERVAL_MODE (1 << 12) +#define GPADC_INTERVAL_MODE (1 << 12) // GPADC_REG_START -#define GPADC_START (1 << 5) -#define KEY_START (1 << 4) +#define GPADC_START (1 << 5) +#define KEY_START (1 << 4) // GPADC_REG_CH_EN -#define CHAN_EN_REG_SHIFT 0 -#define CHAN_EN_REG_MASK (0xFF << CHAN_EN_REG_SHIFT) -#define CHAN_EN_REG(n) BITFIELD_VAL(CHAN_EN_REG, n) +#define CHAN_EN_REG_SHIFT 0 +#define CHAN_EN_REG_MASK (0xFF << CHAN_EN_REG_SHIFT) +#define CHAN_EN_REG(n) BITFIELD_VAL(CHAN_EN_REG, n) // GPADC_REG_INT_MASK -#define KEY_ERR1_INTR_MSK (1 << 12) -#define KEY_ERR0_INTR_MSK (1 << 11) -#define KEY_PRESS_INTR_MSK (1 << 10) -#define KEY_RELEASE_INTR_MSK (1 << 9) -#define SAMPLE_DONE_INTR_MSK (1 << 8) -#define CHAN_DATA_INTR_MSK_SHIFT 0 -#define CHAN_DATA_INTR_MSK_MASK (0xFF << CHAN_DATA_INTR_MSK_SHIFT) -#define CHAN_DATA_INTR_MSK(n) BITFIELD_VAL(CHAN_DATA_INTR_MSK, n) +#define KEY_ERR1_INTR_MSK (1 << 12) +#define KEY_ERR0_INTR_MSK (1 << 11) +#define KEY_PRESS_INTR_MSK (1 << 10) +#define KEY_RELEASE_INTR_MSK (1 << 9) +#define SAMPLE_DONE_INTR_MSK (1 << 8) +#define CHAN_DATA_INTR_MSK_SHIFT 0 +#define CHAN_DATA_INTR_MSK_MASK (0xFF << CHAN_DATA_INTR_MSK_SHIFT) +#define CHAN_DATA_INTR_MSK(n) BITFIELD_VAL(CHAN_DATA_INTR_MSK, n) // GPADC_REG_INT_EN -#define KEY_ERR1_INTR_EN (1 << 12) -#define KEY_ERR0_INTR_EN (1 << 11) -#define KEY_PRESS_INTR_EN (1 << 10) -#define KEY_RELEASE_INTR_EN (1 << 9) -#define SAMPLE_DONE_INTR_EN (1 << 8) -#define CHAN_DATA_INTR_EN_SHIFT 0 -#define CHAN_DATA_INTR_EN_MASK (0xFF << CHAN_DATA_INTR_EN_SHIFT) -#define CHAN_DATA_INTR_EN(n) BITFIELD_VAL(CHAN_DATA_INTR_EN, n) +#define KEY_ERR1_INTR_EN (1 << 12) +#define KEY_ERR0_INTR_EN (1 << 11) +#define KEY_PRESS_INTR_EN (1 << 10) +#define KEY_RELEASE_INTR_EN (1 << 9) +#define SAMPLE_DONE_INTR_EN (1 << 8) +#define CHAN_DATA_INTR_EN_SHIFT 0 +#define CHAN_DATA_INTR_EN_MASK (0xFF << CHAN_DATA_INTR_EN_SHIFT) +#define CHAN_DATA_INTR_EN(n) BITFIELD_VAL(CHAN_DATA_INTR_EN, n) // GPADC_REG_INT_RAW_STS -#define KEY_ERR1_INTR (1 << 12) -#define KEY_ERR0_INTR (1 << 11) -#define KEY_PRESS_INTR (1 << 10) -#define KEY_RELEASE_INTR (1 << 9) -#define SAMPLE_PERIOD_DONE_INTR (1 << 8) -#define CHAN_DATA_VALID_INTR_SHIFT 0 -#define CHAN_DATA_VALID_INTR_MASK (0xFF << CHAN_DATA_VALID_INTR_SHIFT) -#define CHAN_DATA_VALID_INTR(n) BITFIELD_VAL(CHAN_DATA_VALID_INTR, n) +#define KEY_ERR1_INTR (1 << 12) +#define KEY_ERR0_INTR (1 << 11) +#define KEY_PRESS_INTR (1 << 10) +#define KEY_RELEASE_INTR (1 << 9) +#define SAMPLE_PERIOD_DONE_INTR (1 << 8) +#define CHAN_DATA_VALID_INTR_SHIFT 0 +#define CHAN_DATA_VALID_INTR_MASK (0xFF << CHAN_DATA_VALID_INTR_SHIFT) +#define CHAN_DATA_VALID_INTR(n) BITFIELD_VAL(CHAN_DATA_VALID_INTR, n) // GPADC_REG_INT_MSKED_STS -#define KEY_ERR1_INTR_MSKED (1 << 12) -#define KEY_ERR0_INTR_MSKED (1 << 11) -#define KEY_PRESS_INTR_MSKED (1 << 10) -#define KEY_RELEASE_INTR_MSKED (1 << 9) -#define SAMPLE_DONE_INTR_MSKED (1 << 8) -#define CHAN_DATA_INTR_MSKED_SHIFT 0 -#define CHAN_DATA_INTR_MSKED_MASK (0xFF << CHAN_DATA_INTR_MSKED_SHIFT) -#define CHAN_DATA_INTR_MSKED(n) BITFIELD_VAL(CHAN_DATA_INTR_MSKED, n) +#define KEY_ERR1_INTR_MSKED (1 << 12) +#define KEY_ERR0_INTR_MSKED (1 << 11) +#define KEY_PRESS_INTR_MSKED (1 << 10) +#define KEY_RELEASE_INTR_MSKED (1 << 9) +#define SAMPLE_DONE_INTR_MSKED (1 << 8) +#define CHAN_DATA_INTR_MSKED_SHIFT 0 +#define CHAN_DATA_INTR_MSKED_MASK (0xFF << CHAN_DATA_INTR_MSKED_SHIFT) +#define CHAN_DATA_INTR_MSKED(n) BITFIELD_VAL(CHAN_DATA_INTR_MSKED, n) // GPADC_REG_INT_CLR -#define KEY_ERR1_INTR_CLR (1 << 12) -#define KEY_ERR0_INTR_CLR (1 << 11) -#define KEY_PRESS_INTR_CLR (1 << 10) -#define KEY_RELEASE_INTR_CLR (1 << 9) -#define SAMPLE_DONE_INTR_CLR (1 << 8) -#define CHAN_DATA_INTR_CLR_SHIFT 0 -#define CHAN_DATA_INTR_CLR_MASK (0xFF << CHAN_DATA_INTR_CLR_SHIFT) -#define CHAN_DATA_INTR_CLR(n) BITFIELD_VAL(CHAN_DATA_INTR_CLR, n) +#define KEY_ERR1_INTR_CLR (1 << 12) +#define KEY_ERR0_INTR_CLR (1 << 11) +#define KEY_PRESS_INTR_CLR (1 << 10) +#define KEY_RELEASE_INTR_CLR (1 << 9) +#define SAMPLE_DONE_INTR_CLR (1 << 8) +#define CHAN_DATA_INTR_CLR_SHIFT 0 +#define CHAN_DATA_INTR_CLR_MASK (0xFF << CHAN_DATA_INTR_CLR_SHIFT) +#define CHAN_DATA_INTR_CLR(n) BITFIELD_VAL(CHAN_DATA_INTR_CLR, n) // GPADC_REG_CH0_DATA -#define DATA_CHAN0_SHIFT 0 -#define DATA_CHAN0_MASK (0x3FF << DATA_CHAN0_SHIFT) -#define DATA_CHAN0(n) BITFIELD_VAL(DATA_CHAN0, n) +#define DATA_CHAN0_SHIFT 0 +#define DATA_CHAN0_MASK (0x3FF << DATA_CHAN0_SHIFT) +#define DATA_CHAN0(n) BITFIELD_VAL(DATA_CHAN0, n) #elif defined(CHIP_BEST1000) enum GPADC_REG_T { - GPADC_REG_VBAT_EN = 0x45, - GPADC_REG_INTVL_EN = 0x60, - GPADC_REG_INTVL_VAL = 0x64, - GPADC_REG_START = 0x65, - GPADC_REG_CH_EN = 0x65, - GPADC_REG_INT_MASK = 0x67, - GPADC_REG_INT_EN = 0x68, - GPADC_REG_INT_RAW_STS = 0x69, - GPADC_REG_INT_MSKED_STS = 0x6A, - GPADC_REG_INT_CLR = 0x6A, - GPADC_REG_CH0_DATA = 0x78, + GPADC_REG_VBAT_EN = 0x45, + GPADC_REG_INTVL_EN = 0x60, + GPADC_REG_INTVL_VAL = 0x64, + GPADC_REG_START = 0x65, + GPADC_REG_CH_EN = 0x65, + GPADC_REG_INT_MASK = 0x67, + GPADC_REG_INT_EN = 0x68, + GPADC_REG_INT_RAW_STS = 0x69, + GPADC_REG_INT_MSKED_STS = 0x6A, + GPADC_REG_INT_CLR = 0x6A, + GPADC_REG_CH0_DATA = 0x78, }; // GPADC_REG_VBAT_EN -#define REG_PU_VBAT_DIV (1 << 0) +#define REG_PU_VBAT_DIV (1 << 0) // GPADC_REG_INTVL_EN -#define GPADC_INTERVAL_MODE (1 << 12) +#define GPADC_INTERVAL_MODE (1 << 12) // GPADC_REG_START -#define KEY_START (1 << 9) -#define GPADC_START (1 << 8) +#define KEY_START (1 << 9) +#define GPADC_START (1 << 8) // GPADC_REG_CH_EN -#define CHAN_EN_REG_SHIFT 0 -#define CHAN_EN_REG_MASK (0xFF << CHAN_EN_REG_SHIFT) -#define CHAN_EN_REG(n) BITFIELD_VAL(CHAN_EN_REG, n) +#define CHAN_EN_REG_SHIFT 0 +#define CHAN_EN_REG_MASK (0xFF << CHAN_EN_REG_SHIFT) +#define CHAN_EN_REG(n) BITFIELD_VAL(CHAN_EN_REG, n) // GPADC_REG_INT_MASK -#define KEY_ERR1_INTR_MSK (1 << 12) -#define KEY_ERR0_INTR_MSK (1 << 11) -#define KEY_PRESS_INTR_MSK (1 << 10) -#define KEY_RELEASE_INTR_MSK (1 << 9) -#define SAMPLE_DONE_INTR_MSK (1 << 8) -#define CHAN_DATA_INTR_MSK_SHIFT 0 -#define CHAN_DATA_INTR_MSK_MASK (0xFF << CHAN_DATA_INTR_MSK_SHIFT) -#define CHAN_DATA_INTR_MSK(n) BITFIELD_VAL(CHAN_DATA_INTR_MSK, n) +#define KEY_ERR1_INTR_MSK (1 << 12) +#define KEY_ERR0_INTR_MSK (1 << 11) +#define KEY_PRESS_INTR_MSK (1 << 10) +#define KEY_RELEASE_INTR_MSK (1 << 9) +#define SAMPLE_DONE_INTR_MSK (1 << 8) +#define CHAN_DATA_INTR_MSK_SHIFT 0 +#define CHAN_DATA_INTR_MSK_MASK (0xFF << CHAN_DATA_INTR_MSK_SHIFT) +#define CHAN_DATA_INTR_MSK(n) BITFIELD_VAL(CHAN_DATA_INTR_MSK, n) // GPADC_REG_INT_EN -#define KEY_ERR1_INTR_EN (1 << 12) -#define KEY_ERR0_INTR_EN (1 << 11) -#define KEY_PRESS_INTR_EN (1 << 10) -#define KEY_RELEASE_INTR_EN (1 << 9) -#define SAMPLE_DONE_INTR_EN (1 << 8) -#define CHAN_DATA_INTR_EN_SHIFT 0 -#define CHAN_DATA_INTR_EN_MASK (0xFF << CHAN_DATA_INTR_EN_SHIFT) -#define CHAN_DATA_INTR_EN(n) BITFIELD_VAL(CHAN_DATA_INTR_EN, n) +#define KEY_ERR1_INTR_EN (1 << 12) +#define KEY_ERR0_INTR_EN (1 << 11) +#define KEY_PRESS_INTR_EN (1 << 10) +#define KEY_RELEASE_INTR_EN (1 << 9) +#define SAMPLE_DONE_INTR_EN (1 << 8) +#define CHAN_DATA_INTR_EN_SHIFT 0 +#define CHAN_DATA_INTR_EN_MASK (0xFF << CHAN_DATA_INTR_EN_SHIFT) +#define CHAN_DATA_INTR_EN(n) BITFIELD_VAL(CHAN_DATA_INTR_EN, n) // GPADC_REG_INT_RAW_STS -#define KEY_ERR1_INTR (1 << 12) -#define KEY_ERR0_INTR (1 << 11) -#define KEY_PRESS_INTR (1 << 10) -#define KEY_RELEASE_INTR (1 << 9) -#define SAMPLE_PERIOD_DONE_INTR (1 << 8) -#define CHAN_DATA_VALID_INTR_SHIFT 0 -#define CHAN_DATA_VALID_INTR_MASK (0xFF << CHAN_DATA_VALID_INTR_SHIFT) -#define CHAN_DATA_VALID_INTR(n) BITFIELD_VAL(CHAN_DATA_VALID_INTR, n) +#define KEY_ERR1_INTR (1 << 12) +#define KEY_ERR0_INTR (1 << 11) +#define KEY_PRESS_INTR (1 << 10) +#define KEY_RELEASE_INTR (1 << 9) +#define SAMPLE_PERIOD_DONE_INTR (1 << 8) +#define CHAN_DATA_VALID_INTR_SHIFT 0 +#define CHAN_DATA_VALID_INTR_MASK (0xFF << CHAN_DATA_VALID_INTR_SHIFT) +#define CHAN_DATA_VALID_INTR(n) BITFIELD_VAL(CHAN_DATA_VALID_INTR, n) // GPADC_REG_INT_MSKED_STS -#define KEY_ERR1_INTR_MSKED (1 << 12) -#define KEY_ERR0_INTR_MSKED (1 << 11) -#define KEY_PRESS_INTR_MSKED (1 << 10) -#define KEY_RELEASE_INTR_MSKED (1 << 9) -#define SAMPLE_DONE_INTR_MSKED (1 << 8) -#define CHAN_DATA_INTR_MSKED_SHIFT 0 -#define CHAN_DATA_INTR_MSKED_MASK (0xFF << CHAN_DATA_INTR_MSKED_SHIFT) -#define CHAN_DATA_INTR_MSKED(n) BITFIELD_VAL(CHAN_DATA_INTR_MSKED, n) +#define KEY_ERR1_INTR_MSKED (1 << 12) +#define KEY_ERR0_INTR_MSKED (1 << 11) +#define KEY_PRESS_INTR_MSKED (1 << 10) +#define KEY_RELEASE_INTR_MSKED (1 << 9) +#define SAMPLE_DONE_INTR_MSKED (1 << 8) +#define CHAN_DATA_INTR_MSKED_SHIFT 0 +#define CHAN_DATA_INTR_MSKED_MASK (0xFF << CHAN_DATA_INTR_MSKED_SHIFT) +#define CHAN_DATA_INTR_MSKED(n) BITFIELD_VAL(CHAN_DATA_INTR_MSKED, n) // GPADC_REG_INT_CLR -#define KEY_ERR1_INTR_CLR (1 << 12) -#define KEY_ERR0_INTR_CLR (1 << 11) -#define KEY_PRESS_INTR_CLR (1 << 10) -#define KEY_RELEASE_INTR_CLR (1 << 9) -#define SAMPLE_DONE_INTR_CLR (1 << 8) -#define CHAN_DATA_INTR_CLR_SHIFT 0 -#define CHAN_DATA_INTR_CLR_MASK (0xFF << CHAN_DATA_INTR_CLR_SHIFT) -#define CHAN_DATA_INTR_CLR(n) BITFIELD_VAL(CHAN_DATA_INTR_CLR, n) +#define KEY_ERR1_INTR_CLR (1 << 12) +#define KEY_ERR0_INTR_CLR (1 << 11) +#define KEY_PRESS_INTR_CLR (1 << 10) +#define KEY_RELEASE_INTR_CLR (1 << 9) +#define SAMPLE_DONE_INTR_CLR (1 << 8) +#define CHAN_DATA_INTR_CLR_SHIFT 0 +#define CHAN_DATA_INTR_CLR_MASK (0xFF << CHAN_DATA_INTR_CLR_SHIFT) +#define CHAN_DATA_INTR_CLR(n) BITFIELD_VAL(CHAN_DATA_INTR_CLR, n) // GPADC_REG_CH0_DATA -#define DATA_CHAN0_SHIFT 0 -#define DATA_CHAN0_MASK (0x3FF << DATA_CHAN0_SHIFT) -#define DATA_CHAN0(n) BITFIELD_VAL(DATA_CHAN0, n) +#define DATA_CHAN0_SHIFT 0 +#define DATA_CHAN0_MASK (0x3FF << DATA_CHAN0_SHIFT) +#define DATA_CHAN0(n) BITFIELD_VAL(DATA_CHAN0, n) #else #error "Please update GPADC register definitions" @@ -254,538 +255,538 @@ static bool g_adcCalibrated = false; static HAL_GPADC_EVENT_CB_T gpadc_event_cb[HAL_GPADC_CHAN_QTY]; static enum HAL_GPADC_ATP_T gpadc_atp[HAL_GPADC_CHAN_QTY]; -static enum HAL_GPADC_ATP_T hal_gpadc_get_min_atp(void) -{ - enum HAL_GPADC_CHAN_T ch; - enum HAL_GPADC_ATP_T atp = HAL_GPADC_ATP_NULL; +static enum HAL_GPADC_ATP_T hal_gpadc_get_min_atp(void) { + enum HAL_GPADC_CHAN_T ch; + enum HAL_GPADC_ATP_T atp = HAL_GPADC_ATP_NULL; - for (ch = HAL_GPADC_CHAN_0; ch < HAL_GPADC_CHAN_QTY; ch++) { - if (gpadc_atp[ch] != HAL_GPADC_ATP_NULL) { - if (atp == HAL_GPADC_ATP_NULL || - (uint32_t)gpadc_atp[ch] < (uint32_t)atp) { - atp = gpadc_atp[ch]; - } - } + for (ch = HAL_GPADC_CHAN_0; ch < HAL_GPADC_CHAN_QTY; ch++) { + if (gpadc_atp[ch] != HAL_GPADC_ATP_NULL) { + if (atp == HAL_GPADC_ATP_NULL || + (uint32_t)gpadc_atp[ch] < (uint32_t)atp) { + atp = gpadc_atp[ch]; + } } + } - return atp; + return atp; } -static void hal_gpadc_update_atp(void) -{ - enum HAL_GPADC_ATP_T atp; - uint16_t val; +static void hal_gpadc_update_atp(void) { + enum HAL_GPADC_ATP_T atp; + uint16_t val; - atp = hal_gpadc_get_min_atp(); + atp = hal_gpadc_get_min_atp(); - if (atp == HAL_GPADC_ATP_NULL || atp == HAL_GPADC_ATP_ONESHOT) { - gpadc_reg_read(GPADC_REG_INTVL_EN, &val); - val &= ~GPADC_INTERVAL_MODE; - gpadc_reg_write(GPADC_REG_INTVL_EN, val); - } else { - gpadc_reg_read(GPADC_REG_INTVL_EN, &val); - val |= GPADC_INTERVAL_MODE; - gpadc_reg_write(GPADC_REG_INTVL_EN, val); - val = atp * 1000 / 1024; - gpadc_reg_write(GPADC_REG_INTVL_VAL, val); - } + if (atp == HAL_GPADC_ATP_NULL || atp == HAL_GPADC_ATP_ONESHOT) { + gpadc_reg_read(GPADC_REG_INTVL_EN, &val); + val &= ~GPADC_INTERVAL_MODE; + gpadc_reg_write(GPADC_REG_INTVL_EN, val); + } else { + gpadc_reg_read(GPADC_REG_INTVL_EN, &val); + val |= GPADC_INTERVAL_MODE; + gpadc_reg_write(GPADC_REG_INTVL_EN, val); + val = atp * 1000 / 1024; + gpadc_reg_write(GPADC_REG_INTVL_VAL, val); + } } -static int hal_gpadc_adc2volt_calib(void) -{ - int32_t y1, y2, x1, x2; - unsigned short efuse_a = 0; - unsigned short efuse_b = 0; +static int hal_gpadc_adc2volt_calib(void) { + int32_t y1, y2, x1, x2; + unsigned short efuse_a = 0; + unsigned short efuse_b = 0; - if (!g_adcCalibrated) - { - y1 = HAL_GPADC_MVOLT_A*1000; - y2 = HAL_GPADC_MVOLT_B*1000; + if (!g_adcCalibrated) { + y1 = HAL_GPADC_MVOLT_A * 1000; + y2 = HAL_GPADC_MVOLT_B * 1000; - pmu_get_efuse(PMU_EFUSE_PAGE_BATTER_LV, &efuse_a); + pmu_get_efuse(PMU_EFUSE_PAGE_BATTER_LV, &efuse_a); - x1 = efuse_a > 0 ? efuse_a : HAL_GPADC_CALIB_DEFAULT_A; + x1 = efuse_a > 0 ? efuse_a : HAL_GPADC_CALIB_DEFAULT_A; - pmu_get_efuse(PMU_EFUSE_PAGE_BATTER_HV, &efuse_b); - x2 = efuse_b > 0 ? efuse_b : HAL_GPADC_CALIB_DEFAULT_B; + pmu_get_efuse(PMU_EFUSE_PAGE_BATTER_HV, &efuse_b); + x2 = efuse_b > 0 ? efuse_b : HAL_GPADC_CALIB_DEFAULT_B; - g_adcSlope = (y2-y1)/(x2-x1); - g_adcIntcpt = ((y1*x2)-(x1*y2))/((x2-x1)*1000); - g_adcCalibrated = true; + g_adcSlope = (y2 - y1) / (x2 - x1); + g_adcIntcpt = ((y1 * x2) - (x1 * y2)) / ((x2 - x1) * 1000); + g_adcCalibrated = true; - TRACE(7,"%s efuse:%d/%d LV=%d, HV=%d, Slope:%d Intcpt:%d",__func__, efuse_a, efuse_b, x1, x2, g_adcSlope, g_adcIntcpt); - } + TRACE(7, "%s efuse:%d/%d LV=%d, HV=%d, Slope:%d Intcpt:%d", __func__, + efuse_a, efuse_b, x1, x2, g_adcSlope, g_adcIntcpt); + } - return 0; + return 0; } -static HAL_GPADC_MV_T hal_gpadc_adc2volt(uint16_t gpadcVal) -{ - int32_t voltage; +static HAL_GPADC_MV_T hal_gpadc_adc2volt(uint16_t gpadcVal) { + int32_t voltage; - hal_gpadc_adc2volt_calib(); - if (gpadcVal == HAL_GPADC_BAD_VALUE) - { - // Bad values from the GPADC are still Bad Values - // for the voltage-speaking user. - return HAL_GPADC_BAD_VALUE; - } - else - { - voltage = (((g_adcSlope*gpadcVal)/1000) + (g_adcIntcpt)); + hal_gpadc_adc2volt_calib(); + if (gpadcVal == HAL_GPADC_BAD_VALUE) { + // Bad values from the GPADC are still Bad Values + // for the voltage-speaking user. + return HAL_GPADC_BAD_VALUE; + } else { + voltage = (((g_adcSlope * gpadcVal) / 1000) + (g_adcIntcpt)); - return (voltage < 0) ? 0 : voltage; - } + return (voltage < 0) ? 0 : voltage; + } } #ifdef PMU_IRQ_UNIFIED -#define GPADC_IRQ_HDLR_PARAM uint16_t irq_status +#define GPADC_IRQ_HDLR_PARAM uint16_t irq_status #else -#define GPADC_IRQ_HDLR_PARAM void +#define GPADC_IRQ_HDLR_PARAM void #endif -static void hal_gpadc_irq_handler(GPADC_IRQ_HDLR_PARAM) -{ - uint32_t lock; - enum HAL_GPADC_CHAN_T ch; - unsigned short read_val; - uint16_t adc_val; - HAL_GPADC_MV_T volt; +static void hal_gpadc_irq_handler(GPADC_IRQ_HDLR_PARAM) { + uint32_t lock; + enum HAL_GPADC_CHAN_T ch; + unsigned short read_val; + uint16_t adc_val; + HAL_GPADC_MV_T volt; #ifndef PMU_IRQ_UNIFIED - unsigned short irq_status; + unsigned short irq_status; - gpadc_reg_read(GPADC_REG_INT_MSKED_STS, &irq_status); - irq_status &= (CHAN_DATA_INTR_MSKED_MASK|SAMPLE_DONE_INTR_MSKED| - KEY_RELEASE_INTR_MSKED|KEY_PRESS_INTR_MSKED| - KEY_ERR0_INTR_MSKED|KEY_ERR1_INTR_MSKED); - gpadc_reg_write(GPADC_REG_INT_CLR, irq_status); + gpadc_reg_read(GPADC_REG_INT_MSKED_STS, &irq_status); + irq_status &= (CHAN_DATA_INTR_MSKED_MASK | SAMPLE_DONE_INTR_MSKED | + KEY_RELEASE_INTR_MSKED | KEY_PRESS_INTR_MSKED | + KEY_ERR0_INTR_MSKED | KEY_ERR1_INTR_MSKED); + gpadc_reg_write(GPADC_REG_INT_CLR, irq_status); #endif - if (irq_status & CHAN_DATA_INTR_MSKED((1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6))) { - for (ch = HAL_GPADC_CHAN_0; ch < HAL_GPADC_CHAN_QTY; ch++) { - if (irq_status & CHAN_DATA_INTR_MSKED(1<= HAL_GPADC_CHAN_QTY) { - return res; - } - - gpadc_reg_read(GPADC_REG_INT_RAW_STS, &read_val); - - if (read_val & CHAN_DATA_VALID_INTR(1<= HAL_GPADC_CHAN_QTY) { - return -1; - } - - // NOTE: ADCKEY callback is not set here, but in hal_adckey_set_irq_handler() - if (channel != HAL_GPADC_CHAN_ADCKEY) { - gpadc_event_cb[channel] = cb; - gpadc_atp[channel] = atp; - } - - switch (channel) { + if (irq_status & + CHAN_DATA_INTR_MSKED((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | + (1 << 4) | (1 << 5) | (1 << 6))) { + for (ch = HAL_GPADC_CHAN_0; ch < HAL_GPADC_CHAN_QTY; ch++) { + if (irq_status & CHAN_DATA_INTR_MSKED(1 << ch)) { + switch (ch) { case HAL_GPADC_CHAN_BATTERY: - // Enable vbat measurement clock - // vbat div enable - lock = int_lock(); - gpadc_reg_read(GPADC_REG_VBAT_EN, &val); - val |= REG_PU_VBAT_DIV; - gpadc_reg_write(GPADC_REG_VBAT_EN, val); - int_unlock(lock); -#ifndef VBAT_DIV_ALWAYS_ON - // GPADC VBAT needs 10us to be stable and consumes 13mA current - hal_sys_timer_delay_us(20); -#endif case HAL_GPADC_CHAN_0: case HAL_GPADC_CHAN_2: case HAL_GPADC_CHAN_3: case HAL_GPADC_CHAN_4: case HAL_GPADC_CHAN_5: case HAL_GPADC_CHAN_6: - case HAL_GPADC_CHAN_ADCKEY: + gpadc_reg_read(GPADC_REG_CH0_DATA + ch, &adc_val); + adc_val = GET_BITFIELD(adc_val, DATA_CHAN0); + volt = hal_gpadc_adc2volt(adc_val); + if (gpadc_event_cb[ch]) { + gpadc_event_cb[ch](adc_val, volt); + } + if (gpadc_atp[ch] == HAL_GPADC_ATP_NULL || + gpadc_atp[ch] == HAL_GPADC_ATP_ONESHOT) { lock = int_lock(); -#if defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) - if (channel == HAL_GPADC_CHAN_3){ - pmu_led_set_hiz(HAL_GPIO_PIN_LED2); +#ifndef VBAT_DIV_ALWAYS_ON + if (ch == HAL_GPADC_CHAN_BATTERY) { + gpadc_reg_read(GPADC_REG_VBAT_EN, &read_val); + read_val &= ~REG_PU_VBAT_DIV; + gpadc_reg_write(GPADC_REG_VBAT_EN, read_val); } #endif // Int mask - if (channel == HAL_GPADC_CHAN_ADCKEY || gpadc_event_cb[channel]) { - // 1) Always enable ADCKEY mask - // 2) Enable mask if handler is not null - gpadc_reg_read(GPADC_REG_INT_MASK, &val); - val |= CHAN_DATA_INTR_MSK(1<= HAL_GPADC_CHAN_QTY) { - return -1; - } - - if (channel != HAL_GPADC_CHAN_ADCKEY) { - gpadc_atp[channel] = HAL_GPADC_ATP_NULL; - } - - switch (channel) { - case HAL_GPADC_CHAN_BATTERY: -#ifndef VBAT_DIV_ALWAYS_ON - // disable vbat measurement clock - // vbat div disable - lock = int_lock(); - gpadc_reg_read(GPADC_REG_VBAT_EN, &val); - val &= ~REG_PU_VBAT_DIV; - gpadc_reg_write(GPADC_REG_VBAT_EN, val); - int_unlock(lock); -#endif - case HAL_GPADC_CHAN_0: - case HAL_GPADC_CHAN_2: - case HAL_GPADC_CHAN_3: - case HAL_GPADC_CHAN_4: - case HAL_GPADC_CHAN_5: - case HAL_GPADC_CHAN_6: - case HAL_GPADC_CHAN_ADCKEY: - lock = int_lock(); - - // Int mask - gpadc_reg_read(GPADC_REG_INT_MASK, &val); - val &= ~CHAN_DATA_INTR_MSK(1<= HAL_GPADC_CHAN_QTY) { + return res; + } + + gpadc_reg_read(GPADC_REG_INT_RAW_STS, &read_val); + + if (read_val & CHAN_DATA_VALID_INTR(1 << ch)) { + // Clear the channel valid status + gpadc_reg_write(GPADC_REG_INT_CLR, CHAN_DATA_INTR_CLR(1 << ch)); + + gpadc_reg_read(GPADC_REG_CH0_DATA + ch, &read_val); + read_val = GET_BITFIELD(read_val, DATA_CHAN0); + *volt = hal_gpadc_adc2volt(read_val); + res = true; + } + + return res; } -int hal_adckey_set_irq(enum HAL_ADCKEY_IRQ_T type) -{ - uint32_t lock; - uint16_t val; - uint16_t set_mask; - uint16_t clr_mask; - uint16_t set_en; - uint16_t clr_en; - - set_mask = 0; - clr_mask = 0; - set_en = 0; - clr_en = 0; - if (type == HAL_ADCKEY_IRQ_NONE) { - clr_mask = KEY_RELEASE_INTR_MSK | KEY_PRESS_INTR_MSK | KEY_ERR0_INTR_MSK | KEY_ERR1_INTR_MSK; - clr_en = KEY_RELEASE_INTR_EN | KEY_PRESS_INTR_EN | KEY_ERR0_INTR_EN | KEY_ERR1_INTR_EN; - adckey_enabled = false; - } else if (type == HAL_ADCKEY_IRQ_PRESSED) { - set_mask = KEY_PRESS_INTR_MSK | KEY_ERR0_INTR_MSK | KEY_ERR1_INTR_MSK; - clr_mask = KEY_RELEASE_INTR_MSK; - set_en = KEY_PRESS_INTR_EN | KEY_ERR0_INTR_EN | KEY_ERR1_INTR_EN; - clr_en = KEY_RELEASE_INTR_EN; - adckey_enabled = true; - } else if (type == HAL_ADCKEY_IRQ_RELEASED) { - set_mask = KEY_RELEASE_INTR_MSK | KEY_ERR0_INTR_MSK | KEY_ERR1_INTR_MSK; - clr_mask = KEY_PRESS_INTR_MSK; - set_en = KEY_RELEASE_INTR_EN | KEY_ERR0_INTR_EN | KEY_ERR1_INTR_EN; - clr_en = KEY_PRESS_INTR_EN; - adckey_enabled = true; - } else if (type == HAL_ADCKEY_IRQ_BOTH) { - set_mask = KEY_RELEASE_INTR_MSK | KEY_PRESS_INTR_MSK | KEY_ERR0_INTR_MSK | KEY_ERR1_INTR_MSK; - set_en = KEY_RELEASE_INTR_EN | KEY_PRESS_INTR_EN | KEY_ERR0_INTR_EN | KEY_ERR1_INTR_EN; - adckey_enabled = true; - } else { - return 1; +static void hal_gpadc_irq_control(void) { + if (gpadc_enabled || adckey_enabled) { + if (!irq_enabled) { + irq_enabled = true; +#ifdef PMU_IRQ_UNIFIED + pmu_set_irq_unified_handler(PMU_IRQ_TYPE_GPADC, hal_gpadc_irq_handler); +#else + NVIC_SetVector(GPADC_IRQn, (uint32_t)hal_gpadc_irq_handler); + NVIC_SetPriority(GPADC_IRQn, IRQ_PRIORITY_NORMAL); + NVIC_ClearPendingIRQ(GPADC_IRQn); + NVIC_EnableIRQ(GPADC_IRQn); +#endif } + } else { + if (irq_enabled) { + irq_enabled = false; +#ifdef PMU_IRQ_UNIFIED + pmu_set_irq_unified_handler(PMU_IRQ_TYPE_GPADC, NULL); +#else + NVIC_DisableIRQ(GPADC_IRQn); +#endif + } + } +} +int hal_gpadc_open(enum HAL_GPADC_CHAN_T channel, enum HAL_GPADC_ATP_T atp, + HAL_GPADC_EVENT_CB_T cb) { + uint32_t lock; + unsigned short val; + unsigned short reg_start_mask; + + if (channel >= HAL_GPADC_CHAN_QTY) { + return -1; + } + + // NOTE: ADCKEY callback is not set here, but in hal_adckey_set_irq_handler() + if (channel != HAL_GPADC_CHAN_ADCKEY) { + gpadc_event_cb[channel] = cb; + gpadc_atp[channel] = atp; + } + + switch (channel) { + case HAL_GPADC_CHAN_BATTERY: + // Enable vbat measurement clock + // vbat div enable + lock = int_lock(); + gpadc_reg_read(GPADC_REG_VBAT_EN, &val); + val |= REG_PU_VBAT_DIV; + gpadc_reg_write(GPADC_REG_VBAT_EN, val); + int_unlock(lock); +#ifndef VBAT_DIV_ALWAYS_ON + // GPADC VBAT needs 10us to be stable and consumes 13mA current + hal_sys_timer_delay_us(20); +#endif + case HAL_GPADC_CHAN_0: + case HAL_GPADC_CHAN_2: + case HAL_GPADC_CHAN_3: + case HAL_GPADC_CHAN_4: + case HAL_GPADC_CHAN_5: + case HAL_GPADC_CHAN_6: + case HAL_GPADC_CHAN_ADCKEY: lock = int_lock(); - gpadc_reg_read(GPADC_REG_INT_MASK, &val); - val &= ~clr_mask; - val |= set_mask; - gpadc_reg_write(GPADC_REG_INT_MASK, val); +#if defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) + if (channel == HAL_GPADC_CHAN_3) { + pmu_led_set_hiz(HAL_GPIO_PIN_LED2); + } +#endif + // Int mask + if (channel == HAL_GPADC_CHAN_ADCKEY || gpadc_event_cb[channel]) { + // 1) Always enable ADCKEY mask + // 2) Enable mask if handler is not null + gpadc_reg_read(GPADC_REG_INT_MASK, &val); + val |= CHAN_DATA_INTR_MSK(1 << channel); + gpadc_reg_write(GPADC_REG_INT_MASK, val); + gpadc_enabled = true; + hal_gpadc_irq_control(); + } + + // Int enable gpadc_reg_read(GPADC_REG_INT_EN, &val); - val &= ~clr_en; - val |= set_en; + val |= CHAN_DATA_INTR_EN(1 << channel); gpadc_reg_write(GPADC_REG_INT_EN, val); - hal_gpadc_irq_control(); + // Clear the channel valid status + gpadc_reg_write(GPADC_REG_INT_CLR, CHAN_DATA_INTR_CLR(1 << channel)); + + // Channel enable + if (channel == HAL_GPADC_CHAN_ADCKEY) { + reg_start_mask = KEY_START; + } else { + hal_gpadc_update_atp(); + reg_start_mask = GPADC_START; + if (GPADC_REG_START == GPADC_REG_CH_EN) { + reg_start_mask |= CHAN_EN_REG(1 << channel); + } else { + gpadc_reg_read(GPADC_REG_CH_EN, &val); + val |= CHAN_EN_REG(1 << channel); + gpadc_reg_write(GPADC_REG_CH_EN, val); + } + } + + // GPADC enable + gpadc_reg_read(GPADC_REG_START, &val); + val |= reg_start_mask; + gpadc_reg_write(GPADC_REG_START, val); int_unlock(lock); + break; + default: + break; + } - return 0; + return 0; +} + +int hal_gpadc_close(enum HAL_GPADC_CHAN_T channel) { + uint32_t lock; + unsigned short val; + unsigned short chan_int_en; + unsigned short reg_start; + + if (channel >= HAL_GPADC_CHAN_QTY) { + return -1; + } + + if (channel != HAL_GPADC_CHAN_ADCKEY) { + gpadc_atp[channel] = HAL_GPADC_ATP_NULL; + } + + switch (channel) { + case HAL_GPADC_CHAN_BATTERY: +#ifndef VBAT_DIV_ALWAYS_ON + // disable vbat measurement clock + // vbat div disable + lock = int_lock(); + gpadc_reg_read(GPADC_REG_VBAT_EN, &val); + val &= ~REG_PU_VBAT_DIV; + gpadc_reg_write(GPADC_REG_VBAT_EN, val); + int_unlock(lock); +#endif + case HAL_GPADC_CHAN_0: + case HAL_GPADC_CHAN_2: + case HAL_GPADC_CHAN_3: + case HAL_GPADC_CHAN_4: + case HAL_GPADC_CHAN_5: + case HAL_GPADC_CHAN_6: + case HAL_GPADC_CHAN_ADCKEY: + lock = int_lock(); + + // Int mask + gpadc_reg_read(GPADC_REG_INT_MASK, &val); + val &= ~CHAN_DATA_INTR_MSK(1 << channel); + gpadc_reg_write(GPADC_REG_INT_MASK, val); + + // Int enable + gpadc_reg_read(GPADC_REG_INT_EN, &chan_int_en); + chan_int_en &= ~CHAN_DATA_INTR_EN(1 << channel); + gpadc_reg_write(GPADC_REG_INT_EN, chan_int_en); + + // Channel/GPADC enable + gpadc_reg_read(GPADC_REG_START, ®_start); + if (channel == HAL_GPADC_CHAN_ADCKEY) { + reg_start &= ~KEY_START; + } else { + if (GPADC_REG_START == GPADC_REG_CH_EN) { + reg_start &= ~CHAN_EN_REG(1 << channel); + val = reg_start; + } else { + gpadc_reg_read(GPADC_REG_CH_EN, &val); + val &= ~CHAN_EN_REG(1 << channel); + gpadc_reg_write(GPADC_REG_CH_EN, val); + } + if (val & CHAN_EN_REG((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | + (1 << 4) | (1 << 5) | (1 << 6))) { + hal_gpadc_update_atp(); + } else { + reg_start &= ~GPADC_START; + } + } + gpadc_reg_write(GPADC_REG_START, reg_start); + + if ((chan_int_en & + CHAN_DATA_INTR_EN((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | + (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7))) == 0) { + gpadc_enabled = false; + hal_gpadc_irq_control(); + } + + int_unlock(lock); + break; + default: + break; + } + + return 0; +} + +void hal_gpadc_sleep(void) { + unsigned short val; + +#if defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) + return; +#endif + + gpadc_reg_read(GPADC_REG_START, &val); + if (val & GPADC_START) { + val &= ~GPADC_START; + gpadc_reg_write(GPADC_REG_START, val); + } +} + +void hal_gpadc_wakeup(void) { + unsigned short val; + +#if defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) + return; +#endif + + gpadc_reg_read(GPADC_REG_CH_EN, &val); + if (val & CHAN_EN_REG((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | + (1 << 5) | (1 << 6))) { + if (GPADC_REG_START != GPADC_REG_CH_EN) { + gpadc_reg_read(GPADC_REG_START, &val); + } + val |= GPADC_START; + gpadc_reg_write(GPADC_REG_START, val); + } +} + +void hal_adckey_set_irq_handler(HAL_ADCKEY_EVENT_CB_T cb) { + gpadc_event_cb[HAL_GPADC_CHAN_ADCKEY] = (HAL_GPADC_EVENT_CB_T)cb; +} + +int hal_adckey_set_irq(enum HAL_ADCKEY_IRQ_T type) { + uint32_t lock; + uint16_t val; + uint16_t set_mask; + uint16_t clr_mask; + uint16_t set_en; + uint16_t clr_en; + + set_mask = 0; + clr_mask = 0; + set_en = 0; + clr_en = 0; + if (type == HAL_ADCKEY_IRQ_NONE) { + clr_mask = KEY_RELEASE_INTR_MSK | KEY_PRESS_INTR_MSK | KEY_ERR0_INTR_MSK | + KEY_ERR1_INTR_MSK; + clr_en = KEY_RELEASE_INTR_EN | KEY_PRESS_INTR_EN | KEY_ERR0_INTR_EN | + KEY_ERR1_INTR_EN; + adckey_enabled = false; + } else if (type == HAL_ADCKEY_IRQ_PRESSED) { + set_mask = KEY_PRESS_INTR_MSK | KEY_ERR0_INTR_MSK | KEY_ERR1_INTR_MSK; + clr_mask = KEY_RELEASE_INTR_MSK; + set_en = KEY_PRESS_INTR_EN | KEY_ERR0_INTR_EN | KEY_ERR1_INTR_EN; + clr_en = KEY_RELEASE_INTR_EN; + adckey_enabled = true; + } else if (type == HAL_ADCKEY_IRQ_RELEASED) { + set_mask = KEY_RELEASE_INTR_MSK | KEY_ERR0_INTR_MSK | KEY_ERR1_INTR_MSK; + clr_mask = KEY_PRESS_INTR_MSK; + set_en = KEY_RELEASE_INTR_EN | KEY_ERR0_INTR_EN | KEY_ERR1_INTR_EN; + clr_en = KEY_PRESS_INTR_EN; + adckey_enabled = true; + } else if (type == HAL_ADCKEY_IRQ_BOTH) { + set_mask = KEY_RELEASE_INTR_MSK | KEY_PRESS_INTR_MSK | KEY_ERR0_INTR_MSK | + KEY_ERR1_INTR_MSK; + set_en = KEY_RELEASE_INTR_EN | KEY_PRESS_INTR_EN | KEY_ERR0_INTR_EN | + KEY_ERR1_INTR_EN; + adckey_enabled = true; + } else { + return 1; + } + + lock = int_lock(); + + gpadc_reg_read(GPADC_REG_INT_MASK, &val); + val &= ~clr_mask; + val |= set_mask; + gpadc_reg_write(GPADC_REG_INT_MASK, val); + + gpadc_reg_read(GPADC_REG_INT_EN, &val); + val &= ~clr_en; + val |= set_en; + gpadc_reg_write(GPADC_REG_INT_EN, val); + + hal_gpadc_irq_control(); + + int_unlock(lock); + + return 0; } #endif // !GPADC_CHIP_SPECIFIC - diff --git a/platform/hal/hal_gpio.c b/platform/hal/hal_gpio.c index aecb50f..39a232a 100644 --- a/platform/hal/hal_gpio.c +++ b/platform/hal/hal_gpio.c @@ -13,15 +13,15 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "hal_gpio.h" +#include "cmsis_nvic.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "plat_addr_map.h" +#include "plat_types.h" +#include "reg_gpio.h" #include "stdarg.h" #include "stdio.h" -#include "plat_types.h" -#include "plat_addr_map.h" -#include "hal_gpio.h" -#include "reg_gpio.h" -#include "hal_trace.h" -#include "cmsis_nvic.h" -#include "hal_uart.h" #ifdef PMU_HAS_LED_PIN #include "pmu.h" #endif @@ -30,479 +30,465 @@ #define HAL_GPIO_PORT_NUM 1 #define HAL_GPIO_PIN_NUM_EACH_PORT (32) -#define HAL_GPIO_PIN_NUM_EACH_BANK (HAL_GPIO_PORT_NUM*HAL_GPIO_PIN_NUM_EACH_PORT) +#define HAL_GPIO_PIN_NUM_EACH_BANK \ + (HAL_GPIO_PORT_NUM * HAL_GPIO_PIN_NUM_EACH_PORT) -#define HAL_GPIO_PIN_TO_BANK(pin) \ - ((pin)/HAL_GPIO_PIN_NUM_EACH_BANK) +#define HAL_GPIO_PIN_TO_BANK(pin) ((pin) / HAL_GPIO_PIN_NUM_EACH_BANK) -#define HAL_GPIO_PIN_TO_PORT(pin) \ - (((pin)%HAL_GPIO_PIN_NUM_EACH_BANK)/HAL_GPIO_PIN_NUM_EACH_PORT) +#define HAL_GPIO_PIN_TO_PORT(pin) \ + (((pin) % HAL_GPIO_PIN_NUM_EACH_BANK) / HAL_GPIO_PIN_NUM_EACH_PORT) #ifdef GPIOAUX_BASE #define HAL_GPIO_AUX_BANK_NUM 1 #define HAL_GPIO_AUX_PORT_NUM 1 #define HAL_GPIO_AUX_PIN_NUM_EACH_PORT (8) -#define HAL_GPIO_AUX_PIN_NUM_EACH_BANK (HAL_GPIO_AUX_PORT_NUM*HAL_GPIO_AUX_PIN_NUM_EACH_PORT) +#define HAL_GPIO_AUX_PIN_NUM_EACH_BANK \ + (HAL_GPIO_AUX_PORT_NUM * HAL_GPIO_AUX_PIN_NUM_EACH_PORT) -#define HAL_GPIO_AUX_PIN_TO_BANK(pin) \ - (((pin) - HAL_GPIO_PIN_P4_0)/HAL_GPIO_AUX_PIN_NUM_EACH_BANK) +#define HAL_GPIO_AUX_PIN_TO_BANK(pin) \ + (((pin)-HAL_GPIO_PIN_P4_0) / HAL_GPIO_AUX_PIN_NUM_EACH_BANK) -#define HAL_GPIO_AUX_PIN_TO_PORT(pin) \ - ((((pin) - HAL_GPIO_PIN_P4_0)%HAL_GPIO_AUX_PIN_NUM_EACH_BANK)/HAL_GPIO_AUX_PIN_NUM_EACH_PORT) +#define HAL_GPIO_AUX_PIN_TO_PORT(pin) \ + ((((pin)-HAL_GPIO_PIN_P4_0) % HAL_GPIO_AUX_PIN_NUM_EACH_BANK) / \ + HAL_GPIO_AUX_PIN_NUM_EACH_PORT) #endif -typedef void (* _HAL_GPIO_IRQ_HANDLER)(void); +typedef void (*_HAL_GPIO_IRQ_HANDLER)(void); struct GPIO_PORT_T { - __IO uint32_t GPIO_DR; // 0x00 - __IO uint32_t GPIO_DDR; // 0x04 - __IO uint32_t GPIO_CTL; // 0x08 + __IO uint32_t GPIO_DR; // 0x00 + __IO uint32_t GPIO_DDR; // 0x04 + __IO uint32_t GPIO_CTL; // 0x08 }; struct GPIO_BANK_T { - struct GPIO_PORT_T port[HAL_GPIO_PORT_NUM]; - struct GPIO_PORT_T _port_reserved[3]; - __IO uint32_t GPIO_INTEN; // 0x30 - __IO uint32_t GPIO_INTMASK; // 0x34 - __IO uint32_t GPIO_INTTYPE_LEVEL; // 0x38 - __IO uint32_t GPIO_INT_POLARITY; // 0x3C - __I uint32_t GPIO_INTSTATUS; // 0x40 - __I uint32_t GPIO_RAW_INTSTATUS; // 0x44 - __IO uint32_t GPIO_DEBOUNCE; // 0x48 - __IO uint32_t GPIO_PORTA_EOI; // 0x4C - __I uint32_t GPIO_EXT_PORT[HAL_GPIO_PORT_NUM]; // 0x50 - __I uint32_t GPIO_EXT_PORT_reserved[3]; - __IO uint32_t GPIO_LS_SYNC; // 0x60 + struct GPIO_PORT_T port[HAL_GPIO_PORT_NUM]; + struct GPIO_PORT_T _port_reserved[3]; + __IO uint32_t GPIO_INTEN; // 0x30 + __IO uint32_t GPIO_INTMASK; // 0x34 + __IO uint32_t GPIO_INTTYPE_LEVEL; // 0x38 + __IO uint32_t GPIO_INT_POLARITY; // 0x3C + __I uint32_t GPIO_INTSTATUS; // 0x40 + __I uint32_t GPIO_RAW_INTSTATUS; // 0x44 + __IO uint32_t GPIO_DEBOUNCE; // 0x48 + __IO uint32_t GPIO_PORTA_EOI; // 0x4C + __I uint32_t GPIO_EXT_PORT[HAL_GPIO_PORT_NUM]; // 0x50 + __I uint32_t GPIO_EXT_PORT_reserved[3]; + __IO uint32_t GPIO_LS_SYNC; // 0x60 }; void _hal_gpio_bank0_irq_handler(void); -static struct GPIO_BANK_T * const gpio_bank[HAL_GPIO_BANK_NUM] = { (struct GPIO_BANK_T *)GPIO_BASE, }; +static struct GPIO_BANK_T *const gpio_bank[HAL_GPIO_BANK_NUM] = { + (struct GPIO_BANK_T *)GPIO_BASE, +}; static HAL_GPIO_PIN_IRQ_HANDLER gpio_irq_handler[HAL_GPIO_PIN_NUM] = {0}; -static _HAL_GPIO_IRQ_HANDLER _gpio_irq_handler[HAL_GPIO_BANK_NUM] = {_hal_gpio_bank0_irq_handler, }; +static _HAL_GPIO_IRQ_HANDLER _gpio_irq_handler[HAL_GPIO_BANK_NUM] = { + _hal_gpio_bank0_irq_handler, +}; #ifdef GPIOAUX_BASE void _hal_gpio_aux_bank0_irq_handler(void); -static struct GPIO_BANK_T * const gpio_aux_bank[HAL_GPIO_BANK_NUM] = { (struct GPIO_BANK_T *)GPIOAUX_BASE, }; +static struct GPIO_BANK_T *const gpio_aux_bank[HAL_GPIO_BANK_NUM] = { + (struct GPIO_BANK_T *)GPIOAUX_BASE, +}; #if defined(CHIP_BEST2000) && defined(PMU_HAS_LED_PIN) -static struct GPIO_BANK_T * const aon_gpio_aux_bank[HAL_GPIO_BANK_NUM] = { (struct GPIO_BANK_T *)AON_GPIOAUX_BASE, }; +static struct GPIO_BANK_T *const aon_gpio_aux_bank[HAL_GPIO_BANK_NUM] = { + (struct GPIO_BANK_T *)AON_GPIOAUX_BASE, +}; #endif -static _HAL_GPIO_IRQ_HANDLER _gpio_aux_irq_handler[HAL_GPIO_AUX_BANK_NUM] = {_hal_gpio_aux_bank0_irq_handler, }; +static _HAL_GPIO_IRQ_HANDLER _gpio_aux_irq_handler[HAL_GPIO_AUX_BANK_NUM] = { + _hal_gpio_aux_bank0_irq_handler, +}; #endif -static const char * const err_bad_pin = "Bad GPIO pin %u (should < %u)"; +static const char *const err_bad_pin = "Bad GPIO pin %u (should < %u)"; -enum HAL_GPIO_DIR_T hal_gpio_pin_get_dir(enum HAL_GPIO_PIN_T pin) -{ - int pin_offset = 0; - int bank = 0, port = 0; - enum HAL_GPIO_DIR_T dir = 0; +enum HAL_GPIO_DIR_T hal_gpio_pin_get_dir(enum HAL_GPIO_PIN_T pin) { + int pin_offset = 0; + int bank = 0, port = 0; + enum HAL_GPIO_DIR_T dir = 0; - enum HAL_GPIO_PIN_T max_pin = HAL_GPIO_PIN_NUM; + enum HAL_GPIO_PIN_T max_pin = HAL_GPIO_PIN_NUM; #ifdef PMU_HAS_LED_PIN - max_pin = HAL_GPIO_PIN_LED_NUM; + max_pin = HAL_GPIO_PIN_LED_NUM; #endif - ASSERT(pin < max_pin, err_bad_pin, pin, max_pin); + ASSERT(pin < max_pin, err_bad_pin, pin, max_pin); - if (0) - { - } + if (0) { + } #ifdef PMU_HAS_LED_PIN - else if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) - { - return pmu_led_get_direction(pin); - } + else if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) { + return pmu_led_get_direction(pin); + } #endif #ifdef GPIOAUX_BASE - else if (pin >= HAL_GPIO_PIN_P4_0) - { - bank = HAL_GPIO_AUX_PIN_TO_BANK(pin); - port = HAL_GPIO_AUX_PIN_TO_PORT(pin); - pin_offset = pin%HAL_GPIO_AUX_PIN_NUM_EACH_PORT; + else if (pin >= HAL_GPIO_PIN_P4_0) { + bank = HAL_GPIO_AUX_PIN_TO_BANK(pin); + port = HAL_GPIO_AUX_PIN_TO_PORT(pin); + pin_offset = pin % HAL_GPIO_AUX_PIN_NUM_EACH_PORT; - if (gpio_aux_bank[bank]->port[port].GPIO_DDR & (0x1<port[port].GPIO_DDR & (0x1 << pin_offset)) + dir = HAL_GPIO_DIR_OUT; else - { - bank = HAL_GPIO_PIN_TO_BANK(pin); - port = HAL_GPIO_PIN_TO_PORT(pin); - pin_offset = pin%HAL_GPIO_PIN_NUM_EACH_PORT; + dir = HAL_GPIO_DIR_IN; + } +#endif + else { + bank = HAL_GPIO_PIN_TO_BANK(pin); + port = HAL_GPIO_PIN_TO_PORT(pin); + pin_offset = pin % HAL_GPIO_PIN_NUM_EACH_PORT; - if (gpio_bank[bank]->port[port].GPIO_DDR & (0x1<port[port].GPIO_DDR & (0x1 << pin_offset)) + dir = HAL_GPIO_DIR_OUT; + else + dir = HAL_GPIO_DIR_IN; + } - return dir; + return dir; } -void hal_gpio_pin_set_dir(enum HAL_GPIO_PIN_T pin, enum HAL_GPIO_DIR_T dir, uint8_t val_for_out) -{ - int pin_offset = 0; - int bank = 0, port = 0; +void hal_gpio_pin_set_dir(enum HAL_GPIO_PIN_T pin, enum HAL_GPIO_DIR_T dir, + uint8_t val_for_out) { + int pin_offset = 0; + int bank = 0, port = 0; - enum HAL_GPIO_PIN_T max_pin = HAL_GPIO_PIN_NUM; + enum HAL_GPIO_PIN_T max_pin = HAL_GPIO_PIN_NUM; #ifdef PMU_HAS_LED_PIN - max_pin = HAL_GPIO_PIN_LED_NUM; + max_pin = HAL_GPIO_PIN_LED_NUM; #endif - ASSERT(pin < max_pin, err_bad_pin, pin, max_pin); + ASSERT(pin < max_pin, err_bad_pin, pin, max_pin); - if(dir == HAL_GPIO_DIR_OUT) { - if(val_for_out) { - hal_gpio_pin_set(pin); - } else { - hal_gpio_pin_clr(pin); - } + if (dir == HAL_GPIO_DIR_OUT) { + if (val_for_out) { + hal_gpio_pin_set(pin); + } else { + hal_gpio_pin_clr(pin); } + } - if (0) - { - } + if (0) { + } #ifdef PMU_HAS_LED_PIN - else if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) - { - pmu_led_set_direction(pin, dir); - } + else if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) { + pmu_led_set_direction(pin, dir); + } #endif #ifdef GPIOAUX_BASE - else if (pin >= HAL_GPIO_PIN_P4_0) - { - bank = HAL_GPIO_AUX_PIN_TO_BANK(pin); - port = HAL_GPIO_AUX_PIN_TO_PORT(pin); - pin_offset = pin%HAL_GPIO_AUX_PIN_NUM_EACH_PORT; + else if (pin >= HAL_GPIO_PIN_P4_0) { + bank = HAL_GPIO_AUX_PIN_TO_BANK(pin); + port = HAL_GPIO_AUX_PIN_TO_PORT(pin); + pin_offset = pin % HAL_GPIO_AUX_PIN_NUM_EACH_PORT; - if(dir == HAL_GPIO_DIR_OUT) - gpio_aux_bank[bank]->port[port].GPIO_DDR |= 0x1<port[port].GPIO_DDR &= ~(0x1<port[port].GPIO_DDR |= 0x1 << pin_offset; else - { - bank = HAL_GPIO_PIN_TO_BANK(pin); - port = HAL_GPIO_PIN_TO_PORT(pin); - pin_offset = pin%HAL_GPIO_PIN_NUM_EACH_PORT; + gpio_aux_bank[bank]->port[port].GPIO_DDR &= ~(0x1 << pin_offset); + } +#endif + else { + bank = HAL_GPIO_PIN_TO_BANK(pin); + port = HAL_GPIO_PIN_TO_PORT(pin); + pin_offset = pin % HAL_GPIO_PIN_NUM_EACH_PORT; - if(dir == HAL_GPIO_DIR_OUT) - gpio_bank[bank]->port[port].GPIO_DDR |= 0x1<port[port].GPIO_DDR &= ~(0x1<port[port].GPIO_DDR |= 0x1 << pin_offset; + else + gpio_bank[bank]->port[port].GPIO_DDR &= ~(0x1 << pin_offset); + } } -void hal_gpio_pin_set(enum HAL_GPIO_PIN_T pin) -{ - int pin_offset = 0; - int bank = 0, port = 0; +void hal_gpio_pin_set(enum HAL_GPIO_PIN_T pin) { + int pin_offset = 0; + int bank = 0, port = 0; - enum HAL_GPIO_PIN_T max_pin = HAL_GPIO_PIN_NUM; + enum HAL_GPIO_PIN_T max_pin = HAL_GPIO_PIN_NUM; #ifdef PMU_HAS_LED_PIN - max_pin = HAL_GPIO_PIN_LED_NUM; + max_pin = HAL_GPIO_PIN_LED_NUM; #endif - ASSERT(pin < max_pin, err_bad_pin, pin, max_pin); + ASSERT(pin < max_pin, err_bad_pin, pin, max_pin); - if (0) - { - } + if (0) { + } #ifdef PMU_HAS_LED_PIN - else if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) - { + else if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) { #ifdef CHIP_BEST2000 - pin_offset = pin - HAL_GPIO_PIN_LED1 + 6; + pin_offset = pin - HAL_GPIO_PIN_LED1 + 6; - aon_gpio_aux_bank[0]->port[0].GPIO_DR |= 0x1<port[0].GPIO_DR |= 0x1 << pin_offset; #else - pmu_led_set_value(pin, 1); + pmu_led_set_value(pin, 1); #endif - } + } #endif #ifdef GPIOAUX_BASE - else if (pin >= HAL_GPIO_PIN_P4_0) - { - bank = HAL_GPIO_AUX_PIN_TO_BANK(pin); - port = HAL_GPIO_AUX_PIN_TO_PORT(pin); - pin_offset = pin%HAL_GPIO_AUX_PIN_NUM_EACH_PORT; + else if (pin >= HAL_GPIO_PIN_P4_0) { + bank = HAL_GPIO_AUX_PIN_TO_BANK(pin); + port = HAL_GPIO_AUX_PIN_TO_PORT(pin); + pin_offset = pin % HAL_GPIO_AUX_PIN_NUM_EACH_PORT; - gpio_aux_bank[bank]->port[port].GPIO_DR |= 0x1<port[port].GPIO_DR |= 0x1 << pin_offset; + } #endif - else - { - bank = HAL_GPIO_PIN_TO_BANK(pin); - port = HAL_GPIO_PIN_TO_PORT(pin); - pin_offset = pin%HAL_GPIO_PIN_NUM_EACH_PORT; + else { + bank = HAL_GPIO_PIN_TO_BANK(pin); + port = HAL_GPIO_PIN_TO_PORT(pin); + pin_offset = pin % HAL_GPIO_PIN_NUM_EACH_PORT; - gpio_bank[bank]->port[port].GPIO_DR |= 0x1<port[port].GPIO_DR |= 0x1 << pin_offset; + } } -void hal_gpio_pin_clr(enum HAL_GPIO_PIN_T pin) -{ - int pin_offset = 0; - int bank = 0, port = 0; +void hal_gpio_pin_clr(enum HAL_GPIO_PIN_T pin) { + int pin_offset = 0; + int bank = 0, port = 0; - enum HAL_GPIO_PIN_T max_pin = HAL_GPIO_PIN_NUM; + enum HAL_GPIO_PIN_T max_pin = HAL_GPIO_PIN_NUM; #ifdef PMU_HAS_LED_PIN - max_pin = HAL_GPIO_PIN_LED_NUM; + max_pin = HAL_GPIO_PIN_LED_NUM; #endif - ASSERT(pin < max_pin, err_bad_pin, pin, max_pin); + ASSERT(pin < max_pin, err_bad_pin, pin, max_pin); - if (0) - { - } + if (0) { + } #ifdef PMU_HAS_LED_PIN - else if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) - { + else if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) { #ifdef CHIP_BEST2000 - pin_offset = pin - HAL_GPIO_PIN_LED1 + 6; + pin_offset = pin - HAL_GPIO_PIN_LED1 + 6; - aon_gpio_aux_bank[0]->port[0].GPIO_DR &= ~(0x1<port[0].GPIO_DR &= ~(0x1 << pin_offset); #else - pmu_led_set_value(pin, 0); + pmu_led_set_value(pin, 0); #endif - } + } #endif #ifdef GPIOAUX_BASE - else if (pin >= HAL_GPIO_PIN_P4_0) - { - bank = HAL_GPIO_AUX_PIN_TO_BANK(pin); - port = HAL_GPIO_AUX_PIN_TO_PORT(pin); - pin_offset = pin%HAL_GPIO_AUX_PIN_NUM_EACH_PORT; + else if (pin >= HAL_GPIO_PIN_P4_0) { + bank = HAL_GPIO_AUX_PIN_TO_BANK(pin); + port = HAL_GPIO_AUX_PIN_TO_PORT(pin); + pin_offset = pin % HAL_GPIO_AUX_PIN_NUM_EACH_PORT; - gpio_aux_bank[bank]->port[port].GPIO_DR &= ~(0x1<port[port].GPIO_DR &= ~(0x1 << pin_offset); + } #endif - else - { - bank = HAL_GPIO_PIN_TO_BANK(pin); - port = HAL_GPIO_PIN_TO_PORT(pin); - pin_offset = pin%HAL_GPIO_PIN_NUM_EACH_PORT; + else { + bank = HAL_GPIO_PIN_TO_BANK(pin); + port = HAL_GPIO_PIN_TO_PORT(pin); + pin_offset = pin % HAL_GPIO_PIN_NUM_EACH_PORT; - gpio_bank[bank]->port[port].GPIO_DR &= ~(0x1<port[port].GPIO_DR &= ~(0x1 << pin_offset); + } } -uint8_t hal_gpio_pin_get_val(enum HAL_GPIO_PIN_T pin) -{ - int pin_offset = 0; - int bank = 0, port = 0; +uint8_t hal_gpio_pin_get_val(enum HAL_GPIO_PIN_T pin) { + int pin_offset = 0; + int bank = 0, port = 0; - enum HAL_GPIO_PIN_T max_pin = HAL_GPIO_PIN_NUM; + enum HAL_GPIO_PIN_T max_pin = HAL_GPIO_PIN_NUM; #ifdef PMU_HAS_LED_PIN - max_pin = HAL_GPIO_PIN_LED_NUM; + max_pin = HAL_GPIO_PIN_LED_NUM; #endif - ASSERT(pin < max_pin, err_bad_pin, pin, max_pin); + ASSERT(pin < max_pin, err_bad_pin, pin, max_pin); - if (0) - { - } + if (0) { + } #ifdef PMU_HAS_LED_PIN - else if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) - { + else if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) { #ifdef CHIP_BEST2000 - pin_offset = pin - HAL_GPIO_PIN_LED1 + 6; + pin_offset = pin - HAL_GPIO_PIN_LED1 + 6; - return (((aon_gpio_aux_bank[0]->GPIO_EXT_PORT[0]) & (0x1<> pin_offset); + return (((aon_gpio_aux_bank[0]->GPIO_EXT_PORT[0]) & (0x1 << pin_offset)) >> + pin_offset); #else - return pmu_led_get_value(pin); + return pmu_led_get_value(pin); #endif - } + } #endif #ifdef GPIOAUX_BASE - else if (pin >= HAL_GPIO_PIN_P4_0) - { - bank = HAL_GPIO_AUX_PIN_TO_BANK(pin); - port = HAL_GPIO_AUX_PIN_TO_PORT(pin); - pin_offset = pin%HAL_GPIO_AUX_PIN_NUM_EACH_PORT; + else if (pin >= HAL_GPIO_PIN_P4_0) { + bank = HAL_GPIO_AUX_PIN_TO_BANK(pin); + port = HAL_GPIO_AUX_PIN_TO_PORT(pin); + pin_offset = pin % HAL_GPIO_AUX_PIN_NUM_EACH_PORT; - /* when as input : read back outside signal value */ - /* when as output: read back DR register value ,same as read back DR register */ + /* when as input : read back outside signal value */ + /* when as output: read back DR register value ,same as read back DR + * register */ - return (((gpio_aux_bank[bank]->GPIO_EXT_PORT[port]) & (0x1<> pin_offset); - } + return ( + ((gpio_aux_bank[bank]->GPIO_EXT_PORT[port]) & (0x1 << pin_offset)) >> + pin_offset); + } #endif - else - { - bank = HAL_GPIO_PIN_TO_BANK(pin); - port = HAL_GPIO_PIN_TO_PORT(pin); - pin_offset = pin%HAL_GPIO_PIN_NUM_EACH_PORT; + else { + bank = HAL_GPIO_PIN_TO_BANK(pin); + port = HAL_GPIO_PIN_TO_PORT(pin); + pin_offset = pin % HAL_GPIO_PIN_NUM_EACH_PORT; - /* when as input : read back outside signal value */ - /* when as output: read back DR register value ,same as read back DR register */ + /* when as input : read back outside signal value */ + /* when as output: read back DR register value ,same as read back DR + * register */ - return (((gpio_bank[bank]->GPIO_EXT_PORT[port]) & (0x1<> pin_offset); - } + return (((gpio_bank[bank]->GPIO_EXT_PORT[port]) & (0x1 << pin_offset)) >> + pin_offset); + } } -void _hal_gpio_bank0_irq_handler(void) -{ - uint32_t raw_status = 0, bank = 0, pin_offset = 0; +void _hal_gpio_bank0_irq_handler(void) { + uint32_t raw_status = 0, bank = 0, pin_offset = 0; - raw_status = gpio_bank[bank]->GPIO_RAW_INTSTATUS; + raw_status = gpio_bank[bank]->GPIO_RAW_INTSTATUS; - if (raw_status == 0) - { - return; - } - - /* clear irq */ - gpio_bank[bank]->GPIO_PORTA_EOI = raw_status; - - while (raw_status) { - if (raw_status & 0x1) { - if (gpio_irq_handler[pin_offset]) { - gpio_irq_handler[pin_offset](pin_offset + bank*HAL_GPIO_PIN_NUM_EACH_BANK); - } - } - raw_status >>= 1; - ++pin_offset; + if (raw_status == 0) { + return; + } + + /* clear irq */ + gpio_bank[bank]->GPIO_PORTA_EOI = raw_status; + + while (raw_status) { + if (raw_status & 0x1) { + if (gpio_irq_handler[pin_offset]) { + gpio_irq_handler[pin_offset](pin_offset + + bank * HAL_GPIO_PIN_NUM_EACH_BANK); + } } + raw_status >>= 1; + ++pin_offset; + } } #ifdef GPIOAUX_BASE -void _hal_gpio_aux_bank0_irq_handler(void) -{ - uint32_t raw_status = 0, bank = 0, pin_offset = 0; +void _hal_gpio_aux_bank0_irq_handler(void) { + uint32_t raw_status = 0, bank = 0, pin_offset = 0; - raw_status = 0; - bank = 0; - pin_offset = 0; + raw_status = 0; + bank = 0; + pin_offset = 0; - raw_status = gpio_aux_bank[bank]->GPIO_RAW_INTSTATUS; + raw_status = gpio_aux_bank[bank]->GPIO_RAW_INTSTATUS; - if (raw_status == 0) - return; + if (raw_status == 0) + return; - /* clear irq */ - gpio_aux_bank[bank]->GPIO_PORTA_EOI = raw_status; + /* clear irq */ + gpio_aux_bank[bank]->GPIO_PORTA_EOI = raw_status; - while (raw_status) { - if (raw_status & 0x1) { - if (gpio_irq_handler[pin_offset + HAL_GPIO_PIN_P4_0]) { - gpio_irq_handler[pin_offset + HAL_GPIO_PIN_P4_0](pin_offset + HAL_GPIO_PIN_P4_0 + bank*HAL_GPIO_PIN_NUM_EACH_BANK); - } - } - raw_status >>= 1; - ++pin_offset; + while (raw_status) { + if (raw_status & 0x1) { + if (gpio_irq_handler[pin_offset + HAL_GPIO_PIN_P4_0]) { + gpio_irq_handler[pin_offset + HAL_GPIO_PIN_P4_0]( + pin_offset + HAL_GPIO_PIN_P4_0 + bank * HAL_GPIO_PIN_NUM_EACH_BANK); + } } + raw_status >>= 1; + ++pin_offset; + } } #endif -uint8_t hal_gpio_setup_irq(enum HAL_GPIO_PIN_T pin, const struct HAL_GPIO_IRQ_CFG_T *cfg) -{ - int pin_offset = 0; - int bank = 0, port = 0; +uint8_t hal_gpio_setup_irq(enum HAL_GPIO_PIN_T pin, + const struct HAL_GPIO_IRQ_CFG_T *cfg) { + int pin_offset = 0; + int bank = 0, port = 0; - enum HAL_GPIO_PIN_T max_pin = HAL_GPIO_PIN_NUM; + enum HAL_GPIO_PIN_T max_pin = HAL_GPIO_PIN_NUM; #if defined(PMU_HAS_LED_PIN) && defined(PMU_HAS_LED_IRQ) - max_pin = HAL_GPIO_PIN_LED_NUM; + max_pin = HAL_GPIO_PIN_LED_NUM; #endif - ASSERT(pin < max_pin, err_bad_pin, pin, max_pin); + ASSERT(pin < max_pin, err_bad_pin, pin, max_pin); - if (0) - { - } + if (0) { + } #if defined(PMU_HAS_LED_PIN) && defined(PMU_HAS_LED_IRQ) - else if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) - { - return pmu_gpio_setup_irq(pin, cfg); - } + else if (pin == HAL_GPIO_PIN_LED1 || pin == HAL_GPIO_PIN_LED2) { + return pmu_gpio_setup_irq(pin, cfg); + } #endif #ifdef GPIOAUX_BASE - else if (pin >= HAL_GPIO_PIN_P4_0) - { - bank = HAL_GPIO_AUX_PIN_TO_BANK(pin); - port = HAL_GPIO_AUX_PIN_TO_PORT(pin); - pin_offset = pin%HAL_GPIO_AUX_PIN_NUM_EACH_PORT; + else if (pin >= HAL_GPIO_PIN_P4_0) { + bank = HAL_GPIO_AUX_PIN_TO_BANK(pin); + port = HAL_GPIO_AUX_PIN_TO_PORT(pin); + pin_offset = pin % HAL_GPIO_AUX_PIN_NUM_EACH_PORT; - /* only port A support irq */ - if (port != 0) - return 0; + /* only port A support irq */ + if (port != 0) + return 0; - if (cfg->irq_enable) { - gpio_aux_bank[bank]->GPIO_INTMASK |= (0x1<irq_enable) { + gpio_aux_bank[bank]->GPIO_INTMASK |= (0x1 << pin_offset); - if (cfg->irq_debounce) - gpio_aux_bank[bank]->GPIO_DEBOUNCE |= 0x1<GPIO_DEBOUNCE &= ~(0x1<irq_debounce) + gpio_aux_bank[bank]->GPIO_DEBOUNCE |= 0x1 << pin_offset; + else + gpio_aux_bank[bank]->GPIO_DEBOUNCE &= ~(0x1 << pin_offset); - if (cfg->irq_type == HAL_GPIO_IRQ_TYPE_EDGE_SENSITIVE) - gpio_aux_bank[bank]->GPIO_INTTYPE_LEVEL |= 0x1<GPIO_INTTYPE_LEVEL &= ~(0x1<irq_type == HAL_GPIO_IRQ_TYPE_EDGE_SENSITIVE) + gpio_aux_bank[bank]->GPIO_INTTYPE_LEVEL |= 0x1 << pin_offset; + else + gpio_aux_bank[bank]->GPIO_INTTYPE_LEVEL &= ~(0x1 << pin_offset); - if (cfg->irq_polarity == HAL_GPIO_IRQ_POLARITY_HIGH_RISING) - gpio_aux_bank[bank]->GPIO_INT_POLARITY |= 0x1<GPIO_INT_POLARITY &= ~(0x1<irq_polarity == HAL_GPIO_IRQ_POLARITY_HIGH_RISING) + gpio_aux_bank[bank]->GPIO_INT_POLARITY |= 0x1 << pin_offset; + else + gpio_aux_bank[bank]->GPIO_INT_POLARITY &= ~(0x1 << pin_offset); - gpio_irq_handler[pin] = cfg->irq_handler; + gpio_irq_handler[pin] = cfg->irq_handler; - NVIC_SetVector(GPIOAUX_IRQn, (uint32_t)_gpio_aux_irq_handler[bank]); - NVIC_SetPriority(GPIOAUX_IRQn, IRQ_PRIORITY_NORMAL); - NVIC_EnableIRQ(GPIOAUX_IRQn); + NVIC_SetVector(GPIOAUX_IRQn, (uint32_t)_gpio_aux_irq_handler[bank]); + NVIC_SetPriority(GPIOAUX_IRQn, IRQ_PRIORITY_NORMAL); + NVIC_EnableIRQ(GPIOAUX_IRQn); - gpio_aux_bank[bank]->GPIO_INTMASK &= ~(0x1<GPIO_INTEN |= 0x1<GPIO_INTMASK |= (0x1<GPIO_INTEN &= ~(0x1<GPIO_INTMASK &= ~(0x1 << pin_offset); + gpio_aux_bank[bank]->GPIO_INTEN |= 0x1 << pin_offset; + } else { + gpio_aux_bank[bank]->GPIO_INTMASK |= (0x1 << pin_offset); + gpio_aux_bank[bank]->GPIO_INTEN &= ~(0x1 << pin_offset); + gpio_irq_handler[pin] = 0; } + } #endif - else - { - bank = HAL_GPIO_PIN_TO_BANK(pin); - port = HAL_GPIO_PIN_TO_PORT(pin); - pin_offset = pin%HAL_GPIO_PIN_NUM_EACH_PORT; + else { + bank = HAL_GPIO_PIN_TO_BANK(pin); + port = HAL_GPIO_PIN_TO_PORT(pin); + pin_offset = pin % HAL_GPIO_PIN_NUM_EACH_PORT; - /* only port A support irq */ - if (port != 0) - return 0; + /* only port A support irq */ + if (port != 0) + return 0; - if (cfg->irq_enable) { - gpio_bank[bank]->GPIO_INTMASK |= (0x1<irq_enable) { + gpio_bank[bank]->GPIO_INTMASK |= (0x1 << pin_offset); - if (cfg->irq_debounce) - gpio_bank[bank]->GPIO_DEBOUNCE |= 0x1<GPIO_DEBOUNCE &= ~(0x1<irq_debounce) + gpio_bank[bank]->GPIO_DEBOUNCE |= 0x1 << pin_offset; + else + gpio_bank[bank]->GPIO_DEBOUNCE &= ~(0x1 << pin_offset); - if (cfg->irq_type == HAL_GPIO_IRQ_TYPE_EDGE_SENSITIVE) - gpio_bank[bank]->GPIO_INTTYPE_LEVEL |= 0x1<GPIO_INTTYPE_LEVEL &= ~(0x1<irq_type == HAL_GPIO_IRQ_TYPE_EDGE_SENSITIVE) + gpio_bank[bank]->GPIO_INTTYPE_LEVEL |= 0x1 << pin_offset; + else + gpio_bank[bank]->GPIO_INTTYPE_LEVEL &= ~(0x1 << pin_offset); - if (cfg->irq_polarity == HAL_GPIO_IRQ_POLARITY_HIGH_RISING) - gpio_bank[bank]->GPIO_INT_POLARITY |= 0x1<GPIO_INT_POLARITY &= ~(0x1<irq_polarity == HAL_GPIO_IRQ_POLARITY_HIGH_RISING) + gpio_bank[bank]->GPIO_INT_POLARITY |= 0x1 << pin_offset; + else + gpio_bank[bank]->GPIO_INT_POLARITY &= ~(0x1 << pin_offset); - gpio_irq_handler[pin] = cfg->irq_handler; + gpio_irq_handler[pin] = cfg->irq_handler; - NVIC_SetVector(GPIO_IRQn, (uint32_t)_gpio_irq_handler[bank]); - NVIC_SetPriority(GPIO_IRQn, IRQ_PRIORITY_NORMAL); - NVIC_EnableIRQ(GPIO_IRQn); + NVIC_SetVector(GPIO_IRQn, (uint32_t)_gpio_irq_handler[bank]); + NVIC_SetPriority(GPIO_IRQn, IRQ_PRIORITY_NORMAL); + NVIC_EnableIRQ(GPIO_IRQn); - gpio_bank[bank]->GPIO_INTMASK &= ~(0x1<GPIO_INTEN |= 0x1<GPIO_INTMASK |= (0x1<GPIO_INTEN &= ~(0x1<GPIO_INTMASK &= ~(0x1 << pin_offset); + gpio_bank[bank]->GPIO_INTEN |= 0x1 << pin_offset; + } else { + gpio_bank[bank]->GPIO_INTMASK |= (0x1 << pin_offset); + gpio_bank[bank]->GPIO_INTEN &= ~(0x1 << pin_offset); + gpio_irq_handler[pin] = 0; } - return 0; + } + return 0; } - diff --git a/platform/hal/hal_i2c.c b/platform/hal/hal_i2c.c index a623213..9f8af60 100644 --- a/platform/hal/hal_i2c.c +++ b/platform/hal/hal_i2c.c @@ -13,16 +13,16 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" -#include "plat_addr_map.h" -#include "string.h" #include "hal_i2c.h" +#include "cmsis_nvic.h" +#include "hal_cmu.h" +#include "hal_dma.h" #include "hal_i2cip.h" #include "hal_timer.h" -#include "hal_dma.h" #include "hal_trace.h" -#include "hal_cmu.h" -#include "cmsis_nvic.h" +#include "plat_addr_map.h" +#include "plat_types.h" +#include "string.h" #ifdef RTOS #include "cmsis_os.h" #endif @@ -78,90 +78,91 @@ #define HAL_I2C_WAIT_RFNE_MS (1000) enum HAL_I2C_SM_STATE_T { - HAL_I2C_SM_CLOSED = 0, - HAL_I2C_SM_IDLE, - HAL_I2C_SM_RUNNING, + HAL_I2C_SM_CLOSED = 0, + HAL_I2C_SM_IDLE, + HAL_I2C_SM_RUNNING, }; enum HAL_I2C_SM_TASK_ACTION_T { - HAL_I2C_SM_TASK_ACTION_NONE = 0, - HAL_I2C_SM_TASK_ACTION_M_SEND, - HAL_I2C_SM_TASK_ACTION_M_RECV, + HAL_I2C_SM_TASK_ACTION_NONE = 0, + HAL_I2C_SM_TASK_ACTION_M_SEND, + HAL_I2C_SM_TASK_ACTION_M_RECV, }; enum HAL_I2C_SM_TASK_STATE_T { - HAL_I2C_SM_TASK_STATE_START = (1 << 0), - HAL_I2C_SM_TASK_STATE_STOP = (1 << 1), - HAL_I2C_SM_TASK_STATE_TX_ABRT = (1 << 2), - HAL_I2C_SM_TASK_STATE_ACT = (1 << 3), - HAL_I2C_SM_TASK_STATE_FIFO_ERR = (1 << 4), + HAL_I2C_SM_TASK_STATE_START = (1 << 0), + HAL_I2C_SM_TASK_STATE_STOP = (1 << 1), + HAL_I2C_SM_TASK_STATE_TX_ABRT = (1 << 2), + HAL_I2C_SM_TASK_STATE_ACT = (1 << 3), + HAL_I2C_SM_TASK_STATE_FIFO_ERR = (1 << 4), }; struct HAL_I2C_SM_TASK_T { - /* send or recv buffer */ - const uint8_t *tx_buf; - uint8_t *rx_buf; - uint16_t tx_txn_len; - uint16_t rx_txn_len; - uint16_t txn_cnt; - uint16_t tx_pos; - uint16_t rx_pos; - uint16_t rx_cmd_sent; + /* send or recv buffer */ + const uint8_t *tx_buf; + uint8_t *rx_buf; + uint16_t tx_txn_len; + uint16_t rx_txn_len; + uint16_t txn_cnt; + uint16_t tx_pos; + uint16_t rx_pos; + uint16_t rx_cmd_sent; - /* device control */ - uint8_t stop; - uint8_t restart_after_write; - uint16_t target_addr; + /* device control */ + uint8_t stop; + uint8_t restart_after_write; + uint16_t target_addr; - /* task control */ - uint32_t state; - uint32_t action; + /* task control */ + uint32_t state; + uint32_t action; - /* system control */ - /* TODO : os and non os version */ - volatile uint32_t lock; - uint32_t transfer_id; - uint32_t errcode; - HAL_I2C_TRANSFER_HANDLER_T handler; + /* system control */ + /* TODO : os and non os version */ + volatile uint32_t lock; + uint32_t transfer_id; + uint32_t errcode; + HAL_I2C_TRANSFER_HANDLER_T handler; }; struct HAL_I2C_SM_T { - /* device related */ - struct HAL_I2C_CONFIG_T cfg; + /* device related */ + struct HAL_I2C_CONFIG_T cfg; - enum HAL_I2C_SM_STATE_T state; + enum HAL_I2C_SM_STATE_T state; - /* state machine related */ + /* state machine related */ #if defined(I2C_TASK_MODE) || defined(I2C_SENSOR_ENGINE) - uint8_t in_task; - uint8_t out_task; - uint8_t task_count; - struct HAL_I2C_SM_TASK_T task[HAL_I2C_SM_TASK_NUM_MAX]; + uint8_t in_task; + uint8_t out_task; + uint8_t task_count; + struct HAL_I2C_SM_TASK_T task[HAL_I2C_SM_TASK_NUM_MAX]; - /* dma related */ + /* dma related */ #ifdef I2C_USE_DMA - struct HAL_DMA_CH_CFG_T tx_dma_cfg; - struct HAL_DMA_CH_CFG_T rx_dma_cfg; - /* i2cip cmd_data use 16bit and read action is driven by write action */ - /* when use dma to read from i2c, we need to use another dma to write cmd/stop/restart */ - /* cmd/stop/restart + data use 16bit width, so dma buffer are 2 times of orgin data buffer */ - uint16_t dma_tx_buf[HAL_I2C_SM_DMA_BUF_LEN_MAX / 2]; + struct HAL_DMA_CH_CFG_T tx_dma_cfg; + struct HAL_DMA_CH_CFG_T rx_dma_cfg; + /* i2cip cmd_data use 16bit and read action is driven by write action */ + /* when use dma to read from i2c, we need to use another dma to write + * cmd/stop/restart */ + /* cmd/stop/restart + data use 16bit width, so dma buffer are 2 times of orgin + * data buffer */ + uint16_t dma_tx_buf[HAL_I2C_SM_DMA_BUF_LEN_MAX / 2]; #endif #endif }; /* state machine end */ -struct HAL_I2C_MOD_NAME_T { -}; +struct HAL_I2C_MOD_NAME_T {}; struct HAL_I2C_HW_DESC_T { - uint32_t base; - enum HAL_CMU_MOD_ID_T mod; - enum HAL_CMU_MOD_ID_T apb; - IRQn_Type irq; + uint32_t base; + enum HAL_CMU_MOD_ID_T mod; + enum HAL_CMU_MOD_ID_T apb; + IRQn_Type irq; #ifdef I2C_USE_DMA - enum HAL_DMA_PERIPH_T rx_periph; - enum HAL_DMA_PERIPH_T tx_periph; + enum HAL_DMA_PERIPH_T rx_periph; + enum HAL_DMA_PERIPH_T tx_periph; #endif }; @@ -190,7 +191,7 @@ static const struct HAL_I2C_HW_DESC_T i2c_desc[HAL_I2C_ID_NUM] = { #endif }; -static const char * const invalid_id = "Invalid I2C ID: %d"; +static const char *const invalid_id = "Invalid I2C ID: %d"; static struct HAL_I2C_SM_T hal_i2c_sm[HAL_I2C_ID_NUM]; @@ -211,1850 +212,1910 @@ static void hal_i2c_sensor_eng_proc(enum HAL_I2C_ID_T id); #endif #endif -static uint32_t _i2c_get_base(enum HAL_I2C_ID_T id) -{ - return i2c_desc[id].base; +static uint32_t _i2c_get_base(enum HAL_I2C_ID_T id) { + return i2c_desc[id].base; } -static void POSSIBLY_UNUSED hal_i2c_delay_ms(int ms) -{ - osDelay(ms); +static void POSSIBLY_UNUSED hal_i2c_delay_ms(int ms) { osDelay(ms); } + +static uint32_t _i2c_adjust_period_cnt(uint32_t period_cnt, uint16_t trising_ns, + uint16_t tfalling_ns, + uint16_t pclk_mhz) { + uint32_t old_period_cnt; + uint16_t rising_falling_cycle; + + old_period_cnt = period_cnt; + + // Round down the rising and falling cycle, so that the period count is + // rounded up, and the SCL freq is always <= the requested freq. + rising_falling_cycle = ((trising_ns + tfalling_ns) * pclk_mhz) / 1000; + + if (period_cnt > rising_falling_cycle) { + period_cnt -= rising_falling_cycle; + } else { + period_cnt = 0; + } + + HAL_I2C_TRACE(5, "%s: period_cnt=%u->%u trising_ns=%u tfalling_ns=%u", + __FUNCTION__, old_period_cnt, period_cnt, trising_ns, + tfalling_ns); + + return period_cnt; } -static uint32_t _i2c_adjust_period_cnt(uint32_t period_cnt, uint16_t trising_ns, uint16_t tfalling_ns, uint16_t pclk_mhz) -{ - uint32_t old_period_cnt; - uint16_t rising_falling_cycle; +static void _i2c_get_clk_cnt(uint32_t period_cnt, uint16_t tlow_ns, + uint16_t thigh_ns, uint16_t spklen, + uint16_t pclk_mhz, uint16_t *plcnt, + uint16_t *phcnt) { +#define IC_SCL_LOW_CYCLE_ADD (1) +// NOTE: H/w spec says that (6 + spklen) cycles is added for SCL high interval, +// but tests show that 1 more cycle is needed +#define IC_SCL_HIGH_CYCLE_ADD (6 + spklen + 1) - old_period_cnt = period_cnt; +#define MIN_IC_SCL_LCNT (7 + spklen + IC_SCL_LOW_CYCLE_ADD) +#define MIN_IC_SCL_HCNT (5 + spklen + IC_SCL_HIGH_CYCLE_ADD) - // Round down the rising and falling cycle, so that the period count is rounded up, - // and the SCL freq is always <= the requested freq. - rising_falling_cycle = ((trising_ns + tfalling_ns) * pclk_mhz) / 1000; + uint32_t lcnt, hcnt; + uint16_t min_lcnt, min_hcnt; - if (period_cnt > rising_falling_cycle) { - period_cnt -= rising_falling_cycle; - } else { - period_cnt = 0; - } + HAL_I2C_TRACE( + 6, "%s: period_cnt=%u tlow_ns=%u thigh_ns=%u spklen=%u pclk_mhz=%u", + __FUNCTION__, period_cnt, tlow_ns, thigh_ns, spklen, pclk_mhz); - HAL_I2C_TRACE(5,"%s: period_cnt=%u->%u trising_ns=%u tfalling_ns=%u", - __FUNCTION__, old_period_cnt, period_cnt, trising_ns, tfalling_ns); + min_lcnt = (tlow_ns * pclk_mhz + 1000 - 1) / 1000; + if (min_lcnt < MIN_IC_SCL_LCNT) { + min_lcnt = MIN_IC_SCL_LCNT; + } + min_hcnt = (thigh_ns * pclk_mhz + 1000 - 1) / 1000; + if (min_hcnt < MIN_IC_SCL_HCNT) { + min_hcnt = MIN_IC_SCL_HCNT; + } - return period_cnt; -} - -static void _i2c_get_clk_cnt(uint32_t period_cnt, uint16_t tlow_ns, uint16_t thigh_ns, uint16_t spklen, - uint16_t pclk_mhz, uint16_t *plcnt, uint16_t *phcnt) -{ -#define IC_SCL_LOW_CYCLE_ADD (1) -// NOTE: H/w spec says that (6 + spklen) cycles is added for SCL high interval, but tests show that 1 more cycle is needed -#define IC_SCL_HIGH_CYCLE_ADD (6 + spklen + 1) - -#define MIN_IC_SCL_LCNT (7 + spklen + IC_SCL_LOW_CYCLE_ADD) -#define MIN_IC_SCL_HCNT (5 + spklen + IC_SCL_HIGH_CYCLE_ADD) - - uint32_t lcnt, hcnt; - uint16_t min_lcnt, min_hcnt; - - HAL_I2C_TRACE(6,"%s: period_cnt=%u tlow_ns=%u thigh_ns=%u spklen=%u pclk_mhz=%u", - __FUNCTION__, period_cnt, tlow_ns, thigh_ns, spklen, pclk_mhz); - - min_lcnt = (tlow_ns * pclk_mhz + 1000 - 1) / 1000; - if (min_lcnt < MIN_IC_SCL_LCNT) { - min_lcnt = MIN_IC_SCL_LCNT; - } - min_hcnt = (thigh_ns * pclk_mhz + 1000 - 1) / 1000; - if (min_hcnt < MIN_IC_SCL_HCNT) { - min_hcnt = MIN_IC_SCL_HCNT; - } - - if (min_lcnt + min_hcnt > period_cnt) { - HAL_I2C_ERROR(5,"%s:WARNING: period_cnt=%u too small: min_lcnt=%u min_hcnt=%u pclk_mhz=%u", - __FUNCTION__, period_cnt, min_lcnt, min_hcnt, pclk_mhz); + if (min_lcnt + min_hcnt > period_cnt) { + HAL_I2C_ERROR(5, + "%s:WARNING: period_cnt=%u too small: min_lcnt=%u " + "min_hcnt=%u pclk_mhz=%u", + __FUNCTION__, period_cnt, min_lcnt, min_hcnt, pclk_mhz); + lcnt = min_lcnt; + hcnt = min_hcnt; + } else { + lcnt = (period_cnt + 1) / 2; + if (min_lcnt >= min_hcnt) { + if (lcnt < min_lcnt) { lcnt = min_lcnt; + } + hcnt = period_cnt - lcnt; + if (hcnt < min_hcnt) { hcnt = min_hcnt; + } } else { - lcnt = (period_cnt + 1) / 2; - if (min_lcnt >= min_hcnt) { - if (lcnt < min_lcnt) { - lcnt = min_lcnt; - } - hcnt = period_cnt - lcnt; - if (hcnt < min_hcnt) { - hcnt = min_hcnt; - } - } else { - hcnt = lcnt; - if (hcnt < min_hcnt) { - hcnt = min_hcnt; - } - lcnt = period_cnt - hcnt; - if (lcnt < min_lcnt) { - lcnt = min_lcnt; - } - } + hcnt = lcnt; + if (hcnt < min_hcnt) { + hcnt = min_hcnt; + } + lcnt = period_cnt - hcnt; + if (lcnt < min_lcnt) { + lcnt = min_lcnt; + } } + } - lcnt -= IC_SCL_LOW_CYCLE_ADD; - hcnt -= IC_SCL_HIGH_CYCLE_ADD; + lcnt -= IC_SCL_LOW_CYCLE_ADD; + hcnt -= IC_SCL_HIGH_CYCLE_ADD; - ASSERT(lcnt <= UINT16_MAX && hcnt <= UINT16_MAX, "%s: lcnt=%u or hcnt=%u overflow", __FUNCTION__, lcnt, hcnt); + ASSERT(lcnt <= UINT16_MAX && hcnt <= UINT16_MAX, + "%s: lcnt=%u or hcnt=%u overflow", __FUNCTION__, lcnt, hcnt); - *plcnt = lcnt; - *phcnt = hcnt; + *plcnt = lcnt; + *phcnt = hcnt; } -static void _i2c_set_speed(enum HAL_I2C_ID_T id, int speed_mode, int speed) -{ -#define MAX_HS_SPK_NS 10 -#define MAX_FSP_SPK_NS 50 -#define MAX_FS_SPK_NS 50 +static void _i2c_set_speed(enum HAL_I2C_ID_T id, int speed_mode, int speed) { +#define MAX_HS_SPK_NS 10 +#define MAX_FSP_SPK_NS 50 +#define MAX_FS_SPK_NS 50 -#define SS_THOLD_NS 1800 // [300, 3450] -#define FS_THOLD_NS 600 // [300, 900] -#define FSP_THOLD_NS 300 // [ 0, -] -#define HS_100PF_THOLD_NS 30 // [ 0, 70] -#define HS_400PF_THOLD_NS 70 // [ 0, 150] +#define SS_THOLD_NS 1800 // [300, 3450] +#define FS_THOLD_NS 600 // [300, 900] +#define FSP_THOLD_NS 300 // [ 0, -] +#define HS_100PF_THOLD_NS 30 // [ 0, 70] +#define HS_400PF_THOLD_NS 70 // [ 0, 150] -#define SS_TRISING_NS 300 // [ 0, 1000] -#define FS_TRISING_NS 50 // [ 20, 300] -#define FSP_TRISING_NS 30 // [ 0, 120] -#define HS_100PF_TRISING_NS 30 // [ 10, 40] for SCL, [ 20, 80] for SDA -#define HS_400PF_TRISING_NS 30 // [ 10, 80] for SCL, [ 20, 160] for SDA +#define SS_TRISING_NS 300 // [ 0, 1000] +#define FS_TRISING_NS 50 // [ 20, 300] +#define FSP_TRISING_NS 30 // [ 0, 120] +#define HS_100PF_TRISING_NS 30 // [ 10, 40] for SCL, [ 20, 80] for SDA +#define HS_400PF_TRISING_NS 30 // [ 10, 80] for SCL, [ 20, 160] for SDA -#define SS_TFALLING_NS 30 // [ 0, 300] -#define FS_TFALLING_NS 30 // [ 20, 300] -#define FSP_TFALLING_NS 30 // [ 20, 120] -#define HS_100PF_TFALLING_NS 30 // [ 10, 40] for SCL, [ 20, 80] for SDA -#define HS_400PF_TFALLING_NS 30 // [ 10, 80] for SCL, [ 20, 160] for SDA +#define SS_TFALLING_NS 30 // [ 0, 300] +#define FS_TFALLING_NS 30 // [ 20, 300] +#define FSP_TFALLING_NS 30 // [ 20, 120] +#define HS_100PF_TFALLING_NS 30 // [ 10, 40] for SCL, [ 20, 80] for SDA +#define HS_400PF_TFALLING_NS 30 // [ 10, 80] for SCL, [ 20, 160] for SDA -#define MIN_SS_TLOW_NS 4700 -#define MIN_SS_THIGH_NS 4000 -#define MIN_FS_TLOW_NS 1300 -#define MIN_FS_THIGH_NS 600 -#define MIN_FSP_TLOW_NS 500 -#define MIN_FSP_THIGH_NS 260 -#define MIN_HS_100PF_TLOW_NS 160 -#define MIN_HS_100PF_THIGH_NS 60 -#define MIN_HS_400PF_TLOW_NS 320 -#define MIN_HS_400PF_THIGH_NS 120 +#define MIN_SS_TLOW_NS 4700 +#define MIN_SS_THIGH_NS 4000 +#define MIN_FS_TLOW_NS 1300 +#define MIN_FS_THIGH_NS 600 +#define MIN_FSP_TLOW_NS 500 +#define MIN_FSP_THIGH_NS 260 +#define MIN_HS_100PF_TLOW_NS 160 +#define MIN_HS_100PF_THIGH_NS 60 +#define MIN_HS_400PF_TLOW_NS 320 +#define MIN_HS_400PF_THIGH_NS 120 // Round down the spike suppression limit value -#define GET_SPKLEN_VAL(s) ((s) * pclk_mhz / 1000) +#define GET_SPKLEN_VAL(s) ((s)*pclk_mhz / 1000) - uint32_t reg_base = _i2c_get_base(id); - uint32_t min_mclk, pclk, period_cnt; - uint16_t lcnt, hcnt, hold_cycle, spklen; - uint16_t tlow_ns, thigh_ns, thold_ns, trising_ns, tfalling_ns; - uint8_t spk_ns; - uint16_t pclk_mhz; + uint32_t reg_base = _i2c_get_base(id); + uint32_t min_mclk, pclk, period_cnt; + uint16_t lcnt, hcnt, hold_cycle, spklen; + uint16_t tlow_ns, thigh_ns, thold_ns, trising_ns, tfalling_ns; + uint8_t spk_ns; + uint16_t pclk_mhz; - if (speed_mode == IC_SPEED_MODE_MAX) { - min_mclk = speed * 50; - } else { - min_mclk = speed * 40; - } - pclk = 0; + if (speed_mode == IC_SPEED_MODE_MAX) { + min_mclk = speed * 50; + } else { + min_mclk = speed * 40; + } + pclk = 0; #ifdef PERIPH_PLL_FREQ - if (PERIPH_PLL_FREQ / 2 > 2 * hal_cmu_get_crystal_freq()) { - // Init to OSC_X2 - pclk = 2 * hal_cmu_get_crystal_freq(); - if (min_mclk > pclk) { - pclk = PERIPH_PLL_FREQ / 2; - hal_cmu_i2c_set_div(2); - } else { - pclk = 0; - } - } -#endif - if (pclk == 0) { - enum HAL_CMU_PERIPH_FREQ_T periph_freq; - - // Init to OSC - pclk = hal_cmu_get_crystal_freq(); - if (min_mclk > pclk) { - pclk *= 2; - periph_freq = HAL_CMU_PERIPH_FREQ_52M; - } else { - periph_freq = HAL_CMU_PERIPH_FREQ_26M; - } - - // NOTE: All I2C controllers share the same module clock configuration - hal_cmu_i2c_set_freq(periph_freq); - } - - pclk_mhz = pclk / 1000000; - period_cnt = (pclk + speed - 1) / speed; - - switch (speed_mode) { - case IC_SPEED_MODE_MAX: - - spk_ns = MAX_HS_SPK_NS; - tlow_ns = MIN_HS_100PF_TLOW_NS; - thigh_ns = MIN_HS_100PF_THIGH_NS; - thold_ns = HS_100PF_THOLD_NS; - trising_ns = HS_100PF_TRISING_NS; - tfalling_ns = HS_100PF_TFALLING_NS; - - spklen = GET_SPKLEN_VAL(spk_ns); - if (spklen == 0) { - spklen = 1; - } - i2cip_w_hs_spklen(reg_base, spklen); - - period_cnt = _i2c_adjust_period_cnt(period_cnt, trising_ns, tfalling_ns, pclk_mhz); - _i2c_get_clk_cnt(period_cnt, tlow_ns, thigh_ns, spklen, pclk_mhz, &lcnt, &hcnt); - - i2cip_w_high_speed_hcnt(reg_base, hcnt); - i2cip_w_high_speed_lcnt(reg_base, lcnt); - - i2cip_w_speed(reg_base, I2CIP_HIGH_SPEED_MASK); - - // Continue to config fast mode -#ifdef I2S_FSP_MODE - period_cnt = (pclk + I2C_FSP_SPEED - 1) / I2C_FSP_SPEED; -#else - period_cnt = (pclk + I2C_FAST_SPEED - 1) / I2C_FAST_SPEED; -#endif - - case IC_SPEED_MODE_FAST: - -#ifdef I2S_FSP_MODE - if (speed > I2C_FAST_SPEED) { - spk_ns = MAX_FSP_SPK_NS; - tlow_ns = MIN_FSP_TLOW_NS; - thigh_ns = MIN_FSP_THIGH_NS; - thold_ns = FSP_THOLD_NS; - trising_ns = FSP_TRISING_NS; - tfalling_ns = FSP_TFALLING_NS; - } else -#endif - { - spk_ns = MAX_FS_SPK_NS; - tlow_ns = MIN_FS_TLOW_NS; - thigh_ns = MIN_FS_THIGH_NS; - trising_ns = FS_TRISING_NS; - tfalling_ns = FS_TFALLING_NS; - } - - spklen = GET_SPKLEN_VAL(spk_ns); - if (spklen == 0) { - spklen = 1; - } - i2cip_w_fs_spklen(reg_base, spklen); - - period_cnt = _i2c_adjust_period_cnt(period_cnt, trising_ns, tfalling_ns, pclk_mhz); - _i2c_get_clk_cnt(period_cnt, tlow_ns, thigh_ns, spklen, pclk_mhz, &lcnt, &hcnt); - - i2cip_w_fast_speed_hcnt(reg_base, hcnt); - i2cip_w_fast_speed_lcnt(reg_base, lcnt); - - // Update sda hold time and speed mode if in fast mode - // Skip if in high speed mode - if (speed_mode == IC_SPEED_MODE_FAST) { - thold_ns = FS_THOLD_NS; - i2cip_w_speed(reg_base, I2CIP_FAST_SPEED_MASK); - } - - break; - - case IC_SPEED_MODE_STANDARD: - default: - - spk_ns = MAX_FS_SPK_NS; - tlow_ns = MIN_SS_TLOW_NS; - thigh_ns = MIN_SS_THIGH_NS; - thold_ns = SS_THOLD_NS; - trising_ns = SS_TRISING_NS; - tfalling_ns = SS_TFALLING_NS; - - spklen = GET_SPKLEN_VAL(spk_ns); - if (spklen == 0) { - spklen = 1; - } - i2cip_w_fs_spklen(reg_base, spklen); - - period_cnt = _i2c_adjust_period_cnt(period_cnt, trising_ns, tfalling_ns, pclk_mhz); - _i2c_get_clk_cnt(period_cnt, tlow_ns, thigh_ns, spklen, pclk_mhz, &lcnt, &hcnt); - - i2cip_w_standard_speed_hcnt(reg_base, hcnt); - i2cip_w_standard_speed_lcnt(reg_base, lcnt); - i2cip_w_speed(reg_base, I2CIP_STANDARD_SPEED_MASK); - break; - } - - // Master mode: min = 1; slave mode: min = (spklen + 7) - hold_cycle = (thold_ns * pclk_mhz + 1000 - 1) / 1000; - i2cip_w_sda_hold_time(reg_base, hold_cycle); - - HAL_I2C_TRACE(1,"crystal freq=%d", pclk); - HAL_I2C_TRACE(5,"i2c-%d mode=%d lcnt=%d hcnt=%d hold=%d", - id, speed_mode, lcnt, hcnt, hold_cycle); -} - -static uint8_t _i2c_set_bus_speed(enum HAL_I2C_ID_T id, - unsigned int speed) -{ - uint32_t speed_mode; - - if (speed > I2C_FSP_SPEED) - speed_mode = IC_SPEED_MODE_MAX; - else if (speed > I2C_FAST_SPEED) -#ifdef I2S_FSP_MODE - speed_mode = IC_SPEED_MODE_FAST; -#else - speed_mode = IC_SPEED_MODE_MAX; -#endif - else if (speed > I2C_STANDARD_SPEED) - speed_mode = IC_SPEED_MODE_FAST; - else - speed_mode = IC_SPEED_MODE_STANDARD; - - _i2c_set_speed(id, speed_mode, speed); - - return 0; -} - -/* state machine related */ -static void hal_i2c_sm_init(enum HAL_I2C_ID_T id, const struct HAL_I2C_CONFIG_T *cfg) -{ - memcpy(&hal_i2c_sm[id].cfg, cfg, sizeof(*cfg)); - hal_i2c_sm[id].state = HAL_I2C_SM_IDLE; -#if defined(I2C_TASK_MODE) || defined(I2C_SENSOR_ENGINE) - hal_i2c_sm[id].in_task = 0; - hal_i2c_sm[id].out_task = 0; - hal_i2c_sm[id].task_count = 0; - -#ifdef I2C_USE_DMA - hal_i2c_sm[id].tx_dma_cfg.ch = HAL_DMA_CHAN_NONE; - hal_i2c_sm[id].rx_dma_cfg.ch = HAL_DMA_CHAN_NONE; -#else - hal_i2c_sm[id].cfg.use_dma = 0; -#endif -#endif -} - -#if defined(I2C_TASK_MODE) || defined(I2C_SENSOR_ENGINE) -static uint32_t hal_i2c_sm_commit(enum HAL_I2C_ID_T id, const uint8_t *tx_buf, uint16_t tx_txn_len, - uint8_t *rx_buf, uint16_t rx_txn_len, uint16_t txn_cnt, - uint16_t target_addr, uint32_t action, - uint32_t transfer_id, HAL_I2C_TRANSFER_HANDLER_T handler) -{ - uint32_t cur = hal_i2c_sm[id].in_task; - - hal_i2c_sm[id].task[cur].tx_buf = tx_buf; - hal_i2c_sm[id].task[cur].rx_buf = rx_buf; - hal_i2c_sm[id].task[cur].stop = 1; - hal_i2c_sm[id].task[cur].lock = 1; - hal_i2c_sm[id].task[cur].state = 0; - hal_i2c_sm[id].task[cur].rx_txn_len = rx_txn_len; - hal_i2c_sm[id].task[cur].tx_txn_len = tx_txn_len; - hal_i2c_sm[id].task[cur].txn_cnt = txn_cnt; - hal_i2c_sm[id].task[cur].tx_pos = 0; - hal_i2c_sm[id].task[cur].rx_pos = 0; - hal_i2c_sm[id].task[cur].rx_cmd_sent = 0; - hal_i2c_sm[id].task[cur].errcode = 0; - hal_i2c_sm[id].task[cur].action = action; - hal_i2c_sm[id].task[cur].handler = handler; - hal_i2c_sm[id].task[cur].restart_after_write = 1; - hal_i2c_sm[id].task[cur].target_addr = target_addr; - hal_i2c_sm[id].task[cur].transfer_id = transfer_id; - - hal_i2c_sm[id].in_task = (cur + 1) % HAL_I2C_SM_TASK_NUM_MAX; - hal_i2c_sm[id].task_count++; - return cur; -} - -static void hal_i2c_sm_done(enum HAL_I2C_ID_T id) -{ - hal_i2c_sm[id].in_task = 0; - hal_i2c_sm[id].out_task = 0; - hal_i2c_sm[id].task_count = 0; - hal_i2c_sm[id].state = HAL_I2C_SM_IDLE; - - HAL_I2C_TRACE(1,"%s", __func__); -} - -static enum HAL_I2C_SM_TASK_STATE_T _i2c_chk_clr_task_error(uint32_t reg_base, uint32_t ip_int_status, uint32_t tx_abrt_source) -{ - enum HAL_I2C_SM_TASK_STATE_T state = 0; - uint32_t tmp1; - - /* tx abort interrupt */ - if (ip_int_status & I2CIP_INT_STATUS_TX_ABRT_MASK) { - state |= HAL_I2C_SM_TASK_STATE_TX_ABRT; - - /* sbyte_norstrt is special to clear : restart disable but user want to send a restart */ - /* to fix this bit : enable restart , clear speical , clear gc_or_start bit temporary */ - tmp1 = i2cip_r_target_address_reg(reg_base); - if (tx_abrt_source & I2CIP_TX_ABRT_SOURCE_ABRT_SBYTE_NORSTRT_MASK) { - i2cip_w_restart(reg_base, HAL_I2C_YES); - i2cip_w_special_bit(reg_base, HAL_I2C_NO); - i2cip_w_gc_or_start_bit(reg_base, HAL_I2C_NO); - } - i2cip_r_clr_tx_abrt(reg_base); - /* restore register after clear */ - if (tx_abrt_source & I2CIP_TX_ABRT_SOURCE_ABRT_SBYTE_NORSTRT_MASK) { - i2cip_w_target_address_reg(reg_base, tmp1); - } - } - /* tx overflow interrupt */ - if (ip_int_status & I2CIP_INT_MASK_TX_OVER_MASK) { - state |= HAL_I2C_SM_TASK_STATE_FIFO_ERR; - i2cip_r_clr_tx_over(reg_base); - } - /* rx overflow interrupt */ - if (ip_int_status & I2CIP_INT_MASK_RX_OVER_MASK) { - state |= HAL_I2C_SM_TASK_STATE_FIFO_ERR; - i2cip_r_clr_rx_over(reg_base); - } - /* rx underflow interrupt */ - if (ip_int_status & I2CIP_INT_MASK_RX_UNDER_MASK) { - state |= HAL_I2C_SM_TASK_STATE_FIFO_ERR; - i2cip_r_clr_rx_under(reg_base); - } - - return state; -} - -static void _i2c_show_error_code(uint32_t errcode) -{ -#ifdef DEBUG - if (errcode & HAL_I2C_ERRCODE_SLVRD_INTX) - HAL_I2C_ERROR(0,"i2c err : HAL_I2C_ERRCODE_SLVRD_INTX"); - if (errcode & HAL_I2C_ERRCODE_SLV_ARBLOST) - HAL_I2C_ERROR(0,"i2c err : HAL_I2C_ERRCODE_SLV_ARBLOST"); - if (errcode & HAL_I2C_ERRCODE_SLVFLUSH_TXFIFO) - HAL_I2C_ERROR(0,"i2c err : HAL_I2C_ERRCODE_SLVFLUSH_TXFIFO"); - if (errcode & HAL_I2C_ERRCODE_MASTER_DIS) - HAL_I2C_ERROR(0,"i2c err : HAL_I2C_ERRCODE_MASTER_DIS"); - if (errcode & HAL_I2C_ERRCODE_10B_RD_NORSTRT) - HAL_I2C_ERROR(0,"i2c err : HAL_I2C_ERRCODE_10B_RD_NORSTRT"); - if (errcode & HAL_I2C_ERRCODE_SBYTE_NORSTRT) - HAL_I2C_ERROR(0,"i2c err : HAL_I2C_ERRCODE_SBYTE_NORSTRT"); - if (errcode & HAL_I2C_ERRCODE_HS_NORSTRT) - HAL_I2C_ERROR(0,"i2c err : HAL_I2C_ERRCODE_HS_NORSTRT"); - if (errcode & HAL_I2C_ERRCODE_SBYTE_ACKDET) - HAL_I2C_ERROR(0,"i2c err : HAL_I2C_ERRCODE_SBYTE_ACKDET"); - if (errcode & HAL_I2C_ERRCODE_HS_ACKDET) - HAL_I2C_ERROR(0,"i2c err : HAL_I2C_ERRCODE_HS_ACKDET"); - if (errcode & HAL_I2C_ERRCODE_GCALL_READ) - HAL_I2C_ERROR(0,"i2c err : HAL_I2C_ERRCODE_GCALL_READ"); - if (errcode & HAL_I2C_ERRCODE_GCALL_NOACK) - HAL_I2C_ERROR(0,"i2c err : HAL_I2C_ERRCODE_GCALL_NOACK"); - if (errcode & HAL_I2C_ERRCODE_TXDATA_NOACK) - HAL_I2C_ERROR(0,"i2c err : HAL_I2C_ERRCODE_TXDATA_NOACK"); - if (errcode & HAL_I2C_ERRCODE_10ADDR2_NOACK) - HAL_I2C_ERROR(0,"i2c err : HAL_I2C_ERRCODE_10ADDR2_NOACK"); - if (errcode & HAL_I2C_ERRCODE_10ADDR1_NOACK) - HAL_I2C_ERROR(0,"i2c err : HAL_I2C_ERRCODE_10ADDR1_NOACK"); - if (errcode & HAL_I2C_ERRCODE_7B_ADDR_NOACK) - HAL_I2C_ERROR(0,"i2c err : HAL_I2C_ERRCODE_7B_ADDR_NOACK"); - - if (errcode & HAL_I2C_ERRCODE_INV_PARAM) - HAL_I2C_ERROR(0,"i2c err : HAL_I2C_ERRCODE_INV_PARAM"); - if (errcode & HAL_I2C_ERRCODE_IN_USE) - HAL_I2C_ERROR(0,"i2c err : HAL_I2C_ERRCODE_IN_USE"); - if (errcode & HAL_I2C_ERRCODE_FIFO_ERR) - HAL_I2C_ERROR(0,"i2c err : HAL_I2C_ERRCODE_FIFO_ERR"); -#endif -} - -#ifdef I2C_USE_DMA -static void hal_i2c_tx_dma_handler(uint8_t chan, uint32_t remain_tsize, uint32_t error, struct HAL_DMA_DESC_T *lli) -{ - enum HAL_I2C_ID_T id; - - for (id = HAL_I2C_ID_0; id < HAL_I2C_ID_NUM; id++) { - if (hal_i2c_sm[id].tx_dma_cfg.ch == chan) { - } - } -} - -static void hal_i2c_rx_dma_handler(uint8_t chan, uint32_t remain_tsize, uint32_t error, struct HAL_DMA_DESC_T *lli) -{ - enum HAL_I2C_ID_T id; - - for (id = HAL_I2C_ID_0; id < HAL_I2C_ID_NUM; id++) { - if (hal_i2c_sm[id].rx_dma_cfg.ch == chan) { - } - } -} - -static void hal_i2c_dma_release(enum HAL_I2C_ID_T id) -{ - uint32_t reg_base; - struct HAL_DMA_CH_CFG_T *tx_dma_cfg = NULL, *rx_dma_cfg = NULL; - - if (hal_i2c_sm[id].cfg.use_dma == 0) { - return; - } - - reg_base = _i2c_get_base(id); - - i2cip_w_tx_dma_enable(reg_base, HAL_I2C_NO); - i2cip_w_rx_dma_enable(reg_base, HAL_I2C_NO); - - tx_dma_cfg = &hal_i2c_sm[id].tx_dma_cfg; - rx_dma_cfg = &hal_i2c_sm[id].rx_dma_cfg; - - HAL_I2C_TRACE(1,"i2c tx free dma ch %d", tx_dma_cfg->ch); - if (tx_dma_cfg->ch != HAL_DMA_CHAN_NONE) { - hal_gpdma_cancel(tx_dma_cfg->ch); - hal_gpdma_free_chan(tx_dma_cfg->ch); - tx_dma_cfg->ch = HAL_DMA_CHAN_NONE; - } - - HAL_I2C_TRACE(1,"i2c rx free dma ch %d", rx_dma_cfg->ch); - if (rx_dma_cfg->ch != HAL_DMA_CHAN_NONE) { - hal_gpdma_cancel(rx_dma_cfg->ch); - hal_gpdma_free_chan(rx_dma_cfg->ch); - rx_dma_cfg->ch = HAL_DMA_CHAN_NONE; - } -} - -static void hal_i2c_dma_config(enum HAL_I2C_ID_T id, const struct HAL_I2C_SM_TASK_T *out_task) -{ - uint32_t reg_base; - uint32_t i, txn; - uint32_t txn_start, org_start; - struct HAL_DMA_CH_CFG_T *tx_dma_cfg = NULL, *rx_dma_cfg = NULL; - enum HAL_I2C_SM_TASK_ACTION_T action; - uint32_t total_tx_len; - - if (hal_i2c_sm[id].cfg.use_dma == 0) { - return; - } - - reg_base = _i2c_get_base(id); - action = out_task->action; - - total_tx_len = out_task->tx_txn_len * out_task->txn_cnt; - if (action == HAL_I2C_SM_TASK_ACTION_M_RECV) { - total_tx_len += out_task->rx_txn_len * out_task->txn_cnt; - } - ASSERT(total_tx_len < ARRAY_SIZE(hal_i2c_sm[id].dma_tx_buf), - "%s: xfer size too large: action=%d total_tx_len=%u (should <= %u)", - __FUNCTION__, action, total_tx_len, ARRAY_SIZE(hal_i2c_sm[id].dma_tx_buf)); - - i2cip_w_tx_dma_enable(reg_base, HAL_I2C_YES); - i2cip_w_tx_dma_tl(reg_base, HAL_I2C_DMA_TX_TL); - - tx_dma_cfg = &hal_i2c_sm[id].tx_dma_cfg; - memset(tx_dma_cfg, 0, sizeof(*tx_dma_cfg)); - tx_dma_cfg->dst = 0; // useless - tx_dma_cfg->dst_bsize = HAL_DMA_BSIZE_1; - tx_dma_cfg->dst_periph = i2c_desc[id].tx_periph; - tx_dma_cfg->dst_width = HAL_DMA_WIDTH_HALFWORD; - tx_dma_cfg->handler = hal_i2c_tx_dma_handler; - tx_dma_cfg->src_bsize = HAL_DMA_BSIZE_1; - tx_dma_cfg->src_periph = 0; // useless - tx_dma_cfg->src_tsize = total_tx_len; - tx_dma_cfg->src_width = HAL_DMA_WIDTH_HALFWORD; - tx_dma_cfg->try_burst = 1; - tx_dma_cfg->type = HAL_DMA_FLOW_M2P_DMA; - tx_dma_cfg->src = (uint32_t)hal_i2c_sm[id].dma_tx_buf; - tx_dma_cfg->ch = hal_gpdma_get_chan(tx_dma_cfg->dst_periph, HAL_DMA_HIGH_PRIO); - HAL_I2C_TRACE(1,"i2c tx get dma ch %d", tx_dma_cfg->ch); - ASSERT(tx_dma_cfg->ch != HAL_DMA_CHAN_NONE, "I2C: Failed to get tx dma chan"); - - HAL_I2C_TRACE(3,"tx size %d cnt %d total tx size %d", out_task->tx_txn_len, out_task->txn_cnt, total_tx_len); - - memset(&hal_i2c_sm[id].dma_tx_buf[0], 0, sizeof(hal_i2c_sm[id].dma_tx_buf)); - - for (txn = 0; txn < out_task->txn_cnt; txn++) { - org_start = out_task->tx_txn_len * txn; - txn_start = (out_task->tx_txn_len + out_task->rx_txn_len) * txn; - for (i = 0; i < out_task->tx_txn_len; i++) { - // lo byte of short : for data - // hi byte of short : for cmd/stop/restart - hal_i2c_sm[id].dma_tx_buf[txn_start + i] = out_task->tx_buf[org_start + i]; - } - if (txn && out_task->restart_after_write) { - hal_i2c_sm[id].dma_tx_buf[txn_start] |= I2CIP_CMD_DATA_RESTART_MASK; - } - } - - if (action == HAL_I2C_SM_TASK_ACTION_M_RECV) { - i2cip_w_rx_dma_enable(reg_base, HAL_I2C_YES); - i2cip_w_rx_dma_tl(reg_base, HAL_I2C_DMA_RX_TL); - - for (txn = 0; txn < out_task->txn_cnt; txn++) { - txn_start = (out_task->tx_txn_len + out_task->rx_txn_len) * txn + out_task->tx_txn_len; - for (i = 0; i < out_task->rx_txn_len; i++) { - // lo byte of short : for data - // hi byte of short : for cmd/stop/restart - hal_i2c_sm[id].dma_tx_buf[txn_start + i] = I2CIP_CMD_DATA_CMD_READ_MASK; - } - if (out_task->restart_after_write) { - hal_i2c_sm[id].dma_tx_buf[txn_start] |= I2CIP_CMD_DATA_RESTART_MASK; - } - } - - HAL_I2C_TRACE(2,"rx size %d cnt %d", out_task->rx_txn_len, out_task->txn_cnt); - - rx_dma_cfg = &hal_i2c_sm[id].rx_dma_cfg; - memset(rx_dma_cfg, 0, sizeof(*rx_dma_cfg)); - rx_dma_cfg->dst = (uint32_t)(out_task->rx_buf); - rx_dma_cfg->dst_bsize = HAL_DMA_BSIZE_1; - rx_dma_cfg->dst_periph = 0; // useless - rx_dma_cfg->dst_width = HAL_DMA_WIDTH_BYTE; - rx_dma_cfg->handler = hal_i2c_rx_dma_handler; - rx_dma_cfg->src_bsize = HAL_DMA_BSIZE_1; - rx_dma_cfg->src_periph = i2c_desc[id].rx_periph; - rx_dma_cfg->src_tsize = out_task->rx_txn_len * out_task->txn_cnt; - rx_dma_cfg->src_width = HAL_DMA_WIDTH_BYTE; - rx_dma_cfg->try_burst = 0; - rx_dma_cfg->src = 0; // useless - rx_dma_cfg->type = HAL_DMA_FLOW_P2M_DMA; - rx_dma_cfg->ch = hal_gpdma_get_chan(rx_dma_cfg->src_periph, HAL_DMA_HIGH_PRIO); - HAL_I2C_TRACE(1,"i2c rx get dma ch %d", rx_dma_cfg->ch); - ASSERT(tx_dma_cfg->ch != HAL_DMA_CHAN_NONE, "I2C: Failed to get rx dma chan"); - } - - if (out_task->stop) { - hal_i2c_sm[id].dma_tx_buf[total_tx_len - 1] |= I2CIP_CMD_DATA_STOP_MASK; - } -} -#endif -#endif - -#ifdef I2C_TASK_MODE -static void hal_i2c_sm_done_task(enum HAL_I2C_ID_T id) -{ - struct HAL_I2C_SM_TASK_T *task; - uint32_t reg_base = _i2c_get_base(id); - - task = &(hal_i2c_sm[id].task[hal_i2c_sm[id].out_task]); - - if (task->errcode) { - HAL_I2C_ERROR(1,"i2c err : 0x%X", task->errcode); - _i2c_show_error_code(task->errcode); - } - - if (task->stop || task->errcode) { - HAL_I2C_TRACE(0,"disable i2c"); - i2cip_w_enable(reg_base, HAL_I2C_NO); - } - -#ifdef I2C_USE_DMA - if (hal_i2c_sm[id].cfg.use_dma) { - hal_i2c_dma_release(id); - } -#endif - - if (hal_i2c_sm[id].cfg.use_sync) { - /* FIXME : os and non-os - different proc */ - task->lock = 0; + if (PERIPH_PLL_FREQ / 2 > 2 * hal_cmu_get_crystal_freq()) { + // Init to OSC_X2 + pclk = 2 * hal_cmu_get_crystal_freq(); + if (min_mclk > pclk) { + pclk = PERIPH_PLL_FREQ / 2; + hal_cmu_i2c_set_div(2); } else { - if (task->handler) { - task->handler(id, task->transfer_id, task->tx_buf, task->tx_txn_len * task->txn_cnt, - task->rx_buf, task->rx_txn_len * task->txn_cnt, task->errcode); - } + pclk = 0; + } + } +#endif + if (pclk == 0) { + enum HAL_CMU_PERIPH_FREQ_T periph_freq; + + // Init to OSC + pclk = hal_cmu_get_crystal_freq(); + if (min_mclk > pclk) { + pclk *= 2; + periph_freq = HAL_CMU_PERIPH_FREQ_52M; + } else { + periph_freq = HAL_CMU_PERIPH_FREQ_26M; } - hal_i2c_sm[id].out_task = (hal_i2c_sm[id].out_task+1)%HAL_I2C_SM_TASK_NUM_MAX; - --hal_i2c_sm[id].task_count; -} + // NOTE: All I2C controllers share the same module clock configuration + hal_cmu_i2c_set_freq(periph_freq); + } -static void hal_i2c_sm_next_task(enum HAL_I2C_ID_T id) -{ - uint32_t out_task_index; - uint32_t reg_base, reinit; - enum HAL_I2C_SM_TASK_ACTION_T action; - struct HAL_I2C_SM_TASK_T *out_task = 0; + pclk_mhz = pclk / 1000000; + period_cnt = (pclk + speed - 1) / speed; - reg_base = _i2c_get_base(id); + switch (speed_mode) { + case IC_SPEED_MODE_MAX: - if (hal_i2c_sm[id].task_count <= 0) { - HAL_I2C_TRACE(0,"no task"); - hal_i2c_sm_done(id); - return; + spk_ns = MAX_HS_SPK_NS; + tlow_ns = MIN_HS_100PF_TLOW_NS; + thigh_ns = MIN_HS_100PF_THIGH_NS; + thold_ns = HS_100PF_THOLD_NS; + trising_ns = HS_100PF_TRISING_NS; + tfalling_ns = HS_100PF_TFALLING_NS; + + spklen = GET_SPKLEN_VAL(spk_ns); + if (spklen == 0) { + spklen = 1; } + i2cip_w_hs_spklen(reg_base, spklen); - out_task_index = hal_i2c_sm[id].out_task; - out_task = &(hal_i2c_sm[id].task[out_task_index]); - action = out_task->action; + period_cnt = + _i2c_adjust_period_cnt(period_cnt, trising_ns, tfalling_ns, pclk_mhz); + _i2c_get_clk_cnt(period_cnt, tlow_ns, thigh_ns, spklen, pclk_mhz, &lcnt, + &hcnt); - /* tx : quarter trigger TX EMPTY INT */ - i2cip_w_tx_threshold(reg_base, HAL_I2C_TX_TL); - if (action == HAL_I2C_SM_TASK_ACTION_M_RECV) { - /* rx : three quarter trigger RX FULL INT */ - i2cip_w_rx_threshold(reg_base, HAL_I2C_RX_TL); - } + i2cip_w_high_speed_hcnt(reg_base, hcnt); + i2cip_w_high_speed_lcnt(reg_base, lcnt); -#ifdef I2C_USE_DMA - if (hal_i2c_sm[id].cfg.use_dma) { - i2cip_init_int_mask(reg_base, I2CIP_INT_MASK_STOP_DET_MASK|I2CIP_INT_MASK_ERROR_MASK); + i2cip_w_speed(reg_base, I2CIP_HIGH_SPEED_MASK); - /* prepare for dma operation */ - hal_i2c_dma_config(id, out_task); + // Continue to config fast mode +#ifdef I2S_FSP_MODE + period_cnt = (pclk + I2C_FSP_SPEED - 1) / I2C_FSP_SPEED; +#else + period_cnt = (pclk + I2C_FAST_SPEED - 1) / I2C_FAST_SPEED; +#endif + + case IC_SPEED_MODE_FAST: + +#ifdef I2S_FSP_MODE + if (speed > I2C_FAST_SPEED) { + spk_ns = MAX_FSP_SPK_NS; + tlow_ns = MIN_FSP_TLOW_NS; + thigh_ns = MIN_FSP_THIGH_NS; + thold_ns = FSP_THOLD_NS; + trising_ns = FSP_TRISING_NS; + tfalling_ns = FSP_TFALLING_NS; } else #endif { - /* open all interrupt */ - i2cip_init_int_mask(reg_base, (I2CIP_INT_MASK_ALL & ~(I2CIP_INT_MASK_START_DET_MASK | I2CIP_INT_MASK_ACTIVITY_MASK))); + spk_ns = MAX_FS_SPK_NS; + tlow_ns = MIN_FS_TLOW_NS; + thigh_ns = MIN_FS_THIGH_NS; + trising_ns = FS_TRISING_NS; + tfalling_ns = FS_TFALLING_NS; } - reinit = i2cip_r_enable_status(reg_base); - /* not enable : reconfig i2cip with new-task params */ - /* enable : same operation with pre task */ - if (!(reinit & I2CIP_ENABLE_STATUS_ENABLE_MASK)) { - HAL_I2C_TRACE(0,"enable i2c"); - i2cip_w_restart(reg_base, HAL_I2C_YES); - i2cip_w_target_address(reg_base, out_task->target_addr); - i2cip_w_enable(reg_base, HAL_I2C_YES); + spklen = GET_SPKLEN_VAL(spk_ns); + if (spklen == 0) { + spklen = 1; } + i2cip_w_fs_spklen(reg_base, spklen); + + period_cnt = + _i2c_adjust_period_cnt(period_cnt, trising_ns, tfalling_ns, pclk_mhz); + _i2c_get_clk_cnt(period_cnt, tlow_ns, thigh_ns, spklen, pclk_mhz, &lcnt, + &hcnt); + + i2cip_w_fast_speed_hcnt(reg_base, hcnt); + i2cip_w_fast_speed_lcnt(reg_base, lcnt); + + // Update sda hold time and speed mode if in fast mode + // Skip if in high speed mode + if (speed_mode == IC_SPEED_MODE_FAST) { + thold_ns = FS_THOLD_NS; + i2cip_w_speed(reg_base, I2CIP_FAST_SPEED_MASK); + } + + break; + + case IC_SPEED_MODE_STANDARD: + default: + + spk_ns = MAX_FS_SPK_NS; + tlow_ns = MIN_SS_TLOW_NS; + thigh_ns = MIN_SS_THIGH_NS; + thold_ns = SS_THOLD_NS; + trising_ns = SS_TRISING_NS; + tfalling_ns = SS_TFALLING_NS; + + spklen = GET_SPKLEN_VAL(spk_ns); + if (spklen == 0) { + spklen = 1; + } + i2cip_w_fs_spklen(reg_base, spklen); + + period_cnt = + _i2c_adjust_period_cnt(period_cnt, trising_ns, tfalling_ns, pclk_mhz); + _i2c_get_clk_cnt(period_cnt, tlow_ns, thigh_ns, spklen, pclk_mhz, &lcnt, + &hcnt); + + i2cip_w_standard_speed_hcnt(reg_base, hcnt); + i2cip_w_standard_speed_lcnt(reg_base, lcnt); + i2cip_w_speed(reg_base, I2CIP_STANDARD_SPEED_MASK); + break; + } + + // Master mode: min = 1; slave mode: min = (spklen + 7) + hold_cycle = (thold_ns * pclk_mhz + 1000 - 1) / 1000; + i2cip_w_sda_hold_time(reg_base, hold_cycle); + + HAL_I2C_TRACE(1, "crystal freq=%d", pclk); + HAL_I2C_TRACE(5, "i2c-%d mode=%d lcnt=%d hcnt=%d hold=%d", id, speed_mode, + lcnt, hcnt, hold_cycle); +} + +static uint8_t _i2c_set_bus_speed(enum HAL_I2C_ID_T id, unsigned int speed) { + uint32_t speed_mode; + + if (speed > I2C_FSP_SPEED) + speed_mode = IC_SPEED_MODE_MAX; + else if (speed > I2C_FAST_SPEED) +#ifdef I2S_FSP_MODE + speed_mode = IC_SPEED_MODE_FAST; +#else + speed_mode = IC_SPEED_MODE_MAX; +#endif + else if (speed > I2C_STANDARD_SPEED) + speed_mode = IC_SPEED_MODE_FAST; + else + speed_mode = IC_SPEED_MODE_STANDARD; + + _i2c_set_speed(id, speed_mode, speed); + + return 0; +} + +/* state machine related */ +static void hal_i2c_sm_init(enum HAL_I2C_ID_T id, + const struct HAL_I2C_CONFIG_T *cfg) { + memcpy(&hal_i2c_sm[id].cfg, cfg, sizeof(*cfg)); + hal_i2c_sm[id].state = HAL_I2C_SM_IDLE; +#if defined(I2C_TASK_MODE) || defined(I2C_SENSOR_ENGINE) + hal_i2c_sm[id].in_task = 0; + hal_i2c_sm[id].out_task = 0; + hal_i2c_sm[id].task_count = 0; #ifdef I2C_USE_DMA - if (hal_i2c_sm[id].cfg.use_dma) { - if (action == HAL_I2C_SM_TASK_ACTION_M_RECV) { - HAL_I2C_TRACE(0,"enable rx dma"); - hal_gpdma_start(&hal_i2c_sm[id].rx_dma_cfg); - } - HAL_I2C_TRACE(0,"enable tx dma"); - hal_gpdma_start(&hal_i2c_sm[id].tx_dma_cfg); - } + hal_i2c_sm[id].tx_dma_cfg.ch = HAL_DMA_CHAN_NONE; + hal_i2c_sm[id].rx_dma_cfg.ch = HAL_DMA_CHAN_NONE; +#else + hal_i2c_sm[id].cfg.use_dma = 0; +#endif #endif } -static uint32_t hal_i2c_sm_wait_task_if_need(enum HAL_I2C_ID_T id, uint32_t task_idx, uint32_t tm_ms) -{ - int tmcnt; - struct HAL_I2C_SM_TASK_T *task = 0; +#if defined(I2C_TASK_MODE) || defined(I2C_SENSOR_ENGINE) +static uint32_t hal_i2c_sm_commit(enum HAL_I2C_ID_T id, const uint8_t *tx_buf, + uint16_t tx_txn_len, uint8_t *rx_buf, + uint16_t rx_txn_len, uint16_t txn_cnt, + uint16_t target_addr, uint32_t action, + uint32_t transfer_id, + HAL_I2C_TRANSFER_HANDLER_T handler) { + uint32_t cur = hal_i2c_sm[id].in_task; - /* FIXME : task_id maybe invalid cause so-fast device operation */ - task = &(hal_i2c_sm[id].task[task_idx]); + hal_i2c_sm[id].task[cur].tx_buf = tx_buf; + hal_i2c_sm[id].task[cur].rx_buf = rx_buf; + hal_i2c_sm[id].task[cur].stop = 1; + hal_i2c_sm[id].task[cur].lock = 1; + hal_i2c_sm[id].task[cur].state = 0; + hal_i2c_sm[id].task[cur].rx_txn_len = rx_txn_len; + hal_i2c_sm[id].task[cur].tx_txn_len = tx_txn_len; + hal_i2c_sm[id].task[cur].txn_cnt = txn_cnt; + hal_i2c_sm[id].task[cur].tx_pos = 0; + hal_i2c_sm[id].task[cur].rx_pos = 0; + hal_i2c_sm[id].task[cur].rx_cmd_sent = 0; + hal_i2c_sm[id].task[cur].errcode = 0; + hal_i2c_sm[id].task[cur].action = action; + hal_i2c_sm[id].task[cur].handler = handler; + hal_i2c_sm[id].task[cur].restart_after_write = 1; + hal_i2c_sm[id].task[cur].target_addr = target_addr; + hal_i2c_sm[id].task[cur].transfer_id = transfer_id; - if (!(hal_i2c_sm[id].cfg.use_sync)) - return 0; + hal_i2c_sm[id].in_task = (cur + 1) % HAL_I2C_SM_TASK_NUM_MAX; + hal_i2c_sm[id].task_count++; + return cur; +} +static void hal_i2c_sm_done(enum HAL_I2C_ID_T id) { + hal_i2c_sm[id].in_task = 0; + hal_i2c_sm[id].out_task = 0; + hal_i2c_sm[id].task_count = 0; + hal_i2c_sm[id].state = HAL_I2C_SM_IDLE; + + HAL_I2C_TRACE(1, "%s", __func__); +} + +static enum HAL_I2C_SM_TASK_STATE_T +_i2c_chk_clr_task_error(uint32_t reg_base, uint32_t ip_int_status, + uint32_t tx_abrt_source) { + enum HAL_I2C_SM_TASK_STATE_T state = 0; + uint32_t tmp1; + + /* tx abort interrupt */ + if (ip_int_status & I2CIP_INT_STATUS_TX_ABRT_MASK) { + state |= HAL_I2C_SM_TASK_STATE_TX_ABRT; + + /* sbyte_norstrt is special to clear : restart disable but user want to send + * a restart */ + /* to fix this bit : enable restart , clear speical , clear gc_or_start bit + * temporary */ + tmp1 = i2cip_r_target_address_reg(reg_base); + if (tx_abrt_source & I2CIP_TX_ABRT_SOURCE_ABRT_SBYTE_NORSTRT_MASK) { + i2cip_w_restart(reg_base, HAL_I2C_YES); + i2cip_w_special_bit(reg_base, HAL_I2C_NO); + i2cip_w_gc_or_start_bit(reg_base, HAL_I2C_NO); + } + i2cip_r_clr_tx_abrt(reg_base); + /* restore register after clear */ + if (tx_abrt_source & I2CIP_TX_ABRT_SOURCE_ABRT_SBYTE_NORSTRT_MASK) { + i2cip_w_target_address_reg(reg_base, tmp1); + } + } + /* tx overflow interrupt */ + if (ip_int_status & I2CIP_INT_MASK_TX_OVER_MASK) { + state |= HAL_I2C_SM_TASK_STATE_FIFO_ERR; + i2cip_r_clr_tx_over(reg_base); + } + /* rx overflow interrupt */ + if (ip_int_status & I2CIP_INT_MASK_RX_OVER_MASK) { + state |= HAL_I2C_SM_TASK_STATE_FIFO_ERR; + i2cip_r_clr_rx_over(reg_base); + } + /* rx underflow interrupt */ + if (ip_int_status & I2CIP_INT_MASK_RX_UNDER_MASK) { + state |= HAL_I2C_SM_TASK_STATE_FIFO_ERR; + i2cip_r_clr_rx_under(reg_base); + } + + return state; +} + +static void _i2c_show_error_code(uint32_t errcode) { +#ifdef DEBUG + if (errcode & HAL_I2C_ERRCODE_SLVRD_INTX) + HAL_I2C_ERROR(0, "i2c err : HAL_I2C_ERRCODE_SLVRD_INTX"); + if (errcode & HAL_I2C_ERRCODE_SLV_ARBLOST) + HAL_I2C_ERROR(0, "i2c err : HAL_I2C_ERRCODE_SLV_ARBLOST"); + if (errcode & HAL_I2C_ERRCODE_SLVFLUSH_TXFIFO) + HAL_I2C_ERROR(0, "i2c err : HAL_I2C_ERRCODE_SLVFLUSH_TXFIFO"); + if (errcode & HAL_I2C_ERRCODE_MASTER_DIS) + HAL_I2C_ERROR(0, "i2c err : HAL_I2C_ERRCODE_MASTER_DIS"); + if (errcode & HAL_I2C_ERRCODE_10B_RD_NORSTRT) + HAL_I2C_ERROR(0, "i2c err : HAL_I2C_ERRCODE_10B_RD_NORSTRT"); + if (errcode & HAL_I2C_ERRCODE_SBYTE_NORSTRT) + HAL_I2C_ERROR(0, "i2c err : HAL_I2C_ERRCODE_SBYTE_NORSTRT"); + if (errcode & HAL_I2C_ERRCODE_HS_NORSTRT) + HAL_I2C_ERROR(0, "i2c err : HAL_I2C_ERRCODE_HS_NORSTRT"); + if (errcode & HAL_I2C_ERRCODE_SBYTE_ACKDET) + HAL_I2C_ERROR(0, "i2c err : HAL_I2C_ERRCODE_SBYTE_ACKDET"); + if (errcode & HAL_I2C_ERRCODE_HS_ACKDET) + HAL_I2C_ERROR(0, "i2c err : HAL_I2C_ERRCODE_HS_ACKDET"); + if (errcode & HAL_I2C_ERRCODE_GCALL_READ) + HAL_I2C_ERROR(0, "i2c err : HAL_I2C_ERRCODE_GCALL_READ"); + if (errcode & HAL_I2C_ERRCODE_GCALL_NOACK) + HAL_I2C_ERROR(0, "i2c err : HAL_I2C_ERRCODE_GCALL_NOACK"); + if (errcode & HAL_I2C_ERRCODE_TXDATA_NOACK) + HAL_I2C_ERROR(0, "i2c err : HAL_I2C_ERRCODE_TXDATA_NOACK"); + if (errcode & HAL_I2C_ERRCODE_10ADDR2_NOACK) + HAL_I2C_ERROR(0, "i2c err : HAL_I2C_ERRCODE_10ADDR2_NOACK"); + if (errcode & HAL_I2C_ERRCODE_10ADDR1_NOACK) + HAL_I2C_ERROR(0, "i2c err : HAL_I2C_ERRCODE_10ADDR1_NOACK"); + if (errcode & HAL_I2C_ERRCODE_7B_ADDR_NOACK) + HAL_I2C_ERROR(0, "i2c err : HAL_I2C_ERRCODE_7B_ADDR_NOACK"); + + if (errcode & HAL_I2C_ERRCODE_INV_PARAM) + HAL_I2C_ERROR(0, "i2c err : HAL_I2C_ERRCODE_INV_PARAM"); + if (errcode & HAL_I2C_ERRCODE_IN_USE) + HAL_I2C_ERROR(0, "i2c err : HAL_I2C_ERRCODE_IN_USE"); + if (errcode & HAL_I2C_ERRCODE_FIFO_ERR) + HAL_I2C_ERROR(0, "i2c err : HAL_I2C_ERRCODE_FIFO_ERR"); +#endif +} + +#ifdef I2C_USE_DMA +static void hal_i2c_tx_dma_handler(uint8_t chan, uint32_t remain_tsize, + uint32_t error, struct HAL_DMA_DESC_T *lli) { + enum HAL_I2C_ID_T id; + + for (id = HAL_I2C_ID_0; id < HAL_I2C_ID_NUM; id++) { + if (hal_i2c_sm[id].tx_dma_cfg.ch == chan) { + } + } +} + +static void hal_i2c_rx_dma_handler(uint8_t chan, uint32_t remain_tsize, + uint32_t error, struct HAL_DMA_DESC_T *lli) { + enum HAL_I2C_ID_T id; + + for (id = HAL_I2C_ID_0; id < HAL_I2C_ID_NUM; id++) { + if (hal_i2c_sm[id].rx_dma_cfg.ch == chan) { + } + } +} + +static void hal_i2c_dma_release(enum HAL_I2C_ID_T id) { + uint32_t reg_base; + struct HAL_DMA_CH_CFG_T *tx_dma_cfg = NULL, *rx_dma_cfg = NULL; + + if (hal_i2c_sm[id].cfg.use_dma == 0) { + return; + } + + reg_base = _i2c_get_base(id); + + i2cip_w_tx_dma_enable(reg_base, HAL_I2C_NO); + i2cip_w_rx_dma_enable(reg_base, HAL_I2C_NO); + + tx_dma_cfg = &hal_i2c_sm[id].tx_dma_cfg; + rx_dma_cfg = &hal_i2c_sm[id].rx_dma_cfg; + + HAL_I2C_TRACE(1, "i2c tx free dma ch %d", tx_dma_cfg->ch); + if (tx_dma_cfg->ch != HAL_DMA_CHAN_NONE) { + hal_gpdma_cancel(tx_dma_cfg->ch); + hal_gpdma_free_chan(tx_dma_cfg->ch); + tx_dma_cfg->ch = HAL_DMA_CHAN_NONE; + } + + HAL_I2C_TRACE(1, "i2c rx free dma ch %d", rx_dma_cfg->ch); + if (rx_dma_cfg->ch != HAL_DMA_CHAN_NONE) { + hal_gpdma_cancel(rx_dma_cfg->ch); + hal_gpdma_free_chan(rx_dma_cfg->ch); + rx_dma_cfg->ch = HAL_DMA_CHAN_NONE; + } +} + +static void hal_i2c_dma_config(enum HAL_I2C_ID_T id, + const struct HAL_I2C_SM_TASK_T *out_task) { + uint32_t reg_base; + uint32_t i, txn; + uint32_t txn_start, org_start; + struct HAL_DMA_CH_CFG_T *tx_dma_cfg = NULL, *rx_dma_cfg = NULL; + enum HAL_I2C_SM_TASK_ACTION_T action; + uint32_t total_tx_len; + + if (hal_i2c_sm[id].cfg.use_dma == 0) { + return; + } + + reg_base = _i2c_get_base(id); + action = out_task->action; + + total_tx_len = out_task->tx_txn_len * out_task->txn_cnt; + if (action == HAL_I2C_SM_TASK_ACTION_M_RECV) { + total_tx_len += out_task->rx_txn_len * out_task->txn_cnt; + } + ASSERT(total_tx_len < ARRAY_SIZE(hal_i2c_sm[id].dma_tx_buf), + "%s: xfer size too large: action=%d total_tx_len=%u (should <= %u)", + __FUNCTION__, action, total_tx_len, + ARRAY_SIZE(hal_i2c_sm[id].dma_tx_buf)); + + i2cip_w_tx_dma_enable(reg_base, HAL_I2C_YES); + i2cip_w_tx_dma_tl(reg_base, HAL_I2C_DMA_TX_TL); + + tx_dma_cfg = &hal_i2c_sm[id].tx_dma_cfg; + memset(tx_dma_cfg, 0, sizeof(*tx_dma_cfg)); + tx_dma_cfg->dst = 0; // useless + tx_dma_cfg->dst_bsize = HAL_DMA_BSIZE_1; + tx_dma_cfg->dst_periph = i2c_desc[id].tx_periph; + tx_dma_cfg->dst_width = HAL_DMA_WIDTH_HALFWORD; + tx_dma_cfg->handler = hal_i2c_tx_dma_handler; + tx_dma_cfg->src_bsize = HAL_DMA_BSIZE_1; + tx_dma_cfg->src_periph = 0; // useless + tx_dma_cfg->src_tsize = total_tx_len; + tx_dma_cfg->src_width = HAL_DMA_WIDTH_HALFWORD; + tx_dma_cfg->try_burst = 1; + tx_dma_cfg->type = HAL_DMA_FLOW_M2P_DMA; + tx_dma_cfg->src = (uint32_t)hal_i2c_sm[id].dma_tx_buf; + tx_dma_cfg->ch = + hal_gpdma_get_chan(tx_dma_cfg->dst_periph, HAL_DMA_HIGH_PRIO); + HAL_I2C_TRACE(1, "i2c tx get dma ch %d", tx_dma_cfg->ch); + ASSERT(tx_dma_cfg->ch != HAL_DMA_CHAN_NONE, "I2C: Failed to get tx dma chan"); + + HAL_I2C_TRACE(3, "tx size %d cnt %d total tx size %d", out_task->tx_txn_len, + out_task->txn_cnt, total_tx_len); + + memset(&hal_i2c_sm[id].dma_tx_buf[0], 0, sizeof(hal_i2c_sm[id].dma_tx_buf)); + + for (txn = 0; txn < out_task->txn_cnt; txn++) { + org_start = out_task->tx_txn_len * txn; + txn_start = (out_task->tx_txn_len + out_task->rx_txn_len) * txn; + for (i = 0; i < out_task->tx_txn_len; i++) { + // lo byte of short : for data + // hi byte of short : for cmd/stop/restart + hal_i2c_sm[id].dma_tx_buf[txn_start + i] = + out_task->tx_buf[org_start + i]; + } + if (txn && out_task->restart_after_write) { + hal_i2c_sm[id].dma_tx_buf[txn_start] |= I2CIP_CMD_DATA_RESTART_MASK; + } + } + + if (action == HAL_I2C_SM_TASK_ACTION_M_RECV) { + i2cip_w_rx_dma_enable(reg_base, HAL_I2C_YES); + i2cip_w_rx_dma_tl(reg_base, HAL_I2C_DMA_RX_TL); + + for (txn = 0; txn < out_task->txn_cnt; txn++) { + txn_start = (out_task->tx_txn_len + out_task->rx_txn_len) * txn + + out_task->tx_txn_len; + for (i = 0; i < out_task->rx_txn_len; i++) { + // lo byte of short : for data + // hi byte of short : for cmd/stop/restart + hal_i2c_sm[id].dma_tx_buf[txn_start + i] = I2CIP_CMD_DATA_CMD_READ_MASK; + } + if (out_task->restart_after_write) { + hal_i2c_sm[id].dma_tx_buf[txn_start] |= I2CIP_CMD_DATA_RESTART_MASK; + } + } + + HAL_I2C_TRACE(2, "rx size %d cnt %d", out_task->rx_txn_len, + out_task->txn_cnt); + + rx_dma_cfg = &hal_i2c_sm[id].rx_dma_cfg; + memset(rx_dma_cfg, 0, sizeof(*rx_dma_cfg)); + rx_dma_cfg->dst = (uint32_t)(out_task->rx_buf); + rx_dma_cfg->dst_bsize = HAL_DMA_BSIZE_1; + rx_dma_cfg->dst_periph = 0; // useless + rx_dma_cfg->dst_width = HAL_DMA_WIDTH_BYTE; + rx_dma_cfg->handler = hal_i2c_rx_dma_handler; + rx_dma_cfg->src_bsize = HAL_DMA_BSIZE_1; + rx_dma_cfg->src_periph = i2c_desc[id].rx_periph; + rx_dma_cfg->src_tsize = out_task->rx_txn_len * out_task->txn_cnt; + rx_dma_cfg->src_width = HAL_DMA_WIDTH_BYTE; + rx_dma_cfg->try_burst = 0; + rx_dma_cfg->src = 0; // useless + rx_dma_cfg->type = HAL_DMA_FLOW_P2M_DMA; + rx_dma_cfg->ch = + hal_gpdma_get_chan(rx_dma_cfg->src_periph, HAL_DMA_HIGH_PRIO); + HAL_I2C_TRACE(1, "i2c rx get dma ch %d", rx_dma_cfg->ch); + ASSERT(tx_dma_cfg->ch != HAL_DMA_CHAN_NONE, + "I2C: Failed to get rx dma chan"); + } + + if (out_task->stop) { + hal_i2c_sm[id].dma_tx_buf[total_tx_len - 1] |= I2CIP_CMD_DATA_STOP_MASK; + } +} +#endif +#endif + +#ifdef I2C_TASK_MODE +static void hal_i2c_sm_done_task(enum HAL_I2C_ID_T id) { + struct HAL_I2C_SM_TASK_T *task; + uint32_t reg_base = _i2c_get_base(id); + + task = &(hal_i2c_sm[id].task[hal_i2c_sm[id].out_task]); + + if (task->errcode) { + HAL_I2C_ERROR(1, "i2c err : 0x%X", task->errcode); + _i2c_show_error_code(task->errcode); + } + + if (task->stop || task->errcode) { + HAL_I2C_TRACE(0, "disable i2c"); + i2cip_w_enable(reg_base, HAL_I2C_NO); + } + +#ifdef I2C_USE_DMA + if (hal_i2c_sm[id].cfg.use_dma) { + hal_i2c_dma_release(id); + } +#endif + + if (hal_i2c_sm[id].cfg.use_sync) { /* FIXME : os and non-os - different proc */ - tmcnt = tm_ms / HAL_I2C_DLY_MS; - while(1) { - uint32_t lock = task->lock; - - if (!lock) - break; - - if (!tmcnt) { - HAL_I2C_TRACE(1,"wait lock timeout %d ms", tm_ms); - task->errcode = HAL_I2C_ERRCODE_SYNC_TIMEOUT; - hal_i2c_sm_done_task(id); - hal_i2c_sm_next_task(id); - break; - } - hal_i2c_delay_ms(HAL_I2C_DLY_MS); - tmcnt--; + task->lock = 0; + } else { + if (task->handler) { + task->handler(id, task->transfer_id, task->tx_buf, + task->tx_txn_len * task->txn_cnt, task->rx_buf, + task->rx_txn_len * task->txn_cnt, task->errcode); } - return task->errcode; + } + + hal_i2c_sm[id].out_task = + (hal_i2c_sm[id].out_task + 1) % HAL_I2C_SM_TASK_NUM_MAX; + --hal_i2c_sm[id].task_count; } -static void hal_i2c_sm_kickoff(enum HAL_I2C_ID_T id) -{ - if (hal_i2c_sm[id].state == HAL_I2C_SM_IDLE) { - hal_i2c_sm[id].state = HAL_I2C_SM_RUNNING; - hal_i2c_sm_next_task(id); - } -} +static void hal_i2c_sm_next_task(enum HAL_I2C_ID_T id) { + uint32_t out_task_index; + uint32_t reg_base, reinit; + enum HAL_I2C_SM_TASK_ACTION_T action; + struct HAL_I2C_SM_TASK_T *out_task = 0; -static void hal_i2c_sm_proc(enum HAL_I2C_ID_T id) -{ - uint32_t reg_base = 0; - enum HAL_I2C_SM_STATE_T state; - enum HAL_I2C_SM_TASK_STATE_T task_state; - struct HAL_I2C_SM_TASK_T *task; - uint32_t i = 0, restart = 0, stop = 0, data = 0; - uint32_t ip_int_status = 0, tx_abrt_source = 0; - uint8_t rx_limit, tx_limit, rx_cnt, tx_cnt; - uint32_t total_tx_len, total_rx_len; - uint32_t txn_idx, txn_pos; + reg_base = _i2c_get_base(id); - reg_base = _i2c_get_base(id); - state = hal_i2c_sm[id].state; - task = &(hal_i2c_sm[id].task[hal_i2c_sm[id].out_task]); + if (hal_i2c_sm[id].task_count <= 0) { + HAL_I2C_TRACE(0, "no task"); + hal_i2c_sm_done(id); + return; + } - ip_int_status = i2cip_r_int_status(reg_base); - tx_abrt_source = i2cip_r_tx_abrt_source(reg_base); + out_task_index = hal_i2c_sm[id].out_task; + out_task = &(hal_i2c_sm[id].task[out_task_index]); + action = out_task->action; - HAL_I2C_TRACE(4,"id:%d, ip_int_status=0x%X tx_abrt_source=0x%X state=%d", - id, ip_int_status, tx_abrt_source, state); + /* tx : quarter trigger TX EMPTY INT */ + i2cip_w_tx_threshold(reg_base, HAL_I2C_TX_TL); + if (action == HAL_I2C_SM_TASK_ACTION_M_RECV) { + /* rx : three quarter trigger RX FULL INT */ + i2cip_w_rx_threshold(reg_base, HAL_I2C_RX_TL); + } - task_state = _i2c_chk_clr_task_error(reg_base, ip_int_status, tx_abrt_source); - - if (state != HAL_I2C_SM_RUNNING) { - HAL_I2C_ERROR(3,"*** WARNING: No i2c task running: id=%d ip_int_status=0x%X tx_abrt_source=0x%X", id, ip_int_status, tx_abrt_source); - i2cip_r_clr_all_intr(reg_base); - return; - } - - HAL_I2C_TRACE(1,"RUNNING action=%d", task->action); - - task->state |= task_state; - - if (task->state & (HAL_I2C_SM_TASK_STATE_TX_ABRT | HAL_I2C_SM_TASK_STATE_FIFO_ERR)) { - HAL_I2C_ERROR(5,"*** ERROR:%s: id=%d task_state=0x%X ip_int_status=0x%X tx_abrt_source=0x%X", __func__, id, task->state, ip_int_status, tx_abrt_source); - task->errcode = tx_abrt_source; - if (task->state & HAL_I2C_SM_TASK_STATE_FIFO_ERR) { - task->errcode |= HAL_I2C_ERRCODE_FIFO_ERR; - } - /* done task on any error */ - hal_i2c_sm_done_task(id); - hal_i2c_sm_next_task(id); - return; - } - - /* stop det interrupt */ - if (ip_int_status & I2CIP_INT_STATUS_STOP_DET_MASK) { - task->state |= HAL_I2C_SM_TASK_STATE_STOP; - i2cip_r_clr_stop_det(reg_base); - } - - /* start det interrupt */ - if (ip_int_status & I2CIP_INT_STATUS_START_DET_MASK) { - task->state |= HAL_I2C_SM_TASK_STATE_START; - i2cip_r_clr_start_det(reg_base); - } - - /* activeity det interrupt */ - if (ip_int_status & I2CIP_INT_STATUS_ACTIVITY_MASK) { - task->state |= HAL_I2C_SM_TASK_STATE_ACT; - i2cip_r_clr_activity(reg_base); - } - - switch (task->action) { - case HAL_I2C_SM_TASK_ACTION_M_SEND: - { - if (hal_i2c_sm[id].cfg.use_dma == 0) { - /* tx empty : means tx fifo is at or below IC_TX_TL : - need to write more data : we can NOT clear this bit, cleared by hw */ - if (ip_int_status & I2CIP_INT_STATUS_TX_EMPTY_MASK) { - total_tx_len = task->tx_txn_len * task->txn_cnt; - tx_limit = i2cip_r_tx_fifo_level(reg_base); - if (tx_limit < I2CIP_TX_FIFO_DEPTH) { - tx_limit = I2CIP_TX_FIFO_DEPTH - tx_limit; - } else { - tx_limit = 0; - } - HAL_I2C_TRACE(4,"m_send: tx_pos=%d tx_txn_len=%d cnt=%d tx_limit=%d", - task->tx_pos, task->tx_txn_len, task->txn_cnt, tx_limit); - for (i = task->tx_pos, tx_cnt = 0; - ((i < total_tx_len) && (tx_cnt < tx_limit)); - ++i, ++tx_cnt) { - /* last byte : we need to decide stop */ - if (i == total_tx_len - 1) { - stop = task->stop ? I2CIP_CMD_DATA_STOP_MASK : 0; - } else { - stop = 0; - } - if (task->txn_cnt == 1) { - txn_pos = i; - } else { - txn_pos = i % task->tx_txn_len; - } - /* first byte : need to decide restart */ - if (i && task->restart_after_write && txn_pos == 0) { - restart = I2CIP_CMD_DATA_RESTART_MASK; - } else { - restart = 0; - } - /* write data to FIFO */ - i2cip_w_cmd_data(reg_base, - task->tx_buf[i] | I2CIP_CMD_DATA_CMD_WRITE_MASK | restart | stop); - - HAL_I2C_TRACE(3,"m_send: data=0x%02X restart=0x%X stop=0x%X", - task->tx_buf[i], restart, stop); - } - - task->tx_pos = i; - - /* all write action done : do NOT need tx empty int */ - if (task->tx_pos == total_tx_len) { - i2cip_clear_int_mask(reg_base, I2CIP_INT_MASK_TX_EMPTY_MASK); - } - HAL_I2C_TRACE(1,"m_send: i2c status=0x%X", i2cip_r_status(reg_base)); - } - } - - /* stop condition : done task */ - if (task->state & HAL_I2C_SM_TASK_STATE_STOP) { - HAL_I2C_TRACE(1,"m_send: task->state:0x%X", task->state); - hal_i2c_sm_done_task(id); - hal_i2c_sm_next_task(id); - } - break; - } - case HAL_I2C_SM_TASK_ACTION_M_RECV: - { - if (hal_i2c_sm[id].cfg.use_dma == 0) { - /* rx full : need to read */ - if (ip_int_status & I2CIP_INT_STATUS_RX_FULL_MASK) { - total_rx_len = task->rx_txn_len * task->txn_cnt; - rx_limit = i2cip_r_rx_fifo_level(reg_base); - HAL_I2C_TRACE(4,"m_recv:full: rx_pos=%d rx_txn_len=%d cnt=%d rx_limit=%d", - task->rx_pos, task->rx_txn_len, task->txn_cnt, rx_limit); - for (i = task->rx_pos, rx_cnt = 0; - ((i < total_rx_len) && (rx_cnt < rx_limit)); - ++i, ++rx_cnt) { - task->rx_buf[i] = i2cip_r_cmd_data(reg_base); - HAL_I2C_TRACE(2,"m_recv:full: rx_buf[%d] 0x%X", i, task->rx_buf[i]); - } - task->rx_pos = i; - } - - /* tx empty : means tx fifo is at or below IC_TX_TL : - need to write more data : we can NOT clear this bit, cleared by hw */ - if (ip_int_status & I2CIP_INT_STATUS_TX_EMPTY_MASK) { - total_tx_len = (task->tx_txn_len + task->rx_txn_len) * task->txn_cnt; - tx_limit = i2cip_r_tx_fifo_level(reg_base); - if (tx_limit < I2CIP_TX_FIFO_DEPTH) { - tx_limit = I2CIP_TX_FIFO_DEPTH - tx_limit; - } else { - tx_limit = 0; - } - rx_limit = task->rx_cmd_sent - task->rx_pos + 1; - if (rx_limit < I2CIP_RX_FIFO_DEPTH) { - rx_limit = I2CIP_RX_FIFO_DEPTH - rx_limit; - } else { - rx_limit = 0; - } - HAL_I2C_TRACE(6,"m_recv:txEmpty: tx_pos=%d tx_txn_len=%d rx_txn_len=%d cnt=%d tx_limit=%d rx_limit=%d", - task->tx_pos, task->tx_txn_len, task->rx_txn_len, task->txn_cnt, tx_limit, rx_limit); - if (tx_limit > rx_limit) { - tx_limit = rx_limit; - } - for (i = task->tx_pos, tx_cnt = 0; - ((i < total_tx_len) && (tx_cnt < tx_limit)); - ++i, ++tx_cnt) { - /* last byte : we need to decide stop */ - if (i == (total_tx_len - 1)) { - stop = task->stop ? I2CIP_CMD_DATA_STOP_MASK : 0; - } else { - stop = 0; - } - if (task->txn_cnt == 1) { - txn_idx = 0; - txn_pos = i; - } else { - txn_idx = i / (task->tx_txn_len + task->rx_txn_len); - txn_pos = i % (task->tx_txn_len + task->rx_txn_len); - } - /* first byte : need to decide restart */ - if (i && task->restart_after_write && (txn_pos == 0 || txn_pos == task->tx_txn_len)) { - restart = I2CIP_CMD_DATA_RESTART_MASK; - } else { - restart = 0; - } - /* real write data */ - if (txn_pos < task->tx_txn_len) { - if (task->txn_cnt == 1) { - data = task->tx_buf[txn_pos]; - } else { - data = task->tx_buf[txn_idx * task->tx_txn_len + txn_pos]; - } - } else { - data = I2CIP_CMD_DATA_CMD_READ_MASK; - task->rx_cmd_sent++; - } - - i2cip_w_cmd_data(reg_base, data | restart | stop); - HAL_I2C_TRACE(4,"m_recv:tx: data[%u]=0x%02X restart=0x%X stop=0x%X", - i, data, restart, stop); - } - - task->tx_pos = i; - - /* all write action done */ - if (task->tx_pos == total_tx_len) { - i2cip_clear_int_mask(reg_base, I2CIP_INT_MASK_TX_EMPTY_MASK); - } - } - } - - /* stop condition : need to read out all rx fifo */ - if (task->state & HAL_I2C_SM_TASK_STATE_STOP) { - if (hal_i2c_sm[id].cfg.use_dma) { #ifdef I2C_USE_DMA - if (hal_i2c_sm[id].rx_dma_cfg.ch == HAL_DMA_CHAN_NONE) { - HAL_I2C_TRACE(0,"m_recv:stop:WARNING: bad rx dma chan!"); - } else { - if (hal_dma_chan_busy(hal_i2c_sm[id].rx_dma_cfg.ch)) { - HAL_I2C_TRACE(0,"m_recv:stop:WARNING: rx dma not finished yet!"); - } - } + if (hal_i2c_sm[id].cfg.use_dma) { + i2cip_init_int_mask(reg_base, I2CIP_INT_MASK_STOP_DET_MASK | + I2CIP_INT_MASK_ERROR_MASK); + + /* prepare for dma operation */ + hal_i2c_dma_config(id, out_task); + } else #endif - } else { - rx_limit = i2cip_r_rx_fifo_level(reg_base); - HAL_I2C_TRACE(1,"m_recv:stop: rx_limit=%d", rx_limit); - for (i = task->rx_pos, rx_cnt = 0; - ((rx_cnt < rx_limit) && (i < task->rx_txn_len)); - ++i, ++rx_cnt) { - task->rx_buf[i] = i2cip_r_cmd_data(reg_base); - HAL_I2C_TRACE(2,"m_recv:stop: rx_buf[%d] 0x%X", i, task->rx_buf[i]); - } - task->rx_pos = i; - if (task->rx_pos != task->rx_txn_len * task->txn_cnt) { - HAL_I2C_TRACE(3,"m_recv:stop:WARNING: rx_pos(%u) != rx_txn_len(%u) * txn_cnt(%u)", task->rx_pos, task->rx_txn_len, task->txn_cnt); - } - } - hal_i2c_sm_done_task(id); - hal_i2c_sm_next_task(id); - } - break; - } - default: - break; + { + /* open all interrupt */ + i2cip_init_int_mask(reg_base, + (I2CIP_INT_MASK_ALL & ~(I2CIP_INT_MASK_START_DET_MASK | + I2CIP_INT_MASK_ACTIVITY_MASK))); + } + + reinit = i2cip_r_enable_status(reg_base); + /* not enable : reconfig i2cip with new-task params */ + /* enable : same operation with pre task */ + if (!(reinit & I2CIP_ENABLE_STATUS_ENABLE_MASK)) { + HAL_I2C_TRACE(0, "enable i2c"); + i2cip_w_restart(reg_base, HAL_I2C_YES); + i2cip_w_target_address(reg_base, out_task->target_addr); + i2cip_w_enable(reg_base, HAL_I2C_YES); + } + +#ifdef I2C_USE_DMA + if (hal_i2c_sm[id].cfg.use_dma) { + if (action == HAL_I2C_SM_TASK_ACTION_M_RECV) { + HAL_I2C_TRACE(0, "enable rx dma"); + hal_gpdma_start(&hal_i2c_sm[id].rx_dma_cfg); } + HAL_I2C_TRACE(0, "enable tx dma"); + hal_gpdma_start(&hal_i2c_sm[id].tx_dma_cfg); + } +#endif } -void hal_i2c_irq_handler(void) -{ - enum HAL_I2C_ID_T id; +static uint32_t hal_i2c_sm_wait_task_if_need(enum HAL_I2C_ID_T id, + uint32_t task_idx, + uint32_t tm_ms) { + int tmcnt; + struct HAL_I2C_SM_TASK_T *task = 0; - for (id = HAL_I2C_ID_0; id < HAL_I2C_ID_NUM; id++) { - if (NVIC_GetActive(i2c_desc[id].irq)) { - hal_i2c_sm_proc(id); - } + /* FIXME : task_id maybe invalid cause so-fast device operation */ + task = &(hal_i2c_sm[id].task[task_idx]); + + if (!(hal_i2c_sm[id].cfg.use_sync)) + return 0; + + /* FIXME : os and non-os - different proc */ + tmcnt = tm_ms / HAL_I2C_DLY_MS; + while (1) { + uint32_t lock = task->lock; + + if (!lock) + break; + + if (!tmcnt) { + HAL_I2C_TRACE(1, "wait lock timeout %d ms", tm_ms); + task->errcode = HAL_I2C_ERRCODE_SYNC_TIMEOUT; + hal_i2c_sm_done_task(id); + hal_i2c_sm_next_task(id); + break; } + hal_i2c_delay_ms(HAL_I2C_DLY_MS); + tmcnt--; + } + return task->errcode; +} + +static void hal_i2c_sm_kickoff(enum HAL_I2C_ID_T id) { + if (hal_i2c_sm[id].state == HAL_I2C_SM_IDLE) { + hal_i2c_sm[id].state = HAL_I2C_SM_RUNNING; + hal_i2c_sm_next_task(id); + } +} + +static void hal_i2c_sm_proc(enum HAL_I2C_ID_T id) { + uint32_t reg_base = 0; + enum HAL_I2C_SM_STATE_T state; + enum HAL_I2C_SM_TASK_STATE_T task_state; + struct HAL_I2C_SM_TASK_T *task; + uint32_t i = 0, restart = 0, stop = 0, data = 0; + uint32_t ip_int_status = 0, tx_abrt_source = 0; + uint8_t rx_limit, tx_limit, rx_cnt, tx_cnt; + uint32_t total_tx_len, total_rx_len; + uint32_t txn_idx, txn_pos; + + reg_base = _i2c_get_base(id); + state = hal_i2c_sm[id].state; + task = &(hal_i2c_sm[id].task[hal_i2c_sm[id].out_task]); + + ip_int_status = i2cip_r_int_status(reg_base); + tx_abrt_source = i2cip_r_tx_abrt_source(reg_base); + + HAL_I2C_TRACE(4, "id:%d, ip_int_status=0x%X tx_abrt_source=0x%X state=%d", id, + ip_int_status, tx_abrt_source, state); + + task_state = _i2c_chk_clr_task_error(reg_base, ip_int_status, tx_abrt_source); + + if (state != HAL_I2C_SM_RUNNING) { + HAL_I2C_ERROR(3, + "*** WARNING: No i2c task running: id=%d ip_int_status=0x%X " + "tx_abrt_source=0x%X", + id, ip_int_status, tx_abrt_source); + i2cip_r_clr_all_intr(reg_base); + return; + } + + HAL_I2C_TRACE(1, "RUNNING action=%d", task->action); + + task->state |= task_state; + + if (task->state & + (HAL_I2C_SM_TASK_STATE_TX_ABRT | HAL_I2C_SM_TASK_STATE_FIFO_ERR)) { + HAL_I2C_ERROR(5, + "*** ERROR:%s: id=%d task_state=0x%X ip_int_status=0x%X " + "tx_abrt_source=0x%X", + __func__, id, task->state, ip_int_status, tx_abrt_source); + task->errcode = tx_abrt_source; + if (task->state & HAL_I2C_SM_TASK_STATE_FIFO_ERR) { + task->errcode |= HAL_I2C_ERRCODE_FIFO_ERR; + } + /* done task on any error */ + hal_i2c_sm_done_task(id); + hal_i2c_sm_next_task(id); + return; + } + + /* stop det interrupt */ + if (ip_int_status & I2CIP_INT_STATUS_STOP_DET_MASK) { + task->state |= HAL_I2C_SM_TASK_STATE_STOP; + i2cip_r_clr_stop_det(reg_base); + } + + /* start det interrupt */ + if (ip_int_status & I2CIP_INT_STATUS_START_DET_MASK) { + task->state |= HAL_I2C_SM_TASK_STATE_START; + i2cip_r_clr_start_det(reg_base); + } + + /* activeity det interrupt */ + if (ip_int_status & I2CIP_INT_STATUS_ACTIVITY_MASK) { + task->state |= HAL_I2C_SM_TASK_STATE_ACT; + i2cip_r_clr_activity(reg_base); + } + + switch (task->action) { + case HAL_I2C_SM_TASK_ACTION_M_SEND: { + if (hal_i2c_sm[id].cfg.use_dma == 0) { + /* tx empty : means tx fifo is at or below IC_TX_TL : + need to write more data : we can NOT clear this bit, cleared by hw */ + if (ip_int_status & I2CIP_INT_STATUS_TX_EMPTY_MASK) { + total_tx_len = task->tx_txn_len * task->txn_cnt; + tx_limit = i2cip_r_tx_fifo_level(reg_base); + if (tx_limit < I2CIP_TX_FIFO_DEPTH) { + tx_limit = I2CIP_TX_FIFO_DEPTH - tx_limit; + } else { + tx_limit = 0; + } + HAL_I2C_TRACE(4, "m_send: tx_pos=%d tx_txn_len=%d cnt=%d tx_limit=%d", + task->tx_pos, task->tx_txn_len, task->txn_cnt, tx_limit); + for (i = task->tx_pos, tx_cnt = 0; + ((i < total_tx_len) && (tx_cnt < tx_limit)); ++i, ++tx_cnt) { + /* last byte : we need to decide stop */ + if (i == total_tx_len - 1) { + stop = task->stop ? I2CIP_CMD_DATA_STOP_MASK : 0; + } else { + stop = 0; + } + if (task->txn_cnt == 1) { + txn_pos = i; + } else { + txn_pos = i % task->tx_txn_len; + } + /* first byte : need to decide restart */ + if (i && task->restart_after_write && txn_pos == 0) { + restart = I2CIP_CMD_DATA_RESTART_MASK; + } else { + restart = 0; + } + /* write data to FIFO */ + i2cip_w_cmd_data(reg_base, task->tx_buf[i] | + I2CIP_CMD_DATA_CMD_WRITE_MASK | + restart | stop); + + HAL_I2C_TRACE(3, "m_send: data=0x%02X restart=0x%X stop=0x%X", + task->tx_buf[i], restart, stop); + } + + task->tx_pos = i; + + /* all write action done : do NOT need tx empty int */ + if (task->tx_pos == total_tx_len) { + i2cip_clear_int_mask(reg_base, I2CIP_INT_MASK_TX_EMPTY_MASK); + } + HAL_I2C_TRACE(1, "m_send: i2c status=0x%X", i2cip_r_status(reg_base)); + } + } + + /* stop condition : done task */ + if (task->state & HAL_I2C_SM_TASK_STATE_STOP) { + HAL_I2C_TRACE(1, "m_send: task->state:0x%X", task->state); + hal_i2c_sm_done_task(id); + hal_i2c_sm_next_task(id); + } + break; + } + case HAL_I2C_SM_TASK_ACTION_M_RECV: { + if (hal_i2c_sm[id].cfg.use_dma == 0) { + /* rx full : need to read */ + if (ip_int_status & I2CIP_INT_STATUS_RX_FULL_MASK) { + total_rx_len = task->rx_txn_len * task->txn_cnt; + rx_limit = i2cip_r_rx_fifo_level(reg_base); + HAL_I2C_TRACE(4, + "m_recv:full: rx_pos=%d rx_txn_len=%d cnt=%d rx_limit=%d", + task->rx_pos, task->rx_txn_len, task->txn_cnt, rx_limit); + for (i = task->rx_pos, rx_cnt = 0; + ((i < total_rx_len) && (rx_cnt < rx_limit)); ++i, ++rx_cnt) { + task->rx_buf[i] = i2cip_r_cmd_data(reg_base); + HAL_I2C_TRACE(2, "m_recv:full: rx_buf[%d] 0x%X", i, task->rx_buf[i]); + } + task->rx_pos = i; + } + + /* tx empty : means tx fifo is at or below IC_TX_TL : + need to write more data : we can NOT clear this bit, cleared by hw */ + if (ip_int_status & I2CIP_INT_STATUS_TX_EMPTY_MASK) { + total_tx_len = (task->tx_txn_len + task->rx_txn_len) * task->txn_cnt; + tx_limit = i2cip_r_tx_fifo_level(reg_base); + if (tx_limit < I2CIP_TX_FIFO_DEPTH) { + tx_limit = I2CIP_TX_FIFO_DEPTH - tx_limit; + } else { + tx_limit = 0; + } + rx_limit = task->rx_cmd_sent - task->rx_pos + 1; + if (rx_limit < I2CIP_RX_FIFO_DEPTH) { + rx_limit = I2CIP_RX_FIFO_DEPTH - rx_limit; + } else { + rx_limit = 0; + } + HAL_I2C_TRACE(6, + "m_recv:txEmpty: tx_pos=%d tx_txn_len=%d rx_txn_len=%d " + "cnt=%d tx_limit=%d rx_limit=%d", + task->tx_pos, task->tx_txn_len, task->rx_txn_len, + task->txn_cnt, tx_limit, rx_limit); + if (tx_limit > rx_limit) { + tx_limit = rx_limit; + } + for (i = task->tx_pos, tx_cnt = 0; + ((i < total_tx_len) && (tx_cnt < tx_limit)); ++i, ++tx_cnt) { + /* last byte : we need to decide stop */ + if (i == (total_tx_len - 1)) { + stop = task->stop ? I2CIP_CMD_DATA_STOP_MASK : 0; + } else { + stop = 0; + } + if (task->txn_cnt == 1) { + txn_idx = 0; + txn_pos = i; + } else { + txn_idx = i / (task->tx_txn_len + task->rx_txn_len); + txn_pos = i % (task->tx_txn_len + task->rx_txn_len); + } + /* first byte : need to decide restart */ + if (i && task->restart_after_write && + (txn_pos == 0 || txn_pos == task->tx_txn_len)) { + restart = I2CIP_CMD_DATA_RESTART_MASK; + } else { + restart = 0; + } + /* real write data */ + if (txn_pos < task->tx_txn_len) { + if (task->txn_cnt == 1) { + data = task->tx_buf[txn_pos]; + } else { + data = task->tx_buf[txn_idx * task->tx_txn_len + txn_pos]; + } + } else { + data = I2CIP_CMD_DATA_CMD_READ_MASK; + task->rx_cmd_sent++; + } + + i2cip_w_cmd_data(reg_base, data | restart | stop); + HAL_I2C_TRACE(4, "m_recv:tx: data[%u]=0x%02X restart=0x%X stop=0x%X", + i, data, restart, stop); + } + + task->tx_pos = i; + + /* all write action done */ + if (task->tx_pos == total_tx_len) { + i2cip_clear_int_mask(reg_base, I2CIP_INT_MASK_TX_EMPTY_MASK); + } + } + } + + /* stop condition : need to read out all rx fifo */ + if (task->state & HAL_I2C_SM_TASK_STATE_STOP) { + if (hal_i2c_sm[id].cfg.use_dma) { +#ifdef I2C_USE_DMA + if (hal_i2c_sm[id].rx_dma_cfg.ch == HAL_DMA_CHAN_NONE) { + HAL_I2C_TRACE(0, "m_recv:stop:WARNING: bad rx dma chan!"); + } else { + if (hal_dma_chan_busy(hal_i2c_sm[id].rx_dma_cfg.ch)) { + HAL_I2C_TRACE(0, "m_recv:stop:WARNING: rx dma not finished yet!"); + } + } +#endif + } else { + rx_limit = i2cip_r_rx_fifo_level(reg_base); + HAL_I2C_TRACE(1, "m_recv:stop: rx_limit=%d", rx_limit); + for (i = task->rx_pos, rx_cnt = 0; + ((rx_cnt < rx_limit) && (i < task->rx_txn_len)); ++i, ++rx_cnt) { + task->rx_buf[i] = i2cip_r_cmd_data(reg_base); + HAL_I2C_TRACE(2, "m_recv:stop: rx_buf[%d] 0x%X", i, task->rx_buf[i]); + } + task->rx_pos = i; + if (task->rx_pos != task->rx_txn_len * task->txn_cnt) { + HAL_I2C_TRACE( + 3, + "m_recv:stop:WARNING: rx_pos(%u) != rx_txn_len(%u) * txn_cnt(%u)", + task->rx_pos, task->rx_txn_len, task->txn_cnt); + } + } + hal_i2c_sm_done_task(id); + hal_i2c_sm_next_task(id); + } + break; + } + default: + break; + } +} + +void hal_i2c_irq_handler(void) { + enum HAL_I2C_ID_T id; + + for (id = HAL_I2C_ID_0; id < HAL_I2C_ID_NUM; id++) { + if (NVIC_GetActive(i2c_desc[id].irq)) { + hal_i2c_sm_proc(id); + } + } } #endif #ifdef I2C_SIMPLE_MODE -void hal_i2c_irq_handler_s(void) -{ - enum HAL_I2C_ID_T id; +void hal_i2c_irq_handler_s(void) { + enum HAL_I2C_ID_T id; - for (id = HAL_I2C_ID_0; id < HAL_I2C_ID_NUM; id++) { - if (NVIC_GetActive(i2c_desc[id].irq)) { - hal_i2c_simple_proc(id); - } + for (id = HAL_I2C_ID_0; id < HAL_I2C_ID_NUM; id++) { + if (NVIC_GetActive(i2c_desc[id].irq)) { + hal_i2c_simple_proc(id); } + } } #endif #ifdef I2C_SENSOR_ENGINE -void hal_i2c_irq_handler_sensor_eng(void) -{ - enum HAL_I2C_ID_T id; +void hal_i2c_irq_handler_sensor_eng(void) { + enum HAL_I2C_ID_T id; - for (id = HAL_I2C_ID_0; id < HAL_I2C_ID_NUM; id++) { - if (NVIC_GetActive(i2c_desc[id].irq)) { - hal_i2c_sensor_eng_proc(id); - } + for (id = HAL_I2C_ID_0; id < HAL_I2C_ID_NUM; id++) { + if (NVIC_GetActive(i2c_desc[id].irq)) { + hal_i2c_sensor_eng_proc(id); } + } } #endif -static int POSSIBLY_UNUSED hal_i2c_nvic_setup_irq(enum HAL_I2C_ID_T id, uint32_t handler) -{ - IRQn_Type irqt = i2c_desc[id].irq; +static int POSSIBLY_UNUSED hal_i2c_nvic_setup_irq(enum HAL_I2C_ID_T id, + uint32_t handler) { + IRQn_Type irqt = i2c_desc[id].irq; - NVIC_SetVector(irqt, handler); - NVIC_SetPriority(irqt, IRQ_PRIORITY_NORMAL); - return 0; + NVIC_SetVector(irqt, handler); + NVIC_SetPriority(irqt, IRQ_PRIORITY_NORMAL); + return 0; } -static int hal_i2c_nvic_enable_irq(enum HAL_I2C_ID_T id, int enabled) -{ - IRQn_Type irqt = i2c_desc[id].irq; +static int hal_i2c_nvic_enable_irq(enum HAL_I2C_ID_T id, int enabled) { + IRQn_Type irqt = i2c_desc[id].irq; - if (enabled) { - NVIC_ClearPendingIRQ(irqt); - NVIC_EnableIRQ(irqt); - } else { - NVIC_DisableIRQ(irqt); - NVIC_ClearPendingIRQ(irqt); - } - return 0; + if (enabled) { + NVIC_ClearPendingIRQ(irqt); + NVIC_EnableIRQ(irqt); + } else { + NVIC_DisableIRQ(irqt); + NVIC_ClearPendingIRQ(irqt); + } + return 0; } -uint32_t hal_i2c_open(enum HAL_I2C_ID_T id, const struct HAL_I2C_CONFIG_T *cfg) -{ - uint32_t reg_base; +uint32_t hal_i2c_open(enum HAL_I2C_ID_T id, + const struct HAL_I2C_CONFIG_T *cfg) { + uint32_t reg_base; - ASSERT(id < HAL_I2C_ID_NUM, invalid_id, id); + ASSERT(id < HAL_I2C_ID_NUM, invalid_id, id); - if (hal_i2c_sm[id].state != HAL_I2C_SM_CLOSED) { - return HAL_I2C_ERRCODE_IN_USE; - } + if (hal_i2c_sm[id].state != HAL_I2C_SM_CLOSED) { + return HAL_I2C_ERRCODE_IN_USE; + } - hal_i2c_sm_init(id, cfg); + hal_i2c_sm_init(id, cfg); - hal_cmu_clock_enable(i2c_desc[id].mod); - hal_cmu_clock_enable(i2c_desc[id].apb); - hal_cmu_reset_clear(i2c_desc[id].mod); - hal_cmu_reset_clear(i2c_desc[id].apb); + hal_cmu_clock_enable(i2c_desc[id].mod); + hal_cmu_clock_enable(i2c_desc[id].apb); + hal_cmu_reset_clear(i2c_desc[id].mod); + hal_cmu_reset_clear(i2c_desc[id].apb); - reg_base = _i2c_get_base(id); - HAL_I2C_TRACE(2,"i2c id=%d reg_base=0x%X", id, reg_base); + reg_base = _i2c_get_base(id); + HAL_I2C_TRACE(2, "i2c id=%d reg_base=0x%X", id, reg_base); - i2cip_w_enable(reg_base, HAL_I2C_NO); + i2cip_w_enable(reg_base, HAL_I2C_NO); - i2cip_w_target_address(reg_base, 0x18); + i2cip_w_target_address(reg_base, 0x18); - /* clear */ - i2cip_w_clear_ctrl(reg_base); + /* clear */ + i2cip_w_clear_ctrl(reg_base); - /* as master */ - if (cfg->as_master) { - i2cip_w_disable_slave(reg_base, HAL_I2C_YES); - i2cip_w_master_mode(reg_base, HAL_I2C_YES); - } else { - i2cip_w_disable_slave(reg_base, HAL_I2C_NO); - i2cip_w_master_mode(reg_base, HAL_I2C_NO); + /* as master */ + if (cfg->as_master) { + i2cip_w_disable_slave(reg_base, HAL_I2C_YES); + i2cip_w_master_mode(reg_base, HAL_I2C_YES); + } else { + i2cip_w_disable_slave(reg_base, HAL_I2C_NO); + i2cip_w_master_mode(reg_base, HAL_I2C_NO); - /* address as slave */ - i2cip_w_address_as_slave(reg_base, cfg->addr_as_slave); - } + /* address as slave */ + i2cip_w_address_as_slave(reg_base, cfg->addr_as_slave); + } - /* speed */ - _i2c_set_bus_speed(id, cfg->speed); - if (0) { + /* speed */ + _i2c_set_bus_speed(id, cfg->speed); + if (0) { #ifdef I2C_SIMPLE_MODE - } else if (cfg->mode == HAL_I2C_API_MODE_SIMPLE) { - HAL_I2C_TRACE(0,"simple mode"); - hal_i2c_nvic_setup_irq(id, (uint32_t)hal_i2c_irq_handler_s); + } else if (cfg->mode == HAL_I2C_API_MODE_SIMPLE) { + HAL_I2C_TRACE(0, "simple mode"); + hal_i2c_nvic_setup_irq(id, (uint32_t)hal_i2c_irq_handler_s); - /* only open slave related int, polling in master */ - /* read req (master read us), rx full (master write us) */ - if (cfg->as_master) { - i2cip_init_int_mask(reg_base, I2CIP_INT_UNMASK_ALL); - } else { - i2cip_init_int_mask(reg_base, I2CIP_INT_MASK_RD_REQ_MASK|I2CIP_INT_MASK_RX_FULL_MASK); - } + /* only open slave related int, polling in master */ + /* read req (master read us), rx full (master write us) */ + if (cfg->as_master) { + i2cip_init_int_mask(reg_base, I2CIP_INT_UNMASK_ALL); + } else { + i2cip_init_int_mask(reg_base, I2CIP_INT_MASK_RD_REQ_MASK | + I2CIP_INT_MASK_RX_FULL_MASK); + } - /* rx threshold, 1 byte trigger RX_FULL */ - i2cip_w_rx_threshold(reg_base, I2CIP_RX_TL_1_BYTE); + /* rx threshold, 1 byte trigger RX_FULL */ + i2cip_w_rx_threshold(reg_base, I2CIP_RX_TL_1_BYTE); - /* tx threshold, 1 byte trigger TX_EMPTY */ - i2cip_w_tx_threshold(reg_base, I2CIP_TX_TL_1_BYTE); + /* tx threshold, 1 byte trigger TX_EMPTY */ + i2cip_w_tx_threshold(reg_base, I2CIP_TX_TL_1_BYTE); - /* enable restart */ - i2cip_w_restart(reg_base, HAL_I2C_YES); + /* enable restart */ + i2cip_w_restart(reg_base, HAL_I2C_YES); - /* enable i2c */ - i2cip_w_enable(reg_base, HAL_I2C_YES); + /* enable i2c */ + i2cip_w_enable(reg_base, HAL_I2C_YES); #endif #ifdef I2C_TASK_MODE - } else if (cfg->mode == HAL_I2C_API_MODE_TASK) { - /* only use task irq handler when master mode */ - HAL_I2C_TRACE(0,"task mode"); - if (!cfg->as_master) { - HAL_I2C_TRACE(0,"not as master"); - return HAL_I2C_ERRCODE_INV_PARAM; - } + } else if (cfg->mode == HAL_I2C_API_MODE_TASK) { + /* only use task irq handler when master mode */ + HAL_I2C_TRACE(0, "task mode"); + if (!cfg->as_master) { + HAL_I2C_TRACE(0, "not as master"); + return HAL_I2C_ERRCODE_INV_PARAM; + } #ifndef I2C_USE_DMA - if (cfg->use_dma) { - HAL_I2C_TRACE(0,"using DMA when I2C_USE_DMA is NOT enabled"); - return HAL_I2C_ERRCODE_INV_PARAM; - } + if (cfg->use_dma) { + HAL_I2C_TRACE(0, "using DMA when I2C_USE_DMA is NOT enabled"); + return HAL_I2C_ERRCODE_INV_PARAM; + } #endif - hal_i2c_nvic_setup_irq(id, (uint32_t)hal_i2c_irq_handler); + hal_i2c_nvic_setup_irq(id, (uint32_t)hal_i2c_irq_handler); #endif #ifdef I2C_SENSOR_ENGINE - } else if (cfg->mode == HAL_I2C_API_MODE_SENSOR_ENGINE) { - HAL_I2C_TRACE(0,"sensor engine mode"); - ASSERT(cfg->as_master, "%s: i2c master should be used with sensor engine", __FUNCTION__); - ASSERT(cfg->use_dma, "%s: i2c dma should be used with sensor engine", __FUNCTION__); + } else if (cfg->mode == HAL_I2C_API_MODE_SENSOR_ENGINE) { + HAL_I2C_TRACE(0, "sensor engine mode"); + ASSERT(cfg->as_master, "%s: i2c master should be used with sensor engine", + __FUNCTION__); + ASSERT(cfg->use_dma, "%s: i2c dma should be used with sensor engine", + __FUNCTION__); - hal_i2c_nvic_setup_irq(id, (uint32_t)hal_i2c_irq_handler_sensor_eng); + hal_i2c_nvic_setup_irq(id, (uint32_t)hal_i2c_irq_handler_sensor_eng); #endif - } else { - ASSERT(false, "%s: Bad i2c api mode: %u", __FUNCTION__, cfg->mode); - } + } else { + ASSERT(false, "%s: Bad i2c api mode: %u", __FUNCTION__, cfg->mode); + } - hal_i2c_nvic_enable_irq(id, HAL_I2C_YES); + hal_i2c_nvic_enable_irq(id, HAL_I2C_YES); - return 0; + return 0; } -uint32_t hal_i2c_close(enum HAL_I2C_ID_T id) -{ - uint32_t reg_base; - ASSERT(id < HAL_I2C_ID_NUM, invalid_id, id); +uint32_t hal_i2c_close(enum HAL_I2C_ID_T id) { + uint32_t reg_base; + ASSERT(id < HAL_I2C_ID_NUM, invalid_id, id); - if (hal_i2c_sm[id].state == HAL_I2C_SM_CLOSED) { - return 0; - } + if (hal_i2c_sm[id].state == HAL_I2C_SM_CLOSED) { + return 0; + } - reg_base = _i2c_get_base(id); + reg_base = _i2c_get_base(id); - hal_i2c_nvic_enable_irq(id, HAL_I2C_NO); - i2cip_w_enable(reg_base, HAL_I2C_NO); + hal_i2c_nvic_enable_irq(id, HAL_I2C_NO); + i2cip_w_enable(reg_base, HAL_I2C_NO); #if defined(I2C_TASK_MODE) || defined(I2C_SENSOR_ENGINE) #ifdef I2C_USE_DMA - hal_i2c_dma_release(id); + hal_i2c_dma_release(id); #endif #endif - hal_cmu_reset_set(i2c_desc[id].apb); - hal_cmu_reset_set(i2c_desc[id].mod); - hal_cmu_clock_disable(i2c_desc[id].apb); - hal_cmu_clock_disable(i2c_desc[id].mod); + hal_cmu_reset_set(i2c_desc[id].apb); + hal_cmu_reset_set(i2c_desc[id].mod); + hal_cmu_clock_disable(i2c_desc[id].apb); + hal_cmu_clock_disable(i2c_desc[id].mod); - hal_i2c_sm[id].state = HAL_I2C_SM_CLOSED; + hal_i2c_sm[id].state = HAL_I2C_SM_CLOSED; - return 0; + return 0; } /* task mode */ #ifdef I2C_TASK_MODE uint32_t hal_i2c_task_msend(enum HAL_I2C_ID_T id, uint16_t device_addr, const uint8_t *tx_buf, uint16_t tx_item_len, - uint16_t item_cnt, uint32_t transfer_id, HAL_I2C_TRANSFER_HANDLER_T handler) -{ - uint32_t task_idx; - ASSERT(id < HAL_I2C_ID_NUM, invalid_id, id); + uint16_t item_cnt, uint32_t transfer_id, + HAL_I2C_TRANSFER_HANDLER_T handler) { + uint32_t task_idx; + ASSERT(id < HAL_I2C_ID_NUM, invalid_id, id); - if (hal_i2c_sm[id].cfg.mode != HAL_I2C_API_MODE_TASK) { - HAL_I2C_TRACE(0,"send: not task mode"); - return HAL_I2C_ERRCODE_INV_PARAM; - } + if (hal_i2c_sm[id].cfg.mode != HAL_I2C_API_MODE_TASK) { + HAL_I2C_TRACE(0, "send: not task mode"); + return HAL_I2C_ERRCODE_INV_PARAM; + } - task_idx = hal_i2c_sm_commit(id, tx_buf, tx_item_len, NULL, 0, item_cnt, - device_addr, HAL_I2C_SM_TASK_ACTION_M_SEND, - transfer_id, handler); + task_idx = + hal_i2c_sm_commit(id, tx_buf, tx_item_len, NULL, 0, item_cnt, device_addr, + HAL_I2C_SM_TASK_ACTION_M_SEND, transfer_id, handler); - hal_i2c_sm_kickoff(id); - return hal_i2c_sm_wait_task_if_need(id, task_idx, HAL_I2C_SYNC_TM_MS); + hal_i2c_sm_kickoff(id); + return hal_i2c_sm_wait_task_if_need(id, task_idx, HAL_I2C_SYNC_TM_MS); } -uint32_t hal_i2c_task_send(enum HAL_I2C_ID_T id, uint16_t device_addr, const uint8_t *tx_buf, uint16_t tx_len, - uint32_t transfer_id, HAL_I2C_TRANSFER_HANDLER_T handler) -{ - return hal_i2c_task_msend(id, device_addr, tx_buf, tx_len, 1, transfer_id, handler); +uint32_t hal_i2c_task_send(enum HAL_I2C_ID_T id, uint16_t device_addr, + const uint8_t *tx_buf, uint16_t tx_len, + uint32_t transfer_id, + HAL_I2C_TRANSFER_HANDLER_T handler) { + return hal_i2c_task_msend(id, device_addr, tx_buf, tx_len, 1, transfer_id, + handler); } -uint32_t hal_i2c_task_mrecv(enum HAL_I2C_ID_T id, uint16_t device_addr, const uint8_t *tx_buf, uint16_t tx_item_len, - uint8_t *rx_buf, uint16_t rx_item_len, uint16_t item_cnt, - uint32_t transfer_id, HAL_I2C_TRANSFER_HANDLER_T handler) -{ - uint32_t task_idx; - ASSERT(id < HAL_I2C_ID_NUM, invalid_id, id); +uint32_t hal_i2c_task_mrecv(enum HAL_I2C_ID_T id, uint16_t device_addr, + const uint8_t *tx_buf, uint16_t tx_item_len, + uint8_t *rx_buf, uint16_t rx_item_len, + uint16_t item_cnt, uint32_t transfer_id, + HAL_I2C_TRANSFER_HANDLER_T handler) { + uint32_t task_idx; + ASSERT(id < HAL_I2C_ID_NUM, invalid_id, id); - if (hal_i2c_sm[id].cfg.mode != HAL_I2C_API_MODE_TASK) { - HAL_I2C_TRACE(0,"recv: not task mode"); - return HAL_I2C_ERRCODE_INV_PARAM; - } + if (hal_i2c_sm[id].cfg.mode != HAL_I2C_API_MODE_TASK) { + HAL_I2C_TRACE(0, "recv: not task mode"); + return HAL_I2C_ERRCODE_INV_PARAM; + } - task_idx = hal_i2c_sm_commit(id, tx_buf, tx_item_len, rx_buf, rx_item_len, item_cnt, - device_addr, HAL_I2C_SM_TASK_ACTION_M_RECV, - transfer_id, handler); + task_idx = hal_i2c_sm_commit( + id, tx_buf, tx_item_len, rx_buf, rx_item_len, item_cnt, device_addr, + HAL_I2C_SM_TASK_ACTION_M_RECV, transfer_id, handler); - hal_i2c_sm_kickoff(id); - return hal_i2c_sm_wait_task_if_need(id, task_idx, HAL_I2C_SYNC_TM_MS); + hal_i2c_sm_kickoff(id); + return hal_i2c_sm_wait_task_if_need(id, task_idx, HAL_I2C_SYNC_TM_MS); } -uint32_t hal_i2c_task_recv(enum HAL_I2C_ID_T id, uint16_t device_addr, const uint8_t *tx_buf, uint16_t tx_len, - uint8_t *rx_buf, uint16_t rx_len, - uint32_t transfer_id, HAL_I2C_TRANSFER_HANDLER_T handler) -{ - return hal_i2c_task_mrecv(id, device_addr, tx_buf, tx_len, rx_buf, rx_len, 1, transfer_id, handler); +uint32_t hal_i2c_task_recv(enum HAL_I2C_ID_T id, uint16_t device_addr, + const uint8_t *tx_buf, uint16_t tx_len, + uint8_t *rx_buf, uint16_t rx_len, + uint32_t transfer_id, + HAL_I2C_TRANSFER_HANDLER_T handler) { + return hal_i2c_task_mrecv(id, device_addr, tx_buf, tx_len, rx_buf, rx_len, 1, + transfer_id, handler); } -uint32_t hal_i2c_send(enum HAL_I2C_ID_T id, uint32_t device_addr, uint8_t *buf, uint32_t reg_len, uint32_t value_len, - uint32_t transfer_id, HAL_I2C_TRANSFER_HANDLER_T handler) -{ - return hal_i2c_task_send(id, device_addr, buf, reg_len + value_len, transfer_id, handler); +uint32_t hal_i2c_send(enum HAL_I2C_ID_T id, uint32_t device_addr, uint8_t *buf, + uint32_t reg_len, uint32_t value_len, + uint32_t transfer_id, + HAL_I2C_TRANSFER_HANDLER_T handler) { + return hal_i2c_task_send(id, device_addr, buf, reg_len + value_len, + transfer_id, handler); } -uint32_t hal_i2c_recv(enum HAL_I2C_ID_T id, uint32_t device_addr, uint8_t *buf, uint32_t reg_len, uint32_t value_len, - uint8_t restart_after_write, uint32_t transfer_id, HAL_I2C_TRANSFER_HANDLER_T handler) -{ - return hal_i2c_task_recv(id, device_addr, buf, reg_len, buf + reg_len, value_len, transfer_id, handler); +uint32_t hal_i2c_recv(enum HAL_I2C_ID_T id, uint32_t device_addr, uint8_t *buf, + uint32_t reg_len, uint32_t value_len, + uint8_t restart_after_write, uint32_t transfer_id, + HAL_I2C_TRANSFER_HANDLER_T handler) { + return hal_i2c_task_recv(id, device_addr, buf, reg_len, buf + reg_len, + value_len, transfer_id, handler); } #endif /* task mode end */ /* simple mode */ #ifdef I2C_SIMPLE_MODE -static void hal_i2c_simple_proc(enum HAL_I2C_ID_T id) -{ - uint32_t reg_base = _i2c_get_base(id); - uint32_t irq_status = i2cip_r_raw_int_status(reg_base); - uint32_t abt_source = i2cip_r_tx_abrt_source(reg_base); - HAL_I2C_INT_HANDLER_T h = hal_i2c_int_handlers[id]; +static void hal_i2c_simple_proc(enum HAL_I2C_ID_T id) { + uint32_t reg_base = _i2c_get_base(id); + uint32_t irq_status = i2cip_r_raw_int_status(reg_base); + uint32_t abt_source = i2cip_r_tx_abrt_source(reg_base); + HAL_I2C_INT_HANDLER_T h = hal_i2c_int_handlers[id]; - i2cip_r_clr_all_intr(reg_base); + i2cip_r_clr_all_intr(reg_base); - if (h) { - HAL_I2C_TRACE(3,"%s:irq=0x%X abt=0x%X", __func__, irq_status, abt_source); - h(id, irq_status, abt_source); - } + if (h) { + HAL_I2C_TRACE(3, "%s:irq=0x%X abt=0x%X", __func__, irq_status, abt_source); + h(id, irq_status, abt_source); + } - // TODO: clean irq after callback done ? - i2cip_r_clr_all_intr(reg_base); + // TODO: clean irq after callback done ? + i2cip_r_clr_all_intr(reg_base); - HAL_I2C_TRACE(3,"%s:0x%X 0x%X", __func__, - i2cip_r_status(reg_base), i2cip_r_raw_int_status(reg_base)); + HAL_I2C_TRACE(3, "%s:0x%X 0x%X", __func__, i2cip_r_status(reg_base), + i2cip_r_raw_int_status(reg_base)); } -static uint32_t _i2c_check_tx_abrt_error(enum HAL_I2C_ID_T id) -{ - uint32_t reg_base = _i2c_get_base(id); +static uint32_t _i2c_check_tx_abrt_error(enum HAL_I2C_ID_T id) { + uint32_t reg_base = _i2c_get_base(id); - if (i2cip_r_raw_int_status(reg_base) & I2CIP_RAW_INT_STATUS_TX_ABRT_MASK) - return i2cip_r_tx_abrt_source(reg_base); + if (i2cip_r_raw_int_status(reg_base) & I2CIP_RAW_INT_STATUS_TX_ABRT_MASK) + return i2cip_r_tx_abrt_source(reg_base); - return 0; + return 0; } -uint32_t hal_i2c_slv_write(enum HAL_I2C_ID_T id, uint8_t *buf, uint32_t len, uint32_t *act_write) -{ - uint32_t reg_base = 0, i = 0, ret = 0; +uint32_t hal_i2c_slv_write(enum HAL_I2C_ID_T id, uint8_t *buf, uint32_t len, + uint32_t *act_write) { + uint32_t reg_base = 0, i = 0, ret = 0; - reg_base = _i2c_get_base(id); + reg_base = _i2c_get_base(id); - *act_write = 0; + *act_write = 0; - for (i = 0; i < len;) { - /* Tx Fifo Not Full */ - if (i2cip_r_status(reg_base) & I2CIP_STATUS_TFNF_MASK) { - i2cip_w_cmd_data(reg_base, buf[i]); - ++(*act_write); - ++i; - } - else { - /* wait for TFNF & not rx done & no error */ - while(!(i2cip_r_status(reg_base) & I2CIP_STATUS_TFNF_MASK) - && !(i2cip_r_raw_int_status(reg_base) & I2CIP_RAW_INT_STATUS_RX_DONE_MASK) - && !(ret = _i2c_check_tx_abrt_error(reg_base))); + for (i = 0; i < len;) { + /* Tx Fifo Not Full */ + if (i2cip_r_status(reg_base) & I2CIP_STATUS_TFNF_MASK) { + i2cip_w_cmd_data(reg_base, buf[i]); + ++(*act_write); + ++i; + } else { + /* wait for TFNF & not rx done & no error */ + while (!(i2cip_r_status(reg_base) & I2CIP_STATUS_TFNF_MASK) && + !(i2cip_r_raw_int_status(reg_base) & + I2CIP_RAW_INT_STATUS_RX_DONE_MASK) && + !(ret = _i2c_check_tx_abrt_error(reg_base))) + ; - if (ret || (i2cip_r_raw_int_status(reg_base) & I2CIP_RAW_INT_STATUS_RX_DONE_MASK)) - break; - } + if (ret || (i2cip_r_raw_int_status(reg_base) & + I2CIP_RAW_INT_STATUS_RX_DONE_MASK)) + break; } + } - /* FIXME : tx empty is not end of transmit, i2cip may transmit the last byte */ - while(!(i2cip_r_status(reg_base) & I2CIP_STATUS_TFE_SHIFT) - && !(ret = _i2c_check_tx_abrt_error(reg_base))); + /* FIXME : tx empty is not end of transmit, i2cip may transmit the last byte + */ + while (!(i2cip_r_status(reg_base) & I2CIP_STATUS_TFE_SHIFT) && + !(ret = _i2c_check_tx_abrt_error(reg_base))) + ; - /* wait to idle */ - /* FIXME : time out */ - while(i2cip_r_status(reg_base) & I2CIP_STATUS_ACT_MASK); + /* wait to idle */ + /* FIXME : time out */ + while (i2cip_r_status(reg_base) & I2CIP_STATUS_ACT_MASK) + ; - return ret; + return ret; } -uint32_t hal_i2c_slv_read(enum HAL_I2C_ID_T id, uint8_t *buf, uint32_t len, uint32_t *act_read) -{ - uint32_t reg_base = 0, i = 0, ret = 0, depth = 0; +uint32_t hal_i2c_slv_read(enum HAL_I2C_ID_T id, uint8_t *buf, uint32_t len, + uint32_t *act_read) { + uint32_t reg_base = 0, i = 0, ret = 0, depth = 0; - reg_base = _i2c_get_base(id); + reg_base = _i2c_get_base(id); - *act_read = 0; - /* slave mode : just read */ - for (i = 0; i < len;) { - /* Rx Fifo Not Empty */ - if (i2cip_r_status(reg_base) & I2CIP_STATUS_RFNE_MASK) { - buf[i] = i2cip_r_cmd_data(reg_base); - ++(*act_read); - ++i; - } - else { - /* wait for RFNE & no stop & no error */ - while(!(i2cip_r_status(reg_base) & I2CIP_STATUS_RFNE_MASK) - && !(i2cip_r_raw_int_status(reg_base) & I2CIP_RAW_INT_STATUS_STOP_DET_MASK) - && !(ret = _i2c_check_tx_abrt_error(reg_base))) { - } + *act_read = 0; + /* slave mode : just read */ + for (i = 0; i < len;) { + /* Rx Fifo Not Empty */ + if (i2cip_r_status(reg_base) & I2CIP_STATUS_RFNE_MASK) { + buf[i] = i2cip_r_cmd_data(reg_base); + ++(*act_read); + ++i; + } else { + /* wait for RFNE & no stop & no error */ + while (!(i2cip_r_status(reg_base) & I2CIP_STATUS_RFNE_MASK) && + !(i2cip_r_raw_int_status(reg_base) & + I2CIP_RAW_INT_STATUS_STOP_DET_MASK) && + !(ret = _i2c_check_tx_abrt_error(reg_base))) { + } - if (ret || (i2cip_r_raw_int_status(reg_base) & I2CIP_RAW_INT_STATUS_STOP_DET_MASK)) { - HAL_I2C_TRACE(2,"drv:i2c slave read ret 0x%X, raw status 0x%X", ret, i2cip_r_raw_int_status(reg_base)); - break; - } - } + if (ret || (i2cip_r_raw_int_status(reg_base) & + I2CIP_RAW_INT_STATUS_STOP_DET_MASK)) { + HAL_I2C_TRACE(2, "drv:i2c slave read ret 0x%X, raw status 0x%X", ret, + i2cip_r_raw_int_status(reg_base)); + break; + } } + } - /* may left some bytes in rx fifo */ - depth = i2cip_r_rx_fifo_level(reg_base); - HAL_I2C_TRACE(1,"drv:i2c slave read depth %d", depth); - while (depth > 0 && i < len) { - buf[i] = i2cip_r_cmd_data(reg_base); - ++(*act_read); - ++i; - --depth; - } + /* may left some bytes in rx fifo */ + depth = i2cip_r_rx_fifo_level(reg_base); + HAL_I2C_TRACE(1, "drv:i2c slave read depth %d", depth); + while (depth > 0 && i < len) { + buf[i] = i2cip_r_cmd_data(reg_base); + ++(*act_read); + ++i; + --depth; + } - /* wait to idle */ - while(i2cip_r_status(reg_base) & I2CIP_STATUS_ACT_MASK); + /* wait to idle */ + while (i2cip_r_status(reg_base) & I2CIP_STATUS_ACT_MASK) + ; - return 0; + return 0; } -static void i2c_clear_special_tx_abrt(uint32_t reg_base) -{ - uint32_t abrt = i2cip_r_tx_abrt_source(reg_base); +static void i2c_clear_special_tx_abrt(uint32_t reg_base) { + uint32_t abrt = i2cip_r_tx_abrt_source(reg_base); + i2cip_r_clr_tx_abrt(reg_base); + + if (abrt & I2CIP_TX_ABRT_SOURCE_ABRT_SBYTE_NORSTRT_MASK) { + i2cip_w_restart(reg_base, HAL_I2C_YES); + i2cip_w_special_bit(reg_base, HAL_I2C_NO); + i2cip_w_gc_or_start_bit(reg_base, HAL_I2C_NO); i2cip_r_clr_tx_abrt(reg_base); - - if (abrt & I2CIP_TX_ABRT_SOURCE_ABRT_SBYTE_NORSTRT_MASK) { - i2cip_w_restart(reg_base, HAL_I2C_YES); - i2cip_w_special_bit(reg_base, HAL_I2C_NO); - i2cip_w_gc_or_start_bit(reg_base, HAL_I2C_NO); - i2cip_r_clr_tx_abrt(reg_base); - } + } } -static uint32_t _i2c_check_raw_int_status(uint32_t reg_base, uint32_t mask) -{ - uint32_t regval = i2cip_r_raw_int_status(reg_base); +static uint32_t _i2c_check_raw_int_status(uint32_t reg_base, uint32_t mask) { + uint32_t regval = i2cip_r_raw_int_status(reg_base); - HAL_I2C_TRACE(3,"%s: raw status=0x%X mask=0x%X", __func__, regval, mask); - return regval & mask; + HAL_I2C_TRACE(3, "%s: raw status=0x%X mask=0x%X", __func__, regval, mask); + return regval & mask; } uint32_t hal_i2c_mst_write(enum HAL_I2C_ID_T id, uint32_t dev_addr, - const uint8_t *buf, uint32_t len, uint32_t *act_write, - uint32_t restart, uint32_t stop, uint32_t yield) -{ - uint32_t i, tar, wrcnt, ret = 0; - uint32_t reg_base; - uint32_t start_time, timeout; - uint32_t res, sto; + const uint8_t *buf, uint32_t len, + uint32_t *act_write, uint32_t restart, uint32_t stop, + uint32_t yield) { + uint32_t i, tar, wrcnt, ret = 0; + uint32_t reg_base; + uint32_t start_time, timeout; + uint32_t res, sto; - ASSERT(id < HAL_I2C_ID_NUM, invalid_id, id); + ASSERT(id < HAL_I2C_ID_NUM, invalid_id, id); - if (hal_i2c_sm[id].cfg.mode != HAL_I2C_API_MODE_SIMPLE) { - HAL_I2C_TRACE(0,"mst_write: not simple mode"); - return HAL_I2C_ERRCODE_INV_PARAM; - } + if (hal_i2c_sm[id].cfg.mode != HAL_I2C_API_MODE_SIMPLE) { + HAL_I2C_TRACE(0, "mst_write: not simple mode"); + return HAL_I2C_ERRCODE_INV_PARAM; + } - HAL_I2C_TRACE(7,"%s:id=%d addr=0x%02X buf=0x%X len=%d res=%d sto=%d", - __func__, id, dev_addr, (int)buf, len, restart, stop); + HAL_I2C_TRACE(7, "%s:id=%d addr=0x%02X buf=0x%X len=%d res=%d sto=%d", + __func__, id, dev_addr, (int)buf, len, restart, stop); - reg_base = _i2c_get_base(id); + reg_base = _i2c_get_base(id); - //update TAR - tar = i2cip_r_target_address_reg(reg_base); - if (tar != dev_addr) { - timeout = MS_TO_TICKS(HAL_I2C_WAIT_ACT_MS); - start_time = hal_sys_timer_get(); - while((i2cip_r_status(reg_base) & I2CIP_STATUS_ACT_MASK)) { - if (hal_sys_timer_get() - start_time >= timeout) { - HAL_I2C_TRACE(1,"%s:wait bus idle timeout", __func__); - ret = HAL_I2C_ERRCODE_ACT_TIMEOUT; - goto exit; - } - if (yield) { - hal_i2c_delay_ms(HAL_I2C_DLY_MS); - } - } - - i2cip_w_enable(reg_base, HAL_I2C_NO); - i2cip_w_target_address(reg_base, dev_addr); - i2cip_w_enable(reg_base, HAL_I2C_YES); - HAL_I2C_TRACE(3,"%s:update tar to 0x%02X from 0x%02X", __func__, dev_addr, tar); - } - - // check error - if (_i2c_check_raw_int_status(reg_base, I2CIP_RAW_INT_STATUS_TX_ABRT_MASK - | I2CIP_RAW_INT_STATUS_TX_OVER_MASK - | I2CIP_RAW_INT_STATUS_RX_OVER_MASK - | I2CIP_RAW_INT_STATUS_RX_UNDER_MASK)) { - i2cip_r_clr_all_intr(reg_base); - i2c_clear_special_tx_abrt(reg_base); - HAL_I2C_TRACE(1,"clear error status done before xfer: status=0x%X", - i2cip_r_raw_int_status(reg_base)); - } - - // start to transmit - wrcnt = 0; - for (i = 0; i < len; i++) { - if (i == 0) { - res = restart ? I2CIP_CMD_DATA_RESTART_MASK : 0; - } else { - res = 0; - } - if (i == (len - 1)) { - sto = stop ? I2CIP_CMD_DATA_STOP_MASK : 0; - } else { - sto = 0; - } - - timeout = MS_TO_TICKS(HAL_I2C_WAIT_TFNF_MS); - start_time = hal_sys_timer_get(); - while (!(i2cip_r_status(reg_base) & I2CIP_STATUS_TFNF_MASK)) { - ret = _i2c_check_raw_int_status(reg_base, I2CIP_RAW_INT_STATUS_TX_ABRT_MASK); - if (ret) { - i2c_clear_special_tx_abrt(reg_base); - HAL_I2C_TRACE(2,"%s:error 0x%X", __func__, ret); - goto exit; - } - if (hal_sys_timer_get() - start_time >= timeout) { - HAL_I2C_TRACE(1,"%s:wait tfnf timeout", __func__); - ret = HAL_I2C_ERRCODE_TFNF_TIMEOUT; - goto exit; - } - if (yield) { - hal_i2c_delay_ms(HAL_I2C_DLY_MS); - } - } - i2cip_w_cmd_data(reg_base, buf[i] | res | sto - | I2CIP_CMD_DATA_CMD_WRITE_MASK); - - HAL_I2C_TRACE(4,"send write cmd: data[%d]=0x%02X res=0x%X sto=0x%X", i, buf[i], res, sto); - wrcnt++; - } - - if (act_write) - *act_write = wrcnt; - - if (stop) { - // wait bus idle - timeout = MS_TO_TICKS(HAL_I2C_WAIT_ACT_MS); - start_time = hal_sys_timer_get(); - while (i2cip_r_status(reg_base) & I2CIP_STATUS_ACT_MASK) { - if (hal_sys_timer_get() - start_time >= timeout) { - if (_i2c_check_raw_int_status(reg_base, I2CIP_RAW_INT_STATUS_TX_ABRT_MASK)) { - i2cip_r_clr_all_intr(reg_base); - i2c_clear_special_tx_abrt(reg_base); - HAL_I2C_TRACE(0,"clear error status done after xfer"); - } - HAL_I2C_TRACE(1,"%s:wait act timeout", __func__); - ret = HAL_I2C_ERRCODE_ACT_TIMEOUT; - goto exit; - } - if (yield) { - hal_i2c_delay_ms(HAL_I2C_DLY_MS); - } - } - } else { - // wait until txfifo empty - timeout = MS_TO_TICKS(HAL_I2C_WAIT_TFE_MS); - start_time = hal_sys_timer_get(); - while(!(i2cip_r_status(reg_base) & I2CIP_STATUS_TFE_MASK)) { - if (hal_sys_timer_get() - start_time >= timeout) { - HAL_I2C_TRACE(1,"%s:wait tfe timeout", __func__); - ret = HAL_I2C_ERRCODE_TFE_TIMEOUT; - goto exit; - } - if (yield) { - hal_i2c_delay_ms(HAL_I2C_DLY_MS); - } - } - } - - HAL_I2C_TRACE(1,"%s:done", __func__); - return 0; -exit: - HAL_I2C_TRACE(3,"%s:error=0x%X, status=0x%X", __func__, ret, - i2cip_r_raw_int_status(reg_base)); - return ret; -} - -uint32_t hal_i2c_mst_read(enum HAL_I2C_ID_T id, uint32_t dev_addr, - uint8_t *buf, uint32_t len, uint32_t *act_read, - uint32_t restart, uint32_t stop, uint32_t yield) -{ - uint32_t i, j, tar, rdcnt, wrcnt, ret = 0; - uint32_t reg_base; - uint32_t start_time, timeout; - uint32_t res, sto; - uint8_t tmp; - uint8_t rx_ongoing, tx_limit; - - ASSERT(id < HAL_I2C_ID_NUM, invalid_id, id); - - if (hal_i2c_sm[id].cfg.mode != HAL_I2C_API_MODE_SIMPLE) { - HAL_I2C_TRACE(0,"mst_read: not simple mode"); - return HAL_I2C_ERRCODE_INV_PARAM; - } - - HAL_I2C_TRACE(7,"%s:id=%d addr=0x%02X buf=0x%X len=%d res=%d sto=%d", - __func__, id, dev_addr, (int)buf, len, restart, stop); - - reg_base = _i2c_get_base(id); - - // update TAR - tar = i2cip_r_target_address_reg(reg_base); - if (tar != dev_addr) { - timeout = MS_TO_TICKS(HAL_I2C_WAIT_ACT_MS); - start_time = hal_sys_timer_get(); - while((i2cip_r_status(reg_base) & I2CIP_STATUS_ACT_MASK)) { - if (hal_sys_timer_get() - start_time >= timeout) { - HAL_I2C_TRACE(1,"%s:wait bus idle timeout", __func__); - ret = HAL_I2C_ERRCODE_ACT_TIMEOUT; - goto exit; - } - if (yield) { - hal_i2c_delay_ms(HAL_I2C_DLY_MS); - } - } - - i2cip_w_enable(reg_base, HAL_I2C_NO); - i2cip_w_target_address(reg_base, dev_addr); - i2cip_w_enable(reg_base, HAL_I2C_YES); - HAL_I2C_TRACE(3,"%s:update tar to 0x%02X from 0x%02X", __func__, dev_addr, tar); - } - - // clear fifo by reading - j = i2cip_r_rx_fifo_level(reg_base); - if (j) { - for (i = 0;i < j; i++) { - tmp = i2cip_r_cmd_data(reg_base); - HAL_I2C_TRACE(2,"%s:discard data 0x%02X", __func__, tmp); - } - } - - // check error - if (_i2c_check_raw_int_status(reg_base, I2CIP_RAW_INT_STATUS_TX_ABRT_MASK - | I2CIP_RAW_INT_STATUS_TX_OVER_MASK - | I2CIP_RAW_INT_STATUS_RX_OVER_MASK - | I2CIP_RAW_INT_STATUS_RX_UNDER_MASK)) { - i2cip_r_clr_all_intr(reg_base); - i2c_clear_special_tx_abrt(reg_base); - HAL_I2C_TRACE(1,"clear error status done before xfer, status=0x%X", - i2cip_r_raw_int_status(reg_base)); - } - - // read data - timeout = MS_TO_TICKS(HAL_I2C_WAIT_RFNE_MS); + // update TAR + tar = i2cip_r_target_address_reg(reg_base); + if (tar != dev_addr) { + timeout = MS_TO_TICKS(HAL_I2C_WAIT_ACT_MS); start_time = hal_sys_timer_get(); - wrcnt = 0; - rdcnt = 0; - while(rdcnt < len) { - // send reading cmd - rx_ongoing = i2cip_r_tx_fifo_level(reg_base) + i2cip_r_rx_fifo_level(reg_base) + 1; - if (rx_ongoing < I2CIP_RX_FIFO_DEPTH) { - tx_limit = I2CIP_RX_FIFO_DEPTH - rx_ongoing; - } else { - tx_limit = 0; - } - - for(i = 0; i < tx_limit && wrcnt < len; i++, wrcnt++) { - if (!(i2cip_r_status(reg_base) & I2CIP_STATUS_TFNF_MASK)) { - break; - } - if (wrcnt == 0) { - res = restart ? I2CIP_CMD_DATA_RESTART_MASK : 0; - } else { - res = 0; - } - if (wrcnt == len - 1) { - sto = stop ? I2CIP_CMD_DATA_STOP_MASK : 0; - } else { - sto = 0; - } - - i2cip_w_cmd_data(reg_base, I2CIP_CMD_DATA_CMD_READ_MASK | res | sto); - HAL_I2C_TRACE(3,"send read cmd: [%u] res=0x%X, sto=0x%X", wrcnt, res, sto); - } - - if (i2cip_r_status(reg_base) & I2CIP_STATUS_RFNE_MASK) { - tmp = i2cip_r_cmd_data(reg_base); - HAL_I2C_TRACE(2,"i2c recv [%u] 0x%02X", rdcnt, tmp); - if (buf) { - buf[rdcnt++] = tmp; - } - start_time = hal_sys_timer_get(); - } else { - if (hal_sys_timer_get() - start_time >= timeout) { - HAL_I2C_TRACE(1,"%s:wait rfne timeout", __func__); - ret = HAL_I2C_ERRCODE_RFNE_TIMEOUT; - goto exit; - } - if (yield) { - hal_i2c_delay_ms(HAL_I2C_DLY_MS); - } - } + while ((i2cip_r_status(reg_base) & I2CIP_STATUS_ACT_MASK)) { + if (hal_sys_timer_get() - start_time >= timeout) { + HAL_I2C_TRACE(1, "%s:wait bus idle timeout", __func__); + ret = HAL_I2C_ERRCODE_ACT_TIMEOUT; + goto exit; + } + if (yield) { + hal_i2c_delay_ms(HAL_I2C_DLY_MS); + } } - if (act_read) *act_read = rdcnt; + i2cip_w_enable(reg_base, HAL_I2C_NO); + i2cip_w_target_address(reg_base, dev_addr); + i2cip_w_enable(reg_base, HAL_I2C_YES); + HAL_I2C_TRACE(3, "%s:update tar to 0x%02X from 0x%02X", __func__, dev_addr, + tar); + } - if (stop) { - timeout = MS_TO_TICKS(HAL_I2C_WAIT_ACT_MS); - start_time = hal_sys_timer_get(); - while (i2cip_r_status(reg_base) & I2CIP_STATUS_ACT_MASK){ - if (hal_sys_timer_get() - start_time >= timeout) { - HAL_I2C_TRACE(1,"%s:wait act timeout", __func__); - ret = HAL_I2C_ERRCODE_ACT_TIMEOUT; - goto exit; - } - if (yield) { - hal_i2c_delay_ms(HAL_I2C_DLY_MS); - } - } + // check error + if (_i2c_check_raw_int_status(reg_base, + I2CIP_RAW_INT_STATUS_TX_ABRT_MASK | + I2CIP_RAW_INT_STATUS_TX_OVER_MASK | + I2CIP_RAW_INT_STATUS_RX_OVER_MASK | + I2CIP_RAW_INT_STATUS_RX_UNDER_MASK)) { + i2cip_r_clr_all_intr(reg_base); + i2c_clear_special_tx_abrt(reg_base); + HAL_I2C_TRACE(1, "clear error status done before xfer: status=0x%X", + i2cip_r_raw_int_status(reg_base)); + } + + // start to transmit + wrcnt = 0; + for (i = 0; i < len; i++) { + if (i == 0) { + res = restart ? I2CIP_CMD_DATA_RESTART_MASK : 0; + } else { + res = 0; + } + if (i == (len - 1)) { + sto = stop ? I2CIP_CMD_DATA_STOP_MASK : 0; + } else { + sto = 0; } - HAL_I2C_TRACE(1,"%s:done", __func__); - return 0; + timeout = MS_TO_TICKS(HAL_I2C_WAIT_TFNF_MS); + start_time = hal_sys_timer_get(); + while (!(i2cip_r_status(reg_base) & I2CIP_STATUS_TFNF_MASK)) { + ret = _i2c_check_raw_int_status(reg_base, + I2CIP_RAW_INT_STATUS_TX_ABRT_MASK); + if (ret) { + i2c_clear_special_tx_abrt(reg_base); + HAL_I2C_TRACE(2, "%s:error 0x%X", __func__, ret); + goto exit; + } + if (hal_sys_timer_get() - start_time >= timeout) { + HAL_I2C_TRACE(1, "%s:wait tfnf timeout", __func__); + ret = HAL_I2C_ERRCODE_TFNF_TIMEOUT; + goto exit; + } + if (yield) { + hal_i2c_delay_ms(HAL_I2C_DLY_MS); + } + } + i2cip_w_cmd_data(reg_base, + buf[i] | res | sto | I2CIP_CMD_DATA_CMD_WRITE_MASK); + + HAL_I2C_TRACE(4, "send write cmd: data[%d]=0x%02X res=0x%X sto=0x%X", i, + buf[i], res, sto); + wrcnt++; + } + + if (act_write) + *act_write = wrcnt; + + if (stop) { + // wait bus idle + timeout = MS_TO_TICKS(HAL_I2C_WAIT_ACT_MS); + start_time = hal_sys_timer_get(); + while (i2cip_r_status(reg_base) & I2CIP_STATUS_ACT_MASK) { + if (hal_sys_timer_get() - start_time >= timeout) { + if (_i2c_check_raw_int_status(reg_base, + I2CIP_RAW_INT_STATUS_TX_ABRT_MASK)) { + i2cip_r_clr_all_intr(reg_base); + i2c_clear_special_tx_abrt(reg_base); + HAL_I2C_TRACE(0, "clear error status done after xfer"); + } + HAL_I2C_TRACE(1, "%s:wait act timeout", __func__); + ret = HAL_I2C_ERRCODE_ACT_TIMEOUT; + goto exit; + } + if (yield) { + hal_i2c_delay_ms(HAL_I2C_DLY_MS); + } + } + } else { + // wait until txfifo empty + timeout = MS_TO_TICKS(HAL_I2C_WAIT_TFE_MS); + start_time = hal_sys_timer_get(); + while (!(i2cip_r_status(reg_base) & I2CIP_STATUS_TFE_MASK)) { + if (hal_sys_timer_get() - start_time >= timeout) { + HAL_I2C_TRACE(1, "%s:wait tfe timeout", __func__); + ret = HAL_I2C_ERRCODE_TFE_TIMEOUT; + goto exit; + } + if (yield) { + hal_i2c_delay_ms(HAL_I2C_DLY_MS); + } + } + } + + HAL_I2C_TRACE(1, "%s:done", __func__); + return 0; exit: - HAL_I2C_TRACE(3,"%s:error=0x%X, status=0x%X", __func__, ret, - i2cip_r_raw_int_status(reg_base)); - return ret; + HAL_I2C_TRACE(3, "%s:error=0x%X, status=0x%X", __func__, ret, + i2cip_r_raw_int_status(reg_base)); + return ret; } -uint32_t hal_i2c_simple_send(enum HAL_I2C_ID_T id, uint16_t device_addr, const uint8_t *tx_buf, uint16_t tx_len) -{ - return hal_i2c_mst_write(id, device_addr, tx_buf, tx_len, NULL, true, true, false); -} +uint32_t hal_i2c_mst_read(enum HAL_I2C_ID_T id, uint32_t dev_addr, uint8_t *buf, + uint32_t len, uint32_t *act_read, uint32_t restart, + uint32_t stop, uint32_t yield) { + uint32_t i, j, tar, rdcnt, wrcnt, ret = 0; + uint32_t reg_base; + uint32_t start_time, timeout; + uint32_t res, sto; + uint8_t tmp; + uint8_t rx_ongoing, tx_limit; -uint32_t hal_i2c_simple_recv(enum HAL_I2C_ID_T id, uint16_t device_addr, const uint8_t *tx_buf, uint16_t tx_len, uint8_t *rx_buf, uint16_t rx_len) -{ - int ret; + ASSERT(id < HAL_I2C_ID_NUM, invalid_id, id); - ret = hal_i2c_mst_write(id, device_addr, tx_buf, tx_len, NULL, true, false, false); - if (ret) { - HAL_I2C_TRACE(2,"%s: mst_write failed: ret=%d", __func__, ret); - return ret; + if (hal_i2c_sm[id].cfg.mode != HAL_I2C_API_MODE_SIMPLE) { + HAL_I2C_TRACE(0, "mst_read: not simple mode"); + return HAL_I2C_ERRCODE_INV_PARAM; + } + + HAL_I2C_TRACE(7, "%s:id=%d addr=0x%02X buf=0x%X len=%d res=%d sto=%d", + __func__, id, dev_addr, (int)buf, len, restart, stop); + + reg_base = _i2c_get_base(id); + + // update TAR + tar = i2cip_r_target_address_reg(reg_base); + if (tar != dev_addr) { + timeout = MS_TO_TICKS(HAL_I2C_WAIT_ACT_MS); + start_time = hal_sys_timer_get(); + while ((i2cip_r_status(reg_base) & I2CIP_STATUS_ACT_MASK)) { + if (hal_sys_timer_get() - start_time >= timeout) { + HAL_I2C_TRACE(1, "%s:wait bus idle timeout", __func__); + ret = HAL_I2C_ERRCODE_ACT_TIMEOUT; + goto exit; + } + if (yield) { + hal_i2c_delay_ms(HAL_I2C_DLY_MS); + } } - return hal_i2c_mst_read(id, device_addr, rx_buf, rx_len, NULL, true, true, false); + i2cip_w_enable(reg_base, HAL_I2C_NO); + i2cip_w_target_address(reg_base, dev_addr); + i2cip_w_enable(reg_base, HAL_I2C_YES); + HAL_I2C_TRACE(3, "%s:update tar to 0x%02X from 0x%02X", __func__, dev_addr, + tar); + } + + // clear fifo by reading + j = i2cip_r_rx_fifo_level(reg_base); + if (j) { + for (i = 0; i < j; i++) { + tmp = i2cip_r_cmd_data(reg_base); + HAL_I2C_TRACE(2, "%s:discard data 0x%02X", __func__, tmp); + } + } + + // check error + if (_i2c_check_raw_int_status(reg_base, + I2CIP_RAW_INT_STATUS_TX_ABRT_MASK | + I2CIP_RAW_INT_STATUS_TX_OVER_MASK | + I2CIP_RAW_INT_STATUS_RX_OVER_MASK | + I2CIP_RAW_INT_STATUS_RX_UNDER_MASK)) { + i2cip_r_clr_all_intr(reg_base); + i2c_clear_special_tx_abrt(reg_base); + HAL_I2C_TRACE(1, "clear error status done before xfer, status=0x%X", + i2cip_r_raw_int_status(reg_base)); + } + + // read data + timeout = MS_TO_TICKS(HAL_I2C_WAIT_RFNE_MS); + start_time = hal_sys_timer_get(); + wrcnt = 0; + rdcnt = 0; + while (rdcnt < len) { + // send reading cmd + rx_ongoing = + i2cip_r_tx_fifo_level(reg_base) + i2cip_r_rx_fifo_level(reg_base) + 1; + if (rx_ongoing < I2CIP_RX_FIFO_DEPTH) { + tx_limit = I2CIP_RX_FIFO_DEPTH - rx_ongoing; + } else { + tx_limit = 0; + } + + for (i = 0; i < tx_limit && wrcnt < len; i++, wrcnt++) { + if (!(i2cip_r_status(reg_base) & I2CIP_STATUS_TFNF_MASK)) { + break; + } + if (wrcnt == 0) { + res = restart ? I2CIP_CMD_DATA_RESTART_MASK : 0; + } else { + res = 0; + } + if (wrcnt == len - 1) { + sto = stop ? I2CIP_CMD_DATA_STOP_MASK : 0; + } else { + sto = 0; + } + + i2cip_w_cmd_data(reg_base, I2CIP_CMD_DATA_CMD_READ_MASK | res | sto); + HAL_I2C_TRACE(3, "send read cmd: [%u] res=0x%X, sto=0x%X", wrcnt, res, + sto); + } + + if (i2cip_r_status(reg_base) & I2CIP_STATUS_RFNE_MASK) { + tmp = i2cip_r_cmd_data(reg_base); + HAL_I2C_TRACE(2, "i2c recv [%u] 0x%02X", rdcnt, tmp); + if (buf) { + buf[rdcnt++] = tmp; + } + start_time = hal_sys_timer_get(); + } else { + if (hal_sys_timer_get() - start_time >= timeout) { + HAL_I2C_TRACE(1, "%s:wait rfne timeout", __func__); + ret = HAL_I2C_ERRCODE_RFNE_TIMEOUT; + goto exit; + } + if (yield) { + hal_i2c_delay_ms(HAL_I2C_DLY_MS); + } + } + } + + if (act_read) + *act_read = rdcnt; + + if (stop) { + timeout = MS_TO_TICKS(HAL_I2C_WAIT_ACT_MS); + start_time = hal_sys_timer_get(); + while (i2cip_r_status(reg_base) & I2CIP_STATUS_ACT_MASK) { + if (hal_sys_timer_get() - start_time >= timeout) { + HAL_I2C_TRACE(1, "%s:wait act timeout", __func__); + ret = HAL_I2C_ERRCODE_ACT_TIMEOUT; + goto exit; + } + if (yield) { + hal_i2c_delay_ms(HAL_I2C_DLY_MS); + } + } + } + + HAL_I2C_TRACE(1, "%s:done", __func__); + return 0; +exit: + HAL_I2C_TRACE(3, "%s:error=0x%X, status=0x%X", __func__, ret, + i2cip_r_raw_int_status(reg_base)); + return ret; } -uint32_t hal_i2c_set_interrupt_handler(enum HAL_I2C_ID_T id, HAL_I2C_INT_HANDLER_T handler) -{ - hal_i2c_int_handlers[id] = handler; - return 0; +uint32_t hal_i2c_simple_send(enum HAL_I2C_ID_T id, uint16_t device_addr, + const uint8_t *tx_buf, uint16_t tx_len) { + return hal_i2c_mst_write(id, device_addr, tx_buf, tx_len, NULL, true, true, + false); +} + +uint32_t hal_i2c_simple_recv(enum HAL_I2C_ID_T id, uint16_t device_addr, + const uint8_t *tx_buf, uint16_t tx_len, + uint8_t *rx_buf, uint16_t rx_len) { + int ret; + + ret = hal_i2c_mst_write(id, device_addr, tx_buf, tx_len, NULL, true, false, + false); + if (ret) { + HAL_I2C_TRACE(2, "%s: mst_write failed: ret=%d", __func__, ret); + return ret; + } + + return hal_i2c_mst_read(id, device_addr, rx_buf, rx_len, NULL, true, true, + false); +} + +uint32_t hal_i2c_set_interrupt_handler(enum HAL_I2C_ID_T id, + HAL_I2C_INT_HANDLER_T handler) { + hal_i2c_int_handlers[id] = handler; + return 0; } #endif /* simple mode end */ /* sensor engine mode */ #ifdef I2C_SENSOR_ENGINE -static void hal_i2c_sensor_eng_proc(enum HAL_I2C_ID_T id) -{ - HAL_I2C_TRACE(2,"%s: id=%d", __func__, id); +static void hal_i2c_sensor_eng_proc(enum HAL_I2C_ID_T id) { + HAL_I2C_TRACE(2, "%s: id=%d", __func__, id); - uint32_t reg_base = _i2c_get_base(id); - uint32_t irq_status = i2cip_r_int_status(reg_base); - uint32_t POSSIBLY_UNUSED irq_raw_status = i2cip_r_raw_int_status(reg_base); - uint32_t abt_source = i2cip_r_tx_abrt_source(reg_base); - enum HAL_I2C_SM_TASK_STATE_T task_state; + uint32_t reg_base = _i2c_get_base(id); + uint32_t irq_status = i2cip_r_int_status(reg_base); + uint32_t POSSIBLY_UNUSED irq_raw_status = i2cip_r_raw_int_status(reg_base); + uint32_t abt_source = i2cip_r_tx_abrt_source(reg_base); + enum HAL_I2C_SM_TASK_STATE_T task_state; - task_state = _i2c_chk_clr_task_error(reg_base, irq_status, abt_source); + task_state = _i2c_chk_clr_task_error(reg_base, irq_status, abt_source); - HAL_I2C_TRACE(5,"%s: id=%d irq=0x%X/0x%X abt=0x%X", __func__, id, irq_status, irq_raw_status, abt_source); - _i2c_show_error_code(abt_source); + HAL_I2C_TRACE(5, "%s: id=%d irq=0x%X/0x%X abt=0x%X", __func__, id, irq_status, + irq_raw_status, abt_source); + _i2c_show_error_code(abt_source); - if (task_state & (HAL_I2C_SM_TASK_STATE_TX_ABRT | HAL_I2C_SM_TASK_STATE_FIFO_ERR)) { - HAL_I2C_ERROR(6,"*** Error:%s: id=%d task_state=0x%X irq=0x%X/0x%X abt=0x%X", __func__, id, task_state, irq_status, irq_raw_status, abt_source); - hal_i2c_sensor_engine_stop(i2c_sensor_id[id]); - } + if (task_state & + (HAL_I2C_SM_TASK_STATE_TX_ABRT | HAL_I2C_SM_TASK_STATE_FIFO_ERR)) { + HAL_I2C_ERROR( + 6, "*** Error:%s: id=%d task_state=0x%X irq=0x%X/0x%X abt=0x%X", + __func__, id, task_state, irq_status, irq_raw_status, abt_source); + hal_i2c_sensor_engine_stop(i2c_sensor_id[id]); + } } -static void _sensor_irq_handler(enum HAL_SENSOR_ENGINE_ID_T id, enum HAL_SENSOR_ENGINE_DEVICE_T device, const uint8_t *buf, uint32_t len) -{ - enum HAL_I2C_ID_T i2c_id; +static void _sensor_irq_handler(enum HAL_SENSOR_ENGINE_ID_T id, + enum HAL_SENSOR_ENGINE_DEVICE_T device, + const uint8_t *buf, uint32_t len) { + enum HAL_I2C_ID_T i2c_id; - i2c_id = HAL_I2C_ID_0 + (device - HAL_SENSOR_ENGINE_DEVICE_I2C0); - ASSERT(i2c_id < HAL_I2C_ID_NUM, invalid_id, i2c_id); + i2c_id = HAL_I2C_ID_0 + (device - HAL_SENSOR_ENGINE_DEVICE_I2C0); + ASSERT(i2c_id < HAL_I2C_ID_NUM, invalid_id, i2c_id); - if (i2c_sensor_handler[i2c_id]) { - i2c_sensor_handler[i2c_id](i2c_id, buf, len); - } + if (i2c_sensor_handler[i2c_id]) { + i2c_sensor_handler[i2c_id](i2c_id, buf, len); + } } -uint32_t hal_i2c_sensor_engine_start(enum HAL_I2C_ID_T id, const struct HAL_I2C_SENSOR_ENGINE_CONFIG_T *cfg) -{ - enum HAL_I2C_SM_TASK_ACTION_T action; - const struct HAL_I2C_SM_TASK_T *out_task; - struct HAL_SENSOR_ENGINE_CFG_T sensor_cfg; - uint32_t reg_base; +uint32_t +hal_i2c_sensor_engine_start(enum HAL_I2C_ID_T id, + const struct HAL_I2C_SENSOR_ENGINE_CONFIG_T *cfg) { + enum HAL_I2C_SM_TASK_ACTION_T action; + const struct HAL_I2C_SM_TASK_T *out_task; + struct HAL_SENSOR_ENGINE_CFG_T sensor_cfg; + uint32_t reg_base; - HAL_I2C_ERROR(2,"%s: id=%d", __func__, id); - ASSERT(id < HAL_I2C_ID_NUM, invalid_id, id); + HAL_I2C_ERROR(2, "%s: id=%d", __func__, id); + ASSERT(id < HAL_I2C_ID_NUM, invalid_id, id); - if (hal_i2c_sm[id].cfg.mode != HAL_I2C_API_MODE_SENSOR_ENGINE) { - HAL_I2C_TRACE(1,"i2c-se start: not sensor engine mode: %d", hal_i2c_sm[id].cfg.mode); - return HAL_I2C_ERRCODE_INV_PARAM; - } - if (hal_i2c_sm[id].state != HAL_I2C_SM_IDLE) { - HAL_I2C_TRACE(1,"i2c-se start: not idle: %d", hal_i2c_sm[id].state); - return HAL_I2C_ERRCODE_INV_PARAM; - } + if (hal_i2c_sm[id].cfg.mode != HAL_I2C_API_MODE_SENSOR_ENGINE) { + HAL_I2C_TRACE(1, "i2c-se start: not sensor engine mode: %d", + hal_i2c_sm[id].cfg.mode); + return HAL_I2C_ERRCODE_INV_PARAM; + } + if (hal_i2c_sm[id].state != HAL_I2C_SM_IDLE) { + HAL_I2C_TRACE(1, "i2c-se start: not idle: %d", hal_i2c_sm[id].state); + return HAL_I2C_ERRCODE_INV_PARAM; + } - reg_base = _i2c_get_base(id); - action = HAL_I2C_SM_TASK_ACTION_M_RECV; + reg_base = _i2c_get_base(id); + action = HAL_I2C_SM_TASK_ACTION_M_RECV; - hal_i2c_sm[id].state = HAL_I2C_SM_RUNNING; + hal_i2c_sm[id].state = HAL_I2C_SM_RUNNING; - hal_i2c_sm_commit(id, cfg->write_buf, cfg->write_txn_len, - cfg->read_buf, cfg->read_txn_len, cfg->txn_cnt, - cfg->target_addr, action, 0, NULL); + hal_i2c_sm_commit(id, cfg->write_buf, cfg->write_txn_len, cfg->read_buf, + cfg->read_txn_len, cfg->txn_cnt, cfg->target_addr, action, + 0, NULL); - out_task = &(hal_i2c_sm[id].task[hal_i2c_sm[id].out_task]); - hal_i2c_dma_config(id, out_task); + out_task = &(hal_i2c_sm[id].task[hal_i2c_sm[id].out_task]); + hal_i2c_dma_config(id, out_task); - i2c_sensor_id[id] = cfg->id; - i2c_sensor_handler[id] = cfg->handler; + i2c_sensor_id[id] = cfg->id; + i2c_sensor_handler[id] = cfg->handler; - memset(&sensor_cfg, 0, sizeof(sensor_cfg)); - sensor_cfg.id = cfg->id; - sensor_cfg.device = (id == HAL_I2C_ID_0) ? HAL_SENSOR_ENGINE_DEVICE_I2C0 : HAL_SENSOR_ENGINE_DEVICE_I2C1; - sensor_cfg.trigger_type = cfg->trigger_type; - sensor_cfg.trigger_gpio = cfg->trigger_gpio; - sensor_cfg.period_us = cfg->period_us; - sensor_cfg.device_address = cfg->target_addr; - sensor_cfg.tx_dma_cfg = &hal_i2c_sm[id].tx_dma_cfg; - sensor_cfg.rx_dma_cfg = &hal_i2c_sm[id].rx_dma_cfg; - sensor_cfg.rx_burst_len = cfg->read_txn_len * cfg->txn_cnt; - sensor_cfg.rx_burst_cnt = cfg->read_burst_cnt; - sensor_cfg.handler = _sensor_irq_handler;; + memset(&sensor_cfg, 0, sizeof(sensor_cfg)); + sensor_cfg.id = cfg->id; + sensor_cfg.device = (id == HAL_I2C_ID_0) ? HAL_SENSOR_ENGINE_DEVICE_I2C0 + : HAL_SENSOR_ENGINE_DEVICE_I2C1; + sensor_cfg.trigger_type = cfg->trigger_type; + sensor_cfg.trigger_gpio = cfg->trigger_gpio; + sensor_cfg.period_us = cfg->period_us; + sensor_cfg.device_address = cfg->target_addr; + sensor_cfg.tx_dma_cfg = &hal_i2c_sm[id].tx_dma_cfg; + sensor_cfg.rx_dma_cfg = &hal_i2c_sm[id].rx_dma_cfg; + sensor_cfg.rx_burst_len = cfg->read_txn_len * cfg->txn_cnt; + sensor_cfg.rx_burst_cnt = cfg->read_burst_cnt; + sensor_cfg.handler = _sensor_irq_handler; + ; #ifdef I2C_VAD - sensor_cfg.data_to_vad = 1; - i2cip_w_data_to_vad(reg_base, HAL_I2C_YES); + sensor_cfg.data_to_vad = 1; + i2cip_w_data_to_vad(reg_base, HAL_I2C_YES); #endif - hal_sensor_engine_open(&sensor_cfg); + hal_sensor_engine_open(&sensor_cfg); - /* tx : quarter trigger TX EMPTY INT */ - i2cip_w_tx_threshold(reg_base, HAL_I2C_TX_TL); - if (action == HAL_I2C_SM_TASK_ACTION_M_RECV) { - /* rx : three quarter trigger RX FULL INT */ - i2cip_w_rx_threshold(reg_base, HAL_I2C_RX_TL); - } + /* tx : quarter trigger TX EMPTY INT */ + i2cip_w_tx_threshold(reg_base, HAL_I2C_TX_TL); + if (action == HAL_I2C_SM_TASK_ACTION_M_RECV) { + /* rx : three quarter trigger RX FULL INT */ + i2cip_w_rx_threshold(reg_base, HAL_I2C_RX_TL); + } - i2cip_init_int_mask(reg_base, I2CIP_INT_MASK_ERROR_MASK); + i2cip_init_int_mask(reg_base, I2CIP_INT_MASK_ERROR_MASK); - i2cip_w_restart(reg_base, HAL_I2C_YES); - i2cip_w_target_address(reg_base, out_task->target_addr); + i2cip_w_restart(reg_base, HAL_I2C_YES); + i2cip_w_target_address(reg_base, out_task->target_addr); - return 0; + return 0; } -uint32_t hal_i2c_sensor_engine_stop(enum HAL_I2C_ID_T id) -{ - uint32_t reg_base; - uint32_t irq_status; - uint32_t abt_source; +uint32_t hal_i2c_sensor_engine_stop(enum HAL_I2C_ID_T id) { + uint32_t reg_base; + uint32_t irq_status; + uint32_t abt_source; - HAL_I2C_ERROR(2,"%s: id=%d", __func__, id); - ASSERT(id < HAL_I2C_ID_NUM, invalid_id, id); + HAL_I2C_ERROR(2, "%s: id=%d", __func__, id); + ASSERT(id < HAL_I2C_ID_NUM, invalid_id, id); - if (hal_i2c_sm[id].cfg.mode != HAL_I2C_API_MODE_SENSOR_ENGINE) { - HAL_I2C_TRACE(1,"i2c-se stop: not sensor engine mode: %d", hal_i2c_sm[id].cfg.mode); - return HAL_I2C_ERRCODE_INV_PARAM; - } - if (hal_i2c_sm[id].state != HAL_I2C_SM_RUNNING) { - HAL_I2C_TRACE(1,"i2c-se stop: not running: %d", hal_i2c_sm[id].state); - return HAL_I2C_ERRCODE_INV_PARAM; - } + if (hal_i2c_sm[id].cfg.mode != HAL_I2C_API_MODE_SENSOR_ENGINE) { + HAL_I2C_TRACE(1, "i2c-se stop: not sensor engine mode: %d", + hal_i2c_sm[id].cfg.mode); + return HAL_I2C_ERRCODE_INV_PARAM; + } + if (hal_i2c_sm[id].state != HAL_I2C_SM_RUNNING) { + HAL_I2C_TRACE(1, "i2c-se stop: not running: %d", hal_i2c_sm[id].state); + return HAL_I2C_ERRCODE_INV_PARAM; + } - hal_sensor_engine_close(i2c_sensor_id[id]); + hal_sensor_engine_close(i2c_sensor_id[id]); - hal_i2c_dma_release(id); + hal_i2c_dma_release(id); - reg_base = _i2c_get_base(id); + reg_base = _i2c_get_base(id); - HAL_I2C_TRACE(0,"disable i2c"); - i2cip_w_enable(reg_base, HAL_I2C_NO); + HAL_I2C_TRACE(0, "disable i2c"); + i2cip_w_enable(reg_base, HAL_I2C_NO); - irq_status = i2cip_r_int_status(reg_base); - abt_source = i2cip_r_tx_abrt_source(reg_base); - _i2c_chk_clr_task_error(reg_base, irq_status, abt_source); + irq_status = i2cip_r_int_status(reg_base); + abt_source = i2cip_r_tx_abrt_source(reg_base); + _i2c_chk_clr_task_error(reg_base, irq_status, abt_source); #ifdef I2C_VAD - i2cip_w_data_to_vad(reg_base, HAL_I2C_NO); + i2cip_w_data_to_vad(reg_base, HAL_I2C_NO); #endif - hal_i2c_sm_done(id); + hal_i2c_sm_done(id); - return 0; + return 0; } #endif /* sensor engine mode end */ @@ -2064,46 +2125,43 @@ uint32_t hal_i2c_sensor_engine_stop(enum HAL_I2C_ID_T id) static uint8_t g_i2c_open = false; -#define DURATION_INIT_1 600 -#define DURATION_INIT_2 600 -#define DURATION_INIT_3 600 +#define DURATION_INIT_1 600 +#define DURATION_INIT_2 600 +#define DURATION_INIT_3 600 -#define DURATION_START_1 600 -#define DURATION_START_2 600 -#define DURATION_START_3 600 +#define DURATION_START_1 600 +#define DURATION_START_2 600 +#define DURATION_START_3 600 -#define DURATION_STOP_1 800 -#define DURATION_STOP_2 600 -#define DURATION_STOP_3 1300 +#define DURATION_STOP_1 800 +#define DURATION_STOP_2 600 +#define DURATION_STOP_3 1300 -#define DURATION_HIGH 900 -#define DURATION_LOW 600 +#define DURATION_HIGH 900 +#define DURATION_LOW 600 -#define HAL_GPIO_I2C_DELAY(duration) hal_sys_timer_delay_ns(duration); +#define HAL_GPIO_I2C_DELAY(duration) hal_sys_timer_delay_ns(duration); struct HAL_GPIO_I2C_CONFIG_T hal_gpio_i2c_cfg; -inline void GPIO_InitIO(uint8_t port, uint8_t direction, uint8_t val_for_out) -{ - hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)port, (enum HAL_GPIO_DIR_T)direction, val_for_out); +inline void GPIO_InitIO(uint8_t port, uint8_t direction, uint8_t val_for_out) { + hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)port, + (enum HAL_GPIO_DIR_T)direction, val_for_out); } -inline void GPIO_WriteIO(uint8_t port, uint8_t data) -{ - if(data){ - hal_gpio_pin_set((enum HAL_GPIO_PIN_T)port); - }else{ - hal_gpio_pin_clr((enum HAL_GPIO_PIN_T)port); - } +inline void GPIO_WriteIO(uint8_t port, uint8_t data) { + if (data) { + hal_gpio_pin_set((enum HAL_GPIO_PIN_T)port); + } else { + hal_gpio_pin_clr((enum HAL_GPIO_PIN_T)port); + } } -inline uint8_t GPIO_ReadIO(uint8_t port) -{ - uint8_t level = 0; - level = hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)port); - return level; +inline uint8_t GPIO_ReadIO(uint8_t port) { + uint8_t level = 0; + level = hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)port); + return level; } - // //------------------------------------------------------------------- // Function: gpio_i2c_init @@ -2112,263 +2170,255 @@ inline uint8_t GPIO_ReadIO(uint8_t port) // Return: bool //------------------------------------------------------------------- +static int hal_gpio_i2c_initialize(const struct HAL_GPIO_I2C_CONFIG_T *cfg) { + struct HAL_IOMUX_PIN_FUNCTION_MAP hal_gpio_i2c_iomux_cfg[] = { + {HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + {HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}, + }; -static int hal_gpio_i2c_initialize(const struct HAL_GPIO_I2C_CONFIG_T *cfg) -{ - struct HAL_IOMUX_PIN_FUNCTION_MAP hal_gpio_i2c_iomux_cfg[] = { - {HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}, - {HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}, - }; + hal_gpio_i2c_cfg.scl = cfg->scl; + hal_gpio_i2c_cfg.sda = cfg->sda; + hal_gpio_i2c_iomux_cfg[0].pin = (enum HAL_IOMUX_PIN_T)hal_gpio_i2c_cfg.scl; + hal_gpio_i2c_iomux_cfg[1].pin = (enum HAL_IOMUX_PIN_T)hal_gpio_i2c_cfg.sda; + hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)hal_gpio_i2c_iomux_cfg, + sizeof(hal_gpio_i2c_iomux_cfg) / + sizeof(struct HAL_IOMUX_PIN_FUNCTION_MAP)); - hal_gpio_i2c_cfg.scl = cfg->scl; - hal_gpio_i2c_cfg.sda = cfg->sda; - hal_gpio_i2c_iomux_cfg[0].pin = (enum HAL_IOMUX_PIN_T)hal_gpio_i2c_cfg.scl; - hal_gpio_i2c_iomux_cfg[1].pin = (enum HAL_IOMUX_PIN_T)hal_gpio_i2c_cfg.sda; - hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)hal_gpio_i2c_iomux_cfg, sizeof(hal_gpio_i2c_iomux_cfg)/sizeof(struct HAL_IOMUX_PIN_FUNCTION_MAP)); + HAL_I2C_TRACE(2, "hal_gpio_i2c_initialize scl=%d sda=%d", + hal_gpio_i2c_cfg.scl, hal_gpio_i2c_cfg.sda); + // iTemp = hal_gpio_i2c_cfg.scl | hal_gpio_i2c_cfg.sda ; + // Set the GPIO pin to output status + GPIO_InitIO(hal_gpio_i2c_cfg.scl, 1, 1); + GPIO_InitIO(hal_gpio_i2c_cfg.sda, 1, 1); + HAL_GPIO_I2C_DELAY(DURATION_INIT_1); - HAL_I2C_TRACE(2,"hal_gpio_i2c_initialize scl=%d sda=%d", hal_gpio_i2c_cfg.scl , hal_gpio_i2c_cfg.sda); - //iTemp = hal_gpio_i2c_cfg.scl | hal_gpio_i2c_cfg.sda ; - // Set the GPIO pin to output status - GPIO_InitIO(hal_gpio_i2c_cfg.scl, 1, 1); - GPIO_InitIO(hal_gpio_i2c_cfg.sda, 1, 1); - HAL_GPIO_I2C_DELAY(DURATION_INIT_1); + // Make the I2C bus in idle status + GPIO_WriteIO(hal_gpio_i2c_cfg.scl, 1); + HAL_GPIO_I2C_DELAY(DURATION_INIT_1); + GPIO_WriteIO(hal_gpio_i2c_cfg.sda, 1); + HAL_GPIO_I2C_DELAY(DURATION_INIT_1); - // Make the I2C bus in idle status - GPIO_WriteIO(hal_gpio_i2c_cfg.scl,1); - HAL_GPIO_I2C_DELAY(DURATION_INIT_1); - GPIO_WriteIO(hal_gpio_i2c_cfg.sda ,1); - HAL_GPIO_I2C_DELAY(DURATION_INIT_1); + for (byte i = 0; i < 30; i++) { + GPIO_WriteIO(hal_gpio_i2c_cfg.scl, 0); /* low */ + HAL_GPIO_I2C_DELAY(DURATION_LOW); + GPIO_WriteIO(hal_gpio_i2c_cfg.scl, 1); + HAL_GPIO_I2C_DELAY(DURATION_HIGH); + } - for(byte i=0;i<30;i++) - { - GPIO_WriteIO(hal_gpio_i2c_cfg.scl,0); /* low */ - HAL_GPIO_I2C_DELAY(DURATION_LOW); - GPIO_WriteIO(hal_gpio_i2c_cfg.scl,1); - HAL_GPIO_I2C_DELAY(DURATION_HIGH); - } - - return 0; + return 0; } static void hal_gpio_i2c_start(void) /* start or re-start */ { - GPIO_InitIO(hal_gpio_i2c_cfg.sda, 1, 1); - GPIO_WriteIO(hal_gpio_i2c_cfg.sda ,1); - GPIO_WriteIO(hal_gpio_i2c_cfg.scl,1); + GPIO_InitIO(hal_gpio_i2c_cfg.sda, 1, 1); + GPIO_WriteIO(hal_gpio_i2c_cfg.sda, 1); + GPIO_WriteIO(hal_gpio_i2c_cfg.scl, 1); - HAL_GPIO_I2C_DELAY(DURATION_START_1); - GPIO_WriteIO(hal_gpio_i2c_cfg.sda ,0); - HAL_GPIO_I2C_DELAY(DURATION_START_2); - GPIO_WriteIO(hal_gpio_i2c_cfg.scl,0); - HAL_GPIO_I2C_DELAY(DURATION_START_3);/* start condition */ + HAL_GPIO_I2C_DELAY(DURATION_START_1); + GPIO_WriteIO(hal_gpio_i2c_cfg.sda, 0); + HAL_GPIO_I2C_DELAY(DURATION_START_2); + GPIO_WriteIO(hal_gpio_i2c_cfg.scl, 0); + HAL_GPIO_I2C_DELAY(DURATION_START_3); /* start condition */ } -static void hal_gpio_i2c_stop(void) -{ - GPIO_WriteIO(hal_gpio_i2c_cfg.scl,0); - HAL_GPIO_I2C_DELAY(DURATION_LOW); - GPIO_InitIO(hal_gpio_i2c_cfg.sda, 1, 0); - GPIO_WriteIO(hal_gpio_i2c_cfg.sda ,0); - HAL_GPIO_I2C_DELAY(DURATION_STOP_1); - GPIO_WriteIO(hal_gpio_i2c_cfg.scl,1); - HAL_GPIO_I2C_DELAY(DURATION_STOP_2); - GPIO_WriteIO(hal_gpio_i2c_cfg.sda ,1); /* stop condition */ - HAL_GPIO_I2C_DELAY(DURATION_STOP_3); +static void hal_gpio_i2c_stop(void) { + GPIO_WriteIO(hal_gpio_i2c_cfg.scl, 0); + HAL_GPIO_I2C_DELAY(DURATION_LOW); + GPIO_InitIO(hal_gpio_i2c_cfg.sda, 1, 0); + GPIO_WriteIO(hal_gpio_i2c_cfg.sda, 0); + HAL_GPIO_I2C_DELAY(DURATION_STOP_1); + GPIO_WriteIO(hal_gpio_i2c_cfg.scl, 1); + HAL_GPIO_I2C_DELAY(DURATION_STOP_2); + GPIO_WriteIO(hal_gpio_i2c_cfg.sda, 1); /* stop condition */ + HAL_GPIO_I2C_DELAY(DURATION_STOP_3); } static uint8_t hal_gpio_i2c_txbyte(uint8_t data) /* return 0 --> ack */ { - int i; - uint8_t temp_value = 0; - for(i=7; (i>=0)&&(i<=7); i--) - { - GPIO_WriteIO(hal_gpio_i2c_cfg.scl,0); /* low */ - HAL_GPIO_I2C_DELAY(DURATION_LOW); - if(i==7)GPIO_InitIO(hal_gpio_i2c_cfg.sda, 1, 0); - HAL_GPIO_I2C_DELAY(DURATION_LOW); + int i; + uint8_t temp_value = 0; + for (i = 7; (i >= 0) && (i <= 7); i--) { + GPIO_WriteIO(hal_gpio_i2c_cfg.scl, 0); /* low */ + HAL_GPIO_I2C_DELAY(DURATION_LOW); + if (i == 7) + GPIO_InitIO(hal_gpio_i2c_cfg.sda, 1, 0); + HAL_GPIO_I2C_DELAY(DURATION_LOW); - GPIO_WriteIO(hal_gpio_i2c_cfg.sda ,((data>>i)&0x01)); - HAL_GPIO_I2C_DELAY(DURATION_LOW/2); - GPIO_WriteIO(hal_gpio_i2c_cfg.scl, 1); /* high */ - HAL_GPIO_I2C_DELAY(DURATION_HIGH); - } - GPIO_WriteIO(hal_gpio_i2c_cfg.scl,0); /* low */ - HAL_GPIO_I2C_DELAY(DURATION_LOW); - GPIO_InitIO(hal_gpio_i2c_cfg.sda, 0, 1);/* input */ - HAL_GPIO_I2C_DELAY(DURATION_LOW/2); - GPIO_WriteIO(hal_gpio_i2c_cfg.scl,1); /* high */ + GPIO_WriteIO(hal_gpio_i2c_cfg.sda, ((data >> i) & 0x01)); + HAL_GPIO_I2C_DELAY(DURATION_LOW / 2); + GPIO_WriteIO(hal_gpio_i2c_cfg.scl, 1); /* high */ HAL_GPIO_I2C_DELAY(DURATION_HIGH); - temp_value = GPIO_ReadIO(hal_gpio_i2c_cfg.sda ); - GPIO_WriteIO(hal_gpio_i2c_cfg.scl,0); /* low */ - HAL_GPIO_I2C_DELAY(DURATION_LOW); - return temp_value; + } + GPIO_WriteIO(hal_gpio_i2c_cfg.scl, 0); /* low */ + HAL_GPIO_I2C_DELAY(DURATION_LOW); + GPIO_InitIO(hal_gpio_i2c_cfg.sda, 0, 1); /* input */ + HAL_GPIO_I2C_DELAY(DURATION_LOW / 2); + GPIO_WriteIO(hal_gpio_i2c_cfg.scl, 1); /* high */ + HAL_GPIO_I2C_DELAY(DURATION_HIGH); + temp_value = GPIO_ReadIO(hal_gpio_i2c_cfg.sda); + GPIO_WriteIO(hal_gpio_i2c_cfg.scl, 0); /* low */ + HAL_GPIO_I2C_DELAY(DURATION_LOW); + return temp_value; } -static void hal_gpio_i2c_rxbyte(uint8_t *data, uint8_t ack) -{ - int i; - uint32_t dataCache; +static void hal_gpio_i2c_rxbyte(uint8_t *data, uint8_t ack) { + int i; + uint32_t dataCache; - dataCache = 0; - for(i=7; (i>=0)&&(i<=7); i--) - { - GPIO_WriteIO(hal_gpio_i2c_cfg.scl,0); - HAL_GPIO_I2C_DELAY(DURATION_LOW); - if(i==7)GPIO_InitIO(hal_gpio_i2c_cfg.sda, 0, 1); - HAL_GPIO_I2C_DELAY(DURATION_LOW); - GPIO_WriteIO(hal_gpio_i2c_cfg.scl,1); - HAL_GPIO_I2C_DELAY(DURATION_HIGH); - dataCache |= (GPIO_ReadIO(hal_gpio_i2c_cfg.sda )<= 0) && (i <= 7); i--) { + GPIO_WriteIO(hal_gpio_i2c_cfg.scl, 0); HAL_GPIO_I2C_DELAY(DURATION_LOW); - GPIO_InitIO(hal_gpio_i2c_cfg.sda, 1, 1); - GPIO_WriteIO(hal_gpio_i2c_cfg.sda ,ack); - HAL_GPIO_I2C_DELAY(DURATION_LOW/2); - GPIO_WriteIO(hal_gpio_i2c_cfg.scl,1); + if (i == 7) + GPIO_InitIO(hal_gpio_i2c_cfg.sda, 0, 1); + HAL_GPIO_I2C_DELAY(DURATION_LOW); + GPIO_WriteIO(hal_gpio_i2c_cfg.scl, 1); HAL_GPIO_I2C_DELAY(DURATION_HIGH); - GPIO_WriteIO(hal_gpio_i2c_cfg.scl,0); /* low */ - HAL_GPIO_I2C_DELAY(DURATION_LOW); - *data = (uint8_t)dataCache; + dataCache |= (GPIO_ReadIO(hal_gpio_i2c_cfg.sda) << i); + HAL_GPIO_I2C_DELAY(DURATION_LOW / 2); + } + + GPIO_WriteIO(hal_gpio_i2c_cfg.scl, 0); + HAL_GPIO_I2C_DELAY(DURATION_LOW); + GPIO_InitIO(hal_gpio_i2c_cfg.sda, 1, 1); + GPIO_WriteIO(hal_gpio_i2c_cfg.sda, ack); + HAL_GPIO_I2C_DELAY(DURATION_LOW / 2); + GPIO_WriteIO(hal_gpio_i2c_cfg.scl, 1); + HAL_GPIO_I2C_DELAY(DURATION_HIGH); + GPIO_WriteIO(hal_gpio_i2c_cfg.scl, 0); /* low */ + HAL_GPIO_I2C_DELAY(DURATION_LOW); + *data = (uint8_t)dataCache; } +uint32_t hal_gpio_i2c_simple_send(uint32_t device_addr, const uint8_t *tx_buf, + uint16_t tx_len) { + uint32_t i; -uint32_t hal_gpio_i2c_simple_send(uint32_t device_addr, const uint8_t *tx_buf, uint16_t tx_len) -{ - uint32_t i; + hal_gpio_i2c_start(); + if (device_addr & HAL_I2C_10BITADDR_MASK) { + hal_gpio_i2c_txbyte(0xF0 | ((device_addr & 0x200) >> 7)); + hal_gpio_i2c_txbyte(device_addr & 0xFF); + } else { + hal_gpio_i2c_txbyte((device_addr & 0x7F) << 1); + } + for (i = 0; i < tx_len; i++, tx_buf++) { + hal_gpio_i2c_txbyte(*tx_buf); + } + hal_gpio_i2c_stop(); + return 0; +} + +uint32_t hal_gpio_i2c_simple_recv(uint32_t device_addr, const uint8_t *tx_buf, + uint16_t tx_len, uint8_t *rx_buf, + uint16_t rx_len) { + uint8_t tempdata; + uint32_t i; + + if (tx_len) { hal_gpio_i2c_start(); if (device_addr & HAL_I2C_10BITADDR_MASK) { - hal_gpio_i2c_txbyte(0xF0 | ((device_addr & 0x200) >> 7)); - hal_gpio_i2c_txbyte(device_addr & 0xFF); + hal_gpio_i2c_txbyte(((device_addr & 0x200) >> 7) | 0xF0); + hal_gpio_i2c_txbyte(device_addr & 0xFF); } else { - hal_gpio_i2c_txbyte((device_addr & 0x7F) << 1); + hal_gpio_i2c_txbyte((device_addr & 0x7F) << 1); } for (i = 0; i < tx_len; i++, tx_buf++) { - hal_gpio_i2c_txbyte(*tx_buf); + hal_gpio_i2c_txbyte(*tx_buf); } - hal_gpio_i2c_stop(); + } - return 0; + hal_gpio_i2c_start(); + if (device_addr & HAL_I2C_10BITADDR_MASK) { + hal_gpio_i2c_txbyte(((device_addr & 0x200) >> 7) | 0xF1); + } else { + hal_gpio_i2c_txbyte(((device_addr & 0x7F) << 1) | 1); + } + for (i = 0; i < rx_len; i++, rx_buf++) { + hal_gpio_i2c_rxbyte(&tempdata, (i == rx_len - 1)); + *rx_buf = tempdata; + } + hal_gpio_i2c_stop(); + + return 0; } -uint32_t hal_gpio_i2c_simple_recv(uint32_t device_addr, const uint8_t *tx_buf, uint16_t tx_len, uint8_t *rx_buf, uint16_t rx_len) -{ - uint8_t tempdata; - uint32_t i; +#define touch_ic_device_addr 0x60 +unsigned char I2C_WriteByte(unsigned char reg, unsigned char data) { + unsigned char result; + unsigned char buff[2]; - if (tx_len) { - hal_gpio_i2c_start(); - if (device_addr & HAL_I2C_10BITADDR_MASK) { - hal_gpio_i2c_txbyte(((device_addr & 0x200) >> 7) | 0xF0); - hal_gpio_i2c_txbyte(device_addr & 0xFF); - } else { - hal_gpio_i2c_txbyte((device_addr & 0x7F) << 1); - } - for (i = 0; i < tx_len; i++, tx_buf++) { - hal_gpio_i2c_txbyte(*tx_buf); - } - } + buff[0] = reg; + buff[1] = data; - hal_gpio_i2c_start(); - if (device_addr & HAL_I2C_10BITADDR_MASK) { - hal_gpio_i2c_txbyte(((device_addr & 0x200) >> 7) | 0xF1); - } else { - hal_gpio_i2c_txbyte(((device_addr & 0x7F) << 1) | 1); - } - for (i = 0; i < rx_len; i++, rx_buf++) { - hal_gpio_i2c_rxbyte(&tempdata, (i == rx_len - 1)); - *rx_buf = tempdata; - } - hal_gpio_i2c_stop(); - - return 0; + result = + hal_gpio_i2c_simple_send((unsigned char)touch_ic_device_addr, buff, 2); + return result; } -#define touch_ic_device_addr 0x60 -unsigned char I2C_WriteByte(unsigned char reg, unsigned char data) -{ - unsigned char result; - unsigned char buff[2]; +unsigned char I2C_ReadByte(unsigned char reg, unsigned char *data) { + unsigned char result; - buff[0] = reg; - buff[1] = data; - - result = hal_gpio_i2c_simple_send((unsigned char)touch_ic_device_addr,buff,2); - return result; + result = hal_gpio_i2c_simple_recv((unsigned char)touch_ic_device_addr, ®, + 1, data, 1); + + return result; } -unsigned char I2C_ReadByte(unsigned char reg, unsigned char* data) -{ - unsigned char result; - - result = hal_gpio_i2c_simple_recv((unsigned char)touch_ic_device_addr,®,1,data,1); +int hal_gpio_i2c_open(const struct HAL_GPIO_I2C_CONFIG_T *cfg) { + static bool i2cInitDone = false; + int lock; - return result; + if (g_i2c_open == true) { + return -1; + } + lock = int_lock(); + g_i2c_open = 0; + int_unlock(lock); + + if (!i2cInitDone) { + hal_gpio_i2c_initialize(cfg); + i2cInitDone = 0; + } + + return 0; } +int hal_gpio_i2c_close(void) { + int lock; + if (g_i2c_open == false) { + return false; + } -int hal_gpio_i2c_open(const struct HAL_GPIO_I2C_CONFIG_T *cfg) -{ - static bool i2cInitDone = false; - int lock; + lock = int_lock(); + g_i2c_open = false; + int_unlock(lock); - if (g_i2c_open == true) - { - return -1; - } - lock = int_lock(); - g_i2c_open = 0; - int_unlock(lock); - - if (!i2cInitDone) - { - hal_gpio_i2c_initialize(cfg); - i2cInitDone = 0; - } - - return 0; + return 0; } -int hal_gpio_i2c_close(void) -{ - int lock; - - if (g_i2c_open == false) - { - return false; - } - - lock = int_lock(); - g_i2c_open = false; - int_unlock(lock); - - return 0; +uint32_t hal_gpio_i2c_send(uint32_t device_addr, const uint8_t *buf, + uint32_t reg_len, uint32_t value_len) { + return hal_gpio_i2c_simple_send(device_addr, buf, reg_len + value_len); } -uint32_t hal_gpio_i2c_send(uint32_t device_addr, const uint8_t *buf, uint32_t reg_len, uint32_t value_len) -{ - return hal_gpio_i2c_simple_send(device_addr, buf, reg_len + value_len); -} - -uint32_t hal_gpio_i2c_recv(uint32_t device_addr, uint8_t *buf, uint32_t reg_len, uint32_t value_len, uint8_t restart_after_write) -{ - return hal_gpio_i2c_simple_recv(device_addr, buf, reg_len, buf+reg_len, value_len); +uint32_t hal_gpio_i2c_recv(uint32_t device_addr, uint8_t *buf, uint32_t reg_len, + uint32_t value_len, uint8_t restart_after_write) { + return hal_gpio_i2c_simple_recv(device_addr, buf, reg_len, buf + reg_len, + value_len); } /* gpio iic end */ -int app_i2c_demo_init(void) -{ - static struct HAL_GPIO_I2C_CONFIG_T i2c_cfg={ - HAL_GPIO_PIN_P2_0, - HAL_GPIO_PIN_P2_1, - 0, - }; - hal_gpio_i2c_open(&i2c_cfg); - - return 0; -} +int app_i2c_demo_init(void) { + static struct HAL_GPIO_I2C_CONFIG_T i2c_cfg = { + HAL_GPIO_PIN_P2_0, + HAL_GPIO_PIN_P2_1, + 0, + }; + hal_gpio_i2c_open(&i2c_cfg); + return 0; +} diff --git a/platform/hal/hal_i2s.c b/platform/hal/hal_i2s.c index b09cf2a..c62558c 100644 --- a/platform/hal/hal_i2s.c +++ b/platform/hal/hal_i2s.c @@ -13,83 +13,83 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" -#include "plat_addr_map.h" -#include "reg_i2sip.h" -#include "hal_i2sip.h" #include "hal_i2s.h" #include "hal_cmu.h" +#include "hal_i2sip.h" #include "hal_iomux.h" +#include "plat_addr_map.h" +#include "plat_types.h" +#include "reg_i2sip.h" #if !defined(CHIP_BEST1000) && defined(I2S_MCLK_FROM_SPDIF) #include "hal_spdif.h" #endif -#include "hal_timer.h" -#include "hal_trace.h" #include "analog.h" #include "cmsis.h" +#include "hal_timer.h" +#include "hal_trace.h" // Trigger DMA request when TX-FIFO count <= threshold -#define HAL_I2S_TX_FIFO_TRIGGER_LEVEL (I2SIP_FIFO_DEPTH/2) +#define HAL_I2S_TX_FIFO_TRIGGER_LEVEL (I2SIP_FIFO_DEPTH / 2) // Trigger DMA request when RX-FIFO count >= threshold -#define HAL_I2S_RX_FIFO_TRIGGER_LEVEL (I2SIP_FIFO_DEPTH/2) +#define HAL_I2S_RX_FIFO_TRIGGER_LEVEL (I2SIP_FIFO_DEPTH / 2) #define HAL_I2S_YES 1 #define HAL_I2S_NO 0 #ifdef CHIP_BEST1000 -#define I2S_CMU_DIV CODEC_PLL_DIV -#define I2S_CHAN_NUM 1 +#define I2S_CMU_DIV CODEC_PLL_DIV +#define I2S_CHAN_NUM 1 #else -#define I2S_CMU_DIV CODEC_CMU_DIV -#define I2S_CHAN_NUM 4 +#define I2S_CMU_DIV CODEC_CMU_DIV +#define I2S_CHAN_NUM 4 #endif #ifndef I2S_MCLK_DIV -#define I2S_MCLK_DIV 2 +#define I2S_MCLK_DIV 2 #endif enum HAL_I2S_STATUS_T { - HAL_I2S_STATUS_NULL, - HAL_I2S_STATUS_OPENED, - HAL_I2S_STATUS_STARTED, + HAL_I2S_STATUS_NULL, + HAL_I2S_STATUS_OPENED, + HAL_I2S_STATUS_STARTED, }; -struct I2S_SAMPLE_RATE_T{ - enum AUD_SAMPRATE_T sample_rate; - uint32_t codec_freq; - uint8_t codec_div; - uint8_t cmu_div; +struct I2S_SAMPLE_RATE_T { + enum AUD_SAMPRATE_T sample_rate; + uint32_t codec_freq; + uint8_t codec_div; + uint8_t cmu_div; }; struct HAL_I2S_MOD_NAME_T { - enum HAL_CMU_MOD_ID_T mod; - enum HAL_CMU_MOD_ID_T apb; + enum HAL_CMU_MOD_ID_T mod; + enum HAL_CMU_MOD_ID_T apb; }; #ifndef FPGA -static const struct I2S_SAMPLE_RATE_T i2s_sample_rate[]={ - {AUD_SAMPRATE_8000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, - {AUD_SAMPRATE_16000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, - {AUD_SAMPRATE_32000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, - {AUD_SAMPRATE_44100, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, - {AUD_SAMPRATE_48000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, - {AUD_SAMPRATE_64000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, - {AUD_SAMPRATE_96000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, - {AUD_SAMPRATE_128000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, - {AUD_SAMPRATE_256000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, - {AUD_SAMPRATE_176400, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, - {AUD_SAMPRATE_192000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, - {AUD_SAMPRATE_352800, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, - {AUD_SAMPRATE_384000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, - {AUD_SAMPRATE_512000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, - {AUD_SAMPRATE_705600, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, - {AUD_SAMPRATE_768000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, - {AUD_SAMPRATE_1024000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, +static const struct I2S_SAMPLE_RATE_T i2s_sample_rate[] = { + {AUD_SAMPRATE_8000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, + {AUD_SAMPRATE_16000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, + {AUD_SAMPRATE_32000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, + {AUD_SAMPRATE_44100, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, + {AUD_SAMPRATE_48000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, + {AUD_SAMPRATE_64000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, + {AUD_SAMPRATE_96000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, + {AUD_SAMPRATE_128000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, + {AUD_SAMPRATE_256000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, + {AUD_SAMPRATE_176400, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, + {AUD_SAMPRATE_192000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, + {AUD_SAMPRATE_352800, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, + {AUD_SAMPRATE_384000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, + {AUD_SAMPRATE_512000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, + {AUD_SAMPRATE_705600, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, + {AUD_SAMPRATE_768000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, + {AUD_SAMPRATE_1024000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, I2S_CMU_DIV}, }; #endif -static const char * const invalid_id = "Invalid I2S ID: %d\n"; -//static const char * const invalid_ch = "Invalid I2S CH: %d\n"; +static const char *const invalid_id = "Invalid I2S ID: %d\n"; +// static const char * const invalid_ch = "Invalid I2S CH: %d\n"; static enum HAL_I2S_STATUS_T i2s_status[HAL_I2S_ID_QTY][AUD_STREAM_NUM]; static enum HAL_I2S_MODE_T i2s_mode[HAL_I2S_ID_QTY]; @@ -97,7 +97,8 @@ static bool i2s_dma[HAL_I2S_ID_QTY][AUD_STREAM_NUM]; static bool sync_start[HAL_I2S_ID_QTY][AUD_STREAM_NUM]; #ifdef CHIP_BEST2000 static uint8_t i2s_rx_line_map[HAL_I2S_ID_QTY]; -STATIC_ASSERT(sizeof(i2s_rx_line_map) * 8 >= I2S_CHAN_NUM, "i2s_rx_line_map size too small"); +STATIC_ASSERT(sizeof(i2s_rx_line_map) * 8 >= I2S_CHAN_NUM, + "i2s_rx_line_map size too small"); #endif static const struct HAL_I2S_MOD_NAME_T i2s_mod[HAL_I2S_ID_QTY] = { @@ -113,534 +114,548 @@ static const struct HAL_I2S_MOD_NAME_T i2s_mod[HAL_I2S_ID_QTY] = { #endif }; -static inline uint32_t _i2s_get_reg_base(enum HAL_I2S_ID_T id) -{ - ASSERT(id < HAL_I2S_ID_QTY, invalid_id, id); - switch(id) { - case HAL_I2S_ID_0: - return I2S0_BASE; - break; +static inline uint32_t _i2s_get_reg_base(enum HAL_I2S_ID_T id) { + ASSERT(id < HAL_I2S_ID_QTY, invalid_id, id); + switch (id) { + case HAL_I2S_ID_0: + return I2S0_BASE; + break; #if defined(CHIP_HAS_I2S) && (CHIP_HAS_I2S > 1) - case HAL_I2S_ID_1: - return I2S1_BASE; - break; + case HAL_I2S_ID_1: + return I2S1_BASE; + break; #endif - default: - break; - } - return 0; + default: + break; + } + return 0; } -static int hal_i2s_master_stream_closed(void) -{ - enum HAL_I2S_ID_T id; +static int hal_i2s_master_stream_closed(void) { + enum HAL_I2S_ID_T id; - for (id = HAL_I2S_ID_0; id < HAL_I2S_ID_QTY; id++) { - if (i2s_status[id][AUD_STREAM_PLAYBACK] != HAL_I2S_STATUS_NULL || - i2s_status[id][AUD_STREAM_CAPTURE] != HAL_I2S_STATUS_NULL) { - if (i2s_mode[id] == HAL_I2S_MODE_MASTER) { - return false; - } - } + for (id = HAL_I2S_ID_0; id < HAL_I2S_ID_QTY; id++) { + if (i2s_status[id][AUD_STREAM_PLAYBACK] != HAL_I2S_STATUS_NULL || + i2s_status[id][AUD_STREAM_CAPTURE] != HAL_I2S_STATUS_NULL) { + if (i2s_mode[id] == HAL_I2S_MODE_MASTER) { + return false; + } } + } - return true; + return true; } -int hal_i2s_open(enum HAL_I2S_ID_T id, enum AUD_STREAM_T stream, enum HAL_I2S_MODE_T mode) -{ - uint32_t reg_base; +int hal_i2s_open(enum HAL_I2S_ID_T id, enum AUD_STREAM_T stream, + enum HAL_I2S_MODE_T mode) { + uint32_t reg_base; - reg_base = _i2s_get_reg_base(id); + reg_base = _i2s_get_reg_base(id); - ASSERT(mode == HAL_I2S_MODE_MASTER || mode == HAL_I2S_MODE_SLAVE, - "Invalid I2S mode for stream %d: %d", stream, mode); - ASSERT(i2s_mode[id] == HAL_I2S_MODE_NULL || i2s_mode[id] == mode, - "Incompatible I2S mode for stream %d: prev=%d cur=%d", stream, i2s_mode[id], mode); + ASSERT(mode == HAL_I2S_MODE_MASTER || mode == HAL_I2S_MODE_SLAVE, + "Invalid I2S mode for stream %d: %d", stream, mode); + ASSERT(i2s_mode[id] == HAL_I2S_MODE_NULL || i2s_mode[id] == mode, + "Incompatible I2S mode for stream %d: prev=%d cur=%d", stream, + i2s_mode[id], mode); - if (i2s_status[id][stream] != HAL_I2S_STATUS_NULL) { - TRACE(2,"Invalid I2S opening status for stream %d: %d", stream, i2s_status[id][stream]); - return 1; - } + if (i2s_status[id][stream] != HAL_I2S_STATUS_NULL) { + TRACE(2, "Invalid I2S opening status for stream %d: %d", stream, + i2s_status[id][stream]); + return 1; + } - if (i2s_status[id][AUD_STREAM_PLAYBACK] == HAL_I2S_STATUS_NULL && - i2s_status[id][AUD_STREAM_CAPTURE] == HAL_I2S_STATUS_NULL) { - if (mode == HAL_I2S_MODE_MASTER) { + if (i2s_status[id][AUD_STREAM_PLAYBACK] == HAL_I2S_STATUS_NULL && + i2s_status[id][AUD_STREAM_CAPTURE] == HAL_I2S_STATUS_NULL) { + if (mode == HAL_I2S_MODE_MASTER) { #ifndef SIMU - if (hal_i2s_master_stream_closed()) { - analog_aud_pll_open(ANA_AUD_PLL_USER_I2S); - } + if (hal_i2s_master_stream_closed()) { + analog_aud_pll_open(ANA_AUD_PLL_USER_I2S); + } #endif - hal_cmu_i2s_clock_enable(id); - } + hal_cmu_i2s_clock_enable(id); + } - if (id == HAL_I2S_ID_0) { - hal_iomux_set_i2s0(); + if (id == HAL_I2S_ID_0) { + hal_iomux_set_i2s0(); #if defined(CHIP_HAS_I2S) && (CHIP_HAS_I2S > 1) - } else { - hal_iomux_set_i2s1(); + } else { + hal_iomux_set_i2s1(); #endif - } + } - hal_cmu_clock_enable(i2s_mod[id].mod); - hal_cmu_clock_enable(i2s_mod[id].apb); - hal_cmu_reset_clear(i2s_mod[id].mod); - hal_cmu_reset_clear(i2s_mod[id].apb); - i2sip_w_enable_i2sip(reg_base, HAL_I2S_YES); + hal_cmu_clock_enable(i2s_mod[id].mod); + hal_cmu_clock_enable(i2s_mod[id].apb); + hal_cmu_reset_clear(i2s_mod[id].mod); + hal_cmu_reset_clear(i2s_mod[id].apb); + i2sip_w_enable_i2sip(reg_base, HAL_I2S_YES); - for (int i = 0; i < I2S_CHAN_NUM; i++) { - i2sip_w_enable_rx_channel(reg_base, i, HAL_I2S_NO); - i2sip_w_enable_tx_channel(reg_base, i, HAL_I2S_NO); - i2sip_w_rx_fifo_reset(reg_base, i); - i2sip_w_tx_fifo_reset(reg_base, i); - } + for (int i = 0; i < I2S_CHAN_NUM; i++) { + i2sip_w_enable_rx_channel(reg_base, i, HAL_I2S_NO); + i2sip_w_enable_tx_channel(reg_base, i, HAL_I2S_NO); + i2sip_w_rx_fifo_reset(reg_base, i); + i2sip_w_tx_fifo_reset(reg_base, i); + } #ifndef CHIP_BEST1000 - if (mode == HAL_I2S_MODE_MASTER) { - i2sip_w_enable_slave_mode(reg_base, HAL_I2S_NO); - } else { - i2sip_w_enable_slave_mode(reg_base, HAL_I2S_YES); - } + if (mode == HAL_I2S_MODE_MASTER) { + i2sip_w_enable_slave_mode(reg_base, HAL_I2S_NO); + } else { + i2sip_w_enable_slave_mode(reg_base, HAL_I2S_YES); + } #endif - if (mode == HAL_I2S_MODE_MASTER) { - hal_cmu_i2s_set_master_mode(id); - } else { - hal_cmu_i2s_set_slave_mode(id); - } - - i2s_mode[id] = mode; + if (mode == HAL_I2S_MODE_MASTER) { + hal_cmu_i2s_set_master_mode(id); + } else { + hal_cmu_i2s_set_slave_mode(id); } - i2s_dma[id][stream] = false; - i2s_status[id][stream] = HAL_I2S_STATUS_OPENED; + i2s_mode[id] = mode; + } - return 0; + i2s_dma[id][stream] = false; + i2s_status[id][stream] = HAL_I2S_STATUS_OPENED; + + return 0; } -int hal_i2s_close(enum HAL_I2S_ID_T id, enum AUD_STREAM_T stream) -{ - uint32_t reg_base; +int hal_i2s_close(enum HAL_I2S_ID_T id, enum AUD_STREAM_T stream) { + uint32_t reg_base; - reg_base = _i2s_get_reg_base(id); + reg_base = _i2s_get_reg_base(id); - if (i2s_status[id][stream] != HAL_I2S_STATUS_OPENED) { - TRACE(2,"Invalid I2S closing status for stream %d: %d", stream, i2s_status[id][stream]); - return 1; - } + if (i2s_status[id][stream] != HAL_I2S_STATUS_OPENED) { + TRACE(2, "Invalid I2S closing status for stream %d: %d", stream, + i2s_status[id][stream]); + return 1; + } - i2s_status[id][stream] = HAL_I2S_STATUS_NULL; + i2s_status[id][stream] = HAL_I2S_STATUS_NULL; - if (i2s_status[id][AUD_STREAM_PLAYBACK] == HAL_I2S_STATUS_NULL && - i2s_status[id][AUD_STREAM_CAPTURE] == HAL_I2S_STATUS_NULL) { - i2sip_w_enable_i2sip(reg_base, HAL_I2S_NO); - hal_cmu_reset_set(i2s_mod[id].apb); - hal_cmu_reset_set(i2s_mod[id].mod); - hal_cmu_clock_disable(i2s_mod[id].apb); - hal_cmu_clock_disable(i2s_mod[id].mod); + if (i2s_status[id][AUD_STREAM_PLAYBACK] == HAL_I2S_STATUS_NULL && + i2s_status[id][AUD_STREAM_CAPTURE] == HAL_I2S_STATUS_NULL) { + i2sip_w_enable_i2sip(reg_base, HAL_I2S_NO); + hal_cmu_reset_set(i2s_mod[id].apb); + hal_cmu_reset_set(i2s_mod[id].mod); + hal_cmu_clock_disable(i2s_mod[id].apb); + hal_cmu_clock_disable(i2s_mod[id].mod); - if (i2s_mode[id] == HAL_I2S_MODE_MASTER) { - hal_cmu_i2s_clock_disable(id); - if (hal_i2s_master_stream_closed()) { + if (i2s_mode[id] == HAL_I2S_MODE_MASTER) { + hal_cmu_i2s_clock_disable(id); + if (hal_i2s_master_stream_closed()) { #if !defined(CHIP_BEST1000) && defined(I2S_MCLK_FROM_SPDIF) - hal_cmu_clock_out_disable(); - hal_spdif_clock_out_disable(HAL_SPDIF_ID_0); + hal_cmu_clock_out_disable(); + hal_spdif_clock_out_disable(HAL_SPDIF_ID_0); #endif #ifndef SIMU - analog_aud_pll_close(ANA_AUD_PLL_USER_I2S); + analog_aud_pll_close(ANA_AUD_PLL_USER_I2S); #endif - } - } - - i2s_mode[id] = HAL_I2S_MODE_NULL; + } } - return 0; + i2s_mode[id] = HAL_I2S_MODE_NULL; + } + + return 0; } #ifdef AF_ADC_I2S_SYNC static bool _hal_i2s_enable_delay[HAL_I2S_ID_QTY]; -void hal_i2s_enable_delay(enum HAL_I2S_ID_T id) -{ - _hal_i2s_enable_delay[id] = true; +void hal_i2s_enable_delay(enum HAL_I2S_ID_T id) { + _hal_i2s_enable_delay[id] = true; } -void hal_i2s_disable_delay(enum HAL_I2S_ID_T id) -{ - _hal_i2s_enable_delay[id] = false; +void hal_i2s_disable_delay(enum HAL_I2S_ID_T id) { + _hal_i2s_enable_delay[id] = false; } -void hal_i2s_enable(enum HAL_I2S_ID_T id) -{ - i2sip_w_enable_clk_gen(_i2s_get_reg_base(id), HAL_I2S_YES); +void hal_i2s_enable(enum HAL_I2S_ID_T id) { + i2sip_w_enable_clk_gen(_i2s_get_reg_base(id), HAL_I2S_YES); } #endif -int hal_i2s_start_stream(enum HAL_I2S_ID_T id, enum AUD_STREAM_T stream) -{ - uint32_t reg_base; - uint32_t lock; - bool xfer_en[AUD_STREAM_NUM]; +int hal_i2s_start_stream(enum HAL_I2S_ID_T id, enum AUD_STREAM_T stream) { + uint32_t reg_base; + uint32_t lock; + bool xfer_en[AUD_STREAM_NUM]; - reg_base = _i2s_get_reg_base(id); + reg_base = _i2s_get_reg_base(id); - if (i2s_status[id][stream] != HAL_I2S_STATUS_OPENED) { - TRACE(2,"Invalid I2S starting status for stream %d: %d", stream, i2s_status[id][stream]); - return 1; - } + if (i2s_status[id][stream] != HAL_I2S_STATUS_OPENED) { + TRACE(2, "Invalid I2S starting status for stream %d: %d", stream, + i2s_status[id][stream]); + return 1; + } - if (i2s_mode[id] == HAL_I2S_MODE_SLAVE && sync_start[id][stream]) { - xfer_en[stream] = false; - xfer_en[!stream] = false; + if (i2s_mode[id] == HAL_I2S_MODE_SLAVE && sync_start[id][stream]) { + xfer_en[stream] = false; + xfer_en[!stream] = false; + } else { + xfer_en[stream] = true; + if (i2s_mode[id] == HAL_I2S_MODE_SLAVE && + i2s_status[id][!stream] == HAL_I2S_STATUS_STARTED && + sync_start[id][!stream]) { + xfer_en[!stream] = true; } else { - xfer_en[stream] = true; - if (i2s_mode[id] == HAL_I2S_MODE_SLAVE && - i2s_status[id][!stream] == HAL_I2S_STATUS_STARTED && - sync_start[id][!stream]) { - xfer_en[!stream] = true; - } else { - xfer_en[!stream] = false; - } + xfer_en[!stream] = false; } + } - if (stream == AUD_STREAM_PLAYBACK) { - lock = int_lock(); - i2sip_w_enable_tx_channel(reg_base, 0, HAL_I2S_YES); - if (xfer_en[stream]) { - i2sip_w_enable_tx_block(reg_base, HAL_I2S_YES); - if (i2s_dma[id][stream]) { - i2sip_w_enable_tx_dma(reg_base, HAL_I2S_YES); - } - } - if (xfer_en[!stream]) { - i2sip_w_enable_rx_block(reg_base, HAL_I2S_YES); - } - int_unlock(lock); - if (i2s_dma[id][stream] && i2s_mode[id] == HAL_I2S_MODE_MASTER) { - // Delay a little time for DMA to fill the TX FIFO before sending (enabling clk gen) - for (volatile int i = 0; i < 50; i++); - } - } else { - if (i2s_dma[id][stream]) { - i2sip_w_enable_rx_dma(reg_base, HAL_I2S_YES); - } + if (stream == AUD_STREAM_PLAYBACK) { + lock = int_lock(); + i2sip_w_enable_tx_channel(reg_base, 0, HAL_I2S_YES); + if (xfer_en[stream]) { + i2sip_w_enable_tx_block(reg_base, HAL_I2S_YES); + if (i2s_dma[id][stream]) { + i2sip_w_enable_tx_dma(reg_base, HAL_I2S_YES); + } + } + if (xfer_en[!stream]) { + i2sip_w_enable_rx_block(reg_base, HAL_I2S_YES); + } + int_unlock(lock); + if (i2s_dma[id][stream] && i2s_mode[id] == HAL_I2S_MODE_MASTER) { + // Delay a little time for DMA to fill the TX FIFO before sending + // (enabling clk gen) + for (volatile int i = 0; i < 50; i++) + ; + } + } else { + if (i2s_dma[id][stream]) { + i2sip_w_enable_rx_dma(reg_base, HAL_I2S_YES); + } #ifdef CHIP_BEST2000 - int i; - for (i = 0; i < I2S_CHAN_NUM; i++) { - if (i2s_rx_line_map[id] & (1 << i)) { - i2sip_w_enable_rx_channel(reg_base, i, HAL_I2S_YES); - } - } -#else - i2sip_w_enable_rx_channel(reg_base, 0, HAL_I2S_YES); -#endif - lock = int_lock(); - if (xfer_en[stream]) { - i2sip_w_enable_rx_block(reg_base, HAL_I2S_YES); - } - if (xfer_en[!stream]) { - i2sip_w_enable_tx_block(reg_base, HAL_I2S_YES); - if (i2s_dma[id][!stream]) { - i2sip_w_enable_tx_dma(reg_base, HAL_I2S_YES); - } - } - int_unlock(lock); + int i; + for (i = 0; i < I2S_CHAN_NUM; i++) { + if (i2s_rx_line_map[id] & (1 << i)) { + i2sip_w_enable_rx_channel(reg_base, i, HAL_I2S_YES); + } } +#else + i2sip_w_enable_rx_channel(reg_base, 0, HAL_I2S_YES); +#endif + lock = int_lock(); + if (xfer_en[stream]) { + i2sip_w_enable_rx_block(reg_base, HAL_I2S_YES); + } + if (xfer_en[!stream]) { + i2sip_w_enable_tx_block(reg_base, HAL_I2S_YES); + if (i2s_dma[id][!stream]) { + i2sip_w_enable_tx_dma(reg_base, HAL_I2S_YES); + } + } + int_unlock(lock); + } - if (i2s_mode[id] == HAL_I2S_MODE_MASTER && !sync_start[id][stream]) { - if (i2sip_r_clk_gen_enabled(reg_base) == 0) { - hal_cmu_i2s_clock_out_enable(id); + if (i2s_mode[id] == HAL_I2S_MODE_MASTER && !sync_start[id][stream]) { + if (i2sip_r_clk_gen_enabled(reg_base) == 0) { + hal_cmu_i2s_clock_out_enable(id); #ifdef AF_ADC_I2S_SYNC - if (_hal_i2s_enable_delay[id]) { - _hal_i2s_enable_delay[id] = false; - } else { - hal_i2s_enable(id); - } + if (_hal_i2s_enable_delay[id]) { + _hal_i2s_enable_delay[id] = false; + } else { + hal_i2s_enable(id); + } #else - i2sip_w_enable_clk_gen(reg_base, HAL_I2S_YES); + i2sip_w_enable_clk_gen(reg_base, HAL_I2S_YES); #endif - } } + } - i2s_status[id][stream] = HAL_I2S_STATUS_STARTED; + i2s_status[id][stream] = HAL_I2S_STATUS_STARTED; - return 0; + return 0; } -int hal_i2s_stop_stream(enum HAL_I2S_ID_T id, enum AUD_STREAM_T stream) -{ - uint32_t reg_base; +int hal_i2s_stop_stream(enum HAL_I2S_ID_T id, enum AUD_STREAM_T stream) { + uint32_t reg_base; - reg_base = _i2s_get_reg_base(id); + reg_base = _i2s_get_reg_base(id); - if (i2s_status[id][stream] != HAL_I2S_STATUS_STARTED) { - TRACE(2,"Invalid I2S stopping status for stream %d: %d", stream, i2s_status[id][stream]); - return 1; - } + if (i2s_status[id][stream] != HAL_I2S_STATUS_STARTED) { + TRACE(2, "Invalid I2S stopping status for stream %d: %d", stream, + i2s_status[id][stream]); + return 1; + } - i2s_status[id][stream] = HAL_I2S_STATUS_OPENED; - - if (i2s_status[id][AUD_STREAM_PLAYBACK] != HAL_I2S_STATUS_STARTED && - i2s_status[id][AUD_STREAM_CAPTURE] != HAL_I2S_STATUS_STARTED) { - if (i2s_mode[id] == HAL_I2S_MODE_MASTER) { - hal_cmu_i2s_clock_out_disable(id); - i2sip_w_enable_clk_gen(reg_base, HAL_I2S_NO); -#ifdef AF_ADC_I2S_SYNC - _hal_i2s_enable_delay[id] = false; -#endif - } - } - - if (stream == AUD_STREAM_PLAYBACK) { - i2sip_w_enable_tx_block(reg_base, HAL_I2S_NO); - i2sip_w_enable_tx_channel(reg_base, 0, HAL_I2S_NO); - i2sip_w_enable_tx_dma(reg_base, HAL_I2S_NO); - i2sip_w_tx_fifo_reset(reg_base, 0); - } else { - i2sip_w_enable_rx_block(reg_base, HAL_I2S_NO); - i2sip_w_enable_rx_dma(reg_base, HAL_I2S_NO); -#ifdef CHIP_BEST1000 - i2sip_w_enable_rx_channel(reg_base, 0, HAL_I2S_NO); - i2sip_w_rx_fifo_reset(reg_base, 0); -#else - int i; - for (i = 0; i < I2S_CHAN_NUM; i++) { - i2sip_w_enable_rx_channel(reg_base, i, HAL_I2S_NO); - i2sip_w_rx_fifo_reset(reg_base, i); - } -#endif - } - - return 0; -} - -int hal_i2s_setup_stream(enum HAL_I2S_ID_T id, enum AUD_STREAM_T stream, const struct HAL_I2S_CONFIG_T *cfg) -{ - uint32_t reg_base; - uint32_t div = 0; - uint8_t cycles; - uint8_t resolution = 0, word_sclk = 0; - bool valid; - int POSSIBLY_UNUSED i; - - reg_base = _i2s_get_reg_base(id); - - if (i2s_status[id][stream] != HAL_I2S_STATUS_OPENED) { - TRACE(2,"Invalid I2S setup status for stream %d: %d", stream, i2s_status[id][stream]); - return 1; - } - - cycles = cfg->cycles; - if (cycles == 0) { - if (cfg->bits <= AUD_BITS_16) { - cycles = 16; - } else { - cycles = 32; - } - } - ASSERT(cycles >= cfg->bits, "I2S cycles (%u) should >= bits (%u)", cycles, cfg->bits); - - switch (cycles) - { - case 16: - word_sclk = I2SIP_CLK_CFG_WSS_VAL_16CYCLE; - break; - case 24: - word_sclk = I2SIP_CLK_CFG_WSS_VAL_24CYCLE; - break; - case 32: - word_sclk = I2SIP_CLK_CFG_WSS_VAL_32CYCLE; - break; - default: - ASSERT(false, "Bad I2S cycles (%u)", cycles); - return 1; - } - - switch (cfg->bits) - { - case AUD_BITS_8: - resolution = I2SIP_CFG_WLEN_VAL_IGNORE; - break; - case AUD_BITS_12: - resolution = I2SIP_CFG_WLEN_VAL_12BIT; - break; - case AUD_BITS_16: - resolution = I2SIP_CFG_WLEN_VAL_16BIT; - break; - case AUD_BITS_20: - resolution = I2SIP_CFG_WLEN_VAL_20BIT; - break; - case AUD_BITS_24: - resolution = I2SIP_CFG_WLEN_VAL_24BIT; - break; - case AUD_BITS_32: - resolution = I2SIP_CFG_WLEN_VAL_32BIT; - break; - default: - ASSERT(false, "Bad I2S bits (%u)", cfg->bits); - return 1; - } - - /* word clock width : how many sclk work sclk count*/ - /* sclk gate in word clock : how many sclk gate : fixed no gate */ - i2sip_w_clk_cfg_reg(reg_base, (word_sclk<channel_num == AUD_CHANNEL_NUM_2); - } else { - valid = (cfg->channel_num == AUD_CHANNEL_NUM_2 || cfg->channel_num == AUD_CHANNEL_NUM_4 || - cfg->channel_num == AUD_CHANNEL_NUM_6 || cfg->channel_num == AUD_CHANNEL_NUM_8); - } -#else - valid = (cfg->channel_num == AUD_CHANNEL_NUM_2); -#endif - ASSERT(valid, "[%s] Stream %d Channel number(%d) error", __func__, stream, cfg->channel_num); + i2s_status[id][stream] = HAL_I2S_STATUS_OPENED; + if (i2s_status[id][AUD_STREAM_PLAYBACK] != HAL_I2S_STATUS_STARTED && + i2s_status[id][AUD_STREAM_CAPTURE] != HAL_I2S_STATUS_STARTED) { if (i2s_mode[id] == HAL_I2S_MODE_MASTER) { + hal_cmu_i2s_clock_out_disable(id); + i2sip_w_enable_clk_gen(reg_base, HAL_I2S_NO); +#ifdef AF_ADC_I2S_SYNC + _hal_i2s_enable_delay[id] = false; +#endif + } + } + + if (stream == AUD_STREAM_PLAYBACK) { + i2sip_w_enable_tx_block(reg_base, HAL_I2S_NO); + i2sip_w_enable_tx_channel(reg_base, 0, HAL_I2S_NO); + i2sip_w_enable_tx_dma(reg_base, HAL_I2S_NO); + i2sip_w_tx_fifo_reset(reg_base, 0); + } else { + i2sip_w_enable_rx_block(reg_base, HAL_I2S_NO); + i2sip_w_enable_rx_dma(reg_base, HAL_I2S_NO); +#ifdef CHIP_BEST1000 + i2sip_w_enable_rx_channel(reg_base, 0, HAL_I2S_NO); + i2sip_w_rx_fifo_reset(reg_base, 0); +#else + int i; + for (i = 0; i < I2S_CHAN_NUM; i++) { + i2sip_w_enable_rx_channel(reg_base, i, HAL_I2S_NO); + i2sip_w_rx_fifo_reset(reg_base, i); + } +#endif + } + + return 0; +} + +int hal_i2s_setup_stream(enum HAL_I2S_ID_T id, enum AUD_STREAM_T stream, + const struct HAL_I2S_CONFIG_T *cfg) { + uint32_t reg_base; + uint32_t div = 0; + uint8_t cycles; + uint8_t resolution = 0, word_sclk = 0; + bool valid; + int POSSIBLY_UNUSED i; + + reg_base = _i2s_get_reg_base(id); + + if (i2s_status[id][stream] != HAL_I2S_STATUS_OPENED) { + TRACE(2, "Invalid I2S setup status for stream %d: %d", stream, + i2s_status[id][stream]); + return 1; + } + + cycles = cfg->cycles; + if (cycles == 0) { + if (cfg->bits <= AUD_BITS_16) { + cycles = 16; + } else { + cycles = 32; + } + } + ASSERT(cycles >= cfg->bits, "I2S cycles (%u) should >= bits (%u)", cycles, + cfg->bits); + + switch (cycles) { + case 16: + word_sclk = I2SIP_CLK_CFG_WSS_VAL_16CYCLE; + break; + case 24: + word_sclk = I2SIP_CLK_CFG_WSS_VAL_24CYCLE; + break; + case 32: + word_sclk = I2SIP_CLK_CFG_WSS_VAL_32CYCLE; + break; + default: + ASSERT(false, "Bad I2S cycles (%u)", cycles); + return 1; + } + + switch (cfg->bits) { + case AUD_BITS_8: + resolution = I2SIP_CFG_WLEN_VAL_IGNORE; + break; + case AUD_BITS_12: + resolution = I2SIP_CFG_WLEN_VAL_12BIT; + break; + case AUD_BITS_16: + resolution = I2SIP_CFG_WLEN_VAL_16BIT; + break; + case AUD_BITS_20: + resolution = I2SIP_CFG_WLEN_VAL_20BIT; + break; + case AUD_BITS_24: + resolution = I2SIP_CFG_WLEN_VAL_24BIT; + break; + case AUD_BITS_32: + resolution = I2SIP_CFG_WLEN_VAL_32BIT; + break; + default: + ASSERT(false, "Bad I2S bits (%u)", cfg->bits); + return 1; + } + + /* word clock width : how many sclk work sclk count*/ + /* sclk gate in word clock : how many sclk gate : fixed no gate */ + i2sip_w_clk_cfg_reg(reg_base, (word_sclk << I2SIP_CLK_CFG_WSS_SHIFT) | + (I2SIP_CLK_CFG_SCLK_GATE_VAL_NO_GATE + << I2SIP_CLK_CFG_SCLK_GATE_SHIFT)); + +#ifdef CHIP_BEST2000 + if (stream == AUD_STREAM_PLAYBACK) { + valid = (cfg->channel_num == AUD_CHANNEL_NUM_2); + } else { + valid = (cfg->channel_num == AUD_CHANNEL_NUM_2 || + cfg->channel_num == AUD_CHANNEL_NUM_4 || + cfg->channel_num == AUD_CHANNEL_NUM_6 || + cfg->channel_num == AUD_CHANNEL_NUM_8); + } +#else + valid = (cfg->channel_num == AUD_CHANNEL_NUM_2); +#endif + ASSERT(valid, "[%s] Stream %d Channel number(%d) error", __func__, stream, + cfg->channel_num); + + if (i2s_mode[id] == HAL_I2S_MODE_MASTER) { #ifdef FPGA - uint32_t sclk; + uint32_t sclk; - sclk = cfg->sample_rate * cycles * AUD_CHANNEL_NUM_2; + sclk = cfg->sample_rate * cycles * AUD_CHANNEL_NUM_2; -#define I2S_CLOCK_SOURCE 22579200 //44100*512 - div = I2S_CLOCK_SOURCE/sclk - 1; +#define I2S_CLOCK_SOURCE 22579200 // 44100*512 + div = I2S_CLOCK_SOURCE / sclk - 1; #undef I2S_CLOCK_SOURCE - TRACE(1,"div = %x",div); + TRACE(1, "div = %x", div); #else - uint32_t i2s_clock; - uint32_t bit_rate; + uint32_t i2s_clock; + uint32_t bit_rate; - for (i = 0; i < ARRAY_SIZE(i2s_sample_rate); i++) - { - if (i2s_sample_rate[i].sample_rate == cfg->sample_rate) - { - break; - } - } - ASSERT(i < ARRAY_SIZE(i2s_sample_rate), "%s: Invalid i2s sample rate: %d", __func__, cfg->sample_rate); + for (i = 0; i < ARRAY_SIZE(i2s_sample_rate); i++) { + if (i2s_sample_rate[i].sample_rate == cfg->sample_rate) { + break; + } + } + ASSERT(i < ARRAY_SIZE(i2s_sample_rate), "%s: Invalid i2s sample rate: %d", + __func__, cfg->sample_rate); - TRACE(3,"[%s] stream=%d sample_rate=%d", __func__, stream, cfg->sample_rate); + TRACE(3, "[%s] stream=%d sample_rate=%d", __func__, stream, + cfg->sample_rate); - ASSERT(i2s_sample_rate[i].codec_div / i2s_sample_rate[i].cmu_div * i2s_sample_rate[i].cmu_div == i2s_sample_rate[i].codec_div, - "%s: Invalid codec div for rate %u: codec_div=%u cmu_div=%u", __func__, cfg->sample_rate, - i2s_sample_rate[i].codec_div, i2s_sample_rate[i].cmu_div); + ASSERT(i2s_sample_rate[i].codec_div / i2s_sample_rate[i].cmu_div * + i2s_sample_rate[i].cmu_div == + i2s_sample_rate[i].codec_div, + "%s: Invalid codec div for rate %u: codec_div=%u cmu_div=%u", + __func__, cfg->sample_rate, i2s_sample_rate[i].codec_div, + i2s_sample_rate[i].cmu_div); #ifndef SIMU - analog_aud_freq_pll_config(i2s_sample_rate[i].codec_freq, i2s_sample_rate[i].codec_div); + analog_aud_freq_pll_config(i2s_sample_rate[i].codec_freq, + i2s_sample_rate[i].codec_div); #ifdef CHIP_BEST2000 - analog_aud_pll_set_dig_div(i2s_sample_rate[i].codec_div / i2s_sample_rate[i].cmu_div); + analog_aud_pll_set_dig_div(i2s_sample_rate[i].codec_div / + i2s_sample_rate[i].cmu_div); #endif #endif - i2s_clock = i2s_sample_rate[i].codec_freq * i2s_sample_rate[i].cmu_div; - bit_rate = i2s_sample_rate[i].sample_rate * AUD_CHANNEL_NUM_2 * cycles; - div = i2s_clock / bit_rate; + i2s_clock = i2s_sample_rate[i].codec_freq * i2s_sample_rate[i].cmu_div; + bit_rate = i2s_sample_rate[i].sample_rate * AUD_CHANNEL_NUM_2 * cycles; + div = i2s_clock / bit_rate; - ASSERT(i2s_clock == bit_rate * div, "%s: Bad stream cfg (bad cycles?): i2s_clock=%u bit_rate=%u cycles=%u", - __func__, i2s_clock, bit_rate, cycles); + ASSERT( + i2s_clock == bit_rate * div, + "%s: Bad stream cfg (bad cycles?): i2s_clock=%u bit_rate=%u cycles=%u", + __func__, i2s_clock, bit_rate, cycles); #if !defined(CHIP_BEST1000) && defined(I2S_MCLK_FROM_SPDIF) #ifdef I2S_MCLK_PIN - hal_iomux_set_i2s_mclk(); - hal_cmu_i2s_mclk_enable(HAL_CMU_I2S_MCLK_PLLSPDIF0); + hal_iomux_set_i2s_mclk(); + hal_cmu_i2s_mclk_enable(HAL_CMU_I2S_MCLK_PLLSPDIF0); #else - hal_iomux_set_clock_out(); - hal_cmu_clock_out_enable(HAL_CMU_CLOCK_OUT_MCU_SPDIF0); + hal_iomux_set_clock_out(); + hal_cmu_clock_out_enable(HAL_CMU_CLOCK_OUT_MCU_SPDIF0); #endif - // By default MCLK is half of (CODEC_FREQ_24P576M or CODEC_FREQ_22P5792M) - hal_spdif_clock_out_enable(HAL_SPDIF_ID_0, i2s_sample_rate[i].cmu_div * I2S_MCLK_DIV); + // By default MCLK is half of (CODEC_FREQ_24P576M or CODEC_FREQ_22P5792M) + hal_spdif_clock_out_enable(HAL_SPDIF_ID_0, + i2s_sample_rate[i].cmu_div * I2S_MCLK_DIV); #endif #endif - hal_cmu_i2s_set_div(id, div); - } + hal_cmu_i2s_set_div(id, div); + } - if ((stream == AUD_STREAM_PLAYBACK && i2s_status[id][AUD_STREAM_CAPTURE] == HAL_I2S_STATUS_NULL) || - (stream == AUD_STREAM_CAPTURE && i2s_status[id][AUD_STREAM_PLAYBACK] == HAL_I2S_STATUS_NULL)) { - hal_cmu_reset_pulse(i2s_mod[id].mod); - } + if ((stream == AUD_STREAM_PLAYBACK && + i2s_status[id][AUD_STREAM_CAPTURE] == HAL_I2S_STATUS_NULL) || + (stream == AUD_STREAM_CAPTURE && + i2s_status[id][AUD_STREAM_PLAYBACK] == HAL_I2S_STATUS_NULL)) { + hal_cmu_reset_pulse(i2s_mod[id].mod); + } - i2s_dma[id][stream] = cfg->use_dma; - sync_start[id][stream] = cfg->sync_start; + i2s_dma[id][stream] = cfg->use_dma; + sync_start[id][stream] = cfg->sync_start; - if (stream == AUD_STREAM_PLAYBACK) - { - /* resolution : valid bit width */ - i2sip_w_tx_resolution(reg_base, 0, resolution); + if (stream == AUD_STREAM_PLAYBACK) { + /* resolution : valid bit width */ + i2sip_w_tx_resolution(reg_base, 0, resolution); - /* fifo level to trigger empty interrupt or dma req */ - i2sip_w_tx_fifo_threshold(reg_base, 0, HAL_I2S_TX_FIFO_TRIGGER_LEVEL); - } - else - { + /* fifo level to trigger empty interrupt or dma req */ + i2sip_w_tx_fifo_threshold(reg_base, 0, HAL_I2S_TX_FIFO_TRIGGER_LEVEL); + } else { #ifdef CHIP_BEST2000 - uint32_t ch; - uint32_t cnt = 0; + uint32_t ch; + uint32_t cnt = 0; - i2s_rx_line_map[id] = 0; + i2s_rx_line_map[id] = 0; - for (i = 0; i < I2S_CHAN_NUM; i++) { - ch = (cfg->channel_map >> (i * 2)) & 3; - ASSERT(ch == 0 || ch == 3, "[%s] Stream %d Bad Chan Map 0x%04X", __func__, stream, cfg->channel_map); - if (ch == 3) { - i2s_rx_line_map[id] |= (1 << i); - cnt += 2; - } - } - ASSERT(cnt == cfg->channel_num, "[%s] Stream %d Unmatched Chan Num (%u) and Map (0x%04X)", - __func__, stream, cfg->channel_num, cfg->channel_map); + for (i = 0; i < I2S_CHAN_NUM; i++) { + ch = (cfg->channel_map >> (i * 2)) & 3; + ASSERT(ch == 0 || ch == 3, "[%s] Stream %d Bad Chan Map 0x%04X", __func__, + stream, cfg->channel_map); + if (ch == 3) { + i2s_rx_line_map[id] |= (1 << i); + cnt += 2; + } + } + ASSERT(cnt == cfg->channel_num, + "[%s] Stream %d Unmatched Chan Num (%u) and Map (0x%04X)", __func__, + stream, cfg->channel_num, cfg->channel_map); - if (cfg->chan_sep_buf) { - i2sip_w_rx_dma_blk_size(reg_base, HAL_I2S_RX_FIFO_TRIGGER_LEVEL); - i2sp_w_enable_rx_dma_block(reg_base, HAL_I2S_YES); - } else { - i2sp_w_enable_rx_dma_block(reg_base, HAL_I2S_NO); - } + if (cfg->chan_sep_buf) { + i2sip_w_rx_dma_blk_size(reg_base, HAL_I2S_RX_FIFO_TRIGGER_LEVEL); + i2sp_w_enable_rx_dma_block(reg_base, HAL_I2S_YES); + } else { + i2sp_w_enable_rx_dma_block(reg_base, HAL_I2S_NO); + } - for (i = 0; i < I2S_CHAN_NUM; i++) { - if (i2s_rx_line_map[id] & (1 << i)) { - i2sip_w_rx_resolution(reg_base, i, resolution); - i2sip_w_rx_fifo_threshold(reg_base, i, HAL_I2S_RX_FIFO_TRIGGER_LEVEL); - } - } + for (i = 0; i < I2S_CHAN_NUM; i++) { + if (i2s_rx_line_map[id] & (1 << i)) { + i2sip_w_rx_resolution(reg_base, i, resolution); + i2sip_w_rx_fifo_threshold(reg_base, i, HAL_I2S_RX_FIFO_TRIGGER_LEVEL); + } + } #else - /* resolution : valid bit width */ - i2sip_w_rx_resolution(reg_base, 0, resolution); + /* resolution : valid bit width */ + i2sip_w_rx_resolution(reg_base, 0, resolution); - /* fifo level to trigger empty interrupt or dma req */ - i2sip_w_rx_fifo_threshold(reg_base, 0, HAL_I2S_RX_FIFO_TRIGGER_LEVEL); + /* fifo level to trigger empty interrupt or dma req */ + i2sip_w_rx_fifo_threshold(reg_base, 0, HAL_I2S_RX_FIFO_TRIGGER_LEVEL); #endif - } + } - return 0; + return 0; } -int hal_i2s_send(enum HAL_I2S_ID_T id, const uint8_t *value, uint32_t value_len) -{ - uint32_t i = 0; - uint32_t reg_base; +int hal_i2s_send(enum HAL_I2S_ID_T id, const uint8_t *value, + uint32_t value_len) { + uint32_t i = 0; + uint32_t reg_base; - reg_base = _i2s_get_reg_base(id); + reg_base = _i2s_get_reg_base(id); - for (i = 0; i < value_len; i += 4) { - while (!(i2sip_r_int_status(reg_base, 0) & I2SIP_INT_STATUS_TX_FIFO_EMPTY_MASK)); + for (i = 0; i < value_len; i += 4) { + while (!(i2sip_r_int_status(reg_base, 0) & + I2SIP_INT_STATUS_TX_FIFO_EMPTY_MASK)) + ; - i2sip_w_tx_left_fifo(reg_base, 0, value[i+1]<<8 | value[i]); - i2sip_w_tx_right_fifo(reg_base, 0, value[i+3]<<8 | value[i+2]); - } + i2sip_w_tx_left_fifo(reg_base, 0, value[i + 1] << 8 | value[i]); + i2sip_w_tx_right_fifo(reg_base, 0, value[i + 3] << 8 | value[i + 2]); + } - return 0; + return 0; } -uint8_t hal_i2s_recv(enum HAL_I2S_ID_T id, uint8_t *value, uint32_t value_len) -{ - //uint32_t reg_base; +uint8_t hal_i2s_recv(enum HAL_I2S_ID_T id, uint8_t *value, uint32_t value_len) { + // uint32_t reg_base; - //reg_base = _i2s_get_reg_base(id); + // reg_base = _i2s_get_reg_base(id); - return 0; + return 0; } //================================================================================ @@ -649,153 +664,144 @@ uint8_t hal_i2s_recv(enum HAL_I2S_ID_T id, uint8_t *value, uint32_t value_len) static bool i2s_pkt_opened = false; -int hal_i2s_packet_open(void) -{ - uint32_t reg_base; - uint8_t resolution = 0, word_sclk = 0; +int hal_i2s_packet_open(void) { + uint32_t reg_base; + uint8_t resolution = 0, word_sclk = 0; - if (i2s_pkt_opened) { - return 1; - } + if (i2s_pkt_opened) { + return 1; + } - word_sclk = I2SIP_CLK_CFG_WSS_VAL_32CYCLE; - resolution = I2SIP_CFG_WLEN_VAL_32BIT; + word_sclk = I2SIP_CLK_CFG_WSS_VAL_32CYCLE; + resolution = I2SIP_CFG_WLEN_VAL_32BIT; - reg_base = _i2s_get_reg_base(HAL_I2S_ID_0); + reg_base = _i2s_get_reg_base(HAL_I2S_ID_0); - hal_iomux_set_i2s0(); - hal_cmu_i2s_clock_enable(HAL_I2S_ID_0); - hal_cmu_clock_enable(i2s_mod[HAL_I2S_ID_0].mod); - hal_cmu_clock_enable(i2s_mod[HAL_I2S_ID_0].apb); - hal_cmu_reset_clear(i2s_mod[HAL_I2S_ID_0].mod); - hal_cmu_reset_clear(i2s_mod[HAL_I2S_ID_0].apb); - i2sip_w_enable_i2sip(reg_base, HAL_I2S_YES); + hal_iomux_set_i2s0(); + hal_cmu_i2s_clock_enable(HAL_I2S_ID_0); + hal_cmu_clock_enable(i2s_mod[HAL_I2S_ID_0].mod); + hal_cmu_clock_enable(i2s_mod[HAL_I2S_ID_0].apb); + hal_cmu_reset_clear(i2s_mod[HAL_I2S_ID_0].mod); + hal_cmu_reset_clear(i2s_mod[HAL_I2S_ID_0].apb); + i2sip_w_enable_i2sip(reg_base, HAL_I2S_YES); - for (int i = 0; i < I2S_CHAN_NUM; i++) { - i2sip_w_enable_rx_channel(reg_base, i, HAL_I2S_NO); - i2sip_w_enable_tx_channel(reg_base, i, HAL_I2S_NO); - } + for (int i = 0; i < I2S_CHAN_NUM; i++) { + i2sip_w_enable_rx_channel(reg_base, i, HAL_I2S_NO); + i2sip_w_enable_tx_channel(reg_base, i, HAL_I2S_NO); + } - hal_cmu_i2s_set_slave_mode(HAL_I2S_ID_0); + hal_cmu_i2s_set_slave_mode(HAL_I2S_ID_0); #ifndef CHIP_BEST1000 - i2sip_w_enable_slave_mode(reg_base, HAL_I2S_YES); + i2sip_w_enable_slave_mode(reg_base, HAL_I2S_YES); #endif - /* word clock width : how many sclk work sclk count*/ - /* sclk gate in word clock : how many sclk gate : fixed no gate */ - i2sip_w_clk_cfg_reg(reg_base, (word_sclk< #include #include -#include "hal_i2s.h" -#include "hal_trace.h" -#include "hal_dma.h" -#include "hal_i2s_tdm.h" #if 0 -#define I2S_TDM_TRACE TRACE -#define I2S_TDM_DUMP8 DUMP8 +#define I2S_TDM_TRACE TRACE +#define I2S_TDM_DUMP8 DUMP8 #else #define I2S_TDM_TRACE(n, str, ...) #define I2S_TDM_DUMP8(str, ...) #endif -#define I2S_TDM_FRAME_SIZE_MAX 512 -#define I2S_TDM_TX_FRAME_NUM 2 -#define I2S_TDM_TX_FRAME_SIZE I2S_TDM_FRAME_SIZE_MAX/16 +#define I2S_TDM_FRAME_SIZE_MAX 512 +#define I2S_TDM_TX_FRAME_NUM 2 +#define I2S_TDM_TX_FRAME_SIZE I2S_TDM_FRAME_SIZE_MAX / 16 -static struct HAL_DMA_DESC_T i2s_tdm_tx_dma_desc[HAL_I2S_ID_QTY][I2S_TDM_TX_FRAME_NUM]; -static uint16_t I2S_TDM_BUF_ALIGN i2s_tdm_tx_buf[HAL_I2S_ID_QTY][I2S_TDM_TX_FRAME_NUM][I2S_TDM_TX_FRAME_SIZE]; +static struct HAL_DMA_DESC_T i2s_tdm_tx_dma_desc[HAL_I2S_ID_QTY] + [I2S_TDM_TX_FRAME_NUM]; +static uint16_t I2S_TDM_BUF_ALIGN + i2s_tdm_tx_buf[HAL_I2S_ID_QTY][I2S_TDM_TX_FRAME_NUM][I2S_TDM_TX_FRAME_SIZE]; static struct HAL_DMA_CH_CFG_T tx_dma_cfg[HAL_I2S_ID_QTY]; static struct HAL_I2S_TDM_CONFIG_T i2s_tdm_cfg[HAL_I2S_ID_QTY]; -static inline bool i2s_tdm_cycles_in_arrays(uint16_t cycles) -{ - if(cycles == (uint16_t)HAL_I2S_TDM_CYCLES_16 - || cycles == (uint16_t)HAL_I2S_TDM_CYCLES_32 - || cycles == (uint16_t)HAL_I2S_TDM_CYCLES_64 - || cycles == (uint16_t)HAL_I2S_TDM_CYCLES_128 - || cycles == (uint16_t)HAL_I2S_TDM_CYCLES_256 - || cycles == (uint16_t)HAL_I2S_TDM_CYCLES_512 - ) - return true; - else - return false; +static inline bool i2s_tdm_cycles_in_arrays(uint16_t cycles) { + if (cycles == (uint16_t)HAL_I2S_TDM_CYCLES_16 || + cycles == (uint16_t)HAL_I2S_TDM_CYCLES_32 || + cycles == (uint16_t)HAL_I2S_TDM_CYCLES_64 || + cycles == (uint16_t)HAL_I2S_TDM_CYCLES_128 || + cycles == (uint16_t)HAL_I2S_TDM_CYCLES_256 || + cycles == (uint16_t)HAL_I2S_TDM_CYCLES_512) + return true; + else + return false; } -static inline bool i2s_tdm_fs_cycles_in_arrays(uint16_t fs_cycles) -{ - if(fs_cycles == (uint16_t)HAL_I2S_TDM_FS_CYCLES_1 - || fs_cycles == (uint16_t)HAL_TDM_FS_CYCLES_8 - || fs_cycles == (uint16_t)HAL_I2S_TDM_FS_CYCLES_16 - || fs_cycles == (uint16_t)HAL_I2S_TDM_FS_CYCLES_32 - || fs_cycles == (uint16_t)HAL_I2S_TDM_FS_CYCLES_64 - || fs_cycles == (uint16_t)HAL_I2S_TDM_FS_CYCLES_128 - || fs_cycles == (uint16_t)HAL_I2S_TDM_FS_CYCLES_256 - || fs_cycles == (uint16_t)HAL_I2S_TDM_FS_CYCLES_ONE_LESS) - return true; - else - return false; +static inline bool i2s_tdm_fs_cycles_in_arrays(uint16_t fs_cycles) { + if (fs_cycles == (uint16_t)HAL_I2S_TDM_FS_CYCLES_1 || + fs_cycles == (uint16_t)HAL_TDM_FS_CYCLES_8 || + fs_cycles == (uint16_t)HAL_I2S_TDM_FS_CYCLES_16 || + fs_cycles == (uint16_t)HAL_I2S_TDM_FS_CYCLES_32 || + fs_cycles == (uint16_t)HAL_I2S_TDM_FS_CYCLES_64 || + fs_cycles == (uint16_t)HAL_I2S_TDM_FS_CYCLES_128 || + fs_cycles == (uint16_t)HAL_I2S_TDM_FS_CYCLES_256 || + fs_cycles == (uint16_t)HAL_I2S_TDM_FS_CYCLES_ONE_LESS) + return true; + else + return false; } -static inline bool i2s_tdm_slot_cycles_in_arrays(uint8_t slot_cycles) -{ - if(slot_cycles == (uint8_t)HAL_I2S_TDM_SLOT_CYCLES_16 - || slot_cycles == (uint8_t)HAL_I2S_TDM_SLOT_CYCLES_32) - return true; - else - return false; +static inline bool i2s_tdm_slot_cycles_in_arrays(uint8_t slot_cycles) { + if (slot_cycles == (uint8_t)HAL_I2S_TDM_SLOT_CYCLES_16 || + slot_cycles == (uint8_t)HAL_I2S_TDM_SLOT_CYCLES_32) + return true; + else + return false; } -static void i2s_tdm0_tx_handler(uint8_t chan, uint32_t remains, uint32_t error, struct HAL_DMA_DESC_T *lli) -{ +static void i2s_tdm0_tx_handler(uint8_t chan, uint32_t remains, uint32_t error, + struct HAL_DMA_DESC_T *lli) { #if 0 static int cnt = 0; @@ -90,8 +88,8 @@ static void i2s_tdm0_tx_handler(uint8_t chan, uint32_t remains, uint32_t error, #endif } -static void i2s_tdm1_tx_handler(uint8_t chan, uint32_t remains, uint32_t error, struct HAL_DMA_DESC_T *lli) -{ +static void i2s_tdm1_tx_handler(uint8_t chan, uint32_t remains, uint32_t error, + struct HAL_DMA_DESC_T *lli) { #if 0 static int cnt = 0; @@ -103,213 +101,209 @@ static void i2s_tdm1_tx_handler(uint8_t chan, uint32_t remains, uint32_t error, #endif } -int32_t hal_i2s_tdm_open(enum HAL_I2S_ID_T i2s_id,enum HAL_I2S_MODE_T mode) -{ - int ret; +int32_t hal_i2s_tdm_open(enum HAL_I2S_ID_T i2s_id, enum HAL_I2S_MODE_T mode) { + int ret; - I2S_TDM_TRACE(3,"%s: i2s_id = %d,mode = %d.", __func__, i2s_id, mode); - ASSERT(i2s_id < HAL_I2S_ID_QTY,"%s: i2s_id = %d!", __func__, i2s_id); - // i2s open playback and capture. - ret = hal_i2s_open(i2s_id, AUD_STREAM_PLAYBACK, mode); - if(ret) - { - I2S_TDM_TRACE(2,"%s: hal_i2s_open playback failed.ret = %d.", __func__, ret); - goto __func_fail; - } - ret = hal_i2s_open(i2s_id, AUD_STREAM_CAPTURE, mode); - if(ret) - { - I2S_TDM_TRACE(2,"%s: hal_i2s_open capture failed.ret = %d.", __func__, ret); - goto __func_fail; - } + I2S_TDM_TRACE(3, "%s: i2s_id = %d,mode = %d.", __func__, i2s_id, mode); + ASSERT(i2s_id < HAL_I2S_ID_QTY, "%s: i2s_id = %d!", __func__, i2s_id); + // i2s open playback and capture. + ret = hal_i2s_open(i2s_id, AUD_STREAM_PLAYBACK, mode); + if (ret) { + I2S_TDM_TRACE(2, "%s: hal_i2s_open playback failed.ret = %d.", __func__, + ret); + goto __func_fail; + } + ret = hal_i2s_open(i2s_id, AUD_STREAM_CAPTURE, mode); + if (ret) { + I2S_TDM_TRACE(2, "%s: hal_i2s_open capture failed.ret = %d.", __func__, + ret); + goto __func_fail; + } - I2S_TDM_TRACE(1,"%s done.", __func__); - return 0; + I2S_TDM_TRACE(1, "%s done.", __func__); + return 0; __func_fail: - I2S_TDM_TRACE(2,"%s failed. ret = %d.", __func__, ret); - return ret; + I2S_TDM_TRACE(2, "%s failed. ret = %d.", __func__, ret); + return ret; } -int32_t hal_i2s_tdm_setup(enum HAL_I2S_ID_T i2s_id, - uint32_t sample_rate, - struct HAL_I2S_TDM_CONFIG_T *i2s_tdm_cfg) -{ - int i,j,m,n; - int ret; - struct HAL_I2S_CONFIG_T i2s_cfg; - uint16_t *buf; - uint32_t cycles; - uint32_t fs_cycles; - uint32_t slot_cycles; - uint32_t fs_remain; +int32_t hal_i2s_tdm_setup(enum HAL_I2S_ID_T i2s_id, uint32_t sample_rate, + struct HAL_I2S_TDM_CONFIG_T *i2s_tdm_cfg) { + int i, j, m, n; + int ret; + struct HAL_I2S_CONFIG_T i2s_cfg; + uint16_t *buf; + uint32_t cycles; + uint32_t fs_cycles; + uint32_t slot_cycles; + uint32_t fs_remain; - I2S_TDM_TRACE(3,"%s: i2s_id = %d,sample_rate = %d.", __func__, i2s_id, sample_rate); - ASSERT(i2s_id < HAL_I2S_ID_QTY,"%s: i2s_id = %d!", __func__, i2s_id); - ASSERT(i2s_tdm_cycles_in_arrays(i2s_tdm_cfg->cycles), - "%s: cycles(%d) error!", __func__, i2s_tdm_cfg->cycles); - ASSERT(i2s_tdm_fs_cycles_in_arrays(i2s_tdm_cfg->fs_cycles), - "%s: fs_cycles(%d) error!", __func__, i2s_tdm_cfg->fs_cycles); - ASSERT(i2s_tdm_slot_cycles_in_arrays(i2s_tdm_cfg->slot_cycles), - "%s: slot_cycles(%d) error!", __func__, i2s_tdm_cfg->slot_cycles); + I2S_TDM_TRACE(3, "%s: i2s_id = %d,sample_rate = %d.", __func__, i2s_id, + sample_rate); + ASSERT(i2s_id < HAL_I2S_ID_QTY, "%s: i2s_id = %d!", __func__, i2s_id); + ASSERT(i2s_tdm_cycles_in_arrays(i2s_tdm_cfg->cycles), "%s: cycles(%d) error!", + __func__, i2s_tdm_cfg->cycles); + ASSERT(i2s_tdm_fs_cycles_in_arrays(i2s_tdm_cfg->fs_cycles), + "%s: fs_cycles(%d) error!", __func__, i2s_tdm_cfg->fs_cycles); + ASSERT(i2s_tdm_slot_cycles_in_arrays(i2s_tdm_cfg->slot_cycles), + "%s: slot_cycles(%d) error!", __func__, i2s_tdm_cfg->slot_cycles); - i2s_tdm_cfg[i2s_id] = *i2s_tdm_cfg; - cycles = i2s_tdm_cfg->cycles; - fs_cycles = i2s_tdm_cfg->fs_cycles == HAL_I2S_TDM_FS_CYCLES_ONE_LESS ?\ - cycles - 1: i2s_tdm_cfg->fs_cycles; - slot_cycles = i2s_tdm_cfg->slot_cycles; + i2s_tdm_cfg[i2s_id] = *i2s_tdm_cfg; + cycles = i2s_tdm_cfg->cycles; + fs_cycles = i2s_tdm_cfg->fs_cycles == HAL_I2S_TDM_FS_CYCLES_ONE_LESS + ? cycles - 1 + : i2s_tdm_cfg->fs_cycles; + slot_cycles = i2s_tdm_cfg->slot_cycles; - memset(&i2s_cfg, 0, sizeof(i2s_cfg)); - i2s_cfg.use_dma = true; - i2s_cfg.sync_start = true; - i2s_cfg.chan_sep_buf = false; - i2s_cfg.bits = slot_cycles; - i2s_cfg.channel_num = 2; - i2s_cfg.channel_map = AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1; - i2s_cfg.sample_rate = (sample_rate*(cycles/i2s_cfg.bits))/2; - ret = hal_i2s_setup_stream(i2s_id, AUD_STREAM_PLAYBACK, &i2s_cfg); - if(ret) - { - I2S_TDM_TRACE(2,"%s: playback failed.ret = %d.", __func__, ret); - goto __func_fail; - } - i2s_cfg.sync_start = false; - ret = hal_i2s_setup_stream(i2s_id, AUD_STREAM_CAPTURE, &i2s_cfg); - if(ret) - { - I2S_TDM_TRACE(1,"hal_i2s_setup_stream capture failed.ret = %d.", ret); - goto __func_fail; - } + memset(&i2s_cfg, 0, sizeof(i2s_cfg)); + i2s_cfg.use_dma = true; + i2s_cfg.sync_start = true; + i2s_cfg.chan_sep_buf = false; + i2s_cfg.bits = slot_cycles; + i2s_cfg.channel_num = 2; + i2s_cfg.channel_map = AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1; + i2s_cfg.sample_rate = (sample_rate * (cycles / i2s_cfg.bits)) / 2; + ret = hal_i2s_setup_stream(i2s_id, AUD_STREAM_PLAYBACK, &i2s_cfg); + if (ret) { + I2S_TDM_TRACE(2, "%s: playback failed.ret = %d.", __func__, ret); + goto __func_fail; + } + i2s_cfg.sync_start = false; + ret = hal_i2s_setup_stream(i2s_id, AUD_STREAM_CAPTURE, &i2s_cfg); + if (ret) { + I2S_TDM_TRACE(1, "hal_i2s_setup_stream capture failed.ret = %d.", ret); + goto __func_fail; + } - // Set tx buffer, output signal as slave device ws. - I2S_TDM_TRACE(3,"%s: cycles = %d, fs_cycles = %d", __func__, cycles, fs_cycles); - for (i = 0; i < I2S_TDM_TX_FRAME_NUM ; i++) { - buf = (uint16_t*)(&i2s_tdm_tx_buf[i2s_id][i][0]); - for(j = 0; j < I2S_TDM_TX_FRAME_SIZE/(cycles/16); j ++){ - fs_remain = fs_cycles; - for(m = 0; m < (cycles/16); m++) { - buf[j*(cycles/16) + m] = 0; - for(n = 0; n < 16; n++) { - if (fs_remain > 0) { - buf[j*(cycles/16) + m] |= (1<< n); - fs_remain --; - } else { - break; - } - } - } + // Set tx buffer, output signal as slave device ws. + I2S_TDM_TRACE(3, "%s: cycles = %d, fs_cycles = %d", __func__, cycles, + fs_cycles); + for (i = 0; i < I2S_TDM_TX_FRAME_NUM; i++) { + buf = (uint16_t *)(&i2s_tdm_tx_buf[i2s_id][i][0]); + for (j = 0; j < I2S_TDM_TX_FRAME_SIZE / (cycles / 16); j++) { + fs_remain = fs_cycles; + for (m = 0; m < (cycles / 16); m++) { + buf[j * (cycles / 16) + m] = 0; + for (n = 0; n < 16; n++) { + if (fs_remain > 0) { + buf[j * (cycles / 16) + m] |= (1 << n); + fs_remain--; + } else { + break; + } } + } } + } - I2S_TDM_TRACE(1,"%s done.", __func__); - return 0; + I2S_TDM_TRACE(1, "%s done.", __func__); + return 0; __func_fail: - I2S_TDM_TRACE(2,"%s failed. ret = %d.", __func__, ret); - return ret; + I2S_TDM_TRACE(2, "%s failed. ret = %d.", __func__, ret); + return ret; } -int32_t hal_i2s_tdm_start_stream(enum HAL_I2S_ID_T i2s_id) -{ - uint32_t i; - int ret; +int32_t hal_i2s_tdm_start_stream(enum HAL_I2S_ID_T i2s_id) { + uint32_t i; + int ret; - I2S_TDM_TRACE(2,"%s: i2s_id = %d.", __func__, i2s_id); - ASSERT(i2s_id < HAL_I2S_ID_QTY,"%s: i2s_id = %d!", __func__, i2s_id); + I2S_TDM_TRACE(2, "%s: i2s_id = %d.", __func__, i2s_id); + ASSERT(i2s_id < HAL_I2S_ID_QTY, "%s: i2s_id = %d!", __func__, i2s_id); - memset(&tx_dma_cfg[i2s_id], 0, sizeof(tx_dma_cfg[i2s_id])); - tx_dma_cfg[i2s_id].dst = 0; //useless - tx_dma_cfg[i2s_id].dst_bsize = HAL_DMA_BSIZE_4; - tx_dma_cfg[i2s_id].dst_periph = i2s_id == HAL_I2S_ID_0 ? HAL_AUDMA_I2S0_TX : HAL_AUDMA_I2S1_TX; - tx_dma_cfg[i2s_id].dst_width = HAL_DMA_WIDTH_HALFWORD; - tx_dma_cfg[i2s_id].handler = i2s_id == HAL_I2S_ID_0 ? i2s_tdm0_tx_handler : i2s_tdm1_tx_handler; - tx_dma_cfg[i2s_id].src_bsize = HAL_DMA_BSIZE_4; - tx_dma_cfg[i2s_id].src_tsize = (sizeof(i2s_tdm_tx_buf[i2s_id][0])/2); - tx_dma_cfg[i2s_id].src_width = HAL_DMA_WIDTH_HALFWORD; - tx_dma_cfg[i2s_id].try_burst = 1; - tx_dma_cfg[i2s_id].type = HAL_DMA_FLOW_M2P_DMA; - tx_dma_cfg[i2s_id].ch = hal_audma_get_chan(tx_dma_cfg[i2s_id].dst_periph, HAL_DMA_HIGH_PRIO); + memset(&tx_dma_cfg[i2s_id], 0, sizeof(tx_dma_cfg[i2s_id])); + tx_dma_cfg[i2s_id].dst = 0; // useless + tx_dma_cfg[i2s_id].dst_bsize = HAL_DMA_BSIZE_4; + tx_dma_cfg[i2s_id].dst_periph = + i2s_id == HAL_I2S_ID_0 ? HAL_AUDMA_I2S0_TX : HAL_AUDMA_I2S1_TX; + tx_dma_cfg[i2s_id].dst_width = HAL_DMA_WIDTH_HALFWORD; + tx_dma_cfg[i2s_id].handler = + i2s_id == HAL_I2S_ID_0 ? i2s_tdm0_tx_handler : i2s_tdm1_tx_handler; + tx_dma_cfg[i2s_id].src_bsize = HAL_DMA_BSIZE_4; + tx_dma_cfg[i2s_id].src_tsize = (sizeof(i2s_tdm_tx_buf[i2s_id][0]) / 2); + tx_dma_cfg[i2s_id].src_width = HAL_DMA_WIDTH_HALFWORD; + tx_dma_cfg[i2s_id].try_burst = 1; + tx_dma_cfg[i2s_id].type = HAL_DMA_FLOW_M2P_DMA; + tx_dma_cfg[i2s_id].ch = + hal_audma_get_chan(tx_dma_cfg[i2s_id].dst_periph, HAL_DMA_HIGH_PRIO); - for (i = 0; i < I2S_TDM_TX_FRAME_NUM; i++) { - tx_dma_cfg[i2s_id].src = (uint32_t)&i2s_tdm_tx_buf[i2s_id][i][0]; - ret = hal_audma_init_desc(&i2s_tdm_tx_dma_desc[i2s_id][i], - &tx_dma_cfg[i2s_id], - &i2s_tdm_tx_dma_desc[i2s_id][(i + 1) % I2S_TDM_TX_FRAME_NUM], - 1); - if(ret) - { - I2S_TDM_TRACE(2,"%s: hal_audma_init_desc tx failed.ret = %d.", __func__, ret); - goto __func_fail; - } + for (i = 0; i < I2S_TDM_TX_FRAME_NUM; i++) { + tx_dma_cfg[i2s_id].src = (uint32_t)&i2s_tdm_tx_buf[i2s_id][i][0]; + ret = hal_audma_init_desc( + &i2s_tdm_tx_dma_desc[i2s_id][i], &tx_dma_cfg[i2s_id], + &i2s_tdm_tx_dma_desc[i2s_id][(i + 1) % I2S_TDM_TX_FRAME_NUM], 1); + if (ret) { + I2S_TDM_TRACE(2, "%s: hal_audma_init_desc tx failed.ret = %d.", __func__, + ret); + goto __func_fail; } + } - ret = hal_audma_sg_start(&i2s_tdm_tx_dma_desc[i2s_id][0], &tx_dma_cfg[i2s_id]); - if(ret) - { - I2S_TDM_TRACE(2,"%s: hal_audma_sg_start tx failed.ret = %d.", __func__, ret); - goto __func_fail; - } + ret = + hal_audma_sg_start(&i2s_tdm_tx_dma_desc[i2s_id][0], &tx_dma_cfg[i2s_id]); + if (ret) { + I2S_TDM_TRACE(2, "%s: hal_audma_sg_start tx failed.ret = %d.", __func__, + ret); + goto __func_fail; + } - // i2s start stream playback and capture. - ret = hal_i2s_start_stream(i2s_id, AUD_STREAM_PLAYBACK); - if(ret) - { - I2S_TDM_TRACE(2,"%s: hal_i2s_start_stream failed.ret = %d.", __func__, ret); - } + // i2s start stream playback and capture. + ret = hal_i2s_start_stream(i2s_id, AUD_STREAM_PLAYBACK); + if (ret) { + I2S_TDM_TRACE(2, "%s: hal_i2s_start_stream failed.ret = %d.", __func__, + ret); + } - ret = hal_i2s_start_stream(i2s_id, AUD_STREAM_CAPTURE); - if(ret) - { - I2S_TDM_TRACE(1,"hal_i2s_start_stream tx failed.ret = %d.", ret); - goto __func_fail; - } + ret = hal_i2s_start_stream(i2s_id, AUD_STREAM_CAPTURE); + if (ret) { + I2S_TDM_TRACE(1, "hal_i2s_start_stream tx failed.ret = %d.", ret); + goto __func_fail; + } - I2S_TDM_TRACE(1,"%s done.", __func__); - return ret; + I2S_TDM_TRACE(1, "%s done.", __func__); + return ret; __func_fail: - I2S_TDM_TRACE(2,"%s failed.ret = %d.", __func__, ret); - return ret; + I2S_TDM_TRACE(2, "%s failed.ret = %d.", __func__, ret); + return ret; } -int32_t hal_i2s_tdm_stop_stream(enum HAL_I2S_ID_T i2s_id) -{ - I2S_TDM_TRACE(2,"%s: i2s_id = %d.", __func__, i2s_id); - ASSERT(i2s_id < HAL_I2S_ID_QTY,"%s: i2s_id = %d!", __func__, i2s_id); +int32_t hal_i2s_tdm_stop_stream(enum HAL_I2S_ID_T i2s_id) { + I2S_TDM_TRACE(2, "%s: i2s_id = %d.", __func__, i2s_id); + ASSERT(i2s_id < HAL_I2S_ID_QTY, "%s: i2s_id = %d!", __func__, i2s_id); - hal_dma_stop(tx_dma_cfg[i2s_id].ch); - hal_i2s_stop_stream(i2s_id,AUD_STREAM_PLAYBACK); - hal_i2s_stop_stream(i2s_id,AUD_STREAM_CAPTURE); + hal_dma_stop(tx_dma_cfg[i2s_id].ch); + hal_i2s_stop_stream(i2s_id, AUD_STREAM_PLAYBACK); + hal_i2s_stop_stream(i2s_id, AUD_STREAM_CAPTURE); - I2S_TDM_TRACE(1,"%s done.", __func__); - return 0; + I2S_TDM_TRACE(1, "%s done.", __func__); + return 0; } -int32_t hal_i2s_tdm_close(enum HAL_I2S_ID_T i2s_id) -{ - I2S_TDM_TRACE(2,"%s: i2s_id = %d.", __func__, i2s_id); - ASSERT(i2s_id < HAL_I2S_ID_QTY,"%s: i2s_id = %d!", __func__, i2s_id); +int32_t hal_i2s_tdm_close(enum HAL_I2S_ID_T i2s_id) { + I2S_TDM_TRACE(2, "%s: i2s_id = %d.", __func__, i2s_id); + ASSERT(i2s_id < HAL_I2S_ID_QTY, "%s: i2s_id = %d!", __func__, i2s_id); - hal_i2s_close(i2s_id,AUD_STREAM_PLAYBACK); - hal_i2s_close(i2s_id,AUD_STREAM_CAPTURE); + hal_i2s_close(i2s_id, AUD_STREAM_PLAYBACK); + hal_i2s_close(i2s_id, AUD_STREAM_CAPTURE); - I2S_TDM_TRACE(1,"%s done.", __func__); - return 0; + I2S_TDM_TRACE(1, "%s done.", __func__); + return 0; } -void hal_i2s_tdm_get_config(enum HAL_I2S_ID_T i2s_id,struct HAL_I2S_TDM_CONFIG_T *tdm_cfg) -{ - I2S_TDM_TRACE(2,"%s: i2s_id = %d.", __func__, i2s_id); - ASSERT(i2s_id < HAL_I2S_ID_QTY,"%s: i2s_id = %d!", __func__, i2s_id); +void hal_i2s_tdm_get_config(enum HAL_I2S_ID_T i2s_id, + struct HAL_I2S_TDM_CONFIG_T *tdm_cfg) { + I2S_TDM_TRACE(2, "%s: i2s_id = %d.", __func__, i2s_id); + ASSERT(i2s_id < HAL_I2S_ID_QTY, "%s: i2s_id = %d!", __func__, i2s_id); - *tdm_cfg = i2s_tdm_cfg[i2s_id]; + *tdm_cfg = i2s_tdm_cfg[i2s_id]; } -void hal_i2s_tdm_set_config(enum HAL_I2S_ID_T i2s_id,struct HAL_I2S_TDM_CONFIG_T *tdm_cfg) -{ - I2S_TDM_TRACE(2,"%s: i2s_id = %d.", __func__, i2s_id); - ASSERT(i2s_id < HAL_I2S_ID_QTY,"%s: i2s_id = %d!", __func__, i2s_id); +void hal_i2s_tdm_set_config(enum HAL_I2S_ID_T i2s_id, + struct HAL_I2S_TDM_CONFIG_T *tdm_cfg) { + I2S_TDM_TRACE(2, "%s: i2s_id = %d.", __func__, i2s_id); + ASSERT(i2s_id < HAL_I2S_ID_QTY, "%s: i2s_id = %d!", __func__, i2s_id); - i2s_tdm_cfg[i2s_id] = *tdm_cfg; + i2s_tdm_cfg[i2s_id] = *tdm_cfg; } - diff --git a/platform/hal/hal_intersys.c b/platform/hal/hal_intersys.c index 6bc131b..9aa5d00 100644 --- a/platform/hal/hal_intersys.c +++ b/platform/hal/hal_intersys.c @@ -18,8 +18,8 @@ #ifdef BT_CMU_BASE #include "hal_intersys.h" -#include "hal_trace.h" #include "hal_sleep.h" +#include "hal_trace.h" #include CHIP_SPECIFIC_HDR(reg_cmu) #include CHIP_SPECIFIC_HDR(reg_btcmu) #include "cmsis_nvic.h" @@ -31,49 +31,49 @@ #define PEER_IRQ_AUTO_CLEAR #endif -#define MAX_SEND_RECORD_COUNT 3 +#define MAX_SEND_RECORD_COUNT 3 // MCU-CMU ISIRQ_SET -#define CMU_BT2MCU_DATA_DONE_SET (1 << 0) -#define CMU_BT2MCU_DATA1_DONE_SET (1 << 1) -#define CMU_MCU2BT_DATA_IND_SET (1 << 2) -#define CMU_MCU2BT_DATA1_IND_SET (1 << 3) +#define CMU_BT2MCU_DATA_DONE_SET (1 << 0) +#define CMU_BT2MCU_DATA1_DONE_SET (1 << 1) +#define CMU_MCU2BT_DATA_IND_SET (1 << 2) +#define CMU_MCU2BT_DATA1_IND_SET (1 << 3) // MCU-CMU ISIRQ_CLR -#define CMU_BT2MCU_DATA_DONE_CLR (1 << 0) -#define CMU_BT2MCU_DATA1_DONE_CLR (1 << 1) -#define CMU_MCU2BT_DATA_IND_CLR (1 << 2) -#define CMU_MCU2BT_DATA1_IND_CLR (1 << 3) +#define CMU_BT2MCU_DATA_DONE_CLR (1 << 0) +#define CMU_BT2MCU_DATA1_DONE_CLR (1 << 1) +#define CMU_MCU2BT_DATA_IND_CLR (1 << 2) +#define CMU_MCU2BT_DATA1_IND_CLR (1 << 3) // BT-CMU ISIRQ_SET -#define BTCMU_MCU2BT_DATA_DONE_SET (1 << 0) -#define BTCMU_MCU2BT_DATA1_DONE_SET (1 << 1) -#define BTCMU_BT2MCU_DATA_IND_SET (1 << 2) -#define BTCMU_BT2MCU_DATA1_IND_SET (1 << 3) +#define BTCMU_MCU2BT_DATA_DONE_SET (1 << 0) +#define BTCMU_MCU2BT_DATA1_DONE_SET (1 << 1) +#define BTCMU_BT2MCU_DATA_IND_SET (1 << 2) +#define BTCMU_BT2MCU_DATA1_IND_SET (1 << 3) // BT-CMU ISIRQ_CLR -#define BTCMU_MCU2BT_DATA_DONE_CLR (1 << 0) -#define BTCMU_MCU2BT_DATA1_DONE_CLR (1 << 1) -#define BTCMU_BT2MCU_DATA_IND_CLR (1 << 2) -#define BTCMU_BT2MCU_DATA1_IND_CLR (1 << 3) +#define BTCMU_MCU2BT_DATA_DONE_CLR (1 << 0) +#define BTCMU_MCU2BT_DATA1_DONE_CLR (1 << 1) +#define BTCMU_BT2MCU_DATA_IND_CLR (1 << 2) +#define BTCMU_BT2MCU_DATA1_IND_CLR (1 << 3) enum HAL_INTERSYS_IRQ_TYPE_T { - HAL_INTERSYS_IRQ_SEND_IND, - HAL_INTERSYS_IRQ_RECV_DONE, + HAL_INTERSYS_IRQ_SEND_IND, + HAL_INTERSYS_IRQ_RECV_DONE, - HAL_INTERSYS_IRQ_TYPE_QTY + HAL_INTERSYS_IRQ_TYPE_QTY }; struct HAL_INTERSYS_MSG_T { - struct HAL_INTERSYS_MSG_T *next; // pointer to next element in the list - enum HAL_INTERSYS_MSG_TYPE_T type; // message type - unsigned int len; // message data length in bytes - const unsigned char *data; // pointer to the message data + struct HAL_INTERSYS_MSG_T *next; // pointer to next element in the list + enum HAL_INTERSYS_MSG_TYPE_T type; // message type + unsigned int len; // message data length in bytes + const unsigned char *data; // pointer to the message data }; struct HAL_INTERSYS_SEND_RECORD_T { - struct HAL_INTERSYS_MSG_T msg; - bool in_use; + struct HAL_INTERSYS_MSG_T msg; + bool in_use; }; static const IRQn_Type rx_irq_id[HAL_INTERSYS_ID_QTY] = { @@ -86,32 +86,50 @@ static const IRQn_Type tx_irq_id[HAL_INTERSYS_ID_QTY] = { ISDONE1_IRQn, }; -static struct HAL_INTERSYS_MSG_T *** const bt_recv_msg_list_ppp[HAL_INTERSYS_ID_QTY] = { - (struct HAL_INTERSYS_MSG_T ***)(BT_RAM_BASE + BT_INTESYS_MEM_OFFSET + 0x4), - (struct HAL_INTERSYS_MSG_T ***)(BT_RAM_BASE+ BT_INTESYS_MEM_OFFSET + 0xC), +static struct HAL_INTERSYS_MSG_T ** + *const bt_recv_msg_list_ppp[HAL_INTERSYS_ID_QTY] = { + (struct HAL_INTERSYS_MSG_T ***)(BT_RAM_BASE + BT_INTESYS_MEM_OFFSET + + 0x4), + (struct HAL_INTERSYS_MSG_T ***)(BT_RAM_BASE + BT_INTESYS_MEM_OFFSET + + 0xC), }; -static struct HAL_INTERSYS_MSG_T ** const recv_msg_list_p[HAL_INTERSYS_ID_QTY] = { - (struct HAL_INTERSYS_MSG_T **)(BT_RAM_BASE + BT_INTESYS_MEM_OFFSET), - (struct HAL_INTERSYS_MSG_T **)(BT_RAM_BASE + BT_INTESYS_MEM_OFFSET + 0x8), +static struct HAL_INTERSYS_MSG_T **const recv_msg_list_p[HAL_INTERSYS_ID_QTY] = + { + (struct HAL_INTERSYS_MSG_T **)(BT_RAM_BASE + BT_INTESYS_MEM_OFFSET), + (struct HAL_INTERSYS_MSG_T **)(BT_RAM_BASE + BT_INTESYS_MEM_OFFSET + + 0x8), }; -static struct HAL_INTERSYS_MSG_T * send_msg_list_p[HAL_INTERSYS_ID_QTY]; -static struct HAL_INTERSYS_MSG_T * send_pending_list_p[HAL_INTERSYS_ID_QTY]; +static struct HAL_INTERSYS_MSG_T *send_msg_list_p[HAL_INTERSYS_ID_QTY]; +static struct HAL_INTERSYS_MSG_T *send_pending_list_p[HAL_INTERSYS_ID_QTY]; static struct HAL_INTERSYS_MSG_T recv_pending_head[HAL_INTERSYS_ID_QTY]; -static struct HAL_INTERSYS_SEND_RECORD_T send_msgs[HAL_INTERSYS_ID_QTY][MAX_SEND_RECORD_COUNT]; +static struct HAL_INTERSYS_SEND_RECORD_T send_msgs[HAL_INTERSYS_ID_QTY] + [MAX_SEND_RECORD_COUNT]; -static HAL_INTERSYS_RX_IRQ_HANDLER rx_irq_handler[HAL_INTERSYS_ID_QTY][HAL_INTERSYS_MSG_TYPE_QTY]; -static HAL_INTERSYS_TX_IRQ_HANDLER tx_irq_handler[HAL_INTERSYS_ID_QTY][HAL_INTERSYS_MSG_TYPE_QTY]; +static HAL_INTERSYS_RX_IRQ_HANDLER rx_irq_handler[HAL_INTERSYS_ID_QTY] + [HAL_INTERSYS_MSG_TYPE_QTY]; +static HAL_INTERSYS_TX_IRQ_HANDLER tx_irq_handler[HAL_INTERSYS_ID_QTY] + [HAL_INTERSYS_MSG_TYPE_QTY]; -static uint8_t chan_opened[HAL_INTERSYS_ID_QTY] = { 0, 0, }; -STATIC_ASSERT(sizeof(chan_opened[0]) * 8 >= HAL_INTERSYS_MSG_TYPE_QTY, "chan_opened size too small"); +static uint8_t chan_opened[HAL_INTERSYS_ID_QTY] = { + 0, + 0, +}; +STATIC_ASSERT(sizeof(chan_opened[0]) * 8 >= HAL_INTERSYS_MSG_TYPE_QTY, + "chan_opened size too small"); -static bool need_flow_ctrl[HAL_INTERSYS_ID_QTY] = { false, false, }; +static bool need_flow_ctrl[HAL_INTERSYS_ID_QTY] = { + false, + false, +}; -static bool chan_busy[HAL_INTERSYS_ID_QTY] = { false, false, }; +static bool chan_busy[HAL_INTERSYS_ID_QTY] = { + false, + false, +}; static bool busy_now = false; @@ -119,404 +137,400 @@ static bool busy_now = false; static bool peer_irq_auto_clear; #endif -static struct CMU_T * const cmu = (struct CMU_T *)CMU_BASE; +static struct CMU_T *const cmu = (struct CMU_T *)CMU_BASE; -static struct BTCMU_T * const btcmu = (struct BTCMU_T *)BT_CMU_BASE; +static struct BTCMU_T *const btcmu = (struct BTCMU_T *)BT_CMU_BASE; -static void hal_intersys_busy(enum HAL_INTERSYS_ID_T id, bool busy) -{ - int i; - bool new_state; +static void hal_intersys_busy(enum HAL_INTERSYS_ID_T id, bool busy) { + int i; + bool new_state; - if (chan_busy[id] == busy) { - return; + if (chan_busy[id] == busy) { + return; + } + + chan_busy[id] = busy; + + if (busy_now == busy) { + return; + } + + if (busy) { + hal_sys_wake_lock(HAL_SYS_WAKE_LOCK_USER_INTERSYS); + busy_now = true; + } else { + new_state = false; + for (i = 0; i < HAL_INTERSYS_ID_QTY; i++) { + if (chan_busy[i]) { + new_state = true; + break; + } } - - chan_busy[id] = busy; - - if (busy_now == busy) { - return; - } - - if (busy) { - hal_sys_wake_lock(HAL_SYS_WAKE_LOCK_USER_INTERSYS); - busy_now = true; - } else { - new_state = false; - for (i = 0; i < HAL_INTERSYS_ID_QTY; i++) { - if (chan_busy[i]) { - new_state = true; - break; - } - } - if (!new_state) { - hal_sys_wake_unlock(HAL_SYS_WAKE_LOCK_USER_INTERSYS); - busy_now = false; - } + if (!new_state) { + hal_sys_wake_unlock(HAL_SYS_WAKE_LOCK_USER_INTERSYS); + busy_now = false; } + } } #ifdef PEER_IRQ_AUTO_CLEAR -void hal_intersys_peer_irq_auto_clear(bool enable) -{ - peer_irq_auto_clear = enable; +void hal_intersys_peer_irq_auto_clear(bool enable) { + peer_irq_auto_clear = enable; } #endif -static int hal_intersys_peer_irq_set(enum HAL_INTERSYS_ID_T id, enum HAL_INTERSYS_IRQ_TYPE_T type) -{ - uint32_t value; +static int hal_intersys_peer_irq_set(enum HAL_INTERSYS_ID_T id, + enum HAL_INTERSYS_IRQ_TYPE_T type) { + uint32_t value; - if (id == HAL_INTERSYS_ID_0) { - if (type == HAL_INTERSYS_IRQ_SEND_IND) { - value = CMU_MCU2BT_DATA_IND_SET; - } else { - value = CMU_BT2MCU_DATA_DONE_SET; - } + if (id == HAL_INTERSYS_ID_0) { + if (type == HAL_INTERSYS_IRQ_SEND_IND) { + value = CMU_MCU2BT_DATA_IND_SET; } else { - if (type == HAL_INTERSYS_IRQ_SEND_IND) { - value = CMU_MCU2BT_DATA1_IND_SET; - } else { - value = CMU_BT2MCU_DATA1_DONE_SET; - } + value = CMU_BT2MCU_DATA_DONE_SET; } + } else { + if (type == HAL_INTERSYS_IRQ_SEND_IND) { + value = CMU_MCU2BT_DATA1_IND_SET; + } else { + value = CMU_BT2MCU_DATA1_DONE_SET; + } + } #ifdef PEER_IRQ_AUTO_CLEAR - uint32_t ret; + uint32_t ret; - ret = int_lock(); - cmu->ISIRQ_SET = value; - if (peer_irq_auto_clear) { - if (CMU_MCU2BT_DATA_IND_SET == value) { - cmu->ISIRQ_CLR |= CMU_MCU2BT_DATA_IND_CLR; - } else { - cmu->ISIRQ_CLR |= CMU_BT2MCU_DATA_DONE_CLR; - } - hal_sys_timer_delay(MS_TO_TICKS(2)); + ret = int_lock(); + cmu->ISIRQ_SET = value; + if (peer_irq_auto_clear) { + if (CMU_MCU2BT_DATA_IND_SET == value) { + cmu->ISIRQ_CLR |= CMU_MCU2BT_DATA_IND_CLR; + } else { + cmu->ISIRQ_CLR |= CMU_BT2MCU_DATA_DONE_CLR; } - int_unlock(ret); + hal_sys_timer_delay(MS_TO_TICKS(2)); + } + int_unlock(ret); #else - cmu->ISIRQ_SET = value; + cmu->ISIRQ_SET = value; #endif - return 0; + return 0; } -static inline void btcmu_reg_update_wait(void) -{ - // Make sure BTCMU (26M clock domain) write opertions finish before return - btcmu->ISIRQ_CLR; +static inline void btcmu_reg_update_wait(void) { + // Make sure BTCMU (26M clock domain) write opertions finish before return + btcmu->ISIRQ_CLR; } -static int hal_intersys_local_irq_clear(enum HAL_INTERSYS_ID_T id, enum HAL_INTERSYS_IRQ_TYPE_T type) -{ - uint32_t value; +static int hal_intersys_local_irq_clear(enum HAL_INTERSYS_ID_T id, + enum HAL_INTERSYS_IRQ_TYPE_T type) { + uint32_t value; - if (id == HAL_INTERSYS_ID_0) { - if (type == HAL_INTERSYS_IRQ_SEND_IND) { - value = BTCMU_BT2MCU_DATA_IND_CLR; - } else { - value = BTCMU_MCU2BT_DATA_DONE_CLR; - } + if (id == HAL_INTERSYS_ID_0) { + if (type == HAL_INTERSYS_IRQ_SEND_IND) { + value = BTCMU_BT2MCU_DATA_IND_CLR; } else { - if (type == HAL_INTERSYS_IRQ_SEND_IND) { - value = BTCMU_BT2MCU_DATA1_IND_CLR; - } else { - value = BTCMU_MCU2BT_DATA1_DONE_CLR; - } + value = BTCMU_MCU2BT_DATA_DONE_CLR; } - - btcmu->ISIRQ_CLR = value; - btcmu_reg_update_wait(); - return 0; -} - -static int hal_intersys_local_irq_set(enum HAL_INTERSYS_ID_T id, enum HAL_INTERSYS_IRQ_TYPE_T type) -{ - uint32_t value; - - if (id == HAL_INTERSYS_ID_0) { - if (type == HAL_INTERSYS_IRQ_SEND_IND) { - value = BTCMU_BT2MCU_DATA_IND_SET; - } else { - value = BTCMU_MCU2BT_DATA_DONE_SET; - } + } else { + if (type == HAL_INTERSYS_IRQ_SEND_IND) { + value = BTCMU_BT2MCU_DATA1_IND_CLR; } else { - if (type == HAL_INTERSYS_IRQ_SEND_IND) { - value = BTCMU_BT2MCU_DATA1_IND_SET; - } else { - value = BTCMU_MCU2BT_DATA1_DONE_SET; - } + value = BTCMU_MCU2BT_DATA1_DONE_CLR; } + } - btcmu->ISIRQ_SET = value; - btcmu_reg_update_wait(); - return 0; + btcmu->ISIRQ_CLR = value; + btcmu_reg_update_wait(); + return 0; } +static int hal_intersys_local_irq_set(enum HAL_INTERSYS_ID_T id, + enum HAL_INTERSYS_IRQ_TYPE_T type) { + uint32_t value; -//static void hal_intersys_wait_done_idle(void) + if (id == HAL_INTERSYS_ID_0) { + if (type == HAL_INTERSYS_IRQ_SEND_IND) { + value = BTCMU_BT2MCU_DATA_IND_SET; + } else { + value = BTCMU_MCU2BT_DATA_DONE_SET; + } + } else { + if (type == HAL_INTERSYS_IRQ_SEND_IND) { + value = BTCMU_BT2MCU_DATA1_IND_SET; + } else { + value = BTCMU_MCU2BT_DATA1_DONE_SET; + } + } + + btcmu->ISIRQ_SET = value; + btcmu_reg_update_wait(); + return 0; +} + +// static void hal_intersys_wait_done_idle(void) //{ -// while(hal_cmu_get_address()->ISIRQ_SET & (CMU_BT2MCU_DATA_DONE_SET |CMU_BT2MCU_DATA1_DONE_SET)); +// while(hal_cmu_get_address()->ISIRQ_SET & (CMU_BT2MCU_DATA_DONE_SET +// |CMU_BT2MCU_DATA1_DONE_SET)); //} - -//static void hal_intersys_wait_data_idle(void) +// static void hal_intersys_wait_data_idle(void) //{ -// while(hal_cmu_get_address()->ISIRQ_SET & (CMU_MCU2BT_DATA_IND_SET |CMU_MCU2BT_DATA1_IND_SET)); +// while(hal_cmu_get_address()->ISIRQ_SET & (CMU_MCU2BT_DATA_IND_SET +// |CMU_MCU2BT_DATA1_IND_SET)); //} debug_intersys_type g_debug_intersys; -static void hal_intersys_rx_irq(void) -{ - int id; - struct HAL_INTERSYS_MSG_T *msg_ptr; - enum HAL_INTERSYS_MSG_TYPE_T type; - unsigned int processed; +static void hal_intersys_rx_irq(void) { + int id; + struct HAL_INTERSYS_MSG_T *msg_ptr; + enum HAL_INTERSYS_MSG_TYPE_T type; + unsigned int processed; - if (g_debug_intersys.cmd_opcode != 0xFFFF){ - g_debug_intersys.irq_happen += 1; - } + if (g_debug_intersys.cmd_opcode != 0xFFFF) { + g_debug_intersys.irq_happen += 1; + } - for (id = HAL_INTERSYS_ID_0; id < HAL_INTERSYS_ID_QTY; id++) { - if (NVIC_GetActive(rx_irq_id[id])) { - hal_intersys_local_irq_clear(id, HAL_INTERSYS_IRQ_SEND_IND); + for (id = HAL_INTERSYS_ID_0; id < HAL_INTERSYS_ID_QTY; id++) { + if (NVIC_GetActive(rx_irq_id[id])) { + hal_intersys_local_irq_clear(id, HAL_INTERSYS_IRQ_SEND_IND); - if (recv_pending_head[id].data) { - // Previous unprocessed message - msg_ptr = &recv_pending_head[id]; - } else { - // New message - msg_ptr = *recv_msg_list_p[id]; - } - while (msg_ptr) { - type = msg_ptr->type; - if (type >= HAL_INTERSYS_MSG_TYPE_QTY) { - // Error - ASSERT(false, "INTERSYS-RX: Invalid msg type: %d", type); - break; - } - if (rx_irq_handler[id][type]) { - processed = rx_irq_handler[id][type](msg_ptr->data, msg_ptr->len); - // Check if flow control needed - if (processed < msg_ptr->len) { - recv_pending_head[id].next = msg_ptr->next; - recv_pending_head[id].type = msg_ptr->type; - recv_pending_head[id].len = msg_ptr->len - processed; - recv_pending_head[id].data = msg_ptr->data + processed; - break; - } - } else { - // Error - ASSERT(false, "INTERSYS-RX: Handler missing"); - break; - } - msg_ptr = msg_ptr->next; - } - - if (msg_ptr == NULL) { - if (!need_flow_ctrl[id]){ - hal_intersys_peer_irq_set(id, HAL_INTERSYS_IRQ_RECV_DONE); - } - recv_pending_head[id].data = NULL; - } + if (recv_pending_head[id].data) { + // Previous unprocessed message + msg_ptr = &recv_pending_head[id]; + } else { + // New message + msg_ptr = *recv_msg_list_p[id]; + } + while (msg_ptr) { + type = msg_ptr->type; + if (type >= HAL_INTERSYS_MSG_TYPE_QTY) { + // Error + ASSERT(false, "INTERSYS-RX: Invalid msg type: %d", type); + break; } - } -} - -static void hal_intersys_tx_irq(void) -{ - int id; - struct HAL_INTERSYS_MSG_T *msg_ptr; - enum HAL_INTERSYS_MSG_TYPE_T type; - - for (id = HAL_INTERSYS_ID_0; id < HAL_INTERSYS_ID_QTY; id++) { - if (NVIC_GetActive(tx_irq_id[id])) { - hal_intersys_local_irq_clear(id, HAL_INTERSYS_IRQ_RECV_DONE); - - msg_ptr = send_msg_list_p[id]; - while (msg_ptr) { - type = msg_ptr->type; - if (type >= HAL_INTERSYS_MSG_TYPE_QTY) { - // Error - ASSERT(false, "INTERSYS-TX: Invalid msg type: %d", type); - break; - } - if (tx_irq_handler[id][type]) { - tx_irq_handler[id][type](msg_ptr->data, msg_ptr->len); - }; - CONTAINER_OF(msg_ptr, struct HAL_INTERSYS_SEND_RECORD_T, msg)->in_use = false; - msg_ptr = msg_ptr->next; - } - - if (send_pending_list_p[id]) { - send_msg_list_p[id] = send_pending_list_p[id]; - send_pending_list_p[id] = NULL; - hal_intersys_peer_irq_set(id, HAL_INTERSYS_IRQ_SEND_IND); - } else { - send_msg_list_p[id] = NULL; - // Allow sleep - hal_intersys_busy(id, false); - } - } - } -} - -int hal_intersys_open(enum HAL_INTERSYS_ID_T id, enum HAL_INTERSYS_MSG_TYPE_T type, - HAL_INTERSYS_RX_IRQ_HANDLER rxhandler, HAL_INTERSYS_TX_IRQ_HANDLER txhandler, bool rx_flowctrl) -{ - int i; - - if (id >= HAL_INTERSYS_ID_QTY) { - return 1; - } - if (type >= HAL_INTERSYS_MSG_TYPE_QTY) { - return 2; - } - - if (chan_opened[id] == 0) { - if (id == HAL_INTERSYS_ID_0) { - cmu->ISIRQ_CLR = CMU_BT2MCU_DATA_DONE_CLR | CMU_MCU2BT_DATA_IND_CLR; + if (rx_irq_handler[id][type]) { + processed = rx_irq_handler[id][type](msg_ptr->data, msg_ptr->len); + // Check if flow control needed + if (processed < msg_ptr->len) { + recv_pending_head[id].next = msg_ptr->next; + recv_pending_head[id].type = msg_ptr->type; + recv_pending_head[id].len = msg_ptr->len - processed; + recv_pending_head[id].data = msg_ptr->data + processed; + break; + } } else { - cmu->ISIRQ_CLR = CMU_BT2MCU_DATA1_DONE_CLR | CMU_MCU2BT_DATA1_IND_CLR; + // Error + ASSERT(false, "INTERSYS-RX: Handler missing"); + break; } - *bt_recv_msg_list_ppp[id] = &send_msg_list_p[id]; + msg_ptr = msg_ptr->next; + } - NVIC_SetVector(rx_irq_id[id], (uint32_t)hal_intersys_rx_irq); - NVIC_SetPriority(rx_irq_id[id], IRQ_PRIORITY_NORMAL); - - NVIC_SetVector(tx_irq_id[id], (uint32_t)hal_intersys_tx_irq); - NVIC_SetPriority(tx_irq_id[id], IRQ_PRIORITY_NORMAL); - - // Stop IRQs by default - NVIC_DisableIRQ(rx_irq_id[id]); - NVIC_DisableIRQ(tx_irq_id[id]); - - send_msg_list_p[id] = NULL; - send_pending_list_p[id] = NULL; + if (msg_ptr == NULL) { + if (!need_flow_ctrl[id]) { + hal_intersys_peer_irq_set(id, HAL_INTERSYS_IRQ_RECV_DONE); + } recv_pending_head[id].data = NULL; - for (i = 0; i < MAX_SEND_RECORD_COUNT; i++) { - send_msgs[id][i].in_use = false; + } + } + } +} + +static void hal_intersys_tx_irq(void) { + int id; + struct HAL_INTERSYS_MSG_T *msg_ptr; + enum HAL_INTERSYS_MSG_TYPE_T type; + + for (id = HAL_INTERSYS_ID_0; id < HAL_INTERSYS_ID_QTY; id++) { + if (NVIC_GetActive(tx_irq_id[id])) { + hal_intersys_local_irq_clear(id, HAL_INTERSYS_IRQ_RECV_DONE); + + msg_ptr = send_msg_list_p[id]; + while (msg_ptr) { + type = msg_ptr->type; + if (type >= HAL_INTERSYS_MSG_TYPE_QTY) { + // Error + ASSERT(false, "INTERSYS-TX: Invalid msg type: %d", type); + break; } - need_flow_ctrl[id] = rx_flowctrl; + if (tx_irq_handler[id][type]) { + tx_irq_handler[id][type](msg_ptr->data, msg_ptr->len); + }; + CONTAINER_OF(msg_ptr, struct HAL_INTERSYS_SEND_RECORD_T, msg)->in_use = + false; + msg_ptr = msg_ptr->next; + } + + if (send_pending_list_p[id]) { + send_msg_list_p[id] = send_pending_list_p[id]; + send_pending_list_p[id] = NULL; + hal_intersys_peer_irq_set(id, HAL_INTERSYS_IRQ_SEND_IND); + } else { + send_msg_list_p[id] = NULL; + // Allow sleep + hal_intersys_busy(id, false); + } + } + } +} + +int hal_intersys_open(enum HAL_INTERSYS_ID_T id, + enum HAL_INTERSYS_MSG_TYPE_T type, + HAL_INTERSYS_RX_IRQ_HANDLER rxhandler, + HAL_INTERSYS_TX_IRQ_HANDLER txhandler, bool rx_flowctrl) { + int i; + + if (id >= HAL_INTERSYS_ID_QTY) { + return 1; + } + if (type >= HAL_INTERSYS_MSG_TYPE_QTY) { + return 2; + } + + if (chan_opened[id] == 0) { + if (id == HAL_INTERSYS_ID_0) { + cmu->ISIRQ_CLR = CMU_BT2MCU_DATA_DONE_CLR | CMU_MCU2BT_DATA_IND_CLR; } else { - ASSERT(need_flow_ctrl[id] == rx_flowctrl, "INTERSYS-OPEN: rx_flowctrl=%d (should be %d)", rx_flowctrl, need_flow_ctrl[id]); - return 3; + cmu->ISIRQ_CLR = CMU_BT2MCU_DATA1_DONE_CLR | CMU_MCU2BT_DATA1_IND_CLR; } - chan_opened[id] |= (1 << type); + *bt_recv_msg_list_ppp[id] = &send_msg_list_p[id]; - rx_irq_handler[id][type] = rxhandler; - tx_irq_handler[id][type] = txhandler; + NVIC_SetVector(rx_irq_id[id], (uint32_t)hal_intersys_rx_irq); + NVIC_SetPriority(rx_irq_id[id], IRQ_PRIORITY_NORMAL); - return 0; -} - -int hal_intersys_close(enum HAL_INTERSYS_ID_T id,enum HAL_INTERSYS_MSG_TYPE_T type) -{ - if (id >= HAL_INTERSYS_ID_QTY) { - return 1; - } - - chan_opened[id] &= ~(1 << type); - rx_irq_handler[id][type] = NULL; - tx_irq_handler[id][type] = NULL; - - if (chan_opened[id] == 0) { - // Stop IRQs by default - NVIC_DisableIRQ(rx_irq_id[id]); - NVIC_DisableIRQ(tx_irq_id[id]); - - send_msg_list_p[id] = NULL; - send_pending_list_p[id] = NULL; - recv_pending_head[id].data = NULL; - need_flow_ctrl[id] = false; - } - - return 0; -} - -int hal_intersys_start_recv(enum HAL_INTERSYS_ID_T id) -{ - if (id >= HAL_INTERSYS_ID_QTY) { - return 1; - } - - NVIC_EnableIRQ(rx_irq_id[id]); - // Check if there is any previous unprocessed message - if (recv_pending_head[id].data) { - hal_intersys_local_irq_set(id, HAL_INTERSYS_IRQ_SEND_IND); - } - return 0; -} - -int hal_intersys_stop_recv(enum HAL_INTERSYS_ID_T id) -{ - if (id >= HAL_INTERSYS_ID_QTY) { - return 1; - } + NVIC_SetVector(tx_irq_id[id], (uint32_t)hal_intersys_tx_irq); + NVIC_SetPriority(tx_irq_id[id], IRQ_PRIORITY_NORMAL); + // Stop IRQs by default NVIC_DisableIRQ(rx_irq_id[id]); - return 0; -} + NVIC_DisableIRQ(tx_irq_id[id]); -int hal_intersys_send(enum HAL_INTERSYS_ID_T id, enum HAL_INTERSYS_MSG_TYPE_T type, - const unsigned char *data, unsigned int len) -{ - uint32_t lock; - int ret; - struct HAL_INTERSYS_SEND_RECORD_T *record; - struct HAL_INTERSYS_MSG_T *next; - int i; - - if (id >= HAL_INTERSYS_ID_QTY) { - return 1; - } - if (type >= HAL_INTERSYS_MSG_TYPE_QTY) { - return 2; - } - if ((chan_opened[id] & (1 << type)) == 0) { - return 3; - } - - NVIC_EnableIRQ(tx_irq_id[id]); - - ret = -1; - record = &send_msgs[id][0]; - - lock = int_lock(); + send_msg_list_p[id] = NULL; + send_pending_list_p[id] = NULL; + recv_pending_head[id].data = NULL; for (i = 0; i < MAX_SEND_RECORD_COUNT; i++) { - if (record->in_use) { - record++; - continue; - } - record->in_use = true; - record->msg.next = NULL; - record->msg.type = type; - record->msg.len = len; - record->msg.data = data; - if (send_msg_list_p[id] == NULL) { - send_msg_list_p[id] = &record->msg; - hal_intersys_peer_irq_set(id, HAL_INTERSYS_IRQ_SEND_IND); - } else if (send_pending_list_p[id] == NULL) { - send_pending_list_p[id] = &record->msg; - } else { - next = send_pending_list_p[id]; - while (next->next) { - next = next->next; - } - next->next = &record->msg; - } - ret = 0; - // Prohibit sleep here - hal_intersys_busy(id, true); - break; + send_msgs[id][i].in_use = false; } - int_unlock(lock); + need_flow_ctrl[id] = rx_flowctrl; + } else { + ASSERT(need_flow_ctrl[id] == rx_flowctrl, + "INTERSYS-OPEN: rx_flowctrl=%d (should be %d)", rx_flowctrl, + need_flow_ctrl[id]); + return 3; + } + chan_opened[id] |= (1 << type); - return ret; + rx_irq_handler[id][type] = rxhandler; + tx_irq_handler[id][type] = txhandler; + + return 0; } -void hal_intersys_rx_done(enum HAL_INTERSYS_ID_T id) -{ - hal_intersys_peer_irq_set(id, HAL_INTERSYS_IRQ_RECV_DONE); +int hal_intersys_close(enum HAL_INTERSYS_ID_T id, + enum HAL_INTERSYS_MSG_TYPE_T type) { + if (id >= HAL_INTERSYS_ID_QTY) { + return 1; + } + + chan_opened[id] &= ~(1 << type); + rx_irq_handler[id][type] = NULL; + tx_irq_handler[id][type] = NULL; + + if (chan_opened[id] == 0) { + // Stop IRQs by default + NVIC_DisableIRQ(rx_irq_id[id]); + NVIC_DisableIRQ(tx_irq_id[id]); + + send_msg_list_p[id] = NULL; + send_pending_list_p[id] = NULL; + recv_pending_head[id].data = NULL; + need_flow_ctrl[id] = false; + } + + return 0; +} + +int hal_intersys_start_recv(enum HAL_INTERSYS_ID_T id) { + if (id >= HAL_INTERSYS_ID_QTY) { + return 1; + } + + NVIC_EnableIRQ(rx_irq_id[id]); + // Check if there is any previous unprocessed message + if (recv_pending_head[id].data) { + hal_intersys_local_irq_set(id, HAL_INTERSYS_IRQ_SEND_IND); + } + return 0; +} + +int hal_intersys_stop_recv(enum HAL_INTERSYS_ID_T id) { + if (id >= HAL_INTERSYS_ID_QTY) { + return 1; + } + + NVIC_DisableIRQ(rx_irq_id[id]); + return 0; +} + +int hal_intersys_send(enum HAL_INTERSYS_ID_T id, + enum HAL_INTERSYS_MSG_TYPE_T type, + const unsigned char *data, unsigned int len) { + uint32_t lock; + int ret; + struct HAL_INTERSYS_SEND_RECORD_T *record; + struct HAL_INTERSYS_MSG_T *next; + int i; + + if (id >= HAL_INTERSYS_ID_QTY) { + return 1; + } + if (type >= HAL_INTERSYS_MSG_TYPE_QTY) { + return 2; + } + if ((chan_opened[id] & (1 << type)) == 0) { + return 3; + } + + NVIC_EnableIRQ(tx_irq_id[id]); + + ret = -1; + record = &send_msgs[id][0]; + + lock = int_lock(); + for (i = 0; i < MAX_SEND_RECORD_COUNT; i++) { + if (record->in_use) { + record++; + continue; + } + record->in_use = true; + record->msg.next = NULL; + record->msg.type = type; + record->msg.len = len; + record->msg.data = data; + if (send_msg_list_p[id] == NULL) { + send_msg_list_p[id] = &record->msg; + hal_intersys_peer_irq_set(id, HAL_INTERSYS_IRQ_SEND_IND); + } else if (send_pending_list_p[id] == NULL) { + send_pending_list_p[id] = &record->msg; + } else { + next = send_pending_list_p[id]; + while (next->next) { + next = next->next; + } + next->next = &record->msg; + } + ret = 0; + // Prohibit sleep here + hal_intersys_busy(id, true); + break; + } + int_unlock(lock); + + return ret; +} + +void hal_intersys_rx_done(enum HAL_INTERSYS_ID_T id) { + hal_intersys_peer_irq_set(id, HAL_INTERSYS_IRQ_RECV_DONE); } #endif @@ -524,32 +538,28 @@ void hal_intersys_rx_done(enum HAL_INTERSYS_ID_T id) #ifdef TX_RX_PCM_MASK static FRAME2BUFF_HANDLER DecQ; -void hal_intersys_mic_rx_irq() -{ - int id; - id = HAL_INTERSYS_ID_1; - if(NVIC_GetActive(rx_irq_id[id])) - { - hal_intersys_local_irq_clear(id, HAL_INTERSYS_IRQ_SEND_IND); - //TRACE(0,"HAL_INTERSYS_ID_1 CLEAR"); - //output data to buff - DecQ(); - } +void hal_intersys_mic_rx_irq() { + int id; + id = HAL_INTERSYS_ID_1; + if (NVIC_GetActive(rx_irq_id[id])) { + hal_intersys_local_irq_clear(id, HAL_INTERSYS_IRQ_SEND_IND); + // TRACE(0,"HAL_INTERSYS_ID_1 CLEAR"); + // output data to buff + DecQ(); + } } -int hal_intersys_mic_open(enum HAL_INTERSYS_ID_T id, FRAME2BUFF_HANDLER dch) -{ - // if(btdrv_is_pcm_mask_enable()==1) - { - DecQ= dch; - NVIC_EnableIRQ(rx_irq_id[id]); - if(id == HAL_INTERSYS_ID_1) - { - cmu->ISIRQ_CLR = CMU_BT2MCU_DATA1_DONE_CLR | CMU_MCU2BT_DATA1_IND_CLR; - NVIC_SetVector(rx_irq_id[id], (uint32_t)hal_intersys_mic_rx_irq); - NVIC_SetPriority(rx_irq_id[id], IRQ_PRIORITY_NORMAL); - } +int hal_intersys_mic_open(enum HAL_INTERSYS_ID_T id, FRAME2BUFF_HANDLER dch) { + // if(btdrv_is_pcm_mask_enable()==1) + { + DecQ = dch; + NVIC_EnableIRQ(rx_irq_id[id]); + if (id == HAL_INTERSYS_ID_1) { + cmu->ISIRQ_CLR = CMU_BT2MCU_DATA1_DONE_CLR | CMU_MCU2BT_DATA1_IND_CLR; + NVIC_SetVector(rx_irq_id[id], (uint32_t)hal_intersys_mic_rx_irq); + NVIC_SetPriority(rx_irq_id[id], IRQ_PRIORITY_NORMAL); } - return 0; + } + return 0; } #endif diff --git a/platform/hal/hal_key.c b/platform/hal/hal_key.c index bec42c9..13238dc 100644 --- a/platform/hal/hal_key.c +++ b/platform/hal/hal_key.c @@ -13,24 +13,25 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_addr_map.h" -#include "plat_types.h" -#include "string.h" -#include "hal_iomux.h" -#include "hal_timer.h" -#include "hwtimer_list.h" -#include "hal_sleep.h" -#include "hal_trace.h" -#include "hal_chipid.h" #include "hal_key.h" #include "cmsis_nvic.h" +#include "hal_chipid.h" +#include "hal_iomux.h" +#include "hal_sleep.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hwtimer_list.h" +#include "plat_addr_map.h" +#include "plat_types.h" #include "pmu.h" +#include "string.h" #include "tgt_hardware.h" #ifdef KEY_DEBUG -#define HAL_KEY_TRACE(n, s, ...) TRACE(n, "[%u]" s, TICKS_TO_MS(hal_sys_timer_get()), ##__VA_ARGS__) +#define HAL_KEY_TRACE(n, s, ...) \ + TRACE(n, "[%u]" s, TICKS_TO_MS(hal_sys_timer_get()), ##__VA_ARGS__) #else -#define HAL_KEY_TRACE(n, s, ...) TRACE_DUMMY(n, s, ##__VA_ARGS__) +#define HAL_KEY_TRACE(n, s, ...) TRACE_DUMMY(n, s, ##__VA_ARGS__) #endif #ifdef CHIP_BEST2000 @@ -38,9 +39,9 @@ #endif #ifdef GPIO_MAP_64BIT -typedef uint64_t GPIO_MAP_T; +typedef uint64_t GPIO_MAP_T; #else -typedef uint32_t GPIO_MAP_T; +typedef uint32_t GPIO_MAP_T; #endif // #ifndef APP_TEST_MODE @@ -51,87 +52,89 @@ typedef uint32_t GPIO_MAP_T; #endif #ifdef NO_GPIOKEY #undef CFG_HW_GPIOKEY_NUM -#define CFG_HW_GPIOKEY_NUM 0 +#define CFG_HW_GPIOKEY_NUM 0 #endif #ifdef NO_ADCKEY #undef CFG_HW_ADCKEY_NUMBER -#define CFG_HW_ADCKEY_NUMBER 0 +#define CFG_HW_ADCKEY_NUMBER 0 #endif #ifndef CFG_SW_KEY_LLPRESS_THRESH_MS -#define CFG_SW_KEY_LLPRESS_THRESH_MS 5000 +#define CFG_SW_KEY_LLPRESS_THRESH_MS 5000 #endif #ifndef CFG_SW_KEY_LPRESS_THRESH_MS -#define CFG_SW_KEY_LPRESS_THRESH_MS 1500 +#define CFG_SW_KEY_LPRESS_THRESH_MS 1500 #endif #ifndef CFG_SW_KEY_REPEAT_THRESH_MS -#define CFG_SW_KEY_REPEAT_THRESH_MS 500 +#define CFG_SW_KEY_REPEAT_THRESH_MS 500 #endif #ifndef CFG_SW_KEY_DBLCLICK_THRESH_MS -#define CFG_SW_KEY_DBLCLICK_THRESH_MS 400 +#define CFG_SW_KEY_DBLCLICK_THRESH_MS 400 #endif #ifndef CFG_SW_KEY_INIT_DOWN_THRESH_MS -#define CFG_SW_KEY_INIT_DOWN_THRESH_MS 200 +#define CFG_SW_KEY_INIT_DOWN_THRESH_MS 200 #endif #ifndef CFG_SW_KEY_INIT_LPRESS_THRESH_MS -#define CFG_SW_KEY_INIT_LPRESS_THRESH_MS 3000 +#define CFG_SW_KEY_INIT_LPRESS_THRESH_MS 3000 #endif #ifndef CFG_SW_KEY_INIT_LLPRESS_THRESH_MS -#define CFG_SW_KEY_INIT_LLPRESS_THRESH_MS 10000 +#define CFG_SW_KEY_INIT_LLPRESS_THRESH_MS 10000 #endif #ifndef CFG_SW_KEY_CHECK_INTERVAL_MS -#define CFG_SW_KEY_CHECK_INTERVAL_MS 40 +#define CFG_SW_KEY_CHECK_INTERVAL_MS 40 #endif -//common key define -#define KEY_LONGLONGPRESS_THRESHOLD MS_TO_TICKS(CFG_SW_KEY_LLPRESS_THRESH_MS) -#define KEY_LONGPRESS_THRESHOLD MS_TO_TICKS(CFG_SW_KEY_LPRESS_THRESH_MS) -#define KEY_DOUBLECLICK_THRESHOLD MS_TO_TICKS(CFG_SW_KEY_DBLCLICK_THRESH_MS) -#define KEY_LONGPRESS_REPEAT_THRESHOLD MS_TO_TICKS(CFG_SW_KEY_REPEAT_THRESH_MS) +// common key define +#define KEY_LONGLONGPRESS_THRESHOLD MS_TO_TICKS(CFG_SW_KEY_LLPRESS_THRESH_MS) +#define KEY_LONGPRESS_THRESHOLD MS_TO_TICKS(CFG_SW_KEY_LPRESS_THRESH_MS) +#define KEY_DOUBLECLICK_THRESHOLD MS_TO_TICKS(CFG_SW_KEY_DBLCLICK_THRESH_MS) +#define KEY_LONGPRESS_REPEAT_THRESHOLD MS_TO_TICKS(CFG_SW_KEY_REPEAT_THRESH_MS) -#define KEY_INIT_DOWN_THRESHOLD MS_TO_TICKS(CFG_SW_KEY_INIT_DOWN_THRESH_MS) -#define KEY_INIT_LONGPRESS_THRESHOLD MS_TO_TICKS(CFG_SW_KEY_INIT_LPRESS_THRESH_MS) -#define KEY_INIT_LONGLONGPRESS_THRESHOLD MS_TO_TICKS(CFG_SW_KEY_INIT_LLPRESS_THRESH_MS) +#define KEY_INIT_DOWN_THRESHOLD MS_TO_TICKS(CFG_SW_KEY_INIT_DOWN_THRESH_MS) +#define KEY_INIT_LONGPRESS_THRESHOLD \ + MS_TO_TICKS(CFG_SW_KEY_INIT_LPRESS_THRESH_MS) +#define KEY_INIT_LONGLONGPRESS_THRESHOLD \ + MS_TO_TICKS(CFG_SW_KEY_INIT_LLPRESS_THRESH_MS) -#define KEY_CHECKER_INTERVAL MS_TO_TICKS(CFG_SW_KEY_CHECK_INTERVAL_MS) +#define KEY_CHECKER_INTERVAL MS_TO_TICKS(CFG_SW_KEY_CHECK_INTERVAL_MS) -#define KEY_DEBOUNCE_INTERVAL (KEY_CHECKER_INTERVAL * 2) -#define KEY_DITHER_INTERVAL (KEY_CHECKER_INTERVAL * 1) +#define KEY_DEBOUNCE_INTERVAL (KEY_CHECKER_INTERVAL * 2) +#define KEY_DITHER_INTERVAL (KEY_CHECKER_INTERVAL * 1) -#define MAX_KEY_CLICK_COUNT (HAL_KEY_EVENT_RAMPAGECLICK - HAL_KEY_EVENT_CLICK) +#define MAX_KEY_CLICK_COUNT (HAL_KEY_EVENT_RAMPAGECLICK - HAL_KEY_EVENT_CLICK) struct HAL_KEY_ADCKEY_T { - bool debounce; - bool dither; - enum HAL_KEY_CODE_T code_debounce; - enum HAL_KEY_CODE_T code_down; - uint32_t time; + bool debounce; + bool dither; + enum HAL_KEY_CODE_T code_debounce; + enum HAL_KEY_CODE_T code_down; + uint32_t time; }; struct HAL_KEY_GPIOKEY_T { - GPIO_MAP_T pin_debounce; - GPIO_MAP_T pin_dither; - GPIO_MAP_T pin_down; - uint32_t time_debounce; - uint32_t time_dither; + GPIO_MAP_T pin_debounce; + GPIO_MAP_T pin_dither; + GPIO_MAP_T pin_down; + uint32_t time_debounce; + uint32_t time_dither; }; struct HAL_KEY_PWRKEY_T { - bool debounce; - bool dither; - bool pressed; - uint32_t time; + bool debounce; + bool dither; + bool pressed; + uint32_t time; }; struct HAL_KEY_STATUS_T { - enum HAL_KEY_CODE_T code_down; - enum HAL_KEY_CODE_T code_ready; - enum HAL_KEY_CODE_T code_click; - enum HAL_KEY_EVENT_T event; - uint32_t time_updown; - uint32_t time_click; - uint8_t cnt_repeat; - uint8_t cnt_click; + enum HAL_KEY_CODE_T code_down; + enum HAL_KEY_CODE_T code_ready; + enum HAL_KEY_CODE_T code_click; + enum HAL_KEY_EVENT_T event; + uint32_t time_updown; + uint32_t time_click; + uint8_t cnt_repeat; + uint8_t cnt_click; }; static int (*key_detected_callback)(uint32_t, uint8_t) = NULL; @@ -142,71 +145,63 @@ static struct HAL_KEY_STATUS_T key_status; static void hal_key_disable_allint(void); static void hal_key_enable_allint(void); -static int send_key_event(enum HAL_KEY_CODE_T code, enum HAL_KEY_EVENT_T event) -{ - if (key_detected_callback) { - return key_detected_callback(code, event); - } - return 0; +static int send_key_event(enum HAL_KEY_CODE_T code, + enum HAL_KEY_EVENT_T event) { + if (key_detected_callback) { + return key_detected_callback(code, event); + } + return 0; } -static void hal_key_debounce_timer_restart(void) -{ - uint32_t lock; - bool set = false; +static void hal_key_debounce_timer_restart(void) { + uint32_t lock; + bool set = false; - lock = int_lock(); - if (!timer_active) { - timer_active = true; - set = true; - } - int_unlock(lock); + lock = int_lock(); + if (!timer_active) { + timer_active = true; + set = true; + } + int_unlock(lock); - if (set) { - hwtimer_stop(debounce_timer); - hwtimer_start(debounce_timer, KEY_CHECKER_INTERVAL); - //hal_sys_wake_lock(HAL_SYS_WAKE_LOCK_USER_KEY); - } + if (set) { + hwtimer_stop(debounce_timer); + hwtimer_start(debounce_timer, KEY_CHECKER_INTERVAL); + // hal_sys_wake_lock(HAL_SYS_WAKE_LOCK_USER_KEY); + } } #if (CFG_HW_ADCKEY_NUMBER > 0) static uint16_t adckey_volt_table[CFG_HW_ADCKEY_NUMBER]; struct HAL_KEY_ADCKEY_T adc_key; -static inline POSSIBLY_UNUSED void hal_adckey_enable_press_int(void) -{ - hal_adckey_set_irq(HAL_ADCKEY_IRQ_PRESSED); +static inline POSSIBLY_UNUSED void hal_adckey_enable_press_int(void) { + hal_adckey_set_irq(HAL_ADCKEY_IRQ_PRESSED); } -static inline POSSIBLY_UNUSED void hal_adckey_enable_release_int(void) -{ - hal_adckey_set_irq(HAL_ADCKEY_IRQ_RELEASED); +static inline POSSIBLY_UNUSED void hal_adckey_enable_release_int(void) { + hal_adckey_set_irq(HAL_ADCKEY_IRQ_RELEASED); } -static inline POSSIBLY_UNUSED void hal_adckey_enable_adc_int(void) -{ - hal_gpadc_open(HAL_GPADC_CHAN_ADCKEY, HAL_GPADC_ATP_NULL, NULL); +static inline POSSIBLY_UNUSED void hal_adckey_enable_adc_int(void) { + hal_gpadc_open(HAL_GPADC_CHAN_ADCKEY, HAL_GPADC_ATP_NULL, NULL); } -static inline POSSIBLY_UNUSED void hal_adckey_disable_adc_int(void) -{ - hal_gpadc_close(HAL_GPADC_CHAN_ADCKEY); +static inline POSSIBLY_UNUSED void hal_adckey_disable_adc_int(void) { + hal_gpadc_close(HAL_GPADC_CHAN_ADCKEY); } -static inline POSSIBLY_UNUSED void hal_adckey_disable_allint(void) -{ - hal_gpadc_close(HAL_GPADC_CHAN_ADCKEY); - hal_adckey_set_irq(HAL_ADCKEY_IRQ_NONE); +static inline POSSIBLY_UNUSED void hal_adckey_disable_allint(void) { + hal_gpadc_close(HAL_GPADC_CHAN_ADCKEY); + hal_adckey_set_irq(HAL_ADCKEY_IRQ_NONE); } -static inline POSSIBLY_UNUSED void hal_adckey_reset(void) -{ - memset(&adc_key, 0, sizeof(adc_key)); +static inline POSSIBLY_UNUSED void hal_adckey_reset(void) { + memset(&adc_key, 0, sizeof(adc_key)); } -static enum HAL_KEY_CODE_T hal_adckey_findkey(uint16_t volt) -{ - int index = 0; +static enum HAL_KEY_CODE_T hal_adckey_findkey(uint16_t volt) { + int index = 0; #if 0 if (volt == HAL_GPADC_BAD_VALUE) { @@ -214,242 +209,232 @@ static enum HAL_KEY_CODE_T hal_adckey_findkey(uint16_t volt) } #endif - if (CFG_HW_ADCKEY_ADC_KEYVOLT_BASE < volt && volt < CFG_HW_ADCKEY_ADC_MAXVOLT) { - for (index = 0; index < CFG_HW_ADCKEY_NUMBER; index++) { - if (volt <= adckey_volt_table[index]) { - return CFG_HW_ADCKEY_MAP_TABLE[index]; - } - } + if (CFG_HW_ADCKEY_ADC_KEYVOLT_BASE < volt && + volt < CFG_HW_ADCKEY_ADC_MAXVOLT) { + for (index = 0; index < CFG_HW_ADCKEY_NUMBER; index++) { + if (volt <= adckey_volt_table[index]) { + return CFG_HW_ADCKEY_MAP_TABLE[index]; + } } + } - return HAL_KEY_CODE_NONE; + return HAL_KEY_CODE_NONE; } -static void hal_adckey_irqhandler(enum HAL_ADCKEY_IRQ_STATUS_T irq_status, HAL_GPADC_MV_T val) -{ - enum HAL_KEY_CODE_T code; +static void hal_adckey_irqhandler(enum HAL_ADCKEY_IRQ_STATUS_T irq_status, + HAL_GPADC_MV_T val) { + enum HAL_KEY_CODE_T code; #ifdef NO_GROUPKEY - hal_key_disable_allint(); + hal_key_disable_allint(); #else - hal_adckey_disable_allint(); + hal_adckey_disable_allint(); #endif - if (irq_status & (HAL_ADCKEY_ERR0 | HAL_ADCKEY_ERR1)) { - HAL_KEY_TRACE(1,"irq,adckey err 0x%04X", irq_status); - adc_key.debounce = true; - adc_key.code_debounce = HAL_KEY_CODE_NONE; - goto _debounce; - } - if (irq_status & HAL_ADCKEY_PRESSED) { - HAL_KEY_TRACE(0,"irq,adckey press"); - adc_key.debounce = true; - adc_key.code_debounce = HAL_KEY_CODE_NONE; - adc_key.time = hal_sys_timer_get(); - hal_adckey_enable_adc_int(); - goto _exit; - } - if (irq_status & HAL_ADCKEY_RELEASED) { - HAL_KEY_TRACE(0,"irq,adckey release"); - adc_key.code_debounce = HAL_KEY_CODE_NONE; - goto _debounce; - } - if(irq_status & HAL_ADCKEY_ADC_VALID) { - code = hal_adckey_findkey(val); - HAL_KEY_TRACE(3,"irq,adckey cur:0x%X pre:0x%X volt:%d", code, adc_key.code_debounce, val); + if (irq_status & (HAL_ADCKEY_ERR0 | HAL_ADCKEY_ERR1)) { + HAL_KEY_TRACE(1, "irq,adckey err 0x%04X", irq_status); + adc_key.debounce = true; + adc_key.code_debounce = HAL_KEY_CODE_NONE; + goto _debounce; + } + if (irq_status & HAL_ADCKEY_PRESSED) { + HAL_KEY_TRACE(0, "irq,adckey press"); + adc_key.debounce = true; + adc_key.code_debounce = HAL_KEY_CODE_NONE; + adc_key.time = hal_sys_timer_get(); + hal_adckey_enable_adc_int(); + goto _exit; + } + if (irq_status & HAL_ADCKEY_RELEASED) { + HAL_KEY_TRACE(0, "irq,adckey release"); + adc_key.code_debounce = HAL_KEY_CODE_NONE; + goto _debounce; + } + if (irq_status & HAL_ADCKEY_ADC_VALID) { + code = hal_adckey_findkey(val); + HAL_KEY_TRACE(3, "irq,adckey cur:0x%X pre:0x%X volt:%d", code, + adc_key.code_debounce, val); - if (adc_key.code_debounce == HAL_KEY_CODE_NONE) { - adc_key.code_debounce = code; - } else if (adc_key.code_debounce != code) { - adc_key.code_debounce = HAL_KEY_CODE_NONE; - } + if (adc_key.code_debounce == HAL_KEY_CODE_NONE) { + adc_key.code_debounce = code; + } else if (adc_key.code_debounce != code) { + adc_key.code_debounce = HAL_KEY_CODE_NONE; } + } _debounce: - hal_key_debounce_timer_restart(); + hal_key_debounce_timer_restart(); _exit: - return; + return; } -static void hal_adckey_open(void) -{ - uint16_t i; - uint32_t basevolt; +static void hal_adckey_open(void) { + uint16_t i; + uint32_t basevolt; - HAL_KEY_TRACE(1,"%s\n", __func__); + HAL_KEY_TRACE(1, "%s\n", __func__); - hal_adckey_reset(); + hal_adckey_reset(); - basevolt = (CFG_HW_ADCKEY_ADC_MAXVOLT - CFG_HW_ADCKEY_ADC_MINVOLT) / (CFG_HW_ADCKEY_NUMBER + 2); + basevolt = (CFG_HW_ADCKEY_ADC_MAXVOLT - CFG_HW_ADCKEY_ADC_MINVOLT) / + (CFG_HW_ADCKEY_NUMBER + 2); - adckey_volt_table[0] = CFG_HW_ADCKEY_ADC_KEYVOLT_BASE + basevolt; + adckey_volt_table[0] = CFG_HW_ADCKEY_ADC_KEYVOLT_BASE + basevolt; - for(i = 1; i < CFG_HW_ADCKEY_NUMBER-1; i++) { - adckey_volt_table[i] = adckey_volt_table[i - 1] + basevolt; - } - adckey_volt_table[CFG_HW_ADCKEY_NUMBER - 1] = CFG_HW_ADCKEY_ADC_MAXVOLT; + for (i = 1; i < CFG_HW_ADCKEY_NUMBER - 1; i++) { + adckey_volt_table[i] = adckey_volt_table[i - 1] + basevolt; + } + adckey_volt_table[CFG_HW_ADCKEY_NUMBER - 1] = CFG_HW_ADCKEY_ADC_MAXVOLT; - hal_adckey_set_irq_handler(hal_adckey_irqhandler); + hal_adckey_set_irq_handler(hal_adckey_irqhandler); } -static void hal_adckey_close(void) -{ - HAL_KEY_TRACE(1,"%s\n", __func__); +static void hal_adckey_close(void) { + HAL_KEY_TRACE(1, "%s\n", __func__); - hal_adckey_reset(); + hal_adckey_reset(); - hal_adckey_disable_allint(); + hal_adckey_disable_allint(); } #endif // (CFG_HW_ADCKEY_NUMBER > 0) #ifndef NO_PWRKEY struct HAL_KEY_PWRKEY_T pwr_key; -static inline POSSIBLY_UNUSED void hal_pwrkey_enable_riseedge_int(void) -{ - hal_pwrkey_set_irq(HAL_PWRKEY_IRQ_RISING_EDGE); +static inline POSSIBLY_UNUSED void hal_pwrkey_enable_riseedge_int(void) { + hal_pwrkey_set_irq(HAL_PWRKEY_IRQ_RISING_EDGE); } -static inline POSSIBLY_UNUSED void hal_pwrkey_enable_falledge_int(void) -{ - hal_pwrkey_set_irq(HAL_PWRKEY_IRQ_FALLING_EDGE); +static inline POSSIBLY_UNUSED void hal_pwrkey_enable_falledge_int(void) { + hal_pwrkey_set_irq(HAL_PWRKEY_IRQ_FALLING_EDGE); } -static inline POSSIBLY_UNUSED void hal_pwrkey_enable_bothedge_int(void) -{ - hal_pwrkey_set_irq(HAL_PWRKEY_IRQ_BOTH_EDGE); +static inline POSSIBLY_UNUSED void hal_pwrkey_enable_bothedge_int(void) { + hal_pwrkey_set_irq(HAL_PWRKEY_IRQ_BOTH_EDGE); } -static inline void hal_pwrkey_enable_int(void) -{ +static inline void hal_pwrkey_enable_int(void) { #ifdef __POWERKEY_CTRL_ONOFF_ONLY__ - hal_pwrkey_enable_riseedge_int(); + hal_pwrkey_enable_riseedge_int(); #else - hal_pwrkey_enable_falledge_int(); + hal_pwrkey_enable_falledge_int(); #endif } -static inline void hal_pwrkey_disable_int(void) -{ - hal_pwrkey_set_irq(HAL_PWRKEY_IRQ_NONE); +static inline void hal_pwrkey_disable_int(void) { + hal_pwrkey_set_irq(HAL_PWRKEY_IRQ_NONE); } -static inline void hal_pwrkey_reset(void) -{ - memset(&pwr_key, 0, sizeof(pwr_key)); +static inline void hal_pwrkey_reset(void) { + memset(&pwr_key, 0, sizeof(pwr_key)); } -static inline bool hal_pwrkey_get_status(void) -{ +static inline bool hal_pwrkey_get_status(void) { #ifdef CHIP_BEST1000 - if (hal_get_chip_metal_id() < HAL_CHIP_METAL_ID_2) { - return pwr_key.pressed; - } else + if (hal_get_chip_metal_id() < HAL_CHIP_METAL_ID_2) { + return pwr_key.pressed; + } else #endif - { - return hal_pwrkey_pressed(); - } + { + return hal_pwrkey_pressed(); + } } -static void hal_pwrkey_handle_irq_state(enum HAL_PWRKEY_IRQ_T state) -{ -// uint32_t time = hal_sys_timer_get(); +static void hal_pwrkey_handle_irq_state(enum HAL_PWRKEY_IRQ_T state) { + // uint32_t time = hal_sys_timer_get(); #ifdef NO_GROUPKEY - hal_key_disable_allint(); + hal_key_disable_allint(); #else - hal_pwrkey_disable_int(); + hal_pwrkey_disable_int(); #endif #ifdef __POWERKEY_CTRL_ONOFF_ONLY__ - if (state & HAL_PWRKEY_IRQ_RISING_EDGE) { - HAL_KEY_TRACE(0,"pwr_key irq up"); - pwr_key.debounce = true; - } + if (state & HAL_PWRKEY_IRQ_RISING_EDGE) { + HAL_KEY_TRACE(0, "pwr_key irq up"); + pwr_key.debounce = true; + } #else // !__POWERKEY_CTRL_ONOFF_ONLY__ - if (state & HAL_PWRKEY_IRQ_FALLING_EDGE) { - HAL_KEY_TRACE(0,"pwr_key irq down"); + if (state & HAL_PWRKEY_IRQ_FALLING_EDGE) { + HAL_KEY_TRACE(0, "pwr_key irq down"); #ifdef CHIP_BEST1000 - if (hal_get_chip_metal_id() < HAL_CHIP_METAL_ID_2) { - pwr_key.debounce = true; - pwr_key.pressed = true; - hal_pwrkey_enable_riseedge_int(); - } else + if (hal_get_chip_metal_id() < HAL_CHIP_METAL_ID_2) { + pwr_key.debounce = true; + pwr_key.pressed = true; + hal_pwrkey_enable_riseedge_int(); + } else #endif - { - pwr_key.pressed = hal_pwrkey_pressed(); - if (pwr_key.pressed) { - pwr_key.debounce = true; - } else { - pwr_key.dither = true; - } - } - // pwr_key.time = time; + { + pwr_key.pressed = hal_pwrkey_pressed(); + if (pwr_key.pressed) { + pwr_key.debounce = true; + } else { + pwr_key.dither = true; + } } + // pwr_key.time = time; + } #ifdef CHIP_BEST1000 - if (state & HAL_PWRKEY_IRQ_RISING_EDGE) { - if (hal_get_chip_metal_id() < HAL_CHIP_METAL_ID_2) { - HAL_KEY_TRACE(0,"pwr_key irq up"); - pwr_key.pressed = false; - hal_pwrkey_enable_falledge_int(); - } + if (state & HAL_PWRKEY_IRQ_RISING_EDGE) { + if (hal_get_chip_metal_id() < HAL_CHIP_METAL_ID_2) { + HAL_KEY_TRACE(0, "pwr_key irq up"); + pwr_key.pressed = false; + hal_pwrkey_enable_falledge_int(); } + } #endif #endif // !__POWERKEY_CTRL_ONOFF_ONLY__ - hal_key_debounce_timer_restart(); + hal_key_debounce_timer_restart(); } #ifdef CHIP_HAS_EXT_PMU -#define PWRKEY_IRQ_HDLR_PARAM uint16_t irq_status +#define PWRKEY_IRQ_HDLR_PARAM uint16_t irq_status #else -#define PWRKEY_IRQ_HDLR_PARAM void +#define PWRKEY_IRQ_HDLR_PARAM void #endif -static void hal_pwrkey_irqhandler(PWRKEY_IRQ_HDLR_PARAM) -{ - enum HAL_PWRKEY_IRQ_T state; +static void hal_pwrkey_irqhandler(PWRKEY_IRQ_HDLR_PARAM) { + enum HAL_PWRKEY_IRQ_T state; #ifdef CHIP_HAS_EXT_PMU - state = pmu_pwrkey_irq_value_to_state(irq_status); + state = pmu_pwrkey_irq_value_to_state(irq_status); #else - state = hal_pwrkey_get_irq_state(); + state = hal_pwrkey_get_irq_state(); #endif - HAL_KEY_TRACE(2,"%s: %08x", __func__, state); + HAL_KEY_TRACE(2, "%s: %08x", __func__, state); - hal_pwrkey_handle_irq_state(state); + hal_pwrkey_handle_irq_state(state); } -static void hal_pwrkey_open(void) -{ - hal_pwrkey_reset(); +static void hal_pwrkey_open(void) { + hal_pwrkey_reset(); #ifdef CHIP_HAS_EXT_PMU - pmu_set_irq_unified_handler(PMU_IRQ_TYPE_PWRKEY, hal_pwrkey_irqhandler); + pmu_set_irq_unified_handler(PMU_IRQ_TYPE_PWRKEY, hal_pwrkey_irqhandler); #else - NVIC_SetVector(PWRKEY_IRQn, (uint32_t)hal_pwrkey_irqhandler); - NVIC_SetPriority(PWRKEY_IRQn, IRQ_PRIORITY_NORMAL); - NVIC_ClearPendingIRQ(PWRKEY_IRQn); - NVIC_EnableIRQ(PWRKEY_IRQn); + NVIC_SetVector(PWRKEY_IRQn, (uint32_t)hal_pwrkey_irqhandler); + NVIC_SetPriority(PWRKEY_IRQn, IRQ_PRIORITY_NORMAL); + NVIC_ClearPendingIRQ(PWRKEY_IRQn); + NVIC_EnableIRQ(PWRKEY_IRQn); #endif } -static void hal_pwrkey_close(void) -{ - hal_pwrkey_reset(); +static void hal_pwrkey_close(void) { + hal_pwrkey_reset(); - hal_pwrkey_disable_int(); + hal_pwrkey_disable_int(); #ifdef CHIP_HAS_EXT_PMU - pmu_set_irq_unified_handler(PMU_IRQ_TYPE_PWRKEY, NULL); + pmu_set_irq_unified_handler(PMU_IRQ_TYPE_PWRKEY, NULL); #else - NVIC_SetVector(PWRKEY_IRQn, (uint32_t)NULL); - NVIC_DisableIRQ(PWRKEY_IRQn); + NVIC_SetVector(PWRKEY_IRQn, (uint32_t)NULL); + NVIC_DisableIRQ(PWRKEY_IRQn); #endif } #endif // !NO_PWRKEY @@ -459,341 +444,337 @@ struct HAL_KEY_GPIOKEY_T gpio_key; static void hal_gpiokey_disable_irq(enum HAL_GPIO_PIN_T pin); -static inline void hal_gpiokey_reset(void) -{ - memset(&gpio_key, 0, sizeof(gpio_key)); +static inline void hal_gpiokey_reset(void) { + memset(&gpio_key, 0, sizeof(gpio_key)); } -static int hal_gpiokey_find_index(enum HAL_GPIO_PIN_T pin) -{ - int i; +static int hal_gpiokey_find_index(enum HAL_GPIO_PIN_T pin) { + int i; - for (i = 0; i < CFG_HW_GPIOKEY_NUM; i++) { - if (cfg_hw_gpio_key_cfg[i].key_config.pin == (enum HAL_IOMUX_PIN_T)pin) { - return i; - } + for (i = 0; i < CFG_HW_GPIOKEY_NUM; i++) { + if (cfg_hw_gpio_key_cfg[i].key_config.pin == (enum HAL_IOMUX_PIN_T)pin) { + return i; } + } - ASSERT(i < CFG_HW_GPIOKEY_NUM, "GPIOKEY IRQ: Invalid pin=%d", pin); - return i; + ASSERT(i < CFG_HW_GPIOKEY_NUM, "GPIOKEY IRQ: Invalid pin=%d", pin); + return i; } -static bool hal_gpiokey_pressed(enum HAL_GPIO_PIN_T pin) -{ - int i = hal_gpiokey_find_index(pin); - return (hal_gpio_pin_get_val(pin) == cfg_hw_gpio_key_cfg[i].key_down); +static bool hal_gpiokey_pressed(enum HAL_GPIO_PIN_T pin) { + int i = hal_gpiokey_find_index(pin); + return (hal_gpio_pin_get_val(pin) == cfg_hw_gpio_key_cfg[i].key_down); } -static void hal_gpiokey_irqhandler(enum HAL_GPIO_PIN_T pin) -{ - bool pressed; - uint32_t lock; - uint32_t time; +static void hal_gpiokey_irqhandler(enum HAL_GPIO_PIN_T pin) { + bool pressed; + uint32_t lock; + uint32_t time; #ifdef NO_GROUPKEY - hal_key_disable_allint(); + hal_key_disable_allint(); #else - hal_gpiokey_disable_irq(pin); + hal_gpiokey_disable_irq(pin); #endif - pressed = hal_gpiokey_pressed(pin); - HAL_KEY_TRACE(2,"gpio_key trig=%d pressed=%d", pin, pressed); + pressed = hal_gpiokey_pressed(pin); + HAL_KEY_TRACE(2, "gpio_key trig=%d pressed=%d", pin, pressed); - time = hal_sys_timer_get(); + time = hal_sys_timer_get(); - lock = int_lock(); - if (pressed) { - gpio_key.pin_debounce |= ((GPIO_MAP_T)1 << pin); - gpio_key.time_debounce = time; + lock = int_lock(); + if (pressed) { + gpio_key.pin_debounce |= ((GPIO_MAP_T)1 << pin); + gpio_key.time_debounce = time; + } else { + gpio_key.pin_dither |= ((GPIO_MAP_T)1 << pin); + gpio_key.time_dither = time; + } + int_unlock(lock); + + hal_key_debounce_timer_restart(); +} + +static void hal_gpiokey_enable_irq(enum HAL_GPIO_PIN_T pin, + enum HAL_GPIO_IRQ_POLARITY_T polarity) { + struct HAL_GPIO_IRQ_CFG_T gpiocfg; + + hal_gpio_pin_set_dir(pin, HAL_GPIO_DIR_IN, 0); + + gpiocfg.irq_enable = true; + gpiocfg.irq_debounce = true; + gpiocfg.irq_polarity = polarity; + gpiocfg.irq_handler = hal_gpiokey_irqhandler; + gpiocfg.irq_type = HAL_GPIO_IRQ_TYPE_LEVEL_SENSITIVE; + + hal_gpio_setup_irq(pin, &gpiocfg); +} + +static void hal_gpiokey_disable_irq(enum HAL_GPIO_PIN_T pin) { + static const struct HAL_GPIO_IRQ_CFG_T gpiocfg = { + .irq_enable = false, + .irq_debounce = false, + .irq_polarity = HAL_GPIO_IRQ_POLARITY_LOW_FALLING, + .irq_handler = NULL, + .irq_type = HAL_GPIO_IRQ_TYPE_LEVEL_SENSITIVE, + }; + + hal_gpio_setup_irq(pin, &gpiocfg); +} + +static inline void hal_gpiokey_enable_allint(void) { + uint8_t i; + enum HAL_GPIO_IRQ_POLARITY_T polarity; + + for (i = 0; i < CFG_HW_GPIOKEY_NUM; i++) { + if (cfg_hw_gpio_key_cfg[i].key_code == HAL_KEY_CODE_NONE) { + continue; + } + + if (cfg_hw_gpio_key_cfg[i].key_down == HAL_KEY_GPIOKEY_VAL_LOW) { + polarity = HAL_GPIO_IRQ_POLARITY_LOW_FALLING; } else { - gpio_key.pin_dither |= ((GPIO_MAP_T)1 << pin); - gpio_key.time_dither = time; + polarity = HAL_GPIO_IRQ_POLARITY_HIGH_RISING; } - int_unlock(lock); - - hal_key_debounce_timer_restart(); + hal_gpiokey_enable_irq( + (enum HAL_GPIO_PIN_T)cfg_hw_gpio_key_cfg[i].key_config.pin, polarity); + } } -static void hal_gpiokey_enable_irq(enum HAL_GPIO_PIN_T pin, enum HAL_GPIO_IRQ_POLARITY_T polarity) -{ - struct HAL_GPIO_IRQ_CFG_T gpiocfg; +static inline void hal_gpiokey_disable_allint(void) { + uint8_t i; - hal_gpio_pin_set_dir(pin, HAL_GPIO_DIR_IN, 0); - - gpiocfg.irq_enable = true; - gpiocfg.irq_debounce = true; - gpiocfg.irq_polarity = polarity; - gpiocfg.irq_handler = hal_gpiokey_irqhandler; - gpiocfg.irq_type = HAL_GPIO_IRQ_TYPE_LEVEL_SENSITIVE; - - hal_gpio_setup_irq(pin, &gpiocfg); -} - -static void hal_gpiokey_disable_irq(enum HAL_GPIO_PIN_T pin) -{ - static const struct HAL_GPIO_IRQ_CFG_T gpiocfg = { - .irq_enable = false, - .irq_debounce = false, - .irq_polarity = HAL_GPIO_IRQ_POLARITY_LOW_FALLING, - .irq_handler = NULL, - .irq_type = HAL_GPIO_IRQ_TYPE_LEVEL_SENSITIVE, - }; - - hal_gpio_setup_irq(pin, &gpiocfg); -} - -static inline void hal_gpiokey_enable_allint(void) -{ - uint8_t i; - enum HAL_GPIO_IRQ_POLARITY_T polarity; - - for (i = 0; i < CFG_HW_GPIOKEY_NUM; i++){ - if (cfg_hw_gpio_key_cfg[i].key_code == HAL_KEY_CODE_NONE) { - continue; - } - - if (cfg_hw_gpio_key_cfg[i].key_down == HAL_KEY_GPIOKEY_VAL_LOW) { - polarity = HAL_GPIO_IRQ_POLARITY_LOW_FALLING; - } else { - polarity = HAL_GPIO_IRQ_POLARITY_HIGH_RISING; - } - hal_gpiokey_enable_irq((enum HAL_GPIO_PIN_T)cfg_hw_gpio_key_cfg[i].key_config.pin, polarity); + for (i = 0; i < CFG_HW_GPIOKEY_NUM; i++) { + if (cfg_hw_gpio_key_cfg[i].key_code == HAL_KEY_CODE_NONE) { + continue; } + + hal_gpiokey_disable_irq( + (enum HAL_GPIO_PIN_T)cfg_hw_gpio_key_cfg[i].key_config.pin); + } } -static inline void hal_gpiokey_disable_allint(void) -{ - uint8_t i; +static void hal_gpiokey_open(void) { + uint8_t i; + HAL_KEY_TRACE(1, "%s\n", __func__); - for (i = 0; i < CFG_HW_GPIOKEY_NUM; i++) { - if (cfg_hw_gpio_key_cfg[i].key_code == HAL_KEY_CODE_NONE) { - continue; - } + hal_gpiokey_reset(); - hal_gpiokey_disable_irq((enum HAL_GPIO_PIN_T)cfg_hw_gpio_key_cfg[i].key_config.pin); + for (i = 0; i < CFG_HW_GPIOKEY_NUM; i++) { + if (cfg_hw_gpio_key_cfg[i].key_code == HAL_KEY_CODE_NONE) { + continue; } + + hal_iomux_init(&cfg_hw_gpio_key_cfg[i].key_config, 1); + } } -static void hal_gpiokey_open(void) -{ - uint8_t i; - HAL_KEY_TRACE(1,"%s\n", __func__); +static void hal_gpiokey_close(void) { + HAL_KEY_TRACE(1, "%s\n", __func__); - hal_gpiokey_reset(); + hal_gpiokey_reset(); - for (i = 0; i < CFG_HW_GPIOKEY_NUM; i++) { - if (cfg_hw_gpio_key_cfg[i].key_code == HAL_KEY_CODE_NONE) { - continue; - } - - hal_iomux_init(&cfg_hw_gpio_key_cfg[i].key_config, 1); - } -} - -static void hal_gpiokey_close(void) -{ - HAL_KEY_TRACE(1,"%s\n", __func__); - - hal_gpiokey_reset(); - - hal_gpiokey_disable_allint(); + hal_gpiokey_disable_allint(); } #endif // (CFG_HW_GPIOKEY_NUM > 0) -enum HAL_KEY_EVENT_T hal_key_read_status(enum HAL_KEY_CODE_T code) -{ - uint8_t gpio_val; - int i; +enum HAL_KEY_EVENT_T hal_key_read_status(enum HAL_KEY_CODE_T code) { + uint8_t gpio_val; + int i; - if (code == HAL_KEY_CODE_PWR){ - if (hal_pwrkey_pressed()) - return HAL_KEY_EVENT_DOWN; - else - return HAL_KEY_EVENT_UP; - }else{ - for(i = 0; i < CFG_HW_GPIOKEY_NUM; i++) { - if(cfg_hw_gpio_key_cfg[i].key_code == code) { - gpio_val = hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)cfg_hw_gpio_key_cfg[i].key_config.pin); - if (gpio_val == cfg_hw_gpio_key_cfg[i].key_down) { - return HAL_KEY_EVENT_DOWN; - } else { - return HAL_KEY_EVENT_UP; - } - } + if (code == HAL_KEY_CODE_PWR) { + if (hal_pwrkey_pressed()) + return HAL_KEY_EVENT_DOWN; + else + return HAL_KEY_EVENT_UP; + } else { + for (i = 0; i < CFG_HW_GPIOKEY_NUM; i++) { + if (cfg_hw_gpio_key_cfg[i].key_code == code) { + gpio_val = hal_gpio_pin_get_val( + (enum HAL_GPIO_PIN_T)cfg_hw_gpio_key_cfg[i].key_config.pin); + if (gpio_val == cfg_hw_gpio_key_cfg[i].key_down) { + return HAL_KEY_EVENT_DOWN; + } else { + return HAL_KEY_EVENT_UP; } + } } - return HAL_KEY_EVENT_NONE; + } + return HAL_KEY_EVENT_NONE; } -static void hal_key_disable_allint(void) -{ +static void hal_key_disable_allint(void) { #ifndef NO_PWRKEY - hal_pwrkey_disable_int(); + hal_pwrkey_disable_int(); #endif #if (CFG_HW_ADCKEY_NUMBER > 0) - hal_adckey_disable_allint(); + hal_adckey_disable_allint(); #endif #if (CFG_HW_GPIOKEY_NUM > 0) - hal_gpiokey_disable_allint(); + hal_gpiokey_disable_allint(); #endif } -static void hal_key_enable_allint(void) -{ +static void hal_key_enable_allint(void) { #ifndef NO_PWRKEY - hal_pwrkey_enable_int(); + hal_pwrkey_enable_int(); #endif #if (CFG_HW_ADCKEY_NUMBER > 0) - hal_adckey_enable_press_int(); + hal_adckey_enable_press_int(); #endif #if (CFG_HW_GPIOKEY_NUM > 0) - hal_gpiokey_enable_allint(); + hal_gpiokey_enable_allint(); #endif } -static void hal_key_debounce_handler(void *param) -{ - uint32_t time; - enum HAL_KEY_CODE_T code_down = HAL_KEY_CODE_NONE; - int index; - bool need_timer = false; +static void hal_key_debounce_handler(void *param) { + uint32_t time; + enum HAL_KEY_CODE_T code_down = HAL_KEY_CODE_NONE; + int index; + bool need_timer = false; - timer_active = false; + timer_active = false; - time = hal_sys_timer_get(); + time = hal_sys_timer_get(); #ifndef NO_PWRKEY #ifdef __POWERKEY_CTRL_ONOFF_ONLY__ + if (pwr_key.debounce) { + pwr_key.debounce = false; + code_down |= HAL_KEY_CODE_PWR; +#ifdef NO_GROUPKEY + hal_key_enable_allint(); +#else + hal_pwrkey_enable_int(); +#endif + } +#else + if (pwr_key.debounce || pwr_key.dither || pwr_key.pressed) { + bool pressed = hal_pwrkey_get_status(); + + // HAL_KEY_TRACE(4,"keyDbnPwr: dbn=%d dither=%d pressed=%d/%d", + // pwr_key.debounce, pwr_key.dither, pwr_key.pressed, pressed); + if (pwr_key.debounce) { + pwr_key.pressed = pressed; + if (pressed) { + pwr_key.dither = false; + if (time - pwr_key.time >= KEY_DEBOUNCE_INTERVAL) { + pwr_key.debounce = false; + pwr_key.dither = false; + code_down |= HAL_KEY_CODE_PWR; + } + } else { pwr_key.debounce = false; - code_down |= HAL_KEY_CODE_PWR; + pwr_key.dither = true; + pwr_key.time = time; + } + } else if (pwr_key.dither) { + if (time - pwr_key.time >= KEY_DITHER_INTERVAL) { + pwr_key.dither = false; + pwr_key.pressed = false; #ifdef NO_GROUPKEY hal_key_enable_allint(); #else hal_pwrkey_enable_int(); #endif - } -#else - if (pwr_key.debounce || pwr_key.dither || pwr_key.pressed) { - bool pressed = hal_pwrkey_get_status(); - - //HAL_KEY_TRACE(4,"keyDbnPwr: dbn=%d dither=%d pressed=%d/%d", pwr_key.debounce, pwr_key.dither, pwr_key.pressed, pressed); - - if (pwr_key.debounce) { - pwr_key.pressed = pressed; - if (pressed) { - pwr_key.dither = false; - if (time - pwr_key.time >= KEY_DEBOUNCE_INTERVAL) { - pwr_key.debounce = false; - pwr_key.dither = false; - code_down |= HAL_KEY_CODE_PWR; - } - } else { - pwr_key.debounce = false; - pwr_key.dither = true; - pwr_key.time = time; - } - } else if (pwr_key.dither) { - if (time - pwr_key.time >= KEY_DITHER_INTERVAL) { - pwr_key.dither = false; - pwr_key.pressed = false; + } + } else if (pwr_key.pressed) { + if (pressed) { + code_down |= HAL_KEY_CODE_PWR; + } else { + pwr_key.pressed = false; #ifdef NO_GROUPKEY - hal_key_enable_allint(); + hal_key_enable_allint(); #else - hal_pwrkey_enable_int(); + hal_pwrkey_enable_int(); #endif - } - } else if (pwr_key.pressed) { - if (pressed) { - code_down |= HAL_KEY_CODE_PWR; - } else { - pwr_key.pressed = false; -#ifdef NO_GROUPKEY - hal_key_enable_allint(); -#else - hal_pwrkey_enable_int(); -#endif - } - } - } - if (pwr_key.debounce || pwr_key.dither || pwr_key.pressed) { - need_timer = true; + } } + } + if (pwr_key.debounce || pwr_key.dither || pwr_key.pressed) { + need_timer = true; + } #endif #endif #if (CFG_HW_ADCKEY_NUMBER > 0) - if (adc_key.debounce || adc_key.dither || adc_key.code_down != HAL_KEY_CODE_NONE) { - bool skip_check = false; + if (adc_key.debounce || adc_key.dither || + adc_key.code_down != HAL_KEY_CODE_NONE) { + bool skip_check = false; - //HAL_KEY_TRACE(4,"keyDbnAdc: dbn=%d dither=%d code_dbn=0x%X code_down=0x%X", adc_key.debounce, adc_key.dither, adc_key.code_debounce, adc_key.code_down); + // HAL_KEY_TRACE(4,"keyDbnAdc: dbn=%d dither=%d code_dbn=0x%X + // code_down=0x%X", adc_key.debounce, adc_key.dither, adc_key.code_debounce, + // adc_key.code_down); - if (adc_key.debounce) { - if (adc_key.code_debounce == HAL_KEY_CODE_NONE) { - adc_key.debounce = false; - adc_key.dither = true; - adc_key.time = time; - } else { - if (time - adc_key.time >= KEY_DEBOUNCE_INTERVAL) { - adc_key.debounce = false; - adc_key.dither = false; - adc_key.code_down = adc_key.code_debounce; - adc_key.code_debounce = HAL_KEY_CODE_NONE; - code_down |= adc_key.code_down; - } - } - } else if (adc_key.dither) { - if (time - adc_key.time >= KEY_DITHER_INTERVAL) { - adc_key.dither = false; - adc_key.code_debounce = HAL_KEY_CODE_NONE; - adc_key.code_down = HAL_KEY_CODE_NONE; -#ifdef NO_GROUPKEY - hal_key_enable_allint(); -#else - hal_adckey_enable_press_int(); -#endif - } - skip_check = true; - } else if (adc_key.code_down != HAL_KEY_CODE_NONE) { - if (adc_key.code_debounce == adc_key.code_down) { - code_down |= adc_key.code_down; - } else { - adc_key.code_down = HAL_KEY_CODE_NONE; -#ifdef NO_GROUPKEY - hal_key_enable_allint(); -#else - hal_adckey_enable_press_int(); -#endif - skip_check = true; - } + if (adc_key.debounce) { + if (adc_key.code_debounce == HAL_KEY_CODE_NONE) { + adc_key.debounce = false; + adc_key.dither = true; + adc_key.time = time; + } else { + if (time - adc_key.time >= KEY_DEBOUNCE_INTERVAL) { + adc_key.debounce = false; + adc_key.dither = false; + adc_key.code_down = adc_key.code_debounce; + adc_key.code_debounce = HAL_KEY_CODE_NONE; + code_down |= adc_key.code_down; } + } + } else if (adc_key.dither) { + if (time - adc_key.time >= KEY_DITHER_INTERVAL) { + adc_key.dither = false; + adc_key.code_debounce = HAL_KEY_CODE_NONE; + adc_key.code_down = HAL_KEY_CODE_NONE; +#ifdef NO_GROUPKEY + hal_key_enable_allint(); +#else + hal_adckey_enable_press_int(); +#endif + } + skip_check = true; + } else if (adc_key.code_down != HAL_KEY_CODE_NONE) { + if (adc_key.code_debounce == adc_key.code_down) { + code_down |= adc_key.code_down; + } else { + adc_key.code_down = HAL_KEY_CODE_NONE; +#ifdef NO_GROUPKEY + hal_key_enable_allint(); +#else + hal_adckey_enable_press_int(); +#endif + skip_check = true; + } + } - if (!skip_check) { - hal_adckey_enable_adc_int(); - } - } - if (adc_key.debounce || adc_key.dither || adc_key.code_down != HAL_KEY_CODE_NONE) { - need_timer = true; + if (!skip_check) { + hal_adckey_enable_adc_int(); } + } + if (adc_key.debounce || adc_key.dither || + adc_key.code_down != HAL_KEY_CODE_NONE) { + need_timer = true; + } #endif #if (CFG_HW_GPIOKEY_NUM > 0) - enum HAL_GPIO_PIN_T gpio; - GPIO_MAP_T pin; - uint32_t lock; + enum HAL_GPIO_PIN_T gpio; + GPIO_MAP_T pin; + uint32_t lock; #ifdef GPIO_MAP_64BIT - ASSERT((gpio_key.pin_debounce & gpio_key.pin_dither) == 0 && - (gpio_key.pin_debounce & gpio_key.pin_dither) == 0 && - (gpio_key.pin_debounce & gpio_key.pin_dither) == 0, - "Bad gpio_key pin map: dbn=0x%X-%X dither=0x%X-%X down=0x%X-%X", - (uint32_t)(gpio_key.pin_debounce >> 32), (uint32_t)(gpio_key.pin_debounce), - (uint32_t)(gpio_key.pin_dither >> 32), (uint32_t)(gpio_key.pin_dither), - (uint32_t)(gpio_key.pin_down >> 32), (uint32_t)(gpio_key.pin_down)); + ASSERT((gpio_key.pin_debounce & gpio_key.pin_dither) == 0 && + (gpio_key.pin_debounce & gpio_key.pin_dither) == 0 && + (gpio_key.pin_debounce & gpio_key.pin_dither) == 0, + "Bad gpio_key pin map: dbn=0x%X-%X dither=0x%X-%X down=0x%X-%X", + (uint32_t)(gpio_key.pin_debounce >> 32), + (uint32_t)(gpio_key.pin_debounce), + (uint32_t)(gpio_key.pin_dither >> 32), (uint32_t)(gpio_key.pin_dither), + (uint32_t)(gpio_key.pin_down >> 32), (uint32_t)(gpio_key.pin_down)); #if 0 HAL_KEY_TRACE(6,"keyDbnGpio: pin_dbn=0x%X-%X pin_dither=0x%X-%X pin_down=0x%X-%X", (uint32_t)(gpio_key.pin_debounce >> 32), (uint32_t)(gpio_key.pin_debounce), @@ -801,222 +782,239 @@ static void hal_key_debounce_handler(void *param) (uint32_t)(gpio_key.pin_down >> 32), (uint32_t)(gpio_key.pin_down)); #endif #else // !GPIO_MAP_64BIT - ASSERT((gpio_key.pin_debounce & gpio_key.pin_dither) == 0 && - (gpio_key.pin_debounce & gpio_key.pin_dither) == 0 && - (gpio_key.pin_debounce & gpio_key.pin_dither) == 0, - "Bad gpio_key pin map: dbn=0x%X dither=0x%X down=0x%X", - (uint32_t)gpio_key.pin_debounce, (uint32_t)gpio_key.pin_dither, (uint32_t)gpio_key.pin_down); + ASSERT((gpio_key.pin_debounce & gpio_key.pin_dither) == 0 && + (gpio_key.pin_debounce & gpio_key.pin_dither) == 0 && + (gpio_key.pin_debounce & gpio_key.pin_dither) == 0, + "Bad gpio_key pin map: dbn=0x%X dither=0x%X down=0x%X", + (uint32_t)gpio_key.pin_debounce, (uint32_t)gpio_key.pin_dither, + (uint32_t)gpio_key.pin_down); #if 0 HAL_KEY_TRACE(3,"keyDbnGpio: pin_dbn=0x%X pin_dither=0x%X pin_down=0x%X", (uint32_t)gpio_key.pin_debounce, (uint32_t)gpio_key.pin_dither, (uint32_t)gpio_key.pin_down); #endif #endif // !GPIO_MAP_64BIT - if (gpio_key.pin_dither) { - if (time - gpio_key.time_dither >= KEY_DITHER_INTERVAL) { - pin = gpio_key.pin_dither; + if (gpio_key.pin_dither) { + if (time - gpio_key.time_dither >= KEY_DITHER_INTERVAL) { + pin = gpio_key.pin_dither; - lock = int_lock(); - gpio_key.pin_dither &= ~pin; - int_unlock(lock); + lock = int_lock(); + gpio_key.pin_dither &= ~pin; + int_unlock(lock); #ifdef NO_GROUPKEY - hal_key_enable_allint(); + hal_key_enable_allint(); #else - gpio = HAL_GPIO_PIN_P0_0; - while (pin) { - if (pin & ((GPIO_MAP_T)1 << gpio)) { - pin &= ~((GPIO_MAP_T)1 << gpio); - index = hal_gpiokey_find_index(gpio); - hal_gpiokey_enable_irq(gpio, (cfg_hw_gpio_key_cfg[index].key_down == HAL_KEY_GPIOKEY_VAL_LOW) ? - HAL_GPIO_IRQ_POLARITY_LOW_FALLING : HAL_GPIO_IRQ_POLARITY_HIGH_RISING); - } - gpio++; - } -#endif + gpio = HAL_GPIO_PIN_P0_0; + while (pin) { + if (pin & ((GPIO_MAP_T)1 << gpio)) { + pin &= ~((GPIO_MAP_T)1 << gpio); + index = hal_gpiokey_find_index(gpio); + hal_gpiokey_enable_irq(gpio, (cfg_hw_gpio_key_cfg[index].key_down == + HAL_KEY_GPIOKEY_VAL_LOW) + ? HAL_GPIO_IRQ_POLARITY_LOW_FALLING + : HAL_GPIO_IRQ_POLARITY_HIGH_RISING); } + gpio++; + } +#endif } - if (gpio_key.pin_down) { - pin = gpio_key.pin_down; + } + if (gpio_key.pin_down) { + pin = gpio_key.pin_down; - gpio = HAL_GPIO_PIN_P0_0; - while (pin) { - if (pin & ((GPIO_MAP_T)1 << gpio)) { - pin &= ~((GPIO_MAP_T)1 << gpio); - index = hal_gpiokey_find_index(gpio); - if (hal_gpio_pin_get_val(gpio) == cfg_hw_gpio_key_cfg[index].key_down) { - code_down |= cfg_hw_gpio_key_cfg[index].key_code; - } else { - gpio_key.pin_down &= ~((GPIO_MAP_T)1 << gpio); + gpio = HAL_GPIO_PIN_P0_0; + while (pin) { + if (pin & ((GPIO_MAP_T)1 << gpio)) { + pin &= ~((GPIO_MAP_T)1 << gpio); + index = hal_gpiokey_find_index(gpio); + if (hal_gpio_pin_get_val(gpio) == cfg_hw_gpio_key_cfg[index].key_down) { + code_down |= cfg_hw_gpio_key_cfg[index].key_code; + } else { + gpio_key.pin_down &= ~((GPIO_MAP_T)1 << gpio); #ifdef NO_GROUPKEY - hal_key_enable_allint(); + hal_key_enable_allint(); #else - hal_gpiokey_enable_irq(gpio, (cfg_hw_gpio_key_cfg[index].key_down == HAL_KEY_GPIOKEY_VAL_LOW) ? - HAL_GPIO_IRQ_POLARITY_LOW_FALLING : HAL_GPIO_IRQ_POLARITY_HIGH_RISING); + hal_gpiokey_enable_irq(gpio, (cfg_hw_gpio_key_cfg[index].key_down == + HAL_KEY_GPIOKEY_VAL_LOW) + ? HAL_GPIO_IRQ_POLARITY_LOW_FALLING + : HAL_GPIO_IRQ_POLARITY_HIGH_RISING); #endif - } - } - gpio++; } + } + gpio++; } - if (gpio_key.pin_debounce) { - GPIO_MAP_T down_added = 0; - GPIO_MAP_T dither_added = 0; + } + if (gpio_key.pin_debounce) { + GPIO_MAP_T down_added = 0; + GPIO_MAP_T dither_added = 0; - pin = gpio_key.pin_debounce; + pin = gpio_key.pin_debounce; - gpio = HAL_GPIO_PIN_P0_0; - while (pin) { - if (pin & ((GPIO_MAP_T)1 << gpio)) { - pin &= ~((GPIO_MAP_T)1 << gpio); - index = hal_gpiokey_find_index(gpio); - if (hal_gpio_pin_get_val(gpio) == cfg_hw_gpio_key_cfg[index].key_down) { - if (time - gpio_key.time_debounce >= KEY_DEBOUNCE_INTERVAL) { - down_added |= ((GPIO_MAP_T)1 << gpio); - code_down |= cfg_hw_gpio_key_cfg[index].key_code; - gpio_key.pin_down |= ((GPIO_MAP_T)1 << gpio); - } - } else { - dither_added |= ((GPIO_MAP_T)1 << gpio); - } - } - gpio++; + gpio = HAL_GPIO_PIN_P0_0; + while (pin) { + if (pin & ((GPIO_MAP_T)1 << gpio)) { + pin &= ~((GPIO_MAP_T)1 << gpio); + index = hal_gpiokey_find_index(gpio); + if (hal_gpio_pin_get_val(gpio) == cfg_hw_gpio_key_cfg[index].key_down) { + if (time - gpio_key.time_debounce >= KEY_DEBOUNCE_INTERVAL) { + down_added |= ((GPIO_MAP_T)1 << gpio); + code_down |= cfg_hw_gpio_key_cfg[index].key_code; + gpio_key.pin_down |= ((GPIO_MAP_T)1 << gpio); + } + } else { + dither_added |= ((GPIO_MAP_T)1 << gpio); } + } + gpio++; + } - lock = int_lock(); - gpio_key.pin_debounce &= ~(down_added | dither_added); - gpio_key.pin_dither |= dither_added; - int_unlock(lock); - } - if (gpio_key.pin_dither || gpio_key.pin_down || gpio_key.pin_debounce) { - need_timer = true; - } + lock = int_lock(); + gpio_key.pin_debounce &= ~(down_added | dither_added); + gpio_key.pin_dither |= dither_added; + int_unlock(lock); + } + if (gpio_key.pin_dither || gpio_key.pin_down || gpio_key.pin_debounce) { + need_timer = true; + } #endif - enum HAL_KEY_CODE_T down_new; - enum HAL_KEY_CODE_T up_new; - enum HAL_KEY_CODE_T map; + enum HAL_KEY_CODE_T down_new; + enum HAL_KEY_CODE_T up_new; + enum HAL_KEY_CODE_T map; - down_new = code_down & ~key_status.code_down; - up_new = ~code_down & key_status.code_down; + down_new = code_down & ~key_status.code_down; + up_new = ~code_down & key_status.code_down; - //HAL_KEY_TRACE(5,"keyDbn: code_down=0x%X/0x%X down_new=0x%X up_new=0x%X event=%d", key_status.code_down, code_down, down_new, up_new, key_status.event); + // HAL_KEY_TRACE(5,"keyDbn: code_down=0x%X/0x%X down_new=0x%X up_new=0x%X + // event=%d", key_status.code_down, code_down, down_new, up_new, + // key_status.event); - // Check newly up keys - map = up_new; - index = 0; - while (map) { - if (map & (1 << index)) { - map &= ~(1 << index); - send_key_event((1 << index), HAL_KEY_EVENT_UP); - if (key_status.event == HAL_KEY_EVENT_LONGPRESS || key_status.event == HAL_KEY_EVENT_LONGLONGPRESS) { - send_key_event((1 << index), HAL_KEY_EVENT_UP_AFTER_LONGPRESS); - } - key_status.time_updown = time; + // Check newly up keys + map = up_new; + index = 0; + while (map) { + if (map & (1 << index)) { + map &= ~(1 << index); + send_key_event((1 << index), HAL_KEY_EVENT_UP); + if (key_status.event == HAL_KEY_EVENT_LONGPRESS || + key_status.event == HAL_KEY_EVENT_LONGLONGPRESS) { + send_key_event((1 << index), HAL_KEY_EVENT_UP_AFTER_LONGPRESS); + } + key_status.time_updown = time; + } + index++; + } + + if (up_new) { + if (key_status.event == HAL_KEY_EVENT_LONGPRESS || + key_status.event == HAL_KEY_EVENT_LONGLONGPRESS) { + // LongPress is finished when all of the LongPress keys are released + if ((code_down & key_status.code_ready) == 0) { + key_status.event = HAL_KEY_EVENT_NONE; + } + } else if (key_status.event == HAL_KEY_EVENT_DOWN) { + // Enter click handling if not in LongPress + key_status.event = HAL_KEY_EVENT_UP; + } + } + + if (key_status.event == HAL_KEY_EVENT_UP) { + // ASSERT(key_status.code_ready != HAL_KEY_CODE_NONE, "Bad code_ready"); + + if (key_status.code_click == HAL_KEY_CODE_NONE || + key_status.code_click != key_status.code_ready) { + if (key_status.code_click != HAL_KEY_CODE_NONE) { + send_key_event(key_status.code_click, + HAL_KEY_EVENT_CLICK + key_status.cnt_click); + } + key_status.code_click = key_status.code_ready; + key_status.cnt_click = 0; + key_status.time_click = time; + } else if (up_new && + (up_new | key_status.code_down) == key_status.code_click) { + key_status.cnt_click++; + key_status.time_click = time; + } + if (time - key_status.time_click >= KEY_DOUBLECLICK_THRESHOLD || + key_status.cnt_click >= MAX_KEY_CLICK_COUNT) { + send_key_event(key_status.code_click, + HAL_KEY_EVENT_CLICK + key_status.cnt_click); + key_status.code_click = HAL_KEY_CODE_NONE; + key_status.cnt_click = 0; + key_status.event = HAL_KEY_EVENT_NONE; + } + } + + // Update key_status.code_down + key_status.code_down = code_down; + + // Check newly down keys and update key_status.code_ready + map = down_new; + index = 0; + while (map) { + if (map & (1 << index)) { + map &= ~(1 << index); + send_key_event((1 << index), HAL_KEY_EVENT_DOWN); + if (key_status.event == HAL_KEY_EVENT_NONE) { + send_key_event((1 << index), HAL_KEY_EVENT_FIRST_DOWN); + } else { + send_key_event((1 << index), HAL_KEY_EVENT_CONTINUED_DOWN); + } + if (key_status.event == HAL_KEY_EVENT_NONE || + key_status.event == HAL_KEY_EVENT_DOWN || + key_status.event == HAL_KEY_EVENT_UP) { + key_status.code_ready = code_down; + } + key_status.time_updown = time; + } + index++; + } + + if (down_new) { + if (key_status.event == HAL_KEY_EVENT_NONE || + key_status.event == HAL_KEY_EVENT_UP) { + key_status.event = HAL_KEY_EVENT_DOWN; + } + } + + // LongPress should be stopped if any key is released + if ((code_down & key_status.code_ready) == key_status.code_ready) { + if (key_status.event == HAL_KEY_EVENT_DOWN) { + if (time - key_status.time_updown >= KEY_LONGPRESS_THRESHOLD) { + key_status.cnt_repeat = 0; + key_status.event = HAL_KEY_EVENT_LONGPRESS; + send_key_event(key_status.code_ready, key_status.event); + } + } else if (key_status.event == HAL_KEY_EVENT_LONGPRESS || + key_status.event == HAL_KEY_EVENT_LONGLONGPRESS) { + key_status.cnt_repeat++; + if (key_status.cnt_repeat == + KEY_LONGPRESS_REPEAT_THRESHOLD / KEY_CHECKER_INTERVAL) { + key_status.cnt_repeat = 0; + send_key_event(key_status.code_ready, HAL_KEY_EVENT_REPEAT); + } + if (key_status.event == HAL_KEY_EVENT_LONGPRESS) { + if (time - key_status.time_updown >= KEY_LONGLONGPRESS_THRESHOLD) { + key_status.event = HAL_KEY_EVENT_LONGLONGPRESS; + send_key_event(key_status.code_ready, key_status.event); } - index++; + } } + } - if (up_new) { - if (key_status.event == HAL_KEY_EVENT_LONGPRESS || key_status.event == HAL_KEY_EVENT_LONGLONGPRESS) { - // LongPress is finished when all of the LongPress keys are released - if ((code_down & key_status.code_ready) == 0) { - key_status.event = HAL_KEY_EVENT_NONE; - } - } else if (key_status.event == HAL_KEY_EVENT_DOWN) { - // Enter click handling if not in LongPress - key_status.event = HAL_KEY_EVENT_UP; - } - } + if (key_status.event != HAL_KEY_EVENT_NONE) { + need_timer = true; + } - if (key_status.event == HAL_KEY_EVENT_UP) { - //ASSERT(key_status.code_ready != HAL_KEY_CODE_NONE, "Bad code_ready"); - - if (key_status.code_click == HAL_KEY_CODE_NONE || key_status.code_click != key_status.code_ready) { - if (key_status.code_click != HAL_KEY_CODE_NONE) { - send_key_event(key_status.code_click, HAL_KEY_EVENT_CLICK + key_status.cnt_click); - } - key_status.code_click = key_status.code_ready; - key_status.cnt_click = 0; - key_status.time_click = time; - } else if (up_new && (up_new | key_status.code_down) == key_status.code_click) { - key_status.cnt_click++; - key_status.time_click = time; - } - if (time - key_status.time_click >= KEY_DOUBLECLICK_THRESHOLD || key_status.cnt_click >= MAX_KEY_CLICK_COUNT) { - send_key_event(key_status.code_click, HAL_KEY_EVENT_CLICK + key_status.cnt_click); - key_status.code_click = HAL_KEY_CODE_NONE; - key_status.cnt_click = 0; - key_status.event = HAL_KEY_EVENT_NONE; - } - } - - // Update key_status.code_down - key_status.code_down = code_down; - - // Check newly down keys and update key_status.code_ready - map = down_new; - index = 0; - while (map) { - if (map & (1 << index)) { - map &= ~(1 << index); - send_key_event((1 << index), HAL_KEY_EVENT_DOWN); - if (key_status.event == HAL_KEY_EVENT_NONE) { - send_key_event((1 << index), HAL_KEY_EVENT_FIRST_DOWN); - } else { - send_key_event((1 << index), HAL_KEY_EVENT_CONTINUED_DOWN); - } - if (key_status.event == HAL_KEY_EVENT_NONE || - key_status.event == HAL_KEY_EVENT_DOWN || - key_status.event == HAL_KEY_EVENT_UP) { - key_status.code_ready = code_down; - } - key_status.time_updown = time; - } - index++; - } - - if (down_new) { - if (key_status.event == HAL_KEY_EVENT_NONE || key_status.event == HAL_KEY_EVENT_UP) { - key_status.event = HAL_KEY_EVENT_DOWN; - } - } - - // LongPress should be stopped if any key is released - if ((code_down & key_status.code_ready) == key_status.code_ready) { - if (key_status.event == HAL_KEY_EVENT_DOWN) { - if (time - key_status.time_updown >= KEY_LONGPRESS_THRESHOLD) { - key_status.cnt_repeat = 0; - key_status.event = HAL_KEY_EVENT_LONGPRESS; - send_key_event(key_status.code_ready, key_status.event); - } - } else if (key_status.event == HAL_KEY_EVENT_LONGPRESS || key_status.event == HAL_KEY_EVENT_LONGLONGPRESS) { - key_status.cnt_repeat++; - if (key_status.cnt_repeat == KEY_LONGPRESS_REPEAT_THRESHOLD / KEY_CHECKER_INTERVAL) { - key_status.cnt_repeat = 0; - send_key_event(key_status.code_ready, HAL_KEY_EVENT_REPEAT); - } - if (key_status.event == HAL_KEY_EVENT_LONGPRESS) { - if (time - key_status.time_updown >= KEY_LONGLONGPRESS_THRESHOLD) { - key_status.event = HAL_KEY_EVENT_LONGLONGPRESS; - send_key_event(key_status.code_ready, key_status.event); - } - } - } - } - - if (key_status.event != HAL_KEY_EVENT_NONE) { - need_timer = true; - } - - if (need_timer) { - hal_key_debounce_timer_restart(); - } else { - //hal_sys_wake_unlock(HAL_SYS_WAKE_LOCK_USER_KEY); - } + if (need_timer) { + hal_key_debounce_timer_restart(); + } else { + // hal_sys_wake_unlock(HAL_SYS_WAKE_LOCK_USER_KEY); + } } -#if 0//def CHECK_PWRKEY_AT_BOOT +#if 0 // def CHECK_PWRKEY_AT_BOOT static void hal_key_boot_handler(void *param) { #ifndef NO_PWRKEY @@ -1091,93 +1089,90 @@ static void hal_key_boot_handler(void *param) } #endif } -#endif //CHECK_PWRKEY_AT_BOOT +#endif // CHECK_PWRKEY_AT_BOOT -int hal_key_open(int checkPwrKey, int (* cb)(uint32_t, uint8_t)) -{ - int nRet = 0; - uint32_t lock; +int hal_key_open(int checkPwrKey, int (*cb)(uint32_t, uint8_t)) { + int nRet = 0; + uint32_t lock; - key_detected_callback = cb; + key_detected_callback = cb; - memset(&key_status, 0, sizeof(key_status)); + memset(&key_status, 0, sizeof(key_status)); - lock = int_lock(); + lock = int_lock(); #ifdef CHECK_PWRKEY_AT_BOOT - if (checkPwrKey) { - int cnt; - int i = 0; + if (checkPwrKey) { + int cnt; + int i = 0; - cnt = 10; - do { - hal_sys_timer_delay(MS_TO_TICKS(150)); - if (!hal_pwrkey_startup_pressed()) { - HAL_KEY_TRACE(0,"pwr_key init DITHERING"); - nRet = -1; - goto _exit; - } - } while (++i < cnt); - } + cnt = 10; + do { + hal_sys_timer_delay(MS_TO_TICKS(150)); + if (!hal_pwrkey_startup_pressed()) { + HAL_KEY_TRACE(0, "pwr_key init DITHERING"); + nRet = -1; + goto _exit; + } + } while (++i < cnt); + } #endif #ifndef NO_PWRKEY - hal_pwrkey_open(); + hal_pwrkey_open(); #endif #if (CFG_HW_ADCKEY_NUMBER > 0) - hal_adckey_open(); + hal_adckey_open(); #endif #if (CFG_HW_GPIOKEY_NUM > 0) - hal_gpiokey_open(); + hal_gpiokey_open(); #endif #ifdef CHECK_PWRKEY_AT_BOOT #ifndef __POWERKEY_CTRL_ONOFF_ONLY__ - if (checkPwrKey) { - debounce_timer = hwtimer_alloc(hal_key_boot_handler, NULL); - hal_pwrkey_handle_irq_state(HAL_PWRKEY_IRQ_FALLING_EDGE); - } else + if (checkPwrKey) { + debounce_timer = hwtimer_alloc(hal_key_boot_handler, NULL); + hal_pwrkey_handle_irq_state(HAL_PWRKEY_IRQ_FALLING_EDGE); + } else #endif #endif - { - debounce_timer = hwtimer_alloc(hal_key_debounce_handler, NULL); - hal_key_enable_allint(); - } + { + debounce_timer = hwtimer_alloc(hal_key_debounce_handler, NULL); + hal_key_enable_allint(); + } - ASSERT(debounce_timer, "Failed to alloc key debounce timer"); + ASSERT(debounce_timer, "Failed to alloc key debounce timer"); - goto _exit; // Avoid compiler warnings + goto _exit; // Avoid compiler warnings _exit: - int_unlock(lock); + int_unlock(lock); - return nRet; + return nRet; } -int hal_key_close(void) -{ - hal_key_disable_allint(); +int hal_key_close(void) { + hal_key_disable_allint(); #ifndef NO_PWRKEY - hal_pwrkey_close(); + hal_pwrkey_close(); #endif #if (CFG_HW_ADCKEY_NUMBER > 0) - hal_adckey_close(); + hal_adckey_close(); #endif #if (CFG_HW_GPIOKEY_NUM > 0) - hal_gpiokey_close(); + hal_gpiokey_close(); #endif - if (debounce_timer) { - hwtimer_stop(debounce_timer); - hwtimer_free(debounce_timer); - debounce_timer = NULL; - } - timer_active = false; - key_detected_callback = NULL; + if (debounce_timer) { + hwtimer_stop(debounce_timer); + hwtimer_free(debounce_timer); + debounce_timer = NULL; + } + timer_active = false; + key_detected_callback = NULL; - //hal_sys_wake_unlock(HAL_SYS_WAKE_LOCK_USER_KEY); + // hal_sys_wake_unlock(HAL_SYS_WAKE_LOCK_USER_KEY); - return 0; + return 0; } - diff --git a/platform/hal/hal_mcu2cp.c b/platform/hal/hal_mcu2cp.c index e1ef87f..034f8db 100644 --- a/platform/hal/hal_mcu2cp.c +++ b/platform/hal/hal_mcu2cp.c @@ -15,54 +15,54 @@ ****************************************************************************/ #ifdef CHIP_HAS_CP -#include "plat_addr_map.h" +#include "hal_mcu2cp.h" #include "cmsis_nvic.h" #include "hal_location.h" -#include "hal_mcu2cp.h" #include "hal_sleep.h" #include "hal_timer.h" #include "hal_trace.h" +#include "plat_addr_map.h" #include CHIP_SPECIFIC_HDR(reg_cmu) -#define MAX_SEND_RECORD_COUNT 3 +#define MAX_SEND_RECORD_COUNT 3 -#define HAL_SYS_WAKE_LOCK_USER_MCU2CP HAL_SYS_WAKE_LOCK_USER_4 +#define HAL_SYS_WAKE_LOCK_USER_MCU2CP HAL_SYS_WAKE_LOCK_USER_4 #ifdef CP_API -#define API_POSTFIX _cp -#define MCU2CP_TEXT_LOC CP_TEXT_SRAM_LOC -#define MCU2CP_RODATA_LOC CP_DATA_LOC -#define MCU2CP_BSS_LOC CP_BSS_LOC -#define MCU2CP_BSS_DEF CP_BSS_DEF +#define API_POSTFIX _cp +#define MCU2CP_TEXT_LOC CP_TEXT_SRAM_LOC +#define MCU2CP_RODATA_LOC CP_DATA_LOC +#define MCU2CP_BSS_LOC CP_BSS_LOC +#define MCU2CP_BSS_DEF CP_BSS_DEF #else -#define API_POSTFIX _mcu +#define API_POSTFIX _mcu #define MCU2CP_TEXT_LOC #define MCU2CP_RODATA_LOC #define MCU2CP_BSS_LOC -#define MCU2CP_BSS_DEF CP_BSS_DEF +#define MCU2CP_BSS_DEF CP_BSS_DEF #endif -#define MCU2CP_API_A(n, p) MCU2CP_TEXT_LOC n ## p -#define MCU2CP_API_B(n, p) MCU2CP_API_A(n, p) -#define MCU2CP_API(n) MCU2CP_API_B(n, API_POSTFIX) +#define MCU2CP_API_A(n, p) MCU2CP_TEXT_LOC n##p +#define MCU2CP_API_B(n, p) MCU2CP_API_A(n, p) +#define MCU2CP_API(n) MCU2CP_API_B(n, API_POSTFIX) enum HAL_MCU2CP_IRQ_TYPE_T { - HAL_MCU2CP_IRQ_SEND_IND, - HAL_MCU2CP_IRQ_RECV_DONE, + HAL_MCU2CP_IRQ_SEND_IND, + HAL_MCU2CP_IRQ_RECV_DONE, - HAL_MCU2CP_IRQ_TYPE_QTY + HAL_MCU2CP_IRQ_TYPE_QTY }; struct HAL_MCU2CP_MSG_T { - struct HAL_MCU2CP_MSG_T *next; // pointer to next element in the list - enum HAL_MCU2CP_MSG_TYPE_T type; // message type - unsigned int len; // message data length in bytes - const unsigned char *data; // pointer to the message data + struct HAL_MCU2CP_MSG_T *next; // pointer to next element in the list + enum HAL_MCU2CP_MSG_TYPE_T type; // message type + unsigned int len; // message data length in bytes + const unsigned char *data; // pointer to the message data }; struct HAL_MCU2CP_SEND_RECORD_T { - struct HAL_MCU2CP_MSG_T msg; - bool in_use; + struct HAL_MCU2CP_MSG_T msg; + bool in_use; }; static const IRQn_Type MCU2CP_RODATA_LOC rx_irq_id[HAL_MCU2CP_ID_QTY] = { @@ -75,480 +75,493 @@ static const IRQn_Type MCU2CP_RODATA_LOC tx_irq_id[HAL_MCU2CP_ID_QTY] = { MCU2CP_DONE1_IRQn, }; -static const struct HAL_MCU2CP_MSG_T ** MCU2CP_BSS_LOC recv_msg_list_p; +static const struct HAL_MCU2CP_MSG_T **MCU2CP_BSS_LOC recv_msg_list_p; -static struct HAL_MCU2CP_MSG_T * MCU2CP_BSS_LOC send_msg_list_p[HAL_MCU2CP_ID_QTY]; -static struct HAL_MCU2CP_MSG_T * MCU2CP_BSS_LOC send_pending_list_p[HAL_MCU2CP_ID_QTY]; +static struct HAL_MCU2CP_MSG_T *MCU2CP_BSS_LOC + send_msg_list_p[HAL_MCU2CP_ID_QTY]; +static struct HAL_MCU2CP_MSG_T *MCU2CP_BSS_LOC + send_pending_list_p[HAL_MCU2CP_ID_QTY]; -static struct HAL_MCU2CP_MSG_T MCU2CP_BSS_LOC recv_pending_head[HAL_MCU2CP_ID_QTY]; +static struct HAL_MCU2CP_MSG_T MCU2CP_BSS_LOC + recv_pending_head[HAL_MCU2CP_ID_QTY]; -static struct HAL_MCU2CP_SEND_RECORD_T MCU2CP_BSS_LOC send_msgs[HAL_MCU2CP_ID_QTY][MAX_SEND_RECORD_COUNT]; +static struct HAL_MCU2CP_SEND_RECORD_T MCU2CP_BSS_LOC + send_msgs[HAL_MCU2CP_ID_QTY][MAX_SEND_RECORD_COUNT]; -static HAL_MCU2CP_RX_IRQ_HANDLER MCU2CP_BSS_LOC rx_irq_handler[HAL_MCU2CP_ID_QTY][HAL_MCU2CP_MSG_TYPE_QTY]; -static HAL_MCU2CP_TX_IRQ_HANDLER MCU2CP_BSS_LOC tx_irq_handler[HAL_MCU2CP_ID_QTY][HAL_MCU2CP_MSG_TYPE_QTY]; +static HAL_MCU2CP_RX_IRQ_HANDLER MCU2CP_BSS_LOC + rx_irq_handler[HAL_MCU2CP_ID_QTY][HAL_MCU2CP_MSG_TYPE_QTY]; +static HAL_MCU2CP_TX_IRQ_HANDLER MCU2CP_BSS_LOC + tx_irq_handler[HAL_MCU2CP_ID_QTY][HAL_MCU2CP_MSG_TYPE_QTY]; -static uint8_t MCU2CP_BSS_LOC chan_opened[HAL_MCU2CP_ID_QTY] = { 0, 0, }; -STATIC_ASSERT(sizeof(chan_opened[0]) * 8 >= HAL_MCU2CP_MSG_TYPE_QTY, "chan_opened size too small"); +static uint8_t MCU2CP_BSS_LOC chan_opened[HAL_MCU2CP_ID_QTY] = { + 0, + 0, +}; +STATIC_ASSERT(sizeof(chan_opened[0]) * 8 >= HAL_MCU2CP_MSG_TYPE_QTY, + "chan_opened size too small"); -static bool MCU2CP_BSS_LOC need_flow_ctrl[HAL_MCU2CP_ID_QTY] = { false, false, }; +static bool MCU2CP_BSS_LOC need_flow_ctrl[HAL_MCU2CP_ID_QTY] = { + false, + false, +}; #ifndef CP_API -static bool MCU2CP_BSS_LOC chan_busy[HAL_MCU2CP_ID_QTY] = { false, false, }; +static bool MCU2CP_BSS_LOC chan_busy[HAL_MCU2CP_ID_QTY] = { + false, + false, +}; static bool MCU2CP_BSS_LOC busy_now = false; #endif -static struct CMU_T * const MCU2CP_RODATA_LOC cmu = (struct CMU_T *)CMU_BASE; +static struct CMU_T *const MCU2CP_RODATA_LOC cmu = (struct CMU_T *)CMU_BASE; -static void MCU2CP_TEXT_LOC hal_mcu2cp_busy(enum HAL_MCU2CP_ID_T id, bool busy) -{ +static void MCU2CP_TEXT_LOC hal_mcu2cp_busy(enum HAL_MCU2CP_ID_T id, + bool busy) { #ifndef CP_API - int i; - bool new_state; + int i; + bool new_state; - if (chan_busy[id] == busy) { - return; + if (chan_busy[id] == busy) { + return; + } + + chan_busy[id] = busy; + + if (busy_now == busy) { + return; + } + + if (busy) { + hal_sys_wake_lock(HAL_SYS_WAKE_LOCK_USER_MCU2CP); + busy_now = true; + } else { + new_state = false; + for (i = 0; i < HAL_MCU2CP_ID_QTY; i++) { + if (chan_busy[i]) { + new_state = true; + break; + } } - - chan_busy[id] = busy; - - if (busy_now == busy) { - return; - } - - if (busy) { - hal_sys_wake_lock(HAL_SYS_WAKE_LOCK_USER_MCU2CP); - busy_now = true; - } else { - new_state = false; - for (i = 0; i < HAL_MCU2CP_ID_QTY; i++) { - if (chan_busy[i]) { - new_state = true; - break; - } - } - if (!new_state) { - hal_sys_wake_unlock(HAL_SYS_WAKE_LOCK_USER_MCU2CP); - busy_now = false; - } + if (!new_state) { + hal_sys_wake_unlock(HAL_SYS_WAKE_LOCK_USER_MCU2CP); + busy_now = false; } + } #endif } -static int MCU2CP_TEXT_LOC hal_mcu2cp_peer_irq_set(enum HAL_MCU2CP_ID_T id, enum HAL_MCU2CP_IRQ_TYPE_T type) -{ - uint32_t value; +static int MCU2CP_TEXT_LOC hal_mcu2cp_peer_irq_set( + enum HAL_MCU2CP_ID_T id, enum HAL_MCU2CP_IRQ_TYPE_T type) { + uint32_t value; #ifdef CP_API - if (id == HAL_MCU2CP_ID_0) { - if (type == HAL_MCU2CP_IRQ_SEND_IND) { - value = CMU_CP2MCU_DATA_IND_SET; - } else { - value = CMU_MCU2CP_DATA_DONE_SET; - } + if (id == HAL_MCU2CP_ID_0) { + if (type == HAL_MCU2CP_IRQ_SEND_IND) { + value = CMU_CP2MCU_DATA_IND_SET; } else { - if (type == HAL_MCU2CP_IRQ_SEND_IND) { - value = CMU_CP2MCU_DATA1_IND_SET; - } else { - value = CMU_MCU2CP_DATA1_DONE_SET; - } + value = CMU_MCU2CP_DATA_DONE_SET; } + } else { + if (type == HAL_MCU2CP_IRQ_SEND_IND) { + value = CMU_CP2MCU_DATA1_IND_SET; + } else { + value = CMU_MCU2CP_DATA1_DONE_SET; + } + } - cmu->CP2MCU_IRQ_SET = value; + cmu->CP2MCU_IRQ_SET = value; #else - if (id == HAL_MCU2CP_ID_0) { - if (type == HAL_MCU2CP_IRQ_SEND_IND) { - value = CMU_MCU2CP_DATA_IND_SET; - } else { - value = CMU_CP2MCU_DATA_DONE_SET; - } + if (id == HAL_MCU2CP_ID_0) { + if (type == HAL_MCU2CP_IRQ_SEND_IND) { + value = CMU_MCU2CP_DATA_IND_SET; } else { - if (type == HAL_MCU2CP_IRQ_SEND_IND) { - value = CMU_MCU2CP_DATA1_IND_SET; - } else { - value = CMU_CP2MCU_DATA1_DONE_SET; - } + value = CMU_CP2MCU_DATA_DONE_SET; } + } else { + if (type == HAL_MCU2CP_IRQ_SEND_IND) { + value = CMU_MCU2CP_DATA1_IND_SET; + } else { + value = CMU_CP2MCU_DATA1_DONE_SET; + } + } - cmu->MCU2CP_IRQ_SET = value; + cmu->MCU2CP_IRQ_SET = value; #endif - return 0; + return 0; } -static int MCU2CP_TEXT_LOC hal_mcu2cp_local_irq_clear(enum HAL_MCU2CP_ID_T id, enum HAL_MCU2CP_IRQ_TYPE_T type) -{ - uint32_t value; +static int MCU2CP_TEXT_LOC hal_mcu2cp_local_irq_clear( + enum HAL_MCU2CP_ID_T id, enum HAL_MCU2CP_IRQ_TYPE_T type) { + uint32_t value; #ifdef CP_API - if (id == HAL_MCU2CP_ID_0) { - if (type == HAL_MCU2CP_IRQ_SEND_IND) { - value = CMU_MCU2CP_DATA_IND_CLR; - } else { - value = CMU_CP2MCU_DATA_DONE_CLR; - } + if (id == HAL_MCU2CP_ID_0) { + if (type == HAL_MCU2CP_IRQ_SEND_IND) { + value = CMU_MCU2CP_DATA_IND_CLR; } else { - if (type == HAL_MCU2CP_IRQ_SEND_IND) { - value = CMU_MCU2CP_DATA1_IND_CLR; - } else { - value = CMU_CP2MCU_DATA1_DONE_CLR; - } + value = CMU_CP2MCU_DATA_DONE_CLR; } + } else { + if (type == HAL_MCU2CP_IRQ_SEND_IND) { + value = CMU_MCU2CP_DATA1_IND_CLR; + } else { + value = CMU_CP2MCU_DATA1_DONE_CLR; + } + } - cmu->MCU2CP_IRQ_CLR = value; + cmu->MCU2CP_IRQ_CLR = value; #else - if (id == HAL_MCU2CP_ID_0) { - if (type == HAL_MCU2CP_IRQ_SEND_IND) { - value = CMU_CP2MCU_DATA_IND_CLR; - } else { - value = CMU_MCU2CP_DATA_DONE_CLR; - } + if (id == HAL_MCU2CP_ID_0) { + if (type == HAL_MCU2CP_IRQ_SEND_IND) { + value = CMU_CP2MCU_DATA_IND_CLR; } else { - if (type == HAL_MCU2CP_IRQ_SEND_IND) { - value = CMU_CP2MCU_DATA1_IND_CLR; - } else { - value = CMU_MCU2CP_DATA1_DONE_CLR; - } + value = CMU_MCU2CP_DATA_DONE_CLR; } + } else { + if (type == HAL_MCU2CP_IRQ_SEND_IND) { + value = CMU_CP2MCU_DATA1_IND_CLR; + } else { + value = CMU_MCU2CP_DATA1_DONE_CLR; + } + } - cmu->CP2MCU_IRQ_CLR = value; + cmu->CP2MCU_IRQ_CLR = value; #endif - return 0; + return 0; } -static int MCU2CP_TEXT_LOC hal_mcu2cp_local_irq_set(enum HAL_MCU2CP_ID_T id, enum HAL_MCU2CP_IRQ_TYPE_T type) -{ - uint32_t value; +static int MCU2CP_TEXT_LOC hal_mcu2cp_local_irq_set( + enum HAL_MCU2CP_ID_T id, enum HAL_MCU2CP_IRQ_TYPE_T type) { + uint32_t value; #ifdef CP_API - if (id == HAL_MCU2CP_ID_0) { - if (type == HAL_MCU2CP_IRQ_SEND_IND) { - value = CMU_MCU2CP_DATA_IND_SET; - } else { - value = CMU_CP2MCU_DATA_DONE_SET; - } + if (id == HAL_MCU2CP_ID_0) { + if (type == HAL_MCU2CP_IRQ_SEND_IND) { + value = CMU_MCU2CP_DATA_IND_SET; } else { - if (type == HAL_MCU2CP_IRQ_SEND_IND) { - value = CMU_MCU2CP_DATA1_IND_SET; - } else { - value = CMU_CP2MCU_DATA1_DONE_SET; - } + value = CMU_CP2MCU_DATA_DONE_SET; } + } else { + if (type == HAL_MCU2CP_IRQ_SEND_IND) { + value = CMU_MCU2CP_DATA1_IND_SET; + } else { + value = CMU_CP2MCU_DATA1_DONE_SET; + } + } - cmu->MCU2CP_IRQ_SET = value; + cmu->MCU2CP_IRQ_SET = value; #else - if (id == HAL_MCU2CP_ID_0) { - if (type == HAL_MCU2CP_IRQ_SEND_IND) { - value = CMU_CP2MCU_DATA_IND_SET; - } else { - value = CMU_MCU2CP_DATA_DONE_SET; - } + if (id == HAL_MCU2CP_ID_0) { + if (type == HAL_MCU2CP_IRQ_SEND_IND) { + value = CMU_CP2MCU_DATA_IND_SET; } else { - if (type == HAL_MCU2CP_IRQ_SEND_IND) { - value = CMU_CP2MCU_DATA1_IND_SET; - } else { - value = CMU_MCU2CP_DATA1_DONE_SET; - } + value = CMU_MCU2CP_DATA_DONE_SET; } + } else { + if (type == HAL_MCU2CP_IRQ_SEND_IND) { + value = CMU_CP2MCU_DATA1_IND_SET; + } else { + value = CMU_MCU2CP_DATA1_DONE_SET; + } + } - cmu->CP2MCU_IRQ_SET = value; + cmu->CP2MCU_IRQ_SET = value; #endif - return 0; + return 0; } -static void MCU2CP_TEXT_LOC hal_mcu2cp_rx_irq(void) -{ - int id; - const struct HAL_MCU2CP_MSG_T *msg_ptr; - enum HAL_MCU2CP_MSG_TYPE_T type; - unsigned int processed; +static void MCU2CP_TEXT_LOC hal_mcu2cp_rx_irq(void) { + int id; + const struct HAL_MCU2CP_MSG_T *msg_ptr; + enum HAL_MCU2CP_MSG_TYPE_T type; + unsigned int processed; - for (id = HAL_MCU2CP_ID_0; id < HAL_MCU2CP_ID_QTY; id++) { - if (NVIC_GetActive(rx_irq_id[id])) { - hal_mcu2cp_local_irq_clear(id, HAL_MCU2CP_IRQ_SEND_IND); + for (id = HAL_MCU2CP_ID_0; id < HAL_MCU2CP_ID_QTY; id++) { + if (NVIC_GetActive(rx_irq_id[id])) { + hal_mcu2cp_local_irq_clear(id, HAL_MCU2CP_IRQ_SEND_IND); - if (recv_pending_head[id].data) { - // Previous unprocessed message - msg_ptr = &recv_pending_head[id]; - } else { - // New message - msg_ptr = recv_msg_list_p[id]; - } - while (msg_ptr) { - type = msg_ptr->type; - if (type >= HAL_MCU2CP_MSG_TYPE_QTY) { - // Error - ASSERT(false, "MCU2CP-RX: Invalid msg type: %d", type); - break; - } - if (rx_irq_handler[id][type]) { - processed = rx_irq_handler[id][type](msg_ptr->data, msg_ptr->len); - // Check if flow control needed - if (processed < msg_ptr->len) { - recv_pending_head[id].next = msg_ptr->next; - recv_pending_head[id].type = msg_ptr->type; - recv_pending_head[id].len = msg_ptr->len - processed; - recv_pending_head[id].data = msg_ptr->data + processed; - break; - } - } else { - // Error - ASSERT(false, "MCU2CP-RX: Handler missing"); - break; - } - msg_ptr = msg_ptr->next; - } - - if (msg_ptr == NULL) { - if (!need_flow_ctrl[id]){ - hal_mcu2cp_peer_irq_set(id, HAL_MCU2CP_IRQ_RECV_DONE); - } - recv_pending_head[id].data = NULL; - } + if (recv_pending_head[id].data) { + // Previous unprocessed message + msg_ptr = &recv_pending_head[id]; + } else { + // New message + msg_ptr = recv_msg_list_p[id]; + } + while (msg_ptr) { + type = msg_ptr->type; + if (type >= HAL_MCU2CP_MSG_TYPE_QTY) { + // Error + ASSERT(false, "MCU2CP-RX: Invalid msg type: %d", type); + break; } - } -} - -static void MCU2CP_TEXT_LOC hal_mcu2cp_tx_irq(void) -{ - int id; - struct HAL_MCU2CP_MSG_T *msg_ptr; - enum HAL_MCU2CP_MSG_TYPE_T type; - - for (id = HAL_MCU2CP_ID_0; id < HAL_MCU2CP_ID_QTY; id++) { - if (NVIC_GetActive(tx_irq_id[id])) { - hal_mcu2cp_local_irq_clear(id, HAL_MCU2CP_IRQ_RECV_DONE); - - msg_ptr = send_msg_list_p[id]; - while (msg_ptr) { - type = msg_ptr->type; - if (type >= HAL_MCU2CP_MSG_TYPE_QTY) { - // Error - ASSERT(false, "MCU2CP-TX: Invalid msg type: %d", type); - break; - } - if (tx_irq_handler[id][type]) { - tx_irq_handler[id][type](msg_ptr->data, msg_ptr->len); - }; - CONTAINER_OF(msg_ptr, struct HAL_MCU2CP_SEND_RECORD_T, msg)->in_use = false; - msg_ptr = msg_ptr->next; - } - - if (send_pending_list_p[id]) { - send_msg_list_p[id] = send_pending_list_p[id]; - send_pending_list_p[id] = NULL; - hal_mcu2cp_peer_irq_set(id, HAL_MCU2CP_IRQ_SEND_IND); - } else { - send_msg_list_p[id] = NULL; - // Allow sleep - hal_mcu2cp_busy(id, false); - } + if (rx_irq_handler[id][type]) { + processed = rx_irq_handler[id][type](msg_ptr->data, msg_ptr->len); + // Check if flow control needed + if (processed < msg_ptr->len) { + recv_pending_head[id].next = msg_ptr->next; + recv_pending_head[id].type = msg_ptr->type; + recv_pending_head[id].len = msg_ptr->len - processed; + recv_pending_head[id].data = msg_ptr->data + processed; + break; + } + } else { + // Error + ASSERT(false, "MCU2CP-RX: Handler missing"); + break; } + msg_ptr = msg_ptr->next; + } + + if (msg_ptr == NULL) { + if (!need_flow_ctrl[id]) { + hal_mcu2cp_peer_irq_set(id, HAL_MCU2CP_IRQ_RECV_DONE); + } + recv_pending_head[id].data = NULL; + } } + } } -const struct HAL_MCU2CP_MSG_T ** hal_mcu2cp_get_send_msg_list_mcu(void); -const struct HAL_MCU2CP_MSG_T ** hal_mcu2cp_get_send_msg_list_cp (void); +static void MCU2CP_TEXT_LOC hal_mcu2cp_tx_irq(void) { + int id; + struct HAL_MCU2CP_MSG_T *msg_ptr; + enum HAL_MCU2CP_MSG_TYPE_T type; + + for (id = HAL_MCU2CP_ID_0; id < HAL_MCU2CP_ID_QTY; id++) { + if (NVIC_GetActive(tx_irq_id[id])) { + hal_mcu2cp_local_irq_clear(id, HAL_MCU2CP_IRQ_RECV_DONE); + + msg_ptr = send_msg_list_p[id]; + while (msg_ptr) { + type = msg_ptr->type; + if (type >= HAL_MCU2CP_MSG_TYPE_QTY) { + // Error + ASSERT(false, "MCU2CP-TX: Invalid msg type: %d", type); + break; + } + if (tx_irq_handler[id][type]) { + tx_irq_handler[id][type](msg_ptr->data, msg_ptr->len); + }; + CONTAINER_OF(msg_ptr, struct HAL_MCU2CP_SEND_RECORD_T, msg)->in_use = + false; + msg_ptr = msg_ptr->next; + } + + if (send_pending_list_p[id]) { + send_msg_list_p[id] = send_pending_list_p[id]; + send_pending_list_p[id] = NULL; + hal_mcu2cp_peer_irq_set(id, HAL_MCU2CP_IRQ_SEND_IND); + } else { + send_msg_list_p[id] = NULL; + // Allow sleep + hal_mcu2cp_busy(id, false); + } + } + } +} + +const struct HAL_MCU2CP_MSG_T **hal_mcu2cp_get_send_msg_list_mcu(void); +const struct HAL_MCU2CP_MSG_T **hal_mcu2cp_get_send_msg_list_cp(void); #ifdef CP_API // This is initialization code and should NOT be in CP text location -const struct HAL_MCU2CP_MSG_T ** hal_mcu2cp_get_send_msg_list_cp(void) +const struct HAL_MCU2CP_MSG_T **hal_mcu2cp_get_send_msg_list_cp(void) #else -const struct HAL_MCU2CP_MSG_T ** hal_mcu2cp_get_send_msg_list_mcu(void) +const struct HAL_MCU2CP_MSG_T **hal_mcu2cp_get_send_msg_list_mcu(void) #endif { - return (const struct HAL_MCU2CP_MSG_T **)&send_msg_list_p[0]; + return (const struct HAL_MCU2CP_MSG_T **)&send_msg_list_p[0]; } -int MCU2CP_API(hal_mcu2cp_open)(enum HAL_MCU2CP_ID_T id, enum HAL_MCU2CP_MSG_TYPE_T type, - HAL_MCU2CP_RX_IRQ_HANDLER rxhandler, HAL_MCU2CP_TX_IRQ_HANDLER txhandler, bool rx_flowctrl) -{ - int i; +int MCU2CP_API(hal_mcu2cp_open)(enum HAL_MCU2CP_ID_T id, + enum HAL_MCU2CP_MSG_TYPE_T type, + HAL_MCU2CP_RX_IRQ_HANDLER rxhandler, + HAL_MCU2CP_TX_IRQ_HANDLER txhandler, + bool rx_flowctrl) { + int i; - if (id >= HAL_MCU2CP_ID_QTY) { - return 1; - } - if (type >= HAL_MCU2CP_MSG_TYPE_QTY) { - return 2; - } + if (id >= HAL_MCU2CP_ID_QTY) { + return 1; + } + if (type >= HAL_MCU2CP_MSG_TYPE_QTY) { + return 2; + } - if (chan_opened[id] == 0) { - hal_mcu2cp_local_irq_clear(id, HAL_MCU2CP_IRQ_SEND_IND); - hal_mcu2cp_local_irq_clear(id, HAL_MCU2CP_IRQ_RECV_DONE); + if (chan_opened[id] == 0) { + hal_mcu2cp_local_irq_clear(id, HAL_MCU2CP_IRQ_SEND_IND); + hal_mcu2cp_local_irq_clear(id, HAL_MCU2CP_IRQ_RECV_DONE); #ifdef CP_API - recv_msg_list_p = hal_mcu2cp_get_send_msg_list_mcu(); + recv_msg_list_p = hal_mcu2cp_get_send_msg_list_mcu(); #else - recv_msg_list_p = hal_mcu2cp_get_send_msg_list_cp(); + recv_msg_list_p = hal_mcu2cp_get_send_msg_list_cp(); #endif - NVIC_SetVector(rx_irq_id[id], (uint32_t)hal_mcu2cp_rx_irq); - NVIC_SetPriority(rx_irq_id[id], IRQ_PRIORITY_NORMAL); + NVIC_SetVector(rx_irq_id[id], (uint32_t)hal_mcu2cp_rx_irq); + NVIC_SetPriority(rx_irq_id[id], IRQ_PRIORITY_NORMAL); - NVIC_SetVector(tx_irq_id[id], (uint32_t)hal_mcu2cp_tx_irq); - NVIC_SetPriority(tx_irq_id[id], IRQ_PRIORITY_NORMAL); - - // Stop IRQs by default - NVIC_DisableIRQ(rx_irq_id[id]); - NVIC_DisableIRQ(tx_irq_id[id]); - - send_msg_list_p[id] = NULL; - send_pending_list_p[id] = NULL; - recv_pending_head[id].data = NULL; - for (i = 0; i < MAX_SEND_RECORD_COUNT; i++) { - send_msgs[id][i].in_use = false; - } - need_flow_ctrl[id] = rx_flowctrl; - } else { - ASSERT(need_flow_ctrl[id] == rx_flowctrl, "MCU2CP-OPEN: rx_flowctrl=%d (should be %d)", rx_flowctrl, need_flow_ctrl[id]); - return 3; - } - chan_opened[id] |= (1 << type); - - rx_irq_handler[id][type] = rxhandler; - tx_irq_handler[id][type] = txhandler; - - return 0; -} - -int MCU2CP_API(hal_mcu2cp_close)(enum HAL_MCU2CP_ID_T id,enum HAL_MCU2CP_MSG_TYPE_T type) -{ - if (id >= HAL_MCU2CP_ID_QTY) { - return 1; - } - - chan_opened[id] &= ~(1 << type); - rx_irq_handler[id][type] = NULL; - tx_irq_handler[id][type] = NULL; - - if (chan_opened[id] == 0) { - // Stop IRQs by default - NVIC_DisableIRQ(rx_irq_id[id]); - NVIC_DisableIRQ(tx_irq_id[id]); - - send_msg_list_p[id] = NULL; - send_pending_list_p[id] = NULL; - recv_pending_head[id].data = NULL; - need_flow_ctrl[id] = false; - } - - return 0; -} - -int MCU2CP_API(hal_mcu2cp_start_recv)(enum HAL_MCU2CP_ID_T id) -{ - if (id >= HAL_MCU2CP_ID_QTY) { - return 1; - } - - NVIC_EnableIRQ(rx_irq_id[id]); - // Check if there is any previous unprocessed message - if (recv_pending_head[id].data) { - hal_mcu2cp_local_irq_set(id, HAL_MCU2CP_IRQ_SEND_IND); - } - return 0; -} - -int MCU2CP_API(hal_mcu2cp_stop_recv)(enum HAL_MCU2CP_ID_T id) -{ - if (id >= HAL_MCU2CP_ID_QTY) { - return 1; - } + NVIC_SetVector(tx_irq_id[id], (uint32_t)hal_mcu2cp_tx_irq); + NVIC_SetPriority(tx_irq_id[id], IRQ_PRIORITY_NORMAL); + // Stop IRQs by default NVIC_DisableIRQ(rx_irq_id[id]); - return 0; -} + NVIC_DisableIRQ(tx_irq_id[id]); -int MCU2CP_API(hal_mcu2cp_send)(enum HAL_MCU2CP_ID_T id, enum HAL_MCU2CP_MSG_TYPE_T type, - const unsigned char *data, unsigned int len) -{ - uint32_t lock; - int ret; - struct HAL_MCU2CP_SEND_RECORD_T *record; - struct HAL_MCU2CP_MSG_T *next; - int i; - - if (id >= HAL_MCU2CP_ID_QTY) { - return 1; - } - if (type >= HAL_MCU2CP_MSG_TYPE_QTY) { - return 2; - } - if ((chan_opened[id] & (1 << type)) == 0) { - return 3; - } - - NVIC_EnableIRQ(tx_irq_id[id]); - - ret = -1; - record = &send_msgs[id][0]; - - lock = int_lock(); + send_msg_list_p[id] = NULL; + send_pending_list_p[id] = NULL; + recv_pending_head[id].data = NULL; for (i = 0; i < MAX_SEND_RECORD_COUNT; i++) { - if (record->in_use) { - record++; - continue; - } - record->in_use = true; - record->msg.next = NULL; - record->msg.type = type; - record->msg.len = len; - record->msg.data = data; - if (send_msg_list_p[id] == NULL) { - send_msg_list_p[id] = &record->msg; - hal_mcu2cp_peer_irq_set(id, HAL_MCU2CP_IRQ_SEND_IND); - } else if (send_pending_list_p[id] == NULL) { - send_pending_list_p[id] = &record->msg; - } else { - next = send_pending_list_p[id]; - while (next->next) { - next = next->next; - } - next->next = &record->msg; - } - ret = 0; - // Prohibit sleep here - hal_mcu2cp_busy(id, true); - break; + send_msgs[id][i].in_use = false; } - int_unlock(lock); + need_flow_ctrl[id] = rx_flowctrl; + } else { + ASSERT(need_flow_ctrl[id] == rx_flowctrl, + "MCU2CP-OPEN: rx_flowctrl=%d (should be %d)", rx_flowctrl, + need_flow_ctrl[id]); + return 3; + } + chan_opened[id] |= (1 << type); - return ret; + rx_irq_handler[id][type] = rxhandler; + tx_irq_handler[id][type] = txhandler; + + return 0; } -void MCU2CP_API(hal_mcu2cp_rx_done)(enum HAL_MCU2CP_ID_T id) -{ - hal_mcu2cp_peer_irq_set(id, HAL_MCU2CP_IRQ_RECV_DONE); +int MCU2CP_API(hal_mcu2cp_close)(enum HAL_MCU2CP_ID_T id, + enum HAL_MCU2CP_MSG_TYPE_T type) { + if (id >= HAL_MCU2CP_ID_QTY) { + return 1; + } + + chan_opened[id] &= ~(1 << type); + rx_irq_handler[id][type] = NULL; + tx_irq_handler[id][type] = NULL; + + if (chan_opened[id] == 0) { + // Stop IRQs by default + NVIC_DisableIRQ(rx_irq_id[id]); + NVIC_DisableIRQ(tx_irq_id[id]); + + send_msg_list_p[id] = NULL; + send_pending_list_p[id] = NULL; + recv_pending_head[id].data = NULL; + need_flow_ctrl[id] = false; + } + + return 0; } -int MCU2CP_API(hal_mcu2cp_opened)(enum HAL_MCU2CP_ID_T id) -{ - return !!chan_opened[id]; +int MCU2CP_API(hal_mcu2cp_start_recv)(enum HAL_MCU2CP_ID_T id) { + if (id >= HAL_MCU2CP_ID_QTY) { + return 1; + } + + NVIC_EnableIRQ(rx_irq_id[id]); + // Check if there is any previous unprocessed message + if (recv_pending_head[id].data) { + hal_mcu2cp_local_irq_set(id, HAL_MCU2CP_IRQ_SEND_IND); + } + return 0; } -int MCU2CP_API(hal_mcu2cp_local_irq_pending)(enum HAL_MCU2CP_ID_T id) -{ - uint32_t value; +int MCU2CP_API(hal_mcu2cp_stop_recv)(enum HAL_MCU2CP_ID_T id) { + if (id >= HAL_MCU2CP_ID_QTY) { + return 1; + } + + NVIC_DisableIRQ(rx_irq_id[id]); + return 0; +} + +int MCU2CP_API(hal_mcu2cp_send)(enum HAL_MCU2CP_ID_T id, + enum HAL_MCU2CP_MSG_TYPE_T type, + const unsigned char *data, unsigned int len) { + uint32_t lock; + int ret; + struct HAL_MCU2CP_SEND_RECORD_T *record; + struct HAL_MCU2CP_MSG_T *next; + int i; + + if (id >= HAL_MCU2CP_ID_QTY) { + return 1; + } + if (type >= HAL_MCU2CP_MSG_TYPE_QTY) { + return 2; + } + if ((chan_opened[id] & (1 << type)) == 0) { + return 3; + } + + NVIC_EnableIRQ(tx_irq_id[id]); + + ret = -1; + record = &send_msgs[id][0]; + + lock = int_lock(); + for (i = 0; i < MAX_SEND_RECORD_COUNT; i++) { + if (record->in_use) { + record++; + continue; + } + record->in_use = true; + record->msg.next = NULL; + record->msg.type = type; + record->msg.len = len; + record->msg.data = data; + if (send_msg_list_p[id] == NULL) { + send_msg_list_p[id] = &record->msg; + hal_mcu2cp_peer_irq_set(id, HAL_MCU2CP_IRQ_SEND_IND); + } else if (send_pending_list_p[id] == NULL) { + send_pending_list_p[id] = &record->msg; + } else { + next = send_pending_list_p[id]; + while (next->next) { + next = next->next; + } + next->next = &record->msg; + } + ret = 0; + // Prohibit sleep here + hal_mcu2cp_busy(id, true); + break; + } + int_unlock(lock); + + return ret; +} + +void MCU2CP_API(hal_mcu2cp_rx_done)(enum HAL_MCU2CP_ID_T id) { + hal_mcu2cp_peer_irq_set(id, HAL_MCU2CP_IRQ_RECV_DONE); +} + +int MCU2CP_API(hal_mcu2cp_opened)(enum HAL_MCU2CP_ID_T id) { + return !!chan_opened[id]; +} + +int MCU2CP_API(hal_mcu2cp_local_irq_pending)(enum HAL_MCU2CP_ID_T id) { + uint32_t value; #ifdef CP_API - if (id == HAL_MCU2CP_ID_0) { - value = CMU_MCU2CP_DATA_IND_SET | CMU_CP2MCU_DATA_DONE_SET; - } else { - value = CMU_MCU2CP_DATA1_IND_SET | CMU_CP2MCU_DATA1_DONE_SET; - } + if (id == HAL_MCU2CP_ID_0) { + value = CMU_MCU2CP_DATA_IND_SET | CMU_CP2MCU_DATA_DONE_SET; + } else { + value = CMU_MCU2CP_DATA1_IND_SET | CMU_CP2MCU_DATA1_DONE_SET; + } - return !!(cmu->MCU2CP_IRQ_SET & value); + return !!(cmu->MCU2CP_IRQ_SET & value); #else - if (id == HAL_MCU2CP_ID_0) { - value = CMU_CP2MCU_DATA_IND_SET | CMU_MCU2CP_DATA_DONE_SET; - } else { - value = CMU_CP2MCU_DATA1_IND_SET | CMU_MCU2CP_DATA1_DONE_SET; - } + if (id == HAL_MCU2CP_ID_0) { + value = CMU_CP2MCU_DATA_IND_SET | CMU_MCU2CP_DATA_DONE_SET; + } else { + value = CMU_CP2MCU_DATA1_IND_SET | CMU_MCU2CP_DATA1_DONE_SET; + } - return !!(cmu->CP2MCU_IRQ_SET & value); + return !!(cmu->CP2MCU_IRQ_SET & value); #endif } #endif - diff --git a/platform/hal/hal_memsc.c b/platform/hal/hal_memsc.c index 5a7d6dc..dc55066 100644 --- a/platform/hal/hal_memsc.c +++ b/platform/hal/hal_memsc.c @@ -13,34 +13,30 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_addr_map.h" #include "hal_memsc.h" #include "hal_cmu.h" +#include "plat_addr_map.h" -int hal_memsc_lock(enum HAL_MEMSC_ID_T id) -{ - if (id >= HAL_MEMSC_ID_QTY) { - return 0; - } +int hal_memsc_lock(enum HAL_MEMSC_ID_T id) { + if (id >= HAL_MEMSC_ID_QTY) { + return 0; + } - return (hal_cmu_get_memsc_addr())[id]; + return (hal_cmu_get_memsc_addr())[id]; } -void hal_memsc_unlock(enum HAL_MEMSC_ID_T id) -{ - if (id >= HAL_MEMSC_ID_QTY) { - return; - } +void hal_memsc_unlock(enum HAL_MEMSC_ID_T id) { + if (id >= HAL_MEMSC_ID_QTY) { + return; + } - (hal_cmu_get_memsc_addr())[id] = 1; + (hal_cmu_get_memsc_addr())[id] = 1; } -bool hal_memsc_avail(enum HAL_MEMSC_ID_T id) -{ - if (id >= HAL_MEMSC_ID_QTY) { - return false; - } +bool hal_memsc_avail(enum HAL_MEMSC_ID_T id) { + if (id >= HAL_MEMSC_ID_QTY) { + return false; + } - return !!((hal_cmu_get_memsc_addr())[4] & (1 << id)); + return !!((hal_cmu_get_memsc_addr())[4] & (1 << id)); } - diff --git a/platform/hal/hal_norflash.c b/platform/hal/hal_norflash.c index ddfa14d..e345e98 100644 --- a/platform/hal/hal_norflash.c +++ b/platform/hal/hal_norflash.c @@ -13,18 +13,18 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" -#include "plat_addr_map.h" -#include "cmsis.h" -#include "hal_norflaship.h" #include "hal_norflash.h" +#include "cmsis.h" #include "hal_bootmode.h" #include "hal_cmu.h" +#include "hal_norflaship.h" #include "hal_sysfreq.h" #include "hal_timer.h" #include "hal_trace.h" #include "norflash_cfg.h" #include "norflash_drv.h" +#include "plat_addr_map.h" +#include "plat_types.h" #include "pmu.h" #include "string.h" @@ -32,54 +32,57 @@ * * uint8_t data[1024]; * hal_norflash_open(HAL_NORFLASH_ID_0, HAL_NORFLASH_SPEED_26M, 0); - * \/\/ hal_norflash_open(HAL_NORFLASH_ID_0, HAL_NORFLASH_SPEED_13M, HAL_NORFLASH_OP_MODE_QUAD); - * \/\/ hal_norflash_open(HAL_NORFLASH_ID_0, HAL_NORFLASH_SPEED_13M, HAL_NORFLASH_OP_MODE_QUAD|HAL_NORFLASH_OP_MODE_CONTINUOUS_READ); + * \/\/ hal_norflash_open(HAL_NORFLASH_ID_0, HAL_NORFLASH_SPEED_13M, + * HAL_NORFLASH_OP_MODE_QUAD); + * \/\/ hal_norflash_open(HAL_NORFLASH_ID_0, HAL_NORFLASH_SPEED_13M, + * HAL_NORFLASH_OP_MODE_QUAD|HAL_NORFLASH_OP_MODE_CONTINUOUS_READ); * hal_norflash_erase(HAL_I2C_ID_0, 0, 4096); * memset(data, 0xcc, 1024); * hal_norflash_write(HAL_I2C_ID_0, 0, data, 1024); * for (i = 0; i < 10; ++i) { - * TRACE(2,"[0x%x] - 0x%x\n", 0x08000000 + i, *((volatile uint8_t *)(0x08000000 + i))); + * TRACE(2,"[0x%x] - 0x%x\n", 0x08000000 + i, *((volatile uint8_t + * *)(0x08000000 + i))); * } -*/ + */ -#define HAL_NORFLASH_CP_ID_LEN 2 +#define HAL_NORFLASH_CP_ID_LEN 2 -#define HAL_NORFLASH_YES 1 -#define HAL_NORFLASH_NO 0 +#define HAL_NORFLASH_YES 1 +#define HAL_NORFLASH_NO 0 // 64M Bytes -#define HAL_NORFLASH_ADDR_MASK 0x03FFFFFF +#define HAL_NORFLASH_ADDR_MASK 0x03FFFFFF // Protect lower 1/2 by default #ifndef FLASH_BLOCK_PROTECTION_64M_BIT -#define FLASH_BLOCK_PROTECTION_64M_BIT 0x0034 +#define FLASH_BLOCK_PROTECTION_64M_BIT 0x0034 #endif #ifndef FLASH_BLOCK_PROTECTION_32M_BIT -#define FLASH_BLOCK_PROTECTION_32M_BIT 0x0038 +#define FLASH_BLOCK_PROTECTION_32M_BIT 0x0038 #endif #ifndef FLASH_BLOCK_PROTECTION_16M_BIT -#define FLASH_BLOCK_PROTECTION_16M_BIT 0x0034 +#define FLASH_BLOCK_PROTECTION_16M_BIT 0x0034 #endif #ifndef FLASH_BLOCK_PROTECTION_8M_BIT -#define FLASH_BLOCK_PROTECTION_8M_BIT 0x0030 +#define FLASH_BLOCK_PROTECTION_8M_BIT 0x0030 #endif struct HAL_Norflash_Context { - bool opened; - uint8_t device_id[HAL_NORFLASH_DEVICE_ID_LEN]; + bool opened; + uint8_t device_id[HAL_NORFLASH_DEVICE_ID_LEN]; #ifdef FLASH_UNIQUE_ID - uint8_t unique_id[HAL_NORFLASH_UNIQUE_ID_LEN + HAL_NORFLASH_CP_ID_LEN]; + uint8_t unique_id[HAL_NORFLASH_UNIQUE_ID_LEN + HAL_NORFLASH_CP_ID_LEN]; #endif - uint32_t total_size; - uint32_t block_size; - uint32_t sector_size; - uint32_t page_size; - enum HAL_NORFLASH_RET_T open_state; + uint32_t total_size; + uint32_t block_size; + uint32_t sector_size; + uint32_t page_size; + enum HAL_NORFLASH_RET_T open_state; }; static struct HAL_Norflash_Context norflash_ctx[HAL_NORFLASH_ID_NUM]; -static const char * const err_not_opened = "norflash not opened"; +static const char *const err_not_opened = "norflash not opened"; static const struct HAL_NORFLASH_CONFIG_T norflash_cfg = { #if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) @@ -100,33 +103,30 @@ static const struct HAL_NORFLASH_CONFIG_T norflash_cfg = { .speed = HAL_NORFLASH_SPEED_104M, #endif #endif - .mode = HAL_NORFLASH_OP_MODE_STAND_SPI | - HAL_NORFLASH_OP_MODE_FAST_SPI | - HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | - HAL_NORFLASH_OP_MODE_DUAL_IO | - HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | - HAL_NORFLASH_OP_MODE_QUAD_IO | + .mode = HAL_NORFLASH_OP_MODE_STAND_SPI | HAL_NORFLASH_OP_MODE_FAST_SPI | + HAL_NORFLASH_OP_MODE_DUAL_OUTPUT | HAL_NORFLASH_OP_MODE_DUAL_IO | + HAL_NORFLASH_OP_MODE_QUAD_OUTPUT | HAL_NORFLASH_OP_MODE_QUAD_IO | HAL_NORFLASH_OP_MODE_CONTINUOUS_READ | - HAL_NORFLASH_OP_MODE_READ_WRAP | - HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | + HAL_NORFLASH_OP_MODE_READ_WRAP | HAL_NORFLASH_OP_MODE_PAGE_PROGRAM | HAL_NORFLASH_OP_MODE_DUAL_PAGE_PROGRAM | HAL_NORFLASH_OP_MODE_QUAD_PAGE_PROGRAM, .override_config = 0, }; #ifdef FLASH_FREQ_DYNAMIC_ADJUST -struct HAL_NORFLASH_FREQ_DYNAMIC_ADJUST_CONFIG_T{ - uint32_t source_clk; - uint8_t timing_index; +struct HAL_NORFLASH_FREQ_DYNAMIC_ADJUST_CONFIG_T { + uint32_t source_clk; + uint8_t timing_index; }; -static struct HAL_NORFLASH_FREQ_DYNAMIC_ADJUST_CONFIG_T norflash_freq_dynamic_adjust_cfg[2]; +static struct HAL_NORFLASH_FREQ_DYNAMIC_ADJUST_CONFIG_T + norflash_freq_dynamic_adjust_cfg[2]; #endif #ifdef FLASH_SUSPEND enum SUSPEND_STATE_T { - SUSPEND_STATE_NONE, - SUSPEND_STATE_ERASE, - SUSPEND_STATE_PROGRAM, + SUSPEND_STATE_NONE, + SUSPEND_STATE_ERASE, + SUSPEND_STATE_PROGRAM, }; static enum SUSPEND_STATE_T suspend_state; @@ -144,1288 +144,606 @@ static uint16_t sec_reg_pp_size; static bool sec_reg_enabled; #endif -enum HAL_CMU_FREQ_T hal_norflash_clk_to_cmu_freq(uint32_t clk) -{ - enum HAL_CMU_FREQ_T freq; +enum HAL_CMU_FREQ_T hal_norflash_clk_to_cmu_freq(uint32_t clk) { + enum HAL_CMU_FREQ_T freq; - if (clk >= HAL_NORFLASH_SPEED_208M) { - freq = HAL_CMU_FREQ_208M; - } else if (clk >= HAL_NORFLASH_SPEED_104M) { - freq = HAL_CMU_FREQ_104M; - } else if (clk >= HAL_NORFLASH_SPEED_78M) { - freq = HAL_CMU_FREQ_78M; - } else if (clk >= HAL_NORFLASH_SPEED_52M) { - freq = HAL_CMU_FREQ_52M; - } else { - freq = HAL_CMU_FREQ_26M; - } + if (clk >= HAL_NORFLASH_SPEED_208M) { + freq = HAL_CMU_FREQ_208M; + } else if (clk >= HAL_NORFLASH_SPEED_104M) { + freq = HAL_CMU_FREQ_104M; + } else if (clk >= HAL_NORFLASH_SPEED_78M) { + freq = HAL_CMU_FREQ_78M; + } else if (clk >= HAL_NORFLASH_SPEED_52M) { + freq = HAL_CMU_FREQ_52M; + } else { + freq = HAL_CMU_FREQ_26M; + } #if defined(CHIP_BEST1000) && defined(AUD_PLL_DOUBLE) - if (freq == HAL_CMU_FREQ_208M) { - freq = HAL_CMU_FREQ_104M; - } + if (freq == HAL_CMU_FREQ_208M) { + freq = HAL_CMU_FREQ_104M; + } #endif #ifdef SIMU #ifdef SIMU_FAST_FLASH -#define MAX_SIMU_FLASH_FREQ HAL_CMU_FREQ_104M +#define MAX_SIMU_FLASH_FREQ HAL_CMU_FREQ_104M #else -#define MAX_SIMU_FLASH_FREQ HAL_CMU_FREQ_52M +#define MAX_SIMU_FLASH_FREQ HAL_CMU_FREQ_52M #endif - if (freq > MAX_SIMU_FLASH_FREQ) { - freq = MAX_SIMU_FLASH_FREQ; - } + if (freq > MAX_SIMU_FLASH_FREQ) { + freq = MAX_SIMU_FLASH_FREQ; + } #endif - return freq; + return freq; } -enum HAL_NORFLASH_RET_T hal_norflash_get_size(enum HAL_NORFLASH_ID_T id, uint32_t *total_size, - uint32_t *block_size, uint32_t *sector_size, - uint32_t *page_size) -{ - ASSERT(norflash_ctx[id].opened, err_not_opened); +enum HAL_NORFLASH_RET_T hal_norflash_get_size(enum HAL_NORFLASH_ID_T id, + uint32_t *total_size, + uint32_t *block_size, + uint32_t *sector_size, + uint32_t *page_size) { + ASSERT(norflash_ctx[id].opened, err_not_opened); - if (total_size) { - *total_size = norflash_ctx[id].total_size; - } - if (block_size) { - *block_size = norflash_ctx[id].block_size; - } - if (sector_size) { - *sector_size = norflash_ctx[id].sector_size; - } - if (page_size) { - *page_size = norflash_ctx[id].page_size; - } - return HAL_NORFLASH_OK; + if (total_size) { + *total_size = norflash_ctx[id].total_size; + } + if (block_size) { + *block_size = norflash_ctx[id].block_size; + } + if (sector_size) { + *sector_size = norflash_ctx[id].sector_size; + } + if (page_size) { + *page_size = norflash_ctx[id].page_size; + } + return HAL_NORFLASH_OK; } -enum HAL_NORFLASH_RET_T hal_norflash_get_boundary(enum HAL_NORFLASH_ID_T id, uint32_t address, - uint32_t *block_boundary, uint32_t *sector_boundary) -{ - ASSERT(norflash_ctx[id].opened, err_not_opened); +enum HAL_NORFLASH_RET_T hal_norflash_get_boundary(enum HAL_NORFLASH_ID_T id, + uint32_t address, + uint32_t *block_boundary, + uint32_t *sector_boundary) { + ASSERT(norflash_ctx[id].opened, err_not_opened); - static const uint32_t flash_base[] = { FLASH_BASE, FLASHX_BASE, FLASH_NC_BASE, FLASHX_NC_BASE, }; - int i; + static const uint32_t flash_base[] = { + FLASH_BASE, + FLASHX_BASE, + FLASH_NC_BASE, + FLASHX_NC_BASE, + }; + int i; - for (i = 0; i < ARRAY_SIZE(flash_base); i++) { - if (flash_base[i] <= address && address < flash_base[i] + norflash_ctx[id].total_size) { - address -= flash_base[i]; - if (block_boundary) - *block_boundary = flash_base[i] + (address/norflash_ctx[id].block_size)*norflash_ctx[id].block_size; - if (sector_boundary) - *sector_boundary = flash_base[i] + (address/norflash_ctx[id].sector_size)*norflash_ctx[id].sector_size; - break; - } + for (i = 0; i < ARRAY_SIZE(flash_base); i++) { + if (flash_base[i] <= address && + address < flash_base[i] + norflash_ctx[id].total_size) { + address -= flash_base[i]; + if (block_boundary) + *block_boundary = + flash_base[i] + (address / norflash_ctx[id].block_size) * + norflash_ctx[id].block_size; + if (sector_boundary) + *sector_boundary = + flash_base[i] + (address / norflash_ctx[id].sector_size) * + norflash_ctx[id].sector_size; + break; } + } - if (i == ARRAY_SIZE(flash_base)) { - return HAL_NORFLASH_BAD_ADDR; - } + if (i == ARRAY_SIZE(flash_base)) { + return HAL_NORFLASH_BAD_ADDR; + } - return HAL_NORFLASH_OK; + return HAL_NORFLASH_OK; } -enum HAL_NORFLASH_RET_T hal_norflash_get_id(enum HAL_NORFLASH_ID_T id, uint8_t *value, uint32_t len) -{ - len = MIN(len, sizeof(norflash_ctx[id].device_id)); +enum HAL_NORFLASH_RET_T hal_norflash_get_id(enum HAL_NORFLASH_ID_T id, + uint8_t *value, uint32_t len) { + len = MIN(len, sizeof(norflash_ctx[id].device_id)); - memcpy(value, norflash_ctx[id].device_id, len); + memcpy(value, norflash_ctx[id].device_id, len); - return HAL_NORFLASH_OK; + return HAL_NORFLASH_OK; } #ifdef FLASH_UNIQUE_ID -enum HAL_NORFLASH_RET_T hal_norflash_get_unique_id(enum HAL_NORFLASH_ID_T id, uint8_t *value, uint32_t len) -{ - ASSERT(norflash_ctx[id].opened, err_not_opened); +enum HAL_NORFLASH_RET_T hal_norflash_get_unique_id(enum HAL_NORFLASH_ID_T id, + uint8_t *value, + uint32_t len) { + ASSERT(norflash_ctx[id].opened, err_not_opened); - len = MIN(len, sizeof(norflash_ctx[id].unique_id)); + len = MIN(len, sizeof(norflash_ctx[id].unique_id)); - memcpy(value, norflash_ctx[id].unique_id, len); + memcpy(value, norflash_ctx[id].unique_id, len); - return HAL_NORFLASH_OK; + return HAL_NORFLASH_OK; } #endif #ifdef FLASH_PROTECTION -static uint32_t hal_norflash_get_bp_cfg(enum HAL_NORFLASH_ID_T id) -{ - uint32_t val = 0; +static uint32_t hal_norflash_get_bp_cfg(enum HAL_NORFLASH_ID_T id) { + uint32_t val = 0; - // Set BP and CMP bits - // E.g., for 32M bit flash, BP=0b00010 CMP=1 can protect 0x000000 - 0x3DFFFF - - if (FLASH_SIZE != hal_norflash_get_flash_total_size(id)) { - return val; - } - - if (norflash_ctx[id].device_id[0] != 0xC8 && // GigaDevice - norflash_ctx[id].device_id[0] != 0x85 && // Puya - norflash_ctx[id].device_id[0] != 0x20 // Xinxin - ) { - return val; - } - - if (FLASH_SIZE == 0x800000) { - val = FLASH_BLOCK_PROTECTION_64M_BIT; - } else if (FLASH_SIZE == 0x400000) { - val = FLASH_BLOCK_PROTECTION_32M_BIT; - } else if (FLASH_SIZE == 0x200000) { - val = FLASH_BLOCK_PROTECTION_16M_BIT; - } else if (FLASH_SIZE == 0x100000) { - val = FLASH_BLOCK_PROTECTION_8M_BIT; - } else { - // CAUTION: - // Different configuration for GD and Puya - } + // Set BP and CMP bits + // E.g., for 32M bit flash, BP=0b00010 CMP=1 can protect 0x000000 - 0x3DFFFF + if (FLASH_SIZE != hal_norflash_get_flash_total_size(id)) { return val; + } + + if (norflash_ctx[id].device_id[0] != 0xC8 && // GigaDevice + norflash_ctx[id].device_id[0] != 0x85 && // Puya + norflash_ctx[id].device_id[0] != 0x20 // Xinxin + ) { + return val; + } + + if (FLASH_SIZE == 0x800000) { + val = FLASH_BLOCK_PROTECTION_64M_BIT; + } else if (FLASH_SIZE == 0x400000) { + val = FLASH_BLOCK_PROTECTION_32M_BIT; + } else if (FLASH_SIZE == 0x200000) { + val = FLASH_BLOCK_PROTECTION_16M_BIT; + } else if (FLASH_SIZE == 0x100000) { + val = FLASH_BLOCK_PROTECTION_8M_BIT; + } else { + // CAUTION: + // Different configuration for GD and Puya + } + + return val; } #endif -enum HAL_NORFLASH_RET_T hal_norflash_enable_protection(enum HAL_NORFLASH_ID_T id) -{ - int ret = 0; +enum HAL_NORFLASH_RET_T +hal_norflash_enable_protection(enum HAL_NORFLASH_ID_T id) { + int ret = 0; #ifdef FLASH_PROTECTION - uint32_t lock; + uint32_t lock; - if (!norflash_ctx[id].opened) { - return HAL_NORFLASH_NOT_OPENED; - } + if (!norflash_ctx[id].opened) { + return HAL_NORFLASH_NOT_OPENED; + } - lock = int_lock_global(); + lock = int_lock_global(); - norflash_pre_operation(); + norflash_pre_operation(); - ret = norflash_set_block_protection(hal_norflash_get_bp_cfg(id)); + ret = norflash_set_block_protection(hal_norflash_get_bp_cfg(id)); - norflash_post_operation(); + norflash_post_operation(); - int_unlock_global(lock); + int_unlock_global(lock); #endif - return ret ? HAL_NORFLASH_BAD_OP : HAL_NORFLASH_OK; + return ret ? HAL_NORFLASH_BAD_OP : HAL_NORFLASH_OK; } -enum HAL_NORFLASH_RET_T hal_norflash_disable_protection(enum HAL_NORFLASH_ID_T id) -{ - int ret = 0; +enum HAL_NORFLASH_RET_T +hal_norflash_disable_protection(enum HAL_NORFLASH_ID_T id) { + int ret = 0; #ifdef FLASH_PROTECTION - uint32_t lock; + uint32_t lock; - if (!norflash_ctx[id].opened) { - return HAL_NORFLASH_NOT_OPENED; - } + if (!norflash_ctx[id].opened) { + return HAL_NORFLASH_NOT_OPENED; + } - lock = int_lock_global(); + lock = int_lock_global(); - norflash_pre_operation(); + norflash_pre_operation(); - ret = norflash_set_block_protection(0); + ret = norflash_set_block_protection(0); - norflash_post_operation(); + norflash_post_operation(); - int_unlock_global(lock); + int_unlock_global(lock); #endif - return ret ? HAL_NORFLASH_BAD_OP : HAL_NORFLASH_OK; + return ret ? HAL_NORFLASH_BAD_OP : HAL_NORFLASH_OK; } #ifdef FLASH_SECURITY_REGISTER -enum HAL_NORFLASH_RET_T hal_norflash_security_register_lock(enum HAL_NORFLASH_ID_T id, uint32_t start_address, uint32_t len) -{ - uint32_t remain_len; - int ret = 0; - uint32_t reg_base; - uint32_t reg_pos; - uint32_t pos; - uint32_t lock_size; - uint32_t reg_id; +enum HAL_NORFLASH_RET_T +hal_norflash_security_register_lock(enum HAL_NORFLASH_ID_T id, + uint32_t start_address, uint32_t len) { + uint32_t remain_len; + int ret = 0; + uint32_t reg_base; + uint32_t reg_pos; + uint32_t pos; + uint32_t lock_size; + uint32_t reg_id; - ASSERT(norflash_ctx[id].opened, err_not_opened); + ASSERT(norflash_ctx[id].opened, err_not_opened); - if (!sec_reg_enabled) { - return HAL_NORFLASH_BAD_OP; - } - // Check address and length - if (sec_reg_total_size <= start_address) { - return HAL_NORFLASH_BAD_ADDR; - } - remain_len = sec_reg_total_size - start_address; - if (len > remain_len) { - return HAL_NORFLASH_BAD_LEN; - } - // Align to register boundary - remain_len = start_address & (sec_reg_size - 1); - if (remain_len) { - start_address -= remain_len; - len += remain_len; - } - remain_len = len & (sec_reg_size - 1); - if (remain_len) { - len += sec_reg_size - remain_len; + if (!sec_reg_enabled) { + return HAL_NORFLASH_BAD_OP; + } + // Check address and length + if (sec_reg_total_size <= start_address) { + return HAL_NORFLASH_BAD_ADDR; + } + remain_len = sec_reg_total_size - start_address; + if (len > remain_len) { + return HAL_NORFLASH_BAD_LEN; + } + // Align to register boundary + remain_len = start_address & (sec_reg_size - 1); + if (remain_len) { + start_address -= remain_len; + len += remain_len; + } + remain_len = len & (sec_reg_size - 1); + if (remain_len) { + len += sec_reg_size - remain_len; + } + + pos = start_address; + remain_len = len; + + reg_base = sec_reg_base; + reg_pos = 0; + reg_id = 0; + + norflash_pre_operation(); + + while (remain_len > 0 && ret == 0) { + if (reg_pos <= pos && pos < reg_pos + sec_reg_size) { + // lock a register + lock_size = sec_reg_size - (pos - reg_pos); + ret = norflash_security_register_lock(reg_id); + if (remain_len > lock_size) { + remain_len -= lock_size; + } else { + remain_len = 0; + } + pos += lock_size; } + reg_pos += sec_reg_size; + reg_base += sec_reg_offset; + reg_id++; + } - pos = start_address; - remain_len = len; + norflash_post_operation(); - reg_base = sec_reg_base; - reg_pos = 0; - reg_id = 0; - - norflash_pre_operation(); - - while (remain_len > 0 && ret == 0) { - if (reg_pos <= pos && pos < reg_pos + sec_reg_size) { - // lock a register - lock_size = sec_reg_size - (pos - reg_pos); - ret = norflash_security_register_lock(reg_id); - if (remain_len > lock_size) { - remain_len -= lock_size; - } else { - remain_len = 0; - } - pos += lock_size; - } - reg_pos += sec_reg_size; - reg_base += sec_reg_offset; - reg_id++; - } - - norflash_post_operation(); - - return ret; + return ret; } -enum HAL_NORFLASH_RET_T hal_norflash_security_register_erase(enum HAL_NORFLASH_ID_T id, uint32_t start_address, uint32_t len) -{ - uint32_t remain_len; - enum HAL_NORFLASH_RET_T ret = HAL_NORFLASH_OK; - uint32_t reg_base; - uint32_t reg_pos; - uint32_t pos; - uint32_t erase_size; +enum HAL_NORFLASH_RET_T +hal_norflash_security_register_erase(enum HAL_NORFLASH_ID_T id, + uint32_t start_address, uint32_t len) { + uint32_t remain_len; + enum HAL_NORFLASH_RET_T ret = HAL_NORFLASH_OK; + uint32_t reg_base; + uint32_t reg_pos; + uint32_t pos; + uint32_t erase_size; - ASSERT(norflash_ctx[id].opened, err_not_opened); + ASSERT(norflash_ctx[id].opened, err_not_opened); - if (!sec_reg_enabled) { - return HAL_NORFLASH_BAD_OP; - } - // Check address and length - if (sec_reg_total_size <= start_address) { - return HAL_NORFLASH_BAD_ADDR; - } - remain_len = sec_reg_total_size - start_address; - if (len > remain_len) { - return HAL_NORFLASH_BAD_LEN; - } - // Align to register boundary - remain_len = start_address & (sec_reg_size - 1); - if (remain_len) { - start_address -= remain_len; - len += remain_len; - } - remain_len = len & (sec_reg_size - 1); - if (remain_len) { - len += sec_reg_size - remain_len; + if (!sec_reg_enabled) { + return HAL_NORFLASH_BAD_OP; + } + // Check address and length + if (sec_reg_total_size <= start_address) { + return HAL_NORFLASH_BAD_ADDR; + } + remain_len = sec_reg_total_size - start_address; + if (len > remain_len) { + return HAL_NORFLASH_BAD_LEN; + } + // Align to register boundary + remain_len = start_address & (sec_reg_size - 1); + if (remain_len) { + start_address -= remain_len; + len += remain_len; + } + remain_len = len & (sec_reg_size - 1); + if (remain_len) { + len += sec_reg_size - remain_len; + } + + pos = start_address; + remain_len = len; + + reg_base = sec_reg_base; + reg_pos = 0; + + norflash_pre_operation(); + + while (remain_len > 0 && ret == HAL_NORFLASH_OK) { + if (reg_pos <= pos && pos < reg_pos + sec_reg_size) { + // erase a register + erase_size = sec_reg_size - (pos - reg_pos); + ret = norflash_security_register_erase(reg_base + (pos - reg_pos)); + if (remain_len > erase_size) { + remain_len -= erase_size; + } else { + remain_len = 0; + } + pos += erase_size; } + reg_pos += sec_reg_size; + reg_base += sec_reg_offset; + } - pos = start_address; - remain_len = len; + norflash_post_operation(); - reg_base = sec_reg_base; - reg_pos = 0; - - norflash_pre_operation(); - - while (remain_len > 0 && ret == HAL_NORFLASH_OK) { - if (reg_pos <= pos && pos < reg_pos + sec_reg_size) { - // erase a register - erase_size = sec_reg_size - (pos - reg_pos); - ret = norflash_security_register_erase(reg_base + (pos - reg_pos)); - if (remain_len > erase_size) { - remain_len -= erase_size; - } else { - remain_len = 0; - } - pos += erase_size; - } - reg_pos += sec_reg_size; - reg_base += sec_reg_offset; - } - - norflash_post_operation(); - - return ret; + return ret; } -enum HAL_NORFLASH_RET_T hal_norflash_security_register_write(enum HAL_NORFLASH_ID_T id, uint32_t start_address, const uint8_t *buffer, uint32_t len) -{ - const uint8_t *current_buffer; - uint32_t remain_len; - enum HAL_NORFLASH_RET_T ret = HAL_NORFLASH_OK; - uint32_t reg_base; - uint32_t reg_pos; - uint32_t pos; - uint32_t write_size; - uint32_t each_write; - uint32_t pp_remain; +enum HAL_NORFLASH_RET_T +hal_norflash_security_register_write(enum HAL_NORFLASH_ID_T id, + uint32_t start_address, + const uint8_t *buffer, uint32_t len) { + const uint8_t *current_buffer; + uint32_t remain_len; + enum HAL_NORFLASH_RET_T ret = HAL_NORFLASH_OK; + uint32_t reg_base; + uint32_t reg_pos; + uint32_t pos; + uint32_t write_size; + uint32_t each_write; + uint32_t pp_remain; - ASSERT(norflash_ctx[id].opened, err_not_opened); + ASSERT(norflash_ctx[id].opened, err_not_opened); - if (!sec_reg_enabled) { - return HAL_NORFLASH_BAD_OP; - } - // Check address and length - if (sec_reg_total_size <= start_address) { - return HAL_NORFLASH_BAD_ADDR; - } - remain_len = sec_reg_total_size - start_address; - if (len > remain_len) { - return HAL_NORFLASH_BAD_LEN; - } + if (!sec_reg_enabled) { + return HAL_NORFLASH_BAD_OP; + } + // Check address and length + if (sec_reg_total_size <= start_address) { + return HAL_NORFLASH_BAD_ADDR; + } + remain_len = sec_reg_total_size - start_address; + if (len > remain_len) { + return HAL_NORFLASH_BAD_LEN; + } - pos = start_address; - current_buffer = buffer; - remain_len = len; + pos = start_address; + current_buffer = buffer; + remain_len = len; - reg_base = sec_reg_base; - reg_pos = 0; + reg_base = sec_reg_base; + reg_pos = 0; - norflash_pre_operation(); + norflash_pre_operation(); - while (remain_len > 0 && ret == HAL_NORFLASH_OK) { - if (reg_pos <= pos && pos < reg_pos + sec_reg_size) { - // write a register - if (pos + remain_len <= reg_pos + sec_reg_size) { - write_size = remain_len; - } else { - write_size = sec_reg_size - (pos - reg_pos); - } - remain_len -= write_size; - while (write_size > 0 && ret == HAL_NORFLASH_OK) { - if (write_size > sec_reg_pp_size) { - each_write = sec_reg_pp_size; - } else { - each_write = write_size; - } - // Align to security register program page size - pp_remain = sec_reg_pp_size - ((pos - reg_pos) & (sec_reg_pp_size - 1)); - if (each_write > pp_remain) { - each_write = pp_remain; - } - ret = norflash_security_register_write(reg_base + (pos - reg_pos), current_buffer, each_write); - write_size -= each_write; - pos += each_write; - current_buffer += each_write; - } + while (remain_len > 0 && ret == HAL_NORFLASH_OK) { + if (reg_pos <= pos && pos < reg_pos + sec_reg_size) { + // write a register + if (pos + remain_len <= reg_pos + sec_reg_size) { + write_size = remain_len; + } else { + write_size = sec_reg_size - (pos - reg_pos); + } + remain_len -= write_size; + while (write_size > 0 && ret == HAL_NORFLASH_OK) { + if (write_size > sec_reg_pp_size) { + each_write = sec_reg_pp_size; + } else { + each_write = write_size; } - reg_pos += sec_reg_size; - reg_base += sec_reg_offset; + // Align to security register program page size + pp_remain = sec_reg_pp_size - ((pos - reg_pos) & (sec_reg_pp_size - 1)); + if (each_write > pp_remain) { + each_write = pp_remain; + } + ret = norflash_security_register_write(reg_base + (pos - reg_pos), + current_buffer, each_write); + write_size -= each_write; + pos += each_write; + current_buffer += each_write; + } } + reg_pos += sec_reg_size; + reg_base += sec_reg_offset; + } - norflash_post_operation(); + norflash_post_operation(); - return ret; + return ret; } -enum HAL_NORFLASH_RET_T hal_norflash_security_register_read(enum HAL_NORFLASH_ID_T id, uint32_t start_address, uint8_t *buffer, uint32_t len) -{ - uint8_t *current_buffer; - uint32_t remain_len, read_size; - int ret = 0; - uint32_t reg_base; - uint32_t reg_pos; - uint32_t pos; +enum HAL_NORFLASH_RET_T +hal_norflash_security_register_read(enum HAL_NORFLASH_ID_T id, + uint32_t start_address, uint8_t *buffer, + uint32_t len) { + uint8_t *current_buffer; + uint32_t remain_len, read_size; + int ret = 0; + uint32_t reg_base; + uint32_t reg_pos; + uint32_t pos; #ifdef FLASH_SEC_REG_FIFO_READ - uint32_t each_read; + uint32_t each_read; #endif - ASSERT(norflash_ctx[id].opened, err_not_opened); + ASSERT(norflash_ctx[id].opened, err_not_opened); - if (!sec_reg_enabled) { - return HAL_NORFLASH_BAD_OP; - } - // Check address and length - if (sec_reg_total_size <= start_address) { - return HAL_NORFLASH_BAD_ADDR; - } - remain_len = sec_reg_total_size - start_address; - if (len > remain_len) { - return HAL_NORFLASH_BAD_LEN; - } + if (!sec_reg_enabled) { + return HAL_NORFLASH_BAD_OP; + } + // Check address and length + if (sec_reg_total_size <= start_address) { + return HAL_NORFLASH_BAD_ADDR; + } + remain_len = sec_reg_total_size - start_address; + if (len > remain_len) { + return HAL_NORFLASH_BAD_LEN; + } - pos = start_address; - current_buffer = buffer; - remain_len = len; + pos = start_address; + current_buffer = buffer; + remain_len = len; - reg_base = sec_reg_base; - reg_pos = 0; + reg_base = sec_reg_base; + reg_pos = 0; - norflash_pre_operation(); + norflash_pre_operation(); #ifndef FLASH_SEC_REG_FIFO_READ - uint32_t mode = norflash_security_register_enable_read(); + uint32_t mode = norflash_security_register_enable_read(); #endif - while (remain_len > 0 && ret == 0) { - if (reg_pos <= pos && pos < reg_pos + sec_reg_size) { - // read a register - if (pos + remain_len <= reg_pos + sec_reg_size) { - read_size = remain_len; - } else { - read_size = sec_reg_size - (pos - reg_pos); - } - remain_len -= read_size; + while (remain_len > 0 && ret == 0) { + if (reg_pos <= pos && pos < reg_pos + sec_reg_size) { + // read a register + if (pos + remain_len <= reg_pos + sec_reg_size) { + read_size = remain_len; + } else { + read_size = sec_reg_size - (pos - reg_pos); + } + remain_len -= read_size; #ifdef FLASH_SEC_REG_FIFO_READ - while (read_size > 0 && ret == 0) { - if (read_size > NORFLASHIP_RXFIFO_SIZE) { - each_read = NORFLASHIP_RXFIFO_SIZE; - } else { - each_read = read_size; - } - ret = norflash_security_register_read(reg_base + (pos - reg_pos), current_buffer, each_read); - read_size -= each_read; - pos += each_read; - current_buffer += each_read; - } + while (read_size > 0 && ret == 0) { + if (read_size > NORFLASHIP_RXFIFO_SIZE) { + each_read = NORFLASHIP_RXFIFO_SIZE; + } else { + each_read = read_size; + } + ret = norflash_security_register_read(reg_base + (pos - reg_pos), + current_buffer, each_read); + read_size -= each_read; + pos += each_read; + current_buffer += each_read; + } #else - memcpy(current_buffer, (void *)(reg_base + (pos - reg_pos)), read_size); - pos += read_size; - current_buffer += read_size; + memcpy(current_buffer, (void *)(reg_base + (pos - reg_pos)), read_size); + pos += read_size; + current_buffer += read_size; #endif - } - reg_pos += sec_reg_size; - reg_base += sec_reg_offset; } + reg_pos += sec_reg_size; + reg_base += sec_reg_offset; + } #ifndef FLASH_SEC_REG_FIFO_READ - norflash_security_register_disable_read(mode); + norflash_security_register_disable_read(mode); #endif - norflash_post_operation(); + norflash_post_operation(); - return (ret ? HAL_NORFLASH_ERR : HAL_NORFLASH_OK); + return (ret ? HAL_NORFLASH_ERR : HAL_NORFLASH_OK); } -static enum HAL_NORFLASH_RET_T hal_norflash_parse_security_register_config(void) -{ - union DRV_NORFLASH_SEC_REG_CFG_T cfg; - uint32_t reg_cnt; +static enum HAL_NORFLASH_RET_T +hal_norflash_parse_security_register_config(void) { + union DRV_NORFLASH_SEC_REG_CFG_T cfg; + uint32_t reg_cnt; - cfg = norflash_get_security_register_config(); + cfg = norflash_get_security_register_config(); - if (!cfg.s.enabled) { - return HAL_NORFLASH_BAD_OP; - } + if (!cfg.s.enabled) { + return HAL_NORFLASH_BAD_OP; + } - if (cfg.s.base == SEC_REG_BASE_0X1000) { - sec_reg_base = 0x1000; - } else if (cfg.s.base == SEC_REG_BASE_0X0000) { - sec_reg_base = 0; - } else { - return HAL_NORFLASH_BAD_CFG; - } - sec_reg_base += FLASH_NC_BASE; + if (cfg.s.base == SEC_REG_BASE_0X1000) { + sec_reg_base = 0x1000; + } else if (cfg.s.base == SEC_REG_BASE_0X0000) { + sec_reg_base = 0; + } else { + return HAL_NORFLASH_BAD_CFG; + } + sec_reg_base += FLASH_NC_BASE; - if (cfg.s.size == SEC_REG_SIZE_1024) { - sec_reg_size = 1024; - } else if (cfg.s.size == SEC_REG_SIZE_512) { - sec_reg_size = 512; - } else if (cfg.s.size == SEC_REG_SIZE_256) { - sec_reg_size = 256; - } else { - return HAL_NORFLASH_BAD_CFG; - } + if (cfg.s.size == SEC_REG_SIZE_1024) { + sec_reg_size = 1024; + } else if (cfg.s.size == SEC_REG_SIZE_512) { + sec_reg_size = 512; + } else if (cfg.s.size == SEC_REG_SIZE_256) { + sec_reg_size = 256; + } else { + return HAL_NORFLASH_BAD_CFG; + } - if (cfg.s.offset == SEC_REG_OFFSET_0X1000) { - sec_reg_offset = 0x1000; - } else if (cfg.s.offset == SEC_REG_OFFSET_0X0100) { - sec_reg_offset = 0x0100; - } else { - return HAL_NORFLASH_BAD_CFG; - } + if (cfg.s.offset == SEC_REG_OFFSET_0X1000) { + sec_reg_offset = 0x1000; + } else if (cfg.s.offset == SEC_REG_OFFSET_0X0100) { + sec_reg_offset = 0x0100; + } else { + return HAL_NORFLASH_BAD_CFG; + } - if (sec_reg_size > sec_reg_offset) { - return HAL_NORFLASH_BAD_CFG; - } + if (sec_reg_size > sec_reg_offset) { + return HAL_NORFLASH_BAD_CFG; + } - if (cfg.s.cnt == SEC_REG_CNT_3) { - reg_cnt = 3; - } else if (cfg.s.cnt == SEC_REG_CNT_4) { - reg_cnt = 4; - } else { - return HAL_NORFLASH_BAD_CFG; - } + if (cfg.s.cnt == SEC_REG_CNT_3) { + reg_cnt = 3; + } else if (cfg.s.cnt == SEC_REG_CNT_4) { + reg_cnt = 4; + } else { + return HAL_NORFLASH_BAD_CFG; + } - if (cfg.s.pp == SEC_REG_PP_256) { - sec_reg_pp_size = 256; - } else if (cfg.s.pp == SEC_REG_PP_1024) { - sec_reg_pp_size = 1024; - } else { - return HAL_NORFLASH_BAD_CFG; - } + if (cfg.s.pp == SEC_REG_PP_256) { + sec_reg_pp_size = 256; + } else if (cfg.s.pp == SEC_REG_PP_1024) { + sec_reg_pp_size = 1024; + } else { + return HAL_NORFLASH_BAD_CFG; + } #if (CHIP_FLASH_CTRL_VER <= 1) #ifdef FLASH_SEC_REG_PP_1024 - // To write more than 256 bytes on flash controller V1, SPI rate must be lowered to avoid tx FIFO underflow. - // Otherwise, the data must be split into pieces with size no more than 256 bytes. + // To write more than 256 bytes on flash controller V1, SPI rate must be + // lowered to avoid tx FIFO underflow. Otherwise, the data must be split into + // pieces with size no more than 256 bytes. #else - sec_reg_pp_size = 256; + sec_reg_pp_size = 256; #endif #endif - sec_reg_total_size = sec_reg_size * reg_cnt; + sec_reg_total_size = sec_reg_size * reg_cnt; - return HAL_NORFLASH_OK; + return HAL_NORFLASH_OK; } #endif -static void hal_norflash_reset_timing(void) -{ - const uint32_t default_div = 8; +static void hal_norflash_reset_timing(void) { + const uint32_t default_div = 8; - // Restore default divider - norflaship_div(default_div); - norflash_init_sample_delay_by_div(default_div); + // Restore default divider + norflaship_div(default_div); + norflash_init_sample_delay_by_div(default_div); } -static enum HAL_NORFLASH_RET_T _norflash_open(enum HAL_NORFLASH_ID_T id, const struct HAL_NORFLASH_CONFIG_T *cfg, - bool reopen, bool calib, uint32_t timing_idx) -{ - struct HAL_NORFLASH_CONFIG_T norcfg; - enum HAL_CMU_FREQ_T source_freq; - int result; - uint32_t op; - int found; +static enum HAL_NORFLASH_RET_T +_norflash_open(enum HAL_NORFLASH_ID_T id, + const struct HAL_NORFLASH_CONFIG_T *cfg, bool reopen, bool calib, + uint32_t timing_idx) { + struct HAL_NORFLASH_CONFIG_T norcfg; + enum HAL_CMU_FREQ_T source_freq; + int result; + uint32_t op; + int found; - if (reopen) { - ASSERT(norflash_ctx[id].opened, err_not_opened); - } + if (reopen) { + ASSERT(norflash_ctx[id].opened, err_not_opened); + } - // Place the config into ram - if (cfg == NULL) { - return HAL_NORFLASH_CFG_NULL; - } - memcpy(&norcfg, cfg, sizeof(norcfg)); + // Place the config into ram + if (cfg == NULL) { + return HAL_NORFLASH_CFG_NULL; + } + memcpy(&norcfg, cfg, sizeof(norcfg)); - norflaship_busy_wait(); + norflaship_busy_wait(); - // Reset states - norflash_ctx[id].opened = false; - norflash_ctx[id].open_state = HAL_NORFLASH_NOT_OPENED; + // Reset states + norflash_ctx[id].opened = false; + norflash_ctx[id].open_state = HAL_NORFLASH_NOT_OPENED; #ifdef FLASH_SUSPEND - suspend_state = SUSPEND_STATE_NONE; + suspend_state = SUSPEND_STATE_NONE; #endif #ifdef FLASH_SECURITY_REGISTER - sec_reg_enabled = false; + sec_reg_enabled = false; #endif - if (!reopen) { -#if (CHIP_FLASH_CTRL_VER >= 2) - // Set the direction of 4 IO pins to output when in idle - norflaship_set_idle_io_dir(0); -#endif -#if (CHIP_FLASH_CTRL_VER >= 3) - // Set the dummy cycles for security register read command - norflaship_dummy_others(8); -#endif - - // Reset norflash source clock - hal_cmu_flash_set_freq(HAL_CMU_FREQ_26M); - - // Reset controller timing - hal_norflash_reset_timing(); - - // Reset norflash in slow clock configuration - norflash_reset(); - - // Get device ID - norflash_get_id(norflash_ctx[id].device_id, sizeof(norflash_ctx[id].device_id)); - - // For each driver in array, match chip and select drv_ops - found = norflash_match_chip(norflash_ctx[id].device_id, sizeof(norflash_ctx[id].device_id)); - if (!found) { - result = HAL_NORFLASH_BAD_ID; - goto _exit; - } - -#ifdef FLASH_UNIQUE_ID - // 1) Flash controller V1: - // Use slow clock to avoid rx fifo overflow - // 2) Flash controller V2/3/4/5: - // Use slow clock to avoid stopping SPI clock - // (One bit might be read as a fixed 1 at the SPI clock stopping edge in some timing combinations) - // 3) Flash controller V6 or later: - // Can use fast clock - norflash_get_unique_id(norflash_ctx[id].unique_id, sizeof(norflash_ctx[id].unique_id)); -#endif - } - - // Set norflash source clock - source_freq = hal_norflash_clk_to_cmu_freq(norcfg.source_clk); - hal_cmu_flash_set_freq(source_freq); - - /* over write config */ - if (norcfg.override_config) { - /* div */ - norflaship_div(norcfg.div); - /* cmd quad */ - norflaship_cmdquad(norcfg.cmdquad?HAL_NORFLASH_YES:HAL_NORFLASH_NO); - /* sample delay */ - norflaship_samdly(norcfg.samdly); -#if 0 - /* dummy clc */ - norflaship_dummyclc(norcfg.dummyclc); - - /* dummy clc en */ - norflaship_dummyclcen(norcfg.dummyclcen); - - /* 4 byte address */ - norflaship_addrbyte4(norcfg.byte4byteaddr); -#endif - /* ru en */ - norflaship_ruen(norcfg.spiruen); - /* rd en */ - norflaship_rden(norcfg.spirden); - /* rd cmd */ - norflaship_rdcmd(norcfg.rdcmd); - /* frd cmd */ - norflaship_frdcmd(norcfg.frdcmd); - /* qrd cmd */ - norflaship_qrdcmd(norcfg.qrdcmd); - } else { - // Init divider - result = norflash_init_div(&norcfg); - if (result != 0) { - result = HAL_NORFLASH_BAD_DIV; - goto _exit; - } - - if (!reopen || calib) { - if (reopen) { - norflash_pre_operation(); - } - // Calib with the new divider - result = norflash_sample_delay_calib(DRV_NORFLASH_CALIB_FLASH_ID); - if (result != 0) { - result = HAL_NORFLASH_BAD_CALIB_ID; - goto _exit; - } - if (reopen) { - norflash_post_operation(); - } - } else { - norflash_set_sample_delay_index(timing_idx); - } - } - - if (!reopen) { - norflash_get_size(&norflash_ctx[id].total_size, &norflash_ctx[id].block_size, - &norflash_ctx[id].sector_size, &norflash_ctx[id].page_size); - -#ifdef FLASH_SECURITY_REGISTER - result = hal_norflash_parse_security_register_config(); - if (result == HAL_NORFLASH_OK) { - sec_reg_enabled = true; - } else if (result != HAL_NORFLASH_BAD_OP) { - goto _exit; - } -#endif - -#if (CHIP_FLASH_CTRL_VER <= 1) && !defined(FLASH_LOW_SPEED) && !defined(OSC_26M_X4_AUD2BB) - // 1) Flash controller V2 or later - // No requirement on system_freq - // 2) Flash controller V1 - // Requirement on system_freq when running in quad mode (4-line mode): - // Byte Access: flash_line_speed < 2 * system_freq - // Halfword Access: flash_line_speed < 4 * system_freq - // Word Access: flash_line_speed < 8 * system_freq - // The maximum flash_line_speed is 120M in spec, and PLL_FREQ / 2 in our system. - // Normally it is 24.576M * 8 / 2 ~= 100M. - // So the safe system_freq should be larger than 50M/25M/12.5M for byte/halfword/word access. - // Cached access to flash is always safe, because it is always word-aligned (system_freq is never below 26M). - // However, uncached access (e.g., access to audio/user/factory data sections) is under risk. - hal_sysfreq_set_min_freq(HAL_CMU_FREQ_52M); -#endif - -#if defined(PROGRAMMER) || defined(OTA_PROGRAMMER) - norflash_init_status(0); -#elif defined(FLASH_PROTECTION) - norflash_set_block_protection(hal_norflash_get_bp_cfg(id)); -#endif - } - - op = norcfg.mode; - if (norcfg.speed >= HAL_NORFLASH_SPEED_104M) { - op |= HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE; - } - - // Divider will be set to normal read mode - result = norflash_set_mode(op); - if (result != 0) { - result = HAL_NORFLASH_BAD_OP; - goto _exit; - } - - // ----------------------------- - // From now on, norflash_pre_operation() must be called before - // sending any command to flash - // ----------------------------- - - if (!reopen) { -#if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) - if (norcfg.dec_enable && (norcfg.dec_size > 0)) { - norflaship_dec_saddr(norcfg.dec_addr); - norflaship_dec_eaddr(norcfg.dec_addr + norcfg.dec_size); - norflaship_dec_index(norcfg.dec_idx); - norflaship_dec_enable(); - } else { - norflaship_dec_disable(); - } -#endif - -#if defined(CHIP_BEST2001) && (defined(PSRAMUHS_ENABLE) || defined(PSRAM_ENABLE)) - norflaship_fetch_disable(); -#endif - } - - if (!norcfg.override_config && (!reopen || calib)) { - result = norflash_sample_delay_calib(DRV_NORFLASH_CALIB_MAGIC_WORD); - if (result != 0) { - result = HAL_NORFLASH_BAD_CALIB_MAGIC; - goto _exit; - } - } - - norflash_ctx[id].opened = true; - - result = HAL_NORFLASH_OK; - -_exit: - if (result != HAL_NORFLASH_OK) { - hal_cmu_flash_set_freq(HAL_CMU_FREQ_26M); - hal_norflash_reset_timing(); - // Flash might be accessed again - } - - norflash_ctx[id].open_state = result; - - return result; -} - -enum HAL_NORFLASH_RET_T hal_norflash_open(enum HAL_NORFLASH_ID_T id, const struct HAL_NORFLASH_CONFIG_T *cfg) -{ - return _norflash_open(id, cfg, false, true, 0); -} - -enum HAL_NORFLASH_RET_T hal_norflash_reopen(enum HAL_NORFLASH_ID_T id, const struct HAL_NORFLASH_CONFIG_T *cfg) -{ - return _norflash_open(id, cfg, true, true, 0); -} - -enum HAL_NORFLASH_RET_T hal_norflash_apply_config(enum HAL_NORFLASH_ID_T id, const struct HAL_NORFLASH_CONFIG_T *cfg, uint32_t timing_idx) -{ - return _norflash_open(id, cfg, true, false, timing_idx); -} - -uint32_t hal_norflash_get_timing_index(enum HAL_NORFLASH_ID_T id) -{ - ASSERT(norflash_ctx[id].opened, err_not_opened); - return norflash_get_sample_delay_index(); -} - -void hal_norflash_show_calib_result(void) -{ - norflash_show_calib_result(); -} - -enum HAL_NORFLASH_RET_T hal_norflash_erase_chip(enum HAL_NORFLASH_ID_T id) -{ - uint32_t total_size = 0; - - ASSERT(norflash_ctx[id].opened, err_not_opened); - - total_size = norflash_ctx[id].total_size; - - return hal_norflash_erase(id, 0, total_size); -} - -static enum HAL_NORFLASH_RET_T hal_norflash_erase_int(enum HAL_NORFLASH_ID_T id, uint32_t start_address, uint32_t len, int suspend) -{ - uint32_t remain_len, current_address, total_size, block_size, sector_size; - enum HAL_NORFLASH_RET_T ret = HAL_NORFLASH_OK; - total_size = norflash_ctx[id].total_size; - block_size = norflash_ctx[id].block_size; - sector_size = norflash_ctx[id].sector_size; - - // Check address and length - if (total_size <= (start_address & HAL_NORFLASH_ADDR_MASK)) { - return HAL_NORFLASH_BAD_ADDR; - } - remain_len = total_size - (start_address & HAL_NORFLASH_ADDR_MASK); - if (len > remain_len) { - return HAL_NORFLASH_BAD_LEN; - } - -#ifdef PUYA_FLASH_ERASE_PAGE_ENABLE - // Align to page boundary - uint32_t page_size; - - page_size = norflash_ctx[id].page_size; - remain_len = start_address & (page_size - 1); - if (remain_len) { - start_address -= remain_len; - len += remain_len; - } - remain_len = len & (page_size - 1); - if (remain_len) { - len += page_size - remain_len; - } -#else - // Align to sector boundary - remain_len = start_address & (sector_size - 1); - if (remain_len) { - start_address -= remain_len; - len += remain_len; - } - remain_len = len & (sector_size - 1); - if (remain_len) { - len += sector_size - remain_len; - } -#endif - current_address = start_address; - remain_len = len; - - norflash_pre_operation(); - - if ((current_address & HAL_NORFLASH_ADDR_MASK) == 0 && remain_len >= total_size) { - // erase whole chip - ret = norflash_erase(current_address, DRV_NORFLASH_ERASE_CHIP, suspend); - } else { - while (remain_len > 0 && ret == HAL_NORFLASH_OK) { - if (remain_len >= block_size && ((current_address & (block_size - 1)) == 0)) { - // if large enough to erase a block and current_address is block boundary - erase a block - ret = norflash_erase(current_address, DRV_NORFLASH_ERASE_BLOCK, suspend); - remain_len -= block_size; - current_address += block_size; - } else { -#ifdef PUYA_FLASH_ERASE_PAGE_ENABLE - if (remain_len >= sector_size && ((current_address & (sector_size - 1)) == 0)) { - // if large enough to erase a sector and current_address is sector boundary - erase a sector - ret = norflash_erase(current_address, DRV_NORFLASH_ERASE_SECTOR, suspend); - remain_len -= sector_size; - current_address += sector_size; - } else { - // erase a page - ret = norflash_erase(current_address, DRV_NORFLASH_ERASE_PAGE, suspend); - if (remain_len > page_size) { - remain_len -= page_size; - } else { - remain_len = 0; - } - current_address += page_size; - } -#else - // erase a sector - ret = norflash_erase(current_address, DRV_NORFLASH_ERASE_SECTOR, suspend); - if (remain_len > sector_size) { - remain_len -= sector_size; - } else { - remain_len = 0; - } - current_address += sector_size; -#endif - } - } - } - - norflash_post_operation(); - -#ifdef FLASH_SUSPEND - if (ret == HAL_NORFLASH_SUSPENDED) { - suspend_state = SUSPEND_STATE_ERASE; - op_next_addr = current_address; - op_remain_len = remain_len; - } else { - suspend_state = SUSPEND_STATE_NONE; - } -#endif - - return ret; -} - -enum HAL_NORFLASH_RET_T hal_norflash_erase_suspend(enum HAL_NORFLASH_ID_T id, uint32_t start_address, uint32_t len, int suspend) -{ - ASSERT(norflash_ctx[id].opened, err_not_opened); - -#ifdef FLASH_SUSPEND - if (suspend_state != SUSPEND_STATE_NONE) { - return HAL_NORFLASH_BAD_OP; - } - if ((norflash_get_supported_mode() & HAL_NORFLASH_OP_MODE_SUSPEND) == 0) { - suspend = 0; - } -#endif - - return hal_norflash_erase_int(id, start_address, len, suspend); -} - -enum HAL_NORFLASH_RET_T hal_norflash_erase(enum HAL_NORFLASH_ID_T id, uint32_t start_address, uint32_t len) -{ - return hal_norflash_erase_suspend(id, start_address, len, 0); -} - -enum HAL_NORFLASH_RET_T hal_norflash_erase_resume(enum HAL_NORFLASH_ID_T id, int suspend) -{ -#ifdef FLASH_SUSPEND - enum HAL_NORFLASH_RET_T ret; - - ASSERT(norflash_ctx[id].opened, err_not_opened); - - if (suspend_state != SUSPEND_STATE_ERASE) { - return HAL_NORFLASH_BAD_OP; - } - if ((norflash_get_supported_mode() & HAL_NORFLASH_OP_MODE_SUSPEND) == 0) { - return HAL_NORFLASH_BAD_OP; - } - - ret = norflash_erase_resume(suspend); - if (ret == HAL_NORFLASH_SUSPENDED) { - return ret; - } - - return hal_norflash_erase_int(id, op_next_addr, op_remain_len, suspend); -#else - return HAL_NORFLASH_OK; -#endif -} - -static enum HAL_NORFLASH_RET_T hal_norflash_write_int(enum HAL_NORFLASH_ID_T id, uint32_t start_address, const uint8_t *buffer, uint32_t len, int suspend) -{ - const uint8_t *current_buffer; - uint32_t remain_len, current_address, total_size, page_size, write_size; - uint32_t pp_remain; - enum HAL_NORFLASH_RET_T ret = HAL_NORFLASH_OK; - - total_size = norflash_ctx[id].total_size; - page_size = norflash_ctx[id].page_size; - - // Check address and length - if (total_size <= (start_address & HAL_NORFLASH_ADDR_MASK)) { - return HAL_NORFLASH_BAD_ADDR; - } - remain_len = total_size - (start_address & HAL_NORFLASH_ADDR_MASK); - if (len > remain_len) { - return HAL_NORFLASH_BAD_LEN; - } - - current_address = start_address; - current_buffer = buffer; - remain_len = len; - - norflash_pre_operation(); - - while (remain_len > 0 && ret == HAL_NORFLASH_OK) { - if (remain_len > page_size) { - write_size = page_size; - } else { - write_size = remain_len; - } - // Align to program page - pp_remain = page_size - (current_address & (page_size - 1)); - if (write_size > pp_remain) { - write_size = pp_remain; - } - - ret = norflash_write(current_address, current_buffer, write_size, suspend); - - current_address += write_size; - current_buffer += write_size; - remain_len -= write_size; - } - - norflash_post_operation(); - -#ifdef FLASH_SUSPEND - if (ret == HAL_NORFLASH_SUSPENDED) { - suspend_state = SUSPEND_STATE_PROGRAM; - op_next_addr = current_address; - op_next_buf = current_buffer; - op_remain_len = remain_len; - } else { - suspend_state = SUSPEND_STATE_NONE; - } -#endif - - return ret; -} - -enum HAL_NORFLASH_RET_T hal_norflash_write_suspend(enum HAL_NORFLASH_ID_T id, uint32_t start_address, const uint8_t *buffer, uint32_t len, int suspend) -{ - ASSERT(norflash_ctx[id].opened, err_not_opened); - -#ifdef FLASH_SUSPEND - if (suspend_state != SUSPEND_STATE_NONE) { - return HAL_NORFLASH_BAD_OP; - } - if ((norflash_get_supported_mode() & HAL_NORFLASH_OP_MODE_SUSPEND) == 0) { - suspend = 0; - } -#endif - - return hal_norflash_write_int(id, start_address, buffer, len, suspend); -} - -enum HAL_NORFLASH_RET_T hal_norflash_write(enum HAL_NORFLASH_ID_T id, uint32_t start_address, const uint8_t *buffer, uint32_t len) -{ - return hal_norflash_write_suspend(id, start_address, buffer, len, 0); -} - -enum HAL_NORFLASH_RET_T hal_norflash_write_resume(enum HAL_NORFLASH_ID_T id, int suspend) -{ -#ifdef FLASH_SUSPEND - enum HAL_NORFLASH_RET_T ret; - - ASSERT(norflash_ctx[id].opened, err_not_opened); - - if (suspend_state != SUSPEND_STATE_PROGRAM) { - return HAL_NORFLASH_BAD_OP; - } - if ((norflash_get_supported_mode() & HAL_NORFLASH_OP_MODE_SUSPEND) == 0) { - return HAL_NORFLASH_BAD_OP; - } - - ret = norflash_write_resume(suspend); - if (ret == HAL_NORFLASH_SUSPENDED) { - return ret; - } - - return hal_norflash_write_int(id, op_next_addr, op_next_buf, op_remain_len, suspend); -#else - return HAL_NORFLASH_OK; -#endif -} - -enum HAL_NORFLASH_RET_T hal_norflash_suspend_check_irq(enum HAL_NORFLASH_ID_T id, uint32_t irq_num) -{ -#ifdef FLASH_SUSPEND - int ret; - - ret = norflash_suspend_check_irq(irq_num); - if (ret) { - return HAL_NORFLASH_ERR; - } -#endif - - return HAL_NORFLASH_OK; -} - -enum HAL_NORFLASH_RET_T hal_norflash_read(enum HAL_NORFLASH_ID_T id, uint32_t start_address, uint8_t *buffer, uint32_t len) -{ - uint8_t *current_buffer; - uint32_t remain_len, current_address, total_size, read_size; - - ASSERT(norflash_ctx[id].opened, err_not_opened); - - total_size = norflash_ctx[id].total_size; - - // Check address and length - if (total_size <= (start_address & HAL_NORFLASH_ADDR_MASK)) { - return HAL_NORFLASH_BAD_ADDR; - } - remain_len = total_size - (start_address & HAL_NORFLASH_ADDR_MASK); - if (len > remain_len) { - return HAL_NORFLASH_BAD_LEN; - } - - read_size = NORFLASHIP_RXFIFO_SIZE; - remain_len = len; - current_address = start_address; - current_buffer = buffer; - - norflash_pre_operation(); - - while (remain_len > 0) { - read_size = (remain_len > NORFLASHIP_RXFIFO_SIZE) ? NORFLASHIP_RXFIFO_SIZE : remain_len; - norflash_read(current_address, current_buffer, read_size); - - current_address += read_size; - current_buffer += read_size; - remain_len -= read_size; - } - - norflash_post_operation(); - - return HAL_NORFLASH_OK; -} - -enum HAL_NORFLASH_RET_T hal_norflash_close(enum HAL_NORFLASH_ID_T id) -{ - return HAL_NORFLASH_OK; -} - -void hal_norflash_sleep(enum HAL_NORFLASH_ID_T id) -{ - if (!norflash_ctx[id].opened) { - return; - } - -#ifdef FLASH_DEEP_SLEEP - norflash_sleep(); -#else - norflash_pre_operation(); -#endif - - norflaship_busy_wait(); - norflaship_sleep(); -} - -void hal_norflash_wakeup(enum HAL_NORFLASH_ID_T id) -{ - if (!norflash_ctx[id].opened) { - return; - } - - norflaship_wakeup(); - -#ifdef FLASH_DEEP_SLEEP - norflash_wakeup(); -#else - norflash_post_operation(); -#endif - -#if 0 - // Flush prefetch buffer - *(volatile uint32_t *)FLASH_NC_BASE; - *(volatile uint32_t *)(FLASH_NC_BASE + 0x1000); -#else - norflaship_clear_rxfifo(); - norflaship_busy_wait(); -#endif -} - -int hal_norflash_busy(void) -{ - return norflaship_is_busy(); -} - -static void hal_norflash_prefetch_idle(void) -{ - hal_sys_timer_delay(4); - if (norflaship_is_busy()) { - hal_sys_timer_delay(4); - } -} - -#ifdef FLASH_FREQ_DYNAMIC_ADJUST -int hal_norflash_freq_dynamic_adjust_save_config(struct HAL_NORFLASH_FREQ_DYNAMIC_ADJUST_CONFIG_T *adjust_cfg) -{ - int ret = -1; - - for (uint8_t i = 0; i= 2) // Set the direction of 4 IO pins to output when in idle norflaship_set_idle_io_dir(0); @@ -1444,166 +762,890 @@ enum HAL_NORFLASH_RET_T hal_norflash_deinit(void) // Reset norflash in slow clock configuration norflash_reset(); - norflash_ctx[HAL_NORFLASH_ID_0].opened = false; + // Get device ID + norflash_get_id(norflash_ctx[id].device_id, + sizeof(norflash_ctx[id].device_id)); - return HAL_NORFLASH_OK; + // For each driver in array, match chip and select drv_ops + found = norflash_match_chip(norflash_ctx[id].device_id, + sizeof(norflash_ctx[id].device_id)); + if (!found) { + result = HAL_NORFLASH_BAD_ID; + goto _exit; + } + +#ifdef FLASH_UNIQUE_ID + // 1) Flash controller V1: + // Use slow clock to avoid rx fifo overflow + // 2) Flash controller V2/3/4/5: + // Use slow clock to avoid stopping SPI clock + // (One bit might be read as a fixed 1 at the SPI clock stopping edge in + // some timing combinations) + // 3) Flash controller V6 or later: + // Can use fast clock + norflash_get_unique_id(norflash_ctx[id].unique_id, + sizeof(norflash_ctx[id].unique_id)); +#endif + } + + // Set norflash source clock + source_freq = hal_norflash_clk_to_cmu_freq(norcfg.source_clk); + hal_cmu_flash_set_freq(source_freq); + + /* over write config */ + if (norcfg.override_config) { + /* div */ + norflaship_div(norcfg.div); + /* cmd quad */ + norflaship_cmdquad(norcfg.cmdquad ? HAL_NORFLASH_YES : HAL_NORFLASH_NO); + /* sample delay */ + norflaship_samdly(norcfg.samdly); +#if 0 + /* dummy clc */ + norflaship_dummyclc(norcfg.dummyclc); + + /* dummy clc en */ + norflaship_dummyclcen(norcfg.dummyclcen); + + /* 4 byte address */ + norflaship_addrbyte4(norcfg.byte4byteaddr); +#endif + /* ru en */ + norflaship_ruen(norcfg.spiruen); + /* rd en */ + norflaship_rden(norcfg.spirden); + /* rd cmd */ + norflaship_rdcmd(norcfg.rdcmd); + /* frd cmd */ + norflaship_frdcmd(norcfg.frdcmd); + /* qrd cmd */ + norflaship_qrdcmd(norcfg.qrdcmd); + } else { + // Init divider + result = norflash_init_div(&norcfg); + if (result != 0) { + result = HAL_NORFLASH_BAD_DIV; + goto _exit; + } + + if (!reopen || calib) { + if (reopen) { + norflash_pre_operation(); + } + // Calib with the new divider + result = norflash_sample_delay_calib(DRV_NORFLASH_CALIB_FLASH_ID); + if (result != 0) { + result = HAL_NORFLASH_BAD_CALIB_ID; + goto _exit; + } + if (reopen) { + norflash_post_operation(); + } + } else { + norflash_set_sample_delay_index(timing_idx); + } + } + + if (!reopen) { + norflash_get_size( + &norflash_ctx[id].total_size, &norflash_ctx[id].block_size, + &norflash_ctx[id].sector_size, &norflash_ctx[id].page_size); + +#ifdef FLASH_SECURITY_REGISTER + result = hal_norflash_parse_security_register_config(); + if (result == HAL_NORFLASH_OK) { + sec_reg_enabled = true; + } else if (result != HAL_NORFLASH_BAD_OP) { + goto _exit; + } +#endif + +#if (CHIP_FLASH_CTRL_VER <= 1) && !defined(FLASH_LOW_SPEED) && \ + !defined(OSC_26M_X4_AUD2BB) + // 1) Flash controller V2 or later + // No requirement on system_freq + // 2) Flash controller V1 + // Requirement on system_freq when running in quad mode (4-line mode): + // Byte Access: flash_line_speed < 2 * system_freq + // Halfword Access: flash_line_speed < 4 * system_freq + // Word Access: flash_line_speed < 8 * system_freq + // The maximum flash_line_speed is 120M in spec, and PLL_FREQ / 2 in our + // system. Normally it is 24.576M * 8 / 2 ~= 100M. So the safe + // system_freq should be larger than 50M/25M/12.5M for byte/halfword/word + // access. Cached access to flash is always safe, because it is always + // word-aligned (system_freq is never below 26M). However, uncached + // access (e.g., access to audio/user/factory data sections) is under + // risk. + hal_sysfreq_set_min_freq(HAL_CMU_FREQ_52M); +#endif + +#if defined(PROGRAMMER) || defined(OTA_PROGRAMMER) + norflash_init_status(0); +#elif defined(FLASH_PROTECTION) + norflash_set_block_protection(hal_norflash_get_bp_cfg(id)); +#endif + } + + op = norcfg.mode; + if (norcfg.speed >= HAL_NORFLASH_SPEED_104M) { + op |= HAL_NORFLASH_OP_MODE_HIGH_PERFORMANCE; + } + + // Divider will be set to normal read mode + result = norflash_set_mode(op); + if (result != 0) { + result = HAL_NORFLASH_BAD_OP; + goto _exit; + } + + // ----------------------------- + // From now on, norflash_pre_operation() must be called before + // sending any command to flash + // ----------------------------- + + if (!reopen) { +#if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) + if (norcfg.dec_enable && (norcfg.dec_size > 0)) { + norflaship_dec_saddr(norcfg.dec_addr); + norflaship_dec_eaddr(norcfg.dec_addr + norcfg.dec_size); + norflaship_dec_index(norcfg.dec_idx); + norflaship_dec_enable(); + } else { + norflaship_dec_disable(); + } +#endif + +#if defined(CHIP_BEST2001) && \ + (defined(PSRAMUHS_ENABLE) || defined(PSRAM_ENABLE)) + norflaship_fetch_disable(); +#endif + } + + if (!norcfg.override_config && (!reopen || calib)) { + result = norflash_sample_delay_calib(DRV_NORFLASH_CALIB_MAGIC_WORD); + if (result != 0) { + result = HAL_NORFLASH_BAD_CALIB_MAGIC; + goto _exit; + } + } + + norflash_ctx[id].opened = true; + + result = HAL_NORFLASH_OK; + +_exit: + if (result != HAL_NORFLASH_OK) { + hal_cmu_flash_set_freq(HAL_CMU_FREQ_26M); + hal_norflash_reset_timing(); + // Flash might be accessed again + } + + norflash_ctx[id].open_state = result; + + return result; } -uint32_t hal_norflash_get_flash_total_size(enum HAL_NORFLASH_ID_T id) -{ - return norflash_ctx[id].total_size; +enum HAL_NORFLASH_RET_T +hal_norflash_open(enum HAL_NORFLASH_ID_T id, + const struct HAL_NORFLASH_CONFIG_T *cfg) { + return _norflash_open(id, cfg, false, true, 0); } -int hal_norflash_opened(enum HAL_NORFLASH_ID_T id) -{ - return norflash_ctx[id].opened; +enum HAL_NORFLASH_RET_T +hal_norflash_reopen(enum HAL_NORFLASH_ID_T id, + const struct HAL_NORFLASH_CONFIG_T *cfg) { + return _norflash_open(id, cfg, true, true, 0); } -enum HAL_NORFLASH_RET_T hal_norflash_get_open_state(enum HAL_NORFLASH_ID_T id) -{ - return norflash_ctx[id].open_state; +enum HAL_NORFLASH_RET_T +hal_norflash_apply_config(enum HAL_NORFLASH_ID_T id, + const struct HAL_NORFLASH_CONFIG_T *cfg, + uint32_t timing_idx) { + return _norflash_open(id, cfg, true, false, timing_idx); } -enum HAL_NORFLASH_RET_T hal_norflash_enable_remap(enum HAL_NORFLASH_ID_T id, uint32_t addr, uint32_t len, uint32_t offset) -{ +uint32_t hal_norflash_get_timing_index(enum HAL_NORFLASH_ID_T id) { + ASSERT(norflash_ctx[id].opened, err_not_opened); + return norflash_get_sample_delay_index(); +} + +void hal_norflash_show_calib_result(void) { norflash_show_calib_result(); } + +enum HAL_NORFLASH_RET_T hal_norflash_erase_chip(enum HAL_NORFLASH_ID_T id) { + uint32_t total_size = 0; + + ASSERT(norflash_ctx[id].opened, err_not_opened); + + total_size = norflash_ctx[id].total_size; + + return hal_norflash_erase(id, 0, total_size); +} + +static enum HAL_NORFLASH_RET_T hal_norflash_erase_int(enum HAL_NORFLASH_ID_T id, + uint32_t start_address, + uint32_t len, + int suspend) { + uint32_t remain_len, current_address, total_size, block_size, sector_size; + enum HAL_NORFLASH_RET_T ret = HAL_NORFLASH_OK; + total_size = norflash_ctx[id].total_size; + block_size = norflash_ctx[id].block_size; + sector_size = norflash_ctx[id].sector_size; + + // Check address and length + if (total_size <= (start_address & HAL_NORFLASH_ADDR_MASK)) { + return HAL_NORFLASH_BAD_ADDR; + } + remain_len = total_size - (start_address & HAL_NORFLASH_ADDR_MASK); + if (len > remain_len) { + return HAL_NORFLASH_BAD_LEN; + } + +#ifdef PUYA_FLASH_ERASE_PAGE_ENABLE + // Align to page boundary + uint32_t page_size; + + page_size = norflash_ctx[id].page_size; + remain_len = start_address & (page_size - 1); + if (remain_len) { + start_address -= remain_len; + len += remain_len; + } + remain_len = len & (page_size - 1); + if (remain_len) { + len += page_size - remain_len; + } +#else + // Align to sector boundary + remain_len = start_address & (sector_size - 1); + if (remain_len) { + start_address -= remain_len; + len += remain_len; + } + remain_len = len & (sector_size - 1); + if (remain_len) { + len += sector_size - remain_len; + } +#endif + current_address = start_address; + remain_len = len; + + norflash_pre_operation(); + + if ((current_address & HAL_NORFLASH_ADDR_MASK) == 0 && + remain_len >= total_size) { + // erase whole chip + ret = norflash_erase(current_address, DRV_NORFLASH_ERASE_CHIP, suspend); + } else { + while (remain_len > 0 && ret == HAL_NORFLASH_OK) { + if (remain_len >= block_size && + ((current_address & (block_size - 1)) == 0)) { + // if large enough to erase a block and current_address is block + // boundary - erase a block + ret = + norflash_erase(current_address, DRV_NORFLASH_ERASE_BLOCK, suspend); + remain_len -= block_size; + current_address += block_size; + } else { +#ifdef PUYA_FLASH_ERASE_PAGE_ENABLE + if (remain_len >= sector_size && + ((current_address & (sector_size - 1)) == 0)) { + // if large enough to erase a sector and current_address is sector + // boundary - erase a sector + ret = norflash_erase(current_address, DRV_NORFLASH_ERASE_SECTOR, + suspend); + remain_len -= sector_size; + current_address += sector_size; + } else { + // erase a page + ret = + norflash_erase(current_address, DRV_NORFLASH_ERASE_PAGE, suspend); + if (remain_len > page_size) { + remain_len -= page_size; + } else { + remain_len = 0; + } + current_address += page_size; + } +#else + // erase a sector + ret = + norflash_erase(current_address, DRV_NORFLASH_ERASE_SECTOR, suspend); + if (remain_len > sector_size) { + remain_len -= sector_size; + } else { + remain_len = 0; + } + current_address += sector_size; +#endif + } + } + } + + norflash_post_operation(); + +#ifdef FLASH_SUSPEND + if (ret == HAL_NORFLASH_SUSPENDED) { + suspend_state = SUSPEND_STATE_ERASE; + op_next_addr = current_address; + op_remain_len = remain_len; + } else { + suspend_state = SUSPEND_STATE_NONE; + } +#endif + + return ret; +} + +enum HAL_NORFLASH_RET_T hal_norflash_erase_suspend(enum HAL_NORFLASH_ID_T id, + uint32_t start_address, + uint32_t len, int suspend) { + ASSERT(norflash_ctx[id].opened, err_not_opened); + +#ifdef FLASH_SUSPEND + if (suspend_state != SUSPEND_STATE_NONE) { + return HAL_NORFLASH_BAD_OP; + } + if ((norflash_get_supported_mode() & HAL_NORFLASH_OP_MODE_SUSPEND) == 0) { + suspend = 0; + } +#endif + + return hal_norflash_erase_int(id, start_address, len, suspend); +} + +enum HAL_NORFLASH_RET_T hal_norflash_erase(enum HAL_NORFLASH_ID_T id, + uint32_t start_address, + uint32_t len) { + return hal_norflash_erase_suspend(id, start_address, len, 0); +} + +enum HAL_NORFLASH_RET_T hal_norflash_erase_resume(enum HAL_NORFLASH_ID_T id, + int suspend) { +#ifdef FLASH_SUSPEND + enum HAL_NORFLASH_RET_T ret; + + ASSERT(norflash_ctx[id].opened, err_not_opened); + + if (suspend_state != SUSPEND_STATE_ERASE) { + return HAL_NORFLASH_BAD_OP; + } + if ((norflash_get_supported_mode() & HAL_NORFLASH_OP_MODE_SUSPEND) == 0) { + return HAL_NORFLASH_BAD_OP; + } + + ret = norflash_erase_resume(suspend); + if (ret == HAL_NORFLASH_SUSPENDED) { + return ret; + } + + return hal_norflash_erase_int(id, op_next_addr, op_remain_len, suspend); +#else + return HAL_NORFLASH_OK; +#endif +} + +static enum HAL_NORFLASH_RET_T +hal_norflash_write_int(enum HAL_NORFLASH_ID_T id, uint32_t start_address, + const uint8_t *buffer, uint32_t len, int suspend) { + const uint8_t *current_buffer; + uint32_t remain_len, current_address, total_size, page_size, write_size; + uint32_t pp_remain; + enum HAL_NORFLASH_RET_T ret = HAL_NORFLASH_OK; + + total_size = norflash_ctx[id].total_size; + page_size = norflash_ctx[id].page_size; + + // Check address and length + if (total_size <= (start_address & HAL_NORFLASH_ADDR_MASK)) { + return HAL_NORFLASH_BAD_ADDR; + } + remain_len = total_size - (start_address & HAL_NORFLASH_ADDR_MASK); + if (len > remain_len) { + return HAL_NORFLASH_BAD_LEN; + } + + current_address = start_address; + current_buffer = buffer; + remain_len = len; + + norflash_pre_operation(); + + while (remain_len > 0 && ret == HAL_NORFLASH_OK) { + if (remain_len > page_size) { + write_size = page_size; + } else { + write_size = remain_len; + } + // Align to program page + pp_remain = page_size - (current_address & (page_size - 1)); + if (write_size > pp_remain) { + write_size = pp_remain; + } + + ret = norflash_write(current_address, current_buffer, write_size, suspend); + + current_address += write_size; + current_buffer += write_size; + remain_len -= write_size; + } + + norflash_post_operation(); + +#ifdef FLASH_SUSPEND + if (ret == HAL_NORFLASH_SUSPENDED) { + suspend_state = SUSPEND_STATE_PROGRAM; + op_next_addr = current_address; + op_next_buf = current_buffer; + op_remain_len = remain_len; + } else { + suspend_state = SUSPEND_STATE_NONE; + } +#endif + + return ret; +} + +enum HAL_NORFLASH_RET_T hal_norflash_write_suspend(enum HAL_NORFLASH_ID_T id, + uint32_t start_address, + const uint8_t *buffer, + uint32_t len, int suspend) { + ASSERT(norflash_ctx[id].opened, err_not_opened); + +#ifdef FLASH_SUSPEND + if (suspend_state != SUSPEND_STATE_NONE) { + return HAL_NORFLASH_BAD_OP; + } + if ((norflash_get_supported_mode() & HAL_NORFLASH_OP_MODE_SUSPEND) == 0) { + suspend = 0; + } +#endif + + return hal_norflash_write_int(id, start_address, buffer, len, suspend); +} + +enum HAL_NORFLASH_RET_T hal_norflash_write(enum HAL_NORFLASH_ID_T id, + uint32_t start_address, + const uint8_t *buffer, + uint32_t len) { + return hal_norflash_write_suspend(id, start_address, buffer, len, 0); +} + +enum HAL_NORFLASH_RET_T hal_norflash_write_resume(enum HAL_NORFLASH_ID_T id, + int suspend) { +#ifdef FLASH_SUSPEND + enum HAL_NORFLASH_RET_T ret; + + ASSERT(norflash_ctx[id].opened, err_not_opened); + + if (suspend_state != SUSPEND_STATE_PROGRAM) { + return HAL_NORFLASH_BAD_OP; + } + if ((norflash_get_supported_mode() & HAL_NORFLASH_OP_MODE_SUSPEND) == 0) { + return HAL_NORFLASH_BAD_OP; + } + + ret = norflash_write_resume(suspend); + if (ret == HAL_NORFLASH_SUSPENDED) { + return ret; + } + + return hal_norflash_write_int(id, op_next_addr, op_next_buf, op_remain_len, + suspend); +#else + return HAL_NORFLASH_OK; +#endif +} + +enum HAL_NORFLASH_RET_T +hal_norflash_suspend_check_irq(enum HAL_NORFLASH_ID_T id, uint32_t irq_num) { +#ifdef FLASH_SUSPEND + int ret; + + ret = norflash_suspend_check_irq(irq_num); + if (ret) { + return HAL_NORFLASH_ERR; + } +#endif + + return HAL_NORFLASH_OK; +} + +enum HAL_NORFLASH_RET_T hal_norflash_read(enum HAL_NORFLASH_ID_T id, + uint32_t start_address, + uint8_t *buffer, uint32_t len) { + uint8_t *current_buffer; + uint32_t remain_len, current_address, total_size, read_size; + + ASSERT(norflash_ctx[id].opened, err_not_opened); + + total_size = norflash_ctx[id].total_size; + + // Check address and length + if (total_size <= (start_address & HAL_NORFLASH_ADDR_MASK)) { + return HAL_NORFLASH_BAD_ADDR; + } + remain_len = total_size - (start_address & HAL_NORFLASH_ADDR_MASK); + if (len > remain_len) { + return HAL_NORFLASH_BAD_LEN; + } + + read_size = NORFLASHIP_RXFIFO_SIZE; + remain_len = len; + current_address = start_address; + current_buffer = buffer; + + norflash_pre_operation(); + + while (remain_len > 0) { + read_size = (remain_len > NORFLASHIP_RXFIFO_SIZE) ? NORFLASHIP_RXFIFO_SIZE + : remain_len; + norflash_read(current_address, current_buffer, read_size); + + current_address += read_size; + current_buffer += read_size; + remain_len -= read_size; + } + + norflash_post_operation(); + + return HAL_NORFLASH_OK; +} + +enum HAL_NORFLASH_RET_T hal_norflash_close(enum HAL_NORFLASH_ID_T id) { + return HAL_NORFLASH_OK; +} + +void hal_norflash_sleep(enum HAL_NORFLASH_ID_T id) { + if (!norflash_ctx[id].opened) { + return; + } + +#ifdef FLASH_DEEP_SLEEP + norflash_sleep(); +#else + norflash_pre_operation(); +#endif + + norflaship_busy_wait(); + norflaship_sleep(); +} + +void hal_norflash_wakeup(enum HAL_NORFLASH_ID_T id) { + if (!norflash_ctx[id].opened) { + return; + } + + norflaship_wakeup(); + +#ifdef FLASH_DEEP_SLEEP + norflash_wakeup(); +#else + norflash_post_operation(); +#endif + +#if 0 + // Flush prefetch buffer + *(volatile uint32_t *)FLASH_NC_BASE; + *(volatile uint32_t *)(FLASH_NC_BASE + 0x1000); +#else + norflaship_clear_rxfifo(); + norflaship_busy_wait(); +#endif +} + +int hal_norflash_busy(void) { return norflaship_is_busy(); } + +static void hal_norflash_prefetch_idle(void) { + hal_sys_timer_delay(4); + if (norflaship_is_busy()) { + hal_sys_timer_delay(4); + } +} + +#ifdef FLASH_FREQ_DYNAMIC_ADJUST +int hal_norflash_freq_dynamic_adjust_save_config( + struct HAL_NORFLASH_FREQ_DYNAMIC_ADJUST_CONFIG_T *adjust_cfg) { + int ret = -1; + + for (uint8_t i = 0; i < ARRAY_SIZE(norflash_freq_dynamic_adjust_cfg); i++) { + if (!norflash_freq_dynamic_adjust_cfg[i].source_clk) { + norflash_freq_dynamic_adjust_cfg[i] = *adjust_cfg; + ret = 0; + break; + } + } + + return ret; +} + +int hal_norflash_freq_dynamic_adjust_set_freq(enum HAL_CMU_FREQ_T freq) { + int ret = -1; + + for (uint8_t i = 0; i < ARRAY_SIZE(norflash_freq_dynamic_adjust_cfg); i++) { + if (hal_norflash_clk_to_cmu_freq( + norflash_freq_dynamic_adjust_cfg[i].source_clk) == freq) { + struct HAL_NORFLASH_CONFIG_T norflash_cfg = + *(struct HAL_NORFLASH_CONFIG_T *)hal_norflash_get_init_config(); + norflash_cfg.source_clk = norflash_freq_dynamic_adjust_cfg[i].source_clk; + hal_norflash_apply_config( + HAL_NORFLASH_ID_0, &norflash_cfg, + norflash_freq_dynamic_adjust_cfg[i].timing_index); + ret = 0; + break; + } + } + + return ret; +} +#endif + +void hal_norflash_set_freq(enum HAL_CMU_FREQ_T freq) { + if (!hal_norflash_opened(HAL_NORFLASH_ID_0)) { + // At least best1000 and best2001 require the timing reset +#if 1 + // Make sure flash is still working after freq change + + // Wait until norflash becomes idle + hal_norflash_prefetch_idle(); + + // Reset flash timing + hal_norflash_reset_timing(); +#endif + + hal_cmu_flash_set_freq(freq); + } +#ifdef FLASH_FREQ_DYNAMIC_ADJUST + else { + if (hal_cmu_flash_get_freq() != freq) { + hal_norflash_freq_dynamic_adjust_set_freq(freq); + } + } +#endif +} + +const struct HAL_NORFLASH_CONFIG_T *hal_norflash_get_init_config(void) { + return &norflash_cfg; +} + +enum HAL_NORFLASH_RET_T hal_norflash_init(void) { + enum HAL_NORFLASH_RET_T ret; + struct HAL_NORFLASH_CONFIG_T norflash_cfg = + *(struct HAL_NORFLASH_CONFIG_T *)hal_norflash_get_init_config(); + + // Pmu codes might be located in flash + pmu_flash_freq_config(norflash_cfg.speed); + + // Avoid flash access from here + hal_norflash_prefetch_idle(); + + ret = hal_norflash_open(HAL_NORFLASH_ID_0, &norflash_cfg); + if (ret != HAL_NORFLASH_OK) { + goto _exit; + } +#ifdef FLASH_FREQ_DYNAMIC_ADJUST + struct HAL_NORFLASH_FREQ_DYNAMIC_ADJUST_CONFIG_T dynamic_adjust_cfg; + uint32_t source_clk_save; + source_clk_save = norflash_cfg.source_clk; + dynamic_adjust_cfg.source_clk = norflash_cfg.source_clk; + dynamic_adjust_cfg.timing_index = + hal_norflash_get_timing_index(HAL_NORFLASH_ID_0); + hal_norflash_freq_dynamic_adjust_save_config(&dynamic_adjust_cfg); + norflash_cfg.source_clk = HAL_NORFLASH_SPEED_26M; + norflash_cfg.speed = HAL_NORFLASH_SPEED_26M; + ret = hal_norflash_reopen(HAL_NORFLASH_ID_0, &norflash_cfg); + if (ret != HAL_NORFLASH_OK) { + goto _exit; + } + dynamic_adjust_cfg.source_clk = norflash_cfg.source_clk; + dynamic_adjust_cfg.timing_index = + hal_norflash_get_timing_index(HAL_NORFLASH_ID_0); + hal_norflash_freq_dynamic_adjust_save_config(&dynamic_adjust_cfg); + hal_norflash_set_freq(hal_norflash_clk_to_cmu_freq(source_clk_save)); +#endif +_exit: + return ret; +} + +enum HAL_NORFLASH_RET_T hal_norflash_deinit(void) { + // Avoid flash access from here + hal_norflash_prefetch_idle(); + #if (CHIP_FLASH_CTRL_VER >= 2) - uint32_t flash_size; - uint32_t remap_from; - int ret; + // Set the direction of 4 IO pins to output when in idle + norflaship_set_idle_io_dir(0); +#endif +#if (CHIP_FLASH_CTRL_VER >= 3) + // Set the dummy cycles for security register read command + norflaship_dummy_others(8); +#endif - STATIC_ASSERT((FLASH_BASE & HAL_NORFLASH_ADDR_MASK) == 0, "Bad FLASH_BASE"); - STATIC_ASSERT((FLASH_SIZE & (FLASH_SIZE - 1)) == 0, "Bad FLASH_SIZE"); + // Reset norflash source clock + hal_cmu_flash_set_freq(HAL_CMU_FREQ_26M); + + // Reset controller timing + hal_norflash_reset_timing(); + + // Reset norflash in slow clock configuration + norflash_reset(); + + norflash_ctx[HAL_NORFLASH_ID_0].opened = false; + + return HAL_NORFLASH_OK; +} + +uint32_t hal_norflash_get_flash_total_size(enum HAL_NORFLASH_ID_T id) { + return norflash_ctx[id].total_size; +} + +int hal_norflash_opened(enum HAL_NORFLASH_ID_T id) { + return norflash_ctx[id].opened; +} + +enum HAL_NORFLASH_RET_T hal_norflash_get_open_state(enum HAL_NORFLASH_ID_T id) { + return norflash_ctx[id].open_state; +} + +enum HAL_NORFLASH_RET_T hal_norflash_enable_remap(enum HAL_NORFLASH_ID_T id, + uint32_t addr, uint32_t len, + uint32_t offset) { +#if (CHIP_FLASH_CTRL_VER >= 2) + uint32_t flash_size; + uint32_t remap_from; + int ret; + + STATIC_ASSERT((FLASH_BASE & HAL_NORFLASH_ADDR_MASK) == 0, "Bad FLASH_BASE"); + STATIC_ASSERT((FLASH_SIZE & (FLASH_SIZE - 1)) == 0, "Bad FLASH_SIZE"); #ifdef OTA_BARE_BOOT - flash_size = FLASH_SIZE; + flash_size = FLASH_SIZE; #else - if (!norflash_ctx[id].opened) { - return HAL_NORFLASH_NOT_OPENED; - } + if (!norflash_ctx[id].opened) { + return HAL_NORFLASH_NOT_OPENED; + } - flash_size = norflash_ctx[id].total_size; + flash_size = norflash_ctx[id].total_size; #ifndef PROGRAMMER - if (flash_size > FLASH_SIZE) { - flash_size = FLASH_SIZE; - } + if (flash_size > FLASH_SIZE) { + flash_size = FLASH_SIZE; + } #endif #endif - remap_from = addr & HAL_NORFLASH_ADDR_MASK; + remap_from = addr & HAL_NORFLASH_ADDR_MASK; #ifdef CHIP_BEST2300P - uint32_t remap_to, remap_len, remap_end, region_len; - uint8_t remap_id; - uint8_t msb_pos; + uint32_t remap_to, remap_len, remap_end, region_len; + uint8_t remap_id; + uint8_t msb_pos; - if (offset & (offset - 1)) { - return HAL_NORFLASH_BAD_ADDR; - } - if (offset > flash_size / 2) { - return HAL_NORFLASH_BAD_ADDR; - } - flash_size = offset * 2; + if (offset & (offset - 1)) { + return HAL_NORFLASH_BAD_ADDR; + } + if (offset > flash_size / 2) { + return HAL_NORFLASH_BAD_ADDR; + } + flash_size = offset * 2; - if (remap_from < flash_size / (1 << (NORFLASHIP_REMAP_NUM + 1))) { - return HAL_NORFLASH_BAD_ADDR; - } - if (remap_from % (flash_size / (1 << (NORFLASHIP_REMAP_NUM + 1)))) { - return HAL_NORFLASH_BAD_ADDR; - } + if (remap_from < flash_size / (1 << (NORFLASHIP_REMAP_NUM + 1))) { + return HAL_NORFLASH_BAD_ADDR; + } + if (remap_from % (flash_size / (1 << (NORFLASHIP_REMAP_NUM + 1)))) { + return HAL_NORFLASH_BAD_ADDR; + } - if (remap_from + len > flash_size / 2) { - return HAL_NORFLASH_BAD_LEN; - } + if (remap_from + len > flash_size / 2) { + return HAL_NORFLASH_BAD_LEN; + } - norflaship_busy_wait(); + norflaship_busy_wait(); - remap_id = 0; - remap_end = flash_size / 2; - remap_len = remap_end - remap_from; - while (remap_len && remap_id < NORFLASHIP_REMAP_NUM) { - msb_pos = 31 - __CLZ(remap_len); - region_len = 1 << msb_pos; - remap_from = remap_end - region_len; - remap_to = flash_size - remap_end; // OR: (flash_size / 2 + (flash_size / 2 - remap_end)) - ret = norflaship_config_remap_section(remap_id, remap_from, region_len, remap_to); - if (ret) { - return HAL_NORFLASH_BAD_OP; - } - remap_len -= region_len; - remap_end -= region_len; - remap_id++; - } - - if (remap_len) { - return HAL_NORFLASH_BAD_LEN; - } -#else - // Align len to sector size - len = (len + (REMAP_SECTOR_SIZE - 1)) & ~(REMAP_SECTOR_SIZE - 1); - if (len > offset) { - return HAL_NORFLASH_BAD_LEN; - } - if (remap_from + len > offset) { - return HAL_NORFLASH_BAD_LEN; - } - if (remap_from + len + offset > flash_size) { - return HAL_NORFLASH_BAD_ADDR; - } - - norflaship_busy_wait(); - - ret = norflaship_config_remap_section(0, remap_from, len, remap_from + offset); + remap_id = 0; + remap_end = flash_size / 2; + remap_len = remap_end - remap_from; + while (remap_len && remap_id < NORFLASHIP_REMAP_NUM) { + msb_pos = 31 - __CLZ(remap_len); + region_len = 1 << msb_pos; + remap_from = remap_end - region_len; + remap_to = flash_size - + remap_end; // OR: (flash_size / 2 + (flash_size / 2 - remap_end)) + ret = norflaship_config_remap_section(remap_id, remap_from, region_len, + remap_to); if (ret) { - return HAL_NORFLASH_BAD_OP; + return HAL_NORFLASH_BAD_OP; } + remap_len -= region_len; + remap_end -= region_len; + remap_id++; + } + + if (remap_len) { + return HAL_NORFLASH_BAD_LEN; + } +#else + // Align len to sector size + len = (len + (REMAP_SECTOR_SIZE - 1)) & ~(REMAP_SECTOR_SIZE - 1); + if (len > offset) { + return HAL_NORFLASH_BAD_LEN; + } + if (remap_from + len > offset) { + return HAL_NORFLASH_BAD_LEN; + } + if (remap_from + len + offset > flash_size) { + return HAL_NORFLASH_BAD_ADDR; + } + + norflaship_busy_wait(); + + ret = + norflaship_config_remap_section(0, remap_from, len, remap_from + offset); + if (ret) { + return HAL_NORFLASH_BAD_OP; + } #endif - hal_norflash_re_enable_remap(id); + hal_norflash_re_enable_remap(id); - return HAL_NORFLASH_OK; + return HAL_NORFLASH_OK; #else - return HAL_NORFLASH_ERR; + return HAL_NORFLASH_ERR; #endif } -enum HAL_NORFLASH_RET_T hal_norflash_disable_remap(enum HAL_NORFLASH_ID_T id) -{ +enum HAL_NORFLASH_RET_T hal_norflash_disable_remap(enum HAL_NORFLASH_ID_T id) { #if (CHIP_FLASH_CTRL_VER >= 2) - norflaship_busy_wait(); + norflaship_busy_wait(); - norflaship_disable_remap(); + norflaship_disable_remap(); - norflaship_busy_wait(); - norflaship_clear_fifos(); + norflaship_busy_wait(); + norflaship_clear_fifos(); - return HAL_NORFLASH_OK; + return HAL_NORFLASH_OK; #else - return HAL_NORFLASH_ERR; + return HAL_NORFLASH_ERR; #endif } -enum HAL_NORFLASH_RET_T hal_norflash_re_enable_remap(enum HAL_NORFLASH_ID_T id) -{ +enum HAL_NORFLASH_RET_T +hal_norflash_re_enable_remap(enum HAL_NORFLASH_ID_T id) { #if (CHIP_FLASH_CTRL_VER >= 2) - norflaship_busy_wait(); + norflaship_busy_wait(); - norflaship_enable_remap(); + norflaship_enable_remap(); - norflaship_busy_wait(); - norflaship_clear_fifos(); + norflaship_busy_wait(); + norflaship_clear_fifos(); - return HAL_NORFLASH_OK; + return HAL_NORFLASH_OK; #else - return HAL_NORFLASH_ERR; + return HAL_NORFLASH_ERR; #endif } -int hal_norflash_get_remap_status(enum HAL_NORFLASH_ID_T id) -{ +int hal_norflash_get_remap_status(enum HAL_NORFLASH_ID_T id) { #if (CHIP_FLASH_CTRL_VER >= 2) - return norflaship_get_remap_status(); + return norflaship_get_remap_status(); #else - return HAL_NORFLASH_ERR; + return HAL_NORFLASH_ERR; #endif } - diff --git a/platform/hal/hal_norflaship_v1.c b/platform/hal/hal_norflaship_v1.c index d88054c..e1bc75f 100644 --- a/platform/hal/hal_norflaship_v1.c +++ b/platform/hal/hal_norflaship_v1.c @@ -15,14 +15,14 @@ ****************************************************************************/ #if (CHIP_FLASH_CTRL_VER <= 1) -#include "plat_types.h" -#include "plat_addr_map.h" -#include "reg_norflaship_v1.h" #include "hal_norflaship.h" +#include "plat_addr_map.h" +#include "plat_types.h" +#include "reg_norflaship_v1.h" #ifdef PROGRAMMER #include "task_schedule.h" #else -#define TASK_SCHEDULE true +#define TASK_SCHEDULE true #endif //==================================================================================== @@ -74,358 +74,311 @@ /* register memory address */ #define NORFLASHIP_BASEADDR FLASH_CTRL_BASE -#define norflaship_readb(a) \ - (*(volatile unsigned char*)(NORFLASHIP_BASEADDR+a)) +#define norflaship_readb(a) \ + (*(volatile unsigned char *)(NORFLASHIP_BASEADDR + a)) -#define norflaship_read32(a) \ - (*(volatile unsigned int *)(NORFLASHIP_BASEADDR+a)) +#define norflaship_read32(a) \ + (*(volatile unsigned int *)(NORFLASHIP_BASEADDR + a)) -#define norflaship_write32(v,a) \ - ((*(volatile unsigned int *)(NORFLASHIP_BASEADDR+a)) = v) +#define norflaship_write32(v, a) \ + ((*(volatile unsigned int *)(NORFLASHIP_BASEADDR + a)) = v) /* ip ops */ -uint8_t norflaship_continuous_read_mode_bit(uint8_t mode_bit) -{ - uint32_t val = 0; - norflaship_busy_wait(); - val = norflaship_read32(TX_CONFIG2_BASE); - val &= ~(TX_MODBIT_MASK); - val |= (mode_bit< 0) { - st = norflaship_read32(INT_STATUS_BASE); - if (st & TXFIFOFULL_MASK) { - continue; - } - norflaship_write32(*val, TXDATA_BASE); - val++; - len--; - } - return 0; -} -uint8_t norflaship_read_rxfifo_count(void) -{ - uint32_t val = 0; - val = norflaship_readb(INT_STATUS_BASE); - return ((val&RXFIFOCOUNT_MASK)>>RXFIFOCOUNT_SHIFT); -} -uint8_t norflaship_read_rxfifo(void) -{ - uint32_t val = 0; - val = norflaship_readb(RXDATA_BASE); - return val&0xff; -} -void norflaship_blksize(uint32_t blksize) -{ - uint32_t val = 0; - val = norflaship_read32(TX_CONFIG2_BASE); - val = ((~(TX_BLKSIZE_MASK))&val) | (blksize<>RXFIFOCOUNT_SHIFT) < cnt) && TASK_SCHEDULE); -} -void norflaship_rxfifo_empty_wait(void) -{ - uint32_t st = 0; - do { - st = norflaship_read32(INT_STATUS_BASE); - } while ((st&RXFIFOEMPTY_MASK) && TASK_SCHEDULE); -} -void norflaship_busy_wait(void) -{ - uint32_t st = 0; - do { - st = norflaship_read32(INT_STATUS_BASE); - } while ((st&BUSY_MASK) && TASK_SCHEDULE); -} -int norflaship_is_busy(void) -{ - uint32_t st = 0; +uint32_t norflaship_v1_write_txfifo_safe(const uint8_t *val, uint32_t len) { + uint32_t i; + uint32_t st; + for (i = 0; i < len; ++i) { st = norflaship_read32(INT_STATUS_BASE); - return !!(st&BUSY_MASK); + if (st & TXFIFOFULL_MASK) { + break; + } + norflaship_write32(val[i], TXDATA_BASE); + } + return len - i; } -void norflaship_clear_fifos(void) -{ - norflaship_busy_wait(); - norflaship_write32(RXFIFOCLR_MASK|TXFIFOCLR_MASK, FIFO_CONFIG_BASE); - norflaship_busy_wait(); +uint32_t norflaship_v1_write_txfifo_all(const uint8_t *val, uint32_t len) { + uint32_t st; + while (len > 0) { + st = norflaship_read32(INT_STATUS_BASE); + if (st & TXFIFOFULL_MASK) { + continue; + } + norflaship_write32(*val, TXDATA_BASE); + val++; + len--; + } + return 0; } -void norflaship_clear_rxfifo(void) -{ - norflaship_busy_wait(); - norflaship_write32(RXFIFOCLR_MASK, FIFO_CONFIG_BASE); - norflaship_busy_wait(); +uint8_t norflaship_read_rxfifo_count(void) { + uint32_t val = 0; + val = norflaship_readb(INT_STATUS_BASE); + return ((val & RXFIFOCOUNT_MASK) >> RXFIFOCOUNT_SHIFT); } -void norflaship_clear_txfifo(void) -{ - norflaship_busy_wait(); - norflaship_write32(TXFIFOCLR_MASK, FIFO_CONFIG_BASE); - norflaship_busy_wait(); +uint8_t norflaship_read_rxfifo(void) { + uint32_t val = 0; + val = norflaship_readb(RXDATA_BASE); + return val & 0xff; } -void norflaship_div(uint32_t div) -{ - uint32_t val = 0; - norflaship_busy_wait(); - val = norflaship_read32(MODE1_CONFIG_BASE); - val = (~(CLKDIV_MASK) & val) | (div<> CLKDIV_SHIFT; +void norflaship_cmd_addr(uint8_t cmd, uint32_t address) { + norflaship_busy_wait(); + norflaship_write32(address << TX_ADDR_SHIFT | (cmd << TX_CMD_SHIFT), + TX_CONFIG1_BASE); } -void norflaship_cmdquad(uint32_t v) -{ - uint32_t val = 0; - norflaship_busy_wait(); - val = norflaship_read32(MODE1_CONFIG_BASE); - if (v) - val |= CMDQUAD_MASK; - else - val &= ~CMDQUAD_MASK; - norflaship_write32(val, MODE1_CONFIG_BASE); +void norflaship_ext_tx_cmd(uint8_t cmd, uint32_t tx_len) { + norflaship_busy_wait(); + norflaship_write32(cmd << EXT_CMD_SHIFT, TX_CONFIG1_BASE); } -uint32_t norflaship_get_pos_neg(void) -{ - uint32_t val = 0; - val = norflaship_read32(MODE1_CONFIG_BASE); - return !!(val & POS_NEG_MASK); +void norflaship_ext_rx_cmd(uint8_t cmd, uint32_t tx_len, uint32_t rx_len) { + norflaship_busy_wait(); + norflaship_blksize(rx_len); + norflaship_write32(EXT_CMD_RX_MASK | (cmd << EXT_CMD_SHIFT), TX_CONFIG1_BASE); } -void norflaship_pos_neg(uint32_t v) -{ - uint32_t val = 0; - norflaship_busy_wait(); - val = norflaship_read32(MODE1_CONFIG_BASE); - if (v) - val |= POS_NEG_MASK; - else - val &= ~POS_NEG_MASK; - norflaship_write32(val, MODE1_CONFIG_BASE); +void norflaship_cmd_done(void) { norflaship_busy_wait(); } +void norflaship_rxfifo_count_wait(uint8_t cnt) { + uint32_t st = 0; + do { + st = norflaship_read32(INT_STATUS_BASE); + } while ((((st & RXFIFOCOUNT_MASK) >> RXFIFOCOUNT_SHIFT) < cnt) && + TASK_SCHEDULE); } -uint32_t norflaship_get_neg_phase(void) -{ - uint32_t val = 0; - val = norflaship_read32(MODE1_CONFIG_BASE); - return !!(val & NEG_PHASE_MASK); +void norflaship_rxfifo_empty_wait(void) { + uint32_t st = 0; + do { + st = norflaship_read32(INT_STATUS_BASE); + } while ((st & RXFIFOEMPTY_MASK) && TASK_SCHEDULE); } -void norflaship_neg_phase(uint32_t v) -{ - uint32_t val = 0; - norflaship_busy_wait(); - val = norflaship_read32(MODE1_CONFIG_BASE); - if (v) - val |= NEG_PHASE_MASK; - else - val &= ~NEG_PHASE_MASK; - norflaship_write32(val, MODE1_CONFIG_BASE); +void norflaship_busy_wait(void) { + uint32_t st = 0; + do { + st = norflaship_read32(INT_STATUS_BASE); + } while ((st & BUSY_MASK) && TASK_SCHEDULE); } -uint32_t norflaship_get_samdly(void) -{ - uint32_t val = 0; - val = norflaship_read32(MODE1_CONFIG_BASE); - return (val & SAMDLY_MASK) >> SAMDLY_SHIFT; +int norflaship_is_busy(void) { + uint32_t st = 0; + st = norflaship_read32(INT_STATUS_BASE); + return !!(st & BUSY_MASK); } -void norflaship_samdly(uint32_t v) -{ - uint32_t val = 0; - norflaship_busy_wait(); - val = norflaship_read32(MODE1_CONFIG_BASE); - val = (~(SAMDLY_MASK) & val) | (v<> CLKDIV_SHIFT; } -void norflaship_dummyclc(uint32_t v) -{ - uint32_t val = 0; - val = norflaship_read32(MODE1_CONFIG_BASE); - val = (~(DUMMYCLC_MASK) & val) | (v<> SAMDLY_SHIFT; } -void norflaship_rdcmd(uint32_t v) -{ - uint32_t val = 0; - val = norflaship_read32(MODE2_CONFIG_BASE); - val = (~(RDCMD_MASK) & val) | (v<> RDCMD_SHIFT); +void norflaship_wpr_pin(uint32_t v) { + uint32_t val = 0; + val = norflaship_read32(MODE1_CONFIG_BASE); + if (v) + val |= WPRPIN_MASK; + else + val &= ~WPRPIN_MASK; + norflaship_write32(val, MODE1_CONFIG_BASE); } -void norflaship_sleep(void) -{ +void norflaship_quad_mode(uint32_t v) { + uint32_t val = 0; + norflaship_busy_wait(); + val = norflaship_read32(MODE1_CONFIG_BASE); + if (v) + val |= QUADMODE_MASK; + else + val &= ~QUADMODE_MASK; + norflaship_write32(val, MODE1_CONFIG_BASE); } -void norflaship_wakeup(void) -{ +void norflaship_dummyclc(uint32_t v) { + uint32_t val = 0; + val = norflaship_read32(MODE1_CONFIG_BASE); + val = (~(DUMMYCLC_MASK)&val) | (v << DUMMYCLC_SHIFT); + norflaship_write32(val, MODE1_CONFIG_BASE); } +void norflaship_dummyclcen(uint32_t v) { + uint32_t val = 0; + val = norflaship_read32(MODE1_CONFIG_BASE); + if (v) + val |= DUMMYCLCEN_MASK; + else + val &= ~DUMMYCLCEN_MASK; + norflaship_write32(val, MODE1_CONFIG_BASE); +} +void norflaship_addrbyte4(uint32_t v) { + uint32_t val = 0; + val = norflaship_read32(MODE1_CONFIG_BASE); + if (v) + val |= ADDRBYTE4_MASK; + else + val &= ~ADDRBYTE4_MASK; + norflaship_write32(val, MODE1_CONFIG_BASE); +} +void norflaship_ruen(uint32_t v) { + uint32_t val = 0; + val = norflaship_read32(PULL_UP_DOWN_CONFIG_BASE); + val = (~(SPIRUEN_MASK)&val) | (v << SPIRUEN_SHIFT); + norflaship_write32(val, PULL_UP_DOWN_CONFIG_BASE); +} +void norflaship_rden(uint32_t v) { + uint32_t val = 0; + val = norflaship_read32(PULL_UP_DOWN_CONFIG_BASE); + val = (~(SPIRDEN_MASK)&val) | (v << SPIRDEN_SHIFT); + norflaship_write32(val, PULL_UP_DOWN_CONFIG_BASE); +} +void norflaship_dualiocmd(uint32_t v) { + uint32_t val = 0; + val = norflaship_read32(MODE2_CONFIG_BASE); + val = (~(DUALIOCMD_MASK)&val) | (v << DUALIOCMD_SHIFT); + norflaship_write32(val, MODE2_CONFIG_BASE); +} +void norflaship_rdcmd(uint32_t v) { + uint32_t val = 0; + val = norflaship_read32(MODE2_CONFIG_BASE); + val = (~(RDCMD_MASK)&val) | (v << RDCMD_SHIFT); + norflaship_write32(val, MODE2_CONFIG_BASE); +} +void norflaship_frdcmd(uint32_t v) { + uint32_t val = 0; + val = norflaship_read32(MODE2_CONFIG_BASE); + val = (~(FRDCMD_MASK)&val) | (v << FRDCMD_SHIFT); + norflaship_write32(val, MODE2_CONFIG_BASE); +} +void norflaship_qrdcmd(uint32_t v) { + uint32_t val = 0; + val = norflaship_read32(MODE2_CONFIG_BASE); + val = (~(QRDCMDBIT_MASK)&val) | (v << QRDCMDBIT_SHIFT); + norflaship_write32(val, MODE2_CONFIG_BASE); +} +uint32_t norflaship_get_rdcmd(void) { + uint32_t val; + val = norflaship_read32(MODE2_CONFIG_BASE); + return ((RDCMD_MASK & val) >> RDCMD_SHIFT); +} +void norflaship_sleep(void) {} +void norflaship_wakeup(void) {} #endif diff --git a/platform/hal/hal_norflaship_v2.c b/platform/hal/hal_norflaship_v2.c index 9b5e2c8..5bdf58d 100644 --- a/platform/hal/hal_norflaship_v2.c +++ b/platform/hal/hal_norflaship_v2.c @@ -15,15 +15,15 @@ ****************************************************************************/ #if (CHIP_FLASH_CTRL_VER >= 2) -#include "plat_types.h" -#include "plat_addr_map.h" #include "cmsis.h" -#include "reg_norflaship_v2.h" #include "hal_norflaship.h" +#include "plat_addr_map.h" +#include "plat_types.h" +#include "reg_norflaship_v2.h" #ifdef PROGRAMMER #include "task_schedule.h" #else -#define TASK_SCHEDULE true +#define TASK_SCHEDULE true #endif //==================================================================================== @@ -74,7 +74,8 @@ parameter FPP = 8'hF2 ; */ -static struct NORFLASH_CTRL_T * const norflash = (struct NORFLASH_CTRL_T *)FLASH_CTRL_BASE; +static struct NORFLASH_CTRL_T *const norflash = + (struct NORFLASH_CTRL_T *)FLASH_CTRL_BASE; #if 0 static const uint8_t line_mode[8] = { @@ -83,32 +84,28 @@ static const uint8_t line_mode[8] = { }; #endif -uint8_t norflaship_continuous_read_mode_bit(uint8_t mode_bit) -{ - norflaship_busy_wait(); - norflash->REG_004 = SET_BITFIELD(norflash->REG_004, REG_004_MODEBIT, mode_bit); - return 0; +uint8_t norflaship_continuous_read_mode_bit(uint8_t mode_bit) { + norflaship_busy_wait(); + norflash->REG_004 = + SET_BITFIELD(norflash->REG_004, REG_004_MODEBIT, mode_bit); + return 0; } -uint8_t norflaship_continuous_read_off(void) -{ - norflaship_busy_wait(); - norflash->REG_004 &= ~REG_004_CONTINUOUS_MODE; - return 0; +uint8_t norflaship_continuous_read_off(void) { + norflaship_busy_wait(); + norflash->REG_004 &= ~REG_004_CONTINUOUS_MODE; + return 0; } -uint8_t norflaship_continuous_read_on(void) -{ - norflaship_busy_wait(); - norflash->REG_004 |= REG_004_CONTINUOUS_MODE; - return 0; +uint8_t norflaship_continuous_read_on(void) { + norflaship_busy_wait(); + norflash->REG_004 |= REG_004_CONTINUOUS_MODE; + return 0; } -uint8_t norflaship_read_txfifo_empty_count(void) -{ - return GET_BITFIELD(norflash->REG_00C, REG_00C_TXFIFO_EMPCNT); +uint8_t norflaship_read_txfifo_empty_count(void) { + return GET_BITFIELD(norflash->REG_00C, REG_00C_TXFIFO_EMPCNT); } -uint32_t norflaship_write_txfifo(const uint8_t *val, uint32_t len) -{ - uint32_t avail = norflaship_read_txfifo_empty_count(); - while (len > 0 && avail > 0) { +uint32_t norflaship_write_txfifo(const uint8_t *val, uint32_t len) { + uint32_t avail = norflaship_read_txfifo_empty_count(); + while (len > 0 && avail > 0) { #if 0 if (len >= 4 && ((uint32_t)val & 3) == 0) { norflash->REG_008.TXWORD = *(uint32_t *)val; @@ -120,444 +117,403 @@ uint32_t norflaship_write_txfifo(const uint8_t *val, uint32_t len) len -= 2; } else #endif - { - norflash->REG_008.TXBYTE = *(uint8_t *)val; - val += 1; - len -= 1; - } - avail -= 1; + { + norflash->REG_008.TXBYTE = *(uint8_t *)val; + val += 1; + len -= 1; } - return len; + avail -= 1; + } + return len; } -uint8_t norflaship_read_rxfifo_count(void) -{ - return GET_BITFIELD(norflash->REG_00C, REG_00C_RXFIFO_COUNT); +uint8_t norflaship_read_rxfifo_count(void) { + return GET_BITFIELD(norflash->REG_00C, REG_00C_RXFIFO_COUNT); } -uint8_t norflaship_read_rxfifo(void) -{ - return norflash->REG_010; +uint8_t norflaship_read_rxfifo(void) { return norflash->REG_010; } +void norflaship_blksize(uint32_t blksize) { + norflash->REG_004 = + SET_BITFIELD(norflash->REG_004, REG_004_BLOCK_SIZE, blksize); } -void norflaship_blksize(uint32_t blksize) -{ - norflash->REG_004 = SET_BITFIELD(norflash->REG_004, REG_004_BLOCK_SIZE, blksize); +void norflaship_cmd_addr(uint8_t cmd, uint32_t address) { + norflaship_busy_wait(); + norflash->REG_004 &= ~REG_004_NEW_CMD_EN; + norflash->REG_000 = REG_000_CMD(cmd) | REG_000_ADDR(address); } -void norflaship_cmd_addr(uint8_t cmd, uint32_t address) -{ - norflaship_busy_wait(); - norflash->REG_004 &= ~REG_004_NEW_CMD_EN; - norflash->REG_000 = REG_000_CMD(cmd) | REG_000_ADDR(address); +void norflaship_ext_tx_cmd(uint8_t cmd, uint32_t tx_len) { + norflaship_busy_wait(); + norflash->REG_004 = + SET_BITFIELD(norflash->REG_004, REG_004_BLOCK_SIZE, tx_len) | + REG_004_NEW_CMD_EN; + norflash->REG_000 = REG_000_CMD(cmd); } -void norflaship_ext_tx_cmd(uint8_t cmd, uint32_t tx_len) -{ - norflaship_busy_wait(); - norflash->REG_004 = SET_BITFIELD(norflash->REG_004, REG_004_BLOCK_SIZE, tx_len) | REG_004_NEW_CMD_EN; - norflash->REG_000 = REG_000_CMD(cmd); +void norflaship_ext_rx_cmd(uint8_t cmd, uint32_t tx_len, uint32_t rx_len) { + norflaship_busy_wait(); + norflash->REG_004 = + SET_BITFIELD(norflash->REG_004, REG_004_BLOCK_SIZE, tx_len) | + REG_004_NEW_CMD_EN; + norflash->REG_000 = + REG_000_CMD(cmd) | REG_000_NEW_CMD_RX_EN | REG_000_NEW_CMD_RX_LEN(rx_len); } -void norflaship_ext_rx_cmd(uint8_t cmd, uint32_t tx_len, uint32_t rx_len) -{ - norflaship_busy_wait(); - norflash->REG_004 = SET_BITFIELD(norflash->REG_004, REG_004_BLOCK_SIZE, tx_len) | REG_004_NEW_CMD_EN; - norflash->REG_000 = REG_000_CMD(cmd) | REG_000_NEW_CMD_RX_EN | REG_000_NEW_CMD_RX_LEN(rx_len); +void norflaship_cmd_done(void) { + norflaship_busy_wait(); + norflash->REG_004 &= ~REG_004_NEW_CMD_EN; } -void norflaship_cmd_done(void) -{ - norflaship_busy_wait(); - norflash->REG_004 &= ~REG_004_NEW_CMD_EN; +void norflaship_rxfifo_count_wait(uint8_t cnt) { + while ((norflaship_read_rxfifo_count() < cnt) && TASK_SCHEDULE) + ; } -void norflaship_rxfifo_count_wait(uint8_t cnt) -{ - while ((norflaship_read_rxfifo_count() < cnt) && TASK_SCHEDULE); +void norflaship_rxfifo_empty_wait(void) { + while ((norflash->REG_00C & REG_00C_RXFIFO_EMPTY) && TASK_SCHEDULE) + ; } -void norflaship_rxfifo_empty_wait(void) -{ - while ((norflash->REG_00C & REG_00C_RXFIFO_EMPTY) && TASK_SCHEDULE); +int norflaship_txfifo_is_full(void) { + return !!(norflash->REG_00C & REG_00C_TXFIFO_FULL); } -int norflaship_txfifo_is_full(void) -{ - return !!(norflash->REG_00C & REG_00C_TXFIFO_FULL); +void norflaship_busy_wait(void) { + while ((norflash->REG_00C & REG_00C_BUSY) && TASK_SCHEDULE) + ; } -void norflaship_busy_wait(void) -{ - while ((norflash->REG_00C & REG_00C_BUSY) && TASK_SCHEDULE); +int norflaship_is_busy(void) { return !!(norflash->REG_00C & REG_00C_BUSY); } +void norflaship_clear_fifos(void) { + norflaship_busy_wait(); + norflash->REG_018 = REG_018_TXFIFOCLR | REG_018_RXFIFOCLR; + norflaship_busy_wait(); } -int norflaship_is_busy(void) -{ - return !!(norflash->REG_00C & REG_00C_BUSY); +void norflaship_clear_rxfifo(void) { + norflaship_busy_wait(); + norflash->REG_018 = REG_018_RXFIFOCLR; + norflaship_busy_wait(); } -void norflaship_clear_fifos(void) -{ - norflaship_busy_wait(); - norflash->REG_018 = REG_018_TXFIFOCLR | REG_018_RXFIFOCLR; - norflaship_busy_wait(); +void norflaship_clear_txfifo(void) { + norflaship_busy_wait(); + norflash->REG_018 = REG_018_TXFIFOCLR; + norflaship_busy_wait(); } -void norflaship_clear_rxfifo(void) -{ - norflaship_busy_wait(); - norflash->REG_018 = REG_018_RXFIFOCLR; - norflaship_busy_wait(); -} -void norflaship_clear_txfifo(void) -{ - norflaship_busy_wait(); - norflash->REG_018 = REG_018_TXFIFOCLR; - norflaship_busy_wait(); -} -void norflaship_div(uint32_t div) -{ - norflaship_busy_wait(); +void norflaship_div(uint32_t div) { + norflaship_busy_wait(); #ifdef CHIP_BEST2300P - norflash->REG_014 = SET_BITFIELD(norflash->REG_014, REG_014_CLKDIV, div) | EXTRA_TCHSH_EN_O; + norflash->REG_014 = + SET_BITFIELD(norflash->REG_014, REG_014_CLKDIV, div) | EXTRA_TCHSH_EN_O; #else - norflash->REG_014 = SET_BITFIELD(norflash->REG_014, REG_014_CLKDIV, div); + norflash->REG_014 = SET_BITFIELD(norflash->REG_014, REG_014_CLKDIV, div); #endif } -uint32_t norflaship_get_div(void) -{ - return GET_BITFIELD(norflash->REG_014, REG_014_CLKDIV); +uint32_t norflaship_get_div(void) { + return GET_BITFIELD(norflash->REG_014, REG_014_CLKDIV); } -void norflaship_cmdquad(uint32_t v) -{ - norflaship_busy_wait(); +void norflaship_cmdquad(uint32_t v) { + norflaship_busy_wait(); #ifdef CHIP_BEST2300P - if (v) { - norflash->REG_014 |= REG_014_CMDQUAD | EXTRA_TCHSH_EN_O; - } else { - norflash->REG_014 = (norflash->REG_014 & ~REG_014_CMDQUAD) | EXTRA_TCHSH_EN_O; - } + if (v) { + norflash->REG_014 |= REG_014_CMDQUAD | EXTRA_TCHSH_EN_O; + } else { + norflash->REG_014 = + (norflash->REG_014 & ~REG_014_CMDQUAD) | EXTRA_TCHSH_EN_O; + } #else - if (v) { - norflash->REG_014 |= REG_014_CMDQUAD; - } else { - norflash->REG_014 &= ~REG_014_CMDQUAD; - } + if (v) { + norflash->REG_014 |= REG_014_CMDQUAD; + } else { + norflash->REG_014 &= ~REG_014_CMDQUAD; + } #endif } -uint32_t norflaship_get_samdly(void) -{ - return GET_BITFIELD(norflash->REG_014, REG_014_SAMPLESEL); +uint32_t norflaship_get_samdly(void) { + return GET_BITFIELD(norflash->REG_014, REG_014_SAMPLESEL); } -void norflaship_samdly(uint32_t v) -{ - norflaship_busy_wait(); +void norflaship_samdly(uint32_t v) { + norflaship_busy_wait(); #ifdef CHIP_BEST2300P - norflash->REG_014 = SET_BITFIELD(norflash->REG_014, REG_014_SAMPLESEL, v) | EXTRA_TCHSH_EN_O; + norflash->REG_014 = + SET_BITFIELD(norflash->REG_014, REG_014_SAMPLESEL, v) | EXTRA_TCHSH_EN_O; #else - norflash->REG_014 = SET_BITFIELD(norflash->REG_014, REG_014_SAMPLESEL, v); + norflash->REG_014 = SET_BITFIELD(norflash->REG_014, REG_014_SAMPLESEL, v); #endif } -void norflaship_dual_mode(uint32_t v) -{ - norflaship_busy_wait(); +void norflaship_dual_mode(uint32_t v) { + norflaship_busy_wait(); #ifdef CHIP_BEST2300P - if (v) { - norflash->REG_014 |= REG_014_RAM_DUALMODE | EXTRA_TCHSH_EN_O; - } else { - norflash->REG_014 = (norflash->REG_014 & ~REG_014_RAM_DUALMODE) | EXTRA_TCHSH_EN_O; - } + if (v) { + norflash->REG_014 |= REG_014_RAM_DUALMODE | EXTRA_TCHSH_EN_O; + } else { + norflash->REG_014 = + (norflash->REG_014 & ~REG_014_RAM_DUALMODE) | EXTRA_TCHSH_EN_O; + } #else - if (v) { - norflash->REG_014 |= REG_014_RAM_DUALMODE; - } else { - norflash->REG_014 &= ~REG_014_RAM_DUALMODE; - } + if (v) { + norflash->REG_014 |= REG_014_RAM_DUALMODE; + } else { + norflash->REG_014 &= ~REG_014_RAM_DUALMODE; + } #endif } -void norflaship_hold_pin(uint32_t v) -{ +void norflaship_hold_pin(uint32_t v) { #ifdef CHIP_BEST2300P - if (v) { - norflash->REG_014 |= REG_014_HOLDPIN | EXTRA_TCHSH_EN_O; - } else { - norflash->REG_014 = (norflash->REG_014 & ~REG_014_HOLDPIN) | EXTRA_TCHSH_EN_O; - } + if (v) { + norflash->REG_014 |= REG_014_HOLDPIN | EXTRA_TCHSH_EN_O; + } else { + norflash->REG_014 = + (norflash->REG_014 & ~REG_014_HOLDPIN) | EXTRA_TCHSH_EN_O; + } #else - if (v) { - norflash->REG_014 |= REG_014_HOLDPIN; - } else { - norflash->REG_014 &= ~REG_014_HOLDPIN; - } + if (v) { + norflash->REG_014 |= REG_014_HOLDPIN; + } else { + norflash->REG_014 &= ~REG_014_HOLDPIN; + } #endif } -void norflaship_wpr_pin(uint32_t v) -{ +void norflaship_wpr_pin(uint32_t v) { #ifdef CHIP_BEST2300P - if (v) { - norflash->REG_014 |= REG_014_WPROPIN | EXTRA_TCHSH_EN_O; - } else { - norflash->REG_014 = (norflash->REG_014 & ~REG_014_WPROPIN) | EXTRA_TCHSH_EN_O; - } + if (v) { + norflash->REG_014 |= REG_014_WPROPIN | EXTRA_TCHSH_EN_O; + } else { + norflash->REG_014 = + (norflash->REG_014 & ~REG_014_WPROPIN) | EXTRA_TCHSH_EN_O; + } #else - if (v) { - norflash->REG_014 |= REG_014_WPROPIN; - } else { - norflash->REG_014 &= ~REG_014_WPROPIN; - } + if (v) { + norflash->REG_014 |= REG_014_WPROPIN; + } else { + norflash->REG_014 &= ~REG_014_WPROPIN; + } #endif } -void norflaship_quad_mode(uint32_t v) -{ - norflaship_busy_wait(); +void norflaship_quad_mode(uint32_t v) { + norflaship_busy_wait(); #ifdef CHIP_BEST2300P - if (v) { - norflash->REG_014 |= REG_014_RAM_QUADMODE | EXTRA_TCHSH_EN_O; - } else { - norflash->REG_014 = (norflash->REG_014 & ~REG_014_RAM_QUADMODE) | EXTRA_TCHSH_EN_O; - } + if (v) { + norflash->REG_014 |= REG_014_RAM_QUADMODE | EXTRA_TCHSH_EN_O; + } else { + norflash->REG_014 = + (norflash->REG_014 & ~REG_014_RAM_QUADMODE) | EXTRA_TCHSH_EN_O; + } #else - if (v) { - norflash->REG_014 |= REG_014_RAM_QUADMODE; - } else { - norflash->REG_014 &= ~REG_014_RAM_QUADMODE; - } + if (v) { + norflash->REG_014 |= REG_014_RAM_QUADMODE; + } else { + norflash->REG_014 &= ~REG_014_RAM_QUADMODE; + } #endif } -void norflaship_addrbyte4(uint32_t v) -{ +void norflaship_addrbyte4(uint32_t v) { #ifdef CHIP_BEST2300P - if (v) { - norflash->REG_014 |= REG_014_FOUR_BYTE_ADDR_EN | EXTRA_TCHSH_EN_O; - } else { - norflash->REG_014 = (norflash->REG_014 & ~REG_014_FOUR_BYTE_ADDR_EN) | EXTRA_TCHSH_EN_O; - } + if (v) { + norflash->REG_014 |= REG_014_FOUR_BYTE_ADDR_EN | EXTRA_TCHSH_EN_O; + } else { + norflash->REG_014 = + (norflash->REG_014 & ~REG_014_FOUR_BYTE_ADDR_EN) | EXTRA_TCHSH_EN_O; + } #else - if (v) { - norflash->REG_014 |= REG_014_FOUR_BYTE_ADDR_EN; - } else { - norflash->REG_014 &= ~REG_014_FOUR_BYTE_ADDR_EN; - } + if (v) { + norflash->REG_014 |= REG_014_FOUR_BYTE_ADDR_EN; + } else { + norflash->REG_014 &= ~REG_014_FOUR_BYTE_ADDR_EN; + } #endif } -void norflaship_ruen(uint32_t v) -{ - norflash->REG_034 = SET_BITFIELD(norflash->REG_034, REG_034_SPI_RUEN, v); +void norflaship_ruen(uint32_t v) { + norflash->REG_034 = SET_BITFIELD(norflash->REG_034, REG_034_SPI_RUEN, v); } -void norflaship_rden(uint32_t v) -{ - norflash->REG_034 = SET_BITFIELD(norflash->REG_034, REG_034_SPI_RDEN, v); +void norflaship_rden(uint32_t v) { + norflash->REG_034 = SET_BITFIELD(norflash->REG_034, REG_034_SPI_RDEN, v); } -void norflaship_dualiocmd(uint32_t v) -{ - norflash->REG_020 = SET_BITFIELD(norflash->REG_020, REG_020_DUALCMD, v); +void norflaship_dualiocmd(uint32_t v) { + norflash->REG_020 = SET_BITFIELD(norflash->REG_020, REG_020_DUALCMD, v); } -void norflaship_rdcmd(uint32_t v) -{ - norflash->REG_020 = SET_BITFIELD(norflash->REG_020, REG_020_READCMD, v); +void norflaship_rdcmd(uint32_t v) { + norflash->REG_020 = SET_BITFIELD(norflash->REG_020, REG_020_READCMD, v); } -void norflaship_frdcmd(uint32_t v) -{ - norflash->REG_020 = SET_BITFIELD(norflash->REG_020, REG_020_FREADCMD, v); +void norflaship_frdcmd(uint32_t v) { + norflash->REG_020 = SET_BITFIELD(norflash->REG_020, REG_020_FREADCMD, v); } -void norflaship_qrdcmd(uint32_t v) -{ - norflash->REG_020 = SET_BITFIELD(norflash->REG_020, REG_020_QUADCMD, v); +void norflaship_qrdcmd(uint32_t v) { + norflash->REG_020 = SET_BITFIELD(norflash->REG_020, REG_020_QUADCMD, v); } -uint32_t norflaship_get_rdcmd(void) -{ - return GET_BITFIELD(norflash->REG_020, REG_020_READCMD); +uint32_t norflaship_get_rdcmd(void) { + return GET_BITFIELD(norflash->REG_020, REG_020_READCMD); } -void norflaship_set_idle_io_dir(uint32_t v) -{ +void norflaship_set_idle_io_dir(uint32_t v) { #ifdef NORFLASHIP_HAS_IDLE_IO_CTRL - norflash->REG_034 = SET_BITFIELD(norflash->REG_034, REG_034_SPI_IOEN, v); + norflash->REG_034 = SET_BITFIELD(norflash->REG_034, REG_034_SPI_IOEN, v); #endif } -void norflaship_sleep(void) -{ +void norflaship_sleep(void) { #ifndef NORFLASHIP_HAS_IDLE_IO_CTRL - norflash->REG_034 |= REG_034_SPI_IORES(1 << 2); + norflash->REG_034 |= REG_034_SPI_IORES(1 << 2); #endif } -void norflaship_wakeup(void) -{ +void norflaship_wakeup(void) { #ifndef NORFLASHIP_HAS_IDLE_IO_CTRL - norflash->REG_034 &= ~REG_034_SPI_IORES(1 << 2); + norflash->REG_034 &= ~REG_034_SPI_IORES(1 << 2); #endif } -void norflaship_dec_index(uint32_t idx) -{ +void norflaship_dec_index(uint32_t idx) { #ifdef NORFLASHIP_HAS_SECURITY - norflash->REG_058 = SET_BITFIELD(norflash->REG_058, REG_058_IDX, idx); + norflash->REG_058 = SET_BITFIELD(norflash->REG_058, REG_058_IDX, idx); #endif } -void norflaship_dec_saddr(uint32_t addr) -{ +void norflaship_dec_saddr(uint32_t addr) { #ifdef NORFLASHIP_HAS_SECURITY - norflash->REG_060 = ((addr & 0x000000ff) << 24) - |((addr & 0x0000ff00) << 8) - |((addr & 0x00ff0000) >> 8) - |((addr & 0xff000000) >> 24); + norflash->REG_060 = ((addr & 0x000000ff) << 24) | ((addr & 0x0000ff00) << 8) | + ((addr & 0x00ff0000) >> 8) | ((addr & 0xff000000) >> 24); #endif } -void norflaship_dec_eaddr(uint32_t addr) -{ +void norflaship_dec_eaddr(uint32_t addr) { #ifdef NORFLASHIP_HAS_SECURITY - norflash->REG_064 = ((addr & 0x000000ff) << 24) - |((addr & 0x0000ff00) << 8) - |((addr & 0x00ff0000) >> 8) - |((addr & 0xff000000) >> 24); + norflash->REG_064 = ((addr & 0x000000ff) << 24) | ((addr & 0x0000ff00) << 8) | + ((addr & 0x00ff0000) >> 8) | ((addr & 0xff000000) >> 24); #endif } -void norflaship_dec_enable(void) -{ +void norflaship_dec_enable(void) { #ifdef NORFLASHIP_HAS_SECURITY - norflash->REG_06C |= REG_06C_DEC_ENABLE; + norflash->REG_06C |= REG_06C_DEC_ENABLE; #endif } -void norflaship_dec_disable(void) -{ +void norflaship_dec_disable(void) { #ifdef NORFLASHIP_HAS_SECURITY - norflash->REG_06C &= ~REG_06C_DEC_ENABLE; + norflash->REG_06C &= ~REG_06C_DEC_ENABLE; #endif } -void norflaship_man_wrap_width(uint32_t width) -{ +void norflaship_man_wrap_width(uint32_t width) { #ifdef NORFLASHIP_HAS_SECURITY - int bits = 0; + int bits = 0; - if (width == 8) - bits = 0; - else if (width == 16) - bits = 1; - else if (width == 32) - bits = 2; - else if (width == 64) - bits = 3; - else - bits = 1; - norflash->REG_038 = SET_BITFIELD(norflash->REG_038, REG_038_MAN_WRAP_BITS, bits); + if (width == 8) + bits = 0; + else if (width == 16) + bits = 1; + else if (width == 32) + bits = 2; + else if (width == 64) + bits = 3; + else + bits = 1; + norflash->REG_038 = + SET_BITFIELD(norflash->REG_038, REG_038_MAN_WRAP_BITS, bits); #endif } -void norflaship_man_wrap_enable(void) -{ +void norflaship_man_wrap_enable(void) { #ifdef NORFLASHIP_HAS_SECURITY - norflash->REG_038 |= REG_038_MAN_WRAP_ENABLE; + norflash->REG_038 |= REG_038_MAN_WRAP_ENABLE; #endif } -void norflaship_man_wrap_disable(void) -{ +void norflaship_man_wrap_disable(void) { #ifdef NORFLASHIP_HAS_SECURITY - norflash->REG_038 &= ~REG_038_MAN_WRAP_ENABLE; + norflash->REG_038 &= ~REG_038_MAN_WRAP_ENABLE; #endif } -void norflaship_auto_wrap_cmd(uint32_t cmd) -{ +void norflaship_auto_wrap_cmd(uint32_t cmd) { #ifdef NORFLASHIP_HAS_SECURITY - norflash->REG_038 = SET_BITFIELD(norflash->REG_038, REG_038_AUTO_WRAP_CMD, cmd); + norflash->REG_038 = + SET_BITFIELD(norflash->REG_038, REG_038_AUTO_WRAP_CMD, cmd); #endif } -void norflaship_man_mode_enable(void) -{ +void norflaship_man_mode_enable(void) { #ifdef NORFLASHIP_HAS_SECURITY - norflash->REG_038 |= REG_038_WRAP_MODE_SEL; + norflash->REG_038 |= REG_038_WRAP_MODE_SEL; #endif } -void norflaship_man_mode_disable(void) -{ +void norflaship_man_mode_disable(void) { #ifdef NORFLASHIP_HAS_SECURITY - norflash->REG_038 &= ~REG_038_WRAP_MODE_SEL; + norflash->REG_038 &= ~REG_038_WRAP_MODE_SEL; #endif } -int norflaship_config_remap_section(uint32_t id, uint32_t addr, uint32_t len, uint32_t new_addr) -{ +int norflaship_config_remap_section(uint32_t id, uint32_t addr, uint32_t len, + uint32_t new_addr) { #ifdef NORFLASHIP_HAS_REMAP - __IO uint32_t *start, *end, *to; + __IO uint32_t *start, *end, *to; - if (id >= 4) { - return 1; - } - if (len == 0) { - norflash->REG_0B0 &= ~(REG_0B0_ADDR0_REMAP_EN << id); - return 0; - } - if (addr & (REMAP_SECTOR_SIZE - 1)) { - return 2; - } - if (new_addr & (REMAP_SECTOR_SIZE - 1)) { - return 3; - } - if (len < REMAP_SECTOR_SIZE) { - return 4; - } + if (id >= 4) { + return 1; + } + if (len == 0) { + norflash->REG_0B0 &= ~(REG_0B0_ADDR0_REMAP_EN << id); + return 0; + } + if (addr & (REMAP_SECTOR_SIZE - 1)) { + return 2; + } + if (new_addr & (REMAP_SECTOR_SIZE - 1)) { + return 3; + } + if (len < REMAP_SECTOR_SIZE) { + return 4; + } #ifdef CHIP_BEST2300P - if (len & (len - 1)) { - return 5; - } + if (len & (len - 1)) { + return 5; + } - uint32_t len_idx; + uint32_t len_idx; - len_idx = __CLZ(__RBIT(len)) - 9; + len_idx = __CLZ(__RBIT(len)) - 9; - norflash->REG_0A0 = (norflash->REG_0A0 & ~(REG_0A0_LEN_WIDTH0_MASK << (id * REG_0A0_LEN_WIDTH1_SHIFT))) | - (REG_0A0_LEN_WIDTH0(len_idx) << (id * REG_0A0_LEN_WIDTH1_SHIFT)); + norflash->REG_0A0 = + (norflash->REG_0A0 & + ~(REG_0A0_LEN_WIDTH0_MASK << (id * REG_0A0_LEN_WIDTH1_SHIFT))) | + (REG_0A0_LEN_WIDTH0(len_idx) << (id * REG_0A0_LEN_WIDTH1_SHIFT)); #else - if (len & (REMAP_SECTOR_SIZE - 1)) { - return 5; - } + if (len & (REMAP_SECTOR_SIZE - 1)) { + return 5; + } #endif - start = &norflash->REG_070 + id; - end = &norflash->REG_080 + id; - to = &norflash->REG_090 + id; + start = &norflash->REG_070 + id; + end = &norflash->REG_080 + id; + to = &norflash->REG_090 + id; - *start = addr; - *end = addr + len - 1; - *to = new_addr; + *start = addr; + *end = addr + len - 1; + *to = new_addr; - norflash->REG_0B0 |= (REG_0B0_ADDR0_REMAP_EN << id); + norflash->REG_0B0 |= (REG_0B0_ADDR0_REMAP_EN << id); - return 0; + return 0; #else - return -1; + return -1; #endif } -void norflaship_enable_remap(void) -{ +void norflaship_enable_remap(void) { #ifdef NORFLASHIP_HAS_REMAP - norflash->REG_0B0 |= REG_0B0_GLB_REMAP_EN; + norflash->REG_0B0 |= REG_0B0_GLB_REMAP_EN; #endif } -void norflaship_disable_remap(void) -{ +void norflaship_disable_remap(void) { #ifdef NORFLASHIP_HAS_REMAP - norflash->REG_0B0 &= ~REG_0B0_GLB_REMAP_EN; + norflash->REG_0B0 &= ~REG_0B0_GLB_REMAP_EN; #endif } -int norflaship_get_remap_status(void) -{ +int norflaship_get_remap_status(void) { #ifdef NORFLASHIP_HAS_REMAP - return (norflash->REG_0B0 & REG_0B0_GLB_REMAP_EN) ? true : false; + return (norflash->REG_0B0 & REG_0B0_GLB_REMAP_EN) ? true : false; #else - return false; + return false; #endif } #if (CHIP_FLASH_CTRL_VER >= 3) -void norflaship_dummy_others(uint32_t v) -{ - norflash->REG_150 = REG_150_DUMMY_OTHERS(v); +void norflaship_dummy_others(uint32_t v) { + norflash->REG_150 = REG_150_DUMMY_OTHERS(v); } #endif -void norflaship_fetch_disable() -{ - norflash->REG_02C &= ~REG_02C_FETCH_EN; -} +void norflaship_fetch_disable() { norflash->REG_02C &= ~REG_02C_FETCH_EN; } #endif - diff --git a/platform/hal/hal_overlay.c b/platform/hal/hal_overlay.c index 1d741f0..f0a6c48 100644 --- a/platform/hal/hal_overlay.c +++ b/platform/hal/hal_overlay.c @@ -13,12 +13,12 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" #include "hal_overlay.h" -#include "hal_sysfreq.h" -#include "hal_cache.h" -#include "hal_trace.h" #include "cmsis.h" +#include "hal_cache.h" +#include "hal_sysfreq.h" +#include "hal_trace.h" +#include "plat_types.h" #ifdef __ARMCC_VERSION #include "link_sym_armclang.h" #endif @@ -63,198 +63,172 @@ extern uint32_t __load_stop_overlay_data7[]; #ifndef NO_OVERLAY -#define OVERLAY_IS_FREE 0 -#define OVERLAY_IS_USED 1 - -#define CHECK_OVERLAY_ID(id) \ - do {\ - if ((id < 0) || (id >= HAL_OVERLAY_ID_QTY)) { \ - ASSERT(0, "overlay id error %d", id); \ - } \ - } while (0) +#define OVERLAY_IS_FREE 0 +#define OVERLAY_IS_USED 1 +#define CHECK_OVERLAY_ID(id) \ + do { \ + if ((id < 0) || (id >= HAL_OVERLAY_ID_QTY)) { \ + ASSERT(0, "overlay id error %d", id); \ + } \ + } while (0) static bool segment_state[HAL_OVERLAY_ID_QTY]; static enum HAL_OVERLAY_ID_T cur_overlay_id = HAL_OVERLAY_ID_QTY; -static uint32_t * const text_load_start[HAL_OVERLAY_ID_QTY] = { - __load_start_overlay_text0, - __load_start_overlay_text1, - __load_start_overlay_text2, - __load_start_overlay_text3, - __load_start_overlay_text4, - __load_start_overlay_text5, - __load_start_overlay_text6, - __load_start_overlay_text7, +static uint32_t *const text_load_start[HAL_OVERLAY_ID_QTY] = { + __load_start_overlay_text0, __load_start_overlay_text1, + __load_start_overlay_text2, __load_start_overlay_text3, + __load_start_overlay_text4, __load_start_overlay_text5, + __load_start_overlay_text6, __load_start_overlay_text7, }; -static uint32_t * const text_load_stop[HAL_OVERLAY_ID_QTY] = { - __load_stop_overlay_text0, - __load_stop_overlay_text1, - __load_stop_overlay_text2, - __load_stop_overlay_text3, - __load_stop_overlay_text4, - __load_stop_overlay_text5, - __load_stop_overlay_text6, - __load_stop_overlay_text7, +static uint32_t *const text_load_stop[HAL_OVERLAY_ID_QTY] = { + __load_stop_overlay_text0, __load_stop_overlay_text1, + __load_stop_overlay_text2, __load_stop_overlay_text3, + __load_stop_overlay_text4, __load_stop_overlay_text5, + __load_stop_overlay_text6, __load_stop_overlay_text7, }; -static uint32_t * const data_load_start[HAL_OVERLAY_ID_QTY] = { - __load_start_overlay_data0, - __load_start_overlay_data1, - __load_start_overlay_data2, - __load_start_overlay_data3, - __load_start_overlay_data4, - __load_start_overlay_data5, - __load_start_overlay_data6, - __load_start_overlay_data7, +static uint32_t *const data_load_start[HAL_OVERLAY_ID_QTY] = { + __load_start_overlay_data0, __load_start_overlay_data1, + __load_start_overlay_data2, __load_start_overlay_data3, + __load_start_overlay_data4, __load_start_overlay_data5, + __load_start_overlay_data6, __load_start_overlay_data7, }; -static uint32_t * const data_load_stop[HAL_OVERLAY_ID_QTY] = { - __load_stop_overlay_data0, - __load_stop_overlay_data1, - __load_stop_overlay_data2, - __load_stop_overlay_data3, - __load_stop_overlay_data4, - __load_stop_overlay_data5, - __load_stop_overlay_data6, - __load_stop_overlay_data7, +static uint32_t *const data_load_stop[HAL_OVERLAY_ID_QTY] = { + __load_stop_overlay_data0, __load_stop_overlay_data1, + __load_stop_overlay_data2, __load_stop_overlay_data3, + __load_stop_overlay_data4, __load_stop_overlay_data5, + __load_stop_overlay_data6, __load_stop_overlay_data7, }; - /*must called by lock get */ -static void invalid_overlay_cache(enum HAL_OVERLAY_ID_T id) -{ - // TODO: PSRAM is large enough and no need to overlay - return; +static void invalid_overlay_cache(enum HAL_OVERLAY_ID_T id) { + // TODO: PSRAM is large enough and no need to overlay + return; #if defined(CHIP_HAS_PSRAM) && defined(PSRAM_ENABLE) - if (((uint32_t)__overlay_text_exec_start__ >= PSRAM_BASE && - (uint32_t)__overlay_text_exec_start__ < PSRAM_BASE + PSRAM_SIZE) || - ((uint32_t)__overlay_text_exec_start__ >= PSRAMX_BASE && - (uint32_t)__overlay_text_exec_start__ < PSRAMX_BASE + PSRAM_SIZE)) { - hal_cache_invalidate(HAL_CACHE_ID_I_CACHE, - (uint32_t)__overlay_text_exec_start__, - (uint32_t)text_load_stop[id] - (uint32_t)text_load_start[id]); - } + if (((uint32_t)__overlay_text_exec_start__ >= PSRAM_BASE && + (uint32_t)__overlay_text_exec_start__ < PSRAM_BASE + PSRAM_SIZE) || + ((uint32_t)__overlay_text_exec_start__ >= PSRAMX_BASE && + (uint32_t)__overlay_text_exec_start__ < PSRAMX_BASE + PSRAM_SIZE)) { + hal_cache_invalidate( + HAL_CACHE_ID_I_CACHE, (uint32_t)__overlay_text_exec_start__, + (uint32_t)text_load_stop[id] - (uint32_t)text_load_start[id]); + } - if (((uint32_t)__overlay_data_start__ >= PSRAM_BASE && - (uint32_t)__overlay_data_start__ < PSRAM_BASE + PSRAM_SIZE) || - ((uint32_t)__overlay_data_start__ >= PSRAMX_BASE && - (uint32_t)__overlay_data_start__ < PSRAMX_BASE + PSRAM_SIZE)) { - hal_cache_invalidate(HAL_CACHE_ID_D_CACHE, - (uint32_t)__overlay_data_start__, - (uint32_t)data_load_stop[id] - (uint32_t)data_load_start[id]); - } + if (((uint32_t)__overlay_data_start__ >= PSRAM_BASE && + (uint32_t)__overlay_data_start__ < PSRAM_BASE + PSRAM_SIZE) || + ((uint32_t)__overlay_data_start__ >= PSRAMX_BASE && + (uint32_t)__overlay_data_start__ < PSRAMX_BASE + PSRAM_SIZE)) { + hal_cache_invalidate(HAL_CACHE_ID_D_CACHE, (uint32_t)__overlay_data_start__, + (uint32_t)data_load_stop[id] - + (uint32_t)data_load_start[id]); + } #endif } -enum HAL_OVERLAY_RET_T hal_overlay_load(enum HAL_OVERLAY_ID_T id) -{ - enum HAL_OVERLAY_RET_T ret; +enum HAL_OVERLAY_RET_T hal_overlay_load(enum HAL_OVERLAY_ID_T id) { + enum HAL_OVERLAY_RET_T ret; - CHECK_OVERLAY_ID(id); - ret = HAL_OVERLAY_RET_OK; + CHECK_OVERLAY_ID(id); + ret = HAL_OVERLAY_RET_OK; - uint32_t lock; - uint32_t *dst, *src; + uint32_t lock; + uint32_t *dst, *src; - if (hal_overlay_is_used()) { - ASSERT(0, "overlay %d is in use", id); - return HAL_OVERLAY_RET_IN_USE; - } + if (hal_overlay_is_used()) { + ASSERT(0, "overlay %d is in use", id); + return HAL_OVERLAY_RET_IN_USE; + } - hal_sysfreq_req(HAL_SYSFREQ_USER_OVERLAY, HAL_CMU_FREQ_52M); - lock = int_lock(); + hal_sysfreq_req(HAL_SYSFREQ_USER_OVERLAY, HAL_CMU_FREQ_52M); + lock = int_lock(); - if (cur_overlay_id == HAL_OVERLAY_ID_QTY) { - cur_overlay_id = HAL_OVERLAY_ID_IN_CFG; - } else if (cur_overlay_id == HAL_OVERLAY_ID_IN_CFG) { - ret = HAL_OVERLAY_RET_IN_CFG; - } else { - ret = HAL_OVERLAY_RET_IN_USE; - } + if (cur_overlay_id == HAL_OVERLAY_ID_QTY) { + cur_overlay_id = HAL_OVERLAY_ID_IN_CFG; + } else if (cur_overlay_id == HAL_OVERLAY_ID_IN_CFG) { + ret = HAL_OVERLAY_RET_IN_CFG; + } else { + ret = HAL_OVERLAY_RET_IN_USE; + } - if (ret != HAL_OVERLAY_RET_OK) { - goto _exit; - } + if (ret != HAL_OVERLAY_RET_OK) { + goto _exit; + } - hal_overlay_acquire(id); + hal_overlay_acquire(id); - for (dst = __overlay_text_start__, src = text_load_start[id]; - src < text_load_stop[id]; - dst++, src++) { - *dst = *src; - } + for (dst = __overlay_text_start__, src = text_load_start[id]; + src < text_load_stop[id]; dst++, src++) { + *dst = *src; + } - for (dst = __overlay_data_start__, src = data_load_start[id]; - src < data_load_stop[id]; - dst++, src++) { - *dst = *src; - } + for (dst = __overlay_data_start__, src = data_load_start[id]; + src < data_load_stop[id]; dst++, src++) { + *dst = *src; + } - cur_overlay_id = id; - segment_state[id] = OVERLAY_IS_USED; + cur_overlay_id = id; + segment_state[id] = OVERLAY_IS_USED; _exit: - int_unlock(lock); - hal_sysfreq_req(HAL_SYSFREQ_USER_OVERLAY, HAL_CMU_FREQ_32K); + int_unlock(lock); + hal_sysfreq_req(HAL_SYSFREQ_USER_OVERLAY, HAL_CMU_FREQ_32K); - return ret; + return ret; } -enum HAL_OVERLAY_RET_T hal_overlay_unload(enum HAL_OVERLAY_ID_T id) -{ - enum HAL_OVERLAY_RET_T ret; +enum HAL_OVERLAY_RET_T hal_overlay_unload(enum HAL_OVERLAY_ID_T id) { + enum HAL_OVERLAY_RET_T ret; - CHECK_OVERLAY_ID(id); - ret = HAL_OVERLAY_RET_OK; + CHECK_OVERLAY_ID(id); + ret = HAL_OVERLAY_RET_OK; - uint32_t lock; + uint32_t lock; - lock = int_lock(); - if (cur_overlay_id == id) { - cur_overlay_id = HAL_OVERLAY_ID_QTY; - } else if (cur_overlay_id == HAL_OVERLAY_ID_IN_CFG) { - ret = HAL_OVERLAY_RET_IN_CFG; - } else { - ret = HAL_OVERLAY_RET_IN_USE; - } - hal_overlay_release(id); - int_unlock(lock); + lock = int_lock(); + if (cur_overlay_id == id) { + cur_overlay_id = HAL_OVERLAY_ID_QTY; + } else if (cur_overlay_id == HAL_OVERLAY_ID_IN_CFG) { + ret = HAL_OVERLAY_RET_IN_CFG; + } else { + ret = HAL_OVERLAY_RET_IN_USE; + } + hal_overlay_release(id); + int_unlock(lock); - return ret; + return ret; } /* * get the overlay's text start address */ -uint32_t hal_overlay_get_text_address(void) -{ - return (uint32_t)__overlay_text_start__; +uint32_t hal_overlay_get_text_address(void) { + return (uint32_t)__overlay_text_start__; } /* * get the whole size of the overlay text */ -uint32_t hal_overlay_get_text_all_size(void) -{ - uint32_t text_start, text_end; +uint32_t hal_overlay_get_text_all_size(void) { + uint32_t text_start, text_end; - text_start = (uint32_t)__overlay_text_exec_start__; - text_end = (uint32_t)__overlay_text_exec_end__; - return text_end - text_start; + text_start = (uint32_t)__overlay_text_exec_start__; + text_end = (uint32_t)__overlay_text_exec_end__; + return text_end - text_start; } /* * get the segment size of one overlay text */ -uint32_t hal_overlay_get_text_size(enum HAL_OVERLAY_ID_T id) -{ - CHECK_OVERLAY_ID(id); +uint32_t hal_overlay_get_text_size(enum HAL_OVERLAY_ID_T id) { + CHECK_OVERLAY_ID(id); - return (uint32_t)text_load_stop[id] - (uint32_t)text_load_start[id]; + return (uint32_t)text_load_stop[id] - (uint32_t)text_load_start[id]; } /* @@ -277,83 +251,77 @@ uint32_t hal_overlay_get_text_size(enum HAL_OVERLAY_ID_T id) * Use the free space of one segement, this function * return the free address of space */ -uint32_t hal_overlay_get_text_free_addr(enum HAL_OVERLAY_ID_T id) -{ - uint32_t segment_text_sz; - uint32_t start_addr; - uint32_t free_addr; +uint32_t hal_overlay_get_text_free_addr(enum HAL_OVERLAY_ID_T id) { + uint32_t segment_text_sz; + uint32_t start_addr; + uint32_t free_addr; - CHECK_OVERLAY_ID(id); - segment_text_sz = hal_overlay_get_text_size(id); - start_addr = hal_overlay_get_text_address(); - free_addr = start_addr + segment_text_sz; + CHECK_OVERLAY_ID(id); + segment_text_sz = hal_overlay_get_text_size(id); + start_addr = hal_overlay_get_text_address(); + free_addr = start_addr + segment_text_sz; - if (free_addr & 0x3 ) { - ASSERT(0, "free addr %p is not aligned to 4", (void *)free_addr); - } - return free_addr; + if (free_addr & 0x3) { + ASSERT(0, "free addr %p is not aligned to 4", (void *)free_addr); + } + return free_addr; } /* * get the free size for one overlay text */ -uint32_t hal_overlay_get_text_free_size(enum HAL_OVERLAY_ID_T id) -{ - uint32_t all_text_sz; - uint32_t segment_text_sz; +uint32_t hal_overlay_get_text_free_size(enum HAL_OVERLAY_ID_T id) { + uint32_t all_text_sz; + uint32_t segment_text_sz; - CHECK_OVERLAY_ID(id); - all_text_sz = hal_overlay_get_text_all_size(); - segment_text_sz = hal_overlay_get_text_size(id); + CHECK_OVERLAY_ID(id); + all_text_sz = hal_overlay_get_text_all_size(); + segment_text_sz = hal_overlay_get_text_size(id); - return all_text_sz - segment_text_sz; + return all_text_sz - segment_text_sz; } /* * acquire one overlay segment */ -void hal_overlay_acquire(enum HAL_OVERLAY_ID_T id) -{ - uint32_t lock; +void hal_overlay_acquire(enum HAL_OVERLAY_ID_T id) { + uint32_t lock; - CHECK_OVERLAY_ID(id); - segment_state[id] = OVERLAY_IS_USED; + CHECK_OVERLAY_ID(id); + segment_state[id] = OVERLAY_IS_USED; - lock = int_lock(); - invalid_overlay_cache(id); - int_unlock(lock); - return; + lock = int_lock(); + invalid_overlay_cache(id); + int_unlock(lock); + return; } /* * release one overlay segment */ -void hal_overlay_release(enum HAL_OVERLAY_ID_T id) -{ - CHECK_OVERLAY_ID(id); - segment_state[id] = OVERLAY_IS_FREE; - return; +void hal_overlay_release(enum HAL_OVERLAY_ID_T id) { + CHECK_OVERLAY_ID(id); + segment_state[id] = OVERLAY_IS_FREE; + return; } /* * check if any overlay segment is used */ -bool hal_overlay_is_used(void) -{ - int i; - uint32_t lock; +bool hal_overlay_is_used(void) { + int i; + uint32_t lock; - lock = int_lock(); - for (i = 0; i < HAL_OVERLAY_ID_QTY; i++) { - // if any segment is in use, the overlay is used; - if (segment_state[i] == OVERLAY_IS_USED ) { - int_unlock(lock); - return true; - } + lock = int_lock(); + for (i = 0; i < HAL_OVERLAY_ID_QTY; i++) { + // if any segment is in use, the overlay is used; + if (segment_state[i] == OVERLAY_IS_USED) { + int_unlock(lock); + return true; } - int_unlock(lock); - return false; + } + int_unlock(lock); + return false; } #endif - diff --git a/platform/hal/hal_overlay.h b/platform/hal/hal_overlay.h index 2ad555b..379007e 100644 --- a/platform/hal/hal_overlay.h +++ b/platform/hal/hal_overlay.h @@ -15,58 +15,60 @@ ****************************************************************************/ #ifndef __HAL_OVERLAY_H__ #define __HAL_OVERLAY_H__ +#include +#include #ifdef __cplusplus extern "C" { #endif -#define HAL_OVERLAY_TEXT0_LOC __attribute__((section(".overlay_text0"))) -#define HAL_OVERLAY_TEXT1_LOC __attribute__((section(".overlay_text1"))) -#define HAL_OVERLAY_TEXT2_LOC __attribute__((section(".overlay_text2"))) -#define HAL_OVERLAY_TEXT3_LOC __attribute__((section(".overlay_text3"))) -#define HAL_OVERLAY_TEXT4_LOC __attribute__((section(".overlay_text4"))) -#define HAL_OVERLAY_TEXT5_LOC __attribute__((section(".overlay_text5"))) -#define HAL_OVERLAY_TEXT6_LOC __attribute__((section(".overlay_text6"))) -#define HAL_OVERLAY_TEXT7_LOC __attribute__((section(".overlay_text7"))) +#define HAL_OVERLAY_TEXT0_LOC __attribute__((section(".overlay_text0"))) +#define HAL_OVERLAY_TEXT1_LOC __attribute__((section(".overlay_text1"))) +#define HAL_OVERLAY_TEXT2_LOC __attribute__((section(".overlay_text2"))) +#define HAL_OVERLAY_TEXT3_LOC __attribute__((section(".overlay_text3"))) +#define HAL_OVERLAY_TEXT4_LOC __attribute__((section(".overlay_text4"))) +#define HAL_OVERLAY_TEXT5_LOC __attribute__((section(".overlay_text5"))) +#define HAL_OVERLAY_TEXT6_LOC __attribute__((section(".overlay_text6"))) +#define HAL_OVERLAY_TEXT7_LOC __attribute__((section(".overlay_text7"))) -#define HAL_OVERLAY_RODATA0_LOC __attribute__((section(".overlay_rodata0"))) -#define HAL_OVERLAY_RODATA1_LOC __attribute__((section(".overlay_rodata1"))) -#define HAL_OVERLAY_RODATA2_LOC __attribute__((section(".overlay_rodata2"))) -#define HAL_OVERLAY_RODATA3_LOC __attribute__((section(".overlay_rodata3"))) -#define HAL_OVERLAY_RODATA4_LOC __attribute__((section(".overlay_rodata4"))) -#define HAL_OVERLAY_RODATA5_LOC __attribute__((section(".overlay_rodata5"))) -#define HAL_OVERLAY_RODATA6_LOC __attribute__((section(".overlay_rodata6"))) -#define HAL_OVERLAY_RODATA7_LOC __attribute__((section(".overlay_rodata7"))) +#define HAL_OVERLAY_RODATA0_LOC __attribute__((section(".overlay_rodata0"))) +#define HAL_OVERLAY_RODATA1_LOC __attribute__((section(".overlay_rodata1"))) +#define HAL_OVERLAY_RODATA2_LOC __attribute__((section(".overlay_rodata2"))) +#define HAL_OVERLAY_RODATA3_LOC __attribute__((section(".overlay_rodata3"))) +#define HAL_OVERLAY_RODATA4_LOC __attribute__((section(".overlay_rodata4"))) +#define HAL_OVERLAY_RODATA5_LOC __attribute__((section(".overlay_rodata5"))) +#define HAL_OVERLAY_RODATA6_LOC __attribute__((section(".overlay_rodata6"))) +#define HAL_OVERLAY_RODATA7_LOC __attribute__((section(".overlay_rodata7"))) -#define HAL_OVERLAY_DATA0_LOC __attribute__((section(".overlay_data0"))) -#define HAL_OVERLAY_DATA1_LOC __attribute__((section(".overlay_data1"))) -#define HAL_OVERLAY_DATA2_LOC __attribute__((section(".overlay_data2"))) -#define HAL_OVERLAY_DATA3_LOC __attribute__((section(".overlay_data3"))) -#define HAL_OVERLAY_DATA4_LOC __attribute__((section(".overlay_data4"))) -#define HAL_OVERLAY_DATA5_LOC __attribute__((section(".overlay_data5"))) -#define HAL_OVERLAY_DATA6_LOC __attribute__((section(".overlay_data6"))) -#define HAL_OVERLAY_DATA7_LOC __attribute__((section(".overlay_data7"))) +#define HAL_OVERLAY_DATA0_LOC __attribute__((section(".overlay_data0"))) +#define HAL_OVERLAY_DATA1_LOC __attribute__((section(".overlay_data1"))) +#define HAL_OVERLAY_DATA2_LOC __attribute__((section(".overlay_data2"))) +#define HAL_OVERLAY_DATA3_LOC __attribute__((section(".overlay_data3"))) +#define HAL_OVERLAY_DATA4_LOC __attribute__((section(".overlay_data4"))) +#define HAL_OVERLAY_DATA5_LOC __attribute__((section(".overlay_data5"))) +#define HAL_OVERLAY_DATA6_LOC __attribute__((section(".overlay_data6"))) +#define HAL_OVERLAY_DATA7_LOC __attribute__((section(".overlay_data7"))) -#define INVALID_OVERLAY_ADDR 0xffffffff +#define INVALID_OVERLAY_ADDR 0xffffffff enum HAL_OVERLAY_ID_T { - HAL_OVERLAY_ID_0, - HAL_OVERLAY_ID_1, - HAL_OVERLAY_ID_2, - HAL_OVERLAY_ID_3, - HAL_OVERLAY_ID_4, - HAL_OVERLAY_ID_5, - HAL_OVERLAY_ID_6, - HAL_OVERLAY_ID_7, + HAL_OVERLAY_ID_0, + HAL_OVERLAY_ID_1, + HAL_OVERLAY_ID_2, + HAL_OVERLAY_ID_3, + HAL_OVERLAY_ID_4, + HAL_OVERLAY_ID_5, + HAL_OVERLAY_ID_6, + HAL_OVERLAY_ID_7, - HAL_OVERLAY_ID_QTY, - HAL_OVERLAY_ID_IN_CFG, + HAL_OVERLAY_ID_QTY, + HAL_OVERLAY_ID_IN_CFG, }; enum HAL_OVERLAY_RET_T { - HAL_OVERLAY_RET_OK, - HAL_OVERLAY_RET_BAD_ID, - HAL_OVERLAY_RET_IN_CFG, - HAL_OVERLAY_RET_IN_USE, + HAL_OVERLAY_RET_OK, + HAL_OVERLAY_RET_BAD_ID, + HAL_OVERLAY_RET_IN_CFG, + HAL_OVERLAY_RET_IN_USE, }; #ifndef NO_OVERLAY @@ -88,7 +90,7 @@ uint32_t hal_overlay_get_text_all_size(void); */ uint32_t hal_overlay_get_text_size(enum HAL_OVERLAY_ID_T id); /* - * Use the free space of one segement, this function + * Use the free space of one segement, this function * return the free address of space */ uint32_t hal_overlay_get_text_free_addr(enum HAL_OVERLAY_ID_T id); @@ -111,32 +113,41 @@ bool hal_overlay_is_used(void); #else -static inline enum HAL_OVERLAY_RET_T hal_overlay_load(enum HAL_OVERLAY_ID_T id) -{ return HAL_OVERLAY_RET_OK; } +static inline enum HAL_OVERLAY_RET_T +hal_overlay_load(enum HAL_OVERLAY_ID_T id) { + return HAL_OVERLAY_RET_OK; +} -static inline enum HAL_OVERLAY_RET_T hal_overlay_unload(enum HAL_OVERLAY_ID_T id) -{ return HAL_OVERLAY_RET_OK; } +static inline enum HAL_OVERLAY_RET_T +hal_overlay_unload(enum HAL_OVERLAY_ID_T id) { + return HAL_OVERLAY_RET_OK; +} -static inline uint32_t hal_overlay_get_text_address(void) -{ return INVALID_OVERLAY_ADDR;} +static inline uint32_t hal_overlay_get_text_address(void) { + return INVALID_OVERLAY_ADDR; +} -static inline uint32_t hal_overlay_get_text_all_size(void) -{ return 0;} +static inline uint32_t hal_overlay_get_text_all_size(void) { return 0; } -static inline uint32_t hal_overlay_get_text_size(enum HAL_OVERLAY_ID_T id) -{ return 0;} +static inline uint32_t hal_overlay_get_text_size(enum HAL_OVERLAY_ID_T id) { + return 0; +} -static inline uint32_t hal_overlay_get_text_free_addr(enum HAL_OVERLAY_ID_T id) -{ return INVALID_OVERLAY_ADDR;} +static inline uint32_t +hal_overlay_get_text_free_addr(enum HAL_OVERLAY_ID_T id) { + return INVALID_OVERLAY_ADDR; +} -static inline uint32_t hal_overlay_get_text_free_size(enum HAL_OVERLAY_ID_T id) -{ return 0;} +static inline uint32_t +hal_overlay_get_text_free_size(enum HAL_OVERLAY_ID_T id) { + return 0; +} -static inline void hal_overlay_acquire(enum HAL_OVERLAY_ID_T id) { return;} +static inline void hal_overlay_acquire(enum HAL_OVERLAY_ID_T id) { return; } -static inline void hal_overlay_release(enum HAL_OVERLAY_ID_T id) { return;} +static inline void hal_overlay_release(enum HAL_OVERLAY_ID_T id) { return; } -static inline bool hal_overlay_is_used(void) { return false;} +static inline bool hal_overlay_is_used(void) { return false; } #endif /*NO_OVERLAY*/ @@ -145,4 +156,3 @@ static inline bool hal_overlay_is_used(void) { return false;} #endif #endif /*__HAL_OVERLAY_H__*/ - diff --git a/platform/hal/hal_phyif.c b/platform/hal/hal_phyif.c index 08d05bd..8378d77 100644 --- a/platform/hal/hal_phyif.c +++ b/platform/hal/hal_phyif.c @@ -15,19 +15,19 @@ ****************************************************************************/ #ifdef CHIP_HAS_SPIPHY -#include "plat_types.h" -#include "cmsis.h" #include "hal_phyif.h" -#include "hal_spi.h" +#include "cmsis.h" #include "hal_location.h" +#include "hal_spi.h" +#include "plat_types.h" -#define PHY_READ_CMD(r) ((1 << 24) | (((r) & 0xFF) << 16)) -#define PHY_WRITE_CMD(r, v) ((((r) & 0xFF) << 16) | ((v) & 0xFFFF)) -#define PHY_READ_VAL(v) ((v) & 0xFFFF) +#define PHY_READ_CMD(r) ((1 << 24) | (((r)&0xFF) << 16)) +#define PHY_WRITE_CMD(r, v) ((((r)&0xFF) << 16) | ((v)&0xFFFF)) +#define PHY_READ_VAL(v) ((v)&0xFFFF) -#define SPIPHY_REG_CS(r) ((r) >> 12) -#define SPIPHY_REG_PAGE(r) (((r) >> 8) & 0xF) -#define SPIPHY_REG_OFFSET(r) ((r) & 0xFF) +#define SPIPHY_REG_CS(r) ((r) >> 12) +#define SPIPHY_REG_PAGE(r) (((r) >> 8) & 0xF) +#define SPIPHY_REG_OFFSET(r) ((r)&0xFF) static const struct HAL_SPI_CFG_T spi_cfg = { .clk_delay_half = false, @@ -47,113 +47,107 @@ static uint8_t BOOT_BSS_LOC phyif_open_map; static uint8_t BOOT_BSS_LOC phy_cs; -static int hal_phyif_rawread(unsigned short reg, unsigned short *val) -{ - int ret; - unsigned int data; - unsigned int cmd; - - data = 0; - cmd = PHY_READ_CMD(reg); - ret = hal_spiphy_recv(&cmd, &data, 4); - if (ret) { - return ret; - } - *val = PHY_READ_VAL(data); - return 0; -} - -static int hal_phyif_rawwrite(unsigned short reg, unsigned short val) -{ - int ret; - unsigned int cmd; - - cmd = PHY_WRITE_CMD(reg, val); - ret = hal_spiphy_send(&cmd, 4); - if (ret) { - return ret; - } - return 0; -} - -int hal_phyif_reg_read(unsigned short reg, unsigned short *val) -{ - uint32_t lock; - int ret; - uint8_t cs; - //uint8_t page; - - cs = SPIPHY_REG_CS(reg); - //page = SPIPHY_REG_PAGE(reg); - reg = SPIPHY_REG_OFFSET(reg); - - lock = int_lock(); - if (cs != phy_cs) { - hal_spiphy_activate_cs(cs); - phy_cs = cs; - } - ret = hal_phyif_rawread(reg, val); - int_unlock(lock); +static int hal_phyif_rawread(unsigned short reg, unsigned short *val) { + int ret; + unsigned int data; + unsigned int cmd; + data = 0; + cmd = PHY_READ_CMD(reg); + ret = hal_spiphy_recv(&cmd, &data, 4); + if (ret) { return ret; + } + *val = PHY_READ_VAL(data); + return 0; } -int hal_phyif_reg_write(unsigned short reg, unsigned short val) -{ - uint32_t lock; - int ret; - uint8_t cs; - //uint8_t page; - - cs = SPIPHY_REG_CS(reg); - //page = SPIPHY_REG_PAGE(reg); - reg = SPIPHY_REG_OFFSET(reg); - - lock = int_lock(); - if (cs != phy_cs) { - hal_spiphy_activate_cs(cs); - phy_cs = cs; - } - ret = hal_phyif_rawwrite(reg, val); - int_unlock(lock); +static int hal_phyif_rawwrite(unsigned short reg, unsigned short val) { + int ret; + unsigned int cmd; + cmd = PHY_WRITE_CMD(reg, val); + ret = hal_spiphy_send(&cmd, 4); + if (ret) { return ret; + } + return 0; } -int hal_phyif_open(uint32_t cs) -{ - int ret; - uint32_t lock; +int hal_phyif_reg_read(unsigned short reg, unsigned short *val) { + uint32_t lock; + int ret; + uint8_t cs; + // uint8_t page; - ret = 0; + cs = SPIPHY_REG_CS(reg); + // page = SPIPHY_REG_PAGE(reg); + reg = SPIPHY_REG_OFFSET(reg); - lock = int_lock(); - if (phyif_open_map == 0) { - ret = hal_spiphy_open(&spi_cfg); - } - if (ret == 0) { - phyif_open_map |= (1 << cs); - } - int_unlock(lock); + lock = int_lock(); + if (cs != phy_cs) { + hal_spiphy_activate_cs(cs); + phy_cs = cs; + } + ret = hal_phyif_rawread(reg, val); + int_unlock(lock); - return ret; + return ret; } -int hal_phyif_close(uint32_t cs) -{ - int ret; - uint32_t lock; +int hal_phyif_reg_write(unsigned short reg, unsigned short val) { + uint32_t lock; + int ret; + uint8_t cs; + // uint8_t page; - ret = 0; + cs = SPIPHY_REG_CS(reg); + // page = SPIPHY_REG_PAGE(reg); + reg = SPIPHY_REG_OFFSET(reg); - lock = int_lock(); - phyif_open_map &= ~(1 << cs); - if (phyif_open_map == 0) { - ret = hal_spiphy_close(spi_cfg.cs); - } - int_unlock(lock); + lock = int_lock(); + if (cs != phy_cs) { + hal_spiphy_activate_cs(cs); + phy_cs = cs; + } + ret = hal_phyif_rawwrite(reg, val); + int_unlock(lock); - return ret; + return ret; +} + +int hal_phyif_open(uint32_t cs) { + int ret; + uint32_t lock; + + ret = 0; + + lock = int_lock(); + if (phyif_open_map == 0) { + ret = hal_spiphy_open(&spi_cfg); + } + if (ret == 0) { + phyif_open_map |= (1 << cs); + } + int_unlock(lock); + + return ret; +} + +int hal_phyif_close(uint32_t cs) { + int ret; + uint32_t lock; + + ret = 0; + + lock = int_lock(); + phyif_open_map &= ~(1 << cs); + if (phyif_open_map == 0) { + ret = hal_spiphy_close(spi_cfg.cs); + } + int_unlock(lock); + + return ret; } #endif diff --git a/platform/hal/hal_psram_v1.c b/platform/hal/hal_psram_v1.c index 92263f3..229b2c4 100644 --- a/platform/hal/hal_psram_v1.c +++ b/platform/hal/hal_psram_v1.c @@ -15,8 +15,6 @@ ****************************************************************************/ #if defined(CHIP_HAS_PSRAM) && (CHIP_PSRAM_CTRL_VER == 1) -#include "plat_types.h" -#include "plat_addr_map.h" #include "hal_cmu.h" #include "hal_location.h" #include "hal_psram.h" @@ -24,6 +22,8 @@ #include "hal_timer.h" #include "hal_trace.h" #include "hal_uart.h" +#include "plat_addr_map.h" +#include "plat_types.h" #include "pmu.h" #define PSRAM_CALIB 0 @@ -36,36 +36,36 @@ #define HAL_PSRAM_CMD_RAM_WRITE 0x80 enum HAL_PSRAM_SPEED { - HAL_PSRAM_SPEED_13M = 13000000, - HAL_PSRAM_SPEED_26M = 26000000, - HAL_PSRAM_SPEED_50M = 50000000, - HAL_PSRAM_SPEED_52M = 52000000, - HAL_PSRAM_SPEED_78M = 78000000, - HAL_PSRAM_SPEED_104M = 104000000, - HAL_PSRAM_SPEED_130M = 130000000, - HAL_PSRAM_SPEED_156M = 156000000, - HAL_PSRAM_SPEED_182M = 182000000, - HAL_PSRAM_SPEED_208M = 208000000, - HAL_PSRAM_SPEED_234M = 234000000, + HAL_PSRAM_SPEED_13M = 13000000, + HAL_PSRAM_SPEED_26M = 26000000, + HAL_PSRAM_SPEED_50M = 50000000, + HAL_PSRAM_SPEED_52M = 52000000, + HAL_PSRAM_SPEED_78M = 78000000, + HAL_PSRAM_SPEED_104M = 104000000, + HAL_PSRAM_SPEED_130M = 130000000, + HAL_PSRAM_SPEED_156M = 156000000, + HAL_PSRAM_SPEED_182M = 182000000, + HAL_PSRAM_SPEED_208M = 208000000, + HAL_PSRAM_SPEED_234M = 234000000, }; struct HAL_PSRAM_CONFIG_T { - uint32_t source_clk; - uint32_t speed; - uint32_t dqs_rd_sel; - uint32_t dqs_wr_sel; + uint32_t source_clk; + uint32_t speed; + uint32_t dqs_rd_sel; + uint32_t dqs_wr_sel; - /* internal use : can be config if need to (useful for rom) */ - uint8_t override_config:1; - uint8_t div; + /* internal use : can be config if need to (useful for rom) */ + uint8_t override_config : 1; + uint8_t div; }; #define PSRAM_DEVICE_ID_LEN_MAX 8 struct HAL_Psram_Context { - uint8_t device_id[PSRAM_DEVICE_ID_LEN_MAX]; - uint32_t total_size; - uint32_t read_size; - uint32_t write_size; + uint8_t device_id[PSRAM_DEVICE_ID_LEN_MAX]; + uint32_t total_size; + uint32_t read_size; + uint32_t write_size; }; /* hal api */ @@ -80,33 +80,34 @@ void hal_psram_wakeup_init(void); struct HAL_Psram_Context psram_ctx[HAL_PSRAM_ID_NUM]; -//static const char * const invalid_drv = "psram drv invalid"; +// static const char * const invalid_drv = "psram drv invalid"; #define DIGITAL_REG(a) *(volatile uint32_t *)(a) -FLASH_TEXT_LOC static uint32_t _psram_get_reg_base(enum HAL_PSRAM_ID_T id) -{ - switch(id) { - case HAL_PSRAM_ID_0: - default: - return PSRAM_CTRL_BASE; - break; - } +FLASH_TEXT_LOC static uint32_t _psram_get_reg_base(enum HAL_PSRAM_ID_T id) { + switch (id) { + case HAL_PSRAM_ID_0: + default: + return PSRAM_CTRL_BASE; + break; + } } -FLASH_TEXT_LOC static void _psram_exitsleep_onprocess_wait(enum HAL_PSRAM_ID_T id) -{ - uint32_t reg_base = 0; - reg_base = _psram_get_reg_base(id); - while (psramip_r_exit_sleep_onprocess(reg_base)); +FLASH_TEXT_LOC static void +_psram_exitsleep_onprocess_wait(enum HAL_PSRAM_ID_T id) { + uint32_t reg_base = 0; + reg_base = _psram_get_reg_base(id); + while (psramip_r_exit_sleep_onprocess(reg_base)) + ; - while (!psramip_r_sleep_wakeup_state(reg_base)); + while (!psramip_r_sleep_wakeup_state(reg_base)) + ; } -FLASH_TEXT_LOC static void _psram_busy_wait(enum HAL_PSRAM_ID_T id) -{ - uint32_t reg_base = 0; - reg_base = _psram_get_reg_base(id); - while (psramip_r_busy(reg_base)); +FLASH_TEXT_LOC static void _psram_busy_wait(enum HAL_PSRAM_ID_T id) { + uint32_t reg_base = 0; + reg_base = _psram_get_reg_base(id); + while (psramip_r_busy(reg_base)) + ; } #if 0 static void _psram_div(enum HAL_PSRAM_ID_T id) @@ -184,76 +185,72 @@ void hal_psram_reg_dump(enum HAL_PSRAM_ID_T id) #endif -FLASH_TEXT_LOC uint8_t hal_psramip_read_reg(uint8_t reg) -{ - uint32_t mr; - psramip_clear_fifo(_psram_get_reg_base(HAL_PSRAM_ID_0)); - psramip_w_cmd_addr(0x40150000, HAL_PSRAM_CMD_REG_READ, (uint32_t)reg); - while((psramip_r_status(0x40150000)& PSRAM_STAT_BUSY)); +FLASH_TEXT_LOC uint8_t hal_psramip_read_reg(uint8_t reg) { + uint32_t mr; + psramip_clear_fifo(_psram_get_reg_base(HAL_PSRAM_ID_0)); + psramip_w_cmd_addr(0x40150000, HAL_PSRAM_CMD_REG_READ, (uint32_t)reg); + while ((psramip_r_status(0x40150000) & PSRAM_STAT_BUSY)) + ; - mr = psramip_r_rx_fifo(0x40150000); - return mr&0xff; + mr = psramip_r_rx_fifo(0x40150000); + return mr & 0xff; } -FLASH_TEXT_LOC void hal_psramip_write_reg(uint8_t reg, uint8_t val) -{ - enum HAL_PSRAM_ID_T id = HAL_PSRAM_ID_0; - psramip_clear_fifo(_psram_get_reg_base(HAL_PSRAM_ID_0)); - psramip_w_tx_fifo(0x40150000, (uint32_t)val); - psramip_w_cmd_addr(0x40150000, HAL_PSRAM_CMD_REG_WRITE, (uint32_t)reg); - _psram_busy_wait(id); +FLASH_TEXT_LOC void hal_psramip_write_reg(uint8_t reg, uint8_t val) { + enum HAL_PSRAM_ID_T id = HAL_PSRAM_ID_0; + psramip_clear_fifo(_psram_get_reg_base(HAL_PSRAM_ID_0)); + psramip_w_tx_fifo(0x40150000, (uint32_t)val); + psramip_w_cmd_addr(0x40150000, HAL_PSRAM_CMD_REG_WRITE, (uint32_t)reg); + _psram_busy_wait(id); } -FLASH_TEXT_LOC void hal_psram_suspend(enum HAL_PSRAM_ID_T id) -{ - uint32_t reg_base = 0; - reg_base = _psram_get_reg_base(id); +FLASH_TEXT_LOC void hal_psram_suspend(enum HAL_PSRAM_ID_T id) { + uint32_t reg_base = 0; + reg_base = _psram_get_reg_base(id); - psramip_w_acc_size(reg_base, 1); - hal_psramip_write_reg(0x6, 0xf0); + psramip_w_acc_size(reg_base, 1); + hal_psramip_write_reg(0x6, 0xf0); } -FLASH_TEXT_LOC void hal_psram_resume(enum HAL_PSRAM_ID_T id) -{ - uint32_t reg_base = 0; - reg_base = _psram_get_reg_base(id); +FLASH_TEXT_LOC void hal_psram_resume(enum HAL_PSRAM_ID_T id) { + uint32_t reg_base = 0; + reg_base = _psram_get_reg_base(id); - psramip_w_exit_sleep(reg_base); + psramip_w_exit_sleep(reg_base); - _psram_exitsleep_onprocess_wait(id); + _psram_exitsleep_onprocess_wait(id); } -//uint32_t test_ctrl =0; +// uint32_t test_ctrl =0; #ifdef CHIP_BEST2000 void pmu_open_bbpll_for_psram(); /*psram 120M use bbpll(div 4), 160M use bbpll(dir4), 100M use audio pll*/ -FLASH_TEXT_LOC void hal_psram_init(void) -{ +FLASH_TEXT_LOC void hal_psram_init(void) { #ifndef PSRAM_LOW_SPEED - uint8_t mr = 0; + uint8_t mr = 0; // enum HAL_PSRAM_ID_T id = HAL_PSRAM_ID_0; #if defined(PSRAM_120M) || defined(PSRAM_160M) - pmu_open_bbpll_for_psram(); - hal_cmu_mem_set_freq(HAL_CMU_FREQ_208M); + pmu_open_bbpll_for_psram(); + hal_cmu_mem_set_freq(HAL_CMU_FREQ_208M); #else /*PSRAM_160M*/ #ifdef MCU_ULTRAHIGH_PERFORMANCE_MODE - hal_cmu_mem_set_freq(HAL_CMU_FREQ_104M);//104*2 + hal_cmu_mem_set_freq(HAL_CMU_FREQ_104M); // 104*2 #else - hal_cmu_mem_set_freq(HAL_CMU_FREQ_208M); + hal_cmu_mem_set_freq(HAL_CMU_FREQ_208M); #endif #endif /*PSRAM_160M*/ - pmu_psram_freq_config(HAL_PSRAM_SPEED_208M); + pmu_psram_freq_config(HAL_PSRAM_SPEED_208M); #else - hal_cmu_mem_set_freq(HAL_CMU_FREQ_26M); - pmu_psram_freq_config(HAL_PSRAM_SPEED_26M); + hal_cmu_mem_set_freq(HAL_CMU_FREQ_26M); + pmu_psram_freq_config(HAL_PSRAM_SPEED_26M); #endif - hal_cmu_clock_enable(HAL_CMU_MOD_O_PSRAM); - hal_cmu_clock_enable(HAL_CMU_MOD_H_PSRAM); - hal_cmu_reset_clear(HAL_CMU_MOD_O_PSRAM); - hal_cmu_reset_clear(HAL_CMU_MOD_H_PSRAM); - DIGITAL_REG(0x4008004c) |= 0x1<<21; - #if 0 //for debug + hal_cmu_clock_enable(HAL_CMU_MOD_O_PSRAM); + hal_cmu_clock_enable(HAL_CMU_MOD_H_PSRAM); + hal_cmu_reset_clear(HAL_CMU_MOD_O_PSRAM); + hal_cmu_reset_clear(HAL_CMU_MOD_H_PSRAM); + DIGITAL_REG(0x4008004c) |= 0x1 << 21; +#if 0 // for debug DIGITAL_REG(0x40150020) = 0x01; DIGITAL_REG(0x400000ac) &= ~(0xc0000); @@ -264,269 +261,286 @@ FLASH_TEXT_LOC void hal_psram_init(void) #endif #ifndef PSRAM_LOW_SPEED - DIGITAL_REG(0x40150040) = 0x44712133; + DIGITAL_REG(0x40150040) = 0x44712133; - DIGITAL_REG(0x40150044) = 0x200040b1; - DIGITAL_REG(0x40150044) |= (1<<1)|(1<<30); + DIGITAL_REG(0x40150044) = 0x200040b1; + DIGITAL_REG(0x40150044) |= (1 << 1) | (1 << 30); - while (((DIGITAL_REG(0x40150044)) & (0x1<<30))); - //hal_sys_timer_delay(MS_TO_TICKS(10)); - DIGITAL_REG(0x40150044) &= ~(1<<0); + while (((DIGITAL_REG(0x40150044)) & (0x1 << 30))) + ; + // hal_sys_timer_delay(MS_TO_TICKS(10)); + DIGITAL_REG(0x40150044) &= ~(1 << 0); - while (!((DIGITAL_REG(0x40150044)) & (0x1<<0))); - //hal_sys_timer_delay(MS_TO_TICKS(10)); + while (!((DIGITAL_REG(0x40150044)) & (0x1 << 0))) + ; + // hal_sys_timer_delay(MS_TO_TICKS(10)); - DIGITAL_REG(0x40000090) = 0x0001ffff; - while (!((DIGITAL_REG(0x40000090)) & (0x1<<20))); - //hal_sys_timer_delay(MS_TO_TICKS(10)); + DIGITAL_REG(0x40000090) = 0x0001ffff; + while (!((DIGITAL_REG(0x40000090)) & (0x1 << 20))) + ; + // hal_sys_timer_delay(MS_TO_TICKS(10)); - //lp delay - // DIGITAL_REG(0x4015001C)=0xffffffff;//c - DIGITAL_REG(0x4015001C)=((4*200)<<0)| - ((70*200)<<16)| - ((70*200/1000)<<10);// 208MHZ: tHS 10us, tXHS 100us, tXPHS 100ns - //ramp=1k select low speed - DIGITAL_REG(0x4015002C)=0x0000000d;//c - //tx/rx Phase - // #error "6666666666666666" - //DIGITAL_REG(0x40150024)= 0x55000713;//0x55000373;//223 - //DIGITAL_REG(0x40150024)= 0x55000373;//0x55000373;//223 - #if PSRAM_CALIB + // lp delay + // DIGITAL_REG(0x4015001C)=0xffffffff;//c + DIGITAL_REG(0x4015001C) = + ((4 * 200) << 0) | ((70 * 200) << 16) | + ((70 * 200 / 1000) << 10); // 208MHZ: tHS 10us, tXHS 100us, tXPHS 100ns + // ramp=1k select low speed + DIGITAL_REG(0x4015002C) = 0x0000000d; // c + // tx/rx Phase +// #error "6666666666666666" +// DIGITAL_REG(0x40150024)= 0x55000713;//0x55000373;//223 +// DIGITAL_REG(0x40150024)= 0x55000373;//0x55000373;//223 +#if PSRAM_CALIB - DIGITAL_REG(0x40150024)= 0x55000373;//0x55000373;//223 - #else + DIGITAL_REG(0x40150024) = 0x55000373; // 0x55000373;//223 +#else #if defined(PSRAM_200M) - DIGITAL_REG(0x40150024)= 0x55000653;//0x55000373;//223 + DIGITAL_REG(0x40150024) = 0x55000653; // 0x55000373;//223 #elif defined(PSRAM_160M) - DIGITAL_REG(0x40150024)= 0x55000463;//;//0x55000373;//223 + DIGITAL_REG(0x40150024) = 0x55000463; //;//0x55000373;//223 #elif defined(PSRAM_120M) - DIGITAL_REG(0x40150024)= 0x55000113;//0x55000373;//223 + DIGITAL_REG(0x40150024) = 0x55000113; // 0x55000373;//223 #else /*100M*/ - DIGITAL_REG(0x40150024)= 0x55000113;//0x55000373;//223 + DIGITAL_REG(0x40150024) = 0x55000113; // 0x55000373;//223 #endif - #endif - while (!((DIGITAL_REG(0x40150024)) & (0x1<<3))); +#endif + while (!((DIGITAL_REG(0x40150024)) & (0x1 << 3))) + ; #if 1 - //reset psram chip - psramip_write32(0xff, 0x40150000, 0x00); - while((psramip_r_status(0x40150000)& PSRAM_STAT_BUSY)); - //clear fifo - psramip_write32(0x03, 0x40150000, 0x18); + // reset psram chip + psramip_write32(0xff, 0x40150000, 0x00); + while ((psramip_r_status(0x40150000) & PSRAM_STAT_BUSY)) + ; + // clear fifo + psramip_write32(0x03, 0x40150000, 0x18); - while((psramip_r_status(0x40150000)& PSRAM_STAT_BUSY)); - hal_sys_timer_delay(US_TO_TICKS(10)); - // test_ctrl = 1; - // while (test_ctrl ==1); + while ((psramip_r_status(0x40150000) & PSRAM_STAT_BUSY)) + ; + hal_sys_timer_delay(US_TO_TICKS(10)); + // test_ctrl = 1; + // while (test_ctrl ==1); - mr = hal_psramip_read_reg(0x0); - mr &= ~(0x3 << 6); // MR[7:6] must set 0 - mr &= ~(0x1 << 5); //MR0[5] = 0, latency type 0->variable - mr &= ~(0x7 << 2); - mr |= (0x6 << 2); //MR0[4:2] = '110 Latency =6 for 200M (variable latency) - mr &= ~(0x3 << 0); - mr |= (0x1 << 0); //driver strength '01 -> half - hal_psramip_write_reg(0x0, mr); - mr = hal_psramip_read_reg(0x0); - //TRACE(2,"PSRAM MODE REG 0 = 0x%x, status = 0x%x", mr, psramip_r_status(0x40150000)); + mr = hal_psramip_read_reg(0x0); + mr &= ~(0x3 << 6); // MR[7:6] must set 0 + mr &= ~(0x1 << 5); // MR0[5] = 0, latency type 0->variable + mr &= ~(0x7 << 2); + mr |= (0x6 << 2); // MR0[4:2] = '110 Latency =6 for 200M (variable latency) + mr &= ~(0x3 << 0); + mr |= (0x1 << 0); // driver strength '01 -> half + hal_psramip_write_reg(0x0, mr); + mr = hal_psramip_read_reg(0x0); + // TRACE(2,"PSRAM MODE REG 0 = 0x%x, status = 0x%x", mr, + // psramip_r_status(0x40150000)); - mr = hal_psramip_read_reg(0x4); - mr &= ~(0x01 << 7); - mr |= (0x01 << 7); // MR[7] '1 -> write latency 1 for clk > 166MHz - //hal_psramip_write_reg(0x4, mr); - mr = hal_psramip_read_reg(0x4); - //TRACE(2,"PSRAM MODE REG 4 = 0x%x, status = 0x%x", mr, psramip_r_status(0x40150000)); + mr = hal_psramip_read_reg(0x4); + mr &= ~(0x01 << 7); + mr |= (0x01 << 7); // MR[7] '1 -> write latency 1 for clk > 166MHz + // hal_psramip_write_reg(0x4, mr); + mr = hal_psramip_read_reg(0x4); + // TRACE(2,"PSRAM MODE REG 4 = 0x%x, status = 0x%x", mr, + // psramip_r_status(0x40150000)); #endif - hal_sys_timer_delay(US_TO_TICKS(10)); -#else /*PSRAM_LOW_SPEED*/ - // open psram phy power - DIGITAL_REG(0x4008004c) |= (1 << 21); - //init psram - //lp delay - DIGITAL_REG(0x4015001C)=0x3fff3cff;//c - //ramp=1k select low speed - DIGITAL_REG(0x4015002C)=0x0000000c; - //tx/rx Phase - DIGITAL_REG(0x40150024)=0x55000223; + hal_sys_timer_delay(US_TO_TICKS(10)); +#else /*PSRAM_LOW_SPEED*/ + // open psram phy power + DIGITAL_REG(0x4008004c) |= (1 << 21); + // init psram + // lp delay + DIGITAL_REG(0x4015001C) = 0x3fff3cff; // c + // ramp=1k select low speed + DIGITAL_REG(0x4015002C) = 0x0000000c; + // tx/rx Phase + DIGITAL_REG(0x40150024) = 0x55000223; #endif /*PSRAM_LOW_SPEED*/ - psramip_w_acc_size(_psram_get_reg_base(HAL_PSRAM_ID_0), 1); + psramip_w_acc_size(_psram_get_reg_base(HAL_PSRAM_ID_0), 1); #ifdef PSRAM_200M - hal_cmu_mem_set_freq(HAL_CMU_FREQ_208M); + hal_cmu_mem_set_freq(HAL_CMU_FREQ_208M); #endif } -FLASH_TEXT_LOC void hal_psram_wakeup_init(void) -{ +FLASH_TEXT_LOC void hal_psram_wakeup_init(void) { #ifndef PSRAM_LOW_SPEED - DIGITAL_REG(0x40150040) = 0x44712133; + DIGITAL_REG(0x40150040) = 0x44712133; - DIGITAL_REG(0x40150044) = 0x200040b1; - DIGITAL_REG(0x40150044) |= (1<<1)|(1<<30); + DIGITAL_REG(0x40150044) = 0x200040b1; + DIGITAL_REG(0x40150044) |= (1 << 1) | (1 << 30); - //TRACE(1,"0x40150044 = 0x%x \n",DIGITAL_REG(0x40150044)); - while (((DIGITAL_REG(0x40150044)) & (0x1<<30))); - //hal_sys_timer_delay(MS_TO_TICKS(10)); - DIGITAL_REG(0x40150044) &= ~(1<<0); + // TRACE(1,"0x40150044 = 0x%x \n",DIGITAL_REG(0x40150044)); + while (((DIGITAL_REG(0x40150044)) & (0x1 << 30))) + ; + // hal_sys_timer_delay(MS_TO_TICKS(10)); + DIGITAL_REG(0x40150044) &= ~(1 << 0); - //TRACE(1,"0x40150044 = 0x%x \n", DIGITAL_REG(0x40150044)); - while (!((DIGITAL_REG(0x40150044)) & (0x1<<0))); - //hal_sys_timer_delay(MS_TO_TICKS(10)); + // TRACE(1,"0x40150044 = 0x%x \n", DIGITAL_REG(0x40150044)); + while (!((DIGITAL_REG(0x40150044)) & (0x1 << 0))) + ; + // hal_sys_timer_delay(MS_TO_TICKS(10)); - DIGITAL_REG(0x40000090) = 0x0001ffff; - //TRACE(1,"0x40000090 = 0x%x \n", DIGITAL_REG(0x40000090)); - while (!((DIGITAL_REG(0x40000090)) & (0x1<<20))); - //hal_sys_timer_delay(MS_TO_TICKS(10)); + DIGITAL_REG(0x40000090) = 0x0001ffff; + // TRACE(1,"0x40000090 = 0x%x \n", DIGITAL_REG(0x40000090)); + while (!((DIGITAL_REG(0x40000090)) & (0x1 << 20))) + ; + // hal_sys_timer_delay(MS_TO_TICKS(10)); #endif - hal_psram_resume(HAL_PSRAM_ID_0); + hal_psram_resume(HAL_PSRAM_ID_0); } -FLASH_TEXT_LOC void hal_psram_sleep(void) -{ +FLASH_TEXT_LOC void hal_psram_sleep(void) { #ifndef PSRAM_LOW_SPEED - hal_psram_suspend(HAL_PSRAM_ID_0); - /* dll power off */ - DIGITAL_REG(0x40150044) &= ~(1 << 1); - /* phy power off */ - /* DIGITAL_REG(0x4008004c) &= ~(1 << 21) */ + hal_psram_suspend(HAL_PSRAM_ID_0); + /* dll power off */ + DIGITAL_REG(0x40150044) &= ~(1 << 1); + /* phy power off */ + /* DIGITAL_REG(0x4008004c) &= ~(1 << 21) */ #endif } #else -FLASH_TEXT_LOC void hal_psram_init(void) -{ +FLASH_TEXT_LOC void hal_psram_init(void) { #ifndef PSRAM_LOW_SPEED - unsigned int mr = 0; - enum HAL_PSRAM_ID_T id = HAL_PSRAM_ID_0; + unsigned int mr = 0; + enum HAL_PSRAM_ID_T id = HAL_PSRAM_ID_0; #endif - hal_cmu_mem_set_freq(HAL_CMU_FREQ_208M); - - hal_cmu_clock_enable(HAL_CMU_MOD_O_PSRAM); - hal_cmu_clock_enable(HAL_CMU_MOD_H_PSRAM); - hal_cmu_reset_clear(HAL_CMU_MOD_O_PSRAM); - hal_cmu_reset_clear(HAL_CMU_MOD_H_PSRAM); + hal_cmu_mem_set_freq(HAL_CMU_FREQ_208M); + hal_cmu_clock_enable(HAL_CMU_MOD_O_PSRAM); + hal_cmu_clock_enable(HAL_CMU_MOD_H_PSRAM); + hal_cmu_reset_clear(HAL_CMU_MOD_O_PSRAM); + hal_cmu_reset_clear(HAL_CMU_MOD_H_PSRAM); #ifndef PSRAM_LOW_SPEED - DIGITAL_REG(0x4001f038) = 0x77783533; + DIGITAL_REG(0x4001f038) = 0x77783533; - DIGITAL_REG(0x4001f03c) = 0x3ffffff4; - DIGITAL_REG(0x4001f03c) |= (1<<1)|(1<<30); - while (((DIGITAL_REG(0x4001f03c)) & (0x1<<30))); - hal_sys_timer_delay(MS_TO_TICKS(10)); - DIGITAL_REG(0x4001f03c) &= ~(1<<0); - while (!((DIGITAL_REG(0x4001f03c)) & (0x1<<0))); - hal_sys_timer_delay(MS_TO_TICKS(10)); + DIGITAL_REG(0x4001f03c) = 0x3ffffff4; + DIGITAL_REG(0x4001f03c) |= (1 << 1) | (1 << 30); + while (((DIGITAL_REG(0x4001f03c)) & (0x1 << 30))) + ; + hal_sys_timer_delay(MS_TO_TICKS(10)); + DIGITAL_REG(0x4001f03c) &= ~(1 << 0); + while (!((DIGITAL_REG(0x4001f03c)) & (0x1 << 0))) + ; + hal_sys_timer_delay(MS_TO_TICKS(10)); - DIGITAL_REG(0x40000090) = 0x0001ffff; - while (!((DIGITAL_REG(0x40000090)) & (0x1<<20))); - hal_sys_timer_delay(MS_TO_TICKS(10)); + DIGITAL_REG(0x40000090) = 0x0001ffff; + while (!((DIGITAL_REG(0x40000090)) & (0x1 << 20))) + ; + hal_sys_timer_delay(MS_TO_TICKS(10)); - //lp delay - DIGITAL_REG(0x4015001C)=0xffffffff;//c - //ramp=1k select low speed - DIGITAL_REG(0x4015002C)=0x0000000d;//c - //tx/rx Phase - DIGITAL_REG(0x40150024)=0x55000563;//223 - while (!((DIGITAL_REG(0x40150024)) & (0x1<<3))); + // lp delay + DIGITAL_REG(0x4015001C) = 0xffffffff; // c + // ramp=1k select low speed + DIGITAL_REG(0x4015002C) = 0x0000000d; // c + // tx/rx Phase + DIGITAL_REG(0x40150024) = 0x55000563; // 223 + while (!((DIGITAL_REG(0x40150024)) & (0x1 << 3))) + ; #if 1 - //reset psram chip - psramip_write32(0xff, 0x40150000, 0x00); - while((psramip_r_status(0x40150000)& PSRAM_STAT_BUSY)); - //clear fifo - psramip_write32(0x03, 0x40150000, 0x18); - while((psramip_r_status(0x40150000)& PSRAM_STAT_BUSY)); - hal_sys_timer_delay(MS_TO_TICKS(10)); + // reset psram chip + psramip_write32(0xff, 0x40150000, 0x00); + while ((psramip_r_status(0x40150000) & PSRAM_STAT_BUSY)) + ; + // clear fifo + psramip_write32(0x03, 0x40150000, 0x18); + while ((psramip_r_status(0x40150000) & PSRAM_STAT_BUSY)) + ; + hal_sys_timer_delay(MS_TO_TICKS(10)); - //read MR0 - psramip_w_cmd_addr(0x40150000, HAL_PSRAM_CMD_REG_READ, 0); - while((psramip_r_status(0x40150000)& PSRAM_STAT_BUSY)); - //need read twice - mr = psramip_r_rx_fifo(0x40150000); - mr = psramip_r_rx_fifo(0x40150000); - // hal_uart_printf("count=0x%x mr0 = 0x%x \n", psramip_r_status(0x40150000), mr); + // read MR0 + psramip_w_cmd_addr(0x40150000, HAL_PSRAM_CMD_REG_READ, 0); + while ((psramip_r_status(0x40150000) & PSRAM_STAT_BUSY)) + ; + // need read twice + mr = psramip_r_rx_fifo(0x40150000); + mr = psramip_r_rx_fifo(0x40150000); + // hal_uart_printf("count=0x%x mr0 = 0x%x \n", psramip_r_status(0x40150000), + // mr); - mr &= 0xff; - mr &= ~(0x03 << 6); // MR[7:6] must set 0 - // driver strength 00:1/16 01:1/2 10:1/4 11:1/8 MR0[1:0] - mr &= ~0x03; - mr |= 0x01; - //for >> 200M MR0[4:2] - mr &= ~(0x07 << 2); - mr |= (0x06 << 2); - psramip_w_tx_fifo(0x40150000, mr); - psramip_w_cmd_addr(0x40150000, HAL_PSRAM_CMD_REG_WRITE, 0); - _psram_busy_wait(id); + mr &= 0xff; + mr &= ~(0x03 << 6); // MR[7:6] must set 0 + // driver strength 00:1/16 01:1/2 10:1/4 11:1/8 MR0[1:0] + mr &= ~0x03; + mr |= 0x01; + // for >> 200M MR0[4:2] + mr &= ~(0x07 << 2); + mr |= (0x06 << 2); + psramip_w_tx_fifo(0x40150000, mr); + psramip_w_cmd_addr(0x40150000, HAL_PSRAM_CMD_REG_WRITE, 0); + _psram_busy_wait(id); - //read MR0 again - psramip_w_cmd_addr(0x40150000, HAL_PSRAM_CMD_REG_READ, 0); - while((psramip_r_status(0x40150000)& PSRAM_STAT_BUSY)); - mr = psramip_r_rx_fifo(0x40150000); - mr = psramip_r_rx_fifo(0x40150000); - // hal_uart_printf("count=0x%x mr0 = 0x%x \n", psramip_r_status(0x40150000), mr); - //read MR4 - psramip_w_cmd_addr(0x40150000, HAL_PSRAM_CMD_REG_READ, 4); - _psram_busy_wait(id); - mr = psramip_r_rx_fifo(0x40150000); - mr = psramip_r_rx_fifo(0x40150000); - // hal_uart_printf("mr4 = 0x%x\n", mr); + // read MR0 again + psramip_w_cmd_addr(0x40150000, HAL_PSRAM_CMD_REG_READ, 0); + while ((psramip_r_status(0x40150000) & PSRAM_STAT_BUSY)) + ; + mr = psramip_r_rx_fifo(0x40150000); + mr = psramip_r_rx_fifo(0x40150000); + // hal_uart_printf("count=0x%x mr0 = 0x%x \n", psramip_r_status(0x40150000), + // mr); + // read MR4 + psramip_w_cmd_addr(0x40150000, HAL_PSRAM_CMD_REG_READ, 4); + _psram_busy_wait(id); + mr = psramip_r_rx_fifo(0x40150000); + mr = psramip_r_rx_fifo(0x40150000); + // hal_uart_printf("mr4 = 0x%x\n", mr); - _psram_busy_wait(id); + _psram_busy_wait(id); #endif - hal_sys_timer_delay(MS_TO_TICKS(10)); + hal_sys_timer_delay(MS_TO_TICKS(10)); #else - // open psram phy power - DIGITAL_REG(0x4001f02c) |= (1 << 16); - //init psram - //lp delay - DIGITAL_REG(0x4015001C)=0x3fff3cff;//c - //ramp=1k select low speed - DIGITAL_REG(0x4015002C)=0x0000000c; - //tx/rx Phase - DIGITAL_REG(0x40150024)=0x55000223; + // open psram phy power + DIGITAL_REG(0x4001f02c) |= (1 << 16); + // init psram + // lp delay + DIGITAL_REG(0x4015001C) = 0x3fff3cff; // c + // ramp=1k select low speed + DIGITAL_REG(0x4015002C) = 0x0000000c; + // tx/rx Phase + DIGITAL_REG(0x40150024) = 0x55000223; #endif } -FLASH_TEXT_LOC void hal_psram_wakeup_init(void) -{ +FLASH_TEXT_LOC void hal_psram_wakeup_init(void) { #ifndef PSRAM_LOW_SPEED - // dll - DIGITAL_REG(0x4001f038) = 0x77783533; + // dll + DIGITAL_REG(0x4001f038) = 0x77783533; - DIGITAL_REG(0x4001f03c) = 0x3ffffff4; - DIGITAL_REG(0x4001f03c) |= (1<<1)|(1<<30); - while (((DIGITAL_REG(0x4001f03c)) & (0x1<<30))); - hal_sys_timer_delay(MS_TO_TICKS(10)); - DIGITAL_REG(0x4001f03c) &= ~(1<<0); - while (!((DIGITAL_REG(0x4001f03c)) & (0x1<<0))); - hal_sys_timer_delay(MS_TO_TICKS(10)); + DIGITAL_REG(0x4001f03c) = 0x3ffffff4; + DIGITAL_REG(0x4001f03c) |= (1 << 1) | (1 << 30); + while (((DIGITAL_REG(0x4001f03c)) & (0x1 << 30))) + ; + hal_sys_timer_delay(MS_TO_TICKS(10)); + DIGITAL_REG(0x4001f03c) &= ~(1 << 0); + while (!((DIGITAL_REG(0x4001f03c)) & (0x1 << 0))) + ; + hal_sys_timer_delay(MS_TO_TICKS(10)); - DIGITAL_REG(0x40000090) = 0x0001ffff; - while (!((DIGITAL_REG(0x40000090)) & (0x1<<20))); - hal_sys_timer_delay(MS_TO_TICKS(10)); + DIGITAL_REG(0x40000090) = 0x0001ffff; + while (!((DIGITAL_REG(0x40000090)) & (0x1 << 20))) + ; + hal_sys_timer_delay(MS_TO_TICKS(10)); #endif - hal_psram_resume(HAL_PSRAM_ID_0); + hal_psram_resume(HAL_PSRAM_ID_0); } -FLASH_TEXT_LOC void hal_psram_sleep(void) -{ +FLASH_TEXT_LOC void hal_psram_sleep(void) { #ifndef PSRAM_LOW_SPEED - hal_psram_suspend(HAL_PSRAM_ID_0); - /* dll power off */ - DIGITAL_REG(0x4001f03c) &= ~(1 << 1); - /* phy power off */ - /* DIGITAL_REG(0x4001f02c) &= ~(1 << 16) */ + hal_psram_suspend(HAL_PSRAM_ID_0); + /* dll power off */ + DIGITAL_REG(0x4001f03c) &= ~(1 << 1); + /* phy power off */ + /* DIGITAL_REG(0x4001f02c) &= ~(1 << 16) */ #endif } #endif -FLASH_TEXT_LOC void hal_psram_wakeup(void) -{ +FLASH_TEXT_LOC void hal_psram_wakeup(void) { #ifndef PSRAM_LOW_SPEED - hal_psram_wakeup_init(); + hal_psram_wakeup_init(); #endif } diff --git a/platform/hal/hal_psram_v2.c b/platform/hal/hal_psram_v2.c index 76a39ba..34babdc 100644 --- a/platform/hal/hal_psram_v2.c +++ b/platform/hal/hal_psram_v2.c @@ -15,13 +15,13 @@ ****************************************************************************/ #if defined(CHIP_HAS_PSRAM) && (CHIP_PSRAM_CTRL_VER >= 2) -#include "plat_types.h" -#include "plat_addr_map.h" +#include "hal_cache.h" #include "hal_location.h" #include "hal_psram.h" #include "hal_timer.h" #include "hal_trace.h" -#include "hal_cache.h" +#include "plat_addr_map.h" +#include "plat_types.h" #include "pmu.h" #include "reg_psram_mc_v2.h" #include "reg_psram_phy_v2.h" @@ -44,674 +44,672 @@ #define PSRAM_TRACENOCRLF_NOTS(...) #endif -#define TX_FIFO_DEPTH 8 -#define RX_FIFO_DEPTH 8 +#define TX_FIFO_DEPTH 8 +#define RX_FIFO_DEPTH 8 // MR0 -#define MR0_DRIVE_STR_SHIFT 0 -#define MR0_DRIVE_STR_MASK (0x3 << MR0_DRIVE_STR_SHIFT) -#define MR0_DRIVE_STR(n) BITFIELD_VAL(MR0_DRIVE_STR, n) -#define MR0_READ_LATENCY_SHIFT 2 -#define MR0_READ_LATENCY_MASK (0x7 << MR0_READ_LATENCY_SHIFT) -#define MR0_READ_LATENCY(n) BITFIELD_VAL(MR0_READ_LATENCY, n) -#define MR0_LT (1 << 5) -#define MR0_FIXED_00_SHIFT 6 -#define MR0_FIXED_00_MASK (0x3 << MR0_FIXED_00_SHIFT) -#define MR0_FIXED_00(n) BITFIELD_VAL(MR0_FIXED_00, n) +#define MR0_DRIVE_STR_SHIFT 0 +#define MR0_DRIVE_STR_MASK (0x3 << MR0_DRIVE_STR_SHIFT) +#define MR0_DRIVE_STR(n) BITFIELD_VAL(MR0_DRIVE_STR, n) +#define MR0_READ_LATENCY_SHIFT 2 +#define MR0_READ_LATENCY_MASK (0x7 << MR0_READ_LATENCY_SHIFT) +#define MR0_READ_LATENCY(n) BITFIELD_VAL(MR0_READ_LATENCY, n) +#define MR0_LT (1 << 5) +#define MR0_FIXED_00_SHIFT 6 +#define MR0_FIXED_00_MASK (0x3 << MR0_FIXED_00_SHIFT) +#define MR0_FIXED_00(n) BITFIELD_VAL(MR0_FIXED_00, n) // MR1 -#define MR1_VENDOR_ID_SHIFT 0 -#define MR1_VENDOR_ID_MASK (0x1F << MR1_VENDOR_ID_SHIFT) -#define MR1_VENDOR_ID(n) BITFIELD_VAL(MR1_VENDOR_ID, n) -#define MR1_DENSITY_SHIFT 5 -#define MR1_DENSITY_MASK (0x3 << MR1_DENSITY_SHIFT) -#define MR1_DENSITY(n) BITFIELD_VAL(MR1_DENSITY, n) -#define MR1_ULP (1 << 7) +#define MR1_VENDOR_ID_SHIFT 0 +#define MR1_VENDOR_ID_MASK (0x1F << MR1_VENDOR_ID_SHIFT) +#define MR1_VENDOR_ID(n) BITFIELD_VAL(MR1_VENDOR_ID, n) +#define MR1_DENSITY_SHIFT 5 +#define MR1_DENSITY_MASK (0x3 << MR1_DENSITY_SHIFT) +#define MR1_DENSITY(n) BITFIELD_VAL(MR1_DENSITY, n) +#define MR1_ULP (1 << 7) // MR2 -#define MR2_VENDOR_ID_SHIFT 0 -#define MR2_VENDOR_ID_MASK (0x7 << MR2_VENDOR_ID_SHIFT) -#define MR2_VENDOR_ID(n) BITFIELD_VAL(MR2_VENDOR_ID, n) -#define MR2_DEV_ID_SHIFT 3 -#define MR2_DEV_ID_MASK (0x3 << MR2_DEV_ID_SHIFT) -#define MR2_DEV_ID(n) BITFIELD_VAL(MR2_DEV_ID, n) -#define MR2_RSVD (1 << 5) -#define MR2_FIXED_1 (1 << 6) -#define MR2_GB (1 << 7) +#define MR2_VENDOR_ID_SHIFT 0 +#define MR2_VENDOR_ID_MASK (0x7 << MR2_VENDOR_ID_SHIFT) +#define MR2_VENDOR_ID(n) BITFIELD_VAL(MR2_VENDOR_ID, n) +#define MR2_DEV_ID_SHIFT 3 +#define MR2_DEV_ID_MASK (0x3 << MR2_DEV_ID_SHIFT) +#define MR2_DEV_ID(n) BITFIELD_VAL(MR2_DEV_ID, n) +#define MR2_RSVD (1 << 5) +#define MR2_FIXED_1 (1 << 6) +#define MR2_GB (1 << 7) // MR4 -#define MR4_PASR_SHIFT 0 -#define MR4_PASR_MASK (0x7 << MR4_PASR_SHIFT) -#define MR4_PASR(n) BITFIELD_VAL(MR4_PASR, n) -#define MR4_RF (1 << 3) -#define MR4_FIXED_0 (1 << 4) -#define MR4_WRITE_LATENCY_SHIFT 5 -#define MR4_WRITE_LATENCY_MASK (0x7 << MR4_WRITE_LATENCY_SHIFT) -#define MR4_WRITE_LATENCY(n) BITFIELD_VAL(MR4_WRITE_LATENCY, n) +#define MR4_PASR_SHIFT 0 +#define MR4_PASR_MASK (0x7 << MR4_PASR_SHIFT) +#define MR4_PASR(n) BITFIELD_VAL(MR4_PASR, n) +#define MR4_RF (1 << 3) +#define MR4_FIXED_0 (1 << 4) +#define MR4_WRITE_LATENCY_SHIFT 5 +#define MR4_WRITE_LATENCY_MASK (0x7 << MR4_WRITE_LATENCY_SHIFT) +#define MR4_WRITE_LATENCY(n) BITFIELD_VAL(MR4_WRITE_LATENCY, n) // MR6 -#define MR6_RSVD_SHIFT 0 -#define MR6_RSVD_MASK (0xF << MR6_RSVD_SHIFT) -#define MR6_RSVD(n) BITFIELD_VAL(MR6_RSVD, n) -#define MR6_HALF_SLEEP_SHIFT 4 -#define MR6_HALF_SLEEP_MASK (0xF << MR6_HALF_SLEEP_SHIFT) -#define MR6_HALF_SLEEP(n) BITFIELD_VAL(MR6_HALF_SLEEP, n) +#define MR6_RSVD_SHIFT 0 +#define MR6_RSVD_MASK (0xF << MR6_RSVD_SHIFT) +#define MR6_RSVD(n) BITFIELD_VAL(MR6_RSVD, n) +#define MR6_HALF_SLEEP_SHIFT 4 +#define MR6_HALF_SLEEP_MASK (0xF << MR6_HALF_SLEEP_SHIFT) +#define MR6_HALF_SLEEP(n) BITFIELD_VAL(MR6_HALF_SLEEP, n) // MR8 -#define MR8_BL_SHIFT 0 -#define MR8_BL_MASK (0x3 << MR8_BL_SHIFT) -#define MR8_BL(n) BITFIELD_VAL(MR8_BL, n) -#define MR8_BT (1 << 2) -#define MR8_FIXED_0 (1 << 3) -#define MR8_RSVD_SHIFT 4 -#define MR8_RSVD_MASK (0x7 << MR8_RSVD_SHIFT) -#define MR8_RSVD(n) BITFIELD_VAL(MR8_RSVD, n) -#define MR8_FIXED_00 (1 << 7) +#define MR8_BL_SHIFT 0 +#define MR8_BL_MASK (0x3 << MR8_BL_SHIFT) +#define MR8_BL(n) BITFIELD_VAL(MR8_BL, n) +#define MR8_BT (1 << 2) +#define MR8_FIXED_0 (1 << 3) +#define MR8_RSVD_SHIFT 4 +#define MR8_RSVD_MASK (0x7 << MR8_RSVD_SHIFT) +#define MR8_RSVD(n) BITFIELD_VAL(MR8_RSVD, n) +#define MR8_FIXED_00 (1 << 7) enum PSRAM_CMD_T { - PSRAM_CMD_SYNC_READ = 0x00, - PSRAM_CMD_SYNC_WRITE = 0x80, - PSRAM_CMD_4BYTE_READ = 0x3F, - PSRAM_CMD_4BYTE_WRITE = 0xBF, - PSRAM_CMD_REG_READ = 0x40, - PSRAM_CMD_REG_WRITE = 0xC0, - PSRAM_CMD_GLOBAL_RESET = 0xFF, + PSRAM_CMD_SYNC_READ = 0x00, + PSRAM_CMD_SYNC_WRITE = 0x80, + PSRAM_CMD_4BYTE_READ = 0x3F, + PSRAM_CMD_4BYTE_WRITE = 0xBF, + PSRAM_CMD_REG_READ = 0x40, + PSRAM_CMD_REG_WRITE = 0xC0, + PSRAM_CMD_GLOBAL_RESET = 0xFF, }; enum CP_FSM_STATE_T { - CP_FSM_STATE_SELF_REFRESH = 1, - CP_FSM_STATE_PD = 2, - CP_FSM_STATE_READY = 4, + CP_FSM_STATE_SELF_REFRESH = 1, + CP_FSM_STATE_PD = 2, + CP_FSM_STATE_READY = 4, }; enum MEMIF_CMD_T { - MEMIF_NO_CMD = 0x00, - MEMIF_WRITE = 0x01, - MEMIF_READ = 0x02, - MEMIF_MRS = 0x05, - MEMIF_MRR = 0x06, - MEMIF_REF = 0x08, - MEMIF_SREF = 0x09, - MEMIF_PD = 0x10, - MEMIF_NOP = 0x20, - MEMIF_RST = 0xFF, - MEMIF_ZQCL = 0x85, - MEMIF_ZQCS = 0x45, - MEMIF_ZQCRST = 0x25, - MEMIF_START_CLOCK = 0x40, - MEMIF_STOP_CLOCK = 0x80, - MEMIF_NEW_CMD = 0x7F, + MEMIF_NO_CMD = 0x00, + MEMIF_WRITE = 0x01, + MEMIF_READ = 0x02, + MEMIF_MRS = 0x05, + MEMIF_MRR = 0x06, + MEMIF_REF = 0x08, + MEMIF_SREF = 0x09, + MEMIF_PD = 0x10, + MEMIF_NOP = 0x20, + MEMIF_RST = 0xFF, + MEMIF_ZQCL = 0x85, + MEMIF_ZQCS = 0x45, + MEMIF_ZQCRST = 0x25, + MEMIF_START_CLOCK = 0x40, + MEMIF_STOP_CLOCK = 0x80, + MEMIF_NEW_CMD = 0x7F, }; -static struct PSRAM_MC_T * const psram_mc = (struct PSRAM_MC_T *)PSRAM_CTRL_BASE; -static struct PSRAM_PHY_T * const psram_phy = (struct PSRAM_PHY_T *)(PSRAM_CTRL_BASE + 0x8000); +static struct PSRAM_MC_T *const psram_mc = (struct PSRAM_MC_T *)PSRAM_CTRL_BASE; +static struct PSRAM_PHY_T *const psram_phy = + (struct PSRAM_PHY_T *)(PSRAM_CTRL_BASE + 0x8000); -static const uint32_t psram_cfg_clk = 48*1000*1000; +static const uint32_t psram_cfg_clk = 48 * 1000 * 1000; #if (PSRAM_SPEED != 0) -static const uint32_t psram_run_clk = PSRAM_SPEED*1000*1000; +static const uint32_t psram_run_clk = PSRAM_SPEED * 1000 * 1000; #else #error "invalid PSRAMUHS_SPEED" #endif static void psram_chip_timing_config(uint32_t clk, bool psram_first); -int hal_psramip_mc_busy(void) -{ - return !!(psram_mc->REG_404 & PSRAM_ULP_MC_BUSY); +int hal_psramip_mc_busy(void) { + return !!(psram_mc->REG_404 & PSRAM_ULP_MC_BUSY); } -static int hal_psramip_wb_busy(void) -{ - return !!(psram_mc->REG_404 & PSRAM_ULP_MC_WB_FILL_LEVEL_MASK); +static int hal_psramip_wb_busy(void) { + return !!(psram_mc->REG_404 & PSRAM_ULP_MC_WB_FILL_LEVEL_MASK); } -int hal_psramip_mc_in_sleep(void) -{ - return GET_BITFIELD(psram_mc->REG_404, PSRAM_ULP_MC_CP_FSM_STATE) == CP_FSM_STATE_PD; +int hal_psramip_mc_in_sleep(void) { + return GET_BITFIELD(psram_mc->REG_404, PSRAM_ULP_MC_CP_FSM_STATE) == + CP_FSM_STATE_PD; } -int hal_psramip_rx_fifo_empty(void) -{ - return !!(psram_mc->REG_404 & PSRAM_ULP_MC_MGR_RXFIFO_R_EMPTY); +int hal_psramip_rx_fifo_empty(void) { + return !!(psram_mc->REG_404 & PSRAM_ULP_MC_MGR_RXFIFO_R_EMPTY); } -int hal_psramip_tx_fifo_full(void) -{ - return !!(psram_mc->REG_404 & PSRAM_ULP_MC_MGR_TXFIFO_W_FULL); +int hal_psramip_tx_fifo_full(void) { + return !!(psram_mc->REG_404 & PSRAM_ULP_MC_MGR_TXFIFO_W_FULL); } -uint32_t hal_psramip_get_rx_fifo_len(void) -{ - return GET_BITFIELD(psram_mc->REG_404, PSRAM_ULP_MC_MGR_RXFIFO_FULL_CNT); +uint32_t hal_psramip_get_rx_fifo_len(void) { + return GET_BITFIELD(psram_mc->REG_404, PSRAM_ULP_MC_MGR_RXFIFO_FULL_CNT); } -uint32_t hal_psramip_get_tx_fifo_free_len(void) -{ - return GET_BITFIELD(psram_mc->REG_404, PSRAM_ULP_MC_MGR_TXFIFO_EMPTY_CNT); +uint32_t hal_psramip_get_tx_fifo_free_len(void) { + return GET_BITFIELD(psram_mc->REG_404, PSRAM_ULP_MC_MGR_TXFIFO_EMPTY_CNT); } -void hal_psramip_mc_busy_wait(void) -{ - while (hal_psramip_mc_busy()); +void hal_psramip_mc_busy_wait(void) { + while (hal_psramip_mc_busy()) + ; } -void hal_psramip_wb_busy_wait(void) -{ - while (hal_psramip_wb_busy()); +void hal_psramip_wb_busy_wait(void) { + while (hal_psramip_wb_busy()) + ; } -void hal_psramip_flush_tx_fifo(void) -{ - hal_psramip_mc_busy_wait(); - psram_mc->REG_01C = PSRAM_ULP_MC_MGR_TX_FIFO_CLR; - hal_psramip_mc_busy_wait(); +void hal_psramip_flush_tx_fifo(void) { + hal_psramip_mc_busy_wait(); + psram_mc->REG_01C = PSRAM_ULP_MC_MGR_TX_FIFO_CLR; + hal_psramip_mc_busy_wait(); } -void hal_psramip_flush_rx_fifo(void) -{ - hal_psramip_mc_busy_wait(); - psram_mc->REG_01C = PSRAM_ULP_MC_MGR_RX_FIFO_CLR; - hal_psramip_mc_busy_wait(); +void hal_psramip_flush_rx_fifo(void) { + hal_psramip_mc_busy_wait(); + psram_mc->REG_01C = PSRAM_ULP_MC_MGR_RX_FIFO_CLR; + hal_psramip_mc_busy_wait(); } -void hal_psramip_flush_all_fifo(void) -{ - hal_psramip_mc_busy_wait(); - psram_mc->REG_01C = PSRAM_ULP_MC_MGR_TX_FIFO_CLR | PSRAM_ULP_MC_MGR_RX_FIFO_CLR; - hal_psramip_mc_busy_wait(); +void hal_psramip_flush_all_fifo(void) { + hal_psramip_mc_busy_wait(); + psram_mc->REG_01C = + PSRAM_ULP_MC_MGR_TX_FIFO_CLR | PSRAM_ULP_MC_MGR_RX_FIFO_CLR; + hal_psramip_mc_busy_wait(); } -void hal_psramip_xfer_addr_len(uint32_t addr, uint32_t len) -{ - psram_mc->REG_008 = addr; - psram_mc->REG_00C = len; +void hal_psramip_xfer_addr_len(uint32_t addr, uint32_t len) { + psram_mc->REG_008 = addr; + psram_mc->REG_00C = len; } -void hal_psramip_write_fifo(uint32_t *data, uint32_t len) -{ - for (int i = 0; i < len; i++) { - psram_mc->REG_014 = *data++; - } +void hal_psramip_write_fifo(uint32_t *data, uint32_t len) { + for (int i = 0; i < len; i++) { + psram_mc->REG_014 = *data++; + } } -void hal_psramip_read_fifo(uint32_t *data, uint32_t len) -{ - for (int i = 0; i < len; i++) { - *data++ = psram_mc->REG_018; - } +void hal_psramip_read_fifo(uint32_t *data, uint32_t len) { + for (int i = 0; i < len; i++) { + *data++ = psram_mc->REG_018; + } } -void hal_psramip_set_reg_data_mask(void) -{ +void hal_psramip_set_reg_data_mask(void) { #ifdef PSRAM_DUAL_8BIT - psram_mc->REG_010 = 0xFC; + psram_mc->REG_010 = 0xFC; #else - psram_mc->REG_010 = 0xFE; + psram_mc->REG_010 = 0xFE; #endif } -void hal_psramip_set_mem_data_mask(void) -{ - psram_mc->REG_010 = 0; +void hal_psramip_set_mem_data_mask(void) { psram_mc->REG_010 = 0; } + +void hal_psramip_set_cmd(enum MEMIF_CMD_T cmd) { psram_mc->REG_004 = cmd; } + +POSSIBLY_UNUSED void psram_read_reg(uint32_t reg, uint32_t *val) { + hal_psramip_flush_all_fifo(); + hal_psramip_xfer_addr_len(reg, 1); + hal_psramip_set_cmd(MEMIF_MRR); + while (hal_psramip_rx_fifo_empty()) + ; + hal_psramip_read_fifo(val, 1); } -void hal_psramip_set_cmd(enum MEMIF_CMD_T cmd) -{ - psram_mc->REG_004 = cmd; -} - -POSSIBLY_UNUSED void psram_read_reg(uint32_t reg, uint32_t *val) -{ - hal_psramip_flush_all_fifo(); - hal_psramip_xfer_addr_len(reg, 1); - hal_psramip_set_cmd(MEMIF_MRR); - while (hal_psramip_rx_fifo_empty()); - hal_psramip_read_fifo(val, 1); -} - -static void psram_send_cmd_reg(enum MEMIF_CMD_T cmd, uint32_t reg, uint32_t val) -{ +static void psram_send_cmd_reg(enum MEMIF_CMD_T cmd, uint32_t reg, + uint32_t val) { #ifdef PSRAM_DUAL_8BIT - val &= 0xFF; - val |= (val << 8); + val &= 0xFF; + val |= (val << 8); #endif - hal_psramip_flush_all_fifo(); - //hal_psramip_set_reg_data_mask(); - hal_psramip_write_fifo(&val, 1); - hal_psramip_xfer_addr_len(reg, 1); - hal_psramip_set_cmd(cmd); - while (hal_psramip_get_tx_fifo_free_len() != TX_FIFO_DEPTH); - hal_psramip_mc_busy_wait(); - //hal_psramip_set_mem_data_mask(); + hal_psramip_flush_all_fifo(); + // hal_psramip_set_reg_data_mask(); + hal_psramip_write_fifo(&val, 1); + hal_psramip_xfer_addr_len(reg, 1); + hal_psramip_set_cmd(cmd); + while (hal_psramip_get_tx_fifo_free_len() != TX_FIFO_DEPTH) + ; + hal_psramip_mc_busy_wait(); + // hal_psramip_set_mem_data_mask(); } -static void psram_write_reg(uint32_t reg, uint32_t val) -{ - psram_send_cmd_reg(MEMIF_MRS, reg, val); +static void psram_write_reg(uint32_t reg, uint32_t val) { + psram_send_cmd_reg(MEMIF_MRS, reg, val); } -static void psram_single_cmd(enum MEMIF_CMD_T cmd) -{ - hal_psramip_flush_all_fifo(); - hal_psramip_set_cmd(cmd); - hal_psramip_mc_busy_wait(); +static void psram_single_cmd(enum MEMIF_CMD_T cmd) { + hal_psramip_flush_all_fifo(); + hal_psramip_set_cmd(cmd); + hal_psramip_mc_busy_wait(); } -static POSSIBLY_UNUSED void psram_reset(void) -{ - psram_single_cmd(MEMIF_RST); -} +static POSSIBLY_UNUSED void psram_reset(void) { psram_single_cmd(MEMIF_RST); } -static void psram_set_timing(uint32_t clk) -{ - uint32_t reg; - uint32_t val; +static void psram_set_timing(uint32_t clk) { + uint32_t reg; + uint32_t val; #if PSRAMSIZE == 0x800000 - reg = 8; + reg = 8; #ifdef PSRAM_WRAP_ENABLE - // Wrap 32 - val = MR8_BL(1); + // Wrap 32 + val = MR8_BL(1); #else - // Wrap 1k - val = MR8_BL(0x3); + // Wrap 1k + val = MR8_BL(0x3); #endif - psram_write_reg(reg, val); + psram_write_reg(reg, val); #endif - reg = 0; - if (clk <= 66000000) { - val = 2; - } else if (clk <= 109000000) { - val = 3; - } else if (clk <= 133000000) { - val = 4; - } else if (clk <= 166000000) { - val = 5; - } else { - val = 6; - } - // Latency type: Variable - val = MR0_DRIVE_STR(3) | MR0_READ_LATENCY(val); - psram_write_reg(reg, val); - - reg = 4; - if (clk <= 166000000) { - val = 0; - } else { - val = 4; - } - //Fast Refresh, - val = MR4_PASR(0) | MR4_WRITE_LATENCY(val); - psram_write_reg(reg, val); -} - -static void hal_psram_phy_dll_config(uint32_t clk) -{ - uint32_t phy_clk; - uint32_t range; - uint32_t val; - - val = psram_phy->REG_050; - val &= ~PSRAM_ULP_PHY_REG_DLL_RESETB | PSRAM_ULP_PHY_REG_DLL_CK_RDY; - psram_phy->REG_050 = val; - phy_clk = clk; - if (phy_clk <= 100000000 / 2) { - range = 3; - } else if (phy_clk <= 150000000 / 2) { - range = 2; - } else if (phy_clk <= 300000000 / 2) { - range = 1; - } else { - range = 0; - } - val = SET_BITFIELD(val, PSRAM_ULP_PHY_REG_DLL_RANGE, range); - psram_phy->REG_050 = val; - val |= PSRAM_ULP_PHY_REG_DLL_RESETB | PSRAM_ULP_PHY_REG_DLL_CK_RDY; - psram_phy->REG_050 = val; -} - -static void hal_psram_phy_init(uint32_t clk) -{ - uint32_t val; - val = psram_phy->REG_048; - val |= PSRAM_ULP_PHY_REG_LDO_PU | PSRAM_ULP_PHY_REG_LDO_PRECHARGE; - psram_phy->REG_048 = val; - hal_sys_timer_delay_us(10); - - val &= ~PSRAM_ULP_PHY_REG_LDO_PRECHARGE; - val = SET_BITFIELD(val, PSRAM_ULP_PHY_REG_LDO_IEN1, 0xc); - val = SET_BITFIELD(val, PSRAM_ULP_PHY_REG_LDO_IEN2, 0x5); - val = SET_BITFIELD(val, PSRAM_ULP_PHY_REG_LDO_VTUNE, 0x0); - psram_phy->REG_048 = val; - - val = psram_phy->REG_04C; - val |= PSRAM_ULP_PHY_REG_PSRAM_PU; - val = SET_BITFIELD(val, PSRAM_ULP_PHY_REG_PSRAM_SWRC, 0x3); - val = SET_BITFIELD(val, PSRAM_ULP_PHY_REG_PSRAM_TXDRV, 0x3); - psram_phy->REG_04C = val; - - val = psram_phy->REG_050; - val |= PSRAM_ULP_PHY_REG_DLL_PU; - //val = SET_BITFIELD(val, PSRAM_ULP_PHY_REG_DLL_SWRC, 0x3); - psram_phy->REG_050 = val; - hal_sys_timer_delay_us(2); - - val |= PSRAM_ULP_PHY_REG_DLL_RESETB; - psram_phy->REG_050 = val; - hal_sys_timer_delay_us(20); - - hal_psram_phy_dll_config(clk); -} - -static void hal_psram_mc_set_timing(uint32_t clk) -{ - uint32_t val; - - if (clk <= 166000000) { - val = PSRAM_ULP_MC_WRITE_LATENCY(0); - } else { - val = PSRAM_ULP_MC_WRITE_LATENCY(2); - } - psram_mc->REG_028 = val; -#if (CHIP_PSRAM_CTRL_VER == 2) - if (clk <= 66000000) { - val = PSRAM_ULP_MC_READ_LATENCY(2); - } else if (clk <= 109000000) { - val = PSRAM_ULP_MC_READ_LATENCY(3); - } else if (clk <= 133000000) { - val = PSRAM_ULP_MC_READ_LATENCY(4); - } else if (clk <= 166000000) { - val = PSRAM_ULP_MC_READ_LATENCY(5); - } else { - val = PSRAM_ULP_MC_READ_LATENCY(6); - } - psram_mc->REG_02C = val; -#else - // Min latency: 2 cycles - psram_mc->REG_02C = PSRAM_ULP_MC_READ_LATENCY(2); -#endif - // tRC >= 55 ns - val = (clk / 1000000 * 55 + (1000 - 1)) / 1000; - psram_mc->REG_050 = PSRAM_ULP_MC_T_RC(val); + reg = 0; + if (clk <= 66000000) { val = 2; - psram_mc->REG_058 = PSRAM_ULP_MC_T_CPHR(val); - psram_mc->REG_068 = PSRAM_ULP_MC_T_MRR(val); + } else if (clk <= 109000000) { + val = 3; + } else if (clk <= 133000000) { + val = 4; + } else if (clk <= 166000000) { + val = 5; + } else { val = 6; - psram_mc->REG_060 = PSRAM_ULP_MC_T_CPHW(val); + } + // Latency type: Variable + val = MR0_DRIVE_STR(3) | MR0_READ_LATENCY(val); + psram_write_reg(reg, val); + + reg = 4; + if (clk <= 166000000) { + val = 0; + } else { + val = 4; + } + // Fast Refresh, + val = MR4_PASR(0) | MR4_WRITE_LATENCY(val); + psram_write_reg(reg, val); +} + +static void hal_psram_phy_dll_config(uint32_t clk) { + uint32_t phy_clk; + uint32_t range; + uint32_t val; + + val = psram_phy->REG_050; + val &= ~PSRAM_ULP_PHY_REG_DLL_RESETB | PSRAM_ULP_PHY_REG_DLL_CK_RDY; + psram_phy->REG_050 = val; + phy_clk = clk; + if (phy_clk <= 100000000 / 2) { + range = 3; + } else if (phy_clk <= 150000000 / 2) { + range = 2; + } else if (phy_clk <= 300000000 / 2) { + range = 1; + } else { + range = 0; + } + val = SET_BITFIELD(val, PSRAM_ULP_PHY_REG_DLL_RANGE, range); + psram_phy->REG_050 = val; + val |= PSRAM_ULP_PHY_REG_DLL_RESETB | PSRAM_ULP_PHY_REG_DLL_CK_RDY; + psram_phy->REG_050 = val; +} + +static void hal_psram_phy_init(uint32_t clk) { + uint32_t val; + val = psram_phy->REG_048; + val |= PSRAM_ULP_PHY_REG_LDO_PU | PSRAM_ULP_PHY_REG_LDO_PRECHARGE; + psram_phy->REG_048 = val; + hal_sys_timer_delay_us(10); + + val &= ~PSRAM_ULP_PHY_REG_LDO_PRECHARGE; + val = SET_BITFIELD(val, PSRAM_ULP_PHY_REG_LDO_IEN1, 0xc); + val = SET_BITFIELD(val, PSRAM_ULP_PHY_REG_LDO_IEN2, 0x5); + val = SET_BITFIELD(val, PSRAM_ULP_PHY_REG_LDO_VTUNE, 0x0); + psram_phy->REG_048 = val; + + val = psram_phy->REG_04C; + val |= PSRAM_ULP_PHY_REG_PSRAM_PU; + val = SET_BITFIELD(val, PSRAM_ULP_PHY_REG_PSRAM_SWRC, 0x3); + val = SET_BITFIELD(val, PSRAM_ULP_PHY_REG_PSRAM_TXDRV, 0x3); + psram_phy->REG_04C = val; + + val = psram_phy->REG_050; + val |= PSRAM_ULP_PHY_REG_DLL_PU; + // val = SET_BITFIELD(val, PSRAM_ULP_PHY_REG_DLL_SWRC, 0x3); + psram_phy->REG_050 = val; + hal_sys_timer_delay_us(2); + + val |= PSRAM_ULP_PHY_REG_DLL_RESETB; + psram_phy->REG_050 = val; + hal_sys_timer_delay_us(20); + + hal_psram_phy_dll_config(clk); +} + +static void hal_psram_mc_set_timing(uint32_t clk) { + uint32_t val; + + if (clk <= 166000000) { + val = PSRAM_ULP_MC_WRITE_LATENCY(0); + } else { + val = PSRAM_ULP_MC_WRITE_LATENCY(2); + } + psram_mc->REG_028 = val; +#if (CHIP_PSRAM_CTRL_VER == 2) + if (clk <= 66000000) { + val = PSRAM_ULP_MC_READ_LATENCY(2); + } else if (clk <= 109000000) { + val = PSRAM_ULP_MC_READ_LATENCY(3); + } else if (clk <= 133000000) { + val = PSRAM_ULP_MC_READ_LATENCY(4); + } else if (clk <= 166000000) { + val = PSRAM_ULP_MC_READ_LATENCY(5); + } else { + val = PSRAM_ULP_MC_READ_LATENCY(6); + } + psram_mc->REG_02C = val; +#else + // Min latency: 2 cycles + psram_mc->REG_02C = PSRAM_ULP_MC_READ_LATENCY(2); +#endif + // tRC >= 55 ns + val = (clk / 1000000 * 55 + (1000 - 1)) / 1000; + psram_mc->REG_050 = PSRAM_ULP_MC_T_RC(val); + val = 2; + psram_mc->REG_058 = PSRAM_ULP_MC_T_CPHR(val); + psram_mc->REG_068 = PSRAM_ULP_MC_T_MRR(val); + val = 6; + psram_mc->REG_060 = PSRAM_ULP_MC_T_CPHW(val); #ifdef CHIP_BEST2001 - val += 1; + val += 1; #endif - psram_mc->REG_06C = PSRAM_ULP_MC_T_MRS(val); - // tCEM <= 2.5 us - val = clk / 1000000 * 25 / 10; - psram_mc->REG_070 = PSRAM_ULP_MC_T_CEM(val); - // tRST >= 2 us - val = clk / 1000000 * 2 + 1; - psram_mc->REG_074 = PSRAM_ULP_MC_T_RST(val); - // tHS >= 4 us - val = clk / 1000000 * 4 + 1; - psram_mc->REG_080 = PSRAM_ULP_MC_T_HS(val); - // tXPHS in [60 ns, 4 us] - val = (clk / 1000000 * 60 + (1000 - 1)) / 1000; - psram_mc->REG_084 = PSRAM_ULP_MC_T_XPHS(val); - // tXHS >= 70 us - val = clk / 1000000 * 70 + 1; - psram_mc->REG_088 = PSRAM_ULP_MC_T_XHS(val); - psram_mc->REG_09C = PSRAM_ULP_MC_WR_DMY_CYC(1); - // NOP dummy cycles, same as tXPHS in [60 ns, 4 us] - val = (clk / 1000000 * 60 + (1000 - 1)) / 1000; - psram_mc->REG_0A0 = PSRAM_ULP_MC_STOP_CLK_IN_NOP | PSRAM_ULP_MC_NOP_DMY_CYC(val); - psram_mc->REG_0A4 = PSRAM_ULP_MC_QUEUE_IDLE_CYCLE(5000); + psram_mc->REG_06C = PSRAM_ULP_MC_T_MRS(val); + // tCEM <= 2.5 us + val = clk / 1000000 * 25 / 10; + psram_mc->REG_070 = PSRAM_ULP_MC_T_CEM(val); + // tRST >= 2 us + val = clk / 1000000 * 2 + 1; + psram_mc->REG_074 = PSRAM_ULP_MC_T_RST(val); + // tHS >= 4 us + val = clk / 1000000 * 4 + 1; + psram_mc->REG_080 = PSRAM_ULP_MC_T_HS(val); + // tXPHS in [60 ns, 4 us] + val = (clk / 1000000 * 60 + (1000 - 1)) / 1000; + psram_mc->REG_084 = PSRAM_ULP_MC_T_XPHS(val); + // tXHS >= 70 us + val = clk / 1000000 * 70 + 1; + psram_mc->REG_088 = PSRAM_ULP_MC_T_XHS(val); + psram_mc->REG_09C = PSRAM_ULP_MC_WR_DMY_CYC(1); + // NOP dummy cycles, same as tXPHS in [60 ns, 4 us] + val = (clk / 1000000 * 60 + (1000 - 1)) / 1000; + psram_mc->REG_0A0 = + PSRAM_ULP_MC_STOP_CLK_IN_NOP | PSRAM_ULP_MC_NOP_DMY_CYC(val); + psram_mc->REG_0A4 = PSRAM_ULP_MC_QUEUE_IDLE_CYCLE(5000); } -static void hal_psram_init_calib(void) -{ - uint32_t delay; +static void hal_psram_init_calib(void) { + uint32_t delay; - while ((psram_phy->REG_058 & PSRAM_ULP_PHY_DLL_LOCK) == 0); + while ((psram_phy->REG_058 & PSRAM_ULP_PHY_DLL_LOCK) == 0) + ; - delay = GET_BITFIELD(psram_phy->REG_058, PSRAM_ULP_PHY_DLL_DLY_IN); - //ASSERT(delay < (PSRAM_ULP_PHY_DLL_DLY_IN_MASK >> PSRAM_ULP_PHY_DLL_DLY_IN_SHIFT), - // "%s: Bad DLL_DLY_IN=0x%X reg=0x%08X", __func__, delay, psram_phy->REG_058); + delay = GET_BITFIELD(psram_phy->REG_058, PSRAM_ULP_PHY_DLL_DLY_IN); + // ASSERT(delay < (PSRAM_ULP_PHY_DLL_DLY_IN_MASK >> + // PSRAM_ULP_PHY_DLL_DLY_IN_SHIFT), + // "%s: Bad DLL_DLY_IN=0x%X reg=0x%08X", __func__, delay, + // psram_phy->REG_058); - delay /= 2; - psram_phy->REG_054 = PSRAM_ULP_PHY_REG_PSRAM_TX_CEB_DLY(delay) | PSRAM_ULP_PHY_REG_PSRAM_TX_CLK_DLY(delay) | - PSRAM_ULP_PHY_REG_PSRAM_TX_DQS_DLY(delay) | PSRAM_ULP_PHY_REG_PSRAM_RX_DQS_DLY(delay); + delay /= 2; + psram_phy->REG_054 = PSRAM_ULP_PHY_REG_PSRAM_TX_CEB_DLY(delay) | + PSRAM_ULP_PHY_REG_PSRAM_TX_CLK_DLY(delay) | + PSRAM_ULP_PHY_REG_PSRAM_TX_DQS_DLY(delay) | + PSRAM_ULP_PHY_REG_PSRAM_RX_DQS_DLY(delay); } -static void hal_psram_mc_init(uint32_t clk) -{ +static void hal_psram_mc_init(uint32_t clk) { #ifdef PSRAM_DUAL_8BIT - psram_mc->REG_000 = PSRAM_ULP_MC_CHIP_BIT; + psram_mc->REG_000 = PSRAM_ULP_MC_CHIP_BIT; #else - psram_mc->REG_000 = 0; + psram_mc->REG_000 = 0; #endif - psram_mc->REG_020 = 0; - psram_mc->REG_024 = + psram_mc->REG_020 = 0; + psram_mc->REG_024 = #ifndef CHIP_BEST2001 - PSRAM_ULP_MC_ENTRY_SLEEP_IDLE | + PSRAM_ULP_MC_ENTRY_SLEEP_IDLE | #endif - PSRAM_ULP_MC_AUTOWAKEUP_EN | - PSRAM_ULP_MC_PD_MR(6) | PSRAM_ULP_MC_PD_CMD(0xF0); + PSRAM_ULP_MC_AUTOWAKEUP_EN | PSRAM_ULP_MC_PD_MR(6) | + PSRAM_ULP_MC_PD_CMD(0xF0); #ifdef PSRAM_WRAP_ENABLE - // Burst len: 32 bytes, page: 1K - psram_mc->REG_034 = PSRAM_ULP_MC_BURST_LENGTH(1) | PSRAM_ULP_MC_PAGE_BOUNDARY(0); + // Burst len: 32 bytes, page: 1K + psram_mc->REG_034 = + PSRAM_ULP_MC_BURST_LENGTH(1) | PSRAM_ULP_MC_PAGE_BOUNDARY(0); #else - // 8MB psram - // Burst len: 1K, page: 1K - psram_mc->REG_034 = PSRAM_ULP_MC_BURST_LENGTH(4) | PSRAM_ULP_MC_PAGE_BOUNDARY(0); + // 8MB psram + // Burst len: 1K, page: 1K + psram_mc->REG_034 = + PSRAM_ULP_MC_BURST_LENGTH(4) | PSRAM_ULP_MC_PAGE_BOUNDARY(0); #endif - // AHB bus width: 32 bits - psram_mc->REG_038 = 0; - // Write buffer level with high priority: 0~7 - psram_mc->REG_03C = PSRAM_ULP_MC_HIGH_PRI_LEVEL(4); + // AHB bus width: 32 bits + psram_mc->REG_038 = 0; + // Write buffer level with high priority: 0~7 + psram_mc->REG_03C = PSRAM_ULP_MC_HIGH_PRI_LEVEL(4); #ifdef PSRAM_WRAP_ENABLE - psram_mc->REG_040 = PSRAM_ULP_MC_CP_WRAP_EN; + psram_mc->REG_040 = PSRAM_ULP_MC_CP_WRAP_EN; #else - psram_mc->REG_040 = PSRAM_ULP_MC_WRAP_CRT_RET_EN; + psram_mc->REG_040 = PSRAM_ULP_MC_WRAP_CRT_RET_EN; #endif - psram_mc->REG_044 = 0; - psram_mc->REG_048 = 0; + psram_mc->REG_044 = 0; + psram_mc->REG_048 = 0; - hal_psramip_set_reg_data_mask(); + hal_psramip_set_reg_data_mask(); - hal_psram_mc_set_timing(clk); + hal_psram_mc_set_timing(clk); - psram_mc->REG_400 = PSRAM_ULP_MC_INIT_COMPLETE; + psram_mc->REG_400 = PSRAM_ULP_MC_INIT_COMPLETE; - hal_psram_init_calib(); + hal_psram_init_calib(); } -void hal_psram_sleep(void) -{ - hal_psramip_mc_busy_wait(); - if (!hal_psramip_mc_in_sleep()) { +void hal_psram_sleep(void) { + hal_psramip_mc_busy_wait(); + if (!hal_psramip_mc_in_sleep()) { #ifndef CHIP_BEST2001 - psram_mc->REG_024 &= ~PSRAM_ULP_MC_ENTRY_SLEEP_IDLE; + psram_mc->REG_024 &= ~PSRAM_ULP_MC_ENTRY_SLEEP_IDLE; #endif - hal_psramip_mc_busy_wait(); - hal_psramip_set_cmd(MEMIF_PD); - hal_psramip_mc_busy_wait(); - } -} - -void hal_psram_wakeup(void) -{ hal_psramip_mc_busy_wait(); + hal_psramip_set_cmd(MEMIF_PD); + hal_psramip_mc_busy_wait(); + } +} + +void hal_psram_wakeup(void) { + hal_psramip_mc_busy_wait(); #ifndef CHIP_BEST2001 - psram_mc->REG_024 |= PSRAM_ULP_MC_ENTRY_SLEEP_IDLE; + psram_mc->REG_024 |= PSRAM_ULP_MC_ENTRY_SLEEP_IDLE; #endif } -static void psram_chip_timing_config(uint32_t clk, bool update_psram_first) -{ - enum HAL_CMU_FREQ_T freq; +static void psram_chip_timing_config(uint32_t clk, bool update_psram_first) { + enum HAL_CMU_FREQ_T freq; - if (clk <= 52000000) { - freq = HAL_CMU_FREQ_104M; - } else if (clk <= 104000000) { - freq = HAL_CMU_FREQ_208M; - } else { + if (clk <= 52000000) { + freq = HAL_CMU_FREQ_104M; + } else if (clk <= 104000000) { + freq = HAL_CMU_FREQ_208M; + } else { #ifdef HAL_CMU_FREQ_T - freq = HAL_CMU_FREQ_390M; + freq = HAL_CMU_FREQ_390M; #else - freq = HAL_CMU_FREQ_208M; + freq = HAL_CMU_FREQ_208M; #endif - } + } - if (update_psram_first) { - psram_set_timing(clk); - } + if (update_psram_first) { + psram_set_timing(clk); + } - hal_cmu_mem_set_freq(freq); - hal_sys_timer_delay_us(3); - hal_psram_phy_dll_config(clk); - hal_psram_init_calib(); - hal_psram_mc_set_timing(clk); - if (!update_psram_first) { - psram_set_timing(clk); - } + hal_cmu_mem_set_freq(freq); + hal_sys_timer_delay_us(3); + hal_psram_phy_dll_config(clk); + hal_psram_init_calib(); + hal_psram_mc_set_timing(clk); + if (!update_psram_first) { + psram_set_timing(clk); + } } -static bool psramphy_check_write_valid() -{ - int i; - volatile uint32_t *psram_base = (volatile uint32_t *)PSRAM_NC_BASE; - for (i=0; i<0x8; ++i) { - *(psram_base+i) = 0xffffffff; +static bool psramphy_check_write_valid() { + int i; + volatile uint32_t *psram_base = (volatile uint32_t *)PSRAM_NC_BASE; + for (i = 0; i < 0x8; ++i) { + *(psram_base + i) = 0xffffffff; + } + for (i = 0; i < 0x8; ++i) { + *(psram_base + i) = ((i << 0) | (i << 8) | (i << 16) | (i << 24)); + } + hal_psramip_wb_busy_wait(); + hal_psramip_mc_busy_wait(); + for (i = 0; i < 0x8; ++i) { + uint32_t check_val = *(psram_base + i); + if (check_val != ((i << 0) | (i << 8) | (i << 16) | (i << 24))) { + // PSRAM_TRACE(2,"write fail, %p = 0x%x", (uint32_t)(psram_base+i), + // check_val); + return false; } - for (i=0; i<0x8; ++i) { - *(psram_base+i) = ((i << 0) | (i << 8) | (i << 16) | (i << 24)); - } - hal_psramip_wb_busy_wait(); - hal_psramip_mc_busy_wait(); - for (i=0; i<0x8; ++i) { - uint32_t check_val = *(psram_base+i); - if (check_val != ((i << 0) | (i << 8) | (i << 16) | (i << 24))) { - //PSRAM_TRACE(2,"write fail, %p = 0x%x", (uint32_t)(psram_base+i), check_val); - return false; - } - } - return true; + } + return true; } -static void hal_psram_calib_range(uint32_t range) -{ - uint32_t val; - uint32_t delay; - uint8_t tx_dqs, rx_dqs; - uint8_t inc_delay, volume; - uint8_t cali_valid[0x20][0x20]; - uint8_t cali_value[0x20][0x20]; +static void hal_psram_calib_range(uint32_t range) { + uint32_t val; + uint32_t delay; + uint8_t tx_dqs, rx_dqs; + uint8_t inc_delay, volume; + uint8_t cali_valid[0x20][0x20]; + uint8_t cali_value[0x20][0x20]; - ASSERT(range <= (PSRAM_ULP_PHY_DLL_DLY_IN_MASK >> PSRAM_ULP_PHY_DLL_DLY_IN_SHIFT), "ERROR, bad ana phy range:%d", range); + ASSERT(range <= + (PSRAM_ULP_PHY_DLL_DLY_IN_MASK >> PSRAM_ULP_PHY_DLL_DLY_IN_SHIFT), + "ERROR, bad ana phy range:%d", range); - val = psram_phy->REG_050; - val &= ~(PSRAM_ULP_PHY_REG_DLL_RESETB | PSRAM_ULP_PHY_REG_DLL_CK_RDY); - psram_phy->REG_050 = val; - val = SET_BITFIELD(val, PSRAM_ULP_PHY_REG_DLL_RANGE, range); - psram_phy->REG_050 = val; - val |= (PSRAM_ULP_PHY_REG_DLL_RESETB | PSRAM_ULP_PHY_REG_DLL_CK_RDY); - psram_phy->REG_050 = val; + val = psram_phy->REG_050; + val &= ~(PSRAM_ULP_PHY_REG_DLL_RESETB | PSRAM_ULP_PHY_REG_DLL_CK_RDY); + psram_phy->REG_050 = val; + val = SET_BITFIELD(val, PSRAM_ULP_PHY_REG_DLL_RANGE, range); + psram_phy->REG_050 = val; + val |= (PSRAM_ULP_PHY_REG_DLL_RESETB | PSRAM_ULP_PHY_REG_DLL_CK_RDY); + psram_phy->REG_050 = val; - hal_sys_timer_delay_us(100); - while ((psram_phy->REG_058 & PSRAM_ULP_PHY_DLL_LOCK) == 0); + hal_sys_timer_delay_us(100); + while ((psram_phy->REG_058 & PSRAM_ULP_PHY_DLL_LOCK) == 0) + ; - val = psram_phy->REG_058; - if ((val & PSRAM_ULP_PHY_DLL_ALL_ONE)) { - PSRAM_TRACE(2,"%s: all one, increase range=%d", __func__, range+1); - return hal_psram_calib_range(range+1); + val = psram_phy->REG_058; + if ((val & PSRAM_ULP_PHY_DLL_ALL_ONE)) { + PSRAM_TRACE(2, "%s: all one, increase range=%d", __func__, range + 1); + return hal_psram_calib_range(range + 1); + } + + delay = GET_BITFIELD(val, PSRAM_ULP_PHY_DLL_DLY_IN); + PSRAM_TRACE(4, "%s, range:%d, T/4 = 0x%x(psram_phy->REG_058:0x%x)", __func__, + range, delay / 2, val); + if (delay > (PSRAM_ULP_PHY_REG_PSRAM_TX_DQS_DLY_MASK >> + PSRAM_ULP_PHY_REG_PSRAM_TX_DQS_DLY_SHIFT) && + range < 3) { + PSRAM_TRACE("%s: bad delay (T/2 > 0x1f). increase range=%d", __func__, + range + 1); + return hal_psram_calib_range(range + 1); + } + + inc_delay = delay / 8; + if (inc_delay == 0) + inc_delay = 1; + + // volume = + // (PSRAM_ULP_PHY_REG_PSRAM_TX_DQS_DLY_MASK>>PSRAM_ULP_PHY_REG_PSRAM_TX_DQS_DLY_SHIFT) + // / inc_delay; + volume = MIN(delay, (PSRAM_ULP_PHY_REG_PSRAM_TX_DQS_DLY_MASK >> + PSRAM_ULP_PHY_REG_PSRAM_TX_DQS_DLY_SHIFT)) / + inc_delay; + + PSRAM_TRACE(2, "volume:%d, inc_delay:%d", volume, inc_delay); + + uint8_t all_valid = 1; + + memset(cali_valid, 0, sizeof(cali_valid)); + for (tx_dqs = 0; tx_dqs <= volume; tx_dqs++) { + for (rx_dqs = 0; rx_dqs <= volume; rx_dqs++) { + psram_phy->REG_054 = + PSRAM_ULP_PHY_REG_PSRAM_TX_CEB_DLY(delay / 2) | + PSRAM_ULP_PHY_REG_PSRAM_TX_CLK_DLY(delay / 2) | + PSRAM_ULP_PHY_REG_PSRAM_TX_DQS_DLY(tx_dqs * inc_delay) | + PSRAM_ULP_PHY_REG_PSRAM_RX_DQS_DLY(rx_dqs * inc_delay); + cali_valid[tx_dqs][rx_dqs] = psramphy_check_write_valid(); + if (cali_valid[tx_dqs][rx_dqs] == 0) + all_valid = 0; } + } - delay = GET_BITFIELD(val, PSRAM_ULP_PHY_DLL_DLY_IN); - PSRAM_TRACE(4,"%s, range:%d, T/4 = 0x%x(psram_phy->REG_058:0x%x)", __func__, range, delay/2, val); - if (delay > (PSRAM_ULP_PHY_REG_PSRAM_TX_DQS_DLY_MASK>>PSRAM_ULP_PHY_REG_PSRAM_TX_DQS_DLY_SHIFT) && range<3) { - PSRAM_TRACE("%s: bad delay (T/2 > 0x1f). increase range=%d", __func__, range+1); - return hal_psram_calib_range(range+1); - } + if (all_valid && range < (PSRAM_ULP_PHY_DLL_DLY_IN_MASK >> + PSRAM_ULP_PHY_DLL_DLY_IN_SHIFT)) { + PSRAM_TRACE(2, "%s: all valid increase range=%d", __func__, range + 1); + // return hal_psram_calib_range(range+1); + } - inc_delay = delay/8; - if (inc_delay == 0) - inc_delay = 1; - - //volume = (PSRAM_ULP_PHY_REG_PSRAM_TX_DQS_DLY_MASK>>PSRAM_ULP_PHY_REG_PSRAM_TX_DQS_DLY_SHIFT) / inc_delay; - volume = MIN(delay, (PSRAM_ULP_PHY_REG_PSRAM_TX_DQS_DLY_MASK>>PSRAM_ULP_PHY_REG_PSRAM_TX_DQS_DLY_SHIFT)) / inc_delay; - - PSRAM_TRACE(2,"volume:%d, inc_delay:%d", volume, inc_delay); - - uint8_t all_valid = 1; - - memset(cali_valid, 0, sizeof(cali_valid)); - for (tx_dqs=0; tx_dqs<=volume; tx_dqs++) { - for (rx_dqs=0; rx_dqs<=volume; rx_dqs++) { - psram_phy->REG_054 = PSRAM_ULP_PHY_REG_PSRAM_TX_CEB_DLY(delay/2) | PSRAM_ULP_PHY_REG_PSRAM_TX_CLK_DLY(delay/2) | - PSRAM_ULP_PHY_REG_PSRAM_TX_DQS_DLY(tx_dqs*inc_delay) | PSRAM_ULP_PHY_REG_PSRAM_RX_DQS_DLY(rx_dqs*inc_delay); - cali_valid[tx_dqs][rx_dqs] = psramphy_check_write_valid(); - if (cali_valid[tx_dqs][rx_dqs] == 0) - all_valid = 0; + memset(cali_value, 0, sizeof(cali_value)); + PSRAM_TRACENOCRLF_NOTS("\r\n\r\n " + "-----------------------------------------------------" + "----------------- \r\n"); + PSRAM_TRACENOCRLF_NOTS(" rx_dqs"); + for (tx_dqs = 0; tx_dqs <= volume; tx_dqs++) { + PSRAM_TRACENOCRLF_NOTS(" %2d ", tx_dqs * inc_delay); + } + PSRAM_TRACENOCRLF_NOTS("\r\n"); + for (tx_dqs = 0; tx_dqs <= volume; tx_dqs++) { + PSRAM_TRACENOCRLF_NOTS("tx_dqs:%2d ", tx_dqs * inc_delay); + for (rx_dqs = 0; rx_dqs <= volume; rx_dqs++) { + PSRAM_TRACENOCRLF_NOTS(" %d ", cali_valid[tx_dqs][rx_dqs]); + if (cali_valid[tx_dqs][rx_dqs]) { + uint8_t len_from_zero; + int8_t p; + p = tx_dqs; + while (p >= 0) { + if (cali_valid[p][rx_dqs] == 0) + break; + p--; } - } + len_from_zero = tx_dqs - p; + cali_value[tx_dqs][rx_dqs] = len_from_zero; - if (all_valid && range < (PSRAM_ULP_PHY_DLL_DLY_IN_MASK >> PSRAM_ULP_PHY_DLL_DLY_IN_SHIFT)) { - PSRAM_TRACE(2,"%s: all valid increase range=%d", __func__, range+1); - //return hal_psram_calib_range(range+1); - } + p = tx_dqs; + while (p <= volume) { + if (cali_valid[p][rx_dqs] == 0) + break; + p++; + } + len_from_zero = p - tx_dqs; + cali_value[tx_dqs][rx_dqs] = + MIN(cali_value[tx_dqs][rx_dqs], len_from_zero); - memset(cali_value, 0, sizeof(cali_value)); - PSRAM_TRACENOCRLF_NOTS("\r\n\r\n ---------------------------------------------------------------------- \r\n"); - PSRAM_TRACENOCRLF_NOTS(" rx_dqs"); - for (tx_dqs=0; tx_dqs<=volume; tx_dqs++) { - PSRAM_TRACENOCRLF_NOTS(" %2d ", tx_dqs*inc_delay); + p = rx_dqs; + while (p >= 0) { + if (cali_valid[tx_dqs][p] == 0) + break; + p--; + } + len_from_zero = rx_dqs - p; + cali_value[tx_dqs][rx_dqs] = + MIN(cali_value[tx_dqs][rx_dqs], len_from_zero); + + p = rx_dqs; + while (p <= volume) { + if (cali_valid[tx_dqs][p] == 0) + break; + p++; + } + len_from_zero = p - rx_dqs; + cali_value[tx_dqs][rx_dqs] = + MIN(cali_value[tx_dqs][rx_dqs], len_from_zero); + } } PSRAM_TRACENOCRLF_NOTS("\r\n"); - for (tx_dqs=0; tx_dqs<=volume; tx_dqs++) { - PSRAM_TRACENOCRLF_NOTS("tx_dqs:%2d ", tx_dqs*inc_delay); - for (rx_dqs=0; rx_dqs<=volume; rx_dqs++) { - PSRAM_TRACENOCRLF_NOTS(" %d ", cali_valid[tx_dqs][rx_dqs]); - if (cali_valid[tx_dqs][rx_dqs]) { - uint8_t len_from_zero; - int8_t p; - p = tx_dqs; - while (p>=0) { - if (cali_valid[p][rx_dqs] == 0) - break; - p--; - } - len_from_zero = tx_dqs - p; - cali_value[tx_dqs][rx_dqs] = len_from_zero; - - p = tx_dqs; - while (p<=volume) { - if (cali_valid[p][rx_dqs] == 0) - break; - p++; - } - len_from_zero = p - tx_dqs; - cali_value[tx_dqs][rx_dqs] = MIN(cali_value[tx_dqs][rx_dqs], len_from_zero); - - p = rx_dqs; - while (p>=0) { - if (cali_valid[tx_dqs][p] == 0) - break; - p--; - } - len_from_zero = rx_dqs - p; - cali_value[tx_dqs][rx_dqs] = MIN(cali_value[tx_dqs][rx_dqs], len_from_zero); - - p = rx_dqs; - while (p<=volume) { - if (cali_valid[tx_dqs][p] == 0) - break; - p++; - } - len_from_zero = p - rx_dqs; - cali_value[tx_dqs][rx_dqs] = MIN(cali_value[tx_dqs][rx_dqs], len_from_zero); - } - } - PSRAM_TRACENOCRLF_NOTS("\r\n"); - } - PSRAM_TRACENOCRLF_NOTS(" -------------------------------------------------------------------------- \r\n"); + } + PSRAM_TRACENOCRLF_NOTS(" ----------------------------------------------------" + "---------------------- \r\n"); #if 0 PSRAM_TRACENOCRLF_NOTS("\r\n\r\n ---------------------------------------------------------------------- \r\n"); @@ -730,86 +728,83 @@ static void hal_psram_calib_range(uint32_t range) PSRAM_TRACENOCRLF_NOTS(" -------------------------------------------------------------------------- \r\n"); #endif - uint32_t position = 0; - uint8_t max_value = 0; - for (tx_dqs=0; tx_dqs<=volume; tx_dqs++) { - for (rx_dqs=0; rx_dqs<=volume; rx_dqs++) { - if (cali_value[tx_dqs][rx_dqs] > max_value) { - max_value = cali_value[tx_dqs][rx_dqs]; - position = tx_dqs*(volume+1) + rx_dqs; - } - } + uint32_t position = 0; + uint8_t max_value = 0; + for (tx_dqs = 0; tx_dqs <= volume; tx_dqs++) { + for (rx_dqs = 0; rx_dqs <= volume; rx_dqs++) { + if (cali_value[tx_dqs][rx_dqs] > max_value) { + max_value = cali_value[tx_dqs][rx_dqs]; + position = tx_dqs * (volume + 1) + rx_dqs; + } } - PSRAM_TRACENOCRLF_NOTS("position:%d\r\n", position); - tx_dqs = position/(volume+1)*inc_delay; - rx_dqs = (position%(volume+1))*inc_delay; - PSRAM_TRACENOCRLF_NOTS("most optimal position. tx_dqs:%d, rx_dqs:%d\r\n", tx_dqs, rx_dqs); - - psram_phy->REG_054 = PSRAM_ULP_PHY_REG_PSRAM_TX_CEB_DLY(delay/2) | PSRAM_ULP_PHY_REG_PSRAM_TX_CLK_DLY(delay/2) | - PSRAM_ULP_PHY_REG_PSRAM_TX_DQS_DLY(tx_dqs) | PSRAM_ULP_PHY_REG_PSRAM_RX_DQS_DLY(rx_dqs); + } + PSRAM_TRACENOCRLF_NOTS("position:%d\r\n", position); + tx_dqs = position / (volume + 1) * inc_delay; + rx_dqs = (position % (volume + 1)) * inc_delay; + PSRAM_TRACENOCRLF_NOTS("most optimal position. tx_dqs:%d, rx_dqs:%d\r\n", + tx_dqs, rx_dqs); + psram_phy->REG_054 = PSRAM_ULP_PHY_REG_PSRAM_TX_CEB_DLY(delay / 2) | + PSRAM_ULP_PHY_REG_PSRAM_TX_CLK_DLY(delay / 2) | + PSRAM_ULP_PHY_REG_PSRAM_TX_DQS_DLY(tx_dqs) | + PSRAM_ULP_PHY_REG_PSRAM_RX_DQS_DLY(rx_dqs); } -static void hal_psram_calib(uint32_t clk) -{ - uint32_t phy_clk; - uint32_t range; - PSRAM_TRACE("%s, speed:%d", __func__, clk); - phy_clk = clk; - if (phy_clk <= 100000000 / 2) { - range = 3; - } else if (phy_clk <= 150000000 / 2) { - range = 2; - } else if (phy_clk <= 300000000 / 2) { - range = 1; - } else { - range = 0; - } - hal_psram_calib_range(range); +static void hal_psram_calib(uint32_t clk) { + uint32_t phy_clk; + uint32_t range; + PSRAM_TRACE("%s, speed:%d", __func__, clk); + phy_clk = clk; + if (phy_clk <= 100000000 / 2) { + range = 3; + } else if (phy_clk <= 150000000 / 2) { + range = 2; + } else if (phy_clk <= 300000000 / 2) { + range = 1; + } else { + range = 0; + } + hal_psram_calib_range(range); } -void hal_psram_snoop_enable() -{ - psram_mc->REG_044 &= ~PSRAM_ULP_MC_SNP_DISABLE; +void hal_psram_snoop_enable() { + psram_mc->REG_044 &= ~PSRAM_ULP_MC_SNP_DISABLE; } -void hal_psram_snoop_disable() -{ - psram_mc->REG_044 |= PSRAM_ULP_MC_SNP_DISABLE; +void hal_psram_snoop_disable() { + psram_mc->REG_044 |= PSRAM_ULP_MC_SNP_DISABLE; } -void hal_psram_init(void) -{ - hal_cache_wrap_enable(HAL_CACHE_ID_I_CACHE); - hal_cache_wrap_enable(HAL_CACHE_ID_D_CACHE); +void hal_psram_init(void) { + hal_cache_wrap_enable(HAL_CACHE_ID_I_CACHE); + hal_cache_wrap_enable(HAL_CACHE_ID_D_CACHE); - hal_cmu_mem_set_freq(HAL_CMU_FREQ_104M); - hal_cmu_clock_enable(HAL_CMU_MOD_O_PSRAM); - hal_cmu_clock_enable(HAL_CMU_MOD_H_PSRAM); - hal_cmu_reset_clear(HAL_CMU_MOD_O_PSRAM); - hal_cmu_reset_clear(HAL_CMU_MOD_H_PSRAM); + hal_cmu_mem_set_freq(HAL_CMU_FREQ_104M); + hal_cmu_clock_enable(HAL_CMU_MOD_O_PSRAM); + hal_cmu_clock_enable(HAL_CMU_MOD_H_PSRAM); + hal_cmu_reset_clear(HAL_CMU_MOD_O_PSRAM); + hal_cmu_reset_clear(HAL_CMU_MOD_H_PSRAM); - hal_psram_phy_init(psram_cfg_clk); - hal_sys_timer_delay_us(30); - hal_psram_mc_init(psram_cfg_clk); + hal_psram_phy_init(psram_cfg_clk); + hal_sys_timer_delay_us(30); + hal_psram_mc_init(psram_cfg_clk); #ifdef PSRAM_RESET - psram_reset(); - psram_chip_timing_config(psram_run_clk, true); + psram_reset(); + psram_chip_timing_config(psram_run_clk, true); #else - uint32_t reg; - uint32_t val; + uint32_t reg; + uint32_t val; - reg = 4; - psram_read_reg(reg, &val); - if (val & MR4_WL) { - psram_chip_timing_config(psram_run_clk, false); - } else { - psram_chip_timing_config(psram_run_clk, true); - } + reg = 4; + psram_read_reg(reg, &val); + if (val & MR4_WL) { + psram_chip_timing_config(psram_run_clk, false); + } else { + psram_chip_timing_config(psram_run_clk, true); + } #endif - hal_psram_snoop_disable(); - hal_psram_calib(psram_run_clk); - hal_psram_snoop_enable(); + hal_psram_snoop_disable(); + hal_psram_calib(psram_run_clk); + hal_psram_snoop_enable(); } #endif - diff --git a/platform/hal/hal_psramuhs.c b/platform/hal/hal_psramuhs.c index 1bca21e..021bb7b 100644 --- a/platform/hal/hal_psramuhs.c +++ b/platform/hal/hal_psramuhs.c @@ -15,13 +15,13 @@ ****************************************************************************/ #ifdef CHIP_HAS_PSRAMUHS -#include "plat_types.h" -#include "plat_addr_map.h" -#include "hal_location.h" #include "hal_psramuhs.h" +#include "hal_cache.h" +#include "hal_location.h" #include "hal_timer.h" #include "hal_trace.h" -#include "hal_cache.h" +#include "plat_addr_map.h" +#include "plat_types.h" #include "pmu.h" #include "psramuhsphy.h" #include "reg_psramuhs_mc.h" @@ -40,593 +40,563 @@ #define PSRAMUHS_DUMMY_CYCLE #endif -#define TX_FIFO_DEPTH 4 -#define RX_FIFO_DEPTH 4 +#define TX_FIFO_DEPTH 4 +#define RX_FIFO_DEPTH 4 enum CP_FSM_STATE_T { - CP_FSM_STATE_SELF_REFRESH = 1, - CP_FSM_STATE_PD = 2, - CP_FSM_STATE_READY = 4, + CP_FSM_STATE_SELF_REFRESH = 1, + CP_FSM_STATE_PD = 2, + CP_FSM_STATE_READY = 4, }; enum MEMIF_CMD_T { - MEMIF_NO_CMD = 0x00, - MEMIF_WRITE = 0x01, - MEMIF_READ = 0x02, - MEMIF_MRS = 0x05, - MEMIF_MRR = 0x06, - MEMIF_REF = 0x08, - MEMIF_SREF = 0x09, - MEMIF_PD = 0x10, - MEMIF_NOP = 0x20, - MEMIF_RST = 0xFF, - MEMIF_ZQCL = 0x85, - MEMIF_ZQCS = 0x45, - MEMIF_ZQCRST = 0x25, - MEMIF_START_CLOCK = 0x40, - MEMIF_STOP_CLOCK = 0x80, - MEMIF_NEW_CMD = 0x7F, + MEMIF_NO_CMD = 0x00, + MEMIF_WRITE = 0x01, + MEMIF_READ = 0x02, + MEMIF_MRS = 0x05, + MEMIF_MRR = 0x06, + MEMIF_REF = 0x08, + MEMIF_SREF = 0x09, + MEMIF_PD = 0x10, + MEMIF_NOP = 0x20, + MEMIF_RST = 0xFF, + MEMIF_ZQCL = 0x85, + MEMIF_ZQCS = 0x45, + MEMIF_ZQCRST = 0x25, + MEMIF_START_CLOCK = 0x40, + MEMIF_STOP_CLOCK = 0x80, + MEMIF_NEW_CMD = 0x7F, }; -static struct PSRAMUHS_MC_T * const psramuhs_mc = (struct PSRAMUHS_MC_T *)PSRAMUHS_CTRL_BASE; +static struct PSRAMUHS_MC_T *const psramuhs_mc = + (struct PSRAMUHS_MC_T *)PSRAMUHS_CTRL_BASE; #ifdef FPGA static const uint32_t psramuhs_run_clk = 26000000; #else #if (PSRAMUHS_SPEED != 0) -static const uint32_t psramuhs_run_clk = PSRAMUHS_SPEED*1000*1000; +static const uint32_t psramuhs_run_clk = PSRAMUHS_SPEED * 1000 * 1000; #else #error "invalid PSRAMUHS_SPEED" #endif #endif -static int hal_psramuhsip_mc_busy(void) -{ - return !!(psramuhs_mc->REG_404 & PSRAM_UHS_MC_BUSY); +static int hal_psramuhsip_mc_busy(void) { + return !!(psramuhs_mc->REG_404 & PSRAM_UHS_MC_BUSY); } -static int hal_psramuhsip_wb_busy(void) -{ - return !!(psramuhs_mc->REG_404 & PSRAM_UHS_MC_WB_FILL_LEVEL_MASK); +static int hal_psramuhsip_wb_busy(void) { + return !!(psramuhs_mc->REG_404 & PSRAM_UHS_MC_WB_FILL_LEVEL_MASK); } -int hal_psramuhsip_mc_in_sleep(void) -{ - return GET_BITFIELD(psramuhs_mc->REG_404, PSRAM_UHS_MC_CP_FSM_STATE) == CP_FSM_STATE_PD; +int hal_psramuhsip_mc_in_sleep(void) { + return GET_BITFIELD(psramuhs_mc->REG_404, PSRAM_UHS_MC_CP_FSM_STATE) == + CP_FSM_STATE_PD; } -int hal_psramuhsip_rx_fifo_empty(void) -{ - return !!(psramuhs_mc->REG_404 & PSRAM_UHS_MC_MGR_RXFIFO_R_EMPTY); +int hal_psramuhsip_rx_fifo_empty(void) { + return !!(psramuhs_mc->REG_404 & PSRAM_UHS_MC_MGR_RXFIFO_R_EMPTY); } -int hal_psramuhsip_tx_fifo_full(void) -{ - return !!(psramuhs_mc->REG_404 & PSRAM_UHS_MC_MGR_TXFIFO_W_FULL); +int hal_psramuhsip_tx_fifo_full(void) { + return !!(psramuhs_mc->REG_404 & PSRAM_UHS_MC_MGR_TXFIFO_W_FULL); } -uint32_t hal_psramuhsip_get_rx_fifo_len(void) -{ - return GET_BITFIELD(psramuhs_mc->REG_404, PSRAM_UHS_MC_MGR_RXFIFO_FULL_CNT); +uint32_t hal_psramuhsip_get_rx_fifo_len(void) { + return GET_BITFIELD(psramuhs_mc->REG_404, PSRAM_UHS_MC_MGR_RXFIFO_FULL_CNT); } -uint32_t hal_psramuhsip_get_tx_fifo_free_len(void) -{ - return GET_BITFIELD(psramuhs_mc->REG_404, PSRAM_UHS_MC_MGR_TXFIFO_EMPTY_CNT); +uint32_t hal_psramuhsip_get_tx_fifo_free_len(void) { + return GET_BITFIELD(psramuhs_mc->REG_404, PSRAM_UHS_MC_MGR_TXFIFO_EMPTY_CNT); } -void hal_psramuhsip_mc_busy_wait(void) -{ - while (hal_psramuhsip_mc_busy()); +void hal_psramuhsip_mc_busy_wait(void) { + while (hal_psramuhsip_mc_busy()) + ; } -void hal_psramuhsip_wb_busy_wait(void) -{ - while (hal_psramuhsip_wb_busy()); +void hal_psramuhsip_wb_busy_wait(void) { + while (hal_psramuhsip_wb_busy()) + ; } -void hal_psramuhsip_flush_tx_fifo(void) -{ - hal_psramuhsip_mc_busy_wait(); - psramuhs_mc->REG_01C = PSRAM_UHS_MC_MGR_TX_FIFO_CLR; - hal_psramuhsip_mc_busy_wait(); +void hal_psramuhsip_flush_tx_fifo(void) { + hal_psramuhsip_mc_busy_wait(); + psramuhs_mc->REG_01C = PSRAM_UHS_MC_MGR_TX_FIFO_CLR; + hal_psramuhsip_mc_busy_wait(); } -void hal_psramuhsip_flush_rx_fifo(void) -{ - hal_psramuhsip_mc_busy_wait(); - psramuhs_mc->REG_01C = PSRAM_UHS_MC_MGR_RX_FIFO_CLR; - hal_psramuhsip_mc_busy_wait(); +void hal_psramuhsip_flush_rx_fifo(void) { + hal_psramuhsip_mc_busy_wait(); + psramuhs_mc->REG_01C = PSRAM_UHS_MC_MGR_RX_FIFO_CLR; + hal_psramuhsip_mc_busy_wait(); } -void hal_psramuhsip_flush_all_fifo(void) -{ - hal_psramuhsip_mc_busy_wait(); - psramuhs_mc->REG_01C = PSRAM_UHS_MC_MGR_TX_FIFO_CLR | PSRAM_UHS_MC_MGR_RX_FIFO_CLR; - hal_psramuhsip_mc_busy_wait(); +void hal_psramuhsip_flush_all_fifo(void) { + hal_psramuhsip_mc_busy_wait(); + psramuhs_mc->REG_01C = + PSRAM_UHS_MC_MGR_TX_FIFO_CLR | PSRAM_UHS_MC_MGR_RX_FIFO_CLR; + hal_psramuhsip_mc_busy_wait(); } -void hal_psramuhsip_xfer_addr_len(uint32_t addr, uint32_t len) -{ - psramuhs_mc->REG_008 = addr; - psramuhs_mc->REG_00C = len; +void hal_psramuhsip_xfer_addr_len(uint32_t addr, uint32_t len) { + psramuhs_mc->REG_008 = addr; + psramuhs_mc->REG_00C = len; } -void hal_psramuhsip_write_fifo(uint32_t *data, uint32_t len) -{ - for (int i = 0; i < len; i++) { - psramuhs_mc->REG_014 = *data++; - } +void hal_psramuhsip_write_fifo(uint32_t *data, uint32_t len) { + for (int i = 0; i < len; i++) { + psramuhs_mc->REG_014 = *data++; + } } -void hal_psramuhsip_read_fifo(uint32_t *data, uint32_t len) -{ - for (int i = 0; i < len; i++) { - *data++ = psramuhs_mc->REG_018; - } +void hal_psramuhsip_read_fifo(uint32_t *data, uint32_t len) { + for (int i = 0; i < len; i++) { + *data++ = psramuhs_mc->REG_018; + } } -void hal_psramuhsip_set_reg_data_mask(void) -{ +void hal_psramuhsip_set_reg_data_mask(void) { #ifdef PSRAMUHS_DUAL_8BIT - psramuhs_mc->REG_010 = 0xFFFC; + psramuhs_mc->REG_010 = 0xFFFC; #else - psramuhs_mc->REG_010 = 0xFFFE; + psramuhs_mc->REG_010 = 0xFFFE; #endif } -void hal_psramuhsip_set_mem_data_mask(void) -{ - psramuhs_mc->REG_010 = 0; +void hal_psramuhsip_set_mem_data_mask(void) { psramuhs_mc->REG_010 = 0; } + +void hal_psramuhsip_set_reg_fifo_width(void) { psramuhs_mc->REG_0B0 = 0; } + +void hal_psramuhsip_set_mem_fifo_width(void) { + // 128 bits if PSRAMUHS_DUAL_8BIT; 64 bits otherwise + psramuhs_mc->REG_0B0 = PSRAM_UHS_MC_MGR_FIFO_TEST_EN; } -void hal_psramuhsip_set_reg_fifo_width(void) -{ - psramuhs_mc->REG_0B0 = 0; +void hal_psramuhsip_set_cmd(enum MEMIF_CMD_T cmd) { + psramuhs_mc->REG_004 = cmd; } -void hal_psramuhsip_set_mem_fifo_width(void) -{ - // 128 bits if PSRAMUHS_DUAL_8BIT; 64 bits otherwise - psramuhs_mc->REG_0B0 = PSRAM_UHS_MC_MGR_FIFO_TEST_EN; +POSSIBLY_UNUSED void psramuhs_read_reg(uint32_t reg, uint32_t *val) { + hal_psramuhsip_flush_all_fifo(); + hal_psramuhsip_xfer_addr_len(reg, 1); + hal_psramuhsip_set_cmd(MEMIF_MRR); + while (hal_psramuhsip_rx_fifo_empty()) + ; + hal_psramuhsip_read_fifo(val, 1); } -void hal_psramuhsip_set_cmd(enum MEMIF_CMD_T cmd) -{ - psramuhs_mc->REG_004 = cmd; -} - -POSSIBLY_UNUSED void psramuhs_read_reg(uint32_t reg, uint32_t *val) -{ - hal_psramuhsip_flush_all_fifo(); - hal_psramuhsip_xfer_addr_len(reg, 1); - hal_psramuhsip_set_cmd(MEMIF_MRR); - while (hal_psramuhsip_rx_fifo_empty()); - hal_psramuhsip_read_fifo(val, 1); -} - -static void psramuhs_send_cmd_reg(enum MEMIF_CMD_T cmd, uint32_t reg, uint32_t val) -{ +static void psramuhs_send_cmd_reg(enum MEMIF_CMD_T cmd, uint32_t reg, + uint32_t val) { #if !defined(PSRAMUHS_DIG_LOOPBACK) && !defined(PSRAMUHS_ANA_LOOPBACK) #ifdef PSRAMUHS_DUAL_8BIT - val &= 0xFF; - val |= (val << 8); + val &= 0xFF; + val |= (val << 8); #endif - hal_psramuhsip_flush_all_fifo(); - //hal_psramuhsip_set_reg_fifo_width(); - //hal_psramuhsip_set_reg_data_mask(); - hal_psramuhsip_write_fifo(&val, 1); - hal_psramuhsip_xfer_addr_len(reg, 1); - hal_psramuhsip_set_cmd(cmd); - while (hal_psramuhsip_get_tx_fifo_free_len() != TX_FIFO_DEPTH); - hal_psramuhsip_mc_busy_wait(); - //hal_psramuhsip_set_mem_fifo_width(); - //hal_psramuhsip_set_mem_data_mask(); + hal_psramuhsip_flush_all_fifo(); + // hal_psramuhsip_set_reg_fifo_width(); + // hal_psramuhsip_set_reg_data_mask(); + hal_psramuhsip_write_fifo(&val, 1); + hal_psramuhsip_xfer_addr_len(reg, 1); + hal_psramuhsip_set_cmd(cmd); + while (hal_psramuhsip_get_tx_fifo_free_len() != TX_FIFO_DEPTH) + ; + hal_psramuhsip_mc_busy_wait(); + // hal_psramuhsip_set_mem_fifo_width(); + // hal_psramuhsip_set_mem_data_mask(); #endif } -static void psramuhs_write_reg(uint32_t reg, uint32_t val) -{ - psramuhs_send_cmd_reg(MEMIF_MRS, reg, val); +static void psramuhs_write_reg(uint32_t reg, uint32_t val) { + psramuhs_send_cmd_reg(MEMIF_MRS, reg, val); } -static void psramuhs_single_cmd(enum MEMIF_CMD_T cmd) -{ +static void psramuhs_single_cmd(enum MEMIF_CMD_T cmd) { #if !defined(PSRAMUHS_DIG_LOOPBACK) && !defined(PSRAMUHS_ANA_LOOPBACK) - hal_psramuhsip_flush_all_fifo(); - hal_psramuhsip_set_cmd(cmd); - hal_psramuhsip_mc_busy_wait(); + hal_psramuhsip_flush_all_fifo(); + hal_psramuhsip_set_cmd(cmd); + hal_psramuhsip_mc_busy_wait(); #endif } -static POSSIBLY_UNUSED void psramuhs_start_clock(void) -{ - psramuhs_single_cmd(MEMIF_START_CLOCK); +static POSSIBLY_UNUSED void psramuhs_start_clock(void) { + psramuhs_single_cmd(MEMIF_START_CLOCK); } -static POSSIBLY_UNUSED void psramuhs_stop_clock(void) -{ - psramuhs_single_cmd(MEMIF_STOP_CLOCK); +static POSSIBLY_UNUSED void psramuhs_stop_clock(void) { + psramuhs_single_cmd(MEMIF_STOP_CLOCK); } -static POSSIBLY_UNUSED void psramuhs_reset(void) -{ - psramuhs_single_cmd(MEMIF_RST); +static POSSIBLY_UNUSED void psramuhs_reset(void) { + psramuhs_single_cmd(MEMIF_RST); } -static POSSIBLY_UNUSED void psramuhs_zq_calib_reset(void) -{ - psramuhs_send_cmd_reg(MEMIF_ZQCRST, 7, 0); +static POSSIBLY_UNUSED void psramuhs_zq_calib_reset(void) { + psramuhs_send_cmd_reg(MEMIF_ZQCRST, 7, 0); } -static POSSIBLY_UNUSED void psramuhs_zq_calib(void) -{ - psramuhs_send_cmd_reg(MEMIF_ZQCL, 5, 0); +static POSSIBLY_UNUSED void psramuhs_zq_calib(void) { + psramuhs_send_cmd_reg(MEMIF_ZQCL, 5, 0); } -static void psramuhs_set_timing(uint32_t clk) -{ - uint32_t reg; - uint32_t val; - uint32_t burst_len; +static void psramuhs_set_timing(uint32_t clk) { + uint32_t reg; + uint32_t val; + uint32_t burst_len; - reg = 0; - if (clk <= 200000000) { - val = 7; - } else if (clk <= 333000000) { - val = 6; - } else if (clk <= 400000000) { - val = 5; - } else if (clk <= 533000000) { - val = 4; - } else if (clk <= 667000000) { - val = 0; - } else if (clk <= 800000000) { - val = 1; - } else if (clk <= 933000000) { - val = 2; - } else { - val = 3; - } - // Latency, drive - val = (val << 0) | (2 << 3); + reg = 0; + if (clk <= 200000000) { + val = 7; + } else if (clk <= 333000000) { + val = 6; + } else if (clk <= 400000000) { + val = 5; + } else if (clk <= 533000000) { + val = 4; + } else if (clk <= 667000000) { + val = 0; + } else if (clk <= 800000000) { + val = 1; + } else if (clk <= 933000000) { + val = 2; + } else { + val = 3; + } + // Latency, drive + val = (val << 0) | (2 << 3); #if 0 //refresh disable val |= (1 << 7); #endif - psramuhs_write_reg(reg, val); + psramuhs_write_reg(reg, val); - reg = 2; + reg = 2; #if defined(__ARM_ARCH_ISA_ARM) || defined(DSP_ENABLE) #ifdef PSRAMUHS_DUAL_8BIT - burst_len = 0x1;//32B + burst_len = 0x1; // 32B #else - burst_len = 0x2;//64B + burst_len = 0x2; // 64B #endif #else #ifdef PSRAMUHS_DUAL_8BIT - burst_len = 0x0;//16B + burst_len = 0x0; // 16B #else - burst_len = 0x1;//32B + burst_len = 0x1; // 32B #endif #endif #ifdef PSRAMUHS_PRA_ENABLE - // Burst len, pra enable - val = (burst_len << 0) | (1 << 4); + // Burst len, pra enable + val = (burst_len << 0) | (1 << 4); #else - // Burst len, auto-precharge + // Burst len, auto-precharge #ifdef PSRAMUHS_AUTO_PRECHARGE - val = (burst_len << 0) | (1 << 3); + val = (burst_len << 0) | (1 << 3); #else - val = (burst_len << 0); + val = (burst_len << 0); #endif #endif - //wrap enable + // wrap enable #ifdef PSRAMUHS_WRAP_ENABLE - val |= (1 << 2); + val |= (1 << 2); #endif - psramuhs_write_reg(reg, val); + psramuhs_write_reg(reg, val); - reg = 6; - // Vref trim - val = (8 << 0); - psramuhs_write_reg(reg, val); - hal_sys_timer_delay_us(5); + reg = 6; + // Vref trim + val = (8 << 0); + psramuhs_write_reg(reg, val); + hal_sys_timer_delay_us(5); - psramuhs_zq_calib_reset(); - psramuhs_zq_calib(); + psramuhs_zq_calib_reset(); + psramuhs_zq_calib(); } -void hal_psramuhs_sleep(void) -{ -} +void hal_psramuhs_sleep(void) {} -void hal_psramuhs_wakeup(void) -{ -} +void hal_psramuhs_wakeup(void) {} -static void hal_psramuhs_mc_set_timing(uint32_t clk) -{ - uint32_t val1, val2; - uint32_t val; +static void hal_psramuhs_mc_set_timing(uint32_t clk) { + uint32_t val1, val2; + uint32_t val; - if (clk <= 200000000) { - val1 = 9; - val2 = 5; - } else if (clk <= 333000000) { - val1 = 13; - val2 = 5; - } else if (clk <= 400000000) { - val1 = 16; - val2 = 6; - } else if (clk <= 533000000) { - val1 = 20; - val2 = 10; - } else if (clk <= 667000000) { - val1 = 24; - val2 = 12; - } else if (clk <= 800000000) { - val1 = 29; - val2 = 14; - } else if (clk <= 933000000) { - val1 = 33; - val2 = 16; - } else { - val1 = 37; - val2 = 18; - } - if (clk >= 466000000) - val2--; + if (clk <= 200000000) { + val1 = 9; + val2 = 5; + } else if (clk <= 333000000) { + val1 = 13; + val2 = 5; + } else if (clk <= 400000000) { + val1 = 16; + val2 = 6; + } else if (clk <= 533000000) { + val1 = 20; + val2 = 10; + } else if (clk <= 667000000) { + val1 = 24; + val2 = 12; + } else if (clk <= 800000000) { + val1 = 29; + val2 = 14; + } else if (clk <= 933000000) { + val1 = 33; + val2 = 16; + } else { + val1 = 37; + val2 = 18; + } + if (clk >= 466000000) + val2--; - psramuhs_mc->REG_028 = PSRAM_UHS_MC_WRITE_LATENCY(val2); - psramuhs_mc->REG_02C = PSRAM_UHS_MC_READ_LATENCY(val1); + psramuhs_mc->REG_028 = PSRAM_UHS_MC_WRITE_LATENCY(val2); + psramuhs_mc->REG_02C = PSRAM_UHS_MC_READ_LATENCY(val1); - // tCEM_MAX <= 7.8 us when MRW2[5]==1 && MRR4[2]==0, or <= 3.9 us when MRW2[5]==0 || MRR4[2]==1 - val = (clk / 1000000) * 30 / 10 - 1; - psramuhs_mc->REG_04C = PSRAM_UHS_MC_T_REFI(val) | PSRAM_UHS_MC_NUM_OF_BURST_RFS(0x1000); + // tCEM_MAX <= 7.8 us when MRW2[5]==1 && MRR4[2]==0, or <= 3.9 us when + // MRW2[5]==0 || MRR4[2]==1 + val = (clk / 1000000) * 30 / 10 - 1; + psramuhs_mc->REG_04C = + PSRAM_UHS_MC_T_REFI(val) | PSRAM_UHS_MC_NUM_OF_BURST_RFS(0x1000); #ifdef FPGA - clk = 800*1000*1000; + clk = 800 * 1000 * 1000; #endif - // tRC >= 60 ns - val = ((clk / 1000000) * 60 + (1000 - 1)) / 1000; - psramuhs_mc->REG_050 = PSRAM_UHS_MC_T_RC(val); - // tRFC >= 60 ns - val = ((clk / 1000000) * 60 + (1000 - 1)) / 1000; - psramuhs_mc->REG_054 = PSRAM_UHS_MC_T_RFC(val); + // tRC >= 60 ns + val = ((clk / 1000000) * 60 + (1000 - 1)) / 1000; + psramuhs_mc->REG_050 = PSRAM_UHS_MC_T_RC(val); + // tRFC >= 60 ns + val = ((clk / 1000000) * 60 + (1000 - 1)) / 1000; + psramuhs_mc->REG_054 = PSRAM_UHS_MC_T_RFC(val); #ifdef PSRAMUHS_AUTO_PRECHARGE - // tCPHR >= 5 ns (auto precharge) + // tCPHR >= 5 ns (auto precharge) #if PSRAMUHS_SPEED >= 900 - val = ((clk / 1000000) * 5 + (1000 - 1)) / 1000; -#else /*PSRAMUHS_SPEED == 1000*/ - val = 20; + val = ((clk / 1000000) * 5 + (1000 - 1)) / 1000; +#else /*PSRAMUHS_SPEED == 1000*/ + val = 20; #endif /*PSRAMUHS_SPEED == 1000*/ - psramuhs_mc->REG_05C = PSRAM_UHS_MC_T_CPHR_AP(val); + psramuhs_mc->REG_05C = PSRAM_UHS_MC_T_CPHR_AP(val); - // tCPHW >= 30 ns (auto precharge) + // tCPHW >= 30 ns (auto precharge) #if PSRAMUHS_SPEED >= 900 - val = ((clk / 1000000) * 30 + (1000 - 1)) / 1000; -#else /*PSRAMUHS_SPEED == 1000*/ - val = 100; + val = ((clk / 1000000) * 30 + (1000 - 1)) / 1000; +#else /*PSRAMUHS_SPEED == 1000*/ + val = 100; #endif /*PSRAMUHS_SPEED == 1000*/ - psramuhs_mc->REG_064 = PSRAM_UHS_MC_T_CPHW_AP(val); + psramuhs_mc->REG_064 = PSRAM_UHS_MC_T_CPHW_AP(val); #else /*PSRAMUHS_AUTO_PRECHARGE*/ - // tCPHR >= 20 ns (no auto precharge) + // tCPHR >= 20 ns (no auto precharge) #if PSRAMUHS_SPEED >= 900 - val = ((clk / 1000000) * 20 + (1000 - 1)) / 1000; -#else /*PSRAMUHS_SPEED == 1000*/ - val = 20; + val = ((clk / 1000000) * 20 + (1000 - 1)) / 1000; +#else /*PSRAMUHS_SPEED == 1000*/ + val = 20; #endif /*PSRAMUHS_SPEED == 1000*/ - psramuhs_mc->REG_058 = PSRAM_UHS_MC_T_CPHR(val); + psramuhs_mc->REG_058 = PSRAM_UHS_MC_T_CPHR(val); - // tCPHW >= 30 ns (no auto precharge) + // tCPHW >= 30 ns (no auto precharge) #if PSRAMUHS_SPEED >= 900 - val = ((clk / 1000000) * 30 + (1000 - 1)) / 1000; -#else /*PSRAMUHS_SPEED == 1000*/ - val = 100; + val = ((clk / 1000000) * 30 + (1000 - 1)) / 1000; +#else /*PSRAMUHS_SPEED == 1000*/ + val = 100; #endif /*PSRAMUHS_SPEED == 1000*/ - psramuhs_mc->REG_060 = PSRAM_UHS_MC_T_CPHW(val); + psramuhs_mc->REG_060 = PSRAM_UHS_MC_T_CPHW(val); #endif /*PSRAMUHS_AUTO_PRECHARGE*/ - // tMRR >= 20ns - val = 20;//((clk / 1000000) * 20 + (1000 - 1)) / 1000; - psramuhs_mc->REG_068 = PSRAM_UHS_MC_T_MRR(val); - // tMRW >= 100 ns - val = ((clk / 1000000) * 100 + (1000 - 1)) / 1000; - psramuhs_mc->REG_06C = PSRAM_UHS_MC_T_MRS(val); - // tCEM >= 4 cycles - psramuhs_mc->REG_070 = PSRAM_UHS_MC_T_CEM(4); - // tRST >= 10 us - val = (clk / 1000000) * 10; - psramuhs_mc->REG_074 = PSRAM_UHS_MC_T_RST(val); - // tSRF >= 100 ns - val = ((clk / 1000000) + (10 - 1)) / 10; - psramuhs_mc->REG_078 = PSRAM_UHS_MC_T_SRF(val); - // tSRF >= 70 ns - val = ((clk / 1000000) * 70 + (1000 - 1)) / 1000; - psramuhs_mc->REG_07C = PSRAM_UHS_MC_T_XSR(val); - // tHS >= 150 us - val = (clk / 1000000) * 150; - psramuhs_mc->REG_080 = PSRAM_UHS_MC_T_HS(val); - // tXPHS >= 100 ns - val = ((clk / 1000000) + (10 - 1)) / 10; - psramuhs_mc->REG_084 = PSRAM_UHS_MC_T_XPHS(val); - // tXHS >= 150 us - val = (clk / 1000000) * 150; - psramuhs_mc->REG_088 = PSRAM_UHS_MC_T_XHS(val); - // tZQCAL >= 1 us - val = (clk / 1000000) * 1; - psramuhs_mc->REG_08C = PSRAM_UHS_MC_T_ZQCAL(val); - // tZQCRST >= 1 us - val = (clk / 1000000) * 1; - psramuhs_mc->REG_090 = PSRAM_UHS_MC_T_ZQCRST(val); - // NOP dummy cycles, same as tXPHS >= 100 ns - val = ((clk / 1000000) + (10 - 1)) / 10; - psramuhs_mc->REG_0A0 = PSRAM_UHS_MC_STOP_CLK_IN_NOP | PSRAM_UHS_MC_NOP_DMY_CYC(val); - psramuhs_mc->REG_0A4 = PSRAM_UHS_MC_QUEUE_IDLE_CYCLE(50000); - // tDQSCK in [2 ns, 6.5 ns], expanded time >= tDQSCK_MAX - val = ((clk / 1000000) * 65/10 + (1000 - 1)) / 1000; - psramuhs_mc->REG_0A8 = PSRAM_UHS_MC_T_EXPANDRD(val); + // tMRR >= 20ns + val = 20; //((clk / 1000000) * 20 + (1000 - 1)) / 1000; + psramuhs_mc->REG_068 = PSRAM_UHS_MC_T_MRR(val); + // tMRW >= 100 ns + val = ((clk / 1000000) * 100 + (1000 - 1)) / 1000; + psramuhs_mc->REG_06C = PSRAM_UHS_MC_T_MRS(val); + // tCEM >= 4 cycles + psramuhs_mc->REG_070 = PSRAM_UHS_MC_T_CEM(4); + // tRST >= 10 us + val = (clk / 1000000) * 10; + psramuhs_mc->REG_074 = PSRAM_UHS_MC_T_RST(val); + // tSRF >= 100 ns + val = ((clk / 1000000) + (10 - 1)) / 10; + psramuhs_mc->REG_078 = PSRAM_UHS_MC_T_SRF(val); + // tSRF >= 70 ns + val = ((clk / 1000000) * 70 + (1000 - 1)) / 1000; + psramuhs_mc->REG_07C = PSRAM_UHS_MC_T_XSR(val); + // tHS >= 150 us + val = (clk / 1000000) * 150; + psramuhs_mc->REG_080 = PSRAM_UHS_MC_T_HS(val); + // tXPHS >= 100 ns + val = ((clk / 1000000) + (10 - 1)) / 10; + psramuhs_mc->REG_084 = PSRAM_UHS_MC_T_XPHS(val); + // tXHS >= 150 us + val = (clk / 1000000) * 150; + psramuhs_mc->REG_088 = PSRAM_UHS_MC_T_XHS(val); + // tZQCAL >= 1 us + val = (clk / 1000000) * 1; + psramuhs_mc->REG_08C = PSRAM_UHS_MC_T_ZQCAL(val); + // tZQCRST >= 1 us + val = (clk / 1000000) * 1; + psramuhs_mc->REG_090 = PSRAM_UHS_MC_T_ZQCRST(val); + // NOP dummy cycles, same as tXPHS >= 100 ns + val = ((clk / 1000000) + (10 - 1)) / 10; + psramuhs_mc->REG_0A0 = + PSRAM_UHS_MC_STOP_CLK_IN_NOP | PSRAM_UHS_MC_NOP_DMY_CYC(val); + psramuhs_mc->REG_0A4 = PSRAM_UHS_MC_QUEUE_IDLE_CYCLE(50000); + // tDQSCK in [2 ns, 6.5 ns], expanded time >= tDQSCK_MAX + val = ((clk / 1000000) * 65 / 10 + (1000 - 1)) / 1000; + psramuhs_mc->REG_0A8 = PSRAM_UHS_MC_T_EXPANDRD(val); } -static void hal_psramuhs_mc_init(uint32_t clk) -{ - uint32_t val; - uint32_t burst_len; - uint32_t boundary; +static void hal_psramuhs_mc_init(uint32_t clk) { + uint32_t val; + uint32_t burst_len; + uint32_t boundary; - val = PSRAM_UHS_MC_CHIP_TYPE; + val = PSRAM_UHS_MC_CHIP_TYPE; #ifdef PSRAMUHS_DUAL_8BIT - val |= PSRAM_UHS_MC_CHIP_BIT; + val |= PSRAM_UHS_MC_CHIP_BIT; #endif #ifdef PSRAMUHS_DUAL_SWITCH - val |= PSRAM_UHS_MC_CHIP_SWITCH; + val |= PSRAM_UHS_MC_CHIP_SWITCH; #endif #ifdef PSRAMUHS_16BIT - val |= PSRAM_UHS_MC_CHIP_IO_X16 | PSRAM_UHS_MC_CHIP_CA_PATTERN(2); + val |= PSRAM_UHS_MC_CHIP_IO_X16 | PSRAM_UHS_MC_CHIP_CA_PATTERN(2); #else - val |= PSRAM_UHS_MC_CHIP_CA_PATTERN(1); + val |= PSRAM_UHS_MC_CHIP_CA_PATTERN(1); #endif #if (PSRAMUHS_SIZE == 0x800000) - val |= PSRAM_UHS_MC_CHIP_MEM_SIZE(1); + val |= PSRAM_UHS_MC_CHIP_MEM_SIZE(1); #elif (PSRAMUHS_SIZE == 0x1000000) - val |= PSRAM_UHS_MC_CHIP_MEM_SIZE(2); + val |= PSRAM_UHS_MC_CHIP_MEM_SIZE(2); #elif (PSRAMUHS_SIZE == 0x2000000) - val |= PSRAM_UHS_MC_CHIP_MEM_SIZE(3); + val |= PSRAM_UHS_MC_CHIP_MEM_SIZE(3); #else - ASSERT(false, "Bad PSRAMUHS_SIZE=0x%08X", PSRAMUHS_SIZE); + ASSERT(false, "Bad PSRAMUHS_SIZE=0x%08X", PSRAMUHS_SIZE); #endif - psramuhs_mc->REG_000 = val; - psramuhs_mc->REG_024 = PSRAM_UHS_MC_STOP_CLK_IDLE | PSRAM_UHS_MC_AUTOWAKEUP_EN; - // Burst length: 1=32 bytes (Cortex-M) or 2=64 bytes (Cortex-A), Page boundary: 2K bytes + psramuhs_mc->REG_000 = val; + psramuhs_mc->REG_024 = + PSRAM_UHS_MC_STOP_CLK_IDLE | PSRAM_UHS_MC_AUTOWAKEUP_EN; + // Burst length: 1=32 bytes (Cortex-M) or 2=64 bytes (Cortex-A), Page + // boundary: 2K bytes #ifdef PSRAMUHS_WRAP_ENABLE #if defined(__ARM_ARCH_ISA_ARM) || defined(DSP_ENABLE) - burst_len = 0x2;//64B + burst_len = 0x2; // 64B #else - burst_len = 0x1;//32B + burst_len = 0x1; // 32B #endif #else #ifdef PSRAMUHS_DUAL_8BIT - burst_len = 0x6;// 0:16B 5;2KB 6:4KB + burst_len = 0x6; // 0:16B 5;2KB 6:4KB #else - burst_len = 0x5;// 0:16B 5;2KB 6:4KB + burst_len = 0x5; // 0:16B 5;2KB 6:4KB #endif #endif #ifdef PSRAMUHS_DUAL_8BIT - boundary = 2; + boundary = 2; #else - boundary = 1; + boundary = 1; #endif - psramuhs_mc->REG_034 = PSRAM_UHS_MC_BURST_LENGTH(burst_len) | PSRAM_UHS_MC_PAGE_BOUNDARY(boundary); + psramuhs_mc->REG_034 = PSRAM_UHS_MC_BURST_LENGTH(burst_len) | + PSRAM_UHS_MC_PAGE_BOUNDARY(boundary); - // AXI bus width: 128 bits - psramuhs_mc->REG_038 = PSRAM_UHS_MC_BUS_WIDTH; - // Write buffer level with high priority: 0~15 - psramuhs_mc->REG_03C = PSRAM_UHS_MC_HIGH_PRI_LEVEL(8); + // AXI bus width: 128 bits + psramuhs_mc->REG_038 = PSRAM_UHS_MC_BUS_WIDTH; + // Write buffer level with high priority: 0~15 + psramuhs_mc->REG_03C = PSRAM_UHS_MC_HIGH_PRI_LEVEL(8); #ifdef PSRAMUHS_PRA_ENABLE - psramuhs_mc->REG_040 = PSRAM_UHS_MC_PRA_ENABLE | PSRAM_UHS_MC_PRA_MAX_CNT(32); + psramuhs_mc->REG_040 = PSRAM_UHS_MC_PRA_ENABLE | PSRAM_UHS_MC_PRA_MAX_CNT(32); #else #ifdef PSRAMUHS_AUTO_PRECHARGE - psramuhs_mc->REG_040 = PSRAM_UHS_MC_AUTO_PRECHARGE | PSRAM_UHS_MC_PRA_MAX_CNT(32); + psramuhs_mc->REG_040 = + PSRAM_UHS_MC_AUTO_PRECHARGE | PSRAM_UHS_MC_PRA_MAX_CNT(32); #else - psramuhs_mc->REG_040 = PSRAM_UHS_MC_PRA_MAX_CNT(32); + psramuhs_mc->REG_040 = PSRAM_UHS_MC_PRA_MAX_CNT(32); #endif #endif #ifdef PSRAMUHS_WRAP_ENABLE - psramuhs_mc->REG_040 |= PSRAM_UHS_MC_CP_WRAP_EN; + psramuhs_mc->REG_040 |= PSRAM_UHS_MC_CP_WRAP_EN; #endif - psramuhs_mc->REG_048 = PSRAM_UHS_MC_FRE_RATIO(2); + psramuhs_mc->REG_048 = PSRAM_UHS_MC_FRE_RATIO(2); #ifdef PSRAMUHS_DUMMY_CYCLE - psramuhs_mc->REG_840 |= PSRAM_UHS_MC_PHY_DUMMY_CYC_EN; + psramuhs_mc->REG_840 |= PSRAM_UHS_MC_PHY_DUMMY_CYC_EN; #endif #if defined(CHIP_BEST2001) - psramuhs_mc->REG_840 |= PSRAM_UHS_MC_PHY_IDLE_PAD_EN; + psramuhs_mc->REG_840 |= PSRAM_UHS_MC_PHY_IDLE_PAD_EN; #endif - psramuhs_mc->REG_844 = PSRAM_UHS_MC_T_WPST(2); + psramuhs_mc->REG_844 = PSRAM_UHS_MC_T_WPST(2); - hal_psramuhsip_set_reg_fifo_width(); - hal_psramuhsip_set_reg_data_mask(); + hal_psramuhsip_set_reg_fifo_width(); + hal_psramuhsip_set_reg_data_mask(); - hal_psramuhs_mc_set_timing(clk); + hal_psramuhs_mc_set_timing(clk); - psramuhs_mc->REG_400 = PSRAM_UHS_MC_INIT_COMPLETE; + psramuhs_mc->REG_400 = PSRAM_UHS_MC_INIT_COMPLETE; #ifdef PSRAMUHS_DIG_LOOPBACK - psramuhs_mc->REG_840 |= PSRAM_UHS_MC_PHY_LOOPBACK_EN; - psramuhs_mc->REG_044 |= PSRAM_UHS_MC_SNP_DISABLE; + psramuhs_mc->REG_840 |= PSRAM_UHS_MC_PHY_LOOPBACK_EN; + psramuhs_mc->REG_044 |= PSRAM_UHS_MC_SNP_DISABLE; #endif #ifdef PSRAMUHS_ANA_LOOPBACK - psramuhs_mc->REG_044 |= PSRAM_UHS_MC_SNP_DISABLE; - psramuhs_mc->REG_0B0 |= PSRAM_UHS_MC_MGR_FIFO_TEST_EN; - psramuhs_mc->REG_840 |= PSRAM_UHS_MC_ANA_LOOPBACK_EN; + psramuhs_mc->REG_044 |= PSRAM_UHS_MC_SNP_DISABLE; + psramuhs_mc->REG_0B0 |= PSRAM_UHS_MC_MGR_FIFO_TEST_EN; + psramuhs_mc->REG_840 |= PSRAM_UHS_MC_ANA_LOOPBACK_EN; #endif #ifndef FPGA #if !defined(PSRAMUHS_DIG_LOOPBACK) && !defined(PSRAMUHS_ANA_LOOPBACK) - psramuhsphy_init_calib(); + psramuhsphy_init_calib(); #endif #endif - } -void hal_psramuhs_mc_entry_auto_lp() -{ - psramuhs_mc->REG_024 |= PSRAM_UHS_MC_ENTRY_SLEEP_IDLE | PSRAM_UHS_MC_ENTRY_SELF_REFRESH_IDLE; +void hal_psramuhs_mc_entry_auto_lp() { + psramuhs_mc->REG_024 |= + PSRAM_UHS_MC_ENTRY_SLEEP_IDLE | PSRAM_UHS_MC_ENTRY_SELF_REFRESH_IDLE; } -void hal_psramuhs_snoop_enable() -{ - psramuhs_mc->REG_044 &= ~PSRAM_UHS_MC_SNP_DISABLE; +void hal_psramuhs_snoop_enable() { + psramuhs_mc->REG_044 &= ~PSRAM_UHS_MC_SNP_DISABLE; } -void hal_psramuhs_snoop_disable() -{ - psramuhs_mc->REG_044 |= PSRAM_UHS_MC_SNP_DISABLE; +void hal_psramuhs_snoop_disable() { + psramuhs_mc->REG_044 |= PSRAM_UHS_MC_SNP_DISABLE; } -void hal_psramuhs_refresh_enable() -{ +void hal_psramuhs_refresh_enable() { #ifdef PSRAMUHS_BURST_REFRESH - psramuhs_mc->REG_020 = PSRAM_UHS_MC_REFRESH_MODE | PSRAM_UHS_MC_BURST_REFRESH_EN; + psramuhs_mc->REG_020 = + PSRAM_UHS_MC_REFRESH_MODE | PSRAM_UHS_MC_BURST_REFRESH_EN; #else - psramuhs_mc->REG_020 = PSRAM_UHS_MC_REFRESH_MODE; + psramuhs_mc->REG_020 = PSRAM_UHS_MC_REFRESH_MODE; #endif } -void hal_psramuhs_init(void) -{ +void hal_psramuhs_init(void) { #if PSRAMUHS_ENABLE #error "must set MPU befor 2001 eco" #endif - hal_cache_wrap_enable(HAL_CACHE_ID_I_CACHE); - hal_cache_wrap_enable(HAL_CACHE_ID_D_CACHE); + hal_cache_wrap_enable(HAL_CACHE_ID_I_CACHE); + hal_cache_wrap_enable(HAL_CACHE_ID_D_CACHE); - hal_cmu_ddr_clock_enable(); - hal_cmu_clock_enable(HAL_CMU_MOD_O_PSRAMUHS); - hal_cmu_clock_enable(HAL_CMU_MOD_H_PSRAMUHS); - hal_cmu_reset_clear(HAL_CMU_MOD_O_PSRAMUHS); - hal_cmu_reset_clear(HAL_CMU_MOD_H_PSRAMUHS); + hal_cmu_ddr_clock_enable(); + hal_cmu_clock_enable(HAL_CMU_MOD_O_PSRAMUHS); + hal_cmu_clock_enable(HAL_CMU_MOD_H_PSRAMUHS); + hal_cmu_reset_clear(HAL_CMU_MOD_O_PSRAMUHS); + hal_cmu_reset_clear(HAL_CMU_MOD_H_PSRAMUHS); #ifndef FPGA - psramuhsphy_open(psramuhs_run_clk); + psramuhsphy_open(psramuhs_run_clk); #endif - hal_psramuhs_mc_init(psramuhs_run_clk); - psramuhs_start_clock(); - hal_sys_timer_delay_us(3); - psramuhs_reset(); - psramuhs_stop_clock(); - psramuhs_set_timing(psramuhs_run_clk); - hal_psramuhs_refresh_enable(); + hal_psramuhs_mc_init(psramuhs_run_clk); + psramuhs_start_clock(); + hal_sys_timer_delay_us(3); + psramuhs_reset(); + psramuhs_stop_clock(); + psramuhs_set_timing(psramuhs_run_clk); + hal_psramuhs_refresh_enable(); #ifndef FPGA #if !defined(PSRAMUHS_DIG_LOOPBACK) && !defined(PSRAMUHS_ANA_LOOPBACK) - hal_psramuhs_snoop_disable(); - psramuhsphy_calib(psramuhs_run_clk); - hal_psramuhs_snoop_enable(); + hal_psramuhs_snoop_disable(); + psramuhsphy_calib(psramuhs_run_clk); + hal_psramuhs_snoop_enable(); #endif #endif - //hal_psramuhs_mc_entry_auto_lp(); + // hal_psramuhs_mc_entry_auto_lp(); } #endif - diff --git a/platform/hal/hal_pwm.c b/platform/hal/hal_pwm.c index c02c713..54e11a8 100644 --- a/platform/hal/hal_pwm.c +++ b/platform/hal/hal_pwm.c @@ -13,22 +13,22 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_addr_map.h" #include "hal_pwm.h" -#include "reg_pwm.h" #include "cmsis.h" #include "hal_cmu.h" #include "hal_timer.h" #include "hal_trace.h" +#include "plat_addr_map.h" +#include "reg_pwm.h" -#define PWM_SLOW_CLOCK (CONFIG_SYSTICK_HZ) -#define PWM_FAST_CLOCK (hal_cmu_get_crystal_freq() / 2) -#define PWM_MAX_VALUE 0xFFFF +#define PWM_SLOW_CLOCK (CONFIG_SYSTICK_HZ) +#define PWM_FAST_CLOCK (hal_cmu_get_crystal_freq() / 2) +#define PWM_MAX_VALUE 0xFFFF // Max allowed PWM freqency error in percentage -#define PWM_MAX_FREQ_ERR_PCT 5 +#define PWM_MAX_FREQ_ERR_PCT 5 -static struct PWM_T * const pwm[] = { +static struct PWM_T *const pwm[] = { (struct PWM_T *)PWM_BASE, #ifdef CHIP_BEST2000 (struct PWM_T *)AON_PWM_BASE, @@ -49,155 +49,157 @@ static const enum HAL_CMU_MOD_ID_T pwm_p_mod[] = { #endif }; -int hal_pwm_enable(enum HAL_PWM_ID_T id, const struct HAL_PWM_CFG_T *cfg) -{ - uint32_t mod_freq; - uint32_t load; - uint32_t toggle; - uint32_t lock; - uint8_t ratio; - uint8_t index; - uint8_t offset; +int hal_pwm_enable(enum HAL_PWM_ID_T id, const struct HAL_PWM_CFG_T *cfg) { + uint32_t mod_freq; + uint32_t load; + uint32_t toggle; + uint32_t lock; + uint8_t ratio; + uint8_t index; + uint8_t offset; - if (id >= HAL_PWM_ID_QTY) { - return 1; - } - if (cfg->ratio > 100) { - return 2; - } + if (id >= HAL_PWM_ID_QTY) { + return 1; + } + if (cfg->ratio > 100) { + return 2; + } - if (cfg->inv && (cfg->ratio == 0 || cfg->ratio == 100)) { - ratio = 100 - cfg->ratio; - } else { - ratio = cfg->ratio; - } + if (cfg->inv && (cfg->ratio == 0 || cfg->ratio == 100)) { + ratio = 100 - cfg->ratio; + } else { + ratio = cfg->ratio; + } #ifdef PWM_TRY_SLOW_CLOCK + mod_freq = PWM_SLOW_CLOCK; +#else + if (cfg->sleep_on) { mod_freq = PWM_SLOW_CLOCK; -#else - if (cfg->sleep_on) { - mod_freq = PWM_SLOW_CLOCK; - } else { - mod_freq = PWM_FAST_CLOCK; - } + } else { + mod_freq = PWM_FAST_CLOCK; + } #endif - if (ratio == 100) { - load = PWM_MAX_VALUE; - toggle = PWM_MAX_VALUE; - } else if (ratio == 0) { - load = 0; - toggle = 0; - } else { - load = mod_freq / cfg->freq; - toggle = load * ratio / 100; - if (toggle == 0) { - toggle = 1; - } + if (ratio == 100) { + load = PWM_MAX_VALUE; + toggle = PWM_MAX_VALUE; + } else if (ratio == 0) { + load = 0; + toggle = 0; + } else { + load = mod_freq / cfg->freq; + toggle = load * ratio / 100; + if (toggle == 0) { + toggle = 1; + } #ifdef PWM_TRY_SLOW_CLOCK - // Check PWM frequency error in percentage - if (!cfg->sleep_on && ABS((int)(toggle * 100 - load * ratio)) > load * PWM_MAX_FREQ_ERR_PCT) { - mod_freq = PWM_FAST_CLOCK; - load = mod_freq / cfg->freq; - toggle = load * ratio / 100; - } -#endif - load = PWM_MAX_VALUE + 1 - load; - toggle = PWM_MAX_VALUE - toggle; + // Check PWM frequency error in percentage + if (!cfg->sleep_on && + ABS((int)(toggle * 100 - load * ratio)) > load * PWM_MAX_FREQ_ERR_PCT) { + mod_freq = PWM_FAST_CLOCK; + load = mod_freq / cfg->freq; + toggle = load * ratio / 100; } +#endif + load = PWM_MAX_VALUE + 1 - load; + toggle = PWM_MAX_VALUE - toggle; + } #ifdef CHIP_BEST2000 - if (id < HAL_PWM2_ID_0) { - index = 0; - offset = id - HAL_PWM_ID_0; - } else { - index = 1; - offset = id - HAL_PWM2_ID_0; - } -#else + if (id < HAL_PWM2_ID_0) { index = 0; offset = id - HAL_PWM_ID_0; -#endif - - if (hal_cmu_reset_get_status(pwm_o_mod[index] + offset) == HAL_CMU_RST_SET) { - hal_cmu_clock_enable(pwm_o_mod[index] + offset); - hal_cmu_clock_enable(pwm_p_mod[index]); - hal_cmu_reset_clear(pwm_o_mod[index] + offset); - hal_cmu_reset_clear(pwm_p_mod[index]); - } else { - pwm[index]->EN &= ~(1 << offset); - } - - if (ratio == 0) { - // Output 0 when disabled - return 0; - } - - hal_cmu_pwm_set_freq(id, mod_freq); - - lock = int_lock(); - - if (offset == 0) { - pwm[index]->LOAD01 = SET_BITFIELD(pwm[index]->LOAD01, PWM_LOAD01_0, load); - pwm[index]->TOGGLE01 = SET_BITFIELD(pwm[index]->TOGGLE01, PWM_TOGGLE01_0, toggle); - } else if (offset == 1) { - pwm[index]->LOAD01 = SET_BITFIELD(pwm[index]->LOAD01, PWM_LOAD01_1, load); - pwm[index]->TOGGLE01 = SET_BITFIELD(pwm[index]->TOGGLE01, PWM_TOGGLE01_1, toggle); - } else if (offset == 2) { - pwm[index]->LOAD23 = SET_BITFIELD(pwm[index]->LOAD23, PWM_LOAD23_2, load); - pwm[index]->TOGGLE23 = SET_BITFIELD(pwm[index]->TOGGLE23, PWM_TOGGLE23_2, toggle); - } else { - pwm[index]->LOAD23 = SET_BITFIELD(pwm[index]->LOAD23, PWM_LOAD23_3, load); - pwm[index]->TOGGLE23 = SET_BITFIELD(pwm[index]->TOGGLE23, PWM_TOGGLE23_3, toggle); - } - - if (cfg->inv) { - pwm[index]->INV |= (1 << offset); - } else { - pwm[index]->INV &= ~(1 << offset); - } - - pwm[index]->EN |= (1 << offset); - - int_unlock(lock); - - return 0; -} - -int hal_pwm_disable(enum HAL_PWM_ID_T id) -{ - uint8_t index; - uint8_t offset; - - if (id >= HAL_PWM_ID_QTY) { - return 1; - } - -#ifdef CHIP_BEST2000 - if (id < HAL_PWM2_ID_0) { - index = 0; - offset = id - HAL_PWM_ID_0; - } else { - index = 1; - offset = id - HAL_PWM2_ID_0; - } + } else { + index = 1; + offset = id - HAL_PWM2_ID_0; + } #else - index = 0; - offset = id - HAL_PWM_ID_0; + index = 0; + offset = id - HAL_PWM_ID_0; #endif - if (hal_cmu_reset_get_status(pwm_o_mod[index] + offset) == HAL_CMU_RST_SET) { - return 0; - } - + if (hal_cmu_reset_get_status(pwm_o_mod[index] + offset) == HAL_CMU_RST_SET) { + hal_cmu_clock_enable(pwm_o_mod[index] + offset); + hal_cmu_clock_enable(pwm_p_mod[index]); + hal_cmu_reset_clear(pwm_o_mod[index] + offset); + hal_cmu_reset_clear(pwm_p_mod[index]); + } else { pwm[index]->EN &= ~(1 << offset); - hal_cmu_reset_set(pwm_o_mod[index] + offset); - hal_cmu_clock_disable(pwm_o_mod[index] + offset); - if (pwm[index]->EN == 0) { - hal_cmu_reset_set(pwm_p_mod[index]); - hal_cmu_clock_disable(pwm_p_mod[index]); - } + } + if (ratio == 0) { + // Output 0 when disabled return 0; + } + + hal_cmu_pwm_set_freq(id, mod_freq); + + lock = int_lock(); + + if (offset == 0) { + pwm[index]->LOAD01 = SET_BITFIELD(pwm[index]->LOAD01, PWM_LOAD01_0, load); + pwm[index]->TOGGLE01 = + SET_BITFIELD(pwm[index]->TOGGLE01, PWM_TOGGLE01_0, toggle); + } else if (offset == 1) { + pwm[index]->LOAD01 = SET_BITFIELD(pwm[index]->LOAD01, PWM_LOAD01_1, load); + pwm[index]->TOGGLE01 = + SET_BITFIELD(pwm[index]->TOGGLE01, PWM_TOGGLE01_1, toggle); + } else if (offset == 2) { + pwm[index]->LOAD23 = SET_BITFIELD(pwm[index]->LOAD23, PWM_LOAD23_2, load); + pwm[index]->TOGGLE23 = + SET_BITFIELD(pwm[index]->TOGGLE23, PWM_TOGGLE23_2, toggle); + } else { + pwm[index]->LOAD23 = SET_BITFIELD(pwm[index]->LOAD23, PWM_LOAD23_3, load); + pwm[index]->TOGGLE23 = + SET_BITFIELD(pwm[index]->TOGGLE23, PWM_TOGGLE23_3, toggle); + } + + if (cfg->inv) { + pwm[index]->INV |= (1 << offset); + } else { + pwm[index]->INV &= ~(1 << offset); + } + + pwm[index]->EN |= (1 << offset); + + int_unlock(lock); + + return 0; } +int hal_pwm_disable(enum HAL_PWM_ID_T id) { + uint8_t index; + uint8_t offset; + + if (id >= HAL_PWM_ID_QTY) { + return 1; + } + +#ifdef CHIP_BEST2000 + if (id < HAL_PWM2_ID_0) { + index = 0; + offset = id - HAL_PWM_ID_0; + } else { + index = 1; + offset = id - HAL_PWM2_ID_0; + } +#else + index = 0; + offset = id - HAL_PWM_ID_0; +#endif + + if (hal_cmu_reset_get_status(pwm_o_mod[index] + offset) == HAL_CMU_RST_SET) { + return 0; + } + + pwm[index]->EN &= ~(1 << offset); + hal_cmu_reset_set(pwm_o_mod[index] + offset); + hal_cmu_clock_disable(pwm_o_mod[index] + offset); + if (pwm[index]->EN == 0) { + hal_cmu_reset_set(pwm_p_mod[index]); + hal_cmu_clock_disable(pwm_p_mod[index]); + } + + return 0; +} diff --git a/platform/hal/hal_rtc.c b/platform/hal/hal_rtc.c index 1851b0f..91de6c8 100644 --- a/platform/hal/hal_rtc.c +++ b/platform/hal/hal_rtc.c @@ -15,105 +15,94 @@ ****************************************************************************/ #ifdef CHIP_HAS_DIG_RTC -#include "plat_addr_map.h" #include "hal_rtc.h" +#include "plat_addr_map.h" #include "reg_rtc.h" static HAL_RTC_IRQ_HANDLER_T irq_handler = NULL; -static struct RTC_T * const rtc = (struct RTC_T *)RTC_BASE; +static struct RTC_T *const rtc = (struct RTC_T *)RTC_BASE; -static const unsigned char rtc_days_in_month[] = { - 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 -}; +static const unsigned char rtc_days_in_month[] = {31, 28, 31, 30, 31, 30, + 31, 31, 30, 31, 30, 31}; static const unsigned short rtc_ydays[2][13] = { /* Normal years */ - { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, + {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, /* Leap years */ - { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } -}; + {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}}; -#define LEAPS_THRU_END_OF(y) ((y)/4 - (y)/100 + (y)/400) +#define LEAPS_THRU_END_OF(y) ((y) / 4 - (y) / 100 + (y) / 400) -static inline int is_leap_year(unsigned int year) -{ - return (!(year % 4) && (year % 100)) || !(year % 400); +static inline int is_leap_year(unsigned int year) { + return (!(year % 4) && (year % 100)) || !(year % 400); } /* * The number of days in the month. */ -int rtc_month_days(unsigned int month, unsigned int year) -{ - return rtc_days_in_month[month] + (is_leap_year(year) && month == 1); +int rtc_month_days(unsigned int month, unsigned int year) { + return rtc_days_in_month[month] + (is_leap_year(year) && month == 1); } /* * The number of days since January 1. (0 to 365) */ -int rtc_year_days(unsigned int day, unsigned int month, unsigned int year) -{ - return rtc_ydays[is_leap_year(year)][month] + day-1; +int rtc_year_days(unsigned int day, unsigned int month, unsigned int year) { + return rtc_ydays[is_leap_year(year)][month] + day - 1; } /* * Convert seconds since 01-01-1970 00:00:00 to Gregorian date. */ -void rtc_time_to_tm(unsigned long time, struct rtc_time *tm) -{ - unsigned int month, year; - int days; +void rtc_time_to_tm(unsigned long time, struct rtc_time *tm) { + unsigned int month, year; + int days; - days = time / 86400; - time -= (unsigned int) days * 86400; + days = time / 86400; + time -= (unsigned int)days * 86400; - /* day of the week, 1970-01-01 was a Thursday */ - //tm->tm_wday = (days + 4) % 7; + /* day of the week, 1970-01-01 was a Thursday */ + // tm->tm_wday = (days + 4) % 7; - year = 1970 + days / 365; - days -= (year - 1970) * 365 - + LEAPS_THRU_END_OF(year - 1) - - LEAPS_THRU_END_OF(1970 - 1); - if (days < 0) { - year -= 1; - days += 365 + is_leap_year(year); - } - tm->tm_year = year - 1900; - //tm->tm_yday = days + 1; + year = 1970 + days / 365; + days -= (year - 1970) * 365 + LEAPS_THRU_END_OF(year - 1) - + LEAPS_THRU_END_OF(1970 - 1); + if (days < 0) { + year -= 1; + days += 365 + is_leap_year(year); + } + tm->tm_year = year - 1900; + // tm->tm_yday = days + 1; - for (month = 0; month < 11; month++) { - int newdays; + for (month = 0; month < 11; month++) { + int newdays; - newdays = days - rtc_month_days(month, year); - if (newdays < 0) - break; - days = newdays; - } - tm->tm_mon = month; - tm->tm_mday = days + 1; + newdays = days - rtc_month_days(month, year); + if (newdays < 0) + break; + days = newdays; + } + tm->tm_mon = month; + tm->tm_mday = days + 1; - tm->tm_hour = time / 3600; - time -= tm->tm_hour * 3600; - tm->tm_min = time / 60; - tm->tm_sec = time - tm->tm_min * 60; + tm->tm_hour = time / 3600; + time -= tm->tm_hour * 3600; + tm->tm_min = time / 60; + tm->tm_sec = time - tm->tm_min * 60; } /* * Does the rtc_time represent a valid date/time? */ -int rtc_valid_tm(struct rtc_time *tm) -{ - if (tm->tm_year < 70 - || ((unsigned)tm->tm_mon) >= 12 - || tm->tm_mday < 1 - || tm->tm_mday > rtc_month_days(tm->tm_mon, tm->tm_year + 1900) - || ((unsigned)tm->tm_hour) >= 24 - || ((unsigned)tm->tm_min) >= 60 - || ((unsigned)tm->tm_sec) >= 60) - return -1; +int rtc_valid_tm(struct rtc_time *tm) { + if (tm->tm_year < 70 || ((unsigned)tm->tm_mon) >= 12 || tm->tm_mday < 1 || + tm->tm_mday > rtc_month_days(tm->tm_mon, tm->tm_year + 1900) || + ((unsigned)tm->tm_hour) >= 24 || ((unsigned)tm->tm_min) >= 60 || + ((unsigned)tm->tm_sec) >= 60) + return -1; - return 0; + return 0; } /* Converts Gregorian date to seconds since 1970-01-01 00:00:00. @@ -131,116 +120,110 @@ int rtc_valid_tm(struct rtc_time *tm) * machines where long is 32-bit! (However, as time_t is signed, we * will already get problems at other places on 2038-01-19 03:14:08) */ -unsigned long -mktime(const unsigned int year0, const unsigned int mon0, - const unsigned int day, const unsigned int hour, - const unsigned int min, const unsigned int sec) -{ - unsigned int mon = mon0, year = year0; +unsigned long mktime(const unsigned int year0, const unsigned int mon0, + const unsigned int day, const unsigned int hour, + const unsigned int min, const unsigned int sec) { + unsigned int mon = mon0, year = year0; - /* 1..12 -> 11,12,1..10 */ - if (0 >= (int) (mon -= 2)) { - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } + /* 1..12 -> 11,12,1..10 */ + if (0 >= (int)(mon -= 2)) { + mon += 12; /* Puts Feb last since it has leap day */ + year -= 1; + } - return ((((unsigned long) - (year/4 - year/100 + year/400 + 367*mon/12 + day) + - year*365 - 719499 - )*24 + hour /* now have hours */ - )*60 + min /* now have minutes */ - )*60 + sec; /* finally seconds */ + return ((((unsigned long)(year / 4 - year / 100 + year / 400 + + 367 * mon / 12 + day) + + year * 365 - 719499) * + 24 + + hour /* now have hours */ + ) * 60 + + min /* now have minutes */ + ) * 60 + + sec; /* finally seconds */ } /* * Convert Gregorian date to seconds since 01-01-1970 00:00:00. */ -int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time) -{ - *time = mktime(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec); - return 0; +int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time) { + *time = mktime(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, + tm->tm_min, tm->tm_sec); + return 0; } -int hal_rtc_get(struct rtc_time *time) -{ - unsigned long value; +int hal_rtc_get(struct rtc_time *time) { + unsigned long value; - if ((rtc->RTCCR & RTC_CR_EN) == 0) { - return 1; - } + if ((rtc->RTCCR & RTC_CR_EN) == 0) { + return 1; + } - value = rtc->RTCDR; - rtc_tm_to_time(time, &value); - return 0; + value = rtc->RTCDR; + rtc_tm_to_time(time, &value); + return 0; } -int hal_rtc_set(struct rtc_time *time) -{ - unsigned long value; +int hal_rtc_set(struct rtc_time *time) { + unsigned long value; - if (rtc_valid_tm(time) != 0) { - return 1; - } + if (rtc_valid_tm(time) != 0) { + return 1; + } - if ((rtc->RTCCR & RTC_CR_EN) == 0) { - rtc->RTCCR = RTC_CR_EN; - } + if ((rtc->RTCCR & RTC_CR_EN) == 0) { + rtc->RTCCR = RTC_CR_EN; + } - rtc_tm_to_time(time, &value); - rtc->RTCLR = value; - return 0; + rtc_tm_to_time(time, &value); + rtc->RTCLR = value; + return 0; } -int hal_rtc_set_alarm(struct rtc_time *time) -{ - unsigned long value; +int hal_rtc_set_alarm(struct rtc_time *time) { + unsigned long value; - if (rtc_valid_tm(time) != 0) { - return 1; - } + if (rtc_valid_tm(time) != 0) { + return 1; + } - if ((rtc->RTCCR & RTC_CR_EN) == 0) { - return 1; - } + if ((rtc->RTCCR & RTC_CR_EN) == 0) { + return 1; + } - rtc_tm_to_time(time, &value); - rtc->RTCMR = value; + rtc_tm_to_time(time, &value); + rtc->RTCMR = value; + rtc->RTCICR = RTC_BIT_AI; + rtc->RTCIMSC = RTC_BIT_AI; + return 0; +} + +int hal_rtc_clear_alarm(void) { + rtc->RTCIMSC = 0; + rtc->RTCICR = RTC_BIT_AI; + return 0; +} + +HAL_RTC_IRQ_HANDLER_T hal_rtc_set_irq_handler(HAL_RTC_IRQ_HANDLER_T handler) { + HAL_RTC_IRQ_HANDLER_T old_handler; + + old_handler = irq_handler; + irq_handler = handler; + return old_handler; +} + +void RTC_IRQHandler(void) { + uint32_t value; + struct rtc_time time; + + if ((rtc->RTCMIS & RTC_BIT_AI) != 0) { rtc->RTCICR = RTC_BIT_AI; - rtc->RTCIMSC = RTC_BIT_AI; - return 0; -} -int hal_rtc_clear_alarm(void) -{ - rtc->RTCIMSC = 0; - rtc->RTCICR = RTC_BIT_AI; - return 0; -} - -HAL_RTC_IRQ_HANDLER_T hal_rtc_set_irq_handler(HAL_RTC_IRQ_HANDLER_T handler) -{ - HAL_RTC_IRQ_HANDLER_T old_handler; - - old_handler = irq_handler; - irq_handler = handler; - return old_handler; -} - -void RTC_IRQHandler(void) -{ - uint32_t value; - struct rtc_time time; - - if ((rtc->RTCMIS & RTC_BIT_AI) != 0) { - rtc->RTCICR = RTC_BIT_AI; - - if (irq_handler != NULL) { - value = rtc->RTCDR; - rtc_time_to_tm(value, &time); - irq_handler(&time); - } + if (irq_handler != NULL) { + value = rtc->RTCDR; + rtc_time_to_tm(value, &time); + irq_handler(&time); } + } } #endif // CHIP_HAS_DIG_RTC diff --git a/platform/hal/hal_sdmmc.c b/platform/hal/hal_sdmmc.c index 7d87402..55067e8 100644 --- a/platform/hal/hal_sdmmc.c +++ b/platform/hal/hal_sdmmc.c @@ -15,22 +15,22 @@ ****************************************************************************/ #ifdef CHIP_HAS_SDMMC +#include "hal_sdmmc.h" +#include "cmsis_nvic.h" #include "errno.h" +#include "hal_cmu.h" +#include "hal_dma.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "plat_addr_map.h" +#include "reg_sdmmcip.h" #include "stdarg.h" #include "stdio.h" #include "string.h" -#include "plat_addr_map.h" -#include "reg_sdmmcip.h" -#include "hal_sdmmc.h" -#include "cmsis_nvic.h" -#include "hal_uart.h" -#include "hal_trace.h" -#include "hal_dma.h" -#include "hal_timer.h" -#include "hal_cmu.h" #ifndef ETIMEDOUT -#define ETIMEDOUT 110 /* Connection timed out */ +#define ETIMEDOUT 110 /* Connection timed out */ #endif #define HAL_SDMMC_USE_DMA 1 @@ -45,467 +45,463 @@ #define _SDMMC_DMA_MINALIGN 32 -#define _sdmmc_be32_to_cpu(x) \ - ((uint32_t)( \ - (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \ - (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \ - (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \ - (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24) )) +#define _sdmmc_be32_to_cpu(x) \ + ((uint32_t)((((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \ + (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \ + (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \ + (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24))) -#define _SDMMC_DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) -#define _SDMMC_ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1)) +#define _SDMMC_DIV_ROUND_UP(n, d) (((n) + (d)-1) / (d)) +#define _SDMMC_ROUND(a, b) (((a) + (b)-1) & ~((b)-1)) -#define _SDMMC_PAD_COUNT(s, pad) (((s) - 1) / (pad) + 1) +#define _SDMMC_PAD_COUNT(s, pad) (((s)-1) / (pad) + 1) #define _SDMMC_PAD_SIZE(s, pad) (_SDMMC_PAD_COUNT(s, pad) * pad) -#define _SDMMC_ALLOC_ALIGN_BUFFER_PAD(type, name, size, align, pad) \ - char __##name[_SDMMC_ROUND(_SDMMC_PAD_SIZE((size) * sizeof(type), pad), align) + (align - 1)]; \ - type *name = (type *) ALIGN((uint32_t)__##name, align) +#define _SDMMC_ALLOC_ALIGN_BUFFER_PAD(type, name, size, align, pad) \ + char __##name[_SDMMC_ROUND(_SDMMC_PAD_SIZE((size) * sizeof(type), pad), \ + align) + \ + (align - 1)]; \ + type *name = (type *)ALIGN((uint32_t)__##name, align) -#define _SDMMC_ALLOC_ALIGN_BUFFER(type, name, size, align) \ - _SDMMC_ALLOC_ALIGN_BUFFER_PAD(type, name, size, align, 1) -#define _SDMMC_ALLOC_CACHE_ALIGN_BUFFER_PAD(type, name, size, pad) \ - _SDMMC_ALLOC_ALIGN_BUFFER_PAD(type, name, size, _SDMMC_DMA_MINALIGN, pad) -#define _SDMMC_ALLOC_CACHE_ALIGN_BUFFER(type, name, size) \ - _SDMMC_ALLOC_ALIGN_BUFFER(type, name, size, _SDMMC_DMA_MINALIGN) +#define _SDMMC_ALLOC_ALIGN_BUFFER(type, name, size, align) \ + _SDMMC_ALLOC_ALIGN_BUFFER_PAD(type, name, size, align, 1) +#define _SDMMC_ALLOC_CACHE_ALIGN_BUFFER_PAD(type, name, size, pad) \ + _SDMMC_ALLOC_ALIGN_BUFFER_PAD(type, name, size, _SDMMC_DMA_MINALIGN, pad) +#define _SDMMC_ALLOC_CACHE_ALIGN_BUFFER(type, name, size) \ + _SDMMC_ALLOC_ALIGN_BUFFER(type, name, size, _SDMMC_DMA_MINALIGN) typedef struct block_dev_desc { - int if_type; /* type of the interface */ - int dev; /* device number */ - unsigned char part_type; /* partition type */ - unsigned char target; /* target SCSI ID */ - unsigned char lun; /* target LUN */ - unsigned char type; /* device type */ - unsigned char removable; /* removable device */ + int if_type; /* type of the interface */ + int dev; /* device number */ + unsigned char part_type; /* partition type */ + unsigned char target; /* target SCSI ID */ + unsigned char lun; /* target LUN */ + unsigned char type; /* device type */ + unsigned char removable; /* removable device */ #ifdef CONFIG_LBA48 - unsigned char lba48; /* device can use 48bit addr (ATA/ATAPI v7) */ + unsigned char lba48; /* device can use 48bit addr (ATA/ATAPI v7) */ #endif - uint32_t lba; /* number of blocks */ - unsigned long blksz; /* block size */ - int log2blksz; /* for convenience: log2(blksz) */ - char vendor [40+1]; /* IDE model, SCSI Vendor */ - char product[20+1]; /* IDE Serial no, SCSI product */ - char revision[8+1]; /* firmware revision */ - void *priv; /* driver private struct pointer */ + uint32_t lba; /* number of blocks */ + unsigned long blksz; /* block size */ + int log2blksz; /* for convenience: log2(blksz) */ + char vendor[40 + 1]; /* IDE model, SCSI Vendor */ + char product[20 + 1]; /* IDE Serial no, SCSI product */ + char revision[8 + 1]; /* firmware revision */ + void *priv; /* driver private struct pointer */ } block_dev_desc_t; /* SD/MMC version bits; 8 flags, 8 major, 8 minor, 8 change */ -#define SD_VERSION_SD (1U << 31) +#define SD_VERSION_SD (1U << 31) #define MMC_VERSION_MMC (1U << 30) -#define MAKE_SDMMC_VERSION(a, b, c) \ - ((((uint32_t)(a)) << 16) | ((uint32_t)(b) << 8) | (uint32_t)(c)) -#define MAKE_SD_VERSION(a, b, c) \ - (SD_VERSION_SD | MAKE_SDMMC_VERSION(a, b, c)) -#define MAKE_MMC_VERSION(a, b, c) \ - (MMC_VERSION_MMC | MAKE_SDMMC_VERSION(a, b, c)) +#define MAKE_SDMMC_VERSION(a, b, c) \ + ((((uint32_t)(a)) << 16) | ((uint32_t)(b) << 8) | (uint32_t)(c)) +#define MAKE_SD_VERSION(a, b, c) (SD_VERSION_SD | MAKE_SDMMC_VERSION(a, b, c)) +#define MAKE_MMC_VERSION(a, b, c) \ + (MMC_VERSION_MMC | MAKE_SDMMC_VERSION(a, b, c)) -#define EXTRACT_SDMMC_MAJOR_VERSION(x) \ - (((uint32_t)(x) >> 16) & 0xff) -#define EXTRACT_SDMMC_MINOR_VERSION(x) \ - (((uint32_t)(x) >> 8) & 0xff) -#define EXTRACT_SDMMC_CHANGE_VERSION(x) \ - ((uint32_t)(x) & 0xff) +#define EXTRACT_SDMMC_MAJOR_VERSION(x) (((uint32_t)(x) >> 16) & 0xff) +#define EXTRACT_SDMMC_MINOR_VERSION(x) (((uint32_t)(x) >> 8) & 0xff) +#define EXTRACT_SDMMC_CHANGE_VERSION(x) ((uint32_t)(x)&0xff) -#define SD_VERSION_3 MAKE_SD_VERSION(3, 0, 0) -#define SD_VERSION_2 MAKE_SD_VERSION(2, 0, 0) -#define SD_VERSION_1_0 MAKE_SD_VERSION(1, 0, 0) -#define SD_VERSION_1_10 MAKE_SD_VERSION(1, 10, 0) +#define SD_VERSION_3 MAKE_SD_VERSION(3, 0, 0) +#define SD_VERSION_2 MAKE_SD_VERSION(2, 0, 0) +#define SD_VERSION_1_0 MAKE_SD_VERSION(1, 0, 0) +#define SD_VERSION_1_10 MAKE_SD_VERSION(1, 10, 0) #define MMC_VERSION_UNKNOWN MAKE_MMC_VERSION(0, 0, 0) -#define MMC_VERSION_1_2 MAKE_MMC_VERSION(1, 2, 0) -#define MMC_VERSION_1_4 MAKE_MMC_VERSION(1, 4, 0) -#define MMC_VERSION_2_2 MAKE_MMC_VERSION(2, 2, 0) -#define MMC_VERSION_3 MAKE_MMC_VERSION(3, 0, 0) -#define MMC_VERSION_4 MAKE_MMC_VERSION(4, 0, 0) -#define MMC_VERSION_4_1 MAKE_MMC_VERSION(4, 1, 0) -#define MMC_VERSION_4_2 MAKE_MMC_VERSION(4, 2, 0) -#define MMC_VERSION_4_3 MAKE_MMC_VERSION(4, 3, 0) -#define MMC_VERSION_4_41 MAKE_MMC_VERSION(4, 4, 1) -#define MMC_VERSION_4_5 MAKE_MMC_VERSION(4, 5, 0) -#define MMC_VERSION_5_0 MAKE_MMC_VERSION(5, 0, 0) +#define MMC_VERSION_1_2 MAKE_MMC_VERSION(1, 2, 0) +#define MMC_VERSION_1_4 MAKE_MMC_VERSION(1, 4, 0) +#define MMC_VERSION_2_2 MAKE_MMC_VERSION(2, 2, 0) +#define MMC_VERSION_3 MAKE_MMC_VERSION(3, 0, 0) +#define MMC_VERSION_4 MAKE_MMC_VERSION(4, 0, 0) +#define MMC_VERSION_4_1 MAKE_MMC_VERSION(4, 1, 0) +#define MMC_VERSION_4_2 MAKE_MMC_VERSION(4, 2, 0) +#define MMC_VERSION_4_3 MAKE_MMC_VERSION(4, 3, 0) +#define MMC_VERSION_4_41 MAKE_MMC_VERSION(4, 4, 1) +#define MMC_VERSION_4_5 MAKE_MMC_VERSION(4, 5, 0) +#define MMC_VERSION_5_0 MAKE_MMC_VERSION(5, 0, 0) -#define MMC_MODE_HS (1 << 0) -#define MMC_MODE_HS_52MHz (1 << 1) -#define MMC_MODE_4BIT (1 << 2) -#define MMC_MODE_8BIT (1 << 3) -#define MMC_MODE_SPI (1 << 4) -#define MMC_MODE_DDR_52MHz (1 << 5) +#define MMC_MODE_HS (1 << 0) +#define MMC_MODE_HS_52MHz (1 << 1) +#define MMC_MODE_4BIT (1 << 2) +#define MMC_MODE_8BIT (1 << 3) +#define MMC_MODE_SPI (1 << 4) +#define MMC_MODE_DDR_52MHz (1 << 5) -#define SD_DATA_4BIT 0x00040000 +#define SD_DATA_4BIT 0x00040000 -#define IS_SD(x) ((x)->version & SD_VERSION_SD) -#define IS_MMC(x) ((x)->version & MMC_VERSION_MMC) +#define IS_SD(x) ((x)->version & SD_VERSION_SD) +#define IS_MMC(x) ((x)->version & MMC_VERSION_MMC) -#define MMC_DATA_READ 1 -#define MMC_DATA_WRITE 2 +#define MMC_DATA_READ 1 +#define MMC_DATA_WRITE 2 -#define NO_CARD_ERR -16 /* No SD/MMC card inserted */ -#define UNUSABLE_ERR -17 /* Unusable Card */ -#define COMM_ERR -18 /* Communications Error */ -#define TIMEOUT -19 -#define SWITCH_ERR -20 /* Card reports failure to switch mode */ +#define NO_CARD_ERR -16 /* No SD/MMC card inserted */ +#define UNUSABLE_ERR -17 /* Unusable Card */ +#define COMM_ERR -18 /* Communications Error */ +#define TIMEOUT -19 +#define SWITCH_ERR -20 /* Card reports failure to switch mode */ -#define MMC_CMD_GO_IDLE_STATE 0 -#define MMC_CMD_SEND_OP_COND 1 -#define MMC_CMD_ALL_SEND_CID 2 -#define MMC_CMD_SET_RELATIVE_ADDR 3 -#define MMC_CMD_SET_DSR 4 -#define MMC_CMD_SWITCH 6 -#define MMC_CMD_SELECT_CARD 7 -#define MMC_CMD_SEND_EXT_CSD 8 -#define MMC_CMD_SEND_CSD 9 -#define MMC_CMD_SEND_CID 10 -#define MMC_CMD_STOP_TRANSMISSION 12 -#define MMC_CMD_SEND_STATUS 13 -#define MMC_CMD_SET_BLOCKLEN 16 -#define MMC_CMD_READ_SINGLE_BLOCK 17 +#define MMC_CMD_GO_IDLE_STATE 0 +#define MMC_CMD_SEND_OP_COND 1 +#define MMC_CMD_ALL_SEND_CID 2 +#define MMC_CMD_SET_RELATIVE_ADDR 3 +#define MMC_CMD_SET_DSR 4 +#define MMC_CMD_SWITCH 6 +#define MMC_CMD_SELECT_CARD 7 +#define MMC_CMD_SEND_EXT_CSD 8 +#define MMC_CMD_SEND_CSD 9 +#define MMC_CMD_SEND_CID 10 +#define MMC_CMD_STOP_TRANSMISSION 12 +#define MMC_CMD_SEND_STATUS 13 +#define MMC_CMD_SET_BLOCKLEN 16 +#define MMC_CMD_READ_SINGLE_BLOCK 17 #define MMC_CMD_READ_MULTIPLE_BLOCK 18 -#define MMC_CMD_SET_BLOCK_COUNT 23 -#define MMC_CMD_WRITE_SINGLE_BLOCK 24 -#define MMC_CMD_WRITE_MULTIPLE_BLOCK 25 -#define MMC_CMD_ERASE_GROUP_START 35 -#define MMC_CMD_ERASE_GROUP_END 36 -#define MMC_CMD_ERASE 38 -#define MMC_CMD_APP_CMD 55 -#define MMC_CMD_SPI_READ_OCR 58 -#define MMC_CMD_SPI_CRC_ON_OFF 59 -#define MMC_CMD_RES_MAN 62 +#define MMC_CMD_SET_BLOCK_COUNT 23 +#define MMC_CMD_WRITE_SINGLE_BLOCK 24 +#define MMC_CMD_WRITE_MULTIPLE_BLOCK 25 +#define MMC_CMD_ERASE_GROUP_START 35 +#define MMC_CMD_ERASE_GROUP_END 36 +#define MMC_CMD_ERASE 38 +#define MMC_CMD_APP_CMD 55 +#define MMC_CMD_SPI_READ_OCR 58 +#define MMC_CMD_SPI_CRC_ON_OFF 59 +#define MMC_CMD_RES_MAN 62 -#define MMC_CMD62_ARG1 0xefac62ec -#define MMC_CMD62_ARG2 0xcbaea7 +#define MMC_CMD62_ARG1 0xefac62ec +#define MMC_CMD62_ARG2 0xcbaea7 +#define SD_CMD_SEND_RELATIVE_ADDR 3 +#define SD_CMD_SWITCH_FUNC 6 +#define SD_CMD_SEND_IF_COND 8 +#define SD_CMD_SWITCH_UHS18V 11 -#define SD_CMD_SEND_RELATIVE_ADDR 3 -#define SD_CMD_SWITCH_FUNC 6 -#define SD_CMD_SEND_IF_COND 8 -#define SD_CMD_SWITCH_UHS18V 11 - -#define SD_CMD_APP_SET_BUS_WIDTH 6 -#define SD_CMD_ERASE_WR_BLK_START 32 -#define SD_CMD_ERASE_WR_BLK_END 33 -#define SD_CMD_APP_SEND_OP_COND 41 -#define SD_CMD_APP_SEND_SCR 51 +#define SD_CMD_APP_SET_BUS_WIDTH 6 +#define SD_CMD_ERASE_WR_BLK_START 32 +#define SD_CMD_ERASE_WR_BLK_END 33 +#define SD_CMD_APP_SEND_OP_COND 41 +#define SD_CMD_APP_SEND_SCR 51 /* SCR definitions in different words */ -#define SD_HIGHSPEED_BUSY 0x00020000 -#define SD_HIGHSPEED_SUPPORTED 0x00020000 +#define SD_HIGHSPEED_BUSY 0x00020000 +#define SD_HIGHSPEED_SUPPORTED 0x00020000 -#define OCR_BUSY 0x80000000 -#define OCR_HCS 0x40000000 -#define OCR_VOLTAGE_MASK 0x007FFF80 -#define OCR_ACCESS_MODE 0x60000000 +#define OCR_BUSY 0x80000000 +#define OCR_HCS 0x40000000 +#define OCR_VOLTAGE_MASK 0x007FFF80 +#define OCR_ACCESS_MODE 0x60000000 -#define SECURE_ERASE 0x80000000 +#define SECURE_ERASE 0x80000000 -#define MMC_STATUS_MASK (~0x0206BF7F) +#define MMC_STATUS_MASK (~0x0206BF7F) #define MMC_STATUS_SWITCH_ERROR (1 << 7) #define MMC_STATUS_RDY_FOR_DATA (1 << 8) -#define MMC_STATUS_CURR_STATE (0xf << 9) -#define MMC_STATUS_ERROR (1 << 19) +#define MMC_STATUS_CURR_STATE (0xf << 9) +#define MMC_STATUS_ERROR (1 << 19) -#define MMC_STATE_PRG (7 << 9) +#define MMC_STATE_PRG (7 << 9) -#define MMC_VDD_165_195 0x00000080 /* VDD voltage 1.65 - 1.95 */ -#define MMC_VDD_20_21 0x00000100 /* VDD voltage 2.0 ~ 2.1 */ -#define MMC_VDD_21_22 0x00000200 /* VDD voltage 2.1 ~ 2.2 */ -#define MMC_VDD_22_23 0x00000400 /* VDD voltage 2.2 ~ 2.3 */ -#define MMC_VDD_23_24 0x00000800 /* VDD voltage 2.3 ~ 2.4 */ -#define MMC_VDD_24_25 0x00001000 /* VDD voltage 2.4 ~ 2.5 */ -#define MMC_VDD_25_26 0x00002000 /* VDD voltage 2.5 ~ 2.6 */ -#define MMC_VDD_26_27 0x00004000 /* VDD voltage 2.6 ~ 2.7 */ -#define MMC_VDD_27_28 0x00008000 /* VDD voltage 2.7 ~ 2.8 */ -#define MMC_VDD_28_29 0x00010000 /* VDD voltage 2.8 ~ 2.9 */ -#define MMC_VDD_29_30 0x00020000 /* VDD voltage 2.9 ~ 3.0 */ -#define MMC_VDD_30_31 0x00040000 /* VDD voltage 3.0 ~ 3.1 */ -#define MMC_VDD_31_32 0x00080000 /* VDD voltage 3.1 ~ 3.2 */ -#define MMC_VDD_32_33 0x00100000 /* VDD voltage 3.2 ~ 3.3 */ -#define MMC_VDD_33_34 0x00200000 /* VDD voltage 3.3 ~ 3.4 */ -#define MMC_VDD_34_35 0x00400000 /* VDD voltage 3.4 ~ 3.5 */ -#define MMC_VDD_35_36 0x00800000 /* VDD voltage 3.5 ~ 3.6 */ +#define MMC_VDD_165_195 0x00000080 /* VDD voltage 1.65 - 1.95 */ +#define MMC_VDD_20_21 0x00000100 /* VDD voltage 2.0 ~ 2.1 */ +#define MMC_VDD_21_22 0x00000200 /* VDD voltage 2.1 ~ 2.2 */ +#define MMC_VDD_22_23 0x00000400 /* VDD voltage 2.2 ~ 2.3 */ +#define MMC_VDD_23_24 0x00000800 /* VDD voltage 2.3 ~ 2.4 */ +#define MMC_VDD_24_25 0x00001000 /* VDD voltage 2.4 ~ 2.5 */ +#define MMC_VDD_25_26 0x00002000 /* VDD voltage 2.5 ~ 2.6 */ +#define MMC_VDD_26_27 0x00004000 /* VDD voltage 2.6 ~ 2.7 */ +#define MMC_VDD_27_28 0x00008000 /* VDD voltage 2.7 ~ 2.8 */ +#define MMC_VDD_28_29 0x00010000 /* VDD voltage 2.8 ~ 2.9 */ +#define MMC_VDD_29_30 0x00020000 /* VDD voltage 2.9 ~ 3.0 */ +#define MMC_VDD_30_31 0x00040000 /* VDD voltage 3.0 ~ 3.1 */ +#define MMC_VDD_31_32 0x00080000 /* VDD voltage 3.1 ~ 3.2 */ +#define MMC_VDD_32_33 0x00100000 /* VDD voltage 3.2 ~ 3.3 */ +#define MMC_VDD_33_34 0x00200000 /* VDD voltage 3.3 ~ 3.4 */ +#define MMC_VDD_34_35 0x00400000 /* VDD voltage 3.4 ~ 3.5 */ +#define MMC_VDD_35_36 0x00800000 /* VDD voltage 3.5 ~ 3.6 */ -#define MMC_SWITCH_MODE_CMD_SET 0x00 /* Change the command set */ -#define MMC_SWITCH_MODE_SET_BITS 0x01 /* Set bits in EXT_CSD byte - addressed by index which are - 1 in value field */ -#define MMC_SWITCH_MODE_CLEAR_BITS 0x02 /* Clear bits in EXT_CSD byte - addressed by index, which are - 1 in value field */ -#define MMC_SWITCH_MODE_WRITE_BYTE 0x03 /* Set target byte to value */ +#define MMC_SWITCH_MODE_CMD_SET 0x00 /* Change the command set */ +#define MMC_SWITCH_MODE_SET_BITS \ + 0x01 /* Set bits in EXT_CSD byte \ +addressed by index which are \ +1 in value field */ +#define MMC_SWITCH_MODE_CLEAR_BITS \ + 0x02 /* Clear bits in EXT_CSD byte \ + addressed by index, which are \ + 1 in value field */ +#define MMC_SWITCH_MODE_WRITE_BYTE 0x03 /* Set target byte to value */ -#define SD_SWITCH_CHECK 0 -#define SD_SWITCH_SWITCH 1 +#define SD_SWITCH_CHECK 0 +#define SD_SWITCH_SWITCH 1 /* * EXT_CSD fields */ -#define EXT_CSD_ENH_START_ADDR 136 /* R/W */ -#define EXT_CSD_ENH_SIZE_MULT 140 /* R/W */ -#define EXT_CSD_GP_SIZE_MULT 143 /* R/W */ -#define EXT_CSD_PARTITION_SETTING 155 /* R/W */ -#define EXT_CSD_PARTITIONS_ATTRIBUTE 156 /* R/W */ -#define EXT_CSD_MAX_ENH_SIZE_MULT 157 /* R */ -#define EXT_CSD_PARTITIONING_SUPPORT 160 /* RO */ -#define EXT_CSD_RST_N_FUNCTION 162 /* R/W */ -#define EXT_CSD_WR_REL_PARAM 166 /* R */ -#define EXT_CSD_WR_REL_SET 167 /* R/W */ -#define EXT_CSD_RPMB_MULT 168 /* RO */ -#define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ -#define EXT_CSD_BOOT_BUS_WIDTH 177 -#define EXT_CSD_PART_CONF 179 /* R/W */ -#define EXT_CSD_BUS_WIDTH 183 /* R/W */ -#define EXT_CSD_HS_TIMING 185 /* R/W */ -#define EXT_CSD_REV 192 /* RO */ -#define EXT_CSD_CARD_TYPE 196 /* RO */ -#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ -#define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */ -#define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */ -#define EXT_CSD_BOOT_MULT 226 /* RO */ +#define EXT_CSD_ENH_START_ADDR 136 /* R/W */ +#define EXT_CSD_ENH_SIZE_MULT 140 /* R/W */ +#define EXT_CSD_GP_SIZE_MULT 143 /* R/W */ +#define EXT_CSD_PARTITION_SETTING 155 /* R/W */ +#define EXT_CSD_PARTITIONS_ATTRIBUTE 156 /* R/W */ +#define EXT_CSD_MAX_ENH_SIZE_MULT 157 /* R */ +#define EXT_CSD_PARTITIONING_SUPPORT 160 /* RO */ +#define EXT_CSD_RST_N_FUNCTION 162 /* R/W */ +#define EXT_CSD_WR_REL_PARAM 166 /* R */ +#define EXT_CSD_WR_REL_SET 167 /* R/W */ +#define EXT_CSD_RPMB_MULT 168 /* RO */ +#define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ +#define EXT_CSD_BOOT_BUS_WIDTH 177 +#define EXT_CSD_PART_CONF 179 /* R/W */ +#define EXT_CSD_BUS_WIDTH 183 /* R/W */ +#define EXT_CSD_HS_TIMING 185 /* R/W */ +#define EXT_CSD_REV 192 /* RO */ +#define EXT_CSD_CARD_TYPE 196 /* RO */ +#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ +#define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */ +#define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */ +#define EXT_CSD_BOOT_MULT 226 /* RO */ /* * EXT_CSD field definitions */ -#define EXT_CSD_CMD_SET_NORMAL (1 << 0) -#define EXT_CSD_CMD_SET_SECURE (1 << 1) -#define EXT_CSD_CMD_SET_CPSECURE (1 << 2) +#define EXT_CSD_CMD_SET_NORMAL (1 << 0) +#define EXT_CSD_CMD_SET_SECURE (1 << 1) +#define EXT_CSD_CMD_SET_CPSECURE (1 << 2) -#define EXT_CSD_CARD_TYPE_26 (1 << 0) /* Card can run at 26MHz */ -#define EXT_CSD_CARD_TYPE_52 (1 << 1) /* Card can run at 52MHz */ -#define EXT_CSD_CARD_TYPE_DDR_1_8V (1 << 2) -#define EXT_CSD_CARD_TYPE_DDR_1_2V (1 << 3) -#define EXT_CSD_CARD_TYPE_DDR_52 (EXT_CSD_CARD_TYPE_DDR_1_8V \ - | EXT_CSD_CARD_TYPE_DDR_1_2V) +#define EXT_CSD_CARD_TYPE_26 (1 << 0) /* Card can run at 26MHz */ +#define EXT_CSD_CARD_TYPE_52 (1 << 1) /* Card can run at 52MHz */ +#define EXT_CSD_CARD_TYPE_DDR_1_8V (1 << 2) +#define EXT_CSD_CARD_TYPE_DDR_1_2V (1 << 3) +#define EXT_CSD_CARD_TYPE_DDR_52 \ + (EXT_CSD_CARD_TYPE_DDR_1_8V | EXT_CSD_CARD_TYPE_DDR_1_2V) -#define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */ -#define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */ -#define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */ -#define EXT_CSD_DDR_BUS_WIDTH_4 5 /* Card is in 4 bit DDR mode */ -#define EXT_CSD_DDR_BUS_WIDTH_8 6 /* Card is in 8 bit DDR mode */ +#define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */ +#define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */ +#define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */ +#define EXT_CSD_DDR_BUS_WIDTH_4 5 /* Card is in 4 bit DDR mode */ +#define EXT_CSD_DDR_BUS_WIDTH_8 6 /* Card is in 8 bit DDR mode */ -#define EXT_CSD_BOOT_ACK_ENABLE (1 << 6) -#define EXT_CSD_BOOT_PARTITION_ENABLE (1 << 3) -#define EXT_CSD_PARTITION_ACCESS_ENABLE (1 << 0) -#define EXT_CSD_PARTITION_ACCESS_DISABLE (0 << 0) +#define EXT_CSD_BOOT_ACK_ENABLE (1 << 6) +#define EXT_CSD_BOOT_PARTITION_ENABLE (1 << 3) +#define EXT_CSD_PARTITION_ACCESS_ENABLE (1 << 0) +#define EXT_CSD_PARTITION_ACCESS_DISABLE (0 << 0) -#define EXT_CSD_BOOT_ACK(x) (x << 6) -#define EXT_CSD_BOOT_PART_NUM(x) (x << 3) +#define EXT_CSD_BOOT_ACK(x) (x << 6) +#define EXT_CSD_BOOT_PART_NUM(x) (x << 3) #define EXT_CSD_PARTITION_ACCESS(x) (x << 0) -#define EXT_CSD_BOOT_BUS_WIDTH_MODE(x) (x << 3) +#define EXT_CSD_BOOT_BUS_WIDTH_MODE(x) (x << 3) #define EXT_CSD_BOOT_BUS_WIDTH_RESET(x) (x << 2) #define EXT_CSD_BOOT_BUS_WIDTH_WIDTH(x) (x) #define EXT_CSD_PARTITION_SETTING_COMPLETED (1 << 0) -#define EXT_CSD_ENH_USR (1 << 0) /* user data area is enhanced */ -#define EXT_CSD_ENH_GP(x) (1 << ((x)+1)) /* GP part (x+1) is enhanced */ +#define EXT_CSD_ENH_USR (1 << 0) /* user data area is enhanced */ +#define EXT_CSD_ENH_GP(x) (1 << ((x) + 1)) /* GP part (x+1) is enhanced */ -#define EXT_CSD_HS_CTRL_REL (1 << 0) /* host controlled WR_REL_SET */ +#define EXT_CSD_HS_CTRL_REL (1 << 0) /* host controlled WR_REL_SET */ -#define EXT_CSD_WR_DATA_REL_USR (1 << 0) /* user data area WR_REL */ -#define EXT_CSD_WR_DATA_REL_GP(x) (1 << ((x)+1)) /* GP part (x+1) WR_REL */ +#define EXT_CSD_WR_DATA_REL_USR (1 << 0) /* user data area WR_REL */ +#define EXT_CSD_WR_DATA_REL_GP(x) (1 << ((x) + 1)) /* GP part (x+1) WR_REL */ -#define R1_ILLEGAL_COMMAND (1 << 22) -#define R1_APP_CMD (1 << 5) +#define R1_ILLEGAL_COMMAND (1 << 22) +#define R1_APP_CMD (1 << 5) #define MMC_RSP_PRESENT (1 << 0) -#define MMC_RSP_136 (1 << 1) /* 136 bit response */ -#define MMC_RSP_CRC (1 << 2) /* expect valid crc */ -#define MMC_RSP_BUSY (1 << 3) /* card may send busy */ -#define MMC_RSP_OPCODE (1 << 4) /* response contains opcode */ +#define MMC_RSP_136 (1 << 1) /* 136 bit response */ +#define MMC_RSP_CRC (1 << 2) /* expect valid crc */ +#define MMC_RSP_BUSY (1 << 3) /* card may send busy */ +#define MMC_RSP_OPCODE (1 << 4) /* response contains opcode */ -#define MMC_RSP_NONE (0) -#define MMC_RSP_R1 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) -#define MMC_RSP_R1b (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE| \ - MMC_RSP_BUSY) -#define MMC_RSP_R2 (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC) -#define MMC_RSP_R3 (MMC_RSP_PRESENT) -#define MMC_RSP_R4 (MMC_RSP_PRESENT) -#define MMC_RSP_R5 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) -#define MMC_RSP_R6 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) -#define MMC_RSP_R7 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) +#define MMC_RSP_NONE (0) +#define MMC_RSP_R1 (MMC_RSP_PRESENT | MMC_RSP_CRC | MMC_RSP_OPCODE) +#define MMC_RSP_R1b \ + (MMC_RSP_PRESENT | MMC_RSP_CRC | MMC_RSP_OPCODE | MMC_RSP_BUSY) +#define MMC_RSP_R2 (MMC_RSP_PRESENT | MMC_RSP_136 | MMC_RSP_CRC) +#define MMC_RSP_R3 (MMC_RSP_PRESENT) +#define MMC_RSP_R4 (MMC_RSP_PRESENT) +#define MMC_RSP_R5 (MMC_RSP_PRESENT | MMC_RSP_CRC | MMC_RSP_OPCODE) +#define MMC_RSP_R6 (MMC_RSP_PRESENT | MMC_RSP_CRC | MMC_RSP_OPCODE) +#define MMC_RSP_R7 (MMC_RSP_PRESENT | MMC_RSP_CRC | MMC_RSP_OPCODE) #define MMCPART_NOAVAILABLE (0xff) -#define PART_ACCESS_MASK (0x7) -#define PART_SUPPORT (0x1) -#define ENHNCD_SUPPORT (0x2) -#define PART_ENH_ATTRIB (0x1f) +#define PART_ACCESS_MASK (0x7) +#define PART_SUPPORT (0x1) +#define ENHNCD_SUPPORT (0x2) +#define PART_ENH_ATTRIB (0x1f) /* Maximum block size for MMC */ -#define MMC_MAX_BLOCK_LEN 512 +#define MMC_MAX_BLOCK_LEN 512 /* The number of MMC physical partitions. These consist of: * boot partitions (2), general purpose partitions (4) in MMC v4.4. */ -#define MMC_NUM_BOOT_PARTITION 2 -#define MMC_PART_RPMB 3 /* RPMB partition number */ +#define MMC_NUM_BOOT_PARTITION 2 +#define MMC_PART_RPMB 3 /* RPMB partition number */ struct mmc_cid { - unsigned long psn; - unsigned short oid; - uint8_t mid; - uint8_t prv; - uint8_t mdt; - char pnm[7]; + unsigned long psn; + unsigned short oid; + uint8_t mid; + uint8_t prv; + uint8_t mdt; + char pnm[7]; }; struct mmc_cmd { - u16 cmdidx; - uint32_t resp_type; - uint32_t cmdarg; - uint32_t response[4]; + u16 cmdidx; + uint32_t resp_type; + uint32_t cmdarg; + uint32_t response[4]; }; struct mmc_data { - union { - char *dest; - const char *src; /* src buffers don't get written to */ - }; - uint32_t flags; - uint32_t blocks; - uint32_t blocksize; + union { + char *dest; + const char *src; /* src buffers don't get written to */ + }; + uint32_t flags; + uint32_t blocks; + uint32_t blocksize; }; /* forward decl. */ struct mmc; struct mmc_ops { - int (*send_cmd)(struct mmc *mmc, - struct mmc_cmd *cmd, struct mmc_data *data); - void (*set_ios)(struct mmc *mmc); - int (*init)(struct mmc *mmc); - int (*getcd)(struct mmc *mmc); - int (*getwp)(struct mmc *mmc); + int (*send_cmd)(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data); + void (*set_ios)(struct mmc *mmc); + int (*init)(struct mmc *mmc); + int (*getcd)(struct mmc *mmc); + int (*getwp)(struct mmc *mmc); }; struct mmc_config { - const struct mmc_ops *ops; - uint32_t host_caps; - uint32_t voltages; - uint32_t f_min; - uint32_t f_max; - uint32_t b_max; - uint8_t part_type; + const struct mmc_ops *ops; + uint32_t host_caps; + uint32_t voltages; + uint32_t f_min; + uint32_t f_max; + uint32_t b_max; + uint8_t part_type; }; /* TODO struct mmc should be in mmc_private but it's hard to fix right now */ struct mmc { - const struct mmc_config *cfg; /* provided configuration */ - uint32_t version; - void *priv; - uint32_t has_init; - int high_capacity; - uint32_t bus_width; - uint32_t clock; - uint32_t card_caps; - uint32_t ocr; - uint32_t dsr; - uint32_t dsr_imp; - uint32_t scr[2]; - uint32_t csd[4]; - uint32_t cid[4]; - u16 rca; - u8 part_support; - u8 part_attr; - u8 wr_rel_set; - char part_config; - char part_num; - uint32_t tran_speed; - uint32_t read_bl_len; - uint32_t write_bl_len; - uint32_t erase_grp_size; /* in 512-byte sectors */ - uint32_t hc_wp_grp_size; /* in 512-byte sectors */ - uint64_t capacity; - uint64_t capacity_user; - uint64_t capacity_boot; - uint64_t capacity_rpmb; - uint64_t capacity_gp[4]; - uint64_t enh_user_start; - uint64_t enh_user_size; - block_dev_desc_t block_dev; - char op_cond_pending; /* 1 if we are waiting on an op_cond command */ - char init_in_progress; /* 1 if we have done mmc_start_init() */ - char preinit; /* start init as early as possible */ - int ddr_mode; + const struct mmc_config *cfg; /* provided configuration */ + uint32_t version; + void *priv; + uint32_t has_init; + int high_capacity; + uint32_t bus_width; + uint32_t clock; + uint32_t card_caps; + uint32_t ocr; + uint32_t dsr; + uint32_t dsr_imp; + uint32_t scr[2]; + uint32_t csd[4]; + uint32_t cid[4]; + u16 rca; + u8 part_support; + u8 part_attr; + u8 wr_rel_set; + char part_config; + char part_num; + uint32_t tran_speed; + uint32_t read_bl_len; + uint32_t write_bl_len; + uint32_t erase_grp_size; /* in 512-byte sectors */ + uint32_t hc_wp_grp_size; /* in 512-byte sectors */ + uint64_t capacity; + uint64_t capacity_user; + uint64_t capacity_boot; + uint64_t capacity_rpmb; + uint64_t capacity_gp[4]; + uint64_t enh_user_start; + uint64_t enh_user_size; + block_dev_desc_t block_dev; + char op_cond_pending; /* 1 if we are waiting on an op_cond command */ + char init_in_progress; /* 1 if we have done mmc_start_init() */ + char preinit; /* start init as early as possible */ + int ddr_mode; }; struct mmc_hwpart_conf { - struct { - uint32_t enh_start; /* in 512-byte sectors */ - uint32_t enh_size; /* in 512-byte sectors, if 0 no enh area */ - unsigned wr_rel_change : 1; - unsigned wr_rel_set : 1; - } user; - struct { - uint32_t size; /* in 512-byte sectors */ - unsigned enhanced : 1; - unsigned wr_rel_change : 1; - unsigned wr_rel_set : 1; - } gp_part[4]; + struct { + uint32_t enh_start; /* in 512-byte sectors */ + uint32_t enh_size; /* in 512-byte sectors, if 0 no enh area */ + unsigned wr_rel_change : 1; + unsigned wr_rel_set : 1; + } user; + struct { + uint32_t size; /* in 512-byte sectors */ + unsigned enhanced : 1; + unsigned wr_rel_change : 1; + unsigned wr_rel_set : 1; + } gp_part[4]; }; enum mmc_hwpart_conf_mode { - MMC_HWPART_CONF_CHECK, - MMC_HWPART_CONF_SET, - MMC_HWPART_CONF_COMPLETE, + MMC_HWPART_CONF_CHECK, + MMC_HWPART_CONF_SET, + MMC_HWPART_CONF_COMPLETE, }; struct sdmmcip_host { - void *ioaddr; - unsigned int quirks; - unsigned int caps; - unsigned int version; - unsigned int clock; - unsigned int bus_hz; - unsigned int div; - int dev_index; - int dev_id; - int buswidth; - uint32_t fifoth_val; - bool detect_enb; - struct mmc *mmc; - void *priv; + void *ioaddr; + unsigned int quirks; + unsigned int caps; + unsigned int version; + unsigned int clock; + unsigned int bus_hz; + unsigned int div; + int dev_index; + int dev_id; + int buswidth; + uint32_t fifoth_val; + bool detect_enb; + struct mmc *mmc; + void *priv; - void (*clksel)(struct sdmmcip_host *host); - void (*board_init)(struct sdmmcip_host *host); - unsigned int (*get_mmc_clk)(struct sdmmcip_host *host); + void (*clksel)(struct sdmmcip_host *host); + void (*board_init)(struct sdmmcip_host *host); + unsigned int (*get_mmc_clk)(struct sdmmcip_host *host); - struct mmc_config cfg; + struct mmc_config cfg; #ifdef HAL_SDMMC_USE_DMA - /* TODO : os and non-os condition */ - uint8_t dma_ch; - volatile uint32_t sdmmc_dma_lock; - HAL_DMA_IRQ_HANDLER_T tx_dma_handler; - HAL_DMA_IRQ_HANDLER_T rx_dma_handler; + /* TODO : os and non-os condition */ + uint8_t dma_ch; + volatile uint32_t sdmmc_dma_lock; + HAL_DMA_IRQ_HANDLER_T tx_dma_handler; + HAL_DMA_IRQ_HANDLER_T rx_dma_handler; #endif }; struct sdmmcip_idmac { - uint32_t flags; - uint32_t cnt; - uint32_t addr; - uint32_t next_addr; + uint32_t flags; + uint32_t cnt; + uint32_t addr; + uint32_t next_addr; }; static void hal_sdmmc_delay(uint32_t ms); static HAL_SDMMC_DELAY_FUNC sdmmc_delay = NULL; -static inline void sdmmcip_writel(struct sdmmcip_host *host, int reg, uint32_t val) -{ - *((volatile uint32_t *)(host->ioaddr + reg)) = val; +static inline void sdmmcip_writel(struct sdmmcip_host *host, int reg, + uint32_t val) { + *((volatile uint32_t *)(host->ioaddr + reg)) = val; } -static inline uint32_t sdmmcip_readl(struct sdmmcip_host *host, int reg) -{ - return *((volatile uint32_t *)(host->ioaddr + reg)); +static inline uint32_t sdmmcip_readl(struct sdmmcip_host *host, int reg) { + return *((volatile uint32_t *)(host->ioaddr + reg)); } #ifdef CONFIG_MMC_SPI -#define sdmmc_host_is_spi(mmc) ((mmc)->cfg->host_caps & MMC_MODE_SPI) +#define sdmmc_host_is_spi(mmc) ((mmc)->cfg->host_caps & MMC_MODE_SPI) #else -#define sdmmc_host_is_spi(mmc) 0 +#define sdmmc_host_is_spi(mmc) 0 #endif #ifndef CONFIG_SYS_MMC_MAX_BLK_COUNT @@ -513,396 +509,403 @@ static inline uint32_t sdmmcip_readl(struct sdmmcip_host *host, int reg) #endif static void (*sdmmc_detected_callback)(uint8_t) = NULL; -static uint32_t sdmmc_ip_base[HAL_SDMMC_ID_NUM] = {SDMMC_BASE, }; +static uint32_t sdmmc_ip_base[HAL_SDMMC_ID_NUM] = { + SDMMC_BASE, +}; static struct sdmmcip_host sdmmc_host[HAL_SDMMC_ID_NUM]; static struct mmc sdmmc_devices[HAL_SDMMC_ID_NUM]; -//static const char * const invalid_id = "Invalid SDMMC ID: %d\n"; +// static const char * const invalid_id = "Invalid SDMMC ID: %d\n"; #ifdef HAL_SDMMC_USE_DMA -static void sdmmcip0_ext_dma_tx_handler(uint8_t chan, uint32_t remain_tsize, uint32_t error, struct HAL_DMA_DESC_T *lli); -static void sdmmcip0_ext_dma_rx_handler(uint8_t chan, uint32_t remain_tsize, uint32_t error, struct HAL_DMA_DESC_T *lli); -static HAL_DMA_IRQ_HANDLER_T sdmmcip_ext_dma_irq_handlers[HAL_SDMMC_ID_NUM*2] = { - sdmmcip0_ext_dma_tx_handler, sdmmcip0_ext_dma_rx_handler, +static void sdmmcip0_ext_dma_tx_handler(uint8_t chan, uint32_t remain_tsize, + uint32_t error, + struct HAL_DMA_DESC_T *lli); +static void sdmmcip0_ext_dma_rx_handler(uint8_t chan, uint32_t remain_tsize, + uint32_t error, + struct HAL_DMA_DESC_T *lli); +static HAL_DMA_IRQ_HANDLER_T + sdmmcip_ext_dma_irq_handlers[HAL_SDMMC_ID_NUM * 2] = { + sdmmcip0_ext_dma_tx_handler, + sdmmcip0_ext_dma_rx_handler, }; #endif -uint32_t _sdmmc_div64_32(uint64_t *n, uint32_t base) -{ - uint64_t rem = *n; - uint64_t b = base; - uint64_t res, d = 1; - uint32_t high = rem >> 32; +uint32_t _sdmmc_div64_32(uint64_t *n, uint32_t base) { + uint64_t rem = *n; + uint64_t b = base; + uint64_t res, d = 1; + uint32_t high = rem >> 32; - /* Reduce the thing a bit first */ - res = 0; - if (high >= base) { - high /= base; - res = (uint64_t) high << 32; - rem -= (uint64_t) (high*base) << 32; + /* Reduce the thing a bit first */ + res = 0; + if (high >= base) { + high /= base; + res = (uint64_t)high << 32; + rem -= (uint64_t)(high * base) << 32; + } + + while ((int64_t)b > 0 && b < rem) { + b = b + b; + d = d + d; + } + + do { + if (rem >= b) { + rem -= b; + res += d; } + b >>= 1; + d >>= 1; + } while (d); - while ((int64_t)b > 0 && b < rem) { - b = b+b; - d = d+d; - } - - do { - if (rem >= b) { - rem -= b; - res += d; - } - b >>= 1; - d >>= 1; - } while (d); - - *n = res; - return rem; + *n = res; + return rem; } - /* The unnecessary pointer compare is there * * to check for type safety (n must be 64bit) * */ -# define _sdmmc_do_div(n,base) ({ \ - uint32_t __base = (base); \ - uint32_t __rem; \ - (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \ - if (((n) >> 32) == 0) { \ - __rem = (uint32_t)(n) % __base; \ - (n) = (uint32_t)(n) / __base; \ - } else \ - __rem = _sdmmc_div64_32(&(n), __base); \ - __rem; \ - }) +#define _sdmmc_do_div(n, base) \ + ({ \ + uint32_t __base = (base); \ + uint32_t __rem; \ + (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \ + if (((n) >> 32) == 0) { \ + __rem = (uint32_t)(n) % __base; \ + (n) = (uint32_t)(n) / __base; \ + } else \ + __rem = _sdmmc_div64_32(&(n), __base); \ + __rem; \ + }) /* Wrapper for _sdmmc_do_div(). Doesn't modify dividend and returns * * the result, not reminder. * */ -static inline uint64_t _sdmmc_lldiv(uint64_t dividend, uint32_t divisor) -{ - uint64_t __res = dividend; - _sdmmc_do_div(__res, divisor); - return(__res); +static inline uint64_t _sdmmc_lldiv(uint64_t dividend, uint32_t divisor) { + uint64_t __res = dividend; + _sdmmc_do_div(__res, divisor); + return (__res); } - -static void mmc_udelay(int cnt) -{ - volatile uint32_t i = 0, c = 0; - for(i = 0; i < cnt; ++i) { - c++; - __asm("nop"); - } +static void mmc_udelay(int cnt) { + volatile uint32_t i = 0, c = 0; + for (i = 0; i < cnt; ++i) { + c++; + __asm("nop"); + } } +static int sdmmcip_wait_reset(struct sdmmcip_host *host, uint32_t value) { + uint32_t ctrl; + unsigned long timeout = 1000; -static int sdmmcip_wait_reset(struct sdmmcip_host *host, uint32_t value) -{ - uint32_t ctrl; - unsigned long timeout = 1000; + sdmmcip_writel(host, SDMMCIP_REG_CTRL, value); - sdmmcip_writel(host, SDMMCIP_REG_CTRL, value); - - while (timeout--) { - ctrl = sdmmcip_readl(host, SDMMCIP_REG_CTRL); - if (!(ctrl & SDMMCIP_REG_RESET_ALL)) - return 1; - } - return 0; + while (timeout--) { + ctrl = sdmmcip_readl(host, SDMMCIP_REG_CTRL); + if (!(ctrl & SDMMCIP_REG_RESET_ALL)) + return 1; + } + return 0; } #ifdef HAL_SDMMC_USE_DMA -static void sdmmcip0_ext_dma_tx_handler(uint8_t chan, uint32_t remain_tsize, uint32_t error, struct HAL_DMA_DESC_T *lli) -{ - uint32_t ip_raw_int_status = 0; - struct sdmmcip_host *host = &sdmmc_host[HAL_SDMMC_ID_0]; - HAL_SDMMC_TRACE(2,"%s:%d\n", __func__, __LINE__); - ip_raw_int_status = sdmmcip_readl(host, SDMMCIP_REG_RINTSTS); - HAL_SDMMC_TRACE(3,"%s:%d, tx ip_raw_int_status 0x%x\n", __func__, __LINE__, ip_raw_int_status); - if (ip_raw_int_status & (SDMMCIP_REG_DATA_ERR|SDMMCIP_REG_DATA_TOUT)) { - HAL_SDMMC_TRACE(3,"%s:%d, sdmmcip0 tx dma error 0x%x\n", __func__, __LINE__, ip_raw_int_status); - } +static void sdmmcip0_ext_dma_tx_handler(uint8_t chan, uint32_t remain_tsize, + uint32_t error, + struct HAL_DMA_DESC_T *lli) { + uint32_t ip_raw_int_status = 0; + struct sdmmcip_host *host = &sdmmc_host[HAL_SDMMC_ID_0]; + HAL_SDMMC_TRACE(2, "%s:%d\n", __func__, __LINE__); + ip_raw_int_status = sdmmcip_readl(host, SDMMCIP_REG_RINTSTS); + HAL_SDMMC_TRACE(3, "%s:%d, tx ip_raw_int_status 0x%x\n", __func__, __LINE__, + ip_raw_int_status); + if (ip_raw_int_status & (SDMMCIP_REG_DATA_ERR | SDMMCIP_REG_DATA_TOUT)) { + HAL_SDMMC_TRACE(3, "%s:%d, sdmmcip0 tx dma error 0x%x\n", __func__, + __LINE__, ip_raw_int_status); + } - /* TODO : os and non-os condition */ - host->sdmmc_dma_lock = 0; + /* TODO : os and non-os condition */ + host->sdmmc_dma_lock = 0; } -static void sdmmcip0_ext_dma_rx_handler(uint8_t chan, uint32_t remain_tsize, uint32_t error, struct HAL_DMA_DESC_T *lli) -{ - uint32_t ip_raw_int_status = 0; - struct sdmmcip_host *host = &sdmmc_host[HAL_SDMMC_ID_0]; - HAL_SDMMC_TRACE(2,"%s:%d\n", __func__, __LINE__); - ip_raw_int_status = sdmmcip_readl(host, SDMMCIP_REG_RINTSTS); - HAL_SDMMC_TRACE(3,"%s:%d, ip_raw_int_status 0x%x\n", __func__, __LINE__, ip_raw_int_status); - if (ip_raw_int_status & (SDMMCIP_REG_DATA_ERR|SDMMCIP_REG_DATA_TOUT)) { - HAL_SDMMC_TRACE(3,"%s:%d, sdmmcip0 rx dma error 0x%x\n", __func__, __LINE__, ip_raw_int_status); - } +static void sdmmcip0_ext_dma_rx_handler(uint8_t chan, uint32_t remain_tsize, + uint32_t error, + struct HAL_DMA_DESC_T *lli) { + uint32_t ip_raw_int_status = 0; + struct sdmmcip_host *host = &sdmmc_host[HAL_SDMMC_ID_0]; + HAL_SDMMC_TRACE(2, "%s:%d\n", __func__, __LINE__); + ip_raw_int_status = sdmmcip_readl(host, SDMMCIP_REG_RINTSTS); + HAL_SDMMC_TRACE(3, "%s:%d, ip_raw_int_status 0x%x\n", __func__, __LINE__, + ip_raw_int_status); + if (ip_raw_int_status & (SDMMCIP_REG_DATA_ERR | SDMMCIP_REG_DATA_TOUT)) { + HAL_SDMMC_TRACE(3, "%s:%d, sdmmcip0 rx dma error 0x%x\n", __func__, + __LINE__, ip_raw_int_status); + } - /* TODO : os and non-os condition */ - host->sdmmc_dma_lock = 0; + /* TODO : os and non-os condition */ + host->sdmmc_dma_lock = 0; } #endif static void sdmmcip_prepare_data(struct sdmmcip_host *host, - struct mmc_data *data, - struct sdmmcip_idmac *cur_idmac, - void *bounce_buffer) -{ + struct mmc_data *data, + struct sdmmcip_idmac *cur_idmac, + void *bounce_buffer) { #ifdef HAL_SDMMC_USE_DMA - uint32_t ctrl = 0; - struct HAL_DMA_CH_CFG_T dma_cfg; + uint32_t ctrl = 0; + struct HAL_DMA_CH_CFG_T dma_cfg; #endif - sdmmcip_writel(host, SDMMCIP_REG_BLKSIZ, data->blocksize); - sdmmcip_writel(host, SDMMCIP_REG_BYTCNT, data->blocksize * data->blocks); + sdmmcip_writel(host, SDMMCIP_REG_BLKSIZ, data->blocksize); + sdmmcip_writel(host, SDMMCIP_REG_BYTCNT, data->blocksize * data->blocks); - - /* use dma */ + /* use dma */ #ifdef HAL_SDMMC_USE_DMA - HAL_SDMMC_TRACE(0,"sdmmc use dma\n"); - /* enable sdmmcip e-dma */ - ctrl = sdmmcip_readl(host, SDMMCIP_REG_CTRL); - ctrl |= (SDMMCIP_REG_DMA_EN); - sdmmcip_writel(host, SDMMCIP_REG_CTRL, ctrl); + HAL_SDMMC_TRACE(0, "sdmmc use dma\n"); + /* enable sdmmcip e-dma */ + ctrl = sdmmcip_readl(host, SDMMCIP_REG_CTRL); + ctrl |= (SDMMCIP_REG_DMA_EN); + sdmmcip_writel(host, SDMMCIP_REG_CTRL, ctrl); - host->sdmmc_dma_lock = 1; + host->sdmmc_dma_lock = 1; - memset(&dma_cfg, 0, sizeof(dma_cfg)); - if (data->flags & MMC_DATA_READ) { - HAL_SDMMC_TRACE(0,"sdmmc use dma read\n"); - dma_cfg.dst = (uint32_t)data->dest; - //HAL_SDMMC_TRACE(2,"sddma :len %d, buf 0x%x\n", data->blocksize*data->blocks, dma_cfg.dst); - if ((dma_cfg.dst % 4) != 0) { - dma_cfg.dst_width = HAL_DMA_WIDTH_BYTE; - } - else { - dma_cfg.dst_width = HAL_DMA_WIDTH_WORD; - } - dma_cfg.dst_bsize = HAL_DMA_BSIZE_1; - dma_cfg.dst_periph = 0; // useless - //dma_cfg.dst_width = HAL_DMA_WIDTH_WORD; - dma_cfg.handler = host->rx_dma_handler; - dma_cfg.src_bsize = HAL_DMA_BSIZE_1; - dma_cfg.src_periph = HAL_GPDMA_SDMMC; - dma_cfg.src_tsize = data->blocks*data->blocksize/4; - HAL_SDMMC_TRACE(1,"sdmmc use dma tsize %d\n", dma_cfg.src_tsize); - dma_cfg.src_width = HAL_DMA_WIDTH_WORD; - dma_cfg.try_burst = 1; - dma_cfg.type = HAL_DMA_FLOW_P2M_DMA; - dma_cfg.src = (uint32_t)0; // useless - dma_cfg.ch = hal_gpdma_get_chan(dma_cfg.src_periph, HAL_DMA_HIGH_PRIO); - HAL_SDMMC_TRACE(1,"sdmmc use dma get ch %d\n", dma_cfg.ch); + memset(&dma_cfg, 0, sizeof(dma_cfg)); + if (data->flags & MMC_DATA_READ) { + HAL_SDMMC_TRACE(0, "sdmmc use dma read\n"); + dma_cfg.dst = (uint32_t)data->dest; + // HAL_SDMMC_TRACE(2,"sddma :len %d, buf 0x%x\n", + // data->blocksize*data->blocks, dma_cfg.dst); + if ((dma_cfg.dst % 4) != 0) { + dma_cfg.dst_width = HAL_DMA_WIDTH_BYTE; + } else { + dma_cfg.dst_width = HAL_DMA_WIDTH_WORD; } - else { - HAL_SDMMC_TRACE(0,"sdmmc use dma write\n"); - dma_cfg.dst = 0; // useless - dma_cfg.dst_bsize = HAL_DMA_BSIZE_1; - dma_cfg.dst_periph = HAL_GPDMA_SDMMC; - dma_cfg.dst_width = HAL_DMA_WIDTH_WORD; - dma_cfg.handler = host->tx_dma_handler; - dma_cfg.src_bsize = HAL_DMA_BSIZE_1; - dma_cfg.src_periph = 0; // useless - //dma_cfg.src_tsize = data->blocks*data->blocksize/4; - HAL_SDMMC_TRACE(1,"sdmmc use dma tsize %d\n", dma_cfg.src_tsize); - //dma_cfg.src_width = HAL_DMA_WIDTH_WORD; - dma_cfg.try_burst = 1; - dma_cfg.type = HAL_DMA_FLOW_M2P_DMA; - dma_cfg.src = (uint32_t)data->src; - //uart_printf("sddma :len %d, buf 0x%x\n", data->blocksize*data->blocks, dma_cfg.src); - if ((dma_cfg.src % 4) != 0) { - dma_cfg.src_width = HAL_DMA_WIDTH_BYTE; - dma_cfg.src_tsize = data->blocks*data->blocksize; - } - else { - dma_cfg.src_width = HAL_DMA_WIDTH_WORD; - dma_cfg.src_tsize = data->blocks*data->blocksize/4; - } - dma_cfg.ch = hal_gpdma_get_chan(dma_cfg.dst_periph, HAL_DMA_HIGH_PRIO); - HAL_SDMMC_TRACE(1,"sdmmc use dma get ch %d\n", dma_cfg.ch); - - //uart_printf("%s:%d src 0x%x\n", __func__, __LINE__, dma_cfg.src); + dma_cfg.dst_bsize = HAL_DMA_BSIZE_1; + dma_cfg.dst_periph = 0; // useless + // dma_cfg.dst_width = HAL_DMA_WIDTH_WORD; + dma_cfg.handler = host->rx_dma_handler; + dma_cfg.src_bsize = HAL_DMA_BSIZE_1; + dma_cfg.src_periph = HAL_GPDMA_SDMMC; + dma_cfg.src_tsize = data->blocks * data->blocksize / 4; + HAL_SDMMC_TRACE(1, "sdmmc use dma tsize %d\n", dma_cfg.src_tsize); + dma_cfg.src_width = HAL_DMA_WIDTH_WORD; + dma_cfg.try_burst = 1; + dma_cfg.type = HAL_DMA_FLOW_P2M_DMA; + dma_cfg.src = (uint32_t)0; // useless + dma_cfg.ch = hal_gpdma_get_chan(dma_cfg.src_periph, HAL_DMA_HIGH_PRIO); + HAL_SDMMC_TRACE(1, "sdmmc use dma get ch %d\n", dma_cfg.ch); + } else { + HAL_SDMMC_TRACE(0, "sdmmc use dma write\n"); + dma_cfg.dst = 0; // useless + dma_cfg.dst_bsize = HAL_DMA_BSIZE_1; + dma_cfg.dst_periph = HAL_GPDMA_SDMMC; + dma_cfg.dst_width = HAL_DMA_WIDTH_WORD; + dma_cfg.handler = host->tx_dma_handler; + dma_cfg.src_bsize = HAL_DMA_BSIZE_1; + dma_cfg.src_periph = 0; // useless + // dma_cfg.src_tsize = data->blocks*data->blocksize/4; + HAL_SDMMC_TRACE(1, "sdmmc use dma tsize %d\n", dma_cfg.src_tsize); + // dma_cfg.src_width = HAL_DMA_WIDTH_WORD; + dma_cfg.try_burst = 1; + dma_cfg.type = HAL_DMA_FLOW_M2P_DMA; + dma_cfg.src = (uint32_t)data->src; + // uart_printf("sddma :len %d, buf 0x%x\n", data->blocksize*data->blocks, + // dma_cfg.src); + if ((dma_cfg.src % 4) != 0) { + dma_cfg.src_width = HAL_DMA_WIDTH_BYTE; + dma_cfg.src_tsize = data->blocks * data->blocksize; + } else { + dma_cfg.src_width = HAL_DMA_WIDTH_WORD; + dma_cfg.src_tsize = data->blocks * data->blocksize / 4; } + dma_cfg.ch = hal_gpdma_get_chan(dma_cfg.dst_periph, HAL_DMA_HIGH_PRIO); + HAL_SDMMC_TRACE(1, "sdmmc use dma get ch %d\n", dma_cfg.ch); - host->dma_ch = dma_cfg.ch; + // uart_printf("%s:%d src 0x%x\n", __func__, __LINE__, dma_cfg.src); + } - hal_gpdma_start(&dma_cfg); + host->dma_ch = dma_cfg.ch; + + hal_gpdma_start(&dma_cfg); #endif } static int sdmmcip_set_transfer_mode(struct sdmmcip_host *host, - struct mmc_data *data) -{ - unsigned long mode; + struct mmc_data *data) { + unsigned long mode; - mode = SDMMCIP_REG_CMD_DATA_EXP; - if (data->flags & MMC_DATA_WRITE) - mode |= SDMMCIP_REG_CMD_RW; + mode = SDMMCIP_REG_CMD_DATA_EXP; + if (data->flags & MMC_DATA_WRITE) + mode |= SDMMCIP_REG_CMD_RW; - return mode; + return mode; } static int sdmmcip_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, - struct mmc_data *data) -{ - int ret = 0; - int flags = 0, i; - uint32_t retry = 1000000; - uint32_t mask, ctrl; - int busy_tmo = MS_TO_TICKS(1000), busy_t = 0; + struct mmc_data *data) { + int ret = 0; + int flags = 0, i; + uint32_t retry = 1000000; + uint32_t mask, ctrl; + int busy_tmo = MS_TO_TICKS(1000), busy_t = 0; #ifndef HAL_SDMMC_USE_DMA - uint32_t status = 0, fifo_data = 0; + uint32_t status = 0, fifo_data = 0; #endif - struct sdmmcip_host *host = mmc->priv; + struct sdmmcip_host *host = mmc->priv; - busy_t = hal_sys_timer_get(); + busy_t = hal_sys_timer_get(); - while ((sdmmcip_readl(host, SDMMCIP_REG_STATUS) & SDMMCIP_REG_BUSY) && hal_sys_timer_get()<(busy_t+busy_tmo)) { - HAL_SDMMC_TRACE(0,"[sdmmc]busy\n"); + while ((sdmmcip_readl(host, SDMMCIP_REG_STATUS) & SDMMCIP_REG_BUSY) && + hal_sys_timer_get() < (busy_t + busy_tmo)) { + HAL_SDMMC_TRACE(0, "[sdmmc]busy\n"); + } + + sdmmcip_writel(host, SDMMCIP_REG_RINTSTS, SDMMCIP_REG_INTMSK_CD); + + if (data) { + sdmmcip_prepare_data(host, data, 0, 0); + } + + sdmmcip_writel(host, SDMMCIP_REG_CMDARG, cmd->cmdarg); + + if (data) + flags = sdmmcip_set_transfer_mode(host, data); + + if ((cmd->resp_type & MMC_RSP_136) && (cmd->resp_type & MMC_RSP_BUSY)) + return -1; + + if (cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION) + flags |= SDMMCIP_REG_CMD_ABORT_STOP; + else + flags |= SDMMCIP_REG_CMD_PRV_DAT_WAIT; + + if (cmd->resp_type & MMC_RSP_PRESENT) { + flags |= SDMMCIP_REG_CMD_RESP_EXP; + if (cmd->resp_type & MMC_RSP_136) + flags |= SDMMCIP_REG_CMD_RESP_LENGTH; + } + + if (cmd->resp_type & MMC_RSP_CRC) + flags |= SDMMCIP_REG_CMD_CHECK_CRC; + + flags |= (cmd->cmdidx | SDMMCIP_REG_CMD_START | SDMMCIP_REG_CMD_USE_HOLD_REG); + + sdmmcip_writel(host, SDMMCIP_REG_CMD, flags); + + for (i = 0; i < retry; i++) { + mask = sdmmcip_readl(host, SDMMCIP_REG_RINTSTS); + if (mask & SDMMCIP_REG_INTMSK_CDONE) { + if (!data) + sdmmcip_writel(host, SDMMCIP_REG_RINTSTS, SDMMCIP_REG_INTMSK_CDONE); + break; } + } - sdmmcip_writel(host, SDMMCIP_REG_RINTSTS, SDMMCIP_REG_INTMSK_CD); + if (i == retry) { + HAL_SDMMC_TRACE(1, "%s: Timeout.\n", __func__); + return TIMEOUT; + } - if (data) { - sdmmcip_prepare_data(host, data, 0, 0); - } - - sdmmcip_writel(host, SDMMCIP_REG_CMDARG, cmd->cmdarg); - - if (data) - flags = sdmmcip_set_transfer_mode(host, data); - - if ((cmd->resp_type & MMC_RSP_136) && (cmd->resp_type & MMC_RSP_BUSY)) - return -1; - - if (cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION) - flags |= SDMMCIP_REG_CMD_ABORT_STOP; - else - flags |= SDMMCIP_REG_CMD_PRV_DAT_WAIT; - - if (cmd->resp_type & MMC_RSP_PRESENT) { - flags |= SDMMCIP_REG_CMD_RESP_EXP; - if (cmd->resp_type & MMC_RSP_136) - flags |= SDMMCIP_REG_CMD_RESP_LENGTH; - } - - if (cmd->resp_type & MMC_RSP_CRC) - flags |= SDMMCIP_REG_CMD_CHECK_CRC; - - flags |= (cmd->cmdidx | SDMMCIP_REG_CMD_START | SDMMCIP_REG_CMD_USE_HOLD_REG); - - sdmmcip_writel(host, SDMMCIP_REG_CMD, flags); - - for (i = 0; i < retry; i++) { - mask = sdmmcip_readl(host, SDMMCIP_REG_RINTSTS); - if (mask & SDMMCIP_REG_INTMSK_CDONE) { - if (!data) - sdmmcip_writel(host, SDMMCIP_REG_RINTSTS, SDMMCIP_REG_INTMSK_CDONE); - break; - } - } - - if (i == retry) { - HAL_SDMMC_TRACE(1,"%s: Timeout.\n", __func__); - return TIMEOUT; - } - - if (mask & SDMMCIP_REG_INTMSK_RTO) { - /* - * Timeout here is not necessarily fatal. (e)MMC cards - * will splat here when they receive CMD55 as they do - * not support this command and that is exactly the way - * to tell them apart from SD cards. Thus, this output - * below shall be TRACE(). eMMC cards also do not favor - * CMD8, please keep that in mind. - */ - HAL_SDMMC_TRACE(1,"%s: Response Timeout.\n", __func__); - return TIMEOUT; - } else if (mask & SDMMCIP_REG_INTMSK_RE) { - HAL_SDMMC_TRACE(1,"%s: Response Error.\n", __func__); - return -1; - } - - - if (cmd->resp_type & MMC_RSP_PRESENT) { - if (cmd->resp_type & MMC_RSP_136) { - cmd->response[0] = sdmmcip_readl(host, SDMMCIP_REG_RESP3); - cmd->response[1] = sdmmcip_readl(host, SDMMCIP_REG_RESP2); - cmd->response[2] = sdmmcip_readl(host, SDMMCIP_REG_RESP1); - cmd->response[3] = sdmmcip_readl(host, SDMMCIP_REG_RESP0); - } else { - cmd->response[0] = sdmmcip_readl(host, SDMMCIP_REG_RESP0); - } + if (mask & SDMMCIP_REG_INTMSK_RTO) { + /* + * Timeout here is not necessarily fatal. (e)MMC cards + * will splat here when they receive CMD55 as they do + * not support this command and that is exactly the way + * to tell them apart from SD cards. Thus, this output + * below shall be TRACE(). eMMC cards also do not favor + * CMD8, please keep that in mind. + */ + HAL_SDMMC_TRACE(1, "%s: Response Timeout.\n", __func__); + return TIMEOUT; + } else if (mask & SDMMCIP_REG_INTMSK_RE) { + HAL_SDMMC_TRACE(1, "%s: Response Error.\n", __func__); + return -1; + } + + if (cmd->resp_type & MMC_RSP_PRESENT) { + if (cmd->resp_type & MMC_RSP_136) { + cmd->response[0] = sdmmcip_readl(host, SDMMCIP_REG_RESP3); + cmd->response[1] = sdmmcip_readl(host, SDMMCIP_REG_RESP2); + cmd->response[2] = sdmmcip_readl(host, SDMMCIP_REG_RESP1); + cmd->response[3] = sdmmcip_readl(host, SDMMCIP_REG_RESP0); + } else { + cmd->response[0] = sdmmcip_readl(host, SDMMCIP_REG_RESP0); } + } #ifndef HAL_SDMMC_USE_DMA - if (data) { - i = 0; - while(1) { - mask = sdmmcip_readl(host, SDMMCIP_REG_RINTSTS); - if (mask & (SDMMCIP_REG_DATA_ERR | SDMMCIP_REG_DATA_TOUT)) { - HAL_SDMMC_TRACE(1,"%s: READ DATA ERROR!\n", __func__); - ret = -1; - goto out; - } - status = sdmmcip_readl(host, SDMMCIP_REG_STATUS); - if (data->flags == MMC_DATA_READ) { - if (status & SDMMCIP_REG_FIFO_COUNT_MASK) { - fifo_data = sdmmcip_readl(host, SDMMCIP_REG_FIFO_OFFSET); - //HAL_SDMMC_TRACE(3,"%s: count %d, read -> 0x%x\n", __func__, i, fifo_data); - /* FIXME: now we just deal with 32bit width fifo one time */ - if (i < data->blocks*data->blocksize) { - memcpy(data->dest + i, &fifo_data, sizeof(fifo_data)); - i += sizeof(fifo_data); - } - else { - HAL_SDMMC_TRACE(1,"%s: fifo data too much\n", __func__); - ret = -1; - goto out; - } - } - /* nothing to read from fifo and DTO is set */ - else if(mask & SDMMCIP_REG_INTMSK_DTO) { - if(i != data->blocks*data->blocksize) { - HAL_SDMMC_TRACE(3,"%s: need to read %d, actually read %d\n", __func__, data->blocks*data->blocksize, i); - } - ret = 0; - goto out; - } - } - else { - /* nothing to write to fifo and DTO is set */ - if(mask & SDMMCIP_REG_INTMSK_DTO) { - /* check if number is right */ - if(i != data->blocks*data->blocksize) { - HAL_SDMMC_TRACE(3,"%s: need to write %d, actually written %d\n", __func__, data->blocks*data->blocksize, i); - } - ret = 0; - goto out; - } - else if (!(status & SDMMCIP_REG_FIFO_COUNT_MASK)) { - /* FIXME: now we just deal with 32bit width fifo one time */ - if(i < data->blocks*data->blocksize) { - memcpy(&fifo_data, data->src + i, sizeof(fifo_data)); - //HAL_SDMMC_TRACE(4,"%s: fifo %d, count %d, write -> 0x%x\n", __func__, ((status & SDMMCIP_REG_FIFO_COUNT_MASK)>>SDMMCIP_REG_FIFO_COUNT_SHIFT), i, fifo_data); - i += sizeof(fifo_data); - sdmmcip_writel(host, SDMMCIP_REG_FIFO_OFFSET, fifo_data); - } - else { - HAL_SDMMC_TRACE(1,"%s: no data to write to fifo, do nothing\n", __func__); - } - } - } + if (data) { + i = 0; + while (1) { + mask = sdmmcip_readl(host, SDMMCIP_REG_RINTSTS); + if (mask & (SDMMCIP_REG_DATA_ERR | SDMMCIP_REG_DATA_TOUT)) { + HAL_SDMMC_TRACE(1, "%s: READ DATA ERROR!\n", __func__); + ret = -1; + goto out; + } + status = sdmmcip_readl(host, SDMMCIP_REG_STATUS); + if (data->flags == MMC_DATA_READ) { + if (status & SDMMCIP_REG_FIFO_COUNT_MASK) { + fifo_data = sdmmcip_readl(host, SDMMCIP_REG_FIFO_OFFSET); + // HAL_SDMMC_TRACE(3,"%s: count %d, read -> 0x%x\n", __func__, i, + // fifo_data); + /* FIXME: now we just deal with 32bit width fifo one time */ + if (i < data->blocks * data->blocksize) { + memcpy(data->dest + i, &fifo_data, sizeof(fifo_data)); + i += sizeof(fifo_data); + } else { + HAL_SDMMC_TRACE(1, "%s: fifo data too much\n", __func__); + ret = -1; + goto out; + } } + /* nothing to read from fifo and DTO is set */ + else if (mask & SDMMCIP_REG_INTMSK_DTO) { + if (i != data->blocks * data->blocksize) { + HAL_SDMMC_TRACE(3, "%s: need to read %d, actually read %d\n", + __func__, data->blocks * data->blocksize, i); + } + ret = 0; + goto out; + } + } else { + /* nothing to write to fifo and DTO is set */ + if (mask & SDMMCIP_REG_INTMSK_DTO) { + /* check if number is right */ + if (i != data->blocks * data->blocksize) { + HAL_SDMMC_TRACE(3, "%s: need to write %d, actually written %d\n", + __func__, data->blocks * data->blocksize, i); + } + ret = 0; + goto out; + } else if (!(status & SDMMCIP_REG_FIFO_COUNT_MASK)) { + /* FIXME: now we just deal with 32bit width fifo one time */ + if (i < data->blocks * data->blocksize) { + memcpy(&fifo_data, data->src + i, sizeof(fifo_data)); + // HAL_SDMMC_TRACE(4,"%s: fifo %d, count %d, write -> 0x%x\n", + // __func__, ((status & + // SDMMCIP_REG_FIFO_COUNT_MASK)>>SDMMCIP_REG_FIFO_COUNT_SHIFT), i, + // fifo_data); + i += sizeof(fifo_data); + sdmmcip_writel(host, SDMMCIP_REG_FIFO_OFFSET, fifo_data); + } else { + HAL_SDMMC_TRACE(1, "%s: no data to write to fifo, do nothing\n", + __func__); + } + } + } } + } #endif #ifdef HAL_SDMMC_USE_DMA - while (host->sdmmc_dma_lock); - ctrl = sdmmcip_readl(host, SDMMCIP_REG_CTRL); - ctrl |= SDMMCIP_REG_CTRL_DMA_RESET; - sdmmcip_wait_reset(host, ctrl); - if (data) { - hal_gpdma_free_chan(host->dma_ch); + while (host->sdmmc_dma_lock) + ; + ctrl = sdmmcip_readl(host, SDMMCIP_REG_CTRL); + ctrl |= SDMMCIP_REG_CTRL_DMA_RESET; + sdmmcip_wait_reset(host, ctrl); + if (data) { + hal_gpdma_free_chan(host->dma_ch); #if 0 if (data->flags & MMC_DATA_READ) { for (int ccc = 0; ccc < 400; ++ccc) { @@ -911,979 +914,943 @@ static int sdmmcip_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, HAL_SDMMC_TRACE(0,"\n"); } #endif - } + } #endif #ifndef HAL_SDMMC_USE_DMA out: #endif - mask = sdmmcip_readl(host, SDMMCIP_REG_RINTSTS); - sdmmcip_writel(host, SDMMCIP_REG_RINTSTS, mask&(~SDMMCIP_REG_INTMSK_CD)); + mask = sdmmcip_readl(host, SDMMCIP_REG_RINTSTS); + sdmmcip_writel(host, SDMMCIP_REG_RINTSTS, mask & (~SDMMCIP_REG_INTMSK_CD)); - ctrl = sdmmcip_readl(host, SDMMCIP_REG_CTRL); - ctrl &= ~(SDMMCIP_REG_DMA_EN); - sdmmcip_writel(host, SDMMCIP_REG_CTRL, ctrl); + ctrl = sdmmcip_readl(host, SDMMCIP_REG_CTRL); + ctrl &= ~(SDMMCIP_REG_DMA_EN); + sdmmcip_writel(host, SDMMCIP_REG_CTRL, ctrl); - mmc_udelay(100); + mmc_udelay(100); - return ret; + return ret; } -static int sdmmcip_setup_bus(struct sdmmcip_host *host, uint32_t freq) -{ - uint32_t div, status; - int timeout = 10000; - unsigned long sclk; - - if ((freq == host->clock) || (freq == 0)) - return 0; - /* - * If host->get_mmc_clk isn't defined, - * then assume that host->bus_hz is source clock value. - * host->bus_hz should be set by user. - */ - if (host->get_mmc_clk) - sclk = host->get_mmc_clk(host); - else if (host->bus_hz) - sclk = host->bus_hz; - else { - HAL_SDMMC_TRACE(1,"%s: Didn't get source clock value.\n", __func__); - return -EINVAL; - } - - if (sclk == freq) - div = 0; /* bypass mode */ - else - div = _SDMMC_DIV_ROUND_UP(sclk, 2 * freq); - - HAL_SDMMC_TRACE(4,"%s : freq %d, sclk %ld, div %d\n", __func__, freq, sclk, div); - - sdmmcip_writel(host, SDMMCIP_REG_CLKENA, 0); - //sdmmcip_writel(host, SDMMCIP_REG_CLKSRC, 0); - //sdmmcip_writel(host, SDMMCIP_REG_CLKSRC, 0x03000000); - //sdmmcip_writel(host, SDMMCIP_REG_CLKSRC, 0x11000000); - - sdmmcip_writel(host, SDMMCIP_REG_CLKDIV, div); - sdmmcip_writel(host, SDMMCIP_REG_CMD, SDMMCIP_REG_CMD_PRV_DAT_WAIT | - SDMMCIP_REG_CMD_UPD_CLK | SDMMCIP_REG_CMD_START); - - do { - status = sdmmcip_readl(host, SDMMCIP_REG_CMD); - if (timeout-- < 0) { - HAL_SDMMC_TRACE(1,"%s: Timeout!\n", __func__); - return -ETIMEDOUT; - } - } while (status & SDMMCIP_REG_CMD_START); - - sdmmcip_writel(host, SDMMCIP_REG_CLKENA, SDMMCIP_REG_CLKEN_ENABLE | - SDMMCIP_REG_CLKEN_LOW_PWR); - //sdmmcip_writel(host, SDMMCIP_REG_CLKENA, SDMMCIP_REG_CLKEN_ENABLE); - - sdmmcip_writel(host, SDMMCIP_REG_CMD, SDMMCIP_REG_CMD_PRV_DAT_WAIT | - SDMMCIP_REG_CMD_UPD_CLK | SDMMCIP_REG_CMD_START); - - timeout = 10000; - do { - status = sdmmcip_readl(host, SDMMCIP_REG_CMD); - if (timeout-- < 0) { - HAL_SDMMC_TRACE(1,"%s: Timeout!\n", __func__); - return -ETIMEDOUT; - } - } while (status & SDMMCIP_REG_CMD_START); - - host->clock = freq; +static int sdmmcip_setup_bus(struct sdmmcip_host *host, uint32_t freq) { + uint32_t div, status; + int timeout = 10000; + unsigned long sclk; + if ((freq == host->clock) || (freq == 0)) return 0; + /* + * If host->get_mmc_clk isn't defined, + * then assume that host->bus_hz is source clock value. + * host->bus_hz should be set by user. + */ + if (host->get_mmc_clk) + sclk = host->get_mmc_clk(host); + else if (host->bus_hz) + sclk = host->bus_hz; + else { + HAL_SDMMC_TRACE(1, "%s: Didn't get source clock value.\n", __func__); + return -EINVAL; + } + + if (sclk == freq) + div = 0; /* bypass mode */ + else + div = _SDMMC_DIV_ROUND_UP(sclk, 2 * freq); + + HAL_SDMMC_TRACE(4, "%s : freq %d, sclk %ld, div %d\n", __func__, freq, sclk, + div); + + sdmmcip_writel(host, SDMMCIP_REG_CLKENA, 0); + // sdmmcip_writel(host, SDMMCIP_REG_CLKSRC, 0); + // sdmmcip_writel(host, SDMMCIP_REG_CLKSRC, 0x03000000); + // sdmmcip_writel(host, SDMMCIP_REG_CLKSRC, 0x11000000); + + sdmmcip_writel(host, SDMMCIP_REG_CLKDIV, div); + sdmmcip_writel(host, SDMMCIP_REG_CMD, + SDMMCIP_REG_CMD_PRV_DAT_WAIT | SDMMCIP_REG_CMD_UPD_CLK | + SDMMCIP_REG_CMD_START); + + do { + status = sdmmcip_readl(host, SDMMCIP_REG_CMD); + if (timeout-- < 0) { + HAL_SDMMC_TRACE(1, "%s: Timeout!\n", __func__); + return -ETIMEDOUT; + } + } while (status & SDMMCIP_REG_CMD_START); + + sdmmcip_writel(host, SDMMCIP_REG_CLKENA, + SDMMCIP_REG_CLKEN_ENABLE | SDMMCIP_REG_CLKEN_LOW_PWR); + // sdmmcip_writel(host, SDMMCIP_REG_CLKENA, SDMMCIP_REG_CLKEN_ENABLE); + + sdmmcip_writel(host, SDMMCIP_REG_CMD, + SDMMCIP_REG_CMD_PRV_DAT_WAIT | SDMMCIP_REG_CMD_UPD_CLK | + SDMMCIP_REG_CMD_START); + + timeout = 10000; + do { + status = sdmmcip_readl(host, SDMMCIP_REG_CMD); + if (timeout-- < 0) { + HAL_SDMMC_TRACE(1, "%s: Timeout!\n", __func__); + return -ETIMEDOUT; + } + } while (status & SDMMCIP_REG_CMD_START); + + host->clock = freq; + + return 0; } -static void sdmmcip_set_ios(struct mmc *mmc) -{ - struct sdmmcip_host *host = (struct sdmmcip_host *)mmc->priv; - uint32_t ctype, regs; +static void sdmmcip_set_ios(struct mmc *mmc) { + struct sdmmcip_host *host = (struct sdmmcip_host *)mmc->priv; + uint32_t ctype, regs; - HAL_SDMMC_TRACE(2,"Buswidth = %d, clock: %d\n", mmc->bus_width, mmc->clock); + HAL_SDMMC_TRACE(2, "Buswidth = %d, clock: %d\n", mmc->bus_width, mmc->clock); - sdmmcip_setup_bus(host, mmc->clock); + sdmmcip_setup_bus(host, mmc->clock); - switch (mmc->bus_width) { - case 8: - ctype = SDMMCIP_REG_CTYPE_8BIT; - break; - case 4: - ctype = SDMMCIP_REG_CTYPE_4BIT; - break; - default: - ctype = SDMMCIP_REG_CTYPE_1BIT; - break; - } + switch (mmc->bus_width) { + case 8: + ctype = SDMMCIP_REG_CTYPE_8BIT; + break; + case 4: + ctype = SDMMCIP_REG_CTYPE_4BIT; + break; + default: + ctype = SDMMCIP_REG_CTYPE_1BIT; + break; + } - sdmmcip_writel(host, SDMMCIP_REG_CTYPE, ctype); + sdmmcip_writel(host, SDMMCIP_REG_CTYPE, ctype); - regs = sdmmcip_readl(host, SDMMCIP_REG_UHS_REG); - if (mmc->ddr_mode) - regs |= SDMMCIP_REG_DDR_MODE; - else - regs &= ~SDMMCIP_REG_DDR_MODE; + regs = sdmmcip_readl(host, SDMMCIP_REG_UHS_REG); + if (mmc->ddr_mode) + regs |= SDMMCIP_REG_DDR_MODE; + else + regs &= ~SDMMCIP_REG_DDR_MODE; - sdmmcip_writel(host, SDMMCIP_REG_UHS_REG, regs); + sdmmcip_writel(host, SDMMCIP_REG_UHS_REG, regs); - if (host->clksel) - host->clksel(host); + if (host->clksel) + host->clksel(host); } -static int sdmmcip_init(struct mmc *mmc) -{ - struct sdmmcip_host *host = mmc->priv; +static int sdmmcip_init(struct mmc *mmc) { + struct sdmmcip_host *host = mmc->priv; - if (host->board_init) - host->board_init(host); + if (host->board_init) + host->board_init(host); - HAL_SDMMC_TRACE(2,"host->ioaddr %x, SDMMCIP_REG_PWREN %x\n", host->ioaddr, SDMMCIP_REG_PWREN); - sdmmcip_writel(host, SDMMCIP_REG_PWREN, 1); + HAL_SDMMC_TRACE(2, "host->ioaddr %x, SDMMCIP_REG_PWREN %x\n", host->ioaddr, + SDMMCIP_REG_PWREN); + sdmmcip_writel(host, SDMMCIP_REG_PWREN, 1); - if (!sdmmcip_wait_reset(host, SDMMCIP_REG_RESET_ALL)) { - HAL_SDMMC_TRACE(2,"%s[%d] Fail-reset!!\n", __func__, __LINE__); - return -1; - } + if (!sdmmcip_wait_reset(host, SDMMCIP_REG_RESET_ALL)) { + HAL_SDMMC_TRACE(2, "%s[%d] Fail-reset!!\n", __func__, __LINE__); + return -1; + } - /* Enumerate at 400KHz */ - sdmmcip_setup_bus(host, mmc->cfg->f_min); + /* Enumerate at 400KHz */ + sdmmcip_setup_bus(host, mmc->cfg->f_min); - if (host->detect_enb){ - sdmmcip_writel(host, SDMMCIP_REG_RINTSTS, SDMMCIP_REG_INTMSK_ALL&(~SDMMCIP_REG_INTMSK_CD)); - sdmmcip_writel(host, SDMMCIP_REG_INTMASK, SDMMCIP_REG_INTMSK_CD); - sdmmcip_writel(host, SDMMCIP_REG_CTRL, SDMMCIP_REG_INT_EN); - }else{ - sdmmcip_writel(host, SDMMCIP_REG_RINTSTS, SDMMCIP_REG_INTMSK_ALL); - sdmmcip_writel(host, SDMMCIP_REG_INTMASK, ~SDMMCIP_REG_INTMSK_ALL); - } + if (host->detect_enb) { + sdmmcip_writel(host, SDMMCIP_REG_RINTSTS, + SDMMCIP_REG_INTMSK_ALL & (~SDMMCIP_REG_INTMSK_CD)); + sdmmcip_writel(host, SDMMCIP_REG_INTMASK, SDMMCIP_REG_INTMSK_CD); + sdmmcip_writel(host, SDMMCIP_REG_CTRL, SDMMCIP_REG_INT_EN); + } else { + sdmmcip_writel(host, SDMMCIP_REG_RINTSTS, SDMMCIP_REG_INTMSK_ALL); + sdmmcip_writel(host, SDMMCIP_REG_INTMASK, ~SDMMCIP_REG_INTMSK_ALL); + } - sdmmcip_writel(host, SDMMCIP_REG_TMOUT, 0xFFFFFFFF); + sdmmcip_writel(host, SDMMCIP_REG_TMOUT, 0xFFFFFFFF); - sdmmcip_writel(host, SDMMCIP_REG_IDINTEN, 0); - sdmmcip_writel(host, SDMMCIP_REG_BMOD, 1); + sdmmcip_writel(host, SDMMCIP_REG_IDINTEN, 0); + sdmmcip_writel(host, SDMMCIP_REG_BMOD, 1); - sdmmcip_writel(host, SDMMCIP_REG_FIFOTH, host->fifoth_val); + sdmmcip_writel(host, SDMMCIP_REG_FIFOTH, host->fifoth_val); - sdmmcip_writel(host, SDMMCIP_REG_CLKENA, 0); - //sdmmcip_writel(host, SDMMCIP_REG_CLKSRC, 0); - //sdmmcip_writel(host, SDMMCIP_REG_CLKSRC, 0x03000000); - //sdmmcip_writel(host, SDMMCIP_REG_CLKSRC, 0x11000000); + sdmmcip_writel(host, SDMMCIP_REG_CLKENA, 0); + // sdmmcip_writel(host, SDMMCIP_REG_CLKSRC, 0); + // sdmmcip_writel(host, SDMMCIP_REG_CLKSRC, 0x03000000); + // sdmmcip_writel(host, SDMMCIP_REG_CLKSRC, 0x11000000); - sdmmcip_writel(host, SDMMCIP_REG_RESET_CARD, 0); - mmc_udelay(1000); - sdmmcip_writel(host, SDMMCIP_REG_RESET_CARD, 1); - mmc_udelay(1000); - mmc_udelay(1000); - sdmmcip_writel(host, SDMMCIP_REG_RESET_CARD, 0); - //sdmmcip_writel(host, SDMMCIP_REG_RESET_CARD, 1); + sdmmcip_writel(host, SDMMCIP_REG_RESET_CARD, 0); + mmc_udelay(1000); + sdmmcip_writel(host, SDMMCIP_REG_RESET_CARD, 1); + mmc_udelay(1000); + mmc_udelay(1000); + sdmmcip_writel(host, SDMMCIP_REG_RESET_CARD, 0); + // sdmmcip_writel(host, SDMMCIP_REG_RESET_CARD, 1); - return 0; + return 0; } static const struct mmc_ops sdmmcip_ops = { - .send_cmd = sdmmcip_send_cmd, - .set_ios = sdmmcip_set_ios, - .init = sdmmcip_init, + .send_cmd = sdmmcip_send_cmd, + .set_ios = sdmmcip_set_ios, + .init = sdmmcip_init, }; -int board_mmc_getcd(struct mmc *mmc) -{ - return -1; +int board_mmc_getcd(struct mmc *mmc) { return -1; } + +int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) { + int ret; + + int i; + uint8_t *ptr; + + HAL_SDMMC_TRACE(1, "CMD_SEND:%d\n", cmd->cmdidx); + HAL_SDMMC_TRACE(1, "\t\tARG\t\t\t 0x%08X\n", cmd->cmdarg); + ret = mmc->cfg->ops->send_cmd(mmc, cmd, data); + HAL_SDMMC_TRACE(0, "send cmd end..."); + switch (cmd->resp_type) { + case MMC_RSP_NONE: + HAL_SDMMC_TRACE(0, "\t\tMMC_RSP_NONE\n"); + break; + case MMC_RSP_R1: + HAL_SDMMC_TRACE(1, "\t\tMMC_RSP_R1,5,6,7 \t 0x%08X \n", cmd->response[0]); + break; + case MMC_RSP_R1b: + HAL_SDMMC_TRACE(1, "\t\tMMC_RSP_R1b\t\t 0x%08X \n", cmd->response[0]); + break; + case MMC_RSP_R2: + HAL_SDMMC_TRACE(1, "\t\tMMC_RSP_R2\t\t 0x%08X \n", cmd->response[0]); + HAL_SDMMC_TRACE(1, "\t\t \t\t 0x%08X \n", cmd->response[1]); + HAL_SDMMC_TRACE(1, "\t\t \t\t 0x%08X \n", cmd->response[2]); + HAL_SDMMC_TRACE(1, "\t\t \t\t 0x%08X \n", cmd->response[3]); + HAL_SDMMC_TRACE(0, "\n"); + HAL_SDMMC_TRACE(0, "\t\t\t\t\tDUMPING DATA\n"); + for (i = 0; i < 4; i++) { + int j; + HAL_SDMMC_TRACE(1, "\t\t\t\t\t%03d - ", i * 4); + ptr = (uint8_t *)&cmd->response[i]; + ptr += 3; + for (j = 0; j < 4; j++) + HAL_SDMMC_TRACE(1, "%02X ", *ptr--); + HAL_SDMMC_TRACE(0, "\n"); + } + break; + case MMC_RSP_R3: + HAL_SDMMC_TRACE(1, "\t\tMMC_RSP_R3,4\t\t 0x%08X \n", cmd->response[0]); + break; + default: + HAL_SDMMC_TRACE(0, "\t\tERROR MMC rsp not supported\n"); + break; + } + return ret; } -int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) -{ - int ret; +int mmc_send_status(struct mmc *mmc, int timeout) { + struct mmc_cmd cmd; + int err, retries = 5; + int POSSIBLY_UNUSED status; - int i; - uint8_t *ptr; + cmd.cmdidx = MMC_CMD_SEND_STATUS; + cmd.resp_type = MMC_RSP_R1; + if (!sdmmc_host_is_spi(mmc)) + cmd.cmdarg = mmc->rca << 16; - HAL_SDMMC_TRACE(1,"CMD_SEND:%d\n", cmd->cmdidx); - HAL_SDMMC_TRACE(1,"\t\tARG\t\t\t 0x%08X\n", cmd->cmdarg); - ret = mmc->cfg->ops->send_cmd(mmc, cmd, data); - HAL_SDMMC_TRACE(0,"send cmd end..."); - switch (cmd->resp_type) { - case MMC_RSP_NONE: - HAL_SDMMC_TRACE(0,"\t\tMMC_RSP_NONE\n"); - break; - case MMC_RSP_R1: - HAL_SDMMC_TRACE(1,"\t\tMMC_RSP_R1,5,6,7 \t 0x%08X \n", - cmd->response[0]); - break; - case MMC_RSP_R1b: - HAL_SDMMC_TRACE(1,"\t\tMMC_RSP_R1b\t\t 0x%08X \n", - cmd->response[0]); - break; - case MMC_RSP_R2: - HAL_SDMMC_TRACE(1,"\t\tMMC_RSP_R2\t\t 0x%08X \n", - cmd->response[0]); - HAL_SDMMC_TRACE(1,"\t\t \t\t 0x%08X \n", - cmd->response[1]); - HAL_SDMMC_TRACE(1,"\t\t \t\t 0x%08X \n", - cmd->response[2]); - HAL_SDMMC_TRACE(1,"\t\t \t\t 0x%08X \n", - cmd->response[3]); - HAL_SDMMC_TRACE(0,"\n"); - HAL_SDMMC_TRACE(0,"\t\t\t\t\tDUMPING DATA\n"); - for (i = 0; i < 4; i++) { - int j; - HAL_SDMMC_TRACE(1,"\t\t\t\t\t%03d - ", i*4); - ptr = (uint8_t *)&cmd->response[i]; - ptr += 3; - for (j = 0; j < 4; j++) - HAL_SDMMC_TRACE(1,"%02X ", *ptr--); - HAL_SDMMC_TRACE(0,"\n"); - } - break; - case MMC_RSP_R3: - HAL_SDMMC_TRACE(1,"\t\tMMC_RSP_R3,4\t\t 0x%08X \n", - cmd->response[0]); - break; - default: - HAL_SDMMC_TRACE(0,"\t\tERROR MMC rsp not supported\n"); - break; - } - return ret; + while (1) { + err = mmc_send_cmd(mmc, &cmd, NULL); + if (!err) { + if ((cmd.response[0] & MMC_STATUS_RDY_FOR_DATA) && + (cmd.response[0] & MMC_STATUS_CURR_STATE) != MMC_STATE_PRG) + break; + else if (cmd.response[0] & MMC_STATUS_MASK) { + return COMM_ERR; + } + } else if (--retries < 0) + return err; + + if (timeout-- <= 0) + break; + + mmc_udelay(1000); + } + + status = (cmd.response[0] & MMC_STATUS_CURR_STATE) >> 9; + HAL_SDMMC_TRACE(1, "CURR STATE:%d\n", status); + if (timeout <= 0) { + return TIMEOUT; + } + if (cmd.response[0] & MMC_STATUS_SWITCH_ERROR) + return SWITCH_ERR; + + return 0; } -int mmc_send_status(struct mmc *mmc, int timeout) -{ - struct mmc_cmd cmd; - int err, retries = 5; - int POSSIBLY_UNUSED status; - - cmd.cmdidx = MMC_CMD_SEND_STATUS; - cmd.resp_type = MMC_RSP_R1; - if (!sdmmc_host_is_spi(mmc)) - cmd.cmdarg = mmc->rca << 16; - - while (1) { - err = mmc_send_cmd(mmc, &cmd, NULL); - if (!err) { - if ((cmd.response[0] & MMC_STATUS_RDY_FOR_DATA) && - (cmd.response[0] & MMC_STATUS_CURR_STATE) != - MMC_STATE_PRG) - break; - else if (cmd.response[0] & MMC_STATUS_MASK) { - return COMM_ERR; - } - } else if (--retries < 0) - return err; - - if (timeout-- <= 0) - break; - - mmc_udelay(1000); - } - - status = (cmd.response[0] & MMC_STATUS_CURR_STATE) >> 9; - HAL_SDMMC_TRACE(1,"CURR STATE:%d\n", status); - if (timeout <= 0) { - return TIMEOUT; - } - if (cmd.response[0] & MMC_STATUS_SWITCH_ERROR) - return SWITCH_ERR; +int mmc_set_blocklen(struct mmc *mmc, int len) { + struct mmc_cmd cmd; + if (mmc->ddr_mode) return 0; + + cmd.cmdidx = MMC_CMD_SET_BLOCKLEN; + cmd.resp_type = MMC_RSP_R1; + cmd.cmdarg = len; + + return mmc_send_cmd(mmc, &cmd, NULL); } -int mmc_set_blocklen(struct mmc *mmc, int len) -{ - struct mmc_cmd cmd; - - if (mmc->ddr_mode) - return 0; - - cmd.cmdidx = MMC_CMD_SET_BLOCKLEN; - cmd.resp_type = MMC_RSP_R1; - cmd.cmdarg = len; - - return mmc_send_cmd(mmc, &cmd, NULL); -} - -struct mmc *find_mmc_device(int dev_num) -{ - return &sdmmc_devices[dev_num]; +struct mmc *find_mmc_device(int dev_num) { + return &sdmmc_devices[dev_num]; } static int mmc_read_blocks(struct mmc *mmc, void *dst, uint32_t start, - uint32_t blkcnt) -{ - struct mmc_cmd cmd; - struct mmc_data data; + uint32_t blkcnt) { + struct mmc_cmd cmd; + struct mmc_data data; - if (blkcnt > 1) - cmd.cmdidx = MMC_CMD_READ_MULTIPLE_BLOCK; - else - cmd.cmdidx = MMC_CMD_READ_SINGLE_BLOCK; + if (blkcnt > 1) + cmd.cmdidx = MMC_CMD_READ_MULTIPLE_BLOCK; + else + cmd.cmdidx = MMC_CMD_READ_SINGLE_BLOCK; - if (mmc->high_capacity) - cmd.cmdarg = start; - else - cmd.cmdarg = start * mmc->read_bl_len; - - cmd.resp_type = MMC_RSP_R1; - - data.dest = dst; - data.blocks = blkcnt; - data.blocksize = mmc->read_bl_len; - data.flags = MMC_DATA_READ; - - if (mmc_send_cmd(mmc, &cmd, &data)) - return 0; - - if (blkcnt > 1) { - cmd.cmdidx = MMC_CMD_STOP_TRANSMISSION; - cmd.cmdarg = 0; - cmd.resp_type = MMC_RSP_R1b; - if (mmc_send_cmd(mmc, &cmd, NULL)) { - return 0; - } - } - - return blkcnt; -} - -static unsigned long mmc_bread(int dev_num, uint32_t start, uint32_t blkcnt, void *dst) -{ - uint32_t cur, blocks_todo = blkcnt; - - if (blkcnt == 0) - return 0; - - struct mmc *mmc = find_mmc_device(dev_num); - if (!mmc) - return 0; - - if ((start + blkcnt) > mmc->block_dev.lba) { - return 0; - } - - if (mmc_set_blocklen(mmc, mmc->read_bl_len)) - return 0; - - do { - cur = (blocks_todo > mmc->cfg->b_max) ? - mmc->cfg->b_max : blocks_todo; - if(mmc_read_blocks(mmc, dst, start, cur) != cur) - return 0; - blocks_todo -= cur; - start += cur; - dst += cur * mmc->read_bl_len; - } while (blocks_todo > 0); - - return blkcnt; -} - -static unsigned long mmc_erase_t(struct mmc *mmc, unsigned long start, uint32_t blkcnt) -{ - struct mmc_cmd cmd; - unsigned long end; - int err, start_cmd, end_cmd; - - if (mmc->high_capacity) { - end = start + blkcnt - 1; - } else { - end = (start + blkcnt - 1) * mmc->write_bl_len; - start *= mmc->write_bl_len; - } - - if (IS_SD(mmc)) { - start_cmd = SD_CMD_ERASE_WR_BLK_START; - end_cmd = SD_CMD_ERASE_WR_BLK_END; - } else { - start_cmd = MMC_CMD_ERASE_GROUP_START; - end_cmd = MMC_CMD_ERASE_GROUP_END; - } - - cmd.cmdidx = start_cmd; + if (mmc->high_capacity) cmd.cmdarg = start; - cmd.resp_type = MMC_RSP_R1; + else + cmd.cmdarg = start * mmc->read_bl_len; - err = mmc_send_cmd(mmc, &cmd, NULL); - if (err) - goto err_out; + cmd.resp_type = MMC_RSP_R1; - cmd.cmdidx = end_cmd; - cmd.cmdarg = end; - - err = mmc_send_cmd(mmc, &cmd, NULL); - if (err) - goto err_out; - - cmd.cmdidx = MMC_CMD_ERASE; - cmd.cmdarg = SECURE_ERASE; - cmd.resp_type = MMC_RSP_R1b; - - err = mmc_send_cmd(mmc, &cmd, NULL); - if (err) - goto err_out; + data.dest = dst; + data.blocks = blkcnt; + data.blocksize = mmc->read_bl_len; + data.flags = MMC_DATA_READ; + if (mmc_send_cmd(mmc, &cmd, &data)) return 0; -err_out: - //puts("mmc erase failed\n"); - return err; + if (blkcnt > 1) { + cmd.cmdidx = MMC_CMD_STOP_TRANSMISSION; + cmd.cmdarg = 0; + cmd.resp_type = MMC_RSP_R1b; + if (mmc_send_cmd(mmc, &cmd, NULL)) { + return 0; + } + } + + return blkcnt; } -unsigned long mmc_berase(int dev_num, uint32_t start, uint32_t blkcnt) -{ - int err = 0; - struct mmc *mmc = find_mmc_device(dev_num); - uint32_t blk = 0, blk_r = 0; - int timeout = 1000; +static unsigned long mmc_bread(int dev_num, uint32_t start, uint32_t blkcnt, + void *dst) { + uint32_t cur, blocks_todo = blkcnt; - if (!mmc) - return -1; + if (blkcnt == 0) + return 0; - if ((start % mmc->erase_grp_size) || (blkcnt % mmc->erase_grp_size)) - //printf("\n\nCaution! Your devices Erase group is 0x%x\n" - // "The erase range would be change to " - // "0x" LBAF "~0x" LBAF "\n\n", - // mmc->erase_grp_size, start & ~(mmc->erase_grp_size - 1), - // ((start + blkcnt + mmc->erase_grp_size) - // & ~(mmc->erase_grp_size - 1)) - 1); + struct mmc *mmc = find_mmc_device(dev_num); + if (!mmc) + return 0; - while (blk < blkcnt) { - blk_r = ((blkcnt - blk) > mmc->erase_grp_size) ? - mmc->erase_grp_size : (blkcnt - blk); - err = mmc_erase_t(mmc, start + blk, blk_r); - if (err) - break; + if ((start + blkcnt) > mmc->block_dev.lba) { + return 0; + } - blk += blk_r; + if (mmc_set_blocklen(mmc, mmc->read_bl_len)) + return 0; - /* Waiting for the ready status */ - if (mmc_send_status(mmc, timeout)) - return 0; - } + do { + cur = (blocks_todo > mmc->cfg->b_max) ? mmc->cfg->b_max : blocks_todo; + if (mmc_read_blocks(mmc, dst, start, cur) != cur) + return 0; + blocks_todo -= cur; + start += cur; + dst += cur * mmc->read_bl_len; + } while (blocks_todo > 0); - return blk; + return blkcnt; +} + +static unsigned long mmc_erase_t(struct mmc *mmc, unsigned long start, + uint32_t blkcnt) { + struct mmc_cmd cmd; + unsigned long end; + int err, start_cmd, end_cmd; + + if (mmc->high_capacity) { + end = start + blkcnt - 1; + } else { + end = (start + blkcnt - 1) * mmc->write_bl_len; + start *= mmc->write_bl_len; + } + + if (IS_SD(mmc)) { + start_cmd = SD_CMD_ERASE_WR_BLK_START; + end_cmd = SD_CMD_ERASE_WR_BLK_END; + } else { + start_cmd = MMC_CMD_ERASE_GROUP_START; + end_cmd = MMC_CMD_ERASE_GROUP_END; + } + + cmd.cmdidx = start_cmd; + cmd.cmdarg = start; + cmd.resp_type = MMC_RSP_R1; + + err = mmc_send_cmd(mmc, &cmd, NULL); + if (err) + goto err_out; + + cmd.cmdidx = end_cmd; + cmd.cmdarg = end; + + err = mmc_send_cmd(mmc, &cmd, NULL); + if (err) + goto err_out; + + cmd.cmdidx = MMC_CMD_ERASE; + cmd.cmdarg = SECURE_ERASE; + cmd.resp_type = MMC_RSP_R1b; + + err = mmc_send_cmd(mmc, &cmd, NULL); + if (err) + goto err_out; + + return 0; + +err_out: + // puts("mmc erase failed\n"); + return err; +} + +unsigned long mmc_berase(int dev_num, uint32_t start, uint32_t blkcnt) { + int err = 0; + struct mmc *mmc = find_mmc_device(dev_num); + uint32_t blk = 0, blk_r = 0; + int timeout = 1000; + + if (!mmc) + return -1; + + if ((start % mmc->erase_grp_size) || (blkcnt % mmc->erase_grp_size)) + // printf("\n\nCaution! Your devices Erase group is 0x%x\n" + // "The erase range would be change to " + // "0x" LBAF "~0x" LBAF "\n\n", + // mmc->erase_grp_size, start & ~(mmc->erase_grp_size - 1), + // ((start + blkcnt + mmc->erase_grp_size) + // & ~(mmc->erase_grp_size - 1)) - 1); + + while (blk < blkcnt) { + blk_r = ((blkcnt - blk) > mmc->erase_grp_size) ? mmc->erase_grp_size + : (blkcnt - blk); + err = mmc_erase_t(mmc, start + blk, blk_r); + if (err) + break; + + blk += blk_r; + + /* Waiting for the ready status */ + if (mmc_send_status(mmc, timeout)) + return 0; + } + + return blk; } static unsigned long mmc_write_blocks(struct mmc *mmc, uint32_t start, - uint32_t blkcnt, const void *src) -{ - struct mmc_cmd cmd; - struct mmc_data data; - int timeout = 1000; + uint32_t blkcnt, const void *src) { + struct mmc_cmd cmd; + struct mmc_data data; + int timeout = 1000; - if ((start + blkcnt) > mmc->block_dev.lba) { - return 0; - } + if ((start + blkcnt) > mmc->block_dev.lba) { + return 0; + } - if (blkcnt == 0) - return 0; - else if (blkcnt == 1) - cmd.cmdidx = MMC_CMD_WRITE_SINGLE_BLOCK; - else - cmd.cmdidx = MMC_CMD_WRITE_MULTIPLE_BLOCK; + if (blkcnt == 0) + return 0; + else if (blkcnt == 1) + cmd.cmdidx = MMC_CMD_WRITE_SINGLE_BLOCK; + else + cmd.cmdidx = MMC_CMD_WRITE_MULTIPLE_BLOCK; - if (mmc->high_capacity) - cmd.cmdarg = start; - else - cmd.cmdarg = start * mmc->write_bl_len; + if (mmc->high_capacity) + cmd.cmdarg = start; + else + cmd.cmdarg = start * mmc->write_bl_len; - cmd.resp_type = MMC_RSP_R1; + cmd.resp_type = MMC_RSP_R1; - data.src = src; - data.blocks = blkcnt; - data.blocksize = mmc->write_bl_len; - data.flags = MMC_DATA_WRITE; + data.src = src; + data.blocks = blkcnt; + data.blocksize = mmc->write_bl_len; + data.flags = MMC_DATA_WRITE; - if (mmc_send_cmd(mmc, &cmd, &data)) { - HAL_SDMMC_TRACE(0,"mmc write failed\n"); - return 0; - } + if (mmc_send_cmd(mmc, &cmd, &data)) { + HAL_SDMMC_TRACE(0, "mmc write failed\n"); + return 0; + } - /* SPI multiblock writes terminate using a special - * token, not a STOP_TRANSMISSION request. - */ - if (!sdmmc_host_is_spi(mmc) && blkcnt > 1) { - cmd.cmdidx = MMC_CMD_STOP_TRANSMISSION; - cmd.cmdarg = 0; - cmd.resp_type = MMC_RSP_R1b; - if (mmc_send_cmd(mmc, &cmd, NULL)) { - HAL_SDMMC_TRACE(0,"mmc fail to send stop cmd\n"); - return 0; - } - } - - /* Waiting for the ready status */ - if (mmc_send_status(mmc, timeout)) - return 0; - - return blkcnt; -} - -unsigned long mmc_bwrite(int dev_num, uint32_t start, uint32_t blkcnt, const void *src) -{ - uint32_t cur, blocks_todo = blkcnt; - - struct mmc *mmc = find_mmc_device(dev_num); - if (!mmc) - return 0; - - if (mmc_set_blocklen(mmc, mmc->write_bl_len)) - return 0; - - do { - cur = (blocks_todo > mmc->cfg->b_max) ? - mmc->cfg->b_max : blocks_todo; - if (mmc_write_blocks(mmc, start, cur, src) != cur) - return 0; - blocks_todo -= cur; - start += cur; - src += cur * mmc->write_bl_len; - } while (blocks_todo > 0); - - return blkcnt; -} - -static int mmc_go_idle(struct mmc *mmc) -{ - struct mmc_cmd cmd; - int err; - - mmc_udelay(1000); - - cmd.cmdidx = MMC_CMD_GO_IDLE_STATE; + /* SPI multiblock writes terminate using a special + * token, not a STOP_TRANSMISSION request. + */ + if (!sdmmc_host_is_spi(mmc) && blkcnt > 1) { + cmd.cmdidx = MMC_CMD_STOP_TRANSMISSION; cmd.cmdarg = 0; - cmd.resp_type = MMC_RSP_NONE; - - err = mmc_send_cmd(mmc, &cmd, NULL); - - if (err) - return err; - - mmc_udelay(2000); - - return 0; -} - -static int sd_send_op_cond(struct mmc *mmc) -{ - int timeout = 1000; - int err; - struct mmc_cmd cmd; - - while (1) { - cmd.cmdidx = MMC_CMD_APP_CMD; - cmd.resp_type = MMC_RSP_R1; - cmd.cmdarg = 0; - - err = mmc_send_cmd(mmc, &cmd, NULL); - - if (err) - return err; - - cmd.cmdidx = SD_CMD_APP_SEND_OP_COND; - cmd.resp_type = MMC_RSP_R3; - - /* - * Most cards do not answer if some reserved bits - * in the ocr are set. However, Some controller - * can set bit 7 (reserved for low voltages), but - * how to manage low voltages SD card is not yet - * specified. - */ - cmd.cmdarg = sdmmc_host_is_spi(mmc) ? 0 : - (mmc->cfg->voltages & 0xff8000); - - if (mmc->version == SD_VERSION_2) - cmd.cmdarg |= OCR_HCS; - - err = mmc_send_cmd(mmc, &cmd, NULL); - - if (err) - return err; - - if (cmd.response[0] & OCR_BUSY) - break; - - if (timeout-- <= 0) - return UNUSABLE_ERR; - - mmc_udelay(1000); - } - - if (mmc->version != SD_VERSION_2) - mmc->version = SD_VERSION_1_0; - - if (sdmmc_host_is_spi(mmc)) { /* read OCR for spi */ - cmd.cmdidx = MMC_CMD_SPI_READ_OCR; - cmd.resp_type = MMC_RSP_R3; - cmd.cmdarg = 0; - - err = mmc_send_cmd(mmc, &cmd, NULL); - - if (err) - return err; - } - - mmc->ocr = cmd.response[0]; - - mmc->high_capacity = ((mmc->ocr & OCR_HCS) == OCR_HCS); - mmc->rca = 0; - - return 0; -} - -static int mmc_send_op_cond_iter(struct mmc *mmc, int use_arg) -{ - struct mmc_cmd cmd; - int err; - - cmd.cmdidx = MMC_CMD_SEND_OP_COND; - cmd.resp_type = MMC_RSP_R3; - cmd.cmdarg = 0; - if (use_arg && !sdmmc_host_is_spi(mmc)) - cmd.cmdarg = OCR_HCS | - (mmc->cfg->voltages & - (mmc->ocr & OCR_VOLTAGE_MASK)) | - (mmc->ocr & OCR_ACCESS_MODE); - - err = mmc_send_cmd(mmc, &cmd, NULL); - if (err) - return err; - mmc->ocr = cmd.response[0]; - return 0; -} - -static int mmc_send_op_cond(struct mmc *mmc) -{ - int err, i; - - /* Some cards seem to need this */ - // mmc_go_idle(mmc); - - /* Asking to the card its capabilities */ - for (i = 0; i < 2; i++) { - err = mmc_send_op_cond_iter(mmc, i != 0); - if (err) - return err; - - /* exit if not busy (flag seems to be inverted) */ - if (mmc->ocr & OCR_BUSY) - break; - } - mmc->op_cond_pending = 1; - return 0; -} - -static int mmc_complete_op_cond(struct mmc *mmc) -{ - struct mmc_cmd cmd; - int err; - - mmc->op_cond_pending = 0; - if (!(mmc->ocr & OCR_BUSY)) { - while (1) { - err = mmc_send_op_cond_iter(mmc, 1); - if (err) - return err; - if (mmc->ocr & OCR_BUSY) - break; - mmc_udelay(100); - } - } - - if (sdmmc_host_is_spi(mmc)) { /* read OCR for spi */ - cmd.cmdidx = MMC_CMD_SPI_READ_OCR; - cmd.resp_type = MMC_RSP_R3; - cmd.cmdarg = 0; - - err = mmc_send_cmd(mmc, &cmd, NULL); - - if (err) - return err; - - mmc->ocr = cmd.response[0]; - } - - mmc->version = MMC_VERSION_UNKNOWN; - - mmc->high_capacity = ((mmc->ocr & OCR_HCS) == OCR_HCS); - mmc->rca = 1; - - return 0; -} - - -static int mmc_send_ext_csd(struct mmc *mmc, uint8_t *ext_csd) -{ - struct mmc_cmd cmd; - struct mmc_data data; - int err; - - /* Get the Card Status Register */ - cmd.cmdidx = MMC_CMD_SEND_EXT_CSD; - cmd.resp_type = MMC_RSP_R1; - cmd.cmdarg = 0; - - data.dest = (char *)ext_csd; - data.blocks = 1; - data.blocksize = MMC_MAX_BLOCK_LEN; - data.flags = MMC_DATA_READ; - - HAL_SDMMC_TRACE(1,"[%s] start...", __func__); - err = mmc_send_cmd(mmc, &cmd, &data); - HAL_SDMMC_TRACE(2,"[%s] err = %d", __func__, err); - - return err; -} - - -static int mmc_switch(struct mmc *mmc, uint8_t set, uint8_t index, uint8_t value) -{ - struct mmc_cmd cmd; - int timeout = 1000; - int ret; - - cmd.cmdidx = MMC_CMD_SWITCH; cmd.resp_type = MMC_RSP_R1b; - cmd.cmdarg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) | - (index << 16) | - (value << 8); - - ret = mmc_send_cmd(mmc, &cmd, NULL); - - /* Waiting for the ready status */ - if (!ret) - ret = mmc_send_status(mmc, timeout); - - return ret; - -} - -static int mmc_change_freq(struct mmc *mmc) -{ - _SDMMC_ALLOC_CACHE_ALIGN_BUFFER(uint8_t, ext_csd, MMC_MAX_BLOCK_LEN); - char cardtype; - int err; - - mmc->card_caps = 0; - - if (sdmmc_host_is_spi(mmc)) - return 0; - - /* Only version 4 supports high-speed */ - if (mmc->version < MMC_VERSION_4) - return 0; - - mmc->card_caps |= MMC_MODE_4BIT | MMC_MODE_8BIT; - - err = mmc_send_ext_csd(mmc, ext_csd); - - if (err) - return err; - - cardtype = ext_csd[EXT_CSD_CARD_TYPE] & 0xf; - - err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, 1); - - if (err) - return err == SWITCH_ERR ? 0 : err; - - /* Now check to see that it worked */ - err = mmc_send_ext_csd(mmc, ext_csd); - - if (err) - return err; - - /* No high-speed support */ - if (!ext_csd[EXT_CSD_HS_TIMING]) - return 0; - - /* High Speed is set, there are two types: 52MHz and 26MHz */ - if (cardtype & EXT_CSD_CARD_TYPE_52) { - if (cardtype & EXT_CSD_CARD_TYPE_DDR_1_8V) - mmc->card_caps |= MMC_MODE_DDR_52MHz; - mmc->card_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS; - } else { - mmc->card_caps |= MMC_MODE_HS; + if (mmc_send_cmd(mmc, &cmd, NULL)) { + HAL_SDMMC_TRACE(0, "mmc fail to send stop cmd\n"); + return 0; } + } + /* Waiting for the ready status */ + if (mmc_send_status(mmc, timeout)) return 0; + + return blkcnt; } -static int mmc_set_capacity(struct mmc *mmc, int part_num) -{ - switch (part_num) { - case 0: - mmc->capacity = mmc->capacity_user; - break; - case 1: - case 2: - mmc->capacity = mmc->capacity_boot; - break; - case 3: - mmc->capacity = mmc->capacity_rpmb; - break; - case 4: - case 5: - case 6: - case 7: - mmc->capacity = mmc->capacity_gp[part_num - 4]; - break; - default: - return -1; - } - - mmc->block_dev.lba = _sdmmc_lldiv(mmc->capacity, mmc->read_bl_len); +unsigned long mmc_bwrite(int dev_num, uint32_t start, uint32_t blkcnt, + const void *src) { + uint32_t cur, blocks_todo = blkcnt; + struct mmc *mmc = find_mmc_device(dev_num); + if (!mmc) return 0; + + if (mmc_set_blocklen(mmc, mmc->write_bl_len)) + return 0; + + do { + cur = (blocks_todo > mmc->cfg->b_max) ? mmc->cfg->b_max : blocks_todo; + if (mmc_write_blocks(mmc, start, cur, src) != cur) + return 0; + blocks_todo -= cur; + start += cur; + src += cur * mmc->write_bl_len; + } while (blocks_todo > 0); + + return blkcnt; } -int mmc_getcd(struct mmc *mmc) -{ - int cd; +static int mmc_go_idle(struct mmc *mmc) { + struct mmc_cmd cmd; + int err; - cd = board_mmc_getcd(mmc); + mmc_udelay(1000); - if (cd < 0) { - if (mmc->cfg->ops->getcd) - cd = mmc->cfg->ops->getcd(mmc); - else - cd = 1; - } + cmd.cmdidx = MMC_CMD_GO_IDLE_STATE; + cmd.cmdarg = 0; + cmd.resp_type = MMC_RSP_NONE; - return cd; + err = mmc_send_cmd(mmc, &cmd, NULL); + + if (err) + return err; + + mmc_udelay(2000); + + return 0; } -static int sd_switch(struct mmc *mmc, int mode, int group, uint8_t value, uint8_t *resp) -{ - struct mmc_cmd cmd; - struct mmc_data data; +static int sd_send_op_cond(struct mmc *mmc) { + int timeout = 1000; + int err; + struct mmc_cmd cmd; - /* Switch the frequency */ - cmd.cmdidx = SD_CMD_SWITCH_FUNC; - cmd.resp_type = MMC_RSP_R1; - cmd.cmdarg = (mode << 31) | 0xffffff; - cmd.cmdarg &= ~(0xf << (group * 4)); - cmd.cmdarg |= value << (group * 4); - - data.dest = (char *)resp; - data.blocksize = 64; - data.blocks = 1; - data.flags = MMC_DATA_READ; - - hal_sdmmc_delay(1); - - return mmc_send_cmd(mmc, &cmd, &data); -} - - -static int sd_change_freq(struct mmc *mmc) -{ - int err; - struct mmc_cmd cmd; - _SDMMC_ALLOC_CACHE_ALIGN_BUFFER(uint32_t, scr, 2); - _SDMMC_ALLOC_CACHE_ALIGN_BUFFER(uint32_t, switch_status, 16); - struct mmc_data data; - int timeout; - - mmc->card_caps = 0; - - if (sdmmc_host_is_spi(mmc)) - return 0; - - /* Read the SCR to find out if this card supports higher speeds */ + while (1) { cmd.cmdidx = MMC_CMD_APP_CMD; cmd.resp_type = MMC_RSP_R1; - cmd.cmdarg = mmc->rca << 16; + cmd.cmdarg = 0; err = mmc_send_cmd(mmc, &cmd, NULL); if (err) - return err; + return err; - cmd.cmdidx = SD_CMD_APP_SEND_SCR; - cmd.resp_type = MMC_RSP_R1; - cmd.cmdarg = 0; - - timeout = 3; - -retry_scr: - data.dest = (char *)scr; - data.blocksize = 8; - data.blocks = 1; - data.flags = MMC_DATA_READ; - - err = mmc_send_cmd(mmc, &cmd, &data); - - if (err) { - if (timeout--) - goto retry_scr; - - return err; - } - - mmc->scr[0] = _sdmmc_be32_to_cpu(scr[0]); - mmc->scr[1] = _sdmmc_be32_to_cpu(scr[1]); - - switch ((mmc->scr[0] >> 24) & 0xf) { - case 0: - mmc->version = SD_VERSION_1_0; - break; - case 1: - mmc->version = SD_VERSION_1_10; - break; - case 2: - mmc->version = SD_VERSION_2; - if ((mmc->scr[0] >> 15) & 0x1) - mmc->version = SD_VERSION_3; - break; - default: - mmc->version = SD_VERSION_1_0; - break; - } - - if (mmc->scr[0] & SD_DATA_4BIT) - mmc->card_caps |= MMC_MODE_4BIT; - - /* Version 1.0 doesn't support switching */ - if (mmc->version == SD_VERSION_1_0) - return 0; - - timeout = 4; - while (timeout--) { - err = sd_switch(mmc, SD_SWITCH_CHECK, 0, 1, - (uint8_t *)switch_status); - - if (err) - return err; - - /* The high-speed function is busy. Try again */ - if (!(_sdmmc_be32_to_cpu(switch_status[7]) & SD_HIGHSPEED_BUSY)) - break; - } - - /* If high-speed isn't supported, we return */ - if (!(_sdmmc_be32_to_cpu(switch_status[3]) & SD_HIGHSPEED_SUPPORTED)) - return 0; + cmd.cmdidx = SD_CMD_APP_SEND_OP_COND; + cmd.resp_type = MMC_RSP_R3; /* - * If the host doesn't support SD_HIGHSPEED, do not switch card to - * HIGHSPEED mode even if the card support SD_HIGHSPPED. - * This can avoid furthur problem when the card runs in different - * mode between the host. + * Most cards do not answer if some reserved bits + * in the ocr are set. However, Some controller + * can set bit 7 (reserved for low voltages), but + * how to manage low voltages SD card is not yet + * specified. */ - if (!((mmc->cfg->host_caps & MMC_MODE_HS_52MHz) && - (mmc->cfg->host_caps & MMC_MODE_HS))) - return 0; + cmd.cmdarg = sdmmc_host_is_spi(mmc) ? 0 : (mmc->cfg->voltages & 0xff8000); - err = sd_switch(mmc, SD_SWITCH_SWITCH, 0, 1, (uint8_t *)switch_status); + if (mmc->version == SD_VERSION_2) + cmd.cmdarg |= OCR_HCS; + + err = mmc_send_cmd(mmc, &cmd, NULL); if (err) + return err; + + if (cmd.response[0] & OCR_BUSY) + break; + + if (timeout-- <= 0) + return UNUSABLE_ERR; + + mmc_udelay(1000); + } + + if (mmc->version != SD_VERSION_2) + mmc->version = SD_VERSION_1_0; + + if (sdmmc_host_is_spi(mmc)) { /* read OCR for spi */ + cmd.cmdidx = MMC_CMD_SPI_READ_OCR; + cmd.resp_type = MMC_RSP_R3; + cmd.cmdarg = 0; + + err = mmc_send_cmd(mmc, &cmd, NULL); + + if (err) + return err; + } + + mmc->ocr = cmd.response[0]; + + mmc->high_capacity = ((mmc->ocr & OCR_HCS) == OCR_HCS); + mmc->rca = 0; + + return 0; +} + +static int mmc_send_op_cond_iter(struct mmc *mmc, int use_arg) { + struct mmc_cmd cmd; + int err; + + cmd.cmdidx = MMC_CMD_SEND_OP_COND; + cmd.resp_type = MMC_RSP_R3; + cmd.cmdarg = 0; + if (use_arg && !sdmmc_host_is_spi(mmc)) + cmd.cmdarg = OCR_HCS | + (mmc->cfg->voltages & (mmc->ocr & OCR_VOLTAGE_MASK)) | + (mmc->ocr & OCR_ACCESS_MODE); + + err = mmc_send_cmd(mmc, &cmd, NULL); + if (err) + return err; + mmc->ocr = cmd.response[0]; + return 0; +} + +static int mmc_send_op_cond(struct mmc *mmc) { + int err, i; + + /* Some cards seem to need this */ + // mmc_go_idle(mmc); + + /* Asking to the card its capabilities */ + for (i = 0; i < 2; i++) { + err = mmc_send_op_cond_iter(mmc, i != 0); + if (err) + return err; + + /* exit if not busy (flag seems to be inverted) */ + if (mmc->ocr & OCR_BUSY) + break; + } + mmc->op_cond_pending = 1; + return 0; +} + +static int mmc_complete_op_cond(struct mmc *mmc) { + struct mmc_cmd cmd; + int err; + + mmc->op_cond_pending = 0; + if (!(mmc->ocr & OCR_BUSY)) { + while (1) { + err = mmc_send_op_cond_iter(mmc, 1); + if (err) return err; + if (mmc->ocr & OCR_BUSY) + break; + mmc_udelay(100); + } + } - if ((_sdmmc_be32_to_cpu(switch_status[4]) & 0x0f000000) == 0x01000000) - mmc->card_caps |= MMC_MODE_HS; + if (sdmmc_host_is_spi(mmc)) { /* read OCR for spi */ + cmd.cmdidx = MMC_CMD_SPI_READ_OCR; + cmd.resp_type = MMC_RSP_R3; + cmd.cmdarg = 0; + err = mmc_send_cmd(mmc, &cmd, NULL); + + if (err) + return err; + + mmc->ocr = cmd.response[0]; + } + + mmc->version = MMC_VERSION_UNKNOWN; + + mmc->high_capacity = ((mmc->ocr & OCR_HCS) == OCR_HCS); + mmc->rca = 1; + + return 0; +} + +static int mmc_send_ext_csd(struct mmc *mmc, uint8_t *ext_csd) { + struct mmc_cmd cmd; + struct mmc_data data; + int err; + + /* Get the Card Status Register */ + cmd.cmdidx = MMC_CMD_SEND_EXT_CSD; + cmd.resp_type = MMC_RSP_R1; + cmd.cmdarg = 0; + + data.dest = (char *)ext_csd; + data.blocks = 1; + data.blocksize = MMC_MAX_BLOCK_LEN; + data.flags = MMC_DATA_READ; + + HAL_SDMMC_TRACE(1, "[%s] start...", __func__); + err = mmc_send_cmd(mmc, &cmd, &data); + HAL_SDMMC_TRACE(2, "[%s] err = %d", __func__, err); + + return err; +} + +static int mmc_switch(struct mmc *mmc, uint8_t set, uint8_t index, + uint8_t value) { + struct mmc_cmd cmd; + int timeout = 1000; + int ret; + + cmd.cmdidx = MMC_CMD_SWITCH; + cmd.resp_type = MMC_RSP_R1b; + cmd.cmdarg = + (MMC_SWITCH_MODE_WRITE_BYTE << 24) | (index << 16) | (value << 8); + + ret = mmc_send_cmd(mmc, &cmd, NULL); + + /* Waiting for the ready status */ + if (!ret) + ret = mmc_send_status(mmc, timeout); + + return ret; +} + +static int mmc_change_freq(struct mmc *mmc) { + _SDMMC_ALLOC_CACHE_ALIGN_BUFFER(uint8_t, ext_csd, MMC_MAX_BLOCK_LEN); + char cardtype; + int err; + + mmc->card_caps = 0; + + if (sdmmc_host_is_spi(mmc)) return 0; + + /* Only version 4 supports high-speed */ + if (mmc->version < MMC_VERSION_4) + return 0; + + mmc->card_caps |= MMC_MODE_4BIT | MMC_MODE_8BIT; + + err = mmc_send_ext_csd(mmc, ext_csd); + + if (err) + return err; + + cardtype = ext_csd[EXT_CSD_CARD_TYPE] & 0xf; + + err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, 1); + + if (err) + return err == SWITCH_ERR ? 0 : err; + + /* Now check to see that it worked */ + err = mmc_send_ext_csd(mmc, ext_csd); + + if (err) + return err; + + /* No high-speed support */ + if (!ext_csd[EXT_CSD_HS_TIMING]) + return 0; + + /* High Speed is set, there are two types: 52MHz and 26MHz */ + if (cardtype & EXT_CSD_CARD_TYPE_52) { + if (cardtype & EXT_CSD_CARD_TYPE_DDR_1_8V) + mmc->card_caps |= MMC_MODE_DDR_52MHz; + mmc->card_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS; + } else { + mmc->card_caps |= MMC_MODE_HS; + } + + return 0; +} + +static int mmc_set_capacity(struct mmc *mmc, int part_num) { + switch (part_num) { + case 0: + mmc->capacity = mmc->capacity_user; + break; + case 1: + case 2: + mmc->capacity = mmc->capacity_boot; + break; + case 3: + mmc->capacity = mmc->capacity_rpmb; + break; + case 4: + case 5: + case 6: + case 7: + mmc->capacity = mmc->capacity_gp[part_num - 4]; + break; + default: + return -1; + } + + mmc->block_dev.lba = _sdmmc_lldiv(mmc->capacity, mmc->read_bl_len); + + return 0; +} + +int mmc_getcd(struct mmc *mmc) { + int cd; + + cd = board_mmc_getcd(mmc); + + if (cd < 0) { + if (mmc->cfg->ops->getcd) + cd = mmc->cfg->ops->getcd(mmc); + else + cd = 1; + } + + return cd; +} + +static int sd_switch(struct mmc *mmc, int mode, int group, uint8_t value, + uint8_t *resp) { + struct mmc_cmd cmd; + struct mmc_data data; + + /* Switch the frequency */ + cmd.cmdidx = SD_CMD_SWITCH_FUNC; + cmd.resp_type = MMC_RSP_R1; + cmd.cmdarg = (mode << 31) | 0xffffff; + cmd.cmdarg &= ~(0xf << (group * 4)); + cmd.cmdarg |= value << (group * 4); + + data.dest = (char *)resp; + data.blocksize = 64; + data.blocks = 1; + data.flags = MMC_DATA_READ; + + hal_sdmmc_delay(1); + + return mmc_send_cmd(mmc, &cmd, &data); +} + +static int sd_change_freq(struct mmc *mmc) { + int err; + struct mmc_cmd cmd; + _SDMMC_ALLOC_CACHE_ALIGN_BUFFER(uint32_t, scr, 2); + _SDMMC_ALLOC_CACHE_ALIGN_BUFFER(uint32_t, switch_status, 16); + struct mmc_data data; + int timeout; + + mmc->card_caps = 0; + + if (sdmmc_host_is_spi(mmc)) + return 0; + + /* Read the SCR to find out if this card supports higher speeds */ + cmd.cmdidx = MMC_CMD_APP_CMD; + cmd.resp_type = MMC_RSP_R1; + cmd.cmdarg = mmc->rca << 16; + + err = mmc_send_cmd(mmc, &cmd, NULL); + + if (err) + return err; + + cmd.cmdidx = SD_CMD_APP_SEND_SCR; + cmd.resp_type = MMC_RSP_R1; + cmd.cmdarg = 0; + + timeout = 3; + +retry_scr: + data.dest = (char *)scr; + data.blocksize = 8; + data.blocks = 1; + data.flags = MMC_DATA_READ; + + err = mmc_send_cmd(mmc, &cmd, &data); + + if (err) { + if (timeout--) + goto retry_scr; + + return err; + } + + mmc->scr[0] = _sdmmc_be32_to_cpu(scr[0]); + mmc->scr[1] = _sdmmc_be32_to_cpu(scr[1]); + + switch ((mmc->scr[0] >> 24) & 0xf) { + case 0: + mmc->version = SD_VERSION_1_0; + break; + case 1: + mmc->version = SD_VERSION_1_10; + break; + case 2: + mmc->version = SD_VERSION_2; + if ((mmc->scr[0] >> 15) & 0x1) + mmc->version = SD_VERSION_3; + break; + default: + mmc->version = SD_VERSION_1_0; + break; + } + + if (mmc->scr[0] & SD_DATA_4BIT) + mmc->card_caps |= MMC_MODE_4BIT; + + /* Version 1.0 doesn't support switching */ + if (mmc->version == SD_VERSION_1_0) + return 0; + + timeout = 4; + while (timeout--) { + err = sd_switch(mmc, SD_SWITCH_CHECK, 0, 1, (uint8_t *)switch_status); + + if (err) + return err; + + /* The high-speed function is busy. Try again */ + if (!(_sdmmc_be32_to_cpu(switch_status[7]) & SD_HIGHSPEED_BUSY)) + break; + } + + /* If high-speed isn't supported, we return */ + if (!(_sdmmc_be32_to_cpu(switch_status[3]) & SD_HIGHSPEED_SUPPORTED)) + return 0; + + /* + * If the host doesn't support SD_HIGHSPEED, do not switch card to + * HIGHSPEED mode even if the card support SD_HIGHSPPED. + * This can avoid furthur problem when the card runs in different + * mode between the host. + */ + if (!((mmc->cfg->host_caps & MMC_MODE_HS_52MHz) && + (mmc->cfg->host_caps & MMC_MODE_HS))) + return 0; + + err = sd_switch(mmc, SD_SWITCH_SWITCH, 0, 1, (uint8_t *)switch_status); + + if (err) + return err; + + if ((_sdmmc_be32_to_cpu(switch_status[4]) & 0x0f000000) == 0x01000000) + mmc->card_caps |= MMC_MODE_HS; + + return 0; } /* frequency bases */ @@ -1899,929 +1866,938 @@ static const int fbase[] = { * to platforms without floating point. */ static const int multipliers[] = { - 0, /* reserved */ - 10, - 12, - 13, - 15, - 20, - 25, - 30, - 35, - 40, - 45, - 50, - 55, - 60, - 70, - 80, + 0, /* reserved */ + 10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80, }; -static void mmc_set_ios(struct mmc *mmc) -{ - if (mmc->cfg->ops->set_ios) - mmc->cfg->ops->set_ios(mmc); +static void mmc_set_ios(struct mmc *mmc) { + if (mmc->cfg->ops->set_ios) + mmc->cfg->ops->set_ios(mmc); } -void mmc_set_clock(struct mmc *mmc, uint32_t clock) -{ - if (clock > mmc->cfg->f_max) - clock = mmc->cfg->f_max; +void mmc_set_clock(struct mmc *mmc, uint32_t clock) { + if (clock > mmc->cfg->f_max) + clock = mmc->cfg->f_max; - if (clock < mmc->cfg->f_min) - clock = mmc->cfg->f_min; + if (clock < mmc->cfg->f_min) + clock = mmc->cfg->f_min; - mmc->clock = clock; + mmc->clock = clock; - mmc_set_ios(mmc); + mmc_set_ios(mmc); } -static void mmc_set_bus_width(struct mmc *mmc, uint32_t width) -{ - mmc->bus_width = width; +static void mmc_set_bus_width(struct mmc *mmc, uint32_t width) { + mmc->bus_width = width; - mmc_set_ios(mmc); + mmc_set_ios(mmc); } -static int mmc_startup(struct mmc *mmc) -{ - int err, i; - uint32_t mult, freq; - uint32_t cmult, csize, capacity; - struct mmc_cmd cmd; - _SDMMC_ALLOC_CACHE_ALIGN_BUFFER(uint8_t, ext_csd, MMC_MAX_BLOCK_LEN); - _SDMMC_ALLOC_CACHE_ALIGN_BUFFER(uint8_t, test_csd, MMC_MAX_BLOCK_LEN); - int timeout = 1000; - bool has_parts = false; - bool part_completed; +static int mmc_startup(struct mmc *mmc) { + int err, i; + uint32_t mult, freq; + uint32_t cmult, csize, capacity; + struct mmc_cmd cmd; + _SDMMC_ALLOC_CACHE_ALIGN_BUFFER(uint8_t, ext_csd, MMC_MAX_BLOCK_LEN); + _SDMMC_ALLOC_CACHE_ALIGN_BUFFER(uint8_t, test_csd, MMC_MAX_BLOCK_LEN); + int timeout = 1000; + bool has_parts = false; + bool part_completed; #ifdef CONFIG_MMC_SPI_CRC_ON - if (sdmmc_host_is_spi(mmc)) { /* enable CRC check for spi */ - cmd.cmdidx = MMC_CMD_SPI_CRC_ON_OFF; - cmd.resp_type = MMC_RSP_R1; - cmd.cmdarg = 1; - err = mmc_send_cmd(mmc, &cmd, NULL); - - if (err) - return err; - } -#endif - - /* Put the Card in Identify Mode */ - cmd.cmdidx = sdmmc_host_is_spi(mmc) ? MMC_CMD_SEND_CID : - MMC_CMD_ALL_SEND_CID; /* cmd not supported in spi */ - cmd.resp_type = MMC_RSP_R2; - cmd.cmdarg = 0; - + if (sdmmc_host_is_spi(mmc)) { /* enable CRC check for spi */ + cmd.cmdidx = MMC_CMD_SPI_CRC_ON_OFF; + cmd.resp_type = MMC_RSP_R1; + cmd.cmdarg = 1; err = mmc_send_cmd(mmc, &cmd, NULL); if (err) - return err; + return err; + } +#endif - memcpy(mmc->cid, cmd.response, 16); + /* Put the Card in Identify Mode */ + cmd.cmdidx = sdmmc_host_is_spi(mmc) + ? MMC_CMD_SEND_CID + : MMC_CMD_ALL_SEND_CID; /* cmd not supported in spi */ + cmd.resp_type = MMC_RSP_R2; + cmd.cmdarg = 0; - /* - * For MMC cards, set the Relative Address. - * For SD cards, get the Relatvie Address. - * This also puts the cards into Standby State - */ - if (!sdmmc_host_is_spi(mmc)) { /* cmd not supported in spi */ - cmd.cmdidx = SD_CMD_SEND_RELATIVE_ADDR; - cmd.cmdarg = mmc->rca << 16; - cmd.resp_type = MMC_RSP_R6; + err = mmc_send_cmd(mmc, &cmd, NULL); - err = mmc_send_cmd(mmc, &cmd, NULL); + if (err) + return err; - if (err) - return err; + memcpy(mmc->cid, cmd.response, 16); - if (IS_SD(mmc)) - mmc->rca = (cmd.response[0] >> 16) & 0xffff; - } - - /* Get the Card-Specific Data */ - cmd.cmdidx = MMC_CMD_SEND_CSD; - cmd.resp_type = MMC_RSP_R2; + /* + * For MMC cards, set the Relative Address. + * For SD cards, get the Relatvie Address. + * This also puts the cards into Standby State + */ + if (!sdmmc_host_is_spi(mmc)) { /* cmd not supported in spi */ + cmd.cmdidx = SD_CMD_SEND_RELATIVE_ADDR; cmd.cmdarg = mmc->rca << 16; + cmd.resp_type = MMC_RSP_R6; err = mmc_send_cmd(mmc, &cmd, NULL); - /* Waiting for the ready status */ - mmc_send_status(mmc, timeout); - if (err) - return err; - - mmc->csd[0] = cmd.response[0]; - mmc->csd[1] = cmd.response[1]; - mmc->csd[2] = cmd.response[2]; - mmc->csd[3] = cmd.response[3]; - - if (mmc->version == MMC_VERSION_UNKNOWN) { - int version = (cmd.response[0] >> 26) & 0xf; - - switch (version) { - case 0: - mmc->version = MMC_VERSION_1_2; - break; - case 1: - mmc->version = MMC_VERSION_1_4; - break; - case 2: - mmc->version = MMC_VERSION_2_2; - break; - case 3: - mmc->version = MMC_VERSION_3; - break; - case 4: - mmc->version = MMC_VERSION_4; - break; - default: - mmc->version = MMC_VERSION_1_2; - break; - } - } - - /* divide frequency by 10, since the mults are 10x bigger */ - freq = fbase[(cmd.response[0] & 0x7)]; - mult = multipliers[((cmd.response[0] >> 3) & 0xf)]; - - mmc->tran_speed = freq * mult; - - mmc->dsr_imp = ((cmd.response[1] >> 12) & 0x1); - mmc->read_bl_len = 1 << ((cmd.response[1] >> 16) & 0xf); + return err; if (IS_SD(mmc)) - mmc->write_bl_len = mmc->read_bl_len; - else - mmc->write_bl_len = 1 << ((cmd.response[3] >> 22) & 0xf); + mmc->rca = (cmd.response[0] >> 16) & 0xffff; + } - if (mmc->high_capacity) { - csize = (mmc->csd[1] & 0x3f) << 16 - | (mmc->csd[2] & 0xffff0000) >> 16; - cmult = 8; - } else { - csize = (mmc->csd[1] & 0x3ff) << 2 - | (mmc->csd[2] & 0xc0000000) >> 30; - cmult = (mmc->csd[2] & 0x00038000) >> 15; + /* Get the Card-Specific Data */ + cmd.cmdidx = MMC_CMD_SEND_CSD; + cmd.resp_type = MMC_RSP_R2; + cmd.cmdarg = mmc->rca << 16; + + err = mmc_send_cmd(mmc, &cmd, NULL); + + /* Waiting for the ready status */ + mmc_send_status(mmc, timeout); + + if (err) + return err; + + mmc->csd[0] = cmd.response[0]; + mmc->csd[1] = cmd.response[1]; + mmc->csd[2] = cmd.response[2]; + mmc->csd[3] = cmd.response[3]; + + if (mmc->version == MMC_VERSION_UNKNOWN) { + int version = (cmd.response[0] >> 26) & 0xf; + + switch (version) { + case 0: + mmc->version = MMC_VERSION_1_2; + break; + case 1: + mmc->version = MMC_VERSION_1_4; + break; + case 2: + mmc->version = MMC_VERSION_2_2; + break; + case 3: + mmc->version = MMC_VERSION_3; + break; + case 4: + mmc->version = MMC_VERSION_4; + break; + default: + mmc->version = MMC_VERSION_1_2; + break; + } + } + + /* divide frequency by 10, since the mults are 10x bigger */ + freq = fbase[(cmd.response[0] & 0x7)]; + mult = multipliers[((cmd.response[0] >> 3) & 0xf)]; + + mmc->tran_speed = freq * mult; + + mmc->dsr_imp = ((cmd.response[1] >> 12) & 0x1); + mmc->read_bl_len = 1 << ((cmd.response[1] >> 16) & 0xf); + + if (IS_SD(mmc)) + mmc->write_bl_len = mmc->read_bl_len; + else + mmc->write_bl_len = 1 << ((cmd.response[3] >> 22) & 0xf); + + if (mmc->high_capacity) { + csize = (mmc->csd[1] & 0x3f) << 16 | (mmc->csd[2] & 0xffff0000) >> 16; + cmult = 8; + } else { + csize = (mmc->csd[1] & 0x3ff) << 2 | (mmc->csd[2] & 0xc0000000) >> 30; + cmult = (mmc->csd[2] & 0x00038000) >> 15; + } + + mmc->capacity_user = (csize + 1) << (cmult + 2); + mmc->capacity_user *= mmc->read_bl_len; + mmc->capacity_boot = 0; + mmc->capacity_rpmb = 0; + for (i = 0; i < 4; i++) + mmc->capacity_gp[i] = 0; + + if (mmc->read_bl_len > MMC_MAX_BLOCK_LEN) + mmc->read_bl_len = MMC_MAX_BLOCK_LEN; + + if (mmc->write_bl_len > MMC_MAX_BLOCK_LEN) + mmc->write_bl_len = MMC_MAX_BLOCK_LEN; + + if ((mmc->dsr_imp) && (0xffffffff != mmc->dsr)) { + cmd.cmdidx = MMC_CMD_SET_DSR; + cmd.cmdarg = (mmc->dsr & 0xffff) << 16; + cmd.resp_type = MMC_RSP_NONE; + if (mmc_send_cmd(mmc, &cmd, NULL)) { + HAL_SDMMC_TRACE(0, "MMC: SET_DSR failed\n"); + } + } + + /* Select the card, and put it into Transfer Mode */ + if (!sdmmc_host_is_spi(mmc)) { /* cmd not supported in spi */ + cmd.cmdidx = MMC_CMD_SELECT_CARD; + cmd.resp_type = MMC_RSP_R1; + cmd.cmdarg = mmc->rca << 16; + err = mmc_send_cmd(mmc, &cmd, NULL); + + if (err) + return err; + } + + /* + * For SD, its erase group is always one sector + */ + mmc->erase_grp_size = 1; + mmc->part_config = MMCPART_NOAVAILABLE; + if (!IS_SD(mmc) && (mmc->version >= MMC_VERSION_4)) { + /* check ext_csd version and capacity */ + err = mmc_send_ext_csd(mmc, ext_csd); + if (err) + return err; + if (ext_csd[EXT_CSD_REV] >= 2) { + /* + * According to the JEDEC Standard, the value of + * ext_csd's capacity is valid if the value is more + * than 2GB + */ + capacity = ext_csd[EXT_CSD_SEC_CNT] << 0 | + ext_csd[EXT_CSD_SEC_CNT + 1] << 8 | + ext_csd[EXT_CSD_SEC_CNT + 2] << 16 | + ext_csd[EXT_CSD_SEC_CNT + 3] << 24; + capacity *= MMC_MAX_BLOCK_LEN; + if ((capacity >> 20) > 2 * 1024) + mmc->capacity_user = capacity; } - mmc->capacity_user = (csize + 1) << (cmult + 2); - mmc->capacity_user *= mmc->read_bl_len; - mmc->capacity_boot = 0; - mmc->capacity_rpmb = 0; - for (i = 0; i < 4; i++) - mmc->capacity_gp[i] = 0; - - if (mmc->read_bl_len > MMC_MAX_BLOCK_LEN) - mmc->read_bl_len = MMC_MAX_BLOCK_LEN; - - if (mmc->write_bl_len > MMC_MAX_BLOCK_LEN) - mmc->write_bl_len = MMC_MAX_BLOCK_LEN; - - if ((mmc->dsr_imp) && (0xffffffff != mmc->dsr)) { - cmd.cmdidx = MMC_CMD_SET_DSR; - cmd.cmdarg = (mmc->dsr & 0xffff) << 16; - cmd.resp_type = MMC_RSP_NONE; - if (mmc_send_cmd(mmc, &cmd, NULL)) { - HAL_SDMMC_TRACE(0,"MMC: SET_DSR failed\n"); - } + switch (ext_csd[EXT_CSD_REV]) { + case 1: + mmc->version = MMC_VERSION_4_1; + break; + case 2: + mmc->version = MMC_VERSION_4_2; + break; + case 3: + mmc->version = MMC_VERSION_4_3; + break; + case 5: + mmc->version = MMC_VERSION_4_41; + break; + case 6: + mmc->version = MMC_VERSION_4_5; + break; + case 7: + mmc->version = MMC_VERSION_5_0; + break; } - /* Select the card, and put it into Transfer Mode */ - if (!sdmmc_host_is_spi(mmc)) { /* cmd not supported in spi */ - cmd.cmdidx = MMC_CMD_SELECT_CARD; - cmd.resp_type = MMC_RSP_R1; - cmd.cmdarg = mmc->rca << 16; - err = mmc_send_cmd(mmc, &cmd, NULL); + /* The partition data may be non-zero but it is only + * effective if PARTITION_SETTING_COMPLETED is set in + * EXT_CSD, so ignore any data if this bit is not set, + * except for enabling the high-capacity group size + * definition (see below). */ + part_completed = !!(ext_csd[EXT_CSD_PARTITION_SETTING] & + EXT_CSD_PARTITION_SETTING_COMPLETED); - if (err) - return err; + /* store the partition info of emmc */ + mmc->part_support = ext_csd[EXT_CSD_PARTITIONING_SUPPORT]; + if ((ext_csd[EXT_CSD_PARTITIONING_SUPPORT] & PART_SUPPORT) || + ext_csd[EXT_CSD_BOOT_MULT]) + mmc->part_config = ext_csd[EXT_CSD_PART_CONF]; + if (part_completed && + (ext_csd[EXT_CSD_PARTITIONING_SUPPORT] & ENHNCD_SUPPORT)) + mmc->part_attr = ext_csd[EXT_CSD_PARTITIONS_ATTRIBUTE]; + + mmc->capacity_boot = ext_csd[EXT_CSD_BOOT_MULT] << 17; + + mmc->capacity_rpmb = ext_csd[EXT_CSD_RPMB_MULT] << 17; + + for (i = 0; i < 4; i++) { + int idx = EXT_CSD_GP_SIZE_MULT + i * 3; + uint32_t mult = + (ext_csd[idx + 2] << 16) + (ext_csd[idx + 1] << 8) + ext_csd[idx]; + if (mult) + has_parts = true; + if (!part_completed) + continue; + mmc->capacity_gp[i] = mult; + mmc->capacity_gp[i] *= ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]; + mmc->capacity_gp[i] *= ext_csd[EXT_CSD_HC_WP_GRP_SIZE]; + mmc->capacity_gp[i] <<= 19; + } + + if (part_completed) { + mmc->enh_user_size = (ext_csd[EXT_CSD_ENH_SIZE_MULT + 2] << 16) + + (ext_csd[EXT_CSD_ENH_SIZE_MULT + 1] << 8) + + ext_csd[EXT_CSD_ENH_SIZE_MULT]; + mmc->enh_user_size *= ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]; + mmc->enh_user_size *= ext_csd[EXT_CSD_HC_WP_GRP_SIZE]; + mmc->enh_user_size <<= 19; + mmc->enh_user_start = (ext_csd[EXT_CSD_ENH_START_ADDR + 3] << 24) + + (ext_csd[EXT_CSD_ENH_START_ADDR + 2] << 16) + + (ext_csd[EXT_CSD_ENH_START_ADDR + 1] << 8) + + ext_csd[EXT_CSD_ENH_START_ADDR]; + if (mmc->high_capacity) + mmc->enh_user_start <<= 9; } /* - * For SD, its erase group is always one sector + * Host needs to enable ERASE_GRP_DEF bit if device is + * partitioned. This bit will be lost every time after a reset + * or power off. This will affect erase size. */ - mmc->erase_grp_size = 1; - mmc->part_config = MMCPART_NOAVAILABLE; - if (!IS_SD(mmc) && (mmc->version >= MMC_VERSION_4)) { - /* check ext_csd version and capacity */ - err = mmc_send_ext_csd(mmc, ext_csd); - if (err) - return err; - if (ext_csd[EXT_CSD_REV] >= 2) { - /* - * According to the JEDEC Standard, the value of - * ext_csd's capacity is valid if the value is more - * than 2GB - */ - capacity = ext_csd[EXT_CSD_SEC_CNT] << 0 - | ext_csd[EXT_CSD_SEC_CNT + 1] << 8 - | ext_csd[EXT_CSD_SEC_CNT + 2] << 16 - | ext_csd[EXT_CSD_SEC_CNT + 3] << 24; - capacity *= MMC_MAX_BLOCK_LEN; - if ((capacity >> 20) > 2 * 1024) - mmc->capacity_user = capacity; - } + if (part_completed) + has_parts = true; + if ((ext_csd[EXT_CSD_PARTITIONING_SUPPORT] & PART_SUPPORT) && + (ext_csd[EXT_CSD_PARTITIONS_ATTRIBUTE] & PART_ENH_ATTRIB)) + has_parts = true; + if (has_parts) { + err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_ERASE_GROUP_DEF, 1); - switch (ext_csd[EXT_CSD_REV]) { - case 1: - mmc->version = MMC_VERSION_4_1; - break; - case 2: - mmc->version = MMC_VERSION_4_2; - break; - case 3: - mmc->version = MMC_VERSION_4_3; - break; - case 5: - mmc->version = MMC_VERSION_4_41; - break; - case 6: - mmc->version = MMC_VERSION_4_5; - break; - case 7: - mmc->version = MMC_VERSION_5_0; - break; - } - - /* The partition data may be non-zero but it is only - * effective if PARTITION_SETTING_COMPLETED is set in - * EXT_CSD, so ignore any data if this bit is not set, - * except for enabling the high-capacity group size - * definition (see below). */ - part_completed = !!(ext_csd[EXT_CSD_PARTITION_SETTING] & - EXT_CSD_PARTITION_SETTING_COMPLETED); - - /* store the partition info of emmc */ - mmc->part_support = ext_csd[EXT_CSD_PARTITIONING_SUPPORT]; - if ((ext_csd[EXT_CSD_PARTITIONING_SUPPORT] & PART_SUPPORT) || - ext_csd[EXT_CSD_BOOT_MULT]) - mmc->part_config = ext_csd[EXT_CSD_PART_CONF]; - if (part_completed && - (ext_csd[EXT_CSD_PARTITIONING_SUPPORT] & ENHNCD_SUPPORT)) - mmc->part_attr = ext_csd[EXT_CSD_PARTITIONS_ATTRIBUTE]; - - mmc->capacity_boot = ext_csd[EXT_CSD_BOOT_MULT] << 17; - - mmc->capacity_rpmb = ext_csd[EXT_CSD_RPMB_MULT] << 17; - - for (i = 0; i < 4; i++) { - int idx = EXT_CSD_GP_SIZE_MULT + i * 3; - uint32_t mult = (ext_csd[idx + 2] << 16) + - (ext_csd[idx + 1] << 8) + ext_csd[idx]; - if (mult) - has_parts = true; - if (!part_completed) - continue; - mmc->capacity_gp[i] = mult; - mmc->capacity_gp[i] *= - ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]; - mmc->capacity_gp[i] *= ext_csd[EXT_CSD_HC_WP_GRP_SIZE]; - mmc->capacity_gp[i] <<= 19; - } - - if (part_completed) { - mmc->enh_user_size = - (ext_csd[EXT_CSD_ENH_SIZE_MULT+2] << 16) + - (ext_csd[EXT_CSD_ENH_SIZE_MULT+1] << 8) + - ext_csd[EXT_CSD_ENH_SIZE_MULT]; - mmc->enh_user_size *= ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]; - mmc->enh_user_size *= ext_csd[EXT_CSD_HC_WP_GRP_SIZE]; - mmc->enh_user_size <<= 19; - mmc->enh_user_start = - (ext_csd[EXT_CSD_ENH_START_ADDR+3] << 24) + - (ext_csd[EXT_CSD_ENH_START_ADDR+2] << 16) + - (ext_csd[EXT_CSD_ENH_START_ADDR+1] << 8) + - ext_csd[EXT_CSD_ENH_START_ADDR]; - if (mmc->high_capacity) - mmc->enh_user_start <<= 9; - } - - /* - * Host needs to enable ERASE_GRP_DEF bit if device is - * partitioned. This bit will be lost every time after a reset - * or power off. This will affect erase size. - */ - if (part_completed) - has_parts = true; - if ((ext_csd[EXT_CSD_PARTITIONING_SUPPORT] & PART_SUPPORT) && - (ext_csd[EXT_CSD_PARTITIONS_ATTRIBUTE] & PART_ENH_ATTRIB)) - has_parts = true; - if (has_parts) { - err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, - EXT_CSD_ERASE_GROUP_DEF, 1); - - if (err) - return err; - else - ext_csd[EXT_CSD_ERASE_GROUP_DEF] = 1; - } - - if (ext_csd[EXT_CSD_ERASE_GROUP_DEF] & 0x01) { - /* Read out group size from ext_csd */ - mmc->erase_grp_size = - ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] * 1024; - /* - * if high capacity and partition setting completed - * SEC_COUNT is valid even if it is smaller than 2 GiB - * JEDEC Standard JESD84-B45, 6.2.4 - */ - if (mmc->high_capacity && part_completed) { - capacity = (ext_csd[EXT_CSD_SEC_CNT]) | - (ext_csd[EXT_CSD_SEC_CNT + 1] << 8) | - (ext_csd[EXT_CSD_SEC_CNT + 2] << 16) | - (ext_csd[EXT_CSD_SEC_CNT + 3] << 24); - capacity *= MMC_MAX_BLOCK_LEN; - mmc->capacity_user = capacity; - } - } else { - /* Calculate the group size from the csd value. */ - int erase_gsz, erase_gmul; - erase_gsz = (mmc->csd[2] & 0x00007c00) >> 10; - erase_gmul = (mmc->csd[2] & 0x000003e0) >> 5; - mmc->erase_grp_size = (erase_gsz + 1) - * (erase_gmul + 1); - } - - mmc->hc_wp_grp_size = 1024 - * ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] - * ext_csd[EXT_CSD_HC_WP_GRP_SIZE]; - - mmc->wr_rel_set = ext_csd[EXT_CSD_WR_REL_SET]; + if (err) + return err; + else + ext_csd[EXT_CSD_ERASE_GROUP_DEF] = 1; } - err = mmc_set_capacity(mmc, mmc->part_num); - if (err) - return err; + if (ext_csd[EXT_CSD_ERASE_GROUP_DEF] & 0x01) { + /* Read out group size from ext_csd */ + mmc->erase_grp_size = ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] * 1024; + /* + * if high capacity and partition setting completed + * SEC_COUNT is valid even if it is smaller than 2 GiB + * JEDEC Standard JESD84-B45, 6.2.4 + */ + if (mmc->high_capacity && part_completed) { + capacity = (ext_csd[EXT_CSD_SEC_CNT]) | + (ext_csd[EXT_CSD_SEC_CNT + 1] << 8) | + (ext_csd[EXT_CSD_SEC_CNT + 2] << 16) | + (ext_csd[EXT_CSD_SEC_CNT + 3] << 24); + capacity *= MMC_MAX_BLOCK_LEN; + mmc->capacity_user = capacity; + } + } else { + /* Calculate the group size from the csd value. */ + int erase_gsz, erase_gmul; + erase_gsz = (mmc->csd[2] & 0x00007c00) >> 10; + erase_gmul = (mmc->csd[2] & 0x000003e0) >> 5; + mmc->erase_grp_size = (erase_gsz + 1) * (erase_gmul + 1); + } - if (IS_SD(mmc)) - err = sd_change_freq(mmc); - else - err = mmc_change_freq(mmc); + mmc->hc_wp_grp_size = 1024 * ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] * + ext_csd[EXT_CSD_HC_WP_GRP_SIZE]; - if (err) - return err; + mmc->wr_rel_set = ext_csd[EXT_CSD_WR_REL_SET]; + } - /* Restrict card's capabilities by what the host can do */ - mmc->card_caps &= mmc->cfg->host_caps; + err = mmc_set_capacity(mmc, mmc->part_num); + if (err) + return err; - if (IS_SD(mmc)) { + if (IS_SD(mmc)) + err = sd_change_freq(mmc); + else + err = mmc_change_freq(mmc); + + if (err) + return err; + + /* Restrict card's capabilities by what the host can do */ + mmc->card_caps &= mmc->cfg->host_caps; + + if (IS_SD(mmc)) { #ifdef __BUS_WIDTH_SUPPORT_4BIT__ - if (mmc->card_caps & MMC_MODE_4BIT) { - cmd.cmdidx = MMC_CMD_APP_CMD; - cmd.resp_type = MMC_RSP_R1; - cmd.cmdarg = mmc->rca << 16; + if (mmc->card_caps & MMC_MODE_4BIT) { + cmd.cmdidx = MMC_CMD_APP_CMD; + cmd.resp_type = MMC_RSP_R1; + cmd.cmdarg = mmc->rca << 16; - err = mmc_send_cmd(mmc, &cmd, NULL); - if (err) - return err; + err = mmc_send_cmd(mmc, &cmd, NULL); + if (err) + return err; - cmd.cmdidx = SD_CMD_APP_SET_BUS_WIDTH; - cmd.resp_type = MMC_RSP_R1; - cmd.cmdarg = 2; - err = mmc_send_cmd(mmc, &cmd, NULL); - if (err) - return err; + cmd.cmdidx = SD_CMD_APP_SET_BUS_WIDTH; + cmd.resp_type = MMC_RSP_R1; + cmd.cmdarg = 2; + err = mmc_send_cmd(mmc, &cmd, NULL); + if (err) + return err; - mmc_set_bus_width(mmc, 4); - } + mmc_set_bus_width(mmc, 4); + } #endif - if (mmc->card_caps & MMC_MODE_HS) - mmc->tran_speed = 50000000; - else - mmc->tran_speed = 25000000; - } else if (mmc->version >= MMC_VERSION_4) { - /* Only version 4 of MMC supports wider bus widths */ - int idx; + if (mmc->card_caps & MMC_MODE_HS) + mmc->tran_speed = 50000000; + else + mmc->tran_speed = 25000000; + } else if (mmc->version >= MMC_VERSION_4) { + /* Only version 4 of MMC supports wider bus widths */ + int idx; - /* An array of possible bus widths in order of preference */ - static unsigned ext_csd_bits[] = { - EXT_CSD_DDR_BUS_WIDTH_8, - EXT_CSD_DDR_BUS_WIDTH_4, - EXT_CSD_BUS_WIDTH_8, - EXT_CSD_BUS_WIDTH_4, - EXT_CSD_BUS_WIDTH_1, - }; + /* An array of possible bus widths in order of preference */ + static unsigned ext_csd_bits[] = { + EXT_CSD_DDR_BUS_WIDTH_8, EXT_CSD_DDR_BUS_WIDTH_4, EXT_CSD_BUS_WIDTH_8, + EXT_CSD_BUS_WIDTH_4, EXT_CSD_BUS_WIDTH_1, + }; - /* An array to map CSD bus widths to host cap bits */ - static unsigned ext_to_hostcaps[] = { - [EXT_CSD_DDR_BUS_WIDTH_4] = - MMC_MODE_DDR_52MHz | MMC_MODE_4BIT, - [EXT_CSD_DDR_BUS_WIDTH_8] = - MMC_MODE_DDR_52MHz | MMC_MODE_8BIT, - [EXT_CSD_BUS_WIDTH_4] = MMC_MODE_4BIT, - [EXT_CSD_BUS_WIDTH_8] = MMC_MODE_8BIT, - }; + /* An array to map CSD bus widths to host cap bits */ + static unsigned ext_to_hostcaps[] = { + [EXT_CSD_DDR_BUS_WIDTH_4] = MMC_MODE_DDR_52MHz | MMC_MODE_4BIT, + [EXT_CSD_DDR_BUS_WIDTH_8] = MMC_MODE_DDR_52MHz | MMC_MODE_8BIT, + [EXT_CSD_BUS_WIDTH_4] = MMC_MODE_4BIT, + [EXT_CSD_BUS_WIDTH_8] = MMC_MODE_8BIT, + }; - /* An array to map chosen bus width to an integer */ - static unsigned widths[] = { - 8, 4, 8, 4, 1, - }; + /* An array to map chosen bus width to an integer */ + static unsigned widths[] = { + 8, 4, 8, 4, 1, + }; - for (idx=0; idx < ARRAY_SIZE(ext_csd_bits); idx++) { - unsigned int extw = ext_csd_bits[idx]; - unsigned int caps = ext_to_hostcaps[extw]; + for (idx = 0; idx < ARRAY_SIZE(ext_csd_bits); idx++) { + unsigned int extw = ext_csd_bits[idx]; + unsigned int caps = ext_to_hostcaps[extw]; - /* - * If the bus width is still not changed, - * don't try to set the default again. - * Otherwise, recover from switch attempts - * by switching to 1-bit bus width. - */ - if (extw == EXT_CSD_BUS_WIDTH_1 && - mmc->bus_width == 1) { - err = 0; - break; - } + /* + * If the bus width is still not changed, + * don't try to set the default again. + * Otherwise, recover from switch attempts + * by switching to 1-bit bus width. + */ + if (extw == EXT_CSD_BUS_WIDTH_1 && mmc->bus_width == 1) { + err = 0; + break; + } - /* - * Check to make sure the card and controller support - * these capabilities - */ - if ((mmc->card_caps & caps) != caps) - continue; + /* + * Check to make sure the card and controller support + * these capabilities + */ + if ((mmc->card_caps & caps) != caps) + continue; - err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, - EXT_CSD_BUS_WIDTH, extw); + err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH, extw); - if (err) - continue; + if (err) + continue; - mmc->ddr_mode = (caps & MMC_MODE_DDR_52MHz) ? 1 : 0; - mmc_set_bus_width(mmc, widths[idx]); + mmc->ddr_mode = (caps & MMC_MODE_DDR_52MHz) ? 1 : 0; + mmc_set_bus_width(mmc, widths[idx]); - err = mmc_send_ext_csd(mmc, test_csd); + err = mmc_send_ext_csd(mmc, test_csd); - if (err) - continue; + if (err) + continue; - /* Only compare read only fields */ - if (ext_csd[EXT_CSD_PARTITIONING_SUPPORT] - == test_csd[EXT_CSD_PARTITIONING_SUPPORT] && - ext_csd[EXT_CSD_HC_WP_GRP_SIZE] - == test_csd[EXT_CSD_HC_WP_GRP_SIZE] && - ext_csd[EXT_CSD_REV] - == test_csd[EXT_CSD_REV] && - ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] - == test_csd[EXT_CSD_HC_ERASE_GRP_SIZE] && - memcmp(&ext_csd[EXT_CSD_SEC_CNT], - &test_csd[EXT_CSD_SEC_CNT], 4) == 0) - break; - else - err = SWITCH_ERR; - } - - if (err) - return err; - - if (mmc->card_caps & MMC_MODE_HS) { - if (mmc->card_caps & MMC_MODE_HS_52MHz) - mmc->tran_speed = 52000000; - else - mmc->tran_speed = 26000000; - } + /* Only compare read only fields */ + if (ext_csd[EXT_CSD_PARTITIONING_SUPPORT] == + test_csd[EXT_CSD_PARTITIONING_SUPPORT] && + ext_csd[EXT_CSD_HC_WP_GRP_SIZE] == test_csd[EXT_CSD_HC_WP_GRP_SIZE] && + ext_csd[EXT_CSD_REV] == test_csd[EXT_CSD_REV] && + ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] == + test_csd[EXT_CSD_HC_ERASE_GRP_SIZE] && + memcmp(&ext_csd[EXT_CSD_SEC_CNT], &test_csd[EXT_CSD_SEC_CNT], 4) == 0) + break; + else + err = SWITCH_ERR; } - mmc_set_clock(mmc, mmc->tran_speed); + if (err) + return err; - /* Fix the block length for DDR mode */ - if (mmc->ddr_mode) { - mmc->read_bl_len = MMC_MAX_BLOCK_LEN; - mmc->write_bl_len = MMC_MAX_BLOCK_LEN; + if (mmc->card_caps & MMC_MODE_HS) { + if (mmc->card_caps & MMC_MODE_HS_52MHz) + mmc->tran_speed = 52000000; + else + mmc->tran_speed = 26000000; } + } - /* fill in device description */ - mmc->block_dev.lun = 0; - mmc->block_dev.type = 0; - mmc->block_dev.blksz = mmc->read_bl_len; - //mmc->block_dev.log2blksz = LOG2(mmc->block_dev.blksz); - mmc->block_dev.lba = _sdmmc_lldiv(mmc->capacity, mmc->read_bl_len); + mmc_set_clock(mmc, mmc->tran_speed); + + /* Fix the block length for DDR mode */ + if (mmc->ddr_mode) { + mmc->read_bl_len = MMC_MAX_BLOCK_LEN; + mmc->write_bl_len = MMC_MAX_BLOCK_LEN; + } + + /* fill in device description */ + mmc->block_dev.lun = 0; + mmc->block_dev.type = 0; + mmc->block_dev.blksz = mmc->read_bl_len; + // mmc->block_dev.log2blksz = LOG2(mmc->block_dev.blksz); + mmc->block_dev.lba = _sdmmc_lldiv(mmc->capacity, mmc->read_bl_len); #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) - sprintf(mmc->block_dev.vendor, "Man %06x Snr %04x%04x", - (unsigned)(mmc->cid[0] >> 24), (unsigned)(mmc->cid[2] & 0xffff), - (unsigned)((mmc->cid[3] >> 16) & 0xffff)); - sprintf(mmc->block_dev.product, "%c%c%c%c%c%c", (char)mmc->cid[0], - (char)(mmc->cid[1] >> 24), (char)(mmc->cid[1] >> 16), - (char)(mmc->cid[1] >> 8), (char)mmc->cid[1], - (char)(mmc->cid[2] >> 24)); - sprintf(mmc->block_dev.revision, "%d.%d", (unsigned)((mmc->cid[2] >> 20) & 0xf), - (unsigned)((mmc->cid[2] >> 16) & 0xf)); + sprintf(mmc->block_dev.vendor, "Man %06x Snr %04x%04x", + (unsigned)(mmc->cid[0] >> 24), (unsigned)(mmc->cid[2] & 0xffff), + (unsigned)((mmc->cid[3] >> 16) & 0xffff)); + sprintf(mmc->block_dev.product, "%c%c%c%c%c%c", (char)mmc->cid[0], + (char)(mmc->cid[1] >> 24), (char)(mmc->cid[1] >> 16), + (char)(mmc->cid[1] >> 8), (char)mmc->cid[1], + (char)(mmc->cid[2] >> 24)); + sprintf(mmc->block_dev.revision, "%d.%d", + (unsigned)((mmc->cid[2] >> 20) & 0xf), + (unsigned)((mmc->cid[2] >> 16) & 0xf)); #else - mmc->block_dev.vendor[0] = 0; - mmc->block_dev.product[0] = 0; - mmc->block_dev.revision[0] = 0; + mmc->block_dev.vendor[0] = 0; + mmc->block_dev.product[0] = 0; + mmc->block_dev.revision[0] = 0; #endif - HAL_SDMMC_TRACE(1,"%s done\n", __func__); + HAL_SDMMC_TRACE(1, "%s done\n", __func__); + return 0; +} + +static int mmc_send_if_cond(struct mmc *mmc) { + struct mmc_cmd cmd; + int err; + + cmd.cmdidx = SD_CMD_SEND_IF_COND; + /* We set the bit if the host supports voltages between 2.7 and 3.6 V */ + cmd.cmdarg = ((mmc->cfg->voltages & 0xff8000) != 0) << 8 | 0xaa; + cmd.resp_type = MMC_RSP_R7; + + err = mmc_send_cmd(mmc, &cmd, NULL); + + if (err) + return err; + + if ((cmd.response[0] & 0xff) != 0xaa) + return UNUSABLE_ERR; + else + mmc->version = SD_VERSION_2; + + return 0; +} + +struct mmc *mmc_create(int id, const struct mmc_config *cfg, void *priv) { + struct mmc *mmc; + + /* quick validation */ + if (cfg == NULL || cfg->ops == NULL || cfg->ops->send_cmd == NULL || + cfg->f_min == 0 || cfg->f_max == 0 || cfg->b_max == 0) + return NULL; + + mmc = &sdmmc_devices[id]; + if (mmc == NULL) + return NULL; + + mmc->cfg = cfg; + mmc->priv = priv; + + /* the following chunk was mmc_register() */ + + /* Setup dsr related values */ + mmc->dsr_imp = 0; + mmc->dsr = 0xffffffff; + /* Setup the universal parts of the block interface just once */ + mmc->block_dev.removable = 1; + /* setup initial part type */ + mmc->block_dev.part_type = mmc->cfg->part_type; + + return mmc; +} + +int mmc_start_init(struct mmc *mmc) { + int err; + + /* we pretend there's no card when init is NULL */ + if (mmc_getcd(mmc) == 0 || mmc->cfg->ops->init == NULL) { + mmc->has_init = 0; + HAL_SDMMC_TRACE(1, "%s : no card present\n", __func__); + return NO_CARD_ERR; + } + + if (mmc->has_init) return 0; -} -static int mmc_send_if_cond(struct mmc *mmc) -{ - struct mmc_cmd cmd; - int err; + /* made sure it's not NULL earlier */ + err = mmc->cfg->ops->init(mmc); + HAL_SDMMC_TRACE(1, "%s : init done\n", __func__); - cmd.cmdidx = SD_CMD_SEND_IF_COND; - /* We set the bit if the host supports voltages between 2.7 and 3.6 V */ - cmd.cmdarg = ((mmc->cfg->voltages & 0xff8000) != 0) << 8 | 0xaa; - cmd.resp_type = MMC_RSP_R7; + if (err) + return err; - err = mmc_send_cmd(mmc, &cmd, NULL); + mmc->ddr_mode = 0; + mmc_set_bus_width(mmc, 1); + mmc_set_clock(mmc, 1); - if (err) - return err; + /* Reset the Card */ + err = mmc_go_idle(mmc); + HAL_SDMMC_TRACE(1, "%s : idle done\n", __func__); - if ((cmd.response[0] & 0xff) != 0xaa) - return UNUSABLE_ERR; - else - mmc->version = SD_VERSION_2; + if (err) + return err; - return 0; -} + /* The internal partition reset to user partition(0) at every CMD0*/ + mmc->part_num = 0; -struct mmc *mmc_create(int id, const struct mmc_config *cfg, void *priv) -{ - struct mmc *mmc; + /* Test for SD version 2 */ + err = mmc_send_if_cond(mmc); - /* quick validation */ - if (cfg == NULL || cfg->ops == NULL || cfg->ops->send_cmd == NULL || - cfg->f_min == 0 || cfg->f_max == 0 || cfg->b_max == 0) - return NULL; + /* Now try to get the SD card's operating condition */ + err = sd_send_op_cond(mmc); - mmc = &sdmmc_devices[id]; - if (mmc == NULL) - return NULL; + /* If the command timed out, we check for an MMC card */ + if (err == TIMEOUT) { + err = mmc_send_op_cond(mmc); - mmc->cfg = cfg; - mmc->priv = priv; - - /* the following chunk was mmc_register() */ - - /* Setup dsr related values */ - mmc->dsr_imp = 0; - mmc->dsr = 0xffffffff; - /* Setup the universal parts of the block interface just once */ - mmc->block_dev.removable = 1; - /* setup initial part type */ - mmc->block_dev.part_type = mmc->cfg->part_type; - - return mmc; -} - -int mmc_start_init(struct mmc *mmc) -{ - int err; - - /* we pretend there's no card when init is NULL */ - if (mmc_getcd(mmc) == 0 || mmc->cfg->ops->init == NULL) { - mmc->has_init = 0; - HAL_SDMMC_TRACE(1,"%s : no card present\n", __func__); - return NO_CARD_ERR; - } - - if (mmc->has_init) - return 0; - - /* made sure it's not NULL earlier */ - err = mmc->cfg->ops->init(mmc); - HAL_SDMMC_TRACE(1,"%s : init done\n", __func__); - - if (err) - return err; - - mmc->ddr_mode = 0; - mmc_set_bus_width(mmc, 1); - mmc_set_clock(mmc, 1); - - /* Reset the Card */ - err = mmc_go_idle(mmc); - HAL_SDMMC_TRACE(1,"%s : idle done\n", __func__); - - if (err) - return err; - - /* The internal partition reset to user partition(0) at every CMD0*/ - mmc->part_num = 0; - - /* Test for SD version 2 */ - err = mmc_send_if_cond(mmc); - - /* Now try to get the SD card's operating condition */ - err = sd_send_op_cond(mmc); - - /* If the command timed out, we check for an MMC card */ - if (err == TIMEOUT) { - err = mmc_send_op_cond(mmc); - - if (err) { + if (err) { #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) - HAL_SDMMC_TRACE(1,"%s : Card did not respond to voltage select!\n", __func__); + HAL_SDMMC_TRACE(1, "%s : Card did not respond to voltage select!\n", + __func__); #endif - return UNUSABLE_ERR; - } + return UNUSABLE_ERR; } + } - if (!err) - mmc->init_in_progress = 1; + if (!err) + mmc->init_in_progress = 1; - HAL_SDMMC_TRACE(1,"%s : done\n", __func__); - return err; + HAL_SDMMC_TRACE(1, "%s : done\n", __func__); + return err; } -static int mmc_complete_init(struct mmc *mmc) -{ - int err = 0; +static int mmc_complete_init(struct mmc *mmc) { + int err = 0; - mmc->init_in_progress = 0; - if (mmc->op_cond_pending) - err = mmc_complete_op_cond(mmc); + mmc->init_in_progress = 0; + if (mmc->op_cond_pending) + err = mmc_complete_op_cond(mmc); - if (!err) - err = mmc_startup(mmc); - if (err) - mmc->has_init = 0; - else - mmc->has_init = 1; - return err; + if (!err) + err = mmc_startup(mmc); + if (err) + mmc->has_init = 0; + else + mmc->has_init = 1; + return err; } -void hal_sdmmc_irq_handler(void) -{ - uint32_t cdetect,mask; - struct sdmmcip_host *host = &sdmmc_host[HAL_SDMMC_ID_0]; - mask = sdmmcip_readl(host, SDMMCIP_REG_RINTSTS); +void hal_sdmmc_irq_handler(void) { + uint32_t cdetect, mask; + struct sdmmcip_host *host = &sdmmc_host[HAL_SDMMC_ID_0]; + mask = sdmmcip_readl(host, SDMMCIP_REG_RINTSTS); - if (mask & SDMMCIP_REG_INTMSK_CD){ - sdmmcip_writel(host, SDMMCIP_REG_RINTSTS, SDMMCIP_REG_INTMSK_CD); - cdetect = sdmmcip_readl(host, SDMMCIP_REG_CDETECT); - HAL_SDMMC_TRACE(3,"%s cdetect:%d mask:%x\n", __func__, cdetect, mask); - if (sdmmc_detected_callback) - sdmmc_detected_callback(cdetect&0x01 ? 0 : 1); - } + if (mask & SDMMCIP_REG_INTMSK_CD) { + sdmmcip_writel(host, SDMMCIP_REG_RINTSTS, SDMMCIP_REG_INTMSK_CD); + cdetect = sdmmcip_readl(host, SDMMCIP_REG_CDETECT); + HAL_SDMMC_TRACE(3, "%s cdetect:%d mask:%x\n", __func__, cdetect, mask); + if (sdmmc_detected_callback) + sdmmc_detected_callback(cdetect & 0x01 ? 0 : 1); + } } -int hal_sdmmc_enable_detecter(enum HAL_SDMMC_ID_T id,void (* cb)(uint8_t)) -{ - uint32_t ctrl; - struct sdmmcip_host *host = NULL; - HAL_SDMMC_TRACE(1,"%s\n", __func__); +int hal_sdmmc_enable_detecter(enum HAL_SDMMC_ID_T id, void (*cb)(uint8_t)) { + uint32_t ctrl; + struct sdmmcip_host *host = NULL; + HAL_SDMMC_TRACE(1, "%s\n", __func__); - sdmmc_detected_callback = cb; + sdmmc_detected_callback = cb; - host = &sdmmc_host[id]; - host->ioaddr = (void *)sdmmc_ip_base[id]; + host = &sdmmc_host[id]; + host->ioaddr = (void *)sdmmc_ip_base[id]; - if (!sdmmcip_wait_reset(host, SDMMCIP_REG_RESET_ALL)) { - HAL_SDMMC_TRACE(2,"%s[%d] Fail-reset!!\n", __func__, __LINE__); - return -1; - } + if (!sdmmcip_wait_reset(host, SDMMCIP_REG_RESET_ALL)) { + HAL_SDMMC_TRACE(2, "%s[%d] Fail-reset!!\n", __func__, __LINE__); + return -1; + } - host->detect_enb = true; + host->detect_enb = true; - sdmmcip_writel(host, SDMMCIP_REG_RINTSTS, 0xFFFFFFFF); - sdmmcip_writel(host, SDMMCIP_REG_INTMASK, SDMMCIP_REG_INTMSK_CD); + sdmmcip_writel(host, SDMMCIP_REG_RINTSTS, 0xFFFFFFFF); + sdmmcip_writel(host, SDMMCIP_REG_INTMASK, SDMMCIP_REG_INTMSK_CD); - ctrl = SDMMCIP_REG_INT_EN; - sdmmcip_writel(host, SDMMCIP_REG_CTRL, ctrl); + ctrl = SDMMCIP_REG_INT_EN; + sdmmcip_writel(host, SDMMCIP_REG_CTRL, ctrl); - NVIC_SetVector(SDMMC_IRQn, (uint32_t)hal_sdmmc_irq_handler); - NVIC_SetPriority(SDMMC_IRQn, IRQ_PRIORITY_NORMAL); - NVIC_ClearPendingIRQ(SDMMC_IRQn); - NVIC_EnableIRQ(SDMMC_IRQn); - return 0; + NVIC_SetVector(SDMMC_IRQn, (uint32_t)hal_sdmmc_irq_handler); + NVIC_SetPriority(SDMMC_IRQn, IRQ_PRIORITY_NORMAL); + NVIC_ClearPendingIRQ(SDMMC_IRQn); + NVIC_EnableIRQ(SDMMC_IRQn); + return 0; } -void hal_sdmmc_disable_detecter(enum HAL_SDMMC_ID_T id) -{ - uint32_t ctrl = 0; - struct sdmmcip_host *host = NULL; - host = &sdmmc_host[id]; +void hal_sdmmc_disable_detecter(enum HAL_SDMMC_ID_T id) { + uint32_t ctrl = 0; + struct sdmmcip_host *host = NULL; + host = &sdmmc_host[id]; - NVIC_DisableIRQ(SDMMC_IRQn); - NVIC_SetVector(SDMMC_IRQn, (uint32_t)NULL); + NVIC_DisableIRQ(SDMMC_IRQn); + NVIC_SetVector(SDMMC_IRQn, (uint32_t)NULL); - sdmmcip_writel(host, SDMMCIP_REG_RINTSTS, 0xFFFFFFFF); - sdmmcip_writel(host, SDMMCIP_REG_INTMASK, ~SDMMCIP_REG_INTMSK_ALL); + sdmmcip_writel(host, SDMMCIP_REG_RINTSTS, 0xFFFFFFFF); + sdmmcip_writel(host, SDMMCIP_REG_INTMASK, ~SDMMCIP_REG_INTMSK_ALL); - ctrl = sdmmcip_readl(host, SDMMCIP_REG_CTRL); - ctrl |= (SDMMCIP_REG_DMA_EN); - sdmmcip_writel(host, SDMMCIP_REG_CTRL, ctrl); + ctrl = sdmmcip_readl(host, SDMMCIP_REG_CTRL); + ctrl |= (SDMMCIP_REG_DMA_EN); + sdmmcip_writel(host, SDMMCIP_REG_CTRL, ctrl); - host->detect_enb = false; - sdmmc_detected_callback = NULL; + host->detect_enb = false; + sdmmc_detected_callback = NULL; } -int mmc_init(struct mmc *mmc) -{ - int err = 0; - if (mmc->has_init) - return 0; +int mmc_init(struct mmc *mmc) { + int err = 0; + if (mmc->has_init) + return 0; - if (!mmc->init_in_progress) - err = mmc_start_init(mmc); + if (!mmc->init_in_progress) + err = mmc_start_init(mmc); - if (!err) - err = mmc_complete_init(mmc); + if (!err) + err = mmc_complete_init(mmc); - return err; + return err; } /* hal api */ -static void hal_sdmmc_delay(uint32_t ms) -{ - if (sdmmc_delay) { - sdmmc_delay(ms); - } else { - hal_sys_timer_delay(MS_TO_TICKS(ms)); - } +static void hal_sdmmc_delay(uint32_t ms) { + if (sdmmc_delay) { + sdmmc_delay(ms); + } else { + hal_sys_timer_delay(MS_TO_TICKS(ms)); + } } -HAL_SDMMC_DELAY_FUNC hal_sdmmc_set_delay_func(HAL_SDMMC_DELAY_FUNC new_func) -{ - HAL_SDMMC_DELAY_FUNC old_func = sdmmc_delay; - sdmmc_delay = new_func; - return old_func; +HAL_SDMMC_DELAY_FUNC hal_sdmmc_set_delay_func(HAL_SDMMC_DELAY_FUNC new_func) { + HAL_SDMMC_DELAY_FUNC old_func = sdmmc_delay; + sdmmc_delay = new_func; + return old_func; } -int32_t hal_sdmmc_open(enum HAL_SDMMC_ID_T id) -{ - int32_t ret = 0; - struct sdmmcip_host *host = NULL; - HAL_SDMMC_ASSERT(id < HAL_SDMMC_ID_NUM, invalid_id, id); +int32_t hal_sdmmc_open(enum HAL_SDMMC_ID_T id) { + int32_t ret = 0; + struct sdmmcip_host *host = NULL; + HAL_SDMMC_ASSERT(id < HAL_SDMMC_ID_NUM, invalid_id, id); #ifdef FPGA - hal_cmu_sdmmc_set_freq(HAL_CMU_PERIPH_FREQ_26M); + hal_cmu_sdmmc_set_freq(HAL_CMU_PERIPH_FREQ_26M); #else - hal_cmu_sdmmc_set_freq(HAL_CMU_PERIPH_FREQ_52M); + hal_cmu_sdmmc_set_freq(HAL_CMU_PERIPH_FREQ_52M); #endif - hal_cmu_clock_enable(HAL_CMU_MOD_O_SDMMC); - hal_cmu_clock_enable(HAL_CMU_MOD_H_SDMMC); - hal_cmu_reset_clear(HAL_CMU_MOD_O_SDMMC); - hal_cmu_reset_clear(HAL_CMU_MOD_H_SDMMC); + hal_cmu_clock_enable(HAL_CMU_MOD_O_SDMMC); + hal_cmu_clock_enable(HAL_CMU_MOD_H_SDMMC); + hal_cmu_reset_clear(HAL_CMU_MOD_O_SDMMC); + hal_cmu_reset_clear(HAL_CMU_MOD_H_SDMMC); #ifdef FPGA #ifdef CHIP_BEST1000 - /* iomux */ - *((volatile uint32_t *)0x4001f004) |= 0x1<<16; - *((volatile uint32_t *)0x4001f004) |= 0x1<<17; + /* iomux */ + *((volatile uint32_t *)0x4001f004) |= 0x1 << 16; + *((volatile uint32_t *)0x4001f004) |= 0x1 << 17; #endif #endif - host = &sdmmc_host[id]; + host = &sdmmc_host[id]; - host->ioaddr = (void *)sdmmc_ip_base[id]; - //host->buswidth = 4; - host->buswidth = 1; - host->clksel = 0; - host->bus_hz = _SDMMC_CLOCK; - host->dev_index = id; - /* fifo threshold : MSIZE 0 - 1 transter, rx water mark 0 - greater than 0 word triiger dma-req, - * tx water mark 1 - less than or equal 1 word triiger dma-req */ - host->fifoth_val = MSIZE(0) | RX_WMARK(0) | TX_WMARK(1); + host->ioaddr = (void *)sdmmc_ip_base[id]; + // host->buswidth = 4; + host->buswidth = 1; + host->clksel = 0; + host->bus_hz = _SDMMC_CLOCK; + host->dev_index = id; + /* fifo threshold : MSIZE 0 - 1 transter, rx water mark 0 - greater than 0 + * word triiger dma-req, tx water mark 1 - less than or equal 1 word triiger + * dma-req */ + host->fifoth_val = MSIZE(0) | RX_WMARK(0) | TX_WMARK(1); - host->cfg.ops = &sdmmcip_ops; - host->cfg.f_min = 400000; - //host->cfg.f_min = 1000000; - //host->cfg.f_min = 25000000; - //host->cfg.f_min = 52000000; - //host->cfg.f_max = 1000000; - host->cfg.f_max = 26000000; - //host->cfg.f_max = 52000000; - host->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195; - host->cfg.host_caps = 0; + host->cfg.ops = &sdmmcip_ops; + host->cfg.f_min = 400000; + // host->cfg.f_min = 1000000; + // host->cfg.f_min = 25000000; + // host->cfg.f_min = 52000000; + // host->cfg.f_max = 1000000; + host->cfg.f_max = 26000000; + // host->cfg.f_max = 52000000; + host->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195; + host->cfg.host_caps = 0; #ifdef HAL_SDMMC_USE_DMA - host->tx_dma_handler = sdmmcip_ext_dma_irq_handlers[id*2]; - host->rx_dma_handler = sdmmcip_ext_dma_irq_handlers[id*2+1]; + host->tx_dma_handler = sdmmcip_ext_dma_irq_handlers[id * 2]; + host->rx_dma_handler = sdmmcip_ext_dma_irq_handlers[id * 2 + 1]; #endif - if (host->buswidth == 8) { - host->cfg.host_caps |= MMC_MODE_8BIT; - host->cfg.host_caps &= ~MMC_MODE_4BIT; - } else if (host->buswidth == 4) { - host->cfg.host_caps |= MMC_MODE_4BIT; - host->cfg.host_caps &= ~MMC_MODE_8BIT; - } - else { - //host->cfg.host_caps &= ~MMC_MODE_4BIT; - host->cfg.host_caps |= MMC_MODE_4BIT; - host->cfg.host_caps &= ~MMC_MODE_8BIT; - } + if (host->buswidth == 8) { + host->cfg.host_caps |= MMC_MODE_8BIT; + host->cfg.host_caps &= ~MMC_MODE_4BIT; + } else if (host->buswidth == 4) { + host->cfg.host_caps |= MMC_MODE_4BIT; + host->cfg.host_caps &= ~MMC_MODE_8BIT; + } else { + // host->cfg.host_caps &= ~MMC_MODE_4BIT; + host->cfg.host_caps |= MMC_MODE_4BIT; + host->cfg.host_caps &= ~MMC_MODE_8BIT; + } - host->cfg.host_caps |= MMC_MODE_HS | MMC_MODE_HS_52MHz; + host->cfg.host_caps |= MMC_MODE_HS | MMC_MODE_HS_52MHz; - host->cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT; + host->cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT; - host->mmc = mmc_create(host->dev_index, &host->cfg, host); + host->mmc = mmc_create(host->dev_index, &host->cfg, host); - ret = mmc_init(host->mmc); + ret = mmc_init(host->mmc); - hal_sdmmc_dump(HAL_SDMMC_ID_0); + hal_sdmmc_dump(HAL_SDMMC_ID_0); - return ret; + return ret; } -uint32_t hal_sdmmc_read_blocks(enum HAL_SDMMC_ID_T id, uint32_t start_block, uint32_t block_count, uint8_t* dest) -{ - HAL_SDMMC_ASSERT(id < HAL_SDMMC_ID_NUM, invalid_id, id); +uint32_t hal_sdmmc_read_blocks(enum HAL_SDMMC_ID_T id, uint32_t start_block, + uint32_t block_count, uint8_t *dest) { + HAL_SDMMC_ASSERT(id < HAL_SDMMC_ID_NUM, invalid_id, id); - return mmc_bread(id, start_block, block_count, dest); + return mmc_bread(id, start_block, block_count, dest); } -uint32_t hal_sdmmc_write_blocks(enum HAL_SDMMC_ID_T id, uint32_t start_block, uint32_t block_count, uint8_t* src) -{ - HAL_SDMMC_ASSERT(id < HAL_SDMMC_ID_NUM, invalid_id, id); +uint32_t hal_sdmmc_write_blocks(enum HAL_SDMMC_ID_T id, uint32_t start_block, + uint32_t block_count, uint8_t *src) { + HAL_SDMMC_ASSERT(id < HAL_SDMMC_ID_NUM, invalid_id, id); - return mmc_bwrite(id, start_block, block_count, src); + return mmc_bwrite(id, start_block, block_count, src); } -void hal_sdmmc_close(enum HAL_SDMMC_ID_T id) -{ - struct sdmmcip_host *host = NULL; +void hal_sdmmc_close(enum HAL_SDMMC_ID_T id) { + struct sdmmcip_host *host = NULL; - HAL_SDMMC_ASSERT(id < HAL_SDMMC_ID_NUM, invalid_id, id); + HAL_SDMMC_ASSERT(id < HAL_SDMMC_ID_NUM, invalid_id, id); - HAL_SDMMC_TRACE(1,"%s\n", __func__); + HAL_SDMMC_TRACE(1, "%s\n", __func__); - host = &sdmmc_host[id]; - while(host->mmc->init_in_progress) - hal_sdmmc_delay(1); + host = &sdmmc_host[id]; + while (host->mmc->init_in_progress) + hal_sdmmc_delay(1); - host->mmc->has_init = 0; + host->mmc->has_init = 0; - hal_cmu_reset_set(HAL_CMU_MOD_H_SDMMC); - hal_cmu_reset_set(HAL_CMU_MOD_O_SDMMC); - hal_cmu_clock_disable(HAL_CMU_MOD_H_SDMMC); - hal_cmu_clock_disable(HAL_CMU_MOD_O_SDMMC); + hal_cmu_reset_set(HAL_CMU_MOD_H_SDMMC); + hal_cmu_reset_set(HAL_CMU_MOD_O_SDMMC); + hal_cmu_clock_disable(HAL_CMU_MOD_H_SDMMC); + hal_cmu_clock_disable(HAL_CMU_MOD_O_SDMMC); } -void hal_sdmmc_dump(enum HAL_SDMMC_ID_T id) -{ - struct mmc *mmc = NULL; - struct sdmmcip_host *host = NULL; - HAL_SDMMC_ASSERT(id < HAL_SDMMC_ID_NUM, invalid_id, id); +void hal_sdmmc_dump(enum HAL_SDMMC_ID_T id) { + struct mmc *mmc = NULL; + struct sdmmcip_host *host = NULL; + HAL_SDMMC_ASSERT(id < HAL_SDMMC_ID_NUM, invalid_id, id); - host = &sdmmc_host[id]; - mmc = host->mmc; + host = &sdmmc_host[id]; + mmc = host->mmc; - HAL_SDMMC_TRACE(0,"-----------hal_sdmmc_dump-------------\n"); - HAL_SDMMC_TRACE(1," [sdmmc id] : %d\n", id); - HAL_SDMMC_TRACE(1," [io register address] : 0x%x\n", sdmmc_ip_base[id]); - HAL_SDMMC_TRACE(1," [ddr mode] : %d\n", mmc->ddr_mode); - switch(mmc->version) - { - case SD_VERSION_1_0: HAL_SDMMC_TRACE(0," [version] : SD_VERSION_1_0\n"); break; - case SD_VERSION_1_10: HAL_SDMMC_TRACE(0," [version] : SD_VERSION_1_10\n"); break; - case SD_VERSION_2: HAL_SDMMC_TRACE(0," [version] : SD_VERSION_2\n"); break; - case SD_VERSION_3: HAL_SDMMC_TRACE(0," [version] : SD_VERSION_3\n"); break; - case MMC_VERSION_5_0: HAL_SDMMC_TRACE(0," [version] : MMC_VERSION_5_0\n"); break; - case MMC_VERSION_4_5: HAL_SDMMC_TRACE(0," [version] : MMC_VERSION_4_5\n"); break; - case MMC_VERSION_4_41:HAL_SDMMC_TRACE(0," [version] : MMC_VERSION_4_41\n");break; - case MMC_VERSION_4_3: HAL_SDMMC_TRACE(0," [version] : MMC_VERSION_4_3\n"); break; - case MMC_VERSION_4_2: HAL_SDMMC_TRACE(0," [version] : MMC_VERSION_4_2\n"); break; - case MMC_VERSION_4_1: HAL_SDMMC_TRACE(0," [version] : MMC_VERSION_4_1\n"); break; - case MMC_VERSION_4: HAL_SDMMC_TRACE(0," [version] : MMC_VERSION_4\n"); break; - case MMC_VERSION_3: HAL_SDMMC_TRACE(0," [version] : MMC_VERSION_3\n"); break; - case MMC_VERSION_2_2: HAL_SDMMC_TRACE(0," [version] : MMC_VERSION_2_2\n"); break; - case MMC_VERSION_1_4: HAL_SDMMC_TRACE(0," [version] : MMC_VERSION_1_4\n"); break; - case MMC_VERSION_1_2: HAL_SDMMC_TRACE(0," [version] : MMC_VERSION_1_2\n"); break; - default: HAL_SDMMC_TRACE(0," [version] : unkown version\n"); break; - } - HAL_SDMMC_TRACE(1," [is SD card] : 0x%x\n", IS_SD(mmc)); - HAL_SDMMC_TRACE(1," [high_capacity] : 0x%x\n", mmc->high_capacity); - HAL_SDMMC_TRACE(1," [bus_width] : 0x%x\n", mmc->bus_width); - HAL_SDMMC_TRACE(1," [clock] : %d\n", mmc->clock); - HAL_SDMMC_TRACE(1," [card_caps] : 0x%x\n", mmc->card_caps); - HAL_SDMMC_TRACE(1," [ocr] : 0x%x\n", mmc->ocr); - HAL_SDMMC_TRACE(1," [dsr] : 0x%x\n", mmc->dsr); - HAL_SDMMC_TRACE(1," [capacity_user/1024] : %d(K)\n", (uint32_t)(mmc->capacity_user/1024)); - HAL_SDMMC_TRACE(1," [capacity_user/1024/1024] : %d(M)\n", (uint32_t)(mmc->capacity_user/1024/1024)); - HAL_SDMMC_TRACE(1," [capacity_user/1024/1024/1024] : %d(G)\n", (uint32_t)(mmc->capacity_user/1024/1024/1024)); - HAL_SDMMC_TRACE(1," [read_bl_len] : %d\n", mmc->read_bl_len); - HAL_SDMMC_TRACE(1," [write_bl_len] : %d\n", mmc->write_bl_len); - HAL_SDMMC_TRACE(0,"--------------------------------------\n"); + HAL_SDMMC_TRACE(0, "-----------hal_sdmmc_dump-------------\n"); + HAL_SDMMC_TRACE(1, " [sdmmc id] : %d\n", id); + HAL_SDMMC_TRACE(1, " [io register address] : 0x%x\n", + sdmmc_ip_base[id]); + HAL_SDMMC_TRACE(1, " [ddr mode] : %d\n", + mmc->ddr_mode); + switch (mmc->version) { + case SD_VERSION_1_0: + HAL_SDMMC_TRACE(0, + " [version] : SD_VERSION_1_0\n"); + break; + case SD_VERSION_1_10: + HAL_SDMMC_TRACE(0, + " [version] : SD_VERSION_1_10\n"); + break; + case SD_VERSION_2: + HAL_SDMMC_TRACE(0, " [version] : SD_VERSION_2\n"); + break; + case SD_VERSION_3: + HAL_SDMMC_TRACE(0, " [version] : SD_VERSION_3\n"); + break; + case MMC_VERSION_5_0: + HAL_SDMMC_TRACE(0, + " [version] : MMC_VERSION_5_0\n"); + break; + case MMC_VERSION_4_5: + HAL_SDMMC_TRACE(0, + " [version] : MMC_VERSION_4_5\n"); + break; + case MMC_VERSION_4_41: + HAL_SDMMC_TRACE( + 0, " [version] : MMC_VERSION_4_41\n"); + break; + case MMC_VERSION_4_3: + HAL_SDMMC_TRACE(0, + " [version] : MMC_VERSION_4_3\n"); + break; + case MMC_VERSION_4_2: + HAL_SDMMC_TRACE(0, + " [version] : MMC_VERSION_4_2\n"); + break; + case MMC_VERSION_4_1: + HAL_SDMMC_TRACE(0, + " [version] : MMC_VERSION_4_1\n"); + break; + case MMC_VERSION_4: + HAL_SDMMC_TRACE(0, + " [version] : MMC_VERSION_4\n"); + break; + case MMC_VERSION_3: + HAL_SDMMC_TRACE(0, + " [version] : MMC_VERSION_3\n"); + break; + case MMC_VERSION_2_2: + HAL_SDMMC_TRACE(0, + " [version] : MMC_VERSION_2_2\n"); + break; + case MMC_VERSION_1_4: + HAL_SDMMC_TRACE(0, + " [version] : MMC_VERSION_1_4\n"); + break; + case MMC_VERSION_1_2: + HAL_SDMMC_TRACE(0, + " [version] : MMC_VERSION_1_2\n"); + break; + default: + HAL_SDMMC_TRACE(0, + " [version] : unkown version\n"); + break; + } + HAL_SDMMC_TRACE(1, " [is SD card] : 0x%x\n", + IS_SD(mmc)); + HAL_SDMMC_TRACE(1, " [high_capacity] : 0x%x\n", + mmc->high_capacity); + HAL_SDMMC_TRACE(1, " [bus_width] : 0x%x\n", + mmc->bus_width); + HAL_SDMMC_TRACE(1, " [clock] : %d\n", mmc->clock); + HAL_SDMMC_TRACE(1, " [card_caps] : 0x%x\n", + mmc->card_caps); + HAL_SDMMC_TRACE(1, " [ocr] : 0x%x\n", mmc->ocr); + HAL_SDMMC_TRACE(1, " [dsr] : 0x%x\n", mmc->dsr); + HAL_SDMMC_TRACE(1, " [capacity_user/1024] : %d(K)\n", + (uint32_t)(mmc->capacity_user / 1024)); + HAL_SDMMC_TRACE(1, " [capacity_user/1024/1024] : %d(M)\n", + (uint32_t)(mmc->capacity_user / 1024 / 1024)); + HAL_SDMMC_TRACE(1, " [capacity_user/1024/1024/1024] : %d(G)\n", + (uint32_t)(mmc->capacity_user / 1024 / 1024 / 1024)); + HAL_SDMMC_TRACE(1, " [read_bl_len] : %d\n", + mmc->read_bl_len); + HAL_SDMMC_TRACE(1, " [write_bl_len] : %d\n", + mmc->write_bl_len); + HAL_SDMMC_TRACE(0, "--------------------------------------\n"); } -void hal_sdmmc_info(enum HAL_SDMMC_ID_T id, uint32_t *sector_count, uint32_t *sector_size) -{ - struct mmc *mmc = NULL; - struct sdmmcip_host *host = NULL; - HAL_SDMMC_ASSERT(id < HAL_SDMMC_ID_NUM, invalid_id, id); +void hal_sdmmc_info(enum HAL_SDMMC_ID_T id, uint32_t *sector_count, + uint32_t *sector_size) { + struct mmc *mmc = NULL; + struct sdmmcip_host *host = NULL; + HAL_SDMMC_ASSERT(id < HAL_SDMMC_ID_NUM, invalid_id, id); - host = &sdmmc_host[id]; - mmc = host->mmc; + host = &sdmmc_host[id]; + mmc = host->mmc; - if (sector_size) { - *sector_size = mmc->read_bl_len; - HAL_SDMMC_TRACE(1,"[sdmmc] sector_size %d\n", *sector_size); - } - if (sector_count) { - if (mmc->read_bl_len != 0) - *sector_count = mmc->capacity_user/mmc->read_bl_len; - else - *sector_count = 0; - HAL_SDMMC_TRACE(1,"[sdmmc] sector_count %d\n", *sector_count); - } + if (sector_size) { + *sector_size = mmc->read_bl_len; + HAL_SDMMC_TRACE(1, "[sdmmc] sector_size %d\n", *sector_size); + } + if (sector_count) { + if (mmc->read_bl_len != 0) + *sector_count = mmc->capacity_user / mmc->read_bl_len; + else + *sector_count = 0; + HAL_SDMMC_TRACE(1, "[sdmmc] sector_count %d\n", *sector_count); + } } #endif // CHIP_HAS_SDMMC diff --git a/platform/hal/hal_sec_eng.c b/platform/hal/hal_sec_eng.c index 33c2156..b89a12a 100644 --- a/platform/hal/hal_sec_eng.c +++ b/platform/hal/hal_sec_eng.c @@ -17,104 +17,107 @@ #ifdef SEC_ENG_BASE -#include "hal_sec_eng.h" -#include "reg_sec_eng.h" -#include "reg_dma.h" #include "cmsis_nvic.h" #include "hal_cmu.h" #include "hal_dma.h" +#include "hal_sec_eng.h" #include "hal_timer.h" #include "hal_trace.h" +#include "reg_dma.h" +#include "reg_sec_eng.h" -#define SE_DMA_CHAN_NUM 2 -#define SE_DMA_DESC_NUM 4 +#define SE_DMA_CHAN_NUM 2 +#define SE_DMA_DESC_NUM 4 -#define SE_DMA_MAX_DESC_XFER_SIZE (HAL_DMA_MAX_DESC_XFER_SIZE & ~(4 - 1)) +#define SE_DMA_MAX_DESC_XFER_SIZE (HAL_DMA_MAX_DESC_XFER_SIZE & ~(4 - 1)) -#define SE_DMA_RX_CHAN 0 -#define SE_DMA_TX_CHAN 1 +#define SE_DMA_RX_CHAN 0 +#define SE_DMA_TX_CHAN 1 // Trigger DMA request when RX-FIFO count >= threshold -#define SE_DMA_RX_FIFO_TRIG_LEVEL 8 +#define SE_DMA_RX_FIFO_TRIG_LEVEL 8 // Trigger DMA request when TX-FIFO count <= threshold -#define SE_DMA_TX_FIFO_TRIG_LEVEL 8 +#define SE_DMA_TX_FIFO_TRIG_LEVEL 8 enum SE_ACC_CLK_T { - SE_ACC_CLK_DMA = (1 << 1), - SE_ACC_CLK_ACC_BUS = (1 << 2), - SE_ACC_CLK_CRYPT = (1 << 3), - SE_ACC_CLK_ECP = (1 << 4), - SE_ACC_CLK_HASH = (1 << 5), - SE_ACC_CLK_SCRATCH = (1 << 6), - SE_ACC_CLK_ZMODP = (1 << 7), - SE_ACC_CLK_MCT = (1 << 8), - SE_ACC_CLK_OTP = (1 << 9), - SE_ACC_CLK_EBG = (1 << 10), + SE_ACC_CLK_DMA = (1 << 1), + SE_ACC_CLK_ACC_BUS = (1 << 2), + SE_ACC_CLK_CRYPT = (1 << 3), + SE_ACC_CLK_ECP = (1 << 4), + SE_ACC_CLK_HASH = (1 << 5), + SE_ACC_CLK_SCRATCH = (1 << 6), + SE_ACC_CLK_ZMODP = (1 << 7), + SE_ACC_CLK_MCT = (1 << 8), + SE_ACC_CLK_OTP = (1 << 9), + SE_ACC_CLK_EBG = (1 << 10), }; enum SE_ACC_RST_T { - SE_ACC_RST_DMA = (1 << 1), - SE_ACC_RST_ACC_BUS = (1 << 2), - SE_ACC_RST_CRYPT = (1 << 3), - SE_ACC_RST_ECP = (1 << 4), - SE_ACC_RST_HASH = (1 << 5), - SE_ACC_RST_SCRATCH = (1 << 6), - SE_ACC_RST_ZMODP = (1 << 7), - SE_ACC_RST_MCT = (1 << 8), - SE_ACC_RST_OTP = (1 << 9), - SE_ACC_RST_EBG = (1 << 10), + SE_ACC_RST_DMA = (1 << 1), + SE_ACC_RST_ACC_BUS = (1 << 2), + SE_ACC_RST_CRYPT = (1 << 3), + SE_ACC_RST_ECP = (1 << 4), + SE_ACC_RST_HASH = (1 << 5), + SE_ACC_RST_SCRATCH = (1 << 6), + SE_ACC_RST_ZMODP = (1 << 7), + SE_ACC_RST_MCT = (1 << 8), + SE_ACC_RST_OTP = (1 << 9), + SE_ACC_RST_EBG = (1 << 10), }; enum SE_ACC_INT_T { - SE_ACC_INT_AES = (1 << 1), - SE_ACC_INT_DES = (1 << 2), - SE_ACC_INT_RC4 = (1 << 3), - SE_ACC_INT_OTP = (1 << 4), - SE_ACC_INT_ECP = (1 << 6), - SE_ACC_INT_MCT = (1 << 7), - SE_ACC_INT_HASH = (1 << 8), - SE_ACC_INT_ZMODP = (1 << 9), - SE_ACC_INT_SCRATCH = (1 << 10), + SE_ACC_INT_AES = (1 << 1), + SE_ACC_INT_DES = (1 << 2), + SE_ACC_INT_RC4 = (1 << 3), + SE_ACC_INT_OTP = (1 << 4), + SE_ACC_INT_ECP = (1 << 6), + SE_ACC_INT_MCT = (1 << 7), + SE_ACC_INT_HASH = (1 << 8), + SE_ACC_INT_ZMODP = (1 << 9), + SE_ACC_INT_SCRATCH = (1 << 10), }; enum SE_DMA_PERIPH_T { - SE_DMA_PERIPH_TX = 0, - SE_DMA_PERIPH_RX, + SE_DMA_PERIPH_TX = 0, + SE_DMA_PERIPH_RX, - SE_DMA_PERIPH_QTY, + SE_DMA_PERIPH_QTY, }; enum SE_CRYPT_TYPE_T { - SE_CRYPT_NONE = 0, - SE_CRYPT_AES, - SE_CRYPT_DES, - SE_CRYPT_RC4, + SE_CRYPT_NONE = 0, + SE_CRYPT_AES, + SE_CRYPT_DES, + SE_CRYPT_RC4, - SE_CRYPT_QTY, + SE_CRYPT_QTY, }; enum SE_AES_KEY_LEN_T { - SE_AES_KEY_128 = 0, - SE_AES_KEY_192, - SE_AES_KEY_256, + SE_AES_KEY_128 = 0, + SE_AES_KEY_192, + SE_AES_KEY_256, - SE_AES_KEY_LEN_QTY, + SE_AES_KEY_LEN_QTY, }; enum SE_HASH_OP_T { - SE_HASH_OP_INIT = 1, - SE_HASH_OP_UPDATE, - SE_HASH_OP_FINAL, + SE_HASH_OP_INIT = 1, + SE_HASH_OP_UPDATE, + SE_HASH_OP_FINAL, }; -static struct DMA_T * const se_dma = (struct DMA_T *)SEDMA_BASE; +static struct DMA_T *const se_dma = (struct DMA_T *)SEDMA_BASE; -static struct SE_ADEC_T * const se_adec = (struct SE_ADEC_T *)SE_ADEC_BASE; -static struct SE_ACB_T * const se_acb = (struct SE_ACB_T *)SE_ACB_BASE; -static struct SE_DMACFG_T * const se_dmacfg = (struct SE_DMACFG_T *)SE_DMACFG_BASE; -static struct SE_CRYPT_T * const se_crypt = (struct SE_CRYPT_T *)SE_CRYPT_BASE; -POSSIBLY_UNUSED static struct SE_HASH_T * const se_hash = (struct SE_HASH_T *)SE_HASH_BASE; -POSSIBLY_UNUSED static struct SE_OTP_T * const se_otp = (struct SE_OTP_T *)SE_OTP_BASE; +static struct SE_ADEC_T *const se_adec = (struct SE_ADEC_T *)SE_ADEC_BASE; +static struct SE_ACB_T *const se_acb = (struct SE_ACB_T *)SE_ACB_BASE; +static struct SE_DMACFG_T *const se_dmacfg = + (struct SE_DMACFG_T *)SE_DMACFG_BASE; +static struct SE_CRYPT_T *const se_crypt = (struct SE_CRYPT_T *)SE_CRYPT_BASE; +POSSIBLY_UNUSED static struct SE_HASH_T *const se_hash = + (struct SE_HASH_T *)SE_HASH_BASE; +POSSIBLY_UNUSED static struct SE_OTP_T *const se_otp = + (struct SE_OTP_T *)SE_OTP_BASE; static bool se_enabled; @@ -130,908 +133,920 @@ static uint32_t cur_out_len; static struct HAL_DMA_DESC_T dma_desc[SE_DMA_CHAN_NUM][SE_DMA_DESC_NUM]; -static uint32_t se_dma_init_rx_desc(uint32_t out, uint32_t out_len, uint32_t src, uint32_t ctrl); -static uint32_t se_dma_init_tx_desc(uint32_t in, uint32_t in_len, uint32_t dst, uint32_t ctrl); +static uint32_t se_dma_init_rx_desc(uint32_t out, uint32_t out_len, + uint32_t src, uint32_t ctrl); +static uint32_t se_dma_init_tx_desc(uint32_t in, uint32_t in_len, uint32_t dst, + uint32_t ctrl); #ifdef SEC_ENG_HAS_HASH static uint32_t se_hash_get_digest_len(void); static void read_mreg(const volatile uint32_t *reg, void *mem, uint32_t len); #endif -static void sec_eng_irq_handler(void) -{ - enum HAL_SE_DONE_ERR_T err; - uint32_t all_int; - uint32_t aes_int = 0; - uint32_t hash_int = 0; +static void sec_eng_irq_handler(void) { + enum HAL_SE_DONE_ERR_T err; + uint32_t all_int; + uint32_t aes_int = 0; + uint32_t hash_int = 0; - all_int = se_adec->ADEC_INT; + all_int = se_adec->ADEC_INT; - if (all_int & SE_ACC_INT_AES) { - aes_int = se_crypt->AES_INTRPT; + if (all_int & SE_ACC_INT_AES) { + aes_int = se_crypt->AES_INTRPT; - // Clear IRQs - se_crypt->AES_INTRPT = aes_int; - se_adec->ADEC_INT = SE_ACC_INT_AES; + // Clear IRQs + se_crypt->AES_INTRPT = aes_int; + se_adec->ADEC_INT = SE_ACC_INT_AES; - if (aes_int & (AES_INTRPT_ERROR1 | AES_INTRPT_ERROR2)) { - if (se_done_hdlr) { - if ((aes_int & (AES_INTRPT_ERROR1 | AES_INTRPT_ERROR2)) == (AES_INTRPT_ERROR1 | AES_INTRPT_ERROR2)) { - err = HAL_SE_DONE_ERR_ENG_ERR1_ERR2; - } else if (aes_int & AES_INTRPT_ERROR1) { - err = HAL_SE_DONE_ERR_ENG_ERR1; - } else { - err = HAL_SE_DONE_ERR_ENG_ERR2; - } - se_done_hdlr((void *)out_addr, 0, err); - } + if (aes_int & (AES_INTRPT_ERROR1 | AES_INTRPT_ERROR2)) { + if (se_done_hdlr) { + if ((aes_int & (AES_INTRPT_ERROR1 | AES_INTRPT_ERROR2)) == + (AES_INTRPT_ERROR1 | AES_INTRPT_ERROR2)) { + err = HAL_SE_DONE_ERR_ENG_ERR1_ERR2; + } else if (aes_int & AES_INTRPT_ERROR1) { + err = HAL_SE_DONE_ERR_ENG_ERR1; + } else { + err = HAL_SE_DONE_ERR_ENG_ERR2; } + se_done_hdlr((void *)out_addr, 0, err); + } } + } #ifdef SEC_ENG_HAS_HASH - if (all_int & SE_ACC_INT_HASH) { - hash_int = se_hash->HASH_STATUS; + if (all_int & SE_ACC_INT_HASH) { + hash_int = se_hash->HASH_STATUS; - // Clear IRQs - se_hash->HASH_STATUS = hash_int; - se_adec->ADEC_INT = SE_ACC_INT_HASH; + // Clear IRQs + se_hash->HASH_STATUS = hash_int; + se_adec->ADEC_INT = SE_ACC_INT_HASH; - if (hash_int & HASH_STATUS_HASH_DONE) { - if (se_done_hdlr) { - enum HAL_SE_RET_T ret; - uint32_t digest[16]; - uint32_t len; + if (hash_int & HASH_STATUS_HASH_DONE) { + if (se_done_hdlr) { + enum HAL_SE_RET_T ret; + uint32_t digest[16]; + uint32_t len; - ret = hal_se_hash_get_digest(&digest[0], sizeof(digest), &len); - if (ret == HAL_SE_OK) { - se_done_hdlr(&digest[0], len, HAL_SE_DONE_OK); - } else { - se_done_hdlr(NULL, 0, HAL_SE_DONE_OK); - } - } + ret = hal_se_hash_get_digest(&digest[0], sizeof(digest), &len); + if (ret == HAL_SE_OK) { + se_done_hdlr(&digest[0], len, HAL_SE_DONE_OK); + } else { + se_done_hdlr(NULL, 0, HAL_SE_DONE_OK); } + } } + } #endif - LOG_INFO(0, "%s: all_int=0x%08X aes_int=0x%08X hash_int=%d", __func__, all_int, aes_int, hash_int); + LOG_INFO(0, "%s: all_int=0x%08X aes_int=0x%08X hash_int=%d", __func__, + all_int, aes_int, hash_int); } -static void sedma_irq_handler(void) -{ - uint8_t hwch; - uint32_t remains; - uint32_t len; - uint32_t ctrl; - bool tcint, errint; +static void sedma_irq_handler(void) { + uint8_t hwch; + uint32_t remains; + uint32_t len; + uint32_t ctrl; + bool tcint, errint; - for (hwch = 0; hwch < SE_DMA_CHAN_NUM; hwch++) { - if ((se_dma->INTSTAT & DMA_STAT_CHAN(hwch)) == 0) { - continue; - } - - /* Check counter terminal status */ - tcint = !!(se_dma->INTTCSTAT & DMA_STAT_CHAN(hwch)); - /* Check error terminal status */ - errint = !!(se_dma->INTERRSTAT & DMA_STAT_CHAN(hwch)); - - if (tcint || errint) { - if (tcint) { - /* Clear terminate counter Interrupt pending */ - se_dma->INTTCCLR = DMA_STAT_CHAN(hwch); - } - if (errint) { - /* Clear error counter Interrupt pending */ - se_dma->INTERRCLR = DMA_STAT_CHAN(hwch); - } - - remains = GET_BITFIELD(se_dma->CH[hwch].CONTROL, DMA_CONTROL_TRANSFERSIZE); - if (errint) { - se_dma->CH[hwch].CONFIG &= ~DMA_CONFIG_EN; - if (se_done_hdlr) { - se_done_hdlr((uint8_t *)out_addr, 0, - (hwch == SE_DMA_RX_CHAN) ? HAL_SE_DONE_ERR_DMA_OUT : HAL_SE_DONE_ERR_DMA_IN); - } - } else { - if (hwch == SE_DMA_RX_CHAN) { - if (cur_out_len < total_out_len) { - len = total_out_len - cur_out_len; - ctrl = se_dma->CH[hwch].CONTROL & ~DMA_CONTROL_TC_IRQ; - cur_out_len += se_dma_init_rx_desc(out_addr + cur_out_len, len, se_dma->CH[hwch].SRCADDR, ctrl); - se_dma->CH[SE_DMA_RX_CHAN].CONFIG |= DMA_CONFIG_EN; - } else { - if (se_done_hdlr) { - if (remains) { - se_done_hdlr((void *)out_addr, cur_out_len - remains, HAL_SE_DONE_ERR_DMA_IN_REMAIN); - } else { - se_done_hdlr((void *)out_addr, cur_out_len, HAL_SE_DONE_OK); - } - } - } - } else { - if (cur_in_len < total_in_len) { - len = total_in_len - cur_in_len; - ctrl = se_dma->CH[hwch].CONTROL & ~DMA_CONTROL_TC_IRQ; - cur_in_len += se_dma_init_tx_desc(in_addr + cur_in_len, len, se_dma->CH[hwch].DSTADDR, ctrl); - se_dma->CH[SE_DMA_TX_CHAN].CONFIG |= DMA_CONFIG_EN; - } else { - if (remains) { - if (se_done_hdlr) { - se_done_hdlr((void *)out_addr, 0, HAL_SE_DONE_ERR_DMA_IN_REMAIN); - } - } - } - } - } - LOG_INFO(0, "%s: ch=%d tcint=%d errint=%d remains=%u", __func__, hwch, tcint, errint, remains); - } - } -} - -static void se_dma_open(void) -{ - uint8_t i; - - se_adec->ADEC_CTRL |= ADEC_CTRL_CLK_EN_15_0(SE_ACC_CLK_DMA) | ADEC_CTRL_RST_15_0(SE_ACC_RST_DMA); - se_adec->ADEC_CTRL &= ~ADEC_CTRL_RST_15_0(SE_ACC_RST_DMA); - se_adec->ADEC_INT_MSK = ~0UL; - - se_dmacfg->DMA_CTRL = DMA_CTRL_RX_DMA_EN | DMA_CTRL_TX_DMA_EN; - se_dmacfg->DMA_RDL = SE_DMA_RX_FIFO_TRIG_LEVEL; - se_dmacfg->DMA_TDL = SE_DMA_TX_FIFO_TRIG_LEVEL; - - /* Reset all channel configuration register */ - for (i = 0; i < SE_DMA_CHAN_NUM; i++) { - se_dma->CH[i].CONFIG = 0; + for (hwch = 0; hwch < SE_DMA_CHAN_NUM; hwch++) { + if ((se_dma->INTSTAT & DMA_STAT_CHAN(hwch)) == 0) { + continue; } - /* Clear all DMA interrupt and error flag */ - se_dma->INTTCCLR = ~0UL; - se_dma->INTERRCLR = ~0UL; + /* Check counter terminal status */ + tcint = !!(se_dma->INTTCSTAT & DMA_STAT_CHAN(hwch)); + /* Check error terminal status */ + errint = !!(se_dma->INTERRSTAT & DMA_STAT_CHAN(hwch)); - se_dma->DMACONFIG = (se_dma->DMACONFIG & ~(DMA_DMACONFIG_AHB1_BIGENDIAN | - DMA_DMACONFIG_AHB2_BIGENDIAN)) | DMA_DMACONFIG_EN; + if (tcint || errint) { + if (tcint) { + /* Clear terminate counter Interrupt pending */ + se_dma->INTTCCLR = DMA_STAT_CHAN(hwch); + } + if (errint) { + /* Clear error counter Interrupt pending */ + se_dma->INTERRCLR = DMA_STAT_CHAN(hwch); + } - NVIC_SetVector(SEDMA_IRQn, (uint32_t)sedma_irq_handler); - NVIC_SetPriority(SEDMA_IRQn, IRQ_PRIORITY_NORMAL); - NVIC_ClearPendingIRQ(SEDMA_IRQn); - NVIC_EnableIRQ(SEDMA_IRQn); + remains = + GET_BITFIELD(se_dma->CH[hwch].CONTROL, DMA_CONTROL_TRANSFERSIZE); + if (errint) { + se_dma->CH[hwch].CONFIG &= ~DMA_CONFIG_EN; + if (se_done_hdlr) { + se_done_hdlr((uint8_t *)out_addr, 0, + (hwch == SE_DMA_RX_CHAN) ? HAL_SE_DONE_ERR_DMA_OUT + : HAL_SE_DONE_ERR_DMA_IN); + } + } else { + if (hwch == SE_DMA_RX_CHAN) { + if (cur_out_len < total_out_len) { + len = total_out_len - cur_out_len; + ctrl = se_dma->CH[hwch].CONTROL & ~DMA_CONTROL_TC_IRQ; + cur_out_len += se_dma_init_rx_desc(out_addr + cur_out_len, len, + se_dma->CH[hwch].SRCADDR, ctrl); + se_dma->CH[SE_DMA_RX_CHAN].CONFIG |= DMA_CONFIG_EN; + } else { + if (se_done_hdlr) { + if (remains) { + se_done_hdlr((void *)out_addr, cur_out_len - remains, + HAL_SE_DONE_ERR_DMA_IN_REMAIN); + } else { + se_done_hdlr((void *)out_addr, cur_out_len, HAL_SE_DONE_OK); + } + } + } + } else { + if (cur_in_len < total_in_len) { + len = total_in_len - cur_in_len; + ctrl = se_dma->CH[hwch].CONTROL & ~DMA_CONTROL_TC_IRQ; + cur_in_len += se_dma_init_tx_desc(in_addr + cur_in_len, len, + se_dma->CH[hwch].DSTADDR, ctrl); + se_dma->CH[SE_DMA_TX_CHAN].CONFIG |= DMA_CONFIG_EN; + } else { + if (remains) { + if (se_done_hdlr) { + se_done_hdlr((void *)out_addr, 0, + HAL_SE_DONE_ERR_DMA_IN_REMAIN); + } + } + } + } + } + LOG_INFO(0, "%s: ch=%d tcint=%d errint=%d remains=%u", __func__, hwch, + tcint, errint, remains); + } + } } -static void se_dma_cancel_rx(void) -{ - se_dma->CH[SE_DMA_RX_CHAN].CONFIG &= ~DMA_CONFIG_EN; +static void se_dma_open(void) { + uint8_t i; + + se_adec->ADEC_CTRL |= ADEC_CTRL_CLK_EN_15_0(SE_ACC_CLK_DMA) | + ADEC_CTRL_RST_15_0(SE_ACC_RST_DMA); + se_adec->ADEC_CTRL &= ~ADEC_CTRL_RST_15_0(SE_ACC_RST_DMA); + se_adec->ADEC_INT_MSK = ~0UL; + + se_dmacfg->DMA_CTRL = DMA_CTRL_RX_DMA_EN | DMA_CTRL_TX_DMA_EN; + se_dmacfg->DMA_RDL = SE_DMA_RX_FIFO_TRIG_LEVEL; + se_dmacfg->DMA_TDL = SE_DMA_TX_FIFO_TRIG_LEVEL; + + /* Reset all channel configuration register */ + for (i = 0; i < SE_DMA_CHAN_NUM; i++) { + se_dma->CH[i].CONFIG = 0; + } + + /* Clear all DMA interrupt and error flag */ + se_dma->INTTCCLR = ~0UL; + se_dma->INTERRCLR = ~0UL; + + se_dma->DMACONFIG = (se_dma->DMACONFIG & ~(DMA_DMACONFIG_AHB1_BIGENDIAN | + DMA_DMACONFIG_AHB2_BIGENDIAN)) | + DMA_DMACONFIG_EN; + + NVIC_SetVector(SEDMA_IRQn, (uint32_t)sedma_irq_handler); + NVIC_SetPriority(SEDMA_IRQn, IRQ_PRIORITY_NORMAL); + NVIC_ClearPendingIRQ(SEDMA_IRQn); + NVIC_EnableIRQ(SEDMA_IRQn); } -static void se_dma_cancel_tx(void) -{ - se_dma->CH[SE_DMA_TX_CHAN].CONFIG &= ~DMA_CONFIG_EN; +static void se_dma_cancel_rx(void) { + se_dma->CH[SE_DMA_RX_CHAN].CONFIG &= ~DMA_CONFIG_EN; } -static void se_dma_close(void) -{ - NVIC_DisableIRQ(SEDMA_IRQn); - se_dma_cancel_rx(); - se_dma_cancel_tx(); - se_dma->DMACONFIG = 0; +static void se_dma_cancel_tx(void) { + se_dma->CH[SE_DMA_TX_CHAN].CONFIG &= ~DMA_CONFIG_EN; } -static uint32_t se_dma_init_rx_desc(uint32_t out, uint32_t out_len, uint32_t src, uint32_t ctrl) -{ - uint32_t len; - uint32_t cfg_len; - uint32_t desc_idx; - uint32_t i; +static void se_dma_close(void) { + NVIC_DisableIRQ(SEDMA_IRQn); + se_dma_cancel_rx(); + se_dma_cancel_tx(); + se_dma->DMACONFIG = 0; +} - len = out_len; +static uint32_t se_dma_init_rx_desc(uint32_t out, uint32_t out_len, + uint32_t src, uint32_t ctrl) { + uint32_t len; + uint32_t cfg_len; + uint32_t desc_idx; + uint32_t i; + + len = out_len; + if (len > SE_DMA_MAX_DESC_XFER_SIZE * 4) { + len = SE_DMA_MAX_DESC_XFER_SIZE * 4; + } + len &= ~(4 - 1); + ctrl = SET_BITFIELD(ctrl, DMA_CONTROL_TRANSFERSIZE, len / 4); + if (len >= out_len) { + // Always enable IRQ at the end of each xfer + ctrl |= DMA_CONTROL_TC_IRQ; + } + se_dma->CH[SE_DMA_RX_CHAN].CONTROL = ctrl; + se_dma->CH[SE_DMA_RX_CHAN].SRCADDR = src; + se_dma->CH[SE_DMA_RX_CHAN].DSTADDR = out; + + if (len >= out_len) { + se_dma->CH[SE_DMA_RX_CHAN].LLI = 0; + return len; + } + + cfg_len = len; + desc_idx = 0; + while (desc_idx < SE_DMA_DESC_NUM && cfg_len < out_len) { + len = out_len - cfg_len; if (len > SE_DMA_MAX_DESC_XFER_SIZE * 4) { - len = SE_DMA_MAX_DESC_XFER_SIZE * 4; + len = SE_DMA_MAX_DESC_XFER_SIZE * 4; } len &= ~(4 - 1); ctrl = SET_BITFIELD(ctrl, DMA_CONTROL_TRANSFERSIZE, len / 4); - if (len >= out_len) { - // Always enable IRQ at the end of each xfer - ctrl |= DMA_CONTROL_TC_IRQ; - } - se_dma->CH[SE_DMA_RX_CHAN].CONTROL = ctrl; - se_dma->CH[SE_DMA_RX_CHAN].SRCADDR = src; - se_dma->CH[SE_DMA_RX_CHAN].DSTADDR = out; + dma_desc[SE_DMA_RX_CHAN][desc_idx].ctrl = ctrl; + dma_desc[SE_DMA_RX_CHAN][desc_idx].src = src; + dma_desc[SE_DMA_RX_CHAN][desc_idx].dst = out + cfg_len; + cfg_len += len; + desc_idx++; + } - if (len >= out_len) { - se_dma->CH[SE_DMA_RX_CHAN].LLI = 0; - return len; - } + // Always enable IRQ at the end of each xfer + dma_desc[SE_DMA_RX_CHAN][desc_idx - 1].ctrl |= DMA_CONTROL_TC_IRQ; - cfg_len = len; - desc_idx = 0; - while (desc_idx < SE_DMA_DESC_NUM && cfg_len < out_len) { - len = out_len - cfg_len; - if (len > SE_DMA_MAX_DESC_XFER_SIZE * 4) { - len = SE_DMA_MAX_DESC_XFER_SIZE * 4; - } - len &= ~(4 - 1); - ctrl = SET_BITFIELD(ctrl, DMA_CONTROL_TRANSFERSIZE, len / 4); - dma_desc[SE_DMA_RX_CHAN][desc_idx].ctrl = ctrl; - dma_desc[SE_DMA_RX_CHAN][desc_idx].src = src; - dma_desc[SE_DMA_RX_CHAN][desc_idx].dst = out + cfg_len; - cfg_len += len; - desc_idx++; - } + for (i = 0; i + 1 < desc_idx; i++) { + dma_desc[SE_DMA_RX_CHAN][i].lli = + (uint32_t)&dma_desc[SE_DMA_RX_CHAN][i + 1]; + } + dma_desc[SE_DMA_RX_CHAN][desc_idx - 1].lli = 0; - // Always enable IRQ at the end of each xfer - dma_desc[SE_DMA_RX_CHAN][desc_idx - 1].ctrl |= DMA_CONTROL_TC_IRQ; + se_dma->CH[SE_DMA_RX_CHAN].LLI = (uint32_t)&dma_desc[SE_DMA_RX_CHAN][0]; - for (i = 0; i + 1 < desc_idx; i++) { - dma_desc[SE_DMA_RX_CHAN][i].lli = (uint32_t)&dma_desc[SE_DMA_RX_CHAN][i + 1]; - } - dma_desc[SE_DMA_RX_CHAN][desc_idx - 1].lli = 0; - - se_dma->CH[SE_DMA_RX_CHAN].LLI = (uint32_t)&dma_desc[SE_DMA_RX_CHAN][0]; - - return cfg_len; + return cfg_len; } -static void se_dma_enable_rx(void *out, uint32_t out_len) -{ - uint32_t ctrl; +static void se_dma_enable_rx(void *out, uint32_t out_len) { + uint32_t ctrl; - ASSERT((out_len & (4 - 1)) == 0, "%s: out_len must align to 4 bytes: %u", __func__, out_len); + ASSERT((out_len & (4 - 1)) == 0, "%s: out_len must align to 4 bytes: %u", + __func__, out_len); - out_addr = (uint32_t)out; - total_out_len = out_len; + out_addr = (uint32_t)out; + total_out_len = out_len; - /* Reset the Interrupt status */ - se_dma->INTTCCLR = DMA_STAT_CHAN(SE_DMA_RX_CHAN); - se_dma->INTERRCLR = DMA_STAT_CHAN(SE_DMA_RX_CHAN); + /* Reset the Interrupt status */ + se_dma->INTTCCLR = DMA_STAT_CHAN(SE_DMA_RX_CHAN); + se_dma->INTERRCLR = DMA_STAT_CHAN(SE_DMA_RX_CHAN); - ctrl = DMA_CONTROL_SBSIZE(HAL_DMA_BSIZE_8) | - DMA_CONTROL_DBSIZE(HAL_DMA_BSIZE_16) | - DMA_CONTROL_SWIDTH(HAL_DMA_WIDTH_WORD) | - DMA_CONTROL_DWIDTH(HAL_DMA_WIDTH_BYTE) | - DMA_CONTROL_DI; + ctrl = DMA_CONTROL_SBSIZE(HAL_DMA_BSIZE_8) | + DMA_CONTROL_DBSIZE(HAL_DMA_BSIZE_16) | + DMA_CONTROL_SWIDTH(HAL_DMA_WIDTH_WORD) | + DMA_CONTROL_DWIDTH(HAL_DMA_WIDTH_BYTE) | DMA_CONTROL_DI; - cur_out_len = se_dma_init_rx_desc((uint32_t)out, out_len, (uint32_t)&se_dmacfg->DMA_RXFIFO, ctrl); + cur_out_len = se_dma_init_rx_desc((uint32_t)out, out_len, + (uint32_t)&se_dmacfg->DMA_RXFIFO, ctrl); - se_dma->CH[SE_DMA_RX_CHAN].CONFIG = DMA_CONFIG_SRCPERIPH(SE_DMA_PERIPH_RX) | - DMA_CONFIG_TRANSFERTYPE(HAL_DMA_FLOW_P2M_DMA) | - DMA_CONFIG_ERR_IRQMASK | DMA_CONFIG_TC_IRQMASK; - se_dma->CH[SE_DMA_RX_CHAN].CONFIG |= DMA_CONFIG_EN; + se_dma->CH[SE_DMA_RX_CHAN].CONFIG = + DMA_CONFIG_SRCPERIPH(SE_DMA_PERIPH_RX) | + DMA_CONFIG_TRANSFERTYPE(HAL_DMA_FLOW_P2M_DMA) | DMA_CONFIG_ERR_IRQMASK | + DMA_CONFIG_TC_IRQMASK; + se_dma->CH[SE_DMA_RX_CHAN].CONFIG |= DMA_CONFIG_EN; } -static uint32_t se_dma_init_tx_desc(uint32_t in, uint32_t in_len, uint32_t dst, uint32_t ctrl) -{ - uint32_t len; - uint32_t cfg_len; - uint32_t desc_idx; - uint32_t i; +static uint32_t se_dma_init_tx_desc(uint32_t in, uint32_t in_len, uint32_t dst, + uint32_t ctrl) { + uint32_t len; + uint32_t cfg_len; + uint32_t desc_idx; + uint32_t i; - len = in_len; + len = in_len; + if (len > SE_DMA_MAX_DESC_XFER_SIZE) { + len = SE_DMA_MAX_DESC_XFER_SIZE; + } + ctrl = SET_BITFIELD(ctrl, DMA_CONTROL_TRANSFERSIZE, len); + se_dma->CH[SE_DMA_TX_CHAN].CONTROL = ctrl; + se_dma->CH[SE_DMA_TX_CHAN].SRCADDR = in; + se_dma->CH[SE_DMA_TX_CHAN].DSTADDR = dst; + + if (len >= in_len) { + se_dma->CH[SE_DMA_TX_CHAN].LLI = 0; + return len; + } + + cfg_len = len; + desc_idx = 0; + while (desc_idx < SE_DMA_DESC_NUM && cfg_len < in_len) { + len = in_len - cfg_len; if (len > SE_DMA_MAX_DESC_XFER_SIZE) { - len = SE_DMA_MAX_DESC_XFER_SIZE; + len = SE_DMA_MAX_DESC_XFER_SIZE; } ctrl = SET_BITFIELD(ctrl, DMA_CONTROL_TRANSFERSIZE, len); - se_dma->CH[SE_DMA_TX_CHAN].CONTROL = ctrl; - se_dma->CH[SE_DMA_TX_CHAN].SRCADDR = in; - se_dma->CH[SE_DMA_TX_CHAN].DSTADDR = dst; + dma_desc[SE_DMA_TX_CHAN][desc_idx].ctrl = ctrl; + dma_desc[SE_DMA_TX_CHAN][desc_idx].src = in + cfg_len; + dma_desc[SE_DMA_TX_CHAN][desc_idx].dst = dst; + cfg_len += len; + desc_idx++; + } - if (len >= in_len) { - se_dma->CH[SE_DMA_TX_CHAN].LLI = 0; - return len; - } + if (cfg_len < in_len) { + // Enable IRQ at the end of xfer + dma_desc[SE_DMA_TX_CHAN][desc_idx - 1].ctrl |= DMA_CONTROL_TC_IRQ; + } - cfg_len = len; - desc_idx = 0; - while (desc_idx < SE_DMA_DESC_NUM && cfg_len < in_len) { - len = in_len - cfg_len; - if (len > SE_DMA_MAX_DESC_XFER_SIZE) { - len = SE_DMA_MAX_DESC_XFER_SIZE; - } - ctrl = SET_BITFIELD(ctrl, DMA_CONTROL_TRANSFERSIZE, len); - dma_desc[SE_DMA_TX_CHAN][desc_idx].ctrl = ctrl; - dma_desc[SE_DMA_TX_CHAN][desc_idx].src = in + cfg_len; - dma_desc[SE_DMA_TX_CHAN][desc_idx].dst = dst; - cfg_len += len; - desc_idx++; - } + for (i = 0; i + 1 < desc_idx; i++) { + dma_desc[SE_DMA_TX_CHAN][i].lli = + (uint32_t)&dma_desc[SE_DMA_TX_CHAN][i + 1]; + } + dma_desc[SE_DMA_TX_CHAN][desc_idx - 1].lli = 0; - if (cfg_len < in_len) { - // Enable IRQ at the end of xfer - dma_desc[SE_DMA_TX_CHAN][desc_idx - 1].ctrl |= DMA_CONTROL_TC_IRQ; - } + se_dma->CH[SE_DMA_TX_CHAN].LLI = (uint32_t)&dma_desc[SE_DMA_TX_CHAN][0]; - for (i = 0; i + 1 < desc_idx; i++) { - dma_desc[SE_DMA_TX_CHAN][i].lli = (uint32_t)&dma_desc[SE_DMA_TX_CHAN][i + 1]; - } - dma_desc[SE_DMA_TX_CHAN][desc_idx - 1].lli = 0; - - se_dma->CH[SE_DMA_TX_CHAN].LLI = (uint32_t)&dma_desc[SE_DMA_TX_CHAN][0]; - - return cfg_len; + return cfg_len; } -static void se_dma_enable_tx(const void *in, uint32_t in_len) -{ - uint32_t ctrl; +static void se_dma_enable_tx(const void *in, uint32_t in_len) { + uint32_t ctrl; - if (in_len & (4 - 1)) { - in_len = (in_len + (4 - 1)) & ~(4 - 1); - } + if (in_len & (4 - 1)) { + in_len = (in_len + (4 - 1)) & ~(4 - 1); + } - in_addr = (uint32_t)in; - total_in_len = in_len; + in_addr = (uint32_t)in; + total_in_len = in_len; - /* Reset the Interrupt status */ - se_dma->INTTCCLR = DMA_STAT_CHAN(SE_DMA_TX_CHAN); - se_dma->INTERRCLR = DMA_STAT_CHAN(SE_DMA_TX_CHAN); + /* Reset the Interrupt status */ + se_dma->INTTCCLR = DMA_STAT_CHAN(SE_DMA_TX_CHAN); + se_dma->INTERRCLR = DMA_STAT_CHAN(SE_DMA_TX_CHAN); - ctrl = DMA_CONTROL_SBSIZE(HAL_DMA_BSIZE_16) | - DMA_CONTROL_DBSIZE(HAL_DMA_BSIZE_8) | - DMA_CONTROL_SWIDTH(HAL_DMA_WIDTH_BYTE) | - DMA_CONTROL_DWIDTH(HAL_DMA_WIDTH_WORD) | - DMA_CONTROL_SI; + ctrl = DMA_CONTROL_SBSIZE(HAL_DMA_BSIZE_16) | + DMA_CONTROL_DBSIZE(HAL_DMA_BSIZE_8) | + DMA_CONTROL_SWIDTH(HAL_DMA_WIDTH_BYTE) | + DMA_CONTROL_DWIDTH(HAL_DMA_WIDTH_WORD) | DMA_CONTROL_SI; - cur_in_len = se_dma_init_tx_desc((uint32_t)in, in_len, (uint32_t)&se_dmacfg->DMA_TXFIFO, ctrl); + cur_in_len = se_dma_init_tx_desc((uint32_t)in, in_len, + (uint32_t)&se_dmacfg->DMA_TXFIFO, ctrl); - se_dma->CH[SE_DMA_TX_CHAN].CONFIG = DMA_CONFIG_DSTPERIPH(SE_DMA_PERIPH_TX) | - DMA_CONFIG_TRANSFERTYPE(HAL_DMA_FLOW_M2P_DMA) | - DMA_CONFIG_ERR_IRQMASK | DMA_CONFIG_TC_IRQMASK; - se_dma->CH[SE_DMA_TX_CHAN].CONFIG |= DMA_CONFIG_EN; + se_dma->CH[SE_DMA_TX_CHAN].CONFIG = + DMA_CONFIG_DSTPERIPH(SE_DMA_PERIPH_TX) | + DMA_CONFIG_TRANSFERTYPE(HAL_DMA_FLOW_M2P_DMA) | DMA_CONFIG_ERR_IRQMASK | + DMA_CONFIG_TC_IRQMASK; + se_dma->CH[SE_DMA_TX_CHAN].CONFIG |= DMA_CONFIG_EN; } -enum HAL_SE_RET_T hal_se_open(void) -{ - if (se_enabled) { - return HAL_SE_ALREADY_OPENED; - } +enum HAL_SE_RET_T hal_se_open(void) { + if (se_enabled) { + return HAL_SE_ALREADY_OPENED; + } - se_enabled = true; + se_enabled = true; - hal_cmu_clock_enable(HAL_CMU_MOD_H_SEC_ENG); - hal_cmu_clock_enable(HAL_CMU_MOD_P_SEC_ENG); - hal_cmu_reset_clear(HAL_CMU_MOD_H_SEC_ENG); - hal_cmu_reset_clear(HAL_CMU_MOD_P_SEC_ENG); + hal_cmu_clock_enable(HAL_CMU_MOD_H_SEC_ENG); + hal_cmu_clock_enable(HAL_CMU_MOD_P_SEC_ENG); + hal_cmu_reset_clear(HAL_CMU_MOD_H_SEC_ENG); + hal_cmu_reset_clear(HAL_CMU_MOD_P_SEC_ENG); - se_dma_open(); + se_dma_open(); - NVIC_SetVector(SEC_ENG_IRQn, (uint32_t)sec_eng_irq_handler); - NVIC_SetPriority(SEC_ENG_IRQn, IRQ_PRIORITY_NORMAL); - NVIC_ClearPendingIRQ(SEC_ENG_IRQn); - NVIC_EnableIRQ(SEC_ENG_IRQn); + NVIC_SetVector(SEC_ENG_IRQn, (uint32_t)sec_eng_irq_handler); + NVIC_SetPriority(SEC_ENG_IRQn, IRQ_PRIORITY_NORMAL); + NVIC_ClearPendingIRQ(SEC_ENG_IRQn); + NVIC_EnableIRQ(SEC_ENG_IRQn); - return HAL_SE_OK; + return HAL_SE_OK; } -enum HAL_SE_RET_T hal_se_close(void) -{ - if (!se_enabled) { - return HAL_SE_NOT_OPENED; - } +enum HAL_SE_RET_T hal_se_close(void) { + if (!se_enabled) { + return HAL_SE_NOT_OPENED; + } - NVIC_DisableIRQ(SEC_ENG_IRQn); + NVIC_DisableIRQ(SEC_ENG_IRQn); - se_dma_close(); + se_dma_close(); - se_adec->ADEC_INT_MSK = ~0UL; - se_adec->ADEC_CTRL = ~0UL; - se_adec->ADEC_CTRL2 = ~0UL; - se_adec->ADEC_CTRL = 0x0000FFFF; - se_adec->ADEC_CTRL2 = 0x0000FFFF; + se_adec->ADEC_INT_MSK = ~0UL; + se_adec->ADEC_CTRL = ~0UL; + se_adec->ADEC_CTRL2 = ~0UL; + se_adec->ADEC_CTRL = 0x0000FFFF; + se_adec->ADEC_CTRL2 = 0x0000FFFF; - hal_cmu_reset_set(HAL_CMU_MOD_H_SEC_ENG); - hal_cmu_reset_set(HAL_CMU_MOD_P_SEC_ENG); - hal_cmu_clock_disable(HAL_CMU_MOD_H_SEC_ENG); - hal_cmu_clock_disable(HAL_CMU_MOD_P_SEC_ENG); + hal_cmu_reset_set(HAL_CMU_MOD_H_SEC_ENG); + hal_cmu_reset_set(HAL_CMU_MOD_P_SEC_ENG); + hal_cmu_clock_disable(HAL_CMU_MOD_H_SEC_ENG); + hal_cmu_clock_disable(HAL_CMU_MOD_P_SEC_ENG); - se_enabled = false; + se_enabled = false; - return HAL_SE_OK; + return HAL_SE_OK; } -static void write_mreg(volatile uint32_t *reg, const void *mem, uint32_t len) -{ - const uint32_t *p32 = (const uint32_t *)mem; - uint32_t i; - bool aligned_state; +static void write_mreg(volatile uint32_t *reg, const void *mem, uint32_t len) { + const uint32_t *p32 = (const uint32_t *)mem; + uint32_t i; + bool aligned_state; - aligned_state = config_unaligned_access(true); + aligned_state = config_unaligned_access(true); - i = 0; - while (i < len) { - *reg++ = *p32++; - i += 4; - } + i = 0; + while (i < len) { + *reg++ = *p32++; + i += 4; + } - config_unaligned_access(aligned_state); + config_unaligned_access(aligned_state); } -POSSIBLY_UNUSED static void read_mreg(const volatile uint32_t *reg, void *mem, uint32_t len) -{ - uint32_t *p32 = (uint32_t *)mem; - uint32_t i; - bool aligned_state; +POSSIBLY_UNUSED static void read_mreg(const volatile uint32_t *reg, void *mem, + uint32_t len) { + uint32_t *p32 = (uint32_t *)mem; + uint32_t i; + bool aligned_state; - aligned_state = config_unaligned_access(true); + aligned_state = config_unaligned_access(true); - i = 0; - while (i < len) { - *p32++ = *reg++; - i += 4; - } + i = 0; + while (i < len) { + *p32++ = *reg++; + i += 4; + } - config_unaligned_access(aligned_state); + config_unaligned_access(aligned_state); } -enum HAL_SE_RET_T se_aes_crypt(const struct HAL_SE_AES_CFG_T *cfg, bool decrypt) -{ - enum SE_AES_KEY_LEN_T key_len_t; - uint8_t modular; +enum HAL_SE_RET_T se_aes_crypt(const struct HAL_SE_AES_CFG_T *cfg, + bool decrypt) { + enum SE_AES_KEY_LEN_T key_len_t; + uint8_t modular; - if (!se_enabled) { - return HAL_SE_NOT_OPENED; - } + if (!se_enabled) { + return HAL_SE_NOT_OPENED; + } - if (cfg == NULL) { - return HAL_SE_CFG_NULL; + if (cfg == NULL) { + return HAL_SE_CFG_NULL; + } + if (cfg->in == NULL) { + return HAL_SE_INPUT_NULL; + } + if (cfg->out == NULL) { + return HAL_SE_OUTPUT_NULL; + } + if (cfg->key == NULL) { + return HAL_SE_KEY_NULL; + } + if (cfg->mode >= HAL_SE_AES_MODE_QTY) { + return HAL_SE_BAD_AES_MODE; + } + if (cfg->mode != HAL_SE_AES_ECB && cfg->iv == NULL) { + return HAL_SE_IV_NULL; + } + if (cfg->in_len < 16) { + return HAL_SE_BAD_INPUT_LEN; + } + if (cfg->mode == HAL_SE_AES_ECB) { + if (cfg->in_len & (16 - 1)) { + return HAL_SE_BAD_INPUT_LEN; } - if (cfg->in == NULL) { - return HAL_SE_INPUT_NULL; + } else { + // TODO: Support padding or CBC CTS mode? + if (cfg->in_len & (16 - 1)) { + return HAL_SE_BAD_INPUT_LEN; } - if (cfg->out == NULL) { - return HAL_SE_OUTPUT_NULL; + } + if (cfg->mode == HAL_SE_AES_KEY_WRAP) { + if (cfg->in_len & (8 - 1)) { + return HAL_SE_BAD_INPUT_LEN; } - if (cfg->key == NULL) { - return HAL_SE_KEY_NULL; - } - if (cfg->mode >= HAL_SE_AES_MODE_QTY) { - return HAL_SE_BAD_AES_MODE; - } - if (cfg->mode != HAL_SE_AES_ECB && cfg->iv == NULL) { - return HAL_SE_IV_NULL; - } - if (cfg->in_len < 16) { - return HAL_SE_BAD_INPUT_LEN; - } - if (cfg->mode == HAL_SE_AES_ECB) { - if (cfg->in_len & (16 - 1)) { - return HAL_SE_BAD_INPUT_LEN; - } + if (decrypt) { + if (cfg->out_len + 8 != cfg->in_len) { + return HAL_SE_BAD_OUTPUT_LEN; + } } else { - // TODO: Support padding or CBC CTS mode? - if (cfg->in_len & (16 - 1)) { - return HAL_SE_BAD_INPUT_LEN; - } + if (cfg->out_len != cfg->in_len + 8) { + return HAL_SE_BAD_OUTPUT_LEN; + } } - if (cfg->mode == HAL_SE_AES_KEY_WRAP) { - if (cfg->in_len & (8 - 1)) { - return HAL_SE_BAD_INPUT_LEN; - } - if (decrypt) { - if (cfg->out_len + 8 != cfg->in_len) { - return HAL_SE_BAD_OUTPUT_LEN; - } - } else { - if (cfg->out_len != cfg->in_len + 8) { - return HAL_SE_BAD_OUTPUT_LEN; - } - } - } else { - // If padding enabled, - // 1) ENC: cfg->out_len == ((cfg->in_len + 16) & ~(16 - 1)) - // 2) DEC: cfg->out_len == cfg->in_len - if (cfg->out_len != cfg->in_len) { - return HAL_SE_BAD_OUTPUT_LEN; - } + } else { + // If padding enabled, + // 1) ENC: cfg->out_len == ((cfg->in_len + 16) & ~(16 - 1)) + // 2) DEC: cfg->out_len == cfg->in_len + if (cfg->out_len != cfg->in_len) { + return HAL_SE_BAD_OUTPUT_LEN; } - modular = 0; - if (cfg->mode == HAL_SE_AES_CTR) { - if (cfg->ctr_modular > 128) { - return HAL_SE_BAD_AES_MODULAR; - } else if (cfg->ctr_modular < 128) { - modular = cfg->ctr_modular; - } + } + modular = 0; + if (cfg->mode == HAL_SE_AES_CTR) { + if (cfg->ctr_modular > 128) { + return HAL_SE_BAD_AES_MODULAR; + } else if (cfg->ctr_modular < 128) { + modular = cfg->ctr_modular; } + } - if (cfg->key_len == 16) { - key_len_t = SE_AES_KEY_128; - } else if (cfg->key_len == 24) { - key_len_t = SE_AES_KEY_192; - } else if (cfg->key_len == 32) { - key_len_t = SE_AES_KEY_256; - } else { - return HAL_SE_BAD_KEY_LEN; - } + if (cfg->key_len == 16) { + key_len_t = SE_AES_KEY_128; + } else if (cfg->key_len == 24) { + key_len_t = SE_AES_KEY_192; + } else if (cfg->key_len == 32) { + key_len_t = SE_AES_KEY_256; + } else { + return HAL_SE_BAD_KEY_LEN; + } + if (se_crypt->AES_STATUS & AES_STATUS_BUSY) { + return HAL_SE_ENG_BUSY; + } + if (se_dma->ENBLDCHNS & + (DMA_STAT_CHAN(SE_DMA_RX_CHAN) | DMA_STAT_CHAN(SE_DMA_TX_CHAN))) { + return HAL_SE_DMA_BUSY; + } + + se_done_hdlr = cfg->done_hdlr; + + se_adec->ADEC_CTRL |= ADEC_CTRL_CLK_EN_15_0(SE_ACC_CLK_CRYPT) | + ADEC_CTRL_RST_15_0(SE_ACC_RST_CRYPT); + se_adec->ADEC_CTRL &= ~ADEC_CTRL_RST_15_0(SE_ACC_RST_CRYPT); + se_adec->ADEC_INT = SE_ACC_INT_AES; + se_adec->ADEC_INT_MSK &= ~SE_ACC_INT_AES; + + se_dmacfg->DMA_FIFOCLR = DMA_FIFOCLR_RXFIFO_CLR | DMA_FIFOCLR_TXFIFO_CLR; + + se_acb->ACB_CTRL &= ~(ACB_CTRL_WR_CB_CTRL | ACB_CTRL_RD_CB_CTRL); + + se_crypt->ENGINE_SELECT = ENGINE_SELECT_SELECT(SE_CRYPT_AES); + // TODO: Set cts_mode, rkey + se_crypt->AES_CFG = AES_CFG_MODULAR(modular) | AES_CFG_MODE(cfg->mode) | + AES_CFG_KEYLEN(key_len_t) | + (decrypt ? AES_CFG_DECRYPT : 0); + se_crypt->AES_INTRPT = ~0UL; + se_crypt->AES_INTRPT_SRC_EN = + AES_INTRPT_SRC_EN_ERROR1 | AES_INTRPT_SRC_EN_ERROR2; + // se_crypt->AES_INTRPT_SRC_EN |= AES_INTRPT_SRC_EN_DONE; + // TODO: Set outputblock, resume + se_crypt->AES_CTRL |= AES_CTRL_RESET; + se_crypt->AES_CTRL &= ~AES_CTRL_RESET; + + write_mreg(&se_crypt->KEY1[0], cfg->key, cfg->key_len); + if (cfg->mode != HAL_SE_AES_ECB) { + write_mreg(&se_crypt->IV[0], cfg->iv, 16); + if (cfg->mode == HAL_SE_AES_XTS) { + write_mreg(&se_crypt->KEY2[0], cfg->key2, cfg->key_len); + } + } + + se_dma_enable_tx(cfg->in, cfg->in_len); + se_dma_enable_rx(cfg->out, cfg->out_len); + + se_crypt->AES_STREAM_SIZE = cfg->in_len; + se_crypt->AES_CMD = AES_CMD_START; + + return HAL_SE_OK; +} + +enum HAL_SE_RET_T hal_se_aes_encrypt(const struct HAL_SE_AES_CFG_T *cfg) { + return se_aes_crypt(cfg, false); +} + +enum HAL_SE_RET_T hal_se_aes_decrypt(const struct HAL_SE_AES_CFG_T *cfg) { + return se_aes_crypt(cfg, true); +} + +int hal_se_aes_busy(void) { + if (se_enabled) { if (se_crypt->AES_STATUS & AES_STATUS_BUSY) { - return HAL_SE_ENG_BUSY; + return true; } - if (se_dma->ENBLDCHNS & (DMA_STAT_CHAN(SE_DMA_RX_CHAN) | DMA_STAT_CHAN(SE_DMA_TX_CHAN))) { - return HAL_SE_DMA_BUSY; + if (se_dma->ENBLDCHNS & DMA_STAT_CHAN(SE_DMA_RX_CHAN)) { + return true; } - - se_done_hdlr = cfg->done_hdlr; - - se_adec->ADEC_CTRL |= ADEC_CTRL_CLK_EN_15_0(SE_ACC_CLK_CRYPT) | ADEC_CTRL_RST_15_0(SE_ACC_RST_CRYPT); - se_adec->ADEC_CTRL &= ~ADEC_CTRL_RST_15_0(SE_ACC_RST_CRYPT); - se_adec->ADEC_INT = SE_ACC_INT_AES; - se_adec->ADEC_INT_MSK &= ~SE_ACC_INT_AES; - - se_dmacfg->DMA_FIFOCLR = DMA_FIFOCLR_RXFIFO_CLR | DMA_FIFOCLR_TXFIFO_CLR; - - se_acb->ACB_CTRL &= ~(ACB_CTRL_WR_CB_CTRL | ACB_CTRL_RD_CB_CTRL); - - se_crypt->ENGINE_SELECT = ENGINE_SELECT_SELECT(SE_CRYPT_AES); - // TODO: Set cts_mode, rkey - se_crypt->AES_CFG = AES_CFG_MODULAR(modular) | AES_CFG_MODE(cfg->mode) | - AES_CFG_KEYLEN(key_len_t) | (decrypt ? AES_CFG_DECRYPT : 0); - se_crypt->AES_INTRPT = ~0UL; - se_crypt->AES_INTRPT_SRC_EN = AES_INTRPT_SRC_EN_ERROR1 | AES_INTRPT_SRC_EN_ERROR2; - //se_crypt->AES_INTRPT_SRC_EN |= AES_INTRPT_SRC_EN_DONE; - // TODO: Set outputblock, resume - se_crypt->AES_CTRL |= AES_CTRL_RESET; - se_crypt->AES_CTRL &= ~AES_CTRL_RESET; - - write_mreg(&se_crypt->KEY1[0], cfg->key, cfg->key_len); - if (cfg->mode != HAL_SE_AES_ECB) { - write_mreg(&se_crypt->IV[0], cfg->iv, 16); - if (cfg->mode == HAL_SE_AES_XTS) { - write_mreg(&se_crypt->KEY2[0], cfg->key2, cfg->key_len); - } - } - - se_dma_enable_tx(cfg->in, cfg->in_len); - se_dma_enable_rx(cfg->out, cfg->out_len); - - se_crypt->AES_STREAM_SIZE = cfg->in_len; - se_crypt->AES_CMD = AES_CMD_START; - - return HAL_SE_OK; + } + return false; } -enum HAL_SE_RET_T hal_se_aes_encrypt(const struct HAL_SE_AES_CFG_T *cfg) -{ - return se_aes_crypt(cfg, false); -} +enum HAL_SE_RET_T hal_se_aes_reset(void) { + uint32_t lock; -enum HAL_SE_RET_T hal_se_aes_decrypt(const struct HAL_SE_AES_CFG_T *cfg) -{ - return se_aes_crypt(cfg, true); -} + if (!se_enabled) { + return HAL_SE_NOT_OPENED; + } -int hal_se_aes_busy(void) -{ - if (se_enabled) { - if (se_crypt->AES_STATUS & AES_STATUS_BUSY) { - return true; - } - if (se_dma->ENBLDCHNS & DMA_STAT_CHAN(SE_DMA_RX_CHAN)) { - return true; - } - } - return false; -} + lock = int_lock(); + se_dma_cancel_rx(); + se_dma_cancel_tx(); + /* Clear all DMA interrupt and error flag */ + se_dma->INTTCCLR = ~0UL; + se_dma->INTERRCLR = ~0UL; -enum HAL_SE_RET_T hal_se_aes_reset(void) -{ - uint32_t lock; + se_adec->ADEC_CTRL |= ADEC_CTRL_CLK_EN_15_0(SE_ACC_CLK_CRYPT) | + ADEC_CTRL_RST_15_0(SE_ACC_RST_CRYPT); + se_crypt->AES_INTRPT = ~0UL; + se_adec->ADEC_INT = SE_ACC_INT_AES; + int_unlock(lock); - if (!se_enabled) { - return HAL_SE_NOT_OPENED; - } - - lock = int_lock(); - se_dma_cancel_rx(); - se_dma_cancel_tx(); - /* Clear all DMA interrupt and error flag */ - se_dma->INTTCCLR = ~0UL; - se_dma->INTERRCLR = ~0UL; - - se_adec->ADEC_CTRL |= ADEC_CTRL_CLK_EN_15_0(SE_ACC_CLK_CRYPT) | ADEC_CTRL_RST_15_0(SE_ACC_RST_CRYPT); - se_crypt->AES_INTRPT = ~0UL; - se_adec->ADEC_INT = SE_ACC_INT_AES; - int_unlock(lock); - - return HAL_SE_OK; + return HAL_SE_OK; } #ifdef SEC_ENG_HAS_HASH -enum HAL_SE_RET_T se_hash_init(enum HAL_SE_HASH_MODE_T mode, const void *key, uint32_t key_len) -{ - uint32_t val; - bool hmac; +enum HAL_SE_RET_T se_hash_init(enum HAL_SE_HASH_MODE_T mode, const void *key, + uint32_t key_len) { + uint32_t val; + bool hmac; - if (!se_enabled) { - return HAL_SE_NOT_OPENED; + if (!se_enabled) { + return HAL_SE_NOT_OPENED; + } + + if (mode >= HAL_SE_HASH_QTY) { + return HAL_SE_BAD_MODE; + } + + hmac = (key_len > 0); + if (hmac) { + if (key == NULL) { + return HAL_SE_KEY_NULL; } - - if (mode >= HAL_SE_HASH_QTY) { - return HAL_SE_BAD_MODE; - } - - hmac = (key_len > 0); - if (hmac) { - if (key == NULL) { - return HAL_SE_KEY_NULL; - } - if (mode == HAL_SE_HASH_SHA384 || mode == HAL_SE_HASH_SHA512) { - if (key_len > 128) { - return HAL_SE_BAD_KEY_LEN; - } - } else { - if (key_len > 64) { - return HAL_SE_BAD_KEY_LEN; - } - } - } - - if (se_hash->HASH_STATUS & HASH_STATUS_HASH_BUSY) { - return HAL_SE_ENG_BUSY; - } - if (se_dma->ENBLDCHNS & DMA_STAT_CHAN(SE_DMA_TX_CHAN)) { - return HAL_SE_DMA_BUSY; - } - - se_adec->ADEC_CTRL |= ADEC_CTRL_CLK_EN_15_0(SE_ACC_CLK_HASH) | ADEC_CTRL_RST_15_0(SE_ACC_RST_HASH); - se_adec->ADEC_CTRL &= ~ADEC_CTRL_RST_15_0(SE_ACC_RST_HASH); - se_adec->ADEC_INT = SE_ACC_INT_HASH; - se_adec->ADEC_INT_MSK |= SE_ACC_INT_HASH; - - se_dmacfg->DMA_FIFOCLR = DMA_FIFOCLR_TXFIFO_CLR; - - se_acb->ACB_CTRL |= ACB_CTRL_RD_CB_CTRL; - - se_hash->HASH_CFG = HASH_CFG_ALG_SELECT(mode); - val = se_hash->HASH_CTRL; - //val |= HASH_CTRL_RESET; - se_hash->HASH_CTRL = val; - val &= ~(HASH_CTRL_RESET | HASH_CTRL_HW_PADDING); - se_hash->HASH_CTRL = val; - val = SET_BITFIELD(val, HASH_CTRL_HASH_OP_MODE, SE_HASH_OP_INIT); - se_hash->HASH_CTRL = val; - if (hmac) { - se_hash->HASH_CFG |= HASH_CFG_HASH_MODE; - write_mreg(&se_hash->HMAC_KEY[0], key, key_len); - se_hash->HMAC_KEY_LEN = key_len; - } - se_hash->HASH_CMD = HASH_CMD_START; - - // HASH: 500ns; HMAC: 3000ns - while ((se_hash->HASH_STATUS & HASH_STATUS_HASH_DONE) == 0); - - return HAL_SE_OK; -} - -enum HAL_SE_RET_T hal_se_hash_init(enum HAL_SE_HASH_MODE_T mode) -{ - return se_hash_init(mode, NULL, 0); -} - -enum HAL_SE_RET_T se_hash_start(const struct HAL_SE_HASH_CFG_T *cfg, enum SE_HASH_OP_T op, uint64_t total_in_len) -{ - enum SE_HASH_OP_T prev_op; - uint32_t val; - - if (!se_enabled) { - return HAL_SE_NOT_OPENED; - } - - if (cfg == NULL) { - return HAL_SE_CFG_NULL; - } - if (op == SE_HASH_OP_FINAL) { - if (cfg->in == NULL && cfg->in_len) { - return HAL_SE_INPUT_NULL; - } - } else { - if (cfg->in == NULL) { - return HAL_SE_INPUT_NULL; - } - if (cfg->in_len == 0) { - return HAL_SE_BAD_INPUT_LEN; - } - if (cfg->in_len & (64 - 1)) { - return HAL_SE_BAD_INPUT_LEN; - } - } - - prev_op = GET_BITFIELD(se_hash->HASH_CTRL, HASH_CTRL_HASH_OP_MODE); - if (prev_op != SE_HASH_OP_INIT && prev_op != SE_HASH_OP_UPDATE) { - return HAL_SE_BAD_OP; - } - if (se_hash->HASH_STATUS & HASH_STATUS_HASH_BUSY) { - return HAL_SE_ENG_BUSY; - } - if (se_dma->ENBLDCHNS & DMA_STAT_CHAN(SE_DMA_TX_CHAN)) { - return HAL_SE_DMA_BUSY; - } - - se_done_hdlr = cfg->done_hdlr; - - se_hash->HASH_STATUS = ~0UL; - se_adec->ADEC_INT = SE_ACC_INT_HASH; - se_adec->ADEC_INT_MSK &= ~SE_ACC_INT_HASH; - - se_dmacfg->DMA_FIFOCLR = DMA_FIFOCLR_TXFIFO_CLR; - - if (cfg->in_len) { - se_dma_enable_tx(cfg->in, cfg->in_len); - } - - val = se_hash->HASH_CTRL; - val = SET_BITFIELD(val, HASH_CTRL_HASH_OP_MODE, op); - if (op == SE_HASH_OP_UPDATE) { - val &= ~HASH_CTRL_HW_PADDING; - } else { - val |= HASH_CTRL_HW_PADDING; - } - se_hash->HASH_CTRL = val; - if (op == SE_HASH_OP_FINAL) { - se_hash->HASH_MSG_SIZE_L = (uint32_t)total_in_len; - se_hash->HASH_MSG_SIZE_H = (uint32_t)(total_in_len >> 32); - } - se_hash->HASH_SEG_SIZE = cfg->in_len; - se_hash->HASH_CMD = HASH_CMD_START; - - return HAL_SE_OK; -} - -enum HAL_SE_RET_T hal_se_hash_update(const struct HAL_SE_HASH_CFG_T *cfg) -{ - return se_hash_start(cfg, SE_HASH_OP_UPDATE, 0); -} - -enum HAL_SE_RET_T hal_se_hash_final(const struct HAL_SE_HASH_CFG_T *cfg, uint64_t total_in_len) -{ - return se_hash_start(cfg, SE_HASH_OP_FINAL, total_in_len); -} - -enum HAL_SE_RET_T hal_se_hash(enum HAL_SE_HASH_MODE_T mode, const struct HAL_SE_HASH_CFG_T *cfg) -{ - enum HAL_SE_RET_T ret; - - ret = hal_se_hash_init(mode); - if (ret != HAL_SE_OK) { - return ret; - } - ret = hal_se_hash_final(cfg, cfg->in_len); - return ret; -} - -static uint32_t se_hash_get_digest_len(void) -{ - enum HAL_SE_HASH_MODE_T mode; - uint32_t max_len; - - mode = GET_BITFIELD(se_hash->HASH_CFG, HASH_CFG_ALG_SELECT); - if (mode == HAL_SE_HASH_MD5) { - max_len = 16; - } else if (mode == HAL_SE_HASH_SHA1) { - max_len = 20; - } else if (mode == HAL_SE_HASH_SHA224) { - max_len = 28; - } else if (mode == HAL_SE_HASH_SHA256) { - max_len = 32; - } else if (mode == HAL_SE_HASH_SHA384) { - max_len = 48; - } else { - max_len = 64; - } - - return max_len; -} - -enum HAL_SE_RET_T hal_se_hash_get_digest(void *out, uint32_t out_len, uint32_t *real_len) -{ - enum SE_HASH_OP_T prev_op; - uint32_t max_len; - int i; - - if (!se_enabled) { - return HAL_SE_NOT_OPENED; - } - - if (out == NULL) { - return HAL_SE_OUTPUT_NULL; - } - if (out_len & (4 - 1)) { - return HAL_SE_BAD_OUTPUT_LEN; - } - - prev_op = GET_BITFIELD(se_hash->HASH_CTRL, HASH_CTRL_HASH_OP_MODE); - if (prev_op != SE_HASH_OP_FINAL) { - return HAL_SE_BAD_OP; - } - if (se_hash->HASH_STATUS & HASH_STATUS_HASH_BUSY) { - return HAL_SE_ENG_BUSY; - } - if (se_dma->ENBLDCHNS & DMA_STAT_CHAN(SE_DMA_TX_CHAN)) { - return HAL_SE_DMA_BUSY; - } - - max_len = se_hash_get_digest_len(); - if (out_len > max_len) { - out_len = max_len; - } - if (real_len) { - *real_len = out_len; - } - if (out_len > 32) { - for (i = 0; i < out_len / 8; i++) { - read_mreg(&se_hash->HASH_CTX_H[i], out, 4); - read_mreg(&se_hash->HASH_CTX[i], out + 4, 4); - out += 8; - } - } else { - read_mreg(&se_hash->HASH_CTX[0], out, out_len); - } - - return HAL_SE_OK; -} - -int hal_se_hash_busy(void) -{ - if (se_enabled) { - if (se_hash->HASH_STATUS & HASH_STATUS_HASH_BUSY) { - return true; - } - if (se_dma->ENBLDCHNS & DMA_STAT_CHAN(SE_DMA_TX_CHAN)) { - return true; - } - } - return false; -} - -enum HAL_SE_RET_T hal_se_hash_reset(void) -{ - uint32_t lock; - - if (!se_enabled) { - return HAL_SE_NOT_OPENED; - } - - lock = int_lock(); - se_dma_cancel_tx(); - /* Clear all DMA interrupt and error flag */ - se_dma->INTTCCLR = ~0UL; - se_dma->INTERRCLR = ~0UL; - - se_adec->ADEC_CTRL |= ADEC_CTRL_CLK_EN_15_0(SE_ACC_CLK_HASH) | ADEC_CTRL_RST_15_0(SE_ACC_RST_HASH); - se_hash->HASH_STATUS = ~0UL; - se_adec->ADEC_INT = SE_ACC_INT_HASH; - int_unlock(lock); - - return HAL_SE_OK; -} - -enum HAL_SE_RET_T hal_se_hmac_init(enum HAL_SE_HASH_MODE_T mode, const void *key, uint32_t key_len) -{ - if (key_len == 0) { + if (mode == HAL_SE_HASH_SHA384 || mode == HAL_SE_HASH_SHA512) { + if (key_len > 128) { return HAL_SE_BAD_KEY_LEN; + } + } else { + if (key_len > 64) { + return HAL_SE_BAD_KEY_LEN; + } } + } - return se_hash_init(mode, key, key_len); + if (se_hash->HASH_STATUS & HASH_STATUS_HASH_BUSY) { + return HAL_SE_ENG_BUSY; + } + if (se_dma->ENBLDCHNS & DMA_STAT_CHAN(SE_DMA_TX_CHAN)) { + return HAL_SE_DMA_BUSY; + } + + se_adec->ADEC_CTRL |= ADEC_CTRL_CLK_EN_15_0(SE_ACC_CLK_HASH) | + ADEC_CTRL_RST_15_0(SE_ACC_RST_HASH); + se_adec->ADEC_CTRL &= ~ADEC_CTRL_RST_15_0(SE_ACC_RST_HASH); + se_adec->ADEC_INT = SE_ACC_INT_HASH; + se_adec->ADEC_INT_MSK |= SE_ACC_INT_HASH; + + se_dmacfg->DMA_FIFOCLR = DMA_FIFOCLR_TXFIFO_CLR; + + se_acb->ACB_CTRL |= ACB_CTRL_RD_CB_CTRL; + + se_hash->HASH_CFG = HASH_CFG_ALG_SELECT(mode); + val = se_hash->HASH_CTRL; + // val |= HASH_CTRL_RESET; + se_hash->HASH_CTRL = val; + val &= ~(HASH_CTRL_RESET | HASH_CTRL_HW_PADDING); + se_hash->HASH_CTRL = val; + val = SET_BITFIELD(val, HASH_CTRL_HASH_OP_MODE, SE_HASH_OP_INIT); + se_hash->HASH_CTRL = val; + if (hmac) { + se_hash->HASH_CFG |= HASH_CFG_HASH_MODE; + write_mreg(&se_hash->HMAC_KEY[0], key, key_len); + se_hash->HMAC_KEY_LEN = key_len; + } + se_hash->HASH_CMD = HASH_CMD_START; + + // HASH: 500ns; HMAC: 3000ns + while ((se_hash->HASH_STATUS & HASH_STATUS_HASH_DONE) == 0) + ; + + return HAL_SE_OK; } -enum HAL_SE_RET_T hal_se_hmac_update(const struct HAL_SE_HASH_CFG_T *cfg) __attribute__((alias("hal_se_hash_update"))); +enum HAL_SE_RET_T hal_se_hash_init(enum HAL_SE_HASH_MODE_T mode) { + return se_hash_init(mode, NULL, 0); +} -enum HAL_SE_RET_T hal_se_hmac_final(const struct HAL_SE_HASH_CFG_T *cfg, uint64_t total_in_len) __attribute__((alias("hal_se_hash_final"))); +enum HAL_SE_RET_T se_hash_start(const struct HAL_SE_HASH_CFG_T *cfg, + enum SE_HASH_OP_T op, uint64_t total_in_len) { + enum SE_HASH_OP_T prev_op; + uint32_t val; -enum HAL_SE_RET_T hal_se_hmac(enum HAL_SE_HASH_MODE_T mode, const void *key, uint32_t key_len, const struct HAL_SE_HASH_CFG_T *cfg) -{ - enum HAL_SE_RET_T ret; + if (!se_enabled) { + return HAL_SE_NOT_OPENED; + } - ret = hal_se_hmac_init(mode, key, key_len); - if (ret != HAL_SE_OK) { - return ret; + if (cfg == NULL) { + return HAL_SE_CFG_NULL; + } + if (op == SE_HASH_OP_FINAL) { + if (cfg->in == NULL && cfg->in_len) { + return HAL_SE_INPUT_NULL; } - ret = hal_se_hmac_final(cfg, cfg->in_len); + } else { + if (cfg->in == NULL) { + return HAL_SE_INPUT_NULL; + } + if (cfg->in_len == 0) { + return HAL_SE_BAD_INPUT_LEN; + } + if (cfg->in_len & (64 - 1)) { + return HAL_SE_BAD_INPUT_LEN; + } + } + + prev_op = GET_BITFIELD(se_hash->HASH_CTRL, HASH_CTRL_HASH_OP_MODE); + if (prev_op != SE_HASH_OP_INIT && prev_op != SE_HASH_OP_UPDATE) { + return HAL_SE_BAD_OP; + } + if (se_hash->HASH_STATUS & HASH_STATUS_HASH_BUSY) { + return HAL_SE_ENG_BUSY; + } + if (se_dma->ENBLDCHNS & DMA_STAT_CHAN(SE_DMA_TX_CHAN)) { + return HAL_SE_DMA_BUSY; + } + + se_done_hdlr = cfg->done_hdlr; + + se_hash->HASH_STATUS = ~0UL; + se_adec->ADEC_INT = SE_ACC_INT_HASH; + se_adec->ADEC_INT_MSK &= ~SE_ACC_INT_HASH; + + se_dmacfg->DMA_FIFOCLR = DMA_FIFOCLR_TXFIFO_CLR; + + if (cfg->in_len) { + se_dma_enable_tx(cfg->in, cfg->in_len); + } + + val = se_hash->HASH_CTRL; + val = SET_BITFIELD(val, HASH_CTRL_HASH_OP_MODE, op); + if (op == SE_HASH_OP_UPDATE) { + val &= ~HASH_CTRL_HW_PADDING; + } else { + val |= HASH_CTRL_HW_PADDING; + } + se_hash->HASH_CTRL = val; + if (op == SE_HASH_OP_FINAL) { + se_hash->HASH_MSG_SIZE_L = (uint32_t)total_in_len; + se_hash->HASH_MSG_SIZE_H = (uint32_t)(total_in_len >> 32); + } + se_hash->HASH_SEG_SIZE = cfg->in_len; + se_hash->HASH_CMD = HASH_CMD_START; + + return HAL_SE_OK; +} + +enum HAL_SE_RET_T hal_se_hash_update(const struct HAL_SE_HASH_CFG_T *cfg) { + return se_hash_start(cfg, SE_HASH_OP_UPDATE, 0); +} + +enum HAL_SE_RET_T hal_se_hash_final(const struct HAL_SE_HASH_CFG_T *cfg, + uint64_t total_in_len) { + return se_hash_start(cfg, SE_HASH_OP_FINAL, total_in_len); +} + +enum HAL_SE_RET_T hal_se_hash(enum HAL_SE_HASH_MODE_T mode, + const struct HAL_SE_HASH_CFG_T *cfg) { + enum HAL_SE_RET_T ret; + + ret = hal_se_hash_init(mode); + if (ret != HAL_SE_OK) { return ret; + } + ret = hal_se_hash_final(cfg, cfg->in_len); + return ret; } -enum HAL_SE_RET_T hal_se_hmac_get_digest(void *out, uint32_t out_len, uint32_t *real_len) __attribute__((alias("hal_se_hash_get_digest"))); +static uint32_t se_hash_get_digest_len(void) { + enum HAL_SE_HASH_MODE_T mode; + uint32_t max_len; + + mode = GET_BITFIELD(se_hash->HASH_CFG, HASH_CFG_ALG_SELECT); + if (mode == HAL_SE_HASH_MD5) { + max_len = 16; + } else if (mode == HAL_SE_HASH_SHA1) { + max_len = 20; + } else if (mode == HAL_SE_HASH_SHA224) { + max_len = 28; + } else if (mode == HAL_SE_HASH_SHA256) { + max_len = 32; + } else if (mode == HAL_SE_HASH_SHA384) { + max_len = 48; + } else { + max_len = 64; + } + + return max_len; +} + +enum HAL_SE_RET_T hal_se_hash_get_digest(void *out, uint32_t out_len, + uint32_t *real_len) { + enum SE_HASH_OP_T prev_op; + uint32_t max_len; + int i; + + if (!se_enabled) { + return HAL_SE_NOT_OPENED; + } + + if (out == NULL) { + return HAL_SE_OUTPUT_NULL; + } + if (out_len & (4 - 1)) { + return HAL_SE_BAD_OUTPUT_LEN; + } + + prev_op = GET_BITFIELD(se_hash->HASH_CTRL, HASH_CTRL_HASH_OP_MODE); + if (prev_op != SE_HASH_OP_FINAL) { + return HAL_SE_BAD_OP; + } + if (se_hash->HASH_STATUS & HASH_STATUS_HASH_BUSY) { + return HAL_SE_ENG_BUSY; + } + if (se_dma->ENBLDCHNS & DMA_STAT_CHAN(SE_DMA_TX_CHAN)) { + return HAL_SE_DMA_BUSY; + } + + max_len = se_hash_get_digest_len(); + if (out_len > max_len) { + out_len = max_len; + } + if (real_len) { + *real_len = out_len; + } + if (out_len > 32) { + for (i = 0; i < out_len / 8; i++) { + read_mreg(&se_hash->HASH_CTX_H[i], out, 4); + read_mreg(&se_hash->HASH_CTX[i], out + 4, 4); + out += 8; + } + } else { + read_mreg(&se_hash->HASH_CTX[0], out, out_len); + } + + return HAL_SE_OK; +} + +int hal_se_hash_busy(void) { + if (se_enabled) { + if (se_hash->HASH_STATUS & HASH_STATUS_HASH_BUSY) { + return true; + } + if (se_dma->ENBLDCHNS & DMA_STAT_CHAN(SE_DMA_TX_CHAN)) { + return true; + } + } + return false; +} + +enum HAL_SE_RET_T hal_se_hash_reset(void) { + uint32_t lock; + + if (!se_enabled) { + return HAL_SE_NOT_OPENED; + } + + lock = int_lock(); + se_dma_cancel_tx(); + /* Clear all DMA interrupt and error flag */ + se_dma->INTTCCLR = ~0UL; + se_dma->INTERRCLR = ~0UL; + + se_adec->ADEC_CTRL |= ADEC_CTRL_CLK_EN_15_0(SE_ACC_CLK_HASH) | + ADEC_CTRL_RST_15_0(SE_ACC_RST_HASH); + se_hash->HASH_STATUS = ~0UL; + se_adec->ADEC_INT = SE_ACC_INT_HASH; + int_unlock(lock); + + return HAL_SE_OK; +} + +enum HAL_SE_RET_T hal_se_hmac_init(enum HAL_SE_HASH_MODE_T mode, + const void *key, uint32_t key_len) { + if (key_len == 0) { + return HAL_SE_BAD_KEY_LEN; + } + + return se_hash_init(mode, key, key_len); +} + +enum HAL_SE_RET_T hal_se_hmac_update(const struct HAL_SE_HASH_CFG_T *cfg) + __attribute__((alias("hal_se_hash_update"))); + +enum HAL_SE_RET_T hal_se_hmac_final(const struct HAL_SE_HASH_CFG_T *cfg, + uint64_t total_in_len) + __attribute__((alias("hal_se_hash_final"))); + +enum HAL_SE_RET_T hal_se_hmac(enum HAL_SE_HASH_MODE_T mode, const void *key, + uint32_t key_len, + const struct HAL_SE_HASH_CFG_T *cfg) { + enum HAL_SE_RET_T ret; + + ret = hal_se_hmac_init(mode, key, key_len); + if (ret != HAL_SE_OK) { + return ret; + } + ret = hal_se_hmac_final(cfg, cfg->in_len); + return ret; +} + +enum HAL_SE_RET_T hal_se_hmac_get_digest(void *out, uint32_t out_len, + uint32_t *real_len) + __attribute__((alias("hal_se_hash_get_digest"))); int hal_se_hmac_busy(void) __attribute__((alias("hal_se_hash_busy"))); -enum HAL_SE_RET_T hal_se_hmac_reset(void) __attribute__((alias("hal_se_hash_reset"))); +enum HAL_SE_RET_T hal_se_hmac_reset(void) + __attribute__((alias("hal_se_hash_reset"))); #endif #endif - diff --git a/platform/hal/hal_slave_i2c.c b/platform/hal/hal_slave_i2c.c index 64ae1a7..1d5cb83 100644 --- a/platform/hal/hal_slave_i2c.c +++ b/platform/hal/hal_slave_i2c.c @@ -20,54 +20,39 @@ #include "hal_slave_i2c.h" #include "reg_slave_i2c.h" -static struct SLAVE_I2C_T * const slave_i2c = (struct SLAVE_I2C_T *)I2C_SLAVE_BASE; +static struct SLAVE_I2C_T *const slave_i2c = + (struct SLAVE_I2C_T *)I2C_SLAVE_BASE; -void hal_slave_i2c_enable(void) -{ - slave_i2c->EN |= I2C_EN; +void hal_slave_i2c_enable(void) { slave_i2c->EN |= I2C_EN; } + +void hal_slave_i2c_disable(void) { slave_i2c->EN &= ~I2C_EN; } + +uint32_t hal_slave_i2c_get_filter_len(void) { + return GET_BITFIELD(slave_i2c->EN, R_FILTERLEN); } -void hal_slave_i2c_disable(void) -{ - slave_i2c->EN &= ~I2C_EN; +int hal_slave_i2c_set_filter_len(uint32_t len) { + if (len > (W_FILTERLEN_MASK >> W_FILTERLEN_SHIFT)) { + return 1; + } + slave_i2c->EN = SET_BITFIELD(slave_i2c->EN, W_FILTERLEN, len); + return 0; } -uint32_t hal_slave_i2c_get_filter_len(void) -{ - return GET_BITFIELD(slave_i2c->EN, R_FILTERLEN); +uint32_t hal_slave_i2c_get_dev_id(void) { + return GET_BITFIELD(slave_i2c->ID, DEV_ID); } -int hal_slave_i2c_set_filter_len(uint32_t len) -{ - if (len > (W_FILTERLEN_MASK >> W_FILTERLEN_SHIFT)) { - return 1; - } - slave_i2c->EN = SET_BITFIELD(slave_i2c->EN, W_FILTERLEN, len); - return 0; +int hal_slave_i2c_set_dev_id(uint32_t dev_id) { + if (dev_id > 0x7F) { + return 1; + } + slave_i2c->ID = SET_BITFIELD(slave_i2c->ID, DEV_ID, dev_id); + return 0; } -uint32_t hal_slave_i2c_get_dev_id(void) -{ - return GET_BITFIELD(slave_i2c->ID, DEV_ID); -} +void hal_slave_i2c_bypass_timeout(void) { slave_i2c->TBP |= TIMEOUT_BYPASS; } -int hal_slave_i2c_set_dev_id(uint32_t dev_id) -{ - if (dev_id > 0x7F) { - return 1; - } - slave_i2c->ID = SET_BITFIELD(slave_i2c->ID, DEV_ID, dev_id); - return 0; -} - -void hal_slave_i2c_bypass_timeout(void) -{ - slave_i2c->TBP |= TIMEOUT_BYPASS; -} - -void hal_slave_i2c_restore_timeout(void) -{ - slave_i2c->TBP &= ~TIMEOUT_BYPASS; -} +void hal_slave_i2c_restore_timeout(void) { slave_i2c->TBP &= ~TIMEOUT_BYPASS; } #endif diff --git a/platform/hal/hal_sleep.c b/platform/hal/hal_sleep.c index 335b31b..bcd6a4a 100644 --- a/platform/hal/hal_sleep.c +++ b/platform/hal/hal_sleep.c @@ -14,22 +14,23 @@ * ****************************************************************************/ #include "hal_sleep.h" -#include "hal_cmu.h" -#include "hal_location.h" -#include "hal_trace.h" -#include "hal_timer.h" -#include "hal_sysfreq.h" -#include "hal_dma.h" -#include "hal_norflash.h" -#include "hal_gpadc.h" #include "analog.h" -#include "pmu.h" #include "cmsis.h" +#include "hal_cmu.h" +#include "hal_dma.h" +#include "hal_gpadc.h" +#include "hal_location.h" +#include "hal_norflash.h" +#include "hal_sysfreq.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "pmu.h" -//static uint8_t SRAM_STACK_LOC sleep_stack[128]; +// static uint8_t SRAM_STACK_LOC sleep_stack[128]; static HAL_SLEEP_HOOK_HANDLER sleep_hook_handler[HAL_SLEEP_HOOK_USER_QTY]; -static HAL_DEEP_SLEEP_HOOK_HANDLER deep_sleep_hook_handler[HAL_DEEP_SLEEP_HOOK_USER_QTY]; +static HAL_DEEP_SLEEP_HOOK_HANDLER + deep_sleep_hook_handler[HAL_DEEP_SLEEP_HOOK_USER_QTY]; static uint32_t cpu_wake_lock_map; static uint32_t sys_wake_lock_map; @@ -50,133 +51,128 @@ static uint8_t light_sleep_ratio; static uint8_t sys_deep_sleep_ratio; static uint8_t chip_deep_sleep_ratio; -void hal_sleep_start_stats(uint32_t stats_interval_ms, uint32_t trace_interval_ms) -{ - uint32_t lock; +void hal_sleep_start_stats(uint32_t stats_interval_ms, + uint32_t trace_interval_ms) { + uint32_t lock; - lock = int_lock(); - if (stats_interval_ms) { - stats_interval = MS_TO_TICKS(stats_interval_ms); - stats_start_time = hal_sys_timer_get(); - light_sleep_time = 0; - sys_deep_sleep_time = 0; - chip_deep_sleep_time = 0; - stats_valid = false; - stats_started = true; - } else { - stats_started = false; - } - int_unlock(lock); + lock = int_lock(); + if (stats_interval_ms) { + stats_interval = MS_TO_TICKS(stats_interval_ms); + stats_start_time = hal_sys_timer_get(); + light_sleep_time = 0; + sys_deep_sleep_time = 0; + chip_deep_sleep_time = 0; + stats_valid = false; + stats_started = true; + } else { + stats_started = false; + } + int_unlock(lock); #ifdef SLEEP_STATS_TRACE - if (stats_interval_ms && trace_interval_ms) { - stats_trace_interval = MS_TO_TICKS(trace_interval_ms); - } else { - stats_trace_interval = 0; - } + if (stats_interval_ms && trace_interval_ms) { + stats_trace_interval = MS_TO_TICKS(trace_interval_ms); + } else { + stats_trace_interval = 0; + } #endif } -int hal_sleep_get_stats(struct CPU_USAGE_T *usage) -{ - int ret; - uint32_t lock; +int hal_sleep_get_stats(struct CPU_USAGE_T *usage) { + int ret; + uint32_t lock; - lock = int_lock(); - if (stats_valid) { - usage->light_sleep = light_sleep_ratio; - usage->sys_deep_sleep = sys_deep_sleep_ratio; - usage->chip_deep_sleep = chip_deep_sleep_ratio; - usage->busy = 100 - (light_sleep_ratio + sys_deep_sleep_ratio + chip_deep_sleep_ratio); - ret = 0; - } else { - ret = 1; - } - int_unlock(lock); + lock = int_lock(); + if (stats_valid) { + usage->light_sleep = light_sleep_ratio; + usage->sys_deep_sleep = sys_deep_sleep_ratio; + usage->chip_deep_sleep = chip_deep_sleep_ratio; + usage->busy = 100 - (light_sleep_ratio + sys_deep_sleep_ratio + + chip_deep_sleep_ratio); + ret = 0; + } else { + ret = 1; + } + int_unlock(lock); - return ret; + return ret; } -static int hal_sleep_cpu_busy(void) -{ - if (cpu_wake_lock_map || hal_cmu_lpu_busy()) { - return 1; - } else { - return 0; - } -} - -static int hal_sleep_sys_busy(void) -{ - if (sys_wake_lock_map || hal_sysfreq_busy() || hal_dma_busy()) { - return 1; - } else { - return 0; - } -} - -int hal_sleep_set_sleep_hook(enum HAL_SLEEP_HOOK_USER_T user, HAL_SLEEP_HOOK_HANDLER handler) -{ - if (user >= ARRAY_SIZE(sleep_hook_handler)) { - return 1; - } - sleep_hook_handler[user] = handler; +static int hal_sleep_cpu_busy(void) { + if (cpu_wake_lock_map || hal_cmu_lpu_busy()) { + return 1; + } else { return 0; + } } -static int SRAM_TEXT_LOC hal_sleep_exec_sleep_hook(void) -{ - int i; - int ret; - - for (i = 0; i < ARRAY_SIZE(sleep_hook_handler); i++) { - if (sleep_hook_handler[i]) { - ret = sleep_hook_handler[i](); - if (ret) { - return ret; - } - } - } - +static int hal_sleep_sys_busy(void) { + if (sys_wake_lock_map || hal_sysfreq_busy() || hal_dma_busy()) { + return 1; + } else { return 0; + } } -int hal_sleep_set_deep_sleep_hook(enum HAL_DEEP_SLEEP_HOOK_USER_T user, HAL_DEEP_SLEEP_HOOK_HANDLER handler) -{ - if (user >= ARRAY_SIZE(deep_sleep_hook_handler)) { - return 1; +int hal_sleep_set_sleep_hook(enum HAL_SLEEP_HOOK_USER_T user, + HAL_SLEEP_HOOK_HANDLER handler) { + if (user >= ARRAY_SIZE(sleep_hook_handler)) { + return 1; + } + sleep_hook_handler[user] = handler; + return 0; +} + +static int SRAM_TEXT_LOC hal_sleep_exec_sleep_hook(void) { + int i; + int ret; + + for (i = 0; i < ARRAY_SIZE(sleep_hook_handler); i++) { + if (sleep_hook_handler[i]) { + ret = sleep_hook_handler[i](); + if (ret) { + return ret; + } } - deep_sleep_hook_handler[user] = handler; - return 0; + } + + return 0; } -static int SRAM_TEXT_LOC hal_sleep_exec_deep_sleep_hook(void) -{ - int i; - int ret; +int hal_sleep_set_deep_sleep_hook(enum HAL_DEEP_SLEEP_HOOK_USER_T user, + HAL_DEEP_SLEEP_HOOK_HANDLER handler) { + if (user >= ARRAY_SIZE(deep_sleep_hook_handler)) { + return 1; + } + deep_sleep_hook_handler[user] = handler; + return 0; +} - for (i = 0; i < ARRAY_SIZE(deep_sleep_hook_handler); i++) { - if (deep_sleep_hook_handler[i]) { - ret = deep_sleep_hook_handler[i](); - if (ret) { - return ret; - } - } +static int SRAM_TEXT_LOC hal_sleep_exec_deep_sleep_hook(void) { + int i; + int ret; + + for (i = 0; i < ARRAY_SIZE(deep_sleep_hook_handler); i++) { + if (deep_sleep_hook_handler[i]) { + ret = deep_sleep_hook_handler[i](); + if (ret) { + return ret; + } } + } - return 0; + return 0; } -int SRAM_TEXT_LOC hal_sleep_irq_pending(void) -{ +int SRAM_TEXT_LOC hal_sleep_irq_pending(void) { #if defined(__GIC_PRESENT) && (__GIC_PRESENT) - int i; + int i; - for (i = 0; i < (USER_IRQn_QTY + 31) / 32; i++) { - if (GICDistributor->ICPENDR[i] & GICDistributor->ISENABLER[i]) { - return 1; - } + for (i = 0; i < (USER_IRQn_QTY + 31) / 32; i++) { + if (GICDistributor->ICPENDR[i] & GICDistributor->ISENABLER[i]) { + return 1; } + } #else #if 0 int i; @@ -187,401 +183,392 @@ int SRAM_TEXT_LOC hal_sleep_irq_pending(void) } } #else - // If there is any pending and enabled exception (including sysTick) - if (SCB->ICSR & SCB_ICSR_VECTPENDING_Msk) { - return 1; - } + // If there is any pending and enabled exception (including sysTick) + if (SCB->ICSR & SCB_ICSR_VECTPENDING_Msk) { + return 1; + } #endif #endif - return 0; + return 0; } -int SRAM_TEXT_LOC hal_sleep_specific_irq_pending(const uint32_t *irq, uint32_t cnt) -{ - int i; - uint32_t check_cnt; +int SRAM_TEXT_LOC hal_sleep_specific_irq_pending(const uint32_t *irq, + uint32_t cnt) { + int i; + uint32_t check_cnt; - check_cnt = (USER_IRQn_QTY + 31) / 32; - if (check_cnt > cnt) { - check_cnt = cnt; - } + check_cnt = (USER_IRQn_QTY + 31) / 32; + if (check_cnt > cnt) { + check_cnt = cnt; + } #if defined(__GIC_PRESENT) && (__GIC_PRESENT) - for (i = 0; i < check_cnt; i++) { - if (GICDistributor->ICPENDR[i] & GICDistributor->ISENABLER[i] & irq[i]) { - return 1; - } + for (i = 0; i < check_cnt; i++) { + if (GICDistributor->ICPENDR[i] & GICDistributor->ISENABLER[i] & irq[i]) { + return 1; } + } #else - for (i = 0; i < check_cnt; i++) { - if (NVIC->ICPR[i] & NVIC->ISER[i] & irq[i]) { - return 1; - } + for (i = 0; i < check_cnt; i++) { + if (NVIC->ICPR[i] & NVIC->ISER[i] & irq[i]) { + return 1; } + } #endif - return 0; + return 0; } -void WEAK bt_drv_sleep(void) -{ -} +void WEAK bt_drv_sleep(void) {} -void WEAK bt_drv_wakeup(void) -{ -} +void WEAK bt_drv_wakeup(void) {} -static enum HAL_SLEEP_STATUS_T SRAM_TEXT_LOC hal_sleep_lowpower_mode(void) -{ - enum HAL_SLEEP_STATUS_T ret; - enum HAL_CMU_LPU_SLEEP_MODE_T mode; - uint32_t time = 0; +static enum HAL_SLEEP_STATUS_T SRAM_TEXT_LOC hal_sleep_lowpower_mode(void) { + enum HAL_SLEEP_STATUS_T ret; + enum HAL_CMU_LPU_SLEEP_MODE_T mode; + uint32_t time = 0; - ret = HAL_SLEEP_STATUS_LIGHT; - - // Deep sleep hook - if (hal_sleep_exec_deep_sleep_hook() || hal_trace_busy()) { - return ret; - } - - if (stats_started) { - time = hal_sys_timer_get(); - } - - // Modules (except for psram and flash) sleep - hal_gpadc_sleep(); - if (chip_wake_lock_map == 0) { - analog_sleep(); - pmu_sleep(); - } - bt_drv_sleep(); - - // End of sleep - - //psram_sleep(); - hal_norflash_sleep(HAL_NORFLASH_ID_0); - - // Now neither psram nor flash are usable - - if (!hal_sleep_irq_pending()) { - if (chip_wake_lock_map) { - mode = HAL_CMU_LPU_SLEEP_MODE_SYS; - } else { - mode = HAL_CMU_LPU_SLEEP_MODE_CHIP; - } - hal_cmu_lpu_sleep(mode); - ret = HAL_SLEEP_STATUS_DEEP; - } - - hal_norflash_wakeup(HAL_NORFLASH_ID_0); - //psram_wakeup(); - - // Now both psram and flash are usable - - if (chip_wake_lock_map == 0) { - pmu_wakeup(); - analog_wakeup(); - } - bt_drv_wakeup(); - - hal_gpadc_wakeup(); - // Modules (except for psram and flash) wakeup - - // End of wakeup - - if (stats_started) { - time = hal_sys_timer_get() - time; - if (chip_wake_lock_map) { - sys_deep_sleep_time += time; - } else { - chip_deep_sleep_time += time; - } - } + ret = HAL_SLEEP_STATUS_LIGHT; + // Deep sleep hook + if (hal_sleep_exec_deep_sleep_hook() || hal_trace_busy()) { return ret; + } + + if (stats_started) { + time = hal_sys_timer_get(); + } + + // Modules (except for psram and flash) sleep + hal_gpadc_sleep(); + if (chip_wake_lock_map == 0) { + analog_sleep(); + pmu_sleep(); + } + bt_drv_sleep(); + + // End of sleep + + // psram_sleep(); + hal_norflash_sleep(HAL_NORFLASH_ID_0); + + // Now neither psram nor flash are usable + + if (!hal_sleep_irq_pending()) { + if (chip_wake_lock_map) { + mode = HAL_CMU_LPU_SLEEP_MODE_SYS; + } else { + mode = HAL_CMU_LPU_SLEEP_MODE_CHIP; + } + hal_cmu_lpu_sleep(mode); + ret = HAL_SLEEP_STATUS_DEEP; + } + + hal_norflash_wakeup(HAL_NORFLASH_ID_0); + // psram_wakeup(); + + // Now both psram and flash are usable + + if (chip_wake_lock_map == 0) { + pmu_wakeup(); + analog_wakeup(); + } + bt_drv_wakeup(); + + hal_gpadc_wakeup(); + // Modules (except for psram and flash) wakeup + + // End of wakeup + + if (stats_started) { + time = hal_sys_timer_get() - time; + if (chip_wake_lock_map) { + sys_deep_sleep_time += time; + } else { + chip_deep_sleep_time += time; + } + } + + return ret; } -// GCC has trouble in detecting static function usage in embedded ASM statements. -// The following function might be optimized away if there is no explicted call in C codes. -// Specifying "used" (or "noclone") attribute on the function can avoid the mistaken optimization. -static enum HAL_SLEEP_STATUS_T SRAM_TEXT_LOC NOINLINE USED hal_sleep_proc(int light_sleep) -{ - enum HAL_SLEEP_STATUS_T ret; - uint32_t time = 0; - uint32_t interval; +// GCC has trouble in detecting static function usage in embedded ASM +// statements. The following function might be optimized away if there is no +// explicted call in C codes. Specifying "used" (or "noclone") attribute on the +// function can avoid the mistaken optimization. +static enum HAL_SLEEP_STATUS_T SRAM_TEXT_LOC NOINLINE USED +hal_sleep_proc(int light_sleep) { + enum HAL_SLEEP_STATUS_T ret; + uint32_t time = 0; + uint32_t interval; - ret = HAL_SLEEP_STATUS_LIGHT; + ret = HAL_SLEEP_STATUS_LIGHT; - // Check the sleep conditions in interrupt-locked context - if (hal_sleep_cpu_busy()) { - // Cannot sleep - } else { - // Sleep hook - if (hal_sleep_exec_sleep_hook()) { - goto _exit_sleep; - } + // Check the sleep conditions in interrupt-locked context + if (hal_sleep_cpu_busy()) { + // Cannot sleep + } else { + // Sleep hook + if (hal_sleep_exec_sleep_hook()) { + goto _exit_sleep; + } - if (hal_sleep_sys_busy()) { - // Light sleep + if (hal_sleep_sys_busy()) { + // Light sleep - if (stats_started) { - time = hal_sys_timer_get(); - } + if (stats_started) { + time = hal_sys_timer_get(); + } #ifdef NO_LIGHT_SLEEP - // WFI during USB ISO transfer might generate very weak (0.1 mV) 1K tone interference ??? - while (!hal_sleep_irq_pending()); + // WFI during USB ISO transfer might generate very weak (0.1 mV) 1K tone + // interference ??? + while (!hal_sleep_irq_pending()) + ; #else #ifndef __ARM_ARCH_ISA_ARM - SCB->SCR = 0; + SCB->SCR = 0; #endif - __DSB(); - __WFI(); + __DSB(); + __WFI(); #endif - if (stats_started) { - light_sleep_time += hal_sys_timer_get() - time; - } + if (stats_started) { + light_sleep_time += hal_sys_timer_get() - time; + } #ifdef DEBUG - } else if (hal_trace_busy()) { - // Light sleep with trace busy only + } else if (hal_trace_busy()) { + // Light sleep with trace busy only - if (stats_started) { - time = hal_sys_timer_get(); - } + if (stats_started) { + time = hal_sys_timer_get(); + } - // No irq will be generated when trace becomes idle, so the trace status should - // be kept polling actively instead of entering WFI - while (!hal_sleep_irq_pending() && hal_trace_busy()); + // No irq will be generated when trace becomes idle, so the trace status + // should be kept polling actively instead of entering WFI + while (!hal_sleep_irq_pending() && hal_trace_busy()) + ; - if (stats_started) { - light_sleep_time += hal_sys_timer_get() - time; - } + if (stats_started) { + light_sleep_time += hal_sys_timer_get() - time; + } - if (!hal_sleep_irq_pending()) { - goto _deep_sleep; - } + if (!hal_sleep_irq_pending()) { + goto _deep_sleep; + } #endif - } else { - // Deep sleep + } else { + // Deep sleep -_deep_sleep: POSSIBLY_UNUSED; + _deep_sleep: + POSSIBLY_UNUSED; - if (light_sleep) { - ret = HAL_SLEEP_STATUS_DEEP; - } else { - ret = hal_sleep_lowpower_mode(); - } - } + if (light_sleep) { + ret = HAL_SLEEP_STATUS_DEEP; + } else { + ret = hal_sleep_lowpower_mode(); + } } + } _exit_sleep: - if (stats_started) { - time = hal_sys_timer_get(); - interval = time - stats_start_time; - if (interval >= stats_interval) { - if (light_sleep_time > UINT32_MAX / 100) { - light_sleep_ratio = (uint64_t)light_sleep_time * 100 / interval; - } else { - light_sleep_ratio = light_sleep_time * 100 / interval; - } - if (sys_deep_sleep_time > UINT32_MAX / 100) { - sys_deep_sleep_ratio = (uint64_t)sys_deep_sleep_time * 100 / interval; - } else { - sys_deep_sleep_ratio = sys_deep_sleep_time * 100 / interval; - } - if (chip_deep_sleep_time > UINT32_MAX / 100) { - chip_deep_sleep_ratio = (uint64_t)chip_deep_sleep_time * 100 / interval; - } else { - chip_deep_sleep_ratio = chip_deep_sleep_time * 100 / interval; - } - stats_valid = true; - light_sleep_time = 0; - sys_deep_sleep_time = 0; - chip_deep_sleep_time = 0; - stats_start_time = time; - } -#ifdef SLEEP_STATS_TRACE - if (stats_valid && stats_trace_interval) { - uint32_t time = hal_sys_timer_get(); - if (time - stats_trace_time >= stats_trace_interval) { - TRACE(4,"CPU USAGE: busy=%d light=%d sys_deep=%d chip_deep=%d", - 100 - (light_sleep_ratio + sys_deep_sleep_ratio + chip_deep_sleep_ratio), - light_sleep_ratio, sys_deep_sleep_ratio, chip_deep_sleep_ratio); - stats_trace_time = time; -#ifdef DEBUG_SLEEP_USER - TRACE(4,"SLEEP_USER: cpulock=0x%X syslock=0x%X irq=0x%08X_%08X", - cpu_wake_lock_map, sys_wake_lock_map, (NVIC->ICPR[1] & NVIC->ISER[1]), (NVIC->ICPR[0] & NVIC->ISER[0])); - hal_sysfreq_print(); -#endif - } - } -#endif + if (stats_started) { + time = hal_sys_timer_get(); + interval = time - stats_start_time; + if (interval >= stats_interval) { + if (light_sleep_time > UINT32_MAX / 100) { + light_sleep_ratio = (uint64_t)light_sleep_time * 100 / interval; + } else { + light_sleep_ratio = light_sleep_time * 100 / interval; + } + if (sys_deep_sleep_time > UINT32_MAX / 100) { + sys_deep_sleep_ratio = (uint64_t)sys_deep_sleep_time * 100 / interval; + } else { + sys_deep_sleep_ratio = sys_deep_sleep_time * 100 / interval; + } + if (chip_deep_sleep_time > UINT32_MAX / 100) { + chip_deep_sleep_ratio = (uint64_t)chip_deep_sleep_time * 100 / interval; + } else { + chip_deep_sleep_ratio = chip_deep_sleep_time * 100 / interval; + } + stats_valid = true; + light_sleep_time = 0; + sys_deep_sleep_time = 0; + chip_deep_sleep_time = 0; + stats_start_time = time; } +#ifdef SLEEP_STATS_TRACE + if (stats_valid && stats_trace_interval) { + uint32_t time = hal_sys_timer_get(); + if (time - stats_trace_time >= stats_trace_interval) { + TRACE(4, "CPU USAGE: busy=%d light=%d sys_deep=%d chip_deep=%d", + 100 - (light_sleep_ratio + sys_deep_sleep_ratio + + chip_deep_sleep_ratio), + light_sleep_ratio, sys_deep_sleep_ratio, chip_deep_sleep_ratio); + stats_trace_time = time; +#ifdef DEBUG_SLEEP_USER + TRACE(4, "SLEEP_USER: cpulock=0x%X syslock=0x%X irq=0x%08X_%08X", + cpu_wake_lock_map, sys_wake_lock_map, + (NVIC->ICPR[1] & NVIC->ISER[1]), (NVIC->ICPR[0] & NVIC->ISER[0])); + hal_sysfreq_print(); +#endif + } + } +#endif + } - return ret; + return ret; } #ifndef __ARM_ARCH_ISA_ARM -static enum HAL_SLEEP_STATUS_T SRAM_TEXT_LOC NOINLINE USED NAKED hal_sleep_deep_sleep_wrapper(void) -{ - asm volatile( - "push {r4, lr} \n" - // Switch current stack pointer to MSP - "mrs r4, control \n" - "bic r4, #2 \n" - "msr control, r4 \n" - "isb \n" - "movs r0, #0 \n" - "bl hal_sleep_proc \n" - // Switch current stack pointer back to PSP - "orr r4, #2 \n" - "msr control, r4 \n" - "isb \n" - "pop {r4, pc} \n" - ); +static enum HAL_SLEEP_STATUS_T SRAM_TEXT_LOC NOINLINE USED NAKED +hal_sleep_deep_sleep_wrapper(void) { + asm volatile("push {r4, lr} \n" + // Switch current stack pointer to MSP + "mrs r4, control \n" + "bic r4, #2 \n" + "msr control, r4 \n" + "isb \n" + "movs r0, #0 \n" + "bl hal_sleep_proc \n" + // Switch current stack pointer back to PSP + "orr r4, #2 \n" + "msr control, r4 \n" + "isb \n" + "pop {r4, pc} \n"); #ifndef __ARMCC_VERSION - return HAL_SLEEP_STATUS_LIGHT; + return HAL_SLEEP_STATUS_LIGHT; #endif } #endif -enum HAL_SLEEP_STATUS_T SRAM_TEXT_LOC hal_sleep_enter_sleep(void) -{ - enum HAL_SLEEP_STATUS_T ret; - uint32_t lock; +enum HAL_SLEEP_STATUS_T SRAM_TEXT_LOC hal_sleep_enter_sleep(void) { + enum HAL_SLEEP_STATUS_T ret; + uint32_t lock; - ret = HAL_SLEEP_STATUS_LIGHT; + ret = HAL_SLEEP_STATUS_LIGHT; #ifdef NO_SLEEP - return ret; + return ret; #endif - lock = int_lock_global(); + lock = int_lock_global(); #ifndef __ARM_ARCH_ISA_ARM - if (__get_CONTROL() & 0x02) { - ret = hal_sleep_deep_sleep_wrapper(); - } else + if (__get_CONTROL() & 0x02) { + ret = hal_sleep_deep_sleep_wrapper(); + } else #endif - { - ret = hal_sleep_proc(false); - } + { + ret = hal_sleep_proc(false); + } - int_unlock_global(lock); + int_unlock_global(lock); - return ret; + return ret; } -enum HAL_SLEEP_STATUS_T SRAM_TEXT_LOC hal_sleep_light_sleep(void) -{ - enum HAL_SLEEP_STATUS_T ret; - uint32_t lock; +enum HAL_SLEEP_STATUS_T SRAM_TEXT_LOC hal_sleep_light_sleep(void) { + enum HAL_SLEEP_STATUS_T ret; + uint32_t lock; - ret = HAL_SLEEP_STATUS_LIGHT; + ret = HAL_SLEEP_STATUS_LIGHT; #ifdef NO_SLEEP - return ret; + return ret; #endif - lock = int_lock_global(); + lock = int_lock_global(); - ret = hal_sleep_proc(true); + ret = hal_sleep_proc(true); - int_unlock_global(lock); + int_unlock_global(lock); - return ret; + return ret; } -int hal_cpu_wake_lock(enum HAL_CPU_WAKE_LOCK_USER_T user) -{ - uint32_t lock; +int hal_cpu_wake_lock(enum HAL_CPU_WAKE_LOCK_USER_T user) { + uint32_t lock; - if (user >= HAL_CPU_WAKE_LOCK_USER_QTY) { - return 1; - } + if (user >= HAL_CPU_WAKE_LOCK_USER_QTY) { + return 1; + } - lock = int_lock(); - cpu_wake_lock_map |= (1 << user); - int_unlock(lock); + lock = int_lock(); + cpu_wake_lock_map |= (1 << user); + int_unlock(lock); - return 0; + return 0; } -int hal_cpu_wake_unlock(enum HAL_CPU_WAKE_LOCK_USER_T user) -{ - uint32_t lock; +int hal_cpu_wake_unlock(enum HAL_CPU_WAKE_LOCK_USER_T user) { + uint32_t lock; - if (user >= HAL_CPU_WAKE_LOCK_USER_QTY) { - return 1; - } + if (user >= HAL_CPU_WAKE_LOCK_USER_QTY) { + return 1; + } - lock = int_lock(); - cpu_wake_lock_map &= ~(1 << user); - int_unlock(lock); + lock = int_lock(); + cpu_wake_lock_map &= ~(1 << user); + int_unlock(lock); - return 0; + return 0; } -int hal_sys_wake_lock(enum HAL_SYS_WAKE_LOCK_USER_T user) -{ - uint32_t lock; +int hal_sys_wake_lock(enum HAL_SYS_WAKE_LOCK_USER_T user) { + uint32_t lock; - if (user >= HAL_SYS_WAKE_LOCK_USER_QTY) { - return 1; - } + if (user >= HAL_SYS_WAKE_LOCK_USER_QTY) { + return 1; + } - lock = int_lock(); - sys_wake_lock_map |= (1 << user); - int_unlock(lock); + lock = int_lock(); + sys_wake_lock_map |= (1 << user); + int_unlock(lock); - return 0; + return 0; } -int hal_sys_wake_unlock(enum HAL_SYS_WAKE_LOCK_USER_T user) -{ - uint32_t lock; +int hal_sys_wake_unlock(enum HAL_SYS_WAKE_LOCK_USER_T user) { + uint32_t lock; - if (user >= HAL_SYS_WAKE_LOCK_USER_QTY) { - return 1; - } + if (user >= HAL_SYS_WAKE_LOCK_USER_QTY) { + return 1; + } - lock = int_lock(); - sys_wake_lock_map &= ~(1 << user); - int_unlock(lock); + lock = int_lock(); + sys_wake_lock_map &= ~(1 << user); + int_unlock(lock); - return 0; + return 0; } -int hal_chip_wake_lock(enum HAL_CHIP_WAKE_LOCK_USER_T user) -{ - uint32_t lock; +int hal_chip_wake_lock(enum HAL_CHIP_WAKE_LOCK_USER_T user) { + uint32_t lock; - if (user >= HAL_CHIP_WAKE_LOCK_USER_QTY) { - return 1; - } + if (user >= HAL_CHIP_WAKE_LOCK_USER_QTY) { + return 1; + } - lock = int_lock(); - chip_wake_lock_map |= (1 << user); - int_unlock(lock); + lock = int_lock(); + chip_wake_lock_map |= (1 << user); + int_unlock(lock); - return 0; + return 0; } -int hal_chip_wake_unlock(enum HAL_CHIP_WAKE_LOCK_USER_T user) -{ - uint32_t lock; +int hal_chip_wake_unlock(enum HAL_CHIP_WAKE_LOCK_USER_T user) { + uint32_t lock; - if (user >= HAL_CHIP_WAKE_LOCK_USER_QTY) { - return 1; - } + if (user >= HAL_CHIP_WAKE_LOCK_USER_QTY) { + return 1; + } - lock = int_lock(); - chip_wake_lock_map &= ~(1 << user); - int_unlock(lock); + lock = int_lock(); + chip_wake_lock_map &= ~(1 << user); + int_unlock(lock); - return 0; + return 0; } - diff --git a/platform/hal/hal_spdif.c b/platform/hal/hal_spdif.c index 8f4ea6b..a8c3012 100644 --- a/platform/hal/hal_spdif.c +++ b/platform/hal/hal_spdif.c @@ -15,16 +15,16 @@ ****************************************************************************/ #ifdef CHIP_HAS_SPDIF -#include "plat_types.h" -#include "plat_addr_map.h" -#include "reg_spdifip.h" -#include "hal_spdifip.h" #include "hal_spdif.h" -#include "hal_iomux.h" -#include "hal_timer.h" -#include "hal_trace.h" #include "analog.h" #include "cmsis.h" +#include "hal_iomux.h" +#include "hal_spdifip.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "plat_addr_map.h" +#include "plat_types.h" +#include "reg_spdifip.h" //#define SPDIF_CLOCK_SOURCE 240000000 //#define SPDIF_CLOCK_SOURCE 22579200 @@ -35,28 +35,28 @@ //#define SPDIF_CLOCK_SOURCE 84672000 // Trigger DMA request when TX-FIFO count <= threshold -#define HAL_SPDIF_TX_FIFO_TRIGGER_LEVEL (SPDIFIP_FIFO_DEPTH/2) +#define HAL_SPDIF_TX_FIFO_TRIGGER_LEVEL (SPDIFIP_FIFO_DEPTH / 2) // Trigger DMA request when RX-FIFO count >= threshold -#define HAL_SPDIF_RX_FIFO_TRIGGER_LEVEL (SPDIFIP_FIFO_DEPTH/2) +#define HAL_SPDIF_RX_FIFO_TRIGGER_LEVEL (SPDIFIP_FIFO_DEPTH / 2) #define HAL_SPDIF_YES 1 #define HAL_SPDIF_NO 0 #ifdef CHIP_BEST2000 -#define SPDIF_CMU_DIV CODEC_CMU_DIV +#define SPDIF_CMU_DIV CODEC_CMU_DIV #else -#define SPDIF_CMU_DIV CODEC_PLL_DIV +#define SPDIF_CMU_DIV CODEC_PLL_DIV #endif enum HAL_SPDIF_STATUS_T { - HAL_SPDIF_STATUS_NULL, - HAL_SPDIF_STATUS_OPENED, - HAL_SPDIF_STATUS_STARTED, + HAL_SPDIF_STATUS_NULL, + HAL_SPDIF_STATUS_OPENED, + HAL_SPDIF_STATUS_STARTED, }; struct HAL_SPDIF_MOD_NAME_T { - enum HAL_CMU_MOD_ID_T mod; - enum HAL_CMU_MOD_ID_T apb; + enum HAL_CMU_MOD_ID_T mod; + enum HAL_CMU_MOD_ID_T apb; }; struct HAL_SPDIF_MOD_NAME_T spdif_mod[HAL_SPDIF_ID_QTY] = { @@ -72,32 +72,43 @@ struct HAL_SPDIF_MOD_NAME_T spdif_mod[HAL_SPDIF_ID_QTY] = { #endif }; -static const char * const invalid_id = "Invalid SPDIF ID: %d\n"; -//static const char * const invalid_ch = "Invalid SPDIF CH: %d\n"; +static const char *const invalid_id = "Invalid SPDIF ID: %d\n"; +// static const char * const invalid_ch = "Invalid SPDIF CH: %d\n"; struct SPDIF_SAMPLE_RATE_T { - enum AUD_SAMPRATE_T sample_rate; - uint32_t codec_freq; - uint8_t codec_div; - uint8_t pcm_div; - uint8_t tx_ratio; + enum AUD_SAMPRATE_T sample_rate; + uint32_t codec_freq; + uint8_t codec_div; + uint8_t pcm_div; + uint8_t tx_ratio; }; // SAMPLE_RATE * 128 = PLL_nominal / PCM_DIV / TX_RATIO -static const struct SPDIF_SAMPLE_RATE_T spdif_sample_rate[]={ +static const struct SPDIF_SAMPLE_RATE_T spdif_sample_rate[] = { #if defined(CHIP_BEST1000) && defined(AUD_PLL_DOUBLE) - {AUD_SAMPRATE_96000, CODEC_FREQ_48K_SERIES*2, CODEC_PLL_DIV, SPDIF_CMU_DIV, 4}, - {AUD_SAMPRATE_192000, CODEC_FREQ_48K_SERIES*2, CODEC_PLL_DIV, SPDIF_CMU_DIV, 2}, - {AUD_SAMPRATE_384000, CODEC_FREQ_48K_SERIES*2, CODEC_PLL_DIV, SPDIF_CMU_DIV, 1}, + {AUD_SAMPRATE_96000, CODEC_FREQ_48K_SERIES * 2, CODEC_PLL_DIV, + SPDIF_CMU_DIV, 4}, + {AUD_SAMPRATE_192000, CODEC_FREQ_48K_SERIES * 2, CODEC_PLL_DIV, + SPDIF_CMU_DIV, 2}, + {AUD_SAMPRATE_384000, CODEC_FREQ_48K_SERIES * 2, CODEC_PLL_DIV, + SPDIF_CMU_DIV, 1}, #else - {AUD_SAMPRATE_8000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, SPDIF_CMU_DIV, 24}, - {AUD_SAMPRATE_16000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, SPDIF_CMU_DIV, 12}, - {AUD_SAMPRATE_22050, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, SPDIF_CMU_DIV, 8}, - {AUD_SAMPRATE_24000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, SPDIF_CMU_DIV, 8}, - {AUD_SAMPRATE_44100, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, SPDIF_CMU_DIV, 4}, - {AUD_SAMPRATE_48000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, SPDIF_CMU_DIV, 4}, - {AUD_SAMPRATE_96000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, SPDIF_CMU_DIV, 2}, - {AUD_SAMPRATE_192000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, SPDIF_CMU_DIV, 1}, + {AUD_SAMPRATE_8000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, SPDIF_CMU_DIV, + 24}, + {AUD_SAMPRATE_16000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, SPDIF_CMU_DIV, + 12}, + {AUD_SAMPRATE_22050, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, SPDIF_CMU_DIV, + 8}, + {AUD_SAMPRATE_24000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, SPDIF_CMU_DIV, + 8}, + {AUD_SAMPRATE_44100, CODEC_FREQ_44_1K_SERIES, CODEC_PLL_DIV, SPDIF_CMU_DIV, + 4}, + {AUD_SAMPRATE_48000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, SPDIF_CMU_DIV, + 4}, + {AUD_SAMPRATE_96000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, SPDIF_CMU_DIV, + 2}, + {AUD_SAMPRATE_192000, CODEC_FREQ_48K_SERIES, CODEC_PLL_DIV, SPDIF_CMU_DIV, + 1}, #endif }; @@ -109,304 +120,306 @@ STATIC_ASSERT(HAL_SPDIF_ID_QTY <= sizeof(spdif_map) * 8, "Too many SPDIF IDs"); static enum HAL_SPDIF_STATUS_T spdif_status[HAL_SPDIF_ID_QTY][AUD_STREAM_NUM]; static bool spdif_dma[HAL_SPDIF_ID_QTY][AUD_STREAM_NUM]; -static inline uint32_t _spdif_get_reg_base(enum HAL_SPDIF_ID_T id) -{ - ASSERT(id < HAL_SPDIF_ID_QTY, invalid_id, id); +static inline uint32_t _spdif_get_reg_base(enum HAL_SPDIF_ID_T id) { + ASSERT(id < HAL_SPDIF_ID_QTY, invalid_id, id); - switch(id) { - case HAL_SPDIF_ID_0: - default: - return SPDIF0_BASE; - break; + switch (id) { + case HAL_SPDIF_ID_0: + default: + return SPDIF0_BASE; + break; #if (CHIP_HAS_SPDIF > 1) - case HAL_SPDIF_ID_1: - return SPDIF1_BASE; - break; + case HAL_SPDIF_ID_1: + return SPDIF1_BASE; + break; #endif - } - return 0; + } + return 0; } -int hal_spdif_open(enum HAL_SPDIF_ID_T id, enum AUD_STREAM_T stream) -{ - uint32_t reg_base; +int hal_spdif_open(enum HAL_SPDIF_ID_T id, enum AUD_STREAM_T stream) { + uint32_t reg_base; - reg_base = _spdif_get_reg_base(id); + reg_base = _spdif_get_reg_base(id); - if (spdif_status[id][stream] != HAL_SPDIF_STATUS_NULL) { - TRACE(2,"Invalid SPDIF opening status for stream %d: %d", stream, spdif_status[id][stream]); - return 1; - } + if (spdif_status[id][stream] != HAL_SPDIF_STATUS_NULL) { + TRACE(2, "Invalid SPDIF opening status for stream %d: %d", stream, + spdif_status[id][stream]); + return 1; + } - if (spdif_status[id][AUD_STREAM_PLAYBACK] == HAL_SPDIF_STATUS_NULL && - spdif_status[id][AUD_STREAM_CAPTURE] == HAL_SPDIF_STATUS_NULL) { + if (spdif_status[id][AUD_STREAM_PLAYBACK] == HAL_SPDIF_STATUS_NULL && + spdif_status[id][AUD_STREAM_CAPTURE] == HAL_SPDIF_STATUS_NULL) { #ifndef SIMU - bool cfg_pll = true; - int i; + bool cfg_pll = true; + int i; - for (i = HAL_SPDIF_ID_0; i < HAL_SPDIF_ID_QTY; i++) { - if (spdif_status[i][AUD_STREAM_PLAYBACK] != HAL_SPDIF_STATUS_NULL || - spdif_status[i][AUD_STREAM_CAPTURE] != HAL_SPDIF_STATUS_NULL) { - cfg_pll = false; - break; - } - } - if (cfg_pll) { - analog_aud_pll_open(ANA_AUD_PLL_USER_SPDIF); - } + for (i = HAL_SPDIF_ID_0; i < HAL_SPDIF_ID_QTY; i++) { + if (spdif_status[i][AUD_STREAM_PLAYBACK] != HAL_SPDIF_STATUS_NULL || + spdif_status[i][AUD_STREAM_CAPTURE] != HAL_SPDIF_STATUS_NULL) { + cfg_pll = false; + break; + } + } + if (cfg_pll) { + analog_aud_pll_open(ANA_AUD_PLL_USER_SPDIF); + } #endif #if (CHIP_HAS_SPDIF > 1) - if (id == HAL_SPDIF_ID_1) { - hal_iomux_set_spdif1(); - } else + if (id == HAL_SPDIF_ID_1) { + hal_iomux_set_spdif1(); + } else #endif - { - hal_iomux_set_spdif0(); - } - hal_cmu_spdif_clock_enable(id); - hal_cmu_clock_enable(spdif_mod[id].mod); - hal_cmu_clock_enable(spdif_mod[id].apb); - hal_cmu_reset_clear(spdif_mod[id].mod); - hal_cmu_reset_clear(spdif_mod[id].apb); - - spdifip_w_enable_spdifip(reg_base, HAL_SPDIF_YES); - } - - spdif_dma[id][stream] = false; - spdif_status[id][stream] = HAL_SPDIF_STATUS_OPENED; - - return 0; -} - -int hal_spdif_close(enum HAL_SPDIF_ID_T id, enum AUD_STREAM_T stream) -{ - uint32_t reg_base; - - if (id >= HAL_SPDIF_ID_QTY) { - return 1; - } - - if (spdif_status[id][stream] != HAL_SPDIF_STATUS_OPENED) { - TRACE(2,"Invalid SPDIF closing status for stream %d: %d", stream, spdif_status[id][stream]); - return 1; - } - - spdif_status[id][stream] = HAL_SPDIF_STATUS_NULL; - - if (spdif_status[id][AUD_STREAM_PLAYBACK] == HAL_SPDIF_STATUS_NULL && - spdif_status[id][AUD_STREAM_CAPTURE] == HAL_SPDIF_STATUS_NULL) { - reg_base = _spdif_get_reg_base(id); - - spdifip_w_enable_spdifip(reg_base, HAL_SPDIF_NO); - - hal_cmu_spdif_set_div(id, 0x1FFF + 2); - hal_cmu_reset_set(spdif_mod[id].apb); - hal_cmu_reset_set(spdif_mod[id].mod); - hal_cmu_clock_disable(spdif_mod[id].apb); - hal_cmu_clock_disable(spdif_mod[id].mod); - hal_cmu_spdif_clock_disable(id); - -#ifndef SIMU - bool cfg_pll = true; - int i; - - for (i = HAL_SPDIF_ID_0; i < HAL_SPDIF_ID_QTY; i++) { - if (spdif_status[i][AUD_STREAM_PLAYBACK] != HAL_SPDIF_STATUS_NULL || - spdif_status[i][AUD_STREAM_CAPTURE] != HAL_SPDIF_STATUS_NULL) { - cfg_pll = false; - break; - } - } - if (cfg_pll) { - analog_aud_pll_close(ANA_AUD_PLL_USER_SPDIF); - } -#endif - } - - return 0; -} - -int hal_spdif_start_stream(enum HAL_SPDIF_ID_T id, enum AUD_STREAM_T stream) -{ - uint32_t reg_base; - uint32_t lock; - - reg_base = _spdif_get_reg_base(id); - - if (spdif_status[id][stream] != HAL_SPDIF_STATUS_OPENED) { - TRACE(2,"Invalid SPDIF starting status for stream %d: %d", stream, spdif_status[id][stream]); - return 1; - } - - if (stream == AUD_STREAM_PLAYBACK) { - lock = int_lock(); - spdifip_w_enable_tx_channel0(reg_base, HAL_SPDIF_YES); - spdifip_w_enable_tx(reg_base, HAL_SPDIF_YES); - spdifip_w_tx_valid(reg_base, HAL_SPDIF_YES); - if (spdif_dma[id][stream]) { - spdifip_w_enable_tx_dma(reg_base, HAL_SPDIF_YES); - } - int_unlock(lock); - } else { - if (spdif_dma[id][stream]) { - spdifip_w_enable_rx_dma(reg_base, HAL_SPDIF_YES); - } - spdifip_w_enable_rx_channel0(reg_base, HAL_SPDIF_YES); - spdifip_w_enable_rx(reg_base, HAL_SPDIF_YES); - spdifip_w_sample_en(reg_base, HAL_SPDIF_YES); - } - - spdif_status[id][stream] = HAL_SPDIF_STATUS_STARTED; - - return 0; -} - -int hal_spdif_stop_stream(enum HAL_SPDIF_ID_T id, enum AUD_STREAM_T stream) -{ - uint32_t reg_base; - - reg_base = _spdif_get_reg_base(id); - - if (spdif_status[id][stream] != HAL_SPDIF_STATUS_STARTED) { - TRACE(2,"Invalid SPDIF stopping status for stream %d: %d", stream, spdif_status[id][stream]); - return 1; - } - - spdif_status[id][stream] = HAL_SPDIF_STATUS_OPENED; - - if (stream == AUD_STREAM_PLAYBACK) { - spdifip_w_enable_tx(reg_base, HAL_SPDIF_NO); - spdifip_w_enable_tx_channel0(reg_base, HAL_SPDIF_NO); - spdifip_w_enable_tx_dma(reg_base, HAL_SPDIF_NO); - spdifip_w_tx_fifo_reset(reg_base); - } else { - spdifip_w_enable_rx(reg_base, HAL_SPDIF_NO); - spdifip_w_enable_rx_channel0(reg_base, HAL_SPDIF_NO); - spdifip_w_enable_rx_dma(reg_base, HAL_SPDIF_NO); - spdifip_w_rx_fifo_reset(reg_base); - } - - return 0; -} - -int hal_spdif_setup_stream(enum HAL_SPDIF_ID_T id, enum AUD_STREAM_T stream, struct HAL_SPDIF_CONFIG_T *cfg) -{ - uint8_t i; - uint32_t reg_base; - uint8_t fmt; - - reg_base = _spdif_get_reg_base(id); - - if (spdif_status[id][stream] != HAL_SPDIF_STATUS_OPENED) { - TRACE(2,"Invalid SPDIF setup status for stream %d: %d", stream, spdif_status[id][stream]); - return 1; - } - - for (i = 0; i < ARRAY_SIZE(spdif_sample_rate); i++) { - if (spdif_sample_rate[i].sample_rate == cfg->sample_rate) - { - break; - } + hal_iomux_set_spdif0(); } - ASSERT(i < ARRAY_SIZE(spdif_sample_rate), "%s: Invalid spdif sample rate: %d", __func__, cfg->sample_rate); + hal_cmu_spdif_clock_enable(id); + hal_cmu_clock_enable(spdif_mod[id].mod); + hal_cmu_clock_enable(spdif_mod[id].apb); + hal_cmu_reset_clear(spdif_mod[id].mod); + hal_cmu_reset_clear(spdif_mod[id].apb); - TRACE(3,"[%s] stream=%d sample_rate=%d", __func__, stream, cfg->sample_rate); + spdifip_w_enable_spdifip(reg_base, HAL_SPDIF_YES); + } -#ifdef FPGA - hal_cmu_spdif_set_div(id, 2); -#else -#ifndef SIMU - analog_aud_freq_pll_config(spdif_sample_rate[i].codec_freq, spdif_sample_rate[i].codec_div); -#ifdef CHIP_BEST2000 - analog_aud_pll_set_dig_div(spdif_sample_rate[i].codec_div / spdif_sample_rate[i].pcm_div); -#endif -#endif - // SPDIF module is working on 24.576M or 22.5792M - hal_cmu_spdif_set_div(id, spdif_sample_rate[i].pcm_div); -#endif + spdif_dma[id][stream] = false; + spdif_status[id][stream] = HAL_SPDIF_STATUS_OPENED; - if ((stream == AUD_STREAM_PLAYBACK && spdif_status[id][AUD_STREAM_CAPTURE] == HAL_SPDIF_STATUS_NULL) || - (stream == AUD_STREAM_CAPTURE && spdif_status[id][AUD_STREAM_PLAYBACK] == HAL_SPDIF_STATUS_NULL)) { - hal_cmu_reset_pulse(spdif_mod[id].mod); - } - - spdif_dma[id][stream] = cfg->use_dma; - - fmt = 0; - switch (cfg->bits) { - case AUD_BITS_16: - fmt = 0; - break; - // here, 32-bit is treated as 24-bit - case AUD_BITS_32: - case AUD_BITS_24: - fmt = 8; - break; - default: - ASSERT(0, "%s: invalid bits[%d]", __func__, cfg->bits); - } - - if (stream == AUD_STREAM_PLAYBACK) { - spdifip_w_tx_ratio(reg_base, spdif_sample_rate[i].tx_ratio - 1); - spdifip_w_tx_format_cfg_reg(reg_base, fmt); - spdifip_w_tx_fifo_threshold(reg_base, HAL_SPDIF_TX_FIFO_TRIGGER_LEVEL); - } else { - spdifip_w_rx_format_cfg_reg(reg_base, fmt); - spdifip_w_rx_fifo_threshold(reg_base, HAL_SPDIF_RX_FIFO_TRIGGER_LEVEL); - } - - return 0; + return 0; } -int hal_spdif_send(enum HAL_SPDIF_ID_T id, uint8_t *value, uint32_t value_len) -{ - uint32_t i = 0; - uint32_t reg_base; +int hal_spdif_close(enum HAL_SPDIF_ID_T id, enum AUD_STREAM_T stream) { + uint32_t reg_base; + if (id >= HAL_SPDIF_ID_QTY) { + return 1; + } + + if (spdif_status[id][stream] != HAL_SPDIF_STATUS_OPENED) { + TRACE(2, "Invalid SPDIF closing status for stream %d: %d", stream, + spdif_status[id][stream]); + return 1; + } + + spdif_status[id][stream] = HAL_SPDIF_STATUS_NULL; + + if (spdif_status[id][AUD_STREAM_PLAYBACK] == HAL_SPDIF_STATUS_NULL && + spdif_status[id][AUD_STREAM_CAPTURE] == HAL_SPDIF_STATUS_NULL) { reg_base = _spdif_get_reg_base(id); - for (i = 0; i < value_len; i += 4) { - while (!(spdifip_r_int_status(reg_base) & SPDIFIP_INT_STATUS_TX_FIFO_EMPTY_MASK)); - - spdifip_w_tx_left_fifo(reg_base, value[i+1]<<8 | value[i]); - spdifip_w_tx_right_fifo(reg_base, value[i+3]<<8 | value[i+2]); - } - - return 0; -} - -uint8_t hal_spdif_recv(enum HAL_SPDIF_ID_T id, uint8_t *value, uint32_t value_len) -{ - //uint32_t reg_base; - - //reg_base = _spdif_get_reg_base(id); - return 0; -} - -int hal_spdif_clock_out_enable(enum HAL_SPDIF_ID_T id, uint32_t div) -{ - if (id >= HAL_SPDIF_ID_QTY) { - return 1; - } - - hal_cmu_spdif_clock_enable(id); - hal_cmu_spdif_set_div(id, div); - - return 0; -} - -int hal_spdif_clock_out_disable(enum HAL_SPDIF_ID_T id) -{ - if (id >= HAL_SPDIF_ID_QTY) { - return 1; - } + spdifip_w_enable_spdifip(reg_base, HAL_SPDIF_NO); hal_cmu_spdif_set_div(id, 0x1FFF + 2); + hal_cmu_reset_set(spdif_mod[id].apb); + hal_cmu_reset_set(spdif_mod[id].mod); + hal_cmu_clock_disable(spdif_mod[id].apb); + hal_cmu_clock_disable(spdif_mod[id].mod); hal_cmu_spdif_clock_disable(id); - return 0; +#ifndef SIMU + bool cfg_pll = true; + int i; + + for (i = HAL_SPDIF_ID_0; i < HAL_SPDIF_ID_QTY; i++) { + if (spdif_status[i][AUD_STREAM_PLAYBACK] != HAL_SPDIF_STATUS_NULL || + spdif_status[i][AUD_STREAM_CAPTURE] != HAL_SPDIF_STATUS_NULL) { + cfg_pll = false; + break; + } + } + if (cfg_pll) { + analog_aud_pll_close(ANA_AUD_PLL_USER_SPDIF); + } +#endif + } + + return 0; +} + +int hal_spdif_start_stream(enum HAL_SPDIF_ID_T id, enum AUD_STREAM_T stream) { + uint32_t reg_base; + uint32_t lock; + + reg_base = _spdif_get_reg_base(id); + + if (spdif_status[id][stream] != HAL_SPDIF_STATUS_OPENED) { + TRACE(2, "Invalid SPDIF starting status for stream %d: %d", stream, + spdif_status[id][stream]); + return 1; + } + + if (stream == AUD_STREAM_PLAYBACK) { + lock = int_lock(); + spdifip_w_enable_tx_channel0(reg_base, HAL_SPDIF_YES); + spdifip_w_enable_tx(reg_base, HAL_SPDIF_YES); + spdifip_w_tx_valid(reg_base, HAL_SPDIF_YES); + if (spdif_dma[id][stream]) { + spdifip_w_enable_tx_dma(reg_base, HAL_SPDIF_YES); + } + int_unlock(lock); + } else { + if (spdif_dma[id][stream]) { + spdifip_w_enable_rx_dma(reg_base, HAL_SPDIF_YES); + } + spdifip_w_enable_rx_channel0(reg_base, HAL_SPDIF_YES); + spdifip_w_enable_rx(reg_base, HAL_SPDIF_YES); + spdifip_w_sample_en(reg_base, HAL_SPDIF_YES); + } + + spdif_status[id][stream] = HAL_SPDIF_STATUS_STARTED; + + return 0; +} + +int hal_spdif_stop_stream(enum HAL_SPDIF_ID_T id, enum AUD_STREAM_T stream) { + uint32_t reg_base; + + reg_base = _spdif_get_reg_base(id); + + if (spdif_status[id][stream] != HAL_SPDIF_STATUS_STARTED) { + TRACE(2, "Invalid SPDIF stopping status for stream %d: %d", stream, + spdif_status[id][stream]); + return 1; + } + + spdif_status[id][stream] = HAL_SPDIF_STATUS_OPENED; + + if (stream == AUD_STREAM_PLAYBACK) { + spdifip_w_enable_tx(reg_base, HAL_SPDIF_NO); + spdifip_w_enable_tx_channel0(reg_base, HAL_SPDIF_NO); + spdifip_w_enable_tx_dma(reg_base, HAL_SPDIF_NO); + spdifip_w_tx_fifo_reset(reg_base); + } else { + spdifip_w_enable_rx(reg_base, HAL_SPDIF_NO); + spdifip_w_enable_rx_channel0(reg_base, HAL_SPDIF_NO); + spdifip_w_enable_rx_dma(reg_base, HAL_SPDIF_NO); + spdifip_w_rx_fifo_reset(reg_base); + } + + return 0; +} + +int hal_spdif_setup_stream(enum HAL_SPDIF_ID_T id, enum AUD_STREAM_T stream, + struct HAL_SPDIF_CONFIG_T *cfg) { + uint8_t i; + uint32_t reg_base; + uint8_t fmt; + + reg_base = _spdif_get_reg_base(id); + + if (spdif_status[id][stream] != HAL_SPDIF_STATUS_OPENED) { + TRACE(2, "Invalid SPDIF setup status for stream %d: %d", stream, + spdif_status[id][stream]); + return 1; + } + + for (i = 0; i < ARRAY_SIZE(spdif_sample_rate); i++) { + if (spdif_sample_rate[i].sample_rate == cfg->sample_rate) { + break; + } + } + ASSERT(i < ARRAY_SIZE(spdif_sample_rate), "%s: Invalid spdif sample rate: %d", + __func__, cfg->sample_rate); + + TRACE(3, "[%s] stream=%d sample_rate=%d", __func__, stream, cfg->sample_rate); + +#ifdef FPGA + hal_cmu_spdif_set_div(id, 2); +#else +#ifndef SIMU + analog_aud_freq_pll_config(spdif_sample_rate[i].codec_freq, + spdif_sample_rate[i].codec_div); +#ifdef CHIP_BEST2000 + analog_aud_pll_set_dig_div(spdif_sample_rate[i].codec_div / + spdif_sample_rate[i].pcm_div); +#endif +#endif + // SPDIF module is working on 24.576M or 22.5792M + hal_cmu_spdif_set_div(id, spdif_sample_rate[i].pcm_div); +#endif + + if ((stream == AUD_STREAM_PLAYBACK && + spdif_status[id][AUD_STREAM_CAPTURE] == HAL_SPDIF_STATUS_NULL) || + (stream == AUD_STREAM_CAPTURE && + spdif_status[id][AUD_STREAM_PLAYBACK] == HAL_SPDIF_STATUS_NULL)) { + hal_cmu_reset_pulse(spdif_mod[id].mod); + } + + spdif_dma[id][stream] = cfg->use_dma; + + fmt = 0; + switch (cfg->bits) { + case AUD_BITS_16: + fmt = 0; + break; + // here, 32-bit is treated as 24-bit + case AUD_BITS_32: + case AUD_BITS_24: + fmt = 8; + break; + default: + ASSERT(0, "%s: invalid bits[%d]", __func__, cfg->bits); + } + + if (stream == AUD_STREAM_PLAYBACK) { + spdifip_w_tx_ratio(reg_base, spdif_sample_rate[i].tx_ratio - 1); + spdifip_w_tx_format_cfg_reg(reg_base, fmt); + spdifip_w_tx_fifo_threshold(reg_base, HAL_SPDIF_TX_FIFO_TRIGGER_LEVEL); + } else { + spdifip_w_rx_format_cfg_reg(reg_base, fmt); + spdifip_w_rx_fifo_threshold(reg_base, HAL_SPDIF_RX_FIFO_TRIGGER_LEVEL); + } + + return 0; +} + +int hal_spdif_send(enum HAL_SPDIF_ID_T id, uint8_t *value, uint32_t value_len) { + uint32_t i = 0; + uint32_t reg_base; + + reg_base = _spdif_get_reg_base(id); + + for (i = 0; i < value_len; i += 4) { + while (!(spdifip_r_int_status(reg_base) & + SPDIFIP_INT_STATUS_TX_FIFO_EMPTY_MASK)) + ; + + spdifip_w_tx_left_fifo(reg_base, value[i + 1] << 8 | value[i]); + spdifip_w_tx_right_fifo(reg_base, value[i + 3] << 8 | value[i + 2]); + } + + return 0; +} + +uint8_t hal_spdif_recv(enum HAL_SPDIF_ID_T id, uint8_t *value, + uint32_t value_len) { + // uint32_t reg_base; + + // reg_base = _spdif_get_reg_base(id); + return 0; +} + +int hal_spdif_clock_out_enable(enum HAL_SPDIF_ID_T id, uint32_t div) { + if (id >= HAL_SPDIF_ID_QTY) { + return 1; + } + + hal_cmu_spdif_clock_enable(id); + hal_cmu_spdif_set_div(id, div); + + return 0; +} + +int hal_spdif_clock_out_disable(enum HAL_SPDIF_ID_T id) { + if (id >= HAL_SPDIF_ID_QTY) { + return 1; + } + + hal_cmu_spdif_set_div(id, 0x1FFF + 2); + hal_cmu_spdif_clock_disable(id); + + return 0; } #endif diff --git a/platform/hal/hal_spi.c b/platform/hal/hal_spi.c index 1e2cc76..b8d5a99 100644 --- a/platform/hal/hal_spi.c +++ b/platform/hal/hal_spi.c @@ -13,13 +13,13 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_addr_map.h" +#include "hal_spi.h" #include "cmsis.h" #include "hal_cmu.h" #include "hal_dma.h" #include "hal_location.h" -#include "hal_spi.h" #include "hal_trace.h" +#include "plat_addr_map.h" #include "reg_spi.h" #include "string.h" @@ -27,58 +27,58 @@ // 1) Add transfer timeout control #ifdef SPI_ROM_ONLY -#define SPI_ASSERT(c, ...) ASSERT_NODUMP(c) +#define SPI_ASSERT(c, ...) ASSERT_NODUMP(c) #else -#define SPI_ASSERT(c, ...) ASSERT(c, ##__VA_ARGS__) +#define SPI_ASSERT(c, ...) ASSERT(c, ##__VA_ARGS__) #endif enum HAL_SPI_ID_T { - HAL_SPI_ID_INTERNAL, + HAL_SPI_ID_INTERNAL, #ifdef CHIP_HAS_SPI - HAL_SPI_ID_0, + HAL_SPI_ID_0, #endif #ifdef CHIP_HAS_SPILCD - HAL_SPI_ID_SLCD, + HAL_SPI_ID_SLCD, #endif #ifdef CHIP_HAS_SPIPHY - HAL_SPI_ID_PHY, + HAL_SPI_ID_PHY, #endif #ifdef CHIP_HAS_SPIDPD - HAL_SPI_ID_DPD, + HAL_SPI_ID_DPD, #endif - HAL_SPI_ID_QTY + HAL_SPI_ID_QTY }; enum HAL_SPI_CS_T { - HAL_SPI_CS_0, + HAL_SPI_CS_0, #if (CHIP_SPI_VER >= 2) - HAL_SPI_CS_1, - HAL_SPI_CS_2, + HAL_SPI_CS_1, + HAL_SPI_CS_2, #if (CHIP_SPI_VER >= 3) - HAL_SPI_CS_3, + HAL_SPI_CS_3, #if (CHIP_SPI_VER >= 4) - //HAL_SPI_CS_4, +// HAL_SPI_CS_4, #endif #endif #endif - HAL_SPI_CS_QTY + HAL_SPI_CS_QTY }; enum HAL_SPI_XFER_TYPE_T { - HAL_SPI_XFER_TYPE_SEND, - HAL_SPI_XFER_TYPE_RECV, + HAL_SPI_XFER_TYPE_SEND, + HAL_SPI_XFER_TYPE_RECV, - HAL_SPI_XFER_TYPE_QTY + HAL_SPI_XFER_TYPE_QTY }; struct HAL_SPI_MOD_NAME_T { - enum HAL_CMU_MOD_ID_T mod; - enum HAL_CMU_MOD_ID_T apb; + enum HAL_CMU_MOD_ID_T mod; + enum HAL_CMU_MOD_ID_T apb; }; -static struct SPI_T * const spi[HAL_SPI_ID_QTY] = { +static struct SPI_T *const spi[HAL_SPI_ID_QTY] = { (struct SPI_T *)ISPI_BASE, #ifdef CHIP_HAS_SPI (struct SPI_T *)SPI_BASE, @@ -147,9 +147,12 @@ static struct HAL_SPI_CTRL_T spidpd_ctrl; #endif static uint8_t BOOT_BSS_LOC spi_cs_map[HAL_SPI_ID_QTY]; -STATIC_ASSERT(sizeof(spi_cs_map[0]) * 8 >= HAL_SPI_CS_QTY, "spi_cs_map size too small"); +STATIC_ASSERT(sizeof(spi_cs_map[0]) * 8 >= HAL_SPI_CS_QTY, + "spi_cs_map size too small"); -static bool BOOT_BSS_LOC in_use[HAL_SPI_ID_QTY] = { false, }; +static bool BOOT_BSS_LOC in_use[HAL_SPI_ID_QTY] = { + false, +}; static HAL_SPI_DMA_HANDLER_T BOOT_BSS_LOC spi_txdma_handler[HAL_SPI_ID_QTY]; static HAL_SPI_DMA_HANDLER_T BOOT_BSS_LOC spi_rxdma_handler[HAL_SPI_ID_QTY]; @@ -163,450 +166,460 @@ static bool BOOT_BSS_LOC spi_init_done = false; static int hal_spi_activate_cs_id(enum HAL_SPI_ID_T id, uint32_t cs); #endif -//static const char *invalid_id = "Invalid SPI ID: %d"; +// static const char *invalid_id = "Invalid SPI ID: %d"; -static inline uint8_t get_frame_bytes(enum HAL_SPI_ID_T id) -{ - uint8_t bits, cnt; +static inline uint8_t get_frame_bytes(enum HAL_SPI_ID_T id) { + uint8_t bits, cnt; - bits = GET_BITFIELD(spi[id]->SSPCR0, SPI_SSPCR0_DSS) + 1; - if (bits <= 8) { - cnt = 1; - } else if (bits <= 16) { - cnt = 2; - } else { - cnt = 4; - } + bits = GET_BITFIELD(spi[id]->SSPCR0, SPI_SSPCR0_DSS) + 1; + if (bits <= 8) { + cnt = 1; + } else if (bits <= 16) { + cnt = 2; + } else { + cnt = 4; + } - return cnt; + return cnt; } -static inline void copy_frame_from_bytes(uint32_t *val, const uint8_t *data, uint8_t cnt) -{ +static inline void copy_frame_from_bytes(uint32_t *val, const uint8_t *data, + uint8_t cnt) { #ifdef UNALIGNED_ACCESS - if (cnt == 1) { - *val = *(const uint8_t *)data; - } else if (cnt == 2) { - *val = *(const uint16_t *)data; - } else { - *val = *(const uint32_t *)data; - } + if (cnt == 1) { + *val = *(const uint8_t *)data; + } else if (cnt == 2) { + *val = *(const uint16_t *)data; + } else { + *val = *(const uint32_t *)data; + } #else - if (cnt == 1) { - *val = data[0]; - } else if (cnt == 2) { - *val = data[0] | (data[1] << 8); - } else { - *val = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); - } + if (cnt == 1) { + *val = data[0]; + } else if (cnt == 2) { + *val = data[0] | (data[1] << 8); + } else { + *val = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); + } #endif } -static inline void copy_bytes_from_frame(uint8_t *data, uint32_t val, uint8_t cnt) -{ +static inline void copy_bytes_from_frame(uint8_t *data, uint32_t val, + uint8_t cnt) { #ifdef UNALIGNED_ACCESS - if (cnt == 1) { - *(uint8_t *)data = (uint8_t)val; - } else if (cnt == 2) { - *(uint16_t *)data = (uint16_t)val; - } else { - *(uint32_t *)data = (uint32_t)val; - } + if (cnt == 1) { + *(uint8_t *)data = (uint8_t)val; + } else if (cnt == 2) { + *(uint16_t *)data = (uint16_t)val; + } else { + *(uint32_t *)data = (uint32_t)val; + } #else - data[0] = (uint8_t)val; - if (cnt == 1) { - return; - } else if (cnt == 2) { - data[1] = (uint8_t)(val >> 8); - } else { - data[1] = (uint8_t)(val >> 8); - data[2] = (uint8_t)(val >> 16); - data[3] = (uint8_t)(val >> 24); - } + data[0] = (uint8_t)val; + if (cnt == 1) { + return; + } else if (cnt == 2) { + data[1] = (uint8_t)(val >> 8); + } else { + data[1] = (uint8_t)(val >> 8); + data[2] = (uint8_t)(val >> 16); + data[3] = (uint8_t)(val >> 24); + } #endif } -int hal_spi_init_ctrl(const struct HAL_SPI_CFG_T *cfg, struct HAL_SPI_CTRL_T *ctrl) -{ - uint32_t div; - uint16_t cpsdvsr, scr; - uint32_t mod_clk; +int hal_spi_init_ctrl(const struct HAL_SPI_CFG_T *cfg, + struct HAL_SPI_CTRL_T *ctrl) { + uint32_t div; + uint16_t cpsdvsr, scr; + uint32_t mod_clk; #ifdef SPI_ROM_ONLY - // Assume default crystal -- Never access global versatile data to ensure reentrance - mod_clk = HAL_CMU_DEFAULT_CRYSTAL_FREQ; + // Assume default crystal -- Never access global versatile data to ensure + // reentrance + mod_clk = HAL_CMU_DEFAULT_CRYSTAL_FREQ; #else // !SPI_ROM_ONLY - mod_clk = 0; + mod_clk = 0; #ifdef PERIPH_PLL_FREQ - if (PERIPH_PLL_FREQ / 2 > 2 * hal_cmu_get_crystal_freq()) { - // Init to OSC_X2 - mod_clk = 2 * hal_cmu_get_crystal_freq(); - if (cfg->rate * 2 > mod_clk) { - mod_clk = PERIPH_PLL_FREQ / 2; - ctrl->clk_sel = HAL_SPI_MOD_CLK_SEL_PLL; - } else { - mod_clk = 0; - } + if (PERIPH_PLL_FREQ / 2 > 2 * hal_cmu_get_crystal_freq()) { + // Init to OSC_X2 + mod_clk = 2 * hal_cmu_get_crystal_freq(); + if (cfg->rate * 2 > mod_clk) { + mod_clk = PERIPH_PLL_FREQ / 2; + ctrl->clk_sel = HAL_SPI_MOD_CLK_SEL_PLL; + } else { + mod_clk = 0; } + } #endif - if (mod_clk == 0) { - // Init to OSC - mod_clk = hal_cmu_get_crystal_freq(); - if (cfg->rate * 2 > mod_clk) { - mod_clk *= 2; - ctrl->clk_sel = HAL_SPI_MOD_CLK_SEL_OSC_X2; - } else { - ctrl->clk_sel = HAL_SPI_MOD_CLK_SEL_OSC; - } + if (mod_clk == 0) { + // Init to OSC + mod_clk = hal_cmu_get_crystal_freq(); + if (cfg->rate * 2 > mod_clk) { + mod_clk *= 2; + ctrl->clk_sel = HAL_SPI_MOD_CLK_SEL_OSC_X2; + } else { + ctrl->clk_sel = HAL_SPI_MOD_CLK_SEL_OSC; } + } #endif // !SPI_ROM_ONLY - SPI_ASSERT(cfg->rate <= mod_clk / (MIN_CPSDVSR * (1 + MIN_SCR)), "SPI rate too large: %u", cfg->rate); - SPI_ASSERT(cfg->rate >= mod_clk / (MAX_CPSDVSR * (1 + MAX_SCR)), "SPI rate too small: %u", cfg->rate); - SPI_ASSERT(cfg->tx_bits <= MAX_DATA_BITS && cfg->tx_bits >= MIN_DATA_BITS, "Invalid SPI TX bits: %d", cfg->tx_bits); - SPI_ASSERT(cfg->rx_bits <= MAX_DATA_BITS && cfg->rx_bits >= MIN_DATA_BITS, "Invalid SPI RX bits: %d", cfg->rx_bits); - SPI_ASSERT(cfg->rx_frame_bits <= MAX_DATA_BITS && (cfg->rx_frame_bits == 0 || cfg->rx_frame_bits > cfg->rx_bits), - "Invalid SPI RX FRAME bits: %d", cfg->rx_frame_bits); - SPI_ASSERT(cfg->cs < HAL_SPI_CS_QTY, "SPI cs bad: %d", cfg->cs); + SPI_ASSERT(cfg->rate <= mod_clk / (MIN_CPSDVSR * (1 + MIN_SCR)), + "SPI rate too large: %u", cfg->rate); + SPI_ASSERT(cfg->rate >= mod_clk / (MAX_CPSDVSR * (1 + MAX_SCR)), + "SPI rate too small: %u", cfg->rate); + SPI_ASSERT(cfg->tx_bits <= MAX_DATA_BITS && cfg->tx_bits >= MIN_DATA_BITS, + "Invalid SPI TX bits: %d", cfg->tx_bits); + SPI_ASSERT(cfg->rx_bits <= MAX_DATA_BITS && cfg->rx_bits >= MIN_DATA_BITS, + "Invalid SPI RX bits: %d", cfg->rx_bits); + SPI_ASSERT(cfg->rx_frame_bits <= MAX_DATA_BITS && + (cfg->rx_frame_bits == 0 || cfg->rx_frame_bits > cfg->rx_bits), + "Invalid SPI RX FRAME bits: %d", cfg->rx_frame_bits); + SPI_ASSERT(cfg->cs < HAL_SPI_CS_QTY, "SPI cs bad: %d", cfg->cs); - div = (mod_clk + cfg->rate - 1) / cfg->rate; - cpsdvsr = (div + MAX_SCR) / (MAX_SCR + 1); - if (cpsdvsr < 2) { - cpsdvsr = 2; - } else { - if (cpsdvsr & 0x1) { - cpsdvsr += 1; - } - if (cpsdvsr > MAX_CPSDVSR) { - cpsdvsr = MAX_CPSDVSR; - } + div = (mod_clk + cfg->rate - 1) / cfg->rate; + cpsdvsr = (div + MAX_SCR) / (MAX_SCR + 1); + if (cpsdvsr < 2) { + cpsdvsr = 2; + } else { + if (cpsdvsr & 0x1) { + cpsdvsr += 1; } - scr = (div + cpsdvsr - 1) / cpsdvsr; - if (scr > 0) { - scr -= 1; - } - if (scr > MAX_SCR) { - scr = MAX_SCR; + if (cpsdvsr > MAX_CPSDVSR) { + cpsdvsr = MAX_CPSDVSR; } + } + scr = (div + cpsdvsr - 1) / cpsdvsr; + if (scr > 0) { + scr -= 1; + } + if (scr > MAX_SCR) { + scr = MAX_SCR; + } - ctrl->sspcr0_tx = SPI_SSPCR0_SCR(scr) | - (cfg->clk_delay_half ? SPI_SSPCR0_SPH : 0) | - (cfg->clk_polarity ? SPI_SSPCR0_SPO : 0) | - SPI_SSPCR0_FRF(0) | // Only support Motorola SPI frame format - SPI_SSPCR0_DSS(cfg->tx_bits - 1); - ctrl->sspcr1 = (cfg->rx_sep_line ? SPI_RX_SEL_EN : 0) | - SPI_SLAVE_ID(cfg->cs) | - SPI_SSPCR1_SOD | - (cfg->slave ? SPI_SSPCR1_MS : 0) | - SPI_SSPCR1_SSE; - ctrl->sspcpsr = SPI_SSPCPSR_CPSDVSR(cpsdvsr); - ctrl->sspdmacr = (cfg->dma_tx ? SPI_SSPDMACR_TXDMAE : 0) | - (cfg->dma_rx ? SPI_SSPDMACR_RXDMAE : 0); - ctrl->ssprxcr_tx = 0; - if (cfg->rx_frame_bits > 0) { - ctrl->sspcr0_rx = SET_BITFIELD(ctrl->sspcr0_tx, SPI_SSPCR0_DSS, cfg->rx_frame_bits - 1); - ctrl->ssprxcr_rx = SPI_SSPRXCR_EN | SPI_SSPRXCR_OEN_POLARITY | SPI_SSPRXCR_RXBITS(cfg->rx_bits - 1); - } else { - ctrl->sspcr0_rx = SET_BITFIELD(ctrl->sspcr0_tx, SPI_SSPCR0_DSS, cfg->rx_bits - 1); - ctrl->ssprxcr_rx = 0; - } + ctrl->sspcr0_tx = + SPI_SSPCR0_SCR(scr) | (cfg->clk_delay_half ? SPI_SSPCR0_SPH : 0) | + (cfg->clk_polarity ? SPI_SSPCR0_SPO : 0) | + SPI_SSPCR0_FRF(0) | // Only support Motorola SPI frame format + SPI_SSPCR0_DSS(cfg->tx_bits - 1); + ctrl->sspcr1 = (cfg->rx_sep_line ? SPI_RX_SEL_EN : 0) | + SPI_SLAVE_ID(cfg->cs) | SPI_SSPCR1_SOD | + (cfg->slave ? SPI_SSPCR1_MS : 0) | SPI_SSPCR1_SSE; + ctrl->sspcpsr = SPI_SSPCPSR_CPSDVSR(cpsdvsr); + ctrl->sspdmacr = (cfg->dma_tx ? SPI_SSPDMACR_TXDMAE : 0) | + (cfg->dma_rx ? SPI_SSPDMACR_RXDMAE : 0); + ctrl->ssprxcr_tx = 0; + if (cfg->rx_frame_bits > 0) { + ctrl->sspcr0_rx = + SET_BITFIELD(ctrl->sspcr0_tx, SPI_SSPCR0_DSS, cfg->rx_frame_bits - 1); + ctrl->ssprxcr_rx = SPI_SSPRXCR_EN | SPI_SSPRXCR_OEN_POLARITY | + SPI_SSPRXCR_RXBITS(cfg->rx_bits - 1); + } else { + ctrl->sspcr0_rx = + SET_BITFIELD(ctrl->sspcr0_tx, SPI_SSPCR0_DSS, cfg->rx_bits - 1); + ctrl->ssprxcr_rx = 0; + } - return 0; + return 0; } -static void NOINLINE POSSIBLY_UNUSED hal_spi_set_xfer_type_id(enum HAL_SPI_ID_T id, const struct HAL_SPI_CTRL_T *ctrl, enum HAL_SPI_XFER_TYPE_T type) -{ - uint32_t sspcr0; - uint32_t ssprxcr; +static void NOINLINE POSSIBLY_UNUSED hal_spi_set_xfer_type_id( + enum HAL_SPI_ID_T id, const struct HAL_SPI_CTRL_T *ctrl, + enum HAL_SPI_XFER_TYPE_T type) { + uint32_t sspcr0; + uint32_t ssprxcr; - if (type == HAL_SPI_XFER_TYPE_SEND) { - sspcr0 = ctrl->sspcr0_tx; - ssprxcr = ctrl->ssprxcr_tx; - } else { - sspcr0 = ctrl->sspcr0_rx; - ssprxcr = ctrl->ssprxcr_rx; - } + if (type == HAL_SPI_XFER_TYPE_SEND) { + sspcr0 = ctrl->sspcr0_tx; + ssprxcr = ctrl->ssprxcr_tx; + } else { + sspcr0 = ctrl->sspcr0_rx; + ssprxcr = ctrl->ssprxcr_rx; + } - spi[id]->SSPCR0 = sspcr0; - spi[id]->SSPRXCR = ssprxcr; + spi[id]->SSPCR0 = sspcr0; + spi[id]->SSPRXCR = ssprxcr; } -static void NOINLINE hal_spi_enable_id(enum HAL_SPI_ID_T id, const struct HAL_SPI_CTRL_T *ctrl, enum HAL_SPI_XFER_TYPE_T type) -{ - hal_spi_set_xfer_type_id(id, ctrl, type); +static void NOINLINE hal_spi_enable_id(enum HAL_SPI_ID_T id, + const struct HAL_SPI_CTRL_T *ctrl, + enum HAL_SPI_XFER_TYPE_T type) { + hal_spi_set_xfer_type_id(id, ctrl, type); - spi[id]->SSPCR1 = ctrl->sspcr1; - spi[id]->SSPCPSR = ctrl->sspcpsr; - spi[id]->SSPDMACR = ctrl->sspdmacr; + spi[id]->SSPCR1 = ctrl->sspcr1; + spi[id]->SSPCPSR = ctrl->sspcpsr; + spi[id]->SSPDMACR = ctrl->sspdmacr; #ifdef SPI_ROM_ONLY - if (id == HAL_SPI_ID_INTERNAL) { - hal_cmu_ispi_set_freq(HAL_CMU_PERIPH_FREQ_26M); + if (id == HAL_SPI_ID_INTERNAL) { + hal_cmu_ispi_set_freq(HAL_CMU_PERIPH_FREQ_26M); #ifdef CHIP_HAS_SPI - } else if (id == HAL_SPI_ID_0) { - hal_cmu_spi_set_freq(HAL_CMU_PERIPH_FREQ_26M); + } else if (id == HAL_SPI_ID_0) { + hal_cmu_spi_set_freq(HAL_CMU_PERIPH_FREQ_26M); #endif #ifdef CHIP_HAS_SPILCD - } else if (id == HAL_SPI_ID_SLCD) { - hal_cmu_slcd_set_freq(HAL_CMU_PERIPH_FREQ_26M); + } else if (id == HAL_SPI_ID_SLCD) { + hal_cmu_slcd_set_freq(HAL_CMU_PERIPH_FREQ_26M); #endif - } + } #else // !SPI_ROM_ONLY - if (clk_sel[id] != ctrl->clk_sel) { - clk_sel[id] = ctrl->clk_sel; - if (ctrl->clk_sel == HAL_SPI_MOD_CLK_SEL_PLL) { + if (clk_sel[id] != ctrl->clk_sel) { + clk_sel[id] = ctrl->clk_sel; + if (ctrl->clk_sel == HAL_SPI_MOD_CLK_SEL_PLL) { #ifdef PERIPH_PLL_FREQ - if (0) { + if (0) { #ifdef CHIP_HAS_SPI - } else if (id == HAL_SPI_ID_0) { - hal_cmu_spi_set_div(2); + } else if (id == HAL_SPI_ID_0) { + hal_cmu_spi_set_div(2); #endif #ifdef CHIP_HAS_SPILCD - } else if (id == HAL_SPI_ID_SLCD) { - hal_cmu_slcd_set_div(2); + } else if (id == HAL_SPI_ID_SLCD) { + hal_cmu_slcd_set_div(2); #endif - } - // ISPI cannot use PLL clock + } + // ISPI cannot use PLL clock #endif - } else { - enum HAL_CMU_PERIPH_FREQ_T periph_freq; + } else { + enum HAL_CMU_PERIPH_FREQ_T periph_freq; - if (ctrl->clk_sel == HAL_SPI_MOD_CLK_SEL_OSC_X2) { - periph_freq = HAL_CMU_PERIPH_FREQ_52M; - } else { - periph_freq = HAL_CMU_PERIPH_FREQ_26M; - } + if (ctrl->clk_sel == HAL_SPI_MOD_CLK_SEL_OSC_X2) { + periph_freq = HAL_CMU_PERIPH_FREQ_52M; + } else { + periph_freq = HAL_CMU_PERIPH_FREQ_26M; + } - if (id == HAL_SPI_ID_INTERNAL) { - hal_cmu_ispi_set_freq(periph_freq); + if (id == HAL_SPI_ID_INTERNAL) { + hal_cmu_ispi_set_freq(periph_freq); #ifdef CHIP_HAS_SPI - } else if (id == HAL_SPI_ID_0) { - hal_cmu_spi_set_freq(periph_freq); + } else if (id == HAL_SPI_ID_0) { + hal_cmu_spi_set_freq(periph_freq); #endif #ifdef CHIP_HAS_SPILCD - } else if (id == HAL_SPI_ID_SLCD) { - hal_cmu_slcd_set_freq(periph_freq); + } else if (id == HAL_SPI_ID_SLCD) { + hal_cmu_slcd_set_freq(periph_freq); #endif - } - } + } } + } #endif // !SPI_ROM_ONLY } -static void hal_spi_disable_id(enum HAL_SPI_ID_T id) -{ - spi[id]->SSPCR1 &= ~SPI_SSPCR1_SSE; +static void hal_spi_disable_id(enum HAL_SPI_ID_T id) { + spi[id]->SSPCR1 &= ~SPI_SSPCR1_SSE; } -static void POSSIBLY_UNUSED hal_spi_get_ctrl_id(enum HAL_SPI_ID_T id, struct HAL_SPI_CTRL_T *ctrl) -{ - ctrl->sspcr0_tx = spi[id]->SSPCR0; - ctrl->sspcr1 = spi[id]->SSPCR1; - ctrl->sspcpsr = spi[id]->SSPCPSR; - ctrl->sspdmacr = spi[id]->SSPDMACR; - ctrl->ssprxcr_tx = spi[id]->SSPRXCR; +static void POSSIBLY_UNUSED hal_spi_get_ctrl_id(enum HAL_SPI_ID_T id, + struct HAL_SPI_CTRL_T *ctrl) { + ctrl->sspcr0_tx = spi[id]->SSPCR0; + ctrl->sspcr1 = spi[id]->SSPCR1; + ctrl->sspcpsr = spi[id]->SSPCPSR; + ctrl->sspdmacr = spi[id]->SSPDMACR; + ctrl->ssprxcr_tx = spi[id]->SSPRXCR; } -static int NOINLINE hal_spi_open_id(enum HAL_SPI_ID_T id, const struct HAL_SPI_CFG_T *cfg, struct HAL_SPI_CTRL_T *ctrl) -{ - int ret; - struct HAL_SPI_CTRL_T ctrl_regs; - bool cfg_clk = true; +static int NOINLINE hal_spi_open_id(enum HAL_SPI_ID_T id, + const struct HAL_SPI_CFG_T *cfg, + struct HAL_SPI_CTRL_T *ctrl) { + int ret; + struct HAL_SPI_CTRL_T ctrl_regs; + bool cfg_clk = true; - //SPI_ASSERT(id < HAL_SPI_ID_QTY, invalid_id, id); + // SPI_ASSERT(id < HAL_SPI_ID_QTY, invalid_id, id); - if (ctrl == NULL) { - ctrl = &ctrl_regs; - } + if (ctrl == NULL) { + ctrl = &ctrl_regs; + } - ret = hal_spi_init_ctrl(cfg, ctrl); - if (ret) { - return ret; - } + ret = hal_spi_init_ctrl(cfg, ctrl); + if (ret) { + return ret; + } #ifndef SPI_ROM_ONLY - if (!spi_init_done) { - spi_init_done = true; - for (int i = HAL_SPI_ID_INTERNAL; i < HAL_SPI_ID_QTY; i++) { - spi_txdma_chan[i] = HAL_DMA_CHAN_NONE; - spi_rxdma_chan[i] = HAL_DMA_CHAN_NONE; - } + if (!spi_init_done) { + spi_init_done = true; + for (int i = HAL_SPI_ID_INTERNAL; i < HAL_SPI_ID_QTY; i++) { + spi_txdma_chan[i] = HAL_DMA_CHAN_NONE; + spi_rxdma_chan[i] = HAL_DMA_CHAN_NONE; } + } - if (spi_cs_map[id]) { - cfg_clk = false; - } - spi_cs_map[id] |= (1 << cfg->cs); + if (spi_cs_map[id]) { + cfg_clk = false; + } + spi_cs_map[id] |= (1 << cfg->cs); #endif - if (cfg_clk) { - hal_cmu_clock_enable(spi_mod[id].mod); - hal_cmu_clock_enable(spi_mod[id].apb); - hal_cmu_reset_clear(spi_mod[id].mod); - hal_cmu_reset_clear(spi_mod[id].apb); - } + if (cfg_clk) { + hal_cmu_clock_enable(spi_mod[id].mod); + hal_cmu_clock_enable(spi_mod[id].apb); + hal_cmu_reset_clear(spi_mod[id].mod); + hal_cmu_reset_clear(spi_mod[id].apb); + } - hal_spi_enable_id(id, ctrl, HAL_SPI_XFER_TYPE_SEND); + hal_spi_enable_id(id, ctrl, HAL_SPI_XFER_TYPE_SEND); - return 0; + return 0; } -static int POSSIBLY_UNUSED hal_spi_close_id(enum HAL_SPI_ID_T id, uint32_t cs) -{ - int ret = 0; - bool cfg_clk = true; +static int POSSIBLY_UNUSED hal_spi_close_id(enum HAL_SPI_ID_T id, uint32_t cs) { + int ret = 0; + bool cfg_clk = true; #ifndef SPI_ROM_ONLY - if (spi_cs_map[id] & (1 << cs)) { - spi_cs_map[id] &= ~(1 << cs); + if (spi_cs_map[id] & (1 << cs)) { + spi_cs_map[id] &= ~(1 << cs); #if (CHIP_SPI_VER >= 2) - if (spi_cs_map[id]) { - cfg_clk = false; - } -#endif - } else { - ret = 1; - cfg_clk = false; + if (spi_cs_map[id]) { + cfg_clk = false; } #endif + } else { + ret = 1; + cfg_clk = false; + } +#endif - if (cfg_clk) { - hal_spi_disable_id(id); + if (cfg_clk) { + hal_spi_disable_id(id); - hal_cmu_reset_set(spi_mod[id].apb); - hal_cmu_reset_set(spi_mod[id].mod); - hal_cmu_clock_disable(spi_mod[id].apb); - hal_cmu_clock_disable(spi_mod[id].mod); - } + hal_cmu_reset_set(spi_mod[id].apb); + hal_cmu_reset_set(spi_mod[id].mod); + hal_cmu_clock_disable(spi_mod[id].apb); + hal_cmu_clock_disable(spi_mod[id].mod); + } - return ret; + return ret; } -static void POSSIBLY_UNUSED hal_spi_set_cs_id(enum HAL_SPI_ID_T id, uint32_t cs) -{ - spi[id]->SSPCR1 = SET_BITFIELD(spi[id]->SSPCR1, SPI_SLAVE_ID, cs); +static void POSSIBLY_UNUSED hal_spi_set_cs_id(enum HAL_SPI_ID_T id, + uint32_t cs) { + spi[id]->SSPCR1 = SET_BITFIELD(spi[id]->SSPCR1, SPI_SLAVE_ID, cs); } -static bool hal_spi_busy_id(enum HAL_SPI_ID_T id) -{ - return ((spi[id]->SSPCR1 & SPI_SSPCR1_SSE) && (spi[id]->SSPSR & SPI_SSPSR_BSY)); +static bool hal_spi_busy_id(enum HAL_SPI_ID_T id) { + return ((spi[id]->SSPCR1 & SPI_SSPCR1_SSE) && + (spi[id]->SSPSR & SPI_SSPSR_BSY)); } -static void hal_spi_enable_slave_output_id(enum HAL_SPI_ID_T id) -{ - if (spi[id]->SSPCR1 & SPI_SSPCR1_MS) { - spi[id]->SSPCR1 &= ~SPI_SSPCR1_SOD; - } +static void hal_spi_enable_slave_output_id(enum HAL_SPI_ID_T id) { + if (spi[id]->SSPCR1 & SPI_SSPCR1_MS) { + spi[id]->SSPCR1 &= ~SPI_SSPCR1_SOD; + } } -static void hal_spi_disable_slave_output_id(enum HAL_SPI_ID_T id) -{ - if (spi[id]->SSPCR1 & SPI_SSPCR1_MS) { - spi[id]->SSPCR1 |= SPI_SSPCR1_SOD; - } +static void hal_spi_disable_slave_output_id(enum HAL_SPI_ID_T id) { + if (spi[id]->SSPCR1 & SPI_SSPCR1_MS) { + spi[id]->SSPCR1 |= SPI_SSPCR1_SOD; + } } -static int hal_spi_send_id(enum HAL_SPI_ID_T id, const void *data, uint32_t len) -{ - uint8_t cnt; - uint32_t sent, value; - int ret; +static int hal_spi_send_id(enum HAL_SPI_ID_T id, const void *data, + uint32_t len) { + uint8_t cnt; + uint32_t sent, value; + int ret; - //SPI_ASSERT(id < HAL_SPI_ID_QTY, invalid_id, id); - SPI_ASSERT((spi[id]->SSPDMACR & SPI_SSPDMACR_TXDMAE) == 0, "TX-DMA configured on SPI %d", id); + // SPI_ASSERT(id < HAL_SPI_ID_QTY, invalid_id, id); + SPI_ASSERT((spi[id]->SSPDMACR & SPI_SSPDMACR_TXDMAE) == 0, + "TX-DMA configured on SPI %d", id); - cnt = get_frame_bytes(id); + cnt = get_frame_bytes(id); - if (len == 0 || (len & (cnt - 1)) != 0) { - return -1; + if (len == 0 || (len & (cnt - 1)) != 0) { + return -1; + } + + sent = 0; + + hal_spi_enable_slave_output_id(id); + + while (sent < len) { + if ((spi[id]->SSPCR1 & SPI_SSPCR1_SSE) == 0) { + break; } - - sent = 0; - - hal_spi_enable_slave_output_id(id); - - while (sent < len) { - if ((spi[id]->SSPCR1 & SPI_SSPCR1_SSE) == 0) { - break; - } - if (spi[id]->SSPSR & SPI_SSPSR_TNF) { - value = 0; - copy_frame_from_bytes(&value, (uint8_t *)data + sent, cnt); - spi[id]->SSPDR = value; - sent += cnt; - } + if (spi[id]->SSPSR & SPI_SSPSR_TNF) { + value = 0; + copy_frame_from_bytes(&value, (uint8_t *)data + sent, cnt); + spi[id]->SSPDR = value; + sent += cnt; } + } - if (sent >= len) { - ret = 0; - } else { - ret = 1; - } + if (sent >= len) { + ret = 0; + } else { + ret = 1; + } - while (hal_spi_busy_id(id)); - hal_spi_disable_slave_output_id(id); + while (hal_spi_busy_id(id)) + ; + hal_spi_disable_slave_output_id(id); - return ret; + return ret; } -static int hal_spi_recv_id(enum HAL_SPI_ID_T id, const void *cmd, void *data, uint32_t len) -{ - uint8_t cnt; - uint32_t sent, recv, value; - int ret; +static int hal_spi_recv_id(enum HAL_SPI_ID_T id, const void *cmd, void *data, + uint32_t len) { + uint8_t cnt; + uint32_t sent, recv, value; + int ret; - //SPI_ASSERT(id < HAL_SPI_ID_QTY, invalid_id, id); - SPI_ASSERT((spi[id]->SSPDMACR & (SPI_SSPDMACR_TXDMAE | SPI_SSPDMACR_RXDMAE)) == 0, "RX/TX-DMA configured on SPI %d", id); + // SPI_ASSERT(id < HAL_SPI_ID_QTY, invalid_id, id); + SPI_ASSERT( + (spi[id]->SSPDMACR & (SPI_SSPDMACR_TXDMAE | SPI_SSPDMACR_RXDMAE)) == 0, + "RX/TX-DMA configured on SPI %d", id); - cnt = get_frame_bytes(id); + cnt = get_frame_bytes(id); - if (len == 0 || (len & (cnt - 1)) != 0) { - return -1; + if (len == 0 || (len & (cnt - 1)) != 0) { + return -1; + } + + // Rx transaction should start from idle state + if (spi[id]->SSPSR & SPI_SSPSR_BSY) { + return -11; + } + + sent = 0; + recv = 0; + + // Flush the RX FIFO by reset or CPU read + while (spi[id]->SSPSR & SPI_SSPSR_RNE) { + spi[id]->SSPDR; + } + spi[id]->SSPICR = ~0UL; + + hal_spi_enable_slave_output_id(id); + + while (recv < len || sent < len) { + if ((spi[id]->SSPCR1 & SPI_SSPCR1_SSE) == 0) { + break; } - - // Rx transaction should start from idle state - if (spi[id]->SSPSR & SPI_SSPSR_BSY) { - return -11; + if (sent < len && (spi[id]->SSPSR & SPI_SSPSR_TNF)) { + value = 0; + copy_frame_from_bytes(&value, (uint8_t *)cmd + sent, cnt); + spi[id]->SSPDR = value; + sent += cnt; } - - sent = 0; - recv = 0; - - // Flush the RX FIFO by reset or CPU read - while (spi[id]->SSPSR & SPI_SSPSR_RNE) { - spi[id]->SSPDR; + if (recv < len && (spi[id]->SSPSR & SPI_SSPSR_RNE)) { + value = spi[id]->SSPDR; + copy_bytes_from_frame((uint8_t *)data + recv, value, cnt); + recv += cnt; } - spi[id]->SSPICR = ~0UL; + } - hal_spi_enable_slave_output_id(id); + if (recv >= len && sent >= len) { + ret = 0; + } else { + ret = 1; + } - while (recv < len || sent < len) { - if ((spi[id]->SSPCR1 & SPI_SSPCR1_SSE) == 0) { - break; - } - if (sent < len && (spi[id]->SSPSR & SPI_SSPSR_TNF)) { - value = 0; - copy_frame_from_bytes(&value, (uint8_t *)cmd + sent, cnt); - spi[id]->SSPDR = value; - sent += cnt; - } - if (recv < len && (spi[id]->SSPSR & SPI_SSPSR_RNE)) { - value = spi[id]->SSPDR; - copy_bytes_from_frame((uint8_t *)data + recv, value, cnt); - recv += cnt; - } - } + while (hal_spi_busy_id(id)) + ; + hal_spi_disable_slave_output_id(id); - if (recv >= len && sent >= len) { - ret = 0; - } else { - ret = 1; - } - - while (hal_spi_busy_id(id)); - hal_spi_disable_slave_output_id(id); - - return ret; + return ret; } #ifdef SPI_ROM_ONLY @@ -615,41 +628,35 @@ static int hal_spi_recv_id(enum HAL_SPI_ID_T id, const void *cmd, void *data, ui // ISPI ROM functions //------------------------------------------------------------ -int hal_ispi_rom_open(const struct HAL_SPI_CFG_T *cfg) -{ - SPI_ASSERT(cfg->tx_bits == cfg->rx_bits && cfg->rx_frame_bits == 0, "ISPI_ROM: Bad bits cfg"); +int hal_ispi_rom_open(const struct HAL_SPI_CFG_T *cfg) { + SPI_ASSERT(cfg->tx_bits == cfg->rx_bits && cfg->rx_frame_bits == 0, + "ISPI_ROM: Bad bits cfg"); - return hal_spi_open_id(HAL_SPI_ID_INTERNAL, cfg, NULL); + return hal_spi_open_id(HAL_SPI_ID_INTERNAL, cfg, NULL); } -void hal_ispi_rom_activate_cs(uint32_t cs) -{ - SPI_ASSERT(cs < HAL_SPI_CS_QTY, "ISPI_ROM: SPI cs bad: %d", cs); +void hal_ispi_rom_activate_cs(uint32_t cs) { + SPI_ASSERT(cs < HAL_SPI_CS_QTY, "ISPI_ROM: SPI cs bad: %d", cs); - hal_spi_set_cs_id(HAL_SPI_ID_INTERNAL, cs); + hal_spi_set_cs_id(HAL_SPI_ID_INTERNAL, cs); } -int hal_ispi_rom_busy(void) -{ - return hal_spi_busy_id(HAL_SPI_ID_INTERNAL); +int hal_ispi_rom_busy(void) { return hal_spi_busy_id(HAL_SPI_ID_INTERNAL); } + +int hal_ispi_rom_send(const void *data, uint32_t len) { + int ret; + + ret = hal_spi_send_id(HAL_SPI_ID_INTERNAL, data, len); + + return ret; } -int hal_ispi_rom_send(const void *data, uint32_t len) -{ - int ret; +int hal_ispi_rom_recv(const void *cmd, void *data, uint32_t len) { + int ret; - ret = hal_spi_send_id(HAL_SPI_ID_INTERNAL, data, len); + ret = hal_spi_recv_id(HAL_SPI_ID_INTERNAL, cmd, data, len); - return ret; -} - -int hal_ispi_rom_recv(const void *cmd, void *data, uint32_t len) -{ - int ret; - - ret = hal_spi_recv_id(HAL_SPI_ID_INTERNAL, cmd, data, len); - - return ret; + return ret; } #ifdef CHIP_HAS_SPIPHY @@ -657,613 +664,611 @@ int hal_ispi_rom_recv(const void *cmd, void *data, uint32_t len) // SPI PHY ROM functions //------------------------------------------------------------ -int hal_spiphy_rom_open(const struct HAL_SPI_CFG_T *cfg) -{ - SPI_ASSERT(cfg->tx_bits == cfg->rx_bits && cfg->rx_frame_bits == 0, "SPIPHY_ROM: Bad bits cfg"); +int hal_spiphy_rom_open(const struct HAL_SPI_CFG_T *cfg) { + SPI_ASSERT(cfg->tx_bits == cfg->rx_bits && cfg->rx_frame_bits == 0, + "SPIPHY_ROM: Bad bits cfg"); - return hal_spi_open_id(HAL_SPI_ID_PHY, cfg, NULL); + return hal_spi_open_id(HAL_SPI_ID_PHY, cfg, NULL); } -int hal_spiphy_rom_busy(void) -{ - return hal_spi_busy_id(HAL_SPI_ID_PHY); +int hal_spiphy_rom_busy(void) { return hal_spi_busy_id(HAL_SPI_ID_PHY); } + +int hal_spiphy_rom_send(const void *data, uint32_t len) { + int ret; + + ret = hal_spi_send_id(HAL_SPI_ID_PHY, data, len); + + return ret; } -int hal_spiphy_rom_send(const void *data, uint32_t len) -{ - int ret; +int hal_spiphy_rom_recv(const void *cmd, void *data, uint32_t len) { + int ret; - ret = hal_spi_send_id(HAL_SPI_ID_PHY, data, len); + ret = hal_spi_recv_id(HAL_SPI_ID_PHY, cmd, data, len); - return ret; -} - -int hal_spiphy_rom_recv(const void *cmd, void *data, uint32_t len) -{ - int ret; - - ret = hal_spi_recv_id(HAL_SPI_ID_PHY, cmd, data, len); - - return ret; + return ret; } #endif #else // !SPI_ROM_ONLY -static int hal_spi_activate_cs_id(enum HAL_SPI_ID_T id, uint32_t cs) -{ - struct HAL_SPI_CTRL_T *ctrl = NULL; +static int hal_spi_activate_cs_id(enum HAL_SPI_ID_T id, uint32_t cs) { + struct HAL_SPI_CTRL_T *ctrl = NULL; - SPI_ASSERT(cs < HAL_SPI_CS_QTY, "SPI cs bad: %d", cs); - SPI_ASSERT(spi_cs_map[id] & (1 << cs), "SPI cs not opened: %d", cs); + SPI_ASSERT(cs < HAL_SPI_CS_QTY, "SPI cs bad: %d", cs); + SPI_ASSERT(spi_cs_map[id] & (1 << cs), "SPI cs not opened: %d", cs); #if (CHIP_SPI_VER >= 2) - if (0) { + if (0) { #ifdef CHIP_HAS_SPI - } else if (id == HAL_SPI_ID_0) { - spi0_cs = cs; + } else if (id == HAL_SPI_ID_0) { + spi0_cs = cs; #endif #ifdef CHIP_HAS_SPILCD - } else if (id == HAL_SPI_ID_SLCD) { - spilcd_cs = cs; + } else if (id == HAL_SPI_ID_SLCD) { + spilcd_cs = cs; #endif - } + } #endif - if (0) { + if (0) { #ifdef CHIP_HAS_SPI - } else if (id == HAL_SPI_ID_0) { - ctrl = &spi0_ctrl[spi0_cs]; + } else if (id == HAL_SPI_ID_0) { + ctrl = &spi0_ctrl[spi0_cs]; #endif #ifdef CHIP_HAS_SPILCD - } else if (id == HAL_SPI_ID_SLCD) { - ctrl = &spilcd_ctrl[spilcd_cs]; + } else if (id == HAL_SPI_ID_SLCD) { + ctrl = &spilcd_ctrl[spilcd_cs]; #endif - } - if (ctrl) { - hal_spi_enable_id(id, ctrl, HAL_SPI_XFER_TYPE_SEND); - } - - return 0; -} - -static int POSSIBLY_UNUSED hal_spi_enable_and_send_id(enum HAL_SPI_ID_T id, const struct HAL_SPI_CTRL_T *ctrl, const void *data, uint32_t len) -{ - int ret; - struct HAL_SPI_CTRL_T saved; - - //SPI_ASSERT(id < HAL_SPI_ID_QTY, invalid_id, id); - - if (set_bool_flag(&in_use[id])) { - return -31; - } - - hal_spi_get_ctrl_id(id, &saved); + } + if (ctrl) { hal_spi_enable_id(id, ctrl, HAL_SPI_XFER_TYPE_SEND); - ret = hal_spi_send_id(id, data, len); - hal_spi_enable_id(id, &saved, HAL_SPI_XFER_TYPE_SEND); + } - clear_bool_flag(&in_use[id]); - - return ret; + return 0; } -static int POSSIBLY_UNUSED hal_spi_enable_and_recv_id(enum HAL_SPI_ID_T id, const struct HAL_SPI_CTRL_T *ctrl, const void *cmd, void *data, uint32_t len) -{ - int ret; - struct HAL_SPI_CTRL_T saved; +static int POSSIBLY_UNUSED hal_spi_enable_and_send_id( + enum HAL_SPI_ID_T id, const struct HAL_SPI_CTRL_T *ctrl, const void *data, + uint32_t len) { + int ret; + struct HAL_SPI_CTRL_T saved; - if (set_bool_flag(&in_use[id])) { - return -31; - } + // SPI_ASSERT(id < HAL_SPI_ID_QTY, invalid_id, id); - hal_spi_get_ctrl_id(id, &saved); - hal_spi_enable_id(id, ctrl, HAL_SPI_XFER_TYPE_RECV); - ret = hal_spi_recv_id(id, cmd, data, len); - hal_spi_enable_id(id, &saved, HAL_SPI_XFER_TYPE_SEND); + if (set_bool_flag(&in_use[id])) { + return -31; + } - clear_bool_flag(&in_use[id]); + hal_spi_get_ctrl_id(id, &saved); + hal_spi_enable_id(id, ctrl, HAL_SPI_XFER_TYPE_SEND); + ret = hal_spi_send_id(id, data, len); + hal_spi_enable_id(id, &saved, HAL_SPI_XFER_TYPE_SEND); - return ret; + clear_bool_flag(&in_use[id]); + + return ret; } -static void hal_spi_txdma_handler(uint8_t chan, uint32_t remains, uint32_t error, struct HAL_DMA_DESC_T *lli) -{ - enum HAL_SPI_ID_T id; - uint32_t lock; +static int POSSIBLY_UNUSED hal_spi_enable_and_recv_id( + enum HAL_SPI_ID_T id, const struct HAL_SPI_CTRL_T *ctrl, const void *cmd, + void *data, uint32_t len) { + int ret; + struct HAL_SPI_CTRL_T saved; - lock = int_lock(); - for (id = HAL_SPI_ID_INTERNAL; id < HAL_SPI_ID_QTY; id++) { - if (spi_txdma_chan[id] == chan) { - spi_txdma_chan[id] = HAL_DMA_CHAN_NONE; - break; - } - } - int_unlock(lock); + if (set_bool_flag(&in_use[id])) { + return -31; + } - if (id >= HAL_SPI_ID_QTY) { - return; - } + hal_spi_get_ctrl_id(id, &saved); + hal_spi_enable_id(id, ctrl, HAL_SPI_XFER_TYPE_RECV); + ret = hal_spi_recv_id(id, cmd, data, len); + hal_spi_enable_id(id, &saved, HAL_SPI_XFER_TYPE_SEND); - hal_gpdma_free_chan(chan); + clear_bool_flag(&in_use[id]); - clear_bool_flag(&in_use[id]); - - if (spi_txdma_handler[id]) { - spi_txdma_handler[id](error); - } + return ret; } -static int hal_spi_dma_send_id(enum HAL_SPI_ID_T id, const void *data, uint32_t len, HAL_SPI_DMA_HANDLER_T handler) -{ - uint8_t cnt; - enum HAL_DMA_RET_T ret; - struct HAL_DMA_CH_CFG_T dma_cfg; - enum HAL_DMA_WDITH_T dma_width; - uint32_t lock; - enum HAL_DMA_PERIPH_T dst_periph; +static void hal_spi_txdma_handler(uint8_t chan, uint32_t remains, + uint32_t error, struct HAL_DMA_DESC_T *lli) { + enum HAL_SPI_ID_T id; + uint32_t lock; - //SPI_ASSERT(id < HAL_SPI_ID_QTY, invalid_id, id); - SPI_ASSERT((spi[id]->SSPDMACR & SPI_SSPDMACR_TXDMAE), "TX-DMA not configured on SPI %d", id); - - spi_txdma_handler[id] = handler; - - cnt = get_frame_bytes(id); - - if ((len & (cnt - 1)) != 0) { - return -1; - } - if (((uint32_t)data & (cnt - 1)) != 0) { - return -2; + lock = int_lock(); + for (id = HAL_SPI_ID_INTERNAL; id < HAL_SPI_ID_QTY; id++) { + if (spi_txdma_chan[id] == chan) { + spi_txdma_chan[id] = HAL_DMA_CHAN_NONE; + break; } + } + int_unlock(lock); - // Tx transaction should start from idle state for SPI mode 1 and 3 (SPH=1) - if ((spi[id]->SSPCR0 & SPI_SSPCR0_SPH) && (spi[id]->SSPSR & SPI_SSPSR_BSY)) { - return -11; - } + if (id >= HAL_SPI_ID_QTY) { + return; + } - if (id == HAL_SPI_ID_INTERNAL) { - dst_periph = HAL_GPDMA_ISPI_TX; + hal_gpdma_free_chan(chan); + + clear_bool_flag(&in_use[id]); + + if (spi_txdma_handler[id]) { + spi_txdma_handler[id](error); + } +} + +static int hal_spi_dma_send_id(enum HAL_SPI_ID_T id, const void *data, + uint32_t len, HAL_SPI_DMA_HANDLER_T handler) { + uint8_t cnt; + enum HAL_DMA_RET_T ret; + struct HAL_DMA_CH_CFG_T dma_cfg; + enum HAL_DMA_WDITH_T dma_width; + uint32_t lock; + enum HAL_DMA_PERIPH_T dst_periph; + + // SPI_ASSERT(id < HAL_SPI_ID_QTY, invalid_id, id); + SPI_ASSERT((spi[id]->SSPDMACR & SPI_SSPDMACR_TXDMAE), + "TX-DMA not configured on SPI %d", id); + + spi_txdma_handler[id] = handler; + + cnt = get_frame_bytes(id); + + if ((len & (cnt - 1)) != 0) { + return -1; + } + if (((uint32_t)data & (cnt - 1)) != 0) { + return -2; + } + + // Tx transaction should start from idle state for SPI mode 1 and 3 (SPH=1) + if ((spi[id]->SSPCR0 & SPI_SSPCR0_SPH) && (spi[id]->SSPSR & SPI_SSPSR_BSY)) { + return -11; + } + + if (id == HAL_SPI_ID_INTERNAL) { + dst_periph = HAL_GPDMA_ISPI_TX; #ifdef CHIP_HAS_SPI - } else if (id == HAL_SPI_ID_0) { - dst_periph = HAL_GPDMA_SPI_TX; + } else if (id == HAL_SPI_ID_0) { + dst_periph = HAL_GPDMA_SPI_TX; #endif #ifdef CHIP_HAS_SPILCD - } else if (id == HAL_SPI_ID_SLCD) { - dst_periph = HAL_GPDMA_SPILCD_TX; + } else if (id == HAL_SPI_ID_SLCD) { + dst_periph = HAL_GPDMA_SPILCD_TX; #endif - } else { - return -12; - } + } else { + return -12; + } - lock = int_lock(); - if (spi_txdma_chan[id] != HAL_DMA_CHAN_NONE) { - int_unlock(lock); - return -3; - } - spi_txdma_chan[id] = hal_gpdma_get_chan(dst_periph, HAL_DMA_HIGH_PRIO); - if (spi_txdma_chan[id] == HAL_DMA_CHAN_NONE) { - int_unlock(lock); - return -4; - } + lock = int_lock(); + if (spi_txdma_chan[id] != HAL_DMA_CHAN_NONE) { int_unlock(lock); + return -3; + } + spi_txdma_chan[id] = hal_gpdma_get_chan(dst_periph, HAL_DMA_HIGH_PRIO); + if (spi_txdma_chan[id] == HAL_DMA_CHAN_NONE) { + int_unlock(lock); + return -4; + } + int_unlock(lock); - if (cnt == 1) { - dma_width = HAL_DMA_WIDTH_BYTE; - } else if (cnt == 2) { - dma_width = HAL_DMA_WIDTH_HALFWORD; - } else { - dma_width = HAL_DMA_WIDTH_WORD; - } + if (cnt == 1) { + dma_width = HAL_DMA_WIDTH_BYTE; + } else if (cnt == 2) { + dma_width = HAL_DMA_WIDTH_HALFWORD; + } else { + dma_width = HAL_DMA_WIDTH_WORD; + } - memset(&dma_cfg, 0, sizeof(dma_cfg)); - dma_cfg.ch = spi_txdma_chan[id]; - dma_cfg.dst = 0; // useless - dma_cfg.dst_bsize = HAL_DMA_BSIZE_4; - dma_cfg.dst_periph = dst_periph; - dma_cfg.dst_width = dma_width; - dma_cfg.handler = handler ? hal_spi_txdma_handler : NULL; - dma_cfg.src = (uint32_t)data; - dma_cfg.src_bsize = HAL_DMA_BSIZE_16; - //dma_cfg.src_periph = HAL_GPDMA_PERIPH_QTY; // useless - dma_cfg.src_tsize = len / cnt; - dma_cfg.src_width = dma_width; - dma_cfg.try_burst = 0; - dma_cfg.type = HAL_DMA_FLOW_M2P_DMA; + memset(&dma_cfg, 0, sizeof(dma_cfg)); + dma_cfg.ch = spi_txdma_chan[id]; + dma_cfg.dst = 0; // useless + dma_cfg.dst_bsize = HAL_DMA_BSIZE_4; + dma_cfg.dst_periph = dst_periph; + dma_cfg.dst_width = dma_width; + dma_cfg.handler = handler ? hal_spi_txdma_handler : NULL; + dma_cfg.src = (uint32_t)data; + dma_cfg.src_bsize = HAL_DMA_BSIZE_16; + // dma_cfg.src_periph = HAL_GPDMA_PERIPH_QTY; // useless + dma_cfg.src_tsize = len / cnt; + dma_cfg.src_width = dma_width; + dma_cfg.try_burst = 0; + dma_cfg.type = HAL_DMA_FLOW_M2P_DMA; - hal_spi_enable_slave_output_id(id); + hal_spi_enable_slave_output_id(id); - ret = hal_gpdma_start(&dma_cfg); - if (ret != HAL_DMA_OK) { - hal_spi_disable_slave_output_id(id); - return -5; - } + ret = hal_gpdma_start(&dma_cfg); + if (ret != HAL_DMA_OK) { + hal_spi_disable_slave_output_id(id); + return -5; + } - if (handler == NULL) { - while ((spi[id]->SSPCR1 & SPI_SSPCR1_SSE) && hal_gpdma_chan_busy(spi_txdma_chan[id])); - hal_gpdma_free_chan(spi_txdma_chan[id]); - spi_txdma_chan[id] = HAL_DMA_CHAN_NONE; - while (hal_spi_busy_id(id)); - hal_spi_disable_slave_output_id(id); - } - - return 0; -} - -void hal_spi_stop_dma_send_id(enum HAL_SPI_ID_T id) -{ - uint32_t lock; - uint8_t tx_chan; - - lock = int_lock(); - tx_chan = spi_txdma_chan[id]; + if (handler == NULL) { + while ((spi[id]->SSPCR1 & SPI_SSPCR1_SSE) && + hal_gpdma_chan_busy(spi_txdma_chan[id])) + ; + hal_gpdma_free_chan(spi_txdma_chan[id]); spi_txdma_chan[id] = HAL_DMA_CHAN_NONE; - int_unlock(lock); + while (hal_spi_busy_id(id)) + ; + hal_spi_disable_slave_output_id(id); + } - if (tx_chan != HAL_DMA_CHAN_NONE) { - hal_gpdma_cancel(tx_chan); - hal_gpdma_free_chan(tx_chan); - } - - clear_bool_flag(&in_use[id]); + return 0; } -static void hal_spi_rxdma_handler(uint8_t chan, uint32_t remains, uint32_t error, struct HAL_DMA_DESC_T *lli) -{ - enum HAL_SPI_ID_T id; - uint32_t lock; - uint8_t tx_chan = HAL_DMA_CHAN_NONE; - struct HAL_SPI_CTRL_T *ctrl = NULL; +void hal_spi_stop_dma_send_id(enum HAL_SPI_ID_T id) { + uint32_t lock; + uint8_t tx_chan; - lock = int_lock(); - for (id = HAL_SPI_ID_INTERNAL; id < HAL_SPI_ID_QTY; id++) { - if (spi_rxdma_chan[id] == chan) { - tx_chan = spi_txdma_chan[id]; - spi_rxdma_chan[id] = HAL_DMA_CHAN_NONE; - spi_txdma_chan[id] = HAL_DMA_CHAN_NONE; - break; - } - } - int_unlock(lock); + lock = int_lock(); + tx_chan = spi_txdma_chan[id]; + spi_txdma_chan[id] = HAL_DMA_CHAN_NONE; + int_unlock(lock); - if (id >= HAL_SPI_ID_QTY) { - return; - } - - hal_gpdma_free_chan(chan); + if (tx_chan != HAL_DMA_CHAN_NONE) { hal_gpdma_cancel(tx_chan); hal_gpdma_free_chan(tx_chan); + } - if (0) { -#ifdef CHIP_HAS_SPI - } else if (id == HAL_SPI_ID_0) { - ctrl = &spi0_ctrl[spi0_cs]; -#endif -#ifdef CHIP_HAS_SPILCD - } else if (id == HAL_SPI_ID_SLCD) { - ctrl = &spilcd_ctrl[spilcd_cs]; -#endif - } - if (ctrl) { - hal_spi_set_xfer_type_id(id, ctrl, HAL_SPI_XFER_TYPE_SEND); - } - clear_bool_flag(&in_use[id]); - - if (spi_rxdma_handler[id]) { - spi_rxdma_handler[id](error); - } + clear_bool_flag(&in_use[id]); } -static int hal_spi_dma_recv_id(enum HAL_SPI_ID_T id, const void *cmd, void *data, uint32_t len, HAL_SPI_DMA_HANDLER_T handler) -{ - uint8_t cnt; - enum HAL_DMA_RET_T ret; - struct HAL_DMA_CH_CFG_T dma_cfg; - enum HAL_DMA_WDITH_T dma_width; - uint32_t lock; - int result; - enum HAL_DMA_PERIPH_T dst_periph, src_periph; - struct HAL_SPI_CTRL_T *ctrl = NULL; +static void hal_spi_rxdma_handler(uint8_t chan, uint32_t remains, + uint32_t error, struct HAL_DMA_DESC_T *lli) { + enum HAL_SPI_ID_T id; + uint32_t lock; + uint8_t tx_chan = HAL_DMA_CHAN_NONE; + struct HAL_SPI_CTRL_T *ctrl = NULL; - //SPI_ASSERT(id < HAL_SPI_ID_QTY, invalid_id, id); - SPI_ASSERT((spi[id]->SSPDMACR & (SPI_SSPDMACR_TXDMAE | SPI_SSPDMACR_RXDMAE)) == - (SPI_SSPDMACR_TXDMAE | SPI_SSPDMACR_RXDMAE), "RX/TX-DMA not configured on SPI %d", id); - - spi_rxdma_handler[id] = handler; - - result = 0; - - cnt = get_frame_bytes(id); - - if ((len & (cnt - 1)) != 0) { - return -1; - } - if (((uint32_t)data & (cnt - 1)) != 0) { - return -2; + lock = int_lock(); + for (id = HAL_SPI_ID_INTERNAL; id < HAL_SPI_ID_QTY; id++) { + if (spi_rxdma_chan[id] == chan) { + tx_chan = spi_txdma_chan[id]; + spi_rxdma_chan[id] = HAL_DMA_CHAN_NONE; + spi_txdma_chan[id] = HAL_DMA_CHAN_NONE; + break; } + } + int_unlock(lock); - // Rx transaction should start from idle state - if (spi[id]->SSPSR & SPI_SSPSR_BSY) { - return -11; - } + if (id >= HAL_SPI_ID_QTY) { + return; + } - if (id == HAL_SPI_ID_INTERNAL) { - src_periph = HAL_GPDMA_ISPI_RX; - dst_periph = HAL_GPDMA_ISPI_TX; + hal_gpdma_free_chan(chan); + hal_gpdma_cancel(tx_chan); + hal_gpdma_free_chan(tx_chan); + + if (0) { #ifdef CHIP_HAS_SPI - } else if (id == HAL_SPI_ID_0) { - src_periph = HAL_GPDMA_SPI_RX; - dst_periph = HAL_GPDMA_SPI_TX; + } else if (id == HAL_SPI_ID_0) { + ctrl = &spi0_ctrl[spi0_cs]; #endif #ifdef CHIP_HAS_SPILCD - } else if (id == HAL_SPI_ID_SLCD) { - src_periph = HAL_GPDMA_SPILCD_RX; - dst_periph = HAL_GPDMA_SPILCD_TX; + } else if (id == HAL_SPI_ID_SLCD) { + ctrl = &spilcd_ctrl[spilcd_cs]; #endif - } else { - return -12; - } + } + if (ctrl) { + hal_spi_set_xfer_type_id(id, ctrl, HAL_SPI_XFER_TYPE_SEND); + } + clear_bool_flag(&in_use[id]); - lock = int_lock(); - if (spi_txdma_chan[id] != HAL_DMA_CHAN_NONE || spi_rxdma_chan[id] != HAL_DMA_CHAN_NONE) { - int_unlock(lock); - return -3; - } - spi_txdma_chan[id] = hal_gpdma_get_chan(dst_periph, HAL_DMA_HIGH_PRIO); - if (spi_txdma_chan[id] == HAL_DMA_CHAN_NONE) { - int_unlock(lock); - return -4; - } - spi_rxdma_chan[id] = hal_gpdma_get_chan(src_periph, HAL_DMA_HIGH_PRIO); - if (spi_rxdma_chan[id] == HAL_DMA_CHAN_NONE) { - hal_gpdma_free_chan(spi_txdma_chan[id]); - spi_txdma_chan[id] = HAL_DMA_CHAN_NONE; - int_unlock(lock); - return -5; - } + if (spi_rxdma_handler[id]) { + spi_rxdma_handler[id](error); + } +} + +static int hal_spi_dma_recv_id(enum HAL_SPI_ID_T id, const void *cmd, + void *data, uint32_t len, + HAL_SPI_DMA_HANDLER_T handler) { + uint8_t cnt; + enum HAL_DMA_RET_T ret; + struct HAL_DMA_CH_CFG_T dma_cfg; + enum HAL_DMA_WDITH_T dma_width; + uint32_t lock; + int result; + enum HAL_DMA_PERIPH_T dst_periph, src_periph; + struct HAL_SPI_CTRL_T *ctrl = NULL; + + // SPI_ASSERT(id < HAL_SPI_ID_QTY, invalid_id, id); + SPI_ASSERT( + (spi[id]->SSPDMACR & (SPI_SSPDMACR_TXDMAE | SPI_SSPDMACR_RXDMAE)) == + (SPI_SSPDMACR_TXDMAE | SPI_SSPDMACR_RXDMAE), + "RX/TX-DMA not configured on SPI %d", id); + + spi_rxdma_handler[id] = handler; + + result = 0; + + cnt = get_frame_bytes(id); + + if ((len & (cnt - 1)) != 0) { + return -1; + } + if (((uint32_t)data & (cnt - 1)) != 0) { + return -2; + } + + // Rx transaction should start from idle state + if (spi[id]->SSPSR & SPI_SSPSR_BSY) { + return -11; + } + + if (id == HAL_SPI_ID_INTERNAL) { + src_periph = HAL_GPDMA_ISPI_RX; + dst_periph = HAL_GPDMA_ISPI_TX; +#ifdef CHIP_HAS_SPI + } else if (id == HAL_SPI_ID_0) { + src_periph = HAL_GPDMA_SPI_RX; + dst_periph = HAL_GPDMA_SPI_TX; +#endif +#ifdef CHIP_HAS_SPILCD + } else if (id == HAL_SPI_ID_SLCD) { + src_periph = HAL_GPDMA_SPILCD_RX; + dst_periph = HAL_GPDMA_SPILCD_TX; +#endif + } else { + return -12; + } + + lock = int_lock(); + if (spi_txdma_chan[id] != HAL_DMA_CHAN_NONE || + spi_rxdma_chan[id] != HAL_DMA_CHAN_NONE) { int_unlock(lock); - - if (cnt == 1) { - dma_width = HAL_DMA_WIDTH_BYTE; - } else if (cnt == 2) { - dma_width = HAL_DMA_WIDTH_HALFWORD; - } else { - dma_width = HAL_DMA_WIDTH_WORD; - } - - memset(&dma_cfg, 0, sizeof(dma_cfg)); - dma_cfg.ch = spi_rxdma_chan[id]; - dma_cfg.dst = (uint32_t)data; - dma_cfg.dst_bsize = HAL_DMA_BSIZE_16; - //dma_cfg.dst_periph = HAL_GPDMA_PERIPH_QTY; // useless - dma_cfg.dst_width = dma_width; - dma_cfg.handler = handler ? hal_spi_rxdma_handler : NULL; - dma_cfg.src = 0; // useless - dma_cfg.src_periph = src_periph; - dma_cfg.src_bsize = HAL_DMA_BSIZE_4; - dma_cfg.src_tsize = len / cnt; - dma_cfg.src_width = dma_width; - dma_cfg.try_burst = 0; - dma_cfg.type = HAL_DMA_FLOW_P2M_DMA; - - // Flush the RX FIFO by reset or DMA read (CPU read is forbidden when DMA is enabled) - if (spi[id]->SSPSR & SPI_SSPSR_RNE) { - // Reset SPI MODULE might cause the increment of the FIFO pointer - hal_cmu_reset_pulse(spi_mod[id].mod); - // Reset SPI APB will reset the FIFO pointer - hal_cmu_reset_pulse(spi_mod[id].apb); - if (0) { -#ifdef CHIP_HAS_SPI - } else if (id == HAL_SPI_ID_0) { - ctrl = &spi0_ctrl[spi0_cs]; -#endif -#ifdef CHIP_HAS_SPILCD - } else if (id == HAL_SPI_ID_SLCD) { - ctrl = &spilcd_ctrl[spilcd_cs]; -#endif - } - if (ctrl) { - // hal_spi_set_xfer_type_id() is not enough, for all the registers have been reset by APB reset - hal_spi_enable_id(id, ctrl, HAL_SPI_XFER_TYPE_RECV); - } - } - spi[id]->SSPICR = ~0UL; - - ret = hal_gpdma_start(&dma_cfg); - if (ret != HAL_DMA_OK) { - result = -8; - goto _exit; - } - - dma_cfg.ch = spi_txdma_chan[id]; - dma_cfg.dst = 0; // useless - dma_cfg.dst_bsize = HAL_DMA_BSIZE_4; - dma_cfg.dst_periph = dst_periph; - dma_cfg.dst_width = dma_width; - dma_cfg.handler = NULL; - dma_cfg.src = (uint32_t)cmd; - dma_cfg.src_bsize = HAL_DMA_BSIZE_16; - //dma_cfg.src_periph = HAL_GPDMA_PERIPH_QTY; // useless - dma_cfg.src_tsize = len / cnt; - dma_cfg.src_width = dma_width; - dma_cfg.try_burst = 0; - dma_cfg.type = HAL_DMA_FLOW_M2P_DMA; - - hal_spi_enable_slave_output_id(id); - - ret = hal_gpdma_start(&dma_cfg); - if (ret != HAL_DMA_OK) { - result = -9; - goto _exit; - } - - if (handler == NULL) { - while ((spi[id]->SSPCR1 & SPI_SSPCR1_SSE) && hal_gpdma_chan_busy(spi_rxdma_chan[id])); - } - -_exit: - if (result || handler == NULL) { - hal_gpdma_cancel(spi_txdma_chan[id]); - hal_gpdma_free_chan(spi_txdma_chan[id]); - spi_txdma_chan[id] = HAL_DMA_CHAN_NONE; - - while (hal_spi_busy_id(id)); - hal_spi_disable_slave_output_id(id); - - hal_gpdma_cancel(spi_rxdma_chan[id]); - hal_gpdma_free_chan(spi_rxdma_chan[id]); - spi_rxdma_chan[id] = HAL_DMA_CHAN_NONE; - - if (ctrl) { - hal_spi_set_xfer_type_id(id, ctrl, HAL_SPI_XFER_TYPE_SEND); - } - } - - return 0; -} - -void hal_spi_stop_dma_recv_id(enum HAL_SPI_ID_T id) -{ - uint32_t lock; - uint8_t rx_chan, tx_chan; - struct HAL_SPI_CTRL_T *ctrl = NULL; - - lock = int_lock(); - rx_chan = spi_rxdma_chan[id]; - spi_rxdma_chan[id] = HAL_DMA_CHAN_NONE; - tx_chan = spi_txdma_chan[id]; + return -3; + } + spi_txdma_chan[id] = hal_gpdma_get_chan(dst_periph, HAL_DMA_HIGH_PRIO); + if (spi_txdma_chan[id] == HAL_DMA_CHAN_NONE) { + int_unlock(lock); + return -4; + } + spi_rxdma_chan[id] = hal_gpdma_get_chan(src_periph, HAL_DMA_HIGH_PRIO); + if (spi_rxdma_chan[id] == HAL_DMA_CHAN_NONE) { + hal_gpdma_free_chan(spi_txdma_chan[id]); spi_txdma_chan[id] = HAL_DMA_CHAN_NONE; int_unlock(lock); + return -5; + } + int_unlock(lock); - if (rx_chan == HAL_DMA_CHAN_NONE && tx_chan == HAL_DMA_CHAN_NONE) { - return; - } + if (cnt == 1) { + dma_width = HAL_DMA_WIDTH_BYTE; + } else if (cnt == 2) { + dma_width = HAL_DMA_WIDTH_HALFWORD; + } else { + dma_width = HAL_DMA_WIDTH_WORD; + } - if (rx_chan != HAL_DMA_CHAN_NONE) { - hal_gpdma_cancel(rx_chan); - hal_gpdma_free_chan(rx_chan); - } - if (tx_chan != HAL_DMA_CHAN_NONE) { - hal_gpdma_cancel(tx_chan); - hal_gpdma_free_chan(tx_chan); - } + memset(&dma_cfg, 0, sizeof(dma_cfg)); + dma_cfg.ch = spi_rxdma_chan[id]; + dma_cfg.dst = (uint32_t)data; + dma_cfg.dst_bsize = HAL_DMA_BSIZE_16; + // dma_cfg.dst_periph = HAL_GPDMA_PERIPH_QTY; // useless + dma_cfg.dst_width = dma_width; + dma_cfg.handler = handler ? hal_spi_rxdma_handler : NULL; + dma_cfg.src = 0; // useless + dma_cfg.src_periph = src_periph; + dma_cfg.src_bsize = HAL_DMA_BSIZE_4; + dma_cfg.src_tsize = len / cnt; + dma_cfg.src_width = dma_width; + dma_cfg.try_burst = 0; + dma_cfg.type = HAL_DMA_FLOW_P2M_DMA; + // Flush the RX FIFO by reset or DMA read (CPU read is forbidden when DMA is + // enabled) + if (spi[id]->SSPSR & SPI_SSPSR_RNE) { + // Reset SPI MODULE might cause the increment of the FIFO pointer + hal_cmu_reset_pulse(spi_mod[id].mod); + // Reset SPI APB will reset the FIFO pointer + hal_cmu_reset_pulse(spi_mod[id].apb); if (0) { #ifdef CHIP_HAS_SPI } else if (id == HAL_SPI_ID_0) { - ctrl = &spi0_ctrl[spi0_cs]; + ctrl = &spi0_ctrl[spi0_cs]; #endif #ifdef CHIP_HAS_SPILCD } else if (id == HAL_SPI_ID_SLCD) { - ctrl = &spilcd_ctrl[spilcd_cs]; + ctrl = &spilcd_ctrl[spilcd_cs]; #endif } if (ctrl) { - hal_spi_set_xfer_type_id(id, ctrl, HAL_SPI_XFER_TYPE_SEND); + // hal_spi_set_xfer_type_id() is not enough, for all the registers have + // been reset by APB reset + hal_spi_enable_id(id, ctrl, HAL_SPI_XFER_TYPE_RECV); } - clear_bool_flag(&in_use[id]); + } + spi[id]->SSPICR = ~0UL; + + ret = hal_gpdma_start(&dma_cfg); + if (ret != HAL_DMA_OK) { + result = -8; + goto _exit; + } + + dma_cfg.ch = spi_txdma_chan[id]; + dma_cfg.dst = 0; // useless + dma_cfg.dst_bsize = HAL_DMA_BSIZE_4; + dma_cfg.dst_periph = dst_periph; + dma_cfg.dst_width = dma_width; + dma_cfg.handler = NULL; + dma_cfg.src = (uint32_t)cmd; + dma_cfg.src_bsize = HAL_DMA_BSIZE_16; + // dma_cfg.src_periph = HAL_GPDMA_PERIPH_QTY; // useless + dma_cfg.src_tsize = len / cnt; + dma_cfg.src_width = dma_width; + dma_cfg.try_burst = 0; + dma_cfg.type = HAL_DMA_FLOW_M2P_DMA; + + hal_spi_enable_slave_output_id(id); + + ret = hal_gpdma_start(&dma_cfg); + if (ret != HAL_DMA_OK) { + result = -9; + goto _exit; + } + + if (handler == NULL) { + while ((spi[id]->SSPCR1 & SPI_SSPCR1_SSE) && + hal_gpdma_chan_busy(spi_rxdma_chan[id])) + ; + } + +_exit: + if (result || handler == NULL) { + hal_gpdma_cancel(spi_txdma_chan[id]); + hal_gpdma_free_chan(spi_txdma_chan[id]); + spi_txdma_chan[id] = HAL_DMA_CHAN_NONE; + + while (hal_spi_busy_id(id)) + ; + hal_spi_disable_slave_output_id(id); + + hal_gpdma_cancel(spi_rxdma_chan[id]); + hal_gpdma_free_chan(spi_rxdma_chan[id]); + spi_rxdma_chan[id] = HAL_DMA_CHAN_NONE; + + if (ctrl) { + hal_spi_set_xfer_type_id(id, ctrl, HAL_SPI_XFER_TYPE_SEND); + } + } + + return 0; +} + +void hal_spi_stop_dma_recv_id(enum HAL_SPI_ID_T id) { + uint32_t lock; + uint8_t rx_chan, tx_chan; + struct HAL_SPI_CTRL_T *ctrl = NULL; + + lock = int_lock(); + rx_chan = spi_rxdma_chan[id]; + spi_rxdma_chan[id] = HAL_DMA_CHAN_NONE; + tx_chan = spi_txdma_chan[id]; + spi_txdma_chan[id] = HAL_DMA_CHAN_NONE; + int_unlock(lock); + + if (rx_chan == HAL_DMA_CHAN_NONE && tx_chan == HAL_DMA_CHAN_NONE) { + return; + } + + if (rx_chan != HAL_DMA_CHAN_NONE) { + hal_gpdma_cancel(rx_chan); + hal_gpdma_free_chan(rx_chan); + } + if (tx_chan != HAL_DMA_CHAN_NONE) { + hal_gpdma_cancel(tx_chan); + hal_gpdma_free_chan(tx_chan); + } + + if (0) { +#ifdef CHIP_HAS_SPI + } else if (id == HAL_SPI_ID_0) { + ctrl = &spi0_ctrl[spi0_cs]; +#endif +#ifdef CHIP_HAS_SPILCD + } else if (id == HAL_SPI_ID_SLCD) { + ctrl = &spilcd_ctrl[spilcd_cs]; +#endif + } + if (ctrl) { + hal_spi_set_xfer_type_id(id, ctrl, HAL_SPI_XFER_TYPE_SEND); + } + clear_bool_flag(&in_use[id]); } //------------------------------------------------------------ // ISPI functions //------------------------------------------------------------ -int hal_ispi_open(const struct HAL_SPI_CFG_T *cfg) -{ - SPI_ASSERT(cfg->tx_bits == cfg->rx_bits && cfg->rx_frame_bits == 0, "ISPI: Bad bits cfg"); +int hal_ispi_open(const struct HAL_SPI_CFG_T *cfg) { + SPI_ASSERT(cfg->tx_bits == cfg->rx_bits && cfg->rx_frame_bits == 0, + "ISPI: Bad bits cfg"); - return hal_spi_open_id(HAL_SPI_ID_INTERNAL, cfg, NULL); + return hal_spi_open_id(HAL_SPI_ID_INTERNAL, cfg, NULL); } -int hal_ispi_close(uint32_t cs) -{ - return hal_spi_close_id(HAL_SPI_ID_INTERNAL, cs); +int hal_ispi_close(uint32_t cs) { + return hal_spi_close_id(HAL_SPI_ID_INTERNAL, cs); } -void hal_ispi_activate_cs(uint32_t cs) -{ - SPI_ASSERT(cs < HAL_SPI_CS_QTY, "ISPI: SPI cs bad: %d", cs); +void hal_ispi_activate_cs(uint32_t cs) { + SPI_ASSERT(cs < HAL_SPI_CS_QTY, "ISPI: SPI cs bad: %d", cs); - hal_spi_set_cs_id(HAL_SPI_ID_INTERNAL, cs); + hal_spi_set_cs_id(HAL_SPI_ID_INTERNAL, cs); } -int hal_ispi_busy(void) -{ - return hal_spi_busy_id(HAL_SPI_ID_INTERNAL); +int hal_ispi_busy(void) { return hal_spi_busy_id(HAL_SPI_ID_INTERNAL); } + +int hal_ispi_send(const void *data, uint32_t len) { + int ret; + + if (set_bool_flag(&in_use[HAL_SPI_ID_INTERNAL])) { + return -31; + } + + ret = hal_spi_send_id(HAL_SPI_ID_INTERNAL, data, len); + + clear_bool_flag(&in_use[HAL_SPI_ID_INTERNAL]); + + return ret; } -int hal_ispi_send(const void *data, uint32_t len) -{ - int ret; +int hal_ispi_recv(const void *cmd, void *data, uint32_t len) { + int ret; - if (set_bool_flag(&in_use[HAL_SPI_ID_INTERNAL])) { - return -31; - } + if (set_bool_flag(&in_use[HAL_SPI_ID_INTERNAL])) { + return -31; + } - ret = hal_spi_send_id(HAL_SPI_ID_INTERNAL, data, len); + ret = hal_spi_recv_id(HAL_SPI_ID_INTERNAL, cmd, data, len); + clear_bool_flag(&in_use[HAL_SPI_ID_INTERNAL]); + + return ret; +} + +int hal_ispi_dma_send(const void *data, uint32_t len, + HAL_SPI_DMA_HANDLER_T handler) { + int ret; + + if (set_bool_flag(&in_use[HAL_SPI_ID_INTERNAL])) { + return -31; + } + + ret = hal_spi_dma_send_id(HAL_SPI_ID_INTERNAL, data, len, handler); + + if (ret || handler == NULL) { clear_bool_flag(&in_use[HAL_SPI_ID_INTERNAL]); + } - return ret; + return ret; } -int hal_ispi_recv(const void *cmd, void *data, uint32_t len) -{ - int ret; +int hal_ispi_dma_recv(const void *cmd, void *data, uint32_t len, + HAL_SPI_DMA_HANDLER_T handler) { + int ret; - if (set_bool_flag(&in_use[HAL_SPI_ID_INTERNAL])) { - return -31; - } + if (set_bool_flag(&in_use[HAL_SPI_ID_INTERNAL])) { + return -31; + } - ret = hal_spi_recv_id(HAL_SPI_ID_INTERNAL, cmd, data, len); + ret = hal_spi_dma_recv_id(HAL_SPI_ID_INTERNAL, cmd, data, len, handler); + if (ret || handler == NULL) { clear_bool_flag(&in_use[HAL_SPI_ID_INTERNAL]); + } - return ret; + return ret; } -int hal_ispi_dma_send(const void *data, uint32_t len, HAL_SPI_DMA_HANDLER_T handler) -{ - int ret; - - if (set_bool_flag(&in_use[HAL_SPI_ID_INTERNAL])) { - return -31; - } - - ret = hal_spi_dma_send_id(HAL_SPI_ID_INTERNAL, data, len, handler); - - if (ret || handler == NULL) { - clear_bool_flag(&in_use[HAL_SPI_ID_INTERNAL]); - } - - return ret; +void hal_ispi_stop_dma_send(void) { + hal_spi_stop_dma_send_id(HAL_SPI_ID_INTERNAL); } -int hal_ispi_dma_recv(const void *cmd, void *data, uint32_t len, HAL_SPI_DMA_HANDLER_T handler) -{ - int ret; - - if (set_bool_flag(&in_use[HAL_SPI_ID_INTERNAL])) { - return -31; - } - - ret = hal_spi_dma_recv_id(HAL_SPI_ID_INTERNAL, cmd, data, len, handler); - - if (ret || handler == NULL) { - clear_bool_flag(&in_use[HAL_SPI_ID_INTERNAL]); - } - - return ret; -} - -void hal_ispi_stop_dma_send(void) -{ - hal_spi_stop_dma_send_id(HAL_SPI_ID_INTERNAL); -} - -void hal_ispi_stop_dma_recv(void) -{ - hal_spi_stop_dma_recv_id(HAL_SPI_ID_INTERNAL); +void hal_ispi_stop_dma_recv(void) { + hal_spi_stop_dma_recv_id(HAL_SPI_ID_INTERNAL); } #ifdef CHIP_HAS_SPI @@ -1271,156 +1276,146 @@ void hal_ispi_stop_dma_recv(void) // SPI peripheral functions //------------------------------------------------------------ -int hal_spi_open(const struct HAL_SPI_CFG_T *cfg) -{ - int ret; - uint32_t lock; +int hal_spi_open(const struct HAL_SPI_CFG_T *cfg) { + int ret; + uint32_t lock; - if (cfg->cs >= HAL_SPI_CS_QTY) { - return -1; - } + if (cfg->cs >= HAL_SPI_CS_QTY) { + return -1; + } - lock = int_lock(); + lock = int_lock(); - ret = hal_spi_open_id(HAL_SPI_ID_0, cfg, &spi0_ctrl[cfg->cs]); + ret = hal_spi_open_id(HAL_SPI_ID_0, cfg, &spi0_ctrl[cfg->cs]); #if (CHIP_SPI_VER >= 2) - if (ret == 0) { - spi0_cs = cfg->cs; - } + if (ret == 0) { + spi0_cs = cfg->cs; + } #endif - int_unlock(lock); + int_unlock(lock); - return ret; + return ret; } -int hal_spi_close(uint32_t cs) -{ - int ret; - uint32_t lock; +int hal_spi_close(uint32_t cs) { + int ret; + uint32_t lock; - lock = int_lock(); + lock = int_lock(); - ret = hal_spi_close_id(HAL_SPI_ID_0, cs); + ret = hal_spi_close_id(HAL_SPI_ID_0, cs); #if (CHIP_SPI_VER >= 2) - if (ret == 0 && spi0_cs == cs) { - uint32_t lowest_cs; + if (ret == 0 && spi0_cs == cs) { + uint32_t lowest_cs; - lowest_cs = __CLZ(__RBIT(spi_cs_map[HAL_SPI_ID_0])); - if (lowest_cs < HAL_SPI_CS_QTY) { - hal_spi_activate_cs_id(HAL_SPI_ID_0, lowest_cs); - } else { - lowest_cs = HAL_SPI_CS_0; - } - spi0_cs = lowest_cs; + lowest_cs = __CLZ(__RBIT(spi_cs_map[HAL_SPI_ID_0])); + if (lowest_cs < HAL_SPI_CS_QTY) { + hal_spi_activate_cs_id(HAL_SPI_ID_0, lowest_cs); + } else { + lowest_cs = HAL_SPI_CS_0; } + spi0_cs = lowest_cs; + } #endif - int_unlock(lock); + int_unlock(lock); - return ret; + return ret; } -int hal_spi_activate_cs(uint32_t cs) -{ - return hal_spi_activate_cs_id(HAL_SPI_ID_0, cs); +int hal_spi_activate_cs(uint32_t cs) { + return hal_spi_activate_cs_id(HAL_SPI_ID_0, cs); } -int hal_spi_busy(void) -{ - return hal_spi_busy_id(HAL_SPI_ID_0); +int hal_spi_busy(void) { return hal_spi_busy_id(HAL_SPI_ID_0); } + +int hal_spi_send(const void *data, uint32_t len) { + int ret; + + if (set_bool_flag(&in_use[HAL_SPI_ID_0])) { + return -31; + } + + ret = hal_spi_send_id(HAL_SPI_ID_0, data, len); + + clear_bool_flag(&in_use[HAL_SPI_ID_0]); + + return ret; } -int hal_spi_send(const void *data, uint32_t len) -{ - int ret; +int hal_spi_recv(const void *cmd, void *data, uint32_t len) { + int ret; - if (set_bool_flag(&in_use[HAL_SPI_ID_0])) { - return -31; - } + if (set_bool_flag(&in_use[HAL_SPI_ID_0])) { + return -31; + } - ret = hal_spi_send_id(HAL_SPI_ID_0, data, len); + hal_spi_set_xfer_type_id(HAL_SPI_ID_0, &spi0_ctrl[spi0_cs], + HAL_SPI_XFER_TYPE_RECV); + ret = hal_spi_recv_id(HAL_SPI_ID_0, cmd, data, len); + hal_spi_set_xfer_type_id(HAL_SPI_ID_0, &spi0_ctrl[spi0_cs], + HAL_SPI_XFER_TYPE_SEND); + + clear_bool_flag(&in_use[HAL_SPI_ID_0]); + + return ret; +} + +int hal_spi_dma_send(const void *data, uint32_t len, + HAL_SPI_DMA_HANDLER_T handler) { + int ret; + + if (set_bool_flag(&in_use[HAL_SPI_ID_0])) { + return -31; + } + + ret = hal_spi_dma_send_id(HAL_SPI_ID_0, data, len, handler); + + if (ret || handler == NULL) { + clear_bool_flag(&in_use[HAL_SPI_ID_0]); + } + + return ret; +} + +int hal_spi_dma_recv(const void *cmd, void *data, uint32_t len, + HAL_SPI_DMA_HANDLER_T handler) { + int ret; + + if (set_bool_flag(&in_use[HAL_SPI_ID_0])) { + return -31; + } + + hal_spi_set_xfer_type_id(HAL_SPI_ID_0, &spi0_ctrl[spi0_cs], + HAL_SPI_XFER_TYPE_RECV); + + ret = hal_spi_dma_recv_id(HAL_SPI_ID_0, cmd, data, len, handler); + + if (ret || handler == NULL) { + hal_spi_set_xfer_type_id(HAL_SPI_ID_0, &spi0_ctrl[spi0_cs], + HAL_SPI_XFER_TYPE_SEND); clear_bool_flag(&in_use[HAL_SPI_ID_0]); + } - return ret; + return ret; } -int hal_spi_recv(const void *cmd, void *data, uint32_t len) -{ - int ret; +void hal_spi_stop_dma_send(void) { hal_spi_stop_dma_send_id(HAL_SPI_ID_0); } - if (set_bool_flag(&in_use[HAL_SPI_ID_0])) { - return -31; - } +void hal_spi_stop_dma_recv(void) { hal_spi_stop_dma_recv_id(HAL_SPI_ID_0); } - hal_spi_set_xfer_type_id(HAL_SPI_ID_0, &spi0_ctrl[spi0_cs], HAL_SPI_XFER_TYPE_RECV); - ret = hal_spi_recv_id(HAL_SPI_ID_0, cmd, data, len); - hal_spi_set_xfer_type_id(HAL_SPI_ID_0, &spi0_ctrl[spi0_cs], HAL_SPI_XFER_TYPE_SEND); - - clear_bool_flag(&in_use[HAL_SPI_ID_0]); - - return ret; +int hal_spi_enable_and_send(const struct HAL_SPI_CTRL_T *ctrl, const void *data, + uint32_t len) { + return hal_spi_enable_and_send_id(HAL_SPI_ID_0, ctrl, data, len); } -int hal_spi_dma_send(const void *data, uint32_t len, HAL_SPI_DMA_HANDLER_T handler) -{ - int ret; - - if (set_bool_flag(&in_use[HAL_SPI_ID_0])) { - return -31; - } - - ret = hal_spi_dma_send_id(HAL_SPI_ID_0, data, len, handler); - - if (ret || handler == NULL) { - clear_bool_flag(&in_use[HAL_SPI_ID_0]); - } - - return ret; -} - -int hal_spi_dma_recv(const void *cmd, void *data, uint32_t len, HAL_SPI_DMA_HANDLER_T handler) -{ - int ret; - - if (set_bool_flag(&in_use[HAL_SPI_ID_0])) { - return -31; - } - - hal_spi_set_xfer_type_id(HAL_SPI_ID_0, &spi0_ctrl[spi0_cs], HAL_SPI_XFER_TYPE_RECV); - - ret = hal_spi_dma_recv_id(HAL_SPI_ID_0, cmd, data, len, handler); - - if (ret || handler == NULL) { - hal_spi_set_xfer_type_id(HAL_SPI_ID_0, &spi0_ctrl[spi0_cs], HAL_SPI_XFER_TYPE_SEND); - - clear_bool_flag(&in_use[HAL_SPI_ID_0]); - } - - return ret; -} - -void hal_spi_stop_dma_send(void) -{ - hal_spi_stop_dma_send_id(HAL_SPI_ID_0); -} - -void hal_spi_stop_dma_recv(void) -{ - hal_spi_stop_dma_recv_id(HAL_SPI_ID_0); -} - -int hal_spi_enable_and_send(const struct HAL_SPI_CTRL_T *ctrl, const void *data, uint32_t len) -{ - return hal_spi_enable_and_send_id(HAL_SPI_ID_0, ctrl, data, len); -} - -int hal_spi_enable_and_recv(const struct HAL_SPI_CTRL_T *ctrl, const void *cmd, void *data, uint32_t len) -{ - return hal_spi_enable_and_recv_id(HAL_SPI_ID_0, ctrl, cmd, data, len); +int hal_spi_enable_and_recv(const struct HAL_SPI_CTRL_T *ctrl, const void *cmd, + void *data, uint32_t len) { + return hal_spi_enable_and_recv_id(HAL_SPI_ID_0, ctrl, cmd, data, len); } #endif // CHIP_HAS_SPI @@ -1429,180 +1424,172 @@ int hal_spi_enable_and_recv(const struct HAL_SPI_CTRL_T *ctrl, const void *cmd, // SPI LCD functions //------------------------------------------------------------ -int hal_spilcd_open(const struct HAL_SPI_CFG_T *cfg) -{ - int ret; - uint32_t lock; +int hal_spilcd_open(const struct HAL_SPI_CFG_T *cfg) { + int ret; + uint32_t lock; - if (cfg->cs >= HAL_SPI_CS_QTY) { - return -1; - } + if (cfg->cs >= HAL_SPI_CS_QTY) { + return -1; + } - lock = int_lock(); + lock = int_lock(); - ret = hal_spi_open_id(HAL_SPI_ID_SLCD, cfg, &spilcd_ctrl[cfg->cs]); + ret = hal_spi_open_id(HAL_SPI_ID_SLCD, cfg, &spilcd_ctrl[cfg->cs]); #if (CHIP_SPI_VER >= 2) - if (ret == 0) { - spilcd_cs = cfg->cs; - } + if (ret == 0) { + spilcd_cs = cfg->cs; + } #endif - int_unlock(lock); + int_unlock(lock); - return ret; + return ret; } -int hal_spilcd_close(uint32_t cs) -{ - int ret; - uint32_t lock; +int hal_spilcd_close(uint32_t cs) { + int ret; + uint32_t lock; - lock = int_lock(); + lock = int_lock(); - ret = hal_spi_close_id(HAL_SPI_ID_SLCD, cs); + ret = hal_spi_close_id(HAL_SPI_ID_SLCD, cs); #if (CHIP_SPI_VER >= 2) - if (ret == 0 && spilcd_cs == cs) { - uint32_t lowest_cs; + if (ret == 0 && spilcd_cs == cs) { + uint32_t lowest_cs; - lowest_cs = __CLZ(__RBIT(spi_cs_map[HAL_SPI_ID_SLCD])); - if (lowest_cs < HAL_SPI_CS_QTY) { - hal_spi_activate_cs_id(HAL_SPI_ID_SLCD, lowest_cs); - } else { - lowest_cs = HAL_SPI_CS_0; - } - spilcd_cs = lowest_cs; + lowest_cs = __CLZ(__RBIT(spi_cs_map[HAL_SPI_ID_SLCD])); + if (lowest_cs < HAL_SPI_CS_QTY) { + hal_spi_activate_cs_id(HAL_SPI_ID_SLCD, lowest_cs); + } else { + lowest_cs = HAL_SPI_CS_0; } + spilcd_cs = lowest_cs; + } #endif - int_unlock(lock); + int_unlock(lock); - return ret; + return ret; } -int hal_spilcd_activate_cs(uint32_t cs) -{ - return hal_spi_activate_cs_id(HAL_SPI_ID_SLCD, cs); +int hal_spilcd_activate_cs(uint32_t cs) { + return hal_spi_activate_cs_id(HAL_SPI_ID_SLCD, cs); } -int hal_spilcd_busy(void) -{ - return hal_spi_busy_id(HAL_SPI_ID_SLCD); +int hal_spilcd_busy(void) { return hal_spi_busy_id(HAL_SPI_ID_SLCD); } + +int hal_spilcd_send(const void *data, uint32_t len) { + int ret; + + if (set_bool_flag(&in_use[HAL_SPI_ID_SLCD])) { + return -31; + } + + ret = hal_spi_send_id(HAL_SPI_ID_SLCD, data, len); + + clear_bool_flag(&in_use[HAL_SPI_ID_SLCD]); + + return ret; } -int hal_spilcd_send(const void *data, uint32_t len) -{ - int ret; +int hal_spilcd_recv(const void *cmd, void *data, uint32_t len) { + int ret; - if (set_bool_flag(&in_use[HAL_SPI_ID_SLCD])) { - return -31; - } + if (set_bool_flag(&in_use[HAL_SPI_ID_SLCD])) { + return -31; + } - ret = hal_spi_send_id(HAL_SPI_ID_SLCD, data, len); + hal_spi_set_xfer_type_id(HAL_SPI_ID_SLCD, &spilcd_ctrl[spilcd_cs], + HAL_SPI_XFER_TYPE_RECV); + ret = hal_spi_recv_id(HAL_SPI_ID_SLCD, cmd, data, len); + hal_spi_set_xfer_type_id(HAL_SPI_ID_SLCD, &spilcd_ctrl[spilcd_cs], + HAL_SPI_XFER_TYPE_SEND); + + clear_bool_flag(&in_use[HAL_SPI_ID_SLCD]); + + return ret; +} + +int hal_spilcd_dma_send(const void *data, uint32_t len, + HAL_SPI_DMA_HANDLER_T handler) { + int ret; + + if (set_bool_flag(&in_use[HAL_SPI_ID_SLCD])) { + return -31; + } + + ret = hal_spi_dma_send_id(HAL_SPI_ID_SLCD, data, len, handler); + + if (ret || handler == NULL) { + clear_bool_flag(&in_use[HAL_SPI_ID_SLCD]); + } + + return ret; +} + +int hal_spilcd_dma_recv(const void *cmd, void *data, uint32_t len, + HAL_SPI_DMA_HANDLER_T handler) { + int ret; + + if (set_bool_flag(&in_use[HAL_SPI_ID_SLCD])) { + return -31; + } + + hal_spi_set_xfer_type_id(HAL_SPI_ID_SLCD, &spilcd_ctrl[spilcd_cs], + HAL_SPI_XFER_TYPE_RECV); + + ret = hal_spi_dma_recv_id(HAL_SPI_ID_SLCD, cmd, data, len, handler); + + if (ret || handler == NULL) { + hal_spi_set_xfer_type_id(HAL_SPI_ID_SLCD, &spilcd_ctrl[spilcd_cs], + HAL_SPI_XFER_TYPE_SEND); clear_bool_flag(&in_use[HAL_SPI_ID_SLCD]); + } - return ret; + return ret; } -int hal_spilcd_recv(const void *cmd, void *data, uint32_t len) -{ - int ret; - - if (set_bool_flag(&in_use[HAL_SPI_ID_SLCD])) { - return -31; - } - - hal_spi_set_xfer_type_id(HAL_SPI_ID_SLCD, &spilcd_ctrl[spilcd_cs], HAL_SPI_XFER_TYPE_RECV); - ret = hal_spi_recv_id(HAL_SPI_ID_SLCD, cmd, data, len); - hal_spi_set_xfer_type_id(HAL_SPI_ID_SLCD, &spilcd_ctrl[spilcd_cs], HAL_SPI_XFER_TYPE_SEND); - - clear_bool_flag(&in_use[HAL_SPI_ID_SLCD]); - - return ret; +void hal_spilcd_stop_dma_send(void) { + hal_spi_stop_dma_send_id(HAL_SPI_ID_SLCD); } -int hal_spilcd_dma_send(const void *data, uint32_t len, HAL_SPI_DMA_HANDLER_T handler) -{ - int ret; - - if (set_bool_flag(&in_use[HAL_SPI_ID_SLCD])) { - return -31; - } - - ret = hal_spi_dma_send_id(HAL_SPI_ID_SLCD, data, len, handler); - - if (ret || handler == NULL) { - clear_bool_flag(&in_use[HAL_SPI_ID_SLCD]); - } - - return ret; +void hal_spilcd_stop_dma_recv(void) { + hal_spi_stop_dma_recv_id(HAL_SPI_ID_SLCD); } -int hal_spilcd_dma_recv(const void *cmd, void *data, uint32_t len, HAL_SPI_DMA_HANDLER_T handler) -{ - int ret; +int hal_spilcd_set_data_mode(void) { + if (set_bool_flag(&in_use[HAL_SPI_ID_SLCD])) { + return -31; + } - if (set_bool_flag(&in_use[HAL_SPI_ID_SLCD])) { - return -31; - } + spi[HAL_SPI_ID_SLCD]->SSPCR1 |= SPI_LCD_DC_DATA; - hal_spi_set_xfer_type_id(HAL_SPI_ID_SLCD, &spilcd_ctrl[spilcd_cs], HAL_SPI_XFER_TYPE_RECV); - - ret = hal_spi_dma_recv_id(HAL_SPI_ID_SLCD, cmd, data, len, handler); - - if (ret || handler == NULL) { - hal_spi_set_xfer_type_id(HAL_SPI_ID_SLCD, &spilcd_ctrl[spilcd_cs], HAL_SPI_XFER_TYPE_SEND); - - clear_bool_flag(&in_use[HAL_SPI_ID_SLCD]); - } - - return ret; + clear_bool_flag(&in_use[HAL_SPI_ID_SLCD]); + return 0; } -void hal_spilcd_stop_dma_send(void) -{ - hal_spi_stop_dma_send_id(HAL_SPI_ID_SLCD); +int hal_spilcd_set_cmd_mode(void) { + if (set_bool_flag(&in_use[HAL_SPI_ID_SLCD])) { + return -31; + } + + spi[HAL_SPI_ID_SLCD]->SSPCR1 &= ~SPI_LCD_DC_DATA; + + clear_bool_flag(&in_use[HAL_SPI_ID_SLCD]); + return 0; } -void hal_spilcd_stop_dma_recv(void) -{ - hal_spi_stop_dma_recv_id(HAL_SPI_ID_SLCD); +int hal_spilcd_enable_and_send(const struct HAL_SPI_CTRL_T *ctrl, + const void *data, uint32_t len) { + return hal_spi_enable_and_send_id(HAL_SPI_ID_SLCD, ctrl, data, len); } -int hal_spilcd_set_data_mode(void) -{ - if (set_bool_flag(&in_use[HAL_SPI_ID_SLCD])) { - return -31; - } - - spi[HAL_SPI_ID_SLCD]->SSPCR1 |= SPI_LCD_DC_DATA; - - clear_bool_flag(&in_use[HAL_SPI_ID_SLCD]); - return 0; -} - -int hal_spilcd_set_cmd_mode(void) -{ - if (set_bool_flag(&in_use[HAL_SPI_ID_SLCD])) { - return -31; - } - - spi[HAL_SPI_ID_SLCD]->SSPCR1 &= ~SPI_LCD_DC_DATA; - - clear_bool_flag(&in_use[HAL_SPI_ID_SLCD]); - return 0; -} - -int hal_spilcd_enable_and_send(const struct HAL_SPI_CTRL_T *ctrl, const void *data, uint32_t len) -{ - return hal_spi_enable_and_send_id(HAL_SPI_ID_SLCD, ctrl, data, len); -} - -int hal_spilcd_enable_and_recv(const struct HAL_SPI_CTRL_T *ctrl, const void *cmd, void *data, uint32_t len) -{ - return hal_spi_enable_and_recv_id(HAL_SPI_ID_SLCD, ctrl, cmd, data, len); +int hal_spilcd_enable_and_recv(const struct HAL_SPI_CTRL_T *ctrl, + const void *cmd, void *data, uint32_t len) { + return hal_spi_enable_and_recv_id(HAL_SPI_ID_SLCD, ctrl, cmd, data, len); } #endif // CHIP_HAS_SPILCD @@ -1611,58 +1598,51 @@ int hal_spilcd_enable_and_recv(const struct HAL_SPI_CTRL_T *ctrl, const void *cm // SPI PHY functions //------------------------------------------------------------ -int hal_spiphy_open(const struct HAL_SPI_CFG_T *cfg) -{ - SPI_ASSERT(cfg->tx_bits == cfg->rx_bits && cfg->rx_frame_bits == 0, "SPIPHY: Bad bits cfg"); +int hal_spiphy_open(const struct HAL_SPI_CFG_T *cfg) { + SPI_ASSERT(cfg->tx_bits == cfg->rx_bits && cfg->rx_frame_bits == 0, + "SPIPHY: Bad bits cfg"); - return hal_spi_open_id(HAL_SPI_ID_PHY, cfg, NULL); + return hal_spi_open_id(HAL_SPI_ID_PHY, cfg, NULL); } -int hal_spiphy_close(uint32_t cs) -{ - return hal_spi_close_id(HAL_SPI_ID_PHY, cs); +int hal_spiphy_close(uint32_t cs) { + return hal_spi_close_id(HAL_SPI_ID_PHY, cs); } -void hal_spiphy_activate_cs(uint32_t cs) -{ - SPI_ASSERT(cs < HAL_SPI_CS_QTY, "SPIPHY: SPI cs bad: %d", cs); +void hal_spiphy_activate_cs(uint32_t cs) { + SPI_ASSERT(cs < HAL_SPI_CS_QTY, "SPIPHY: SPI cs bad: %d", cs); - hal_spi_set_cs_id(HAL_SPI_ID_PHY, cs); + hal_spi_set_cs_id(HAL_SPI_ID_PHY, cs); } -int hal_spiphy_busy(void) -{ - return hal_spi_busy_id(HAL_SPI_ID_PHY); +int hal_spiphy_busy(void) { return hal_spi_busy_id(HAL_SPI_ID_PHY); } + +int hal_spiphy_send(const void *data, uint32_t len) { + int ret; + + if (set_bool_flag(&in_use[HAL_SPI_ID_PHY])) { + return -31; + } + + ret = hal_spi_send_id(HAL_SPI_ID_PHY, data, len); + + clear_bool_flag(&in_use[HAL_SPI_ID_PHY]); + + return ret; } -int hal_spiphy_send(const void *data, uint32_t len) -{ - int ret; +int hal_spiphy_recv(const void *cmd, void *data, uint32_t len) { + int ret; - if (set_bool_flag(&in_use[HAL_SPI_ID_PHY])) { - return -31; - } + if (set_bool_flag(&in_use[HAL_SPI_ID_PHY])) { + return -31; + } - ret = hal_spi_send_id(HAL_SPI_ID_PHY, data, len); + ret = hal_spi_recv_id(HAL_SPI_ID_PHY, cmd, data, len); - clear_bool_flag(&in_use[HAL_SPI_ID_PHY]); + clear_bool_flag(&in_use[HAL_SPI_ID_PHY]); - return ret; -} - -int hal_spiphy_recv(const void *cmd, void *data, uint32_t len) -{ - int ret; - - if (set_bool_flag(&in_use[HAL_SPI_ID_PHY])) { - return -31; - } - - ret = hal_spi_recv_id(HAL_SPI_ID_PHY, cmd, data, len); - - clear_bool_flag(&in_use[HAL_SPI_ID_PHY]); - - return ret; + return ret; } #endif // CHIP_HAS_SPIPHY @@ -1671,62 +1651,55 @@ int hal_spiphy_recv(const void *cmd, void *data, uint32_t len) // SPI DPD functions //------------------------------------------------------------ -int hal_spidpd_open(const struct HAL_SPI_CFG_T *cfg) -{ - SPI_ASSERT(cfg->rx_frame_bits == 0, "SPIDPD: Bad bits cfg"); +int hal_spidpd_open(const struct HAL_SPI_CFG_T *cfg) { + SPI_ASSERT(cfg->rx_frame_bits == 0, "SPIDPD: Bad bits cfg"); - return hal_spi_open_id(HAL_SPI_ID_DPD, cfg, &spidpd_ctrl); + return hal_spi_open_id(HAL_SPI_ID_DPD, cfg, &spidpd_ctrl); } -int hal_spidpd_close(uint32_t cs) -{ - return hal_spi_close_id(HAL_SPI_ID_DPD, cs); +int hal_spidpd_close(uint32_t cs) { + return hal_spi_close_id(HAL_SPI_ID_DPD, cs); } -void hal_spidpd_activate_cs(uint32_t cs) -{ - SPI_ASSERT(cs < HAL_SPI_CS_QTY, "SPIDPD: SPI cs bad: %d", cs); +void hal_spidpd_activate_cs(uint32_t cs) { + SPI_ASSERT(cs < HAL_SPI_CS_QTY, "SPIDPD: SPI cs bad: %d", cs); - hal_spi_set_cs_id(HAL_SPI_ID_DPD, cs); + hal_spi_set_cs_id(HAL_SPI_ID_DPD, cs); } -int hal_spidpd_busy(void) -{ - return hal_spi_busy_id(HAL_SPI_ID_DPD); +int hal_spidpd_busy(void) { return hal_spi_busy_id(HAL_SPI_ID_DPD); } + +int hal_spidpd_send(const void *data, uint32_t len) { + int ret; + + if (set_bool_flag(&in_use[HAL_SPI_ID_DPD])) { + return -31; + } + + ret = hal_spi_send_id(HAL_SPI_ID_DPD, data, len); + + clear_bool_flag(&in_use[HAL_SPI_ID_DPD]); + + return ret; } -int hal_spidpd_send(const void *data, uint32_t len) -{ - int ret; +int hal_spidpd_recv(const void *cmd, void *data, uint32_t len) { + int ret; - if (set_bool_flag(&in_use[HAL_SPI_ID_DPD])) { - return -31; - } + if (set_bool_flag(&in_use[HAL_SPI_ID_DPD])) { + return -31; + } - ret = hal_spi_send_id(HAL_SPI_ID_DPD, data, len); + hal_spi_set_xfer_type_id(HAL_SPI_ID_DPD, &spidpd_ctrl, + HAL_SPI_XFER_TYPE_RECV); + ret = hal_spi_recv_id(HAL_SPI_ID_DPD, cmd, data, len); + hal_spi_set_xfer_type_id(HAL_SPI_ID_DPD, &spidpd_ctrl, + HAL_SPI_XFER_TYPE_SEND); - clear_bool_flag(&in_use[HAL_SPI_ID_DPD]); + clear_bool_flag(&in_use[HAL_SPI_ID_DPD]); - return ret; -} - -int hal_spidpd_recv(const void *cmd, void *data, uint32_t len) -{ - int ret; - - if (set_bool_flag(&in_use[HAL_SPI_ID_DPD])) { - return -31; - } - - hal_spi_set_xfer_type_id(HAL_SPI_ID_DPD, &spidpd_ctrl, HAL_SPI_XFER_TYPE_RECV); - ret = hal_spi_recv_id(HAL_SPI_ID_DPD, cmd, data, len); - hal_spi_set_xfer_type_id(HAL_SPI_ID_DPD, &spidpd_ctrl, HAL_SPI_XFER_TYPE_SEND); - - clear_bool_flag(&in_use[HAL_SPI_ID_DPD]); - - return ret; + return ret; } #endif // CHIP_HAS_SPIDPD #endif // !SPI_ROM_ONLY - diff --git a/platform/hal/hal_sysfreq.c b/platform/hal/hal_sysfreq.c index 8b2e332..eb10ce8 100644 --- a/platform/hal/hal_sysfreq.c +++ b/platform/hal/hal_sysfreq.c @@ -13,148 +13,141 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" #include "hal_sysfreq.h" +#include "cmsis.h" #include "hal_location.h" #include "hal_trace.h" -#include "cmsis.h" +#include "plat_types.h" #ifndef ROM_BUILD #include "pmu.h" #endif static uint32_t BOOT_BSS_LOC sysfreq_bundle[(HAL_SYSFREQ_USER_QTY + 3) / 4]; -static uint8_t * const sysfreq_per_user = (uint8_t *)&sysfreq_bundle[0]; +static uint8_t *const sysfreq_per_user = (uint8_t *)&sysfreq_bundle[0]; static enum HAL_SYSFREQ_USER_T BOOT_DATA_LOC top_user = HAL_SYSFREQ_USER_QTY; static enum HAL_CMU_FREQ_T BOOT_DATA_LOC min_sysfreq = HAL_CMU_FREQ_26M; -static enum HAL_CMU_FREQ_T hal_sysfreq_revise_freq(enum HAL_CMU_FREQ_T freq) -{ - return freq > min_sysfreq ? freq : min_sysfreq; +static enum HAL_CMU_FREQ_T hal_sysfreq_revise_freq(enum HAL_CMU_FREQ_T freq) { + return freq > min_sysfreq ? freq : min_sysfreq; } -void hal_sysfreq_set_min_freq(enum HAL_CMU_FREQ_T freq) -{ - uint32_t lock; +void hal_sysfreq_set_min_freq(enum HAL_CMU_FREQ_T freq) { + uint32_t lock; - lock = int_lock(); + lock = int_lock(); - if (min_sysfreq < freq) { - min_sysfreq = freq; - if (min_sysfreq > hal_sysfreq_get()) { - hal_cmu_sys_set_freq(min_sysfreq); + if (min_sysfreq < freq) { + min_sysfreq = freq; + if (min_sysfreq > hal_sysfreq_get()) { + hal_cmu_sys_set_freq(min_sysfreq); + } + } + + int_unlock(lock); +} + +int hal_sysfreq_req(enum HAL_SYSFREQ_USER_T user, enum HAL_CMU_FREQ_T freq) { + uint32_t lock; + enum HAL_CMU_FREQ_T cur_sys_freq; + int i; + + if (user >= HAL_SYSFREQ_USER_QTY) { + return 1; + } + if (freq >= HAL_CMU_FREQ_QTY) { + return 2; + } + + lock = int_lock(); + + cur_sys_freq = hal_sysfreq_get(); + + sysfreq_per_user[user] = freq; + + if (freq == cur_sys_freq) { + top_user = user; + } else if (freq > cur_sys_freq) { + top_user = user; + freq = hal_sysfreq_revise_freq(freq); +#ifndef ROM_BUILD + pmu_sys_freq_config(freq); +#ifdef ULTRA_LOW_POWER + // Enable PLL if required + hal_cmu_low_freq_mode_disable(hal_sysfreq_revise_freq(cur_sys_freq), freq); +#endif +#endif + hal_cmu_sys_set_freq(freq); + } else /* if (freq < cur_sys_freq) */ { + if (top_user == user || top_user == HAL_SYSFREQ_USER_QTY) { + if (top_user == user) { + freq = sysfreq_per_user[0]; + user = 0; + for (i = 1; i < HAL_SYSFREQ_USER_QTY; i++) { + if (freq < sysfreq_per_user[i]) { + freq = sysfreq_per_user[i]; + user = i; + } } - } - - int_unlock(lock); -} - -int hal_sysfreq_req(enum HAL_SYSFREQ_USER_T user, enum HAL_CMU_FREQ_T freq) -{ - uint32_t lock; - enum HAL_CMU_FREQ_T cur_sys_freq; - int i; - - if (user >= HAL_SYSFREQ_USER_QTY) { - return 1; - } - if (freq >= HAL_CMU_FREQ_QTY) { - return 2; - } - - lock = int_lock(); - - cur_sys_freq = hal_sysfreq_get(); - - sysfreq_per_user[user] = freq; - - if (freq == cur_sys_freq) { - top_user = user; - } else if (freq > cur_sys_freq) { - top_user = user; + } + top_user = user; + if (freq != cur_sys_freq) { freq = hal_sysfreq_revise_freq(freq); -#ifndef ROM_BUILD - pmu_sys_freq_config(freq); -#ifdef ULTRA_LOW_POWER - // Enable PLL if required - hal_cmu_low_freq_mode_disable(hal_sysfreq_revise_freq(cur_sys_freq), freq); -#endif -#endif hal_cmu_sys_set_freq(freq); - } else /* if (freq < cur_sys_freq) */ { - if (top_user == user || top_user == HAL_SYSFREQ_USER_QTY) { - if (top_user == user) { - freq = sysfreq_per_user[0]; - user = 0; - for (i = 1; i < HAL_SYSFREQ_USER_QTY; i++) { - if (freq < sysfreq_per_user[i]) { - freq = sysfreq_per_user[i]; - user = i; - } - } - } - top_user = user; - if (freq != cur_sys_freq) { - freq = hal_sysfreq_revise_freq(freq); - hal_cmu_sys_set_freq(freq); #ifndef ROM_BUILD #ifdef ULTRA_LOW_POWER - // Disable PLL if capable - hal_cmu_low_freq_mode_enable(hal_sysfreq_revise_freq(cur_sys_freq), freq); + // Disable PLL if capable + hal_cmu_low_freq_mode_enable(hal_sysfreq_revise_freq(cur_sys_freq), + freq); #endif - pmu_sys_freq_config(freq); + pmu_sys_freq_config(freq); #endif - } - } + } } + } - int_unlock(lock); + int_unlock(lock); - return 0; + return 0; } -enum HAL_CMU_FREQ_T hal_sysfreq_get(void) -{ - if (top_user < HAL_SYSFREQ_USER_QTY) { - return sysfreq_per_user[top_user]; - } else { - return hal_cmu_sys_get_freq(); - } +enum HAL_CMU_FREQ_T hal_sysfreq_get(void) { + if (top_user < HAL_SYSFREQ_USER_QTY) { + return sysfreq_per_user[top_user]; + } else { + return hal_cmu_sys_get_freq(); + } } -enum HAL_CMU_FREQ_T hal_sysfreq_get_hw_freq(void) -{ - if (top_user < HAL_SYSFREQ_USER_QTY) { - return hal_sysfreq_revise_freq(sysfreq_per_user[top_user]); - } else { - return hal_cmu_sys_get_freq(); - } +enum HAL_CMU_FREQ_T hal_sysfreq_get_hw_freq(void) { + if (top_user < HAL_SYSFREQ_USER_QTY) { + return hal_sysfreq_revise_freq(sysfreq_per_user[top_user]); + } else { + return hal_cmu_sys_get_freq(); + } } -int hal_sysfreq_busy(void) -{ - int i; +int hal_sysfreq_busy(void) { + int i; - for (i = 0; i < ARRAY_SIZE(sysfreq_bundle); i++) { - if (sysfreq_bundle[i] != 0) { - return 1; - } + for (i = 0; i < ARRAY_SIZE(sysfreq_bundle); i++) { + if (sysfreq_bundle[i] != 0) { + return 1; } + } - return 0; + return 0; } -void hal_sysfreq_print(void) -{ - int i; +void hal_sysfreq_print(void) { + int i; - for (i = 0; i < HAL_SYSFREQ_USER_QTY; i++) { - if (sysfreq_per_user[i] != 0) { - TRACE(2,"*** SYSFREQ user=%d freq=%d", i, sysfreq_per_user[i]); - } + for (i = 0; i < HAL_SYSFREQ_USER_QTY; i++) { + if (sysfreq_per_user[i] != 0) { + TRACE(2, "*** SYSFREQ user=%d freq=%d", i, sysfreq_per_user[i]); } - TRACE(1,"*** SYSFREQ top_user=%d", top_user); + } + TRACE(1, "*** SYSFREQ top_user=%d", top_user); } - diff --git a/platform/hal/hal_tdm.c b/platform/hal/hal_tdm.c index af6632a..f04620d 100644 --- a/platform/hal/hal_tdm.c +++ b/platform/hal/hal_tdm.c @@ -13,20 +13,20 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "hal_tdm.h" +#include "hal_dma.h" +#include "hal_i2s.h" +#include "hal_trace.h" #include #include #include -#include "hal_i2s.h" -#include "hal_trace.h" -#include "hal_dma.h" -#include "hal_tdm.h" #ifndef CHIP_HAS_TDM #include "hal_i2s_tdm.h" #endif #if 0 -#define TDM_TRACE TRACE -#define TDM_DUMP8 DUMP8 +#define TDM_TRACE TRACE +#define TDM_DUMP8 DUMP8 #else #define TDM_TRACE(n, str, ...) #define TDM_DUMP8(str, ...) @@ -34,556 +34,494 @@ #ifdef CHIP_HAS_TDM -static const char * const invalid_id = "Invalid I2S ID: %d\n"; -static inline uint32_t _tdm_get_reg_base(enum HAL_I2S_ID_T id) -{ - ASSERT(id < HAL_I2S_ID_QTY, invalid_id, id); - switch(id) { - case HAL_I2S_ID_0: - return (I2S0_BASE | I2SIP_TDM_CTRL_REG_OFFSET); - break; +static const char *const invalid_id = "Invalid I2S ID: %d\n"; +static inline uint32_t _tdm_get_reg_base(enum HAL_I2S_ID_T id) { + ASSERT(id < HAL_I2S_ID_QTY, invalid_id, id); + switch (id) { + case HAL_I2S_ID_0: + return (I2S0_BASE | I2SIP_TDM_CTRL_REG_OFFSET); + break; #if defined(CHIP_HAS_I2S) && (CHIP_HAS_I2S > 1) - case HAL_I2S_ID_1: - return (I2S1_BASE | I2SIP_TDM_CTRL_REG_OFFSET); - break; + case HAL_I2S_ID_1: + return (I2S1_BASE | I2SIP_TDM_CTRL_REG_OFFSET); + break; #endif - default: - break; - } - return 0; + default: + break; + } + return 0; } -static inline bool tdm_slot_cycles_in_arrays(uint8_t slot_cycles) -{ - if(slot_cycles == (uint8_t)HAL_TDM_SLOT_CYCLES_16 - || slot_cycles == (uint8_t)HAL_TDM_SLOT_CYCLES_32) - return true; - else - return false; +static inline bool tdm_slot_cycles_in_arrays(uint8_t slot_cycles) { + if (slot_cycles == (uint8_t)HAL_TDM_SLOT_CYCLES_16 || + slot_cycles == (uint8_t)HAL_TDM_SLOT_CYCLES_32) + return true; + else + return false; } -static inline bool tdm_cycles_in_arrays(uint16_t cycles) -{ - if(cycles == (uint16_t)HAL_TDM_CYCLES_16 - || cycles == (uint16_t)HAL_TDM_CYCLES_32 - || cycles == (uint16_t)HAL_TDM_CYCLES_64 - || cycles == (uint16_t)HAL_TDM_CYCLES_128 - || cycles == (uint16_t)HAL_TDM_CYCLES_256) - return true; - else - return false; +static inline bool tdm_cycles_in_arrays(uint16_t cycles) { + if (cycles == (uint16_t)HAL_TDM_CYCLES_16 || + cycles == (uint16_t)HAL_TDM_CYCLES_32 || + cycles == (uint16_t)HAL_TDM_CYCLES_64 || + cycles == (uint16_t)HAL_TDM_CYCLES_128 || + cycles == (uint16_t)HAL_TDM_CYCLES_256) + return true; + else + return false; } -static inline bool tdm_fs_cycles_in_arrays(uint16_t fs_cycles) -{ - if(fs_cycles == (uint16_t)HAL_TDM_FS_CYCLES_1 - || fs_cycles == (uint16_t)HAL_TDM_FS_CYCLES_8 - || fs_cycles == (uint16_t)HAL_TDM_FS_CYCLES_16 - || fs_cycles == (uint16_t)HAL_TDM_FS_CYCLES_32 - || fs_cycles == (uint16_t)HAL_TDM_FS_CYCLES_64 - || fs_cycles == (uint16_t)HAL_TDM_FS_CYCLES_128 - || fs_cycles == (uint16_t)HAL_TDM_FS_CYCLES_ONE_LESS) - return true; - else - return false; +static inline bool tdm_fs_cycles_in_arrays(uint16_t fs_cycles) { + if (fs_cycles == (uint16_t)HAL_TDM_FS_CYCLES_1 || + fs_cycles == (uint16_t)HAL_TDM_FS_CYCLES_8 || + fs_cycles == (uint16_t)HAL_TDM_FS_CYCLES_16 || + fs_cycles == (uint16_t)HAL_TDM_FS_CYCLES_32 || + fs_cycles == (uint16_t)HAL_TDM_FS_CYCLES_64 || + fs_cycles == (uint16_t)HAL_TDM_FS_CYCLES_128 || + fs_cycles == (uint16_t)HAL_TDM_FS_CYCLES_ONE_LESS) + return true; + else + return false; } -static void tdm_get_config(enum HAL_I2S_ID_T i2s_id,struct HAL_TDM_CONFIG_T *tdm_config) -{ - volatile uint32_t *base_addr; - uint32_t val; +static void tdm_get_config(enum HAL_I2S_ID_T i2s_id, + struct HAL_TDM_CONFIG_T *tdm_config) { + volatile uint32_t *base_addr; + uint32_t val; - base_addr = (uint32_t*)_tdm_get_reg_base(i2s_id); - val = *base_addr; + base_addr = (uint32_t *)_tdm_get_reg_base(i2s_id); + val = *base_addr; - if((val & (TDM_MODE_FS_ASSERTED_AT_LAST << TDM_MODE_FS_ASSERTED_SHIFT)) == (TDM_MODE_FS_ASSERTED_AT_LAST << TDM_MODE_FS_ASSERTED_SHIFT)) - { - tdm_config->mode = HAL_TDM_MODE_FS_ASSERTED_AT_LAST; - } - else - { - tdm_config->mode = HAL_TDM_MODE_FS_ASSERTED_AT_FIRST; - } - - if((val & (TDM_FS_EDGE_NEGEDGE << TDM_FS_EDGE_SHIFT)) == (TDM_FS_EDGE_NEGEDGE << TDM_FS_EDGE_SHIFT)) - { - tdm_config->edge = HAL_TDM_FS_EDGE_NEGEDGE; - } - else - { - tdm_config->edge = HAL_TDM_FS_EDGE_POSEDGE; - } - - if((val & (TDM_FRAME_WIDTH_16_CYCLES << TDM_FRAME_WIDTH_SHIFT)) == (TDM_FRAME_WIDTH_16_CYCLES << TDM_FRAME_WIDTH_SHIFT)) - { - tdm_config->cycles = HAL_TDM_CYCLES_16; - } - else if((val & (TDM_FRAME_WIDTH_32_CYCLES << TDM_FRAME_WIDTH_SHIFT)) == (TDM_FRAME_WIDTH_32_CYCLES << TDM_FRAME_WIDTH_SHIFT)) - { - tdm_config->cycles = HAL_TDM_CYCLES_32; - } - else if((val & (TDM_FRAME_WIDTH_64_CYCLES << TDM_FRAME_WIDTH_SHIFT)) == (TDM_FRAME_WIDTH_64_CYCLES << TDM_FRAME_WIDTH_SHIFT)) - { - tdm_config->cycles = HAL_TDM_CYCLES_64; - } - else if((val & (TDM_FRAME_WIDTH_128_CYCLES << TDM_FRAME_WIDTH_SHIFT)) == (TDM_FRAME_WIDTH_128_CYCLES << TDM_FRAME_WIDTH_SHIFT)) - { - tdm_config->cycles = HAL_TDM_CYCLES_128; - } - else if((val & (TDM_FRAME_WIDTH_256_CYCLES << TDM_FRAME_WIDTH_SHIFT)) == (TDM_FRAME_WIDTH_256_CYCLES << TDM_FRAME_WIDTH_SHIFT)) - { - tdm_config->cycles = HAL_TDM_CYCLES_256; - } - else - { - tdm_config->cycles = HAL_TDM_CYCLES_256; - } - - if((val & (TDM_FS_WIDTH_8_CYCLES << TDM_FS_WIDTH_SHIFT)) == (TDM_FS_WIDTH_8_CYCLES << TDM_FS_WIDTH_SHIFT)) - { - tdm_config->fs_cycles = HAL_TDM_FS_CYCLES_8; - } - else if((val & (TDM_FS_WIDTH_16_CYCLES << TDM_FS_WIDTH_SHIFT)) == (TDM_FS_WIDTH_16_CYCLES << TDM_FS_WIDTH_SHIFT)) - { - tdm_config->fs_cycles = HAL_TDM_FS_CYCLES_16; - } - else if((val & (TDM_FS_WIDTH_32_CYCLES << TDM_FS_WIDTH_SHIFT)) == (TDM_FS_WIDTH_32_CYCLES << TDM_FS_WIDTH_SHIFT)) - { - tdm_config->fs_cycles = HAL_TDM_FS_CYCLES_32; - } - else if((val & (TDM_FS_WIDTH_64_CYCLES << TDM_FS_WIDTH_SHIFT)) == (TDM_FS_WIDTH_64_CYCLES << TDM_FS_WIDTH_SHIFT)) - { - tdm_config->fs_cycles = HAL_TDM_FS_CYCLES_64; - } - else if((val & (TDM_FS_WIDTH_128_CYCLES << TDM_FS_WIDTH_SHIFT)) == (TDM_FS_WIDTH_128_CYCLES << TDM_FS_WIDTH_SHIFT)) - { - tdm_config->fs_cycles = HAL_TDM_FS_CYCLES_128; - } - else if((val & (TDM_FS_WIDTH_1_CYCLE << TDM_FS_WIDTH_SHIFT)) == (TDM_FS_WIDTH_1_CYCLE << TDM_FS_WIDTH_SHIFT)) - { - tdm_config->fs_cycles = HAL_TDM_FS_CYCLES_ONE_LESS; - } - else - { - tdm_config->fs_cycles = HAL_TDM_FS_CYCLES_ONE_LESS; - } - - if((val & (TDM_SLOT_WIDTH_16_BIT << TDM_SLOT_WIDTH_SHIFT)) == (TDM_SLOT_WIDTH_16_BIT << TDM_SLOT_WIDTH_SHIFT)) - { - tdm_config->slot_cycles = HAL_TDM_SLOT_CYCLES_16; - } - else - { - tdm_config->slot_cycles = HAL_TDM_SLOT_CYCLES_32; - } - - tdm_config->data_offset = ((val >> TDM_DATA_OFFSET_SHIT) & 0x7); -} - -static void tdm_set_config(enum HAL_I2S_ID_T i2s_id,struct HAL_TDM_CONFIG_T *tdm_config) -{ - volatile uint32_t *base_addr; - uint32_t val = 0; - - base_addr = (uint32_t*)_tdm_get_reg_base(i2s_id); - ASSERT(tdm_config->mode < HAL_TDM_MODE_NUM, - "%s: mode = %d error!",__func__, tdm_config->mode); - ASSERT(tdm_config->edge < HAL_TDM_FS_EDGE_NUM, - "%s: edge = %d error!",__func__, tdm_config->edge); - ASSERT(tdm_cycles_in_arrays((uint16_t)tdm_config->cycles), - "%s: cycles = %d error!",__func__, tdm_config->cycles); - ASSERT(tdm_fs_cycles_in_arrays((uint16_t)tdm_config->fs_cycles), - "%s: fs_cycles = %d cycles = %d error!",__func__, tdm_config->fs_cycles, tdm_config->cycles); - ASSERT(tdm_slot_cycles_in_arrays((uint8_t)tdm_config->slot_cycles), - "%s: slot_cycles = %d error!",__func__, tdm_config->slot_cycles); - - if(tdm_config->mode == HAL_TDM_MODE_FS_ASSERTED_AT_LAST) { - val |= (TDM_MODE_FS_ASSERTED_AT_LAST << TDM_MODE_FS_ASSERTED_SHIFT); - } - - if(tdm_config->edge == HAL_TDM_FS_EDGE_NEGEDGE) { - val |= (TDM_FS_EDGE_NEGEDGE << TDM_FS_EDGE_SHIFT); - } - - if(tdm_config->cycles == HAL_TDM_CYCLES_16) { - val |= (TDM_FRAME_WIDTH_16_CYCLES << TDM_FRAME_WIDTH_SHIFT); - } - else if(tdm_config->cycles == HAL_TDM_CYCLES_32) { - val |= (TDM_FRAME_WIDTH_32_CYCLES << TDM_FRAME_WIDTH_SHIFT); - } - else if(tdm_config->cycles == HAL_TDM_CYCLES_64) { - val |= (TDM_FRAME_WIDTH_64_CYCLES << TDM_FRAME_WIDTH_SHIFT); - } - else if(tdm_config->cycles == HAL_TDM_CYCLES_128) { - val |= (TDM_FRAME_WIDTH_128_CYCLES << TDM_FRAME_WIDTH_SHIFT); - } - else { - val |= (TDM_FRAME_WIDTH_256_CYCLES << TDM_FRAME_WIDTH_SHIFT); - } - - if(tdm_config->fs_cycles == HAL_TDM_FS_CYCLES_8) { - val |= (TDM_FS_WIDTH_8_CYCLES << TDM_FS_WIDTH_SHIFT); - } - else if(tdm_config->fs_cycles == HAL_TDM_FS_CYCLES_16) - { - val |= (TDM_FS_WIDTH_16_CYCLES << TDM_FS_WIDTH_SHIFT); - } - else if(tdm_config->fs_cycles == HAL_TDM_FS_CYCLES_32) - { - val |= (TDM_FS_WIDTH_32_CYCLES << TDM_FS_WIDTH_SHIFT); - } - else if(tdm_config->fs_cycles == HAL_TDM_FS_CYCLES_64) - { - val |= (TDM_FS_WIDTH_64_CYCLES << TDM_FS_WIDTH_SHIFT); - } - else if(tdm_config->fs_cycles == HAL_TDM_FS_CYCLES_128) - { - val |= (TDM_FS_WIDTH_128_CYCLES << TDM_FS_WIDTH_SHIFT); - } - else - { - val |= (TDM_FS_WIDTH_FRAME_LENGTH_1_CYCLES << TDM_FS_WIDTH_SHIFT); - } - - if(tdm_config->slot_cycles == HAL_TDM_SLOT_CYCLES_16) - { - val |= (TDM_SLOT_WIDTH_16_BIT << TDM_SLOT_WIDTH_SHIFT); - } - - if(tdm_config->data_offset >= TDM_DATA_OFFSET_MIN - && tdm_config->data_offset <= TDM_DATA_OFFSET_MAX) - { - val |= (tdm_config->data_offset << TDM_DATA_OFFSET_SHIT); - } - - *base_addr = val; -} - -static void tdm_get_default_config(struct HAL_TDM_CONFIG_T *tdm_config) -{ - tdm_config->mode = HAL_TDM_MODE_FS_ASSERTED_AT_FIRST; - tdm_config->edge = HAL_TDM_FS_EDGE_POSEDGE; - tdm_config->cycles = HAL_TDM_CYCLES_32; - tdm_config->fs_cycles = HAL_TDM_FS_CYCLES_1; - tdm_config->slot_cycles = HAL_TDM_SLOT_CYCLES_32; - tdm_config->data_offset = 0; -} - -static void tdm_get_i2s_config(struct HAL_TDM_CONFIG_T *tdm_config) -{ + if ((val & (TDM_MODE_FS_ASSERTED_AT_LAST << TDM_MODE_FS_ASSERTED_SHIFT)) == + (TDM_MODE_FS_ASSERTED_AT_LAST << TDM_MODE_FS_ASSERTED_SHIFT)) { tdm_config->mode = HAL_TDM_MODE_FS_ASSERTED_AT_LAST; + } else { + tdm_config->mode = HAL_TDM_MODE_FS_ASSERTED_AT_FIRST; + } + + if ((val & (TDM_FS_EDGE_NEGEDGE << TDM_FS_EDGE_SHIFT)) == + (TDM_FS_EDGE_NEGEDGE << TDM_FS_EDGE_SHIFT)) { tdm_config->edge = HAL_TDM_FS_EDGE_NEGEDGE; + } else { + tdm_config->edge = HAL_TDM_FS_EDGE_POSEDGE; + } + + if ((val & (TDM_FRAME_WIDTH_16_CYCLES << TDM_FRAME_WIDTH_SHIFT)) == + (TDM_FRAME_WIDTH_16_CYCLES << TDM_FRAME_WIDTH_SHIFT)) { + tdm_config->cycles = HAL_TDM_CYCLES_16; + } else if ((val & (TDM_FRAME_WIDTH_32_CYCLES << TDM_FRAME_WIDTH_SHIFT)) == + (TDM_FRAME_WIDTH_32_CYCLES << TDM_FRAME_WIDTH_SHIFT)) { tdm_config->cycles = HAL_TDM_CYCLES_32; + } else if ((val & (TDM_FRAME_WIDTH_64_CYCLES << TDM_FRAME_WIDTH_SHIFT)) == + (TDM_FRAME_WIDTH_64_CYCLES << TDM_FRAME_WIDTH_SHIFT)) { + tdm_config->cycles = HAL_TDM_CYCLES_64; + } else if ((val & (TDM_FRAME_WIDTH_128_CYCLES << TDM_FRAME_WIDTH_SHIFT)) == + (TDM_FRAME_WIDTH_128_CYCLES << TDM_FRAME_WIDTH_SHIFT)) { + tdm_config->cycles = HAL_TDM_CYCLES_128; + } else if ((val & (TDM_FRAME_WIDTH_256_CYCLES << TDM_FRAME_WIDTH_SHIFT)) == + (TDM_FRAME_WIDTH_256_CYCLES << TDM_FRAME_WIDTH_SHIFT)) { + tdm_config->cycles = HAL_TDM_CYCLES_256; + } else { + tdm_config->cycles = HAL_TDM_CYCLES_256; + } + + if ((val & (TDM_FS_WIDTH_8_CYCLES << TDM_FS_WIDTH_SHIFT)) == + (TDM_FS_WIDTH_8_CYCLES << TDM_FS_WIDTH_SHIFT)) { + tdm_config->fs_cycles = HAL_TDM_FS_CYCLES_8; + } else if ((val & (TDM_FS_WIDTH_16_CYCLES << TDM_FS_WIDTH_SHIFT)) == + (TDM_FS_WIDTH_16_CYCLES << TDM_FS_WIDTH_SHIFT)) { tdm_config->fs_cycles = HAL_TDM_FS_CYCLES_16; + } else if ((val & (TDM_FS_WIDTH_32_CYCLES << TDM_FS_WIDTH_SHIFT)) == + (TDM_FS_WIDTH_32_CYCLES << TDM_FS_WIDTH_SHIFT)) { + tdm_config->fs_cycles = HAL_TDM_FS_CYCLES_32; + } else if ((val & (TDM_FS_WIDTH_64_CYCLES << TDM_FS_WIDTH_SHIFT)) == + (TDM_FS_WIDTH_64_CYCLES << TDM_FS_WIDTH_SHIFT)) { + tdm_config->fs_cycles = HAL_TDM_FS_CYCLES_64; + } else if ((val & (TDM_FS_WIDTH_128_CYCLES << TDM_FS_WIDTH_SHIFT)) == + (TDM_FS_WIDTH_128_CYCLES << TDM_FS_WIDTH_SHIFT)) { + tdm_config->fs_cycles = HAL_TDM_FS_CYCLES_128; + } else if ((val & (TDM_FS_WIDTH_1_CYCLE << TDM_FS_WIDTH_SHIFT)) == + (TDM_FS_WIDTH_1_CYCLE << TDM_FS_WIDTH_SHIFT)) { + tdm_config->fs_cycles = HAL_TDM_FS_CYCLES_ONE_LESS; + } else { + tdm_config->fs_cycles = HAL_TDM_FS_CYCLES_ONE_LESS; + } + + if ((val & (TDM_SLOT_WIDTH_16_BIT << TDM_SLOT_WIDTH_SHIFT)) == + (TDM_SLOT_WIDTH_16_BIT << TDM_SLOT_WIDTH_SHIFT)) { tdm_config->slot_cycles = HAL_TDM_SLOT_CYCLES_16; - tdm_config->data_offset = 0; + } else { + tdm_config->slot_cycles = HAL_TDM_SLOT_CYCLES_32; + } + + tdm_config->data_offset = ((val >> TDM_DATA_OFFSET_SHIT) & 0x7); } -static void tdm_enable(enum HAL_I2S_ID_T i2s_id,bool enable) -{ - volatile uint32_t *base_addr; - uint32_t val = 0; +static void tdm_set_config(enum HAL_I2S_ID_T i2s_id, + struct HAL_TDM_CONFIG_T *tdm_config) { + volatile uint32_t *base_addr; + uint32_t val = 0; - base_addr = (uint32_t*)_tdm_get_reg_base(i2s_id); - val = *base_addr; + base_addr = (uint32_t *)_tdm_get_reg_base(i2s_id); + ASSERT(tdm_config->mode < HAL_TDM_MODE_NUM, "%s: mode = %d error!", __func__, + tdm_config->mode); + ASSERT(tdm_config->edge < HAL_TDM_FS_EDGE_NUM, "%s: edge = %d error!", + __func__, tdm_config->edge); + ASSERT(tdm_cycles_in_arrays((uint16_t)tdm_config->cycles), + "%s: cycles = %d error!", __func__, tdm_config->cycles); + ASSERT(tdm_fs_cycles_in_arrays((uint16_t)tdm_config->fs_cycles), + "%s: fs_cycles = %d cycles = %d error!", __func__, + tdm_config->fs_cycles, tdm_config->cycles); + ASSERT(tdm_slot_cycles_in_arrays((uint8_t)tdm_config->slot_cycles), + "%s: slot_cycles = %d error!", __func__, tdm_config->slot_cycles); - if(enable) - { - val |= (TDM_ENABLE << TDM_ENABLE_SHIFT); - } - else - { - val &= ~(TDM_ENABLE << TDM_ENABLE_SHIFT); - } - *base_addr = val; + if (tdm_config->mode == HAL_TDM_MODE_FS_ASSERTED_AT_LAST) { + val |= (TDM_MODE_FS_ASSERTED_AT_LAST << TDM_MODE_FS_ASSERTED_SHIFT); + } + + if (tdm_config->edge == HAL_TDM_FS_EDGE_NEGEDGE) { + val |= (TDM_FS_EDGE_NEGEDGE << TDM_FS_EDGE_SHIFT); + } + + if (tdm_config->cycles == HAL_TDM_CYCLES_16) { + val |= (TDM_FRAME_WIDTH_16_CYCLES << TDM_FRAME_WIDTH_SHIFT); + } else if (tdm_config->cycles == HAL_TDM_CYCLES_32) { + val |= (TDM_FRAME_WIDTH_32_CYCLES << TDM_FRAME_WIDTH_SHIFT); + } else if (tdm_config->cycles == HAL_TDM_CYCLES_64) { + val |= (TDM_FRAME_WIDTH_64_CYCLES << TDM_FRAME_WIDTH_SHIFT); + } else if (tdm_config->cycles == HAL_TDM_CYCLES_128) { + val |= (TDM_FRAME_WIDTH_128_CYCLES << TDM_FRAME_WIDTH_SHIFT); + } else { + val |= (TDM_FRAME_WIDTH_256_CYCLES << TDM_FRAME_WIDTH_SHIFT); + } + + if (tdm_config->fs_cycles == HAL_TDM_FS_CYCLES_8) { + val |= (TDM_FS_WIDTH_8_CYCLES << TDM_FS_WIDTH_SHIFT); + } else if (tdm_config->fs_cycles == HAL_TDM_FS_CYCLES_16) { + val |= (TDM_FS_WIDTH_16_CYCLES << TDM_FS_WIDTH_SHIFT); + } else if (tdm_config->fs_cycles == HAL_TDM_FS_CYCLES_32) { + val |= (TDM_FS_WIDTH_32_CYCLES << TDM_FS_WIDTH_SHIFT); + } else if (tdm_config->fs_cycles == HAL_TDM_FS_CYCLES_64) { + val |= (TDM_FS_WIDTH_64_CYCLES << TDM_FS_WIDTH_SHIFT); + } else if (tdm_config->fs_cycles == HAL_TDM_FS_CYCLES_128) { + val |= (TDM_FS_WIDTH_128_CYCLES << TDM_FS_WIDTH_SHIFT); + } else { + val |= (TDM_FS_WIDTH_FRAME_LENGTH_1_CYCLES << TDM_FS_WIDTH_SHIFT); + } + + if (tdm_config->slot_cycles == HAL_TDM_SLOT_CYCLES_16) { + val |= (TDM_SLOT_WIDTH_16_BIT << TDM_SLOT_WIDTH_SHIFT); + } + + if (tdm_config->data_offset >= TDM_DATA_OFFSET_MIN && + tdm_config->data_offset <= TDM_DATA_OFFSET_MAX) { + val |= (tdm_config->data_offset << TDM_DATA_OFFSET_SHIT); + } + + *base_addr = val; } -static int32_t tdm_open(enum HAL_I2S_ID_T i2s_id,enum AUD_STREAM_T stream,enum HAL_I2S_MODE_T mode) -{ - int ret; - struct HAL_TDM_CONFIG_T tdm_config; +static void tdm_get_default_config(struct HAL_TDM_CONFIG_T *tdm_config) { + tdm_config->mode = HAL_TDM_MODE_FS_ASSERTED_AT_FIRST; + tdm_config->edge = HAL_TDM_FS_EDGE_POSEDGE; + tdm_config->cycles = HAL_TDM_CYCLES_32; + tdm_config->fs_cycles = HAL_TDM_FS_CYCLES_1; + tdm_config->slot_cycles = HAL_TDM_SLOT_CYCLES_32; + tdm_config->data_offset = 0; +} - TDM_TRACE(4,"%s: i2s_id = %d, stream = %d, mode = %d.", __func__, i2s_id, stream, mode); - ret = hal_i2s_open(i2s_id, stream, mode); - if(ret) - { - TDM_TRACE(2,"%s: hal_i2s_open failed.ret = %d.", __func__, ret); - } - tdm_enable(i2s_id,false); - tdm_get_default_config(&tdm_config); - tdm_set_config(i2s_id, &tdm_config); - TDM_TRACE(1,"%s: done.",__func__); - return ret; +static void tdm_get_i2s_config(struct HAL_TDM_CONFIG_T *tdm_config) { + tdm_config->mode = HAL_TDM_MODE_FS_ASSERTED_AT_LAST; + tdm_config->edge = HAL_TDM_FS_EDGE_NEGEDGE; + tdm_config->cycles = HAL_TDM_CYCLES_32; + tdm_config->fs_cycles = HAL_TDM_FS_CYCLES_16; + tdm_config->slot_cycles = HAL_TDM_SLOT_CYCLES_16; + tdm_config->data_offset = 0; +} + +static void tdm_enable(enum HAL_I2S_ID_T i2s_id, bool enable) { + volatile uint32_t *base_addr; + uint32_t val = 0; + + base_addr = (uint32_t *)_tdm_get_reg_base(i2s_id); + val = *base_addr; + + if (enable) { + val |= (TDM_ENABLE << TDM_ENABLE_SHIFT); + } else { + val &= ~(TDM_ENABLE << TDM_ENABLE_SHIFT); + } + *base_addr = val; +} + +static int32_t tdm_open(enum HAL_I2S_ID_T i2s_id, enum AUD_STREAM_T stream, + enum HAL_I2S_MODE_T mode) { + int ret; + struct HAL_TDM_CONFIG_T tdm_config; + + TDM_TRACE(4, "%s: i2s_id = %d, stream = %d, mode = %d.", __func__, i2s_id, + stream, mode); + ret = hal_i2s_open(i2s_id, stream, mode); + if (ret) { + TDM_TRACE(2, "%s: hal_i2s_open failed.ret = %d.", __func__, ret); + } + tdm_enable(i2s_id, false); + tdm_get_default_config(&tdm_config); + tdm_set_config(i2s_id, &tdm_config); + TDM_TRACE(1, "%s: done.", __func__); + return ret; } static int32_t tdm_setup_stream(enum HAL_I2S_ID_T i2s_id, - enum AUD_STREAM_T stream, - uint32_t sample_rate, - struct HAL_TDM_CONFIG_T *tdm_cfg) -{ - struct HAL_I2S_CONFIG_T i2s_cfg; - uint32_t cycles; - const uint8_t bits = 16; - int ret; + enum AUD_STREAM_T stream, uint32_t sample_rate, + struct HAL_TDM_CONFIG_T *tdm_cfg) { + struct HAL_I2S_CONFIG_T i2s_cfg; + uint32_t cycles; + const uint8_t bits = 16; + int ret; - TDM_TRACE(4,"%s: i2s_id = %d, stream = %d, sample_rate = %d", - __func__, i2s_id, stream, sample_rate); - TDM_TRACE(5,"%s: tdm_cfg: mode = %d,edge = %d,cycles = %d,fs_cycles = %d," - "slot_cycles= %d, offs = %d.", - __func__, tdm_cfg->mode, tdm_cfg->edge, tdm_cfg->cycles, - tdm_cfg->fs_cycles,tdm_cfg->slot_cycles,tdm_cfg->data_offset); - cycles = tdm_cfg->cycles; - ASSERT(tdm_cycles_in_arrays(cycles), - "%s: cycles = %d error!",__func__, tdm_cfg->cycles); - memset(&i2s_cfg, 0, sizeof(i2s_cfg)); - i2s_cfg.use_dma = true; - i2s_cfg.sync_start = tdm_cfg->sync_start; - i2s_cfg.chan_sep_buf = false; - i2s_cfg.bits = bits; - i2s_cfg.channel_num = 2; - i2s_cfg.channel_map = AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1; - i2s_cfg.sample_rate = sample_rate*(cycles/bits)/2; - ret = hal_i2s_setup_stream(i2s_id, stream, &i2s_cfg); - if(ret) - { - TDM_TRACE(2,"%s: playback failed.ret = %d.", __func__, ret); - } - else - { - tdm_enable(i2s_id,false); - tdm_set_config(i2s_id,tdm_cfg); - } + TDM_TRACE(4, "%s: i2s_id = %d, stream = %d, sample_rate = %d", __func__, + i2s_id, stream, sample_rate); + TDM_TRACE(5, + "%s: tdm_cfg: mode = %d,edge = %d,cycles = %d,fs_cycles = %d," + "slot_cycles= %d, offs = %d.", + __func__, tdm_cfg->mode, tdm_cfg->edge, tdm_cfg->cycles, + tdm_cfg->fs_cycles, tdm_cfg->slot_cycles, tdm_cfg->data_offset); + cycles = tdm_cfg->cycles; + ASSERT(tdm_cycles_in_arrays(cycles), "%s: cycles = %d error!", __func__, + tdm_cfg->cycles); + memset(&i2s_cfg, 0, sizeof(i2s_cfg)); + i2s_cfg.use_dma = true; + i2s_cfg.sync_start = tdm_cfg->sync_start; + i2s_cfg.chan_sep_buf = false; + i2s_cfg.bits = bits; + i2s_cfg.channel_num = 2; + i2s_cfg.channel_map = AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1; + i2s_cfg.sample_rate = sample_rate * (cycles / bits) / 2; + ret = hal_i2s_setup_stream(i2s_id, stream, &i2s_cfg); + if (ret) { + TDM_TRACE(2, "%s: playback failed.ret = %d.", __func__, ret); + } else { + tdm_enable(i2s_id, false); + tdm_set_config(i2s_id, tdm_cfg); + } - TDM_TRACE(1,"%s done.", __func__); - return ret; + TDM_TRACE(1, "%s done.", __func__); + return ret; } int32_t tdm_as_i2s_setup_stream(enum HAL_I2S_ID_T i2s_id, - enum AUD_STREAM_T stream, - uint32_t sample_rate) -{ - struct HAL_I2S_CONFIG_T i2s_cfg; - struct HAL_TDM_CONFIG_T tdm_cfg; - int ret; + enum AUD_STREAM_T stream, + uint32_t sample_rate) { + struct HAL_I2S_CONFIG_T i2s_cfg; + struct HAL_TDM_CONFIG_T tdm_cfg; + int ret; - TDM_TRACE(4,"%s: i2s_id = %d, stream = %d, sample_rate = 0x%x.", - __func__, i2s_id, stream, sample_rate); - memset(&i2s_cfg, 0, sizeof(i2s_cfg)); - i2s_cfg.use_dma = true; - i2s_cfg.sync_start = stream == AUD_STREAM_PLAYBACK ? true : false; - i2s_cfg.chan_sep_buf = false; - i2s_cfg.bits = 16; - i2s_cfg.channel_num = 2; - i2s_cfg.channel_map = AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1; - i2s_cfg.sample_rate = sample_rate; - ret = hal_i2s_setup_stream(i2s_id, stream, &i2s_cfg); - if(ret) - { - TDM_TRACE(2,"%s: playback failed.ret = %d.", __func__, ret); - } - else - { - tdm_enable(i2s_id,false); - tdm_get_i2s_config(&tdm_cfg); - tdm_set_config(i2s_id,&tdm_cfg); - } + TDM_TRACE(4, "%s: i2s_id = %d, stream = %d, sample_rate = 0x%x.", __func__, + i2s_id, stream, sample_rate); + memset(&i2s_cfg, 0, sizeof(i2s_cfg)); + i2s_cfg.use_dma = true; + i2s_cfg.sync_start = stream == AUD_STREAM_PLAYBACK ? true : false; + i2s_cfg.chan_sep_buf = false; + i2s_cfg.bits = 16; + i2s_cfg.channel_num = 2; + i2s_cfg.channel_map = AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1; + i2s_cfg.sample_rate = sample_rate; + ret = hal_i2s_setup_stream(i2s_id, stream, &i2s_cfg); + if (ret) { + TDM_TRACE(2, "%s: playback failed.ret = %d.", __func__, ret); + } else { + tdm_enable(i2s_id, false); + tdm_get_i2s_config(&tdm_cfg); + tdm_set_config(i2s_id, &tdm_cfg); + } - TDM_TRACE(1,"%s: done.", __func__); - return ret; + TDM_TRACE(1, "%s: done.", __func__); + return ret; } -static int32_t tdm_start_stream(enum HAL_I2S_ID_T i2s_id, enum AUD_STREAM_T stream) -{ - int ret; +static int32_t tdm_start_stream(enum HAL_I2S_ID_T i2s_id, + enum AUD_STREAM_T stream) { + int ret; - TDM_TRACE(3,"%s: i2s_id = %d, stream = %d.", __func__, i2s_id, stream); - tdm_enable(i2s_id,true); - ret = hal_i2s_start_stream(i2s_id, stream); + TDM_TRACE(3, "%s: i2s_id = %d, stream = %d.", __func__, i2s_id, stream); + tdm_enable(i2s_id, true); + ret = hal_i2s_start_stream(i2s_id, stream); - TDM_TRACE(2,"%s done. ret = %d.", __func__, ret); - return ret; + TDM_TRACE(2, "%s done. ret = %d.", __func__, ret); + return ret; } -static int32_t tdm_stop_stream(enum HAL_I2S_ID_T i2s_id, enum AUD_STREAM_T stream) -{ - int ret; +static int32_t tdm_stop_stream(enum HAL_I2S_ID_T i2s_id, + enum AUD_STREAM_T stream) { + int ret; - TDM_TRACE(3,"%s: i2s_id = %d, stream = %d.", __func__, i2s_id, stream); - tdm_enable(i2s_id,false); + TDM_TRACE(3, "%s: i2s_id = %d, stream = %d.", __func__, i2s_id, stream); + tdm_enable(i2s_id, false); - ret = hal_i2s_stop_stream(i2s_id,stream); + ret = hal_i2s_stop_stream(i2s_id, stream); - TDM_TRACE(2,"%s done. ret = %d.", __func__, ret); - return ret; + TDM_TRACE(2, "%s done. ret = %d.", __func__, ret); + return ret; } -static int32_t tdm_close(enum HAL_I2S_ID_T i2s_id, enum AUD_STREAM_T stream) -{ - int ret; +static int32_t tdm_close(enum HAL_I2S_ID_T i2s_id, enum AUD_STREAM_T stream) { + int ret; - TDM_TRACE(3,"%s: i2s_id = %d, stream = %d.", __func__, i2s_id, stream); - tdm_enable(i2s_id,false); + TDM_TRACE(3, "%s: i2s_id = %d, stream = %d.", __func__, i2s_id, stream); + tdm_enable(i2s_id, false); - ret = hal_i2s_close(i2s_id,stream); + ret = hal_i2s_close(i2s_id, stream); - TDM_TRACE(2,"%s done. ret = %d.", __func__, ret); - return ret; + TDM_TRACE(2, "%s done. ret = %d.", __func__, ret); + return ret; } #endif // CHIP_HAS_TDM -int32_t hal_tdm_open(enum HAL_I2S_ID_T i2s_id,enum AUD_STREAM_T stream,enum HAL_I2S_MODE_T mode) -{ - int ret; +int32_t hal_tdm_open(enum HAL_I2S_ID_T i2s_id, enum AUD_STREAM_T stream, + enum HAL_I2S_MODE_T mode) { + int ret; - TDM_TRACE(3,"hal_tdm_open:i2s_id = %d, stream = %d, mode = %d.", - i2s_id, stream, mode); - ASSERT(i2s_id < HAL_I2S_ID_QTY,"%s: i2s_id = %d!", __func__, i2s_id); - - #ifdef CHIP_HAS_TDM - ret = tdm_open(i2s_id, stream, mode); - #else - ASSERT(stream == AUD_STREAM_CAPTURE, "stream = AUD_STREAM_PLAYBACK!"); - ret = hal_i2s_tdm_open(i2s_id, mode); - #endif - - TDM_TRACE(2,"%s done. ret = %d.", __func__, ret); - return ret; -} - -int32_t hal_tdm_setup_stream(enum HAL_I2S_ID_T i2s_id, - enum AUD_STREAM_T stream, - uint32_t sample_rate, - struct HAL_TDM_CONFIG_T *tdm_cfg) -{ - int ret; - - TDM_TRACE(4,"%s:i2s_id = %d, stream = %d, sample_rate = %d.", - __func__, i2s_id, stream, sample_rate); - ASSERT(i2s_id < HAL_I2S_ID_QTY,"%s: i2s_id = %d!", __func__, i2s_id); - TDM_TRACE(4,"%s: cycles = %d, fs_cycles = %d,slot_cycles = %d.", - __func__, - tdm_cfg->cycles, - tdm_cfg->fs_cycles, - tdm_cfg->slot_cycles); + TDM_TRACE(3, "hal_tdm_open:i2s_id = %d, stream = %d, mode = %d.", i2s_id, + stream, mode); + ASSERT(i2s_id < HAL_I2S_ID_QTY, "%s: i2s_id = %d!", __func__, i2s_id); #ifdef CHIP_HAS_TDM - ret = tdm_setup_stream(i2s_id, stream, sample_rate,tdm_cfg); + ret = tdm_open(i2s_id, stream, mode); #else - struct HAL_I2S_TDM_CONFIG_T i2s_tdm_cfg; - - i2s_tdm_cfg.cycles = (enum HAL_I2S_TDM_CYCLES_T)tdm_cfg->cycles; - i2s_tdm_cfg.fs_cycles = (enum HAL_I2S_TDM_FS_CYCLES_T)tdm_cfg->fs_cycles; - i2s_tdm_cfg.slot_cycles = (enum HAL_I2S_TDM_SLOT_CYCLES_T)tdm_cfg->slot_cycles; - i2s_tdm_cfg.data_offset = tdm_cfg->data_offset; - ret = hal_i2s_tdm_setup(i2s_id, sample_rate, &i2s_tdm_cfg); + ASSERT(stream == AUD_STREAM_CAPTURE, "stream = AUD_STREAM_PLAYBACK!"); + ret = hal_i2s_tdm_open(i2s_id, mode); #endif - TDM_TRACE(2,"%s done. ret = %d.", __func__, ret); - return ret; + TDM_TRACE(2, "%s done. ret = %d.", __func__, ret); + return ret; +} + +int32_t hal_tdm_setup_stream(enum HAL_I2S_ID_T i2s_id, enum AUD_STREAM_T stream, + uint32_t sample_rate, + struct HAL_TDM_CONFIG_T *tdm_cfg) { + int ret; + + TDM_TRACE(4, "%s:i2s_id = %d, stream = %d, sample_rate = %d.", __func__, + i2s_id, stream, sample_rate); + ASSERT(i2s_id < HAL_I2S_ID_QTY, "%s: i2s_id = %d!", __func__, i2s_id); + TDM_TRACE(4, "%s: cycles = %d, fs_cycles = %d,slot_cycles = %d.", __func__, + tdm_cfg->cycles, tdm_cfg->fs_cycles, tdm_cfg->slot_cycles); + +#ifdef CHIP_HAS_TDM + ret = tdm_setup_stream(i2s_id, stream, sample_rate, tdm_cfg); +#else + struct HAL_I2S_TDM_CONFIG_T i2s_tdm_cfg; + + i2s_tdm_cfg.cycles = (enum HAL_I2S_TDM_CYCLES_T)tdm_cfg->cycles; + i2s_tdm_cfg.fs_cycles = (enum HAL_I2S_TDM_FS_CYCLES_T)tdm_cfg->fs_cycles; + i2s_tdm_cfg.slot_cycles = + (enum HAL_I2S_TDM_SLOT_CYCLES_T)tdm_cfg->slot_cycles; + i2s_tdm_cfg.data_offset = tdm_cfg->data_offset; + ret = hal_i2s_tdm_setup(i2s_id, sample_rate, &i2s_tdm_cfg); +#endif + + TDM_TRACE(2, "%s done. ret = %d.", __func__, ret); + return ret; } int32_t hal_tdm_as_i2s_setup_stream(enum HAL_I2S_ID_T i2s_id, - enum AUD_STREAM_T stream, - uint32_t sample_rate) -{ - int ret; + enum AUD_STREAM_T stream, + uint32_t sample_rate) { + int ret; - TDM_TRACE(4,"%s: i2s_id = %d, stream = %d, sample_rate = %d.", - __func__, i2s_id, stream, sample_rate); - ASSERT(i2s_id < HAL_I2S_ID_QTY,"%s: i2s_id = %d!", __func__, i2s_id); + TDM_TRACE(4, "%s: i2s_id = %d, stream = %d, sample_rate = %d.", __func__, + i2s_id, stream, sample_rate); + ASSERT(i2s_id < HAL_I2S_ID_QTY, "%s: i2s_id = %d!", __func__, i2s_id); - // i2s setup stream playback and capture. + // i2s setup stream playback and capture. #ifdef CHIP_HAS_TDM - ret = tdm_as_i2s_setup_stream(i2s_id, stream, sample_rate); + ret = tdm_as_i2s_setup_stream(i2s_id, stream, sample_rate); #else - struct HAL_I2S_TDM_CONFIG_T i2s_tdm_cfg={ - HAL_I2S_TDM_CYCLES_32, - HAL_I2S_TDM_FS_CYCLES_16, - HAL_I2S_TDM_SLOT_CYCLES_16,}; - ret = hal_i2s_tdm_setup(i2s_id, sample_rate, &i2s_tdm_cfg); + struct HAL_I2S_TDM_CONFIG_T i2s_tdm_cfg = { + HAL_I2S_TDM_CYCLES_32, + HAL_I2S_TDM_FS_CYCLES_16, + HAL_I2S_TDM_SLOT_CYCLES_16, + }; + ret = hal_i2s_tdm_setup(i2s_id, sample_rate, &i2s_tdm_cfg); #endif - TDM_TRACE(2,"%s done. ret = %d.", __func__, ret); - return ret; + TDM_TRACE(2, "%s done. ret = %d.", __func__, ret); + return ret; } -int32_t hal_tdm_start_stream(enum HAL_I2S_ID_T i2s_id, enum AUD_STREAM_T stream) -{ - int ret; +int32_t hal_tdm_start_stream(enum HAL_I2S_ID_T i2s_id, + enum AUD_STREAM_T stream) { + int ret; - TDM_TRACE(3,"%s: i2s_id = %d stream = %d.", - __func__, i2s_id, stream); - ASSERT(i2s_id < HAL_I2S_ID_QTY,"%s: i2s_id = %d!", __func__, i2s_id); + TDM_TRACE(3, "%s: i2s_id = %d stream = %d.", __func__, i2s_id, stream); + ASSERT(i2s_id < HAL_I2S_ID_QTY, "%s: i2s_id = %d!", __func__, i2s_id); #ifdef CHIP_HAS_TDM - ret = tdm_start_stream(i2s_id, stream); + ret = tdm_start_stream(i2s_id, stream); #else - ret = hal_i2s_tdm_start_stream(i2s_id); + ret = hal_i2s_tdm_start_stream(i2s_id); #endif - TDM_TRACE(2,"%s done. ret = %d.", __func__, ret); - return ret; + TDM_TRACE(2, "%s done. ret = %d.", __func__, ret); + return ret; } -int32_t hal_tdm_stop_stream(enum HAL_I2S_ID_T i2s_id, enum AUD_STREAM_T stream) -{ - int32_t ret; +int32_t hal_tdm_stop_stream(enum HAL_I2S_ID_T i2s_id, + enum AUD_STREAM_T stream) { + int32_t ret; - TDM_TRACE(3,"%s: i2s_id = %d stream = %d.", - __func__, i2s_id, stream); - ASSERT(i2s_id < HAL_I2S_ID_QTY,"%s: i2s_id = %d!", __func__, i2s_id); + TDM_TRACE(3, "%s: i2s_id = %d stream = %d.", __func__, i2s_id, stream); + ASSERT(i2s_id < HAL_I2S_ID_QTY, "%s: i2s_id = %d!", __func__, i2s_id); #ifdef CHIP_HAS_TDM - ret = tdm_stop_stream(i2s_id, stream); + ret = tdm_stop_stream(i2s_id, stream); #else - ret = hal_i2s_tdm_stop_stream(i2s_id); + ret = hal_i2s_tdm_stop_stream(i2s_id); #endif - TDM_TRACE(2,"%s done. ret = %d.", __func__, ret); - return ret; + TDM_TRACE(2, "%s done. ret = %d.", __func__, ret); + return ret; } -int32_t hal_tdm_close(enum HAL_I2S_ID_T i2s_id, enum AUD_STREAM_T stream) -{ - int32_t ret; +int32_t hal_tdm_close(enum HAL_I2S_ID_T i2s_id, enum AUD_STREAM_T stream) { + int32_t ret; - TDM_TRACE(3,"%s: i2s_id = %d stream = %d.", - __func__, i2s_id, stream); - ASSERT(i2s_id < HAL_I2S_ID_QTY,"%s: i2s_id = %d!", __func__, i2s_id); + TDM_TRACE(3, "%s: i2s_id = %d stream = %d.", __func__, i2s_id, stream); + ASSERT(i2s_id < HAL_I2S_ID_QTY, "%s: i2s_id = %d!", __func__, i2s_id); #ifdef CHIP_HAS_TDM - ret = tdm_close(i2s_id, stream); + ret = tdm_close(i2s_id, stream); #else - ret = hal_i2s_tdm_close(i2s_id); + ret = hal_i2s_tdm_close(i2s_id); #endif - TDM_TRACE(2,"%s done. ret = %d.", __func__, ret); - return ret; + TDM_TRACE(2, "%s done. ret = %d.", __func__, ret); + return ret; } -void hal_tdm_get_config(enum HAL_I2S_ID_T i2s_id,struct HAL_TDM_CONFIG_T *tdm_cfg) -{ - ASSERT(i2s_id < HAL_I2S_ID_QTY,"%s: i2s_id = %d!", __func__, i2s_id); +void hal_tdm_get_config(enum HAL_I2S_ID_T i2s_id, + struct HAL_TDM_CONFIG_T *tdm_cfg) { + ASSERT(i2s_id < HAL_I2S_ID_QTY, "%s: i2s_id = %d!", __func__, i2s_id); #ifdef CHIP_HAS_TDM - tdm_get_config(i2s_id,tdm_cfg); + tdm_get_config(i2s_id, tdm_cfg); #else - struct HAL_I2S_TDM_CONFIG_T i2s_tdm_cfg; - hal_i2s_tdm_get_config(i2s_id, &i2s_tdm_cfg); - tdm_cfg->mode = HAL_TDM_MODE_FS_ASSERTED_AT_FIRST; - tdm_cfg->edge = HAL_TDM_FS_EDGE_POSEDGE; - tdm_cfg->cycles = (enum HAL_TDM_CYCLES_T)i2s_tdm_cfg.cycles; - tdm_cfg->fs_cycles = (enum HAL_TDM_FS_CYCLES)i2s_tdm_cfg.fs_cycles; - tdm_cfg->slot_cycles = (enum HAL_TDM_SLOT_CYCLES_T)i2s_tdm_cfg.slot_cycles; - tdm_cfg->data_offset = i2s_tdm_cfg.data_offset; + struct HAL_I2S_TDM_CONFIG_T i2s_tdm_cfg; + hal_i2s_tdm_get_config(i2s_id, &i2s_tdm_cfg); + tdm_cfg->mode = HAL_TDM_MODE_FS_ASSERTED_AT_FIRST; + tdm_cfg->edge = HAL_TDM_FS_EDGE_POSEDGE; + tdm_cfg->cycles = (enum HAL_TDM_CYCLES_T)i2s_tdm_cfg.cycles; + tdm_cfg->fs_cycles = (enum HAL_TDM_FS_CYCLES)i2s_tdm_cfg.fs_cycles; + tdm_cfg->slot_cycles = (enum HAL_TDM_SLOT_CYCLES_T)i2s_tdm_cfg.slot_cycles; + tdm_cfg->data_offset = i2s_tdm_cfg.data_offset; #endif } -void hal_tdm_set_config(enum HAL_I2S_ID_T i2s_id,struct HAL_TDM_CONFIG_T *tdm_cfg) -{ - ASSERT(i2s_id < HAL_I2S_ID_QTY,"%s: i2s_id = %d!", __func__, i2s_id); +void hal_tdm_set_config(enum HAL_I2S_ID_T i2s_id, + struct HAL_TDM_CONFIG_T *tdm_cfg) { + ASSERT(i2s_id < HAL_I2S_ID_QTY, "%s: i2s_id = %d!", __func__, i2s_id); #ifdef CHIP_HAS_TDM - tdm_set_config(i2s_id,tdm_cfg); + tdm_set_config(i2s_id, tdm_cfg); #else - struct HAL_I2S_TDM_CONFIG_T i2s_tdm_cfg; - i2s_tdm_cfg.cycles = HAL_I2S_TDM_CYCLES_32; - i2s_tdm_cfg.fs_cycles = HAL_I2S_TDM_FS_CYCLES_16; - i2s_tdm_cfg.slot_cycles = HAL_I2S_TDM_SLOT_CYCLES_16; - i2s_tdm_cfg.data_offset = 0; - hal_i2s_tdm_set_config(i2s_id, &i2s_tdm_cfg); + struct HAL_I2S_TDM_CONFIG_T i2s_tdm_cfg; + i2s_tdm_cfg.cycles = HAL_I2S_TDM_CYCLES_32; + i2s_tdm_cfg.fs_cycles = HAL_I2S_TDM_FS_CYCLES_16; + i2s_tdm_cfg.slot_cycles = HAL_I2S_TDM_SLOT_CYCLES_16; + i2s_tdm_cfg.data_offset = 0; + hal_i2s_tdm_set_config(i2s_id, &i2s_tdm_cfg); #endif } - diff --git a/platform/hal/hal_timer.c b/platform/hal/hal_timer.c index 440ed99..8f40463 100644 --- a/platform/hal/hal_timer.c +++ b/platform/hal/hal_timer.c @@ -13,24 +13,26 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_addr_map.h" #include "hal_timer.h" +#include "plat_addr_map.h" #define IGNORE_HAL_TIMER_RAW_API_CHECK +#include "cmsis_nvic.h" +#include "hal_cmu.h" +#include "hal_location.h" #include "hal_timer_raw.h" #include "reg_timer.h" -#include "hal_location.h" -#include "hal_cmu.h" -#include "cmsis_nvic.h" //#define ELAPSED_TIMER_ENABLED -#if defined(CHIP_BEST3001) || defined(CHIP_BEST3003) || defined(CHIP_BEST3005) || defined(CHIP_BEST1400) || defined(CHIP_BEST1402) +#if defined(CHIP_BEST3001) || defined(CHIP_BEST3003) || \ + defined(CHIP_BEST3005) || defined(CHIP_BEST1400) || defined(CHIP_BEST1402) #define CLOCK_SYNC_WORKAROUND #endif #ifdef LOW_SYS_FREQ -#if defined(CHIP_BEST1305) || defined(CHIP_BEST1501) || \ - defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) +#if defined(CHIP_BEST1305) || defined(CHIP_BEST1501) || \ + defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || \ + defined(CHIP_BEST2300A) #define FAST_TIMER_WORKAROUND #endif #endif @@ -39,646 +41,621 @@ //#define TIMER_USE_FPU #endif -#define SLOW_TIMER_VAL_DELTA 1 -#define SLOW_TIMER_VAL_DELTA_SLEEP 10 -#define FAST_TIMER_VAL_DELTA 20 +#define SLOW_TIMER_VAL_DELTA 1 +#define SLOW_TIMER_VAL_DELTA_SLEEP 10 +#define FAST_TIMER_VAL_DELTA 20 #ifdef CALIB_SLOW_TIMER -#define MAX_CALIB_SYSTICK_HZ (CONFIG_SYSTICK_HZ_NOMINAL * 2) +#define MAX_CALIB_SYSTICK_HZ (CONFIG_SYSTICK_HZ_NOMINAL * 2) -#define MIN_CALIB_TICKS (10 * (CONFIG_SYSTICK_HZ_NOMINAL / 1000)) +#define MIN_CALIB_TICKS (10 * (CONFIG_SYSTICK_HZ_NOMINAL / 1000)) -#define MAX_CALIB_TICKS (30 * CONFIG_SYSTICK_HZ_NOMINAL) +#define MAX_CALIB_TICKS (30 * CONFIG_SYSTICK_HZ_NOMINAL) static uint32_t BOOT_DATA_LOC sys_tick_hz = CONFIG_SYSTICK_HZ_NOMINAL; static uint32_t BOOT_BSS_LOC slow_val; static uint32_t BOOT_BSS_LOC fast_val; #endif -static struct DUAL_TIMER_T * const BOOT_RODATA_SRAM_LOC dual_timer0 = (struct DUAL_TIMER_T *)TIMER0_BASE; +static struct DUAL_TIMER_T *const BOOT_RODATA_SRAM_LOC dual_timer0 = + (struct DUAL_TIMER_T *)TIMER0_BASE; #ifdef TIMER1_BASE -static struct DUAL_TIMER_T * const BOOT_RODATA_SRAM_LOC dual_timer1 = (struct DUAL_TIMER_T *)TIMER1_BASE; +static struct DUAL_TIMER_T *const BOOT_RODATA_SRAM_LOC dual_timer1 = + (struct DUAL_TIMER_T *)TIMER1_BASE; #endif static HAL_TIMER_IRQ_HANDLER_T irq_handler = NULL; -//static uint32_t load_value = 0; +// static uint32_t load_value = 0; static uint32_t start_time; static void POSSIBLY_UNUSED hal_timer00_irq_handler(void); static void hal_timer01_irq_handler(void); -__STATIC_FORCEINLINE uint32_t get_timer_value(struct TIMER_T *timer, uint32_t delta) -{ +__STATIC_FORCEINLINE uint32_t get_timer_value(struct TIMER_T *timer, + uint32_t delta) { #ifdef CLOCK_SYNC_WORKAROUND - uint32_t lock; - uint32_t v1, v2; + uint32_t lock; + uint32_t v1, v2; - lock = int_lock(); - do { - v1 = timer->Value; - v2 = timer->Value; - } while ((v1 < v2) || (v1 > v2 + delta)); - int_unlock(lock); + lock = int_lock(); + do { + v1 = timer->Value; + v2 = timer->Value; + } while ((v1 < v2) || (v1 > v2 + delta)); + int_unlock(lock); - return v2; + return v2; #else - return timer->Value; + return timer->Value; #endif } -__STATIC_FORCEINLINE void clear_timer_irq(struct TIMER_T *timer) -{ +__STATIC_FORCEINLINE void clear_timer_irq(struct TIMER_T *timer) { #ifdef CLOCK_SYNC_WORKAROUND - do { - timer->IntClr = 1; - } while (timer->RIS & TIMER_RIS_RIS); -#else + do { timer->IntClr = 1; -#endif -} - -__STATIC_FORCEINLINE void set_timer_load(struct TIMER_T *timer, uint32_t load, uint32_t delta) -{ -#ifdef CLOCK_SYNC_WORKAROUND - uint32_t lock; - uint32_t val; - - lock = int_lock(); - do { - timer->Load = load; - val = timer->Value; - } while ((load < val) || (load > val + delta)); - int_unlock(lock); + } while (timer->RIS & TIMER_RIS_RIS); #else + timer->IntClr = 1; +#endif +} + +__STATIC_FORCEINLINE void set_timer_load(struct TIMER_T *timer, uint32_t load, + uint32_t delta) { +#ifdef CLOCK_SYNC_WORKAROUND + uint32_t lock; + uint32_t val; + + lock = int_lock(); + do { timer->Load = load; + val = timer->Value; + } while ((load < val) || (load > val + delta)); + int_unlock(lock); +#else + timer->Load = load; #endif } -__STATIC_FORCEINLINE void fast_timer_open(void) -{ +__STATIC_FORCEINLINE void fast_timer_open(void) { #ifdef TIMER1_BASE - hal_cmu_timer1_select_fast(); - dual_timer1->timer[0].Control = TIMER_CTRL_EN | TIMER_CTRL_PRESCALE_DIV_1 | TIMER_CTRL_SIZE_32_BIT; + hal_cmu_timer1_select_fast(); + dual_timer1->timer[0].Control = + TIMER_CTRL_EN | TIMER_CTRL_PRESCALE_DIV_1 | TIMER_CTRL_SIZE_32_BIT; #endif } -void BOOT_TEXT_FLASH_LOC hal_sys_timer_open(void) -{ - hal_cmu_timer0_select_slow(); - dual_timer0->timer[0].Control = TIMER_CTRL_EN | TIMER_CTRL_PRESCALE_DIV_1 | TIMER_CTRL_SIZE_32_BIT; - fast_timer_open();; +void BOOT_TEXT_FLASH_LOC hal_sys_timer_open(void) { + hal_cmu_timer0_select_slow(); + dual_timer0->timer[0].Control = + TIMER_CTRL_EN | TIMER_CTRL_PRESCALE_DIV_1 | TIMER_CTRL_SIZE_32_BIT; + fast_timer_open(); + ; } #ifdef CORE_SLEEP_POWER_DOWN -void SRAM_TEXT_LOC hal_sys_timer_wakeup(void) -{ - fast_timer_open();; +void SRAM_TEXT_LOC hal_sys_timer_wakeup(void) { + fast_timer_open(); + ; } #endif -uint32_t BOOT_TEXT_SRAM_LOC hal_sys_timer_get(void) -{ - return -get_timer_value(&dual_timer0->timer[0], SLOW_TIMER_VAL_DELTA); +uint32_t BOOT_TEXT_SRAM_LOC hal_sys_timer_get(void) { + return -get_timer_value(&dual_timer0->timer[0], SLOW_TIMER_VAL_DELTA); } #ifdef CLOCK_SYNC_WORKAROUND -uint32_t SRAM_TEXT_LOC hal_sys_timer_get_in_sleep(void) -{ - return -get_timer_value(&dual_timer0->timer[0], SLOW_TIMER_VAL_DELTA_SLEEP); +uint32_t SRAM_TEXT_LOC hal_sys_timer_get_in_sleep(void) { + return -get_timer_value(&dual_timer0->timer[0], SLOW_TIMER_VAL_DELTA_SLEEP); } #else -uint32_t hal_sys_timer_get_in_sleep(void) __attribute__((alias("hal_sys_timer_get"))); +uint32_t hal_sys_timer_get_in_sleep(void) + __attribute__((alias("hal_sys_timer_get"))); #endif -uint32_t BOOT_TEXT_FLASH_LOC flash_hal_sys_timer_get(void) -{ - return -get_timer_value(&dual_timer0->timer[0], SLOW_TIMER_VAL_DELTA); +uint32_t BOOT_TEXT_FLASH_LOC flash_hal_sys_timer_get(void) { + return -get_timer_value(&dual_timer0->timer[0], SLOW_TIMER_VAL_DELTA); } -uint32_t BOOT_TEXT_SRAM_LOC hal_sys_ms_get(void) -{ - return GET_CURRENT_MS(); -} +uint32_t BOOT_TEXT_SRAM_LOC hal_sys_ms_get(void) { return GET_CURRENT_MS(); } -uint32_t BOOT_TEXT_SRAM_LOC hal_fast_sys_timer_get(void) -{ +uint32_t BOOT_TEXT_SRAM_LOC hal_fast_sys_timer_get(void) { #ifdef TIMER1_BASE #ifdef FAST_TIMER_WORKAROUND - if (hal_cmu_fast_timer_offline()) { + if (hal_cmu_fast_timer_offline()) { #ifdef TIMER_USE_FPU - return (uint32_t)(hal_sys_timer_get() * ((float)CONFIG_FAST_SYSTICK_HZ / CONFIG_SYSTICK_HZ)); + return (uint32_t)(hal_sys_timer_get() * + ((float)CONFIG_FAST_SYSTICK_HZ / CONFIG_SYSTICK_HZ)); #else - return (uint32_t)(hal_sys_timer_get() * (uint64_t)CONFIG_FAST_SYSTICK_HZ / CONFIG_SYSTICK_HZ); + return (uint32_t)(hal_sys_timer_get() * (uint64_t)CONFIG_FAST_SYSTICK_HZ / + CONFIG_SYSTICK_HZ); #endif - } + } #endif // FAST_TIMER_WORKAROUND - return -get_timer_value(&dual_timer1->timer[0], FAST_TIMER_VAL_DELTA); + return -get_timer_value(&dual_timer1->timer[0], FAST_TIMER_VAL_DELTA); #else - return 0; + return 0; #endif } -uint32_t hal_sys_timer_get_max(void) -{ - return 0xFFFFFFFF; -} +uint32_t hal_sys_timer_get_max(void) { return 0xFFFFFFFF; } -void BOOT_TEXT_SRAM_LOC hal_sys_timer_delay(uint32_t ticks) -{ - uint32_t start = hal_sys_timer_get(); +void BOOT_TEXT_SRAM_LOC hal_sys_timer_delay(uint32_t ticks) { + uint32_t start = hal_sys_timer_get(); - while (hal_sys_timer_get() - start < ticks); + while (hal_sys_timer_get() - start < ticks) + ; } #ifdef CLOCK_SYNC_WORKAROUND -void SRAM_TEXT_LOC hal_sys_timer_delay_in_sleep(uint32_t ticks) -{ - uint32_t start = hal_sys_timer_get_in_sleep(); +void SRAM_TEXT_LOC hal_sys_timer_delay_in_sleep(uint32_t ticks) { + uint32_t start = hal_sys_timer_get_in_sleep(); - while (hal_sys_timer_get_in_sleep() - start < ticks); + while (hal_sys_timer_get_in_sleep() - start < ticks) + ; } #else -void hal_sys_timer_delay_in_sleep(uint32_t ticks) __attribute__((alias("hal_sys_timer_delay"))); +void hal_sys_timer_delay_in_sleep(uint32_t ticks) + __attribute__((alias("hal_sys_timer_delay"))); #endif -void BOOT_TEXT_FLASH_LOC flash_hal_sys_timer_delay(uint32_t ticks) -{ - uint32_t start = flash_hal_sys_timer_get(); +void BOOT_TEXT_FLASH_LOC flash_hal_sys_timer_delay(uint32_t ticks) { + uint32_t start = flash_hal_sys_timer_get(); - while (flash_hal_sys_timer_get() - start < ticks); + while (flash_hal_sys_timer_get() - start < ticks) + ; } -void BOOT_TEXT_SRAM_LOC hal_sys_timer_delay_us(uint32_t us) -{ +void BOOT_TEXT_SRAM_LOC hal_sys_timer_delay_us(uint32_t us) { #ifdef TIMER1_BASE #ifdef FAST_TIMER_WORKAROUND - if (hal_cmu_fast_timer_offline()) { - uint32_t start = hal_sys_timer_get(); - uint32_t ticks = US_TO_TICKS(us); + if (hal_cmu_fast_timer_offline()) { + uint32_t start = hal_sys_timer_get(); + uint32_t ticks = US_TO_TICKS(us); - while (hal_sys_timer_get() - start < ticks); - } + while (hal_sys_timer_get() - start < ticks) + ; + } #endif // FAST_TIMER_WORKAROUND - uint32_t start = hal_fast_sys_timer_get(); - uint32_t ticks = US_TO_FAST_TICKS(us); + uint32_t start = hal_fast_sys_timer_get(); + uint32_t ticks = US_TO_FAST_TICKS(us); - while (hal_fast_sys_timer_get() - start < ticks); + while (hal_fast_sys_timer_get() - start < ticks) + ; #else - enum HAL_CMU_FREQ_T freq = hal_cmu_sys_get_freq(); - uint32_t loop; - uint32_t i; + enum HAL_CMU_FREQ_T freq = hal_cmu_sys_get_freq(); + uint32_t loop; + uint32_t i; - // Assuming: - // 1) system clock uses audio PLL - // 2) audio PLL is configured as 48K series, 196.608M - // 3) crystal is 26M + // Assuming: + // 1) system clock uses audio PLL + // 2) audio PLL is configured as 48K series, 196.608M + // 3) crystal is 26M - if (freq == HAL_CMU_FREQ_208M) { - loop = 197; - } else if (freq == HAL_CMU_FREQ_104M) { - loop = 197 / 2; - } else if (freq == HAL_CMU_FREQ_78M) { - loop = 197 / 3; - } else if (freq == HAL_CMU_FREQ_52M) { - loop = 52; - } else { - loop = 26; - } + if (freq == HAL_CMU_FREQ_208M) { + loop = 197; + } else if (freq == HAL_CMU_FREQ_104M) { + loop = 197 / 2; + } else if (freq == HAL_CMU_FREQ_78M) { + loop = 197 / 3; + } else if (freq == HAL_CMU_FREQ_52M) { + loop = 52; + } else { + loop = 26; + } - loop = loop * us / 5; - for (i = 0; i < loop; i++) { - asm volatile("nop"); - } + loop = loop * us / 5; + for (i = 0; i < loop; i++) { + asm volatile("nop"); + } #endif } -void SRAM_TEXT_LOC hal_sys_timer_delay_ns(uint32_t ns) -{ +void SRAM_TEXT_LOC hal_sys_timer_delay_ns(uint32_t ns) { #ifdef TIMER1_BASE #ifdef FAST_TIMER_WORKAROUND - if (hal_cmu_fast_timer_offline()) { - uint32_t start = hal_sys_timer_get(); - uint32_t ticks = US_TO_TICKS((ns + (1000 - 1)) / 1000); + if (hal_cmu_fast_timer_offline()) { + uint32_t start = hal_sys_timer_get(); + uint32_t ticks = US_TO_TICKS((ns + (1000 - 1)) / 1000); - while (hal_sys_timer_get() - start < ticks); - } + while (hal_sys_timer_get() - start < ticks) + ; + } #endif // FAST_TIMER_WORKAROUND - uint32_t start = hal_fast_sys_timer_get(); - uint32_t ticks = NS_TO_FAST_TICKS(ns); + uint32_t start = hal_fast_sys_timer_get(); + uint32_t ticks = NS_TO_FAST_TICKS(ns); - while (hal_fast_sys_timer_get() - start < ticks); + while (hal_fast_sys_timer_get() - start < ticks) + ; #else - enum HAL_CMU_FREQ_T freq = hal_cmu_sys_get_freq(); - uint32_t loop; - uint32_t i; + enum HAL_CMU_FREQ_T freq = hal_cmu_sys_get_freq(); + uint32_t loop; + uint32_t i; - // Assuming: - // 1) system clock uses audio PLL - // 2) audio PLL is configured as 48K series, 196.608M - // 3) crystal is 26M + // Assuming: + // 1) system clock uses audio PLL + // 2) audio PLL is configured as 48K series, 196.608M + // 3) crystal is 26M - if (freq == HAL_CMU_FREQ_208M) { - loop = 197; - } else if (freq == HAL_CMU_FREQ_104M) { - loop = 197 / 2; - } else if (freq == HAL_CMU_FREQ_78M) { - loop = 197 / 3; - } else if (freq == HAL_CMU_FREQ_52M) { - loop = 52; - } else { - loop = 26; - } + if (freq == HAL_CMU_FREQ_208M) { + loop = 197; + } else if (freq == HAL_CMU_FREQ_104M) { + loop = 197 / 2; + } else if (freq == HAL_CMU_FREQ_78M) { + loop = 197 / 3; + } else if (freq == HAL_CMU_FREQ_52M) { + loop = 52; + } else { + loop = 26; + } - loop = loop * ns / 5000; - for (i = 0; i < loop; i++) { - asm volatile("nop"); - } + loop = loop * ns / 5000; + for (i = 0; i < loop; i++) { + asm volatile("nop"); + } #endif } -static uint32_t NOINLINE SRAM_TEXT_DEF(measure_cpu_freq_interval)(uint32_t cnt) -{ - uint32_t start; - struct DUAL_TIMER_T *t; - uint32_t delta; +static uint32_t NOINLINE +SRAM_TEXT_DEF(measure_cpu_freq_interval)(uint32_t cnt) { + uint32_t start; + struct DUAL_TIMER_T *t; + uint32_t delta; #ifdef TIMER1_BASE - t = dual_timer1; - delta = FAST_TIMER_VAL_DELTA; + t = dual_timer1; + delta = FAST_TIMER_VAL_DELTA; #ifdef FAST_TIMER_WORKAROUND - if (hal_cmu_fast_timer_offline()) { - t = dual_timer0; - delta = SLOW_TIMER_VAL_DELTA; - } -#endif // FAST_TIMER_WORKAROUND -#else + if (hal_cmu_fast_timer_offline()) { t = dual_timer0; delta = SLOW_TIMER_VAL_DELTA; -#endif - - start = get_timer_value(&t->timer[0], delta); - - asm volatile( - "_loop:;" -#ifdef __ARM_ARCH_ISA_ARM - "nop;" - "nop;" -#endif - "subs %0, #1;" - "cmp %0, #0;" - "bne _loop;" - : : "r"(cnt)); - - return start - get_timer_value(&t->timer[0], delta); -} - -uint32_t hal_sys_timer_calc_cpu_freq(uint32_t interval_ms, int high_res) -{ - uint32_t ref_freq; - uint32_t cnt; - uint32_t one_sec; - uint32_t lock; - uint32_t run_interval; - uint32_t base_interval; - uint32_t freq; - - // Default measurement interval - if (interval_ms == 0) { -#ifdef TIMER1_BASE - interval_ms = 10; -#else - interval_ms = 100; -#endif - } - - ref_freq = hal_cmu_get_crystal_freq(); - // CPU loop cycle count - cnt = ref_freq / 4 * interval_ms / 1000; - - // Timer ticks per second -#ifdef TIMER1_BASE - one_sec = CONFIG_FAST_SYSTICK_HZ; -#ifdef FAST_TIMER_WORKAROUND - if (hal_cmu_fast_timer_offline()) { - one_sec = CONFIG_SYSTICK_HZ; - } + } #endif // FAST_TIMER_WORKAROUND #else - if (high_res) { - one_sec = CONFIG_FAST_SYSTICK_HZ; - } else { - one_sec = CONFIG_SYSTICK_HZ; - } + t = dual_timer0; + delta = SLOW_TIMER_VAL_DELTA; #endif - // Timer ticks per measurement interval - base_interval = one_sec * interval_ms / 1000; - lock = int_lock(); + start = get_timer_value(&t->timer[0], delta); + + asm volatile("_loop:;" +#ifdef __ARM_ARCH_ISA_ARM + "nop;" + "nop;" +#endif + "subs %0, #1;" + "cmp %0, #0;" + "bne _loop;" + : + : "r"(cnt)); + + return start - get_timer_value(&t->timer[0], delta); +} + +uint32_t hal_sys_timer_calc_cpu_freq(uint32_t interval_ms, int high_res) { + uint32_t ref_freq; + uint32_t cnt; + uint32_t one_sec; + uint32_t lock; + uint32_t run_interval; + uint32_t base_interval; + uint32_t freq; + + // Default measurement interval + if (interval_ms == 0) { +#ifdef TIMER1_BASE + interval_ms = 10; +#else + interval_ms = 100; +#endif + } + + ref_freq = hal_cmu_get_crystal_freq(); + // CPU loop cycle count + cnt = ref_freq / 4 * interval_ms / 1000; + + // Timer ticks per second +#ifdef TIMER1_BASE + one_sec = CONFIG_FAST_SYSTICK_HZ; +#ifdef FAST_TIMER_WORKAROUND + if (hal_cmu_fast_timer_offline()) { + one_sec = CONFIG_SYSTICK_HZ; + } +#endif // FAST_TIMER_WORKAROUND +#else + if (high_res) { + one_sec = CONFIG_FAST_SYSTICK_HZ; + } else { + one_sec = CONFIG_SYSTICK_HZ; + } +#endif + // Timer ticks per measurement interval + base_interval = one_sec * interval_ms / 1000; + + lock = int_lock(); #ifndef TIMER1_BASE - if (high_res) { - hal_cmu_timer0_select_fast(); - } + if (high_res) { + hal_cmu_timer0_select_fast(); + } #endif - run_interval = measure_cpu_freq_interval(cnt); + run_interval = measure_cpu_freq_interval(cnt); #ifndef TIMER1_BASE - if (high_res) { - hal_cmu_timer0_select_slow(); - } + if (high_res) { + hal_cmu_timer0_select_slow(); + } #endif - int_unlock(lock); + int_unlock(lock); #ifdef TIMER_USE_FPU - freq = (uint32_t)((float)ref_freq / run_interval * base_interval); + freq = (uint32_t)((float)ref_freq / run_interval * base_interval); #else - freq = (uint32_t)((uint64_t)ref_freq * base_interval / run_interval); + freq = (uint32_t)((uint64_t)ref_freq * base_interval / run_interval); #endif - if (high_res == 0) { - freq = (freq + 500000) / 1000000 * 1000000; - } + if (high_res == 0) { + freq = (freq + 500000) / 1000000 * 1000000; + } - return freq; + return freq; } #ifdef CALIB_SLOW_TIMER -void hal_sys_timer_calib_start(void) -{ - uint32_t lock; - uint32_t slow; - uint32_t fast; +void hal_sys_timer_calib_start(void) { + uint32_t lock; + uint32_t slow; + uint32_t fast; - lock = int_lock(); - slow = hal_sys_timer_get(); - while (hal_sys_timer_get() == slow); - fast = hal_fast_sys_timer_get(); - int_unlock(lock); + lock = int_lock(); + slow = hal_sys_timer_get(); + while (hal_sys_timer_get() == slow) + ; + fast = hal_fast_sys_timer_get(); + int_unlock(lock); - slow_val = slow + 1; - fast_val = fast; + slow_val = slow + 1; + fast_val = fast; } -int hal_sys_timer_calib_end(void) -{ - uint32_t lock; - uint32_t slow; - uint32_t fast; - uint32_t slow_diff; +int hal_sys_timer_calib_end(void) { + uint32_t lock; + uint32_t slow; + uint32_t fast; + uint32_t slow_diff; - lock = int_lock(); - slow = hal_sys_timer_get(); - while (hal_sys_timer_get() == slow); - fast = hal_fast_sys_timer_get(); - int_unlock(lock); + lock = int_lock(); + slow = hal_sys_timer_get(); + while (hal_sys_timer_get() == slow) + ; + fast = hal_fast_sys_timer_get(); + int_unlock(lock); - slow += 1; - slow_diff = slow - slow_val; + slow += 1; + slow_diff = slow - slow_val; - // Avoid computation error - if (slow_diff < MIN_CALIB_TICKS) { - return 1; - } - // Avoid fast tick overflow - if (slow_diff > MAX_CALIB_TICKS) { - return 2; - } + // Avoid computation error + if (slow_diff < MIN_CALIB_TICKS) { + return 1; + } + // Avoid fast tick overflow + if (slow_diff > MAX_CALIB_TICKS) { + return 2; + } #ifdef TIMER_USE_FPU - sys_tick_hz = (uint32_t)((float)CONFIG_FAST_SYSTICK_HZ / (fast - fast_val) * slow_diff); + sys_tick_hz = + (uint32_t)((float)CONFIG_FAST_SYSTICK_HZ / (fast - fast_val) * slow_diff); #else - uint64_t mul; + uint64_t mul; - mul = (uint64_t)CONFIG_FAST_SYSTICK_HZ * slow_diff; - if ((mul >> 32) == 0) { - sys_tick_hz = (uint32_t)mul / (fast - fast_val); - } else { - sys_tick_hz = mul / (fast - fast_val); - } + mul = (uint64_t)CONFIG_FAST_SYSTICK_HZ * slow_diff; + if ((mul >> 32) == 0) { + sys_tick_hz = (uint32_t)mul / (fast - fast_val); + } else { + sys_tick_hz = mul / (fast - fast_val); + } #endif - if (sys_tick_hz > MAX_CALIB_SYSTICK_HZ) { - sys_tick_hz = MAX_CALIB_SYSTICK_HZ; - } + if (sys_tick_hz > MAX_CALIB_SYSTICK_HZ) { + sys_tick_hz = MAX_CALIB_SYSTICK_HZ; + } - return 0; + return 0; } -void hal_sys_timer_calib(void) -{ - hal_sys_timer_calib_start(); - hal_sys_timer_delay(MIN_CALIB_TICKS); - hal_sys_timer_calib_end(); +void hal_sys_timer_calib(void) { + hal_sys_timer_calib_start(); + hal_sys_timer_delay(MIN_CALIB_TICKS); + hal_sys_timer_calib_end(); } -uint32_t BOOT_TEXT_SRAM_LOC hal_sys_timer_systick_hz(void) -{ - return sys_tick_hz; +uint32_t BOOT_TEXT_SRAM_LOC hal_sys_timer_systick_hz(void) { + return sys_tick_hz; } -uint32_t BOOT_TEXT_SRAM_LOC hal_sys_timer_ms_to_ticks(uint32_t ms) -{ - if (ms <= (~0UL / MAX_CALIB_SYSTICK_HZ)) { - return (ms * sys_tick_hz / 1000); - } else { +uint32_t BOOT_TEXT_SRAM_LOC hal_sys_timer_ms_to_ticks(uint32_t ms) { + if (ms <= (~0UL / MAX_CALIB_SYSTICK_HZ)) { + return (ms * sys_tick_hz / 1000); + } else { #ifdef TIMER_USE_FPU - return (uint32_t)((float)ms / 1000 * sys_tick_hz); + return (uint32_t)((float)ms / 1000 * sys_tick_hz); #else - return ((uint64_t)ms * sys_tick_hz / 1000); + return ((uint64_t)ms * sys_tick_hz / 1000); #endif - } + } } -uint32_t BOOT_TEXT_SRAM_LOC hal_sys_timer_us_to_ticks(uint32_t us) -{ - if (us <= (~0UL / MAX_CALIB_SYSTICK_HZ)) { - return ((us * sys_tick_hz / 1000 + 1000 - 1) / 1000 + 1); - } else { +uint32_t BOOT_TEXT_SRAM_LOC hal_sys_timer_us_to_ticks(uint32_t us) { + if (us <= (~0UL / MAX_CALIB_SYSTICK_HZ)) { + return ((us * sys_tick_hz / 1000 + 1000 - 1) / 1000 + 1); + } else { #ifdef TIMER_USE_FPU - return (uint32_t)((float)us / (1000 * 1000) * sys_tick_hz + 1 + 1); + return (uint32_t)((float)us / (1000 * 1000) * sys_tick_hz + 1 + 1); #else - return (((uint64_t)us * sys_tick_hz / 1000 + 1000 - 1) / 1000 + 1); + return (((uint64_t)us * sys_tick_hz / 1000 + 1000 - 1) / 1000 + 1); #endif - } + } } -uint32_t BOOT_TEXT_SRAM_LOC hal_sys_timer_ticks_to_ms(uint32_t tick) -{ - if (tick <= (~0UL / 1000)) { - return tick * 1000 / CONFIG_SYSTICK_HZ; - } else { +uint32_t BOOT_TEXT_SRAM_LOC hal_sys_timer_ticks_to_ms(uint32_t tick) { + if (tick <= (~0UL / 1000)) { + return tick * 1000 / CONFIG_SYSTICK_HZ; + } else { #ifdef TIMER_USE_FPU - return (uint32_t)((float)tick / CONFIG_SYSTICK_HZ * 1000); + return (uint32_t)((float)tick / CONFIG_SYSTICK_HZ * 1000); #else - return (uint64_t)tick * 1000 / CONFIG_SYSTICK_HZ; + return (uint64_t)tick * 1000 / CONFIG_SYSTICK_HZ; #endif - } + } } -uint32_t BOOT_TEXT_SRAM_LOC hal_sys_timer_ticks_to_us(uint32_t tick) -{ - if (tick <= (~0UL / (1000 * 1000))) { - return tick * (1000 * 1000) / CONFIG_SYSTICK_HZ; - } else { +uint32_t BOOT_TEXT_SRAM_LOC hal_sys_timer_ticks_to_us(uint32_t tick) { + if (tick <= (~0UL / (1000 * 1000))) { + return tick * (1000 * 1000) / CONFIG_SYSTICK_HZ; + } else { #ifdef TIMER_USE_FPU - return (uint32_t)((float)tick / CONFIG_SYSTICK_HZ * (1000 * 1000)); + return (uint32_t)((float)tick / CONFIG_SYSTICK_HZ * (1000 * 1000)); #else - return (uint64_t)tick * (1000 * 1000) / CONFIG_SYSTICK_HZ; + return (uint64_t)tick * (1000 * 1000) / CONFIG_SYSTICK_HZ; #endif - } + } } #endif #ifndef RTOS -int osDelay(uint32_t ms) -{ - hal_sys_timer_delay(MS_TO_TICKS(ms)); - return 0; +int osDelay(uint32_t ms) { + hal_sys_timer_delay(MS_TO_TICKS(ms)); + return 0; } #endif -static void hal_timer00_irq_handler(void) -{ - clear_timer_irq(&dual_timer0->timer[0]); - dual_timer0->timer[0].Control &= ~TIMER_CTRL_INTEN; +static void hal_timer00_irq_handler(void) { + clear_timer_irq(&dual_timer0->timer[0]); + dual_timer0->timer[0].Control &= ~TIMER_CTRL_INTEN; } -void hal_timer_setup(enum HAL_TIMER_TYPE_T type, HAL_TIMER_IRQ_HANDLER_T handler) -{ - uint32_t mode; +void hal_timer_setup(enum HAL_TIMER_TYPE_T type, + HAL_TIMER_IRQ_HANDLER_T handler) { + uint32_t mode; - if (type == HAL_TIMER_TYPE_ONESHOT) { - mode = TIMER_CTRL_ONESHOT; - } else if (type == HAL_TIMER_TYPE_PERIODIC) { - mode = TIMER_CTRL_MODE_PERIODIC; - } else { - mode = 0; - } + if (type == HAL_TIMER_TYPE_ONESHOT) { + mode = TIMER_CTRL_ONESHOT; + } else if (type == HAL_TIMER_TYPE_PERIODIC) { + mode = TIMER_CTRL_MODE_PERIODIC; + } else { + mode = 0; + } - irq_handler = handler; + irq_handler = handler; - clear_timer_irq(&dual_timer0->timer[1]); + clear_timer_irq(&dual_timer0->timer[1]); #ifdef ELAPSED_TIMER_ENABLED - dual_timer0->elapsed_timer[1].ElapsedCtrl = TIMER_ELAPSED_CTRL_CLR; + dual_timer0->elapsed_timer[1].ElapsedCtrl = TIMER_ELAPSED_CTRL_CLR; #endif - if (handler) { - NVIC_SetVector(TIMER01_IRQn, (uint32_t)hal_timer01_irq_handler); - NVIC_SetPriority(TIMER01_IRQn, IRQ_PRIORITY_NORMAL); - NVIC_ClearPendingIRQ(TIMER01_IRQn); - NVIC_EnableIRQ(TIMER01_IRQn); - } - - dual_timer0->timer[1].Control = mode | - (handler ? TIMER_CTRL_INTEN : 0) | - TIMER_CTRL_PRESCALE_DIV_1 | - TIMER_CTRL_SIZE_32_BIT; -} - -void hal_timer_start(uint32_t load) -{ - start_time = hal_sys_timer_get(); - hal_timer_reload(load); - hal_timer_continue(); -} - -void hal_timer_stop(void) -{ - dual_timer0->timer[1].Control &= ~TIMER_CTRL_EN; -#ifdef ELAPSED_TIMER_ENABLED - dual_timer0->elapsed_timer[1].ElapsedCtrl = TIMER_ELAPSED_CTRL_CLR; -#endif - clear_timer_irq(&dual_timer0->timer[1]); + if (handler) { + NVIC_SetVector(TIMER01_IRQn, (uint32_t)hal_timer01_irq_handler); + NVIC_SetPriority(TIMER01_IRQn, IRQ_PRIORITY_NORMAL); NVIC_ClearPendingIRQ(TIMER01_IRQn); + NVIC_EnableIRQ(TIMER01_IRQn); + } + + dual_timer0->timer[1].Control = mode | (handler ? TIMER_CTRL_INTEN : 0) | + TIMER_CTRL_PRESCALE_DIV_1 | + TIMER_CTRL_SIZE_32_BIT; } -void hal_timer_continue(void) -{ +void hal_timer_start(uint32_t load) { + start_time = hal_sys_timer_get(); + hal_timer_reload(load); + hal_timer_continue(); +} + +void hal_timer_stop(void) { + dual_timer0->timer[1].Control &= ~TIMER_CTRL_EN; #ifdef ELAPSED_TIMER_ENABLED - dual_timer0->elapsed_timer[1].ElapsedCtrl = TIMER_ELAPSED_CTRL_EN | TIMER_ELAPSED_CTRL_CLR; + dual_timer0->elapsed_timer[1].ElapsedCtrl = TIMER_ELAPSED_CTRL_CLR; #endif - dual_timer0->timer[1].Control |= TIMER_CTRL_EN; + clear_timer_irq(&dual_timer0->timer[1]); + NVIC_ClearPendingIRQ(TIMER01_IRQn); } -int hal_timer_is_enabled(void) -{ - return !!(dual_timer0->timer[1].Control & TIMER_CTRL_EN); -} - -void hal_timer_reload(uint32_t load) -{ - if (load > HAL_TIMER_LOAD_DELTA) { - //load_value = load; - load -= HAL_TIMER_LOAD_DELTA; - } else { - //load_value = HAL_TIMER_LOAD_DELTA + 1; - load = 1; - } - set_timer_load(&dual_timer0->timer[1], load, SLOW_TIMER_VAL_DELTA); -} - -uint32_t hal_timer_get(void) -{ - return get_timer_value(&dual_timer0->timer[1], SLOW_TIMER_VAL_DELTA); -} - -int hal_timer_irq_active(void) -{ - return NVIC_GetActive(TIMER01_IRQn); -} - -int hal_timer_irq_pending(void) -{ - // Or NVIC_GetPendingIRQ(TIMER2_IRQn) ? - return (dual_timer0->timer[1].MIS & TIMER_MIS_MIS); -} - -uint32_t hal_timer_get_overrun_time(void) -{ +void hal_timer_continue(void) { #ifdef ELAPSED_TIMER_ENABLED - uint32_t extra; + dual_timer0->elapsed_timer[1].ElapsedCtrl = + TIMER_ELAPSED_CTRL_EN | TIMER_ELAPSED_CTRL_CLR; +#endif + dual_timer0->timer[1].Control |= TIMER_CTRL_EN; +} - if (dual_timer0->elapsed_timer[1].ElapsedCtrl & TIMER_ELAPSED_CTRL_EN) { - extra = dual_timer0->elapsed_timer[1].ElapsedVal; - } else { - extra = 0; - } +int hal_timer_is_enabled(void) { + return !!(dual_timer0->timer[1].Control & TIMER_CTRL_EN); +} - return extra; +void hal_timer_reload(uint32_t load) { + if (load > HAL_TIMER_LOAD_DELTA) { + // load_value = load; + load -= HAL_TIMER_LOAD_DELTA; + } else { + // load_value = HAL_TIMER_LOAD_DELTA + 1; + load = 1; + } + set_timer_load(&dual_timer0->timer[1], load, SLOW_TIMER_VAL_DELTA); +} + +uint32_t hal_timer_get(void) { + return get_timer_value(&dual_timer0->timer[1], SLOW_TIMER_VAL_DELTA); +} + +int hal_timer_irq_active(void) { return NVIC_GetActive(TIMER01_IRQn); } + +int hal_timer_irq_pending(void) { + // Or NVIC_GetPendingIRQ(TIMER2_IRQn) ? + return (dual_timer0->timer[1].MIS & TIMER_MIS_MIS); +} + +uint32_t hal_timer_get_overrun_time(void) { +#ifdef ELAPSED_TIMER_ENABLED + uint32_t extra; + + if (dual_timer0->elapsed_timer[1].ElapsedCtrl & TIMER_ELAPSED_CTRL_EN) { + extra = dual_timer0->elapsed_timer[1].ElapsedVal; + } else { + extra = 0; + } + + return extra; #else - return 0; + return 0; #endif } -uint32_t hal_timer_get_elapsed_time(void) -{ - //return load_value + hal_timer_get_overrun_time(); - return hal_sys_timer_get() - start_time; +uint32_t hal_timer_get_elapsed_time(void) { + // return load_value + hal_timer_get_overrun_time(); + return hal_sys_timer_get() - start_time; } -static void hal_timer01_irq_handler(void) -{ - uint32_t elapsed; +static void hal_timer01_irq_handler(void) { + uint32_t elapsed; - clear_timer_irq(&dual_timer0->timer[1]); - if (irq_handler) { - elapsed = hal_timer_get_elapsed_time(); - irq_handler(elapsed); - } else { - dual_timer0->timer[1].Control &= ~TIMER_CTRL_INTEN; - } + clear_timer_irq(&dual_timer0->timer[1]); + if (irq_handler) { + elapsed = hal_timer_get_elapsed_time(); + irq_handler(elapsed); + } else { + dual_timer0->timer[1].Control &= ~TIMER_CTRL_INTEN; + } } -uint32_t hal_timer_get_passed_ticks(uint32_t curr_ticks, uint32_t prev_ticks) -{ - if(curr_ticks < prev_ticks) - return ((0xffffffff - prev_ticks + 1) + curr_ticks); - else - return (curr_ticks - prev_ticks); +uint32_t hal_timer_get_passed_ticks(uint32_t curr_ticks, uint32_t prev_ticks) { + if (curr_ticks < prev_ticks) + return ((0xffffffff - prev_ticks + 1) + curr_ticks); + else + return (curr_ticks - prev_ticks); } - diff --git a/platform/hal/hal_trace.c b/platform/hal/hal_trace.c index a5dc12c..3b46ee2 100644 --- a/platform/hal/hal_trace.c +++ b/platform/hal/hal_trace.c @@ -14,7 +14,8 @@ * ****************************************************************************/ #if !(defined(DEBUG) || defined(REL_TRACE_ENABLE)) -// Implement a local copy of dummy trace functions for library linking (which might be built with DEBUG enabled) +// Implement a local copy of dummy trace functions for library linking (which +// might be built with DEBUG enabled) #define TRACE_FUNC_SPEC #endif #include "hal_trace.h" @@ -22,8 +23,9 @@ #ifdef RTOS #include "cmsis_os.h" #endif -#include "hal_cmu.h" +#include "hal_bootmode.h" #include "hal_chipid.h" +#include "hal_cmu.h" #include "hal_codec.h" #include "hal_dma.h" #include "hal_iomux.h" @@ -35,7 +37,6 @@ #include "stdarg.h" #include "stdio.h" #include "string.h" -#include "hal_bootmode.h" #ifdef CORE_DUMP #include "CrashCatcherApi.h" @@ -45,7 +46,8 @@ extern const char sys_build_info[]; extern void nv_record_flash_flush(void); #ifdef FAULT_DUMP -void hal_trace_fault_dump(const uint32_t *regs, const uint32_t *extra, uint32_t extra_len); +void hal_trace_fault_dump(const uint32_t *regs, const uint32_t *extra, + uint32_t extra_len); #ifndef __ARM_ARCH_ISA_ARM static void hal_trace_fault_handler(void); #endif @@ -65,135 +67,142 @@ static void hal_trace_fault_handler(void); #endif #endif -#define TRACE_IDLE_OUTPUT 0 +#define TRACE_IDLE_OUTPUT 0 #ifndef TRACE_BAUD_RATE -#define TRACE_BAUD_RATE (921600) +#define TRACE_BAUD_RATE (921600) #endif #ifndef TRACE_BUF_SIZE #ifdef AUDIO_DEBUG -#define TRACE_BUF_SIZE (6 * 1024) +#define TRACE_BUF_SIZE (6 * 1024) #else -#define TRACE_BUF_SIZE (4 * 1024) +#define TRACE_BUF_SIZE (4 * 1024) #endif #endif -#define CRASH_BUF_SIZE 100 -#define CRASH_BUF_ATTR ALIGNED(4) USED +#define CRASH_BUF_SIZE 100 +#define CRASH_BUF_ATTR ALIGNED(4) USED #ifndef TRACE_STACK_DUMP_PREV_WORD -#define TRACE_STACK_DUMP_PREV_WORD 16 +#define TRACE_STACK_DUMP_PREV_WORD 16 #endif #ifndef TRACE_STACK_DUMP_WORD -#define TRACE_STACK_DUMP_WORD 32 +#define TRACE_STACK_DUMP_WORD 32 #endif #ifndef TRACE_BACKTRACE_NUM -#define TRACE_BACKTRACE_NUM 20 +#define TRACE_BACKTRACE_NUM 20 #endif #ifndef TRACE_BACKTRACE_SEARCH_WORD -#define TRACE_BACKTRACE_SEARCH_WORD 1024 +#define TRACE_BACKTRACE_SEARCH_WORD 1024 #endif -#define STACK_DUMP_CNT_PER_LEN 4 -#define STACK_DUMP_CNT_PREV ((TRACE_STACK_DUMP_PREV_WORD + STACK_DUMP_CNT_PER_LEN - 1) / STACK_DUMP_CNT_PER_LEN * STACK_DUMP_CNT_PER_LEN) -#define STACK_DUMP_CNT ((TRACE_STACK_DUMP_WORD + STACK_DUMP_CNT_PER_LEN - 1) / STACK_DUMP_CNT_PER_LEN * STACK_DUMP_CNT_PER_LEN) +#define STACK_DUMP_CNT_PER_LEN 4 +#define STACK_DUMP_CNT_PREV \ + ((TRACE_STACK_DUMP_PREV_WORD + STACK_DUMP_CNT_PER_LEN - 1) / \ + STACK_DUMP_CNT_PER_LEN * STACK_DUMP_CNT_PER_LEN) +#define STACK_DUMP_CNT \ + ((TRACE_STACK_DUMP_WORD + STACK_DUMP_CNT_PER_LEN - 1) / \ + STACK_DUMP_CNT_PER_LEN * STACK_DUMP_CNT_PER_LEN) -#define TRACE_FLUSH_TIMEOUT MS_TO_TICKS(2000) +#define TRACE_FLUSH_TIMEOUT MS_TO_TICKS(2000) -#define TRACE_NEAR_FULL_THRESH 200 +#define TRACE_NEAR_FULL_THRESH 200 -#define TRACE_CRLF +#define TRACE_CRLF #ifdef TRACE_CRLF -#define NEW_LINE_STR "\r\n" +#define NEW_LINE_STR "\r\n" #else -#define NEW_LINE_STR "\n" +#define NEW_LINE_STR "\n" #endif -#define HAL_TRACE_ASSERT_ID 0xBE57AAAA -#define HAL_TRACE_EXCEPTION_ID 0xBE57EEEE +#define HAL_TRACE_ASSERT_ID 0xBE57AAAA +#define HAL_TRACE_EXCEPTION_ID 0xBE57EEEE -#define HAL_MEMSC_ID_TRACE HAL_MEMSC_ID_0 +#define HAL_MEMSC_ID_TRACE HAL_MEMSC_ID_0 -#define TRACE_BUF_LOC SYNC_FLAGS_LOC +#define TRACE_BUF_LOC SYNC_FLAGS_LOC struct ASSERT_INFO_T { - uint32_t ID; - uint32_t CPU_ID; - const char *FILE; - const char *FUNC; - uint32_t LINE; - const char *FMT; - uint32_t R[15]; + uint32_t ID; + uint32_t CPU_ID; + const char *FILE; + const char *FUNC; + uint32_t LINE; + const char *FMT; + uint32_t R[15]; #ifndef __ARM_ARCH_ISA_ARM - uint32_t MSP; - uint32_t PSP; - uint32_t CONTROL; + uint32_t MSP; + uint32_t PSP; + uint32_t CONTROL; #ifdef __ARM_ARCH_8M_MAIN__ - uint32_t MSPLIM; - uint32_t PSPLIM; + uint32_t MSPLIM; + uint32_t PSPLIM; #endif #endif }; struct EXCEPTION_INFO_T { - uint32_t ID; - uint32_t CPU_ID; - const uint32_t *REGS; + uint32_t ID; + uint32_t CPU_ID; + const uint32_t *REGS; #ifdef __ARM_ARCH_ISA_ARM - const uint32_t *extra; - uint32_t extra_len; + const uint32_t *extra; + uint32_t extra_len; #else - uint32_t MSP; - uint32_t PSP; - uint8_t PRIMASK; - uint8_t FAULTMASK; - uint8_t BASEPRI; - uint8_t CONTROL; - uint32_t ICSR; - uint32_t AIRCR; - uint32_t SCR; - uint32_t CCR; - uint32_t SHCSR; - uint32_t CFSR; - uint32_t HFSR; - uint32_t AFSR; - uint32_t MMFAR; - uint32_t BFAR; + uint32_t MSP; + uint32_t PSP; + uint8_t PRIMASK; + uint8_t FAULTMASK; + uint8_t BASEPRI; + uint8_t CONTROL; + uint32_t ICSR; + uint32_t AIRCR; + uint32_t SCR; + uint32_t CCR; + uint32_t SHCSR; + uint32_t CFSR; + uint32_t HFSR; + uint32_t AFSR; + uint32_t MMFAR; + uint32_t BFAR; #ifdef __ARM_ARCH_8M_MAIN__ - uint32_t MSPLIM; - uint32_t PSPLIM; + uint32_t MSPLIM; + uint32_t PSPLIM; #endif #endif }; static CRASH_BUF_ATTR char crash_buf[CRASH_BUF_SIZE]; -STATIC_ASSERT(sizeof(crash_buf) >= sizeof(((struct ASSERT_INFO_T *)0)->R), "crash_buf too small to hold assert registers"); +STATIC_ASSERT(sizeof(crash_buf) >= sizeof(((struct ASSERT_INFO_T *)0)->R), + "crash_buf too small to hold assert registers"); #if (defined(DEBUG) || defined(REL_TRACE_ENABLE)) struct HAL_TRACE_BUF_T { - unsigned char buf[TRACE_BUF_SIZE]; - unsigned short wptr; - unsigned short rptr; + unsigned char buf[TRACE_BUF_SIZE]; + unsigned short wptr; + unsigned short rptr; #if (TRACE_IDLE_OUTPUT == 0) - unsigned short sends[2]; + unsigned short sends[2]; #endif - unsigned short discards; - bool sending; - bool in_trace; - bool wrapped; + unsigned short discards; + bool sending; + bool in_trace; + bool wrapped; }; -STATIC_ASSERT(TRACE_BUF_SIZE < (1 << (8 * sizeof(((struct HAL_TRACE_BUF_T *)0)->wptr))), "TRACE_BUF_SIZE is too large to fit in wptr/rptr variable"); +STATIC_ASSERT(TRACE_BUF_SIZE < + (1 << (8 * sizeof(((struct HAL_TRACE_BUF_T *)0)->wptr))), + "TRACE_BUF_SIZE is too large to fit in wptr/rptr variable"); static const struct HAL_UART_CFG_T uart_cfg = { .parity = HAL_UART_PARITY_NONE, .stop = HAL_UART_STOP_BITS_1, .data = HAL_UART_DATA_BITS_8, - .flow = HAL_UART_FLOW_CONTROL_NONE,//HAL_UART_FLOW_CONTROL_RTSCTS, + .flow = HAL_UART_FLOW_CONTROL_NONE, // HAL_UART_FLOW_CONTROL_RTSCTS, .tx_level = HAL_UART_FIFO_LEVEL_1_2, .rx_level = HAL_UART_FIFO_LEVEL_1_2, .baud = TRACE_BAUD_RATE, @@ -225,7 +234,7 @@ static const struct HAL_UART_CFG_T uart_rx_enable_cfg = { .parity = HAL_UART_PARITY_NONE, .stop = HAL_UART_STOP_BITS_1, .data = HAL_UART_DATA_BITS_8, - .flow = HAL_UART_FLOW_CONTROL_NONE,//HAL_UART_FLOW_CONTROL_RTSCTS, + .flow = HAL_UART_FLOW_CONTROL_NONE, // HAL_UART_FLOW_CONTROL_RTSCTS, .tx_level = HAL_UART_FIFO_LEVEL_1_2, .rx_level = HAL_UART_FIFO_LEVEL_1_2, .baud = TRACE_BAUD_RATE, @@ -261,7 +270,8 @@ static const unsigned char discards_digit_start = sizeof(discards_prefix) - 1; static bool crash_dump_onprocess = false; #ifdef CRASH_DUMP_ENABLE -static HAL_TRACE_CRASH_DUMP_CB_T crash_dump_cb_list[HAL_TRACE_CRASH_DUMP_MODULE_END]; +static HAL_TRACE_CRASH_DUMP_CB_T + crash_dump_cb_list[HAL_TRACE_CRASH_DUMP_MODULE_END]; static bool crash_handling; #ifdef TRACE_TO_APP static HAL_TRACE_APP_NOTIFY_T app_notify_cb = NULL; @@ -287,1341 +297,1330 @@ static const char trace_head_buf[] = "[trace]"; static enum LOG_LEVEL_T trace_max_level; static uint32_t trace_mod_map[(LOG_MODULE_QTY + 31) / 32]; -static bool hal_trace_is_uart_transport(enum HAL_TRACE_TRANSPORT_T transport) -{ - if (transport == HAL_TRACE_TRANSPORT_UART0 +static bool hal_trace_is_uart_transport(enum HAL_TRACE_TRANSPORT_T transport) { + if (transport == HAL_TRACE_TRANSPORT_UART0 #if (CHIP_HAS_UART > 1) - || transport == HAL_TRACE_TRANSPORT_UART1 + || transport == HAL_TRACE_TRANSPORT_UART1 #endif #if (CHIP_HAS_UART > 2) - || transport == HAL_TRACE_TRANSPORT_UART2 + || transport == HAL_TRACE_TRANSPORT_UART2 #endif - ) { - return true; - } - return false; + ) { + return true; + } + return false; } #if (TRACE_IDLE_OUTPUT == 0) -static void hal_trace_uart_send(void) -{ - uint32_t wptr, rptr; - uint32_t sends[2]; - uint32_t lock; +static void hal_trace_uart_send(void) { + uint32_t wptr, rptr; + uint32_t sends[2]; + uint32_t lock; - lock = int_lock(); + lock = int_lock(); - wptr = trace.wptr; - rptr = trace.rptr; + wptr = trace.wptr; + rptr = trace.rptr; - // There is a race condition if we do not check s/w flag, but only check the h/w status. - // [e.g., hal_gpdma_chan_busy(dma_cfg.ch)] - // When the DMA is done, but DMA IRQ handler is still pending due to interrupt lock - // or higher priority IRQ, it will have a chance to send the same content twice. - if (!trace.sending && wptr != rptr) { - trace.sending = true; + // There is a race condition if we do not check s/w flag, but only check the + // h/w status. [e.g., hal_gpdma_chan_busy(dma_cfg.ch)] When the DMA is done, + // but DMA IRQ handler is still pending due to interrupt lock or higher + // priority IRQ, it will have a chance to send the same content twice. + if (!trace.sending && wptr != rptr) { + trace.sending = true; + sends[1] = 0; + if (wptr > rptr) { + sends[0] = wptr - rptr; + } else { + sends[0] = TRACE_BUF_SIZE - rptr; + if (sends[0] <= HAL_DMA_MAX_DESC_XFER_SIZE) { + sends[1] = wptr; + } + } + if (sends[0] > HAL_DMA_MAX_DESC_XFER_SIZE) { + sends[1] = sends[0] - HAL_DMA_MAX_DESC_XFER_SIZE; + sends[0] = HAL_DMA_MAX_DESC_XFER_SIZE; + } + if (sends[1] > HAL_DMA_MAX_DESC_XFER_SIZE) { + sends[1] = HAL_DMA_MAX_DESC_XFER_SIZE; + } + + dma_cfg.src = (uint32_t)&trace.buf[rptr]; + if (sends[1] == 0) { + dma_cfg.src_tsize = sends[0]; + hal_gpdma_init_desc(&dma_desc[0], &dma_cfg, NULL, 1); + } else { + dma_cfg.src_tsize = sends[0]; + hal_gpdma_init_desc(&dma_desc[0], &dma_cfg, &dma_desc[1], 0); + + if (rptr + sends[0] < TRACE_BUF_SIZE) { + dma_cfg.src = (uint32_t)&trace.buf[rptr + sends[0]]; + } else { + dma_cfg.src = (uint32_t)&trace.buf[0]; + } + dma_cfg.src_tsize = sends[1]; + hal_gpdma_init_desc(&dma_desc[1], &dma_cfg, NULL, 1); + } + trace.sends[0] = sends[0]; + trace.sends[1] = sends[1]; + + hal_gpdma_sg_start(&dma_desc[0], &dma_cfg); + } + + int_unlock(lock); +} + +static void hal_trace_uart_xfer_done(uint8_t chan, uint32_t remain_tsize, + uint32_t error, + struct HAL_DMA_DESC_T *lli) { + uint32_t sends[2]; + uint32_t lock; + + lock = int_lock(); + + sends[0] = trace.sends[0]; + sends[1] = trace.sends[1]; + + if (error) { + if (lli || sends[1] == 0) { + if (sends[0] > remain_tsize) { + sends[0] -= remain_tsize; + } else { + sends[0] = 0; + } + sends[1] = 0; + } else { + if (sends[1] > remain_tsize) { + sends[1] -= remain_tsize; + } else { sends[1] = 0; - if (wptr > rptr) { - sends[0] = wptr - rptr; - } else { - sends[0] = TRACE_BUF_SIZE - rptr; - if (sends[0] <= HAL_DMA_MAX_DESC_XFER_SIZE) { - sends[1] = wptr; - } - } - if (sends[0] > HAL_DMA_MAX_DESC_XFER_SIZE) { - sends[1] = sends[0] - HAL_DMA_MAX_DESC_XFER_SIZE; - sends[0] = HAL_DMA_MAX_DESC_XFER_SIZE; - } - if (sends[1] > HAL_DMA_MAX_DESC_XFER_SIZE) { - sends[1] = HAL_DMA_MAX_DESC_XFER_SIZE; - } - - dma_cfg.src = (uint32_t)&trace.buf[rptr]; - if (sends[1] == 0) { - dma_cfg.src_tsize = sends[0]; - hal_gpdma_init_desc(&dma_desc[0], &dma_cfg, NULL, 1); - } else { - dma_cfg.src_tsize = sends[0]; - hal_gpdma_init_desc(&dma_desc[0], &dma_cfg, &dma_desc[1], 0); - - if (rptr + sends[0] < TRACE_BUF_SIZE) { - dma_cfg.src = (uint32_t)&trace.buf[rptr + sends[0]]; - } else { - dma_cfg.src = (uint32_t)&trace.buf[0]; - } - dma_cfg.src_tsize = sends[1]; - hal_gpdma_init_desc(&dma_desc[1], &dma_cfg, NULL, 1); - } - trace.sends[0] = sends[0]; - trace.sends[1] = sends[1]; - - hal_gpdma_sg_start(&dma_desc[0], &dma_cfg); + } } + } - int_unlock(lock); + trace.rptr += sends[0] + sends[1]; + if (trace.rptr >= TRACE_BUF_SIZE) { + trace.rptr -= TRACE_BUF_SIZE; + } + trace.sends[0] = 0; + trace.sends[1] = 0; + trace.sending = false; + + hal_trace_uart_send(); + + int_unlock(lock); } -static void hal_trace_uart_xfer_done(uint8_t chan, uint32_t remain_tsize, uint32_t error, struct HAL_DMA_DESC_T *lli) -{ - uint32_t sends[2]; - uint32_t lock; - - lock = int_lock(); - - sends[0] = trace.sends[0]; - sends[1] = trace.sends[1]; - - if (error) { - if (lli || sends[1] == 0) { - if (sends[0] > remain_tsize) { - sends[0] -= remain_tsize; - } else { - sends[0] = 0; - } - sends[1] = 0; - } else { - if (sends[1] > remain_tsize) { - sends[1] -= remain_tsize; - } else { - sends[1] = 0; - } - } - } - - trace.rptr += sends[0] + sends[1]; - if (trace.rptr >= TRACE_BUF_SIZE) { - trace.rptr -= TRACE_BUF_SIZE; - } - trace.sends[0] = 0; - trace.sends[1] = 0; - trace.sending = false; - - hal_trace_uart_send(); - - int_unlock(lock); -} - -static void hal_trace_send(void) -{ +static void hal_trace_send(void) { #ifdef CP_TRACE_ENABLE - if (get_cpu_id()) { - return; - } + if (get_cpu_id()) { + return; + } #endif - if (hal_trace_is_uart_transport(trace_transport)) { - hal_trace_uart_send(); - } + if (hal_trace_is_uart_transport(trace_transport)) { + hal_trace_uart_send(); + } } #else // TRACE_IDLE_OUTPUT -static void hal_trace_uart_idle_send(void) -{ - int i; - uint32_t lock; - unsigned short wptr, rptr; +static void hal_trace_uart_idle_send(void) { + int i; + uint32_t lock; + unsigned short wptr, rptr; - lock = int_lock(); - wptr = trace.wptr; - rptr = trace.rptr; - int_unlock(lock); + lock = int_lock(); + wptr = trace.wptr; + rptr = trace.rptr; + int_unlock(lock); - if (wptr == rptr) { - return; + if (wptr == rptr) { + return; + } + + if (wptr < rptr) { + for (i = rptr; i < TRACE_BUF_SIZE; i++) { + hal_uart_blocked_putc(trace_uart, trace.buf[i]); } + rptr = 0; + } - if (wptr < rptr) { - for (i = rptr; i < TRACE_BUF_SIZE; i++) { - hal_uart_blocked_putc(trace_uart, trace.buf[i]); - } - rptr = 0; - } + for (i = rptr; i < wptr; i++) { + hal_uart_blocked_putc(trace_uart, trace.buf[i]); + } - for (i = rptr; i < wptr; i++) { - hal_uart_blocked_putc(trace_uart, trace.buf[i]); - } - - trace.rptr = wptr; - if (trace.rptr >= TRACE_BUF_SIZE) { - trace.rptr -= TRACE_BUF_SIZE; - } + trace.rptr = wptr; + if (trace.rptr >= TRACE_BUF_SIZE) { + trace.rptr -= TRACE_BUF_SIZE; + } } -void hal_trace_idle_send(void) -{ - if (hal_trace_is_uart_transport(trace_transport)) { - hal_trace_uart_idle_send(); - } +void hal_trace_idle_send(void) { + if (hal_trace_is_uart_transport(trace_transport)) { + hal_trace_uart_idle_send(); + } } #endif // TRACE_IDLE_OUTPUT -int hal_trace_open(enum HAL_TRACE_TRANSPORT_T transport) -{ - int ret; +int hal_trace_open(enum HAL_TRACE_TRANSPORT_T transport) { + int ret; - crash_dump_onprocess = false; + crash_dump_onprocess = false; #if (CHIP_HAS_UART > 1) #ifdef FORCE_TRACE_UART1 - transport = HAL_TRACE_TRANSPORT_UART1; + transport = HAL_TRACE_TRANSPORT_UART1; #endif #endif #if (CHIP_HAS_UART > 2) #ifdef FORCE_TRACE_UART2 - transport = HAL_TRACE_TRANSPORT_UART2; + transport = HAL_TRACE_TRANSPORT_UART2; #endif #endif - if (transport >= HAL_TRACE_TRANSPORT_QTY) { - return 1; - } + if (transport >= HAL_TRACE_TRANSPORT_QTY) { + return 1; + } #ifdef CHIP_HAS_USB - if (transport == HAL_TRACE_TRANSPORT_USB) { - return 1; - } + if (transport == HAL_TRACE_TRANSPORT_USB) { + return 1; + } #endif - if (trace_transport != HAL_TRACE_TRANSPORT_QTY) { - return hal_trace_switch(transport); + if (trace_transport != HAL_TRACE_TRANSPORT_QTY) { + return hal_trace_switch(transport); + } + + trace_max_level = LOG_LEVEL_INFO; + for (int i = 0; i < ARRAY_SIZE(trace_mod_map); i++) { + trace_mod_map[i] = ~0; + } + + memcpy(discards_buf, discards_prefix, discards_digit_start); + + trace.wptr = 0; + trace.rptr = 0; + trace.discards = 0; + trace.sending = false; + trace.in_trace = false; + trace.wrapped = false; + + if (hal_trace_is_uart_transport(transport)) { + trace_uart = HAL_UART_ID_0 + (transport - HAL_TRACE_TRANSPORT_UART0); + ret = hal_uart_open(trace_uart, &uart_cfg); + if (ret) { + return ret; } - trace_max_level = LOG_LEVEL_INFO; - for (int i = 0; i < ARRAY_SIZE(trace_mod_map); i++) { - trace_mod_map[i] = ~0; - } - - memcpy(discards_buf, discards_prefix, discards_digit_start); - - trace.wptr = 0; - trace.rptr = 0; - trace.discards = 0; - trace.sending = false; - trace.in_trace = false; - trace.wrapped = false; - - if (hal_trace_is_uart_transport(transport)) { - trace_uart = HAL_UART_ID_0 + (transport - HAL_TRACE_TRANSPORT_UART0); - ret = hal_uart_open(trace_uart, &uart_cfg); - if (ret) { - return ret; - } - #if (TRACE_IDLE_OUTPUT == 0) - trace.sends[0] = 0; - trace.sends[1] = 0; + trace.sends[0] = 0; + trace.sends[1] = 0; - memset(&dma_cfg, 0, sizeof(dma_cfg)); - dma_cfg.dst = 0; // useless - dma_cfg.dst_bsize = HAL_DMA_BSIZE_8; - dma_cfg.dst_periph = uart_periph[trace_uart - HAL_UART_ID_0]; - dma_cfg.dst_width = HAL_DMA_WIDTH_BYTE; - dma_cfg.handler = hal_trace_uart_xfer_done; - dma_cfg.src_bsize = HAL_DMA_BSIZE_32; - dma_cfg.src_periph = 0; // useless - dma_cfg.src_width = HAL_DMA_WIDTH_BYTE; - dma_cfg.type = HAL_DMA_FLOW_M2P_DMA; - dma_cfg.try_burst = 0; - dma_cfg.ch = hal_gpdma_get_chan(dma_cfg.dst_periph, HAL_DMA_HIGH_PRIO); + memset(&dma_cfg, 0, sizeof(dma_cfg)); + dma_cfg.dst = 0; // useless + dma_cfg.dst_bsize = HAL_DMA_BSIZE_8; + dma_cfg.dst_periph = uart_periph[trace_uart - HAL_UART_ID_0]; + dma_cfg.dst_width = HAL_DMA_WIDTH_BYTE; + dma_cfg.handler = hal_trace_uart_xfer_done; + dma_cfg.src_bsize = HAL_DMA_BSIZE_32; + dma_cfg.src_periph = 0; // useless + dma_cfg.src_width = HAL_DMA_WIDTH_BYTE; + dma_cfg.type = HAL_DMA_FLOW_M2P_DMA; + dma_cfg.try_burst = 0; + dma_cfg.ch = hal_gpdma_get_chan(dma_cfg.dst_periph, HAL_DMA_HIGH_PRIO); - ASSERT(dma_cfg.ch != HAL_DMA_CHAN_NONE, "Failed to get DMA channel"); + ASSERT(dma_cfg.ch != HAL_DMA_CHAN_NONE, "Failed to get DMA channel"); #endif - } + } #ifdef FAULT_DUMP #ifdef __ARM_ARCH_ISA_ARM - GIC_SetFaultDumpHandler(hal_trace_fault_dump); + GIC_SetFaultDumpHandler(hal_trace_fault_dump); #else - NVIC_SetDefaultFaultHandler(hal_trace_fault_handler); + NVIC_SetDefaultFaultHandler(hal_trace_fault_handler); #endif #endif - trace_transport = transport; + trace_transport = transport; #ifdef HAL_TRACE_RX_ENABLE - hal_trace_rx_open(); + hal_trace_rx_open(); #endif - // Show build info - static const char dbl_new_line[] = NEW_LINE_STR NEW_LINE_STR; - hal_trace_output((unsigned char *)dbl_new_line, sizeof(dbl_new_line)); - hal_trace_output((unsigned char *)sys_build_info, strlen(sys_build_info)+1); + // Show build info + static const char dbl_new_line[] = NEW_LINE_STR NEW_LINE_STR; + hal_trace_output((unsigned char *)dbl_new_line, sizeof(dbl_new_line)); + hal_trace_output((unsigned char *)sys_build_info, strlen(sys_build_info) + 1); - char buf[50]; - int len; - len = snprintf(buf, sizeof(buf), - NEW_LINE_STR NEW_LINE_STR "------" NEW_LINE_STR "METAL_ID: %d" NEW_LINE_STR "------" NEW_LINE_STR NEW_LINE_STR, - hal_get_chip_metal_id()); - hal_trace_output((unsigned char *)buf, len+1); + char buf[50]; + int len; + len = snprintf(buf, sizeof(buf), + NEW_LINE_STR NEW_LINE_STR "------" NEW_LINE_STR + "METAL_ID: %d" NEW_LINE_STR + "------" NEW_LINE_STR NEW_LINE_STR, + hal_get_chip_metal_id()); + hal_trace_output((unsigned char *)buf, len + 1); - return 0; + return 0; } -int hal_trace_switch(enum HAL_TRACE_TRANSPORT_T transport) -{ - uint32_t POSSIBLY_UNUSED lock; - int ret; +int hal_trace_switch(enum HAL_TRACE_TRANSPORT_T transport) { + uint32_t POSSIBLY_UNUSED lock; + int ret; #if (CHIP_HAS_UART > 1) #ifdef FORCE_TRACE_UART1 - transport = HAL_TRACE_TRANSPORT_UART1; + transport = HAL_TRACE_TRANSPORT_UART1; #endif #endif #if (CHIP_HAS_UART > 2) #ifdef FORCE_TRACE_UART2 - transport = HAL_TRACE_TRANSPORT_UART2; + transport = HAL_TRACE_TRANSPORT_UART2; #endif #endif #ifdef CHIP_HAS_USB - if (transport == HAL_TRACE_TRANSPORT_USB) { - return 1; - } + if (transport == HAL_TRACE_TRANSPORT_USB) { + return 1; + } #endif - if (transport >= HAL_TRACE_TRANSPORT_QTY) { - return 1; - } - if (trace_transport >= HAL_TRACE_TRANSPORT_QTY) { - return 1; - } - if (trace_transport == transport) { - return 0; - } + if (transport >= HAL_TRACE_TRANSPORT_QTY) { + return 1; + } + if (trace_transport >= HAL_TRACE_TRANSPORT_QTY) { + return 1; + } + if (trace_transport == transport) { + return 0; + } - ret = 0; + ret = 0; #if (CHIP_HAS_UART > 1) - lock = int_lock(); + lock = int_lock(); - if (hal_trace_is_uart_transport(trace_transport)) { + if (hal_trace_is_uart_transport(trace_transport)) { #if (TRACE_IDLE_OUTPUT == 0) - if (dma_cfg.ch != HAL_DMA_CHAN_NONE) { - hal_gpdma_cancel(dma_cfg.ch); - } -#endif - hal_uart_close(trace_uart); + if (dma_cfg.ch != HAL_DMA_CHAN_NONE) { + hal_gpdma_cancel(dma_cfg.ch); } +#endif + hal_uart_close(trace_uart); + } - if (hal_trace_is_uart_transport(transport)) { - trace_uart = HAL_UART_ID_0 + (transport - HAL_TRACE_TRANSPORT_UART0); + if (hal_trace_is_uart_transport(transport)) { + trace_uart = HAL_UART_ID_0 + (transport - HAL_TRACE_TRANSPORT_UART0); #if (TRACE_IDLE_OUTPUT == 0) - dma_cfg.dst_periph = uart_periph[trace_uart - HAL_UART_ID_0]; - trace.sends[0] = 0; - trace.sends[1] = 0; + dma_cfg.dst_periph = uart_periph[trace_uart - HAL_UART_ID_0]; + trace.sends[0] = 0; + trace.sends[1] = 0; #endif - ret = hal_uart_open(trace_uart, &uart_cfg); - if (ret) { + ret = hal_uart_open(trace_uart, &uart_cfg); + if (ret) { #if (TRACE_IDLE_OUTPUT == 0) - hal_gpdma_free_chan(dma_cfg.ch); - dma_cfg.ch = HAL_DMA_CHAN_NONE; + hal_gpdma_free_chan(dma_cfg.ch); + dma_cfg.ch = HAL_DMA_CHAN_NONE; #endif - trace_transport = HAL_TRACE_TRANSPORT_QTY; - goto _exit; - } + trace_transport = HAL_TRACE_TRANSPORT_QTY; + goto _exit; } + } - trace.sending = false; + trace.sending = false; - trace_transport = transport; + trace_transport = transport; _exit: - int_unlock(lock); + int_unlock(lock); #endif // CHIP_HAS_UART > 1 - return ret; + return ret; } -int hal_trace_close(void) -{ - if (trace_transport >= HAL_TRACE_TRANSPORT_QTY) { - goto _exit; - } +int hal_trace_close(void) { + if (trace_transport >= HAL_TRACE_TRANSPORT_QTY) { + goto _exit; + } #ifdef CHIP_HAS_USB - if (trace_transport == HAL_TRACE_TRANSPORT_USB) { - goto _exit; - } + if (trace_transport == HAL_TRACE_TRANSPORT_USB) { + goto _exit; + } #endif - if (hal_trace_is_uart_transport(trace_transport)) { + if (hal_trace_is_uart_transport(trace_transport)) { #if (TRACE_IDLE_OUTPUT == 0) - if (dma_cfg.ch != HAL_DMA_CHAN_NONE) { - hal_gpdma_cancel(dma_cfg.ch); - hal_gpdma_free_chan(dma_cfg.ch); - dma_cfg.ch = HAL_DMA_CHAN_NONE; - } -#endif - hal_uart_close(trace_uart); + if (dma_cfg.ch != HAL_DMA_CHAN_NONE) { + hal_gpdma_cancel(dma_cfg.ch); + hal_gpdma_free_chan(dma_cfg.ch); + dma_cfg.ch = HAL_DMA_CHAN_NONE; } +#endif + hal_uart_close(trace_uart); + } _exit: - trace_transport = HAL_TRACE_TRANSPORT_QTY; + trace_transport = HAL_TRACE_TRANSPORT_QTY; - return 0; + return 0; } -int hal_trace_enable_log_module(enum LOG_MODULE_T module) -{ - if (module >= LOG_MODULE_QTY) { - return 1; - } +int hal_trace_enable_log_module(enum LOG_MODULE_T module) { + if (module >= LOG_MODULE_QTY) { + return 1; + } - trace_mod_map[module >> 5] |= (1 << (module & 0x1F)); - return 0; + trace_mod_map[module >> 5] |= (1 << (module & 0x1F)); + return 0; } -int hal_trace_disable_log_module(enum LOG_MODULE_T module) -{ - if (module >= LOG_MODULE_QTY) { - return 1; - } +int hal_trace_disable_log_module(enum LOG_MODULE_T module) { + if (module >= LOG_MODULE_QTY) { + return 1; + } - trace_mod_map[module >> 5] &= ~(1 << (module & 0x1F)); - return 0; + trace_mod_map[module >> 5] &= ~(1 << (module & 0x1F)); + return 0; } -int hal_trace_set_log_module(const uint32_t *map, uint32_t word_cnt) -{ - if (map == NULL || word_cnt == 0) { - return 1; - } +int hal_trace_set_log_module(const uint32_t *map, uint32_t word_cnt) { + if (map == NULL || word_cnt == 0) { + return 1; + } - if (word_cnt > ARRAY_SIZE(trace_mod_map)) { - word_cnt = ARRAY_SIZE(trace_mod_map); - } - for (int i = 0; i < word_cnt; i++) { - trace_mod_map[i] = map[i]; - } - return 0; + if (word_cnt > ARRAY_SIZE(trace_mod_map)) { + word_cnt = ARRAY_SIZE(trace_mod_map); + } + for (int i = 0; i < word_cnt; i++) { + trace_mod_map[i] = map[i]; + } + return 0; } -int hal_trace_set_log_level(enum LOG_LEVEL_T level) -{ - if (level >= LOG_LEVEL_QTY) { - return 1; - } +int hal_trace_set_log_level(enum LOG_LEVEL_T level) { + if (level >= LOG_LEVEL_QTY) { + return 1; + } - trace_max_level = level; - return 0; + trace_max_level = level; + return 0; } -void hal_trace_get_history_buffer(const unsigned char **buf1, unsigned int *len1, const unsigned char **buf2, unsigned int *len2) -{ - uint32_t lock; - uint8_t *b1, *b2; - uint32_t l1, l2; +void hal_trace_get_history_buffer(const unsigned char **buf1, + unsigned int *len1, + const unsigned char **buf2, + unsigned int *len2) { + uint32_t lock; + uint8_t *b1, *b2; + uint32_t l1, l2; - b1 = b2 = NULL; - l1 = l2 = 0; + b1 = b2 = NULL; + l1 = l2 = 0; - lock = int_lock(); + lock = int_lock(); - if (TRACE_BUF_SIZE > trace.wptr) { - if (trace.wrapped) { - b1 = &trace.buf[trace.wptr]; - l1 = TRACE_BUF_SIZE - trace.wptr; - b2 = &trace.buf[0]; - l2 = trace.wptr; - } else { - b1 = &trace.buf[0]; - l1 = trace.wptr; - b2 = NULL; - l2 = 0; - } + if (TRACE_BUF_SIZE > trace.wptr) { + if (trace.wrapped) { + b1 = &trace.buf[trace.wptr]; + l1 = TRACE_BUF_SIZE - trace.wptr; + b2 = &trace.buf[0]; + l2 = trace.wptr; + } else { + b1 = &trace.buf[0]; + l1 = trace.wptr; + b2 = NULL; + l2 = 0; } + } - int_unlock(lock); + int_unlock(lock); - if (buf1) { - *buf1 = b1; - } - if (len1) { - *len1 = l1; - } - if (buf2) { - *buf2 = b2; - } - if (len2) { - *len2 = l2; - } + if (buf1) { + *buf1 = b1; + } + if (len1) { + *len1 = l1; + } + if (buf2) { + *buf2 = b2; + } + if (len2) { + *len2 = l2; + } } -static void hal_trace_print_discards(uint32_t discards) -{ - static const uint8_t base = 10; - char digit[5], *d, *out; - uint16_t len; - uint16_t size; +static void hal_trace_print_discards(uint32_t discards) { + static const uint8_t base = 10; + char digit[5], *d, *out; + uint16_t len; + uint16_t size; - if (discards > max_discards) { - discards = max_discards; - } + if (discards > max_discards) { + discards = max_discards; + } - d = &digit[0]; - do { - *d++ = (discards % base) + '0'; - } while (discards /= base); + d = &digit[0]; + do { + *d++ = (discards % base) + '0'; + } while (discards /= base); - out = &discards_buf[discards_digit_start]; - do { - *out++ = *--d; - } while (d > &digit[0]); + out = &discards_buf[discards_digit_start]; + do { + *out++ = *--d; + } while (d > &digit[0]); #ifdef TRACE_CRLF - *out++ = '\r'; + *out++ = '\r'; #endif - *out++ = '\n'; - len = out - &discards_buf[0]; + *out++ = '\n'; + len = out - &discards_buf[0]; - size = TRACE_BUF_SIZE - trace.wptr; - if (size >= len) { - size = len; - } - memcpy(&trace.buf[trace.wptr], &discards_buf[0], size); - if (size < len) { - memcpy(&trace.buf[0], &discards_buf[size], len - size); - } - trace.wptr += len; - if (trace.wptr >= TRACE_BUF_SIZE) { - trace.wptr -= TRACE_BUF_SIZE; - } + size = TRACE_BUF_SIZE - trace.wptr; + if (size >= len) { + size = len; + } + memcpy(&trace.buf[trace.wptr], &discards_buf[0], size); + if (size < len) { + memcpy(&trace.buf[0], &discards_buf[size], len - size); + } + trace.wptr += len; + if (trace.wptr >= TRACE_BUF_SIZE) { + trace.wptr -= TRACE_BUF_SIZE; + } } #ifdef AUDIO_DEBUG_V0_1_0 -static void hal_trace_print_head(void) -{ - uint16_t len; - uint16_t size; +static void hal_trace_print_head(void) { + uint16_t len; + uint16_t size; - len = sizeof(trace_head_buf) - 1; + len = sizeof(trace_head_buf) - 1; - size = TRACE_BUF_SIZE - trace.wptr; - if (size >= len) { - size = len; - } - memcpy(&trace.buf[trace.wptr], &trace_head_buf[0], size); - if (size < len) { - memcpy(&trace.buf[0], &trace_head_buf[size], len - size); - } - trace.wptr += len; - if (trace.wptr >= TRACE_BUF_SIZE) { - trace.wptr -= TRACE_BUF_SIZE; - } + size = TRACE_BUF_SIZE - trace.wptr; + if (size >= len) { + size = len; + } + memcpy(&trace.buf[trace.wptr], &trace_head_buf[0], size); + if (size < len) { + memcpy(&trace.buf[0], &trace_head_buf[size], len - size); + } + trace.wptr += len; + if (trace.wptr >= TRACE_BUF_SIZE) { + trace.wptr -= TRACE_BUF_SIZE; + } } #endif -int hal_trace_output(const unsigned char *buf, unsigned int buf_len) -{ - int ret; - uint32_t lock; - uint32_t avail; - uint32_t out_len; - uint16_t size; +int hal_trace_output(const unsigned char *buf, unsigned int buf_len) { + int ret; + uint32_t lock; + uint32_t avail; + uint32_t out_len; + uint16_t size; - ret = 0; + ret = 0; - lock = int_lock(); + lock = int_lock(); #ifdef CP_TRACE_ENABLE - while (hal_memsc_lock(HAL_MEMSC_ID_TRACE) == 0); + while (hal_memsc_lock(HAL_MEMSC_ID_TRACE) == 0) + ; #endif - // Avoid troubles when NMI occurs during trace - if (!trace.in_trace) { - trace.in_trace = true; + // Avoid troubles when NMI occurs during trace + if (!trace.in_trace) { + trace.in_trace = true; - if (trace.wptr >= trace.rptr) { - avail = TRACE_BUF_SIZE - (trace.wptr - trace.rptr) - 1; - } else { - avail = (trace.rptr - trace.wptr) - 1; - } + if (trace.wptr >= trace.rptr) { + avail = TRACE_BUF_SIZE - (trace.wptr - trace.rptr) - 1; + } else { + avail = (trace.rptr - trace.wptr) - 1; + } - out_len = buf_len; + out_len = buf_len; #ifdef AUDIO_DEBUG_V0_1_0 - out_len += sizeof(trace_head_buf) - 1; + out_len += sizeof(trace_head_buf) - 1; #endif - if (trace.discards) { - out_len += sizeof(discards_buf); - } + if (trace.discards) { + out_len += sizeof(discards_buf); + } + if (avail < out_len) { + ret = 1; + if (trace.discards < (1 << (sizeof(trace.discards) * 8)) - 1) { + trace.discards++; + } +#ifdef CP_TRACE_ENABLE +#if (TRACE_IDLE_OUTPUT == 0) + hal_trace_send(); +#endif +#endif + } else { +#ifdef AUDIO_DEBUG_V0_1_0 + hal_trace_print_head(); +#endif + + if (trace.discards) { + hal_trace_print_discards(trace.discards); + trace.discards = 0; + } + + size = TRACE_BUF_SIZE - trace.wptr; + if (size >= buf_len) { + size = buf_len; + } + memcpy(&trace.buf[trace.wptr], &buf[0], size); + if (size < buf_len) { + memcpy(&trace.buf[0], &buf[size], buf_len - size); + } + trace.wptr += buf_len; + if (trace.wptr >= TRACE_BUF_SIZE) { + trace.wptr -= TRACE_BUF_SIZE; + trace.wrapped = true; + } +#if (TRACE_IDLE_OUTPUT == 0) + hal_trace_send(); +#endif + } + +#ifdef CP_TRACE_ENABLE + if (get_cpu_id()) { + if (cp_buffer_cb) { if (avail < out_len) { - ret = 1; - if (trace.discards < (1 << (sizeof(trace.discards) * 8)) - 1) { - trace.discards++; - } -#ifdef CP_TRACE_ENABLE -#if (TRACE_IDLE_OUTPUT == 0) - hal_trace_send(); -#endif -#endif - } else { -#ifdef AUDIO_DEBUG_V0_1_0 - hal_trace_print_head(); -#endif - - if (trace.discards) { - hal_trace_print_discards(trace.discards); - trace.discards = 0; - } - - size = TRACE_BUF_SIZE - trace.wptr; - if (size >= buf_len) { - size = buf_len; - } - memcpy(&trace.buf[trace.wptr], &buf[0], size); - if (size < buf_len) { - memcpy(&trace.buf[0], &buf[size], buf_len - size); - } - trace.wptr += buf_len; - if (trace.wptr >= TRACE_BUF_SIZE) { - trace.wptr -= TRACE_BUF_SIZE; - trace.wrapped = true; - } -#if (TRACE_IDLE_OUTPUT == 0) - hal_trace_send(); -#endif - } - -#ifdef CP_TRACE_ENABLE - if (get_cpu_id()) { - if (cp_buffer_cb) { - if (avail < out_len) { - cp_buffer_cb(HAL_TRACE_BUF_STATE_FULL); - } else if (avail - out_len < TRACE_NEAR_FULL_THRESH) { - cp_buffer_cb(HAL_TRACE_BUF_STATE_NEAR_FULL); - } - } + cp_buffer_cb(HAL_TRACE_BUF_STATE_FULL); + } else if (avail - out_len < TRACE_NEAR_FULL_THRESH) { + cp_buffer_cb(HAL_TRACE_BUF_STATE_NEAR_FULL); } + } + } #endif - trace.in_trace = false; + trace.in_trace = false; #ifdef CRASH_DUMP_ENABLE #ifdef TRACE_TO_APP - if (app_output_cb && app_output_enabled) { - bool saved_output_state; + if (app_output_cb && app_output_enabled) { + bool saved_output_state; - saved_output_state = app_output_enabled; - app_output_enabled = false; + saved_output_state = app_output_enabled; + app_output_enabled = false; - app_output_cb(buf, buf_len); + app_output_cb(buf, buf_len); - app_output_enabled = saved_output_state; - } -#endif -#endif + app_output_enabled = saved_output_state; } +#endif +#endif + } #ifdef CP_TRACE_ENABLE - hal_memsc_unlock(HAL_MEMSC_ID_TRACE); + hal_memsc_unlock(HAL_MEMSC_ID_TRACE); #endif - int_unlock(lock); + int_unlock(lock); - return ret ? 0 : buf_len; + return ret ? 0 : buf_len; } #ifdef USE_TRACE_ID -//define USE_CRC_CHECK +// define USE_CRC_CHECK //#define LITE_VERSION typedef struct { - uint32_t crc:6; - uint32_t count:4; - uint32_t tskid:5; - uint32_t addr:17; //127 KB trace space support -}trace_info_t; + uint32_t crc : 6; + uint32_t count : 4; + uint32_t tskid : 5; + uint32_t addr : 17; // 127 KB trace space support +} trace_info_t; typedef struct { - uint32_t crc:8; - uint32_t timestamp:24; // 4 hours support -}trace_head_t; + uint32_t crc : 8; + uint32_t timestamp : 24; // 4 hours support +} trace_head_t; typedef struct { #ifndef LITE_VERSION - trace_head_t trace_head; + trace_head_t trace_head; #endif - trace_info_t trace_info; -}__attribute__((packed)) LOG_DATA_T; + trace_info_t trace_info; +} __attribute__((packed)) LOG_DATA_T; extern const char *unkonw_str; extern uint32_t __trc_str_start__[]; extern uint32_t __trc_str_end__[]; -uint8_t crc8(uint8_t *data, uint32_t length) -{ - uint8_t i; - uint8_t crc = 0; // Initial value - while(length--) - { - crc ^= *data++; // crc ^= *data; data++; - for ( i = 0; i < 8; i++ ) - { - if ( crc & 0x80 ) - crc = (crc << 1) ^ 0x07; - else - crc <<= 1; - } +uint8_t crc8(uint8_t *data, uint32_t length) { + uint8_t i; + uint8_t crc = 0; // Initial value + while (length--) { + crc ^= *data++; // crc ^= *data; data++; + for (i = 0; i < 8; i++) { + if (crc & 0x80) + crc = (crc << 1) ^ 0x07; + else + crc <<= 1; } - return crc; + } + return crc; } -uint8_t crc6(uint8_t *data, uint32_t length) -{ - uint8_t i; - uint8_t crc = 0; // Initial value - while(length--) - { - crc ^= *data++; // crc ^= *data; data++; - for (i = 0; i < 8; ++i) - { - if (crc & 1) - crc = (crc >> 1) ^ 0x30;// 0x30 = (reverse 0x03)>>(8-6) - else - crc = (crc >> 1); - } +uint8_t crc6(uint8_t *data, uint32_t length) { + uint8_t i; + uint8_t crc = 0; // Initial value + while (length--) { + crc ^= *data++; // crc ^= *data; data++; + for (i = 0; i < 8; ++i) { + if (crc & 1) + crc = (crc >> 1) ^ 0x30; // 0x30 = (reverse 0x03)>>(8-6) + else + crc = (crc >> 1); } - return crc; + } + return crc; } +static int hal_trace_format_id(uint32_t attr, char *buf, uint32_t size, + const char *fmt, va_list ap) { + uint8_t num; + unsigned int value[10]; + LOG_DATA_T trace; -static int hal_trace_format_id(uint32_t attr, char *buf, uint32_t size, const char *fmt, va_list ap) -{ - uint8_t num; - unsigned int value[10]; - LOG_DATA_T trace; + if (size < sizeof(trace) + sizeof(value)) { + return -1; + } - if (size < sizeof(trace) + sizeof(value)) { - return -1; - } + num = GET_BITFIELD(attr, LOG_ATTR_ARG_NUM); + if (num > 10) { + num = 10; + } + for (int i = 0; i < num; i++) { + value[i] = va_arg(ap, unsigned long); + } - num = GET_BITFIELD(attr, LOG_ATTR_ARG_NUM); - if (num > 10) { - num = 10; - } - for (int i = 0; i < num; i++) { - value[i] = va_arg(ap, unsigned long); - } + // memset(buf, 0, size); - //memset(buf, 0, size); - - trace.trace_info.count = num; - trace.trace_info.addr = (uint32_t)fmt-(uint32_t)0xFFFC0000;//(uint32_t)fmt-(uint32_t)__trc_str_start__; - trace.trace_info.tskid = osGetThreadIntId(); - trace.trace_info.crc = 0x2A; + trace.trace_info.count = num; + trace.trace_info.addr = + (uint32_t)fmt - + (uint32_t)0xFFFC0000; //(uint32_t)fmt-(uint32_t)__trc_str_start__; + trace.trace_info.tskid = osGetThreadIntId(); + trace.trace_info.crc = 0x2A; #ifndef LITE_VERSION - trace.trace_head.timestamp = TICKS_TO_MS(hal_sys_timer_get()); + trace.trace_head.timestamp = TICKS_TO_MS(hal_sys_timer_get()); #ifdef USE_CRC_CHECK - trace.trace_head.crc = crc8(((uint8_t *)&trace)+1,7); + trace.trace_head.crc = crc8(((uint8_t *)&trace) + 1, 7); #else - trace.trace_head.crc = 0xBE; + trace.trace_head.crc = 0xBE; #endif #else - trace.trace_info.crc = crc6(((uint8_t *)&trace)+1,3); + trace.trace_info.crc = crc6(((uint8_t *)&trace) + 1, 3); #endif - memcpy(buf, &trace, sizeof(trace)); - if (num != 0) { - memcpy(buf + sizeof(trace), value, 4*num); - } + memcpy(buf, &trace, sizeof(trace)); + if (num != 0) { + memcpy(buf + sizeof(trace), value, 4 * num); + } - return sizeof(trace) + 4*num; + return sizeof(trace) + 4 * num; } #endif -static int hal_trace_print_time(enum LOG_LEVEL_T level, enum LOG_MODULE_T module, char *buf, unsigned int size) -{ +static int hal_trace_print_time(enum LOG_LEVEL_T level, + enum LOG_MODULE_T module, char *buf, + unsigned int size) { #ifdef TRACE_TIME_STAMP - static const char level_ch[] = { 'C', 'E', 'W', 'N', 'I', 'D', 'V', '-', }; - char ctx[10]; - int len; - int i; - const char *mod_name; + static const char level_ch[] = { + 'C', 'E', 'W', 'N', 'I', 'D', 'V', '-', + }; + char ctx[10]; + int len; + int i; + const char *mod_name; #ifdef CRASH_DUMP_ENABLE - if (crash_handling) { - return 0; - } + if (crash_handling) { + return 0; + } #endif - if (0) { + if (0) { #ifdef CP_TRACE_ENABLE - } else if (get_cpu_id()) { - ctx[0] = ' '; - ctx[1] = 'C'; - ctx[2] = 'P'; - ctx[3] = '\0'; + } else if (get_cpu_id()) { + ctx[0] = ' '; + ctx[1] = 'C'; + ctx[2] = 'P'; + ctx[3] = '\0'; #endif - } else if (in_isr()) { - len = snprintf(ctx, sizeof(ctx), "%2d", (int8_t)NVIC_GetCurrentActiveIRQ()); - if (len + 1 < ARRAY_SIZE(ctx)) { - ctx[len] = 'E'; - ctx[len + 1] = '\0'; - } else { - ctx[ARRAY_SIZE(ctx) - 2] = '.'; - ctx[ARRAY_SIZE(ctx) - 1] = '\0'; - } + } else if (in_isr()) { + len = snprintf(ctx, sizeof(ctx), "%2d", (int8_t)NVIC_GetCurrentActiveIRQ()); + if (len + 1 < ARRAY_SIZE(ctx)) { + ctx[len] = 'E'; + ctx[len + 1] = '\0'; } else { + ctx[ARRAY_SIZE(ctx) - 2] = '.'; + ctx[ARRAY_SIZE(ctx) - 1] = '\0'; + } + } else { #ifdef RTOS #ifdef KERNEL_RTX5 - /* const char *thread_name = osGetThreadName(); */ - /* snprintf(ctx, sizeof(ctx), "%.9s", thread_name ? (char *)thread_name : "NULL"); */ - ctx[0] = ' '; - ctx[1] = ' '; - ctx[2] = 't'; - ctx[3] = '\0'; + /* const char *thread_name = osGetThreadName(); */ + /* snprintf(ctx, sizeof(ctx), "%.9s", thread_name ? (char *)thread_name : + * "NULL"); */ + ctx[0] = ' '; + ctx[1] = ' '; + ctx[2] = 't'; + ctx[3] = '\0'; #else - snprintf(ctx, sizeof(ctx), "%3d", osGetThreadIntId()); + snprintf(ctx, sizeof(ctx), "%3d", osGetThreadIntId()); #endif #else - ctx[0] = ' '; - ctx[1] = ' '; - ctx[2] = '0'; - ctx[3] = '\0'; + ctx[0] = ' '; + ctx[1] = ' '; + ctx[2] = '0'; + ctx[3] = '\0'; #endif + } + ctx[ARRAY_SIZE(ctx) - 1] = '\0'; + len = 0; + len += snprintf(&buf[len], size - len, "%9u/", + (unsigned)TICKS_TO_MS(hal_sys_timer_get())); + if (size > len + 2) { + buf[len++] = level_ch[level]; + buf[len++] = '/'; + } + if (size > len + 7) { + mod_name = hal_trace_get_log_module_desc(module); + for (i = 0; i < 6; i++) { + if (mod_name[i] == '\0') { + break; + } + buf[len++] = mod_name[i]; } - ctx[ARRAY_SIZE(ctx) - 1] = '\0'; - len = 0; - len += snprintf(&buf[len], size - len, "%9u/", (unsigned)TICKS_TO_MS(hal_sys_timer_get())); - if (size > len + 2) { - buf[len++] = level_ch[level]; - buf[len++] = '/'; + for (; i < 6; i++) { + buf[len++] = ' '; } - if (size > len + 7) { - mod_name = hal_trace_get_log_module_desc(module); - for (i = 0; i < 6; i++) { - if (mod_name[i] == '\0') { - break; - } - buf[len++] = mod_name[i]; - } - for (; i < 6; i++) { - buf[len++] = ' '; - } - buf[len++] = '/'; - } - len += snprintf(&buf[len], size - len, "%s | ", ctx); - return len; -#else // !TRACE_TIME_STAMP - return 0; + buf[len++] = '/'; + } + len += snprintf(&buf[len], size - len, "%s | ", ctx); + return len; +#else // !TRACE_TIME_STAMP + return 0; #endif // !TRACE_TIME_STAMP } -static inline int hal_trace_format_va(uint32_t attr, char *buf, unsigned int size, const char *fmt, va_list ap) -{ - int len; +static inline int hal_trace_format_va(uint32_t attr, char *buf, + unsigned int size, const char *fmt, + va_list ap) { + int len; - len = vsnprintf(&buf[0], size, fmt, ap); - if ((attr & LOG_ATTR_NO_LF) == 0) { + len = vsnprintf(&buf[0], size, fmt, ap); + if ((attr & LOG_ATTR_NO_LF) == 0) { #ifdef TRACE_CRLF - if (len + 2 < size) { - buf[len++] = '\r'; - } -#endif - if (len + 1 < size) { - buf[len++] = '\n'; - } + if (len + 2 < size) { + buf[len++] = '\r'; } - //if (len < size) buf[len] = 0; +#endif + if (len + 1 < size) { + buf[len++] = '\n'; + } + } + // if (len < size) buf[len] = 0; - return len; + return len; } -static int hal_trace_printf_internal(uint32_t attr, const char *fmt, va_list ap) -{ +static int hal_trace_printf_internal(uint32_t attr, const char *fmt, + va_list ap) { #ifdef USE_TRACE_ID - char buf[60]; + char buf[60]; #else - char buf[120]; + char buf[120]; #endif - int len = 0; - enum LOG_LEVEL_T level; - enum LOG_MODULE_T module; + int len = 0; + enum LOG_LEVEL_T level; + enum LOG_MODULE_T module; - level = GET_BITFIELD(attr, LOG_ATTR_LEVEL); - module = GET_BITFIELD(attr, LOG_ATTR_MOD); + level = GET_BITFIELD(attr, LOG_ATTR_LEVEL); + module = GET_BITFIELD(attr, LOG_ATTR_MOD); #ifdef CRASH_DUMP_ENABLE - if (!crash_handling) + if (!crash_handling) #endif - { - if (level > trace_max_level) { - return 0; - } - if (level > LOG_LEVEL_CRITICAL && (trace_mod_map[module >> 5] & (1 << (module & 0x1F))) == 0) { - return 0; - } + { + if (level > trace_max_level) { + return 0; } + if (level > LOG_LEVEL_CRITICAL && + (trace_mod_map[module >> 5] & (1 << (module & 0x1F))) == 0) { + return 0; + } + } #ifdef USE_TRACE_ID - if ((attr & LOG_ATTR_NO_ID) || (len = hal_trace_format_id(attr, buf, sizeof(buf), fmt, ap)) < 0) + if ((attr & LOG_ATTR_NO_ID) || + (len = hal_trace_format_id(attr, buf, sizeof(buf), fmt, ap)) < 0) #endif - { - len = 0; - if ((attr & LOG_ATTR_NO_TS) == 0) { - len += hal_trace_print_time(level, module, &buf[len], sizeof(buf) - len); - } - len += hal_trace_format_va(attr, &buf[len], sizeof(buf) - len, fmt, ap); + { + len = 0; + if ((attr & LOG_ATTR_NO_TS) == 0) { + len += hal_trace_print_time(level, module, &buf[len], sizeof(buf) - len); } + len += hal_trace_format_va(attr, &buf[len], sizeof(buf) - len, fmt, ap); + } - return hal_trace_output((unsigned char *)buf, len); + return hal_trace_output((unsigned char *)buf, len); } -int hal_trace_printf(uint32_t attr, const char *fmt, ...) -{ - int ret; - va_list ap; +int hal_trace_printf(uint32_t attr, const char *fmt, ...) { + int ret; + va_list ap; - if (attr & LOG_ATTR_IMM) { - hal_trace_flush_buffer(); - } + if (attr & LOG_ATTR_IMM) { + hal_trace_flush_buffer(); + } - va_start(ap, fmt); - ret = hal_trace_printf_internal(attr, fmt, ap); - va_end(ap); + va_start(ap, fmt); + ret = hal_trace_printf_internal(attr, fmt, ap); + va_end(ap); - if (attr & LOG_ATTR_IMM) { - hal_trace_flush_buffer(); - } + if (attr & LOG_ATTR_IMM) { + hal_trace_flush_buffer(); + } - return ret; + return ret; } -int hal_trace_dump(const char *fmt, unsigned int size, unsigned int count, const void *buffer) -{ - char buf[255]={0}; - int len=0, n=0, i=0; +int hal_trace_dump(const char *fmt, unsigned int size, unsigned int count, + const void *buffer) { + char buf[255] = {0}; + int len = 0, n = 0, i = 0; - switch( size ) - { - case sizeof(uint32_t): - while(i 0) { - hal_trace_output((const unsigned char *)newline, sizeof(newline)); - hal_trace_output((unsigned char *)crash_buf, len); - } - len = snprintf(&crash_buf[0], sizeof(crash_buf), NEW_LINE_STR "### ASSERT @ 0x%08X ###" NEW_LINE_STR, (unsigned)info.R[14]); + len = hal_trace_print_time(LOG_LEVEL_CRITICAL, LOG_MODULE_NONE, &crash_buf[0], + sizeof(crash_buf)); + if (len > 0) { + hal_trace_output((const unsigned char *)newline, sizeof(newline)); hal_trace_output((unsigned char *)crash_buf, len); + } + len = snprintf(&crash_buf[0], sizeof(crash_buf), + NEW_LINE_STR "### ASSERT @ 0x%08X ###" NEW_LINE_STR, + (unsigned)info.R[14]); + hal_trace_output((unsigned char *)crash_buf, len); -#if defined(ASSERT_SHOW_FILE_FUNC) || defined(ASSERT_SHOW_FILE) || defined(ASSERT_SHOW_FUNC) - const char separate_line[] = "----------------------------------------" NEW_LINE_STR; +#if defined(ASSERT_SHOW_FILE_FUNC) || defined(ASSERT_SHOW_FILE) || \ + defined(ASSERT_SHOW_FUNC) + const char separate_line[] = + "----------------------------------------" NEW_LINE_STR; #ifdef ASSERT_SHOW_FILE - const char *file = scope; + const char *file = scope; #elif defined(ASSERT_SHOW_FUNC) - const char *func = scope; + const char *func = scope; #endif #if defined(ASSERT_SHOW_FILE_FUNC) || defined(ASSERT_SHOW_FILE) - hal_trace_output((const unsigned char *)desc_file, sizeof(desc_file)); - hal_trace_output((const unsigned char *)file, strlen(file)+1); - hal_trace_output((const unsigned char *)newline, sizeof(newline)); + hal_trace_output((const unsigned char *)desc_file, sizeof(desc_file)); + hal_trace_output((const unsigned char *)file, strlen(file) + 1); + hal_trace_output((const unsigned char *)newline, sizeof(newline)); #endif #if defined(ASSERT_SHOW_FILE_FUNC) || defined(ASSERT_SHOW_FUNC) - hal_trace_output((const unsigned char *)desc_func, sizeof(desc_func)); - hal_trace_output((const unsigned char *)func, strlen(func)+!); - hal_trace_output((const unsigned char *)newline, sizeof(newline)); + hal_trace_output((const unsigned char *)desc_func, sizeof(desc_func)); + hal_trace_output((const unsigned char *)func, strlen(func) + !); + hal_trace_output((const unsigned char *)newline, sizeof(newline)); #endif - hal_trace_output((const unsigned char *)desc_line, sizeof(desc_func)); - len = snprintf(crash_buf, sizeof(crash_buf), "%u", line); - hal_trace_output((const unsigned char *)crash_buf, len); - hal_trace_output((const unsigned char *)newline, sizeof(newline)); + hal_trace_output((const unsigned char *)desc_line, sizeof(desc_func)); + len = snprintf(crash_buf, sizeof(crash_buf), "%u", line); + hal_trace_output((const unsigned char *)crash_buf, len); + hal_trace_output((const unsigned char *)newline, sizeof(newline)); - hal_trace_output((unsigned char *)separate_line, sizeof(separate_line)); + hal_trace_output((unsigned char *)separate_line, sizeof(separate_line)); - hal_trace_flush_buffer(); + hal_trace_flush_buffer(); #endif - va_start(ap, fmt); - len = hal_trace_format_va(0, crash_buf, sizeof(crash_buf), fmt, ap); - va_end(ap); + va_start(ap, fmt); + len = hal_trace_format_va(0, crash_buf, sizeof(crash_buf), fmt, ap); + va_end(ap); - hal_trace_output((unsigned char *)crash_buf, len); + hal_trace_output((unsigned char *)crash_buf, len); - hal_trace_flush_buffer(); + hal_trace_flush_buffer(); - hal_trace_print_common_registers(info.R); - hal_trace_print_special_stack_registers(); + hal_trace_print_common_registers(info.R); + hal_trace_print_special_stack_registers(); - hal_trace_print_stack(info.R[13]); + hal_trace_print_stack(info.R[13]); - hal_trace_print_backtrace(info.R[13], TRACE_BACKTRACE_SEARCH_WORD, TRACE_BACKTRACE_NUM); + hal_trace_print_backtrace(info.R[13], TRACE_BACKTRACE_SEARCH_WORD, + TRACE_BACKTRACE_NUM); - hal_trace_output((const unsigned char *)newline, sizeof(newline)); + hal_trace_output((const unsigned char *)newline, sizeof(newline)); - hal_trace_flush_buffer(); + hal_trace_flush_buffer(); #ifdef CRASH_DUMP_ENABLE - if (full_dump) { - hal_trace_crash_dump_callback(); - hal_trace_flush_buffer(); - hal_sys_timer_delay(MS_TO_TICKS(5)); + if (full_dump) { + hal_trace_crash_dump_callback(); + hal_trace_flush_buffer(); + hal_sys_timer_delay(MS_TO_TICKS(5)); #ifdef CORE_DUMP - AssertCatcher_Entry(); - hal_sys_timer_delay(MS_TO_TICKS(5)); + AssertCatcher_Entry(); + hal_sys_timer_delay(MS_TO_TICKS(5)); #endif #ifdef TRACE_TO_APP - if (app_notify_cb) { - app_notify_cb(HAL_TRACE_STATE_CRASH_END); - } -#endif + if (app_notify_cb) { + app_notify_cb(HAL_TRACE_STATE_CRASH_END); } +#endif + } #ifdef CP_TRACE_ENABLE - if (get_cpu_id()) { - if (cp_notify_cb) { - cp_notify_cb(HAL_TRACE_STATE_CRASH_END); - } - SAFE_PROGRAM_STOP(); + if (get_cpu_id()) { + if (cp_notify_cb) { + cp_notify_cb(HAL_TRACE_STATE_CRASH_END); } + SAFE_PROGRAM_STOP(); + } #endif #endif // CRASH_DUMP_ENABLE #endif // DEBUG || REL_TRACE_ENABLE - hal_trace_crash_end(); + hal_trace_crash_end(); } -void NORETURN NAKED hal_trace_assert_dump(ASSERT_DUMP_ARGS) -{ - asm volatile ( - "subs sp, sp, #4*" TO_STRING(STACK_DUMP_CNT_PREV) ";" - ".cfi_def_cfa_offset 4*" TO_STRING(STACK_DUMP_CNT_PREV) ";" - "push {r0, r1};" - "ldr r0, =crash_buf;" - "ldr r1, [sp];" - "str r1, [r0], 4;" - "ldr r1, [sp, 4];" - "str r1, [r0], 4;" - "stmia r0!, {r2-r12};" - "add r1, sp, #4*(2+" TO_STRING(STACK_DUMP_CNT_PREV) ");" - "str r1, [r0], 4;" - "str lr, [r0], 4;" - "pop {r0, r1};" - "b.w hal_trace_assert_dump_internal;" - ); +void NORETURN NAKED hal_trace_assert_dump(ASSERT_DUMP_ARGS) { + asm volatile("subs sp, sp, #4*" TO_STRING( + STACK_DUMP_CNT_PREV) ";" + ".cfi_def_cfa_offset 4*" TO_STRING( + STACK_DUMP_CNT_PREV) ";" + "push {r0, r1};" + "ldr r0, =crash_buf;" + "ldr r1, [sp];" + "str r1, [r0], 4;" + "ldr r1, [sp, 4];" + "str r1, [r0], 4;" + "stmia r0!, {r2-r12};" + "add r1, sp, " + "#4*(2+" TO_STRING( + STACK_DUMP_CNT_PREV) ")" + ";" + "s" + "t" + "r" + " " + "r" + "1" + "," + " " + "[" + "r" + "0" + "]" + "," + " " + "4" + ";" + "s" + "t" + "r" + " " + "l" + "r" + "," + " " + "[" + "r" + "0" + "]" + "," + " " + "4" + ";" + "p" + "o" + "p" + " " + "{" + "r" + "0" + "," + " " + "r" + "1" + "}" + ";" + "b" + "." + "w" + " " + "h" + "a" + "l" + "_" + "t" + "r" + "a" + "c" + "e" + "_" + "a" + "s" + "s" + "e" + "r" + "t" + "_" + "d" + "u" + "m" + "p" + "_" + "i" + "n" + "t" + "e" + "r" + "n" + "a" + "l" + ";"); } #ifdef FAULT_DUMP -static void hal_trace_fill_exception_info(struct EXCEPTION_INFO_T *info, const uint32_t *regs, const uint32_t *extra, uint32_t extra_len) -{ - info->ID = HAL_TRACE_EXCEPTION_ID; - info->CPU_ID = get_cpu_id_tag(); - info->REGS = regs; +static void hal_trace_fill_exception_info(struct EXCEPTION_INFO_T *info, + const uint32_t *regs, + const uint32_t *extra, + uint32_t extra_len) { + info->ID = HAL_TRACE_EXCEPTION_ID; + info->CPU_ID = get_cpu_id_tag(); + info->REGS = regs; #ifdef __ARM_ARCH_ISA_ARM - info->extra = extra; - info->extra_len = extra_len; + info->extra = extra; + info->extra_len = extra_len; #else - info->MSP = __get_MSP(); - info->PSP = __get_PSP(); - info->PRIMASK = regs[17]; - info->FAULTMASK = __get_FAULTMASK(); - info->BASEPRI = __get_BASEPRI(); - info->CONTROL = __get_CONTROL(); - info->ICSR = SCB->ICSR; - info->AIRCR = SCB->AIRCR; - info->SCR = SCB->SCR; - info->CCR = SCB->CCR; - info->SHCSR = SCB->SHCSR; - info->CFSR = SCB->CFSR; - info->HFSR = SCB->HFSR; - info->AFSR = SCB->AFSR; - info->MMFAR = SCB->MMFAR; - info->BFAR = SCB->BFAR; + info->MSP = __get_MSP(); + info->PSP = __get_PSP(); + info->PRIMASK = regs[17]; + info->FAULTMASK = __get_FAULTMASK(); + info->BASEPRI = __get_BASEPRI(); + info->CONTROL = __get_CONTROL(); + info->ICSR = SCB->ICSR; + info->AIRCR = SCB->AIRCR; + info->SCR = SCB->SCR; + info->CCR = SCB->CCR; + info->SHCSR = SCB->SHCSR; + info->CFSR = SCB->CFSR; + info->HFSR = SCB->HFSR; + info->AFSR = SCB->AFSR; + info->MMFAR = SCB->MMFAR; + info->BFAR = SCB->BFAR; #ifdef __ARM_ARCH_8M_MAIN__ - info->MSPLIM = __get_MSPLIM(); - info->PSPLIM = __get_PSPLIM(); + info->MSPLIM = __get_MSPLIM(); + info->PSPLIM = __get_PSPLIM(); #endif #endif } #if (defined(DEBUG) || defined(REL_TRACE_ENABLE)) #ifdef __ARM_ARCH_ISA_ARM -static void hal_trace_print_fault_info_ca(const struct EXCEPTION_INFO_T *info) -{ - const struct FAULT_REGS_T *fregs; - const uint32_t *extra; - //uint32_t extra_len; - enum EXCEPTION_ID_T id; - int len; - uint32_t val; - const char *desc; +static void hal_trace_print_fault_info_ca(const struct EXCEPTION_INFO_T *info) { + const struct FAULT_REGS_T *fregs; + const uint32_t *extra; + // uint32_t extra_len; + enum EXCEPTION_ID_T id; + int len; + uint32_t val; + const char *desc; - fregs = (const struct FAULT_REGS_T*)info->REGS; - extra = info->extra; - //extra_len = info->extra_len; + fregs = (const struct FAULT_REGS_T *)info->REGS; + extra = info->extra; + // extra_len = info->extra_len; - id = (enum EXCEPTION_ID_T)extra[0]; + id = (enum EXCEPTION_ID_T)extra[0]; - len = snprintf(crash_buf, sizeof(crash_buf), "PC =%08X", (unsigned)fregs->r[15]); - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, ", ExceptionNumber=%d" NEW_LINE_STR, id); - hal_trace_output((unsigned char *)crash_buf, len); + len = snprintf(crash_buf, sizeof(crash_buf), "PC =%08X", + (unsigned)fregs->r[15]); + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + ", ExceptionNumber=%d" NEW_LINE_STR, id); + hal_trace_output((unsigned char *)crash_buf, len); - hal_trace_print_common_registers(fregs->r); + hal_trace_print_common_registers(fregs->r); - len = snprintf(crash_buf, sizeof(crash_buf), "SPSR=%08X", (unsigned)fregs->spsr); - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, ", APSR=%c%c%c%c%c", - (fregs->spsr & (1 << 31)) ? 'N' : 'n', - (fregs->spsr & (1 << 30)) ? 'Z' : 'z', - (fregs->spsr & (1 << 29)) ? 'C' : 'c', - (fregs->spsr & (1 << 28)) ? 'V' : 'v', - (fregs->spsr & (1 << 27)) ? 'Q' : 'q' - ); - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, ", XC=%c%c%c%c%c", - (fregs->spsr & (1 << 9)) ? 'E' : 'e', - (fregs->spsr & (1 << 8)) ? 'A' : 'a', - (fregs->spsr & (1 << 7)) ? 'I' : 'i', - (fregs->spsr & (1 << 6)) ? 'F' : 'f', - (fregs->spsr & (1 << 5)) ? 'T' : 't' - ); - val = fregs->spsr & 0x1F; - if (val == 0x10) { - desc = "USR"; - } else if (val == 0x11) { - desc = "FIQ"; - } else if (val == 0x12) { - desc = "IRQ"; - } else if (val == 0x13) { - desc = "SVC"; - } else if (val == 0x16) { - desc = "MON"; - } else if (val == 0x17) { - desc = "ABT"; - } else if (val == 0x1A) { - desc = "HYP"; - } else if (val == 0x1B) { - desc = "UND"; - } else if (val == 0x1F) { - desc = "SYS"; - } else { - desc = "UNKNOWN"; - } - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, ", MODE=%02X (%s)", (unsigned)val, desc); - hal_trace_output((unsigned char *)crash_buf, len); - hal_trace_output((const unsigned char *)newline, sizeof(newline)); - hal_trace_output((const unsigned char *)newline, sizeof(newline)); + len = snprintf(crash_buf, sizeof(crash_buf), "SPSR=%08X", + (unsigned)fregs->spsr); + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, ", APSR=%c%c%c%c%c", + (fregs->spsr & (1 << 31)) ? 'N' : 'n', + (fregs->spsr & (1 << 30)) ? 'Z' : 'z', + (fregs->spsr & (1 << 29)) ? 'C' : 'c', + (fregs->spsr & (1 << 28)) ? 'V' : 'v', + (fregs->spsr & (1 << 27)) ? 'Q' : 'q'); + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, ", XC=%c%c%c%c%c", + (fregs->spsr & (1 << 9)) ? 'E' : 'e', + (fregs->spsr & (1 << 8)) ? 'A' : 'a', + (fregs->spsr & (1 << 7)) ? 'I' : 'i', + (fregs->spsr & (1 << 6)) ? 'F' : 'f', + (fregs->spsr & (1 << 5)) ? 'T' : 't'); + val = fregs->spsr & 0x1F; + if (val == 0x10) { + desc = "USR"; + } else if (val == 0x11) { + desc = "FIQ"; + } else if (val == 0x12) { + desc = "IRQ"; + } else if (val == 0x13) { + desc = "SVC"; + } else if (val == 0x16) { + desc = "MON"; + } else if (val == 0x17) { + desc = "ABT"; + } else if (val == 0x1A) { + desc = "HYP"; + } else if (val == 0x1B) { + desc = "UND"; + } else if (val == 0x1F) { + desc = "SYS"; + } else { + desc = "UNKNOWN"; + } + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, ", MODE=%02X (%s)", + (unsigned)val, desc); + hal_trace_output((unsigned char *)crash_buf, len); + hal_trace_output((const unsigned char *)newline, sizeof(newline)); + hal_trace_output((const unsigned char *)newline, sizeof(newline)); - hal_trace_flush_buffer(); + hal_trace_flush_buffer(); - if (id == EXCEPTION_UNDEF) { - } else if (id == EXCEPTION_SVC) { - } else if (id == EXCEPTION_PABT) { - } else if (id == EXCEPTION_DABT) { - } else { - } + if (id == EXCEPTION_UNDEF) { + } else if (id == EXCEPTION_SVC) { + } else if (id == EXCEPTION_PABT) { + } else if (id == EXCEPTION_DABT) { + } else { + } } #else -static void hal_trace_print_fault_info_cm(const struct EXCEPTION_INFO_T *info) -{ - const uint32_t *regs; - int len; - uint32_t val; - uint32_t primask; +static void hal_trace_print_fault_info_cm(const struct EXCEPTION_INFO_T *info) { + const uint32_t *regs; + int len; + uint32_t val; + uint32_t primask; - regs = info->REGS; - primask = regs[17]; + regs = info->REGS; + primask = regs[17]; - len = snprintf(crash_buf, sizeof(crash_buf), "PC =%08X", (unsigned)regs[15]); - val = __get_IPSR(); - if (val == 0) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, ", ThreadMode" NEW_LINE_STR); - } else { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, ", ExceptionNumber=%d" NEW_LINE_STR, (int)val - 16); + len = snprintf(crash_buf, sizeof(crash_buf), "PC =%08X", (unsigned)regs[15]); + val = __get_IPSR(); + if (val == 0) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + ", ThreadMode" NEW_LINE_STR); + } else { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + ", ExceptionNumber=%d" NEW_LINE_STR, (int)val - 16); + } + hal_trace_output((unsigned char *)crash_buf, len); + + hal_trace_print_common_registers(regs); + hal_trace_print_special_stack_registers(); + + hal_trace_output((const unsigned char *)newline, sizeof(newline)); + + len = snprintf( + crash_buf, sizeof(crash_buf), + "PRIMASK=%02X, FAULTMASK=%02X, BASEPRI=%02X, CONTROL=%02X" NEW_LINE_STR, + (unsigned)primask, (unsigned)__get_FAULTMASK(), (unsigned)__get_BASEPRI(), + (unsigned)__get_CONTROL()); + hal_trace_output((unsigned char *)crash_buf, len); + len = snprintf(crash_buf, sizeof(crash_buf), "XPSR=%08X", (unsigned)regs[16]); + len += snprintf( + &crash_buf[len], sizeof(crash_buf) - len, ", APSR=%c%c%c%c%c", + (regs[16] & (1 << 31)) ? 'N' : 'n', (regs[16] & (1 << 30)) ? 'Z' : 'z', + (regs[16] & (1 << 29)) ? 'C' : 'c', (regs[16] & (1 << 28)) ? 'V' : 'v', + (regs[16] & (1 << 27)) ? 'Q' : 'q'); + val = regs[16] & 0xFF; + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + ", EPSR=%08X, IPSR=%02X", (unsigned)(regs[16] & 0x0700FC00), + (unsigned)val); + if (val == 0) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (NoException)"); + } + hal_trace_output((unsigned char *)crash_buf, len); + hal_trace_output((const unsigned char *)newline, sizeof(newline)); + hal_trace_output((const unsigned char *)newline, sizeof(newline)); + + hal_trace_flush_buffer(); + + len = snprintf(crash_buf, sizeof(crash_buf), + "ICSR =%08X, AIRCR=%08X, SCR =%08X, CCR =%08X" NEW_LINE_STR, + (unsigned)info->ICSR, (unsigned)info->AIRCR, + (unsigned)info->SCR, (unsigned)info->CCR); + hal_trace_output((unsigned char *)crash_buf, len); + + len = snprintf(crash_buf, sizeof(crash_buf), + "SHCSR=%08X, CFSR =%08X, HFSR =%08X, AFSR =%08X" NEW_LINE_STR, + (unsigned)info->SHCSR, (unsigned)info->CFSR, + (unsigned)info->HFSR, (unsigned)info->AFSR); + hal_trace_output((unsigned char *)crash_buf, len); + + len = snprintf(crash_buf, sizeof(crash_buf), + "MMFAR=%08X, BFAR =%08X" NEW_LINE_STR, (unsigned)info->MMFAR, + (unsigned)info->BFAR); + hal_trace_output((unsigned char *)crash_buf, len); + + if (info->HFSR & (1 << 30)) { + len = snprintf(crash_buf, sizeof(crash_buf), + "(Escalation HardFault)" NEW_LINE_STR); + hal_trace_output((unsigned char *)crash_buf, len); + } + + len = snprintf(crash_buf, sizeof(crash_buf), "FaultInfo :"); + if ((info->SHCSR & 0x3F) == 0) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (None)"); + } else { + if (info->SHCSR & (1 << 0)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (MemFault)"); } - hal_trace_output((unsigned char *)crash_buf, len); - - hal_trace_print_common_registers(regs); - hal_trace_print_special_stack_registers(); - - hal_trace_output((const unsigned char *)newline, sizeof(newline)); - - len = snprintf(crash_buf, sizeof(crash_buf), "PRIMASK=%02X, FAULTMASK=%02X, BASEPRI=%02X, CONTROL=%02X" NEW_LINE_STR, - (unsigned)primask, (unsigned)__get_FAULTMASK(), (unsigned)__get_BASEPRI(), (unsigned)__get_CONTROL()); - hal_trace_output((unsigned char *)crash_buf, len); - len = snprintf(crash_buf, sizeof(crash_buf), "XPSR=%08X", (unsigned)regs[16]); - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, ", APSR=%c%c%c%c%c", - (regs[16] & (1 << 31)) ? 'N' : 'n', - (regs[16] & (1 << 30)) ? 'Z' : 'z', - (regs[16] & (1 << 29)) ? 'C' : 'c', - (regs[16] & (1 << 28)) ? 'V' : 'v', - (regs[16] & (1 << 27)) ? 'Q' : 'q' - ); - val = regs[16] & 0xFF; - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, ", EPSR=%08X, IPSR=%02X", (unsigned)(regs[16] & 0x0700FC00), (unsigned)val); - if (val == 0) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (NoException)"); + if (info->SHCSR & (1 << 1)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (BusFault)"); } - hal_trace_output((unsigned char *)crash_buf, len); - hal_trace_output((const unsigned char *)newline, sizeof(newline)); - hal_trace_output((const unsigned char *)newline, sizeof(newline)); - - hal_trace_flush_buffer(); - - len = snprintf(crash_buf, sizeof(crash_buf), "ICSR =%08X, AIRCR=%08X, SCR =%08X, CCR =%08X" NEW_LINE_STR, - (unsigned)info->ICSR, (unsigned)info->AIRCR, (unsigned)info->SCR, (unsigned)info->CCR); - hal_trace_output((unsigned char *)crash_buf, len); - - len = snprintf(crash_buf, sizeof(crash_buf), "SHCSR=%08X, CFSR =%08X, HFSR =%08X, AFSR =%08X" NEW_LINE_STR, - (unsigned)info->SHCSR, (unsigned)info->CFSR, (unsigned)info->HFSR, (unsigned)info->AFSR); - hal_trace_output((unsigned char *)crash_buf, len); - - len = snprintf(crash_buf, sizeof(crash_buf), "MMFAR=%08X, BFAR =%08X" NEW_LINE_STR, (unsigned)info->MMFAR, (unsigned)info->BFAR); - hal_trace_output((unsigned char *)crash_buf, len); - - if (info->HFSR & (1 << 30)) { - len = snprintf(crash_buf, sizeof(crash_buf), "(Escalation HardFault)" NEW_LINE_STR); - hal_trace_output((unsigned char *)crash_buf, len); - } - - len = snprintf(crash_buf, sizeof(crash_buf), "FaultInfo :"); - if ((info->SHCSR & 0x3F) == 0) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (None)"); - } else { - if (info->SHCSR & (1 << 0)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (MemFault)"); - } - if (info->SHCSR & (1 << 1)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (BusFault)"); - } #ifdef __ARM_ARCH_8M_MAIN__ - if (info->SHCSR & (1 << 2)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (HardFault)"); - } -#endif - if (info->SHCSR & (1 << 3)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (UsageFault)"); - } -#ifdef __ARM_ARCH_8M_MAIN__ - if (info->SHCSR & (1 << 4)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (SecureFault)"); - } - if (info->SHCSR & (1 << 5)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (NMI)"); - } -#endif + if (info->SHCSR & (1 << 2)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (HardFault)"); } - hal_trace_output((unsigned char *)crash_buf, len); - hal_trace_output((const unsigned char *)newline, sizeof(newline)); +#endif + if (info->SHCSR & (1 << 3)) { + len += + snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (UsageFault)"); + } +#ifdef __ARM_ARCH_8M_MAIN__ + if (info->SHCSR & (1 << 4)) { + len += + snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (SecureFault)"); + } + if (info->SHCSR & (1 << 5)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (NMI)"); + } +#endif + } + hal_trace_output((unsigned char *)crash_buf, len); + hal_trace_output((const unsigned char *)newline, sizeof(newline)); - len = snprintf(crash_buf, sizeof(crash_buf), "FaultCause:"); - if (info->CFSR == 0) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (None)"); - } else { - if (info->CFSR & (1 << 0)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (Instruction access violation)"); - } - if (info->CFSR & (1 << 1)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (Data access violation)"); - } - if (info->CFSR & (1 << 3)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (MemFault on unstacking for a return from exception)"); - } - if (info->CFSR & (1 << 4)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (MemFault on stacking for exception entry)"); - } - if (info->CFSR & (1 << 5)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (MemFault during floating-point lazy state preservation)"); - } - if (info->CFSR & (1 << 7)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (MMFAR valid)"); - } - if (len) { - hal_trace_output((unsigned char *)crash_buf, len); - hal_trace_flush_buffer(); - len = 0; - } - if (info->CFSR & (1 << 8)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (Instruction bus error)"); - } - if (info->CFSR & (1 << 9)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (Precise data bus error)"); - } + len = snprintf(crash_buf, sizeof(crash_buf), "FaultCause:"); + if (info->CFSR == 0) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (None)"); + } else { + if (info->CFSR & (1 << 0)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + " (Instruction access violation)"); + } + if (info->CFSR & (1 << 1)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + " (Data access violation)"); + } + if (info->CFSR & (1 << 3)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + " (MemFault on unstacking for a return from exception)"); + } + if (info->CFSR & (1 << 4)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + " (MemFault on stacking for exception entry)"); + } + if (info->CFSR & (1 << 5)) { + len += + snprintf(&crash_buf[len], sizeof(crash_buf) - len, + " (MemFault during floating-point lazy state preservation)"); + } + if (info->CFSR & (1 << 7)) { + len += + snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (MMFAR valid)"); + } + if (len) { + hal_trace_output((unsigned char *)crash_buf, len); + hal_trace_flush_buffer(); + len = 0; + } + if (info->CFSR & (1 << 8)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + " (Instruction bus error)"); + } + if (info->CFSR & (1 << 9)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + " (Precise data bus error)"); + } #ifndef __ARM_ARCH_8M_MAIN__ - if (info->CFSR & (1 << 10)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (Imprecise data bus error)"); - } -#endif - if (info->CFSR & (1 << 11)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (BusFault on unstacking for a return from exception)"); - } - if (info->CFSR & (1 << 12)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (BusFault on stacking for exception entry)"); - } - if (info->CFSR & (1 << 13)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (BusFault during floating-point lazy state preservation)"); - } - if (info->CFSR & (1 << 15)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (BFAR valid)"); - } - if (len) { - hal_trace_output((unsigned char *)crash_buf, len); - hal_trace_flush_buffer(); - len = 0; - } - if (info->CFSR & (1 << 16)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (Undefined instruction UsageFault)"); - } - if (info->CFSR & (1 << 17)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (Invalid state UsageFault)"); - } - if (info->CFSR & (1 << 18)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (Invalid PC load by EXC_RETURN UsageFault)"); - } - if (info->CFSR & (1 << 19)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (No coprocessor UsageFault)"); - } -#ifdef __ARM_ARCH_8M_MAIN__ - if (info->CFSR & (1 << 20)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (Stack overflow UsageFault)"); - } -#endif - if (info->CFSR & (1 << 24)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (Unaligned access UsageFault)"); - } - if (info->CFSR & (1 << 25)) { - len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (Divide by zero UsageFault)"); - } + if (info->CFSR & (1 << 10)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + " (Imprecise data bus error)"); } - hal_trace_output((unsigned char *)crash_buf, len); - hal_trace_output((const unsigned char *)newline, sizeof(newline)); +#endif + if (info->CFSR & (1 << 11)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + " (BusFault on unstacking for a return from exception)"); + } + if (info->CFSR & (1 << 12)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + " (BusFault on stacking for exception entry)"); + } + if (info->CFSR & (1 << 13)) { + len += + snprintf(&crash_buf[len], sizeof(crash_buf) - len, + " (BusFault during floating-point lazy state preservation)"); + } + if (info->CFSR & (1 << 15)) { + len += + snprintf(&crash_buf[len], sizeof(crash_buf) - len, " (BFAR valid)"); + } + if (len) { + hal_trace_output((unsigned char *)crash_buf, len); + hal_trace_flush_buffer(); + len = 0; + } + if (info->CFSR & (1 << 16)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + " (Undefined instruction UsageFault)"); + } + if (info->CFSR & (1 << 17)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + " (Invalid state UsageFault)"); + } + if (info->CFSR & (1 << 18)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + " (Invalid PC load by EXC_RETURN UsageFault)"); + } + if (info->CFSR & (1 << 19)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + " (No coprocessor UsageFault)"); + } +#ifdef __ARM_ARCH_8M_MAIN__ + if (info->CFSR & (1 << 20)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + " (Stack overflow UsageFault)"); + } +#endif + if (info->CFSR & (1 << 24)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + " (Unaligned access UsageFault)"); + } + if (info->CFSR & (1 << 25)) { + len += snprintf(&crash_buf[len], sizeof(crash_buf) - len, + " (Divide by zero UsageFault)"); + } + } + hal_trace_output((unsigned char *)crash_buf, len); + hal_trace_output((const unsigned char *)newline, sizeof(newline)); } #endif -static void hal_trace_print_fault_info(const struct EXCEPTION_INFO_T *info) -{ +static void hal_trace_print_fault_info(const struct EXCEPTION_INFO_T *info) { #ifdef __ARM_ARCH_ISA_ARM - hal_trace_print_fault_info_ca(info); + hal_trace_print_fault_info_ca(info); #else - hal_trace_print_fault_info_cm(info); + hal_trace_print_fault_info_cm(info); #endif } #endif // DEBUG || REL_TRACE_ENABLE -void hal_trace_fault_dump(const uint32_t *regs, const uint32_t *extra, uint32_t extra_len) -{ - struct EXCEPTION_INFO_T info; +void hal_trace_fault_dump(const uint32_t *regs, const uint32_t *extra, + uint32_t extra_len) { + struct EXCEPTION_INFO_T info; - int_lock_global(); + int_lock_global(); - hal_trace_fill_exception_info(&info, regs, extra, extra_len); + hal_trace_fill_exception_info(&info, regs, extra, extra_len); - *(volatile uint32_t *)RAM_BASE = (uint32_t)&info; + *(volatile uint32_t *)RAM_BASE = (uint32_t)&info; #if (defined(DEBUG) || defined(REL_TRACE_ENABLE)) - static const char title[] = NEW_LINE_STR "### EXCEPTION ###" NEW_LINE_STR; - int len; + static const char title[] = NEW_LINE_STR "### EXCEPTION ###" NEW_LINE_STR; + int len; #ifdef CRASH_DUMP_ENABLE - bool full_dump = true; + bool full_dump = true; #ifdef CP_TRACE_ENABLE - if (get_cpu_id()) { - full_dump = false; - if (cp_notify_cb) { - cp_notify_cb(HAL_TRACE_STATE_CRASH_FAULT_START); - } + if (get_cpu_id()) { + full_dump = false; + if (cp_notify_cb) { + cp_notify_cb(HAL_TRACE_STATE_CRASH_FAULT_START); } + } #endif - if (full_dump) { + if (full_dump) { #ifdef TRACE_TO_APP - if (app_notify_cb) { - app_notify_cb(HAL_TRACE_STATE_CRASH_FAULT_START); - } - if (app_crash_custom_cb == NULL) { - app_output_enabled = true; - } -#endif - - crash_dump_onprocess = true; - for (uint8_t i = 0; i < 10; i++) { - REL_TRACE_IMM(0," "); - REL_TRACE_IMM(0," " NEW_LINE_STR); - hal_sys_timer_delay(MS_TO_TICKS(50)); - } + if (app_notify_cb) { + app_notify_cb(HAL_TRACE_STATE_CRASH_FAULT_START); + } + if (app_crash_custom_cb == NULL) { + app_output_enabled = true; } #endif - hal_trace_flush_buffer(); - - hal_sysfreq_req(HAL_SYSFREQ_USER_INIT, HAL_CMU_FREQ_52M); - - len = hal_trace_print_time(LOG_LEVEL_CRITICAL, LOG_MODULE_NONE, &crash_buf[0], sizeof(crash_buf)); - if (len > 0) { - hal_trace_output((const unsigned char *)newline, sizeof(newline)); - hal_trace_output((unsigned char *)crash_buf, len); + crash_dump_onprocess = true; + for (uint8_t i = 0; i < 10; i++) { + REL_TRACE_IMM(0, " " + " "); + REL_TRACE_IMM(0, " " + " " NEW_LINE_STR); + hal_sys_timer_delay(MS_TO_TICKS(50)); } - hal_trace_output((unsigned char *)title, sizeof(title)); + } +#endif - hal_trace_print_fault_info(&info); + hal_trace_flush_buffer(); - hal_trace_flush_buffer(); - - hal_trace_print_stack(regs[13]); - - hal_trace_print_backtrace(regs[13], TRACE_BACKTRACE_SEARCH_WORD, TRACE_BACKTRACE_NUM); + hal_sysfreq_req(HAL_SYSFREQ_USER_INIT, HAL_CMU_FREQ_52M); + len = hal_trace_print_time(LOG_LEVEL_CRITICAL, LOG_MODULE_NONE, &crash_buf[0], + sizeof(crash_buf)); + if (len > 0) { hal_trace_output((const unsigned char *)newline, sizeof(newline)); + hal_trace_output((unsigned char *)crash_buf, len); + } + hal_trace_output((unsigned char *)title, sizeof(title)); - hal_trace_flush_buffer(); + hal_trace_print_fault_info(&info); + + hal_trace_flush_buffer(); + + hal_trace_print_stack(regs[13]); + + hal_trace_print_backtrace(regs[13], TRACE_BACKTRACE_SEARCH_WORD, + TRACE_BACKTRACE_NUM); + + hal_trace_output((const unsigned char *)newline, sizeof(newline)); + + hal_trace_flush_buffer(); #ifdef CRASH_DUMP_ENABLE - if (full_dump) { - hal_trace_crash_dump_callback(); - hal_trace_flush_buffer(); + if (full_dump) { + hal_trace_crash_dump_callback(); + hal_trace_flush_buffer(); #ifndef __ARM_ARCH_ISA_ARM #ifdef TRACE_TO_APP - // Crash-Dump "Lite-Version" - if (app_crash_custom_cb) { - app_crash_custom_cb((unsigned char *)regs, - CRASH_DUMP_REGISTERS_NUM_BYTES); - stack = (uint32_t *)(__get_MSP() & ~3); - app_crash_custom_cb((unsigned char *)stack, - ((CRASH_DUMP_STACK_NUM_BYTES)/2)); - stack = (uint32_t *)(__get_PSP() & ~3); - app_crash_custom_cb((unsigned char *)stack, - ((CRASH_DUMP_STACK_NUM_BYTES)/2)); - } + // Crash-Dump "Lite-Version" + if (app_crash_custom_cb) { + app_crash_custom_cb((unsigned char *)regs, + CRASH_DUMP_REGISTERS_NUM_BYTES); + stack = (uint32_t *)(__get_MSP() & ~3); + app_crash_custom_cb((unsigned char *)stack, + ((CRASH_DUMP_STACK_NUM_BYTES) / 2)); + stack = (uint32_t *)(__get_PSP() & ~3); + app_crash_custom_cb((unsigned char *)stack, + ((CRASH_DUMP_STACK_NUM_BYTES) / 2)); + } #endif #ifdef CORE_DUMP - { - static CrashCatcherExceptionRegisters eregs; + { + static CrashCatcherExceptionRegisters eregs; - eregs.msp = info.MSP; - eregs.psp = info.PSP; - eregs.exceptionPSR = regs[16] & 0x0700FE00; - eregs.r4 = regs[4]; - eregs.r5 = regs[5]; - eregs.r6 = regs[6]; - eregs.r7 = regs[7]; - eregs.r8 = regs[8]; - eregs.r9 = regs[9]; - eregs.r10 = regs[10]; - eregs.r11 = regs[11]; - eregs.exceptionLR = regs[14]; - CrashCatcher_Entry( &eregs); - } + eregs.msp = info.MSP; + eregs.psp = info.PSP; + eregs.exceptionPSR = regs[16] & 0x0700FE00; + eregs.r4 = regs[4]; + eregs.r5 = regs[5]; + eregs.r6 = regs[6]; + eregs.r7 = regs[7]; + eregs.r8 = regs[8]; + eregs.r9 = regs[9]; + eregs.r10 = regs[10]; + eregs.r11 = regs[11]; + eregs.exceptionLR = regs[14]; + CrashCatcher_Entry(&eregs); + } #endif #endif // !__ARM_ARCH_ISA_ARM #ifdef TRACE_TO_APP - if (app_notify_cb) { - app_notify_cb(HAL_TRACE_STATE_CRASH_END); - } -#endif + if (app_notify_cb) { + app_notify_cb(HAL_TRACE_STATE_CRASH_END); } +#endif + } #ifdef CP_TRACE_ENABLE - if (get_cpu_id()) { - if (cp_notify_cb) { - cp_notify_cb(HAL_TRACE_STATE_CRASH_END); - } - SAFE_PROGRAM_STOP(); + if (get_cpu_id()) { + if (cp_notify_cb) { + cp_notify_cb(HAL_TRACE_STATE_CRASH_END); } + SAFE_PROGRAM_STOP(); + } #endif #endif // CRASH_DUMP_ENABLE #endif // DEBUG || REL_TRACE_ENABLE - hal_trace_crash_end(); + hal_trace_crash_end(); } #ifndef __ARM_ARCH_ISA_ARM -static void NAKED hal_trace_fault_handler(void) -{ - // TODO: Save FP registers (and check lazy Floating-point context preservation) - asm volatile ( - // Check EXC_RETURN.SPSEL (bit[2]) - "tst lr, #0x04;" - "ite eq;" - // Using MSP - "mrseq r3, msp;" - // Using PSP - "mrsne r3, psp;" - // Check EXC_RETURN.FType (bit[4]) - "tst lr, #0x10;" - "ite eq;" - // FPU context saved - "moveq r1, #1;" - // No FPU context - "movne r1, #0;" -#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) - "mov, r0, #0;" - // -- Check EXC_RETURN.S (bit[6]) - "tst lr, #0x40;" - "beq _done_sec_cntx;" - // -- Check EXC_RETURN.ES (bit[0]) - "tst lr, #0x01;" - "bne _done_sec_cntx;" - // -- Check EXC_RETURN.DCRS (bit[5]) - "tst lr, #0x20;" - "bne _done_sec_cntx;" - "mov, r0, #1;" - "push {r4-r11};" - "add r3, #2*4;" - "ldm r3!, {r4-r11};" - "_done_sec_cntx:;" - "push {r0};" +static void NAKED hal_trace_fault_handler(void) { + // TODO: Save FP registers (and check lazy Floating-point context + // preservation) + asm volatile( + // Check EXC_RETURN.SPSEL (bit[2]) + "tst lr, #0x04;" + "ite eq;" + // Using MSP + "mrseq r3, msp;" + // Using PSP + "mrsne r3, psp;" + // Check EXC_RETURN.FType (bit[4]) + "tst lr, #0x10;" + "ite eq;" + // FPU context saved + "moveq r1, #1;" + // No FPU context + "movne r1, #0;" +#if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + "mov, r0, #0;" + // -- Check EXC_RETURN.S (bit[6]) + "tst lr, #0x40;" + "beq _done_sec_cntx;" + // -- Check EXC_RETURN.ES (bit[0]) + "tst lr, #0x01;" + "bne _done_sec_cntx;" + // -- Check EXC_RETURN.DCRS (bit[5]) + "tst lr, #0x20;" + "bne _done_sec_cntx;" + "mov, r0, #1;" + "push {r4-r11};" + "add r3, #2*4;" + "ldm r3!, {r4-r11};" + "_done_sec_cntx:;" + "push {r0};" #endif - // Make room for r0-r15,psr,primask - "sub sp, #18*4;" - ".cfi_def_cfa_offset 18*4;" - // Save r4-r11 - "add r0, sp, #4*4;" - "stm r0, {r4-r11};" - ".cfi_offset r4, -14*4;" - ".cfi_offset r5, -13*4;" - ".cfi_offset r6, -12*4;" - ".cfi_offset r7, -11*4;" - ".cfi_offset r8, -10*4;" - ".cfi_offset r9, -9*4;" - ".cfi_offset r10, -8*4;" - ".cfi_offset r11, -7*4;" - // Save r0-r3 - "ldm r3, {r4-r7};" - "stm sp, {r4-r7};" - ".cfi_offset r0, -18*4;" - ".cfi_offset r1, -17*4;" - ".cfi_offset r2, -16*4;" - ".cfi_offset r3, -15*4;" - // Save r12 - "ldr r0, [r3, #4*4];" - "str r0, [sp, #12*4];" - ".cfi_offset r12, -6*4;" - // Save sp - "teq r1, 0;" - "itt eq;" - "addeq r0, r3, #8*4;" - "beq _done_stack_frame;" - "add r0, r3, #(8+18)*4;" -#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) - // -- Check EXC_RETURN.S (bit[6]) - "tst lr, #0x40;" - "beq _done_stack_frame;" - // -- Check FPCCR_S.TS (bit[26]) - "ldr r4, =0xE000EF34;" - "ldr r4, [r4];" - "tst r4, #(1 << 26);" - "it ne;" - "addne r3, #16*4;" + // Make room for r0-r15,psr,primask + "sub sp, #18*4;" + ".cfi_def_cfa_offset 18*4;" + // Save r4-r11 + "add r0, sp, #4*4;" + "stm r0, {r4-r11};" + ".cfi_offset r4, -14*4;" + ".cfi_offset r5, -13*4;" + ".cfi_offset r6, -12*4;" + ".cfi_offset r7, -11*4;" + ".cfi_offset r8, -10*4;" + ".cfi_offset r9, -9*4;" + ".cfi_offset r10, -8*4;" + ".cfi_offset r11, -7*4;" + // Save r0-r3 + "ldm r3, {r4-r7};" + "stm sp, {r4-r7};" + ".cfi_offset r0, -18*4;" + ".cfi_offset r1, -17*4;" + ".cfi_offset r2, -16*4;" + ".cfi_offset r3, -15*4;" + // Save r12 + "ldr r0, [r3, #4*4];" + "str r0, [sp, #12*4];" + ".cfi_offset r12, -6*4;" + // Save sp + "teq r1, 0;" + "itt eq;" + "addeq r0, r3, #8*4;" + "beq _done_stack_frame;" + "add r0, r3, #(8+18)*4;" +#if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + // -- Check EXC_RETURN.S (bit[6]) + "tst lr, #0x40;" + "beq _done_stack_frame;" + // -- Check FPCCR_S.TS (bit[26]) + "ldr r4, =0xE000EF34;" + "ldr r4, [r4];" + "tst r4, #(1 << 26);" + "it ne;" + "addne r3, #16*4;" #endif - "_done_stack_frame:;" - // -- Check RETPSR.SPREALIGN (bit[9]) - "ldr r4, [r3, #7*4];" - "tst r4, #(1 << 9);" - "it ne;" - "addne r0, #4;" - "str r0, [sp, #13*4];" - // Save lr - "ldr r0, [r3, #5*4];" - "str r0, [sp, #14*4];" - // Save pc - "ldr r0, [r3, #6*4];" - "str r0, [sp, #15*4];" - // Save PSR - "ldr r0, [r3, #7*4];" - "str r0, [sp, #16*4];" - // Save primask - "mrs r0, primask;" - "str r0, [sp, #17*4];" - // Save current exception lr - "mov r4, lr;" - ".cfi_register lr, r4;" - // Invoke the fault handler - "mov r0, sp;" - "ldr r2, =hal_trace_fault_dump;" - "blx r2;" - // Restore current exception lr - "mov lr, r4;" - // Restore r4-r7 - "add r0, sp, #4*4;" - "ldm r0, {r4-r7};" - "mov r0, r3;" - // Restore sp - "add sp, #18*4;" -#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) - "pop {r0};" - "cmp r0, #1;" - "it eq;" - "popeq {r4-r11};" + "_done_stack_frame:;" + // -- Check RETPSR.SPREALIGN (bit[9]) + "ldr r4, [r3, #7*4];" + "tst r4, #(1 << 9);" + "it ne;" + "addne r0, #4;" + "str r0, [sp, #13*4];" + // Save lr + "ldr r0, [r3, #5*4];" + "str r0, [sp, #14*4];" + // Save pc + "ldr r0, [r3, #6*4];" + "str r0, [sp, #15*4];" + // Save PSR + "ldr r0, [r3, #7*4];" + "str r0, [sp, #16*4];" + // Save primask + "mrs r0, primask;" + "str r0, [sp, #17*4];" + // Save current exception lr + "mov r4, lr;" + ".cfi_register lr, r4;" + // Invoke the fault handler + "mov r0, sp;" + "ldr r2, =hal_trace_fault_dump;" + "blx r2;" + // Restore current exception lr + "mov lr, r4;" + // Restore r4-r7 + "add r0, sp, #4*4;" + "ldm r0, {r4-r7};" + "mov r0, r3;" + // Restore sp + "add sp, #18*4;" +#if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + "pop {r0};" + "cmp r0, #1;" + "it eq;" + "popeq {r4-r11};" #endif - "bx lr;" - "" - ); + "bx lr;" + ""); } #endif #endif -#define HAL_TRACE_RX_HEAD_SIZE 4 -#define HAL_TRACE_RX_NAME_SIZE 20 -#define HAL_TRACE_RX_BUF_SIZE 1024 -#define HAL_TRACE_RX_ROLE_NUM 6 +#define HAL_TRACE_RX_HEAD_SIZE 4 +#define HAL_TRACE_RX_NAME_SIZE 20 +#define HAL_TRACE_RX_BUF_SIZE 1024 +#define HAL_TRACE_RX_ROLE_NUM 6 -#define HAL_TRACE_RX_HEAD '[' -#define HAL_TRACE_RX_END ']' -#define HAL_TRACE_RX_SEPARATOR ',' +#define HAL_TRACE_RX_HEAD '[' +#define HAL_TRACE_RX_END ']' +#define HAL_TRACE_RX_SEPARATOR ',' -//static struct HAL_DMA_CH_CFG_T dma_cfg_rx; +// static struct HAL_DMA_CH_CFG_T dma_cfg_rx; #if (defined(DEBUG) || defined(REL_TRACE_ENABLE)) static struct HAL_DMA_DESC_T dma_desc_rx; #endif -typedef struct{ - char *name; - uint32_t len; - uint8_t *buf; -}HAL_TRACE_RX_CFG_T; +typedef struct { + char *name; + uint32_t len; + uint8_t *buf; +} HAL_TRACE_RX_CFG_T; -typedef struct{ - char name[HAL_TRACE_RX_NAME_SIZE]; - HAL_TRACE_RX_CALLBACK_T callback; -}HAL_TRACE_RX_LIST_T; +typedef struct { + char name[HAL_TRACE_RX_NAME_SIZE]; + HAL_TRACE_RX_CALLBACK_T callback; +} HAL_TRACE_RX_LIST_T; -typedef struct{ - uint32_t list_num; - HAL_TRACE_RX_LIST_T list[HAL_TRACE_RX_ROLE_NUM]; +typedef struct { + uint32_t list_num; + HAL_TRACE_RX_LIST_T list[HAL_TRACE_RX_ROLE_NUM]; - uint32_t rx_enable; - uint32_t pos; - uint8_t buf[HAL_TRACE_RX_BUF_SIZE]; -}HAL_TRACE_RX_T; + uint32_t rx_enable; + uint32_t pos; + uint8_t buf[HAL_TRACE_RX_BUF_SIZE]; +} HAL_TRACE_RX_T; #if defined(_AUTO_TEST_) extern int auto_test_prase(uint8_t *cmd); @@ -2515,289 +2641,251 @@ extern int auto_test_prase(uint8_t *cmd); HAL_TRACE_RX_T hal_trace_rx; -int hal_trace_rx_dump_list(void) -{ - for(int i=0;iname = (char *)(buf + pos); + for (; pos < HAL_TRACE_RX_NAME_SIZE + HAL_TRACE_RX_HEAD_SIZE; pos++) { + if (buf[pos] == HAL_TRACE_RX_SEPARATOR) { + buf[pos] = 0; + break; } + } - pos++; + // TRACE(1,"Step1: %s", cfg->name); + // TRACE(1,"%d", strlen(cfg->name)); - cfg->name = (char *)(buf+pos); - for(; posbuf = (uint8_t *)(buf + pos); + for (; pos < HAL_TRACE_RX_BUF_SIZE; pos++) { + if (buf[pos] == HAL_TRACE_RX_END) { + buf[pos] = 0; + break; } + len++; + } + cfg->len = len; + if (pos == HAL_TRACE_RX_BUF_SIZE) { + return 2; + } - // TRACE(1,"Step1: %s", cfg->name); - // TRACE(1,"%d", strlen(cfg->name)); - - if(pos == HAL_TRACE_RX_NAME_SIZE) - { - return 1; - } - - pos++; - - len = 0; - cfg->buf = (uint8_t*)(buf+pos); - for(; poslen = len; - if(pos == HAL_TRACE_RX_BUF_SIZE) - { - return 2; - } - - return 0; + return 0; } #if defined(IBRT) -void app_ibrt_peripheral_automate_test(const char* ibrt_cmd, uint32_t cmd_len); -void app_ibrt_peripheral_perform_test(const char* ibrt_cmd); +void app_ibrt_peripheral_automate_test(const char *ibrt_cmd, uint32_t cmd_len); +void app_ibrt_peripheral_perform_test(const char *ibrt_cmd); #endif -int hal_trace_rx_process(uint8_t *buf, uint32_t len) -{ - HAL_TRACE_RX_CFG_T cfg; - int id = 0; - int res = 0; +int hal_trace_rx_process(uint8_t *buf, uint32_t len) { + HAL_TRACE_RX_CFG_T cfg; + int id = 0; + int res = 0; #if defined(IBRT) - if(buf && strlen((char*)buf) >= 10 &&((strncmp((char*)buf, "auto_test:", 10) == 0)||(strncmp((char*)buf, "ibrt_test:", 10) == 0))) - { + if (buf && strlen((char *)buf) >= 10 && + ((strncmp((char *)buf, "auto_test:", 10) == 0) || + (strncmp((char *)buf, "ibrt_test:", 10) == 0))) { #ifdef BES_AUTOMATE_TEST - app_ibrt_peripheral_automate_test((char*)(buf + 10), len - 10); + app_ibrt_peripheral_automate_test((char *)(buf + 10), len - 10); #else - app_ibrt_peripheral_perform_test((char*)(buf + 10)); + app_ibrt_peripheral_perform_test((char *)(buf + 10)); #endif - return 0; - } -#endif - - res = hal_trace_rx_parse((int8_t*)buf, &cfg); - - if(res) - { - TRACE(1,"ERROR: hal_trace_rx_parse %d", res); - return 1; - } - else - { - // TRACE(1,"%s rx OK", cfg.name); - } - - id = hal_trace_rx_is_in_list(cfg.name); - - if(id == -1) - { - TRACE(1,"%s is invalid", cfg.name); - return -1; - } - - if(hal_trace_rx.list[id].callback) - { - hal_trace_rx.list[id].callback(cfg.buf, cfg.len); - } - else - { - TRACE(1,"%s has not callback", hal_trace_rx.list[id].name); - } - return 0; + } +#endif + + res = hal_trace_rx_parse((int8_t *)buf, &cfg); + + if (res) { + TRACE(1, "ERROR: hal_trace_rx_parse %d", res); + return 1; + } else { + // TRACE(1,"%s rx OK", cfg.name); + } + + id = hal_trace_rx_is_in_list(cfg.name); + + if (id == -1) { + TRACE(1, "%s is invalid", cfg.name); + return -1; + } + + if (hal_trace_rx.list[id].callback) { + hal_trace_rx.list[id].callback(cfg.buf, cfg.len); + } else { + TRACE(1, "%s has not callback", hal_trace_rx.list[id].name); + } + + return 0; } #if (defined(DEBUG) || defined(REL_TRACE_ENABLE)) -void hal_trace_rx_start(void) -{ - uint32_t desc_cnt = 1; - union HAL_UART_IRQ_T mask; +void hal_trace_rx_start(void) { + uint32_t desc_cnt = 1; + union HAL_UART_IRQ_T mask; - mask.reg = 0; - mask.BE = 0; - mask.FE = 0; - mask.OE = 0; - mask.PE = 0; - mask.RT = 1; + mask.reg = 0; + mask.BE = 0; + mask.FE = 0; + mask.OE = 0; + mask.PE = 0; + mask.RT = 1; - hal_uart_dma_recv_mask(trace_uart, hal_trace_rx.buf, HAL_TRACE_RX_BUF_SIZE, &dma_desc_rx, &desc_cnt, &mask); + hal_uart_dma_recv_mask(trace_uart, hal_trace_rx.buf, HAL_TRACE_RX_BUF_SIZE, + &dma_desc_rx, &desc_cnt, &mask); } -void hal_trace_rx_irq_handler(uint32_t xfer_size, int dma_error, union HAL_UART_IRQ_T status) -{ - int res; - // TRACE(4,"[%s] %d, %d, %d", __func__, xfer_size, dma_error, status); +void hal_trace_rx_irq_handler(uint32_t xfer_size, int dma_error, + union HAL_UART_IRQ_T status) { + int res; + // TRACE(4,"[%s] %d, %d, %d", __func__, xfer_size, dma_error, status); - if (xfer_size) - { - hal_trace_rx.buf[xfer_size] = 0; - #if defined(_AUTO_TEST_) - res = auto_test_prase(hal_trace_rx.buf); - if(res) - { - TRACE(2,"%s:auto_test_prase prase data error, err_code = %d", __func__, res); - } - #else - //TRACE(2,"[%s] RX = %s", __func__, hal_trace_rx.buf); - res = hal_trace_rx_process(hal_trace_rx.buf, xfer_size); - if(res) - { - TRACE(2,"%s:hal_trace_rx_process prase data error, err_code = %d",__func__, res); - } - #endif - hal_trace_rx_reset(); - hal_trace_rx_start(); + if (xfer_size) { + hal_trace_rx.buf[xfer_size] = 0; +#if defined(_AUTO_TEST_) + res = auto_test_prase(hal_trace_rx.buf); + if (res) { + TRACE(2, "%s:auto_test_prase prase data error, err_code = %d", __func__, + res); } -} - -uint32_t app_test_callback(unsigned char *buf, uint32_t len) -{ - TRACE(2,"[%s] len = %d", __func__, len); - - // Process string - int num_int = 0; - int num_float = 0.0; - TRACE(2,"[%s] %s", __func__, buf); - hal_trace_rx_parser((char*)buf, "%d,%d", &num_int, &num_float); - - TRACE(3,"[%s] %d:%d", __func__, num_int, num_float); - - return 0; -} - -int hal_trace_rx_open() -{ - hal_uart_irq_set_dma_handler(trace_uart, hal_trace_rx_irq_handler, NULL); +#else + // TRACE(2,"[%s] RX = %s", __func__, hal_trace_rx.buf); + res = hal_trace_rx_process(hal_trace_rx.buf, xfer_size); + if (res) { + TRACE(2, "%s:hal_trace_rx_process prase data error, err_code = %d", + __func__, res); + } +#endif + hal_trace_rx_reset(); hal_trace_rx_start(); - - hal_trace_rx_register("test", (HAL_TRACE_RX_CALLBACK_T)app_test_callback); - - return 0; + } } -int hal_trace_rx_reopen() -{ - hal_uart_reopen(trace_uart, &uart_rx_enable_cfg); - hal_trace_rx_open(); - - return 0; +uint32_t app_test_callback(unsigned char *buf, uint32_t len) { + TRACE(2, "[%s] len = %d", __func__, len); + + // Process string + int num_int = 0; + int num_float = 0.0; + TRACE(2, "[%s] %s", __func__, buf); + hal_trace_rx_parser((char *)buf, "%d,%d", &num_int, &num_float); + + TRACE(3, "[%s] %d:%d", __func__, num_int, num_float); + + return 0; +} + +int hal_trace_rx_open() { + hal_uart_irq_set_dma_handler(trace_uart, hal_trace_rx_irq_handler, NULL); + hal_trace_rx_start(); + + hal_trace_rx_register("test", (HAL_TRACE_RX_CALLBACK_T)app_test_callback); + + return 0; +} + +int hal_trace_rx_reopen() { + hal_uart_reopen(trace_uart, &uart_rx_enable_cfg); + hal_trace_rx_open(); + + return 0; } #endif diff --git a/platform/hal/hal_trace_mod.c b/platform/hal/hal_trace_mod.c index 28426f9..477a6a7 100644 --- a/platform/hal/hal_trace_mod.c +++ b/platform/hal/hal_trace_mod.c @@ -17,16 +17,13 @@ #include "plat_types.h" #undef _LOG_MODULE_DEF_A -#define _LOG_MODULE_DEF_A(p, m) # m +#define _LOG_MODULE_DEF_A(p, m) #m -static const char * mod_desc[] = { - _LOG_MODULE_LIST -}; +static const char *mod_desc[] = {_LOG_MODULE_LIST}; -const char *hal_trace_get_log_module_desc(enum LOG_MODULE_T module) -{ - if (module < ARRAY_SIZE(mod_desc)) { - return mod_desc[module]; - } - return NULL; +const char *hal_trace_get_log_module_desc(enum LOG_MODULE_T module) { + if (module < ARRAY_SIZE(mod_desc)) { + return mod_desc[module]; + } + return NULL; } diff --git a/platform/hal/hal_transq.c b/platform/hal/hal_transq.c index 2849378..df21878 100644 --- a/platform/hal/hal_transq.c +++ b/platform/hal/hal_transq.c @@ -15,26 +15,26 @@ ****************************************************************************/ #ifdef CHIP_HAS_TRANSQ +#include "hal_transq.h" +#include "cmsis_nvic.h" +#include "hal_cmu.h" +#include "hal_trace.h" #include "plat_addr_map.h" #include "reg_transq.h" -#include "hal_transq.h" -#include "hal_trace.h" -#include "hal_cmu.h" #include "stdbool.h" -#include "cmsis_nvic.h" // BITMAP: // [High Priority Slots] ...... [Normal Priority Slots] // 31 30 29 28 27 26 25 ...... 10 9 8 7 6 5 4 3 2 1 0 -static struct TRANSQ_T * const transq[HAL_TRANSQ_ID_QTY] = { +static struct TRANSQ_T *const transq[HAL_TRANSQ_ID_QTY] = { (struct TRANSQ_T *)TRANSQ0_BASE, #if (CHIP_HAS_TRANSQ > 1) (struct TRANSQ_T *)TRANSQ1_BASE, #endif }; -static struct TRANSQ_T * const peer_transq[HAL_TRANSQ_ID_QTY] = { +static struct TRANSQ_T *const peer_transq[HAL_TRANSQ_ID_QTY] = { (struct TRANSQ_T *)TRANSQ0_PEER_BASE, #if (CHIP_HAS_TRANSQ > 1) (struct TRANSQ_T *)TRANSQ1_PEER_BASE, @@ -67,552 +67,580 @@ static uint8_t next_rx_slot[HAL_TRANSQ_ID_QTY][HAL_TRANSQ_PRI_QTY]; static uint32_t rx_irq_mask[HAL_TRANSQ_ID_QTY][HAL_TRANSQ_PRI_QTY]; -static uint32_t construct_mask(uint32_t lsb, uint32_t width) -{ - int i; - uint32_t result; +static uint32_t construct_mask(uint32_t lsb, uint32_t width) { + int i; + uint32_t result; - if (lsb >= 32 || width == 0) { - return 0; - } + if (lsb >= 32 || width == 0) { + return 0; + } - result = 0; - for (i = lsb; i < lsb + width; i++) { - result |= (1 << i); - } + result = 0; + for (i = lsb; i < lsb + width; i++) { + result |= (1 << i); + } - return result; + return result; } -static uint32_t get_next_rx_slot(enum HAL_TRANSQ_ID_T id, enum HAL_TRANSQ_PRI_T pri, uint32_t slot) -{ - slot++; - if (pri == HAL_TRANSQ_PRI_HIGH) { - if (slot >= TRANSQ_SLOT_NUM) { - slot = TRANSQ_SLOT_NUM - transq_cfg[id].slot.rx_num[pri]; - } - } else { - if (slot >= transq_cfg[id].slot.rx_num[pri]) { - slot = 0; - } +static uint32_t get_next_rx_slot(enum HAL_TRANSQ_ID_T id, + enum HAL_TRANSQ_PRI_T pri, uint32_t slot) { + slot++; + if (pri == HAL_TRANSQ_PRI_HIGH) { + if (slot >= TRANSQ_SLOT_NUM) { + slot = TRANSQ_SLOT_NUM - transq_cfg[id].slot.rx_num[pri]; } + } else { + if (slot >= transq_cfg[id].slot.rx_num[pri]) { + slot = 0; + } + } - return slot; + return slot; } -static uint32_t get_next_tx_slot(enum HAL_TRANSQ_ID_T id, enum HAL_TRANSQ_PRI_T pri, uint32_t slot) -{ - slot++; - if (pri == HAL_TRANSQ_PRI_HIGH) { - if (slot >= TRANSQ_SLOT_NUM) { - slot = TRANSQ_SLOT_NUM - transq_cfg[id].slot.tx_num[pri]; - } - } else { - if (slot >= transq_cfg[id].slot.tx_num[pri]) { - slot = 0; - } +static uint32_t get_next_tx_slot(enum HAL_TRANSQ_ID_T id, + enum HAL_TRANSQ_PRI_T pri, uint32_t slot) { + slot++; + if (pri == HAL_TRANSQ_PRI_HIGH) { + if (slot >= TRANSQ_SLOT_NUM) { + slot = TRANSQ_SLOT_NUM - transq_cfg[id].slot.tx_num[pri]; } + } else { + if (slot >= transq_cfg[id].slot.tx_num[pri]) { + slot = 0; + } + } - return slot; + return slot; } -static void hal_transq_remote_irq_handler(void) -{ - enum HAL_TRANSQ_ID_T id; - enum HAL_TRANSQ_PRI_T pri; - uint32_t status; - uint32_t slot; +static void hal_transq_remote_irq_handler(void) { + enum HAL_TRANSQ_ID_T id; + enum HAL_TRANSQ_PRI_T pri; + uint32_t status; + uint32_t slot; #if (CHIP_HAS_TRANSQ > 1) - IRQn_Type irq = NVIC_GetCurrentActiveIRQ(); + IRQn_Type irq = NVIC_GetCurrentActiveIRQ(); - for (id = HAL_TRANSQ_ID_0; id < HAL_TRANSQ_ID_QTY; id++) { - if (irq == remote_irq_num[id]) { - break; - } - } - if (id >= HAL_TRANSQ_ID_QTY) { - return; + for (id = HAL_TRANSQ_ID_0; id < HAL_TRANSQ_ID_QTY; id++) { + if (irq == remote_irq_num[id]) { + break; } + } + if (id >= HAL_TRANSQ_ID_QTY) { + return; + } #else - id = HAL_TRANSQ_ID_0; + id = HAL_TRANSQ_ID_0; #endif - while ((status = peer_transq[id]->RMT_MIS) != 0) { - slot = next_rx_slot[id][HAL_TRANSQ_PRI_HIGH]; - if (slot < TRANSQ_SLOT_NUM && (status & (1 << slot))) { - pri = HAL_TRANSQ_PRI_HIGH; - } else { - pri = HAL_TRANSQ_PRI_NORMAL; - slot = next_rx_slot[id][HAL_TRANSQ_PRI_NORMAL]; + while ((status = peer_transq[id]->RMT_MIS) != 0) { + slot = next_rx_slot[id][HAL_TRANSQ_PRI_HIGH]; + if (slot < TRANSQ_SLOT_NUM && (status & (1 << slot))) { + pri = HAL_TRANSQ_PRI_HIGH; + } else { + pri = HAL_TRANSQ_PRI_NORMAL; + slot = next_rx_slot[id][HAL_TRANSQ_PRI_NORMAL]; - ASSERT(slot < TRANSQ_SLOT_NUM && (status & (1 << slot)), - "TRANSQ-%d: Rx IRQ when no slot or out of order: status=0x%08x next=%d pri_next=%d", - id, status, next_rx_slot[id][HAL_TRANSQ_PRI_NORMAL], next_rx_slot[id][HAL_TRANSQ_PRI_HIGH]); - } - - // Mask IRQ from corresponding slots - peer_transq[id]->RMT_INTMASK &= ~rx_irq_mask[id][pri]; - - if (transq_cfg[id].rx_handler) { - transq_cfg[id].rx_handler(pri); - } - } -} - -static int hal_transq_active_tx_valid(enum HAL_TRANSQ_ID_T id, enum HAL_TRANSQ_PRI_T pri) -{ - return (active_tx_slot[id][pri] >= TRANSQ_SLOT_NUM || - active_tx_slot[id][pri] != next_tx_slot[id][pri] || - tx_slot_full[id][pri]); -} - -static void hal_transq_local_irq_handler(void) -{ - enum HAL_TRANSQ_ID_T id; - enum HAL_TRANSQ_PRI_T pri; - uint32_t status; - uint32_t slot, next_slot; - uint32_t lock; - -#if (CHIP_HAS_TRANSQ > 1) - IRQn_Type irq = NVIC_GetCurrentActiveIRQ(); - - for (id = HAL_TRANSQ_ID_0; id < HAL_TRANSQ_ID_QTY; id++) { - if (irq == local_irq_num[id]) { - break; - } - } - if (id >= HAL_TRANSQ_ID_QTY) { - return; - } -#else - id = HAL_TRANSQ_ID_0; -#endif - - while ((status = transq[id]->LERR_MIS) != 0) { - transq[id]->LERR_ISC.LERR_INTCLR = status; - ASSERT(false, "TRANSQ-%d: Tx on active slot: 0x%08x", id, status); + ASSERT(slot < TRANSQ_SLOT_NUM && (status & (1 << slot)), + "TRANSQ-%d: Rx IRQ when no slot or out of order: status=0x%08x " + "next=%d pri_next=%d", + id, status, next_rx_slot[id][HAL_TRANSQ_PRI_NORMAL], + next_rx_slot[id][HAL_TRANSQ_PRI_HIGH]); } - while ((status = transq[id]->LDONE_MIS) != 0) { - if (transq_cfg[id].tx_handler) { - lock = int_lock(); + // Mask IRQ from corresponding slots + peer_transq[id]->RMT_INTMASK &= ~rx_irq_mask[id][pri]; - ASSERT(hal_transq_active_tx_valid(id, HAL_TRANSQ_PRI_HIGH), "TRANSQ-%d: Corrupted pri active tx: active=%d next=%d full=%d", - id, active_tx_slot[id][HAL_TRANSQ_PRI_HIGH], next_tx_slot[id][HAL_TRANSQ_PRI_HIGH], tx_slot_full[id][HAL_TRANSQ_PRI_HIGH]); - ASSERT(hal_transq_active_tx_valid(id, HAL_TRANSQ_PRI_NORMAL), "TRANSQ-%d: Corrupted active tx: active=%d next=%d full=%d", - id, active_tx_slot[id][HAL_TRANSQ_PRI_NORMAL], next_tx_slot[id][HAL_TRANSQ_PRI_NORMAL], tx_slot_full[id][HAL_TRANSQ_PRI_NORMAL]); - - slot = active_tx_slot[id][HAL_TRANSQ_PRI_HIGH]; - if (slot < TRANSQ_SLOT_NUM && (status & (1 << slot))) { - pri = HAL_TRANSQ_PRI_HIGH; - } else { - pri = HAL_TRANSQ_PRI_NORMAL; - slot = active_tx_slot[id][HAL_TRANSQ_PRI_NORMAL]; - - ASSERT(slot < TRANSQ_SLOT_NUM && (status & (1 << slot)), - "TRANSQ-%d: Tx done IRQ when slot empty or out of order: status=0x%08x next=%d pri_next=%d", - id, status, active_tx_slot[id][HAL_TRANSQ_PRI_NORMAL], active_tx_slot[id][HAL_TRANSQ_PRI_HIGH]); - } - - // Clear the interrupt - transq[id]->LDONE_ISC.LDONE_INTCLR = (1 << slot); - - next_slot = get_next_tx_slot(id, pri, slot); - - if (!tx_slot_full[id][pri] && next_slot == next_tx_slot[id][pri]) { - // No tx in progress - active_tx_slot[id][pri] = TRANSQ_SLOT_NUM; - } else { - tx_slot_full[id][pri] = false; - if (transq_cfg[id].slot.tx_num[pri] == 1) { - // No tx in progress - active_tx_slot[id][pri] = TRANSQ_SLOT_NUM; - } else { - // Some tx in progress - active_tx_slot[id][pri] = next_slot; - } - } - - int_unlock(lock); - - transq_cfg[id].tx_handler(pri, - (const uint8_t *)transq[id]->WSLOT[slot].ADDR, - transq[id]->WSLOT[slot].LEN); - } else { - transq[id]->LDONE_INTMASK = 0; - } - } -} - -enum HAL_TRANSQ_RET_T hal_transq_get_rx_status(enum HAL_TRANSQ_ID_T id, enum HAL_TRANSQ_PRI_T pri, bool *ready) -{ - uint32_t lock; - uint32_t slot; - - if (id >= HAL_TRANSQ_ID_QTY) { - return HAL_TRANSQ_RET_BAD_ID; - } - if (pri >= HAL_TRANSQ_PRI_QTY) { - return HAL_TRANSQ_RET_BAD_PRI; - } - if (transq_cfg[id].slot.rx_num[pri] == 0) { - return HAL_TRANSQ_RET_BAD_RX_NUM; - } if (transq_cfg[id].rx_handler) { - // Rx will be processed by IRQ handler - return HAL_TRANSQ_RET_BAD_MODE; + transq_cfg[id].rx_handler(pri); } - - lock = int_lock(); - - slot = next_rx_slot[id][pri]; - - if (slot < TRANSQ_SLOT_NUM && peer_transq[id]->RMT_ISC.RMT_RIS & (1 << slot)) { - *ready = true; - } else { - *ready = false; - } - - int_unlock(lock); - - return HAL_TRANSQ_RET_OK; + } } -enum HAL_TRANSQ_RET_T hal_transq_get_tx_status(enum HAL_TRANSQ_ID_T id, enum HAL_TRANSQ_PRI_T pri, bool *done) -{ - uint32_t lock; - uint32_t slot, next_slot; +static int hal_transq_active_tx_valid(enum HAL_TRANSQ_ID_T id, + enum HAL_TRANSQ_PRI_T pri) { + return (active_tx_slot[id][pri] >= TRANSQ_SLOT_NUM || + active_tx_slot[id][pri] != next_tx_slot[id][pri] || + tx_slot_full[id][pri]); +} - if (id >= HAL_TRANSQ_ID_QTY) { - return HAL_TRANSQ_RET_BAD_ID; - } - if (pri >= HAL_TRANSQ_PRI_QTY) { - return HAL_TRANSQ_RET_BAD_PRI; - } - if (transq_cfg[id].slot.tx_num[pri] == 0) { - return HAL_TRANSQ_RET_BAD_TX_NUM; +static void hal_transq_local_irq_handler(void) { + enum HAL_TRANSQ_ID_T id; + enum HAL_TRANSQ_PRI_T pri; + uint32_t status; + uint32_t slot, next_slot; + uint32_t lock; + +#if (CHIP_HAS_TRANSQ > 1) + IRQn_Type irq = NVIC_GetCurrentActiveIRQ(); + + for (id = HAL_TRANSQ_ID_0; id < HAL_TRANSQ_ID_QTY; id++) { + if (irq == local_irq_num[id]) { + break; } + } + if (id >= HAL_TRANSQ_ID_QTY) { + return; + } +#else + id = HAL_TRANSQ_ID_0; +#endif + + while ((status = transq[id]->LERR_MIS) != 0) { + transq[id]->LERR_ISC.LERR_INTCLR = status; + ASSERT(false, "TRANSQ-%d: Tx on active slot: 0x%08x", id, status); + } + + while ((status = transq[id]->LDONE_MIS) != 0) { if (transq_cfg[id].tx_handler) { - // Tx done will be processed by IRQ handler - return HAL_TRANSQ_RET_BAD_MODE; - } + lock = int_lock(); - lock = int_lock(); + ASSERT(hal_transq_active_tx_valid(id, HAL_TRANSQ_PRI_HIGH), + "TRANSQ-%d: Corrupted pri active tx: active=%d next=%d full=%d", + id, active_tx_slot[id][HAL_TRANSQ_PRI_HIGH], + next_tx_slot[id][HAL_TRANSQ_PRI_HIGH], + tx_slot_full[id][HAL_TRANSQ_PRI_HIGH]); + ASSERT(hal_transq_active_tx_valid(id, HAL_TRANSQ_PRI_NORMAL), + "TRANSQ-%d: Corrupted active tx: active=%d next=%d full=%d", id, + active_tx_slot[id][HAL_TRANSQ_PRI_NORMAL], + next_tx_slot[id][HAL_TRANSQ_PRI_NORMAL], + tx_slot_full[id][HAL_TRANSQ_PRI_NORMAL]); - slot = active_tx_slot[id][pri]; + slot = active_tx_slot[id][HAL_TRANSQ_PRI_HIGH]; + if (slot < TRANSQ_SLOT_NUM && (status & (1 << slot))) { + pri = HAL_TRANSQ_PRI_HIGH; + } else { + pri = HAL_TRANSQ_PRI_NORMAL; + slot = active_tx_slot[id][HAL_TRANSQ_PRI_NORMAL]; - ASSERT(hal_transq_active_tx_valid(id, pri), "TRANSQ-%d: Corrupted active tx: pri=%d active=%d next=%d full=%d", - id, pri, active_tx_slot[id][pri], next_tx_slot[id][pri], tx_slot_full[id][pri]); + ASSERT(slot < TRANSQ_SLOT_NUM && (status & (1 << slot)), + "TRANSQ-%d: Tx done IRQ when slot empty or out of order: " + "status=0x%08x next=%d pri_next=%d", + id, status, active_tx_slot[id][HAL_TRANSQ_PRI_NORMAL], + active_tx_slot[id][HAL_TRANSQ_PRI_HIGH]); + } - if (transq[id]->LDONE_ISC.LDONE_RIS & (1 << slot)) { - *done = true; + // Clear the interrupt + transq[id]->LDONE_ISC.LDONE_INTCLR = (1 << slot); - // Clear the interrupt - transq[id]->LDONE_ISC.LDONE_INTCLR = (1 << slot); + next_slot = get_next_tx_slot(id, pri, slot); - next_slot = get_next_tx_slot(id, pri, slot); - - if (!tx_slot_full[id][pri] && next_slot == next_tx_slot[id][pri]) { - // No tx in progress - active_tx_slot[id][pri] = TRANSQ_SLOT_NUM; + if (!tx_slot_full[id][pri] && next_slot == next_tx_slot[id][pri]) { + // No tx in progress + active_tx_slot[id][pri] = TRANSQ_SLOT_NUM; + } else { + tx_slot_full[id][pri] = false; + if (transq_cfg[id].slot.tx_num[pri] == 1) { + // No tx in progress + active_tx_slot[id][pri] = TRANSQ_SLOT_NUM; } else { - tx_slot_full[id][pri] = false; - if (transq_cfg[id].slot.tx_num[pri] == 1) { - // No tx in progress - active_tx_slot[id][pri] = TRANSQ_SLOT_NUM; - } else { - // Some tx in progress - active_tx_slot[id][pri] = next_slot; - } + // Some tx in progress + active_tx_slot[id][pri] = next_slot; } + } + + int_unlock(lock); + + transq_cfg[id].tx_handler(pri, + (const uint8_t *)transq[id]->WSLOT[slot].ADDR, + transq[id]->WSLOT[slot].LEN); } else { - *done = false; + transq[id]->LDONE_INTMASK = 0; } - - int_unlock(lock); - - return HAL_TRANSQ_RET_OK; + } } -enum HAL_TRANSQ_RET_T hal_transq_rx_first(enum HAL_TRANSQ_ID_T id, enum HAL_TRANSQ_PRI_T pri, const uint8_t **data, uint32_t *len) -{ - enum HAL_TRANSQ_RET_T ret; - uint32_t slot; - //uint32_t lock; +enum HAL_TRANSQ_RET_T hal_transq_get_rx_status(enum HAL_TRANSQ_ID_T id, + enum HAL_TRANSQ_PRI_T pri, + bool *ready) { + uint32_t lock; + uint32_t slot; - if (id >= HAL_TRANSQ_ID_QTY) { - return HAL_TRANSQ_RET_BAD_ID; - } - if (pri >= HAL_TRANSQ_PRI_QTY) { - return HAL_TRANSQ_RET_BAD_PRI; - } - if (transq_cfg[id].slot.rx_num[pri] == 0) { - return HAL_TRANSQ_RET_BAD_RX_NUM; - } + if (id >= HAL_TRANSQ_ID_QTY) { + return HAL_TRANSQ_RET_BAD_ID; + } + if (pri >= HAL_TRANSQ_PRI_QTY) { + return HAL_TRANSQ_RET_BAD_PRI; + } + if (transq_cfg[id].slot.rx_num[pri] == 0) { + return HAL_TRANSQ_RET_BAD_RX_NUM; + } + if (transq_cfg[id].rx_handler) { + // Rx will be processed by IRQ handler + return HAL_TRANSQ_RET_BAD_MODE; + } - //lock = int_lock(); + lock = int_lock(); - slot = next_rx_slot[id][pri]; + slot = next_rx_slot[id][pri]; - if (slot < TRANSQ_SLOT_NUM && peer_transq[id]->RMT_ISC.RMT_RIS & (1 << slot)) { - // Msg available - ret = HAL_TRANSQ_RET_OK; + if (slot < TRANSQ_SLOT_NUM && + peer_transq[id]->RMT_ISC.RMT_RIS & (1 << slot)) { + *ready = true; + } else { + *ready = false; + } - if (data) { - *data = (const uint8_t *)peer_transq[id]->RSLOT[slot].ADDR; - } - if (len) { - *len = peer_transq[id]->RSLOT[slot].LEN; - } - } else { - // No msg. Re-enable IRQ - ret = HAL_TRANSQ_RET_RX_EMPTY; + int_unlock(lock); - if (data) { - *data = NULL; - } - if (len) { - *len = 0; - } - peer_transq[id]->RMT_INTMASK |= rx_irq_mask[id][pri]; - } - - //int_unlock(lock); - - return ret; + return HAL_TRANSQ_RET_OK; } -enum HAL_TRANSQ_RET_T hal_transq_rx_next(enum HAL_TRANSQ_ID_T id, enum HAL_TRANSQ_PRI_T pri, const uint8_t **data, uint32_t *len) -{ - enum HAL_TRANSQ_RET_T ret; - uint32_t slot; - //uint32_t lock; +enum HAL_TRANSQ_RET_T hal_transq_get_tx_status(enum HAL_TRANSQ_ID_T id, + enum HAL_TRANSQ_PRI_T pri, + bool *done) { + uint32_t lock; + uint32_t slot, next_slot; - if (id >= HAL_TRANSQ_ID_QTY) { - return HAL_TRANSQ_RET_BAD_ID; - } - if (pri >= HAL_TRANSQ_PRI_QTY) { - return HAL_TRANSQ_RET_BAD_PRI; - } - if (transq_cfg[id].slot.rx_num[pri] == 0) { - return HAL_TRANSQ_RET_BAD_RX_NUM; - } + if (id >= HAL_TRANSQ_ID_QTY) { + return HAL_TRANSQ_RET_BAD_ID; + } + if (pri >= HAL_TRANSQ_PRI_QTY) { + return HAL_TRANSQ_RET_BAD_PRI; + } + if (transq_cfg[id].slot.tx_num[pri] == 0) { + return HAL_TRANSQ_RET_BAD_TX_NUM; + } + if (transq_cfg[id].tx_handler) { + // Tx done will be processed by IRQ handler + return HAL_TRANSQ_RET_BAD_MODE; + } + lock = int_lock(); + + slot = active_tx_slot[id][pri]; + + ASSERT(hal_transq_active_tx_valid(id, pri), + "TRANSQ-%d: Corrupted active tx: pri=%d active=%d next=%d full=%d", id, + pri, active_tx_slot[id][pri], next_tx_slot[id][pri], + tx_slot_full[id][pri]); + + if (transq[id]->LDONE_ISC.LDONE_RIS & (1 << slot)) { + *done = true; + + // Clear the interrupt + transq[id]->LDONE_ISC.LDONE_INTCLR = (1 << slot); + + next_slot = get_next_tx_slot(id, pri, slot); + + if (!tx_slot_full[id][pri] && next_slot == next_tx_slot[id][pri]) { + // No tx in progress + active_tx_slot[id][pri] = TRANSQ_SLOT_NUM; + } else { + tx_slot_full[id][pri] = false; + if (transq_cfg[id].slot.tx_num[pri] == 1) { + // No tx in progress + active_tx_slot[id][pri] = TRANSQ_SLOT_NUM; + } else { + // Some tx in progress + active_tx_slot[id][pri] = next_slot; + } + } + } else { + *done = false; + } + + int_unlock(lock); + + return HAL_TRANSQ_RET_OK; +} + +enum HAL_TRANSQ_RET_T hal_transq_rx_first(enum HAL_TRANSQ_ID_T id, + enum HAL_TRANSQ_PRI_T pri, + const uint8_t **data, uint32_t *len) { + enum HAL_TRANSQ_RET_T ret; + uint32_t slot; + // uint32_t lock; + + if (id >= HAL_TRANSQ_ID_QTY) { + return HAL_TRANSQ_RET_BAD_ID; + } + if (pri >= HAL_TRANSQ_PRI_QTY) { + return HAL_TRANSQ_RET_BAD_PRI; + } + if (transq_cfg[id].slot.rx_num[pri] == 0) { + return HAL_TRANSQ_RET_BAD_RX_NUM; + } + + // lock = int_lock(); + + slot = next_rx_slot[id][pri]; + + if (slot < TRANSQ_SLOT_NUM && + peer_transq[id]->RMT_ISC.RMT_RIS & (1 << slot)) { + // Msg available ret = HAL_TRANSQ_RET_OK; - //lock = int_lock(); - - slot = next_rx_slot[id][pri]; - - if (slot < TRANSQ_SLOT_NUM && peer_transq[id]->RMT_ISC.RMT_RIS & (1 << slot)) { - // Clear cur IRQ - peer_transq[id]->RMT_ISC.RMT_INTCLR = (1 << slot); - - // Update next_rx_slot - slot = get_next_rx_slot(id, pri, slot); - next_rx_slot[id][pri] = slot; - - if (slot < TRANSQ_SLOT_NUM && peer_transq[id]->RMT_ISC.RMT_RIS & (1 << slot)) { - // Next msg available - if (data) { - *data = (const uint8_t *)peer_transq[id]->RSLOT[slot].ADDR; - } - if (len) { - *len = peer_transq[id]->RSLOT[slot].LEN; - } - } else { - // No msg - ret = HAL_TRANSQ_RET_RX_EMPTY; - } - } else { - // No msg - ret = HAL_TRANSQ_RET_RX_EMPTY; + if (data) { + *data = (const uint8_t *)peer_transq[id]->RSLOT[slot].ADDR; } - - if (ret == HAL_TRANSQ_RET_RX_EMPTY) { - if (data) { - *data = NULL; - } - if (len) { - *len = 0; - } - // Re-enable IRQ - peer_transq[id]->RMT_INTMASK |= rx_irq_mask[id][pri]; + if (len) { + *len = peer_transq[id]->RSLOT[slot].LEN; } + } else { + // No msg. Re-enable IRQ + ret = HAL_TRANSQ_RET_RX_EMPTY; - //int_unlock(lock); + if (data) { + *data = NULL; + } + if (len) { + *len = 0; + } + peer_transq[id]->RMT_INTMASK |= rx_irq_mask[id][pri]; + } - return ret; + // int_unlock(lock); + + return ret; } -enum HAL_TRANSQ_RET_T hal_transq_tx(enum HAL_TRANSQ_ID_T id, enum HAL_TRANSQ_PRI_T pri, const uint8_t *data, uint32_t len) -{ - enum HAL_TRANSQ_RET_T ret; - uint32_t lock; - uint32_t slot; +enum HAL_TRANSQ_RET_T hal_transq_rx_next(enum HAL_TRANSQ_ID_T id, + enum HAL_TRANSQ_PRI_T pri, + const uint8_t **data, uint32_t *len) { + enum HAL_TRANSQ_RET_T ret; + uint32_t slot; + // uint32_t lock; - if (id >= HAL_TRANSQ_ID_QTY) { - return HAL_TRANSQ_RET_BAD_ID; - } - if (pri >= HAL_TRANSQ_PRI_QTY) { - return HAL_TRANSQ_RET_BAD_PRI; - } - if (transq_cfg[id].slot.tx_num[pri] == 0) { - return HAL_TRANSQ_RET_BAD_TX_NUM; - } + if (id >= HAL_TRANSQ_ID_QTY) { + return HAL_TRANSQ_RET_BAD_ID; + } + if (pri >= HAL_TRANSQ_PRI_QTY) { + return HAL_TRANSQ_RET_BAD_PRI; + } + if (transq_cfg[id].slot.rx_num[pri] == 0) { + return HAL_TRANSQ_RET_BAD_RX_NUM; + } - lock = int_lock(); + ret = HAL_TRANSQ_RET_OK; - if (tx_slot_full[id][pri]) { - ret = HAL_TRANSQ_RET_TX_FULL; + // lock = int_lock(); + + slot = next_rx_slot[id][pri]; + + if (slot < TRANSQ_SLOT_NUM && + peer_transq[id]->RMT_ISC.RMT_RIS & (1 << slot)) { + // Clear cur IRQ + peer_transq[id]->RMT_ISC.RMT_INTCLR = (1 << slot); + + // Update next_rx_slot + slot = get_next_rx_slot(id, pri, slot); + next_rx_slot[id][pri] = slot; + + if (slot < TRANSQ_SLOT_NUM && + peer_transq[id]->RMT_ISC.RMT_RIS & (1 << slot)) { + // Next msg available + if (data) { + *data = (const uint8_t *)peer_transq[id]->RSLOT[slot].ADDR; + } + if (len) { + *len = peer_transq[id]->RSLOT[slot].LEN; + } } else { - ret = HAL_TRANSQ_RET_OK; - - slot = next_tx_slot[id][pri]; - - transq[id]->WSLOT[slot].ADDR = (uint32_t)data; - transq[id]->WSLOT[slot].LEN = len; - transq[id]->RMT_INTSET = (1 << slot); - - // Update active_tx_slot if this is the only tx in progress - if (active_tx_slot[id][pri] >= TRANSQ_SLOT_NUM) { - active_tx_slot[id][pri] = slot; - } - - // Update next_tx_slot - next_tx_slot[id][pri] = get_next_tx_slot(id, pri, slot); - - if (next_tx_slot[id][pri] == active_tx_slot[id][pri]) { - tx_slot_full[id][pri] = true; - } + // No msg + ret = HAL_TRANSQ_RET_RX_EMPTY; } + } else { + // No msg + ret = HAL_TRANSQ_RET_RX_EMPTY; + } - int_unlock(lock); + if (ret == HAL_TRANSQ_RET_RX_EMPTY) { + if (data) { + *data = NULL; + } + if (len) { + *len = 0; + } + // Re-enable IRQ + peer_transq[id]->RMT_INTMASK |= rx_irq_mask[id][pri]; + } - return ret; + // int_unlock(lock); + + return ret; } -enum HAL_TRANSQ_RET_T hal_transq_update_num(enum HAL_TRANSQ_ID_T id, const struct HAL_TRANSQ_SLOT_NUM_T *slot) -{ - uint32_t tx_mask; +enum HAL_TRANSQ_RET_T hal_transq_tx(enum HAL_TRANSQ_ID_T id, + enum HAL_TRANSQ_PRI_T pri, + const uint8_t *data, uint32_t len) { + enum HAL_TRANSQ_RET_T ret; + uint32_t lock; + uint32_t slot; - if (id >= HAL_TRANSQ_ID_QTY) { - return HAL_TRANSQ_RET_BAD_ID; - } - if (slot == NULL) { - return HAL_TRANSQ_RET_BAD_SLOT; - } - if (slot->tx_num[HAL_TRANSQ_PRI_NORMAL] + slot->tx_num[HAL_TRANSQ_PRI_HIGH] > TRANSQ_SLOT_NUM) { - return HAL_TRANSQ_RET_BAD_TX_NUM; - } - if (slot->rx_num[HAL_TRANSQ_PRI_NORMAL] + slot->rx_num[HAL_TRANSQ_PRI_HIGH] > TRANSQ_SLOT_NUM) { - return HAL_TRANSQ_RET_BAD_RX_NUM; + if (id >= HAL_TRANSQ_ID_QTY) { + return HAL_TRANSQ_RET_BAD_ID; + } + if (pri >= HAL_TRANSQ_PRI_QTY) { + return HAL_TRANSQ_RET_BAD_PRI; + } + if (transq_cfg[id].slot.tx_num[pri] == 0) { + return HAL_TRANSQ_RET_BAD_TX_NUM; + } + + lock = int_lock(); + + if (tx_slot_full[id][pri]) { + ret = HAL_TRANSQ_RET_TX_FULL; + } else { + ret = HAL_TRANSQ_RET_OK; + + slot = next_tx_slot[id][pri]; + + transq[id]->WSLOT[slot].ADDR = (uint32_t)data; + transq[id]->WSLOT[slot].LEN = len; + transq[id]->RMT_INTSET = (1 << slot); + + // Update active_tx_slot if this is the only tx in progress + if (active_tx_slot[id][pri] >= TRANSQ_SLOT_NUM) { + active_tx_slot[id][pri] = slot; } - transq_cfg[id].slot = *slot; + // Update next_tx_slot + next_tx_slot[id][pri] = get_next_tx_slot(id, pri, slot); - rx_irq_mask[id][HAL_TRANSQ_PRI_NORMAL] = construct_mask(0, slot->rx_num[HAL_TRANSQ_PRI_NORMAL]); - rx_irq_mask[id][HAL_TRANSQ_PRI_HIGH] = construct_mask( - TRANSQ_SLOT_NUM - slot->rx_num[HAL_TRANSQ_PRI_HIGH], - slot->rx_num[HAL_TRANSQ_PRI_HIGH]); - - tx_mask = construct_mask(0, slot->tx_num[HAL_TRANSQ_PRI_NORMAL]) | - construct_mask(TRANSQ_SLOT_NUM - slot->tx_num[HAL_TRANSQ_PRI_HIGH], slot->tx_num[HAL_TRANSQ_PRI_HIGH]); - - transq[id]->RMT_INTMASK = tx_mask; - transq[id]->LERR_INTMASK = tx_mask; - if (transq_cfg[id].tx_handler) { - transq[id]->LDONE_INTMASK = tx_mask; - } else { - transq[id]->LDONE_INTMASK = 0; + if (next_tx_slot[id][pri] == active_tx_slot[id][pri]) { + tx_slot_full[id][pri] = true; } + } - return HAL_TRANSQ_RET_OK; + int_unlock(lock); + + return ret; } -enum HAL_TRANSQ_RET_T hal_transq_open(enum HAL_TRANSQ_ID_T id, const struct HAL_TRANSQ_CFG_T *cfg) -{ - const struct HAL_TRANSQ_SLOT_NUM_T *slot; - uint32_t ctrl; - enum HAL_TRANSQ_RET_T ret; +enum HAL_TRANSQ_RET_T +hal_transq_update_num(enum HAL_TRANSQ_ID_T id, + const struct HAL_TRANSQ_SLOT_NUM_T *slot) { + uint32_t tx_mask; - if (id >= HAL_TRANSQ_ID_QTY) { - return HAL_TRANSQ_RET_BAD_ID; - } - if (cfg == NULL) { - return HAL_TRANSQ_RET_BAD_CFG; - } + if (id >= HAL_TRANSQ_ID_QTY) { + return HAL_TRANSQ_RET_BAD_ID; + } + if (slot == NULL) { + return HAL_TRANSQ_RET_BAD_SLOT; + } + if (slot->tx_num[HAL_TRANSQ_PRI_NORMAL] + slot->tx_num[HAL_TRANSQ_PRI_HIGH] > + TRANSQ_SLOT_NUM) { + return HAL_TRANSQ_RET_BAD_TX_NUM; + } + if (slot->rx_num[HAL_TRANSQ_PRI_NORMAL] + slot->rx_num[HAL_TRANSQ_PRI_HIGH] > + TRANSQ_SLOT_NUM) { + return HAL_TRANSQ_RET_BAD_RX_NUM; + } + + transq_cfg[id].slot = *slot; + + rx_irq_mask[id][HAL_TRANSQ_PRI_NORMAL] = + construct_mask(0, slot->rx_num[HAL_TRANSQ_PRI_NORMAL]); + rx_irq_mask[id][HAL_TRANSQ_PRI_HIGH] = + construct_mask(TRANSQ_SLOT_NUM - slot->rx_num[HAL_TRANSQ_PRI_HIGH], + slot->rx_num[HAL_TRANSQ_PRI_HIGH]); + + tx_mask = construct_mask(0, slot->tx_num[HAL_TRANSQ_PRI_NORMAL]) | + construct_mask(TRANSQ_SLOT_NUM - slot->tx_num[HAL_TRANSQ_PRI_HIGH], + slot->tx_num[HAL_TRANSQ_PRI_HIGH]); + + transq[id]->RMT_INTMASK = tx_mask; + transq[id]->LERR_INTMASK = tx_mask; + if (transq_cfg[id].tx_handler) { + transq[id]->LDONE_INTMASK = tx_mask; + } else { + transq[id]->LDONE_INTMASK = 0; + } + + return HAL_TRANSQ_RET_OK; +} + +enum HAL_TRANSQ_RET_T hal_transq_open(enum HAL_TRANSQ_ID_T id, + const struct HAL_TRANSQ_CFG_T *cfg) { + const struct HAL_TRANSQ_SLOT_NUM_T *slot; + uint32_t ctrl; + enum HAL_TRANSQ_RET_T ret; + + if (id >= HAL_TRANSQ_ID_QTY) { + return HAL_TRANSQ_RET_BAD_ID; + } + if (cfg == NULL) { + return HAL_TRANSQ_RET_BAD_CFG; + } #ifdef CHIP_BEST2000 - hal_cmu_clock_enable(HAL_CMU_MOD_P_TRANSQ_WF); - hal_cmu_reset_clear(HAL_CMU_MOD_P_TRANSQ_WF); + hal_cmu_clock_enable(HAL_CMU_MOD_P_TRANSQ_WF); + hal_cmu_reset_clear(HAL_CMU_MOD_P_TRANSQ_WF); #elif defined(CHIP_BEST2001) && !defined(CHIP_BEST2001_DSP) - //2001 dsp has enable transq clk at hal_cmu_dsp_clock_enable() - hal_cmu_clock_enable(HAL_CMU_MOD_P_TQWF); - hal_cmu_reset_clear(HAL_CMU_MOD_P_TQWF); - hal_cmu_clock_enable(HAL_CMU_MOD_P_TQA7); - hal_cmu_reset_clear(HAL_CMU_MOD_P_TQA7); + // 2001 dsp has enable transq clk at hal_cmu_dsp_clock_enable() + hal_cmu_clock_enable(HAL_CMU_MOD_P_TQWF); + hal_cmu_reset_clear(HAL_CMU_MOD_P_TQWF); + hal_cmu_clock_enable(HAL_CMU_MOD_P_TQA7); + hal_cmu_reset_clear(HAL_CMU_MOD_P_TQA7); #endif - transq_cfg[id] = *cfg; + transq_cfg[id] = *cfg; - slot = &cfg->slot; + slot = &cfg->slot; - ret = hal_transq_update_num(id, slot); - if (ret) { - return ret; - } + ret = hal_transq_update_num(id, slot); + if (ret) { + return ret; + } - next_tx_slot[id][HAL_TRANSQ_PRI_NORMAL] = slot->tx_num[HAL_TRANSQ_PRI_NORMAL] ? 0 : TRANSQ_SLOT_NUM; - active_tx_slot[id][HAL_TRANSQ_PRI_NORMAL] = TRANSQ_SLOT_NUM; - tx_slot_full[id][HAL_TRANSQ_PRI_NORMAL] = false; - next_rx_slot[id][HAL_TRANSQ_PRI_NORMAL] = slot->rx_num[HAL_TRANSQ_PRI_NORMAL] ? 0 : TRANSQ_SLOT_NUM; + next_tx_slot[id][HAL_TRANSQ_PRI_NORMAL] = + slot->tx_num[HAL_TRANSQ_PRI_NORMAL] ? 0 : TRANSQ_SLOT_NUM; + active_tx_slot[id][HAL_TRANSQ_PRI_NORMAL] = TRANSQ_SLOT_NUM; + tx_slot_full[id][HAL_TRANSQ_PRI_NORMAL] = false; + next_rx_slot[id][HAL_TRANSQ_PRI_NORMAL] = + slot->rx_num[HAL_TRANSQ_PRI_NORMAL] ? 0 : TRANSQ_SLOT_NUM; - next_tx_slot[id][HAL_TRANSQ_PRI_HIGH] = slot->tx_num[HAL_TRANSQ_PRI_HIGH] ? - (TRANSQ_SLOT_NUM - slot->tx_num[HAL_TRANSQ_PRI_HIGH]) : TRANSQ_SLOT_NUM; - active_tx_slot[id][HAL_TRANSQ_PRI_HIGH] = TRANSQ_SLOT_NUM; - tx_slot_full[id][HAL_TRANSQ_PRI_HIGH] = false; - next_rx_slot[id][HAL_TRANSQ_PRI_HIGH] = slot->rx_num[HAL_TRANSQ_PRI_HIGH] ? - (TRANSQ_SLOT_NUM - slot->rx_num[HAL_TRANSQ_PRI_HIGH]) : TRANSQ_SLOT_NUM; + next_tx_slot[id][HAL_TRANSQ_PRI_HIGH] = + slot->tx_num[HAL_TRANSQ_PRI_HIGH] + ? (TRANSQ_SLOT_NUM - slot->tx_num[HAL_TRANSQ_PRI_HIGH]) + : TRANSQ_SLOT_NUM; + active_tx_slot[id][HAL_TRANSQ_PRI_HIGH] = TRANSQ_SLOT_NUM; + tx_slot_full[id][HAL_TRANSQ_PRI_HIGH] = false; + next_rx_slot[id][HAL_TRANSQ_PRI_HIGH] = + slot->rx_num[HAL_TRANSQ_PRI_HIGH] + ? (TRANSQ_SLOT_NUM - slot->rx_num[HAL_TRANSQ_PRI_HIGH]) + : TRANSQ_SLOT_NUM; - transq[id]->LDONE_ISC.LDONE_INTCLR = ~0UL; - transq[id]->LERR_ISC.LERR_INTCLR = ~0UL; - transq[id]->RMT_ISC.RMT_INTCLR = ~0UL; + transq[id]->LDONE_ISC.LDONE_INTCLR = ~0UL; + transq[id]->LERR_ISC.LERR_INTCLR = ~0UL; + transq[id]->RMT_ISC.RMT_INTCLR = ~0UL; - ctrl = CTRL_REMOTE_IRQ_EN | CTRL_LOCAL_ERR_IRQ_EN; - if (cfg->tx_handler) { - ctrl |= CTRL_LOCAL_DONE_IRQ_EN; - } - transq[id]->CTRL = ctrl; + ctrl = CTRL_REMOTE_IRQ_EN | CTRL_LOCAL_ERR_IRQ_EN; + if (cfg->tx_handler) { + ctrl |= CTRL_LOCAL_DONE_IRQ_EN; + } + transq[id]->CTRL = ctrl; - if (cfg->rx_handler) { - NVIC_SetVector(remote_irq_num[id], (uint32_t)hal_transq_remote_irq_handler); - NVIC_SetPriority(remote_irq_num[id], IRQ_PRIORITY_NORMAL); - NVIC_ClearPendingIRQ(remote_irq_num[id]); - NVIC_EnableIRQ(remote_irq_num[id]); - } + if (cfg->rx_handler) { + NVIC_SetVector(remote_irq_num[id], (uint32_t)hal_transq_remote_irq_handler); + NVIC_SetPriority(remote_irq_num[id], IRQ_PRIORITY_NORMAL); + NVIC_ClearPendingIRQ(remote_irq_num[id]); + NVIC_EnableIRQ(remote_irq_num[id]); + } - NVIC_SetVector(local_irq_num[id], (uint32_t)hal_transq_local_irq_handler); - NVIC_SetPriority(local_irq_num[id], IRQ_PRIORITY_NORMAL); - NVIC_ClearPendingIRQ(local_irq_num[id]); - NVIC_EnableIRQ(local_irq_num[id]); + NVIC_SetVector(local_irq_num[id], (uint32_t)hal_transq_local_irq_handler); + NVIC_SetPriority(local_irq_num[id], IRQ_PRIORITY_NORMAL); + NVIC_ClearPendingIRQ(local_irq_num[id]); + NVIC_EnableIRQ(local_irq_num[id]); - return HAL_TRANSQ_RET_OK; + return HAL_TRANSQ_RET_OK; } -enum HAL_TRANSQ_RET_T hal_transq_close(enum HAL_TRANSQ_ID_T id) -{ - if (id >= HAL_TRANSQ_ID_QTY) { - return HAL_TRANSQ_RET_BAD_ID; - } +enum HAL_TRANSQ_RET_T hal_transq_close(enum HAL_TRANSQ_ID_T id) { + if (id >= HAL_TRANSQ_ID_QTY) { + return HAL_TRANSQ_RET_BAD_ID; + } - transq[id]->CTRL = 0; - NVIC_DisableIRQ(remote_irq_num[id]); - NVIC_DisableIRQ(local_irq_num[id]); + transq[id]->CTRL = 0; + NVIC_DisableIRQ(remote_irq_num[id]); + NVIC_DisableIRQ(local_irq_num[id]); - return HAL_TRANSQ_RET_OK; + return HAL_TRANSQ_RET_OK; } #endif // CHIP_HAS_TRANSQ diff --git a/platform/hal/hal_uart.c b/platform/hal/hal_uart.c index 1898ca4..04f3c39 100644 --- a/platform/hal/hal_uart.c +++ b/platform/hal/hal_uart.c @@ -15,9 +15,7 @@ ****************************************************************************/ #ifdef CHIP_HAS_UART -#include "plat_addr_map.h" #include "hal_uart.h" -#include "reg_uart.h" #include "cmsis_nvic.h" #include "hal_bootmode.h" #include "hal_cmu.h" @@ -25,24 +23,26 @@ #include "hal_iomux.h" #include "hal_timer.h" #include "hal_trace.h" +#include "plat_addr_map.h" +#include "reg_uart.h" #include "string.h" -#define UART_FLUSH_DELAY_DEFAULT 2 +#define UART_FLUSH_DELAY_DEFAULT 2 enum UART_RX_DMA_MODE_T { - UART_RX_DMA_MODE_NORMAL, - UART_RX_DMA_MODE_PINGPANG, - UART_RX_DMA_MODE_STREAM, - UART_RX_DMA_MODE_BUF_LIST, + UART_RX_DMA_MODE_NORMAL, + UART_RX_DMA_MODE_PINGPANG, + UART_RX_DMA_MODE_STREAM, + UART_RX_DMA_MODE_BUF_LIST, }; struct HAL_UART_HW_DESC_T { - struct UART_T *base; - IRQn_Type irq; - enum HAL_CMU_MOD_ID_T mod; - enum HAL_CMU_MOD_ID_T apb; - enum HAL_DMA_PERIPH_T rx_periph; - enum HAL_DMA_PERIPH_T tx_periph; + struct UART_T *base; + IRQn_Type irq; + enum HAL_CMU_MOD_ID_T mod; + enum HAL_CMU_MOD_ID_T apb; + enum HAL_DMA_PERIPH_T rx_periph; + enum HAL_DMA_PERIPH_T tx_periph; }; static const struct HAL_UART_HW_DESC_T uart[HAL_UART_ID_QTY] = { @@ -88,10 +88,10 @@ static const struct HAL_UART_HW_DESC_T uart[HAL_UART_ID_QTY] = { static bool init_done = false; -static HAL_UART_IRQ_HANDLER_T irq_handler[HAL_UART_ID_QTY] = { NULL }; +static HAL_UART_IRQ_HANDLER_T irq_handler[HAL_UART_ID_QTY] = {NULL}; -static HAL_UART_IRQ_RXDMA_HANDLER_T rxdma_handler[HAL_UART_ID_QTY] = { NULL }; -static HAL_UART_IRQ_TXDMA_HANDLER_T txdma_handler[HAL_UART_ID_QTY] = { NULL }; +static HAL_UART_IRQ_RXDMA_HANDLER_T rxdma_handler[HAL_UART_ID_QTY] = {NULL}; +static HAL_UART_IRQ_TXDMA_HANDLER_T txdma_handler[HAL_UART_ID_QTY] = {NULL}; static uint8_t recv_dma_chan[HAL_UART_ID_QTY]; static uint8_t send_dma_chan[HAL_UART_ID_QTY]; @@ -103,8 +103,9 @@ static union HAL_UART_IRQ_T recv_mask[HAL_UART_ID_QTY]; static enum UART_RX_DMA_MODE_T recv_dma_mode[HAL_UART_ID_QTY]; -static const char * const err_invalid_id = "Invalid UART ID: %d"; -static const char * const err_recv_dma_api = "%s: Set RT irq in hal_uart_dma_recv_mask... to avoid data lost"; +static const char *const err_invalid_id = "Invalid UART ID: %d"; +static const char *const err_recv_dma_api = + "%s: Set RT irq in hal_uart_dma_recv_mask... to avoid data lost"; static const struct HAL_UART_CFG_T default_cfg = { .parity = HAL_UART_PARITY_NONE, @@ -121,1168 +122,1159 @@ static const struct HAL_UART_CFG_T default_cfg = { static void hal_uart_irq_handler(void); -static void set_baud_rate(enum HAL_UART_ID_T id, uint32_t rate) -{ - uint32_t mod_clk; - uint32_t ibrd, fbrd; - uint32_t div; +static void set_baud_rate(enum HAL_UART_ID_T id, uint32_t rate) { + uint32_t mod_clk; + uint32_t ibrd, fbrd; + uint32_t div; - mod_clk = 0; + mod_clk = 0; #ifdef PERIPH_PLL_FREQ - if (PERIPH_PLL_FREQ / 2 > 2 * hal_cmu_get_crystal_freq()) { - // Init to OSC_X2 - mod_clk = 2 * hal_cmu_get_crystal_freq() / 16; - if (cfg->baud > mod_clk) { - mod_clk = PERIPH_PLL_FREQ / 2 / 16; + if (PERIPH_PLL_FREQ / 2 > 2 * hal_cmu_get_crystal_freq()) { + // Init to OSC_X2 + mod_clk = 2 * hal_cmu_get_crystal_freq() / 16; + if (cfg->baud > mod_clk) { + mod_clk = PERIPH_PLL_FREQ / 2 / 16; - if (id == HAL_UART_ID_0) { - hal_cmu_uart0_set_div(2); + if (id == HAL_UART_ID_0) { + hal_cmu_uart0_set_div(2); #if (CHIP_HAS_UART > 1) - } else if (id == HAL_UART_ID_1) { - hal_cmu_uart1_set_div(2); + } else if (id == HAL_UART_ID_1) { + hal_cmu_uart1_set_div(2); #endif #if (CHIP_HAS_UART > 2) - } else if (id == HAL_UART_ID_2) { - hal_cmu_uart2_set_div(2); + } else if (id == HAL_UART_ID_2) { + hal_cmu_uart2_set_div(2); #endif - } - } else { - mod_clk = 0; - } - } -#endif - if (mod_clk == 0) { - enum HAL_CMU_PERIPH_FREQ_T periph_freq; - - // Init to OSC - mod_clk = hal_cmu_get_crystal_freq() / 16; - if (rate > mod_clk) { - mod_clk *= 2; - periph_freq = HAL_CMU_PERIPH_FREQ_52M; - } else { - periph_freq = HAL_CMU_PERIPH_FREQ_26M; - } - - if (id == HAL_UART_ID_0) { - hal_cmu_uart0_set_freq(periph_freq); -#if (CHIP_HAS_UART > 1) - } else if (id == HAL_UART_ID_1) { - hal_cmu_uart1_set_freq(periph_freq); -#endif -#if (CHIP_HAS_UART > 2) - } else if (id == HAL_UART_ID_2) { - hal_cmu_uart2_set_freq(periph_freq); -#endif - } - } - - div = (mod_clk * 64 + rate / 2) / rate; - ibrd = div / 64; - fbrd = div % 64; - if (ibrd == 0 || ibrd >= 65535) { - ASSERT(false, "Invalid baud param: %d", rate); - } - - uart[id].base->UARTIBRD = ibrd; - uart[id].base->UARTFBRD = fbrd; - - return; -} - -int hal_uart_open(enum HAL_UART_ID_T id, const struct HAL_UART_CFG_T *cfg) -{ - uint32_t cr, lcr, dmacr; - int i; - - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - - if (!init_done) { - init_done = true; - for (i = HAL_UART_ID_0; i < HAL_UART_ID_QTY; i++) { - recv_dma_chan[i] = HAL_DMA_CHAN_NONE; - send_dma_chan[i] = HAL_DMA_CHAN_NONE; - } - } - - if (hal_uart_opened(id)) { - hal_uart_close(id); - } - - if (cfg == NULL) { - cfg = &default_cfg; - } - - hal_cmu_clock_enable(uart[id].mod); - hal_cmu_clock_enable(uart[id].apb); - hal_cmu_reset_clear(uart[id].mod); - hal_cmu_reset_clear(uart[id].apb); - - cr = lcr = 0; - - switch (cfg->parity) { - case HAL_UART_PARITY_NONE: - break; - case HAL_UART_PARITY_ODD: - lcr |= UARTLCR_H_PEN; - break; - case HAL_UART_PARITY_EVEN: - lcr |= UARTLCR_H_PEN - | UARTLCR_H_EPS; - break; - case HAL_UART_PARITY_FORCE1: - lcr |= UARTLCR_H_PEN - | UARTLCR_H_SPS; - break; - case HAL_UART_PARITY_FORCE0: - lcr |= UARTLCR_H_PEN - | UARTLCR_H_EPS - | UARTLCR_H_SPS; - break; - default: - ASSERT(false, "Invalid parity param: %d", cfg->parity); - break; - } - - if (cfg->stop == HAL_UART_STOP_BITS_2) { - lcr |= UARTLCR_H_STP2; - } else if (cfg->stop != HAL_UART_STOP_BITS_1) { - ASSERT(false, "Invalid stop bits param: %d", cfg->stop); - } - - switch (cfg->data) { - case HAL_UART_DATA_BITS_5: - lcr |= UARTLCR_H_WLEN_5; - break; - case HAL_UART_DATA_BITS_6: - lcr |= UARTLCR_H_WLEN_6; - break; - case HAL_UART_DATA_BITS_7: - lcr |= UARTLCR_H_WLEN_7; - break; - case HAL_UART_DATA_BITS_8: - lcr |= UARTLCR_H_WLEN_8; - break; - default: - ASSERT(false, "Invalid data bits param: %d", cfg->data); - break; - } - - switch (cfg->flow) { - case HAL_UART_FLOW_CONTROL_NONE: - break; - case HAL_UART_FLOW_CONTROL_RTS: - cr |= UARTCR_RTSEN; - break; - case HAL_UART_FLOW_CONTROL_CTS: - cr |= UARTCR_CTSEN; - break; - case HAL_UART_FLOW_CONTROL_RTSCTS: - cr |= UARTCR_RTSEN - | UARTCR_CTSEN; - break; - default: - ASSERT(false, "Invalid flow control param: %d", cfg->flow); - break; - } - - lcr |= UARTLCR_H_FEN | UARTLCR_H_DMA_RT_CNT(9); - cr |= UARTCR_UARTEN | UARTCR_TXE | UARTCR_RXE; - - dmacr = 0; - if (cfg->dma_rx) { - dmacr |= UARTDMACR_RXDMAE; - } - if (cfg->dma_tx) { - dmacr |= UARTDMACR_TXDMAE; - } - if (cfg->dma_rx_stop_on_err) { - dmacr |= UARTDMACR_DMAONERR; - } - - // Disable UART - uart[id].base->UARTCR &= ~UARTCR_UARTEN; - // Empty FIFO - uart[id].base->UARTLCR_H &= ~UARTLCR_H_FEN; - // Wait until UART becomes idle - while (((uart[id].base->UARTFR) & UARTFR_BUSY) != 0); - // Clear previous errors - uart[id].base->UARTECR = 1; - // Clear previous IRQs - uart[id].base->UARTIMSC = 0; - uart[id].base->UARTICR = ~0UL; - // Configure UART - set_baud_rate(id, cfg->baud); - uart[id].base->UARTLCR_H = lcr; - uart[id].base->UARTDMACR = dmacr; - uart[id].base->UARTIFLS = UARTIFLS_TXFIFO_LEVEL(cfg->tx_level) | - UARTIFLS_RXFIFO_LEVEL(cfg->rx_level); - uart[id].base->UARTCR = cr; - - if (uart[id].irq != INVALID_IRQn) { - NVIC_SetVector(uart[id].irq, (uint32_t)hal_uart_irq_handler); - // The priority should be the same as DMA's - NVIC_SetPriority(uart[id].irq, IRQ_PRIORITY_NORMAL); - NVIC_ClearPendingIRQ(uart[id].irq); - NVIC_EnableIRQ(uart[id].irq); - } - - return 0; -} - -int hal_uart_reopen(enum HAL_UART_ID_T id, const struct HAL_UART_CFG_T *cfg) -{ - uint32_t cr, dmacr; - int i; - - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - - if (!init_done) { - init_done = true; - for (i = HAL_UART_ID_0; i < HAL_UART_ID_QTY; i++) { - recv_dma_chan[i] = HAL_DMA_CHAN_NONE; - send_dma_chan[i] = HAL_DMA_CHAN_NONE; - } - } - - cr = 0; - switch (cfg->flow) { - case HAL_UART_FLOW_CONTROL_NONE: - break; - case HAL_UART_FLOW_CONTROL_RTS: - cr |= UARTCR_RTSEN; - break; - case HAL_UART_FLOW_CONTROL_CTS: - cr |= UARTCR_CTSEN; - break; - case HAL_UART_FLOW_CONTROL_RTSCTS: - cr |= UARTCR_RTSEN - | UARTCR_CTSEN; - break; - default: - ASSERT(false, "Invalid flow control param: %d", cfg->flow); - break; - } - - dmacr = 0; - if (cfg->dma_rx) { - dmacr |= UARTDMACR_RXDMAE; - } - if (cfg->dma_tx) { - dmacr |= UARTDMACR_TXDMAE; - } - if (cfg->dma_rx_stop_on_err) { - dmacr |= UARTDMACR_DMAONERR; - } - - // Configure UART - uart[id].base->UARTDMACR = dmacr; - uart[id].base->UARTCR = (uart[id].base->UARTCR & ~(UARTCR_RTSEN | UARTCR_CTSEN)) | cr; - - if (uart[id].irq != INVALID_IRQn) { - NVIC_SetVector(uart[id].irq, (uint32_t)hal_uart_irq_handler); - // The priority should be the same as DMA's - NVIC_SetPriority(uart[id].irq, IRQ_PRIORITY_NORMAL); - NVIC_ClearPendingIRQ(uart[id].irq); - NVIC_EnableIRQ(uart[id].irq); - } - - return 0; -} - -int hal_uart_close(enum HAL_UART_ID_T id) -{ - uint32_t lock; - - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - - if (uart[id].irq != INVALID_IRQn) { - NVIC_DisableIRQ(uart[id].irq); - } - - lock = int_lock(); - if (recv_dma_chan[id] != HAL_DMA_CHAN_NONE) { - hal_gpdma_cancel(recv_dma_chan[id]); - hal_gpdma_free_chan(recv_dma_chan[id]); - recv_dma_chan[id] = HAL_DMA_CHAN_NONE; - } - if (send_dma_chan[id] != HAL_DMA_CHAN_NONE) { - hal_gpdma_cancel(send_dma_chan[id]); - hal_gpdma_free_chan(send_dma_chan[id]); - send_dma_chan[id] = HAL_DMA_CHAN_NONE; - } - int_unlock(lock); - - // Disable UART - uart[id].base->UARTCR &= ~UARTCR_UARTEN; - // Empty FIFO - uart[id].base->UARTLCR_H &= ~UARTLCR_H_FEN; - - hal_cmu_reset_set(uart[id].apb); - hal_cmu_reset_set(uart[id].mod); - hal_cmu_clock_disable(uart[id].apb); - hal_cmu_clock_disable(uart[id].mod); - - return 0; -} - -int hal_uart_opened(enum HAL_UART_ID_T id) -{ - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - if (uart[id].apb < HAL_CMU_MOD_QTY && - hal_cmu_clock_get_status(uart[id].apb) != HAL_CMU_CLK_ENABLED) { - return 0; - } - if (uart[id].base->UARTCR & UARTCR_UARTEN) { - return 1; - } - return 0; -} - -int hal_uart_change_baud_rate(enum HAL_UART_ID_T id, uint32_t rate) -{ - union HAL_UART_FLAG_T flag; - - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - - if (!hal_uart_opened(id)) { - return 1; - } - - flag.reg = uart[id].base->UARTFR; - if (flag.BUSY) { - return 2; - } - - uart[id].base->UARTCR &= ~UARTCR_UARTEN; - - set_baud_rate(id, rate); - - uart[id].base->UARTLCR_H = uart[id].base->UARTLCR_H; - uart[id].base->UARTCR |= UARTCR_UARTEN; - - return 0; -} - -int hal_uart_pause(enum HAL_UART_ID_T id) -{ - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - if (hal_uart_opened(id)) { - uart[id].base->UARTCR &= ~(UARTCR_TXE | UARTCR_RXE); - return 0; - } - return 1; -} - -int hal_uart_continue(enum HAL_UART_ID_T id) -{ - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - if (hal_uart_opened(id)) { - uart[id].base->UARTCR |= (UARTCR_TXE | UARTCR_RXE); - return 0; - } - return 1; -} - -int hal_uart_readable(enum HAL_UART_ID_T id) -{ - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - return (uart[id].base->UARTFR & UARTFR_RXFE) == 0; -} - -int hal_uart_writable(enum HAL_UART_ID_T id) -{ - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - return (uart[id].base->UARTFR & UARTFR_TXFF) == 0; -} - -uint8_t hal_uart_getc(enum HAL_UART_ID_T id) -{ - uint32_t c; - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - ASSERT((uart[id].base->UARTDMACR & UARTDMACR_RXDMAE) == 0, "RX-DMA configured on UART %d", id); - c = uart[id].base->UARTDR; - return (c & 0xFF); -} - -int hal_uart_putc(enum HAL_UART_ID_T id, uint8_t c) -{ - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - ASSERT((uart[id].base->UARTDMACR & UARTDMACR_TXDMAE) == 0, "TX-DMA configured on UART %d", id); - uart[id].base->UARTDR = c; - return 0; -} - -uint8_t hal_uart_blocked_getc(enum HAL_UART_ID_T id) -{ - while (hal_uart_readable(id) == 0); - return hal_uart_getc(id); -} - -int hal_uart_blocked_putc(enum HAL_UART_ID_T id, uint8_t c) -{ - while (hal_uart_writable(id) == 0); - return hal_uart_putc(id, c); -} - -union HAL_UART_FLAG_T hal_uart_get_flag(enum HAL_UART_ID_T id) -{ - union HAL_UART_FLAG_T flag; - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - flag.reg = uart[id].base->UARTFR; - return flag; -} - -union HAL_UART_STATUS_T hal_uart_get_status(enum HAL_UART_ID_T id) -{ - union HAL_UART_STATUS_T status; - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - status.reg = uart[id].base->UARTRSR; - return status; -} - -void hal_uart_clear_status(enum HAL_UART_ID_T id) -{ - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - uart[id].base->UARTECR = 0; -} - -void hal_uart_break_set(enum HAL_UART_ID_T id) -{ - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - uart[id].base->UARTLCR_H |= UARTLCR_H_BRK; -} - -void hal_uart_break_clear(enum HAL_UART_ID_T id) -{ - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - uart[id].base->UARTLCR_H &= ~UARTLCR_H_BRK; -} - -void hal_uart_flush(enum HAL_UART_ID_T id, uint32_t ticks) -{ - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - - if (!hal_uart_opened(id)) { - return; - } - if ((uart[id].base->UARTLCR_H & UARTLCR_H_FEN) == 0) { - return; - } - - // Disable the UART - uart[id].base->UARTCR &= ~UARTCR_UARTEN; - // Wait for the end of transmission or reception of the current character - hal_sys_timer_delay((ticks > 0) ? ticks : UART_FLUSH_DELAY_DEFAULT); - - // Flush FIFO - uart[id].base->UARTLCR_H &= ~UARTLCR_H_FEN; - uart[id].base->UARTLCR_H |= UARTLCR_H_FEN; - - // Enable the UART - uart[id].base->UARTCR |= UARTCR_UARTEN; -} - -union HAL_UART_IRQ_T hal_uart_get_raw_irq(enum HAL_UART_ID_T id) -{ - union HAL_UART_IRQ_T irq; - - irq.reg = uart[id].base->UARTRIS; - - return irq; -} - -void hal_uart_clear_irq(enum HAL_UART_ID_T id, union HAL_UART_IRQ_T irq) -{ - uart[id].base->UARTICR = irq.reg; -} - -union HAL_UART_IRQ_T hal_uart_irq_get_mask(enum HAL_UART_ID_T id) -{ - union HAL_UART_IRQ_T mask; - - mask.reg = uart[id].base->UARTIMSC; - - return mask; -} - -union HAL_UART_IRQ_T hal_uart_irq_set_mask(enum HAL_UART_ID_T id, union HAL_UART_IRQ_T mask) -{ - union HAL_UART_IRQ_T old_mask; - - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - if (mask.RT) { - ASSERT(recv_dma_chan[id] == HAL_DMA_CHAN_NONE, err_recv_dma_api, __FUNCTION__); - } - old_mask.reg = uart[id].base->UARTIMSC; - uart[id].base->UARTIMSC = mask.reg; - - return old_mask; -} - -HAL_UART_IRQ_HANDLER_T hal_uart_irq_set_handler(enum HAL_UART_ID_T id, HAL_UART_IRQ_HANDLER_T handler) -{ - HAL_UART_IRQ_HANDLER_T old_handler; - - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - old_handler = irq_handler[id]; - irq_handler[id] = handler; - - return old_handler; -} - -static void dma_mode_uart_irq_handler(enum HAL_UART_ID_T id, union HAL_UART_IRQ_T status) -{ - uint32_t xfer = 0; - uint32_t lock; - - if (status.RT || status.FE || status.OE || status.PE || status.BE) { - if (recv_dma_mode[id] == UART_RX_DMA_MODE_NORMAL) { - // Restore the traditional RT behaviour - lock = int_lock(); - uart[id].base->UARTLCR_H &= ~UARTLCR_H_DMA_RT_EN; - int_unlock(lock); - } - - if (rxdma_handler[id]) { - if (recv_dma_chan[id] != HAL_DMA_CHAN_NONE) { - if (recv_dma_mode[id] == UART_RX_DMA_MODE_NORMAL) { - xfer = hal_uart_stop_dma_recv(id); - if (recv_dma_size[id] > xfer) { - xfer = recv_dma_size[id] - xfer; - } else { - xfer = 0; - } - } - } - rxdma_handler[id](xfer, 0, status); - } - } -} - -void hal_uart_irq_set_dma_handler(enum HAL_UART_ID_T id, HAL_UART_IRQ_RXDMA_HANDLER_T rxdma, HAL_UART_IRQ_TXDMA_HANDLER_T txdma) -{ - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - rxdma_handler[id] = rxdma; - txdma_handler[id] = txdma; - irq_handler[id] = dma_mode_uart_irq_handler; -} - -static void recv_dma_irq_handler(uint8_t chan, uint32_t remain_tsize, uint32_t error, struct HAL_DMA_DESC_T *lli) -{ - enum HAL_UART_ID_T id; - uint32_t xfer; - uint32_t lock; - union HAL_UART_IRQ_T status; - - lock = int_lock(); - for (id = HAL_UART_ID_0; id < HAL_UART_ID_QTY; id++) { - if (recv_dma_chan[id] == chan) { - if (recv_dma_mode[id] == UART_RX_DMA_MODE_NORMAL) { - recv_dma_chan[id] = HAL_DMA_CHAN_NONE; - } - break; - } - } - int_unlock(lock); - - if (id == HAL_UART_ID_QTY) { - return; - } - - if (recv_dma_mode[id] == UART_RX_DMA_MODE_NORMAL) { - // Get remain xfer size - xfer = hal_gpdma_get_sg_remain_size(chan); - - hal_gpdma_free_chan(chan); + } } else { - xfer = 0; - status.reg = 0; + mod_clk = 0; + } + } +#endif + if (mod_clk == 0) { + enum HAL_CMU_PERIPH_FREQ_T periph_freq; + + // Init to OSC + mod_clk = hal_cmu_get_crystal_freq() / 16; + if (rate > mod_clk) { + mod_clk *= 2; + periph_freq = HAL_CMU_PERIPH_FREQ_52M; + } else { + periph_freq = HAL_CMU_PERIPH_FREQ_26M; + } + + if (id == HAL_UART_ID_0) { + hal_cmu_uart0_set_freq(periph_freq); +#if (CHIP_HAS_UART > 1) + } else if (id == HAL_UART_ID_1) { + hal_cmu_uart1_set_freq(periph_freq); +#endif +#if (CHIP_HAS_UART > 2) + } else if (id == HAL_UART_ID_2) { + hal_cmu_uart2_set_freq(periph_freq); +#endif + } + } + + div = (mod_clk * 64 + rate / 2) / rate; + ibrd = div / 64; + fbrd = div % 64; + if (ibrd == 0 || ibrd >= 65535) { + ASSERT(false, "Invalid baud param: %d", rate); + } + + uart[id].base->UARTIBRD = ibrd; + uart[id].base->UARTFBRD = fbrd; + + return; +} + +int hal_uart_open(enum HAL_UART_ID_T id, const struct HAL_UART_CFG_T *cfg) { + uint32_t cr, lcr, dmacr; + int i; + + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + + if (!init_done) { + init_done = true; + for (i = HAL_UART_ID_0; i < HAL_UART_ID_QTY; i++) { + recv_dma_chan[i] = HAL_DMA_CHAN_NONE; + send_dma_chan[i] = HAL_DMA_CHAN_NONE; + } + } + + if (hal_uart_opened(id)) { + hal_uart_close(id); + } + + if (cfg == NULL) { + cfg = &default_cfg; + } + + hal_cmu_clock_enable(uart[id].mod); + hal_cmu_clock_enable(uart[id].apb); + hal_cmu_reset_clear(uart[id].mod); + hal_cmu_reset_clear(uart[id].apb); + + cr = lcr = 0; + + switch (cfg->parity) { + case HAL_UART_PARITY_NONE: + break; + case HAL_UART_PARITY_ODD: + lcr |= UARTLCR_H_PEN; + break; + case HAL_UART_PARITY_EVEN: + lcr |= UARTLCR_H_PEN | UARTLCR_H_EPS; + break; + case HAL_UART_PARITY_FORCE1: + lcr |= UARTLCR_H_PEN | UARTLCR_H_SPS; + break; + case HAL_UART_PARITY_FORCE0: + lcr |= UARTLCR_H_PEN | UARTLCR_H_EPS | UARTLCR_H_SPS; + break; + default: + ASSERT(false, "Invalid parity param: %d", cfg->parity); + break; + } + + if (cfg->stop == HAL_UART_STOP_BITS_2) { + lcr |= UARTLCR_H_STP2; + } else if (cfg->stop != HAL_UART_STOP_BITS_1) { + ASSERT(false, "Invalid stop bits param: %d", cfg->stop); + } + + switch (cfg->data) { + case HAL_UART_DATA_BITS_5: + lcr |= UARTLCR_H_WLEN_5; + break; + case HAL_UART_DATA_BITS_6: + lcr |= UARTLCR_H_WLEN_6; + break; + case HAL_UART_DATA_BITS_7: + lcr |= UARTLCR_H_WLEN_7; + break; + case HAL_UART_DATA_BITS_8: + lcr |= UARTLCR_H_WLEN_8; + break; + default: + ASSERT(false, "Invalid data bits param: %d", cfg->data); + break; + } + + switch (cfg->flow) { + case HAL_UART_FLOW_CONTROL_NONE: + break; + case HAL_UART_FLOW_CONTROL_RTS: + cr |= UARTCR_RTSEN; + break; + case HAL_UART_FLOW_CONTROL_CTS: + cr |= UARTCR_CTSEN; + break; + case HAL_UART_FLOW_CONTROL_RTSCTS: + cr |= UARTCR_RTSEN | UARTCR_CTSEN; + break; + default: + ASSERT(false, "Invalid flow control param: %d", cfg->flow); + break; + } + + lcr |= UARTLCR_H_FEN | UARTLCR_H_DMA_RT_CNT(9); + cr |= UARTCR_UARTEN | UARTCR_TXE | UARTCR_RXE; + + dmacr = 0; + if (cfg->dma_rx) { + dmacr |= UARTDMACR_RXDMAE; + } + if (cfg->dma_tx) { + dmacr |= UARTDMACR_TXDMAE; + } + if (cfg->dma_rx_stop_on_err) { + dmacr |= UARTDMACR_DMAONERR; + } + + // Disable UART + uart[id].base->UARTCR &= ~UARTCR_UARTEN; + // Empty FIFO + uart[id].base->UARTLCR_H &= ~UARTLCR_H_FEN; + // Wait until UART becomes idle + while (((uart[id].base->UARTFR) & UARTFR_BUSY) != 0) + ; + // Clear previous errors + uart[id].base->UARTECR = 1; + // Clear previous IRQs + uart[id].base->UARTIMSC = 0; + uart[id].base->UARTICR = ~0UL; + // Configure UART + set_baud_rate(id, cfg->baud); + uart[id].base->UARTLCR_H = lcr; + uart[id].base->UARTDMACR = dmacr; + uart[id].base->UARTIFLS = UARTIFLS_TXFIFO_LEVEL(cfg->tx_level) | + UARTIFLS_RXFIFO_LEVEL(cfg->rx_level); + uart[id].base->UARTCR = cr; + + if (uart[id].irq != INVALID_IRQn) { + NVIC_SetVector(uart[id].irq, (uint32_t)hal_uart_irq_handler); + // The priority should be the same as DMA's + NVIC_SetPriority(uart[id].irq, IRQ_PRIORITY_NORMAL); + NVIC_ClearPendingIRQ(uart[id].irq); + NVIC_EnableIRQ(uart[id].irq); + } + + return 0; +} + +int hal_uart_reopen(enum HAL_UART_ID_T id, const struct HAL_UART_CFG_T *cfg) { + uint32_t cr, dmacr; + int i; + + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + + if (!init_done) { + init_done = true; + for (i = HAL_UART_ID_0; i < HAL_UART_ID_QTY; i++) { + recv_dma_chan[i] = HAL_DMA_CHAN_NONE; + send_dma_chan[i] = HAL_DMA_CHAN_NONE; + } + } + + cr = 0; + switch (cfg->flow) { + case HAL_UART_FLOW_CONTROL_NONE: + break; + case HAL_UART_FLOW_CONTROL_RTS: + cr |= UARTCR_RTSEN; + break; + case HAL_UART_FLOW_CONTROL_CTS: + cr |= UARTCR_CTSEN; + break; + case HAL_UART_FLOW_CONTROL_RTSCTS: + cr |= UARTCR_RTSEN | UARTCR_CTSEN; + break; + default: + ASSERT(false, "Invalid flow control param: %d", cfg->flow); + break; + } + + dmacr = 0; + if (cfg->dma_rx) { + dmacr |= UARTDMACR_RXDMAE; + } + if (cfg->dma_tx) { + dmacr |= UARTDMACR_TXDMAE; + } + if (cfg->dma_rx_stop_on_err) { + dmacr |= UARTDMACR_DMAONERR; + } + + // Configure UART + uart[id].base->UARTDMACR = dmacr; + uart[id].base->UARTCR = + (uart[id].base->UARTCR & ~(UARTCR_RTSEN | UARTCR_CTSEN)) | cr; + + if (uart[id].irq != INVALID_IRQn) { + NVIC_SetVector(uart[id].irq, (uint32_t)hal_uart_irq_handler); + // The priority should be the same as DMA's + NVIC_SetPriority(uart[id].irq, IRQ_PRIORITY_NORMAL); + NVIC_ClearPendingIRQ(uart[id].irq); + NVIC_EnableIRQ(uart[id].irq); + } + + return 0; +} + +int hal_uart_close(enum HAL_UART_ID_T id) { + uint32_t lock; + + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + + if (uart[id].irq != INVALID_IRQn) { + NVIC_DisableIRQ(uart[id].irq); + } + + lock = int_lock(); + if (recv_dma_chan[id] != HAL_DMA_CHAN_NONE) { + hal_gpdma_cancel(recv_dma_chan[id]); + hal_gpdma_free_chan(recv_dma_chan[id]); + recv_dma_chan[id] = HAL_DMA_CHAN_NONE; + } + if (send_dma_chan[id] != HAL_DMA_CHAN_NONE) { + hal_gpdma_cancel(send_dma_chan[id]); + hal_gpdma_free_chan(send_dma_chan[id]); + send_dma_chan[id] = HAL_DMA_CHAN_NONE; + } + int_unlock(lock); + + // Disable UART + uart[id].base->UARTCR &= ~UARTCR_UARTEN; + // Empty FIFO + uart[id].base->UARTLCR_H &= ~UARTLCR_H_FEN; + + hal_cmu_reset_set(uart[id].apb); + hal_cmu_reset_set(uart[id].mod); + hal_cmu_clock_disable(uart[id].apb); + hal_cmu_clock_disable(uart[id].mod); + + return 0; +} + +int hal_uart_opened(enum HAL_UART_ID_T id) { + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + if (uart[id].apb < HAL_CMU_MOD_QTY && + hal_cmu_clock_get_status(uart[id].apb) != HAL_CMU_CLK_ENABLED) { + return 0; + } + if (uart[id].base->UARTCR & UARTCR_UARTEN) { + return 1; + } + return 0; +} + +int hal_uart_change_baud_rate(enum HAL_UART_ID_T id, uint32_t rate) { + union HAL_UART_FLAG_T flag; + + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + + if (!hal_uart_opened(id)) { + return 1; + } + + flag.reg = uart[id].base->UARTFR; + if (flag.BUSY) { + return 2; + } + + uart[id].base->UARTCR &= ~UARTCR_UARTEN; + + set_baud_rate(id, rate); + + uart[id].base->UARTLCR_H = uart[id].base->UARTLCR_H; + uart[id].base->UARTCR |= UARTCR_UARTEN; + + return 0; +} + +int hal_uart_pause(enum HAL_UART_ID_T id) { + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + if (hal_uart_opened(id)) { + uart[id].base->UARTCR &= ~(UARTCR_TXE | UARTCR_RXE); + return 0; + } + return 1; +} + +int hal_uart_continue(enum HAL_UART_ID_T id) { + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + if (hal_uart_opened(id)) { + uart[id].base->UARTCR |= (UARTCR_TXE | UARTCR_RXE); + return 0; + } + return 1; +} + +int hal_uart_readable(enum HAL_UART_ID_T id) { + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + return (uart[id].base->UARTFR & UARTFR_RXFE) == 0; +} + +int hal_uart_writable(enum HAL_UART_ID_T id) { + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + return (uart[id].base->UARTFR & UARTFR_TXFF) == 0; +} + +uint8_t hal_uart_getc(enum HAL_UART_ID_T id) { + uint32_t c; + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + ASSERT((uart[id].base->UARTDMACR & UARTDMACR_RXDMAE) == 0, + "RX-DMA configured on UART %d", id); + c = uart[id].base->UARTDR; + return (c & 0xFF); +} + +int hal_uart_putc(enum HAL_UART_ID_T id, uint8_t c) { + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + ASSERT((uart[id].base->UARTDMACR & UARTDMACR_TXDMAE) == 0, + "TX-DMA configured on UART %d", id); + uart[id].base->UARTDR = c; + return 0; +} + +uint8_t hal_uart_blocked_getc(enum HAL_UART_ID_T id) { + while (hal_uart_readable(id) == 0) + ; + return hal_uart_getc(id); +} + +int hal_uart_blocked_putc(enum HAL_UART_ID_T id, uint8_t c) { + while (hal_uart_writable(id) == 0) + ; + return hal_uart_putc(id, c); +} + +union HAL_UART_FLAG_T hal_uart_get_flag(enum HAL_UART_ID_T id) { + union HAL_UART_FLAG_T flag; + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + flag.reg = uart[id].base->UARTFR; + return flag; +} + +union HAL_UART_STATUS_T hal_uart_get_status(enum HAL_UART_ID_T id) { + union HAL_UART_STATUS_T status; + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + status.reg = uart[id].base->UARTRSR; + return status; +} + +void hal_uart_clear_status(enum HAL_UART_ID_T id) { + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + uart[id].base->UARTECR = 0; +} + +void hal_uart_break_set(enum HAL_UART_ID_T id) { + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + uart[id].base->UARTLCR_H |= UARTLCR_H_BRK; +} + +void hal_uart_break_clear(enum HAL_UART_ID_T id) { + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + uart[id].base->UARTLCR_H &= ~UARTLCR_H_BRK; +} + +void hal_uart_flush(enum HAL_UART_ID_T id, uint32_t ticks) { + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + + if (!hal_uart_opened(id)) { + return; + } + if ((uart[id].base->UARTLCR_H & UARTLCR_H_FEN) == 0) { + return; + } + + // Disable the UART + uart[id].base->UARTCR &= ~UARTCR_UARTEN; + // Wait for the end of transmission or reception of the current character + hal_sys_timer_delay((ticks > 0) ? ticks : UART_FLUSH_DELAY_DEFAULT); + + // Flush FIFO + uart[id].base->UARTLCR_H &= ~UARTLCR_H_FEN; + uart[id].base->UARTLCR_H |= UARTLCR_H_FEN; + + // Enable the UART + uart[id].base->UARTCR |= UARTCR_UARTEN; +} + +union HAL_UART_IRQ_T hal_uart_get_raw_irq(enum HAL_UART_ID_T id) { + union HAL_UART_IRQ_T irq; + + irq.reg = uart[id].base->UARTRIS; + + return irq; +} + +void hal_uart_clear_irq(enum HAL_UART_ID_T id, union HAL_UART_IRQ_T irq) { + uart[id].base->UARTICR = irq.reg; +} + +union HAL_UART_IRQ_T hal_uart_irq_get_mask(enum HAL_UART_ID_T id) { + union HAL_UART_IRQ_T mask; + + mask.reg = uart[id].base->UARTIMSC; + + return mask; +} + +union HAL_UART_IRQ_T hal_uart_irq_set_mask(enum HAL_UART_ID_T id, + union HAL_UART_IRQ_T mask) { + union HAL_UART_IRQ_T old_mask; + + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + if (mask.RT) { + ASSERT(recv_dma_chan[id] == HAL_DMA_CHAN_NONE, err_recv_dma_api, + __FUNCTION__); + } + old_mask.reg = uart[id].base->UARTIMSC; + uart[id].base->UARTIMSC = mask.reg; + + return old_mask; +} + +HAL_UART_IRQ_HANDLER_T +hal_uart_irq_set_handler(enum HAL_UART_ID_T id, + HAL_UART_IRQ_HANDLER_T handler) { + HAL_UART_IRQ_HANDLER_T old_handler; + + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + old_handler = irq_handler[id]; + irq_handler[id] = handler; + + return old_handler; +} + +static void dma_mode_uart_irq_handler(enum HAL_UART_ID_T id, + union HAL_UART_IRQ_T status) { + uint32_t xfer = 0; + uint32_t lock; + + if (status.RT || status.FE || status.OE || status.PE || status.BE) { + if (recv_dma_mode[id] == UART_RX_DMA_MODE_NORMAL) { + // Restore the traditional RT behaviour + lock = int_lock(); + uart[id].base->UARTLCR_H &= ~UARTLCR_H_DMA_RT_EN; + int_unlock(lock); } if (rxdma_handler[id]) { + if (recv_dma_chan[id] != HAL_DMA_CHAN_NONE) { if (recv_dma_mode[id] == UART_RX_DMA_MODE_NORMAL) { - // Already get xfer size - if (recv_dma_size[id] > xfer) { - xfer = recv_dma_size[id] - xfer; - } else { - xfer = 0; - } - } else if (recv_dma_mode[id] == UART_RX_DMA_MODE_PINGPANG) { - xfer = recv_dma_size[id] / 2; + xfer = hal_uart_stop_dma_recv(id); + if (recv_dma_size[id] > xfer) { + xfer = recv_dma_size[id] - xfer; + } else { + xfer = 0; + } } - rxdma_handler[id](xfer, error, status); + } + rxdma_handler[id](xfer, 0, status); } + } } -static void recv_dma_start_callback(uint8_t chan) -{ - enum HAL_UART_ID_T id; - - for (id = HAL_UART_ID_0; id < HAL_UART_ID_QTY; id++) { - if (recv_dma_chan[id] == chan) { - break; - } - } - - if (id == HAL_UART_ID_QTY) { - return; - } - - uart[id].base->UARTIMSC = recv_mask[id].reg; +void hal_uart_irq_set_dma_handler(enum HAL_UART_ID_T id, + HAL_UART_IRQ_RXDMA_HANDLER_T rxdma, + HAL_UART_IRQ_TXDMA_HANDLER_T txdma) { + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + rxdma_handler[id] = rxdma; + txdma_handler[id] = txdma; + irq_handler[id] = dma_mode_uart_irq_handler; } -static int fill_buf_list_dma_desc(struct HAL_DMA_DESC_T *desc, uint32_t cnt, struct HAL_DMA_CH_CFG_T *cfg, - const struct HAL_UART_BUF_T *ubuf, uint32_t ucnt, uint32_t step) -{ - enum HAL_DMA_RET_T ret; - struct HAL_DMA_DESC_T *last_desc; - int tc_irq; - int i; - int u; - uint32_t remain; - uint32_t dlen; +static void recv_dma_irq_handler(uint8_t chan, uint32_t remain_tsize, + uint32_t error, struct HAL_DMA_DESC_T *lli) { + enum HAL_UART_ID_T id; + uint32_t xfer; + uint32_t lock; + union HAL_UART_IRQ_T status; - last_desc = NULL; - - u = 0; - remain = ubuf[0].len; - - for (i = 0, u = 0; i < cnt - 1; i++) { - if (ubuf[u].loop_hdr && last_desc == NULL) { - last_desc = &desc[i]; - } - if (remain <= step) { - dlen = remain; - tc_irq = ubuf[u].irq; - } else { - dlen = step; - tc_irq = 0; - } - cfg->src_tsize = dlen; - ret = hal_gpdma_init_desc(&desc[i], cfg, &desc[i + 1], tc_irq); - if (ret != HAL_DMA_OK) { - return 1; - } - remain -= dlen; - if (remain) { - cfg->dst += dlen; - } else { - u++; - if (u >= ucnt) { - return 2; - } - cfg->dst = (uint32_t)ubuf[u].buf; - remain = ubuf[u].len; - } - } - - cfg->src_tsize = remain; - ret = hal_gpdma_init_desc(&desc[i], cfg, last_desc, ubuf[u].irq); - if (ret != HAL_DMA_OK) { - return 1; - } - - return 0; -} - -static int fill_dma_desc(struct HAL_DMA_DESC_T *desc, uint32_t cnt, struct HAL_DMA_CH_CFG_T *cfg, - uint32_t len, enum UART_RX_DMA_MODE_T mode, uint32_t step) -{ - enum HAL_DMA_RET_T ret; - struct HAL_DMA_DESC_T *last_desc; - int tc_irq; - int i; - - for (i = 0; i < cnt - 1; i++) { - cfg->src_tsize = step; - tc_irq = 0; - if (mode == UART_RX_DMA_MODE_PINGPANG) { - tc_irq = (i == cnt / 2 - 1) ? 1 : 0; - } else if (mode == UART_RX_DMA_MODE_STREAM) { - tc_irq = 1; - } - ret = hal_gpdma_init_desc(&desc[i], cfg, &desc[i + 1], tc_irq); - if (ret != HAL_DMA_OK) { - return 1; - } - cfg->dst += step; - } - - cfg->src_tsize = len - (step * i); - last_desc = NULL; - if (mode == UART_RX_DMA_MODE_PINGPANG || mode == UART_RX_DMA_MODE_STREAM) { - last_desc = &desc[0]; - } - ret = hal_gpdma_init_desc(&desc[i], cfg, last_desc, 1); - if (ret != HAL_DMA_OK) { - return 1; - } - - return 0; -} - -static int start_recv_dma_with_mask(enum HAL_UART_ID_T id, const struct HAL_UART_BUF_T *ubuf, uint32_t ucnt, - struct HAL_DMA_DESC_T *desc, uint32_t *desc_cnt, - const union HAL_UART_IRQ_T *mask, - enum UART_RX_DMA_MODE_T mode, uint32_t step) -{ - uint8_t *buf; - uint32_t len; - struct HAL_DMA_CH_CFG_T dma_cfg; - enum HAL_DMA_RET_T ret; - uint32_t lock; - uint32_t cnt; - uint32_t i; - enum HAL_DMA_PERIPH_T periph; - - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - ASSERT(uart[id].irq != INVALID_IRQn, "DMA not supported on UART %d", id); - ASSERT((uart[id].base->UARTDMACR & UARTDMACR_RXDMAE), "DMA not configured on UART %d", id); - - if (ucnt == 0) { - return -21; - } - if (step > HAL_UART_DMA_TRANSFER_STEP || step == 0) { - return -22; - } - - buf = ubuf[0].buf; - len = ubuf[0].len; - - if (buf == NULL) { - return -23; - } - if (len == 0) { - return -24; - } - - if (0) { - } else if (mode == UART_RX_DMA_MODE_NORMAL) { - cnt = (len + step - 1) / step; - } else if (mode == UART_RX_DMA_MODE_PINGPANG) { - cnt = ((len / 2 + step - 1) / step) * 2; - step = len / cnt; - if (len % cnt != 0) { - return -11; - } - if (step == 0) { - return -12; - } - } else if (mode == UART_RX_DMA_MODE_STREAM) { - cnt = (len + step - 1) / step; - if (cnt == 1) { - // cnt should >= 2 - cnt++; - } - step = (len + cnt - 1) / cnt; - if (step == 0) { - return -13; - } - } else if (mode == UART_RX_DMA_MODE_BUF_LIST) { - cnt = 0; - for (i = 0; i < ucnt; i++) { - if (ubuf->buf == NULL) { - return -14; - } - if (ubuf->len == 0) { - return -15; - } - cnt += (ubuf->len + step - 1) / step; - } - } else { - return -10; - } - - // Return the required DMA descriptor count - if (desc == NULL && desc_cnt) { - *desc_cnt = (cnt == 1) ? 0 : cnt; - return 0; - } - - if (cnt > 1) { - if (desc == NULL || desc_cnt == NULL) { - return -1; - } - if (*desc_cnt < cnt) { - return -2; - } - } - if (desc_cnt) { - *desc_cnt = (cnt == 1) ? 0 : cnt; - } - - periph = uart[id].rx_periph; - - lock = int_lock(); - if (recv_dma_chan[id] != HAL_DMA_CHAN_NONE) { - int_unlock(lock); - return 1; - } - recv_dma_chan[id] = hal_gpdma_get_chan(periph, HAL_DMA_HIGH_PRIO); - if (recv_dma_chan[id] == HAL_DMA_CHAN_NONE) { - int_unlock(lock); - return 2; - } - int_unlock(lock); - - recv_dma_mode[id] = mode; - recv_dma_size[id] = len; - - memset(&dma_cfg, 0, sizeof(dma_cfg)); - dma_cfg.ch = recv_dma_chan[id]; - dma_cfg.dst = (uint32_t)buf; - dma_cfg.dst_bsize = HAL_DMA_BSIZE_32; - dma_cfg.dst_periph = 0; // useless - dma_cfg.dst_width = HAL_DMA_WIDTH_BYTE; - dma_cfg.handler = recv_dma_irq_handler; - dma_cfg.src = 0; // useless - dma_cfg.src_bsize = HAL_DMA_BSIZE_8; - dma_cfg.src_periph = periph; - dma_cfg.src_tsize = len; - dma_cfg.src_width = HAL_DMA_WIDTH_BYTE; - dma_cfg.type = HAL_DMA_FLOW_P2M_DMA; - dma_cfg.try_burst = 0; - - if (mask) { - recv_mask[id] = *mask; - dma_cfg.start_cb = recv_dma_start_callback; - } else { - union HAL_UART_IRQ_T irq_mask; - - irq_mask.reg = uart[id].base->UARTIMSC; - ASSERT(irq_mask.RT == 0, err_recv_dma_api, __FUNCTION__); - } - - // Activate DMA RT behaviour - lock = int_lock(); - uart[id].base->UARTLCR_H |= UARTLCR_H_DMA_RT_EN; - int_unlock(lock); - - if (cnt == 1) { - ret = hal_gpdma_start(&dma_cfg); - } else { - if (mode == UART_RX_DMA_MODE_BUF_LIST) { - ret = fill_buf_list_dma_desc(desc, cnt, &dma_cfg, ubuf, ucnt, step); - } else { - ret = fill_dma_desc(desc, cnt, &dma_cfg, len, mode, step); - } - if (ret) { - goto _err_exit; - } - ret = hal_gpdma_sg_start(desc, &dma_cfg); - } - - if (ret != HAL_DMA_OK) { -_err_exit: - // Restore the traditional RT behaviour - lock = int_lock(); - uart[id].base->UARTLCR_H &= ~UARTLCR_H_DMA_RT_EN; - int_unlock(lock); - hal_gpdma_free_chan(recv_dma_chan[id]); + lock = int_lock(); + for (id = HAL_UART_ID_0; id < HAL_UART_ID_QTY; id++) { + if (recv_dma_chan[id] == chan) { + if (recv_dma_mode[id] == UART_RX_DMA_MODE_NORMAL) { recv_dma_chan[id] = HAL_DMA_CHAN_NONE; - return 3; + } + break; } + } + int_unlock(lock); + if (id == HAL_UART_ID_QTY) { + return; + } + + if (recv_dma_mode[id] == UART_RX_DMA_MODE_NORMAL) { + // Get remain xfer size + xfer = hal_gpdma_get_sg_remain_size(chan); + + hal_gpdma_free_chan(chan); + } else { + xfer = 0; + status.reg = 0; + } + + if (rxdma_handler[id]) { + if (recv_dma_mode[id] == UART_RX_DMA_MODE_NORMAL) { + // Already get xfer size + if (recv_dma_size[id] > xfer) { + xfer = recv_dma_size[id] - xfer; + } else { + xfer = 0; + } + } else if (recv_dma_mode[id] == UART_RX_DMA_MODE_PINGPANG) { + xfer = recv_dma_size[id] / 2; + } + rxdma_handler[id](xfer, error, status); + } +} + +static void recv_dma_start_callback(uint8_t chan) { + enum HAL_UART_ID_T id; + + for (id = HAL_UART_ID_0; id < HAL_UART_ID_QTY; id++) { + if (recv_dma_chan[id] == chan) { + break; + } + } + + if (id == HAL_UART_ID_QTY) { + return; + } + + uart[id].base->UARTIMSC = recv_mask[id].reg; +} + +static int fill_buf_list_dma_desc(struct HAL_DMA_DESC_T *desc, uint32_t cnt, + struct HAL_DMA_CH_CFG_T *cfg, + const struct HAL_UART_BUF_T *ubuf, + uint32_t ucnt, uint32_t step) { + enum HAL_DMA_RET_T ret; + struct HAL_DMA_DESC_T *last_desc; + int tc_irq; + int i; + int u; + uint32_t remain; + uint32_t dlen; + + last_desc = NULL; + + u = 0; + remain = ubuf[0].len; + + for (i = 0, u = 0; i < cnt - 1; i++) { + if (ubuf[u].loop_hdr && last_desc == NULL) { + last_desc = &desc[i]; + } + if (remain <= step) { + dlen = remain; + tc_irq = ubuf[u].irq; + } else { + dlen = step; + tc_irq = 0; + } + cfg->src_tsize = dlen; + ret = hal_gpdma_init_desc(&desc[i], cfg, &desc[i + 1], tc_irq); + if (ret != HAL_DMA_OK) { + return 1; + } + remain -= dlen; + if (remain) { + cfg->dst += dlen; + } else { + u++; + if (u >= ucnt) { + return 2; + } + cfg->dst = (uint32_t)ubuf[u].buf; + remain = ubuf[u].len; + } + } + + cfg->src_tsize = remain; + ret = hal_gpdma_init_desc(&desc[i], cfg, last_desc, ubuf[u].irq); + if (ret != HAL_DMA_OK) { + return 1; + } + + return 0; +} + +static int fill_dma_desc(struct HAL_DMA_DESC_T *desc, uint32_t cnt, + struct HAL_DMA_CH_CFG_T *cfg, uint32_t len, + enum UART_RX_DMA_MODE_T mode, uint32_t step) { + enum HAL_DMA_RET_T ret; + struct HAL_DMA_DESC_T *last_desc; + int tc_irq; + int i; + + for (i = 0; i < cnt - 1; i++) { + cfg->src_tsize = step; + tc_irq = 0; + if (mode == UART_RX_DMA_MODE_PINGPANG) { + tc_irq = (i == cnt / 2 - 1) ? 1 : 0; + } else if (mode == UART_RX_DMA_MODE_STREAM) { + tc_irq = 1; + } + ret = hal_gpdma_init_desc(&desc[i], cfg, &desc[i + 1], tc_irq); + if (ret != HAL_DMA_OK) { + return 1; + } + cfg->dst += step; + } + + cfg->src_tsize = len - (step * i); + last_desc = NULL; + if (mode == UART_RX_DMA_MODE_PINGPANG || mode == UART_RX_DMA_MODE_STREAM) { + last_desc = &desc[0]; + } + ret = hal_gpdma_init_desc(&desc[i], cfg, last_desc, 1); + if (ret != HAL_DMA_OK) { + return 1; + } + + return 0; +} + +static int start_recv_dma_with_mask(enum HAL_UART_ID_T id, + const struct HAL_UART_BUF_T *ubuf, + uint32_t ucnt, struct HAL_DMA_DESC_T *desc, + uint32_t *desc_cnt, + const union HAL_UART_IRQ_T *mask, + enum UART_RX_DMA_MODE_T mode, + uint32_t step) { + uint8_t *buf; + uint32_t len; + struct HAL_DMA_CH_CFG_T dma_cfg; + enum HAL_DMA_RET_T ret; + uint32_t lock; + uint32_t cnt; + uint32_t i; + enum HAL_DMA_PERIPH_T periph; + + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + ASSERT(uart[id].irq != INVALID_IRQn, "DMA not supported on UART %d", id); + ASSERT((uart[id].base->UARTDMACR & UARTDMACR_RXDMAE), + "DMA not configured on UART %d", id); + + if (ucnt == 0) { + return -21; + } + if (step > HAL_UART_DMA_TRANSFER_STEP || step == 0) { + return -22; + } + + buf = ubuf[0].buf; + len = ubuf[0].len; + + if (buf == NULL) { + return -23; + } + if (len == 0) { + return -24; + } + + if (0) { + } else if (mode == UART_RX_DMA_MODE_NORMAL) { + cnt = (len + step - 1) / step; + } else if (mode == UART_RX_DMA_MODE_PINGPANG) { + cnt = ((len / 2 + step - 1) / step) * 2; + step = len / cnt; + if (len % cnt != 0) { + return -11; + } + if (step == 0) { + return -12; + } + } else if (mode == UART_RX_DMA_MODE_STREAM) { + cnt = (len + step - 1) / step; + if (cnt == 1) { + // cnt should >= 2 + cnt++; + } + step = (len + cnt - 1) / cnt; + if (step == 0) { + return -13; + } + } else if (mode == UART_RX_DMA_MODE_BUF_LIST) { + cnt = 0; + for (i = 0; i < ucnt; i++) { + if (ubuf->buf == NULL) { + return -14; + } + if (ubuf->len == 0) { + return -15; + } + cnt += (ubuf->len + step - 1) / step; + } + } else { + return -10; + } + + // Return the required DMA descriptor count + if (desc == NULL && desc_cnt) { + *desc_cnt = (cnt == 1) ? 0 : cnt; return 0; + } + + if (cnt > 1) { + if (desc == NULL || desc_cnt == NULL) { + return -1; + } + if (*desc_cnt < cnt) { + return -2; + } + } + if (desc_cnt) { + *desc_cnt = (cnt == 1) ? 0 : cnt; + } + + periph = uart[id].rx_periph; + + lock = int_lock(); + if (recv_dma_chan[id] != HAL_DMA_CHAN_NONE) { + int_unlock(lock); + return 1; + } + recv_dma_chan[id] = hal_gpdma_get_chan(periph, HAL_DMA_HIGH_PRIO); + if (recv_dma_chan[id] == HAL_DMA_CHAN_NONE) { + int_unlock(lock); + return 2; + } + int_unlock(lock); + + recv_dma_mode[id] = mode; + recv_dma_size[id] = len; + + memset(&dma_cfg, 0, sizeof(dma_cfg)); + dma_cfg.ch = recv_dma_chan[id]; + dma_cfg.dst = (uint32_t)buf; + dma_cfg.dst_bsize = HAL_DMA_BSIZE_32; + dma_cfg.dst_periph = 0; // useless + dma_cfg.dst_width = HAL_DMA_WIDTH_BYTE; + dma_cfg.handler = recv_dma_irq_handler; + dma_cfg.src = 0; // useless + dma_cfg.src_bsize = HAL_DMA_BSIZE_8; + dma_cfg.src_periph = periph; + dma_cfg.src_tsize = len; + dma_cfg.src_width = HAL_DMA_WIDTH_BYTE; + dma_cfg.type = HAL_DMA_FLOW_P2M_DMA; + dma_cfg.try_burst = 0; + + if (mask) { + recv_mask[id] = *mask; + dma_cfg.start_cb = recv_dma_start_callback; + } else { + union HAL_UART_IRQ_T irq_mask; + + irq_mask.reg = uart[id].base->UARTIMSC; + ASSERT(irq_mask.RT == 0, err_recv_dma_api, __FUNCTION__); + } + + // Activate DMA RT behaviour + lock = int_lock(); + uart[id].base->UARTLCR_H |= UARTLCR_H_DMA_RT_EN; + int_unlock(lock); + + if (cnt == 1) { + ret = hal_gpdma_start(&dma_cfg); + } else { + if (mode == UART_RX_DMA_MODE_BUF_LIST) { + ret = fill_buf_list_dma_desc(desc, cnt, &dma_cfg, ubuf, ucnt, step); + } else { + ret = fill_dma_desc(desc, cnt, &dma_cfg, len, mode, step); + } + if (ret) { + goto _err_exit; + } + ret = hal_gpdma_sg_start(desc, &dma_cfg); + } + + if (ret != HAL_DMA_OK) { + _err_exit: + // Restore the traditional RT behaviour + lock = int_lock(); + uart[id].base->UARTLCR_H &= ~UARTLCR_H_DMA_RT_EN; + int_unlock(lock); + hal_gpdma_free_chan(recv_dma_chan[id]); + recv_dma_chan[id] = HAL_DMA_CHAN_NONE; + return 3; + } + + return 0; } // Safe API to trigger receive timeout IRQ and DMA IRQ int hal_uart_dma_recv_mask(enum HAL_UART_ID_T id, uint8_t *buf, uint32_t len, struct HAL_DMA_DESC_T *desc, uint32_t *desc_cnt, - const union HAL_UART_IRQ_T *mask) -{ - struct HAL_UART_BUF_T uart_buf; + const union HAL_UART_IRQ_T *mask) { + struct HAL_UART_BUF_T uart_buf; - uart_buf.buf = buf; - uart_buf.len = len; - uart_buf.irq = false; - uart_buf.loop_hdr = false; - return start_recv_dma_with_mask(id, &uart_buf, 1, desc, desc_cnt, mask, UART_RX_DMA_MODE_NORMAL, HAL_UART_DMA_TRANSFER_STEP); + uart_buf.buf = buf; + uart_buf.len = len; + uart_buf.irq = false; + uart_buf.loop_hdr = false; + return start_recv_dma_with_mask(id, &uart_buf, 1, desc, desc_cnt, mask, + UART_RX_DMA_MODE_NORMAL, + HAL_UART_DMA_TRANSFER_STEP); } // Safe API to trigger receive timeout IRQ and DMA IRQ -int hal_uart_dma_recv_mask_pingpang(enum HAL_UART_ID_T id, uint8_t *buf, uint32_t len, - struct HAL_DMA_DESC_T *desc, uint32_t *desc_cnt, - const union HAL_UART_IRQ_T *mask, uint32_t step) -{ - struct HAL_UART_BUF_T uart_buf; +int hal_uart_dma_recv_mask_pingpang(enum HAL_UART_ID_T id, uint8_t *buf, + uint32_t len, struct HAL_DMA_DESC_T *desc, + uint32_t *desc_cnt, + const union HAL_UART_IRQ_T *mask, + uint32_t step) { + struct HAL_UART_BUF_T uart_buf; - uart_buf.buf = buf; - uart_buf.len = len; - uart_buf.irq = false; - uart_buf.loop_hdr = false; - return start_recv_dma_with_mask(id, &uart_buf, 1, desc, desc_cnt, mask, UART_RX_DMA_MODE_PINGPANG, step); + uart_buf.buf = buf; + uart_buf.len = len; + uart_buf.irq = false; + uart_buf.loop_hdr = false; + return start_recv_dma_with_mask(id, &uart_buf, 1, desc, desc_cnt, mask, + UART_RX_DMA_MODE_PINGPANG, step); } // Safe API to trigger receive timeout IRQ and DMA IRQ -int hal_uart_dma_recv_mask_stream(enum HAL_UART_ID_T id, uint8_t *buf, uint32_t len, - struct HAL_DMA_DESC_T *desc, uint32_t *desc_cnt, - const union HAL_UART_IRQ_T *mask, uint32_t step) -{ - struct HAL_UART_BUF_T uart_buf; +int hal_uart_dma_recv_mask_stream(enum HAL_UART_ID_T id, uint8_t *buf, + uint32_t len, struct HAL_DMA_DESC_T *desc, + uint32_t *desc_cnt, + const union HAL_UART_IRQ_T *mask, + uint32_t step) { + struct HAL_UART_BUF_T uart_buf; - uart_buf.buf = buf; - uart_buf.len = len; - uart_buf.irq = false; - uart_buf.loop_hdr = false; - return start_recv_dma_with_mask(id, &uart_buf, 1, desc, desc_cnt, mask, UART_RX_DMA_MODE_STREAM, step); + uart_buf.buf = buf; + uart_buf.len = len; + uart_buf.irq = false; + uart_buf.loop_hdr = false; + return start_recv_dma_with_mask(id, &uart_buf, 1, desc, desc_cnt, mask, + UART_RX_DMA_MODE_STREAM, step); } // Safe API to trigger receive timeout IRQ and DMA IRQ -int hal_uart_dma_recv_mask_buf_list(enum HAL_UART_ID_T id, const struct HAL_UART_BUF_T *ubuf, uint32_t ucnt, - struct HAL_DMA_DESC_T *desc, uint32_t *desc_cnt, const union HAL_UART_IRQ_T *mask) -{ - return start_recv_dma_with_mask(id, ubuf, ucnt, desc, desc_cnt, mask, UART_RX_DMA_MODE_BUF_LIST, HAL_UART_DMA_TRANSFER_STEP); +int hal_uart_dma_recv_mask_buf_list(enum HAL_UART_ID_T id, + const struct HAL_UART_BUF_T *ubuf, + uint32_t ucnt, struct HAL_DMA_DESC_T *desc, + uint32_t *desc_cnt, + const union HAL_UART_IRQ_T *mask) { + return start_recv_dma_with_mask(id, ubuf, ucnt, desc, desc_cnt, mask, + UART_RX_DMA_MODE_BUF_LIST, + HAL_UART_DMA_TRANSFER_STEP); } int hal_uart_dma_recv(enum HAL_UART_ID_T id, uint8_t *buf, uint32_t len, - struct HAL_DMA_DESC_T *desc, uint32_t *desc_cnt) -{ - struct HAL_UART_BUF_T uart_buf; + struct HAL_DMA_DESC_T *desc, uint32_t *desc_cnt) { + struct HAL_UART_BUF_T uart_buf; - uart_buf.buf = buf; - uart_buf.len = len; - uart_buf.irq = false; - uart_buf.loop_hdr = false; - return start_recv_dma_with_mask(id, &uart_buf, 1, desc, desc_cnt, NULL, UART_RX_DMA_MODE_NORMAL, HAL_UART_DMA_TRANSFER_STEP); + uart_buf.buf = buf; + uart_buf.len = len; + uart_buf.irq = false; + uart_buf.loop_hdr = false; + return start_recv_dma_with_mask(id, &uart_buf, 1, desc, desc_cnt, NULL, + UART_RX_DMA_MODE_NORMAL, + HAL_UART_DMA_TRANSFER_STEP); } -int hal_uart_dma_recv_pingpang(enum HAL_UART_ID_T id, uint8_t *buf, uint32_t len, - struct HAL_DMA_DESC_T *desc, uint32_t *desc_cnt) -{ - struct HAL_UART_BUF_T uart_buf; +int hal_uart_dma_recv_pingpang(enum HAL_UART_ID_T id, uint8_t *buf, + uint32_t len, struct HAL_DMA_DESC_T *desc, + uint32_t *desc_cnt) { + struct HAL_UART_BUF_T uart_buf; - uart_buf.buf = buf; - uart_buf.len = len; - uart_buf.irq = false; - uart_buf.loop_hdr = false; - return start_recv_dma_with_mask(id, &uart_buf, 1, desc, desc_cnt, NULL, UART_RX_DMA_MODE_PINGPANG, HAL_UART_DMA_TRANSFER_STEP_PINGPANG); + uart_buf.buf = buf; + uart_buf.len = len; + uart_buf.irq = false; + uart_buf.loop_hdr = false; + return start_recv_dma_with_mask(id, &uart_buf, 1, desc, desc_cnt, NULL, + UART_RX_DMA_MODE_PINGPANG, + HAL_UART_DMA_TRANSFER_STEP_PINGPANG); } -uint32_t hal_uart_get_dma_recv_addr(enum HAL_UART_ID_T id) -{ - uint32_t lock; - uint32_t addr; - int i; +uint32_t hal_uart_get_dma_recv_addr(enum HAL_UART_ID_T id) { + uint32_t lock; + uint32_t addr; + int i; - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - addr = 0; + addr = 0; - lock = int_lock(); - if (recv_dma_chan[id] != HAL_DMA_CHAN_NONE) { - for (i = 0; i < 2; i++) { - addr = hal_dma_get_cur_dst_addr(recv_dma_chan[id]); - if (addr) { - break; - } - } + lock = int_lock(); + if (recv_dma_chan[id] != HAL_DMA_CHAN_NONE) { + for (i = 0; i < 2; i++) { + addr = hal_dma_get_cur_dst_addr(recv_dma_chan[id]); + if (addr) { + break; + } } - int_unlock(lock); + } + int_unlock(lock); - return addr; + return addr; } -uint32_t hal_uart_stop_dma_recv(enum HAL_UART_ID_T id) -{ - uint32_t remains; - uint32_t lock; - uint8_t chan; +uint32_t hal_uart_stop_dma_recv(enum HAL_UART_ID_T id) { + uint32_t remains; + uint32_t lock; + uint8_t chan; - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - lock = int_lock(); - chan = recv_dma_chan[id]; - recv_dma_chan[id] = HAL_DMA_CHAN_NONE; - // Restore the traditional RT behaviour - uart[id].base->UARTLCR_H &= ~UARTLCR_H_DMA_RT_EN; - int_unlock(lock); + lock = int_lock(); + chan = recv_dma_chan[id]; + recv_dma_chan[id] = HAL_DMA_CHAN_NONE; + // Restore the traditional RT behaviour + uart[id].base->UARTLCR_H &= ~UARTLCR_H_DMA_RT_EN; + int_unlock(lock); - if (chan == HAL_DMA_CHAN_NONE) { - return 0; - } + if (chan == HAL_DMA_CHAN_NONE) { + return 0; + } - // Save the data in DMA FIFO - hal_gpdma_stop(chan); - remains = hal_gpdma_get_sg_remain_size(chan); - hal_gpdma_free_chan(chan); + // Save the data in DMA FIFO + hal_gpdma_stop(chan); + remains = hal_gpdma_get_sg_remain_size(chan); + hal_gpdma_free_chan(chan); - return remains; + return remains; } -static void send_dma_irq_handler(uint8_t chan, uint32_t remain_tsize, uint32_t error, struct HAL_DMA_DESC_T *lli) -{ - enum HAL_UART_ID_T id; - uint32_t xfer; - uint32_t lock; +static void send_dma_irq_handler(uint8_t chan, uint32_t remain_tsize, + uint32_t error, struct HAL_DMA_DESC_T *lli) { + enum HAL_UART_ID_T id; + uint32_t xfer; + uint32_t lock; - lock = int_lock(); - for (id = HAL_UART_ID_0; id < HAL_UART_ID_QTY; id++) { - if (send_dma_chan[id] == chan) { - send_dma_chan[id] = HAL_DMA_CHAN_NONE; - break; - } + lock = int_lock(); + for (id = HAL_UART_ID_0; id < HAL_UART_ID_QTY; id++) { + if (send_dma_chan[id] == chan) { + send_dma_chan[id] = HAL_DMA_CHAN_NONE; + break; } - int_unlock(lock); + } + int_unlock(lock); - if (id == HAL_UART_ID_QTY) { - return; - } - - // Get remain xfer size - xfer = hal_gpdma_get_sg_remain_size(chan); - - hal_gpdma_free_chan(chan); - - if (txdma_handler[id]) { - // Get already xfer size - if (send_dma_size[id] > xfer) { - xfer = send_dma_size[id] - xfer; - } else { - xfer = 0; - } - txdma_handler[id](xfer, error); + if (id == HAL_UART_ID_QTY) { + return; + } + + // Get remain xfer size + xfer = hal_gpdma_get_sg_remain_size(chan); + + hal_gpdma_free_chan(chan); + + if (txdma_handler[id]) { + // Get already xfer size + if (send_dma_size[id] > xfer) { + xfer = send_dma_size[id] - xfer; + } else { + xfer = 0; } + txdma_handler[id](xfer, error); + } } int hal_uart_dma_send(enum HAL_UART_ID_T id, const uint8_t *buf, uint32_t len, - struct HAL_DMA_DESC_T *desc, uint32_t *desc_cnt) -{ - struct HAL_DMA_CH_CFG_T dma_cfg; - enum HAL_DMA_RET_T ret; - uint32_t lock; - uint32_t cnt; - uint32_t i; - enum HAL_DMA_PERIPH_T periph; + struct HAL_DMA_DESC_T *desc, uint32_t *desc_cnt) { + struct HAL_DMA_CH_CFG_T dma_cfg; + enum HAL_DMA_RET_T ret; + uint32_t lock; + uint32_t cnt; + uint32_t i; + enum HAL_DMA_PERIPH_T periph; - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - ASSERT(uart[id].irq != INVALID_IRQn, "DMA not supported on UART %d", id); - ASSERT((uart[id].base->UARTDMACR & UARTDMACR_TXDMAE), "DMA not configured on UART %d", id); + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + ASSERT(uart[id].irq != INVALID_IRQn, "DMA not supported on UART %d", id); + ASSERT((uart[id].base->UARTDMACR & UARTDMACR_TXDMAE), + "DMA not configured on UART %d", id); - cnt = (len + HAL_UART_DMA_TRANSFER_STEP - 1) / HAL_UART_DMA_TRANSFER_STEP; - - // Return the required DMA descriptor count - if (desc == NULL && desc_cnt) { - *desc_cnt = (cnt == 1) ? 0 : cnt; - return 0; - } - - if (cnt == 0) { - return 0; - } - if (cnt > 1) { - if (desc == NULL || desc_cnt == NULL) { - return -1; - } - if (*desc_cnt < cnt) { - return -2; - } - } - if (desc_cnt) { - *desc_cnt = (cnt == 1) ? 0 : cnt; - } - - periph = uart[id].tx_periph; - - lock = int_lock(); - if (send_dma_chan[id] != HAL_DMA_CHAN_NONE) { - int_unlock(lock); - return 1; - } - send_dma_chan[id] = hal_gpdma_get_chan(periph, HAL_DMA_HIGH_PRIO); - if (send_dma_chan[id] == HAL_DMA_CHAN_NONE) { - int_unlock(lock); - return 2; - } - int_unlock(lock); - - send_dma_size[id] = len; - - memset(&dma_cfg, 0, sizeof(dma_cfg)); - dma_cfg.ch = send_dma_chan[id]; - dma_cfg.dst = 0; // useless - dma_cfg.dst_bsize = HAL_DMA_BSIZE_8; - dma_cfg.dst_periph = periph; - dma_cfg.dst_width = HAL_DMA_WIDTH_BYTE; - dma_cfg.handler = send_dma_irq_handler; - dma_cfg.src = (uint32_t)buf; - dma_cfg.src_bsize = HAL_DMA_BSIZE_32; - dma_cfg.src_periph = 0; // useless - dma_cfg.src_tsize = len; - dma_cfg.src_width = HAL_DMA_WIDTH_BYTE; - dma_cfg.type = HAL_DMA_FLOW_M2P_DMA; - dma_cfg.try_burst = 0; - - if (cnt == 1) { - ret = hal_gpdma_start(&dma_cfg); - } else { - for (i = 0; i < cnt - 1; i++) { - dma_cfg.src_tsize = HAL_UART_DMA_TRANSFER_STEP; - ret = hal_gpdma_init_desc(&desc[i], &dma_cfg, &desc[i + 1], 0); - if (ret != HAL_DMA_OK) { - goto _err_exit; - } - dma_cfg.src += HAL_UART_DMA_TRANSFER_STEP; - } - dma_cfg.src_tsize = len - (HAL_UART_DMA_TRANSFER_STEP * i); - ret = hal_gpdma_init_desc(&desc[i], &dma_cfg, NULL, 1); - if (ret != HAL_DMA_OK) { - goto _err_exit; - } - ret = hal_gpdma_sg_start(desc, &dma_cfg); - } - - if (ret != HAL_DMA_OK) { -_err_exit: - hal_gpdma_free_chan(send_dma_chan[id]); - send_dma_chan[id] = HAL_DMA_CHAN_NONE; - return 3; - } + cnt = (len + HAL_UART_DMA_TRANSFER_STEP - 1) / HAL_UART_DMA_TRANSFER_STEP; + // Return the required DMA descriptor count + if (desc == NULL && desc_cnt) { + *desc_cnt = (cnt == 1) ? 0 : cnt; return 0; -} + } -uint32_t hal_uart_stop_dma_send(enum HAL_UART_ID_T id) -{ - uint32_t remains; - uint32_t lock; - uint8_t chan; + if (cnt == 0) { + return 0; + } + if (cnt > 1) { + if (desc == NULL || desc_cnt == NULL) { + return -1; + } + if (*desc_cnt < cnt) { + return -2; + } + } + if (desc_cnt) { + *desc_cnt = (cnt == 1) ? 0 : cnt; + } - ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); + periph = uart[id].tx_periph; - lock = int_lock(); - chan = send_dma_chan[id]; - send_dma_chan[id] = HAL_DMA_CHAN_NONE; + lock = int_lock(); + if (send_dma_chan[id] != HAL_DMA_CHAN_NONE) { int_unlock(lock); + return 1; + } + send_dma_chan[id] = hal_gpdma_get_chan(periph, HAL_DMA_HIGH_PRIO); + if (send_dma_chan[id] == HAL_DMA_CHAN_NONE) { + int_unlock(lock); + return 2; + } + int_unlock(lock); - if (chan == HAL_DMA_CHAN_NONE) { - return 0; + send_dma_size[id] = len; + + memset(&dma_cfg, 0, sizeof(dma_cfg)); + dma_cfg.ch = send_dma_chan[id]; + dma_cfg.dst = 0; // useless + dma_cfg.dst_bsize = HAL_DMA_BSIZE_8; + dma_cfg.dst_periph = periph; + dma_cfg.dst_width = HAL_DMA_WIDTH_BYTE; + dma_cfg.handler = send_dma_irq_handler; + dma_cfg.src = (uint32_t)buf; + dma_cfg.src_bsize = HAL_DMA_BSIZE_32; + dma_cfg.src_periph = 0; // useless + dma_cfg.src_tsize = len; + dma_cfg.src_width = HAL_DMA_WIDTH_BYTE; + dma_cfg.type = HAL_DMA_FLOW_M2P_DMA; + dma_cfg.try_burst = 0; + + if (cnt == 1) { + ret = hal_gpdma_start(&dma_cfg); + } else { + for (i = 0; i < cnt - 1; i++) { + dma_cfg.src_tsize = HAL_UART_DMA_TRANSFER_STEP; + ret = hal_gpdma_init_desc(&desc[i], &dma_cfg, &desc[i + 1], 0); + if (ret != HAL_DMA_OK) { + goto _err_exit; + } + dma_cfg.src += HAL_UART_DMA_TRANSFER_STEP; } + dma_cfg.src_tsize = len - (HAL_UART_DMA_TRANSFER_STEP * i); + ret = hal_gpdma_init_desc(&desc[i], &dma_cfg, NULL, 1); + if (ret != HAL_DMA_OK) { + goto _err_exit; + } + ret = hal_gpdma_sg_start(desc, &dma_cfg); + } - // Not to keep the data in DMA FIFO - hal_gpdma_cancel(chan); - remains = hal_gpdma_get_sg_remain_size(chan); - hal_gpdma_free_chan(chan); + if (ret != HAL_DMA_OK) { + _err_exit: + hal_gpdma_free_chan(send_dma_chan[id]); + send_dma_chan[id] = HAL_DMA_CHAN_NONE; + return 3; + } - return remains; + return 0; } -static void hal_uart_irq_handler(void) -{ - enum HAL_UART_ID_T id; - union HAL_UART_IRQ_T state; +uint32_t hal_uart_stop_dma_send(enum HAL_UART_ID_T id) { + uint32_t remains; + uint32_t lock; + uint8_t chan; - for (id = HAL_UART_ID_0; id < HAL_UART_ID_QTY; id++) { - state.reg = uart[id].base->UARTMIS; + ASSERT(id < HAL_UART_ID_QTY, err_invalid_id, id); - if (state.reg) { - uart[id].base->UARTICR = state.reg; + lock = int_lock(); + chan = send_dma_chan[id]; + send_dma_chan[id] = HAL_DMA_CHAN_NONE; + int_unlock(lock); - if (irq_handler[id] != NULL) { - irq_handler[id](id, state); - } - } + if (chan == HAL_DMA_CHAN_NONE) { + return 0; + } + + // Not to keep the data in DMA FIFO + hal_gpdma_cancel(chan); + remains = hal_gpdma_get_sg_remain_size(chan); + hal_gpdma_free_chan(chan); + + return remains; +} + +static void hal_uart_irq_handler(void) { + enum HAL_UART_ID_T id; + union HAL_UART_IRQ_T state; + + for (id = HAL_UART_ID_0; id < HAL_UART_ID_QTY; id++) { + state.reg = uart[id].base->UARTMIS; + + if (state.reg) { + uart[id].base->UARTICR = state.reg; + + if (irq_handler[id] != NULL) { + irq_handler[id](id, state); + } } + } } // ======================================================================== @@ -1292,64 +1284,62 @@ static void hal_uart_irq_handler(void) #include "stdio.h" #if !defined(DEBUG_PORT) || (DEBUG_PORT == 1) -#define UART_PRINTF_ID HAL_UART_ID_0 +#define UART_PRINTF_ID HAL_UART_ID_0 #else -#define UART_PRINTF_ID HAL_UART_ID_1 +#define UART_PRINTF_ID HAL_UART_ID_1 #endif #ifndef TRACE_BAUD_RATE -#define TRACE_BAUD_RATE (921600) +#define TRACE_BAUD_RATE (921600) #endif -int hal_uart_printf_init(void) -{ - static const struct HAL_UART_CFG_T uart_cfg = { - .parity = HAL_UART_PARITY_NONE, - .stop = HAL_UART_STOP_BITS_1, - .data = HAL_UART_DATA_BITS_8, - .flow = HAL_UART_FLOW_CONTROL_NONE,//HAL_UART_FLOW_CONTROL_RTSCTS, - .tx_level = HAL_UART_FIFO_LEVEL_1_2, - .rx_level = HAL_UART_FIFO_LEVEL_1_4, - .baud = TRACE_BAUD_RATE, - .dma_rx = false, - .dma_tx = false, - .dma_rx_stop_on_err = false, - }; +int hal_uart_printf_init(void) { + static const struct HAL_UART_CFG_T uart_cfg = { + .parity = HAL_UART_PARITY_NONE, + .stop = HAL_UART_STOP_BITS_1, + .data = HAL_UART_DATA_BITS_8, + .flow = HAL_UART_FLOW_CONTROL_NONE, // HAL_UART_FLOW_CONTROL_RTSCTS, + .tx_level = HAL_UART_FIFO_LEVEL_1_2, + .rx_level = HAL_UART_FIFO_LEVEL_1_4, + .baud = TRACE_BAUD_RATE, + .dma_rx = false, + .dma_tx = false, + .dma_rx_stop_on_err = false, + }; - if (UART_PRINTF_ID == HAL_UART_ID_0) { - hal_iomux_set_uart0(); - } else { - hal_iomux_set_uart1(); - } + if (UART_PRINTF_ID == HAL_UART_ID_0) { + hal_iomux_set_uart0(); + } else { + hal_iomux_set_uart1(); + } - return hal_uart_open(UART_PRINTF_ID, &uart_cfg); + return hal_uart_open(UART_PRINTF_ID, &uart_cfg); } -void hal_uart_printf(const char *fmt, ...) -{ - char buf[200]; - int ret; - int i; - va_list ap; +void hal_uart_printf(const char *fmt, ...) { + char buf[200]; + int ret; + int i; + va_list ap; - va_start(ap, fmt); - ret = vsnprintf(buf, sizeof(buf), fmt, ap); + va_start(ap, fmt); + ret = vsnprintf(buf, sizeof(buf), fmt, ap); #ifdef TRACE_CRLF - if (ret + 2 < sizeof(buf)) { - buf[ret++] = '\r'; - } + if (ret + 2 < sizeof(buf)) { + buf[ret++] = '\r'; + } #endif - if (ret + 1 < sizeof(buf)) { - buf[ret++] = '\n'; - } - //buf[ret] = 0; - va_end(ap); + if (ret + 1 < sizeof(buf)) { + buf[ret++] = '\n'; + } + // buf[ret] = 0; + va_end(ap); - if (ret > 0) { - for (i = 0; i < ret; i++) { - hal_uart_blocked_putc(UART_PRINTF_ID, buf[i]); - } + if (ret > 0) { + for (i = 0; i < ret; i++) { + hal_uart_blocked_putc(UART_PRINTF_ID, buf[i]); } + } } #endif // CHIP_HAS_UART diff --git a/platform/hal/hal_usb.c b/platform/hal/hal_usb.c index 7796075..d4bcdc5 100644 --- a/platform/hal/hal_usb.c +++ b/platform/hal/hal_usb.c @@ -15,19 +15,19 @@ ****************************************************************************/ #ifdef CHIP_HAS_USB -#include "plat_addr_map.h" -#include "reg_usb.h" #include "hal_usb.h" -#include "hal_trace.h" -#include "hal_cmu.h" -#include "hal_timer.h" -#include "hal_sysfreq.h" -#include "hal_chipid.h" -#include "usb_descriptor.h" -#include "string.h" #include "cmsis_nvic.h" +#include "hal_chipid.h" +#include "hal_cmu.h" +#include "hal_sysfreq.h" +#include "hal_timer.h" +#include "hal_trace.h" #include "hwtimer_list.h" +#include "plat_addr_map.h" #include "pmu.h" +#include "reg_usb.h" +#include "string.h" +#include "usb_descriptor.h" #ifdef CHIP_HAS_USBPHY #include "usbphy.h" #endif @@ -41,8 +41,18 @@ // GHWCFG3 = 0x03f404e8 // GHWCFG4 = 0x16108020 -#define USB_TRACE(n, mask, str, ...) { if (usb_trmask & (1 << mask)) { TRACE(n, str, ##__VA_ARGS__); } } -#define USB_FUNC_ENTRY_TRACE(mask) { if (usb_trmask & (1 << mask)) { FUNC_ENTRY_TRACE(); } } +#define USB_TRACE(n, mask, str, ...) \ + { \ + if (usb_trmask & (1 << mask)) { \ + TRACE(n, str, ##__VA_ARGS__); \ + } \ + } +#define USB_FUNC_ENTRY_TRACE(mask) \ + { \ + if (usb_trmask & (1 << mask)) { \ + FUNC_ENTRY_TRACE(); \ + } \ + } #ifndef CHIP_BEST1000 #define CHIP_HAS_USBIF @@ -50,75 +60,75 @@ #ifdef USB_HIGH_SPEED #ifndef USB_ISO_INTERVAL -#define USB_ISO_INTERVAL 8 // ANY value larger than 1 +#define USB_ISO_INTERVAL 8 // ANY value larger than 1 #endif #if (USB_ISO_INTERVAL <= 1) #error "Invalid USB_ISO_INTERVAL" #endif #else #undef USB_ISO_INTERVAL -#define USB_ISO_INTERVAL 1 +#define USB_ISO_INTERVAL 1 #endif #ifdef SIMU_UAUD_MAX_PKT // SEND/RECV with mps = USB_MAX_PACKET_SIZE_ISO -#define USB_FIFO_MPS_ISO_RECV USB_FIFO_MPS_ISO_SEND +#define USB_FIFO_MPS_ISO_RECV USB_FIFO_MPS_ISO_SEND #else #ifdef USB_HIGH_SPEED // 384K sample rate, 32 bits, 2 channels = 3072 bytes/ms -#define USB_FIFO_MPS_ISO_RECV 1200 +#define USB_FIFO_MPS_ISO_RECV 1200 #else // 192K sample rate, 16 bits, 2 channels = 768 bytes/ms -#define USB_FIFO_MPS_ISO_RECV USB_FIFO_MPS_ISO_SEND +#define USB_FIFO_MPS_ISO_RECV USB_FIFO_MPS_ISO_SEND #endif #endif -#define PIN_CHECK_ENABLE_INTERVAL MS_TO_TICKS(1) -#define PIN_CHECK_WAIT_RESUME_INTERVAL MS_TO_TICKS(30) -#define LPM_CHECK_INTERVAL MS_TO_TICKS(100) //(US_TO_TICKS(8 + 50) + 2) +#define PIN_CHECK_ENABLE_INTERVAL MS_TO_TICKS(1) +#define PIN_CHECK_WAIT_RESUME_INTERVAL MS_TO_TICKS(30) +#define LPM_CHECK_INTERVAL MS_TO_TICKS(100) //(US_TO_TICKS(8 + 50) + 2) -#define USB_SYS_FREQ HAL_CMU_FREQ_52M +#define USB_SYS_FREQ HAL_CMU_FREQ_52M enum DEVICE_STATE { - ATTACHED, - POWERED, - DEFAULT, - ADDRESS, - CONFIGURED, + ATTACHED, + POWERED, + DEFAULT, + ADDRESS, + CONFIGURED, }; struct EPN_OUT_TRANSFER { - uint8_t *data; - uint32_t length; - bool enabled; + uint8_t *data; + uint32_t length; + bool enabled; }; struct EPN_IN_TRANSFER { - const uint8_t *data; - uint32_t length; - uint16_t pkt_cnt; - bool zero_len_pkt; - bool enabled; + const uint8_t *data; + uint32_t length; + uint16_t pkt_cnt; + bool zero_len_pkt; + bool enabled; }; enum DATA_PID_T { - DATA_PID_DATA0 = 0, - DATA_PID_DATA1 = 2, - DATA_PID_DATA2 = 1, - DATA_PID_MDATA = 3, + DATA_PID_DATA0 = 0, + DATA_PID_DATA1 = 2, + DATA_PID_DATA2 = 1, + DATA_PID_MDATA = 3, }; enum USB_SLEEP_T { - USB_SLEEP_NONE, - USB_SLEEP_SUSPEND, - USB_SLEEP_L1, + USB_SLEEP_NONE, + USB_SLEEP_SUSPEND, + USB_SLEEP_L1, }; static const uint32_t usb_trmask = (1 << 0); //(1 << 2) | (1 << 6) | (1 << 8); -static struct USBC_T * const usbc = (struct USBC_T *)USB_BASE; +static struct USBC_T *const usbc = (struct USBC_T *)USB_BASE; #ifdef CHIP_HAS_USBIF -static struct USBIF_T * const usbif = (struct USBIF_T *)(USB_BASE + 0x00040000); +static struct USBIF_T *const usbif = (struct USBIF_T *)(USB_BASE + 0x00040000); #endif static uint16_t fifo_addr; @@ -157,1736 +167,1690 @@ static void hal_usb_stop_usbdev_timer(void); static void hal_usb_irq_handler(void); -static void hal_usb_init_ep0_transfer(void) -{ - ep0_transfer.stage = NONE_STAGE; - ep0_transfer.data = NULL; - ep0_transfer.length = 0; - ep0_transfer.trx_len = 0; +static void hal_usb_init_ep0_transfer(void) { + ep0_transfer.stage = NONE_STAGE; + ep0_transfer.data = NULL; + ep0_transfer.length = 0; + ep0_transfer.trx_len = 0; } -static void hal_usb_init_epn_transfer(void) -{ - memset(&epn_out_transfer[0], 0, sizeof(epn_out_transfer)); - memset(&epn_in_transfer[0], 0, sizeof(epn_in_transfer)); +static void hal_usb_init_epn_transfer(void) { + memset(&epn_out_transfer[0], 0, sizeof(epn_out_transfer)); + memset(&epn_in_transfer[0], 0, sizeof(epn_in_transfer)); } -static void get_setup_packet(uint8_t *data, struct SETUP_PACKET *packet) -{ - packet->bmRequestType.direction = (data[0] & 0x80) >> 7; - packet->bmRequestType.type = (data[0] & 0x60) >> 5; - packet->bmRequestType.recipient = data[0] & 0x1f; - packet->bRequest = data[1]; - packet->wValue = (data[2] | data[3] << 8); - packet->wIndex = (data[4] | data[5] << 8); - packet->wLength = (data[6] | data[7] << 8); +static void get_setup_packet(uint8_t *data, struct SETUP_PACKET *packet) { + packet->bmRequestType.direction = (data[0] & 0x80) >> 7; + packet->bmRequestType.type = (data[0] & 0x60) >> 5; + packet->bmRequestType.recipient = data[0] & 0x1f; + packet->bRequest = data[1]; + packet->wValue = (data[2] | data[3] << 8); + packet->wIndex = (data[4] | data[5] << 8); + packet->wLength = (data[6] | data[7] << 8); } -static void reset_epn_out_transfer(uint8_t ep) -{ - bool enabled; +static void reset_epn_out_transfer(uint8_t ep) { + bool enabled; - enabled = epn_out_transfer[ep - 1].enabled; + enabled = epn_out_transfer[ep - 1].enabled; - // Clear epn_out_transfer[] before invoking the callback, - // so that ep can be restarted in the callback - memset(&epn_out_transfer[ep - 1], 0, sizeof(epn_out_transfer[0])); + // Clear epn_out_transfer[] before invoking the callback, + // so that ep can be restarted in the callback + memset(&epn_out_transfer[ep - 1], 0, sizeof(epn_out_transfer[0])); - if (enabled && callbacks.epn_recv_compl[ep - 1]) { - callbacks.epn_recv_compl[ep - 1](NULL, 0, XFER_COMPL_ERROR); + if (enabled && callbacks.epn_recv_compl[ep - 1]) { + callbacks.epn_recv_compl[ep - 1](NULL, 0, XFER_COMPL_ERROR); + } +} + +static void reset_epn_in_transfer(uint8_t ep) { + bool enabled; + + enabled = epn_in_transfer[ep - 1].enabled; + + // Clear epn_in_transfer[] before invoking the callback, + // so that ep can be restarted in the callback + memset(&epn_in_transfer[ep - 1], 0, sizeof(epn_in_transfer[0])); + + if (enabled && callbacks.epn_send_compl[ep - 1]) { + callbacks.epn_send_compl[ep - 1](NULL, 0, XFER_COMPL_ERROR); + } +} + +static uint32_t get_ep_type(enum EP_DIR dir, uint8_t ep) { + uint32_t type; + + if (ep == 0) { + return E_CONTROL; + } + + if (dir == EP_OUT) { + type = GET_BITFIELD(usbc->DOEPnCONFIG[ep - 1].DOEPCTL, USBC_EPTYPE); + } else { + type = GET_BITFIELD(usbc->DIEPnCONFIG[ep - 1].DIEPCTL, USBC_EPTYPE); + } + + return type; +} + +static void _set_global_out_nak(void) { + uint32_t start; + uint32_t sts; + uint32_t ep; + + usbc->DCTL |= USBC_SGOUTNAK; + + start = hal_sys_timer_get(); + while (((usbc->GINTSTS & USBC_GOUTNAKEFF) == 0) && + (hal_sys_timer_get() - start < MS_TO_TICKS(5))) { + if (hal_sys_timer_get() - start >= US_TO_TICKS(60)) { + if ((usbc->GRSTCTL & USBC_DMAREQ) == 0) { + break; + } } -} + } -static void reset_epn_in_transfer(uint8_t ep) -{ - bool enabled; + if (usbc->GINTSTS & USBC_GOUTNAKEFF) { + return; + } - enabled = epn_in_transfer[ep - 1].enabled; + start = hal_sys_timer_get(); + while ((usbc->GINTSTS & USBC_RXFLVL) && + (hal_sys_timer_get() - start < MS_TO_TICKS(5))) { + sts = usbc->GRXSTSP; - // Clear epn_in_transfer[] before invoking the callback, - // so that ep can be restarted in the callback - memset(&epn_in_transfer[ep - 1], 0, sizeof(epn_in_transfer[0])); + ep = GET_BITFIELD(sts, USBC_EPNUM); + ASSERT(ep == 0, + "Global OUT NAK: Only ep0 packets can be dropped: ep=%u sts=0x%08X", + ep, sts); - if (enabled && callbacks.epn_send_compl[ep - 1]) { - callbacks.epn_send_compl[ep - 1](NULL, 0, XFER_COMPL_ERROR); - } -} - -static uint32_t get_ep_type(enum EP_DIR dir, uint8_t ep) -{ - uint32_t type; - - if (ep == 0) { - return E_CONTROL; - } - - if (dir == EP_OUT) { - type = GET_BITFIELD(usbc->DOEPnCONFIG[ep - 1].DOEPCTL, USBC_EPTYPE); - } else { - type = GET_BITFIELD(usbc->DIEPnCONFIG[ep - 1].DIEPCTL, USBC_EPTYPE); - } - - return type; -} - -static void _set_global_out_nak(void) -{ - uint32_t start; - uint32_t sts; - uint32_t ep; - - usbc->DCTL |= USBC_SGOUTNAK; - - start = hal_sys_timer_get(); - while (((usbc->GINTSTS & USBC_GOUTNAKEFF) == 0) && - (hal_sys_timer_get() - start < MS_TO_TICKS(5))) { - if (hal_sys_timer_get() - start >= US_TO_TICKS(60)) { - if ((usbc->GRSTCTL & USBC_DMAREQ) == 0) { - break; - } - } - } + // NOTE: + // Global OUT NAK pattern cannot be read out from GRXSTSP -- consumed by + // controller automatically when poping? + hal_sys_timer_delay(US_TO_TICKS(60)); if (usbc->GINTSTS & USBC_GOUTNAKEFF) { - return; + return; } + } - start = hal_sys_timer_get(); - while ((usbc->GINTSTS & USBC_RXFLVL) && - (hal_sys_timer_get() - start < MS_TO_TICKS(5))) { - sts = usbc->GRXSTSP; - - ep = GET_BITFIELD(sts, USBC_EPNUM); - ASSERT(ep == 0, "Global OUT NAK: Only ep0 packets can be dropped: ep=%u sts=0x%08X", ep, sts); - - // NOTE: - // Global OUT NAK pattern cannot be read out from GRXSTSP -- consumed by controller automatically when poping? - - hal_sys_timer_delay(US_TO_TICKS(60)); - if (usbc->GINTSTS & USBC_GOUTNAKEFF) { - return; - } - } - - ASSERT((usbc->GINTSTS & USBC_GOUTNAKEFF), "Global OUT NAK: Failed to recover"); + ASSERT((usbc->GINTSTS & USBC_GOUTNAKEFF), + "Global OUT NAK: Failed to recover"); } -static void _disable_out_ep(uint8_t ep, uint32_t set, uint32_t clr) -{ - volatile uint32_t *ctrl; - volatile uint32_t *intr; - uint32_t doepctl; +static void _disable_out_ep(uint8_t ep, uint32_t set, uint32_t clr) { + volatile uint32_t *ctrl; + volatile uint32_t *intr; + uint32_t doepctl; - if (ep >= EPNUM) { - return; + if (ep >= EPNUM) { + return; + } + + if (ep == 0) { + ctrl = &usbc->DOEPCTL0; + intr = &usbc->DOEPINT0; + } else { + ctrl = &usbc->DOEPnCONFIG[ep - 1].DOEPCTL; + intr = &usbc->DOEPnCONFIG[ep - 1].DOEPINT; + } + + doepctl = *ctrl; + + if ((doepctl & (USBC_EPENA | USBC_USBACTEP)) == 0) { + goto _exit; + } + if ((doepctl & (USBC_EPENA | USBC_NAKSTS)) == USBC_NAKSTS && + set == USBC_SNAK && clr == 0) { + goto _exit; + } + + _set_global_out_nak(); + + *ctrl |= USBC_SNAK | USBC_USBACTEP | set; + + if (clr) { + *ctrl &= ~clr; + } + + // EP0 out cannot be disabled, but stalled + if (ep != 0) { + if (doepctl & USBC_EPENA) { + *intr = USBC_EPDISBLD; + *ctrl |= USBC_EPDIS; + while ((*intr & USBC_EPDISBLD) == 0) + ; } - if (ep == 0) { - ctrl = &usbc->DOEPCTL0; - intr = &usbc->DOEPINT0; + if ((doepctl & USBC_USBACTEP) == 0) { + *ctrl &= ~USBC_USBACTEP; + } + } + + usbc->DCTL |= USBC_CGOUTNAK; + +_exit: + if (ep > 0) { + reset_epn_out_transfer(ep); + } +} + +static void _disable_in_ep(uint8_t ep, uint32_t set, uint32_t clr) { + volatile uint32_t *ctrl; + volatile uint32_t *intr; + uint32_t diepctl; + + if (ep >= EPNUM) { + return; + } + + if (ep == 0) { + ctrl = &usbc->DIEPCTL0; + intr = &usbc->DIEPINT0; + } else { + ctrl = &usbc->DIEPnCONFIG[ep - 1].DIEPCTL; + intr = &usbc->DIEPnCONFIG[ep - 1].DIEPINT; + } + + diepctl = *ctrl; + + if ((diepctl & (USBC_EPENA | USBC_USBACTEP)) == 0) { + goto _exit; + } + if ((diepctl & (USBC_EPENA | USBC_NAKSTS)) == USBC_NAKSTS && + set == USBC_SNAK && clr == 0) { + goto _exit; + } + + *intr = USBC_INEPNAKEFF; + *ctrl |= USBC_SNAK | USBC_USBACTEP | set; + if ((diepctl & USBC_EPENA) && (diepctl & USBC_NAKSTS) == 0) { + while ((*intr & USBC_INEPNAKEFF) == 0) + ; + *intr = USBC_INEPNAKEFF; + } + + if (clr) { + *ctrl &= ~clr; + } + + if (diepctl & USBC_EPENA) { + *intr = USBC_EPDISBLD; + *ctrl |= USBC_EPDIS; + while ((*intr & USBC_EPDISBLD) == 0) + ; + } + + usbc->GRSTCTL = USBC_TXFNUM(ep) | USBC_TXFFLSH; + while ((usbc->GRSTCTL & USBC_TXFFLSH) != 0) + ; + + if ((diepctl & USBC_USBACTEP) == 0) { + *ctrl &= ~USBC_USBACTEP; + } + +_exit: + if (ep > 0) { + reset_epn_in_transfer(ep); + } +} + +void hal_usb_disable_ep(enum EP_DIR dir, uint8_t ep) { + USB_TRACE(3, 14, "%s: %d ep%d", __FUNCTION__, dir, ep); + + if (dir == EP_OUT) { + _disable_out_ep(ep, USBC_SNAK, 0); + } else { + _disable_in_ep(ep, USBC_SNAK, 0); + } +} + +void hal_usb_stall_ep(enum EP_DIR dir, uint8_t ep) { + uint32_t set; + uint32_t clr; + + USB_TRACE(3, 13, "%s: %d ep%d", __FUNCTION__, dir, ep); + + set = USBC_STALL; + clr = 0; + + if (dir == EP_OUT) { + _disable_out_ep(ep, set, clr); + } else { + _disable_in_ep(ep, set, clr); + } +} + +void hal_usb_unstall_ep(enum EP_DIR dir, uint8_t ep) { + uint32_t set; + uint32_t clr; + uint8_t type; + + USB_TRACE(3, 12, "%s: %d ep%d", __FUNCTION__, dir, ep); + + set = USBC_SNAK; + clr = USBC_STALL; + + type = get_ep_type(dir, ep); + if (type == E_INTERRUPT || type == E_BULK) { + set |= USBC_SETD0PID; + } + + if (hal_usb_get_ep_stall_state(dir, ep) == 0) { + // Ep not in stall state + if (ep != 0 && (type == E_INTERRUPT || type == E_BULK)) { + if (dir == EP_OUT) { + usbc->DOEPnCONFIG[ep - 1].DOEPCTL |= USBC_SETD0PID; + } else { + usbc->DIEPnCONFIG[ep - 1].DIEPCTL |= USBC_SETD0PID; + } + } + return; + } + + if (dir == EP_OUT) { + _disable_out_ep(ep, set, clr); + } else { + _disable_in_ep(ep, set, clr); + } +} + +int hal_usb_get_ep_stall_state(enum EP_DIR dir, uint8_t ep) { + volatile uint32_t *ctrl; + + if (ep >= EPNUM) { + return 0; + } + + // Select ctl register + if (ep == 0) { + if (dir == EP_IN) { + ctrl = &usbc->DIEPCTL0; } else { - ctrl = &usbc->DOEPnCONFIG[ep - 1].DOEPCTL; - intr = &usbc->DOEPnCONFIG[ep - 1].DOEPINT; + ctrl = &usbc->DOEPCTL0; + } + } else { + if (dir == EP_IN) { + ctrl = &usbc->DIEPnCONFIG[ep - 1].DIEPCTL; + } else { + ctrl = &usbc->DOEPnCONFIG[ep - 1].DOEPCTL; + } + } + + return ((*ctrl & USBC_STALL) != 0); +} + +void hal_usb_stop_ep(enum EP_DIR dir, uint8_t ep) { + USB_TRACE(3, 11, "%s: %d ep%d", __FUNCTION__, dir, ep); + + hal_usb_disable_ep(dir, ep); +} + +static void hal_usb_stop_all_out_eps(void) { + int i; + volatile uint32_t *ctrl; + volatile uint32_t *intr; + uint32_t doepctl; + + USB_FUNC_ENTRY_TRACE(11); + + // Enable global out nak + _set_global_out_nak(); + + for (i = 0; i < EPNUM; i++) { + if (i == 0) { + ctrl = &usbc->DOEPCTL0; + intr = &usbc->DOEPINT0; + } else { + ctrl = &usbc->DOEPnCONFIG[i - 1].DOEPCTL; + intr = &usbc->DOEPnCONFIG[i - 1].DOEPINT; } doepctl = *ctrl; - if ((doepctl & (USBC_EPENA | USBC_USBACTEP)) == 0) { - goto _exit; - } - if ((doepctl & (USBC_EPENA | USBC_NAKSTS)) == USBC_NAKSTS && set == USBC_SNAK && clr == 0) { - goto _exit; - } - - _set_global_out_nak(); - - *ctrl |= USBC_SNAK | USBC_USBACTEP | set; - - if (clr) { - *ctrl &= ~clr; - } - - // EP0 out cannot be disabled, but stalled - if (ep != 0) { + // BUS RESET will clear USBC_USBACTEP but keep USBC_EPENA in ep ctrl + if (doepctl & (USBC_EPENA | USBC_USBACTEP)) { + *ctrl |= USBC_SNAK | USBC_USBACTEP; + // EP0 out cannot be disabled, but stalled + if (i != 0) { if (doepctl & USBC_EPENA) { - *intr = USBC_EPDISBLD; - *ctrl |= USBC_EPDIS; - while ((*intr & USBC_EPDISBLD) == 0); + *intr = USBC_EPDISBLD; + *ctrl |= USBC_EPDIS; + while ((*intr & USBC_EPDISBLD) == 0) + ; } - if ((doepctl & USBC_USBACTEP) == 0) { - *ctrl &= ~USBC_USBACTEP; + *ctrl &= ~USBC_USBACTEP; } + } } + } - usbc->DCTL |= USBC_CGOUTNAK; - -_exit: - if (ep > 0) { - reset_epn_out_transfer(ep); - } + // Disable global out nak + usbc->DCTL |= USBC_CGOUTNAK; } -static void _disable_in_ep(uint8_t ep, uint32_t set, uint32_t clr) -{ - volatile uint32_t *ctrl; - volatile uint32_t *intr; - uint32_t diepctl; +static void hal_usb_stop_all_in_eps(void) { + int i; + volatile uint32_t *ctrl; + volatile uint32_t *intr; + uint32_t diepctl; - if (ep >= EPNUM) { - return; - } + USB_FUNC_ENTRY_TRACE(11); - if (ep == 0) { - ctrl = &usbc->DIEPCTL0; - intr = &usbc->DIEPINT0; + usbc->DCTL |= USBC_SGNPINNAK; + while ((usbc->GINTSTS & USBC_GINNAKEFF) == 0) + ; + + for (i = 0; i < EPNUM; i++) { + if (i == 0) { + ctrl = &usbc->DIEPCTL0; + intr = &usbc->DIEPINT0; } else { - ctrl = &usbc->DIEPnCONFIG[ep - 1].DIEPCTL; - intr = &usbc->DIEPnCONFIG[ep - 1].DIEPINT; + ctrl = &usbc->DIEPnCONFIG[i - 1].DIEPCTL; + intr = &usbc->DIEPnCONFIG[i - 1].DIEPINT; } diepctl = *ctrl; - if ((diepctl & (USBC_EPENA | USBC_USBACTEP)) == 0) { - goto _exit; - } - if ((diepctl & (USBC_EPENA | USBC_NAKSTS)) == USBC_NAKSTS && set == USBC_SNAK && clr == 0) { - goto _exit; - } - - *intr = USBC_INEPNAKEFF; - *ctrl |= USBC_SNAK | USBC_USBACTEP | set; - if ((diepctl & USBC_EPENA) && (diepctl & USBC_NAKSTS) == 0) { - while ((*intr & USBC_INEPNAKEFF) == 0); + // BUS RESET will clear USBC_USBACTEP but keep USBC_EPENA in ep ctrl + if (diepctl & (USBC_EPENA | USBC_USBACTEP)) { + *intr = USBC_INEPNAKEFF; + *ctrl |= USBC_SNAK | USBC_USBACTEP; + if ((diepctl & USBC_EPENA) && (diepctl & USBC_NAKSTS) == 0) { + while ((*intr & USBC_INEPNAKEFF) == 0) + ; *intr = USBC_INEPNAKEFF; - } - - if (clr) { - *ctrl &= ~clr; - } - - if (diepctl & USBC_EPENA) { + } + if (diepctl & USBC_EPENA) { *intr = USBC_EPDISBLD; *ctrl |= USBC_EPDIS; - while ((*intr & USBC_EPDISBLD) == 0); - } - - usbc->GRSTCTL = USBC_TXFNUM(ep) | USBC_TXFFLSH; - while ((usbc->GRSTCTL & USBC_TXFFLSH) != 0); - - if ((diepctl & USBC_USBACTEP) == 0) { + while ((*intr & USBC_EPDISBLD) == 0) + ; + } + if ((diepctl & USBC_USBACTEP) == 0) { *ctrl &= ~USBC_USBACTEP; + } } + } -_exit: - if (ep > 0) { - reset_epn_in_transfer(ep); - } + // Flush Tx Fifo + usbc->GRSTCTL = USBC_TXFNUM(0x10) | USBC_TXFFLSH | USBC_RXFFLSH; + while ((usbc->GRSTCTL & (USBC_TXFFLSH | USBC_RXFFLSH)) != 0) + ; + + usbc->DCTL |= USBC_CGNPINNAK; } -void hal_usb_disable_ep(enum EP_DIR dir, uint8_t ep) -{ - USB_TRACE(3,14, "%s: %d ep%d", __FUNCTION__, dir, ep); +static void hal_usb_flush_tx_fifo(uint8_t ep) { + usbc->DCTL |= USBC_SGNPINNAK; + while ((usbc->GINTSTS & USBC_GINNAKEFF) == 0) + ; - if (dir == EP_OUT) { - _disable_out_ep(ep, USBC_SNAK, 0); - } else { - _disable_in_ep(ep, USBC_SNAK, 0); - } + while ((usbc->GRSTCTL & USBC_AHBIDLE) == 0) + ; + + // while ((usbc->GRSTCTL & USBC_TXFFLSH) != 0); + + usbc->GRSTCTL = USBC_TXFNUM(ep) | USBC_TXFFLSH; + while ((usbc->GRSTCTL & USBC_TXFFLSH) != 0) + ; + + usbc->DCTL |= USBC_CGNPINNAK; } -void hal_usb_stall_ep(enum EP_DIR dir, uint8_t ep) -{ - uint32_t set; - uint32_t clr; +static void hal_usb_flush_all_tx_fifos(void) { hal_usb_flush_tx_fifo(0x10); } - USB_TRACE(3,13, "%s: %d ep%d", __FUNCTION__, dir, ep); +static void POSSIBLY_UNUSED hal_usb_flush_rx_fifo(void) { + _set_global_out_nak(); - set = USBC_STALL; - clr = 0; + usbc->GRSTCTL |= USBC_RXFFLSH; + while ((usbc->GRSTCTL & USBC_RXFFLSH) != 0) + ; - if (dir == EP_OUT) { - _disable_out_ep(ep, set, clr); - } else { - _disable_in_ep(ep, set, clr); - } + usbc->DCTL |= USBC_CGOUTNAK; } -void hal_usb_unstall_ep(enum EP_DIR dir, uint8_t ep) -{ - uint32_t set; - uint32_t clr; - uint8_t type; +static void hal_usb_alloc_ep0_fifo(void) { + uint32_t ram_size; + uint32_t ram_avail; - USB_TRACE(3,12, "%s: %d ep%d", __FUNCTION__, dir, ep); + if ((usbc->GHWCFG2 & USBC_DYNFIFOSIZING) == 0) { + return; + } - set = USBC_SNAK; - clr = USBC_STALL; + // All endpoints have been stopped in hal_usb_irq_reset() - type = get_ep_type(dir, ep); - if (type == E_INTERRUPT || type == E_BULK) { - set |= USBC_SETD0PID; - } + // Configure FIFOs - if (hal_usb_get_ep_stall_state(dir, ep) == 0) { - // Ep not in stall state - if (ep != 0 && (type == E_INTERRUPT || type == E_BULK)) { - if (dir == EP_OUT) { - usbc->DOEPnCONFIG[ep - 1].DOEPCTL |= USBC_SETD0PID; - } else { - usbc->DIEPnCONFIG[ep - 1].DIEPCTL |= USBC_SETD0PID; - } - } - return; - } - - if (dir == EP_OUT) { - _disable_out_ep(ep, set, clr); - } else { - _disable_in_ep(ep, set, clr); - } -} - -int hal_usb_get_ep_stall_state(enum EP_DIR dir, uint8_t ep) -{ - volatile uint32_t *ctrl; - - if (ep >= EPNUM) { - return 0; - } - - // Select ctl register - if(ep == 0) { - if (dir == EP_IN) { - ctrl = &usbc->DIEPCTL0; - } else { - ctrl = &usbc->DOEPCTL0; - } - } else { - if (dir == EP_IN) { - ctrl = &usbc->DIEPnCONFIG[ep - 1].DIEPCTL; - } else { - ctrl = &usbc->DOEPnCONFIG[ep - 1].DOEPCTL; - } - } - - return ((*ctrl & USBC_STALL) != 0); -} - -void hal_usb_stop_ep(enum EP_DIR dir, uint8_t ep) -{ - USB_TRACE(3,11, "%s: %d ep%d", __FUNCTION__, dir, ep); - - hal_usb_disable_ep(dir, ep); -} - -static void hal_usb_stop_all_out_eps(void) -{ - int i; - volatile uint32_t *ctrl; - volatile uint32_t *intr; - uint32_t doepctl; - - USB_FUNC_ENTRY_TRACE(11); - - // Enable global out nak - _set_global_out_nak(); - - for (i = 0; i < EPNUM; i++) { - if (i == 0) { - ctrl = &usbc->DOEPCTL0; - intr = &usbc->DOEPINT0; - } else { - ctrl = &usbc->DOEPnCONFIG[i - 1].DOEPCTL; - intr = &usbc->DOEPnCONFIG[i - 1].DOEPINT; - } - - doepctl = *ctrl; - - // BUS RESET will clear USBC_USBACTEP but keep USBC_EPENA in ep ctrl - if (doepctl & (USBC_EPENA | USBC_USBACTEP)) { - *ctrl |= USBC_SNAK | USBC_USBACTEP; - // EP0 out cannot be disabled, but stalled - if (i != 0) { - if (doepctl & USBC_EPENA) { - *intr = USBC_EPDISBLD; - *ctrl |= USBC_EPDIS; - while ((*intr & USBC_EPDISBLD) == 0); - } - if ((doepctl & USBC_USBACTEP) == 0) { - *ctrl &= ~USBC_USBACTEP; - } - } - } - } - - // Disable global out nak - usbc->DCTL |= USBC_CGOUTNAK; -} - -static void hal_usb_stop_all_in_eps(void) -{ - int i; - volatile uint32_t *ctrl; - volatile uint32_t *intr; - uint32_t diepctl; - - USB_FUNC_ENTRY_TRACE(11); - - usbc->DCTL |= USBC_SGNPINNAK; - while ((usbc->GINTSTS & USBC_GINNAKEFF) == 0); - - for (i = 0; i < EPNUM; i++) { - if (i == 0) { - ctrl = &usbc->DIEPCTL0; - intr = &usbc->DIEPINT0; - } else { - ctrl = &usbc->DIEPnCONFIG[i - 1].DIEPCTL; - intr = &usbc->DIEPnCONFIG[i - 1].DIEPINT; - } - - diepctl = *ctrl; - - // BUS RESET will clear USBC_USBACTEP but keep USBC_EPENA in ep ctrl - if (diepctl & (USBC_EPENA | USBC_USBACTEP)) { - *intr = USBC_INEPNAKEFF; - *ctrl |= USBC_SNAK | USBC_USBACTEP; - if ((diepctl & USBC_EPENA) && (diepctl & USBC_NAKSTS) == 0) { - while ((*intr & USBC_INEPNAKEFF) == 0); - *intr = USBC_INEPNAKEFF; - } - if (diepctl & USBC_EPENA) { - *intr = USBC_EPDISBLD; - *ctrl |= USBC_EPDIS; - while ((*intr & USBC_EPDISBLD) == 0); - } - if ((diepctl & USBC_USBACTEP) == 0) { - *ctrl &= ~USBC_USBACTEP; - } - } - } - - // Flush Tx Fifo - usbc->GRSTCTL = USBC_TXFNUM(0x10) | USBC_TXFFLSH | USBC_RXFFLSH; - while ((usbc->GRSTCTL & (USBC_TXFFLSH | USBC_RXFFLSH)) != 0); - - usbc->DCTL |= USBC_CGNPINNAK; -} - -static void hal_usb_flush_tx_fifo(uint8_t ep) -{ - usbc->DCTL |= USBC_SGNPINNAK; - while ((usbc->GINTSTS & USBC_GINNAKEFF) == 0); - - while ((usbc->GRSTCTL & USBC_AHBIDLE) == 0); - - //while ((usbc->GRSTCTL & USBC_TXFFLSH) != 0); - - usbc->GRSTCTL = USBC_TXFNUM(ep) | USBC_TXFFLSH; - while ((usbc->GRSTCTL & USBC_TXFFLSH) != 0); - - usbc->DCTL |= USBC_CGNPINNAK; -} - -static void hal_usb_flush_all_tx_fifos(void) -{ - hal_usb_flush_tx_fifo(0x10); -} - -static void POSSIBLY_UNUSED hal_usb_flush_rx_fifo(void) -{ - _set_global_out_nak(); - - usbc->GRSTCTL |= USBC_RXFFLSH; - while ((usbc->GRSTCTL & USBC_RXFFLSH) != 0); - - usbc->DCTL |= USBC_CGOUTNAK; -} - -static void hal_usb_alloc_ep0_fifo(void) -{ - uint32_t ram_size; - uint32_t ram_avail; - - if ((usbc->GHWCFG2 & USBC_DYNFIFOSIZING) == 0) { - return; - } - - // All endpoints have been stopped in hal_usb_irq_reset() - - // Configure FIFOs - - // RX FIFO Calculation - // ------------------- - // SETUP Packets : 4 * n + 6 - // Global OUT NAK : 1 - // DATA Packets + Status Info : (MPS / 4 + 1) * m - // OutEp XFER COMPL : 1 * outEpNum - // OutEp Disable : 1 * outEpNum + // RX FIFO Calculation + // ------------------- + // SETUP Packets : 4 * n + 6 + // Global OUT NAK : 1 + // DATA Packets + Status Info : (MPS / 4 + 1) * m + // OutEp XFER COMPL : 1 * outEpNum + // OutEp Disable : 1 * outEpNum #ifdef USB_ISO -#define RXFIFOSIZE ((4 * CTRL_EPNUM + 6) + 1 + (2 * (USB_FIFO_MPS_ISO_RECV / 4 + 1)) + (EPNUM * 2)) +#define RXFIFOSIZE \ + ((4 * CTRL_EPNUM + 6) + 1 + (2 * (USB_FIFO_MPS_ISO_RECV / 4 + 1)) + \ + (EPNUM * 2)) #else -#define RXFIFOSIZE ((4 * CTRL_EPNUM + 6) + 1 + (2 * (USB_MAX_PACKET_SIZE_BULK / 4 + 1)) + (EPNUM * 2)) +#define RXFIFOSIZE \ + ((4 * CTRL_EPNUM + 6) + 1 + (2 * (USB_MAX_PACKET_SIZE_BULK / 4 + 1)) + \ + (EPNUM * 2)) #endif -#define EP0_TXFIFOSIZE (2 * (USB_MAX_PACKET_SIZE_CTRL + 3) / 4) +#define EP0_TXFIFOSIZE (2 * (USB_MAX_PACKET_SIZE_CTRL + 3) / 4) #if (RXFIFOSIZE + EP0_TXFIFOSIZE > SPFIFORAM_SIZE) #error "Invalid FIFO size configuration" #endif - ram_size = GET_BITFIELD(usbc->GDFIFOCFG, USBC_GDFIFOCFG); - ram_avail = GET_BITFIELD(usbc->GDFIFOCFG, USBC_EPINFOBASEADDR); + ram_size = GET_BITFIELD(usbc->GDFIFOCFG, USBC_GDFIFOCFG); + ram_avail = GET_BITFIELD(usbc->GDFIFOCFG, USBC_EPINFOBASEADDR); - ASSERT(SPFIFORAM_SIZE == ram_size, "Bad dfifo size: %u (should be %u)", ram_size, SPFIFORAM_SIZE); - ASSERT(RXFIFOSIZE + EP0_TXFIFOSIZE <= ram_avail, "Bad dfifo size cfg: rx=%u ep0=%u avail=%u", RXFIFOSIZE, EP0_TXFIFOSIZE, ram_avail); + ASSERT(SPFIFORAM_SIZE == ram_size, "Bad dfifo size: %u (should be %u)", + ram_size, SPFIFORAM_SIZE); + ASSERT(RXFIFOSIZE + EP0_TXFIFOSIZE <= ram_avail, + "Bad dfifo size cfg: rx=%u ep0=%u avail=%u", RXFIFOSIZE, + EP0_TXFIFOSIZE, ram_avail); - // Rx Fifo Size (and init fifo_addr) - usbc->GRXFSIZ = USBC_RXFDEP(RXFIFOSIZE); - fifo_addr = RXFIFOSIZE; + // Rx Fifo Size (and init fifo_addr) + usbc->GRXFSIZ = USBC_RXFDEP(RXFIFOSIZE); + fifo_addr = RXFIFOSIZE; - // EP0 / Non-periodic Tx Fifo Size - usbc->GNPTXFSIZ = USBC_NPTXFSTADDR(fifo_addr) | USBC_NPTXFDEPS(EP0_TXFIFOSIZE); - fifo_addr += EP0_TXFIFOSIZE; + // EP0 / Non-periodic Tx Fifo Size + usbc->GNPTXFSIZ = + USBC_NPTXFSTADDR(fifo_addr) | USBC_NPTXFDEPS(EP0_TXFIFOSIZE); + fifo_addr += EP0_TXFIFOSIZE; - // Flush Tx FIFOs - hal_usb_flush_all_tx_fifos(); + // Flush Tx FIFOs + hal_usb_flush_all_tx_fifos(); } -static void hal_usb_alloc_epn_fifo(uint8_t ep, uint16_t mps) -{ - uint16_t size; - uint32_t ram_avail; +static void hal_usb_alloc_epn_fifo(uint8_t ep, uint16_t mps) { + uint16_t size; + uint32_t ram_avail; - if (ep == 0 || ep >= EPNUM) { - return; - } + if (ep == 0 || ep >= EPNUM) { + return; + } - size = (mps + 3) / 4 * 2; + size = (mps + 3) / 4 * 2; - ram_avail = GET_BITFIELD(usbc->GDFIFOCFG, USBC_EPINFOBASEADDR); + ram_avail = GET_BITFIELD(usbc->GDFIFOCFG, USBC_EPINFOBASEADDR); - ASSERT(fifo_addr + size <= ram_avail, - "Fifo overflow: fifo_addr=%u, size=%u, avail=%u", - fifo_addr, size, ram_avail); + ASSERT(fifo_addr + size <= ram_avail, + "Fifo overflow: fifo_addr=%u, size=%u, avail=%u", fifo_addr, size, + ram_avail); - usbc->DTXFSIZE[ep - 1].DIEPTXFn = USBC_INEPNTXFSTADDR(fifo_addr) | USBC_INEPNTXFDEP(size); - fifo_addr += size; + usbc->DTXFSIZE[ep - 1].DIEPTXFn = + USBC_INEPNTXFSTADDR(fifo_addr) | USBC_INEPNTXFDEP(size); + fifo_addr += size; } -static void hal_usb_soft_reset(void) -{ - usbc->GRSTCTL |= USBC_CSFTRST; - while ((usbc->GRSTCTL & USBC_CSFTRST) != 0); - while ((usbc->GRSTCTL & USBC_AHBIDLE) == 0); +static void hal_usb_soft_reset(void) { + usbc->GRSTCTL |= USBC_CSFTRST; + while ((usbc->GRSTCTL & USBC_CSFTRST) != 0) + ; + while ((usbc->GRSTCTL & USBC_AHBIDLE) == 0) + ; } -static void hal_usb_init_phy(void) -{ +static void hal_usb_init_phy(void) { #ifdef USB_HIGH_SPEED - usbc->GUSBCFG |= USBC_FORCEDEVMODE | USBC_ULPIAUTORES | USBC_ULPIFSLS | USBC_ULPI_UTMI_SEL; - usbc->GUSBCFG &= ~(USBC_FSINTF | USBC_PHYIF | USBC_PHYSEL | USBC_USBTRDTIM_MASK); + usbc->GUSBCFG |= + USBC_FORCEDEVMODE | USBC_ULPIAUTORES | USBC_ULPIFSLS | USBC_ULPI_UTMI_SEL; + usbc->GUSBCFG &= + ~(USBC_FSINTF | USBC_PHYIF | USBC_PHYSEL | USBC_USBTRDTIM_MASK); #else - usbc->GUSBCFG |= USBC_FORCEDEVMODE | USBC_ULPIAUTORES | USBC_ULPIFSLS | - USBC_PHYSEL | USBC_ULPI_UTMI_SEL; - usbc->GUSBCFG &= ~(USBC_FSINTF | USBC_PHYIF | USBC_USBTRDTIM_MASK); + usbc->GUSBCFG |= USBC_FORCEDEVMODE | USBC_ULPIAUTORES | USBC_ULPIFSLS | + USBC_PHYSEL | USBC_ULPI_UTMI_SEL; + usbc->GUSBCFG &= ~(USBC_FSINTF | USBC_PHYIF | USBC_USBTRDTIM_MASK); #endif - // USB turnaround time = 4 * AHB Clock + 1 PHY Clock, in terms of PHY clocks. - // If AHB Clock >= PHY Clock, time can be set to 5. - // If AHB Clock * 2 == PHY Clock, time should be set to 9. - usbc->GUSBCFG |= USBC_USBTRDTIM(5); + // USB turnaround time = 4 * AHB Clock + 1 PHY Clock, in terms of PHY clocks. + // If AHB Clock >= PHY Clock, time can be set to 5. + // If AHB Clock * 2 == PHY Clock, time should be set to 9. + usbc->GUSBCFG |= USBC_USBTRDTIM(5); } -static void hal_usb_device_init(void) -{ - int i; - uint8_t speed; +static void hal_usb_device_init(void) { + int i; + uint8_t speed; #ifdef CHIP_HAS_USBPHY - usbphy_open(); + usbphy_open(); #endif #ifdef USB_HIGH_SPEED #ifdef CHIP_HAS_USBIF - usbif->USBIF_00 &= ~(USBIF_00_CFG_DR_SUSPEND | USBIF_00_CFG_REG_SUSPEND); - usbif->USBIF_08 &= ~USBIF_08_CFG_SEL48M; + usbif->USBIF_00 &= ~(USBIF_00_CFG_DR_SUSPEND | USBIF_00_CFG_REG_SUSPEND); + usbif->USBIF_08 &= ~USBIF_08_CFG_SEL48M; #endif - speed = 0; + speed = 0; #else #ifdef CHIP_HAS_USBIF - usbif->USBIF_00 |= USBIF_00_CFG_DR_SUSPEND | USBIF_00_CFG_REG_SUSPEND; - usbif->USBIF_08 |= USBIF_08_CFG_SEL48M; + usbif->USBIF_00 |= USBIF_00_CFG_DR_SUSPEND | USBIF_00_CFG_REG_SUSPEND; + usbif->USBIF_08 |= USBIF_08_CFG_SEL48M; #endif - speed = 3; + speed = 3; #endif #ifdef CHIP_BEST2000 - if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) { - // dr_suspend and reg_suspend are inverted since metal 1 - usbif->USBIF_00 ^= USBIF_00_CFG_DR_SUSPEND | USBIF_00_CFG_REG_SUSPEND; - } + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_1) { + // dr_suspend and reg_suspend are inverted since metal 1 + usbif->USBIF_00 ^= USBIF_00_CFG_DR_SUSPEND | USBIF_00_CFG_REG_SUSPEND; + } #endif #ifdef USB_HIGH_SPEED - // Wait until usbphy clock is ready - hal_sys_timer_delay(US_TO_TICKS(60)); + // Wait until usbphy clock is ready + hal_sys_timer_delay(US_TO_TICKS(60)); #endif - hal_usb_soft_reset(); - hal_usb_init_phy(); - // Reset after selecting PHY - hal_usb_soft_reset(); - // Some core cfg (except for PHY selection) will also be reset during soft reset - hal_usb_init_phy(); + hal_usb_soft_reset(); + hal_usb_init_phy(); + // Reset after selecting PHY + hal_usb_soft_reset(); + // Some core cfg (except for PHY selection) will also be reset during soft + // reset + hal_usb_init_phy(); - usbc->DCFG &= ~(USBC_DEVSPD_MASK | USBC_PERFRINT_MASK); - usbc->DCFG |= USBC_DEVSPD(speed) | USBC_NZSTSOUTHSHK | USBC_PERFRINT(0); + usbc->DCFG &= ~(USBC_DEVSPD_MASK | USBC_PERFRINT_MASK); + usbc->DCFG |= USBC_DEVSPD(speed) | USBC_NZSTSOUTHSHK | USBC_PERFRINT(0); - // Clear previous interrupts - usbc->GINTMSK = 0; - usbc->GINTSTS = ~0UL; - usbc->DAINTMSK = 0; - usbc->DOEPMSK = 0; - usbc->DIEPMSK = 0; - for (i = 0; i < EPNUM; ++i) { - if (i == 0) { - usbc->DOEPINT0 = ~0UL; - usbc->DIEPINT0 = ~0UL; - } else { - usbc->DOEPnCONFIG[i - 1].DOEPINT = ~0UL; - usbc->DIEPnCONFIG[i - 1].DIEPINT = ~0UL; - } + // Clear previous interrupts + usbc->GINTMSK = 0; + usbc->GINTSTS = ~0UL; + usbc->DAINTMSK = 0; + usbc->DOEPMSK = 0; + usbc->DIEPMSK = 0; + for (i = 0; i < EPNUM; ++i) { + if (i == 0) { + usbc->DOEPINT0 = ~0UL; + usbc->DIEPINT0 = ~0UL; + } else { + usbc->DOEPnCONFIG[i - 1].DOEPINT = ~0UL; + usbc->DIEPnCONFIG[i - 1].DIEPINT = ~0UL; } - usbc->GINTMSK = USBC_USBRST | USBC_ENUMDONE | USBC_ERLYSUSP | USBC_USBSUSP; + } + usbc->GINTMSK = USBC_USBRST | USBC_ENUMDONE | USBC_ERLYSUSP | USBC_USBSUSP; - usbc->DCTL &= ~USBC_SFTDISCON; + usbc->DCTL &= ~USBC_SFTDISCON; #if (USB_ISO_INTERVAL > 1) - // Not to check frame number and ignore ISO incomplete interrupts - usbc->DCTL |= USBC_IGNRFRMNUM; + // Not to check frame number and ignore ISO incomplete interrupts + usbc->DCTL |= USBC_IGNRFRMNUM; #endif - // Enable DMA mode - // Burst size 16 words - usbc->GAHBCFG = USBC_DMAEN | USBC_HBSTLEN(7); - usbc->GAHBCFG |= USBC_GLBLINTRMSK; + // Enable DMA mode + // Burst size 16 words + usbc->GAHBCFG = USBC_DMAEN | USBC_HBSTLEN(7); + usbc->GAHBCFG |= USBC_GLBLINTRMSK; } -static void hal_usb_soft_disconnect(void) -{ - // Disable global interrupt - usbc->GAHBCFG &= ~USBC_GLBLINTRMSK; - // Soft disconnection - usbc->DCTL |= USBC_SFTDISCON; +static void hal_usb_soft_disconnect(void) { + // Disable global interrupt + usbc->GAHBCFG &= ~USBC_GLBLINTRMSK; + // Soft disconnection + usbc->DCTL |= USBC_SFTDISCON; - hal_usb_device_init(); + hal_usb_device_init(); } -static void enable_usb_irq(void) -{ - NVIC_SetVector(USB_IRQn, (uint32_t)hal_usb_irq_handler); +static void enable_usb_irq(void) { + NVIC_SetVector(USB_IRQn, (uint32_t)hal_usb_irq_handler); #ifdef USB_ISO - NVIC_SetPriority(USB_IRQn, IRQ_PRIORITY_HIGH); + NVIC_SetPriority(USB_IRQn, IRQ_PRIORITY_HIGH); #else - NVIC_SetPriority(USB_IRQn, IRQ_PRIORITY_NORMAL); + NVIC_SetPriority(USB_IRQn, IRQ_PRIORITY_NORMAL); #endif - NVIC_ClearPendingIRQ(USB_IRQn); - NVIC_EnableIRQ(USB_IRQn); + NVIC_ClearPendingIRQ(USB_IRQn); + NVIC_EnableIRQ(USB_IRQn); } -int hal_usb_open(const struct HAL_USB_CALLBACKS *c, enum HAL_USB_API_MODE m) -{ - if (c == NULL) { - return 1; - } - if (c->device_desc == NULL || - c->cfg_desc == NULL || - c->string_desc == NULL || - c->setcfg == NULL) { - return 2; - } +int hal_usb_open(const struct HAL_USB_CALLBACKS *c, enum HAL_USB_API_MODE m) { + if (c == NULL) { + return 1; + } + if (c->device_desc == NULL || c->cfg_desc == NULL || c->string_desc == NULL || + c->setcfg == NULL) { + return 2; + } - if (device_state != ATTACHED) { - return 3; - } - device_state = POWERED; - device_sleep_status = USB_SLEEP_NONE; + if (device_state != ATTACHED) { + return 3; + } + device_state = POWERED; + device_sleep_status = USB_SLEEP_NONE; - hal_sysfreq_req(HAL_SYSFREQ_USER_USB, USB_SYS_FREQ); + hal_sysfreq_req(HAL_SYSFREQ_USER_USB, USB_SYS_FREQ); #if defined(USB_SUSPEND) && (defined(PMU_USB_PIN_CHECK) || defined(USB_LPM)) - if (usbdev_timer == NULL) { - usbdev_timer = hwtimer_alloc(NULL, NULL); - ASSERT(usbdev_timer, "Failed to alloc usbdev_timer"); - } + if (usbdev_timer == NULL) { + usbdev_timer = hwtimer_alloc(NULL, NULL); + ASSERT(usbdev_timer, "Failed to alloc usbdev_timer"); + } #endif - hal_cmu_usb_set_device_mode(); - hal_cmu_usb_clock_enable(); + hal_cmu_usb_set_device_mode(); + hal_cmu_usb_clock_enable(); - memcpy(&callbacks, c, sizeof(callbacks)); + memcpy(&callbacks, c, sizeof(callbacks)); - if (usbc->GAHBCFG & USBC_GLBLINTRMSK) { - hal_usb_soft_disconnect(); - } else { - hal_usb_device_init(); - } + if (usbc->GAHBCFG & USBC_GLBLINTRMSK) { + hal_usb_soft_disconnect(); + } else { + hal_usb_device_init(); + } - enable_usb_irq(); + enable_usb_irq(); - if (m == HAL_USB_API_BLOCKING) { - while (device_state != CONFIGURED); - } + if (m == HAL_USB_API_BLOCKING) { + while (device_state != CONFIGURED) + ; + } - return 0; + return 0; } -int hal_usb_reopen(const struct HAL_USB_CALLBACKS *c, uint8_t dcfg, uint8_t alt, uint16_t itf) -{ - if (c == NULL) { - return 1; - } - if (c->device_desc == NULL || - c->cfg_desc == NULL || - c->string_desc == NULL || - c->setcfg == NULL) { - return 2; - } +int hal_usb_reopen(const struct HAL_USB_CALLBACKS *c, uint8_t dcfg, uint8_t alt, + uint16_t itf) { + if (c == NULL) { + return 1; + } + if (c->device_desc == NULL || c->cfg_desc == NULL || c->string_desc == NULL || + c->setcfg == NULL) { + return 2; + } - hal_sysfreq_req(HAL_SYSFREQ_USER_USB, USB_SYS_FREQ); + hal_sysfreq_req(HAL_SYSFREQ_USER_USB, USB_SYS_FREQ); - memcpy(&callbacks, c, sizeof(callbacks)); + memcpy(&callbacks, c, sizeof(callbacks)); - device_state = CONFIGURED; - device_cfg = dcfg; - currentAlternate = alt; - currentInterface = itf; + device_state = CONFIGURED; + device_cfg = dcfg; + currentAlternate = alt; + currentInterface = itf; - enable_usb_irq(); + enable_usb_irq(); - return 0; + return 0; } -void hal_usb_close(void) -{ +void hal_usb_close(void) { #ifdef USB_SUSPEND #if defined(PMU_USB_PIN_CHECK) || defined(USB_LPM) - // Stop pin check timer - hal_usb_stop_usbdev_timer(); + // Stop pin check timer + hal_usb_stop_usbdev_timer(); #ifdef PMU_USB_PIN_CHECK - // Disabe PMU pin status check - pmu_usb_disable_pin_status_check(); + // Disabe PMU pin status check + pmu_usb_disable_pin_status_check(); #endif #endif #endif - NVIC_DisableIRQ(USB_IRQn); + NVIC_DisableIRQ(USB_IRQn); - device_state = ATTACHED; + device_state = ATTACHED; - // Disable global interrupt - usbc->GAHBCFG &= ~USBC_GLBLINTRMSK; - // Soft disconnection - usbc->DCTL |= USBC_SFTDISCON; - // Soft reset - usbc->GRSTCTL |= USBC_CSFTRST; - usbc->DCTL |= USBC_SFTDISCON; - usbc->GRSTCTL |= USBC_CSFTRST; - //while ((usbc->GRSTCTL & USBC_CSFTRST) != 0); - //while ((usbc->GRSTCTL & USBC_AHBIDLE) == 0); + // Disable global interrupt + usbc->GAHBCFG &= ~USBC_GLBLINTRMSK; + // Soft disconnection + usbc->DCTL |= USBC_SFTDISCON; + // Soft reset + usbc->GRSTCTL |= USBC_CSFTRST; + usbc->DCTL |= USBC_SFTDISCON; + usbc->GRSTCTL |= USBC_CSFTRST; + // while ((usbc->GRSTCTL & USBC_CSFTRST) != 0); + // while ((usbc->GRSTCTL & USBC_AHBIDLE) == 0); #ifdef CHIP_HAS_USBPHY - usbphy_close(); + usbphy_close(); #endif - hal_cmu_usb_clock_disable(); + hal_cmu_usb_clock_disable(); - memset(&callbacks, 0, sizeof(callbacks)); + memset(&callbacks, 0, sizeof(callbacks)); - hal_sysfreq_req(HAL_SYSFREQ_USER_USB, HAL_CMU_FREQ_32K); + hal_sysfreq_req(HAL_SYSFREQ_USER_USB, HAL_CMU_FREQ_32K); } -void hal_usb_detect_disconn(void) -{ - // NOTE: - // PHY detects the disconnection event by DP/DN voltage level change. - // But DP/DN voltages are provided by vusb ldo inside chip, which has nothing - // to do with VBUS. That is why USB controller cannot generate the disconnection - // interrupt. - // Meanwhile VBUS detection or charger detection can help to generate USB - // disconnection event via this function. +void hal_usb_detect_disconn(void) { + // NOTE: + // PHY detects the disconnection event by DP/DN voltage level change. + // But DP/DN voltages are provided by vusb ldo inside chip, which has nothing + // to do with VBUS. That is why USB controller cannot generate the + // disconnection interrupt. Meanwhile VBUS detection or charger detection can + // help to generate USB disconnection event via this function. - USB_FUNC_ENTRY_TRACE(26); + USB_FUNC_ENTRY_TRACE(26); - if (device_state != ATTACHED && callbacks.state_change) { - callbacks.state_change(HAL_USB_EVENT_DISCONNECT, 0); - } + if (device_state != ATTACHED && callbacks.state_change) { + callbacks.state_change(HAL_USB_EVENT_DISCONNECT, 0); + } } -int hal_usb_configured(void) -{ - return (device_state == CONFIGURED); +int hal_usb_configured(void) { return (device_state == CONFIGURED); } + +int hal_usb_suspended(void) { + return (device_sleep_status == USB_SLEEP_SUSPEND); } -int hal_usb_suspended(void) -{ - return (device_sleep_status == USB_SLEEP_SUSPEND); -} - -uint32_t hal_usb_get_soffn(void) -{ - return GET_BITFIELD(usbc->DSTS, USBC_SOFFN); +uint32_t hal_usb_get_soffn(void) { + return GET_BITFIELD(usbc->DSTS, USBC_SOFFN); } #ifdef USB_HIGH_SPEED -uint32_t hal_usb_calc_hshb_ep_mps(uint32_t pkt_size) -{ - // For high speed, high bandwidth endpoints - if (pkt_size <= USB_MAX_PACKET_SIZE_ISO) { - return pkt_size; - } else if (pkt_size > USB_MAX_PACKET_SIZE_ISO && pkt_size <= USB_MAX_PACKET_SIZE_ISO * 2) { - return ALIGN(pkt_size / 2, 4); - } else { - // if (pkt_size > USB_MAX_PACKET_SIZE_ISO * 2 && pkt_size <= USB_MAX_PACKET_SIZE_ISO * 3) - return ALIGN(pkt_size / 3, 4); - } +uint32_t hal_usb_calc_hshb_ep_mps(uint32_t pkt_size) { + // For high speed, high bandwidth endpoints + if (pkt_size <= USB_MAX_PACKET_SIZE_ISO) { + return pkt_size; + } else if (pkt_size > USB_MAX_PACKET_SIZE_ISO && + pkt_size <= USB_MAX_PACKET_SIZE_ISO * 2) { + return ALIGN(pkt_size / 2, 4); + } else { + // if (pkt_size > USB_MAX_PACKET_SIZE_ISO * 2 && pkt_size <= + // USB_MAX_PACKET_SIZE_ISO * 3) + return ALIGN(pkt_size / 3, 4); + } } #endif -int hal_usb_activate_epn(enum EP_DIR dir, uint8_t ep, uint8_t type, uint16_t mps) -{ - uint32_t fifo_mps; +int hal_usb_activate_epn(enum EP_DIR dir, uint8_t ep, uint8_t type, + uint16_t mps) { + uint32_t fifo_mps; - USB_TRACE(3,10, "%s: %d ep%d", __FUNCTION__, dir, ep); + USB_TRACE(3, 10, "%s: %d ep%d", __FUNCTION__, dir, ep); - if (ep == 0 || ep >= EPNUM) { - return 1; + if (ep == 0 || ep >= EPNUM) { + return 1; + } + + if (dir == EP_OUT) { + // Stop ep out + if (usbc->DOEPnCONFIG[ep - 1].DOEPCTL & (USBC_EPENA | USBC_USBACTEP)) { + hal_usb_stop_ep(dir, ep); } - - if (dir == EP_OUT) { - // Stop ep out - if (usbc->DOEPnCONFIG[ep - 1].DOEPCTL & (USBC_EPENA | USBC_USBACTEP)) { - hal_usb_stop_ep(dir, ep); - } - // Config ep out - usbc->DOEPnCONFIG[ep - 1].DOEPCTL = - USBC_EPN_MPS(mps) | USBC_EPTYPE(type) | - USBC_USBACTEP | USBC_SNAK | USBC_SETD0PID; - // Unstall ep out - usbc->DOEPnCONFIG[ep - 1].DOEPCTL &= ~USBC_STALL; - // Unmask ep out interrupt - usbc->DAINTMSK |= USBC_OUTEPMSK(1 << ep); - } else { - fifo_mps = mps; -#ifdef USB_HIGH_SPEED - if (type == E_ISOCHRONOUS || type == E_INTERRUPT) { - if (mps > USB_FIFO_MPS_ISO_SEND) { - fifo_mps = USB_FIFO_MPS_ISO_SEND; - } - epn_in_mc[ep - 1] = 1; - } -#endif - // Stop ep in - if (usbc->DIEPnCONFIG[ep - 1].DIEPCTL & (USBC_EPENA | USBC_USBACTEP)) { - hal_usb_stop_ep(dir, ep); - } - // Config ep in - usbc->DIEPnCONFIG[ep - 1].DIEPCTL = - USBC_EPN_MPS(mps) | USBC_EPTYPE(type) | - USBC_USBACTEP | USBC_EPTXFNUM(ep) | USBC_SNAK | USBC_SETD0PID; - // Allocate tx fifo - hal_usb_alloc_epn_fifo(ep, fifo_mps); - // Unstall ep in - usbc->DIEPnCONFIG[ep - 1].DIEPCTL &= ~USBC_STALL; - // Unmask ep in interrupt - usbc->DAINTMSK |= USBC_INEPMSK(1 << ep); - } - - return 0; -} - -int hal_usb_deactivate_epn(enum EP_DIR dir, uint8_t ep) -{ - USB_TRACE(3,9, "%s: %d ep%d", __FUNCTION__, dir, ep); - - if (ep == 0 || ep >= EPNUM) { - return 1; - } - - hal_usb_stop_ep(dir, ep); - - if (dir == EP_OUT) { - usbc->DOEPnCONFIG[ep - 1].DOEPCTL &= ~USBC_USBACTEP; - // Mask ep out interrupt - usbc->DAINTMSK &= ~ USBC_OUTEPMSK(1 << ep); - } else { - usbc->DIEPnCONFIG[ep - 1].DIEPCTL &= ~USBC_USBACTEP; - // Mask ep in interrupt - usbc->DAINTMSK &= ~ USBC_INEPMSK(1 << ep); - } - - return 0; -} - -// NOTE: Not support send epn mps change, which will involve tx fifo reallocation -int hal_usb_update_recv_epn_mps(uint8_t ep, uint16_t mps) -{ - uint8_t type; - - USB_TRACE(3,9, "%s: ep%d mps=%u", __FUNCTION__, ep, mps); - - if (ep == 0 || ep >= EPNUM) { - return 1; - } - - if ((usbc->DOEPnCONFIG[ep - 1].DOEPCTL & USBC_USBACTEP) == 0) { - return 2; - } - - hal_usb_stop_ep(EP_OUT, ep); - - usbc->DOEPnCONFIG[ep - 1].DOEPCTL &= ~USBC_USBACTEP; - // Mask ep out interrupt - usbc->DAINTMSK &= ~ USBC_OUTEPMSK(1 << ep); // Config ep out - type = GET_BITFIELD(usbc->DOEPnCONFIG[ep - 1].DOEPCTL, USBC_EPTYPE); - usbc->DOEPnCONFIG[ep - 1].DOEPCTL = - USBC_EPN_MPS(mps) | USBC_EPTYPE(type) | - USBC_USBACTEP | USBC_SNAK | USBC_SETD0PID; + usbc->DOEPnCONFIG[ep - 1].DOEPCTL = USBC_EPN_MPS(mps) | USBC_EPTYPE(type) | + USBC_USBACTEP | USBC_SNAK | + USBC_SETD0PID; + // Unstall ep out + usbc->DOEPnCONFIG[ep - 1].DOEPCTL &= ~USBC_STALL; // Unmask ep out interrupt usbc->DAINTMSK |= USBC_OUTEPMSK(1 << ep); - - return 0; -} - -int hal_usb_update_send_epn_mc(uint8_t ep, uint8_t mc) -{ + } else { + fifo_mps = mps; #ifdef USB_HIGH_SPEED - uint8_t type; - - USB_TRACE(3,9, "%s: ep%d mc=%u", __FUNCTION__, ep, mc); - - if (ep == 0 || ep >= EPNUM) { - return 1; - } - - if (mc < 1 || mc > 3) { - return 3; - } - - if ((usbc->DIEPnCONFIG[ep - 1].DIEPCTL & USBC_USBACTEP) == 0) { - return 2; - } - - type = GET_BITFIELD(usbc->DIEPnCONFIG[ep - 1].DIEPCTL, USBC_EPTYPE); - if (type == E_INTERRUPT || type == E_ISOCHRONOUS) { - epn_in_mc[ep - 1] = mc; - return 0; + if (type == E_ISOCHRONOUS || type == E_INTERRUPT) { + if (mps > USB_FIFO_MPS_ISO_SEND) { + fifo_mps = USB_FIFO_MPS_ISO_SEND; + } + epn_in_mc[ep - 1] = 1; } #endif + // Stop ep in + if (usbc->DIEPnCONFIG[ep - 1].DIEPCTL & (USBC_EPENA | USBC_USBACTEP)) { + hal_usb_stop_ep(dir, ep); + } + // Config ep in + usbc->DIEPnCONFIG[ep - 1].DIEPCTL = USBC_EPN_MPS(mps) | USBC_EPTYPE(type) | + USBC_USBACTEP | USBC_EPTXFNUM(ep) | + USBC_SNAK | USBC_SETD0PID; + // Allocate tx fifo + hal_usb_alloc_epn_fifo(ep, fifo_mps); + // Unstall ep in + usbc->DIEPnCONFIG[ep - 1].DIEPCTL &= ~USBC_STALL; + // Unmask ep in interrupt + usbc->DAINTMSK |= USBC_INEPMSK(1 << ep); + } + return 0; +} + +int hal_usb_deactivate_epn(enum EP_DIR dir, uint8_t ep) { + USB_TRACE(3, 9, "%s: %d ep%d", __FUNCTION__, dir, ep); + + if (ep == 0 || ep >= EPNUM) { + return 1; + } + + hal_usb_stop_ep(dir, ep); + + if (dir == EP_OUT) { + usbc->DOEPnCONFIG[ep - 1].DOEPCTL &= ~USBC_USBACTEP; + // Mask ep out interrupt + usbc->DAINTMSK &= ~USBC_OUTEPMSK(1 << ep); + } else { + usbc->DIEPnCONFIG[ep - 1].DIEPCTL &= ~USBC_USBACTEP; + // Mask ep in interrupt + usbc->DAINTMSK &= ~USBC_INEPMSK(1 << ep); + } + + return 0; +} + +// NOTE: Not support send epn mps change, which will involve tx fifo +// reallocation +int hal_usb_update_recv_epn_mps(uint8_t ep, uint16_t mps) { + uint8_t type; + + USB_TRACE(3, 9, "%s: ep%d mps=%u", __FUNCTION__, ep, mps); + + if (ep == 0 || ep >= EPNUM) { + return 1; + } + + if ((usbc->DOEPnCONFIG[ep - 1].DOEPCTL & USBC_USBACTEP) == 0) { + return 2; + } + + hal_usb_stop_ep(EP_OUT, ep); + + usbc->DOEPnCONFIG[ep - 1].DOEPCTL &= ~USBC_USBACTEP; + // Mask ep out interrupt + usbc->DAINTMSK &= ~USBC_OUTEPMSK(1 << ep); + // Config ep out + type = GET_BITFIELD(usbc->DOEPnCONFIG[ep - 1].DOEPCTL, USBC_EPTYPE); + usbc->DOEPnCONFIG[ep - 1].DOEPCTL = USBC_EPN_MPS(mps) | USBC_EPTYPE(type) | + USBC_USBACTEP | USBC_SNAK | USBC_SETD0PID; + // Unmask ep out interrupt + usbc->DAINTMSK |= USBC_OUTEPMSK(1 << ep); + + return 0; +} + +int hal_usb_update_send_epn_mc(uint8_t ep, uint8_t mc) { +#ifdef USB_HIGH_SPEED + uint8_t type; + + USB_TRACE(3, 9, "%s: ep%d mc=%u", __FUNCTION__, ep, mc); + + if (ep == 0 || ep >= EPNUM) { + return 1; + } + + if (mc < 1 || mc > 3) { + return 3; + } + + if ((usbc->DIEPnCONFIG[ep - 1].DIEPCTL & USBC_USBACTEP) == 0) { + return 2; + } + + type = GET_BITFIELD(usbc->DIEPnCONFIG[ep - 1].DIEPCTL, USBC_EPTYPE); + if (type == E_INTERRUPT || type == E_ISOCHRONOUS) { + epn_in_mc[ep - 1] = mc; + return 0; + } +#endif + + return 4; +} + +static void hal_usb_recv_ep0(void) { + USB_FUNC_ENTRY_TRACE(8); + + // Enable EP0 to receive a new setup packet + usbc->DOEPTSIZ0 = USBC_SUPCNT(3) | + USBC_OEPXFERSIZE0(USB_MAX_PACKET_SIZE_CTRL) | + USBC_OEPPKTCNT0; + usbc->DOEPDMA0 = (uint32_t)ep0_out_buffer; + usbc->DOEPINT0 = usbc->DOEPINT0; + usbc->DOEPCTL0 |= USBC_CNAK | USBC_EPENA; +} + +static void hal_usb_send_ep0(const uint8_t *data, uint16_t size) { + USB_TRACE(2, 8, "%s: %d", __FUNCTION__, size); + ASSERT(size <= USB_MAX_PACKET_SIZE_CTRL, "Invalid ep0 send size: %d", size); + + if (data && size) { + memcpy(ep0_in_buffer, data, size); + } + + // Enable EP0 to send one packet + usbc->DIEPTSIZ0 = USBC_IEPXFERSIZE0(size) | USBC_IEPPKTCNT0(1); + usbc->DIEPDMA0 = (uint32_t)ep0_in_buffer; + usbc->DIEPINT0 = usbc->DIEPINT0; + usbc->DIEPCTL0 |= USBC_CNAK | USBC_EPENA; +} + +int hal_usb_recv_epn(uint8_t ep, uint8_t *buffer, uint32_t size) { + uint16_t mps; + uint32_t pkt; + uint32_t xfer; + uint32_t fn = 0; +#ifdef USB_ISO + bool isoEp; + uint32_t lock; +#endif + + USB_TRACE(3, 7, "%s: ep%d %d", __FUNCTION__, ep, size); + + if (device_state != CONFIGURED) { + return 1; + } + if (ep == 0 || ep > EPNUM) { + return 2; + } + if (((uint32_t)buffer & 0x3) != 0) { + return 3; + } + if (epn_out_transfer[ep - 1].data != NULL) { return 4; -} + } + if ((usbc->DOEPnCONFIG[ep - 1].DOEPCTL & USBC_USBACTEP) == 0) { + return 5; + } + mps = GET_BITFIELD(usbc->DOEPnCONFIG[ep - 1].DOEPCTL, USBC_EPN_MPS); + mps = ALIGN(mps, 4); + if (size < mps) { + return 6; + } -static void hal_usb_recv_ep0(void) -{ - USB_FUNC_ENTRY_TRACE(8); + if (size > EPN_MAX_XFERSIZE) { + return 7; + } + pkt = size / mps; + if (pkt > EPN_MAX_PKTCNT) { + return 8; + } + xfer = pkt * mps; + if (size != xfer) { + return 9; + } - // Enable EP0 to receive a new setup packet - usbc->DOEPTSIZ0 = USBC_SUPCNT(3) | USBC_OEPXFERSIZE0(USB_MAX_PACKET_SIZE_CTRL) | USBC_OEPPKTCNT0; - usbc->DOEPDMA0 = (uint32_t)ep0_out_buffer; - usbc->DOEPINT0 = usbc->DOEPINT0; - usbc->DOEPCTL0 |= USBC_CNAK | USBC_EPENA; -} + usbc->DOEPnCONFIG[ep - 1].DOEPTSIZ = + USBC_OEPXFERSIZE(xfer) | USBC_OEPPKTCNT(pkt); + usbc->DOEPnCONFIG[ep - 1].DOEPDMA = (uint32_t)buffer; + usbc->DOEPnCONFIG[ep - 1].DOEPINT = usbc->DOEPnCONFIG[ep - 1].DOEPINT; -static void hal_usb_send_ep0(const uint8_t *data, uint16_t size) -{ - USB_TRACE(2,8, "%s: %d", __FUNCTION__, size); - ASSERT(size <= USB_MAX_PACKET_SIZE_CTRL, "Invalid ep0 send size: %d", size); + epn_out_transfer[ep - 1].data = buffer; + epn_out_transfer[ep - 1].length = xfer; + epn_out_transfer[ep - 1].enabled = true; - if (data && size) { - memcpy(ep0_in_buffer, data, size); - } - - // Enable EP0 to send one packet - usbc->DIEPTSIZ0 = USBC_IEPXFERSIZE0(size) | USBC_IEPPKTCNT0(1); - usbc->DIEPDMA0 = (uint32_t)ep0_in_buffer; - usbc->DIEPINT0 = usbc->DIEPINT0; - usbc->DIEPCTL0 |= USBC_CNAK | USBC_EPENA; -} - -int hal_usb_recv_epn(uint8_t ep, uint8_t *buffer, uint32_t size) -{ - uint16_t mps; - uint32_t pkt; - uint32_t xfer; - uint32_t fn = 0; #ifdef USB_ISO - bool isoEp; - uint32_t lock; + if (GET_BITFIELD(usbc->DOEPnCONFIG[ep - 1].DOEPCTL, USBC_EPTYPE) == + E_ISOCHRONOUS) { + isoEp = true; + } else { + isoEp = false; + } + if (isoEp) { + // Set the frame number in time + lock = int_lock(); + // Get next frame number + if (GET_BITFIELD(usbc->DSTS, USBC_SOFFN) & 0x1) { + fn = USBC_SETD0PID; + } else { + fn = USBC_SETD1PID; + } + } #endif - USB_TRACE(3,7, "%s: ep%d %d", __FUNCTION__, ep, size); + usbc->DOEPnCONFIG[ep - 1].DOEPCTL |= USBC_EPENA | USBC_CNAK | fn; - if (device_state != CONFIGURED) { - return 1; - } - if (ep == 0 || ep > EPNUM) { - return 2; - } - if (((uint32_t)buffer & 0x3) != 0) { - return 3; - } - if (epn_out_transfer[ep - 1].data != NULL) { - return 4; - } - if ((usbc->DOEPnCONFIG[ep - 1].DOEPCTL & USBC_USBACTEP) == 0) { - return 5; - } - mps = GET_BITFIELD(usbc->DOEPnCONFIG[ep - 1].DOEPCTL, USBC_EPN_MPS); - mps = ALIGN(mps, 4); - if (size < mps) { - return 6; - } +#ifdef USB_ISO + if (isoEp) { + int_unlock(lock); + } +#endif - if (size > EPN_MAX_XFERSIZE) { - return 7; - } - pkt = size / mps; + return 0; +} + +int hal_usb_send_epn(uint8_t ep, const uint8_t *buffer, uint32_t size, + enum ZLP_STATE zlp) { + uint16_t mps; + uint8_t type; + uint32_t pkt; + uint32_t fn = 0; +#ifdef USB_ISO + bool isoEp; + uint32_t lock; +#endif + + USB_TRACE(3, 6, "%s: ep%d %d", __FUNCTION__, ep, size); + + if (device_state != CONFIGURED) { + return 1; + } + if (ep == 0 || ep > EPNUM) { + return 2; + } + if (((uint32_t)buffer & 0x3) != 0) { + return 3; + } + if (epn_in_transfer[ep - 1].data != NULL) { + return 4; + } + if ((usbc->DIEPnCONFIG[ep - 1].DIEPCTL & USBC_USBACTEP) == 0) { + return 5; + } + if (size > EPN_MAX_XFERSIZE) { + return 7; + } + mps = GET_BITFIELD(usbc->DIEPnCONFIG[ep - 1].DIEPCTL, USBC_EPN_MPS); + if (size <= mps) { + // Also taking care of 0 size packet + pkt = 1; + } else { + // If mps is not aligned in 4 bytes, application should add padding at the + // end of each packet to make sure a new packet always starts at 4-byte + // boundary + pkt = (size + mps - 1) / mps; if (pkt > EPN_MAX_PKTCNT) { - return 8; - } - xfer = pkt * mps; - if (size != xfer) { - return 9; + return 8; } + } - usbc->DOEPnCONFIG[ep - 1].DOEPTSIZ = USBC_OEPXFERSIZE(xfer) | USBC_OEPPKTCNT(pkt); - usbc->DOEPnCONFIG[ep - 1].DOEPDMA = (uint32_t)buffer; - usbc->DOEPnCONFIG[ep - 1].DOEPINT = usbc->DOEPnCONFIG[ep - 1].DOEPINT; - - epn_out_transfer[ep - 1].data = buffer; - epn_out_transfer[ep - 1].length = xfer; - epn_out_transfer[ep - 1].enabled = true; - -#ifdef USB_ISO - if (GET_BITFIELD(usbc->DOEPnCONFIG[ep - 1].DOEPCTL, USBC_EPTYPE) == E_ISOCHRONOUS) { - isoEp = true; - } else { - isoEp = false; - } - if (isoEp) { - // Set the frame number in time - lock = int_lock(); - // Get next frame number - if (GET_BITFIELD(usbc->DSTS, USBC_SOFFN) & 0x1) { - fn = USBC_SETD0PID; - } else { - fn = USBC_SETD1PID; - } - } -#endif - - usbc->DOEPnCONFIG[ep - 1].DOEPCTL |= USBC_EPENA | USBC_CNAK | fn; - -#ifdef USB_ISO - if (isoEp) { - int_unlock(lock); - } -#endif - - return 0; -} - -int hal_usb_send_epn(uint8_t ep, const uint8_t *buffer, uint32_t size, enum ZLP_STATE zlp) -{ - uint16_t mps; - uint8_t type; - uint32_t pkt; - uint32_t fn = 0; -#ifdef USB_ISO - bool isoEp; - uint32_t lock; -#endif - - USB_TRACE(3,6, "%s: ep%d %d", __FUNCTION__, ep, size); - - if (device_state != CONFIGURED) { - return 1; - } - if (ep == 0 || ep > EPNUM) { - return 2; - } - if (((uint32_t)buffer & 0x3) != 0) { - return 3; - } - if (epn_in_transfer[ep - 1].data != NULL) { - return 4; - } - if ((usbc->DIEPnCONFIG[ep - 1].DIEPCTL & USBC_USBACTEP) == 0) { - return 5; - } - if (size > EPN_MAX_XFERSIZE) { - return 7; - } - mps = GET_BITFIELD(usbc->DIEPnCONFIG[ep - 1].DIEPCTL, USBC_EPN_MPS); - if (size <= mps) { - // Also taking care of 0 size packet - pkt = 1; - } else { - // If mps is not aligned in 4 bytes, application should add padding at the end of each packet to - // make sure a new packet always starts at 4-byte boundary - pkt = (size + mps - 1) / mps; - if (pkt > EPN_MAX_PKTCNT) { - return 8; - } - } - - type = GET_BITFIELD(usbc->DIEPnCONFIG[ep - 1].DIEPCTL, USBC_EPTYPE); - if (type == E_INTERRUPT || type == E_ISOCHRONOUS) { + type = GET_BITFIELD(usbc->DIEPnCONFIG[ep - 1].DIEPCTL, USBC_EPTYPE); + if (type == E_INTERRUPT || type == E_ISOCHRONOUS) { #ifdef USB_HIGH_SPEED - if (pkt != epn_in_mc[ep - 1] && (pkt % epn_in_mc[ep - 1])) { - // MC is the pkt cnt must be sent in every (micro)frame. - // The total pkt cnt should be integral multiple of MC value. - return 9; - } + if (pkt != epn_in_mc[ep - 1] && (pkt % epn_in_mc[ep - 1])) { + // MC is the pkt cnt must be sent in every (micro)frame. + // The total pkt cnt should be integral multiple of MC value. + return 9; + } #endif - // Never send a zero length packet at the end of transfer - epn_in_transfer[ep - 1].zero_len_pkt = false; - usbc->DIEPnCONFIG[ep - 1].DIEPTSIZ = USBC_IEPXFERSIZE(size) | USBC_IEPPKTCNT(pkt) | + // Never send a zero length packet at the end of transfer + epn_in_transfer[ep - 1].zero_len_pkt = false; + usbc->DIEPnCONFIG[ep - 1].DIEPTSIZ = USBC_IEPXFERSIZE(size) | + USBC_IEPPKTCNT(pkt) | #ifdef USB_HIGH_SPEED - USBC_MC(epn_in_mc[ep - 1]); + USBC_MC(epn_in_mc[ep - 1]); #else - USBC_MC(1); + USBC_MC(1); #endif + } else { + // Check if a zero length packet is needed at the end of transfer + if (zlp == ZLP_AUTO) { + epn_in_transfer[ep - 1].zero_len_pkt = ((size % mps) == 0); } else { - // Check if a zero length packet is needed at the end of transfer - if (zlp == ZLP_AUTO) { - epn_in_transfer[ep - 1].zero_len_pkt = ((size % mps) == 0); - } else { - epn_in_transfer[ep - 1].zero_len_pkt = false; - } - usbc->DIEPnCONFIG[ep - 1].DIEPTSIZ = USBC_IEPXFERSIZE(size) | USBC_IEPPKTCNT(pkt); + epn_in_transfer[ep - 1].zero_len_pkt = false; } - usbc->DIEPnCONFIG[ep - 1].DIEPDMA = (uint32_t)buffer; - usbc->DIEPnCONFIG[ep - 1].DIEPINT = usbc->DIEPnCONFIG[ep - 1].DIEPINT; + usbc->DIEPnCONFIG[ep - 1].DIEPTSIZ = + USBC_IEPXFERSIZE(size) | USBC_IEPPKTCNT(pkt); + } + usbc->DIEPnCONFIG[ep - 1].DIEPDMA = (uint32_t)buffer; + usbc->DIEPnCONFIG[ep - 1].DIEPINT = usbc->DIEPnCONFIG[ep - 1].DIEPINT; - epn_in_transfer[ep - 1].data = buffer; - epn_in_transfer[ep - 1].length = size; - epn_in_transfer[ep - 1].pkt_cnt = pkt; - epn_in_transfer[ep - 1].enabled = true; + epn_in_transfer[ep - 1].data = buffer; + epn_in_transfer[ep - 1].length = size; + epn_in_transfer[ep - 1].pkt_cnt = pkt; + epn_in_transfer[ep - 1].enabled = true; #ifdef USB_ISO - if (GET_BITFIELD(usbc->DIEPnCONFIG[ep - 1].DIEPCTL, USBC_EPTYPE) == E_ISOCHRONOUS) { - isoEp = true; + if (GET_BITFIELD(usbc->DIEPnCONFIG[ep - 1].DIEPCTL, USBC_EPTYPE) == + E_ISOCHRONOUS) { + isoEp = true; + } else { + isoEp = false; + } + if (isoEp) { + // Set the frame number in time + lock = int_lock(); + // Get next frame number + if (GET_BITFIELD(usbc->DSTS, USBC_SOFFN) & 0x1) { + fn = USBC_SETD0PID; } else { - isoEp = false; - } - if (isoEp) { - // Set the frame number in time - lock = int_lock(); - // Get next frame number - if (GET_BITFIELD(usbc->DSTS, USBC_SOFFN) & 0x1) { - fn = USBC_SETD0PID; - } else { - fn = USBC_SETD1PID; - } + fn = USBC_SETD1PID; } + } #endif - usbc->DIEPnCONFIG[ep - 1].DIEPCTL |= USBC_EPENA | USBC_CNAK | fn; + usbc->DIEPnCONFIG[ep - 1].DIEPCTL |= USBC_EPENA | USBC_CNAK | fn; #ifdef USB_ISO - if (isoEp) { - int_unlock(lock); - } + if (isoEp) { + int_unlock(lock); + } #endif - return 0; + return 0; } -static void hal_usb_recv_epn_complete(uint8_t ep, uint32_t statusEp) -{ - uint8_t *data; - uint32_t size; - uint32_t doeptsiz; - enum XFER_COMPL_STATE state = XFER_COMPL_SUCCESS; +static void hal_usb_recv_epn_complete(uint8_t ep, uint32_t statusEp) { + uint8_t *data; + uint32_t size; + uint32_t doeptsiz; + enum XFER_COMPL_STATE state = XFER_COMPL_SUCCESS; - USB_TRACE(3,5, "%s: ep%d 0x%08x", __FUNCTION__, ep, statusEp); + USB_TRACE(3, 5, "%s: ep%d 0x%08x", __FUNCTION__, ep, statusEp); - if (!epn_out_transfer[ep - 1].enabled) { - return; - } + if (!epn_out_transfer[ep - 1].enabled) { + return; + } - doeptsiz = usbc->DOEPnCONFIG[ep - 1].DOEPTSIZ; + doeptsiz = usbc->DOEPnCONFIG[ep - 1].DOEPTSIZ; - data = epn_out_transfer[ep - 1].data; - size = GET_BITFIELD(doeptsiz, USBC_OEPXFERSIZE); - ASSERT(size <= epn_out_transfer[ep - 1].length, - "Invalid xfer size: size=%d, len=%d", size, epn_out_transfer[ep - 1].length); - size = epn_out_transfer[ep - 1].length - size; + data = epn_out_transfer[ep - 1].data; + size = GET_BITFIELD(doeptsiz, USBC_OEPXFERSIZE); + ASSERT(size <= epn_out_transfer[ep - 1].length, + "Invalid xfer size: size=%d, len=%d", size, + epn_out_transfer[ep - 1].length); + size = epn_out_transfer[ep - 1].length - size; #ifdef USB_ISO - uint32_t doepctl = usbc->DOEPnCONFIG[ep - 1].DOEPCTL; + uint32_t doepctl = usbc->DOEPnCONFIG[ep - 1].DOEPCTL; - if (GET_BITFIELD(doepctl, USBC_EPTYPE) == E_ISOCHRONOUS) { + if (GET_BITFIELD(doepctl, USBC_EPTYPE) == E_ISOCHRONOUS) { #if (USB_ISO_INTERVAL == 1) #if 1 - if (GET_BITFIELD(doeptsiz, USBC_OEPPKTCNT) != 0) { - state = XFER_COMPL_ERROR; - } -#else - uint32_t rxdpid = GET_BITFIELD(doeptsiz, USBC_RXDPID); - uint32_t pkt = epn_out_transfer[ep - 1].length / GET_BITFIELD(doepctl, USBC_EPN_MPS) - - GET_BITFIELD(doeptsiz, USBC_OEPPKTCNT); - if ((rxdpid == DATA_PID_DATA0 && pkt != 1) || - (rxdpid == DATA_PID_DATA1 && pkt != 2) || - (rxdpid == DATA_PID_DATA2 && pkt != 3)) { - state = XFER_COMPL_ERROR; - } -#endif -#else // USB_ISO_INTERVAL != 1 - if (statusEp & USBC_PKTDRPSTS) { - state = XFER_COMPL_ERROR; - } -#endif // USB_ISO_INTERVAL != 1 + if (GET_BITFIELD(doeptsiz, USBC_OEPPKTCNT) != 0) { + state = XFER_COMPL_ERROR; } +#else + uint32_t rxdpid = GET_BITFIELD(doeptsiz, USBC_RXDPID); + uint32_t pkt = + epn_out_transfer[ep - 1].length / GET_BITFIELD(doepctl, USBC_EPN_MPS) - + GET_BITFIELD(doeptsiz, USBC_OEPPKTCNT); + if ((rxdpid == DATA_PID_DATA0 && pkt != 1) || + (rxdpid == DATA_PID_DATA1 && pkt != 2) || + (rxdpid == DATA_PID_DATA2 && pkt != 3)) { + state = XFER_COMPL_ERROR; + } +#endif +#else // USB_ISO_INTERVAL != 1 + if (statusEp & USBC_PKTDRPSTS) { + state = XFER_COMPL_ERROR; + } +#endif // USB_ISO_INTERVAL != 1 + } #endif // USB_ISO - // Clear epn_out_transfer[] before invoking the callback, - // so that ep can be restarted in the callback - memset(&epn_out_transfer[ep - 1], 0, sizeof(epn_out_transfer[0])); + // Clear epn_out_transfer[] before invoking the callback, + // so that ep can be restarted in the callback + memset(&epn_out_transfer[ep - 1], 0, sizeof(epn_out_transfer[0])); - if (callbacks.epn_recv_compl[ep - 1]) { - callbacks.epn_recv_compl[ep - 1](data, size, state); - } + if (callbacks.epn_recv_compl[ep - 1]) { + callbacks.epn_recv_compl[ep - 1](data, size, state); + } } -static void hal_usb_send_epn_complete(uint8_t ep, uint32_t statusEp) -{ - const uint8_t *data; - uint32_t size; - uint16_t pkt, mps; - uint8_t type; - uint32_t mc; - enum XFER_COMPL_STATE state = XFER_COMPL_SUCCESS; +static void hal_usb_send_epn_complete(uint8_t ep, uint32_t statusEp) { + const uint8_t *data; + uint32_t size; + uint16_t pkt, mps; + uint8_t type; + uint32_t mc; + enum XFER_COMPL_STATE state = XFER_COMPL_SUCCESS; - USB_TRACE(3,4, "%s: ep%d 0x%08x", __FUNCTION__, ep, statusEp); + USB_TRACE(3, 4, "%s: ep%d 0x%08x", __FUNCTION__, ep, statusEp); - if (!epn_in_transfer[ep - 1].enabled) { - return; - } + if (!epn_in_transfer[ep - 1].enabled) { + return; + } - if ((statusEp & USBC_XFERCOMPLMSK) == 0) { - state = XFER_COMPL_ERROR; - } + if ((statusEp & USBC_XFERCOMPLMSK) == 0) { + state = XFER_COMPL_ERROR; + } - pkt = GET_BITFIELD(usbc->DIEPnCONFIG[ep - 1].DIEPTSIZ, USBC_IEPPKTCNT); - if (pkt != 0) { - state = XFER_COMPL_ERROR; - mps = GET_BITFIELD(usbc->DIEPnCONFIG[ep - 1].DIEPCTL, USBC_EPN_MPS); - ASSERT(pkt <= epn_in_transfer[ep - 1].pkt_cnt, "Invalid pkt cnt: pkt=%d, pkt_cnt=%d", - pkt, epn_in_transfer[ep - 1].pkt_cnt); - size = (epn_in_transfer[ep - 1].pkt_cnt - pkt) * mps; - } else { - size = epn_in_transfer[ep - 1].length; - } + pkt = GET_BITFIELD(usbc->DIEPnCONFIG[ep - 1].DIEPTSIZ, USBC_IEPPKTCNT); + if (pkt != 0) { + state = XFER_COMPL_ERROR; + mps = GET_BITFIELD(usbc->DIEPnCONFIG[ep - 1].DIEPCTL, USBC_EPN_MPS); + ASSERT(pkt <= epn_in_transfer[ep - 1].pkt_cnt, + "Invalid pkt cnt: pkt=%d, pkt_cnt=%d", pkt, + epn_in_transfer[ep - 1].pkt_cnt); + size = (epn_in_transfer[ep - 1].pkt_cnt - pkt) * mps; + } else { + size = epn_in_transfer[ep - 1].length; + } - if (state == XFER_COMPL_SUCCESS && epn_in_transfer[ep - 1].zero_len_pkt) { - epn_in_transfer[ep - 1].zero_len_pkt = false; - // Send the last zero length packet, except for isochronous/interrupt endpoints - type = GET_BITFIELD(usbc->DIEPnCONFIG[ep - 1].DIEPCTL, USBC_EPTYPE); - if (type == E_INTERRUPT || type == E_ISOCHRONOUS) { + if (state == XFER_COMPL_SUCCESS && epn_in_transfer[ep - 1].zero_len_pkt) { + epn_in_transfer[ep - 1].zero_len_pkt = false; + // Send the last zero length packet, except for isochronous/interrupt + // endpoints + type = GET_BITFIELD(usbc->DIEPnCONFIG[ep - 1].DIEPCTL, USBC_EPTYPE); + if (type == E_INTERRUPT || type == E_ISOCHRONOUS) { #ifdef USB_HIGH_SPEED - mc = USBC_MC(epn_in_mc[ep - 1]); + mc = USBC_MC(epn_in_mc[ep - 1]); #else - mc = USBC_MC(1); + mc = USBC_MC(1); #endif - } else { - mc = 0; - } - usbc->DIEPnCONFIG[ep - 1].DIEPTSIZ = USBC_IEPXFERSIZE(0) | USBC_IEPPKTCNT(1) | mc; - usbc->DIEPnCONFIG[ep - 1].DIEPCTL |= USBC_EPENA | USBC_CNAK; } else { - data = epn_in_transfer[ep - 1].data; + mc = 0; + } + usbc->DIEPnCONFIG[ep - 1].DIEPTSIZ = + USBC_IEPXFERSIZE(0) | USBC_IEPPKTCNT(1) | mc; + usbc->DIEPnCONFIG[ep - 1].DIEPCTL |= USBC_EPENA | USBC_CNAK; + } else { + data = epn_in_transfer[ep - 1].data; - // Clear epn_in_transfer[] before invoking the callback, - // so that ep can be restarted in the callback - memset(&epn_in_transfer[ep - 1], 0, sizeof(epn_in_transfer[0])); + // Clear epn_in_transfer[] before invoking the callback, + // so that ep can be restarted in the callback + memset(&epn_in_transfer[ep - 1], 0, sizeof(epn_in_transfer[0])); - if (state != XFER_COMPL_SUCCESS) { - // The callback will not be invoked when stopping ep, - // for epn_in_transfer[] has been cleared - hal_usb_stop_ep(EP_IN, ep); - } - - if (callbacks.epn_send_compl[ep - 1]) { - callbacks.epn_send_compl[ep - 1](data, size, state); - } + if (state != XFER_COMPL_SUCCESS) { + // The callback will not be invoked when stopping ep, + // for epn_in_transfer[] has been cleared + hal_usb_stop_ep(EP_IN, ep); } + if (callbacks.epn_send_compl[ep - 1]) { + callbacks.epn_send_compl[ep - 1](data, size, state); + } + } } -static bool requestSetAddress(void) -{ - USB_FUNC_ENTRY_TRACE(25); +static bool requestSetAddress(void) { + USB_FUNC_ENTRY_TRACE(25); - /* Set the device address */ - usbc->DCFG = SET_BITFIELD(usbc->DCFG, USBC_DEVADDR, ep0_transfer.setup_pkt.wValue); + /* Set the device address */ + usbc->DCFG = + SET_BITFIELD(usbc->DCFG, USBC_DEVADDR, ep0_transfer.setup_pkt.wValue); + ep0_transfer.stage = STATUS_IN_STAGE; + + if (ep0_transfer.setup_pkt.wValue == 0) { + device_state = DEFAULT; + } else { + device_state = ADDRESS; + } + + return true; +} + +static bool requestSetConfiguration(void) { + USB_FUNC_ENTRY_TRACE(24); + + device_cfg = ep0_transfer.setup_pkt.wValue; + /* Set the device configuration */ + if (device_cfg == 0) { + /* Not configured */ + device_state = ADDRESS; + } else { + if (callbacks.setcfg && callbacks.setcfg(device_cfg)) { + /* Valid configuration */ + device_state = CONFIGURED; + ep0_transfer.stage = STATUS_IN_STAGE; + } else { + return false; + } + } + + return true; +} + +static bool requestGetConfiguration(void) { + USB_FUNC_ENTRY_TRACE(23); + + /* Send the device configuration */ + ep0_transfer.data = &device_cfg; + ep0_transfer.length = sizeof(device_cfg); + ep0_transfer.stage = DATA_IN_STAGE; + return true; +} + +static bool requestGetInterface(void) { + USB_FUNC_ENTRY_TRACE(22); + + /* Return the selected alternate setting for an interface */ + if (device_state != CONFIGURED) { + return false; + } + + /* Send the alternate setting */ + ep0_transfer.setup_pkt.wIndex = currentInterface; + ep0_transfer.data = ¤tAlternate; + ep0_transfer.length = sizeof(currentAlternate); + ep0_transfer.stage = DATA_IN_STAGE; + return true; +} + +static bool requestSetInterface(void) { + bool success = false; + + USB_FUNC_ENTRY_TRACE(21); + + if (callbacks.setitf && callbacks.setitf(ep0_transfer.setup_pkt.wIndex, + ep0_transfer.setup_pkt.wValue)) { + success = true; + currentInterface = ep0_transfer.setup_pkt.wIndex; + currentAlternate = ep0_transfer.setup_pkt.wValue; ep0_transfer.stage = STATUS_IN_STAGE; - - if (ep0_transfer.setup_pkt.wValue == 0) - { - device_state = DEFAULT; - } - else - { - device_state = ADDRESS; - } - - return true; + } + return success; } -static bool requestSetConfiguration(void) -{ - USB_FUNC_ENTRY_TRACE(24); +static bool requestSetFeature(void) { + bool success = false; - device_cfg = ep0_transfer.setup_pkt.wValue; - /* Set the device configuration */ - if (device_cfg == 0) - { - /* Not configured */ - device_state = ADDRESS; + USB_FUNC_ENTRY_TRACE(20); + + if (device_state != CONFIGURED) { + /* Endpoint or interface must be zero */ + if (ep0_transfer.setup_pkt.wIndex != 0) { + return false; } - else - { - if (callbacks.setcfg && callbacks.setcfg(device_cfg)) - { - /* Valid configuration */ - device_state = CONFIGURED; - ep0_transfer.stage = STATUS_IN_STAGE; - } - else - { - return false; - } + } + + switch (ep0_transfer.setup_pkt.bmRequestType.recipient) { + case DEVICE_RECIPIENT: + if (ep0_transfer.setup_pkt.wValue == TEST_MODE) { + // TODO: Check test mode + device_test_mode = (ep0_transfer.setup_pkt.wIndex >> 8); + success = true; } - - return true; -} - -static bool requestGetConfiguration(void) -{ - USB_FUNC_ENTRY_TRACE(23); - - /* Send the device configuration */ - ep0_transfer.data = &device_cfg; - ep0_transfer.length = sizeof(device_cfg); - ep0_transfer.stage = DATA_IN_STAGE; - return true; -} - -static bool requestGetInterface(void) -{ - USB_FUNC_ENTRY_TRACE(22); - - /* Return the selected alternate setting for an interface */ - if (device_state != CONFIGURED) - { - return false; - } - - /* Send the alternate setting */ - ep0_transfer.setup_pkt.wIndex = currentInterface; - ep0_transfer.data = ¤tAlternate; - ep0_transfer.length = sizeof(currentAlternate); - ep0_transfer.stage = DATA_IN_STAGE; - return true; -} - -static bool requestSetInterface(void) -{ - bool success = false; - - USB_FUNC_ENTRY_TRACE(21); - - if(callbacks.setitf && callbacks.setitf(ep0_transfer.setup_pkt.wIndex, ep0_transfer.setup_pkt.wValue)) - { +#ifdef USB_SUSPEND + else if (ep0_transfer.setup_pkt.wValue == DEVICE_REMOTE_WAKEUP) { + if (callbacks.set_remote_wakeup) { + callbacks.set_remote_wakeup(1); + device_pwr_wkup_status |= DEVICE_STATUS_REMOTE_WAKEUP; success = true; - currentInterface = ep0_transfer.setup_pkt.wIndex; - currentAlternate = ep0_transfer.setup_pkt.wValue; - ep0_transfer.stage = STATUS_IN_STAGE; + } } - return success; +#endif + break; + case ENDPOINT_RECIPIENT: + if (ep0_transfer.setup_pkt.wValue == ENDPOINT_HALT) { + // TODO: Check endpoint number + hal_usb_stall_ep((ep0_transfer.setup_pkt.wIndex & 0x80) ? EP_IN : EP_OUT, + ep0_transfer.setup_pkt.wIndex & 0xF); + if (callbacks.state_change) { + callbacks.state_change(HAL_USB_EVENT_STALL, + ep0_transfer.setup_pkt.wIndex & 0xFF); + } + success = true; + } + break; + default: + break; + } + + ep0_transfer.stage = STATUS_IN_STAGE; + + return success; } -static bool requestSetFeature(void) -{ - bool success = false; +static bool requestClearFeature(void) { + bool success = false; - USB_FUNC_ENTRY_TRACE(20); + USB_FUNC_ENTRY_TRACE(19); - if (device_state != CONFIGURED) - { - /* Endpoint or interface must be zero */ - if (ep0_transfer.setup_pkt.wIndex != 0) - { - return false; - } + if (device_state != CONFIGURED) { + /* Endpoint or interface must be zero */ + if (ep0_transfer.setup_pkt.wIndex != 0) { + return false; } + } - switch (ep0_transfer.setup_pkt.bmRequestType.recipient) - { - case DEVICE_RECIPIENT: - if (ep0_transfer.setup_pkt.wValue == TEST_MODE) { - // TODO: Check test mode - device_test_mode = (ep0_transfer.setup_pkt.wIndex >> 8); - success = true; - } + switch (ep0_transfer.setup_pkt.bmRequestType.recipient) { + case DEVICE_RECIPIENT: #ifdef USB_SUSPEND - else if (ep0_transfer.setup_pkt.wValue == DEVICE_REMOTE_WAKEUP) { - if (callbacks.set_remote_wakeup) { - callbacks.set_remote_wakeup(1); - device_pwr_wkup_status |= DEVICE_STATUS_REMOTE_WAKEUP; - success = true; - } - } + if (ep0_transfer.setup_pkt.wValue == DEVICE_REMOTE_WAKEUP) { + if (callbacks.set_remote_wakeup) { + callbacks.set_remote_wakeup(0); + device_pwr_wkup_status &= ~DEVICE_STATUS_REMOTE_WAKEUP; + success = true; + } + } #endif - break; - case ENDPOINT_RECIPIENT: - if (ep0_transfer.setup_pkt.wValue == ENDPOINT_HALT) - { - // TODO: Check endpoint number - hal_usb_stall_ep((ep0_transfer.setup_pkt.wIndex & 0x80) ? EP_IN : EP_OUT, - ep0_transfer.setup_pkt.wIndex & 0xF); - if (callbacks.state_change) { - callbacks.state_change(HAL_USB_EVENT_STALL, ep0_transfer.setup_pkt.wIndex & 0xFF); - } - success = true; - } - break; - default: - break; + break; + case ENDPOINT_RECIPIENT: + /* TODO: We should check that the endpoint number is valid */ + if (ep0_transfer.setup_pkt.wValue == ENDPOINT_HALT) { + hal_usb_unstall_ep((ep0_transfer.setup_pkt.wIndex & 0x80) ? EP_IN + : EP_OUT, + ep0_transfer.setup_pkt.wIndex & 0xF); + if (callbacks.state_change) { + callbacks.state_change(HAL_USB_EVENT_UNSTALL, + ep0_transfer.setup_pkt.wIndex & 0xFF); + } + success = true; } + break; + default: + break; + } - ep0_transfer.stage = STATUS_IN_STAGE; + ep0_transfer.stage = STATUS_IN_STAGE; - return success; + return success; } -static bool requestClearFeature(void) -{ - bool success = false; +static bool requestGetStatus(void) { + static uint16_t status; + bool success = false; - USB_FUNC_ENTRY_TRACE(19); + USB_FUNC_ENTRY_TRACE(18); - if (device_state != CONFIGURED) - { - /* Endpoint or interface must be zero */ - if (ep0_transfer.setup_pkt.wIndex != 0) - { - return false; - } + if (device_state != CONFIGURED) { + /* Endpoint or interface must be zero */ + if (ep0_transfer.setup_pkt.wIndex != 0) { + return false; } + } - switch (ep0_transfer.setup_pkt.bmRequestType.recipient) - { - case DEVICE_RECIPIENT: -#ifdef USB_SUSPEND - if (ep0_transfer.setup_pkt.wValue == DEVICE_REMOTE_WAKEUP) { - if (callbacks.set_remote_wakeup) { - callbacks.set_remote_wakeup(0); - device_pwr_wkup_status &= ~DEVICE_STATUS_REMOTE_WAKEUP; - success = true; - } - } -#endif - break; - case ENDPOINT_RECIPIENT: - /* TODO: We should check that the endpoint number is valid */ - if (ep0_transfer.setup_pkt.wValue == ENDPOINT_HALT) - { - hal_usb_unstall_ep((ep0_transfer.setup_pkt.wIndex & 0x80) ? EP_IN : EP_OUT, - ep0_transfer.setup_pkt.wIndex & 0xF); - if (callbacks.state_change) { - callbacks.state_change(HAL_USB_EVENT_UNSTALL, ep0_transfer.setup_pkt.wIndex & 0xFF); - } - success = true; - } - break; - default: - break; - } - - ep0_transfer.stage = STATUS_IN_STAGE; - - return success; -} - -static bool requestGetStatus(void) -{ - static uint16_t status; - bool success = false; - - USB_FUNC_ENTRY_TRACE(18); - - if (device_state != CONFIGURED) - { - /* Endpoint or interface must be zero */ - if (ep0_transfer.setup_pkt.wIndex != 0) - { - return false; - } - } - - switch (ep0_transfer.setup_pkt.bmRequestType.recipient) - { - case DEVICE_RECIPIENT: - status = device_pwr_wkup_status; - success = true; - break; - case INTERFACE_RECIPIENT: - status = 0; - success = true; - break; - case ENDPOINT_RECIPIENT: - /* TODO: We should check that the endpoint number is valid */ - if (hal_usb_get_ep_stall_state((ep0_transfer.setup_pkt.wIndex & 0x80) ? EP_IN : EP_OUT, - ep0_transfer.setup_pkt.wIndex & 0xF)) - { - status = ENDPOINT_STATUS_HALT; - } - else - { - status = 0; - } - success = true; - break; - default: - break; - } - - if (success) - { - /* Send the status */ - ep0_transfer.data = (uint8_t *)&status; /* Assumes little endian */ - ep0_transfer.length = sizeof(status); - ep0_transfer.stage = DATA_IN_STAGE; - } - - return success; -} - -static bool requestGetDescriptor(void) -{ - bool success = false; - uint8_t type; - uint8_t index; - uint8_t *desc; - - type = DESCRIPTOR_TYPE(ep0_transfer.setup_pkt.wValue); - index = DESCRIPTOR_INDEX(ep0_transfer.setup_pkt.wValue); - - USB_TRACE(3,3, "%s: %d %d", __FUNCTION__, type, index); - - switch (type) - { - case DEVICE_DESCRIPTOR: - desc = (uint8_t *)callbacks.device_desc(type); - if (desc != NULL) - { - if ((desc[0] == DEVICE_DESCRIPTOR_LENGTH) \ - && (desc[1] == DEVICE_DESCRIPTOR)) - { - ep0_transfer.length = desc[0]; - ep0_transfer.data = desc; - success = true; - } - } - break; - case CONFIGURATION_DESCRIPTOR: - desc = (uint8_t *)callbacks.cfg_desc(index); - if (desc != NULL) - { - if ((desc[0] == CONFIGURATION_DESCRIPTOR_LENGTH) \ - && (desc[1] == CONFIGURATION_DESCRIPTOR)) - { - /* Get wTotalLength */ - ep0_transfer.length = desc[2] | (desc[3] << 8); - ep0_transfer.data = desc; - // Get self-powered status - if ((desc[7] >> 6) & 0x01) { - device_pwr_wkup_status |= DEVICE_STATUS_SELF_POWERED; - } else { - device_pwr_wkup_status &= ~DEVICE_STATUS_SELF_POWERED; - } - success = true; - } - } - break; - case STRING_DESCRIPTOR: - ep0_transfer.data = (uint8_t *)callbacks.string_desc(index); - if (ep0_transfer.data) { - ep0_transfer.length = ep0_transfer.data[0]; - success = true; - } - break; - case INTERFACE_DESCRIPTOR: - case ENDPOINT_DESCRIPTOR: - /* TODO: Support is optional, not implemented here */ - break; - case QUALIFIER_DESCRIPTOR: -#ifdef USB_HIGH_SPEED - desc = (uint8_t *)callbacks.device_desc(type); - if (desc != NULL) - { - if (desc[0] == QUALIFIER_DESCRIPTOR_LENGTH && desc[1] == type) - { - ep0_transfer.length = desc[0]; - ep0_transfer.data = desc; - success = true; - } - } -#endif - break; - case BOS_DESCRIPTOR: -#ifdef USB_HIGH_SPEED - desc = (uint8_t *)callbacks.device_desc(type); - if (desc != NULL) - { - if (desc[0] == BOS_DESCRIPTOR_LENGTH && desc[1] == type) - { - // Total length - ep0_transfer.length = desc[2]; - ep0_transfer.data = desc; - success = true; - } - } -#endif - break; - default: - // Might be a class or vendor specific descriptor, which - // should be handled in setuprecv callback - USB_TRACE(1,0, "*** Error: Unknown desc type: %d", type); - break; - } - - if (success) { - ep0_transfer.stage = DATA_IN_STAGE; - } - - return success; -} - -static void hal_usb_reset_all_transfers(void) -{ - int ep; - - USB_FUNC_ENTRY_TRACE(31); - - for (ep = 1; ep < EPNUM; ep++) { - reset_epn_out_transfer(ep); - reset_epn_in_transfer(ep); - } -} - -static bool hal_usb_handle_setup(void) -{ - bool success = false; - enum DEVICE_STATE old_state; - - USB_FUNC_ENTRY_TRACE(17); - - old_state = device_state; - - /* Process standard requests */ - if (ep0_transfer.setup_pkt.bmRequestType.type == STANDARD_TYPE) - { - switch (ep0_transfer.setup_pkt.bRequest) - { - case GET_STATUS: - success = requestGetStatus(); - break; - case CLEAR_FEATURE: - success = requestClearFeature(); - break; - case SET_FEATURE: - success = requestSetFeature(); - break; - case SET_ADDRESS: - success = requestSetAddress(); - break; - case GET_DESCRIPTOR: - success = requestGetDescriptor(); - break; - case SET_DESCRIPTOR: - /* TODO: Support is optional, not implemented here */ - success = false; - break; - case GET_CONFIGURATION: - success = requestGetConfiguration(); - break; - case SET_CONFIGURATION: - success = requestSetConfiguration(); - break; - case GET_INTERFACE: - success = requestGetInterface(); - break; - case SET_INTERFACE: - success = requestSetInterface(); - break; - default: - break; - } - } - - if (old_state == CONFIGURED && device_state != CONFIGURED) { - hal_usb_reset_all_transfers(); - } - - return success; -} - -static int hal_usb_ep0_setup_stage(uint32_t statusEp) -{ - uint8_t *data; - uint8_t setup_cnt; - uint16_t pkt_len; - - // Skip the check on IN/OUT tokens - usbc->DOEPMSK &= ~USBC_OUTTKNEPDISMSK; - usbc->DIEPMSK &= ~USBC_INTKNTXFEMPMSK; - - if (statusEp & USBC_BACK2BACKSETUP) { - data = (uint8_t *)(usbc->DOEPDMA0 - 8); + switch (ep0_transfer.setup_pkt.bmRequestType.recipient) { + case DEVICE_RECIPIENT: + status = device_pwr_wkup_status; + success = true; + break; + case INTERFACE_RECIPIENT: + status = 0; + success = true; + break; + case ENDPOINT_RECIPIENT: + /* TODO: We should check that the endpoint number is valid */ + if (hal_usb_get_ep_stall_state( + (ep0_transfer.setup_pkt.wIndex & 0x80) ? EP_IN : EP_OUT, + ep0_transfer.setup_pkt.wIndex & 0xF)) { + status = ENDPOINT_STATUS_HALT; } else { - setup_cnt = GET_BITFIELD(usbc->DOEPTSIZ0, USBC_SUPCNT); - if (setup_cnt >= 3) { - setup_cnt = 2; + status = 0; + } + success = true; + break; + default: + break; + } + + if (success) { + /* Send the status */ + ep0_transfer.data = (uint8_t *)&status; /* Assumes little endian */ + ep0_transfer.length = sizeof(status); + ep0_transfer.stage = DATA_IN_STAGE; + } + + return success; +} + +static bool requestGetDescriptor(void) { + bool success = false; + uint8_t type; + uint8_t index; + uint8_t *desc; + + type = DESCRIPTOR_TYPE(ep0_transfer.setup_pkt.wValue); + index = DESCRIPTOR_INDEX(ep0_transfer.setup_pkt.wValue); + + USB_TRACE(3, 3, "%s: %d %d", __FUNCTION__, type, index); + + switch (type) { + case DEVICE_DESCRIPTOR: + desc = (uint8_t *)callbacks.device_desc(type); + if (desc != NULL) { + if ((desc[0] == DEVICE_DESCRIPTOR_LENGTH) && + (desc[1] == DEVICE_DESCRIPTOR)) { + ep0_transfer.length = desc[0]; + ep0_transfer.data = desc; + success = true; + } + } + break; + case CONFIGURATION_DESCRIPTOR: + desc = (uint8_t *)callbacks.cfg_desc(index); + if (desc != NULL) { + if ((desc[0] == CONFIGURATION_DESCRIPTOR_LENGTH) && + (desc[1] == CONFIGURATION_DESCRIPTOR)) { + /* Get wTotalLength */ + ep0_transfer.length = desc[2] | (desc[3] << 8); + ep0_transfer.data = desc; + // Get self-powered status + if ((desc[7] >> 6) & 0x01) { + device_pwr_wkup_status |= DEVICE_STATUS_SELF_POWERED; + } else { + device_pwr_wkup_status &= ~DEVICE_STATUS_SELF_POWERED; } - data = (uint8_t *)((uint32_t)ep0_out_buffer + 8 * (2 - setup_cnt)); + success = true; + } } - // Init new transfer - hal_usb_init_ep0_transfer(); - ep0_transfer.stage = SETUP_STAGE; - get_setup_packet(data, &ep0_transfer.setup_pkt); - - USB_TRACE(5,2, "Got SETUP type=%d, req=0x%x, val=0x%x, idx=0x%x, len=%d", - ep0_transfer.setup_pkt.bmRequestType.type, - ep0_transfer.setup_pkt.bRequest, - ep0_transfer.setup_pkt.wValue, - ep0_transfer.setup_pkt.wIndex, - ep0_transfer.setup_pkt.wLength); - - if (ep0_transfer.setup_pkt.wLength == 0 && ep0_transfer.setup_pkt.bmRequestType.direction != EP_OUT) { - USB_TRACE(0,0, "*** Error: Ep0 dir should be out if wLength=0"); - return 1; + break; + case STRING_DESCRIPTOR: + ep0_transfer.data = (uint8_t *)callbacks.string_desc(index); + if (ep0_transfer.data) { + ep0_transfer.length = ep0_transfer.data[0]; + success = true; } - - if (callbacks.setuprecv == NULL || !callbacks.setuprecv(&ep0_transfer)) { - if (!hal_usb_handle_setup()) { - return 1; - } + break; + case INTERFACE_DESCRIPTOR: + case ENDPOINT_DESCRIPTOR: + /* TODO: Support is optional, not implemented here */ + break; + case QUALIFIER_DESCRIPTOR: +#ifdef USB_HIGH_SPEED + desc = (uint8_t *)callbacks.device_desc(type); + if (desc != NULL) { + if (desc[0] == QUALIFIER_DESCRIPTOR_LENGTH && desc[1] == type) { + ep0_transfer.length = desc[0]; + ep0_transfer.data = desc; + success = true; + } } +#endif + break; + case BOS_DESCRIPTOR: +#ifdef USB_HIGH_SPEED + desc = (uint8_t *)callbacks.device_desc(type); + if (desc != NULL) { + if (desc[0] == BOS_DESCRIPTOR_LENGTH && desc[1] == type) { + // Total length + ep0_transfer.length = desc[2]; + ep0_transfer.data = desc; + success = true; + } + } +#endif + break; + default: + // Might be a class or vendor specific descriptor, which + // should be handled in setuprecv callback + USB_TRACE(1, 0, "*** Error: Unknown desc type: %d", type); + break; + } + + if (success) { + ep0_transfer.stage = DATA_IN_STAGE; + } + + return success; +} + +static void hal_usb_reset_all_transfers(void) { + int ep; + + USB_FUNC_ENTRY_TRACE(31); + + for (ep = 1; ep < EPNUM; ep++) { + reset_epn_out_transfer(ep); + reset_epn_in_transfer(ep); + } +} + +static bool hal_usb_handle_setup(void) { + bool success = false; + enum DEVICE_STATE old_state; + + USB_FUNC_ENTRY_TRACE(17); + + old_state = device_state; + + /* Process standard requests */ + if (ep0_transfer.setup_pkt.bmRequestType.type == STANDARD_TYPE) { + switch (ep0_transfer.setup_pkt.bRequest) { + case GET_STATUS: + success = requestGetStatus(); + break; + case CLEAR_FEATURE: + success = requestClearFeature(); + break; + case SET_FEATURE: + success = requestSetFeature(); + break; + case SET_ADDRESS: + success = requestSetAddress(); + break; + case GET_DESCRIPTOR: + success = requestGetDescriptor(); + break; + case SET_DESCRIPTOR: + /* TODO: Support is optional, not implemented here */ + success = false; + break; + case GET_CONFIGURATION: + success = requestGetConfiguration(); + break; + case SET_CONFIGURATION: + success = requestSetConfiguration(); + break; + case GET_INTERFACE: + success = requestGetInterface(); + break; + case SET_INTERFACE: + success = requestSetInterface(); + break; + default: + break; + } + } + + if (old_state == CONFIGURED && device_state != CONFIGURED) { + hal_usb_reset_all_transfers(); + } + + return success; +} + +static int hal_usb_ep0_setup_stage(uint32_t statusEp) { + uint8_t *data; + uint8_t setup_cnt; + uint16_t pkt_len; + + // Skip the check on IN/OUT tokens + usbc->DOEPMSK &= ~USBC_OUTTKNEPDISMSK; + usbc->DIEPMSK &= ~USBC_INTKNTXFEMPMSK; + + if (statusEp & USBC_BACK2BACKSETUP) { + data = (uint8_t *)(usbc->DOEPDMA0 - 8); + } else { + setup_cnt = GET_BITFIELD(usbc->DOEPTSIZ0, USBC_SUPCNT); + if (setup_cnt >= 3) { + setup_cnt = 2; + } + data = (uint8_t *)((uint32_t)ep0_out_buffer + 8 * (2 - setup_cnt)); + } + // Init new transfer + hal_usb_init_ep0_transfer(); + ep0_transfer.stage = SETUP_STAGE; + get_setup_packet(data, &ep0_transfer.setup_pkt); + + USB_TRACE(5, 2, "Got SETUP type=%d, req=0x%x, val=0x%x, idx=0x%x, len=%d", + ep0_transfer.setup_pkt.bmRequestType.type, + ep0_transfer.setup_pkt.bRequest, ep0_transfer.setup_pkt.wValue, + ep0_transfer.setup_pkt.wIndex, ep0_transfer.setup_pkt.wLength); + + if (ep0_transfer.setup_pkt.wLength == 0 && + ep0_transfer.setup_pkt.bmRequestType.direction != EP_OUT) { + USB_TRACE(0, 0, "*** Error: Ep0 dir should be out if wLength=0"); + return 1; + } + + if (callbacks.setuprecv == NULL || !callbacks.setuprecv(&ep0_transfer)) { + if (!hal_usb_handle_setup()) { + return 1; + } + } #if 0 if (ep0_transfer.setup_pkt.wLength == 0) { @@ -1894,605 +1858,624 @@ static int hal_usb_ep0_setup_stage(uint32_t statusEp) } #endif - if (ep0_transfer.stage == DATA_OUT_STAGE) { - if (ep0_transfer.data == NULL) { - ep0_transfer.data = (uint8_t *)ep0_out_buffer; - } - } else if (ep0_transfer.stage == DATA_IN_STAGE) { - if (ep0_transfer.length > ep0_transfer.setup_pkt.wLength) { - ep0_transfer.length = ep0_transfer.setup_pkt.wLength; - } - pkt_len = ep0_transfer.length; - if (pkt_len > USB_MAX_PACKET_SIZE_CTRL) { - pkt_len = USB_MAX_PACKET_SIZE_CTRL; - } - hal_usb_send_ep0(ep0_transfer.data, pkt_len); - } else if(ep0_transfer.stage == STATUS_IN_STAGE) { - hal_usb_send_ep0(NULL, 0); - } else { - USB_TRACE(1,0, "*** Setup stage switches to invalid stage: %d", ep0_transfer.stage); - return 1; + if (ep0_transfer.stage == DATA_OUT_STAGE) { + if (ep0_transfer.data == NULL) { + ep0_transfer.data = (uint8_t *)ep0_out_buffer; } + } else if (ep0_transfer.stage == DATA_IN_STAGE) { + if (ep0_transfer.length > ep0_transfer.setup_pkt.wLength) { + ep0_transfer.length = ep0_transfer.setup_pkt.wLength; + } + pkt_len = ep0_transfer.length; + if (pkt_len > USB_MAX_PACKET_SIZE_CTRL) { + pkt_len = USB_MAX_PACKET_SIZE_CTRL; + } + hal_usb_send_ep0(ep0_transfer.data, pkt_len); + } else if (ep0_transfer.stage == STATUS_IN_STAGE) { + hal_usb_send_ep0(NULL, 0); + } else { + USB_TRACE(1, 0, "*** Setup stage switches to invalid stage: %d", + ep0_transfer.stage); + return 1; + } - return 0; + return 0; } -static int hal_usb_ep0_data_out_stage(void) -{ - uint16_t pkt_len; - uint16_t reg_size; +static int hal_usb_ep0_data_out_stage(void) { + uint16_t pkt_len; + uint16_t reg_size; - reg_size = GET_BITFIELD(usbc->DOEPTSIZ0, USBC_OEPXFERSIZE0); + reg_size = GET_BITFIELD(usbc->DOEPTSIZ0, USBC_OEPXFERSIZE0); - ASSERT(reg_size <= USB_MAX_PACKET_SIZE_CTRL, "Invalid ep0 recv size"); + ASSERT(reg_size <= USB_MAX_PACKET_SIZE_CTRL, "Invalid ep0 recv size"); - pkt_len = MIN(USB_MAX_PACKET_SIZE_CTRL - reg_size, (uint16_t)(ep0_transfer.length - ep0_transfer.trx_len)); + pkt_len = MIN(USB_MAX_PACKET_SIZE_CTRL - reg_size, + (uint16_t)(ep0_transfer.length - ep0_transfer.trx_len)); - ASSERT(ep0_transfer.length >= ep0_transfer.trx_len + pkt_len, - "Invalid ep0 recv len: length=%u trx_len=%u pkt_len=%u", ep0_transfer.length, ep0_transfer.trx_len, pkt_len); + ASSERT(ep0_transfer.length >= ep0_transfer.trx_len + pkt_len, + "Invalid ep0 recv len: length=%u trx_len=%u pkt_len=%u", + ep0_transfer.length, ep0_transfer.trx_len, pkt_len); - memcpy(ep0_transfer.data + ep0_transfer.trx_len, ep0_out_buffer, pkt_len); + memcpy(ep0_transfer.data + ep0_transfer.trx_len, ep0_out_buffer, pkt_len); + ep0_transfer.trx_len += pkt_len; + + // Always enable setup packet receiving + // CAUTION: Start ep0 recv before invoking datarecv callbacks to handle all + // kinds of endpoints. + // Some USBC events are triggered by patterns in receive FIFO, only + // when these patterns are popped by the core (DMA reading) or the + // application (usbc->GRXSTSP reading). E.g., Global OUT NAK + // (DCTL.SGOUTNak) triggers GINTSTS.GOUTNakEff, but the interrupt + // will never raise in data out stage without DMA or usbc->GRXSTSP + // reading. + hal_usb_recv_ep0(); + + pkt_len = ep0_transfer.length - ep0_transfer.trx_len; + if (pkt_len == 0) { + if (callbacks.datarecv == NULL || !callbacks.datarecv(&ep0_transfer)) { + // hal_usb_stall_ep(EP_OUT, 0); + // hal_usb_stall_ep(EP_IN, 0); + // return; + } + ep0_transfer.stage = STATUS_IN_STAGE; + // Check error on IN/OUT tokens + usbc->DOEPMSK |= USBC_OUTTKNEPDISMSK; + // Send status packet + hal_usb_send_ep0(NULL, 0); + } else { + // Receive next data packet + } + + return 0; +} + +static int hal_usb_ep0_data_in_stage(void) { + uint16_t pkt_len; + bool zero_len_pkt = false; + + ASSERT(GET_BITFIELD(usbc->DIEPTSIZ0, USBC_IEPPKTCNT0) == 0, + "Invalid ep0 sent pkt cnt"); + ASSERT(ep0_transfer.length >= ep0_transfer.trx_len, + "Invalid ep0 sent len 1: length=%u trx_len=%u", ep0_transfer.length, + ep0_transfer.trx_len); + + pkt_len = ep0_transfer.length - ep0_transfer.trx_len; + if (pkt_len == 0) { + // The last zero length packet was sent successfully + ep0_transfer.stage = STATUS_OUT_STAGE; + // Receive status packet (receiving is always enabled) + } else { + // Update sent count + if (pkt_len == USB_MAX_PACKET_SIZE_CTRL) { + zero_len_pkt = true; + } else if (pkt_len > USB_MAX_PACKET_SIZE_CTRL) { + pkt_len = USB_MAX_PACKET_SIZE_CTRL; + } ep0_transfer.trx_len += pkt_len; - // Always enable setup packet receiving - // CAUTION: Start ep0 recv before invoking datarecv callbacks to handle all kinds of endpoints. - // Some USBC events are triggered by patterns in receive FIFO, only when these - // patterns are popped by the core (DMA reading) or the application (usbc->GRXSTSP reading). - // E.g., Global OUT NAK (DCTL.SGOUTNak) triggers GINTSTS.GOUTNakEff, but the interrupt will - // never raise in data out stage without DMA or usbc->GRXSTSP reading. - hal_usb_recv_ep0(); + ASSERT(ep0_transfer.length >= ep0_transfer.trx_len, + "Invalid ep0 sent len 2: length=%u trx_len=%u", ep0_transfer.length, + ep0_transfer.trx_len); + // Send next packet pkt_len = ep0_transfer.length - ep0_transfer.trx_len; + if (pkt_len > USB_MAX_PACKET_SIZE_CTRL) { + pkt_len = USB_MAX_PACKET_SIZE_CTRL; + } if (pkt_len == 0) { - if (callbacks.datarecv == NULL || !callbacks.datarecv(&ep0_transfer)) { - //hal_usb_stall_ep(EP_OUT, 0); - //hal_usb_stall_ep(EP_IN, 0); - //return; - } - ep0_transfer.stage = STATUS_IN_STAGE; - // Check error on IN/OUT tokens - usbc->DOEPMSK |= USBC_OUTTKNEPDISMSK; - // Send status packet + if (zero_len_pkt) { + // Send the last zero length packet hal_usb_send_ep0(NULL, 0); - } else { - // Receive next data packet - } - - return 0; -} - -static int hal_usb_ep0_data_in_stage(void) -{ - uint16_t pkt_len; - bool zero_len_pkt = false; - - ASSERT(GET_BITFIELD(usbc->DIEPTSIZ0, USBC_IEPPKTCNT0) == 0, "Invalid ep0 sent pkt cnt"); - ASSERT(ep0_transfer.length >= ep0_transfer.trx_len, "Invalid ep0 sent len 1: length=%u trx_len=%u", ep0_transfer.length, ep0_transfer.trx_len); - - pkt_len = ep0_transfer.length - ep0_transfer.trx_len; - if (pkt_len == 0) { - // The last zero length packet was sent successfully + } else { ep0_transfer.stage = STATUS_OUT_STAGE; + // Check error on IN/OUT tokens + usbc->DIEPMSK |= USBC_INTKNTXFEMPMSK; // Receive status packet (receiving is always enabled) + } } else { - // Update sent count - if (pkt_len == USB_MAX_PACKET_SIZE_CTRL) { - zero_len_pkt = true; - } else if (pkt_len > USB_MAX_PACKET_SIZE_CTRL) { - pkt_len = USB_MAX_PACKET_SIZE_CTRL; - } - ep0_transfer.trx_len += pkt_len; - - ASSERT(ep0_transfer.length >= ep0_transfer.trx_len, "Invalid ep0 sent len 2: length=%u trx_len=%u", ep0_transfer.length, ep0_transfer.trx_len); - - // Send next packet - pkt_len = ep0_transfer.length - ep0_transfer.trx_len; - if (pkt_len > USB_MAX_PACKET_SIZE_CTRL) { - pkt_len = USB_MAX_PACKET_SIZE_CTRL; - } - if (pkt_len == 0) { - if (zero_len_pkt) { - // Send the last zero length packet - hal_usb_send_ep0(NULL, 0); - } else { - ep0_transfer.stage = STATUS_OUT_STAGE; - // Check error on IN/OUT tokens - usbc->DIEPMSK |= USBC_INTKNTXFEMPMSK; - // Receive status packet (receiving is always enabled) - } - } else { - hal_usb_send_ep0(ep0_transfer.data + ep0_transfer.trx_len, pkt_len); - } + hal_usb_send_ep0(ep0_transfer.data + ep0_transfer.trx_len, pkt_len); } + } - return 0; + return 0; } -static int hal_usb_ep0_status_stage(void) -{ - // Done with status packet - ep0_transfer.stage = NONE_STAGE; - // Skip the check on IN/OUT tokens - usbc->DOEPMSK &= ~USBC_OUTTKNEPDISMSK; - usbc->DIEPMSK &= ~USBC_INTKNTXFEMPMSK; +static int hal_usb_ep0_status_stage(void) { + // Done with status packet + ep0_transfer.stage = NONE_STAGE; + // Skip the check on IN/OUT tokens + usbc->DOEPMSK &= ~USBC_OUTTKNEPDISMSK; + usbc->DIEPMSK &= ~USBC_INTKNTXFEMPMSK; - return 0; + return 0; } -static void hal_usb_ep0_test_mode_check(void) -{ - if (device_test_mode) { - usbc->DCTL = SET_BITFIELD(usbc->DCTL, USBC_TSTCTL, device_test_mode); - device_test_mode = 0; - } +static void hal_usb_ep0_test_mode_check(void) { + if (device_test_mode) { + usbc->DCTL = SET_BITFIELD(usbc->DCTL, USBC_TSTCTL, device_test_mode); + device_test_mode = 0; + } } -static void hal_usb_handle_ep0_packet(enum EP_DIR dir, uint32_t statusEp) -{ - int ret; +static void hal_usb_handle_ep0_packet(enum EP_DIR dir, uint32_t statusEp) { + int ret; - USB_TRACE(3,16, "%s: dir=%d, statusEp=0x%08x", __FUNCTION__, dir, statusEp); + USB_TRACE(3, 16, "%s: dir=%d, statusEp=0x%08x", __FUNCTION__, dir, statusEp); - if (dir == EP_OUT) { - if ((statusEp & (USBC_XFERCOMPL | USBC_STSPHSERCVD)) == (USBC_XFERCOMPL | USBC_STSPHSERCVD)) { - // From Linux driver - if (GET_BITFIELD(usbc->DOEPTSIZ0, USBC_OEPXFERSIZE0) == USB_MAX_PACKET_SIZE_CTRL && - (usbc->DOEPTSIZ0 & USBC_OEPPKTCNT0)) { - // Abnormal case - USB_TRACE(2,0, "*** EP0 OUT empty compl with stsphsercvd: stage=%d, size=0x%08x", - ep0_transfer.stage, usbc->DOEPTSIZ0); - // Always enable setup packet receiving - hal_usb_recv_ep0(); - return; - } - } - - if (statusEp & USBC_XFERCOMPL) { - // New packet received - if (statusEp & USBC_SETUP) { - // Clean previous transfer - if (ep0_transfer.stage != NONE_STAGE) { - USB_TRACE(1,0, "*** Setup stage breaks previous stage %d", ep0_transfer.stage); - hal_usb_stop_ep(EP_IN, 0); - } - // New setup packet - ep0_transfer.stage = SETUP_STAGE; - } else if (statusEp & USBC_STUPPKTRCVD) { - // Clean previous transfer - if (ep0_transfer.stage != NONE_STAGE) { - USB_TRACE(1,0, "*** Wait setup stage breaks previous stage %d", ep0_transfer.stage); - hal_usb_stop_ep(EP_IN, 0); - } - // New setup packet received, and wait for USBC h/w state machine finished - // CAUTION: Enabling data receipt before getting USBC_SETUP interrupt might cause - // race condition in h/w, which leads to missing USBC_XFERCOMPL interrupt - // after the data has been received and acked - ep0_transfer.stage = WAIT_SETUP_STAGE; - return; - } - } else { - // No packet received - if (statusEp & USBC_SETUP) { - if (ep0_transfer.stage == WAIT_SETUP_STAGE) { - // Previous packet is setup packet - ep0_transfer.stage = SETUP_STAGE; - } else { - USB_TRACE(1,0, "*** Setup interrupt occurs in stage %d", ep0_transfer.stage); - // The setup packet has been processed - return; - } - } - } - } - - if (ep0_transfer.stage == SETUP_STAGE) { - ASSERT(dir == EP_OUT, "Invalid dir for setup stage"); - - ret = hal_usb_ep0_setup_stage(statusEp); - if (ret) { - // Error - ep0_transfer.stage = NONE_STAGE; - hal_usb_stall_ep(EP_OUT, 0); - hal_usb_stall_ep(EP_IN, 0); - // H/w will unstall EP0 automatically when a setup token is received - //hal_usb_recv_ep0(); - } + if (dir == EP_OUT) { + if ((statusEp & (USBC_XFERCOMPL | USBC_STSPHSERCVD)) == + (USBC_XFERCOMPL | USBC_STSPHSERCVD)) { + // From Linux driver + if (GET_BITFIELD(usbc->DOEPTSIZ0, USBC_OEPXFERSIZE0) == + USB_MAX_PACKET_SIZE_CTRL && + (usbc->DOEPTSIZ0 & USBC_OEPPKTCNT0)) { + // Abnormal case + USB_TRACE( + 2, 0, + "*** EP0 OUT empty compl with stsphsercvd: stage=%d, size=0x%08x", + ep0_transfer.stage, usbc->DOEPTSIZ0); // Always enable setup packet receiving hal_usb_recv_ep0(); - return; + } } if (statusEp & USBC_XFERCOMPL) { - if (dir == EP_OUT) { - if (ep0_transfer.stage == DATA_OUT_STAGE) { - hal_usb_ep0_data_out_stage(); - } else if (ep0_transfer.stage == STATUS_OUT_STAGE) { - hal_usb_ep0_status_stage(); - // Always enable setup packet receiving - hal_usb_recv_ep0(); - } else { - // Abnormal case - USB_TRACE(2,0, "*** EP0 OUT compl in stage %d with size 0x%08x", ep0_transfer.stage, usbc->DOEPTSIZ0); - // Always enable setup packet receiving - hal_usb_recv_ep0(); - } - } else { - if (ep0_transfer.stage == DATA_IN_STAGE) { - hal_usb_ep0_data_in_stage(); - } else if (ep0_transfer.stage == STATUS_IN_STAGE) { - hal_usb_ep0_status_stage(); - hal_usb_ep0_test_mode_check(); - } else { - // Abnormal case - USB_TRACE(2,0, "*** EP0 IN compl in stage %d with size 0x%08x", ep0_transfer.stage, usbc->DIEPTSIZ0); - } + // New packet received + if (statusEp & USBC_SETUP) { + // Clean previous transfer + if (ep0_transfer.stage != NONE_STAGE) { + USB_TRACE(1, 0, "*** Setup stage breaks previous stage %d", + ep0_transfer.stage); + hal_usb_stop_ep(EP_IN, 0); } + // New setup packet + ep0_transfer.stage = SETUP_STAGE; + } else if (statusEp & USBC_STUPPKTRCVD) { + // Clean previous transfer + if (ep0_transfer.stage != NONE_STAGE) { + USB_TRACE(1, 0, "*** Wait setup stage breaks previous stage %d", + ep0_transfer.stage); + hal_usb_stop_ep(EP_IN, 0); + } + // New setup packet received, and wait for USBC h/w state machine + // finished CAUTION: Enabling data receipt before getting USBC_SETUP + // interrupt might cause + // race condition in h/w, which leads to missing USBC_XFERCOMPL + // interrupt after the data has been received and acked + ep0_transfer.stage = WAIT_SETUP_STAGE; + return; + } + } else { + // No packet received + if (statusEp & USBC_SETUP) { + if (ep0_transfer.stage == WAIT_SETUP_STAGE) { + // Previous packet is setup packet + ep0_transfer.stage = SETUP_STAGE; + } else { + USB_TRACE(1, 0, "*** Setup interrupt occurs in stage %d", + ep0_transfer.stage); + // The setup packet has been processed + return; + } + } } + } + + if (ep0_transfer.stage == SETUP_STAGE) { + ASSERT(dir == EP_OUT, "Invalid dir for setup stage"); + + ret = hal_usb_ep0_setup_stage(statusEp); + if (ret) { + // Error + ep0_transfer.stage = NONE_STAGE; + hal_usb_stall_ep(EP_OUT, 0); + hal_usb_stall_ep(EP_IN, 0); + // H/w will unstall EP0 automatically when a setup token is received + // hal_usb_recv_ep0(); + } + // Always enable setup packet receiving + hal_usb_recv_ep0(); + + return; + } + + if (statusEp & USBC_XFERCOMPL) { + if (dir == EP_OUT) { + if (ep0_transfer.stage == DATA_OUT_STAGE) { + hal_usb_ep0_data_out_stage(); + } else if (ep0_transfer.stage == STATUS_OUT_STAGE) { + hal_usb_ep0_status_stage(); + // Always enable setup packet receiving + hal_usb_recv_ep0(); + } else { + // Abnormal case + USB_TRACE(2, 0, "*** EP0 OUT compl in stage %d with size 0x%08x", + ep0_transfer.stage, usbc->DOEPTSIZ0); + // Always enable setup packet receiving + hal_usb_recv_ep0(); + } + } else { + if (ep0_transfer.stage == DATA_IN_STAGE) { + hal_usb_ep0_data_in_stage(); + } else if (ep0_transfer.stage == STATUS_IN_STAGE) { + hal_usb_ep0_status_stage(); + hal_usb_ep0_test_mode_check(); + } else { + // Abnormal case + USB_TRACE(2, 0, "*** EP0 IN compl in stage %d with size 0x%08x", + ep0_transfer.stage, usbc->DIEPTSIZ0); + } + } + } } -static void hal_usb_irq_reset(void) -{ - USB_FUNC_ENTRY_TRACE(2); +static void hal_usb_irq_reset(void) { + USB_FUNC_ENTRY_TRACE(2); - device_state = DEFAULT; - device_pwr_wkup_status = 0; - device_sleep_status = USB_SLEEP_NONE; + device_state = DEFAULT; + device_pwr_wkup_status = 0; + device_sleep_status = USB_SLEEP_NONE; - usbc->PCGCCTL &= ~USBC_STOPPCLK; - usbc->DCTL &= ~USBC_RMTWKUPSIG; + usbc->PCGCCTL &= ~USBC_STOPPCLK; + usbc->DCTL &= ~USBC_RMTWKUPSIG; - hal_usb_reset_all_transfers(); - hal_usb_stop_all_out_eps(); - hal_usb_stop_all_in_eps(); + hal_usb_reset_all_transfers(); + hal_usb_stop_all_out_eps(); + hal_usb_stop_all_in_eps(); - // Unmask ep0 interrupts - usbc->DAINTMSK = USBC_INEPMSK(1 << 0) | USBC_OUTEPMSK(1 << 0); - usbc->DOEPMSK = USBC_XFERCOMPLMSK | USBC_SETUPMSK; - usbc->DIEPMSK = USBC_XFERCOMPLMSK | USBC_TIMEOUTMSK; - usbc->GINTMSK |= USBC_OEPINT | USBC_IEPINT + // Unmask ep0 interrupts + usbc->DAINTMSK = USBC_INEPMSK(1 << 0) | USBC_OUTEPMSK(1 << 0); + usbc->DOEPMSK = USBC_XFERCOMPLMSK | USBC_SETUPMSK; + usbc->DIEPMSK = USBC_XFERCOMPLMSK | USBC_TIMEOUTMSK; + usbc->GINTMSK |= USBC_OEPINT | USBC_IEPINT #if defined(USB_ISO) && (USB_ISO_INTERVAL == 1) - | USBC_INCOMPISOOUT | USBC_INCOMPISOIN + | USBC_INCOMPISOOUT | USBC_INCOMPISOIN #endif - ; + ; #ifdef USB_SUSPEND - usbc->GINTMSK &= ~USBC_WKUPINT; + usbc->GINTMSK &= ~USBC_WKUPINT; #endif #ifdef USB_LPM - usbc->GINTMSK |= USBC_LPM_INT; - usbc->PCGCCTL |= USBC_ENBL_L1GATING; - usbc->GLPMCFG = SET_BITFIELD(usbc->GLPMCFG, USBC_HIRD_THRES, USB_L1_LIGHT_SLEEP_BESL) | USBC_HIRD_THRES_BIT4 | - USBC_LPMCAP | USBC_APPL1RES | USBC_ENBESL; // | USBC_ENBLSLPM; + usbc->GINTMSK |= USBC_LPM_INT; + usbc->PCGCCTL |= USBC_ENBL_L1GATING; + usbc->GLPMCFG = + SET_BITFIELD(usbc->GLPMCFG, USBC_HIRD_THRES, USB_L1_LIGHT_SLEEP_BESL) | + USBC_HIRD_THRES_BIT4 | USBC_LPMCAP | USBC_APPL1RES | + USBC_ENBESL; // | USBC_ENBLSLPM; #ifdef CHIP_HAS_USBIF - usbif->USBIF_04 = SET_BITFIELD(usbif->USBIF_04, USBIF_04_CFG_SLEEP_THSD, USB_L1_LIGHT_SLEEP_BESL); + usbif->USBIF_04 = SET_BITFIELD(usbif->USBIF_04, USBIF_04_CFG_SLEEP_THSD, + USB_L1_LIGHT_SLEEP_BESL); #endif #endif - // Config ep0 size - hal_usb_alloc_ep0_fifo(); - // Reset device address - usbc->DCFG &= ~USBC_DEVADDR_MASK; + // Config ep0 size + hal_usb_alloc_ep0_fifo(); + // Reset device address + usbc->DCFG &= ~USBC_DEVADDR_MASK; - hal_usb_init_ep0_transfer(); - hal_usb_init_epn_transfer(); + hal_usb_init_ep0_transfer(); + hal_usb_init_epn_transfer(); - if (callbacks.state_change) { - callbacks.state_change(HAL_USB_EVENT_RESET, 0); - } + if (callbacks.state_change) { + callbacks.state_change(HAL_USB_EVENT_RESET, 0); + } } -static void hal_usb_irq_enum_done(void) -{ - uint8_t speed; - uint8_t mps = 0; +static void hal_usb_irq_enum_done(void) { + uint8_t speed; + uint8_t mps = 0; - USB_FUNC_ENTRY_TRACE(2); + USB_FUNC_ENTRY_TRACE(2); - speed = GET_BITFIELD(usbc->DSTS, USBC_ENUMSPD); - if (speed == 0) { - // High speed -- ERROR! - mps = 0; // 64 bytes - } else if (speed == 1 || speed == 3) { - // Full speed - mps = 0; // 64 bytes - } else { - // Low speed -- ERROR! - mps = 3; // 8 bytes - } - // Only support 64-byte MPS ! - mps = 0; - // Config max packet size - usbc->DIEPCTL0 = USBC_EP0_MPS(mps) | USBC_USBACTEP | USBC_EPTXFNUM(0) | USBC_SNAK; - usbc->DOEPCTL0 = USBC_EP0_MPS(mps) | USBC_USBACTEP | USBC_SNAK; + speed = GET_BITFIELD(usbc->DSTS, USBC_ENUMSPD); + if (speed == 0) { + // High speed -- ERROR! + mps = 0; // 64 bytes + } else if (speed == 1 || speed == 3) { + // Full speed + mps = 0; // 64 bytes + } else { + // Low speed -- ERROR! + mps = 3; // 8 bytes + } + // Only support 64-byte MPS ! + mps = 0; + // Config max packet size + usbc->DIEPCTL0 = + USBC_EP0_MPS(mps) | USBC_USBACTEP | USBC_EPTXFNUM(0) | USBC_SNAK; + usbc->DOEPCTL0 = USBC_EP0_MPS(mps) | USBC_USBACTEP | USBC_SNAK; - hal_usb_recv_ep0(); + hal_usb_recv_ep0(); } #if defined(USB_ISO) && (USB_ISO_INTERVAL == 1) -static void hal_usb_irq_incomp_iso_out(void) -{ - int i; - uint32_t ctrl; - uint32_t sof_fn; - uint32_t statusEp; +static void hal_usb_irq_incomp_iso_out(void) { + int i; + uint32_t ctrl; + uint32_t sof_fn; + uint32_t statusEp; - sof_fn = GET_BITFIELD(usbc->DSTS, USBC_SOFFN); + sof_fn = GET_BITFIELD(usbc->DSTS, USBC_SOFFN); - for (i = 0; i < EPNUM - 1; i++) { - ctrl = usbc->DOEPnCONFIG[i].DOEPCTL; - if ((ctrl & USBC_EPENA) && ((ctrl >> USBC_EPDPID_SHIFT) & 1) == (sof_fn & 1) && - GET_BITFIELD(ctrl, USBC_EPTYPE) == E_ISOCHRONOUS) { - statusEp = usbc->DOEPnCONFIG[i].DOEPINT; - hal_usb_disable_ep(EP_OUT, i + 1); - break; - } + for (i = 0; i < EPNUM - 1; i++) { + ctrl = usbc->DOEPnCONFIG[i].DOEPCTL; + if ((ctrl & USBC_EPENA) && + ((ctrl >> USBC_EPDPID_SHIFT) & 1) == (sof_fn & 1) && + GET_BITFIELD(ctrl, USBC_EPTYPE) == E_ISOCHRONOUS) { + statusEp = usbc->DOEPnCONFIG[i].DOEPINT; + hal_usb_disable_ep(EP_OUT, i + 1); + break; } + } - if (i < EPNUM - 1) { - USB_TRACE(4,17, "%s ep%d: INT=0x%08x, SOF=0x%04x", __FUNCTION__, i + 1, statusEp, sof_fn); - } else { - USB_TRACE(1,17, "%s: No valid ISO ep", __FUNCTION__); - } + if (i < EPNUM - 1) { + USB_TRACE(4, 17, "%s ep%d: INT=0x%08x, SOF=0x%04x", __FUNCTION__, i + 1, + statusEp, sof_fn); + } else { + USB_TRACE(1, 17, "%s: No valid ISO ep", __FUNCTION__); + } } -static void hal_usb_irq_incomp_iso_in(void) -{ - int i; - uint32_t ctrl; - uint32_t sof_fn; - uint32_t statusEp; +static void hal_usb_irq_incomp_iso_in(void) { + int i; + uint32_t ctrl; + uint32_t sof_fn; + uint32_t statusEp; - sof_fn = GET_BITFIELD(usbc->DSTS, USBC_SOFFN); + sof_fn = GET_BITFIELD(usbc->DSTS, USBC_SOFFN); - for (i = 0; i < EPNUM - 1; i++) { - ctrl = usbc->DIEPnCONFIG[i].DIEPCTL; - if ((ctrl & USBC_EPENA) && ((ctrl >> USBC_EPDPID_SHIFT) & 1) == (sof_fn & 1) && - GET_BITFIELD(ctrl, USBC_EPTYPE) == E_ISOCHRONOUS) { - statusEp = usbc->DIEPnCONFIG[i].DIEPINT; - hal_usb_disable_ep(EP_IN, i + 1); - break; - } + for (i = 0; i < EPNUM - 1; i++) { + ctrl = usbc->DIEPnCONFIG[i].DIEPCTL; + if ((ctrl & USBC_EPENA) && + ((ctrl >> USBC_EPDPID_SHIFT) & 1) == (sof_fn & 1) && + GET_BITFIELD(ctrl, USBC_EPTYPE) == E_ISOCHRONOUS) { + statusEp = usbc->DIEPnCONFIG[i].DIEPINT; + hal_usb_disable_ep(EP_IN, i + 1); + break; } + } - if (i < EPNUM - 1) { - USB_TRACE(4,17, "%s ep%d: INT=0x%08x, SOF=0x%04x", __FUNCTION__, i + 1, statusEp, sof_fn); - } else { - USB_TRACE(1,17, "%s: No valid ISO ep", __FUNCTION__); - } + if (i < EPNUM - 1) { + USB_TRACE(4, 17, "%s ep%d: INT=0x%08x, SOF=0x%04x", __FUNCTION__, i + 1, + statusEp, sof_fn); + } else { + USB_TRACE(1, 17, "%s: No valid ISO ep", __FUNCTION__); + } } #endif #ifdef USB_SUSPEND -static void hal_usb_restore_clock(void) -{ - hal_sysfreq_req(HAL_SYSFREQ_USER_USB, USB_SYS_FREQ); +static void hal_usb_restore_clock(void) { + hal_sysfreq_req(HAL_SYSFREQ_USER_USB, USB_SYS_FREQ); #ifdef PMU_USB_PIN_CHECK #ifdef CHIP_HAS_USBPHY - // Enable dig phy clock - usbphy_wakeup(); + // Enable dig phy clock + usbphy_wakeup(); #endif - hal_cmu_clock_enable(HAL_CMU_MOD_H_USBC); - hal_cmu_clock_enable(HAL_CMU_MOD_O_USB); + hal_cmu_clock_enable(HAL_CMU_MOD_H_USBC); + hal_cmu_clock_enable(HAL_CMU_MOD_O_USB); #endif - usbc->PCGCCTL &= ~USBC_STOPPCLK; + usbc->PCGCCTL &= ~USBC_STOPPCLK; #ifdef PMU_USB_PIN_CHECK - NVIC_ClearPendingIRQ(USB_IRQn); - NVIC_EnableIRQ(USB_IRQn); + NVIC_ClearPendingIRQ(USB_IRQn); + NVIC_EnableIRQ(USB_IRQn); #endif } -static void hal_usb_stop_clock(void) -{ +static void hal_usb_stop_clock(void) { #ifdef PMU_USB_PIN_CHECK - // Disable USB IRQ to avoid errors when RESET/RESUME is detected before stopping USB clock - NVIC_DisableIRQ(USB_IRQn); + // Disable USB IRQ to avoid errors when RESET/RESUME is detected before + // stopping USB clock + NVIC_DisableIRQ(USB_IRQn); #endif - usbc->PCGCCTL |= USBC_STOPPCLK; + usbc->PCGCCTL |= USBC_STOPPCLK; #ifdef PMU_USB_PIN_CHECK - hal_cmu_clock_disable(HAL_CMU_MOD_O_USB); - hal_cmu_clock_disable(HAL_CMU_MOD_H_USBC); + hal_cmu_clock_disable(HAL_CMU_MOD_O_USB); + hal_cmu_clock_disable(HAL_CMU_MOD_H_USBC); #ifdef CHIP_HAS_USBPHY - // Disable dig phy clock - usbphy_sleep(); + // Disable dig phy clock + usbphy_sleep(); #endif #endif - hal_sysfreq_req(HAL_SYSFREQ_USER_USB, HAL_CMU_FREQ_32K); + hal_sysfreq_req(HAL_SYSFREQ_USER_USB, HAL_CMU_FREQ_32K); } #ifdef PMU_USB_PIN_CHECK static void hal_usb_pin_status_resume(enum PMU_USB_PIN_CHK_STATUS_T status); -static void hal_usb_pin_check_enable_check(void *param) -{ +static void hal_usb_pin_check_enable_check(void *param) { + pmu_usb_enable_pin_status_check(); +} + +static void hal_usb_pin_check_cancel_resume(void *param) { + USB_TRACE(3, 18, "[%X] %s: DSTS=0x%08x", hal_sys_timer_get(), __FUNCTION__, + usbc->DSTS); + + if (usbc->DSTS & USBC_SUSPSTS) { + hal_usb_stop_clock(); pmu_usb_enable_pin_status_check(); + } } -static void hal_usb_pin_check_cancel_resume(void *param) -{ - USB_TRACE(3,18, "[%X] %s: DSTS=0x%08x", hal_sys_timer_get(), __FUNCTION__, usbc->DSTS); +static void hal_usb_pin_status_resume(enum PMU_USB_PIN_CHK_STATUS_T status) { + USB_TRACE(2, 18, "%s: %d", __FUNCTION__, status); - if (usbc->DSTS & USBC_SUSPSTS) { - hal_usb_stop_clock(); - pmu_usb_enable_pin_status_check(); - } -} + // Start timer to check resume status, so as to avoid fake pin resume signal + if (usbdev_timer_active) { + hwtimer_stop(usbdev_timer); + } + hwtimer_update_then_start(usbdev_timer, hal_usb_pin_check_cancel_resume, NULL, + PIN_CHECK_WAIT_RESUME_INTERVAL); + usbdev_timer_active = 1; -static void hal_usb_pin_status_resume(enum PMU_USB_PIN_CHK_STATUS_T status) -{ - USB_TRACE(2,18, "%s: %d", __FUNCTION__, status); - - // Start timer to check resume status, so as to avoid fake pin resume signal - if (usbdev_timer_active) { - hwtimer_stop(usbdev_timer); - } - hwtimer_update_then_start(usbdev_timer, hal_usb_pin_check_cancel_resume, NULL, PIN_CHECK_WAIT_RESUME_INTERVAL); - usbdev_timer_active = 1; - - hal_usb_restore_clock(); + hal_usb_restore_clock(); } #endif #if defined(PMU_USB_PIN_CHECK) || defined(USB_LPM) -static void hal_usb_stop_usbdev_timer(void) -{ - if (usbdev_timer_active) { - hwtimer_stop(usbdev_timer); - usbdev_timer_active = 0; - } +static void hal_usb_stop_usbdev_timer(void) { + if (usbdev_timer_active) { + hwtimer_stop(usbdev_timer); + usbdev_timer_active = 0; + } } #endif -static void hal_usb_sleep(enum USB_SLEEP_T cause) -{ - USB_FUNC_ENTRY_TRACE(18); +static void hal_usb_sleep(enum USB_SLEEP_T cause) { + USB_FUNC_ENTRY_TRACE(18); - device_sleep_status = cause; + device_sleep_status = cause; - if (callbacks.state_change) { - callbacks.state_change((cause == USB_SLEEP_SUSPEND) ? HAL_USB_EVENT_SUSPEND : HAL_USB_EVENT_L1_DEEP_SLEEP, 0); - } + if (callbacks.state_change) { + callbacks.state_change((cause == USB_SLEEP_SUSPEND) + ? HAL_USB_EVENT_SUSPEND + : HAL_USB_EVENT_L1_DEEP_SLEEP, + 0); + } - usbc->GINTMSK |= USBC_WKUPINT; + usbc->GINTMSK |= USBC_WKUPINT; #ifdef USB_LPM - usbc->GINTMSK &= ~USBC_LPM_INT; + usbc->GINTMSK &= ~USBC_LPM_INT; #endif - hal_usb_stop_clock(); + hal_usb_stop_clock(); #ifdef PMU_USB_PIN_CHECK - pmu_usb_config_pin_status_check(PMU_USB_PIN_CHK_HOST_RESUME, hal_usb_pin_status_resume, false); - // Stat timer to check current pin status - if (usbdev_timer_active) { - hwtimer_stop(usbdev_timer); - } - hwtimer_update_then_start(usbdev_timer, hal_usb_pin_check_enable_check, NULL, PIN_CHECK_ENABLE_INTERVAL); - usbdev_timer_active = 1; + pmu_usb_config_pin_status_check(PMU_USB_PIN_CHK_HOST_RESUME, + hal_usb_pin_status_resume, false); + // Stat timer to check current pin status + if (usbdev_timer_active) { + hwtimer_stop(usbdev_timer); + } + hwtimer_update_then_start(usbdev_timer, hal_usb_pin_check_enable_check, NULL, + PIN_CHECK_ENABLE_INTERVAL); + usbdev_timer_active = 1; #endif } -static void hal_usb_wakeup(void) -{ - USB_FUNC_ENTRY_TRACE(18); +static void hal_usb_wakeup(void) { + USB_FUNC_ENTRY_TRACE(18); - device_sleep_status = USB_SLEEP_NONE; + device_sleep_status = USB_SLEEP_NONE; #ifndef PMU_USB_PIN_CHECK - hal_usb_restore_clock(); + hal_usb_restore_clock(); #endif + usbc->GINTMSK &= ~USBC_WKUPINT; +#ifdef USB_LPM + usbc->GINTMSK |= USBC_LPM_INT; +#endif + + if (callbacks.state_change) { + callbacks.state_change(HAL_USB_EVENT_RESUME, 0); + } +} + +static void hal_usb_send_resume_signal(int enable) { + if (enable) { +#ifdef PMU_USB_PIN_CHECK + // Stop pin check timer + hal_usb_stop_usbdev_timer(); + // Disabe PMU pin status check + pmu_usb_disable_pin_status_check(); +#endif + + // Restore USB clock and IRQ + hal_usb_restore_clock(); + usbc->GINTMSK &= ~USBC_WKUPINT; -#ifdef USB_LPM - usbc->GINTMSK |= USBC_LPM_INT; -#endif - if (callbacks.state_change) { - callbacks.state_change(HAL_USB_EVENT_RESUME, 0); - } -} - -static void hal_usb_send_resume_signal(int enable) -{ - if (enable) { -#ifdef PMU_USB_PIN_CHECK - // Stop pin check timer - hal_usb_stop_usbdev_timer(); - // Disabe PMU pin status check - pmu_usb_disable_pin_status_check(); -#endif - - // Restore USB clock and IRQ - hal_usb_restore_clock(); - - usbc->GINTMSK &= ~USBC_WKUPINT; - - usbc->DCTL |= USBC_RMTWKUPSIG; - } else { - usbc->DCTL &= ~USBC_RMTWKUPSIG; - } + usbc->DCTL |= USBC_RMTWKUPSIG; + } else { + usbc->DCTL &= ~USBC_RMTWKUPSIG; + } } #endif -int hal_usb_remote_wakeup(int signal) -{ +int hal_usb_remote_wakeup(int signal) { #ifdef USB_SUSPEND - USB_TRACE(2,15, "%s: %d", __FUNCTION__, signal); + USB_TRACE(2, 15, "%s: %d", __FUNCTION__, signal); - if (signal) { - if (device_sleep_status != USB_SLEEP_SUSPEND) { - return 1; - } - if ((device_pwr_wkup_status & DEVICE_STATUS_REMOTE_WAKEUP) == 0) { - return 2; - } + if (signal) { + if (device_sleep_status != USB_SLEEP_SUSPEND) { + return 1; + } + if ((device_pwr_wkup_status & DEVICE_STATUS_REMOTE_WAKEUP) == 0) { + return 2; + } + hal_usb_send_resume_signal(1); + } else { + hal_usb_send_resume_signal(0); + + // USBC will NOT generate resume IRQ in case of remote wakeup, so fake one + // here + hal_usb_wakeup(); + } +#endif + + return 0; +} + +void hal_usb_lpm_sleep_enable(void) { +#ifdef USB_LPM + if (usbc->GLPMCFG & USBC_ENBESL) { + // usbc->GLPMCFG &= ~USBC_RSTRSLPSTS; + } + usbc->GLPMCFG |= (USBC_APPL1RES | USBC_HIRD_THRES_BIT4); + + usbc->PCGCCTL |= USBC_ENBL_L1GATING; +#endif +} + +void hal_usb_lpm_sleep_disable(void) { +#ifdef USB_LPM + uint32_t cnt; + uint32_t lock; + uint32_t lpm; + bool POSSIBLY_UNUSED rmtWake = false; + + usbc->PCGCCTL &= ~USBC_ENBL_L1GATING; + + usbc->GLPMCFG &= ~(USBC_APPL1RES | USBC_HIRD_THRES_BIT4 | USBC_ENBLSLPM); + if (usbc->GLPMCFG & USBC_ENBESL) { + usbc->GLPMCFG |= USBC_RSTRSLPSTS; + } + + lpm_entry = false; + + // Resume if in L1 state + if (usbc->GLPMCFG & USBC_SLPSTS) { + cnt = 0; + while ( + (usbc->GLPMCFG & (USBC_BREMOTEWAKE | USBC_SLPSTS | USBC_L1RESUMEOK)) == + (USBC_BREMOTEWAKE | USBC_SLPSTS)) { + hal_sys_timer_delay(US_TO_TICKS(0)); + if (++cnt > 3) { + break; + } + } + + lock = int_lock(); + + lpm = usbc->GLPMCFG; + + if (lpm & USBC_SLPSTS) { + if ((lpm & (USBC_BREMOTEWAKE | USBC_L1RESUMEOK)) == + (USBC_BREMOTEWAKE | USBC_L1RESUMEOK)) { hal_usb_send_resume_signal(1); - } else { - hal_usb_send_resume_signal(0); - - // USBC will NOT generate resume IRQ in case of remote wakeup, so fake one here - hal_usb_wakeup(); - } -#endif - - return 0; -} - -void hal_usb_lpm_sleep_enable(void) -{ -#ifdef USB_LPM - if (usbc->GLPMCFG & USBC_ENBESL) { - //usbc->GLPMCFG &= ~USBC_RSTRSLPSTS; - } - usbc->GLPMCFG |= (USBC_APPL1RES | USBC_HIRD_THRES_BIT4); - - usbc->PCGCCTL |= USBC_ENBL_L1GATING; -#endif -} - -void hal_usb_lpm_sleep_disable(void) -{ -#ifdef USB_LPM - uint32_t cnt; - uint32_t lock; - uint32_t lpm; - bool POSSIBLY_UNUSED rmtWake = false; - - usbc->PCGCCTL &= ~USBC_ENBL_L1GATING; - - usbc->GLPMCFG &= ~(USBC_APPL1RES | USBC_HIRD_THRES_BIT4 | USBC_ENBLSLPM); - if (usbc->GLPMCFG & USBC_ENBESL) { - usbc->GLPMCFG |= USBC_RSTRSLPSTS; - } - - lpm_entry = false; - - // Resume if in L1 state - if (usbc->GLPMCFG & USBC_SLPSTS) { - cnt = 0; - while ((usbc->GLPMCFG & (USBC_BREMOTEWAKE | USBC_SLPSTS | USBC_L1RESUMEOK)) == - (USBC_BREMOTEWAKE | USBC_SLPSTS)) { - hal_sys_timer_delay(US_TO_TICKS(0)); - if (++cnt > 3) { - break; - } - } - - lock = int_lock(); - - lpm = usbc->GLPMCFG; - - if (lpm & USBC_SLPSTS) { - if ((lpm & (USBC_BREMOTEWAKE | USBC_L1RESUMEOK)) == (USBC_BREMOTEWAKE | USBC_L1RESUMEOK)) { - hal_usb_send_resume_signal(1); - rmtWake = true; + rmtWake = true; #if 0 // Detect race condition between remote wake and L1 state change if ((usbc->GLPMCFG & USBC_SLPSTS) == 0) { @@ -2500,235 +2483,242 @@ void hal_usb_lpm_sleep_disable(void) } #endif #ifdef USB_SUSPEND - if (device_sleep_status == USB_SLEEP_L1) { - // USBC will NOT generate resume IRQ in case of remote wakeup, so fake one here - hal_usb_wakeup(); - } + if (device_sleep_status == USB_SLEEP_L1) { + // USBC will NOT generate resume IRQ in case of remote wakeup, so fake + // one here + hal_usb_wakeup(); + } #endif - } else if ((lpm & (USBC_BREMOTEWAKE | USBC_L1RESUMEOK)) == USBC_BREMOTEWAKE) { - TRACE(1,"\n*** ERROR: LPM Disable: Failed to wait L1 resume OK: 0x%08X\n", lpm); - } - } - - int_unlock(lock); - - if (rmtWake) { - USB_TRACE(1,0, "LPM RmtWake: 0x%08X", lpm); - } - } -#endif -} - -#ifdef USB_LPM -#ifdef USB_SUSPEND -static void hal_usb_lpm_check(void *param) -{ - uint32_t lpm; - uint32_t lock; - - // TODO: Disable USB irq only (might conflict with hal_usb_stop_clock) - lock = int_lock(); - - lpm = usbc->GLPMCFG; - - if (lpm_entry && GET_BITFIELD(lpm, USBC_HIRD) >= USB_L1_DEEP_SLEEP_BESL) { - if ((lpm & USBC_SLPSTS) && (lpm & (USBC_BREMOTEWAKE | USBC_L1RESUMEOK)) != USBC_BREMOTEWAKE) { - lpm_entry = false; - hal_usb_sleep(USB_SLEEP_L1); - } else { - hwtimer_update_then_start(usbdev_timer, hal_usb_lpm_check, NULL, LPM_CHECK_INTERVAL); - usbdev_timer_active = 1; - } + } else if ((lpm & (USBC_BREMOTEWAKE | USBC_L1RESUMEOK)) == + USBC_BREMOTEWAKE) { + TRACE(1, + "\n*** ERROR: LPM Disable: Failed to wait L1 resume OK: 0x%08X\n", + lpm); + } } int_unlock(lock); + + if (rmtWake) { + USB_TRACE(1, 0, "LPM RmtWake: 0x%08X", lpm); + } + } +#endif +} + +#ifdef USB_LPM +#ifdef USB_SUSPEND +static void hal_usb_lpm_check(void *param) { + uint32_t lpm; + uint32_t lock; + + // TODO: Disable USB irq only (might conflict with hal_usb_stop_clock) + lock = int_lock(); + + lpm = usbc->GLPMCFG; + + if (lpm_entry && GET_BITFIELD(lpm, USBC_HIRD) >= USB_L1_DEEP_SLEEP_BESL) { + if ((lpm & USBC_SLPSTS) && + (lpm & (USBC_BREMOTEWAKE | USBC_L1RESUMEOK)) != USBC_BREMOTEWAKE) { + lpm_entry = false; + hal_usb_sleep(USB_SLEEP_L1); + } else { + hwtimer_update_then_start(usbdev_timer, hal_usb_lpm_check, NULL, + LPM_CHECK_INTERVAL); + usbdev_timer_active = 1; + } + } + + int_unlock(lock); } #endif -static void hal_usb_irq_lpm(void) -{ - static const uint32_t lpm_trace_interval = MS_TO_TICKS(2000); - static uint32_t last_lpm_irq_time; - static uint32_t cnt = 0; - uint32_t time; - uint32_t lpm; +static void hal_usb_irq_lpm(void) { + static const uint32_t lpm_trace_interval = MS_TO_TICKS(2000); + static uint32_t last_lpm_irq_time; + static uint32_t cnt = 0; + uint32_t time; + uint32_t lpm; - cnt++; - lpm = usbc->GLPMCFG; + cnt++; + lpm = usbc->GLPMCFG; #ifdef USB_SUSPEND - if (GET_BITFIELD(lpm, USBC_HIRD) >= USB_L1_DEEP_SLEEP_BESL) { - // Stat timer to check L1 sleep state - if (usbdev_timer_active) { - hwtimer_stop(usbdev_timer); - } - hwtimer_update_then_start(usbdev_timer, hal_usb_lpm_check, NULL, LPM_CHECK_INTERVAL); - usbdev_timer_active = 1; - lpm_entry = true; + if (GET_BITFIELD(lpm, USBC_HIRD) >= USB_L1_DEEP_SLEEP_BESL) { + // Stat timer to check L1 sleep state + if (usbdev_timer_active) { + hwtimer_stop(usbdev_timer); } + hwtimer_update_then_start(usbdev_timer, hal_usb_lpm_check, NULL, + LPM_CHECK_INTERVAL); + usbdev_timer_active = 1; + lpm_entry = true; + } #endif - time = hal_sys_timer_get(); - if (time - last_lpm_irq_time >= lpm_trace_interval || GET_BITFIELD(lpm, USBC_HIRD) >= USB_L1_DEEP_SLEEP_BESL) { - last_lpm_irq_time = time; - USB_TRACE(6,0, "LPM IRQ: 0x%08X rmtWake=%d hird=0x%x l1Res=%d slpSts=%d cnt=%u", - lpm, !!(lpm & USBC_BREMOTEWAKE), GET_BITFIELD(lpm, USBC_HIRD), - GET_BITFIELD(lpm, USBC_COREL1RES), !!(lpm & USBC_SLPSTS), cnt); - } + time = hal_sys_timer_get(); + if (time - last_lpm_irq_time >= lpm_trace_interval || + GET_BITFIELD(lpm, USBC_HIRD) >= USB_L1_DEEP_SLEEP_BESL) { + last_lpm_irq_time = time; + USB_TRACE(6, 0, + "LPM IRQ: 0x%08X rmtWake=%d hird=0x%x l1Res=%d slpSts=%d cnt=%u", + lpm, !!(lpm & USBC_BREMOTEWAKE), GET_BITFIELD(lpm, USBC_HIRD), + GET_BITFIELD(lpm, USBC_COREL1RES), !!(lpm & USBC_SLPSTS), cnt); + } } #endif -static void hal_usb_irq_handler(void) -{ - uint32_t status, rawStatus; - uint32_t statusEp, rawStatusEp; - uint32_t data; - uint8_t i; +static void hal_usb_irq_handler(void) { + uint32_t status, rawStatus; + uint32_t statusEp, rawStatusEp; + uint32_t data; + uint8_t i; - // Store interrupt flag and reset it - rawStatus = usbc->GINTSTS; - usbc->GINTSTS = rawStatus; + // Store interrupt flag and reset it + rawStatus = usbc->GINTSTS; + usbc->GINTSTS = rawStatus; - status = rawStatus & (usbc->GINTMSK & (USBC_USBRST | USBC_ENUMDONE + status = rawStatus & + (usbc->GINTMSK & (USBC_USBRST | USBC_ENUMDONE #if defined(USB_ISO) && (USB_ISO_INTERVAL == 1) - | USBC_INCOMPISOOUT | USBC_INCOMPISOIN + | USBC_INCOMPISOOUT | USBC_INCOMPISOIN #endif - | USBC_IEPINT | USBC_OEPINT - | USBC_ERLYSUSP | USBC_USBSUSP | USBC_WKUPINT - | USBC_LPM_INT)); + | USBC_IEPINT | USBC_OEPINT | USBC_ERLYSUSP | + USBC_USBSUSP | USBC_WKUPINT | USBC_LPM_INT)); - USB_TRACE(3,1, "%s: 0x%08x / 0x%08x", __FUNCTION__, status, rawStatus); + USB_TRACE(3, 1, "%s: 0x%08x / 0x%08x", __FUNCTION__, status, rawStatus); #if defined(USB_SUSPEND) && (defined(PMU_USB_PIN_CHECK) || defined(USB_LPM)) - bool stop_timer = true; + bool stop_timer = true; #ifdef USB_LPM - if (lpm_entry && status == USBC_ERLYSUSP && (usbc->DSTS & USBC_ERRTICERR) == 0) { - // LPM TL1TokenRetry (8 us) timer has expired. L1 state transition will be finished - // after TL1Residency (50 us) timer from now. - stop_timer = false; - } else { - lpm_entry = false; - } + if (lpm_entry && status == USBC_ERLYSUSP && + (usbc->DSTS & USBC_ERRTICERR) == 0) { + // LPM TL1TokenRetry (8 us) timer has expired. L1 state transition will be + // finished after TL1Residency (50 us) timer from now. + stop_timer = false; + } else { + lpm_entry = false; + } #endif - if (stop_timer) { - hal_usb_stop_usbdev_timer(); - } + if (stop_timer) { + hal_usb_stop_usbdev_timer(); + } #endif - if (status & USBC_USBRST) { - // Usb reset - hal_usb_irq_reset(); + if (status & USBC_USBRST) { + // Usb reset + hal_usb_irq_reset(); - // We got a reset, and reseted the soft state machine: Discard all other - // interrupt causes. - status &= USBC_ENUMDONE; - } + // We got a reset, and reseted the soft state machine: Discard all other + // interrupt causes. + status &= USBC_ENUMDONE; + } - if (status & USBC_ENUMDONE) { - // Enumeration done - hal_usb_irq_enum_done(); - } + if (status & USBC_ENUMDONE) { + // Enumeration done + hal_usb_irq_enum_done(); + } #if defined(USB_ISO) && (USB_ISO_INTERVAL == 1) - if (status & USBC_INCOMPISOOUT) { - // Incomplete ISO OUT - hal_usb_irq_incomp_iso_out(); - } + if (status & USBC_INCOMPISOOUT) { + // Incomplete ISO OUT + hal_usb_irq_incomp_iso_out(); + } - if (status & USBC_INCOMPISOIN) { - // Incomplete ISO IN - hal_usb_irq_incomp_iso_in(); - } + if (status & USBC_INCOMPISOIN) { + // Incomplete ISO IN + hal_usb_irq_incomp_iso_in(); + } #endif - if (status & USBC_IEPINT) { - // Tx - data = usbc->DAINT & usbc->DAINTMSK; - for (i = 0; i < EPNUM; ++i) { - if (data & USBC_INEPMSK(1 << i)) { - if (i == 0) { - // EP0 - rawStatusEp = usbc->DIEPINT0; - usbc->DIEPINT0 = rawStatusEp; - statusEp = rawStatusEp & usbc->DIEPMSK; + if (status & USBC_IEPINT) { + // Tx + data = usbc->DAINT & usbc->DAINTMSK; + for (i = 0; i < EPNUM; ++i) { + if (data & USBC_INEPMSK(1 << i)) { + if (i == 0) { + // EP0 + rawStatusEp = usbc->DIEPINT0; + usbc->DIEPINT0 = rawStatusEp; + statusEp = rawStatusEp & usbc->DIEPMSK; - if ((statusEp & USBC_TIMEOUT) || (statusEp & USBC_INTKNTXFEMP)) { - usbc->DIEPMSK &= ~USBC_INTKNTXFEMPMSK; - hal_usb_stall_ep(EP_IN, i); - } else if (statusEp & USBC_XFERCOMPL) { - // Handle ep0 command - hal_usb_handle_ep0_packet(EP_IN, rawStatusEp); - } - } else { - rawStatusEp = usbc->DIEPnCONFIG[i - 1].DIEPINT; - usbc->DIEPnCONFIG[i - 1].DIEPINT = rawStatusEp; - statusEp = rawStatusEp & usbc->DIEPMSK; + if ((statusEp & USBC_TIMEOUT) || (statusEp & USBC_INTKNTXFEMP)) { + usbc->DIEPMSK &= ~USBC_INTKNTXFEMPMSK; + hal_usb_stall_ep(EP_IN, i); + } else if (statusEp & USBC_XFERCOMPL) { + // Handle ep0 command + hal_usb_handle_ep0_packet(EP_IN, rawStatusEp); + } + } else { + rawStatusEp = usbc->DIEPnCONFIG[i - 1].DIEPINT; + usbc->DIEPnCONFIG[i - 1].DIEPINT = rawStatusEp; + statusEp = rawStatusEp & usbc->DIEPMSK; - if ((statusEp & USBC_TIMEOUT) || (statusEp & USBC_XFERCOMPL)) { - hal_usb_send_epn_complete(i, rawStatusEp); - } - } - } + if ((statusEp & USBC_TIMEOUT) || (statusEp & USBC_XFERCOMPL)) { + hal_usb_send_epn_complete(i, rawStatusEp); + } } + } } + } - if (status & USBC_OEPINT) { - // Rx - data = usbc->DAINT & usbc->DAINTMSK; - for (i = 0; i < EPNUM; ++i) { - if (data & USBC_OUTEPMSK(1 << i)) { - if (i == 0) { - rawStatusEp = usbc->DOEPINT0; - usbc->DOEPINT0 = rawStatusEp; - statusEp = rawStatusEp & usbc->DOEPMSK; + if (status & USBC_OEPINT) { + // Rx + data = usbc->DAINT & usbc->DAINTMSK; + for (i = 0; i < EPNUM; ++i) { + if (data & USBC_OUTEPMSK(1 << i)) { + if (i == 0) { + rawStatusEp = usbc->DOEPINT0; + usbc->DOEPINT0 = rawStatusEp; + statusEp = rawStatusEp & usbc->DOEPMSK; - if (statusEp & USBC_OUTTKNEPDIS) { - usbc->DOEPMSK &= ~USBC_OUTTKNEPDISMSK; - hal_usb_stall_ep(EP_OUT, i); - if (statusEp & USBC_XFERCOMPL) { - // Always enable setup packet receiving - hal_usb_recv_ep0(); - } - } else if (statusEp & (USBC_XFERCOMPL | USBC_SETUP)) { - // Handle ep0 command - hal_usb_handle_ep0_packet(EP_OUT, rawStatusEp); - } - } else { - rawStatusEp = usbc->DOEPnCONFIG[i - 1].DOEPINT; - usbc->DOEPnCONFIG[i - 1].DOEPINT = rawStatusEp; - statusEp = rawStatusEp & usbc->DOEPMSK; - - if (statusEp & USBC_XFERCOMPL) { - hal_usb_recv_epn_complete(i, rawStatusEp); - } - } + if (statusEp & USBC_OUTTKNEPDIS) { + usbc->DOEPMSK &= ~USBC_OUTTKNEPDISMSK; + hal_usb_stall_ep(EP_OUT, i); + if (statusEp & USBC_XFERCOMPL) { + // Always enable setup packet receiving + hal_usb_recv_ep0(); } + } else if (statusEp & (USBC_XFERCOMPL | USBC_SETUP)) { + // Handle ep0 command + hal_usb_handle_ep0_packet(EP_OUT, rawStatusEp); + } + } else { + rawStatusEp = usbc->DOEPnCONFIG[i - 1].DOEPINT; + usbc->DOEPnCONFIG[i - 1].DOEPINT = rawStatusEp; + statusEp = rawStatusEp & usbc->DOEPMSK; + + if (statusEp & USBC_XFERCOMPL) { + hal_usb_recv_epn_complete(i, rawStatusEp); + } } + } } + } #ifdef USB_SUSPEND - if (status & USBC_ERLYSUSP) { - if (usbc->DSTS & USBC_ERRTICERR) { - hal_usb_soft_disconnect(); - return; - } + if (status & USBC_ERLYSUSP) { + if (usbc->DSTS & USBC_ERRTICERR) { + hal_usb_soft_disconnect(); + return; } + } - if (status & USBC_USBSUSP) { - hal_usb_sleep(USB_SLEEP_SUSPEND); - } + if (status & USBC_USBSUSP) { + hal_usb_sleep(USB_SLEEP_SUSPEND); + } - if (status & USBC_WKUPINT) { - hal_usb_wakeup(); - } + if (status & USBC_WKUPINT) { + hal_usb_wakeup(); + } #endif #ifdef USB_LPM - if (status & USBC_LPM_INT) { - hal_usb_irq_lpm(); - } + if (status & USBC_LPM_INT) { + hal_usb_irq_lpm(); + } #endif } diff --git a/platform/hal/hal_usbhost.c b/platform/hal/hal_usbhost.c index 3ec3596..3e36894 100644 --- a/platform/hal/hal_usbhost.c +++ b/platform/hal/hal_usbhost.c @@ -15,55 +15,67 @@ ****************************************************************************/ #ifdef CHIP_HAS_USB -#include "plat_addr_map.h" -#include "reg_usb.h" #include "hal_usbhost.h" -#include "hal_trace.h" -#include "hal_cmu.h" -#include "hal_timer.h" -#include "hal_sysfreq.h" -#include "string.h" #include "cmsis_nvic.h" +#include "hal_cmu.h" +#include "hal_sysfreq.h" +#include "hal_timer.h" +#include "hal_trace.h" #include "hwtimer_list.h" +#include "plat_addr_map.h" #include "pmu.h" +#include "reg_usb.h" +#include "string.h" -#define MAX_CHAN_NUM 10 -#define MAX_EP_NUM 16 +#define MAX_CHAN_NUM 10 +#define MAX_EP_NUM 16 -#define MAX_XFER_SIZE (USBC_HCTSIZN_XFERSIZE_MASK >> USBC_HCTSIZN_XFERSIZE_SHIFT) -#define MAX_XFER_PKT (USBC_HCTSIZN_PKTCNT_MASK >> USBC_HCTSIZN_PKTCNT_SHIFT) +#define MAX_XFER_SIZE \ + (USBC_HCTSIZN_XFERSIZE_MASK >> USBC_HCTSIZN_XFERSIZE_SHIFT) +#define MAX_XFER_PKT (USBC_HCTSIZN_PKTCNT_MASK >> USBC_HCTSIZN_PKTCNT_SHIFT) -#define HAL_USBC_PHY_FREQ_MHZ 48 -#define HAL_USBC_PHY_FREQ_MHZ_HS 60 -#define HAL_USBC_HPRT_WC_MASK \ - (USBC_HPRT_PRTSUSP | USBC_HPRT_PRTOVRCURRCHNG | USBC_HPRT_PRTENCHNG | USBC_HPRT_PRTENA | USBC_HPRT_PRTCONNDET) +#define HAL_USBC_PHY_FREQ_MHZ 48 +#define HAL_USBC_PHY_FREQ_MHZ_HS 60 +#define HAL_USBC_HPRT_WC_MASK \ + (USBC_HPRT_PRTSUSP | USBC_HPRT_PRTOVRCURRCHNG | USBC_HPRT_PRTENCHNG | \ + USBC_HPRT_PRTENA | USBC_HPRT_PRTCONNDET) -#define HAL_USBHOST_TIMEOUT_TICKS MS_TO_TICKS(200) +#define HAL_USBHOST_TIMEOUT_TICKS MS_TO_TICKS(200) -#define USBHOST_TRACE(n, mask, str, ...) { if (usbhost_trmask & (1 << mask)) { TRACE(n, str, ##__VA_ARGS__); } } -#define USBHOST_FUNC_ENTRY_TRACE(mask) { if (usbhost_trmask & (1 << mask)) { FUNC_ENTRY_TRACE(); } } +#define USBHOST_TRACE(n, mask, str, ...) \ + { \ + if (usbhost_trmask & (1 << mask)) { \ + TRACE(n, str, ##__VA_ARGS__); \ + } \ + } +#define USBHOST_FUNC_ENTRY_TRACE(mask) \ + { \ + if (usbhost_trmask & (1 << mask)) { \ + FUNC_ENTRY_TRACE(); \ + } \ + } enum HAL_USBHOST_CHAN_STATE_T { - HAL_USBHOST_CHAN_IDLE, - HAL_USBHOST_CHAN_ALLOC, - HAL_USBHOST_CHAN_INIT, - HAL_USBHOST_CHAN_XFER, + HAL_USBHOST_CHAN_IDLE, + HAL_USBHOST_CHAN_ALLOC, + HAL_USBHOST_CHAN_INIT, + HAL_USBHOST_CHAN_XFER, - HAL_USBHOST_CHAN_QTY + HAL_USBHOST_CHAN_QTY }; struct HAL_USBHOST_CHAN_DESC_T { - enum HAL_USBHOST_CHAN_STATE_T state; - uint32_t start_xfer_size; - uint16_t start_pkt_cnt; - uint8_t err_cnt; - struct HAL_USBHOST_CHAN_TYPE_T type; - struct HAL_USBHOST_XFER_T xfer; + enum HAL_USBHOST_CHAN_STATE_T state; + uint32_t start_xfer_size; + uint16_t start_pkt_cnt; + uint8_t err_cnt; + struct HAL_USBHOST_CHAN_TYPE_T type; + struct HAL_USBHOST_XFER_T xfer; }; static const uint32_t usbhost_trmask = (1 << 0); //~0UL; //(1 << 3) | (1 << 4); -static struct USBC_T * const usbc = (struct USBC_T *)USB_BASE; +static struct USBC_T *const usbc = (struct USBC_T *)USB_BASE; static HAL_USBHOST_PORT_HANDLER port_handler; static HAL_USBHOST_DELAY_FUNC delay_func; @@ -88,693 +100,702 @@ static uint32_t hal_usbhost_get_xfer_size(uint8_t chan, int complete); static void hal_usbhost_irq_handler(void); static void hal_usbhost_timeout(void *param); -void hal_usbhost_halt_chan(uint8_t chan) -{ - uint32_t mask; +void hal_usbhost_halt_chan(uint8_t chan) { + uint32_t mask; - USBHOST_TRACE(2,17, "%s: %d", __FUNCTION__, chan); + USBHOST_TRACE(2, 17, "%s: %d", __FUNCTION__, chan); - if (chan >= MAX_CHAN_NUM) { - return; - } + if (chan >= MAX_CHAN_NUM) { + return; + } - hwtimer_stop(usbhost_timer[chan]); + hwtimer_stop(usbhost_timer[chan]); - mask = usbc->HCSR[chan].HCINTMSKn; - usbc->HCSR[chan].HCINTMSKn = 0; - if ((usbc->HCSR[chan].HCCHARn & USBC_HCCHARN_CHENA) == 0) { - goto _exit; - } - usbc->HCSR[chan].HCINTn = USBC_HCINTN_CHHLTD; - usbc->HCSR[chan].HCCHARn |= USBC_HCCHARN_CHENA | USBC_HCCHARN_CHDIS; - while ((usbc->HCSR[chan].HCINTn & USBC_HCINTN_CHHLTD) == 0); + mask = usbc->HCSR[chan].HCINTMSKn; + usbc->HCSR[chan].HCINTMSKn = 0; + if ((usbc->HCSR[chan].HCCHARn & USBC_HCCHARN_CHENA) == 0) { + goto _exit; + } + usbc->HCSR[chan].HCINTn = USBC_HCINTN_CHHLTD; + usbc->HCSR[chan].HCCHARn |= USBC_HCCHARN_CHENA | USBC_HCCHARN_CHDIS; + while ((usbc->HCSR[chan].HCINTn & USBC_HCINTN_CHHLTD) == 0) + ; _exit: - usbc->HCSR[chan].HCINTn = ~0UL; - usbc->HCSR[chan].HCINTMSKn = mask; + usbc->HCSR[chan].HCINTn = ~0UL; + usbc->HCSR[chan].HCINTMSKn = mask; } -static void hal_usbhost_soft_reset(void) -{ - usbc->GRSTCTL |= USBC_CSFTRST; - while ((usbc->GRSTCTL & USBC_CSFTRST) != 0); - while ((usbc->GRSTCTL & USBC_AHBIDLE) == 0); +static void hal_usbhost_soft_reset(void) { + usbc->GRSTCTL |= USBC_CSFTRST; + while ((usbc->GRSTCTL & USBC_CSFTRST) != 0) + ; + while ((usbc->GRSTCTL & USBC_AHBIDLE) == 0) + ; } -static void hal_usbhost_init_phy(void) -{ - usbc->GUSBCFG |= USBC_FORCEHSTMODE | USBC_ULPIAUTORES | USBC_ULPIFSLS | - USBC_PHYSEL | USBC_ULPI_UTMI_SEL; - usbc->GUSBCFG &= ~(USBC_FSINTF | USBC_PHYIF | USBC_USBTRDTIM_MASK); - // USBC_USBTRDTIM(9) if AHB bus is 26M - usbc->GUSBCFG |= USBC_USBTRDTIM(5); +static void hal_usbhost_init_phy(void) { + usbc->GUSBCFG |= USBC_FORCEHSTMODE | USBC_ULPIAUTORES | USBC_ULPIFSLS | + USBC_PHYSEL | USBC_ULPI_UTMI_SEL; + usbc->GUSBCFG &= ~(USBC_FSINTF | USBC_PHYIF | USBC_USBTRDTIM_MASK); + // USBC_USBTRDTIM(9) if AHB bus is 26M + usbc->GUSBCFG |= USBC_USBTRDTIM(5); } -int hal_usbhost_open(HAL_USBHOST_PORT_HANDLER port_cb, HAL_USBHOST_DELAY_FUNC delay_fn) -{ - int i; +int hal_usbhost_open(HAL_USBHOST_PORT_HANDLER port_cb, + HAL_USBHOST_DELAY_FUNC delay_fn) { + int i; - USBHOST_FUNC_ENTRY_TRACE(16); + USBHOST_FUNC_ENTRY_TRACE(16); - for (i = 0; i < MAX_CHAN_NUM; i++) { - chan_desc[i].state = HAL_USBHOST_CHAN_IDLE; - } + for (i = 0; i < MAX_CHAN_NUM; i++) { + chan_desc[i].state = HAL_USBHOST_CHAN_IDLE; + } - hal_sysfreq_req(HAL_SYSFREQ_USER_USB, HAL_CMU_FREQ_52M); + hal_sysfreq_req(HAL_SYSFREQ_USER_USB, HAL_CMU_FREQ_52M); - hal_cmu_usb_set_host_mode(); - hal_cmu_usb_clock_enable(); + hal_cmu_usb_set_host_mode(); + hal_cmu_usb_clock_enable(); - hal_usbhost_soft_reset(); - hal_usbhost_init_phy(); - // Reset after selecting PHY - hal_usbhost_soft_reset(); - // Some core cfg (except for PHY selection) will also be reset during soft reset - hal_usbhost_init_phy(); + hal_usbhost_soft_reset(); + hal_usbhost_init_phy(); + // Reset after selecting PHY + hal_usbhost_soft_reset(); + // Some core cfg (except for PHY selection) will also be reset during soft + // reset + hal_usbhost_init_phy(); #ifdef USB_HIGH_SPEED - usbc->HCFG = USBC_HCFG_FSLSPCLKSEL(0); + usbc->HCFG = USBC_HCFG_FSLSPCLKSEL(0); #else - usbc->HCFG = USBC_HCFG_FSLSSUPP | USBC_HCFG_FSLSPCLKSEL(1); + usbc->HCFG = USBC_HCFG_FSLSSUPP | USBC_HCFG_FSLSPCLKSEL(1); #endif - usbc->HPRT = USBC_HPRT_PRTPWR; + usbc->HPRT = USBC_HPRT_PRTPWR; - // Clear previous interrupts - usbc->GINTMSK = 0; - usbc->GINTSTS = ~0UL; - usbc->HAINTMSK = 0; - for (i = 0; i < MAX_CHAN_NUM; i++) { - usbc->HCSR[i].HCINTMSKn = 0; - usbc->HCSR[i].HCINTn = ~0UL; - } - usbc->GINTMSK = USBC_PRTINT | USBC_HCHINT | USBC_DISCONNINT; + // Clear previous interrupts + usbc->GINTMSK = 0; + usbc->GINTSTS = ~0UL; + usbc->HAINTMSK = 0; + for (i = 0; i < MAX_CHAN_NUM; i++) { + usbc->HCSR[i].HCINTMSKn = 0; + usbc->HCSR[i].HCINTn = ~0UL; + } + usbc->GINTMSK = USBC_PRTINT | USBC_HCHINT | USBC_DISCONNINT; - // Enable DMA mode - // Burst size 16 words - usbc->GAHBCFG = USBC_DMAEN | USBC_HBSTLEN(7); - usbc->GAHBCFG |= USBC_GLBLINTRMSK; + // Enable DMA mode + // Burst size 16 words + usbc->GAHBCFG = USBC_DMAEN | USBC_HBSTLEN(7); + usbc->GAHBCFG |= USBC_GLBLINTRMSK; - port_handler = port_cb; - delay_func = delay_fn; + port_handler = port_cb; + delay_func = delay_fn; - usbhost_opened = true; + usbhost_opened = true; - NVIC_SetVector(USB_IRQn, (uint32_t)hal_usbhost_irq_handler); - NVIC_SetPriority(USB_IRQn, IRQ_PRIORITY_NORMAL); - NVIC_ClearPendingIRQ(USB_IRQn); - NVIC_EnableIRQ(USB_IRQn); + NVIC_SetVector(USB_IRQn, (uint32_t)hal_usbhost_irq_handler); + NVIC_SetPriority(USB_IRQn, IRQ_PRIORITY_NORMAL); + NVIC_ClearPendingIRQ(USB_IRQn); + NVIC_EnableIRQ(USB_IRQn); - //usbc->TPORTDBG1 = 0x11; + // usbc->TPORTDBG1 = 0x11; - return 0; + return 0; } -void hal_usbhost_close(void) -{ - uint8_t chan; +void hal_usbhost_close(void) { + uint8_t chan; - USBHOST_FUNC_ENTRY_TRACE(15); + USBHOST_FUNC_ENTRY_TRACE(15); #ifdef PMU_USB_PIN_CHECK - pmu_usb_disable_pin_status_check(); + pmu_usb_disable_pin_status_check(); #endif - NVIC_DisableIRQ(USB_IRQn); + NVIC_DisableIRQ(USB_IRQn); - usbhost_opened = false; + usbhost_opened = false; - hal_cmu_usb_clock_disable(); + hal_cmu_usb_clock_disable(); - for (chan = 0; chan < MAX_CHAN_NUM; chan++) { - hal_usbhost_free_chan(chan); - } + for (chan = 0; chan < MAX_CHAN_NUM; chan++) { + hal_usbhost_free_chan(chan); + } - hal_sysfreq_req(HAL_SYSFREQ_USER_USB, HAL_CMU_FREQ_32K); + hal_sysfreq_req(HAL_SYSFREQ_USER_USB, HAL_CMU_FREQ_32K); } -static void hal_usbhost_delay(uint32_t ms) -{ - if (delay_func) { - delay_func(ms); +static void hal_usbhost_delay(uint32_t ms) { + if (delay_func) { + delay_func(ms); + } else { + hal_sys_timer_delay(MS_TO_TICKS(ms)); + } +} + +void hal_usbhost_port_reset(uint32_t ms) { + int lock; + + USBHOST_TRACE(2, 14, "%s: %d", __FUNCTION__, ms); + + lock = int_lock(); + usbc->HPRT = (usbc->HPRT & ~HAL_USBC_HPRT_WC_MASK) | USBC_HPRT_PRTRST; + int_unlock(lock); + + hal_usbhost_delay(ms); + + lock = int_lock(); + usbc->HPRT = (usbc->HPRT & ~HAL_USBC_HPRT_WC_MASK) & ~USBC_HPRT_PRTRST; + int_unlock(lock); +} + +static void hal_usbhost_port_suspend(void) { + int lock; + + USBHOST_FUNC_ENTRY_TRACE(22); + + lock = int_lock(); + usbc->HPRT = (usbc->HPRT & ~HAL_USBC_HPRT_WC_MASK) | USBC_HPRT_PRTSUSP; + int_unlock(lock); + + hal_usbhost_delay(3); +} + +static void hal_usbhost_port_resume(void) { + int lock; + + USBHOST_FUNC_ENTRY_TRACE(22); + + lock = int_lock(); + usbc->HPRT = (usbc->HPRT & ~HAL_USBC_HPRT_WC_MASK) | USBC_HPRT_PRTRES; + int_unlock(lock); + + hal_usbhost_delay(20); + + lock = int_lock(); + usbc->HPRT = (usbc->HPRT & ~HAL_USBC_HPRT_WC_MASK) & ~USBC_HPRT_PRTRES; + int_unlock(lock); +} + +int hal_usbhost_get_chan(uint8_t *chan) { + int i; + uint32_t lock; + + lock = int_lock(); + for (i = 0; i < MAX_CHAN_NUM; i++) { + if (chan_desc[i].state == HAL_USBHOST_CHAN_IDLE) { + chan_desc[i].state = HAL_USBHOST_CHAN_ALLOC; + break; + } + } + int_unlock(lock); + + USBHOST_TRACE(2, 13, "%s: %d", __FUNCTION__, i); + + if (i == MAX_CHAN_NUM) { + return 1; + } + + *chan = i; + + ASSERT(usbhost_timer[i] == NULL, "%s: Prev hwtimer not released: 0x%08x", + __FUNCTION__, (uint32_t)usbhost_timer[i]); + usbhost_timer[i] = hwtimer_alloc(hal_usbhost_timeout, (void *)(uint32_t)i); + if (usbhost_timer[i] == NULL) { + USBHOST_TRACE(2, 0, "%s: WARNING: Failed to alloc hwtimer for chan=%d", + __FUNCTION__, i); + // Continue even if usbhost_timer is null + } + + return 0; +} + +int hal_usbhost_free_chan(uint8_t chan) { + USBHOST_TRACE(2, 12, "%s: %d", __FUNCTION__, chan); + + if (chan >= MAX_CHAN_NUM) { + return 1; + } + + hwtimer_stop(usbhost_timer[chan]); + hwtimer_free(usbhost_timer[chan]); + usbhost_timer[chan] = NULL; + + chan_desc[chan].state = HAL_USBHOST_CHAN_IDLE; + + return 0; +} + +int hal_usbhost_init_chan(uint8_t chan, + const struct HAL_USBHOST_CHAN_TYPE_T *type) { + USBHOST_TRACE(7, 11, "%s: chan=%d mps=%d ep=%d in=%d type=%d addr=%d", + __FUNCTION__, chan, type->mps, type->ep_num, type->ep_in, + type->ep_type, type->dev_addr); + + if (chan >= MAX_CHAN_NUM) { + return 1; + } + if (chan_desc[chan].state != HAL_USBHOST_CHAN_ALLOC) { + return 2; + } + if (usbc->HCSR[chan].HCCHARn & USBC_HCCHARN_CHENA) { + return 3; + } + if ((type->dev_addr & (USBC_HCCHARN_DEVADDR_MASK >> + USBC_HCCHARN_DEVADDR_SHIFT)) != type->dev_addr) { + return 4; + } + if (type->ep_num >= MAX_EP_NUM) { + return 5; + } + if (type->ep_type >= HAL_USBHOST_EP_QTY) { + return 6; + } + if ((type->mps & (USBC_HCCHARN_MPS_MASK >> USBC_HCCHARN_MPS_SHIFT)) != + type->mps) { + return 7; + } + if (type->mps == 0) { + return 8; + } + + memcpy(&chan_desc[chan].type, type, sizeof(chan_desc[chan].type)); + chan_desc[chan].err_cnt = 0; + + usbc->HCSR[chan].HCINTMSKn = 0; + usbc->HCSR[chan].HCINTn = ~0UL; + + usbc->HCSR[chan].HCCHARn = + USBC_HCCHARN_MPS(type->mps) | USBC_HCCHARN_EPNUM(type->ep_num) | + (type->ep_in ? USBC_HCCHARN_EPDIR : 0) | + USBC_HCCHARN_EPTYPE(type->ep_type) | USBC_HCCHARN_DEVADDR(type->dev_addr); + + usbc->HCSR[chan].HCINTMSKn = USBC_HCINTN_AHBERR | USBC_HCINTN_CHHLTD; + usbc->HAINTMSK |= (1 << chan); + usbc->GINTMSK |= USBC_HCHINT; + + chan_desc[chan].state = HAL_USBHOST_CHAN_INIT; + + return 0; +} + +int hal_usbhost_update_chan_dev_addr(uint8_t chan, uint8_t dev_addr) { + USBHOST_TRACE(3, 10, "%s: chan=%d dev_addr=%d", __FUNCTION__, chan, dev_addr); + + if (chan >= MAX_CHAN_NUM) { + return 1; + } + if (chan_desc[chan].state != HAL_USBHOST_CHAN_INIT) { + return 2; + } + + chan_desc[chan].type.dev_addr = dev_addr; + + usbc->HCSR[chan].HCCHARn = + SET_BITFIELD(usbc->HCSR[chan].HCCHARn, USBC_HCCHARN_DEVADDR, dev_addr); + + chan_desc[chan].state = HAL_USBHOST_CHAN_INIT; + + return 0; +} + +int hal_usbhost_update_chan_mps(uint8_t chan, uint16_t mps) { + USBHOST_TRACE(3, 9, "%s: chan=%d mps=%d", __FUNCTION__, chan, mps); + + if (chan >= MAX_CHAN_NUM) { + return 1; + } + if (chan_desc[chan].state != HAL_USBHOST_CHAN_INIT) { + return 2; + } + + chan_desc[chan].type.mps = mps; + + usbc->HCSR[chan].HCCHARn = + SET_BITFIELD(usbc->HCSR[chan].HCCHARn, USBC_HCCHARN_MPS, mps); + + chan_desc[chan].state = HAL_USBHOST_CHAN_INIT; + + return 0; +} + +int hal_usbhost_start_xfer(uint8_t chan, + const struct HAL_USBHOST_XFER_T *xfer) { + uint32_t max_periodic_len; + uint32_t pkt_cnt; + uint32_t size; + enum HAL_USBHOST_PID_TYPE_T pid; + uint8_t multi_cnt; + + USBHOST_TRACE(5, 7, "%s: chan=%d size=%u mc=%d pid=%d", __FUNCTION__, chan, + xfer->size, xfer->multi_cnt, xfer->pid); + + if (chan >= MAX_CHAN_NUM) { + return 1; + } + if (chan_desc[chan].state != HAL_USBHOST_CHAN_INIT) { + return 2; + } + if (usbc->HCSR[chan].HCCHARn & USBC_HCCHARN_CHENA) { + return 3; + } + if (((uint32_t)xfer->buf & 0x3) != 0) { + return 4; + } + if (chan_desc[chan].type.ep_type == HAL_USBHOST_EP_ISO || + chan_desc[chan].type.ep_type == HAL_USBHOST_EP_INT) { + max_periodic_len = xfer->multi_cnt * chan_desc[chan].type.mps; + if (max_periodic_len < xfer->size) { + return 5; + } + } else { + if (xfer->size > MAX_XFER_SIZE) { + return 6; + } + } + + pkt_cnt = + (xfer->size + (chan_desc[chan].type.mps - 1)) / chan_desc[chan].type.mps; + if (pkt_cnt > MAX_XFER_PKT) { + return 7; + } + if (pkt_cnt == 0) { + pkt_cnt = 1; + } + + if (chan_desc[chan].type.ep_in) { + size = pkt_cnt * chan_desc[chan].type.mps; + } else { + size = xfer->size; + } + + chan_desc[chan].start_xfer_size = size; + chan_desc[chan].start_pkt_cnt = pkt_cnt; + memcpy(&chan_desc[chan].xfer, xfer, sizeof(chan_desc[chan].xfer)); + + pid = xfer->pid; + if (pid == HAL_USBHOST_PID_AUTO) { + pid = GET_BITFIELD(usbc->HCSR[chan].HCTSIZn, USBC_HCTSIZN_PID); + } + multi_cnt = xfer->multi_cnt; + + if (chan_desc[chan].type.ep_type == HAL_USBHOST_EP_ISO || + chan_desc[chan].type.ep_type == HAL_USBHOST_EP_INT) { + multi_cnt = pkt_cnt; + + if (chan_desc[chan].type.ep_type == HAL_USBHOST_EP_ISO) { + pid = HAL_USBHOST_PID_DATA0; // Full speed + } + + if (usbc->HFNUM & 0x1) { + usbc->HCSR[chan].HCCHARn &= ~USBC_HCCHARN_ODDFRM; } else { - hal_sys_timer_delay(MS_TO_TICKS(ms)); + usbc->HCSR[chan].HCCHARn |= USBC_HCCHARN_ODDFRM; } + } + + chan_desc[chan].state = HAL_USBHOST_CHAN_XFER; + + usbc->HCSR[chan].HCTSIZn = USBC_HCTSIZN_PID(pid) | + USBC_HCTSIZN_PKTCNT(pkt_cnt) | + USBC_HCTSIZN_XFERSIZE(size); + usbc->HCSR[chan].HCDMAn = (uint32_t)xfer->buf; + + usbc->HCSR[chan].HCINTn = ~0UL; + + usbc->HCSR[chan].HCCHARn = + SET_BITFIELD(usbc->HCSR[chan].HCCHARn, USBC_HCCHARN_EC, multi_cnt); + usbc->HCSR[chan].HCCHARn &= ~USBC_HCCHARN_CHDIS; + usbc->HCSR[chan].HCCHARn |= USBC_HCCHARN_CHENA; + + if (xfer->handler) { + hwtimer_start(usbhost_timer[chan], HAL_USBHOST_TIMEOUT_TICKS); + } + + return 0; } -void hal_usbhost_port_reset(uint32_t ms) -{ - int lock; - - USBHOST_TRACE(2,14, "%s: %d", __FUNCTION__, ms); - - lock = int_lock(); - usbc->HPRT = (usbc->HPRT & ~HAL_USBC_HPRT_WC_MASK) | USBC_HPRT_PRTRST; - int_unlock(lock); - - hal_usbhost_delay(ms); - - lock = int_lock(); - usbc->HPRT = (usbc->HPRT & ~HAL_USBC_HPRT_WC_MASK) & ~USBC_HPRT_PRTRST; - int_unlock(lock); -} - -static void hal_usbhost_port_suspend(void) -{ - int lock; - - USBHOST_FUNC_ENTRY_TRACE(22); - - lock = int_lock(); - usbc->HPRT = (usbc->HPRT & ~HAL_USBC_HPRT_WC_MASK) | USBC_HPRT_PRTSUSP; - int_unlock(lock); - - hal_usbhost_delay(3); -} - -static void hal_usbhost_port_resume(void) -{ - int lock; - - USBHOST_FUNC_ENTRY_TRACE(22); - - lock = int_lock(); - usbc->HPRT = (usbc->HPRT & ~HAL_USBC_HPRT_WC_MASK) | USBC_HPRT_PRTRES; - int_unlock(lock); - - hal_usbhost_delay(20); - - lock = int_lock(); - usbc->HPRT = (usbc->HPRT & ~HAL_USBC_HPRT_WC_MASK) & ~USBC_HPRT_PRTRES; - int_unlock(lock); -} - -int hal_usbhost_get_chan(uint8_t *chan) -{ - int i; - uint32_t lock; - - lock = int_lock(); - for (i = 0; i < MAX_CHAN_NUM; i++) { - if (chan_desc[i].state == HAL_USBHOST_CHAN_IDLE) { - chan_desc[i].state = HAL_USBHOST_CHAN_ALLOC; - break; - } - } - int_unlock(lock); - - USBHOST_TRACE(2,13, "%s: %d", __FUNCTION__, i); - - if (i == MAX_CHAN_NUM) { - return 1; - } - - *chan = i; - - ASSERT(usbhost_timer[i] == NULL, "%s: Prev hwtimer not released: 0x%08x", __FUNCTION__, (uint32_t)usbhost_timer[i]); - usbhost_timer[i] = hwtimer_alloc(hal_usbhost_timeout, (void *)(uint32_t)i); - if (usbhost_timer[i] == NULL) { - USBHOST_TRACE(2,0, "%s: WARNING: Failed to alloc hwtimer for chan=%d", __FUNCTION__, i); - // Continue even if usbhost_timer is null - } - - return 0; -} - -int hal_usbhost_free_chan(uint8_t chan) -{ - USBHOST_TRACE(2,12, "%s: %d", __FUNCTION__, chan); - - if (chan >= MAX_CHAN_NUM) { - return 1; - } - - hwtimer_stop(usbhost_timer[chan]); - hwtimer_free(usbhost_timer[chan]); - usbhost_timer[chan] = NULL; - - chan_desc[chan].state = HAL_USBHOST_CHAN_IDLE; - - return 0; -} - -int hal_usbhost_init_chan(uint8_t chan, const struct HAL_USBHOST_CHAN_TYPE_T *type) -{ - USBHOST_TRACE(7,11, "%s: chan=%d mps=%d ep=%d in=%d type=%d addr=%d", - __FUNCTION__, chan, type->mps, type->ep_num, type->ep_in, type->ep_type, type->dev_addr); - - if (chan >= MAX_CHAN_NUM) { - return 1; - } - if (chan_desc[chan].state != HAL_USBHOST_CHAN_ALLOC) { - return 2; - } - if (usbc->HCSR[chan].HCCHARn & USBC_HCCHARN_CHENA) { - return 3; - } - if ((type->dev_addr & (USBC_HCCHARN_DEVADDR_MASK >> USBC_HCCHARN_DEVADDR_SHIFT)) != type->dev_addr) { - return 4; - } - if (type->ep_num >= MAX_EP_NUM) { - return 5; - } - if (type->ep_type >= HAL_USBHOST_EP_QTY) { - return 6; - } - if ((type->mps & (USBC_HCCHARN_MPS_MASK >> USBC_HCCHARN_MPS_SHIFT)) != type->mps) { - return 7; - } - if (type->mps == 0) { - return 8; - } - - memcpy(&chan_desc[chan].type, type, sizeof(chan_desc[chan].type)); - chan_desc[chan].err_cnt = 0; - - usbc->HCSR[chan].HCINTMSKn = 0; - usbc->HCSR[chan].HCINTn = ~0UL; - - usbc->HCSR[chan].HCCHARn = USBC_HCCHARN_MPS(type->mps) | USBC_HCCHARN_EPNUM(type->ep_num) | - (type->ep_in ? USBC_HCCHARN_EPDIR : 0) | USBC_HCCHARN_EPTYPE(type->ep_type) | - USBC_HCCHARN_DEVADDR(type->dev_addr); - - usbc->HCSR[chan].HCINTMSKn = USBC_HCINTN_AHBERR | USBC_HCINTN_CHHLTD; - usbc->HAINTMSK |= (1 << chan); - usbc->GINTMSK |= USBC_HCHINT; - - chan_desc[chan].state = HAL_USBHOST_CHAN_INIT; - - return 0; -} - -int hal_usbhost_update_chan_dev_addr(uint8_t chan, uint8_t dev_addr) -{ - USBHOST_TRACE(3,10, "%s: chan=%d dev_addr=%d", __FUNCTION__, chan, dev_addr); - - if (chan >= MAX_CHAN_NUM) { - return 1; - } - if (chan_desc[chan].state != HAL_USBHOST_CHAN_INIT) { - return 2; - } - - chan_desc[chan].type.dev_addr = dev_addr; - - usbc->HCSR[chan].HCCHARn = SET_BITFIELD(usbc->HCSR[chan].HCCHARn, USBC_HCCHARN_DEVADDR, dev_addr); - - chan_desc[chan].state = HAL_USBHOST_CHAN_INIT; - - return 0; -} - -int hal_usbhost_update_chan_mps(uint8_t chan, uint16_t mps) -{ - USBHOST_TRACE(3,9, "%s: chan=%d mps=%d", __FUNCTION__, chan, mps); - - if (chan >= MAX_CHAN_NUM) { - return 1; - } - if (chan_desc[chan].state != HAL_USBHOST_CHAN_INIT) { - return 2; - } - - chan_desc[chan].type.mps = mps; - - usbc->HCSR[chan].HCCHARn = SET_BITFIELD(usbc->HCSR[chan].HCCHARn, USBC_HCCHARN_MPS, mps); - - chan_desc[chan].state = HAL_USBHOST_CHAN_INIT; - - return 0; -} - -int hal_usbhost_start_xfer(uint8_t chan, const struct HAL_USBHOST_XFER_T *xfer) -{ - uint32_t max_periodic_len; - uint32_t pkt_cnt; - uint32_t size; - enum HAL_USBHOST_PID_TYPE_T pid; - uint8_t multi_cnt; - - USBHOST_TRACE(5,7, "%s: chan=%d size=%u mc=%d pid=%d", - __FUNCTION__, chan, xfer->size, xfer->multi_cnt, xfer->pid); - - if (chan >= MAX_CHAN_NUM) { - return 1; - } - if (chan_desc[chan].state != HAL_USBHOST_CHAN_INIT) { - return 2; - } - if (usbc->HCSR[chan].HCCHARn & USBC_HCCHARN_CHENA) { - return 3; - } - if (((uint32_t)xfer->buf & 0x3) != 0) { - return 4; - } - if (chan_desc[chan].type.ep_type == HAL_USBHOST_EP_ISO || - chan_desc[chan].type.ep_type == HAL_USBHOST_EP_INT) { - max_periodic_len = xfer->multi_cnt * chan_desc[chan].type.mps; - if (max_periodic_len < xfer->size) { - return 5; - } - } else { - if (xfer->size > MAX_XFER_SIZE) { - return 6; - } - } - - pkt_cnt = (xfer->size + (chan_desc[chan].type.mps - 1)) / chan_desc[chan].type.mps; - if (pkt_cnt > MAX_XFER_PKT) { - return 7; - } - if (pkt_cnt == 0) { - pkt_cnt = 1; - } - - if (chan_desc[chan].type.ep_in) { - size = pkt_cnt * chan_desc[chan].type.mps; - } else { - size = xfer->size; - } - - chan_desc[chan].start_xfer_size = size; - chan_desc[chan].start_pkt_cnt = pkt_cnt; - memcpy(&chan_desc[chan].xfer, xfer, sizeof(chan_desc[chan].xfer)); - - pid = xfer->pid; - if (pid == HAL_USBHOST_PID_AUTO) { - pid = GET_BITFIELD(usbc->HCSR[chan].HCTSIZn, USBC_HCTSIZN_PID); - } - multi_cnt = xfer->multi_cnt; - - if (chan_desc[chan].type.ep_type == HAL_USBHOST_EP_ISO || - chan_desc[chan].type.ep_type == HAL_USBHOST_EP_INT) { - multi_cnt = pkt_cnt; - - if (chan_desc[chan].type.ep_type == HAL_USBHOST_EP_ISO) { - pid = HAL_USBHOST_PID_DATA0; // Full speed - } - - if (usbc->HFNUM & 0x1) { - usbc->HCSR[chan].HCCHARn &= ~USBC_HCCHARN_ODDFRM; - } else { - usbc->HCSR[chan].HCCHARn |= USBC_HCCHARN_ODDFRM; - } - } - - chan_desc[chan].state = HAL_USBHOST_CHAN_XFER; - - usbc->HCSR[chan].HCTSIZn = USBC_HCTSIZN_PID(pid) | USBC_HCTSIZN_PKTCNT(pkt_cnt) | USBC_HCTSIZN_XFERSIZE(size); - usbc->HCSR[chan].HCDMAn = (uint32_t)xfer->buf; - - usbc->HCSR[chan].HCINTn = ~0UL; - - usbc->HCSR[chan].HCCHARn = SET_BITFIELD(usbc->HCSR[chan].HCCHARn, USBC_HCCHARN_EC, multi_cnt); - usbc->HCSR[chan].HCCHARn &= ~USBC_HCCHARN_CHDIS; - usbc->HCSR[chan].HCCHARn |= USBC_HCCHARN_CHENA; - - if (xfer->handler) { - hwtimer_start(usbhost_timer[chan], HAL_USBHOST_TIMEOUT_TICKS); - } - - return 0; -} - -static void hal_usbhost_setup_xfer_handler(uint8_t chan, uint8_t *buf, uint32_t len, enum HAL_USBHOST_XFER_ERR_T error) -{ - int ret; - struct HAL_USBHOST_XFER_T xfer; - enum HAL_USBHOST_SETUP_STAGE_T handler_stage; - uint8_t handler_chan; - - ret = 1; - if (error != HAL_USBHOST_XFER_ERR_NONE) { - goto _exit; - } - - USBHOST_TRACE(5,6, "%s: chan=%d cur=%d next=%d error=%d", - __FUNCTION__, chan, cur_setup_stage, setup_xfer.next_stage, error); - - handler_stage = setup_xfer.next_stage; - handler_chan = HAL_USBHOST_CHAN_NONE; - - switch (handler_stage) { - case HAL_USBHOST_SETUP_DATA_IN: - case HAL_USBHOST_SETUP_DATA_OUT: - xfer.buf = setup_xfer.data_buf; - xfer.size = setup_xfer.setup_pkt.wLength; - xfer.pid = HAL_USBHOST_PID_DATA1; - xfer.multi_cnt = 0; - xfer.handler = hal_usbhost_setup_xfer_handler; - if (handler_stage == HAL_USBHOST_SETUP_DATA_IN) { - handler_chan = setup_xfer.chan_in; - setup_xfer.next_stage = HAL_USBHOST_SETUP_STATUS_OUT; - } else { - handler_chan = setup_xfer.chan_out; - setup_xfer.next_stage = HAL_USBHOST_SETUP_STATUS_IN; - } - ret = hal_usbhost_start_xfer(handler_chan, &xfer); - if (ret) { - goto _exit; - } - break; - case HAL_USBHOST_SETUP_STATUS_IN: - case HAL_USBHOST_SETUP_STATUS_OUT: - if (cur_setup_stage == HAL_USBHOST_SETUP_DATA_IN) { - if (setup_xfer.setup_pkt.wLength != len) { - USBHOST_TRACE(2,0, "Invalid setup data length: %d expect=%d", len, setup_xfer.setup_pkt.wLength); - // Update received len - setup_xfer.setup_pkt.wLength = len; - } - } - xfer.buf = NULL; - xfer.size = 0; - xfer.pid = HAL_USBHOST_PID_DATA1; - xfer.multi_cnt = 0; - xfer.handler = hal_usbhost_setup_xfer_handler; - if (handler_stage == HAL_USBHOST_SETUP_STATUS_IN) { - handler_chan = setup_xfer.chan_in; - } else { - handler_chan = setup_xfer.chan_out; - } - setup_xfer.next_stage = HAL_USBHOST_SETUP_DONE; - ret = hal_usbhost_start_xfer(handler_chan, &xfer); - if (ret) { - goto _exit; - } - break; - case HAL_USBHOST_SETUP_DONE: - ret = 0; - goto _exit; - break; - default: - ASSERT(false, "Invalid setup next stage %d for chan %d", setup_xfer.next_stage, chan); - ret = 1; - goto _exit; - } - - cur_setup_stage = handler_stage; - - return; - -_exit: - if (error != HAL_USBHOST_XFER_ERR_NONE) { - setup_xfer.next_stage = HAL_USBHOST_SETUP_ERROR; - } - - { - struct HAL_USBHOST_SETUP_XFER_T setup; - - memcpy(&setup, &setup_xfer, sizeof(setup)); - in_setup = false; - if (setup.handler) { - setup.handler(&setup, ret); - } - } - - return; -} - -int hal_usbhost_start_setup_xfer(const struct HAL_USBHOST_SETUP_XFER_T *setup, uint32_t *recv_len) -{ - int ret; - struct HAL_USBHOST_XFER_T xfer; - - USBHOST_TRACE(7,6, "%s: out=%d in=%d type=0x%02x req=0x%02x wlen=%d next_stage=%d", - __FUNCTION__, setup->chan_out, setup->chan_in, setup->setup_pkt.bmRequestType, - setup->setup_pkt.bRequest, setup->setup_pkt.wLength, setup->next_stage); - - if (setup->next_stage >= HAL_USBHOST_SETUP_STATUS_OUT) { - return -1; - } - - if (in_setup) { - return -2; - } - in_setup = true; - - memcpy(&setup_xfer, setup, sizeof(setup_xfer)); - cur_setup_stage = HAL_USBHOST_SETUP_STAGE_QTY; - - xfer.buf = (uint8_t *)&setup_xfer.setup_pkt; - xfer.size = sizeof(setup_xfer.setup_pkt); - xfer.pid = HAL_USBHOST_PID_SETUP; +static void hal_usbhost_setup_xfer_handler(uint8_t chan, uint8_t *buf, + uint32_t len, + enum HAL_USBHOST_XFER_ERR_T error) { + int ret; + struct HAL_USBHOST_XFER_T xfer; + enum HAL_USBHOST_SETUP_STAGE_T handler_stage; + uint8_t handler_chan; + + ret = 1; + if (error != HAL_USBHOST_XFER_ERR_NONE) { + goto _exit; + } + + USBHOST_TRACE(5, 6, "%s: chan=%d cur=%d next=%d error=%d", __FUNCTION__, chan, + cur_setup_stage, setup_xfer.next_stage, error); + + handler_stage = setup_xfer.next_stage; + handler_chan = HAL_USBHOST_CHAN_NONE; + + switch (handler_stage) { + case HAL_USBHOST_SETUP_DATA_IN: + case HAL_USBHOST_SETUP_DATA_OUT: + xfer.buf = setup_xfer.data_buf; + xfer.size = setup_xfer.setup_pkt.wLength; + xfer.pid = HAL_USBHOST_PID_DATA1; xfer.multi_cnt = 0; xfer.handler = hal_usbhost_setup_xfer_handler; - - ret = hal_usbhost_start_xfer(setup_xfer.chan_out, &xfer); + if (handler_stage == HAL_USBHOST_SETUP_DATA_IN) { + handler_chan = setup_xfer.chan_in; + setup_xfer.next_stage = HAL_USBHOST_SETUP_STATUS_OUT; + } else { + handler_chan = setup_xfer.chan_out; + setup_xfer.next_stage = HAL_USBHOST_SETUP_STATUS_IN; + } + ret = hal_usbhost_start_xfer(handler_chan, &xfer); if (ret) { - in_setup = false; - return ret; + goto _exit; } - - if (setup->handler == NULL) { - while (in_setup); - if (setup_xfer.next_stage != HAL_USBHOST_SETUP_DONE) { - return -3; - } - if (recv_len) { - if (setup->next_stage == HAL_USBHOST_SETUP_DATA_IN) { - *recv_len = setup_xfer.setup_pkt.wLength; - } else { - *recv_len = 0; - } - } + break; + case HAL_USBHOST_SETUP_STATUS_IN: + case HAL_USBHOST_SETUP_STATUS_OUT: + if (cur_setup_stage == HAL_USBHOST_SETUP_DATA_IN) { + if (setup_xfer.setup_pkt.wLength != len) { + USBHOST_TRACE(2, 0, "Invalid setup data length: %d expect=%d", len, + setup_xfer.setup_pkt.wLength); + // Update received len + setup_xfer.setup_pkt.wLength = len; + } } + xfer.buf = NULL; + xfer.size = 0; + xfer.pid = HAL_USBHOST_PID_DATA1; + xfer.multi_cnt = 0; + xfer.handler = hal_usbhost_setup_xfer_handler; + if (handler_stage == HAL_USBHOST_SETUP_STATUS_IN) { + handler_chan = setup_xfer.chan_in; + } else { + handler_chan = setup_xfer.chan_out; + } + setup_xfer.next_stage = HAL_USBHOST_SETUP_DONE; + ret = hal_usbhost_start_xfer(handler_chan, &xfer); + if (ret) { + goto _exit; + } + break; + case HAL_USBHOST_SETUP_DONE: + ret = 0; + goto _exit; + break; + default: + ASSERT(false, "Invalid setup next stage %d for chan %d", + setup_xfer.next_stage, chan); + ret = 1; + goto _exit; + } - return 0; + cur_setup_stage = handler_stage; + + return; + +_exit: + if (error != HAL_USBHOST_XFER_ERR_NONE) { + setup_xfer.next_stage = HAL_USBHOST_SETUP_ERROR; + } + + { + struct HAL_USBHOST_SETUP_XFER_T setup; + + memcpy(&setup, &setup_xfer, sizeof(setup)); + in_setup = false; + if (setup.handler) { + setup.handler(&setup, ret); + } + } + + return; } -static void hal_usbhost_stop_all_chans(void) -{ - int i; - uint32_t xfer; - HAL_USBHOST_XFER_COMPL_HANDLER handler; - uint8_t *buf; +int hal_usbhost_start_setup_xfer(const struct HAL_USBHOST_SETUP_XFER_T *setup, + uint32_t *recv_len) { + int ret; + struct HAL_USBHOST_XFER_T xfer; - usbc->HAINTMSK = 0; + USBHOST_TRACE(7, 6, + "%s: out=%d in=%d type=0x%02x req=0x%02x wlen=%d next_stage=%d", + __FUNCTION__, setup->chan_out, setup->chan_in, + setup->setup_pkt.bmRequestType, setup->setup_pkt.bRequest, + setup->setup_pkt.wLength, setup->next_stage); - for (i = 0; i < MAX_CHAN_NUM; i++) { - hal_usbhost_halt_chan(i); + if (setup->next_stage >= HAL_USBHOST_SETUP_STATUS_OUT) { + return -1; + } - if (chan_desc[i].state != HAL_USBHOST_CHAN_XFER) { - continue; - } + if (in_setup) { + return -2; + } + in_setup = true; - if (chan_desc[i].xfer.handler) { - // TODO: Check whether HCTSIZn is reset after channel is halted - xfer = hal_usbhost_get_xfer_size(i, 0); + memcpy(&setup_xfer, setup, sizeof(setup_xfer)); + cur_setup_stage = HAL_USBHOST_SETUP_STAGE_QTY; - // Reset the chan_desc to INIT state so that it can be reused in callback - handler = chan_desc[i].xfer.handler; - buf = chan_desc[i].xfer.buf; - chan_desc[i].state = HAL_USBHOST_CHAN_INIT; + xfer.buf = (uint8_t *)&setup_xfer.setup_pkt; + xfer.size = sizeof(setup_xfer.setup_pkt); + xfer.pid = HAL_USBHOST_PID_SETUP; + xfer.multi_cnt = 0; + xfer.handler = hal_usbhost_setup_xfer_handler; - handler(i, buf, xfer, HAL_USBHOST_XFER_ERR_DISCONN); - } + ret = hal_usbhost_start_xfer(setup_xfer.chan_out, &xfer); + if (ret) { + in_setup = false; + return ret; + } + + if (setup->handler == NULL) { + while (in_setup) + ; + if (setup_xfer.next_stage != HAL_USBHOST_SETUP_DONE) { + return -3; } + if (recv_len) { + if (setup->next_stage == HAL_USBHOST_SETUP_DATA_IN) { + *recv_len = setup_xfer.setup_pkt.wLength; + } else { + *recv_len = 0; + } + } + } - usbc->HAINT = ~0UL; + return 0; } -static void hal_usbhost_disconn_handler(void) -{ - USBHOST_FUNC_ENTRY_TRACE(5); +static void hal_usbhost_stop_all_chans(void) { + int i; + uint32_t xfer; + HAL_USBHOST_XFER_COMPL_HANDLER handler; + uint8_t *buf; - usbc->GINTMSK &= ~USBC_HCHINT; + usbc->HAINTMSK = 0; - hal_usbhost_stop_all_chans(); + for (i = 0; i < MAX_CHAN_NUM; i++) { + hal_usbhost_halt_chan(i); + if (chan_desc[i].state != HAL_USBHOST_CHAN_XFER) { + continue; + } + + if (chan_desc[i].xfer.handler) { + // TODO: Check whether HCTSIZn is reset after channel is halted + xfer = hal_usbhost_get_xfer_size(i, 0); + + // Reset the chan_desc to INIT state so that it can be reused in callback + handler = chan_desc[i].xfer.handler; + buf = chan_desc[i].xfer.buf; + chan_desc[i].state = HAL_USBHOST_CHAN_INIT; + + handler(i, buf, xfer, HAL_USBHOST_XFER_ERR_DISCONN); + } + } + + usbc->HAINT = ~0UL; +} + +static void hal_usbhost_disconn_handler(void) { + USBHOST_FUNC_ENTRY_TRACE(5); + + usbc->GINTMSK &= ~USBC_HCHINT; + + hal_usbhost_stop_all_chans(); + + if (port_handler) { + port_handler(HAL_USBHOST_PORT_DISCONN); + } +} + +static void hal_usbhost_alloc_fifo(void) { + // FIFO configuration should be started after port enabled, or 60 ms after + // soft reset + + hal_usbhost_stop_all_chans(); + + // RX FIFO Calculation + // ------------------- + // DATA Packets + Status Info : (MPS / 4 + 1) * m + // OutEp XFER COMPL : 1 * m + // NAK/NYET Handling : 1 * outEpNum + +#define RXFIFOSIZE (2 * (MAX_USBHOST_PACKET_SIZE / 4 + 1 + 1) + USBHOST_EPNUM) +#define TXFIFOSIZE (2 * (MAX_USBHOST_PACKET_SIZE / 4)) + + // Rx Fifo Size (and init fifo_addr) + usbc->GRXFSIZ = USBC_RXFDEP(RXFIFOSIZE); + + // EP0 / Non-periodic Tx Fifo Size + usbc->GNPTXFSIZ = USBC_NPTXFSTADDR(RXFIFOSIZE) | USBC_NPTXFDEPS(TXFIFOSIZE); + + // Flush all FIFOs + usbc->GRSTCTL = USBC_TXFNUM(0x10) | USBC_TXFFLSH | USBC_RXFFLSH; + while ((usbc->GRSTCTL & (USBC_TXFFLSH | USBC_RXFFLSH)) != 0) + ; +} + +static void hal_usbhost_port_handler(void) { + uint32_t prt; + uint32_t speed; + enum HAL_USBHOST_PORT_EVENT_T event; + + prt = usbc->HPRT; + // USBC_HPRT_PRTENA also controls the port status + usbc->HPRT = prt & ~(USBC_HPRT_PRTENA | USBC_HPRT_PRTSUSP); + + USBHOST_TRACE(2, 4, "%s: 0x%08x", __FUNCTION__, prt); + + if (prt & USBC_HPRT_PRTCONNDET) { if (port_handler) { - port_handler(HAL_USBHOST_PORT_DISCONN); + port_handler(HAL_USBHOST_PORT_CONN); } -} + } -static void hal_usbhost_alloc_fifo(void) -{ - // FIFO configuration should be started after port enabled, or 60 ms after soft reset - - hal_usbhost_stop_all_chans(); - - // RX FIFO Calculation - // ------------------- - // DATA Packets + Status Info : (MPS / 4 + 1) * m - // OutEp XFER COMPL : 1 * m - // NAK/NYET Handling : 1 * outEpNum - -#define RXFIFOSIZE (2 * (MAX_USBHOST_PACKET_SIZE / 4 + 1 + 1) + USBHOST_EPNUM) -#define TXFIFOSIZE (2 * (MAX_USBHOST_PACKET_SIZE / 4)) - - // Rx Fifo Size (and init fifo_addr) - usbc->GRXFSIZ = USBC_RXFDEP(RXFIFOSIZE); - - // EP0 / Non-periodic Tx Fifo Size - usbc->GNPTXFSIZ = USBC_NPTXFSTADDR(RXFIFOSIZE) | USBC_NPTXFDEPS(TXFIFOSIZE); - - // Flush all FIFOs - usbc->GRSTCTL = USBC_TXFNUM(0x10) | USBC_TXFFLSH | USBC_RXFFLSH; - while ((usbc->GRSTCTL & (USBC_TXFFLSH | USBC_RXFFLSH)) != 0); -} - -static void hal_usbhost_port_handler(void) -{ - uint32_t prt; - uint32_t speed; - enum HAL_USBHOST_PORT_EVENT_T event; - - prt = usbc->HPRT; - // USBC_HPRT_PRTENA also controls the port status - usbc->HPRT = prt & ~(USBC_HPRT_PRTENA | USBC_HPRT_PRTSUSP); - - USBHOST_TRACE(2,4, "%s: 0x%08x", __FUNCTION__, prt); - - if (prt & USBC_HPRT_PRTCONNDET) { - if (port_handler) { - port_handler(HAL_USBHOST_PORT_CONN); - } - } - - if (prt & USBC_HPRT_PRTENCHNG) { - if (prt & USBC_HPRT_PRTENA) { - speed = GET_BITFIELD(usbc->HPRT,USBC_HPRT_PRTSPD); - if (speed == 1 || + if (prt & USBC_HPRT_PRTENCHNG) { + if (prt & USBC_HPRT_PRTENA) { + speed = GET_BITFIELD(usbc->HPRT, USBC_HPRT_PRTSPD); + if (speed == 1 || #ifdef USB_HIGH_SPEED - speed == 0 || + speed == 0 || #endif - 0) { + 0) { #ifdef USB_HIGH_SPEED - if (speed == 0) { - // High speed - usbc->HFIR = SET_BITFIELD(usbc->HFIR, USBC_HFIR_FRINT, 125 * HAL_USBC_PHY_FREQ_MHZ_HS); - event = HAL_USBHOST_PORT_EN_HS; - } else + if (speed == 0) { + // High speed + usbc->HFIR = SET_BITFIELD(usbc->HFIR, USBC_HFIR_FRINT, + 125 * HAL_USBC_PHY_FREQ_MHZ_HS); + event = HAL_USBHOST_PORT_EN_HS; + } else #else - { - // Full speed - usbc->HFIR = SET_BITFIELD(usbc->HFIR, USBC_HFIR_FRINT, 1000 * HAL_USBC_PHY_FREQ_MHZ); - event = HAL_USBHOST_PORT_EN_FS; - } -#endif - // Config FIFOs - hal_usbhost_alloc_fifo(); - // Notify upper layer - if (port_handler) { - port_handler(event); - } - } else { - // High (0) or low (2) speed not supported - if (port_handler) { - port_handler(HAL_USBHOST_PORT_EN_BAD); - } - } + { + // Full speed + usbc->HFIR = SET_BITFIELD(usbc->HFIR, USBC_HFIR_FRINT, + 1000 * HAL_USBC_PHY_FREQ_MHZ); + event = HAL_USBHOST_PORT_EN_FS; } +#endif + // Config FIFOs + hal_usbhost_alloc_fifo(); + // Notify upper layer + if (port_handler) { + port_handler(event); + } + } else { + // High (0) or low (2) speed not supported + if (port_handler) { + port_handler(HAL_USBHOST_PORT_EN_BAD); + } + } } + } } -static void hal_usbhost_retry_chan(uint8_t chan, uint32_t size) -{ - uint32_t pkt_cnt; +static void hal_usbhost_retry_chan(uint8_t chan, uint32_t size) { + uint32_t pkt_cnt; - USBHOST_TRACE(3,20, "%s: chan=%d size=%u", __FUNCTION__, chan, size); + USBHOST_TRACE(3, 20, "%s: chan=%d size=%u", __FUNCTION__, chan, size); #if 0 if (chan_desc[chan].state != HAL_USBHOST_CHAN_XFER) { @@ -782,298 +803,317 @@ static void hal_usbhost_retry_chan(uint8_t chan, uint32_t size) } #endif - hal_usbhost_halt_chan(chan); + hal_usbhost_halt_chan(chan); - pkt_cnt = (size + chan_desc[chan].type.mps - 1) / chan_desc[chan].type.mps; - if (pkt_cnt == 0) { - pkt_cnt = 1; - } + pkt_cnt = (size + chan_desc[chan].type.mps - 1) / chan_desc[chan].type.mps; + if (pkt_cnt == 0) { + pkt_cnt = 1; + } - usbc->HCSR[chan].HCTSIZn = (usbc->HCSR[chan].HCTSIZn & ~(USBC_HCTSIZN_PKTCNT_MASK | USBC_HCTSIZN_XFERSIZE_MASK)) | - USBC_HCTSIZN_PKTCNT(pkt_cnt) | USBC_HCTSIZN_XFERSIZE(size); - usbc->HCSR[chan].HCDMAn = (uint32_t)chan_desc[chan].xfer.buf + (chan_desc[chan].start_xfer_size - size); + usbc->HCSR[chan].HCTSIZn = + (usbc->HCSR[chan].HCTSIZn & + ~(USBC_HCTSIZN_PKTCNT_MASK | USBC_HCTSIZN_XFERSIZE_MASK)) | + USBC_HCTSIZN_PKTCNT(pkt_cnt) | USBC_HCTSIZN_XFERSIZE(size); + usbc->HCSR[chan].HCDMAn = (uint32_t)chan_desc[chan].xfer.buf + + (chan_desc[chan].start_xfer_size - size); - usbc->HCSR[chan].HCINTn = ~0UL; + usbc->HCSR[chan].HCINTn = ~0UL; - //usbc->HCSR[chan].HCCHARn = SET_BITFIELD(usbc->HCSR[chan].HCCHARn, USBC_HCCHARN_EC, multi_cnt); - usbc->HCSR[chan].HCCHARn &= ~USBC_HCCHARN_CHDIS; - usbc->HCSR[chan].HCCHARn |= USBC_HCCHARN_CHENA; + // usbc->HCSR[chan].HCCHARn = SET_BITFIELD(usbc->HCSR[chan].HCCHARn, + // USBC_HCCHARN_EC, multi_cnt); + usbc->HCSR[chan].HCCHARn &= ~USBC_HCCHARN_CHDIS; + usbc->HCSR[chan].HCCHARn |= USBC_HCCHARN_CHENA; } -static uint32_t hal_usbhost_get_xfer_size(uint8_t chan, int complete) -{ - uint32_t xfer; +static uint32_t hal_usbhost_get_xfer_size(uint8_t chan, int complete) { + uint32_t xfer; - if (complete) { - if (chan_desc[chan].type.ep_in) { - xfer = GET_BITFIELD(usbc->HCSR[chan].HCTSIZn, USBC_HCTSIZN_XFERSIZE); - if (chan_desc[chan].start_xfer_size > xfer) { - xfer = chan_desc[chan].start_xfer_size - xfer; - } else { - xfer = 0; - } - } else { - xfer = chan_desc[chan].start_xfer_size; - } + if (complete) { + if (chan_desc[chan].type.ep_in) { + xfer = GET_BITFIELD(usbc->HCSR[chan].HCTSIZn, USBC_HCTSIZN_XFERSIZE); + if (chan_desc[chan].start_xfer_size > xfer) { + xfer = chan_desc[chan].start_xfer_size - xfer; + } else { + xfer = 0; + } } else { - xfer = GET_BITFIELD(usbc->HCSR[chan].HCTSIZn, USBC_HCTSIZN_PKTCNT); - if (chan_desc[chan].start_pkt_cnt > xfer) { - xfer = (chan_desc[chan].start_pkt_cnt - xfer) * chan_desc[chan].type.mps; - } else { - xfer = 0; - } + xfer = chan_desc[chan].start_xfer_size; } - - return xfer; -} - -static enum HAL_USBHOST_XFER_ERR_T hal_usbhost_get_xfer_error(uint32_t irq) -{ - if (irq & USBC_HCINTN_XFERCOMPL) return HAL_USBHOST_XFER_ERR_NONE; - if (irq & USBC_HCINTN_AHBERR) return HAL_USBHOST_XFER_ERR_AHB; - if (irq & USBC_HCINTN_STALL) return HAL_USBHOST_XFER_ERR_STALL; - if (irq & USBC_HCINTN_XACTERR) return HAL_USBHOST_XFER_ERR_TRANSACTION; - if (irq & USBC_HCINTN_BBLERR) return HAL_USBHOST_XFER_ERR_BABBLE; - if (irq & USBC_HCINTN_FRMOVRUN) return HAL_USBHOST_XFER_ERR_FRAME_OVERRUN; - if (irq & USBC_HCINTN_DATATGLERR) return HAL_USBHOST_XFER_ERR_DATA_TOGGLE; - - return HAL_USBHOST_XFER_ERR_QTY; -} - -static void hal_usbhost_chan_n_handler(uint8_t chan) -{ - uint32_t raw_irq; - uint32_t irq; - uint32_t xfer; - enum HAL_USBHOST_XFER_ERR_T error; - HAL_USBHOST_XFER_COMPL_HANDLER handler; - uint8_t *buf; - - USBHOST_TRACE(2,3, "%s: %d", __FUNCTION__, chan); - - if (chan_desc[chan].state != HAL_USBHOST_CHAN_XFER) { - return; - } - - raw_irq = usbc->HCSR[chan].HCINTn; - usbc->HCSR[chan].HCINTn = raw_irq; - irq = raw_irq & usbc->HCSR[chan].HCINTMSKn; - - xfer = hal_usbhost_get_xfer_size(chan, (raw_irq & USBC_HCINTN_XFERCOMPL)); - - USBHOST_TRACE(4,18, "%s: chan=%d HCINTn=0x%08x xfer=%u", __FUNCTION__, chan, raw_irq, xfer); - - error = HAL_USBHOST_XFER_ERR_QTY; - - if (chan_desc[chan].type.ep_type == HAL_USBHOST_EP_BULK || - chan_desc[chan].type.ep_type == HAL_USBHOST_EP_CTRL) { - if (chan_desc[chan].type.ep_in) { - if (raw_irq & USBC_HCINTN_CHHLTD) { - if (raw_irq & (USBC_HCINTN_XFERCOMPL | USBC_HCINTN_STALL | USBC_HCINTN_BBLERR)) { - chan_desc[chan].err_cnt = 0; - usbc->HCSR[chan].HCINTMSKn &= ~(USBC_HCINTN_ACK | USBC_HCINTN_NAK | USBC_HCINTN_DATATGLERR); - error = hal_usbhost_get_xfer_error(raw_irq); - } else if (raw_irq & USBC_HCINTN_XACTERR) { - if (chan_desc[chan].err_cnt >= 2) { - error = HAL_USBHOST_XFER_ERR_TRANSACTION; - } else { - chan_desc[chan].err_cnt++; - usbc->HCSR[chan].HCINTMSKn |= USBC_HCINTN_ACK | USBC_HCINTN_NAK | USBC_HCINTN_DATATGLERR; - hal_usbhost_retry_chan(chan, chan_desc[chan].start_xfer_size - xfer); - return; - } - } - } else if (raw_irq & (USBC_HCINTN_ACK | USBC_HCINTN_NAK | USBC_HCINTN_DATATGLERR)) { - chan_desc[chan].err_cnt = 0; - usbc->HCSR[chan].HCINTMSKn &= ~(USBC_HCINTN_ACK | USBC_HCINTN_NAK | USBC_HCINTN_DATATGLERR); - return; - } - } else { - if (raw_irq & USBC_HCINTN_CHHLTD) { - if (raw_irq & (USBC_HCINTN_XFERCOMPL | USBC_HCINTN_STALL)) { - chan_desc[chan].err_cnt = 0; - usbc->HCSR[chan].HCINTMSKn &= ~(USBC_HCINTN_ACK | USBC_HCINTN_NAK | USBC_HCINTN_NYET); - error = hal_usbhost_get_xfer_error(raw_irq); - } else if (raw_irq & USBC_HCINTN_XACTERR) { - if (chan_desc[chan].err_cnt >= 2) { - usbc->HCSR[chan].HCINTMSKn &= ~(USBC_HCINTN_ACK | USBC_HCINTN_NAK | USBC_HCINTN_NYET); - error = HAL_USBHOST_XFER_ERR_TRANSACTION; - } else { - chan_desc[chan].err_cnt++; - usbc->HCSR[chan].HCINTMSKn |= (USBC_HCINTN_ACK | USBC_HCINTN_NAK | USBC_HCINTN_NYET); - hal_usbhost_retry_chan(chan, chan_desc[chan].start_xfer_size - xfer); - return; - } - } - } else if (raw_irq & (USBC_HCINTN_ACK | USBC_HCINTN_NAK | USBC_HCINTN_NYET)) { - chan_desc[chan].err_cnt = 0; - usbc->HCSR[chan].HCINTMSKn &= ~(USBC_HCINTN_ACK | USBC_HCINTN_NAK | USBC_HCINTN_NYET); - return; - } - } - } - - if (error == HAL_USBHOST_XFER_ERR_QTY) { - error = hal_usbhost_get_xfer_error(raw_irq); - } - - if (error == HAL_USBHOST_XFER_ERR_QTY) { - // Unknown IRQ - usbc->HCSR[chan].HCINTMSKn &= ~irq; - USBHOST_TRACE(3,19, "%s: Got unknown IRQ chan=%d irq=0x%08x", __FUNCTION__, chan, irq); + } else { + xfer = GET_BITFIELD(usbc->HCSR[chan].HCTSIZn, USBC_HCTSIZN_PKTCNT); + if (chan_desc[chan].start_pkt_cnt > xfer) { + xfer = (chan_desc[chan].start_pkt_cnt - xfer) * chan_desc[chan].type.mps; } else { - // Stop xfer timer - hwtimer_stop(usbhost_timer[chan]); - - // Reset the chan_desc to INIT state so that it can be reused in callback - handler = chan_desc[chan].xfer.handler; - buf = chan_desc[chan].xfer.buf; - chan_desc[chan].state = HAL_USBHOST_CHAN_INIT; - - if (error != HAL_USBHOST_XFER_ERR_NONE) { - usbc->HAINTMSK &= ~(1 << chan); - if ((raw_irq & USBC_HCINTN_CHHLTD) == 0) { - hal_usbhost_halt_chan(chan); - } - } - if (handler) { - handler(chan, buf, xfer, error); - } + xfer = 0; } + } + + return xfer; } -static void hal_usbhost_chan_handler(void) -{ - uint8_t i; +static enum HAL_USBHOST_XFER_ERR_T hal_usbhost_get_xfer_error(uint32_t irq) { + if (irq & USBC_HCINTN_XFERCOMPL) + return HAL_USBHOST_XFER_ERR_NONE; + if (irq & USBC_HCINTN_AHBERR) + return HAL_USBHOST_XFER_ERR_AHB; + if (irq & USBC_HCINTN_STALL) + return HAL_USBHOST_XFER_ERR_STALL; + if (irq & USBC_HCINTN_XACTERR) + return HAL_USBHOST_XFER_ERR_TRANSACTION; + if (irq & USBC_HCINTN_BBLERR) + return HAL_USBHOST_XFER_ERR_BABBLE; + if (irq & USBC_HCINTN_FRMOVRUN) + return HAL_USBHOST_XFER_ERR_FRAME_OVERRUN; + if (irq & USBC_HCINTN_DATATGLERR) + return HAL_USBHOST_XFER_ERR_DATA_TOGGLE; - USBHOST_FUNC_ENTRY_TRACE(2); - - for (i = 0; i < MAX_CHAN_NUM; i++) { - if (usbc->HAINT & (1 << i)) { - hal_usbhost_chan_n_handler(i); - } - } + return HAL_USBHOST_XFER_ERR_QTY; } -static void hal_usbhost_irq_handler(void) -{ - uint32_t status; +static void hal_usbhost_chan_n_handler(uint8_t chan) { + uint32_t raw_irq; + uint32_t irq; + uint32_t xfer; + enum HAL_USBHOST_XFER_ERR_T error; + HAL_USBHOST_XFER_COMPL_HANDLER handler; + uint8_t *buf; - // Store interrupt flag and reset it - status = usbc->GINTSTS; - usbc->GINTSTS = status; + USBHOST_TRACE(2, 3, "%s: %d", __FUNCTION__, chan); - status &= (usbc->GINTMSK & (USBC_PRTINT | USBC_HCHINT | USBC_DISCONNINT)); + if (chan_desc[chan].state != HAL_USBHOST_CHAN_XFER) { + return; + } - USBHOST_TRACE(2,1, "%s: 0x%08x", __FUNCTION__, status); + raw_irq = usbc->HCSR[chan].HCINTn; + usbc->HCSR[chan].HCINTn = raw_irq; + irq = raw_irq & usbc->HCSR[chan].HCINTMSKn; - if (status & USBC_DISCONNINT) { - hal_usbhost_disconn_handler(); + xfer = hal_usbhost_get_xfer_size(chan, (raw_irq & USBC_HCINTN_XFERCOMPL)); + + USBHOST_TRACE(4, 18, "%s: chan=%d HCINTn=0x%08x xfer=%u", __FUNCTION__, chan, + raw_irq, xfer); + + error = HAL_USBHOST_XFER_ERR_QTY; + + if (chan_desc[chan].type.ep_type == HAL_USBHOST_EP_BULK || + chan_desc[chan].type.ep_type == HAL_USBHOST_EP_CTRL) { + if (chan_desc[chan].type.ep_in) { + if (raw_irq & USBC_HCINTN_CHHLTD) { + if (raw_irq & + (USBC_HCINTN_XFERCOMPL | USBC_HCINTN_STALL | USBC_HCINTN_BBLERR)) { + chan_desc[chan].err_cnt = 0; + usbc->HCSR[chan].HCINTMSKn &= + ~(USBC_HCINTN_ACK | USBC_HCINTN_NAK | USBC_HCINTN_DATATGLERR); + error = hal_usbhost_get_xfer_error(raw_irq); + } else if (raw_irq & USBC_HCINTN_XACTERR) { + if (chan_desc[chan].err_cnt >= 2) { + error = HAL_USBHOST_XFER_ERR_TRANSACTION; + } else { + chan_desc[chan].err_cnt++; + usbc->HCSR[chan].HCINTMSKn |= + USBC_HCINTN_ACK | USBC_HCINTN_NAK | USBC_HCINTN_DATATGLERR; + hal_usbhost_retry_chan(chan, + chan_desc[chan].start_xfer_size - xfer); + return; + } + } + } else if (raw_irq & + (USBC_HCINTN_ACK | USBC_HCINTN_NAK | USBC_HCINTN_DATATGLERR)) { + chan_desc[chan].err_cnt = 0; + usbc->HCSR[chan].HCINTMSKn &= + ~(USBC_HCINTN_ACK | USBC_HCINTN_NAK | USBC_HCINTN_DATATGLERR); return; + } + } else { + if (raw_irq & USBC_HCINTN_CHHLTD) { + if (raw_irq & (USBC_HCINTN_XFERCOMPL | USBC_HCINTN_STALL)) { + chan_desc[chan].err_cnt = 0; + usbc->HCSR[chan].HCINTMSKn &= + ~(USBC_HCINTN_ACK | USBC_HCINTN_NAK | USBC_HCINTN_NYET); + error = hal_usbhost_get_xfer_error(raw_irq); + } else if (raw_irq & USBC_HCINTN_XACTERR) { + if (chan_desc[chan].err_cnt >= 2) { + usbc->HCSR[chan].HCINTMSKn &= + ~(USBC_HCINTN_ACK | USBC_HCINTN_NAK | USBC_HCINTN_NYET); + error = HAL_USBHOST_XFER_ERR_TRANSACTION; + } else { + chan_desc[chan].err_cnt++; + usbc->HCSR[chan].HCINTMSKn |= + (USBC_HCINTN_ACK | USBC_HCINTN_NAK | USBC_HCINTN_NYET); + hal_usbhost_retry_chan(chan, + chan_desc[chan].start_xfer_size - xfer); + return; + } + } + } else if (raw_irq & + (USBC_HCINTN_ACK | USBC_HCINTN_NAK | USBC_HCINTN_NYET)) { + chan_desc[chan].err_cnt = 0; + usbc->HCSR[chan].HCINTMSKn &= + ~(USBC_HCINTN_ACK | USBC_HCINTN_NAK | USBC_HCINTN_NYET); + return; + } } - if (status & USBC_PRTINT) { - hal_usbhost_port_handler(); + } + + if (error == HAL_USBHOST_XFER_ERR_QTY) { + error = hal_usbhost_get_xfer_error(raw_irq); + } + + if (error == HAL_USBHOST_XFER_ERR_QTY) { + // Unknown IRQ + usbc->HCSR[chan].HCINTMSKn &= ~irq; + USBHOST_TRACE(3, 19, "%s: Got unknown IRQ chan=%d irq=0x%08x", __FUNCTION__, + chan, irq); + } else { + // Stop xfer timer + hwtimer_stop(usbhost_timer[chan]); + + // Reset the chan_desc to INIT state so that it can be reused in callback + handler = chan_desc[chan].xfer.handler; + buf = chan_desc[chan].xfer.buf; + chan_desc[chan].state = HAL_USBHOST_CHAN_INIT; + + if (error != HAL_USBHOST_XFER_ERR_NONE) { + usbc->HAINTMSK &= ~(1 << chan); + if ((raw_irq & USBC_HCINTN_CHHLTD) == 0) { + hal_usbhost_halt_chan(chan); + } } - if (status & USBC_HCHINT) { - hal_usbhost_chan_handler(); + if (handler) { + handler(chan, buf, xfer, error); } + } } -static void hal_usbhost_timeout(void *param) -{ - uint8_t chan = (uint8_t)(uint32_t)param; - uint32_t xfer; - HAL_USBHOST_XFER_COMPL_HANDLER handler; - uint8_t *buf; +static void hal_usbhost_chan_handler(void) { + uint8_t i; - USBHOST_TRACE(2,21, "%s: %d", __FUNCTION__, chan); + USBHOST_FUNC_ENTRY_TRACE(2); - if (chan_desc[chan].state != HAL_USBHOST_CHAN_XFER) { - return; + for (i = 0; i < MAX_CHAN_NUM; i++) { + if (usbc->HAINT & (1 << i)) { + hal_usbhost_chan_n_handler(i); } + } +} - hal_usbhost_halt_chan(chan); +static void hal_usbhost_irq_handler(void) { + uint32_t status; - if (chan_desc[chan].xfer.handler) { - // TODO: Check whether HCTSIZn is reset after channel is halted - xfer = hal_usbhost_get_xfer_size(chan, 0); + // Store interrupt flag and reset it + status = usbc->GINTSTS; + usbc->GINTSTS = status; - // Reset the chan_desc to INIT state so that it can be reused in callback - handler = chan_desc[chan].xfer.handler; - buf = chan_desc[chan].xfer.buf; - chan_desc[chan].state = HAL_USBHOST_CHAN_INIT; + status &= (usbc->GINTMSK & (USBC_PRTINT | USBC_HCHINT | USBC_DISCONNINT)); - handler(chan, buf, xfer, HAL_USBHOST_XFER_ERR_TIMEOUT); - } + USBHOST_TRACE(2, 1, "%s: 0x%08x", __FUNCTION__, status); + + if (status & USBC_DISCONNINT) { + hal_usbhost_disconn_handler(); + return; + } + if (status & USBC_PRTINT) { + hal_usbhost_port_handler(); + } + if (status & USBC_HCHINT) { + hal_usbhost_chan_handler(); + } +} + +static void hal_usbhost_timeout(void *param) { + uint8_t chan = (uint8_t)(uint32_t)param; + uint32_t xfer; + HAL_USBHOST_XFER_COMPL_HANDLER handler; + uint8_t *buf; + + USBHOST_TRACE(2, 21, "%s: %d", __FUNCTION__, chan); + + if (chan_desc[chan].state != HAL_USBHOST_CHAN_XFER) { + return; + } + + hal_usbhost_halt_chan(chan); + + if (chan_desc[chan].xfer.handler) { + // TODO: Check whether HCTSIZn is reset after channel is halted + xfer = hal_usbhost_get_xfer_size(chan, 0); + + // Reset the chan_desc to INIT state so that it can be reused in callback + handler = chan_desc[chan].xfer.handler; + buf = chan_desc[chan].xfer.buf; + chan_desc[chan].state = HAL_USBHOST_CHAN_INIT; + + handler(chan, buf, xfer, HAL_USBHOST_XFER_ERR_TIMEOUT); + } } #ifdef PMU_USB_PIN_CHECK -static void hal_usbhost_pin_status_change(enum PMU_USB_PIN_CHK_STATUS_T status) -{ - USBHOST_TRACE(2,24, "%s: %d", __FUNCTION__, status); +static void +hal_usbhost_pin_status_change(enum PMU_USB_PIN_CHK_STATUS_T status) { + USBHOST_TRACE(2, 24, "%s: %d", __FUNCTION__, status); - if (plug_handler) { - if (status == PMU_USB_PIN_CHK_DEV_CONN) { - plug_handler(HAL_USBHOST_PLUG_IN); - } else if (status == PMU_USB_PIN_CHK_DEV_DISCONN) { - plug_handler(HAL_USBHOST_PLUG_OUT); - } + if (plug_handler) { + if (status == PMU_USB_PIN_CHK_DEV_CONN) { + plug_handler(HAL_USBHOST_PLUG_IN); + } else if (status == PMU_USB_PIN_CHK_DEV_DISCONN) { + plug_handler(HAL_USBHOST_PLUG_OUT); } + } } #endif -void hal_usbhost_detect(enum HAL_USBHOST_PLUG_STATUS_T status, HAL_USBHOST_PLUG_HANDLER handler) -{ +void hal_usbhost_detect(enum HAL_USBHOST_PLUG_STATUS_T status, + HAL_USBHOST_PLUG_HANDLER handler) { #ifdef PMU_USB_PIN_CHECK - enum PMU_USB_PIN_CHK_STATUS_T pmu_status; + enum PMU_USB_PIN_CHK_STATUS_T pmu_status; - USBHOST_FUNC_ENTRY_TRACE(23); + USBHOST_FUNC_ENTRY_TRACE(23); - if (status == HAL_USBHOST_PLUG_IN) { - pmu_status = PMU_USB_PIN_CHK_DEV_CONN; - } else if (status == HAL_USBHOST_PLUG_OUT) { - pmu_status = PMU_USB_PIN_CHK_DEV_DISCONN; - } else { - pmu_status = PMU_USB_PIN_CHK_NONE; - } + if (status == HAL_USBHOST_PLUG_IN) { + pmu_status = PMU_USB_PIN_CHK_DEV_CONN; + } else if (status == HAL_USBHOST_PLUG_OUT) { + pmu_status = PMU_USB_PIN_CHK_DEV_DISCONN; + } else { + pmu_status = PMU_USB_PIN_CHK_NONE; + } - plug_handler = handler; - if (handler && pmu_status != PMU_USB_PIN_CHK_NONE) { - pmu_usb_config_pin_status_check(pmu_status, hal_usbhost_pin_status_change, true); - } else { - pmu_usb_disable_pin_status_check(); - } + plug_handler = handler; + if (handler && pmu_status != PMU_USB_PIN_CHK_NONE) { + pmu_usb_config_pin_status_check(pmu_status, hal_usbhost_pin_status_change, + true); + } else { + pmu_usb_disable_pin_status_check(); + } #else - ASSERT(false, "No aux usb pin status check support"); + ASSERT(false, "No aux usb pin status check support"); #endif } -void hal_usbhost_sleep(void) -{ - USBHOST_FUNC_ENTRY_TRACE(22); +void hal_usbhost_sleep(void) { + USBHOST_FUNC_ENTRY_TRACE(22); - if (usbhost_opened) { - hal_usbhost_port_suspend(); + if (usbhost_opened) { + hal_usbhost_port_suspend(); #ifdef PMU_USB_PIN_CHECK - hal_cmu_clock_disable(HAL_CMU_MOD_H_USBC); - hal_cmu_clock_disable(HAL_CMU_MOD_O_USB); - pmu_usb_config_pin_status_check(PMU_USB_PIN_CHK_DEV_DISCONN, hal_usbhost_pin_status_change, true); + hal_cmu_clock_disable(HAL_CMU_MOD_H_USBC); + hal_cmu_clock_disable(HAL_CMU_MOD_O_USB); + pmu_usb_config_pin_status_check(PMU_USB_PIN_CHK_DEV_DISCONN, + hal_usbhost_pin_status_change, true); #endif - } + } } -void hal_usbhost_wakeup(void) -{ - USBHOST_FUNC_ENTRY_TRACE(22); +void hal_usbhost_wakeup(void) { + USBHOST_FUNC_ENTRY_TRACE(22); - if (usbhost_opened) { + if (usbhost_opened) { #ifdef PMU_USB_PIN_CHECK - pmu_usb_disable_pin_status_check(); - hal_cmu_clock_enable(HAL_CMU_MOD_H_USBC); - hal_cmu_clock_enable(HAL_CMU_MOD_O_USB); + pmu_usb_disable_pin_status_check(); + hal_cmu_clock_enable(HAL_CMU_MOD_H_USBC); + hal_cmu_clock_enable(HAL_CMU_MOD_O_USB); #endif - hal_usbhost_port_resume(); - } + hal_usbhost_port_resume(); + } } #endif // CHIP_HAS_USB diff --git a/platform/hal/hal_wdt.c b/platform/hal/hal_wdt.c index a740b9c..5b7fe28 100644 --- a/platform/hal/hal_wdt.c +++ b/platform/hal/hal_wdt.c @@ -13,230 +13,220 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" -#include "plat_addr_map.h" +#include "hal_wdt.h" #include "cmsis.h" #include "cmsis_nvic.h" #include "hal_timer.h" #include "hal_trace.h" #include "hal_uart.h" -#include "hal_wdt.h" +#include "plat_addr_map.h" +#include "plat_types.h" -#if defined(CHIP_BEST3001) || defined(CHIP_BEST3003) || defined(CHIP_BEST3005) || defined(CHIP_BEST1400) || defined(CHIP_BEST1402) +#if defined(CHIP_BEST3001) || defined(CHIP_BEST3003) || \ + defined(CHIP_BEST3005) || defined(CHIP_BEST1400) || defined(CHIP_BEST1402) #define CLOCK_SYNC_WORKAROUND #endif -#define SLOW_TIMER_VAL_DELTA 1 -#define FAST_TIMER_VAL_DELTA 20 +#define SLOW_TIMER_VAL_DELTA 1 +#define FAST_TIMER_VAL_DELTA 20 /* wdt controller */ /* reg address */ /* default timeout in seconds */ -#define DEFAULT_TIMEOUT 60 +#define DEFAULT_TIMEOUT 60 -#define WDT_RATE CONFIG_SYSTICK_HZ +#define WDT_RATE CONFIG_SYSTICK_HZ /* watchdog register offsets and masks */ -#define WDTLOAD_REG_OFFSET 0x000 -#define WDTLOAD_LOAD_MIN 0x00000001 -#define WDTLOAD_LOAD_MAX 0xFFFFFFFF +#define WDTLOAD_REG_OFFSET 0x000 +#define WDTLOAD_LOAD_MIN 0x00000001 +#define WDTLOAD_LOAD_MAX 0xFFFFFFFF -#define WDTVALUE_REG_OFFSET 0x004 +#define WDTVALUE_REG_OFFSET 0x004 -#define WDTCONTROL_REG_OFFSET 0x008 -#define WDTCONTROL_REG_INT_ENABLE (1 << 0) -#define WDTCONTROL_REG_RESET_ENABLE (1 << 1) +#define WDTCONTROL_REG_OFFSET 0x008 +#define WDTCONTROL_REG_INT_ENABLE (1 << 0) +#define WDTCONTROL_REG_RESET_ENABLE (1 << 1) -#define WDTINTCLR_REG_OFFSET 0x00C +#define WDTINTCLR_REG_OFFSET 0x00C -#define WDTRIS_REG_OFFSET 0x010 -#define WDTRIS_REG_INT_MASK (1 << 0) +#define WDTRIS_REG_OFFSET 0x010 +#define WDTRIS_REG_INT_MASK (1 << 0) -#define WDTMIS_REG_OFFSET 0x014 -#define WDTMIS_REG_INT_MASK (1 << 0) +#define WDTMIS_REG_OFFSET 0x014 +#define WDTMIS_REG_INT_MASK (1 << 0) -#define WDTLOCK_REG_OFFSET 0xC00 -#define WDTLOCK_REG_UNLOCK 0x1ACCE551 -#define WDTLOCK_REG_LOCK 0x00000001 +#define WDTLOCK_REG_OFFSET 0xC00 +#define WDTLOCK_REG_UNLOCK 0x1ACCE551 +#define WDTLOCK_REG_LOCK 0x00000001 /* read write */ -#define wdtip_write32(v,b,a) \ - (*((volatile unsigned int *)(b+a)) = v) -#define wdtip_read32(b,a) \ - (*((volatile unsigned int *)(b+a))) +#define wdtip_write32(v, b, a) (*((volatile unsigned int *)(b + a)) = v) +#define wdtip_read32(b, a) (*((volatile unsigned int *)(b + a))) #if 1 typedef void (*HAL_WDT_IRQ_HANDLER)(void); struct HAL_WDT_CTX { - unsigned int load_val; + unsigned int load_val; }; struct HAL_WDT_CTX hal_wdt_ctx[HAL_WDT_ID_NUM]; static void _wdt1_irq_handler(void); -HAL_WDT_IRQ_HANDLER hal_wdt_irq_handler[HAL_WDT_ID_NUM] = -{ +HAL_WDT_IRQ_HANDLER hal_wdt_irq_handler[HAL_WDT_ID_NUM] = { _wdt1_irq_handler, }; HAL_WDT_IRQ_CALLBACK hal_wdt_irq_callback[HAL_WDT_ID_NUM]; -static void _wdt1_irq_handler(void) -{ - if (hal_wdt_irq_callback[HAL_WDT_ID_0] != 0) { - hal_wdt_irq_callback[HAL_WDT_ID_0](HAL_WDT_ID_0, HAL_WDT_EVENT_FIRE); - } +static void _wdt1_irq_handler(void) { + if (hal_wdt_irq_callback[HAL_WDT_ID_0] != 0) { + hal_wdt_irq_callback[HAL_WDT_ID_0](HAL_WDT_ID_0, HAL_WDT_EVENT_FIRE); + } } -static unsigned int _wdt_get_base(enum HAL_WDT_ID_T id) -{ - switch(id) { - default: - case HAL_WDT_ID_0: - return WDT_BASE; - break; - } +static unsigned int _wdt_get_base(enum HAL_WDT_ID_T id) { + switch (id) { + default: + case HAL_WDT_ID_0: + return WDT_BASE; + break; + } - return 0; + return 0; } -static void _wdt_load(enum HAL_WDT_ID_T id) -{ - unsigned int reg_base = 0; - struct HAL_WDT_CTX *wdt = &hal_wdt_ctx[id]; - uint32_t lock; +static void _wdt_load(enum HAL_WDT_ID_T id) { + unsigned int reg_base = 0; + struct HAL_WDT_CTX *wdt = &hal_wdt_ctx[id]; + uint32_t lock; - reg_base = _wdt_get_base(id); + reg_base = _wdt_get_base(id); - lock = int_lock(); + lock = int_lock(); - wdtip_write32(WDTLOCK_REG_UNLOCK, reg_base, WDTLOCK_REG_OFFSET); + wdtip_write32(WDTLOCK_REG_UNLOCK, reg_base, WDTLOCK_REG_OFFSET); #ifdef CLOCK_SYNC_WORKAROUND - uint32_t val; + uint32_t val; - do { - wdtip_write32(wdt->load_val, reg_base, WDTLOAD_REG_OFFSET); - val = wdtip_read32(reg_base, WDTVALUE_REG_OFFSET); - } while ((wdt->load_val < val) || (wdt->load_val > val + SLOW_TIMER_VAL_DELTA)); -#else + do { wdtip_write32(wdt->load_val, reg_base, WDTLOAD_REG_OFFSET); + val = wdtip_read32(reg_base, WDTVALUE_REG_OFFSET); + } while ((wdt->load_val < val) || + (wdt->load_val > val + SLOW_TIMER_VAL_DELTA)); +#else + wdtip_write32(wdt->load_val, reg_base, WDTLOAD_REG_OFFSET); #endif - wdtip_write32(WDTLOCK_REG_LOCK, reg_base, WDTLOCK_REG_OFFSET); + wdtip_write32(WDTLOCK_REG_LOCK, reg_base, WDTLOCK_REG_OFFSET); - int_unlock(lock); + int_unlock(lock); - /* Flush posted writes. */ - wdtip_read32(reg_base, WDTLOCK_REG_OFFSET); + /* Flush posted writes. */ + wdtip_read32(reg_base, WDTLOCK_REG_OFFSET); } -static void _wdt_config(enum HAL_WDT_ID_T id) -{ - unsigned int reg_base = 0; - uint32_t lock; +static void _wdt_config(enum HAL_WDT_ID_T id) { + unsigned int reg_base = 0; + uint32_t lock; - reg_base = _wdt_get_base(id); + reg_base = _wdt_get_base(id); - lock = int_lock(); - wdtip_write32(WDTLOCK_REG_UNLOCK, reg_base, WDTLOCK_REG_OFFSET); - wdtip_write32(WDTRIS_REG_INT_MASK, reg_base, WDTINTCLR_REG_OFFSET); - wdtip_write32(WDTCONTROL_REG_INT_ENABLE | WDTCONTROL_REG_RESET_ENABLE, reg_base, WDTCONTROL_REG_OFFSET); - wdtip_write32(WDTLOCK_REG_LOCK, reg_base, WDTLOCK_REG_OFFSET); - int_unlock(lock); + lock = int_lock(); + wdtip_write32(WDTLOCK_REG_UNLOCK, reg_base, WDTLOCK_REG_OFFSET); + wdtip_write32(WDTRIS_REG_INT_MASK, reg_base, WDTINTCLR_REG_OFFSET); + wdtip_write32(WDTCONTROL_REG_INT_ENABLE | WDTCONTROL_REG_RESET_ENABLE, + reg_base, WDTCONTROL_REG_OFFSET); + wdtip_write32(WDTLOCK_REG_LOCK, reg_base, WDTLOCK_REG_OFFSET); + int_unlock(lock); - /* Flush posted writes. */ - wdtip_read32(reg_base, WDTLOCK_REG_OFFSET); + /* Flush posted writes. */ + wdtip_read32(reg_base, WDTLOCK_REG_OFFSET); } static int wdt_start; /* mandatory operations */ -int hal_wdt_start(enum HAL_WDT_ID_T id) -{ - _wdt_load(id); - _wdt_config(id); - wdt_start = 1; - return 0; +int hal_wdt_start(enum HAL_WDT_ID_T id) { + _wdt_load(id); + _wdt_config(id); + wdt_start = 1; + return 0; } -int hal_wdt_stop(enum HAL_WDT_ID_T id) -{ - unsigned int reg_base = 0; - uint32_t lock; +int hal_wdt_stop(enum HAL_WDT_ID_T id) { + unsigned int reg_base = 0; + uint32_t lock; - reg_base = _wdt_get_base(id); + reg_base = _wdt_get_base(id); - lock = int_lock(); - wdtip_write32(WDTLOCK_REG_UNLOCK, reg_base, WDTLOCK_REG_OFFSET); - wdtip_write32(0, reg_base, WDTCONTROL_REG_OFFSET); - wdtip_write32(WDTLOCK_REG_LOCK, reg_base, WDTLOCK_REG_OFFSET); - int_unlock(lock); + lock = int_lock(); + wdtip_write32(WDTLOCK_REG_UNLOCK, reg_base, WDTLOCK_REG_OFFSET); + wdtip_write32(0, reg_base, WDTCONTROL_REG_OFFSET); + wdtip_write32(WDTLOCK_REG_LOCK, reg_base, WDTLOCK_REG_OFFSET); + int_unlock(lock); - /* Flush posted writes. */ - wdtip_read32(reg_base, WDTLOCK_REG_OFFSET); + /* Flush posted writes. */ + wdtip_read32(reg_base, WDTLOCK_REG_OFFSET); - wdt_start = 0; - return 0; + wdt_start = 0; + return 0; } /* optional operations */ -int hal_wdt_ping(enum HAL_WDT_ID_T id) -{ - if (wdt_start) { - _wdt_load(id); - } +int hal_wdt_ping(enum HAL_WDT_ID_T id) { + if (wdt_start) { + _wdt_load(id); + } - return 0; + return 0; } -int hal_wdt_set_timeout(enum HAL_WDT_ID_T id, unsigned int timeout) -{ - uint64_t load; - struct HAL_WDT_CTX *wdt = &hal_wdt_ctx[id]; +int hal_wdt_set_timeout(enum HAL_WDT_ID_T id, unsigned int timeout) { + uint64_t load; + struct HAL_WDT_CTX *wdt = &hal_wdt_ctx[id]; - /* - * sp805 runs counter with given value twice, after the end of first - * counter it gives an interrupt and then starts counter again. If - * interrupt already occurred then it resets the system. This is why - * load is half of what should be required. - */ - load = WDT_RATE * timeout - 1; + /* + * sp805 runs counter with given value twice, after the end of first + * counter it gives an interrupt and then starts counter again. If + * interrupt already occurred then it resets the system. This is why + * load is half of what should be required. + */ + load = WDT_RATE * timeout - 1; - load = (load > WDTLOAD_LOAD_MAX) ? WDTLOAD_LOAD_MAX: load; - load = (load < WDTLOAD_LOAD_MIN) ? WDTLOAD_LOAD_MIN: load; + load = (load > WDTLOAD_LOAD_MAX) ? WDTLOAD_LOAD_MAX : load; + load = (load < WDTLOAD_LOAD_MIN) ? WDTLOAD_LOAD_MIN : load; - wdt->load_val = load; + wdt->load_val = load; - return 0; + return 0; } -unsigned int hal_wdt_get_timeleft(enum HAL_WDT_ID_T id) -{ - uint64_t load; - unsigned int reg_base = 0; - struct HAL_WDT_CTX *wdt = &hal_wdt_ctx[id]; +unsigned int hal_wdt_get_timeleft(enum HAL_WDT_ID_T id) { + uint64_t load; + unsigned int reg_base = 0; + struct HAL_WDT_CTX *wdt = &hal_wdt_ctx[id]; - reg_base = _wdt_get_base(id); + reg_base = _wdt_get_base(id); - load = wdtip_read32(reg_base, WDTVALUE_REG_OFFSET); + load = wdtip_read32(reg_base, WDTVALUE_REG_OFFSET); - /*If the interrupt is inactive then time left is WDTValue + WDTLoad. */ - if (!(wdtip_read32(reg_base, WDTRIS_REG_OFFSET) & WDTRIS_REG_INT_MASK)) - load += wdt->load_val + 1; + /*If the interrupt is inactive then time left is WDTValue + WDTLoad. */ + if (!(wdtip_read32(reg_base, WDTRIS_REG_OFFSET) & WDTRIS_REG_INT_MASK)) + load += wdt->load_val + 1; - return load/WDT_RATE; + return load / WDT_RATE; } -void hal_wdt_set_irq_callback(enum HAL_WDT_ID_T id, HAL_WDT_IRQ_CALLBACK cb) -{ - switch(id) { - default: - case HAL_WDT_ID_0: - NVIC_SetVector(WDT_IRQn, (uint32_t)hal_wdt_irq_handler[id]); - NVIC_SetPriority(WDT_IRQn, IRQ_PRIORITY_NORMAL); - NVIC_ClearPendingIRQ(WDT_IRQn); - NVIC_EnableIRQ(WDT_IRQn); - break; - } +void hal_wdt_set_irq_callback(enum HAL_WDT_ID_T id, HAL_WDT_IRQ_CALLBACK cb) { + switch (id) { + default: + case HAL_WDT_ID_0: + NVIC_SetVector(WDT_IRQn, (uint32_t)hal_wdt_irq_handler[id]); + NVIC_SetPriority(WDT_IRQn, IRQ_PRIORITY_NORMAL); + NVIC_ClearPendingIRQ(WDT_IRQn); + NVIC_EnableIRQ(WDT_IRQn); + break; + } - hal_wdt_irq_callback[id] = cb; + hal_wdt_irq_callback[id] = cb; } #endif diff --git a/platform/main/main.cpp b/platform/main/main.cpp index e2d3561..7020385 100644 --- a/platform/main/main.cpp +++ b/platform/main/main.cpp @@ -13,10 +13,10 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_addr_map.h" #include "analog.h" -#include "apps.h" #include "app_bt_stream.h" +#include "app_utils.h" +#include "apps.h" #include "cmsis.h" #include "hal_bootmode.h" #include "hal_cmu.h" @@ -32,14 +32,14 @@ #include "hwtimer_list.h" #include "mpu.h" #include "norflash_api.h" +#include "plat_addr_map.h" #include "pmu.h" #include "stdlib.h" #include "tgt_hardware.h" -#include "app_utils.h" #ifdef RTOS -#include "cmsis_os.h" #include "app_factory.h" +#include "cmsis_os.h" #endif #ifdef CORE_DUMP_TO_FLASH #include "coredump_section.h" @@ -49,25 +49,24 @@ extern "C" void log_dump_init(void); extern "C" void crash_dump_init(void); #ifdef FIRMWARE_REV -#define SYS_STORE_FW_VER(x) \ - if(fw_rev_##x) { \ - *fw_rev_##x = fw.softwareRevByte##x; \ - } +#define SYS_STORE_FW_VER(x) \ + if (fw_rev_##x) { \ + *fw_rev_##x = fw.softwareRevByte##x; \ + } -typedef struct -{ - uint8_t softwareRevByte0; - uint8_t softwareRevByte1; - uint8_t softwareRevByte2; - uint8_t softwareRevByte3; +typedef struct { + uint8_t softwareRevByte0; + uint8_t softwareRevByte1; + uint8_t softwareRevByte2; + uint8_t softwareRevByte3; } FIRMWARE_REV_INFO_T; -static FIRMWARE_REV_INFO_T fwRevInfoInFlash __attribute((section(".fw_rev"))) = {0, 0, 1, 0}; +static FIRMWARE_REV_INFO_T fwRevInfoInFlash + __attribute((section(".fw_rev"))) = {0, 0, 1, 0}; FIRMWARE_REV_INFO_T fwRevInfoInRam; extern "C" void system_get_info(uint8_t *fw_rev_0, uint8_t *fw_rev_1, - uint8_t *fw_rev_2, uint8_t *fw_rev_3) -{ + uint8_t *fw_rev_2, uint8_t *fw_rev_3) { FIRMWARE_REV_INFO_T fw = fwRevInfoInFlash; SYS_STORE_FW_VER(0); @@ -78,69 +77,75 @@ extern "C" void system_get_info(uint8_t *fw_rev_0, uint8_t *fw_rev_1, #endif #if defined(_AUTO_TEST_) -static uint8_t fwversion[4] = {0,0,1,0}; +static uint8_t fwversion[4] = {0, 0, 1, 0}; void system_get_fwversion(uint8_t *fw_rev_0, uint8_t *fw_rev_1, - uint8_t *fw_rev_2, uint8_t *fw_rev_3) -{ - *fw_rev_0 = fwversion[0]; - *fw_rev_1 = fwversion[1]; - *fw_rev_2 = fwversion[2]; - *fw_rev_3 = fwversion[3]; + uint8_t *fw_rev_2, uint8_t *fw_rev_3) { + *fw_rev_0 = fwversion[0]; + *fw_rev_1 = fwversion[1]; + *fw_rev_2 = fwversion[2]; + *fw_rev_3 = fwversion[3]; } #endif - -#define system_shutdown_wdt_config(seconds) \ - do{ \ - hal_wdt_stop(HAL_WDT_ID_0); \ - hal_wdt_set_irq_callback(HAL_WDT_ID_0, NULL); \ - hal_wdt_set_timeout(HAL_WDT_ID_0, seconds); \ - hal_wdt_start(HAL_WDT_ID_0); \ - hal_sleep_set_deep_sleep_hook(HAL_DEEP_SLEEP_HOOK_USER_WDT, NULL); \ - }while(0) +#define system_shutdown_wdt_config(seconds) \ + do { \ + hal_wdt_stop(HAL_WDT_ID_0); \ + hal_wdt_set_irq_callback(HAL_WDT_ID_0, NULL); \ + hal_wdt_set_timeout(HAL_WDT_ID_0, seconds); \ + hal_wdt_start(HAL_WDT_ID_0); \ + hal_sleep_set_deep_sleep_hook(HAL_DEEP_SLEEP_HOOK_USER_WDT, NULL); \ + } while (0) static osThreadId main_thread_tid = NULL; -extern "C" int system_shutdown(void) -{ - TRACE(0,"system_shutdown!!"); - osThreadSetPriority(main_thread_tid, osPriorityRealtime); - osSignalSet(main_thread_tid, 0x4); - return 0; +extern "C" int system_shutdown(void) { + TRACE(0, "system_shutdown!!"); + osThreadSetPriority(main_thread_tid, osPriorityRealtime); + osSignalSet(main_thread_tid, 0x4); + return 0; } -int system_reset(void) -{ - osThreadSetPriority(main_thread_tid, osPriorityRealtime); - osSignalSet(main_thread_tid, 0x8); - return 0; +int system_reset(void) { + osThreadSetPriority(main_thread_tid, osPriorityRealtime); + osSignalSet(main_thread_tid, 0x8); + return 0; } -int signal_send_to_main_thread(uint32_t signals) -{ - osSignalSet(main_thread_tid, signals); - return 0; +int signal_send_to_main_thread(uint32_t signals) { + osSignalSet(main_thread_tid, signals); + return 0; } -int tgt_hardware_setup(void) -{ +int tgt_hardware_setup(void) { #ifdef __APP_USE_LED_INDICATE_IBRT_STATUS__ - for (uint8_t i=0;i<3;i++){ - hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)&cfg_ibrt_indication_pinmux_pwl[i], 1); - if(i==0) - hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)cfg_ibrt_indication_pinmux_pwl[i].pin, HAL_GPIO_DIR_OUT, 0); - else - hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)cfg_ibrt_indication_pinmux_pwl[i].pin, HAL_GPIO_DIR_OUT, 1); - } + for (uint8_t i = 0; i < 3; i++) { + hal_iomux_init( + (struct HAL_IOMUX_PIN_FUNCTION_MAP *)&cfg_ibrt_indication_pinmux_pwl[i], + 1); + if (i == 0) + hal_gpio_pin_set_dir( + (enum HAL_GPIO_PIN_T)cfg_ibrt_indication_pinmux_pwl[i].pin, + HAL_GPIO_DIR_OUT, 0); + else + hal_gpio_pin_set_dir( + (enum HAL_GPIO_PIN_T)cfg_ibrt_indication_pinmux_pwl[i].pin, + HAL_GPIO_DIR_OUT, 1); + } #endif - hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)cfg_hw_pinmux_pwl, sizeof(cfg_hw_pinmux_pwl)/sizeof(struct HAL_IOMUX_PIN_FUNCTION_MAP)); - if (app_battery_ext_charger_indicator_cfg.pin != HAL_IOMUX_PIN_NUM){ - hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)&app_battery_ext_charger_indicator_cfg, 1); - hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)app_battery_ext_charger_indicator_cfg.pin, HAL_GPIO_DIR_IN, 1); - } - return 0; + hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)cfg_hw_pinmux_pwl, + sizeof(cfg_hw_pinmux_pwl) / + sizeof(struct HAL_IOMUX_PIN_FUNCTION_MAP)); + if (app_battery_ext_charger_indicator_cfg.pin != HAL_IOMUX_PIN_NUM) { + hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP + *)&app_battery_ext_charger_indicator_cfg, + 1); + hal_gpio_pin_set_dir( + (enum HAL_GPIO_PIN_T)app_battery_ext_charger_indicator_cfg.pin, + HAL_GPIO_DIR_IN, 1); + } + return 0; } #if defined(ROM_UTILS_ON) @@ -152,7 +157,8 @@ uint32_t a2dp_audio_more_data(uint8_t *buf, uint32_t len); uint32_t a2dp_audio_init(void); extern "C" void app_audio_manager_open(void); extern "C" void app_bt_init(void); -extern "C" uint32_t hal_iomux_init(const struct HAL_IOMUX_PIN_FUNCTION_MAP *map, uint32_t count); +extern "C" uint32_t hal_iomux_init(const struct HAL_IOMUX_PIN_FUNCTION_MAP *map, + uint32_t count); void app_overlay_open(void); extern "C" void BesbtInit(void); @@ -161,7 +167,6 @@ extern "C" uint32_t af_open(void); extern "C" int list_init(void); extern "C" void app_audio_open(void); - volatile uint32_t ddddd = 0; #if defined(AAC_TEST) @@ -178,237 +183,235 @@ extern int32_t at_Init(void); #endif #ifdef DEBUG_MODE_USB_DOWNLOAD -static void process_usb_download_mode(void) -{ - if (pmu_charger_get_status() == PMU_CHARGER_PLUGIN && hal_pwrkey_pressed()) { - hal_sw_bootmode_set(HAL_SW_BOOTMODE_FORCE_USB_DLD); - hal_cmu_sys_reboot(); - } +static void process_usb_download_mode(void) { + if (pmu_charger_get_status() == PMU_CHARGER_PLUGIN && hal_pwrkey_pressed()) { + hal_sw_bootmode_set(HAL_SW_BOOTMODE_FORCE_USB_DLD); + hal_cmu_sys_reboot(); + } } #endif -int main(void) -{ - uint8_t sys_case = 0; - int ret = 0; +int main(void) { + uint8_t sys_case = 0; + int ret = 0; #ifdef __WATCHER_DOG_RESET__ #if !defined(BLE_ONLY_ENABLED) - app_wdt_open(15); + app_wdt_open(15); #else - app_wdt_open(30); + app_wdt_open(30); #endif #endif #ifdef __FACTORY_MODE_SUPPORT__ - uint32_t bootmode = hal_sw_bootmode_get(); + uint32_t bootmode = hal_sw_bootmode_get(); #endif #ifdef DEBUG_MODE_USB_DOWNLOAD - process_usb_download_mode(); + process_usb_download_mode(); #endif - tgt_hardware_setup(); + tgt_hardware_setup(); #if defined(ROM_UTILS_ON) - rom_utils_init(); + rom_utils_init(); #endif - main_thread_tid = osThreadGetId(); + main_thread_tid = osThreadGetId(); - hwtimer_init(); + hwtimer_init(); - hal_dma_set_delay_func((HAL_DMA_DELAY_FUNC)osDelay); - hal_audma_open(); - hal_gpdma_open(); - norflash_api_init(); + hal_dma_set_delay_func((HAL_DMA_DELAY_FUNC)osDelay); + hal_audma_open(); + hal_gpdma_open(); + norflash_api_init(); #if defined(DUMP_LOG_ENABLE) - log_dump_init(); + log_dump_init(); #endif #if defined(DUMP_CRASH_ENABLE) - crash_dump_init(); + crash_dump_init(); #endif #ifdef CORE_DUMP_TO_FLASH - coredump_to_flash_init(); + coredump_to_flash_init(); #endif #ifdef DEBUG #if (DEBUG_PORT == 1) - hal_iomux_set_uart0(); + hal_iomux_set_uart0(); #ifdef __FACTORY_MODE_SUPPORT__ - if (!(bootmode & HAL_SW_BOOTMODE_FACTORY)) + if (!(bootmode & HAL_SW_BOOTMODE_FACTORY)) #endif - { - hal_trace_open(HAL_TRACE_TRANSPORT_UART0); - } + { + hal_trace_open(HAL_TRACE_TRANSPORT_UART0); + } #endif #if (DEBUG_PORT == 2) #ifdef __FACTORY_MODE_SUPPORT__ - if (!(bootmode & HAL_SW_BOOTMODE_FACTORY)) + if (!(bootmode & HAL_SW_BOOTMODE_FACTORY)) #endif - { - hal_iomux_set_analog_i2c(); - } - hal_iomux_set_uart1(); - hal_trace_open(HAL_TRACE_TRANSPORT_UART1); + { + hal_iomux_set_analog_i2c(); + } + hal_iomux_set_uart1(); + hal_trace_open(HAL_TRACE_TRANSPORT_UART1); #endif - hal_sleep_start_stats(10000, 10000); - hal_trace_set_log_level(LOG_LEVEL_DEBUG); + hal_sleep_start_stats(10000, 10000); + hal_trace_set_log_level(LOG_LEVEL_DEBUG); #endif - hal_iomux_ispi_access_init(); + hal_iomux_ispi_access_init(); #ifndef FPGA - uint8_t flash_id[HAL_NORFLASH_DEVICE_ID_LEN]; - hal_norflash_get_id(HAL_NORFLASH_ID_0, flash_id, ARRAY_SIZE(flash_id)); - TRACE(3,"FLASH_ID: %02X-%02X-%02X", flash_id[0], flash_id[1], flash_id[2]); - ASSERT(hal_norflash_opened(HAL_NORFLASH_ID_0), "Failed to init flash: %d", hal_norflash_get_open_state(HAL_NORFLASH_ID_0)); + uint8_t flash_id[HAL_NORFLASH_DEVICE_ID_LEN]; + hal_norflash_get_id(HAL_NORFLASH_ID_0, flash_id, ARRAY_SIZE(flash_id)); + TRACE(3, "FLASH_ID: %02X-%02X-%02X", flash_id[0], flash_id[1], flash_id[2]); + ASSERT(hal_norflash_opened(HAL_NORFLASH_ID_0), "Failed to init flash: %d", + hal_norflash_get_open_state(HAL_NORFLASH_ID_0)); - // Software will load the factory data and user data from the bottom TWO sectors from the flash, - // the FLASH_SIZE defined is the common.mk must be equal or greater than the actual chip flash size, - // otherwise the ota will load the wrong information - uint32_t actualFlashSize = hal_norflash_get_flash_total_size(HAL_NORFLASH_ID_0); - if (FLASH_SIZE > actualFlashSize) - { - TRACE_IMM(0,"Wrong FLASH_SIZE defined in target.mk!"); - TRACE_IMM(2,"FLASH_SIZE is defined as 0x%x while the actual chip flash size is 0x%x!", FLASH_SIZE, actualFlashSize); - TRACE_IMM(1,"Please change the FLASH_SIZE in common.mk to 0x%x to enable the OTA feature.", actualFlashSize); - ASSERT(false, " "); - } + // Software will load the factory data and user data from the bottom TWO + // sectors from the flash, the FLASH_SIZE defined is the common.mk must be + // equal or greater than the actual chip flash size, otherwise the ota will + // load the wrong information + uint32_t actualFlashSize = + hal_norflash_get_flash_total_size(HAL_NORFLASH_ID_0); + if (FLASH_SIZE > actualFlashSize) { + TRACE_IMM(0, "Wrong FLASH_SIZE defined in target.mk!"); + TRACE_IMM(2, + "FLASH_SIZE is defined as 0x%x while the actual chip flash size " + "is 0x%x!", + FLASH_SIZE, actualFlashSize); + TRACE_IMM(1, + "Please change the FLASH_SIZE in common.mk to 0x%x to enable the " + "OTA feature.", + actualFlashSize); + ASSERT(false, " "); + } #endif - pmu_open(); + pmu_open(); - analog_open(); + analog_open(); - ret = mpu_open(); - if (ret == 0) { - mpu_setup(); - } + ret = mpu_open(); + if (ret == 0) { + mpu_setup(); + } - srand(hal_sys_timer_get()); + srand(hal_sys_timer_get()); #if defined(_AUTO_TEST_) - at_Init(); + at_Init(); #endif #ifdef VOICE_DATAPATH - app_audio_buffer_check(); + app_audio_buffer_check(); #endif #ifdef FPGA - TRACE(0,"\n[best of best of best...]\n"); - TRACE(1,"\n[ps: w4 0x%x,2]", &ddddd); + TRACE(0, "\n[best of best of best...]\n"); + TRACE(1, "\n[ps: w4 0x%x,2]", &ddddd); - ddddd = 1; - while (ddddd == 1); - TRACE(0,"bt start"); + ddddd = 1; + while (ddddd == 1) + ; + TRACE(0, "bt start"); - list_init(); + list_init(); - app_os_init(); - app_bt_init(); - a2dp_audio_init(); + app_os_init(); + app_bt_init(); + a2dp_audio_init(); - af_open(); - app_audio_open(); - app_audio_manager_open(); - app_overlay_open(); + af_open(); + app_audio_open(); + app_audio_manager_open(); + app_overlay_open(); #if defined(AAC_TEST) - app_overlay_select(APP_OVERLAY_A2DP_AAC); - decode_aac_frame_test(aac_test_pcm_buff, AAC_TEST_PCM_BUFF_LEN); + app_overlay_select(APP_OVERLAY_A2DP_AAC); + decode_aac_frame_test(aac_test_pcm_buff, AAC_TEST_PCM_BUFF_LEN); #endif - SAFE_PROGRAM_STOP(); + SAFE_PROGRAM_STOP(); #else // !FPGA #ifdef __FACTORY_MODE_SUPPORT__ - if (bootmode & HAL_SW_BOOTMODE_FACTORY){ - hal_sw_bootmode_clear(HAL_SW_BOOTMODE_FACTORY); - ret = app_factorymode_init(bootmode); + if (bootmode & HAL_SW_BOOTMODE_FACTORY) { + hal_sw_bootmode_clear(HAL_SW_BOOTMODE_FACTORY); + ret = app_factorymode_init(bootmode); - }else if(bootmode & HAL_SW_BOOTMODE_CALIB){ - hal_sw_bootmode_clear(HAL_SW_BOOTMODE_CALIB); - ret = app_factorymode_calib_only(); - } + } else if (bootmode & HAL_SW_BOOTMODE_CALIB) { + hal_sw_bootmode_clear(HAL_SW_BOOTMODE_CALIB); + ret = app_factorymode_calib_only(); + } #ifdef __USB_COMM__ - else if(bootmode & HAL_SW_BOOTMODE_CDC_COMM) - { - hal_sw_bootmode_clear(HAL_SW_BOOTMODE_CDC_COMM); - ret = app_factorymode_cdc_comm(); - } + else if (bootmode & HAL_SW_BOOTMODE_CDC_COMM) { + hal_sw_bootmode_clear(HAL_SW_BOOTMODE_CDC_COMM); + ret = app_factorymode_cdc_comm(); + } #endif - else + else #endif - { + { #ifdef FIRMWARE_REV - fwRevInfoInRam = fwRevInfoInFlash; - TRACE(4,"The Firmware rev is %d.%d.%d.%d", - fwRevInfoInRam.softwareRevByte0, - fwRevInfoInRam.softwareRevByte1, - fwRevInfoInRam.softwareRevByte2, - fwRevInfoInRam.softwareRevByte3); + fwRevInfoInRam = fwRevInfoInFlash; + TRACE(4, "The Firmware rev is %d.%d.%d.%d", fwRevInfoInRam.softwareRevByte0, + fwRevInfoInRam.softwareRevByte1, fwRevInfoInRam.softwareRevByte2, + fwRevInfoInRam.softwareRevByte3); #endif - ret = app_init(); - } - if (!ret){ + ret = app_init(); + } + if (!ret) { #if defined(_AUTO_TEST_) - AUTO_TEST_SEND("BT Init ok."); + AUTO_TEST_SEND("BT Init ok."); #endif - while(1) - { - osEvent evt; + while (1) { + osEvent evt; #ifndef __POWERKEY_CTRL_ONOFF_ONLY__ - osSignalClear (main_thread_tid, 0x0f); + osSignalClear(main_thread_tid, 0x0f); #endif - //wait any signal - evt = osSignalWait(0x0, osWaitForever); + // wait any signal + evt = osSignalWait(0x0, osWaitForever); - //get role from signal value - if(evt.status == osEventSignal) - { - if(evt.value.signals & 0x04) - { - sys_case = 1; - break; - } - else if(evt.value.signals & 0x08) - { - sys_case = 2; - break; - } - }else{ - sys_case = 1; - break; - } - } + // get role from signal value + if (evt.status == osEventSignal) { + if (evt.value.signals & 0x04) { + sys_case = 1; + break; + } else if (evt.value.signals & 0x08) { + sys_case = 2; + break; + } + } else { + sys_case = 1; + break; + } } + } #ifdef __WATCHER_DOG_RESET__ - system_shutdown_wdt_config(10); + system_shutdown_wdt_config(10); #endif - app_deinit(ret); - TRACE(1,"byebye~~~ %d\n", sys_case); - if ((sys_case == 1)||(sys_case == 0)){ - TRACE(0,"shutdown\n"); + app_deinit(ret); + TRACE(1, "byebye~~~ %d\n", sys_case); + if ((sys_case == 1) || (sys_case == 0)) { + TRACE(0, "shutdown\n"); #if defined(_AUTO_TEST_) - AUTO_TEST_SEND("System shutdown."); - osDelay(50); + AUTO_TEST_SEND("System shutdown."); + osDelay(50); #endif - hal_sw_bootmode_clear(HAL_SW_BOOTMODE_REBOOT); - pmu_shutdown(); - }else if (sys_case == 2){ - TRACE(0,"reset\n"); + hal_sw_bootmode_clear(HAL_SW_BOOTMODE_REBOOT); + pmu_shutdown(); + } else if (sys_case == 2) { + TRACE(0, "reset\n"); #if defined(_AUTO_TEST_) - AUTO_TEST_SEND("System reset."); - osDelay(50); + AUTO_TEST_SEND("System reset."); + osDelay(50); #endif - hal_cmu_sys_reboot(); - } + hal_cmu_sys_reboot(); + } #endif // !FPGA - return 0; + return 0; } - diff --git a/platform/main/noapp_main.cpp b/platform/main/noapp_main.cpp index 205e950..b9fbad9 100644 --- a/platform/main/noapp_main.cpp +++ b/platform/main/noapp_main.cpp @@ -13,20 +13,20 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "hal_cmu.h" -#include "hal_timer.h" -#include "hal_dma.h" -#include "hal_trace.h" -#include "hal_iomux.h" +#include "analog.h" +#include "cmsis.h" #include "hal_bootmode.h" +#include "hal_cmu.h" +#include "hal_dma.h" +#include "hal_iomux.h" #include "hal_norflash.h" #include "hal_sleep.h" #include "hal_sysfreq.h" -#include "cmsis.h" +#include "hal_timer.h" +#include "hal_trace.h" #include "hwtimer_list.h" #include "main_entry.h" #include "pmu.h" -#include "analog.h" #ifdef RTOS #include "cmsis_os.h" @@ -43,171 +43,171 @@ #endif #ifdef __cplusplus -#define EXTERN_C extern "C" +#define EXTERN_C extern "C" #else -#define EXTERN_C extern +#define EXTERN_C extern #endif -#define TIMER_IRQ_PERIOD_MS 2500 -#define DELAY_PERIOD_MS 4000 +#define TIMER_IRQ_PERIOD_MS 2500 +#define DELAY_PERIOD_MS 4000 #ifndef FLASH_FILL -#define FLASH_FILL 1 +#define FLASH_FILL 1 #endif #ifdef KERNEL_RTX -#define OS_TIME_STR "[%2u/%u]" -#define OS_CUR_TIME , SysTick->VAL, os_time +#define OS_TIME_STR "[%2u/%u]" +#define OS_CUR_TIME , SysTick->VAL, os_time #else #define OS_TIME_STR #define OS_CUR_TIME #endif #if defined(MS_TIME) -#define TIME_STR "[%u]" OS_TIME_STR -#define CUR_TIME TICKS_TO_MS(hal_sys_timer_get()) OS_CUR_TIME +#define TIME_STR "[%u]" OS_TIME_STR +#define CUR_TIME TICKS_TO_MS(hal_sys_timer_get()) OS_CUR_TIME #elif defined(RAW_TIME) -#define TIME_STR "[0x%X]" OS_TIME_STR -#define CUR_TIME hal_sys_timer_get() OS_CUR_TIME +#define TIME_STR "[0x%X]" OS_TIME_STR +#define CUR_TIME hal_sys_timer_get() OS_CUR_TIME #else -#define TIME_STR "[%u/0x%X]" OS_TIME_STR -#define CUR_TIME TICKS_TO_MS(hal_sys_timer_get()), hal_sys_timer_get() OS_CUR_TIME +#define TIME_STR "[%u/0x%X]" OS_TIME_STR +#define CUR_TIME \ + TICKS_TO_MS(hal_sys_timer_get()), hal_sys_timer_get() OS_CUR_TIME #endif #ifndef NO_TIMER static HWTIMER_ID hw_timer = NULL; -static void timer_handler(void *param) -{ - TRACE(1,TIME_STR " Timer handler: %u", CUR_TIME, (uint32_t)param); - hwtimer_start(hw_timer, MS_TO_TICKS(TIMER_IRQ_PERIOD_MS)); - TRACE(1,TIME_STR " Start timer %u ms", CUR_TIME, TIMER_IRQ_PERIOD_MS); +static void timer_handler(void *param) { + TRACE(1, TIME_STR " Timer handler: %u", CUR_TIME, (uint32_t)param); + hwtimer_start(hw_timer, MS_TO_TICKS(TIMER_IRQ_PERIOD_MS)); + TRACE(1, TIME_STR " Start timer %u ms", CUR_TIME, TIMER_IRQ_PERIOD_MS); } #endif -const static unsigned char bytes[FLASH_FILL] = { 0x1, }; +const static unsigned char bytes[FLASH_FILL] = { + 0x1, +}; // GDB can set a breakpoint on the main function only if it is // declared as below, when linking with STD libraries. -int MAIN_ENTRY(void) -{ - int POSSIBLY_UNUSED ret; +int MAIN_ENTRY(void) { + int POSSIBLY_UNUSED ret; - hwtimer_init(); - hal_audma_open(); - hal_gpdma_open(); + hwtimer_init(); + hal_audma_open(); + hal_gpdma_open(); #ifdef DEBUG #if (DEBUG_PORT == 3) - hal_iomux_set_analog_i2c(); - hal_iomux_set_uart2(); - hal_trace_open(HAL_TRACE_TRANSPORT_UART2); + hal_iomux_set_analog_i2c(); + hal_iomux_set_uart2(); + hal_trace_open(HAL_TRACE_TRANSPORT_UART2); #elif (DEBUG_PORT == 2) - hal_iomux_set_analog_i2c(); - hal_iomux_set_uart1(); - hal_trace_open(HAL_TRACE_TRANSPORT_UART1); + hal_iomux_set_analog_i2c(); + hal_iomux_set_uart1(); + hal_trace_open(HAL_TRACE_TRANSPORT_UART1); #else - hal_iomux_set_uart0(); - hal_trace_open(HAL_TRACE_TRANSPORT_UART0); + hal_iomux_set_uart0(); + hal_trace_open(HAL_TRACE_TRANSPORT_UART0); #endif #endif #if !defined(SIMU) && !defined(FPGA) - uint8_t flash_id[HAL_NORFLASH_DEVICE_ID_LEN]; - hal_norflash_get_id(HAL_NORFLASH_ID_0, flash_id, ARRAY_SIZE(flash_id)); - TRACE(3,"FLASH_ID: %02X-%02X-%02X", flash_id[0], flash_id[1], flash_id[2]); + uint8_t flash_id[HAL_NORFLASH_DEVICE_ID_LEN]; + hal_norflash_get_id(HAL_NORFLASH_ID_0, flash_id, ARRAY_SIZE(flash_id)); + TRACE(3, "FLASH_ID: %02X-%02X-%02X", flash_id[0], flash_id[1], flash_id[2]); #endif - TRACE(1,TIME_STR " main started: filled@0x%08x", CUR_TIME, (uint32_t)bytes); + TRACE(1, TIME_STR " main started: filled@0x%08x", CUR_TIME, (uint32_t)bytes); #ifndef NO_PMU - ret = pmu_open(); - ASSERT(ret == 0, "Failed to open pmu"); + ret = pmu_open(); + ASSERT(ret == 0, "Failed to open pmu"); #endif - analog_open(); + analog_open(); - hal_cmu_simu_pass(); + hal_cmu_simu_pass(); #ifdef SIMU - hal_sw_bootmode_set(HAL_SW_BOOTMODE_FLASH_BOOT); - hal_cmu_sys_reboot(); + hal_sw_bootmode_set(HAL_SW_BOOTMODE_FLASH_BOOT); + hal_cmu_sys_reboot(); #else #ifdef SLEEP_TEST - hal_sleep_start_stats(10000, 10000); - hal_sysfreq_req(HAL_SYSFREQ_USER_INIT, HAL_CMU_FREQ_32K); + hal_sleep_start_stats(10000, 10000); + hal_sysfreq_req(HAL_SYSFREQ_USER_INIT, HAL_CMU_FREQ_32K); #else - hal_sysfreq_req(HAL_SYSFREQ_USER_INIT, HAL_CMU_FREQ_104M); + hal_sysfreq_req(HAL_SYSFREQ_USER_INIT, HAL_CMU_FREQ_104M); #endif - TRACE(1,"CPU freq: %u", hal_sys_timer_calc_cpu_freq(5, 0)); + TRACE(1, "CPU freq: %u", hal_sys_timer_calc_cpu_freq(5, 0)); #endif #ifdef HWTEST #ifdef USB_SERIAL_TEST - pmu_usb_config(PMU_USB_CONFIG_TYPE_DEVICE); - usb_serial_test(); + pmu_usb_config(PMU_USB_CONFIG_TYPE_DEVICE); + usb_serial_test(); #endif #ifdef USB_SERIAL_DIRECT_XFER_TEST - pmu_usb_config(PMU_USB_CONFIG_TYPE_DEVICE); - usb_serial_direct_xfer_test(); + pmu_usb_config(PMU_USB_CONFIG_TYPE_DEVICE); + usb_serial_direct_xfer_test(); #endif #ifdef USB_AUDIO_TEST - pmu_usb_config(PMU_USB_CONFIG_TYPE_DEVICE); - usb_audio_test(); + pmu_usb_config(PMU_USB_CONFIG_TYPE_DEVICE); + usb_audio_test(); #endif #ifdef I2C_TEST - i2c_test(); + i2c_test(); #endif #ifdef AF_TEST - af_test(); + af_test(); #endif #ifdef VD_TEST - voice_detector_test(); + voice_detector_test(); #endif #ifdef CP_TEST - cp_test(); + cp_test(); #endif #ifdef SEC_ENG_TEST - sec_eng_test(); + sec_eng_test(); #endif #ifdef TDM_TEST - tdm_test(); + tdm_test(); #endif #ifdef A7_DSP_TEST - a7_dsp_test(); + a7_dsp_test(); #endif #ifdef TRANSQ_TEST - transq_test(); + transq_test(); #endif #ifdef PSRAM_TEST - psram_test(); + psram_test(); #endif #ifdef PSRAMUHS_TEST - psramuhs_test(); + psramuhs_test(); #endif - SAFE_PROGRAM_STOP(); + SAFE_PROGRAM_STOP(); #endif // HWTEST #ifdef NO_TIMER - TRACE(0,TIME_STR " Enter sleep ...", CUR_TIME); + TRACE(0, TIME_STR " Enter sleep ...", CUR_TIME); #else - hw_timer = hwtimer_alloc(timer_handler, 0); - hwtimer_start(hw_timer, MS_TO_TICKS(TIMER_IRQ_PERIOD_MS)); - TRACE(1,TIME_STR " Start timer %u ms", CUR_TIME, TIMER_IRQ_PERIOD_MS); + hw_timer = hwtimer_alloc(timer_handler, 0); + hwtimer_start(hw_timer, MS_TO_TICKS(TIMER_IRQ_PERIOD_MS)); + TRACE(1, TIME_STR " Start timer %u ms", CUR_TIME, TIMER_IRQ_PERIOD_MS); #endif - while (1) { + while (1) { #if defined(SLEEP_TEST) && !defined(RTOS) - hal_sleep_enter_sleep(); + hal_sleep_enter_sleep(); #else - osDelay(DELAY_PERIOD_MS); - TRACE(1,TIME_STR " Delay %u ms done", CUR_TIME, DELAY_PERIOD_MS); + osDelay(DELAY_PERIOD_MS); + TRACE(1, TIME_STR " Delay %u ms done", CUR_TIME, DELAY_PERIOD_MS); #endif - } + } - SAFE_PROGRAM_STOP(); - return 0; + SAFE_PROGRAM_STOP(); + return 0; } - diff --git a/platform/main/nostd_main.c b/platform/main/nostd_main.c index 5fa28fc..22d4e12 100644 --- a/platform/main/nostd_main.c +++ b/platform/main/nostd_main.c @@ -15,4 +15,3 @@ ****************************************************************************/ #include "noapp_main.cpp" - diff --git a/rtos/rtx/TARGET_ARM7/HAL_CM.c b/rtos/rtx/TARGET_ARM7/HAL_CM.c index 071fd73..0eb615c 100644 --- a/rtos/rtx/TARGET_ARM7/HAL_CM.c +++ b/rtos/rtx/TARGET_ARM7/HAL_CM.c @@ -32,10 +32,9 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" #include "RTX_Conf.h" #include "rt_HAL_CM.h" - +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Global Variables @@ -49,12 +48,11 @@ BIT dbg_msg; * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_init_stack ---------------------------------*/ -void rt_init_stack (P_TCB p_TCB, FUNCP task_body) { +void rt_init_stack(P_TCB p_TCB, FUNCP task_body) { /* Prepare TCB and saved context for a first time start of a task. */ - U32 *stk,i,size; + U32 *stk, i, size; /* Prepare a complete interrupt frame for first task start */ size = p_TCB->priv_stack >> 2; @@ -93,20 +91,19 @@ void rt_init_stack (P_TCB p_TCB, FUNCP task_body) { We want to do stack/heap collision detection instead. */ if (p_TCB->task_id != 0x01) - p_TCB->stack[0] = MAGIC_WORD; + p_TCB->stack[0] = MAGIC_WORD; } - /*--------------------------- rt_ret_val ----------------------------------*/ -static __inline U32 *rt_ret_regs (P_TCB p_TCB) { +static __inline U32 *rt_ret_regs(P_TCB p_TCB) { /* Get pointer to task return value registers (R0..R3) in Stack */ /* Stack Frame: CPSR,R0-R13,PC */ return (U32 *)(p_TCB->tsk_stack + TCB_STACK_R0_OFFSET_BYTES); } -void rt_ret_val (P_TCB p_TCB, U32 v0) { +void rt_ret_val(P_TCB p_TCB, U32 v0) { U32 *ret; ret = rt_ret_regs(p_TCB); @@ -121,13 +118,11 @@ void rt_ret_val2(P_TCB p_TCB, U32 v0, U32 v1) { ret[1] = v1; } - /*--------------------------- dbg_init --------------------------------------*/ #ifdef DBG_MSG -void dbg_init (void) { - if ((DEMCR & DEMCR_TRCENA) && - (ITM_CONTROL & ITM_ITMENA) && +void dbg_init(void) { + if ((DEMCR & DEMCR_TRCENA) && (ITM_CONTROL & ITM_ITMENA) && (ITM_ENABLE & (1UL << 31))) { dbg_msg = __TRUE; } @@ -137,10 +132,12 @@ void dbg_init (void) { /*--------------------------- dbg_task_notify -------------------------------*/ #ifdef DBG_MSG -void dbg_task_notify (P_TCB p_tcb, BOOL create) { - while (ITM_PORT31_U32 == 0); +void dbg_task_notify(P_TCB p_tcb, BOOL create) { + while (ITM_PORT31_U32 == 0) + ; ITM_PORT31_U32 = (U32)p_tcb->ptask; - while (ITM_PORT31_U32 == 0); + while (ITM_PORT31_U32 == 0) + ; ITM_PORT31_U16 = (create << 8) | p_tcb->task_id; } #endif @@ -148,14 +145,13 @@ void dbg_task_notify (P_TCB p_tcb, BOOL create) { /*--------------------------- dbg_task_switch -------------------------------*/ #ifdef DBG_MSG -void dbg_task_switch (U32 task_id) { - while (ITM_PORT31_U32 == 0); +void dbg_task_switch(U32 task_id) { + while (ITM_PORT31_U32 == 0) + ; ITM_PORT31_U8 = task_id; } #endif - /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_ARM7/RTX_Conf_CM.c b/rtos/rtx/TARGET_ARM7/RTX_Conf_CM.c index 8293e3a..7dc1a3a 100644 --- a/rtos/rtx/TARGET_ARM7/RTX_Conf_CM.c +++ b/rtos/rtx/TARGET_ARM7/RTX_Conf_CM.c @@ -34,7 +34,6 @@ #include "cmsis_os.h" - /*---------------------------------------------------------------------------- * RTX User configuration part BEGIN *---------------------------------------------------------------------------*/ @@ -49,40 +48,40 @@ // counting "main", but not counting "osTimerThread" // Default: 6 #ifndef OS_TASKCNT -# if defined(TARGET_LPC2368) || defined(TARGET_LPC2460) -# define OS_TASKCNT 14 -# else -# error "no target defined" -# endif +#if defined(TARGET_LPC2368) || defined(TARGET_LPC2460) +#define OS_TASKCNT 14 +#else +#error "no target defined" +#endif #endif // Scheduler (+ interrupts) stack size [bytes] <64-4096:8><#/4> #ifndef OS_SCHEDULERSTKSIZE -# if defined(TARGET_LPC2368) || defined(TARGET_LPC2460) -# define OS_SCHEDULERSTKSIZE (136*2) -# else -# error "no target defined" -# endif +#if defined(TARGET_LPC2368) || defined(TARGET_LPC2460) +#define OS_SCHEDULERSTKSIZE (136 * 2) +#else +#error "no target defined" +#endif #endif // Idle stack size [bytes] <64-4096:8><#/4> // Defines default stack size for the Idle thread. #ifndef OS_IDLESTKSIZE - #define OS_IDLESTKSIZE 136 +#define OS_IDLESTKSIZE 136 #endif // Timer Thread stack size [bytes] <64-4096:8><#/4> // Defines stack size for Timer thread. // Default: 200 #ifndef OS_TIMERSTKSZ - #define OS_TIMERSTKSZ WORDS_STACK_SIZE +#define OS_TIMERSTKSZ WORDS_STACK_SIZE #endif // Check for stack overflow // Includes the stack checking code for stack overflow. // Note that additional code reduces the Kernel performance. #ifndef OS_STKCHECK - #define OS_STKCHECK 1 +#define OS_STKCHECK 1 #endif // Processor mode for thread execution @@ -90,7 +89,7 @@ // <1=> Privileged mode // Default: Privileged mode #ifndef OS_RUNPRIV - #define OS_RUNPRIV 1 +#define OS_RUNPRIV 1 #endif // @@ -101,22 +100,22 @@ // Defines the timer clock value. // Default: 6000000 (6MHz) #ifndef OS_CLOCK -# if defined(TARGET_LPC2368) -# define OS_CLOCK 96000000 +#if defined(TARGET_LPC2368) +#define OS_CLOCK 96000000 -# elif defined(TARGET_LPC2460) -# define OS_CLOCK 72000000 +#elif defined(TARGET_LPC2460) +#define OS_CLOCK 72000000 -# else -# error "no target defined" -# endif +#else +#error "no target defined" +#endif #endif // Timer tick value [us] <1-1000000> // Defines the timer tick value. // Default: 1000 (1ms) #ifndef OS_TICK - #define OS_TICK 1000 +#define OS_TICK 1000 #endif // @@ -129,14 +128,14 @@ // // Enables Round-Robin Thread switching. #ifndef OS_ROBIN - #define OS_ROBIN 1 +#define OS_ROBIN 1 #endif // Round-Robin Timeout [ticks] <1-1000> // Defines how long a thread will execute before a thread switch. // Default: 5 #ifndef OS_ROBINTOUT - #define OS_ROBINTOUT 5 +#define OS_ROBINTOUT 5 #endif // @@ -145,7 +144,7 @@ // ============== // Enables user Timers #ifndef OS_TIMERS - #define OS_TIMERS 1 +#define OS_TIMERS 1 #endif // Timer Thread Priority @@ -158,14 +157,14 @@ // Defines priority for Timer Thread // Default: High #ifndef OS_TIMERPRIO - #define OS_TIMERPRIO 5 +#define OS_TIMERPRIO 5 #endif // Timer Callback Queue size <1-32> // Number of concurrent active timer callback functions. // Default: 4 #ifndef OS_TIMERCBQSZ - #define OS_TIMERCBQS 4 +#define OS_TIMERCBQS 4 #endif // @@ -179,7 +178,7 @@ // when they are called from the interrupt handler. // Default: 16 entries #ifndef OS_FIFOSZ - #define OS_FIFOSZ 16 +#define OS_FIFOSZ 16 #endif // @@ -191,29 +190,28 @@ // Define max. number system mutexes that are used to protect // the arm standard runtime library. For microlib they are not used. #ifndef OS_MUTEXCNT - #define OS_MUTEXCNT 12 +#define OS_MUTEXCNT 12 #endif /*---------------------------------------------------------------------------- * RTX User configuration part END *---------------------------------------------------------------------------*/ -#define OS_TRV ((uint32_t)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1) - +#define OS_TRV ((uint32_t)(((double)OS_CLOCK * (double)OS_TICK) / 1E6) - 1) /*---------------------------------------------------------------------------- * OS Idle daemon *---------------------------------------------------------------------------*/ -void os_idle_demon (void) { +void os_idle_demon(void) { /* The idle demon is a system thread, running when no other thread is */ /* ready to run. */ /* Sleep: ideally, we should put the chip to sleep. - Unfortunately, this usually requires disconnecting the interface chip (debugger). - This can be done, but it would break the local file system. + Unfortunately, this usually requires disconnecting the interface chip + (debugger). This can be done, but it would break the local file system. */ for (;;) { - // sleep(); + // sleep(); } } @@ -222,16 +220,16 @@ void os_idle_demon (void) { *---------------------------------------------------------------------------*/ extern void mbed_die(void); -void os_error (uint32_t err_code) { - /* This function is called when a runtime error is detected. Parameter */ - /* 'err_code' holds the runtime error code (defined in RTX_Conf.h). */ - mbed_die(); +void os_error(uint32_t err_code) { + /* This function is called when a runtime error is detected. Parameter */ + /* 'err_code' holds the runtime error code (defined in RTX_Conf.h). */ + mbed_die(); } void sysThreadError(osStatus status) { - if (status != osOK) { - mbed_die(); - } + if (status != osOK) { + mbed_die(); + } } /*---------------------------------------------------------------------------- @@ -243,4 +241,3 @@ void sysThreadError(osStatus status) { /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_ARM7/rt_CMSIS.c b/rtos/rtx/TARGET_ARM7/rt_CMSIS.c index b2992c8..80d559d 100644 --- a/rtos/rtx/TARGET_ARM7/rt_CMSIS.c +++ b/rtos/rtx/TARGET_ARM7/rt_CMSIS.c @@ -36,18 +36,18 @@ #include "core_arm7.h" -#include "rt_TypeDef.h" #include "RTX_Conf.h" -#include "rt_System.h" -#include "rt_Task.h" #include "rt_Event.h" +#include "rt_HAL_CM.h" #include "rt_List.h" -#include "rt_Time.h" -#include "rt_Mutex.h" -#include "rt_Semaphore.h" #include "rt_Mailbox.h" #include "rt_MemBox.h" -#include "rt_HAL_CM.h" +#include "rt_Mutex.h" +#include "rt_Semaphore.h" +#include "rt_System.h" +#include "rt_Task.h" +#include "rt_Time.h" +#include "rt_TypeDef.h" #define os_thread_cb OS_TCB @@ -63,256 +63,228 @@ #error osWait not supported! #endif - // ==== Enumeration, structures, defines ==== // Service Calls defines -#if defined (__CC_ARM) /* ARM Compiler */ +#if defined(__CC_ARM) /* ARM Compiler */ #define __NO_RETURN __declspec(noreturn) -#define osEvent_type osEvent +#define osEvent_type osEvent #define osEvent_ret_status ret -#define osEvent_ret_value ret -#define osEvent_ret_msg ret -#define osEvent_ret_mail ret +#define osEvent_ret_value ret +#define osEvent_ret_msg ret +#define osEvent_ret_mail ret -#define osCallback_type osCallback -#define osCallback_ret ret +#define osCallback_type osCallback +#define osCallback_ret ret -#define SVC_0_1(f,t,...) \ -__svc_indirect(0) t _##f (t(*)()); \ - t f (void); \ -__attribute__((always_inline)) \ -static __inline t __##f (void) { \ - return _##f(f); \ -} +#define SVC_0_1(f, t, ...) \ + __svc_indirect(0) t _##f(t (*)()); \ + t f(void); \ + __attribute__((always_inline)) static __inline t __##f(void) { \ + return _##f(f); \ + } -#define SVC_1_1(f,t,t1,...) \ -__svc_indirect(0) t _##f (t(*)(t1),t1); \ - t f (t1 a1); \ -__attribute__((always_inline)) \ -static __inline t __##f (t1 a1) { \ - return _##f(f,a1); \ -} +#define SVC_1_1(f, t, t1, ...) \ + __svc_indirect(0) t _##f(t (*)(t1), t1); \ + t f(t1 a1); \ + __attribute__((always_inline)) static __inline t __##f(t1 a1) { \ + return _##f(f, a1); \ + } -#define SVC_2_1(f,t,t1,t2,...) \ -__svc_indirect(0) t _##f (t(*)(t1,t2),t1,t2); \ - t f (t1 a1, t2 a2); \ -__attribute__((always_inline)) \ -static __inline t __##f (t1 a1, t2 a2) { \ - return _##f(f,a1,a2); \ -} +#define SVC_2_1(f, t, t1, t2, ...) \ + __svc_indirect(0) t _##f(t (*)(t1, t2), t1, t2); \ + t f(t1 a1, t2 a2); \ + __attribute__((always_inline)) static __inline t __##f(t1 a1, t2 a2) { \ + return _##f(f, a1, a2); \ + } -#define SVC_3_1(f,t,t1,t2,t3,...) \ -__svc_indirect(0) t _##f (t(*)(t1,t2,t3),t1,t2,t3); \ - t f (t1 a1, t2 a2, t3 a3); \ -__attribute__((always_inline)) \ -static __inline t __##f (t1 a1, t2 a2, t3 a3) { \ - return _##f(f,a1,a2,a3); \ -} +#define SVC_3_1(f, t, t1, t2, t3, ...) \ + __svc_indirect(0) t _##f(t (*)(t1, t2, t3), t1, t2, t3); \ + t f(t1 a1, t2 a2, t3 a3); \ + __attribute__((always_inline)) static __inline t __##f(t1 a1, t2 a2, \ + t3 a3) { \ + return _##f(f, a1, a2, a3); \ + } -#define SVC_4_1(f,t,t1,t2,t3,t4,...) \ -__svc_indirect(0) t _##f (t(*)(t1,t2,t3,t4),t1,t2,t3,t4); \ - t f (t1 a1, t2 a2, t3 a3, t4 a4); \ -__attribute__((always_inline)) \ -static __inline t __##f (t1 a1, t2 a2, t3 a3, t4 a4) { \ - return _##f(f,a1,a2,a3,a4); \ -} +#define SVC_4_1(f, t, t1, t2, t3, t4, ...) \ + __svc_indirect(0) t _##f(t (*)(t1, t2, t3, t4), t1, t2, t3, t4); \ + t f(t1 a1, t2 a2, t3 a3, t4 a4); \ + __attribute__((always_inline)) static __inline t __##f(t1 a1, t2 a2, t3 a3, \ + t4 a4) { \ + return _##f(f, a1, a2, a3, a4); \ + } #define SVC_1_2 SVC_1_1 #define SVC_1_3 SVC_1_1 #define SVC_2_3 SVC_2_1 -#elif defined (__GNUC__) /* GNU Compiler */ +#elif defined(__GNUC__) /* GNU Compiler */ #define __NO_RETURN __attribute__((noreturn)) -typedef uint32_t __attribute__((vector_size(8))) ret64; +typedef uint32_t __attribute__((vector_size(8))) ret64; typedef uint32_t __attribute__((vector_size(16))) ret128; -#define RET_pointer __r0 -#define RET_int32_t __r0 -#define RET_osStatus __r0 +#define RET_pointer __r0 +#define RET_int32_t __r0 +#define RET_osStatus __r0 #define RET_osPriority __r0 -#define RET_osEvent {(osStatus)__r0, {(uint32_t)__r1}, {(void *)__r2}} -#define RET_osCallback {(void *)__r0, (void *)__r1} +#define RET_osEvent \ + { \ + (osStatus) __r0, {(uint32_t)__r1}, { (void *)__r2 } \ + } +#define RET_osCallback \ + { (void *)__r0, (void *)__r1 } -#define osEvent_type ret128 -#define osEvent_ret_status (ret128){ret.status} -#define osEvent_ret_value (ret128){ret.status, ret.value.v} -#define osEvent_ret_msg (ret128){ret.status, ret.value.v, (uint32_t)ret.def.message_id} -#define osEvent_ret_mail (ret128){ret.status, ret.value.v, (uint32_t)ret.def.mail_id} +#define osEvent_type ret128 +#define osEvent_ret_status \ + (ret128) { ret.status } +#define osEvent_ret_value \ + (ret128) { ret.status, ret.value.v } +#define osEvent_ret_msg \ + (ret128) { ret.status, ret.value.v, (uint32_t)ret.def.message_id } +#define osEvent_ret_mail \ + (ret128) { ret.status, ret.value.v, (uint32_t)ret.def.mail_id } -#define osCallback_type ret64 -#define osCallback_ret (ret64) {(uint32_t)ret.fp, (uint32_t)ret.arg} +#define osCallback_type ret64 +#define osCallback_ret \ + (ret64) { (uint32_t) ret.fp, (uint32_t)ret.arg } -#define SVC_ArgN(n) \ - register int __r##n __asm("r"#n); +#define SVC_ArgN(n) register int __r##n __asm("r" #n); -#define SVC_ArgR(n,t,a) \ - register t __r##n __asm("r"#n) = a; +#define SVC_ArgR(n, t, a) register t __r##n __asm("r" #n) = a; -#define SVC_Arg0() \ - SVC_ArgN(0) \ - SVC_ArgN(1) \ - SVC_ArgN(2) \ - SVC_ArgN(3) +#define SVC_Arg0() SVC_ArgN(0) SVC_ArgN(1) SVC_ArgN(2) SVC_ArgN(3) -#define SVC_Arg1(t1) \ - SVC_ArgR(0,t1,a1) \ - SVC_ArgN(1) \ - SVC_ArgN(2) \ - SVC_ArgN(3) +#define SVC_Arg1(t1) SVC_ArgR(0, t1, a1) SVC_ArgN(1) SVC_ArgN(2) SVC_ArgN(3) -#define SVC_Arg2(t1,t2) \ - SVC_ArgR(0,t1,a1) \ - SVC_ArgR(1,t2,a2) \ - SVC_ArgN(2) \ - SVC_ArgN(3) +#define SVC_Arg2(t1, t2) \ + SVC_ArgR(0, t1, a1) SVC_ArgR(1, t2, a2) SVC_ArgN(2) SVC_ArgN(3) -#define SVC_Arg3(t1,t2,t3) \ - SVC_ArgR(0,t1,a1) \ - SVC_ArgR(1,t2,a2) \ - SVC_ArgR(2,t3,a3) \ - SVC_ArgN(3) +#define SVC_Arg3(t1, t2, t3) \ + SVC_ArgR(0, t1, a1) SVC_ArgR(1, t2, a2) SVC_ArgR(2, t3, a3) SVC_ArgN(3) -#define SVC_Arg4(t1,t2,t3,t4) \ - SVC_ArgR(0,t1,a1) \ - SVC_ArgR(1,t2,a2) \ - SVC_ArgR(2,t3,a3) \ - SVC_ArgR(3,t4,a4) +#define SVC_Arg4(t1, t2, t3, t4) \ + SVC_ArgR(0, t1, a1) SVC_ArgR(1, t2, a2) SVC_ArgR(2, t3, a3) \ + SVC_ArgR(3, t4, a4) -#if (defined (__CORTEX_M0)) || defined (__CORTEX_M0PLUS) +#if (defined(__CORTEX_M0)) || defined(__CORTEX_M0PLUS) #define SVC_Call(f) \ - __asm volatile \ - ( \ - "ldr r7,="#f"\n\t" \ - "mov r12,r7\n\t" \ - "svc 0" \ - : "=r" (__r0), "=r" (__r1), "=r" (__r2), "=r" (__r3) \ - : "r" (__r0), "r" (__r1), "r" (__r2), "r" (__r3) \ - : "r7", "r12", "lr", "cc" \ - ); + __asm volatile("ldr r7,=" #f "\n\t" \ + "mov r12,r7\n\t" \ + "svc 0" \ + : "=r"(__r0), "=r"(__r1), "=r"(__r2), "=r"(__r3) \ + : "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3) \ + : "r7", "r12", "lr", "cc"); #else #define SVC_Call(f) \ - __asm volatile \ - ( \ - "ldr r12,="#f"\n\t" \ - "svc 0" \ - : "=r" (__r0), "=r" (__r1), "=r" (__r2), "=r" (__r3) \ - : "r" (__r0), "r" (__r1), "r" (__r2), "r" (__r3) \ - : "r12", "lr", "cc" \ - ); + __asm volatile("ldr r12,=" #f "\n\t" \ + "svc 0" \ + : "=r"(__r0), "=r"(__r1), "=r"(__r2), "=r"(__r3) \ + : "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3) \ + : "r12", "lr", "cc"); #endif -#define SVC_0_1(f,t,rv) \ -__attribute__((always_inline)) \ -static inline t __##f (void) { \ - SVC_Arg0(); \ - SVC_Call(f); \ - return (t) rv; \ -} +#define SVC_0_1(f, t, rv) \ + __attribute__((always_inline)) static inline t __##f(void) { \ + SVC_Arg0(); \ + SVC_Call(f); \ + return (t)rv; \ + } -#define SVC_1_1(f,t,t1,rv) \ -__attribute__((always_inline)) \ -static inline t __##f (t1 a1) { \ - SVC_Arg1(t1); \ - SVC_Call(f); \ - return (t) rv; \ -} +#define SVC_1_1(f, t, t1, rv) \ + __attribute__((always_inline)) static inline t __##f(t1 a1) { \ + SVC_Arg1(t1); \ + SVC_Call(f); \ + return (t)rv; \ + } -#define SVC_2_1(f,t,t1,t2,rv) \ -__attribute__((always_inline)) \ -static inline t __##f (t1 a1, t2 a2) { \ - SVC_Arg2(t1,t2); \ - SVC_Call(f); \ - return (t) rv; \ -} +#define SVC_2_1(f, t, t1, t2, rv) \ + __attribute__((always_inline)) static inline t __##f(t1 a1, t2 a2) { \ + SVC_Arg2(t1, t2); \ + SVC_Call(f); \ + return (t)rv; \ + } -#define SVC_3_1(f,t,t1,t2,t3,rv) \ -__attribute__((always_inline)) \ -static inline t __##f (t1 a1, t2 a2, t3 a3) { \ - SVC_Arg3(t1,t2,t3); \ - SVC_Call(f); \ - return (t) rv; \ -} +#define SVC_3_1(f, t, t1, t2, t3, rv) \ + __attribute__((always_inline)) static inline t __##f(t1 a1, t2 a2, t3 a3) { \ + SVC_Arg3(t1, t2, t3); \ + SVC_Call(f); \ + return (t)rv; \ + } -#define SVC_4_1(f,t,t1,t2,t3,t4,rv) \ -__attribute__((always_inline)) \ -static inline t __##f (t1 a1, t2 a2, t3 a3, t4 a4) { \ - SVC_Arg4(t1,t2,t3,t4); \ - SVC_Call(f); \ - return (t) rv; \ -} +#define SVC_4_1(f, t, t1, t2, t3, t4, rv) \ + __attribute__((always_inline)) static inline t __##f(t1 a1, t2 a2, t3 a3, \ + t4 a4) { \ + SVC_Arg4(t1, t2, t3, t4); \ + SVC_Call(f); \ + return (t)rv; \ + } #define SVC_1_2 SVC_1_1 #define SVC_1_3 SVC_1_1 #define SVC_2_3 SVC_2_1 -#elif defined (__ICCARM__) /* IAR Compiler */ +#elif defined(__ICCARM__) /* IAR Compiler */ #define __NO_RETURN __noreturn -#define osEvent_type osEvent +#define osEvent_type osEvent #define osEvent_ret_status ret -#define osEvent_ret_value ret -#define osEvent_ret_msg ret -#define osEvent_ret_mail ret +#define osEvent_ret_value ret +#define osEvent_ret_msg ret +#define osEvent_ret_mail ret -#define osCallback_type osCallback -#define osCallback_ret ret +#define osCallback_type osCallback +#define osCallback_ret ret -#define RET_osEvent osEvent -#define RET_osCallback osCallback +#define RET_osEvent osEvent +#define RET_osCallback osCallback -#define SVC_Setup(f) \ - __asm( \ - "mov r12,%0\n" \ - :: "r"(&f): "r12" \ - ); +#define SVC_Setup(f) __asm("mov r12,%0\n" ::"r"(&f) : "r12"); +#define SVC_0_1(f, t, ...) \ + t f(void); \ + _Pragma("swi_number=0") __swi t _##f(void); \ + static inline t __##f(void) { \ + SVC_Setup(f); \ + return _##f(); \ + } -#define SVC_0_1(f,t,...) \ -t f (void); \ -_Pragma("swi_number=0") __swi t _##f (void); \ -static inline t __##f (void) { \ - SVC_Setup(f); \ - return _##f(); \ -} +#define SVC_1_1(f, t, t1, ...) \ + t f(t1 a1); \ + _Pragma("swi_number=0") __swi t _##f(t1 a1); \ + static inline t __##f(t1 a1) { \ + SVC_Setup(f); \ + return _##f(a1); \ + } -#define SVC_1_1(f,t,t1,...) \ -t f (t1 a1); \ -_Pragma("swi_number=0") __swi t _##f (t1 a1); \ -static inline t __##f (t1 a1) { \ - SVC_Setup(f); \ - return _##f(a1); \ -} +#define SVC_2_1(f, t, t1, t2, ...) \ + t f(t1 a1, t2 a2); \ + _Pragma("swi_number=0") __swi t _##f(t1 a1, t2 a2); \ + static inline t __##f(t1 a1, t2 a2) { \ + SVC_Setup(f); \ + return _##f(a1, a2); \ + } -#define SVC_2_1(f,t,t1,t2,...) \ -t f (t1 a1, t2 a2); \ -_Pragma("swi_number=0") __swi t _##f (t1 a1, t2 a2); \ -static inline t __##f (t1 a1, t2 a2) { \ - SVC_Setup(f); \ - return _##f(a1,a2); \ -} +#define SVC_3_1(f, t, t1, t2, t3, ...) \ + t f(t1 a1, t2 a2, t3 a3); \ + _Pragma("swi_number=0") __swi t _##f(t1 a1, t2 a2, t3 a3); \ + static inline t __##f(t1 a1, t2 a2, t3 a3) { \ + SVC_Setup(f); \ + return _##f(a1, a2, a3); \ + } -#define SVC_3_1(f,t,t1,t2,t3,...) \ -t f (t1 a1, t2 a2, t3 a3); \ -_Pragma("swi_number=0") __swi t _##f (t1 a1, t2 a2, t3 a3); \ -static inline t __##f (t1 a1, t2 a2, t3 a3) { \ - SVC_Setup(f); \ - return _##f(a1,a2,a3); \ -} - -#define SVC_4_1(f,t,t1,t2,t3,t4,...) \ -t f (t1 a1, t2 a2, t3 a3, t4 a4); \ -_Pragma("swi_number=0") __swi t _##f (t1 a1, t2 a2, t3 a3, t4 a4); \ -static inline t __##f (t1 a1, t2 a2, t3 a3, t4 a4) { \ - SVC_Setup(f); \ - return _##f(a1,a2,a3,a4); \ -} +#define SVC_4_1(f, t, t1, t2, t3, t4, ...) \ + t f(t1 a1, t2 a2, t3 a3, t4 a4); \ + _Pragma("swi_number=0") __swi t _##f(t1 a1, t2 a2, t3 a3, t4 a4); \ + static inline t __##f(t1 a1, t2 a2, t3 a3, t4 a4) { \ + SVC_Setup(f); \ + return _##f(a1, a2, a3, a4); \ + } #define SVC_1_2 SVC_1_1 #define SVC_1_3 SVC_1_1 @@ -320,102 +292,110 @@ static inline t __##f (t1 a1, t2 a2, t3 a3, t4 a4) { \ #endif - // Callback structure typedef struct { - void *fp; // Function pointer - void *arg; // Function argument + void *fp; // Function pointer + void *arg; // Function argument } osCallback; - // OS Section definitions #ifdef OS_SECTIONS_LINK_INFO -extern const uint32_t os_section_id$$Base; -extern const uint32_t os_section_id$$Limit; +extern const uint32_t os_section_id$$Base; +extern const uint32_t os_section_id$$Limit; #endif // OS Timers external resources -extern osThreadDef_t os_thread_def_osTimerThread; -extern osThreadId osThreadId_osTimerThread; +extern osThreadDef_t os_thread_def_osTimerThread; +extern osThreadId osThreadId_osTimerThread; extern osMessageQDef_t os_messageQ_def_osTimerMessageQ; -extern osMessageQId osMessageQId_osTimerMessageQ; - +extern osMessageQId osMessageQId_osTimerMessageQ; // ==== Helper Functions ==== /// Convert timeout in millisec to system ticks -static uint32_t rt_ms2tick (uint32_t millisec) { +static uint32_t rt_ms2tick(uint32_t millisec) { uint32_t tick; - if (millisec == osWaitForever) return 0xFFFF; // Indefinite timeout - if (millisec > 4000000) return 0xFFFE; // Max ticks supported + if (millisec == osWaitForever) + return 0xFFFF; // Indefinite timeout + if (millisec > 4000000) + return 0xFFFE; // Max ticks supported - tick = ((1000 * millisec) + os_clockrate - 1) / os_clockrate; - if (tick > 0xFFFE) return 0xFFFE; + tick = ((1000 * millisec) + os_clockrate - 1) / os_clockrate; + if (tick > 0xFFFE) + return 0xFFFE; return tick; } /// Convert Thread ID to TCB pointer -static P_TCB rt_tid2ptcb (osThreadId thread_id) { +static P_TCB rt_tid2ptcb(osThreadId thread_id) { P_TCB ptcb; - if (thread_id == NULL) return NULL; + if (thread_id == NULL) + return NULL; - if ((uint32_t)thread_id & 3) return NULL; + if ((uint32_t)thread_id & 3) + return NULL; #ifdef OS_SECTIONS_LINK_INFO if ((os_section_id$$Base != 0) && (os_section_id$$Limit != 0)) { - if (thread_id < (osThreadId)os_section_id$$Base) return NULL; - if (thread_id >= (osThreadId)os_section_id$$Limit) return NULL; + if (thread_id < (osThreadId)os_section_id$$Base) + return NULL; + if (thread_id >= (osThreadId)os_section_id$$Limit) + return NULL; } #endif ptcb = thread_id; - if (ptcb->cb_type != TCB) return NULL; + if (ptcb->cb_type != TCB) + return NULL; return ptcb; } /// Convert ID pointer to Object pointer -static void *rt_id2obj (void *id) { +static void *rt_id2obj(void *id) { - if ((uint32_t)id & 3) return NULL; + if ((uint32_t)id & 3) + return NULL; #ifdef OS_SECTIONS_LINK_INFO if ((os_section_id$$Base != 0) && (os_section_id$$Limit != 0)) { - if (id < (void *)os_section_id$$Base) return NULL; - if (id >= (void *)os_section_id$$Limit) return NULL; + if (id < (void *)os_section_id$$Base) + return NULL; + if (id >= (void *)os_section_id$$Limit) + return NULL; } #endif return id; } - // ==== Kernel Control ==== -uint8_t os_initialized; // Kernel Initialized flag -uint8_t os_running; // Kernel Running flag +uint8_t os_initialized; // Kernel Initialized flag +uint8_t os_running; // Kernel Running flag // Kernel Control Service Calls declarations SVC_0_1(svcKernelInitialize, osStatus, RET_osStatus) -SVC_0_1(svcKernelStart, osStatus, RET_osStatus) -SVC_0_1(svcKernelRunning, int32_t, RET_int32_t) +SVC_0_1(svcKernelStart, osStatus, RET_osStatus) +SVC_0_1(svcKernelRunning, int32_t, RET_int32_t) -extern void sysThreadError (osStatus status); -osThreadId svcThreadCreate (osThreadDef_t *thread_def, void *argument); -osMessageQId svcMessageCreate (osMessageQDef_t *queue_def, osThreadId thread_id); +extern void sysThreadError(osStatus status); +osThreadId svcThreadCreate(osThreadDef_t *thread_def, void *argument); +osMessageQId svcMessageCreate(osMessageQDef_t *queue_def, osThreadId thread_id); // Kernel Control Service Calls /// Initialize the RTOS Kernel for creating objects -osStatus svcKernelInitialize (void) { - if (os_initialized) return osOK; +osStatus svcKernelInitialize(void) { + if (os_initialized) + return osOK; - rt_sys_init(); // RTX System Initialization - os_tsk.run->prio = 255; // Highest priority + rt_sys_init(); // RTX System Initialization + os_tsk.run->prio = 255; // Highest priority sysThreadError(osOK); @@ -425,17 +405,20 @@ osStatus svcKernelInitialize (void) { } /// Start the RTOS Kernel -osStatus svcKernelStart (void) { +osStatus svcKernelStart(void) { - if (os_running) return osOK; + if (os_running) + return osOK; // Create OS Timers resources (Message Queue & Thread) - osMessageQId_osTimerMessageQ = svcMessageCreate (&os_messageQ_def_osTimerMessageQ, NULL); - osThreadId_osTimerThread = svcThreadCreate(&os_thread_def_osTimerThread, NULL); + osMessageQId_osTimerMessageQ = + svcMessageCreate(&os_messageQ_def_osTimerMessageQ, NULL); + osThreadId_osTimerThread = + svcThreadCreate(&os_thread_def_osTimerThread, NULL); - rt_tsk_prio(0, 0); // Lowest priority -// __set_SP(os_tsk.run->tsk_stack + 8*4); // New context - os_tsk.run = NULL; // Force context switch + rt_tsk_prio(0, 0); // Lowest priority + // __set_SP(os_tsk.run->tsk_stack + 8*4); // New context + os_tsk.run = NULL; // Force context switch rt_sys_start(); @@ -445,35 +428,35 @@ osStatus svcKernelStart (void) { } /// Check if the RTOS kernel is already started -int32_t svcKernelRunning(void) { - return os_running; -} +int32_t svcKernelRunning(void) { return os_running; } // Kernel Control Public API /// Initialize the RTOS Kernel for creating objects -osStatus osKernelInitialize (void) { - if (__get_CONTROL() == MODE_IRQ) return osErrorISR; // Not allowed in ISR - if (__get_CONTROL() == MODE_SUPERVISOR) { // Privileged mode - return svcKernelInitialize(); +osStatus osKernelInitialize(void) { + if (__get_CONTROL() == MODE_IRQ) + return osErrorISR; // Not allowed in ISR + if (__get_CONTROL() == MODE_SUPERVISOR) { // Privileged mode + return svcKernelInitialize(); } else { return __svcKernelInitialize(); } } /// Start the RTOS Kernel -osStatus osKernelStart (void) { +osStatus osKernelStart(void) { - if (__get_CONTROL() == MODE_IRQ) return osErrorISR; // Not allowed in ISR + if (__get_CONTROL() == MODE_IRQ) + return osErrorISR; // Not allowed in ISR switch (__get_CONTROL()) { - case MODE_SUPERVISOR: // Privileged mode - break; - case MODE_USER: - case MODE_SYSTEM: // Unprivileged mode - return osErrorOS; - default: // Other invalid modes - return osErrorOS; - break; + case MODE_SUPERVISOR: // Privileged mode + break; + case MODE_USER: + case MODE_SYSTEM: // Unprivileged mode + return osErrorOS; + default: // Other invalid modes + return osErrorOS; + break; } return svcKernelStart(); } @@ -488,33 +471,30 @@ int32_t osKernelRunning(void) { } } - // ==== Thread Management ==== -__NO_RETURN void osThreadExit (void); +__NO_RETURN void osThreadExit(void); // Thread Service Calls declarations -SVC_2_1(svcThreadCreate, osThreadId, osThreadDef_t *, void *, RET_pointer) -SVC_0_1(svcThreadGetId, osThreadId, RET_pointer) -SVC_1_1(svcThreadTerminate, osStatus, osThreadId, RET_osStatus) -SVC_0_1(svcThreadYield, osStatus, RET_osStatus) -SVC_2_1(svcThreadSetPriority, osStatus, osThreadId, osPriority, RET_osStatus) -SVC_1_1(svcThreadGetPriority, osPriority, osThreadId, RET_osPriority) +SVC_2_1(svcThreadCreate, osThreadId, osThreadDef_t *, void *, RET_pointer) +SVC_0_1(svcThreadGetId, osThreadId, RET_pointer) +SVC_1_1(svcThreadTerminate, osStatus, osThreadId, RET_osStatus) +SVC_0_1(svcThreadYield, osStatus, RET_osStatus) +SVC_2_1(svcThreadSetPriority, osStatus, osThreadId, osPriority, RET_osStatus) +SVC_1_1(svcThreadGetPriority, osPriority, osThreadId, RET_osPriority) // Thread Service Calls -extern OS_TID rt_get_TID (void); -extern void rt_init_context (P_TCB p_TCB, U8 priority, FUNCP task_body); +extern OS_TID rt_get_TID(void); +extern void rt_init_context(P_TCB p_TCB, U8 priority, FUNCP task_body); /// Create a thread and add it to Active Threads and set it to state READY -osThreadId svcThreadCreate (osThreadDef_t *thread_def, void *argument) { - P_TCB ptcb; +osThreadId svcThreadCreate(osThreadDef_t *thread_def, void *argument) { + P_TCB ptcb; - if ((thread_def == NULL) || - (thread_def->pthread == NULL) || + if ((thread_def == NULL) || (thread_def->pthread == NULL) || (thread_def->tpriority < osPriorityIdle) || (thread_def->tpriority > osPriorityRealtime) || - (thread_def->stacksize == 0) || - (thread_def->stack_pointer == NULL) ) { + (thread_def->stacksize == 0) || (thread_def->stack_pointer == NULL)) { sysThreadError(osErrorParameter); return NULL; } @@ -523,162 +503,175 @@ osThreadId svcThreadCreate (osThreadDef_t *thread_def, void *argument) { P_TCB task_context = &thread_def->tcb; /* Utilize the user provided stack. */ - task_context->stack = (U32*)thread_def->stack_pointer; + task_context->stack = (U32 *)thread_def->stack_pointer; task_context->priv_stack = thread_def->stacksize; /* Find a free entry in 'os_active_TCB' table. */ - OS_TID tsk = rt_get_TID (); - os_active_TCB[tsk-1] = task_context; + OS_TID tsk = rt_get_TID(); + os_active_TCB[tsk - 1] = task_context; task_context->task_id = tsk; /* Pass parameter 'argv' to 'rt_init_context' */ task_context->msg = argument; /* For 'size == 0' system allocates the user stack from the memory pool. */ - rt_init_context (task_context, priority, (FUNCP)thread_def->pthread); + rt_init_context(task_context, priority, (FUNCP)thread_def->pthread); /* Dispatch this task to the scheduler for execution. */ DBG_TASK_NOTIFY(task_context, __TRUE); - rt_dispatch (task_context); + rt_dispatch(task_context); - ptcb = (P_TCB)os_active_TCB[tsk - 1]; // TCB pointer + ptcb = (P_TCB)os_active_TCB[tsk - 1]; // TCB pointer - *((uint32_t *)ptcb->tsk_stack + TCB_STACK_LR_OFFSET_DWORDS) = (uint32_t)osThreadExit; /* LR = osThreadExit */ + *((uint32_t *)ptcb->tsk_stack + TCB_STACK_LR_OFFSET_DWORDS) = + (uint32_t)osThreadExit; /* LR = osThreadExit */ return ptcb; } /// Return the thread ID of the current running thread -osThreadId svcThreadGetId (void) { +osThreadId svcThreadGetId(void) { OS_TID tsk; tsk = rt_tsk_self(); - if (tsk == 0) return NULL; + if (tsk == 0) + return NULL; return (P_TCB)os_active_TCB[tsk - 1]; } /// Terminate execution of a thread and remove it from ActiveThreads -osStatus svcThreadTerminate (osThreadId thread_id) { +osStatus svcThreadTerminate(osThreadId thread_id) { OS_RESULT res; - P_TCB ptcb; + P_TCB ptcb; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return osErrorParameter; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return osErrorParameter; - res = rt_tsk_delete(ptcb->task_id); // Delete task + res = rt_tsk_delete(ptcb->task_id); // Delete task - if (res == OS_R_NOK) return osErrorResource; // Delete task failed + if (res == OS_R_NOK) + return osErrorResource; // Delete task failed return osOK; } /// Pass control to next thread that is in state READY -osStatus svcThreadYield (void) { - rt_tsk_pass(); // Pass control to next task +osStatus svcThreadYield(void) { + rt_tsk_pass(); // Pass control to next task return osOK; } /// Change priority of an active thread -osStatus svcThreadSetPriority (osThreadId thread_id, osPriority priority) { +osStatus svcThreadSetPriority(osThreadId thread_id, osPriority priority) { OS_RESULT res; - P_TCB ptcb; + P_TCB ptcb; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return osErrorParameter; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return osErrorParameter; if ((priority < osPriorityIdle) || (priority > osPriorityRealtime)) { return osErrorValue; } - res = rt_tsk_prio( // Change task priority - ptcb->task_id, // Task ID - priority - osPriorityIdle + 1 // New task priority + res = rt_tsk_prio( // Change task priority + ptcb->task_id, // Task ID + priority - osPriorityIdle + 1 // New task priority ); - if (res == OS_R_NOK) return osErrorResource; // Change task priority failed + if (res == OS_R_NOK) + return osErrorResource; // Change task priority failed return osOK; } /// Get current priority of an active thread -osPriority svcThreadGetPriority (osThreadId thread_id) { +osPriority svcThreadGetPriority(osThreadId thread_id) { P_TCB ptcb; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return osPriorityError; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return osPriorityError; return (osPriority)(ptcb->prio - 1 + osPriorityIdle); } - // Thread Public API /// Create a thread and add it to Active Threads and set it to state READY -osThreadId osThreadCreate (osThreadDef_t *thread_def, void *argument) { - if (__get_CONTROL() == MODE_IRQ) return NULL; // Not allowed in ISR +osThreadId osThreadCreate(osThreadDef_t *thread_def, void *argument) { + if (__get_CONTROL() == MODE_IRQ) + return NULL; // Not allowed in ISR if ((__get_CONTROL() == MODE_SUPERVISOR) && (os_running == 0)) { // Privileged and not running - return svcThreadCreate(thread_def, argument); + return svcThreadCreate(thread_def, argument); } else { return __svcThreadCreate(thread_def, argument); } } /// Return the thread ID of the current running thread -osThreadId osThreadGetId (void) { - if (__get_CONTROL() == MODE_IRQ) return NULL; // Not allowed in ISR +osThreadId osThreadGetId(void) { + if (__get_CONTROL() == MODE_IRQ) + return NULL; // Not allowed in ISR return __svcThreadGetId(); } /// Terminate execution of a thread and remove it from ActiveThreads -osStatus osThreadTerminate (osThreadId thread_id) { - if (__get_CONTROL() == MODE_IRQ) return osErrorISR; // Not allowed in ISR +osStatus osThreadTerminate(osThreadId thread_id) { + if (__get_CONTROL() == MODE_IRQ) + return osErrorISR; // Not allowed in ISR return __svcThreadTerminate(thread_id); } /// Pass control to next thread that is in state READY -osStatus osThreadYield (void) { - if (__get_CONTROL() == MODE_IRQ) return osErrorISR; // Not allowed in ISR +osStatus osThreadYield(void) { + if (__get_CONTROL() == MODE_IRQ) + return osErrorISR; // Not allowed in ISR return __svcThreadYield(); } /// Change priority of an active thread -osStatus osThreadSetPriority (osThreadId thread_id, osPriority priority) { - if (__get_CONTROL() == MODE_IRQ) return osErrorISR; // Not allowed in ISR +osStatus osThreadSetPriority(osThreadId thread_id, osPriority priority) { + if (__get_CONTROL() == MODE_IRQ) + return osErrorISR; // Not allowed in ISR return __svcThreadSetPriority(thread_id, priority); } /// Get current priority of an active thread -osPriority osThreadGetPriority (osThreadId thread_id) { - if (__get_CONTROL() == MODE_IRQ) return osPriorityError;// Not allowed in ISR +osPriority osThreadGetPriority(osThreadId thread_id) { + if (__get_CONTROL() == MODE_IRQ) + return osPriorityError; // Not allowed in ISR return __svcThreadGetPriority(thread_id); } /// INTERNAL - Not Public /// Auto Terminate Thread on exit (used implicitly when thread exists) -__NO_RETURN void osThreadExit (void) { +__NO_RETURN void osThreadExit(void) { __svcThreadTerminate(__svcThreadGetId()); - for (;;); // Should never come here + for (;;) + ; // Should never come here } - // ==== Generic Wait Functions ==== // Generic Wait Service Calls declarations -SVC_1_1(svcDelay, osStatus, uint32_t, RET_osStatus) +SVC_1_1(svcDelay, osStatus, uint32_t, RET_osStatus) #if osFeature_Wait != 0 -SVC_1_3(svcWait, os_InRegs osEvent, uint32_t, RET_osEvent) +SVC_1_3(svcWait, os_InRegs osEvent, uint32_t, RET_osEvent) #endif // Generic Wait Service Calls /// Wait for Timeout (Time Delay) -osStatus svcDelay (uint32_t millisec) { - if (millisec == 0) return osOK; +osStatus svcDelay(uint32_t millisec) { + if (millisec == 0) + return osOK; rt_dly_wait(rt_ms2tick(millisec)); return osEventTimeout; } /// Wait for Signal, Message, Mail, or Timeout #if osFeature_Wait != 0 -os_InRegs osEvent_type svcWait (uint32_t millisec) { +os_InRegs osEvent_type svcWait(uint32_t millisec) { osEvent ret; if (millisec == 0) { @@ -694,24 +687,24 @@ os_InRegs osEvent_type svcWait (uint32_t millisec) { } #endif - // Generic Wait API /// Wait for Timeout (Time Delay) -osStatus osDelay (uint32_t millisec) { - if (__get_CONTROL() == MODE_IRQ) return osErrorISR; // Not allowed in ISR +osStatus osDelay(uint32_t millisec) { + if (__get_CONTROL() == MODE_IRQ) + return osErrorISR; // Not allowed in ISR return __svcDelay(millisec); } /// Wait for Signal, Message, Mail, or Timeout -os_InRegs osEvent osWait (uint32_t millisec) { +os_InRegs osEvent osWait(uint32_t millisec) { osEvent ret; #if osFeature_Wait == 0 ret.status = osErrorOS; return ret; #else - if (__get_CONTROL() == MODE_IRQ) { // Not allowed in ISR + if (__get_CONTROL() == MODE_IRQ) { // Not allowed in ISR ret.status = osErrorISR; return ret; } @@ -719,41 +712,40 @@ os_InRegs osEvent osWait (uint32_t millisec) { #endif } - // ==== Timer Management ==== // Timer definitions -#define osTimerInvalid 0 -#define osTimerStopped 1 -#define osTimerRunning 2 +#define osTimerInvalid 0 +#define osTimerStopped 1 +#define osTimerRunning 2 // Timer structures -typedef struct os_timer_cb_ { // Timer Control Block - struct os_timer_cb_ *next; // Pointer to next active Timer - uint8_t state; // Timer State - uint8_t type; // Timer Type (Periodic/One-shot) - uint16_t reserved; // Reserved - uint16_t tcnt; // Timer Delay Count - uint16_t icnt; // Timer Initial Count - void *arg; // Timer Function Argument - osTimerDef_t *timer; // Pointer to Timer definition +typedef struct os_timer_cb_ { // Timer Control Block + struct os_timer_cb_ *next; // Pointer to next active Timer + uint8_t state; // Timer State + uint8_t type; // Timer Type (Periodic/One-shot) + uint16_t reserved; // Reserved + uint16_t tcnt; // Timer Delay Count + uint16_t icnt; // Timer Initial Count + void *arg; // Timer Function Argument + osTimerDef_t *timer; // Pointer to Timer definition } os_timer_cb; // Timer variables -os_timer_cb *os_timer_head; // Pointer to first active Timer - +os_timer_cb *os_timer_head; // Pointer to first active Timer // Timer Helper Functions // Insert Timer into the list sorted by time -static void rt_timer_insert (os_timer_cb *pt, uint32_t tcnt) { +static void rt_timer_insert(os_timer_cb *pt, uint32_t tcnt) { os_timer_cb *p, *prev; prev = NULL; p = os_timer_head; while (p != NULL) { - if (tcnt < p->tcnt) break; + if (tcnt < p->tcnt) + break; tcnt -= p->tcnt; prev = p; p = p->next; @@ -771,17 +763,19 @@ static void rt_timer_insert (os_timer_cb *pt, uint32_t tcnt) { } // Remove Timer from the list -static int rt_timer_remove (os_timer_cb *pt) { +static int rt_timer_remove(os_timer_cb *pt) { os_timer_cb *p, *prev; prev = NULL; p = os_timer_head; while (p != NULL) { - if (p == pt) break; + if (p == pt) + break; prev = p; p = p->next; } - if (p == NULL) return -1; + if (p == NULL) + return -1; if (prev != NULL) { prev->next = pt->next; } else { @@ -794,18 +788,19 @@ static int rt_timer_remove (os_timer_cb *pt) { return 0; } - // Timer Service Calls declarations -SVC_3_1(svcTimerCreate, osTimerId, osTimerDef_t *, os_timer_type, void *, RET_pointer) -SVC_2_1(svcTimerStart, osStatus, osTimerId, uint32_t, RET_osStatus) -SVC_1_1(svcTimerStop, osStatus, osTimerId, RET_osStatus) -SVC_1_1(svcTimerDelete, osStatus, osTimerId, RET_osStatus) -SVC_1_2(svcTimerCall, os_InRegs osCallback, osTimerId, RET_osCallback) +SVC_3_1(svcTimerCreate, osTimerId, osTimerDef_t *, os_timer_type, void *, + RET_pointer) +SVC_2_1(svcTimerStart, osStatus, osTimerId, uint32_t, RET_osStatus) +SVC_1_1(svcTimerStop, osStatus, osTimerId, RET_osStatus) +SVC_1_1(svcTimerDelete, osStatus, osTimerId, RET_osStatus) +SVC_1_2(svcTimerCall, os_InRegs osCallback, osTimerId, RET_osCallback) // Timer Management Service Calls /// Create timer -osTimerId svcTimerCreate (osTimerDef_t *timer_def, os_timer_type type, void *argument) { +osTimerId svcTimerCreate(osTimerDef_t *timer_def, os_timer_type type, + void *argument) { os_timer_cb *pt; if ((timer_def == NULL) || (timer_def->ptimer == NULL)) { @@ -829,42 +824,44 @@ osTimerId svcTimerCreate (osTimerDef_t *timer_def, os_timer_type type, void *arg return NULL; } - if (pt->state != osTimerInvalid){ + if (pt->state != osTimerInvalid) { sysThreadError(osErrorResource); return NULL; } pt->state = osTimerStopped; - pt->type = (uint8_t)type; - pt->arg = argument; + pt->type = (uint8_t)type; + pt->arg = argument; pt->timer = timer_def; return (osTimerId)pt; } /// Start or restart timer -osStatus svcTimerStart (osTimerId timer_id, uint32_t millisec) { +osStatus svcTimerStart(osTimerId timer_id, uint32_t millisec) { os_timer_cb *pt; - uint32_t tcnt; + uint32_t tcnt; pt = rt_id2obj(timer_id); - if (pt == NULL) return osErrorParameter; + if (pt == NULL) + return osErrorParameter; tcnt = rt_ms2tick(millisec); - if (tcnt == 0) return osErrorValue; + if (tcnt == 0) + return osErrorValue; switch (pt->state) { - case osTimerRunning: - if (rt_timer_remove(pt) != 0) { - return osErrorResource; - } - break; - case osTimerStopped: - pt->state = osTimerRunning; - pt->icnt = (uint16_t)tcnt; - break; - default: + case osTimerRunning: + if (rt_timer_remove(pt) != 0) { return osErrorResource; + } + break; + case osTimerStopped: + pt->state = osTimerRunning; + pt->icnt = (uint16_t)tcnt; + break; + default: + return osErrorResource; } rt_timer_insert(pt, tcnt); @@ -873,13 +870,15 @@ osStatus svcTimerStart (osTimerId timer_id, uint32_t millisec) { } /// Stop timer -osStatus svcTimerStop (osTimerId timer_id) { +osStatus svcTimerStop(osTimerId timer_id) { os_timer_cb *pt; pt = rt_id2obj(timer_id); - if (pt == NULL) return osErrorParameter; + if (pt == NULL) + return osErrorParameter; - if (pt->state != osTimerRunning) return osErrorResource; + if (pt->state != osTimerRunning) + return osErrorResource; pt->state = osTimerStopped; @@ -891,20 +890,21 @@ osStatus svcTimerStop (osTimerId timer_id) { } /// Delete timer -osStatus svcTimerDelete (osTimerId timer_id) { +osStatus svcTimerDelete(osTimerId timer_id) { os_timer_cb *pt; pt = rt_id2obj(timer_id); - if (pt == NULL) return osErrorParameter; + if (pt == NULL) + return osErrorParameter; switch (pt->state) { - case osTimerRunning: - rt_timer_remove(pt); - break; - case osTimerStopped: - break; - default: - return osErrorResource; + case osTimerRunning: + rt_timer_remove(pt); + break; + case osTimerStopped: + break; + default: + return osErrorResource; } pt->state = osTimerInvalid; @@ -913,31 +913,33 @@ osStatus svcTimerDelete (osTimerId timer_id) { } /// Get timer callback parameters -os_InRegs osCallback_type svcTimerCall (osTimerId timer_id) { +os_InRegs osCallback_type svcTimerCall(osTimerId timer_id) { os_timer_cb *pt; - osCallback ret; + osCallback ret; pt = rt_id2obj(timer_id); if (pt == NULL) { - ret.fp = NULL; + ret.fp = NULL; ret.arg = NULL; return osCallback_ret; } - ret.fp = (void *)pt->timer->ptimer; + ret.fp = (void *)pt->timer->ptimer; ret.arg = pt->arg; return osCallback_ret; } -static __INLINE osStatus isrMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec); +static __INLINE osStatus isrMessagePut(osMessageQId queue_id, uint32_t info, + uint32_t millisec); /// Timer Tick (called each SysTick) -void sysTimerTick (void) { +void sysTimerTick(void) { os_timer_cb *pt, *p; p = os_timer_head; - if (p == NULL) return; + if (p == NULL) + return; p->tcnt--; while ((p != NULL) && (p->tcnt == 0)) { @@ -953,49 +955,52 @@ void sysTimerTick (void) { } } - // Timer Management Public API /// Create timer -osTimerId osTimerCreate (osTimerDef_t *timer_def, os_timer_type type, void *argument) { - if (__get_CONTROL() == MODE_IRQ) return NULL; // Not allowed in ISR +osTimerId osTimerCreate(osTimerDef_t *timer_def, os_timer_type type, + void *argument) { + if (__get_CONTROL() == MODE_IRQ) + return NULL; // Not allowed in ISR if ((__get_CONTROL() == MODE_SUPERVISOR) && (os_running == 0)) { // Privileged and not running - return svcTimerCreate(timer_def, type, argument); + return svcTimerCreate(timer_def, type, argument); } else { return __svcTimerCreate(timer_def, type, argument); } } /// Start or restart timer -osStatus osTimerStart (osTimerId timer_id, uint32_t millisec) { - if (__get_CONTROL() == MODE_IRQ) return osErrorISR; // Not allowed in ISR +osStatus osTimerStart(osTimerId timer_id, uint32_t millisec) { + if (__get_CONTROL() == MODE_IRQ) + return osErrorISR; // Not allowed in ISR return __svcTimerStart(timer_id, millisec); } /// Stop timer -osStatus osTimerStop (osTimerId timer_id) { - if (__get_CONTROL() == MODE_IRQ) return osErrorISR; // Not allowed in ISR +osStatus osTimerStop(osTimerId timer_id) { + if (__get_CONTROL() == MODE_IRQ) + return osErrorISR; // Not allowed in ISR return __svcTimerStop(timer_id); } /// Delete timer -osStatus osTimerDelete (osTimerId timer_id) { - if (__get_CONTROL() == MODE_IRQ) return osErrorISR; // Not allowed in ISR +osStatus osTimerDelete(osTimerId timer_id) { + if (__get_CONTROL() == MODE_IRQ) + return osErrorISR; // Not allowed in ISR return __svcTimerDelete(timer_id); } /// INTERNAL - Not Public /// Get timer callback parameters (used by OS Timer Thread) -os_InRegs osCallback osTimerCall (osTimerId timer_id) { +os_InRegs osCallback osTimerCall(osTimerId timer_id) { return __svcTimerCall(timer_id); } - // Timer Thread -__NO_RETURN void osTimerThread (void const *argument) { +__NO_RETURN void osTimerThread(void const *argument) { osCallback cb; - osEvent evt; + osEvent evt; for (;;) { evt = osMessageGet(osMessageQId_osTimerMessageQ, osWaitForever); @@ -1008,75 +1013,80 @@ __NO_RETURN void osTimerThread (void const *argument) { } } - // ==== Signal Management ==== // Signal Service Calls declarations -SVC_2_1(svcSignalSet, int32_t, osThreadId, int32_t, RET_int32_t) -SVC_2_1(svcSignalClear, int32_t, osThreadId, int32_t, RET_int32_t) -SVC_1_1(svcSignalGet, int32_t, osThreadId, RET_int32_t) -SVC_2_3(svcSignalWait, os_InRegs osEvent, int32_t, uint32_t, RET_osEvent) +SVC_2_1(svcSignalSet, int32_t, osThreadId, int32_t, RET_int32_t) +SVC_2_1(svcSignalClear, int32_t, osThreadId, int32_t, RET_int32_t) +SVC_1_1(svcSignalGet, int32_t, osThreadId, RET_int32_t) +SVC_2_3(svcSignalWait, os_InRegs osEvent, int32_t, uint32_t, RET_osEvent) // Signal Service Calls /// Set the specified Signal Flags of an active thread -int32_t svcSignalSet (osThreadId thread_id, int32_t signals) { - P_TCB ptcb; +int32_t svcSignalSet(osThreadId thread_id, int32_t signals) { + P_TCB ptcb; int32_t sig; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return 0x80000000; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return 0x80000000; - if (signals & (0xFFFFFFFF << osFeature_Signals)) return 0x80000000; + if (signals & (0xFFFFFFFF << osFeature_Signals)) + return 0x80000000; - sig = ptcb->events; // Previous signal flags + sig = ptcb->events; // Previous signal flags - rt_evt_set(signals, ptcb->task_id); // Set event flags + rt_evt_set(signals, ptcb->task_id); // Set event flags return sig; } /// Clear the specified Signal Flags of an active thread -int32_t svcSignalClear (osThreadId thread_id, int32_t signals) { - P_TCB ptcb; +int32_t svcSignalClear(osThreadId thread_id, int32_t signals) { + P_TCB ptcb; int32_t sig; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return 0x80000000; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return 0x80000000; - if (signals & (0xFFFFFFFF << osFeature_Signals)) return 0x80000000; + if (signals & (0xFFFFFFFF << osFeature_Signals)) + return 0x80000000; - sig = ptcb->events; // Previous signal flags + sig = ptcb->events; // Previous signal flags - rt_evt_clr(signals, ptcb->task_id); // Clear event flags + rt_evt_clr(signals, ptcb->task_id); // Clear event flags return sig; } /// Get Signal Flags status of an active thread -int32_t svcSignalGet (osThreadId thread_id) { +int32_t svcSignalGet(osThreadId thread_id) { P_TCB ptcb; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return 0x80000000; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return 0x80000000; - return ptcb->events; // Return event flags + return ptcb->events; // Return event flags } -/// Wait for one or more Signal Flags to become signaled for the current RUNNING thread -os_InRegs osEvent_type svcSignalWait (int32_t signals, uint32_t millisec) { +/// Wait for one or more Signal Flags to become signaled for the current RUNNING +/// thread +os_InRegs osEvent_type svcSignalWait(int32_t signals, uint32_t millisec) { OS_RESULT res; - osEvent ret; + osEvent ret; if (signals & (0xFFFFFFFF << osFeature_Signals)) { ret.status = osErrorValue; return osEvent_ret_status; } - if (signals != 0) { // Wait for all specified signals + if (signals != 0) { // Wait for all specified signals res = rt_evt_wait(signals, rt_ms2tick(millisec), __TRUE); - } else { // Wait for any signal - res = rt_evt_wait(0xFFFF, rt_ms2tick(millisec), __FALSE); + } else { // Wait for any signal + res = rt_evt_wait(0xFFFF, rt_ms2tick(millisec), __FALSE); } if (res == OS_R_EVT) { @@ -1090,74 +1100,76 @@ os_InRegs osEvent_type svcSignalWait (int32_t signals, uint32_t millisec) { return osEvent_ret_value; } - // Signal ISR Calls /// Set the specified Signal Flags of an active thread -static __INLINE int32_t isrSignalSet (osThreadId thread_id, int32_t signals) { - P_TCB ptcb; +static __INLINE int32_t isrSignalSet(osThreadId thread_id, int32_t signals) { + P_TCB ptcb; int32_t sig; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return 0x80000000; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return 0x80000000; - if (signals & (0xFFFFFFFF << osFeature_Signals)) return 0x80000000; + if (signals & (0xFFFFFFFF << osFeature_Signals)) + return 0x80000000; - sig = ptcb->events; // Previous signal flags + sig = ptcb->events; // Previous signal flags - isr_evt_set(signals, ptcb->task_id); // Set event flags + isr_evt_set(signals, ptcb->task_id); // Set event flags return sig; } - // Signal Public API /// Set the specified Signal Flags of an active thread -int32_t osSignalSet (osThreadId thread_id, int32_t signals) { - if (__get_CONTROL() == MODE_IRQ) { // in ISR - return isrSignalSet(thread_id, signals); - } else { // in Thread +int32_t osSignalSet(osThreadId thread_id, int32_t signals) { + if (__get_CONTROL() == MODE_IRQ) { // in ISR + return isrSignalSet(thread_id, signals); + } else { // in Thread return __svcSignalSet(thread_id, signals); } } /// Clear the specified Signal Flags of an active thread -int32_t osSignalClear (osThreadId thread_id, int32_t signals) { - if (__get_CONTROL() == MODE_IRQ) return osErrorISR; // Not allowed in ISR +int32_t osSignalClear(osThreadId thread_id, int32_t signals) { + if (__get_CONTROL() == MODE_IRQ) + return osErrorISR; // Not allowed in ISR return __svcSignalClear(thread_id, signals); } /// Get Signal Flags status of an active thread -int32_t osSignalGet (osThreadId thread_id) { - if (__get_CONTROL() == MODE_IRQ) return osErrorISR; // Not allowed in ISR +int32_t osSignalGet(osThreadId thread_id) { + if (__get_CONTROL() == MODE_IRQ) + return osErrorISR; // Not allowed in ISR return __svcSignalGet(thread_id); } -/// Wait for one or more Signal Flags to become signaled for the current RUNNING thread -os_InRegs osEvent osSignalWait (int32_t signals, uint32_t millisec) { +/// Wait for one or more Signal Flags to become signaled for the current RUNNING +/// thread +os_InRegs osEvent osSignalWait(int32_t signals, uint32_t millisec) { osEvent ret; - if (__get_CONTROL() == MODE_IRQ) { // Not allowed in ISR + if (__get_CONTROL() == MODE_IRQ) { // Not allowed in ISR ret.status = osErrorISR; return ret; } return __svcSignalWait(signals, millisec); } - // ==== Mutex Management ==== // Mutex Service Calls declarations -SVC_1_1(svcMutexCreate, osMutexId, osMutexDef_t *, RET_pointer) -SVC_2_1(svcMutexWait, osStatus, osMutexId, uint32_t, RET_osStatus) -SVC_1_1(svcMutexRelease, osStatus, osMutexId, RET_osStatus) -SVC_1_1(svcMutexDelete, osStatus, osMutexId, RET_osStatus) +SVC_1_1(svcMutexCreate, osMutexId, osMutexDef_t *, RET_pointer) +SVC_2_1(svcMutexWait, osStatus, osMutexId, uint32_t, RET_osStatus) +SVC_1_1(svcMutexRelease, osStatus, osMutexId, RET_osStatus) +SVC_1_1(svcMutexDelete, osStatus, osMutexId, RET_osStatus) // Mutex Service Calls /// Create and Initialize a Mutex object -osMutexId svcMutexCreate (osMutexDef_t *mutex_def) { +osMutexId svcMutexCreate(osMutexDef_t *mutex_def) { OS_ID mut; if (mutex_def == NULL) { @@ -1176,20 +1188,22 @@ osMutexId svcMutexCreate (osMutexDef_t *mutex_def) { return NULL; } - rt_mut_init(mut); // Initialize Mutex + rt_mut_init(mut); // Initialize Mutex return mut; } /// Wait until a Mutex becomes available -osStatus svcMutexWait (osMutexId mutex_id, uint32_t millisec) { - OS_ID mut; +osStatus svcMutexWait(osMutexId mutex_id, uint32_t millisec) { + OS_ID mut; OS_RESULT res; mut = rt_id2obj(mutex_id); - if (mut == NULL) return osErrorParameter; + if (mut == NULL) + return osErrorParameter; - if (((P_MUCB)mut)->cb_type != MUCB) return osErrorParameter; + if (((P_MUCB)mut)->cb_type != MUCB) + return osErrorParameter; res = rt_mut_wait(mut, rt_ms2tick(millisec)); // Wait for Mutex @@ -1201,81 +1215,90 @@ osStatus svcMutexWait (osMutexId mutex_id, uint32_t millisec) { } /// Release a Mutex that was obtained with osMutexWait -osStatus svcMutexRelease (osMutexId mutex_id) { - OS_ID mut; +osStatus svcMutexRelease(osMutexId mutex_id) { + OS_ID mut; OS_RESULT res; mut = rt_id2obj(mutex_id); - if (mut == NULL) return osErrorParameter; + if (mut == NULL) + return osErrorParameter; - if (((P_MUCB)mut)->cb_type != MUCB) return osErrorParameter; + if (((P_MUCB)mut)->cb_type != MUCB) + return osErrorParameter; - res = rt_mut_release(mut); // Release Mutex + res = rt_mut_release(mut); // Release Mutex - if (res == OS_R_NOK) return osErrorResource; // Thread not owner or Zero Counter + if (res == OS_R_NOK) + return osErrorResource; // Thread not owner or Zero Counter return osOK; } /// Delete a Mutex that was created by osMutexCreate -osStatus svcMutexDelete (osMutexId mutex_id) { +osStatus svcMutexDelete(osMutexId mutex_id) { OS_ID mut; mut = rt_id2obj(mutex_id); - if (mut == NULL) return osErrorParameter; + if (mut == NULL) + return osErrorParameter; - if (((P_MUCB)mut)->cb_type != MUCB) return osErrorParameter; + if (((P_MUCB)mut)->cb_type != MUCB) + return osErrorParameter; - rt_mut_delete(mut); // Release Mutex + rt_mut_delete(mut); // Release Mutex return osOK; } - // Mutex Public API /// Create and Initialize a Mutex object -osMutexId osMutexCreate (osMutexDef_t *mutex_def) { - if (__get_CONTROL() == MODE_IRQ) return NULL; // Not allowed in ISR +osMutexId osMutexCreate(osMutexDef_t *mutex_def) { + if (__get_CONTROL() == MODE_IRQ) + return NULL; // Not allowed in ISR if ((__get_CONTROL() == MODE_SUPERVISOR) && (os_running == 0)) { // Privileged and not running - return svcMutexCreate(mutex_def); + return svcMutexCreate(mutex_def); } else { return __svcMutexCreate(mutex_def); } } /// Wait until a Mutex becomes available -osStatus osMutexWait (osMutexId mutex_id, uint32_t millisec) { - if (__get_CONTROL() == MODE_IRQ) return osErrorISR; // Not allowed in ISR +osStatus osMutexWait(osMutexId mutex_id, uint32_t millisec) { + if (__get_CONTROL() == MODE_IRQ) + return osErrorISR; // Not allowed in ISR return __svcMutexWait(mutex_id, millisec); } /// Release a Mutex that was obtained with osMutexWait -osStatus osMutexRelease (osMutexId mutex_id) { - if (__get_CONTROL() == MODE_IRQ) return osErrorISR; // Not allowed in ISR +osStatus osMutexRelease(osMutexId mutex_id) { + if (__get_CONTROL() == MODE_IRQ) + return osErrorISR; // Not allowed in ISR return __svcMutexRelease(mutex_id); } /// Delete a Mutex that was created by osMutexCreate -osStatus osMutexDelete (osMutexId mutex_id) { - if (__get_CONTROL() == MODE_IRQ) return osErrorISR; // Not allowed in ISR +osStatus osMutexDelete(osMutexId mutex_id) { + if (__get_CONTROL() == MODE_IRQ) + return osErrorISR; // Not allowed in ISR return __svcMutexDelete(mutex_id); } - // ==== Semaphore Management ==== // Semaphore Service Calls declarations -SVC_2_1(svcSemaphoreCreate, osSemaphoreId, const osSemaphoreDef_t *, int32_t, RET_pointer) -SVC_2_1(svcSemaphoreWait, int32_t, osSemaphoreId, uint32_t, RET_int32_t) -SVC_1_1(svcSemaphoreRelease, osStatus, osSemaphoreId, RET_osStatus) -SVC_1_1(svcSemaphoreDelete, osStatus, osSemaphoreId, RET_osStatus) +SVC_2_1(svcSemaphoreCreate, osSemaphoreId, const osSemaphoreDef_t *, int32_t, + RET_pointer) +SVC_2_1(svcSemaphoreWait, int32_t, osSemaphoreId, uint32_t, RET_int32_t) +SVC_1_1(svcSemaphoreRelease, osStatus, osSemaphoreId, RET_osStatus) +SVC_1_1(svcSemaphoreDelete, osStatus, osSemaphoreId, RET_osStatus) // Semaphore Service Calls /// Create and Initialize a Semaphore object -osSemaphoreId svcSemaphoreCreate (const osSemaphoreDef_t *semaphore_def, int32_t count) { +osSemaphoreId svcSemaphoreCreate(const osSemaphoreDef_t *semaphore_def, + int32_t count) { OS_ID sem; if (semaphore_def == NULL) { @@ -1299,119 +1322,131 @@ osSemaphoreId svcSemaphoreCreate (const osSemaphoreDef_t *semaphore_def, int32_t return NULL; } - rt_sem_init(sem, count); // Initialize Semaphore + rt_sem_init(sem, count); // Initialize Semaphore return sem; } /// Wait until a Semaphore becomes available -int32_t svcSemaphoreWait (osSemaphoreId semaphore_id, uint32_t millisec) { - OS_ID sem; +int32_t svcSemaphoreWait(osSemaphoreId semaphore_id, uint32_t millisec) { + OS_ID sem; OS_RESULT res; sem = rt_id2obj(semaphore_id); - if (sem == NULL) return -1; + if (sem == NULL) + return -1; - if (((P_SCB)sem)->cb_type != SCB) return -1; + if (((P_SCB)sem)->cb_type != SCB) + return -1; res = rt_sem_wait(sem, rt_ms2tick(millisec)); // Wait for Semaphore - if (res == OS_R_TMO) return 0; // Timeout + if (res == OS_R_TMO) + return 0; // Timeout return (((P_SCB)sem)->tokens + 1); } /// Release a Semaphore -osStatus svcSemaphoreRelease (osSemaphoreId semaphore_id) { +osStatus svcSemaphoreRelease(osSemaphoreId semaphore_id) { OS_ID sem; sem = rt_id2obj(semaphore_id); - if (sem == NULL) return osErrorParameter; + if (sem == NULL) + return osErrorParameter; - if (((P_SCB)sem)->cb_type != SCB) return osErrorParameter; + if (((P_SCB)sem)->cb_type != SCB) + return osErrorParameter; - if (((P_SCB)sem)->tokens == osFeature_Semaphore) return osErrorResource; + if (((P_SCB)sem)->tokens == osFeature_Semaphore) + return osErrorResource; - rt_sem_send(sem); // Release Semaphore + rt_sem_send(sem); // Release Semaphore return osOK; } /// Delete a Semaphore that was created by osSemaphoreCreate -osStatus svcSemaphoreDelete (osSemaphoreId semaphore_id) { +osStatus svcSemaphoreDelete(osSemaphoreId semaphore_id) { OS_ID sem; sem = rt_id2obj(semaphore_id); - if (sem == NULL) return osErrorParameter; + if (sem == NULL) + return osErrorParameter; - if (((P_SCB)sem)->cb_type != SCB) return osErrorParameter; + if (((P_SCB)sem)->cb_type != SCB) + return osErrorParameter; - rt_sem_delete(sem); // Delete Semaphore + rt_sem_delete(sem); // Delete Semaphore return osOK; } - // Semaphore ISR Calls /// Release a Semaphore -static __INLINE osStatus isrSemaphoreRelease (osSemaphoreId semaphore_id) { +static __INLINE osStatus isrSemaphoreRelease(osSemaphoreId semaphore_id) { OS_ID sem; sem = rt_id2obj(semaphore_id); - if (sem == NULL) return osErrorParameter; + if (sem == NULL) + return osErrorParameter; - if (((P_SCB)sem)->cb_type != SCB) return osErrorParameter; + if (((P_SCB)sem)->cb_type != SCB) + return osErrorParameter; - if (((P_SCB)sem)->tokens == osFeature_Semaphore) return osErrorResource; + if (((P_SCB)sem)->tokens == osFeature_Semaphore) + return osErrorResource; - isr_sem_send(sem); // Release Semaphore + isr_sem_send(sem); // Release Semaphore return osOK; } - // Semaphore Public API /// Create and Initialize a Semaphore object -osSemaphoreId osSemaphoreCreate (osSemaphoreDef_t *semaphore_def, int32_t count) { - if (__get_CONTROL() == MODE_IRQ) return NULL; // Not allowed in ISR +osSemaphoreId osSemaphoreCreate(osSemaphoreDef_t *semaphore_def, + int32_t count) { + if (__get_CONTROL() == MODE_IRQ) + return NULL; // Not allowed in ISR if ((__get_CONTROL() == MODE_SUPERVISOR) && (os_running == 0)) { // Privileged and not running - return svcSemaphoreCreate(semaphore_def, count); + return svcSemaphoreCreate(semaphore_def, count); } else { return __svcSemaphoreCreate(semaphore_def, count); } } /// Wait until a Semaphore becomes available -int32_t osSemaphoreWait (osSemaphoreId semaphore_id, uint32_t millisec) { - if (__get_CONTROL() == MODE_IRQ) return -1; // Not allowed in ISR +int32_t osSemaphoreWait(osSemaphoreId semaphore_id, uint32_t millisec) { + if (__get_CONTROL() == MODE_IRQ) + return -1; // Not allowed in ISR return __svcSemaphoreWait(semaphore_id, millisec); } /// Release a Semaphore -osStatus osSemaphoreRelease (osSemaphoreId semaphore_id) { - if (__get_CONTROL() == MODE_IRQ) { // in ISR - return isrSemaphoreRelease(semaphore_id); - } else { // in Thread +osStatus osSemaphoreRelease(osSemaphoreId semaphore_id) { + if (__get_CONTROL() == MODE_IRQ) { // in ISR + return isrSemaphoreRelease(semaphore_id); + } else { // in Thread return __svcSemaphoreRelease(semaphore_id); } } /// Delete a Semaphore that was created by osSemaphoreCreate -osStatus osSemaphoreDelete (osSemaphoreId semaphore_id) { - if (__get_CONTROL() == MODE_IRQ) return osErrorISR; // Not allowed in ISR +osStatus osSemaphoreDelete(osSemaphoreId semaphore_id) { + if (__get_CONTROL() == MODE_IRQ) + return osErrorISR; // Not allowed in ISR return __svcSemaphoreDelete(semaphore_id); } - // ==== Memory Management Functions ==== // Memory Management Helper Functions // Clear Memory Box (Zero init) -static void rt_clr_box (void *box_mem, void *box) { +static void rt_clr_box(void *box_mem, void *box) { uint32_t *p, n; if (box) { @@ -1423,36 +1458,36 @@ static void rt_clr_box (void *box_mem, void *box) { } // Memory Management Service Calls declarations -SVC_1_1(svcPoolCreate, osPoolId, const osPoolDef_t *, RET_pointer) -SVC_2_1(sysPoolAlloc, void *, osPoolId, uint32_t, RET_pointer) -SVC_2_1(sysPoolFree, osStatus, osPoolId, void *, RET_osStatus) +SVC_1_1(svcPoolCreate, osPoolId, const osPoolDef_t *, RET_pointer) +SVC_2_1(sysPoolAlloc, void *, osPoolId, uint32_t, RET_pointer) +SVC_2_1(sysPoolFree, osStatus, osPoolId, void *, RET_osStatus) // Memory Management Service & ISR Calls /// Create and Initialize memory pool -osPoolId svcPoolCreate (const osPoolDef_t *pool_def) { +osPoolId svcPoolCreate(const osPoolDef_t *pool_def) { uint32_t blk_sz; - if ((pool_def == NULL) || - (pool_def->pool_sz == 0) || - (pool_def->item_sz == 0) || - (pool_def->pool == NULL)) { + if ((pool_def == NULL) || (pool_def->pool_sz == 0) || + (pool_def->item_sz == 0) || (pool_def->pool == NULL)) { sysThreadError(osErrorParameter); return NULL; } blk_sz = (pool_def->item_sz + 3) & ~3; - _init_box(pool_def->pool, sizeof(struct OS_BM) + pool_def->pool_sz * blk_sz, blk_sz); + _init_box(pool_def->pool, sizeof(struct OS_BM) + pool_def->pool_sz * blk_sz, + blk_sz); return pool_def->pool; } /// Allocate a memory block from a memory pool -void *sysPoolAlloc (osPoolId pool_id, uint32_t clr) { +void *sysPoolAlloc(osPoolId pool_id, uint32_t clr) { void *ptr; - if (pool_id == NULL) return NULL; + if (pool_id == NULL) + return NULL; ptr = rt_alloc_box(pool_id); if (clr) { @@ -1463,73 +1498,78 @@ void *sysPoolAlloc (osPoolId pool_id, uint32_t clr) { } /// Return an allocated memory block back to a specific memory pool -osStatus sysPoolFree (osPoolId pool_id, void *block) { +osStatus sysPoolFree(osPoolId pool_id, void *block) { int32_t res; - if (pool_id == NULL) return osErrorParameter; + if (pool_id == NULL) + return osErrorParameter; res = rt_free_box(pool_id, block); - if (res != 0) return osErrorValue; + if (res != 0) + return osErrorValue; return osOK; } - // Memory Management Public API /// Create and Initialize memory pool -osPoolId osPoolCreate (osPoolDef_t *pool_def) { - if (__get_CONTROL() == MODE_IRQ) return NULL; // Not allowed in ISR +osPoolId osPoolCreate(osPoolDef_t *pool_def) { + if (__get_CONTROL() == MODE_IRQ) + return NULL; // Not allowed in ISR if ((__get_CONTROL() == MODE_SUPERVISOR) && (os_running == 0)) { // Privileged and not running - return svcPoolCreate(pool_def); + return svcPoolCreate(pool_def); } else { return __svcPoolCreate(pool_def); } } /// Allocate a memory block from a memory pool -void *osPoolAlloc (osPoolId pool_id) { - if ((__get_CONTROL() == MODE_IRQ) || (__get_CONTROL() == MODE_SUPERVISOR)) { // in ISR or Privileged - return sysPoolAlloc(pool_id, 0); - } else { // in Thread +void *osPoolAlloc(osPoolId pool_id) { + if ((__get_CONTROL() == MODE_IRQ) || + (__get_CONTROL() == MODE_SUPERVISOR)) { // in ISR or Privileged + return sysPoolAlloc(pool_id, 0); + } else { // in Thread return __sysPoolAlloc(pool_id, 0); } } /// Allocate a memory block from a memory pool and set memory block to zero -void *osPoolCAlloc (osPoolId pool_id) { - if ((__get_CONTROL() == MODE_IRQ) || (__get_CONTROL() == MODE_SUPERVISOR)) { // in ISR or Privileged - return sysPoolAlloc(pool_id, 1); - } else { // in Thread +void *osPoolCAlloc(osPoolId pool_id) { + if ((__get_CONTROL() == MODE_IRQ) || + (__get_CONTROL() == MODE_SUPERVISOR)) { // in ISR or Privileged + return sysPoolAlloc(pool_id, 1); + } else { // in Thread return __sysPoolAlloc(pool_id, 1); } } /// Return an allocated memory block back to a specific memory pool -osStatus osPoolFree (osPoolId pool_id, void *block) { - if ((__get_CONTROL() == MODE_IRQ) || (__get_CONTROL() == MODE_SUPERVISOR)) { // in ISR or Privileged - return sysPoolFree(pool_id, block); - } else { // in Thread +osStatus osPoolFree(osPoolId pool_id, void *block) { + if ((__get_CONTROL() == MODE_IRQ) || + (__get_CONTROL() == MODE_SUPERVISOR)) { // in ISR or Privileged + return sysPoolFree(pool_id, block); + } else { // in Thread return __sysPoolFree(pool_id, block); } } - // ==== Message Queue Management Functions ==== // Message Queue Management Service Calls declarations -SVC_2_1(svcMessageCreate, osMessageQId, osMessageQDef_t *, osThreadId, RET_pointer) -SVC_3_1(svcMessagePut, osStatus, osMessageQId, uint32_t, uint32_t, RET_osStatus) -SVC_2_3(svcMessageGet, os_InRegs osEvent, osMessageQId, uint32_t, RET_osEvent) +SVC_2_1(svcMessageCreate, osMessageQId, osMessageQDef_t *, osThreadId, + RET_pointer) +SVC_3_1(svcMessagePut, osStatus, osMessageQId, uint32_t, uint32_t, RET_osStatus) +SVC_2_3(svcMessageGet, os_InRegs osEvent, osMessageQId, uint32_t, RET_osEvent) // Message Queue Service Calls /// Create and Initialize Message Queue -osMessageQId svcMessageCreate (osMessageQDef_t *queue_def, osThreadId thread_id) { +osMessageQId svcMessageCreate(osMessageQDef_t *queue_def, + osThreadId thread_id) { - if ((queue_def == NULL) || - (queue_def->queue_sz == 0) || + if ((queue_def == NULL) || (queue_def->queue_sz == 0) || (queue_def->pool == NULL)) { sysThreadError(osErrorParameter); return NULL; @@ -1540,18 +1580,21 @@ osMessageQId svcMessageCreate (osMessageQDef_t *queue_def, osThreadId thread_id) return NULL; } - rt_mbx_init(queue_def->pool, 4*(queue_def->queue_sz + 4)); + rt_mbx_init(queue_def->pool, 4 * (queue_def->queue_sz + 4)); return queue_def->pool; } /// Put a Message to a Queue -osStatus svcMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec) { +osStatus svcMessagePut(osMessageQId queue_id, uint32_t info, + uint32_t millisec) { OS_RESULT res; - if (queue_id == NULL) return osErrorParameter; + if (queue_id == NULL) + return osErrorParameter; - if (((P_MCB)queue_id)->cb_type != MCB) return osErrorParameter; + if (((P_MCB)queue_id)->cb_type != MCB) + return osErrorParameter; res = rt_mbx_send(queue_id, (void *)info, rt_ms2tick(millisec)); @@ -1563,9 +1606,9 @@ osStatus svcMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec) } /// Get a Message or Wait for a Message from a Queue -os_InRegs osEvent_type svcMessageGet (osMessageQId queue_id, uint32_t millisec) { +os_InRegs osEvent_type svcMessageGet(osMessageQId queue_id, uint32_t millisec) { OS_RESULT res; - osEvent ret; + osEvent ret; if (queue_id == NULL) { ret.status = osErrorParameter; @@ -1589,19 +1632,20 @@ os_InRegs osEvent_type svcMessageGet (osMessageQId queue_id, uint32_t millisec) return osEvent_ret_value; } - // Message Queue ISR Calls /// Put a Message to a Queue -static __INLINE osStatus isrMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec) { +static __INLINE osStatus isrMessagePut(osMessageQId queue_id, uint32_t info, + uint32_t millisec) { if ((queue_id == NULL) || (millisec != 0)) { return osErrorParameter; } - if (((P_MCB)queue_id)->cb_type != MCB) return osErrorParameter; + if (((P_MCB)queue_id)->cb_type != MCB) + return osErrorParameter; - if (rt_mbx_check(queue_id) == 0) { // Check if Queue is full + if (rt_mbx_check(queue_id) == 0) { // Check if Queue is full return osErrorResource; } @@ -1611,9 +1655,10 @@ static __INLINE osStatus isrMessagePut (osMessageQId queue_id, uint32_t info, ui } /// Get a Message or Wait for a Message from a Queue -static __INLINE os_InRegs osEvent isrMessageGet (osMessageQId queue_id, uint32_t millisec) { +static __INLINE os_InRegs osEvent isrMessageGet(osMessageQId queue_id, + uint32_t millisec) { OS_RESULT res; - osEvent ret; + osEvent ret; if ((queue_id == NULL) || (millisec != 0)) { ret.status = osErrorParameter; @@ -1637,58 +1682,56 @@ static __INLINE os_InRegs osEvent isrMessageGet (osMessageQId queue_id, uint32_t return ret; } - // Message Queue Management Public API /// Create and Initialize Message Queue -osMessageQId osMessageCreate (osMessageQDef_t *queue_def, osThreadId thread_id) { - if (__get_CONTROL() == MODE_IRQ) return NULL; // Not allowed in ISR +osMessageQId osMessageCreate(osMessageQDef_t *queue_def, osThreadId thread_id) { + if (__get_CONTROL() == MODE_IRQ) + return NULL; // Not allowed in ISR if ((__get_CONTROL() == MODE_SUPERVISOR) && (os_running == 0)) { // Privileged and not running - return svcMessageCreate(queue_def, thread_id); + return svcMessageCreate(queue_def, thread_id); } else { return __svcMessageCreate(queue_def, thread_id); } } /// Put a Message to a Queue -osStatus osMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec) { - if (__get_CONTROL() == MODE_IRQ) { // in ISR - return isrMessagePut(queue_id, info, millisec); - } else { // in Thread +osStatus osMessagePut(osMessageQId queue_id, uint32_t info, uint32_t millisec) { + if (__get_CONTROL() == MODE_IRQ) { // in ISR + return isrMessagePut(queue_id, info, millisec); + } else { // in Thread return __svcMessagePut(queue_id, info, millisec); } } /// Get a Message or Wait for a Message from a Queue -os_InRegs osEvent osMessageGet (osMessageQId queue_id, uint32_t millisec) { - if (__get_CONTROL() == MODE_IRQ) { // in ISR - return isrMessageGet(queue_id, millisec); - } else { // in Thread +os_InRegs osEvent osMessageGet(osMessageQId queue_id, uint32_t millisec) { + if (__get_CONTROL() == MODE_IRQ) { // in ISR + return isrMessageGet(queue_id, millisec); + } else { // in Thread return __svcMessageGet(queue_id, millisec); } } - // ==== Mail Queue Management Functions ==== // Mail Queue Management Service Calls declarations -SVC_2_1(svcMailCreate, osMailQId, osMailQDef_t *, osThreadId, RET_pointer) -SVC_4_1(sysMailAlloc, void *, osMailQId, uint32_t, uint32_t, uint32_t, RET_pointer) -SVC_3_1(sysMailFree, osStatus, osMailQId, void *, uint32_t, RET_osStatus) +SVC_2_1(svcMailCreate, osMailQId, osMailQDef_t *, osThreadId, RET_pointer) +SVC_4_1(sysMailAlloc, void *, osMailQId, uint32_t, uint32_t, uint32_t, + RET_pointer) +SVC_3_1(sysMailFree, osStatus, osMailQId, void *, uint32_t, RET_osStatus) // Mail Queue Management Service & ISR Calls /// Create and Initialize mail queue -osMailQId svcMailCreate (osMailQDef_t *queue_def, osThreadId thread_id) { +osMailQId svcMailCreate(osMailQDef_t *queue_def, osThreadId thread_id) { uint32_t blk_sz; - P_MCB pmcb; - void *pool; + P_MCB pmcb; + void *pool; - if ((queue_def == NULL) || - (queue_def->queue_sz == 0) || - (queue_def->item_sz == 0) || - (queue_def->pool == NULL)) { + if ((queue_def == NULL) || (queue_def->queue_sz == 0) || + (queue_def->item_sz == 0) || (queue_def->pool == NULL)) { sysThreadError(osErrorParameter); return NULL; } @@ -1705,26 +1748,29 @@ osMailQId svcMailCreate (osMailQDef_t *queue_def, osThreadId thread_id) { _init_box(pool, sizeof(struct OS_BM) + queue_def->queue_sz * blk_sz, blk_sz); - rt_mbx_init(pmcb, 4*(queue_def->queue_sz + 4)); - + rt_mbx_init(pmcb, 4 * (queue_def->queue_sz + 4)); return queue_def->pool; } /// Allocate a memory block from a mail -void *sysMailAlloc (osMailQId queue_id, uint32_t millisec, uint32_t isr, uint32_t clr) { +void *sysMailAlloc(osMailQId queue_id, uint32_t millisec, uint32_t isr, + uint32_t clr) { P_MCB pmcb; void *pool; void *mem; - if (queue_id == NULL) return NULL; + if (queue_id == NULL) + return NULL; pmcb = *(((void **)queue_id) + 0); pool = *(((void **)queue_id) + 1); - if ((pool == NULL) || (pmcb == NULL)) return NULL; + if ((pool == NULL) || (pmcb == NULL)) + return NULL; - if (isr && (millisec != 0)) return NULL; + if (isr && (millisec != 0)) + return NULL; mem = rt_alloc_box(pool); if (clr) { @@ -1749,29 +1795,32 @@ void *sysMailAlloc (osMailQId queue_id, uint32_t millisec, uint32_t isr, uint32_ } /// Free a memory block from a mail -osStatus sysMailFree (osMailQId queue_id, void *mail, uint32_t isr) { - P_MCB pmcb; - P_TCB ptcb; - void *pool; - void *mem; +osStatus sysMailFree(osMailQId queue_id, void *mail, uint32_t isr) { + P_MCB pmcb; + P_TCB ptcb; + void *pool; + void *mem; int32_t res; - if (queue_id == NULL) return osErrorParameter; + if (queue_id == NULL) + return osErrorParameter; pmcb = *(((void **)queue_id) + 0); pool = *(((void **)queue_id) + 1); - if ((pmcb == NULL) || (pool == NULL)) return osErrorParameter; + if ((pmcb == NULL) || (pool == NULL)) + return osErrorParameter; res = rt_free_box(pool, mail); - if (res != 0) return osErrorValue; + if (res != 0) + return osErrorValue; if (pmcb->state == 3) { // Task is waiting to allocate a message if (isr) { - rt_psq_enq (pmcb, (U32)pool); - rt_psh_req (); + rt_psq_enq(pmcb, (U32)pool); + rt_psh_req(); } else { mem = rt_alloc_box(pool); if (mem != NULL) { @@ -1789,56 +1838,58 @@ osStatus sysMailFree (osMailQId queue_id, void *mail, uint32_t isr) { return osOK; } - // Mail Queue Management Public API /// Create and Initialize mail queue -osMailQId osMailCreate (osMailQDef_t *queue_def, osThreadId thread_id) { - if (__get_CONTROL() == MODE_IRQ) return NULL; // Not allowed in ISR +osMailQId osMailCreate(osMailQDef_t *queue_def, osThreadId thread_id) { + if (__get_CONTROL() == MODE_IRQ) + return NULL; // Not allowed in ISR if ((__get_CONTROL() == MODE_SUPERVISOR) && (os_running == 0)) { // Privileged and not running - return svcMailCreate(queue_def, thread_id); + return svcMailCreate(queue_def, thread_id); } else { return __svcMailCreate(queue_def, thread_id); } } /// Allocate a memory block from a mail -void *osMailAlloc (osMailQId queue_id, uint32_t millisec) { - if (__get_CONTROL() == MODE_IRQ) { // in ISR - return sysMailAlloc(queue_id, millisec, 1, 0); - } else { // in Thread +void *osMailAlloc(osMailQId queue_id, uint32_t millisec) { + if (__get_CONTROL() == MODE_IRQ) { // in ISR + return sysMailAlloc(queue_id, millisec, 1, 0); + } else { // in Thread return __sysMailAlloc(queue_id, millisec, 0, 0); } } /// Allocate a memory block from a mail and set memory block to zero -void *osMailCAlloc (osMailQId queue_id, uint32_t millisec) { - if (__get_CONTROL() == MODE_IRQ) { // in ISR - return sysMailAlloc(queue_id, millisec, 1, 1); - } else { // in Thread +void *osMailCAlloc(osMailQId queue_id, uint32_t millisec) { + if (__get_CONTROL() == MODE_IRQ) { // in ISR + return sysMailAlloc(queue_id, millisec, 1, 1); + } else { // in Thread return __sysMailAlloc(queue_id, millisec, 0, 1); } } /// Free a memory block from a mail -osStatus osMailFree (osMailQId queue_id, void *mail) { - if (__get_CONTROL() == MODE_IRQ) { // in ISR - return sysMailFree(queue_id, mail, 1); - } else { // in Thread +osStatus osMailFree(osMailQId queue_id, void *mail) { + if (__get_CONTROL() == MODE_IRQ) { // in ISR + return sysMailFree(queue_id, mail, 1); + } else { // in Thread return __sysMailFree(queue_id, mail, 0); } } /// Put a mail to a queue -osStatus osMailPut (osMailQId queue_id, void *mail) { - if (queue_id == NULL) return osErrorParameter; - if (mail == NULL) return osErrorValue; +osStatus osMailPut(osMailQId queue_id, void *mail) { + if (queue_id == NULL) + return osErrorParameter; + if (mail == NULL) + return osErrorValue; return osMessagePut(*((void **)queue_id), (uint32_t)mail, 0); } /// Get a mail from a queue -os_InRegs osEvent osMailGet (osMailQId queue_id, uint32_t millisec) { +os_InRegs osEvent osMailGet(osMailQId queue_id, uint32_t millisec) { osEvent ret; if (queue_id == NULL) { @@ -1847,7 +1898,8 @@ os_InRegs osEvent osMailGet (osMailQId queue_id, uint32_t millisec) { } ret = osMessageGet(*((void **)queue_id), millisec); - if (ret.status == osEventMessage) ret.status = osEventMail; + if (ret.status == osEventMessage) + ret.status = osEventMail; return ret; } diff --git a/rtos/rtx/TARGET_ARM7/rt_Event.c b/rtos/rtx/TARGET_ARM7/rt_Event.c index 871e4b0..31058e2 100644 --- a/rtos/rtx/TARGET_ARM7/rt_Event.c +++ b/rtos/rtx/TARGET_ARM7/rt_Event.c @@ -32,23 +32,21 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" -#include "RTX_Conf.h" -#include "rt_System.h" #include "rt_Event.h" -#include "rt_List.h" -#include "rt_Task.h" +#include "RTX_Conf.h" #include "rt_HAL_CM.h" - +#include "rt_List.h" +#include "rt_System.h" +#include "rt_Task.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_evt_wait -----------------------------------*/ -OS_RESULT rt_evt_wait (U16 wait_flags, U16 timeout, BOOL and_wait) { +OS_RESULT rt_evt_wait(U16 wait_flags, U16 timeout, BOOL and_wait) { /* Wait for one or more event flags with optional time-out. */ /* "wait_flags" identifies the flags to wait for. */ /* "timeout" is the time-out limit in system ticks (0xffff if no time-out) */ @@ -63,8 +61,7 @@ OS_RESULT rt_evt_wait (U16 wait_flags, U16 timeout, BOOL and_wait) { return (OS_R_EVT); } block_state = WAIT_AND; - } - else { + } else { /* Check for OR-connected events */ if (os_tsk.run->events & wait_flags) { os_tsk.run->waits = os_tsk.run->events & wait_flags; @@ -75,23 +72,22 @@ OS_RESULT rt_evt_wait (U16 wait_flags, U16 timeout, BOOL and_wait) { } /* Task has to wait */ os_tsk.run->waits = wait_flags; - rt_block (timeout, (U8)block_state); + rt_block(timeout, (U8)block_state); return (OS_R_TMO); } - /*--------------------------- rt_evt_set ------------------------------------*/ -void rt_evt_set (U16 event_flags, OS_TID task_id) { +void rt_evt_set(U16 event_flags, OS_TID task_id) { /* Set one or more event flags of a selectable task. */ P_TCB p_tcb; - p_tcb = os_active_TCB[task_id-1]; + p_tcb = os_active_TCB[task_id - 1]; if (p_tcb == NULL) { return; } p_tcb->events |= event_flags; - event_flags = p_tcb->waits; + event_flags = p_tcb->waits; /* If the task is not waiting for an event, it should not be put */ /* to ready state. */ if (p_tcb->state == WAIT_AND) { @@ -103,27 +99,27 @@ void rt_evt_set (U16 event_flags, OS_TID task_id) { if (p_tcb->state == WAIT_OR) { /* Check for OR-connected events */ if (p_tcb->events & event_flags) { - p_tcb->waits &= p_tcb->events; -wkup: p_tcb->events &= ~event_flags; - rt_rmv_dly (p_tcb); - p_tcb->state = READY; + p_tcb->waits &= p_tcb->events; + wkup: + p_tcb->events &= ~event_flags; + rt_rmv_dly(p_tcb); + p_tcb->state = READY; #ifdef __CMSIS_RTOS - rt_ret_val2(p_tcb, 0x08/*osEventSignal*/, p_tcb->waits); + rt_ret_val2(p_tcb, 0x08 /*osEventSignal*/, p_tcb->waits); #else - rt_ret_val (p_tcb, OS_R_EVT); + rt_ret_val(p_tcb, OS_R_EVT); #endif - rt_dispatch (p_tcb); + rt_dispatch(p_tcb); } } } - /*--------------------------- rt_evt_clr ------------------------------------*/ -void rt_evt_clr (U16 clear_flags, OS_TID task_id) { +void rt_evt_clr(U16 clear_flags, OS_TID task_id) { /* Clear one or more event flags (identified by "clear_flags") of a */ /* selectable task (identified by "task"). */ - P_TCB task = os_active_TCB[task_id-1]; + P_TCB task = os_active_TCB[task_id - 1]; if (task == NULL) { return; @@ -131,32 +127,29 @@ void rt_evt_clr (U16 clear_flags, OS_TID task_id) { task->events &= ~clear_flags; } - /*--------------------------- isr_evt_set -----------------------------------*/ -void isr_evt_set (U16 event_flags, OS_TID task_id) { +void isr_evt_set(U16 event_flags, OS_TID task_id) { /* Same function as "os_evt_set", but to be called by ISRs. */ - P_TCB p_tcb = os_active_TCB[task_id-1]; + P_TCB p_tcb = os_active_TCB[task_id - 1]; if (p_tcb == NULL) { return; } - rt_psq_enq (p_tcb, event_flags); - rt_psh_req (); + rt_psq_enq(p_tcb, event_flags); + rt_psh_req(); } - /*--------------------------- rt_evt_get ------------------------------------*/ -U16 rt_evt_get (void) { +U16 rt_evt_get(void) { /* Get events of a running task after waiting for OR connected events. */ return (os_tsk.run->waits); } - /*--------------------------- rt_evt_psh ------------------------------------*/ -void rt_evt_psh (P_TCB p_CB, U16 set_flags) { +void rt_evt_psh(P_TCB p_CB, U16 set_flags) { /* Check if task has to be waken up */ U16 event_flags; @@ -171,16 +164,17 @@ void rt_evt_psh (P_TCB p_CB, U16 set_flags) { if (p_CB->state == WAIT_OR) { /* Check for OR-connected events */ if (p_CB->events & event_flags) { - p_CB->waits &= p_CB->events; -rdy: p_CB->events &= ~event_flags; - rt_rmv_dly (p_CB); - p_CB->state = READY; + p_CB->waits &= p_CB->events; + rdy: + p_CB->events &= ~event_flags; + rt_rmv_dly(p_CB); + p_CB->state = READY; #ifdef __CMSIS_RTOS - rt_ret_val2(p_CB, 0x08/*osEventSignal*/, p_CB->waits); + rt_ret_val2(p_CB, 0x08 /*osEventSignal*/, p_CB->waits); #else - rt_ret_val (p_CB, OS_R_EVT); + rt_ret_val(p_CB, OS_R_EVT); #endif - rt_put_prio (&os_rdy, p_CB); + rt_put_prio(&os_rdy, p_CB); } } } diff --git a/rtos/rtx/TARGET_ARM7/rt_List.c b/rtos/rtx/TARGET_ARM7/rt_List.c index 06b5a89..835f835 100644 --- a/rtos/rtx/TARGET_ARM7/rt_List.c +++ b/rtos/rtx/TARGET_ARM7/rt_List.c @@ -32,32 +32,30 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" -#include "RTX_Conf.h" -#include "rt_System.h" #include "rt_List.h" +#include "RTX_Conf.h" +#include "rt_HAL_CM.h" +#include "rt_System.h" #include "rt_Task.h" #include "rt_Time.h" -#include "rt_HAL_CM.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Global Variables *---------------------------------------------------------------------------*/ /* List head of chained ready tasks */ -struct OS_XCB os_rdy; +struct OS_XCB os_rdy; /* List head of chained delay tasks */ -struct OS_XCB os_dly; - +struct OS_XCB os_dly; /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_put_prio -----------------------------------*/ -void rt_put_prio (P_XCB p_CB, P_TCB p_task) { +void rt_put_prio(P_XCB p_CB, P_TCB p_task) { /* Put task identified with "p_task" into list ordered by priority. */ /* "p_CB" points to head of list; list has always an element at end with */ /* a priority less than "p_task->prio". */ @@ -83,16 +81,14 @@ void rt_put_prio (P_XCB p_CB, P_TCB p_task) { p_CB2->p_rlnk = p_task; } p_task->p_rlnk = (P_TCB)p_CB; - } - else { + } else { p_task->p_rlnk = NULL; } } - /*--------------------------- rt_get_first ----------------------------------*/ -P_TCB rt_get_first (P_XCB p_CB) { +P_TCB rt_get_first(P_XCB p_CB) { /* Get task at head of list: it is the task with highest priority. */ /* "p_CB" points to head of list. */ P_TCB p_first; @@ -105,17 +101,15 @@ P_TCB rt_get_first (P_XCB p_CB) { p_first->p_lnk = NULL; } p_first->p_rlnk = NULL; - } - else { + } else { p_first->p_lnk = NULL; } return (p_first); } - /*--------------------------- rt_put_rdy_first ------------------------------*/ -void rt_put_rdy_first (P_TCB p_task) { +void rt_put_rdy_first(P_TCB p_task) { /* Put task identified with "p_task" at the head of the ready list. The */ /* task must have at least a priority equal to highest priority in list. */ p_task->p_lnk = os_rdy.p_lnk; @@ -123,10 +117,9 @@ void rt_put_rdy_first (P_TCB p_task) { os_rdy.p_lnk = p_task; } - /*--------------------------- rt_get_same_rdy_prio --------------------------*/ -P_TCB rt_get_same_rdy_prio (void) { +P_TCB rt_get_same_rdy_prio(void) { /* Remove a task of same priority from ready list if any exists. Other- */ /* wise return NULL. */ P_TCB p_first; @@ -139,10 +132,9 @@ P_TCB rt_get_same_rdy_prio (void) { return (NULL); } - /*--------------------------- rt_resort_prio --------------------------------*/ -void rt_resort_prio (P_TCB p_task) { +void rt_resort_prio(P_TCB p_task) { /* Re-sort ordered lists after the priority of 'p_task' has changed. */ P_TCB p_CB; @@ -152,26 +144,25 @@ void rt_resort_prio (P_TCB p_task) { p_CB = (P_TCB)&os_rdy; goto res; } - } - else { + } else { p_CB = p_task->p_rlnk; while (p_CB->cb_type == TCB) { /* Find a header of this task chain list. */ p_CB = p_CB->p_rlnk; } -res:rt_rmv_list (p_task); - rt_put_prio ((P_XCB)p_CB, p_task); + res: + rt_rmv_list(p_task); + rt_put_prio((P_XCB)p_CB, p_task); } } - /*--------------------------- rt_put_dly ------------------------------------*/ -void rt_put_dly (P_TCB p_task, U16 delay) { +void rt_put_dly(P_TCB p_task, U16 delay) { /* Put a task identified with "p_task" into chained delay wait list using */ /* a delay value of "delay". */ P_TCB p; - U32 delta,idelay = delay; + U32 delta, idelay = delay; p = (P_TCB)&os_dly; if (p->p_dlnk == NULL) { @@ -183,7 +174,8 @@ void rt_put_dly (P_TCB p_task, U16 delay) { while (delta < idelay) { if (p->p_dlnk == NULL) { /* End of list found */ -last: p_task->p_dlnk = NULL; + last: + p_task->p_dlnk = NULL; p->p_dlnk = p_task; p_task->p_blnk = p; p->delta_time = (U16)(idelay - delta); @@ -204,10 +196,9 @@ last: p_task->p_dlnk = NULL; p->delta_time -= p_task->delta_time; } - /*--------------------------- rt_dec_dly ------------------------------------*/ -void rt_dec_dly (void) { +void rt_dec_dly(void) { /* Decrement delta time of list head: remove tasks having a value of zero.*/ P_TCB p_rdy; @@ -227,26 +218,25 @@ void rt_dec_dly (void) { } p_rdy->p_rlnk = NULL; } - rt_put_prio (&os_rdy, p_rdy); + rt_put_prio(&os_rdy, p_rdy); os_dly.delta_time = p_rdy->delta_time; if (p_rdy->state == WAIT_ITV) { /* Calculate the next time for interval wait. */ p_rdy->delta_time = p_rdy->interval_time + (U16)os_time; } - p_rdy->state = READY; + p_rdy->state = READY; os_dly.p_dlnk = p_rdy->p_dlnk; if (p_rdy->p_dlnk != NULL) { - p_rdy->p_dlnk->p_blnk = (P_TCB)&os_dly; + p_rdy->p_dlnk->p_blnk = (P_TCB)&os_dly; p_rdy->p_dlnk = NULL; } p_rdy->p_blnk = NULL; } } - /*--------------------------- rt_rmv_list -----------------------------------*/ -void rt_rmv_list (P_TCB p_task) { +void rt_rmv_list(P_TCB p_task) { /* Remove task identified with "p_task" from ready, semaphore or mailbox */ /* waiting list if enqueued. */ P_TCB p_b; @@ -271,10 +261,9 @@ void rt_rmv_list (P_TCB p_task) { } } - /*--------------------------- rt_rmv_dly ------------------------------------*/ -void rt_rmv_dly (P_TCB p_task) { +void rt_rmv_dly(P_TCB p_task) { /* Remove task identified with "p_task" from delay list if enqueued. */ P_TCB p_b; @@ -287,8 +276,7 @@ void rt_rmv_dly (P_TCB p_task) { p_b->delta_time += p_task->delta_time; p_task->p_dlnk->p_blnk = p_b; p_task->p_dlnk = NULL; - } - else { + } else { /* 'p_task' is at the end of list */ p_b->delta_time = 0; } @@ -296,25 +284,21 @@ void rt_rmv_dly (P_TCB p_task) { } } - /*--------------------------- rt_psq_enq ------------------------------------*/ -void rt_psq_enq (OS_ID entry, U32 arg) { +void rt_psq_enq(OS_ID entry, U32 arg) { /* Insert post service request "entry" into ps-queue. */ U32 idx; - idx = rt_inc_qi (os_psq->size, &os_psq->count, &os_psq->first); + idx = rt_inc_qi(os_psq->size, &os_psq->count, &os_psq->first); if (idx < os_psq->size) { - os_psq->q[idx].id = entry; + os_psq->q[idx].id = entry; os_psq->q[idx].arg = arg; - } - else { - os_error (OS_ERR_FIFO_OVF); + } else { + os_error(OS_ERR_FIFO_OVF); } } - /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_ARM7/rt_Mailbox.c b/rtos/rtx/TARGET_ARM7/rt_Mailbox.c index b351bd1..b17c522 100644 --- a/rtos/rtx/TARGET_ARM7/rt_Mailbox.c +++ b/rtos/rtx/TARGET_ARM7/rt_Mailbox.c @@ -32,59 +32,55 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" -#include "RTX_Conf.h" -#include "rt_System.h" -#include "rt_List.h" #include "rt_Mailbox.h" -#include "rt_MemBox.h" -#include "rt_Task.h" +#include "RTX_Conf.h" #include "rt_HAL_CM.h" - +#include "rt_List.h" +#include "rt_MemBox.h" +#include "rt_System.h" +#include "rt_Task.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_mbx_init -----------------------------------*/ -void rt_mbx_init (OS_ID mailbox, U16 mbx_size) { +void rt_mbx_init(OS_ID mailbox, U16 mbx_size) { /* Initialize a mailbox */ P_MCB p_MCB = mailbox; p_MCB->cb_type = MCB; - p_MCB->state = 0; - p_MCB->isr_st = 0; - p_MCB->p_lnk = NULL; - p_MCB->first = 0; - p_MCB->last = 0; - p_MCB->count = 0; - p_MCB->size = (mbx_size + sizeof(void *) - sizeof(struct OS_MCB)) / - (U32)sizeof (void *); + p_MCB->state = 0; + p_MCB->isr_st = 0; + p_MCB->p_lnk = NULL; + p_MCB->first = 0; + p_MCB->last = 0; + p_MCB->count = 0; + p_MCB->size = + (mbx_size + sizeof(void *) - sizeof(struct OS_MCB)) / (U32)sizeof(void *); } - /*--------------------------- rt_mbx_send -----------------------------------*/ -OS_RESULT rt_mbx_send (OS_ID mailbox, void *p_msg, U16 timeout) { +OS_RESULT rt_mbx_send(OS_ID mailbox, void *p_msg, U16 timeout) { /* Send message to a mailbox */ P_MCB p_MCB = mailbox; P_TCB p_TCB; if ((p_MCB->p_lnk != NULL) && (p_MCB->state == 1)) { /* A task is waiting for message */ - p_TCB = rt_get_first ((P_XCB)p_MCB); + p_TCB = rt_get_first((P_XCB)p_MCB); #ifdef __CMSIS_RTOS - rt_ret_val2(p_TCB, 0x10/*osEventMessage*/, (U32)p_msg); + rt_ret_val2(p_TCB, 0x10 /*osEventMessage*/, (U32)p_msg); #else *p_TCB->msg = p_msg; - rt_ret_val (p_TCB, OS_R_MBX); + rt_ret_val(p_TCB, OS_R_MBX); #endif - rt_rmv_dly (p_TCB); - rt_dispatch (p_TCB); - } - else { + rt_rmv_dly(p_TCB); + rt_dispatch(p_TCB); + } else { /* Store message in mailbox queue */ if (p_MCB->count == p_MCB->size) { /* No free message entry, wait for one. If message queue is full, */ @@ -94,22 +90,21 @@ OS_RESULT rt_mbx_send (OS_ID mailbox, void *p_msg, U16 timeout) { return (OS_R_TMO); } if (p_MCB->p_lnk != NULL) { - rt_put_prio ((P_XCB)p_MCB, os_tsk.run); - } - else { + rt_put_prio((P_XCB)p_MCB, os_tsk.run); + } else { p_MCB->p_lnk = os_tsk.run; - os_tsk.run->p_lnk = NULL; + os_tsk.run->p_lnk = NULL; os_tsk.run->p_rlnk = (P_TCB)p_MCB; /* Task is waiting to send a message */ p_MCB->state = 2; } os_tsk.run->msg = p_msg; - rt_block (timeout, WAIT_MBX); + rt_block(timeout, WAIT_MBX); return (OS_R_TMO); } /* Yes, there is a free entry in a mailbox. */ p_MCB->msg[p_MCB->first] = p_msg; - rt_inc (&p_MCB->count); + rt_inc(&p_MCB->count); if (++p_MCB->first == p_MCB->size) { p_MCB->first = 0; } @@ -117,10 +112,9 @@ OS_RESULT rt_mbx_send (OS_ID mailbox, void *p_msg, U16 timeout) { return (OS_R_OK); } - /*--------------------------- rt_mbx_wait -----------------------------------*/ -OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout) { +OS_RESULT rt_mbx_wait(OS_ID mailbox, void **message, U16 timeout) { /* Receive a message; possibly wait for it */ P_MCB p_MCB = mailbox; P_TCB p_TCB; @@ -134,9 +128,9 @@ OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout) { } if ((p_MCB->p_lnk != NULL) && (p_MCB->state == 2)) { /* A task is waiting to send message */ - p_TCB = rt_get_first ((P_XCB)p_MCB); + p_TCB = rt_get_first((P_XCB)p_MCB); #ifdef __CMSIS_RTOS - rt_ret_val(p_TCB, 0/*osOK*/); + rt_ret_val(p_TCB, 0 /*osOK*/); #else rt_ret_val(p_TCB, OS_R_OK); #endif @@ -144,11 +138,10 @@ OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout) { if (++p_MCB->first == p_MCB->size) { p_MCB->first = 0; } - rt_rmv_dly (p_TCB); - rt_dispatch (p_TCB); - } - else { - rt_dec (&p_MCB->count); + rt_rmv_dly(p_TCB); + rt_dispatch(p_TCB); + } else { + rt_dec(&p_MCB->count); } return (OS_R_OK); } @@ -157,9 +150,8 @@ OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout) { return (OS_R_TMO); } if (p_MCB->p_lnk != NULL) { - rt_put_prio ((P_XCB)p_MCB, os_tsk.run); - } - else { + rt_put_prio((P_XCB)p_MCB, os_tsk.run); + } else { p_MCB->p_lnk = os_tsk.run; os_tsk.run->p_lnk = NULL; os_tsk.run->p_rlnk = (P_TCB)p_MCB; @@ -173,10 +165,9 @@ OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout) { return (OS_R_TMO); } - /*--------------------------- rt_mbx_check ----------------------------------*/ -OS_RESULT rt_mbx_check (OS_ID mailbox) { +OS_RESULT rt_mbx_check(OS_ID mailbox) { /* Check for free space in a mailbox. Returns the number of messages */ /* that can be stored to a mailbox. It returns 0 when mailbox is full. */ P_MCB p_MCB = mailbox; @@ -184,21 +175,19 @@ OS_RESULT rt_mbx_check (OS_ID mailbox) { return (p_MCB->size - p_MCB->count); } - /*--------------------------- isr_mbx_send ----------------------------------*/ -void isr_mbx_send (OS_ID mailbox, void *p_msg) { +void isr_mbx_send(OS_ID mailbox, void *p_msg) { /* Same function as "os_mbx_send", but to be called by ISRs. */ P_MCB p_MCB = mailbox; - rt_psq_enq (p_MCB, (U32)p_msg); - rt_psh_req (); + rt_psq_enq(p_MCB, (U32)p_msg); + rt_psh_req(); } - /*--------------------------- isr_mbx_receive -------------------------------*/ -OS_RESULT isr_mbx_receive (OS_ID mailbox, void **message) { +OS_RESULT isr_mbx_receive(OS_ID mailbox, void **message) { /* Receive a message in the interrupt function. The interrupt function */ /* should not wait for a message since this would block the rtx os. */ P_MCB p_MCB = mailbox; @@ -208,10 +197,10 @@ OS_RESULT isr_mbx_receive (OS_ID mailbox, void **message) { *message = p_MCB->msg[p_MCB->last]; if (p_MCB->state == 2) { /* A task is locked waiting to send message */ - rt_psq_enq (p_MCB, 0); - rt_psh_req (); + rt_psq_enq(p_MCB, 0); + rt_psh_req(); } - rt_dec (&p_MCB->count); + rt_dec(&p_MCB->count); if (++p_MCB->last == p_MCB->size) { p_MCB->last = 0; } @@ -220,73 +209,73 @@ OS_RESULT isr_mbx_receive (OS_ID mailbox, void **message) { return (OS_R_OK); } - /*--------------------------- rt_mbx_psh ------------------------------------*/ -void rt_mbx_psh (P_MCB p_CB, void *p_msg) { +void rt_mbx_psh(P_MCB p_CB, void *p_msg) { /* Store the message to the mailbox queue or pass it to task directly. */ P_TCB p_TCB; void *mem; - if (p_CB->p_lnk != NULL) switch (p_CB->state) { + if (p_CB->p_lnk != NULL) + switch (p_CB->state) { #ifdef __CMSIS_RTOS case 3: /* Task is waiting to allocate memory, remove it from the waiting list */ mem = rt_alloc_box(p_msg); - if (mem == NULL) break; - p_TCB = rt_get_first ((P_XCB)p_CB); + if (mem == NULL) + break; + p_TCB = rt_get_first((P_XCB)p_CB); rt_ret_val(p_TCB, (U32)mem); p_TCB->state = READY; - rt_rmv_dly (p_TCB); - rt_put_prio (&os_rdy, p_TCB); + rt_rmv_dly(p_TCB); + rt_put_prio(&os_rdy, p_TCB); break; #endif case 2: /* Task is waiting to send a message, remove it from the waiting list */ - p_TCB = rt_get_first ((P_XCB)p_CB); + p_TCB = rt_get_first((P_XCB)p_CB); #ifdef __CMSIS_RTOS - rt_ret_val(p_TCB, 0/*osOK*/); + rt_ret_val(p_TCB, 0 /*osOK*/); #else rt_ret_val(p_TCB, OS_R_OK); #endif p_CB->msg[p_CB->first] = p_TCB->msg; - rt_inc (&p_CB->count); + rt_inc(&p_CB->count); if (++p_CB->first == p_CB->size) { p_CB->first = 0; } p_TCB->state = READY; - rt_rmv_dly (p_TCB); - rt_put_prio (&os_rdy, p_TCB); + rt_rmv_dly(p_TCB); + rt_put_prio(&os_rdy, p_TCB); break; case 1: /* Task is waiting for a message, pass the message to the task directly */ - p_TCB = rt_get_first ((P_XCB)p_CB); + p_TCB = rt_get_first((P_XCB)p_CB); #ifdef __CMSIS_RTOS - rt_ret_val2(p_TCB, 0x10/*osEventMessage*/, (U32)p_msg); + rt_ret_val2(p_TCB, 0x10 /*osEventMessage*/, (U32)p_msg); #else *p_TCB->msg = p_msg; - rt_ret_val (p_TCB, OS_R_MBX); + rt_ret_val(p_TCB, OS_R_MBX); #endif p_TCB->state = READY; - rt_rmv_dly (p_TCB); - rt_put_prio (&os_rdy, p_TCB); + rt_rmv_dly(p_TCB); + rt_put_prio(&os_rdy, p_TCB); break; - } else { - /* No task is waiting for a message, store it to the mailbox queue */ - if (p_CB->count < p_CB->size) { - p_CB->msg[p_CB->first] = p_msg; - rt_inc (&p_CB->count); - if (++p_CB->first == p_CB->size) { - p_CB->first = 0; - } - } - else { - os_error (OS_ERR_MBX_OVF); + } + else { + /* No task is waiting for a message, store it to the mailbox queue */ + if (p_CB->count < p_CB->size) { + p_CB->msg[p_CB->first] = p_msg; + rt_inc(&p_CB->count); + if (++p_CB->first == p_CB->size) { + p_CB->first = 0; } + } else { + os_error(OS_ERR_MBX_OVF); + } } } /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_ARM7/rt_MemBox.c b/rtos/rtx/TARGET_ARM7/rt_MemBox.c index 9b5a00f..2a0359a 100644 --- a/rtos/rtx/TARGET_ARM7/rt_MemBox.c +++ b/rtos/rtx/TARGET_ARM7/rt_MemBox.c @@ -32,36 +32,34 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" -#include "RTX_Conf.h" -#include "rt_System.h" #include "rt_MemBox.h" +#include "RTX_Conf.h" #include "rt_HAL_CM.h" +#include "rt_System.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Global Functions *---------------------------------------------------------------------------*/ - /*--------------------------- _init_box -------------------------------------*/ -int _init_box (void *box_mem, U32 box_size, U32 blk_size) { +int _init_box(void *box_mem, U32 box_size, U32 blk_size) { /* Initialize memory block system, returns 0 if OK, 1 if fails. */ void *end; void *blk; void *next; - U32 sizeof_bm; + U32 sizeof_bm; /* Create memory structure. */ if (blk_size & BOX_ALIGN_8) { /* Memory blocks 8-byte aligned. */ blk_size = ((blk_size & ~BOX_ALIGN_8) + 7) & ~7; - sizeof_bm = (sizeof (struct OS_BM) + 7) & ~7; - } - else { + sizeof_bm = (sizeof(struct OS_BM) + 7) & ~7; + } else { /* Memory blocks 4-byte aligned. */ blk_size = (blk_size + 3) & ~3; - sizeof_bm = sizeof (struct OS_BM); + sizeof_bm = sizeof(struct OS_BM); } if (blk_size == 0) { return (1); @@ -70,17 +68,18 @@ int _init_box (void *box_mem, U32 box_size, U32 blk_size) { return (1); } /* Create a Memory structure. */ - blk = ((U8 *) box_mem) + sizeof_bm; - ((P_BM) box_mem)->free = blk; - end = ((U8 *) box_mem) + box_size; - ((P_BM) box_mem)->end = end; - ((P_BM) box_mem)->blk_size = blk_size; + blk = ((U8 *)box_mem) + sizeof_bm; + ((P_BM)box_mem)->free = blk; + end = ((U8 *)box_mem) + box_size; + ((P_BM)box_mem)->end = end; + ((P_BM)box_mem)->blk_size = blk_size; /* Link all free blocks using offsets. */ - end = ((U8 *) end) - blk_size; - while (1) { - next = ((U8 *) blk) + blk_size; - if (next > end) break; + end = ((U8 *)end) - blk_size; + while (1) { + next = ((U8 *)blk) + blk_size; + if (next > end) + break; *((void **)blk) = next; blk = next; } @@ -91,42 +90,42 @@ int _init_box (void *box_mem, U32 box_size, U32 blk_size) { /*--------------------------- rt_alloc_box ----------------------------------*/ -void *rt_alloc_box (void *box_mem) { +void *rt_alloc_box(void *box_mem) { /* Allocate a memory block and return start address. */ void **free; #ifndef __USE_EXCLUSIVE_ACCESS - int irq_dis; + int irq_dis; - irq_dis = __disable_irq (); - free = ((P_BM) box_mem)->free; + irq_dis = __disable_irq(); + free = ((P_BM)box_mem)->free; if (free) { - ((P_BM) box_mem)->free = *free; + ((P_BM)box_mem)->free = *free; } - if (!irq_dis) __enable_irq (); + if (!irq_dis) + __enable_irq(); #else do { - if ((free = (void **)__ldrex(&((P_BM) box_mem)->free)) == 0) { + if ((free = (void **)__ldrex(&((P_BM)box_mem)->free)) == 0) { __clrex(); break; } - } while (__strex((U32)*free, &((P_BM) box_mem)->free)); + } while (__strex((U32)*free, &((P_BM)box_mem)->free)); #endif return (free); } - /*--------------------------- _calloc_box -----------------------------------*/ -void *_calloc_box (void *box_mem) { +void *_calloc_box(void *box_mem) { /* Allocate a 0-initialized memory block and return start address. */ void *free; U32 *p; U32 i; - free = _alloc_box (box_mem); - if (free) { + free = _alloc_box(box_mem); + if (free) { p = free; - for (i = ((P_BM) box_mem)->blk_size; i; i -= 4) { + for (i = ((P_BM)box_mem)->blk_size; i; i -= 4) { *p = 0; p++; } @@ -134,28 +133,29 @@ void *_calloc_box (void *box_mem) { return (free); } - /*--------------------------- rt_free_box -----------------------------------*/ -int rt_free_box (void *box_mem, void *box) { - /* Free a memory block, returns 0 if OK, 1 if box does not belong to box_mem */ +int rt_free_box(void *box_mem, void *box) { + /* Free a memory block, returns 0 if OK, 1 if box does not belong to box_mem + */ #ifndef __USE_EXCLUSIVE_ACCESS int irq_dis; #endif - if (box < box_mem || box >= ((P_BM) box_mem)->end) { + if (box < box_mem || box >= ((P_BM)box_mem)->end) { return (1); } #ifndef __USE_EXCLUSIVE_ACCESS - irq_dis = __disable_irq (); - *((void **)box) = ((P_BM) box_mem)->free; - ((P_BM) box_mem)->free = box; - if (!irq_dis) __enable_irq (); + irq_dis = __disable_irq(); + *((void **)box) = ((P_BM)box_mem)->free; + ((P_BM)box_mem)->free = box; + if (!irq_dis) + __enable_irq(); #else do { - *((void **)box) = (void *)__ldrex(&((P_BM) box_mem)->free); - } while (__strex ((U32)box, &((P_BM) box_mem)->free)); + *((void **)box) = (void *)__ldrex(&((P_BM)box_mem)->free); + } while (__strex((U32)box, &((P_BM)box_mem)->free)); #endif return (0); } @@ -163,4 +163,3 @@ int rt_free_box (void *box_mem, void *box) { /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_ARM7/rt_Mutex.c b/rtos/rtx/TARGET_ARM7/rt_Mutex.c index 87398ad..0736b5f 100644 --- a/rtos/rtx/TARGET_ARM7/rt_Mutex.c +++ b/rtos/rtx/TARGET_ARM7/rt_Mutex.c @@ -32,63 +32,60 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" +#include "rt_Mutex.h" #include "RTX_Conf.h" +#include "rt_HAL_CM.h" #include "rt_List.h" #include "rt_Task.h" -#include "rt_Mutex.h" -#include "rt_HAL_CM.h" - +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_mut_init -----------------------------------*/ -void rt_mut_init (OS_ID mutex) { +void rt_mut_init(OS_ID mutex) { /* Initialize a mutex object */ P_MUCB p_MCB = mutex; p_MCB->cb_type = MUCB; - p_MCB->prio = 0; - p_MCB->level = 0; - p_MCB->p_lnk = NULL; - p_MCB->owner = NULL; + p_MCB->prio = 0; + p_MCB->level = 0; + p_MCB->p_lnk = NULL; + p_MCB->owner = NULL; } - /*--------------------------- rt_mut_delete ---------------------------------*/ #ifdef __CMSIS_RTOS -OS_RESULT rt_mut_delete (OS_ID mutex) { +OS_RESULT rt_mut_delete(OS_ID mutex) { /* Delete a mutex object */ P_MUCB p_MCB = mutex; - P_TCB p_TCB; + P_TCB p_TCB; /* Restore owner task's priority. */ if (p_MCB->level != 0) { p_MCB->owner->prio = p_MCB->prio; if (p_MCB->owner != os_tsk.run) { - rt_resort_prio (p_MCB->owner); + rt_resort_prio(p_MCB->owner); } } while (p_MCB->p_lnk != NULL) { /* A task is waiting for mutex. */ - p_TCB = rt_get_first ((P_XCB)p_MCB); - rt_ret_val(p_TCB, 0/*osOK*/); + p_TCB = rt_get_first((P_XCB)p_MCB); + rt_ret_val(p_TCB, 0 /*osOK*/); rt_rmv_dly(p_TCB); p_TCB->state = READY; - rt_put_prio (&os_rdy, p_TCB); + rt_put_prio(&os_rdy, p_TCB); } if (os_rdy.p_lnk && (os_rdy.p_lnk->prio > os_tsk.run->prio)) { /* preempt running task */ - rt_put_prio (&os_rdy, os_tsk.run); + rt_put_prio(&os_rdy, os_tsk.run); os_tsk.run->state = READY; - rt_dispatch (NULL); + rt_dispatch(NULL); } p_MCB->cb_type = 0; @@ -97,13 +94,12 @@ OS_RESULT rt_mut_delete (OS_ID mutex) { } #endif - /*--------------------------- rt_mut_release --------------------------------*/ -OS_RESULT rt_mut_release (OS_ID mutex) { +OS_RESULT rt_mut_release(OS_ID mutex) { /* Release a mutex object */ P_MUCB p_MCB = mutex; - P_TCB p_TCB; + P_TCB p_TCB; if (p_MCB->level == 0 || p_MCB->owner != os_tsk.run) { /* Unbalanced mutex release or task is not the owner */ @@ -116,56 +112,54 @@ OS_RESULT rt_mut_release (OS_ID mutex) { os_tsk.run->prio = p_MCB->prio; if (p_MCB->p_lnk != NULL) { /* A task is waiting for mutex. */ - p_TCB = rt_get_first ((P_XCB)p_MCB); + p_TCB = rt_get_first((P_XCB)p_MCB); #ifdef __CMSIS_RTOS - rt_ret_val(p_TCB, 0/*osOK*/); + rt_ret_val(p_TCB, 0 /*osOK*/); #else rt_ret_val(p_TCB, OS_R_MUT); #endif - rt_rmv_dly (p_TCB); + rt_rmv_dly(p_TCB); /* A waiting task becomes the owner of this mutex. */ - p_MCB->level = 1; - p_MCB->owner = p_TCB; - p_MCB->prio = p_TCB->prio; + p_MCB->level = 1; + p_MCB->owner = p_TCB; + p_MCB->prio = p_TCB->prio; /* Priority inversion, check which task continues. */ if (os_tsk.run->prio >= rt_rdy_prio()) { - rt_dispatch (p_TCB); - } - else { + rt_dispatch(p_TCB); + } else { /* Ready task has higher priority than running task. */ - rt_put_prio (&os_rdy, os_tsk.run); - rt_put_prio (&os_rdy, p_TCB); + rt_put_prio(&os_rdy, os_tsk.run); + rt_put_prio(&os_rdy, p_TCB); os_tsk.run->state = READY; - p_TCB->state = READY; - rt_dispatch (NULL); + p_TCB->state = READY; + rt_dispatch(NULL); } - } - else { + } else { /* Check if own priority raised by priority inversion. */ if (rt_rdy_prio() > os_tsk.run->prio) { - rt_put_prio (&os_rdy, os_tsk.run); + rt_put_prio(&os_rdy, os_tsk.run); os_tsk.run->state = READY; - rt_dispatch (NULL); + rt_dispatch(NULL); } } return (OS_R_OK); } - /*--------------------------- rt_mut_wait -----------------------------------*/ -OS_RESULT rt_mut_wait (OS_ID mutex, U16 timeout) { +OS_RESULT rt_mut_wait(OS_ID mutex, U16 timeout) { /* Wait for a mutex, continue when mutex is free. */ P_MUCB p_MCB = mutex; if (p_MCB->level == 0) { p_MCB->owner = os_tsk.run; - p_MCB->prio = os_tsk.run->prio; + p_MCB->prio = os_tsk.run->prio; goto inc; } if (p_MCB->owner == os_tsk.run) { /* OK, running task is the owner of this mutex. */ -inc:p_MCB->level++; + inc: + p_MCB->level++; return (OS_R_OK); } /* Mutex owned by another task, wait until released. */ @@ -176,22 +170,19 @@ inc:p_MCB->level++; /* This priority inversion is called priority inheritance. */ if (p_MCB->prio < os_tsk.run->prio) { p_MCB->owner->prio = os_tsk.run->prio; - rt_resort_prio (p_MCB->owner); + rt_resort_prio(p_MCB->owner); } if (p_MCB->p_lnk != NULL) { - rt_put_prio ((P_XCB)p_MCB, os_tsk.run); - } - else { + rt_put_prio((P_XCB)p_MCB, os_tsk.run); + } else { p_MCB->p_lnk = os_tsk.run; - os_tsk.run->p_lnk = NULL; + os_tsk.run->p_lnk = NULL; os_tsk.run->p_rlnk = (P_TCB)p_MCB; } rt_block(timeout, WAIT_MUT); return (OS_R_TMO); } - /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_ARM7/rt_Robin.c b/rtos/rtx/TARGET_ARM7/rt_Robin.c index ed58ea0..bcb0c01 100644 --- a/rtos/rtx/TARGET_ARM7/rt_Robin.c +++ b/rtos/rtx/TARGET_ARM7/rt_Robin.c @@ -32,13 +32,13 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" +#include "rt_Robin.h" #include "RTX_Conf.h" +#include "rt_HAL_CM.h" #include "rt_List.h" #include "rt_Task.h" #include "rt_Time.h" -#include "rt_Robin.h" -#include "rt_HAL_CM.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Global Variables @@ -46,14 +46,13 @@ struct OS_ROBIN os_robin; - /*---------------------------------------------------------------------------- * Global Functions *---------------------------------------------------------------------------*/ /*--------------------------- rt_init_robin ---------------------------------*/ -__weak void rt_init_robin (void) { +__weak void rt_init_robin(void) { /* Initialize Round Robin variables. */ os_robin.task = NULL; os_robin.tout = (U16)os_rrobin; @@ -61,7 +60,7 @@ __weak void rt_init_robin (void) { /*--------------------------- rt_chk_robin ----------------------------------*/ -__weak void rt_chk_robin (void) { +__weak void rt_chk_robin(void) { /* Check if Round Robin timeout expired and switch to the next ready task.*/ P_TCB p_new; @@ -73,12 +72,11 @@ __weak void rt_chk_robin (void) { if (os_robin.time == (U16)os_time) { /* Round Robin timeout has expired, swap Robin tasks. */ os_robin.task = NULL; - p_new = rt_get_first (&os_rdy); - rt_put_prio ((P_XCB)&os_rdy, p_new); + p_new = rt_get_first(&os_rdy); + rt_put_prio((P_XCB)&os_rdy, p_new); } } /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_ARM7/rt_Semaphore.c b/rtos/rtx/TARGET_ARM7/rt_Semaphore.c index 5bf6525..76ee0dd 100644 --- a/rtos/rtx/TARGET_ARM7/rt_Semaphore.c +++ b/rtos/rtx/TARGET_ARM7/rt_Semaphore.c @@ -32,54 +32,51 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" -#include "RTX_Conf.h" -#include "rt_System.h" -#include "rt_List.h" -#include "rt_Task.h" #include "rt_Semaphore.h" +#include "RTX_Conf.h" #include "rt_HAL_CM.h" - +#include "rt_List.h" +#include "rt_System.h" +#include "rt_Task.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_sem_init -----------------------------------*/ -void rt_sem_init (OS_ID semaphore, U16 token_count) { +void rt_sem_init(OS_ID semaphore, U16 token_count) { /* Initialize a semaphore */ P_SCB p_SCB = semaphore; p_SCB->cb_type = SCB; - p_SCB->p_lnk = NULL; + p_SCB->p_lnk = NULL; p_SCB->tokens = token_count; } - /*--------------------------- rt_sem_delete ---------------------------------*/ #ifdef __CMSIS_RTOS -OS_RESULT rt_sem_delete (OS_ID semaphore) { +OS_RESULT rt_sem_delete(OS_ID semaphore) { /* Delete semaphore */ P_SCB p_SCB = semaphore; P_TCB p_TCB; while (p_SCB->p_lnk != NULL) { /* A task is waiting for token */ - p_TCB = rt_get_first ((P_XCB)p_SCB); + p_TCB = rt_get_first((P_XCB)p_SCB); rt_ret_val(p_TCB, 0); rt_rmv_dly(p_TCB); p_TCB->state = READY; - rt_put_prio (&os_rdy, p_TCB); + rt_put_prio(&os_rdy, p_TCB); } if (os_rdy.p_lnk && (os_rdy.p_lnk->prio > os_tsk.run->prio)) { /* preempt running task */ - rt_put_prio (&os_rdy, os_tsk.run); + rt_put_prio(&os_rdy, os_tsk.run); os_tsk.run->state = READY; - rt_dispatch (NULL); + rt_dispatch(NULL); } p_SCB->cb_type = 0; @@ -88,36 +85,33 @@ OS_RESULT rt_sem_delete (OS_ID semaphore) { } #endif - /*--------------------------- rt_sem_send -----------------------------------*/ -OS_RESULT rt_sem_send (OS_ID semaphore) { +OS_RESULT rt_sem_send(OS_ID semaphore) { /* Return a token to semaphore */ P_SCB p_SCB = semaphore; P_TCB p_TCB; if (p_SCB->p_lnk != NULL) { /* A task is waiting for token */ - p_TCB = rt_get_first ((P_XCB)p_SCB); + p_TCB = rt_get_first((P_XCB)p_SCB); #ifdef __CMSIS_RTOS rt_ret_val(p_TCB, 1); #else rt_ret_val(p_TCB, OS_R_SEM); #endif - rt_rmv_dly (p_TCB); - rt_dispatch (p_TCB); - } - else { + rt_rmv_dly(p_TCB); + rt_dispatch(p_TCB); + } else { /* Store token. */ p_SCB->tokens++; } return (OS_R_OK); } - /*--------------------------- rt_sem_wait -----------------------------------*/ -OS_RESULT rt_sem_wait (OS_ID semaphore, U16 timeout) { +OS_RESULT rt_sem_wait(OS_ID semaphore, U16 timeout) { /* Obtain a token; possibly wait for it */ P_SCB p_SCB = semaphore; @@ -130,9 +124,8 @@ OS_RESULT rt_sem_wait (OS_ID semaphore, U16 timeout) { return (OS_R_TMO); } if (p_SCB->p_lnk != NULL) { - rt_put_prio ((P_XCB)p_SCB, os_tsk.run); - } - else { + rt_put_prio((P_XCB)p_SCB, os_tsk.run); + } else { p_SCB->p_lnk = os_tsk.run; os_tsk.run->p_lnk = NULL; os_tsk.run->p_rlnk = (P_TCB)p_SCB; @@ -141,37 +134,34 @@ OS_RESULT rt_sem_wait (OS_ID semaphore, U16 timeout) { return (OS_R_TMO); } - /*--------------------------- isr_sem_send ----------------------------------*/ -void isr_sem_send (OS_ID semaphore) { +void isr_sem_send(OS_ID semaphore) { /* Same function as "os_sem"send", but to be called by ISRs */ P_SCB p_SCB = semaphore; - rt_psq_enq (p_SCB, 0); - rt_psh_req (); + rt_psq_enq(p_SCB, 0); + rt_psh_req(); } - /*--------------------------- rt_sem_psh ------------------------------------*/ -void rt_sem_psh (P_SCB p_CB) { +void rt_sem_psh(P_SCB p_CB) { /* Check if task has to be waken up */ P_TCB p_TCB; if (p_CB->p_lnk != NULL) { /* A task is waiting for token */ - p_TCB = rt_get_first ((P_XCB)p_CB); - rt_rmv_dly (p_TCB); - p_TCB->state = READY; + p_TCB = rt_get_first((P_XCB)p_CB); + rt_rmv_dly(p_TCB); + p_TCB->state = READY; #ifdef __CMSIS_RTOS rt_ret_val(p_TCB, 1); #else rt_ret_val(p_TCB, OS_R_SEM); #endif - rt_put_prio (&os_rdy, p_TCB); - } - else { + rt_put_prio(&os_rdy, p_TCB); + } else { /* Store token */ p_CB->tokens++; } @@ -180,4 +170,3 @@ void rt_sem_psh (P_SCB p_CB) { /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_ARM7/rt_System.c b/rtos/rtx/TARGET_ARM7/rt_System.c index 2482701..56e5393 100644 --- a/rtos/rtx/TARGET_ARM7/rt_System.c +++ b/rtos/rtx/TARGET_ARM7/rt_System.c @@ -32,17 +32,17 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" -#include "RTX_Conf.h" -#include "rt_Task.h" #include "rt_System.h" +#include "RTX_Conf.h" #include "rt_Event.h" +#include "rt_HAL_CM.h" #include "rt_List.h" #include "rt_Mailbox.h" -#include "rt_Semaphore.h" -#include "rt_Time.h" #include "rt_Robin.h" -#include "rt_HAL_CM.h" +#include "rt_Semaphore.h" +#include "rt_Task.h" +#include "rt_Time.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Global Variables @@ -56,25 +56,24 @@ int os_tick_irqn; static volatile BIT os_lock; static volatile BIT os_psh_flag; -static U8 pend_flags; +static U8 pend_flags; /*---------------------------------------------------------------------------- * Global Functions *---------------------------------------------------------------------------*/ -#if defined (__CC_ARM) -__asm void $$RTX$$version (void) { - /* Export a version number symbol for a version control. */ +#if defined(__CC_ARM) +__asm void $$RTX$$version(void) { + /* Export a version number symbol for a version control. */ - EXPORT __RL_RTX_VER + EXPORT __RL_RTX_VER -__RL_RTX_VER EQU 0x450 + __RL_RTX_VER EQU 0x450 } #endif - /*--------------------------- rt_suspend ------------------------------------*/ -U32 rt_suspend (void) { +U32 rt_suspend(void) { /* Suspend OS scheduler */ U32 delta = 0xFFFF; @@ -85,22 +84,22 @@ U32 rt_suspend (void) { } #ifndef __CMSIS_RTOS if (os_tmr.next) { - if (os_tmr.tcnt < delta) delta = os_tmr.tcnt; + if (os_tmr.tcnt < delta) + delta = os_tmr.tcnt; } #endif return (delta); } - /*--------------------------- rt_resume -------------------------------------*/ -void rt_resume (U32 sleep_time) { +void rt_resume(U32 sleep_time) { /* Resume OS scheduler after suspend */ P_TCB next; - U32 delta; + U32 delta; os_tsk.run->state = READY; - rt_put_rdy_first (os_tsk.run); + rt_put_rdy_first(os_tsk.run); os_robin.task = NULL; @@ -108,17 +107,18 @@ void rt_resume (U32 sleep_time) { if (os_dly.p_dlnk) { delta = sleep_time; if (delta >= os_dly.delta_time) { - delta -= os_dly.delta_time; + delta -= os_dly.delta_time; os_time += os_dly.delta_time; os_dly.delta_time = 1; while (os_dly.p_dlnk) { rt_dec_dly(); - if (delta == 0) break; + if (delta == 0) + break; delta--; os_time++; } } else { - os_time += delta; + os_time += delta; os_dly.delta_time -= delta; } } else { @@ -130,11 +130,12 @@ void rt_resume (U32 sleep_time) { if (os_tmr.next) { delta = sleep_time; if (delta >= os_tmr.tcnt) { - delta -= os_tmr.tcnt; + delta -= os_tmr.tcnt; os_tmr.tcnt = 1; while (os_tmr.next) { rt_tmr_tick(); - if (delta == 0) break; + if (delta == 0) + break; delta--; } } else { @@ -144,105 +145,95 @@ void rt_resume (U32 sleep_time) { #endif /* Switch back to highest ready task */ - next = rt_get_first (&os_rdy); - rt_switch_req (next); + next = rt_get_first(&os_rdy); + rt_switch_req(next); rt_tsk_unlock(); } - /*--------------------------- rt_tsk_lock -----------------------------------*/ -void rt_tsk_lock (void) { +void rt_tsk_lock(void) { /* Prevent task switching by locking out scheduler */ - OS_X_LOCK(os_tick_irqn); - os_lock = __TRUE; - OS_X_UNPEND (&pend_flags); + OS_X_LOCK(os_tick_irqn); + os_lock = __TRUE; + OS_X_UNPEND(&pend_flags); } - /*--------------------------- rt_tsk_unlock ---------------------------------*/ -void rt_tsk_unlock (void) { +void rt_tsk_unlock(void) { /* Unlock scheduler and re-enable task switching */ - OS_X_UNLOCK(os_tick_irqn); - os_lock = __FALSE; - OS_X_PEND (pend_flags, os_psh_flag); - os_psh_flag = __FALSE; + OS_X_UNLOCK(os_tick_irqn); + os_lock = __FALSE; + OS_X_PEND(pend_flags, os_psh_flag); + os_psh_flag = __FALSE; } - /*--------------------------- rt_psh_req ------------------------------------*/ -void rt_psh_req (void) { +void rt_psh_req(void) { /* Initiate a post service handling request if required. */ if (os_lock == __FALSE) { - OS_PEND_IRQ (); - } - else { + OS_PEND_IRQ(); + } else { os_psh_flag = __TRUE; } } - /*--------------------------- rt_pop_req ------------------------------------*/ -void rt_pop_req (void) { +void rt_pop_req(void) { /* Process an ISR post service requests. */ struct OS_XCB *p_CB; P_TCB next; - U32 idx; + U32 idx; os_tsk.run->state = READY; - rt_put_rdy_first (os_tsk.run); + rt_put_rdy_first(os_tsk.run); idx = os_psq->last; while (os_psq->count) { p_CB = os_psq->q[idx].id; if (p_CB->cb_type == TCB) { /* Is of TCB type */ - rt_evt_psh ((P_TCB)p_CB, (U16)os_psq->q[idx].arg); - } - else if (p_CB->cb_type == MCB) { + rt_evt_psh((P_TCB)p_CB, (U16)os_psq->q[idx].arg); + } else if (p_CB->cb_type == MCB) { /* Is of MCB type */ - rt_mbx_psh ((P_MCB)p_CB, (void *)os_psq->q[idx].arg); - } - else { + rt_mbx_psh((P_MCB)p_CB, (void *)os_psq->q[idx].arg); + } else { /* Must be of SCB type */ - rt_sem_psh ((P_SCB)p_CB); + rt_sem_psh((P_SCB)p_CB); } - if (++idx == os_psq->size) idx = 0; - rt_dec (&os_psq->count); + if (++idx == os_psq->size) + idx = 0; + rt_dec(&os_psq->count); } os_psq->last = idx; - next = rt_get_first (&os_rdy); - rt_switch_req (next); + next = rt_get_first(&os_rdy); + rt_switch_req(next); } - /*--------------------------- os_tick_init ----------------------------------*/ -__weak int os_tick_init (void) { +__weak int os_tick_init(void) { /* Initialize SysTick timer as system tick timer. */ - rt_systick_init (); - return (SYS_TICK_IRQn); /* Return IRQ number of SysTick timer */ + rt_systick_init(); + return (SYS_TICK_IRQn); /* Return IRQ number of SysTick timer */ } - /*--------------------------- os_tick_irqack --------------------------------*/ -__weak void os_tick_irqack (void) { - /* Acknowledge timer interrupt. */ +__weak void os_tick_irqack(void) { /* Acknowledge timer interrupt. */ } - /*--------------------------- rt_systick ------------------------------------*/ extern void sysTimerTick(void); -void rt_systick (void) { - if(NVIC_Pending(SYS_TICK_IRQn)){ +void rt_systick(void) { + if (NVIC_Pending(SYS_TICK_IRQn)) { rt_pop_req(); NVIC_UnpendIRQ(SYS_TICK_IRQn); SYS_TICK_TIMER->IR = 0xF; // clear timer interrupt @@ -252,42 +243,42 @@ void rt_systick (void) { P_TCB next; os_tsk.run->state = READY; - rt_put_rdy_first (os_tsk.run); + rt_put_rdy_first(os_tsk.run); /* Check Round Robin timeout. */ - rt_chk_robin (); + rt_chk_robin(); /* Update delays. */ os_time++; - rt_dec_dly (); + rt_dec_dly(); /* Check the user timers. */ #ifdef __CMSIS_RTOS sysTimerTick(); #else - rt_tmr_tick (); + rt_tmr_tick(); #endif /* Switch back to highest ready task */ - next = rt_get_first (&os_rdy); - rt_switch_req (next); + next = rt_get_first(&os_rdy); + rt_switch_req(next); SYS_TICK_TIMER->IR = 0xF; // clear timer interrupt } /*--------------------------- rt_stk_check ----------------------------------*/ -__weak void rt_stk_check (void) { - /* Check for stack overflow. */ - if (os_tsk.run->task_id == 0x01) { - // TODO: For the main thread the check should be done against the main heap pointer - } else { - if ((os_tsk.run->tsk_stack < (U32)os_tsk.run->stack) || - (os_tsk.run->stack[0] != MAGIC_WORD)) { - os_error (OS_ERR_STK_OVF); - } +__weak void rt_stk_check(void) { + /* Check for stack overflow. */ + if (os_tsk.run->task_id == 0x01) { + // TODO: For the main thread the check should be done against the main heap + // pointer + } else { + if ((os_tsk.run->tsk_stack < (U32)os_tsk.run->stack) || + (os_tsk.run->stack[0] != MAGIC_WORD)) { + os_error(OS_ERR_STK_OVF); } + } } /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_ARM7/rt_Task.c b/rtos/rtx/TARGET_ARM7/rt_Task.c index d9e4d3f..2c39218 100644 --- a/rtos/rtx/TARGET_ARM7/rt_Task.c +++ b/rtos/rtx/TARGET_ARM7/rt_Task.c @@ -32,14 +32,14 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" -#include "RTX_Conf.h" -#include "rt_System.h" #include "rt_Task.h" +#include "RTX_Conf.h" +#include "rt_HAL_CM.h" #include "rt_List.h" #include "rt_MemBox.h" #include "rt_Robin.h" -#include "rt_HAL_CM.h" +#include "rt_System.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Global Variables @@ -51,27 +51,26 @@ struct OS_TSK os_tsk; /* Task Control Blocks of idle demon */ struct OS_TCB os_idle_TCB; - /*---------------------------------------------------------------------------- * Local Functions *---------------------------------------------------------------------------*/ -OS_TID rt_get_TID (void) { +OS_TID rt_get_TID(void) { U32 tid; for (tid = 1; tid <= os_maxtaskrun; tid++) { - if (os_active_TCB[tid-1] == NULL) { + if (os_active_TCB[tid - 1] == NULL) { return ((OS_TID)tid); } } return (0); } -#if defined (__CC_ARM) && !defined (__MICROLIB) +#if defined(__CC_ARM) && !defined(__MICROLIB) /*--------------------------- __user_perthread_libspace ---------------------*/ -extern void *__libspace_start; +extern void *__libspace_start; -void *__user_perthread_libspace (void) { +void *__user_perthread_libspace(void) { /* Provide a separate libspace for each task. */ if (os_tsk.run == NULL) { /* RTX not running yet. */ @@ -83,65 +82,60 @@ void *__user_perthread_libspace (void) { /*--------------------------- rt_init_context -------------------------------*/ -void rt_init_context (P_TCB p_TCB, U8 priority, FUNCP task_body) { +void rt_init_context(P_TCB p_TCB, U8 priority, FUNCP task_body) { /* Initialize general part of the Task Control Block. */ p_TCB->cb_type = TCB; - p_TCB->state = READY; - p_TCB->prio = priority; - p_TCB->p_lnk = NULL; - p_TCB->p_rlnk = NULL; - p_TCB->p_dlnk = NULL; - p_TCB->p_blnk = NULL; - p_TCB->delta_time = 0; + p_TCB->state = READY; + p_TCB->prio = priority; + p_TCB->p_lnk = NULL; + p_TCB->p_rlnk = NULL; + p_TCB->p_dlnk = NULL; + p_TCB->p_blnk = NULL; + p_TCB->delta_time = 0; p_TCB->interval_time = 0; - p_TCB->events = 0; - p_TCB->waits = 0; + p_TCB->events = 0; + p_TCB->waits = 0; p_TCB->stack_frame = 0; - rt_init_stack (p_TCB, task_body); + rt_init_stack(p_TCB, task_body); } - /*--------------------------- rt_switch_req ---------------------------------*/ -void rt_switch_req (P_TCB p_new) { +void rt_switch_req(P_TCB p_new) { /* Switch to next task (identified by "p_new"). */ - os_tsk.new_tsk = p_new; + os_tsk.new_tsk = p_new; p_new->state = RUNNING; DBG_TASK_SWITCH(p_new->task_id); } - /*--------------------------- rt_dispatch -----------------------------------*/ -void rt_dispatch (P_TCB next_TCB) { +void rt_dispatch(P_TCB next_TCB) { /* Dispatch next task if any identified or dispatch highest ready task */ /* "next_TCB" identifies a task to run or has value NULL (=no next task) */ if (next_TCB == NULL) { /* Running task was blocked: continue with highest ready task */ - next_TCB = rt_get_first (&os_rdy); - rt_switch_req (next_TCB); - } - else { + next_TCB = rt_get_first(&os_rdy); + rt_switch_req(next_TCB); + } else { /* Check which task continues */ if (next_TCB->prio > os_tsk.run->prio) { /* preempt running task */ - rt_put_rdy_first (os_tsk.run); + rt_put_rdy_first(os_tsk.run); os_tsk.run->state = READY; - rt_switch_req (next_TCB); - } - else { + rt_switch_req(next_TCB); + } else { /* put next task into ready list, no task switch takes place */ next_TCB->state = READY; - rt_put_prio (&os_rdy, next_TCB); + rt_put_prio(&os_rdy, next_TCB); } } } - /*--------------------------- rt_block --------------------------------------*/ -void rt_block (U16 timeout, U8 block_state) { +void rt_block(U16 timeout, U8 block_state) { /* Block running task and choose next ready task. */ /* "timeout" sets a time-out value or is 0xffff (=no time-out). */ /* "block_state" defines the appropriate task state */ @@ -149,33 +143,31 @@ void rt_block (U16 timeout, U8 block_state) { if (timeout) { if (timeout < 0xffff) { - rt_put_dly (os_tsk.run, timeout); + rt_put_dly(os_tsk.run, timeout); } os_tsk.run->state = block_state; - next_TCB = rt_get_first (&os_rdy); - rt_switch_req (next_TCB); + next_TCB = rt_get_first(&os_rdy); + rt_switch_req(next_TCB); } } - /*--------------------------- rt_tsk_pass -----------------------------------*/ -void rt_tsk_pass (void) { +void rt_tsk_pass(void) { /* Allow tasks of same priority level to run cooperatively.*/ P_TCB p_new; p_new = rt_get_same_rdy_prio(); if (p_new != NULL) { - rt_put_prio ((P_XCB)&os_rdy, os_tsk.run); + rt_put_prio((P_XCB)&os_rdy, os_tsk.run); os_tsk.run->state = READY; - rt_switch_req (p_new); + rt_switch_req(p_new); } } - /*--------------------------- rt_tsk_self -----------------------------------*/ -OS_TID rt_tsk_self (void) { +OS_TID rt_tsk_self(void) { /* Return own task identifier value. */ if (os_tsk.run == NULL) { return (0); @@ -183,72 +175,71 @@ OS_TID rt_tsk_self (void) { return (os_tsk.run->task_id); } - /*--------------------------- rt_tsk_prio -----------------------------------*/ -OS_RESULT rt_tsk_prio (OS_TID task_id, U8 new_prio) { +OS_RESULT rt_tsk_prio(OS_TID task_id, U8 new_prio) { /* Change execution priority of a task to "new_prio". */ P_TCB p_task; if (task_id == 0) { /* Change execution priority of calling task. */ os_tsk.run->prio = new_prio; -run:if (rt_rdy_prio() > new_prio) { - rt_put_prio (&os_rdy, os_tsk.run); - os_tsk.run->state = READY; - rt_dispatch (NULL); + run: + if (rt_rdy_prio() > new_prio) { + rt_put_prio(&os_rdy, os_tsk.run); + os_tsk.run->state = READY; + rt_dispatch(NULL); } return (OS_R_OK); } /* Find the task in the "os_active_TCB" array. */ - if (task_id > os_maxtaskrun || os_active_TCB[task_id-1] == NULL) { + if (task_id > os_maxtaskrun || os_active_TCB[task_id - 1] == NULL) { /* Task with "task_id" not found or not started. */ return (OS_R_NOK); } - p_task = os_active_TCB[task_id-1]; + p_task = os_active_TCB[task_id - 1]; p_task->prio = new_prio; if (p_task == os_tsk.run) { goto run; } - rt_resort_prio (p_task); + rt_resort_prio(p_task); if (p_task->state == READY) { /* Task enqueued in a ready list. */ - p_task = rt_get_first (&os_rdy); - rt_dispatch (p_task); + p_task = rt_get_first(&os_rdy); + rt_dispatch(p_task); } return (OS_R_OK); } /*--------------------------- rt_tsk_delete ---------------------------------*/ -OS_RESULT rt_tsk_delete (OS_TID task_id) { +OS_RESULT rt_tsk_delete(OS_TID task_id) { /* Terminate the task identified with "task_id". */ P_TCB task_context; if (task_id == 0 || task_id == os_tsk.run->task_id) { /* Terminate itself. */ - os_tsk.run->state = INACTIVE; + os_tsk.run->state = INACTIVE; os_tsk.run->tsk_stack = 0; - rt_stk_check (); - os_active_TCB[os_tsk.run->task_id-1] = NULL; + rt_stk_check(); + os_active_TCB[os_tsk.run->task_id - 1] = NULL; os_tsk.run->stack = NULL; DBG_TASK_NOTIFY(os_tsk.run, __FALSE); os_tsk.run = NULL; - rt_dispatch (NULL); + rt_dispatch(NULL); /* The program should never come to this point. */ - } - else { + } else { /* Find the task in the "os_active_TCB" array. */ - if (task_id > os_maxtaskrun || os_active_TCB[task_id-1] == NULL) { + if (task_id > os_maxtaskrun || os_active_TCB[task_id - 1] == NULL) { /* Task with "task_id" not found or not started. */ return (OS_R_NOK); } - task_context = os_active_TCB[task_id-1]; - rt_rmv_list (task_context); - rt_rmv_dly (task_context); - os_active_TCB[task_id-1] = NULL; + task_context = os_active_TCB[task_id - 1]; + rt_rmv_list(task_context); + rt_rmv_dly(task_context); + os_active_TCB[task_id - 1] = NULL; task_context->stack = NULL; DBG_TASK_NOTIFY(task_context, __FALSE); @@ -256,13 +247,12 @@ OS_RESULT rt_tsk_delete (OS_TID task_id) { return (OS_R_OK); } - /*--------------------------- rt_sys_init -----------------------------------*/ #ifdef __CMSIS_RTOS -void rt_sys_init (void) { +void rt_sys_init(void) { #else -void rt_sys_init (FUNCP first_task, U32 prio_stksz, void *stk) { +void rt_sys_init(FUNCP first_task, U32 prio_stksz, void *stk) { #endif /* Initialize system and start up task declared with "first_task". */ U32 i; @@ -278,56 +268,55 @@ void rt_sys_init (FUNCP first_task, U32 prio_stksz, void *stk) { os_idle_TCB.task_id = 255; os_idle_TCB.priv_stack = idle_task_stack_size; os_idle_TCB.stack = idle_task_stack; - rt_init_context (&os_idle_TCB, 0, os_idle_demon); + rt_init_context(&os_idle_TCB, 0, os_idle_demon); /* Set up ready list: initially empty */ os_rdy.cb_type = HCB; - os_rdy.p_lnk = NULL; + os_rdy.p_lnk = NULL; /* Set up delay list: initially empty */ os_dly.cb_type = HCB; - os_dly.p_dlnk = NULL; - os_dly.p_blnk = NULL; + os_dly.p_dlnk = NULL; + os_dly.p_blnk = NULL; os_dly.delta_time = 0; /* Fix SP and systemvariables to assume idle task is running */ /* Transform main program into idle task by assuming idle TCB */ #ifndef __CMSIS_RTOS - rt_set_PSP (os_idle_TCB.tsk_stack); + rt_set_PSP(os_idle_TCB.tsk_stack); #endif os_tsk.run = &os_idle_TCB; os_tsk.run->state = RUNNING; /* Initialize ps queue */ os_psq->first = 0; - os_psq->last = 0; - os_psq->size = os_fifo_size; + os_psq->last = 0; + os_psq->size = os_fifo_size; - rt_init_robin (); + rt_init_robin(); /* Intitialize SVC and PendSV */ - rt_svc_init (); + rt_svc_init(); #ifndef __CMSIS_RTOS /* Intitialize and start system clock timer */ - os_tick_irqn = os_tick_init (); + os_tick_irqn = os_tick_init(); if (os_tick_irqn >= 0) { OS_X_INIT(os_tick_irqn); } /* Start up first user task before entering the endless loop */ - rt_tsk_create (first_task, prio_stksz, stk, NULL); + rt_tsk_create(first_task, prio_stksz, stk, NULL); #endif } - /*--------------------------- rt_sys_start ----------------------------------*/ #ifdef __CMSIS_RTOS -void rt_sys_start (void) { +void rt_sys_start(void) { /* Start system */ /* Intitialize and start system clock timer */ - os_tick_irqn = os_tick_init (); + os_tick_irqn = os_tick_init(); if (os_tick_irqn >= 0) { OS_X_INIT(os_tick_irqn); } diff --git a/rtos/rtx/TARGET_ARM7/rt_Time.c b/rtos/rtx/TARGET_ARM7/rt_Time.c index 075f2e5..806b4ad 100644 --- a/rtos/rtx/TARGET_ARM7/rt_Time.c +++ b/rtos/rtx/TARGET_ARM7/rt_Time.c @@ -32,10 +32,10 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" +#include "rt_Time.h" #include "RTX_Conf.h" #include "rt_Task.h" -#include "rt_Time.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Global Variables @@ -44,51 +44,45 @@ /* Free running system tick counter */ U32 os_time; - /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_time_get -----------------------------------*/ -U32 rt_time_get (void) { +U32 rt_time_get(void) { /* Get system time tick */ return (os_time); } - /*--------------------------- rt_dly_wait -----------------------------------*/ -void rt_dly_wait (U16 delay_time) { +void rt_dly_wait(U16 delay_time) { /* Delay task by "delay_time" */ - rt_block (delay_time, WAIT_DLY); + rt_block(delay_time, WAIT_DLY); } - /*--------------------------- rt_itv_set ------------------------------------*/ -void rt_itv_set (U16 interval_time) { +void rt_itv_set(U16 interval_time) { /* Set interval length and define start of first interval */ os_tsk.run->interval_time = interval_time; os_tsk.run->delta_time = interval_time + (U16)os_time; } - /*--------------------------- rt_itv_wait -----------------------------------*/ -void rt_itv_wait (void) { +void rt_itv_wait(void) { /* Wait for interval end and define start of next one */ U16 delta; delta = os_tsk.run->delta_time - (U16)os_time; os_tsk.run->delta_time += os_tsk.run->interval_time; if ((delta & 0x8000) == 0) { - rt_block (delta, WAIT_ITV); + rt_block(delta, WAIT_ITV); } } /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_A/HAL_CA.c b/rtos/rtx/TARGET_CORTEX_A/HAL_CA.c index 295a64f..300a57b 100644 --- a/rtos/rtx/TARGET_CORTEX_A/HAL_CA.c +++ b/rtos/rtx/TARGET_CORTEX_A/HAL_CA.c @@ -32,15 +32,15 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" #include "RTX_Config.h" #include "rt_HAL_CA.h" +#include "rt_TypeDef.h" /*--------------------------- os_init_context -------------------------------*/ -void rt_init_stack (P_TCB p_TCB, FUNCP task_body) { +void rt_init_stack(P_TCB p_TCB, FUNCP task_body) { /* Prepare TCB and saved context for a first time start of a task. */ - U32 *stk,i,size; + U32 *stk, i, size; /* Prepare a complete interrupt frame for first task start */ size = p_TCB->priv_stack >> 2; @@ -67,7 +67,7 @@ void rt_init_stack (P_TCB p_TCB, FUNCP task_body) { stk[15] |= CPSR_T_BIT; } /* Assign a void pointer to R0. */ - stk[8] = (U32)p_TCB->msg; + stk[8] = (U32)p_TCB->msg; /* Clear R1-R12,LR registers. */ for (i = 0; i < 8; i++) { stk[i] = 0; @@ -86,26 +86,25 @@ void rt_init_stack (P_TCB p_TCB, FUNCP task_body) { p_TCB->stack[0] = MAGIC_WORD; } - /*--------------------------- rt_ret_val ----------------------------------*/ -static __inline U32 *rt_ret_regs (P_TCB p_TCB) { +static __inline U32 *rt_ret_regs(P_TCB p_TCB) { /* Get pointer to task return value registers (R0..R3) in Stack */ #if (__TARGET_FPU_VFP) if (p_TCB->stack_frame & 0x2) { /* Extended Stack Frame: S0-31,FPSCR,Reserved,R4-R11,R0-R3,R12,LR,PC,xPSR */ - return (U32 *)(p_TCB->tsk_stack + 8*4 + 34*4); + return (U32 *)(p_TCB->tsk_stack + 8 * 4 + 34 * 4); } else { /* Basic Stack Frame: R4-R11,R0-R3,R12,LR,PC,xPSR */ - return (U32 *)(p_TCB->tsk_stack + 8*4); + return (U32 *)(p_TCB->tsk_stack + 8 * 4); } #else /* Stack Frame: R4-R11,R0-R3,R12,LR,PC,xPSR */ - return (U32 *)(p_TCB->tsk_stack + 8*4); + return (U32 *)(p_TCB->tsk_stack + 8 * 4); #endif } -void rt_ret_val (P_TCB p_TCB, U32 v0) { +void rt_ret_val(P_TCB p_TCB, U32 v0) { U32 *ret; ret = rt_ret_regs(p_TCB); @@ -120,7 +119,6 @@ void rt_ret_val2(P_TCB p_TCB, U32 v0, U32 v1) { ret[1] = v1; } - /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ diff --git a/rtos/rtx/TARGET_CORTEX_A/RTX_Conf_CA.c b/rtos/rtx/TARGET_CORTEX_A/RTX_Conf_CA.c index 78863e8..a07c0f4 100644 --- a/rtos/rtx/TARGET_CORTEX_A/RTX_Conf_CA.c +++ b/rtos/rtx/TARGET_CORTEX_A/RTX_Conf_CA.c @@ -47,21 +47,21 @@ // Defines max. number of threads that will run at the same time. // Default: 6 #ifndef OS_TASKCNT - #define OS_TASKCNT 25 +#define OS_TASKCNT 25 #endif #ifdef __MBED_CMSIS_RTOS_CA9 // Idle stack size [bytes] <64-4096:8><#/4> // Defines default stack size for the Idle thread. #ifndef OS_IDLESTKSIZE - #define OS_IDLESTKSIZE 128 +#define OS_IDLESTKSIZE 128 #endif #else // __MBED_CMSIS_RTOS_CA9 // Default Thread stack size [bytes] <64-4096:8><#/4> // Defines default stack size for threads with osThreadDef stacksz = 0 // Default: 200 #ifndef OS_STKSIZE - #define OS_STKSIZE 200 +#define OS_STKSIZE 200 #endif #endif // __MBED_CMSIS_RTOS_CA9 @@ -69,7 +69,7 @@ // Defines stack size for main thread. // Default: 200 #ifndef OS_MAINSTKSIZE - #define OS_MAINSTKSIZE 2048 +#define OS_MAINSTKSIZE 2048 #endif #ifndef __MBED_CMSIS_RTOS_CA9 @@ -77,14 +77,14 @@ // Defines the number of threads with user-provided stack size. // Default: 0 #ifndef OS_PRIVCNT - #define OS_PRIVCNT 0 +#define OS_PRIVCNT 0 #endif -// Total stack size [bytes] for threads with user-provided stack size <0-4096:8><#/4> -// Defines the combined stack size for threads with user-provided stack size. -// Default: 0 +// Total stack size [bytes] for threads with user-provided stack size +// <0-4096:8><#/4> Defines the combined stack size for threads with +// user-provided stack size. Default: 0 #ifndef OS_PRIVSTKSIZE - #define OS_PRIVSTKSIZE 0 +#define OS_PRIVSTKSIZE 0 #endif #endif // __MBED_CMSIS_RTOS_CA9 @@ -92,7 +92,7 @@ // Includes the stack checking code for stack overflow. // Note that additional code reduces the Kernel performance. #ifndef OS_STKCHECK - #define OS_STKCHECK 1 +#define OS_STKCHECK 1 #endif // Processor mode for thread execution @@ -100,7 +100,7 @@ // <1=> Privileged mode // Default: Privileged mode #ifndef OS_RUNPRIV - #define OS_RUNPRIV 1 +#define OS_RUNPRIV 1 #endif // @@ -110,25 +110,25 @@ // Use Cortex-M SysTick timer as RTX Kernel Timer // Use the Cortex-M SysTick timer as a time-base for RTX. #ifndef OS_SYSTICK - #define OS_SYSTICK 0 +#define OS_SYSTICK 0 #endif // // Timer clock value [Hz] <1-1000000000> // Defines the timer clock value. // Default: 12000000 (12MHz) #ifndef OS_CLOCK -# if defined(TARGET_RZ_A1H) - #define OS_CLOCK 12000000 -# else -# error "no target defined" -# endif +#if defined(TARGET_RZ_A1H) +#define OS_CLOCK 12000000 +#else +#error "no target defined" +#endif #endif // Timer tick value [us] <1-1000000> // Defines the timer tick value. // Default: 1000 (1ms) #ifndef OS_TICK - #define OS_TICK 1000 +#define OS_TICK 1000 #endif // @@ -141,14 +141,14 @@ // // Enables Round-Robin Thread switching. #ifndef OS_ROBIN - #define OS_ROBIN 1 +#define OS_ROBIN 1 #endif // Round-Robin Timeout [ticks] <1-1000> // Defines how long a thread will execute before a thread switch. // Default: 5 #ifndef OS_ROBINTOUT - #define OS_ROBINTOUT 5 +#define OS_ROBINTOUT 5 #endif // @@ -157,7 +157,7 @@ // ============== // Enables user Timers #ifndef OS_TIMERS - #define OS_TIMERS 1 +#define OS_TIMERS 1 #endif // Timer Thread Priority @@ -168,21 +168,21 @@ // Defines priority for Timer Thread // Default: High #ifndef OS_TIMERPRIO - #define OS_TIMERPRIO 5 +#define OS_TIMERPRIO 5 #endif // Timer Thread stack size [bytes] <64-4096:8><#/4> // Defines stack size for Timer thread. // Default: 200 #ifndef OS_TIMERSTKSZ - #define OS_TIMERSTKSZ WORDS_STACK_SIZE +#define OS_TIMERSTKSZ WORDS_STACK_SIZE #endif // Timer Callback Queue size <1-32> // Number of concurrent active timer callback functions. // Default: 4 #ifndef OS_TIMERCBQS - #define OS_TIMERCBQS 4 +#define OS_TIMERCBQS 4 #endif // @@ -196,7 +196,7 @@ // when they are called from the interrupt handler. // Default: 16 entries #ifndef OS_FIFOSZ - #define OS_FIFOSZ 16 +#define OS_FIFOSZ 16 #endif // @@ -208,15 +208,14 @@ // Define max. number system mutexes that are used to protect // the arm standard runtime library. For microlib they are not used. #ifndef OS_MUTEXCNT - #define OS_MUTEXCNT 12 +#define OS_MUTEXCNT 12 #endif /*---------------------------------------------------------------------------- * RTX User configuration part END *---------------------------------------------------------------------------*/ -#define OS_TRV ((uint32_t)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1) - +#define OS_TRV ((uint32_t)(((double)OS_CLOCK * (double)OS_TICK) / 1E6) - 1) /*---------------------------------------------------------------------------- * Global Functions @@ -224,7 +223,7 @@ /*--------------------------- os_idle_demon ---------------------------------*/ -void os_idle_demon (void) { +void os_idle_demon(void) { /* The idle demon is a system thread, running when no other thread is */ /* ready to run. */ @@ -233,91 +232,86 @@ void os_idle_demon (void) { } } -#if (OS_SYSTICK == 0) // Functions for alternative timer as RTX kernel timer +#if (OS_SYSTICK == 0) // Functions for alternative timer as RTX kernel timer /*--------------------------- os_tick_init ----------------------------------*/ #ifdef TARGET_RZ_A1H -#define OSTM0 (0xFCFEC000uL) /* OSTM0 */ -#define OSTM1 (0xFCFEC400uL) /* OSTM1 */ -#define CPG (0xFCFE0410uL) /* CPG */ +#define OSTM0 (0xFCFEC000uL) /* OSTM0 */ +#define OSTM1 (0xFCFEC400uL) /* OSTM1 */ +#define CPG (0xFCFE0410uL) /* CPG */ -#define CPGSTBCR5 (*((volatile unsigned char*)(CPG + 0x00000018uL))) +#define CPGSTBCR5 (*((volatile unsigned char *)(CPG + 0x00000018uL))) -#define OSTM0CMP (*((volatile unsigned long*)(OSTM0 + 0x00000000uL))) -#define OSTM0CNT (*((volatile unsigned long*)(OSTM0 + 0x00000004uL))) -#define OSTM0TE (*((volatile unsigned char*)(OSTM0 + 0x00000010uL))) -#define OSTM0TS (*((volatile unsigned char*)(OSTM0 + 0x00000014uL))) -#define OSTM0TT (*((volatile unsigned char*)(OSTM0 + 0x00000018uL))) -#define OSTM0CTL (*((volatile unsigned char*)(OSTM0 + 0x00000020uL))) +#define OSTM0CMP (*((volatile unsigned long *)(OSTM0 + 0x00000000uL))) +#define OSTM0CNT (*((volatile unsigned long *)(OSTM0 + 0x00000004uL))) +#define OSTM0TE (*((volatile unsigned char *)(OSTM0 + 0x00000010uL))) +#define OSTM0TS (*((volatile unsigned char *)(OSTM0 + 0x00000014uL))) +#define OSTM0TT (*((volatile unsigned char *)(OSTM0 + 0x00000018uL))) +#define OSTM0CTL (*((volatile unsigned char *)(OSTM0 + 0x00000020uL))) -#define OSTM1CMP (*((volatile unsigned long*)(OSTM1 + 0x00000000uL))) -#define OSTM1CNT (*((volatile unsigned long*)(OSTM1 + 0x00000004uL))) -#define OSTM1TE (*((volatile unsigned char*)(OSTM1 + 0x00000010uL))) -#define OSTM1TS (*((volatile unsigned char*)(OSTM1 + 0x00000014uL))) -#define OSTM1TT (*((volatile unsigned char*)(OSTM1 + 0x00000018uL))) -#define OSTM1CTL (*((volatile unsigned char*)(OSTM1 + 0x00000020uL))) +#define OSTM1CMP (*((volatile unsigned long *)(OSTM1 + 0x00000000uL))) +#define OSTM1CNT (*((volatile unsigned long *)(OSTM1 + 0x00000004uL))) +#define OSTM1TE (*((volatile unsigned char *)(OSTM1 + 0x00000010uL))) +#define OSTM1TS (*((volatile unsigned char *)(OSTM1 + 0x00000014uL))) +#define OSTM1TT (*((volatile unsigned char *)(OSTM1 + 0x00000018uL))) +#define OSTM1CTL (*((volatile unsigned char *)(OSTM1 + 0x00000020uL))) -#define CPG_STBCR5_BIT_MSTP51 (0x02u) /* OSTM0 */ -#define CM1_RENESAS_RZ_A1_P0_CLK ( 32000000u) -#define CM0_RENESAS_RZ_A1_P0_CLK ( 33333333u) +#define CPG_STBCR5_BIT_MSTP51 (0x02u) /* OSTM0 */ +#define CM1_RENESAS_RZ_A1_P0_CLK (32000000u) +#define CM0_RENESAS_RZ_A1_P0_CLK (33333333u) -typedef enum -{ - IRQ_SGI0 = 0, - IRQ_OSTMI0TINT = 134 -} IRQn_Type; +typedef enum { IRQ_SGI0 = 0, IRQ_OSTMI0TINT = 134 } IRQn_Type; -typedef void(*IRQHandler)(); +typedef void (*IRQHandler)(); extern void PendSV_Handler(uint32_t); extern void OS_Tick_Handler(uint32_t); -extern uint32_t InterruptHandlerRegister (IRQn_Type irq, IRQHandler handler); +extern uint32_t InterruptHandlerRegister(IRQn_Type irq, IRQHandler handler); #endif // Initialize alternative hardware timer as RTX kernel timer // Return: IRQ number of the alternative hardware timer -int os_tick_init (void) { +int os_tick_init(void) { #ifdef TARGET_RZ_A1H CPGSTBCR5 &= ~(CPG_STBCR5_BIT_MSTP51); /* enable OSTM0 clock */ - OSTM0TT = 0x1; /* Stop the counter and clears the OSTM0TE bit. */ - OSTM0CTL = 0x1; /* Interval timer mode. Interrupt enabled */ + OSTM0TT = 0x1; /* Stop the counter and clears the OSTM0TE bit. */ + OSTM0CTL = 0x1; /* Interval timer mode. Interrupt enabled */ - OSTM0CMP = (uint32_t)(((double)CM0_RENESAS_RZ_A1_P0_CLK*(double)OS_TICK)/1E6); + OSTM0CMP = + (uint32_t)(((double)CM0_RENESAS_RZ_A1_P0_CLK * (double)OS_TICK) / 1E6); - OSTM0TS = 0x1; /* Start the counter and sets the OSTM0TE bit. */ + OSTM0TS = 0x1; /* Start the counter and sets the OSTM0TE bit. */ - InterruptHandlerRegister(IRQ_SGI0 , (IRQHandler)PendSV_Handler); + InterruptHandlerRegister(IRQ_SGI0, (IRQHandler)PendSV_Handler); InterruptHandlerRegister(IRQ_OSTMI0TINT, (IRQHandler)OS_Tick_Handler); - return IRQ_OSTMI0TINT; /* Return IRQ number of timer (0..239) */ - /* RTX will set and configure the interrupt */ + /* RTX will set and configure the interrupt */ #endif } /*--------------------------- os_tick_irqack --------------------------------*/ // Acknowledge alternative hardware timer interrupt -void os_tick_irqack (void) { - /* ... */ +void os_tick_irqack(void) { /* ... */ } -#endif // (OS_SYSTICK == 0) +#endif // (OS_SYSTICK == 0) /*--------------------------- os_error --------------------------------------*/ extern void mbed_die(void); -void os_error (uint32_t err_code) { +void os_error(uint32_t err_code) { /* This function is called when a runtime error is detected. Parameter */ /* 'err_code' holds the runtime error code (defined in RTL.H). */ - mbed_die(); + mbed_die(); /* HERE: include optional code to be executed on runtime error. */ - for (;;); + for (;;) + ; } - /*---------------------------------------------------------------------------- * RTX Configuration Functions *---------------------------------------------------------------------------*/ diff --git a/rtos/rtx/TARGET_CORTEX_A/TOOLCHAIN_ARM/HAL_CA9.c b/rtos/rtx/TARGET_CORTEX_A/TOOLCHAIN_ARM/HAL_CA9.c index eaca180..a59296a 100644 --- a/rtos/rtx/TARGET_CORTEX_A/TOOLCHAIN_ARM/HAL_CA9.c +++ b/rtos/rtx/TARGET_CORTEX_A/TOOLCHAIN_ARM/HAL_CA9.c @@ -32,385 +32,379 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" #include "RTX_Config.h" -#include "rt_System.h" -#include "rt_Task.h" +#include "rt_HAL_CA.h" #include "rt_List.h" #include "rt_MemBox.h" -#include "rt_HAL_CA.h" - +#include "rt_System.h" +#include "rt_Task.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ -//For A-class, set USR/SYS stack -__asm void rt_set_PSP (U32 stack) { - ARM - - MRS R1, CPSR - CPS #MODE_SYS ;no effect in USR mode - ISB - MOV SP, R0 - MSR CPSR_c, R1 ;no effect in USR mode - ISB - BX LR +// For A-class, set USR/SYS stack +__asm void rt_set_PSP(U32 stack) { + ARM + MRS R1, + CPSR CPS #MODE_SYS; + no effect in USR mode ISB MOV SP, R0 MSR CPSR_c, R1; + no effect in USR mode ISB BX LR } -//For A-class, get USR/SYS stack -__asm U32 rt_get_PSP (void) { - ARM +// For A-class, get USR/SYS stack +__asm U32 rt_get_PSP(void) { + ARM - MRS R1, CPSR - CPS #MODE_SYS ;no effect in USR mode - ISB - MOV R0, SP - MSR CPSR_c, R1 ;no effect in USR mode - ISB - BX LR + MRS R1, + CPSR CPS #MODE_SYS; + no effect in USR mode ISB MOV R0, SP MSR CPSR_c, R1; + no effect in USR mode ISB BX LR } /*--------------------------- _alloc_box ------------------------------------*/ -__asm void *_alloc_box (void *box_mem) { - /* Function wrapper for Unprivileged/Privileged mode. */ - ARM +__asm void *_alloc_box(void *box_mem) { + /* Function wrapper for Unprivileged/Privileged mode. */ + ARM - LDR R12,=__cpp(rt_alloc_box) - MRS R2, CPSR - LSLS R2, #28 - BXNE R12 - SVC 0 - BX LR + LDR R12, + = __cpp(rt_alloc_box) MRS R2, CPSR LSLS R2, #28 BXNE R12 SVC 0 BX LR } - /*--------------------------- _free_box -------------------------------------*/ -__asm int _free_box (void *box_mem, void *box) { - /* Function wrapper for Unprivileged/Privileged mode. */ - ARM - - LDR R12,=__cpp(rt_free_box) - MRS R2, CPSR - LSLS R2, #28 - BXNE R12 - SVC 0 - BX LR +__asm int _free_box(void *box_mem, void *box) { + /* Function wrapper for Unprivileged/Privileged mode. */ + ARM + LDR R12, + = __cpp(rt_free_box) MRS R2, CPSR LSLS R2, #28 BXNE R12 SVC 0 BX LR } /*-------------------------- SVC_Handler -----------------------------------*/ #pragma push #pragma arm -__asm void SVC_Handler (void) { - PRESERVE8 - ARM +__asm void SVC_Handler(void) { + PRESERVE8 + ARM - IMPORT rt_tsk_lock - IMPORT rt_tsk_unlock - IMPORT SVC_Count - IMPORT SVC_Table - IMPORT rt_stk_check - IMPORT FPUEnable + IMPORT rt_tsk_lock IMPORT rt_tsk_unlock IMPORT SVC_Count IMPORT SVC_Table + IMPORT rt_stk_check IMPORT FPUEnable -Mode_SVC EQU 0x13 + Mode_SVC EQU 0x13 - SRSFD SP!, #Mode_SVC ; Push LR_SVC and SPRS_SVC onto SVC mode stack - PUSH {R4} ; Push R4 so we can use it as a temp + SRSFD SP !, +#Mode_SVC; + Push LR_SVC and SPRS_SVC onto SVC mode stack PUSH{R4}; + Push R4 so we can use it as a temp - MRS R4,SPSR ; Get SPSR - TST R4,#CPSR_T_BIT ; Check Thumb Bit - LDRNEH R4,[LR,#-2] ; Thumb: Load Halfword - BICNE R4,R4,#0xFF00 ; Extract SVC Number - LDREQ R4,[LR,#-4] ; ARM: Load Word - BICEQ R4,R4,#0xFF000000 ; Extract SVC Number + MRS R4, + SPSR; + Get SPSR TST R4, #CPSR_T_BIT; + Check Thumb Bit LDRNEH R4, [ LR, # - 2 ]; +Thumb: + Load Halfword BICNE R4, R4, #0xFF00; + Extract SVC Number LDREQ R4, [ LR, # - 4 ]; +ARM: + Load Word BICEQ R4, R4, #0xFF000000; + Extract SVC Number - /* Lock out systick and re-enable interrupts */ - PUSH {R0-R3,R12,LR} + /* Lock out systick and re-enable interrupts */ + PUSH{R0 - R3, R12, LR} - AND R12, SP, #4 ; Ensure stack is 8-byte aligned - SUB SP, SP, R12 ; Adjust stack - PUSH {R12, LR} ; Store stack adjustment and dummy LR to SVC stack + AND R12, + SP, #4; + Ensure stack is 8 - byte aligned SUB SP, SP, R12; + Adjust stack PUSH{R12, LR}; + Store stack adjustment and dummy LR to SVC stack - BLX rt_tsk_lock - CPSIE i + BLX rt_tsk_lock CPSIE i - POP {R12, LR} ; Get stack adjustment & discard dummy LR - ADD SP, SP, R12 ; Unadjust stack + POP{R12, LR}; + Get stack adjustment &discard dummy LR ADD SP, SP, R12; + Unadjust stack - POP {R0-R3,R12,LR} + POP{R0 - R3, R12, LR} - CMP R4,#0 - BNE SVC_User + CMP R4, +# 0 BNE SVC_User - MRS R4,SPSR - PUSH {R4} ; Push R4 so we can use it as a temp - AND R4, SP, #4 ; Ensure stack is 8-byte aligned - SUB SP, SP, R4 ; Adjust stack - PUSH {R4, LR} ; Store stack adjustment and dummy LR - BLX R12 - POP {R4, LR} ; Get stack adjustment & discard dummy LR - ADD SP, SP, R4 ; Unadjust stack - POP {R4} ; Restore R4 - MSR SPSR_CXSF,R4 + MRS R4, SPSR PUSH{R4}; + Push R4 so we can use it as a temp AND R4, SP, #4; + Ensure stack is 8 - byte aligned SUB SP, SP, R4; + Adjust stack PUSH{R4, LR}; + Store stack adjustment and dummy LR BLX R12 POP{R4, LR}; + Get stack adjustment &discard dummy LR ADD SP, SP, R4; + Unadjust stack POP{R4}; + Restore R4 MSR SPSR_CXSF, + R4 - /* Here we will be in SVC mode (even if coming in from PendSV_Handler or OS_Tick_Handler) */ -Sys_Switch - LDR LR,=__cpp(&os_tsk) - LDM LR,{R4,LR} ; os_tsk.run, os_tsk.new - CMP R4,LR - BNE switching + /* Here we will be in SVC mode (even if coming in from PendSV_Handler + or OS_Tick_Handler) */ + Sys_Switch LDR LR, + = __cpp(&os_tsk) LDM LR, {R4, LR}; + os_tsk.run, os_tsk.new CMP R4, + LR BNE switching - PUSH {R0-R3,R12,LR} + PUSH{R0 - R3, R12, LR} - AND R12, SP, #4 ; Ensure stack is 8-byte aligned - SUB SP, SP, R12 ; Adjust stack - PUSH {R12, LR} ; Store stack adjustment and dummy LR to SVC stack + AND R12, + SP, #4; + Ensure stack is 8 - byte aligned SUB SP, SP, R12; + Adjust stack PUSH{R12, LR}; + Store stack adjustment and dummy LR to SVC stack - CPSID i - BLX rt_tsk_unlock + CPSID i BLX rt_tsk_unlock - POP {R12, LR} ; Get stack adjustment & discard dummy LR - ADD SP, SP, R12 ; Unadjust stack + POP{R12, LR}; + Get stack adjustment &discard dummy LR ADD SP, SP, R12; + Unadjust stack - POP {R0-R3,R12,LR} - POP {R4} - RFEFD SP! ; Return from exception, no task switch + POP{R0 - R3, R12, LR} POP{R4} RFEFD SP !; + Return from exception, + no task switch -switching - CLREX - CMP R4,#0 - ADDEQ SP,SP,#12 ; Original R4, LR & SPSR do not need to be popped when we are paging in a different task - BEQ SVC_Next ; Runtask deleted? + switching CLREX CMP R4, +# 0 ADDEQ SP, SP, #12; + Original R4, + LR &SPSR do not need to be popped when we are paging in a different task + BEQ SVC_Next; + Runtask deleted ? + PUSH{R8 - R11} // R4 and LR already stacked + MOV R10, + R4; + Preserve os_tsk.run MOV R11, LR; + Preserve os_tsk.new - PUSH {R8-R11} //R4 and LR already stacked - MOV R10,R4 ; Preserve os_tsk.run - MOV R11,LR ; Preserve os_tsk.new + ADD R8, + SP, #16; + Unstack R4, LR LDMIA R8, + {R4, LR} - ADD R8,SP,#16 ; Unstack R4,LR - LDMIA R8,{R4,LR} + SUB SP, + SP, #4; Make space on the stack for the next instn + STMIA SP,{SP}^ ; + Put User SP onto stack POP{R8}; + Pop User SP into R8 - SUB SP,SP,#4 ; Make space on the stack for the next instn - STMIA SP,{SP}^ ; Put User SP onto stack - POP {R8} ; Pop User SP into R8 + MRS R9, + SPSR STMDB R8 !, {R9}; + User CPSR STMDB R8 !, {LR}; + User PC STMDB R8, {LR} ^ ; + User LR SUB R8, R8, #4; No writeback for store of User LR + STMDB R8!,{R0-R3,R12} ; + User R0 - R3, R12 MOV R3, R10; + os_tsk.run MOV LR, R11; + os_tsk.new POP{R9 - R12} ADD SP, SP, #12; Fix up SP for unstack of R4, LR & SPSR + STMDB R8!,{R4-R7,R9-R12} ; + User R4 - R11 - MRS R9,SPSR - STMDB R8!,{R9} ; User CPSR - STMDB R8!,{LR} ; User PC - STMDB R8,{LR}^ ; User LR - SUB R8,R8,#4 ; No writeback for store of User LR - STMDB R8!,{R0-R3,R12} ; User R0-R3,R12 - MOV R3,R10 ; os_tsk.run - MOV LR,R11 ; os_tsk.new - POP {R9-R12} - ADD SP,SP,#12 ; Fix up SP for unstack of R4, LR & SPSR - STMDB R8!,{R4-R7,R9-R12} ; User R4-R11 + // If applicable, stack VFP state + MRC p15, + 0, R1, c1, c0, 2; + VFP / NEON access enabled ? (CPACR)AND R2, R1, #0x00F00000 CMP R2, +# 0x00F00000 BNE no_outgoing_vfp VMRS R2, FPSCR STMDB R8 !, {R2, R4 }; + Push FPSCR, maintain 8 - byte alignment VSTMDB R8 !, {S0 - S31} LDRB R2, + [ R3, #TCB_STACKF ]; + Record in TCB that VFP state is stacked ORR R2, #2 STRB R2, + [ R3, #TCB_STACKF ] - //If applicable, stack VFP state - MRC p15,0,R1,c1,c0,2 ; VFP/NEON access enabled? (CPACR) - AND R2,R1,#0x00F00000 - CMP R2,#0x00F00000 - BNE no_outgoing_vfp - VMRS R2,FPSCR - STMDB R8!,{R2,R4} ; Push FPSCR, maintain 8-byte alignment - VSTMDB R8!,{S0-S31} - LDRB R2,[R3,#TCB_STACKF] ; Record in TCB that VFP state is stacked - ORR R2,#2 - STRB R2,[R3,#TCB_STACKF] + no_outgoing_vfp STR R8, + [R3, #TCB_TSTACK] MOV R4, + LR -no_outgoing_vfp - STR R8,[R3,#TCB_TSTACK] - MOV R4,LR + PUSH { R4 }; + Push R4 so we can use it as a temp AND R4, SP, #4; + Ensure stack is 8 - byte aligned SUB SP, SP, R4; + Adjust stack PUSH{R4, LR}; + Store stack adjustment and dummy LR to SVC stack - PUSH {R4} ; Push R4 so we can use it as a temp - AND R4, SP, #4 ; Ensure stack is 8-byte aligned - SUB SP, SP, R4 ; Adjust stack - PUSH {R4, LR} ; Store stack adjustment and dummy LR to SVC stack + BLX rt_stk_check - BLX rt_stk_check + POP{R4, LR}; + Get stack adjustment &discard dummy LR ADD SP, SP, R4; + Unadjust stack POP{R4}; + Restore R4 - POP {R4, LR} ; Get stack adjustment & discard dummy LR - ADD SP, SP, R4 ; Unadjust stack - POP {R4} ; Restore R4 + MOV LR, + R4 - MOV LR,R4 + SVC_Next // R4 == os_tsk.run, LR == os_tsk.new, R0-R3, R5-R12 + // corruptible + LDR R1, + = __cpp(&os_tsk); + os_tsk.run = os_tsk.new STR LR, [ R1 ] LDRB R1, [ LR, #TCB_TID ]; + os_tsk.run->task_id LSL R1, #8; + Store PROCID MCR p15, 0, R1, c13, c0, 1; + Write CONTEXTIDR -SVC_Next //R4 == os_tsk.run, LR == os_tsk.new, R0-R3, R5-R12 corruptible - LDR R1,=__cpp(&os_tsk) ; os_tsk.run = os_tsk.new - STR LR,[R1] - LDRB R1,[LR,#TCB_TID] ; os_tsk.run->task_id - LSL R1,#8 ; Store PROCID - MCR p15,0,R1,c13,c0,1 ; Write CONTEXTIDR + LDR R0, + [ LR, #TCB_TSTACK ]; + os_tsk.run->tsk_stack - LDR R0,[LR,#TCB_TSTACK] ; os_tsk.run->tsk_stack + // Does incoming task have VFP state in stack? + LDRB R3, + [ LR, #TCB_STACKF ] TST R3, #0x2 MRC p15, 0, R1, c1, c0, 2; + Read CPACR ANDEQ R1, R1, #0xFF0FFFFF; + Disable VFP access if incoming task does not have stacked VFP state ORRNE R1, + R1, #0x00F00000; + Enable VFP access if incoming task does have stacked VFP state MCR p15, 0, R1, + c1, c0, 2; + Write CPACR BEQ no_incoming_vfp ISB; + We only need the sync if we enabled, + otherwise we will context switch before next VFP instruction anyway VLDMIA + R0 !, + {S0 - S31} LDR R2, [R0] VMSR FPSCR, R2 ADD R0, R0, +# 8 - //Does incoming task have VFP state in stack? - LDRB R3,[LR,#TCB_STACKF] - TST R3,#0x2 - MRC p15,0,R1,c1,c0,2 ; Read CPACR - ANDEQ R1,R1,#0xFF0FFFFF ; Disable VFP access if incoming task does not have stacked VFP state - ORRNE R1,R1,#0x00F00000 ; Enable VFP access if incoming task does have stacked VFP state - MCR p15,0,R1,c1,c0,2 ; Write CPACR - BEQ no_incoming_vfp - ISB ; We only need the sync if we enabled, otherwise we will context switch before next VFP instruction anyway - VLDMIA R0!,{S0-S31} - LDR R2,[R0] - VMSR FPSCR,R2 - ADD R0,R0,#8 + no_incoming_vfp LDR R1, [ R0, #60 ]; + Restore User CPSR MSR SPSR_CXSF, R1 LDMIA R0 !, {R4 - R11}; + Restore User R4 - R11 ADD R0, R0, #4; + Restore User R1 - R3, R12 LDMIA R0 !, {R1 - R3, R12} LDMIA R0, {LR} ^ ; + Restore User LR ADD R0, R0, #4; No writeback for load to user LR + LDMIA R0!,{LR} ; + Restore User PC ADD R0, R0, #4; Correct User SP for unstacked user CPSR -no_incoming_vfp - LDR R1,[R0,#60] ; Restore User CPSR - MSR SPSR_CXSF,R1 - LDMIA R0!,{R4-R11} ; Restore User R4-R11 - ADD R0,R0,#4 ; Restore User R1-R3,R12 - LDMIA R0!,{R1-R3,R12} - LDMIA R0,{LR}^ ; Restore User LR - ADD R0,R0,#4 ; No writeback for load to user LR - LDMIA R0!,{LR} ; Restore User PC - ADD R0,R0,#4 ; Correct User SP for unstacked user CPSR + PUSH {R0} ; + Push R0 onto stack LDMIA SP, {SP} ^ ; + Get R0 off stack into User SP ADD SP, SP, #4; + Put SP back - PUSH {R0} ; Push R0 onto stack - LDMIA SP,{SP}^ ; Get R0 off stack into User SP - ADD SP,SP,#4 ; Put SP back + LDR R0, + [ R0, # - 32 ]; + Restore R0 - LDR R0,[R0,#-32] ; Restore R0 + PUSH{R0 - R3, R12, LR} - PUSH {R0-R3,R12,LR} + AND R12, + SP, #4; + Ensure stack is 8 - byte aligned SUB SP, SP, R12; + Adjust stack PUSH{R12, LR}; + Store stack adjustment and dummy LR to SVC stack - AND R12, SP, #4 ; Ensure stack is 8-byte aligned - SUB SP, SP, R12 ; Adjust stack - PUSH {R12, LR} ; Store stack adjustment and dummy LR to SVC stack + CPSID i BLX rt_tsk_unlock - CPSID i - BLX rt_tsk_unlock + POP{R12, LR}; + Get stack adjustment &discard dummy LR ADD SP, SP, R12; + Unadjust stack - POP {R12, LR} ; Get stack adjustment & discard dummy LR - ADD SP, SP, R12 ; Unadjust stack + POP{R0 - R3, R12, LR} - POP {R0-R3,R12,LR} + MOVS PC, + LR; + Return from exception - MOVS PC,LR ; Return from exception + /*------------------- User SVC -------------------------------*/ - - /*------------------- User SVC -------------------------------*/ - -SVC_User - LDR R12,=SVC_Count - LDR R12,[R12] - CMP R4,R12 ; Check for overflow + SVC_User LDR R12, + = SVC_Count LDR R12, [R12] CMP R4, R12; Check for overflow BHI SVC_Done LDR R12,=SVC_Table-4 - LDR R12,[R12,R4,LSL #2] ; Load SVC Function Address - MRS R4,SPSR ; Save SPSR - PUSH {R4} ; Push R4 so we can use it as a temp - AND R4, SP, #4 ; Ensure stack is 8-byte aligned - SUB SP, SP, R4 ; Adjust stack - PUSH {R4, LR} ; Store stack adjustment and dummy LR - BLX R12 ; Call SVC Function - POP {R4, LR} ; Get stack adjustment & discard dummy LR - ADD SP, SP, R4 ; Unadjust stack - POP {R4} ; Restore R4 - MSR SPSR_CXSF,R4 ; Restore SPSR + LDR R12,[R12,R4,LSL #2] ; + Load SVC Function Address MRS R4, SPSR; + Save SPSR PUSH{R4}; + Push R4 so we can use it as a temp AND R4, SP, #4; + Ensure stack is 8 - byte aligned SUB SP, SP, R4; + Adjust stack PUSH{R4, LR}; + Store stack adjustment and dummy LR BLX R12; + Call SVC Function POP{R4, LR}; + Get stack adjustment &discard dummy LR ADD SP, SP, R4; + Unadjust stack POP{R4}; + Restore R4 MSR SPSR_CXSF, R4; + Restore SPSR -SVC_Done - PUSH {R0-R3,R12,LR} + SVC_Done PUSH{R0 - R3, R12, LR} - PUSH {R4} ; Push R4 so we can use it as a temp - AND R4, SP, #4 ; Ensure stack is 8-byte aligned - SUB SP, SP, R4 ; Adjust stack - PUSH {R4, LR} ; Store stack adjustment and dummy LR + PUSH{R4}; + Push R4 so we can use it as a temp AND R4, SP, #4; + Ensure stack is 8 - byte aligned SUB SP, SP, R4; + Adjust stack PUSH{R4, LR}; + Store stack adjustment and dummy LR - CPSID i - BLX rt_tsk_unlock + CPSID i BLX rt_tsk_unlock - POP {R4, LR} ; Get stack adjustment & discard dummy LR - ADD SP, SP, R4 ; Unadjust stack - POP {R4} ; Restore R4 + POP{R4, LR}; + Get stack adjustment &discard dummy LR ADD SP, SP, R4; + Unadjust stack POP{R4}; + Restore R4 - POP {R0-R3,R12,LR} - POP {R4} - RFEFD SP! ; Return from exception + POP{R0 - R3, R12, LR} POP{R4} RFEFD SP !; + Return from exception } #pragma pop #pragma push #pragma arm -__asm void PendSV_Handler (U32 IRQn) { - ARM +__asm void PendSV_Handler(U32 IRQn) { + ARM - IMPORT rt_tsk_lock - IMPORT IRQNestLevel + IMPORT rt_tsk_lock IMPORT IRQNestLevel - ADD SP,SP,#8 //fix up stack pointer (R0 has been pushed and will never be popped, R1 was pushed for stack alignment) + ADD SP, + SP, +# 8 // fix up stack pointer (R0 has been pushed and will never be popped, \ + // R1 was pushed for stack alignment) - //Disable systick interrupts, then write EOIR. We want interrupts disabled before we enter the context switcher. - PUSH {R0, R1} - BLX rt_tsk_lock - POP {R0, R1} - LDR R1, =__cpp(&GICInterface_BASE) - LDR R1, [R1, #0] - STR R0, [R1, #0x10] + // Disable systick interrupts, then write EOIR. We want interrupts + // disabled before we enter the context switcher. + PUSH{R0, R1} BLX rt_tsk_lock POP{R0, R1} LDR R1, + = __cpp(&GICInterface_BASE) LDR R1, [ R1, #0 ] STR R0, + [ R1, #0x10 ] - LDR R0, =IRQNestLevel ; Get address of nesting counter - LDR R1, [R0] - SUB R1, R1, #1 ; Decrement nesting counter - STR R1, [R0] + LDR R0, + = IRQNestLevel; + Get address of nesting counter LDR R1, [R0] SUB R1, R1, #1; + Decrement nesting counter STR R1, [R0] - BLX __cpp(rt_pop_req) + BLX __cpp(rt_pop_req) - POP {R1, LR} ; Get stack adjustment & discard dummy LR - ADD SP, SP, R1 ; Unadjust stack + POP { R1, LR }; + Get stack adjustment &discard dummy LR ADD SP, SP, R1; + Unadjust stack - LDR R0,[SP,#24] - MSR SPSR_CXSF,R0 - POP {R0-R3,R12} ; Leave SPSR & LR on the stack - PUSH {R4} - B Sys_Switch + LDR R0, + [SP, #24] MSR SPSR_CXSF, R0 POP { R0 - R3, R12 }; + Leave SPSR &LR on the stack PUSH{R4} B Sys_Switch } #pragma pop - #pragma push #pragma arm -__asm void OS_Tick_Handler (U32 IRQn) { - ARM +__asm void OS_Tick_Handler(U32 IRQn) { + ARM - IMPORT rt_tsk_lock - IMPORT IRQNestLevel + IMPORT rt_tsk_lock IMPORT IRQNestLevel - ADD SP,SP,#8 //fix up stack pointer (R0 has been pushed and will never be popped, R1 was pushed for stack alignment) + ADD SP, + SP, +# 8 // fix up stack pointer (R0 has been pushed and will never be popped, \ + // R1 was pushed for stack alignment) - PUSH {R0, R1} - BLX rt_tsk_lock - POP {R0, R1} - LDR R1, =__cpp(&GICInterface_BASE) - LDR R1, [R1, #0] - STR R0, [R1, #0x10] + PUSH{R0, R1} BLX rt_tsk_lock POP{R0, R1} LDR R1, + = __cpp(&GICInterface_BASE) LDR R1, [ R1, #0 ] STR R0, + [ R1, #0x10 ] - LDR R0, =IRQNestLevel ; Get address of nesting counter - LDR R1, [R0] - SUB R1, R1, #1 ; Decrement nesting counter - STR R1, [R0] + LDR R0, + = IRQNestLevel; + Get address of nesting counter LDR R1, [R0] SUB R1, R1, #1; + Decrement nesting counter STR R1, [R0] - BLX __cpp(os_tick_irqack) - BLX __cpp(rt_systick) + BLX __cpp(os_tick_irqack) BLX __cpp(rt_systick) - POP {R1, LR} ; Get stack adjustment & discard dummy LR - ADD SP, SP, R1 ; Unadjust stack + POP { R1, LR }; + Get stack adjustment &discard dummy LR ADD SP, SP, R1; + Unadjust stack - LDR R0,[SP,#24] - MSR SPSR_CXSF,R0 - POP {R0-R3,R12} ; Leave SPSR & LR on the stack - PUSH {R4} - B Sys_Switch + LDR R0, + [SP, #24] MSR SPSR_CXSF, R0 POP { R0 - R3, R12 }; + Leave SPSR &LR on the stack PUSH{R4} B Sys_Switch } #pragma pop - /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ diff --git a/rtos/rtx/TARGET_CORTEX_A/rt_CMSIS.c b/rtos/rtx/TARGET_CORTEX_A/rt_CMSIS.c index 1bd8244..75d924b 100644 --- a/rtos/rtx/TARGET_CORTEX_A/rt_CMSIS.c +++ b/rtos/rtx/TARGET_CORTEX_A/rt_CMSIS.c @@ -36,19 +36,19 @@ #include "cmsis.h" -#include "rt_TypeDef.h" #include "RTX_Config.h" -#include "rt_System.h" -#include "rt_Task.h" #include "rt_Event.h" +#include "rt_HAL_CM.h" #include "rt_List.h" -#include "rt_Time.h" -#include "rt_Mutex.h" -#include "rt_Semaphore.h" #include "rt_Mailbox.h" #include "rt_MemBox.h" #include "rt_Memory.h" -#include "rt_HAL_CM.h" +#include "rt_Mutex.h" +#include "rt_Semaphore.h" +#include "rt_System.h" +#include "rt_Task.h" +#include "rt_Time.h" +#include "rt_TypeDef.h" #define os_thread_cb OS_TCB @@ -64,435 +64,414 @@ #error osWait not supported! #endif - // ==== Enumeration, structures, defines ==== // Service Calls defines -#if defined (__CC_ARM) /* ARM Compiler */ +#if defined(__CC_ARM) /* ARM Compiler */ #define __NO_RETURN __declspec(noreturn) -#define osEvent_type osEvent +#define osEvent_type osEvent #define osEvent_ret_status ret -#define osEvent_ret_value ret -#define osEvent_ret_msg ret -#define osEvent_ret_mail ret +#define osEvent_ret_value ret +#define osEvent_ret_msg ret +#define osEvent_ret_mail ret -#define osCallback_type osCallback -#define osCallback_ret ret +#define osCallback_type osCallback +#define osCallback_ret ret -#define SVC_0_1(f,t,...) \ -__svc_indirect(0) t _##f (t(*)()); \ - t f (void); \ -__attribute__((always_inline)) \ -static __inline t __##f (void) { \ - return _##f(f); \ -} +#define SVC_0_1(f, t, ...) \ + __svc_indirect(0) t _##f(t (*)()); \ + t f(void); \ + __attribute__((always_inline)) static __inline t __##f(void) { \ + return _##f(f); \ + } -#define SVC_1_1(f,t,t1,...) \ -__svc_indirect(0) t _##f (t(*)(t1),t1); \ - t f (t1 a1); \ -__attribute__((always_inline)) \ -static __inline t __##f (t1 a1) { \ - return _##f(f,a1); \ -} +#define SVC_1_1(f, t, t1, ...) \ + __svc_indirect(0) t _##f(t (*)(t1), t1); \ + t f(t1 a1); \ + __attribute__((always_inline)) static __inline t __##f(t1 a1) { \ + return _##f(f, a1); \ + } -#define SVC_2_1(f,t,t1,t2,...) \ -__svc_indirect(0) t _##f (t(*)(t1,t2),t1,t2); \ - t f (t1 a1, t2 a2); \ -__attribute__((always_inline)) \ -static __inline t __##f (t1 a1, t2 a2) { \ - return _##f(f,a1,a2); \ -} +#define SVC_2_1(f, t, t1, t2, ...) \ + __svc_indirect(0) t _##f(t (*)(t1, t2), t1, t2); \ + t f(t1 a1, t2 a2); \ + __attribute__((always_inline)) static __inline t __##f(t1 a1, t2 a2) { \ + return _##f(f, a1, a2); \ + } -#define SVC_3_1(f,t,t1,t2,t3,...) \ -__svc_indirect(0) t _##f (t(*)(t1,t2,t3),t1,t2,t3); \ - t f (t1 a1, t2 a2, t3 a3); \ -__attribute__((always_inline)) \ -static __inline t __##f (t1 a1, t2 a2, t3 a3) { \ - return _##f(f,a1,a2,a3); \ -} +#define SVC_3_1(f, t, t1, t2, t3, ...) \ + __svc_indirect(0) t _##f(t (*)(t1, t2, t3), t1, t2, t3); \ + t f(t1 a1, t2 a2, t3 a3); \ + __attribute__((always_inline)) static __inline t __##f(t1 a1, t2 a2, \ + t3 a3) { \ + return _##f(f, a1, a2, a3); \ + } -#define SVC_4_1(f,t,t1,t2,t3,t4,...) \ -__svc_indirect(0) t _##f (t(*)(t1,t2,t3,t4),t1,t2,t3,t4); \ - t f (t1 a1, t2 a2, t3 a3, t4 a4); \ -__attribute__((always_inline)) \ -static __inline t __##f (t1 a1, t2 a2, t3 a3, t4 a4) { \ - return _##f(f,a1,a2,a3,a4); \ -} +#define SVC_4_1(f, t, t1, t2, t3, t4, ...) \ + __svc_indirect(0) t _##f(t (*)(t1, t2, t3, t4), t1, t2, t3, t4); \ + t f(t1 a1, t2 a2, t3 a3, t4 a4); \ + __attribute__((always_inline)) static __inline t __##f(t1 a1, t2 a2, t3 a3, \ + t4 a4) { \ + return _##f(f, a1, a2, a3, a4); \ + } #define SVC_1_2 SVC_1_1 #define SVC_1_3 SVC_1_1 #define SVC_2_3 SVC_2_1 -#elif defined (__GNUC__) /* GNU Compiler */ +#elif defined(__GNUC__) /* GNU Compiler */ #define __NO_RETURN __attribute__((noreturn)) -typedef uint32_t __attribute__((vector_size(8))) ret64; +typedef uint32_t __attribute__((vector_size(8))) ret64; typedef uint32_t __attribute__((vector_size(16))) ret128; -#define RET_pointer __r0 -#define RET_int32_t __r0 -#define RET_uint32_t __r0 -#define RET_osStatus __r0 +#define RET_pointer __r0 +#define RET_int32_t __r0 +#define RET_uint32_t __r0 +#define RET_osStatus __r0 #define RET_osPriority __r0 -#define RET_osEvent {(osStatus)__r0, {(uint32_t)__r1}, {(void *)__r2}} -#define RET_osCallback {(void *)__r0, (void *)__r1} +#define RET_osEvent \ + { \ + (osStatus) __r0, {(uint32_t)__r1}, { (void *)__r2 } \ + } +#define RET_osCallback \ + { (void *)__r0, (void *)__r1 } -#if defined (__ARM_PCS_VFP) +#if defined(__ARM_PCS_VFP) -#define osEvent_type void -#define osEvent_ret_status { __asm ("MOV r0, %0;" \ - : /* no outputs */ \ - : "r"(ret.status) \ - : "r0" \ - ); \ - } -#define osEvent_ret_value { __asm ("MOV r1, %0;" \ - "MOV r0, %1;" \ - : /* no outputs */ \ - : "r"(ret.value.v), \ - "r"(ret.status) \ - : "r0", "r1" \ - ); \ - } -#define osEvent_ret_msg { __asm ("MOV r2, %0;" \ - "MOV r1, %1;" \ - "MOV r0, %2;" \ - : /* no outputs */ \ - : "r"(ret.def.message_id), \ - "r"(ret.value.v), \ - "r"(ret.status) \ - : "r0", "r1" , "r2" \ - ); \ - } +#define osEvent_type void +#define osEvent_ret_status \ + { \ + __asm("MOV r0, %0;" \ + : /* no outputs */ \ + : "r"(ret.status) \ + : "r0"); \ + } +#define osEvent_ret_value \ + { \ + __asm("MOV r1, %0;" \ + "MOV r0, %1;" \ + : /* no outputs */ \ + : "r"(ret.value.v), "r"(ret.status) \ + : "r0", "r1"); \ + } +#define osEvent_ret_msg \ + { \ + __asm("MOV r2, %0;" \ + "MOV r1, %1;" \ + "MOV r0, %2;" \ + : /* no outputs */ \ + : "r"(ret.def.message_id), "r"(ret.value.v), "r"(ret.status) \ + : "r0", "r1", "r2"); \ + } -#define osEvent_ret_mail { __asm ("MOV r2, %0;" \ - "MOV r1, %1;" \ - "MOV r0, %2;" \ - : /* no outputs */ \ - : "r"(ret.def.mail_id), \ - "r"(ret.value.v), \ - "r"(ret.status) \ - : "r0", "r1" , "r2" \ - ); \ - } +#define osEvent_ret_mail \ + { \ + __asm("MOV r2, %0;" \ + "MOV r1, %1;" \ + "MOV r0, %2;" \ + : /* no outputs */ \ + : "r"(ret.def.mail_id), "r"(ret.value.v), "r"(ret.status) \ + : "r0", "r1", "r2"); \ + } -#define osCallback_type void -#define osCallback_ret { __asm ("MOV r1, %0;" \ - "MOV r0, %1;" \ - : /* no outputs */ \ - : "r"(ret.arg), \ - "r"(ret.fp) \ - : "r0", "r1" \ - ); \ - } +#define osCallback_type void +#define osCallback_ret \ + { \ + __asm("MOV r1, %0;" \ + "MOV r0, %1;" \ + : /* no outputs */ \ + : "r"(ret.arg), "r"(ret.fp) \ + : "r0", "r1"); \ + } #else /* defined (__ARM_PCS_VFP) */ -#define osEvent_type ret128 -#define osEvent_ret_status (ret128){ret.status} -#define osEvent_ret_value (ret128){ret.status, ret.value.v} -#define osEvent_ret_msg (ret128){ret.status, ret.value.v, (uint32_t)ret.def.message_id} -#define osEvent_ret_mail (ret128){ret.status, ret.value.v, (uint32_t)ret.def.mail_id} +#define osEvent_type ret128 +#define osEvent_ret_status \ + (ret128) { ret.status } +#define osEvent_ret_value \ + (ret128) { ret.status, ret.value.v } +#define osEvent_ret_msg \ + (ret128) { ret.status, ret.value.v, (uint32_t)ret.def.message_id } +#define osEvent_ret_mail \ + (ret128) { ret.status, ret.value.v, (uint32_t)ret.def.mail_id } -#define osCallback_type ret64 -#define osCallback_ret (ret64) {(uint32_t)ret.fp, (uint32_t)ret.arg} +#define osCallback_type ret64 +#define osCallback_ret \ + (ret64) { (uint32_t) ret.fp, (uint32_t)ret.arg } #endif /* defined (__ARM_PCS_VFP) */ -#define SVC_ArgN(n) \ - register int __r##n __asm("r"#n); +#define SVC_ArgN(n) register int __r##n __asm("r" #n); -#define SVC_ArgR(n,t,a) \ - register t __r##n __asm("r"#n) = a; +#define SVC_ArgR(n, t, a) register t __r##n __asm("r" #n) = a; -#define SVC_Arg0() \ - SVC_ArgN(0) \ - SVC_ArgN(1) \ - SVC_ArgN(2) \ - SVC_ArgN(3) +#define SVC_Arg0() SVC_ArgN(0) SVC_ArgN(1) SVC_ArgN(2) SVC_ArgN(3) -#define SVC_Arg1(t1) \ - SVC_ArgR(0,t1,a1) \ - SVC_ArgN(1) \ - SVC_ArgN(2) \ - SVC_ArgN(3) +#define SVC_Arg1(t1) SVC_ArgR(0, t1, a1) SVC_ArgN(1) SVC_ArgN(2) SVC_ArgN(3) -#define SVC_Arg2(t1,t2) \ - SVC_ArgR(0,t1,a1) \ - SVC_ArgR(1,t2,a2) \ - SVC_ArgN(2) \ - SVC_ArgN(3) +#define SVC_Arg2(t1, t2) \ + SVC_ArgR(0, t1, a1) SVC_ArgR(1, t2, a2) SVC_ArgN(2) SVC_ArgN(3) -#define SVC_Arg3(t1,t2,t3) \ - SVC_ArgR(0,t1,a1) \ - SVC_ArgR(1,t2,a2) \ - SVC_ArgR(2,t3,a3) \ - SVC_ArgN(3) +#define SVC_Arg3(t1, t2, t3) \ + SVC_ArgR(0, t1, a1) SVC_ArgR(1, t2, a2) SVC_ArgR(2, t3, a3) SVC_ArgN(3) -#define SVC_Arg4(t1,t2,t3,t4) \ - SVC_ArgR(0,t1,a1) \ - SVC_ArgR(1,t2,a2) \ - SVC_ArgR(2,t3,a3) \ - SVC_ArgR(3,t4,a4) +#define SVC_Arg4(t1, t2, t3, t4) \ + SVC_ArgR(0, t1, a1) SVC_ArgR(1, t2, a2) SVC_ArgR(2, t3, a3) \ + SVC_ArgR(3, t4, a4) -#if (defined (__CORTEX_M0)) +#if (defined(__CORTEX_M0)) #define SVC_Call(f) \ - __asm volatile \ - ( \ - "ldr r7,="#f"\n\t" \ - "mov r12,r7\n\t" \ - "svc 0" \ - : "=r" (__r0), "=r" (__r1), "=r" (__r2), "=r" (__r3) \ - : "r" (__r0), "r" (__r1), "r" (__r2), "r" (__r3) \ - : "r7", "r12", "lr", "cc" \ - ); + __asm volatile("ldr r7,=" #f "\n\t" \ + "mov r12,r7\n\t" \ + "svc 0" \ + : "=r"(__r0), "=r"(__r1), "=r"(__r2), "=r"(__r3) \ + : "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3) \ + : "r7", "r12", "lr", "cc"); #else #define SVC_Call(f) \ - __asm volatile \ - ( \ - "ldr r12,="#f"\n\t" \ - "svc 0" \ - : "=r" (__r0), "=r" (__r1), "=r" (__r2), "=r" (__r3) \ - : "r" (__r0), "r" (__r1), "r" (__r2), "r" (__r3) \ - : "r12", "lr", "cc" \ - ); + __asm volatile("ldr r12,=" #f "\n\t" \ + "svc 0" \ + : "=r"(__r0), "=r"(__r1), "=r"(__r2), "=r"(__r3) \ + : "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3) \ + : "r12", "lr", "cc"); #endif -#define SVC_0_1(f,t,rv) \ -__attribute__((always_inline)) \ -static inline t __##f (void) { \ - SVC_Arg0(); \ - SVC_Call(f); \ - return (t) rv; \ -} +#define SVC_0_1(f, t, rv) \ + __attribute__((always_inline)) static inline t __##f(void) { \ + SVC_Arg0(); \ + SVC_Call(f); \ + return (t)rv; \ + } -#define SVC_1_1(f,t,t1,rv) \ -__attribute__((always_inline)) \ -static inline t __##f (t1 a1) { \ - SVC_Arg1(t1); \ - SVC_Call(f); \ - return (t) rv; \ -} +#define SVC_1_1(f, t, t1, rv) \ + __attribute__((always_inline)) static inline t __##f(t1 a1) { \ + SVC_Arg1(t1); \ + SVC_Call(f); \ + return (t)rv; \ + } -#define SVC_2_1(f,t,t1,t2,rv) \ -__attribute__((always_inline)) \ -static inline t __##f (t1 a1, t2 a2) { \ - SVC_Arg2(t1,t2); \ - SVC_Call(f); \ - return (t) rv; \ -} +#define SVC_2_1(f, t, t1, t2, rv) \ + __attribute__((always_inline)) static inline t __##f(t1 a1, t2 a2) { \ + SVC_Arg2(t1, t2); \ + SVC_Call(f); \ + return (t)rv; \ + } -#define SVC_3_1(f,t,t1,t2,t3,rv) \ -__attribute__((always_inline)) \ -static inline t __##f (t1 a1, t2 a2, t3 a3) { \ - SVC_Arg3(t1,t2,t3); \ - SVC_Call(f); \ - return (t) rv; \ -} +#define SVC_3_1(f, t, t1, t2, t3, rv) \ + __attribute__((always_inline)) static inline t __##f(t1 a1, t2 a2, t3 a3) { \ + SVC_Arg3(t1, t2, t3); \ + SVC_Call(f); \ + return (t)rv; \ + } -#define SVC_4_1(f,t,t1,t2,t3,t4,rv) \ -__attribute__((always_inline)) \ -static inline t __##f (t1 a1, t2 a2, t3 a3, t4 a4) { \ - SVC_Arg4(t1,t2,t3,t4); \ - SVC_Call(f); \ - return (t) rv; \ -} +#define SVC_4_1(f, t, t1, t2, t3, t4, rv) \ + __attribute__((always_inline)) static inline t __##f(t1 a1, t2 a2, t3 a3, \ + t4 a4) { \ + SVC_Arg4(t1, t2, t3, t4); \ + SVC_Call(f); \ + return (t)rv; \ + } #define SVC_1_2 SVC_1_1 #define SVC_1_3 SVC_1_1 #define SVC_2_3 SVC_2_1 -#elif defined (__ICCARM__) /* IAR Compiler */ +#elif defined(__ICCARM__) /* IAR Compiler */ #define __NO_RETURN __noreturn -#define RET_osEvent "=r"(ret.status), "=r"(ret.value), "=r"(ret.def) -#define RET_osCallback "=r"(ret.fp), "=r"(ret.arg) +#define RET_osEvent "=r"(ret.status), "=r"(ret.value), "=r"(ret.def) +#define RET_osCallback "=r"(ret.fp), "=r"(ret.arg) -#define osEvent_type osEvent +#define osEvent_type osEvent #define osEvent_ret_status ret -#define osEvent_ret_value ret -#define osEvent_ret_msg ret -#define osEvent_ret_mail ret +#define osEvent_ret_value ret +#define osEvent_ret_msg ret +#define osEvent_ret_mail ret -#define osCallback_type uint64_t -#define osCallback_ret ((uint64_t)ret.fp | ((uint64_t)ret.arg)<<32) +#define osCallback_type uint64_t +#define osCallback_ret ((uint64_t)ret.fp | ((uint64_t)ret.arg) << 32) -#define SVC_Setup(f) \ - __asm( \ - "mov r12,%0\n" \ - :: "r"(&f): "r12" \ - ); +#define SVC_Setup(f) __asm("mov r12,%0\n" ::"r"(&f) : "r12"); #define SVC_Ret3() \ - __asm( \ - "ldr r0,[sp,#0]\n" \ - "ldr r1,[sp,#4]\n" \ - "ldr r2,[sp,#8]\n" \ - ); + __asm("ldr r0,[sp,#0]\n" \ + "ldr r1,[sp,#4]\n" \ + "ldr r2,[sp,#8]\n"); -#define SVC_0_1(f,t,...) \ -t f (void); \ -_Pragma("swi_number=0") __swi t _##f (void); \ -static inline t __##f (void) { \ - SVC_Setup(f); \ - return _##f(); \ -} +#define SVC_0_1(f, t, ...) \ + t f(void); \ + _Pragma("swi_number=0") __swi t _##f(void); \ + static inline t __##f(void) { \ + SVC_Setup(f); \ + return _##f(); \ + } -#define SVC_1_1(f,t,t1,...) \ -t f (t1 a1); \ -_Pragma("swi_number=0") __swi t _##f (t1 a1); \ -static inline t __##f (t1 a1) { \ - SVC_Setup(f); \ - return _##f(a1); \ -} +#define SVC_1_1(f, t, t1, ...) \ + t f(t1 a1); \ + _Pragma("swi_number=0") __swi t _##f(t1 a1); \ + static inline t __##f(t1 a1) { \ + SVC_Setup(f); \ + return _##f(a1); \ + } -#define SVC_2_1(f,t,t1,t2,...) \ -t f (t1 a1, t2 a2); \ -_Pragma("swi_number=0") __swi t _##f (t1 a1, t2 a2); \ -static inline t __##f (t1 a1, t2 a2) { \ - SVC_Setup(f); \ - return _##f(a1,a2); \ -} +#define SVC_2_1(f, t, t1, t2, ...) \ + t f(t1 a1, t2 a2); \ + _Pragma("swi_number=0") __swi t _##f(t1 a1, t2 a2); \ + static inline t __##f(t1 a1, t2 a2) { \ + SVC_Setup(f); \ + return _##f(a1, a2); \ + } -#define SVC_3_1(f,t,t1,t2,t3,...) \ -t f (t1 a1, t2 a2, t3 a3); \ -_Pragma("swi_number=0") __swi t _##f (t1 a1, t2 a2, t3 a3); \ -static inline t __##f (t1 a1, t2 a2, t3 a3) { \ - SVC_Setup(f); \ - return _##f(a1,a2,a3); \ -} +#define SVC_3_1(f, t, t1, t2, t3, ...) \ + t f(t1 a1, t2 a2, t3 a3); \ + _Pragma("swi_number=0") __swi t _##f(t1 a1, t2 a2, t3 a3); \ + static inline t __##f(t1 a1, t2 a2, t3 a3) { \ + SVC_Setup(f); \ + return _##f(a1, a2, a3); \ + } -#define SVC_4_1(f,t,t1,t2,t3,t4,...) \ -t f (t1 a1, t2 a2, t3 a3, t4 a4); \ -_Pragma("swi_number=0") __swi t _##f (t1 a1, t2 a2, t3 a3, t4 a4); \ -static inline t __##f (t1 a1, t2 a2, t3 a3, t4 a4) { \ - SVC_Setup(f); \ - return _##f(a1,a2,a3,a4); \ -} +#define SVC_4_1(f, t, t1, t2, t3, t4, ...) \ + t f(t1 a1, t2 a2, t3 a3, t4 a4); \ + _Pragma("swi_number=0") __swi t _##f(t1 a1, t2 a2, t3 a3, t4 a4); \ + static inline t __##f(t1 a1, t2 a2, t3 a3, t4 a4) { \ + SVC_Setup(f); \ + return _##f(a1, a2, a3, a4); \ + } -#define SVC_1_2(f,t,t1,rr) \ -uint64_t f (t1 a1); \ -_Pragma("swi_number=0") __swi uint64_t _##f (t1 a1); \ -static inline t __##f (t1 a1) { \ - t ret; \ - SVC_Setup(f); \ - _##f(a1); \ - __asm("" : rr : :); \ - return ret; \ -} +#define SVC_1_2(f, t, t1, rr) \ + uint64_t f(t1 a1); \ + _Pragma("swi_number=0") __swi uint64_t _##f(t1 a1); \ + static inline t __##f(t1 a1) { \ + t ret; \ + SVC_Setup(f); \ + _##f(a1); \ + __asm("" : rr : :); \ + return ret; \ + } -#define SVC_1_3(f,t,t1,rr) \ -t f (t1 a1); \ -void f##_ (t1 a1) { \ - f(a1); \ - SVC_Ret3(); \ -} \ -_Pragma("swi_number=0") __swi void _##f (t1 a1); \ -static inline t __##f (t1 a1) { \ - t ret; \ - SVC_Setup(f##_); \ - _##f(a1); \ - __asm("" : rr : :); \ - return ret; \ -} +#define SVC_1_3(f, t, t1, rr) \ + t f(t1 a1); \ + void f##_(t1 a1) { \ + f(a1); \ + SVC_Ret3(); \ + } \ + _Pragma("swi_number=0") __swi void _##f(t1 a1); \ + static inline t __##f(t1 a1) { \ + t ret; \ + SVC_Setup(f##_); \ + _##f(a1); \ + __asm("" : rr : :); \ + return ret; \ + } -#define SVC_2_3(f,t,t1,t2,rr) \ -t f (t1 a1, t2 a2); \ -void f##_ (t1 a1, t2 a2) { \ - f(a1,a2); \ - SVC_Ret3(); \ -} \ -_Pragma("swi_number=0") __swi void _##f (t1 a1, t2 a2); \ -static inline t __##f (t1 a1, t2 a2) { \ - t ret; \ - SVC_Setup(f##_); \ - _##f(a1,a2); \ - __asm("" : rr : :); \ - return ret; \ -} +#define SVC_2_3(f, t, t1, t2, rr) \ + t f(t1 a1, t2 a2); \ + void f##_(t1 a1, t2 a2) { \ + f(a1, a2); \ + SVC_Ret3(); \ + } \ + _Pragma("swi_number=0") __swi void _##f(t1 a1, t2 a2); \ + static inline t __##f(t1 a1, t2 a2) { \ + t ret; \ + SVC_Setup(f##_); \ + _##f(a1, a2); \ + __asm("" : rr : :); \ + return ret; \ + } #endif - // Callback structure typedef struct { - void *fp; // Function pointer - void *arg; // Function argument + void *fp; // Function pointer + void *arg; // Function argument } osCallback; - // OS Section definitions #ifdef OS_SECTIONS_LINK_INFO -extern const uint32_t os_section_id$$Base; -extern const uint32_t os_section_id$$Limit; +extern const uint32_t os_section_id$$Base; +extern const uint32_t os_section_id$$Limit; #endif #ifndef __MBED_CMSIS_RTOS_CA9 // OS Stack Memory for Threads definitions -extern uint64_t os_stack_mem[]; -extern const uint32_t os_stack_sz; +extern uint64_t os_stack_mem[]; +extern const uint32_t os_stack_sz; #endif // OS Timers external resources -extern const osThreadDef_t os_thread_def_osTimerThread; -extern osThreadId osThreadId_osTimerThread; +extern const osThreadDef_t os_thread_def_osTimerThread; +extern osThreadId osThreadId_osTimerThread; extern const osMessageQDef_t os_messageQ_def_osTimerMessageQ; -extern osMessageQId osMessageQId_osTimerMessageQ; - -extern U32 IRQNestLevel; /* Indicates whether inside an ISR, and the depth of nesting. 0 = not in ISR. */ +extern osMessageQId osMessageQId_osTimerMessageQ; +extern U32 IRQNestLevel; /* Indicates whether inside an ISR, and the depth of + nesting. 0 = not in ISR. */ // ==== Helper Functions ==== /// Convert timeout in millisec to system ticks -static uint32_t rt_ms2tick (uint32_t millisec) { +static uint32_t rt_ms2tick(uint32_t millisec) { uint32_t tick; - if (millisec == osWaitForever) return 0xFFFF; // Indefinite timeout - if (millisec > 4000000) return 0xFFFE; // Max ticks supported + if (millisec == osWaitForever) + return 0xFFFF; // Indefinite timeout + if (millisec > 4000000) + return 0xFFFE; // Max ticks supported - tick = ((1000 * millisec) + os_clockrate - 1) / os_clockrate; - if (tick > 0xFFFE) return 0xFFFE; + tick = ((1000 * millisec) + os_clockrate - 1) / os_clockrate; + if (tick > 0xFFFE) + return 0xFFFE; return tick; } /// Convert Thread ID to TCB pointer -static P_TCB rt_tid2ptcb (osThreadId thread_id) { +static P_TCB rt_tid2ptcb(osThreadId thread_id) { P_TCB ptcb; - if (thread_id == NULL) return NULL; + if (thread_id == NULL) + return NULL; - if ((uint32_t)thread_id & 3) return NULL; + if ((uint32_t)thread_id & 3) + return NULL; #ifdef OS_SECTIONS_LINK_INFO if ((os_section_id$$Base != 0) && (os_section_id$$Limit != 0)) { - if (thread_id < (osThreadId)os_section_id$$Base) return NULL; - if (thread_id >= (osThreadId)os_section_id$$Limit) return NULL; + if (thread_id < (osThreadId)os_section_id$$Base) + return NULL; + if (thread_id >= (osThreadId)os_section_id$$Limit) + return NULL; } #endif ptcb = thread_id; - if (ptcb->cb_type != TCB) return NULL; + if (ptcb->cb_type != TCB) + return NULL; return ptcb; } /// Convert ID pointer to Object pointer -static void *rt_id2obj (void *id) { +static void *rt_id2obj(void *id) { - if ((uint32_t)id & 3) return NULL; + if ((uint32_t)id & 3) + return NULL; #ifdef OS_SECTIONS_LINK_INFO if ((os_section_id$$Base != 0) && (os_section_id$$Limit != 0)) { - if (id < (void *)os_section_id$$Base) return NULL; - if (id >= (void *)os_section_id$$Limit) return NULL; + if (id < (void *)os_section_id$$Base) + return NULL; + if (id >= (void *)os_section_id$$Limit) + return NULL; } #endif @@ -501,46 +480,45 @@ static void *rt_id2obj (void *id) { // === Helper functions for system call interface === -static __inline char __get_mode(void) { - return (char)(__get_CPSR() & 0x1f); -} +static __inline char __get_mode(void) { return (char)(__get_CPSR() & 0x1f); } static __inline char __exceptional_mode(void) { - switch(__get_mode()) { - case MODE_USR: - case MODE_SYS: - return 0; - case MODE_SVC: - if (IRQNestLevel == 0) - return 0; /* handling a regular service call */ - else - return 1; /* handling an ISR in SVC mode */ - default: - return 1; - } + switch (__get_mode()) { + case MODE_USR: + case MODE_SYS: + return 0; + case MODE_SVC: + if (IRQNestLevel == 0) + return 0; /* handling a regular service call */ + else + return 1; /* handling an ISR in SVC mode */ + default: + return 1; + } } // ==== Kernel Control ==== -uint8_t os_initialized; // Kernel Initialized flag -uint8_t os_running; // Kernel Running flag +uint8_t os_initialized; // Kernel Initialized flag +uint8_t os_running; // Kernel Running flag // Kernel Control Service Calls declarations SVC_0_1(svcKernelInitialize, osStatus, RET_osStatus) -SVC_0_1(svcKernelStart, osStatus, RET_osStatus) -SVC_0_1(svcKernelRunning, int32_t, RET_int32_t) +SVC_0_1(svcKernelStart, osStatus, RET_osStatus) +SVC_0_1(svcKernelRunning, int32_t, RET_int32_t) -static void sysThreadError (osStatus status); -osThreadId svcThreadCreate (const osThreadDef_t *thread_def, void *argument); -osMessageQId svcMessageCreate (const osMessageQDef_t *queue_def, osThreadId thread_id); +static void sysThreadError(osStatus status); +osThreadId svcThreadCreate(const osThreadDef_t *thread_def, void *argument); +osMessageQId svcMessageCreate(const osMessageQDef_t *queue_def, + osThreadId thread_id); // Kernel Control Service Calls /// Initialize the RTOS Kernel for creating objects -osStatus svcKernelInitialize (void) { +osStatus svcKernelInitialize(void) { #ifdef __MBED_CMSIS_RTOS_CA9 if (!os_initialized) { - rt_sys_init(); // RTX System Initialization + rt_sys_init(); // RTX System Initialization } #else int ret; @@ -548,20 +526,24 @@ osStatus svcKernelInitialize (void) { if (!os_initialized) { // Init Thread Stack Memory (must be 8-byte aligned) - if ((uint32_t)os_stack_mem & 7) return osErrorNoMemory; + if ((uint32_t)os_stack_mem & 7) + return osErrorNoMemory; ret = rt_init_mem(os_stack_mem, os_stack_sz); - if (ret != 0) return osErrorNoMemory; + if (ret != 0) + return osErrorNoMemory; - rt_sys_init(); // RTX System Initialization + rt_sys_init(); // RTX System Initialization } #endif - os_tsk.run->prio = 255; // Highest priority + os_tsk.run->prio = 255; // Highest priority if (!os_initialized) { // Create OS Timers resources (Message Queue & Thread) - osMessageQId_osTimerMessageQ = svcMessageCreate (&os_messageQ_def_osTimerMessageQ, NULL); - osThreadId_osTimerThread = svcThreadCreate(&os_thread_def_osTimerThread, NULL); + osMessageQId_osTimerMessageQ = + svcMessageCreate(&os_messageQ_def_osTimerMessageQ, NULL); + osThreadId_osTimerThread = + svcThreadCreate(&os_thread_def_osTimerThread, NULL); } sysThreadError(osOK); @@ -572,13 +554,14 @@ osStatus svcKernelInitialize (void) { } /// Start the RTOS Kernel -osStatus svcKernelStart (void) { +osStatus svcKernelStart(void) { - if (os_running) return osOK; + if (os_running) + return osOK; - rt_tsk_prio(0, 0); // Lowest priority - __set_PSP(os_tsk.run->tsk_stack + 8*4); // New context - os_tsk.run = NULL; // Force context switch + rt_tsk_prio(0, 0); // Lowest priority + __set_PSP(os_tsk.run->tsk_stack + 8 * 4); // New context + os_tsk.run = NULL; // Force context switch rt_sys_start(); @@ -588,78 +571,76 @@ osStatus svcKernelStart (void) { } /// Check if the RTOS kernel is already started -int32_t svcKernelRunning(void) { - return os_running; -} +int32_t svcKernelRunning(void) { return os_running; } // Kernel Control Public API /// Initialize the RTOS Kernel for creating objects -osStatus osKernelInitialize (void) { - if (__exceptional_mode()) return osErrorISR; // Not allowed in ISR +osStatus osKernelInitialize(void) { + if (__exceptional_mode()) + return osErrorISR; // Not allowed in ISR if (__get_mode() != MODE_USR) { - return svcKernelInitialize(); + return svcKernelInitialize(); } else { return __svcKernelInitialize(); } } /// Start the RTOS Kernel -osStatus osKernelStart (void) { +osStatus osKernelStart(void) { char mode = __get_mode(); - switch(mode) { - case MODE_USR: - if (os_flags & 1) return osErrorOS; // Privileged Thread mode requested from Unprivileged - break; - case MODE_SYS: - if (!(os_flags & 1)) { - __set_CPS_USR(); - } - break; - default: - return osErrorISR; // Not allowed in ISR + switch (mode) { + case MODE_USR: + if (os_flags & 1) + return osErrorOS; // Privileged Thread mode requested from Unprivileged + break; + case MODE_SYS: + if (!(os_flags & 1)) { + __set_CPS_USR(); + } + break; + default: + return osErrorISR; // Not allowed in ISR } return __svcKernelStart(); } /// Check if the RTOS kernel is already started int32_t osKernelRunning(void) { - if(__get_mode() != MODE_USR) { + if (__get_mode() != MODE_USR) { return os_running; } else { return __svcKernelRunning(); } } - // ==== Thread Management ==== /// Set Thread Error (for Create functions which return IDs) -static void sysThreadError (osStatus status) { +static void sysThreadError(osStatus status) { // To Do } -__NO_RETURN void osThreadExit (void); +__NO_RETURN void osThreadExit(void); // Thread Service Calls declarations -SVC_2_1(svcThreadCreate, osThreadId, const osThreadDef_t *, void *, RET_pointer) -SVC_0_1(svcThreadGetId, osThreadId, RET_pointer) -SVC_1_1(svcThreadTerminate, osStatus, osThreadId, RET_osStatus) -SVC_0_1(svcThreadYield, osStatus, RET_osStatus) -SVC_2_1(svcThreadSetPriority, osStatus, osThreadId, osPriority, RET_osStatus) -SVC_1_1(svcThreadGetPriority, osPriority, osThreadId, RET_osPriority) +SVC_2_1(svcThreadCreate, osThreadId, const osThreadDef_t *, void *, RET_pointer) +SVC_0_1(svcThreadGetId, osThreadId, RET_pointer) +SVC_1_1(svcThreadTerminate, osStatus, osThreadId, RET_osStatus) +SVC_0_1(svcThreadYield, osStatus, RET_osStatus) +SVC_2_1(svcThreadSetPriority, osStatus, osThreadId, osPriority, RET_osStatus) +SVC_1_1(svcThreadGetPriority, osPriority, osThreadId, RET_osPriority) // Thread Service Calls /// Create a thread and add it to Active Threads and set it to state READY -osThreadId svcThreadCreate (const osThreadDef_t *thread_def, void *argument) { - P_TCB ptcb; +osThreadId svcThreadCreate(const osThreadDef_t *thread_def, void *argument) { + P_TCB ptcb; OS_TID tsk; - void *stk; + void *stk; - if ((thread_def == NULL) || - (thread_def->pthread == NULL) || + if ((thread_def == NULL) || (thread_def->pthread == NULL) || (thread_def->tpriority < osPriorityIdle) || (thread_def->tpriority > osPriorityRealtime)) { sysThreadError(osErrorParameter); @@ -667,45 +648,43 @@ osThreadId svcThreadCreate (const osThreadDef_t *thread_def, void *argument) { } #ifdef __MBED_CMSIS_RTOS_CA9 - if (thread_def->stacksize != 0) { // Custom stack size + if (thread_def->stacksize != 0) { // Custom stack size stk = (void *)thread_def->stack_pointer; - } else { // Default stack size + } else { // Default stack size stk = NULL; } #else - if (thread_def->stacksize != 0) { // Custom stack size - stk = rt_alloc_mem( // Allocate stack - os_stack_mem, - thread_def->stacksize - ); + if (thread_def->stacksize != 0) { // Custom stack size + stk = rt_alloc_mem( // Allocate stack + os_stack_mem, thread_def->stacksize); if (stk == NULL) { - sysThreadError(osErrorNoMemory); // Out of memory + sysThreadError(osErrorNoMemory); // Out of memory return NULL; } - } else { // Default stack size + } else { // Default stack size stk = NULL; } #endif - tsk = rt_tsk_create( // Create task - (FUNCP)thread_def->pthread, // Task function pointer - (thread_def->tpriority-osPriorityIdle+1) | // Task priority - (thread_def->stacksize << 8), // Task stack size in bytes - stk, // Pointer to task's stack - argument // Argument to the task + tsk = rt_tsk_create( // Create task + (FUNCP)thread_def->pthread, // Task function pointer + (thread_def->tpriority - osPriorityIdle + 1) | // Task priority + (thread_def->stacksize << 8), // Task stack size in bytes + stk, // Pointer to task's stack + argument // Argument to the task ); - if (tsk == 0) { // Invalid task ID + if (tsk == 0) { // Invalid task ID #ifndef __MBED_CMSIS_RTOS_CA9 if (stk != NULL) { - rt_free_mem(os_stack_mem, stk); // Free allocated stack + rt_free_mem(os_stack_mem, stk); // Free allocated stack } #endif - sysThreadError(osErrorNoMemory); // Create task failed (Out of memory) + sysThreadError(osErrorNoMemory); // Create task failed (Out of memory) return NULL; } - ptcb = (P_TCB)os_active_TCB[tsk - 1]; // TCB pointer + ptcb = (P_TCB)os_active_TCB[tsk - 1]; // TCB pointer *((uint32_t *)ptcb->tsk_stack + 13) = (uint32_t)osThreadExit; @@ -713,36 +692,39 @@ osThreadId svcThreadCreate (const osThreadDef_t *thread_def, void *argument) { } /// Return the thread ID of the current running thread -osThreadId svcThreadGetId (void) { +osThreadId svcThreadGetId(void) { OS_TID tsk; tsk = rt_tsk_self(); - if (tsk == 0) return NULL; + if (tsk == 0) + return NULL; return (P_TCB)os_active_TCB[tsk - 1]; } /// Terminate execution of a thread and remove it from ActiveThreads -osStatus svcThreadTerminate (osThreadId thread_id) { +osStatus svcThreadTerminate(osThreadId thread_id) { OS_RESULT res; - P_TCB ptcb; + P_TCB ptcb; #ifndef __MBED_CMSIS_RTOS_CA9 - void *stk; + void *stk; #endif - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return osErrorParameter; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return osErrorParameter; #ifndef __MBED_CMSIS_RTOS_CA9 - stk = ptcb->priv_stack ? ptcb->stack : NULL; // Private stack + stk = ptcb->priv_stack ? ptcb->stack : NULL; // Private stack #endif - res = rt_tsk_delete(ptcb->task_id); // Delete task + res = rt_tsk_delete(ptcb->task_id); // Delete task - if (res == OS_R_NOK) return osErrorResource; // Delete task failed + if (res == OS_R_NOK) + return osErrorResource; // Delete task failed #ifndef __MBED_CMSIS_RTOS_CA9 if (stk != NULL) { - rt_free_mem(os_stack_mem, stk); // Free private stack + rt_free_mem(os_stack_mem, stk); // Free private stack } #endif @@ -750,103 +732,114 @@ osStatus svcThreadTerminate (osThreadId thread_id) { } /// Pass control to next thread that is in state READY -osStatus svcThreadYield (void) { - rt_tsk_pass(); // Pass control to next task +osStatus svcThreadYield(void) { + rt_tsk_pass(); // Pass control to next task return osOK; } /// Change priority of an active thread -osStatus svcThreadSetPriority (osThreadId thread_id, osPriority priority) { +osStatus svcThreadSetPriority(osThreadId thread_id, osPriority priority) { OS_RESULT res; - P_TCB ptcb; + P_TCB ptcb; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return osErrorParameter; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return osErrorParameter; if ((priority < osPriorityIdle) || (priority > osPriorityRealtime)) { return osErrorValue; } - res = rt_tsk_prio( // Change task priority - ptcb->task_id, // Task ID - priority - osPriorityIdle + 1 // New task priority + res = rt_tsk_prio( // Change task priority + ptcb->task_id, // Task ID + priority - osPriorityIdle + 1 // New task priority ); - if (res == OS_R_NOK) return osErrorResource; // Change task priority failed + if (res == OS_R_NOK) + return osErrorResource; // Change task priority failed return osOK; } /// Get current priority of an active thread -osPriority svcThreadGetPriority (osThreadId thread_id) { +osPriority svcThreadGetPriority(osThreadId thread_id) { P_TCB ptcb; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return osPriorityError; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return osPriorityError; return (osPriority)(ptcb->prio - 1 + osPriorityIdle); } - // Thread Public API /// Create a thread and add it to Active Threads and set it to state READY -osThreadId osThreadCreate (const osThreadDef_t *thread_def, void *argument) { - if (__exceptional_mode()) return NULL; // Not allowed in ISR +osThreadId osThreadCreate(const osThreadDef_t *thread_def, void *argument) { + if (__exceptional_mode()) + return NULL; // Not allowed in ISR if ((__get_mode() != MODE_USR) && (os_running == 0)) { // Privileged and not running - return svcThreadCreate(thread_def, argument); + return svcThreadCreate(thread_def, argument); } else { return __svcThreadCreate(thread_def, argument); } } /// Return the thread ID of the current running thread -osThreadId osThreadGetId (void) { - if (__exceptional_mode()) return NULL; // Not allowed in ISR +osThreadId osThreadGetId(void) { + if (__exceptional_mode()) + return NULL; // Not allowed in ISR return __svcThreadGetId(); } /// Terminate execution of a thread and remove it from ActiveThreads -osStatus osThreadTerminate (osThreadId thread_id) { - if (__exceptional_mode()) return osErrorISR; // Not allowed in ISR +osStatus osThreadTerminate(osThreadId thread_id) { + if (__exceptional_mode()) + return osErrorISR; // Not allowed in ISR return __svcThreadTerminate(thread_id); } /// Pass control to next thread that is in state READY -osStatus osThreadYield (void) { - if (__exceptional_mode()) return osErrorISR; // Not allowed in ISR +osStatus osThreadYield(void) { + if (__exceptional_mode()) + return osErrorISR; // Not allowed in ISR return __svcThreadYield(); } /// Change priority of an active thread -osStatus osThreadSetPriority (osThreadId thread_id, osPriority priority) { - if (__exceptional_mode()) return osErrorISR; // Not allowed in ISR +osStatus osThreadSetPriority(osThreadId thread_id, osPriority priority) { + if (__exceptional_mode()) + return osErrorISR; // Not allowed in ISR return __svcThreadSetPriority(thread_id, priority); } /// Get current priority of an active thread -osPriority osThreadGetPriority (osThreadId thread_id) { - if (__exceptional_mode()) return osPriorityError;// Not allowed in ISR +osPriority osThreadGetPriority(osThreadId thread_id) { + if (__exceptional_mode()) + return osPriorityError; // Not allowed in ISR return __svcThreadGetPriority(thread_id); } /// INTERNAL - Not Public /// Auto Terminate Thread on exit (used implicitly when thread exists) -__NO_RETURN void osThreadExit (void) { +__NO_RETURN void osThreadExit(void) { __svcThreadTerminate(__svcThreadGetId()); - for (;;); // Should never come here + for (;;) + ; // Should never come here } #ifdef __MBED_CMSIS_RTOS_CA9 /// Get current thread state -uint8_t osThreadGetState (osThreadId thread_id) { +uint8_t osThreadGetState(osThreadId thread_id) { P_TCB ptcb; - if (__exceptional_mode()) return osErrorISR; // Not allowed in ISR + if (__exceptional_mode()) + return osErrorISR; // Not allowed in ISR - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return osErrorParameter; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return osErrorParameter; return ptcb->state; } @@ -855,28 +848,29 @@ uint8_t osThreadGetState (osThreadId thread_id) { // ==== Generic Wait Functions ==== // Generic Wait Service Calls declarations -SVC_1_1(svcDelay, osStatus, uint32_t, RET_osStatus) +SVC_1_1(svcDelay, osStatus, uint32_t, RET_osStatus) #if osFeature_Wait != 0 -SVC_1_3(svcWait, os_InRegs osEvent, uint32_t, RET_osEvent) +SVC_1_3(svcWait, os_InRegs osEvent, uint32_t, RET_osEvent) #endif // Generic Wait Service Calls /// Wait for Timeout (Time Delay) -osStatus svcDelay (uint32_t millisec) { - if (millisec == 0) return osOK; +osStatus svcDelay(uint32_t millisec) { + if (millisec == 0) + return osOK; rt_dly_wait(rt_ms2tick(millisec)); return osEventTimeout; } /// Wait for Signal, Message, Mail, or Timeout #if osFeature_Wait != 0 -os_InRegs osEvent_type svcWait (uint32_t millisec) { +os_InRegs osEvent_type svcWait(uint32_t millisec) { osEvent ret; if (millisec == 0) { ret.status = osOK; -#if defined (__GNUC__) && defined (__ARM_PCS_VFP) +#if defined(__GNUC__) && defined(__ARM_PCS_VFP) osEvent_ret_status; return; #else @@ -888,7 +882,7 @@ os_InRegs osEvent_type svcWait (uint32_t millisec) { rt_dly_wait(rt_ms2tick(millisec)); ret.status = osEventTimeout; -#if defined (__GNUC__) && defined (__ARM_PCS_VFP) +#if defined(__GNUC__) && defined(__ARM_PCS_VFP) osEvent_ret_status; return; #else @@ -897,24 +891,24 @@ os_InRegs osEvent_type svcWait (uint32_t millisec) { } #endif - // Generic Wait API /// Wait for Timeout (Time Delay) -osStatus osDelay (uint32_t millisec) { - if (__exceptional_mode()) return osErrorISR; // Not allowed in ISR +osStatus osDelay(uint32_t millisec) { + if (__exceptional_mode()) + return osErrorISR; // Not allowed in ISR return __svcDelay(millisec); } /// Wait for Signal, Message, Mail, or Timeout -os_InRegs osEvent osWait (uint32_t millisec) { +os_InRegs osEvent osWait(uint32_t millisec) { osEvent ret; #if osFeature_Wait == 0 ret.status = osErrorOS; return ret; #else - if (__exceptional_mode()) { // Not allowed in ISR + if (__exceptional_mode()) { // Not allowed in ISR ret.status = osErrorISR; return ret; } @@ -922,41 +916,40 @@ os_InRegs osEvent osWait (uint32_t millisec) { #endif } - // ==== Timer Management ==== // Timer definitions -#define osTimerInvalid 0 -#define osTimerStopped 1 -#define osTimerRunning 2 +#define osTimerInvalid 0 +#define osTimerStopped 1 +#define osTimerRunning 2 // Timer structures -typedef struct os_timer_cb_ { // Timer Control Block - struct os_timer_cb_ *next; // Pointer to next active Timer - uint8_t state; // Timer State - uint8_t type; // Timer Type (Periodic/One-shot) - uint16_t reserved; // Reserved - uint16_t tcnt; // Timer Delay Count - uint16_t icnt; // Timer Initial Count - void *arg; // Timer Function Argument - const osTimerDef_t *timer; // Pointer to Timer definition +typedef struct os_timer_cb_ { // Timer Control Block + struct os_timer_cb_ *next; // Pointer to next active Timer + uint8_t state; // Timer State + uint8_t type; // Timer Type (Periodic/One-shot) + uint16_t reserved; // Reserved + uint16_t tcnt; // Timer Delay Count + uint16_t icnt; // Timer Initial Count + void *arg; // Timer Function Argument + const osTimerDef_t *timer; // Pointer to Timer definition } os_timer_cb; // Timer variables -os_timer_cb *os_timer_head; // Pointer to first active Timer - +os_timer_cb *os_timer_head; // Pointer to first active Timer // Timer Helper Functions // Insert Timer into the list sorted by time -static void rt_timer_insert (os_timer_cb *pt, uint32_t tcnt) { +static void rt_timer_insert(os_timer_cb *pt, uint32_t tcnt) { os_timer_cb *p, *prev; prev = NULL; p = os_timer_head; while (p != NULL) { - if (tcnt < p->tcnt) break; + if (tcnt < p->tcnt) + break; tcnt -= p->tcnt; prev = p; p = p->next; @@ -974,17 +967,19 @@ static void rt_timer_insert (os_timer_cb *pt, uint32_t tcnt) { } // Remove Timer from the list -static int rt_timer_remove (os_timer_cb *pt) { +static int rt_timer_remove(os_timer_cb *pt) { os_timer_cb *p, *prev; prev = NULL; p = os_timer_head; while (p != NULL) { - if (p == pt) break; + if (p == pt) + break; prev = p; p = p->next; } - if (p == NULL) return -1; + if (p == NULL) + return -1; if (prev != NULL) { prev->next = pt->next; } else { @@ -997,18 +992,19 @@ static int rt_timer_remove (os_timer_cb *pt) { return 0; } - // Timer Service Calls declarations -SVC_3_1(svcTimerCreate, osTimerId, const osTimerDef_t *, os_timer_type, void *, RET_pointer) -SVC_2_1(svcTimerStart, osStatus, osTimerId, uint32_t, RET_osStatus) -SVC_1_1(svcTimerStop, osStatus, osTimerId, RET_osStatus) -SVC_1_1(svcTimerDelete, osStatus, osTimerId, RET_osStatus) -SVC_1_2(svcTimerCall, os_InRegs osCallback, osTimerId, RET_osCallback) +SVC_3_1(svcTimerCreate, osTimerId, const osTimerDef_t *, os_timer_type, void *, + RET_pointer) +SVC_2_1(svcTimerStart, osStatus, osTimerId, uint32_t, RET_osStatus) +SVC_1_1(svcTimerStop, osStatus, osTimerId, RET_osStatus) +SVC_1_1(svcTimerDelete, osStatus, osTimerId, RET_osStatus) +SVC_1_2(svcTimerCall, os_InRegs osCallback, osTimerId, RET_osCallback) // Timer Management Service Calls /// Create timer -osTimerId svcTimerCreate (const osTimerDef_t *timer_def, os_timer_type type, void *argument) { +osTimerId svcTimerCreate(const osTimerDef_t *timer_def, os_timer_type type, + void *argument) { os_timer_cb *pt; if ((timer_def == NULL) || (timer_def->ptimer == NULL)) { @@ -1032,42 +1028,44 @@ osTimerId svcTimerCreate (const osTimerDef_t *timer_def, os_timer_type type, voi return NULL; } - if (pt->state != osTimerInvalid){ + if (pt->state != osTimerInvalid) { sysThreadError(osErrorResource); return NULL; } pt->state = osTimerStopped; - pt->type = (uint8_t)type; - pt->arg = argument; + pt->type = (uint8_t)type; + pt->arg = argument; pt->timer = timer_def; return (osTimerId)pt; } /// Start or restart timer -osStatus svcTimerStart (osTimerId timer_id, uint32_t millisec) { +osStatus svcTimerStart(osTimerId timer_id, uint32_t millisec) { os_timer_cb *pt; - uint32_t tcnt; + uint32_t tcnt; pt = rt_id2obj(timer_id); - if (pt == NULL) return osErrorParameter; + if (pt == NULL) + return osErrorParameter; tcnt = rt_ms2tick(millisec); - if (tcnt == 0) return osErrorValue; + if (tcnt == 0) + return osErrorValue; switch (pt->state) { - case osTimerRunning: - if (rt_timer_remove(pt) != 0) { - return osErrorResource; - } - break; - case osTimerStopped: - pt->state = osTimerRunning; - pt->icnt = (uint16_t)tcnt; - break; - default: + case osTimerRunning: + if (rt_timer_remove(pt) != 0) { return osErrorResource; + } + break; + case osTimerStopped: + pt->state = osTimerRunning; + pt->icnt = (uint16_t)tcnt; + break; + default: + return osErrorResource; } rt_timer_insert(pt, tcnt); @@ -1076,13 +1074,15 @@ osStatus svcTimerStart (osTimerId timer_id, uint32_t millisec) { } /// Stop timer -osStatus svcTimerStop (osTimerId timer_id) { +osStatus svcTimerStop(osTimerId timer_id) { os_timer_cb *pt; pt = rt_id2obj(timer_id); - if (pt == NULL) return osErrorParameter; + if (pt == NULL) + return osErrorParameter; - if (pt->state != osTimerRunning) return osErrorResource; + if (pt->state != osTimerRunning) + return osErrorResource; pt->state = osTimerStopped; @@ -1094,20 +1094,21 @@ osStatus svcTimerStop (osTimerId timer_id) { } /// Delete timer -osStatus svcTimerDelete (osTimerId timer_id) { +osStatus svcTimerDelete(osTimerId timer_id) { os_timer_cb *pt; pt = rt_id2obj(timer_id); - if (pt == NULL) return osErrorParameter; + if (pt == NULL) + return osErrorParameter; switch (pt->state) { - case osTimerRunning: - rt_timer_remove(pt); - break; - case osTimerStopped: - break; - default: - return osErrorResource; + case osTimerRunning: + rt_timer_remove(pt); + break; + case osTimerStopped: + break; + default: + return osErrorResource; } pt->state = osTimerInvalid; @@ -1116,15 +1117,15 @@ osStatus svcTimerDelete (osTimerId timer_id) { } /// Get timer callback parameters -os_InRegs osCallback_type svcTimerCall (osTimerId timer_id) { +os_InRegs osCallback_type svcTimerCall(osTimerId timer_id) { os_timer_cb *pt; - osCallback ret; + osCallback ret; pt = rt_id2obj(timer_id); if (pt == NULL) { - ret.fp = NULL; + ret.fp = NULL; ret.arg = NULL; -#if defined (__GNUC__) && defined (__ARM_PCS_VFP) +#if defined(__GNUC__) && defined(__ARM_PCS_VFP) osCallback_ret; return; #else @@ -1132,10 +1133,10 @@ os_InRegs osCallback_type svcTimerCall (osTimerId timer_id) { #endif } - ret.fp = (void *)pt->timer->ptimer; + ret.fp = (void *)pt->timer->ptimer; ret.arg = pt->arg; -#if defined (__GNUC__) && defined (__ARM_PCS_VFP) +#if defined(__GNUC__) && defined(__ARM_PCS_VFP) osCallback_ret; return; #else @@ -1143,14 +1144,16 @@ os_InRegs osCallback_type svcTimerCall (osTimerId timer_id) { #endif } -static __INLINE osStatus isrMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec); +static __INLINE osStatus isrMessagePut(osMessageQId queue_id, uint32_t info, + uint32_t millisec); /// Timer Tick (called each SysTick) -void sysTimerTick (void) { +void sysTimerTick(void) { os_timer_cb *pt, *p; p = os_timer_head; - if (p == NULL) return; + if (p == NULL) + return; p->tcnt--; while ((p != NULL) && (p->tcnt == 0)) { @@ -1166,49 +1169,52 @@ void sysTimerTick (void) { } } - // Timer Management Public API /// Create timer -osTimerId osTimerCreate (const osTimerDef_t *timer_def, os_timer_type type, void *argument) { - if (__exceptional_mode()) return NULL; // Not allowed in ISR +osTimerId osTimerCreate(const osTimerDef_t *timer_def, os_timer_type type, + void *argument) { + if (__exceptional_mode()) + return NULL; // Not allowed in ISR if ((__get_mode() != MODE_USR) && (os_running == 0)) { // Privileged and not running - return svcTimerCreate(timer_def, type, argument); + return svcTimerCreate(timer_def, type, argument); } else { return __svcTimerCreate(timer_def, type, argument); } } /// Start or restart timer -osStatus osTimerStart (osTimerId timer_id, uint32_t millisec) { - if (__exceptional_mode()) return osErrorISR; // Not allowed in ISR +osStatus osTimerStart(osTimerId timer_id, uint32_t millisec) { + if (__exceptional_mode()) + return osErrorISR; // Not allowed in ISR return __svcTimerStart(timer_id, millisec); } /// Stop timer -osStatus osTimerStop (osTimerId timer_id) { - if (__exceptional_mode()) return osErrorISR; // Not allowed in ISR +osStatus osTimerStop(osTimerId timer_id) { + if (__exceptional_mode()) + return osErrorISR; // Not allowed in ISR return __svcTimerStop(timer_id); } /// Delete timer -osStatus osTimerDelete (osTimerId timer_id) { - if (__exceptional_mode()) return osErrorISR; // Not allowed in ISR +osStatus osTimerDelete(osTimerId timer_id) { + if (__exceptional_mode()) + return osErrorISR; // Not allowed in ISR return __svcTimerDelete(timer_id); } /// INTERNAL - Not Public /// Get timer callback parameters (used by OS Timer Thread) -os_InRegs osCallback osTimerCall (osTimerId timer_id) { +os_InRegs osCallback osTimerCall(osTimerId timer_id) { return __svcTimerCall(timer_id); } - // Timer Thread -__NO_RETURN void osTimerThread (void const *argument) { +__NO_RETURN void osTimerThread(void const *argument) { osCallback cb; - osEvent evt; + osEvent evt; for (;;) { evt = osMessageGet(osMessageQId_osTimerMessageQ, osWaitForever); @@ -1221,69 +1227,74 @@ __NO_RETURN void osTimerThread (void const *argument) { } } - // ==== Signal Management ==== // Signal Service Calls declarations -SVC_2_1(svcSignalSet, int32_t, osThreadId, int32_t, RET_int32_t) -SVC_2_1(svcSignalClear, int32_t, osThreadId, int32_t, RET_int32_t) -SVC_1_1(svcSignalGet, int32_t, osThreadId, RET_int32_t) -SVC_2_3(svcSignalWait, os_InRegs osEvent, int32_t, uint32_t, RET_osEvent) +SVC_2_1(svcSignalSet, int32_t, osThreadId, int32_t, RET_int32_t) +SVC_2_1(svcSignalClear, int32_t, osThreadId, int32_t, RET_int32_t) +SVC_1_1(svcSignalGet, int32_t, osThreadId, RET_int32_t) +SVC_2_3(svcSignalWait, os_InRegs osEvent, int32_t, uint32_t, RET_osEvent) // Signal Service Calls /// Set the specified Signal Flags of an active thread -int32_t svcSignalSet (osThreadId thread_id, int32_t signals) { - P_TCB ptcb; +int32_t svcSignalSet(osThreadId thread_id, int32_t signals) { + P_TCB ptcb; int32_t sig; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return 0x80000000; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return 0x80000000; - if (signals & (0xFFFFFFFF << osFeature_Signals)) return 0x80000000; + if (signals & (0xFFFFFFFF << osFeature_Signals)) + return 0x80000000; - sig = ptcb->events; // Previous signal flags + sig = ptcb->events; // Previous signal flags - rt_evt_set(signals, ptcb->task_id); // Set event flags + rt_evt_set(signals, ptcb->task_id); // Set event flags return sig; } /// Clear the specified Signal Flags of an active thread -int32_t svcSignalClear (osThreadId thread_id, int32_t signals) { - P_TCB ptcb; +int32_t svcSignalClear(osThreadId thread_id, int32_t signals) { + P_TCB ptcb; int32_t sig; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return 0x80000000; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return 0x80000000; - if (signals & (0xFFFFFFFF << osFeature_Signals)) return 0x80000000; + if (signals & (0xFFFFFFFF << osFeature_Signals)) + return 0x80000000; - sig = ptcb->events; // Previous signal flags + sig = ptcb->events; // Previous signal flags - rt_evt_clr(signals, ptcb->task_id); // Clear event flags + rt_evt_clr(signals, ptcb->task_id); // Clear event flags return sig; } /// Get Signal Flags status of an active thread -int32_t svcSignalGet (osThreadId thread_id) { +int32_t svcSignalGet(osThreadId thread_id) { P_TCB ptcb; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return 0x80000000; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return 0x80000000; - return ptcb->events; // Return event flags + return ptcb->events; // Return event flags } -/// Wait for one or more Signal Flags to become signaled for the current RUNNING thread -os_InRegs osEvent_type svcSignalWait (int32_t signals, uint32_t millisec) { +/// Wait for one or more Signal Flags to become signaled for the current RUNNING +/// thread +os_InRegs osEvent_type svcSignalWait(int32_t signals, uint32_t millisec) { OS_RESULT res; - osEvent ret; + osEvent ret; if (signals & (0xFFFFFFFF << osFeature_Signals)) { ret.status = osErrorValue; -#if defined (__GNUC__) && defined (__ARM_PCS_VFP) +#if defined(__GNUC__) && defined(__ARM_PCS_VFP) osEvent_ret_status; return; #else @@ -1291,10 +1302,10 @@ os_InRegs osEvent_type svcSignalWait (int32_t signals, uint32_t millisec) { #endif } - if (signals != 0) { // Wait for all specified signals + if (signals != 0) { // Wait for all specified signals res = rt_evt_wait(signals, rt_ms2tick(millisec), __TRUE); - } else { // Wait for any signal - res = rt_evt_wait(0xFFFF, rt_ms2tick(millisec), __FALSE); + } else { // Wait for any signal + res = rt_evt_wait(0xFFFF, rt_ms2tick(millisec), __FALSE); } if (res == OS_R_EVT) { @@ -1305,7 +1316,7 @@ os_InRegs osEvent_type svcSignalWait (int32_t signals, uint32_t millisec) { ret.value.signals = 0; } -#if defined (__GNUC__) && defined (__ARM_PCS_VFP) +#if defined(__GNUC__) && defined(__ARM_PCS_VFP) osEvent_ret_value; return; #else @@ -1313,74 +1324,76 @@ os_InRegs osEvent_type svcSignalWait (int32_t signals, uint32_t millisec) { #endif } - // Signal ISR Calls /// Set the specified Signal Flags of an active thread -static __INLINE int32_t isrSignalSet (osThreadId thread_id, int32_t signals) { - P_TCB ptcb; +static __INLINE int32_t isrSignalSet(osThreadId thread_id, int32_t signals) { + P_TCB ptcb; int32_t sig; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return 0x80000000; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return 0x80000000; - if (signals & (0xFFFFFFFF << osFeature_Signals)) return 0x80000000; + if (signals & (0xFFFFFFFF << osFeature_Signals)) + return 0x80000000; - sig = ptcb->events; // Previous signal flags + sig = ptcb->events; // Previous signal flags - isr_evt_set(signals, ptcb->task_id); // Set event flags + isr_evt_set(signals, ptcb->task_id); // Set event flags return sig; } - // Signal Public API /// Set the specified Signal Flags of an active thread -int32_t osSignalSet (osThreadId thread_id, int32_t signals) { - if (__exceptional_mode()) { // in ISR - return isrSignalSet(thread_id, signals); - } else { // in Thread +int32_t osSignalSet(osThreadId thread_id, int32_t signals) { + if (__exceptional_mode()) { // in ISR + return isrSignalSet(thread_id, signals); + } else { // in Thread return __svcSignalSet(thread_id, signals); } } /// Clear the specified Signal Flags of an active thread -int32_t osSignalClear (osThreadId thread_id, int32_t signals) { - if (__exceptional_mode()) return osErrorISR; // Not allowed in ISR +int32_t osSignalClear(osThreadId thread_id, int32_t signals) { + if (__exceptional_mode()) + return osErrorISR; // Not allowed in ISR return __svcSignalClear(thread_id, signals); } /// Get Signal Flags status of an active thread -int32_t osSignalGet (osThreadId thread_id) { - if (__exceptional_mode()) return osErrorISR; // Not allowed in ISR +int32_t osSignalGet(osThreadId thread_id) { + if (__exceptional_mode()) + return osErrorISR; // Not allowed in ISR return __svcSignalGet(thread_id); } -/// Wait for one or more Signal Flags to become signaled for the current RUNNING thread -os_InRegs osEvent osSignalWait (int32_t signals, uint32_t millisec) { +/// Wait for one or more Signal Flags to become signaled for the current RUNNING +/// thread +os_InRegs osEvent osSignalWait(int32_t signals, uint32_t millisec) { osEvent ret; - if (__exceptional_mode()) { // Not allowed in ISR + if (__exceptional_mode()) { // Not allowed in ISR ret.status = osErrorISR; return ret; } return __svcSignalWait(signals, millisec); } - // ==== Mutex Management ==== // Mutex Service Calls declarations -SVC_1_1(svcMutexCreate, osMutexId, const osMutexDef_t *, RET_pointer) -SVC_2_1(svcMutexWait, osStatus, osMutexId, uint32_t, RET_osStatus) -SVC_1_1(svcMutexRelease, osStatus, osMutexId, RET_osStatus) -SVC_1_1(svcMutexDelete, osStatus, osMutexId, RET_osStatus) +SVC_1_1(svcMutexCreate, osMutexId, const osMutexDef_t *, RET_pointer) +SVC_2_1(svcMutexWait, osStatus, osMutexId, uint32_t, RET_osStatus) +SVC_1_1(svcMutexRelease, osStatus, osMutexId, RET_osStatus) +SVC_1_1(svcMutexDelete, osStatus, osMutexId, RET_osStatus) // Mutex Service Calls /// Create and Initialize a Mutex object -osMutexId svcMutexCreate (const osMutexDef_t *mutex_def) { +osMutexId svcMutexCreate(const osMutexDef_t *mutex_def) { OS_ID mut; if (mutex_def == NULL) { @@ -1399,20 +1412,22 @@ osMutexId svcMutexCreate (const osMutexDef_t *mutex_def) { return NULL; } - rt_mut_init(mut); // Initialize Mutex + rt_mut_init(mut); // Initialize Mutex return mut; } /// Wait until a Mutex becomes available -osStatus svcMutexWait (osMutexId mutex_id, uint32_t millisec) { - OS_ID mut; +osStatus svcMutexWait(osMutexId mutex_id, uint32_t millisec) { + OS_ID mut; OS_RESULT res; mut = rt_id2obj(mutex_id); - if (mut == NULL) return osErrorParameter; + if (mut == NULL) + return osErrorParameter; - if (((P_MUCB)mut)->cb_type != MUCB) return osErrorParameter; + if (((P_MUCB)mut)->cb_type != MUCB) + return osErrorParameter; res = rt_mut_wait(mut, rt_ms2tick(millisec)); // Wait for Mutex @@ -1424,81 +1439,90 @@ osStatus svcMutexWait (osMutexId mutex_id, uint32_t millisec) { } /// Release a Mutex that was obtained with osMutexWait -osStatus svcMutexRelease (osMutexId mutex_id) { - OS_ID mut; +osStatus svcMutexRelease(osMutexId mutex_id) { + OS_ID mut; OS_RESULT res; mut = rt_id2obj(mutex_id); - if (mut == NULL) return osErrorParameter; + if (mut == NULL) + return osErrorParameter; - if (((P_MUCB)mut)->cb_type != MUCB) return osErrorParameter; + if (((P_MUCB)mut)->cb_type != MUCB) + return osErrorParameter; - res = rt_mut_release(mut); // Release Mutex + res = rt_mut_release(mut); // Release Mutex - if (res == OS_R_NOK) return osErrorResource; // Thread not owner or Zero Counter + if (res == OS_R_NOK) + return osErrorResource; // Thread not owner or Zero Counter return osOK; } /// Delete a Mutex that was created by osMutexCreate -osStatus svcMutexDelete (osMutexId mutex_id) { +osStatus svcMutexDelete(osMutexId mutex_id) { OS_ID mut; mut = rt_id2obj(mutex_id); - if (mut == NULL) return osErrorParameter; + if (mut == NULL) + return osErrorParameter; - if (((P_MUCB)mut)->cb_type != MUCB) return osErrorParameter; + if (((P_MUCB)mut)->cb_type != MUCB) + return osErrorParameter; - rt_mut_delete(mut); // Release Mutex + rt_mut_delete(mut); // Release Mutex return osOK; } - // Mutex Public API /// Create and Initialize a Mutex object -osMutexId osMutexCreate (const osMutexDef_t *mutex_def) { - if (__exceptional_mode()) return NULL; // Not allowed in ISR +osMutexId osMutexCreate(const osMutexDef_t *mutex_def) { + if (__exceptional_mode()) + return NULL; // Not allowed in ISR if ((__get_mode() != MODE_USR) && (os_running == 0)) { // Privileged and not running - return svcMutexCreate(mutex_def); + return svcMutexCreate(mutex_def); } else { return __svcMutexCreate(mutex_def); } } /// Wait until a Mutex becomes available -osStatus osMutexWait (osMutexId mutex_id, uint32_t millisec) { - if (__exceptional_mode()) return osErrorISR; // Not allowed in ISR +osStatus osMutexWait(osMutexId mutex_id, uint32_t millisec) { + if (__exceptional_mode()) + return osErrorISR; // Not allowed in ISR return __svcMutexWait(mutex_id, millisec); } /// Release a Mutex that was obtained with osMutexWait -osStatus osMutexRelease (osMutexId mutex_id) { - if (__exceptional_mode()) return osErrorISR; // Not allowed in ISR +osStatus osMutexRelease(osMutexId mutex_id) { + if (__exceptional_mode()) + return osErrorISR; // Not allowed in ISR return __svcMutexRelease(mutex_id); } /// Delete a Mutex that was created by osMutexCreate -osStatus osMutexDelete (osMutexId mutex_id) { - if (__exceptional_mode()) return osErrorISR; // Not allowed in ISR +osStatus osMutexDelete(osMutexId mutex_id) { + if (__exceptional_mode()) + return osErrorISR; // Not allowed in ISR return __svcMutexDelete(mutex_id); } - // ==== Semaphore Management ==== // Semaphore Service Calls declarations -SVC_2_1(svcSemaphoreCreate, osSemaphoreId, const osSemaphoreDef_t *, int32_t, RET_pointer) -SVC_2_1(svcSemaphoreWait, int32_t, osSemaphoreId, uint32_t, RET_int32_t) -SVC_1_1(svcSemaphoreRelease, osStatus, osSemaphoreId, RET_osStatus) -SVC_1_1(svcSemaphoreDelete, osStatus, osSemaphoreId, RET_osStatus) +SVC_2_1(svcSemaphoreCreate, osSemaphoreId, const osSemaphoreDef_t *, int32_t, + RET_pointer) +SVC_2_1(svcSemaphoreWait, int32_t, osSemaphoreId, uint32_t, RET_int32_t) +SVC_1_1(svcSemaphoreRelease, osStatus, osSemaphoreId, RET_osStatus) +SVC_1_1(svcSemaphoreDelete, osStatus, osSemaphoreId, RET_osStatus) // Semaphore Service Calls /// Create and Initialize a Semaphore object -osSemaphoreId svcSemaphoreCreate (const osSemaphoreDef_t *semaphore_def, int32_t count) { +osSemaphoreId svcSemaphoreCreate(const osSemaphoreDef_t *semaphore_def, + int32_t count) { OS_ID sem; if (semaphore_def == NULL) { @@ -1522,119 +1546,131 @@ osSemaphoreId svcSemaphoreCreate (const osSemaphoreDef_t *semaphore_def, int32_t return NULL; } - rt_sem_init(sem, count); // Initialize Semaphore + rt_sem_init(sem, count); // Initialize Semaphore return sem; } /// Wait until a Semaphore becomes available -int32_t svcSemaphoreWait (osSemaphoreId semaphore_id, uint32_t millisec) { - OS_ID sem; +int32_t svcSemaphoreWait(osSemaphoreId semaphore_id, uint32_t millisec) { + OS_ID sem; OS_RESULT res; sem = rt_id2obj(semaphore_id); - if (sem == NULL) return -1; + if (sem == NULL) + return -1; - if (((P_SCB)sem)->cb_type != SCB) return -1; + if (((P_SCB)sem)->cb_type != SCB) + return -1; res = rt_sem_wait(sem, rt_ms2tick(millisec)); // Wait for Semaphore - if (res == OS_R_TMO) return 0; // Timeout + if (res == OS_R_TMO) + return 0; // Timeout return (((P_SCB)sem)->tokens + 1); } /// Release a Semaphore -osStatus svcSemaphoreRelease (osSemaphoreId semaphore_id) { +osStatus svcSemaphoreRelease(osSemaphoreId semaphore_id) { OS_ID sem; sem = rt_id2obj(semaphore_id); - if (sem == NULL) return osErrorParameter; + if (sem == NULL) + return osErrorParameter; - if (((P_SCB)sem)->cb_type != SCB) return osErrorParameter; + if (((P_SCB)sem)->cb_type != SCB) + return osErrorParameter; - if (((P_SCB)sem)->tokens == osFeature_Semaphore) return osErrorResource; + if (((P_SCB)sem)->tokens == osFeature_Semaphore) + return osErrorResource; - rt_sem_send(sem); // Release Semaphore + rt_sem_send(sem); // Release Semaphore return osOK; } /// Delete a Semaphore that was created by osSemaphoreCreate -osStatus svcSemaphoreDelete (osSemaphoreId semaphore_id) { +osStatus svcSemaphoreDelete(osSemaphoreId semaphore_id) { OS_ID sem; sem = rt_id2obj(semaphore_id); - if (sem == NULL) return osErrorParameter; + if (sem == NULL) + return osErrorParameter; - if (((P_SCB)sem)->cb_type != SCB) return osErrorParameter; + if (((P_SCB)sem)->cb_type != SCB) + return osErrorParameter; - rt_sem_delete(sem); // Delete Semaphore + rt_sem_delete(sem); // Delete Semaphore return osOK; } - // Semaphore ISR Calls /// Release a Semaphore -static __INLINE osStatus isrSemaphoreRelease (osSemaphoreId semaphore_id) { +static __INLINE osStatus isrSemaphoreRelease(osSemaphoreId semaphore_id) { OS_ID sem; sem = rt_id2obj(semaphore_id); - if (sem == NULL) return osErrorParameter; + if (sem == NULL) + return osErrorParameter; - if (((P_SCB)sem)->cb_type != SCB) return osErrorParameter; + if (((P_SCB)sem)->cb_type != SCB) + return osErrorParameter; - if (((P_SCB)sem)->tokens == osFeature_Semaphore) return osErrorResource; + if (((P_SCB)sem)->tokens == osFeature_Semaphore) + return osErrorResource; - isr_sem_send(sem); // Release Semaphore + isr_sem_send(sem); // Release Semaphore return osOK; } - // Semaphore Public API /// Create and Initialize a Semaphore object -osSemaphoreId osSemaphoreCreate (const osSemaphoreDef_t *semaphore_def, int32_t count) { - if (__exceptional_mode()) return NULL; // Not allowed in ISR +osSemaphoreId osSemaphoreCreate(const osSemaphoreDef_t *semaphore_def, + int32_t count) { + if (__exceptional_mode()) + return NULL; // Not allowed in ISR if ((__get_mode() != MODE_USR) && (os_running == 0)) { // Privileged and not running - return svcSemaphoreCreate(semaphore_def, count); + return svcSemaphoreCreate(semaphore_def, count); } else { return __svcSemaphoreCreate(semaphore_def, count); } } /// Wait until a Semaphore becomes available -int32_t osSemaphoreWait (osSemaphoreId semaphore_id, uint32_t millisec) { - if (__exceptional_mode()) return -1; // Not allowed in ISR +int32_t osSemaphoreWait(osSemaphoreId semaphore_id, uint32_t millisec) { + if (__exceptional_mode()) + return -1; // Not allowed in ISR return __svcSemaphoreWait(semaphore_id, millisec); } /// Release a Semaphore -osStatus osSemaphoreRelease (osSemaphoreId semaphore_id) { - if (__exceptional_mode()) { // in ISR - return isrSemaphoreRelease(semaphore_id); - } else { // in Thread +osStatus osSemaphoreRelease(osSemaphoreId semaphore_id) { + if (__exceptional_mode()) { // in ISR + return isrSemaphoreRelease(semaphore_id); + } else { // in Thread return __svcSemaphoreRelease(semaphore_id); } } /// Delete a Semaphore that was created by osSemaphoreCreate -osStatus osSemaphoreDelete (osSemaphoreId semaphore_id) { - if (__exceptional_mode()) return osErrorISR; // Not allowed in ISR +osStatus osSemaphoreDelete(osSemaphoreId semaphore_id) { + if (__exceptional_mode()) + return osErrorISR; // Not allowed in ISR return __svcSemaphoreDelete(semaphore_id); } - // ==== Memory Management Functions ==== // Memory Management Helper Functions // Clear Memory Box (Zero init) -static void rt_clr_box (void *box_mem, void *box) { +static void rt_clr_box(void *box_mem, void *box) { uint32_t *p, n; if (box) { @@ -1646,36 +1682,36 @@ static void rt_clr_box (void *box_mem, void *box) { } // Memory Management Service Calls declarations -SVC_1_1(svcPoolCreate, osPoolId, const osPoolDef_t *, RET_pointer) -SVC_2_1(sysPoolAlloc, void *, osPoolId, uint32_t, RET_pointer) -SVC_2_1(sysPoolFree, osStatus, osPoolId, void *, RET_osStatus) +SVC_1_1(svcPoolCreate, osPoolId, const osPoolDef_t *, RET_pointer) +SVC_2_1(sysPoolAlloc, void *, osPoolId, uint32_t, RET_pointer) +SVC_2_1(sysPoolFree, osStatus, osPoolId, void *, RET_osStatus) // Memory Management Service & ISR Calls /// Create and Initialize memory pool -osPoolId svcPoolCreate (const osPoolDef_t *pool_def) { +osPoolId svcPoolCreate(const osPoolDef_t *pool_def) { uint32_t blk_sz; - if ((pool_def == NULL) || - (pool_def->pool_sz == 0) || - (pool_def->item_sz == 0) || - (pool_def->pool == NULL)) { + if ((pool_def == NULL) || (pool_def->pool_sz == 0) || + (pool_def->item_sz == 0) || (pool_def->pool == NULL)) { sysThreadError(osErrorParameter); return NULL; } blk_sz = (pool_def->item_sz + 3) & ~3; - _init_box(pool_def->pool, sizeof(struct OS_BM) + pool_def->pool_sz * blk_sz, blk_sz); + _init_box(pool_def->pool, sizeof(struct OS_BM) + pool_def->pool_sz * blk_sz, + blk_sz); return pool_def->pool; } /// Allocate a memory block from a memory pool -void *sysPoolAlloc (osPoolId pool_id, uint32_t clr) { +void *sysPoolAlloc(osPoolId pool_id, uint32_t clr) { void *ptr; - if (pool_id == NULL) return NULL; + if (pool_id == NULL) + return NULL; ptr = rt_alloc_box(pool_id); if (clr) { @@ -1686,73 +1722,75 @@ void *sysPoolAlloc (osPoolId pool_id, uint32_t clr) { } /// Return an allocated memory block back to a specific memory pool -osStatus sysPoolFree (osPoolId pool_id, void *block) { +osStatus sysPoolFree(osPoolId pool_id, void *block) { int32_t res; - if (pool_id == NULL) return osErrorParameter; + if (pool_id == NULL) + return osErrorParameter; res = rt_free_box(pool_id, block); - if (res != 0) return osErrorValue; + if (res != 0) + return osErrorValue; return osOK; } - // Memory Management Public API /// Create and Initialize memory pool -osPoolId osPoolCreate (const osPoolDef_t *pool_def) { - if (__exceptional_mode()) return NULL; // Not allowed in ISR +osPoolId osPoolCreate(const osPoolDef_t *pool_def) { + if (__exceptional_mode()) + return NULL; // Not allowed in ISR if ((__get_mode() != MODE_USR) && (os_running == 0)) { // Privileged and not running - return svcPoolCreate(pool_def); + return svcPoolCreate(pool_def); } else { return __svcPoolCreate(pool_def); } } /// Allocate a memory block from a memory pool -void *osPoolAlloc (osPoolId pool_id) { - if (__get_mode() != MODE_USR) { // in ISR or Privileged - return sysPoolAlloc(pool_id, 0); - } else { // in Thread +void *osPoolAlloc(osPoolId pool_id) { + if (__get_mode() != MODE_USR) { // in ISR or Privileged + return sysPoolAlloc(pool_id, 0); + } else { // in Thread return __sysPoolAlloc(pool_id, 0); } } /// Allocate a memory block from a memory pool and set memory block to zero -void *osPoolCAlloc (osPoolId pool_id) { - if (__get_mode() != MODE_USR) { // in ISR or Privileged - return sysPoolAlloc(pool_id, 1); - } else { // in Thread +void *osPoolCAlloc(osPoolId pool_id) { + if (__get_mode() != MODE_USR) { // in ISR or Privileged + return sysPoolAlloc(pool_id, 1); + } else { // in Thread return __sysPoolAlloc(pool_id, 1); } } /// Return an allocated memory block back to a specific memory pool -osStatus osPoolFree (osPoolId pool_id, void *block) { - if (__get_mode() != MODE_USR) { // in ISR or Privileged - return sysPoolFree(pool_id, block); - } else { // in Thread +osStatus osPoolFree(osPoolId pool_id, void *block) { + if (__get_mode() != MODE_USR) { // in ISR or Privileged + return sysPoolFree(pool_id, block); + } else { // in Thread return __sysPoolFree(pool_id, block); } } - // ==== Message Queue Management Functions ==== // Message Queue Management Service Calls declarations -SVC_2_1(svcMessageCreate, osMessageQId, const osMessageQDef_t *, osThreadId, RET_pointer) -SVC_3_1(svcMessagePut, osStatus, osMessageQId, uint32_t, uint32_t, RET_osStatus) -SVC_2_3(svcMessageGet, os_InRegs osEvent, osMessageQId, uint32_t, RET_osEvent) +SVC_2_1(svcMessageCreate, osMessageQId, const osMessageQDef_t *, osThreadId, + RET_pointer) +SVC_3_1(svcMessagePut, osStatus, osMessageQId, uint32_t, uint32_t, RET_osStatus) +SVC_2_3(svcMessageGet, os_InRegs osEvent, osMessageQId, uint32_t, RET_osEvent) // Message Queue Service Calls /// Create and Initialize Message Queue -osMessageQId svcMessageCreate (const osMessageQDef_t *queue_def, osThreadId thread_id) { +osMessageQId svcMessageCreate(const osMessageQDef_t *queue_def, + osThreadId thread_id) { - if ((queue_def == NULL) || - (queue_def->queue_sz == 0) || + if ((queue_def == NULL) || (queue_def->queue_sz == 0) || (queue_def->pool == NULL)) { sysThreadError(osErrorParameter); return NULL; @@ -1763,18 +1801,21 @@ osMessageQId svcMessageCreate (const osMessageQDef_t *queue_def, osThreadId thre return NULL; } - rt_mbx_init(queue_def->pool, 4*(queue_def->queue_sz + 4)); + rt_mbx_init(queue_def->pool, 4 * (queue_def->queue_sz + 4)); return queue_def->pool; } /// Put a Message to a Queue -osStatus svcMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec) { +osStatus svcMessagePut(osMessageQId queue_id, uint32_t info, + uint32_t millisec) { OS_RESULT res; - if (queue_id == NULL) return osErrorParameter; + if (queue_id == NULL) + return osErrorParameter; - if (((P_MCB)queue_id)->cb_type != MCB) return osErrorParameter; + if (((P_MCB)queue_id)->cb_type != MCB) + return osErrorParameter; res = rt_mbx_send(queue_id, (void *)info, rt_ms2tick(millisec)); @@ -1786,13 +1827,13 @@ osStatus svcMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec) } /// Get a Message or Wait for a Message from a Queue -os_InRegs osEvent_type svcMessageGet (osMessageQId queue_id, uint32_t millisec) { +os_InRegs osEvent_type svcMessageGet(osMessageQId queue_id, uint32_t millisec) { OS_RESULT res; - osEvent ret; + osEvent ret; if (queue_id == NULL) { ret.status = osErrorParameter; -#if defined (__GNUC__) && defined (__ARM_PCS_VFP) +#if defined(__GNUC__) && defined(__ARM_PCS_VFP) osEvent_ret_status; return; #else @@ -1802,7 +1843,7 @@ os_InRegs osEvent_type svcMessageGet (osMessageQId queue_id, uint32_t millisec) if (((P_MCB)queue_id)->cb_type != MCB) { ret.status = osErrorParameter; -#if defined (__GNUC__) && defined (__ARM_PCS_VFP) +#if defined(__GNUC__) && defined(__ARM_PCS_VFP) osEvent_ret_status; return; #else @@ -1814,7 +1855,7 @@ os_InRegs osEvent_type svcMessageGet (osMessageQId queue_id, uint32_t millisec) if (res == OS_R_TMO) { ret.status = millisec ? osEventTimeout : osOK; -#if defined (__GNUC__) && defined (__ARM_PCS_VFP) +#if defined(__GNUC__) && defined(__ARM_PCS_VFP) osEvent_ret_value; return; #else @@ -1824,7 +1865,7 @@ os_InRegs osEvent_type svcMessageGet (osMessageQId queue_id, uint32_t millisec) ret.status = osEventMessage; -#if defined (__GNUC__) && defined (__ARM_PCS_VFP) +#if defined(__GNUC__) && defined(__ARM_PCS_VFP) osEvent_ret_value; return; #else @@ -1832,19 +1873,20 @@ os_InRegs osEvent_type svcMessageGet (osMessageQId queue_id, uint32_t millisec) #endif } - // Message Queue ISR Calls /// Put a Message to a Queue -static __INLINE osStatus isrMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec) { +static __INLINE osStatus isrMessagePut(osMessageQId queue_id, uint32_t info, + uint32_t millisec) { if ((queue_id == NULL) || (millisec != 0)) { return osErrorParameter; } - if (((P_MCB)queue_id)->cb_type != MCB) return osErrorParameter; + if (((P_MCB)queue_id)->cb_type != MCB) + return osErrorParameter; - if (rt_mbx_check(queue_id) == 0) { // Check if Queue is full + if (rt_mbx_check(queue_id) == 0) { // Check if Queue is full return osErrorResource; } @@ -1854,9 +1896,10 @@ static __INLINE osStatus isrMessagePut (osMessageQId queue_id, uint32_t info, ui } /// Get a Message or Wait for a Message from a Queue -static __INLINE os_InRegs osEvent isrMessageGet (osMessageQId queue_id, uint32_t millisec) { +static __INLINE os_InRegs osEvent isrMessageGet(osMessageQId queue_id, + uint32_t millisec) { OS_RESULT res; - osEvent ret; + osEvent ret; if ((queue_id == NULL) || (millisec != 0)) { ret.status = osErrorParameter; @@ -1880,58 +1923,57 @@ static __INLINE os_InRegs osEvent isrMessageGet (osMessageQId queue_id, uint32_t return ret; } - // Message Queue Management Public API /// Create and Initialize Message Queue -osMessageQId osMessageCreate (const osMessageQDef_t *queue_def, osThreadId thread_id) { - if (__exceptional_mode()) return NULL; // Not allowed in ISR +osMessageQId osMessageCreate(const osMessageQDef_t *queue_def, + osThreadId thread_id) { + if (__exceptional_mode()) + return NULL; // Not allowed in ISR if ((__get_mode() != MODE_USR) && (os_running == 0)) { // Privileged and not running - return svcMessageCreate(queue_def, thread_id); + return svcMessageCreate(queue_def, thread_id); } else { return __svcMessageCreate(queue_def, thread_id); } } /// Put a Message to a Queue -osStatus osMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec) { - if (__exceptional_mode()) { // in ISR - return isrMessagePut(queue_id, info, millisec); - } else { // in Thread +osStatus osMessagePut(osMessageQId queue_id, uint32_t info, uint32_t millisec) { + if (__exceptional_mode()) { // in ISR + return isrMessagePut(queue_id, info, millisec); + } else { // in Thread return __svcMessagePut(queue_id, info, millisec); } } /// Get a Message or Wait for a Message from a Queue -os_InRegs osEvent osMessageGet (osMessageQId queue_id, uint32_t millisec) { - if (__exceptional_mode()) { // in ISR - return isrMessageGet(queue_id, millisec); - } else { // in Thread +os_InRegs osEvent osMessageGet(osMessageQId queue_id, uint32_t millisec) { + if (__exceptional_mode()) { // in ISR + return isrMessageGet(queue_id, millisec); + } else { // in Thread return __svcMessageGet(queue_id, millisec); } } - // ==== Mail Queue Management Functions ==== // Mail Queue Management Service Calls declarations -SVC_2_1(svcMailCreate, osMailQId, const osMailQDef_t *, osThreadId, RET_pointer) -SVC_4_1(sysMailAlloc, void *, osMailQId, uint32_t, uint32_t, uint32_t, RET_pointer) -SVC_3_1(sysMailFree, osStatus, osMailQId, void *, uint32_t, RET_osStatus) +SVC_2_1(svcMailCreate, osMailQId, const osMailQDef_t *, osThreadId, RET_pointer) +SVC_4_1(sysMailAlloc, void *, osMailQId, uint32_t, uint32_t, uint32_t, + RET_pointer) +SVC_3_1(sysMailFree, osStatus, osMailQId, void *, uint32_t, RET_osStatus) // Mail Queue Management Service & ISR Calls /// Create and Initialize mail queue -osMailQId svcMailCreate (const osMailQDef_t *queue_def, osThreadId thread_id) { +osMailQId svcMailCreate(const osMailQDef_t *queue_def, osThreadId thread_id) { uint32_t blk_sz; - P_MCB pmcb; - void *pool; + P_MCB pmcb; + void *pool; - if ((queue_def == NULL) || - (queue_def->queue_sz == 0) || - (queue_def->item_sz == 0) || - (queue_def->pool == NULL)) { + if ((queue_def == NULL) || (queue_def->queue_sz == 0) || + (queue_def->item_sz == 0) || (queue_def->pool == NULL)) { sysThreadError(osErrorParameter); return NULL; } @@ -1948,26 +1990,29 @@ osMailQId svcMailCreate (const osMailQDef_t *queue_def, osThreadId thread_id) { _init_box(pool, sizeof(struct OS_BM) + queue_def->queue_sz * blk_sz, blk_sz); - rt_mbx_init(pmcb, 4*(queue_def->queue_sz + 4)); - + rt_mbx_init(pmcb, 4 * (queue_def->queue_sz + 4)); return queue_def->pool; } /// Allocate a memory block from a mail -void *sysMailAlloc (osMailQId queue_id, uint32_t millisec, uint32_t isr, uint32_t clr) { +void *sysMailAlloc(osMailQId queue_id, uint32_t millisec, uint32_t isr, + uint32_t clr) { P_MCB pmcb; void *pool; void *mem; - if (queue_id == NULL) return NULL; + if (queue_id == NULL) + return NULL; pmcb = *(((void **)queue_id) + 0); pool = *(((void **)queue_id) + 1); - if ((pool == NULL) || (pmcb == NULL)) return NULL; + if ((pool == NULL) || (pmcb == NULL)) + return NULL; - if (isr && (millisec != 0)) return NULL; + if (isr && (millisec != 0)) + return NULL; mem = rt_alloc_box(pool); if (clr) { @@ -1992,29 +2037,32 @@ void *sysMailAlloc (osMailQId queue_id, uint32_t millisec, uint32_t isr, uint32_ } /// Free a memory block from a mail -osStatus sysMailFree (osMailQId queue_id, void *mail, uint32_t isr) { - P_MCB pmcb; - P_TCB ptcb; - void *pool; - void *mem; +osStatus sysMailFree(osMailQId queue_id, void *mail, uint32_t isr) { + P_MCB pmcb; + P_TCB ptcb; + void *pool; + void *mem; int32_t res; - if (queue_id == NULL) return osErrorParameter; + if (queue_id == NULL) + return osErrorParameter; pmcb = *(((void **)queue_id) + 0); pool = *(((void **)queue_id) + 1); - if ((pmcb == NULL) || (pool == NULL)) return osErrorParameter; + if ((pmcb == NULL) || (pool == NULL)) + return osErrorParameter; res = rt_free_box(pool, mail); - if (res != 0) return osErrorValue; + if (res != 0) + return osErrorValue; if (pmcb->state == 3) { // Task is waiting to allocate a message if (isr) { - rt_psq_enq (pmcb, (U32)pool); - rt_psh_req (); + rt_psq_enq(pmcb, (U32)pool); + rt_psh_req(); } else { mem = rt_alloc_box(pool); if (mem != NULL) { @@ -2032,51 +2080,53 @@ osStatus sysMailFree (osMailQId queue_id, void *mail, uint32_t isr) { return osOK; } - // Mail Queue Management Public API /// Create and Initialize mail queue -osMailQId osMailCreate (const osMailQDef_t *queue_def, osThreadId thread_id) { - if (__exceptional_mode()) return NULL; // Not allowed in ISR +osMailQId osMailCreate(const osMailQDef_t *queue_def, osThreadId thread_id) { + if (__exceptional_mode()) + return NULL; // Not allowed in ISR if ((__get_mode() != MODE_USR) && (os_running == 0)) { // Privileged and not running - return svcMailCreate(queue_def, thread_id); + return svcMailCreate(queue_def, thread_id); } else { return __svcMailCreate(queue_def, thread_id); } } /// Allocate a memory block from a mail -void *osMailAlloc (osMailQId queue_id, uint32_t millisec) { - if (__exceptional_mode()) { // in ISR - return sysMailAlloc(queue_id, millisec, 1, 0); - } else { // in Thread +void *osMailAlloc(osMailQId queue_id, uint32_t millisec) { + if (__exceptional_mode()) { // in ISR + return sysMailAlloc(queue_id, millisec, 1, 0); + } else { // in Thread return __sysMailAlloc(queue_id, millisec, 0, 0); } } /// Allocate a memory block from a mail and set memory block to zero -void *osMailCAlloc (osMailQId queue_id, uint32_t millisec) { - if (__exceptional_mode()) { // in ISR - return sysMailAlloc(queue_id, millisec, 1, 1); - } else { // in Thread +void *osMailCAlloc(osMailQId queue_id, uint32_t millisec) { + if (__exceptional_mode()) { // in ISR + return sysMailAlloc(queue_id, millisec, 1, 1); + } else { // in Thread return __sysMailAlloc(queue_id, millisec, 0, 1); } } /// Free a memory block from a mail -osStatus osMailFree (osMailQId queue_id, void *mail) { - if (__exceptional_mode()) { // in ISR - return sysMailFree(queue_id, mail, 1); - } else { // in Thread +osStatus osMailFree(osMailQId queue_id, void *mail) { + if (__exceptional_mode()) { // in ISR + return sysMailFree(queue_id, mail, 1); + } else { // in Thread return __sysMailFree(queue_id, mail, 0); } } /// Put a mail to a queue -osStatus osMailPut (osMailQId queue_id, void *mail) { - if (queue_id == NULL) return osErrorParameter; - if (mail == NULL) return osErrorValue; +osStatus osMailPut(osMailQId queue_id, void *mail) { + if (queue_id == NULL) + return osErrorParameter; + if (mail == NULL) + return osErrorValue; return osMessagePut(*((void **)queue_id), (uint32_t)mail, 0); } @@ -2085,7 +2135,7 @@ osStatus osMailPut (osMailQId queue_id, void *mail) { #pragma Ospace #endif // __arm__ /// Get a mail from a queue -os_InRegs osEvent osMailGet (osMailQId queue_id, uint32_t millisec) { +os_InRegs osEvent osMailGet(osMailQId queue_id, uint32_t millisec) { osEvent ret; if (queue_id == NULL) { @@ -2094,7 +2144,8 @@ os_InRegs osEvent osMailGet (osMailQId queue_id, uint32_t millisec) { } ret = osMessageGet(*((void **)queue_id), millisec); - if (ret.status == osEventMessage) ret.status = osEventMail; + if (ret.status == osEventMessage) + ret.status = osEventMail; return ret; } diff --git a/rtos/rtx/TARGET_CORTEX_A/rt_Event.c b/rtos/rtx/TARGET_CORTEX_A/rt_Event.c index 1ea088f..0c33233 100644 --- a/rtos/rtx/TARGET_CORTEX_A/rt_Event.c +++ b/rtos/rtx/TARGET_CORTEX_A/rt_Event.c @@ -32,27 +32,25 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" -#include "RTX_Config.h" -#include "rt_System.h" #include "rt_Event.h" +#include "RTX_Config.h" #include "rt_List.h" +#include "rt_System.h" #include "rt_Task.h" +#include "rt_TypeDef.h" #ifdef __CORTEX_A9 #include "rt_HAL_CA.h" #else #include "rt_HAL_CM.h" #endif - /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_evt_wait -----------------------------------*/ -OS_RESULT rt_evt_wait (U16 wait_flags, U16 timeout, BOOL and_wait) { +OS_RESULT rt_evt_wait(U16 wait_flags, U16 timeout, BOOL and_wait) { /* Wait for one or more event flags with optional time-out. */ /* "wait_flags" identifies the flags to wait for. */ /* "timeout" is the time-out limit in system ticks (0xffff if no time-out) */ @@ -67,8 +65,7 @@ OS_RESULT rt_evt_wait (U16 wait_flags, U16 timeout, BOOL and_wait) { return (OS_R_EVT); } block_state = WAIT_AND; - } - else { + } else { /* Check for OR-connected events */ if (os_tsk.run->events & wait_flags) { os_tsk.run->waits = os_tsk.run->events & wait_flags; @@ -79,23 +76,22 @@ OS_RESULT rt_evt_wait (U16 wait_flags, U16 timeout, BOOL and_wait) { } /* Task has to wait */ os_tsk.run->waits = wait_flags; - rt_block (timeout, (U8)block_state); + rt_block(timeout, (U8)block_state); return (OS_R_TMO); } - /*--------------------------- rt_evt_set ------------------------------------*/ -void rt_evt_set (U16 event_flags, OS_TID task_id) { +void rt_evt_set(U16 event_flags, OS_TID task_id) { /* Set one or more event flags of a selectable task. */ P_TCB p_tcb; - p_tcb = os_active_TCB[task_id-1]; + p_tcb = os_active_TCB[task_id - 1]; if (p_tcb == NULL) { return; } p_tcb->events |= event_flags; - event_flags = p_tcb->waits; + event_flags = p_tcb->waits; /* If the task is not waiting for an event, it should not be put */ /* to ready state. */ if (p_tcb->state == WAIT_AND) { @@ -107,27 +103,27 @@ void rt_evt_set (U16 event_flags, OS_TID task_id) { if (p_tcb->state == WAIT_OR) { /* Check for OR-connected events */ if (p_tcb->events & event_flags) { - p_tcb->waits &= p_tcb->events; -wkup: p_tcb->events &= ~event_flags; - rt_rmv_dly (p_tcb); - p_tcb->state = READY; + p_tcb->waits &= p_tcb->events; + wkup: + p_tcb->events &= ~event_flags; + rt_rmv_dly(p_tcb); + p_tcb->state = READY; #ifdef __CMSIS_RTOS - rt_ret_val2(p_tcb, 0x08/*osEventSignal*/, p_tcb->waits); + rt_ret_val2(p_tcb, 0x08 /*osEventSignal*/, p_tcb->waits); #else - rt_ret_val (p_tcb, OS_R_EVT); + rt_ret_val(p_tcb, OS_R_EVT); #endif - rt_dispatch (p_tcb); + rt_dispatch(p_tcb); } } } - /*--------------------------- rt_evt_clr ------------------------------------*/ -void rt_evt_clr (U16 clear_flags, OS_TID task_id) { +void rt_evt_clr(U16 clear_flags, OS_TID task_id) { /* Clear one or more event flags (identified by "clear_flags") of a */ /* selectable task (identified by "task"). */ - P_TCB task = os_active_TCB[task_id-1]; + P_TCB task = os_active_TCB[task_id - 1]; if (task == NULL) { return; @@ -135,32 +131,29 @@ void rt_evt_clr (U16 clear_flags, OS_TID task_id) { task->events &= ~clear_flags; } - /*--------------------------- isr_evt_set -----------------------------------*/ -void isr_evt_set (U16 event_flags, OS_TID task_id) { +void isr_evt_set(U16 event_flags, OS_TID task_id) { /* Same function as "os_evt_set", but to be called by ISRs. */ - P_TCB p_tcb = os_active_TCB[task_id-1]; + P_TCB p_tcb = os_active_TCB[task_id - 1]; if (p_tcb == NULL) { return; } - rt_psq_enq (p_tcb, event_flags); - rt_psh_req (); + rt_psq_enq(p_tcb, event_flags); + rt_psh_req(); } - /*--------------------------- rt_evt_get ------------------------------------*/ -U16 rt_evt_get (void) { +U16 rt_evt_get(void) { /* Get events of a running task after waiting for OR connected events. */ return (os_tsk.run->waits); } - /*--------------------------- rt_evt_psh ------------------------------------*/ -void rt_evt_psh (P_TCB p_CB, U16 set_flags) { +void rt_evt_psh(P_TCB p_CB, U16 set_flags) { /* Check if task has to be waken up */ U16 event_flags; @@ -175,16 +168,17 @@ void rt_evt_psh (P_TCB p_CB, U16 set_flags) { if (p_CB->state == WAIT_OR) { /* Check for OR-connected events */ if (p_CB->events & event_flags) { - p_CB->waits &= p_CB->events; -rdy: p_CB->events &= ~event_flags; - rt_rmv_dly (p_CB); - p_CB->state = READY; + p_CB->waits &= p_CB->events; + rdy: + p_CB->events &= ~event_flags; + rt_rmv_dly(p_CB); + p_CB->state = READY; #ifdef __CMSIS_RTOS - rt_ret_val2(p_CB, 0x08/*osEventSignal*/, p_CB->waits); + rt_ret_val2(p_CB, 0x08 /*osEventSignal*/, p_CB->waits); #else - rt_ret_val (p_CB, OS_R_EVT); + rt_ret_val(p_CB, OS_R_EVT); #endif - rt_put_prio (&os_rdy, p_CB); + rt_put_prio(&os_rdy, p_CB); } } } diff --git a/rtos/rtx/TARGET_CORTEX_A/rt_List.c b/rtos/rtx/TARGET_CORTEX_A/rt_List.c index 7dede12..f2db232 100644 --- a/rtos/rtx/TARGET_CORTEX_A/rt_List.c +++ b/rtos/rtx/TARGET_CORTEX_A/rt_List.c @@ -32,12 +32,12 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" +#include "rt_List.h" #include "RTX_Config.h" #include "rt_System.h" -#include "rt_List.h" #include "rt_Task.h" #include "rt_Time.h" +#include "rt_TypeDef.h" #ifdef __CORTEX_A9 #include "rt_HAL_CA.h" #else @@ -49,19 +49,17 @@ *---------------------------------------------------------------------------*/ /* List head of chained ready tasks */ -struct OS_XCB os_rdy; +struct OS_XCB os_rdy; /* List head of chained delay tasks */ -struct OS_XCB os_dly; - +struct OS_XCB os_dly; /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_put_prio -----------------------------------*/ -void rt_put_prio (P_XCB p_CB, P_TCB p_task) { +void rt_put_prio(P_XCB p_CB, P_TCB p_task) { /* Put task identified with "p_task" into list ordered by priority. */ /* "p_CB" points to head of list; list has always an element at end with */ /* a priority less than "p_task->prio". */ @@ -87,16 +85,14 @@ void rt_put_prio (P_XCB p_CB, P_TCB p_task) { p_CB2->p_rlnk = p_task; } p_task->p_rlnk = (P_TCB)p_CB; - } - else { + } else { p_task->p_rlnk = NULL; } } - /*--------------------------- rt_get_first ----------------------------------*/ -P_TCB rt_get_first (P_XCB p_CB) { +P_TCB rt_get_first(P_XCB p_CB) { /* Get task at head of list: it is the task with highest priority. */ /* "p_CB" points to head of list. */ P_TCB p_first; @@ -109,17 +105,15 @@ P_TCB rt_get_first (P_XCB p_CB) { p_first->p_lnk = NULL; } p_first->p_rlnk = NULL; - } - else { + } else { p_first->p_lnk = NULL; } return (p_first); } - /*--------------------------- rt_put_rdy_first ------------------------------*/ -void rt_put_rdy_first (P_TCB p_task) { +void rt_put_rdy_first(P_TCB p_task) { /* Put task identified with "p_task" at the head of the ready list. The */ /* task must have at least a priority equal to highest priority in list. */ p_task->p_lnk = os_rdy.p_lnk; @@ -127,10 +121,9 @@ void rt_put_rdy_first (P_TCB p_task) { os_rdy.p_lnk = p_task; } - /*--------------------------- rt_get_same_rdy_prio --------------------------*/ -P_TCB rt_get_same_rdy_prio (void) { +P_TCB rt_get_same_rdy_prio(void) { /* Remove a task of same priority from ready list if any exists. Other- */ /* wise return NULL. */ P_TCB p_first; @@ -143,10 +136,9 @@ P_TCB rt_get_same_rdy_prio (void) { return (NULL); } - /*--------------------------- rt_resort_prio --------------------------------*/ -void rt_resort_prio (P_TCB p_task) { +void rt_resort_prio(P_TCB p_task) { /* Re-sort ordered lists after the priority of 'p_task' has changed. */ P_TCB p_CB; @@ -156,26 +148,25 @@ void rt_resort_prio (P_TCB p_task) { p_CB = (P_TCB)&os_rdy; goto res; } - } - else { + } else { p_CB = p_task->p_rlnk; while (p_CB->cb_type == TCB) { /* Find a header of this task chain list. */ p_CB = p_CB->p_rlnk; } -res:rt_rmv_list (p_task); - rt_put_prio ((P_XCB)p_CB, p_task); + res: + rt_rmv_list(p_task); + rt_put_prio((P_XCB)p_CB, p_task); } } - /*--------------------------- rt_put_dly ------------------------------------*/ -void rt_put_dly (P_TCB p_task, U16 delay) { +void rt_put_dly(P_TCB p_task, U16 delay) { /* Put a task identified with "p_task" into chained delay wait list using */ /* a delay value of "delay". */ P_TCB p; - U32 delta,idelay = delay; + U32 delta, idelay = delay; p = (P_TCB)&os_dly; if (p->p_dlnk == NULL) { @@ -187,7 +178,8 @@ void rt_put_dly (P_TCB p_task, U16 delay) { while (delta < idelay) { if (p->p_dlnk == NULL) { /* End of list found */ -last: p_task->p_dlnk = NULL; + last: + p_task->p_dlnk = NULL; p->p_dlnk = p_task; p_task->p_blnk = p; p->delta_time = (U16)(idelay - delta); @@ -208,10 +200,9 @@ last: p_task->p_dlnk = NULL; p->delta_time -= p_task->delta_time; } - /*--------------------------- rt_dec_dly ------------------------------------*/ -void rt_dec_dly (void) { +void rt_dec_dly(void) { /* Decrement delta time of list head: remove tasks having a value of zero.*/ P_TCB p_rdy; @@ -231,26 +222,25 @@ void rt_dec_dly (void) { } p_rdy->p_rlnk = NULL; } - rt_put_prio (&os_rdy, p_rdy); + rt_put_prio(&os_rdy, p_rdy); os_dly.delta_time = p_rdy->delta_time; if (p_rdy->state == WAIT_ITV) { /* Calculate the next time for interval wait. */ p_rdy->delta_time = p_rdy->interval_time + (U16)os_time; } - p_rdy->state = READY; + p_rdy->state = READY; os_dly.p_dlnk = p_rdy->p_dlnk; if (p_rdy->p_dlnk != NULL) { - p_rdy->p_dlnk->p_blnk = (P_TCB)&os_dly; + p_rdy->p_dlnk->p_blnk = (P_TCB)&os_dly; p_rdy->p_dlnk = NULL; } p_rdy->p_blnk = NULL; } } - /*--------------------------- rt_rmv_list -----------------------------------*/ -void rt_rmv_list (P_TCB p_task) { +void rt_rmv_list(P_TCB p_task) { /* Remove task identified with "p_task" from ready, semaphore or mailbox */ /* waiting list if enqueued. */ P_TCB p_b; @@ -275,10 +265,9 @@ void rt_rmv_list (P_TCB p_task) { } } - /*--------------------------- rt_rmv_dly ------------------------------------*/ -void rt_rmv_dly (P_TCB p_task) { +void rt_rmv_dly(P_TCB p_task) { /* Remove task identified with "p_task" from delay list if enqueued. */ P_TCB p_b; @@ -291,8 +280,7 @@ void rt_rmv_dly (P_TCB p_task) { p_b->delta_time += p_task->delta_time; p_task->p_dlnk->p_blnk = p_b; p_task->p_dlnk = NULL; - } - else { + } else { /* 'p_task' is at the end of list */ p_b->delta_time = 0; } @@ -300,25 +288,21 @@ void rt_rmv_dly (P_TCB p_task) { } } - /*--------------------------- rt_psq_enq ------------------------------------*/ -void rt_psq_enq (OS_ID entry, U32 arg) { +void rt_psq_enq(OS_ID entry, U32 arg) { /* Insert post service request "entry" into ps-queue. */ U32 idx; - idx = rt_inc_qi (os_psq->size, &os_psq->count, &os_psq->first); + idx = rt_inc_qi(os_psq->size, &os_psq->count, &os_psq->first); if (idx < os_psq->size) { - os_psq->q[idx].id = entry; + os_psq->q[idx].id = entry; os_psq->q[idx].arg = arg; - } - else { - os_error (OS_ERR_FIFO_OVF); + } else { + os_error(OS_ERR_FIFO_OVF); } } - /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_A/rt_Mailbox.c b/rtos/rtx/TARGET_CORTEX_A/rt_Mailbox.c index 81a00b9..9601b45 100644 --- a/rtos/rtx/TARGET_CORTEX_A/rt_Mailbox.c +++ b/rtos/rtx/TARGET_CORTEX_A/rt_Mailbox.c @@ -32,63 +32,59 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" -#include "RTX_Config.h" -#include "rt_System.h" -#include "rt_List.h" #include "rt_Mailbox.h" +#include "RTX_Config.h" +#include "rt_List.h" #include "rt_MemBox.h" +#include "rt_System.h" #include "rt_Task.h" +#include "rt_TypeDef.h" #ifdef __CORTEX_A9 #include "rt_HAL_CA.h" #else #include "rt_HAL_CM.h" #endif - /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_mbx_init -----------------------------------*/ -void rt_mbx_init (OS_ID mailbox, U16 mbx_size) { +void rt_mbx_init(OS_ID mailbox, U16 mbx_size) { /* Initialize a mailbox */ P_MCB p_MCB = mailbox; p_MCB->cb_type = MCB; - p_MCB->state = 0; - p_MCB->isr_st = 0; - p_MCB->p_lnk = NULL; - p_MCB->first = 0; - p_MCB->last = 0; - p_MCB->count = 0; - p_MCB->size = (mbx_size + sizeof(void *) - sizeof(struct OS_MCB)) / - (U32)sizeof (void *); + p_MCB->state = 0; + p_MCB->isr_st = 0; + p_MCB->p_lnk = NULL; + p_MCB->first = 0; + p_MCB->last = 0; + p_MCB->count = 0; + p_MCB->size = + (mbx_size + sizeof(void *) - sizeof(struct OS_MCB)) / (U32)sizeof(void *); } - /*--------------------------- rt_mbx_send -----------------------------------*/ -OS_RESULT rt_mbx_send (OS_ID mailbox, void *p_msg, U16 timeout) { +OS_RESULT rt_mbx_send(OS_ID mailbox, void *p_msg, U16 timeout) { /* Send message to a mailbox */ P_MCB p_MCB = mailbox; P_TCB p_TCB; if ((p_MCB->p_lnk != NULL) && (p_MCB->state == 1)) { /* A task is waiting for message */ - p_TCB = rt_get_first ((P_XCB)p_MCB); + p_TCB = rt_get_first((P_XCB)p_MCB); #ifdef __CMSIS_RTOS - rt_ret_val2(p_TCB, 0x10/*osEventMessage*/, (U32)p_msg); + rt_ret_val2(p_TCB, 0x10 /*osEventMessage*/, (U32)p_msg); #else *p_TCB->msg = p_msg; - rt_ret_val (p_TCB, OS_R_MBX); + rt_ret_val(p_TCB, OS_R_MBX); #endif - rt_rmv_dly (p_TCB); - rt_dispatch (p_TCB); - } - else { + rt_rmv_dly(p_TCB); + rt_dispatch(p_TCB); + } else { /* Store message in mailbox queue */ if (p_MCB->count == p_MCB->size) { /* No free message entry, wait for one. If message queue is full, */ @@ -98,22 +94,21 @@ OS_RESULT rt_mbx_send (OS_ID mailbox, void *p_msg, U16 timeout) { return (OS_R_TMO); } if (p_MCB->p_lnk != NULL) { - rt_put_prio ((P_XCB)p_MCB, os_tsk.run); - } - else { + rt_put_prio((P_XCB)p_MCB, os_tsk.run); + } else { p_MCB->p_lnk = os_tsk.run; - os_tsk.run->p_lnk = NULL; + os_tsk.run->p_lnk = NULL; os_tsk.run->p_rlnk = (P_TCB)p_MCB; /* Task is waiting to send a message */ p_MCB->state = 2; } os_tsk.run->msg = p_msg; - rt_block (timeout, WAIT_MBX); + rt_block(timeout, WAIT_MBX); return (OS_R_TMO); } /* Yes, there is a free entry in a mailbox. */ p_MCB->msg[p_MCB->first] = p_msg; - rt_inc (&p_MCB->count); + rt_inc(&p_MCB->count); if (++p_MCB->first == p_MCB->size) { p_MCB->first = 0; } @@ -121,10 +116,9 @@ OS_RESULT rt_mbx_send (OS_ID mailbox, void *p_msg, U16 timeout) { return (OS_R_OK); } - /*--------------------------- rt_mbx_wait -----------------------------------*/ -OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout) { +OS_RESULT rt_mbx_wait(OS_ID mailbox, void **message, U16 timeout) { /* Receive a message; possibly wait for it */ P_MCB p_MCB = mailbox; P_TCB p_TCB; @@ -138,9 +132,9 @@ OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout) { } if ((p_MCB->p_lnk != NULL) && (p_MCB->state == 2)) { /* A task is waiting to send message */ - p_TCB = rt_get_first ((P_XCB)p_MCB); + p_TCB = rt_get_first((P_XCB)p_MCB); #ifdef __CMSIS_RTOS - rt_ret_val(p_TCB, 0/*osOK*/); + rt_ret_val(p_TCB, 0 /*osOK*/); #else rt_ret_val(p_TCB, OS_R_OK); #endif @@ -148,11 +142,10 @@ OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout) { if (++p_MCB->first == p_MCB->size) { p_MCB->first = 0; } - rt_rmv_dly (p_TCB); - rt_dispatch (p_TCB); - } - else { - rt_dec (&p_MCB->count); + rt_rmv_dly(p_TCB); + rt_dispatch(p_TCB); + } else { + rt_dec(&p_MCB->count); } return (OS_R_OK); } @@ -161,9 +154,8 @@ OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout) { return (OS_R_TMO); } if (p_MCB->p_lnk != NULL) { - rt_put_prio ((P_XCB)p_MCB, os_tsk.run); - } - else { + rt_put_prio((P_XCB)p_MCB, os_tsk.run); + } else { p_MCB->p_lnk = os_tsk.run; os_tsk.run->p_lnk = NULL; os_tsk.run->p_rlnk = (P_TCB)p_MCB; @@ -177,10 +169,9 @@ OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout) { return (OS_R_TMO); } - /*--------------------------- rt_mbx_check ----------------------------------*/ -OS_RESULT rt_mbx_check (OS_ID mailbox) { +OS_RESULT rt_mbx_check(OS_ID mailbox) { /* Check for free space in a mailbox. Returns the number of messages */ /* that can be stored to a mailbox. It returns 0 when mailbox is full. */ P_MCB p_MCB = mailbox; @@ -188,21 +179,19 @@ OS_RESULT rt_mbx_check (OS_ID mailbox) { return (p_MCB->size - p_MCB->count); } - /*--------------------------- isr_mbx_send ----------------------------------*/ -void isr_mbx_send (OS_ID mailbox, void *p_msg) { +void isr_mbx_send(OS_ID mailbox, void *p_msg) { /* Same function as "os_mbx_send", but to be called by ISRs. */ P_MCB p_MCB = mailbox; - rt_psq_enq (p_MCB, (U32)p_msg); - rt_psh_req (); + rt_psq_enq(p_MCB, (U32)p_msg); + rt_psh_req(); } - /*--------------------------- isr_mbx_receive -------------------------------*/ -OS_RESULT isr_mbx_receive (OS_ID mailbox, void **message) { +OS_RESULT isr_mbx_receive(OS_ID mailbox, void **message) { /* Receive a message in the interrupt function. The interrupt function */ /* should not wait for a message since this would block the rtx os. */ P_MCB p_MCB = mailbox; @@ -212,10 +201,10 @@ OS_RESULT isr_mbx_receive (OS_ID mailbox, void **message) { *message = p_MCB->msg[p_MCB->last]; if (p_MCB->state == 2) { /* A task is locked waiting to send message */ - rt_psq_enq (p_MCB, 0); - rt_psh_req (); + rt_psq_enq(p_MCB, 0); + rt_psh_req(); } - rt_dec (&p_MCB->count); + rt_dec(&p_MCB->count); if (++p_MCB->last == p_MCB->size) { p_MCB->last = 0; } @@ -224,68 +213,69 @@ OS_RESULT isr_mbx_receive (OS_ID mailbox, void **message) { return (OS_R_OK); } - /*--------------------------- rt_mbx_psh ------------------------------------*/ -void rt_mbx_psh (P_MCB p_CB, void *p_msg) { +void rt_mbx_psh(P_MCB p_CB, void *p_msg) { /* Store the message to the mailbox queue or pass it to task directly. */ P_TCB p_TCB; void *mem; - if (p_CB->p_lnk != NULL) switch (p_CB->state) { + if (p_CB->p_lnk != NULL) + switch (p_CB->state) { #ifdef __CMSIS_RTOS case 3: /* Task is waiting to allocate memory, remove it from the waiting list */ mem = rt_alloc_box(p_msg); - if (mem == NULL) break; - p_TCB = rt_get_first ((P_XCB)p_CB); + if (mem == NULL) + break; + p_TCB = rt_get_first((P_XCB)p_CB); rt_ret_val(p_TCB, (U32)mem); p_TCB->state = READY; - rt_rmv_dly (p_TCB); - rt_put_prio (&os_rdy, p_TCB); + rt_rmv_dly(p_TCB); + rt_put_prio(&os_rdy, p_TCB); break; #endif case 2: /* Task is waiting to send a message, remove it from the waiting list */ - p_TCB = rt_get_first ((P_XCB)p_CB); + p_TCB = rt_get_first((P_XCB)p_CB); #ifdef __CMSIS_RTOS - rt_ret_val(p_TCB, 0/*osOK*/); + rt_ret_val(p_TCB, 0 /*osOK*/); #else rt_ret_val(p_TCB, OS_R_OK); #endif p_CB->msg[p_CB->first] = p_TCB->msg; - rt_inc (&p_CB->count); + rt_inc(&p_CB->count); if (++p_CB->first == p_CB->size) { p_CB->first = 0; } p_TCB->state = READY; - rt_rmv_dly (p_TCB); - rt_put_prio (&os_rdy, p_TCB); + rt_rmv_dly(p_TCB); + rt_put_prio(&os_rdy, p_TCB); break; case 1: /* Task is waiting for a message, pass the message to the task directly */ - p_TCB = rt_get_first ((P_XCB)p_CB); + p_TCB = rt_get_first((P_XCB)p_CB); #ifdef __CMSIS_RTOS - rt_ret_val2(p_TCB, 0x10/*osEventMessage*/, (U32)p_msg); + rt_ret_val2(p_TCB, 0x10 /*osEventMessage*/, (U32)p_msg); #else *p_TCB->msg = p_msg; - rt_ret_val (p_TCB, OS_R_MBX); + rt_ret_val(p_TCB, OS_R_MBX); #endif p_TCB->state = READY; - rt_rmv_dly (p_TCB); - rt_put_prio (&os_rdy, p_TCB); + rt_rmv_dly(p_TCB); + rt_put_prio(&os_rdy, p_TCB); break; - } else { + } + else { /* No task is waiting for a message, store it to the mailbox queue */ if (p_CB->count < p_CB->size) { p_CB->msg[p_CB->first] = p_msg; - rt_inc (&p_CB->count); + rt_inc(&p_CB->count); if (++p_CB->first == p_CB->size) { p_CB->first = 0; } - } - else { - os_error (OS_ERR_MBX_OVF); + } else { + os_error(OS_ERR_MBX_OVF); } } } @@ -293,4 +283,3 @@ void rt_mbx_psh (P_MCB p_CB, void *p_msg) { /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_A/rt_MemBox.c b/rtos/rtx/TARGET_CORTEX_A/rt_MemBox.c index ad5ced1..fe7f28a 100644 --- a/rtos/rtx/TARGET_CORTEX_A/rt_MemBox.c +++ b/rtos/rtx/TARGET_CORTEX_A/rt_MemBox.c @@ -32,10 +32,10 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" +#include "rt_MemBox.h" #include "RTX_Config.h" #include "rt_System.h" -#include "rt_MemBox.h" +#include "rt_TypeDef.h" #ifdef __CORTEX_A9 #include "rt_HAL_CA.h" #else @@ -46,26 +46,24 @@ * Global Functions *---------------------------------------------------------------------------*/ - /*--------------------------- _init_box -------------------------------------*/ -int _init_box (void *box_mem, U32 box_size, U32 blk_size) { +int _init_box(void *box_mem, U32 box_size, U32 blk_size) { /* Initialize memory block system, returns 0 if OK, 1 if fails. */ void *end; void *blk; void *next; - U32 sizeof_bm; + U32 sizeof_bm; /* Create memory structure. */ if (blk_size & BOX_ALIGN_8) { /* Memory blocks 8-byte aligned. */ blk_size = ((blk_size & ~BOX_ALIGN_8) + 7) & ~7; - sizeof_bm = (sizeof (struct OS_BM) + 7) & ~7; - } - else { + sizeof_bm = (sizeof(struct OS_BM) + 7) & ~7; + } else { /* Memory blocks 4-byte aligned. */ blk_size = (blk_size + 3) & ~3; - sizeof_bm = sizeof (struct OS_BM); + sizeof_bm = sizeof(struct OS_BM); } if (blk_size == 0) { return (1); @@ -74,17 +72,18 @@ int _init_box (void *box_mem, U32 box_size, U32 blk_size) { return (1); } /* Create a Memory structure. */ - blk = ((U8 *) box_mem) + sizeof_bm; - ((P_BM) box_mem)->free = blk; - end = ((U8 *) box_mem) + box_size; - ((P_BM) box_mem)->end = end; - ((P_BM) box_mem)->blk_size = blk_size; + blk = ((U8 *)box_mem) + sizeof_bm; + ((P_BM)box_mem)->free = blk; + end = ((U8 *)box_mem) + box_size; + ((P_BM)box_mem)->end = end; + ((P_BM)box_mem)->blk_size = blk_size; /* Link all free blocks using offsets. */ - end = ((U8 *) end) - blk_size; - while (1) { - next = ((U8 *) blk) + blk_size; - if (next > end) break; + end = ((U8 *)end) - blk_size; + while (1) { + next = ((U8 *)blk) + blk_size; + if (next > end) + break; *((void **)blk) = next; blk = next; } @@ -95,42 +94,42 @@ int _init_box (void *box_mem, U32 box_size, U32 blk_size) { /*--------------------------- rt_alloc_box ----------------------------------*/ -void *rt_alloc_box (void *box_mem) { +void *rt_alloc_box(void *box_mem) { /* Allocate a memory block and return start address. */ void **free; #ifndef __USE_EXCLUSIVE_ACCESS - int irq_dis; + int irq_dis; - irq_dis = __disable_irq (); - free = ((P_BM) box_mem)->free; + irq_dis = __disable_irq(); + free = ((P_BM)box_mem)->free; if (free) { - ((P_BM) box_mem)->free = *free; + ((P_BM)box_mem)->free = *free; } - if (!irq_dis) __enable_irq (); + if (!irq_dis) + __enable_irq(); #else do { - if ((free = (void **)__ldrex(&((P_BM) box_mem)->free)) == 0) { + if ((free = (void **)__ldrex(&((P_BM)box_mem)->free)) == 0) { __clrex(); break; } - } while (__strex((U32)*free, &((P_BM) box_mem)->free)); + } while (__strex((U32)*free, &((P_BM)box_mem)->free)); #endif return (free); } - /*--------------------------- _calloc_box -----------------------------------*/ -void *_calloc_box (void *box_mem) { +void *_calloc_box(void *box_mem) { /* Allocate a 0-initialized memory block and return start address. */ void *free; U32 *p; U32 i; - free = _alloc_box (box_mem); - if (free) { + free = _alloc_box(box_mem); + if (free) { p = free; - for (i = ((P_BM) box_mem)->blk_size; i; i -= 4) { + for (i = ((P_BM)box_mem)->blk_size; i; i -= 4) { *p = 0; p++; } @@ -138,28 +137,29 @@ void *_calloc_box (void *box_mem) { return (free); } - /*--------------------------- rt_free_box -----------------------------------*/ -int rt_free_box (void *box_mem, void *box) { - /* Free a memory block, returns 0 if OK, 1 if box does not belong to box_mem */ +int rt_free_box(void *box_mem, void *box) { + /* Free a memory block, returns 0 if OK, 1 if box does not belong to box_mem + */ #ifndef __USE_EXCLUSIVE_ACCESS int irq_dis; #endif - if (box < box_mem || box >= ((P_BM) box_mem)->end) { + if (box < box_mem || box >= ((P_BM)box_mem)->end) { return (1); } #ifndef __USE_EXCLUSIVE_ACCESS - irq_dis = __disable_irq (); - *((void **)box) = ((P_BM) box_mem)->free; - ((P_BM) box_mem)->free = box; - if (!irq_dis) __enable_irq (); + irq_dis = __disable_irq(); + *((void **)box) = ((P_BM)box_mem)->free; + ((P_BM)box_mem)->free = box; + if (!irq_dis) + __enable_irq(); #else do { - *((void **)box) = (void *)__ldrex(&((P_BM) box_mem)->free); - } while (__strex ((U32)box, &((P_BM) box_mem)->free)); + *((void **)box) = (void *)__ldrex(&((P_BM)box_mem)->free); + } while (__strex((U32)box, &((P_BM)box_mem)->free)); #endif return (0); } @@ -167,4 +167,3 @@ int rt_free_box (void *box_mem, void *box) { /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_A/rt_Memory.c b/rtos/rtx/TARGET_CORTEX_A/rt_Memory.c index f6499fb..97bb7e5 100644 --- a/rtos/rtx/TARGET_CORTEX_A/rt_Memory.c +++ b/rtos/rtx/TARGET_CORTEX_A/rt_Memory.c @@ -32,9 +32,8 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" #include "rt_Memory.h" - +#include "rt_TypeDef.h" /* Functions */ @@ -44,10 +43,11 @@ // size: Size of memory pool in bytes // Return: 0 - OK, 1 - Error -int rt_init_mem (void *pool, U32 size) { +int rt_init_mem(void *pool, U32 size) { MEMP *ptr; - if ((pool == NULL) || (size < sizeof(MEMP))) return (1); + if ((pool == NULL) || (size < sizeof(MEMP))) + return (1); ptr = (MEMP *)pool; ptr->next = (MEMP *)((U32)pool + size - sizeof(MEMP *)); @@ -63,11 +63,12 @@ int rt_init_mem (void *pool, U32 size) { // size: Size of memory in bytes to allocate // Return: Pointer to allocated memory -void *rt_alloc_mem (void *pool, U32 size) { +void *rt_alloc_mem(void *pool, U32 size) { MEMP *p, *p_search, *p_new; - U32 hole_size; + U32 hole_size; - if ((pool == NULL) || (size == 0)) return NULL; + if ((pool == NULL) || (size == 0)) + return NULL; /* Add header offset to 'size' */ size += sizeof(MEMP); @@ -76,10 +77,11 @@ void *rt_alloc_mem (void *pool, U32 size) { p_search = (MEMP *)pool; while (1) { - hole_size = (U32)p_search->next - (U32)p_search; + hole_size = (U32)p_search->next - (U32)p_search; hole_size -= p_search->len; /* Check if hole size is big enough */ - if (hole_size >= size) break; + if (hole_size >= size) + break; p_search = p_search->next; if (p_search->next == NULL) { /* Failed, we are at the end of the list */ @@ -93,9 +95,9 @@ void *rt_alloc_mem (void *pool, U32 size) { p = (MEMP *)(((U32)p_search) + sizeof(MEMP)); } else { /* Insert new list element into the memory list */ - p_new = (MEMP *)((U32)p_search + p_search->len); + p_new = (MEMP *)((U32)p_search + p_search->len); p_new->next = p_search->next; - p_new->len = size; + p_new->len = size; p_search->next = p_new; p = (MEMP *)(((U32)p_new) + sizeof(MEMP)); } @@ -109,10 +111,11 @@ void *rt_alloc_mem (void *pool, U32 size) { // mem: Pointer to memory to free // Return: 0 - OK, 1 - Error -int rt_free_mem (void *pool, void *mem) { +int rt_free_mem(void *pool, void *mem) { MEMP *p_search, *p_prev, *p_return; - if ((pool == NULL) || (mem == NULL)) return (1); + if ((pool == NULL) || (mem == NULL)) + return (1); p_return = (MEMP *)((U32)mem - sizeof(MEMP)); @@ -120,7 +123,7 @@ int rt_free_mem (void *pool, void *mem) { p_prev = NULL; p_search = (MEMP *)pool; while (p_search != p_return) { - p_prev = p_search; + p_prev = p_search; p_search = p_search->next; if (p_search == NULL) { /* Valid Memory block not found */ diff --git a/rtos/rtx/TARGET_CORTEX_A/rt_Mutex.c b/rtos/rtx/TARGET_CORTEX_A/rt_Mutex.c index 4b2fbf8..bafd5b4 100644 --- a/rtos/rtx/TARGET_CORTEX_A/rt_Mutex.c +++ b/rtos/rtx/TARGET_CORTEX_A/rt_Mutex.c @@ -32,68 +32,65 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" +#include "rt_Mutex.h" #include "RTX_Config.h" #include "rt_List.h" #include "rt_Task.h" -#include "rt_Mutex.h" +#include "rt_TypeDef.h" #ifdef __CORTEX_A9 #include "rt_HAL_CA.h" #else #include "rt_HAL_CM.h" #endif - /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_mut_init -----------------------------------*/ -void rt_mut_init (OS_ID mutex) { +void rt_mut_init(OS_ID mutex) { /* Initialize a mutex object */ P_MUCB p_MCB = mutex; p_MCB->cb_type = MUCB; - p_MCB->prio = 0; - p_MCB->level = 0; - p_MCB->p_lnk = NULL; - p_MCB->owner = NULL; + p_MCB->prio = 0; + p_MCB->level = 0; + p_MCB->p_lnk = NULL; + p_MCB->owner = NULL; } - /*--------------------------- rt_mut_delete ---------------------------------*/ #ifdef __CMSIS_RTOS -OS_RESULT rt_mut_delete (OS_ID mutex) { +OS_RESULT rt_mut_delete(OS_ID mutex) { /* Delete a mutex object */ P_MUCB p_MCB = mutex; - P_TCB p_TCB; + P_TCB p_TCB; __DMB(); /* Restore owner task's priority. */ if (p_MCB->level != 0) { p_MCB->owner->prio = p_MCB->prio; if (p_MCB->owner != os_tsk.run) { - rt_resort_prio (p_MCB->owner); + rt_resort_prio(p_MCB->owner); } } while (p_MCB->p_lnk != NULL) { /* A task is waiting for mutex. */ - p_TCB = rt_get_first ((P_XCB)p_MCB); - rt_ret_val(p_TCB, 0/*osOK*/); + p_TCB = rt_get_first((P_XCB)p_MCB); + rt_ret_val(p_TCB, 0 /*osOK*/); rt_rmv_dly(p_TCB); p_TCB->state = READY; - rt_put_prio (&os_rdy, p_TCB); + rt_put_prio(&os_rdy, p_TCB); } if (os_rdy.p_lnk && (os_rdy.p_lnk->prio > os_tsk.run->prio)) { /* preempt running task */ - rt_put_prio (&os_rdy, os_tsk.run); + rt_put_prio(&os_rdy, os_tsk.run); os_tsk.run->state = READY; - rt_dispatch (NULL); + rt_dispatch(NULL); } p_MCB->cb_type = 0; @@ -102,13 +99,12 @@ OS_RESULT rt_mut_delete (OS_ID mutex) { } #endif - /*--------------------------- rt_mut_release --------------------------------*/ -OS_RESULT rt_mut_release (OS_ID mutex) { +OS_RESULT rt_mut_release(OS_ID mutex) { /* Release a mutex object */ P_MUCB p_MCB = mutex; - P_TCB p_TCB; + P_TCB p_TCB; if (p_MCB->level == 0 || p_MCB->owner != os_tsk.run) { /* Unbalanced mutex release or task is not the owner */ @@ -122,56 +118,54 @@ OS_RESULT rt_mut_release (OS_ID mutex) { os_tsk.run->prio = p_MCB->prio; if (p_MCB->p_lnk != NULL) { /* A task is waiting for mutex. */ - p_TCB = rt_get_first ((P_XCB)p_MCB); + p_TCB = rt_get_first((P_XCB)p_MCB); #ifdef __CMSIS_RTOS - rt_ret_val(p_TCB, 0/*osOK*/); + rt_ret_val(p_TCB, 0 /*osOK*/); #else rt_ret_val(p_TCB, OS_R_MUT); #endif - rt_rmv_dly (p_TCB); + rt_rmv_dly(p_TCB); /* A waiting task becomes the owner of this mutex. */ - p_MCB->level = 1; - p_MCB->owner = p_TCB; - p_MCB->prio = p_TCB->prio; + p_MCB->level = 1; + p_MCB->owner = p_TCB; + p_MCB->prio = p_TCB->prio; /* Priority inversion, check which task continues. */ if (os_tsk.run->prio >= rt_rdy_prio()) { - rt_dispatch (p_TCB); - } - else { + rt_dispatch(p_TCB); + } else { /* Ready task has higher priority than running task. */ - rt_put_prio (&os_rdy, os_tsk.run); - rt_put_prio (&os_rdy, p_TCB); + rt_put_prio(&os_rdy, os_tsk.run); + rt_put_prio(&os_rdy, p_TCB); os_tsk.run->state = READY; - p_TCB->state = READY; - rt_dispatch (NULL); + p_TCB->state = READY; + rt_dispatch(NULL); } - } - else { + } else { /* Check if own priority raised by priority inversion. */ if (rt_rdy_prio() > os_tsk.run->prio) { - rt_put_prio (&os_rdy, os_tsk.run); + rt_put_prio(&os_rdy, os_tsk.run); os_tsk.run->state = READY; - rt_dispatch (NULL); + rt_dispatch(NULL); } } return (OS_R_OK); } - /*--------------------------- rt_mut_wait -----------------------------------*/ -OS_RESULT rt_mut_wait (OS_ID mutex, U16 timeout) { +OS_RESULT rt_mut_wait(OS_ID mutex, U16 timeout) { /* Wait for a mutex, continue when mutex is free. */ P_MUCB p_MCB = mutex; if (p_MCB->level == 0) { p_MCB->owner = os_tsk.run; - p_MCB->prio = os_tsk.run->prio; + p_MCB->prio = os_tsk.run->prio; goto inc; } if (p_MCB->owner == os_tsk.run) { /* OK, running task is the owner of this mutex. */ -inc:p_MCB->level++; + inc: + p_MCB->level++; __DMB(); return (OS_R_OK); } @@ -183,22 +177,19 @@ inc:p_MCB->level++; /* This priority inversion is called priority inheritance. */ if (p_MCB->prio < os_tsk.run->prio) { p_MCB->owner->prio = os_tsk.run->prio; - rt_resort_prio (p_MCB->owner); + rt_resort_prio(p_MCB->owner); } if (p_MCB->p_lnk != NULL) { - rt_put_prio ((P_XCB)p_MCB, os_tsk.run); - } - else { + rt_put_prio((P_XCB)p_MCB, os_tsk.run); + } else { p_MCB->p_lnk = os_tsk.run; - os_tsk.run->p_lnk = NULL; + os_tsk.run->p_lnk = NULL; os_tsk.run->p_rlnk = (P_TCB)p_MCB; } rt_block(timeout, WAIT_MUT); return (OS_R_TMO); } - /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_A/rt_Robin.c b/rtos/rtx/TARGET_CORTEX_A/rt_Robin.c index 66b1d89..b075e44 100644 --- a/rtos/rtx/TARGET_CORTEX_A/rt_Robin.c +++ b/rtos/rtx/TARGET_CORTEX_A/rt_Robin.c @@ -32,12 +32,12 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" +#include "rt_Robin.h" #include "RTX_Config.h" #include "rt_List.h" #include "rt_Task.h" #include "rt_Time.h" -#include "rt_Robin.h" +#include "rt_TypeDef.h" #ifdef __CORTEX_A9 #include "rt_HAL_CA.h" #else @@ -50,14 +50,13 @@ struct OS_ROBIN os_robin; - /*---------------------------------------------------------------------------- * Global Functions *---------------------------------------------------------------------------*/ /*--------------------------- rt_init_robin ---------------------------------*/ -__weak void rt_init_robin (void) { +__weak void rt_init_robin(void) { /* Initialize Round Robin variables. */ os_robin.task = NULL; os_robin.tout = (U16)os_rrobin; @@ -65,7 +64,7 @@ __weak void rt_init_robin (void) { /*--------------------------- rt_chk_robin ----------------------------------*/ -__weak void rt_chk_robin (void) { +__weak void rt_chk_robin(void) { /* Check if Round Robin timeout expired and switch to the next ready task.*/ P_TCB p_new; @@ -77,12 +76,11 @@ __weak void rt_chk_robin (void) { if (os_robin.time == (U16)os_time) { /* Round Robin timeout has expired, swap Robin tasks. */ os_robin.task = NULL; - p_new = rt_get_first (&os_rdy); - rt_put_prio ((P_XCB)&os_rdy, p_new); + p_new = rt_get_first(&os_rdy); + rt_put_prio((P_XCB)&os_rdy, p_new); } } /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_A/rt_Semaphore.c b/rtos/rtx/TARGET_CORTEX_A/rt_Semaphore.c index 192fdbb..ace2a79 100644 --- a/rtos/rtx/TARGET_CORTEX_A/rt_Semaphore.c +++ b/rtos/rtx/TARGET_CORTEX_A/rt_Semaphore.c @@ -32,40 +32,37 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" -#include "RTX_Config.h" -#include "rt_System.h" -#include "rt_List.h" -#include "rt_Task.h" #include "rt_Semaphore.h" +#include "RTX_Config.h" +#include "rt_List.h" +#include "rt_System.h" +#include "rt_Task.h" +#include "rt_TypeDef.h" #ifdef __CORTEX_A9 #include "rt_HAL_CA.h" #else #include "rt_HAL_CM.h" #endif - /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_sem_init -----------------------------------*/ -void rt_sem_init (OS_ID semaphore, U16 token_count) { +void rt_sem_init(OS_ID semaphore, U16 token_count) { /* Initialize a semaphore */ P_SCB p_SCB = semaphore; p_SCB->cb_type = SCB; - p_SCB->p_lnk = NULL; + p_SCB->p_lnk = NULL; p_SCB->tokens = token_count; } - /*--------------------------- rt_sem_delete ---------------------------------*/ #ifdef __CMSIS_RTOS -OS_RESULT rt_sem_delete (OS_ID semaphore) { +OS_RESULT rt_sem_delete(OS_ID semaphore) { /* Delete semaphore */ P_SCB p_SCB = semaphore; P_TCB p_TCB; @@ -73,18 +70,18 @@ OS_RESULT rt_sem_delete (OS_ID semaphore) { __DMB(); while (p_SCB->p_lnk != NULL) { /* A task is waiting for token */ - p_TCB = rt_get_first ((P_XCB)p_SCB); + p_TCB = rt_get_first((P_XCB)p_SCB); rt_ret_val(p_TCB, 0); rt_rmv_dly(p_TCB); p_TCB->state = READY; - rt_put_prio (&os_rdy, p_TCB); + rt_put_prio(&os_rdy, p_TCB); } if (os_rdy.p_lnk && (os_rdy.p_lnk->prio > os_tsk.run->prio)) { /* preempt running task */ - rt_put_prio (&os_rdy, os_tsk.run); + rt_put_prio(&os_rdy, os_tsk.run); os_tsk.run->state = READY; - rt_dispatch (NULL); + rt_dispatch(NULL); } p_SCB->cb_type = 0; @@ -93,10 +90,9 @@ OS_RESULT rt_sem_delete (OS_ID semaphore) { } #endif - /*--------------------------- rt_sem_send -----------------------------------*/ -OS_RESULT rt_sem_send (OS_ID semaphore) { +OS_RESULT rt_sem_send(OS_ID semaphore) { /* Return a token to semaphore */ P_SCB p_SCB = semaphore; P_TCB p_TCB; @@ -104,26 +100,24 @@ OS_RESULT rt_sem_send (OS_ID semaphore) { __DMB(); if (p_SCB->p_lnk != NULL) { /* A task is waiting for token */ - p_TCB = rt_get_first ((P_XCB)p_SCB); + p_TCB = rt_get_first((P_XCB)p_SCB); #ifdef __CMSIS_RTOS rt_ret_val(p_TCB, 1); #else rt_ret_val(p_TCB, OS_R_SEM); #endif - rt_rmv_dly (p_TCB); - rt_dispatch (p_TCB); - } - else { + rt_rmv_dly(p_TCB); + rt_dispatch(p_TCB); + } else { /* Store token. */ p_SCB->tokens++; } return (OS_R_OK); } - /*--------------------------- rt_sem_wait -----------------------------------*/ -OS_RESULT rt_sem_wait (OS_ID semaphore, U16 timeout) { +OS_RESULT rt_sem_wait(OS_ID semaphore, U16 timeout) { /* Obtain a token; possibly wait for it */ P_SCB p_SCB = semaphore; @@ -137,9 +131,8 @@ OS_RESULT rt_sem_wait (OS_ID semaphore, U16 timeout) { return (OS_R_TMO); } if (p_SCB->p_lnk != NULL) { - rt_put_prio ((P_XCB)p_SCB, os_tsk.run); - } - else { + rt_put_prio((P_XCB)p_SCB, os_tsk.run); + } else { p_SCB->p_lnk = os_tsk.run; os_tsk.run->p_lnk = NULL; os_tsk.run->p_rlnk = (P_TCB)p_SCB; @@ -148,38 +141,35 @@ OS_RESULT rt_sem_wait (OS_ID semaphore, U16 timeout) { return (OS_R_TMO); } - /*--------------------------- isr_sem_send ----------------------------------*/ -void isr_sem_send (OS_ID semaphore) { +void isr_sem_send(OS_ID semaphore) { /* Same function as "os_sem"send", but to be called by ISRs */ P_SCB p_SCB = semaphore; - rt_psq_enq (p_SCB, 0); - rt_psh_req (); + rt_psq_enq(p_SCB, 0); + rt_psh_req(); } - /*--------------------------- rt_sem_psh ------------------------------------*/ -void rt_sem_psh (P_SCB p_CB) { +void rt_sem_psh(P_SCB p_CB) { /* Check if task has to be waken up */ P_TCB p_TCB; __DMB(); if (p_CB->p_lnk != NULL) { /* A task is waiting for token */ - p_TCB = rt_get_first ((P_XCB)p_CB); - rt_rmv_dly (p_TCB); - p_TCB->state = READY; + p_TCB = rt_get_first((P_XCB)p_CB); + rt_rmv_dly(p_TCB); + p_TCB->state = READY; #ifdef __CMSIS_RTOS rt_ret_val(p_TCB, 1); #else rt_ret_val(p_TCB, OS_R_SEM); #endif - rt_put_prio (&os_rdy, p_TCB); - } - else { + rt_put_prio(&os_rdy, p_TCB); + } else { /* Store token */ p_CB->tokens++; } @@ -188,4 +178,3 @@ void rt_sem_psh (P_SCB p_CB) { /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_A/rt_System.c b/rtos/rtx/TARGET_CORTEX_A/rt_System.c index db8c32b..0ae1234 100644 --- a/rtos/rtx/TARGET_CORTEX_A/rt_System.c +++ b/rtos/rtx/TARGET_CORTEX_A/rt_System.c @@ -32,17 +32,17 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" -#include "RTX_Config.h" -#include "rt_Task.h" #include "rt_System.h" +#include "RTX_Config.h" #include "rt_Event.h" #include "rt_List.h" #include "rt_Mailbox.h" +#include "rt_Robin.h" #include "rt_Semaphore.h" +#include "rt_Task.h" #include "rt_Time.h" #include "rt_Timer.h" -#include "rt_Robin.h" +#include "rt_TypeDef.h" #ifdef __CORTEX_A9 #include "rt_HAL_CA.h" #else @@ -62,26 +62,25 @@ int os_tick_irqn; static volatile BIT os_lock; static volatile BIT os_psh_flag; #ifndef __CORTEX_A9 -static U8 pend_flags; +static U8 pend_flags; #endif /*---------------------------------------------------------------------------- * Global Functions *---------------------------------------------------------------------------*/ -#if defined (__CC_ARM) -__asm void $$RTX$$version (void) { - /* Export a version number symbol for a version control. */ +#if defined(__CC_ARM) +__asm void $$RTX$$version(void) { + /* Export a version number symbol for a version control. */ - EXPORT __RL_RTX_VER + EXPORT __RL_RTX_VER -__RL_RTX_VER EQU 0x450 + __RL_RTX_VER EQU 0x450 } #endif - /*--------------------------- rt_suspend ------------------------------------*/ -U32 rt_suspend (void) { +U32 rt_suspend(void) { /* Suspend OS scheduler */ U32 delta = 0xFFFF; @@ -92,23 +91,23 @@ U32 rt_suspend (void) { } #ifndef __CMSIS_RTOS if (os_tmr.next) { - if (os_tmr.tcnt < delta) delta = os_tmr.tcnt; + if (os_tmr.tcnt < delta) + delta = os_tmr.tcnt; } #endif return (delta); } - /*--------------------------- rt_resume -------------------------------------*/ -void rt_resume (U32 sleep_time) { +void rt_resume(U32 sleep_time) { /* Resume OS scheduler after suspend */ P_TCB next; - U32 delta; + U32 delta; os_tsk.run->state = READY; - rt_put_rdy_first (os_tsk.run); + rt_put_rdy_first(os_tsk.run); os_robin.task = NULL; @@ -116,17 +115,18 @@ void rt_resume (U32 sleep_time) { if (os_dly.p_dlnk) { delta = sleep_time; if (delta >= os_dly.delta_time) { - delta -= os_dly.delta_time; + delta -= os_dly.delta_time; os_time += os_dly.delta_time; os_dly.delta_time = 1; while (os_dly.p_dlnk) { rt_dec_dly(); - if (delta == 0) break; + if (delta == 0) + break; delta--; os_time++; } } else { - os_time += delta; + os_time += delta; os_dly.delta_time -= delta; } } else { @@ -138,11 +138,12 @@ void rt_resume (U32 sleep_time) { if (os_tmr.next) { delta = sleep_time; if (delta >= os_tmr.tcnt) { - delta -= os_tmr.tcnt; + delta -= os_tmr.tcnt; os_tmr.tcnt = 1; while (os_tmr.next) { rt_tmr_tick(); - if (delta == 0) break; + if (delta == 0) + break; delta--; } } else { @@ -152,153 +153,142 @@ void rt_resume (U32 sleep_time) { #endif /* Switch back to highest ready task */ - next = rt_get_first (&os_rdy); - rt_switch_req (next); + next = rt_get_first(&os_rdy); + rt_switch_req(next); rt_tsk_unlock(); } - /*--------------------------- rt_tsk_lock -----------------------------------*/ -void rt_tsk_lock (void) { +void rt_tsk_lock(void) { /* Prevent task switching by locking out scheduler */ if (os_tick_irqn < 0) { OS_LOCK(); os_lock = __TRUE; - OS_UNPEND (&pend_flags); + OS_UNPEND(&pend_flags); } else { OS_X_LOCK(os_tick_irqn); os_lock = __TRUE; - OS_X_UNPEND (&pend_flags); + OS_X_UNPEND(&pend_flags); } } - /*--------------------------- rt_tsk_unlock ---------------------------------*/ -void rt_tsk_unlock (void) { +void rt_tsk_unlock(void) { /* Unlock scheduler and re-enable task switching */ if (os_tick_irqn < 0) { OS_UNLOCK(); os_lock = __FALSE; - OS_PEND (pend_flags, os_psh_flag); + OS_PEND(pend_flags, os_psh_flag); os_psh_flag = __FALSE; } else { OS_X_UNLOCK(os_tick_irqn); os_lock = __FALSE; - OS_X_PEND (pend_flags, os_psh_flag); + OS_X_PEND(pend_flags, os_psh_flag); os_psh_flag = __FALSE; } } - /*--------------------------- rt_psh_req ------------------------------------*/ -void rt_psh_req (void) { +void rt_psh_req(void) { /* Initiate a post service handling request if required. */ if (os_lock == __FALSE) { - OS_PEND_IRQ (); - } - else { + OS_PEND_IRQ(); + } else { os_psh_flag = __TRUE; } } - /*--------------------------- rt_pop_req ------------------------------------*/ -void rt_pop_req (void) { +void rt_pop_req(void) { /* Process an ISR post service requests. */ struct OS_XCB *p_CB; P_TCB next; - U32 idx; + U32 idx; os_tsk.run->state = READY; - rt_put_rdy_first (os_tsk.run); + rt_put_rdy_first(os_tsk.run); idx = os_psq->last; while (os_psq->count) { p_CB = os_psq->q[idx].id; if (p_CB->cb_type == TCB) { /* Is of TCB type */ - rt_evt_psh ((P_TCB)p_CB, (U16)os_psq->q[idx].arg); - } - else if (p_CB->cb_type == MCB) { + rt_evt_psh((P_TCB)p_CB, (U16)os_psq->q[idx].arg); + } else if (p_CB->cb_type == MCB) { /* Is of MCB type */ - rt_mbx_psh ((P_MCB)p_CB, (void *)os_psq->q[idx].arg); - } - else { + rt_mbx_psh((P_MCB)p_CB, (void *)os_psq->q[idx].arg); + } else { /* Must be of SCB type */ - rt_sem_psh ((P_SCB)p_CB); + rt_sem_psh((P_SCB)p_CB); } - if (++idx == os_psq->size) idx = 0; - rt_dec (&os_psq->count); + if (++idx == os_psq->size) + idx = 0; + rt_dec(&os_psq->count); } os_psq->last = idx; - next = rt_get_first (&os_rdy); - rt_switch_req (next); + next = rt_get_first(&os_rdy); + rt_switch_req(next); } - /*--------------------------- os_tick_init ----------------------------------*/ -__weak int os_tick_init (void) { +__weak int os_tick_init(void) { /* Initialize SysTick timer as system tick timer. */ - rt_systick_init (); - return (-1); /* Return IRQ number of SysTick timer */ + rt_systick_init(); + return (-1); /* Return IRQ number of SysTick timer */ } - /*--------------------------- os_tick_irqack --------------------------------*/ -__weak void os_tick_irqack (void) { - /* Acknowledge timer interrupt. */ +__weak void os_tick_irqack(void) { /* Acknowledge timer interrupt. */ } - /*--------------------------- rt_systick ------------------------------------*/ extern void sysTimerTick(void); -void rt_systick (void) { +void rt_systick(void) { /* Check for system clock update, suspend running task. */ P_TCB next; os_tsk.run->state = READY; - rt_put_rdy_first (os_tsk.run); + rt_put_rdy_first(os_tsk.run); /* Check Round Robin timeout. */ - rt_chk_robin (); + rt_chk_robin(); /* Update delays. */ os_time++; - rt_dec_dly (); + rt_dec_dly(); /* Check the user timers. */ #ifdef __CMSIS_RTOS sysTimerTick(); #else - rt_tmr_tick (); + rt_tmr_tick(); #endif /* Switch back to highest ready task */ - next = rt_get_first (&os_rdy); - rt_switch_req (next); + next = rt_get_first(&os_rdy); + rt_switch_req(next); } /*--------------------------- rt_stk_check ----------------------------------*/ -__weak void rt_stk_check (void) { +__weak void rt_stk_check(void) { /* Check for stack overflow. */ if ((os_tsk.run->tsk_stack < (U32)os_tsk.run->stack) || (os_tsk.run->stack[0] != MAGIC_WORD)) { - os_error (OS_ERR_STK_OVF); + os_error(OS_ERR_STK_OVF); } } /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_A/rt_Task.c b/rtos/rtx/TARGET_CORTEX_A/rt_Task.c index ce2455a..76c2915 100644 --- a/rtos/rtx/TARGET_CORTEX_A/rt_Task.c +++ b/rtos/rtx/TARGET_CORTEX_A/rt_Task.c @@ -32,13 +32,13 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" -#include "RTX_Config.h" -#include "rt_System.h" #include "rt_Task.h" +#include "RTX_Config.h" #include "rt_List.h" #include "rt_MemBox.h" #include "rt_Robin.h" +#include "rt_System.h" +#include "rt_TypeDef.h" #ifdef __CORTEX_A9 #include "rt_HAL_CA.h" #else @@ -55,88 +55,81 @@ struct OS_TSK os_tsk; /* Task Control Blocks of idle demon */ struct OS_TCB os_idle_TCB; - /*---------------------------------------------------------------------------- * Local Functions *---------------------------------------------------------------------------*/ -static OS_TID rt_get_TID (void) { +static OS_TID rt_get_TID(void) { U32 tid; for (tid = 1; tid <= os_maxtaskrun; tid++) { - if (os_active_TCB[tid-1] == NULL) { + if (os_active_TCB[tid - 1] == NULL) { return ((OS_TID)tid); } } return (0); } - /*--------------------------- rt_init_context -------------------------------*/ -static void rt_init_context (P_TCB p_TCB, U8 priority, FUNCP task_body) { +static void rt_init_context(P_TCB p_TCB, U8 priority, FUNCP task_body) { /* Initialize general part of the Task Control Block. */ p_TCB->cb_type = TCB; - p_TCB->state = READY; - p_TCB->prio = priority; - p_TCB->p_lnk = NULL; - p_TCB->p_rlnk = NULL; - p_TCB->p_dlnk = NULL; - p_TCB->p_blnk = NULL; - p_TCB->delta_time = 0; + p_TCB->state = READY; + p_TCB->prio = priority; + p_TCB->p_lnk = NULL; + p_TCB->p_rlnk = NULL; + p_TCB->p_dlnk = NULL; + p_TCB->p_blnk = NULL; + p_TCB->delta_time = 0; p_TCB->interval_time = 0; - p_TCB->events = 0; - p_TCB->waits = 0; + p_TCB->events = 0; + p_TCB->waits = 0; p_TCB->stack_frame = 0; if (p_TCB->priv_stack == 0) { /* Allocate the memory space for the stack. */ - p_TCB->stack = rt_alloc_box (mp_stk); + p_TCB->stack = rt_alloc_box(mp_stk); } - rt_init_stack (p_TCB, task_body); + rt_init_stack(p_TCB, task_body); } - /*--------------------------- rt_switch_req ---------------------------------*/ -void rt_switch_req (P_TCB p_new) { +void rt_switch_req(P_TCB p_new) { /* Switch to next task (identified by "p_new"). */ - os_tsk.new = p_new; + os_tsk.new = p_new; p_new->state = RUNNING; DBG_TASK_SWITCH(p_new->task_id); } - /*--------------------------- rt_dispatch -----------------------------------*/ -void rt_dispatch (P_TCB next_TCB) { +void rt_dispatch(P_TCB next_TCB) { /* Dispatch next task if any identified or dispatch highest ready task */ /* "next_TCB" identifies a task to run or has value NULL (=no next task) */ if (next_TCB == NULL) { /* Running task was blocked: continue with highest ready task */ - next_TCB = rt_get_first (&os_rdy); - rt_switch_req (next_TCB); - } - else { + next_TCB = rt_get_first(&os_rdy); + rt_switch_req(next_TCB); + } else { /* Check which task continues */ if (next_TCB->prio > os_tsk.run->prio) { /* preempt running task */ - rt_put_rdy_first (os_tsk.run); + rt_put_rdy_first(os_tsk.run); os_tsk.run->state = READY; - rt_switch_req (next_TCB); - } - else { + rt_switch_req(next_TCB); + } else { /* put next task into ready list, no task switch takes place */ next_TCB->state = READY; - rt_put_prio (&os_rdy, next_TCB); + rt_put_prio(&os_rdy, next_TCB); } } } - /*--------------------------- rt_block --------------------------------------*/ -void rt_block (U16 timeout, U8 block_state) { +void rt_block(U16 timeout, U8 block_state) { /* Block running task and choose next ready task. */ /* "timeout" sets a time-out value or is 0xffff (=no time-out). */ /* "block_state" defines the appropriate task state */ @@ -144,33 +137,31 @@ void rt_block (U16 timeout, U8 block_state) { if (timeout) { if (timeout < 0xffff) { - rt_put_dly (os_tsk.run, timeout); + rt_put_dly(os_tsk.run, timeout); } os_tsk.run->state = block_state; - next_TCB = rt_get_first (&os_rdy); - rt_switch_req (next_TCB); + next_TCB = rt_get_first(&os_rdy); + rt_switch_req(next_TCB); } } - /*--------------------------- rt_tsk_pass -----------------------------------*/ -void rt_tsk_pass (void) { +void rt_tsk_pass(void) { /* Allow tasks of same priority level to run cooperatively.*/ P_TCB p_new; p_new = rt_get_same_rdy_prio(); if (p_new != NULL) { - rt_put_prio ((P_XCB)&os_rdy, os_tsk.run); + rt_put_prio((P_XCB)&os_rdy, os_tsk.run); os_tsk.run->state = READY; - rt_switch_req (p_new); + rt_switch_req(p_new); } } - /*--------------------------- rt_tsk_self -----------------------------------*/ -OS_TID rt_tsk_self (void) { +OS_TID rt_tsk_self(void) { /* Return own task identifier value. */ if (os_tsk.run == NULL) { return (0); @@ -178,47 +169,46 @@ OS_TID rt_tsk_self (void) { return (os_tsk.run->task_id); } - /*--------------------------- rt_tsk_prio -----------------------------------*/ -OS_RESULT rt_tsk_prio (OS_TID task_id, U8 new_prio) { +OS_RESULT rt_tsk_prio(OS_TID task_id, U8 new_prio) { /* Change execution priority of a task to "new_prio". */ P_TCB p_task; if (task_id == 0) { /* Change execution priority of calling task. */ os_tsk.run->prio = new_prio; -run:if (rt_rdy_prio() > new_prio) { - rt_put_prio (&os_rdy, os_tsk.run); - os_tsk.run->state = READY; - rt_dispatch (NULL); + run: + if (rt_rdy_prio() > new_prio) { + rt_put_prio(&os_rdy, os_tsk.run); + os_tsk.run->state = READY; + rt_dispatch(NULL); } return (OS_R_OK); } /* Find the task in the "os_active_TCB" array. */ - if (task_id > os_maxtaskrun || os_active_TCB[task_id-1] == NULL) { + if (task_id > os_maxtaskrun || os_active_TCB[task_id - 1] == NULL) { /* Task with "task_id" not found or not started. */ return (OS_R_NOK); } - p_task = os_active_TCB[task_id-1]; + p_task = os_active_TCB[task_id - 1]; p_task->prio = new_prio; if (p_task == os_tsk.run) { goto run; } - rt_resort_prio (p_task); + rt_resort_prio(p_task); if (p_task->state == READY) { /* Task enqueued in a ready list. */ - p_task = rt_get_first (&os_rdy); - rt_dispatch (p_task); + p_task = rt_get_first(&os_rdy); + rt_dispatch(p_task); } return (OS_R_OK); } - /*--------------------------- rt_tsk_create ---------------------------------*/ -OS_TID rt_tsk_create (FUNCP task, U32 prio_stksz, void *stk, void *argv) { +OS_TID rt_tsk_create(FUNCP task, U32 prio_stksz, void *stk, void *argv) { /* Start a new task declared with "task". */ P_TCB task_context; U32 i; @@ -227,73 +217,70 @@ OS_TID rt_tsk_create (FUNCP task, U32 prio_stksz, void *stk, void *argv) { if ((prio_stksz & 0xFF) == 0) { prio_stksz += 1; } - task_context = rt_alloc_box (mp_tcb); + task_context = rt_alloc_box(mp_tcb); if (task_context == NULL) { return (0); } /* If "size != 0" use a private user provided stack. */ - task_context->stack = stk; + task_context->stack = stk; task_context->priv_stack = prio_stksz >> 8; /* Pass parameter 'argv' to 'rt_init_context' */ task_context->msg = argv; /* For 'size == 0' system allocates the user stack from the memory pool. */ - rt_init_context (task_context, prio_stksz & 0xFF, task); + rt_init_context(task_context, prio_stksz & 0xFF, task); /* Find a free entry in 'os_active_TCB' table. */ - i = rt_get_TID (); - os_active_TCB[i-1] = task_context; + i = rt_get_TID(); + os_active_TCB[i - 1] = task_context; task_context->task_id = i; DBG_TASK_NOTIFY(task_context, __TRUE); - rt_dispatch (task_context); + rt_dispatch(task_context); return ((OS_TID)i); } - /*--------------------------- rt_tsk_delete ---------------------------------*/ -OS_RESULT rt_tsk_delete (OS_TID task_id) { +OS_RESULT rt_tsk_delete(OS_TID task_id) { /* Terminate the task identified with "task_id". */ P_TCB task_context; if (task_id == 0 || task_id == os_tsk.run->task_id) { /* Terminate itself. */ - os_tsk.run->state = INACTIVE; - os_tsk.run->tsk_stack = rt_get_PSP (); - rt_stk_check (); - os_active_TCB[os_tsk.run->task_id-1] = NULL; - rt_free_box (mp_stk, os_tsk.run->stack); + os_tsk.run->state = INACTIVE; + os_tsk.run->tsk_stack = rt_get_PSP(); + rt_stk_check(); + os_active_TCB[os_tsk.run->task_id - 1] = NULL; + rt_free_box(mp_stk, os_tsk.run->stack); os_tsk.run->stack = NULL; DBG_TASK_NOTIFY(os_tsk.run, __FALSE); - rt_free_box (mp_tcb, os_tsk.run); + rt_free_box(mp_tcb, os_tsk.run); os_tsk.run = NULL; - rt_dispatch (NULL); + rt_dispatch(NULL); /* The program should never come to this point. */ - } - else { + } else { /* Find the task in the "os_active_TCB" array. */ - if (task_id > os_maxtaskrun || os_active_TCB[task_id-1] == NULL) { + if (task_id > os_maxtaskrun || os_active_TCB[task_id - 1] == NULL) { /* Task with "task_id" not found or not started. */ return (OS_R_NOK); } - task_context = os_active_TCB[task_id-1]; - rt_rmv_list (task_context); - rt_rmv_dly (task_context); - os_active_TCB[task_id-1] = NULL; - rt_free_box (mp_stk, task_context->stack); + task_context = os_active_TCB[task_id - 1]; + rt_rmv_list(task_context); + rt_rmv_dly(task_context); + os_active_TCB[task_id - 1] = NULL; + rt_free_box(mp_stk, task_context->stack); task_context->stack = NULL; DBG_TASK_NOTIFY(task_context, __FALSE); - rt_free_box (mp_tcb, task_context); + rt_free_box(mp_tcb, task_context); } return (OS_R_OK); } - /*--------------------------- rt_sys_init -----------------------------------*/ #ifdef __CMSIS_RTOS -void rt_sys_init (void) { +void rt_sys_init(void) { #else -void rt_sys_init (FUNCP first_task, U32 prio_stksz, void *stk) { +void rt_sys_init(FUNCP first_task, U32 prio_stksz, void *stk) { #endif /* Initialize system and start up task declared with "first_task". */ U32 i; @@ -304,63 +291,62 @@ void rt_sys_init (FUNCP first_task, U32 prio_stksz, void *stk) { for (i = 0; i < os_maxtaskrun; i++) { os_active_TCB[i] = NULL; } - rt_init_box (&mp_tcb, mp_tcb_size, sizeof(struct OS_TCB)); - rt_init_box (&mp_stk, mp_stk_size, BOX_ALIGN_8 | (U16)(os_stackinfo)); - rt_init_box ((U32 *)m_tmr, mp_tmr_size, sizeof(struct OS_TMR)); + rt_init_box(&mp_tcb, mp_tcb_size, sizeof(struct OS_TCB)); + rt_init_box(&mp_stk, mp_stk_size, BOX_ALIGN_8 | (U16)(os_stackinfo)); + rt_init_box((U32 *)m_tmr, mp_tmr_size, sizeof(struct OS_TMR)); /* Set up TCB of idle demon */ - os_idle_TCB.task_id = 255; + os_idle_TCB.task_id = 255; os_idle_TCB.priv_stack = 0; - rt_init_context (&os_idle_TCB, 0, os_idle_demon); + rt_init_context(&os_idle_TCB, 0, os_idle_demon); /* Set up ready list: initially empty */ os_rdy.cb_type = HCB; - os_rdy.p_lnk = NULL; + os_rdy.p_lnk = NULL; /* Set up delay list: initially empty */ os_dly.cb_type = HCB; - os_dly.p_dlnk = NULL; - os_dly.p_blnk = NULL; + os_dly.p_dlnk = NULL; + os_dly.p_blnk = NULL; os_dly.delta_time = 0; /* Fix SP and system variables to assume idle task is running */ /* Transform main program into idle task by assuming idle TCB */ #ifndef __CMSIS_RTOS - rt_set_PSP (os_idle_TCB.tsk_stack+32); + rt_set_PSP(os_idle_TCB.tsk_stack + 32); #endif os_tsk.run = &os_idle_TCB; os_tsk.run->state = RUNNING; /* Initialize ps queue */ os_psq->first = 0; - os_psq->last = 0; - os_psq->size = os_fifo_size; + os_psq->last = 0; + os_psq->size = os_fifo_size; - rt_init_robin (); + rt_init_robin(); /* Initialize SVC and PendSV */ - rt_svc_init (); + rt_svc_init(); #ifndef __CMSIS_RTOS /* Initialize and start system clock timer */ - os_tick_irqn = os_tick_init (); + os_tick_irqn = os_tick_init(); if (os_tick_irqn >= 0) { OS_X_INIT(os_tick_irqn); } /* Start up first user task before entering the endless loop */ - rt_tsk_create (first_task, prio_stksz, stk, NULL); + rt_tsk_create(first_task, prio_stksz, stk, NULL); #endif } - /*--------------------------- rt_sys_start ----------------------------------*/ #ifdef __CMSIS_RTOS -void rt_sys_start (void) { +void rt_sys_start(void) { /* Start system */ /* Initialize and start system clock timer */ - os_tick_irqn = os_tick_init (); + os_tick_irqn = os_tick_init(); if (os_tick_irqn >= 0) { OS_X_INIT(os_tick_irqn); } diff --git a/rtos/rtx/TARGET_CORTEX_A/rt_Time.c b/rtos/rtx/TARGET_CORTEX_A/rt_Time.c index d99dc75..d2ce308 100644 --- a/rtos/rtx/TARGET_CORTEX_A/rt_Time.c +++ b/rtos/rtx/TARGET_CORTEX_A/rt_Time.c @@ -32,10 +32,10 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" +#include "rt_Time.h" #include "RTX_Config.h" #include "rt_Task.h" -#include "rt_Time.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Global Variables @@ -44,51 +44,45 @@ /* Free running system tick counter */ U32 os_time; - /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_time_get -----------------------------------*/ -U32 rt_time_get (void) { +U32 rt_time_get(void) { /* Get system time tick */ return (os_time); } - /*--------------------------- rt_dly_wait -----------------------------------*/ -void rt_dly_wait (U16 delay_time) { +void rt_dly_wait(U16 delay_time) { /* Delay task by "delay_time" */ - rt_block (delay_time, WAIT_DLY); + rt_block(delay_time, WAIT_DLY); } - /*--------------------------- rt_itv_set ------------------------------------*/ -void rt_itv_set (U16 interval_time) { +void rt_itv_set(U16 interval_time) { /* Set interval length and define start of first interval */ os_tsk.run->interval_time = interval_time; os_tsk.run->delta_time = interval_time + (U16)os_time; } - /*--------------------------- rt_itv_wait -----------------------------------*/ -void rt_itv_wait (void) { +void rt_itv_wait(void) { /* Wait for interval end and define start of next one */ U16 delta; delta = os_tsk.run->delta_time - (U16)os_time; os_tsk.run->delta_time += os_tsk.run->interval_time; if ((delta & 0x8000) == 0) { - rt_block (delta, WAIT_ITV); + rt_block(delta, WAIT_ITV); } } /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/HAL_CM.c b/rtos/rtx/TARGET_CORTEX_M/HAL_CM.c index 421dc34..86d88f0 100644 --- a/rtos/rtx/TARGET_CORTEX_M/HAL_CM.c +++ b/rtos/rtx/TARGET_CORTEX_M/HAL_CM.c @@ -32,10 +32,9 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" #include "RTX_Conf.h" #include "rt_HAL_CM.h" - +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Global Variables @@ -49,12 +48,11 @@ BIT dbg_msg; * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_init_stack ---------------------------------*/ -void rt_init_stack (P_TCB p_TCB, FUNCP task_body) { +void rt_init_stack(P_TCB p_TCB, FUNCP task_body) { /* Prepare TCB and saved context for a first time start of a task. */ - U32 *stk,i,size; + U32 *stk, i, size; /* Prepare a complete interrupt frame for first task start */ size = p_TCB->priv_stack >> 2; @@ -93,35 +91,34 @@ void rt_init_stack (P_TCB p_TCB, FUNCP task_body) { We want to do stack/heap collision detection instead. */ if (p_TCB->task_id != 0x01) { - p_TCB->stack[0] = MAGIC_WORD; + p_TCB->stack[0] = MAGIC_WORD; #ifdef DEBUG - for (i = 1; i < (stk - p_TCB->stack); i++) { - p_TCB->stack[i] = 0xCCCCCCCC; - } + for (i = 1; i < (stk - p_TCB->stack); i++) { + p_TCB->stack[i] = 0xCCCCCCCC; + } #endif } } - /*--------------------------- rt_ret_val ----------------------------------*/ -static __inline U32 *rt_ret_regs (P_TCB p_TCB) { +static __inline U32 *rt_ret_regs(P_TCB p_TCB) { /* Get pointer to task return value registers (R0..R3) in Stack */ #if (__TARGET_FPU_VFP) if (p_TCB->stack_frame) { /* Extended Stack Frame: R4-R11,S16-S31,R0-R3,R12,LR,PC,xPSR,S0-S15,FPSCR */ - return (U32 *)(p_TCB->tsk_stack + 8*4 + 16*4); + return (U32 *)(p_TCB->tsk_stack + 8 * 4 + 16 * 4); } else { /* Basic Stack Frame: R4-R11,R0-R3,R12,LR,PC,xPSR */ - return (U32 *)(p_TCB->tsk_stack + 8*4); + return (U32 *)(p_TCB->tsk_stack + 8 * 4); } #else /* Stack Frame: R4-R11,R0-R3,R12,LR,PC,xPSR */ - return (U32 *)(p_TCB->tsk_stack + 8*4); + return (U32 *)(p_TCB->tsk_stack + 8 * 4); #endif } -void rt_ret_val (P_TCB p_TCB, U32 v0) { +void rt_ret_val(P_TCB p_TCB, U32 v0) { U32 *ret; ret = rt_ret_regs(p_TCB); @@ -136,13 +133,11 @@ void rt_ret_val2(P_TCB p_TCB, U32 v0, U32 v1) { ret[1] = v1; } - /*--------------------------- dbg_init --------------------------------------*/ #ifdef DBG_MSG -void dbg_init (void) { - if ((DEMCR & DEMCR_TRCENA) && - (ITM_CONTROL & ITM_ITMENA) && +void dbg_init(void) { + if ((DEMCR & DEMCR_TRCENA) && (ITM_CONTROL & ITM_ITMENA) && (ITM_ENABLE & (1UL << 31))) { dbg_msg = __TRUE; } @@ -152,10 +147,12 @@ void dbg_init (void) { /*--------------------------- dbg_task_notify -------------------------------*/ #ifdef DBG_MSG -void dbg_task_notify (P_TCB p_tcb, BOOL create) { - while (ITM_PORT31_U32 == 0); +void dbg_task_notify(P_TCB p_tcb, BOOL create) { + while (ITM_PORT31_U32 == 0) + ; ITM_PORT31_U32 = (U32)p_tcb->ptask; - while (ITM_PORT31_U32 == 0); + while (ITM_PORT31_U32 == 0) + ; ITM_PORT31_U16 = (create << 8) | p_tcb->task_id; } #endif @@ -163,14 +160,13 @@ void dbg_task_notify (P_TCB p_tcb, BOOL create) { /*--------------------------- dbg_task_switch -------------------------------*/ #ifdef DBG_MSG -void dbg_task_switch (U32 task_id) { - while (ITM_PORT31_U32 == 0); +void dbg_task_switch(U32 task_id) { + while (ITM_PORT31_U32 == 0) + ; ITM_PORT31_U8 = task_id; } #endif - /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/RTX_Conf.h b/rtos/rtx/TARGET_CORTEX_M/RTX_Conf.h index 3fb7ba3..8275fd6 100644 --- a/rtos/rtx/TARGET_CORTEX_M/RTX_Conf.h +++ b/rtos/rtx/TARGET_CORTEX_M/RTX_Conf.h @@ -31,18 +31,20 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ +#include "rt_TypeDef.h" /* Error Codes */ -#define OS_ERR_STK_OVF 1U -#define OS_ERR_FIFO_OVF 2U -#define OS_ERR_MBX_OVF 3U -#define OS_ERR_TIMER_OVF 4U +#define OS_ERR_STK_OVF 1U +#define OS_ERR_FIFO_OVF 2U +#define OS_ERR_MBX_OVF 3U +#define OS_ERR_TIMER_OVF 4U /* Definitions */ -#define BOX_ALIGN_8 0x80000000 -#define _declare_box(pool,size,cnt) U32 pool[(((size)+3)/4)*(cnt) + 3] -#define _declare_box8(pool,size,cnt) U64 pool[(((size)+7)/8)*(cnt) + 2] -#define _init_box8(pool,size,bsize) _init_box (pool,size,(bsize) | BOX_ALIGN_8) +#define BOX_ALIGN_8 0x80000000 +#define _declare_box(pool, size, cnt) U32 pool[(((size) + 3) / 4) * (cnt) + 3] +#define _declare_box8(pool, size, cnt) U64 pool[(((size) + 7) / 8) * (cnt) + 2] +#define _init_box8(pool, size, bsize) \ + _init_box(pool, size, (bsize) | BOX_ALIGN_8) /* Variables */ extern U32 idle_task_stack[]; @@ -52,21 +54,21 @@ extern U32 task_rtime[]; /* Constants */ extern U16 const os_maxtaskrun; -extern U8 const os_flags; +extern U8 const os_flags; extern U32 const os_rrobin; extern U32 const os_clockrate; extern U32 const os_timernum; extern U16 const idle_task_stack_size; -extern U8 const os_fifo_size; +extern U8 const os_fifo_size; /* Functions */ -extern U32 os_get_trv (void); -extern void os_idle_demon (void); -extern int os_tick_init (void); -extern void os_tick_irqack (void); -extern void os_tmr_call (U16 info); -extern void os_error (U32 err_code); +extern U32 os_get_trv(void); +extern void os_idle_demon(void); +extern int os_tick_init(void); +extern void os_tick_irqack(void); +extern void os_tmr_call(U16 info); +extern void os_error(U32 err_code); /*---------------------------------------------------------------------------- * end of file diff --git a/rtos/rtx/TARGET_CORTEX_M/RTX_Conf_CM.c b/rtos/rtx/TARGET_CORTEX_M/RTX_Conf_CM.c index d4acf88..465ff2e 100644 --- a/rtos/rtx/TARGET_CORTEX_M/RTX_Conf_CM.c +++ b/rtos/rtx/TARGET_CORTEX_M/RTX_Conf_CM.c @@ -32,23 +32,20 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "stdarg.h" -#include "stdio.h" +#include "cmsis.h" #include "cmsis_os.h" -#include "rt_System.h" -#include "rt_Time.h" +#include "hal_sleep.h" #include "hal_timer.h" #include "hal_trace.h" -#include "hal_sleep.h" -#include "cmsis.h" #include "hwtimer_list.h" +#include "rt_System.h" +#include "rt_Time.h" +#include "stdarg.h" +#include "stdio.h" #define WEAK __attribute__((weak)) -void WEAK sleep(void) -{ - hal_sleep_enter_sleep(); -} +void WEAK sleep(void) { hal_sleep_enter_sleep(); } /*---------------------------------------------------------------------------- * RTX User configuration part BEGIN @@ -64,32 +61,32 @@ void WEAK sleep(void) // counting "main", but not counting "osTimerThread" // Default: 6 #ifndef OS_TASKCNT -# define OS_TASKCNT __BEST_D_OS_TASKCNT +#define OS_TASKCNT __BEST_D_OS_TASKCNT #endif // Scheduler (+ interrupts) stack size [bytes] <64-4096:8><#/4> #ifndef OS_SCHEDULERSTKSIZE -# define OS_SCHEDULERSTKSIZE __BEST_D_OS_SCHEDULERSTKSIZE +#define OS_SCHEDULERSTKSIZE __BEST_D_OS_SCHEDULERSTKSIZE #endif // Idle stack size [bytes] <64-4096:8><#/4> // Defines default stack size for the Idle thread. #ifndef OS_IDLESTKSIZE - #define OS_IDLESTKSIZE 256 +#define OS_IDLESTKSIZE 256 #endif // Timer Thread stack size [bytes] <64-4096:8><#/4> // Defines stack size for Timer thread. // Default: 200 #ifndef OS_TIMERSTKSZ - #define OS_TIMERSTKSZ WORDS_STACK_SIZE +#define OS_TIMERSTKSZ WORDS_STACK_SIZE #endif // Check for stack overflow // Includes the stack checking code for stack overflow. // Note that additional code reduces the Kernel performance. #ifndef OS_STKCHECK - #define OS_STKCHECK 1 +#define OS_STKCHECK 1 #endif // Processor mode for thread execution @@ -97,14 +94,14 @@ void WEAK sleep(void) // <1=> Privileged mode // Default: Privileged mode #ifndef OS_RUNPRIV - #define OS_RUNPRIV 1 +#define OS_RUNPRIV 1 #endif // Timer tick value [us] <1-1000000> // Defines the timer tick value. // Default: 1000 (1ms) #ifndef OS_TICK - #define OS_TICK 1000 +#define OS_TICK 1000 #endif // @@ -117,14 +114,14 @@ void WEAK sleep(void) // // Enables Round-Robin Thread switching. #ifndef OS_ROBIN - #define OS_ROBIN 1 +#define OS_ROBIN 1 #endif // Round-Robin Timeout [ticks] <1-1000> // Defines how long a thread will execute before a thread switch. // Default: 5 #ifndef OS_ROBINTOUT - #define OS_ROBINTOUT 5 +#define OS_ROBINTOUT 5 #endif // @@ -133,7 +130,7 @@ void WEAK sleep(void) // ============== // Enables user Timers #ifndef OS_TIMERS - #define OS_TIMERS 1 +#define OS_TIMERS 1 #endif // Timer Thread Priority @@ -146,14 +143,14 @@ void WEAK sleep(void) // Defines priority for Timer Thread // Default: High #ifndef OS_TIMERPRIO - #define OS_TIMERPRIO 5 +#define OS_TIMERPRIO 5 #endif // Timer Callback Queue size <1-32> // Number of concurrent active timer callback functions. // Default: 4 #ifndef OS_TIMERCBQSZ - #define OS_TIMERCBQS 16 +#define OS_TIMERCBQS 16 #endif // @@ -167,7 +164,7 @@ void WEAK sleep(void) // when they are called from the interrupt handler. // Default: 16 entries #ifndef OS_FIFOSZ - #define OS_FIFOSZ 16 +#define OS_FIFOSZ 16 #endif // @@ -179,19 +176,17 @@ void WEAK sleep(void) // Define max. number system mutexes that are used to protect // the arm standard runtime library. For microlib they are not used. #ifndef OS_MUTEXCNT - #define OS_MUTEXCNT 12 +#define OS_MUTEXCNT 12 #endif /*---------------------------------------------------------------------------- * RTX User configuration part END *---------------------------------------------------------------------------*/ -#define OS_TRV ((uint32_t)((((float)OS_CLOCK*(float)OS_TICK))/(float)1E6+0.5f)-1) +#define OS_TRV \ + ((uint32_t)((((float)OS_CLOCK * (float)OS_TICK)) / (float)1E6 + 0.5f) - 1) -U32 os_get_trv (void) -{ - return OS_TRV; -} +U32 os_get_trv(void) { return OS_TRV; } extern void rtx_show_all_threads(void); @@ -202,93 +197,94 @@ extern void check_hung_tasks(void); /*---------------------------------------------------------------------------- * OS Idle daemon *---------------------------------------------------------------------------*/ -void os_idle_demon (void) { - /* The idle demon is a system thread, running when no other thread is */ - /* ready to run. */ +void os_idle_demon(void) { + /* The idle demon is a system thread, running when no other thread is */ + /* ready to run. */ - unsigned int os_ticks; - HWTIMER_ID timer; - int ret; + unsigned int os_ticks; + HWTIMER_ID timer; + int ret; #if defined(DEBUG_SLEEP) && (DEBUG_SLEEP >= 2) - unsigned int start_time; - unsigned int start_os_time; - unsigned int start_tick; + unsigned int start_time; + unsigned int start_os_time; + unsigned int start_tick; #endif #if defined(FPGA) || !(defined(ROM_BUILD) || defined(PROGRAMMER)) - ret = hal_trace_crash_dump_register(HAL_TRACE_CRASH_DUMP_MODULE_SYS, rtx_show_all_threads); - ASSERT(ret == 0, "IdleTask: Failed to register crash dump callback"); + ret = hal_trace_crash_dump_register(HAL_TRACE_CRASH_DUMP_MODULE_SYS, + rtx_show_all_threads); + ASSERT(ret == 0, "IdleTask: Failed to register crash dump callback"); #endif - timer = hwtimer_alloc((HWTIMER_CALLBACK_T)rt_psh_req, NULL); - ASSERT(timer, "IdleTask: Failed to alloc sleep timer"); - /* Sleep: ideally, we should put the chip to sleep. - Unfortunately, this usually requires disconnecting the interface chip (debugger). - This can be done, but it would break the local file system. - */ - for (;;) { + timer = hwtimer_alloc((HWTIMER_CALLBACK_T)rt_psh_req, NULL); + ASSERT(timer, "IdleTask: Failed to alloc sleep timer"); + /* Sleep: ideally, we should put the chip to sleep. + Unfortunately, this usually requires disconnecting the interface chip + (debugger). This can be done, but it would break the local file system. + */ + for (;;) { #if TASK_HUNG_CHECK_ENABLED - check_hung_tasks(); + check_hung_tasks(); #endif - if (hal_sleep_light_sleep() == HAL_SLEEP_STATUS_DEEP) { - os_ticks = rt_suspend(); - if (os_ticks) { + if (hal_sleep_light_sleep() == HAL_SLEEP_STATUS_DEEP) { + os_ticks = rt_suspend(); + if (os_ticks) { #if defined(DEBUG_SLEEP) && (DEBUG_SLEEP >= 2) - __disable_irq(); + __disable_irq(); #endif - ret = hwtimer_start(timer, MS_TO_HWTICKS(os_ticks * OS_TICK / 1000)); + ret = hwtimer_start(timer, MS_TO_HWTICKS(os_ticks * OS_TICK / 1000)); #if defined(DEBUG_SLEEP) && (DEBUG_SLEEP >= 2) - start_time = hal_sys_timer_get(); - start_tick = SysTick->VAL; - start_os_time = os_time; - __enable_irq(); + start_time = hal_sys_timer_get(); + start_tick = SysTick->VAL; + start_os_time = os_time; + __enable_irq(); #endif - if (ret == 0) { - sleep(); - ret = hwtimer_stop(timer); - } -#if defined(DEBUG_SLEEP) && (DEBUG_SLEEP >= 2) - if (hal_sys_timer_get() - start_time >= MS_TO_HWTICKS(1)) { - TRACE(4,"[%u/0x%X][%2u/%u] os_idle_demon start timer", - TICKS_TO_MS(start_time), start_time, start_tick, start_os_time); - } -#endif - } - rt_resume(os_ticks); + if (ret == 0) { + sleep(); + ret = hwtimer_stop(timer); } +#if defined(DEBUG_SLEEP) && (DEBUG_SLEEP >= 2) + if (hal_sys_timer_get() - start_time >= MS_TO_HWTICKS(1)) { + TRACE(4, "[%u/0x%X][%2u/%u] os_idle_demon start timer", + TICKS_TO_MS(start_time), start_time, start_tick, start_os_time); + } +#endif + } + rt_resume(os_ticks); } + } } /*---------------------------------------------------------------------------- * RTX Errors *---------------------------------------------------------------------------*/ extern void rtx_show_current_thread(void); -void os_error (uint32_t err_code) { - /* This function is called when a runtime error is detected. Parameter */ - /* 'err_code' holds the runtime error code (defined in RTX_Conf.h). */ +void os_error(uint32_t err_code) { + /* This function is called when a runtime error is detected. Parameter */ + /* 'err_code' holds the runtime error code (defined in RTX_Conf.h). */ - rtx_show_current_thread(); - ASSERT(0, "os_error: %d ThreadId:%d\n", err_code, osGetThreadIntId()); + rtx_show_current_thread(); + ASSERT(0, "os_error: %d ThreadId:%d\n", err_code, osGetThreadIntId()); - //mbed_die(); + // mbed_die(); } -void os_error_str (const char *str, ...) { - va_list ap; - static char buf[50]; +void os_error_str(const char *str, ...) { + va_list ap; + static char buf[50]; - va_start(ap, str); - vsnprintf(buf, sizeof(buf), str, ap); - va_end(ap); + va_start(ap, str); + vsnprintf(buf, sizeof(buf), str, ap); + va_end(ap); - ASSERT(0, "%s\n", buf); + ASSERT(0, "%s\n", buf); } void sysThreadError(osStatus status) { - if (status != osOK) { - TRACE_IMM(1,"osStatus: %08x\n", status); - rtx_show_current_thread(); - ASSERT(0, "sysThreadError ThreadId:%d\n", osGetThreadIntId()); - } + if (status != osOK) { + TRACE_IMM(1, "osStatus: %08x\n", status); + rtx_show_current_thread(); + ASSERT(0, "sysThreadError ThreadId:%d\n", osGetThreadIntId()); + } } /*---------------------------------------------------------------------------- @@ -300,4 +296,3 @@ void sysThreadError(osStatus status) { /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/TARGET_M0/TOOLCHAIN_ARM/HAL_CM0.c b/rtos/rtx/TARGET_CORTEX_M/TARGET_M0/TOOLCHAIN_ARM/HAL_CM0.c index 492e94a..aa3208e 100644 --- a/rtos/rtx/TARGET_CORTEX_M/TARGET_M0/TOOLCHAIN_ARM/HAL_CM0.c +++ b/rtos/rtx/TARGET_CORTEX_M/TARGET_M0/TOOLCHAIN_ARM/HAL_CM0.c @@ -32,270 +32,220 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" #include "RTX_Conf.h" -#include "rt_System.h" #include "rt_HAL_CM.h" -#include "rt_Task.h" #include "rt_MemBox.h" - +#include "rt_System.h" +#include "rt_Task.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_set_PSP ------------------------------------*/ -__asm void rt_set_PSP (U32 stack) { - MSR PSP,R0 - BX LR -} - +__asm void rt_set_PSP(U32 stack) { MSR PSP, R0 BX LR } /*--------------------------- rt_get_PSP ------------------------------------*/ -__asm U32 rt_get_PSP (void) { - MRS R0,PSP - BX LR -} - +__asm U32 rt_get_PSP(void) { MRS R0, PSP BX LR } /*--------------------------- os_set_env ------------------------------------*/ -__asm void os_set_env (void) { - /* Switch to Unprivileged/Privileged Thread mode, use PSP. */ - MOV R0,SP ; PSP = MSP - MSR PSP,R0 - LDR R0,=__cpp(&os_flags) - LDRB R0,[R0] - LSLS R0,#31 - BNE PrivilegedE - MOVS R0,#0x03 ; Unprivileged Thread mode, use PSP - MSR CONTROL,R0 - BX LR -PrivilegedE - MOVS R0,#0x02 ; Privileged Thread mode, use PSP - MSR CONTROL,R0 - BX LR +__asm void os_set_env(void) { + /* Switch to Unprivileged/Privileged Thread mode, use PSP. */ + MOV R0, SP; + PSP = MSP MSR PSP, R0 LDR R0, = __cpp(&os_flags) LDRB R0, [R0] LSLS R0, +# 31 BNE PrivilegedE MOVS R0, #0x03; + Unprivileged Thread mode, use PSP MSR CONTROL, R0 BX LR PrivilegedE MOVS R0, +# 0x02; + Privileged Thread mode, use PSP MSR CONTROL, + R0 BX LR - ALIGN + ALIGN } - /*--------------------------- _alloc_box ------------------------------------*/ -__asm void *_alloc_box (void *box_mem) { - /* Function wrapper for Unprivileged/Privileged mode. */ - LDR R3,=__cpp(rt_alloc_box) - MOV R12,R3 - MRS R3,IPSR - LSLS R3,#24 - BNE PrivilegedA - MRS R3,CONTROL - LSLS R3,#31 - BEQ PrivilegedA - SVC 0 - BX LR -PrivilegedA - BX R12 +__asm void *_alloc_box(void *box_mem) { + /* Function wrapper for Unprivileged/Privileged mode. */ + LDR R3, = __cpp(rt_alloc_box) MOV R12, R3 MRS R3, IPSR LSLS R3, +# 24 BNE PrivilegedA MRS R3, CONTROL LSLS R3, +# 31 BEQ PrivilegedA SVC 0 BX LR PrivilegedA BX R12 - ALIGN + ALIGN } - /*--------------------------- _free_box -------------------------------------*/ -__asm int _free_box (void *box_mem, void *box) { - /* Function wrapper for Unprivileged/Privileged mode. */ - LDR R3,=__cpp(rt_free_box) - MOV R12,R3 - MRS R3,IPSR - LSLS R3,#24 - BNE PrivilegedF - MRS R3,CONTROL - LSLS R3,#31 - BEQ PrivilegedF - SVC 0 - BX LR -PrivilegedF - BX R12 +__asm int _free_box(void *box_mem, void *box) { + /* Function wrapper for Unprivileged/Privileged mode. */ + LDR R3, = __cpp(rt_free_box) MOV R12, R3 MRS R3, IPSR LSLS R3, +# 24 BNE PrivilegedF MRS R3, CONTROL LSLS R3, +# 31 BEQ PrivilegedF SVC 0 BX LR PrivilegedF BX R12 - ALIGN + ALIGN } - /*-------------------------- SVC_Handler ------------------------------------*/ -__asm void SVC_Handler (void) { - PRESERVE8 +__asm void SVC_Handler(void) { + PRESERVE8 - IMPORT SVC_Count - IMPORT SVC_Table - IMPORT rt_stk_check + IMPORT SVC_Count IMPORT SVC_Table IMPORT rt_stk_check - MRS R0,PSP ; Read PSP - LDR R1,[R0,#24] ; Read Saved PC from Stack - SUBS R1,R1,#2 ; Point to SVC Instruction - LDRB R1,[R1] ; Load SVC Number - CMP R1,#0 - BNE SVC_User ; User SVC Number > 0 + MRS R0, + PSP; + Read PSP LDR R1, [ R0, #24 ]; + Read Saved PC from Stack SUBS R1, R1, #2; + Point to SVC Instruction LDRB R1, [R1]; + Load SVC Number CMP R1, #0 BNE SVC_User; + User SVC Number > 0 - MOV LR,R4 - LDMIA R0,{R0-R3,R4} ; Read R0-R3,R12 from stack - MOV R12,R4 - MOV R4,LR - BLX R12 ; Call SVC Function + MOV LR, + R4 LDMIA R0, {R0 - R3, R4}; + Read R0 - R3, R12 from stack MOV R12, R4 MOV R4, LR BLX R12; + Call SVC Function - MRS R3,PSP ; Read PSP - STMIA R3!,{R0-R2} ; Store return values + MRS R3, + PSP; + Read PSP STMIA R3 !, {R0 - R2}; + Store return values - LDR R3,=__cpp(&os_tsk) - LDMIA R3!,{R1,R2} ; os_tsk.run, os_tsk.new - CMP R1,R2 - BEQ SVC_Exit ; no task switch + LDR R3, + = __cpp(&os_tsk) LDMIA R3 !, {R1, R2}; + os_tsk.run, os_tsk.new CMP R1, R2 BEQ SVC_Exit; + no task switch - SUBS R3,#8 - CMP R1,#0 ; Runtask deleted? - BEQ SVC_Next + SUBS R3, +# 8 CMP R1, #0; + Runtask deleted ? BEQ SVC_Next - MRS R0,PSP ; Read PSP - SUBS R0,R0,#32 ; Adjust Start Address - STR R0,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack - STMIA R0!,{R4-R7} ; Save old context (R4-R7) - MOV R4,R8 - MOV R5,R9 - MOV R6,R10 - MOV R7,R11 - STMIA R0!,{R4-R7} ; Save old context (R8-R11) + MRS R0, + PSP; + Read PSP SUBS R0, R0, #32; + Adjust Start Address STR R0, [ R1, #TCB_TSTACK ]; + Update os_tsk.run->tsk_stack STMIA R0 !, {R4 - R7}; + Save old context(R4 - R7) MOV R4, R8 MOV R5, R9 MOV R6, R10 MOV R7, + R11 STMIA R0 !, {R4 - R7}; + Save old context(R8 - R11) - PUSH {R2,R3} - BL rt_stk_check ; Check for Stack overflow + PUSH{R2, R3} BL rt_stk_check; Check for Stack overflow POP {R2,R3} SVC_Next - STR R2,[R3] ; os_tsk.run = os_tsk.new + STR R2,[R3] ; + os_tsk.run = os_tsk.new - LDR R0,[R2,#TCB_TSTACK] ; os_tsk.new->tsk_stack - ADDS R0,R0,#16 ; Adjust Start Address - LDMIA R0!,{R4-R7} ; Restore new Context (R8-R11) - MOV R8,R4 - MOV R9,R5 - MOV R10,R6 - MOV R11,R7 - MSR PSP,R0 ; Write PSP - SUBS R0,R0,#32 ; Adjust Start Address - LDMIA R0!,{R4-R7} ; Restore new Context (R4-R7) + LDR R0, + [ R2, #TCB_TSTACK ]; + os_tsk.new->tsk_stack ADDS R0, R0, #16; + Adjust Start Address LDMIA R0 !, {R4 - R7}; + Restore new Context(R8 - R11) MOV R8, R4 MOV R9, R5 MOV R10, R6 MOV R11, + R7 MSR PSP, R0; + Write PSP SUBS R0, R0, #32; + Adjust Start Address LDMIA R0 !, {R4 - R7}; + Restore new Context(R4 - R7) -SVC_Exit - MOVS R0,#:NOT:0xFFFFFFFD ; Set EXC_RETURN value - MVNS R0,R0 - BX R0 ; RETI to Thread Mode, use PSP + SVC_Exit MOVS R0, +# : NOT : 0xFFFFFFFD; + Set EXC_RETURN value MVNS R0, R0 BX R0; + RETI to Thread Mode, + use PSP - /*------------------- User SVC ------------------------------*/ + /*------------------- User SVC ------------------------------*/ -SVC_User - PUSH {R4,LR} ; Save Registers - LDR R2,=SVC_Count - LDR R2,[R2] - CMP R1,R2 - BHI SVC_Done ; Overflow + SVC_User PUSH{R4, LR}; + Save Registers LDR R2, = SVC_Count LDR R2, [R2] CMP R1, R2 BHI SVC_Done; + Overflow - LDR R4,=SVC_Table-4 - LSLS R1,R1,#2 - LDR R4,[R4,R1] ; Load SVC Function Address - MOV LR,R4 + LDR R4, + = SVC_Table - 4 LSLS R1, R1, #2 LDR R4, [ R4, R1 ]; + Load SVC Function Address MOV LR, + R4 - LDMIA R0,{R0-R3,R4} ; Read R0-R3,R12 from stack - MOV R12,R4 - BLX LR ; Call SVC Function + LDMIA R0, + {R0 - R3, R4}; + Read R0 - R3, R12 from stack MOV R12, R4 BLX LR; + Call SVC Function - MRS R4,PSP ; Read PSP - STMIA R4!,{R0-R3} ; Function return values -SVC_Done - POP {R4,PC} ; RETI + MRS R4, + PSP; + Read PSP STMIA R4 !, {R0 - R3}; + Function return values SVC_Done POP{R4, PC}; + RETI - ALIGN + ALIGN } - /*-------------------------- PendSV_Handler ---------------------------------*/ -__asm void PendSV_Handler (void) { - PRESERVE8 +__asm void PendSV_Handler(void) { + PRESERVE8 - BL __cpp(rt_pop_req) + BL __cpp(rt_pop_req) -Sys_Switch - LDR R3,=__cpp(&os_tsk) - LDMIA R3!,{R1,R2} ; os_tsk.run, os_tsk.new - CMP R1,R2 - BEQ Sys_Exit ; no task switch + Sys_Switch LDR R3, + = __cpp(&os_tsk) LDMIA R3 !, {R1, R2}; + os_tsk.run, os_tsk.new CMP R1, R2 BEQ Sys_Exit; + no task switch - SUBS R3,#8 + SUBS R3, +# 8 - MRS R0,PSP ; Read PSP - SUBS R0,R0,#32 ; Adjust Start Address - STR R0,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack - STMIA R0!,{R4-R7} ; Save old context (R4-R7) - MOV R4,R8 - MOV R5,R9 - MOV R6,R10 - MOV R7,R11 - STMIA R0!,{R4-R7} ; Save old context (R8-R11) + MRS R0, PSP; + Read PSP SUBS R0, R0, #32; + Adjust Start Address STR R0, [ R1, #TCB_TSTACK ]; + Update os_tsk.run->tsk_stack STMIA R0 !, {R4 - R7}; + Save old context(R4 - R7) MOV R4, R8 MOV R5, R9 MOV R6, R10 MOV R7, + R11 STMIA R0 !, {R4 - R7}; + Save old context(R8 - R11) - PUSH {R2,R3} - BL rt_stk_check ; Check for Stack overflow + PUSH{R2, R3} BL rt_stk_check; Check for Stack overflow POP {R2,R3} - STR R2,[R3] ; os_tsk.run = os_tsk.new + STR R2,[R3] ; + os_tsk.run = os_tsk.new - LDR R0,[R2,#TCB_TSTACK] ; os_tsk.new->tsk_stack - ADDS R0,R0,#16 ; Adjust Start Address - LDMIA R0!,{R4-R7} ; Restore new Context (R8-R11) - MOV R8,R4 - MOV R9,R5 - MOV R10,R6 - MOV R11,R7 - MSR PSP,R0 ; Write PSP - SUBS R0,R0,#32 ; Adjust Start Address - LDMIA R0!,{R4-R7} ; Restore new Context (R4-R7) + LDR R0, + [ R2, #TCB_TSTACK ]; + os_tsk.new->tsk_stack ADDS R0, R0, #16; + Adjust Start Address LDMIA R0 !, {R4 - R7}; + Restore new Context(R8 - R11) MOV R8, R4 MOV R9, R5 MOV R10, R6 MOV R11, + R7 MSR PSP, R0; + Write PSP SUBS R0, R0, #32; + Adjust Start Address LDMIA R0 !, {R4 - R7}; + Restore new Context(R4 - R7) -Sys_Exit - MOVS R0,#:NOT:0xFFFFFFFD ; Set EXC_RETURN value - MVNS R0,R0 - BX R0 ; RETI to Thread Mode, use PSP + Sys_Exit MOVS R0, +# : NOT : 0xFFFFFFFD; + Set EXC_RETURN value MVNS R0, R0 BX R0; + RETI to Thread Mode, use PSP - ALIGN + ALIGN } - /*-------------------------- SysTick_Handler --------------------------------*/ -__asm void SysTick_Handler (void) { - PRESERVE8 +__asm void SysTick_Handler(void) { + PRESERVE8 - BL __cpp(rt_systick) - B Sys_Switch + BL __cpp(rt_systick) B Sys_Switch - ALIGN + ALIGN } - /*-------------------------- OS_Tick_Handler --------------------------------*/ -__asm void OS_Tick_Handler (void) { - PRESERVE8 +__asm void OS_Tick_Handler(void) { + PRESERVE8 - BL __cpp(os_tick_irqack) - BL __cpp(rt_systick) - B Sys_Switch + BL __cpp(os_tick_irqack) BL __cpp(rt_systick) B Sys_Switch - ALIGN + ALIGN } - /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/TARGET_M0P/TOOLCHAIN_ARM/HAL_CM0.c b/rtos/rtx/TARGET_CORTEX_M/TARGET_M0P/TOOLCHAIN_ARM/HAL_CM0.c index 492e94a..aa3208e 100644 --- a/rtos/rtx/TARGET_CORTEX_M/TARGET_M0P/TOOLCHAIN_ARM/HAL_CM0.c +++ b/rtos/rtx/TARGET_CORTEX_M/TARGET_M0P/TOOLCHAIN_ARM/HAL_CM0.c @@ -32,270 +32,220 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" #include "RTX_Conf.h" -#include "rt_System.h" #include "rt_HAL_CM.h" -#include "rt_Task.h" #include "rt_MemBox.h" - +#include "rt_System.h" +#include "rt_Task.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_set_PSP ------------------------------------*/ -__asm void rt_set_PSP (U32 stack) { - MSR PSP,R0 - BX LR -} - +__asm void rt_set_PSP(U32 stack) { MSR PSP, R0 BX LR } /*--------------------------- rt_get_PSP ------------------------------------*/ -__asm U32 rt_get_PSP (void) { - MRS R0,PSP - BX LR -} - +__asm U32 rt_get_PSP(void) { MRS R0, PSP BX LR } /*--------------------------- os_set_env ------------------------------------*/ -__asm void os_set_env (void) { - /* Switch to Unprivileged/Privileged Thread mode, use PSP. */ - MOV R0,SP ; PSP = MSP - MSR PSP,R0 - LDR R0,=__cpp(&os_flags) - LDRB R0,[R0] - LSLS R0,#31 - BNE PrivilegedE - MOVS R0,#0x03 ; Unprivileged Thread mode, use PSP - MSR CONTROL,R0 - BX LR -PrivilegedE - MOVS R0,#0x02 ; Privileged Thread mode, use PSP - MSR CONTROL,R0 - BX LR +__asm void os_set_env(void) { + /* Switch to Unprivileged/Privileged Thread mode, use PSP. */ + MOV R0, SP; + PSP = MSP MSR PSP, R0 LDR R0, = __cpp(&os_flags) LDRB R0, [R0] LSLS R0, +# 31 BNE PrivilegedE MOVS R0, #0x03; + Unprivileged Thread mode, use PSP MSR CONTROL, R0 BX LR PrivilegedE MOVS R0, +# 0x02; + Privileged Thread mode, use PSP MSR CONTROL, + R0 BX LR - ALIGN + ALIGN } - /*--------------------------- _alloc_box ------------------------------------*/ -__asm void *_alloc_box (void *box_mem) { - /* Function wrapper for Unprivileged/Privileged mode. */ - LDR R3,=__cpp(rt_alloc_box) - MOV R12,R3 - MRS R3,IPSR - LSLS R3,#24 - BNE PrivilegedA - MRS R3,CONTROL - LSLS R3,#31 - BEQ PrivilegedA - SVC 0 - BX LR -PrivilegedA - BX R12 +__asm void *_alloc_box(void *box_mem) { + /* Function wrapper for Unprivileged/Privileged mode. */ + LDR R3, = __cpp(rt_alloc_box) MOV R12, R3 MRS R3, IPSR LSLS R3, +# 24 BNE PrivilegedA MRS R3, CONTROL LSLS R3, +# 31 BEQ PrivilegedA SVC 0 BX LR PrivilegedA BX R12 - ALIGN + ALIGN } - /*--------------------------- _free_box -------------------------------------*/ -__asm int _free_box (void *box_mem, void *box) { - /* Function wrapper for Unprivileged/Privileged mode. */ - LDR R3,=__cpp(rt_free_box) - MOV R12,R3 - MRS R3,IPSR - LSLS R3,#24 - BNE PrivilegedF - MRS R3,CONTROL - LSLS R3,#31 - BEQ PrivilegedF - SVC 0 - BX LR -PrivilegedF - BX R12 +__asm int _free_box(void *box_mem, void *box) { + /* Function wrapper for Unprivileged/Privileged mode. */ + LDR R3, = __cpp(rt_free_box) MOV R12, R3 MRS R3, IPSR LSLS R3, +# 24 BNE PrivilegedF MRS R3, CONTROL LSLS R3, +# 31 BEQ PrivilegedF SVC 0 BX LR PrivilegedF BX R12 - ALIGN + ALIGN } - /*-------------------------- SVC_Handler ------------------------------------*/ -__asm void SVC_Handler (void) { - PRESERVE8 +__asm void SVC_Handler(void) { + PRESERVE8 - IMPORT SVC_Count - IMPORT SVC_Table - IMPORT rt_stk_check + IMPORT SVC_Count IMPORT SVC_Table IMPORT rt_stk_check - MRS R0,PSP ; Read PSP - LDR R1,[R0,#24] ; Read Saved PC from Stack - SUBS R1,R1,#2 ; Point to SVC Instruction - LDRB R1,[R1] ; Load SVC Number - CMP R1,#0 - BNE SVC_User ; User SVC Number > 0 + MRS R0, + PSP; + Read PSP LDR R1, [ R0, #24 ]; + Read Saved PC from Stack SUBS R1, R1, #2; + Point to SVC Instruction LDRB R1, [R1]; + Load SVC Number CMP R1, #0 BNE SVC_User; + User SVC Number > 0 - MOV LR,R4 - LDMIA R0,{R0-R3,R4} ; Read R0-R3,R12 from stack - MOV R12,R4 - MOV R4,LR - BLX R12 ; Call SVC Function + MOV LR, + R4 LDMIA R0, {R0 - R3, R4}; + Read R0 - R3, R12 from stack MOV R12, R4 MOV R4, LR BLX R12; + Call SVC Function - MRS R3,PSP ; Read PSP - STMIA R3!,{R0-R2} ; Store return values + MRS R3, + PSP; + Read PSP STMIA R3 !, {R0 - R2}; + Store return values - LDR R3,=__cpp(&os_tsk) - LDMIA R3!,{R1,R2} ; os_tsk.run, os_tsk.new - CMP R1,R2 - BEQ SVC_Exit ; no task switch + LDR R3, + = __cpp(&os_tsk) LDMIA R3 !, {R1, R2}; + os_tsk.run, os_tsk.new CMP R1, R2 BEQ SVC_Exit; + no task switch - SUBS R3,#8 - CMP R1,#0 ; Runtask deleted? - BEQ SVC_Next + SUBS R3, +# 8 CMP R1, #0; + Runtask deleted ? BEQ SVC_Next - MRS R0,PSP ; Read PSP - SUBS R0,R0,#32 ; Adjust Start Address - STR R0,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack - STMIA R0!,{R4-R7} ; Save old context (R4-R7) - MOV R4,R8 - MOV R5,R9 - MOV R6,R10 - MOV R7,R11 - STMIA R0!,{R4-R7} ; Save old context (R8-R11) + MRS R0, + PSP; + Read PSP SUBS R0, R0, #32; + Adjust Start Address STR R0, [ R1, #TCB_TSTACK ]; + Update os_tsk.run->tsk_stack STMIA R0 !, {R4 - R7}; + Save old context(R4 - R7) MOV R4, R8 MOV R5, R9 MOV R6, R10 MOV R7, + R11 STMIA R0 !, {R4 - R7}; + Save old context(R8 - R11) - PUSH {R2,R3} - BL rt_stk_check ; Check for Stack overflow + PUSH{R2, R3} BL rt_stk_check; Check for Stack overflow POP {R2,R3} SVC_Next - STR R2,[R3] ; os_tsk.run = os_tsk.new + STR R2,[R3] ; + os_tsk.run = os_tsk.new - LDR R0,[R2,#TCB_TSTACK] ; os_tsk.new->tsk_stack - ADDS R0,R0,#16 ; Adjust Start Address - LDMIA R0!,{R4-R7} ; Restore new Context (R8-R11) - MOV R8,R4 - MOV R9,R5 - MOV R10,R6 - MOV R11,R7 - MSR PSP,R0 ; Write PSP - SUBS R0,R0,#32 ; Adjust Start Address - LDMIA R0!,{R4-R7} ; Restore new Context (R4-R7) + LDR R0, + [ R2, #TCB_TSTACK ]; + os_tsk.new->tsk_stack ADDS R0, R0, #16; + Adjust Start Address LDMIA R0 !, {R4 - R7}; + Restore new Context(R8 - R11) MOV R8, R4 MOV R9, R5 MOV R10, R6 MOV R11, + R7 MSR PSP, R0; + Write PSP SUBS R0, R0, #32; + Adjust Start Address LDMIA R0 !, {R4 - R7}; + Restore new Context(R4 - R7) -SVC_Exit - MOVS R0,#:NOT:0xFFFFFFFD ; Set EXC_RETURN value - MVNS R0,R0 - BX R0 ; RETI to Thread Mode, use PSP + SVC_Exit MOVS R0, +# : NOT : 0xFFFFFFFD; + Set EXC_RETURN value MVNS R0, R0 BX R0; + RETI to Thread Mode, + use PSP - /*------------------- User SVC ------------------------------*/ + /*------------------- User SVC ------------------------------*/ -SVC_User - PUSH {R4,LR} ; Save Registers - LDR R2,=SVC_Count - LDR R2,[R2] - CMP R1,R2 - BHI SVC_Done ; Overflow + SVC_User PUSH{R4, LR}; + Save Registers LDR R2, = SVC_Count LDR R2, [R2] CMP R1, R2 BHI SVC_Done; + Overflow - LDR R4,=SVC_Table-4 - LSLS R1,R1,#2 - LDR R4,[R4,R1] ; Load SVC Function Address - MOV LR,R4 + LDR R4, + = SVC_Table - 4 LSLS R1, R1, #2 LDR R4, [ R4, R1 ]; + Load SVC Function Address MOV LR, + R4 - LDMIA R0,{R0-R3,R4} ; Read R0-R3,R12 from stack - MOV R12,R4 - BLX LR ; Call SVC Function + LDMIA R0, + {R0 - R3, R4}; + Read R0 - R3, R12 from stack MOV R12, R4 BLX LR; + Call SVC Function - MRS R4,PSP ; Read PSP - STMIA R4!,{R0-R3} ; Function return values -SVC_Done - POP {R4,PC} ; RETI + MRS R4, + PSP; + Read PSP STMIA R4 !, {R0 - R3}; + Function return values SVC_Done POP{R4, PC}; + RETI - ALIGN + ALIGN } - /*-------------------------- PendSV_Handler ---------------------------------*/ -__asm void PendSV_Handler (void) { - PRESERVE8 +__asm void PendSV_Handler(void) { + PRESERVE8 - BL __cpp(rt_pop_req) + BL __cpp(rt_pop_req) -Sys_Switch - LDR R3,=__cpp(&os_tsk) - LDMIA R3!,{R1,R2} ; os_tsk.run, os_tsk.new - CMP R1,R2 - BEQ Sys_Exit ; no task switch + Sys_Switch LDR R3, + = __cpp(&os_tsk) LDMIA R3 !, {R1, R2}; + os_tsk.run, os_tsk.new CMP R1, R2 BEQ Sys_Exit; + no task switch - SUBS R3,#8 + SUBS R3, +# 8 - MRS R0,PSP ; Read PSP - SUBS R0,R0,#32 ; Adjust Start Address - STR R0,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack - STMIA R0!,{R4-R7} ; Save old context (R4-R7) - MOV R4,R8 - MOV R5,R9 - MOV R6,R10 - MOV R7,R11 - STMIA R0!,{R4-R7} ; Save old context (R8-R11) + MRS R0, PSP; + Read PSP SUBS R0, R0, #32; + Adjust Start Address STR R0, [ R1, #TCB_TSTACK ]; + Update os_tsk.run->tsk_stack STMIA R0 !, {R4 - R7}; + Save old context(R4 - R7) MOV R4, R8 MOV R5, R9 MOV R6, R10 MOV R7, + R11 STMIA R0 !, {R4 - R7}; + Save old context(R8 - R11) - PUSH {R2,R3} - BL rt_stk_check ; Check for Stack overflow + PUSH{R2, R3} BL rt_stk_check; Check for Stack overflow POP {R2,R3} - STR R2,[R3] ; os_tsk.run = os_tsk.new + STR R2,[R3] ; + os_tsk.run = os_tsk.new - LDR R0,[R2,#TCB_TSTACK] ; os_tsk.new->tsk_stack - ADDS R0,R0,#16 ; Adjust Start Address - LDMIA R0!,{R4-R7} ; Restore new Context (R8-R11) - MOV R8,R4 - MOV R9,R5 - MOV R10,R6 - MOV R11,R7 - MSR PSP,R0 ; Write PSP - SUBS R0,R0,#32 ; Adjust Start Address - LDMIA R0!,{R4-R7} ; Restore new Context (R4-R7) + LDR R0, + [ R2, #TCB_TSTACK ]; + os_tsk.new->tsk_stack ADDS R0, R0, #16; + Adjust Start Address LDMIA R0 !, {R4 - R7}; + Restore new Context(R8 - R11) MOV R8, R4 MOV R9, R5 MOV R10, R6 MOV R11, + R7 MSR PSP, R0; + Write PSP SUBS R0, R0, #32; + Adjust Start Address LDMIA R0 !, {R4 - R7}; + Restore new Context(R4 - R7) -Sys_Exit - MOVS R0,#:NOT:0xFFFFFFFD ; Set EXC_RETURN value - MVNS R0,R0 - BX R0 ; RETI to Thread Mode, use PSP + Sys_Exit MOVS R0, +# : NOT : 0xFFFFFFFD; + Set EXC_RETURN value MVNS R0, R0 BX R0; + RETI to Thread Mode, use PSP - ALIGN + ALIGN } - /*-------------------------- SysTick_Handler --------------------------------*/ -__asm void SysTick_Handler (void) { - PRESERVE8 +__asm void SysTick_Handler(void) { + PRESERVE8 - BL __cpp(rt_systick) - B Sys_Switch + BL __cpp(rt_systick) B Sys_Switch - ALIGN + ALIGN } - /*-------------------------- OS_Tick_Handler --------------------------------*/ -__asm void OS_Tick_Handler (void) { - PRESERVE8 +__asm void OS_Tick_Handler(void) { + PRESERVE8 - BL __cpp(os_tick_irqack) - BL __cpp(rt_systick) - B Sys_Switch + BL __cpp(os_tick_irqack) BL __cpp(rt_systick) B Sys_Switch - ALIGN + ALIGN } - /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/TARGET_M3/TOOLCHAIN_ARM/HAL_CM3.c b/rtos/rtx/TARGET_CORTEX_M/TARGET_M3/TOOLCHAIN_ARM/HAL_CM3.c index feb1457..28f9418 100644 --- a/rtos/rtx/TARGET_CORTEX_M/TARGET_M3/TOOLCHAIN_ARM/HAL_CM3.c +++ b/rtos/rtx/TARGET_CORTEX_M/TARGET_M3/TOOLCHAIN_ARM/HAL_CM3.c @@ -32,218 +32,194 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" #include "RTX_Conf.h" -#include "rt_System.h" #include "rt_HAL_CM.h" -#include "rt_Task.h" #include "rt_MemBox.h" - +#include "rt_System.h" +#include "rt_Task.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_set_PSP ------------------------------------*/ -__asm void rt_set_PSP (U32 stack) { - MSR PSP,R0 - BX LR -} - +__asm void rt_set_PSP(U32 stack) { MSR PSP, R0 BX LR } /*--------------------------- rt_get_PSP ------------------------------------*/ -__asm U32 rt_get_PSP (void) { - MRS R0,PSP - BX LR -} - +__asm U32 rt_get_PSP(void) { MRS R0, PSP BX LR } /*--------------------------- os_set_env ------------------------------------*/ -__asm void os_set_env (void) { - /* Switch to Unprivileged/Privileged Thread mode, use PSP. */ - MOV R0,SP ; PSP = MSP - MSR PSP,R0 - LDR R0,=__cpp(&os_flags) - LDRB R0,[R0] - LSLS R0,#31 - MOVNE R0,#0x02 ; Privileged Thread mode, use PSP - MOVEQ R0,#0x03 ; Unprivileged Thread mode, use PSP - MSR CONTROL,R0 - BX LR +__asm void os_set_env(void) { + /* Switch to Unprivileged/Privileged Thread mode, use PSP. */ + MOV R0, SP; + PSP = MSP MSR PSP, R0 LDR R0, = __cpp(&os_flags) LDRB R0, [R0] LSLS R0, +# 31 MOVNE R0, #0x02; + Privileged Thread mode, use PSP MOVEQ R0, #0x03; + Unprivileged Thread mode, use PSP MSR CONTROL, + R0 BX LR - ALIGN + ALIGN } - /*--------------------------- _alloc_box ------------------------------------*/ -__asm void *_alloc_box (void *box_mem) { - /* Function wrapper for Unprivileged/Privileged mode. */ - LDR R12,=__cpp(rt_alloc_box) - MRS R3,IPSR - LSLS R3,#24 - BXNE R12 - MRS R3,CONTROL - LSLS R3,#31 - BXEQ R12 - SVC 0 - BX LR +__asm void *_alloc_box(void *box_mem) { + /* Function wrapper for Unprivileged/Privileged mode. */ + LDR R12, = __cpp(rt_alloc_box) MRS R3, IPSR LSLS R3, #24 BXNE R12 MRS R3, + CONTROL LSLS R3, +# 31 BXEQ R12 SVC 0 BX LR - ALIGN + ALIGN } - /*--------------------------- _free_box -------------------------------------*/ -__asm int _free_box (void *box_mem, void *box) { - /* Function wrapper for Unprivileged/Privileged mode. */ - LDR R12,=__cpp(rt_free_box) - MRS R3,IPSR - LSLS R3,#24 - BXNE R12 - MRS R3,CONTROL - LSLS R3,#31 - BXEQ R12 - SVC 0 - BX LR +__asm int _free_box(void *box_mem, void *box) { + /* Function wrapper for Unprivileged/Privileged mode. */ + LDR R12, = __cpp(rt_free_box) MRS R3, IPSR LSLS R3, #24 BXNE R12 MRS R3, + CONTROL LSLS R3, +# 31 BXEQ R12 SVC 0 BX LR - ALIGN + ALIGN } - /*-------------------------- SVC_Handler ------------------------------------*/ -__asm void SVC_Handler (void) { - PRESERVE8 +__asm void SVC_Handler(void) { + PRESERVE8 - IMPORT SVC_Count - IMPORT SVC_Table - IMPORT rt_stk_check + IMPORT SVC_Count IMPORT SVC_Table IMPORT rt_stk_check - MRS R0,PSP ; Read PSP - LDR R1,[R0,#24] ; Read Saved PC from Stack - LDRB R1,[R1,#-2] ; Load SVC Number - CBNZ R1,SVC_User + MRS R0, + PSP; + Read PSP LDR R1, [ R0, #24 ]; + Read Saved PC from Stack LDRB R1, [ R1, # - 2 ]; + Load SVC Number CBNZ R1, + SVC_User - LDM R0,{R0-R3,R12} ; Read R0-R3,R12 from stack - BLX R12 ; Call SVC Function + LDM R0, + {R0 - R3, R12}; + Read R0 - R3, R12 from stack BLX R12; + Call SVC Function - MRS R12,PSP ; Read PSP - STM R12,{R0-R2} ; Store return values + MRS R12, + PSP; + Read PSP STM R12, {R0 - R2}; + Store return values - LDR R3,=__cpp(&os_tsk) - LDM R3,{R1,R2} ; os_tsk.run, os_tsk.new - CMP R1,R2 - BEQ SVC_Exit ; no task switch + LDR R3, + = __cpp(&os_tsk) LDM R3, {R1, R2}; + os_tsk.run, os_tsk.new CMP R1, R2 BEQ SVC_Exit; + no task switch - CBZ R1,SVC_Next ; Runtask deleted? - STMDB R12!,{R4-R11} ; Save Old context - STR R12,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack + CBZ R1, + SVC_Next; + Runtask deleted ? STMDB R12 !, {R4 - R11}; + Save Old context STR R12, [ R1, #TCB_TSTACK ]; + Update os_tsk.run->tsk_stack - PUSH {R2,R3} - BL rt_stk_check ; Check for Stack overflow + PUSH{R2, R3} BL rt_stk_check; Check for Stack overflow POP {R2,R3} SVC_Next - STR R2,[R3] ; os_tsk.run = os_tsk.new + STR R2,[R3] ; + os_tsk.run = os_tsk.new - LDR R12,[R2,#TCB_TSTACK] ; os_tsk.new->tsk_stack - LDMIA R12!,{R4-R11} ; Restore New Context - MSR PSP,R12 ; Write PSP + LDR R12, + [ R2, #TCB_TSTACK ]; + os_tsk.new->tsk_stack LDMIA R12 !, {R4 - R11}; + Restore New Context MSR PSP, R12; + Write PSP -SVC_Exit - MVN LR,#:NOT:0xFFFFFFFD ; set EXC_RETURN value - BX LR + SVC_Exit MVN LR, +# : NOT : 0xFFFFFFFD; + set EXC_RETURN value BX LR - /*------------------- User SVC ------------------------------*/ + /*------------------- User SVC ------------------------------*/ -SVC_User - PUSH {R4,LR} ; Save Registers - LDR R2,=SVC_Count - LDR R2,[R2] - CMP R1,R2 - BHI SVC_Done ; Overflow + SVC_User PUSH{R4, LR}; + Save Registers LDR R2, = SVC_Count LDR R2, [R2] CMP R1, R2 BHI SVC_Done; + Overflow - LDR R4,=SVC_Table-4 - LDR R4,[R4,R1,LSL #2] ; Load SVC Function Address + LDR R4, + = SVC_Table - 4 LDR R4, [ R4, R1, LSL #2 ]; + Load SVC Function Address - LDM R0,{R0-R3,R12} ; Read R0-R3,R12 from stack - BLX R4 ; Call SVC Function + LDM R0, + {R0 - R3, R12}; + Read R0 - R3, R12 from stack BLX R4; + Call SVC Function - MRS R12,PSP - STM R12,{R0-R3} ; Function return values -SVC_Done - POP {R4,PC} ; RETI + MRS R12, + PSP STM R12, {R0 - R3}; + Function return values SVC_Done POP{R4, PC}; + RETI - ALIGN + ALIGN } - /*-------------------------- PendSV_Handler ---------------------------------*/ -__asm void PendSV_Handler (void) { - PRESERVE8 +__asm void PendSV_Handler(void) { + PRESERVE8 - BL __cpp(rt_pop_req) + BL __cpp(rt_pop_req) -Sys_Switch - LDR R3,=__cpp(&os_tsk) - LDM R3,{R1,R2} ; os_tsk.run, os_tsk.new - CMP R1,R2 - BEQ Sys_Exit + Sys_Switch LDR R3, + = __cpp(&os_tsk) LDM R3, {R1, R2}; + os_tsk.run, os_tsk.new CMP R1, + R2 BEQ Sys_Exit - MRS R12,PSP ; Read PSP - STMDB R12!,{R4-R11} ; Save Old context - STR R12,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack + MRS R12, + PSP; + Read PSP STMDB R12 !, {R4 - R11}; + Save Old context STR R12, [ R1, #TCB_TSTACK ]; + Update os_tsk.run->tsk_stack - PUSH {R2,R3} - BL rt_stk_check ; Check for Stack overflow + PUSH{R2, R3} BL rt_stk_check; Check for Stack overflow POP {R2,R3} - STR R2,[R3] ; os_tsk.run = os_tsk.new + STR R2,[R3] ; + os_tsk.run = os_tsk.new - LDR R12,[R2,#TCB_TSTACK] ; os_tsk.new->tsk_stack - LDMIA R12!,{R4-R11} ; Restore New Context - MSR PSP,R12 ; Write PSP + LDR R12, + [ R2, #TCB_TSTACK ]; + os_tsk.new->tsk_stack LDMIA R12 !, {R4 - R11}; + Restore New Context MSR PSP, R12; + Write PSP -Sys_Exit - MVN LR,#:NOT:0xFFFFFFFD ; set EXC_RETURN value - BX LR ; Return to Thread Mode + Sys_Exit MVN LR, +# : NOT : 0xFFFFFFFD; + set EXC_RETURN value BX LR; + Return to Thread Mode - ALIGN + ALIGN } - /*-------------------------- SysTick_Handler --------------------------------*/ -__asm void SysTick_Handler (void) { - PRESERVE8 +__asm void SysTick_Handler(void) { + PRESERVE8 - BL __cpp(rt_systick) - B Sys_Switch + BL __cpp(rt_systick) B Sys_Switch - ALIGN + ALIGN } - /*-------------------------- OS_Tick_Handler --------------------------------*/ -__asm void OS_Tick_Handler (void) { - PRESERVE8 +__asm void OS_Tick_Handler(void) { + PRESERVE8 - BL __cpp(os_tick_irqack) - BL __cpp(rt_systick) - B Sys_Switch + BL __cpp(os_tick_irqack) BL __cpp(rt_systick) B Sys_Switch - ALIGN + ALIGN } - /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/TARGET_M4/TOOLCHAIN_ARM/HAL_CM4.c b/rtos/rtx/TARGET_CORTEX_M/TARGET_M4/TOOLCHAIN_ARM/HAL_CM4.c index 32327d8..11c4958 100644 --- a/rtos/rtx/TARGET_CORTEX_M/TARGET_M4/TOOLCHAIN_ARM/HAL_CM4.c +++ b/rtos/rtx/TARGET_CORTEX_M/TARGET_M4/TOOLCHAIN_ARM/HAL_CM4.c @@ -32,278 +32,254 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" #include "RTX_Conf.h" -#include "rt_System.h" #include "rt_HAL_CM.h" -#include "rt_Task.h" #include "rt_MemBox.h" - +#include "rt_System.h" +#include "rt_Task.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_set_PSP ------------------------------------*/ -__asm void rt_set_PSP (U32 stack) { - MSR PSP,R0 - BX LR -} - +__asm void rt_set_PSP(U32 stack) { MSR PSP, R0 BX LR } /*--------------------------- rt_get_PSP ------------------------------------*/ -__asm U32 rt_get_PSP (void) { - MRS R0,PSP - BX LR -} - +__asm U32 rt_get_PSP(void) { MRS R0, PSP BX LR } /*--------------------------- os_set_env ------------------------------------*/ -__asm void os_set_env (void) { - /* Switch to Unprivileged/Privileged Thread mode, use PSP. */ - MOV R0,SP ; PSP = MSP - MSR PSP,R0 - LDR R0,=__cpp(&os_flags) - LDRB R0,[R0] - LSLS R0,#31 - MOVNE R0,#0x02 ; Privileged Thread mode, use PSP - MOVEQ R0,#0x03 ; Unprivileged Thread mode, use PSP - MSR CONTROL,R0 - BX LR +__asm void os_set_env(void) { + /* Switch to Unprivileged/Privileged Thread mode, use PSP. */ + MOV R0, SP; + PSP = MSP MSR PSP, R0 LDR R0, = __cpp(&os_flags) LDRB R0, [R0] LSLS R0, +# 31 MOVNE R0, #0x02; + Privileged Thread mode, use PSP MOVEQ R0, #0x03; + Unprivileged Thread mode, use PSP MSR CONTROL, + R0 BX LR - ALIGN + ALIGN } - /*--------------------------- _alloc_box ------------------------------------*/ -__asm void *_alloc_box (void *box_mem) { - /* Function wrapper for Unprivileged/Privileged mode. */ - LDR R12,=__cpp(rt_alloc_box) - MRS R3,IPSR - LSLS R3,#24 - BXNE R12 - MRS R3,CONTROL - LSLS R3,#31 - BXEQ R12 - SVC 0 - BX LR +__asm void *_alloc_box(void *box_mem) { + /* Function wrapper for Unprivileged/Privileged mode. */ + LDR R12, = __cpp(rt_alloc_box) MRS R3, IPSR LSLS R3, #24 BXNE R12 MRS R3, + CONTROL LSLS R3, +# 31 BXEQ R12 SVC 0 BX LR - ALIGN + ALIGN } - /*--------------------------- _free_box -------------------------------------*/ -__asm int _free_box (void *box_mem, void *box) { - /* Function wrapper for Unprivileged/Privileged mode. */ - LDR R12,=__cpp(rt_free_box) - MRS R3,IPSR - LSLS R3,#24 - BXNE R12 - MRS R3,CONTROL - LSLS R3,#31 - BXEQ R12 - SVC 0 - BX LR +__asm int _free_box(void *box_mem, void *box) { + /* Function wrapper for Unprivileged/Privileged mode. */ + LDR R12, = __cpp(rt_free_box) MRS R3, IPSR LSLS R3, #24 BXNE R12 MRS R3, + CONTROL LSLS R3, +# 31 BXEQ R12 SVC 0 BX LR - ALIGN + ALIGN } - /*-------------------------- SVC_Handler ------------------------------------*/ -__asm void SVC_Handler (void) { - PRESERVE8 +__asm void SVC_Handler(void) { + PRESERVE8 - IMPORT SVC_Count - IMPORT SVC_Table - IMPORT rt_stk_check + IMPORT SVC_Count IMPORT SVC_Table IMPORT rt_stk_check -#ifdef IFX_XMC4XXX - EXPORT SVC_Handler_Veneer -SVC_Handler_Veneer +#ifdef IFX_XMC4XXX + EXPORT SVC_Handler_Veneer SVC_Handler_Veneer #endif - MRS R0,PSP ; Read PSP - LDR R1,[R0,#24] ; Read Saved PC from Stack - LDRB R1,[R1,#-2] ; Load SVC Number - CBNZ R1,SVC_User + MRS R0, + PSP; + Read PSP LDR R1, [ R0, #24 ]; + Read Saved PC from Stack LDRB R1, [ R1, # - 2 ]; + Load SVC Number CBNZ R1, + SVC_User - LDM R0,{R0-R3,R12} ; Read R0-R3,R12 from stack - PUSH {R4,LR} ; Save EXC_RETURN - BLX R12 ; Call SVC Function - POP {R4,LR} ; Restore EXC_RETURN + LDM R0, + {R0 - R3, R12}; + Read R0 - R3, R12 from stack PUSH{R4, LR}; + Save EXC_RETURN BLX R12; + Call SVC Function POP{R4, LR}; + Restore EXC_RETURN - MRS R12,PSP ; Read PSP - STM R12,{R0-R2} ; Store return values + MRS R12, + PSP; + Read PSP STM R12, {R0 - R2}; + Store return values - LDR R3,=__cpp(&os_tsk) - LDM R3,{R1,R2} ; os_tsk.run, os_tsk.new - CMP R1,R2 -#ifdef IFX_XMC4XXX - PUSHEQ {LR} - POPEQ {PC} + LDR R3, + = __cpp(&os_tsk) LDM R3, {R1, R2}; + os_tsk.run, os_tsk.new CMP R1, + R2 +#ifdef IFX_XMC4XXX + PUSHEQ{LR} POPEQ { + PC + } #else - BXEQ LR ; RETI, no task switch + BXEQ LR; + RETI, no task switch #endif - CBZ R1,SVC_Next ; Runtask deleted? - TST LR,#0x10 ; is it extended frame? - VSTMDBEQ R12!,{S16-S31} ; yes, stack also VFP hi-regs - MOVEQ R0,#0x01 ; os_tsk->stack_frame val - MOVNE R0,#0x00 - STRB R0,[R1,#TCB_STACKF] ; os_tsk.run->stack_frame = val - STMDB R12!,{R4-R11} ; Save Old context - STR R12,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack + CBZ R1, SVC_Next; + Runtask deleted ? TST LR, #0x10; + is it extended frame ? VSTMDBEQ R12 !, {S16 - S31}; + yes, stack also VFP hi - regs MOVEQ R0, #0x01; + os_tsk->stack_frame val MOVNE R0, #0x00 STRB R0, [ R1, #TCB_STACKF ]; + os_tsk.run->stack_frame = val STMDB R12 !, {R4 - R11}; + Save Old context STR R12, [ R1, #TCB_TSTACK ]; + Update os_tsk.run->tsk_stack - PUSH {R2,R3} - BL rt_stk_check ; Check for Stack overflow + PUSH{R2, R3} BL rt_stk_check; Check for Stack overflow POP {R2,R3} SVC_Next - STR R2,[R3] ; os_tsk.run = os_tsk.new + STR R2,[R3] ; + os_tsk.run = os_tsk.new - LDR R12,[R2,#TCB_TSTACK] ; os_tsk.new->tsk_stack - LDMIA R12!,{R4-R11} ; Restore New Context - LDRB R0,[R2,#TCB_STACKF] ; Stack Frame - CMP R0,#0 ; Basic/Extended Stack Frame - VLDMIANE R12!,{S16-S31} ; restore VFP hi-registers - MVNNE LR,#:NOT:0xFFFFFFED ; set EXC_RETURN value - MVNEQ LR,#:NOT:0xFFFFFFFD - MSR PSP,R12 ; Write PSP + LDR R12, + [ R2, #TCB_TSTACK ]; + os_tsk.new->tsk_stack LDMIA R12 !, {R4 - R11}; + Restore New Context LDRB R0, [ R2, #TCB_STACKF ]; + Stack Frame CMP R0, #0; + Basic / Extended Stack Frame VLDMIANE R12 !, {S16 - S31}; + restore VFP hi - registers MVNNE LR, # : NOT : 0xFFFFFFED; + set EXC_RETURN value MVNEQ LR, # : NOT : 0xFFFFFFFD MSR PSP, R12; + Write PSP -SVC_Exit -#ifdef IFX_XMC4XXX - PUSH {LR} - POP {PC} + SVC_Exit +#ifdef IFX_XMC4XXX + PUSH{LR} POP { + PC + } #else - BX LR + BX LR #endif - /*------------------- User SVC ------------------------------*/ + /*------------------- User SVC ------------------------------*/ -SVC_User - PUSH {R4,LR} ; Save Registers - LDR R2,=SVC_Count - LDR R2,[R2] - CMP R1,R2 - BHI SVC_Done ; Overflow + SVC_User PUSH{R4, LR}; + Save Registers LDR R2, = SVC_Count LDR R2, [R2] CMP R1, R2 BHI SVC_Done; + Overflow - LDR R4,=SVC_Table-4 - LDR R4,[R4,R1,LSL #2] ; Load SVC Function Address + LDR R4, + = SVC_Table - 4 LDR R4, [ R4, R1, LSL #2 ]; + Load SVC Function Address - LDM R0,{R0-R3,R12} ; Read R0-R3,R12 from stack - BLX R4 ; Call SVC Function + LDM R0, + {R0 - R3, R12}; + Read R0 - R3, R12 from stack BLX R4; + Call SVC Function - MRS R12,PSP - STM R12,{R0-R3} ; Function return values -SVC_Done - POP {R4,PC} ; RETI + MRS R12, + PSP STM R12, {R0 - R3}; + Function return values SVC_Done POP{R4, PC}; + RETI - ALIGN + ALIGN } - /*-------------------------- PendSV_Handler ---------------------------------*/ -__asm void PendSV_Handler (void) { - PRESERVE8 +__asm void PendSV_Handler(void) { + PRESERVE8 -#ifdef IFX_XMC4XXX - EXPORT PendSV_Handler_Veneer -PendSV_Handler_Veneer +#ifdef IFX_XMC4XXX + EXPORT PendSV_Handler_Veneer PendSV_Handler_Veneer #endif - PUSH {R4,LR} ; Save EXC_RETURN - BL __cpp(rt_pop_req) + PUSH{R4, LR}; + Save EXC_RETURN BL __cpp(rt_pop_req) -Sys_Switch - POP {R4,LR} ; Restore EXC_RETURN + Sys_Switch POP{R4, LR}; + Restore EXC_RETURN - LDR R3,=__cpp(&os_tsk) - LDM R3,{R1,R2} ; os_tsk.run, os_tsk.new - CMP R1,R2 -#ifdef IFX_XMC4XXX - PUSHEQ {LR} - POPEQ {PC} + LDR R3, + = __cpp(&os_tsk) LDM R3, {R1, R2}; + os_tsk.run, os_tsk.new CMP R1, + R2 +#ifdef IFX_XMC4XXX + PUSHEQ{LR} POPEQ { + PC + } #else - BXEQ LR ; RETI, no task switch + BXEQ LR; + RETI, no task switch #endif - MRS R12,PSP ; Read PSP - TST LR,#0x10 ; is it extended frame? - VSTMDBEQ R12!,{S16-S31} ; yes, stack also VFP hi-regs - MOVEQ R0,#0x01 ; os_tsk->stack_frame val - MOVNE R0,#0x00 - STRB R0,[R1,#TCB_STACKF] ; os_tsk.run->stack_frame = val - STMDB R12!,{R4-R11} ; Save Old context - STR R12,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack + MRS R12, PSP; + Read PSP TST LR, #0x10; + is it extended frame ? VSTMDBEQ R12 !, {S16 - S31}; + yes, stack also VFP hi - regs MOVEQ R0, #0x01; + os_tsk->stack_frame val MOVNE R0, #0x00 STRB R0, [ R1, #TCB_STACKF ]; + os_tsk.run->stack_frame = val STMDB R12 !, {R4 - R11}; + Save Old context STR R12, [ R1, #TCB_TSTACK ]; + Update os_tsk.run->tsk_stack - PUSH {R2,R3} - BL rt_stk_check ; Check for Stack overflow + PUSH{R2, R3} BL rt_stk_check; Check for Stack overflow POP {R2,R3} - STR R2,[R3] ; os_tsk.run = os_tsk.new + STR R2,[R3] ; + os_tsk.run = os_tsk.new - LDR R12,[R2,#TCB_TSTACK] ; os_tsk.new->tsk_stack - LDMIA R12!,{R4-R11} ; Restore New Context - LDRB R0,[R2,#TCB_STACKF] ; Stack Frame - CMP R0,#0 ; Basic/Extended Stack Frame - VLDMIANE R12!,{S16-S31} ; restore VFP hi-regs - MVNNE LR,#:NOT:0xFFFFFFED ; set EXC_RETURN value - MVNEQ LR,#:NOT:0xFFFFFFFD - MSR PSP,R12 ; Write PSP + LDR R12, + [ R2, #TCB_TSTACK ]; + os_tsk.new->tsk_stack LDMIA R12 !, {R4 - R11}; + Restore New Context LDRB R0, [ R2, #TCB_STACKF ]; + Stack Frame CMP R0, #0; + Basic / Extended Stack Frame VLDMIANE R12 !, {S16 - S31}; + restore VFP hi - regs MVNNE LR, # : NOT : 0xFFFFFFED; + set EXC_RETURN value MVNEQ LR, # : NOT : 0xFFFFFFFD MSR PSP, R12; + Write PSP -Sys_Exit -#ifdef IFX_XMC4XXX - PUSH {LR} - POP {PC} + Sys_Exit +#ifdef IFX_XMC4XXX + PUSH{LR} POP { + PC + } #else - BX LR ; Return to Thread Mode + BX LR; + Return to Thread Mode #endif - ALIGN + ALIGN } - /*-------------------------- SysTick_Handler --------------------------------*/ -__asm void SysTick_Handler (void) { - PRESERVE8 +__asm void SysTick_Handler(void) { + PRESERVE8 -#ifdef IFX_XMC4XXX - EXPORT SysTick_Handler_Veneer -SysTick_Handler_Veneer +#ifdef IFX_XMC4XXX + EXPORT SysTick_Handler_Veneer SysTick_Handler_Veneer #endif - PUSH {R4,LR} ; Save EXC_RETURN - BL __cpp(rt_systick) - B Sys_Switch + PUSH{R4, LR}; + Save EXC_RETURN BL __cpp(rt_systick) B Sys_Switch - ALIGN + ALIGN } - /*-------------------------- OS_Tick_Handler --------------------------------*/ -__asm void OS_Tick_Handler (void) { - PRESERVE8 +__asm void OS_Tick_Handler(void) { + PRESERVE8 - PUSH {R4,LR} ; Save EXC_RETURN - BL __cpp(os_tick_irqack) - BL __cpp(rt_systick) - B Sys_Switch + PUSH{R4, LR}; + Save EXC_RETURN BL __cpp(os_tick_irqack) BL __cpp(rt_systick) B Sys_Switch - ALIGN + ALIGN } - /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_CMSIS.c b/rtos/rtx/TARGET_CORTEX_M/rt_CMSIS.c index 381c21b..b29ccfa 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_CMSIS.c +++ b/rtos/rtx/TARGET_CORTEX_M/rt_CMSIS.c @@ -36,18 +36,18 @@ #include "cmsis.h" -#include "rt_TypeDef.h" #include "RTX_Conf.h" -#include "rt_System.h" -#include "rt_Task.h" #include "rt_Event.h" +#include "rt_HAL_CM.h" #include "rt_List.h" -#include "rt_Time.h" -#include "rt_Mutex.h" -#include "rt_Semaphore.h" #include "rt_Mailbox.h" #include "rt_MemBox.h" -#include "rt_HAL_CM.h" +#include "rt_Mutex.h" +#include "rt_Semaphore.h" +#include "rt_System.h" +#include "rt_Task.h" +#include "rt_Time.h" +#include "rt_TypeDef.h" #define os_thread_cb OS_TCB @@ -70,260 +70,233 @@ // CAUTION: // It will be treated as in ISR when calling OS APIs in intlock(), but // the stack might still be using PSP instead of MSP. -#define IN_ISR() (__get_IPSR() != 0 || __get_PRIMASK() != 0) +#define IN_ISR() (__get_IPSR() != 0 || __get_PRIMASK() != 0) #else -#define IN_ISR() (__get_IPSR() != 0) +#define IN_ISR() (__get_IPSR() != 0) #endif // ==== Enumeration, structures, defines ==== // Service Calls defines -#if defined (__CC_ARM) /* ARM Compiler */ +#if defined(__CC_ARM) /* ARM Compiler */ #define __NO_RETURN __declspec(noreturn) -#define osEvent_type osEvent +#define osEvent_type osEvent #define osEvent_ret_status ret -#define osEvent_ret_value ret -#define osEvent_ret_msg ret -#define osEvent_ret_mail ret +#define osEvent_ret_value ret +#define osEvent_ret_msg ret +#define osEvent_ret_mail ret -#define osCallback_type osCallback -#define osCallback_ret ret +#define osCallback_type osCallback +#define osCallback_ret ret -#define SVC_0_1(f,t,...) \ -__svc_indirect(0) t _##f (t(*)()); \ - t f (void); \ -__attribute__((always_inline)) \ -static __inline t __##f (void) { \ - return _##f(f); \ -} +#define SVC_0_1(f, t, ...) \ + __svc_indirect(0) t _##f(t (*)()); \ + t f(void); \ + __attribute__((always_inline)) static __inline t __##f(void) { \ + return _##f(f); \ + } -#define SVC_1_1(f,t,t1,...) \ -__svc_indirect(0) t _##f (t(*)(t1),t1); \ - t f (t1 a1); \ -__attribute__((always_inline)) \ -static __inline t __##f (t1 a1) { \ - return _##f(f,a1); \ -} +#define SVC_1_1(f, t, t1, ...) \ + __svc_indirect(0) t _##f(t (*)(t1), t1); \ + t f(t1 a1); \ + __attribute__((always_inline)) static __inline t __##f(t1 a1) { \ + return _##f(f, a1); \ + } -#define SVC_2_1(f,t,t1,t2,...) \ -__svc_indirect(0) t _##f (t(*)(t1,t2),t1,t2); \ - t f (t1 a1, t2 a2); \ -__attribute__((always_inline)) \ -static __inline t __##f (t1 a1, t2 a2) { \ - return _##f(f,a1,a2); \ -} +#define SVC_2_1(f, t, t1, t2, ...) \ + __svc_indirect(0) t _##f(t (*)(t1, t2), t1, t2); \ + t f(t1 a1, t2 a2); \ + __attribute__((always_inline)) static __inline t __##f(t1 a1, t2 a2) { \ + return _##f(f, a1, a2); \ + } -#define SVC_3_1(f,t,t1,t2,t3,...) \ -__svc_indirect(0) t _##f (t(*)(t1,t2,t3),t1,t2,t3); \ - t f (t1 a1, t2 a2, t3 a3); \ -__attribute__((always_inline)) \ -static __inline t __##f (t1 a1, t2 a2, t3 a3) { \ - return _##f(f,a1,a2,a3); \ -} +#define SVC_3_1(f, t, t1, t2, t3, ...) \ + __svc_indirect(0) t _##f(t (*)(t1, t2, t3), t1, t2, t3); \ + t f(t1 a1, t2 a2, t3 a3); \ + __attribute__((always_inline)) static __inline t __##f(t1 a1, t2 a2, \ + t3 a3) { \ + return _##f(f, a1, a2, a3); \ + } -#define SVC_4_1(f,t,t1,t2,t3,t4,...) \ -__svc_indirect(0) t _##f (t(*)(t1,t2,t3,t4),t1,t2,t3,t4); \ - t f (t1 a1, t2 a2, t3 a3, t4 a4); \ -__attribute__((always_inline)) \ -static __inline t __##f (t1 a1, t2 a2, t3 a3, t4 a4) { \ - return _##f(f,a1,a2,a3,a4); \ -} +#define SVC_4_1(f, t, t1, t2, t3, t4, ...) \ + __svc_indirect(0) t _##f(t (*)(t1, t2, t3, t4), t1, t2, t3, t4); \ + t f(t1 a1, t2 a2, t3 a3, t4 a4); \ + __attribute__((always_inline)) static __inline t __##f(t1 a1, t2 a2, t3 a3, \ + t4 a4) { \ + return _##f(f, a1, a2, a3, a4); \ + } #define SVC_1_2 SVC_1_1 #define SVC_1_3 SVC_1_1 #define SVC_2_3 SVC_2_1 -#elif defined (__GNUC__) /* GNU Compiler */ +#elif defined(__GNUC__) /* GNU Compiler */ //#define __NO_RETURN __attribute__((noreturn)) -typedef uint32_t __attribute__((vector_size(8))) ret64; +typedef uint32_t __attribute__((vector_size(8))) ret64; typedef uint32_t __attribute__((vector_size(16))) ret128; -#define RET_pointer __r0 -#define RET_int32_t __r0 -#define RET_osStatus __r0 +#define RET_pointer __r0 +#define RET_int32_t __r0 +#define RET_osStatus __r0 #define RET_osPriority __r0 -#define RET_osEvent {(osStatus)__r0, {(uint32_t)__r1}, {(void *)__r2}} -#define RET_osCallback {(void *)__r0, (void *)__r1} +#define RET_osEvent \ + { \ + (osStatus) __r0, {(uint32_t)__r1}, { (void *)__r2 } \ + } +#define RET_osCallback \ + { (void *)__r0, (void *)__r1 } -#define osEvent_type __attribute__((pcs("aapcs"))) ret128 -#define osEvent_ret_status (ret128){ret.status} -#define osEvent_ret_value (ret128){ret.status, ret.value.v} -#define osEvent_ret_msg (ret128){ret.status, ret.value.v, (uint32_t)ret.def.message_id} -#define osEvent_ret_mail (ret128){ret.status, ret.value.v, (uint32_t)ret.def.mail_id} +#define osEvent_type __attribute__((pcs("aapcs"))) ret128 +#define osEvent_ret_status \ + (ret128) { ret.status } +#define osEvent_ret_value \ + (ret128) { ret.status, ret.value.v } +#define osEvent_ret_msg \ + (ret128) { ret.status, ret.value.v, (uint32_t)ret.def.message_id } +#define osEvent_ret_mail \ + (ret128) { ret.status, ret.value.v, (uint32_t)ret.def.mail_id } -#define osCallback_type __attribute__((pcs("aapcs"))) ret64 -#define osCallback_ret (ret64) {(uint32_t)ret.fp, (uint32_t)ret.arg} +#define osCallback_type __attribute__((pcs("aapcs"))) ret64 +#define osCallback_ret \ + (ret64) { (uint32_t) ret.fp, (uint32_t)ret.arg } -#define SVC_ArgN(n) \ - register int __r##n __asm("r"#n); +#define SVC_ArgN(n) register int __r##n __asm("r" #n); -#define SVC_ArgR(n,t,a) \ - register t __r##n __asm("r"#n) = a; +#define SVC_ArgR(n, t, a) register t __r##n __asm("r" #n) = a; -#define SVC_Arg0() \ - SVC_ArgN(0) \ - SVC_ArgN(1) \ - SVC_ArgN(2) \ - SVC_ArgN(3) +#define SVC_Arg0() SVC_ArgN(0) SVC_ArgN(1) SVC_ArgN(2) SVC_ArgN(3) -#define SVC_Arg1(t1) \ - SVC_ArgR(0,t1,a1) \ - SVC_ArgN(1) \ - SVC_ArgN(2) \ - SVC_ArgN(3) +#define SVC_Arg1(t1) SVC_ArgR(0, t1, a1) SVC_ArgN(1) SVC_ArgN(2) SVC_ArgN(3) -#define SVC_Arg2(t1,t2) \ - SVC_ArgR(0,t1,a1) \ - SVC_ArgR(1,t2,a2) \ - SVC_ArgN(2) \ - SVC_ArgN(3) +#define SVC_Arg2(t1, t2) \ + SVC_ArgR(0, t1, a1) SVC_ArgR(1, t2, a2) SVC_ArgN(2) SVC_ArgN(3) -#define SVC_Arg3(t1,t2,t3) \ - SVC_ArgR(0,t1,a1) \ - SVC_ArgR(1,t2,a2) \ - SVC_ArgR(2,t3,a3) \ - SVC_ArgN(3) +#define SVC_Arg3(t1, t2, t3) \ + SVC_ArgR(0, t1, a1) SVC_ArgR(1, t2, a2) SVC_ArgR(2, t3, a3) SVC_ArgN(3) -#define SVC_Arg4(t1,t2,t3,t4) \ - SVC_ArgR(0,t1,a1) \ - SVC_ArgR(1,t2,a2) \ - SVC_ArgR(2,t3,a3) \ - SVC_ArgR(3,t4,a4) +#define SVC_Arg4(t1, t2, t3, t4) \ + SVC_ArgR(0, t1, a1) SVC_ArgR(1, t2, a2) SVC_ArgR(2, t3, a3) \ + SVC_ArgR(3, t4, a4) -#if (defined (__CORTEX_M0)) || defined (__CORTEX_M0PLUS) +#if (defined(__CORTEX_M0)) || defined(__CORTEX_M0PLUS) #define SVC_Call(f) \ - __asm volatile \ - ( \ - "ldr r7,="#f"\n\t" \ - "mov r12,r7\n\t" \ - "svc 0" \ - : "=r" (__r0), "=r" (__r1), "=r" (__r2), "=r" (__r3) \ - : "r" (__r0), "r" (__r1), "r" (__r2), "r" (__r3) \ - : "r7", "r12", "lr", "cc" \ - ); + __asm volatile("ldr r7,=" #f "\n\t" \ + "mov r12,r7\n\t" \ + "svc 0" \ + : "=r"(__r0), "=r"(__r1), "=r"(__r2), "=r"(__r3) \ + : "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3) \ + : "r7", "r12", "lr", "cc"); #else #define SVC_Call(f) \ - __asm volatile \ - ( \ - "ldr r12,="#f"\n\t" \ - "svc 0" \ - : "=r" (__r0), "=r" (__r1), "=r" (__r2), "=r" (__r3) \ - : "r" (__r0), "r" (__r1), "r" (__r2), "r" (__r3) \ - : "r12", "lr", "cc" \ - ); + __asm volatile("ldr r12,=" #f "\n\t" \ + "svc 0" \ + : "=r"(__r0), "=r"(__r1), "=r"(__r2), "=r"(__r3) \ + : "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3) \ + : "r12", "lr", "cc"); #endif -#define SVC_0_1(f,t,rv) \ -__attribute__((always_inline)) \ -static inline t __##f (void) { \ - SVC_Arg0(); \ - SVC_Call(f); \ - return (t) rv; \ -} +#define SVC_0_1(f, t, rv) \ + __attribute__((always_inline)) static inline t __##f(void) { \ + SVC_Arg0(); \ + SVC_Call(f); \ + return (t)rv; \ + } -#define SVC_1_1(f,t,t1,rv) \ -__attribute__((always_inline)) \ -static inline t __##f (t1 a1) { \ - SVC_Arg1(t1); \ - SVC_Call(f); \ - return (t) rv; \ -} +#define SVC_1_1(f, t, t1, rv) \ + __attribute__((always_inline)) static inline t __##f(t1 a1) { \ + SVC_Arg1(t1); \ + SVC_Call(f); \ + return (t)rv; \ + } -#define SVC_2_1(f,t,t1,t2,rv) \ -__attribute__((always_inline)) \ -static inline t __##f (t1 a1, t2 a2) { \ - SVC_Arg2(t1,t2); \ - SVC_Call(f); \ - return (t) rv; \ -} +#define SVC_2_1(f, t, t1, t2, rv) \ + __attribute__((always_inline)) static inline t __##f(t1 a1, t2 a2) { \ + SVC_Arg2(t1, t2); \ + SVC_Call(f); \ + return (t)rv; \ + } -#define SVC_3_1(f,t,t1,t2,t3,rv) \ -__attribute__((always_inline)) \ -static inline t __##f (t1 a1, t2 a2, t3 a3) { \ - SVC_Arg3(t1,t2,t3); \ - SVC_Call(f); \ - return (t) rv; \ -} +#define SVC_3_1(f, t, t1, t2, t3, rv) \ + __attribute__((always_inline)) static inline t __##f(t1 a1, t2 a2, t3 a3) { \ + SVC_Arg3(t1, t2, t3); \ + SVC_Call(f); \ + return (t)rv; \ + } -#define SVC_4_1(f,t,t1,t2,t3,t4,rv) \ -__attribute__((always_inline)) \ -static inline t __##f (t1 a1, t2 a2, t3 a3, t4 a4) { \ - SVC_Arg4(t1,t2,t3,t4); \ - SVC_Call(f); \ - return (t) rv; \ -} +#define SVC_4_1(f, t, t1, t2, t3, t4, rv) \ + __attribute__((always_inline)) static inline t __##f(t1 a1, t2 a2, t3 a3, \ + t4 a4) { \ + SVC_Arg4(t1, t2, t3, t4); \ + SVC_Call(f); \ + return (t)rv; \ + } #define SVC_1_2 SVC_1_1 #define SVC_1_3 SVC_1_1 #define SVC_2_3 SVC_2_1 -#elif defined (__ICCARM__) /* IAR Compiler */ +#elif defined(__ICCARM__) /* IAR Compiler */ #define __NO_RETURN __noreturn -#define osEvent_type osEvent +#define osEvent_type osEvent #define osEvent_ret_status ret -#define osEvent_ret_value ret -#define osEvent_ret_msg ret -#define osEvent_ret_mail ret +#define osEvent_ret_value ret +#define osEvent_ret_msg ret +#define osEvent_ret_mail ret -#define osCallback_type osCallback -#define osCallback_ret ret +#define osCallback_type osCallback +#define osCallback_ret ret -#define RET_osEvent osEvent -#define RET_osCallback osCallback +#define RET_osEvent osEvent +#define RET_osCallback osCallback -#define SVC_Setup(f) \ - __asm( \ - "mov r12,%0\n" \ - :: "r"(&f): "r12" \ - ); +#define SVC_Setup(f) __asm("mov r12,%0\n" ::"r"(&f) : "r12"); +#define SVC_0_1(f, t, ...) \ + t f(void); \ + _Pragma("swi_number=0") __swi t _##f(void); \ + static inline t __##f(void) { \ + SVC_Setup(f); \ + return _##f(); \ + } -#define SVC_0_1(f,t,...) \ -t f (void); \ -_Pragma("swi_number=0") __swi t _##f (void); \ -static inline t __##f (void) { \ - SVC_Setup(f); \ - return _##f(); \ -} +#define SVC_1_1(f, t, t1, ...) \ + t f(t1 a1); \ + _Pragma("swi_number=0") __swi t _##f(t1 a1); \ + static inline t __##f(t1 a1) { \ + SVC_Setup(f); \ + return _##f(a1); \ + } -#define SVC_1_1(f,t,t1,...) \ -t f (t1 a1); \ -_Pragma("swi_number=0") __swi t _##f (t1 a1); \ -static inline t __##f (t1 a1) { \ - SVC_Setup(f); \ - return _##f(a1); \ -} +#define SVC_2_1(f, t, t1, t2, ...) \ + t f(t1 a1, t2 a2); \ + _Pragma("swi_number=0") __swi t _##f(t1 a1, t2 a2); \ + static inline t __##f(t1 a1, t2 a2) { \ + SVC_Setup(f); \ + return _##f(a1, a2); \ + } -#define SVC_2_1(f,t,t1,t2,...) \ -t f (t1 a1, t2 a2); \ -_Pragma("swi_number=0") __swi t _##f (t1 a1, t2 a2); \ -static inline t __##f (t1 a1, t2 a2) { \ - SVC_Setup(f); \ - return _##f(a1,a2); \ -} +#define SVC_3_1(f, t, t1, t2, t3, ...) \ + t f(t1 a1, t2 a2, t3 a3); \ + _Pragma("swi_number=0") __swi t _##f(t1 a1, t2 a2, t3 a3); \ + static inline t __##f(t1 a1, t2 a2, t3 a3) { \ + SVC_Setup(f); \ + return _##f(a1, a2, a3); \ + } -#define SVC_3_1(f,t,t1,t2,t3,...) \ -t f (t1 a1, t2 a2, t3 a3); \ -_Pragma("swi_number=0") __swi t _##f (t1 a1, t2 a2, t3 a3); \ -static inline t __##f (t1 a1, t2 a2, t3 a3) { \ - SVC_Setup(f); \ - return _##f(a1,a2,a3); \ -} - -#define SVC_4_1(f,t,t1,t2,t3,t4,...) \ -t f (t1 a1, t2 a2, t3 a3, t4 a4); \ -_Pragma("swi_number=0") __swi t _##f (t1 a1, t2 a2, t3 a3, t4 a4); \ -static inline t __##f (t1 a1, t2 a2, t3 a3, t4 a4) { \ - SVC_Setup(f); \ - return _##f(a1,a2,a3,a4); \ -} +#define SVC_4_1(f, t, t1, t2, t3, t4, ...) \ + t f(t1 a1, t2 a2, t3 a3, t4 a4); \ + _Pragma("swi_number=0") __swi t _##f(t1 a1, t2 a2, t3 a3, t4 a4); \ + static inline t __##f(t1 a1, t2 a2, t3 a3, t4 a4) { \ + SVC_Setup(f); \ + return _##f(a1, a2, a3, a4); \ + } #define SVC_1_2 SVC_1_1 #define SVC_1_3 SVC_1_1 @@ -331,102 +304,111 @@ static inline t __##f (t1 a1, t2 a2, t3 a3, t4 a4) { \ #endif - // Callback structure typedef struct { - void *fp; // Function pointer - void *arg; // Function argument + void *fp; // Function pointer + void *arg; // Function argument } osCallback; - // OS Section definitions #ifdef OS_SECTIONS_LINK_INFO -extern const uint32_t os_section_id$$Base; -extern const uint32_t os_section_id$$Limit; +extern const uint32_t os_section_id$$Base; +extern const uint32_t os_section_id$$Limit; #endif // OS Timers external resources -extern osThreadDef_t os_thread_def_osTimerThread; -extern osThreadId osThreadId_osTimerThread; +extern osThreadDef_t os_thread_def_osTimerThread; +extern osThreadId osThreadId_osTimerThread; extern osMessageQDef_t os_messageQ_def_osTimerMessageQ; -extern osMessageQId osMessageQId_osTimerMessageQ; - +extern osMessageQId osMessageQId_osTimerMessageQ; // ==== Helper Functions ==== /// Convert timeout in millisec to system ticks -static uint32_t rt_ms2tick (uint32_t millisec) { +static uint32_t rt_ms2tick(uint32_t millisec) { uint32_t tick; - if (millisec == osWaitForever) return 0xFFFF; // Indefinite timeout - if (millisec > 4000000) return 0xFFFE; // Max ticks supported + if (millisec == osWaitForever) + return 0xFFFF; // Indefinite timeout + if (millisec > 4000000) + return 0xFFFE; // Max ticks supported - tick = ((1000 * millisec) + os_clockrate - 1) / os_clockrate; - if (tick > 0xFFFE) return 0xFFFE; + tick = ((1000 * millisec) + os_clockrate - 1) / os_clockrate; + if (tick > 0xFFFE) + return 0xFFFE; return tick; } /// Convert Thread ID to TCB pointer -static P_TCB rt_tid2ptcb (osThreadId thread_id) { +static P_TCB rt_tid2ptcb(osThreadId thread_id) { P_TCB ptcb; - if (thread_id == NULL) return NULL; + if (thread_id == NULL) + return NULL; - if ((uint32_t)thread_id & 3) return NULL; + if ((uint32_t)thread_id & 3) + return NULL; #ifdef OS_SECTIONS_LINK_INFO if ((os_section_id$$Base != 0) && (os_section_id$$Limit != 0)) { - if (thread_id < (osThreadId)os_section_id$$Base) return NULL; - if (thread_id >= (osThreadId)os_section_id$$Limit) return NULL; + if (thread_id < (osThreadId)os_section_id$$Base) + return NULL; + if (thread_id >= (osThreadId)os_section_id$$Limit) + return NULL; } #endif ptcb = thread_id; - if (ptcb->cb_type != TCB) return NULL; + if (ptcb->cb_type != TCB) + return NULL; return ptcb; } /// Convert ID pointer to Object pointer -static void *rt_id2obj (void *id) { +static void *rt_id2obj(void *id) { - if ((uint32_t)id & 3) return NULL; + if ((uint32_t)id & 3) + return NULL; #ifdef OS_SECTIONS_LINK_INFO if ((os_section_id$$Base != 0) && (os_section_id$$Limit != 0)) { - if (id < (void *)os_section_id$$Base) return NULL; - if (id >= (void *)os_section_id$$Limit) return NULL; + if (id < (void *)os_section_id$$Base) + return NULL; + if (id >= (void *)os_section_id$$Limit) + return NULL; } #endif return id; } - // ==== Kernel Control ==== -uint8_t os_initialized; // Kernel Initialized flag -uint8_t os_running; // Kernel Running flag +uint8_t os_initialized; // Kernel Initialized flag +uint8_t os_running; // Kernel Running flag // Kernel Control Service Calls declarations SVC_0_1(svcKernelInitialize, osStatus, RET_osStatus) -SVC_0_1(svcKernelStart, osStatus, RET_osStatus) -SVC_0_1(svcKernelRunning, int32_t, RET_int32_t) +SVC_0_1(svcKernelStart, osStatus, RET_osStatus) +SVC_0_1(svcKernelRunning, int32_t, RET_int32_t) -extern void sysThreadError (osStatus status); -osThreadId svcThreadCreate (osThreadDef_t *thread_def, void *argument); -osMessageQId svcMessageCreate (const osMessageQDef_t *queue_def, osThreadId thread_id); +extern void sysThreadError(osStatus status); +osThreadId svcThreadCreate(osThreadDef_t *thread_def, void *argument); +osMessageQId svcMessageCreate(const osMessageQDef_t *queue_def, + osThreadId thread_id); // Kernel Control Service Calls /// Initialize the RTOS Kernel for creating objects -osStatus svcKernelInitialize (void) { - if (os_initialized) return osOK; +osStatus svcKernelInitialize(void) { + if (os_initialized) + return osOK; - rt_sys_init(); // RTX System Initialization - os_tsk.run->prio = 255; // Highest priority + rt_sys_init(); // RTX System Initialization + os_tsk.run->prio = 255; // Highest priority sysThreadError(osOK); @@ -436,20 +418,23 @@ osStatus svcKernelInitialize (void) { } /// Start the RTOS Kernel -osStatus svcKernelStart (void) { +osStatus svcKernelStart(void) { - if (os_running) return osOK; + if (os_running) + return osOK; // Create OS Timers resources (Message Queue & Thread) - osMessageQId_osTimerMessageQ = svcMessageCreate (&os_messageQ_def_osTimerMessageQ, NULL); - osThreadId_osTimerThread = svcThreadCreate(&os_thread_def_osTimerThread, NULL); + osMessageQId_osTimerMessageQ = + svcMessageCreate(&os_messageQ_def_osTimerMessageQ, NULL); + osThreadId_osTimerThread = + svcThreadCreate(&os_thread_def_osTimerThread, NULL); - rt_tsk_prio(0, 0); // Lowest priority + rt_tsk_prio(0, 0); // Lowest priority #ifdef __ARM_ARCH_8M_MAIN__ __set_PSPLIM((uint32_t)os_tsk.run->stack); #endif - __set_PSP(os_tsk.run->tsk_stack + 8*4); // New context - os_tsk.run = NULL; // Force context switch + __set_PSP(os_tsk.run->tsk_stack + 8 * 4); // New context + os_tsk.run = NULL; // Force context switch rt_sys_start(); @@ -459,53 +444,54 @@ osStatus svcKernelStart (void) { } /// Check if the RTOS kernel is already started -int32_t svcKernelRunning(void) { - return os_running; -} +int32_t svcKernelRunning(void) { return os_running; } // Kernel Control Public API /// Initialize the RTOS Kernel for creating objects -osStatus osKernelInitialize (void) { - if (__get_IPSR() != 0) return osErrorISR; // Not allowed in ISR - if ((__get_CONTROL() & 1) == 0) { // Privileged mode - return svcKernelInitialize(); +osStatus osKernelInitialize(void) { + if (__get_IPSR() != 0) + return osErrorISR; // Not allowed in ISR + if ((__get_CONTROL() & 1) == 0) { // Privileged mode + return svcKernelInitialize(); } else { return __svcKernelInitialize(); } } /// Start the RTOS Kernel -osStatus osKernelStart (void) { +osStatus osKernelStart(void) { uint32_t stack[8]; - if (__get_IPSR() != 0) return osErrorISR; // Not allowed in ISR + if (__get_IPSR() != 0) + return osErrorISR; // Not allowed in ISR switch (__get_CONTROL() & 0x03) { - case 0x00: // Privileged Thread mode & MSP + case 0x00: // Privileged Thread mode & MSP #ifdef __ARM_ARCH_8M_MAIN__ - __set_PSPLIM(__get_MSPLIM()); + __set_PSPLIM(__get_MSPLIM()); #endif - __set_PSP((uint32_t)(stack + 8)); // Initial PSP - if (os_flags & 1) { - __set_CONTROL(0x02); // Set Privileged Thread mode & PSP - } else { - __set_CONTROL(0x03); // Set Unprivileged Thread mode & PSP - } + __set_PSP((uint32_t)(stack + 8)); // Initial PSP + if (os_flags & 1) { + __set_CONTROL(0x02); // Set Privileged Thread mode & PSP + } else { + __set_CONTROL(0x03); // Set Unprivileged Thread mode & PSP + } + __DSB(); + __ISB(); + break; + case 0x01: // Unprivileged Thread mode & MSP + return osErrorOS; + case 0x02: // Privileged Thread mode & PSP + if ((os_flags & 1) == 0) { // Unprivileged Thread mode requested + __set_CONTROL(0x03); // Set Unprivileged Thread mode & PSP __DSB(); __ISB(); - break; - case 0x01: // Unprivileged Thread mode & MSP - return osErrorOS; - case 0x02: // Privileged Thread mode & PSP - if ((os_flags & 1) == 0) { // Unprivileged Thread mode requested - __set_CONTROL(0x03); // Set Unprivileged Thread mode & PSP - __DSB(); - __ISB(); - } - break; - case 0x03: // Unprivileged Thread mode & PSP - if (os_flags & 1) return osErrorOS; // Privileged Thread mode requested - break; + } + break; + case 0x03: // Unprivileged Thread mode & PSP + if (os_flags & 1) + return osErrorOS; // Privileged Thread mode requested + break; } return __svcKernelStart(); } @@ -520,35 +506,33 @@ int32_t osKernelRunning(void) { } } - // ==== Thread Management ==== -__NO_RETURN void osThreadExit (void); +__NO_RETURN void osThreadExit(void); // Thread Service Calls declarations -SVC_2_1(svcThreadCreate, osThreadId, osThreadDef_t *, void *, RET_pointer) -SVC_0_1(svcThreadGetId, osThreadId, RET_pointer) -SVC_1_1(svcThreadTerminate, osStatus, osThreadId, RET_osStatus) -SVC_0_1(svcThreadYield, osStatus, RET_osStatus) -SVC_2_1(svcThreadSetPriority, osStatus, osThreadId, osPriority, RET_osStatus) -SVC_1_1(svcThreadGetPriority, osPriority, osThreadId, RET_osPriority) -SVC_1_1(svcThreadShow, osStatus, osThreadId, RET_osStatus) -SVC_3_1(svcThreadSetHungCheck,osStatus, osThreadId, int32_t, uint32_t, RET_osStatus) +SVC_2_1(svcThreadCreate, osThreadId, osThreadDef_t *, void *, RET_pointer) +SVC_0_1(svcThreadGetId, osThreadId, RET_pointer) +SVC_1_1(svcThreadTerminate, osStatus, osThreadId, RET_osStatus) +SVC_0_1(svcThreadYield, osStatus, RET_osStatus) +SVC_2_1(svcThreadSetPriority, osStatus, osThreadId, osPriority, RET_osStatus) +SVC_1_1(svcThreadGetPriority, osPriority, osThreadId, RET_osPriority) +SVC_1_1(svcThreadShow, osStatus, osThreadId, RET_osStatus) +SVC_3_1(svcThreadSetHungCheck, osStatus, osThreadId, int32_t, uint32_t, + RET_osStatus) // Thread Service Calls -extern OS_TID rt_get_TID (void); -extern void rt_init_context (P_TCB p_TCB, U8 priority, FUNCP task_body); +extern OS_TID rt_get_TID(void); +extern void rt_init_context(P_TCB p_TCB, U8 priority, FUNCP task_body); /// Create a thread and add it to Active Threads and set it to state READY -osThreadId svcThreadCreate (osThreadDef_t *thread_def, void *argument) { - P_TCB ptcb; +osThreadId svcThreadCreate(osThreadDef_t *thread_def, void *argument) { + P_TCB ptcb; - if ((thread_def == NULL) || - (thread_def->pthread == NULL) || + if ((thread_def == NULL) || (thread_def->pthread == NULL) || (thread_def->tpriority < osPriorityIdle) || (thread_def->tpriority > osPriorityRealtime) || - (thread_def->stacksize == 0) || - (thread_def->stack_pointer == NULL) ) { + (thread_def->stacksize == 0) || (thread_def->stack_pointer == NULL)) { sysThreadError(osErrorParameter); return NULL; } @@ -557,29 +541,29 @@ osThreadId svcThreadCreate (osThreadDef_t *thread_def, void *argument) { P_TCB task_context = &thread_def->tcb; /* Utilize the user provided stack. */ - task_context->stack = (U32*)thread_def->stack_pointer; + task_context->stack = (U32 *)thread_def->stack_pointer; task_context->priv_stack = thread_def->stacksize; /* Find a free entry in 'os_active_TCB' table. */ - OS_TID tsk = rt_get_TID (); + OS_TID tsk = rt_get_TID(); if (tsk == 0) { sysThreadError(osErrorResource); return NULL; } - os_active_TCB[tsk-1] = task_context; + os_active_TCB[tsk - 1] = task_context; task_context->task_id = tsk; /* Pass parameter 'argv' to 'rt_init_context' */ - task_context->msg = argument; + task_context->msg = argument; #if __RTX_CPU_STATISTICS__ task_context->name = (U8 *)thread_def->name_str; #endif /* Initialize thread context structure, including the thread's stack. */ - rt_init_context (task_context, priority, (FUNCP)thread_def->pthread); + rt_init_context(task_context, priority, (FUNCP)thread_def->pthread); /* Dispatch this task to the scheduler for execution. */ DBG_TASK_NOTIFY(task_context, __TRUE); - rt_dispatch (task_context); + rt_dispatch(task_context); - ptcb = (P_TCB)os_active_TCB[tsk - 1]; // TCB pointer + ptcb = (P_TCB)os_active_TCB[tsk - 1]; // TCB pointer *((uint32_t *)ptcb->tsk_stack + 13) = (uint32_t)osThreadExit; @@ -587,168 +571,183 @@ osThreadId svcThreadCreate (osThreadDef_t *thread_def, void *argument) { } /// Return the thread ID of the current running thread -osThreadId svcThreadGetId (void) { +osThreadId svcThreadGetId(void) { OS_TID tsk; tsk = rt_tsk_self(); - if (tsk == 0) return NULL; + if (tsk == 0) + return NULL; return (P_TCB)os_active_TCB[tsk - 1]; } /// Terminate execution of a thread and remove it from ActiveThreads -osStatus svcThreadTerminate (osThreadId thread_id) { +osStatus svcThreadTerminate(osThreadId thread_id) { OS_RESULT res; - P_TCB ptcb; + P_TCB ptcb; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return osErrorParameter; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return osErrorParameter; - res = rt_tsk_delete(ptcb->task_id); // Delete task + res = rt_tsk_delete(ptcb->task_id); // Delete task - if (res == OS_R_NOK) return osErrorResource; // Delete task failed + if (res == OS_R_NOK) + return osErrorResource; // Delete task failed return osOK; } /// Pass control to next thread that is in state READY -osStatus svcThreadYield (void) { - rt_tsk_pass(); // Pass control to next task +osStatus svcThreadYield(void) { + rt_tsk_pass(); // Pass control to next task return osOK; } /// Change priority of an active thread -osStatus svcThreadSetPriority (osThreadId thread_id, osPriority priority) { +osStatus svcThreadSetPriority(osThreadId thread_id, osPriority priority) { OS_RESULT res; - P_TCB ptcb; + P_TCB ptcb; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return osErrorParameter; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return osErrorParameter; if ((priority < osPriorityIdle) || (priority > osPriorityRealtime)) { return osErrorValue; } - res = rt_tsk_prio( // Change task priority - ptcb->task_id, // Task ID - priority - osPriorityIdle + 1 // New task priority + res = rt_tsk_prio( // Change task priority + ptcb->task_id, // Task ID + priority - osPriorityIdle + 1 // New task priority ); - if (res == OS_R_NOK) return osErrorResource; // Change task priority failed + if (res == OS_R_NOK) + return osErrorResource; // Change task priority failed return osOK; } /// Get current priority of an active thread -osPriority svcThreadGetPriority (osThreadId thread_id) { +osPriority svcThreadGetPriority(osThreadId thread_id) { P_TCB ptcb; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return osPriorityError; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return osPriorityError; return (osPriority)(ptcb->prio - 1 + osPriorityIdle); } /// Show a thread -osStatus svcThreadShow (osThreadId thread_id) { - P_TCB ptcb; +osStatus svcThreadShow(osThreadId thread_id) { + P_TCB ptcb; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return osErrorParameter; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return osErrorParameter; rt_tsk_show(ptcb); return osOK; } - // Thread Public API /// Create a thread and add it to Active Threads and set it to state READY -osThreadId osThreadCreate (osThreadDef_t *thread_def, void *argument) { - if (__get_IPSR() != 0) return NULL; // Not allowed in ISR +osThreadId osThreadCreate(osThreadDef_t *thread_def, void *argument) { + if (__get_IPSR() != 0) + return NULL; // Not allowed in ISR if (((__get_CONTROL() & 1) == 0) && (os_running == 0)) { // Privileged and not running - return svcThreadCreate(thread_def, argument); + return svcThreadCreate(thread_def, argument); } else { return __svcThreadCreate(thread_def, argument); } } /// Return the thread ID of the current running thread -osThreadId osThreadGetId (void) { - if (__get_IPSR() != 0) return NULL; // Not allowed in ISR +osThreadId osThreadGetId(void) { + if (__get_IPSR() != 0) + return NULL; // Not allowed in ISR return __svcThreadGetId(); } -int osGetThreadIntId (void) { - OS_TID tid; - uint32_t lock; +int osGetThreadIntId(void) { + OS_TID tid; + uint32_t lock; - if (__get_IPSR() != 0) return 0; - lock = int_lock(); - tid = rt_tsk_self(); - int_unlock(lock); - return tid; + if (__get_IPSR() != 0) + return 0; + lock = int_lock(); + tid = rt_tsk_self(); + int_unlock(lock); + return tid; } /// Terminate execution of a thread and remove it from ActiveThreads -osStatus osThreadTerminate (osThreadId thread_id) { - if (__get_IPSR() != 0) return osErrorISR; // Not allowed in ISR +osStatus osThreadTerminate(osThreadId thread_id) { + if (__get_IPSR() != 0) + return osErrorISR; // Not allowed in ISR return __svcThreadTerminate(thread_id); } /// Pass control to next thread that is in state READY -osStatus osThreadYield (void) { - if (__get_IPSR() != 0) return osErrorISR; // Not allowed in ISR +osStatus osThreadYield(void) { + if (__get_IPSR() != 0) + return osErrorISR; // Not allowed in ISR return __svcThreadYield(); } /// Change priority of an active thread -osStatus osThreadSetPriority (osThreadId thread_id, osPriority priority) { - if (__get_IPSR() != 0) return osErrorISR; // Not allowed in ISR +osStatus osThreadSetPriority(osThreadId thread_id, osPriority priority) { + if (__get_IPSR() != 0) + return osErrorISR; // Not allowed in ISR return __svcThreadSetPriority(thread_id, priority); } /// Get current priority of an active thread -osPriority osThreadGetPriority (osThreadId thread_id) { - if (__get_IPSR() != 0) return osPriorityError;// Not allowed in ISR +osPriority osThreadGetPriority(osThreadId thread_id) { + if (__get_IPSR() != 0) + return osPriorityError; // Not allowed in ISR return __svcThreadGetPriority(thread_id); } /// Dump a thread -osStatus osThreadShow (osThreadId thread_id) { - if (__get_IPSR() != 0) return osPriorityError;// Not allowed in ISR +osStatus osThreadShow(osThreadId thread_id) { + if (__get_IPSR() != 0) + return osPriorityError; // Not allowed in ISR return __svcThreadShow(thread_id); } /// INTERNAL - Not Public /// Auto Terminate Thread on exit (used implicitly when thread exists) -__NO_RETURN void osThreadExit (void) { +__NO_RETURN void osThreadExit(void) { __svcThreadTerminate(__svcThreadGetId()); - for (;;); // Should never come here + for (;;) + ; // Should never come here } - // ==== Generic Wait Functions ==== // Generic Wait Service Calls declarations -SVC_1_1(svcDelay, osStatus, uint32_t, RET_osStatus) +SVC_1_1(svcDelay, osStatus, uint32_t, RET_osStatus) #if osFeature_Wait != 0 -SVC_1_3(svcWait, os_InRegs osEvent, uint32_t, RET_osEvent) +SVC_1_3(svcWait, os_InRegs osEvent, uint32_t, RET_osEvent) #endif // Generic Wait Service Calls /// Wait for Timeout (Time Delay) -osStatus svcDelay (uint32_t millisec) { - if (millisec == 0) return osOK; +osStatus svcDelay(uint32_t millisec) { + if (millisec == 0) + return osOK; rt_dly_wait(rt_ms2tick(millisec)); return osEventTimeout; } /// Wait for Signal, Message, Mail, or Timeout #if osFeature_Wait != 0 -os_InRegs osEvent_type svcWait (uint32_t millisec) { +os_InRegs osEvent_type svcWait(uint32_t millisec) { osEvent ret; if (millisec == 0) { @@ -764,24 +763,24 @@ os_InRegs osEvent_type svcWait (uint32_t millisec) { } #endif - // Generic Wait API /// Wait for Timeout (Time Delay) -osStatus osDelay (uint32_t millisec) { - if (__get_IPSR() != 0) return osErrorISR; // Not allowed in ISR +osStatus osDelay(uint32_t millisec) { + if (__get_IPSR() != 0) + return osErrorISR; // Not allowed in ISR return __svcDelay(millisec); } /// Wait for Signal, Message, Mail, or Timeout -os_InRegs osEvent osWait (uint32_t millisec) { +os_InRegs osEvent osWait(uint32_t millisec) { osEvent ret; #if osFeature_Wait == 0 ret.status = osErrorOS; return ret; #else - if (__get_IPSR() != 0) { // Not allowed in ISR + if (__get_IPSR() != 0) { // Not allowed in ISR ret.status = osErrorISR; return ret; } @@ -789,41 +788,40 @@ os_InRegs osEvent osWait (uint32_t millisec) { #endif } - // ==== Timer Management ==== // Timer definitions -#define osTimerInvalid 0 -#define osTimerStopped 1 -#define osTimerRunning 2 +#define osTimerInvalid 0 +#define osTimerStopped 1 +#define osTimerRunning 2 // Timer structures -typedef struct os_timer_cb_ { // Timer Control Block - struct os_timer_cb_ *next; // Pointer to next active Timer - uint8_t state; // Timer State - uint8_t type; // Timer Type (Periodic/One-shot) - uint16_t reserved; // Reserved - uint16_t tcnt; // Timer Delay Count - uint16_t icnt; // Timer Initial Count - void *arg; // Timer Function Argument - const osTimerDef_t *timer; // Pointer to Timer definition +typedef struct os_timer_cb_ { // Timer Control Block + struct os_timer_cb_ *next; // Pointer to next active Timer + uint8_t state; // Timer State + uint8_t type; // Timer Type (Periodic/One-shot) + uint16_t reserved; // Reserved + uint16_t tcnt; // Timer Delay Count + uint16_t icnt; // Timer Initial Count + void *arg; // Timer Function Argument + const osTimerDef_t *timer; // Pointer to Timer definition } os_timer_cb; // Timer variables -os_timer_cb *os_timer_head; // Pointer to first active Timer - +os_timer_cb *os_timer_head; // Pointer to first active Timer // Timer Helper Functions // Insert Timer into the list sorted by time -static void rt_timer_insert (os_timer_cb *pt, uint32_t tcnt) { +static void rt_timer_insert(os_timer_cb *pt, uint32_t tcnt) { os_timer_cb *p, *prev; prev = NULL; p = os_timer_head; while (p != NULL) { - if (tcnt < p->tcnt) break; + if (tcnt < p->tcnt) + break; tcnt -= p->tcnt; prev = p; p = p->next; @@ -841,17 +839,19 @@ static void rt_timer_insert (os_timer_cb *pt, uint32_t tcnt) { } // Remove Timer from the list -static int32_t rt_timer_remove (os_timer_cb *pt) { +static int32_t rt_timer_remove(os_timer_cb *pt) { os_timer_cb *p, *prev; prev = NULL; p = os_timer_head; while (p != NULL) { - if (p == pt) break; + if (p == pt) + break; prev = p; p = p->next; } - if (p == NULL) return -1; + if (p == NULL) + return -1; if (prev != NULL) { prev->next = pt->next; } else { @@ -864,18 +864,19 @@ static int32_t rt_timer_remove (os_timer_cb *pt) { return 0; } - // Timer Service Calls declarations -SVC_3_1(svcTimerCreate, osTimerId, const osTimerDef_t *, os_timer_type, void *, RET_pointer) -SVC_2_1(svcTimerStart, osStatus, osTimerId, uint32_t, RET_osStatus) -SVC_1_1(svcTimerStop, osStatus, osTimerId, RET_osStatus) -SVC_1_1(svcTimerDelete, osStatus, osTimerId, RET_osStatus) -SVC_1_2(svcTimerCall, os_InRegs osCallback, osTimerId, RET_osCallback) +SVC_3_1(svcTimerCreate, osTimerId, const osTimerDef_t *, os_timer_type, void *, + RET_pointer) +SVC_2_1(svcTimerStart, osStatus, osTimerId, uint32_t, RET_osStatus) +SVC_1_1(svcTimerStop, osStatus, osTimerId, RET_osStatus) +SVC_1_1(svcTimerDelete, osStatus, osTimerId, RET_osStatus) +SVC_1_2(svcTimerCall, os_InRegs osCallback, osTimerId, RET_osCallback) // Timer Management Service Calls /// Create timer -osTimerId svcTimerCreate (const osTimerDef_t *timer_def, os_timer_type type, void *argument) { +osTimerId svcTimerCreate(const osTimerDef_t *timer_def, os_timer_type type, + void *argument) { os_timer_cb *pt; if ((timer_def == NULL) || (timer_def->ptimer == NULL)) { @@ -899,43 +900,45 @@ osTimerId svcTimerCreate (const osTimerDef_t *timer_def, os_timer_type type, voi return NULL; } - if (pt->state != osTimerInvalid){ + if (pt->state != osTimerInvalid) { sysThreadError(osErrorResource); return NULL; } - pt->next = NULL; + pt->next = NULL; pt->state = osTimerStopped; - pt->type = (uint8_t)type; - pt->arg = argument; + pt->type = (uint8_t)type; + pt->arg = argument; pt->timer = timer_def; return (osTimerId)pt; } /// Start or restart timer -osStatus svcTimerStart (osTimerId timer_id, uint32_t millisec) { +osStatus svcTimerStart(osTimerId timer_id, uint32_t millisec) { os_timer_cb *pt; - uint32_t tcnt; + uint32_t tcnt; pt = rt_id2obj(timer_id); - if (pt == NULL) return osErrorParameter; + if (pt == NULL) + return osErrorParameter; tcnt = rt_ms2tick(millisec); - if (tcnt == 0) return osErrorValue; + if (tcnt == 0) + return osErrorValue; switch (pt->state) { - case osTimerRunning: - if (rt_timer_remove(pt) != 0) { - return osErrorResource; - } - break; - case osTimerStopped: - pt->state = osTimerRunning; - pt->icnt = (uint16_t)tcnt; - break; - default: + case osTimerRunning: + if (rt_timer_remove(pt) != 0) { return osErrorResource; + } + break; + case osTimerStopped: + pt->state = osTimerRunning; + pt->icnt = (uint16_t)tcnt; + break; + default: + return osErrorResource; } rt_timer_insert(pt, tcnt); @@ -944,13 +947,15 @@ osStatus svcTimerStart (osTimerId timer_id, uint32_t millisec) { } /// Stop timer -osStatus svcTimerStop (osTimerId timer_id) { +osStatus svcTimerStop(osTimerId timer_id) { os_timer_cb *pt; pt = rt_id2obj(timer_id); - if (pt == NULL) return osErrorParameter; + if (pt == NULL) + return osErrorParameter; - if (pt->state != osTimerRunning) return osErrorResource; + if (pt->state != osTimerRunning) + return osErrorResource; pt->state = osTimerStopped; @@ -962,20 +967,21 @@ osStatus svcTimerStop (osTimerId timer_id) { } /// Delete timer -osStatus svcTimerDelete (osTimerId timer_id) { +osStatus svcTimerDelete(osTimerId timer_id) { os_timer_cb *pt; pt = rt_id2obj(timer_id); - if (pt == NULL) return osErrorParameter; + if (pt == NULL) + return osErrorParameter; switch (pt->state) { - case osTimerRunning: - rt_timer_remove(pt); - break; - case osTimerStopped: - break; - default: - return osErrorResource; + case osTimerRunning: + rt_timer_remove(pt); + break; + case osTimerStopped: + break; + default: + return osErrorResource; } pt->state = osTimerInvalid; @@ -984,32 +990,34 @@ osStatus svcTimerDelete (osTimerId timer_id) { } /// Get timer callback parameters -os_InRegs osCallback_type svcTimerCall (osTimerId timer_id) { +os_InRegs osCallback_type svcTimerCall(osTimerId timer_id) { os_timer_cb *pt; - osCallback ret; + osCallback ret; pt = rt_id2obj(timer_id); if (pt == NULL) { - ret.fp = NULL; + ret.fp = NULL; ret.arg = NULL; return osCallback_ret; } - ret.fp = (void *)pt->timer->ptimer; + ret.fp = (void *)pt->timer->ptimer; ret.arg = pt->arg; return osCallback_ret; } -static __INLINE osStatus isrMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec); +static __INLINE osStatus isrMessagePut(osMessageQId queue_id, uint32_t info, + uint32_t millisec); /// Timer Tick (called each SysTick) -void sysTimerTick (void) { +void sysTimerTick(void) { os_timer_cb *pt, *p; - osStatus status; + osStatus status; p = os_timer_head; - if (p == NULL) return; + if (p == NULL) + return; p->tcnt--; while ((p != NULL) && (p->tcnt == 0)) { @@ -1028,56 +1036,59 @@ void sysTimerTick (void) { } } -uint32_t rt_timer_delay_count(void) -{ - if (os_timer_head) { - return os_timer_head->tcnt; - } - return 0; +uint32_t rt_timer_delay_count(void) { + if (os_timer_head) { + return os_timer_head->tcnt; + } + return 0; } // Timer Management Public API /// Create timer -osTimerId osTimerCreate (const osTimerDef_t *timer_def, os_timer_type type, void *argument) { - if (__get_IPSR() != 0) return NULL; // Not allowed in ISR +osTimerId osTimerCreate(const osTimerDef_t *timer_def, os_timer_type type, + void *argument) { + if (__get_IPSR() != 0) + return NULL; // Not allowed in ISR if (((__get_CONTROL() & 1) == 0) && (os_running == 0)) { // Privileged and not running - return svcTimerCreate(timer_def, type, argument); + return svcTimerCreate(timer_def, type, argument); } else { return __svcTimerCreate(timer_def, type, argument); } } /// Start or restart timer -osStatus osTimerStart (osTimerId timer_id, uint32_t millisec) { - if (__get_IPSR() != 0) return osErrorISR; // Not allowed in ISR +osStatus osTimerStart(osTimerId timer_id, uint32_t millisec) { + if (__get_IPSR() != 0) + return osErrorISR; // Not allowed in ISR return __svcTimerStart(timer_id, millisec); } /// Stop timer -osStatus osTimerStop (osTimerId timer_id) { - if (__get_IPSR() != 0) return osErrorISR; // Not allowed in ISR +osStatus osTimerStop(osTimerId timer_id) { + if (__get_IPSR() != 0) + return osErrorISR; // Not allowed in ISR return __svcTimerStop(timer_id); } /// Delete timer -osStatus osTimerDelete (osTimerId timer_id) { - if (__get_IPSR() != 0) return osErrorISR; // Not allowed in ISR +osStatus osTimerDelete(osTimerId timer_id) { + if (__get_IPSR() != 0) + return osErrorISR; // Not allowed in ISR return __svcTimerDelete(timer_id); } /// INTERNAL - Not Public /// Get timer callback parameters (used by OS Timer Thread) -os_InRegs osCallback osTimerCall (osTimerId timer_id) { +os_InRegs osCallback osTimerCall(osTimerId timer_id) { return __svcTimerCall(timer_id); } - // Timer Thread -__NO_RETURN void osTimerThread (void const *argument) { +__NO_RETURN void osTimerThread(void const *argument) { osCallback cb; - osEvent evt; + osEvent evt; for (;;) { evt = osMessageGet(osMessageQId_osTimerMessageQ, osWaitForever); @@ -1090,75 +1101,80 @@ __NO_RETURN void osTimerThread (void const *argument) { } } - // ==== Signal Management ==== // Signal Service Calls declarations -SVC_2_1(svcSignalSet, int32_t, osThreadId, int32_t, RET_int32_t) -SVC_2_1(svcSignalClear, int32_t, osThreadId, int32_t, RET_int32_t) -SVC_1_1(svcSignalGet, int32_t, osThreadId, RET_int32_t) -SVC_2_3(svcSignalWait, os_InRegs osEvent, int32_t, uint32_t, RET_osEvent) +SVC_2_1(svcSignalSet, int32_t, osThreadId, int32_t, RET_int32_t) +SVC_2_1(svcSignalClear, int32_t, osThreadId, int32_t, RET_int32_t) +SVC_1_1(svcSignalGet, int32_t, osThreadId, RET_int32_t) +SVC_2_3(svcSignalWait, os_InRegs osEvent, int32_t, uint32_t, RET_osEvent) // Signal Service Calls /// Set the specified Signal Flags of an active thread -int32_t svcSignalSet (osThreadId thread_id, int32_t signals) { - P_TCB ptcb; +int32_t svcSignalSet(osThreadId thread_id, int32_t signals) { + P_TCB ptcb; int32_t sig; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return 0x80000000; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return 0x80000000; - if (signals & (0xFFFFFFFF << osFeature_Signals)) return 0x80000000; + if (signals & (0xFFFFFFFF << osFeature_Signals)) + return 0x80000000; - sig = ptcb->events; // Previous signal flags + sig = ptcb->events; // Previous signal flags - rt_evt_set(signals, ptcb->task_id); // Set event flags + rt_evt_set(signals, ptcb->task_id); // Set event flags return sig; } /// Clear the specified Signal Flags of an active thread -int32_t svcSignalClear (osThreadId thread_id, int32_t signals) { - P_TCB ptcb; +int32_t svcSignalClear(osThreadId thread_id, int32_t signals) { + P_TCB ptcb; int32_t sig; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return 0x80000000; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return 0x80000000; - if (signals & (0xFFFFFFFF << osFeature_Signals)) return 0x80000000; + if (signals & (0xFFFFFFFF << osFeature_Signals)) + return 0x80000000; - sig = ptcb->events; // Previous signal flags + sig = ptcb->events; // Previous signal flags - rt_evt_clr(signals, ptcb->task_id); // Clear event flags + rt_evt_clr(signals, ptcb->task_id); // Clear event flags return sig; } /// Get Signal Flags status of an active thread -int32_t svcSignalGet (osThreadId thread_id) { +int32_t svcSignalGet(osThreadId thread_id) { P_TCB ptcb; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return 0x80000000; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return 0x80000000; - return ptcb->events; // Return event flags + return ptcb->events; // Return event flags } -/// Wait for one or more Signal Flags to become signaled for the current RUNNING thread -os_InRegs osEvent_type svcSignalWait (int32_t signals, uint32_t millisec) { +/// Wait for one or more Signal Flags to become signaled for the current RUNNING +/// thread +os_InRegs osEvent_type svcSignalWait(int32_t signals, uint32_t millisec) { OS_RESULT res; - osEvent ret; + osEvent ret; if (signals & (0xFFFFFFFF << osFeature_Signals)) { ret.status = osErrorValue; return osEvent_ret_status; } - if (signals != 0) { // Wait for all specified signals + if (signals != 0) { // Wait for all specified signals res = rt_evt_wait(signals, rt_ms2tick(millisec), __TRUE); - } else { // Wait for any signal - res = rt_evt_wait(0xFFFF, rt_ms2tick(millisec), __FALSE); + } else { // Wait for any signal + res = rt_evt_wait(0xFFFF, rt_ms2tick(millisec), __FALSE); } if (res == OS_R_EVT) { @@ -1172,75 +1188,77 @@ os_InRegs osEvent_type svcSignalWait (int32_t signals, uint32_t millisec) { return osEvent_ret_value; } - // Signal ISR Calls /// Set the specified Signal Flags of an active thread -static __INLINE int32_t isrSignalSet (osThreadId thread_id, int32_t signals) { - P_TCB ptcb; +static __INLINE int32_t isrSignalSet(osThreadId thread_id, int32_t signals) { + P_TCB ptcb; int32_t sig; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return 0x80000000; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return 0x80000000; - if (signals & (0xFFFFFFFF << osFeature_Signals)) return 0x80000000; + if (signals & (0xFFFFFFFF << osFeature_Signals)) + return 0x80000000; - sig = ptcb->events; // Previous signal flags + sig = ptcb->events; // Previous signal flags - isr_evt_set(signals, ptcb->task_id); // Set event flags + isr_evt_set(signals, ptcb->task_id); // Set event flags return sig; } - // Signal Public API /// Set the specified Signal Flags of an active thread -int32_t osSignalSet (osThreadId thread_id, int32_t signals) { - if (IN_ISR()) { // in ISR - return isrSignalSet(thread_id, signals); - } else { // in Thread +int32_t osSignalSet(osThreadId thread_id, int32_t signals) { + if (IN_ISR()) { // in ISR + return isrSignalSet(thread_id, signals); + } else { // in Thread return __svcSignalSet(thread_id, signals); } } /// Clear the specified Signal Flags of an active thread -int32_t osSignalClear (osThreadId thread_id, int32_t signals) { - if (__get_IPSR() != 0) return osErrorISR; // Not allowed in ISR +int32_t osSignalClear(osThreadId thread_id, int32_t signals) { + if (__get_IPSR() != 0) + return osErrorISR; // Not allowed in ISR return __svcSignalClear(thread_id, signals); } /// Get Signal Flags status of an active thread -int32_t osSignalGet (osThreadId thread_id) { - if (__get_IPSR() != 0) return osErrorISR; // Not allowed in ISR +int32_t osSignalGet(osThreadId thread_id) { + if (__get_IPSR() != 0) + return osErrorISR; // Not allowed in ISR return __svcSignalGet(thread_id); } -/// Wait for one or more Signal Flags to become signaled for the current RUNNING thread -os_InRegs osEvent osSignalWait (int32_t signals, uint32_t millisec) { +/// Wait for one or more Signal Flags to become signaled for the current RUNNING +/// thread +os_InRegs osEvent osSignalWait(int32_t signals, uint32_t millisec) { osEvent ret; - if (__get_IPSR() != 0) { // Not allowed in ISR + if (__get_IPSR() != 0) { // Not allowed in ISR ret.status = osErrorISR; return ret; } return __svcSignalWait(signals, millisec); } - // ==== Mutex Management ==== // Mutex Service Calls declarations -SVC_1_1(svcMutexCreate, osMutexId, const osMutexDef_t *, RET_pointer) -SVC_2_1(svcMutexWait, osStatus, osMutexId, uint32_t, RET_osStatus) -SVC_1_1(svcMutexRelease, osStatus, osMutexId, RET_osStatus) -SVC_1_1(svcMutexDelete, osStatus, osMutexId, RET_osStatus) -SVC_1_1(svcMutexGetOwner, osThreadId, osMutexId, RET_pointer) +SVC_1_1(svcMutexCreate, osMutexId, const osMutexDef_t *, RET_pointer) +SVC_2_1(svcMutexWait, osStatus, osMutexId, uint32_t, RET_osStatus) +SVC_1_1(svcMutexRelease, osStatus, osMutexId, RET_osStatus) +SVC_1_1(svcMutexDelete, osStatus, osMutexId, RET_osStatus) +SVC_1_1(svcMutexGetOwner, osThreadId, osMutexId, RET_pointer) // Mutex Service Calls /// Create and Initialize a Mutex object -osMutexId svcMutexCreate (const osMutexDef_t *mutex_def) { +osMutexId svcMutexCreate(const osMutexDef_t *mutex_def) { OS_ID mut; if (mutex_def == NULL) { @@ -1259,20 +1277,22 @@ osMutexId svcMutexCreate (const osMutexDef_t *mutex_def) { return NULL; } - rt_mut_init(mut); // Initialize Mutex + rt_mut_init(mut); // Initialize Mutex return mut; } /// Wait until a Mutex becomes available -osStatus svcMutexWait (osMutexId mutex_id, uint32_t millisec) { - OS_ID mut; +osStatus svcMutexWait(osMutexId mutex_id, uint32_t millisec) { + OS_ID mut; OS_RESULT res; mut = rt_id2obj(mutex_id); - if (mut == NULL) return osErrorParameter; + if (mut == NULL) + return osErrorParameter; - if (((P_MUCB)mut)->cb_type != MUCB) return osErrorParameter; + if (((P_MUCB)mut)->cb_type != MUCB) + return osErrorParameter; res = rt_mut_wait(mut, rt_ms2tick(millisec)); // Wait for Mutex @@ -1287,99 +1307,111 @@ osStatus svcMutexWait (osMutexId mutex_id, uint32_t millisec) { } /// Release a Mutex that was obtained with osMutexWait -osStatus svcMutexRelease (osMutexId mutex_id) { - OS_ID mut; +osStatus svcMutexRelease(osMutexId mutex_id) { + OS_ID mut; OS_RESULT res; mut = rt_id2obj(mutex_id); - if (mut == NULL) return osErrorParameter; + if (mut == NULL) + return osErrorParameter; - if (((P_MUCB)mut)->cb_type != MUCB) return osErrorParameter; + if (((P_MUCB)mut)->cb_type != MUCB) + return osErrorParameter; - res = rt_mut_release(mut); // Release Mutex + res = rt_mut_release(mut); // Release Mutex - if (res == OS_R_NOK) return osErrorResource; // Thread not owner or Zero Counter + if (res == OS_R_NOK) + return osErrorResource; // Thread not owner or Zero Counter return osOK; } /// Delete a Mutex that was created by osMutexCreate -osStatus svcMutexDelete (osMutexId mutex_id) { +osStatus svcMutexDelete(osMutexId mutex_id) { OS_ID mut; mut = rt_id2obj(mutex_id); - if (mut == NULL) return osErrorParameter; + if (mut == NULL) + return osErrorParameter; - if (((P_MUCB)mut)->cb_type != MUCB) return osErrorParameter; + if (((P_MUCB)mut)->cb_type != MUCB) + return osErrorParameter; - rt_mut_delete(mut); // Release Mutex + rt_mut_delete(mut); // Release Mutex return osOK; } /// Get owner thread of a Mutex object. -osThreadId svcMutexGetOwner (osMutexId mutex_id) { +osThreadId svcMutexGetOwner(osMutexId mutex_id) { OS_ID mut; mut = rt_id2obj(mutex_id); - if (mut == NULL) return NULL; + if (mut == NULL) + return NULL; - if (((P_MUCB)mut)->cb_type != MUCB) return NULL; + if (((P_MUCB)mut)->cb_type != MUCB) + return NULL; return (osThreadId)(((P_MUCB)mut)->owner); } - // Mutex Public API /// Create and Initialize a Mutex object -osMutexId osMutexCreate (const osMutexDef_t *mutex_def) { - if (__get_IPSR() != 0) return NULL; // Not allowed in ISR +osMutexId osMutexCreate(const osMutexDef_t *mutex_def) { + if (__get_IPSR() != 0) + return NULL; // Not allowed in ISR if (((__get_CONTROL() & 1) == 0) && (os_running == 0)) { // Privileged and not running - return svcMutexCreate(mutex_def); + return svcMutexCreate(mutex_def); } else { return __svcMutexCreate(mutex_def); } } /// Wait until a Mutex becomes available -osStatus osMutexWait (osMutexId mutex_id, uint32_t millisec) { - if (__get_IPSR() != 0) return osErrorISR; // Not allowed in ISR +osStatus osMutexWait(osMutexId mutex_id, uint32_t millisec) { + if (__get_IPSR() != 0) + return osErrorISR; // Not allowed in ISR return __svcMutexWait(mutex_id, millisec); } /// Release a Mutex that was obtained with osMutexWait -osStatus osMutexRelease (osMutexId mutex_id) { - if (__get_IPSR() != 0) return osErrorISR; // Not allowed in ISR +osStatus osMutexRelease(osMutexId mutex_id) { + if (__get_IPSR() != 0) + return osErrorISR; // Not allowed in ISR return __svcMutexRelease(mutex_id); } /// Delete a Mutex that was created by osMutexCreate -osStatus osMutexDelete (osMutexId mutex_id) { - if (__get_IPSR() != 0) return osErrorISR; // Not allowed in ISR +osStatus osMutexDelete(osMutexId mutex_id) { + if (__get_IPSR() != 0) + return osErrorISR; // Not allowed in ISR return __svcMutexDelete(mutex_id); } /// Get owner thread of a Mutex object. -osThreadId osMutexGetOwner (osMutexId mutex_id) { - if (__get_IPSR() != 0) return NULL; // Not allowed in ISR +osThreadId osMutexGetOwner(osMutexId mutex_id) { + if (__get_IPSR() != 0) + return NULL; // Not allowed in ISR return __svcMutexGetOwner(mutex_id); } - // ==== Semaphore Management ==== // Semaphore Service Calls declarations -SVC_2_1(svcSemaphoreCreate, osSemaphoreId, const osSemaphoreDef_t *, int32_t, RET_pointer) -SVC_2_1(svcSemaphoreWait, int32_t, osSemaphoreId, uint32_t, RET_int32_t) -SVC_1_1(svcSemaphoreRelease, osStatus, osSemaphoreId, RET_osStatus) -SVC_1_1(svcSemaphoreDelete, osStatus, osSemaphoreId, RET_osStatus) +SVC_2_1(svcSemaphoreCreate, osSemaphoreId, const osSemaphoreDef_t *, int32_t, + RET_pointer) +SVC_2_1(svcSemaphoreWait, int32_t, osSemaphoreId, uint32_t, RET_int32_t) +SVC_1_1(svcSemaphoreRelease, osStatus, osSemaphoreId, RET_osStatus) +SVC_1_1(svcSemaphoreDelete, osStatus, osSemaphoreId, RET_osStatus) // Semaphore Service Calls /// Create and Initialize a Semaphore object -osSemaphoreId svcSemaphoreCreate (const osSemaphoreDef_t *semaphore_def, int32_t count) { +osSemaphoreId svcSemaphoreCreate(const osSemaphoreDef_t *semaphore_def, + int32_t count) { OS_ID sem; if (semaphore_def == NULL) { @@ -1403,119 +1435,131 @@ osSemaphoreId svcSemaphoreCreate (const osSemaphoreDef_t *semaphore_def, int32_t return NULL; } - rt_sem_init(sem, count); // Initialize Semaphore + rt_sem_init(sem, count); // Initialize Semaphore return sem; } /// Wait until a Semaphore becomes available -int32_t svcSemaphoreWait (osSemaphoreId semaphore_id, uint32_t millisec) { - OS_ID sem; +int32_t svcSemaphoreWait(osSemaphoreId semaphore_id, uint32_t millisec) { + OS_ID sem; OS_RESULT res; sem = rt_id2obj(semaphore_id); - if (sem == NULL) return -1; + if (sem == NULL) + return -1; - if (((P_SCB)sem)->cb_type != SCB) return -1; + if (((P_SCB)sem)->cb_type != SCB) + return -1; res = rt_sem_wait(sem, rt_ms2tick(millisec)); // Wait for Semaphore - if (res == OS_R_TMO) return 0; // Timeout + if (res == OS_R_TMO) + return 0; // Timeout return (((P_SCB)sem)->tokens + 1); } /// Release a Semaphore -osStatus svcSemaphoreRelease (osSemaphoreId semaphore_id) { +osStatus svcSemaphoreRelease(osSemaphoreId semaphore_id) { OS_ID sem; sem = rt_id2obj(semaphore_id); - if (sem == NULL) return osErrorParameter; + if (sem == NULL) + return osErrorParameter; - if (((P_SCB)sem)->cb_type != SCB) return osErrorParameter; + if (((P_SCB)sem)->cb_type != SCB) + return osErrorParameter; - if (((P_SCB)sem)->tokens == osFeature_Semaphore) return osErrorResource; + if (((P_SCB)sem)->tokens == osFeature_Semaphore) + return osErrorResource; - rt_sem_send(sem); // Release Semaphore + rt_sem_send(sem); // Release Semaphore return osOK; } /// Delete a Semaphore that was created by osSemaphoreCreate -osStatus svcSemaphoreDelete (osSemaphoreId semaphore_id) { +osStatus svcSemaphoreDelete(osSemaphoreId semaphore_id) { OS_ID sem; sem = rt_id2obj(semaphore_id); - if (sem == NULL) return osErrorParameter; + if (sem == NULL) + return osErrorParameter; - if (((P_SCB)sem)->cb_type != SCB) return osErrorParameter; + if (((P_SCB)sem)->cb_type != SCB) + return osErrorParameter; - rt_sem_delete(sem); // Delete Semaphore + rt_sem_delete(sem); // Delete Semaphore return osOK; } - // Semaphore ISR Calls /// Release a Semaphore -static __INLINE osStatus isrSemaphoreRelease (osSemaphoreId semaphore_id) { +static __INLINE osStatus isrSemaphoreRelease(osSemaphoreId semaphore_id) { OS_ID sem; sem = rt_id2obj(semaphore_id); - if (sem == NULL) return osErrorParameter; + if (sem == NULL) + return osErrorParameter; - if (((P_SCB)sem)->cb_type != SCB) return osErrorParameter; + if (((P_SCB)sem)->cb_type != SCB) + return osErrorParameter; - if (((P_SCB)sem)->tokens == osFeature_Semaphore) return osErrorResource; + if (((P_SCB)sem)->tokens == osFeature_Semaphore) + return osErrorResource; - isr_sem_send(sem); // Release Semaphore + isr_sem_send(sem); // Release Semaphore return osOK; } - // Semaphore Public API /// Create and Initialize a Semaphore object -osSemaphoreId osSemaphoreCreate (const osSemaphoreDef_t *semaphore_def, int32_t count) { - if (__get_IPSR() != 0) return NULL; // Not allowed in ISR +osSemaphoreId osSemaphoreCreate(const osSemaphoreDef_t *semaphore_def, + int32_t count) { + if (__get_IPSR() != 0) + return NULL; // Not allowed in ISR if (((__get_CONTROL() & 1) == 0) && (os_running == 0)) { // Privileged and not running - return svcSemaphoreCreate(semaphore_def, count); + return svcSemaphoreCreate(semaphore_def, count); } else { return __svcSemaphoreCreate(semaphore_def, count); } } /// Wait until a Semaphore becomes available -int32_t osSemaphoreWait (osSemaphoreId semaphore_id, uint32_t millisec) { - if (__get_IPSR() != 0) return -1; // Not allowed in ISR +int32_t osSemaphoreWait(osSemaphoreId semaphore_id, uint32_t millisec) { + if (__get_IPSR() != 0) + return -1; // Not allowed in ISR return __svcSemaphoreWait(semaphore_id, millisec); } /// Release a Semaphore -osStatus osSemaphoreRelease (osSemaphoreId semaphore_id) { - if (IN_ISR()) { // in ISR - return isrSemaphoreRelease(semaphore_id); - } else { // in Thread +osStatus osSemaphoreRelease(osSemaphoreId semaphore_id) { + if (IN_ISR()) { // in ISR + return isrSemaphoreRelease(semaphore_id); + } else { // in Thread return __svcSemaphoreRelease(semaphore_id); } } /// Delete a Semaphore that was created by osSemaphoreCreate -osStatus osSemaphoreDelete (osSemaphoreId semaphore_id) { - if (__get_IPSR() != 0) return osErrorISR; // Not allowed in ISR +osStatus osSemaphoreDelete(osSemaphoreId semaphore_id) { + if (__get_IPSR() != 0) + return osErrorISR; // Not allowed in ISR return __svcSemaphoreDelete(semaphore_id); } - // ==== Memory Management Functions ==== // Memory Management Helper Functions // Clear Memory Box (Zero init) -static void rt_clr_box (void *box_mem, void *box) { +static void rt_clr_box(void *box_mem, void *box) { uint32_t *p, n; if ((box_mem != NULL) && (box != NULL)) { @@ -1527,36 +1571,36 @@ static void rt_clr_box (void *box_mem, void *box) { } // Memory Management Service Calls declarations -SVC_1_1(svcPoolCreate, osPoolId, const osPoolDef_t *, RET_pointer) -SVC_2_1(sysPoolAlloc, void *, osPoolId, uint32_t, RET_pointer) -SVC_2_1(sysPoolFree, osStatus, osPoolId, void *, RET_osStatus) +SVC_1_1(svcPoolCreate, osPoolId, const osPoolDef_t *, RET_pointer) +SVC_2_1(sysPoolAlloc, void *, osPoolId, uint32_t, RET_pointer) +SVC_2_1(sysPoolFree, osStatus, osPoolId, void *, RET_osStatus) // Memory Management Service & ISR Calls /// Create and Initialize memory pool -osPoolId svcPoolCreate (const osPoolDef_t *pool_def) { +osPoolId svcPoolCreate(const osPoolDef_t *pool_def) { uint32_t blk_sz; - if ((pool_def == NULL) || - (pool_def->pool_sz == 0) || - (pool_def->item_sz == 0) || - (pool_def->pool == NULL)) { + if ((pool_def == NULL) || (pool_def->pool_sz == 0) || + (pool_def->item_sz == 0) || (pool_def->pool == NULL)) { sysThreadError(osErrorParameter); return NULL; } blk_sz = (pool_def->item_sz + 3) & ~3; - _init_box(pool_def->pool, sizeof(struct OS_BM) + pool_def->pool_sz * blk_sz, blk_sz); + _init_box(pool_def->pool, sizeof(struct OS_BM) + pool_def->pool_sz * blk_sz, + blk_sz); return pool_def->pool; } /// Allocate a memory block from a memory pool -void *sysPoolAlloc (osPoolId pool_id, uint32_t clr) { +void *sysPoolAlloc(osPoolId pool_id, uint32_t clr) { void *ptr; - if (pool_id == NULL) return NULL; + if (pool_id == NULL) + return NULL; ptr = rt_alloc_box(pool_id); if (clr) { @@ -1567,73 +1611,76 @@ void *sysPoolAlloc (osPoolId pool_id, uint32_t clr) { } /// Return an allocated memory block back to a specific memory pool -osStatus sysPoolFree (osPoolId pool_id, void *block) { +osStatus sysPoolFree(osPoolId pool_id, void *block) { int32_t res; - if (pool_id == NULL) return osErrorParameter; + if (pool_id == NULL) + return osErrorParameter; res = rt_free_box(pool_id, block); - if (res != 0) return osErrorValue; + if (res != 0) + return osErrorValue; return osOK; } - // Memory Management Public API /// Create and Initialize memory pool -osPoolId osPoolCreate (const osPoolDef_t *pool_def) { - if (__get_IPSR() != 0) return NULL; // Not allowed in ISR +osPoolId osPoolCreate(const osPoolDef_t *pool_def) { + if (__get_IPSR() != 0) + return NULL; // Not allowed in ISR if (((__get_CONTROL() & 1) == 0) && (os_running == 0)) { // Privileged and not running - return svcPoolCreate(pool_def); + return svcPoolCreate(pool_def); } else { return __svcPoolCreate(pool_def); } } /// Allocate a memory block from a memory pool -void *osPoolAlloc (osPoolId pool_id) { - if ((__get_IPSR() != 0) || ((__get_CONTROL() & 1) == 0)) { // in ISR or Privileged - return sysPoolAlloc(pool_id, 0); - } else { // in Thread +void *osPoolAlloc(osPoolId pool_id) { + if ((__get_IPSR() != 0) || + ((__get_CONTROL() & 1) == 0)) { // in ISR or Privileged + return sysPoolAlloc(pool_id, 0); + } else { // in Thread return __sysPoolAlloc(pool_id, 0); } } /// Allocate a memory block from a memory pool and set memory block to zero -void *osPoolCAlloc (osPoolId pool_id) { - if ((IN_ISR()) || ((__get_CONTROL() & 1) == 0)) { // in ISR or Privileged - return sysPoolAlloc(pool_id, 1); - } else { // in Thread +void *osPoolCAlloc(osPoolId pool_id) { + if ((IN_ISR()) || ((__get_CONTROL() & 1) == 0)) { // in ISR or Privileged + return sysPoolAlloc(pool_id, 1); + } else { // in Thread return __sysPoolAlloc(pool_id, 1); } } /// Return an allocated memory block back to a specific memory pool -osStatus osPoolFree (osPoolId pool_id, void *block) { - if ((IN_ISR()) || ((__get_CONTROL() & 1) == 0)) { // in ISR or Privileged - return sysPoolFree(pool_id, block); - } else { // in Thread +osStatus osPoolFree(osPoolId pool_id, void *block) { + if ((IN_ISR()) || ((__get_CONTROL() & 1) == 0)) { // in ISR or Privileged + return sysPoolFree(pool_id, block); + } else { // in Thread return __sysPoolFree(pool_id, block); } } - // ==== Message Queue Management Functions ==== // Message Queue Management Service Calls declarations -SVC_2_1(svcMessageCreate, osMessageQId, const osMessageQDef_t *, osThreadId, RET_pointer) -SVC_3_1(svcMessagePut, osStatus, osMessageQId, uint32_t, uint32_t, RET_osStatus) -SVC_2_3(svcMessageGet, os_InRegs osEvent, osMessageQId, uint32_t, RET_osEvent) +SVC_2_1(svcMessageCreate, osMessageQId, const osMessageQDef_t *, osThreadId, + RET_pointer) +SVC_3_1(svcMessagePut, osStatus, osMessageQId, uint32_t, uint32_t, RET_osStatus) +SVC_2_3(svcMessageGet, os_InRegs osEvent, osMessageQId, uint32_t, RET_osEvent) // Message Queue Service Calls /// Create and Initialize Message Queue -osMessageQId svcMessageCreate (const osMessageQDef_t *queue_def, osThreadId thread_id) { +osMessageQId svcMessageCreate(const osMessageQDef_t *queue_def, + osThreadId thread_id) { - if ((queue_def == NULL) || - (queue_def->queue_sz == 0) || + if ((queue_def == NULL) || (queue_def->queue_sz == 0) || (queue_def->pool == NULL)) { sysThreadError(osErrorParameter); return NULL; @@ -1644,18 +1691,21 @@ osMessageQId svcMessageCreate (const osMessageQDef_t *queue_def, osThreadId thre return NULL; } - rt_mbx_init(queue_def->pool, 4*(queue_def->queue_sz + 4)); + rt_mbx_init(queue_def->pool, 4 * (queue_def->queue_sz + 4)); return queue_def->pool; } /// Put a Message to a Queue -osStatus svcMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec) { +osStatus svcMessagePut(osMessageQId queue_id, uint32_t info, + uint32_t millisec) { OS_RESULT res; - if (queue_id == NULL) return osErrorParameter; + if (queue_id == NULL) + return osErrorParameter; - if (((P_MCB)queue_id)->cb_type != MCB) return osErrorParameter; + if (((P_MCB)queue_id)->cb_type != MCB) + return osErrorParameter; res = rt_mbx_send(queue_id, (void *)info, rt_ms2tick(millisec)); @@ -1667,9 +1717,9 @@ osStatus svcMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec) } /// Get a Message or Wait for a Message from a Queue -os_InRegs osEvent_type svcMessageGet (osMessageQId queue_id, uint32_t millisec) { +os_InRegs osEvent_type svcMessageGet(osMessageQId queue_id, uint32_t millisec) { OS_RESULT res; - osEvent ret; + osEvent ret; if (queue_id == NULL) { ret.status = osErrorParameter; @@ -1693,19 +1743,20 @@ os_InRegs osEvent_type svcMessageGet (osMessageQId queue_id, uint32_t millisec) return osEvent_ret_value; } - // Message Queue ISR Calls /// Put a Message to a Queue -static __INLINE osStatus isrMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec) { +static __INLINE osStatus isrMessagePut(osMessageQId queue_id, uint32_t info, + uint32_t millisec) { if ((queue_id == NULL) || (millisec != 0)) { return osErrorParameter; } - if (((P_MCB)queue_id)->cb_type != MCB) return osErrorParameter; + if (((P_MCB)queue_id)->cb_type != MCB) + return osErrorParameter; - if (rt_mbx_check(queue_id) == 0) { // Check if Queue is full + if (rt_mbx_check(queue_id) == 0) { // Check if Queue is full return osErrorResource; } @@ -1715,9 +1766,10 @@ static __INLINE osStatus isrMessagePut (osMessageQId queue_id, uint32_t info, ui } /// Get a Message or Wait for a Message from a Queue -static __INLINE os_InRegs osEvent isrMessageGet (osMessageQId queue_id, uint32_t millisec) { +static __INLINE os_InRegs osEvent isrMessageGet(osMessageQId queue_id, + uint32_t millisec) { OS_RESULT res; - osEvent ret; + osEvent ret; if ((queue_id == NULL) || (millisec != 0)) { ret.status = osErrorParameter; @@ -1741,63 +1793,61 @@ static __INLINE os_InRegs osEvent isrMessageGet (osMessageQId queue_id, uint32_t return ret; } - // Message Queue Management Public API /// Create and Initialize Message Queue -osMessageQId osMessageCreate (const osMessageQDef_t *queue_def, osThreadId thread_id) { - if (__get_IPSR() != 0) return NULL; // Not allowed in ISR +osMessageQId osMessageCreate(const osMessageQDef_t *queue_def, + osThreadId thread_id) { + if (__get_IPSR() != 0) + return NULL; // Not allowed in ISR if (((__get_CONTROL() & 1) == 0) && (os_running == 0)) { // Privileged and not running - return svcMessageCreate(queue_def, thread_id); + return svcMessageCreate(queue_def, thread_id); } else { return __svcMessageCreate(queue_def, thread_id); } } /// Put a Message to a Queue -osStatus osMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec) { - if (IN_ISR()) { // in ISR - return isrMessagePut(queue_id, info, millisec); - } else { // in Thread +osStatus osMessagePut(osMessageQId queue_id, uint32_t info, uint32_t millisec) { + if (IN_ISR()) { // in ISR + return isrMessagePut(queue_id, info, millisec); + } else { // in Thread return __svcMessagePut(queue_id, info, millisec); } } /// Get a Message or Wait for a Message from a Queue -os_InRegs osEvent osMessageGet (osMessageQId queue_id, uint32_t millisec) { - if (IN_ISR()) { // in ISR - return isrMessageGet(queue_id, millisec); - } else { // in Thread +os_InRegs osEvent osMessageGet(osMessageQId queue_id, uint32_t millisec) { + if (IN_ISR()) { // in ISR + return isrMessageGet(queue_id, millisec); + } else { // in Thread return __svcMessageGet(queue_id, millisec); } } - -uint32_t osMessageGetSpace (osMessageQId queue_id) -{ - return rt_mbx_check(queue_id); +uint32_t osMessageGetSpace(osMessageQId queue_id) { + return rt_mbx_check(queue_id); } // ==== Mail Queue Management Functions ==== // Mail Queue Management Service Calls declarations -SVC_2_1(svcMailCreate, osMailQId, const osMailQDef_t *, osThreadId, RET_pointer) -SVC_4_1(sysMailAlloc, void *, osMailQId, uint32_t, uint32_t, uint32_t, RET_pointer) -SVC_3_1(sysMailFree, osStatus, osMailQId, void *, uint32_t, RET_osStatus) +SVC_2_1(svcMailCreate, osMailQId, const osMailQDef_t *, osThreadId, RET_pointer) +SVC_4_1(sysMailAlloc, void *, osMailQId, uint32_t, uint32_t, uint32_t, + RET_pointer) +SVC_3_1(sysMailFree, osStatus, osMailQId, void *, uint32_t, RET_osStatus) // Mail Queue Management Service & ISR Calls /// Create and Initialize mail queue -osMailQId svcMailCreate (const osMailQDef_t *queue_def, osThreadId thread_id) { +osMailQId svcMailCreate(const osMailQDef_t *queue_def, osThreadId thread_id) { uint32_t blk_sz; - P_MCB pmcb; - void *pool; + P_MCB pmcb; + void *pool; - if ((queue_def == NULL) || - (queue_def->queue_sz == 0) || - (queue_def->item_sz == 0) || - (queue_def->pool == NULL)) { + if ((queue_def == NULL) || (queue_def->queue_sz == 0) || + (queue_def->item_sz == 0) || (queue_def->pool == NULL)) { sysThreadError(osErrorParameter); return NULL; } @@ -1814,26 +1864,29 @@ osMailQId svcMailCreate (const osMailQDef_t *queue_def, osThreadId thread_id) { _init_box(pool, sizeof(struct OS_BM) + queue_def->queue_sz * blk_sz, blk_sz); - rt_mbx_init(pmcb, 4*(queue_def->queue_sz + 4)); - + rt_mbx_init(pmcb, 4 * (queue_def->queue_sz + 4)); return queue_def->pool; } /// Allocate a memory block from a mail -void *sysMailAlloc (osMailQId queue_id, uint32_t millisec, uint32_t isr, uint32_t clr) { +void *sysMailAlloc(osMailQId queue_id, uint32_t millisec, uint32_t isr, + uint32_t clr) { P_MCB pmcb; void *pool; void *mem; - if (queue_id == NULL) return NULL; + if (queue_id == NULL) + return NULL; pmcb = *(((void **)queue_id) + 0); pool = *(((void **)queue_id) + 1); - if ((pool == NULL) || (pmcb == NULL)) return NULL; + if ((pool == NULL) || (pmcb == NULL)) + return NULL; - if (isr && (millisec != 0)) return NULL; + if (isr && (millisec != 0)) + return NULL; mem = rt_alloc_box(pool); if (clr) { @@ -1858,29 +1911,32 @@ void *sysMailAlloc (osMailQId queue_id, uint32_t millisec, uint32_t isr, uint32_ } /// Free a memory block from a mail -osStatus sysMailFree (osMailQId queue_id, void *mail, uint32_t isr) { - P_MCB pmcb; - P_TCB ptcb; - void *pool; - void *mem; +osStatus sysMailFree(osMailQId queue_id, void *mail, uint32_t isr) { + P_MCB pmcb; + P_TCB ptcb; + void *pool; + void *mem; int32_t res; - if (queue_id == NULL) return osErrorParameter; + if (queue_id == NULL) + return osErrorParameter; pmcb = *(((void **)queue_id) + 0); pool = *(((void **)queue_id) + 1); - if ((pmcb == NULL) || (pool == NULL)) return osErrorParameter; + if ((pmcb == NULL) || (pool == NULL)) + return osErrorParameter; res = rt_free_box(pool, mail); - if (res != 0) return osErrorValue; + if (res != 0) + return osErrorValue; if ((pmcb->p_lnk != NULL) && (pmcb->state == 3U)) { // Task is waiting to allocate a message if (isr) { - rt_psq_enq (pmcb, (U32)pool); - rt_psh_req (); + rt_psq_enq(pmcb, (U32)pool); + rt_psh_req(); } else { mem = rt_alloc_box(pool); if (mem != NULL) { @@ -1895,60 +1951,64 @@ osStatus sysMailFree (osMailQId queue_id, void *mail, uint32_t isr) { return osOK; } - // Mail Queue Management Public API /// Create and Initialize mail queue -osMailQId osMailCreate (const osMailQDef_t *queue_def, osThreadId thread_id) { - if (__get_IPSR() != 0) return NULL; // Not allowed in ISR +osMailQId osMailCreate(const osMailQDef_t *queue_def, osThreadId thread_id) { + if (__get_IPSR() != 0) + return NULL; // Not allowed in ISR if (((__get_CONTROL() & 1) == 0) && (os_running == 0)) { // Privileged and not running - return svcMailCreate(queue_def, thread_id); + return svcMailCreate(queue_def, thread_id); } else { return __svcMailCreate(queue_def, thread_id); } } /// Allocate a memory block from a mail -void *osMailAlloc (osMailQId queue_id, uint32_t millisec) { - if (IN_ISR()) { // in ISR - return sysMailAlloc(queue_id, millisec, 1, 0); - } else { // in Thread +void *osMailAlloc(osMailQId queue_id, uint32_t millisec) { + if (IN_ISR()) { // in ISR + return sysMailAlloc(queue_id, millisec, 1, 0); + } else { // in Thread return __sysMailAlloc(queue_id, millisec, 0, 0); } } /// Allocate a memory block from a mail and set memory block to zero -void *osMailCAlloc (osMailQId queue_id, uint32_t millisec) { - if (IN_ISR()) { // in ISR - return sysMailAlloc(queue_id, millisec, 1, 1); - } else { // in Thread +void *osMailCAlloc(osMailQId queue_id, uint32_t millisec) { + if (IN_ISR()) { // in ISR + return sysMailAlloc(queue_id, millisec, 1, 1); + } else { // in Thread return __sysMailAlloc(queue_id, millisec, 0, 1); } } /// Free a memory block from a mail -osStatus osMailFree (osMailQId queue_id, void *mail) { - if (IN_ISR()) { // in ISR - return sysMailFree(queue_id, mail, 1); - } else { // in Thread +osStatus osMailFree(osMailQId queue_id, void *mail) { + if (IN_ISR()) { // in ISR + return sysMailFree(queue_id, mail, 1); + } else { // in Thread return __sysMailFree(queue_id, mail, 0); } } /// Put a mail to a queue -osStatus osMailPut (osMailQId queue_id, void *mail) { - if (queue_id == NULL) return osErrorParameter; - if (mail == NULL) return osErrorValue; +osStatus osMailPut(osMailQId queue_id, void *mail) { + if (queue_id == NULL) + return osErrorParameter; + if (mail == NULL) + return osErrorValue; return osMessagePut(*((void **)queue_id), (uint32_t)mail, 0); } #if TASK_HUNG_CHECK_ENABLED -osStatus svcThreadSetHungCheck (osThreadId thread_id, int32_t enable, uint32_t timeout) { - P_TCB ptcb; +osStatus svcThreadSetHungCheck(osThreadId thread_id, int32_t enable, + uint32_t timeout) { + P_TCB ptcb; - ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer - if (ptcb == NULL) return osErrorParameter; + ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer + if (ptcb == NULL) + return osErrorParameter; ptcb->hung_check = !!enable; ptcb->hung_check_timeout = timeout; @@ -1956,8 +2016,10 @@ osStatus svcThreadSetHungCheck (osThreadId thread_id, int32_t enable, uint32_t t } /// enable/disable the hung check feature of an active thread -osStatus osThreadSetHungCheck (osThreadId thread_id, int32_t enable, uint32_t timeout) { - if (__get_IPSR() != 0) return osErrorISR; // Not allowed in ISR +osStatus osThreadSetHungCheck(osThreadId thread_id, int32_t enable, + uint32_t timeout) { + if (__get_IPSR() != 0) + return osErrorISR; // Not allowed in ISR return __svcThreadSetHungCheck(thread_id, enable, timeout); } #endif @@ -1967,7 +2029,7 @@ osStatus osThreadSetHungCheck (osThreadId thread_id, int32_t enable, uint32_t ti #pragma Ospace #endif // __arm__ /// Get a mail from a queue -os_InRegs osEvent osMailGet (osMailQId queue_id, uint32_t millisec) { +os_InRegs osEvent osMailGet(osMailQId queue_id, uint32_t millisec) { osEvent ret; if (queue_id == NULL) { @@ -1976,7 +2038,8 @@ os_InRegs osEvent osMailGet (osMailQId queue_id, uint32_t millisec) { } ret = osMessageGet(*((void **)queue_id), millisec); - if (ret.status == osEventMessage) ret.status = osEventMail; + if (ret.status == osEventMessage) + ret.status = osEventMail; return ret; } diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_Event.c b/rtos/rtx/TARGET_CORTEX_M/rt_Event.c index acd8ccc..dcd7f87 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_Event.c +++ b/rtos/rtx/TARGET_CORTEX_M/rt_Event.c @@ -32,23 +32,21 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" -#include "RTX_Conf.h" -#include "rt_System.h" #include "rt_Event.h" -#include "rt_List.h" -#include "rt_Task.h" +#include "RTX_Conf.h" #include "rt_HAL_CM.h" - +#include "rt_List.h" +#include "rt_System.h" +#include "rt_Task.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_evt_wait -----------------------------------*/ -OS_RESULT rt_evt_wait (U16 wait_flags, U16 timeout, BOOL and_wait) { +OS_RESULT rt_evt_wait(U16 wait_flags, U16 timeout, BOOL and_wait) { /* Wait for one or more event flags with optional time-out. */ /* "wait_flags" identifies the flags to wait for. */ /* "timeout" is the time-out limit in system ticks (0xffff if no time-out) */ @@ -63,8 +61,7 @@ OS_RESULT rt_evt_wait (U16 wait_flags, U16 timeout, BOOL and_wait) { return (OS_R_EVT); } block_state = WAIT_AND; - } - else { + } else { /* Check for OR-connected events */ if (os_tsk.run->events & wait_flags) { os_tsk.run->waits = os_tsk.run->events & wait_flags; @@ -75,23 +72,22 @@ OS_RESULT rt_evt_wait (U16 wait_flags, U16 timeout, BOOL and_wait) { } /* Task has to wait */ os_tsk.run->waits = wait_flags; - rt_block (timeout, (U8)block_state); + rt_block(timeout, (U8)block_state); return (OS_R_TMO); } - /*--------------------------- rt_evt_set ------------------------------------*/ -void rt_evt_set (U16 event_flags, OS_TID task_id) { +void rt_evt_set(U16 event_flags, OS_TID task_id) { /* Set one or more event flags of a selectable task. */ P_TCB p_tcb; - p_tcb = os_active_TCB[task_id-1]; + p_tcb = os_active_TCB[task_id - 1]; if (p_tcb == NULL) { return; } p_tcb->events |= event_flags; - event_flags = p_tcb->waits; + event_flags = p_tcb->waits; /* If the task is not waiting for an event, it should not be put */ /* to ready state. */ if (p_tcb->state == WAIT_AND) { @@ -103,27 +99,27 @@ void rt_evt_set (U16 event_flags, OS_TID task_id) { if (p_tcb->state == WAIT_OR) { /* Check for OR-connected events */ if (p_tcb->events & event_flags) { - p_tcb->waits &= p_tcb->events; -wkup: p_tcb->events &= ~event_flags; - rt_rmv_dly (p_tcb); - p_tcb->state = READY; + p_tcb->waits &= p_tcb->events; + wkup: + p_tcb->events &= ~event_flags; + rt_rmv_dly(p_tcb); + p_tcb->state = READY; #ifdef __CMSIS_RTOS - rt_ret_val2(p_tcb, 0x08/*osEventSignal*/, p_tcb->waits); + rt_ret_val2(p_tcb, 0x08 /*osEventSignal*/, p_tcb->waits); #else - rt_ret_val (p_tcb, OS_R_EVT); + rt_ret_val(p_tcb, OS_R_EVT); #endif - rt_dispatch (p_tcb); + rt_dispatch(p_tcb); } } } - /*--------------------------- rt_evt_clr ------------------------------------*/ -void rt_evt_clr (U16 clear_flags, OS_TID task_id) { +void rt_evt_clr(U16 clear_flags, OS_TID task_id) { /* Clear one or more event flags (identified by "clear_flags") of a */ /* selectable task (identified by "task"). */ - P_TCB task = os_active_TCB[task_id-1]; + P_TCB task = os_active_TCB[task_id - 1]; if (task == NULL) { return; @@ -131,32 +127,29 @@ void rt_evt_clr (U16 clear_flags, OS_TID task_id) { task->events &= ~clear_flags; } - /*--------------------------- isr_evt_set -----------------------------------*/ -void isr_evt_set (U16 event_flags, OS_TID task_id) { +void isr_evt_set(U16 event_flags, OS_TID task_id) { /* Same function as "os_evt_set", but to be called by ISRs. */ - P_TCB p_tcb = os_active_TCB[task_id-1]; + P_TCB p_tcb = os_active_TCB[task_id - 1]; if (p_tcb == NULL) { return; } - rt_psq_enq (p_tcb, event_flags); - rt_psh_req (); + rt_psq_enq(p_tcb, event_flags); + rt_psh_req(); } - /*--------------------------- rt_evt_get ------------------------------------*/ -U16 rt_evt_get (void) { +U16 rt_evt_get(void) { /* Get events of a running task after waiting for OR connected events. */ return (os_tsk.run->waits); } - /*--------------------------- rt_evt_psh ------------------------------------*/ -void rt_evt_psh (P_TCB p_CB, U16 set_flags) { +void rt_evt_psh(P_TCB p_CB, U16 set_flags) { /* Check if task has to be waken up */ U16 event_flags; @@ -171,16 +164,17 @@ void rt_evt_psh (P_TCB p_CB, U16 set_flags) { if (p_CB->state == WAIT_OR) { /* Check for OR-connected events */ if (p_CB->events & event_flags) { - p_CB->waits &= p_CB->events; -rdy: p_CB->events &= ~event_flags; - rt_rmv_dly (p_CB); - p_CB->state = READY; + p_CB->waits &= p_CB->events; + rdy: + p_CB->events &= ~event_flags; + rt_rmv_dly(p_CB); + p_CB->state = READY; #ifdef __CMSIS_RTOS - rt_ret_val2(p_CB, 0x08/*osEventSignal*/, p_CB->waits); + rt_ret_val2(p_CB, 0x08 /*osEventSignal*/, p_CB->waits); #else - rt_ret_val (p_CB, OS_R_EVT); + rt_ret_val(p_CB, OS_R_EVT); #endif - rt_put_prio (&os_rdy, p_CB); + rt_put_prio(&os_rdy, p_CB); } } } diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_Event.h b/rtos/rtx/TARGET_CORTEX_M/rt_Event.h index 8b92f3c..164f986 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_Event.h +++ b/rtos/rtx/TARGET_CORTEX_M/rt_Event.h @@ -31,16 +31,15 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ - +#include "rt_TypeDef.h" /* Functions */ -extern OS_RESULT rt_evt_wait (U16 wait_flags, U16 timeout, BOOL and_wait); -extern void rt_evt_set (U16 event_flags, OS_TID task_id); -extern void rt_evt_clr (U16 clear_flags, OS_TID task_id); -extern void isr_evt_set (U16 event_flags, OS_TID task_id); -extern U16 rt_evt_get (void); -extern void rt_evt_psh (P_TCB p_CB, U16 set_flags); +extern OS_RESULT rt_evt_wait(U16 wait_flags, U16 timeout, BOOL and_wait); +extern void rt_evt_set(U16 event_flags, OS_TID task_id); +extern void rt_evt_clr(U16 clear_flags, OS_TID task_id); +extern void isr_evt_set(U16 event_flags, OS_TID task_id); +extern U16 rt_evt_get(void); +extern void rt_evt_psh(P_TCB p_CB, U16 set_flags); /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_HAL_CM.h b/rtos/rtx/TARGET_CORTEX_M/rt_HAL_CM.h index 8ffef86..aafa5b2 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_HAL_CM.h +++ b/rtos/rtx/TARGET_CORTEX_M/rt_HAL_CM.h @@ -32,70 +32,69 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ +#include "rt_TypeDef.h" + /* Definitions */ -#define INITIAL_xPSR 0x01000000 -#define DEMCR_TRCENA 0x01000000 -#define ITM_ITMENA 0x00000001 -#define MAGIC_WORD 0xE25A2EA5 +#define INITIAL_xPSR 0x01000000 +#define DEMCR_TRCENA 0x01000000 +#define ITM_ITMENA 0x00000001 +#define MAGIC_WORD 0xE25A2EA5 -#define SYSTICK_EXTERNAL_CLOCK 1 +#define SYSTICK_EXTERNAL_CLOCK 1 -#if defined (__CC_ARM) /* ARM Compiler */ +#if defined(__CC_ARM) /* ARM Compiler */ #if ((__TARGET_ARCH_7_M || __TARGET_ARCH_7E_M) && !NO_EXCLUSIVE_ACCESS) - #define __USE_EXCLUSIVE_ACCESS +#define __USE_EXCLUSIVE_ACCESS #else - #undef __USE_EXCLUSIVE_ACCESS +#undef __USE_EXCLUSIVE_ACCESS #endif -#elif defined (__GNUC__) /* GNU Compiler */ +#elif defined(__GNUC__) /* GNU Compiler */ -#undef __USE_EXCLUSIVE_ACCESS +#undef __USE_EXCLUSIVE_ACCESS -#if defined (__CORTEX_M0) || defined (__CORTEX_M0PLUS) +#if defined(__CORTEX_M0) || defined(__CORTEX_M0PLUS) #define __TARGET_ARCH_6S_M 1 #else #define __TARGET_ARCH_6S_M 0 #endif -#if defined (__VFP_FP__) && !defined(__SOFTFP__) +#if defined(__VFP_FP__) && !defined(__SOFTFP__) #define __TARGET_FPU_VFP 1 #else #define __TARGET_FPU_VFP 0 #endif #define __inline inline -#define __weak __attribute__((weak)) +#define __weak __attribute__((weak)) #ifndef __CMSIS_GENERIC -__attribute__((always_inline)) static inline void __enable_irq(void) -{ - __asm volatile ("cpsie i"); +__attribute__((always_inline)) static inline void __enable_irq(void) { + __asm volatile("cpsie i"); } -__attribute__((always_inline)) static inline U32 __disable_irq(void) -{ +__attribute__((always_inline)) static inline U32 __disable_irq(void) { U32 result; - __asm volatile ("mrs %0, primask" : "=r" (result)); - __asm volatile ("cpsid i"); - return(result & 1); + __asm volatile("mrs %0, primask" : "=r"(result)); + __asm volatile("cpsid i"); + return (result & 1); } #endif -__attribute__(( always_inline)) static inline U8 __clz(U32 value) -{ +__attribute__((always_inline)) static inline U8 __clz(U32 value) { U8 result; - __asm volatile ("clz %0, %1" : "=r" (result) : "r" (value)); - return(result); + __asm volatile("clz %0, %1" : "=r"(result) : "r"(value)); + return (result); } -#elif defined (__ICCARM__) /* IAR Compiler */ +#elif defined(__ICCARM__) /* IAR Compiler */ -#undef __USE_EXCLUSIVE_ACCESS +#undef __USE_EXCLUSIVE_ACCESS #if (__CORE__ == __ARM6M__) #define __TARGET_ARCH_6S_M 1 @@ -113,175 +112,184 @@ __attribute__(( always_inline)) static inline U8 __clz(U32 value) #ifndef __CMSIS_GENERIC -static inline void __enable_irq(void) -{ - __asm volatile ("cpsie i"); -} +static inline void __enable_irq(void) { __asm volatile("cpsie i"); } -static inline U32 __disable_irq(void) -{ +static inline U32 __disable_irq(void) { U32 result; - __asm volatile ("mrs %0, primask" : "=r" (result)); - __asm volatile ("cpsid i"); - return(result & 1); + __asm volatile("mrs %0, primask" : "=r"(result)); + __asm volatile("cpsid i"); + return (result & 1); } #endif -static inline U8 __clz(U32 value) -{ +static inline U8 __clz(U32 value) { U8 result; - __asm volatile ("clz %0, %1" : "=r" (result) : "r" (value)); - return(result); + __asm volatile("clz %0, %1" : "=r"(result) : "r"(value)); + return (result); } #endif /* NVIC registers */ -#define NVIC_ST_CTRL (*((volatile U32 *)0xE000E010)) -#define NVIC_ST_RELOAD (*((volatile U32 *)0xE000E014)) +#define NVIC_ST_CTRL (*((volatile U32 *)0xE000E010)) +#define NVIC_ST_RELOAD (*((volatile U32 *)0xE000E014)) #define NVIC_ST_CURRENT (*((volatile U32 *)0xE000E018)) -#define NVIC_ISER ((volatile U32 *)0xE000E100) -#define NVIC_ICER ((volatile U32 *)0xE000E180) +#define NVIC_ISER ((volatile U32 *)0xE000E100) +#define NVIC_ICER ((volatile U32 *)0xE000E180) #if (__TARGET_ARCH_6S_M) -#define NVIC_IP ((volatile U32 *)0xE000E400) +#define NVIC_IP ((volatile U32 *)0xE000E400) #else -#define NVIC_IP ((volatile U8 *)0xE000E400) +#define NVIC_IP ((volatile U8 *)0xE000E400) #endif -#define NVIC_INT_CTRL (*((volatile U32 *)0xE000ED04)) -#define NVIC_AIR_CTRL (*((volatile U32 *)0xE000ED0C)) -#define NVIC_SYS_PRI2 (*((volatile U32 *)0xE000ED1C)) -#define NVIC_SYS_PRI3 (*((volatile U32 *)0xE000ED20)) +#define NVIC_INT_CTRL (*((volatile U32 *)0xE000ED04)) +#define NVIC_AIR_CTRL (*((volatile U32 *)0xE000ED0C)) +#define NVIC_SYS_PRI2 (*((volatile U32 *)0xE000ED1C)) +#define NVIC_SYS_PRI3 (*((volatile U32 *)0xE000ED20)) -#define OS_PEND_IRQ() NVIC_INT_CTRL = (1<<28) -#define OS_PENDING ((NVIC_INT_CTRL >> 26) & (1<<2 | 1)) -#define OS_UNPEND(fl) NVIC_INT_CTRL = (*fl = OS_PENDING) << 25 -#define OS_PEND(fl,p) NVIC_INT_CTRL = (fl | p<<2) << 26 +#define OS_PEND_IRQ() NVIC_INT_CTRL = (1 << 28) +#define OS_PENDING ((NVIC_INT_CTRL >> 26) & (1 << 2 | 1)) +#define OS_UNPEND(fl) NVIC_INT_CTRL = (*fl = OS_PENDING) << 25 +#define OS_PEND(fl, p) NVIC_INT_CTRL = (fl | p << 2) << 26 #if (SYSTICK_EXTERNAL_CLOCK) -#define OS_LOCK() NVIC_ST_CTRL = 0x0001 -#define OS_UNLOCK() NVIC_ST_CTRL = 0x0003 +#define OS_LOCK() NVIC_ST_CTRL = 0x0001 +#define OS_UNLOCK() NVIC_ST_CTRL = 0x0003 #else -#define OS_LOCK() NVIC_ST_CTRL = 0x0005 -#define OS_UNLOCK() NVIC_ST_CTRL = 0x0007 +#define OS_LOCK() NVIC_ST_CTRL = 0x0005 +#define OS_UNLOCK() NVIC_ST_CTRL = 0x0007 #endif -#define OS_X_PENDING ((NVIC_INT_CTRL >> 28) & 1) -#define OS_X_UNPEND(fl) NVIC_INT_CTRL = (*fl = OS_X_PENDING) << 27 -#define OS_X_PEND(fl,p) NVIC_INT_CTRL = (fl | p) << 28 +#define OS_X_PENDING ((NVIC_INT_CTRL >> 28) & 1) +#define OS_X_UNPEND(fl) NVIC_INT_CTRL = (*fl = OS_X_PENDING) << 27 +#define OS_X_PEND(fl, p) NVIC_INT_CTRL = (fl | p) << 28 #if (__TARGET_ARCH_6S_M) -#define OS_X_INIT(n) NVIC_IP[n>>2] |= 0xFF << (8*(n & 0x03)); \ - NVIC_ISER[n>>5] = 1 << (n & 0x1F) +#define OS_X_INIT(n) \ + NVIC_IP[n >> 2] |= 0xFF << (8 * (n & 0x03)); \ + NVIC_ISER[n >> 5] = 1 << (n & 0x1F) #else -#define OS_X_INIT(n) NVIC_IP[n] = 0xFF; \ - NVIC_ISER[n>>5] = 1 << (n & 0x1F) +#define OS_X_INIT(n) \ + NVIC_IP[n] = 0xFF; \ + NVIC_ISER[n >> 5] = 1 << (n & 0x1F) #endif -#define OS_X_LOCK(n) NVIC_ICER[n>>5] = 1 << (n & 0x1F) -#define OS_X_UNLOCK(n) NVIC_ISER[n>>5] = 1 << (n & 0x1F) +#define OS_X_LOCK(n) NVIC_ICER[n >> 5] = 1 << (n & 0x1F) +#define OS_X_UNLOCK(n) NVIC_ISER[n >> 5] = 1 << (n & 0x1F) /* Core Debug registers */ -#define DEMCR (*((volatile U32 *)0xE000EDFC)) +#define DEMCR (*((volatile U32 *)0xE000EDFC)) /* ITM registers */ -#define ITM_CONTROL (*((volatile U32 *)0xE0000E80)) -#define ITM_ENABLE (*((volatile U32 *)0xE0000E00)) -#define ITM_PORT30_U32 (*((volatile U32 *)0xE0000078)) -#define ITM_PORT31_U32 (*((volatile U32 *)0xE000007C)) -#define ITM_PORT31_U16 (*((volatile U16 *)0xE000007C)) -#define ITM_PORT31_U8 (*((volatile U8 *)0xE000007C)) +#define ITM_CONTROL (*((volatile U32 *)0xE0000E80)) +#define ITM_ENABLE (*((volatile U32 *)0xE0000E00)) +#define ITM_PORT30_U32 (*((volatile U32 *)0xE0000078)) +#define ITM_PORT31_U32 (*((volatile U32 *)0xE000007C)) +#define ITM_PORT31_U16 (*((volatile U16 *)0xE000007C)) +#define ITM_PORT31_U8 (*((volatile U8 *)0xE000007C)) /* Variables */ extern BIT dbg_msg; /* Functions */ #ifdef __USE_EXCLUSIVE_ACCESS - #define rt_inc(p) while(__strex((__ldrex(p)+1),p)) - #define rt_dec(p) while(__strex((__ldrex(p)-1),p)) +#define rt_inc(p) while (__strex((__ldrex(p) + 1), p)) +#define rt_dec(p) while (__strex((__ldrex(p) - 1), p)) #else - #define rt_inc(p) __disable_irq();(*p)++;__enable_irq(); - #define rt_dec(p) __disable_irq();(*p)--;__enable_irq(); +#define rt_inc(p) \ + __disable_irq(); \ + (*p)++; \ + __enable_irq(); +#define rt_dec(p) \ + __disable_irq(); \ + (*p)--; \ + __enable_irq(); #endif -__inline static U32 rt_inc_qi (U32 size, U8 *count, U8 *first) { - U32 cnt,c2; +__inline static U32 rt_inc_qi(U32 size, U8 *count, U8 *first) { + U32 cnt, c2; #ifdef __USE_EXCLUSIVE_ACCESS do { if ((cnt = __ldrex(count)) == size) { __clrex(); - return (cnt); } - } while (__strex(cnt+1, count)); + return (cnt); + } + } while (__strex(cnt + 1, count)); do { c2 = (cnt = __ldrex(first)) + 1; - if (c2 == size) c2 = 0; + if (c2 == size) + c2 = 0; } while (__strex(c2, first)); #else __disable_irq(); if ((cnt = *count) < size) { - *count = cnt+1; + *count = cnt + 1; c2 = (cnt = *first) + 1; - if (c2 == size) c2 = 0; + if (c2 == size) + c2 = 0; *first = c2; } - __enable_irq (); + __enable_irq(); #endif return (cnt); } -__inline static void rt_systick_init (void) { - NVIC_ST_RELOAD = os_get_trv(); +__inline static void rt_systick_init(void) { + NVIC_ST_RELOAD = os_get_trv(); NVIC_ST_CURRENT = 0; #if (SYSTICK_EXTERNAL_CLOCK) - NVIC_ST_CTRL = 0x0003; + NVIC_ST_CTRL = 0x0003; #else - NVIC_ST_CTRL = 0x0007; + NVIC_ST_CTRL = 0x0007; #endif - NVIC_SYS_PRI3 |= 0xFF000000; + NVIC_SYS_PRI3 |= 0xFF000000; } -__inline static void rt_svc_init (void) { +__inline static void rt_svc_init(void) { #if !(__TARGET_ARCH_6S_M) - int sh,prigroup; + int sh, prigroup; #endif NVIC_SYS_PRI3 |= 0x00FF0000; #if (__TARGET_ARCH_6S_M) - NVIC_SYS_PRI2 |= (NVIC_SYS_PRI3<<(8+1)) & 0xFC000000; + NVIC_SYS_PRI2 |= (NVIC_SYS_PRI3 << (8 + 1)) & 0xFC000000; #else - sh = 8 - __clz (~((NVIC_SYS_PRI3 << 8) & 0xFF000000)); + sh = 8 - __clz(~((NVIC_SYS_PRI3 << 8) & 0xFF000000)); prigroup = ((NVIC_AIR_CTRL >> 8) & 0x07); if (prigroup >= sh) { sh = prigroup + 1; } - NVIC_SYS_PRI2 = ((0xFEFFFFFF << sh) & 0xFF000000) | (NVIC_SYS_PRI2 & 0x00FFFFFF); + NVIC_SYS_PRI2 = + ((0xFEFFFFFF << sh) & 0xFF000000) | (NVIC_SYS_PRI2 & 0x00FFFFFF); #endif } -extern void rt_set_PSP (U32 stack); -extern U32 rt_get_PSP (void); -extern void os_set_env (void); -extern void *_alloc_box (void *box_mem); -extern int _free_box (void *box_mem, void *box); +extern void rt_set_PSP(U32 stack); +extern U32 rt_get_PSP(void); +extern void os_set_env(void); +extern void *_alloc_box(void *box_mem); +extern int _free_box(void *box_mem, void *box); -extern void rt_init_stack (P_TCB p_TCB, FUNCP task_body); -extern void rt_ret_val (P_TCB p_TCB, U32 v0); -extern void rt_ret_val2 (P_TCB p_TCB, U32 v0, U32 v1); +extern void rt_init_stack(P_TCB p_TCB, FUNCP task_body); +extern void rt_ret_val(P_TCB p_TCB, U32 v0); +extern void rt_ret_val2(P_TCB p_TCB, U32 v0, U32 v1); -extern void dbg_init (void); -extern void dbg_task_notify (P_TCB p_tcb, BOOL create); -extern void dbg_task_switch (U32 task_id); +extern void dbg_init(void); +extern void dbg_task_notify(P_TCB p_tcb, BOOL create); +extern void dbg_task_switch(U32 task_id); #ifdef DBG_MSG #define DBG_INIT() dbg_init() -#define DBG_TASK_NOTIFY(p_tcb,create) if (dbg_msg) dbg_task_notify(p_tcb,create) -#define DBG_TASK_SWITCH(task_id) if (dbg_msg && (os_tsk.new_tsk != os_tsk.run)) \ - dbg_task_switch(task_id) +#define DBG_TASK_NOTIFY(p_tcb, create) \ + if (dbg_msg) \ + dbg_task_notify(p_tcb, create) +#define DBG_TASK_SWITCH(task_id) \ + if (dbg_msg && (os_tsk.new_tsk != os_tsk.run)) \ + dbg_task_switch(task_id) #else #define DBG_INIT() -#define DBG_TASK_NOTIFY(p_tcb,create) +#define DBG_TASK_NOTIFY(p_tcb, create) #define DBG_TASK_SWITCH(task_id) #endif /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_List.c b/rtos/rtx/TARGET_CORTEX_M/rt_List.c index 47e54af..47ae211 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_List.c +++ b/rtos/rtx/TARGET_CORTEX_M/rt_List.c @@ -32,32 +32,30 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" -#include "RTX_Conf.h" -#include "rt_System.h" #include "rt_List.h" +#include "RTX_Conf.h" +#include "rt_HAL_CM.h" +#include "rt_System.h" #include "rt_Task.h" #include "rt_Time.h" -#include "rt_HAL_CM.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Global Variables *---------------------------------------------------------------------------*/ /* List head of chained ready tasks */ -struct OS_XCB os_rdy; +struct OS_XCB os_rdy; /* List head of chained delay tasks */ -struct OS_XCB os_dly; - +struct OS_XCB os_dly; /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_put_prio -----------------------------------*/ -void rt_put_prio (P_XCB p_CB, P_TCB p_task) { +void rt_put_prio(P_XCB p_CB, P_TCB p_task) { /* Put task identified with "p_task" into list ordered by priority. */ /* "p_CB" points to head of list; list has always an element at end with */ /* a priority less than "p_task->prio". */ @@ -83,16 +81,14 @@ void rt_put_prio (P_XCB p_CB, P_TCB p_task) { p_CB2->p_rlnk = p_task; } p_task->p_rlnk = (P_TCB)p_CB; - } - else { + } else { p_task->p_rlnk = NULL; } } - /*--------------------------- rt_get_first ----------------------------------*/ -P_TCB rt_get_first (P_XCB p_CB) { +P_TCB rt_get_first(P_XCB p_CB) { /* Get task at head of list: it is the task with highest priority. */ /* "p_CB" points to head of list. */ P_TCB p_first; @@ -105,17 +101,15 @@ P_TCB rt_get_first (P_XCB p_CB) { p_first->p_lnk = NULL; } p_first->p_rlnk = NULL; - } - else { + } else { p_first->p_lnk = NULL; } return (p_first); } - /*--------------------------- rt_put_rdy_first ------------------------------*/ -void rt_put_rdy_first (P_TCB p_task) { +void rt_put_rdy_first(P_TCB p_task) { /* Put task identified with "p_task" at the head of the ready list. The */ /* task must have at least a priority equal to highest priority in list. */ p_task->p_lnk = os_rdy.p_lnk; @@ -123,10 +117,9 @@ void rt_put_rdy_first (P_TCB p_task) { os_rdy.p_lnk = p_task; } - /*--------------------------- rt_put_rdy_last ------------------------------*/ -void rt_put_rdy_last (P_TCB p_task) { +void rt_put_rdy_last(P_TCB p_task) { /* Put task identified with "p_task" at the tail of the ready list. The */ /* task must have at least a priority equal to lowest priority in list. */ P_TCB p_last; @@ -146,10 +139,9 @@ void rt_put_rdy_last (P_TCB p_task) { } } - /*--------------------------- rt_get_same_rdy_prio --------------------------*/ -P_TCB rt_get_same_rdy_prio (void) { +P_TCB rt_get_same_rdy_prio(void) { /* Remove a task of same priority from ready list if any exists. Other- */ /* wise return NULL. */ P_TCB p_first; @@ -162,10 +154,9 @@ P_TCB rt_get_same_rdy_prio (void) { return (NULL); } - /*--------------------------- rt_resort_prio --------------------------------*/ -void rt_resort_prio (P_TCB p_task) { +void rt_resort_prio(P_TCB p_task) { /* Re-sort ordered lists after the priority of 'p_task' has changed. */ P_TCB p_CB; @@ -175,26 +166,25 @@ void rt_resort_prio (P_TCB p_task) { p_CB = (P_TCB)&os_rdy; goto res; } - } - else { + } else { p_CB = p_task->p_rlnk; while (p_CB->cb_type == TCB) { /* Find a header of this task chain list. */ p_CB = p_CB->p_rlnk; } -res:rt_rmv_list (p_task); - rt_put_prio ((P_XCB)p_CB, p_task); + res: + rt_rmv_list(p_task); + rt_put_prio((P_XCB)p_CB, p_task); } } - /*--------------------------- rt_put_dly ------------------------------------*/ -void rt_put_dly (P_TCB p_task, U16 delay) { +void rt_put_dly(P_TCB p_task, U16 delay) { /* Put a task identified with "p_task" into chained delay wait list using */ /* a delay value of "delay". */ P_TCB p; - U32 delta,idelay = delay; + U32 delta, idelay = delay; p = (P_TCB)&os_dly; if (p->p_dlnk == NULL) { @@ -206,7 +196,8 @@ void rt_put_dly (P_TCB p_task, U16 delay) { while (delta < idelay) { if (p->p_dlnk == NULL) { /* End of list found */ -last: p_task->p_dlnk = NULL; + last: + p_task->p_dlnk = NULL; p->p_dlnk = p_task; p_task->p_blnk = p; p->delta_time = (U16)(idelay - delta); @@ -227,10 +218,9 @@ last: p_task->p_dlnk = NULL; p->delta_time -= p_task->delta_time; } - /*--------------------------- rt_dec_dly ------------------------------------*/ -void rt_dec_dly (void) { +void rt_dec_dly(void) { /* Decrement delta time of list head: remove tasks having a value of zero.*/ P_TCB p_rdy; @@ -250,26 +240,25 @@ void rt_dec_dly (void) { } p_rdy->p_rlnk = NULL; } - rt_put_prio (&os_rdy, p_rdy); + rt_put_prio(&os_rdy, p_rdy); os_dly.delta_time = p_rdy->delta_time; if (p_rdy->state == WAIT_ITV) { /* Calculate the next time for interval wait. */ p_rdy->delta_time = p_rdy->interval_time + (U16)os_time; } - p_rdy->state = READY; + p_rdy->state = READY; os_dly.p_dlnk = p_rdy->p_dlnk; if (p_rdy->p_dlnk != NULL) { - p_rdy->p_dlnk->p_blnk = (P_TCB)&os_dly; + p_rdy->p_dlnk->p_blnk = (P_TCB)&os_dly; p_rdy->p_dlnk = NULL; } p_rdy->p_blnk = NULL; } } - /*--------------------------- rt_rmv_list -----------------------------------*/ -void rt_rmv_list (P_TCB p_task) { +void rt_rmv_list(P_TCB p_task) { /* Remove task identified with "p_task" from ready, semaphore or mailbox */ /* waiting list if enqueued. */ P_TCB p_b; @@ -294,10 +283,9 @@ void rt_rmv_list (P_TCB p_task) { } } - /*--------------------------- rt_rmv_dly ------------------------------------*/ -void rt_rmv_dly (P_TCB p_task) { +void rt_rmv_dly(P_TCB p_task) { /* Remove task identified with "p_task" from delay list if enqueued. */ P_TCB p_b; @@ -310,8 +298,7 @@ void rt_rmv_dly (P_TCB p_task) { p_b->delta_time += p_task->delta_time; p_task->p_dlnk->p_blnk = p_b; p_task->p_dlnk = NULL; - } - else { + } else { /* 'p_task' is at the end of list */ p_b->delta_time = 0; } @@ -319,25 +306,21 @@ void rt_rmv_dly (P_TCB p_task) { } } - /*--------------------------- rt_psq_enq ------------------------------------*/ -void rt_psq_enq (OS_ID entry, U32 arg) { +void rt_psq_enq(OS_ID entry, U32 arg) { /* Insert post service request "entry" into ps-queue. */ U32 idx; - idx = rt_inc_qi (os_psq->size, &os_psq->count, &os_psq->first); + idx = rt_inc_qi(os_psq->size, &os_psq->count, &os_psq->first); if (idx < os_psq->size) { - os_psq->q[idx].id = entry; + os_psq->q[idx].id = entry; os_psq->q[idx].arg = arg; - } - else { - os_error (OS_ERR_FIFO_OVF); + } else { + os_error(OS_ERR_FIFO_OVF); } } - /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_List.h b/rtos/rtx/TARGET_CORTEX_M/rt_List.h index d68a127..114182d 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_List.h +++ b/rtos/rtx/TARGET_CORTEX_M/rt_List.h @@ -31,38 +31,36 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ - +#include "rt_TypeDef.h" /* Definitions */ /* Values for 'cb_type' */ -#define TCB 0 -#define MCB 1 -#define SCB 2 -#define MUCB 3 -#define HCB 4 +#define TCB 0 +#define MCB 1 +#define SCB 2 +#define MUCB 3 +#define HCB 4 /* Variables */ extern struct OS_XCB os_rdy; extern struct OS_XCB os_dly; /* Functions */ -extern void rt_put_prio (P_XCB p_CB, P_TCB p_task); -extern P_TCB rt_get_first (P_XCB p_CB); -extern void rt_put_rdy_first (P_TCB p_task); -extern void rt_put_rdy_last (P_TCB p_task); -extern P_TCB rt_get_same_rdy_prio (void); -extern void rt_resort_prio (P_TCB p_task); -extern void rt_put_dly (P_TCB p_task, U16 delay); -extern void rt_dec_dly (void); -extern void rt_rmv_list (P_TCB p_task); -extern void rt_rmv_dly (P_TCB p_task); -extern void rt_psq_enq (OS_ID entry, U32 arg); +extern void rt_put_prio(P_XCB p_CB, P_TCB p_task); +extern P_TCB rt_get_first(P_XCB p_CB); +extern void rt_put_rdy_first(P_TCB p_task); +extern void rt_put_rdy_last(P_TCB p_task); +extern P_TCB rt_get_same_rdy_prio(void); +extern void rt_resort_prio(P_TCB p_task); +extern void rt_put_dly(P_TCB p_task, U16 delay); +extern void rt_dec_dly(void); +extern void rt_rmv_list(P_TCB p_task); +extern void rt_rmv_dly(P_TCB p_task); +extern void rt_psq_enq(OS_ID entry, U32 arg); /* This is a fast macro generating in-line code */ #define rt_rdy_prio(void) (os_rdy.p_lnk->prio) - /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_Mailbox.c b/rtos/rtx/TARGET_CORTEX_M/rt_Mailbox.c index ef28b76..41c57d9 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_Mailbox.c +++ b/rtos/rtx/TARGET_CORTEX_M/rt_Mailbox.c @@ -32,59 +32,55 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" -#include "RTX_Conf.h" -#include "rt_System.h" -#include "rt_List.h" #include "rt_Mailbox.h" -#include "rt_MemBox.h" -#include "rt_Task.h" +#include "RTX_Conf.h" #include "rt_HAL_CM.h" - +#include "rt_List.h" +#include "rt_MemBox.h" +#include "rt_System.h" +#include "rt_Task.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_mbx_init -----------------------------------*/ -void rt_mbx_init (OS_ID mailbox, U16 mbx_size) { +void rt_mbx_init(OS_ID mailbox, U16 mbx_size) { /* Initialize a mailbox */ P_MCB p_MCB = mailbox; p_MCB->cb_type = MCB; - p_MCB->state = 0; - p_MCB->isr_st = 0; - p_MCB->p_lnk = NULL; - p_MCB->first = 0; - p_MCB->last = 0; - p_MCB->count = 0; - p_MCB->size = (mbx_size + sizeof(void *) - sizeof(struct OS_MCB)) / - (U32)sizeof (void *); + p_MCB->state = 0; + p_MCB->isr_st = 0; + p_MCB->p_lnk = NULL; + p_MCB->first = 0; + p_MCB->last = 0; + p_MCB->count = 0; + p_MCB->size = + (mbx_size + sizeof(void *) - sizeof(struct OS_MCB)) / (U32)sizeof(void *); } - /*--------------------------- rt_mbx_send -----------------------------------*/ -OS_RESULT rt_mbx_send (OS_ID mailbox, void *p_msg, U16 timeout) { +OS_RESULT rt_mbx_send(OS_ID mailbox, void *p_msg, U16 timeout) { /* Send message to a mailbox */ P_MCB p_MCB = mailbox; P_TCB p_TCB; if ((p_MCB->p_lnk != NULL) && (p_MCB->state == 1)) { /* A task is waiting for message */ - p_TCB = rt_get_first ((P_XCB)p_MCB); + p_TCB = rt_get_first((P_XCB)p_MCB); #ifdef __CMSIS_RTOS - rt_ret_val2(p_TCB, 0x10/*osEventMessage*/, (U32)p_msg); + rt_ret_val2(p_TCB, 0x10 /*osEventMessage*/, (U32)p_msg); #else *p_TCB->msg = p_msg; - rt_ret_val (p_TCB, OS_R_MBX); + rt_ret_val(p_TCB, OS_R_MBX); #endif - rt_rmv_dly (p_TCB); - rt_dispatch (p_TCB); - } - else { + rt_rmv_dly(p_TCB); + rt_dispatch(p_TCB); + } else { /* Store message in mailbox queue */ if (p_MCB->count == p_MCB->size) { /* No free message entry, wait for one. If message queue is full, */ @@ -94,22 +90,21 @@ OS_RESULT rt_mbx_send (OS_ID mailbox, void *p_msg, U16 timeout) { return (OS_R_TMO); } if (p_MCB->p_lnk != NULL) { - rt_put_prio ((P_XCB)p_MCB, os_tsk.run); - } - else { + rt_put_prio((P_XCB)p_MCB, os_tsk.run); + } else { p_MCB->p_lnk = os_tsk.run; - os_tsk.run->p_lnk = NULL; + os_tsk.run->p_lnk = NULL; os_tsk.run->p_rlnk = (P_TCB)p_MCB; /* Task is waiting to send a message */ p_MCB->state = 2; } os_tsk.run->msg = p_msg; - rt_block (timeout, WAIT_MBX); + rt_block(timeout, WAIT_MBX); return (OS_R_TMO); } /* Yes, there is a free entry in a mailbox. */ p_MCB->msg[p_MCB->first] = p_msg; - rt_inc (&p_MCB->count); + rt_inc(&p_MCB->count); if (++p_MCB->first == p_MCB->size) { p_MCB->first = 0; } @@ -117,10 +112,9 @@ OS_RESULT rt_mbx_send (OS_ID mailbox, void *p_msg, U16 timeout) { return (OS_R_OK); } - /*--------------------------- rt_mbx_wait -----------------------------------*/ -OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout) { +OS_RESULT rt_mbx_wait(OS_ID mailbox, void **message, U16 timeout) { /* Receive a message; possibly wait for it */ P_MCB p_MCB = mailbox; P_TCB p_TCB; @@ -134,9 +128,9 @@ OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout) { } if ((p_MCB->p_lnk != NULL) && (p_MCB->state == 2)) { /* A task is waiting to send message */ - p_TCB = rt_get_first ((P_XCB)p_MCB); + p_TCB = rt_get_first((P_XCB)p_MCB); #ifdef __CMSIS_RTOS - rt_ret_val(p_TCB, 0/*osOK*/); + rt_ret_val(p_TCB, 0 /*osOK*/); #else rt_ret_val(p_TCB, OS_R_OK); #endif @@ -144,11 +138,10 @@ OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout) { if (++p_MCB->first == p_MCB->size) { p_MCB->first = 0; } - rt_rmv_dly (p_TCB); - rt_dispatch (p_TCB); - } - else { - rt_dec (&p_MCB->count); + rt_rmv_dly(p_TCB); + rt_dispatch(p_TCB); + } else { + rt_dec(&p_MCB->count); } return (OS_R_OK); } @@ -157,9 +150,8 @@ OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout) { return (OS_R_TMO); } if (p_MCB->p_lnk != NULL) { - rt_put_prio ((P_XCB)p_MCB, os_tsk.run); - } - else { + rt_put_prio((P_XCB)p_MCB, os_tsk.run); + } else { p_MCB->p_lnk = os_tsk.run; os_tsk.run->p_lnk = NULL; os_tsk.run->p_rlnk = (P_TCB)p_MCB; @@ -173,10 +165,9 @@ OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout) { return (OS_R_TMO); } - /*--------------------------- rt_mbx_check ----------------------------------*/ -OS_RESULT rt_mbx_check (OS_ID mailbox) { +OS_RESULT rt_mbx_check(OS_ID mailbox) { /* Check for free space in a mailbox. Returns the number of messages */ /* that can be stored to a mailbox. It returns 0 when mailbox is full. */ P_MCB p_MCB = mailbox; @@ -184,21 +175,19 @@ OS_RESULT rt_mbx_check (OS_ID mailbox) { return (p_MCB->size - p_MCB->count); } - /*--------------------------- isr_mbx_send ----------------------------------*/ -void isr_mbx_send (OS_ID mailbox, void *p_msg) { +void isr_mbx_send(OS_ID mailbox, void *p_msg) { /* Same function as "os_mbx_send", but to be called by ISRs. */ P_MCB p_MCB = mailbox; - rt_psq_enq (p_MCB, (U32)p_msg); - rt_psh_req (); + rt_psq_enq(p_MCB, (U32)p_msg); + rt_psh_req(); } - /*--------------------------- isr_mbx_receive -------------------------------*/ -OS_RESULT isr_mbx_receive (OS_ID mailbox, void **message) { +OS_RESULT isr_mbx_receive(OS_ID mailbox, void **message) { /* Receive a message in the interrupt function. The interrupt function */ /* should not wait for a message since this would block the rtx os. */ P_MCB p_MCB = mailbox; @@ -208,10 +197,10 @@ OS_RESULT isr_mbx_receive (OS_ID mailbox, void **message) { *message = p_MCB->msg[p_MCB->last]; if (p_MCB->state == 2) { /* A task is locked waiting to send message */ - rt_psq_enq (p_MCB, 0); - rt_psh_req (); + rt_psq_enq(p_MCB, 0); + rt_psh_req(); } - rt_dec (&p_MCB->count); + rt_dec(&p_MCB->count); if (++p_MCB->last == p_MCB->size) { p_MCB->last = 0; } @@ -220,73 +209,73 @@ OS_RESULT isr_mbx_receive (OS_ID mailbox, void **message) { return (OS_R_OK); } - /*--------------------------- rt_mbx_psh ------------------------------------*/ -void rt_mbx_psh (P_MCB p_CB, void *p_msg) { +void rt_mbx_psh(P_MCB p_CB, void *p_msg) { /* Store the message to the mailbox queue or pass it to task directly. */ P_TCB p_TCB; void *mem; - if (p_CB->p_lnk != NULL) switch (p_CB->state) { + if (p_CB->p_lnk != NULL) + switch (p_CB->state) { #ifdef __CMSIS_RTOS case 3: /* Task is waiting to allocate memory, remove it from the waiting list */ mem = rt_alloc_box(p_msg); - if (mem == NULL) break; - p_TCB = rt_get_first ((P_XCB)p_CB); + if (mem == NULL) + break; + p_TCB = rt_get_first((P_XCB)p_CB); rt_ret_val(p_TCB, (U32)mem); p_TCB->state = READY; - rt_rmv_dly (p_TCB); - rt_put_prio (&os_rdy, p_TCB); + rt_rmv_dly(p_TCB); + rt_put_prio(&os_rdy, p_TCB); break; #endif case 2: /* Task is waiting to send a message, remove it from the waiting list */ - p_TCB = rt_get_first ((P_XCB)p_CB); + p_TCB = rt_get_first((P_XCB)p_CB); #ifdef __CMSIS_RTOS - rt_ret_val(p_TCB, 0/*osOK*/); + rt_ret_val(p_TCB, 0 /*osOK*/); #else rt_ret_val(p_TCB, OS_R_OK); #endif p_CB->msg[p_CB->first] = p_TCB->msg; - rt_inc (&p_CB->count); + rt_inc(&p_CB->count); if (++p_CB->first == p_CB->size) { p_CB->first = 0; } p_TCB->state = READY; - rt_rmv_dly (p_TCB); - rt_put_prio (&os_rdy, p_TCB); + rt_rmv_dly(p_TCB); + rt_put_prio(&os_rdy, p_TCB); break; case 1: /* Task is waiting for a message, pass the message to the task directly */ - p_TCB = rt_get_first ((P_XCB)p_CB); + p_TCB = rt_get_first((P_XCB)p_CB); #ifdef __CMSIS_RTOS - rt_ret_val2(p_TCB, 0x10/*osEventMessage*/, (U32)p_msg); + rt_ret_val2(p_TCB, 0x10 /*osEventMessage*/, (U32)p_msg); #else *p_TCB->msg = p_msg; - rt_ret_val (p_TCB, OS_R_MBX); + rt_ret_val(p_TCB, OS_R_MBX); #endif p_TCB->state = READY; - rt_rmv_dly (p_TCB); - rt_put_prio (&os_rdy, p_TCB); + rt_rmv_dly(p_TCB); + rt_put_prio(&os_rdy, p_TCB); break; - } else { - /* No task is waiting for a message, store it to the mailbox queue */ - if (p_CB->count < p_CB->size) { - p_CB->msg[p_CB->first] = p_msg; - rt_inc (&p_CB->count); - if (++p_CB->first == p_CB->size) { - p_CB->first = 0; - } - } - else { - os_error (OS_ERR_MBX_OVF); + } + else { + /* No task is waiting for a message, store it to the mailbox queue */ + if (p_CB->count < p_CB->size) { + p_CB->msg[p_CB->first] = p_msg; + rt_inc(&p_CB->count); + if (++p_CB->first == p_CB->size) { + p_CB->first = 0; } + } else { + os_error(OS_ERR_MBX_OVF); + } } } /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_Mailbox.h b/rtos/rtx/TARGET_CORTEX_M/rt_Mailbox.h index 0c8e2f3..956ef52 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_Mailbox.h +++ b/rtos/rtx/TARGET_CORTEX_M/rt_Mailbox.h @@ -31,18 +31,16 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ - +#include "rt_TypeDef.h" /* Functions */ -extern void rt_mbx_init (OS_ID mailbox, U16 mbx_size); -extern OS_RESULT rt_mbx_send (OS_ID mailbox, void *p_msg, U16 timeout); -extern OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout); -extern OS_RESULT rt_mbx_check (OS_ID mailbox); -extern void isr_mbx_send (OS_ID mailbox, void *p_msg); -extern OS_RESULT isr_mbx_receive (OS_ID mailbox, void **message); -extern void rt_mbx_psh (P_MCB p_CB, void *p_msg); - +extern void rt_mbx_init(OS_ID mailbox, U16 mbx_size); +extern OS_RESULT rt_mbx_send(OS_ID mailbox, void *p_msg, U16 timeout); +extern OS_RESULT rt_mbx_wait(OS_ID mailbox, void **message, U16 timeout); +extern OS_RESULT rt_mbx_check(OS_ID mailbox); +extern void isr_mbx_send(OS_ID mailbox, void *p_msg); +extern OS_RESULT isr_mbx_receive(OS_ID mailbox, void **message); +extern void rt_mbx_psh(P_MCB p_CB, void *p_msg); /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_MemBox.c b/rtos/rtx/TARGET_CORTEX_M/rt_MemBox.c index 5b96ae0..58a67d5 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_MemBox.c +++ b/rtos/rtx/TARGET_CORTEX_M/rt_MemBox.c @@ -32,36 +32,34 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" -#include "RTX_Conf.h" -#include "rt_System.h" #include "rt_MemBox.h" +#include "RTX_Conf.h" #include "rt_HAL_CM.h" +#include "rt_System.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Global Functions *---------------------------------------------------------------------------*/ - /*--------------------------- _init_box -------------------------------------*/ -int _init_box (void *box_mem, U32 box_size, U32 blk_size) { +int _init_box(void *box_mem, U32 box_size, U32 blk_size) { /* Initialize memory block system, returns 0 if OK, 1 if fails. */ void *end; void *blk; void *next; - U32 sizeof_bm; + U32 sizeof_bm; /* Create memory structure. */ if (blk_size & BOX_ALIGN_8) { /* Memory blocks 8-byte aligned. */ blk_size = ((blk_size & ~BOX_ALIGN_8) + 7) & ~7; - sizeof_bm = (sizeof (struct OS_BM) + 7) & ~7; - } - else { + sizeof_bm = (sizeof(struct OS_BM) + 7) & ~7; + } else { /* Memory blocks 4-byte aligned. */ blk_size = (blk_size + 3) & ~3; - sizeof_bm = sizeof (struct OS_BM); + sizeof_bm = sizeof(struct OS_BM); } if (blk_size == 0) { return (1); @@ -70,17 +68,18 @@ int _init_box (void *box_mem, U32 box_size, U32 blk_size) { return (1); } /* Create a Memory structure. */ - blk = ((U8 *) box_mem) + sizeof_bm; - ((P_BM) box_mem)->free = blk; - end = ((U8 *) box_mem) + box_size; - ((P_BM) box_mem)->end = end; - ((P_BM) box_mem)->blk_size = blk_size; + blk = ((U8 *)box_mem) + sizeof_bm; + ((P_BM)box_mem)->free = blk; + end = ((U8 *)box_mem) + box_size; + ((P_BM)box_mem)->end = end; + ((P_BM)box_mem)->blk_size = blk_size; /* Link all free blocks using offsets. */ - end = ((U8 *) end) - blk_size; - while (1) { - next = ((U8 *) blk) + blk_size; - if (next > end) break; + end = ((U8 *)end) - blk_size; + while (1) { + next = ((U8 *)blk) + blk_size; + if (next > end) + break; *((void **)blk) = next; blk = next; } @@ -91,42 +90,42 @@ int _init_box (void *box_mem, U32 box_size, U32 blk_size) { /*--------------------------- rt_alloc_box ----------------------------------*/ -void *rt_alloc_box (void *box_mem) { +void *rt_alloc_box(void *box_mem) { /* Allocate a memory block and return start address. */ void **free; #ifndef __USE_EXCLUSIVE_ACCESS - int irq_dis; + int irq_dis; - irq_dis = __disable_irq (); - free = ((P_BM) box_mem)->free; + irq_dis = __disable_irq(); + free = ((P_BM)box_mem)->free; if (free) { - ((P_BM) box_mem)->free = *free; + ((P_BM)box_mem)->free = *free; } - if (!irq_dis) __enable_irq (); + if (!irq_dis) + __enable_irq(); #else do { - if ((free = (void **)__ldrex(&((P_BM) box_mem)->free)) == 0) { + if ((free = (void **)__ldrex(&((P_BM)box_mem)->free)) == 0) { __clrex(); break; } - } while (__strex((U32)*free, &((P_BM) box_mem)->free)); + } while (__strex((U32)*free, &((P_BM)box_mem)->free)); #endif return (free); } - /*--------------------------- _calloc_box -----------------------------------*/ -void *_calloc_box (void *box_mem) { +void *_calloc_box(void *box_mem) { /* Allocate a 0-initialized memory block and return start address. */ void *free; U32 *p; U32 i; - free = _alloc_box (box_mem); - if (free) { + free = _alloc_box(box_mem); + if (free) { p = free; - for (i = ((P_BM) box_mem)->blk_size; i; i -= 4) { + for (i = ((P_BM)box_mem)->blk_size; i; i -= 4) { *p = 0; p++; } @@ -134,28 +133,29 @@ void *_calloc_box (void *box_mem) { return (free); } - /*--------------------------- rt_free_box -----------------------------------*/ -int rt_free_box (void *box_mem, void *box) { - /* Free a memory block, returns 0 if OK, 1 if box does not belong to box_mem */ +int rt_free_box(void *box_mem, void *box) { + /* Free a memory block, returns 0 if OK, 1 if box does not belong to box_mem + */ #ifndef __USE_EXCLUSIVE_ACCESS int irq_dis; #endif - if (box < box_mem || box >= ((P_BM) box_mem)->end) { + if (box < box_mem || box >= ((P_BM)box_mem)->end) { return (1); } #ifndef __USE_EXCLUSIVE_ACCESS - irq_dis = __disable_irq (); - *((void **)box) = ((P_BM) box_mem)->free; - ((P_BM) box_mem)->free = box; - if (!irq_dis) __enable_irq (); + irq_dis = __disable_irq(); + *((void **)box) = ((P_BM)box_mem)->free; + ((P_BM)box_mem)->free = box; + if (!irq_dis) + __enable_irq(); #else do { - *((void **)box) = (void *)__ldrex(&((P_BM) box_mem)->free); - } while (__strex ((U32)box, &((P_BM) box_mem)->free)); + *((void **)box) = (void *)__ldrex(&((P_BM)box_mem)->free); + } while (__strex((U32)box, &((P_BM)box_mem)->free)); #endif return (0); } @@ -163,4 +163,3 @@ int rt_free_box (void *box_mem, void *box) { /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_MemBox.h b/rtos/rtx/TARGET_CORTEX_M/rt_MemBox.h index c10a1cb..3ce3da8 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_MemBox.h +++ b/rtos/rtx/TARGET_CORTEX_M/rt_MemBox.h @@ -31,16 +31,15 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ - +#include "rt_TypeDef.h" /* Functions */ -#define rt_init_box _init_box -#define rt_calloc_box _calloc_box -extern int _init_box (void *box_mem, U32 box_size, U32 blk_size); -extern void *rt_alloc_box (void *box_mem); -extern void * _calloc_box (void *box_mem); -extern int rt_free_box (void *box_mem, void *box); +#define rt_init_box _init_box +#define rt_calloc_box _calloc_box +extern int _init_box(void *box_mem, U32 box_size, U32 blk_size); +extern void *rt_alloc_box(void *box_mem); +extern void *_calloc_box(void *box_mem); +extern int rt_free_box(void *box_mem, void *box); /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_Mutex.c b/rtos/rtx/TARGET_CORTEX_M/rt_Mutex.c index c7a996b..c387a66 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_Mutex.c +++ b/rtos/rtx/TARGET_CORTEX_M/rt_Mutex.c @@ -32,63 +32,60 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" +#include "rt_Mutex.h" #include "RTX_Conf.h" +#include "rt_HAL_CM.h" #include "rt_List.h" #include "rt_Task.h" -#include "rt_Mutex.h" -#include "rt_HAL_CM.h" - +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_mut_init -----------------------------------*/ -void rt_mut_init (OS_ID mutex) { +void rt_mut_init(OS_ID mutex) { /* Initialize a mutex object */ P_MUCB p_MCB = mutex; p_MCB->cb_type = MUCB; - p_MCB->prio = 0; - p_MCB->level = 0; - p_MCB->p_lnk = NULL; - p_MCB->owner = NULL; + p_MCB->prio = 0; + p_MCB->level = 0; + p_MCB->p_lnk = NULL; + p_MCB->owner = NULL; } - /*--------------------------- rt_mut_delete ---------------------------------*/ #ifdef __CMSIS_RTOS -OS_RESULT rt_mut_delete (OS_ID mutex) { +OS_RESULT rt_mut_delete(OS_ID mutex) { /* Delete a mutex object */ P_MUCB p_MCB = mutex; - P_TCB p_TCB; + P_TCB p_TCB; /* Restore owner task's priority. */ if (p_MCB->level != 0) { p_MCB->owner->prio = p_MCB->prio; if (p_MCB->owner != os_tsk.run) { - rt_resort_prio (p_MCB->owner); + rt_resort_prio(p_MCB->owner); } } while (p_MCB->p_lnk != NULL) { /* A task is waiting for mutex. */ - p_TCB = rt_get_first ((P_XCB)p_MCB); - rt_ret_val(p_TCB, 0/*osOK*/); + p_TCB = rt_get_first((P_XCB)p_MCB); + rt_ret_val(p_TCB, 0 /*osOK*/); rt_rmv_dly(p_TCB); p_TCB->state = READY; - rt_put_prio (&os_rdy, p_TCB); + rt_put_prio(&os_rdy, p_TCB); } if (os_rdy.p_lnk && (os_rdy.p_lnk->prio > os_tsk.run->prio)) { /* preempt running task */ - rt_put_prio (&os_rdy, os_tsk.run); + rt_put_prio(&os_rdy, os_tsk.run); os_tsk.run->state = READY; - rt_dispatch (NULL); + rt_dispatch(NULL); } p_MCB->cb_type = 0; @@ -97,13 +94,12 @@ OS_RESULT rt_mut_delete (OS_ID mutex) { } #endif - /*--------------------------- rt_mut_release --------------------------------*/ -OS_RESULT rt_mut_release (OS_ID mutex) { +OS_RESULT rt_mut_release(OS_ID mutex) { /* Release a mutex object */ P_MUCB p_MCB = mutex; - P_TCB p_TCB; + P_TCB p_TCB; if (p_MCB->level == 0 || p_MCB->owner != os_tsk.run) { /* Unbalanced mutex release or task is not the owner */ @@ -116,56 +112,54 @@ OS_RESULT rt_mut_release (OS_ID mutex) { os_tsk.run->prio = p_MCB->prio; if (p_MCB->p_lnk != NULL) { /* A task is waiting for mutex. */ - p_TCB = rt_get_first ((P_XCB)p_MCB); + p_TCB = rt_get_first((P_XCB)p_MCB); #ifdef __CMSIS_RTOS - rt_ret_val(p_TCB, 0/*osOK*/); + rt_ret_val(p_TCB, 0 /*osOK*/); #else rt_ret_val(p_TCB, OS_R_MUT); #endif - rt_rmv_dly (p_TCB); + rt_rmv_dly(p_TCB); /* A waiting task becomes the owner of this mutex. */ - p_MCB->level = 1; - p_MCB->owner = p_TCB; - p_MCB->prio = p_TCB->prio; + p_MCB->level = 1; + p_MCB->owner = p_TCB; + p_MCB->prio = p_TCB->prio; /* Priority inversion, check which task continues. */ if (os_tsk.run->prio >= rt_rdy_prio()) { - rt_dispatch (p_TCB); - } - else { + rt_dispatch(p_TCB); + } else { /* Ready task has higher priority than running task. */ - rt_put_prio (&os_rdy, os_tsk.run); - rt_put_prio (&os_rdy, p_TCB); + rt_put_prio(&os_rdy, os_tsk.run); + rt_put_prio(&os_rdy, p_TCB); os_tsk.run->state = READY; - p_TCB->state = READY; - rt_dispatch (NULL); + p_TCB->state = READY; + rt_dispatch(NULL); } - } - else { + } else { /* Check if own priority raised by priority inversion. */ if (rt_rdy_prio() > os_tsk.run->prio) { - rt_put_prio (&os_rdy, os_tsk.run); + rt_put_prio(&os_rdy, os_tsk.run); os_tsk.run->state = READY; - rt_dispatch (NULL); + rt_dispatch(NULL); } } return (OS_R_OK); } - /*--------------------------- rt_mut_wait -----------------------------------*/ -OS_RESULT rt_mut_wait (OS_ID mutex, U16 timeout) { +OS_RESULT rt_mut_wait(OS_ID mutex, U16 timeout) { /* Wait for a mutex, continue when mutex is free. */ P_MUCB p_MCB = mutex; if (p_MCB->level == 0) { p_MCB->owner = os_tsk.run; - p_MCB->prio = os_tsk.run->prio; + p_MCB->prio = os_tsk.run->prio; goto inc; } if (p_MCB->owner == os_tsk.run) { /* OK, running task is the owner of this mutex. */ -inc:p_MCB->level++; + inc: + p_MCB->level++; return (OS_R_OK); } /* Mutex owned by another task, wait until released. */ @@ -176,22 +170,19 @@ inc:p_MCB->level++; /* This priority inversion is called priority inheritance. */ if (p_MCB->prio < os_tsk.run->prio) { p_MCB->owner->prio = os_tsk.run->prio; - rt_resort_prio (p_MCB->owner); + rt_resort_prio(p_MCB->owner); } if (p_MCB->p_lnk != NULL) { - rt_put_prio ((P_XCB)p_MCB, os_tsk.run); - } - else { + rt_put_prio((P_XCB)p_MCB, os_tsk.run); + } else { p_MCB->p_lnk = os_tsk.run; - os_tsk.run->p_lnk = NULL; + os_tsk.run->p_lnk = NULL; os_tsk.run->p_rlnk = (P_TCB)p_MCB; } rt_block(timeout, WAIT_MUT); return (OS_R_TMO); } - /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_Mutex.h b/rtos/rtx/TARGET_CORTEX_M/rt_Mutex.h index bf15c4d..c3064f2 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_Mutex.h +++ b/rtos/rtx/TARGET_CORTEX_M/rt_Mutex.h @@ -31,7 +31,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ - +#include "rt_TypeDef.h" /* Functions */ extern void rt_mut_init (OS_ID mutex); extern OS_RESULT rt_mut_delete (OS_ID mutex); diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_Robin.c b/rtos/rtx/TARGET_CORTEX_M/rt_Robin.c index d693dc6..54092a7 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_Robin.c +++ b/rtos/rtx/TARGET_CORTEX_M/rt_Robin.c @@ -32,13 +32,13 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" +#include "rt_Robin.h" #include "RTX_Conf.h" +#include "rt_HAL_CM.h" #include "rt_List.h" #include "rt_Task.h" #include "rt_Time.h" -#include "rt_Robin.h" -#include "rt_HAL_CM.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Global Variables @@ -46,14 +46,13 @@ struct OS_ROBIN os_robin; - /*---------------------------------------------------------------------------- * Global Functions *---------------------------------------------------------------------------*/ /*--------------------------- rt_init_robin ---------------------------------*/ -__weak void rt_init_robin (void) { +__weak void rt_init_robin(void) { /* Initialize Round Robin variables. */ os_robin.task = NULL; os_robin.tout = (U16)os_rrobin; @@ -61,7 +60,7 @@ __weak void rt_init_robin (void) { /*--------------------------- rt_chk_robin ----------------------------------*/ -__weak void rt_chk_robin (void) { +__weak void rt_chk_robin(void) { /* Check if Round Robin timeout expired and switch to the next ready task.*/ P_TCB p_new; @@ -73,12 +72,11 @@ __weak void rt_chk_robin (void) { if (os_robin.time == (U16)os_time) { /* Round Robin timeout has expired, swap Robin tasks. */ os_robin.task = NULL; - p_new = rt_get_first (&os_rdy); - rt_put_prio ((P_XCB)&os_rdy, p_new); + p_new = rt_get_first(&os_rdy); + rt_put_prio((P_XCB)&os_rdy, p_new); } } /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_Semaphore.c b/rtos/rtx/TARGET_CORTEX_M/rt_Semaphore.c index 93ff2bf..769f66b 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_Semaphore.c +++ b/rtos/rtx/TARGET_CORTEX_M/rt_Semaphore.c @@ -32,54 +32,51 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" -#include "RTX_Conf.h" -#include "rt_System.h" -#include "rt_List.h" -#include "rt_Task.h" #include "rt_Semaphore.h" +#include "RTX_Conf.h" #include "rt_HAL_CM.h" - +#include "rt_List.h" +#include "rt_System.h" +#include "rt_Task.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_sem_init -----------------------------------*/ -void rt_sem_init (OS_ID semaphore, U16 token_count) { +void rt_sem_init(OS_ID semaphore, U16 token_count) { /* Initialize a semaphore */ P_SCB p_SCB = semaphore; p_SCB->cb_type = SCB; - p_SCB->p_lnk = NULL; + p_SCB->p_lnk = NULL; p_SCB->tokens = token_count; } - /*--------------------------- rt_sem_delete ---------------------------------*/ #ifdef __CMSIS_RTOS -OS_RESULT rt_sem_delete (OS_ID semaphore) { +OS_RESULT rt_sem_delete(OS_ID semaphore) { /* Delete semaphore */ P_SCB p_SCB = semaphore; P_TCB p_TCB; while (p_SCB->p_lnk != NULL) { /* A task is waiting for token */ - p_TCB = rt_get_first ((P_XCB)p_SCB); + p_TCB = rt_get_first((P_XCB)p_SCB); rt_ret_val(p_TCB, 0); rt_rmv_dly(p_TCB); p_TCB->state = READY; - rt_put_prio (&os_rdy, p_TCB); + rt_put_prio(&os_rdy, p_TCB); } if (os_rdy.p_lnk && (os_rdy.p_lnk->prio > os_tsk.run->prio)) { /* preempt running task */ - rt_put_prio (&os_rdy, os_tsk.run); + rt_put_prio(&os_rdy, os_tsk.run); os_tsk.run->state = READY; - rt_dispatch (NULL); + rt_dispatch(NULL); } p_SCB->cb_type = 0; @@ -88,36 +85,33 @@ OS_RESULT rt_sem_delete (OS_ID semaphore) { } #endif - /*--------------------------- rt_sem_send -----------------------------------*/ -OS_RESULT rt_sem_send (OS_ID semaphore) { +OS_RESULT rt_sem_send(OS_ID semaphore) { /* Return a token to semaphore */ P_SCB p_SCB = semaphore; P_TCB p_TCB; if (p_SCB->p_lnk != NULL) { /* A task is waiting for token */ - p_TCB = rt_get_first ((P_XCB)p_SCB); + p_TCB = rt_get_first((P_XCB)p_SCB); #ifdef __CMSIS_RTOS rt_ret_val(p_TCB, 1); #else rt_ret_val(p_TCB, OS_R_SEM); #endif - rt_rmv_dly (p_TCB); - rt_dispatch (p_TCB); - } - else { + rt_rmv_dly(p_TCB); + rt_dispatch(p_TCB); + } else { /* Store token. */ p_SCB->tokens++; } return (OS_R_OK); } - /*--------------------------- rt_sem_wait -----------------------------------*/ -OS_RESULT rt_sem_wait (OS_ID semaphore, U16 timeout) { +OS_RESULT rt_sem_wait(OS_ID semaphore, U16 timeout) { /* Obtain a token; possibly wait for it */ P_SCB p_SCB = semaphore; @@ -130,9 +124,8 @@ OS_RESULT rt_sem_wait (OS_ID semaphore, U16 timeout) { return (OS_R_TMO); } if (p_SCB->p_lnk != NULL) { - rt_put_prio ((P_XCB)p_SCB, os_tsk.run); - } - else { + rt_put_prio((P_XCB)p_SCB, os_tsk.run); + } else { p_SCB->p_lnk = os_tsk.run; os_tsk.run->p_lnk = NULL; os_tsk.run->p_rlnk = (P_TCB)p_SCB; @@ -141,37 +134,34 @@ OS_RESULT rt_sem_wait (OS_ID semaphore, U16 timeout) { return (OS_R_TMO); } - /*--------------------------- isr_sem_send ----------------------------------*/ -void isr_sem_send (OS_ID semaphore) { +void isr_sem_send(OS_ID semaphore) { /* Same function as "os_sem"send", but to be called by ISRs */ P_SCB p_SCB = semaphore; - rt_psq_enq (p_SCB, 0); - rt_psh_req (); + rt_psq_enq(p_SCB, 0); + rt_psh_req(); } - /*--------------------------- rt_sem_psh ------------------------------------*/ -void rt_sem_psh (P_SCB p_CB) { +void rt_sem_psh(P_SCB p_CB) { /* Check if task has to be waken up */ P_TCB p_TCB; if (p_CB->p_lnk != NULL) { /* A task is waiting for token */ - p_TCB = rt_get_first ((P_XCB)p_CB); - rt_rmv_dly (p_TCB); - p_TCB->state = READY; + p_TCB = rt_get_first((P_XCB)p_CB); + rt_rmv_dly(p_TCB); + p_TCB->state = READY; #ifdef __CMSIS_RTOS rt_ret_val(p_TCB, 1); #else rt_ret_val(p_TCB, OS_R_SEM); #endif - rt_put_prio (&os_rdy, p_TCB); - } - else { + rt_put_prio(&os_rdy, p_TCB); + } else { /* Store token */ p_CB->tokens++; } @@ -180,4 +170,3 @@ void rt_sem_psh (P_SCB p_CB) { /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_Semaphore.h b/rtos/rtx/TARGET_CORTEX_M/rt_Semaphore.h index ec45480..3ebcdfb 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_Semaphore.h +++ b/rtos/rtx/TARGET_CORTEX_M/rt_Semaphore.h @@ -31,16 +31,15 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ - +#include "rt_TypeDef.h" /* Functions */ -extern void rt_sem_init (OS_ID semaphore, U16 token_count); +extern void rt_sem_init(OS_ID semaphore, U16 token_count); extern OS_RESULT rt_sem_delete(OS_ID semaphore); -extern OS_RESULT rt_sem_send (OS_ID semaphore); -extern OS_RESULT rt_sem_wait (OS_ID semaphore, U16 timeout); -extern void isr_sem_send (OS_ID semaphore); -extern void rt_sem_psh (P_SCB p_CB); +extern OS_RESULT rt_sem_send(OS_ID semaphore); +extern OS_RESULT rt_sem_wait(OS_ID semaphore, U16 timeout); +extern void isr_sem_send(OS_ID semaphore); +extern void rt_sem_psh(P_SCB p_CB); /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_System.c b/rtos/rtx/TARGET_CORTEX_M/rt_System.c index 022c433..e8fa1fa 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_System.c +++ b/rtos/rtx/TARGET_CORTEX_M/rt_System.c @@ -32,17 +32,17 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" -#include "RTX_Conf.h" -#include "rt_Task.h" #include "rt_System.h" +#include "RTX_Conf.h" #include "rt_Event.h" +#include "rt_HAL_CM.h" #include "rt_List.h" #include "rt_Mailbox.h" -#include "rt_Semaphore.h" -#include "rt_Time.h" #include "rt_Robin.h" -#include "rt_HAL_CM.h" +#include "rt_Semaphore.h" +#include "rt_Task.h" +#include "rt_Time.h" +#include "rt_TypeDef.h" #include "hal_sleep.h" #include "hal_timer.h" @@ -63,26 +63,26 @@ int os_tick_irqn; static volatile BIT os_lock; static volatile BIT os_psh_flag; -static U8 pend_flags; -static U32 systick_lock_tick; -static U32 systick_lock_ts; +static U8 pend_flags; +static U32 systick_lock_tick; +static U32 systick_lock_ts; /*---------------------------------------------------------------------------- * Global Functions *---------------------------------------------------------------------------*/ -#if defined (__CC_ARM) -__asm void $$RTX$$version (void) { - /* Export a version number symbol for a version control. */ +#if defined(__CC_ARM) +__asm void $$RTX$$version(void) { + /* Export a version number symbol for a version control. */ - EXPORT __RL_RTX_VER + EXPORT __RL_RTX_VER -__RL_RTX_VER EQU 0x450 + __RL_RTX_VER EQU 0x450 } #endif /*--------------------------- rt_suspend ------------------------------------*/ -U32 rt_suspend (void) { +U32 rt_suspend(void) { /* Suspend OS scheduler */ U32 delta = 0xFFFF; U32 start_tick; @@ -92,13 +92,14 @@ U32 rt_suspend (void) { rt_tsk_lock(); systick_lock_tick = NVIC_ST_CURRENT; systick_lock_ts = hal_sys_timer_get(); - if (start_tick != 0 && (systick_lock_tick == 0 || start_tick < systick_lock_tick)) { + if (start_tick != 0 && + (systick_lock_tick == 0 || start_tick < systick_lock_tick)) { #if defined(DEBUG_SLEEP) && (DEBUG_SLEEP >= 1) - TRACE(6,"[%u/0x%X][%2u/%u] rt_suspend corner case: %02u -> %02u", - TICKS_TO_MS(hal_sys_timer_get()), hal_sys_timer_get(), NVIC_ST_CURRENT, os_time, - start_tick, systick_lock_tick); + TRACE(6, "[%u/0x%X][%2u/%u] rt_suspend corner case: %02u -> %02u", + TICKS_TO_MS(hal_sys_timer_get()), hal_sys_timer_get(), + NVIC_ST_CURRENT, os_time, start_tick, systick_lock_tick); #endif - pend_flags |= 1; + pend_flags |= 1; } if (pend_flags) { delta = 0; @@ -121,7 +122,8 @@ U32 rt_suspend (void) { } #else if (os_tmr.next) { - if (os_tmr.tcnt < delta) delta = os_tmr.tcnt; + if (os_tmr.tcnt < delta) + delta = os_tmr.tcnt; } #endif @@ -129,22 +131,23 @@ U32 rt_suspend (void) { } /*--------------------------- rt_resume -------------------------------------*/ -void rt_resume (U32 sleep_time) { +void rt_resume(U32 sleep_time) { /* Resume OS scheduler after suspend */ - //P_TCB next; - U32 delta; - U32 resume_ts; - U32 unlock_ts; - U32 systick_remain; - U32 sleep_ticks; - U8 tick_running = 0; + // P_TCB next; + U32 delta; + U32 resume_ts; + U32 unlock_ts; + U32 systick_remain; + U32 sleep_ticks; + U8 tick_running = 0; const U32 reload = (NVIC_ST_RELOAD + 1); __disable_irq(); resume_ts = hal_sys_timer_get(); __enable_irq(); - sleep_ticks = (resume_ts - systick_lock_ts) * (OS_CLOCK_NOMINAL / CONFIG_SYSTICK_HZ_NOMINAL); + sleep_ticks = (resume_ts - systick_lock_ts) * + (OS_CLOCK_NOMINAL / CONFIG_SYSTICK_HZ_NOMINAL); if (systick_lock_tick == 0) { sleep_time = sleep_ticks / reload; systick_remain = reload - sleep_ticks % reload; @@ -177,12 +180,13 @@ _inc_sleep_time: if (os_dly.p_dlnk) { delta = sleep_time; if (delta >= os_dly.delta_time) { - delta -= os_dly.delta_time; + delta -= os_dly.delta_time; os_time += os_dly.delta_time; os_dly.delta_time = 1; while (os_dly.p_dlnk) { rt_dec_dly(); - if (delta == 0) break; + if (delta == 0) + break; delta--; os_time++; } @@ -192,7 +196,7 @@ _inc_sleep_time: } rt_psh_req(); } else { - os_time += delta; + os_time += delta; os_dly.delta_time -= delta; } } else { @@ -211,11 +215,12 @@ _inc_sleep_time: if (os_tmr.next) { delta = sleep_time; if (delta >= os_tmr.tcnt) { - delta -= os_tmr.tcnt; + delta -= os_tmr.tcnt; os_tmr.tcnt = 1; while (os_tmr.next) { rt_tmr_tick(); - if (delta == 0) break; + if (delta == 0) + break; delta--; } } else { @@ -234,9 +239,11 @@ _inc_sleep_time: #if defined(DEBUG_SLEEP) && (DEBUG_SLEEP >= 1) if (sleep_time > 0) { - TRACE(7,"[%u/0x%X][%2u/%u] rt_resume: sleep_ticks=%u sleep_time=%u systick_remain=%u", - TICKS_TO_MS(hal_sys_timer_get()), hal_sys_timer_get(), NVIC_ST_CURRENT, os_time, - sleep_ticks, sleep_time, systick_remain); + TRACE(7, + "[%u/0x%X][%2u/%u] rt_resume: sleep_ticks=%u sleep_time=%u " + "systick_remain=%u", + TICKS_TO_MS(hal_sys_timer_get()), hal_sys_timer_get(), + NVIC_ST_CURRENT, os_time, sleep_ticks, sleep_time, systick_remain); } #endif @@ -251,12 +258,15 @@ _task_unlock: // systick_remain value range: [1, reload] if (sleep_ticks >= systick_remain) { #if defined(DEBUG_SLEEP) && (DEBUG_SLEEP >= 1) - TRACE(6,"[%u/0x%X][%2u/%u] rt_resume corner case: sleep_ticks=%u systick_remain=%u", - TICKS_TO_MS(hal_sys_timer_get()), hal_sys_timer_get(), NVIC_ST_CURRENT, os_time, - sleep_ticks, systick_remain); + TRACE(6, + "[%u/0x%X][%2u/%u] rt_resume corner case: sleep_ticks=%u " + "systick_remain=%u", + TICKS_TO_MS(hal_sys_timer_get()), hal_sys_timer_get(), + NVIC_ST_CURRENT, os_time, sleep_ticks, systick_remain); // Update timestamp since traces also consume time unlock_ts = hal_sys_timer_get(); - sleep_ticks = (unlock_ts - resume_ts) * (OS_CLOCK_NOMINAL / CONFIG_SYSTICK_HZ_NOMINAL); + sleep_ticks = (unlock_ts - resume_ts) * + (OS_CLOCK_NOMINAL / CONFIG_SYSTICK_HZ_NOMINAL); #endif delta = sleep_ticks - systick_remain; sleep_time = delta / reload + 1; @@ -270,10 +280,11 @@ _task_unlock: systick_remain = 0; } if (systick_remain) { - NVIC_ST_RELOAD = systick_remain; + NVIC_ST_RELOAD = systick_remain; NVIC_ST_CURRENT = 0; - while (NVIC_ST_CURRENT == 0); - NVIC_ST_RELOAD = reload - 1; + while (NVIC_ST_CURRENT == 0) + ; + NVIC_ST_RELOAD = reload - 1; } else { NVIC_ST_CURRENT = 0; } @@ -287,71 +298,67 @@ _task_unlock: } } - /*--------------------------- rt_tsk_lock -----------------------------------*/ -void rt_tsk_lock (void) { +void rt_tsk_lock(void) { /* Prevent task switching by locking out scheduler */ if (os_tick_irqn < 0) { OS_LOCK(); os_lock = __TRUE; - OS_UNPEND (&pend_flags); + OS_UNPEND(&pend_flags); } else { OS_X_LOCK(os_tick_irqn); os_lock = __TRUE; - OS_X_UNPEND (&pend_flags); + OS_X_UNPEND(&pend_flags); } } - /*--------------------------- rt_tsk_unlock ---------------------------------*/ -void rt_tsk_unlock (void) { +void rt_tsk_unlock(void) { /* Unlock scheduler and re-enable task switching */ if (os_tick_irqn < 0) { OS_UNLOCK(); os_lock = __FALSE; - OS_PEND (pend_flags, os_psh_flag); + OS_PEND(pend_flags, os_psh_flag); os_psh_flag = __FALSE; } else { OS_X_UNLOCK(os_tick_irqn); os_lock = __FALSE; - OS_X_PEND (pend_flags, os_psh_flag); + OS_X_PEND(pend_flags, os_psh_flag); os_psh_flag = __FALSE; } // Allow cpu sleep hal_cpu_wake_unlock(HAL_CPU_WAKE_LOCK_USER_RTOS); } - /*--------------------------- rt_psh_req ------------------------------------*/ -void rt_psh_req (void) { +void rt_psh_req(void) { /* Initiate a post service handling request if required. */ if (os_lock == __FALSE) { - OS_PEND_IRQ (); - } - else { + OS_PEND_IRQ(); + } else { os_psh_flag = __TRUE; - // Prohibit cpu sleep when an OS service request is enqueued during os lock (rt_suspend) + // Prohibit cpu sleep when an OS service request is enqueued during os lock + // (rt_suspend) hal_cpu_wake_lock(HAL_CPU_WAKE_LOCK_USER_RTOS); } } - /*--------------------------- rt_pop_req ------------------------------------*/ -void rt_pop_req (void) { +void rt_pop_req(void) { /* Process an ISR post service requests. */ struct OS_XCB *p_CB; P_TCB next; - U32 idx; + U32 idx; os_tsk.run->state = READY; if (os_tsk.run == &os_idle_TCB) { - rt_put_rdy_last (os_tsk.run); + rt_put_rdy_last(os_tsk.run); } else { - rt_put_rdy_first (os_tsk.run); + rt_put_rdy_first(os_tsk.run); } idx = os_psq->last; @@ -359,44 +366,39 @@ void rt_pop_req (void) { p_CB = os_psq->q[idx].id; if (p_CB->cb_type == TCB) { /* Is of TCB type */ - rt_evt_psh ((P_TCB)p_CB, (U16)os_psq->q[idx].arg); - } - else if (p_CB->cb_type == MCB) { + rt_evt_psh((P_TCB)p_CB, (U16)os_psq->q[idx].arg); + } else if (p_CB->cb_type == MCB) { /* Is of MCB type */ - rt_mbx_psh ((P_MCB)p_CB, (void *)os_psq->q[idx].arg); - } - else { + rt_mbx_psh((P_MCB)p_CB, (void *)os_psq->q[idx].arg); + } else { /* Must be of SCB type */ - rt_sem_psh ((P_SCB)p_CB); + rt_sem_psh((P_SCB)p_CB); } - if (++idx == os_psq->size) idx = 0; - rt_dec (&os_psq->count); + if (++idx == os_psq->size) + idx = 0; + rt_dec(&os_psq->count); } os_psq->last = idx; - next = rt_get_first (&os_rdy); - rt_switch_req (next); + next = rt_get_first(&os_rdy); + rt_switch_req(next); } - /*--------------------------- os_tick_init ----------------------------------*/ -__weak int os_tick_init (void) { +__weak int os_tick_init(void) { /* Initialize SysTick timer as system tick timer. */ - rt_systick_init (); - return (-1); /* Return IRQ number of SysTick timer */ + rt_systick_init(); + return (-1); /* Return IRQ number of SysTick timer */ } - /*--------------------------- os_tick_irqack --------------------------------*/ -__weak void os_tick_irqack (void) { - /* Acknowledge timer interrupt. */ +__weak void os_tick_irqack(void) { /* Acknowledge timer interrupt. */ } - /*--------------------------- rt_systick ------------------------------------*/ -void rt_systick (void) { +void rt_systick(void) { /* Check for system clock update, suspend running task. */ P_TCB next; @@ -405,41 +407,41 @@ void rt_systick (void) { #endif os_tsk.run->state = READY; - rt_put_rdy_first (os_tsk.run); + rt_put_rdy_first(os_tsk.run); /* Check Round Robin timeout. */ - rt_chk_robin (); + rt_chk_robin(); /* Update delays. */ os_time++; - rt_dec_dly (); + rt_dec_dly(); /* Check the user timers. */ #ifdef __CMSIS_RTOS sysTimerTick(); #else - rt_tmr_tick (); + rt_tmr_tick(); #endif /* Switch back to highest ready task */ - next = rt_get_first (&os_rdy); - rt_switch_req (next); + next = rt_get_first(&os_rdy); + rt_switch_req(next); } /*--------------------------- rt_stk_check ----------------------------------*/ -__weak void rt_stk_check (void) { - /* Check for stack overflow. */ - if (os_tsk.run->task_id == 0x01) { - // TODO: For the main thread the check should be done against the main heap pointer - } else { - if ((os_tsk.run->tsk_stack < (U32)os_tsk.run->stack) || - (os_tsk.run->stack[0] != MAGIC_WORD)) { - os_error (OS_ERR_STK_OVF); - } +__weak void rt_stk_check(void) { + /* Check for stack overflow. */ + if (os_tsk.run->task_id == 0x01) { + // TODO: For the main thread the check should be done against the main heap + // pointer + } else { + if ((os_tsk.run->tsk_stack < (U32)os_tsk.run->stack) || + (os_tsk.run->stack[0] != MAGIC_WORD)) { + os_error(OS_ERR_STK_OVF); } + } } /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_System.h b/rtos/rtx/TARGET_CORTEX_M/rt_System.h index 91db648..3400453 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_System.h +++ b/rtos/rtx/TARGET_CORTEX_M/rt_System.h @@ -31,22 +31,21 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ - +#include "rt_TypeDef.h" /* Variables */ -#define os_psq ((P_PSQ)&os_fifo) +#define os_psq ((P_PSQ)&os_fifo) extern int os_tick_irqn; /* Functions */ -extern U32 rt_suspend (void); -extern void rt_resume (U32 sleep_time); -extern void rt_tsk_lock (void); -extern void rt_tsk_unlock (void); -extern void rt_psh_req (void); -extern void rt_pop_req (void); -extern void rt_systick (void); -extern void rt_stk_check (void); +extern U32 rt_suspend(void); +extern void rt_resume(U32 sleep_time); +extern void rt_tsk_lock(void); +extern void rt_tsk_unlock(void); +extern void rt_psh_req(void); +extern void rt_pop_req(void); +extern void rt_systick(void); +extern void rt_stk_check(void); /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_Task.c b/rtos/rtx/TARGET_CORTEX_M/rt_Task.c index 98c8160..feae106 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_Task.c +++ b/rtos/rtx/TARGET_CORTEX_M/rt_Task.c @@ -32,14 +32,14 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" -#include "RTX_Conf.h" -#include "rt_System.h" #include "rt_Task.h" +#include "RTX_Conf.h" +#include "rt_HAL_CM.h" #include "rt_List.h" #include "rt_MemBox.h" #include "rt_Robin.h" -#include "rt_HAL_CM.h" +#include "rt_System.h" +#include "rt_TypeDef.h" #include "hal_timer.h" @@ -53,32 +53,28 @@ struct OS_TSK os_tsk; /* Task Control Blocks of idle demon */ struct OS_TCB os_idle_TCB; -static U32 rtx_get_hwticks(void) -{ - return hal_sys_timer_get(); -} - +static U32 rtx_get_hwticks(void) { return hal_sys_timer_get(); } /*---------------------------------------------------------------------------- * Local Functions *---------------------------------------------------------------------------*/ -OS_TID rt_get_TID (void) { +OS_TID rt_get_TID(void) { U32 tid; for (tid = 1; tid <= os_maxtaskrun; tid++) { - if (os_active_TCB[tid-1] == NULL) { + if (os_active_TCB[tid - 1] == NULL) { return ((OS_TID)tid); } } return (0); } -#if defined (__CC_ARM) && !defined (__MICROLIB) +#if defined(__CC_ARM) && !defined(__MICROLIB) /*--------------------------- __user_perthread_libspace ---------------------*/ -extern void *__libspace_start; +extern void *__libspace_start; -void *__user_perthread_libspace (void) { +void *__user_perthread_libspace(void) { /* Provide a separate libspace for each task. */ if (os_tsk.run == NULL) { /* RTX not running yet. */ @@ -90,71 +86,66 @@ void *__user_perthread_libspace (void) { /*--------------------------- rt_init_context -------------------------------*/ -void rt_init_context (P_TCB p_TCB, U8 priority, FUNCP task_body) { +void rt_init_context(P_TCB p_TCB, U8 priority, FUNCP task_body) { /* Initialize general part of the Task Control Block. */ p_TCB->cb_type = TCB; - p_TCB->state = READY; - p_TCB->prio = priority; - p_TCB->p_lnk = NULL; - p_TCB->p_rlnk = NULL; - p_TCB->p_dlnk = NULL; - p_TCB->p_blnk = NULL; - p_TCB->delta_time = 0; + p_TCB->state = READY; + p_TCB->prio = priority; + p_TCB->p_lnk = NULL; + p_TCB->p_rlnk = NULL; + p_TCB->p_dlnk = NULL; + p_TCB->p_blnk = NULL; + p_TCB->delta_time = 0; p_TCB->interval_time = 0; - p_TCB->events = 0; - p_TCB->waits = 0; + p_TCB->events = 0; + p_TCB->waits = 0; p_TCB->stack_frame = 0; - rt_init_stack (p_TCB, task_body); + rt_init_stack(p_TCB, task_body); } - /*--------------------------- rt_switch_req ---------------------------------*/ -void rt_switch_req (P_TCB p_new) { +void rt_switch_req(P_TCB p_new) { /* Switch to next task (identified by "p_new"). */ - os_tsk.new_tsk = p_new; + os_tsk.new_tsk = p_new; #if __RTX_CPU_STATISTICS__ if (os_tsk.run != p_new) { - os_tsk.run->swap_out_time = HWTICKS_TO_MS(rtx_get_hwticks()); - p_new->swap_in_time = HWTICKS_TO_MS(rtx_get_hwticks()); + os_tsk.run->swap_out_time = HWTICKS_TO_MS(rtx_get_hwticks()); + p_new->swap_in_time = HWTICKS_TO_MS(rtx_get_hwticks()); } #endif p_new->state = RUNNING; DBG_TASK_SWITCH(p_new->task_id); } - /*--------------------------- rt_dispatch -----------------------------------*/ -void rt_dispatch (P_TCB next_TCB) { +void rt_dispatch(P_TCB next_TCB) { /* Dispatch next task if any identified or dispatch highest ready task */ /* "next_TCB" identifies a task to run or has value NULL (=no next task) */ if (next_TCB == NULL) { /* Running task was blocked: continue with highest ready task */ - next_TCB = rt_get_first (&os_rdy); - rt_switch_req (next_TCB); - } - else { + next_TCB = rt_get_first(&os_rdy); + rt_switch_req(next_TCB); + } else { /* Check which task continues */ if (next_TCB->prio > os_tsk.run->prio) { /* preempt running task */ - rt_put_rdy_first (os_tsk.run); + rt_put_rdy_first(os_tsk.run); os_tsk.run->state = READY; - rt_switch_req (next_TCB); - } - else { + rt_switch_req(next_TCB); + } else { /* put next task into ready list, no task switch takes place */ next_TCB->state = READY; - rt_put_prio (&os_rdy, next_TCB); + rt_put_prio(&os_rdy, next_TCB); } } } - /*--------------------------- rt_block --------------------------------------*/ -void rt_block (U16 timeout, U8 block_state) { +void rt_block(U16 timeout, U8 block_state) { /* Block running task and choose next ready task. */ /* "timeout" sets a time-out value or is 0xffff (=no time-out). */ /* "block_state" defines the appropriate task state */ @@ -162,33 +153,31 @@ void rt_block (U16 timeout, U8 block_state) { if (timeout) { if (timeout < 0xffff) { - rt_put_dly (os_tsk.run, timeout); + rt_put_dly(os_tsk.run, timeout); } os_tsk.run->state = block_state; - next_TCB = rt_get_first (&os_rdy); - rt_switch_req (next_TCB); + next_TCB = rt_get_first(&os_rdy); + rt_switch_req(next_TCB); } } - /*--------------------------- rt_tsk_pass -----------------------------------*/ -void rt_tsk_pass (void) { +void rt_tsk_pass(void) { /* Allow tasks of same priority level to run cooperatively.*/ P_TCB p_new; p_new = rt_get_same_rdy_prio(); if (p_new != NULL) { - rt_put_prio ((P_XCB)&os_rdy, os_tsk.run); + rt_put_prio((P_XCB)&os_rdy, os_tsk.run); os_tsk.run->state = READY; - rt_switch_req (p_new); + rt_switch_req(p_new); } } - /*--------------------------- rt_tsk_self -----------------------------------*/ -OS_TID rt_tsk_self (void) { +OS_TID rt_tsk_self(void) { /* Return own task identifier value. */ if (os_tsk.run == NULL) { return (0); @@ -196,72 +185,71 @@ OS_TID rt_tsk_self (void) { return (os_tsk.run->task_id); } - /*--------------------------- rt_tsk_prio -----------------------------------*/ -OS_RESULT rt_tsk_prio (OS_TID task_id, U8 new_prio) { +OS_RESULT rt_tsk_prio(OS_TID task_id, U8 new_prio) { /* Change execution priority of a task to "new_prio". */ P_TCB p_task; if (task_id == 0) { /* Change execution priority of calling task. */ os_tsk.run->prio = new_prio; -run:if (rt_rdy_prio() > new_prio) { - rt_put_prio (&os_rdy, os_tsk.run); - os_tsk.run->state = READY; - rt_dispatch (NULL); + run: + if (rt_rdy_prio() > new_prio) { + rt_put_prio(&os_rdy, os_tsk.run); + os_tsk.run->state = READY; + rt_dispatch(NULL); } return (OS_R_OK); } /* Find the task in the "os_active_TCB" array. */ - if (task_id > os_maxtaskrun || os_active_TCB[task_id-1] == NULL) { + if (task_id > os_maxtaskrun || os_active_TCB[task_id - 1] == NULL) { /* Task with "task_id" not found or not started. */ return (OS_R_NOK); } - p_task = os_active_TCB[task_id-1]; + p_task = os_active_TCB[task_id - 1]; p_task->prio = new_prio; if (p_task == os_tsk.run) { goto run; } - rt_resort_prio (p_task); + rt_resort_prio(p_task); if (p_task->state == READY) { /* Task enqueued in a ready list. */ - p_task = rt_get_first (&os_rdy); - rt_dispatch (p_task); + p_task = rt_get_first(&os_rdy); + rt_dispatch(p_task); } return (OS_R_OK); } /*--------------------------- rt_tsk_delete ---------------------------------*/ -OS_RESULT rt_tsk_delete (OS_TID task_id) { +OS_RESULT rt_tsk_delete(OS_TID task_id) { /* Terminate the task identified with "task_id". */ P_TCB task_context; if (task_id == 0 || task_id == os_tsk.run->task_id) { /* Terminate itself. */ - os_tsk.run->state = INACTIVE; - os_tsk.run->tsk_stack = rt_get_PSP (); - rt_stk_check (); - os_active_TCB[os_tsk.run->task_id-1] = NULL; + os_tsk.run->state = INACTIVE; + os_tsk.run->tsk_stack = rt_get_PSP(); + rt_stk_check(); + os_active_TCB[os_tsk.run->task_id - 1] = NULL; os_tsk.run->stack = NULL; DBG_TASK_NOTIFY(os_tsk.run, __FALSE); os_tsk.run = NULL; - rt_dispatch (NULL); + rt_dispatch(NULL); /* The program should never come to this point. */ - } - else { + } else { /* Find the task in the "os_active_TCB" array. */ - if (task_id > os_maxtaskrun || os_active_TCB[task_id-1] == NULL) { + if (task_id > os_maxtaskrun || os_active_TCB[task_id - 1] == NULL) { /* Task with "task_id" not found or not started. */ return (OS_R_NOK); } - task_context = os_active_TCB[task_id-1]; - rt_rmv_list (task_context); - rt_rmv_dly (task_context); - os_active_TCB[task_id-1] = NULL; + task_context = os_active_TCB[task_id - 1]; + rt_rmv_list(task_context); + rt_rmv_dly(task_context); + os_active_TCB[task_id - 1] = NULL; task_context->stack = NULL; DBG_TASK_NOTIFY(task_context, __FALSE); @@ -269,13 +257,12 @@ OS_RESULT rt_tsk_delete (OS_TID task_id) { return (OS_R_OK); } - /*--------------------------- rt_sys_init -----------------------------------*/ #ifdef __CMSIS_RTOS -void rt_sys_init (void) { +void rt_sys_init(void) { #else -void rt_sys_init (FUNCP first_task, U32 prio_stksz, void *stk) { +void rt_sys_init(FUNCP first_task, U32 prio_stksz, void *stk) { #endif /* Initialize system and start up task declared with "first_task". */ U32 i; @@ -294,58 +281,57 @@ void rt_sys_init (FUNCP first_task, U32 prio_stksz, void *stk) { #if __RTX_CPU_STATISTICS__ os_idle_TCB.name = (U8 *)"os_idle"; #endif - rt_init_context (&os_idle_TCB, 0, os_idle_demon); + rt_init_context(&os_idle_TCB, 0, os_idle_demon); /* Set up ready list: initially empty */ os_rdy.cb_type = HCB; - os_rdy.p_lnk = NULL; + os_rdy.p_lnk = NULL; /* Set up delay list: initially empty */ os_dly.cb_type = HCB; - os_dly.p_dlnk = NULL; - os_dly.p_blnk = NULL; + os_dly.p_dlnk = NULL; + os_dly.p_blnk = NULL; os_dly.delta_time = 0; /* Fix SP and systemvariables to assume idle task is running */ /* Transform main program into idle task by assuming idle TCB */ #ifndef __CMSIS_RTOS - rt_set_PSP (os_idle_TCB.tsk_stack+32); + rt_set_PSP(os_idle_TCB.tsk_stack + 32); #endif os_tsk.run = &os_idle_TCB; os_tsk.run->state = RUNNING; /* Initialize ps queue */ os_psq->first = 0; - os_psq->last = 0; - os_psq->size = os_fifo_size; + os_psq->last = 0; + os_psq->size = os_fifo_size; #if __RTX_CPU_STATISTICS__ os_tsk.run->swap_in_time = HWTICKS_TO_MS(rtx_get_hwticks()); #endif - rt_init_robin (); + rt_init_robin(); /* Intitialize SVC and PendSV */ - rt_svc_init (); + rt_svc_init(); #ifndef __CMSIS_RTOS /* Intitialize and start system clock timer */ - os_tick_irqn = os_tick_init (); + os_tick_irqn = os_tick_init(); if (os_tick_irqn >= 0) { OS_X_INIT(os_tick_irqn); } /* Start up first user task before entering the endless loop */ - rt_tsk_create (first_task, prio_stksz, stk, NULL); + rt_tsk_create(first_task, prio_stksz, stk, NULL); #endif } - /*--------------------------- rt_sys_start ----------------------------------*/ #ifdef __CMSIS_RTOS -void rt_sys_start (void) { +void rt_sys_start(void) { /* Start system */ /* Intitialize and start system clock timer */ - os_tick_irqn = os_tick_init (); + os_tick_irqn = os_tick_init(); if (os_tick_irqn >= 0) { OS_X_INIT(os_tick_irqn); } @@ -356,348 +342,357 @@ void rt_sys_start (void) { // Debug functions //------------------------------------------------------------------------------ -#include "plat_addr_map.h" #include "hal_location.h" #include "hal_trace.h" +#include "plat_addr_map.h" #define RTX_DUMP_VERBOSE struct IRQ_STACK_FRAME_T { - uint32_t r0; - uint32_t r1; - uint32_t r2; - uint32_t r3; - uint32_t r12; - uint32_t lr; - uint32_t pc; - uint32_t xpsr; + uint32_t r0; + uint32_t r1; + uint32_t r2; + uint32_t r3; + uint32_t r12; + uint32_t lr; + uint32_t pc; + uint32_t xpsr; }; extern uint32_t __StackTop[]; -static inline uint32_t get_IPSR(void) -{ +static inline uint32_t get_IPSR(void) { uint32_t result; - asm volatile ("MRS %0, ipsr" : "=r" (result) ); - return(result); + asm volatile("MRS %0, ipsr" : "=r"(result)); + return (result); } -static inline uint32_t get_PSP(void) -{ +static inline uint32_t get_PSP(void) { uint32_t result; - asm volatile ("MRS %0, psp" : "=r" (result) ); - return(result); + asm volatile("MRS %0, psp" : "=r"(result)); + return (result); } -static inline struct IRQ_STACK_FRAME_T *_rtx_get_irq_stack_frame(P_TCB tcb) -{ - uint32_t sp; +static inline struct IRQ_STACK_FRAME_T *_rtx_get_irq_stack_frame(P_TCB tcb) { + uint32_t sp; - if (tcb == NULL) { - return NULL; - } - if (tcb == os_tsk.run && get_IPSR() == 0) { - return NULL; - } - if (tcb == os_tsk.run) { - sp = get_PSP(); - } else { - sp = tcb->tsk_stack; - } - if ((sp & 3) || !hal_trace_address_writable(sp)) { - return NULL; - } + if (tcb == NULL) { + return NULL; + } + if (tcb == os_tsk.run && get_IPSR() == 0) { + return NULL; + } + if (tcb == os_tsk.run) { + sp = get_PSP(); + } else { + sp = tcb->tsk_stack; + } + if ((sp & 3) || !hal_trace_address_writable(sp)) { + return NULL; + } - if (tcb != os_tsk.run) { - // r4-r11 - sp += 4 * 8; - if (tcb->stack_frame) { - // s16-s31 - sp += 4 * 16; - } + if (tcb != os_tsk.run) { + // r4-r11 + sp += 4 * 8; + if (tcb->stack_frame) { + // s16-s31 + sp += 4 * 16; } + } - return (struct IRQ_STACK_FRAME_T *)sp; + return (struct IRQ_STACK_FRAME_T *)sp; } FLASH_TEXT_LOC -void rt_tsk_show(P_TCB tcb) -{ - static const char * const state_list[] = { - "INACTIVE", "READY", "RUNNING", "WAIT_DLY", "WAIT_ITV", "WAIT_OR", "WAIT_AND", "WAIT_SEM", "WAIT_MBX", "WAIT_MUT", "BAD", - }; - const char *task_st_str; - uint32_t idx; - struct IRQ_STACK_FRAME_T *frame; +void rt_tsk_show(P_TCB tcb) { + static const char *const state_list[] = { + "INACTIVE", "READY", "RUNNING", "WAIT_DLY", "WAIT_ITV", "WAIT_OR", + "WAIT_AND", "WAIT_SEM", "WAIT_MBX", "WAIT_MUT", "BAD", + }; + const char *task_st_str; + uint32_t idx; + struct IRQ_STACK_FRAME_T *frame; - if (tcb) { - if (tcb->cb_type == TCB && ((tcb->task_id >= 1 && tcb->task_id <= os_maxtaskrun) || tcb->task_id == 255) && - tcb->ptask && tcb->stack) { - if (tcb->state < ARRAY_SIZE(state_list)) { - idx = tcb->state; - } else { - idx = ARRAY_SIZE(state_list) - 1; - } - task_st_str = state_list[idx]; - REL_TRACE_NOCRLF_NOTS(1,"--- Task %3u", tcb->task_id); + if (tcb) { + if (tcb->cb_type == TCB && + ((tcb->task_id >= 1 && tcb->task_id <= os_maxtaskrun) || + tcb->task_id == 255) && + tcb->ptask && tcb->stack) { + if (tcb->state < ARRAY_SIZE(state_list)) { + idx = tcb->state; + } else { + idx = ARRAY_SIZE(state_list) - 1; + } + task_st_str = state_list[idx]; + REL_TRACE_NOCRLF_NOTS(1, "--- Task %3u", tcb->task_id); - REL_TRACE_NOTS(4," tcb=0x%08X prio=%u state=%-8s ptask=0x%08X", (uint32_t)tcb, tcb->prio, task_st_str, (uint32_t)tcb->ptask); + REL_TRACE_NOTS(4, " tcb=0x%08X prio=%u state=%-8s ptask=0x%08X", + (uint32_t)tcb, tcb->prio, task_st_str, + (uint32_t)tcb->ptask); #if __RTX_CPU_STATISTICS__ - if(tcb->name || tcb->task_id == 1) { - REL_TRACE_NOTS(1," name=%s", tcb->name ? (const char *)tcb->name : "main"); - } + if (tcb->name || tcb->task_id == 1) { + REL_TRACE_NOTS(1, " name=%s", + tcb->name ? (const char *)tcb->name : "main"); + } #endif #ifdef RTX_DUMP_VERBOSE - REL_TRACE_NOTS(3," p_lnk=0x%08X p_rlnk=0x%08X p_dlnk=0x%08X", - (uint32_t)tcb->p_lnk, (uint32_t)tcb->p_rlnk, (uint32_t)tcb->p_dlnk); - REL_TRACE_NOTS(3," p_blnk=0x%08X delta_time=%u interval_time=%u", - (uint32_t)tcb->p_blnk, tcb->delta_time, tcb->interval_time); - REL_TRACE_NOTS(3," events=0x%04X waits=0x%04X msg=0x%08X", - tcb->events, tcb->waits, (uint32_t)tcb->msg); - REL_TRACE_NOTS(2," priv_stack(stack_size)=%4u tsk_stack(sp)=0x%08X", - tcb->priv_stack, tcb->tsk_stack); - REL_TRACE_NOTS(3," stack(top)=0x%08X stack_frame=%u stk_msk:0x%04x", - (uint32_t)tcb->stack, tcb->stack_frame, tcb->stack[0]); + REL_TRACE_NOTS(3, " p_lnk=0x%08X p_rlnk=0x%08X p_dlnk=0x%08X", + (uint32_t)tcb->p_lnk, (uint32_t)tcb->p_rlnk, + (uint32_t)tcb->p_dlnk); + REL_TRACE_NOTS(3, " p_blnk=0x%08X delta_time=%u interval_time=%u", + (uint32_t)tcb->p_blnk, tcb->delta_time, + tcb->interval_time); + REL_TRACE_NOTS(3, " events=0x%04X waits=0x%04X msg=0x%08X", + tcb->events, tcb->waits, (uint32_t)tcb->msg); + REL_TRACE_NOTS(2, " priv_stack(stack_size)=%4u tsk_stack(sp)=0x%08X", + tcb->priv_stack, tcb->tsk_stack); + REL_TRACE_NOTS(3, " stack(top)=0x%08X stack_frame=%u stk_msk:0x%04x", + (uint32_t)tcb->stack, tcb->stack_frame, tcb->stack[0]); #ifdef __RTX_CPU_STATISTICS__ - REL_TRACE_NOTS(2," swap_in_time=%u swap_out_time=%u", - tcb->swap_in_time, tcb->swap_out_time); - REL_TRACE_NOCRLF_NOTS(0," after last switch "); - if (tcb->swap_in_time <= tcb->swap_out_time) - REL_TRACE_NOTS(1,"task runtime %u ms", tcb->swap_out_time - tcb->swap_in_time); - else - REL_TRACE_NOTS(1,"task still runing, now %d", HWTICKS_TO_MS(rtx_get_hwticks())); + REL_TRACE_NOTS(2, " swap_in_time=%u swap_out_time=%u", + tcb->swap_in_time, tcb->swap_out_time); + REL_TRACE_NOCRLF_NOTS(0, " after last switch "); + if (tcb->swap_in_time <= tcb->swap_out_time) + REL_TRACE_NOTS(1, "task runtime %u ms", + tcb->swap_out_time - tcb->swap_in_time); + else + REL_TRACE_NOTS(1, "task still runing, now %d", + HWTICKS_TO_MS(rtx_get_hwticks())); #endif #endif /*RTX_DUMP_VERBOSE*/ - frame = _rtx_get_irq_stack_frame(tcb); - if (frame) { - uint32_t stack_end; - uint32_t search_cnt, print_cnt; + frame = _rtx_get_irq_stack_frame(tcb); + if (frame) { + uint32_t stack_end; + uint32_t search_cnt, print_cnt; - REL_TRACE_NOTS(0," "); - REL_TRACE_NOTS(4," R0 =0x%08X R1=0x%08X R2=0x%08X R3 =0x%08X", frame->r0, frame->r1, frame->r2, frame->r3); - REL_TRACE_NOTS(4," R12=0x%08X LR=0x%08X PC=0x%08X XPSR=0x%08X", frame->r12, frame->lr, frame->pc, frame->xpsr); + REL_TRACE_NOTS(0, " "); + REL_TRACE_NOTS(4, " R0 =0x%08X R1=0x%08X R2=0x%08X R3 =0x%08X", + frame->r0, frame->r1, frame->r2, frame->r3); + REL_TRACE_NOTS(4, " R12=0x%08X LR=0x%08X PC=0x%08X XPSR=0x%08X", + frame->r12, frame->lr, frame->pc, frame->xpsr); - stack_end = (uint32_t)tcb->stack + tcb->priv_stack; - if (stack_end > tcb->tsk_stack) { - search_cnt = (stack_end - tcb->tsk_stack) / 4; - if (search_cnt > 512) { - search_cnt = 512; - } - print_cnt = 10; - hal_trace_print_backtrace(tcb->tsk_stack, search_cnt, print_cnt); - } - } - } else { - REL_TRACE_NOTS(0,"--- Task BAD"); + stack_end = (uint32_t)tcb->stack + tcb->priv_stack; + if (stack_end > tcb->tsk_stack) { + search_cnt = (stack_end - tcb->tsk_stack) / 4; + if (search_cnt > 512) { + search_cnt = 512; + } + print_cnt = 10; + hal_trace_print_backtrace(tcb->tsk_stack, search_cnt, print_cnt); } + } } else { - REL_TRACE_NOTS(0,"--- Task NONE"); + REL_TRACE_NOTS(0, "--- Task BAD"); } + } else { + REL_TRACE_NOTS(0, "--- Task NONE"); + } } FLASH_TEXT_LOC -void rtx_show_current_thread(void) -{ - REL_TRACE_NOTS(1,"Current Task : %u", os_tsk.run ? os_tsk.run->task_id : 0); - REL_TRACE_NOTS(1,"New Running Task: %u", os_tsk.new_tsk ? os_tsk.new_tsk->task_id : 0); - REL_TRACE_IMM_NOTS(0," "); +void rtx_show_current_thread(void) { + REL_TRACE_NOTS(1, "Current Task : %u", + os_tsk.run ? os_tsk.run->task_id : 0); + REL_TRACE_NOTS(1, "New Running Task: %u", + os_tsk.new_tsk ? os_tsk.new_tsk->task_id : 0); + REL_TRACE_IMM_NOTS(0, " "); } FLASH_TEXT_LOC -void rtx_show_ready_threads(void) -{ - P_TCB tcb; - uint32_t i; +void rtx_show_ready_threads(void) { + P_TCB tcb; + uint32_t i; - REL_TRACE_NOTS(0,"Ready Tasks:"); - if (os_rdy.p_lnk) { - tcb = os_rdy.p_lnk; - i = 0; - do { - REL_TRACE_NOCRLF_NOTS(1,"%u ", tcb->task_id); - tcb = tcb->p_lnk; - i++; - } while (tcb && i < os_maxtaskrun); - REL_TRACE_NOTS(0," "); - if (tcb) { - REL_TRACE_NOTS(2,"*** Error: List corrupted? count=%u next=0x%08X\n", i, (uint32_t)tcb); - } - } else { - REL_TRACE_NOTS(0,""); + REL_TRACE_NOTS(0, "Ready Tasks:"); + if (os_rdy.p_lnk) { + tcb = os_rdy.p_lnk; + i = 0; + do { + REL_TRACE_NOCRLF_NOTS(1, "%u ", tcb->task_id); + tcb = tcb->p_lnk; + i++; + } while (tcb && i < os_maxtaskrun); + REL_TRACE_NOTS(0, " "); + if (tcb) { + REL_TRACE_NOTS(2, "*** Error: List corrupted? count=%u next=0x%08X\n", i, + (uint32_t)tcb); } - REL_TRACE_IMM_NOTS(0," "); + } else { + REL_TRACE_NOTS(0, ""); + } + REL_TRACE_IMM_NOTS(0, " "); } FLASH_TEXT_LOC -void rtx_show_delay_threads(void) -{ - P_TCB tcb; - uint32_t i; +void rtx_show_delay_threads(void) { + P_TCB tcb; + uint32_t i; - REL_TRACE_NOTS(0,"Delay Tasks:"); - if (os_dly.p_dlnk) { - tcb = os_dly.p_dlnk; - i = 0; - do { - REL_TRACE_NOCRLF_NOTS(1,"%u ", tcb->task_id); - tcb = tcb->p_dlnk; - i++; - } while (tcb && i < os_maxtaskrun); - REL_TRACE_NOTS(0," "); - if (tcb) { - REL_TRACE_NOTS(2,"*** Error: List corrupted? count=%u next=0x%08X\n", i, (uint32_t)tcb); - } - } else { - REL_TRACE_NOTS(0,""); + REL_TRACE_NOTS(0, "Delay Tasks:"); + if (os_dly.p_dlnk) { + tcb = os_dly.p_dlnk; + i = 0; + do { + REL_TRACE_NOCRLF_NOTS(1, "%u ", tcb->task_id); + tcb = tcb->p_dlnk; + i++; + } while (tcb && i < os_maxtaskrun); + REL_TRACE_NOTS(0, " "); + if (tcb) { + REL_TRACE_NOTS(2, "*** Error: List corrupted? count=%u next=0x%08X\n", i, + (uint32_t)tcb); } - REL_TRACE_IMM_NOTS(0," "); + } else { + REL_TRACE_NOTS(0, ""); + } + REL_TRACE_IMM_NOTS(0, " "); } FLASH_TEXT_LOC -void rtx_show_all_threads(void) -{ - int i; +void rtx_show_all_threads(void) { + int i; #if (defined(DEBUG) || defined(REL_TRACE_ENABLE)) - if (hal_trace_crash_dump_onprocess()){ - for (i = 0; i < 10; i++){ - REL_TRACE_IMM_NOTS(0," "); - REL_TRACE_IMM_NOTS(0," \n"); - hal_sys_timer_delay(MS_TO_TICKS(200)); - } + if (hal_trace_crash_dump_onprocess()) { + for (i = 0; i < 10; i++) { + REL_TRACE_IMM_NOTS(0, " " + " "); + REL_TRACE_IMM_NOTS(0, " " + " \n"); + hal_sys_timer_delay(MS_TO_TICKS(200)); } + } #endif - REL_TRACE_NOTS(0,"Task List:"); - for (i = 0; i < os_maxtaskrun; i++) { - if (os_active_TCB[i]) { - rt_tsk_show(os_active_TCB[i]); - REL_TRACE_IMM_NOTS(0," "); + REL_TRACE_NOTS(0, "Task List:"); + for (i = 0; i < os_maxtaskrun; i++) { + if (os_active_TCB[i]) { + rt_tsk_show(os_active_TCB[i]); + REL_TRACE_IMM_NOTS(0, " "); #if (defined(DEBUG) || defined(REL_TRACE_ENABLE)) - if (hal_trace_crash_dump_onprocess()){ - hal_sys_timer_delay(MS_TO_TICKS(500)); - } + if (hal_trace_crash_dump_onprocess()) { + hal_sys_timer_delay(MS_TO_TICKS(500)); + } #endif - } } - rt_tsk_show(&os_idle_TCB); - REL_TRACE_IMM_NOTS(0," "); + } + rt_tsk_show(&os_idle_TCB); + REL_TRACE_IMM_NOTS(0, " "); - rtx_show_current_thread(); - rtx_show_ready_threads(); - rtx_show_delay_threads(); + rtx_show_current_thread(); + rtx_show_ready_threads(); + rtx_show_delay_threads(); } #if __RTX_CPU_STATISTICS__ #if TASK_HUNG_CHECK_ENABLED -FLASH_TEXT_LOC NOINLINE -static void print_hung_task(const P_TCB tcb, U32 curr_time) -{ - REL_TRACE_IMM_NOTS(2,"Task \"%s\" blocked for %dms", - tcb->name==NULL ? (tcb->task_id == 1 ? "main" : "null") : (char *)tcb->name, - curr_time - tcb->swap_out_time); - ASSERT(0, "Find task hung"); +FLASH_TEXT_LOC NOINLINE static void print_hung_task(const P_TCB tcb, + U32 curr_time) { + REL_TRACE_IMM_NOTS(2, "Task \"%s\" blocked for %dms", + tcb->name == NULL ? (tcb->task_id == 1 ? "main" : "null") + : (char *)tcb->name, + curr_time - tcb->swap_out_time); + ASSERT(0, "Find task hung"); } -static void check_hung_task(const P_TCB tcb) -{ - uint32_t curr_hwticks, curr_time; +static void check_hung_task(const P_TCB tcb) { + uint32_t curr_hwticks, curr_time; - if (!tcb->hung_check) - return; + if (!tcb->hung_check) + return; - curr_hwticks = hal_sys_timer_get(); - curr_time = HWTICKS_TO_MS(curr_hwticks); - if((curr_time - tcb->swap_out_time) > tcb->hung_check_timeout) { - print_hung_task(tcb, curr_time); - } + curr_hwticks = hal_sys_timer_get(); + curr_time = HWTICKS_TO_MS(curr_hwticks); + if ((curr_time - tcb->swap_out_time) > tcb->hung_check_timeout) { + print_hung_task(tcb, curr_time); + } } -void check_hung_tasks(void) -{ - int i; +void check_hung_tasks(void) { + int i; - for (i = 0; i < os_maxtaskrun; i++) { - if (os_active_TCB[i]) { - P_TCB tcb = os_active_TCB[i]; - check_hung_task(tcb); - } + for (i = 0; i < os_maxtaskrun; i++) { + if (os_active_TCB[i]) { + P_TCB tcb = os_active_TCB[i]; + check_hung_task(tcb); } + } } #endif -static inline void print_task_sw_statitics(P_TCB tcb) -{ - /* - REL_TRACE_NOTS(3,"--- Task swap in:%d out=%d runings %d", - tcb->swap_in_time, - tcb->swap_out_time, - tcb->rtime); - */ +static inline void print_task_sw_statitics(P_TCB tcb) { + /* + REL_TRACE_NOTS(3,"--- Task swap in:%d out=%d runings %d", + tcb->swap_in_time, + tcb->swap_out_time, + tcb->rtime); + */ } FLASH_TEXT_LOC -static void _rtx_show_thread_usage(P_TCB tcb, U32 sample_time) -{ - if (tcb) { - if (tcb->cb_type == TCB && ((tcb->task_id >= 1 && tcb->task_id <= os_maxtaskrun)) && - tcb->ptask && tcb->stack) { - REL_TRACE_NOTS(5,"--- Task id:%d task_name=%s cpu=%%%d", - tcb->task_id, - tcb->name==NULL ? (tcb->task_id == 1 ? "main" : "null") : (char *)tcb->name, - sample_time != 0 ? ((tcb->rtime - task_rtime[tcb->task_id]) * 100 / sample_time) : 0); - print_task_sw_statitics(tcb); - task_rtime[tcb->task_id] = tcb->rtime; - } else if (tcb->task_id == 255 ) { - REL_TRACE_NOTS(5,"--- Task id:%d task_name=%s cpu=%%%d", - tcb->task_id, - "idle", - sample_time != 0 ? (tcb->rtime - task_rtime[0]) * 100 / sample_time : 0); - print_task_sw_statitics(tcb); - task_rtime[0] = tcb->rtime; - } else { - REL_TRACE_NOTS(0,"--- Task BAD"); - } +static void _rtx_show_thread_usage(P_TCB tcb, U32 sample_time) { + if (tcb) { + if (tcb->cb_type == TCB && + ((tcb->task_id >= 1 && tcb->task_id <= os_maxtaskrun)) && tcb->ptask && + tcb->stack) { + REL_TRACE_NOTS( + 5, "--- Task id:%d task_name=%s cpu=%%%d", tcb->task_id, + tcb->name == NULL ? (tcb->task_id == 1 ? "main" : "null") + : (char *)tcb->name, + sample_time != 0 + ? ((tcb->rtime - task_rtime[tcb->task_id]) * 100 / sample_time) + : 0); + print_task_sw_statitics(tcb); + task_rtime[tcb->task_id] = tcb->rtime; + } else if (tcb->task_id == 255) { + REL_TRACE_NOTS( + 5, "--- Task id:%d task_name=%s cpu=%%%d", tcb->task_id, "idle", + sample_time != 0 ? (tcb->rtime - task_rtime[0]) * 100 / sample_time + : 0); + print_task_sw_statitics(tcb); + task_rtime[0] = tcb->rtime; } else { - REL_TRACE_NOTS(0,"--- Task NONE"); + REL_TRACE_NOTS(0, "--- Task BAD"); } + } else { + REL_TRACE_NOTS(0, "--- Task NONE"); + } } FLASH_TEXT_LOC -void rtx_show_all_threads_usage(void) -{ - int i; - static BOOL first_time = 1; - uint32_t sample_time; - static U32 start_sample_time = 0; +void rtx_show_all_threads_usage(void) { + int i; + static BOOL first_time = 1; + uint32_t sample_time; + static U32 start_sample_time = 0; - if (first_time) { - for (i = 0; i < os_maxtaskrun; i++) { - if (os_active_TCB[i]) { - P_TCB tcb = os_active_TCB[i]; - task_rtime[tcb->task_id] = tcb->rtime; - } - } - task_rtime[0] = os_idle_TCB.rtime; - start_sample_time = rtx_get_hwticks(); - first_time = 0; - return; - } - - sample_time = HWTICKS_TO_MS(rtx_get_hwticks() - start_sample_time); - REL_TRACE_IMM_NOTS(0," "); - REL_TRACE_NOTS(0,"Task List:"); + if (first_time) { for (i = 0; i < os_maxtaskrun; i++) { - if (os_active_TCB[i]) { - _rtx_show_thread_usage(os_active_TCB[i], sample_time); - } + if (os_active_TCB[i]) { + P_TCB tcb = os_active_TCB[i]; + task_rtime[tcb->task_id] = tcb->rtime; + } } - _rtx_show_thread_usage(&os_idle_TCB, sample_time); - start_sample_time = rtx_get_hwticks(); - REL_TRACE_IMM_NOTS(0," "); + task_rtime[0] = os_idle_TCB.rtime; + start_sample_time = rtx_get_hwticks(); + first_time = 0; + return; + } + + sample_time = HWTICKS_TO_MS(rtx_get_hwticks() - start_sample_time); + REL_TRACE_IMM_NOTS(0, " "); + REL_TRACE_NOTS(0, "Task List:"); + for (i = 0; i < os_maxtaskrun; i++) { + if (os_active_TCB[i]) { + _rtx_show_thread_usage(os_active_TCB[i], sample_time); + } + } + _rtx_show_thread_usage(&os_idle_TCB, sample_time); + start_sample_time = rtx_get_hwticks(); + REL_TRACE_IMM_NOTS(0, " "); } #endif @@ -705,29 +700,28 @@ void rtx_show_all_threads_usage(void) /* * health time period for idle thread scheduled */ -#define TASK_IDLE_HEALTH_PERIOD (60 * 1000) +#define TASK_IDLE_HEALTH_PERIOD (60 * 1000) FLASH_TEXT_LOC -int rtx_task_idle_health_check(void) -{ - P_TCB tcb = &os_idle_TCB; - uint32_t now, period; +int rtx_task_idle_health_check(void) { + P_TCB tcb = &os_idle_TCB; + uint32_t now, period; - now = HWTICKS_TO_MS(rtx_get_hwticks()); + now = HWTICKS_TO_MS(rtx_get_hwticks()); - if (now >= tcb->swap_in_time) { - period = now - tcb->swap_in_time; - } else { - uint64_t temp; - temp = now + HWTICKS_TO_MS((-1u)); - period = temp - tcb->swap_in_time; - } + if (now >= tcb->swap_in_time) { + period = now - tcb->swap_in_time; + } else { + uint64_t temp; + temp = now + HWTICKS_TO_MS((-1u)); + period = temp - tcb->swap_in_time; + } - if ( period > TASK_IDLE_HEALTH_PERIOD) { - REL_TRACE_NOTS(1,"--- Task idle hung %d seconds", period / 1000); - return -1; - } - return 0; + if (period > TASK_IDLE_HEALTH_PERIOD) { + REL_TRACE_NOTS(1, "--- Task idle hung %d seconds", period / 1000); + return -1; + } + return 0; } /*---------------------------------------------------------------------------- diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_Task.h b/rtos/rtx/TARGET_CORTEX_M/rt_Task.h index b84e615..8d30be4 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_Task.h +++ b/rtos/rtx/TARGET_CORTEX_M/rt_Task.h @@ -31,44 +31,45 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ +#include "rt_TypeDef.h" /* Definitions */ -#define __CMSIS_RTOS 1 +#define __CMSIS_RTOS 1 /* Values for 'state' */ -#define INACTIVE 0 -#define READY 1 -#define RUNNING 2 -#define WAIT_DLY 3 -#define WAIT_ITV 4 -#define WAIT_OR 5 -#define WAIT_AND 6 -#define WAIT_SEM 7 -#define WAIT_MBX 8 -#define WAIT_MUT 9 +#define INACTIVE 0 +#define READY 1 +#define RUNNING 2 +#define WAIT_DLY 3 +#define WAIT_ITV 4 +#define WAIT_OR 5 +#define WAIT_AND 6 +#define WAIT_SEM 7 +#define WAIT_MBX 8 +#define WAIT_MUT 9 /* Return codes */ -#define OS_R_TMO 0x01 -#define OS_R_EVT 0x02 -#define OS_R_SEM 0x03 -#define OS_R_MBX 0x04 -#define OS_R_MUT 0x05 +#define OS_R_TMO 0x01 +#define OS_R_EVT 0x02 +#define OS_R_SEM 0x03 +#define OS_R_MBX 0x04 +#define OS_R_MUT 0x05 -#define OS_R_OK 0x00 -#define OS_R_NOK 0xff +#define OS_R_OK 0x00 +#define OS_R_NOK 0xff /* Variables */ extern struct OS_TSK os_tsk; extern struct OS_TCB os_idle_TCB; /* Functions */ -extern void rt_switch_req (P_TCB p_new); -extern void rt_dispatch (P_TCB next_TCB); -extern void rt_block (U16 timeout, U8 block_state); -extern void rt_tsk_pass (void); -extern OS_TID rt_tsk_self (void); -extern OS_RESULT rt_tsk_prio (OS_TID task_id, U8 new_prio); -extern OS_RESULT rt_tsk_delete (OS_TID task_id); -extern void rt_sys_init (void); -extern void rt_sys_start (void); -extern void rt_tsk_show (P_TCB tcb); +extern void rt_switch_req(P_TCB p_new); +extern void rt_dispatch(P_TCB next_TCB); +extern void rt_block(U16 timeout, U8 block_state); +extern void rt_tsk_pass(void); +extern OS_TID rt_tsk_self(void); +extern OS_RESULT rt_tsk_prio(OS_TID task_id, U8 new_prio); +extern OS_RESULT rt_tsk_delete(OS_TID task_id); +extern void rt_sys_init(void); +extern void rt_sys_start(void); +extern void rt_tsk_show(P_TCB tcb); diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_Time.c b/rtos/rtx/TARGET_CORTEX_M/rt_Time.c index b02cceb..5b63224 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_Time.c +++ b/rtos/rtx/TARGET_CORTEX_M/rt_Time.c @@ -32,10 +32,10 @@ * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ -#include "rt_TypeDef.h" +#include "rt_Time.h" #include "RTX_Conf.h" #include "rt_Task.h" -#include "rt_Time.h" +#include "rt_TypeDef.h" /*---------------------------------------------------------------------------- * Global Variables @@ -44,51 +44,45 @@ /* Free running system tick counter */ U32 os_time; - /*---------------------------------------------------------------------------- * Functions *---------------------------------------------------------------------------*/ - /*--------------------------- rt_time_get -----------------------------------*/ -U32 rt_time_get (void) { +U32 rt_time_get(void) { /* Get system time tick */ return (os_time); } - /*--------------------------- rt_dly_wait -----------------------------------*/ -void rt_dly_wait (U16 delay_time) { +void rt_dly_wait(U16 delay_time) { /* Delay task by "delay_time" */ - rt_block (delay_time, WAIT_DLY); + rt_block(delay_time, WAIT_DLY); } - /*--------------------------- rt_itv_set ------------------------------------*/ -void rt_itv_set (U16 interval_time) { +void rt_itv_set(U16 interval_time) { /* Set interval length and define start of first interval */ os_tsk.run->interval_time = interval_time; os_tsk.run->delta_time = interval_time + (U16)os_time; } - /*--------------------------- rt_itv_wait -----------------------------------*/ -void rt_itv_wait (void) { +void rt_itv_wait(void) { /* Wait for interval end and define start of next one */ U16 delta; delta = os_tsk.run->delta_time - (U16)os_time; os_tsk.run->delta_time += os_tsk.run->interval_time; if ((delta & 0x8000) == 0) { - rt_block (delta, WAIT_ITV); + rt_block(delta, WAIT_ITV); } } /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_Time.h b/rtos/rtx/TARGET_CORTEX_M/rt_Time.h index 2c352e1..f5fac0e 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_Time.h +++ b/rtos/rtx/TARGET_CORTEX_M/rt_Time.h @@ -31,7 +31,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *---------------------------------------------------------------------------*/ - +#include "rt_TypeDef.h" // // SysTick Timer Configuration // ============================== @@ -40,21 +40,21 @@ // Defines the timer clock value. // Default: 6000000 (6MHz) #ifdef CALIB_SLOW_TIMER - #define OS_CLOCK (CONFIG_SYSTICK_HZ * (OS_CLOCK_NOMINAL / CONFIG_SYSTICK_HZ_NOMINAL)) +#define OS_CLOCK \ + (CONFIG_SYSTICK_HZ * (OS_CLOCK_NOMINAL / CONFIG_SYSTICK_HZ_NOMINAL)) #else - #define OS_CLOCK OS_CLOCK_NOMINAL +#define OS_CLOCK OS_CLOCK_NOMINAL #endif /* Variables */ extern U32 os_time; /* Functions */ -extern U32 rt_time_get (void); -extern void rt_dly_wait (U16 delay_time); -extern void rt_itv_set (U16 interval_time); -extern void rt_itv_wait (void); +extern U32 rt_time_get(void); +extern void rt_dly_wait(U16 delay_time); +extern void rt_itv_set(U16 interval_time); +extern void rt_itv_wait(void); /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/ - diff --git a/rtos/rtx/TARGET_CORTEX_M/rt_TypeDef.h b/rtos/rtx/TARGET_CORTEX_M/rt_TypeDef.h index 27416c5..093292b 100644 --- a/rtos/rtx/TARGET_CORTEX_M/rt_TypeDef.h +++ b/rtos/rtx/TARGET_CORTEX_M/rt_TypeDef.h @@ -36,93 +36,110 @@ #include "os_tcb.h" -typedef U32 OS_TID; -typedef void *OS_ID; -typedef U32 OS_RESULT; +typedef U32 OS_TID; +typedef void *OS_ID; +typedef U32 OS_RESULT; -#define TCB_STACKF 32 /* 'stack_frame' offset */ -#define TCB_TSTACK 40 /* 'tsk_stack' offset */ +#define TCB_STACKF 32 /* 'stack_frame' offset */ +#define TCB_TSTACK 40 /* 'tsk_stack' offset */ -typedef struct OS_PSFE { /* Post Service Fifo Entry */ - void *id; /* Object Identification */ - U32 arg; /* Object Argument */ +typedef struct OS_PSFE { /* Post Service Fifo Entry */ + void *id; /* Object Identification */ + U32 arg; /* Object Argument */ } *P_PSFE; -typedef struct OS_PSQ { /* Post Service Queue */ - U8 first; /* FIFO Head Index */ - U8 last; /* FIFO Tail Index */ - U8 count; /* Number of stored items in FIFO */ - U8 size; /* FIFO Size */ - struct OS_PSFE q[1]; /* FIFO Content */ +typedef struct OS_PSQ { /* Post Service Queue */ + U8 first; /* FIFO Head Index */ + U8 last; /* FIFO Tail Index */ + U8 count; /* Number of stored items in FIFO */ + U8 size; /* FIFO Size */ + struct OS_PSFE q[1]; /* FIFO Content */ } *P_PSQ; typedef struct OS_TSK { - P_TCB run; /* Current running task */ - P_TCB new_tsk; /* Scheduled task to run */ + P_TCB run; /* Current running task */ + P_TCB new_tsk; /* Scheduled task to run */ } *P_TSK; -typedef struct OS_ROBIN { /* Round Robin Control */ - P_TCB task; /* Round Robin task */ - U16 time; /* Round Robin switch time */ - U16 tout; /* Round Robin timeout */ +typedef struct OS_ROBIN { /* Round Robin Control */ + P_TCB task; /* Round Robin task */ + U16 time; /* Round Robin switch time */ + U16 tout; /* Round Robin timeout */ } *P_ROBIN; typedef struct OS_XCB { - U8 cb_type; /* Control Block Type */ - struct OS_TCB *p_lnk; /* Link pointer for ready/sem. wait list */ - struct OS_TCB *p_rlnk; /* Link pointer for sem./mbx lst backwards */ - struct OS_TCB *p_dlnk; /* Link pointer for delay list */ - struct OS_TCB *p_blnk; /* Link pointer for delay list backwards */ - U16 delta_time; /* Time until time out */ + U8 cb_type; /* Control Block Type */ + struct OS_TCB *p_lnk; /* Link pointer for ready/sem. wait list */ + struct OS_TCB *p_rlnk; /* Link pointer for sem./mbx lst backwards */ + struct OS_TCB *p_dlnk; /* Link pointer for delay list */ + struct OS_TCB *p_blnk; /* Link pointer for delay list backwards */ + U16 delta_time; /* Time until time out */ } *P_XCB; typedef struct OS_MCB { - U8 cb_type; /* Control Block Type */ - U8 state; /* State flag variable */ - U8 isr_st; /* State flag variable for isr functions */ - struct OS_TCB *p_lnk; /* Chain of tasks waiting for message */ - U16 first; /* Index of the message list begin */ - U16 last; /* Index of the message list end */ - U16 count; /* Actual number of stored messages */ - U16 size; /* Maximum number of stored messages */ - void *msg[1]; /* FIFO for Message pointers 1st element */ + U8 cb_type; /* Control Block Type */ + U8 state; /* State flag variable */ + U8 isr_st; /* State flag variable for isr functions */ + struct OS_TCB *p_lnk; /* Chain of tasks waiting for message */ + U16 first; /* Index of the message list begin */ + U16 last; /* Index of the message list end */ + U16 count; /* Actual number of stored messages */ + U16 size; /* Maximum number of stored messages */ + void *msg[1]; /* FIFO for Message pointers 1st element */ } *P_MCB; typedef struct OS_SCB { - U8 cb_type; /* Control Block Type */ - U8 mask; /* Semaphore token mask */ - U16 tokens; /* Semaphore tokens */ - struct OS_TCB *p_lnk; /* Chain of tasks waiting for tokens */ + U8 cb_type; /* Control Block Type */ + U8 mask; /* Semaphore token mask */ + U16 tokens; /* Semaphore tokens */ + struct OS_TCB *p_lnk; /* Chain of tasks waiting for tokens */ } *P_SCB; typedef struct OS_MUCB { - U8 cb_type; /* Control Block Type */ - U8 prio; /* Owner task default priority */ - U16 level; /* Call nesting level */ - struct OS_TCB *p_lnk; /* Chain of tasks waiting for mutex */ - struct OS_TCB *owner; /* Mutex owner task */ + U8 cb_type; /* Control Block Type */ + U8 prio; /* Owner task default priority */ + U16 level; /* Call nesting level */ + struct OS_TCB *p_lnk; /* Chain of tasks waiting for mutex */ + struct OS_TCB *owner; /* Mutex owner task */ } *P_MUCB; typedef struct OS_XTMR { - struct OS_TMR *next; - U16 tcnt; + struct OS_TMR *next; + U16 tcnt; } *P_XTMR; typedef struct OS_TMR { - struct OS_TMR *next; /* Link pointer to Next timer */ - U16 tcnt; /* Timer delay count */ - U16 info; /* User defined call info */ + struct OS_TMR *next; /* Link pointer to Next timer */ + U16 tcnt; /* Timer delay count */ + U16 info; /* User defined call info */ } *P_TMR; typedef struct OS_BM { - void *free; /* Pointer to first free memory block */ - void *end; /* Pointer to memory block end */ - U32 blk_size; /* Memory block size */ + void *free; /* Pointer to first free memory block */ + void *end; /* Pointer to memory block end */ + U32 blk_size; /* Memory block size */ } *P_BM; /* Definitions */ -#define __TRUE 1 -#define __FALSE 0 -#define NULL ((void *) 0) +#define __TRUE 1 +#define __FALSE 0 +#define NULL ((void *)0) +#ifndef BOOL_DEFINED +typedef unsigned int BOOL; /* IGNORESTYLE */ +#endif + +typedef unsigned int U32; +typedef unsigned short U16; +typedef unsigned char U8; + +typedef int S32; +typedef short S16; +typedef char S8; + +#ifndef U32_PTR_DEFINED +typedef U32 U32_PTR; + +#define U32_PTR_DEFINED +#endif /* U32_PTR_DEFINED */ #endif diff --git a/rtos/rtx5/cmsis_os1.c b/rtos/rtx5/cmsis_os1.c index b645d7c..1c71c28 100644 --- a/rtos/rtx5/cmsis_os1.c +++ b/rtos/rtx5/cmsis_os1.c @@ -24,28 +24,27 @@ * Title: cmsis_os_v1.c V1 module file *---------------------------------------------------------------------------*/ -#include #include "cmsis_os.h" #include "rtx_os.h" +#include #if (osCMSIS >= 0x20000U) - // Thread -osThreadId osThreadCreate (const osThreadDef_t *thread_def, void *argument) { +osThreadId osThreadCreate(const osThreadDef_t *thread_def, void *argument) { if (thread_def == NULL) { return (osThreadId)NULL; } - return osThreadNew((osThreadFunc_t)thread_def->pthread, argument, &thread_def->attr); + return osThreadNew((osThreadFunc_t)thread_def->pthread, argument, + &thread_def->attr); } - // Signals -#define SignalMask ((1U< 0U) && (flags < 0x80000000U)) { event.status = osEventSignal; event.value.signals = (int32_t)flags; } else { switch ((int32_t)flags) { - case osErrorResource: - event.status = osOK; - break; - case osErrorTimeout: - event.status = osEventTimeout; - break; - case osErrorParameter: - event.status = osErrorValue; - break; - default: - event.status = (osStatus)flags; - break; + case osErrorResource: + event.status = osOK; + break; + case osErrorTimeout: + event.status = osEventTimeout; + break; + case osErrorParameter: + event.status = osErrorValue; + break; + default: + event.status = (osStatus)flags; + break; } } return event; } - // Timer -osTimerId osTimerCreate (const osTimerDef_t *timer_def, os_timer_type type, void *argument) { +osTimerId osTimerCreate(const osTimerDef_t *timer_def, os_timer_type type, + void *argument) { if (timer_def == NULL) { return (osTimerId)NULL; } - return osTimerNew((osTimerFunc_t)timer_def->ptimer, type, argument, &timer_def->attr); + return osTimerNew((osTimerFunc_t)timer_def->ptimer, type, argument, + &timer_def->attr); } - // Mutex -osMutexId osMutexCreate (const osMutexDef_t *mutex_def) { +osMutexId osMutexCreate(const osMutexDef_t *mutex_def) { if (mutex_def == NULL) { return (osMutexId)NULL; @@ -119,58 +118,59 @@ osMutexId osMutexCreate (const osMutexDef_t *mutex_def) { return osMutexNew(mutex_def); } - // Semaphore -#if (defined (osFeature_Semaphore) && (osFeature_Semaphore != 0U)) +#if (defined(osFeature_Semaphore) && (osFeature_Semaphore != 0U)) -osSemaphoreId osSemaphoreCreate (const osSemaphoreDef_t *semaphore_def, int32_t count) { +osSemaphoreId osSemaphoreCreate(const osSemaphoreDef_t *semaphore_def, + int32_t count) { if (semaphore_def == NULL) { return (osSemaphoreId)NULL; } - return osSemaphoreNew(osRtxSemaphoreTokenLimit, (uint32_t)count, semaphore_def); + return osSemaphoreNew(osRtxSemaphoreTokenLimit, (uint32_t)count, + semaphore_def); } -int32_t osSemaphoreWait (osSemaphoreId semaphore_id, uint32_t millisec) { +int32_t osSemaphoreWait(osSemaphoreId semaphore_id, uint32_t millisec) { osStatus_t status; - uint32_t count; + uint32_t count; status = osSemaphoreAcquire(semaphore_id, millisec); switch (status) { - case osOK: - count = osSemaphoreGetCount(semaphore_id); - return ((int32_t)count + 1); - case osErrorResource: - case osErrorTimeout: - return 0; - default: - break; + case osOK: + count = osSemaphoreGetCount(semaphore_id); + return ((int32_t)count + 1); + case osErrorResource: + case osErrorTimeout: + return 0; + default: + break; } return -1; } -#endif // Semaphore - +#endif // Semaphore // Memory Pool #if (defined(osFeature_Pool) && (osFeature_Pool != 0)) -osPoolId osPoolCreate (const osPoolDef_t *pool_def) { +osPoolId osPoolCreate(const osPoolDef_t *pool_def) { if (pool_def == NULL) { return (osPoolId)NULL; } - return ((osPoolId)(osMemoryPoolNew(pool_def->pool_sz, pool_def->item_sz, &pool_def->attr))); + return ((osPoolId)( + osMemoryPoolNew(pool_def->pool_sz, pool_def->item_sz, &pool_def->attr))); } -void *osPoolAlloc (osPoolId pool_id) { +void *osPoolAlloc(osPoolId pool_id) { return osMemoryPoolAlloc((osMemoryPoolId_t)pool_id, 0U); } -void *osPoolCAlloc (osPoolId pool_id) { - void *block; +void *osPoolCAlloc(osPoolId pool_id) { + void *block; uint32_t block_size; block_size = osMemoryPoolGetBlockSize((osMemoryPoolId_t)pool_id); @@ -184,72 +184,72 @@ void *osPoolCAlloc (osPoolId pool_id) { return block; } -osStatus osPoolFree (osPoolId pool_id, void *block) { +osStatus osPoolFree(osPoolId pool_id, void *block) { return osMemoryPoolFree((osMemoryPoolId_t)pool_id, block); } -#endif // Memory Pool - +#endif // Memory Pool // Message Queue #if (defined(osFeature_MessageQ) && (osFeature_MessageQ != 0)) -osMessageQId osMessageCreate (const osMessageQDef_t *queue_def, osThreadId thread_id) { +osMessageQId osMessageCreate(const osMessageQDef_t *queue_def, + osThreadId thread_id) { (void)thread_id; if (queue_def == NULL) { return (osMessageQId)NULL; } - return ((osMessageQId)(osMessageQueueNew(queue_def->queue_sz, sizeof(uint32_t), &queue_def->attr))); + return ((osMessageQId)(osMessageQueueNew( + queue_def->queue_sz, sizeof(uint32_t), &queue_def->attr))); } -osStatus osMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec) { +osStatus osMessagePut(osMessageQId queue_id, uint32_t info, uint32_t millisec) { return osMessageQueuePut((osMessageQueueId_t)queue_id, &info, 0U, millisec); } -osEvent osMessageGet (osMessageQId queue_id, uint32_t millisec) { +osEvent osMessageGet(osMessageQId queue_id, uint32_t millisec) { osStatus_t status; - osEvent event; - uint32_t message; + osEvent event; + uint32_t message; - status = osMessageQueueGet((osMessageQueueId_t)queue_id, &message, NULL, millisec); + status = + osMessageQueueGet((osMessageQueueId_t)queue_id, &message, NULL, millisec); switch (status) { - case osOK: - event.status = osEventMessage; - event.value.v = message; - break; - case osErrorResource: - event.status = osOK; - break; - case osErrorTimeout: - event.status = osEventTimeout; - break; - default: - event.status = status; - break; + case osOK: + event.status = osEventMessage; + event.value.v = message; + break; + case osErrorResource: + event.status = osOK; + break; + case osErrorTimeout: + event.status = osEventTimeout; + break; + default: + event.status = status; + break; } return event; } -uint32_t osMessageGetSpace (osMessageQId queue_id) -{ - return osMessageQueueGetSpace(queue_id); +uint32_t osMessageGetSpace(osMessageQId queue_id) { + return osMessageQueueGetSpace(queue_id); } -#endif // Message Queue - +#endif // Message Queue // Mail Queue #if (defined(osFeature_MailQ) && (osFeature_MailQ != 0)) typedef struct os_mail_queue_s { - osMemoryPoolId_t mp_id; + osMemoryPoolId_t mp_id; osMessageQueueId_t mq_id; } os_mail_queue_t; -osMailQId osMailCreate (const osMailQDef_t *queue_def, osThreadId thread_id) { +osMailQId osMailCreate(const osMailQDef_t *queue_def, osThreadId thread_id) { os_mail_queue_t *ptr; (void)thread_id; @@ -262,9 +262,12 @@ osMailQId osMailCreate (const osMailQDef_t *queue_def, osThreadId thread_id) { return (osMailQId)NULL; } - ptr->mp_id = osMemoryPoolNew (queue_def->queue_sz, queue_def->item_sz, &queue_def->mp_attr); - ptr->mq_id = osMessageQueueNew(queue_def->queue_sz, sizeof(void *), &queue_def->mq_attr); - if ((ptr->mp_id == (osMemoryPoolId_t)NULL) || (ptr->mq_id == (osMessageQueueId_t)NULL)) { + ptr->mp_id = osMemoryPoolNew(queue_def->queue_sz, queue_def->item_sz, + &queue_def->mp_attr); + ptr->mq_id = osMessageQueueNew(queue_def->queue_sz, sizeof(void *), + &queue_def->mq_attr); + if ((ptr->mp_id == (osMemoryPoolId_t)NULL) || + (ptr->mq_id == (osMessageQueueId_t)NULL)) { if (ptr->mp_id != (osMemoryPoolId_t)NULL) { osMemoryPoolDelete(ptr->mp_id); } @@ -277,7 +280,7 @@ osMailQId osMailCreate (const osMailQDef_t *queue_def, osThreadId thread_id) { return (osMailQId)ptr; } -void *osMailAlloc (osMailQId queue_id, uint32_t millisec) { +void *osMailAlloc(osMailQId queue_id, uint32_t millisec) { os_mail_queue_t *ptr = (os_mail_queue_t *)queue_id; if (ptr == NULL) { @@ -286,10 +289,10 @@ void *osMailAlloc (osMailQId queue_id, uint32_t millisec) { return osMemoryPoolAlloc(ptr->mp_id, millisec); } -void *osMailCAlloc (osMailQId queue_id, uint32_t millisec) { +void *osMailCAlloc(osMailQId queue_id, uint32_t millisec) { os_mail_queue_t *ptr = (os_mail_queue_t *)queue_id; - void *block; - uint32_t block_size; + void *block; + uint32_t block_size; if (ptr == NULL) { return NULL; @@ -304,10 +307,9 @@ void *osMailCAlloc (osMailQId queue_id, uint32_t millisec) { } return block; - } -osStatus osMailPut (osMailQId queue_id, const void *mail) { +osStatus osMailPut(osMailQId queue_id, const void *mail) { os_mail_queue_t *ptr = (os_mail_queue_t *)queue_id; if (ptr == NULL) { @@ -319,11 +321,11 @@ osStatus osMailPut (osMailQId queue_id, const void *mail) { return osMessageQueuePut(ptr->mq_id, &mail, 0U, 0U); } -osEvent osMailGet (osMailQId queue_id, uint32_t millisec) { +osEvent osMailGet(osMailQId queue_id, uint32_t millisec) { os_mail_queue_t *ptr = (os_mail_queue_t *)queue_id; - osStatus_t status; - osEvent event; - void *mail; + osStatus_t status; + osEvent event; + void *mail; if (ptr == NULL) { event.status = osErrorParameter; @@ -332,24 +334,24 @@ osEvent osMailGet (osMailQId queue_id, uint32_t millisec) { status = osMessageQueueGet(ptr->mq_id, &mail, NULL, millisec); switch (status) { - case osOK: - event.status = osEventMail; - event.value.p = mail; - break; - case osErrorResource: - event.status = osOK; - break; - case osErrorTimeout: - event.status = osEventTimeout; - break; - default: - event.status = status; - break; + case osOK: + event.status = osEventMail; + event.value.p = mail; + break; + case osErrorResource: + event.status = osOK; + break; + case osErrorTimeout: + event.status = osEventTimeout; + break; + default: + event.status = status; + break; } return event; } -osStatus osMailFree (osMailQId queue_id, void *mail) { +osStatus osMailFree(osMailQId queue_id, void *mail) { os_mail_queue_t *ptr = (os_mail_queue_t *)queue_id; if (ptr == NULL) { @@ -361,6 +363,6 @@ osStatus osMailFree (osMailQId queue_id, void *mail) { return osMemoryPoolFree(ptr->mp_id, mail); } -#endif // Mail Queue +#endif // Mail Queue -#endif // osCMSIS +#endif // osCMSIS diff --git a/rtos/rtx5/os_systick.c b/rtos/rtx5/os_systick.c index b44a361..b7ca352 100644 --- a/rtos/rtx5/os_systick.c +++ b/rtos/rtx5/os_systick.c @@ -1,9 +1,9 @@ -/**************************************************************************//** - * @file os_systick.c - * @brief CMSIS OS Tick SysTick implementation - * @version V1.0.1 - * @date 24. November 2017 - ******************************************************************************/ +/**************************************************************************/ /** + * @file os_systick.c + * @brief CMSIS OS Tick SysTick implementation + * @version V1.0.1 + * @date 24. November 2017 + ******************************************************************************/ /* * Copyright (c) 2017-2017 ARM Limited. All rights reserved. * @@ -25,70 +25,68 @@ #include "os_tick.h" -//lint -emacro((923,9078),SCB,SysTick) "cast from unsigned long to pointer" +// lint -emacro((923,9078),SCB,SysTick) "cast from unsigned long to pointer" #include "RTE_Components.h" #include CMSIS_device_header -#ifdef SysTick +#ifdef SysTick #ifndef SYSTICK_IRQ_PRIORITY -#define SYSTICK_IRQ_PRIORITY 0xFFU +#define SYSTICK_IRQ_PRIORITY 0xFFU #endif #ifdef CALIB_SLOW_TIMER -#define OS_CLOCK (CONFIG_SYSTICK_HZ * (OS_CLOCK_NOMINAL / CONFIG_SYSTICK_HZ_NOMINAL)) +#define OS_CLOCK \ + (CONFIG_SYSTICK_HZ * (OS_CLOCK_NOMINAL / CONFIG_SYSTICK_HZ_NOMINAL)) #else -#define OS_CLOCK OS_CLOCK_NOMINAL +#define OS_CLOCK OS_CLOCK_NOMINAL #endif uint32_t SystemCoreClock; -#define SYSTICK_EXTERNAL_CLOCK 1 +#define SYSTICK_EXTERNAL_CLOCK 1 -void SystemCoreClockUpdate() -{ - SystemCoreClock = OS_CLOCK; -} +void SystemCoreClockUpdate() { SystemCoreClock = OS_CLOCK; } static uint8_t PendST; // Setup OS Tick. -__WEAK int32_t OS_Tick_Setup (uint32_t freq, IRQHandler_t handler) { +__WEAK int32_t OS_Tick_Setup(uint32_t freq, IRQHandler_t handler) { uint32_t load; (void)handler; if (freq == 0U) { - //lint -e{904} "Return statement before end of function" + // lint -e{904} "Return statement before end of function" return (-1); } load = (SystemCoreClock / freq) - 1U; if (load > 0x00FFFFFFU) { - //lint -e{904} "Return statement before end of function" + // lint -e{904} "Return statement before end of function" return (-1); } // Set SysTick Interrupt Priority -#if ((defined(__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ != 0)) || \ - (defined(__CORTEX_M) && (__CORTEX_M == 7U))) +#if ((defined(__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ != 0)) || \ + (defined(__CORTEX_M) && (__CORTEX_M == 7U))) SCB->SHPR[11] = SYSTICK_IRQ_PRIORITY; -#elif (defined(__ARM_ARCH_8M_BASE__) && (__ARM_ARCH_8M_BASE__ != 0)) +#elif (defined(__ARM_ARCH_8M_BASE__) && (__ARM_ARCH_8M_BASE__ != 0)) SCB->SHPR[1] |= ((uint32_t)SYSTICK_IRQ_PRIORITY << 24); -#elif ((defined(__ARM_ARCH_7M__) && (__ARM_ARCH_7M__ != 0)) || \ - (defined(__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ != 0))) - SCB->SHP[11] = SYSTICK_IRQ_PRIORITY; -#elif (defined(__ARM_ARCH_6M__) && (__ARM_ARCH_6M__ != 0)) - SCB->SHP[1] |= ((uint32_t)SYSTICK_IRQ_PRIORITY << 24); +#elif ((defined(__ARM_ARCH_7M__) && (__ARM_ARCH_7M__ != 0)) || \ + (defined(__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ != 0))) + SCB->SHP[11] = SYSTICK_IRQ_PRIORITY; +#elif (defined(__ARM_ARCH_6M__) && (__ARM_ARCH_6M__ != 0)) + SCB->SHP[1] |= ((uint32_t)SYSTICK_IRQ_PRIORITY << 24); #else #error "Unknown ARM Core!" #endif #if (SYSTICK_EXTERNAL_CLOCK) - SysTick->CTRL = SysTick_CTRL_TICKINT_Msk; + SysTick->CTRL = SysTick_CTRL_TICKINT_Msk; #else - SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk; + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk; #endif - SysTick->LOAD = load; - SysTick->VAL = 0U; + SysTick->LOAD = load; + SysTick->VAL = 0U; PendST = 0U; @@ -96,18 +94,18 @@ __WEAK int32_t OS_Tick_Setup (uint32_t freq, IRQHandler_t handler) { } /// Enable OS Tick. -__WEAK void OS_Tick_Enable (void) { +__WEAK void OS_Tick_Enable(void) { if (PendST != 0U) { PendST = 0U; SCB->ICSR = SCB_ICSR_PENDSTSET_Msk; } - SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; + SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; } /// Disable OS Tick. -__WEAK void OS_Tick_Disable (void) { +__WEAK void OS_Tick_Disable(void) { SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; @@ -118,34 +116,26 @@ __WEAK void OS_Tick_Disable (void) { } // Acknowledge OS Tick IRQ. -__WEAK void OS_Tick_AcknowledgeIRQ (void) { - (void)SysTick->CTRL; -} +__WEAK void OS_Tick_AcknowledgeIRQ(void) { (void)SysTick->CTRL; } // Get OS Tick IRQ number. -__WEAK int32_t OS_Tick_GetIRQn (void) { - return ((int32_t)SysTick_IRQn); -} +__WEAK int32_t OS_Tick_GetIRQn(void) { return ((int32_t)SysTick_IRQn); } // Get OS Tick clock. -__WEAK uint32_t OS_Tick_GetClock (void) { - return (SystemCoreClock); -} +__WEAK uint32_t OS_Tick_GetClock(void) { return (SystemCoreClock); } // Get OS Tick interval. -__WEAK uint32_t OS_Tick_GetInterval (void) { - return (SysTick->LOAD + 1U); -} +__WEAK uint32_t OS_Tick_GetInterval(void) { return (SysTick->LOAD + 1U); } // Get OS Tick count value. -__WEAK uint32_t OS_Tick_GetCount (void) { +__WEAK uint32_t OS_Tick_GetCount(void) { uint32_t load = SysTick->LOAD; - return (load - SysTick->VAL); + return (load - SysTick->VAL); } // Get OS Tick overflow status. -__WEAK uint32_t OS_Tick_GetOverflow (void) { +__WEAK uint32_t OS_Tick_GetOverflow(void) { return ((SysTick->CTRL >> 16) & 1U); } -#endif // SysTick +#endif // SysTick diff --git a/rtos/rtx5/rtx_config/rtx_config.c b/rtos/rtx5/rtx_config/rtx_config.c index 5e6a67e..ba9051d 100644 --- a/rtos/rtx5/rtx_config/rtx_config.c +++ b/rtos/rtx5/rtx_config/rtx_config.c @@ -25,22 +25,19 @@ * ----------------------------------------------------------------------------- */ -#include "cmsis_compiler.h" #include "RTE_Components.h" +#include "cmsis_compiler.h" #include CMSIS_device_header -#include "rtx_os.h" -#include "rtx_config.h" +#include "hal_sleep.h" #include "hal_timer.h" #include "hal_trace.h" -#include "hal_sleep.h" +#include "rtx_config.h" +#include "rtx_os.h" #include "cmsis_os2.h" #include "hwtimer_list.h" -void WEAK sleep(void) -{ - hal_sleep_enter_sleep(); -} +void WEAK sleep(void) { hal_sleep_enter_sleep(); } extern void rtx_show_all_threads(void); #if TASK_HUNG_CHECK_ENABLED @@ -48,80 +45,85 @@ extern void check_hung_threads(void); #endif // OS Idle Thread -__NO_RETURN void osRtxIdleThread (void *argument) { - unsigned int os_ticks; - HWTIMER_ID timer; - int ret; +__NO_RETURN void osRtxIdleThread(void *argument) { + unsigned int os_ticks; + HWTIMER_ID timer; + int ret; #if defined(DEBUG_SLEEP) && (DEBUG_SLEEP >= 2) - unsigned int start_time; - unsigned int start_os_time; - unsigned int start_tick; + unsigned int start_time; + unsigned int start_os_time; + unsigned int start_tick; #endif #if !(defined(ROM_BUILD) || defined(PROGRAMMER)) - ret = hal_trace_crash_dump_register(HAL_TRACE_CRASH_DUMP_MODULE_SYS, rtx_show_all_threads); - ASSERT(ret == 0, "IdleTask: Failed to register crash dump callback"); + ret = hal_trace_crash_dump_register(HAL_TRACE_CRASH_DUMP_MODULE_SYS, + rtx_show_all_threads); + ASSERT(ret == 0, "IdleTask: Failed to register crash dump callback"); #endif - timer = hwtimer_alloc(NULL, NULL); - ASSERT(timer, "IdleTask: Failed to alloc sleep timer"); + timer = hwtimer_alloc(NULL, NULL); + ASSERT(timer, "IdleTask: Failed to alloc sleep timer"); for (;;) { #if TASK_HUNG_CHECK_ENABLED - check_hung_threads(); + check_hung_threads(); #endif - if (hal_sleep_light_sleep() == HAL_SLEEP_STATUS_DEEP) { - os_ticks = osKernelSuspend(); - if (os_ticks) { + if (hal_sleep_light_sleep() == HAL_SLEEP_STATUS_DEEP) { + os_ticks = osKernelSuspend(); + if (os_ticks) { #if defined(DEBUG_SLEEP) && (DEBUG_SLEEP >= 2) - __disable_irq(); + __disable_irq(); #endif - ret = hwtimer_start(timer, MS_TO_HWTICKS(os_ticks * OS_TICK_FREQ / 1000)); + ret = + hwtimer_start(timer, MS_TO_HWTICKS(os_ticks * OS_TICK_FREQ / 1000)); #if defined(DEBUG_SLEEP) && (DEBUG_SLEEP >= 2) - start_time = hal_sys_timer_get(); - start_tick = SysTick->VAL; - start_os_time = osRtxInfo.kernel.tick; - __enable_irq(); + start_time = hal_sys_timer_get(); + start_tick = SysTick->VAL; + start_os_time = osRtxInfo.kernel.tick; + __enable_irq(); #endif - if (ret == 0) { - sleep(); - ret = hwtimer_stop(timer); - } -#if defined(DEBUG_SLEEP) && (DEBUG_SLEEP >= 2) - if (hal_sys_timer_get() - start_time >= MS_TO_HWTICKS(1)) { - TRACE(5,"[%u/0x%X][%2u/%u] os_idle_demon start timer. tick:%u", - TICKS_TO_MS(start_time), start_time, start_tick, start_os_time, os_ticks); - } -#endif - } - osKernelResume(os_ticks); + if (ret == 0) { + sleep(); + ret = hwtimer_stop(timer); } +#if defined(DEBUG_SLEEP) && (DEBUG_SLEEP >= 2) + if (hal_sys_timer_get() - start_time >= MS_TO_HWTICKS(1)) { + TRACE(5, "[%u/0x%X][%2u/%u] os_idle_demon start timer. tick:%u", + TICKS_TO_MS(start_time), start_time, start_tick, start_os_time, + os_ticks); + } +#endif + } + osKernelResume(os_ticks); } + } } // OS Error Callback function -__WEAK uint32_t osRtxErrorNotify (uint32_t code, void *object_id) { +__WEAK uint32_t osRtxErrorNotify(uint32_t code, void *object_id) { (void)object_id; switch (code) { - case osRtxErrorStackUnderflow: - // Stack overflow detected for thread (thread_id=object_id) - break; - case osRtxErrorISRQueueOverflow: - // ISR Queue overflow detected when inserting object (object_id) - break; - case osRtxErrorTimerQueueOverflow: - // User Timer Callback Queue overflow detected for timer (timer_id=object_id) - break; - case osRtxErrorClibSpace: - // Standard C/C++ library libspace not available: increase OS_THREAD_LIBSPACE_NUM - break; - case osRtxErrorClibMutex: - // Standard C/C++ library mutex initialization failed - break; - default: - // Reserved - break; + case osRtxErrorStackUnderflow: + // Stack overflow detected for thread (thread_id=object_id) + break; + case osRtxErrorISRQueueOverflow: + // ISR Queue overflow detected when inserting object (object_id) + break; + case osRtxErrorTimerQueueOverflow: + // User Timer Callback Queue overflow detected for timer + // (timer_id=object_id) + break; + case osRtxErrorClibSpace: + // Standard C/C++ library libspace not available: increase + // OS_THREAD_LIBSPACE_NUM + break; + case osRtxErrorClibMutex: + // Standard C/C++ library mutex initialization failed + break; + default: + // Reserved + break; } ASSERT(0, "osRtxErrorNotify, code: %08x\n", code); -//return 0U; + // return 0U; } diff --git a/rtos/rtx5/rtx_delay.c b/rtos/rtx5/rtx_delay.c index 9d0cf41..7b0fcea 100644 --- a/rtos/rtx5/rtx_delay.c +++ b/rtos/rtx5/rtx_delay.c @@ -25,12 +25,11 @@ #include "rtx_lib.h" - // ==== Service Calls ==== /// Wait for Timeout (Time Delay). /// \note API identical to osDelay -static osStatus_t svcRtxDelay (uint32_t ticks) { +static osStatus_t svcRtxDelay(uint32_t ticks) { if (ticks != 0U) { if (osRtxThreadWaitEnter(osRtxThreadWaitingDelay, ticks)) { @@ -45,12 +44,12 @@ static osStatus_t svcRtxDelay (uint32_t ticks) { /// Wait until specified time. /// \note API identical to osDelayUntil -static osStatus_t svcRtxDelayUntil (uint32_t ticks) { +static osStatus_t svcRtxDelayUntil(uint32_t ticks) { ticks -= osRtxInfo.kernel.tick; if ((ticks == 0U) || (ticks > 0x7FFFFFFFU)) { EvrRtxDelayError((int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } @@ -64,16 +63,15 @@ static osStatus_t svcRtxDelayUntil (uint32_t ticks) { } // Service Calls definitions -//lint ++flb "Library Begin" [MISRA Note 11] -SVC0_1(Delay, osStatus_t, uint32_t) +// lint ++flb "Library Begin" [MISRA Note 11] +SVC0_1(Delay, osStatus_t, uint32_t) SVC0_1(DelayUntil, osStatus_t, uint32_t) -//lint --flb "Library End" - +// lint --flb "Library End" // ==== Public API ==== /// Wait for Timeout (Time Delay). -osStatus_t osDelay (uint32_t ticks) { +osStatus_t osDelay(uint32_t ticks) { osStatus_t status; EvrRtxDelay(ticks); @@ -87,7 +85,7 @@ osStatus_t osDelay (uint32_t ticks) { } /// Wait until specified time. -osStatus_t osDelayUntil (uint32_t ticks) { +osStatus_t osDelayUntil(uint32_t ticks) { osStatus_t status; EvrRtxDelayUntil(ticks); diff --git a/rtos/rtx5/rtx_evflags.c b/rtos/rtx5/rtx_evflags.c index 87e94d3..a75dd14 100644 --- a/rtos/rtx5/rtx_evflags.c +++ b/rtos/rtx5/rtx_evflags.c @@ -25,22 +25,19 @@ #include "rtx_lib.h" - // OS Runtime Object Memory Usage #if ((defined(OS_OBJ_MEM_USAGE) && (OS_OBJ_MEM_USAGE != 0))) -osRtxObjectMemUsage_t osRtxEventFlagsMemUsage \ -__attribute__((section(".data.os.evflags.obj"))) = -{ 0U, 0U, 0U }; +osRtxObjectMemUsage_t osRtxEventFlagsMemUsage + __attribute__((section(".data.os.evflags.obj"))) = {0U, 0U, 0U}; #endif - // ==== Helper functions ==== /// Set Event Flags. /// \param[in] ef event flags object. /// \param[in] flags specifies the flags to set. /// \return event flags after setting. -static uint32_t EventFlagsSet (os_event_flags_t *ef, uint32_t flags) { +static uint32_t EventFlagsSet(os_event_flags_t *ef, uint32_t flags) { #if (EXCLUSIVE_ACCESS == 0) uint32_t primask = __get_PRIMASK(); #endif @@ -66,7 +63,7 @@ static uint32_t EventFlagsSet (os_event_flags_t *ef, uint32_t flags) { /// \param[in] ef event flags object. /// \param[in] flags specifies the flags to clear. /// \return event flags before clearing. -static uint32_t EventFlagsClear (os_event_flags_t *ef, uint32_t flags) { +static uint32_t EventFlagsClear(os_event_flags_t *ef, uint32_t flags) { #if (EXCLUSIVE_ACCESS == 0) uint32_t primask = __get_PRIMASK(); #endif @@ -92,8 +89,10 @@ static uint32_t EventFlagsClear (os_event_flags_t *ef, uint32_t flags) { /// \param[in] ef event flags object. /// \param[in] flags specifies the flags to check. /// \param[in] options specifies flags options (osFlagsXxxx). -/// \return event flags before clearing or 0 if specified flags have not been set. -static uint32_t EventFlagsCheck (os_event_flags_t *ef, uint32_t flags, uint32_t options) { +/// \return event flags before clearing or 0 if specified flags have not been +/// set. +static uint32_t EventFlagsCheck(os_event_flags_t *ef, uint32_t flags, + uint32_t options) { #if (EXCLUSIVE_ACCESS == 0) uint32_t primask; #endif @@ -105,7 +104,8 @@ static uint32_t EventFlagsCheck (os_event_flags_t *ef, uint32_t flags, uint32_t __disable_irq(); event_flags = ef->event_flags; - if ((((options & osFlagsWaitAll) != 0U) && ((event_flags & flags) != flags)) || + if ((((options & osFlagsWaitAll) != 0U) && + ((event_flags & flags) != flags)) || (((options & osFlagsWaitAll) == 0U) && ((event_flags & flags) == 0U))) { event_flags = 0U; } else { @@ -124,7 +124,8 @@ static uint32_t EventFlagsCheck (os_event_flags_t *ef, uint32_t flags, uint32_t #endif } else { event_flags = ef->event_flags; - if ((((options & osFlagsWaitAll) != 0U) && ((event_flags & flags) != flags)) || + if ((((options & osFlagsWaitAll) != 0U) && + ((event_flags & flags) != flags)) || (((options & osFlagsWaitAll) == 0U) && ((event_flags & flags) == 0U))) { event_flags = 0U; } @@ -133,78 +134,84 @@ static uint32_t EventFlagsCheck (os_event_flags_t *ef, uint32_t flags, uint32_t return event_flags; } - // ==== Post ISR processing ==== /// Event Flags post ISR processing. /// \param[in] ef event flags object. -static void osRtxEventFlagsPostProcess (os_event_flags_t *ef) { +static void osRtxEventFlagsPostProcess(os_event_flags_t *ef) { os_thread_t *thread; os_thread_t *thread_next; - uint32_t event_flags; + uint32_t event_flags; // Check if Threads are waiting for Event Flags thread = ef->thread_list; while (thread != NULL) { thread_next = thread->thread_next; - event_flags = EventFlagsCheck(ef, thread->wait_flags, thread->flags_options); + event_flags = + EventFlagsCheck(ef, thread->wait_flags, thread->flags_options); if (event_flags != 0U) { osRtxThreadListRemove(thread); osRtxThreadWaitExit(thread, event_flags, FALSE); - EvrRtxEventFlagsWaitCompleted(ef, thread->wait_flags, thread->flags_options, event_flags); + EvrRtxEventFlagsWaitCompleted(ef, thread->wait_flags, + thread->flags_options, event_flags); } thread = thread_next; } } - // ==== Service Calls ==== /// Create and Initialize an Event Flags object. /// \note API identical to osEventFlagsNew -static osEventFlagsId_t svcRtxEventFlagsNew (const osEventFlagsAttr_t *attr) { +static osEventFlagsId_t svcRtxEventFlagsNew(const osEventFlagsAttr_t *attr) { os_event_flags_t *ef; - uint8_t flags; - const char *name; + uint8_t flags; + const char *name; // Process attributes if (attr != NULL) { name = attr->name; - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 6] - ef = attr->cb_mem; + // lint -e{9079} "conversion from pointer to void to pointer to other type" + // [MISRA Note 6] + ef = attr->cb_mem; if (ef != NULL) { - //lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note 7] - if ((((uint32_t)ef & 3U) != 0U) || (attr->cb_size < sizeof(os_event_flags_t))) { + // lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note + // 7] + if ((((uint32_t)ef & 3U) != 0U) || + (attr->cb_size < sizeof(os_event_flags_t))) { EvrRtxEventFlagsError(NULL, osRtxErrorInvalidControlBlock); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } else { if (attr->cb_size != 0U) { EvrRtxEventFlagsError(NULL, osRtxErrorInvalidControlBlock); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } } else { name = NULL; - ef = NULL; + ef = NULL; } // Allocate object memory if not provided if (ef == NULL) { if (osRtxInfo.mpi.event_flags != NULL) { - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] ef = osRtxMemoryPoolAlloc(osRtxInfo.mpi.event_flags); } else { - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] ef = osRtxMemoryAlloc(osRtxInfo.mem.common, sizeof(os_event_flags_t), 1U); } #if (defined(OS_OBJ_MEM_USAGE) && (OS_OBJ_MEM_USAGE != 0)) if (ef != NULL) { uint32_t used; osRtxEventFlagsMemUsage.cnt_alloc++; - used = osRtxEventFlagsMemUsage.cnt_alloc - osRtxEventFlagsMemUsage.cnt_free; + used = + osRtxEventFlagsMemUsage.cnt_alloc - osRtxEventFlagsMemUsage.cnt_free; if (osRtxEventFlagsMemUsage.max_used < used) { osRtxEventFlagsMemUsage.max_used = used; } @@ -217,9 +224,9 @@ static osEventFlagsId_t svcRtxEventFlagsNew (const osEventFlagsAttr_t *attr) { if (ef != NULL) { // Initialize control block - ef->id = osRtxIdEventFlags; - ef->flags = flags; - ef->name = name; + ef->id = osRtxIdEventFlags; + ef->flags = flags; + ef->name = name; ef->thread_list = NULL; ef->event_flags = 0U; @@ -236,13 +243,13 @@ static osEventFlagsId_t svcRtxEventFlagsNew (const osEventFlagsAttr_t *attr) { /// Get name of an Event Flags object. /// \note API identical to osEventFlagsGetName -static const char *svcRtxEventFlagsGetName (osEventFlagsId_t ef_id) { +static const char *svcRtxEventFlagsGetName(osEventFlagsId_t ef_id) { os_event_flags_t *ef = osRtxEventFlagsId(ef_id); // Check parameters if ((ef == NULL) || (ef->id != osRtxIdEventFlags)) { EvrRtxEventFlagsGetName(ef, NULL); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } @@ -253,18 +260,18 @@ static const char *svcRtxEventFlagsGetName (osEventFlagsId_t ef_id) { /// Set the specified Event Flags. /// \note API identical to osEventFlagsSet -static uint32_t svcRtxEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags) { +static uint32_t svcRtxEventFlagsSet(osEventFlagsId_t ef_id, uint32_t flags) { os_event_flags_t *ef = osRtxEventFlagsId(ef_id); - os_thread_t *thread; - os_thread_t *thread_next; - uint32_t event_flags; - uint32_t event_flags0; + os_thread_t *thread; + os_thread_t *thread_next; + uint32_t event_flags; + uint32_t event_flags0; // Check parameters if ((ef == NULL) || (ef->id != osRtxIdEventFlags) || ((flags & ~(((uint32_t)1U << osRtxEventFlagsLimit) - 1U)) != 0U)) { EvrRtxEventFlagsError(ef, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return ((uint32_t)osErrorParameter); } @@ -275,7 +282,8 @@ static uint32_t svcRtxEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags) { thread = ef->thread_list; while (thread != NULL) { thread_next = thread->thread_next; - event_flags0 = EventFlagsCheck(ef, thread->wait_flags, thread->flags_options); + event_flags0 = + EventFlagsCheck(ef, thread->wait_flags, thread->flags_options); if (event_flags0 != 0U) { if ((thread->flags_options & osFlagsNoClear) == 0U) { event_flags = event_flags0 & ~thread->wait_flags; @@ -284,7 +292,8 @@ static uint32_t svcRtxEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags) { } osRtxThreadListRemove(thread); osRtxThreadWaitExit(thread, event_flags0, FALSE); - EvrRtxEventFlagsWaitCompleted(ef, thread->wait_flags, thread->flags_options, event_flags0); + EvrRtxEventFlagsWaitCompleted(ef, thread->wait_flags, + thread->flags_options, event_flags0); } thread = thread_next; } @@ -297,15 +306,15 @@ static uint32_t svcRtxEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags) { /// Clear the specified Event Flags. /// \note API identical to osEventFlagsClear -static uint32_t svcRtxEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags) { +static uint32_t svcRtxEventFlagsClear(osEventFlagsId_t ef_id, uint32_t flags) { os_event_flags_t *ef = osRtxEventFlagsId(ef_id); - uint32_t event_flags; + uint32_t event_flags; // Check parameters if ((ef == NULL) || (ef->id != osRtxIdEventFlags) || ((flags & ~(((uint32_t)1U << osRtxEventFlagsLimit) - 1U)) != 0U)) { EvrRtxEventFlagsError(ef, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return ((uint32_t)osErrorParameter); } @@ -319,13 +328,13 @@ static uint32_t svcRtxEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags) { /// Get the current Event Flags. /// \note API identical to osEventFlagsGet -static uint32_t svcRtxEventFlagsGet (osEventFlagsId_t ef_id) { +static uint32_t svcRtxEventFlagsGet(osEventFlagsId_t ef_id) { os_event_flags_t *ef = osRtxEventFlagsId(ef_id); // Check parameters if ((ef == NULL) || (ef->id != osRtxIdEventFlags)) { EvrRtxEventFlagsGet(ef, 0U); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } @@ -336,16 +345,17 @@ static uint32_t svcRtxEventFlagsGet (osEventFlagsId_t ef_id) { /// Wait for one or more Event Flags to become signaled. /// \note API identical to osEventFlagsWait -static uint32_t svcRtxEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout) { +static uint32_t svcRtxEventFlagsWait(osEventFlagsId_t ef_id, uint32_t flags, + uint32_t options, uint32_t timeout) { os_event_flags_t *ef = osRtxEventFlagsId(ef_id); - os_thread_t *thread; - uint32_t event_flags; + os_thread_t *thread; + uint32_t event_flags; // Check parameters if ((ef == NULL) || (ef->id != osRtxIdEventFlags) || ((flags & ~(((uint32_t)1U << osRtxEventFlagsLimit) - 1U)) != 0U)) { EvrRtxEventFlagsError(ef, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return ((uint32_t)osErrorParameter); } @@ -379,14 +389,14 @@ static uint32_t svcRtxEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, ui /// Delete an Event Flags object. /// \note API identical to osEventFlagsDelete -static osStatus_t svcRtxEventFlagsDelete (osEventFlagsId_t ef_id) { +static osStatus_t svcRtxEventFlagsDelete(osEventFlagsId_t ef_id) { os_event_flags_t *ef = osRtxEventFlagsId(ef_id); - os_thread_t *thread; + os_thread_t *thread; // Check parameters if ((ef == NULL) || (ef->id != osRtxIdEventFlags)) { EvrRtxEventFlagsError(ef, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } @@ -420,31 +430,30 @@ static osStatus_t svcRtxEventFlagsDelete (osEventFlagsId_t ef_id) { } // Service Calls definitions -//lint ++flb "Library Begin" [MISRA Note 11] -SVC0_1(EventFlagsNew, osEventFlagsId_t, const osEventFlagsAttr_t *) -SVC0_1(EventFlagsGetName, const char *, osEventFlagsId_t) -SVC0_2(EventFlagsSet, uint32_t, osEventFlagsId_t, uint32_t) -SVC0_2(EventFlagsClear, uint32_t, osEventFlagsId_t, uint32_t) -SVC0_1(EventFlagsGet, uint32_t, osEventFlagsId_t) -SVC0_4(EventFlagsWait, uint32_t, osEventFlagsId_t, uint32_t, uint32_t, uint32_t) -SVC0_1(EventFlagsDelete, osStatus_t, osEventFlagsId_t) -//lint --flb "Library End" - +// lint ++flb "Library Begin" [MISRA Note 11] +SVC0_1(EventFlagsNew, osEventFlagsId_t, const osEventFlagsAttr_t *) +SVC0_1(EventFlagsGetName, const char *, osEventFlagsId_t) +SVC0_2(EventFlagsSet, uint32_t, osEventFlagsId_t, uint32_t) +SVC0_2(EventFlagsClear, uint32_t, osEventFlagsId_t, uint32_t) +SVC0_1(EventFlagsGet, uint32_t, osEventFlagsId_t) +SVC0_4(EventFlagsWait, uint32_t, osEventFlagsId_t, uint32_t, uint32_t, uint32_t) +SVC0_1(EventFlagsDelete, osStatus_t, osEventFlagsId_t) +// lint --flb "Library End" // ==== ISR Calls ==== /// Set the specified Event Flags. /// \note API identical to osEventFlagsSet __STATIC_INLINE -uint32_t isrRtxEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags) { +uint32_t isrRtxEventFlagsSet(osEventFlagsId_t ef_id, uint32_t flags) { os_event_flags_t *ef = osRtxEventFlagsId(ef_id); - uint32_t event_flags; + uint32_t event_flags; // Check parameters if ((ef == NULL) || (ef->id != osRtxIdEventFlags) || ((flags & ~(((uint32_t)1U << osRtxEventFlagsLimit) - 1U)) != 0U)) { EvrRtxEventFlagsError(ef, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return ((uint32_t)osErrorParameter); } @@ -462,15 +471,16 @@ uint32_t isrRtxEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags) { /// Wait for one or more Event Flags to become signaled. /// \note API identical to osEventFlagsWait __STATIC_INLINE -uint32_t isrRtxEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout) { +uint32_t isrRtxEventFlagsWait(osEventFlagsId_t ef_id, uint32_t flags, + uint32_t options, uint32_t timeout) { os_event_flags_t *ef = osRtxEventFlagsId(ef_id); - uint32_t event_flags; + uint32_t event_flags; // Check parameters if ((ef == NULL) || (ef->id != osRtxIdEventFlags) || (timeout != 0U) || ((flags & ~(((uint32_t)1U << osRtxEventFlagsLimit) - 1U)) != 0U)) { EvrRtxEventFlagsError(ef, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return ((uint32_t)osErrorParameter); } @@ -486,11 +496,10 @@ uint32_t isrRtxEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t return event_flags; } - // ==== Public API ==== /// Create and Initialize an Event Flags object. -osEventFlagsId_t osEventFlagsNew (const osEventFlagsAttr_t *attr) { +osEventFlagsId_t osEventFlagsNew(const osEventFlagsAttr_t *attr) { osEventFlagsId_t ef_id; EvrRtxEventFlagsNew(attr); @@ -504,7 +513,7 @@ osEventFlagsId_t osEventFlagsNew (const osEventFlagsAttr_t *attr) { } /// Get name of an Event Flags object. -const char *osEventFlagsGetName (osEventFlagsId_t ef_id) { +const char *osEventFlagsGetName(osEventFlagsId_t ef_id) { const char *name; if (IsIrqMode() || IsIrqMasked()) { @@ -517,58 +526,59 @@ const char *osEventFlagsGetName (osEventFlagsId_t ef_id) { } /// Set the specified Event Flags. -uint32_t osEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags) { +uint32_t osEventFlagsSet(osEventFlagsId_t ef_id, uint32_t flags) { uint32_t event_flags; EvrRtxEventFlagsSet(ef_id, flags); if (IsIrqMode() || IsIrqMasked()) { event_flags = isrRtxEventFlagsSet(ef_id, flags); } else { - event_flags = __svcEventFlagsSet(ef_id, flags); + event_flags = __svcEventFlagsSet(ef_id, flags); } return event_flags; } /// Clear the specified Event Flags. -uint32_t osEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags) { +uint32_t osEventFlagsClear(osEventFlagsId_t ef_id, uint32_t flags) { uint32_t event_flags; EvrRtxEventFlagsClear(ef_id, flags); if (IsIrqMode() || IsIrqMasked()) { event_flags = svcRtxEventFlagsClear(ef_id, flags); } else { - event_flags = __svcEventFlagsClear(ef_id, flags); + event_flags = __svcEventFlagsClear(ef_id, flags); } return event_flags; } /// Get the current Event Flags. -uint32_t osEventFlagsGet (osEventFlagsId_t ef_id) { +uint32_t osEventFlagsGet(osEventFlagsId_t ef_id) { uint32_t event_flags; if (IsIrqMode() || IsIrqMasked()) { event_flags = svcRtxEventFlagsGet(ef_id); } else { - event_flags = __svcEventFlagsGet(ef_id); + event_flags = __svcEventFlagsGet(ef_id); } return event_flags; } /// Wait for one or more Event Flags to become signaled. -uint32_t osEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout) { +uint32_t osEventFlagsWait(osEventFlagsId_t ef_id, uint32_t flags, + uint32_t options, uint32_t timeout) { uint32_t event_flags; EvrRtxEventFlagsWait(ef_id, flags, options, timeout); if (IsIrqMode() || IsIrqMasked()) { event_flags = isrRtxEventFlagsWait(ef_id, flags, options, timeout); } else { - event_flags = __svcEventFlagsWait(ef_id, flags, options, timeout); + event_flags = __svcEventFlagsWait(ef_id, flags, options, timeout); } return event_flags; } /// Delete an Event Flags object. -osStatus_t osEventFlagsDelete (osEventFlagsId_t ef_id) { +osStatus_t osEventFlagsDelete(osEventFlagsId_t ef_id) { osStatus_t status; EvrRtxEventFlagsDelete(ef_id); diff --git a/rtos/rtx5/rtx_evr.c b/rtos/rtx5/rtx_evr.c index a313dae..f954458 100644 --- a/rtos/rtx5/rtx_evr.c +++ b/rtos/rtx5/rtx_evr.c @@ -23,221 +23,280 @@ * ----------------------------------------------------------------------------- */ -#include +#include "rtx_evr.h" // RTX Event Recorder definitions #include "cmsis_compiler.h" -#include "rtx_evr.h" // RTX Event Recorder definitions -#include "rtx_lib.h" #include "hal_trace.h" +#include "rtx_lib.h" +#include -#ifdef RTE_Compiler_EventRecorder +#ifdef RTE_Compiler_EventRecorder -//lint -e923 -e9074 -e9078 [MISRA Note 13] +// lint -e923 -e9074 -e9078 [MISRA Note 13] /// Event IDs for "RTX Memory Management" -#define EvtRtxMemoryInit EventID(EventLevelOp, EvtRtxMemoryNo, 0x00U) -#define EvtRtxMemoryAlloc EventID(EventLevelOp, EvtRtxMemoryNo, 0x01U) -#define EvtRtxMemoryFree EventID(EventLevelOp, EvtRtxMemoryNo, 0x02U) -#define EvtRtxMemoryBlockInit EventID(EventLevelOp, EvtRtxMemoryNo, 0x03U) -#define EvtRtxMemoryBlockAlloc EventID(EventLevelOp, EvtRtxMemoryNo, 0x04U) -#define EvtRtxMemoryBlockFree EventID(EventLevelOp, EvtRtxMemoryNo, 0x05U) +#define EvtRtxMemoryInit EventID(EventLevelOp, EvtRtxMemoryNo, 0x00U) +#define EvtRtxMemoryAlloc EventID(EventLevelOp, EvtRtxMemoryNo, 0x01U) +#define EvtRtxMemoryFree EventID(EventLevelOp, EvtRtxMemoryNo, 0x02U) +#define EvtRtxMemoryBlockInit EventID(EventLevelOp, EvtRtxMemoryNo, 0x03U) +#define EvtRtxMemoryBlockAlloc EventID(EventLevelOp, EvtRtxMemoryNo, 0x04U) +#define EvtRtxMemoryBlockFree EventID(EventLevelOp, EvtRtxMemoryNo, 0x05U) /// Event IDs for "RTX Kernel" -#define EvtRtxKernelError EventID(EventLevelError, EvtRtxKernelNo, 0x00U) -#define EvtRtxKernelInitialize EventID(EventLevelAPI, EvtRtxKernelNo, 0x01U) -#define EvtRtxKernelInitialized EventID(EventLevelOp, EvtRtxKernelNo, 0x02U) -#define EvtRtxKernelGetInfo EventID(EventLevelAPI, EvtRtxKernelNo, 0x03U) -#define EvtRtxKernelInfoRetrieved EventID(EventLevelOp, EvtRtxKernelNo, 0x04U) -#define EvtRtxKernelInfoRetrieved_Detail EventID(EventLevelDetail, EvtRtxKernelNo, 0x05U) -#define EvtRtxKernelGetState EventID(EventLevelAPI, EvtRtxKernelNo, 0x06U) -#define EvtRtxKernelStart EventID(EventLevelAPI, EvtRtxKernelNo, 0x07U) -#define EvtRtxKernelStarted EventID(EventLevelOp, EvtRtxKernelNo, 0x08U) -#define EvtRtxKernelLock EventID(EventLevelAPI, EvtRtxKernelNo, 0x09U) -#define EvtRtxKernelLocked EventID(EventLevelOp, EvtRtxKernelNo, 0x0AU) -#define EvtRtxKernelUnlock EventID(EventLevelAPI, EvtRtxKernelNo, 0x0BU) -#define EvtRtxKernelUnlocked EventID(EventLevelOp, EvtRtxKernelNo, 0x0CU) -#define EvtRtxKernelRestoreLock EventID(EventLevelAPI, EvtRtxKernelNo, 0x0DU) -#define EvtRtxKernelLockRestored EventID(EventLevelOp, EvtRtxKernelNo, 0x0EU) -#define EvtRtxKernelSuspend EventID(EventLevelAPI, EvtRtxKernelNo, 0x0FU) -#define EvtRtxKernelSuspended EventID(EventLevelOp, EvtRtxKernelNo, 0x10U) -#define EvtRtxKernelResume EventID(EventLevelAPI, EvtRtxKernelNo, 0x11U) -#define EvtRtxKernelResumed EventID(EventLevelOp, EvtRtxKernelNo, 0x12U) -#define EvtRtxKernelGetTickCount EventID(EventLevelAPI, EvtRtxKernelNo, 0x13U) -#define EvtRtxKernelGetTickFreq EventID(EventLevelAPI, EvtRtxKernelNo, 0x14U) -#define EvtRtxKernelGetSysTimerCount EventID(EventLevelAPI, EvtRtxKernelNo, 0x15U) -#define EvtRtxKernelGetSysTimerFreq EventID(EventLevelAPI, EvtRtxKernelNo, 0x16U) +#define EvtRtxKernelError EventID(EventLevelError, EvtRtxKernelNo, 0x00U) +#define EvtRtxKernelInitialize EventID(EventLevelAPI, EvtRtxKernelNo, 0x01U) +#define EvtRtxKernelInitialized EventID(EventLevelOp, EvtRtxKernelNo, 0x02U) +#define EvtRtxKernelGetInfo EventID(EventLevelAPI, EvtRtxKernelNo, 0x03U) +#define EvtRtxKernelInfoRetrieved EventID(EventLevelOp, EvtRtxKernelNo, 0x04U) +#define EvtRtxKernelInfoRetrieved_Detail \ + EventID(EventLevelDetail, EvtRtxKernelNo, 0x05U) +#define EvtRtxKernelGetState EventID(EventLevelAPI, EvtRtxKernelNo, 0x06U) +#define EvtRtxKernelStart EventID(EventLevelAPI, EvtRtxKernelNo, 0x07U) +#define EvtRtxKernelStarted EventID(EventLevelOp, EvtRtxKernelNo, 0x08U) +#define EvtRtxKernelLock EventID(EventLevelAPI, EvtRtxKernelNo, 0x09U) +#define EvtRtxKernelLocked EventID(EventLevelOp, EvtRtxKernelNo, 0x0AU) +#define EvtRtxKernelUnlock EventID(EventLevelAPI, EvtRtxKernelNo, 0x0BU) +#define EvtRtxKernelUnlocked EventID(EventLevelOp, EvtRtxKernelNo, 0x0CU) +#define EvtRtxKernelRestoreLock EventID(EventLevelAPI, EvtRtxKernelNo, 0x0DU) +#define EvtRtxKernelLockRestored EventID(EventLevelOp, EvtRtxKernelNo, 0x0EU) +#define EvtRtxKernelSuspend EventID(EventLevelAPI, EvtRtxKernelNo, 0x0FU) +#define EvtRtxKernelSuspended EventID(EventLevelOp, EvtRtxKernelNo, 0x10U) +#define EvtRtxKernelResume EventID(EventLevelAPI, EvtRtxKernelNo, 0x11U) +#define EvtRtxKernelResumed EventID(EventLevelOp, EvtRtxKernelNo, 0x12U) +#define EvtRtxKernelGetTickCount EventID(EventLevelAPI, EvtRtxKernelNo, 0x13U) +#define EvtRtxKernelGetTickFreq EventID(EventLevelAPI, EvtRtxKernelNo, 0x14U) +#define EvtRtxKernelGetSysTimerCount \ + EventID(EventLevelAPI, EvtRtxKernelNo, 0x15U) +#define EvtRtxKernelGetSysTimerFreq \ + EventID(EventLevelAPI, EvtRtxKernelNo, 0x16U) /// Event IDs for "RTX Thread" -#define EvtRtxThreadError EventID(EventLevelError, EvtRtxThreadNo, 0x00U) -#define EvtRtxThreadNew EventID(EventLevelAPI, EvtRtxThreadNo, 0x01U) -#define EvtRtxThreadCreated_Addr EventID(EventLevelOp, EvtRtxThreadNo, 0x03U) -#define EvtRtxThreadCreated_Name EventID(EventLevelOp, EvtRtxThreadNo, 0x2CU) -#define EvtRtxThreadGetName EventID(EventLevelAPI, EvtRtxThreadNo, 0x04U) -#define EvtRtxThreadGetId EventID(EventLevelAPI, EvtRtxThreadNo, 0x06U) -#define EvtRtxThreadGetState EventID(EventLevelAPI, EvtRtxThreadNo, 0x07U) -#define EvtRtxThreadGetStackSize EventID(EventLevelAPI, EvtRtxThreadNo, 0x08U) -#define EvtRtxThreadGetStackSpace EventID(EventLevelAPI, EvtRtxThreadNo, 0x09U) -#define EvtRtxThreadSetPriority EventID(EventLevelAPI, EvtRtxThreadNo, 0x0AU) -#define EvtRtxThreadPriorityUpdated EventID(EventLevelOp, EvtRtxThreadNo, 0x2DU) -#define EvtRtxThreadGetPriority EventID(EventLevelAPI, EvtRtxThreadNo, 0x0BU) -#define EvtRtxThreadYield EventID(EventLevelAPI, EvtRtxThreadNo, 0x0CU) -#define EvtRtxThreadSuspend EventID(EventLevelAPI, EvtRtxThreadNo, 0x0DU) -#define EvtRtxThreadSuspended EventID(EventLevelOp, EvtRtxThreadNo, 0x0EU) -#define EvtRtxThreadResume EventID(EventLevelAPI, EvtRtxThreadNo, 0x0FU) -#define EvtRtxThreadResumed EventID(EventLevelOp, EvtRtxThreadNo, 0x10U) -#define EvtRtxThreadDetach EventID(EventLevelAPI, EvtRtxThreadNo, 0x11U) -#define EvtRtxThreadDetached EventID(EventLevelOp, EvtRtxThreadNo, 0x12U) -#define EvtRtxThreadJoin EventID(EventLevelAPI, EvtRtxThreadNo, 0x13U) -#define EvtRtxThreadJoinPending EventID(EventLevelOp, EvtRtxThreadNo, 0x14U) -#define EvtRtxThreadJoined EventID(EventLevelOp, EvtRtxThreadNo, 0x15U) -#define EvtRtxThreadBlocked EventID(EventLevelDetail, EvtRtxThreadNo, 0x16U) -#define EvtRtxThreadUnblocked EventID(EventLevelDetail, EvtRtxThreadNo, 0x17U) -#define EvtRtxThreadPreempted EventID(EventLevelDetail, EvtRtxThreadNo, 0x18U) -#define EvtRtxThreadSwitched EventID(EventLevelOp, EvtRtxThreadNo, 0x19U) -#define EvtRtxThreadExit EventID(EventLevelAPI, EvtRtxThreadNo, 0x1AU) -#define EvtRtxThreadTerminate EventID(EventLevelAPI, EvtRtxThreadNo, 0x1BU) -#define EvtRtxThreadDestroyed EventID(EventLevelOp, EvtRtxThreadNo, 0x1CU) -#define EvtRtxThreadGetCount EventID(EventLevelAPI, EvtRtxThreadNo, 0x1DU) -#define EvtRtxThreadEnumerate EventID(EventLevelAPI, EvtRtxThreadNo, 0x1EU) +#define EvtRtxThreadError EventID(EventLevelError, EvtRtxThreadNo, 0x00U) +#define EvtRtxThreadNew EventID(EventLevelAPI, EvtRtxThreadNo, 0x01U) +#define EvtRtxThreadCreated_Addr EventID(EventLevelOp, EvtRtxThreadNo, 0x03U) +#define EvtRtxThreadCreated_Name EventID(EventLevelOp, EvtRtxThreadNo, 0x2CU) +#define EvtRtxThreadGetName EventID(EventLevelAPI, EvtRtxThreadNo, 0x04U) +#define EvtRtxThreadGetId EventID(EventLevelAPI, EvtRtxThreadNo, 0x06U) +#define EvtRtxThreadGetState EventID(EventLevelAPI, EvtRtxThreadNo, 0x07U) +#define EvtRtxThreadGetStackSize EventID(EventLevelAPI, EvtRtxThreadNo, 0x08U) +#define EvtRtxThreadGetStackSpace EventID(EventLevelAPI, EvtRtxThreadNo, 0x09U) +#define EvtRtxThreadSetPriority EventID(EventLevelAPI, EvtRtxThreadNo, 0x0AU) +#define EvtRtxThreadPriorityUpdated EventID(EventLevelOp, EvtRtxThreadNo, 0x2DU) +#define EvtRtxThreadGetPriority EventID(EventLevelAPI, EvtRtxThreadNo, 0x0BU) +#define EvtRtxThreadYield EventID(EventLevelAPI, EvtRtxThreadNo, 0x0CU) +#define EvtRtxThreadSuspend EventID(EventLevelAPI, EvtRtxThreadNo, 0x0DU) +#define EvtRtxThreadSuspended EventID(EventLevelOp, EvtRtxThreadNo, 0x0EU) +#define EvtRtxThreadResume EventID(EventLevelAPI, EvtRtxThreadNo, 0x0FU) +#define EvtRtxThreadResumed EventID(EventLevelOp, EvtRtxThreadNo, 0x10U) +#define EvtRtxThreadDetach EventID(EventLevelAPI, EvtRtxThreadNo, 0x11U) +#define EvtRtxThreadDetached EventID(EventLevelOp, EvtRtxThreadNo, 0x12U) +#define EvtRtxThreadJoin EventID(EventLevelAPI, EvtRtxThreadNo, 0x13U) +#define EvtRtxThreadJoinPending EventID(EventLevelOp, EvtRtxThreadNo, 0x14U) +#define EvtRtxThreadJoined EventID(EventLevelOp, EvtRtxThreadNo, 0x15U) +#define EvtRtxThreadBlocked EventID(EventLevelDetail, EvtRtxThreadNo, 0x16U) +#define EvtRtxThreadUnblocked EventID(EventLevelDetail, EvtRtxThreadNo, 0x17U) +#define EvtRtxThreadPreempted EventID(EventLevelDetail, EvtRtxThreadNo, 0x18U) +#define EvtRtxThreadSwitched EventID(EventLevelOp, EvtRtxThreadNo, 0x19U) +#define EvtRtxThreadExit EventID(EventLevelAPI, EvtRtxThreadNo, 0x1AU) +#define EvtRtxThreadTerminate EventID(EventLevelAPI, EvtRtxThreadNo, 0x1BU) +#define EvtRtxThreadDestroyed EventID(EventLevelOp, EvtRtxThreadNo, 0x1CU) +#define EvtRtxThreadGetCount EventID(EventLevelAPI, EvtRtxThreadNo, 0x1DU) +#define EvtRtxThreadEnumerate EventID(EventLevelAPI, EvtRtxThreadNo, 0x1EU) /// Event IDs for "RTX Thread Flags" -#define EvtRtxThreadFlagsError EventID(EventLevelError, EvtRtxThreadFlagsNo, 0x00U) -#define EvtRtxThreadFlagsSet EventID(EventLevelAPI, EvtRtxThreadFlagsNo, 0x01U) -#define EvtRtxThreadFlagsSetDone EventID(EventLevelOp, EvtRtxThreadFlagsNo, 0x02U) -#define EvtRtxThreadFlagsClear EventID(EventLevelAPI, EvtRtxThreadFlagsNo, 0x03U) -#define EvtRtxThreadFlagsClearDone EventID(EventLevelOp, EvtRtxThreadFlagsNo, 0x04U) -#define EvtRtxThreadFlagsGet EventID(EventLevelAPI, EvtRtxThreadFlagsNo, 0x05U) -#define EvtRtxThreadFlagsWait EventID(EventLevelAPI, EvtRtxThreadFlagsNo, 0x06U) -#define EvtRtxThreadFlagsWaitPending EventID(EventLevelOp, EvtRtxThreadFlagsNo, 0x07U) -#define EvtRtxThreadFlagsWaitTimeout EventID(EventLevelOp, EvtRtxThreadFlagsNo, 0x08U) -#define EvtRtxThreadFlagsWaitCompleted EventID(EventLevelOp, EvtRtxThreadFlagsNo, 0x09U) -#define EvtRtxThreadFlagsWaitNotCompleted EventID(EventLevelOp, EvtRtxThreadFlagsNo, 0x0AU) +#define EvtRtxThreadFlagsError \ + EventID(EventLevelError, EvtRtxThreadFlagsNo, 0x00U) +#define EvtRtxThreadFlagsSet EventID(EventLevelAPI, EvtRtxThreadFlagsNo, 0x01U) +#define EvtRtxThreadFlagsSetDone \ + EventID(EventLevelOp, EvtRtxThreadFlagsNo, 0x02U) +#define EvtRtxThreadFlagsClear \ + EventID(EventLevelAPI, EvtRtxThreadFlagsNo, 0x03U) +#define EvtRtxThreadFlagsClearDone \ + EventID(EventLevelOp, EvtRtxThreadFlagsNo, 0x04U) +#define EvtRtxThreadFlagsGet EventID(EventLevelAPI, EvtRtxThreadFlagsNo, 0x05U) +#define EvtRtxThreadFlagsWait EventID(EventLevelAPI, EvtRtxThreadFlagsNo, 0x06U) +#define EvtRtxThreadFlagsWaitPending \ + EventID(EventLevelOp, EvtRtxThreadFlagsNo, 0x07U) +#define EvtRtxThreadFlagsWaitTimeout \ + EventID(EventLevelOp, EvtRtxThreadFlagsNo, 0x08U) +#define EvtRtxThreadFlagsWaitCompleted \ + EventID(EventLevelOp, EvtRtxThreadFlagsNo, 0x09U) +#define EvtRtxThreadFlagsWaitNotCompleted \ + EventID(EventLevelOp, EvtRtxThreadFlagsNo, 0x0AU) /// Event IDs for "RTX Generic Wait" -#define EvtRtxDelayError EventID(EventLevelError, EvtRtxWaitNo, 0x00U) -#define EvtRtxDelay EventID(EventLevelAPI, EvtRtxWaitNo, 0x01U) -#define EvtRtxDelayUntil EventID(EventLevelAPI, EvtRtxWaitNo, 0x02U) -#define EvtRtxDelayStarted EventID(EventLevelOp, EvtRtxWaitNo, 0x03U) -#define EvtRtxDelayUntilStarted EventID(EventLevelOp, EvtRtxWaitNo, 0x04U) -#define EvtRtxDelayCompleted EventID(EventLevelOp, EvtRtxWaitNo, 0x05U) +#define EvtRtxDelayError EventID(EventLevelError, EvtRtxWaitNo, 0x00U) +#define EvtRtxDelay EventID(EventLevelAPI, EvtRtxWaitNo, 0x01U) +#define EvtRtxDelayUntil EventID(EventLevelAPI, EvtRtxWaitNo, 0x02U) +#define EvtRtxDelayStarted EventID(EventLevelOp, EvtRtxWaitNo, 0x03U) +#define EvtRtxDelayUntilStarted EventID(EventLevelOp, EvtRtxWaitNo, 0x04U) +#define EvtRtxDelayCompleted EventID(EventLevelOp, EvtRtxWaitNo, 0x05U) /// Event IDs for "RTX Timer" -#define EvtRtxTimerError EventID(EventLevelError, EvtRtxTimerNo, 0x00U) -#define EvtRtxTimerCallback EventID(EventLevelOp, EvtRtxTimerNo, 0x01U) -#define EvtRtxTimerNew EventID(EventLevelAPI, EvtRtxTimerNo, 0x02U) -#define EvtRtxTimerCreated EventID(EventLevelOp, EvtRtxTimerNo, 0x04U) -#define EvtRtxTimerGetName EventID(EventLevelAPI, EvtRtxTimerNo, 0x05U) -#define EvtRtxTimerStart EventID(EventLevelAPI, EvtRtxTimerNo, 0x07U) -#define EvtRtxTimerStarted EventID(EventLevelOp, EvtRtxTimerNo, 0x08U) -#define EvtRtxTimerStop EventID(EventLevelAPI, EvtRtxTimerNo, 0x09U) -#define EvtRtxTimerStopped EventID(EventLevelOp, EvtRtxTimerNo, 0x0AU) -#define EvtRtxTimerIsRunning EventID(EventLevelAPI, EvtRtxTimerNo, 0x0BU) -#define EvtRtxTimerDelete EventID(EventLevelAPI, EvtRtxTimerNo, 0x0CU) -#define EvtRtxTimerDestroyed EventID(EventLevelOp, EvtRtxTimerNo, 0x0DU) +#define EvtRtxTimerError EventID(EventLevelError, EvtRtxTimerNo, 0x00U) +#define EvtRtxTimerCallback EventID(EventLevelOp, EvtRtxTimerNo, 0x01U) +#define EvtRtxTimerNew EventID(EventLevelAPI, EvtRtxTimerNo, 0x02U) +#define EvtRtxTimerCreated EventID(EventLevelOp, EvtRtxTimerNo, 0x04U) +#define EvtRtxTimerGetName EventID(EventLevelAPI, EvtRtxTimerNo, 0x05U) +#define EvtRtxTimerStart EventID(EventLevelAPI, EvtRtxTimerNo, 0x07U) +#define EvtRtxTimerStarted EventID(EventLevelOp, EvtRtxTimerNo, 0x08U) +#define EvtRtxTimerStop EventID(EventLevelAPI, EvtRtxTimerNo, 0x09U) +#define EvtRtxTimerStopped EventID(EventLevelOp, EvtRtxTimerNo, 0x0AU) +#define EvtRtxTimerIsRunning EventID(EventLevelAPI, EvtRtxTimerNo, 0x0BU) +#define EvtRtxTimerDelete EventID(EventLevelAPI, EvtRtxTimerNo, 0x0CU) +#define EvtRtxTimerDestroyed EventID(EventLevelOp, EvtRtxTimerNo, 0x0DU) /// Event IDs for "RTX Event Flags" -#define EvtRtxEventFlagsError EventID(EventLevelError, EvtRtxEventFlagsNo, 0x00U) -#define EvtRtxEventFlagsNew EventID(EventLevelAPI, EvtRtxEventFlagsNo, 0x01U) -#define EvtRtxEventFlagsCreated EventID(EventLevelOp, EvtRtxEventFlagsNo, 0x03U) -#define EvtRtxEventFlagsGetName EventID(EventLevelAPI, EvtRtxEventFlagsNo, 0x04U) -#define EvtRtxEventFlagsSet EventID(EventLevelAPI, EvtRtxEventFlagsNo, 0x06U) -#define EvtRtxEventFlagsSetDone EventID(EventLevelOp, EvtRtxEventFlagsNo, 0x07U) -#define EvtRtxEventFlagsClear EventID(EventLevelAPI, EvtRtxEventFlagsNo, 0x08U) -#define EvtRtxEventFlagsClearDone EventID(EventLevelOp, EvtRtxEventFlagsNo, 0x09U) -#define EvtRtxEventFlagsGet EventID(EventLevelAPI, EvtRtxEventFlagsNo, 0x0AU) -#define EvtRtxEventFlagsWait EventID(EventLevelAPI, EvtRtxEventFlagsNo, 0x0BU) -#define EvtRtxEventFlagsWaitPending EventID(EventLevelOp, EvtRtxEventFlagsNo, 0x0CU) -#define EvtRtxEventFlagsWaitTimeout EventID(EventLevelOp, EvtRtxEventFlagsNo, 0x0DU) -#define EvtRtxEventFlagsWaitCompleted EventID(EventLevelOp, EvtRtxEventFlagsNo, 0x0EU) -#define EvtRtxEventFlagsWaitNotCompleted EventID(EventLevelOp, EvtRtxEventFlagsNo, 0x0FU) -#define EvtRtxEventFlagsDelete EventID(EventLevelAPI, EvtRtxEventFlagsNo, 0x10U) -#define EvtRtxEventFlagsDestroyed EventID(EventLevelOp, EvtRtxEventFlagsNo, 0x11U) +#define EvtRtxEventFlagsError \ + EventID(EventLevelError, EvtRtxEventFlagsNo, 0x00U) +#define EvtRtxEventFlagsNew EventID(EventLevelAPI, EvtRtxEventFlagsNo, 0x01U) +#define EvtRtxEventFlagsCreated EventID(EventLevelOp, EvtRtxEventFlagsNo, 0x03U) +#define EvtRtxEventFlagsGetName \ + EventID(EventLevelAPI, EvtRtxEventFlagsNo, 0x04U) +#define EvtRtxEventFlagsSet EventID(EventLevelAPI, EvtRtxEventFlagsNo, 0x06U) +#define EvtRtxEventFlagsSetDone EventID(EventLevelOp, EvtRtxEventFlagsNo, 0x07U) +#define EvtRtxEventFlagsClear EventID(EventLevelAPI, EvtRtxEventFlagsNo, 0x08U) +#define EvtRtxEventFlagsClearDone \ + EventID(EventLevelOp, EvtRtxEventFlagsNo, 0x09U) +#define EvtRtxEventFlagsGet EventID(EventLevelAPI, EvtRtxEventFlagsNo, 0x0AU) +#define EvtRtxEventFlagsWait EventID(EventLevelAPI, EvtRtxEventFlagsNo, 0x0BU) +#define EvtRtxEventFlagsWaitPending \ + EventID(EventLevelOp, EvtRtxEventFlagsNo, 0x0CU) +#define EvtRtxEventFlagsWaitTimeout \ + EventID(EventLevelOp, EvtRtxEventFlagsNo, 0x0DU) +#define EvtRtxEventFlagsWaitCompleted \ + EventID(EventLevelOp, EvtRtxEventFlagsNo, 0x0EU) +#define EvtRtxEventFlagsWaitNotCompleted \ + EventID(EventLevelOp, EvtRtxEventFlagsNo, 0x0FU) +#define EvtRtxEventFlagsDelete EventID(EventLevelAPI, EvtRtxEventFlagsNo, 0x10U) +#define EvtRtxEventFlagsDestroyed \ + EventID(EventLevelOp, EvtRtxEventFlagsNo, 0x11U) /// Event IDs for "RTX Mutex" -#define EvtRtxMutexError EventID(EventLevelError, EvtRtxMutexNo, 0x00U) -#define EvtRtxMutexNew EventID(EventLevelAPI, EvtRtxMutexNo, 0x01U) -#define EvtRtxMutexCreated EventID(EventLevelOp, EvtRtxMutexNo, 0x03U) -#define EvtRtxMutexGetName EventID(EventLevelAPI, EvtRtxMutexNo, 0x04U) -#define EvtRtxMutexAcquire EventID(EventLevelAPI, EvtRtxMutexNo, 0x06U) -#define EvtRtxMutexAcquirePending EventID(EventLevelOp, EvtRtxMutexNo, 0x07U) -#define EvtRtxMutexAcquireTimeout EventID(EventLevelOp, EvtRtxMutexNo, 0x08U) -#define EvtRtxMutexAcquired EventID(EventLevelOp, EvtRtxMutexNo, 0x09U) -#define EvtRtxMutexNotAcquired EventID(EventLevelOp, EvtRtxMutexNo, 0x0AU) -#define EvtRtxMutexRelease EventID(EventLevelAPI, EvtRtxMutexNo, 0x0BU) -#define EvtRtxMutexReleased EventID(EventLevelOp, EvtRtxMutexNo, 0x0CU) -#define EvtRtxMutexGetOwner EventID(EventLevelAPI, EvtRtxMutexNo, 0x0DU) -#define EvtRtxMutexDelete EventID(EventLevelAPI, EvtRtxMutexNo, 0x0EU) -#define EvtRtxMutexDestroyed EventID(EventLevelOp, EvtRtxMutexNo, 0x0FU) +#define EvtRtxMutexError EventID(EventLevelError, EvtRtxMutexNo, 0x00U) +#define EvtRtxMutexNew EventID(EventLevelAPI, EvtRtxMutexNo, 0x01U) +#define EvtRtxMutexCreated EventID(EventLevelOp, EvtRtxMutexNo, 0x03U) +#define EvtRtxMutexGetName EventID(EventLevelAPI, EvtRtxMutexNo, 0x04U) +#define EvtRtxMutexAcquire EventID(EventLevelAPI, EvtRtxMutexNo, 0x06U) +#define EvtRtxMutexAcquirePending EventID(EventLevelOp, EvtRtxMutexNo, 0x07U) +#define EvtRtxMutexAcquireTimeout EventID(EventLevelOp, EvtRtxMutexNo, 0x08U) +#define EvtRtxMutexAcquired EventID(EventLevelOp, EvtRtxMutexNo, 0x09U) +#define EvtRtxMutexNotAcquired EventID(EventLevelOp, EvtRtxMutexNo, 0x0AU) +#define EvtRtxMutexRelease EventID(EventLevelAPI, EvtRtxMutexNo, 0x0BU) +#define EvtRtxMutexReleased EventID(EventLevelOp, EvtRtxMutexNo, 0x0CU) +#define EvtRtxMutexGetOwner EventID(EventLevelAPI, EvtRtxMutexNo, 0x0DU) +#define EvtRtxMutexDelete EventID(EventLevelAPI, EvtRtxMutexNo, 0x0EU) +#define EvtRtxMutexDestroyed EventID(EventLevelOp, EvtRtxMutexNo, 0x0FU) /// Event IDs for "RTX Semaphore" -#define EvtRtxSemaphoreError EventID(EventLevelError, EvtRtxSemaphoreNo, 0x00U) -#define EvtRtxSemaphoreNew EventID(EventLevelAPI, EvtRtxSemaphoreNo, 0x01U) -#define EvtRtxSemaphoreCreated EventID(EventLevelOp, EvtRtxSemaphoreNo, 0x03U) -#define EvtRtxSemaphoreGetName EventID(EventLevelAPI, EvtRtxSemaphoreNo, 0x04U) -#define EvtRtxSemaphoreAcquire EventID(EventLevelAPI, EvtRtxSemaphoreNo, 0x06U) -#define EvtRtxSemaphoreAcquirePending EventID(EventLevelOp, EvtRtxSemaphoreNo, 0x07U) -#define EvtRtxSemaphoreAcquireTimeout EventID(EventLevelOp, EvtRtxSemaphoreNo, 0x08U) -#define EvtRtxSemaphoreAcquired EventID(EventLevelOp, EvtRtxSemaphoreNo, 0x09U) -#define EvtRtxSemaphoreNotAcquired EventID(EventLevelOp, EvtRtxSemaphoreNo, 0x0AU) -#define EvtRtxSemaphoreRelease EventID(EventLevelAPI, EvtRtxSemaphoreNo, 0x0BU) -#define EvtRtxSemaphoreReleased EventID(EventLevelOp, EvtRtxSemaphoreNo, 0x0CU) -#define EvtRtxSemaphoreGetCount EventID(EventLevelAPI, EvtRtxSemaphoreNo, 0x0DU) -#define EvtRtxSemaphoreDelete EventID(EventLevelAPI, EvtRtxSemaphoreNo, 0x0EU) -#define EvtRtxSemaphoreDestroyed EventID(EventLevelOp, EvtRtxSemaphoreNo, 0x0FU) +#define EvtRtxSemaphoreError EventID(EventLevelError, EvtRtxSemaphoreNo, 0x00U) +#define EvtRtxSemaphoreNew EventID(EventLevelAPI, EvtRtxSemaphoreNo, 0x01U) +#define EvtRtxSemaphoreCreated EventID(EventLevelOp, EvtRtxSemaphoreNo, 0x03U) +#define EvtRtxSemaphoreGetName EventID(EventLevelAPI, EvtRtxSemaphoreNo, 0x04U) +#define EvtRtxSemaphoreAcquire EventID(EventLevelAPI, EvtRtxSemaphoreNo, 0x06U) +#define EvtRtxSemaphoreAcquirePending \ + EventID(EventLevelOp, EvtRtxSemaphoreNo, 0x07U) +#define EvtRtxSemaphoreAcquireTimeout \ + EventID(EventLevelOp, EvtRtxSemaphoreNo, 0x08U) +#define EvtRtxSemaphoreAcquired EventID(EventLevelOp, EvtRtxSemaphoreNo, 0x09U) +#define EvtRtxSemaphoreNotAcquired \ + EventID(EventLevelOp, EvtRtxSemaphoreNo, 0x0AU) +#define EvtRtxSemaphoreRelease EventID(EventLevelAPI, EvtRtxSemaphoreNo, 0x0BU) +#define EvtRtxSemaphoreReleased EventID(EventLevelOp, EvtRtxSemaphoreNo, 0x0CU) +#define EvtRtxSemaphoreGetCount EventID(EventLevelAPI, EvtRtxSemaphoreNo, 0x0DU) +#define EvtRtxSemaphoreDelete EventID(EventLevelAPI, EvtRtxSemaphoreNo, 0x0EU) +#define EvtRtxSemaphoreDestroyed EventID(EventLevelOp, EvtRtxSemaphoreNo, 0x0FU) /// Event IDs for "RTX Memory Pool" -#define EvtRtxMemoryPoolError EventID(EventLevelError, EvtRtxMemoryPoolNo, 0x00U) -#define EvtRtxMemoryPoolNew EventID(EventLevelAPI, EvtRtxMemoryPoolNo, 0x01U) -#define EvtRtxMemoryPoolCreated EventID(EventLevelOp, EvtRtxMemoryPoolNo, 0x03U) -#define EvtRtxMemoryPoolGetName EventID(EventLevelAPI, EvtRtxMemoryPoolNo, 0x04U) -#define EvtRtxMemoryPoolAlloc EventID(EventLevelAPI, EvtRtxMemoryPoolNo, 0x06U) -#define EvtRtxMemoryPoolAllocPending EventID(EventLevelOp, EvtRtxMemoryPoolNo, 0x07U) -#define EvtRtxMemoryPoolAllocTimeout EventID(EventLevelOp, EvtRtxMemoryPoolNo, 0x08U) -#define EvtRtxMemoryPoolAllocated EventID(EventLevelOp, EvtRtxMemoryPoolNo, 0x09U) -#define EvtRtxMemoryPoolAllocFailed EventID(EventLevelOp, EvtRtxMemoryPoolNo, 0x0AU) -#define EvtRtxMemoryPoolFree EventID(EventLevelAPI, EvtRtxMemoryPoolNo, 0x0BU) -#define EvtRtxMemoryPoolDeallocated EventID(EventLevelOp, EvtRtxMemoryPoolNo, 0x0CU) -#define EvtRtxMemoryPoolFreeFailed EventID(EventLevelOp, EvtRtxMemoryPoolNo, 0x0DU) -#define EvtRtxMemoryPoolGetCapacity EventID(EventLevelAPI, EvtRtxMemoryPoolNo, 0x0EU) -#define EvtRtxMemoryPoolGetBlockSize EventID(EventLevelAPI, EvtRtxMemoryPoolNo, 0x0FU) -#define EvtRtxMemoryPoolGetCount EventID(EventLevelAPI, EvtRtxMemoryPoolNo, 0x10U) -#define EvtRtxMemoryPoolGetSpace EventID(EventLevelAPI, EvtRtxMemoryPoolNo, 0x11U) -#define EvtRtxMemoryPoolDelete EventID(EventLevelAPI, EvtRtxMemoryPoolNo, 0x12U) -#define EvtRtxMemoryPoolDestroyed EventID(EventLevelOp, EvtRtxMemoryPoolNo, 0x13U) +#define EvtRtxMemoryPoolError \ + EventID(EventLevelError, EvtRtxMemoryPoolNo, 0x00U) +#define EvtRtxMemoryPoolNew EventID(EventLevelAPI, EvtRtxMemoryPoolNo, 0x01U) +#define EvtRtxMemoryPoolCreated EventID(EventLevelOp, EvtRtxMemoryPoolNo, 0x03U) +#define EvtRtxMemoryPoolGetName \ + EventID(EventLevelAPI, EvtRtxMemoryPoolNo, 0x04U) +#define EvtRtxMemoryPoolAlloc EventID(EventLevelAPI, EvtRtxMemoryPoolNo, 0x06U) +#define EvtRtxMemoryPoolAllocPending \ + EventID(EventLevelOp, EvtRtxMemoryPoolNo, 0x07U) +#define EvtRtxMemoryPoolAllocTimeout \ + EventID(EventLevelOp, EvtRtxMemoryPoolNo, 0x08U) +#define EvtRtxMemoryPoolAllocated \ + EventID(EventLevelOp, EvtRtxMemoryPoolNo, 0x09U) +#define EvtRtxMemoryPoolAllocFailed \ + EventID(EventLevelOp, EvtRtxMemoryPoolNo, 0x0AU) +#define EvtRtxMemoryPoolFree EventID(EventLevelAPI, EvtRtxMemoryPoolNo, 0x0BU) +#define EvtRtxMemoryPoolDeallocated \ + EventID(EventLevelOp, EvtRtxMemoryPoolNo, 0x0CU) +#define EvtRtxMemoryPoolFreeFailed \ + EventID(EventLevelOp, EvtRtxMemoryPoolNo, 0x0DU) +#define EvtRtxMemoryPoolGetCapacity \ + EventID(EventLevelAPI, EvtRtxMemoryPoolNo, 0x0EU) +#define EvtRtxMemoryPoolGetBlockSize \ + EventID(EventLevelAPI, EvtRtxMemoryPoolNo, 0x0FU) +#define EvtRtxMemoryPoolGetCount \ + EventID(EventLevelAPI, EvtRtxMemoryPoolNo, 0x10U) +#define EvtRtxMemoryPoolGetSpace \ + EventID(EventLevelAPI, EvtRtxMemoryPoolNo, 0x11U) +#define EvtRtxMemoryPoolDelete EventID(EventLevelAPI, EvtRtxMemoryPoolNo, 0x12U) +#define EvtRtxMemoryPoolDestroyed \ + EventID(EventLevelOp, EvtRtxMemoryPoolNo, 0x13U) /// Event IDs for "RTX Message Queue" -#define EvtRtxMessageQueueError EventID(EventLevelError, EvtRtxMessageQueueNo, 0x00U) -#define EvtRtxMessageQueueNew EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x01U) -#define EvtRtxMessageQueueCreated EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x03U) -#define EvtRtxMessageQueueGetName EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x04U) -#define EvtRtxMessageQueuePut EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x06U) -#define EvtRtxMessageQueuePutPending EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x07U) -#define EvtRtxMessageQueuePutTimeout EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x08U) -#define EvtRtxMessageQueueInsertPending EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x09U) -#define EvtRtxMessageQueueInserted EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x0AU) -#define EvtRtxMessageQueueNotInserted EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x0BU) -#define EvtRtxMessageQueueGet EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x0CU) -#define EvtRtxMessageQueueGetPending EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x0DU) -#define EvtRtxMessageQueueGetTimeout EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x0EU) -#define EvtRtxMessageQueueRetrieved EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x0FU) -#define EvtRtxMessageQueueNotRetrieved EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x10U) -#define EvtRtxMessageQueueGetCapacity EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x11U) -#define EvtRtxMessageQueueGetMsgSize EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x12U) -#define EvtRtxMessageQueueGetCount EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x13U) -#define EvtRtxMessageQueueGetSpace EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x14U) -#define EvtRtxMessageQueueReset EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x15U) -#define EvtRtxMessageQueueResetDone EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x16U) -#define EvtRtxMessageQueueDelete EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x17U) -#define EvtRtxMessageQueueDestroyed EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x18U) +#define EvtRtxMessageQueueError \ + EventID(EventLevelError, EvtRtxMessageQueueNo, 0x00U) +#define EvtRtxMessageQueueNew \ + EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x01U) +#define EvtRtxMessageQueueCreated \ + EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x03U) +#define EvtRtxMessageQueueGetName \ + EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x04U) +#define EvtRtxMessageQueuePut \ + EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x06U) +#define EvtRtxMessageQueuePutPending \ + EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x07U) +#define EvtRtxMessageQueuePutTimeout \ + EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x08U) +#define EvtRtxMessageQueueInsertPending \ + EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x09U) +#define EvtRtxMessageQueueInserted \ + EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x0AU) +#define EvtRtxMessageQueueNotInserted \ + EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x0BU) +#define EvtRtxMessageQueueGet \ + EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x0CU) +#define EvtRtxMessageQueueGetPending \ + EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x0DU) +#define EvtRtxMessageQueueGetTimeout \ + EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x0EU) +#define EvtRtxMessageQueueRetrieved \ + EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x0FU) +#define EvtRtxMessageQueueNotRetrieved \ + EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x10U) +#define EvtRtxMessageQueueGetCapacity \ + EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x11U) +#define EvtRtxMessageQueueGetMsgSize \ + EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x12U) +#define EvtRtxMessageQueueGetCount \ + EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x13U) +#define EvtRtxMessageQueueGetSpace \ + EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x14U) +#define EvtRtxMessageQueueReset \ + EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x15U) +#define EvtRtxMessageQueueResetDone \ + EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x16U) +#define EvtRtxMessageQueueDelete \ + EventID(EventLevelAPI, EvtRtxMessageQueueNo, 0x17U) +#define EvtRtxMessageQueueDestroyed \ + EventID(EventLevelOp, EvtRtxMessageQueueNo, 0x18U) -#endif // RTE_Compiler_EventRecorder - -//lint -esym(522, EvrRtx*) "Functions 'EvrRtx*' can be overridden (do not lack side-effects)" +#endif // RTE_Compiler_EventRecorder +// lint -esym(522, EvrRtx*) "Functions 'EvrRtx*' can be overridden (do not lack +// side-effects)" // ==== Memory Events ==== -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMORY != 0) && !defined(EVR_RTX_MEMORY_INIT_DISABLE)) -__WEAK void EvrRtxMemoryInit (void *mem, uint32_t size, uint32_t result) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMORY != 0) && \ + !defined(EVR_RTX_MEMORY_INIT_DISABLE)) +__WEAK void EvrRtxMemoryInit(void *mem, uint32_t size, uint32_t result) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord4(EvtRtxMemoryInit, (uint32_t)mem, size, result, 0U); #else @@ -248,10 +307,13 @@ __WEAK void EvrRtxMemoryInit (void *mem, uint32_t size, uint32_t result) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMORY != 0) && !defined(EVR_RTX_MEMORY_ALLOC_DISABLE)) -__WEAK void EvrRtxMemoryAlloc (void *mem, uint32_t size, uint32_t type, void *block) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMORY != 0) && \ + !defined(EVR_RTX_MEMORY_ALLOC_DISABLE)) +__WEAK void EvrRtxMemoryAlloc(void *mem, uint32_t size, uint32_t type, + void *block) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxMemoryAlloc, (uint32_t)mem, size, type, (uint32_t)block); + (void)EventRecord4(EvtRtxMemoryAlloc, (uint32_t)mem, size, type, + (uint32_t)block); #else (void)mem; (void)size; @@ -261,10 +323,12 @@ __WEAK void EvrRtxMemoryAlloc (void *mem, uint32_t size, uint32_t type, void *bl } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMORY != 0) && !defined(EVR_RTX_MEMORY_FREE_DISABLE)) -__WEAK void EvrRtxMemoryFree (void *mem, void *block, uint32_t result) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMORY != 0) && \ + !defined(EVR_RTX_MEMORY_FREE_DISABLE)) +__WEAK void EvrRtxMemoryFree(void *mem, void *block, uint32_t result) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxMemoryFree, (uint32_t)mem, (uint32_t)block, result, 0U); + (void)EventRecord4(EvtRtxMemoryFree, (uint32_t)mem, (uint32_t)block, result, + 0U); #else (void)mem; (void)block; @@ -273,10 +337,13 @@ __WEAK void EvrRtxMemoryFree (void *mem, void *block, uint32_t result) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMORY != 0) && !defined(EVR_RTX_MEMORY_BLOCK_INIT_DISABLE)) -__WEAK void EvrRtxMemoryBlockInit (osRtxMpInfo_t *mp_info, uint32_t block_count, uint32_t block_size, void *block_mem) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMORY != 0) && \ + !defined(EVR_RTX_MEMORY_BLOCK_INIT_DISABLE)) +__WEAK void EvrRtxMemoryBlockInit(osRtxMpInfo_t *mp_info, uint32_t block_count, + uint32_t block_size, void *block_mem) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxMemoryBlockInit, (uint32_t)mp_info, block_count, block_size, (uint32_t)block_mem); + (void)EventRecord4(EvtRtxMemoryBlockInit, (uint32_t)mp_info, block_count, + block_size, (uint32_t)block_mem); #else (void)mp_info; (void)block_count; @@ -286,10 +353,12 @@ __WEAK void EvrRtxMemoryBlockInit (osRtxMpInfo_t *mp_info, uint32_t block_count, } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMORY != 0) && !defined(EVR_RTX_MEMORY_BLOCK_ALLOC_DISABLE)) -__WEAK void EvrRtxMemoryBlockAlloc (osRtxMpInfo_t *mp_info, void *block) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMORY != 0) && \ + !defined(EVR_RTX_MEMORY_BLOCK_ALLOC_DISABLE)) +__WEAK void EvrRtxMemoryBlockAlloc(osRtxMpInfo_t *mp_info, void *block) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxMemoryBlockAlloc, (uint32_t)mp_info, (uint32_t)block); + (void)EventRecord2(EvtRtxMemoryBlockAlloc, (uint32_t)mp_info, + (uint32_t)block); #else (void)mp_info; (void)block; @@ -297,10 +366,13 @@ __WEAK void EvrRtxMemoryBlockAlloc (osRtxMpInfo_t *mp_info, void *block) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMORY != 0) && !defined(EVR_RTX_MEMORY_BLOCK_FREE_DISABLE)) -__WEAK void EvrRtxMemoryBlockFree (osRtxMpInfo_t *mp_info, void *block, int32_t status) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMORY != 0) && \ + !defined(EVR_RTX_MEMORY_BLOCK_FREE_DISABLE)) +__WEAK void EvrRtxMemoryBlockFree(osRtxMpInfo_t *mp_info, void *block, + int32_t status) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxMemoryBlockFree, (uint32_t)mp_info, (uint32_t)block, (uint32_t)status, 0U); + (void)EventRecord4(EvtRtxMemoryBlockFree, (uint32_t)mp_info, (uint32_t)block, + (uint32_t)status, 0U); #else (void)mp_info; (void)block; @@ -309,21 +381,22 @@ __WEAK void EvrRtxMemoryBlockFree (osRtxMpInfo_t *mp_info, void *block, int32_t } #endif - // ==== Kernel Events ==== -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_ERROR_DISABLE)) -__WEAK void EvrRtxKernelError (int32_t status) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_ERROR_DISABLE)) +__WEAK void EvrRtxKernelError(int32_t status) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxKernelError, (uint32_t)status, 0U); + (void)EventRecord2(EvtRtxKernelError, (uint32_t)status, 0U); #else (void)status; #endif } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_INITIALIZE_DISABLE)) -__WEAK void EvrRtxKernelInitialize (void) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_INITIALIZE_DISABLE)) +__WEAK void EvrRtxKernelInitialize(void) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxKernelInitialize, 0U, 0U); #else @@ -331,8 +404,9 @@ __WEAK void EvrRtxKernelInitialize (void) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_INITIALIZED_DISABLE)) -__WEAK void EvrRtxKernelInitialized (void) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_INITIALIZED_DISABLE)) +__WEAK void EvrRtxKernelInitialized(void) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxKernelInitialized, 0U, 0U); #else @@ -340,10 +414,13 @@ __WEAK void EvrRtxKernelInitialized (void) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_GET_INFO_DISABLE)) -__WEAK void EvrRtxKernelGetInfo (osVersion_t *version, char *id_buf, uint32_t id_size) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_GET_INFO_DISABLE)) +__WEAK void EvrRtxKernelGetInfo(osVersion_t *version, char *id_buf, + uint32_t id_size) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxKernelGetInfo, (uint32_t)version, (uint32_t)id_buf, id_size, 0U); + (void)EventRecord4(EvtRtxKernelGetInfo, (uint32_t)version, (uint32_t)id_buf, + id_size, 0U); #else (void)version; (void)id_buf; @@ -352,11 +429,14 @@ __WEAK void EvrRtxKernelGetInfo (osVersion_t *version, char *id_buf, uint32_t id } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_INFO_RETRIEVED_DISABLE)) -__WEAK void EvrRtxKernelInfoRetrieved (const osVersion_t *version, const char *id_buf, uint32_t id_size) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_INFO_RETRIEVED_DISABLE)) +__WEAK void EvrRtxKernelInfoRetrieved(const osVersion_t *version, + const char *id_buf, uint32_t id_size) { #if defined(RTE_Compiler_EventRecorder) if (version != NULL) { - (void)EventRecord2(EvtRtxKernelInfoRetrieved, version->api, version->kernel); + (void)EventRecord2(EvtRtxKernelInfoRetrieved, version->api, + version->kernel); } if (id_buf != NULL) { (void)EventRecordData(EvtRtxKernelInfoRetrieved_Detail, id_buf, id_size); @@ -369,8 +449,9 @@ __WEAK void EvrRtxKernelInfoRetrieved (const osVersion_t *version, const char *i } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_GET_STATE_DISABLE)) -__WEAK void EvrRtxKernelGetState (osKernelState_t state) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_GET_STATE_DISABLE)) +__WEAK void EvrRtxKernelGetState(osKernelState_t state) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxKernelGetState, (uint32_t)state, 0U); #else @@ -379,8 +460,9 @@ __WEAK void EvrRtxKernelGetState (osKernelState_t state) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_START_DISABLE)) -__WEAK void EvrRtxKernelStart (void) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_START_DISABLE)) +__WEAK void EvrRtxKernelStart(void) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxKernelStart, 0U, 0U); #else @@ -388,8 +470,9 @@ __WEAK void EvrRtxKernelStart (void) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_STARTED_DISABLE)) -__WEAK void EvrRtxKernelStarted (void) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_STARTED_DISABLE)) +__WEAK void EvrRtxKernelStarted(void) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxKernelStarted, 0U, 0U); #else @@ -397,8 +480,9 @@ __WEAK void EvrRtxKernelStarted (void) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_LOCK_DISABLE)) -__WEAK void EvrRtxKernelLock (void) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_LOCK_DISABLE)) +__WEAK void EvrRtxKernelLock(void) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxKernelLock, 0U, 0U); #else @@ -406,8 +490,9 @@ __WEAK void EvrRtxKernelLock (void) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_LOCKED_DISABLE)) -__WEAK void EvrRtxKernelLocked (int32_t lock) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_LOCKED_DISABLE)) +__WEAK void EvrRtxKernelLocked(int32_t lock) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxKernelLocked, (uint32_t)lock, 0U); #else @@ -416,8 +501,9 @@ __WEAK void EvrRtxKernelLocked (int32_t lock) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_UNLOCK_DISABLE)) -__WEAK void EvrRtxKernelUnlock (void) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_UNLOCK_DISABLE)) +__WEAK void EvrRtxKernelUnlock(void) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxKernelUnlock, 0U, 0U); #else @@ -425,8 +511,9 @@ __WEAK void EvrRtxKernelUnlock (void) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_UNLOCKED_DISABLE)) -__WEAK void EvrRtxKernelUnlocked (int32_t lock) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_UNLOCKED_DISABLE)) +__WEAK void EvrRtxKernelUnlocked(int32_t lock) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxKernelUnlocked, (uint32_t)lock, 0U); #else @@ -435,8 +522,9 @@ __WEAK void EvrRtxKernelUnlocked (int32_t lock) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_RESTORE_LOCK_DISABLE)) -__WEAK void EvrRtxKernelRestoreLock (int32_t lock) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_RESTORE_LOCK_DISABLE)) +__WEAK void EvrRtxKernelRestoreLock(int32_t lock) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxKernelRestoreLock, (uint32_t)lock, 0U); #else @@ -445,8 +533,9 @@ __WEAK void EvrRtxKernelRestoreLock (int32_t lock) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_LOCK_RESTORED_DISABLE)) -__WEAK void EvrRtxKernelLockRestored (int32_t lock) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_LOCK_RESTORED_DISABLE)) +__WEAK void EvrRtxKernelLockRestored(int32_t lock) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxKernelLockRestored, (uint32_t)lock, 0U); #else @@ -455,8 +544,9 @@ __WEAK void EvrRtxKernelLockRestored (int32_t lock) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_SUSPEND_DISABLE)) -__WEAK void EvrRtxKernelSuspend (void) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_SUSPEND_DISABLE)) +__WEAK void EvrRtxKernelSuspend(void) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxKernelSuspend, 0U, 0U); #else @@ -464,8 +554,9 @@ __WEAK void EvrRtxKernelSuspend (void) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_SUSPENDED_DISABLE)) -__WEAK void EvrRtxKernelSuspended (uint32_t sleep_ticks) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_SUSPENDED_DISABLE)) +__WEAK void EvrRtxKernelSuspended(uint32_t sleep_ticks) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxKernelSuspended, sleep_ticks, 0U); #else @@ -474,8 +565,9 @@ __WEAK void EvrRtxKernelSuspended (uint32_t sleep_ticks) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_RESUME_DISABLE)) -__WEAK void EvrRtxKernelResume (uint32_t sleep_ticks) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_RESUME_DISABLE)) +__WEAK void EvrRtxKernelResume(uint32_t sleep_ticks) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxKernelResume, sleep_ticks, 0U); #else @@ -484,8 +576,9 @@ __WEAK void EvrRtxKernelResume (uint32_t sleep_ticks) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_RESUMED_DISABLE)) -__WEAK void EvrRtxKernelResumed (void) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_RESUMED_DISABLE)) +__WEAK void EvrRtxKernelResumed(void) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxKernelResumed, 0U, 0U); #else @@ -493,8 +586,9 @@ __WEAK void EvrRtxKernelResumed (void) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_GET_TICK_COUNT_DISABLE)) -__WEAK void EvrRtxKernelGetTickCount (uint32_t count) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_GET_TICK_COUNT_DISABLE)) +__WEAK void EvrRtxKernelGetTickCount(uint32_t count) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxKernelGetTickCount, count, 0U); #else @@ -503,8 +597,9 @@ __WEAK void EvrRtxKernelGetTickCount (uint32_t count) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_GET_TICK_FREQ_DISABLE)) -__WEAK void EvrRtxKernelGetTickFreq (uint32_t freq) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_GET_TICK_FREQ_DISABLE)) +__WEAK void EvrRtxKernelGetTickFreq(uint32_t freq) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxKernelGetTickFreq, freq, 0U); #else @@ -513,8 +608,9 @@ __WEAK void EvrRtxKernelGetTickFreq (uint32_t freq) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_GET_SYS_TIMER_COUNT_DISABLE)) -__WEAK void EvrRtxKernelGetSysTimerCount (uint32_t count) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_GET_SYS_TIMER_COUNT_DISABLE)) +__WEAK void EvrRtxKernelGetSysTimerCount(uint32_t count) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxKernelGetSysTimerCount, count, 0U); #else @@ -523,8 +619,9 @@ __WEAK void EvrRtxKernelGetSysTimerCount (uint32_t count) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_GET_SYS_TIMER_FREQ_DISABLE)) -__WEAK void EvrRtxKernelGetSysTimerFreq (uint32_t freq) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && \ + !defined(EVR_RTX_KERNEL_GET_SYS_TIMER_FREQ_DISABLE)) +__WEAK void EvrRtxKernelGetSysTimerFreq(uint32_t freq) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxKernelGetSysTimerFreq, freq, 0U); #else @@ -533,24 +630,28 @@ __WEAK void EvrRtxKernelGetSysTimerFreq (uint32_t freq) { } #endif - // ==== Thread Events ==== -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_ERROR_DISABLE)) -__WEAK void EvrRtxThreadError (osThreadId_t thread_id, int32_t status) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_ERROR_DISABLE)) +__WEAK void EvrRtxThreadError(osThreadId_t thread_id, int32_t status) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadError, (uint32_t)thread_id, (uint32_t)status); #else os_thread_t *thread = osRtxThreadId(thread_id); - TRACE(2,"EvrRtxThreadError, thread name:%s, status:%d", thread ? thread->name : "NULL", status); + TRACE(2, "EvrRtxThreadError, thread name:%s, status:%d", + thread ? thread->name : "NULL", status); #endif } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_NEW_DISABLE)) -__WEAK void EvrRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_NEW_DISABLE)) +__WEAK void EvrRtxThreadNew(osThreadFunc_t func, void *argument, + const osThreadAttr_t *attr) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxThreadNew, (uint32_t)func, (uint32_t)argument, (uint32_t)attr, 0U); + (void)EventRecord4(EvtRtxThreadNew, (uint32_t)func, (uint32_t)argument, + (uint32_t)attr, 0U); #else (void)func; (void)argument; @@ -559,13 +660,17 @@ __WEAK void EvrRtxThreadNew (osThreadFunc_t func, void *argument, const osThread } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_CREATED_DISABLE)) -__WEAK void EvrRtxThreadCreated (osThreadId_t thread_id, uint32_t thread_addr, const char *name) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_CREATED_DISABLE)) +__WEAK void EvrRtxThreadCreated(osThreadId_t thread_id, uint32_t thread_addr, + const char *name) { #if defined(RTE_Compiler_EventRecorder) if (name != NULL) { - (void)EventRecord2(EvtRtxThreadCreated_Name, (uint32_t)thread_id, (uint32_t)name); + (void)EventRecord2(EvtRtxThreadCreated_Name, (uint32_t)thread_id, + (uint32_t)name); } else { - (void)EventRecord2(EvtRtxThreadCreated_Addr, (uint32_t)thread_id, thread_addr); + (void)EventRecord2(EvtRtxThreadCreated_Addr, (uint32_t)thread_id, + thread_addr); } #else (void)thread_id; @@ -575,8 +680,9 @@ __WEAK void EvrRtxThreadCreated (osThreadId_t thread_id, uint32_t thread_addr, c } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_GET_NAME_DISABLE)) -__WEAK void EvrRtxThreadGetName (osThreadId_t thread_id, const char *name) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_GET_NAME_DISABLE)) +__WEAK void EvrRtxThreadGetName(osThreadId_t thread_id, const char *name) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadGetName, (uint32_t)thread_id, (uint32_t)name); #else @@ -586,8 +692,9 @@ __WEAK void EvrRtxThreadGetName (osThreadId_t thread_id, const char *name) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_GET_ID_DISABLE)) -__WEAK void EvrRtxThreadGetId (osThreadId_t thread_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_GET_ID_DISABLE)) +__WEAK void EvrRtxThreadGetId(osThreadId_t thread_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadGetId, (uint32_t)thread_id, 0U); #else @@ -596,10 +703,13 @@ __WEAK void EvrRtxThreadGetId (osThreadId_t thread_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_GET_STATE_DISABLE)) -__WEAK void EvrRtxThreadGetState (osThreadId_t thread_id, osThreadState_t state) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_GET_STATE_DISABLE)) +__WEAK void EvrRtxThreadGetState(osThreadId_t thread_id, + osThreadState_t state) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxThreadGetState, (uint32_t)thread_id, (uint32_t)state); + (void)EventRecord2(EvtRtxThreadGetState, (uint32_t)thread_id, + (uint32_t)state); #else (void)thread_id; (void)state; @@ -607,8 +717,10 @@ __WEAK void EvrRtxThreadGetState (osThreadId_t thread_id, osThreadState_t state) } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_GET_STACK_SIZE_DISABLE)) -__WEAK void EvrRtxThreadGetStackSize (osThreadId_t thread_id, uint32_t stack_size) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_GET_STACK_SIZE_DISABLE)) +__WEAK void EvrRtxThreadGetStackSize(osThreadId_t thread_id, + uint32_t stack_size) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadGetStackSize, (uint32_t)thread_id, stack_size); #else @@ -618,10 +730,13 @@ __WEAK void EvrRtxThreadGetStackSize (osThreadId_t thread_id, uint32_t stack_siz } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_GET_STACK_SPACE_DISABLE)) -__WEAK void EvrRtxThreadGetStackSpace (osThreadId_t thread_id, uint32_t stack_space) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_GET_STACK_SPACE_DISABLE)) +__WEAK void EvrRtxThreadGetStackSpace(osThreadId_t thread_id, + uint32_t stack_space) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxThreadGetStackSpace, (uint32_t)thread_id, stack_space); + (void)EventRecord2(EvtRtxThreadGetStackSpace, (uint32_t)thread_id, + stack_space); #else (void)thread_id; (void)stack_space; @@ -629,10 +744,13 @@ __WEAK void EvrRtxThreadGetStackSpace (osThreadId_t thread_id, uint32_t stack_sp } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_SET_PRIORITY_DISABLE)) -__WEAK void EvrRtxThreadSetPriority (osThreadId_t thread_id, osPriority_t priority) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_SET_PRIORITY_DISABLE)) +__WEAK void EvrRtxThreadSetPriority(osThreadId_t thread_id, + osPriority_t priority) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxThreadSetPriority, (uint32_t)thread_id, (uint32_t)priority); + (void)EventRecord2(EvtRtxThreadSetPriority, (uint32_t)thread_id, + (uint32_t)priority); #else (void)thread_id; (void)priority; @@ -640,10 +758,13 @@ __WEAK void EvrRtxThreadSetPriority (osThreadId_t thread_id, osPriority_t priori } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_PRIORITY_UPDATED_DISABLE)) -__WEAK void EvrRtxThreadPriorityUpdated (osThreadId_t thread_id, osPriority_t priority) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_PRIORITY_UPDATED_DISABLE)) +__WEAK void EvrRtxThreadPriorityUpdated(osThreadId_t thread_id, + osPriority_t priority) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxThreadPriorityUpdated, (uint32_t)thread_id, (uint32_t)priority); + (void)EventRecord2(EvtRtxThreadPriorityUpdated, (uint32_t)thread_id, + (uint32_t)priority); #else (void)thread_id; (void)priority; @@ -651,10 +772,13 @@ __WEAK void EvrRtxThreadPriorityUpdated (osThreadId_t thread_id, osPriority_t pr } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_GET_PRIORITY_DISABLE)) -__WEAK void EvrRtxThreadGetPriority (osThreadId_t thread_id, osPriority_t priority) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_GET_PRIORITY_DISABLE)) +__WEAK void EvrRtxThreadGetPriority(osThreadId_t thread_id, + osPriority_t priority) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxThreadGetPriority, (uint32_t)thread_id, (uint32_t)priority); + (void)EventRecord2(EvtRtxThreadGetPriority, (uint32_t)thread_id, + (uint32_t)priority); #else (void)thread_id; (void)priority; @@ -662,8 +786,9 @@ __WEAK void EvrRtxThreadGetPriority (osThreadId_t thread_id, osPriority_t priori } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_YIELD_DISABLE)) -__WEAK void EvrRtxThreadYield (void) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_YIELD_DISABLE)) +__WEAK void EvrRtxThreadYield(void) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadYield, 0U, 0U); #else @@ -671,8 +796,9 @@ __WEAK void EvrRtxThreadYield (void) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_SUSPEND_DISABLE)) -__WEAK void EvrRtxThreadSuspend (osThreadId_t thread_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_SUSPEND_DISABLE)) +__WEAK void EvrRtxThreadSuspend(osThreadId_t thread_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadSuspend, (uint32_t)thread_id, 0U); #else @@ -681,8 +807,9 @@ __WEAK void EvrRtxThreadSuspend (osThreadId_t thread_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_SUSPENDED_DISABLE)) -__WEAK void EvrRtxThreadSuspended (osThreadId_t thread_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_SUSPENDED_DISABLE)) +__WEAK void EvrRtxThreadSuspended(osThreadId_t thread_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadSuspended, (uint32_t)thread_id, 0U); #else @@ -691,8 +818,9 @@ __WEAK void EvrRtxThreadSuspended (osThreadId_t thread_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_RESUME_DISABLE)) -__WEAK void EvrRtxThreadResume (osThreadId_t thread_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_RESUME_DISABLE)) +__WEAK void EvrRtxThreadResume(osThreadId_t thread_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadResume, (uint32_t)thread_id, 0U); #else @@ -701,8 +829,9 @@ __WEAK void EvrRtxThreadResume (osThreadId_t thread_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_RESUMED_DISABLE)) -__WEAK void EvrRtxThreadResumed (osThreadId_t thread_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_RESUMED_DISABLE)) +__WEAK void EvrRtxThreadResumed(osThreadId_t thread_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadResumed, (uint32_t)thread_id, 0U); #else @@ -711,8 +840,9 @@ __WEAK void EvrRtxThreadResumed (osThreadId_t thread_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_DETACH_DISABLE)) -__WEAK void EvrRtxThreadDetach (osThreadId_t thread_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_DETACH_DISABLE)) +__WEAK void EvrRtxThreadDetach(osThreadId_t thread_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadDetach, (uint32_t)thread_id, 0U); #else @@ -721,8 +851,9 @@ __WEAK void EvrRtxThreadDetach (osThreadId_t thread_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_DETACHED_DISABLE)) -__WEAK void EvrRtxThreadDetached (osThreadId_t thread_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_DETACHED_DISABLE)) +__WEAK void EvrRtxThreadDetached(osThreadId_t thread_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadDetached, (uint32_t)thread_id, 0U); #else @@ -731,8 +862,9 @@ __WEAK void EvrRtxThreadDetached (osThreadId_t thread_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_JOIN_DISABLE)) -__WEAK void EvrRtxThreadJoin (osThreadId_t thread_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_JOIN_DISABLE)) +__WEAK void EvrRtxThreadJoin(osThreadId_t thread_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadJoin, (uint32_t)thread_id, 0U); #else @@ -741,8 +873,9 @@ __WEAK void EvrRtxThreadJoin (osThreadId_t thread_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_JOIN_PENDING_DISABLE)) -__WEAK void EvrRtxThreadJoinPending (osThreadId_t thread_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_JOIN_PENDING_DISABLE)) +__WEAK void EvrRtxThreadJoinPending(osThreadId_t thread_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadJoinPending, (uint32_t)thread_id, 0U); #else @@ -751,8 +884,9 @@ __WEAK void EvrRtxThreadJoinPending (osThreadId_t thread_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_JOINED_DISABLE)) -__WEAK void EvrRtxThreadJoined (osThreadId_t thread_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_JOINED_DISABLE)) +__WEAK void EvrRtxThreadJoined(osThreadId_t thread_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadJoined, (uint32_t)thread_id, 0U); #else @@ -761,8 +895,9 @@ __WEAK void EvrRtxThreadJoined (osThreadId_t thread_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_BLOCKED_DISABLE)) -__WEAK void EvrRtxThreadBlocked (osThreadId_t thread_id, uint32_t timeout) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_BLOCKED_DISABLE)) +__WEAK void EvrRtxThreadBlocked(osThreadId_t thread_id, uint32_t timeout) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadBlocked, (uint32_t)thread_id, timeout); #else @@ -772,8 +907,9 @@ __WEAK void EvrRtxThreadBlocked (osThreadId_t thread_id, uint32_t timeout) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_UNBLOCKED_DISABLE)) -__WEAK void EvrRtxThreadUnblocked (osThreadId_t thread_id, uint32_t ret_val) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_UNBLOCKED_DISABLE)) +__WEAK void EvrRtxThreadUnblocked(osThreadId_t thread_id, uint32_t ret_val) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadUnblocked, (uint32_t)thread_id, ret_val); #else @@ -783,8 +919,9 @@ __WEAK void EvrRtxThreadUnblocked (osThreadId_t thread_id, uint32_t ret_val) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_PREEMPTED_DISABLE)) -__WEAK void EvrRtxThreadPreempted (osThreadId_t thread_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_PREEMPTED_DISABLE)) +__WEAK void EvrRtxThreadPreempted(osThreadId_t thread_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadPreempted, (uint32_t)thread_id, 0U); #else @@ -793,8 +930,9 @@ __WEAK void EvrRtxThreadPreempted (osThreadId_t thread_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_SWITCHED_DISABLE)) -__WEAK void EvrRtxThreadSwitched (osThreadId_t thread_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_SWITCHED_DISABLE)) +__WEAK void EvrRtxThreadSwitched(osThreadId_t thread_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadSwitched, (uint32_t)thread_id, 0U); #else @@ -803,8 +941,9 @@ __WEAK void EvrRtxThreadSwitched (osThreadId_t thread_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_EXIT_DISABLE)) -__WEAK void EvrRtxThreadExit (void) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_EXIT_DISABLE)) +__WEAK void EvrRtxThreadExit(void) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadExit, 0U, 0U); #else @@ -812,8 +951,9 @@ __WEAK void EvrRtxThreadExit (void) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_TERMINATE_DISABLE)) -__WEAK void EvrRtxThreadTerminate (osThreadId_t thread_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_TERMINATE_DISABLE)) +__WEAK void EvrRtxThreadTerminate(osThreadId_t thread_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadTerminate, (uint32_t)thread_id, 0U); #else @@ -822,8 +962,9 @@ __WEAK void EvrRtxThreadTerminate (osThreadId_t thread_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_DESTROYED_DISABLE)) -__WEAK void EvrRtxThreadDestroyed (osThreadId_t thread_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_DESTROYED_DISABLE)) +__WEAK void EvrRtxThreadDestroyed(osThreadId_t thread_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadDestroyed, (uint32_t)thread_id, 0U); #else @@ -832,8 +973,9 @@ __WEAK void EvrRtxThreadDestroyed (osThreadId_t thread_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_GET_COUNT_DISABLE)) -__WEAK void EvrRtxThreadGetCount (uint32_t count) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_GET_COUNT_DISABLE)) +__WEAK void EvrRtxThreadGetCount(uint32_t count) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadGetCount, count, 0U); #else @@ -842,10 +984,13 @@ __WEAK void EvrRtxThreadGetCount (uint32_t count) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_ENUMERATE_DISABLE)) -__WEAK void EvrRtxThreadEnumerate (osThreadId_t *thread_array, uint32_t array_items, uint32_t count) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && \ + !defined(EVR_RTX_THREAD_ENUMERATE_DISABLE)) +__WEAK void EvrRtxThreadEnumerate(osThreadId_t *thread_array, + uint32_t array_items, uint32_t count) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxThreadEnumerate, (uint32_t)thread_array, array_items, count, 0U); + (void)EventRecord4(EvtRtxThreadEnumerate, (uint32_t)thread_array, array_items, + count, 0U); #else (void)thread_array; (void)array_items; @@ -854,13 +999,14 @@ __WEAK void EvrRtxThreadEnumerate (osThreadId_t *thread_array, uint32_t array_it } #endif - // ==== Thread Flags Events ==== -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && !defined(EVR_RTX_THREAD_FLAGS_ERROR_DISABLE)) -__WEAK void EvrRtxThreadFlagsError (osThreadId_t thread_id, int32_t status) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && \ + !defined(EVR_RTX_THREAD_FLAGS_ERROR_DISABLE)) +__WEAK void EvrRtxThreadFlagsError(osThreadId_t thread_id, int32_t status) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxThreadFlagsError, (uint32_t)thread_id, (uint32_t)status); + (void)EventRecord2(EvtRtxThreadFlagsError, (uint32_t)thread_id, + (uint32_t)status); #else (void)thread_id; (void)status; @@ -868,8 +1014,9 @@ __WEAK void EvrRtxThreadFlagsError (osThreadId_t thread_id, int32_t status) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && !defined(EVR_RTX_THREAD_FLAGS_SET_DISABLE)) -__WEAK void EvrRtxThreadFlagsSet (osThreadId_t thread_id, uint32_t flags) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && \ + !defined(EVR_RTX_THREAD_FLAGS_SET_DISABLE)) +__WEAK void EvrRtxThreadFlagsSet(osThreadId_t thread_id, uint32_t flags) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadFlagsSet, (uint32_t)thread_id, flags); #else @@ -879,10 +1026,13 @@ __WEAK void EvrRtxThreadFlagsSet (osThreadId_t thread_id, uint32_t flags) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && !defined(EVR_RTX_THREAD_FLAGS_SET_DONE_DISABLE)) -__WEAK void EvrRtxThreadFlagsSetDone (osThreadId_t thread_id, uint32_t thread_flags) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && \ + !defined(EVR_RTX_THREAD_FLAGS_SET_DONE_DISABLE)) +__WEAK void EvrRtxThreadFlagsSetDone(osThreadId_t thread_id, + uint32_t thread_flags) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxThreadFlagsSetDone, (uint32_t)thread_id, thread_flags); + (void)EventRecord2(EvtRtxThreadFlagsSetDone, (uint32_t)thread_id, + thread_flags); #else (void)thread_id; (void)thread_flags; @@ -890,8 +1040,9 @@ __WEAK void EvrRtxThreadFlagsSetDone (osThreadId_t thread_id, uint32_t thread_fl } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && !defined(EVR_RTX_THREAD_FLAGS_CLEAR_DISABLE)) -__WEAK void EvrRtxThreadFlagsClear (uint32_t flags) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && \ + !defined(EVR_RTX_THREAD_FLAGS_CLEAR_DISABLE)) +__WEAK void EvrRtxThreadFlagsClear(uint32_t flags) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadFlagsClear, flags, 0U); #else @@ -900,8 +1051,9 @@ __WEAK void EvrRtxThreadFlagsClear (uint32_t flags) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && !defined(EVR_RTX_THREAD_FLAGS_CLEAR_DONE_DISABLE)) -__WEAK void EvrRtxThreadFlagsClearDone (uint32_t thread_flags) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && \ + !defined(EVR_RTX_THREAD_FLAGS_CLEAR_DONE_DISABLE)) +__WEAK void EvrRtxThreadFlagsClearDone(uint32_t thread_flags) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadFlagsClearDone, thread_flags, 0U); #else @@ -910,8 +1062,9 @@ __WEAK void EvrRtxThreadFlagsClearDone (uint32_t thread_flags) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && !defined(EVR_RTX_THREAD_FLAGS_GET_DISABLE)) -__WEAK void EvrRtxThreadFlagsGet (uint32_t thread_flags) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && \ + !defined(EVR_RTX_THREAD_FLAGS_GET_DISABLE)) +__WEAK void EvrRtxThreadFlagsGet(uint32_t thread_flags) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadFlagsGet, thread_flags, 0U); #else @@ -920,8 +1073,10 @@ __WEAK void EvrRtxThreadFlagsGet (uint32_t thread_flags) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && !defined(EVR_RTX_THREAD_FLAGS_WAIT_DISABLE)) -__WEAK void EvrRtxThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && \ + !defined(EVR_RTX_THREAD_FLAGS_WAIT_DISABLE)) +__WEAK void EvrRtxThreadFlagsWait(uint32_t flags, uint32_t options, + uint32_t timeout) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord4(EvtRtxThreadFlagsWait, flags, options, timeout, 0U); #else @@ -932,8 +1087,10 @@ __WEAK void EvrRtxThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t ti } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && !defined(EVR_RTX_THREAD_FLAGS_WAIT_PENDING_DISABLE)) -__WEAK void EvrRtxThreadFlagsWaitPending (uint32_t flags, uint32_t options, uint32_t timeout) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && \ + !defined(EVR_RTX_THREAD_FLAGS_WAIT_PENDING_DISABLE)) +__WEAK void EvrRtxThreadFlagsWaitPending(uint32_t flags, uint32_t options, + uint32_t timeout) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord4(EvtRtxThreadFlagsWaitPending, flags, options, timeout, 0U); #else @@ -944,8 +1101,9 @@ __WEAK void EvrRtxThreadFlagsWaitPending (uint32_t flags, uint32_t options, uint } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && !defined(EVR_RTX_THREAD_FLAGS_WAIT_TIMEOUT_DISABLE)) -__WEAK void EvrRtxThreadFlagsWaitTimeout (osThreadId_t thread_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && \ + !defined(EVR_RTX_THREAD_FLAGS_WAIT_TIMEOUT_DISABLE)) +__WEAK void EvrRtxThreadFlagsWaitTimeout(osThreadId_t thread_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadFlagsWaitTimeout, (uint32_t)thread_id, 0U); #else @@ -954,10 +1112,14 @@ __WEAK void EvrRtxThreadFlagsWaitTimeout (osThreadId_t thread_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && !defined(EVR_RTX_THREAD_FLAGS_WAIT_COMPLETED_DISABLE)) -__WEAK void EvrRtxThreadFlagsWaitCompleted (uint32_t flags, uint32_t options, uint32_t thread_flags, osThreadId_t thread_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && \ + !defined(EVR_RTX_THREAD_FLAGS_WAIT_COMPLETED_DISABLE)) +__WEAK void EvrRtxThreadFlagsWaitCompleted(uint32_t flags, uint32_t options, + uint32_t thread_flags, + osThreadId_t thread_id) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxThreadFlagsWaitCompleted, flags, options, thread_flags, (uint32_t)thread_id); + (void)EventRecord4(EvtRtxThreadFlagsWaitCompleted, flags, options, + thread_flags, (uint32_t)thread_id); #else (void)flags; (void)options; @@ -967,8 +1129,10 @@ __WEAK void EvrRtxThreadFlagsWaitCompleted (uint32_t flags, uint32_t options, ui } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && !defined(EVR_RTX_THREAD_FLAGS_WAIT_NOT_COMPLETED_DISABLE)) -__WEAK void EvrRtxThreadFlagsWaitNotCompleted (uint32_t flags, uint32_t options) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THFLAGS != 0) && \ + !defined(EVR_RTX_THREAD_FLAGS_WAIT_NOT_COMPLETED_DISABLE)) +__WEAK void EvrRtxThreadFlagsWaitNotCompleted(uint32_t flags, + uint32_t options) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxThreadFlagsWaitNotCompleted, flags, options); #else @@ -978,11 +1142,11 @@ __WEAK void EvrRtxThreadFlagsWaitNotCompleted (uint32_t flags, uint32_t options) } #endif - // ==== Generic Wait Events ==== -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_WAIT != 0) && !defined(EVR_RTX_DELAY_ERROR_DISABLE)) -__WEAK void EvrRtxDelayError (int32_t status) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_WAIT != 0) && \ + !defined(EVR_RTX_DELAY_ERROR_DISABLE)) +__WEAK void EvrRtxDelayError(int32_t status) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxDelayError, (uint32_t)status, 0U); #else @@ -991,9 +1155,9 @@ __WEAK void EvrRtxDelayError (int32_t status) { } #endif - -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_WAIT != 0) && !defined(EVR_RTX_DELAY_DISABLE)) -__WEAK void EvrRtxDelay (uint32_t ticks) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_WAIT != 0) && \ + !defined(EVR_RTX_DELAY_DISABLE)) +__WEAK void EvrRtxDelay(uint32_t ticks) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxDelay, ticks, 0U); #else @@ -1002,8 +1166,9 @@ __WEAK void EvrRtxDelay (uint32_t ticks) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_WAIT != 0) && !defined(EVR_RTX_DELAY_UNTIL_DISABLE)) -__WEAK void EvrRtxDelayUntil (uint32_t ticks) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_WAIT != 0) && \ + !defined(EVR_RTX_DELAY_UNTIL_DISABLE)) +__WEAK void EvrRtxDelayUntil(uint32_t ticks) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxDelayUntil, ticks, 0U); #else @@ -1012,8 +1177,9 @@ __WEAK void EvrRtxDelayUntil (uint32_t ticks) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_WAIT != 0) && !defined(EVR_RTX_DELAY_STARTED_DISABLE)) -__WEAK void EvrRtxDelayStarted (uint32_t ticks) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_WAIT != 0) && \ + !defined(EVR_RTX_DELAY_STARTED_DISABLE)) +__WEAK void EvrRtxDelayStarted(uint32_t ticks) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxDelayStarted, ticks, 0U); #else @@ -1022,8 +1188,9 @@ __WEAK void EvrRtxDelayStarted (uint32_t ticks) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_WAIT != 0) && !defined(EVR_RTX_DELAY_UNTIL_STARTED_DISABLE)) -__WEAK void EvrRtxDelayUntilStarted (uint32_t ticks) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_WAIT != 0) && \ + !defined(EVR_RTX_DELAY_UNTIL_STARTED_DISABLE)) +__WEAK void EvrRtxDelayUntilStarted(uint32_t ticks) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxDelayUntilStarted, ticks, 0U); #else @@ -1032,8 +1199,9 @@ __WEAK void EvrRtxDelayUntilStarted (uint32_t ticks) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_WAIT != 0) && !defined(EVR_RTX_DELAY_COMPLETED_DISABLE)) -__WEAK void EvrRtxDelayCompleted (osThreadId_t thread_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_WAIT != 0) && \ + !defined(EVR_RTX_DELAY_COMPLETED_DISABLE)) +__WEAK void EvrRtxDelayCompleted(osThreadId_t thread_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxDelayCompleted, (uint32_t)thread_id, 0U); #else @@ -1042,11 +1210,11 @@ __WEAK void EvrRtxDelayCompleted (osThreadId_t thread_id) { } #endif - // ==== Timer Events ==== -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && !defined(EVR_RTX_TIMER_ERROR_DISABLE)) -__WEAK void EvrRtxTimerError (osTimerId_t timer_id, int32_t status) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && \ + !defined(EVR_RTX_TIMER_ERROR_DISABLE)) +__WEAK void EvrRtxTimerError(osTimerId_t timer_id, int32_t status) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxTimerError, (uint32_t)timer_id, (uint32_t)status); #else @@ -1056,8 +1224,9 @@ __WEAK void EvrRtxTimerError (osTimerId_t timer_id, int32_t status) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && !defined(EVR_RTX_TIMER_CALLBACK_DISABLE)) -__WEAK void EvrRtxTimerCallback (osTimerFunc_t func, void *argument) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && \ + !defined(EVR_RTX_TIMER_CALLBACK_DISABLE)) +__WEAK void EvrRtxTimerCallback(osTimerFunc_t func, void *argument) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxTimerCallback, (uint32_t)func, (uint32_t)argument); #else @@ -1067,10 +1236,13 @@ __WEAK void EvrRtxTimerCallback (osTimerFunc_t func, void *argument) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && !defined(EVR_RTX_TIMER_NEW_DISABLE)) -__WEAK void EvrRtxTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && \ + !defined(EVR_RTX_TIMER_NEW_DISABLE)) +__WEAK void EvrRtxTimerNew(osTimerFunc_t func, osTimerType_t type, + void *argument, const osTimerAttr_t *attr) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxTimerNew, (uint32_t)func, (uint32_t)type, (uint32_t)argument, (uint32_t)attr); + (void)EventRecord4(EvtRtxTimerNew, (uint32_t)func, (uint32_t)type, + (uint32_t)argument, (uint32_t)attr); #else (void)func; (void)type; @@ -1080,8 +1252,9 @@ __WEAK void EvrRtxTimerNew (osTimerFunc_t func, osTimerType_t type, void *argume } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && !defined(EVR_RTX_TIMER_CREATED_DISABLE)) -__WEAK void EvrRtxTimerCreated (osTimerId_t timer_id, const char *name) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && \ + !defined(EVR_RTX_TIMER_CREATED_DISABLE)) +__WEAK void EvrRtxTimerCreated(osTimerId_t timer_id, const char *name) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxTimerCreated, (uint32_t)timer_id, (uint32_t)name); #else @@ -1091,8 +1264,9 @@ __WEAK void EvrRtxTimerCreated (osTimerId_t timer_id, const char *name) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && !defined(EVR_RTX_TIMER_GET_NAME_DISABLE)) -__WEAK void EvrRtxTimerGetName (osTimerId_t timer_id, const char *name) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && \ + !defined(EVR_RTX_TIMER_GET_NAME_DISABLE)) +__WEAK void EvrRtxTimerGetName(osTimerId_t timer_id, const char *name) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxTimerGetName, (uint32_t)timer_id, (uint32_t)name); #else @@ -1102,8 +1276,9 @@ __WEAK void EvrRtxTimerGetName (osTimerId_t timer_id, const char *name) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && !defined(EVR_RTX_TIMER_START_DISABLE)) -__WEAK void EvrRtxTimerStart (osTimerId_t timer_id, uint32_t ticks) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && \ + !defined(EVR_RTX_TIMER_START_DISABLE)) +__WEAK void EvrRtxTimerStart(osTimerId_t timer_id, uint32_t ticks) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxTimerStart, (uint32_t)timer_id, ticks); #else @@ -1113,8 +1288,9 @@ __WEAK void EvrRtxTimerStart (osTimerId_t timer_id, uint32_t ticks) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && !defined(EVR_RTX_TIMER_STARTED_DISABLE)) -__WEAK void EvrRtxTimerStarted (osTimerId_t timer_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && \ + !defined(EVR_RTX_TIMER_STARTED_DISABLE)) +__WEAK void EvrRtxTimerStarted(osTimerId_t timer_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxTimerStarted, (uint32_t)timer_id, 0U); #else @@ -1123,8 +1299,9 @@ __WEAK void EvrRtxTimerStarted (osTimerId_t timer_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && !defined(EVR_RTX_TIMER_STOP_DISABLE)) -__WEAK void EvrRtxTimerStop (osTimerId_t timer_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && \ + !defined(EVR_RTX_TIMER_STOP_DISABLE)) +__WEAK void EvrRtxTimerStop(osTimerId_t timer_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxTimerStop, (uint32_t)timer_id, 0U); #else @@ -1133,8 +1310,9 @@ __WEAK void EvrRtxTimerStop (osTimerId_t timer_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && !defined(EVR_RTX_TIMER_STOPPED_DISABLE)) -__WEAK void EvrRtxTimerStopped (osTimerId_t timer_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && \ + !defined(EVR_RTX_TIMER_STOPPED_DISABLE)) +__WEAK void EvrRtxTimerStopped(osTimerId_t timer_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxTimerStopped, (uint32_t)timer_id, 0U); #else @@ -1143,8 +1321,9 @@ __WEAK void EvrRtxTimerStopped (osTimerId_t timer_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && !defined(EVR_RTX_TIMER_IS_RUNNING_DISABLE)) -__WEAK void EvrRtxTimerIsRunning (osTimerId_t timer_id, uint32_t running) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && \ + !defined(EVR_RTX_TIMER_IS_RUNNING_DISABLE)) +__WEAK void EvrRtxTimerIsRunning(osTimerId_t timer_id, uint32_t running) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxTimerIsRunning, (uint32_t)timer_id, running); #else @@ -1154,8 +1333,9 @@ __WEAK void EvrRtxTimerIsRunning (osTimerId_t timer_id, uint32_t running) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && !defined(EVR_RTX_TIMER_DELETE_DISABLE)) -__WEAK void EvrRtxTimerDelete (osTimerId_t timer_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && \ + !defined(EVR_RTX_TIMER_DELETE_DISABLE)) +__WEAK void EvrRtxTimerDelete(osTimerId_t timer_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxTimerDelete, (uint32_t)timer_id, 0U); #else @@ -1164,8 +1344,9 @@ __WEAK void EvrRtxTimerDelete (osTimerId_t timer_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && !defined(EVR_RTX_TIMER_DESTROYED_DISABLE)) -__WEAK void EvrRtxTimerDestroyed (osTimerId_t timer_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_TIMER != 0) && \ + !defined(EVR_RTX_TIMER_DESTROYED_DISABLE)) +__WEAK void EvrRtxTimerDestroyed(osTimerId_t timer_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxTimerDestroyed, (uint32_t)timer_id, 0U); #else @@ -1174,11 +1355,11 @@ __WEAK void EvrRtxTimerDestroyed (osTimerId_t timer_id) { } #endif - // ==== Event Flags Events ==== -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && !defined(EVR_RTX_EVENT_FLAGS_ERROR_DISABLE)) -__WEAK void EvrRtxEventFlagsError (osEventFlagsId_t ef_id, int32_t status) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && \ + !defined(EVR_RTX_EVENT_FLAGS_ERROR_DISABLE)) +__WEAK void EvrRtxEventFlagsError(osEventFlagsId_t ef_id, int32_t status) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxEventFlagsError, (uint32_t)ef_id, (uint32_t)status); #else @@ -1188,8 +1369,9 @@ __WEAK void EvrRtxEventFlagsError (osEventFlagsId_t ef_id, int32_t status) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && !defined(EVR_RTX_EVENT_FLAGS_NEW_DISABLE)) -__WEAK void EvrRtxEventFlagsNew (const osEventFlagsAttr_t *attr) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && \ + !defined(EVR_RTX_EVENT_FLAGS_NEW_DISABLE)) +__WEAK void EvrRtxEventFlagsNew(const osEventFlagsAttr_t *attr) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxEventFlagsNew, (uint32_t)attr, 0U); #else @@ -1198,8 +1380,9 @@ __WEAK void EvrRtxEventFlagsNew (const osEventFlagsAttr_t *attr) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && !defined(EVR_RTX_EVENT_FLAGS_CREATED_DISABLE)) -__WEAK void EvrRtxEventFlagsCreated (osEventFlagsId_t ef_id, const char *name) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && \ + !defined(EVR_RTX_EVENT_FLAGS_CREATED_DISABLE)) +__WEAK void EvrRtxEventFlagsCreated(osEventFlagsId_t ef_id, const char *name) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxEventFlagsCreated, (uint32_t)ef_id, (uint32_t)name); #else @@ -1209,8 +1392,9 @@ __WEAK void EvrRtxEventFlagsCreated (osEventFlagsId_t ef_id, const char *name) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && !defined(EVR_RTX_EVENT_FLAGS_GET_NAME_DISABLE)) -__WEAK void EvrRtxEventFlagsGetName (osEventFlagsId_t ef_id, const char *name) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && \ + !defined(EVR_RTX_EVENT_FLAGS_GET_NAME_DISABLE)) +__WEAK void EvrRtxEventFlagsGetName(osEventFlagsId_t ef_id, const char *name) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxEventFlagsGetName, (uint32_t)ef_id, (uint32_t)name); #else @@ -1220,8 +1404,9 @@ __WEAK void EvrRtxEventFlagsGetName (osEventFlagsId_t ef_id, const char *name) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && !defined(EVR_RTX_EVENT_FLAGS_SET_DISABLE)) -__WEAK void EvrRtxEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && \ + !defined(EVR_RTX_EVENT_FLAGS_SET_DISABLE)) +__WEAK void EvrRtxEventFlagsSet(osEventFlagsId_t ef_id, uint32_t flags) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxEventFlagsSet, (uint32_t)ef_id, flags); #else @@ -1231,8 +1416,10 @@ __WEAK void EvrRtxEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && !defined(EVR_RTX_EVENT_FLAGS_SET_DONE_DISABLE)) -__WEAK void EvrRtxEventFlagsSetDone (osEventFlagsId_t ef_id, uint32_t event_flags) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && \ + !defined(EVR_RTX_EVENT_FLAGS_SET_DONE_DISABLE)) +__WEAK void EvrRtxEventFlagsSetDone(osEventFlagsId_t ef_id, + uint32_t event_flags) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxEventFlagsSetDone, (uint32_t)ef_id, event_flags); #else @@ -1242,8 +1429,9 @@ __WEAK void EvrRtxEventFlagsSetDone (osEventFlagsId_t ef_id, uint32_t event_flag } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && !defined(EVR_RTX_EVENT_FLAGS_CLEAR_DISABLE)) -__WEAK void EvrRtxEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && \ + !defined(EVR_RTX_EVENT_FLAGS_CLEAR_DISABLE)) +__WEAK void EvrRtxEventFlagsClear(osEventFlagsId_t ef_id, uint32_t flags) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxEventFlagsClear, (uint32_t)ef_id, flags); #else @@ -1253,8 +1441,10 @@ __WEAK void EvrRtxEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && !defined(EVR_RTX_EVENT_FLAGS_CLEAR_DONE_DISABLE)) -__WEAK void EvrRtxEventFlagsClearDone (osEventFlagsId_t ef_id, uint32_t event_flags) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && \ + !defined(EVR_RTX_EVENT_FLAGS_CLEAR_DONE_DISABLE)) +__WEAK void EvrRtxEventFlagsClearDone(osEventFlagsId_t ef_id, + uint32_t event_flags) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxEventFlagsClearDone, (uint32_t)ef_id, event_flags); #else @@ -1264,8 +1454,9 @@ __WEAK void EvrRtxEventFlagsClearDone (osEventFlagsId_t ef_id, uint32_t event_fl } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && !defined(EVR_RTX_EVENT_FLAGS_GET_DISABLE)) -__WEAK void EvrRtxEventFlagsGet (osEventFlagsId_t ef_id, uint32_t event_flags) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && \ + !defined(EVR_RTX_EVENT_FLAGS_GET_DISABLE)) +__WEAK void EvrRtxEventFlagsGet(osEventFlagsId_t ef_id, uint32_t event_flags) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxEventFlagsGet, (uint32_t)ef_id, event_flags); #else @@ -1275,10 +1466,13 @@ __WEAK void EvrRtxEventFlagsGet (osEventFlagsId_t ef_id, uint32_t event_flags) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && !defined(EVR_RTX_EVENT_FLAGS_WAIT_DISABLE)) -__WEAK void EvrRtxEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && \ + !defined(EVR_RTX_EVENT_FLAGS_WAIT_DISABLE)) +__WEAK void EvrRtxEventFlagsWait(osEventFlagsId_t ef_id, uint32_t flags, + uint32_t options, uint32_t timeout) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxEventFlagsWait, (uint32_t)ef_id, flags, options, timeout); + (void)EventRecord4(EvtRtxEventFlagsWait, (uint32_t)ef_id, flags, options, + timeout); #else (void)ef_id; (void)flags; @@ -1288,10 +1482,13 @@ __WEAK void EvrRtxEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32 } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && !defined(EVR_RTX_EVENT_FLAGS_WAIT_PENDING_DISABLE)) -__WEAK void EvrRtxEventFlagsWaitPending (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && \ + !defined(EVR_RTX_EVENT_FLAGS_WAIT_PENDING_DISABLE)) +__WEAK void EvrRtxEventFlagsWaitPending(osEventFlagsId_t ef_id, uint32_t flags, + uint32_t options, uint32_t timeout) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxEventFlagsWaitPending, (uint32_t)ef_id, flags, options, timeout); + (void)EventRecord4(EvtRtxEventFlagsWaitPending, (uint32_t)ef_id, flags, + options, timeout); #else (void)ef_id; (void)flags; @@ -1301,8 +1498,9 @@ __WEAK void EvrRtxEventFlagsWaitPending (osEventFlagsId_t ef_id, uint32_t flags, } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && !defined(EVR_RTX_EVENT_FLAGS_WAIT_TIMEOUT_DISABLE)) -__WEAK void EvrRtxEventFlagsWaitTimeout (osEventFlagsId_t ef_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && \ + !defined(EVR_RTX_EVENT_FLAGS_WAIT_TIMEOUT_DISABLE)) +__WEAK void EvrRtxEventFlagsWaitTimeout(osEventFlagsId_t ef_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxEventFlagsWaitTimeout, (uint32_t)ef_id, 0U); #else @@ -1311,10 +1509,14 @@ __WEAK void EvrRtxEventFlagsWaitTimeout (osEventFlagsId_t ef_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && !defined(EVR_RTX_EVENT_FLAGS_WAIT_COMPLETED_DISABLE)) -__WEAK void EvrRtxEventFlagsWaitCompleted (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t event_flags) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && \ + !defined(EVR_RTX_EVENT_FLAGS_WAIT_COMPLETED_DISABLE)) +__WEAK void EvrRtxEventFlagsWaitCompleted(osEventFlagsId_t ef_id, + uint32_t flags, uint32_t options, + uint32_t event_flags) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxEventFlagsWaitCompleted, (uint32_t)ef_id, flags, options, event_flags); + (void)EventRecord4(EvtRtxEventFlagsWaitCompleted, (uint32_t)ef_id, flags, + options, event_flags); #else (void)ef_id; (void)flags; @@ -1324,10 +1526,13 @@ __WEAK void EvrRtxEventFlagsWaitCompleted (osEventFlagsId_t ef_id, uint32_t flag } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && !defined(EVR_RTX_EVENT_FLAGS_WAIT_NOT_COMPLETED_DISABLE)) -__WEAK void EvrRtxEventFlagsWaitNotCompleted (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && \ + !defined(EVR_RTX_EVENT_FLAGS_WAIT_NOT_COMPLETED_DISABLE)) +__WEAK void EvrRtxEventFlagsWaitNotCompleted(osEventFlagsId_t ef_id, + uint32_t flags, uint32_t options) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxEventFlagsWaitNotCompleted, (uint32_t)ef_id, flags, options, 0U); + (void)EventRecord4(EvtRtxEventFlagsWaitNotCompleted, (uint32_t)ef_id, flags, + options, 0U); #else (void)ef_id; (void)flags; @@ -1336,8 +1541,9 @@ __WEAK void EvrRtxEventFlagsWaitNotCompleted (osEventFlagsId_t ef_id, uint32_t f } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && !defined(EVR_RTX_EVENT_FLAGS_DELETE_DISABLE)) -__WEAK void EvrRtxEventFlagsDelete (osEventFlagsId_t ef_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && \ + !defined(EVR_RTX_EVENT_FLAGS_DELETE_DISABLE)) +__WEAK void EvrRtxEventFlagsDelete(osEventFlagsId_t ef_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxEventFlagsDelete, (uint32_t)ef_id, 0U); #else @@ -1346,8 +1552,9 @@ __WEAK void EvrRtxEventFlagsDelete (osEventFlagsId_t ef_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && !defined(EVR_RTX_EVENT_FLAGS_DESTROYED_DISABLE)) -__WEAK void EvrRtxEventFlagsDestroyed (osEventFlagsId_t ef_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_EVFLAGS != 0) && \ + !defined(EVR_RTX_EVENT_FLAGS_DESTROYED_DISABLE)) +__WEAK void EvrRtxEventFlagsDestroyed(osEventFlagsId_t ef_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxEventFlagsDestroyed, (uint32_t)ef_id, 0U); #else @@ -1356,11 +1563,11 @@ __WEAK void EvrRtxEventFlagsDestroyed (osEventFlagsId_t ef_id) { } #endif - // ==== Mutex Events ==== -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && !defined(EVR_RTX_MUTEX_ERROR_DISABLE)) -__WEAK void EvrRtxMutexError (osMutexId_t mutex_id, int32_t status) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && \ + !defined(EVR_RTX_MUTEX_ERROR_DISABLE)) +__WEAK void EvrRtxMutexError(osMutexId_t mutex_id, int32_t status) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMutexError, (uint32_t)mutex_id, (uint32_t)status); #else @@ -1370,8 +1577,9 @@ __WEAK void EvrRtxMutexError (osMutexId_t mutex_id, int32_t status) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && !defined(EVR_RTX_MUTEX_NEW_DISABLE)) -__WEAK void EvrRtxMutexNew (const osMutexAttr_t *attr) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && \ + !defined(EVR_RTX_MUTEX_NEW_DISABLE)) +__WEAK void EvrRtxMutexNew(const osMutexAttr_t *attr) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMutexNew, (uint32_t)attr, 0U); #else @@ -1380,8 +1588,9 @@ __WEAK void EvrRtxMutexNew (const osMutexAttr_t *attr) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && !defined(EVR_RTX_MUTEX_CREATED_DISABLE)) -__WEAK void EvrRtxMutexCreated (osMutexId_t mutex_id, const char *name) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && \ + !defined(EVR_RTX_MUTEX_CREATED_DISABLE)) +__WEAK void EvrRtxMutexCreated(osMutexId_t mutex_id, const char *name) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMutexCreated, (uint32_t)mutex_id, (uint32_t)name); #else @@ -1391,8 +1600,9 @@ __WEAK void EvrRtxMutexCreated (osMutexId_t mutex_id, const char *name) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && !defined(EVR_RTX_MUTEX_GET_NAME_DISABLE)) -__WEAK void EvrRtxMutexGetName (osMutexId_t mutex_id, const char *name) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && \ + !defined(EVR_RTX_MUTEX_GET_NAME_DISABLE)) +__WEAK void EvrRtxMutexGetName(osMutexId_t mutex_id, const char *name) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMutexGetName, (uint32_t)mutex_id, (uint32_t)name); #else @@ -1402,8 +1612,9 @@ __WEAK void EvrRtxMutexGetName (osMutexId_t mutex_id, const char *name) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && !defined(EVR_RTX_MUTEX_ACQUIRE_DISABLE)) -__WEAK void EvrRtxMutexAcquire (osMutexId_t mutex_id, uint32_t timeout) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && \ + !defined(EVR_RTX_MUTEX_ACQUIRE_DISABLE)) +__WEAK void EvrRtxMutexAcquire(osMutexId_t mutex_id, uint32_t timeout) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMutexAcquire, (uint32_t)mutex_id, timeout); #else @@ -1413,8 +1624,9 @@ __WEAK void EvrRtxMutexAcquire (osMutexId_t mutex_id, uint32_t timeout) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && !defined(EVR_RTX_MUTEX_ACQUIRE_PENDING_DISABLE)) -__WEAK void EvrRtxMutexAcquirePending (osMutexId_t mutex_id, uint32_t timeout) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && \ + !defined(EVR_RTX_MUTEX_ACQUIRE_PENDING_DISABLE)) +__WEAK void EvrRtxMutexAcquirePending(osMutexId_t mutex_id, uint32_t timeout) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMutexAcquirePending, (uint32_t)mutex_id, timeout); #else @@ -1424,8 +1636,9 @@ __WEAK void EvrRtxMutexAcquirePending (osMutexId_t mutex_id, uint32_t timeout) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && !defined(EVR_RTX_MUTEX_ACQUIRE_TIMEOUT_DISABLE)) -__WEAK void EvrRtxMutexAcquireTimeout (osMutexId_t mutex_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && \ + !defined(EVR_RTX_MUTEX_ACQUIRE_TIMEOUT_DISABLE)) +__WEAK void EvrRtxMutexAcquireTimeout(osMutexId_t mutex_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMutexAcquireTimeout, (uint32_t)mutex_id, 0U); #else @@ -1434,8 +1647,9 @@ __WEAK void EvrRtxMutexAcquireTimeout (osMutexId_t mutex_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && !defined(EVR_RTX_MUTEX_ACQUIRED_DISABLE)) -__WEAK void EvrRtxMutexAcquired (osMutexId_t mutex_id, uint32_t lock) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && \ + !defined(EVR_RTX_MUTEX_ACQUIRED_DISABLE)) +__WEAK void EvrRtxMutexAcquired(osMutexId_t mutex_id, uint32_t lock) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMutexAcquired, (uint32_t)mutex_id, lock); #else @@ -1445,8 +1659,9 @@ __WEAK void EvrRtxMutexAcquired (osMutexId_t mutex_id, uint32_t lock) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && !defined(EVR_RTX_MUTEX_NOT_ACQUIRED_DISABLE)) -__WEAK void EvrRtxMutexNotAcquired (osMutexId_t mutex_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && \ + !defined(EVR_RTX_MUTEX_NOT_ACQUIRED_DISABLE)) +__WEAK void EvrRtxMutexNotAcquired(osMutexId_t mutex_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMutexNotAcquired, (uint32_t)mutex_id, 0U); #else @@ -1455,8 +1670,9 @@ __WEAK void EvrRtxMutexNotAcquired (osMutexId_t mutex_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && !defined(EVR_RTX_MUTEX_RELEASE_DISABLE)) -__WEAK void EvrRtxMutexRelease (osMutexId_t mutex_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && \ + !defined(EVR_RTX_MUTEX_RELEASE_DISABLE)) +__WEAK void EvrRtxMutexRelease(osMutexId_t mutex_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMutexRelease, (uint32_t)mutex_id, 0U); #else @@ -1465,8 +1681,9 @@ __WEAK void EvrRtxMutexRelease (osMutexId_t mutex_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && !defined(EVR_RTX_MUTEX_RELEASED_DISABLE)) -__WEAK void EvrRtxMutexReleased (osMutexId_t mutex_id, uint32_t lock) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && \ + !defined(EVR_RTX_MUTEX_RELEASED_DISABLE)) +__WEAK void EvrRtxMutexReleased(osMutexId_t mutex_id, uint32_t lock) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMutexReleased, (uint32_t)mutex_id, lock); #else @@ -1476,10 +1693,12 @@ __WEAK void EvrRtxMutexReleased (osMutexId_t mutex_id, uint32_t lock) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && !defined(EVR_RTX_MUTEX_GET_OWNER_DISABLE)) -__WEAK void EvrRtxMutexGetOwner (osMutexId_t mutex_id, osThreadId_t thread_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && \ + !defined(EVR_RTX_MUTEX_GET_OWNER_DISABLE)) +__WEAK void EvrRtxMutexGetOwner(osMutexId_t mutex_id, osThreadId_t thread_id) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxMutexGetOwner, (uint32_t)mutex_id, (uint32_t)thread_id); + (void)EventRecord2(EvtRtxMutexGetOwner, (uint32_t)mutex_id, + (uint32_t)thread_id); #else (void)mutex_id; (void)thread_id; @@ -1487,8 +1706,9 @@ __WEAK void EvrRtxMutexGetOwner (osMutexId_t mutex_id, osThreadId_t thread_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && !defined(EVR_RTX_MUTEX_DELETE_DISABLE)) -__WEAK void EvrRtxMutexDelete (osMutexId_t mutex_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && \ + !defined(EVR_RTX_MUTEX_DELETE_DISABLE)) +__WEAK void EvrRtxMutexDelete(osMutexId_t mutex_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMutexDelete, (uint32_t)mutex_id, 0U); #else @@ -1497,8 +1717,9 @@ __WEAK void EvrRtxMutexDelete (osMutexId_t mutex_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && !defined(EVR_RTX_MUTEX_DESTROYED_DISABLE)) -__WEAK void EvrRtxMutexDestroyed (osMutexId_t mutex_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MUTEX != 0) && \ + !defined(EVR_RTX_MUTEX_DESTROYED_DISABLE)) +__WEAK void EvrRtxMutexDestroyed(osMutexId_t mutex_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMutexDestroyed, (uint32_t)mutex_id, 0U); #else @@ -1507,13 +1728,14 @@ __WEAK void EvrRtxMutexDestroyed (osMutexId_t mutex_id) { } #endif - // ==== Semaphore Events ==== -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && !defined(EVR_RTX_SEMAPHORE_ERROR_DISABLE)) -__WEAK void EvrRtxSemaphoreError (osSemaphoreId_t semaphore_id, int32_t status) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && \ + !defined(EVR_RTX_SEMAPHORE_ERROR_DISABLE)) +__WEAK void EvrRtxSemaphoreError(osSemaphoreId_t semaphore_id, int32_t status) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxSemaphoreError, (uint32_t)semaphore_id, (uint32_t)status); + (void)EventRecord2(EvtRtxSemaphoreError, (uint32_t)semaphore_id, + (uint32_t)status); #else (void)semaphore_id; (void)status; @@ -1521,10 +1743,13 @@ __WEAK void EvrRtxSemaphoreError (osSemaphoreId_t semaphore_id, int32_t status) } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && !defined(EVR_RTX_SEMAPHORE_NEW_DISABLE)) -__WEAK void EvrRtxSemaphoreNew (uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && \ + !defined(EVR_RTX_SEMAPHORE_NEW_DISABLE)) +__WEAK void EvrRtxSemaphoreNew(uint32_t max_count, uint32_t initial_count, + const osSemaphoreAttr_t *attr) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxSemaphoreNew, max_count, initial_count, (uint32_t)attr, 0U); + (void)EventRecord4(EvtRtxSemaphoreNew, max_count, initial_count, + (uint32_t)attr, 0U); #else (void)max_count; (void)initial_count; @@ -1533,10 +1758,13 @@ __WEAK void EvrRtxSemaphoreNew (uint32_t max_count, uint32_t initial_count, cons } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && !defined(EVR_RTX_SEMAPHORE_CREATED_DISABLE)) -__WEAK void EvrRtxSemaphoreCreated (osSemaphoreId_t semaphore_id, const char *name) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && \ + !defined(EVR_RTX_SEMAPHORE_CREATED_DISABLE)) +__WEAK void EvrRtxSemaphoreCreated(osSemaphoreId_t semaphore_id, + const char *name) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxSemaphoreCreated, (uint32_t)semaphore_id, (uint32_t)name); + (void)EventRecord2(EvtRtxSemaphoreCreated, (uint32_t)semaphore_id, + (uint32_t)name); #else (void)semaphore_id; (void)name; @@ -1544,10 +1772,13 @@ __WEAK void EvrRtxSemaphoreCreated (osSemaphoreId_t semaphore_id, const char *na } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && !defined(EVR_RTX_SEMAPHORE_GET_NAME_DISABLE)) -__WEAK void EvrRtxSemaphoreGetName (osSemaphoreId_t semaphore_id, const char *name) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && \ + !defined(EVR_RTX_SEMAPHORE_GET_NAME_DISABLE)) +__WEAK void EvrRtxSemaphoreGetName(osSemaphoreId_t semaphore_id, + const char *name) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxSemaphoreGetName, (uint32_t)semaphore_id, (uint32_t)name); + (void)EventRecord2(EvtRtxSemaphoreGetName, (uint32_t)semaphore_id, + (uint32_t)name); #else #endif (void)semaphore_id; @@ -1555,8 +1786,10 @@ __WEAK void EvrRtxSemaphoreGetName (osSemaphoreId_t semaphore_id, const char *na } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && !defined(EVR_RTX_SEMAPHORE_ACQUIRE_DISABLE)) -__WEAK void EvrRtxSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && \ + !defined(EVR_RTX_SEMAPHORE_ACQUIRE_DISABLE)) +__WEAK void EvrRtxSemaphoreAcquire(osSemaphoreId_t semaphore_id, + uint32_t timeout) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxSemaphoreAcquire, (uint32_t)semaphore_id, timeout); #else @@ -1566,10 +1799,13 @@ __WEAK void EvrRtxSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeo } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && !defined(EVR_RTX_SEMAPHORE_ACQUIRE_PENDING_DISABLE)) -__WEAK void EvrRtxSemaphoreAcquirePending (osSemaphoreId_t semaphore_id, uint32_t timeout) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && \ + !defined(EVR_RTX_SEMAPHORE_ACQUIRE_PENDING_DISABLE)) +__WEAK void EvrRtxSemaphoreAcquirePending(osSemaphoreId_t semaphore_id, + uint32_t timeout) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxSemaphoreAcquirePending, (uint32_t)semaphore_id, (uint32_t)timeout); + (void)EventRecord2(EvtRtxSemaphoreAcquirePending, (uint32_t)semaphore_id, + (uint32_t)timeout); #else (void)semaphore_id; (void)timeout; @@ -1577,8 +1813,9 @@ __WEAK void EvrRtxSemaphoreAcquirePending (osSemaphoreId_t semaphore_id, uint32_ } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && !defined(EVR_RTX_SEMAPHORE_ACQUIRE_TIMEOUT_DISABLE)) -__WEAK void EvrRtxSemaphoreAcquireTimeout (osSemaphoreId_t semaphore_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && \ + !defined(EVR_RTX_SEMAPHORE_ACQUIRE_TIMEOUT_DISABLE)) +__WEAK void EvrRtxSemaphoreAcquireTimeout(osSemaphoreId_t semaphore_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxSemaphoreAcquireTimeout, (uint32_t)semaphore_id, 0U); #else @@ -1587,8 +1824,10 @@ __WEAK void EvrRtxSemaphoreAcquireTimeout (osSemaphoreId_t semaphore_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && !defined(EVR_RTX_SEMAPHORE_ACQUIRED_DISABLE)) -__WEAK void EvrRtxSemaphoreAcquired (osSemaphoreId_t semaphore_id, uint32_t tokens) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && \ + !defined(EVR_RTX_SEMAPHORE_ACQUIRED_DISABLE)) +__WEAK void EvrRtxSemaphoreAcquired(osSemaphoreId_t semaphore_id, + uint32_t tokens) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxSemaphoreAcquired, (uint32_t)semaphore_id, tokens); #else @@ -1598,8 +1837,9 @@ __WEAK void EvrRtxSemaphoreAcquired (osSemaphoreId_t semaphore_id, uint32_t toke } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && !defined(EVR_RTX_SEMAPHORE_NOT_ACQUIRED_DISABLE)) -__WEAK void EvrRtxSemaphoreNotAcquired (osSemaphoreId_t semaphore_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && \ + !defined(EVR_RTX_SEMAPHORE_NOT_ACQUIRED_DISABLE)) +__WEAK void EvrRtxSemaphoreNotAcquired(osSemaphoreId_t semaphore_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxSemaphoreNotAcquired, (uint32_t)semaphore_id, 0U); #else @@ -1608,8 +1848,9 @@ __WEAK void EvrRtxSemaphoreNotAcquired (osSemaphoreId_t semaphore_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && !defined(EVR_RTX_SEMAPHORE_RELEASE_DISABLE)) -__WEAK void EvrRtxSemaphoreRelease (osSemaphoreId_t semaphore_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && \ + !defined(EVR_RTX_SEMAPHORE_RELEASE_DISABLE)) +__WEAK void EvrRtxSemaphoreRelease(osSemaphoreId_t semaphore_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxSemaphoreRelease, (uint32_t)semaphore_id, 0U); #else @@ -1618,8 +1859,10 @@ __WEAK void EvrRtxSemaphoreRelease (osSemaphoreId_t semaphore_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && !defined(EVR_RTX_SEMAPHORE_RELEASED_DISABLE)) -__WEAK void EvrRtxSemaphoreReleased (osSemaphoreId_t semaphore_id, uint32_t tokens) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && \ + !defined(EVR_RTX_SEMAPHORE_RELEASED_DISABLE)) +__WEAK void EvrRtxSemaphoreReleased(osSemaphoreId_t semaphore_id, + uint32_t tokens) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxSemaphoreReleased, (uint32_t)semaphore_id, tokens); #else @@ -1629,8 +1872,10 @@ __WEAK void EvrRtxSemaphoreReleased (osSemaphoreId_t semaphore_id, uint32_t toke } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && !defined(EVR_RTX_SEMAPHORE_GET_COUNT_DISABLE)) -__WEAK void EvrRtxSemaphoreGetCount (osSemaphoreId_t semaphore_id, uint32_t count) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && \ + !defined(EVR_RTX_SEMAPHORE_GET_COUNT_DISABLE)) +__WEAK void EvrRtxSemaphoreGetCount(osSemaphoreId_t semaphore_id, + uint32_t count) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxSemaphoreGetCount, (uint32_t)semaphore_id, count); #else @@ -1640,8 +1885,9 @@ __WEAK void EvrRtxSemaphoreGetCount (osSemaphoreId_t semaphore_id, uint32_t coun } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && !defined(EVR_RTX_SEMAPHORE_DELETE_DISABLE)) -__WEAK void EvrRtxSemaphoreDelete (osSemaphoreId_t semaphore_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && \ + !defined(EVR_RTX_SEMAPHORE_DELETE_DISABLE)) +__WEAK void EvrRtxSemaphoreDelete(osSemaphoreId_t semaphore_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxSemaphoreDelete, (uint32_t)semaphore_id, 0U); #else @@ -1650,8 +1896,9 @@ __WEAK void EvrRtxSemaphoreDelete (osSemaphoreId_t semaphore_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && !defined(EVR_RTX_SEMAPHORE_DESTROYED_DISABLE)) -__WEAK void EvrRtxSemaphoreDestroyed (osSemaphoreId_t semaphore_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_SEMAPHORE != 0) && \ + !defined(EVR_RTX_SEMAPHORE_DESTROYED_DISABLE)) +__WEAK void EvrRtxSemaphoreDestroyed(osSemaphoreId_t semaphore_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxSemaphoreDestroyed, (uint32_t)semaphore_id, 0U); #else @@ -1660,11 +1907,11 @@ __WEAK void EvrRtxSemaphoreDestroyed (osSemaphoreId_t semaphore_id) { } #endif - // ==== Memory Pool Events ==== -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && !defined(EVR_RTX_MEMORY_POOL_ERROR_DISABLE)) -__WEAK void EvrRtxMemoryPoolError (osMemoryPoolId_t mp_id, int32_t status) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && \ + !defined(EVR_RTX_MEMORY_POOL_ERROR_DISABLE)) +__WEAK void EvrRtxMemoryPoolError(osMemoryPoolId_t mp_id, int32_t status) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMemoryPoolError, (uint32_t)mp_id, (uint32_t)status); #else @@ -1674,10 +1921,13 @@ __WEAK void EvrRtxMemoryPoolError (osMemoryPoolId_t mp_id, int32_t status) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && !defined(EVR_RTX_MEMORY_POOL_NEW_DISABLE)) -__WEAK void EvrRtxMemoryPoolNew (uint32_t block_count, uint32_t block_size, const osMemoryPoolAttr_t *attr) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && \ + !defined(EVR_RTX_MEMORY_POOL_NEW_DISABLE)) +__WEAK void EvrRtxMemoryPoolNew(uint32_t block_count, uint32_t block_size, + const osMemoryPoolAttr_t *attr) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxMemoryPoolNew, block_count, block_size, (uint32_t)attr, 0U); + (void)EventRecord4(EvtRtxMemoryPoolNew, block_count, block_size, + (uint32_t)attr, 0U); #else (void)block_count; (void)block_size; @@ -1686,8 +1936,9 @@ __WEAK void EvrRtxMemoryPoolNew (uint32_t block_count, uint32_t block_size, cons } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && !defined(EVR_RTX_MEMORY_POOL_CREATED_DISABLE)) -__WEAK void EvrRtxMemoryPoolCreated (osMemoryPoolId_t mp_id, const char *name) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && \ + !defined(EVR_RTX_MEMORY_POOL_CREATED_DISABLE)) +__WEAK void EvrRtxMemoryPoolCreated(osMemoryPoolId_t mp_id, const char *name) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMemoryPoolCreated, (uint32_t)mp_id, (uint32_t)name); #else @@ -1697,8 +1948,9 @@ __WEAK void EvrRtxMemoryPoolCreated (osMemoryPoolId_t mp_id, const char *name) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && !defined(EVR_RTX_MEMORY_POOL_GET_NAME_DISABLE)) -__WEAK void EvrRtxMemoryPoolGetName (osMemoryPoolId_t mp_id, const char *name) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && \ + !defined(EVR_RTX_MEMORY_POOL_GET_NAME_DISABLE)) +__WEAK void EvrRtxMemoryPoolGetName(osMemoryPoolId_t mp_id, const char *name) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMemoryPoolGetName, (uint32_t)mp_id, (uint32_t)name); #else @@ -1708,8 +1960,9 @@ __WEAK void EvrRtxMemoryPoolGetName (osMemoryPoolId_t mp_id, const char *name) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && !defined(EVR_RTX_MEMORY_POOL_ALLOC_DISABLE)) -__WEAK void EvrRtxMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && \ + !defined(EVR_RTX_MEMORY_POOL_ALLOC_DISABLE)) +__WEAK void EvrRtxMemoryPoolAlloc(osMemoryPoolId_t mp_id, uint32_t timeout) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMemoryPoolAlloc, (uint32_t)mp_id, timeout); #else @@ -1719,8 +1972,10 @@ __WEAK void EvrRtxMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && !defined(EVR_RTX_MEMORY_POOL_ALLOC_PENDING_DISABLE)) -__WEAK void EvrRtxMemoryPoolAllocPending (osMemoryPoolId_t mp_id, uint32_t timeout) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && \ + !defined(EVR_RTX_MEMORY_POOL_ALLOC_PENDING_DISABLE)) +__WEAK void EvrRtxMemoryPoolAllocPending(osMemoryPoolId_t mp_id, + uint32_t timeout) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMemoryPoolAllocPending, (uint32_t)mp_id, timeout); #else @@ -1730,8 +1985,9 @@ __WEAK void EvrRtxMemoryPoolAllocPending (osMemoryPoolId_t mp_id, uint32_t timeo } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && !defined(EVR_RTX_MEMORY_POOL_ALLOC_TIMEOUT_DISABLE)) -__WEAK void EvrRtxMemoryPoolAllocTimeout (osMemoryPoolId_t mp_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && \ + !defined(EVR_RTX_MEMORY_POOL_ALLOC_TIMEOUT_DISABLE)) +__WEAK void EvrRtxMemoryPoolAllocTimeout(osMemoryPoolId_t mp_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMemoryPoolAllocTimeout, (uint32_t)mp_id, 0U); #else @@ -1740,10 +1996,12 @@ __WEAK void EvrRtxMemoryPoolAllocTimeout (osMemoryPoolId_t mp_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && !defined(EVR_RTX_MEMORY_POOL_ALLOCATED_DISABLE)) -__WEAK void EvrRtxMemoryPoolAllocated (osMemoryPoolId_t mp_id, void *block) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && \ + !defined(EVR_RTX_MEMORY_POOL_ALLOCATED_DISABLE)) +__WEAK void EvrRtxMemoryPoolAllocated(osMemoryPoolId_t mp_id, void *block) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxMemoryPoolAllocated, (uint32_t)mp_id, (uint32_t)block); + (void)EventRecord2(EvtRtxMemoryPoolAllocated, (uint32_t)mp_id, + (uint32_t)block); #else (void)mp_id; (void)block; @@ -1751,8 +2009,9 @@ __WEAK void EvrRtxMemoryPoolAllocated (osMemoryPoolId_t mp_id, void *block) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && !defined(EVR_RTX_MEMORY_POOL_ALLOC_FAILED_DISABLE)) -__WEAK void EvrRtxMemoryPoolAllocFailed (osMemoryPoolId_t mp_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && \ + !defined(EVR_RTX_MEMORY_POOL_ALLOC_FAILED_DISABLE)) +__WEAK void EvrRtxMemoryPoolAllocFailed(osMemoryPoolId_t mp_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMemoryPoolAllocFailed, (uint32_t)mp_id, 0U); #else @@ -1761,8 +2020,9 @@ __WEAK void EvrRtxMemoryPoolAllocFailed (osMemoryPoolId_t mp_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && !defined(EVR_RTX_MEMORY_POOL_FREE_DISABLE)) -__WEAK void EvrRtxMemoryPoolFree (osMemoryPoolId_t mp_id, void *block) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && \ + !defined(EVR_RTX_MEMORY_POOL_FREE_DISABLE)) +__WEAK void EvrRtxMemoryPoolFree(osMemoryPoolId_t mp_id, void *block) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMemoryPoolFree, (uint32_t)mp_id, (uint32_t)block); #else @@ -1772,10 +2032,12 @@ __WEAK void EvrRtxMemoryPoolFree (osMemoryPoolId_t mp_id, void *block) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && !defined(EVR_RTX_MEMORY_POOL_DEALLOCATED_DISABLE)) -__WEAK void EvrRtxMemoryPoolDeallocated (osMemoryPoolId_t mp_id, void *block) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && \ + !defined(EVR_RTX_MEMORY_POOL_DEALLOCATED_DISABLE)) +__WEAK void EvrRtxMemoryPoolDeallocated(osMemoryPoolId_t mp_id, void *block) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxMemoryPoolDeallocated, (uint32_t)mp_id, (uint32_t)block); + (void)EventRecord2(EvtRtxMemoryPoolDeallocated, (uint32_t)mp_id, + (uint32_t)block); #else (void)mp_id; (void)block; @@ -1783,10 +2045,12 @@ __WEAK void EvrRtxMemoryPoolDeallocated (osMemoryPoolId_t mp_id, void *block) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && !defined(EVR_RTX_MEMORY_POOL_FREE_FAILED_DISABLE)) -__WEAK void EvrRtxMemoryPoolFreeFailed (osMemoryPoolId_t mp_id, void *block) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && \ + !defined(EVR_RTX_MEMORY_POOL_FREE_FAILED_DISABLE)) +__WEAK void EvrRtxMemoryPoolFreeFailed(osMemoryPoolId_t mp_id, void *block) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxMemoryPoolFreeFailed, (uint32_t)mp_id, (uint32_t)block); + (void)EventRecord2(EvtRtxMemoryPoolFreeFailed, (uint32_t)mp_id, + (uint32_t)block); #else (void)mp_id; (void)block; @@ -1794,8 +2058,10 @@ __WEAK void EvrRtxMemoryPoolFreeFailed (osMemoryPoolId_t mp_id, void *block) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && !defined(EVR_RTX_MEMORY_POOL_GET_CAPACITY_DISABLE)) -__WEAK void EvrRtxMemoryPoolGetCapacity (osMemoryPoolId_t mp_id, uint32_t capacity) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && \ + !defined(EVR_RTX_MEMORY_POOL_GET_CAPACITY_DISABLE)) +__WEAK void EvrRtxMemoryPoolGetCapacity(osMemoryPoolId_t mp_id, + uint32_t capacity) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMemoryPoolGetCapacity, (uint32_t)mp_id, capacity); #else @@ -1805,8 +2071,10 @@ __WEAK void EvrRtxMemoryPoolGetCapacity (osMemoryPoolId_t mp_id, uint32_t capaci } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && !defined(EVR_RTX_MEMORY_POOL_GET_BLOCK_SZIE_DISABLE)) -__WEAK void EvrRtxMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id, uint32_t block_size) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && \ + !defined(EVR_RTX_MEMORY_POOL_GET_BLOCK_SZIE_DISABLE)) +__WEAK void EvrRtxMemoryPoolGetBlockSize(osMemoryPoolId_t mp_id, + uint32_t block_size) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMemoryPoolGetBlockSize, (uint32_t)mp_id, block_size); #else @@ -1816,8 +2084,9 @@ __WEAK void EvrRtxMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id, uint32_t block } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && !defined(EVR_RTX_MEMORY_POOL_GET_COUNT_DISABLE)) -__WEAK void EvrRtxMemoryPoolGetCount (osMemoryPoolId_t mp_id, uint32_t count) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && \ + !defined(EVR_RTX_MEMORY_POOL_GET_COUNT_DISABLE)) +__WEAK void EvrRtxMemoryPoolGetCount(osMemoryPoolId_t mp_id, uint32_t count) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMemoryPoolGetCount, (uint32_t)mp_id, count); #else @@ -1827,8 +2096,9 @@ __WEAK void EvrRtxMemoryPoolGetCount (osMemoryPoolId_t mp_id, uint32_t count) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && !defined(EVR_RTX_MEMORY_POOL_GET_SPACE_DISABLE)) -__WEAK void EvrRtxMemoryPoolGetSpace (osMemoryPoolId_t mp_id, uint32_t space) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && \ + !defined(EVR_RTX_MEMORY_POOL_GET_SPACE_DISABLE)) +__WEAK void EvrRtxMemoryPoolGetSpace(osMemoryPoolId_t mp_id, uint32_t space) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMemoryPoolGetSpace, (uint32_t)mp_id, space); #else @@ -1838,8 +2108,9 @@ __WEAK void EvrRtxMemoryPoolGetSpace (osMemoryPoolId_t mp_id, uint32_t space) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && !defined(EVR_RTX_MEMORY_POOL_DELETE_DISABLE)) -__WEAK void EvrRtxMemoryPoolDelete (osMemoryPoolId_t mp_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && \ + !defined(EVR_RTX_MEMORY_POOL_DELETE_DISABLE)) +__WEAK void EvrRtxMemoryPoolDelete(osMemoryPoolId_t mp_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMemoryPoolDelete, (uint32_t)mp_id, 0U); #else @@ -1848,8 +2119,9 @@ __WEAK void EvrRtxMemoryPoolDelete (osMemoryPoolId_t mp_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && !defined(EVR_RTX_MEMORY_POOL_DESTROYED_DISABLE)) -__WEAK void EvrRtxMemoryPoolDestroyed (osMemoryPoolId_t mp_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MEMPOOL != 0) && \ + !defined(EVR_RTX_MEMORY_POOL_DESTROYED_DISABLE)) +__WEAK void EvrRtxMemoryPoolDestroyed(osMemoryPoolId_t mp_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMemoryPoolDestroyed, (uint32_t)mp_id, 0U); #else @@ -1858,13 +2130,14 @@ __WEAK void EvrRtxMemoryPoolDestroyed (osMemoryPoolId_t mp_id) { } #endif - // ==== Message Queue Events ==== -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_ERROR_DISABLE)) -__WEAK void EvrRtxMessageQueueError (osMessageQueueId_t mq_id, int32_t status) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_ERROR_DISABLE)) +__WEAK void EvrRtxMessageQueueError(osMessageQueueId_t mq_id, int32_t status) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2 (EvtRtxMessageQueueError, (uint32_t)mq_id, (uint32_t)status); + (void)EventRecord2(EvtRtxMessageQueueError, (uint32_t)mq_id, + (uint32_t)status); #else (void)mq_id; (void)status; @@ -1872,10 +2145,13 @@ __WEAK void EvrRtxMessageQueueError (osMessageQueueId_t mq_id, int32_t status) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_NEW_DISABLE)) -__WEAK void EvrRtxMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_NEW_DISABLE)) +__WEAK void EvrRtxMessageQueueNew(uint32_t msg_count, uint32_t msg_size, + const osMessageQueueAttr_t *attr) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxMessageQueueNew, msg_count, msg_size, (uint32_t)attr, 0U); + (void)EventRecord4(EvtRtxMessageQueueNew, msg_count, msg_size, (uint32_t)attr, + 0U); #else (void)msg_count; (void)msg_size; @@ -1884,10 +2160,13 @@ __WEAK void EvrRtxMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_CREATED_DISABLE)) -__WEAK void EvrRtxMessageQueueCreated (osMessageQueueId_t mq_id, const char *name) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_CREATED_DISABLE)) +__WEAK void EvrRtxMessageQueueCreated(osMessageQueueId_t mq_id, + const char *name) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxMessageQueueCreated, (uint32_t)mq_id, (uint32_t)name); + (void)EventRecord2(EvtRtxMessageQueueCreated, (uint32_t)mq_id, + (uint32_t)name); #else (void)mq_id; (void)name; @@ -1895,10 +2174,13 @@ __WEAK void EvrRtxMessageQueueCreated (osMessageQueueId_t mq_id, const char *nam } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_GET_NAME_DISABLE)) -__WEAK void EvrRtxMessageQueueGetName (osMessageQueueId_t mq_id, const char *name) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_GET_NAME_DISABLE)) +__WEAK void EvrRtxMessageQueueGetName(osMessageQueueId_t mq_id, + const char *name) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxMessageQueueGetName, (uint32_t)mq_id, (uint32_t)name); + (void)EventRecord2(EvtRtxMessageQueueGetName, (uint32_t)mq_id, + (uint32_t)name); #else (void)mq_id; (void)name; @@ -1906,10 +2188,13 @@ __WEAK void EvrRtxMessageQueueGetName (osMessageQueueId_t mq_id, const char *nam } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_PUT_DISABLE)) -__WEAK void EvrRtxMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_PUT_DISABLE)) +__WEAK void EvrRtxMessageQueuePut(osMessageQueueId_t mq_id, const void *msg_ptr, + uint8_t msg_prio, uint32_t timeout) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxMessageQueuePut, (uint32_t)mq_id, (uint32_t)msg_ptr, (uint32_t)msg_prio, timeout); + (void)EventRecord4(EvtRtxMessageQueuePut, (uint32_t)mq_id, (uint32_t)msg_ptr, + (uint32_t)msg_prio, timeout); #else (void)mq_id; (void)msg_ptr; @@ -1919,10 +2204,14 @@ __WEAK void EvrRtxMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_PUT_PENDING_DISABLE)) -__WEAK void EvrRtxMessageQueuePutPending (osMessageQueueId_t mq_id, const void *msg_ptr, uint32_t timeout) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_PUT_PENDING_DISABLE)) +__WEAK void EvrRtxMessageQueuePutPending(osMessageQueueId_t mq_id, + const void *msg_ptr, + uint32_t timeout) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxMessageQueuePutPending, (uint32_t)mq_id, (uint32_t)msg_ptr, timeout, 0U); + (void)EventRecord4(EvtRtxMessageQueuePutPending, (uint32_t)mq_id, + (uint32_t)msg_ptr, timeout, 0U); #else (void)mq_id; (void)msg_ptr; @@ -1931,8 +2220,9 @@ __WEAK void EvrRtxMessageQueuePutPending (osMessageQueueId_t mq_id, const void * } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_PUT_TIMEOUT_DISABLE)) -__WEAK void EvrRtxMessageQueuePutTimeout (osMessageQueueId_t mq_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_PUT_TIMEOUT_DISABLE)) +__WEAK void EvrRtxMessageQueuePutTimeout(osMessageQueueId_t mq_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMessageQueuePutTimeout, (uint32_t)mq_id, 0U); #else @@ -1941,10 +2231,13 @@ __WEAK void EvrRtxMessageQueuePutTimeout (osMessageQueueId_t mq_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_INSERT_PENDING_DISABLE)) -__WEAK void EvrRtxMessageQueueInsertPending (osMessageQueueId_t mq_id, const void *msg_ptr) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_INSERT_PENDING_DISABLE)) +__WEAK void EvrRtxMessageQueueInsertPending(osMessageQueueId_t mq_id, + const void *msg_ptr) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxMessageQueueInsertPending, (uint32_t)mq_id, (uint32_t)msg_ptr); + (void)EventRecord2(EvtRtxMessageQueueInsertPending, (uint32_t)mq_id, + (uint32_t)msg_ptr); #else (void)mq_id; (void)msg_ptr; @@ -1952,10 +2245,13 @@ __WEAK void EvrRtxMessageQueueInsertPending (osMessageQueueId_t mq_id, const voi } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_INSERTED_DISABLE)) -__WEAK void EvrRtxMessageQueueInserted (osMessageQueueId_t mq_id, const void *msg_ptr) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_INSERTED_DISABLE)) +__WEAK void EvrRtxMessageQueueInserted(osMessageQueueId_t mq_id, + const void *msg_ptr) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxMessageQueueInserted, (uint32_t)mq_id, (uint32_t)msg_ptr); + (void)EventRecord2(EvtRtxMessageQueueInserted, (uint32_t)mq_id, + (uint32_t)msg_ptr); #else (void)mq_id; (void)msg_ptr; @@ -1963,10 +2259,13 @@ __WEAK void EvrRtxMessageQueueInserted (osMessageQueueId_t mq_id, const void *ms } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_NOT_INSERTED_DISABLE)) -__WEAK void EvrRtxMessageQueueNotInserted (osMessageQueueId_t mq_id, const void *msg_ptr) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_NOT_INSERTED_DISABLE)) +__WEAK void EvrRtxMessageQueueNotInserted(osMessageQueueId_t mq_id, + const void *msg_ptr) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxMessageQueueNotInserted, (uint32_t)mq_id, (uint32_t)msg_ptr); + (void)EventRecord2(EvtRtxMessageQueueNotInserted, (uint32_t)mq_id, + (uint32_t)msg_ptr); #else (void)mq_id; (void)msg_ptr; @@ -1974,10 +2273,13 @@ __WEAK void EvrRtxMessageQueueNotInserted (osMessageQueueId_t mq_id, const void } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_GET_DISABLE)) -__WEAK void EvrRtxMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_GET_DISABLE)) +__WEAK void EvrRtxMessageQueueGet(osMessageQueueId_t mq_id, void *msg_ptr, + uint8_t *msg_prio, uint32_t timeout) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxMessageQueueGet, (uint32_t)mq_id, (uint32_t)msg_ptr, (uint32_t)msg_prio, timeout); + (void)EventRecord4(EvtRtxMessageQueueGet, (uint32_t)mq_id, (uint32_t)msg_ptr, + (uint32_t)msg_prio, timeout); #else (void)mq_id; (void)msg_ptr; @@ -1987,10 +2289,13 @@ __WEAK void EvrRtxMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_GET_PENDING_DISABLE)) -__WEAK void EvrRtxMessageQueueGetPending (osMessageQueueId_t mq_id, void *msg_ptr, uint32_t timeout) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_GET_PENDING_DISABLE)) +__WEAK void EvrRtxMessageQueueGetPending(osMessageQueueId_t mq_id, + void *msg_ptr, uint32_t timeout) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord4(EvtRtxMessageQueueGetPending, (uint32_t)mq_id, (uint32_t)msg_ptr, timeout, 0U); + (void)EventRecord4(EvtRtxMessageQueueGetPending, (uint32_t)mq_id, + (uint32_t)msg_ptr, timeout, 0U); #else (void)mq_id; (void)msg_ptr; @@ -1999,8 +2304,9 @@ __WEAK void EvrRtxMessageQueueGetPending (osMessageQueueId_t mq_id, void *msg_pt } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_GET_TIMEOUT_DISABLE)) -__WEAK void EvrRtxMessageQueueGetTimeout (osMessageQueueId_t mq_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_GET_TIMEOUT_DISABLE)) +__WEAK void EvrRtxMessageQueueGetTimeout(osMessageQueueId_t mq_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMessageQueueGetTimeout, (uint32_t)mq_id, 0U); #else @@ -2009,10 +2315,13 @@ __WEAK void EvrRtxMessageQueueGetTimeout (osMessageQueueId_t mq_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_RETRIEVED_DISABLE)) -__WEAK void EvrRtxMessageQueueRetrieved (osMessageQueueId_t mq_id, void *msg_ptr) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_RETRIEVED_DISABLE)) +__WEAK void EvrRtxMessageQueueRetrieved(osMessageQueueId_t mq_id, + void *msg_ptr) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxMessageQueueRetrieved, (uint32_t)mq_id, (uint32_t)msg_ptr); + (void)EventRecord2(EvtRtxMessageQueueRetrieved, (uint32_t)mq_id, + (uint32_t)msg_ptr); #else (void)mq_id; (void)msg_ptr; @@ -2020,10 +2329,13 @@ __WEAK void EvrRtxMessageQueueRetrieved (osMessageQueueId_t mq_id, void *msg_ptr } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_NOT_RETRIEVED_DISABLE)) -__WEAK void EvrRtxMessageQueueNotRetrieved (osMessageQueueId_t mq_id, void *msg_ptr) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_NOT_RETRIEVED_DISABLE)) +__WEAK void EvrRtxMessageQueueNotRetrieved(osMessageQueueId_t mq_id, + void *msg_ptr) { #if defined(RTE_Compiler_EventRecorder) - (void)EventRecord2(EvtRtxMessageQueueNotRetrieved, (uint32_t)mq_id, (uint32_t)msg_ptr); + (void)EventRecord2(EvtRtxMessageQueueNotRetrieved, (uint32_t)mq_id, + (uint32_t)msg_ptr); #else (void)mq_id; (void)msg_ptr; @@ -2031,8 +2343,10 @@ __WEAK void EvrRtxMessageQueueNotRetrieved (osMessageQueueId_t mq_id, void *msg_ } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_GET_CAPACITY_DISABLE)) -__WEAK void EvrRtxMessageQueueGetCapacity (osMessageQueueId_t mq_id, uint32_t capacity) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_GET_CAPACITY_DISABLE)) +__WEAK void EvrRtxMessageQueueGetCapacity(osMessageQueueId_t mq_id, + uint32_t capacity) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMessageQueueGetCapacity, (uint32_t)mq_id, capacity); #else @@ -2042,8 +2356,10 @@ __WEAK void EvrRtxMessageQueueGetCapacity (osMessageQueueId_t mq_id, uint32_t ca } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_GET_MSG_SIZE_DISABLE)) -__WEAK void EvrRtxMessageQueueGetMsgSize (osMessageQueueId_t mq_id, uint32_t msg_size) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_GET_MSG_SIZE_DISABLE)) +__WEAK void EvrRtxMessageQueueGetMsgSize(osMessageQueueId_t mq_id, + uint32_t msg_size) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMessageQueueGetMsgSize, (uint32_t)mq_id, msg_size); #else @@ -2053,8 +2369,10 @@ __WEAK void EvrRtxMessageQueueGetMsgSize (osMessageQueueId_t mq_id, uint32_t msg } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_GET_COUNT_DISABLE)) -__WEAK void EvrRtxMessageQueueGetCount (osMessageQueueId_t mq_id, uint32_t count) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_GET_COUNT_DISABLE)) +__WEAK void EvrRtxMessageQueueGetCount(osMessageQueueId_t mq_id, + uint32_t count) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMessageQueueGetCount, (uint32_t)mq_id, count); #else @@ -2064,8 +2382,10 @@ __WEAK void EvrRtxMessageQueueGetCount (osMessageQueueId_t mq_id, uint32_t count } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_GET_SPACE_DISABLE)) -__WEAK void EvrRtxMessageQueueGetSpace (osMessageQueueId_t mq_id, uint32_t space) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_GET_SPACE_DISABLE)) +__WEAK void EvrRtxMessageQueueGetSpace(osMessageQueueId_t mq_id, + uint32_t space) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMessageQueueGetSpace, (uint32_t)mq_id, space); #else @@ -2075,8 +2395,9 @@ __WEAK void EvrRtxMessageQueueGetSpace (osMessageQueueId_t mq_id, uint32_t space } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_RESET_DISABLE)) -__WEAK void EvrRtxMessageQueueReset (osMessageQueueId_t mq_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_RESET_DISABLE)) +__WEAK void EvrRtxMessageQueueReset(osMessageQueueId_t mq_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMessageQueueReset, (uint32_t)mq_id, 0U); #else @@ -2085,8 +2406,9 @@ __WEAK void EvrRtxMessageQueueReset (osMessageQueueId_t mq_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_RESET_DONE_DISABLE)) -__WEAK void EvrRtxMessageQueueResetDone (osMessageQueueId_t mq_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_RESET_DONE_DISABLE)) +__WEAK void EvrRtxMessageQueueResetDone(osMessageQueueId_t mq_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMessageQueueResetDone, (uint32_t)mq_id, 0U); #else @@ -2095,8 +2417,9 @@ __WEAK void EvrRtxMessageQueueResetDone (osMessageQueueId_t mq_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_DELETE_DISABLE)) -__WEAK void EvrRtxMessageQueueDelete (osMessageQueueId_t mq_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_DELETE_DISABLE)) +__WEAK void EvrRtxMessageQueueDelete(osMessageQueueId_t mq_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMessageQueueDelete, (uint32_t)mq_id, 0U); #else @@ -2105,8 +2428,9 @@ __WEAK void EvrRtxMessageQueueDelete (osMessageQueueId_t mq_id) { } #endif -#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_DESTROYED_DISABLE)) -__WEAK void EvrRtxMessageQueueDestroyed (osMessageQueueId_t mq_id) { +#if (!defined(EVR_RTX_DISABLE) && (OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_DESTROYED_DISABLE)) +__WEAK void EvrRtxMessageQueueDestroyed(osMessageQueueId_t mq_id) { #if defined(RTE_Compiler_EventRecorder) (void)EventRecord2(EvtRtxMessageQueueDestroyed, (uint32_t)mq_id, 0U); #else diff --git a/rtos/rtx5/rtx_kernel.c b/rtos/rtx5/rtx_kernel.c index 4735c73..ee4c9b3 100644 --- a/rtos/rtx5/rtx_kernel.c +++ b/rtos/rtx5/rtx_kernel.c @@ -23,24 +23,26 @@ * ----------------------------------------------------------------------------- */ -#include "rtx_lib.h" -#include "os_tick.h" #include "hal_timer.h" #include "hal_trace.h" +#include "os_tick.h" +#include "rtx_lib.h" // OS Runtime Information osRtxInfo_t osRtxInfo __attribute__((section(".data.os"))) = -//lint -e{785} "Initialize only OS ID, OS Version and Kernel State" -{ .os_id = osRtxKernelId, .version = osRtxVersionKernel, .kernel.state = osRtxKernelInactive }; + // lint -e{785} "Initialize only OS ID, OS Version and Kernel State" + {.os_id = osRtxKernelId, + .version = osRtxVersionKernel, + .kernel.state = osRtxKernelInactive}; -#define OS_BSS_LOC __attribute__((section(".bss.os"))) +#define OS_BSS_LOC __attribute__((section(".bss.os"))) OS_BSS_LOC static uint32_t systick_lock_val; OS_BSS_LOC static uint32_t systick_lock_ts; // ==== Helper functions ==== /// Block Kernel (disable: thread switching, time tick, post ISR processing). -static void KernelBlock (void) { +static void KernelBlock(void) { OS_Tick_Disable(); @@ -54,7 +56,7 @@ static void KernelBlock (void) { } /// Unblock Kernel -static void KernelUnblock (void) { +static void KernelUnblock(void) { osRtxInfo.kernel.blocked = 0U; __DSB(); @@ -67,21 +69,20 @@ static void KernelUnblock (void) { OS_Tick_Enable(); } - // ==== Service Calls ==== /// Initialize the RTOS Kernel. /// \note API identical to osKernelInitialize -static osStatus_t svcRtxKernelInitialize (void) { +static osStatus_t svcRtxKernelInitialize(void) { if (osRtxInfo.kernel.state == osRtxKernelReady) { EvrRtxKernelInitialized(); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osOK; } if (osRtxInfo.kernel.state != osRtxKernelInactive) { EvrRtxKernelError((int32_t)osError); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osError; } @@ -89,34 +90,39 @@ static osStatus_t svcRtxKernelInitialize (void) { // Initialize Secure Process Stack if (TZ_InitContextSystem_S() == 0U) { EvrRtxKernelError(osRtxErrorTZ_InitContext_S); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osError; } #endif // Initialize osRtxInfo - memset((uint8_t *)&osRtxInfo + offsetof(osRtxInfo_t, kernel), 0, sizeof(osRtxInfo) - offsetof(osRtxInfo_t, kernel)); + memset((uint8_t *)&osRtxInfo + offsetof(osRtxInfo_t, kernel), 0, + sizeof(osRtxInfo) - offsetof(osRtxInfo_t, kernel)); osRtxInfo.isr_queue.data = osRtxConfig.isr_queue.data; - osRtxInfo.isr_queue.max = osRtxConfig.isr_queue.max; + osRtxInfo.isr_queue.max = osRtxConfig.isr_queue.max; osRtxInfo.thread.robin.timeout = osRtxConfig.robin_timeout; // Initialize Memory Pools (Variable Block Size) - if (osRtxMemoryInit(osRtxConfig.mem.common_addr, osRtxConfig.mem.common_size) != 0U) { + if (osRtxMemoryInit(osRtxConfig.mem.common_addr, + osRtxConfig.mem.common_size) != 0U) { osRtxInfo.mem.common = osRtxConfig.mem.common_addr; } - if (osRtxMemoryInit(osRtxConfig.mem.stack_addr, osRtxConfig.mem.stack_size) != 0U) { + if (osRtxMemoryInit(osRtxConfig.mem.stack_addr, osRtxConfig.mem.stack_size) != + 0U) { osRtxInfo.mem.stack = osRtxConfig.mem.stack_addr; } else { osRtxInfo.mem.stack = osRtxInfo.mem.common; } - if (osRtxMemoryInit(osRtxConfig.mem.mp_data_addr, osRtxConfig.mem.mp_data_size) != 0U) { + if (osRtxMemoryInit(osRtxConfig.mem.mp_data_addr, + osRtxConfig.mem.mp_data_size) != 0U) { osRtxInfo.mem.mp_data = osRtxConfig.mem.mp_data_addr; } else { osRtxInfo.mem.mp_data = osRtxInfo.mem.common; } - if (osRtxMemoryInit(osRtxConfig.mem.mq_data_addr, osRtxConfig.mem.mq_data_size) != 0U) { + if (osRtxMemoryInit(osRtxConfig.mem.mq_data_addr, + osRtxConfig.mem.mq_data_size) != 0U) { osRtxInfo.mem.mq_data = osRtxConfig.mem.mq_data_addr; } else { osRtxInfo.mem.mq_data = osRtxInfo.mem.common; @@ -124,24 +130,21 @@ static osStatus_t svcRtxKernelInitialize (void) { // Initialize Memory Pools (Fixed Block Size) if (osRtxConfig.mpi.stack != NULL) { - (void)osRtxMemoryPoolInit(osRtxConfig.mpi.stack, - osRtxConfig.mpi.stack->max_blocks, - osRtxConfig.mpi.stack->block_size, - osRtxConfig.mpi.stack->block_base); + (void)osRtxMemoryPoolInit( + osRtxConfig.mpi.stack, osRtxConfig.mpi.stack->max_blocks, + osRtxConfig.mpi.stack->block_size, osRtxConfig.mpi.stack->block_base); osRtxInfo.mpi.stack = osRtxConfig.mpi.stack; } if (osRtxConfig.mpi.thread != NULL) { - (void)osRtxMemoryPoolInit(osRtxConfig.mpi.thread, - osRtxConfig.mpi.thread->max_blocks, - osRtxConfig.mpi.thread->block_size, - osRtxConfig.mpi.thread->block_base); + (void)osRtxMemoryPoolInit( + osRtxConfig.mpi.thread, osRtxConfig.mpi.thread->max_blocks, + osRtxConfig.mpi.thread->block_size, osRtxConfig.mpi.thread->block_base); osRtxInfo.mpi.thread = osRtxConfig.mpi.thread; } if (osRtxConfig.mpi.timer != NULL) { - (void)osRtxMemoryPoolInit(osRtxConfig.mpi.timer, - osRtxConfig.mpi.timer->max_blocks, - osRtxConfig.mpi.timer->block_size, - osRtxConfig.mpi.timer->block_base); + (void)osRtxMemoryPoolInit( + osRtxConfig.mpi.timer, osRtxConfig.mpi.timer->max_blocks, + osRtxConfig.mpi.timer->block_size, osRtxConfig.mpi.timer->block_base); osRtxInfo.mpi.timer = osRtxConfig.mpi.timer; } if (osRtxConfig.mpi.event_flags != NULL) { @@ -152,10 +155,9 @@ static osStatus_t svcRtxKernelInitialize (void) { osRtxInfo.mpi.event_flags = osRtxConfig.mpi.event_flags; } if (osRtxConfig.mpi.mutex != NULL) { - (void)osRtxMemoryPoolInit(osRtxConfig.mpi.mutex, - osRtxConfig.mpi.mutex->max_blocks, - osRtxConfig.mpi.mutex->block_size, - osRtxConfig.mpi.mutex->block_base); + (void)osRtxMemoryPoolInit( + osRtxConfig.mpi.mutex, osRtxConfig.mpi.mutex->max_blocks, + osRtxConfig.mpi.mutex->block_size, osRtxConfig.mpi.mutex->block_base); osRtxInfo.mpi.mutex = osRtxConfig.mpi.mutex; } if (osRtxConfig.mpi.semaphore != NULL) { @@ -189,11 +191,12 @@ static osStatus_t svcRtxKernelInitialize (void) { /// Get RTOS Kernel Information. /// \note API identical to osKernelGetInfo -static osStatus_t svcRtxKernelGetInfo (osVersion_t *version, char *id_buf, uint32_t id_size) { +static osStatus_t svcRtxKernelGetInfo(osVersion_t *version, char *id_buf, + uint32_t id_size) { uint32_t size; if (version != NULL) { - version->api = osRtxVersionAPI; + version->api = osRtxVersionAPI; version->kernel = osRtxVersionKernel; } @@ -213,7 +216,7 @@ static osStatus_t svcRtxKernelGetInfo (osVersion_t *version, char *id_buf, uint3 /// Get the current RTOS Kernel state. /// \note API identical to osKernelGetState -static osKernelState_t svcRtxKernelGetState (void) { +static osKernelState_t svcRtxKernelGetState(void) { osKernelState_t state = osRtxKernelState(); EvrRtxKernelGetState(state); return state; @@ -221,19 +224,19 @@ static osKernelState_t svcRtxKernelGetState (void) { /// Start the RTOS Kernel scheduler. /// \note API identical to osKernelStart -static osStatus_t svcRtxKernelStart (void) { +static osStatus_t svcRtxKernelStart(void) { os_thread_t *thread; if (osRtxInfo.kernel.state != osRtxKernelReady) { EvrRtxKernelError(osRtxErrorKernelNotReady); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osError; } // Thread startup (Idle and Timer Thread) if (!osRtxThreadStartup()) { EvrRtxKernelError((int32_t)osError); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osError; } @@ -243,7 +246,7 @@ static osStatus_t svcRtxKernelStart (void) { // Setup RTOS Tick if (OS_Tick_Setup(osRtxConfig.tick_freq, OS_TICK_HANDLER) != 0) { EvrRtxKernelError((int32_t)osError); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osError; } osRtxInfo.tick_irqn = OS_Tick_GetIRQn(); @@ -272,93 +275,93 @@ static osStatus_t svcRtxKernelStart (void) { /// Lock the RTOS Kernel scheduler. /// \note API identical to osKernelLock -static int32_t svcRtxKernelLock (void) { +static int32_t svcRtxKernelLock(void) { int32_t lock; switch (osRtxInfo.kernel.state) { - case osRtxKernelRunning: - osRtxInfo.kernel.state = osRtxKernelLocked; - EvrRtxKernelLocked(0); - lock = 0; - break; - case osRtxKernelLocked: - EvrRtxKernelLocked(1); - lock = 1; - break; - default: - EvrRtxKernelError((int32_t)osError); - lock = (int32_t)osError; - break; + case osRtxKernelRunning: + osRtxInfo.kernel.state = osRtxKernelLocked; + EvrRtxKernelLocked(0); + lock = 0; + break; + case osRtxKernelLocked: + EvrRtxKernelLocked(1); + lock = 1; + break; + default: + EvrRtxKernelError((int32_t)osError); + lock = (int32_t)osError; + break; } return lock; } /// Unlock the RTOS Kernel scheduler. /// \note API identical to osKernelUnlock -static int32_t svcRtxKernelUnlock (void) { +static int32_t svcRtxKernelUnlock(void) { int32_t lock; switch (osRtxInfo.kernel.state) { - case osRtxKernelRunning: - EvrRtxKernelUnlocked(0); - lock = 0; - break; - case osRtxKernelLocked: - osRtxInfo.kernel.state = osRtxKernelRunning; - EvrRtxKernelUnlocked(1); - lock = 1; - break; - default: - EvrRtxKernelError((int32_t)osError); - lock = (int32_t)osError; - break; + case osRtxKernelRunning: + EvrRtxKernelUnlocked(0); + lock = 0; + break; + case osRtxKernelLocked: + osRtxInfo.kernel.state = osRtxKernelRunning; + EvrRtxKernelUnlocked(1); + lock = 1; + break; + default: + EvrRtxKernelError((int32_t)osError); + lock = (int32_t)osError; + break; } return lock; } /// Restore the RTOS Kernel scheduler lock state. /// \note API identical to osKernelRestoreLock -static int32_t svcRtxKernelRestoreLock (int32_t lock) { +static int32_t svcRtxKernelRestoreLock(int32_t lock) { int32_t lock_new; switch (osRtxInfo.kernel.state) { - case osRtxKernelRunning: - case osRtxKernelLocked: - switch (lock) { - case 0: - osRtxInfo.kernel.state = osRtxKernelRunning; - EvrRtxKernelLockRestored(0); - lock_new = 0; - break; - case 1: - osRtxInfo.kernel.state = osRtxKernelLocked; - EvrRtxKernelLockRestored(1); - lock_new = 1; - break; - default: - EvrRtxKernelError((int32_t)osError); - lock_new = (int32_t)osError; - break; - } + case osRtxKernelRunning: + case osRtxKernelLocked: + switch (lock) { + case 0: + osRtxInfo.kernel.state = osRtxKernelRunning; + EvrRtxKernelLockRestored(0); + lock_new = 0; + break; + case 1: + osRtxInfo.kernel.state = osRtxKernelLocked; + EvrRtxKernelLockRestored(1); + lock_new = 1; break; default: EvrRtxKernelError((int32_t)osError); lock_new = (int32_t)osError; break; + } + break; + default: + EvrRtxKernelError((int32_t)osError); + lock_new = (int32_t)osError; + break; } return lock_new; } /// Suspend the RTOS Kernel scheduler. /// \note API identical to osKernelSuspend -static uint32_t svcRtxKernelSuspend (void) { +static uint32_t svcRtxKernelSuspend(void) { const os_thread_t *thread; - const os_timer_t *timer; - uint32_t delay; + const os_timer_t *timer; + uint32_t delay; if (osRtxInfo.kernel.state != osRtxKernelRunning) { EvrRtxKernelError(osRtxErrorKernelNotRunning); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } @@ -392,27 +395,28 @@ static uint32_t svcRtxKernelSuspend (void) { /// Resume the RTOS Kernel scheduler. /// \note API identical to osKernelResume -static void svcRtxKernelResume (uint32_t sleep_ticks) { +static void svcRtxKernelResume(uint32_t sleep_ticks) { os_thread_t *thread; - os_timer_t *timer; - uint32_t delay; - uint32_t ticks; + os_timer_t *timer; + uint32_t delay; + uint32_t ticks; - uint32_t resume_ts; - uint32_t tick_interval; - uint32_t sysclk_remain; - uint32_t delta_clk; - uint32_t sleep_clk; + uint32_t resume_ts; + uint32_t tick_interval; + uint32_t sysclk_remain; + uint32_t delta_clk; + uint32_t sleep_clk; if (osRtxInfo.kernel.state != osRtxKernelSuspended) { EvrRtxKernelResumed(); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return; } tick_interval = OS_Tick_GetInterval(); resume_ts = hal_sys_timer_get(); - sleep_clk = (resume_ts - systick_lock_ts) * (OS_CLOCK_NOMINAL / CONFIG_SYSTICK_HZ_NOMINAL); + sleep_clk = (resume_ts - systick_lock_ts) * + (OS_CLOCK_NOMINAL / CONFIG_SYSTICK_HZ_NOMINAL); if (systick_lock_val == 0) { sleep_ticks = sleep_clk / tick_interval; sysclk_remain = sleep_clk % tick_interval; @@ -468,13 +472,14 @@ static void svcRtxKernelResume (uint32_t sleep_ticks) { osRtxThreadDispatch(NULL); if (sysclk_remain == tick_interval) { - sysclk_remain = 0; + sysclk_remain = 0; } if (sysclk_remain) { SysTick->LOAD = sysclk_remain; SysTick->VAL = 0; SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; - while (SysTick->VAL == 0); + while (SysTick->VAL == 0) + ; SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; SysTick->LOAD = tick_interval - 1; } else @@ -482,39 +487,38 @@ static void svcRtxKernelResume (uint32_t sleep_ticks) { #if defined(DEBUG_SLEEP) && (DEBUG_SLEEP >= 1) if (sleep_clk > 0) { - TRACE(7,"[%u/0x%X][%2u/%u] resume: suspend tick:%u, sleep_clk=%u ticks=%u", - TICKS_TO_MS(hal_sys_timer_get()), hal_sys_timer_get(), sysclk_remain, SysTick->VAL, systick_lock_val, - sleep_clk, sleep_ticks); + TRACE(7, "[%u/0x%X][%2u/%u] resume: suspend tick:%u, sleep_clk=%u ticks=%u", + TICKS_TO_MS(hal_sys_timer_get()), hal_sys_timer_get(), sysclk_remain, + SysTick->VAL, systick_lock_val, sleep_clk, sleep_ticks); } #endif KernelUnblock(); EvrRtxKernelResumed(); - } /// Get the RTOS kernel tick count. /// \note API identical to osKernelGetTickCount -static uint32_t svcRtxKernelGetTickCount (void) { +static uint32_t svcRtxKernelGetTickCount(void) { EvrRtxKernelGetTickCount(osRtxInfo.kernel.tick); return osRtxInfo.kernel.tick; } /// Get the RTOS kernel tick frequency. /// \note API identical to osKernelGetTickFreq -static uint32_t svcRtxKernelGetTickFreq (void) { +static uint32_t svcRtxKernelGetTickFreq(void) { EvrRtxKernelGetTickFreq(osRtxConfig.tick_freq); return osRtxConfig.tick_freq; } /// Get the RTOS kernel system timer count. /// \note API identical to osKernelGetSysTimerCount -static uint32_t svcRtxKernelGetSysTimerCount (void) { +static uint32_t svcRtxKernelGetSysTimerCount(void) { uint32_t tick; uint32_t count; - tick = (uint32_t)osRtxInfo.kernel.tick; + tick = (uint32_t)osRtxInfo.kernel.tick; count = OS_Tick_GetCount(); if (OS_Tick_GetOverflow() != 0U) { count = OS_Tick_GetCount(); @@ -527,44 +531,42 @@ static uint32_t svcRtxKernelGetSysTimerCount (void) { /// Get the RTOS kernel system timer frequency. /// \note API identical to osKernelGetSysTimerFreq -static uint32_t svcRtxKernelGetSysTimerFreq (void) { +static uint32_t svcRtxKernelGetSysTimerFreq(void) { uint32_t freq = OS_Tick_GetClock(); EvrRtxKernelGetSysTimerFreq(freq); return freq; } // Service Calls definitions -//lint ++flb "Library Begin" [MISRA Note 11] -SVC0_0 (KernelInitialize, osStatus_t) -SVC0_3 (KernelGetInfo, osStatus_t, osVersion_t *, char *, uint32_t) -SVC0_0 (KernelStart, osStatus_t) -SVC0_0 (KernelLock, int32_t) -SVC0_0 (KernelUnlock, int32_t) -SVC0_1 (KernelRestoreLock, int32_t, int32_t) -SVC0_0 (KernelSuspend, uint32_t) -SVC0_1N(KernelResume, void, uint32_t) -SVC0_0 (KernelGetState, osKernelState_t) -SVC0_0 (KernelGetTickCount, uint32_t) -SVC0_0 (KernelGetTickFreq, uint32_t) -SVC0_0 (KernelGetSysTimerCount, uint32_t) -SVC0_0 (KernelGetSysTimerFreq, uint32_t) -//lint --flb "Library End" - +// lint ++flb "Library Begin" [MISRA Note 11] +SVC0_0(KernelInitialize, osStatus_t) +SVC0_3(KernelGetInfo, osStatus_t, osVersion_t *, char *, uint32_t) +SVC0_0(KernelStart, osStatus_t) +SVC0_0(KernelLock, int32_t) +SVC0_0(KernelUnlock, int32_t) +SVC0_1(KernelRestoreLock, int32_t, int32_t) +SVC0_0(KernelSuspend, uint32_t) +SVC0_1N(KernelResume, void, uint32_t) +SVC0_0(KernelGetState, osKernelState_t) +SVC0_0(KernelGetTickCount, uint32_t) +SVC0_0(KernelGetTickFreq, uint32_t) +SVC0_0(KernelGetSysTimerCount, uint32_t) +SVC0_0(KernelGetSysTimerFreq, uint32_t) +// lint --flb "Library End" // ==== Library functions ==== /// RTOS Kernel Pre-Initialization Hook -//lint -esym(759,osRtxKernelPreInit) "Prototype in header" -//lint -esym(765,osRtxKernelPreInit) "Global scope (can be overridden)" -//lint -esym(522,osRtxKernelPreInit) "Can be overridden (do not lack side-effects)" -__WEAK void osRtxKernelPreInit (void) { -} - +// lint -esym(759,osRtxKernelPreInit) "Prototype in header" +// lint -esym(765,osRtxKernelPreInit) "Global scope (can be overridden)" +// lint -esym(522,osRtxKernelPreInit) "Can be overridden (do not lack +// side-effects)" +__WEAK void osRtxKernelPreInit(void) {} // ==== Public API ==== /// Initialize the RTOS Kernel. -osStatus_t osKernelInitialize (void) { +osStatus_t osKernelInitialize(void) { osStatus_t status; osRtxKernelPreInit(); @@ -579,32 +581,33 @@ osStatus_t osKernelInitialize (void) { } /// Get RTOS Kernel Information. -osStatus_t osKernelGetInfo (osVersion_t *version, char *id_buf, uint32_t id_size) { +osStatus_t osKernelGetInfo(osVersion_t *version, char *id_buf, + uint32_t id_size) { osStatus_t status; EvrRtxKernelGetInfo(version, id_buf, id_size); if (IsIrqMode() || IsIrqMasked() || IsPrivileged()) { status = svcRtxKernelGetInfo(version, id_buf, id_size); } else { - status = __svcKernelGetInfo(version, id_buf, id_size); + status = __svcKernelGetInfo(version, id_buf, id_size); } return status; } /// Get the current RTOS Kernel state. -osKernelState_t osKernelGetState (void) { +osKernelState_t osKernelGetState(void) { osKernelState_t state; if (IsIrqMode() || IsIrqMasked() || IsPrivileged()) { state = svcRtxKernelGetState(); } else { - state = __svcKernelGetState(); + state = __svcKernelGetState(); } return state; } /// Start the RTOS Kernel scheduler. -osStatus_t osKernelStart (void) { +osStatus_t osKernelStart(void) { osStatus_t status; EvrRtxKernelStart(); @@ -618,7 +621,7 @@ osStatus_t osKernelStart (void) { } /// Lock the RTOS Kernel scheduler. -int32_t osKernelLock (void) { +int32_t osKernelLock(void) { int32_t lock; EvrRtxKernelLock(); @@ -632,7 +635,7 @@ int32_t osKernelLock (void) { } /// Unlock the RTOS Kernel scheduler. -int32_t osKernelUnlock (void) { +int32_t osKernelUnlock(void) { int32_t lock; EvrRtxKernelUnlock(); @@ -646,7 +649,7 @@ int32_t osKernelUnlock (void) { } /// Restore the RTOS Kernel scheduler lock state. -int32_t osKernelRestoreLock (int32_t lock) { +int32_t osKernelRestoreLock(int32_t lock) { int32_t lock_new; EvrRtxKernelRestoreLock(lock); @@ -660,7 +663,7 @@ int32_t osKernelRestoreLock (int32_t lock) { } /// Suspend the RTOS Kernel scheduler. -uint32_t osKernelSuspend (void) { +uint32_t osKernelSuspend(void) { uint32_t ticks; EvrRtxKernelSuspend(); @@ -674,7 +677,7 @@ uint32_t osKernelSuspend (void) { } /// Resume the RTOS Kernel scheduler. -void osKernelResume (uint32_t sleep_ticks) { +void osKernelResume(uint32_t sleep_ticks) { EvrRtxKernelResume(sleep_ticks); if (IsIrqMode() || IsIrqMasked()) { @@ -685,49 +688,49 @@ void osKernelResume (uint32_t sleep_ticks) { } /// Get the RTOS kernel tick count. -uint32_t osKernelGetTickCount (void) { +uint32_t osKernelGetTickCount(void) { uint32_t count; if (IsIrqMode() || IsIrqMasked()) { count = svcRtxKernelGetTickCount(); } else { - count = __svcKernelGetTickCount(); + count = __svcKernelGetTickCount(); } return count; } /// Get the RTOS kernel tick frequency. -uint32_t osKernelGetTickFreq (void) { +uint32_t osKernelGetTickFreq(void) { uint32_t freq; if (IsIrqMode() || IsIrqMasked()) { freq = svcRtxKernelGetTickFreq(); } else { - freq = __svcKernelGetTickFreq(); + freq = __svcKernelGetTickFreq(); } return freq; } /// Get the RTOS kernel system timer count. -uint32_t osKernelGetSysTimerCount (void) { +uint32_t osKernelGetSysTimerCount(void) { uint32_t count; if (IsIrqMode() || IsIrqMasked()) { count = svcRtxKernelGetSysTimerCount(); } else { - count = __svcKernelGetSysTimerCount(); + count = __svcKernelGetSysTimerCount(); } return count; } /// Get the RTOS kernel system timer frequency. -uint32_t osKernelGetSysTimerFreq (void) { +uint32_t osKernelGetSysTimerFreq(void) { uint32_t freq; if (IsIrqMode() || IsIrqMasked()) { freq = svcRtxKernelGetSysTimerFreq(); } else { - freq = __svcKernelGetSysTimerFreq(); + freq = __svcKernelGetSysTimerFreq(); } return freq; } diff --git a/rtos/rtx5/rtx_lib.c b/rtos/rtx5/rtx_lib.c index 431b240..74210d2 100644 --- a/rtos/rtx5/rtx_lib.c +++ b/rtos/rtx5/rtx_lib.c @@ -27,13 +27,12 @@ #include "rtx_config.h" #include "rtx_os.h" -#ifdef RTE_Compiler_EventRecorder +#ifdef RTE_Compiler_EventRecorder #include "EventRecorder.h" #include "EventRecorderConf.h" #endif #include "rtx_evr.h" - // System Configuration // ==================== @@ -42,8 +41,8 @@ #if ((OS_DYNAMIC_MEM_SIZE % 8) != 0) #error "Invalid Dynamic Memory size!" #endif -static uint64_t os_mem[OS_DYNAMIC_MEM_SIZE/8] \ -__attribute__((section(".bss.os"))); +static uint64_t os_mem[OS_DYNAMIC_MEM_SIZE / 8] + __attribute__((section(".bss.os"))); #endif // Kernel Tick Frequency @@ -55,9 +54,8 @@ __attribute__((section(".bss.os"))); #if (OS_ISR_FIFO_QUEUE < 4) #error "Invalid ISR FIFO Queue size!" #endif -static void *os_isr_queue[OS_ISR_FIFO_QUEUE] \ -__attribute__((section(".bss.os"))); - +static void *os_isr_queue[OS_ISR_FIFO_QUEUE] + __attribute__((section(".bss.os"))); // Thread Configuration // ==================== @@ -70,7 +68,6 @@ __attribute__((section(".bss.os"))); #error "Invalid Idle Thread Stack size!" #endif - #if (OS_THREAD_OBJ_MEM != 0) #if (OS_THREAD_NUM == 0) @@ -82,73 +79,73 @@ __attribute__((section(".bss.os"))); #endif // Thread Control Blocks -static osRtxThread_t os_thread_cb[OS_THREAD_NUM] \ -__attribute__((section(".bss.os.thread.cb"))); +static osRtxThread_t os_thread_cb[OS_THREAD_NUM] + __attribute__((section(".bss.os.thread.cb"))); // Thread Default Stack #if (OS_THREAD_DEF_STACK_NUM != 0) -static uint64_t os_thread_def_stack[OS_THREAD_DEF_STACK_NUM*(OS_STACK_SIZE/8)] \ -__attribute__((section(".bss.os.thread.stack"))); +static uint64_t + os_thread_def_stack[OS_THREAD_DEF_STACK_NUM * (OS_STACK_SIZE / 8)] + __attribute__((section(".bss.os.thread.stack"))); #endif // Memory Pool for Thread Control Blocks -static osRtxMpInfo_t os_mpi_thread \ -__attribute__((section(".data.os.thread.mpi"))) = -{ (uint32_t)OS_THREAD_NUM, 0U, (uint32_t)osRtxThreadCbSize, &os_thread_cb[0], NULL, NULL }; +static osRtxMpInfo_t os_mpi_thread + __attribute__((section(".data.os.thread.mpi"))) = { + (uint32_t)OS_THREAD_NUM, 0U, (uint32_t)osRtxThreadCbSize, + &os_thread_cb[0], NULL, NULL}; // Memory Pool for Thread Default Stack #if (OS_THREAD_DEF_STACK_NUM != 0) -static osRtxMpInfo_t os_mpi_def_stack \ -__attribute__((section(".data.os.thread.mpi"))) = -{ (uint32_t)OS_THREAD_DEF_STACK_NUM, 0U, (uint32_t)OS_STACK_SIZE, &os_thread_def_stack[0], NULL, NULL }; +static osRtxMpInfo_t os_mpi_def_stack + __attribute__((section(".data.os.thread.mpi"))) = { + (uint32_t)OS_THREAD_DEF_STACK_NUM, 0U, (uint32_t)OS_STACK_SIZE, + &os_thread_def_stack[0], NULL, NULL}; #endif // Memory Pool for Thread Stack #if (OS_THREAD_USER_STACK_SIZE != 0) -static uint64_t os_thread_stack[2 + OS_THREAD_NUM + (OS_THREAD_USER_STACK_SIZE/8)] \ -__attribute__((section(".bss.os.thread.stack"))); +static uint64_t + os_thread_stack[2 + OS_THREAD_NUM + (OS_THREAD_USER_STACK_SIZE / 8)] + __attribute__((section(".bss.os.thread.stack"))); #endif -#endif // (OS_THREAD_OBJ_MEM != 0) - +#endif // (OS_THREAD_OBJ_MEM != 0) // Stack overrun checking #if (OS_STACK_CHECK == 0) // Override library function -extern void osRtxThreadStackCheck (void); - void osRtxThreadStackCheck (void) {} +extern void osRtxThreadStackCheck(void); +void osRtxThreadStackCheck(void) {} #endif - // Idle Thread Control Block -static osRtxThread_t os_idle_thread_cb \ -__attribute__((section(".bss.os.thread.cb"))); +static osRtxThread_t os_idle_thread_cb + __attribute__((section(".bss.os.thread.cb"))); // Idle Thread Stack -static uint64_t os_idle_thread_stack[OS_IDLE_THREAD_STACK_SIZE/8] \ -__attribute__((section(".bss.os.thread.stack"))); +static uint64_t os_idle_thread_stack[OS_IDLE_THREAD_STACK_SIZE / 8] + __attribute__((section(".bss.os.thread.stack"))); // Idle Thread Attributes static const osThreadAttr_t os_idle_thread_attr = { #if defined(OS_IDLE_THREAD_NAME) - OS_IDLE_THREAD_NAME, + OS_IDLE_THREAD_NAME, #else - NULL, + NULL, #endif - osThreadDetached, - &os_idle_thread_cb, - (uint32_t)sizeof(os_idle_thread_cb), - &os_idle_thread_stack[0], - (uint32_t)sizeof(os_idle_thread_stack), - osPriorityIdle, + osThreadDetached, + &os_idle_thread_cb, + (uint32_t)sizeof(os_idle_thread_cb), + &os_idle_thread_stack[0], + (uint32_t)sizeof(os_idle_thread_stack), + osPriorityIdle, #if defined(OS_IDLE_THREAD_TZ_MOD_ID) - (uint32_t)OS_IDLE_THREAD_TZ_MOD_ID, + (uint32_t)OS_IDLE_THREAD_TZ_MOD_ID, #else - 0U, + 0U, #endif - 0U -}; - + 0U}; // Timer Configuration // =================== @@ -160,78 +157,74 @@ static const osThreadAttr_t os_idle_thread_attr = { #endif // Timer Control Blocks -static osRtxTimer_t os_timer_cb[OS_TIMER_NUM] \ -__attribute__((section(".bss.os.timer.cb"))); +static osRtxTimer_t os_timer_cb[OS_TIMER_NUM] + __attribute__((section(".bss.os.timer.cb"))); // Memory Pool for Timer Control Blocks -static osRtxMpInfo_t os_mpi_timer \ -__attribute__((section(".data.os.timer.mpi"))) = -{ (uint32_t)OS_TIMER_NUM, 0U, (uint32_t)osRtxTimerCbSize, &os_timer_cb[0], NULL, NULL }; - -#endif // (OS_TIMER_OBJ_MEM != 0) +static osRtxMpInfo_t os_mpi_timer + __attribute__((section(".data.os.timer.mpi"))) = { + (uint32_t)OS_TIMER_NUM, 0U, (uint32_t)osRtxTimerCbSize, + &os_timer_cb[0], NULL, NULL}; +#endif // (OS_TIMER_OBJ_MEM != 0) #if ((OS_TIMER_THREAD_STACK_SIZE != 0) && (OS_TIMER_CB_QUEUE != 0)) -#if (((OS_TIMER_THREAD_STACK_SIZE % 8) != 0) || (OS_TIMER_THREAD_STACK_SIZE < 96)) +#if (((OS_TIMER_THREAD_STACK_SIZE % 8) != 0) || \ + (OS_TIMER_THREAD_STACK_SIZE < 96)) #error "Invalid Timer Thread Stack size!" #endif // Timer Thread Control Block -static osRtxThread_t os_timer_thread_cb \ -__attribute__((section(".bss.os.thread.cb"))); +static osRtxThread_t os_timer_thread_cb + __attribute__((section(".bss.os.thread.cb"))); // Timer Thread Stack -static uint64_t os_timer_thread_stack[OS_TIMER_THREAD_STACK_SIZE/8] \ -__attribute__((section(".bss.os.thread.stack"))); +static uint64_t os_timer_thread_stack[OS_TIMER_THREAD_STACK_SIZE / 8] + __attribute__((section(".bss.os.thread.stack"))); // Timer Thread Attributes static const osThreadAttr_t os_timer_thread_attr = { #if defined(OS_TIMER_THREAD_NAME) - OS_TIMER_THREAD_NAME, + OS_TIMER_THREAD_NAME, #else - NULL, + NULL, #endif - osThreadDetached, - &os_timer_thread_cb, - (uint32_t)sizeof(os_timer_thread_cb), - &os_timer_thread_stack[0], - (uint32_t)sizeof(os_timer_thread_stack), - //lint -e{9030} -e{9034} "cast from signed to enum" - (osPriority_t)OS_TIMER_THREAD_PRIO, + osThreadDetached, &os_timer_thread_cb, (uint32_t)sizeof(os_timer_thread_cb), + &os_timer_thread_stack[0], (uint32_t)sizeof(os_timer_thread_stack), + // lint -e{9030} -e{9034} "cast from signed to enum" + (osPriority_t)OS_TIMER_THREAD_PRIO, #if defined(OS_TIMER_THREAD_TZ_MOD_ID) - (uint32_t)OS_TIMER_THREAD_TZ_MOD_ID, + (uint32_t)OS_TIMER_THREAD_TZ_MOD_ID, #else - 0U, + 0U, #endif - 0U -}; + 0U}; // Timer Message Queue Control Block -static osRtxMessageQueue_t os_timer_mq_cb \ -__attribute__((section(".bss.os.msgqueue.cb"))); +static osRtxMessageQueue_t os_timer_mq_cb + __attribute__((section(".bss.os.msgqueue.cb"))); // Timer Message Queue Data -static uint32_t os_timer_mq_data[osRtxMessageQueueMemSize(OS_TIMER_CB_QUEUE,8)/4] \ -__attribute__((section(".bss.os.msgqueue.mem"))); +static uint32_t + os_timer_mq_data[osRtxMessageQueueMemSize(OS_TIMER_CB_QUEUE, 8) / 4] + __attribute__((section(".bss.os.msgqueue.mem"))); // Timer Message Queue Attributes static const osMessageQueueAttr_t os_timer_mq_attr = { - NULL, - 0U, - &os_timer_mq_cb, - (uint32_t)sizeof(os_timer_mq_cb), - &os_timer_mq_data[0], - (uint32_t)sizeof(os_timer_mq_data) -}; + NULL, + 0U, + &os_timer_mq_cb, + (uint32_t)sizeof(os_timer_mq_cb), + &os_timer_mq_data[0], + (uint32_t)sizeof(os_timer_mq_data)}; #else -extern void osRtxTimerThread (void *argument); - void osRtxTimerThread (void *argument) { (void)argument; } - -#endif // ((OS_TIMER_THREAD_STACK_SIZE != 0) && (OS_TIMER_CB_QUEUE != 0)) +extern void osRtxTimerThread(void *argument); +void osRtxTimerThread(void *argument) { (void)argument; } +#endif // ((OS_TIMER_THREAD_STACK_SIZE != 0) && (OS_TIMER_CB_QUEUE != 0)) // Event Flags Configuration // ========================= @@ -243,16 +236,19 @@ extern void osRtxTimerThread (void *argument); #endif // Event Flags Control Blocks -static osRtxEventFlags_t os_ef_cb[OS_EVFLAGS_NUM] \ -__attribute__((section(".bss.os.evflags.cb"))); +static osRtxEventFlags_t os_ef_cb[OS_EVFLAGS_NUM] + __attribute__((section(".bss.os.evflags.cb"))); // Memory Pool for Event Flags Control Blocks -static osRtxMpInfo_t os_mpi_ef \ -__attribute__((section(".data.os.evflags.mpi"))) = -{ (uint32_t)OS_EVFLAGS_NUM, 0U, (uint32_t)osRtxEventFlagsCbSize, &os_ef_cb[0], NULL, NULL }; - -#endif // (OS_EVFLAGS_OBJ_MEM != 0) +static osRtxMpInfo_t os_mpi_ef __attribute__(( + section(".data.os.evflags.mpi"))) = {(uint32_t)OS_EVFLAGS_NUM, + 0U, + (uint32_t)osRtxEventFlagsCbSize, + &os_ef_cb[0], + NULL, + NULL}; +#endif // (OS_EVFLAGS_OBJ_MEM != 0) // Mutex Configuration // =================== @@ -264,16 +260,16 @@ __attribute__((section(".data.os.evflags.mpi"))) = #endif // Mutex Control Blocks -static osRtxMutex_t os_mutex_cb[OS_MUTEX_NUM] \ -__attribute__((section(".bss.os.mutex.cb"))); +static osRtxMutex_t os_mutex_cb[OS_MUTEX_NUM] + __attribute__((section(".bss.os.mutex.cb"))); // Memory Pool for Mutex Control Blocks -static osRtxMpInfo_t os_mpi_mutex \ -__attribute__((section(".data.os.mutex.mpi"))) = -{ (uint32_t)OS_MUTEX_NUM, 0U, (uint32_t)osRtxMutexCbSize, &os_mutex_cb[0], NULL, NULL }; - -#endif // (OS_MUTEX_OBJ_MEM != 0) +static osRtxMpInfo_t os_mpi_mutex + __attribute__((section(".data.os.mutex.mpi"))) = { + (uint32_t)OS_MUTEX_NUM, 0U, (uint32_t)osRtxMutexCbSize, + &os_mutex_cb[0], NULL, NULL}; +#endif // (OS_MUTEX_OBJ_MEM != 0) // Semaphore Configuration // ======================= @@ -285,16 +281,16 @@ __attribute__((section(".data.os.mutex.mpi"))) = #endif // Semaphore Control Blocks -static osRtxSemaphore_t os_semaphore_cb[OS_SEMAPHORE_NUM] \ -__attribute__((section(".bss.os.semaphore.cb"))); +static osRtxSemaphore_t os_semaphore_cb[OS_SEMAPHORE_NUM] + __attribute__((section(".bss.os.semaphore.cb"))); // Memory Pool for Semaphore Control Blocks -static osRtxMpInfo_t os_mpi_semaphore \ -__attribute__((section(".data.os.semaphore.mpi"))) = -{ (uint32_t)OS_SEMAPHORE_NUM, 0U, (uint32_t)osRtxSemaphoreCbSize, &os_semaphore_cb[0], NULL, NULL }; - -#endif // (OS_SEMAPHORE_OBJ_MEM != 0) +static osRtxMpInfo_t os_mpi_semaphore + __attribute__((section(".data.os.semaphore.mpi"))) = { + (uint32_t)OS_SEMAPHORE_NUM, 0U, (uint32_t)osRtxSemaphoreCbSize, + &os_semaphore_cb[0], NULL, NULL}; +#endif // (OS_SEMAPHORE_OBJ_MEM != 0) // Memory Pool Configuration // ========================= @@ -306,25 +302,28 @@ __attribute__((section(".data.os.semaphore.mpi"))) = #endif // Memory Pool Control Blocks -static osRtxMemoryPool_t os_mp_cb[OS_MEMPOOL_NUM] \ -__attribute__((section(".bss.os.mempool.cb"))); +static osRtxMemoryPool_t os_mp_cb[OS_MEMPOOL_NUM] + __attribute__((section(".bss.os.mempool.cb"))); // Memory Pool for Memory Pool Control Blocks -static osRtxMpInfo_t os_mpi_mp \ -__attribute__((section(".data.os.mempool.mpi"))) = -{ (uint32_t)OS_MEMPOOL_NUM, 0U, (uint32_t)osRtxMemoryPoolCbSize, &os_mp_cb[0], NULL, NULL }; +static osRtxMpInfo_t os_mpi_mp __attribute__(( + section(".data.os.mempool.mpi"))) = {(uint32_t)OS_MEMPOOL_NUM, + 0U, + (uint32_t)osRtxMemoryPoolCbSize, + &os_mp_cb[0], + NULL, + NULL}; // Memory Pool for Memory Pool Data Storage #if (OS_MEMPOOL_DATA_SIZE != 0) #if ((OS_MEMPOOL_DATA_SIZE % 8) != 0) #error "Invalid Data Memory size for Memory Pools!" #endif -static uint64_t os_mp_data[2 + OS_MEMPOOL_NUM + (OS_MEMPOOL_DATA_SIZE/8)] \ -__attribute__((section(".bss.os.mempool.mem"))); +static uint64_t os_mp_data[2 + OS_MEMPOOL_NUM + (OS_MEMPOOL_DATA_SIZE / 8)] + __attribute__((section(".bss.os.mempool.mem"))); #endif -#endif // (OS_MEMPOOL_OBJ_MEM != 0) - +#endif // (OS_MEMPOOL_OBJ_MEM != 0) // Message Queue Configuration // =========================== @@ -336,25 +335,28 @@ __attribute__((section(".bss.os.mempool.mem"))); #endif // Message Queue Control Blocks -static osRtxMessageQueue_t os_mq_cb[OS_MSGQUEUE_NUM] \ -__attribute__((section(".bss.os.msgqueue.cb"))); +static osRtxMessageQueue_t os_mq_cb[OS_MSGQUEUE_NUM] + __attribute__((section(".bss.os.msgqueue.cb"))); // Memory Pool for Message Queue Control Blocks -static osRtxMpInfo_t os_mpi_mq \ -__attribute__((section(".data.os.msgqueue.mpi"))) = -{ (uint32_t)OS_MSGQUEUE_NUM, 0U, (uint32_t)osRtxMessageQueueCbSize, &os_mq_cb[0], NULL, NULL }; +static osRtxMpInfo_t os_mpi_mq __attribute__(( + section(".data.os.msgqueue.mpi"))) = {(uint32_t)OS_MSGQUEUE_NUM, + 0U, + (uint32_t)osRtxMessageQueueCbSize, + &os_mq_cb[0], + NULL, + NULL}; // Memory Pool for Message Queue Data Storage #if (OS_MSGQUEUE_DATA_SIZE != 0) #if ((OS_MSGQUEUE_DATA_SIZE % 8) != 0) #error "Invalid Data Memory size for Message Queues!" #endif -static uint64_t os_mq_data[2 + OS_MSGQUEUE_NUM + (OS_MSGQUEUE_DATA_SIZE/8)] \ -__attribute__((section(".bss.os.msgqueue.mem"))); +static uint64_t os_mq_data[2 + OS_MSGQUEUE_NUM + (OS_MSGQUEUE_DATA_SIZE / 8)] + __attribute__((section(".bss.os.msgqueue.mem"))); #endif -#endif // (OS_MSGQUEUE_OBJ_MEM != 0) - +#endif // (OS_MSGQUEUE_OBJ_MEM != 0) // Event Recorder Configuration // ============================ @@ -362,337 +364,354 @@ __attribute__((section(".bss.os.msgqueue.mem"))); #if (defined(OS_EVR_INIT) && (OS_EVR_INIT != 0)) // Initial Thread configuration covered also Thread Flags and Generic Wait -#if defined(OS_EVR_THREAD_FILTER) +#if defined(OS_EVR_THREAD_FILTER) #if !defined(OS_EVR_THFLAGS_FILTER) -#define OS_EVR_THFLAGS_FILTER OS_EVR_THREAD_FILTER +#define OS_EVR_THFLAGS_FILTER OS_EVR_THREAD_FILTER #endif #if !defined(OS_EVR_WAIT_FILTER) -#define OS_EVR_WAIT_FILTER OS_EVR_THREAD_FILTER +#define OS_EVR_WAIT_FILTER OS_EVR_THREAD_FILTER #endif #endif // Migrate initial filter configuration -#if defined(OS_EVR_MEMORY_FILTER) -#define OS_EVR_MEMORY_LEVEL (((OS_EVR_MEMORY_FILTER & 0x80U) != 0U) ? (OS_EVR_MEMORY_FILTER & 0x0FU) : 0U) +#if defined(OS_EVR_MEMORY_FILTER) +#define OS_EVR_MEMORY_LEVEL \ + (((OS_EVR_MEMORY_FILTER & 0x80U) != 0U) ? (OS_EVR_MEMORY_FILTER & 0x0FU) : 0U) #endif -#if defined(OS_EVR_KERNEL_FILTER) -#define OS_EVR_KERNEL_LEVEL (((OS_EVR_KERNEL_FILTER & 0x80U) != 0U) ? (OS_EVR_KERNEL_FILTER & 0x0FU) : 0U) +#if defined(OS_EVR_KERNEL_FILTER) +#define OS_EVR_KERNEL_LEVEL \ + (((OS_EVR_KERNEL_FILTER & 0x80U) != 0U) ? (OS_EVR_KERNEL_FILTER & 0x0FU) : 0U) #endif -#if defined(OS_EVR_THREAD_FILTER) -#define OS_EVR_THREAD_LEVEL (((OS_EVR_THREAD_FILTER & 0x80U) != 0U) ? (OS_EVR_THREAD_FILTER & 0x0FU) : 0U) +#if defined(OS_EVR_THREAD_FILTER) +#define OS_EVR_THREAD_LEVEL \ + (((OS_EVR_THREAD_FILTER & 0x80U) != 0U) ? (OS_EVR_THREAD_FILTER & 0x0FU) : 0U) #endif -#if defined(OS_EVR_WAIT_FILTER) -#define OS_EVR_WAIT_LEVEL (((OS_EVR_WAIT_FILTER & 0x80U) != 0U) ? (OS_EVR_WAIT_FILTER & 0x0FU) : 0U) +#if defined(OS_EVR_WAIT_FILTER) +#define OS_EVR_WAIT_LEVEL \ + (((OS_EVR_WAIT_FILTER & 0x80U) != 0U) ? (OS_EVR_WAIT_FILTER & 0x0FU) : 0U) #endif -#if defined(OS_EVR_THFLAGS_FILTER) -#define OS_EVR_THFLAGS_LEVEL (((OS_EVR_THFLAGS_FILTER & 0x80U) != 0U) ? (OS_EVR_THFLAGS_FILTER & 0x0FU) : 0U) +#if defined(OS_EVR_THFLAGS_FILTER) +#define OS_EVR_THFLAGS_LEVEL \ + (((OS_EVR_THFLAGS_FILTER & 0x80U) != 0U) ? (OS_EVR_THFLAGS_FILTER & 0x0FU) \ + : 0U) #endif -#if defined(OS_EVR_EVFLAGS_FILTER) -#define OS_EVR_EVFLAGS_LEVEL (((OS_EVR_EVFLAGS_FILTER & 0x80U) != 0U) ? (OS_EVR_EVFLAGS_FILTER & 0x0FU) : 0U) +#if defined(OS_EVR_EVFLAGS_FILTER) +#define OS_EVR_EVFLAGS_LEVEL \ + (((OS_EVR_EVFLAGS_FILTER & 0x80U) != 0U) ? (OS_EVR_EVFLAGS_FILTER & 0x0FU) \ + : 0U) #endif -#if defined(OS_EVR_TIMER_FILTER) -#define OS_EVR_TIMER_LEVEL (((OS_EVR_TIMER_FILTER & 0x80U) != 0U) ? (OS_EVR_TIMER_FILTER & 0x0FU) : 0U) +#if defined(OS_EVR_TIMER_FILTER) +#define OS_EVR_TIMER_LEVEL \ + (((OS_EVR_TIMER_FILTER & 0x80U) != 0U) ? (OS_EVR_TIMER_FILTER & 0x0FU) : 0U) #endif -#if defined(OS_EVR_MUTEX_FILTER) -#define OS_EVR_MUTEX_LEVEL (((OS_EVR_MUTEX_FILTER & 0x80U) != 0U) ? (OS_EVR_MUTEX_FILTER & 0x0FU) : 0U) +#if defined(OS_EVR_MUTEX_FILTER) +#define OS_EVR_MUTEX_LEVEL \ + (((OS_EVR_MUTEX_FILTER & 0x80U) != 0U) ? (OS_EVR_MUTEX_FILTER & 0x0FU) : 0U) #endif -#if defined(OS_EVR_SEMAPHORE_FILTER) -#define OS_EVR_SEMAPHORE_LEVEL (((OS_EVR_SEMAPHORE_FILTER & 0x80U) != 0U) ? (OS_EVR_SEMAPHORE_FILTER & 0x0FU) : 0U) +#if defined(OS_EVR_SEMAPHORE_FILTER) +#define OS_EVR_SEMAPHORE_LEVEL \ + (((OS_EVR_SEMAPHORE_FILTER & 0x80U) != 0U) \ + ? (OS_EVR_SEMAPHORE_FILTER & 0x0FU) \ + : 0U) #endif -#if defined(OS_EVR_MEMPOOL_FILTER) -#define OS_EVR_MEMPOOL_LEVEL (((OS_EVR_MEMPOOL_FILTER & 0x80U) != 0U) ? (OS_EVR_MEMPOOL_FILTER & 0x0FU) : 0U) +#if defined(OS_EVR_MEMPOOL_FILTER) +#define OS_EVR_MEMPOOL_LEVEL \ + (((OS_EVR_MEMPOOL_FILTER & 0x80U) != 0U) ? (OS_EVR_MEMPOOL_FILTER & 0x0FU) \ + : 0U) #endif -#if defined(OS_EVR_MSGQUEUE_FILTER) -#define OS_EVR_MSGQUEUE_LEVEL (((OS_EVR_MSGQUEUE_FILTER & 0x80U) != 0U) ? (OS_EVR_MSGQUEUE_FILTER & 0x0FU) : 0U) +#if defined(OS_EVR_MSGQUEUE_FILTER) +#define OS_EVR_MSGQUEUE_LEVEL \ + (((OS_EVR_MSGQUEUE_FILTER & 0x80U) != 0U) ? (OS_EVR_MSGQUEUE_FILTER & 0x0FU) \ + : 0U) #endif -#if defined(RTE_Compiler_EventRecorder) +#if defined(RTE_Compiler_EventRecorder) // Event Recorder Initialize -__STATIC_INLINE void evr_initialize (void) { +__STATIC_INLINE void evr_initialize(void) { (void)EventRecorderInitialize(OS_EVR_LEVEL, (uint32_t)OS_EVR_START); - (void)EventRecorderEnable(OS_EVR_MEMORY_LEVEL, EvtRtxMemoryNo, EvtRtxMemoryNo); - (void)EventRecorderEnable(OS_EVR_KERNEL_LEVEL, EvtRtxKernelNo, EvtRtxKernelNo); - (void)EventRecorderEnable(OS_EVR_THREAD_LEVEL, EvtRtxThreadNo, EvtRtxThreadNo); - (void)EventRecorderEnable(OS_EVR_WAIT_LEVEL, EvtRtxWaitNo, EvtRtxWaitNo); - (void)EventRecorderEnable(OS_EVR_THFLAGS_LEVEL, EvtRtxThreadFlagsNo, EvtRtxThreadFlagsNo); - (void)EventRecorderEnable(OS_EVR_EVFLAGS_LEVEL, EvtRtxEventFlagsNo, EvtRtxEventFlagsNo); - (void)EventRecorderEnable(OS_EVR_TIMER_LEVEL, EvtRtxTimerNo, EvtRtxTimerNo); - (void)EventRecorderEnable(OS_EVR_MUTEX_LEVEL, EvtRtxMutexNo, EvtRtxMutexNo); - (void)EventRecorderEnable(OS_EVR_SEMAPHORE_LEVEL, EvtRtxSemaphoreNo, EvtRtxSemaphoreNo); - (void)EventRecorderEnable(OS_EVR_MEMPOOL_LEVEL, EvtRtxMemoryPoolNo, EvtRtxMemoryPoolNo); - (void)EventRecorderEnable(OS_EVR_MSGQUEUE_LEVEL, EvtRtxMessageQueueNo, EvtRtxMessageQueueNo); + (void)EventRecorderEnable(OS_EVR_MEMORY_LEVEL, EvtRtxMemoryNo, + EvtRtxMemoryNo); + (void)EventRecorderEnable(OS_EVR_KERNEL_LEVEL, EvtRtxKernelNo, + EvtRtxKernelNo); + (void)EventRecorderEnable(OS_EVR_THREAD_LEVEL, EvtRtxThreadNo, + EvtRtxThreadNo); + (void)EventRecorderEnable(OS_EVR_WAIT_LEVEL, EvtRtxWaitNo, EvtRtxWaitNo); + (void)EventRecorderEnable(OS_EVR_THFLAGS_LEVEL, EvtRtxThreadFlagsNo, + EvtRtxThreadFlagsNo); + (void)EventRecorderEnable(OS_EVR_EVFLAGS_LEVEL, EvtRtxEventFlagsNo, + EvtRtxEventFlagsNo); + (void)EventRecorderEnable(OS_EVR_TIMER_LEVEL, EvtRtxTimerNo, EvtRtxTimerNo); + (void)EventRecorderEnable(OS_EVR_MUTEX_LEVEL, EvtRtxMutexNo, EvtRtxMutexNo); + (void)EventRecorderEnable(OS_EVR_SEMAPHORE_LEVEL, EvtRtxSemaphoreNo, + EvtRtxSemaphoreNo); + (void)EventRecorderEnable(OS_EVR_MEMPOOL_LEVEL, EvtRtxMemoryPoolNo, + EvtRtxMemoryPoolNo); + (void)EventRecorderEnable(OS_EVR_MSGQUEUE_LEVEL, EvtRtxMessageQueueNo, + EvtRtxMessageQueueNo); } #else -#warning "Event Recorder cannot be initialized (Event Recorder component is not selected)!" +#warning \ + "Event Recorder cannot be initialized (Event Recorder component is not selected)!" #define evr_initialize() #endif -#endif // (OS_EVR_INIT != 0) - +#endif // (OS_EVR_INIT != 0) // OS Configuration // ================ - -const osRtxConfig_t osRtxConfig \ -__USED \ -__attribute__((section(".rodata"))) = -{ - //lint -e{835} "Zero argument to operator" - 0U // Flags +const osRtxConfig_t osRtxConfig __USED __attribute__((section(".rodata"))) = { + // lint -e{835} "Zero argument to operator" + 0U // Flags #if (OS_PRIVILEGE_MODE != 0) - | osRtxConfigPrivilegedMode + | osRtxConfigPrivilegedMode #endif #if (OS_STACK_CHECK != 0) - | osRtxConfigStackCheck + | osRtxConfigStackCheck #endif #if (OS_STACK_WATERMARK != 0) - | osRtxConfigStackWatermark + | osRtxConfigStackWatermark #endif - , - (uint32_t)OS_TICK_FREQ, + , + (uint32_t)OS_TICK_FREQ, #if (OS_ROBIN_ENABLE != 0) - (uint32_t)OS_ROBIN_TIMEOUT, + (uint32_t)OS_ROBIN_TIMEOUT, #else - 0U, + 0U, #endif - { &os_isr_queue[0], (uint16_t)(sizeof(os_isr_queue)/sizeof(void *)), 0U }, - { - // Memory Pools (Variable Block Size) + {&os_isr_queue[0], (uint16_t)(sizeof(os_isr_queue) / sizeof(void *)), 0U}, + { +// Memory Pools (Variable Block Size) #if ((OS_THREAD_OBJ_MEM != 0) && (OS_THREAD_USER_STACK_SIZE != 0)) - &os_thread_stack[0], sizeof(os_thread_stack), + &os_thread_stack[0], + sizeof(os_thread_stack), #else - NULL, 0U, + NULL, 0U, #endif #if ((OS_MEMPOOL_OBJ_MEM != 0) && (OS_MEMPOOL_DATA_SIZE != 0)) - &os_mp_data[0], sizeof(os_mp_data), + &os_mp_data[0], + sizeof(os_mp_data), #else - NULL, 0U, + NULL, 0U, #endif #if ((OS_MSGQUEUE_OBJ_MEM != 0) && (OS_MSGQUEUE_DATA_SIZE != 0)) - &os_mq_data[0], sizeof(os_mq_data), + &os_mq_data[0], + sizeof(os_mq_data), #else - NULL, 0U, + NULL, 0U, #endif #if (OS_DYNAMIC_MEM_SIZE != 0) - &os_mem[0], (uint32_t)OS_DYNAMIC_MEM_SIZE, + &os_mem[0], + (uint32_t)OS_DYNAMIC_MEM_SIZE, #else - NULL, 0U + NULL, 0U #endif - }, - { - // Memory Pools (Fixed Block Size) + }, + { +// Memory Pools (Fixed Block Size) #if (OS_THREAD_OBJ_MEM != 0) #if (OS_THREAD_DEF_STACK_NUM != 0) - &os_mpi_def_stack, + &os_mpi_def_stack, #else - NULL, + NULL, #endif - &os_mpi_thread, + &os_mpi_thread, #else - NULL, - NULL, + NULL, + NULL, #endif #if (OS_TIMER_OBJ_MEM != 0) - &os_mpi_timer, + &os_mpi_timer, #else - NULL, + NULL, #endif #if (OS_EVFLAGS_OBJ_MEM != 0) - &os_mpi_ef, + &os_mpi_ef, #else - NULL, + NULL, #endif #if (OS_MUTEX_OBJ_MEM != 0) - &os_mpi_mutex, + &os_mpi_mutex, #else - NULL, + NULL, #endif #if (OS_SEMAPHORE_OBJ_MEM != 0) - &os_mpi_semaphore, + &os_mpi_semaphore, #else - NULL, + NULL, #endif #if (OS_MEMPOOL_OBJ_MEM != 0) - &os_mpi_mp, + &os_mpi_mp, #else - NULL, + NULL, #endif #if (OS_MSGQUEUE_OBJ_MEM != 0) - &os_mpi_mq, + &os_mpi_mq, +#else + NULL, +#endif + }, + (uint32_t)OS_STACK_SIZE, + &os_idle_thread_attr, +#if ((OS_TIMER_THREAD_STACK_SIZE != 0) && (OS_TIMER_CB_QUEUE != 0)) + &os_timer_thread_attr, + &os_timer_mq_attr, + (uint32_t)OS_TIMER_CB_QUEUE #else NULL, -#endif - }, - (uint32_t)OS_STACK_SIZE, - &os_idle_thread_attr, -#if ((OS_TIMER_THREAD_STACK_SIZE != 0) && (OS_TIMER_CB_QUEUE != 0)) - &os_timer_thread_attr, - &os_timer_mq_attr, - (uint32_t)OS_TIMER_CB_QUEUE -#else - NULL, - NULL, - 0U + NULL, + 0U #endif }; - // Non weak reference to library irq module -//lint -esym(526,irqRtxLib) "Defined by Exception handlers" -//lint -esym(714,irqRtxLibRef) "Non weak reference" -//lint -esym(765,irqRtxLibRef) "Global scope" -extern uint8_t irqRtxLib; +// lint -esym(526,irqRtxLib) "Defined by Exception handlers" +// lint -esym(714,irqRtxLibRef) "Non weak reference" +// lint -esym(765,irqRtxLibRef) "Global scope" +extern uint8_t irqRtxLib; extern const uint8_t *irqRtxLibRef; - const uint8_t *irqRtxLibRef = &irqRtxLib; +const uint8_t *irqRtxLibRef = &irqRtxLib; // Default User SVC Table -//lint -esym(714,osRtxUserSVC) "Referenced by Exception handlers" -//lint -esym(765,osRtxUserSVC) "Global scope" -//lint -e{9067} "extern array declared without size" -extern void * const osRtxUserSVC[]; -__WEAK void * const osRtxUserSVC[1] = { (void *)0 }; - +// lint -esym(714,osRtxUserSVC) "Referenced by Exception handlers" +// lint -esym(765,osRtxUserSVC) "Global scope" +// lint -e{9067} "extern array declared without size" +extern void *const osRtxUserSVC[]; +__WEAK void *const osRtxUserSVC[1] = {(void *)0}; // OS Sections // =========== -#if defined(__CC_ARM) || \ +#if defined(__CC_ARM) || \ (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) -static uint32_t __os_thread_cb_start__ __attribute__((weakref(".bss.os.thread.cb$$Base"))); //lint -esym(728,__os_thread_cb_start__) -static uint32_t __os_thread_cb_end__ __attribute__((weakref(".bss.os.thread.cb$$Limit"))); //lint -esym(728,__os_thread_cb_end__) -static uint32_t __os_timer_cb_start__ __attribute__((weakref(".bss.os.timer.cb$$Base"))); //lint -esym(728,__os_timer_cb_start__) -static uint32_t __os_timer_cb_end__ __attribute__((weakref(".bss.os.timer.cb$$Limit"))); //lint -esym(728,__os_timer_cb_end__) -static uint32_t __os_evflags_cb_start__ __attribute__((weakref(".bss.os.evflags.cb$$Base"))); //lint -esym(728,__os_evflags_cb_start__) -static uint32_t __os_evflags_cb_end__ __attribute__((weakref(".bss.os.evflags.cb$$Limit"))); //lint -esym(728,__os_evflags_cb_end__) -static uint32_t __os_mutex_cb_start__ __attribute__((weakref(".bss.os.mutex.cb$$Base"))); //lint -esym(728,__os_mutex_cb_start__) -static uint32_t __os_mutex_cb_end__ __attribute__((weakref(".bss.os.mutex.cb$$Limit"))); //lint -esym(728,__os_mutex_cb_end__) -static uint32_t __os_semaphore_cb_start__ __attribute__((weakref(".bss.os.semaphore.cb$$Base"))); //lint -esym(728,__os_semaphore_cb_start__) -static uint32_t __os_semaphore_cb_end__ __attribute__((weakref(".bss.os.semaphore.cb$$Limit"))); //lint -esym(728,__os_semaphore_cb_end__) -static uint32_t __os_mempool_cb_start__ __attribute__((weakref(".bss.os.mempool.cb$$Base"))); //lint -esym(728,__os_mempool_cb_start__) -static uint32_t __os_mempool_cb_end__ __attribute__((weakref(".bss.os.mempool.cb$$Limit"))); //lint -esym(728,__os_mempool_cb_end__) -static uint32_t __os_msgqueue_cb_start__ __attribute__((weakref(".bss.os.msgqueue.cb$$Base"))); //lint -esym(728,__os_msgqueue_cb_start__) -static uint32_t __os_msgqueue_cb_end__ __attribute__((weakref(".bss.os.msgqueue.cb$$Limit"))); //lint -esym(728,__os_msgqueue_cb_end__) +static uint32_t __os_thread_cb_start__ __attribute__((weakref( + ".bss.os.thread.cb$$Base"))); // lint -esym(728,__os_thread_cb_start__) +static uint32_t __os_thread_cb_end__ __attribute__((weakref( + ".bss.os.thread.cb$$Limit"))); // lint -esym(728,__os_thread_cb_end__) +static uint32_t __os_timer_cb_start__ __attribute__((weakref( + ".bss.os.timer.cb$$Base"))); // lint -esym(728,__os_timer_cb_start__) +static uint32_t __os_timer_cb_end__ __attribute__(( + weakref(".bss.os.timer.cb$$Limit"))); // lint -esym(728,__os_timer_cb_end__) +static uint32_t __os_evflags_cb_start__ __attribute__((weakref( + ".bss.os.evflags.cb$$Base"))); // lint -esym(728,__os_evflags_cb_start__) +static uint32_t __os_evflags_cb_end__ __attribute__((weakref( + ".bss.os.evflags.cb$$Limit"))); // lint -esym(728,__os_evflags_cb_end__) +static uint32_t __os_mutex_cb_start__ __attribute__((weakref( + ".bss.os.mutex.cb$$Base"))); // lint -esym(728,__os_mutex_cb_start__) +static uint32_t __os_mutex_cb_end__ __attribute__(( + weakref(".bss.os.mutex.cb$$Limit"))); // lint -esym(728,__os_mutex_cb_end__) +static uint32_t __os_semaphore_cb_start__ __attribute__((weakref( + ".bss.os.semaphore.cb$$Base"))); // lint + // -esym(728,__os_semaphore_cb_start__) +static uint32_t __os_semaphore_cb_end__ __attribute__((weakref( + ".bss.os.semaphore.cb$$Limit"))); // lint -esym(728,__os_semaphore_cb_end__) +static uint32_t __os_mempool_cb_start__ __attribute__((weakref( + ".bss.os.mempool.cb$$Base"))); // lint -esym(728,__os_mempool_cb_start__) +static uint32_t __os_mempool_cb_end__ __attribute__((weakref( + ".bss.os.mempool.cb$$Limit"))); // lint -esym(728,__os_mempool_cb_end__) +static uint32_t __os_msgqueue_cb_start__ __attribute__((weakref( + ".bss.os.msgqueue.cb$$Base"))); // lint -esym(728,__os_msgqueue_cb_start__) +static uint32_t __os_msgqueue_cb_end__ __attribute__((weakref( + ".bss.os.msgqueue.cb$$Limit"))); // lint -esym(728,__os_msgqueue_cb_end__) #else -extern uint32_t __os_thread_cb_start__ __attribute__((weak)); -extern uint32_t __os_thread_cb_end__ __attribute__((weak)); -extern uint32_t __os_timer_cb_start__ __attribute__((weak)); -extern uint32_t __os_timer_cb_end__ __attribute__((weak)); -extern uint32_t __os_evflags_cb_start__ __attribute__((weak)); -extern uint32_t __os_evflags_cb_end__ __attribute__((weak)); -extern uint32_t __os_mutex_cb_start__ __attribute__((weak)); -extern uint32_t __os_mutex_cb_end__ __attribute__((weak)); +extern uint32_t __os_thread_cb_start__ __attribute__((weak)); +extern uint32_t __os_thread_cb_end__ __attribute__((weak)); +extern uint32_t __os_timer_cb_start__ __attribute__((weak)); +extern uint32_t __os_timer_cb_end__ __attribute__((weak)); +extern uint32_t __os_evflags_cb_start__ __attribute__((weak)); +extern uint32_t __os_evflags_cb_end__ __attribute__((weak)); +extern uint32_t __os_mutex_cb_start__ __attribute__((weak)); +extern uint32_t __os_mutex_cb_end__ __attribute__((weak)); extern uint32_t __os_semaphore_cb_start__ __attribute__((weak)); -extern uint32_t __os_semaphore_cb_end__ __attribute__((weak)); -extern uint32_t __os_mempool_cb_start__ __attribute__((weak)); -extern uint32_t __os_mempool_cb_end__ __attribute__((weak)); -extern uint32_t __os_msgqueue_cb_start__ __attribute__((weak)); -extern uint32_t __os_msgqueue_cb_end__ __attribute__((weak)); +extern uint32_t __os_semaphore_cb_end__ __attribute__((weak)); +extern uint32_t __os_mempool_cb_start__ __attribute__((weak)); +extern uint32_t __os_mempool_cb_end__ __attribute__((weak)); +extern uint32_t __os_msgqueue_cb_start__ __attribute__((weak)); +extern uint32_t __os_msgqueue_cb_end__ __attribute__((weak)); #endif -//lint -e{9067} "extern array declared without size" -extern const uint32_t * const os_cb_sections[]; - -//lint -esym(714,os_cb_sections) "Referenced by debugger" -//lint -esym(765,os_cb_sections) "Global scope" -const uint32_t * const os_cb_sections[] \ -__USED \ -__attribute__((section(".rodata"))) = -{ - &__os_thread_cb_start__, - &__os_thread_cb_end__, - &__os_timer_cb_start__, - &__os_timer_cb_end__, - &__os_evflags_cb_start__, - &__os_evflags_cb_end__, - &__os_mutex_cb_start__, - &__os_mutex_cb_end__, - &__os_semaphore_cb_start__, - &__os_semaphore_cb_end__, - &__os_mempool_cb_start__, - &__os_mempool_cb_end__, - &__os_msgqueue_cb_start__, - &__os_msgqueue_cb_end__ -}; +// lint -e{9067} "extern array declared without size" +extern const uint32_t *const os_cb_sections[]; +// lint -esym(714,os_cb_sections) "Referenced by debugger" +// lint -esym(765,os_cb_sections) "Global scope" +const uint32_t *const os_cb_sections[] __USED + __attribute__((section(".rodata"))) = { + &__os_thread_cb_start__, &__os_thread_cb_end__, + &__os_timer_cb_start__, &__os_timer_cb_end__, + &__os_evflags_cb_start__, &__os_evflags_cb_end__, + &__os_mutex_cb_start__, &__os_mutex_cb_end__, + &__os_semaphore_cb_start__, &__os_semaphore_cb_end__, + &__os_mempool_cb_start__, &__os_mempool_cb_end__, + &__os_msgqueue_cb_start__, &__os_msgqueue_cb_end__}; // OS Initialization // ================= -#if defined(__CC_ARM) || \ +#if defined(__CC_ARM) || \ (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) #ifndef __MICROLIB -//lint -esym(714,_platform_post_stackheap_init) "Referenced by C library" -//lint -esym(765,_platform_post_stackheap_init) "Global scope" -extern void _platform_post_stackheap_init (void); -__WEAK void _platform_post_stackheap_init (void) { - (void)osKernelInitialize(); -} +// lint -esym(714,_platform_post_stackheap_init) "Referenced by C library" +// lint -esym(765,_platform_post_stackheap_init) "Global scope" +extern void _platform_post_stackheap_init(void); +__WEAK void _platform_post_stackheap_init(void) { (void)osKernelInitialize(); } #endif #elif defined(__GNUC__) -osThreadAttr_t os_thread_attr_main = { - "main", - osThreadDetached, - NULL, - 0, - NULL, - 0, - osPriorityNormal, - 0, - 0 -}; +osThreadAttr_t os_thread_attr_main = {"main", osThreadDetached, NULL, 0, NULL, + 0, osPriorityNormal, 0, 0}; #ifndef OS_SCHEDULERSTKSIZE -#define OS_SCHEDULERSTKSIZE 512 +#define OS_SCHEDULERSTKSIZE 512 #endif -extern uint32_t __StackTop[]; -#define INITIAL_SP ((uint32_t)__StackTop) +extern uint32_t __StackTop[]; +#define INITIAL_SP ((uint32_t)__StackTop) -extern uint32_t __StackLimit[]; -#define MAIN_STACK_BUF (__StackLimit) +extern uint32_t __StackLimit[]; +#define MAIN_STACK_BUF (__StackLimit) -#define ROUND_UP(x, align) (((uint32_t)(x) + (align - 1)) & ~(align - 1)) +#define ROUND_UP(x, align) (((uint32_t)(x) + (align - 1)) & ~(align - 1)) #define ROUND_DOWN(x, align) ((uint32_t)(x) & ~(align - 1)) void set_main_stack(void) { - // That is the bottom of the main stack block: no collision detection - os_thread_attr_main.stack_mem = (uint32_t *)ROUND_UP(MAIN_STACK_BUF, 8); + // That is the bottom of the main stack block: no collision detection + os_thread_attr_main.stack_mem = (uint32_t *)ROUND_UP(MAIN_STACK_BUF, 8); - // Leave OS_SCHEDULERSTKSIZE words for the scheduler and interrupts - os_thread_attr_main.stack_size = ROUND_DOWN((INITIAL_SP - (unsigned int)ROUND_UP(MAIN_STACK_BUF, 8)) - (OS_SCHEDULERSTKSIZE * 4), 8); + // Leave OS_SCHEDULERSTKSIZE words for the scheduler and interrupts + os_thread_attr_main.stack_size = + ROUND_DOWN((INITIAL_SP - (unsigned int)ROUND_UP(MAIN_STACK_BUF, 8)) - + (OS_SCHEDULERSTKSIZE * 4), + 8); } -extern void software_init_hook (void); -__WEAK void software_init_hook (void) { - __asm ( - ".syntax unified\n" - ".thumb\n" - "movs r0,#0\n" - "movs r1,#0\n" - "mov r4,r0\n" - "mov r5,r1\n" - "bl SystemCoreClockUpdate\n" - "bl osKernelInitialize\n" - "ldr r0,= __libc_fini_array\n" - "bl atexit\n" - "bl __libc_init_array\n" - "mov r0,r4\n" - "mov r1,r5\n" - "bl set_main_stack\n" - "ldr r0,=main\n" - "movs r1,#0\n" - "ldr r2,=os_thread_attr_main\n" - "bl osThreadNew\n" - "bl osKernelStart\n" - "bl exit\n" - ); +extern void software_init_hook(void); +__WEAK void software_init_hook(void) { + __asm(".syntax unified\n" + ".thumb\n" + "movs r0,#0\n" + "movs r1,#0\n" + "mov r4,r0\n" + "mov r5,r1\n" + "bl SystemCoreClockUpdate\n" + "bl osKernelInitialize\n" + "ldr r0,= __libc_fini_array\n" + "bl atexit\n" + "bl __libc_init_array\n" + "mov r0,r4\n" + "mov r1,r5\n" + "bl set_main_stack\n" + "ldr r0,=main\n" + "movs r1,#0\n" + "ldr r2,=os_thread_attr_main\n" + "bl osThreadNew\n" + "bl osKernelStart\n" + "bl exit\n"); } #endif @@ -701,39 +720,39 @@ __WEAK void software_init_hook (void) { // RTOS Kernel Pre-Initialization Hook #if (defined(OS_EVR_INIT) && (OS_EVR_INIT != 0)) -void osRtxKernelPreInit (void); -void osRtxKernelPreInit (void) { +void osRtxKernelPreInit(void); +void osRtxKernelPreInit(void) { if (osKernelGetState() == osKernelInactive) { evr_initialize(); } } #endif - // C/C++ Standard Library Multithreading Interface // =============================================== -#if ( !defined(RTX_NO_MULTITHREAD_CLIB) && \ - ( defined(__CC_ARM) || \ - (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))) && \ - !defined(__MICROLIB)) +#if (!defined(RTX_NO_MULTITHREAD_CLIB) && \ + (defined(__CC_ARM) || \ + (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))) && \ + !defined(__MICROLIB)) #define LIBSPACE_SIZE 96 -//lint -esym(714,__user_perthread_libspace,_mutex_*) "Referenced by C library" -//lint -esym(765,__user_perthread_libspace,_mutex_*) "Global scope" -//lint -esym(9003, os_libspace*) "variables 'os_libspace*' defined at module scope" +// lint -esym(714,__user_perthread_libspace,_mutex_*) "Referenced by C library" +// lint -esym(765,__user_perthread_libspace,_mutex_*) "Global scope" +// lint -esym(9003, os_libspace*) "variables 'os_libspace*' defined at module +// scope" // Memory for libspace -static uint32_t os_libspace[OS_THREAD_LIBSPACE_NUM+1][LIBSPACE_SIZE/4] \ -__attribute__((section(".bss.os.libspace"))); +static uint32_t os_libspace[OS_THREAD_LIBSPACE_NUM + 1][LIBSPACE_SIZE / 4] + __attribute__((section(".bss.os.libspace"))); // Thread IDs for libspace -static osThreadId_t os_libspace_id[OS_THREAD_LIBSPACE_NUM] \ -__attribute__((section(".bss.os.libspace"))); +static osThreadId_t os_libspace_id[OS_THREAD_LIBSPACE_NUM] + __attribute__((section(".bss.os.libspace"))); // Check if Kernel has been started -static uint32_t os_kernel_is_active (void) { +static uint32_t os_kernel_is_active(void) { static uint8_t os_kernel_active = 0U; if (os_kernel_active == 0U) { @@ -745,10 +764,10 @@ static uint32_t os_kernel_is_active (void) { } // Provide libspace for current thread -void *__user_perthread_libspace (void); -void *__user_perthread_libspace (void) { +void *__user_perthread_libspace(void); +void *__user_perthread_libspace(void) { osThreadId_t id; - uint32_t n; + uint32_t n; if (os_kernel_is_active() != 0U) { id = osThreadGetId(); @@ -767,16 +786,16 @@ void *__user_perthread_libspace (void) { n = OS_THREAD_LIBSPACE_NUM; } - //lint -e{9087} "cast between pointers to different object types" + // lint -e{9087} "cast between pointers to different object types" return (void *)&os_libspace[n][0]; } // Mutex identifier typedef void *mutex; -//lint -save "Function prototypes defined in C library" -//lint -e970 "Use of 'int' outside of a typedef" -//lint -e818 "Pointer 'm' could be declared as pointing to const" +// lint -save "Function prototypes defined in C library" +// lint -e970 "Use of 'int' outside of a typedef" +// lint -e818 "Pointer 'm' could be declared as pointing to const" // Initialize mutex __USED @@ -815,10 +834,8 @@ void _mutex_release(mutex *m) { // Free mutex __USED void _mutex_free(mutex *m); -void _mutex_free(mutex *m) { - (void)osMutexDelete(*m); -} +void _mutex_free(mutex *m) { (void)osMutexDelete(*m); } -//lint -restore +// lint -restore #endif diff --git a/rtos/rtx5/rtx_memory.c b/rtos/rtx5/rtx_memory.c index b22bfda..4d2f786 100644 --- a/rtos/rtx5/rtx_memory.c +++ b/rtos/rtx5/rtx_memory.c @@ -25,58 +25,58 @@ #include "rtx_lib.h" - // Memory Pool Header structure typedef struct { - uint32_t size; // Memory Pool size - uint32_t used; // Used Memory + uint32_t size; // Memory Pool size + uint32_t used; // Used Memory } mem_head_t; // Memory Block Header structure typedef struct mem_block_s { - struct mem_block_s *next; // Next Memory Block in list - uint32_t info; // Block Info or max used Memory (in last block) + struct mem_block_s *next; // Next Memory Block in list + uint32_t info; // Block Info or max used Memory (in last block) } mem_block_t; // Memory Block Info: Length = <31:2>:'00', Type = <1:0> -#define MB_INFO_LEN_MASK 0xFFFFFFFCU // Length mask -#define MB_INFO_TYPE_MASK 0x00000003U // Type mask +#define MB_INFO_LEN_MASK 0xFFFFFFFCU // Length mask +#define MB_INFO_TYPE_MASK 0x00000003U // Type mask // Memory Head Pointer -__STATIC_INLINE mem_head_t *MemHeadPtr (void *mem) { - //lint -e{9079} -e{9087} "conversion from pointer to void to pointer to other type" [MISRA Note 6] +__STATIC_INLINE mem_head_t *MemHeadPtr(void *mem) { + // lint -e{9079} -e{9087} "conversion from pointer to void to pointer to other + // type" [MISRA Note 6] return ((mem_head_t *)mem); } // Memory Block Pointer -__STATIC_INLINE mem_block_t *MemBlockPtr (void *mem, uint32_t offset) { - uint32_t addr; +__STATIC_INLINE mem_block_t *MemBlockPtr(void *mem, uint32_t offset) { + uint32_t addr; mem_block_t *ptr; - //lint --e{923} --e{9078} "cast between pointer and unsigned int" [MISRA Note 8] + // lint --e{923} --e{9078} "cast between pointer and unsigned int" [MISRA Note + // 8] addr = (uint32_t)mem + offset; - ptr = (mem_block_t *)addr; + ptr = (mem_block_t *)addr; return ptr; } - // ==== Library functions ==== /// Initialize Memory Pool with variable block size. /// \param[in] mem pointer to memory pool. /// \param[in] size size of a memory pool in bytes. /// \return 1 - success, 0 - failure. -__WEAK uint32_t osRtxMemoryInit (void *mem, uint32_t size) { - mem_head_t *head; +__WEAK uint32_t osRtxMemoryInit(void *mem, uint32_t size) { + mem_head_t *head; mem_block_t *ptr; // Check parameters - //lint -e{923} "cast from pointer to unsigned int" [MISRA Note 7] + // lint -e{923} "cast from pointer to unsigned int" [MISRA Note 7] if ((mem == NULL) || (((uint32_t)mem & 7U) != 0U) || ((size & 7U) != 0U) || - (size < (sizeof(mem_head_t) + (2U*sizeof(mem_block_t))))) { + (size < (sizeof(mem_head_t) + (2U * sizeof(mem_block_t))))) { EvrRtxMemoryInit(mem, size, 0U); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } @@ -100,18 +100,19 @@ __WEAK uint32_t osRtxMemoryInit (void *mem, uint32_t size) { /// Allocate a memory block from a Memory Pool. /// \param[in] mem pointer to memory pool. /// \param[in] size size of a memory block in bytes. -/// \param[in] type memory block type: 0 - generic, 1 - control block -/// \return allocated memory block or NULL in case of no memory is available. -__WEAK void *osRtxMemoryAlloc (void *mem, uint32_t size, uint32_t type) { +/// \param[in] type memory block type: 0 - generic, 1 - control +/// block \return allocated memory block or NULL in case of no memory is +/// available. +__WEAK void *osRtxMemoryAlloc(void *mem, uint32_t size, uint32_t type) { mem_block_t *ptr; mem_block_t *p, *p_new; - uint32_t block_size; - uint32_t hole_size; + uint32_t block_size; + uint32_t hole_size; // Check parameters if ((mem == NULL) || (size == 0U) || ((type & ~MB_INFO_TYPE_MASK) != 0U)) { EvrRtxMemoryAlloc(mem, size, type, NULL); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } @@ -123,8 +124,8 @@ __WEAK void *osRtxMemoryAlloc (void *mem, uint32_t size, uint32_t type) { // Search for hole big enough p = MemBlockPtr(mem, sizeof(mem_head_t)); for (;;) { - //lint -e{923} -e{9078} "cast from pointer to unsigned int" - hole_size = (uint32_t)p->next - (uint32_t)p; + // lint -e{923} -e{9078} "cast from pointer to unsigned int" + hole_size = (uint32_t)p->next - (uint32_t)p; hole_size -= p->info & MB_INFO_LEN_MASK; if (hole_size >= block_size) { // Hole found @@ -134,7 +135,7 @@ __WEAK void *osRtxMemoryAlloc (void *mem, uint32_t size, uint32_t type) { if (p->next == NULL) { // Failed (end of list) EvrRtxMemoryAlloc(mem, size, type, NULL); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } @@ -171,14 +172,14 @@ __WEAK void *osRtxMemoryAlloc (void *mem, uint32_t size, uint32_t type) { /// \param[in] mem pointer to memory pool. /// \param[in] block memory block to be returned to the memory pool. /// \return 1 - success, 0 - failure. -__WEAK uint32_t osRtxMemoryFree (void *mem, void *block) { +__WEAK uint32_t osRtxMemoryFree(void *mem, void *block) { const mem_block_t *ptr; - mem_block_t *p, *p_prev; + mem_block_t *p, *p_prev; // Check parameters if ((mem == NULL) || (block == NULL)) { EvrRtxMemoryFree(mem, block, 0U); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } @@ -195,7 +196,7 @@ __WEAK uint32_t osRtxMemoryFree (void *mem, void *block) { if (p == NULL) { // Not found EvrRtxMemoryFree(mem, block, 0U); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } } diff --git a/rtos/rtx5/rtx_mempool.c b/rtos/rtx5/rtx_mempool.c index f7a1872..73c24fe 100644 --- a/rtos/rtx5/rtx_mempool.c +++ b/rtos/rtx5/rtx_mempool.c @@ -25,15 +25,12 @@ #include "rtx_lib.h" - // OS Runtime Object Memory Usage #if ((defined(OS_OBJ_MEM_USAGE) && (OS_OBJ_MEM_USAGE != 0))) -osRtxObjectMemUsage_t osRtxMemoryPoolMemUsage \ -__attribute__((section(".data.os.mempool.obj"))) = -{ 0U, 0U, 0U }; +osRtxObjectMemUsage_t osRtxMemoryPoolMemUsage + __attribute__((section(".data.os.mempool.obj"))) = {0U, 0U, 0U}; #endif - // ==== Library functions ==== /// Initialize Memory Pool. @@ -42,24 +39,27 @@ __attribute__((section(".data.os.mempool.obj"))) = /// \param[in] block_size size of a memory block in bytes. /// \param[in] block_mem pointer to memory for block storage. /// \return 1 - success, 0 - failure. -uint32_t osRtxMemoryPoolInit (os_mp_info_t *mp_info, uint32_t block_count, uint32_t block_size, void *block_mem) { - //lint --e{9079} --e{9087} "conversion from pointer to void to pointer to other type" [MISRA Note 6] +uint32_t osRtxMemoryPoolInit(os_mp_info_t *mp_info, uint32_t block_count, + uint32_t block_size, void *block_mem) { + // lint --e{9079} --e{9087} "conversion from pointer to void to pointer to + // other type" [MISRA Note 6] void *mem; void *block; // Check parameters - if ((mp_info == NULL) || (block_count == 0U) || (block_size == 0U) || (block_mem == NULL)) { - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + if ((mp_info == NULL) || (block_count == 0U) || (block_size == 0U) || + (block_mem == NULL)) { + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } // Initialize information structure - mp_info->max_blocks = block_count; + mp_info->max_blocks = block_count; mp_info->used_blocks = 0U; - mp_info->block_size = block_size; - mp_info->block_base = block_mem; - mp_info->block_free = block_mem; - mp_info->block_lim = &(((uint8_t *)block_mem)[block_count * block_size]); + mp_info->block_size = block_size; + mp_info->block_base = block_mem; + mp_info->block_free = block_mem; + mp_info->block_lim = &(((uint8_t *)block_mem)[block_count * block_size]); EvrRtxMemoryBlockInit(mp_info, block_count, block_size, block_mem); @@ -77,8 +77,9 @@ uint32_t osRtxMemoryPoolInit (os_mp_info_t *mp_info, uint32_t block_count, uint3 /// Allocate a memory block from a Memory Pool. /// \param[in] mp_info memory pool info. -/// \return address of the allocated memory block or NULL in case of no memory is available. -void *osRtxMemoryPoolAlloc (os_mp_info_t *mp_info) { +/// \return address of the allocated memory block or NULL in case of no memory +/// is available. +void *osRtxMemoryPoolAlloc(os_mp_info_t *mp_info) { #if (EXCLUSIVE_ACCESS == 0) uint32_t primask = __get_PRIMASK(); #endif @@ -86,7 +87,7 @@ void *osRtxMemoryPoolAlloc (os_mp_info_t *mp_info) { if (mp_info == NULL) { EvrRtxMemoryBlockAlloc(NULL, NULL); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } @@ -95,7 +96,8 @@ void *osRtxMemoryPoolAlloc (os_mp_info_t *mp_info) { block = mp_info->block_free; if (block != NULL) { - //lint --e{9079} --e{9087} "conversion from pointer to void to pointer to other type" + // lint --e{9079} --e{9087} "conversion from pointer to void to pointer to + // other type" mp_info->block_free = *((void **)block); mp_info->used_blocks++; } @@ -117,24 +119,27 @@ void *osRtxMemoryPoolAlloc (os_mp_info_t *mp_info) { /// Return an allocated memory block back to a Memory Pool. /// \param[in] mp_info memory pool info. -/// \param[in] block address of the allocated memory block to be returned to the memory pool. -/// \return status code that indicates the execution status of the function. -osStatus_t osRtxMemoryPoolFree (os_mp_info_t *mp_info, void *block) { +/// \param[in] block address of the allocated memory block to be +/// returned to the memory pool. \return status code that indicates the +/// execution status of the function. +osStatus_t osRtxMemoryPoolFree(os_mp_info_t *mp_info, void *block) { #if (EXCLUSIVE_ACCESS == 0) uint32_t primask = __get_PRIMASK(); #endif - //lint -e{946} "Relational operator applied to pointers" - if ((mp_info == NULL) || (block < mp_info->block_base) || (block >= mp_info->block_lim)) { + // lint -e{946} "Relational operator applied to pointers" + if ((mp_info == NULL) || (block < mp_info->block_base) || + (block >= mp_info->block_lim)) { EvrRtxMemoryBlockFree(mp_info, block, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } #if (EXCLUSIVE_ACCESS == 0) __disable_irq(); - //lint --e{9079} --e{9087} "conversion from pointer to void to pointer to other type" + // lint --e{9079} --e{9087} "conversion from pointer to void to pointer to + // other type" *((void **)block) = mp_info->block_free; mp_info->block_free = block; mp_info->used_blocks--; @@ -152,13 +157,12 @@ osStatus_t osRtxMemoryPoolFree (os_mp_info_t *mp_info, void *block) { return osOK; } - // ==== Post ISR processing ==== /// Memory Pool post ISR processing. /// \param[in] mp memory pool object. -static void osRtxMemoryPoolPostProcess (os_memory_pool_t *mp) { - void *block; +static void osRtxMemoryPoolPostProcess(os_memory_pool_t *mp) { + void *block; os_thread_t *thread; // Check if Thread is waiting to allocate memory @@ -168,39 +172,40 @@ static void osRtxMemoryPoolPostProcess (os_memory_pool_t *mp) { if (block != NULL) { // Wakeup waiting Thread with highest Priority thread = osRtxThreadListGet(osRtxObject(mp)); - //lint -e{923} "cast from pointer to unsigned int" + // lint -e{923} "cast from pointer to unsigned int" osRtxThreadWaitExit(thread, (uint32_t)block, FALSE); EvrRtxMemoryPoolAllocated(mp, block); } } } - // ==== Service Calls ==== /// Create and Initialize a Memory Pool object. /// \note API identical to osMemoryPoolNew -static osMemoryPoolId_t svcRtxMemoryPoolNew (uint32_t block_count, uint32_t block_size, const osMemoryPoolAttr_t *attr) { +static osMemoryPoolId_t svcRtxMemoryPoolNew(uint32_t block_count, + uint32_t block_size, + const osMemoryPoolAttr_t *attr) { os_memory_pool_t *mp; - void *mp_mem; - uint32_t mp_size; - uint32_t b_count; - uint32_t b_size; - uint32_t size; - uint8_t flags; - const char *name; + void *mp_mem; + uint32_t mp_size; + uint32_t b_count; + uint32_t b_size; + uint32_t size; + uint8_t flags; + const char *name; // Check parameters - if ((block_count == 0U) || (block_size == 0U)) { + if ((block_count == 0U) || (block_size == 0U)) { EvrRtxMemoryPoolError(NULL, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } - b_count = block_count; - b_size = (block_size + 3U) & ~3UL; + b_count = block_count; + b_size = (block_size + 3U) & ~3UL; if ((__CLZ(b_count) + __CLZ(b_size)) < 32U) { EvrRtxMemoryPoolError(NULL, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } @@ -208,60 +213,68 @@ static osMemoryPoolId_t svcRtxMemoryPoolNew (uint32_t block_count, uint32_t bloc // Process attributes if (attr != NULL) { - name = attr->name; - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 6] - mp = attr->cb_mem; - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 6] - mp_mem = attr->mp_mem; + name = attr->name; + // lint -e{9079} "conversion from pointer to void to pointer to other type" + // [MISRA Note 6] + mp = attr->cb_mem; + // lint -e{9079} "conversion from pointer to void to pointer to other type" + // [MISRA Note 6] + mp_mem = attr->mp_mem; mp_size = attr->mp_size; if (mp != NULL) { - //lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note 7] - if ((((uint32_t)mp & 3U) != 0U) || (attr->cb_size < sizeof(os_memory_pool_t))) { + // lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note + // 7] + if ((((uint32_t)mp & 3U) != 0U) || + (attr->cb_size < sizeof(os_memory_pool_t))) { EvrRtxMemoryPoolError(NULL, osRtxErrorInvalidControlBlock); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } else { if (attr->cb_size != 0U) { EvrRtxMemoryPoolError(NULL, osRtxErrorInvalidControlBlock); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } if (mp_mem != NULL) { - //lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note 7] + // lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note + // 7] if ((((uint32_t)mp_mem & 3U) != 0U) || (mp_size < size)) { EvrRtxMemoryPoolError(NULL, osRtxErrorInvalidDataMemory); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } else { if (mp_size != 0U) { EvrRtxMemoryPoolError(NULL, osRtxErrorInvalidDataMemory); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } } else { - name = NULL; - mp = NULL; + name = NULL; + mp = NULL; mp_mem = NULL; } // Allocate object memory if not provided if (mp == NULL) { if (osRtxInfo.mpi.memory_pool != NULL) { - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] mp = osRtxMemoryPoolAlloc(osRtxInfo.mpi.memory_pool); } else { - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] mp = osRtxMemoryAlloc(osRtxInfo.mem.common, sizeof(os_memory_pool_t), 1U); } #if (defined(OS_OBJ_MEM_USAGE) && (OS_OBJ_MEM_USAGE != 0)) if (mp != NULL) { uint32_t used; osRtxMemoryPoolMemUsage.cnt_alloc++; - used = osRtxMemoryPoolMemUsage.cnt_alloc - osRtxMemoryPoolMemUsage.cnt_free; + used = + osRtxMemoryPoolMemUsage.cnt_alloc - osRtxMemoryPoolMemUsage.cnt_free; if (osRtxMemoryPoolMemUsage.max_used < used) { osRtxMemoryPoolMemUsage.max_used = used; } @@ -274,7 +287,8 @@ static osMemoryPoolId_t svcRtxMemoryPoolNew (uint32_t block_count, uint32_t bloc // Allocate data memory if not provided if ((mp != NULL) && (mp_mem == NULL)) { - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other type" + // [MISRA Note 5] mp_mem = osRtxMemoryAlloc(osRtxInfo.mem.mp_data, size, 0U); if (mp_mem == NULL) { if ((flags & osRtxFlagSystemObject) != 0U) { @@ -296,9 +310,9 @@ static osMemoryPoolId_t svcRtxMemoryPoolNew (uint32_t block_count, uint32_t bloc if (mp != NULL) { // Initialize control block - mp->id = osRtxIdMemoryPool; - mp->flags = flags; - mp->name = name; + mp->id = osRtxIdMemoryPool; + mp->flags = flags; + mp->name = name; mp->thread_list = NULL; (void)osRtxMemoryPoolInit(&mp->mp_info, b_count, b_size, mp_mem); @@ -315,13 +329,13 @@ static osMemoryPoolId_t svcRtxMemoryPoolNew (uint32_t block_count, uint32_t bloc /// Get name of a Memory Pool object. /// \note API identical to osMemoryPoolGetName -static const char *svcRtxMemoryPoolGetName (osMemoryPoolId_t mp_id) { +static const char *svcRtxMemoryPoolGetName(osMemoryPoolId_t mp_id) { os_memory_pool_t *mp = osRtxMemoryPoolId(mp_id); // Check parameters if ((mp == NULL) || (mp->id != osRtxIdMemoryPool)) { EvrRtxMemoryPoolGetName(mp, NULL); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } @@ -332,14 +346,14 @@ static const char *svcRtxMemoryPoolGetName (osMemoryPoolId_t mp_id) { /// Allocate a memory block from a Memory Pool. /// \note API identical to osMemoryPoolAlloc -static void *svcRtxMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout) { +static void *svcRtxMemoryPoolAlloc(osMemoryPoolId_t mp_id, uint32_t timeout) { os_memory_pool_t *mp = osRtxMemoryPoolId(mp_id); - void *block; + void *block; // Check parameters if ((mp == NULL) || (mp->id != osRtxIdMemoryPool)) { EvrRtxMemoryPoolError(mp, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } @@ -367,16 +381,16 @@ static void *svcRtxMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout) { /// Return an allocated memory block back to a Memory Pool. /// \note API identical to osMemoryPoolFree -static osStatus_t svcRtxMemoryPoolFree (osMemoryPoolId_t mp_id, void *block) { +static osStatus_t svcRtxMemoryPoolFree(osMemoryPoolId_t mp_id, void *block) { os_memory_pool_t *mp = osRtxMemoryPoolId(mp_id); - void *block0; - os_thread_t *thread; - osStatus_t status; + void *block0; + os_thread_t *thread; + osStatus_t status; // Check parameters if ((mp == NULL) || (mp->id != osRtxIdMemoryPool)) { EvrRtxMemoryPoolError(mp, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } @@ -391,7 +405,7 @@ static osStatus_t svcRtxMemoryPoolFree (osMemoryPoolId_t mp_id, void *block) { if (block0 != NULL) { // Wakeup waiting Thread with highest Priority thread = osRtxThreadListGet(osRtxObject(mp)); - //lint -e{923} "cast from pointer to unsigned int" + // lint -e{923} "cast from pointer to unsigned int" osRtxThreadWaitExit(thread, (uint32_t)block0, TRUE); EvrRtxMemoryPoolAllocated(mp, block0); } @@ -405,13 +419,13 @@ static osStatus_t svcRtxMemoryPoolFree (osMemoryPoolId_t mp_id, void *block) { /// Get maximum number of memory blocks in a Memory Pool. /// \note API identical to osMemoryPoolGetCapacity -static uint32_t svcRtxMemoryPoolGetCapacity (osMemoryPoolId_t mp_id) { +static uint32_t svcRtxMemoryPoolGetCapacity(osMemoryPoolId_t mp_id) { os_memory_pool_t *mp = osRtxMemoryPoolId(mp_id); // Check parameters if ((mp == NULL) || (mp->id != osRtxIdMemoryPool)) { EvrRtxMemoryPoolGetCapacity(mp, 0U); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } @@ -422,13 +436,13 @@ static uint32_t svcRtxMemoryPoolGetCapacity (osMemoryPoolId_t mp_id) { /// Get memory block size in a Memory Pool. /// \note API identical to osMemoryPoolGetBlockSize -static uint32_t svcRtxMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id) { +static uint32_t svcRtxMemoryPoolGetBlockSize(osMemoryPoolId_t mp_id) { os_memory_pool_t *mp = osRtxMemoryPoolId(mp_id); // Check parameters if ((mp == NULL) || (mp->id != osRtxIdMemoryPool)) { EvrRtxMemoryPoolGetBlockSize(mp, 0U); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } @@ -439,13 +453,13 @@ static uint32_t svcRtxMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id) { /// Get number of memory blocks used in a Memory Pool. /// \note API identical to osMemoryPoolGetCount -static uint32_t svcRtxMemoryPoolGetCount (osMemoryPoolId_t mp_id) { +static uint32_t svcRtxMemoryPoolGetCount(osMemoryPoolId_t mp_id) { os_memory_pool_t *mp = osRtxMemoryPoolId(mp_id); // Check parameters if ((mp == NULL) || (mp->id != osRtxIdMemoryPool)) { EvrRtxMemoryPoolGetCount(mp, 0U); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } @@ -456,31 +470,32 @@ static uint32_t svcRtxMemoryPoolGetCount (osMemoryPoolId_t mp_id) { /// Get number of memory blocks available in a Memory Pool. /// \note API identical to osMemoryPoolGetSpace -static uint32_t svcRtxMemoryPoolGetSpace (osMemoryPoolId_t mp_id) { +static uint32_t svcRtxMemoryPoolGetSpace(osMemoryPoolId_t mp_id) { os_memory_pool_t *mp = osRtxMemoryPoolId(mp_id); // Check parameters if ((mp == NULL) || (mp->id != osRtxIdMemoryPool)) { EvrRtxMemoryPoolGetSpace(mp, 0U); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } - EvrRtxMemoryPoolGetSpace(mp, mp->mp_info.max_blocks - mp->mp_info.used_blocks); + EvrRtxMemoryPoolGetSpace(mp, + mp->mp_info.max_blocks - mp->mp_info.used_blocks); return (mp->mp_info.max_blocks - mp->mp_info.used_blocks); } /// Delete a Memory Pool object. /// \note API identical to osMemoryPoolDelete -static osStatus_t svcRtxMemoryPoolDelete (osMemoryPoolId_t mp_id) { +static osStatus_t svcRtxMemoryPoolDelete(osMemoryPoolId_t mp_id) { os_memory_pool_t *mp = osRtxMemoryPoolId(mp_id); - os_thread_t *thread; + os_thread_t *thread; // Check parameters if ((mp == NULL) || (mp->id != osRtxIdMemoryPool)) { EvrRtxMemoryPoolError(mp, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } @@ -519,32 +534,32 @@ static osStatus_t svcRtxMemoryPoolDelete (osMemoryPoolId_t mp_id) { } // Service Calls definitions -//lint ++flb "Library Begin" [MISRA Note 11] -SVC0_3(MemoryPoolNew, osMemoryPoolId_t, uint32_t, uint32_t, const osMemoryPoolAttr_t *) -SVC0_1(MemoryPoolGetName, const char *, osMemoryPoolId_t) -SVC0_2(MemoryPoolAlloc, void *, osMemoryPoolId_t, uint32_t) -SVC0_2(MemoryPoolFree, osStatus_t, osMemoryPoolId_t, void *) -SVC0_1(MemoryPoolGetCapacity, uint32_t, osMemoryPoolId_t) -SVC0_1(MemoryPoolGetBlockSize, uint32_t, osMemoryPoolId_t) -SVC0_1(MemoryPoolGetCount, uint32_t, osMemoryPoolId_t) -SVC0_1(MemoryPoolGetSpace, uint32_t, osMemoryPoolId_t) -SVC0_1(MemoryPoolDelete, osStatus_t, osMemoryPoolId_t) -//lint --flb "Library End" - +// lint ++flb "Library Begin" [MISRA Note 11] +SVC0_3(MemoryPoolNew, osMemoryPoolId_t, uint32_t, uint32_t, + const osMemoryPoolAttr_t *) +SVC0_1(MemoryPoolGetName, const char *, osMemoryPoolId_t) +SVC0_2(MemoryPoolAlloc, void *, osMemoryPoolId_t, uint32_t) +SVC0_2(MemoryPoolFree, osStatus_t, osMemoryPoolId_t, void *) +SVC0_1(MemoryPoolGetCapacity, uint32_t, osMemoryPoolId_t) +SVC0_1(MemoryPoolGetBlockSize, uint32_t, osMemoryPoolId_t) +SVC0_1(MemoryPoolGetCount, uint32_t, osMemoryPoolId_t) +SVC0_1(MemoryPoolGetSpace, uint32_t, osMemoryPoolId_t) +SVC0_1(MemoryPoolDelete, osStatus_t, osMemoryPoolId_t) +// lint --flb "Library End" // ==== ISR Calls ==== /// Allocate a memory block from a Memory Pool. /// \note API identical to osMemoryPoolAlloc __STATIC_INLINE -void *isrRtxMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout) { +void *isrRtxMemoryPoolAlloc(osMemoryPoolId_t mp_id, uint32_t timeout) { os_memory_pool_t *mp = osRtxMemoryPoolId(mp_id); - void *block; + void *block; // Check parameters if ((mp == NULL) || (mp->id != osRtxIdMemoryPool) || (timeout != 0U)) { EvrRtxMemoryPoolError(mp, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } @@ -562,14 +577,14 @@ void *isrRtxMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout) { /// Return an allocated memory block back to a Memory Pool. /// \note API identical to osMemoryPoolFree __STATIC_INLINE -osStatus_t isrRtxMemoryPoolFree (osMemoryPoolId_t mp_id, void *block) { +osStatus_t isrRtxMemoryPoolFree(osMemoryPoolId_t mp_id, void *block) { os_memory_pool_t *mp = osRtxMemoryPoolId(mp_id); - osStatus_t status; + osStatus_t status; // Check parameters if ((mp == NULL) || (mp->id != osRtxIdMemoryPool)) { EvrRtxMemoryPoolError(mp, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } @@ -586,11 +601,11 @@ osStatus_t isrRtxMemoryPoolFree (osMemoryPoolId_t mp_id, void *block) { return status; } - // ==== Public API ==== /// Create and Initialize a Memory Pool object. -osMemoryPoolId_t osMemoryPoolNew (uint32_t block_count, uint32_t block_size, const osMemoryPoolAttr_t *attr) { +osMemoryPoolId_t osMemoryPoolNew(uint32_t block_count, uint32_t block_size, + const osMemoryPoolAttr_t *attr) { osMemoryPoolId_t mp_id; EvrRtxMemoryPoolNew(block_count, block_size, attr); @@ -604,7 +619,7 @@ osMemoryPoolId_t osMemoryPoolNew (uint32_t block_count, uint32_t block_size, con } /// Get name of a Memory Pool object. -const char *osMemoryPoolGetName (osMemoryPoolId_t mp_id) { +const char *osMemoryPoolGetName(osMemoryPoolId_t mp_id) { const char *name; if (IsIrqMode() || IsIrqMasked()) { @@ -617,81 +632,81 @@ const char *osMemoryPoolGetName (osMemoryPoolId_t mp_id) { } /// Allocate a memory block from a Memory Pool. -void *osMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout) { +void *osMemoryPoolAlloc(osMemoryPoolId_t mp_id, uint32_t timeout) { void *memory; EvrRtxMemoryPoolAlloc(mp_id, timeout); if (IsIrqMode() || IsIrqMasked()) { memory = isrRtxMemoryPoolAlloc(mp_id, timeout); } else { - memory = __svcMemoryPoolAlloc(mp_id, timeout); + memory = __svcMemoryPoolAlloc(mp_id, timeout); } return memory; } /// Return an allocated memory block back to a Memory Pool. -osStatus_t osMemoryPoolFree (osMemoryPoolId_t mp_id, void *block) { +osStatus_t osMemoryPoolFree(osMemoryPoolId_t mp_id, void *block) { osStatus_t status; EvrRtxMemoryPoolFree(mp_id, block); if (IsIrqMode() || IsIrqMasked()) { status = isrRtxMemoryPoolFree(mp_id, block); } else { - status = __svcMemoryPoolFree(mp_id, block); + status = __svcMemoryPoolFree(mp_id, block); } return status; } /// Get maximum number of memory blocks in a Memory Pool. -uint32_t osMemoryPoolGetCapacity (osMemoryPoolId_t mp_id) { +uint32_t osMemoryPoolGetCapacity(osMemoryPoolId_t mp_id) { uint32_t capacity; if (IsIrqMode() || IsIrqMasked()) { capacity = svcRtxMemoryPoolGetCapacity(mp_id); } else { - capacity = __svcMemoryPoolGetCapacity(mp_id); + capacity = __svcMemoryPoolGetCapacity(mp_id); } return capacity; } /// Get memory block size in a Memory Pool. -uint32_t osMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id) { +uint32_t osMemoryPoolGetBlockSize(osMemoryPoolId_t mp_id) { uint32_t block_size; if (IsIrqMode() || IsIrqMasked()) { block_size = svcRtxMemoryPoolGetBlockSize(mp_id); } else { - block_size = __svcMemoryPoolGetBlockSize(mp_id); + block_size = __svcMemoryPoolGetBlockSize(mp_id); } return block_size; } /// Get number of memory blocks used in a Memory Pool. -uint32_t osMemoryPoolGetCount (osMemoryPoolId_t mp_id) { +uint32_t osMemoryPoolGetCount(osMemoryPoolId_t mp_id) { uint32_t count; if (IsIrqMode() || IsIrqMasked()) { count = svcRtxMemoryPoolGetCount(mp_id); } else { - count = __svcMemoryPoolGetCount(mp_id); + count = __svcMemoryPoolGetCount(mp_id); } return count; } /// Get number of memory blocks available in a Memory Pool. -uint32_t osMemoryPoolGetSpace (osMemoryPoolId_t mp_id) { +uint32_t osMemoryPoolGetSpace(osMemoryPoolId_t mp_id) { uint32_t space; if (IsIrqMode() || IsIrqMasked()) { space = svcRtxMemoryPoolGetSpace(mp_id); } else { - space = __svcMemoryPoolGetSpace(mp_id); + space = __svcMemoryPoolGetSpace(mp_id); } return space; } /// Delete a Memory Pool object. -osStatus_t osMemoryPoolDelete (osMemoryPoolId_t mp_id) { +osStatus_t osMemoryPoolDelete(osMemoryPoolId_t mp_id) { osStatus_t status; EvrRtxMemoryPoolDelete(mp_id); diff --git a/rtos/rtx5/rtx_msgqueue.c b/rtos/rtx5/rtx_msgqueue.c index 5451998..4c12bbf 100644 --- a/rtos/rtx5/rtx_msgqueue.c +++ b/rtos/rtx5/rtx_msgqueue.c @@ -25,23 +25,20 @@ #include "rtx_lib.h" - // OS Runtime Object Memory Usage #if ((defined(OS_OBJ_MEM_USAGE) && (OS_OBJ_MEM_USAGE != 0))) -osRtxObjectMemUsage_t osRtxMessageQueueMemUsage \ -__attribute__((section(".data.os.msgqueue.obj"))) = -{ 0U, 0U, 0U }; +osRtxObjectMemUsage_t osRtxMessageQueueMemUsage + __attribute__((section(".data.os.msgqueue.obj"))) = {0U, 0U, 0U}; #endif - // ==== Helper functions ==== /// Put a Message into Queue sorted by Priority (Highest at Head). /// \param[in] mq message queue object. /// \param[in] msg message object. -static void MessageQueuePut (os_message_queue_t *mq, os_message_t *msg) { +static void MessageQueuePut(os_message_queue_t *mq, os_message_t *msg) { #if (EXCLUSIVE_ACCESS == 0) - uint32_t primask = __get_PRIMASK(); + uint32_t primask = __get_PRIMASK(); #endif os_message_t *prev, *next; @@ -67,7 +64,7 @@ static void MessageQueuePut (os_message_queue_t *mq, os_message_t *msg) { } else { msg->prev = NULL; msg->next = NULL; - mq->msg_first= msg; + mq->msg_first = msg; mq->msg_last = msg; } @@ -87,13 +84,13 @@ static void MessageQueuePut (os_message_queue_t *mq, os_message_t *msg) { /// Get a Message from Queue with Highest Priority. /// \param[in] mq message queue object. /// \return message object or NULL. -static os_message_t *MessageQueueGet (os_message_queue_t *mq) { +static os_message_t *MessageQueueGet(os_message_queue_t *mq) { #if (EXCLUSIVE_ACCESS == 0) - uint32_t primask = __get_PRIMASK(); + uint32_t primask = __get_PRIMASK(); #endif os_message_t *msg; - uint32_t count; - uint8_t flags; + uint32_t count; + uint8_t flags; #if (EXCLUSIVE_ACCESS == 0) __disable_irq(); @@ -141,7 +138,8 @@ static os_message_t *MessageQueueGet (os_message_queue_t *mq) { /// Remove a Message from Queue /// \param[in] mq message queue object. /// \param[in] msg message object. -static void MessageQueueRemove (os_message_queue_t *mq, const os_message_t *msg) { +static void MessageQueueRemove(os_message_queue_t *mq, + const os_message_t *msg) { if (msg->prev != NULL) { msg->prev->next = msg->next; @@ -155,22 +153,21 @@ static void MessageQueueRemove (os_message_queue_t *mq, const os_message_t *msg) } } - // ==== Post ISR processing ==== /// Message Queue post ISR processing. /// \param[in] msg message object. -static void osRtxMessageQueuePostProcess (os_message_t *msg) { +static void osRtxMessageQueuePostProcess(os_message_t *msg) { os_message_queue_t *mq; - os_message_t *msg0; - os_thread_t *thread; - const uint32_t *reg; - const void *ptr_src; - void *ptr_dst; + os_message_t *msg0; + os_thread_t *thread; + const uint32_t *reg; + const void *ptr_src; + void *ptr_dst; if (msg->flags != 0U) { // Remove Message - //lint -e{9079} -e{9087} "cast between pointers to different object types" + // lint -e{9079} -e{9087} "cast between pointers to different object types" mq = *((os_message_queue_t **)(void *)&msg[1]); MessageQueueRemove(mq, msg); // Free memory @@ -179,7 +176,8 @@ static void osRtxMessageQueuePostProcess (os_message_t *msg) { // Check if Thread is waiting to send a Message if (mq->thread_list != NULL) { // Try to allocate memory - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] msg0 = osRtxMemoryPoolAlloc(&mq->mp_info); if (msg0 != NULL) { // Wakeup waiting Thread with highest Priority @@ -187,12 +185,12 @@ static void osRtxMessageQueuePostProcess (os_message_t *msg) { osRtxThreadWaitExit(thread, (uint32_t)osOK, FALSE); // Copy Message (R2: const void *msg_ptr, R3: uint8_t msg_prio) reg = osRtxThreadRegPtr(thread); - //lint -e{923} "cast from unsigned int to pointer" + // lint -e{923} "cast from unsigned int to pointer" ptr_src = (const void *)reg[2]; memcpy(&msg0[1], ptr_src, mq->msg_size); // Store Message into Queue - msg0->id = osRtxIdMessage; - msg0->flags = 0U; + msg0->id = osRtxIdMessage; + msg0->flags = 0U; msg0->priority = (uint8_t)reg[3]; MessageQueuePut(mq, msg0); EvrRtxMessageQueueInserted(mq, ptr_src); @@ -200,23 +198,24 @@ static void osRtxMessageQueuePostProcess (os_message_t *msg) { } } else { // New Message - //lint -e{9079} -e{9087} "cast between pointers to different object types" + // lint -e{9079} -e{9087} "cast between pointers to different object types" mq = (void *)msg->next; - //lint -e{9087} "cast between pointers to different object types" + // lint -e{9087} "cast between pointers to different object types" ptr_src = (const void *)msg->prev; // Check if Thread is waiting to receive a Message - if ((mq->thread_list != NULL) && (mq->thread_list->state == osRtxThreadWaitingMessageGet)) { + if ((mq->thread_list != NULL) && + (mq->thread_list->state == osRtxThreadWaitingMessageGet)) { EvrRtxMessageQueueInserted(mq, ptr_src); // Wakeup waiting Thread with highest Priority thread = osRtxThreadListGet(osRtxObject(mq)); osRtxThreadWaitExit(thread, (uint32_t)osOK, FALSE); // Copy Message (R2: void *msg_ptr, R3: uint8_t *msg_prio) reg = osRtxThreadRegPtr(thread); - //lint -e{923} "cast from unsigned int to pointer" + // lint -e{923} "cast from unsigned int to pointer" ptr_dst = (void *)reg[2]; memcpy(ptr_dst, &msg[1], mq->msg_size); if (reg[3] != 0U) { - //lint -e{923} -e{9078} "cast from unsigned int to pointer" + // lint -e{923} -e{9078} "cast from unsigned int to pointer" *((uint8_t *)reg[3]) = msg->priority; } EvrRtxMessageQueueRetrieved(mq, ptr_dst); @@ -230,30 +229,31 @@ static void osRtxMessageQueuePostProcess (os_message_t *msg) { } } - // ==== Service Calls ==== /// Create and Initialize a Message Queue object. /// \note API identical to osMessageQueueNew -static osMessageQueueId_t svcRtxMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr) { +static osMessageQueueId_t +svcRtxMessageQueueNew(uint32_t msg_count, uint32_t msg_size, + const osMessageQueueAttr_t *attr) { os_message_queue_t *mq; - void *mq_mem; - uint32_t mq_size; - uint32_t block_size; - uint32_t size; - uint8_t flags; - const char *name; + void *mq_mem; + uint32_t mq_size; + uint32_t block_size; + uint32_t size; + uint8_t flags; + const char *name; // Check parameters - if ((msg_count == 0U) || (msg_size == 0U)) { + if ((msg_count == 0U) || (msg_size == 0U)) { EvrRtxMessageQueueError(NULL, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } block_size = ((msg_size + 3U) & ~3UL) + sizeof(os_message_t); if ((__CLZ(msg_count) + __CLZ(block_size)) < 32U) { EvrRtxMessageQueueError(NULL, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } @@ -261,60 +261,69 @@ static osMessageQueueId_t svcRtxMessageQueueNew (uint32_t msg_count, uint32_t ms // Process attributes if (attr != NULL) { - name = attr->name; - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 6] - mq = attr->cb_mem; - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 6] - mq_mem = attr->mq_mem; + name = attr->name; + // lint -e{9079} "conversion from pointer to void to pointer to other type" + // [MISRA Note 6] + mq = attr->cb_mem; + // lint -e{9079} "conversion from pointer to void to pointer to other type" + // [MISRA Note 6] + mq_mem = attr->mq_mem; mq_size = attr->mq_size; if (mq != NULL) { - //lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note 7] - if ((((uint32_t)mq & 3U) != 0U) || (attr->cb_size < sizeof(os_message_queue_t))) { + // lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note + // 7] + if ((((uint32_t)mq & 3U) != 0U) || + (attr->cb_size < sizeof(os_message_queue_t))) { EvrRtxMessageQueueError(NULL, osRtxErrorInvalidControlBlock); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } else { if (attr->cb_size != 0U) { EvrRtxMessageQueueError(NULL, osRtxErrorInvalidControlBlock); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } if (mq_mem != NULL) { - //lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note 7] + // lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note + // 7] if ((((uint32_t)mq_mem & 3U) != 0U) || (mq_size < size)) { EvrRtxMessageQueueError(NULL, osRtxErrorInvalidDataMemory); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } else { if (mq_size != 0U) { EvrRtxMessageQueueError(NULL, osRtxErrorInvalidDataMemory); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } } else { - name = NULL; - mq = NULL; + name = NULL; + mq = NULL; mq_mem = NULL; } // Allocate object memory if not provided if (mq == NULL) { if (osRtxInfo.mpi.message_queue != NULL) { - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] mq = osRtxMemoryPoolAlloc(osRtxInfo.mpi.message_queue); } else { - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] - mq = osRtxMemoryAlloc(osRtxInfo.mem.common, sizeof(os_message_queue_t), 1U); + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] + mq = osRtxMemoryAlloc(osRtxInfo.mem.common, sizeof(os_message_queue_t), + 1U); } #if (defined(OS_OBJ_MEM_USAGE) && (OS_OBJ_MEM_USAGE != 0)) if (mq != NULL) { uint32_t used; osRtxMessageQueueMemUsage.cnt_alloc++; - used = osRtxMessageQueueMemUsage.cnt_alloc - osRtxMessageQueueMemUsage.cnt_free; + used = osRtxMessageQueueMemUsage.cnt_alloc - + osRtxMessageQueueMemUsage.cnt_free; if (osRtxMessageQueueMemUsage.max_used < used) { osRtxMessageQueueMemUsage.max_used = used; } @@ -327,7 +336,8 @@ static osMessageQueueId_t svcRtxMessageQueueNew (uint32_t msg_count, uint32_t ms // Allocate data memory if not provided if ((mq != NULL) && (mq_mem == NULL)) { - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other type" + // [MISRA Note 5] mq_mem = osRtxMemoryAlloc(osRtxInfo.mem.mq_data, size, 0U); if (mq_mem == NULL) { if ((flags & osRtxFlagSystemObject) != 0U) { @@ -349,14 +359,14 @@ static osMessageQueueId_t svcRtxMessageQueueNew (uint32_t msg_count, uint32_t ms if (mq != NULL) { // Initialize control block - mq->id = osRtxIdMessageQueue; - mq->flags = flags; - mq->name = name; + mq->id = osRtxIdMessageQueue; + mq->flags = flags; + mq->name = name; mq->thread_list = NULL; - mq->msg_size = msg_size; - mq->msg_count = 0U; - mq->msg_first = NULL; - mq->msg_last = NULL; + mq->msg_size = msg_size; + mq->msg_count = 0U; + mq->msg_first = NULL; + mq->msg_last = NULL; (void)osRtxMemoryPoolInit(&mq->mp_info, msg_count, block_size, mq_mem); // Register post ISR processing function @@ -372,13 +382,13 @@ static osMessageQueueId_t svcRtxMessageQueueNew (uint32_t msg_count, uint32_t ms /// Get name of a Message Queue object. /// \note API identical to osMessageQueueGetName -static const char *svcRtxMessageQueueGetName (osMessageQueueId_t mq_id) { +static const char *svcRtxMessageQueueGetName(osMessageQueueId_t mq_id) { os_message_queue_t *mq = osRtxMessageQueueId(mq_id); // Check parameters if ((mq == NULL) || (mq->id != osRtxIdMessageQueue)) { EvrRtxMessageQueueGetName(mq, NULL); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } @@ -389,48 +399,52 @@ static const char *svcRtxMessageQueueGetName (osMessageQueueId_t mq_id) { /// Put a Message into a Queue or timeout if Queue is full. /// \note API identical to osMessageQueuePut -static osStatus_t svcRtxMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout) { +static osStatus_t svcRtxMessageQueuePut(osMessageQueueId_t mq_id, + const void *msg_ptr, uint8_t msg_prio, + uint32_t timeout) { os_message_queue_t *mq = osRtxMessageQueueId(mq_id); - os_message_t *msg; - os_thread_t *thread; - uint32_t *reg; - void *ptr; - osStatus_t status; + os_message_t *msg; + os_thread_t *thread; + uint32_t *reg; + void *ptr; + osStatus_t status; // Check parameters if ((mq == NULL) || (mq->id != osRtxIdMessageQueue) || (msg_ptr == NULL)) { EvrRtxMessageQueueError(mq, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } // Check if Thread is waiting to receive a Message - if ((mq->thread_list != NULL) && (mq->thread_list->state == osRtxThreadWaitingMessageGet)) { + if ((mq->thread_list != NULL) && + (mq->thread_list->state == osRtxThreadWaitingMessageGet)) { EvrRtxMessageQueueInserted(mq, msg_ptr); // Wakeup waiting Thread with highest Priority thread = osRtxThreadListGet(osRtxObject(mq)); osRtxThreadWaitExit(thread, (uint32_t)osOK, TRUE); // Copy Message (R2: void *msg_ptr, R3: uint8_t *msg_prio) reg = osRtxThreadRegPtr(thread); - //lint -e{923} "cast from unsigned int to pointer" + // lint -e{923} "cast from unsigned int to pointer" ptr = (void *)reg[2]; memcpy(ptr, msg_ptr, mq->msg_size); if (reg[3] != 0U) { - //lint -e{923} -e{9078} "cast from unsigned int to pointer" + // lint -e{923} -e{9078} "cast from unsigned int to pointer" *((uint8_t *)reg[3]) = msg_prio; } EvrRtxMessageQueueRetrieved(mq, ptr); status = osOK; } else { // Try to allocate memory - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other type" + // [MISRA Note 5] msg = osRtxMemoryPoolAlloc(&mq->mp_info); if (msg != NULL) { // Copy Message memcpy(&msg[1], msg_ptr, mq->msg_size); // Put Message into Queue - msg->id = osRtxIdMessage; - msg->flags = 0U; + msg->id = osRtxIdMessage; + msg->flags = 0U; msg->priority = msg_prio; MessageQueuePut(mq, msg); EvrRtxMessageQueueInserted(mq, msg_ptr); @@ -443,11 +457,11 @@ static osStatus_t svcRtxMessageQueuePut (osMessageQueueId_t mq_id, const void *m if (osRtxThreadWaitEnter(osRtxThreadWaitingMessagePut, timeout)) { osRtxThreadListPut(osRtxObject(mq), osRtxThreadGetRunning()); // Save arguments (R2: const void *msg_ptr, R3: uint8_t msg_prio) - //lint -e{923} -e{9078} "cast from unsigned int to pointer" + // lint -e{923} -e{9078} "cast from unsigned int to pointer" reg = (uint32_t *)(__get_PSP()); - //lint -e{923} -e{9078} "cast from pointer to unsigned int" + // lint -e{923} -e{9078} "cast from pointer to unsigned int" reg[2] = (uint32_t)msg_ptr; - //lint -e{923} -e{9078} "cast from pointer to unsigned int" + // lint -e{923} -e{9078} "cast from pointer to unsigned int" reg[3] = (uint32_t)msg_prio; } else { EvrRtxMessageQueuePutTimeout(mq); @@ -465,18 +479,19 @@ static osStatus_t svcRtxMessageQueuePut (osMessageQueueId_t mq_id, const void *m /// Get a Message from a Queue or timeout if Queue is empty. /// \note API identical to osMessageQueueGet -static osStatus_t svcRtxMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout) { +static osStatus_t svcRtxMessageQueueGet(osMessageQueueId_t mq_id, void *msg_ptr, + uint8_t *msg_prio, uint32_t timeout) { os_message_queue_t *mq = osRtxMessageQueueId(mq_id); - os_message_t *msg; - os_thread_t *thread; - uint32_t *reg; - const void *ptr; - osStatus_t status; + os_message_t *msg; + os_thread_t *thread; + uint32_t *reg; + const void *ptr; + osStatus_t status; // Check parameters if ((mq == NULL) || (mq->id != osRtxIdMessageQueue) || (msg_ptr == NULL)) { EvrRtxMessageQueueError(mq, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } @@ -496,7 +511,8 @@ static osStatus_t svcRtxMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr // Check if Thread is waiting to send a Message if (mq->thread_list != NULL) { // Try to allocate memory - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] msg = osRtxMemoryPoolAlloc(&mq->mp_info); if (msg != NULL) { // Wakeup waiting Thread with highest Priority @@ -504,12 +520,12 @@ static osStatus_t svcRtxMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr osRtxThreadWaitExit(thread, (uint32_t)osOK, TRUE); // Copy Message (R2: const void *msg_ptr, R3: uint8_t msg_prio) reg = osRtxThreadRegPtr(thread); - //lint -e{923} "cast from unsigned int to pointer" + // lint -e{923} "cast from unsigned int to pointer" ptr = (const void *)reg[2]; memcpy(&msg[1], ptr, mq->msg_size); // Store Message into Queue - msg->id = osRtxIdMessage; - msg->flags = 0U; + msg->id = osRtxIdMessage; + msg->flags = 0U; msg->priority = (uint8_t)reg[3]; MessageQueuePut(mq, msg); EvrRtxMessageQueueInserted(mq, ptr); @@ -524,11 +540,11 @@ static osStatus_t svcRtxMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr if (osRtxThreadWaitEnter(osRtxThreadWaitingMessageGet, timeout)) { osRtxThreadListPut(osRtxObject(mq), osRtxThreadGetRunning()); // Save arguments (R2: void *msg_ptr, R3: uint8_t *msg_prio) - //lint -e{923} -e{9078} "cast from unsigned int to pointer" + // lint -e{923} -e{9078} "cast from unsigned int to pointer" reg = (uint32_t *)(__get_PSP()); - //lint -e{923} -e{9078} "cast from pointer to unsigned int" + // lint -e{923} -e{9078} "cast from pointer to unsigned int" reg[2] = (uint32_t)msg_ptr; - //lint -e{923} -e{9078} "cast from pointer to unsigned int" + // lint -e{923} -e{9078} "cast from pointer to unsigned int" reg[3] = (uint32_t)msg_prio; } else { EvrRtxMessageQueueGetTimeout(mq); @@ -545,13 +561,13 @@ static osStatus_t svcRtxMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr /// Get maximum number of messages in a Message Queue. /// \note API identical to osMessageQueueGetCapacity -static uint32_t svcRtxMessageQueueGetCapacity (osMessageQueueId_t mq_id) { +static uint32_t svcRtxMessageQueueGetCapacity(osMessageQueueId_t mq_id) { os_message_queue_t *mq = osRtxMessageQueueId(mq_id); // Check parameters if ((mq == NULL) || (mq->id != osRtxIdMessageQueue)) { EvrRtxMessageQueueGetCapacity(mq, 0U); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } @@ -562,13 +578,13 @@ static uint32_t svcRtxMessageQueueGetCapacity (osMessageQueueId_t mq_id) { /// Get maximum message size in a Memory Pool. /// \note API identical to osMessageQueueGetMsgSize -static uint32_t svcRtxMessageQueueGetMsgSize (osMessageQueueId_t mq_id) { +static uint32_t svcRtxMessageQueueGetMsgSize(osMessageQueueId_t mq_id) { os_message_queue_t *mq = osRtxMessageQueueId(mq_id); // Check parameters if ((mq == NULL) || (mq->id != osRtxIdMessageQueue)) { EvrRtxMessageQueueGetMsgSize(mq, 0U); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } @@ -579,13 +595,13 @@ static uint32_t svcRtxMessageQueueGetMsgSize (osMessageQueueId_t mq_id) { /// Get number of queued messages in a Message Queue. /// \note API identical to osMessageQueueGetCount -static uint32_t svcRtxMessageQueueGetCount (osMessageQueueId_t mq_id) { +static uint32_t svcRtxMessageQueueGetCount(osMessageQueueId_t mq_id) { os_message_queue_t *mq = osRtxMessageQueueId(mq_id); // Check parameters if ((mq == NULL) || (mq->id != osRtxIdMessageQueue)) { EvrRtxMessageQueueGetCount(mq, 0U); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } @@ -596,13 +612,13 @@ static uint32_t svcRtxMessageQueueGetCount (osMessageQueueId_t mq_id) { /// Get number of available slots for messages in a Message Queue. /// \note API identical to osMessageQueueGetSpace -static uint32_t svcRtxMessageQueueGetSpace (osMessageQueueId_t mq_id) { +static uint32_t svcRtxMessageQueueGetSpace(osMessageQueueId_t mq_id) { os_message_queue_t *mq = osRtxMessageQueueId(mq_id); // Check parameters if ((mq == NULL) || (mq->id != osRtxIdMessageQueue)) { EvrRtxMessageQueueGetSpace(mq, 0U); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } @@ -613,17 +629,17 @@ static uint32_t svcRtxMessageQueueGetSpace (osMessageQueueId_t mq_id) { /// Reset a Message Queue to initial empty state. /// \note API identical to osMessageQueueReset -static osStatus_t svcRtxMessageQueueReset (osMessageQueueId_t mq_id) { +static osStatus_t svcRtxMessageQueueReset(osMessageQueueId_t mq_id) { os_message_queue_t *mq = osRtxMessageQueueId(mq_id); - os_message_t *msg; - os_thread_t *thread; - const uint32_t *reg; - const void *ptr; + os_message_t *msg; + os_thread_t *thread; + const uint32_t *reg; + const void *ptr; // Check parameters if ((mq == NULL) || (mq->id != osRtxIdMessageQueue)) { EvrRtxMessageQueueError(mq, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } @@ -642,10 +658,12 @@ static osStatus_t svcRtxMessageQueueReset (osMessageQueueId_t mq_id) { } // Check if Threads are waiting to send Messages - if ((mq->thread_list != NULL) && (mq->thread_list->state == osRtxThreadWaitingMessagePut)) { + if ((mq->thread_list != NULL) && + (mq->thread_list->state == osRtxThreadWaitingMessagePut)) { do { // Try to allocate memory - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] msg = osRtxMemoryPoolAlloc(&mq->mp_info); if (msg != NULL) { // Wakeup waiting Thread with highest Priority @@ -653,12 +671,12 @@ static osStatus_t svcRtxMessageQueueReset (osMessageQueueId_t mq_id) { osRtxThreadWaitExit(thread, (uint32_t)osOK, FALSE); // Copy Message (R2: const void *msg_ptr, R3: uint8_t msg_prio) reg = osRtxThreadRegPtr(thread); - //lint -e{923} "cast from unsigned int to pointer" + // lint -e{923} "cast from unsigned int to pointer" ptr = (const void *)reg[2]; memcpy(&msg[1], ptr, mq->msg_size); // Store Message into Queue - msg->id = osRtxIdMessage; - msg->flags = 0U; + msg->id = osRtxIdMessage; + msg->flags = 0U; msg->priority = (uint8_t)reg[3]; MessageQueuePut(mq, msg); EvrRtxMessageQueueInserted(mq, ptr); @@ -674,14 +692,14 @@ static osStatus_t svcRtxMessageQueueReset (osMessageQueueId_t mq_id) { /// Delete a Message Queue object. /// \note API identical to osMessageQueueDelete -static osStatus_t svcRtxMessageQueueDelete (osMessageQueueId_t mq_id) { +static osStatus_t svcRtxMessageQueueDelete(osMessageQueueId_t mq_id) { os_message_queue_t *mq = osRtxMessageQueueId(mq_id); - os_thread_t *thread; + os_thread_t *thread; // Check parameters if ((mq == NULL) || (mq->id != osRtxIdMessageQueue)) { EvrRtxMessageQueueError(mq, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } @@ -720,51 +738,56 @@ static osStatus_t svcRtxMessageQueueDelete (osMessageQueueId_t mq_id) { } // Service Calls definitions -//lint ++flb "Library Begin" [MISRA Note 11] -SVC0_3(MessageQueueNew, osMessageQueueId_t, uint32_t, uint32_t, const osMessageQueueAttr_t *) -SVC0_1(MessageQueueGetName, const char *, osMessageQueueId_t) -SVC0_4(MessageQueuePut, osStatus_t, osMessageQueueId_t, const void *, uint8_t, uint32_t) -SVC0_4(MessageQueueGet, osStatus_t, osMessageQueueId_t, void *, uint8_t *, uint32_t) -SVC0_1(MessageQueueGetCapacity, uint32_t, osMessageQueueId_t) -SVC0_1(MessageQueueGetMsgSize, uint32_t, osMessageQueueId_t) -SVC0_1(MessageQueueGetCount, uint32_t, osMessageQueueId_t) -SVC0_1(MessageQueueGetSpace, uint32_t, osMessageQueueId_t) -SVC0_1(MessageQueueReset, osStatus_t, osMessageQueueId_t) -SVC0_1(MessageQueueDelete, osStatus_t, osMessageQueueId_t) -//lint --flb "Library End" - +// lint ++flb "Library Begin" [MISRA Note 11] +SVC0_3(MessageQueueNew, osMessageQueueId_t, uint32_t, uint32_t, + const osMessageQueueAttr_t *) +SVC0_1(MessageQueueGetName, const char *, osMessageQueueId_t) +SVC0_4(MessageQueuePut, osStatus_t, osMessageQueueId_t, const void *, uint8_t, + uint32_t) +SVC0_4(MessageQueueGet, osStatus_t, osMessageQueueId_t, void *, uint8_t *, + uint32_t) +SVC0_1(MessageQueueGetCapacity, uint32_t, osMessageQueueId_t) +SVC0_1(MessageQueueGetMsgSize, uint32_t, osMessageQueueId_t) +SVC0_1(MessageQueueGetCount, uint32_t, osMessageQueueId_t) +SVC0_1(MessageQueueGetSpace, uint32_t, osMessageQueueId_t) +SVC0_1(MessageQueueReset, osStatus_t, osMessageQueueId_t) +SVC0_1(MessageQueueDelete, osStatus_t, osMessageQueueId_t) +// lint --flb "Library End" // ==== ISR Calls ==== /// Put a Message into a Queue or timeout if Queue is full. /// \note API identical to osMessageQueuePut __STATIC_INLINE -osStatus_t isrRtxMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout) { +osStatus_t isrRtxMessageQueuePut(osMessageQueueId_t mq_id, const void *msg_ptr, + uint8_t msg_prio, uint32_t timeout) { os_message_queue_t *mq = osRtxMessageQueueId(mq_id); - os_message_t *msg; - osStatus_t status; + os_message_t *msg; + osStatus_t status; // Check parameters - if ((mq == NULL) || (mq->id != osRtxIdMessageQueue) || (msg_ptr == NULL) || (timeout != 0U)) { + if ((mq == NULL) || (mq->id != osRtxIdMessageQueue) || (msg_ptr == NULL) || + (timeout != 0U)) { EvrRtxMessageQueueError(mq, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } // Try to allocate memory - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other type" + // [MISRA Note 5] msg = osRtxMemoryPoolAlloc(&mq->mp_info); if (msg != NULL) { // Copy Message memcpy(&msg[1], msg_ptr, mq->msg_size); - msg->id = osRtxIdMessage; - msg->flags = 0U; + msg->id = osRtxIdMessage; + msg->flags = 0U; msg->priority = msg_prio; // Register post ISR processing - //lint -e{9079} -e{9087} "cast between pointers to different object types" + // lint -e{9079} -e{9087} "cast between pointers to different object types" *((const void **)(void *)&msg->prev) = msg_ptr; - //lint -e{9079} -e{9087} "cast between pointers to different object types" - *( (void **) &msg->next) = mq; + // lint -e{9079} -e{9087} "cast between pointers to different object types" + *((void **)&msg->next) = mq; osRtxPostProcess(osRtxObject(msg)); EvrRtxMessageQueueInsertPending(mq, msg_ptr); status = osOK; @@ -780,15 +803,17 @@ osStatus_t isrRtxMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, /// Get a Message from a Queue or timeout if Queue is empty. /// \note API identical to osMessageQueueGet __STATIC_INLINE -osStatus_t isrRtxMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout) { +osStatus_t isrRtxMessageQueueGet(osMessageQueueId_t mq_id, void *msg_ptr, + uint8_t *msg_prio, uint32_t timeout) { os_message_queue_t *mq = osRtxMessageQueueId(mq_id); - os_message_t *msg; - osStatus_t status; + os_message_t *msg; + osStatus_t status; // Check parameters - if ((mq == NULL) || (mq->id != osRtxIdMessageQueue) || (msg_ptr == NULL) || (timeout != 0U)) { + if ((mq == NULL) || (mq->id != osRtxIdMessageQueue) || (msg_ptr == NULL) || + (timeout != 0U)) { EvrRtxMessageQueueError(mq, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } @@ -801,7 +826,7 @@ osStatus_t isrRtxMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8 *msg_prio = msg->priority; } // Register post ISR processing - //lint -e{9079} -e{9087} "cast between pointers to different object types" + // lint -e{9079} -e{9087} "cast between pointers to different object types" *((os_message_queue_t **)(void *)&msg[1]) = mq; osRtxPostProcess(osRtxObject(msg)); EvrRtxMessageQueueRetrieved(mq, msg_ptr); @@ -815,11 +840,11 @@ osStatus_t isrRtxMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8 return status; } - // ==== Public API ==== /// Create and Initialize a Message Queue object. -osMessageQueueId_t osMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr) { +osMessageQueueId_t osMessageQueueNew(uint32_t msg_count, uint32_t msg_size, + const osMessageQueueAttr_t *attr) { osMessageQueueId_t mq_id; EvrRtxMessageQueueNew(msg_count, msg_size, attr); @@ -833,7 +858,7 @@ osMessageQueueId_t osMessageQueueNew (uint32_t msg_count, uint32_t msg_size, con } /// Get name of a Message Queue object. -const char *osMessageQueueGetName (osMessageQueueId_t mq_id) { +const char *osMessageQueueGetName(osMessageQueueId_t mq_id) { const char *name; if (IsIrqMode() || IsIrqMasked()) { @@ -846,81 +871,83 @@ const char *osMessageQueueGetName (osMessageQueueId_t mq_id) { } /// Put a Message into a Queue or timeout if Queue is full. -osStatus_t osMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout) { +osStatus_t osMessageQueuePut(osMessageQueueId_t mq_id, const void *msg_ptr, + uint8_t msg_prio, uint32_t timeout) { osStatus_t status; EvrRtxMessageQueuePut(mq_id, msg_ptr, msg_prio, timeout); if (IsIrqMode() || IsIrqMasked()) { status = isrRtxMessageQueuePut(mq_id, msg_ptr, msg_prio, timeout); } else { - status = __svcMessageQueuePut(mq_id, msg_ptr, msg_prio, timeout); + status = __svcMessageQueuePut(mq_id, msg_ptr, msg_prio, timeout); } return status; } /// Get a Message from a Queue or timeout if Queue is empty. -osStatus_t osMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout) { +osStatus_t osMessageQueueGet(osMessageQueueId_t mq_id, void *msg_ptr, + uint8_t *msg_prio, uint32_t timeout) { osStatus_t status; EvrRtxMessageQueueGet(mq_id, msg_ptr, msg_prio, timeout); if (IsIrqMode() || IsIrqMasked()) { status = isrRtxMessageQueueGet(mq_id, msg_ptr, msg_prio, timeout); } else { - status = __svcMessageQueueGet(mq_id, msg_ptr, msg_prio, timeout); + status = __svcMessageQueueGet(mq_id, msg_ptr, msg_prio, timeout); } return status; } /// Get maximum number of messages in a Message Queue. -uint32_t osMessageQueueGetCapacity (osMessageQueueId_t mq_id) { +uint32_t osMessageQueueGetCapacity(osMessageQueueId_t mq_id) { uint32_t capacity; if (IsIrqMode() || IsIrqMasked()) { capacity = svcRtxMessageQueueGetCapacity(mq_id); } else { - capacity = __svcMessageQueueGetCapacity(mq_id); + capacity = __svcMessageQueueGetCapacity(mq_id); } return capacity; } /// Get maximum message size in a Memory Pool. -uint32_t osMessageQueueGetMsgSize (osMessageQueueId_t mq_id) { +uint32_t osMessageQueueGetMsgSize(osMessageQueueId_t mq_id) { uint32_t msg_size; if (IsIrqMode() || IsIrqMasked()) { msg_size = svcRtxMessageQueueGetMsgSize(mq_id); } else { - msg_size = __svcMessageQueueGetMsgSize(mq_id); + msg_size = __svcMessageQueueGetMsgSize(mq_id); } return msg_size; } /// Get number of queued messages in a Message Queue. -uint32_t osMessageQueueGetCount (osMessageQueueId_t mq_id) { +uint32_t osMessageQueueGetCount(osMessageQueueId_t mq_id) { uint32_t count; if (IsIrqMode() || IsIrqMasked()) { count = svcRtxMessageQueueGetCount(mq_id); } else { - count = __svcMessageQueueGetCount(mq_id); + count = __svcMessageQueueGetCount(mq_id); } return count; } /// Get number of available slots for messages in a Message Queue. -uint32_t osMessageQueueGetSpace (osMessageQueueId_t mq_id) { +uint32_t osMessageQueueGetSpace(osMessageQueueId_t mq_id) { uint32_t space; if (IsIrqMode() || IsIrqMasked()) { space = svcRtxMessageQueueGetSpace(mq_id); } else { - space = __svcMessageQueueGetSpace(mq_id); + space = __svcMessageQueueGetSpace(mq_id); } return space; } /// Reset a Message Queue to initial empty state. -osStatus_t osMessageQueueReset (osMessageQueueId_t mq_id) { +osStatus_t osMessageQueueReset(osMessageQueueId_t mq_id) { osStatus_t status; EvrRtxMessageQueueReset(mq_id); @@ -934,7 +961,7 @@ osStatus_t osMessageQueueReset (osMessageQueueId_t mq_id) { } /// Delete a Message Queue object. -osStatus_t osMessageQueueDelete (osMessageQueueId_t mq_id) { +osStatus_t osMessageQueueDelete(osMessageQueueId_t mq_id) { osStatus_t status; EvrRtxMessageQueueDelete(mq_id); diff --git a/rtos/rtx5/rtx_mutex.c b/rtos/rtx5/rtx_mutex.c index 1941488..c21ed75 100644 --- a/rtos/rtx5/rtx_mutex.c +++ b/rtos/rtx5/rtx_mutex.c @@ -25,23 +25,20 @@ #include "rtx_lib.h" - // OS Runtime Object Memory Usage #if ((defined(OS_OBJ_MEM_USAGE) && (OS_OBJ_MEM_USAGE != 0))) -osRtxObjectMemUsage_t osRtxMutexMemUsage \ -__attribute__((section(".data.os.mutex.obj"))) = -{ 0U, 0U, 0U }; +osRtxObjectMemUsage_t osRtxMutexMemUsage + __attribute__((section(".data.os.mutex.obj"))) = {0U, 0U, 0U}; #endif - // ==== Library functions ==== /// Release Mutex list when owner Thread terminates. /// \param[in] mutex mutex object. /// \return 1 - success, 0 - failure. -void osRtxMutexOwnerRelease (os_mutex_t *mutex_list) { - os_mutex_t *mutex; - os_mutex_t *mutex_next; +void osRtxMutexOwnerRelease(os_mutex_t *mutex_list) { + os_mutex_t *mutex; + os_mutex_t *mutex_next; os_thread_t *thread; mutex = mutex_list; @@ -59,8 +56,8 @@ void osRtxMutexOwnerRelease (os_mutex_t *mutex_list) { osRtxThreadWaitExit(thread, (uint32_t)osOK, FALSE); // Thread is the new Mutex owner mutex->owner_thread = thread; - mutex->owner_prev = NULL; - mutex->owner_next = thread->mutex_list; + mutex->owner_prev = NULL; + mutex->owner_next = thread->mutex_list; if (thread->mutex_list != NULL) { thread->mutex_list->owner_prev = mutex; } @@ -73,50 +70,54 @@ void osRtxMutexOwnerRelease (os_mutex_t *mutex_list) { } } - // ==== Service Calls ==== /// Create and Initialize a Mutex object. /// \note API identical to osMutexNew -static osMutexId_t svcRtxMutexNew (const osMutexAttr_t *attr) { +static osMutexId_t svcRtxMutexNew(const osMutexAttr_t *attr) { os_mutex_t *mutex; - uint32_t attr_bits; - uint8_t flags; + uint32_t attr_bits; + uint8_t flags; const char *name; // Process attributes if (attr != NULL) { - name = attr->name; + name = attr->name; attr_bits = attr->attr_bits; - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 6] - mutex = attr->cb_mem; + // lint -e{9079} "conversion from pointer to void to pointer to other type" + // [MISRA Note 6] + mutex = attr->cb_mem; if (mutex != NULL) { - //lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note 7] - if ((((uint32_t)mutex & 3U) != 0U) || (attr->cb_size < sizeof(os_mutex_t))) { + // lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note + // 7] + if ((((uint32_t)mutex & 3U) != 0U) || + (attr->cb_size < sizeof(os_mutex_t))) { EvrRtxMutexError(NULL, osRtxErrorInvalidControlBlock); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } else { if (attr->cb_size != 0U) { EvrRtxMutexError(NULL, osRtxErrorInvalidControlBlock); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } } else { - name = NULL; + name = NULL; attr_bits = 0U; - mutex = NULL; + mutex = NULL; } // Allocate object memory if not provided if (mutex == NULL) { if (osRtxInfo.mpi.mutex != NULL) { - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] mutex = osRtxMemoryPoolAlloc(osRtxInfo.mpi.mutex); } else { - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] mutex = osRtxMemoryAlloc(osRtxInfo.mem.common, sizeof(os_mutex_t), 1U); } #if (defined(OS_OBJ_MEM_USAGE) && (OS_OBJ_MEM_USAGE != 0)) @@ -136,15 +137,15 @@ static osMutexId_t svcRtxMutexNew (const osMutexAttr_t *attr) { if (mutex != NULL) { // Initialize control block - mutex->id = osRtxIdMutex; - mutex->flags = flags; - mutex->attr = (uint8_t)attr_bits; - mutex->name = name; - mutex->thread_list = NULL; + mutex->id = osRtxIdMutex; + mutex->flags = flags; + mutex->attr = (uint8_t)attr_bits; + mutex->name = name; + mutex->thread_list = NULL; mutex->owner_thread = NULL; - mutex->owner_prev = NULL; - mutex->owner_next = NULL; - mutex->lock = 0U; + mutex->owner_prev = NULL; + mutex->owner_next = NULL; + mutex->lock = 0U; EvrRtxMutexCreated(mutex, mutex->name); } else { @@ -156,13 +157,13 @@ static osMutexId_t svcRtxMutexNew (const osMutexAttr_t *attr) { /// Get name of a Mutex object. /// \note API identical to osMutexGetName -static const char *svcRtxMutexGetName (osMutexId_t mutex_id) { +static const char *svcRtxMutexGetName(osMutexId_t mutex_id) { os_mutex_t *mutex = osRtxMutexId(mutex_id); // Check parameters if ((mutex == NULL) || (mutex->id != osRtxIdMutex)) { EvrRtxMutexGetName(mutex, NULL); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } @@ -173,23 +174,23 @@ static const char *svcRtxMutexGetName (osMutexId_t mutex_id) { /// Acquire a Mutex or timeout if it is locked. /// \note API identical to osMutexAcquire -static osStatus_t svcRtxMutexAcquire (osMutexId_t mutex_id, uint32_t timeout) { - os_mutex_t *mutex = osRtxMutexId(mutex_id); +static osStatus_t svcRtxMutexAcquire(osMutexId_t mutex_id, uint32_t timeout) { + os_mutex_t *mutex = osRtxMutexId(mutex_id); os_thread_t *thread; - osStatus_t status; + osStatus_t status; // Check running thread thread = osRtxThreadGetRunning(); if (thread == NULL) { EvrRtxMutexError(mutex, osRtxErrorKernelNotRunning); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osError; } // Check parameters if ((mutex == NULL) || (mutex->id != osRtxIdMutex)) { EvrRtxMutexError(mutex, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } @@ -197,8 +198,8 @@ static osStatus_t svcRtxMutexAcquire (osMutexId_t mutex_id, uint32_t timeout) { if (mutex->lock == 0U) { // Acquire Mutex mutex->owner_thread = thread; - mutex->owner_prev = NULL; - mutex->owner_next = thread->mutex_list; + mutex->owner_prev = NULL; + mutex->owner_next = thread->mutex_list; if (thread->mutex_list != NULL) { thread->mutex_list->owner_prev = mutex; } @@ -208,7 +209,8 @@ static osStatus_t svcRtxMutexAcquire (osMutexId_t mutex_id, uint32_t timeout) { status = osOK; } else { // Check if Mutex is recursive and running Thread is the owner - if (((mutex->attr & osMutexRecursive) != 0U) && (mutex->owner_thread == thread)) { + if (((mutex->attr & osMutexRecursive) != 0U) && + (mutex->owner_thread == thread)) { // Try to increment lock counter if (mutex->lock == osRtxMutexLockLimit) { EvrRtxMutexError(mutex, osRtxErrorMutexLockLimit); @@ -223,7 +225,8 @@ static osStatus_t svcRtxMutexAcquire (osMutexId_t mutex_id, uint32_t timeout) { if (timeout != 0U) { // Check if Priority inheritance protocol is enabled if ((mutex->attr & osMutexPrioInherit) != 0U) { - // Raise priority of owner Thread if lower than priority of running Thread + // Raise priority of owner Thread if lower than priority of running + // Thread if (mutex->owner_thread->priority < thread->priority) { mutex->owner_thread->priority = thread->priority; osRtxThreadListSort(mutex->owner_thread); @@ -249,38 +252,38 @@ static osStatus_t svcRtxMutexAcquire (osMutexId_t mutex_id, uint32_t timeout) { /// Release a Mutex that was acquired by osMutexAcquire. /// \note API identical to osMutexRelease -static osStatus_t svcRtxMutexRelease (osMutexId_t mutex_id) { - os_mutex_t *mutex = osRtxMutexId(mutex_id); - const os_mutex_t *mutex0; - os_thread_t *thread; - int8_t priority; +static osStatus_t svcRtxMutexRelease(osMutexId_t mutex_id) { + os_mutex_t *mutex = osRtxMutexId(mutex_id); + const os_mutex_t *mutex0; + os_thread_t *thread; + int8_t priority; // Check running thread thread = osRtxThreadGetRunning(); if (thread == NULL) { EvrRtxMutexError(mutex, osRtxErrorKernelNotRunning); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osError; } // Check parameters if ((mutex == NULL) || (mutex->id != osRtxIdMutex)) { EvrRtxMutexError(mutex, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } // Check if Mutex is not locked if (mutex->lock == 0U) { EvrRtxMutexError(mutex, osRtxErrorMutexNotLocked); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorResource; } // Check if running Thread is not the owner if (mutex->owner_thread != thread) { EvrRtxMutexError(mutex, osRtxErrorMutexNotOwned); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorResource; } @@ -304,10 +307,11 @@ static osStatus_t svcRtxMutexRelease (osMutexId_t mutex_id) { // Restore running Thread priority if ((mutex->attr & osMutexPrioInherit) != 0U) { priority = thread->priority_base; - mutex0 = thread->mutex_list; + mutex0 = thread->mutex_list; while (mutex0 != NULL) { // Mutexes owned by running Thread - if ((mutex0->thread_list != NULL) && (mutex0->thread_list->priority > priority)) { + if ((mutex0->thread_list != NULL) && + (mutex0->thread_list->priority > priority)) { // Higher priority Thread is waiting for Mutex priority = mutex0->thread_list->priority; } @@ -323,8 +327,8 @@ static osStatus_t svcRtxMutexRelease (osMutexId_t mutex_id) { osRtxThreadWaitExit(thread, (uint32_t)osOK, FALSE); // Thread is the new Mutex owner mutex->owner_thread = thread; - mutex->owner_prev = NULL; - mutex->owner_next = thread->mutex_list; + mutex->owner_prev = NULL; + mutex->owner_next = thread->mutex_list; if (thread->mutex_list != NULL) { thread->mutex_list->owner_prev = mutex; } @@ -341,20 +345,20 @@ static osStatus_t svcRtxMutexRelease (osMutexId_t mutex_id) { /// Get Thread which owns a Mutex object. /// \note API identical to osMutexGetOwner -static osThreadId_t svcRtxMutexGetOwner (osMutexId_t mutex_id) { +static osThreadId_t svcRtxMutexGetOwner(osMutexId_t mutex_id) { os_mutex_t *mutex = osRtxMutexId(mutex_id); // Check parameters if ((mutex == NULL) || (mutex->id != osRtxIdMutex)) { EvrRtxMutexGetOwner(mutex, NULL); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } // Check if Mutex is not locked if (mutex->lock == 0U) { EvrRtxMutexGetOwner(mutex, NULL); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } @@ -365,16 +369,16 @@ static osThreadId_t svcRtxMutexGetOwner (osMutexId_t mutex_id) { /// Delete a Mutex object. /// \note API identical to osMutexDelete -static osStatus_t svcRtxMutexDelete (osMutexId_t mutex_id) { - os_mutex_t *mutex = osRtxMutexId(mutex_id); - const os_mutex_t *mutex0; - os_thread_t *thread; - int8_t priority; +static osStatus_t svcRtxMutexDelete(osMutexId_t mutex_id) { + os_mutex_t *mutex = osRtxMutexId(mutex_id); + const os_mutex_t *mutex0; + os_thread_t *thread; + int8_t priority; // Check parameters if ((mutex == NULL) || (mutex->id != osRtxIdMutex)) { EvrRtxMutexError(mutex, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } @@ -396,10 +400,11 @@ static osStatus_t svcRtxMutexDelete (osMutexId_t mutex_id) { // Restore owner Thread priority if ((mutex->attr & osMutexPrioInherit) != 0U) { priority = thread->priority_base; - mutex0 = thread->mutex_list; + mutex0 = thread->mutex_list; while (mutex0 != NULL) { // Mutexes owned by running Thread - if ((mutex0->thread_list != NULL) && (mutex0->thread_list->priority > priority)) { + if ((mutex0->thread_list != NULL) && + (mutex0->thread_list->priority > priority)) { // Higher priority Thread is waiting for Mutex priority = mutex0->thread_list->priority; } @@ -441,20 +446,19 @@ static osStatus_t svcRtxMutexDelete (osMutexId_t mutex_id) { } // Service Calls definitions -//lint ++flb "Library Begin" [MISRA Note 11] -SVC0_1(MutexNew, osMutexId_t, const osMutexAttr_t *) -SVC0_1(MutexGetName, const char *, osMutexId_t) -SVC0_2(MutexAcquire, osStatus_t, osMutexId_t, uint32_t) -SVC0_1(MutexRelease, osStatus_t, osMutexId_t) +// lint ++flb "Library Begin" [MISRA Note 11] +SVC0_1(MutexNew, osMutexId_t, const osMutexAttr_t *) +SVC0_1(MutexGetName, const char *, osMutexId_t) +SVC0_2(MutexAcquire, osStatus_t, osMutexId_t, uint32_t) +SVC0_1(MutexRelease, osStatus_t, osMutexId_t) SVC0_1(MutexGetOwner, osThreadId_t, osMutexId_t) -SVC0_1(MutexDelete, osStatus_t, osMutexId_t) -//lint --flb "Library End" - +SVC0_1(MutexDelete, osStatus_t, osMutexId_t) +// lint --flb "Library End" // ==== Public API ==== /// Create and Initialize a Mutex object. -osMutexId_t osMutexNew (const osMutexAttr_t *attr) { +osMutexId_t osMutexNew(const osMutexAttr_t *attr) { osMutexId_t mutex_id; EvrRtxMutexNew(attr); @@ -468,7 +472,7 @@ osMutexId_t osMutexNew (const osMutexAttr_t *attr) { } /// Get name of a Mutex object. -const char *osMutexGetName (osMutexId_t mutex_id) { +const char *osMutexGetName(osMutexId_t mutex_id) { const char *name; if (IsIrqMode() || IsIrqMasked()) { @@ -481,7 +485,7 @@ const char *osMutexGetName (osMutexId_t mutex_id) { } /// Acquire a Mutex or timeout if it is locked. -osStatus_t osMutexAcquire (osMutexId_t mutex_id, uint32_t timeout) { +osStatus_t osMutexAcquire(osMutexId_t mutex_id, uint32_t timeout) { osStatus_t status; EvrRtxMutexAcquire(mutex_id, timeout); @@ -495,7 +499,7 @@ osStatus_t osMutexAcquire (osMutexId_t mutex_id, uint32_t timeout) { } /// Release a Mutex that was acquired by \ref osMutexAcquire. -osStatus_t osMutexRelease (osMutexId_t mutex_id) { +osStatus_t osMutexRelease(osMutexId_t mutex_id) { osStatus_t status; EvrRtxMutexRelease(mutex_id); @@ -509,7 +513,7 @@ osStatus_t osMutexRelease (osMutexId_t mutex_id) { } /// Get Thread which owns a Mutex object. -osThreadId_t osMutexGetOwner (osMutexId_t mutex_id) { +osThreadId_t osMutexGetOwner(osMutexId_t mutex_id) { osThreadId_t thread; if (IsIrqMode() || IsIrqMasked()) { @@ -522,7 +526,7 @@ osThreadId_t osMutexGetOwner (osMutexId_t mutex_id) { } /// Delete a Mutex object. -osStatus_t osMutexDelete (osMutexId_t mutex_id) { +osStatus_t osMutexDelete(osMutexId_t mutex_id) { osStatus_t status; EvrRtxMutexDelete(mutex_id); diff --git a/rtos/rtx5/rtx_semaphore.c b/rtos/rtx5/rtx_semaphore.c index ebca855..90f9b2c 100644 --- a/rtos/rtx5/rtx_semaphore.c +++ b/rtos/rtx5/rtx_semaphore.c @@ -25,21 +25,18 @@ #include "rtx_lib.h" - // OS Runtime Object Memory Usage #if ((defined(OS_OBJ_MEM_USAGE) && (OS_OBJ_MEM_USAGE != 0))) -osRtxObjectMemUsage_t osRtxSemaphoreMemUsage \ -__attribute__((section(".data.os.semaphore.obj"))) = -{ 0U, 0U, 0U }; +osRtxObjectMemUsage_t osRtxSemaphoreMemUsage + __attribute__((section(".data.os.semaphore.obj"))) = {0U, 0U, 0U}; #endif - // ==== Helper functions ==== /// Decrement Semaphore tokens. /// \param[in] semaphore semaphore object. /// \return 1 - success, 0 - failure. -static uint32_t SemaphoreTokenDecrement (os_semaphore_t *semaphore) { +static uint32_t SemaphoreTokenDecrement(os_semaphore_t *semaphore) { #if (EXCLUSIVE_ACCESS == 0) uint32_t primask = __get_PRIMASK(); #endif @@ -72,7 +69,7 @@ static uint32_t SemaphoreTokenDecrement (os_semaphore_t *semaphore) { /// Increment Semaphore tokens. /// \param[in] semaphore semaphore object. /// \return 1 - success, 0 - failure. -static uint32_t SemaphoreTokenIncrement (os_semaphore_t *semaphore) { +static uint32_t SemaphoreTokenIncrement(os_semaphore_t *semaphore) { #if (EXCLUSIVE_ACCESS == 0) uint32_t primask = __get_PRIMASK(); #endif @@ -92,7 +89,8 @@ static uint32_t SemaphoreTokenIncrement (os_semaphore_t *semaphore) { __enable_irq(); } #else - if (atomic_inc16_lt(&semaphore->tokens, semaphore->max_tokens) < semaphore->max_tokens) { + if (atomic_inc16_lt(&semaphore->tokens, semaphore->max_tokens) < + semaphore->max_tokens) { ret = 1U; } else { ret = 0U; @@ -102,12 +100,11 @@ static uint32_t SemaphoreTokenIncrement (os_semaphore_t *semaphore) { return ret; } - // ==== Post ISR processing ==== /// Semaphore post ISR processing. /// \param[in] semaphore semaphore object. -static void osRtxSemaphorePostProcess (os_semaphore_t *semaphore) { +static void osRtxSemaphorePostProcess(os_semaphore_t *semaphore) { os_thread_t *thread; // Check if Thread is waiting for a token @@ -122,55 +119,63 @@ static void osRtxSemaphorePostProcess (os_semaphore_t *semaphore) { } } - // ==== Service Calls ==== /// Create and Initialize a Semaphore object. /// \note API identical to osSemaphoreNew -static osSemaphoreId_t svcRtxSemaphoreNew (uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr) { +static osSemaphoreId_t svcRtxSemaphoreNew(uint32_t max_count, + uint32_t initial_count, + const osSemaphoreAttr_t *attr) { os_semaphore_t *semaphore; - uint8_t flags; - const char *name; + uint8_t flags; + const char *name; // Check parameters - if ((max_count == 0U) || (max_count > osRtxSemaphoreTokenLimit) || (initial_count > max_count)) { + if ((max_count == 0U) || (max_count > osRtxSemaphoreTokenLimit) || + (initial_count > max_count)) { EvrRtxSemaphoreError(NULL, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } // Process attributes if (attr != NULL) { - name = attr->name; - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 6] + name = attr->name; + // lint -e{9079} "conversion from pointer to void to pointer to other type" + // [MISRA Note 6] semaphore = attr->cb_mem; if (semaphore != NULL) { - //lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note 7] - if ((((uint32_t)semaphore & 3U) != 0U) || (attr->cb_size < sizeof(os_semaphore_t))) { + // lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note + // 7] + if ((((uint32_t)semaphore & 3U) != 0U) || + (attr->cb_size < sizeof(os_semaphore_t))) { EvrRtxSemaphoreError(NULL, osRtxErrorInvalidControlBlock); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } else { if (attr->cb_size != 0U) { EvrRtxSemaphoreError(NULL, osRtxErrorInvalidControlBlock); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } } else { - name = NULL; + name = NULL; semaphore = NULL; } // Allocate object memory if not provided if (semaphore == NULL) { if (osRtxInfo.mpi.semaphore != NULL) { - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] semaphore = osRtxMemoryPoolAlloc(osRtxInfo.mpi.semaphore); } else { - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] - semaphore = osRtxMemoryAlloc(osRtxInfo.mem.common, sizeof(os_semaphore_t), 1U); + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] + semaphore = + osRtxMemoryAlloc(osRtxInfo.mem.common, sizeof(os_semaphore_t), 1U); } #if (defined(OS_OBJ_MEM_USAGE) && (OS_OBJ_MEM_USAGE != 0)) if (semaphore != NULL) { @@ -189,19 +194,19 @@ static osSemaphoreId_t svcRtxSemaphoreNew (uint32_t max_count, uint32_t initial_ if (semaphore != NULL) { // Initialize control block - semaphore->id = osRtxIdSemaphore; - semaphore->flags = flags; - semaphore->name = name; + semaphore->id = osRtxIdSemaphore; + semaphore->flags = flags; + semaphore->name = name; semaphore->thread_list = NULL; - semaphore->tokens = (uint16_t)initial_count; - semaphore->max_tokens = (uint16_t)max_count; + semaphore->tokens = (uint16_t)initial_count; + semaphore->max_tokens = (uint16_t)max_count; // Register post ISR processing function osRtxInfo.post_process.semaphore = osRtxSemaphorePostProcess; EvrRtxSemaphoreCreated(semaphore, semaphore->name); } else { - EvrRtxSemaphoreError(NULL,(int32_t)osErrorNoMemory); + EvrRtxSemaphoreError(NULL, (int32_t)osErrorNoMemory); } return semaphore; @@ -209,13 +214,13 @@ static osSemaphoreId_t svcRtxSemaphoreNew (uint32_t max_count, uint32_t initial_ /// Get name of a Semaphore object. /// \note API identical to osSemaphoreGetName -static const char *svcRtxSemaphoreGetName (osSemaphoreId_t semaphore_id) { +static const char *svcRtxSemaphoreGetName(osSemaphoreId_t semaphore_id) { os_semaphore_t *semaphore = osRtxSemaphoreId(semaphore_id); // Check parameters if ((semaphore == NULL) || (semaphore->id != osRtxIdSemaphore)) { EvrRtxSemaphoreGetName(semaphore, NULL); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } @@ -226,14 +231,15 @@ static const char *svcRtxSemaphoreGetName (osSemaphoreId_t semaphore_id) { /// Acquire a Semaphore token or timeout if no tokens are available. /// \note API identical to osSemaphoreAcquire -static osStatus_t svcRtxSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout) { +static osStatus_t svcRtxSemaphoreAcquire(osSemaphoreId_t semaphore_id, + uint32_t timeout) { os_semaphore_t *semaphore = osRtxSemaphoreId(semaphore_id); - osStatus_t status; + osStatus_t status; // Check parameters if ((semaphore == NULL) || (semaphore->id != osRtxIdSemaphore)) { EvrRtxSemaphoreError(semaphore, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } @@ -263,15 +269,15 @@ static osStatus_t svcRtxSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t /// Release a Semaphore token that was acquired by osSemaphoreAcquire. /// \note API identical to osSemaphoreRelease -static osStatus_t svcRtxSemaphoreRelease (osSemaphoreId_t semaphore_id) { +static osStatus_t svcRtxSemaphoreRelease(osSemaphoreId_t semaphore_id) { os_semaphore_t *semaphore = osRtxSemaphoreId(semaphore_id); - os_thread_t *thread; - osStatus_t status; + os_thread_t *thread; + osStatus_t status; // Check parameters if ((semaphore == NULL) || (semaphore->id != osRtxIdSemaphore)) { EvrRtxSemaphoreError(semaphore, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } @@ -299,13 +305,13 @@ static osStatus_t svcRtxSemaphoreRelease (osSemaphoreId_t semaphore_id) { /// Get current Semaphore token count. /// \note API identical to osSemaphoreGetCount -static uint32_t svcRtxSemaphoreGetCount (osSemaphoreId_t semaphore_id) { +static uint32_t svcRtxSemaphoreGetCount(osSemaphoreId_t semaphore_id) { os_semaphore_t *semaphore = osRtxSemaphoreId(semaphore_id); // Check parameters if ((semaphore == NULL) || (semaphore->id != osRtxIdSemaphore)) { EvrRtxSemaphoreGetCount(semaphore, 0U); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } @@ -316,14 +322,14 @@ static uint32_t svcRtxSemaphoreGetCount (osSemaphoreId_t semaphore_id) { /// Delete a Semaphore object. /// \note API identical to osSemaphoreDelete -static osStatus_t svcRtxSemaphoreDelete (osSemaphoreId_t semaphore_id) { +static osStatus_t svcRtxSemaphoreDelete(osSemaphoreId_t semaphore_id) { os_semaphore_t *semaphore = osRtxSemaphoreId(semaphore_id); - os_thread_t *thread; + os_thread_t *thread; // Check parameters if ((semaphore == NULL) || (semaphore->id != osRtxIdSemaphore)) { EvrRtxSemaphoreError(semaphore, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } @@ -357,29 +363,31 @@ static osStatus_t svcRtxSemaphoreDelete (osSemaphoreId_t semaphore_id) { } // Service Calls definitions -//lint ++flb "Library Begin" [MISRA Note 11] -SVC0_3(SemaphoreNew, osSemaphoreId_t, uint32_t, uint32_t, const osSemaphoreAttr_t *) -SVC0_1(SemaphoreGetName, const char *, osSemaphoreId_t) -SVC0_2(SemaphoreAcquire, osStatus_t, osSemaphoreId_t, uint32_t) -SVC0_1(SemaphoreRelease, osStatus_t, osSemaphoreId_t) -SVC0_1(SemaphoreGetCount, uint32_t, osSemaphoreId_t) -SVC0_1(SemaphoreDelete, osStatus_t, osSemaphoreId_t) -//lint --flb "Library End" - +// lint ++flb "Library Begin" [MISRA Note 11] +SVC0_3(SemaphoreNew, osSemaphoreId_t, uint32_t, uint32_t, + const osSemaphoreAttr_t *) +SVC0_1(SemaphoreGetName, const char *, osSemaphoreId_t) +SVC0_2(SemaphoreAcquire, osStatus_t, osSemaphoreId_t, uint32_t) +SVC0_1(SemaphoreRelease, osStatus_t, osSemaphoreId_t) +SVC0_1(SemaphoreGetCount, uint32_t, osSemaphoreId_t) +SVC0_1(SemaphoreDelete, osStatus_t, osSemaphoreId_t) +// lint --flb "Library End" // ==== ISR Calls ==== /// Acquire a Semaphore token or timeout if no tokens are available. /// \note API identical to osSemaphoreAcquire __STATIC_INLINE -osStatus_t isrRtxSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout) { +osStatus_t isrRtxSemaphoreAcquire(osSemaphoreId_t semaphore_id, + uint32_t timeout) { os_semaphore_t *semaphore = osRtxSemaphoreId(semaphore_id); - osStatus_t status; + osStatus_t status; // Check parameters - if ((semaphore == NULL) || (semaphore->id != osRtxIdSemaphore) || (timeout != 0U)) { + if ((semaphore == NULL) || (semaphore->id != osRtxIdSemaphore) || + (timeout != 0U)) { EvrRtxSemaphoreError(semaphore, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } @@ -399,14 +407,14 @@ osStatus_t isrRtxSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeou /// Release a Semaphore token that was acquired by osSemaphoreAcquire. /// \note API identical to osSemaphoreRelease __STATIC_INLINE -osStatus_t isrRtxSemaphoreRelease (osSemaphoreId_t semaphore_id) { +osStatus_t isrRtxSemaphoreRelease(osSemaphoreId_t semaphore_id) { os_semaphore_t *semaphore = osRtxSemaphoreId(semaphore_id); - osStatus_t status; + osStatus_t status; // Check parameters if ((semaphore == NULL) || (semaphore->id != osRtxIdSemaphore)) { EvrRtxSemaphoreError(semaphore, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } @@ -424,11 +432,11 @@ osStatus_t isrRtxSemaphoreRelease (osSemaphoreId_t semaphore_id) { return status; } - // ==== Public API ==== /// Create and Initialize a Semaphore object. -osSemaphoreId_t osSemaphoreNew (uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr) { +osSemaphoreId_t osSemaphoreNew(uint32_t max_count, uint32_t initial_count, + const osSemaphoreAttr_t *attr) { osSemaphoreId_t semaphore_id; EvrRtxSemaphoreNew(max_count, initial_count, attr); @@ -442,7 +450,7 @@ osSemaphoreId_t osSemaphoreNew (uint32_t max_count, uint32_t initial_count, cons } /// Get name of a Semaphore object. -const char *osSemaphoreGetName (osSemaphoreId_t semaphore_id) { +const char *osSemaphoreGetName(osSemaphoreId_t semaphore_id) { const char *name; if (IsIrqMode() || IsIrqMasked()) { @@ -455,45 +463,45 @@ const char *osSemaphoreGetName (osSemaphoreId_t semaphore_id) { } /// Acquire a Semaphore token or timeout if no tokens are available. -osStatus_t osSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout) { +osStatus_t osSemaphoreAcquire(osSemaphoreId_t semaphore_id, uint32_t timeout) { osStatus_t status; EvrRtxSemaphoreAcquire(semaphore_id, timeout); if (IsIrqMode() || IsIrqMasked()) { status = isrRtxSemaphoreAcquire(semaphore_id, timeout); } else { - status = __svcSemaphoreAcquire(semaphore_id, timeout); + status = __svcSemaphoreAcquire(semaphore_id, timeout); } return status; } /// Release a Semaphore token that was acquired by osSemaphoreAcquire. -osStatus_t osSemaphoreRelease (osSemaphoreId_t semaphore_id) { +osStatus_t osSemaphoreRelease(osSemaphoreId_t semaphore_id) { osStatus_t status; EvrRtxSemaphoreRelease(semaphore_id); if (IsIrqMode() || IsIrqMasked()) { status = isrRtxSemaphoreRelease(semaphore_id); } else { - status = __svcSemaphoreRelease(semaphore_id); + status = __svcSemaphoreRelease(semaphore_id); } return status; } /// Get current Semaphore token count. -uint32_t osSemaphoreGetCount (osSemaphoreId_t semaphore_id) { +uint32_t osSemaphoreGetCount(osSemaphoreId_t semaphore_id) { uint32_t count; if (IsIrqMode() || IsIrqMasked()) { count = svcRtxSemaphoreGetCount(semaphore_id); } else { - count = __svcSemaphoreGetCount(semaphore_id); + count = __svcSemaphoreGetCount(semaphore_id); } return count; } /// Delete a Semaphore object. -osStatus_t osSemaphoreDelete (osSemaphoreId_t semaphore_id) { +osStatus_t osSemaphoreDelete(osSemaphoreId_t semaphore_id) { osStatus_t status; EvrRtxSemaphoreDelete(semaphore_id); diff --git a/rtos/rtx5/rtx_system.c b/rtos/rtx5/rtx_system.c index 06e18b7..3b9df29 100644 --- a/rtos/rtx5/rtx_system.c +++ b/rtos/rtx5/rtx_system.c @@ -25,13 +25,12 @@ #include "rtx_lib.h" - // ==== Helper functions ==== /// Put Object into ISR Queue. /// \param[in] object object. /// \return 1 - success, 0 - failure. -static uint32_t isr_queue_put (os_object_t *object) { +static uint32_t isr_queue_put(os_object_t *object) { #if (EXCLUSIVE_ACCESS == 0) uint32_t primask = __get_PRIMASK(); #else @@ -74,11 +73,11 @@ static uint32_t isr_queue_put (os_object_t *object) { /// Get Object from ISR Queue. /// \return object or NULL. -static os_object_t *isr_queue_get (void) { +static os_object_t *isr_queue_get(void) { #if (EXCLUSIVE_ACCESS != 0) - uint32_t n; + uint32_t n; #endif - uint16_t max; + uint16_t max; os_object_t *ret; max = osRtxInfo.isr_queue.max; @@ -109,14 +108,13 @@ static os_object_t *isr_queue_get (void) { return ret; } - // ==== Library Functions ==== /// Tick Handler. -//lint -esym(714,osRtxTick_Handler) "Referenced by Exception handlers" -//lint -esym(759,osRtxTick_Handler) "Prototype in header" -//lint -esym(765,osRtxTick_Handler) "Global scope" -void osRtxTick_Handler (void) { +// lint -esym(714,osRtxTick_Handler) "Referenced by Exception handlers" +// lint -esym(759,osRtxTick_Handler) "Prototype in header" +// lint -esym(765,osRtxTick_Handler) "Global scope" +void osRtxTick_Handler(void) { os_thread_t *thread; OS_Tick_AcknowledgeIRQ(); @@ -141,7 +139,7 @@ void osRtxTick_Handler (void) { if (osRtxInfo.thread.robin.thread != osRtxInfo.thread.run.next) { // Reset Round Robin osRtxInfo.thread.robin.thread = osRtxInfo.thread.run.next; - osRtxInfo.thread.robin.tick = osRtxInfo.thread.robin.timeout; + osRtxInfo.thread.robin.tick = osRtxInfo.thread.robin.timeout; } else { if (osRtxInfo.thread.robin.tick != 0U) { osRtxInfo.thread.robin.tick--; @@ -150,13 +148,14 @@ void osRtxTick_Handler (void) { // Round Robin Timeout if (osRtxKernelGetState() == osRtxKernelRunning) { thread = osRtxInfo.thread.ready.thread_list; - if ((thread != NULL) && (thread->priority == osRtxInfo.thread.robin.thread->priority)) { + if ((thread != NULL) && + (thread->priority == osRtxInfo.thread.robin.thread->priority)) { osRtxThreadListRemove(thread); osRtxThreadReadyPut(osRtxInfo.thread.robin.thread); EvrRtxThreadPreempted(osRtxInfo.thread.robin.thread); osRtxThreadSwitch(thread); osRtxInfo.thread.robin.thread = thread; - osRtxInfo.thread.robin.tick = osRtxInfo.thread.robin.timeout; + osRtxInfo.thread.robin.tick = osRtxInfo.thread.robin.timeout; } } } @@ -165,10 +164,10 @@ void osRtxTick_Handler (void) { } /// Pending Service Call Handler. -//lint -esym(714,osRtxPendSV_Handler) "Referenced by Exception handlers" -//lint -esym(759,osRtxPendSV_Handler) "Prototype in header" -//lint -esym(765,osRtxPendSV_Handler) "Global scope" -void osRtxPendSV_Handler (void) { +// lint -esym(714,osRtxPendSV_Handler) "Referenced by Exception handlers" +// lint -esym(759,osRtxPendSV_Handler) "Prototype in header" +// lint -esym(765,osRtxPendSV_Handler) "Global scope" +void osRtxPendSV_Handler(void) { os_object_t *object; for (;;) { @@ -177,24 +176,24 @@ void osRtxPendSV_Handler (void) { break; } switch (object->id) { - case osRtxIdThread: - osRtxInfo.post_process.thread(osRtxThreadObject(object)); - break; - case osRtxIdEventFlags: - osRtxInfo.post_process.event_flags(osRtxEventFlagsObject(object)); - break; - case osRtxIdSemaphore: - osRtxInfo.post_process.semaphore(osRtxSemaphoreObject(object)); - break; - case osRtxIdMemoryPool: - osRtxInfo.post_process.memory_pool(osRtxMemoryPoolObject(object)); - break; - case osRtxIdMessage: - osRtxInfo.post_process.message(osRtxMessageObject(object)); - break; - default: - // Should never come here - break; + case osRtxIdThread: + osRtxInfo.post_process.thread(osRtxThreadObject(object)); + break; + case osRtxIdEventFlags: + osRtxInfo.post_process.event_flags(osRtxEventFlagsObject(object)); + break; + case osRtxIdSemaphore: + osRtxInfo.post_process.semaphore(osRtxSemaphoreObject(object)); + break; + case osRtxIdMemoryPool: + osRtxInfo.post_process.memory_pool(osRtxMemoryPoolObject(object)); + break; + case osRtxIdMessage: + osRtxInfo.post_process.message(osRtxMessageObject(object)); + break; + default: + // Should never come here + break; } } @@ -203,7 +202,7 @@ void osRtxPendSV_Handler (void) { /// Register post ISR processing. /// \param[in] object generic object. -void osRtxPostProcess (os_object_t *object) { +void osRtxPostProcess(os_object_t *object) { if (isr_queue_put(object) != 0U) { if (osRtxInfo.kernel.blocked == 0U) { diff --git a/rtos/rtx5/rtx_thread.c b/rtos/rtx5/rtx_thread.c index 5b3ae27..ed2497d 100644 --- a/rtos/rtx5/rtx_thread.c +++ b/rtos/rtx5/rtx_thread.c @@ -23,21 +23,17 @@ * ----------------------------------------------------------------------------- */ -#include "rtx_lib.h" #include "hal_timer.h" +#include "rtx_lib.h" // OS Runtime Object Memory Usage #if ((defined(OS_OBJ_MEM_USAGE) && (OS_OBJ_MEM_USAGE != 0))) -osRtxObjectMemUsage_t osRtxThreadMemUsage \ -__attribute__((section(".data.os.thread.obj"))) = -{ 0U, 0U, 0U }; +osRtxObjectMemUsage_t osRtxThreadMemUsage + __attribute__((section(".data.os.thread.obj"))) = {0U, 0U, 0U}; #endif #if __RTX_CPU_STATISTICS__ -uint32_t rtx_get_hwticks(void) -{ - return hal_sys_timer_get(); -} +uint32_t rtx_get_hwticks(void) { return hal_sys_timer_get(); } #endif // ==== Helper functions ==== @@ -46,7 +42,7 @@ uint32_t rtx_get_hwticks(void) /// \param[in] thread thread object. /// \param[in] flags specifies the flags to set. /// \return thread flags after setting. -static uint32_t ThreadFlagsSet (os_thread_t *thread, uint32_t flags) { +static uint32_t ThreadFlagsSet(os_thread_t *thread, uint32_t flags) { #if (EXCLUSIVE_ACCESS == 0) uint32_t primask = __get_PRIMASK(); #endif @@ -72,7 +68,7 @@ static uint32_t ThreadFlagsSet (os_thread_t *thread, uint32_t flags) { /// \param[in] thread thread object. /// \param[in] flags specifies the flags to clear. /// \return thread flags before clearing. -static uint32_t ThreadFlagsClear (os_thread_t *thread, uint32_t flags) { +static uint32_t ThreadFlagsClear(os_thread_t *thread, uint32_t flags) { #if (EXCLUSIVE_ACCESS == 0) uint32_t primask = __get_PRIMASK(); #endif @@ -98,8 +94,10 @@ static uint32_t ThreadFlagsClear (os_thread_t *thread, uint32_t flags) { /// \param[in] thread thread object. /// \param[in] flags specifies the flags to check. /// \param[in] options specifies flags options (osFlagsXxxx). -/// \return thread flags before clearing or 0 if specified flags have not been set. -static uint32_t ThreadFlagsCheck (os_thread_t *thread, uint32_t flags, uint32_t options) { +/// \return thread flags before clearing or 0 if specified flags have not been +/// set. +static uint32_t ThreadFlagsCheck(os_thread_t *thread, uint32_t flags, + uint32_t options) { #if (EXCLUSIVE_ACCESS == 0) uint32_t primask; #endif @@ -111,8 +109,10 @@ static uint32_t ThreadFlagsCheck (os_thread_t *thread, uint32_t flags, uint32_t __disable_irq(); thread_flags = thread->thread_flags; - if ((((options & osFlagsWaitAll) != 0U) && ((thread_flags & flags) != flags)) || - (((options & osFlagsWaitAll) == 0U) && ((thread_flags & flags) == 0U))) { + if ((((options & osFlagsWaitAll) != 0U) && + ((thread_flags & flags) != flags)) || + (((options & osFlagsWaitAll) == 0U) && + ((thread_flags & flags) == 0U))) { thread_flags = 0U; } else { thread->thread_flags &= ~flags; @@ -130,8 +130,10 @@ static uint32_t ThreadFlagsCheck (os_thread_t *thread, uint32_t flags, uint32_t #endif } else { thread_flags = thread->thread_flags; - if ((((options & osFlagsWaitAll) != 0U) && ((thread_flags & flags) != flags)) || - (((options & osFlagsWaitAll) == 0U) && ((thread_flags & flags) == 0U))) { + if ((((options & osFlagsWaitAll) != 0U) && + ((thread_flags & flags) != flags)) || + (((options & osFlagsWaitAll) == 0U) && + ((thread_flags & flags) == 0U))) { thread_flags = 0U; } } @@ -139,15 +141,14 @@ static uint32_t ThreadFlagsCheck (os_thread_t *thread, uint32_t flags, uint32_t return thread_flags; } - // ==== Library functions ==== -/// Put a Thread into specified Object list sorted by Priority (Highest at Head). -/// \param[in] object generic object. -/// \param[in] thread thread object. -void osRtxThreadListPut (os_object_t *object, os_thread_t *thread) { +/// Put a Thread into specified Object list sorted by Priority (Highest at +/// Head). \param[in] object generic object. \param[in] thread thread +/// object. +void osRtxThreadListPut(os_object_t *object, os_thread_t *thread) { os_thread_t *prev, *next; - int32_t priority; + int32_t priority; priority = thread->priority; @@ -168,7 +169,7 @@ void osRtxThreadListPut (os_object_t *object, os_thread_t *thread) { /// Get a Thread with Highest Priority from specified Object list and remove it. /// \param[in] object generic object. /// \return thread object. -os_thread_t *osRtxThreadListGet (os_object_t *object) { +os_thread_t *osRtxThreadListGet(os_object_t *object) { os_thread_t *thread; thread = object->thread_list; @@ -181,17 +182,23 @@ os_thread_t *osRtxThreadListGet (os_object_t *object) { return thread; } -#if (!defined(EVR_RTX_DISABLE) && \ - (((OS_EVR_EVFLAGS != 0) && !defined(EVR_RTX_EVENT_FLAGS_WAIT_TIMEOUT_DISABLE)) || \ - ((OS_EVR_MUTEX != 0) && !defined(EVR_RTX_MUTEX_ACQUIRE_TIMEOUT_DISABLE)) || \ - ((OS_EVR_SEMAPHORE != 0) && !defined(EVR_RTX_SEMAPHORE_ACQUIRE_TIMEOUT_DISABLE)) || \ - ((OS_EVR_MEMPOOL != 0) && !defined(EVR_RTX_MEMORY_POOL_ALLOC_TIMEOUT_DISABLE)) || \ - ((OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_GET_TIMEOUT_DISABLE)) || \ - ((OS_EVR_MSGQUEUE != 0) && !defined(EVR_RTX_MESSAGE_QUEUE_PUT_TIMEOUT_DISABLE)))) +#if (!defined(EVR_RTX_DISABLE) && \ + (((OS_EVR_EVFLAGS != 0) && \ + !defined(EVR_RTX_EVENT_FLAGS_WAIT_TIMEOUT_DISABLE)) || \ + ((OS_EVR_MUTEX != 0) && \ + !defined(EVR_RTX_MUTEX_ACQUIRE_TIMEOUT_DISABLE)) || \ + ((OS_EVR_SEMAPHORE != 0) && \ + !defined(EVR_RTX_SEMAPHORE_ACQUIRE_TIMEOUT_DISABLE)) || \ + ((OS_EVR_MEMPOOL != 0) && \ + !defined(EVR_RTX_MEMORY_POOL_ALLOC_TIMEOUT_DISABLE)) || \ + ((OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_GET_TIMEOUT_DISABLE)) || \ + ((OS_EVR_MSGQUEUE != 0) && \ + !defined(EVR_RTX_MESSAGE_QUEUE_PUT_TIMEOUT_DISABLE)))) /// Retrieve Thread list root. /// \param[in] thread thread object. -static void *osRtxThreadListRoot (os_thread_t *thread) { +static void *osRtxThreadListRoot(os_thread_t *thread) { os_thread_t *thread0; thread0 = thread; @@ -205,7 +212,7 @@ static void *osRtxThreadListRoot (os_thread_t *thread) { /// Re-sort a Thread in linked Object list by Priority (Highest at Head). /// \param[in] thread thread object. -void osRtxThreadListSort (os_thread_t *thread) { +void osRtxThreadListSort(os_thread_t *thread) { os_object_t *object; os_thread_t *thread0; @@ -224,7 +231,7 @@ void osRtxThreadListSort (os_thread_t *thread) { /// Remove a Thread from linked Object list. /// \param[in] thread thread object. -void osRtxThreadListRemove (os_thread_t *thread) { +void osRtxThreadListRemove(os_thread_t *thread) { if (thread->thread_prev != NULL) { thread->thread_prev->thread_next = thread->thread_next; @@ -237,7 +244,8 @@ void osRtxThreadListRemove (os_thread_t *thread) { /// Unlink a Thread from specified linked list. /// \param[in] thread thread object. -static void osRtxThreadListUnlink (os_thread_t **thread_list, os_thread_t *thread) { +static void osRtxThreadListUnlink(os_thread_t **thread_list, + os_thread_t *thread) { if (thread->thread_next != NULL) { thread->thread_next->thread_prev = thread->thread_prev; @@ -252,7 +260,7 @@ static void osRtxThreadListUnlink (os_thread_t **thread_list, os_thread_t *threa /// Mark a Thread as Ready and put it into Ready list (sorted by Priority). /// \param[in] thread thread object. -void osRtxThreadReadyPut (os_thread_t *thread) { +void osRtxThreadReadyPut(os_thread_t *thread) { thread->state = osRtxThreadReady; osRtxThreadListPut(&osRtxInfo.thread.ready, thread); @@ -261,13 +269,13 @@ void osRtxThreadReadyPut (os_thread_t *thread) { /// Insert a Thread into the Delay list sorted by Delay (Lowest at Head). /// \param[in] thread thread object. /// \param[in] delay delay value. -static void osRtxThreadDelayInsert (os_thread_t *thread, uint32_t delay) { +static void osRtxThreadDelayInsert(os_thread_t *thread, uint32_t delay) { os_thread_t *prev, *next; if (delay == osWaitForever) { prev = NULL; next = osRtxInfo.thread.wait_list; - while (next != NULL) { + while (next != NULL) { prev = next; next = next->delay_next; } @@ -304,7 +312,7 @@ static void osRtxThreadDelayInsert (os_thread_t *thread, uint32_t delay) { /// Remove a Thread from the Delay list. /// \param[in] thread thread object. -static void osRtxThreadDelayRemove (os_thread_t *thread) { +static void osRtxThreadDelayRemove(os_thread_t *thread) { if (thread->delay == osWaitForever) { if (thread->delay_next != NULL) { @@ -331,12 +339,12 @@ static void osRtxThreadDelayRemove (os_thread_t *thread) { } /// Process Thread Delay Tick (executed each System Tick). -void osRtxThreadDelayTick (void) { +void osRtxThreadDelayTick(void) { os_thread_t *thread; thread = osRtxInfo.thread.delay_list; if (thread == NULL) { - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return; } @@ -345,33 +353,38 @@ void osRtxThreadDelayTick (void) { if (thread->delay == 0U) { do { switch (thread->state) { - case osRtxThreadWaitingDelay: - EvrRtxDelayCompleted(thread); - break; - case osRtxThreadWaitingThreadFlags: - EvrRtxThreadFlagsWaitTimeout(thread); - break; - case osRtxThreadWaitingEventFlags: - EvrRtxEventFlagsWaitTimeout((osEventFlagsId_t)osRtxThreadListRoot(thread)); - break; - case osRtxThreadWaitingMutex: - EvrRtxMutexAcquireTimeout((osMutexId_t)osRtxThreadListRoot(thread)); - break; - case osRtxThreadWaitingSemaphore: - EvrRtxSemaphoreAcquireTimeout((osSemaphoreId_t)osRtxThreadListRoot(thread)); - break; - case osRtxThreadWaitingMemoryPool: - EvrRtxMemoryPoolAllocTimeout((osMemoryPoolId_t)osRtxThreadListRoot(thread)); - break; - case osRtxThreadWaitingMessageGet: - EvrRtxMessageQueueGetTimeout((osMessageQueueId_t)osRtxThreadListRoot(thread)); - break; - case osRtxThreadWaitingMessagePut: - EvrRtxMessageQueuePutTimeout((osMessageQueueId_t)osRtxThreadListRoot(thread)); - break; - default: - // Invalid - break; + case osRtxThreadWaitingDelay: + EvrRtxDelayCompleted(thread); + break; + case osRtxThreadWaitingThreadFlags: + EvrRtxThreadFlagsWaitTimeout(thread); + break; + case osRtxThreadWaitingEventFlags: + EvrRtxEventFlagsWaitTimeout( + (osEventFlagsId_t)osRtxThreadListRoot(thread)); + break; + case osRtxThreadWaitingMutex: + EvrRtxMutexAcquireTimeout((osMutexId_t)osRtxThreadListRoot(thread)); + break; + case osRtxThreadWaitingSemaphore: + EvrRtxSemaphoreAcquireTimeout( + (osSemaphoreId_t)osRtxThreadListRoot(thread)); + break; + case osRtxThreadWaitingMemoryPool: + EvrRtxMemoryPoolAllocTimeout( + (osMemoryPoolId_t)osRtxThreadListRoot(thread)); + break; + case osRtxThreadWaitingMessageGet: + EvrRtxMessageQueueGetTimeout( + (osMessageQueueId_t)osRtxThreadListRoot(thread)); + break; + case osRtxThreadWaitingMessagePut: + EvrRtxMessageQueuePutTimeout( + (osMessageQueueId_t)osRtxThreadListRoot(thread)); + break; + default: + // Invalid + break; } EvrRtxThreadUnblocked(thread, (osRtxThreadRegPtr(thread))[0]); osRtxThreadListRemove(thread); @@ -388,17 +401,17 @@ void osRtxThreadDelayTick (void) { /// Get pointer to Thread registers (R0..R3) /// \param[in] thread thread object. /// \return pointer to registers R0-R3. -uint32_t *osRtxThreadRegPtr (const os_thread_t *thread) { +uint32_t *osRtxThreadRegPtr(const os_thread_t *thread) { uint32_t addr = thread->sp + StackOffsetR0(thread->stack_frame); - //lint -e{923} -e{9078} "cast from unsigned int to pointer" + // lint -e{923} -e{9078} "cast from unsigned int to pointer" return ((uint32_t *)addr); } /// Block running Thread execution and register it as Ready to Run. /// \param[in] thread running thread object. -static void osRtxThreadBlock (os_thread_t *thread) { +static void osRtxThreadBlock(os_thread_t *thread) { os_thread_t *prev, *next; - int32_t priority; + int32_t priority; thread->state = osRtxThreadReady; @@ -423,14 +436,15 @@ static void osRtxThreadBlock (os_thread_t *thread) { /// Switch to specified Thread. /// \param[in] thread thread object. -void osRtxThreadSwitch (os_thread_t *thread) { +void osRtxThreadSwitch(os_thread_t *thread) { thread->state = osRtxThreadRunning; osRtxInfo.thread.run.next = thread; #if __RTX_CPU_STATISTICS__ if (osRtxInfo.thread.run.curr != thread) { if (osRtxInfo.thread.run.curr) - osRtxInfo.thread.run.curr->swap_out_time = HWTICKS_TO_MS(rtx_get_hwticks()); + osRtxInfo.thread.run.curr->swap_out_time = + HWTICKS_TO_MS(rtx_get_hwticks()); thread->swap_in_time = HWTICKS_TO_MS(rtx_get_hwticks()); } #endif @@ -440,18 +454,17 @@ void osRtxThreadSwitch (os_thread_t *thread) { /// Dispatch specified Thread or Ready Thread with Highest Priority. /// \param[in] thread thread object or NULL. -void osRtxThreadDispatch (os_thread_t *thread) { - uint8_t kernel_state; +void osRtxThreadDispatch(os_thread_t *thread) { + uint8_t kernel_state; os_thread_t *thread_running; os_thread_t *thread_ready; - kernel_state = osRtxKernelGetState(); + kernel_state = osRtxKernelGetState(); thread_running = osRtxThreadGetRunning(); if (thread == NULL) { thread_ready = osRtxInfo.thread.ready.thread_list; - if ((kernel_state == osRtxKernelRunning) && - (thread_ready != NULL) && + if ((kernel_state == osRtxKernelRunning) && (thread_ready != NULL) && (thread_ready->priority > thread_running->priority)) { // Preempt running Thread osRtxThreadListRemove(thread_ready); @@ -475,7 +488,8 @@ void osRtxThreadDispatch (os_thread_t *thread) { /// \param[in] thread thread object. /// \param[in] ret_val return value. /// \param[in] dispatch dispatch flag. -void osRtxThreadWaitExit (os_thread_t *thread, uint32_t ret_val, bool_t dispatch) { +void osRtxThreadWaitExit(os_thread_t *thread, uint32_t ret_val, + bool_t dispatch) { uint32_t *reg; EvrRtxThreadUnblocked(thread, ret_val); @@ -495,18 +509,18 @@ void osRtxThreadWaitExit (os_thread_t *thread, uint32_t ret_val, bool_t dispatch /// \param[in] state new thread state. /// \param[in] timeout timeout. /// \return true - success, false - failure. -bool_t osRtxThreadWaitEnter (uint8_t state, uint32_t timeout) { +bool_t osRtxThreadWaitEnter(uint8_t state, uint32_t timeout) { os_thread_t *thread; // Check if Kernel is running if (osRtxKernelGetState() != osRtxKernelRunning) { - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return FALSE; } // Check if any thread is ready if (osRtxInfo.thread.ready.thread_list == NULL) { - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return FALSE; } @@ -524,15 +538,15 @@ bool_t osRtxThreadWaitEnter (uint8_t state, uint32_t timeout) { } /// Check current running Thread Stack. -//lint -esym(759,osRtxThreadStackCheck) "Prototype in header" -//lint -esym(765,osRtxThreadStackCheck) "Global scope (can be overridden)" -__WEAK void osRtxThreadStackCheck (void) { +// lint -esym(759,osRtxThreadStackCheck) "Prototype in header" +// lint -esym(765,osRtxThreadStackCheck) "Global scope (can be overridden)" +__WEAK void osRtxThreadStackCheck(void) { os_thread_t *thread; thread = osRtxThreadGetRunning(); if (thread != NULL) { - //lint -e{923} "cast from pointer to unsigned int" - //lint -e{9079} -e{9087} "cast between pointers to different object types" + // lint -e{923} "cast from pointer to unsigned int" + // lint -e{9079} -e{9087} "cast between pointers to different object types" if ((thread->sp <= (uint32_t)thread->stack_mem) || (*((uint32_t *)thread->stack_mem) != osRtxStackMagicWord)) { (void)osRtxErrorNotify(osRtxErrorStackUnderflow, thread); @@ -543,9 +557,9 @@ __WEAK void osRtxThreadStackCheck (void) { #ifdef RTX_TF_M_EXTENSION /// Get TrustZone Module Identifier of running Thread. /// \return TrustZone Module Identifier. -uint32_t osRtxTzGetModuleId (void) { +uint32_t osRtxTzGetModuleId(void) { os_thread_t *thread; - uint32_t tz_module; + uint32_t tz_module; thread = osRtxThreadGetRunning(); if (thread != NULL) { @@ -558,39 +572,40 @@ uint32_t osRtxTzGetModuleId (void) { } #endif - // ==== Post ISR processing ==== /// Thread post ISR processing. /// \param[in] thread thread object. -static void osRtxThreadPostProcess (os_thread_t *thread) { +static void osRtxThreadPostProcess(os_thread_t *thread) { uint32_t thread_flags; // Check if Thread is waiting for Thread Flags if (thread->state == osRtxThreadWaitingThreadFlags) { - thread_flags = ThreadFlagsCheck(thread, thread->wait_flags, thread->flags_options); + thread_flags = + ThreadFlagsCheck(thread, thread->wait_flags, thread->flags_options); if (thread_flags != 0U) { osRtxThreadWaitExit(thread, thread_flags, FALSE); - EvrRtxThreadFlagsWaitCompleted(thread->wait_flags, thread->flags_options, thread_flags, thread); + EvrRtxThreadFlagsWaitCompleted(thread->wait_flags, thread->flags_options, + thread_flags, thread); } } } - // ==== Service Calls ==== /// Create a thread and add it to Active Threads. /// \note API identical to osThreadNew -static osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr) { - os_thread_t *thread; - uint32_t attr_bits; - void *stack_mem; - uint32_t stack_size; - osPriority_t priority; - uint8_t flags; - const char *name; - uint32_t *ptr; - uint32_t n; +static osThreadId_t svcRtxThreadNew(osThreadFunc_t func, void *argument, + const osThreadAttr_t *attr) { + os_thread_t *thread; + uint32_t attr_bits; + void *stack_mem; + uint32_t stack_size; + osPriority_t priority; + uint8_t flags; + const char *name; + uint32_t *ptr; + uint32_t n; #if (DOMAIN_NS == 1) TZ_ModuleId_t tz_module; TZ_MemoryId_t tz_memory; @@ -599,42 +614,47 @@ static osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const // Check parameters if (func == NULL) { EvrRtxThreadError(NULL, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } // Process attributes if (attr != NULL) { - name = attr->name; - attr_bits = attr->attr_bits; - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 6] - thread = attr->cb_mem; - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 6] - stack_mem = attr->stack_mem; + name = attr->name; + attr_bits = attr->attr_bits; + // lint -e{9079} "conversion from pointer to void to pointer to other type" + // [MISRA Note 6] + thread = attr->cb_mem; + // lint -e{9079} "conversion from pointer to void to pointer to other type" + // [MISRA Note 6] + stack_mem = attr->stack_mem; stack_size = attr->stack_size; - priority = attr->priority; + priority = attr->priority; #if (DOMAIN_NS == 1) - tz_module = attr->tz_module; + tz_module = attr->tz_module; #endif if (thread != NULL) { - //lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note 7] - if ((((uint32_t)thread & 3U) != 0U) || (attr->cb_size < sizeof(os_thread_t))) { + // lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note + // 7] + if ((((uint32_t)thread & 3U) != 0U) || + (attr->cb_size < sizeof(os_thread_t))) { EvrRtxThreadError(NULL, osRtxErrorInvalidControlBlock); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } else { if (attr->cb_size != 0U) { EvrRtxThreadError(NULL, osRtxErrorInvalidControlBlock); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } if (stack_mem != NULL) { - //lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note 7] + // lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note + // 7] if ((((uint32_t)stack_mem & 7U) != 0U) || (stack_size == 0U)) { EvrRtxThreadError(NULL, osRtxErrorInvalidThreadStack); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } @@ -643,36 +663,39 @@ static osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const } else { if ((priority < osPriorityIdle) || (priority > osPriorityISR)) { EvrRtxThreadError(NULL, osRtxErrorInvalidPriority); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } } else { - name = NULL; - attr_bits = 0U; - thread = NULL; - stack_mem = NULL; + name = NULL; + attr_bits = 0U; + thread = NULL; + stack_mem = NULL; stack_size = 0U; - priority = osPriorityNormal; + priority = osPriorityNormal; #if (DOMAIN_NS == 1) - tz_module = 0U; + tz_module = 0U; #endif } // Check stack size - if ((stack_size != 0U) && (((stack_size & 7U) != 0U) || (stack_size < (64U + 8U)))) { + if ((stack_size != 0U) && + (((stack_size & 7U) != 0U) || (stack_size < (64U + 8U)))) { EvrRtxThreadError(NULL, osRtxErrorInvalidThreadStack); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } // Allocate object memory if not provided if (thread == NULL) { if (osRtxInfo.mpi.thread != NULL) { - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] thread = osRtxMemoryPoolAlloc(osRtxInfo.mpi.thread); } else { - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] thread = osRtxMemoryAlloc(osRtxInfo.mem.common, sizeof(os_thread_t), 1U); } #if (defined(OS_OBJ_MEM_USAGE) && (OS_OBJ_MEM_USAGE != 0)) @@ -695,17 +718,20 @@ static osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const if (stack_size == 0U) { stack_size = osRtxConfig.thread_stack_size; if (osRtxInfo.mpi.stack != NULL) { - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] stack_mem = osRtxMemoryPoolAlloc(osRtxInfo.mpi.stack); if (stack_mem != NULL) { flags |= osRtxThreadFlagDefStack; } } else { - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] stack_mem = osRtxMemoryAlloc(osRtxInfo.mem.stack, stack_size, 0U); } } else { - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] stack_mem = osRtxMemoryAlloc(osRtxInfo.mem.stack, stack_size, 0U); } if (stack_mem == NULL) { @@ -756,62 +782,62 @@ static osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const if (thread != NULL) { // Initialize control block - //lint --e{923} --e{9078} "cast between pointers and unsigned int" - //lint --e{9079} --e{9087} "cast between pointers to different object types" - //lint --e{9074} "conversion between a pointer to function and another type" - thread->id = osRtxIdThread; - thread->state = osRtxThreadReady; - thread->flags = flags; - thread->attr = (uint8_t)attr_bits; - thread->name = name; - thread->thread_next = NULL; - thread->thread_prev = NULL; - thread->delay_next = NULL; - thread->delay_prev = NULL; - thread->thread_join = NULL; - thread->delay = 0U; - thread->priority = (int8_t)priority; + // lint --e{923} --e{9078} "cast between pointers and unsigned int" + // lint --e{9079} --e{9087} "cast between pointers to different object + // types" lint --e{9074} "conversion between a pointer to function and + // another type" + thread->id = osRtxIdThread; + thread->state = osRtxThreadReady; + thread->flags = flags; + thread->attr = (uint8_t)attr_bits; + thread->name = name; + thread->thread_next = NULL; + thread->thread_prev = NULL; + thread->delay_next = NULL; + thread->delay_prev = NULL; + thread->thread_join = NULL; + thread->delay = 0U; + thread->priority = (int8_t)priority; thread->priority_base = (int8_t)priority; - thread->stack_frame = STACK_FRAME_INIT_VAL; + thread->stack_frame = STACK_FRAME_INIT_VAL; thread->flags_options = 0U; - thread->wait_flags = 0U; - thread->thread_flags = 0U; - thread->mutex_list = NULL; - thread->stack_mem = stack_mem; - thread->stack_size = stack_size; - thread->sp = (uint32_t)stack_mem + stack_size - 64U; - thread->thread_addr = (uint32_t)func; - #if (DOMAIN_NS == 1) - thread->tz_memory = tz_memory; - #ifdef RTX_TF_M_EXTENSION - thread->tz_module = tz_module; - #endif - #endif + thread->wait_flags = 0U; + thread->thread_flags = 0U; + thread->mutex_list = NULL; + thread->stack_mem = stack_mem; + thread->stack_size = stack_size; + thread->sp = (uint32_t)stack_mem + stack_size - 64U; + thread->thread_addr = (uint32_t)func; +#if (DOMAIN_NS == 1) + thread->tz_memory = tz_memory; +#ifdef RTX_TF_M_EXTENSION + thread->tz_module = tz_module; +#endif +#endif #if __RTX_CPU_STATISTICS__ - thread->rtime = 0; - thread->step_rtime = 0; + thread->rtime = 0; + thread->step_rtime = 0; #endif // Initialize stack - //lint --e{613} false detection: "Possible use of null pointer" + // lint --e{613} false detection: "Possible use of null pointer" ptr = (uint32_t *)stack_mem; ptr[0] = osRtxStackMagicWord; if ((osRtxConfig.flags & osRtxConfigStackWatermark) != 0U) { - for (n = (stack_size/4U) - (16U + 1U); n != 0U; n--) { - ptr++; + for (n = (stack_size / 4U) - (16U + 1U); n != 0U; n--) { + ptr++; *ptr = osRtxStackFillPattern; } } ptr = (uint32_t *)thread->sp; for (n = 0U; n != 13U; n++) { - ptr[n] = 0U; // R4..R11, R0..R3, R12 + ptr[n] = 0U; // R4..R11, R0..R3, R12 } - ptr[13] = (uint32_t)osThreadExit; // LR - ptr[14] = (uint32_t)func; // PC + ptr[13] = (uint32_t)osThreadExit; // LR + ptr[14] = (uint32_t)func; // PC ptr[15] = xPSR_InitVal( - (bool_t)((osRtxConfig.flags & osRtxConfigPrivilegedMode) != 0U), - (bool_t)(((uint32_t)func & 1U) != 0U) - ); // xPSR - ptr[8] = (uint32_t)argument; // R0 + (bool_t)((osRtxConfig.flags & osRtxConfigPrivilegedMode) != 0U), + (bool_t)(((uint32_t)func & 1U) != 0U)); // xPSR + ptr[8] = (uint32_t)argument; // R0 // Register post ISR processing function osRtxInfo.post_process.thread = osRtxThreadPostProcess; @@ -830,13 +856,13 @@ static osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const /// Get name of a thread. /// \note API identical to osThreadGetName -static const char *svcRtxThreadGetName (osThreadId_t thread_id) { +static const char *svcRtxThreadGetName(osThreadId_t thread_id) { os_thread_t *thread = osRtxThreadId(thread_id); // Check parameters if ((thread == NULL) || (thread->id != osRtxIdThread)) { EvrRtxThreadGetName(thread, NULL); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } @@ -847,7 +873,7 @@ static const char *svcRtxThreadGetName (osThreadId_t thread_id) { /// Return the thread ID of the current running thread. /// \note API identical to osThreadGetId -static osThreadId_t svcRtxThreadGetId (void) { +static osThreadId_t svcRtxThreadGetId(void) { os_thread_t *thread; thread = osRtxThreadGetRunning(); @@ -857,14 +883,14 @@ static osThreadId_t svcRtxThreadGetId (void) { /// Get current thread state of a thread. /// \note API identical to osThreadGetState -static osThreadState_t svcRtxThreadGetState (osThreadId_t thread_id) { - os_thread_t *thread = osRtxThreadId(thread_id); +static osThreadState_t svcRtxThreadGetState(osThreadId_t thread_id) { + os_thread_t *thread = osRtxThreadId(thread_id); osThreadState_t state; // Check parameters if ((thread == NULL) || (thread->id != osRtxIdThread)) { EvrRtxThreadGetState(thread, osThreadError); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osThreadError; } @@ -877,13 +903,13 @@ static osThreadState_t svcRtxThreadGetState (osThreadId_t thread_id) { /// Get stack size of a thread. /// \note API identical to osThreadGetStackSize -static uint32_t svcRtxThreadGetStackSize (osThreadId_t thread_id) { +static uint32_t svcRtxThreadGetStackSize(osThreadId_t thread_id) { os_thread_t *thread = osRtxThreadId(thread_id); // Check parameters if ((thread == NULL) || (thread->id != osRtxIdThread)) { EvrRtxThreadGetStackSize(thread, 0U); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } @@ -892,28 +918,28 @@ static uint32_t svcRtxThreadGetStackSize (osThreadId_t thread_id) { return thread->stack_size; } -/// Get available stack space of a thread based on stack watermark recording during execution. -/// \note API identical to osThreadGetStackSpace -static uint32_t svcRtxThreadGetStackSpace (osThreadId_t thread_id) { - os_thread_t *thread = osRtxThreadId(thread_id); +/// Get available stack space of a thread based on stack watermark recording +/// during execution. \note API identical to osThreadGetStackSpace +static uint32_t svcRtxThreadGetStackSpace(osThreadId_t thread_id) { + os_thread_t *thread = osRtxThreadId(thread_id); const uint32_t *stack; - uint32_t space; + uint32_t space; // Check parameters if ((thread == NULL) || (thread->id != osRtxIdThread)) { EvrRtxThreadGetStackSpace(thread, 0U); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } // Check if stack watermark is not enabled if ((osRtxConfig.flags & osRtxConfigStackWatermark) == 0U) { EvrRtxThreadGetStackSpace(thread, 0U); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } - //lint -e{9079} "conversion from pointer to void to pointer to other type" + // lint -e{9079} "conversion from pointer to void to pointer to other type" stack = thread->stack_mem; if (*stack++ == osRtxStackMagicWord) { for (space = 4U; space < thread->stack_size; space += 4U) { @@ -932,26 +958,27 @@ static uint32_t svcRtxThreadGetStackSpace (osThreadId_t thread_id) { /// Change priority of a thread. /// \note API identical to osThreadSetPriority -static osStatus_t svcRtxThreadSetPriority (osThreadId_t thread_id, osPriority_t priority) { +static osStatus_t svcRtxThreadSetPriority(osThreadId_t thread_id, + osPriority_t priority) { os_thread_t *thread = osRtxThreadId(thread_id); // Check parameters if ((thread == NULL) || (thread->id != osRtxIdThread) || (priority < osPriorityIdle) || (priority > osPriorityISR)) { EvrRtxThreadError(thread, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } // Check object state if (thread->state == osRtxThreadTerminated) { EvrRtxThreadError(thread, (int32_t)osErrorResource); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorResource; } - if (thread->priority != (int8_t)priority) { - thread->priority = (int8_t)priority; + if (thread->priority != (int8_t)priority) { + thread->priority = (int8_t)priority; thread->priority_base = (int8_t)priority; EvrRtxThreadPriorityUpdated(thread, priority); osRtxThreadListSort(thread); @@ -963,21 +990,21 @@ static osStatus_t svcRtxThreadSetPriority (osThreadId_t thread_id, osPriority_t /// Get current priority of a thread. /// \note API identical to osThreadGetPriority -static osPriority_t svcRtxThreadGetPriority (osThreadId_t thread_id) { +static osPriority_t svcRtxThreadGetPriority(osThreadId_t thread_id) { os_thread_t *thread = osRtxThreadId(thread_id); osPriority_t priority; // Check parameters if ((thread == NULL) || (thread->id != osRtxIdThread)) { EvrRtxThreadGetPriority(thread, osPriorityError); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osPriorityError; } // Check object state if (thread->state == osRtxThreadTerminated) { EvrRtxThreadGetPriority(thread, osPriorityError); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osPriorityError; } @@ -990,13 +1017,13 @@ static osPriority_t svcRtxThreadGetPriority (osThreadId_t thread_id) { /// Pass control to next thread that is in state READY. /// \note API identical to osThreadYield -static osStatus_t svcRtxThreadYield (void) { +static osStatus_t svcRtxThreadYield(void) { os_thread_t *thread_running; os_thread_t *thread_ready; if (osRtxKernelGetState() == osRtxKernelRunning) { thread_running = osRtxThreadGetRunning(); - thread_ready = osRtxInfo.thread.ready.thread_list; + thread_ready = osRtxInfo.thread.ready.thread_list; if ((thread_ready != NULL) && (thread_ready->priority == thread_running->priority)) { osRtxThreadListRemove(thread_ready); @@ -1011,43 +1038,43 @@ static osStatus_t svcRtxThreadYield (void) { /// Suspend execution of a thread. /// \note API identical to osThreadSuspend -static osStatus_t svcRtxThreadSuspend (osThreadId_t thread_id) { +static osStatus_t svcRtxThreadSuspend(osThreadId_t thread_id) { os_thread_t *thread = osRtxThreadId(thread_id); - osStatus_t status; + osStatus_t status; // Check parameters if ((thread == NULL) || (thread->id != osRtxIdThread)) { EvrRtxThreadError(thread, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } // Check object state switch (thread->state & osRtxThreadStateMask) { - case osRtxThreadRunning: - if ((osRtxKernelGetState() != osRtxKernelRunning) || - (osRtxInfo.thread.ready.thread_list == NULL)) { - EvrRtxThreadError(thread, (int32_t)osErrorResource); - status = osErrorResource; - } else { - status = osOK; - } - break; - case osRtxThreadReady: - osRtxThreadListRemove(thread); - status = osOK; - break; - case osRtxThreadBlocked: - osRtxThreadListRemove(thread); - osRtxThreadDelayRemove(thread); - status = osOK; - break; - case osRtxThreadInactive: - case osRtxThreadTerminated: - default: + case osRtxThreadRunning: + if ((osRtxKernelGetState() != osRtxKernelRunning) || + (osRtxInfo.thread.ready.thread_list == NULL)) { EvrRtxThreadError(thread, (int32_t)osErrorResource); status = osErrorResource; - break; + } else { + status = osOK; + } + break; + case osRtxThreadReady: + osRtxThreadListRemove(thread); + status = osOK; + break; + case osRtxThreadBlocked: + osRtxThreadListRemove(thread); + osRtxThreadDelayRemove(thread); + status = osOK; + break; + case osRtxThreadInactive: + case osRtxThreadTerminated: + default: + EvrRtxThreadError(thread, (int32_t)osErrorResource); + status = osErrorResource; + break; } if (status == osOK) { @@ -1069,20 +1096,20 @@ static osStatus_t svcRtxThreadSuspend (osThreadId_t thread_id) { /// Resume execution of a thread. /// \note API identical to osThreadResume -static osStatus_t svcRtxThreadResume (osThreadId_t thread_id) { +static osStatus_t svcRtxThreadResume(osThreadId_t thread_id) { os_thread_t *thread = osRtxThreadId(thread_id); // Check parameters if ((thread == NULL) || (thread->id != osRtxIdThread)) { EvrRtxThreadError(thread, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } // Check object state if ((thread->state & osRtxThreadStateMask) != osRtxThreadBlocked) { EvrRtxThreadError(thread, (int32_t)osErrorResource); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorResource; } @@ -1098,11 +1125,11 @@ static osStatus_t svcRtxThreadResume (osThreadId_t thread_id) { /// Free Thread resources. /// \param[in] thread thread object. -static void osRtxThreadFree (os_thread_t *thread) { +static void osRtxThreadFree(os_thread_t *thread) { // Mark object as inactive and invalid thread->state = osRtxThreadInactive; - thread->id = osRtxIdInvalid; + thread->id = osRtxIdInvalid; #if (DOMAIN_NS == 1) // Free secure process stack @@ -1135,20 +1162,20 @@ static void osRtxThreadFree (os_thread_t *thread) { /// Detach a thread (thread storage can be reclaimed when thread terminates). /// \note API identical to osThreadDetach -static osStatus_t svcRtxThreadDetach (osThreadId_t thread_id) { +static osStatus_t svcRtxThreadDetach(osThreadId_t thread_id) { os_thread_t *thread = osRtxThreadId(thread_id); // Check parameters if ((thread == NULL) || (thread->id != osRtxIdThread)) { EvrRtxThreadError(thread, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } // Check object attributes if ((thread->attr & osThreadJoinable) == 0U) { EvrRtxThreadError(thread, osRtxErrorThreadNotJoinable); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorResource; } @@ -1166,28 +1193,28 @@ static osStatus_t svcRtxThreadDetach (osThreadId_t thread_id) { /// Wait for specified thread to terminate. /// \note API identical to osThreadJoin -static osStatus_t svcRtxThreadJoin (osThreadId_t thread_id) { +static osStatus_t svcRtxThreadJoin(osThreadId_t thread_id) { os_thread_t *thread = osRtxThreadId(thread_id); - osStatus_t status; + osStatus_t status; // Check parameters if ((thread == NULL) || (thread->id != osRtxIdThread)) { EvrRtxThreadError(thread, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } // Check object attributes if ((thread->attr & osThreadJoinable) == 0U) { EvrRtxThreadError(thread, osRtxErrorThreadNotJoinable); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorResource; } // Check object state if (thread->state == osRtxThreadRunning) { EvrRtxThreadError(thread, (int32_t)osErrorResource); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorResource; } @@ -1213,13 +1240,13 @@ static osStatus_t svcRtxThreadJoin (osThreadId_t thread_id) { /// Terminate execution of current running thread. /// \note API identical to osThreadExit -static void svcRtxThreadExit (void) { +static void svcRtxThreadExit(void) { os_thread_t *thread; // Check if switch to next Ready Thread is possible if ((osRtxKernelGetState() != osRtxKernelRunning) || (osRtxInfo.thread.ready.thread_list == NULL)) { - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return; } @@ -1258,43 +1285,43 @@ static void svcRtxThreadExit (void) { /// Terminate execution of a thread. /// \note API identical to osThreadTerminate -static osStatus_t svcRtxThreadTerminate (osThreadId_t thread_id) { +static osStatus_t svcRtxThreadTerminate(osThreadId_t thread_id) { os_thread_t *thread = osRtxThreadId(thread_id); - osStatus_t status; + osStatus_t status; // Check parameters if ((thread == NULL) || (thread->id != osRtxIdThread)) { EvrRtxThreadError(thread, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } // Check object state switch (thread->state & osRtxThreadStateMask) { - case osRtxThreadRunning: - if ((osRtxKernelGetState() != osRtxKernelRunning) || - (osRtxInfo.thread.ready.thread_list == NULL)) { - EvrRtxThreadError(thread, (int32_t)osErrorResource); - status = osErrorResource; - } else { - status = osOK; - } - break; - case osRtxThreadReady: - osRtxThreadListRemove(thread); - status = osOK; - break; - case osRtxThreadBlocked: - osRtxThreadListRemove(thread); - osRtxThreadDelayRemove(thread); - status = osOK; - break; - case osRtxThreadInactive: - case osRtxThreadTerminated: - default: + case osRtxThreadRunning: + if ((osRtxKernelGetState() != osRtxKernelRunning) || + (osRtxInfo.thread.ready.thread_list == NULL)) { EvrRtxThreadError(thread, (int32_t)osErrorResource); status = osErrorResource; - break; + } else { + status = osOK; + } + break; + case osRtxThreadReady: + osRtxThreadListRemove(thread); + status = osOK; + break; + case osRtxThreadBlocked: + osRtxThreadListRemove(thread); + osRtxThreadDelayRemove(thread); + status = osOK; + break; + case osRtxThreadInactive: + case osRtxThreadTerminated: + default: + EvrRtxThreadError(thread, (int32_t)osErrorResource); + status = osErrorResource; + break; } if (status == osOK) { @@ -1337,28 +1364,28 @@ static osStatus_t svcRtxThreadTerminate (osThreadId_t thread_id) { /// Get number of active threads. /// \note API identical to osThreadGetCount -static uint32_t svcRtxThreadGetCount (void) { +static uint32_t svcRtxThreadGetCount(void) { const os_thread_t *thread; - uint32_t count; + uint32_t count; // Running Thread count = 1U; // Ready List - for (thread = osRtxInfo.thread.ready.thread_list; - thread != NULL; thread = thread->thread_next) { + for (thread = osRtxInfo.thread.ready.thread_list; thread != NULL; + thread = thread->thread_next) { count++; } // Delay List - for (thread = osRtxInfo.thread.delay_list; - thread != NULL; thread = thread->delay_next) { + for (thread = osRtxInfo.thread.delay_list; thread != NULL; + thread = thread->delay_next) { count++; } // Wait List - for (thread = osRtxInfo.thread.wait_list; - thread != NULL; thread = thread->delay_next) { + for (thread = osRtxInfo.thread.wait_list; thread != NULL; + thread = thread->delay_next) { count++; } @@ -1369,44 +1396,46 @@ static uint32_t svcRtxThreadGetCount (void) { /// Enumerate active threads. /// \note API identical to osThreadEnumerate -static uint32_t svcRtxThreadEnumerate (osThreadId_t *thread_array, uint32_t array_items) { +static uint32_t svcRtxThreadEnumerate(osThreadId_t *thread_array, + uint32_t array_items) { os_thread_t *thread; - uint32_t count; + uint32_t count; // Check parameters if ((thread_array == NULL) || (array_items == 0U)) { EvrRtxThreadEnumerate(thread_array, array_items, 0U); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } // Running Thread *thread_array = osRtxThreadGetRunning(); - thread_array++; - count = 1U; + thread_array++; + count = 1U; // Ready List for (thread = osRtxInfo.thread.ready.thread_list; - (thread != NULL) && (count < array_items); thread = thread->thread_next) { + (thread != NULL) && (count < array_items); + thread = thread->thread_next) { *thread_array = thread; - thread_array++; - count++; + thread_array++; + count++; } // Delay List for (thread = osRtxInfo.thread.delay_list; (thread != NULL) && (count < array_items); thread = thread->delay_next) { *thread_array = thread; - thread_array++; - count++; + thread_array++; + count++; } // Wait List for (thread = osRtxInfo.thread.wait_list; (thread != NULL) && (count < array_items); thread = thread->delay_next) { *thread_array = thread; - thread_array++; - count++; + thread_array++; + count++; } EvrRtxThreadEnumerate(thread_array - count, array_items, count); @@ -1416,23 +1445,23 @@ static uint32_t svcRtxThreadEnumerate (osThreadId_t *thread_array, uint32_t arra /// Set the specified Thread Flags of a thread. /// \note API identical to osThreadFlagsSet -static uint32_t svcRtxThreadFlagsSet (osThreadId_t thread_id, uint32_t flags) { +static uint32_t svcRtxThreadFlagsSet(osThreadId_t thread_id, uint32_t flags) { os_thread_t *thread = osRtxThreadId(thread_id); - uint32_t thread_flags; - uint32_t thread_flags0; + uint32_t thread_flags; + uint32_t thread_flags0; // Check parameters if ((thread == NULL) || (thread->id != osRtxIdThread) || ((flags & ~(((uint32_t)1U << osRtxThreadFlagsLimit) - 1U)) != 0U)) { EvrRtxThreadFlagsError(thread, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return ((uint32_t)osErrorParameter); } // Check object state if (thread->state == osRtxThreadTerminated) { EvrRtxThreadFlagsError(thread, (int32_t)osErrorResource); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return ((uint32_t)osErrorResource); } @@ -1441,7 +1470,8 @@ static uint32_t svcRtxThreadFlagsSet (osThreadId_t thread_id, uint32_t flags) { // Check if Thread is waiting for Thread Flags if (thread->state == osRtxThreadWaitingThreadFlags) { - thread_flags0 = ThreadFlagsCheck(thread, thread->wait_flags, thread->flags_options); + thread_flags0 = + ThreadFlagsCheck(thread, thread->wait_flags, thread->flags_options); if (thread_flags0 != 0U) { if ((thread->flags_options & osFlagsNoClear) == 0U) { thread_flags = thread_flags0 & ~thread->wait_flags; @@ -1449,7 +1479,8 @@ static uint32_t svcRtxThreadFlagsSet (osThreadId_t thread_id, uint32_t flags) { thread_flags = thread_flags0; } osRtxThreadWaitExit(thread, thread_flags0, TRUE); - EvrRtxThreadFlagsWaitCompleted(thread->wait_flags, thread->flags_options, thread_flags0, thread); + EvrRtxThreadFlagsWaitCompleted(thread->wait_flags, thread->flags_options, + thread_flags0, thread); } } @@ -1460,22 +1491,22 @@ static uint32_t svcRtxThreadFlagsSet (osThreadId_t thread_id, uint32_t flags) { /// Clear the specified Thread Flags of current running thread. /// \note API identical to osThreadFlagsClear -static uint32_t svcRtxThreadFlagsClear (uint32_t flags) { +static uint32_t svcRtxThreadFlagsClear(uint32_t flags) { os_thread_t *thread; - uint32_t thread_flags; + uint32_t thread_flags; // Check running thread thread = osRtxThreadGetRunning(); if (thread == NULL) { EvrRtxThreadFlagsError(NULL, osRtxErrorKernelNotRunning); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return ((uint32_t)osError); } // Check parameters if ((flags & ~(((uint32_t)1U << osRtxThreadFlagsLimit) - 1U)) != 0U) { EvrRtxThreadFlagsError(thread, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return ((uint32_t)osErrorParameter); } @@ -1489,14 +1520,14 @@ static uint32_t svcRtxThreadFlagsClear (uint32_t flags) { /// Get the current Thread Flags of current running thread. /// \note API identical to osThreadFlagsGet -static uint32_t svcRtxThreadFlagsGet (void) { +static uint32_t svcRtxThreadFlagsGet(void) { const os_thread_t *thread; // Check running thread thread = osRtxThreadGetRunning(); if (thread == NULL) { EvrRtxThreadFlagsGet(0U); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } @@ -1505,24 +1536,25 @@ static uint32_t svcRtxThreadFlagsGet (void) { return thread->thread_flags; } -/// Wait for one or more Thread Flags of the current running thread to become signaled. -/// \note API identical to osThreadFlagsWait -static uint32_t svcRtxThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout) { +/// Wait for one or more Thread Flags of the current running thread to become +/// signaled. \note API identical to osThreadFlagsWait +static uint32_t svcRtxThreadFlagsWait(uint32_t flags, uint32_t options, + uint32_t timeout) { os_thread_t *thread; - uint32_t thread_flags; + uint32_t thread_flags; // Check running thread thread = osRtxThreadGetRunning(); if (thread == NULL) { EvrRtxThreadFlagsError(NULL, osRtxErrorKernelNotRunning); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return ((uint32_t)osError); } // Check parameters if ((flags & ~(((uint32_t)1U << osRtxThreadFlagsLimit) - 1U)) != 0U) { EvrRtxThreadFlagsError(thread, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return ((uint32_t)osErrorParameter); } @@ -1550,7 +1582,8 @@ static uint32_t svcRtxThreadFlagsWait (uint32_t flags, uint32_t options, uint32_ return thread_flags; } #if TASK_HUNG_CHECK_ENABLED -osStatus_t svcRtxThreadSetHungCheck (osThreadId_t thread_id, int32_t enable, uint32_t timeout) { +osStatus_t svcRtxThreadSetHungCheck(osThreadId_t thread_id, int32_t enable, + uint32_t timeout) { os_thread_t *thread = osRtxThreadId(thread_id); if (thread == NULL) @@ -1562,61 +1595,57 @@ osStatus_t svcRtxThreadSetHungCheck (osThreadId_t thread_id, int32_t enable, uin } #endif -int rtx_task_idle_health_check(void) -{ - return 0; -} +int rtx_task_idle_health_check(void) { return 0; } // Service Calls definitions -//lint ++flb "Library Begin" [MISRA Note 11] -SVC0_3 (ThreadNew, osThreadId_t, osThreadFunc_t, void *, const osThreadAttr_t *) -SVC0_1 (ThreadGetName, const char *, osThreadId_t) -SVC0_0 (ThreadGetId, osThreadId_t) -SVC0_1 (ThreadGetState, osThreadState_t, osThreadId_t) -SVC0_1 (ThreadGetStackSize, uint32_t, osThreadId_t) -SVC0_1 (ThreadGetStackSpace, uint32_t, osThreadId_t) -SVC0_2 (ThreadSetPriority, osStatus_t, osThreadId_t, osPriority_t) -SVC0_1 (ThreadGetPriority, osPriority_t, osThreadId_t) -SVC0_0 (ThreadYield, osStatus_t) -SVC0_1 (ThreadSuspend, osStatus_t, osThreadId_t) -SVC0_1 (ThreadResume, osStatus_t, osThreadId_t) -SVC0_1 (ThreadDetach, osStatus_t, osThreadId_t) -SVC0_1 (ThreadJoin, osStatus_t, osThreadId_t) -SVC0_0N(ThreadExit, void) -SVC0_1 (ThreadTerminate, osStatus_t, osThreadId_t) -SVC0_0 (ThreadGetCount, uint32_t) -SVC0_2 (ThreadEnumerate, uint32_t, osThreadId_t *, uint32_t) -SVC0_2 (ThreadFlagsSet, uint32_t, osThreadId_t, uint32_t) -SVC0_1 (ThreadFlagsClear, uint32_t, uint32_t) -SVC0_0 (ThreadFlagsGet, uint32_t) -SVC0_3 (ThreadFlagsWait, uint32_t, uint32_t, uint32_t, uint32_t) +// lint ++flb "Library Begin" [MISRA Note 11] +SVC0_3(ThreadNew, osThreadId_t, osThreadFunc_t, void *, const osThreadAttr_t *) +SVC0_1(ThreadGetName, const char *, osThreadId_t) +SVC0_0(ThreadGetId, osThreadId_t) +SVC0_1(ThreadGetState, osThreadState_t, osThreadId_t) +SVC0_1(ThreadGetStackSize, uint32_t, osThreadId_t) +SVC0_1(ThreadGetStackSpace, uint32_t, osThreadId_t) +SVC0_2(ThreadSetPriority, osStatus_t, osThreadId_t, osPriority_t) +SVC0_1(ThreadGetPriority, osPriority_t, osThreadId_t) +SVC0_0(ThreadYield, osStatus_t) +SVC0_1(ThreadSuspend, osStatus_t, osThreadId_t) +SVC0_1(ThreadResume, osStatus_t, osThreadId_t) +SVC0_1(ThreadDetach, osStatus_t, osThreadId_t) +SVC0_1(ThreadJoin, osStatus_t, osThreadId_t) +SVC0_0N(ThreadExit, void) +SVC0_1(ThreadTerminate, osStatus_t, osThreadId_t) +SVC0_0(ThreadGetCount, uint32_t) +SVC0_2(ThreadEnumerate, uint32_t, osThreadId_t *, uint32_t) +SVC0_2(ThreadFlagsSet, uint32_t, osThreadId_t, uint32_t) +SVC0_1(ThreadFlagsClear, uint32_t, uint32_t) +SVC0_0(ThreadFlagsGet, uint32_t) +SVC0_3(ThreadFlagsWait, uint32_t, uint32_t, uint32_t, uint32_t) #if TASK_HUNG_CHECK_ENABLED -SVC0_3 (ThreadSetHungCheck, osStatus_t, osThreadId_t, int32_t, uint32_t) +SVC0_3(ThreadSetHungCheck, osStatus_t, osThreadId_t, int32_t, uint32_t) #endif -//lint --flb "Library End" - +// lint --flb "Library End" // ==== ISR Calls ==== /// Set the specified Thread Flags of a thread. /// \note API identical to osThreadFlagsSet __STATIC_INLINE -uint32_t isrRtxThreadFlagsSet (osThreadId_t thread_id, uint32_t flags) { +uint32_t isrRtxThreadFlagsSet(osThreadId_t thread_id, uint32_t flags) { os_thread_t *thread = osRtxThreadId(thread_id); - uint32_t thread_flags; + uint32_t thread_flags; // Check parameters if ((thread == NULL) || (thread->id != osRtxIdThread) || ((flags & ~(((uint32_t)1U << osRtxThreadFlagsLimit) - 1U)) != 0U)) { EvrRtxThreadFlagsError(thread, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return ((uint32_t)osErrorParameter); } // Check object state if (thread->state == osRtxThreadTerminated) { EvrRtxThreadFlagsError(thread, (int32_t)osErrorResource); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return ((uint32_t)osErrorResource); } @@ -1631,24 +1660,21 @@ uint32_t isrRtxThreadFlagsSet (osThreadId_t thread_id, uint32_t flags) { return thread_flags; } - // ==== Library functions ==== /// Thread startup (Idle and Timer Thread). /// \return true - success, false - failure. -bool_t osRtxThreadStartup (void) { +bool_t osRtxThreadStartup(void) { bool_t ret = TRUE; // Create Idle Thread osRtxInfo.thread.idle = osRtxThreadId( - svcRtxThreadNew(osRtxIdleThread, NULL, osRtxConfig.idle_thread_attr) - ); + svcRtxThreadNew(osRtxIdleThread, NULL, osRtxConfig.idle_thread_attr)); // Create Timer Thread if (osRtxConfig.timer_mq_mcnt != 0U) { osRtxInfo.timer.thread = osRtxThreadId( - svcRtxThreadNew(osRtxTimerThread, NULL, osRtxConfig.timer_thread_attr) - ); + svcRtxThreadNew(osRtxTimerThread, NULL, osRtxConfig.timer_thread_attr)); if (osRtxInfo.timer.thread == NULL) { ret = FALSE; } @@ -1657,11 +1683,11 @@ bool_t osRtxThreadStartup (void) { return ret; } - // ==== Public API ==== /// Create a thread and add it to Active Threads. -osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr) { +osThreadId_t osThreadNew(osThreadFunc_t func, void *argument, + const osThreadAttr_t *attr) { osThreadId_t thread_id; EvrRtxThreadNew(func, argument, attr); @@ -1675,7 +1701,7 @@ osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAtt } /// Get name of a thread. -const char *osThreadGetName (osThreadId_t thread_id) { +const char *osThreadGetName(osThreadId_t thread_id) { const char *name; if (IsIrqMode() || IsIrqMasked()) { @@ -1688,24 +1714,24 @@ const char *osThreadGetName (osThreadId_t thread_id) { } /// Return the thread ID of the current running thread. -osThreadId_t osThreadGetId (void) { +osThreadId_t osThreadGetId(void) { osThreadId_t thread_id; if (IsIrqMode() || IsIrqMasked()) { thread_id = svcRtxThreadGetId(); } else { - thread_id = __svcThreadGetId(); + thread_id = __svcThreadGetId(); } return thread_id; } -const char *osGetThreadName (void) { - os_thread_t *thread = osRtxThreadId(osThreadGetId()); - return thread->name; +const char *osGetThreadName(void) { + os_thread_t *thread = osRtxThreadId(osThreadGetId()); + return thread->name; } /// Get current thread state of a thread. -osThreadState_t osThreadGetState (osThreadId_t thread_id) { +osThreadState_t osThreadGetState(osThreadId_t thread_id) { osThreadState_t state; if (IsIrqMode() || IsIrqMasked()) { @@ -1718,7 +1744,7 @@ osThreadState_t osThreadGetState (osThreadId_t thread_id) { } /// Get stack size of a thread. -uint32_t osThreadGetStackSize (osThreadId_t thread_id) { +uint32_t osThreadGetStackSize(osThreadId_t thread_id) { uint32_t stack_size; if (IsIrqMode() || IsIrqMasked()) { @@ -1730,9 +1756,9 @@ uint32_t osThreadGetStackSize (osThreadId_t thread_id) { return stack_size; } - -/// Get available stack space of a thread based on stack watermark recording during execution. -uint32_t osThreadGetStackSpace (osThreadId_t thread_id) { +/// Get available stack space of a thread based on stack watermark recording +/// during execution. +uint32_t osThreadGetStackSpace(osThreadId_t thread_id) { uint32_t stack_space; if (IsIrqMode() || IsIrqMasked()) { @@ -1745,7 +1771,7 @@ uint32_t osThreadGetStackSpace (osThreadId_t thread_id) { } /// Change priority of a thread. -osStatus_t osThreadSetPriority (osThreadId_t thread_id, osPriority_t priority) { +osStatus_t osThreadSetPriority(osThreadId_t thread_id, osPriority_t priority) { osStatus_t status; EvrRtxThreadSetPriority(thread_id, priority); @@ -1759,7 +1785,7 @@ osStatus_t osThreadSetPriority (osThreadId_t thread_id, osPriority_t priority) { } /// Get current priority of a thread. -osPriority_t osThreadGetPriority (osThreadId_t thread_id) { +osPriority_t osThreadGetPriority(osThreadId_t thread_id) { osPriority_t priority; if (IsIrqMode() || IsIrqMasked()) { @@ -1772,7 +1798,7 @@ osPriority_t osThreadGetPriority (osThreadId_t thread_id) { } /// Pass control to next thread that is in state READY. -osStatus_t osThreadYield (void) { +osStatus_t osThreadYield(void) { osStatus_t status; EvrRtxThreadYield(); @@ -1786,7 +1812,7 @@ osStatus_t osThreadYield (void) { } /// Suspend execution of a thread. -osStatus_t osThreadSuspend (osThreadId_t thread_id) { +osStatus_t osThreadSuspend(osThreadId_t thread_id) { osStatus_t status; EvrRtxThreadSuspend(thread_id); @@ -1800,7 +1826,7 @@ osStatus_t osThreadSuspend (osThreadId_t thread_id) { } /// Resume execution of a thread. -osStatus_t osThreadResume (osThreadId_t thread_id) { +osStatus_t osThreadResume(osThreadId_t thread_id) { osStatus_t status; EvrRtxThreadResume(thread_id); @@ -1814,7 +1840,7 @@ osStatus_t osThreadResume (osThreadId_t thread_id) { } /// Detach a thread (thread storage can be reclaimed when thread terminates). -osStatus_t osThreadDetach (osThreadId_t thread_id) { +osStatus_t osThreadDetach(osThreadId_t thread_id) { osStatus_t status; EvrRtxThreadDetach(thread_id); @@ -1828,7 +1854,7 @@ osStatus_t osThreadDetach (osThreadId_t thread_id) { } /// Wait for specified thread to terminate. -osStatus_t osThreadJoin (osThreadId_t thread_id) { +osStatus_t osThreadJoin(osThreadId_t thread_id) { osStatus_t status; EvrRtxThreadJoin(thread_id); @@ -1842,15 +1868,16 @@ osStatus_t osThreadJoin (osThreadId_t thread_id) { } /// Terminate execution of current running thread. -__NO_RETURN void osThreadExit (void) { +__NO_RETURN void osThreadExit(void) { EvrRtxThreadExit(); __svcThreadExit(); EvrRtxThreadError(NULL, (int32_t)osError); - for (;;) {} + for (;;) { + } } /// Terminate execution of a thread. -osStatus_t osThreadTerminate (osThreadId_t thread_id) { +osStatus_t osThreadTerminate(osThreadId_t thread_id) { osStatus_t status; EvrRtxThreadTerminate(thread_id); @@ -1864,7 +1891,7 @@ osStatus_t osThreadTerminate (osThreadId_t thread_id) { } /// Get number of active threads. -uint32_t osThreadGetCount (void) { +uint32_t osThreadGetCount(void) { uint32_t count; if (IsIrqMode() || IsIrqMasked()) { @@ -1877,7 +1904,7 @@ uint32_t osThreadGetCount (void) { } /// Enumerate active threads. -uint32_t osThreadEnumerate (osThreadId_t *thread_array, uint32_t array_items) { +uint32_t osThreadEnumerate(osThreadId_t *thread_array, uint32_t array_items) { uint32_t count; if (IsIrqMode() || IsIrqMasked()) { @@ -1890,20 +1917,20 @@ uint32_t osThreadEnumerate (osThreadId_t *thread_array, uint32_t array_items) { } /// Set the specified Thread Flags of a thread. -uint32_t osThreadFlagsSet (osThreadId_t thread_id, uint32_t flags) { +uint32_t osThreadFlagsSet(osThreadId_t thread_id, uint32_t flags) { uint32_t thread_flags; EvrRtxThreadFlagsSet(thread_id, flags); if (IsIrqMode() || IsIrqMasked()) { thread_flags = isrRtxThreadFlagsSet(thread_id, flags); } else { - thread_flags = __svcThreadFlagsSet(thread_id, flags); + thread_flags = __svcThreadFlagsSet(thread_id, flags); } return thread_flags; } /// Clear the specified Thread Flags of current running thread. -uint32_t osThreadFlagsClear (uint32_t flags) { +uint32_t osThreadFlagsClear(uint32_t flags) { uint32_t thread_flags; EvrRtxThreadFlagsClear(flags); @@ -1917,7 +1944,7 @@ uint32_t osThreadFlagsClear (uint32_t flags) { } /// Get the current Thread Flags of current running thread. -uint32_t osThreadFlagsGet (void) { +uint32_t osThreadFlagsGet(void) { uint32_t thread_flags; if (IsIrqMode() || IsIrqMasked()) { @@ -1929,8 +1956,9 @@ uint32_t osThreadFlagsGet (void) { return thread_flags; } -/// Wait for one or more Thread Flags of the current running thread to become signaled. -uint32_t osThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout) { +/// Wait for one or more Thread Flags of the current running thread to become +/// signaled. +uint32_t osThreadFlagsWait(uint32_t flags, uint32_t options, uint32_t timeout) { uint32_t thread_flags; EvrRtxThreadFlagsWait(flags, options, timeout); @@ -1944,9 +1972,10 @@ uint32_t osThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout) } #if TASK_HUNG_CHECK_ENABLED /// enable/disable the hung check feature of an active thread -osStatus_t osThreadSetHungCheck (osThreadId_t thread_id, int32_t enable, uint32_t timeout) { +osStatus_t osThreadSetHungCheck(osThreadId_t thread_id, int32_t enable, + uint32_t timeout) { if (IsIrqMode() || IsIrqMasked()) - return osErrorISR; // Not allowed in ISR + return osErrorISR; // Not allowed in ISR return __svcThreadSetHungCheck(thread_id, enable, timeout); } #endif diff --git a/rtos/rtx5/rtx_thread_dump.c b/rtos/rtx5/rtx_thread_dump.c index b70cb4e..78ec8e7 100644 --- a/rtos/rtx5/rtx_thread_dump.c +++ b/rtos/rtx5/rtx_thread_dump.c @@ -23,377 +23,382 @@ * ----------------------------------------------------------------------------- */ -#include "rtx_lib.h" -#include "plat_addr_map.h" #include "hal_location.h" -#include "hal_trace.h" #include "hal_timer.h" +#include "hal_trace.h" +#include "plat_addr_map.h" +#include "rtx_lib.h" #define RTX_DUMP_VERBOSE struct IRQ_STACK_FRAME_T { - uint32_t r0; - uint32_t r1; - uint32_t r2; - uint32_t r3; - uint32_t r12; - uint32_t lr; - uint32_t pc; - uint32_t xpsr; + uint32_t r0; + uint32_t r1; + uint32_t r2; + uint32_t r3; + uint32_t r12; + uint32_t lr; + uint32_t pc; + uint32_t xpsr; }; extern uint32_t __StackTop[]; -static inline uint32_t get_IPSR(void) -{ +static inline uint32_t get_IPSR(void) { uint32_t result; - asm volatile ("MRS %0, ipsr" : "=r" (result) ); - return(result); + asm volatile("MRS %0, ipsr" : "=r"(result)); + return (result); } -static inline uint32_t get_PSP(void) -{ +static inline uint32_t get_PSP(void) { uint32_t result; - asm volatile ("MRS %0, psp" : "=r" (result) ); - return(result); + asm volatile("MRS %0, psp" : "=r"(result)); + return (result); } -static inline struct IRQ_STACK_FRAME_T *_rtx_get_irq_stack_frame(const os_thread_t *thread) -{ - uint32_t sp; +static inline struct IRQ_STACK_FRAME_T * +_rtx_get_irq_stack_frame(const os_thread_t *thread) { + uint32_t sp; - if (thread == NULL) { - return NULL; - } - if (thread == osRtxThreadGetRunning() && get_IPSR() == 0) { - return NULL; - } - if (thread == osRtxThreadGetRunning()) { - sp = get_PSP(); - } else { - sp = thread->sp; - } - if ((sp & 3) || !hal_trace_address_writable(sp)) { - return NULL; - } + if (thread == NULL) { + return NULL; + } + if (thread == osRtxThreadGetRunning() && get_IPSR() == 0) { + return NULL; + } + if (thread == osRtxThreadGetRunning()) { + sp = get_PSP(); + } else { + sp = thread->sp; + } + if ((sp & 3) || !hal_trace_address_writable(sp)) { + return NULL; + } - if (thread != osRtxThreadGetRunning()) { - // r4-r11 - sp += 4 * 8; - if ((thread->stack_frame & 0x10) == 0) { - // s16-s31 - sp += 4 * 16; - } + if (thread != osRtxThreadGetRunning()) { + // r4-r11 + sp += 4 * 8; + if ((thread->stack_frame & 0x10) == 0) { + // s16-s31 + sp += 4 * 16; } + } - return (struct IRQ_STACK_FRAME_T *)sp; + return (struct IRQ_STACK_FRAME_T *)sp; } FLASH_TEXT_LOC -void rtx_thread_show(const os_thread_t *thread) -{ - const char *thread_st_str; - struct IRQ_STACK_FRAME_T *frame; +void rtx_thread_show(const os_thread_t *thread) { + const char *thread_st_str; + struct IRQ_STACK_FRAME_T *frame; - if (thread) { - switch (thread->state) { - case osRtxThreadInactive: - thread_st_str = "INACTIVE"; - break; - case osRtxThreadReady: - thread_st_str = "READY"; - break; - case osRtxThreadRunning: - thread_st_str = "RUNNING"; - break; - case osRtxThreadTerminated: - thread_st_str = "TERMINAT"; - break; - case osRtxThreadWaitingDelay: - thread_st_str = "WAIT_DLY"; - break; - case osRtxThreadWaitingJoin: - thread_st_str = "WAIT_JOIN"; - break; - case osRtxThreadWaitingThreadFlags: - thread_st_str = "WAIT_FLAG"; - break; - case osRtxThreadWaitingEventFlags: - thread_st_str = "WAIT_EVE"; - break; - case osRtxThreadWaitingMutex: - thread_st_str = "WAIT_MUT"; - break; - case osRtxThreadWaitingSemaphore: - thread_st_str = "WAIT_SEM"; - break; - case osRtxThreadWaitingMemoryPool: - thread_st_str = "WAIT_MEM"; - break; - case osRtxThreadWaitingMessageGet: - thread_st_str = "WAIT_MGET"; - break; - case osRtxThreadWaitingMessagePut: - thread_st_str = "WAIT_MPUT"; - break; - default: - thread_st_str = "BAD"; - break; - } - REL_TRACE_NOCRLF_NOTS(0,"--- Thread "); - REL_TRACE_NOCRLF_NOTS(1,"name=%s", thread->name ? thread->name : "NULL"); + if (thread) { + switch (thread->state) { + case osRtxThreadInactive: + thread_st_str = "INACTIVE"; + break; + case osRtxThreadReady: + thread_st_str = "READY"; + break; + case osRtxThreadRunning: + thread_st_str = "RUNNING"; + break; + case osRtxThreadTerminated: + thread_st_str = "TERMINAT"; + break; + case osRtxThreadWaitingDelay: + thread_st_str = "WAIT_DLY"; + break; + case osRtxThreadWaitingJoin: + thread_st_str = "WAIT_JOIN"; + break; + case osRtxThreadWaitingThreadFlags: + thread_st_str = "WAIT_FLAG"; + break; + case osRtxThreadWaitingEventFlags: + thread_st_str = "WAIT_EVE"; + break; + case osRtxThreadWaitingMutex: + thread_st_str = "WAIT_MUT"; + break; + case osRtxThreadWaitingSemaphore: + thread_st_str = "WAIT_SEM"; + break; + case osRtxThreadWaitingMemoryPool: + thread_st_str = "WAIT_MEM"; + break; + case osRtxThreadWaitingMessageGet: + thread_st_str = "WAIT_MGET"; + break; + case osRtxThreadWaitingMessagePut: + thread_st_str = "WAIT_MPUT"; + break; + default: + thread_st_str = "BAD"; + break; + } + REL_TRACE_NOCRLF_NOTS(0, "--- Thread "); + REL_TRACE_NOCRLF_NOTS(1, "name=%s", thread->name ? thread->name : "NULL"); - REL_TRACE_NOTS(4," thread=0x%x, prio=%u state=%-9s thread_addr=0x%08X", (uint32_t)thread, thread->priority, thread_st_str, thread->thread_addr); + REL_TRACE_NOTS(4, " thread=0x%x, prio=%u state=%-9s thread_addr=0x%08X", + (uint32_t)thread, thread->priority, thread_st_str, + thread->thread_addr); #ifdef RTX_DUMP_VERBOSE - REL_TRACE_NOTS(4," thread_next=0x%08X thread_prev=0x%08X delay_next=0x%08X delay_prev=0x%08X", - (uint32_t)thread->thread_next, (uint32_t)thread->thread_prev, (uint32_t)thread->delay_next, (uint32_t)thread->delay_prev); - REL_TRACE_NOTS(4," thread_join=0x%08X flags_options=%u wait_flags=%u thread_flags=%u", - (uint32_t)thread->thread_join, thread->flags_options, thread->wait_flags, thread->thread_flags); - REL_TRACE_NOTS(3," stack_mem=0x%08X stack_size=%u sp:0x%04x", - (uint32_t)thread->stack_mem, thread->stack_size, thread->sp); + REL_TRACE_NOTS(4, + " thread_next=0x%08X thread_prev=0x%08X " + "delay_next=0x%08X delay_prev=0x%08X", + (uint32_t)thread->thread_next, (uint32_t)thread->thread_prev, + (uint32_t)thread->delay_next, (uint32_t)thread->delay_prev); + REL_TRACE_NOTS( + 4, + " thread_join=0x%08X flags_options=%u wait_flags=%u thread_flags=%u", + (uint32_t)thread->thread_join, thread->flags_options, + thread->wait_flags, thread->thread_flags); + REL_TRACE_NOTS(3, " stack_mem=0x%08X stack_size=%u sp:0x%04x", + (uint32_t)thread->stack_mem, thread->stack_size, thread->sp); #ifdef __RTX_CPU_STATISTICS__ - REL_TRACE_NOTS(2," swap_in_time=%u swap_out_time=%u", - thread->swap_in_time, thread->swap_out_time); - REL_TRACE_NOCRLF_NOTS(0," after last switch "); - if (thread->swap_in_time <= thread->swap_out_time) - REL_TRACE_NOTS(1,"thread runtime %ums", thread->swap_out_time - thread->swap_in_time); - else - REL_TRACE_NOTS(1,"thread still runing, now %d", HWTICKS_TO_MS(rtx_get_hwticks())); + REL_TRACE_NOTS(2, " swap_in_time=%u swap_out_time=%u", + thread->swap_in_time, thread->swap_out_time); + REL_TRACE_NOCRLF_NOTS(0, " after last switch "); + if (thread->swap_in_time <= thread->swap_out_time) + REL_TRACE_NOTS(1, "thread runtime %ums", + thread->swap_out_time - thread->swap_in_time); + else + REL_TRACE_NOTS(1, "thread still runing, now %d", + HWTICKS_TO_MS(rtx_get_hwticks())); #endif #endif /*RTX_DUMP_VERBOSE*/ - frame = _rtx_get_irq_stack_frame(thread); - if (frame) { - uint32_t stack_end; - uint32_t search_cnt, print_cnt; + frame = _rtx_get_irq_stack_frame(thread); + if (frame) { + uint32_t stack_end; + uint32_t search_cnt, print_cnt; - REL_TRACE_NOTS(1," frame:0x%08X", (uint32_t)frame); - REL_TRACE_NOTS(4," R0 =0x%08X R1=0x%08X R2=0x%08X R3 =0x%08X", frame->r0, frame->r1, frame->r2, frame->r3); - REL_TRACE_NOTS(4," R12=0x%08X LR=0x%08X PC=0x%08X XPSR=0x%08X", frame->r12, frame->lr, frame->pc, frame->xpsr); + REL_TRACE_NOTS(1, " frame:0x%08X", (uint32_t)frame); + REL_TRACE_NOTS(4, " R0 =0x%08X R1=0x%08X R2=0x%08X R3 =0x%08X", + frame->r0, frame->r1, frame->r2, frame->r3); + REL_TRACE_NOTS(4, " R12=0x%08X LR=0x%08X PC=0x%08X XPSR=0x%08X", + frame->r12, frame->lr, frame->pc, frame->xpsr); - stack_end = (uint32_t)thread->stack_mem + thread->stack_size; - if (stack_end > thread->sp) { - search_cnt = (stack_end - thread->sp) / 4; - if (search_cnt > 512) { - search_cnt = 512; - } - print_cnt = 10; - hal_trace_print_backtrace(thread->sp, search_cnt, print_cnt); - } + stack_end = (uint32_t)thread->stack_mem + thread->stack_size; + if (stack_end > thread->sp) { + search_cnt = (stack_end - thread->sp) / 4; + if (search_cnt > 512) { + search_cnt = 512; } - } else { - REL_TRACE_NOTS(0,"--- Thread NONE"); + print_cnt = 10; + hal_trace_print_backtrace(thread->sp, search_cnt, print_cnt); + } } + } else { + REL_TRACE_NOTS(0, "--- Thread NONE"); + } - - REL_TRACE_IMM_NOTS(0," "); + REL_TRACE_IMM_NOTS(0, " "); #if (defined(DEBUG) || defined(REL_TRACE_ENABLE)) - if (hal_trace_crash_dump_onprocess()){ - hal_sys_timer_delay(MS_TO_TICKS(500)); - } + if (hal_trace_crash_dump_onprocess()) { + hal_sys_timer_delay(MS_TO_TICKS(500)); + } #endif } -void rtx_show_all_threads(void) -{ - int i; - const os_thread_t *thread; +void rtx_show_all_threads(void) { + int i; + const os_thread_t *thread; #if (defined(DEBUG) || defined(REL_TRACE_ENABLE)) - if (hal_trace_crash_dump_onprocess()){ - for (i = 0; i < 10; i++){ - REL_TRACE_IMM_NOTS(0," "); - REL_TRACE_IMM_NOTS(0," \n"); - hal_sys_timer_delay(MS_TO_TICKS(200)); - } + if (hal_trace_crash_dump_onprocess()) { + for (i = 0; i < 10; i++) { + REL_TRACE_IMM_NOTS(0, " " + " "); + REL_TRACE_IMM_NOTS(0, " " + " \n"); + hal_sys_timer_delay(MS_TO_TICKS(200)); } + } #endif - REL_TRACE_NOTS(0,"Thread List:"); + REL_TRACE_NOTS(0, "Thread List:"); - // Current List - REL_TRACE_NOTS(0,"Current List"); - rtx_thread_show(osRtxInfo.thread.run.curr); + // Current List + REL_TRACE_NOTS(0, "Current List"); + rtx_thread_show(osRtxInfo.thread.run.curr); - // Next List - if (osRtxInfo.thread.run.next != osRtxInfo.thread.run.curr) { - REL_TRACE_NOTS(0,"Next List"); - rtx_thread_show(osRtxInfo.thread.run.next); - } + // Next List + if (osRtxInfo.thread.run.next != osRtxInfo.thread.run.curr) { + REL_TRACE_NOTS(0, "Next List"); + rtx_thread_show(osRtxInfo.thread.run.next); + } - // Ready List - REL_TRACE_NOTS(0,"Ready List"); - for (thread = osRtxInfo.thread.ready.thread_list; - thread != NULL; thread = thread->thread_next) { - rtx_thread_show(thread); - } + // Ready List + REL_TRACE_NOTS(0, "Ready List"); + for (thread = osRtxInfo.thread.ready.thread_list; thread != NULL; + thread = thread->thread_next) { + rtx_thread_show(thread); + } - // Delay List - REL_TRACE_NOTS(0,"Delay List"); - for (thread = osRtxInfo.thread.delay_list; - thread != NULL; thread = thread->delay_next) { - rtx_thread_show(thread); - } + // Delay List + REL_TRACE_NOTS(0, "Delay List"); + for (thread = osRtxInfo.thread.delay_list; thread != NULL; + thread = thread->delay_next) { + rtx_thread_show(thread); + } - // Wait List - REL_TRACE_NOTS(0,"Wait List"); - for (thread = osRtxInfo.thread.wait_list; - thread != NULL; thread = thread->delay_next) { - rtx_thread_show(thread); - } + // Wait List + REL_TRACE_NOTS(0, "Wait List"); + for (thread = osRtxInfo.thread.wait_list; thread != NULL; + thread = thread->delay_next) { + rtx_thread_show(thread); + } - // Terminate List - REL_TRACE_NOTS(0,"Terminate List"); - for (thread = osRtxInfo.thread.terminate_list; - thread != NULL; thread = thread->thread_next) { - rtx_thread_show(thread); - } + // Terminate List + REL_TRACE_NOTS(0, "Terminate List"); + for (thread = osRtxInfo.thread.terminate_list; thread != NULL; + thread = thread->thread_next) { + rtx_thread_show(thread); + } - REL_TRACE_IMM_NOTS(0," "); + REL_TRACE_IMM_NOTS(0, " "); } #if __RTX_CPU_STATISTICS__ #if TASK_HUNG_CHECK_ENABLED -FLASH_TEXT_LOC NOINLINE -static void print_hung_task(const os_thread_t *thread, U32 curr_time) -{ - REL_TRACE_IMM_NOTS(2,"Thread \"%s\" blocked for %dms", - thread->name==NULL ? "NULL" : (char *)thread->name, - curr_time - thread->swap_out_time); - ASSERT(0, "Find thread hung "); +FLASH_TEXT_LOC NOINLINE static void print_hung_task(const os_thread_t *thread, + U32 curr_time) { + REL_TRACE_IMM_NOTS(2, "Thread \"%s\" blocked for %dms", + thread->name == NULL ? "NULL" : (char *)thread->name, + curr_time - thread->swap_out_time); + ASSERT(0, "Find thread hung "); } -static void check_hung_thread(const os_thread_t *thread) -{ - uint32_t curr_hwticks, curr_time; +static void check_hung_thread(const os_thread_t *thread) { + uint32_t curr_hwticks, curr_time; - if (!thread->hung_check) - return; + if (!thread->hung_check) + return; - curr_hwticks = hal_sys_timer_get(); - curr_time = HWTICKS_TO_MS(curr_hwticks); - if((curr_time - thread->swap_out_time) > thread->hung_check_timeout) { - print_hung_task(thread, curr_time); - } + curr_hwticks = hal_sys_timer_get(); + curr_time = HWTICKS_TO_MS(curr_hwticks); + if ((curr_time - thread->swap_out_time) > thread->hung_check_timeout) { + print_hung_task(thread, curr_time); + } } -void check_hung_threads(void) -{ - const os_thread_t *thread; - // Current List - check_hung_thread(osRtxInfo.thread.run.curr); +void check_hung_threads(void) { + const os_thread_t *thread; + // Current List + check_hung_thread(osRtxInfo.thread.run.curr); - // Next List - if (osRtxInfo.thread.run.next != osRtxInfo.thread.run.curr) - check_hung_thread(osRtxInfo.thread.run.next); + // Next List + if (osRtxInfo.thread.run.next != osRtxInfo.thread.run.curr) + check_hung_thread(osRtxInfo.thread.run.next); - // Ready List - for (thread = osRtxInfo.thread.ready.thread_list; - thread != NULL; thread = thread->thread_next) { - check_hung_thread(thread); - } + // Ready List + for (thread = osRtxInfo.thread.ready.thread_list; thread != NULL; + thread = thread->thread_next) { + check_hung_thread(thread); + } - // Delay List - for (thread = osRtxInfo.thread.delay_list; - thread != NULL; thread = thread->delay_next) { - check_hung_thread(thread); - } + // Delay List + for (thread = osRtxInfo.thread.delay_list; thread != NULL; + thread = thread->delay_next) { + check_hung_thread(thread); + } - // Wait List - for (thread = osRtxInfo.thread.wait_list; - thread != NULL; thread = thread->delay_next) { - check_hung_thread(thread); - } + // Wait List + for (thread = osRtxInfo.thread.wait_list; thread != NULL; + thread = thread->delay_next) { + check_hung_thread(thread); + } - // Terminate List - for (thread = osRtxInfo.thread.terminate_list; - thread != NULL; thread = thread->thread_next) { - check_hung_thread(thread); - } + // Terminate List + for (thread = osRtxInfo.thread.terminate_list; thread != NULL; + thread = thread->thread_next) { + check_hung_thread(thread); + } } #endif -static inline void print_thread_sw_statitics(const os_thread_t *thread) -{ - /* - REL_TRACE_NOTS(3,"--- Thread swap in:%d out=%d runings %d", - thread->swap_in_time, - thread->swap_out_time, - thread->rtime); - */ +static inline void print_thread_sw_statitics(const os_thread_t *thread) { + /* + REL_TRACE_NOTS(3,"--- Thread swap in:%d out=%d runings %d", + thread->swap_in_time, + thread->swap_out_time, + thread->rtime); + */ } FLASH_TEXT_LOC -static void _rtx_show_thread_usage(const os_thread_t *thread, uint32_t sample_time) -{ - if (thread) { - if (thread->thread_addr && thread->stack_mem) { - REL_TRACE_NOTS(4,"--- Thread name=%s cpu=%%%d", - thread->name==NULL ? "null" : (char *)thread->name, - sample_time != 0 ? ((thread->rtime - thread->step_rtime) * 100 / sample_time) : 0); - print_thread_sw_statitics(thread); - ((os_thread_t *)thread)->step_rtime = thread->rtime; - } else { - REL_TRACE_NOTS(0,"--- Thread BAD"); - } +static void _rtx_show_thread_usage(const os_thread_t *thread, + uint32_t sample_time) { + if (thread) { + if (thread->thread_addr && thread->stack_mem) { + REL_TRACE_NOTS(4, "--- Thread name=%s cpu=%%%d", + thread->name == NULL ? "null" : (char *)thread->name, + sample_time != 0 ? ((thread->rtime - thread->step_rtime) * + 100 / sample_time) + : 0); + print_thread_sw_statitics(thread); + ((os_thread_t *)thread)->step_rtime = thread->rtime; } else { - REL_TRACE_NOTS(0,"--- Thread NONE"); + REL_TRACE_NOTS(0, "--- Thread BAD"); } + } else { + REL_TRACE_NOTS(0, "--- Thread NONE"); + } } FLASH_TEXT_LOC -void rtx_show_all_threads_usage(void) -{ - const os_thread_t *thread; - static bool first_time = 1; - uint32_t sample_time; - static uint32_t start_sample_time = 0; +void rtx_show_all_threads_usage(void) { + const os_thread_t *thread; + static bool first_time = 1; + uint32_t sample_time; + static uint32_t start_sample_time = 0; - if (first_time) { - start_sample_time = rtx_get_hwticks(); - first_time = 0; - return; - } + if (first_time) { + start_sample_time = rtx_get_hwticks(); + first_time = 0; + return; + } - sample_time = HWTICKS_TO_MS(rtx_get_hwticks() - start_sample_time); - REL_TRACE_IMM_NOTS(0," "); - REL_TRACE_NOTS(0,"Thread List:"); + sample_time = HWTICKS_TO_MS(rtx_get_hwticks() - start_sample_time); + REL_TRACE_IMM_NOTS(0, " "); + REL_TRACE_NOTS(0, "Thread List:"); - // Current List - _rtx_show_thread_usage(osRtxInfo.thread.run.curr, sample_time); + // Current List + _rtx_show_thread_usage(osRtxInfo.thread.run.curr, sample_time); - // Next List - if (osRtxInfo.thread.run.next != osRtxInfo.thread.run.curr) - _rtx_show_thread_usage(osRtxInfo.thread.run.next, sample_time); + // Next List + if (osRtxInfo.thread.run.next != osRtxInfo.thread.run.curr) + _rtx_show_thread_usage(osRtxInfo.thread.run.next, sample_time); - // Ready List - for (thread = osRtxInfo.thread.ready.thread_list; - thread != NULL; thread = thread->thread_next) { - _rtx_show_thread_usage(thread, sample_time); - } + // Ready List + for (thread = osRtxInfo.thread.ready.thread_list; thread != NULL; + thread = thread->thread_next) { + _rtx_show_thread_usage(thread, sample_time); + } - // Delay List - for (thread = osRtxInfo.thread.delay_list; - thread != NULL; thread = thread->delay_next) { - _rtx_show_thread_usage(thread, sample_time); - } + // Delay List + for (thread = osRtxInfo.thread.delay_list; thread != NULL; + thread = thread->delay_next) { + _rtx_show_thread_usage(thread, sample_time); + } - // Wait List - for (thread = osRtxInfo.thread.wait_list; - thread != NULL; thread = thread->delay_next) { - _rtx_show_thread_usage(thread, sample_time); - } + // Wait List + for (thread = osRtxInfo.thread.wait_list; thread != NULL; + thread = thread->delay_next) { + _rtx_show_thread_usage(thread, sample_time); + } - // Terminate List - for (thread = osRtxInfo.thread.terminate_list; - thread != NULL; thread = thread->thread_next) { - _rtx_show_thread_usage(thread, sample_time); - } - start_sample_time = rtx_get_hwticks(); - REL_TRACE_IMM_NOTS(0," "); + // Terminate List + for (thread = osRtxInfo.thread.terminate_list; thread != NULL; + thread = thread->thread_next) { + _rtx_show_thread_usage(thread, sample_time); + } + start_sample_time = rtx_get_hwticks(); + REL_TRACE_IMM_NOTS(0, " "); } #endif - diff --git a/rtos/rtx5/rtx_timer.c b/rtos/rtx5/rtx_timer.c index de3c987..d08857a 100644 --- a/rtos/rtx5/rtx_timer.c +++ b/rtos/rtx5/rtx_timer.c @@ -25,36 +25,33 @@ #include "rtx_lib.h" - // OS Runtime Object Memory Usage #if ((defined(OS_OBJ_MEM_USAGE) && (OS_OBJ_MEM_USAGE != 0))) -osRtxObjectMemUsage_t osRtxTimerMemUsage \ -__attribute__((section(".data.os.timer.obj"))) = -{ 0U, 0U, 0U }; +osRtxObjectMemUsage_t osRtxTimerMemUsage + __attribute__((section(".data.os.timer.obj"))) = {0U, 0U, 0U}; #endif - // ==== Helper functions ==== /// Insert Timer into the Timer List sorted by Time. /// \param[in] timer timer object. /// \param[in] tick timer tick. -static void TimerInsert (os_timer_t *timer, uint32_t tick) { +static void TimerInsert(os_timer_t *timer, uint32_t tick) { os_timer_t *prev, *next; prev = NULL; next = osRtxInfo.timer.list; while ((next != NULL) && (next->tick <= tick)) { tick -= next->tick; - prev = next; - next = next->next; + prev = next; + next = next->next; } timer->tick = tick; timer->prev = prev; timer->next = next; if (next != NULL) { next->tick -= timer->tick; - next->prev = timer; + next->prev = timer; } if (prev != NULL) { prev->next = timer; @@ -65,14 +62,14 @@ static void TimerInsert (os_timer_t *timer, uint32_t tick) { /// Remove Timer from the Timer List. /// \param[in] timer timer object. -static void TimerRemove (const os_timer_t *timer) { +static void TimerRemove(const os_timer_t *timer) { if (timer->next != NULL) { timer->next->tick += timer->tick; - timer->next->prev = timer->prev; + timer->next->prev = timer->prev; } if (timer->prev != NULL) { - timer->prev->next = timer->next; + timer->prev->next = timer->next; } else { osRtxInfo.timer.list = timer->next; } @@ -80,7 +77,7 @@ static void TimerRemove (const os_timer_t *timer) { /// Unlink Timer from the Timer List Head. /// \param[in] timer timer object. -static void TimerUnlink (const os_timer_t *timer) { +static void TimerUnlink(const os_timer_t *timer) { if (timer->next != NULL) { timer->next->prev = timer->prev; @@ -88,17 +85,16 @@ static void TimerUnlink (const os_timer_t *timer) { osRtxInfo.timer.list = timer->next; } - // ==== Library functions ==== /// Timer Tick (called each SysTick). -static void osRtxTimerTick (void) { +static void osRtxTimerTick(void) { os_timer_t *timer; - osStatus_t status; + osStatus_t status; timer = osRtxInfo.timer.list; if (timer == NULL) { - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return; } @@ -119,18 +115,18 @@ static void osRtxTimerTick (void) { } /// Timer Thread -__WEAK __NO_RETURN void osRtxTimerThread (void *argument) { +__WEAK __NO_RETURN void osRtxTimerThread(void *argument) { os_timer_finfo_t finfo; - osStatus_t status; - (void) argument; + osStatus_t status; + (void)argument; osRtxInfo.timer.mq = osRtxMessageQueueId( - osMessageQueueNew(osRtxConfig.timer_mq_mcnt, sizeof(os_timer_finfo_t), osRtxConfig.timer_mq_attr) - ); + osMessageQueueNew(osRtxConfig.timer_mq_mcnt, sizeof(os_timer_finfo_t), + osRtxConfig.timer_mq_attr)); osRtxInfo.timer.tick = osRtxTimerTick; for (;;) { - //lint -e{934} "Taking address of near auto variable" + // lint -e{934} "Taking address of near auto variable" status = osMessageQueueGet(osRtxInfo.timer.mq, &finfo, NULL, osWaitForever); if (status == osOK) { EvrRtxTimerCallback(finfo.func, finfo.arg); @@ -143,49 +139,55 @@ __WEAK __NO_RETURN void osRtxTimerThread (void *argument) { /// Create and Initialize a timer. /// \note API identical to osTimerNew -static osTimerId_t svcRtxTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr) { +static osTimerId_t svcRtxTimerNew(osTimerFunc_t func, osTimerType_t type, + void *argument, const osTimerAttr_t *attr) { os_timer_t *timer; - uint8_t flags; + uint8_t flags; const char *name; // Check parameters if ((func == NULL) || ((type != osTimerOnce) && (type != osTimerPeriodic))) { EvrRtxTimerError(NULL, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } // Process attributes if (attr != NULL) { - name = attr->name; - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 6] + name = attr->name; + // lint -e{9079} "conversion from pointer to void to pointer to other type" + // [MISRA Note 6] timer = attr->cb_mem; if (timer != NULL) { - //lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note 7] - if ((((uint32_t)timer & 3U) != 0U) || (attr->cb_size < sizeof(os_timer_t))) { + // lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note + // 7] + if ((((uint32_t)timer & 3U) != 0U) || + (attr->cb_size < sizeof(os_timer_t))) { EvrRtxTimerError(NULL, osRtxErrorInvalidControlBlock); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } else { if (attr->cb_size != 0U) { EvrRtxTimerError(NULL, osRtxErrorInvalidControlBlock); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } } } else { - name = NULL; + name = NULL; timer = NULL; } // Allocate object memory if not provided if (timer == NULL) { if (osRtxInfo.mpi.timer != NULL) { - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] timer = osRtxMemoryPoolAlloc(osRtxInfo.mpi.timer); } else { - //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5] + // lint -e{9079} "conversion from pointer to void to pointer to other + // type" [MISRA Note 5] timer = osRtxMemoryAlloc(osRtxInfo.mem.common, sizeof(os_timer_t), 1U); } #if (defined(OS_OBJ_MEM_USAGE) && (OS_OBJ_MEM_USAGE != 0)) @@ -205,17 +207,17 @@ static osTimerId_t svcRtxTimerNew (osTimerFunc_t func, osTimerType_t type, void if (timer != NULL) { // Initialize control block - timer->id = osRtxIdTimer; - timer->state = osRtxTimerStopped; - timer->flags = flags; - timer->type = (uint8_t)type; - timer->name = name; - timer->prev = NULL; - timer->next = NULL; - timer->tick = 0U; - timer->load = 0U; + timer->id = osRtxIdTimer; + timer->state = osRtxTimerStopped; + timer->flags = flags; + timer->type = (uint8_t)type; + timer->name = name; + timer->prev = NULL; + timer->next = NULL; + timer->tick = 0U; + timer->load = 0U; timer->finfo.func = func; - timer->finfo.arg = argument; + timer->finfo.arg = argument; EvrRtxTimerCreated(timer, timer->name); } else { @@ -227,13 +229,13 @@ static osTimerId_t svcRtxTimerNew (osTimerFunc_t func, osTimerType_t type, void /// Get name of a timer. /// \note API identical to osTimerGetName -static const char *svcRtxTimerGetName (osTimerId_t timer_id) { +static const char *svcRtxTimerGetName(osTimerId_t timer_id) { os_timer_t *timer = osRtxTimerId(timer_id); // Check parameters if ((timer == NULL) || (timer->id != osRtxIdTimer)) { EvrRtxTimerGetName(timer, NULL); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return NULL; } @@ -244,13 +246,13 @@ static const char *svcRtxTimerGetName (osTimerId_t timer_id) { /// Start or restart a timer. /// \note API identical to osTimerStart -static osStatus_t svcRtxTimerStart (osTimerId_t timer_id, uint32_t ticks) { +static osStatus_t svcRtxTimerStart(osTimerId_t timer_id, uint32_t ticks) { os_timer_t *timer = osRtxTimerId(timer_id); // Check parameters if ((timer == NULL) || (timer->id != osRtxIdTimer) || (ticks == 0U)) { EvrRtxTimerError(timer, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } @@ -259,11 +261,11 @@ static osStatus_t svcRtxTimerStart (osTimerId_t timer_id, uint32_t ticks) { } else { if (osRtxInfo.timer.tick == NULL) { EvrRtxTimerError(timer, (int32_t)osErrorResource); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorResource; } else { timer->state = osRtxTimerRunning; - timer->load = ticks; + timer->load = ticks; } } @@ -276,20 +278,20 @@ static osStatus_t svcRtxTimerStart (osTimerId_t timer_id, uint32_t ticks) { /// Stop a timer. /// \note API identical to osTimerStop -static osStatus_t svcRtxTimerStop (osTimerId_t timer_id) { +static osStatus_t svcRtxTimerStop(osTimerId_t timer_id) { os_timer_t *timer = osRtxTimerId(timer_id); // Check parameters if ((timer == NULL) || (timer->id != osRtxIdTimer)) { EvrRtxTimerError(timer, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } // Check object state if (timer->state != osRtxTimerRunning) { EvrRtxTimerError(timer, (int32_t)osErrorResource); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorResource; } @@ -304,14 +306,14 @@ static osStatus_t svcRtxTimerStop (osTimerId_t timer_id) { /// Check if a timer is running. /// \note API identical to osTimerIsRunning -static uint32_t svcRtxTimerIsRunning (osTimerId_t timer_id) { +static uint32_t svcRtxTimerIsRunning(osTimerId_t timer_id) { os_timer_t *timer = osRtxTimerId(timer_id); - uint32_t is_running; + uint32_t is_running; // Check parameters if ((timer == NULL) || (timer->id != osRtxIdTimer)) { EvrRtxTimerIsRunning(timer, 0U); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return 0U; } @@ -328,13 +330,13 @@ static uint32_t svcRtxTimerIsRunning (osTimerId_t timer_id) { /// Delete a timer. /// \note API identical to osTimerDelete -static osStatus_t svcRtxTimerDelete (osTimerId_t timer_id) { +static osStatus_t svcRtxTimerDelete(osTimerId_t timer_id) { os_timer_t *timer = osRtxTimerId(timer_id); // Check parameters if ((timer == NULL) || (timer->id != osRtxIdTimer)) { EvrRtxTimerError(timer, (int32_t)osErrorParameter); - //lint -e{904} "Return statement before end of function" [MISRA Note 1] + // lint -e{904} "Return statement before end of function" [MISRA Note 1] return osErrorParameter; } @@ -344,7 +346,7 @@ static osStatus_t svcRtxTimerDelete (osTimerId_t timer_id) { // Mark object as inactive and invalid timer->state = osRtxTimerInactive; - timer->id = osRtxIdInvalid; + timer->id = osRtxIdInvalid; // Free object memory if ((timer->flags & osRtxFlagSystemObject) != 0U) { @@ -364,20 +366,21 @@ static osStatus_t svcRtxTimerDelete (osTimerId_t timer_id) { } // Service Calls definitions -//lint ++flb "Library Begin" [MISRA Note 11] -SVC0_4(TimerNew, osTimerId_t, osTimerFunc_t, osTimerType_t, void *, const osTimerAttr_t *) -SVC0_1(TimerGetName, const char *, osTimerId_t) -SVC0_2(TimerStart, osStatus_t, osTimerId_t, uint32_t) -SVC0_1(TimerStop, osStatus_t, osTimerId_t) -SVC0_1(TimerIsRunning, uint32_t, osTimerId_t) -SVC0_1(TimerDelete, osStatus_t, osTimerId_t) -//lint --flb "Library End" - +// lint ++flb "Library Begin" [MISRA Note 11] +SVC0_4(TimerNew, osTimerId_t, osTimerFunc_t, osTimerType_t, void *, + const osTimerAttr_t *) +SVC0_1(TimerGetName, const char *, osTimerId_t) +SVC0_2(TimerStart, osStatus_t, osTimerId_t, uint32_t) +SVC0_1(TimerStop, osStatus_t, osTimerId_t) +SVC0_1(TimerIsRunning, uint32_t, osTimerId_t) +SVC0_1(TimerDelete, osStatus_t, osTimerId_t) +// lint --flb "Library End" // ==== Public API ==== /// Create and Initialize a timer. -osTimerId_t osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr) { +osTimerId_t osTimerNew(osTimerFunc_t func, osTimerType_t type, void *argument, + const osTimerAttr_t *attr) { osTimerId_t timer_id; EvrRtxTimerNew(func, type, argument, attr); @@ -391,7 +394,7 @@ osTimerId_t osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, } /// Get name of a timer. -const char *osTimerGetName (osTimerId_t timer_id) { +const char *osTimerGetName(osTimerId_t timer_id) { const char *name; if (IsIrqMode() || IsIrqMasked()) { @@ -404,7 +407,7 @@ const char *osTimerGetName (osTimerId_t timer_id) { } /// Start or restart a timer. -osStatus_t osTimerStart (osTimerId_t timer_id, uint32_t ticks) { +osStatus_t osTimerStart(osTimerId_t timer_id, uint32_t ticks) { osStatus_t status; EvrRtxTimerStart(timer_id, ticks); @@ -418,7 +421,7 @@ osStatus_t osTimerStart (osTimerId_t timer_id, uint32_t ticks) { } /// Stop a timer. -osStatus_t osTimerStop (osTimerId_t timer_id) { +osStatus_t osTimerStop(osTimerId_t timer_id) { osStatus_t status; EvrRtxTimerStop(timer_id); @@ -432,7 +435,7 @@ osStatus_t osTimerStop (osTimerId_t timer_id) { } /// Check if a timer is running. -uint32_t osTimerIsRunning (osTimerId_t timer_id) { +uint32_t osTimerIsRunning(osTimerId_t timer_id) { uint32_t is_running; if (IsIrqMode() || IsIrqMasked()) { @@ -445,7 +448,7 @@ uint32_t osTimerIsRunning (osTimerId_t timer_id) { } /// Delete a timer. -osStatus_t osTimerDelete (osTimerId_t timer_id) { +osStatus_t osTimerDelete(osTimerId_t timer_id) { osStatus_t status; EvrRtxTimerDelete(timer_id); diff --git a/services/app_ai/src/app_ai_algorithm.cpp b/services/app_ai/src/app_ai_algorithm.cpp index d5d8819..95c480e 100644 --- a/services/app_ai/src/app_ai_algorithm.cpp +++ b/services/app_ai/src/app_ai_algorithm.cpp @@ -1,13 +1,13 @@ #ifdef AI_ALGORITHM_ENABLE +#include "app_ai_algorithm.h" +#include "audio_dump.h" #include "cmsis_os.h" +#include "cqueue.h" #include "hal_aud.h" #include "hal_location.h" #include "hal_trace.h" -#include "app_ai_algorithm.h" -#include "cqueue.h" #include "heap_api.h" -#include "audio_dump.h" #include "norflash_api.h" #ifdef BISTO_ENABLED @@ -27,51 +27,52 @@ #define AI_CP_BSS_LOC #endif -#define AI_CP_CACHE_ATTR ALIGNED(4) AI_CP_BSS_LOC +#define AI_CP_CACHE_ATTR ALIGNED(4) AI_CP_BSS_LOC -#define AI_ABS(x) (x>=0?x:(-x)) +#define AI_ABS(x) (x >= 0 ? x : (-x)) -#define FRAME_LEN (256) +#define FRAME_LEN (256) #if AI_CAPTURE_CHANNEL_NUM == 2 -#define CAPTURE_CHANNEL_NUM (2) +#define CAPTURE_CHANNEL_NUM (2) #else -#define CAPTURE_CHANNEL_NUM (1) +#define CAPTURE_CHANNEL_NUM (1) #endif #ifdef AI_CAPTURE_DATA_AEC -#define AUDIO_CHANNEL_NUM (2) +#define AUDIO_CHANNEL_NUM (2) #else -#define AUDIO_CHANNEL_NUM (0) +#define AUDIO_CHANNEL_NUM (0) #endif -#define CAPTURE_AUDIO_CHANNEL_NUM (CAPTURE_CHANNEL_NUM+AUDIO_CHANNEL_NUM) -#define MIC_DATA_PROCESS_SIZE (FRAME_LEN * CAPTURE_AUDIO_CHANNEL_NUM * sizeof(short)) +#define CAPTURE_AUDIO_CHANNEL_NUM (CAPTURE_CHANNEL_NUM + AUDIO_CHANNEL_NUM) +#define MIC_DATA_PROCESS_SIZE \ + (FRAME_LEN * CAPTURE_AUDIO_CHANNEL_NUM * sizeof(short)) #define AI_AEC_CACHE_NUM 6 -typedef struct -{ - uint8_t cp_data_cache[AI_AEC_CACHE_NUM][MIC_DATA_PROCESS_SIZE]; - uint8_t cp_data_in_cache_num; - uint8_t cp_data_process_cache_num; - uint8_t cp_data_out_cache_num; - uint8_t cp_data_use_cache_num; - uint8_t cp_data_use_max_cache_num; - AI_AEC_CACHE_STATE_E cache_state[AI_AEC_CACHE_NUM]; -} AI_AEC_struct ; +typedef struct { + uint8_t cp_data_cache[AI_AEC_CACHE_NUM][MIC_DATA_PROCESS_SIZE]; + uint8_t cp_data_in_cache_num; + uint8_t cp_data_process_cache_num; + uint8_t cp_data_out_cache_num; + uint8_t cp_data_use_cache_num; + uint8_t cp_data_use_max_cache_num; + AI_AEC_CACHE_STATE_E cache_state[AI_AEC_CACHE_NUM]; +} AI_AEC_struct; -#define MED_MEM_POOL_SIZE (1024*136) +#define MED_MEM_POOL_SIZE (1024 * 136) static uint8_t g_medMemPool[MED_MEM_POOL_SIZE] __attribute__((aligned(4))); osMutexId mic_data_handle_mutex_id = NULL; osMutexDef(mic_data_handle_queue_mutex); -#define LOCK_MIC_DATA_HANDLE_QUEUE() \ - osMutexWait(mic_data_handle_mutex_id, osWaitForever); +#define LOCK_MIC_DATA_HANDLE_QUEUE() \ + osMutexWait(mic_data_handle_mutex_id, osWaitForever); -#define UNLOCK_MIC_DATA_HANDLE_QUEUE() \ - osMutexRelease(mic_data_handle_mutex_id); +#define UNLOCK_MIC_DATA_HANDLE_QUEUE() osMutexRelease(mic_data_handle_mutex_id); CQueue mic_data_handle_queue; -unsigned char mic_data_handle_queue_buff[MIC_DATA_PROCESS_SIZE * 6] __attribute__((aligned(4))); -unsigned char mic_data_handle_temp_buff[MIC_DATA_PROCESS_SIZE] __attribute__((aligned(4))); +unsigned char mic_data_handle_queue_buff[MIC_DATA_PROCESS_SIZE * 6] + __attribute__((aligned(4))); +unsigned char mic_data_handle_temp_buff[MIC_DATA_PROCESS_SIZE] + __attribute__((aligned(4))); #ifdef AI_CAPTURE_DATA_AEC static bool ai_aec_inited = false; @@ -89,23 +90,23 @@ static AI_CP_BSS_LOC short aec2_out_buf2[FRAME_LEN] = {0}; #endif Ec2FloatConfig speech_aec2float_cfg = { - .bypass = 0, - .hpf_enabled = false, - .af_enabled = true, - .nlp_enabled = false, - .clip_enabled = false, + .bypass = 0, + .hpf_enabled = false, + .af_enabled = true, + .nlp_enabled = false, + .clip_enabled = false, .stsupp_enabled = false, - .ns_enabled = false, - .cng_enabled = false, - .blocks = 6, - .delay = 0, - .min_ovrd = 2, - .target_supp = -40, - .noise_supp = -15, - .cng_type = 1, - .cng_level = -60, + .ns_enabled = false, + .cng_enabled = false, + .blocks = 6, + .delay = 0, + .min_ovrd = 2, + .target_supp = -40, + .noise_supp = -15, + .cng_type = 1, + .cng_level = -60, .clip_threshold = -20.f, - .banks = 32, + .banks = 32, }; #endif @@ -115,297 +116,281 @@ static AI_CP_CACHE_ATTR AI_AEC_struct ai_aec_struct; #define IGNORE_ECHO_VOL 60 CP_TEXT_SRAM_LOC -void app_ai_aec_process(uint8_t *buf, uint32_t length) -{ - uint16_t i = 0; - short *tmp_in = (short *)buf; - float echo_vol=0; +void app_ai_aec_process(uint8_t *buf, uint32_t length) { + uint16_t i = 0; + short *tmp_in = (short *)buf; + float echo_vol = 0; - for (i = 0; i < FRAME_LEN; i++) - { - data_mic1[i] = tmp_in[i*CAPTURE_AUDIO_CHANNEL_NUM]; - echo_ref1[i] = tmp_in[i*CAPTURE_AUDIO_CHANNEL_NUM+2]; - echo_ref2[i] = tmp_in[i*CAPTURE_AUDIO_CHANNEL_NUM+3]; - echo_vol += AI_ABS((float)echo_ref1[i])/FRAME_LEN; - } + for (i = 0; i < FRAME_LEN; i++) { + data_mic1[i] = tmp_in[i * CAPTURE_AUDIO_CHANNEL_NUM]; + echo_ref1[i] = tmp_in[i * CAPTURE_AUDIO_CHANNEL_NUM + 2]; + echo_ref2[i] = tmp_in[i * CAPTURE_AUDIO_CHANNEL_NUM + 3]; + echo_vol += AI_ABS((float)echo_ref1[i]) / FRAME_LEN; + } - //TRACE(3, "%s len %d echo_vol %d", __func__, length, (uint16_t)echo_vol); + // TRACE(3, "%s len %d echo_vol %d", __func__, length, (uint16_t)echo_vol); - if (echo_vol < IGNORE_ECHO_VOL) - { - //TRACE(1, "%s echo_vol is too small", __func__); - return; - } + if (echo_vol < IGNORE_ECHO_VOL) { + // TRACE(1, "%s echo_vol is too small", __func__); + return; + } - ec2float_stereo(speech_aec2float_st1, data_mic1, echo_ref1, echo_ref2,FRAME_LEN, aec2_out_buf1); - for (i = 0; i < FRAME_LEN; i++) - { - tmp_in[i*CAPTURE_AUDIO_CHANNEL_NUM] = aec2_out_buf1[i]; - } + ec2float_stereo(speech_aec2float_st1, data_mic1, echo_ref1, echo_ref2, + FRAME_LEN, aec2_out_buf1); + for (i = 0; i < FRAME_LEN; i++) { + tmp_in[i * CAPTURE_AUDIO_CHANNEL_NUM] = aec2_out_buf1[i]; + } #if AI_CAPTURE_CHANNEL_NUM == 2 - for (i = 0; i < FRAME_LEN; i++) - { - data_mic2[i] = tmp_in[i*CAPTURE_AUDIO_CHANNEL_NUM+1]; - echo_ref1[i] = tmp_in[i+FRAME_LEN*2]; - echo_ref2[i] = tmp_in[i+FRAME_LEN*3]; - } - ec2float_stereo(speech_aec2float_st2, data_mic2, echo_ref1, echo_ref2,FRAME_LEN, aec2_out_buf2); + for (i = 0; i < FRAME_LEN; i++) { + data_mic2[i] = tmp_in[i * CAPTURE_AUDIO_CHANNEL_NUM + 1]; + echo_ref1[i] = tmp_in[i + FRAME_LEN * 2]; + echo_ref2[i] = tmp_in[i + FRAME_LEN * 3]; + } + ec2float_stereo(speech_aec2float_st2, data_mic2, echo_ref1, echo_ref2, + FRAME_LEN, aec2_out_buf2); - for (i = 0; i < FRAME_LEN; i++) - { - tmp_in[i*CAPTURE_AUDIO_CHANNEL_NUM+1] = aec2_out_buf2[i]; - } + for (i = 0; i < FRAME_LEN; i++) { + tmp_in[i * CAPTURE_AUDIO_CHANNEL_NUM + 1] = aec2_out_buf2[i]; + } #endif #if defined(AUDIO_DEBUG) - audio_dump_clear_up(); - audio_dump_add_channel_data(0, data_mic1, FRAME_LEN); - audio_dump_add_channel_data(1, aec2_out_buf1, FRAME_LEN); + audio_dump_clear_up(); + audio_dump_add_channel_data(0, data_mic1, FRAME_LEN); + audio_dump_add_channel_data(1, aec2_out_buf1, FRAME_LEN); #if AI_CAPTURE_CHANNEL_NUM == 2 - audio_dump_add_channel_data(2, data_mic2, FRAME_LEN); - audio_dump_add_channel_data(3, aec2_out_buf2, FRAME_LEN); + audio_dump_add_channel_data(2, data_mic2, FRAME_LEN); + audio_dump_add_channel_data(3, aec2_out_buf2, FRAME_LEN); #endif - audio_dump_run(); + audio_dump_run(); #endif } -bool app_ai_aec_get_data_from_cache(uint8_t *buf, uint32_t length) -{ - bool ret = false; - uint8_t out_cache_num = ai_aec_struct.cp_data_out_cache_num; - uint8_t *out_data_cache = ai_aec_struct.cp_data_cache[out_cache_num]; - AI_AEC_CACHE_STATE_E out_cache_state = ai_aec_struct.cache_state[out_cache_num]; +bool app_ai_aec_get_data_from_cache(uint8_t *buf, uint32_t length) { + bool ret = false; + uint8_t out_cache_num = ai_aec_struct.cp_data_out_cache_num; + uint8_t *out_data_cache = ai_aec_struct.cp_data_cache[out_cache_num]; + AI_AEC_CACHE_STATE_E out_cache_state = + ai_aec_struct.cache_state[out_cache_num]; #ifdef AI_AEC_CP_ACCEL - //TRACE(2, "%s cache_num %d state %d", __func__, ai_aec_struct.cp_data_out_cache_num, out_cache_state); + // TRACE(2, "%s cache_num %d state %d", __func__, + // ai_aec_struct.cp_data_out_cache_num, out_cache_state); - if (AI_AEC_CACHE_PROCESSED == out_cache_state) - { - memcpy(buf, out_data_cache, length); - ai_aec_struct.cache_state[out_cache_num] = AI_AEC_CACHE_IDLE; - if (++ai_aec_struct.cp_data_out_cache_num >= AI_AEC_CACHE_NUM) - { - ai_aec_struct.cp_data_out_cache_num = 0; - } - ai_aec_struct.cp_data_use_cache_num--; - ret = true; + if (AI_AEC_CACHE_PROCESSED == out_cache_state) { + memcpy(buf, out_data_cache, length); + ai_aec_struct.cache_state[out_cache_num] = AI_AEC_CACHE_IDLE; + if (++ai_aec_struct.cp_data_out_cache_num >= AI_AEC_CACHE_NUM) { + ai_aec_struct.cp_data_out_cache_num = 0; } - else - { - ret = false; - } -#else + ai_aec_struct.cp_data_use_cache_num--; ret = true; + } else { + ret = false; + } +#else + ret = true; #endif - return ret; + return ret; } -void app_ai_aec_mic_data_handle(uint8_t *buf, uint32_t length) -{ - uint8_t in_cache_num = ai_aec_struct.cp_data_in_cache_num; - uint8_t *in_data_cache = ai_aec_struct.cp_data_cache[in_cache_num]; - AI_AEC_CACHE_STATE_E in_cache_state = ai_aec_struct.cache_state[in_cache_num]; +void app_ai_aec_mic_data_handle(uint8_t *buf, uint32_t length) { + uint8_t in_cache_num = ai_aec_struct.cp_data_in_cache_num; + uint8_t *in_data_cache = ai_aec_struct.cp_data_cache[in_cache_num]; + AI_AEC_CACHE_STATE_E in_cache_state = ai_aec_struct.cache_state[in_cache_num]; #ifdef AI_AEC_CP_ACCEL - //TRACE(2, "%s cache_num %d state %d max_num %d", __func__, ai_aec_struct.cp_data_in_cache_num, in_cache_state, ai_aec_struct.cp_data_use_max_cache_num); - if (AI_AEC_CACHE_IDLE == in_cache_state) - { - memcpy(in_data_cache, buf, length); - ai_aec_struct.cache_state[in_cache_num] = AI_AEC_CACHE_CACHED; - if (++ai_aec_struct.cp_data_in_cache_num >= AI_AEC_CACHE_NUM) - { - ai_aec_struct.cp_data_in_cache_num = 0; - } - ai_aec_struct.cp_data_use_cache_num++; - if (ai_aec_struct.cp_data_use_cache_num > ai_aec_struct.cp_data_use_max_cache_num) - { - ai_aec_struct.cp_data_use_max_cache_num = ai_aec_struct.cp_data_use_cache_num; - } - cp_accel_send_event_mcu2cp(CP_BUILD_ID(CP_TASK_AEC, CP_EVENT_AEC_PROCESSING)); + // TRACE(2, "%s cache_num %d state %d max_num %d", __func__, + // ai_aec_struct.cp_data_in_cache_num, in_cache_state, + // ai_aec_struct.cp_data_use_max_cache_num); + if (AI_AEC_CACHE_IDLE == in_cache_state) { + memcpy(in_data_cache, buf, length); + ai_aec_struct.cache_state[in_cache_num] = AI_AEC_CACHE_CACHED; + if (++ai_aec_struct.cp_data_in_cache_num >= AI_AEC_CACHE_NUM) { + ai_aec_struct.cp_data_in_cache_num = 0; } - else - { - TRACE(3, "%s cache %d state error %d", __func__, in_cache_num, in_cache_state); + ai_aec_struct.cp_data_use_cache_num++; + if (ai_aec_struct.cp_data_use_cache_num > + ai_aec_struct.cp_data_use_max_cache_num) { + ai_aec_struct.cp_data_use_max_cache_num = + ai_aec_struct.cp_data_use_cache_num; } + cp_accel_send_event_mcu2cp( + CP_BUILD_ID(CP_TASK_AEC, CP_EVENT_AEC_PROCESSING)); + } else { + TRACE(3, "%s cache %d state error %d", __func__, in_cache_num, + in_cache_state); + } #else - app_ai_aec_process(buf, length); + app_ai_aec_process(buf, length); #endif - return; + return; } -void app_ai_algorithm_mic_data_handle(uint8_t *buf, uint32_t length) -{ - bool ret = false; - uint16_t i = 0; - uint32_t queue_len = 0; - short *tmp_out = (short *)mic_data_handle_temp_buff; +void app_ai_algorithm_mic_data_handle(uint8_t *buf, uint32_t length) { + bool ret = false; + uint16_t i = 0; + uint32_t queue_len = 0; + short *tmp_out = (short *)mic_data_handle_temp_buff; - //TRACE(2, "%s len %d", __func__, length); + // TRACE(2, "%s len %d", __func__, length); + LOCK_MIC_DATA_HANDLE_QUEUE(); + if (EnCQueue(&mic_data_handle_queue, (CQItemType *)buf, length) == CQ_ERR) { + TRACE(2, "###far_field_queue overflow, want %d bytes, has %d bytes\n", + length, AvailableOfCQueue(&mic_data_handle_queue)); + } + queue_len = LengthOfCQueue(&mic_data_handle_queue); + UNLOCK_MIC_DATA_HANDLE_QUEUE(); + + while (queue_len >= MIC_DATA_PROCESS_SIZE) { LOCK_MIC_DATA_HANDLE_QUEUE(); - if (EnCQueue(&mic_data_handle_queue,(CQItemType *) buf, length) == CQ_ERR) - { - TRACE(2, "###far_field_queue overflow, want %d bytes, has %d bytes\n", - length, AvailableOfCQueue(&mic_data_handle_queue)); - } + ret = (DeCQueue(&mic_data_handle_queue, mic_data_handle_temp_buff, + MIC_DATA_PROCESS_SIZE) == CQ_OK) + ? true + : false; queue_len = LengthOfCQueue(&mic_data_handle_queue); UNLOCK_MIC_DATA_HANDLE_QUEUE(); - while (queue_len >= MIC_DATA_PROCESS_SIZE) - { - LOCK_MIC_DATA_HANDLE_QUEUE(); - ret = (DeCQueue(&mic_data_handle_queue, mic_data_handle_temp_buff, MIC_DATA_PROCESS_SIZE)==CQ_OK)?true:false; - queue_len = LengthOfCQueue(&mic_data_handle_queue); - UNLOCK_MIC_DATA_HANDLE_QUEUE(); - #ifdef AI_CAPTURE_DATA_AEC - if (ai_aec_inited && ret) - { - app_ai_aec_mic_data_handle(mic_data_handle_temp_buff, MIC_DATA_PROCESS_SIZE); - ret = app_ai_aec_get_data_from_cache(mic_data_handle_temp_buff, MIC_DATA_PROCESS_SIZE); - } + if (ai_aec_inited && ret) { + app_ai_aec_mic_data_handle(mic_data_handle_temp_buff, + MIC_DATA_PROCESS_SIZE); + ret = app_ai_aec_get_data_from_cache(mic_data_handle_temp_buff, + MIC_DATA_PROCESS_SIZE); + } #endif - while (ret) - { - //ret = other algorithm handle result + while (ret) { + // ret = other algorithm handle result - if (ret) - { - for (i = 0; i < FRAME_LEN; i++) - { - tmp_out[i] = tmp_out[i*CAPTURE_AUDIO_CHANNEL_NUM]; - } - app_voicepath_enqueue_pcm_data(mic_data_handle_temp_buff, FRAME_LEN*2); - } - - if (ai_aec_inited) - { - ret = app_ai_aec_get_data_from_cache(mic_data_handle_temp_buff, MIC_DATA_PROCESS_SIZE); - } - else - { - ret = false; - } + if (ret) { + for (i = 0; i < FRAME_LEN; i++) { + tmp_out[i] = tmp_out[i * CAPTURE_AUDIO_CHANNEL_NUM]; } + app_voicepath_enqueue_pcm_data(mic_data_handle_temp_buff, + FRAME_LEN * 2); + } + + if (ai_aec_inited) { + ret = app_ai_aec_get_data_from_cache(mic_data_handle_temp_buff, + MIC_DATA_PROCESS_SIZE); + } else { + ret = false; + } } + } } #ifdef AI_AEC_CP_ACCEL AI_TEXT_SRAM_LOC -void cp_aec_data_process(void) -{ - uint8_t process_cache_num = ai_aec_struct.cp_data_process_cache_num; - uint8_t *data_cache = ai_aec_struct.cp_data_cache[process_cache_num]; - AI_AEC_CACHE_STATE_E process_cache_state = ai_aec_struct.cache_state[process_cache_num]; +void cp_aec_data_process(void) { + uint8_t process_cache_num = ai_aec_struct.cp_data_process_cache_num; + uint8_t *data_cache = ai_aec_struct.cp_data_cache[process_cache_num]; + AI_AEC_CACHE_STATE_E process_cache_state = + ai_aec_struct.cache_state[process_cache_num]; - while (AI_AEC_CACHE_CACHED == process_cache_state) - { - app_ai_aec_process(data_cache, MIC_DATA_PROCESS_SIZE); - ai_aec_struct.cache_state[process_cache_num] = AI_AEC_CACHE_PROCESSED; - if (++ai_aec_struct.cp_data_process_cache_num >= AI_AEC_CACHE_NUM) - { - ai_aec_struct.cp_data_process_cache_num = 0; - } - process_cache_num = ai_aec_struct.cp_data_process_cache_num; - data_cache = ai_aec_struct.cp_data_cache[process_cache_num]; - process_cache_state = ai_aec_struct.cache_state[process_cache_num]; + while (AI_AEC_CACHE_CACHED == process_cache_state) { + app_ai_aec_process(data_cache, MIC_DATA_PROCESS_SIZE); + ai_aec_struct.cache_state[process_cache_num] = AI_AEC_CACHE_PROCESSED; + if (++ai_aec_struct.cp_data_process_cache_num >= AI_AEC_CACHE_NUM) { + ai_aec_struct.cp_data_process_cache_num = 0; } - //else - //{ - //TRACE(3, "%s cache state %d error %d", __func__, process_cache_num, process_cache_state); - //} + process_cache_num = ai_aec_struct.cp_data_process_cache_num; + data_cache = ai_aec_struct.cp_data_cache[process_cache_num]; + process_cache_state = ai_aec_struct.cache_state[process_cache_num]; + } + // else + //{ + // TRACE(3, "%s cache state %d error %d", __func__, process_cache_num, + // process_cache_state); + //} } AI_TEXT_SRAM_LOC -unsigned int cp_aec_main(uint8_t event) -{ - switch (event) - { - case CP_EVENT_AEC_PROCESSING: - cp_aec_data_process(); - break; - default: - break; - } - return 0; +unsigned int cp_aec_main(uint8_t event) { + switch (event) { + case CP_EVENT_AEC_PROCESSING: + cp_aec_data_process(); + break; + default: + break; + } + return 0; } -static struct cp_task_desc TASK_DESC_AEC = {CP_ACCEL_STATE_CLOSED, cp_aec_main, NULL, NULL, NULL}; -void cp_aec_init(void) -{ - uint8_t i = 0; - TRACE(2, "%s ai_aec_inited %d", __func__, ai_aec_inited); +static struct cp_task_desc TASK_DESC_AEC = {CP_ACCEL_STATE_CLOSED, cp_aec_main, + NULL, NULL, NULL}; +void cp_aec_init(void) { + uint8_t i = 0; + TRACE(2, "%s ai_aec_inited %d", __func__, ai_aec_inited); - if (!ai_aec_inited) - { - memset(&ai_aec_struct, 0, sizeof(ai_aec_struct)); - ai_aec_struct.cp_data_in_cache_num = 0; - ai_aec_struct.cp_data_process_cache_num = 0; - ai_aec_struct.cp_data_out_cache_num = 0; - for (i=0; i free size = %d", __func__, size, buff_size_free); + ASSERT(size <= buff_size_free, "[%s] size = %d > free size = %d", __func__, + size, buff_size_free); - *buff = app_ai_if_capture_buf.buff + app_ai_if_capture_buf.buff_size_used; + *buff = app_ai_if_capture_buf.buff + app_ai_if_capture_buf.buff_size_used; - app_ai_if_capture_buf.buff_size_used += size; - app_ai_if_capture_buf.buff_size_free -= size; + app_ai_if_capture_buf.buff_size_used += size; + app_ai_if_capture_buf.buff_size_free -= size; - TRACE(3,"AI allocate %d, now used %d left %d", size, - app_ai_if_capture_buf.buff_size_used, - app_ai_if_capture_buf.buff_size_free); + TRACE(3, "AI allocate %d, now used %d left %d", size, + app_ai_if_capture_buf.buff_size_used, + app_ai_if_capture_buf.buff_size_free); } -void app_ai_if_mobile_connect_handle(bt_bdaddr_t *_addr) -{ - MOBILE_CONN_TYPE_E type = MOBILE_CONNECT_IDLE; - uint16_t vend_id = 0; - uint16_t vend_id_source = 0; +void app_ai_if_mobile_connect_handle(bt_bdaddr_t *_addr) { + MOBILE_CONN_TYPE_E type = MOBILE_CONNECT_IDLE; + uint16_t vend_id = 0; + uint16_t vend_id_source = 0; - btif_dip_get_record_vend_id_and_source(_addr, &vend_id, &vend_id_source); - TRACE(3, "%s vend_id 0x%x vend_id_source 0x%x", __func__, vend_id, vend_id_source); - if (vend_id) - { - type = btif_dip_check_is_ios_by_vend_id(vend_id, vend_id_source)?MOBILE_CONNECT_IOS:MOBILE_CONNECT_ANDROID; + btif_dip_get_record_vend_id_and_source(_addr, &vend_id, &vend_id_source); + TRACE(3, "%s vend_id 0x%x vend_id_source 0x%x", __func__, vend_id, + vend_id_source); + if (vend_id) { + type = btif_dip_check_is_ios_by_vend_id(vend_id, vend_id_source) + ? MOBILE_CONNECT_IOS + : MOBILE_CONNECT_ANDROID; #ifdef __AI_VOICE__ - app_ai_mobile_connect_handle(type, _addr); + app_ai_mobile_connect_handle(type, _addr); #endif #ifdef BISTO_ENABLED - gsound_custom_bt_link_connected_handler(_addr->address); - gsound_mobile_type_get_callback(type); + gsound_custom_bt_link_connected_handler(_addr->address); + gsound_mobile_type_get_callback(type); #endif - } + } #ifdef BLE_ENABLE - app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); + app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); #endif } -void app_ai_voice_init(void) -{ +void app_ai_voice_init(void) { #ifdef __AI_VOICE__ - uint32_t ai_spec = app_ai_if_get_ai_spec(); + uint32_t ai_spec = app_ai_if_get_ai_spec(); - app_ai_manager_init(); - if (ai_spec != AI_SPEC_INIT) - { - ai_open(ai_spec); - app_ai_tws_init(); + app_ai_manager_init(); + if (ai_spec != AI_SPEC_INIT) { + ai_open(ai_spec); + app_ai_tws_init(); #ifdef OPUS_IN_OVERLAY - app_ai_set_opus_in_overlay(true); + app_ai_set_opus_in_overlay(true); #endif -#if VOB_ENCODING_ALGORITHM==ENCODING_ALGORITHM_OPUS - app_ai_set_encode_type(ENCODING_ALGORITHM_OPUS); -#elif VOB_ENCODING_ALGORITHM==ENCODING_ALGORITHM_SBC - app_ai_set_encode_type(ENCODING_ALGORITHM_SBC); +#if VOB_ENCODING_ALGORITHM == ENCODING_ALGORITHM_OPUS + app_ai_set_encode_type(ENCODING_ALGORITHM_OPUS); +#elif VOB_ENCODING_ALGORITHM == ENCODING_ALGORITHM_SBC + app_ai_set_encode_type(ENCODING_ALGORITHM_SBC); #else - app_ai_set_encode_type(NO_ENCODING); + app_ai_set_encode_type(NO_ENCODING); #endif #ifdef AI_32KBPS_VOICE - app_ai_set_use_ai_32kbps_voice(true); + app_ai_set_use_ai_32kbps_voice(true); #endif #ifdef NO_LOCAL_START_TONE - app_ai_set_local_start_tone(false); + app_ai_set_local_start_tone(false); #endif - app_ai_if_custom_init(); + app_ai_if_custom_init(); #ifdef __THROUGH_PUT__ - app_throughput_test_init(); + app_throughput_test_init(); #endif - } + } - app_capture_audio_mempool_init(); + app_capture_audio_mempool_init(); #ifdef __THIRDPARTY - app_ai_if_thirdparty_init(); + app_ai_if_thirdparty_init(); #endif - app_ai_if_mempool_init(); + app_ai_if_mempool_init(); #endif } static bool isMusicOrPromptOnGoing = false; static uint32_t musicOrPromptSampleRate; -void app_ai_if_inform_music_or_prompt_status(bool isOn, uint32_t sampleRate) -{ - isMusicOrPromptOnGoing = isOn; - musicOrPromptSampleRate = sampleRate; +void app_ai_if_inform_music_or_prompt_status(bool isOn, uint32_t sampleRate) { + isMusicOrPromptOnGoing = isOn; + musicOrPromptSampleRate = sampleRate; } -bool app_ai_if_is_music_or_prompt_ongoing(void) -{ +bool app_ai_if_is_music_or_prompt_ongoing(void) { #ifdef ANC_APP - return isMusicOrPromptOnGoing||app_anc_is_on(); + return isMusicOrPromptOnGoing || app_anc_is_on(); #else - return isMusicOrPromptOnGoing; + return isMusicOrPromptOnGoing; #endif } -uint32_t app_ai_if_get_music_or_prompt_sample_rate(void) -{ +uint32_t app_ai_if_get_music_or_prompt_sample_rate(void) { #ifdef ANC_APP - if (isMusicOrPromptOnGoing) - { - return musicOrPromptSampleRate; - } - else if (app_anc_is_on()) - { - return app_anc_get_sample_rate(); - } - else - { - return 0; - } -#else + if (isMusicOrPromptOnGoing) { return musicOrPromptSampleRate; + } else if (app_anc_is_on()) { + return app_anc_get_sample_rate(); + } else { + return 0; + } +#else + return musicOrPromptSampleRate; #endif } extern void alexa_wwe_pre_music_or_prompt_check(void); extern "C" void app_voicepath_pre_music_or_prompt_check(void); -void app_ai_if_pre_music_or_prompt_check(void) -{ +void app_ai_if_pre_music_or_prompt_check(void) { #ifdef __ALEXA_WWE_LITE - alexa_wwe_pre_music_or_prompt_check(); + alexa_wwe_pre_music_or_prompt_check(); #endif #ifdef BISTO_ENABLED - app_voicepath_pre_music_or_prompt_check(); + app_voicepath_pre_music_or_prompt_check(); #endif } - diff --git a/services/app_ai/src/app_ai_if_custom_ui.cpp b/services/app_ai/src/app_ai_if_custom_ui.cpp index 3af7449..b49581c 100644 --- a/services/app_ai/src/app_ai_if_custom_ui.cpp +++ b/services/app_ai/src/app_ai_if_custom_ui.cpp @@ -1,12 +1,12 @@ -#include "cmsis_os.h" -#include "hal_trace.h" +#include "app_ai_if_custom_ui.h" +#include "app_ai_if.h" +#include "app_ai_if_config.h" +#include "app_ai_tws.h" +#include "app_ble_mode_switch.h" #include "app_spp.h" #include "app_through_put.h" -#include "app_ai_if.h" -#include "app_ai_tws.h" -#include "app_ai_if_config.h" -#include "app_ble_mode_switch.h" -#include "app_ai_if_custom_ui.h" +#include "cmsis_os.h" +#include "hal_trace.h" #ifdef RTOS #include "cmsis_os.h" #endif @@ -19,100 +19,95 @@ #endif #ifdef __AI_VOICE__ -static void app_ai_if_custom_ui_global_handler_ind(uint32_t cmd, void *param1, uint32_t param2) -{ - switch (cmd) - { - case AI_CUSTOM_CODE_AI_ROLE_SWITCH: - break; +static void app_ai_if_custom_ui_global_handler_ind(uint32_t cmd, void *param1, + uint32_t param2) { + switch (cmd) { + case AI_CUSTOM_CODE_AI_ROLE_SWITCH: + break; - case AI_CUSTOM_CODE_CMD_RECEIVE: + case AI_CUSTOM_CODE_CMD_RECEIVE: #ifdef __THROUGH_PUT__ - app_throughput_receive_cmd(param1, param2); + app_throughput_receive_cmd(param1, param2); #endif - break; + break; - case AI_CUSTOM_CODE_DATA_RECEIVE: - break; + case AI_CUSTOM_CODE_DATA_RECEIVE: + break; - case AI_CUSTOM_CODE_AI_CONNECT: - break; + case AI_CUSTOM_CODE_AI_CONNECT: + break; - case AI_CUSTOM_CODE_AI_DISCONNECT: + case AI_CUSTOM_CODE_AI_DISCONNECT: #ifdef __THROUGH_PUT__ - app_stop_throughput_test(); + app_stop_throughput_test(); #endif - break; + break; - case AI_CUSTOM_CODE_UPDATE_MTU: - break; + case AI_CUSTOM_CODE_UPDATE_MTU: + break; - case AI_CUSTOM_CODE_WAKE_UP: - break; + case AI_CUSTOM_CODE_WAKE_UP: + break; - case AI_CUSTOM_CODE_START_SPEECH: - break; + case AI_CUSTOM_CODE_START_SPEECH: + break; - case AI_CUSTOM_CODE_ENDPOINT_SPEECH: - break; + case AI_CUSTOM_CODE_ENDPOINT_SPEECH: + break; - case AI_CUSTOM_CODE_STOP_SPEECH: - break; - case AI_CUSTOM_CODE_DATA_SEND_DONE: + case AI_CUSTOM_CODE_STOP_SPEECH: + break; + case AI_CUSTOM_CODE_DATA_SEND_DONE: #ifdef __THROUGH_PUT__ - app_throughput_cmd_send_done(param1, param2); + app_throughput_cmd_send_done(param1, param2); #endif - break; + break; - case AI_CUSTOM_CODE_KEY_EVENT_HANDLE: - break; + case AI_CUSTOM_CODE_KEY_EVENT_HANDLE: + break; - case AI_CUSTOM_CODE_AI_ROLE_SWITCH_COMPLETE: - break; + case AI_CUSTOM_CODE_AI_ROLE_SWITCH_COMPLETE: + break; - case AI_CUSTOM_CODE_MOBILE_CONNECT: - break; + case AI_CUSTOM_CODE_MOBILE_CONNECT: + break; - case AI_CUSTOM_CODE_MOBILE_DISCONNECT: - break; + case AI_CUSTOM_CODE_MOBILE_DISCONNECT: + break; - case AI_CUSTOM_CODE_SETUP_COMPLETE: - break; + case AI_CUSTOM_CODE_SETUP_COMPLETE: + break; - default: - break; - } + default: + break; + } } #endif -bool app_ai_if_custom_ui_send_cmd(uint8_t *cmd_buf,uint16_t cmd_len) -{ - osStatus status = (osStatus)osErrorValue; +bool app_ai_if_custom_ui_send_cmd(uint8_t *cmd_buf, uint16_t cmd_len) { + osStatus status = (osStatus)osErrorValue; #ifdef __AI_VOICE__ - TRACE(1, "%s", __func__); + TRACE(1, "%s", __func__); - uint8_t send_buf[L2CAP_MTU] = {0}; - uint16_t *output_size_p = NULL; - uint8_t *output_buf_p = NULL; + uint8_t send_buf[L2CAP_MTU] = {0}; + uint16_t *output_size_p = NULL; + uint8_t *output_buf_p = NULL; - output_size_p = (uint16_t *)send_buf; - output_buf_p = &send_buf[AI_CMD_CODE_SIZE]; + output_size_p = (uint16_t *)send_buf; + output_buf_p = &send_buf[AI_CMD_CODE_SIZE]; - memcpy(output_buf_p, cmd_buf, cmd_len); - *output_size_p = cmd_len; + memcpy(output_buf_p, cmd_buf, cmd_len); + *output_size_p = cmd_len; - if (ai_transport_cmd_put(send_buf, (cmd_len+AI_CMD_CODE_SIZE))) - { - status = ai_mailbox_put(SIGN_AI_TRANSPORT, cmd_len); - } + if (ai_transport_cmd_put(send_buf, (cmd_len + AI_CMD_CODE_SIZE))) { + status = ai_mailbox_put(SIGN_AI_TRANSPORT, cmd_len); + } #endif - return (osOK == status); + return (osOK == status); } -void app_ai_if_custom_init(void) -{ +void app_ai_if_custom_init(void) { #ifdef __AI_VOICE__ - app_ai_register_ui_global_handler_ind(app_ai_if_custom_ui_global_handler_ind); + app_ai_register_ui_global_handler_ind(app_ai_if_custom_ui_global_handler_ind); #endif } - diff --git a/services/app_ai/src/app_ai_if_gsound.cpp b/services/app_ai/src/app_ai_if_gsound.cpp index 0bf2d8c..2cf0aae 100644 --- a/services/app_ai/src/app_ai_if_gsound.cpp +++ b/services/app_ai/src/app_ai_if_gsound.cpp @@ -1,16 +1,13 @@ +#include "app_ai_if_gsound.h" #include "cmsis_os.h" #include "hal_trace.h" -#include "app_ai_if_gsound.h" - #ifdef BISTO_ENABLED #include "gsound_custom_service.h" #endif -void app_ai_if_gsound_service_enable_switch(bool onOff) -{ +void app_ai_if_gsound_service_enable_switch(bool onOff) { #ifdef BISTO_ENABLED - gsound_service_enable_switch(onOff); + gsound_service_enable_switch(onOff); #endif } - diff --git a/services/app_ai/src/app_ai_if_thirdparty.cpp b/services/app_ai/src/app_ai_if_thirdparty.cpp index 2f75fb0..e8bd62f 100644 --- a/services/app_ai/src/app_ai_if_thirdparty.cpp +++ b/services/app_ai/src/app_ai_if_thirdparty.cpp @@ -1,108 +1,111 @@ -#include "cmsis_os.h" -#include "spp_api.h" -#include "hal_trace.h" -#include "app_ai_if.h" -#include "app_ai_tws.h" -#include "app_ai_manager_api.h" #include "app_ai_if_thirdparty.h" -#include "app_thirdparty.h" +#include "app_ai_if.h" +#include "app_ai_manager_api.h" +#include "app_ai_tws.h" #include "app_bt_media_manager.h" +#include "app_thirdparty.h" +#include "cmsis_os.h" +#include "hal_trace.h" +#include "spp_api.h" #ifdef __AI_VOICE__ -#include "ai_manager.h" #include "ai_control.h" +#include "ai_manager.h" #include "ai_thread.h" #include "app_ai_voice.h" #endif -uint8_t app_ai_if_thirdparty_mempool_buf[APP_AI_IF_THIRDPARTY_MEMPOOL_BUFFER_SIZE]; +uint8_t + app_ai_if_thirdparty_mempool_buf[APP_AI_IF_THIRDPARTY_MEMPOOL_BUFFER_SIZE]; THIRDPARTY_AI_MEMPOOL_BUFFER_T app_ai_if_thirdparty_mempool_buf_t; -POSSIBLY_UNUSED void app_ai_if_thirdparty_mempool_init(void) -{ - memset((uint8_t *)app_ai_if_thirdparty_mempool_buf, 0, APP_AI_IF_THIRDPARTY_MEMPOOL_BUFFER_SIZE); +POSSIBLY_UNUSED void app_ai_if_thirdparty_mempool_init(void) { + memset((uint8_t *)app_ai_if_thirdparty_mempool_buf, 0, + APP_AI_IF_THIRDPARTY_MEMPOOL_BUFFER_SIZE); - app_ai_if_thirdparty_mempool_buf_t.buff = app_ai_if_thirdparty_mempool_buf; - app_ai_if_thirdparty_mempool_buf_t.buff_size_total = APP_AI_IF_THIRDPARTY_MEMPOOL_BUFFER_SIZE; - app_ai_if_thirdparty_mempool_buf_t.buff_size_used = 0; - app_ai_if_thirdparty_mempool_buf_t.buff_size_free = APP_AI_IF_THIRDPARTY_MEMPOOL_BUFFER_SIZE; + app_ai_if_thirdparty_mempool_buf_t.buff = app_ai_if_thirdparty_mempool_buf; + app_ai_if_thirdparty_mempool_buf_t.buff_size_total = + APP_AI_IF_THIRDPARTY_MEMPOOL_BUFFER_SIZE; + app_ai_if_thirdparty_mempool_buf_t.buff_size_used = 0; + app_ai_if_thirdparty_mempool_buf_t.buff_size_free = + APP_AI_IF_THIRDPARTY_MEMPOOL_BUFFER_SIZE; - TRACE(3, "%s buf %p size %d", __func__, app_ai_if_thirdparty_mempool_buf, APP_AI_IF_THIRDPARTY_MEMPOOL_BUFFER_SIZE); + TRACE(3, "%s buf %p size %d", __func__, app_ai_if_thirdparty_mempool_buf, + APP_AI_IF_THIRDPARTY_MEMPOOL_BUFFER_SIZE); } -void app_ai_if_thirdparty_mempool_deinit(void) -{ - TRACE(2, "%s size %d", __func__, app_ai_if_thirdparty_mempool_buf_t.buff_size_total); +void app_ai_if_thirdparty_mempool_deinit(void) { + TRACE(2, "%s size %d", __func__, + app_ai_if_thirdparty_mempool_buf_t.buff_size_total); - memset((uint8_t *)app_ai_if_thirdparty_mempool_buf_t.buff, 0, app_ai_if_thirdparty_mempool_buf_t.buff_size_total); + memset((uint8_t *)app_ai_if_thirdparty_mempool_buf_t.buff, 0, + app_ai_if_thirdparty_mempool_buf_t.buff_size_total); - app_ai_if_thirdparty_mempool_buf_t.buff_size_used = 0; - app_ai_if_thirdparty_mempool_buf_t.buff_size_free = app_ai_if_thirdparty_mempool_buf_t.buff_size_total; + app_ai_if_thirdparty_mempool_buf_t.buff_size_used = 0; + app_ai_if_thirdparty_mempool_buf_t.buff_size_free = + app_ai_if_thirdparty_mempool_buf_t.buff_size_total; } -void app_ai_if_thirdparty_mempool_get_buff(uint8_t **buff, uint32_t size) -{ - uint32_t buff_size_free; +void app_ai_if_thirdparty_mempool_get_buff(uint8_t **buff, uint32_t size) { + uint32_t buff_size_free; - buff_size_free = app_ai_if_thirdparty_mempool_buf_t.buff_size_free; + buff_size_free = app_ai_if_thirdparty_mempool_buf_t.buff_size_free; - if (size % 4){ - size = size + (4 - size % 4); - } + if (size % 4) { + size = size + (4 - size % 4); + } - TRACE(3,"%s free %d to allocate %d", __func__, buff_size_free, size); + TRACE(3, "%s free %d to allocate %d", __func__, buff_size_free, size); - ASSERT(size <= buff_size_free, "[%s] size = %d > free size = %d", __func__, size, buff_size_free); + ASSERT(size <= buff_size_free, "[%s] size = %d > free size = %d", __func__, + size, buff_size_free); - *buff = app_ai_if_thirdparty_mempool_buf_t.buff + app_ai_if_thirdparty_mempool_buf_t.buff_size_used; + *buff = app_ai_if_thirdparty_mempool_buf_t.buff + + app_ai_if_thirdparty_mempool_buf_t.buff_size_used; - app_ai_if_thirdparty_mempool_buf_t.buff_size_used += size; - app_ai_if_thirdparty_mempool_buf_t.buff_size_free -= size; + app_ai_if_thirdparty_mempool_buf_t.buff_size_used += size; + app_ai_if_thirdparty_mempool_buf_t.buff_size_free -= size; - TRACE(3,"thirdparty allocate %d, now used %d left %d", size, - app_ai_if_thirdparty_mempool_buf_t.buff_size_used, - app_ai_if_thirdparty_mempool_buf_t.buff_size_free); + TRACE(3, "thirdparty allocate %d, now used %d left %d", size, + app_ai_if_thirdparty_mempool_buf_t.buff_size_used, + app_ai_if_thirdparty_mempool_buf_t.buff_size_free); } -void app_ai_if_thirdparty_start_stream_by_app_audio_manager(void) -{ +void app_ai_if_thirdparty_start_stream_by_app_audio_manager(void) { #ifdef __THIRDPARTY - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, - BT_STREAM_THIRDPARTY_VOICE, - 0, - 0); + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, + BT_STREAM_THIRDPARTY_VOICE, 0, 0); #endif } -void app_ai_if_thirdparty_stop_stream_by_app_audio_manager(void) -{ +void app_ai_if_thirdparty_stop_stream_by_app_audio_manager(void) { #ifdef __THIRDPARTY - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, - BT_STREAM_THIRDPARTY_VOICE, - 0, - 0); + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, + BT_STREAM_THIRDPARTY_VOICE, 0, 0); #endif } -int app_ai_if_thirdparty_event_handle(THIRDPARTY_FUNC_ID funcId, THIRDPARTY_EVENT_TYPE event_type) -{ - int ret = 0; +int app_ai_if_thirdparty_event_handle(THIRDPARTY_FUNC_ID funcId, + THIRDPARTY_EVENT_TYPE event_type) { + int ret = 0; #ifdef __THIRDPARTY - ret = app_thirdparty_specific_lib_event_handle(funcId, event_type); + ret = app_thirdparty_specific_lib_event_handle(funcId, event_type); #endif - return ret; + return ret; } -void app_ai_if_thirdparty_init(void) -{ +void app_ai_if_thirdparty_init(void) { #if defined(__THIRDPARTY) && defined(__AI_VOICE__) - app_ai_set_use_thirdparty(true); - app_ai_if_thirdparty_mempool_init(); - app_thirdparty_callback_init(THIRDPARTY_DATA_COME_CALLBACK, app_ai_voice_thirdparty_data_come_callback); - app_thirdparty_callback_init(THIRDPARTY_WAKE_UP_CALLBACK, app_ai_voice_thirdparty_wake_up_callback); - app_thirdparty_callback_init(THIRDPARTY_START_SPEECH_CALLBACK, app_ai_voice_thirdparty_start_speech_callback); - app_thirdparty_callback_init(THIRDPARTY_STOP_SPEECH_CALLBACK, app_ai_voice_thirdparty_stop_speech_callback); - app_ai_if_thirdparty_event_handle(THIRDPARTY_FUNC_KWS, THIRDPARTY_INIT); + app_ai_set_use_thirdparty(true); + app_ai_if_thirdparty_mempool_init(); + app_thirdparty_callback_init(THIRDPARTY_DATA_COME_CALLBACK, + app_ai_voice_thirdparty_data_come_callback); + app_thirdparty_callback_init(THIRDPARTY_WAKE_UP_CALLBACK, + app_ai_voice_thirdparty_wake_up_callback); + app_thirdparty_callback_init(THIRDPARTY_START_SPEECH_CALLBACK, + app_ai_voice_thirdparty_start_speech_callback); + app_thirdparty_callback_init(THIRDPARTY_STOP_SPEECH_CALLBACK, + app_ai_voice_thirdparty_stop_speech_callback); + app_ai_if_thirdparty_event_handle(THIRDPARTY_FUNC_KWS, THIRDPARTY_INIT); #endif } - diff --git a/services/app_ai/src/app_ai_manager_api.cpp b/services/app_ai/src/app_ai_manager_api.cpp index 5fdb6a1..de8502c 100644 --- a/services/app_ai/src/app_ai_manager_api.cpp +++ b/services/app_ai/src/app_ai_manager_api.cpp @@ -1,131 +1,115 @@ -#include "cmsis_os.h" -#include "hal_trace.h" +#include "app_ai_manager_api.h" #include "app_ai_if.h" #include "app_ai_tws.h" -#include "app_ai_manager_api.h" +#include "cmsis_os.h" +#include "hal_trace.h" #ifdef __AI_VOICE__ #include "ai_manager.h" #include "ai_thread.h" #endif -bool app_ai_manager_is_in_multi_ai_mode(void) -{ - bool ret = false; +bool app_ai_manager_is_in_multi_ai_mode(void) { + bool ret = false; #ifdef IS_MULTI_AI_ENABLED - ret = true; + ret = true; #endif - return ret; + return ret; } -bool app_ai_manager_voicekey_is_enable(void) -{ - bool ret = true; +bool app_ai_manager_voicekey_is_enable(void) { + bool ret = true; #ifdef IS_MULTI_AI_ENABLED - ret = ai_voicekey_is_enable(); + ret = ai_voicekey_is_enable(); #endif - return ret; + return ret; } -void app_ai_manager_voicekey_save_status(bool state) -{ +void app_ai_manager_voicekey_save_status(bool state) { #ifdef IS_MULTI_AI_ENABLED - ai_voicekey_save_status(state); + ai_voicekey_save_status(state); #endif } -void app_ai_manager_switch_spec(AI_SPEC_TYPE_E ai_spec) -{ +void app_ai_manager_switch_spec(AI_SPEC_TYPE_E ai_spec) { #ifdef IS_MULTI_AI_ENABLED - ai_manager_switch_spec(ai_spec); + ai_manager_switch_spec(ai_spec); #endif } -void app_ai_manager_set_current_spec(AI_SPEC_TYPE_E ai_spec) -{ +void app_ai_manager_set_current_spec(AI_SPEC_TYPE_E ai_spec) { #ifdef IS_MULTI_AI_ENABLED - ai_manager_set_current_spec(ai_spec); + ai_manager_set_current_spec(ai_spec); #endif } -uint8_t app_ai_manager_get_current_spec(void) -{ - uint8_t ret = -1; +uint8_t app_ai_manager_get_current_spec(void) { + uint8_t ret = -1; #ifdef IS_MULTI_AI_ENABLED - ret = ai_manager_get_current_spec(); + ret = ai_manager_get_current_spec(); #endif - return ret; + return ret; } -bool app_ai_manager_is_need_reboot(void) -{ - bool ret = false; +bool app_ai_manager_is_need_reboot(void) { + bool ret = false; #ifdef IS_MULTI_AI_ENABLED - ret = ai_manager_is_need_reboot(); + ret = ai_manager_is_need_reboot(); #endif - return ret; + return ret; } -void app_ai_manager_enable(bool isEnabled, AI_SPEC_TYPE_E ai_spec) -{ +void app_ai_manager_enable(bool isEnabled, AI_SPEC_TYPE_E ai_spec) { #ifdef IS_MULTI_AI_ENABLED - ai_manager_enable(isEnabled, ai_spec); + ai_manager_enable(isEnabled, ai_spec); #endif } -void app_ai_manager_set_spec_connected_status(AI_SPEC_TYPE_E ai_spec, uint8_t connected) -{ +void app_ai_manager_set_spec_connected_status(AI_SPEC_TYPE_E ai_spec, + uint8_t connected) { #ifdef IS_MULTI_AI_ENABLED - ai_manager_set_spec_connected_status(ai_spec, connected); + ai_manager_set_spec_connected_status(ai_spec, connected); #endif } -int8_t app_ai_manager_get_spec_connected_status(uint8_t ai_spec) -{ - uint8_t ret = -1; +int8_t app_ai_manager_get_spec_connected_status(uint8_t ai_spec) { + uint8_t ret = -1; #ifdef IS_MULTI_AI_ENABLED - ret = ai_manager_get_spec_connected_status(ai_spec); + ret = ai_manager_get_spec_connected_status(ai_spec); #endif - return ret; + return ret; } -bool app_ai_manager_spec_get_status_is_in_invalid(void) -{ - bool ret = true; +bool app_ai_manager_spec_get_status_is_in_invalid(void) { + bool ret = true; #ifdef IS_MULTI_AI_ENABLED - ret = ai_manager_spec_get_status_is_in_invalid(); + ret = ai_manager_spec_get_status_is_in_invalid(); #endif - return ret; + return ret; } -void app_ai_manager_set_spec_update_flag(bool onOff) -{ +void app_ai_manager_set_spec_update_flag(bool onOff) { #ifdef IS_MULTI_AI_ENABLED - ai_manager_set_spec_update_flag(onOff); + ai_manager_set_spec_update_flag(onOff); #endif } -bool app_ai_manager_get_spec_update_flag(void) -{ - bool ret = false; +bool app_ai_manager_get_spec_update_flag(void) { + bool ret = false; #ifdef IS_MULTI_AI_ENABLED - ret = ai_manager_get_spec_update_flag(); + ret = ai_manager_get_spec_update_flag(); #endif - return ret; + return ret; } -void app_ai_manager_spec_update_start_reboot(void) -{ +void app_ai_manager_spec_update_start_reboot(void) { #ifdef IS_MULTI_AI_ENABLED - ai_manager_spec_update_start_reboot(); + ai_manager_spec_update_start_reboot(); #endif } -void app_ai_manager_init(void) -{ +void app_ai_manager_init(void) { #ifdef IS_MULTI_AI_ENABLED - ai_manager_init(); + ai_manager_init(); #endif } - - diff --git a/services/app_ai/src/app_ai_tws.cpp b/services/app_ai/src/app_ai_tws.cpp index 118b689..3626187 100644 --- a/services/app_ai/src/app_ai_tws.cpp +++ b/services/app_ai/src/app_ai_tws.cpp @@ -1,39 +1,41 @@ -#include "cmsis_os.h" -#include "spp_api.h" -#include "hal_trace.h" -#include "app_ai_if.h" #include "app_ai_tws.h" -#include "app_ble_mode_switch.h" +#include "app_ai_if.h" #include "app_ai_if_thirdparty.h" +#include "app_ble_mode_switch.h" +#include "cmsis_os.h" #include "hal_location.h" +#include "hal_trace.h" +#include "spp_api.h" #ifdef __AI_VOICE__ -#include "ai_manager.h" #include "ai_control.h" +#include "ai_manager.h" #include "ai_thread.h" #include "app_ai_voice.h" #endif #if defined(IBRT) -#include "app_tws_ibrt.h" +#include "app_ibrt_if.h" +#include "app_ibrt_ui.h" #include "app_tws_ctrl_thread.h" +#include "app_tws_ibrt.h" #include "app_tws_ibrt_cmd_handler.h" #include "app_tws_if.h" -#include "app_ibrt_ui.h" -#include "app_ibrt_if.h" -#include "app_tws_ctrl_thread.h" #endif #ifdef BISTO_ENABLED #include "gsound_custom.h" -#include "gsound_custom_tws.h" #include "gsound_custom_bt.h" +#include "gsound_custom_tws.h" #endif - -#define CASE_S(s) case s:return "["#s"]"; -#define CASE_D() default:return "[INVALID]"; -#define APP_AI_ROLE_SWITCH_TIME_IN_MS (500) +#define CASE_S(s) \ + case s: \ + return "[" #s "]"; +#define CASE_D() \ + default: \ + return "[INVALID]"; +#define APP_AI_ROLE_SWITCH_TIME_IN_MS (500) APP_AI_TWS_REBOOT_T REBOOT_CUSTOM_PARAM_LOC app_ai_tws_reboot = {false, 0xFF}; @@ -42,12 +44,11 @@ static void app_ai_role_switch_timeout_cb(void const *n); osTimerDef(APP_AI_ROLE_SWITCH_TIMER, app_ai_role_switch_timeout_cb); osTimerId app_ai_role_switch_timer_id = NULL; -static void app_ai_role_switch_timeout_cb(void const *n) -{ - app_ai_tws_role_switch_dis_ble(); +static void app_ai_role_switch_timeout_cb(void const *n) { + app_ai_tws_role_switch_dis_ble(); } -#define APP_AI_BLE_DISC_TIME_IN_MS (100) +#define APP_AI_BLE_DISC_TIME_IN_MS (100) static void app_ai_ble_disc_timeout_cb(void const *n); osTimerDef(APP_AI_BLE_DISC_TIMER, app_ai_ble_disc_timeout_cb); osTimerId app_ai_ble_disc_timer_id = NULL; @@ -55,602 +56,518 @@ osTimerId app_ai_ble_disc_timer_id = NULL; extern "C" bool app_ai_ble_is_connected(void); extern "C" uint16_t app_ai_ble_get_conhdl(void); -static void app_ai_ble_disc_timeout_cb(void const *n) -{ - TRACE(1,"%s", __func__); +static void app_ai_ble_disc_timeout_cb(void const *n) { + TRACE(1, "%s", __func__); - app_ai_tws_role_switch_direct(); + app_ai_tws_role_switch_direct(); } #endif -void app_ai_let_slave_continue_roleswitch(void) -{ +void app_ai_let_slave_continue_roleswitch(void) { #if defined(IBRT) && defined(__AI_VOICE__) - uint8_t role = app_ai_get_ai_spec(); - tws_ctrl_send_cmd(APP_TWS_CMD_LET_SLAVE_CONTINUE_RS, &role, 1); + uint8_t role = app_ai_get_ai_spec(); + tws_ctrl_send_cmd(APP_TWS_CMD_LET_SLAVE_CONTINUE_RS, &role, 1); #endif } -bool app_ai_tws_role_switch_direct(void) -{ - bool ret = false; +bool app_ai_tws_role_switch_direct(void) { + bool ret = false; #if defined(IBRT) && defined(__AI_VOICE__) - if (!app_ai_is_role_switching()) - { - TRACE(1,"%s isn't switching now", __func__); - return ret; - } - - TRACE(2,"%s initiative %d", __func__, app_ai_is_initiative_switch()); - if (app_ai_is_role_switch_direct()) - { - TRACE(1,"%s has done", __func__); - return ret; - } - app_ai_set_role_switch_direct(true); - - osTimerStop(app_ai_role_switch_timer_id); - osTimerStop(app_ai_ble_disc_timer_id); - - if (app_ai_is_initiative_switch()) - { - app_ibrt_if_tws_switch_prepare_done_in_bt_thread(IBRT_ROLE_SWITCH_USER_AI, app_ai_get_ai_spec()); - return ret; - } - else - { - app_ai_let_slave_continue_roleswitch(); - //ret = true; - } -#endif - + if (!app_ai_is_role_switching()) { + TRACE(1, "%s isn't switching now", __func__); return ret; -} - -bool app_ai_tws_role_switch_dis_ble(void) -{ - bool ret = false; -#if defined(IBRT) && defined(__AI_VOICE__) - uint16_t ble_Conhandle = 0; - bool ble_connected = app_ai_ble_is_connected(); - TRACE(2,"%s ble_connected %d", __func__, ble_connected); - - osTimerStop(app_ai_role_switch_timer_id); - - if (ble_connected) - { - // disconnect ble connection if existing - ble_Conhandle = app_ai_ble_get_conhdl(); - bt_drv_reg_op_ble_sup_timeout_set(ble_Conhandle, 15); //fix ble disconnection takes long time:connSupervisionTime=150ms - app_ble_disconnect_all(); - osTimerStart(app_ai_ble_disc_timer_id, APP_AI_BLE_DISC_TIME_IN_MS); - ret = true; - } - else - { - ret = app_ai_tws_role_switch_direct(); - } -#endif + } + TRACE(2, "%s initiative %d", __func__, app_ai_is_initiative_switch()); + if (app_ai_is_role_switch_direct()) { + TRACE(1, "%s has done", __func__); return ret; -} + } + app_ai_set_role_switch_direct(true); -#if defined(IBRT) && defined(__AI_VOICE__) -static void app_ai_tws_slave_request_master_role_switch(void) -{ - TRACE(3,"%s complete %d switching %d", __func__, \ - app_ai_is_setup_complete(), \ - app_ai_is_role_switching()); - - uint8_t role = app_ai_get_ai_spec(); - tws_ctrl_send_cmd(APP_TWS_CMD_LET_MASTER_PREPARE_RS, &role, 1); - osTimerStart(app_ai_ble_disc_timer_id, APP_AI_ROLE_SWITCH_TIME_IN_MS+APP_AI_BLE_DISC_TIME_IN_MS); -} -#endif - -bool app_ai_tws_master_role_switch(void) -{ - bool ret = false; -#if defined(IBRT) && defined(__AI_VOICE__) - TRACE(3,"%s complete %d switching %d", __func__, \ - app_ai_is_setup_complete(), \ - app_ai_is_role_switching()); - - if (app_ai_is_use_thirdparty()) - { - app_ai_if_thirdparty_stop_stream_by_app_audio_manager(); - app_ai_if_thirdparty_event_handle(THIRDPARTY_FUNC_KWS, THIRDPARTY_AI_DISCONNECT); - } - - app_ai_set_role_switching(true); - osTimerStart(app_ai_role_switch_timer_id, APP_AI_ROLE_SWITCH_TIME_IN_MS); - if (app_ai_is_stream_running() || (app_ai_get_speech_state() != AI_SPEECH_STATE__IDLE)) - { - TRACE(2,"%s stream runing %d", __func__, app_ai_is_stream_running()); - - ai_function_handle(CALLBACK_STOP_SPEECH, NULL, 0); - } - - if (ERROR_RETURN != ai_function_handle(API_AI_ROLE_SWITCH, NULL, 0)) - { - return true; - } - - ret = app_ai_tws_role_switch_dis_ble(); -#endif + osTimerStop(app_ai_role_switch_timer_id); + osTimerStop(app_ai_ble_disc_timer_id); + if (app_ai_is_initiative_switch()) { + app_ibrt_if_tws_switch_prepare_done_in_bt_thread(IBRT_ROLE_SWITCH_USER_AI, + app_ai_get_ai_spec()); return ret; + } else { + app_ai_let_slave_continue_roleswitch(); + // ret = true; + } +#endif + + return ret; } -bool app_ai_role_switch(void) -{ - bool ret = false; +bool app_ai_tws_role_switch_dis_ble(void) { + bool ret = false; +#if defined(IBRT) && defined(__AI_VOICE__) + uint16_t ble_Conhandle = 0; + bool ble_connected = app_ai_ble_is_connected(); + TRACE(2, "%s ble_connected %d", __func__, ble_connected); + + osTimerStop(app_ai_role_switch_timer_id); + + if (ble_connected) { + // disconnect ble connection if existing + ble_Conhandle = app_ai_ble_get_conhdl(); + bt_drv_reg_op_ble_sup_timeout_set( + ble_Conhandle, + 15); // fix ble disconnection takes long time:connSupervisionTime=150ms + app_ble_disconnect_all(); + osTimerStart(app_ai_ble_disc_timer_id, APP_AI_BLE_DISC_TIME_IN_MS); + ret = true; + } else { + ret = app_ai_tws_role_switch_direct(); + } +#endif + + return ret; +} + +#if defined(IBRT) && defined(__AI_VOICE__) +static void app_ai_tws_slave_request_master_role_switch(void) { + TRACE(3, "%s complete %d switching %d", __func__, app_ai_is_setup_complete(), + app_ai_is_role_switching()); + + uint8_t role = app_ai_get_ai_spec(); + tws_ctrl_send_cmd(APP_TWS_CMD_LET_MASTER_PREPARE_RS, &role, 1); + osTimerStart(app_ai_ble_disc_timer_id, + APP_AI_ROLE_SWITCH_TIME_IN_MS + APP_AI_BLE_DISC_TIME_IN_MS); +} +#endif + +bool app_ai_tws_master_role_switch(void) { + bool ret = false; +#if defined(IBRT) && defined(__AI_VOICE__) + TRACE(3, "%s complete %d switching %d", __func__, app_ai_is_setup_complete(), + app_ai_is_role_switching()); + + if (app_ai_is_use_thirdparty()) { + app_ai_if_thirdparty_stop_stream_by_app_audio_manager(); + app_ai_if_thirdparty_event_handle(THIRDPARTY_FUNC_KWS, + THIRDPARTY_AI_DISCONNECT); + } + + app_ai_set_role_switching(true); + osTimerStart(app_ai_role_switch_timer_id, APP_AI_ROLE_SWITCH_TIME_IN_MS); + if (app_ai_is_stream_running() || + (app_ai_get_speech_state() != AI_SPEECH_STATE__IDLE)) { + TRACE(2, "%s stream runing %d", __func__, app_ai_is_stream_running()); + + ai_function_handle(CALLBACK_STOP_SPEECH, NULL, 0); + } + + if (ERROR_RETURN != ai_function_handle(API_AI_ROLE_SWITCH, NULL, 0)) { + return true; + } + + ret = app_ai_tws_role_switch_dis_ble(); +#endif + + return ret; +} + +bool app_ai_role_switch(void) { + bool ret = false; #ifdef __AI_VOICE__ - TRACE(3,"%s complete %d switching %d", __func__, \ - app_ai_is_setup_complete(), \ - app_ai_is_role_switching()); + TRACE(3, "%s complete %d switching %d", __func__, app_ai_is_setup_complete(), + app_ai_is_role_switching()); - if (app_ai_is_role_switching()) - { - TRACE(1,"%s is switching now", __func__); - return ret; - } - app_ai_set_role_switching(true); - app_ai_set_initiative_switch(true); + if (app_ai_is_role_switching()) { + TRACE(1, "%s is switching now", __func__); + return ret; + } + app_ai_set_role_switching(true); + app_ai_set_initiative_switch(true); - if(!app_ai_is_setup_complete() && !app_ai_is_peer_setup_complete()) - { - TRACE(1,"%s ai not setup complete", __func__); - return ret; - } + if (!app_ai_is_setup_complete() && !app_ai_is_peer_setup_complete()) { + TRACE(1, "%s ai not setup complete", __func__); + return ret; + } #if defined(IBRT) - if (app_ai_tws_get_local_role() == APP_AI_TWS_MASTER) - { - ret = app_ai_tws_master_role_switch(); - } - else - { - app_ai_tws_slave_request_master_role_switch(); - ret = true; - } + if (app_ai_tws_get_local_role() == APP_AI_TWS_MASTER) { + ret = app_ai_tws_master_role_switch(); + } else { + app_ai_tws_slave_request_master_role_switch(); + ret = true; + } #endif #endif - return ret; + return ret; } -uint32_t app_ai_tws_role_switch_prepare(uint32_t *wait_ms) -{ - uint32_t ret = 0; +uint32_t app_ai_tws_role_switch_prepare(uint32_t *wait_ms) { + uint32_t ret = 0; #ifdef BISTO_ENABLED + *wait_ms = 800; + ret |= (1 << AI_SPEC_GSOUND); +#endif + +#ifdef __AI_VOICE__ + if (app_ai_role_switch()) { *wait_ms = 800; - ret |= (1 << AI_SPEC_GSOUND); + ret |= (1 << app_ai_get_ai_spec()); + } #endif -#ifdef __AI_VOICE__ - if (app_ai_role_switch()) - { - *wait_ms = 800; - ret |= (1 << app_ai_get_ai_spec()); - } -#endif - - TRACE(3,"[%s] ret=%d, wait_ms=%d", __func__, ret, *wait_ms); - return ret; + TRACE(3, "[%s] ret=%d, wait_ms=%d", __func__, ret, *wait_ms); + return ret; } -void app_ai_tws_master_role_switch_prepare(void) -{ +void app_ai_tws_master_role_switch_prepare(void) { #ifdef __AI_VOICE__ - app_ai_tws_master_role_switch(); + app_ai_tws_master_role_switch(); #endif } -void app_ai_tws_role_switch_prepare_done(void) -{ +void app_ai_tws_role_switch_prepare_done(void) { #if defined(IBRT) && defined(__AI_VOICE__) - TRACE(1,"%s", __func__); + TRACE(1, "%s", __func__); - app_ai_tws_role_switch_direct(); + app_ai_tws_role_switch_direct(); #endif } -void app_ai_tws_role_switch(void) -{ - TRACE(1,"[%s]", __func__); +void app_ai_tws_role_switch(void) { + TRACE(1, "[%s]", __func__); #ifdef BISTO_ENABLED - gsound_tws_request_roleswitch(); + gsound_tws_request_roleswitch(); #endif } -void app_ai_tws_role_switch_complete(void) -{ +void app_ai_tws_role_switch_complete(void) { #ifdef __AI_VOICE__ - TRACE(1,"%s", __func__); + TRACE(1, "%s", __func__); - app_ai_set_role_switching(false); - app_ai_set_initiative_switch(false); - app_ai_set_role_switch_direct(false); - app_ai_set_can_role_switch(false); - app_ai_set_ble_adv(); + app_ai_set_role_switching(false); + app_ai_set_initiative_switch(false); + app_ai_set_role_switch_direct(false); + app_ai_set_can_role_switch(false); + app_ai_set_ble_adv(); - if (app_ai_is_setup_complete()) - { - app_ai_set_speech_state(AI_SPEECH_STATE__IDLE); - app_ai_voice_stream_deinit(); + if (app_ai_is_setup_complete()) { + app_ai_set_speech_state(AI_SPEECH_STATE__IDLE); + app_ai_voice_stream_deinit(); #if defined(IBRT) - if (app_tws_ibrt_tws_link_connected() && (app_ai_tws_get_local_role() == APP_AI_TWS_MASTER)) + if (app_tws_ibrt_tws_link_connected() && + (app_ai_tws_get_local_role() == APP_AI_TWS_MASTER)) #endif - { - if (app_ai_is_in_multi_ai_mode()) - { - if (AI_SPEC_GSOUND == ai_manager_get_current_spec() || \ - AI_SPEC_INIT == ai_manager_get_current_spec()) - { - return; - } - } - - if (app_ai_is_use_thirdparty()) - { - app_ai_if_thirdparty_event_handle(THIRDPARTY_FUNC_KWS, THIRDPARTY_AI_CONNECT); - app_ai_if_thirdparty_start_stream_by_app_audio_manager(); - } + { + if (app_ai_is_in_multi_ai_mode()) { + if (AI_SPEC_GSOUND == ai_manager_get_current_spec() || + AI_SPEC_INIT == ai_manager_get_current_spec()) { + return; } - } + } - app_ai_ui_global_handler_ind(AI_CUSTOM_CODE_AI_ROLE_SWITCH_COMPLETE, NULL, 0); + if (app_ai_is_use_thirdparty()) { + app_ai_if_thirdparty_event_handle(THIRDPARTY_FUNC_KWS, + THIRDPARTY_AI_CONNECT); + app_ai_if_thirdparty_start_stream_by_app_audio_manager(); + } + } + } + + app_ai_ui_global_handler_ind(AI_CUSTOM_CODE_AI_ROLE_SWITCH_COMPLETE, NULL, 0); #endif } -void app_ai_tws_sync_info_prepare_handler(uint8_t *buf, uint16_t *length) -{ +void app_ai_tws_sync_info_prepare_handler(uint8_t *buf, uint16_t *length) { #ifdef __AI_VOICE__ - uint16_t buf_len = 0; + uint16_t buf_len = 0; - *length = ai_save_ctx(buf, buf_len); + *length = ai_save_ctx(buf, buf_len); #endif } -void app_ai_tws_sync_info_received_handler(uint8_t *buf, uint16_t length) -{ +void app_ai_tws_sync_info_received_handler(uint8_t *buf, uint16_t length) { #ifdef __AI_VOICE__ - ai_restore_ctx(buf, length); + ai_restore_ctx(buf, length); #endif } -void app_ai_tws_sync_init(void) -{ +void app_ai_tws_sync_init(void) { #if defined(IBRT) && defined(__AI_VOICE__) - TWS_SYNC_USER_T user_app_ai_t = { - app_ai_tws_sync_info_prepare_handler, - app_ai_tws_sync_info_received_handler, - NULL, - NULL, - NULL, - }; + TWS_SYNC_USER_T user_app_ai_t = { + app_ai_tws_sync_info_prepare_handler, + app_ai_tws_sync_info_received_handler, + NULL, + NULL, + NULL, + }; - app_tws_if_register_sync_user(TWS_SYNC_USER_AI_INFO, &user_app_ai_t); + app_tws_if_register_sync_user(TWS_SYNC_USER_AI_INFO, &user_app_ai_t); - if(NULL == app_ai_role_switch_timer_id) - { - app_ai_role_switch_timer_id = - osTimerCreate(osTimer(APP_AI_ROLE_SWITCH_TIMER), osTimerOnce, NULL); - } - if(NULL == app_ai_ble_disc_timer_id) - { - app_ai_ble_disc_timer_id = - osTimerCreate(osTimer(APP_AI_BLE_DISC_TIMER), osTimerOnce, NULL); - } + if (NULL == app_ai_role_switch_timer_id) { + app_ai_role_switch_timer_id = + osTimerCreate(osTimer(APP_AI_ROLE_SWITCH_TIMER), osTimerOnce, NULL); + } + if (NULL == app_ai_ble_disc_timer_id) { + app_ai_ble_disc_timer_id = + osTimerCreate(osTimer(APP_AI_BLE_DISC_TIMER), osTimerOnce, NULL); + } #endif } -void app_ai_tws_sync_ai_info(void) -{ +void app_ai_tws_sync_ai_info(void) { #if defined(IBRT) && defined(__AI_VOICE__) - app_tws_if_sync_info(TWS_SYNC_USER_AI_INFO); + app_tws_if_sync_info(TWS_SYNC_USER_AI_INFO); #endif } -void ai_manager_sync_info_prepare_handler(uint8_t *buf, uint16_t *length) -{ +void ai_manager_sync_info_prepare_handler(uint8_t *buf, uint16_t *length) { #ifdef IS_MULTI_AI_ENABLED - uint16_t buf_len = 0; + uint16_t buf_len = 0; - *length = ai_manager_save_ctx(buf, buf_len); + *length = ai_manager_save_ctx(buf, buf_len); #endif } -void ai_manager_sync_info_received_handler(uint8_t *buf, uint16_t length) -{ +void ai_manager_sync_info_received_handler(uint8_t *buf, uint16_t length) { #ifdef IS_MULTI_AI_ENABLED - ai_manager_restore_ctx(buf, length); + ai_manager_restore_ctx(buf, length); #endif } -void ai_manager_sync_info_received_rsp_handler(uint8_t *buf, uint16_t length) -{ +void ai_manager_sync_info_received_rsp_handler(uint8_t *buf, uint16_t length) { #ifdef IS_MULTI_AI_ENABLED - ai_manager_save_ctx_rsp_handle(buf, length); + ai_manager_save_ctx_rsp_handle(buf, length); #endif } -void ai_manager_sync_init(void) -{ +void ai_manager_sync_init(void) { #if defined(IBRT) && defined(IS_MULTI_AI_ENABLED) - TWS_SYNC_USER_T user_ai_manager_t = { - ai_manager_sync_info_prepare_handler, - ai_manager_sync_info_received_handler, - NULL, - ai_manager_sync_info_received_rsp_handler, - ai_manager_sync_info_received_rsp_handler, - }; + TWS_SYNC_USER_T user_ai_manager_t = { + ai_manager_sync_info_prepare_handler, + ai_manager_sync_info_received_handler, + NULL, + ai_manager_sync_info_received_rsp_handler, + ai_manager_sync_info_received_rsp_handler, + }; - app_tws_if_register_sync_user(TWS_SYNC_USER_AI_MANAGER, &user_ai_manager_t); + app_tws_if_register_sync_user(TWS_SYNC_USER_AI_MANAGER, &user_ai_manager_t); #endif } -void app_ai_tws_sync_ai_manager_info(void) -{ +void app_ai_tws_sync_ai_manager_info(void) { #if defined(IBRT) && defined(IS_MULTI_AI_ENABLED) - app_tws_if_sync_info(TWS_SYNC_USER_AI_MANAGER); + app_tws_if_sync_info(TWS_SYNC_USER_AI_MANAGER); #endif } #ifdef IBRT -static void gsound_connect_sync_info_prepare_handler(uint8_t *buf, uint16_t *length) -{ +static void gsound_connect_sync_info_prepare_handler(uint8_t *buf, + uint16_t *length) { #ifdef BISTO_ENABLED - *length = 0; + *length = 0; - AI_CONNECTION_STATE_T *pAiInfo = (AI_CONNECTION_STATE_T*)buf; + AI_CONNECTION_STATE_T *pAiInfo = (AI_CONNECTION_STATE_T *)buf; - pAiInfo->connBtState = gsound_is_bt_connected(); - pAiInfo->connPathType = gsound_custom_get_connection_path(); - memcpy(pAiInfo->connBdAddr, gsound_get_connected_bd_addr(), 6); + pAiInfo->connBtState = gsound_is_bt_connected(); + pAiInfo->connPathType = gsound_custom_get_connection_path(); + memcpy(pAiInfo->connBdAddr, gsound_get_connected_bd_addr(), 6); - if (CONNECTION_BLE == pAiInfo->connPathType) - { - pAiInfo->connPathState = gsound_get_ble_connect_state(); - } - else if (CONNECTION_BT == pAiInfo->connPathType) - { - pAiInfo->connPathState = gsound_get_bt_connect_state(); - } - else - { - pAiInfo->connPathState = 0; - } + if (CONNECTION_BLE == pAiInfo->connPathType) { + pAiInfo->connPathState = gsound_get_ble_connect_state(); + } else if (CONNECTION_BT == pAiInfo->connPathType) { + pAiInfo->connPathState = gsound_get_bt_connect_state(); + } else { + pAiInfo->connPathState = 0; + } - *length = sizeof(AI_CONNECTION_STATE_T); + *length = sizeof(AI_CONNECTION_STATE_T); #endif } -static void gsound_connect_sync_info_received_handler(uint8_t *buf, uint16_t length) -{ +static void gsound_connect_sync_info_received_handler(uint8_t *buf, + uint16_t length) { #ifdef BISTO_ENABLED - gsound_custom_connection_state_received_handler(buf); + gsound_custom_connection_state_received_handler(buf); #endif } #endif -void app_ai_tws_gsound_sync_init(void) -{ +void app_ai_tws_gsound_sync_init(void) { #ifdef IBRT - TWS_SYNC_USER_T userAiConnect = { - gsound_connect_sync_info_prepare_handler, - gsound_connect_sync_info_received_handler, - NULL, - NULL, - NULL, - }; + TWS_SYNC_USER_T userAiConnect = { + gsound_connect_sync_info_prepare_handler, + gsound_connect_sync_info_received_handler, + NULL, + NULL, + NULL, + }; - app_tws_if_register_sync_user(TWS_SYNC_USER_AI_CONNECTION, &userAiConnect); + app_tws_if_register_sync_user(TWS_SYNC_USER_AI_CONNECTION, &userAiConnect); #endif } -void app_ai_tws_send_cmd_to_peer(uint8_t *p_buff, uint16_t length) -{ +void app_ai_tws_send_cmd_to_peer(uint8_t *p_buff, uint16_t length) { #ifdef IBRT - if (app_tws_ibrt_tws_link_connected()) - { - app_tws_if_ai_send_cmd_to_peer(p_buff, length); - } + if (app_tws_ibrt_tws_link_connected()) { + app_tws_if_ai_send_cmd_to_peer(p_buff, length); + } #endif } -void app_ai_tws_rev_peer_cmd_hanlder(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ +void app_ai_tws_rev_peer_cmd_hanlder(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { #ifdef __AI_VOICE__ - app_ai_rev_peer_cmd_hanlder(rsp_seq, p_buff, length); + app_ai_rev_peer_cmd_hanlder(rsp_seq, p_buff, length); #endif } -void app_ai_tws_send_cmd_with_rsp_to_peer(uint8_t *p_buff, uint16_t length) -{ +void app_ai_tws_send_cmd_with_rsp_to_peer(uint8_t *p_buff, uint16_t length) { #ifdef IBRT - if (app_tws_ibrt_tws_link_connected()) - { - app_tws_if_ai_send_cmd_with_rsp_to_peer(p_buff, length); - } + if (app_tws_ibrt_tws_link_connected()) { + app_tws_if_ai_send_cmd_with_rsp_to_peer(p_buff, length); + } #endif } -void app_ai_tws_send_cmd_rsp_to_peer(uint8_t *p_buff, uint16_t rsp_seq, uint16_t length) -{ +void app_ai_tws_send_cmd_rsp_to_peer(uint8_t *p_buff, uint16_t rsp_seq, + uint16_t length) { #ifdef IBRT - if (app_tws_ibrt_tws_link_connected()) - { - app_tws_if_ai_send_cmd_rsp_to_peer(p_buff, rsp_seq, length); - } + if (app_tws_ibrt_tws_link_connected()) { + app_tws_if_ai_send_cmd_rsp_to_peer(p_buff, rsp_seq, length); + } #endif } -void app_ai_tws_rev_peer_cmd_with_rsp_hanlder(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ +void app_ai_tws_rev_peer_cmd_with_rsp_hanlder(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { #ifdef __AI_VOICE__ - app_ai_rev_peer_cmd_hanlder(rsp_seq, p_buff, length); + app_ai_rev_peer_cmd_hanlder(rsp_seq, p_buff, length); #endif } -void app_ai_tws_rev_cmd_rsp_from_peer_hanlder(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ +void app_ai_tws_rev_cmd_rsp_from_peer_hanlder(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { #ifdef __AI_VOICE__ - app_ai_rev_peer_cmd_hanlder(rsp_seq, p_buff, length); + app_ai_rev_peer_cmd_hanlder(rsp_seq, p_buff, length); #endif } -void app_ai_tws_rev_cmd_rsp_timeout_hanlder(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ +void app_ai_tws_rev_cmd_rsp_timeout_hanlder(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { #ifdef __AI_VOICE__ - app_ai_rev_peer_cmd_rsp_timeout_hanlder(rsp_seq, p_buff, length); + app_ai_rev_peer_cmd_rsp_timeout_hanlder(rsp_seq, p_buff, length); #endif } - -bool app_ai_tws_init_done(void) -{ +bool app_ai_tws_init_done(void) { #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - return (p_ibrt_ctrl->init_done != 0); + return (p_ibrt_ctrl->init_done != 0); #endif - return false; + return false; } -bool app_ai_tws_link_connected(void) -{ +bool app_ai_tws_link_connected(void) { #if defined(IBRT) - return app_tws_ibrt_tws_link_connected(); + return app_tws_ibrt_tws_link_connected(); #endif - return false; + return false; } -uint8_t *app_ai_tws_local_address(void) -{ - uint8_t *local_addr = NULL; +uint8_t *app_ai_tws_local_address(void) { + uint8_t *local_addr = NULL; #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - local_addr = p_ibrt_ctrl->local_addr.address; + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + local_addr = p_ibrt_ctrl->local_addr.address; #endif - return local_addr; + return local_addr; } -uint8_t *app_ai_tws_peer_address(void) -{ - uint8_t *peer_addr = NULL; +uint8_t *app_ai_tws_peer_address(void) { + uint8_t *peer_addr = NULL; #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - peer_addr = p_ibrt_ctrl->local_addr.address; + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + peer_addr = p_ibrt_ctrl->local_addr.address; #endif - return peer_addr; + return peer_addr; } -void app_ai_tws_reboot_record_box_state(void) -{ - app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); - app_ai_tws_reboot.is_ai_reboot = true; - app_ai_tws_reboot.box_state = p_ibrt_ui->box_state; - TRACE(2, "%s box state %d", __func__, p_ibrt_ui->box_state); +void app_ai_tws_reboot_record_box_state(void) { + app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); + app_ai_tws_reboot.is_ai_reboot = true; + app_ai_tws_reboot.box_state = p_ibrt_ui->box_state; + TRACE(2, "%s box state %d", __func__, p_ibrt_ui->box_state); } -uint8_t app_ai_tws_reboot_get_box_action(void) -{ - uint8_t box_state = 0xFF; +uint8_t app_ai_tws_reboot_get_box_action(void) { + uint8_t box_state = 0xFF; - if (app_ai_tws_reboot.is_ai_reboot) - { - box_state = app_ai_tws_reboot.box_state; - } + if (app_ai_tws_reboot.is_ai_reboot) { + box_state = app_ai_tws_reboot.box_state; + } - TRACE(2, "%s box state %d", __func__, box_state); - if (box_state == IBRT_IN_BOX_OPEN) - { - return IBRT_OPEN_BOX_EVENT; - } - else if (box_state == IBRT_OUT_BOX) - { - return IBRT_FETCH_OUT_EVENT; - } - else if (box_state == IBRT_OUT_BOX_WEARED) - { - return IBRT_WEAR_UP_EVENT; - } + TRACE(2, "%s box state %d", __func__, box_state); + if (box_state == IBRT_IN_BOX_OPEN) { + return IBRT_OPEN_BOX_EVENT; + } else if (box_state == IBRT_OUT_BOX) { + return IBRT_FETCH_OUT_EVENT; + } else if (box_state == IBRT_OUT_BOX_WEARED) { + return IBRT_WEAR_UP_EVENT; + } - return 0xFF; + return 0xFF; } -void app_ai_tws_clear_reboot_box_state(void) -{ - TRACE(2, "%s box state %d", __func__, app_ai_tws_reboot.box_state); - app_ai_tws_reboot.is_ai_reboot = false; - app_ai_tws_reboot.box_state = 0xFF; +void app_ai_tws_clear_reboot_box_state(void) { + TRACE(2, "%s box state %d", __func__, app_ai_tws_reboot.box_state); + app_ai_tws_reboot.is_ai_reboot = false; + app_ai_tws_reboot.box_state = 0xFF; } -void app_ai_tws_disconnect_all_bt_connection(void) -{ +void app_ai_tws_disconnect_all_bt_connection(void) { #if defined(IBRT) - app_tws_ibrt_disconnect_all_connection(); + app_tws_ibrt_disconnect_all_connection(); #endif } -uint8_t app_ai_tws_get_local_role(void) -{ - uint8_t local_role = APP_AI_TWS_UNKNOW; +uint8_t app_ai_tws_get_local_role(void) { + uint8_t local_role = APP_AI_TWS_UNKNOW; #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (app_ibrt_ui_is_profile_exchanged()) - { - if (app_tws_ibrt_mobile_link_connected()) - { - local_role = APP_AI_TWS_MASTER; - } - else if (app_tws_ibrt_slave_ibrt_link_connected()) - { - local_role = APP_AI_TWS_SLAVE; - } - else - { - local_role = APP_AI_TWS_UNKNOW; - } + if (app_ibrt_ui_is_profile_exchanged()) { + if (app_tws_ibrt_mobile_link_connected()) { + local_role = APP_AI_TWS_MASTER; + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + local_role = APP_AI_TWS_SLAVE; + } else { + local_role = APP_AI_TWS_UNKNOW; } - else if (app_tws_ibrt_tws_link_connected()) - { - if (app_tws_ibrt_mobile_link_connected()) - { - local_role = APP_AI_TWS_MASTER; - } - else if(p_ibrt_ctrl->current_role == IBRT_MASTER) - { - local_role = APP_AI_TWS_MASTER; - } - else - { - local_role = APP_AI_TWS_SLAVE; - } - - } - else - { - local_role = APP_AI_TWS_UNKNOW; + } else if (app_tws_ibrt_tws_link_connected()) { + if (app_tws_ibrt_mobile_link_connected()) { + local_role = APP_AI_TWS_MASTER; + } else if (p_ibrt_ctrl->current_role == IBRT_MASTER) { + local_role = APP_AI_TWS_MASTER; + } else { + local_role = APP_AI_TWS_SLAVE; } - TRACE(5, "[%s] %d exchanged %d tws %d mobile %d", - __func__, local_role, app_ibrt_ui_is_profile_exchanged(), - app_tws_ibrt_tws_link_connected(), - app_tws_ibrt_mobile_link_connected()); + } else { + local_role = APP_AI_TWS_UNKNOW; + } + + TRACE(5, "[%s] %d exchanged %d tws %d mobile %d", __func__, local_role, + app_ibrt_ui_is_profile_exchanged(), app_tws_ibrt_tws_link_connected(), + app_tws_ibrt_mobile_link_connected()); #endif - return local_role; + return local_role; } -void app_ai_tws_init(void) -{ +void app_ai_tws_init(void) { #if defined(IBRT) && defined(__AI_VOICE__) - app_ai_set_in_tws_mode(true); + app_ai_set_in_tws_mode(true); #endif } - diff --git a/services/app_ai/voice_sbc/voice_sbc.cpp b/services/app_ai/voice_sbc/voice_sbc.cpp index c36d1a3..30f9594 100644 --- a/services/app_ai/voice_sbc/voice_sbc.cpp +++ b/services/app_ai/voice_sbc/voice_sbc.cpp @@ -17,17 +17,10 @@ #include "voice_sbc.h" #include "hal_trace.h" -static VOICE_SBC_CONFIG_T voice_sbc_config = -{ - VOICE_SBC_CHANNEL_COUNT , - VOICE_SBC_CHANNEL_MODE , - VOICE_SBC_BIT_POOL , - VOICE_SBC_SIZE_PER_SAMPLE , - VOICE_SBC_SAMPLE_RATE , - VOICE_SBC_NUM_BLOCKS , - VOICE_SBC_NUM_SUB_BANDS , - VOICE_SBC_MSBC_FLAG , - VOICE_SBC_ALLOC_METHOD , +static VOICE_SBC_CONFIG_T voice_sbc_config = { + VOICE_SBC_CHANNEL_COUNT, VOICE_SBC_CHANNEL_MODE, VOICE_SBC_BIT_POOL, + VOICE_SBC_SIZE_PER_SAMPLE, VOICE_SBC_SAMPLE_RATE, VOICE_SBC_NUM_BLOCKS, + VOICE_SBC_NUM_SUB_BANDS, VOICE_SBC_MSBC_FLAG, VOICE_SBC_ALLOC_METHOD, }; static int voice_sbc_init_encoder(void); @@ -38,159 +31,150 @@ static uint32_t voice_sbc_frame_len = 0; static float voice_sbc_eq_band_gain[8] = {1, 1, 1, 1, 1, 1, 1, 1}; -static int voice_sbc_init_encoder(void) -{ - btif_sbc_init_encoder(&voice_sbc_encoder); - voice_sbc_encoder.streamInfo.numChannels = voice_sbc_config.channelCnt; - voice_sbc_encoder.streamInfo.channelMode = voice_sbc_config.channelMode; - voice_sbc_encoder.streamInfo.bitPool = voice_sbc_config.bitPool; - voice_sbc_encoder.streamInfo.sampleFreq = voice_sbc_config.sampleRate; - voice_sbc_encoder.streamInfo.allocMethod = voice_sbc_config.allocMethod; - voice_sbc_encoder.streamInfo.numBlocks = voice_sbc_config.numBlocks; - voice_sbc_encoder.streamInfo.numSubBands = voice_sbc_config.numSubBands; - voice_sbc_encoder.streamInfo.mSbcFlag = voice_sbc_config.mSbcFlag; +static int voice_sbc_init_encoder(void) { + btif_sbc_init_encoder(&voice_sbc_encoder); + voice_sbc_encoder.streamInfo.numChannels = voice_sbc_config.channelCnt; + voice_sbc_encoder.streamInfo.channelMode = voice_sbc_config.channelMode; + voice_sbc_encoder.streamInfo.bitPool = voice_sbc_config.bitPool; + voice_sbc_encoder.streamInfo.sampleFreq = voice_sbc_config.sampleRate; + voice_sbc_encoder.streamInfo.allocMethod = voice_sbc_config.allocMethod; + voice_sbc_encoder.streamInfo.numBlocks = voice_sbc_config.numBlocks; + voice_sbc_encoder.streamInfo.numSubBands = voice_sbc_config.numSubBands; + voice_sbc_encoder.streamInfo.mSbcFlag = voice_sbc_config.mSbcFlag; - voice_sbc_frame_len = btif_sbc_frame_len(&(voice_sbc_encoder.streamInfo)); + voice_sbc_frame_len = btif_sbc_frame_len(&(voice_sbc_encoder.streamInfo)); - TRACE(1,"frame len is %d", voice_sbc_frame_len); - return 0; + TRACE(1, "frame len is %d", voice_sbc_frame_len); + return 0; } -static int voice_sbc_init_decoder(void) -{ - btif_sbc_init_decoder(&voice_sbc_decoder); - voice_sbc_decoder.streamInfo.numChannels = voice_sbc_config.channelCnt; - voice_sbc_decoder.streamInfo.channelMode = voice_sbc_config.channelMode; - voice_sbc_decoder.streamInfo.bitPool = voice_sbc_config.bitPool; - voice_sbc_decoder.streamInfo.sampleFreq = voice_sbc_config.sampleRate; - voice_sbc_decoder.streamInfo.allocMethod = voice_sbc_config.allocMethod; - voice_sbc_decoder.streamInfo.numBlocks = voice_sbc_config.numBlocks; - voice_sbc_decoder.streamInfo.numSubBands = voice_sbc_config.numSubBands; - voice_sbc_decoder.streamInfo.mSbcFlag = voice_sbc_config.mSbcFlag; - return 0; +static int voice_sbc_init_decoder(void) { + btif_sbc_init_decoder(&voice_sbc_decoder); + voice_sbc_decoder.streamInfo.numChannels = voice_sbc_config.channelCnt; + voice_sbc_decoder.streamInfo.channelMode = voice_sbc_config.channelMode; + voice_sbc_decoder.streamInfo.bitPool = voice_sbc_config.bitPool; + voice_sbc_decoder.streamInfo.sampleFreq = voice_sbc_config.sampleRate; + voice_sbc_decoder.streamInfo.allocMethod = voice_sbc_config.allocMethod; + voice_sbc_decoder.streamInfo.numBlocks = voice_sbc_config.numBlocks; + voice_sbc_decoder.streamInfo.numSubBands = voice_sbc_config.numSubBands; + voice_sbc_decoder.streamInfo.mSbcFlag = voice_sbc_config.mSbcFlag; + return 0; } -uint32_t voice_sbc_get_frame_len(void) -{ - return voice_sbc_frame_len; +uint32_t voice_sbc_get_frame_len(void) { return voice_sbc_frame_len; } + +uint32_t voice_sbc_encode(uint8_t *input, uint32_t inputBytes, + uint32_t *purchasedBytes, uint8_t *output, + uint8_t isReset) { + if (isReset) { + voice_sbc_init_encoder(); + } + + btif_sbc_pcm_data_t PcmEncData; + uint16_t outputSbcBytes, bytes_encoded; + + PcmEncData.numChannels = voice_sbc_encoder.streamInfo.numChannels; + PcmEncData.sampleFreq = voice_sbc_encoder.streamInfo.sampleFreq; + + if (voice_sbc_encoder.streamInfo.mSbcFlag) { + uint16_t outputOffset = 0; + uint16_t oneChunkOutput = 0; + uint16_t oneChunkConsumed; + bytes_encoded = 0; + + for (uint32_t index = 0; index < inputBytes; + index += (uint32_t)VOICE_SBC_PCM_DATA_SIZE_PER_FRAME) { + PcmEncData.data = input + index; + PcmEncData.dataLen = VOICE_SBC_PCM_DATA_SIZE_PER_FRAME; + // output[outputOffset++] = 0xAD; + // output[outputOffset++] = 0x02; + btif_sbc_encode_frames(&voice_sbc_encoder, &PcmEncData, &oneChunkConsumed, + &output[outputOffset], &oneChunkOutput, 0xFFFF); + outputOffset += oneChunkOutput; + // output[outputOffset++] = 0x00; + + bytes_encoded += oneChunkConsumed; + } + + outputSbcBytes = outputOffset; + } else { + PcmEncData.data = input; + PcmEncData.dataLen = inputBytes; + + btif_sbc_encode_frames(&voice_sbc_encoder, &PcmEncData, &bytes_encoded, + output, &outputSbcBytes, 0xFFFF); + } + + TRACE(2, "Encode %d bytes PCM data into %d bytes SBC data.", inputBytes, + outputSbcBytes); + TRACE(1, "Consumed PCM data %d bytes", bytes_encoded); + + *purchasedBytes = bytes_encoded; + + return outputSbcBytes; } -uint32_t voice_sbc_encode(uint8_t *input, uint32_t inputBytes, uint32_t* purchasedBytes, uint8_t *output, uint8_t isReset) -{ - if (isReset) - { - voice_sbc_init_encoder(); - } - - btif_sbc_pcm_data_t PcmEncData; - uint16_t outputSbcBytes, bytes_encoded; - - PcmEncData.numChannels = voice_sbc_encoder.streamInfo.numChannels; - PcmEncData.sampleFreq = voice_sbc_encoder.streamInfo.sampleFreq; +uint32_t voice_sbc_decode(uint8_t *pcm_buffer, CQueue *encodedDataQueue, + uint32_t expectedOutputSize, uint8_t isReset) { + if (isReset) { + voice_sbc_init_decoder(); + } + int r = 0; + unsigned char *e1 = NULL, *e2 = NULL; + unsigned int len1 = 0, len2 = 0; + uint32_t sbcDataBytesToDecode; + unsigned int pcm_offset = 0; + uint16_t byte_decode; + int8_t ret; + btif_sbc_pcm_data_t voice_PcmDecData; - if (voice_sbc_encoder.streamInfo.mSbcFlag) - { - uint16_t outputOffset = 0; - uint16_t oneChunkOutput = 0; - uint16_t oneChunkConsumed; - bytes_encoded = 0; +get_again: + voice_PcmDecData.data = pcm_buffer + pcm_offset; + voice_PcmDecData.dataLen = 0; - for (uint32_t index = 0;index < inputBytes;index += (uint32_t)VOICE_SBC_PCM_DATA_SIZE_PER_FRAME) - { - PcmEncData.data = input+index; - PcmEncData.dataLen = VOICE_SBC_PCM_DATA_SIZE_PER_FRAME; - //output[outputOffset++] = 0xAD; - //output[outputOffset++] = 0x02; - btif_sbc_encode_frames(&voice_sbc_encoder, &PcmEncData, &oneChunkConsumed, - &output[outputOffset], &oneChunkOutput, 0xFFFF) ; - outputOffset += oneChunkOutput; - //output[outputOffset++] = 0x00; + if (LengthOfCQueue(encodedDataQueue) > + VOICE_SBC_ENCODED_DATA_SIZE_PER_FRAME) { + sbcDataBytesToDecode = VOICE_SBC_ENCODED_DATA_SIZE_PER_FRAME; + } else { + sbcDataBytesToDecode = LengthOfCQueue(encodedDataQueue); + } - bytes_encoded += oneChunkConsumed; - } + len1 = len2 = 0; + r = PeekCQueue(encodedDataQueue, sbcDataBytesToDecode, &e1, &len1, &e2, + &len2); + if ((r == CQ_ERR) || (0 == len1)) { + goto exit; + } - outputSbcBytes = outputOffset; - } - else - { - PcmEncData.data = input; - PcmEncData.dataLen = inputBytes; + ret = btif_sbc_decode_frames(&voice_sbc_decoder, (unsigned char *)e1, len1, + &byte_decode, &voice_PcmDecData, + expectedOutputSize - pcm_offset, + voice_sbc_eq_band_gain); - btif_sbc_encode_frames(&voice_sbc_encoder, &PcmEncData, &bytes_encoded, - output, &outputSbcBytes, 0xFFFF) ; - } - - TRACE(2,"Encode %d bytes PCM data into %d bytes SBC data.", inputBytes, outputSbcBytes); - TRACE(1,"Consumed PCM data %d bytes", bytes_encoded); - - *purchasedBytes = bytes_encoded; - - return outputSbcBytes; -} + TRACE(4, "len1 %d byte_decode %d expectedOutputSize %d pcm_offset %d", len1, + byte_decode, expectedOutputSize, pcm_offset); + TRACE(1, "voice_PcmDecData.dataLen %d", voice_PcmDecData.dataLen); -uint32_t voice_sbc_decode(uint8_t* pcm_buffer, CQueue* encodedDataQueue, uint32_t expectedOutputSize, uint8_t isReset) -{ - if (isReset) - { - voice_sbc_init_decoder(); - } - int r = 0; - unsigned char *e1 = NULL, *e2 = NULL; - unsigned int len1 = 0, len2 = 0; - uint32_t sbcDataBytesToDecode; - unsigned int pcm_offset = 0; - uint16_t byte_decode; - int8_t ret; - btif_sbc_pcm_data_t voice_PcmDecData; - -get_again: - voice_PcmDecData.data = pcm_buffer+pcm_offset; - voice_PcmDecData.dataLen = 0; - - if (LengthOfCQueue(encodedDataQueue) > VOICE_SBC_ENCODED_DATA_SIZE_PER_FRAME) - { - sbcDataBytesToDecode = VOICE_SBC_ENCODED_DATA_SIZE_PER_FRAME; - } - else - { - sbcDataBytesToDecode = LengthOfCQueue(encodedDataQueue); - } - - len1 = len2 = 0; - r = PeekCQueue(encodedDataQueue, sbcDataBytesToDecode, &e1, &len1, &e2, &len2); - if ((r == CQ_ERR) || (0 == len1)) { - goto exit; - } + DeCQueue(encodedDataQueue, 0, byte_decode); - ret = btif_sbc_decode_frames(&voice_sbc_decoder, (unsigned char *)e1, len1, &byte_decode, - &voice_PcmDecData, expectedOutputSize-pcm_offset, voice_sbc_eq_band_gain); + pcm_offset += voice_PcmDecData.dataLen; - TRACE(4,"len1 %d byte_decode %d expectedOutputSize %d pcm_offset %d", - len1, byte_decode, expectedOutputSize, pcm_offset); - TRACE(1,"voice_PcmDecData.dataLen %d", voice_PcmDecData.dataLen); + if (expectedOutputSize == pcm_offset) { + goto exit; + } + + if ((ret == BT_STS_SDP_CONT_STATE) || (ret == BT_STS_SUCCESS)) { + goto get_again; + } - DeCQueue(encodedDataQueue, 0, byte_decode); - - pcm_offset += voice_PcmDecData.dataLen; - - if (expectedOutputSize == pcm_offset) - { - goto exit; - } - - if ((ret == BT_STS_SDP_CONT_STATE) || (ret == BT_STS_SUCCESS)) { - goto get_again; - } - exit: - TRACE(1,"Get pcm data size %d", pcm_offset); - return pcm_offset; + TRACE(1, "Get pcm data size %d", pcm_offset); + return pcm_offset; } -int voice_sbc_init(VOICE_SBC_CONFIG_T* pConfig) -{ - voice_sbc_config = *pConfig; - return 0; +int voice_sbc_init(VOICE_SBC_CONFIG_T *pConfig) { + voice_sbc_config = *pConfig; + return 0; } #endif diff --git a/services/app_ibrt/inc/app_ibrt_a2dp.h b/services/app_ibrt/inc/app_ibrt_a2dp.h index 9de9c60..40b1494 100644 --- a/services/app_ibrt/inc/app_ibrt_a2dp.h +++ b/services/app_ibrt/inc/app_ibrt_a2dp.h @@ -15,6 +15,9 @@ ****************************************************************************/ #ifndef __APP_IBRT_A2DP__ #define __APP_IBRT_A2DP__ +#include "a2dp_api.h" +#include "app_tws_ibrt_cmd_sync_a2dp_status.h" +#include a2dp_stream_t *app_bt_get_mobile_a2dp_stream(uint32_t deviceId); int a2dp_ibrt_sync_set_status(ibrt_a2dp_status_t *a2dp_status); diff --git a/services/app_ibrt/inc/app_ibrt_custom_cmd.h b/services/app_ibrt/inc/app_ibrt_custom_cmd.h index 05a9403..34b0763 100644 --- a/services/app_ibrt/inc/app_ibrt_custom_cmd.h +++ b/services/app_ibrt/inc/app_ibrt_custom_cmd.h @@ -15,11 +15,12 @@ ****************************************************************************/ #ifndef __APP_IBRT_CUSTOM_CMD__ #define __APP_IBRT_CUSTOM_CMD__ +#include -#define APP_IBRT_CMD_BASE 0x8000 -#define APP_IBRT_CMD_MASK 0x0F00 -#define APP_IBRT_CUSTOM_CMD_PREFIX 0x0100 -#define APP_IBRT_OTA_CMD_PREFIX 0x0200 +#define APP_IBRT_CMD_BASE 0x8000 +#define APP_IBRT_CMD_MASK 0x0F00 +#define APP_IBRT_CUSTOM_CMD_PREFIX 0x0100 +#define APP_IBRT_OTA_CMD_PREFIX 0x0200 #define APP_IBRT_OTA_TWS_CMD_PREFIX 0x0300 int app_ibrt_customif_cmd_table_get(void **cmd_tbl, uint16_t *cmd_size); diff --git a/services/app_ibrt/inc/app_ibrt_hf.h b/services/app_ibrt/inc/app_ibrt_hf.h index bd8a3c1..db3b542 100644 --- a/services/app_ibrt/inc/app_ibrt_hf.h +++ b/services/app_ibrt/inc/app_ibrt_hf.h @@ -16,6 +16,8 @@ #ifndef __APP_IBRT_HF__ #define __APP_IBRT_HF__ +#include "app_tws_ibrt_cmd_sync_hfp_status.h" +#include "hfp_api.h" #ifdef __cplusplus extern "C" { #endif diff --git a/services/app_ibrt/inc/app_ibrt_peripheral_manager.h b/services/app_ibrt/inc/app_ibrt_peripheral_manager.h index 940c6c1..b559185 100644 --- a/services/app_ibrt/inc/app_ibrt_peripheral_manager.h +++ b/services/app_ibrt/inc/app_ibrt_peripheral_manager.h @@ -15,42 +15,43 @@ ****************************************************************************/ #ifndef __APP_IBRT_PERIPHERAL_MANAGER_H__ #define __APP_IBRT_PERIPHERAL_MANAGER_H__ +#include /************************* -* automate_cmd format -* item len(byte) -* group_code 1 -* opera_code 1 -* test_times 1 -* param_len 1 -* *param param_len(0-255) -*************************/ -#define AUTOMATE_TEST_CMD_CRC_RECORD_LEN (2) -#define AUTOMATE_TEST_CMD_PARAM_MAX_LEN (255) + * automate_cmd format + * item len(byte) + * group_code 1 + * opera_code 1 + * test_times 1 + * param_len 1 + * *param param_len(0-255) + *************************/ +#define AUTOMATE_TEST_CMD_CRC_RECORD_LEN (2) +#define AUTOMATE_TEST_CMD_PARAM_MAX_LEN (255) typedef struct { - uint8_t group_code; - uint8_t opera_code; - uint8_t test_times; - uint8_t param_len; - uint8_t param[0]; + uint8_t group_code; + uint8_t opera_code; + uint8_t test_times; + uint8_t param_len; + uint8_t param[0]; } AUTO_TEST_CMD_T; typedef struct { - uint32_t message_id; - uint32_t message_ptr; - uint32_t message_Param0; - uint32_t message_Param1; - uint32_t message_Param2; + uint32_t message_id; + uint32_t message_ptr; + uint32_t message_Param0; + uint32_t message_Param1; + uint32_t message_Param2; } TWS_PD_MSG_BODY; typedef struct { - TWS_PD_MSG_BODY msg_body; + TWS_PD_MSG_BODY msg_body; } TWS_PD_MSG_BLOCK; -int app_ibrt_peripheral_mailbox_put(TWS_PD_MSG_BLOCK* msg_src); -int app_ibrt_peripheral_mailbox_free(TWS_PD_MSG_BLOCK* msg_p); -int app_ibrt_peripheral_mailbox_get(TWS_PD_MSG_BLOCK** msg_p); +int app_ibrt_peripheral_mailbox_put(TWS_PD_MSG_BLOCK *msg_src); +int app_ibrt_peripheral_mailbox_free(TWS_PD_MSG_BLOCK *msg_p); +int app_ibrt_peripheral_mailbox_get(TWS_PD_MSG_BLOCK **msg_p); void app_ibrt_peripheral_thread_init(void); void app_ibrt_peripheral_run0(uint32_t ptr); void app_ibrt_peripheral_run1(uint32_t ptr, uint32_t param0); diff --git a/services/app_ibrt/inc/app_ibrt_ui_test.h b/services/app_ibrt/inc/app_ibrt_ui_test.h index cedf2fb..3feef52 100644 --- a/services/app_ibrt/inc/app_ibrt_ui_test.h +++ b/services/app_ibrt/inc/app_ibrt_ui_test.h @@ -15,19 +15,18 @@ ****************************************************************************/ #ifndef __APP_IBRT_UI_TEST_H__ #define __APP_IBRT_UI_TEST_H__ +#include "app_key.h" #include - #if defined(IBRT) typedef void (*app_uart_test_function_handle)(void); -typedef struct -{ - const char* string; - app_uart_test_function_handle function; +typedef struct { + const char *string; + app_uart_test_function_handle function; } app_uart_handle_t; -app_uart_test_function_handle app_ibrt_ui_find_uart_handle(unsigned char* buf); +app_uart_test_function_handle app_ibrt_ui_find_uart_handle(unsigned char *buf); void app_ibrt_ui_test_key_init(void); diff --git a/services/app_ibrt/inc/app_ibrt_voice_report.h b/services/app_ibrt/inc/app_ibrt_voice_report.h index c540b89..6b0051d 100644 --- a/services/app_ibrt/inc/app_ibrt_voice_report.h +++ b/services/app_ibrt/inc/app_ibrt_voice_report.h @@ -15,20 +15,19 @@ ****************************************************************************/ #ifndef __APP_IBRT_VOICE_REPORT_H__ #define __APP_IBRT_VOICE_REPORT_H__ +#include -typedef struct -{ - uint32_t aud_id; - uint32_t aud_pram; - uint32_t tg_tick; - uint32_t vol; +typedef struct { + uint32_t aud_id; + uint32_t aud_pram; + uint32_t tg_tick; + uint32_t vol; } __attribute__((packed)) app_ibrt_voice_report_info_t; -typedef struct -{ - uint32_t aud_id; - uint32_t aud_pram; - uint32_t vol; +typedef struct { + uint32_t aud_id; + uint32_t aud_pram; + uint32_t vol; } __attribute__((packed)) app_ibrt_voice_report_request_t; #ifdef __cplusplus @@ -39,9 +38,13 @@ int app_ibrt_voice_report_trigger_checker(void); int app_ibrt_voice_report_trigger_init(uint32_t aud_id, uint32_t aud_pram); int app_ibrt_voice_report_trigger_deinit(void); void app_ibrt_send_voice_report_request_req(uint8_t *p_buff, uint16_t length); -void app_ibrt_voice_report_request_req_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +void app_ibrt_voice_report_request_req_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); void app_ibrt_send_voice_report_start_req(uint8_t *p_buff, uint16_t length); -void app_ibrt_voice_report_request_start_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +void app_ibrt_voice_report_request_start_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); int app_ibrt_if_voice_report_handler(uint32_t aud_id, uint16_t aud_pram); bool app_ibrt_voice_report_is_me(uint32_t voice_chnlsel); diff --git a/services/app_ibrt/src/app_ibrt_auto_test.cpp b/services/app_ibrt/src/app_ibrt_auto_test.cpp index 71f761f..54abf0e 100644 --- a/services/app_ibrt/src/app_ibrt_auto_test.cpp +++ b/services/app_ibrt/src/app_ibrt_auto_test.cpp @@ -13,138 +13,144 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "app_tws_ibrt_trace.h" -#include "factory_section.h" -#include "hal_timer.h" -#include "apps.h" -#include "app_battery.h" -#include "app_anc.h" -#include "app_a2dp.h" -#include "app_key.h" #include "app_ibrt_auto_test.h" -#include "app_ibrt_if.h" -#include "app_ibrt_ui.h" -#include "app_ibrt_ui_test.h" -#include "app_ibrt_peripheral_manager.h" #include "a2dp_decoder.h" -#include "app_ibrt_keyboard.h" -#include "nvrecord_env.h" -#include "nvrecord_ble.h" -#include "app_tws_if.h" -#include "besbt.h" -#include "app_bt.h" +#include "app_a2dp.h" #include "app_ai_if.h" #include "app_ai_manager_api.h" -#include "app_bt_media_manager.h" +#include "app_anc.h" #include "app_audio.h" +#include "app_battery.h" #include "app_ble_mode_switch.h" +#include "app_bt.h" +#include "app_bt_media_manager.h" +#include "app_ibrt_if.h" +#include "app_ibrt_keyboard.h" +#include "app_ibrt_peripheral_manager.h" +#include "app_ibrt_ui.h" +#include "app_ibrt_ui_test.h" +#include "app_key.h" +#include "app_tws_ibrt_trace.h" +#include "app_tws_if.h" +#include "apps.h" +#include "besbt.h" +#include "factory_section.h" +#include "hal_timer.h" +#include "nvrecord_ble.h" +#include "nvrecord_env.h" +#include #if defined(IBRT) #include "btapp.h" -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; extern int hfp_volume_get(enum BT_DEVICE_ID_T id); int bt_sco_player_get_codetype(void); AUTO_TEST_STATE_T auto_test_state_t = {0}; - -uint16_t app_ibrt_auto_test_get_tws_page_timeout_value(void) -{ - return app_ibrt_ui_get_tws_page_timeout_value(); +uint16_t app_ibrt_auto_test_get_tws_page_timeout_value(void) { + return app_ibrt_ui_get_tws_page_timeout_value(); } #ifdef BES_AUTOMATE_TEST -void app_ibrt_auto_test_print_earphone_state(void const *n) -{ - app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); +void app_ibrt_auto_test_print_earphone_state(void const *n) { + app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - auto_test_state_t.head[0] = 0xE1; - auto_test_state_t.head[1] = 0x38; - auto_test_state_t.head[2] = 0x7C; - auto_test_state_t.length = sizeof(auto_test_state_t); + auto_test_state_t.head[0] = 0xE1; + auto_test_state_t.head[1] = 0x38; + auto_test_state_t.head[2] = 0x7C; + auto_test_state_t.length = sizeof(auto_test_state_t); - //a2dp & hfp state - auto_test_state_t.bt_stream_state.local_volume = app_bt_stream_local_volume_get(); - auto_test_state_t.bt_stream_state.a2dp_volume = a2dp_volume_get(BT_DEVICE_ID_1); - auto_test_state_t.bt_stream_state.hfp_volume = hfp_volume_get(BT_DEVICE_ID_1); - auto_test_state_t.bt_stream_state.a2dp_streamming = a2dp_is_music_ongoing(); - auto_test_state_t.bt_stream_state.a2dp_codec_type = app_bt_device.codec_type[BT_DEVICE_ID_1]; - auto_test_state_t.bt_stream_state.a2dp_sample_rate = app_bt_device.sample_rate[BT_DEVICE_ID_1]; - auto_test_state_t.bt_stream_state.a2dp_sample_bit = app_bt_device.sample_bit[BT_DEVICE_ID_1]; + // a2dp & hfp state + auto_test_state_t.bt_stream_state.local_volume = + app_bt_stream_local_volume_get(); + auto_test_state_t.bt_stream_state.a2dp_volume = + a2dp_volume_get(BT_DEVICE_ID_1); + auto_test_state_t.bt_stream_state.hfp_volume = hfp_volume_get(BT_DEVICE_ID_1); + auto_test_state_t.bt_stream_state.a2dp_streamming = a2dp_is_music_ongoing(); + auto_test_state_t.bt_stream_state.a2dp_codec_type = + app_bt_device.codec_type[BT_DEVICE_ID_1]; + auto_test_state_t.bt_stream_state.a2dp_sample_rate = + app_bt_device.sample_rate[BT_DEVICE_ID_1]; + auto_test_state_t.bt_stream_state.a2dp_sample_bit = + app_bt_device.sample_bit[BT_DEVICE_ID_1]; - auto_test_state_t.bt_stream_state.sco_streaming = is_sco_mode(); - auto_test_state_t.bt_stream_state.sco_codec_type = (uint8_t)bt_sco_player_get_codetype(); - app_ibrt_if_get_hfp_call_status((AppIbrtCallStatus *)&auto_test_state_t.bt_stream_state.call_status); + auto_test_state_t.bt_stream_state.sco_streaming = is_sco_mode(); + auto_test_state_t.bt_stream_state.sco_codec_type = + (uint8_t)bt_sco_player_get_codetype(); + app_ibrt_if_get_hfp_call_status( + (AppIbrtCallStatus *)&auto_test_state_t.bt_stream_state.call_status); - //media state - auto_test_state_t.bt_media_state.media_active = bt_media_get_media_active(BT_DEVICE_ID_1); - auto_test_state_t.bt_media_state.curr_active_media = bt_media_get_current_media(); - auto_test_state_t.bt_media_state.promt_exist = app_audio_list_playback_exist(); + // media state + auto_test_state_t.bt_media_state.media_active = + bt_media_get_media_active(BT_DEVICE_ID_1); + auto_test_state_t.bt_media_state.curr_active_media = + bt_media_get_current_media(); + auto_test_state_t.bt_media_state.promt_exist = + app_audio_list_playback_exist(); - // ui state - auto_test_state_t.ui_state.current_ms = TICKS_TO_MS(hal_sys_timer_get()); - auto_test_state_t.ui_state.cpu_freq = hal_sysfreq_get(); - auto_test_state_t.ui_state.super_state = p_ibrt_ui->super_state; - auto_test_state_t.ui_state.active_event = p_ibrt_ui->active_event; - auto_test_state_t.ui_state.ibrt_sm_running = p_ibrt_ui->ibrt_sm_running; - auto_test_state_t.ui_state.ui_state = p_ibrt_ui->box_state; + // ui state + auto_test_state_t.ui_state.current_ms = TICKS_TO_MS(hal_sys_timer_get()); + auto_test_state_t.ui_state.cpu_freq = hal_sysfreq_get(); + auto_test_state_t.ui_state.super_state = p_ibrt_ui->super_state; + auto_test_state_t.ui_state.active_event = p_ibrt_ui->active_event; + auto_test_state_t.ui_state.ibrt_sm_running = p_ibrt_ui->ibrt_sm_running; + auto_test_state_t.ui_state.ui_state = p_ibrt_ui->box_state; - if (IBRT_SLAVE != p_ibrt_ctrl->current_role) - { - auto_test_state_t.ui_state.mobile_link_bt_role = app_tws_ibrt_get_local_mobile_role(); - auto_test_state_t.ui_state.mobile_link_bt_mode = p_ibrt_ctrl->mobile_mode; - auto_test_state_t.ui_state.mobile_constate = p_ibrt_ctrl->mobile_constate; - //auto_test_state_t.ui_state.mobile_connect = app_tws_ibrt_mobile_link_connected(); - } - auto_test_state_t.ui_state.tws_role = p_ibrt_ctrl->current_role; - auto_test_state_t.ui_state.tws_link_bt_role = app_tws_ibrt_get_local_tws_role(); - auto_test_state_t.ui_state.tws_link_bt_mode = p_ibrt_ctrl->tws_mode; - auto_test_state_t.ui_state.tws_constate = p_ibrt_ctrl->tws_constate; - auto_test_state_t.ui_state.role_switch_state = - (p_ibrt_ctrl->slave_tws_switch_pending || - p_ibrt_ctrl->master_tws_switch_pending); + if (IBRT_SLAVE != p_ibrt_ctrl->current_role) { + auto_test_state_t.ui_state.mobile_link_bt_role = + app_tws_ibrt_get_local_mobile_role(); + auto_test_state_t.ui_state.mobile_link_bt_mode = p_ibrt_ctrl->mobile_mode; + auto_test_state_t.ui_state.mobile_constate = p_ibrt_ctrl->mobile_constate; + // auto_test_state_t.ui_state.mobile_connect = + // app_tws_ibrt_mobile_link_connected(); + } + auto_test_state_t.ui_state.tws_role = p_ibrt_ctrl->current_role; + auto_test_state_t.ui_state.tws_link_bt_role = + app_tws_ibrt_get_local_tws_role(); + auto_test_state_t.ui_state.tws_link_bt_mode = p_ibrt_ctrl->tws_mode; + auto_test_state_t.ui_state.tws_constate = p_ibrt_ctrl->tws_constate; + auto_test_state_t.ui_state.role_switch_state = + (p_ibrt_ctrl->slave_tws_switch_pending || + p_ibrt_ctrl->master_tws_switch_pending); #ifdef __IAG_BLE_INCLUDE__ - auto_test_state_t.ui_state.ble_state = app_ble_get_current_state(); - auto_test_state_t.ui_state.ble_operation = app_ble_get_current_operation(); - auto_test_state_t.ui_state.ble_connection_state = 0; - for (uint8_t i = 0; i < BLE_CONNECTION_MAX; i++) - { - if (app_ble_is_connection_on(i)) - { - auto_test_state_t.ui_state.ble_connection_state |= - (1 << i); - } + auto_test_state_t.ui_state.ble_state = app_ble_get_current_state(); + auto_test_state_t.ui_state.ble_operation = app_ble_get_current_operation(); + auto_test_state_t.ui_state.ble_connection_state = 0; + for (uint8_t i = 0; i < BLE_CONNECTION_MAX; i++) { + if (app_ble_is_connection_on(i)) { + auto_test_state_t.ui_state.ble_connection_state |= (1 << i); } + } #endif - //TRACE(1, "earphone len %d state :", auto_test_state_t.length); - DUMP8("%02x", (uint8_t *)&auto_test_state_t, auto_test_state_t.length); + // TRACE(1, "earphone len %d state :", auto_test_state_t.length); + DUMP8("%02x", (uint8_t *)&auto_test_state_t, auto_test_state_t.length); } #define APP_AUTO_TEST_PRINT_STATE_TIME_IN_MS 500 -osTimerDef (APP_AUTO_TEST_PRINT_STATE_TIMEOUT, app_ibrt_auto_test_print_earphone_state); -osTimerId app_auto_test_print_state_timeout_timer_id = NULL; +osTimerDef(APP_AUTO_TEST_PRINT_STATE_TIMEOUT, + app_ibrt_auto_test_print_earphone_state); +osTimerId app_auto_test_print_state_timeout_timer_id = NULL; #endif -void app_ibrt_auto_test_init(void) -{ +void app_ibrt_auto_test_init(void) { #ifdef BES_AUTOMATE_TEST - memset((uint8_t *)&auto_test_state_t, 0, sizeof(auto_test_state_t)); - if (app_auto_test_print_state_timeout_timer_id == NULL) - { - app_auto_test_print_state_timeout_timer_id = osTimerCreate(osTimer(APP_AUTO_TEST_PRINT_STATE_TIMEOUT), osTimerPeriodic, NULL); - osTimerStart(app_auto_test_print_state_timeout_timer_id, APP_AUTO_TEST_PRINT_STATE_TIME_IN_MS); - } + memset((uint8_t *)&auto_test_state_t, 0, sizeof(auto_test_state_t)); + if (app_auto_test_print_state_timeout_timer_id == NULL) { + app_auto_test_print_state_timeout_timer_id = osTimerCreate( + osTimer(APP_AUTO_TEST_PRINT_STATE_TIMEOUT), osTimerPeriodic, NULL); + osTimerStart(app_auto_test_print_state_timeout_timer_id, + APP_AUTO_TEST_PRINT_STATE_TIME_IN_MS); + } #endif } void app_ibrt_auto_test_inform_cmd_received(uint8_t group_code, - uint8_t operation_code) -{ - AUTO_TEST_TRACE(2, "AUTO_TEST_CMD received:%d:%d:", group_code, operation_code); + uint8_t operation_code) { + AUTO_TEST_TRACE(2, "AUTO_TEST_CMD received:%d:%d:", group_code, + operation_code); } #endif - diff --git a/services/app_ibrt/src/app_ibrt_auto_test_cmd_handle.cpp b/services/app_ibrt/src/app_ibrt_auto_test_cmd_handle.cpp index 63d12e9..23c044f 100644 --- a/services/app_ibrt/src/app_ibrt_auto_test_cmd_handle.cpp +++ b/services/app_ibrt/src/app_ibrt_auto_test_cmd_handle.cpp @@ -13,41 +13,41 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "app_tws_ibrt_trace.h" -#include "factory_section.h" -#include "apps.h" -#include "app_battery.h" -#include "app_anc.h" -#include "app_key.h" -#include "app_ibrt_if.h" -#include "app_ibrt_ui_test.h" -#include "app_ibrt_auto_test.h" #include "app_ibrt_auto_test_cmd_handle.h" -#include "app_ibrt_ui_test_cmd_if.h" -#include "app_ibrt_peripheral_manager.h" #include "a2dp_decoder.h" -#include "app_ibrt_keyboard.h" -#include "nvrecord_env.h" -#include "nvrecord_ble.h" -#include "norflash_api.h" -#include "app_tws_if.h" -#include "besbt.h" -#include "app_bt.h" #include "app_ai_if.h" #include "app_ai_manager_api.h" +#include "app_anc.h" +#include "app_battery.h" #include "app_ble_uart.h" +#include "app_bt.h" +#include "app_ibrt_auto_test.h" +#include "app_ibrt_if.h" +#include "app_ibrt_keyboard.h" +#include "app_ibrt_peripheral_manager.h" +#include "app_ibrt_ui_test.h" +#include "app_ibrt_ui_test_cmd_if.h" +#include "app_key.h" +#include "app_tws_ibrt_trace.h" +#include "app_tws_if.h" +#include "apps.h" +#include "besbt.h" +#include "factory_section.h" +#include "norflash_api.h" +#include "nvrecord_ble.h" +#include "nvrecord_env.h" +#include #if defined(BISTO_ENABLED) #include "gsound_custom_actions.h" -#include "gsound_custom_bt.h" #include "gsound_custom_ble.h" - +#include "gsound_custom_bt.h" + #endif #ifdef __IAG_BLE_INCLUDE__ #include "app.h" #include "app_ble_mode_switch.h" #endif - + #ifdef BES_OTA #include "ota_control.h" #endif @@ -70,10 +70,9 @@ Modification : Created function *****************************************************************************/ -void app_ibrt_ui_reboot_test(void) -{ - app_ibrt_peripheral_auto_test_stop(); - app_reset(); +void app_ibrt_ui_reboot_test(void) { + app_ibrt_peripheral_auto_test_stop(); + app_reset(); } /***************************************************************************** @@ -91,11 +90,10 @@ void app_ibrt_ui_reboot_test(void) Modification : Created function *****************************************************************************/ -void app_ibrt_ui_factory_reset_test(void) -{ - app_ibrt_peripheral_auto_test_stop(); - nv_record_rebuild(); - app_reset(); +void app_ibrt_ui_factory_reset_test(void) { + app_ibrt_peripheral_auto_test_stop(); + nv_record_rebuild(); + app_reset(); } /***************************************************************************** @@ -113,21 +111,17 @@ void app_ibrt_ui_factory_reset_test(void) Modification : Created function *****************************************************************************/ -void app_ibrt_ui_disconnect_tws(void) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - btif_remote_device_t *remdev = NULL; +void app_ibrt_ui_disconnect_tws(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + btif_remote_device_t *remdev = NULL; - if(app_tws_ibrt_tws_link_connected()) - { - remdev = btif_me_get_remote_device_by_handle(p_ibrt_ctrl->tws_conhandle); + if (app_tws_ibrt_tws_link_connected()) { + remdev = btif_me_get_remote_device_by_handle(p_ibrt_ctrl->tws_conhandle); - if (remdev != NULL) - { - app_tws_ibrt_disconnect_connection(remdev); - } + if (remdev != NULL) { + app_tws_ibrt_disconnect_connection(remdev); } - + } } /***************************************************************************** @@ -148,15 +142,13 @@ void app_ibrt_ui_disconnect_tws(void) *****************************************************************************/ static void app_ibrt_ui_auto_test_voice_promt_handle(uint8_t operation_code, - uint8_t *param, - uint8_t param_len) -{ - TRACE(2, "%s op_code 0x%x", __func__, operation_code); - switch (operation_code) - { - default: - break; - } + uint8_t *param, + uint8_t param_len) { + TRACE(2, "%s op_code 0x%x", __func__, operation_code); + switch (operation_code) { + default: + break; + } } /***************************************************************************** @@ -177,34 +169,32 @@ Modification : Created function *****************************************************************************/ static void app_ibrt_ui_auto_test_a2dp_handle(uint8_t operation_code, - uint8_t *param, - uint8_t param_len) -{ - TRACE(2, "%s op_code 0x%x", __func__, operation_code); + uint8_t *param, + uint8_t param_len) { + TRACE(2, "%s op_code 0x%x", __func__, operation_code); - switch (operation_code) - { - case A2DP_AUTO_TEST_AUDIO_PLAY: - app_ibrt_ui_audio_play_test(); - break; - case A2DP_AUTO_TEST_AUDIO_PAUSE: - app_ibrt_ui_audio_pause_test(); - break; - case A2DP_AUTO_TEST_AUDIO_FORWARD: - app_ibrt_ui_audio_forward_test(); - break; - case A2DP_AUTO_TEST_AUDIO_BACKWARD: - app_ibrt_ui_audio_backward_test(); - break; - case A2DP_AUTO_TEST_AVRCP_VOL_UP: - app_bt_volumeup(); - break; - case A2DP_AUTO_TEST_AVRCP_VOL_DOWN: - app_bt_volumedown(); - break; - default: - break; - } + switch (operation_code) { + case A2DP_AUTO_TEST_AUDIO_PLAY: + app_ibrt_ui_audio_play_test(); + break; + case A2DP_AUTO_TEST_AUDIO_PAUSE: + app_ibrt_ui_audio_pause_test(); + break; + case A2DP_AUTO_TEST_AUDIO_FORWARD: + app_ibrt_ui_audio_forward_test(); + break; + case A2DP_AUTO_TEST_AUDIO_BACKWARD: + app_ibrt_ui_audio_backward_test(); + break; + case A2DP_AUTO_TEST_AVRCP_VOL_UP: + app_bt_volumeup(); + break; + case A2DP_AUTO_TEST_AVRCP_VOL_DOWN: + app_bt_volumedown(); + break; + default: + break; + } } /***************************************************************************** @@ -225,37 +215,35 @@ Modification : Created function *****************************************************************************/ static void app_ibrt_ui_auto_test_hfp_handle(uint8_t operation_code, - uint8_t *param, - uint8_t param_len) -{ - TRACE(2, "%s op_code 0x%x", __func__, operation_code); + uint8_t *param, + uint8_t param_len) { + TRACE(2, "%s op_code 0x%x", __func__, operation_code); - switch (operation_code) - { - case HFP_AUTO_TEST_SCO_CREATE: - app_ibrt_ui_hfsco_create_test(); - break; - case HFP_AUTO_TEST_SCO_DISC: - app_ibrt_ui_hfsco_disc_test(); - break; - case HFP_AUTO_TEST_CALL_REDIAL: - app_ibrt_ui_call_redial_test(); - break; - case HFP_AUTO_TEST_CALL_ANSWER: - app_ibrt_ui_call_answer_test(); - break; - case HFP_AUTO_TEST_CALL_HANGUP: - app_ibrt_ui_call_hangup_test(); - break; - case HFP_AUTO_TEST_VOLUME_UP: - app_ibrt_ui_local_volume_up_test(); - break; - case HFP_AUTO_TEST_VOLUME_DOWN: - app_ibrt_ui_local_volume_down_test(); - break; - default: - break; - } + switch (operation_code) { + case HFP_AUTO_TEST_SCO_CREATE: + app_ibrt_ui_hfsco_create_test(); + break; + case HFP_AUTO_TEST_SCO_DISC: + app_ibrt_ui_hfsco_disc_test(); + break; + case HFP_AUTO_TEST_CALL_REDIAL: + app_ibrt_ui_call_redial_test(); + break; + case HFP_AUTO_TEST_CALL_ANSWER: + app_ibrt_ui_call_answer_test(); + break; + case HFP_AUTO_TEST_CALL_HANGUP: + app_ibrt_ui_call_hangup_test(); + break; + case HFP_AUTO_TEST_VOLUME_UP: + app_ibrt_ui_local_volume_up_test(); + break; + case HFP_AUTO_TEST_VOLUME_DOWN: + app_ibrt_ui_local_volume_down_test(); + break; + default: + break; + } } /***************************************************************************** Prototype : app_ibrt_ui_auto_test_ui_handle @@ -275,89 +263,87 @@ Modification : Created function *****************************************************************************/ static void app_ibrt_ui_auto_test_ui_handle(uint8_t operation_code, - uint8_t *param, - uint8_t param_len) -{ - TRACE(2, "%s op_code 0x%x", __func__, operation_code); + uint8_t *param, uint8_t param_len) { + TRACE(2, "%s op_code 0x%x", __func__, operation_code); - switch (operation_code) - { - case UI_AUTO_TEST_OPEN_BOX: - app_ibrt_ui_open_box_event_test(); - break; - case UI_AUTO_TEST_CLOSE_BOX: - app_ibrt_ui_close_box_event_test(); - break; - case UI_AUTO_TEST_FETCH_OUT_BOX: - app_ibrt_ui_fetch_out_box_event_test(); - break; - case UI_AUTO_TEST_PUT_IN_BOX: - app_ibrt_ui_put_in_box_event_test(); - break; - case UI_AUTO_TEST_WEAR_UP: - app_ibrt_ui_ware_up_event_test(); - break; - case UI_AUTO_TEST_WEAR_DOWN: - app_ibrt_ui_ware_down_event_test(); - break; - case UI_AUTO_TEST_ROLE_SWITCH: - app_tws_if_trigger_role_switch(); - break; - case UI_AUTO_TEST_PHONE_CONN_EVENT: - app_ibrt_ui_phone_connect_event_test(); - break; - case UI_AUTO_TEST_RECONN_EVENT: - app_ibrt_ui_reconnect_event_test(); - break; - case UI_AUTO_TEST_CONN_SECOND_MOBILE: - app_ibrt_ui_choice_connect_second_mobile(); - break; - case UI_AUTO_TEST_MOBILE_TWS_DISC: - app_ibrt_if_disconnect_mobile_tws_link(); - break; - case UI_AUTO_TEST_PAIRING_MODE: - app_ibrt_ui_pairing_mode_test(); - break; - case UI_AUTO_TEST_FREEMAN_MODE: - app_ibrt_ui_freeman_pairing_mode_test(); - break; - case UI_AUTO_TEST_SUSPEND_IBRT: - app_ibrt_ui_suspend_ibrt_test(); - break; - case UI_AUTO_TEST_RESUME_IBRT: - app_ibrt_ui_resume_ibrt_test(); - break; - case UI_AUTO_TEST_SHUT_DOWN: - app_ibrt_ui_shut_down_test(); - break; - case UI_AUTO_TEST_REBOOT: - app_ibrt_ui_reboot_test(); - break; - case UI_AUTO_TEST_FACTORY_RESET: - app_ibrt_ui_factory_reset_test(); - break; - case UI_AUTO_TEST_ASSERT: - app_ibrt_peripheral_auto_test_stop(); - ASSERT(false, "Force Panic!!!"); - break; - case UI_AUTO_TEST_CONNECT_MOBILE: - app_ibrt_if_choice_mobile_connect(0); - break; - case UI_AUTO_TEST_DISCONNECT_MOBILE: - app_tws_ibrt_disconnect_mobile(); - break; - case UI_AUTO_TEST_CONNECT_TWS: - app_tws_ibrt_create_tws_connection(app_ibrt_auto_test_get_tws_page_timeout_value()); - break; - case UI_AUTO_TEST_DISCONNECT_TWS: - app_ibrt_ui_disconnect_tws(); - break; - case UI_AUTO_TEST_ENABLE_TPORTS: - app_ibrt_enable_tports_test(); - break; - default: - break; - } + switch (operation_code) { + case UI_AUTO_TEST_OPEN_BOX: + app_ibrt_ui_open_box_event_test(); + break; + case UI_AUTO_TEST_CLOSE_BOX: + app_ibrt_ui_close_box_event_test(); + break; + case UI_AUTO_TEST_FETCH_OUT_BOX: + app_ibrt_ui_fetch_out_box_event_test(); + break; + case UI_AUTO_TEST_PUT_IN_BOX: + app_ibrt_ui_put_in_box_event_test(); + break; + case UI_AUTO_TEST_WEAR_UP: + app_ibrt_ui_ware_up_event_test(); + break; + case UI_AUTO_TEST_WEAR_DOWN: + app_ibrt_ui_ware_down_event_test(); + break; + case UI_AUTO_TEST_ROLE_SWITCH: + app_tws_if_trigger_role_switch(); + break; + case UI_AUTO_TEST_PHONE_CONN_EVENT: + app_ibrt_ui_phone_connect_event_test(); + break; + case UI_AUTO_TEST_RECONN_EVENT: + app_ibrt_ui_reconnect_event_test(); + break; + case UI_AUTO_TEST_CONN_SECOND_MOBILE: + app_ibrt_ui_choice_connect_second_mobile(); + break; + case UI_AUTO_TEST_MOBILE_TWS_DISC: + app_ibrt_if_disconnect_mobile_tws_link(); + break; + case UI_AUTO_TEST_PAIRING_MODE: + app_ibrt_ui_pairing_mode_test(); + break; + case UI_AUTO_TEST_FREEMAN_MODE: + app_ibrt_ui_freeman_pairing_mode_test(); + break; + case UI_AUTO_TEST_SUSPEND_IBRT: + app_ibrt_ui_suspend_ibrt_test(); + break; + case UI_AUTO_TEST_RESUME_IBRT: + app_ibrt_ui_resume_ibrt_test(); + break; + case UI_AUTO_TEST_SHUT_DOWN: + app_ibrt_ui_shut_down_test(); + break; + case UI_AUTO_TEST_REBOOT: + app_ibrt_ui_reboot_test(); + break; + case UI_AUTO_TEST_FACTORY_RESET: + app_ibrt_ui_factory_reset_test(); + break; + case UI_AUTO_TEST_ASSERT: + app_ibrt_peripheral_auto_test_stop(); + ASSERT(false, "Force Panic!!!"); + break; + case UI_AUTO_TEST_CONNECT_MOBILE: + app_ibrt_if_choice_mobile_connect(0); + break; + case UI_AUTO_TEST_DISCONNECT_MOBILE: + app_tws_ibrt_disconnect_mobile(); + break; + case UI_AUTO_TEST_CONNECT_TWS: + app_tws_ibrt_create_tws_connection( + app_ibrt_auto_test_get_tws_page_timeout_value()); + break; + case UI_AUTO_TEST_DISCONNECT_TWS: + app_ibrt_ui_disconnect_tws(); + break; + case UI_AUTO_TEST_ENABLE_TPORTS: + app_ibrt_enable_tports_test(); + break; + default: + break; + } } /***************************************************************************** @@ -375,12 +361,12 @@ Author : bestechnic Modification : Created function *****************************************************************************/ -void app_ibrt_ui_auto_test_ai_simulate_button_action(enum APP_KEY_EVENT_T eventCode) -{ - APP_KEY_STATUS keyEvent; - keyEvent.code = APP_KEY_CODE_GOOGLE; - keyEvent.event = eventCode; - app_ibrt_ui_test_voice_assistant_key(&keyEvent, NULL); +void app_ibrt_ui_auto_test_ai_simulate_button_action( + enum APP_KEY_EVENT_T eventCode) { + APP_KEY_STATUS keyEvent; + keyEvent.code = APP_KEY_CODE_GOOGLE; + keyEvent.event = eventCode; + app_ibrt_ui_test_voice_assistant_key(&keyEvent, NULL); } /***************************************************************************** @@ -398,22 +384,23 @@ Author : bestechnic Modification : Created function *****************************************************************************/ -void app_ibrt_ui_auto_test_ai_disconnect(void) -{ +void app_ibrt_ui_auto_test_ai_disconnect(void) { #ifdef __AI_VOICE__ - //if (app_ai_ble_is_connected() && AI_TRANSPORT_BLE != app_ai_get_transport_type()) - //{ - //app_ai_disconnect_ble(); - //} - //if (app_ai_spp_is_connected() && AI_TRANSPORT_SPP != app_ai_get_transport_type()) - //{ - //app_ai_spp_disconnlink(); - //} + // if (app_ai_ble_is_connected() && AI_TRANSPORT_BLE != + // app_ai_get_transport_type()) + //{ + // app_ai_disconnect_ble(); + //} + // if (app_ai_spp_is_connected() && AI_TRANSPORT_SPP != + // app_ai_get_transport_type()) + //{ + // app_ai_spp_disconnlink(); + //} #endif #ifdef BISTO_ENABLED - //gsound_custom_ble_disconnect_ble_link(); - //gsound_custom_bt_disconnect_all_channel(); + // gsound_custom_ble_disconnect_ble_link(); + // gsound_custom_bt_disconnect_all_channel(); #endif } @@ -435,37 +422,33 @@ Modification : Created function *****************************************************************************/ static void app_ibrt_ui_auto_test_ai_handle(uint8_t operation_code, - uint8_t *param, - uint8_t param_len) -{ - TRACE(2, "%s op_code 0x%x", __func__, operation_code); - switch (operation_code) - { - case AI_AUTO_TEST_PTT_BUTTON_ACTION: - app_ibrt_ui_auto_test_ai_simulate_button_action((enum APP_KEY_EVENT_T)*param); - break; - case AI_AUTO_TEST_DISCONNECT_AI: - app_ibrt_ui_auto_test_ai_disconnect(); - break; - default: - break; - } + uint8_t *param, uint8_t param_len) { + TRACE(2, "%s op_code 0x%x", __func__, operation_code); + switch (operation_code) { + case AI_AUTO_TEST_PTT_BUTTON_ACTION: + app_ibrt_ui_auto_test_ai_simulate_button_action((enum APP_KEY_EVENT_T) * + param); + break; + case AI_AUTO_TEST_DISCONNECT_AI: + app_ibrt_ui_auto_test_ai_disconnect(); + break; + default: + break; + } } -typedef struct -{ - uint8_t scanFilterPolicy; - uint16_t scanWindowInMs; - uint16_t scanIntervalInMs; +typedef struct { + uint8_t scanFilterPolicy; + uint16_t scanWindowInMs; + uint16_t scanIntervalInMs; } APP_IBRT_UI_AUTO_TEST_BLE_SCAN_PARAM_T; -typedef struct -{ - uint8_t conidx; - uint32_t min_interval_in_ms; - uint32_t max_interval_in_ms; - uint32_t supervision_timeout_in_ms; - uint8_t slaveLantency; +typedef struct { + uint8_t conidx; + uint32_t min_interval_in_ms; + uint32_t max_interval_in_ms; + uint32_t supervision_timeout_in_ms; + uint8_t slaveLantency; } APP_IBRT_UI_AUTO_TEST_BLE_UPDATED_CONN_PARAM_T; /***************************************************************************** @@ -486,72 +469,61 @@ Modification : Created function *****************************************************************************/ static void app_ibrt_ui_auto_test_ble_handle(uint8_t operation_code, - uint8_t *param, - uint8_t param_len) -{ - TRACE(2, "%s op_code 0x%x", __func__, operation_code); + uint8_t *param, + uint8_t param_len) { + TRACE(2, "%s op_code 0x%x", __func__, operation_code); #ifdef __IAG_BLE_INCLUDE__ - switch (operation_code) - { - case BLE_AUTO_TEST_START_ADV: - { - uint16_t advIntervalMs = *(uint16_t *)param; - app_ble_start_connectable_adv(advIntervalMs); - break; - } - case BLE_AUTO_TEST_STOP_ADV: - { - app_ble_stop_activities(); - break; - } - case BLE_AUTO_TEST_DISCONNECT: - { - app_ble_disconnect_all(); - break; - } - case BLE_AUTO_TEST_START_CONNECT: - { - // six bytes ble address as the parameter - app_ble_start_connect(param); - break; - } - case BLE_AUTO_TEST_STOP_CONNECT: - { - app_ble_stop_activities(); - break; - } - case BLE_AUTO_TEST_START_SCAN: - { - APP_IBRT_UI_AUTO_TEST_BLE_SCAN_PARAM_T* pScanParam = - (APP_IBRT_UI_AUTO_TEST_BLE_SCAN_PARAM_T *)param; - app_ble_start_scan((enum BLE_SCAN_FILTER_POLICY)(pScanParam->scanFilterPolicy), - pScanParam->scanWindowInMs, pScanParam->scanIntervalInMs); - break; - } - case BLE_AUTO_TEST_STOP_SCAN: - { - app_ble_stop_activities(); - break; - } - case BLE_AUTO_TEST_UPDATE_CONN_PARAM: - { - #ifdef __IAG_BLE_INCLUDE__ - APP_IBRT_UI_AUTO_TEST_BLE_UPDATED_CONN_PARAM_T* pConnParam - = (APP_IBRT_UI_AUTO_TEST_BLE_UPDATED_CONN_PARAM_T *)param; - if (app_ble_is_connection_on(pConnParam->conidx)) - { - l2cap_update_param(pConnParam->conidx, - pConnParam->min_interval_in_ms, - pConnParam->max_interval_in_ms, - pConnParam->supervision_timeout_in_ms, - pConnParam->slaveLantency); - } - #endif - break; - } - default: - break; + switch (operation_code) { + case BLE_AUTO_TEST_START_ADV: { + uint16_t advIntervalMs = *(uint16_t *)param; + app_ble_start_connectable_adv(advIntervalMs); + break; + } + case BLE_AUTO_TEST_STOP_ADV: { + app_ble_stop_activities(); + break; + } + case BLE_AUTO_TEST_DISCONNECT: { + app_ble_disconnect_all(); + break; + } + case BLE_AUTO_TEST_START_CONNECT: { + // six bytes ble address as the parameter + app_ble_start_connect(param); + break; + } + case BLE_AUTO_TEST_STOP_CONNECT: { + app_ble_stop_activities(); + break; + } + case BLE_AUTO_TEST_START_SCAN: { + APP_IBRT_UI_AUTO_TEST_BLE_SCAN_PARAM_T *pScanParam = + (APP_IBRT_UI_AUTO_TEST_BLE_SCAN_PARAM_T *)param; + app_ble_start_scan( + (enum BLE_SCAN_FILTER_POLICY)(pScanParam->scanFilterPolicy), + pScanParam->scanWindowInMs, pScanParam->scanIntervalInMs); + break; + } + case BLE_AUTO_TEST_STOP_SCAN: { + app_ble_stop_activities(); + break; + } + case BLE_AUTO_TEST_UPDATE_CONN_PARAM: { +#ifdef __IAG_BLE_INCLUDE__ + APP_IBRT_UI_AUTO_TEST_BLE_UPDATED_CONN_PARAM_T *pConnParam = + (APP_IBRT_UI_AUTO_TEST_BLE_UPDATED_CONN_PARAM_T *)param; + if (app_ble_is_connection_on(pConnParam->conidx)) { + l2cap_update_param(pConnParam->conidx, pConnParam->min_interval_in_ms, + pConnParam->max_interval_in_ms, + pConnParam->supervision_timeout_in_ms, + pConnParam->slaveLantency); } +#endif + break; + } + default: + break; + } #endif } /***************************************************************************** @@ -572,25 +544,22 @@ Modification : Created function *****************************************************************************/ static void app_ibrt_ui_auto_test_flash_handle(uint8_t operation_code, - uint8_t *param, - uint8_t param_len) -{ - TRACE(2, "%s op_code 0x%x", __func__, operation_code); - switch (operation_code) - { - case FLASH_AUTO_TEST_PROGRAM: - break; - case FLASH_AUTO_TEST_ERASE: - break; - case FLASH_AUTO_TEST_FLUSH_NV: - { - nv_record_flash_flush(); - norflash_flush_all_pending_op(); - break; - } - default: - break; - } + uint8_t *param, + uint8_t param_len) { + TRACE(2, "%s op_code 0x%x", __func__, operation_code); + switch (operation_code) { + case FLASH_AUTO_TEST_PROGRAM: + break; + case FLASH_AUTO_TEST_ERASE: + break; + case FLASH_AUTO_TEST_FLUSH_NV: { + nv_record_flash_flush(); + norflash_flush_all_pending_op(); + break; + } + default: + break; + } } /***************************************************************************** @@ -612,40 +581,37 @@ Modification : Created function *****************************************************************************/ extern "C" void app_ibrt_ui_automate_test_cmd_handler(uint8_t group_code, - uint8_t operation_code, - uint8_t *param, - uint8_t param_len) -{ - switch (group_code) - { - case AUTO_TEST_VOICE_PROMPT: - app_ibrt_ui_auto_test_voice_promt_handle(operation_code, param, param_len); - break; - case AUTO_TEST_A2DP: - app_ibrt_ui_auto_test_a2dp_handle(operation_code, param, param_len); - break; - case AUTO_TEST_HFP: - app_ibrt_ui_auto_test_hfp_handle(operation_code, param, param_len); - break; - case AUTO_TEST_UI: - app_ibrt_ui_auto_test_ui_handle(operation_code, param, param_len); - break; - case AUTO_TEST_AI: - app_ibrt_ui_auto_test_ai_handle(operation_code, param, param_len); - break; - case AUTO_TEST_BLE: - app_ibrt_ui_auto_test_ble_handle(operation_code, param, param_len); - break; - case AUTO_TEST_FLASH: - app_ibrt_ui_auto_test_flash_handle(operation_code, param, param_len); - break; - case AUTO_TEST_UNUSE: - break; - default: - break; - } + uint8_t operation_code, + uint8_t *param, + uint8_t param_len) { + switch (group_code) { + case AUTO_TEST_VOICE_PROMPT: + app_ibrt_ui_auto_test_voice_promt_handle(operation_code, param, param_len); + break; + case AUTO_TEST_A2DP: + app_ibrt_ui_auto_test_a2dp_handle(operation_code, param, param_len); + break; + case AUTO_TEST_HFP: + app_ibrt_ui_auto_test_hfp_handle(operation_code, param, param_len); + break; + case AUTO_TEST_UI: + app_ibrt_ui_auto_test_ui_handle(operation_code, param, param_len); + break; + case AUTO_TEST_AI: + app_ibrt_ui_auto_test_ai_handle(operation_code, param, param_len); + break; + case AUTO_TEST_BLE: + app_ibrt_ui_auto_test_ble_handle(operation_code, param, param_len); + break; + case AUTO_TEST_FLASH: + app_ibrt_ui_auto_test_flash_handle(operation_code, param, param_len); + break; + case AUTO_TEST_UNUSE: + break; + default: + break; + } } #endif #endif - diff --git a/services/app_ibrt/src/app_ibrt_ble_adv.cpp b/services/app_ibrt/src/app_ibrt_ble_adv.cpp index 46693d4..834f63a 100644 --- a/services/app_ibrt/src/app_ibrt_ble_adv.cpp +++ b/services/app_ibrt/src/app_ibrt_ble_adv.cpp @@ -1,45 +1,45 @@ #include "app_ibrt_ble_adv.h" +#include "app_tws_ibrt.h" +#include "cmsis_os.h" +#include "co_bt_defines.h" +#include "factory_section.h" #include "hal_trace.h" #include "me_api.h" -#include "cmsis_os.h" -#include "factory_section.h" -#include "co_bt_defines.h" -#include "app_tws_ibrt.h" SLAVE_BLE_MODE_T slaveBleMode; static app_ble_adv_para_data_t app_ble_adv_para_data_cfg; #define APP_IBRT_BLE_ADV_DATA_MAX_LEN (31) #define APP_IBRT_BLE_SCAN_RSP_DATA_MAX_LEN (31) -const char *g_slave_ble_state_str[] = -{ +const char *g_slave_ble_state_str[] = { "BLE_STATE_IDLE", "BLE_ADVERTISING", "BLE_STARTING_ADV", "BLE_STOPPING_ADV", }; - -const char *g_slave_ble_op_str[] = -{ + +const char *g_slave_ble_op_str[] = { "BLE_OP_IDLE", "BLE_START_ADV", "BLE_STOP_ADV", "BLE_STOPPING_ADV", }; -#define SET_SLAVE_BLE_STATE(newState) \ - do \ - { \ - TRACE(3,"[BLE][STATE]%s->%s at line %d", g_slave_ble_state_str[slaveBleMode.state], g_slave_ble_state_str[newState], __LINE__); \ - slaveBleMode.state = (newState); \ - } while (0); +#define SET_SLAVE_BLE_STATE(newState) \ + do { \ + TRACE(3, "[BLE][STATE]%s->%s at line %d", \ + g_slave_ble_state_str[slaveBleMode.state], \ + g_slave_ble_state_str[newState], __LINE__); \ + slaveBleMode.state = (newState); \ + } while (0); -#define SET_SLAVE_BLE_OP(newOp) \ - do \ - { \ - TRACE(3,"[BLE][OP]%s->%s at line %d", g_slave_ble_op_str[slaveBleMode.op], g_slave_ble_op_str[newOp], __LINE__); \ - slaveBleMode.op = (newOp); \ - } while (0); +#define SET_SLAVE_BLE_OP(newOp) \ + do { \ + TRACE(3, "[BLE][OP]%s->%s at line %d", \ + g_slave_ble_op_str[slaveBleMode.op], g_slave_ble_op_str[newOp], \ + __LINE__); \ + slaveBleMode.op = (newOp); \ + } while (0); /***************************************************************************** Prototype : app_slave_ble_cmd_complete_callback Description : stop ble adv @@ -55,24 +55,22 @@ const char *g_slave_ble_op_str[] = Modification : Created function *****************************************************************************/ -void app_ibrt_slave_ble_cmd_complete_callback(const void *para) -{ - slave_ble_cmd_comp_t *p_cmd_complete = (slave_ble_cmd_comp_t *)para; +void app_ibrt_slave_ble_cmd_complete_callback(const void *para) { + slave_ble_cmd_comp_t *p_cmd_complete = (slave_ble_cmd_comp_t *)para; - switch (p_cmd_complete->cmd_opcode) - { - case HCI_BLE_ADV_CMD_OPCODE: - if(!p_cmd_complete->param[0]) - app_ibrt_ble_switch_activities(); - else - { - TRACE(2,"%s error p_cmd_complete->param[0] %d", __func__, p_cmd_complete->param[0]); - SET_SLAVE_BLE_STATE(BLE_STATE_IDLE); - SET_SLAVE_BLE_OP(BLE_OP_IDLE); - } - default: - break; + switch (p_cmd_complete->cmd_opcode) { + case HCI_BLE_ADV_CMD_OPCODE: + if (!p_cmd_complete->param[0]) + app_ibrt_ble_switch_activities(); + else { + TRACE(2, "%s error p_cmd_complete->param[0] %d", __func__, + p_cmd_complete->param[0]); + SET_SLAVE_BLE_STATE(BLE_STATE_IDLE); + SET_SLAVE_BLE_OP(BLE_OP_IDLE); } + default: + break; + } } /***************************************************************************** @@ -90,34 +88,35 @@ void app_ibrt_slave_ble_cmd_complete_callback(const void *para) Modification : Created function *****************************************************************************/ -void app_ibrt_ble_adv_para_data_init(void) -{ - app_ble_adv_para_data_t *adv_para_cfg = &app_ble_adv_para_data_cfg; - - adv_para_cfg->adv_type = ADV_CONN_UNDIR; - adv_para_cfg->advInterval_Ms = APP_IBRT_BLE_ADV_INTERVAL; - adv_para_cfg->own_addr_type = ADDR_PUBLIC; - adv_para_cfg->peer_addr_type = ADDR_PUBLIC; - adv_para_cfg->adv_chanmap = ADV_ALL_CHNLS_EN; - adv_para_cfg->adv_filter_policy = ADV_ALLOW_SCAN_ANY_CON_ANY; - memset(adv_para_cfg->bd_addr.address, 0, BTIF_BD_ADDR_SIZE); +void app_ibrt_ble_adv_para_data_init(void) { + app_ble_adv_para_data_t *adv_para_cfg = &app_ble_adv_para_data_cfg; - const char* ble_name_in_nv = (const char*)factory_section_get_ble_name(); - uint32_t nameLen = strlen(ble_name_in_nv); - - ASSERT(APP_IBRT_BLE_ADV_DATA_MAX_LEN >= nameLen, "ble adv data exceed"); - - adv_para_cfg->adv_data_len = 0; - adv_para_cfg->adv_data[adv_para_cfg->adv_data_len++] = nameLen+1; - adv_para_cfg->adv_data[adv_para_cfg->adv_data_len++] = 0x08; - memcpy(&adv_para_cfg->adv_data[adv_para_cfg->adv_data_len], ble_name_in_nv, nameLen); - adv_para_cfg->adv_data_len += nameLen; - - adv_para_cfg->scan_rsp_data_len = 0; - memset(adv_para_cfg->scan_rsp_data,0,sizeof(adv_para_cfg->scan_rsp_data)); - - memset(&slaveBleMode, 0, sizeof(slaveBleMode)); - btif_me_register_cmd_complete_callback(HCI_CMD_COMPLETE_USER_BLE, app_ibrt_slave_ble_cmd_complete_callback); + adv_para_cfg->adv_type = ADV_CONN_UNDIR; + adv_para_cfg->advInterval_Ms = APP_IBRT_BLE_ADV_INTERVAL; + adv_para_cfg->own_addr_type = ADDR_PUBLIC; + adv_para_cfg->peer_addr_type = ADDR_PUBLIC; + adv_para_cfg->adv_chanmap = ADV_ALL_CHNLS_EN; + adv_para_cfg->adv_filter_policy = ADV_ALLOW_SCAN_ANY_CON_ANY; + memset(adv_para_cfg->bd_addr.address, 0, BTIF_BD_ADDR_SIZE); + + const char *ble_name_in_nv = (const char *)factory_section_get_ble_name(); + uint32_t nameLen = strlen(ble_name_in_nv); + + ASSERT(APP_IBRT_BLE_ADV_DATA_MAX_LEN >= nameLen, "ble adv data exceed"); + + adv_para_cfg->adv_data_len = 0; + adv_para_cfg->adv_data[adv_para_cfg->adv_data_len++] = nameLen + 1; + adv_para_cfg->adv_data[adv_para_cfg->adv_data_len++] = 0x08; + memcpy(&adv_para_cfg->adv_data[adv_para_cfg->adv_data_len], ble_name_in_nv, + nameLen); + adv_para_cfg->adv_data_len += nameLen; + + adv_para_cfg->scan_rsp_data_len = 0; + memset(adv_para_cfg->scan_rsp_data, 0, sizeof(adv_para_cfg->scan_rsp_data)); + + memset(&slaveBleMode, 0, sizeof(slaveBleMode)); + btif_me_register_cmd_complete_callback( + HCI_CMD_COMPLETE_USER_BLE, app_ibrt_slave_ble_cmd_complete_callback); } /***************************************************************************** @@ -135,19 +134,19 @@ void app_ibrt_ble_adv_para_data_init(void) Modification : Created function *****************************************************************************/ -void app_ibrt_ble_set_adv_para_handler(app_ble_adv_para_data_t *adv_para_cfg) -{ - btif_adv_para_struct_t adv_para; - adv_para.adv_type = adv_para_cfg->adv_type; - adv_para.interval_max = adv_para_cfg->advInterval_Ms * 8 / 5; - adv_para.interval_min = adv_para_cfg->advInterval_Ms * 8 / 5; - adv_para.own_addr_type = adv_para_cfg->own_addr_type; - adv_para.peer_addr_type = adv_para_cfg->peer_addr_type; - adv_para.adv_chanmap = adv_para_cfg->adv_chanmap; - adv_para.adv_filter_policy = adv_para_cfg->adv_filter_policy; - memcpy(adv_para.bd_addr.address, adv_para_cfg->bd_addr.address, BTIF_BD_ADDR_SIZE); - - btif_me_ble_set_adv_parameters(&adv_para); +void app_ibrt_ble_set_adv_para_handler(app_ble_adv_para_data_t *adv_para_cfg) { + btif_adv_para_struct_t adv_para; + adv_para.adv_type = adv_para_cfg->adv_type; + adv_para.interval_max = adv_para_cfg->advInterval_Ms * 8 / 5; + adv_para.interval_min = adv_para_cfg->advInterval_Ms * 8 / 5; + adv_para.own_addr_type = adv_para_cfg->own_addr_type; + adv_para.peer_addr_type = adv_para_cfg->peer_addr_type; + adv_para.adv_chanmap = adv_para_cfg->adv_chanmap; + adv_para.adv_filter_policy = adv_para_cfg->adv_filter_policy; + memcpy(adv_para.bd_addr.address, adv_para_cfg->bd_addr.address, + BTIF_BD_ADDR_SIZE); + + btif_me_ble_set_adv_parameters(&adv_para); } /***************************************************************************** Prototype : app_ibrt_ble_set_adv_data_handler @@ -164,10 +163,10 @@ void app_ibrt_ble_set_adv_para_handler(app_ble_adv_para_data_t *adv_para_cfg) Modification : Created function *****************************************************************************/ -void app_ibrt_ble_set_adv_data_handler(app_ble_adv_para_data_t *adv_data_cfg) -{ - btif_me_ble_set_adv_data(adv_data_cfg->adv_data_len, adv_data_cfg->adv_data); - btif_me_ble_set_scan_rsp_data(adv_data_cfg->scan_rsp_data_len, adv_data_cfg->scan_rsp_data); +void app_ibrt_ble_set_adv_data_handler(app_ble_adv_para_data_t *adv_data_cfg) { + btif_me_ble_set_adv_data(adv_data_cfg->adv_data_len, adv_data_cfg->adv_data); + btif_me_ble_set_scan_rsp_data(adv_data_cfg->scan_rsp_data_len, + adv_data_cfg->scan_rsp_data); } /***************************************************************************** Prototype : app_ibrt_ble_adv_start @@ -184,33 +183,31 @@ void app_ibrt_ble_set_adv_data_handler(app_ble_adv_para_data_t *adv_data_cfg) Modification : Created function *****************************************************************************/ -void app_ibrt_ble_adv_start(uint8_t adv_type, uint16_t advInterval) -{ - TRACE(2,"ble adv start with adv_type %d advIntervalms %dms", adv_type, advInterval); - app_ble_adv_para_data_cfg.adv_type = adv_type; - app_ble_adv_para_data_cfg.advInterval_Ms = advInterval; - - switch(slaveBleMode.state) - { - case BLE_ADVERTISING: - SET_SLAVE_BLE_STATE(BLE_STOPPING_ADV); - SET_SLAVE_BLE_OP(BLE_START_ADV); - btif_me_ble_set_adv_en(false); - break; - case BLE_STARTING_ADV: - case BLE_STOPPING_ADV: - SET_SLAVE_BLE_OP(BLE_START_ADV); - break; - case BLE_STATE_IDLE: - SET_SLAVE_BLE_STATE(BLE_STARTING_ADV); - app_ibrt_ble_set_adv_para_handler(&app_ble_adv_para_data_cfg); - app_ibrt_ble_set_adv_data_handler(&app_ble_adv_para_data_cfg); - btif_me_ble_set_adv_en(true); - break; - default: - break; - } +void app_ibrt_ble_adv_start(uint8_t adv_type, uint16_t advInterval) { + TRACE(2, "ble adv start with adv_type %d advIntervalms %dms", adv_type, + advInterval); + app_ble_adv_para_data_cfg.adv_type = adv_type; + app_ble_adv_para_data_cfg.advInterval_Ms = advInterval; + switch (slaveBleMode.state) { + case BLE_ADVERTISING: + SET_SLAVE_BLE_STATE(BLE_STOPPING_ADV); + SET_SLAVE_BLE_OP(BLE_START_ADV); + btif_me_ble_set_adv_en(false); + break; + case BLE_STARTING_ADV: + case BLE_STOPPING_ADV: + SET_SLAVE_BLE_OP(BLE_START_ADV); + break; + case BLE_STATE_IDLE: + SET_SLAVE_BLE_STATE(BLE_STARTING_ADV); + app_ibrt_ble_set_adv_para_handler(&app_ble_adv_para_data_cfg); + app_ibrt_ble_set_adv_data_handler(&app_ble_adv_para_data_cfg); + btif_me_ble_set_adv_en(true); + break; + default: + break; + } } /***************************************************************************** Prototype : app_ibrt_ble_adv_stop @@ -227,12 +224,11 @@ void app_ibrt_ble_adv_start(uint8_t adv_type, uint16_t advInterval) Modification : Created function *****************************************************************************/ -void app_ibrt_ble_adv_stop(void) -{ - TRACE(1,"%s",__func__); - SET_SLAVE_BLE_STATE(BLE_STOPPING_ADV); - SET_SLAVE_BLE_OP(BLE_STOP_ADV); - btif_me_ble_set_adv_en(false); +void app_ibrt_ble_adv_stop(void) { + TRACE(1, "%s", __func__); + SET_SLAVE_BLE_STATE(BLE_STOPPING_ADV); + SET_SLAVE_BLE_OP(BLE_STOP_ADV); + btif_me_ble_set_adv_en(false); } /***************************************************************************** Prototype : app_ibrt_ble_switch_activities @@ -249,35 +245,31 @@ void app_ibrt_ble_adv_stop(void) Modification : Created function *****************************************************************************/ -void app_ibrt_ble_switch_activities(void) -{ - switch(slaveBleMode.state) - { - case BLE_STARTING_ADV: - SET_SLAVE_BLE_STATE(BLE_ADVERTISING); - if(slaveBleMode.op == BLE_START_ADV) - { - SET_SLAVE_BLE_OP(BLE_OP_IDLE); - } - break; - case BLE_STOPPING_ADV: - SET_SLAVE_BLE_STATE(BLE_STATE_IDLE); - if(slaveBleMode.op == BLE_STOP_ADV) - { - SET_SLAVE_BLE_OP(BLE_OP_IDLE); - } - break; - default: - break; +void app_ibrt_ble_switch_activities(void) { + switch (slaveBleMode.state) { + case BLE_STARTING_ADV: + SET_SLAVE_BLE_STATE(BLE_ADVERTISING); + if (slaveBleMode.op == BLE_START_ADV) { + SET_SLAVE_BLE_OP(BLE_OP_IDLE); } - switch(slaveBleMode.op) - { - case BLE_START_ADV: - app_ibrt_ble_adv_start(ADV_CONN_UNDIR, app_ble_adv_para_data_cfg.advInterval_Ms); - break; - default: - break; + break; + case BLE_STOPPING_ADV: + SET_SLAVE_BLE_STATE(BLE_STATE_IDLE); + if (slaveBleMode.op == BLE_STOP_ADV) { + SET_SLAVE_BLE_OP(BLE_OP_IDLE); } + break; + default: + break; + } + switch (slaveBleMode.op) { + case BLE_START_ADV: + app_ibrt_ble_adv_start(ADV_CONN_UNDIR, + app_ble_adv_para_data_cfg.advInterval_Ms); + break; + default: + break; + } } /***************************************************************************** @@ -297,15 +289,14 @@ void app_ibrt_ble_switch_activities(void) *****************************************************************************/ void app_ibrt_ble_adv_data_config(uint8_t *advData, uint8_t advDataLen, - uint8_t *scanRspData, uint8_t scanRspDataLen) -{ - ASSERT(APP_IBRT_BLE_ADV_DATA_MAX_LEN >= advDataLen, "ble adv data len exceed"); - ASSERT(APP_IBRT_BLE_SCAN_RSP_DATA_MAX_LEN >= scanRspDataLen, "scan response data len exceed") - memcpy(app_ble_adv_para_data_cfg.adv_data, advData, advDataLen); - memcpy(app_ble_adv_para_data_cfg.scan_rsp_data, scanRspData, scanRspDataLen); - app_ble_adv_para_data_cfg.adv_data_len = advDataLen; - app_ble_adv_para_data_cfg.scan_rsp_data_len = scanRspDataLen; + uint8_t *scanRspData, + uint8_t scanRspDataLen) { + ASSERT(APP_IBRT_BLE_ADV_DATA_MAX_LEN >= advDataLen, + "ble adv data len exceed"); + ASSERT(APP_IBRT_BLE_SCAN_RSP_DATA_MAX_LEN >= scanRspDataLen, + "scan response data len exceed") + memcpy(app_ble_adv_para_data_cfg.adv_data, advData, advDataLen); + memcpy(app_ble_adv_para_data_cfg.scan_rsp_data, scanRspData, scanRspDataLen); + app_ble_adv_para_data_cfg.adv_data_len = advDataLen; + app_ble_adv_para_data_cfg.scan_rsp_data_len = scanRspDataLen; } - - - diff --git a/services/app_ibrt/src/app_ibrt_customif_cmd.cpp b/services/app_ibrt/src/app_ibrt_customif_cmd.cpp index 928b4ac..efdd57c 100644 --- a/services/app_ibrt/src/app_ibrt_customif_cmd.cpp +++ b/services/app_ibrt/src/app_ibrt_customif_cmd.cpp @@ -13,13 +13,13 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "string.h" -#include "app_tws_ibrt_trace.h" +#include "app_ibrt_customif_cmd.h" +#include "app_dip.h" #include "app_tws_ctrl_thread.h" #include "app_tws_ibrt_cmd_handler.h" -#include "app_ibrt_customif_cmd.h" +#include "app_tws_ibrt_trace.h" #include "app_tws_if.h" -#include "app_dip.h" +#include "string.h" #ifdef BISTO_ENABLED #include "gsound_custom.h" #endif @@ -30,229 +30,257 @@ #include "apps.h" #if defined(IBRT) /* -* custom cmd handler add here, this is just a example -*/ + * custom cmd handler add here, this is just a example + */ -#define app_ibrt_custom_cmd_rsp_timeout_handler_null (0) -#define app_ibrt_custom_cmd_rsp_handler_null (0) -#define app_ibrt_custom_cmd_rx_handler_null (0) +#define app_ibrt_custom_cmd_rsp_timeout_handler_null (0) +#define app_ibrt_custom_cmd_rsp_handler_null (0) +#define app_ibrt_custom_cmd_rx_handler_null (0) #ifdef BISTO_ENABLED static void app_ibrt_bisto_dip_sync(uint8_t *p_buff, uint16_t length); -static void app_ibrt_bisto_dip_sync_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +static void app_ibrt_bisto_dip_sync_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length); #endif #ifdef __DUAL_MIC_RECORDING__ -static void app_ibrt_customif_audio_send(uint8_t* p_buff, uint16_t length); -static void app_ibrt_customif_audio_send_done(uint16_t cmdcode, uint16_t rsp_seq, uint8_t *ptrParam, uint16_t paramLen); -static void app_ibrt_customif_audio_send_handler(uint16_t rsp_seq, uint8_t* p_buff, uint16_t length); +static void app_ibrt_customif_audio_send(uint8_t *p_buff, uint16_t length); +static void app_ibrt_customif_audio_send_done(uint16_t cmdcode, + uint16_t rsp_seq, + uint8_t *ptrParam, + uint16_t paramLen); +static void app_ibrt_customif_audio_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); #endif void app_ibrt_customif_test1_cmd_send(uint8_t *p_buff, uint16_t length); -static void app_ibrt_customif_test1_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +static void app_ibrt_customif_test1_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); static void app_ibrt_customif_test2_cmd_send(uint8_t *p_buff, uint16_t length); -static void app_ibrt_customif_test2_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_customif_test2_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_customif_test2_cmd_send_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_customif_test3_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +static void app_ibrt_customif_test2_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_customif_test2_cmd_send_rsp_timeout_handler( + uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +static void app_ibrt_customif_test2_cmd_send_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_customif_test3_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); -static void app_ibrt_customif_test4_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static const app_tws_cmd_instance_t g_ibrt_custom_cmd_handler_table[]= -{ +static void app_ibrt_customif_test4_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static const app_tws_cmd_instance_t g_ibrt_custom_cmd_handler_table[] = { #ifdef GFPS_ENABLED - { - APP_TWS_CMD_SHARE_FASTPAIR_INFO, "SHARE_FASTPAIR_INFO", - app_ibrt_share_fastpair_info, - app_ibrt_shared_fastpair_info_received_handler, 0, - app_ibrt_custom_cmd_rsp_timeout_handler_null, app_ibrt_custom_cmd_rsp_handler_null - }, + {APP_TWS_CMD_SHARE_FASTPAIR_INFO, "SHARE_FASTPAIR_INFO", + app_ibrt_share_fastpair_info, + app_ibrt_shared_fastpair_info_received_handler, 0, + app_ibrt_custom_cmd_rsp_timeout_handler_null, + app_ibrt_custom_cmd_rsp_handler_null}, #endif #ifdef BISTO_ENABLED - { - APP_TWS_CMD_BISTO_DIP_SYNC, "BISTO_DIP_SYNC", - app_ibrt_bisto_dip_sync, - app_ibrt_bisto_dip_sync_handler, 0, - app_ibrt_cmd_rsp_timeout_handler_null, app_ibrt_cmd_rsp_handler_null - }, + {APP_TWS_CMD_BISTO_DIP_SYNC, "BISTO_DIP_SYNC", app_ibrt_bisto_dip_sync, + app_ibrt_bisto_dip_sync_handler, 0, app_ibrt_cmd_rsp_timeout_handler_null, + app_ibrt_cmd_rsp_handler_null}, #endif #ifdef __DUAL_MIC_RECORDING__ { - APP_IBRT_CUSTOM_CMD_DMA_AUDIO, "TWS_CMD_DMA_AUDIO", + APP_IBRT_CUSTOM_CMD_DMA_AUDIO, + "TWS_CMD_DMA_AUDIO", app_ibrt_customif_audio_send, - app_ibrt_customif_audio_send_handler, 0, - app_ibrt_custom_cmd_rsp_timeout_handler_null, app_ibrt_custom_cmd_rsp_handler_null, + app_ibrt_customif_audio_send_handler, + 0, + app_ibrt_custom_cmd_rsp_timeout_handler_null, + app_ibrt_custom_cmd_rsp_handler_null, app_ibrt_customif_audio_send_done, }, #endif - { - APP_IBRT_CUSTOM_CMD_TEST1, "TWS_CMD_TEST1", - app_ibrt_customif_test1_cmd_send, - app_ibrt_customif_test1_cmd_send_handler, 0, - app_ibrt_custom_cmd_rsp_timeout_handler_null, app_ibrt_custom_cmd_rsp_handler_null - }, - { - APP_IBRT_CUSTOM_CMD_TEST2, "TWS_CMD_TEST2", - app_ibrt_customif_test2_cmd_send, - app_ibrt_customif_test2_cmd_send_handler, RSP_TIMEOUT_DEFAULT, - app_ibrt_customif_test2_cmd_send_rsp_timeout_handler, app_ibrt_customif_test2_cmd_send_rsp_handler - }, - { - APP_IBRT_CUSTOM_CMD_TEST3, "TWS_CMD_TEST3", - app_ibrt_customif_test3_cmd_send, - app_ibrt_customif_test3_cmd_send_handler, 0, - app_ibrt_custom_cmd_rsp_timeout_handler_null, app_ibrt_custom_cmd_rsp_handler_null - }, - { - APP_IBRT_CUSTOM_CMD_TEST4, "TWS_CMD_TEST4", - app_ibrt_customif_test4_cmd_send, - app_ibrt_customif_test4_cmd_send_handler, 0, - app_ibrt_custom_cmd_rsp_timeout_handler_null, app_ibrt_custom_cmd_rsp_handler_null - }, + {APP_IBRT_CUSTOM_CMD_TEST1, "TWS_CMD_TEST1", + app_ibrt_customif_test1_cmd_send, app_ibrt_customif_test1_cmd_send_handler, + 0, app_ibrt_custom_cmd_rsp_timeout_handler_null, + app_ibrt_custom_cmd_rsp_handler_null}, + {APP_IBRT_CUSTOM_CMD_TEST2, "TWS_CMD_TEST2", + app_ibrt_customif_test2_cmd_send, app_ibrt_customif_test2_cmd_send_handler, + RSP_TIMEOUT_DEFAULT, app_ibrt_customif_test2_cmd_send_rsp_timeout_handler, + app_ibrt_customif_test2_cmd_send_rsp_handler}, + {APP_IBRT_CUSTOM_CMD_TEST3, "TWS_CMD_TEST3", + app_ibrt_customif_test3_cmd_send, app_ibrt_customif_test3_cmd_send_handler, + 0, app_ibrt_custom_cmd_rsp_timeout_handler_null, + app_ibrt_custom_cmd_rsp_handler_null}, + {APP_IBRT_CUSTOM_CMD_TEST4, "TWS_CMD_TEST4", + app_ibrt_customif_test4_cmd_send, app_ibrt_customif_test4_cmd_send_handler, + 0, app_ibrt_custom_cmd_rsp_timeout_handler_null, + app_ibrt_custom_cmd_rsp_handler_null}, }; -int app_ibrt_customif_cmd_table_get(void **cmd_tbl, uint16_t *cmd_size) -{ - *cmd_tbl = (void *)&g_ibrt_custom_cmd_handler_table; - *cmd_size = ARRAY_SIZE(g_ibrt_custom_cmd_handler_table); - return 0; +int app_ibrt_customif_cmd_table_get(void **cmd_tbl, uint16_t *cmd_size) { + *cmd_tbl = (void *)&g_ibrt_custom_cmd_handler_table; + *cmd_size = ARRAY_SIZE(g_ibrt_custom_cmd_handler_table); + return 0; } - #ifdef BISTO_ENABLED -static void app_ibrt_bisto_dip_sync(uint8_t *p_buff, uint16_t length) -{ - app_ibrt_send_cmd_without_rsp(APP_TWS_CMD_BISTO_DIP_SYNC, p_buff, length); +static void app_ibrt_bisto_dip_sync(uint8_t *p_buff, uint16_t length) { + app_ibrt_send_cmd_without_rsp(APP_TWS_CMD_BISTO_DIP_SYNC, p_buff, length); } -static void app_ibrt_bisto_dip_sync_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - gsound_mobile_type_get_callback(*(MOBILE_CONN_TYPE_E *)p_buff); +static void app_ibrt_bisto_dip_sync_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + gsound_mobile_type_get_callback(*(MOBILE_CONN_TYPE_E *)p_buff); } #endif #ifdef __DUAL_MIC_RECORDING__ -static void app_ibrt_customif_audio_send(uint8_t* p_buff, uint16_t length) { - TRACE(1, "%s", __func__); - app_recording_send_data_to_master(); +static void app_ibrt_customif_audio_send(uint8_t *p_buff, uint16_t length) { + TRACE(1, "%s", __func__); + app_recording_send_data_to_master(); } -static void app_ibrt_customif_audio_send_handler(uint16_t rsp_seq, uint8_t* p_buff, uint16_t length) { - ai_function_handle(CALLBACK_STORE_SLAVE_DATA, (void*)p_buff, length); - //TRACE(1, "%s", __func__); +static void app_ibrt_customif_audio_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + ai_function_handle(CALLBACK_STORE_SLAVE_DATA, (void *)p_buff, length); + // TRACE(1, "%s", __func__); } -static void app_ibrt_customif_audio_send_done(uint16_t cmdcode, uint16_t rsp_seq, uint8_t* ptrParam, - uint16_t paramLen) { - TRACE(1, "%s", __func__); - app_recording_audio_send_done(); +static void app_ibrt_customif_audio_send_done(uint16_t cmdcode, + uint16_t rsp_seq, + uint8_t *ptrParam, + uint16_t paramLen) { + TRACE(1, "%s", __func__); + app_recording_audio_send_done(); } #endif -void app_ibrt_customif_cmd_test(ibrt_custom_cmd_test_t *cmd_test) -{ - tws_ctrl_send_cmd(APP_IBRT_CUSTOM_CMD_TEST1, (uint8_t*)cmd_test, sizeof(ibrt_custom_cmd_test_t)); - tws_ctrl_send_cmd(APP_IBRT_CUSTOM_CMD_TEST2, (uint8_t*)cmd_test, sizeof(ibrt_custom_cmd_test_t)); - tws_ctrl_send_cmd(APP_IBRT_CUSTOM_CMD_TEST3, (uint8_t*)cmd_test, sizeof(ibrt_custom_cmd_test_t)); +void app_ibrt_customif_cmd_test(ibrt_custom_cmd_test_t *cmd_test) { + tws_ctrl_send_cmd(APP_IBRT_CUSTOM_CMD_TEST1, (uint8_t *)cmd_test, + sizeof(ibrt_custom_cmd_test_t)); + tws_ctrl_send_cmd(APP_IBRT_CUSTOM_CMD_TEST2, (uint8_t *)cmd_test, + sizeof(ibrt_custom_cmd_test_t)); + tws_ctrl_send_cmd(APP_IBRT_CUSTOM_CMD_TEST3, (uint8_t *)cmd_test, + sizeof(ibrt_custom_cmd_test_t)); } -void app_ibrt_customif_test1_cmd_send(uint8_t *p_buff, uint16_t length) -{ - app_ibrt_send_cmd_without_rsp(APP_IBRT_CUSTOM_CMD_TEST1, p_buff, length); - TRACE(1,"%s", __func__); +void app_ibrt_customif_test1_cmd_send(uint8_t *p_buff, uint16_t length) { + app_ibrt_send_cmd_without_rsp(APP_IBRT_CUSTOM_CMD_TEST1, p_buff, length); + TRACE(1, "%s", __func__); } -static void app_ibrt_customif_test1_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - TRACE(1,"%s", __func__); - app_ibrt_search_ui_handle_key((APP_KEY_STATUS *)p_buff, NULL); +static void app_ibrt_customif_test1_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + TRACE(1, "%s", __func__); + app_ibrt_search_ui_handle_key((APP_KEY_STATUS *)p_buff, NULL); } -static void app_ibrt_customif_test2_cmd_send(uint8_t *p_buff, uint16_t length) -{ - TRACE(1,"%s", __func__); +static void app_ibrt_customif_test2_cmd_send(uint8_t *p_buff, uint16_t length) { + TRACE(1, "%s", __func__); } -static void app_ibrt_customif_test2_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - tws_ctrl_send_rsp(APP_IBRT_CUSTOM_CMD_TEST2, rsp_seq, NULL, 0); - TRACE(1,"%s", __func__); - +static void app_ibrt_customif_test2_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + tws_ctrl_send_rsp(APP_IBRT_CUSTOM_CMD_TEST2, rsp_seq, NULL, 0); + TRACE(1, "%s", __func__); } -static void app_ibrt_customif_test2_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - TRACE(1,"%s", __func__); - +static void app_ibrt_customif_test2_cmd_send_rsp_timeout_handler( + uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) { + TRACE(1, "%s", __func__); } -static void app_ibrt_customif_test2_cmd_send_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - TRACE(1,"%s", __func__); +static void app_ibrt_customif_test2_cmd_send_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + TRACE(1, "%s", __func__); } -void app_ibrt_customif_test3_cmd_send(uint8_t *p_buff, uint16_t length) -{ - app_ibrt_send_cmd_without_rsp(APP_IBRT_CUSTOM_CMD_TEST3, p_buff, length); - TRACE(1,"%s", __func__); +void app_ibrt_customif_test3_cmd_send(uint8_t *p_buff, uint16_t length) { + app_ibrt_send_cmd_without_rsp(APP_IBRT_CUSTOM_CMD_TEST3, p_buff, length); + TRACE(1, "%s", __func__); } extern void app_ibrt_ui_test_mtu_change_sync_notify(void); -static void app_ibrt_customif_test3_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - /*TRACE(3,"%s,latency_mode_is_open = %d", __func__,latency_mode_is_open); - if(*p_buff == latency_mode_is_open)return; - if(*p_buff == 0) - latency_mode_is_open = 1; - else if(*p_buff == 1) - latency_mode_is_open = 0; - app_ibrt_ui_test_mtu_change_sync_notify();*/ +static void app_ibrt_customif_test3_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + /*TRACE(3,"%s,latency_mode_is_open = %d", __func__,latency_mode_is_open); + if(*p_buff == latency_mode_is_open)return; + if(*p_buff == 0) + latency_mode_is_open = 1; + else if(*p_buff == 1) + latency_mode_is_open = 0; + app_ibrt_ui_test_mtu_change_sync_notify();*/ } -void app_ibrt_customif_test4_cmd_send(uint8_t *p_buff, uint16_t length) -{ - TRACE(3,"%s", __func__); - app_ibrt_send_cmd_without_rsp(APP_IBRT_CUSTOM_CMD_TEST4, p_buff, length); +void app_ibrt_customif_test4_cmd_send(uint8_t *p_buff, uint16_t length) { + TRACE(3, "%s", __func__); + app_ibrt_send_cmd_without_rsp(APP_IBRT_CUSTOM_CMD_TEST4, p_buff, length); } extern void app_ibrt_sync_volume_info(); -static void app_ibrt_customif_test4_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - TRACE(3,"!!!!app_ibrt_customif_test4_cmd_send_handler"); - app_ibrt_sync_volume_info(); +static void app_ibrt_customif_test4_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + TRACE(3, "!!!!app_ibrt_customif_test4_cmd_send_handler"); + app_ibrt_sync_volume_info(); } #ifdef CUSTOM_BITRATE //#include "product_config.h" #include "nvrecord_extension.h" -extern void a2dp_avdtpcodec_aac_user_configure(uint32_t bitrate,uint8_t user_configure); -extern void a2dp_avdtpcodec_sbc_user_configure(uint32_t bitpool,uint8_t user_configure); -extern void app_audio_dynamic_update_dest_packet_mtu(uint8_t codec_index, uint8_t packet_mtu, uint8_t user_configure); +extern void a2dp_avdtpcodec_aac_user_configure(uint32_t bitrate, + uint8_t user_configure); +extern void a2dp_avdtpcodec_sbc_user_configure(uint32_t bitpool, + uint8_t user_configure); +extern void app_audio_dynamic_update_dest_packet_mtu(uint8_t codec_index, + uint8_t packet_mtu, + uint8_t user_configure); -void app_ibrt_user_a2dp_info_sync_tws_share_cmd_send(uint8_t *p_buff, uint16_t length) -{ - tws_ctrl_send_cmd(APP_TWS_CMD_A2DP_CONFIG_SYNC, p_buff, length); +void app_ibrt_user_a2dp_info_sync_tws_share_cmd_send(uint8_t *p_buff, + uint16_t length) { + tws_ctrl_send_cmd(APP_TWS_CMD_A2DP_CONFIG_SYNC, p_buff, length); } -static void app_ibrt_user_a2dp_info_sync(uint8_t *p_buff, uint16_t length) -{ - if((app_tws_ibrt_mobile_link_connected())){ - app_ibrt_send_cmd_without_rsp(APP_TWS_CMD_A2DP_CONFIG_SYNC, p_buff, length); - } +static void app_ibrt_user_a2dp_info_sync(uint8_t *p_buff, uint16_t length) { + if ((app_tws_ibrt_mobile_link_connected())) { + app_ibrt_send_cmd_without_rsp(APP_TWS_CMD_A2DP_CONFIG_SYNC, p_buff, length); + } } -static void app_ibrt_user_a2dp_info_sync_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - ibrt_custome_codec_t *a2dp_user_config_ptr=(ibrt_custome_codec_t *)p_buff; - TRACE(4,"%s %d %d %d",__func__,a2dp_user_config_ptr->aac_bitrate,a2dp_user_config_ptr->sbc_bitpool,a2dp_user_config_ptr->audio_latentcy); - if((app_tws_ibrt_slave_ibrt_link_connected())){ - a2dp_avdtpcodec_sbc_user_configure(a2dp_user_config_ptr->sbc_bitpool, true); - a2dp_avdtpcodec_aac_user_configure(a2dp_user_config_ptr->aac_bitrate, true); - app_audio_dynamic_update_dest_packet_mtu(0, (a2dp_user_config_ptr->audio_latentcy-USER_CONFIG_AUDIO_LATENCY_ERROR)/3, true);//sbc - app_audio_dynamic_update_dest_packet_mtu(1, (a2dp_user_config_ptr->audio_latentcy-USER_CONFIG_AUDIO_LATENCY_ERROR)/23, true);//aac - uint32_t lock = nv_record_pre_write_operation(); - nv_record_get_extension_entry_ptr()->a2dp_user_info.aac_bitrate = a2dp_user_config_ptr->aac_bitrate; - nv_record_get_extension_entry_ptr()->a2dp_user_info.sbc_bitpool = a2dp_user_config_ptr->sbc_bitpool; - nv_record_get_extension_entry_ptr()->a2dp_user_info.audio_latentcy = a2dp_user_config_ptr->audio_latentcy; - nv_record_post_write_operation(lock); - nv_record_flash_flush(); - } +static void app_ibrt_user_a2dp_info_sync_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + ibrt_custome_codec_t *a2dp_user_config_ptr = (ibrt_custome_codec_t *)p_buff; + TRACE(4, "%s %d %d %d", __func__, a2dp_user_config_ptr->aac_bitrate, + a2dp_user_config_ptr->sbc_bitpool, + a2dp_user_config_ptr->audio_latentcy); + if ((app_tws_ibrt_slave_ibrt_link_connected())) { + a2dp_avdtpcodec_sbc_user_configure(a2dp_user_config_ptr->sbc_bitpool, true); + a2dp_avdtpcodec_aac_user_configure(a2dp_user_config_ptr->aac_bitrate, true); + app_audio_dynamic_update_dest_packet_mtu( + 0, + (a2dp_user_config_ptr->audio_latentcy - + USER_CONFIG_AUDIO_LATENCY_ERROR) / + 3, + true); // sbc + app_audio_dynamic_update_dest_packet_mtu( + 1, + (a2dp_user_config_ptr->audio_latentcy - + USER_CONFIG_AUDIO_LATENCY_ERROR) / + 23, + true); // aac + uint32_t lock = nv_record_pre_write_operation(); + nv_record_get_extension_entry_ptr()->a2dp_user_info.aac_bitrate = + a2dp_user_config_ptr->aac_bitrate; + nv_record_get_extension_entry_ptr()->a2dp_user_info.sbc_bitpool = + a2dp_user_config_ptr->sbc_bitpool; + nv_record_get_extension_entry_ptr()->a2dp_user_info.audio_latentcy = + a2dp_user_config_ptr->audio_latentcy; + nv_record_post_write_operation(lock); + nv_record_flash_flush(); + } } #endif #endif diff --git a/services/app_ibrt/src/app_ibrt_customif_ui.cpp b/services/app_ibrt/src/app_ibrt_customif_ui.cpp index 8a5ccf6..b1bf460 100644 --- a/services/app_ibrt/src/app_ibrt_customif_ui.cpp +++ b/services/app_ibrt/src/app_ibrt_customif_ui.cpp @@ -13,28 +13,28 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "cmsis_os.h" -#include -#include "apps.h" -#include "app_tws_ibrt_trace.h" -#include "app_ibrt_if.h" #include "app_ibrt_customif_ui.h" -#include "me_api.h" -#include "app_ibrt_ui.h" -#include "app_vendor_cmd_evt.h" -#include "besaud_api.h" -#include "app_battery.h" -#include "app_tws_ibrt_cmd_handler.h" -#include "app_tws_ctrl_thread.h" -#include "app_hfp.h" -#include "app_tws_if.h" -#include "app_bt_media_manager.h" -#include "app_spp.h" #include "anc_wnr.h" +#include "app_battery.h" +#include "app_bt.h" +#include "app_bt_media_manager.h" +#include "app_hfp.h" +#include "app_ibrt_customif_cmd.h" +#include "app_ibrt_if.h" +#include "app_ibrt_ui.h" +#include "app_spp.h" +#include "app_tws_ctrl_thread.h" +#include "app_tws_ibrt_cmd_handler.h" +#include "app_tws_ibrt_trace.h" +#include "app_tws_if.h" +#include "app_vendor_cmd_evt.h" +#include "apps.h" +#include "besaud_api.h" +#include "cmsis_os.h" +#include "me_api.h" #include "nvrecord.h" #include "nvrecord_extension.h" -#include "app_bt.h" -#include "app_ibrt_customif_cmd.h" +#include #ifdef MEDIA_PLAYER_SUPPORT #include "app_media_player.h" @@ -47,598 +47,523 @@ #ifdef ANC_APP extern "C" void app_anc_sync_status(void); #endif -void app_ibrt_customif_ui_vender_event_handler_ind(uint8_t evt_type, uint8_t *buffer, uint8_t length) -{ - uint8_t subcode = evt_type; - POSSIBLY_UNUSED ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); +void app_ibrt_customif_ui_vender_event_handler_ind(uint8_t evt_type, + uint8_t *buffer, + uint8_t length) { + uint8_t subcode = evt_type; + POSSIBLY_UNUSED ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - switch (subcode) - { - case HCI_DBG_SNIFFER_INIT_CMP_EVT_SUBCODE: - break; + switch (subcode) { + case HCI_DBG_SNIFFER_INIT_CMP_EVT_SUBCODE: + break; - case HCI_DBG_IBRT_CONNECTED_EVT_SUBCODE: - app_tws_if_ibrt_connected_handler(); - break; + case HCI_DBG_IBRT_CONNECTED_EVT_SUBCODE: + app_tws_if_ibrt_connected_handler(); + break; - case HCI_DBG_IBRT_DISCONNECTED_EVT_SUBCODE: - app_tws_if_ibrt_disconnected_handler(); - break; + case HCI_DBG_IBRT_DISCONNECTED_EVT_SUBCODE: + app_tws_if_ibrt_disconnected_handler(); + break; - case HCI_DBG_IBRT_SWITCH_COMPLETE_EVT_SUBCODE: + case HCI_DBG_IBRT_SWITCH_COMPLETE_EVT_SUBCODE: - /* - * New Master do some special action,such as update battery to phone, - * since TWS switch may lead to old TWS master update battery fail - */ + /* + * New Master do some special action,such as update battery to phone, + * since TWS switch may lead to old TWS master update battery fail + */ #if defined(SUPPORT_BATTERY_REPORT) || defined(SUPPORT_HF_INDICATORS) - if(p_ibrt_ctrl->current_role == IBRT_MASTER) - { - uint8_t battery_level; - TRACE(0,"New TWS master update battery report after tws switch"); - app_battery_get_info(NULL, &battery_level, NULL); - app_hfp_battery_report(battery_level); - } + if (p_ibrt_ctrl->current_role == IBRT_MASTER) { + uint8_t battery_level; + TRACE(0, "New TWS master update battery report after tws switch"); + app_battery_get_info(NULL, &battery_level, NULL); + app_hfp_battery_report(battery_level); + } #endif - app_tws_if_tws_role_switch_complete_handler(p_ibrt_ctrl->current_role); - break; + app_tws_if_tws_role_switch_complete_handler(p_ibrt_ctrl->current_role); + break; - case HCI_NOTIFY_CURRENT_ADDR_EVT_CODE: - break; + case HCI_NOTIFY_CURRENT_ADDR_EVT_CODE: + break; - case HCI_DBG_TRACE_WARNING_EVT_CODE: - break; + case HCI_DBG_TRACE_WARNING_EVT_CODE: + break; - case HCI_SCO_SNIFFER_STATUS_EVT_CODE: - break; + case HCI_SCO_SNIFFER_STATUS_EVT_CODE: + break; - case HCI_DBG_RX_SEQ_ERROR_EVT_SUBCODE: - break; + case HCI_DBG_RX_SEQ_ERROR_EVT_SUBCODE: + break; - case HCI_LL_MONITOR_EVT_CODE: - break; + case HCI_LL_MONITOR_EVT_CODE: + break; - case HCI_GET_TWS_SLAVE_MOBILE_RSSI_CODE: - break; + case HCI_GET_TWS_SLAVE_MOBILE_RSSI_CODE: + break; - default: - break; - } + default: + break; + } } extern void startonce_delay_event_Timer_(int ms); extern void startreconnectfail_delay_report(int ms); extern uint8_t once_event_case; -extern bool IsMobileLinkLossing; +extern bool IsMobileLinkLossing; extern bool IsTwsLinkdiscon; extern bool IsTwsLinkLossing; extern void app_ibrt_customif_test4_cmd_send(uint8_t *p_buff, uint16_t length); -void app_ibrt_customif_ui_global_handler_ind(ibrt_link_type_e link_type, uint8_t evt_type, uint8_t status) -{ - static ibrt_ctrl_t *p_ibrt_ctrl = app_ibrt_if_get_bt_ctrl_ctx(); - static app_ibrt_ui_t *p_ui_ctrl = app_ibrt_ui_get_ctx(); - TRACE(0,"%s,evt_type = %d,link_type = %d,status = %d",__func__,evt_type,link_type,status); - switch (evt_type) - { - case BTIF_BTEVENT_LINK_CONNECT_CNF:// An outgoing ACL connection is up - //fall through - if((!IsMobileLinkLossing) && (MOBILE_LINK == link_type) && (p_ui_ctrl->box_state != IBRT_IN_BOX_CLOSED) && ((status == BTIF_BEC_NO_ERROR)||(status == BTIF_BEC_PAGE_TIMEOUT))) - { - TRACE(3,"xqd log 1 -- reconnected mobile fail\n"); - //app_voice_report(APP_STATUS_INDICATION_BOTHSCAN,0); - startreconnectfail_delay_report(1200); - } - if((!IsTwsLinkLossing) && (TWS_LINK == link_type) && (p_ui_ctrl->box_state != IBRT_IN_BOX_CLOSED) && ((status == BTIF_BEC_NO_ERROR)||(status == BTIF_BEC_PAGE_TIMEOUT))) - { - TRACE(3,"xqd log 1 -- reconnected TWS fail\n"); - } - break; - case BTIF_BTEVENT_LINK_CONNECT_IND://An incoming ACL connection is up - if (MOBILE_LINK == link_type) - { - if (BTIF_BEC_NO_ERROR == status) - { - app_status_indication_set(APP_STATUS_INDICATION_CONNECTED); - app_tws_if_mobile_connected_handler(p_ibrt_ctrl->mobile_addr.address); - } - } - break; - case BTIF_BTEVENT_LINK_DISCONNECT: - if((MOBILE_LINK == link_type) && (p_ui_ctrl->box_state != IBRT_IN_BOX_CLOSED) && ((status == BTIF_BEC_CONNECTION_TIMEOUT)|| (status == BTIF_BEC_LOW_RESOURCES))) - { - TRACE(3,"xqd log 1 -- mobile linkloss\n"); - IsMobileLinkLossing = TRUE; - nv_record_flash_flush(); - } - if (!app_tws_ibrt_mobile_link_connected()) - { - app_ibrt_if_sniff_checker_reset(); - } - if (MOBILE_LINK == link_type) - { - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_VOICE, BT_DEVICE_ID_1, MAX_RECORD_NUM); - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_SBC, BT_DEVICE_ID_1, MAX_RECORD_NUM); - app_tws_if_mobile_disconnected_handler(p_ibrt_ctrl->mobile_addr.address); - } - if (TWS_LINK == link_type) - { +void app_ibrt_customif_ui_global_handler_ind(ibrt_link_type_e link_type, + uint8_t evt_type, uint8_t status) { + static ibrt_ctrl_t *p_ibrt_ctrl = app_ibrt_if_get_bt_ctrl_ctx(); + static app_ibrt_ui_t *p_ui_ctrl = app_ibrt_ui_get_ctx(); + TRACE(0, "%s,evt_type = %d,link_type = %d,status = %d", __func__, evt_type, + link_type, status); + switch (evt_type) { + case BTIF_BTEVENT_LINK_CONNECT_CNF: // An outgoing ACL connection is up + // fall through + if ((!IsMobileLinkLossing) && (MOBILE_LINK == link_type) && + (p_ui_ctrl->box_state != IBRT_IN_BOX_CLOSED) && + ((status == BTIF_BEC_NO_ERROR) || (status == BTIF_BEC_PAGE_TIMEOUT))) { + TRACE(3, "xqd log 1 -- reconnected mobile fail\n"); + // app_voice_report(APP_STATUS_INDICATION_BOTHSCAN,0); + startreconnectfail_delay_report(1200); + } + if ((!IsTwsLinkLossing) && (TWS_LINK == link_type) && + (p_ui_ctrl->box_state != IBRT_IN_BOX_CLOSED) && + ((status == BTIF_BEC_NO_ERROR) || (status == BTIF_BEC_PAGE_TIMEOUT))) { + TRACE(3, "xqd log 1 -- reconnected TWS fail\n"); + } + break; + case BTIF_BTEVENT_LINK_CONNECT_IND: // An incoming ACL connection is up + if (MOBILE_LINK == link_type) { + if (BTIF_BEC_NO_ERROR == status) { + app_status_indication_set(APP_STATUS_INDICATION_CONNECTED); + app_tws_if_mobile_connected_handler(p_ibrt_ctrl->mobile_addr.address); + } + } + break; + case BTIF_BTEVENT_LINK_DISCONNECT: + if ((MOBILE_LINK == link_type) && + (p_ui_ctrl->box_state != IBRT_IN_BOX_CLOSED) && + ((status == BTIF_BEC_CONNECTION_TIMEOUT) || + (status == BTIF_BEC_LOW_RESOURCES))) { + TRACE(3, "xqd log 1 -- mobile linkloss\n"); + IsMobileLinkLossing = TRUE; + nv_record_flash_flush(); + } + if (!app_tws_ibrt_mobile_link_connected()) { + app_ibrt_if_sniff_checker_reset(); + } + if (MOBILE_LINK == link_type) { + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_VOICE, + BT_DEVICE_ID_1, MAX_RECORD_NUM); + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_SBC, + BT_DEVICE_ID_1, MAX_RECORD_NUM); + app_tws_if_mobile_disconnected_handler(p_ibrt_ctrl->mobile_addr.address); + } + if (TWS_LINK == link_type) { #ifdef MEDIA_PLAYER_SUPPORT - app_tws_sync_prompt_manager_reset(); + app_tws_sync_prompt_manager_reset(); #endif - } + } - break; - case BTIF_STACK_LINK_DISCONNECT_COMPLETE: - // app_status_indication_set(APP_STATUS_INDICATION_DISCONNECTED); - if((MOBILE_LINK == link_type) && (p_ui_ctrl->box_state != IBRT_IN_BOX_CLOSED) && ((status == BTIF_BEC_USER_TERMINATED)||(status == BTIF_BEC_LOCAL_TERMINATED))){ - if((app_tws_ibrt_tws_link_connected()) && (p_ibrt_ctrl->current_role == IBRT_SLAVE)) - { - TRACE(0,"4TWS connected and This is Slave!!!"); - }/*else{ - once_event_case = 2; - startonce_delay_event_Timer_(1500); - }*/ - } - - if((MOBILE_LINK == link_type) && (p_ui_ctrl->box_state != IBRT_IN_BOX_CLOSED) && ((status == BTIF_BEC_CONNECTION_TIMEOUT)|| (status == BTIF_BEC_LOW_RESOURCES))) - { - TRACE(3,"xqd log 2 -- mobile linkloss\n"); - IsMobileLinkLossing = TRUE; - nv_record_flash_flush(); - if(p_ibrt_ctrl->current_role != IBRT_SLAVE){ - once_event_case = 4; - startonce_delay_event_Timer_(5000); - } - } - else if((TWS_LINK == link_type) && (p_ui_ctrl->box_state != IBRT_IN_BOX_CLOSED) && ((status == BTIF_BEC_CONNECTION_TIMEOUT)|| (status == BTIF_BEC_LOW_RESOURCES))) - { - TRACE(3,"xqd log 3 -- tws linkloss\n"); - IsTwsLinkLossing = true; - once_event_case = 4; - nv_record_flash_flush(); - startonce_delay_event_Timer_(10000); - TRACE(3,"MyLog: The TWS connection is lost, reset the indication!!!"); - if (!app_device_bt_is_connected() && !IsMobileLinkLossing) { - TRACE(3,"MyLog: The TWS connection is lost, reset the indication!!!"); - //app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); - } - } - break; + break; + case BTIF_STACK_LINK_DISCONNECT_COMPLETE: + // app_status_indication_set(APP_STATUS_INDICATION_DISCONNECTED); + if ((MOBILE_LINK == link_type) && + (p_ui_ctrl->box_state != IBRT_IN_BOX_CLOSED) && + ((status == BTIF_BEC_USER_TERMINATED) || + (status == BTIF_BEC_LOCAL_TERMINATED))) { + if ((app_tws_ibrt_tws_link_connected()) && + (p_ibrt_ctrl->current_role == IBRT_SLAVE)) { + TRACE(0, "4TWS connected and This is Slave!!!"); + } /*else{ + once_event_case = 2; + startonce_delay_event_Timer_(1500); + }*/ + } - case BTIF_BTEVENT_ROLE_CHANGE: - break; + if ((MOBILE_LINK == link_type) && + (p_ui_ctrl->box_state != IBRT_IN_BOX_CLOSED) && + ((status == BTIF_BEC_CONNECTION_TIMEOUT) || + (status == BTIF_BEC_LOW_RESOURCES))) { + TRACE(3, "xqd log 2 -- mobile linkloss\n"); + IsMobileLinkLossing = TRUE; + nv_record_flash_flush(); + if (p_ibrt_ctrl->current_role != IBRT_SLAVE) { + once_event_case = 4; + startonce_delay_event_Timer_(5000); + } + } else if ((TWS_LINK == link_type) && + (p_ui_ctrl->box_state != IBRT_IN_BOX_CLOSED) && + ((status == BTIF_BEC_CONNECTION_TIMEOUT) || + (status == BTIF_BEC_LOW_RESOURCES))) { + TRACE(3, "xqd log 3 -- tws linkloss\n"); + IsTwsLinkLossing = true; + once_event_case = 4; + nv_record_flash_flush(); + startonce_delay_event_Timer_(10000); + TRACE(3, "MyLog: The TWS connection is lost, reset the indication!!!"); + if (!app_device_bt_is_connected() && !IsMobileLinkLossing) { + TRACE(3, "MyLog: The TWS connection is lost, reset the indication!!!"); + // app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); + } + } + break; - case BTIF_BTEVENT_BES_AUD_CONNECTED: - { - //tws link callback when besaud connection complete - if(TWS_LINK == link_type){ - /*if((p_ibrt_ctrl->current_role == IBRT_MASTER)) - { - app_ibrt_customif_test4_cmd_send(&status,1); - }*/ - if(latency_mode_is_open) - app_ibrt_customif_test3_cmd_send(&latency_mode_is_open,1); - if(!IsTwsLinkdiscon){ - //startdelay_report_tone(1000,APP_STATUS_INDICATION_DUDU); - //app_status_indication_set(APP_STATUS_INDICATION_TWS_CONNECTED); - } - IsTwsLinkdiscon = false; - //app_voice_report(APP_STATUS_INDICATION_CONNECTED, 0); - } - if (BTIF_BEC_NO_ERROR == status) - { - TRACE(3,"tjmLOG----------------------TJM!!!!!current_role = 0x%x",p_ibrt_ctrl->current_role); + case BTIF_BTEVENT_ROLE_CHANGE: + break; + + case BTIF_BTEVENT_BES_AUD_CONNECTED: { + // tws link callback when besaud connection complete + if (TWS_LINK == link_type) { + /*if((p_ibrt_ctrl->current_role == IBRT_MASTER)) + { + app_ibrt_customif_test4_cmd_send(&status,1); + }*/ + if (latency_mode_is_open) + app_ibrt_customif_test3_cmd_send(&latency_mode_is_open, 1); + if (!IsTwsLinkdiscon) { + // startdelay_report_tone(1000,APP_STATUS_INDICATION_DUDU); + // app_status_indication_set(APP_STATUS_INDICATION_TWS_CONNECTED); + } + IsTwsLinkdiscon = false; + // app_voice_report(APP_STATUS_INDICATION_CONNECTED, 0); + } + if (BTIF_BEC_NO_ERROR == status) { + TRACE(3, "tjmLOG----------------------TJM!!!!!current_role = 0x%x", + p_ibrt_ctrl->current_role); #ifdef ANC_APP - app_anc_sync_status(); + app_anc_sync_status(); #endif #ifdef ANC_WNR_ENABLED - app_wnr_sync_state(); + app_wnr_sync_state(); #endif - if (p_ibrt_ctrl->current_role == IBRT_MASTER && - app_ibrt_ui_get_enter_pairing_mode()) - { + if (p_ibrt_ctrl->current_role == IBRT_MASTER && + app_ibrt_ui_get_enter_pairing_mode()) { #if defined(MEDIA_PLAYER_SUPPORT) - app_voice_report(APP_STATUS_INDICATION_CONNECTED, 0); + app_voice_report(APP_STATUS_INDICATION_CONNECTED, 0); #endif - app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); - } - else - { - app_status_indication_set(APP_STATUS_INDICATION_CONNECTED); - } + app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); + } else { + app_status_indication_set(APP_STATUS_INDICATION_CONNECTED); + } - app_tws_if_tws_connected_handler(); - } + app_tws_if_tws_connected_handler(); + } - } + } break; + + case BTIF_BTEVENT_BES_AUD_DISCONNECTED: + app_tws_if_tws_disconnected_handler(); + if (!app_poweroff_flag && !IsTwsLinkLossing && !IsMobileLinkLossing) { + TRACE(3, "xqd--log: TWS is disconnected and it isn't tws link lossed."); + } else { + IsTwsLinkdiscon = true; + } + break; + + case BTIF_BTEVENT_ENCRYPTION_CHANGE: + break; + + case BTIF_BTEVENT_MODE_CHANGE: + break; + + default: + break; + } +} +void app_ibrt_customif_open_box_complete_ind(void) {} +void app_ibrt_customif_close_box_complete_ind(void) {} +void app_ibrt_customif_fetch_out_complete_ind(void) {} +void app_ibrt_customif_put_in_complete_ind(void) {} +void app_ibrt_customif_wear_up_complete_ind(void) {} +void app_ibrt_customif_wear_down_complete_ind(void) {} +void app_ibrt_customif_ui_global_event_update(ibrt_event_type evt_type, + ibrt_ui_state_e old_state, + ibrt_ui_state_e new_state, + ibrt_action_e action, + ibrt_ui_error_e status) { + switch (new_state) { + case IBRT_UI_IDLE: + if (IBRT_UI_IDLE != old_state) { + // callback when UI event completed + switch (evt_type) { + case IBRT_OPEN_BOX_EVENT: + app_ibrt_customif_open_box_complete_ind(); break; - - case BTIF_BTEVENT_BES_AUD_DISCONNECTED: - app_tws_if_tws_disconnected_handler(); - if(!app_poweroff_flag && !IsTwsLinkLossing && !IsMobileLinkLossing) - { - TRACE(3,"xqd--log: TWS is disconnected and it isn't tws link lossed."); - }else{ - IsTwsLinkdiscon = true; - } - break; - - case BTIF_BTEVENT_ENCRYPTION_CHANGE: - break; - - case BTIF_BTEVENT_MODE_CHANGE: - break; - - default: - break; + case IBRT_FETCH_OUT_EVENT: + app_ibrt_customif_fetch_out_complete_ind(); + break; + case IBRT_PUT_IN_EVENT: + app_ibrt_customif_put_in_complete_ind(); + break; + case IBRT_CLOSE_BOX_EVENT: + app_ibrt_customif_close_box_complete_ind(); + break; + case IBRT_WEAR_UP_EVENT: + app_ibrt_customif_wear_up_complete_ind(); + break; + case IBRT_WEAR_DOWN_EVENT: + app_ibrt_customif_wear_down_complete_ind(); + break; + default: + break; + } } -} -void app_ibrt_customif_open_box_complete_ind(void) -{ + break; -} -void app_ibrt_customif_close_box_complete_ind(void) -{ + case IBRT_UI_IDLE_WAIT: + break; -} -void app_ibrt_customif_fetch_out_complete_ind(void) -{ + case IBRT_UI_W4_TWS_CONNECTION: + break; -} -void app_ibrt_customif_put_in_complete_ind(void) -{ + case IBRT_UI_W4_TWS_INFO_EXCHANGE_COMPLETE: + break; -} -void app_ibrt_customif_wear_up_complete_ind(void) -{ + case IBRT_UI_W4_TWS_BT_MSS_COMPLETE: + break; -} -void app_ibrt_customif_wear_down_complete_ind(void) -{ + case IBRT_UI_W4_SET_ENV_COMPLETE: + break; -} -void app_ibrt_customif_ui_global_event_update(ibrt_event_type evt_type, ibrt_ui_state_e old_state, \ - ibrt_ui_state_e new_state,ibrt_action_e action,\ - ibrt_ui_error_e status) -{ - switch (new_state) - { - case IBRT_UI_IDLE: - if (IBRT_UI_IDLE != old_state) - { - //callback when UI event completed - switch (evt_type) - { - case IBRT_OPEN_BOX_EVENT: - app_ibrt_customif_open_box_complete_ind(); - break; - case IBRT_FETCH_OUT_EVENT: - app_ibrt_customif_fetch_out_complete_ind(); - break; - case IBRT_PUT_IN_EVENT: - app_ibrt_customif_put_in_complete_ind(); - break; - case IBRT_CLOSE_BOX_EVENT: - app_ibrt_customif_close_box_complete_ind(); - break; - case IBRT_WEAR_UP_EVENT: - app_ibrt_customif_wear_up_complete_ind(); - break; - case IBRT_WEAR_DOWN_EVENT: - app_ibrt_customif_wear_down_complete_ind(); - break; - default: - break; - } - } - break; + case IBRT_UI_W4_MOBILE_CONNECTION: + break; - case IBRT_UI_IDLE_WAIT: - break; + case IBRT_UI_W4_MOBILE_MSS_COMPLETE: + break; - case IBRT_UI_W4_TWS_CONNECTION: - break; + case IBRT_UI_W4_MOBILE_ENTER_ACTIVE_MODE: + break; - case IBRT_UI_W4_TWS_INFO_EXCHANGE_COMPLETE: - break; + case IBRT_UI_W4_START_IBRT_COMPLETE: + break; - case IBRT_UI_W4_TWS_BT_MSS_COMPLETE: - break; + case IBRT_UI_W4_IBRT_DATA_EXCHANGE_COMPLETE: + break; - case IBRT_UI_W4_SET_ENV_COMPLETE: - break; + case IBRT_UI_W4_TWS_SWITCH_COMPLETE: + break; - case IBRT_UI_W4_MOBILE_CONNECTION: - break; + case IBRT_UI_W4_SM_STOP: + break; - case IBRT_UI_W4_MOBILE_MSS_COMPLETE: - break; - - case IBRT_UI_W4_MOBILE_ENTER_ACTIVE_MODE: - break; - - case IBRT_UI_W4_START_IBRT_COMPLETE: - break; - - case IBRT_UI_W4_IBRT_DATA_EXCHANGE_COMPLETE: - break; - - case IBRT_UI_W4_TWS_SWITCH_COMPLETE: - break; - - case IBRT_UI_W4_SM_STOP: - break; - - default: - break; - } + default: + break; + } } /* -* custom tws switch interface -* tws switch cmd send sucess, return true, else return false -*/ -bool app_ibrt_customif_ui_tws_switch(void) -{ - return app_ibrt_ui_tws_switch(); + * custom tws switch interface + * tws switch cmd send sucess, return true, else return false + */ +bool app_ibrt_customif_ui_tws_switch(void) { return app_ibrt_ui_tws_switch(); } + +/* + * custom tws switching check interface + * whether doing tws switch now, return true, else return false + */ +bool app_ibrt_customif_ui_is_tws_switching(void) { + return app_ibrt_ui_is_tws_switching(); } /* -* custom tws switching check interface -* whether doing tws switch now, return true, else return false -*/ -bool app_ibrt_customif_ui_is_tws_switching(void) -{ - return app_ibrt_ui_is_tws_switching(); -} + * custom reconfig bd_addr + */ +void app_ibrt_customif_ui_reconfig_bd_addr(bt_bdaddr_t local_addr, + bt_bdaddr_t peer_addr, + ibrt_role_e nv_role) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); -/* -* custom reconfig bd_addr -*/ -void app_ibrt_customif_ui_reconfig_bd_addr(bt_bdaddr_t local_addr, bt_bdaddr_t peer_addr, ibrt_role_e nv_role) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); + p_ibrt_ctrl->local_addr = local_addr; + p_ibrt_ctrl->peer_addr = peer_addr; + p_ibrt_ctrl->nv_role = nv_role; - p_ibrt_ctrl->local_addr = local_addr; - p_ibrt_ctrl->peer_addr = peer_addr; - p_ibrt_ctrl->nv_role = nv_role; - - if (!p_ibrt_ctrl->is_ibrt_search_ui) - { - if (IBRT_MASTER == p_ibrt_ctrl->nv_role) - { - p_ibrt_ctrl->peer_addr = local_addr; - btif_me_set_bt_address(p_ibrt_ctrl->local_addr.address); - } - else if (IBRT_SLAVE == p_ibrt_ctrl->nv_role) - { - p_ibrt_ctrl->local_addr = peer_addr; - btif_me_set_bt_address(p_ibrt_ctrl->local_addr.address); - } - else - { - ASSERT(0, "%s nv_role error", __func__); - } + if (!p_ibrt_ctrl->is_ibrt_search_ui) { + if (IBRT_MASTER == p_ibrt_ctrl->nv_role) { + p_ibrt_ctrl->peer_addr = local_addr; + btif_me_set_bt_address(p_ibrt_ctrl->local_addr.address); + } else if (IBRT_SLAVE == p_ibrt_ctrl->nv_role) { + p_ibrt_ctrl->local_addr = peer_addr; + btif_me_set_bt_address(p_ibrt_ctrl->local_addr.address); + } else { + ASSERT(0, "%s nv_role error", __func__); } - p_ibrt_ui->bonding_success = true; + } + p_ibrt_ui->bonding_success = true; } /*custom can block connect mobile if needed*/ -bool app_ibrt_customif_connect_mobile_needed_ind(void) -{ - return true; -} +bool app_ibrt_customif_connect_mobile_needed_ind(void) { return true; } -void app_ibrt_customif_mobile_connected_ind(bt_bdaddr_t * addr) -{ +void app_ibrt_customif_mobile_connected_ind(bt_bdaddr_t *addr) { #ifdef BLE_ENABLE - app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); + app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); #endif - app_ibrt_if_config_keeper_mobile_update(addr); + app_ibrt_if_config_keeper_mobile_update(addr); } -void app_ibrt_customif_ibrt_connected_ind(bt_bdaddr_t * addr) -{ - app_ibrt_if_config_keeper_mobile_update(addr); +void app_ibrt_customif_ibrt_connected_ind(bt_bdaddr_t *addr) { + app_ibrt_if_config_keeper_mobile_update(addr); } -void app_ibrt_customif_tws_connected_ind(bt_bdaddr_t * addr) -{ - app_ibrt_if_config_keeper_tws_update(addr); +void app_ibrt_customif_tws_connected_ind(bt_bdaddr_t *addr) { + app_ibrt_if_config_keeper_tws_update(addr); } -void app_ibrt_customif_profile_state_change_ind(uint32_t profile,uint8_t connected) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - TRACE(2,"custom if profle=%x state change to =%x",profile,connected); +void app_ibrt_customif_profile_state_change_ind(uint32_t profile, + uint8_t connected) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + TRACE(2, "custom if profle=%x state change to =%x", profile, connected); - switch (profile) - { - case BTIF_APP_A2DP_PROFILE_ID: - if (connected) - { - //TRACE(0,"cutomif A2DP profile connected"); - //ibrt slave - if (p_ibrt_ctrl->current_role == IBRT_SLAVE) - { - //TO DO - } - //ibrt master - else if (p_ibrt_ctrl->current_role == IBRT_MASTER) - { - //TO DO - } - //no tws connected - else - { - //TO DO - } - } - else - { - //TRACE(0,"cutomif A2DP profile disconnected"); - //ibrt slave - if (p_ibrt_ctrl->current_role == IBRT_SLAVE) - { - //TO DO - } - //ibrt master - else if (p_ibrt_ctrl->current_role == IBRT_MASTER) - { - //TO DO - } - //no tws connected - else - { - //TO DO - } - } - break; - - case BTIF_APP_AVRCP_PROFILE_ID: - if (connected) - { - //TRACE(0,"cutomif AVRCP profile connected"); - //ibrt slave - if (p_ibrt_ctrl->current_role == IBRT_SLAVE) - { - //TO DO - } - //ibrt master - else if (p_ibrt_ctrl->current_role == IBRT_MASTER) - { - //TO DO - } - //no tws connected - else - { - //TO DO - } - } - else - { - //TRACE(0,"cutomif AVRCP profile disconnected"); - //ibrt slave - if (p_ibrt_ctrl->current_role == IBRT_SLAVE) - { - //TO DO - } - //ibrt master - else if (p_ibrt_ctrl->current_role == IBRT_MASTER) - { - //TO DO - } - //no tws connected - else - { - //TO DO - } - } - break; - - case BTIF_APP_HFP_PROFILE_ID: - if (connected) - { - //TRACE(0,"cutomif HFP profile connected"); - //ibrt slave - if (p_ibrt_ctrl->current_role == IBRT_SLAVE) - { - //TO DO - } - //ibrt master - else if (p_ibrt_ctrl->current_role == IBRT_MASTER) - { - //TO DO - } - //no tws connected - else - { - //TO DO - } - } - else - { - //TRACE(0,"cutomif HFP profile disconnected"); - //ibrt slave - if (p_ibrt_ctrl->current_role == IBRT_SLAVE) - { - //TO DO - } - //ibrt master - else if (p_ibrt_ctrl->current_role == IBRT_MASTER) - { - //TO DO - } - //no tws connected - else - { - //TO DO - } - - } - break; - - case BTIF_APP_SPP_CLIENT_AI_VOICE_ID: - case BTIF_APP_SPP_SERVER_AI_VOICE_ID: - case BTIF_APP_SPP_SERVER_GREEN_ID: - case BTIF_APP_SPP_CLIENT_CCMP_ID: - case BTIF_APP_SPP_CLIENT_RED_ID: - case BTIF_APP_SPP_SERVER_RED_ID: - case BTIF_APP_SPP_SERVER_TOTA_ID: - case BTIF_APP_SPP_SERVER_GSOUND_CTL_ID: - case BTIF_APP_SPP_SERVER_GSOUND_AUD_ID: - case BTIF_APP_SPP_SERVER_BES_OTA_ID: - case BTIF_APP_SPP_SERVER_FP_RFCOMM_ID: - case BTIF_APP_SPP_SERVER_TOTA_GENERAL_ID: - if (connected) - { - //TRACE(0,"cutomif SPP profile connected"); - //ibrt slave - if (p_ibrt_ctrl->current_role == IBRT_SLAVE) - { - //TO DO - } - //ibrt master - else if (p_ibrt_ctrl->current_role == IBRT_MASTER) - { - //TO DO - } - //no tws connected - else - { - //TO DO - } - - } - else - { - //TRACE(0,"cutomif SPP profile disconnected"); - //ibrt slave - if (p_ibrt_ctrl->current_role == IBRT_SLAVE) - { - //TO DO - } - //ibrt master - else if (p_ibrt_ctrl->current_role == IBRT_MASTER) - { - //TO DO - } - //no tws connected - else - { - //TO DO - } - - } - break; - - default: - TRACE(1,"unknown profle=%x state change",profile); - break; + switch (profile) { + case BTIF_APP_A2DP_PROFILE_ID: + if (connected) { + // TRACE(0,"cutomif A2DP profile connected"); + // ibrt slave + if (p_ibrt_ctrl->current_role == IBRT_SLAVE) { + // TO DO + } + // ibrt master + else if (p_ibrt_ctrl->current_role == IBRT_MASTER) { + // TO DO + } + // no tws connected + else { + // TO DO + } + } else { + // TRACE(0,"cutomif A2DP profile disconnected"); + // ibrt slave + if (p_ibrt_ctrl->current_role == IBRT_SLAVE) { + // TO DO + } + // ibrt master + else if (p_ibrt_ctrl->current_role == IBRT_MASTER) { + // TO DO + } + // no tws connected + else { + // TO DO + } } + break; + case BTIF_APP_AVRCP_PROFILE_ID: + if (connected) { + // TRACE(0,"cutomif AVRCP profile connected"); + // ibrt slave + if (p_ibrt_ctrl->current_role == IBRT_SLAVE) { + // TO DO + } + // ibrt master + else if (p_ibrt_ctrl->current_role == IBRT_MASTER) { + // TO DO + } + // no tws connected + else { + // TO DO + } + } else { + // TRACE(0,"cutomif AVRCP profile disconnected"); + // ibrt slave + if (p_ibrt_ctrl->current_role == IBRT_SLAVE) { + // TO DO + } + // ibrt master + else if (p_ibrt_ctrl->current_role == IBRT_MASTER) { + // TO DO + } + // no tws connected + else { + // TO DO + } + } + break; + + case BTIF_APP_HFP_PROFILE_ID: + if (connected) { + // TRACE(0,"cutomif HFP profile connected"); + // ibrt slave + if (p_ibrt_ctrl->current_role == IBRT_SLAVE) { + // TO DO + } + // ibrt master + else if (p_ibrt_ctrl->current_role == IBRT_MASTER) { + // TO DO + } + // no tws connected + else { + // TO DO + } + } else { + // TRACE(0,"cutomif HFP profile disconnected"); + // ibrt slave + if (p_ibrt_ctrl->current_role == IBRT_SLAVE) { + // TO DO + } + // ibrt master + else if (p_ibrt_ctrl->current_role == IBRT_MASTER) { + // TO DO + } + // no tws connected + else { + // TO DO + } + } + break; + + case BTIF_APP_SPP_CLIENT_AI_VOICE_ID: + case BTIF_APP_SPP_SERVER_AI_VOICE_ID: + case BTIF_APP_SPP_SERVER_GREEN_ID: + case BTIF_APP_SPP_CLIENT_CCMP_ID: + case BTIF_APP_SPP_CLIENT_RED_ID: + case BTIF_APP_SPP_SERVER_RED_ID: + case BTIF_APP_SPP_SERVER_TOTA_ID: + case BTIF_APP_SPP_SERVER_GSOUND_CTL_ID: + case BTIF_APP_SPP_SERVER_GSOUND_AUD_ID: + case BTIF_APP_SPP_SERVER_BES_OTA_ID: + case BTIF_APP_SPP_SERVER_FP_RFCOMM_ID: + case BTIF_APP_SPP_SERVER_TOTA_GENERAL_ID: + if (connected) { + // TRACE(0,"cutomif SPP profile connected"); + // ibrt slave + if (p_ibrt_ctrl->current_role == IBRT_SLAVE) { + // TO DO + } + // ibrt master + else if (p_ibrt_ctrl->current_role == IBRT_MASTER) { + // TO DO + } + // no tws connected + else { + // TO DO + } + + } else { + // TRACE(0,"cutomif SPP profile disconnected"); + // ibrt slave + if (p_ibrt_ctrl->current_role == IBRT_SLAVE) { + // TO DO + } + // ibrt master + else if (p_ibrt_ctrl->current_role == IBRT_MASTER) { + // TO DO + } + // no tws connected + else { + // TO DO + } + } + break; + + default: + TRACE(1, "unknown profle=%x state change", profile); + break; + } } /******************************reconnectfail_delay_report_timer*********************************************************/ @@ -646,244 +571,266 @@ osTimerId reconnectfail_delay_reportid = NULL; void startreconnectfail_delay_report(int ms); void stopreconnectfail_delay_report(void); static void reconnectfail_delay_reportfun(const void *); -osTimerDef(defreconnectfail_delay_report,reconnectfail_delay_reportfun); -void reconnectfail_delay_reportinit(void) -{ - reconnectfail_delay_reportid = osTimerCreate(osTimer(defreconnectfail_delay_report),osTimerOnce,(void *)0); +osTimerDef(defreconnectfail_delay_report, reconnectfail_delay_reportfun); +void reconnectfail_delay_reportinit(void) { + reconnectfail_delay_reportid = osTimerCreate( + osTimer(defreconnectfail_delay_report), osTimerOnce, (void *)0); } -static void reconnectfail_delay_reportfun(const void *) -{ - static ibrt_ctrl_t *p_ibrt_ctrl = app_ibrt_if_get_bt_ctrl_ctx(); - TRACE(3,"\n\n!!!!!!enter %s\n\n",__func__); - if((p_ibrt_ctrl->access_mode == 0x3)&&(p_ibrt_ctrl->current_role != IBRT_SLAVE)){ - app_voice_report(APP_STATUS_INDICATION_BOTHSCAN,0); - app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); - } +static void reconnectfail_delay_reportfun(const void *) { + static ibrt_ctrl_t *p_ibrt_ctrl = app_ibrt_if_get_bt_ctrl_ctx(); + TRACE(3, "\n\n!!!!!!enter %s\n\n", __func__); + if ((p_ibrt_ctrl->access_mode == 0x3) && + (p_ibrt_ctrl->current_role != IBRT_SLAVE)) { + app_voice_report(APP_STATUS_INDICATION_BOTHSCAN, 0); + app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); + } } -void startreconnectfail_delay_report(int ms) -{ - TRACE(3,"\n\n !!!!!!!!!!start %s\n\n",__func__); - osTimerStart(reconnectfail_delay_reportid,ms); +void startreconnectfail_delay_report(int ms) { + TRACE(3, "\n\n !!!!!!!!!!start %s\n\n", __func__); + osTimerStart(reconnectfail_delay_reportid, ms); } -void stopreconnectfail_delay_report(void) -{ +void stopreconnectfail_delay_report(void) { - TRACE(3,"\n\n!!!!!!!!!! stop %s\n\n",__func__); - osTimerStop(reconnectfail_delay_reportid); + TRACE(3, "\n\n!!!!!!!!!! stop %s\n\n", __func__); + osTimerStop(reconnectfail_delay_reportid); } - - /********************************reconnectfail_delay_report_timer*******************************************************/ -void app_ibrt_customif_ui_pairing_set(trigger_pairing_mode_type_e trigger_type) -{ - TRACE(2,"%s: %d", __func__, __LINE__); +void app_ibrt_customif_ui_pairing_set( + trigger_pairing_mode_type_e trigger_type) { + TRACE(2, "%s: %d", __func__, __LINE__); } -void app_ibrt_customif_ui_pairing_clear(trigger_pairing_mode_type_e trigger_type) -{ - TRACE(2,"%s: %d", __func__, __LINE__); +void app_ibrt_customif_ui_pairing_clear( + trigger_pairing_mode_type_e trigger_type) { + TRACE(2, "%s: %d", __func__, __LINE__); } /* -* custom config main function -*/ + * custom config main function + */ -int app_ibrt_customif_ui_start(void) -{ - ibrt_ui_config_t config; +int app_ibrt_customif_ui_start(void) { + ibrt_ui_config_t config; - // zero init the config - memset(&config, 0, sizeof(ibrt_ui_config_t)); + // zero init the config + memset(&config, 0, sizeof(ibrt_ui_config_t)); - //freeman mode config, default should be false - config.freeman_enable = false; + // freeman mode config, default should be false + config.freeman_enable = false; - //dont do role switch with mobile when enter freeman mode - config.freeman_dont_role_switch = false; + // dont do role switch with mobile when enter freeman mode + config.freeman_dont_role_switch = false; - //tws earphone set the same addr, UI will be flexible, default should be true - config.tws_use_same_addr = true; + // tws earphone set the same addr, UI will be flexible, default should be true + config.tws_use_same_addr = true; - //ibrt slave will reconnect to mobile if tws connect failed, default should be true - config.slave_reconnect_enable = true; + // ibrt slave will reconnect to mobile if tws connect failed, default should + // be true + config.slave_reconnect_enable = true; - //do tws switch when wearup or weardown, must be true because MIC will be with IBRT master - config.wear_updown_tws_switch_enable = true; + // do tws switch when wearup or weardown, must be true because MIC will be + // with IBRT master + config.wear_updown_tws_switch_enable = true; - //pairing mode default value, default should be set false - config.enter_pairing_mode = false; + // pairing mode default value, default should be set false + config.enter_pairing_mode = false; - //following cases the reconnect will be fail for freeman, please set to true if you want to reconnect successful: - //1. freeman has link key but mobile deleted the link key - //2. freeman changed its bt address after reboot and use the new address to reconnect mobile - config.freeman_accept_mobile_new_pairing = false; + // following cases the reconnect will be fail for freeman, please set to true + // if you want to reconnect successful: + // 1. freeman has link key but mobile deleted the link key + // 2. freeman changed its bt address after reboot and use the new address to + // reconnect mobile + config.freeman_accept_mobile_new_pairing = false; - //for some proj no box key, default should be false; - config.enter_pairing_on_empty_mobile_addr = true; + // for some proj no box key, default should be false; + config.enter_pairing_on_empty_mobile_addr = true; - //for some proj no box key, default should be false - config.enter_pairing_on_reconnect_mobile_failed = true; + // for some proj no box key, default should be false + config.enter_pairing_on_reconnect_mobile_failed = true; - //when mobile has connected, enter_pairing_on_reconnect_mobile_failed will be cleared, default false - config.enter_pairing_on_reconnect_mobile_failed_once = false; + // when mobile has connected, enter_pairing_on_reconnect_mobile_failed will be + // cleared, default false + config.enter_pairing_on_reconnect_mobile_failed_once = false; - //for some proj no box key, default should be false - config.enter_pairing_on_mobile_disconnect = true; + // for some proj no box key, default should be false + config.enter_pairing_on_mobile_disconnect = true; - //for 08 error reconnect event, default must be true - config.disc_tws_before_reconnect_mobile = true; - config.wait_time_before_disc_tws = 3000; + // for 08 error reconnect event, default must be true + config.disc_tws_before_reconnect_mobile = true; + config.wait_time_before_disc_tws = 3000; - //do tws switch when RSII value change, default should be true - config.tws_switch_according_to_rssi_value = false; + // do tws switch when RSII value change, default should be true + config.tws_switch_according_to_rssi_value = false; - //disable tws switch, NOT recommended to open - config.disable_tws_switch = false; + // disable tws switch, NOT recommended to open + config.disable_tws_switch = false; - //disable tws switch, NOT recommended to open - config.disable_stop_ibrt = true; + // disable tws switch, NOT recommended to open + config.disable_stop_ibrt = true; - //exchange snoop info by BLE_box, special custom config, default should be false - config.snoop_via_ble_enable = false; - //controller basband monitor - config.lowlayer_monitor_enable = false; + // exchange snoop info by BLE_box, special custom config, default should be + // false + config.snoop_via_ble_enable = false; + // controller basband monitor + config.lowlayer_monitor_enable = false; - config.delay_exit_sniff = true; - config.delay_ms_exit_sniff = 3000; + config.delay_exit_sniff = true; + config.delay_ms_exit_sniff = 3000; - config.check_plugin_excute_closedbox_event = true; + config.check_plugin_excute_closedbox_event = true; - config.share_tws_info_done = false; + config.share_tws_info_done = false; - config.nv_slave_enter_pairing_on_mobile_disconnect = true; - config.nv_slave_enter_pairing_on_empty_mobile_addr = true; + config.nv_slave_enter_pairing_on_mobile_disconnect = true; + config.nv_slave_enter_pairing_on_empty_mobile_addr = true; - //only allow paired mobile device incoming when not in paring mode,default should be false - config.mobile_incoming_filter_unpaired = false; - //close box debounce time config - config.close_box_event_wait_response_timeout = IBRT_UI_CLOSE_BOX_EVENT_WAIT_RESPONSE_TIMEOUT; + // only allow paired mobile device incoming when not in paring mode,default + // should be false + config.mobile_incoming_filter_unpaired = false; + // close box debounce time config + config.close_box_event_wait_response_timeout = + IBRT_UI_CLOSE_BOX_EVENT_WAIT_RESPONSE_TIMEOUT; - //do tws switch when RSII value change, timer threshold - config.role_switch_timer_threshold = IBRT_UI_ROLE_SWITCH_TIME_THRESHOLD; + // do tws switch when RSII value change, timer threshold + config.role_switch_timer_threshold = IBRT_UI_ROLE_SWITCH_TIME_THRESHOLD; - //do tws switch when rssi value change over threshold - config.rssi_threshold = IBRT_UI_ROLE_SWITCH_THRESHOLD_WITH_RSSI; + // do tws switch when rssi value change over threshold + config.rssi_threshold = IBRT_UI_ROLE_SWITCH_THRESHOLD_WITH_RSSI; - //wait time before launch reconnect event - config.reconnect_mobile_wait_response_timeout = IBRT_UI_RECONNECT_MOBILE_WAIT_RESPONSE_TIMEOUT; + // wait time before launch reconnect event + config.reconnect_mobile_wait_response_timeout = + IBRT_UI_RECONNECT_MOBILE_WAIT_RESPONSE_TIMEOUT; - //reconnect event internal config wait timer when tws disconnect - config.reconnect_wait_ready_timeout = IBRT_UI_MOBILE_RECONNECT_WAIT_READY_TIMEOUT; - config.reconnect_mobile_wait_ready_timeout = IBRT_UI_MOBILE_RECONNECT_WAIT_READY_TIMEOUT; - config.reconnect_tws_wait_ready_timeout = IBRT_UI_TWS_RECONNECT_WAIT_READY_TIMEOUT; - config.reconnect_ibrt_wait_response_timeout = IBRT_UI_RECONNECT_IBRT_WAIT_RESPONSE_TIMEOUT; - config.nv_master_reconnect_tws_wait_response_timeout = IBRT_UI_NV_MASTER_RECONNECT_TWS_WAIT_RESPONSE_TIMEOUT; - config.nv_slave_reconnect_tws_wait_response_timeout = IBRT_UI_NV_SLAVE_RECONNECT_TWS_WAIT_RESPONSE_TIMEOUT; + // reconnect event internal config wait timer when tws disconnect + config.reconnect_wait_ready_timeout = + IBRT_UI_MOBILE_RECONNECT_WAIT_READY_TIMEOUT; + config.reconnect_mobile_wait_ready_timeout = + IBRT_UI_MOBILE_RECONNECT_WAIT_READY_TIMEOUT; + config.reconnect_tws_wait_ready_timeout = + IBRT_UI_TWS_RECONNECT_WAIT_READY_TIMEOUT; + config.reconnect_ibrt_wait_response_timeout = + IBRT_UI_RECONNECT_IBRT_WAIT_RESPONSE_TIMEOUT; + config.nv_master_reconnect_tws_wait_response_timeout = + IBRT_UI_NV_MASTER_RECONNECT_TWS_WAIT_RESPONSE_TIMEOUT; + config.nv_slave_reconnect_tws_wait_response_timeout = + IBRT_UI_NV_SLAVE_RECONNECT_TWS_WAIT_RESPONSE_TIMEOUT; - //pairing mode timeout config - config.disable_bt_scan_timeout = IBRT_UI_DISABLE_BT_SCAN_TIMEOUT; + // pairing mode timeout config + config.disable_bt_scan_timeout = IBRT_UI_DISABLE_BT_SCAN_TIMEOUT; - //open box reconnect mobile times config - config.open_reconnect_mobile_max_times = IBRT_UI_OPEN_RECONNECT_MOBILE_MAX_TIMES; + // open box reconnect mobile times config + config.open_reconnect_mobile_max_times = + IBRT_UI_OPEN_RECONNECT_MOBILE_MAX_TIMES; - //open box reconnect tws times config - config.open_reconnect_tws_max_times = IBRT_UI_OPEN_RECONNECT_TWS_MAX_TIMES; + // open box reconnect tws times config + config.open_reconnect_tws_max_times = IBRT_UI_OPEN_RECONNECT_TWS_MAX_TIMES; - //connection timeout reconnect mobile times config - config.reconnect_mobile_max_times = IBRT_UI_RECONNECT_MOBILE_MAX_TIMES; + // connection timeout reconnect mobile times config + config.reconnect_mobile_max_times = IBRT_UI_RECONNECT_MOBILE_MAX_TIMES; - //connection timeout reconnect tws times config - config.reconnect_tws_max_times = IBRT_UI_RECONNECT_TWS_MAX_TIMES; + // connection timeout reconnect tws times config + config.reconnect_tws_max_times = IBRT_UI_RECONNECT_TWS_MAX_TIMES; - //connection timeout reconnect ibrt times config - config.reconnect_ibrt_max_times = IBRT_UI_RECONNECT_IBRT_MAX_TIMES; + // connection timeout reconnect ibrt times config + config.reconnect_ibrt_max_times = IBRT_UI_RECONNECT_IBRT_MAX_TIMES; - //reconnect tws one cycle - config.tws_reconnect_cycle = IBRT_TWS_RECONNECT_ONE_CYCLE; + // reconnect tws one cycle + config.tws_reconnect_cycle = IBRT_TWS_RECONNECT_ONE_CYCLE; - //reconnect mobile one cycle - config.mobile_reconnect_cycle = IBRT_MOBILE_RECONNECT_ONE_CYCLE; + // reconnect mobile one cycle + config.mobile_reconnect_cycle = IBRT_MOBILE_RECONNECT_ONE_CYCLE; - //BES internal config, DO NOT modify - config.long_private_poll_interval = IBRT_UI_LONG_POLL_INTERVAL; - config.default_private_poll_interval = IBRT_UI_DEFAULT_POLL_INTERVAL; - config.short_private_poll_interval = IBRT_UI_SHORT_POLL_INTERVAL; - config.default_private_poll_interval_in_sco = IBRT_UI_DEFAULT_POLL_INTERVAL_IN_SCO; - config.short_private_poll_interval_in_sco = IBRT_UI_SHORT_POLL_INTERVAL_IN_SCO; - config.default_bt_tpoll = IBRT_TWS_BT_TPOLL_DEFAULT; + // BES internal config, DO NOT modify + config.long_private_poll_interval = IBRT_UI_LONG_POLL_INTERVAL; + config.default_private_poll_interval = IBRT_UI_DEFAULT_POLL_INTERVAL; + config.short_private_poll_interval = IBRT_UI_SHORT_POLL_INTERVAL; + config.default_private_poll_interval_in_sco = + IBRT_UI_DEFAULT_POLL_INTERVAL_IN_SCO; + config.short_private_poll_interval_in_sco = + IBRT_UI_SHORT_POLL_INTERVAL_IN_SCO; + config.default_bt_tpoll = IBRT_TWS_BT_TPOLL_DEFAULT; - //for fast connect when only one headset in the nearby - config.tws_page_timeout_on_last_success = IBRT_TWS_PAGE_TIMEOUT_ON_CONNECT_SUCCESS_LAST; - config.tws_page_timeout_on_last_failed = IBRT_TWS_PAGE_TIMEOUT_ON_CONNECT_FAILED_LAST; - config.mobile_page_timeout = IBRT_MOBILE_PAGE_TIMEOUT; - config.tws_page_timeout_on_reconnect_mobile_failed = IBRT_TWS_PAGE_TIMEOUT_ON_RECONNECT_MOBILE_FAILED; - config.tws_page_timeout_on_reconnect_mobile_success = IBRT_TWS_PAGE_TIMEOUT_ON_RECONNECT_MOBILE_SUCCESS; + // for fast connect when only one headset in the nearby + config.tws_page_timeout_on_last_success = + IBRT_TWS_PAGE_TIMEOUT_ON_CONNECT_SUCCESS_LAST; + config.tws_page_timeout_on_last_failed = + IBRT_TWS_PAGE_TIMEOUT_ON_CONNECT_FAILED_LAST; + config.mobile_page_timeout = IBRT_MOBILE_PAGE_TIMEOUT; + config.tws_page_timeout_on_reconnect_mobile_failed = + IBRT_TWS_PAGE_TIMEOUT_ON_RECONNECT_MOBILE_FAILED; + config.tws_page_timeout_on_reconnect_mobile_success = + IBRT_TWS_PAGE_TIMEOUT_ON_RECONNECT_MOBILE_SUCCESS; - //tws connection timeout - config.tws_connection_timeout = IBRT_UI_TWS_CONNECTION_TIMEOUT; + // tws connection timeout + config.tws_connection_timeout = IBRT_UI_TWS_CONNECTION_TIMEOUT; - config.rx_seq_error_timeout = IBRT_UI_RX_SEQ_ERROR_TIMEOUT; - config.rx_seq_error_threshold = IBRT_UI_RX_SEQ_ERROR_THRESHOLD; - config.rx_seq_recover_wait_timeout = IBRT_UI_RX_SEQ_ERROR_RECOVER_TIMEOUT; + config.rx_seq_error_timeout = IBRT_UI_RX_SEQ_ERROR_TIMEOUT; + config.rx_seq_error_threshold = IBRT_UI_RX_SEQ_ERROR_THRESHOLD; + config.rx_seq_recover_wait_timeout = IBRT_UI_RX_SEQ_ERROR_RECOVER_TIMEOUT; - config.rssi_monitor_timeout = IBRT_UI_RSSI_MONITOR_TIMEOUT; + config.rssi_monitor_timeout = IBRT_UI_RSSI_MONITOR_TIMEOUT; + config.wear_updown_detect_supported = false; + config.stop_ibrt_timeout = IBRT_UI_STOP_IBRT_TIMEOUT; - config.wear_updown_detect_supported = false; - config.stop_ibrt_timeout = IBRT_UI_STOP_IBRT_TIMEOUT; + config.radical_scan_interval_nv_slave = IBRT_UI_RADICAL_SAN_INTERVAL_NV_SLAVE; + config.radical_scan_interval_nv_master = + IBRT_UI_RADICAL_SAN_INTERVAL_NV_MASTER; + config.event_hung_timeout = IBRT_EVENT_HUNG_TIMEOUT; + config.rssi_tws_switch_threshold = IBRT_TWS_SWITCH_RSSI_THRESHOLD; + config.stop_ibrt_wait_time_after_tws_switch = IBRT_STOP_IBRT_WAIT_TIME; + config.tws_conn_failed_wait_time = TWS_CONN_FAILED_WAIT_TIME; + config.sm_running_timeout = SM_RUNNING_TIMEOUT; + config.peer_sm_running_timeout = PEER_SM_RUNNING_TIMEOUT; + config.reconnect_peer_sm_running_timeout = RECONNECT_PEER_SM_RUNNING_TIMEOUT; + config.connect_no_03_timeout = CONNECT_NO_03_TIMEOUT; + config.disconnect_no_05_timeout = DISCONNECT_NO_05_TIMEOUT; - config.radical_scan_interval_nv_slave = IBRT_UI_RADICAL_SAN_INTERVAL_NV_SLAVE; - config.radical_scan_interval_nv_master = IBRT_UI_RADICAL_SAN_INTERVAL_NV_MASTER; - config.event_hung_timeout = IBRT_EVENT_HUNG_TIMEOUT; - config.rssi_tws_switch_threshold = IBRT_TWS_SWITCH_RSSI_THRESHOLD; - config.stop_ibrt_wait_time_after_tws_switch = IBRT_STOP_IBRT_WAIT_TIME; - config.tws_conn_failed_wait_time = TWS_CONN_FAILED_WAIT_TIME; + config.tws_switch_tx_data_protect = true; + config.tws_cmd_send_timeout = IBRT_UI_TWS_CMD_SEND_TIMEOUT; + config.tws_cmd_send_counter_threshold = IBRT_UI_TWS_COUNTER_THRESHOLD; + config.tws_switch_stable_timeout = IBRT_UI_TWS_SWITCH_STABLE_TIMEOUT; - config.sm_running_timeout = SM_RUNNING_TIMEOUT; - config.peer_sm_running_timeout = PEER_SM_RUNNING_TIMEOUT; - config.reconnect_peer_sm_running_timeout = RECONNECT_PEER_SM_RUNNING_TIMEOUT; - config.connect_no_03_timeout = CONNECT_NO_03_TIMEOUT; - config.disconnect_no_05_timeout = DISCONNECT_NO_05_TIMEOUT; + config.invoke_event_when_box_closed = true; - config.tws_switch_tx_data_protect = true; - config.tws_cmd_send_timeout = IBRT_UI_TWS_CMD_SEND_TIMEOUT; - config.tws_cmd_send_counter_threshold = IBRT_UI_TWS_COUNTER_THRESHOLD; - config.tws_switch_stable_timeout = IBRT_UI_TWS_SWITCH_STABLE_TIMEOUT; + // if open_box/close box detect supported, may open this config to speed up + // connection setup + config.tws_stay_when_close_box = false; + config.free_tws_timeout = IBRT_UI_DISC_TWS_TIMEOUT; - config.invoke_event_when_box_closed = true; + config.profile_concurrency_supported = false; + config.audio_sync_mismatch_resume_version = 2; + config.filter_duplicate_event = true; - //if open_box/close box detect supported, may open this config to speed up connection setup - config.tws_stay_when_close_box = false; - config.free_tws_timeout = IBRT_UI_DISC_TWS_TIMEOUT; + app_ibrt_if_register_global_handler_ind( + app_ibrt_customif_ui_global_handler_ind); + app_ibrt_if_register_vender_handler_ind( + app_ibrt_customif_ui_vender_event_handler_ind); + app_ibrt_if_register_global_event_update_ind( + app_ibrt_customif_ui_global_event_update); + app_ibrt_if_register_link_connected_ind( + app_ibrt_customif_mobile_connected_ind, + app_ibrt_customif_ibrt_connected_ind, + app_ibrt_customif_tws_connected_ind); + app_ibrt_if_register_profile_state_change_ind( + app_ibrt_customif_profile_state_change_ind); + app_ibrt_if_register_connect_mobile_needed_ind( + app_ibrt_customif_connect_mobile_needed_ind); + app_ibrt_if_register_pairing_mode_ind(app_ibrt_customif_ui_pairing_set, + app_ibrt_customif_ui_pairing_clear); + app_ibrt_if_config(&config); - config.profile_concurrency_supported = false; - - config.audio_sync_mismatch_resume_version = 2; - config.filter_duplicate_event = true; - - app_ibrt_if_register_global_handler_ind(app_ibrt_customif_ui_global_handler_ind); - app_ibrt_if_register_vender_handler_ind(app_ibrt_customif_ui_vender_event_handler_ind); - app_ibrt_if_register_global_event_update_ind(app_ibrt_customif_ui_global_event_update); - app_ibrt_if_register_link_connected_ind(app_ibrt_customif_mobile_connected_ind, - app_ibrt_customif_ibrt_connected_ind, - app_ibrt_customif_tws_connected_ind); - app_ibrt_if_register_profile_state_change_ind(app_ibrt_customif_profile_state_change_ind); - app_ibrt_if_register_connect_mobile_needed_ind(app_ibrt_customif_connect_mobile_needed_ind); - app_ibrt_if_register_pairing_mode_ind(app_ibrt_customif_ui_pairing_set, app_ibrt_customif_ui_pairing_clear); - app_ibrt_if_config(&config); - - if (config.delay_exit_sniff) - { - app_ibrt_if_sniff_checker_init(config.delay_ms_exit_sniff); - } - reconnectfail_delay_reportinit(); - return 0; + if (config.delay_exit_sniff) { + app_ibrt_if_sniff_checker_init(config.delay_ms_exit_sniff); + } + reconnectfail_delay_reportinit(); + return 0; } #endif diff --git a/services/app_ibrt/src/app_ibrt_if.cpp b/services/app_ibrt/src/app_ibrt_if.cpp index 8dd5932..aa90e19 100644 --- a/services/app_ibrt/src/app_ibrt_if.cpp +++ b/services/app_ibrt/src/app_ibrt_if.cpp @@ -13,34 +13,34 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "cmsis_os.h" -#include -#include "hal_trace.h" -#include "hal_location.h" -#include "hal_timer.h" -#include "nvrecord.h" -#include "crc32.h" -#include "app_tws_ibrt_trace.h" #include "app_ibrt_if.h" -#include "app_ibrt_if_internal.h" -#include "app_ibrt_ui_test.h" #include "a2dp_decoder.h" -#include "app_ibrt_nvrecord.h" -#include "bt_drv_reg_op.h" -#include "bt_drv_interface.h" -#include "btapp.h" -#include "app_tws_ibrt_cmd_sync_a2dp_status.h" -#include "app_ibrt_a2dp.h" -#include "app_tws_ibrt_cmd_sync_hfp_status.h" -#include "app_ibrt_hf.h" -#include "app_bt_stream.h" -#include "app_tws_ctrl_thread.h" -#include "app_bt_media_manager.h" -#include "app_bt_func.h" #include "app_ai_if.h" #include "app_ai_tws.h" +#include "app_bt_func.h" +#include "app_bt_media_manager.h" +#include "app_bt_stream.h" +#include "app_ibrt_a2dp.h" +#include "app_ibrt_hf.h" +#include "app_ibrt_if_internal.h" +#include "app_ibrt_nvrecord.h" +#include "app_ibrt_ui_test.h" +#include "app_tws_ctrl_thread.h" +#include "app_tws_ibrt_cmd_sync_a2dp_status.h" +#include "app_tws_ibrt_cmd_sync_hfp_status.h" +#include "app_tws_ibrt_trace.h" #include "app_tws_if.h" #include "besaud_api.h" +#include "bt_drv_interface.h" +#include "bt_drv_reg_op.h" +#include "btapp.h" +#include "cmsis_os.h" +#include "crc32.h" +#include "hal_location.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "nvrecord.h" +#include #ifdef BLE_ENABLE #include "app_ble_include.h" #endif @@ -53,1151 +53,1022 @@ #include "app_spp_tota.h" #endif -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; extern uint8_t avrcp_get_media_status(void); - #if defined(IBRT) static uint32_t tws_sniff_block_start = 0; static uint32_t tws_sniff_block_next_sec = 0; -void app_ibrt_if_register_tws_switch_needed_ind(APP_IBRT_IF_TWS_SWITCH_NEEDED_IND tws_switch_need_ind) -{ - app_ibrt_ui_register_tws_switch_needed_ind(tws_switch_need_ind); +void app_ibrt_if_register_tws_switch_needed_ind( + APP_IBRT_IF_TWS_SWITCH_NEEDED_IND tws_switch_need_ind) { + app_ibrt_ui_register_tws_switch_needed_ind(tws_switch_need_ind); } -void app_ibrt_if_register_connect_mobile_needed_ind(APP_IBRT_IF_CONNECT_MOBILE_NEEDED_IND connect_moible_need_ind) -{ - app_ibrt_ui_register_connect_mobile_needed_ind(connect_moible_need_ind); +void app_ibrt_if_register_connect_mobile_needed_ind( + APP_IBRT_IF_CONNECT_MOBILE_NEEDED_IND connect_moible_need_ind) { + app_ibrt_ui_register_connect_mobile_needed_ind(connect_moible_need_ind); } -void app_ibrt_if_register_vender_handler_ind(APP_IBRT_IF_VENDER_EVENT_HANDLER_IND handler) -{ - app_ibrt_ui_register_vender_event_update_ind(handler); +void app_ibrt_if_register_vender_handler_ind( + APP_IBRT_IF_VENDER_EVENT_HANDLER_IND handler) { + app_ibrt_ui_register_vender_event_update_ind(handler); } -void app_ibrt_if_register_global_handler_ind(APP_IBRT_IF_GLOBAL_HANDLER_IND handler) -{ - app_ibrt_ui_register_global_handler_ind(handler); +void app_ibrt_if_register_global_handler_ind( + APP_IBRT_IF_GLOBAL_HANDLER_IND handler) { + app_ibrt_ui_register_global_handler_ind(handler); } -void app_ibrt_if_register_global_event_update_ind(APP_IBRT_IF_GLOBAL_EVENT_UPDATE_IND handler) -{ - app_ibrt_ui_register_global_event_update_ind(handler); +void app_ibrt_if_register_global_event_update_ind( + APP_IBRT_IF_GLOBAL_EVENT_UPDATE_IND handler) { + app_ibrt_ui_register_global_event_update_ind(handler); } -void app_ibrt_if_register_pairing_mode_ind(APP_IBRT_UI_PAIRING_MODE_HANDLER_IND set_callback, APP_IBRT_UI_PAIRING_MODE_HANDLER_IND clear_callback) -{ - app_ibrt_ui_register_pairing_mode_ind(set_callback, clear_callback); +void app_ibrt_if_register_pairing_mode_ind( + APP_IBRT_UI_PAIRING_MODE_HANDLER_IND set_callback, + APP_IBRT_UI_PAIRING_MODE_HANDLER_IND clear_callback) { + app_ibrt_ui_register_pairing_mode_ind(set_callback, clear_callback); } -void app_ibrt_if_register_cmd_complete_ind(APP_IBRT_UI_CMD_COMPLETE_HANDLER_IND cmd_complete_ind) -{ - app_ibrt_ui_register_cmd_complete_ind(cmd_complete_ind); - +void app_ibrt_if_register_cmd_complete_ind( + APP_IBRT_UI_CMD_COMPLETE_HANDLER_IND cmd_complete_ind) { + app_ibrt_ui_register_cmd_complete_ind(cmd_complete_ind); } -void app_ibrt_if_register_link_connected_ind(APP_IBRT_UI_CONNECTED_HANDLER_IND mobile_connected_ind, - APP_IBRT_UI_CONNECTED_HANDLER_IND ibrt_connected_ind, - APP_IBRT_UI_CONNECTED_HANDLER_IND tws_connected_ind) -{ - app_ibrt_ui_register_link_connected_ind(mobile_connected_ind, ibrt_connected_ind, tws_connected_ind); +void app_ibrt_if_register_link_connected_ind( + APP_IBRT_UI_CONNECTED_HANDLER_IND mobile_connected_ind, + APP_IBRT_UI_CONNECTED_HANDLER_IND ibrt_connected_ind, + APP_IBRT_UI_CONNECTED_HANDLER_IND tws_connected_ind) { + app_ibrt_ui_register_link_connected_ind( + mobile_connected_ind, ibrt_connected_ind, tws_connected_ind); } -void app_ibrt_if_register_profile_state_change_ind(APP_IBRT_IF_PROFILE_STATE_CHANGE_IND handler) -{ - app_ibrt_ui_register_profile_state_change_ind(handler); +void app_ibrt_if_register_profile_state_change_ind( + APP_IBRT_IF_PROFILE_STATE_CHANGE_IND handler) { + app_ibrt_ui_register_profile_state_change_ind(handler); } -typedef struct -{ - ibrt_config_t ibrt_config; - nvrec_btdevicerecord rec_mobile; - nvrec_btdevicerecord rec_peer; - uint8_t reserved __attribute__((aligned(4))); - uint32_t crc; +typedef struct { + ibrt_config_t ibrt_config; + nvrec_btdevicerecord rec_mobile; + nvrec_btdevicerecord rec_peer; + uint8_t reserved __attribute__((aligned(4))); + uint32_t crc; } ibrt_config_ram_bak_t; ibrt_config_ram_bak_t REBOOT_CUSTOM_PARAM_LOC ibrt_config_ram_bak; -int app_ibrt_if_config_keeper_clear(void) -{ - memset(&ibrt_config_ram_bak, 0, sizeof(ibrt_config_ram_bak)); - return 0; +int app_ibrt_if_config_keeper_clear(void) { + memset(&ibrt_config_ram_bak, 0, sizeof(ibrt_config_ram_bak)); + return 0; } -void app_ibrt_if_set_silent_mode(void) -{ - app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); +void app_ibrt_if_set_silent_mode(void) { + app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); - p_ibrt_ui->silent_mode = true; + p_ibrt_ui->silent_mode = true; + app_ibrt_ui_event_entry(IBRT_TWS_PAIRING_EVENT); +} + +void app_ibrt_if_clear_silent_mode(void) { + app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); + + p_ibrt_ui->silent_mode = false; + app_ibrt_ui_judge_scan_type(IBRT_RESTORE_SCAN, NO_LINK_TYPE, + IBRT_UI_NO_ERROR); +} + +int app_ibrt_if_config_keeper_flush(void) { + ibrt_config_ram_bak.crc = + crc32(0, (uint8_t *)(&ibrt_config_ram_bak), + (sizeof(ibrt_config_ram_bak_t) - sizeof(uint32_t))); + TRACE(2, "%s crc:%08x", __func__, ibrt_config_ram_bak.crc); + return 0; +} + +int app_ibrt_if_volume_ptr_update(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + + btif_remote_device_t *remDev = NULL; + + if (app_tws_ibrt_mobile_link_connected()) { + remDev = btif_me_get_remote_device_by_handle(p_ibrt_ctrl->mobile_conhandle); + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + remDev = btif_me_get_remote_device_by_handle(p_ibrt_ctrl->ibrt_conhandle); + } + + if (remDev) { + app_bt_stream_volume_ptr_update( + (uint8_t *)btif_me_get_remote_device_bdaddr(remDev)); + } + + return 0; +} + +void app_ibrt_if_pairing_mode_refresh(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + + if (p_ibrt_ctrl->nv_role == IBRT_MASTER) { app_ibrt_ui_event_entry(IBRT_TWS_PAIRING_EVENT); + } else { + if (!btif_besaud_is_connected()) { + app_ibrt_ui_set_enter_pairing_mode(IBRT_TWS_PAIR_MODE_ENTER); + app_ibrt_ui_judge_scan_type(IBRT_ENTER_PAIRING_MODE_TRIGGER, NO_LINK_TYPE, + 0); + } else { + tws_ctrl_send_cmd(APP_TWS_CMD_PAIRING_MODE_REFRESH, NULL, 0); + } + } } -void app_ibrt_if_clear_silent_mode(void) -{ - app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); +int app_ibrt_if_config_keeper_mobile_update(bt_bdaddr_t *addr) { + nvrec_btdevicerecord *nv_record = NULL; + nvrec_btdevicerecord *rambak_record = NULL; - p_ibrt_ui->silent_mode = false; - app_ibrt_ui_judge_scan_type(IBRT_RESTORE_SCAN, NO_LINK_TYPE, IBRT_UI_NO_ERROR); + rambak_record = &ibrt_config_ram_bak.rec_mobile; + + if (!nv_record_btdevicerecord_find(addr, &nv_record)) { + TRACE(1, "%s success", __func__); + DUMP8("%02x ", nv_record->record.bdAddr.address, + sizeof(nv_record->record.bdAddr.address)); + DUMP8("%02x ", nv_record->record.linkKey, + sizeof(nv_record->record.linkKey)); + ibrt_config_ram_bak.ibrt_config.mobile_addr = *addr; + *rambak_record = *nv_record; + app_ibrt_if_config_keeper_flush(); + app_ibrt_if_volume_ptr_update(); + } else { + TRACE(1, "%s failure", __func__); + } + + return 0; } -int app_ibrt_if_config_keeper_flush(void) -{ - ibrt_config_ram_bak.crc = crc32(0,(uint8_t *)(&ibrt_config_ram_bak),(sizeof(ibrt_config_ram_bak_t)-sizeof(uint32_t))); - TRACE(2,"%s crc:%08x", __func__, ibrt_config_ram_bak.crc); - return 0; -} +int app_ibrt_if_config_keeper_tws_update(bt_bdaddr_t *addr) { + nvrec_btdevicerecord *nv_record = NULL; + nvrec_btdevicerecord *rambak_record = NULL; -int app_ibrt_if_volume_ptr_update(void) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + rambak_record = &ibrt_config_ram_bak.rec_peer; - btif_remote_device_t *remDev = NULL; + if (!nv_record_btdevicerecord_find(addr, &nv_record)) { + TRACE(1, "%s success", __func__); + DUMP8("%02x ", nv_record->record.bdAddr.address, + sizeof(nv_record->record.bdAddr.address)); + DUMP8("%02x ", nv_record->record.linkKey, + sizeof(nv_record->record.linkKey)); + ibrt_config_ram_bak.ibrt_config.peer_addr = *addr; + *rambak_record = *nv_record; + app_ibrt_if_config_keeper_flush(); + app_ibrt_if_volume_ptr_update(); + } else { + TRACE(1, "%s failure", __func__); + } - if (app_tws_ibrt_mobile_link_connected()) - { - remDev = btif_me_get_remote_device_by_handle(p_ibrt_ctrl->mobile_conhandle); - } - else if (app_tws_ibrt_slave_ibrt_link_connected()) - { - remDev = btif_me_get_remote_device_by_handle(p_ibrt_ctrl->ibrt_conhandle); - } - - if (remDev) - { - app_bt_stream_volume_ptr_update((uint8_t *) btif_me_get_remote_device_bdaddr(remDev)); - } - - return 0; -} - -void app_ibrt_if_pairing_mode_refresh(void) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - - if (p_ibrt_ctrl->nv_role == IBRT_MASTER) - { - app_ibrt_ui_event_entry(IBRT_TWS_PAIRING_EVENT); - } - else - { - if (!btif_besaud_is_connected()) - { - app_ibrt_ui_set_enter_pairing_mode(IBRT_TWS_PAIR_MODE_ENTER); - app_ibrt_ui_judge_scan_type(IBRT_ENTER_PAIRING_MODE_TRIGGER, NO_LINK_TYPE, 0); - } - else - { - tws_ctrl_send_cmd(APP_TWS_CMD_PAIRING_MODE_REFRESH, NULL, 0); - } - } -} - -int app_ibrt_if_config_keeper_mobile_update(bt_bdaddr_t *addr) -{ - nvrec_btdevicerecord *nv_record = NULL; - nvrec_btdevicerecord *rambak_record = NULL; - - rambak_record = &ibrt_config_ram_bak.rec_mobile; - - if (!nv_record_btdevicerecord_find(addr,&nv_record)) - { - TRACE(1,"%s success", __func__); - DUMP8("%02x ", nv_record->record.bdAddr.address, sizeof(nv_record->record.bdAddr.address)); - DUMP8("%02x ", nv_record->record.linkKey, sizeof(nv_record->record.linkKey)); - ibrt_config_ram_bak.ibrt_config.mobile_addr = *addr; - *rambak_record = *nv_record; - app_ibrt_if_config_keeper_flush(); - app_ibrt_if_volume_ptr_update(); - } - else - { - TRACE(1,"%s failure", __func__); - } - - return 0; -} - -int app_ibrt_if_config_keeper_tws_update(bt_bdaddr_t *addr) -{ - nvrec_btdevicerecord *nv_record = NULL; - nvrec_btdevicerecord *rambak_record = NULL; - - rambak_record = &ibrt_config_ram_bak.rec_peer; - - if (!nv_record_btdevicerecord_find(addr,&nv_record)) - { - TRACE(1,"%s success", __func__); - DUMP8("%02x ", nv_record->record.bdAddr.address, sizeof(nv_record->record.bdAddr.address)); - DUMP8("%02x ", nv_record->record.linkKey, sizeof(nv_record->record.linkKey)); - ibrt_config_ram_bak.ibrt_config.peer_addr = *addr; - *rambak_record = *nv_record; - app_ibrt_if_config_keeper_flush(); - app_ibrt_if_volume_ptr_update(); - } - else - { - TRACE(1,"%s failure", __func__); - } - - return 0; + return 0; } /* -* tws preparation before tws switch if needed -*/ + * tws preparation before tws switch if needed + */ #ifdef IBRT_OTA extern void ota_control_send_start_role_switch(void); #endif -bool app_ibrt_if_tws_switch_prepare_needed(uint32_t *wait_ms) -{ - __attribute__((unused)) ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - bool ret = false; +bool app_ibrt_if_tws_switch_prepare_needed(uint32_t *wait_ms) { + __attribute__((unused)) ibrt_ctrl_t *p_ibrt_ctrl = + app_tws_ibrt_get_bt_ctrl_ctx(); + bool ret = false; #ifdef BLE_ENABLE - ble_callback_evnet_t event; - event.evt_type = BLE_CALLBACK_RS_START; - app_ble_core_global_callback_event(&event, NULL); + ble_callback_evnet_t event; + event.evt_type = BLE_CALLBACK_RS_START; + app_ble_core_global_callback_event(&event, NULL); #endif #if defined(__AI_VOICE__) || defined(BISTO_ENABLED) - p_ibrt_ctrl->ibrt_ai_role_switch_handle = app_ai_tws_role_switch_prepare(wait_ms); - if (p_ibrt_ctrl->ibrt_ai_role_switch_handle) - { - p_ibrt_ctrl->ibrt_role_switch_handle_user |= (1 << IBRT_ROLE_SWITCH_USER_AI); - } + p_ibrt_ctrl->ibrt_ai_role_switch_handle = + app_ai_tws_role_switch_prepare(wait_ms); + if (p_ibrt_ctrl->ibrt_ai_role_switch_handle) { + p_ibrt_ctrl->ibrt_role_switch_handle_user |= + (1 << IBRT_ROLE_SWITCH_USER_AI); + } #endif #ifdef IBRT_OTA - if (app_get_bes_ota_state()) - { - p_ibrt_ctrl->ibrt_role_switch_handle_user |= (1 << IBRT_ROLE_SWITCH_USER_OTA); - *wait_ms = 800; - } + if (app_get_bes_ota_state()) { + p_ibrt_ctrl->ibrt_role_switch_handle_user |= + (1 << IBRT_ROLE_SWITCH_USER_OTA); + *wait_ms = 800; + } #endif - if (p_ibrt_ctrl->ibrt_role_switch_handle_user) - { - ret = true; - } + if (p_ibrt_ctrl->ibrt_role_switch_handle_user) { + ret = true; + } - app_tws_if_role_switch_started_handler(); + app_tws_if_role_switch_started_handler(); - TRACE(2,"tws_switch_prepare_needed=%d, wait_ms=%d", ret, *wait_ms); - return ret; + TRACE(2, "tws_switch_prepare_needed=%d, wait_ms=%d", ret, *wait_ms); + return ret; } /* -* tws preparation before tws switch -*/ -void app_ibrt_if_tws_swtich_prepare(void) -{ + * tws preparation before tws switch + */ +void app_ibrt_if_tws_swtich_prepare(void) { #if defined(BISTO_ENABLED) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (p_ibrt_ctrl->ibrt_ai_role_switch_handle & (1 << AI_SPEC_GSOUND)) - { - app_ai_tws_role_switch(); - } + if (p_ibrt_ctrl->ibrt_ai_role_switch_handle & (1 << AI_SPEC_GSOUND)) { + app_ai_tws_role_switch(); + } #endif #ifdef IBRT_OTA - ibrt_ctrl_t *ota_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if ((app_get_bes_ota_state()) &&\ - (ota_ibrt_ctrl->ibrt_role_switch_handle_user & IBRT_ROLE_SWITCH_USER_OTA)) - { - app_set_ota_role_switch_initiator(true); - bes_ota_send_role_switch_req(); - } + ibrt_ctrl_t *ota_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if ((app_get_bes_ota_state()) && + (ota_ibrt_ctrl->ibrt_role_switch_handle_user & + IBRT_ROLE_SWITCH_USER_OTA)) { + app_set_ota_role_switch_initiator(true); + bes_ota_send_role_switch_req(); + } #endif } /* -* notify UI SM tws preparation done -*/ -extern osTimerId ibrt_ui_tws_switch_prepare_timer_id; -static void app_ibrt_if_tws_switch_prepare_done(IBRT_ROLE_SWITCH_USER_E user, uint32_t role) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + * notify UI SM tws preparation done + */ +extern osTimerId ibrt_ui_tws_switch_prepare_timer_id; +static void app_ibrt_if_tws_switch_prepare_done(IBRT_ROLE_SWITCH_USER_E user, + uint32_t role) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (p_ibrt_ctrl->ibrt_role_switch_handle_user) - { + if (p_ibrt_ctrl->ibrt_role_switch_handle_user) { #if defined(__AI_VOICE__) || defined(BISTO_ENABLED) - TRACE(4,"%s ai_handle 0x%x role %d%s", __func__, \ - p_ibrt_ctrl->ibrt_ai_role_switch_handle, \ - role, \ - ai_spec_type2str((AI_SPEC_TYPE_E)role)); + TRACE(4, "%s ai_handle 0x%x role %d%s", __func__, + p_ibrt_ctrl->ibrt_ai_role_switch_handle, role, + ai_spec_type2str((AI_SPEC_TYPE_E)role)); - if (user == IBRT_ROLE_SWITCH_USER_AI) - { - if (role >= AI_SPEC_COUNT) - { - TRACE(1,"%s role error", __func__); - return; - } - if (!p_ibrt_ctrl->ibrt_ai_role_switch_handle) - { - TRACE(1,"%s ai_handle is 0", __func__); - return; - } + if (user == IBRT_ROLE_SWITCH_USER_AI) { + if (role >= AI_SPEC_COUNT) { + TRACE(1, "%s role error", __func__); + return; + } + if (!p_ibrt_ctrl->ibrt_ai_role_switch_handle) { + TRACE(1, "%s ai_handle is 0", __func__); + return; + } - p_ibrt_ctrl->ibrt_ai_role_switch_handle &= ~(1 << role); - if (!p_ibrt_ctrl->ibrt_ai_role_switch_handle) - { - p_ibrt_ctrl->ibrt_role_switch_handle_user &= ~IBRT_ROLE_SWITCH_USER_AI; - } - } - else + p_ibrt_ctrl->ibrt_ai_role_switch_handle &= ~(1 << role); + if (!p_ibrt_ctrl->ibrt_ai_role_switch_handle) { + p_ibrt_ctrl->ibrt_role_switch_handle_user &= ~IBRT_ROLE_SWITCH_USER_AI; + } + } else #endif - { - p_ibrt_ctrl->ibrt_role_switch_handle_user &= ~user; - } - - if (!p_ibrt_ctrl->ibrt_role_switch_handle_user) - { - osTimerStop(ibrt_ui_tws_switch_prepare_timer_id); - app_ibrt_ui_event_handler(IBRT_ACTION_TWS_SWITCH_PREPARE_COMPLETE,IBRT_UI_NO_ERROR); - } - } -} - -void app_ibrt_if_tws_switch_prepare_done_in_bt_thread(IBRT_ROLE_SWITCH_USER_E user, uint32_t role) -{ - app_bt_start_custom_function_in_bt_thread(user, - role, - (uint32_t)app_ibrt_if_tws_switch_prepare_done); -} - -int app_ibrt_if_config_keeper_resume(ibrt_config_t *config) -{ - uint32_t crc; - nvrec_btdevicerecord *nv_record = NULL; - nvrec_btdevicerecord *rambak_record = NULL; - bool mobile_check_ok = false; - bool peer_check_ok = false; - bool flash_need_flush = false; - bt_bdaddr_t zeroAddr = {0,0,0,0,0,0}; - - crc = crc32(0,(uint8_t *)(&ibrt_config_ram_bak),(sizeof(ibrt_config_ram_bak_t)-sizeof(uint32_t))); - - TRACE(3,"%s start crc:%08x/%08x", __func__, ibrt_config_ram_bak.crc, crc); - if (crc == ibrt_config_ram_bak.crc) { - TRACE_IMM(1,"%s success", __func__); - TRACE(1,"%s config loc", __func__); - DUMP8("%02x ", config->local_addr.address, 6); - TRACE(1,"%s config mobile", __func__); - DUMP8("%02x ", config->mobile_addr.address, 6); - TRACE(1,"%s config peer", __func__); - DUMP8("%02x ", config->peer_addr.address, 6); - - rambak_record = &ibrt_config_ram_bak.rec_mobile; - if (!nv_record_btdevicerecord_find(&config->mobile_addr,&nv_record)) - { - TRACE(1,"%s find mobile", __func__); - DUMP8("%02x ", nv_record->record.bdAddr.address, sizeof(nv_record->record.bdAddr.address)); - DUMP8("%02x ", nv_record->record.linkKey, sizeof(nv_record->record.linkKey)); - if (!memcmp(rambak_record->record.linkKey, nv_record->record.linkKey, sizeof(nv_record->record.linkKey))) - { - TRACE(1,"%s check mobile success", __func__); - mobile_check_ok = true; - } - } - if (!mobile_check_ok) - { - TRACE(1,"%s check mobile failure", __func__); - DUMP8("%02x ", rambak_record->record.bdAddr.address, sizeof(zeroAddr)); - DUMP8("%02x ", rambak_record->record.linkKey, sizeof(rambak_record->record.linkKey)); - if (memcmp(rambak_record->record.bdAddr.address, zeroAddr.address, sizeof(zeroAddr))) - { - nv_record_add(section_usrdata_ddbrecord, rambak_record); - config->mobile_addr = rambak_record->record.bdAddr; - flash_need_flush = true; - TRACE(1,"%s resume mobile", __func__); - } - } - - rambak_record = &ibrt_config_ram_bak.rec_peer; - if (!nv_record_btdevicerecord_find(&config->peer_addr,&nv_record)) - { - TRACE(1,"%s find tws peer", __func__); - DUMP8("%02x ", nv_record->record.bdAddr.address, sizeof(nv_record->record.bdAddr.address)); - DUMP8("%02x ", nv_record->record.linkKey, sizeof(nv_record->record.linkKey)); - if (!memcmp(rambak_record->record.linkKey, nv_record->record.linkKey, sizeof(nv_record->record.linkKey))) - { - TRACE(1,"%s check tws peer success", __func__); - peer_check_ok = true; - } - } - if (!peer_check_ok) - { - TRACE(1,"%s check tws peer failure", __func__); - DUMP8("%02x ", rambak_record->record.bdAddr.address, sizeof(rambak_record->record.bdAddr)); - DUMP8("%02x ", rambak_record->record.linkKey, sizeof(rambak_record->record.linkKey)); - if (memcmp(rambak_record->record.bdAddr.address, zeroAddr.address, sizeof(zeroAddr))) - { - nv_record_add(section_usrdata_ddbrecord, rambak_record); - config->peer_addr = rambak_record->record.bdAddr; - flash_need_flush = true; - TRACE(1,"%s resume tws peer", __func__); - } - } - + p_ibrt_ctrl->ibrt_role_switch_handle_user &= ~user; } - ibrt_config_ram_bak.ibrt_config = *config; + if (!p_ibrt_ctrl->ibrt_role_switch_handle_user) { + osTimerStop(ibrt_ui_tws_switch_prepare_timer_id); + app_ibrt_ui_event_handler(IBRT_ACTION_TWS_SWITCH_PREPARE_COMPLETE, + IBRT_UI_NO_ERROR); + } + } +} + +void app_ibrt_if_tws_switch_prepare_done_in_bt_thread( + IBRT_ROLE_SWITCH_USER_E user, uint32_t role) { + app_bt_start_custom_function_in_bt_thread( + user, role, (uint32_t)app_ibrt_if_tws_switch_prepare_done); +} + +int app_ibrt_if_config_keeper_resume(ibrt_config_t *config) { + uint32_t crc; + nvrec_btdevicerecord *nv_record = NULL; + nvrec_btdevicerecord *rambak_record = NULL; + bool mobile_check_ok = false; + bool peer_check_ok = false; + bool flash_need_flush = false; + bt_bdaddr_t zeroAddr = {0, 0, 0, 0, 0, 0}; + + crc = crc32(0, (uint8_t *)(&ibrt_config_ram_bak), + (sizeof(ibrt_config_ram_bak_t) - sizeof(uint32_t))); + + TRACE(3, "%s start crc:%08x/%08x", __func__, ibrt_config_ram_bak.crc, crc); + if (crc == ibrt_config_ram_bak.crc) { + TRACE_IMM(1, "%s success", __func__); + TRACE(1, "%s config loc", __func__); + DUMP8("%02x ", config->local_addr.address, 6); + TRACE(1, "%s config mobile", __func__); + DUMP8("%02x ", config->mobile_addr.address, 6); + TRACE(1, "%s config peer", __func__); + DUMP8("%02x ", config->peer_addr.address, 6); + rambak_record = &ibrt_config_ram_bak.rec_mobile; - if (!nv_record_btdevicerecord_find(&config->mobile_addr,&nv_record)) - { - *rambak_record = *nv_record; + if (!nv_record_btdevicerecord_find(&config->mobile_addr, &nv_record)) { + TRACE(1, "%s find mobile", __func__); + DUMP8("%02x ", nv_record->record.bdAddr.address, + sizeof(nv_record->record.bdAddr.address)); + DUMP8("%02x ", nv_record->record.linkKey, + sizeof(nv_record->record.linkKey)); + if (!memcmp(rambak_record->record.linkKey, nv_record->record.linkKey, + sizeof(nv_record->record.linkKey))) { + TRACE(1, "%s check mobile success", __func__); + mobile_check_ok = true; + } } - else - { - memset(rambak_record, 0, sizeof(nvrec_btdevicerecord)); + if (!mobile_check_ok) { + TRACE(1, "%s check mobile failure", __func__); + DUMP8("%02x ", rambak_record->record.bdAddr.address, sizeof(zeroAddr)); + DUMP8("%02x ", rambak_record->record.linkKey, + sizeof(rambak_record->record.linkKey)); + if (memcmp(rambak_record->record.bdAddr.address, zeroAddr.address, + sizeof(zeroAddr))) { + nv_record_add(section_usrdata_ddbrecord, rambak_record); + config->mobile_addr = rambak_record->record.bdAddr; + flash_need_flush = true; + TRACE(1, "%s resume mobile", __func__); + } } + rambak_record = &ibrt_config_ram_bak.rec_peer; - if (!nv_record_btdevicerecord_find(&config->peer_addr,&nv_record)) - { - *rambak_record = *nv_record; + if (!nv_record_btdevicerecord_find(&config->peer_addr, &nv_record)) { + TRACE(1, "%s find tws peer", __func__); + DUMP8("%02x ", nv_record->record.bdAddr.address, + sizeof(nv_record->record.bdAddr.address)); + DUMP8("%02x ", nv_record->record.linkKey, + sizeof(nv_record->record.linkKey)); + if (!memcmp(rambak_record->record.linkKey, nv_record->record.linkKey, + sizeof(nv_record->record.linkKey))) { + TRACE(1, "%s check tws peer success", __func__); + peer_check_ok = true; + } } - else - { - memset(rambak_record, 0, sizeof(nvrec_btdevicerecord)); + if (!peer_check_ok) { + TRACE(1, "%s check tws peer failure", __func__); + DUMP8("%02x ", rambak_record->record.bdAddr.address, + sizeof(rambak_record->record.bdAddr)); + DUMP8("%02x ", rambak_record->record.linkKey, + sizeof(rambak_record->record.linkKey)); + if (memcmp(rambak_record->record.bdAddr.address, zeroAddr.address, + sizeof(zeroAddr))) { + nv_record_add(section_usrdata_ddbrecord, rambak_record); + config->peer_addr = rambak_record->record.bdAddr; + flash_need_flush = true; + TRACE(1, "%s resume tws peer", __func__); + } } - app_ibrt_if_config_keeper_flush(); - if (flash_need_flush) - { - nv_record_flash_flush(); - } - TRACE_IMM(2,"%s end crc:%08x", __func__, ibrt_config_ram_bak.crc); + } - TRACE(1,"%s mobile", __func__); - DUMP8("%02x ", ibrt_config_ram_bak.rec_mobile.record.bdAddr.address, sizeof(ibrt_config_ram_bak.rec_mobile.record.bdAddr)); - DUMP8("%02x ", ibrt_config_ram_bak.rec_mobile.record.linkKey, sizeof(ibrt_config_ram_bak.rec_mobile.record.linkKey)); - TRACE(1,"%s peer", __func__); - DUMP8("%02x ", ibrt_config_ram_bak.rec_peer.record.bdAddr.address, sizeof(ibrt_config_ram_bak.rec_peer.record.bdAddr)); - DUMP8("%02x ", ibrt_config_ram_bak.rec_peer.record.linkKey, sizeof(ibrt_config_ram_bak.rec_peer.record.linkKey)); - return 0; + ibrt_config_ram_bak.ibrt_config = *config; + rambak_record = &ibrt_config_ram_bak.rec_mobile; + if (!nv_record_btdevicerecord_find(&config->mobile_addr, &nv_record)) { + *rambak_record = *nv_record; + } else { + memset(rambak_record, 0, sizeof(nvrec_btdevicerecord)); + } + rambak_record = &ibrt_config_ram_bak.rec_peer; + if (!nv_record_btdevicerecord_find(&config->peer_addr, &nv_record)) { + *rambak_record = *nv_record; + } else { + memset(rambak_record, 0, sizeof(nvrec_btdevicerecord)); + } + app_ibrt_if_config_keeper_flush(); + if (flash_need_flush) { + nv_record_flash_flush(); + } + TRACE_IMM(2, "%s end crc:%08x", __func__, ibrt_config_ram_bak.crc); + + TRACE(1, "%s mobile", __func__); + DUMP8("%02x ", ibrt_config_ram_bak.rec_mobile.record.bdAddr.address, + sizeof(ibrt_config_ram_bak.rec_mobile.record.bdAddr)); + DUMP8("%02x ", ibrt_config_ram_bak.rec_mobile.record.linkKey, + sizeof(ibrt_config_ram_bak.rec_mobile.record.linkKey)); + TRACE(1, "%s peer", __func__); + DUMP8("%02x ", ibrt_config_ram_bak.rec_peer.record.bdAddr.address, + sizeof(ibrt_config_ram_bak.rec_peer.record.bdAddr)); + DUMP8("%02x ", ibrt_config_ram_bak.rec_peer.record.linkKey, + sizeof(ibrt_config_ram_bak.rec_peer.record.linkKey)); + return 0; } -int app_ibrt_if_config_load(ibrt_config_t *config) -{ - memset(config->mobile_addr.address, 0, BD_ADDR_LEN); +int app_ibrt_if_config_load(ibrt_config_t *config) { + memset(config->mobile_addr.address, 0, BD_ADDR_LEN); #ifdef IBRT_SEARCH_UI - app_ibrt_nvrecord_config_load((void *)config); - config->audio_chnl_sel = A2DP_AUDIO_CHANNEL_SELECT_LRMERGE; + app_ibrt_nvrecord_config_load((void *)config); + config->audio_chnl_sel = A2DP_AUDIO_CHANNEL_SELECT_LRMERGE; #else - app_ibrt_ui_test_config_load((void *)config); + app_ibrt_ui_test_config_load((void *)config); #endif - return 0; + return 0; } -int app_ibrt_if_reconfig(ibrt_config_t *config) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - p_ibrt_ctrl->nv_role = config->nv_role ; - memcpy(p_ibrt_ctrl->peer_addr.address, config->peer_addr.address, 6); - return 0; +int app_ibrt_if_reconfig(ibrt_config_t *config) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + p_ibrt_ctrl->nv_role = config->nv_role; + memcpy(p_ibrt_ctrl->peer_addr.address, config->peer_addr.address, 6); + return 0; } -int app_ibrt_if_ui_reconfig(ibrt_ui_config_t *config) -{ - app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); +int app_ibrt_if_ui_reconfig(ibrt_ui_config_t *config) { + app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); - p_ibrt_ui->config = *config; + p_ibrt_ui->config = *config; - return 0; + return 0; } -int app_ibrt_core_if_reconfig(ibrt_core_config_t *config) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); +int app_ibrt_core_if_reconfig(ibrt_core_config_t *config) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - p_ibrt_ctrl->config = *config; + p_ibrt_ctrl->config = *config; - return 0; + return 0; } -int app_ibrt_if_config(ibrt_ui_config_t *ui_config) -{ - app_ibrt_if_ui_reconfig(ui_config); +int app_ibrt_if_config(ibrt_ui_config_t *ui_config) { + app_ibrt_if_ui_reconfig(ui_config); - ibrt_core_config_t core_config; - core_config.lowlayer_monitor_enable = ui_config->lowlayer_monitor_enable; - core_config.long_private_poll_interval = ui_config->long_private_poll_interval; - core_config.default_private_poll_interval = ui_config->default_private_poll_interval; - core_config.short_private_poll_interval = ui_config->short_private_poll_interval; - core_config.default_private_poll_interval_in_sco = ui_config->default_private_poll_interval_in_sco; - core_config.short_private_poll_interval_in_sco = ui_config->short_private_poll_interval_in_sco; - core_config.default_bt_tpoll = ui_config->default_bt_tpoll; - core_config.tws_switch_tx_data_protect = ui_config->tws_switch_tx_data_protect; - core_config.tws_cmd_send_timeout = ui_config->tws_cmd_send_timeout; - core_config.tws_cmd_send_counter_threshold = ui_config->tws_cmd_send_counter_threshold; - core_config.tws_switch_stable_timeout = ui_config->tws_switch_stable_timeout; - core_config.mobile_page_timeout = ui_config->mobile_page_timeout; - core_config.tws_connection_timeout = ui_config->tws_connection_timeout; - core_config.delay_exit_sniff = ui_config->delay_exit_sniff; - core_config.delay_ms_exit_sniff = ui_config->delay_ms_exit_sniff; - core_config.audio_sync_mismatch_resume_version = ui_config->audio_sync_mismatch_resume_version; - app_ibrt_core_if_reconfig(&core_config); + ibrt_core_config_t core_config; + core_config.lowlayer_monitor_enable = ui_config->lowlayer_monitor_enable; + core_config.long_private_poll_interval = + ui_config->long_private_poll_interval; + core_config.default_private_poll_interval = + ui_config->default_private_poll_interval; + core_config.short_private_poll_interval = + ui_config->short_private_poll_interval; + core_config.default_private_poll_interval_in_sco = + ui_config->default_private_poll_interval_in_sco; + core_config.short_private_poll_interval_in_sco = + ui_config->short_private_poll_interval_in_sco; + core_config.default_bt_tpoll = ui_config->default_bt_tpoll; + core_config.tws_switch_tx_data_protect = + ui_config->tws_switch_tx_data_protect; + core_config.tws_cmd_send_timeout = ui_config->tws_cmd_send_timeout; + core_config.tws_cmd_send_counter_threshold = + ui_config->tws_cmd_send_counter_threshold; + core_config.tws_switch_stable_timeout = ui_config->tws_switch_stable_timeout; + core_config.mobile_page_timeout = ui_config->mobile_page_timeout; + core_config.tws_connection_timeout = ui_config->tws_connection_timeout; + core_config.delay_exit_sniff = ui_config->delay_exit_sniff; + core_config.delay_ms_exit_sniff = ui_config->delay_ms_exit_sniff; + core_config.audio_sync_mismatch_resume_version = + ui_config->audio_sync_mismatch_resume_version; + app_ibrt_core_if_reconfig(&core_config); - return 0; + return 0; } -int app_ibrt_if_event_entry(ibrt_event_type event) -{ - TRACE(1,"ibrt_ui_log:custom event entry enter=%s", g_log_event_str[event]); - //int status = app_ibrt_ui_event_entry(event); +int app_ibrt_if_event_entry(ibrt_event_type event) { + TRACE(1, "ibrt_ui_log:custom event entry enter=%s", g_log_event_str[event]); + // int status = app_ibrt_ui_event_entry(event); - app_bt_start_custom_function_in_bt_thread((uint32_t)event, 0, (uint32_t)app_ibrt_ui_event_entry); + app_bt_start_custom_function_in_bt_thread((uint32_t)event, 0, + (uint32_t)app_ibrt_ui_event_entry); #ifdef BLE_ENABLE - ble_callback_evnet_t ble_callback_event; - ble_callback_event.evt_type = BLE_CALLBACK_IBRT_EVENT_ENTRY; - ble_callback_event.p.ibrt_event_entry_handled.event = event; - app_ble_core_global_callback_event(&ble_callback_event, NULL); + ble_callback_evnet_t ble_callback_event; + ble_callback_event.evt_type = BLE_CALLBACK_IBRT_EVENT_ENTRY; + ble_callback_event.p.ibrt_event_entry_handled.event = event; + app_ble_core_global_callback_event(&ble_callback_event, NULL); #endif - return 0; + return 0; } -void app_ibrt_if_choice_connect_second_mobile(void) -{ - TRACE(0,"ibrt_ui_log:app_ibrt_if_choice_connect_second_mobile"); - app_ibrt_ui_choice_connect_second_mobile(); +void app_ibrt_if_choice_connect_second_mobile(void) { + TRACE(0, "ibrt_ui_log:app_ibrt_if_choice_connect_second_mobile"); + app_ibrt_ui_choice_connect_second_mobile(); } -void app_ibrt_if_choice_mobile_connect(uint8_t index) -{ - TRACE(0,"ibrt_ui_log:app_ibrt_if_choice_mobile_connect"); - app_ibrt_ui_choice_mobile_connect(index); +void app_ibrt_if_choice_mobile_connect(uint8_t index) { + TRACE(0, "ibrt_ui_log:app_ibrt_if_choice_mobile_connect"); + app_ibrt_ui_choice_mobile_connect(index); } -void app_ibrt_if_disconnect_mobile(void) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); +void app_ibrt_if_disconnect_mobile(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (app_tws_ibrt_mobile_link_connected()) - { - app_tws_ibrt_disconnect_connection(btif_me_get_remote_device_by_handle(p_ibrt_ctrl->mobile_conhandle)); - } - else if (btif_besaud_is_connected()) - { - tws_ctrl_send_cmd(APP_TWS_CMD_DISC_MOBILE, NULL, 0); - } + if (app_tws_ibrt_mobile_link_connected()) { + app_tws_ibrt_disconnect_connection( + btif_me_get_remote_device_by_handle(p_ibrt_ctrl->mobile_conhandle)); + } else if (btif_besaud_is_connected()) { + tws_ctrl_send_cmd(APP_TWS_CMD_DISC_MOBILE, NULL, 0); + } } -void app_ibrt_if_disconnect_mobile_tws_link(void) -{ - TRACE(0,"ibrt_ui_log:app_ibrt_if_disconnect_mobile_tws_link"); - app_ibrt_ui_event_entry(IBRT_DISCONNECT_MOBILE_TWS_EVENT); +void app_ibrt_if_disconnect_mobile_tws_link(void) { + TRACE(0, "ibrt_ui_log:app_ibrt_if_disconnect_mobile_tws_link"); + app_ibrt_ui_event_entry(IBRT_DISCONNECT_MOBILE_TWS_EVENT); } -app_ibrt_if_ui_t* app_ibrt_if_ui_get_ctx(void) -{ - return (app_ibrt_if_ui_t *)app_ibrt_ui_get_ctx(); +app_ibrt_if_ui_t *app_ibrt_if_ui_get_ctx(void) { + return (app_ibrt_if_ui_t *)app_ibrt_ui_get_ctx(); } -app_ibrt_if_ctrl_t *app_ibrt_if_get_bt_ctrl_ctx(void) -{ - return (app_ibrt_if_ctrl_t *)app_tws_ibrt_get_bt_ctrl_ctx(); +app_ibrt_if_ctrl_t *app_ibrt_if_get_bt_ctrl_ctx(void) { + return (app_ibrt_if_ctrl_t *)app_tws_ibrt_get_bt_ctrl_ctx(); } /* -* this function is only for tws ibrt pairing mode -* when tws earphone is in the nearby, tws link will be connected firstly -* when mobile link exist, this function will disconnect mobile link -*/ -void app_ibrt_if_enter_pairing_after_tws_connected(void) -{ - app_ibrt_ui_event_entry(IBRT_TWS_PAIRING_EVENT); + * this function is only for tws ibrt pairing mode + * when tws earphone is in the nearby, tws link will be connected firstly + * when mobile link exist, this function will disconnect mobile link + */ +void app_ibrt_if_enter_pairing_after_tws_connected(void) { + app_ibrt_ui_event_entry(IBRT_TWS_PAIRING_EVENT); } /* -* this function is only for freeman pairing -* no tws link or ibrt link should be connected -* when mobile link or tws link exist, this function will disconnect mobile link and tws link -*/ -void app_ibrt_if_enter_freeman_pairing(void) -{ - app_ibrt_ui_event_entry(IBRT_FREEMAN_PAIRING_EVENT); + * this function is only for freeman pairing + * no tws link or ibrt link should be connected + * when mobile link or tws link exist, this function will disconnect mobile link + * and tws link + */ +void app_ibrt_if_enter_freeman_pairing(void) { + app_ibrt_ui_event_entry(IBRT_FREEMAN_PAIRING_EVENT); } -void app_ibrt_if_ctx_checker(void) -{ - app_ibrt_if_ui_t* ibrt_if_ui_ctx = app_ibrt_if_ui_get_ctx(); - ibrt_ctrl_t *p_ibrt_ctrl = app_ibrt_if_get_bt_ctrl_ctx(); +void app_ibrt_if_ctx_checker(void) { + app_ibrt_if_ui_t *ibrt_if_ui_ctx = app_ibrt_if_ui_get_ctx(); + ibrt_ctrl_t *p_ibrt_ctrl = app_ibrt_if_get_bt_ctrl_ctx(); - TRACE(3,"checker: nv_role:%d current_role:%d access_mode:%d", - p_ibrt_ctrl->nv_role, - p_ibrt_ctrl->current_role, - p_ibrt_ctrl->access_mode); + TRACE(3, "checker: nv_role:%d current_role:%d access_mode:%d", + p_ibrt_ctrl->nv_role, p_ibrt_ctrl->current_role, + p_ibrt_ctrl->access_mode); - DUMP8("%02x ", p_ibrt_ctrl->local_addr.address, BD_ADDR_LEN); - DUMP8("%02x ", p_ibrt_ctrl->peer_addr.address, BD_ADDR_LEN); + DUMP8("%02x ", p_ibrt_ctrl->local_addr.address, BD_ADDR_LEN); + DUMP8("%02x ", p_ibrt_ctrl->peer_addr.address, BD_ADDR_LEN); - TRACE(4,"checker: super_state:%s/%s evt:%s plf:%d", - g_log_super_state_str[ibrt_if_ui_ctx->super_state], - g_log_super_state_str[ibrt_if_ui_ctx->wait_state], - g_log_event_str[ibrt_if_ui_ctx->active_event&0x0F], - ibrt_if_ui_ctx->profile_exchanged); + TRACE(4, "checker: super_state:%s/%s evt:%s plf:%d", + g_log_super_state_str[ibrt_if_ui_ctx->super_state], + g_log_super_state_str[ibrt_if_ui_ctx->wait_state], + g_log_event_str[ibrt_if_ui_ctx->active_event & 0x0F], + ibrt_if_ui_ctx->profile_exchanged); - TRACE(4,"checker: box_state:%s/%s sm_run:%d/%d", g_log_box_state_str[ibrt_if_ui_ctx->box_state], - g_log_box_state_str[ibrt_if_ui_ctx->peer_tws_info.box_state], - ibrt_if_ui_ctx->ibrt_sm_running, - ibrt_if_ui_ctx->peer_tws_info.ibrt_sm_running); + TRACE(4, "checker: box_state:%s/%s sm_run:%d/%d", + g_log_box_state_str[ibrt_if_ui_ctx->box_state], + g_log_box_state_str[ibrt_if_ui_ctx->peer_tws_info.box_state], + ibrt_if_ui_ctx->ibrt_sm_running, + ibrt_if_ui_ctx->peer_tws_info.ibrt_sm_running); - if (p_ibrt_ctrl->mobile_mode == IBRT_ACTIVE_MODE || - p_ibrt_ctrl->tws_mode == IBRT_ACTIVE_MODE) - { - bt_drv_reg_op_controller_state_checker(); - } + if (p_ibrt_ctrl->mobile_mode == IBRT_ACTIVE_MODE || + p_ibrt_ctrl->tws_mode == IBRT_ACTIVE_MODE) { + bt_drv_reg_op_controller_state_checker(); + } } -int app_ibrt_if_force_audio_retrigger(void) -{ - a2dp_audio_detect_next_packet_callback_register(NULL); - a2dp_audio_detect_store_packet_callback_register(NULL); - app_ibrt_if_voice_report_trig_retrigger(); - return 0; +int app_ibrt_if_force_audio_retrigger(void) { + a2dp_audio_detect_next_packet_callback_register(NULL); + a2dp_audio_detect_store_packet_callback_register(NULL); + app_ibrt_if_voice_report_trig_retrigger(); + return 0; } -int app_ibrt_if_force_audio_retrigger_slave_sync(void) -{ - a2dp_audio_detect_next_packet_callback_register(NULL); - a2dp_audio_detect_store_packet_callback_register(NULL); - //app_ibrt_if_voice_report_trig_retrigger(); - return 0; +int app_ibrt_if_force_audio_retrigger_slave_sync(void) { + a2dp_audio_detect_next_packet_callback_register(NULL); + a2dp_audio_detect_store_packet_callback_register(NULL); + // app_ibrt_if_voice_report_trig_retrigger(); + return 0; } -bool app_ibrt_if_is_audio_active(void) -{ - btif_avdtp_stream_state_t state = btif_a2dp_get_stream_state(app_bt_get_mobile_a2dp_stream(BTIF_DEVICE_ID_1)); - return ((state == BTIF_AVDTP_STRM_STATE_STREAMING) || \ - btapp_hfp_is_sco_active()); +bool app_ibrt_if_is_audio_active(void) { + btif_avdtp_stream_state_t state = btif_a2dp_get_stream_state( + app_bt_get_mobile_a2dp_stream(BTIF_DEVICE_ID_1)); + return ((state == BTIF_AVDTP_STRM_STATE_STREAMING) || + btapp_hfp_is_sco_active()); } -bool app_ibrt_if_false_trigger_protect(ibrt_event_type evt_type) -{ - app_ibrt_ui_t *p_ui_ctrl = app_ibrt_ui_get_ctx(); - ibrt_box_state box_state; - if (app_ibrt_ui_event_queue_empty() || \ - (IBRT_BOX_UNKNOWN == p_ui_ctrl->box_state_future)) - { - box_state = p_ui_ctrl->box_state; - p_ui_ctrl->box_state_future = IBRT_BOX_UNKNOWN; - } - else - { - TRACE(2,"event queue not empty, use future box state to judge, rear=%d, front=%d",\ - p_ui_ctrl->event_q_manager.rear, p_ui_ctrl->event_q_manager.front); +bool app_ibrt_if_false_trigger_protect(ibrt_event_type evt_type) { + app_ibrt_ui_t *p_ui_ctrl = app_ibrt_ui_get_ctx(); + ibrt_box_state box_state; + if (app_ibrt_ui_event_queue_empty() || + (IBRT_BOX_UNKNOWN == p_ui_ctrl->box_state_future)) { + box_state = p_ui_ctrl->box_state; + p_ui_ctrl->box_state_future = IBRT_BOX_UNKNOWN; + } else { + TRACE(2, + "event queue not empty, use future box state to judge, rear=%d, " + "front=%d", + p_ui_ctrl->event_q_manager.rear, p_ui_ctrl->event_q_manager.front); - box_state = p_ui_ctrl->box_state_future; - } + box_state = p_ui_ctrl->box_state_future; + } - TRACE(1,"ibrt_ui_log:current box state=%s", g_log_box_state_str[box_state]); + TRACE(1, "ibrt_ui_log:current box state=%s", g_log_box_state_str[box_state]); #ifdef IBRT_SEARCH_UI - return false; + return false; #else - switch (evt_type) - { - case IBRT_OPEN_BOX_EVENT: - return (box_state != IBRT_IN_BOX_CLOSED); + switch (evt_type) { + case IBRT_OPEN_BOX_EVENT: + return (box_state != IBRT_IN_BOX_CLOSED); - case IBRT_FETCH_OUT_EVENT: - return (box_state != IBRT_IN_BOX_OPEN); + case IBRT_FETCH_OUT_EVENT: + return (box_state != IBRT_IN_BOX_OPEN); - case IBRT_PUT_IN_EVENT: - return (box_state != IBRT_OUT_BOX); + case IBRT_PUT_IN_EVENT: + return (box_state != IBRT_OUT_BOX); - case IBRT_CLOSE_BOX_EVENT: - return (box_state != IBRT_IN_BOX_OPEN); + case IBRT_CLOSE_BOX_EVENT: + return (box_state != IBRT_IN_BOX_OPEN); - case IBRT_WEAR_UP_EVENT: - return (box_state != IBRT_OUT_BOX); + case IBRT_WEAR_UP_EVENT: + return (box_state != IBRT_OUT_BOX); - case IBRT_WEAR_DOWN_EVENT: - return (box_state != IBRT_OUT_BOX_WEARED); + case IBRT_WEAR_DOWN_EVENT: + return (box_state != IBRT_OUT_BOX_WEARED); - default: - break; - } - return false; + default: + break; + } + return false; #endif } -void app_ibrt_if_sco_lowlatency_scan(uint16_t interval, uint16_t window, uint8_t interlanced) -{ - app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); - TRACE(3,"ibrt_ui_log:custom pscan int 0x%02x win 0x%02x type %d\n", interval, window, interlanced); - p_ibrt_ui->pscan_cust_interval = interval; - p_ibrt_ui->pscan_cust_window = window; - p_ibrt_ui->pscan_cust_type = interlanced; - app_ibrt_ui_judge_scan_type(IBRT_SCO_PLAYING_TRIGGER, NO_LINK_TYPE, IBRT_UI_NO_ERROR); +void app_ibrt_if_sco_lowlatency_scan(uint16_t interval, uint16_t window, + uint8_t interlanced) { + app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); + TRACE(3, "ibrt_ui_log:custom pscan int 0x%02x win 0x%02x type %d\n", interval, + window, interlanced); + p_ibrt_ui->pscan_cust_interval = interval; + p_ibrt_ui->pscan_cust_window = window; + p_ibrt_ui->pscan_cust_type = interlanced; + app_ibrt_ui_judge_scan_type(IBRT_SCO_PLAYING_TRIGGER, NO_LINK_TYPE, + IBRT_UI_NO_ERROR); } -void app_ibrt_if_sco_restore_scan(void) -{ - TRACE(0,"ibrt_ui_log:restore pscan\n"); - app_ibrt_ui_judge_scan_type(IBRT_SCO_SUSPEND_TRIGGER, NO_LINK_TYPE, IBRT_UI_NO_ERROR); +void app_ibrt_if_sco_restore_scan(void) { + TRACE(0, "ibrt_ui_log:restore pscan\n"); + app_ibrt_ui_judge_scan_type(IBRT_SCO_SUSPEND_TRIGGER, NO_LINK_TYPE, + IBRT_UI_NO_ERROR); } -void app_ibrt_if_a2dp_lowlatency_scan(uint16_t interval, uint16_t window, uint8_t interlanced) -{ - app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); - TRACE(3,"ibrt_ui_log:custom pscan int 0x%02x win 0x%02x type %d\n", interval, window, interlanced); - p_ibrt_ui->pscan_cust_interval = interval; - p_ibrt_ui->pscan_cust_window = window; - p_ibrt_ui->pscan_cust_type = interlanced; - app_ibrt_ui_judge_scan_type(IBRT_A2DP_PLAYING_TRIGGER, NO_LINK_TYPE, IBRT_UI_NO_ERROR); +void app_ibrt_if_a2dp_lowlatency_scan(uint16_t interval, uint16_t window, + uint8_t interlanced) { + app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); + TRACE(3, "ibrt_ui_log:custom pscan int 0x%02x win 0x%02x type %d\n", interval, + window, interlanced); + p_ibrt_ui->pscan_cust_interval = interval; + p_ibrt_ui->pscan_cust_window = window; + p_ibrt_ui->pscan_cust_type = interlanced; + app_ibrt_ui_judge_scan_type(IBRT_A2DP_PLAYING_TRIGGER, NO_LINK_TYPE, + IBRT_UI_NO_ERROR); } -void app_ibrt_if_a2dp_restore_scan(void) -{ - TRACE(0,"ibrt_ui_log:restore pscan\n"); - app_ibrt_ui_judge_scan_type(IBRT_A2DP_SUSPEND_TRIGGER, NO_LINK_TYPE, IBRT_UI_NO_ERROR); +void app_ibrt_if_a2dp_restore_scan(void) { + TRACE(0, "ibrt_ui_log:restore pscan\n"); + app_ibrt_ui_judge_scan_type(IBRT_A2DP_SUSPEND_TRIGGER, NO_LINK_TYPE, + IBRT_UI_NO_ERROR); } /*check if tws link reconnect is allowed*/ -bool app_ibrt_if_tws_reconnect_allowed(void) -{ - app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); +bool app_ibrt_if_tws_reconnect_allowed(void) { + app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); - if (app_ibrt_ui_is_box_closed()) - { - TRACE(2," connect tws disallowed_1, box_state=%d, f_box_state=%d",\ - p_ibrt_ui->box_state, p_ibrt_ui->box_state_future); - return false; - } - else if (app_tws_ibrt_mobile_link_connected() && \ - app_ibrt_if_is_audio_active()) - { + if (app_ibrt_ui_is_box_closed()) { + TRACE(2, " connect tws disallowed_1, box_state=%d, f_box_state=%d", + p_ibrt_ui->box_state, p_ibrt_ui->box_state_future); + return false; + } else if (app_tws_ibrt_mobile_link_connected() && + app_ibrt_if_is_audio_active()) { - TRACE(2," connect tws disallowed_2, box_state=%d, f_box_state=%d",\ - p_ibrt_ui->box_state, p_ibrt_ui->box_state_future); - return false; - } - else - { - TRACE(0," connect tws allowed"); - return true; - } + TRACE(2, " connect tws disallowed_2, box_state=%d, f_box_state=%d", + p_ibrt_ui->box_state, p_ibrt_ui->box_state_future); + return false; + } else { + TRACE(0, " connect tws allowed"); + return true; + } } -void app_ibrt_if_sniff_event_callback(const btif_event_t *event) -{ +void app_ibrt_if_sniff_event_callback(const btif_event_t *event) {} +void app_ibrt_if_audio_mute(void) {} + +void app_ibrt_if_audio_recover(void) {} + +int app_ibrt_if_tws_sniff_block(uint32_t block_next_sec) { + tws_sniff_block_start = hal_sys_timer_get(); + tws_sniff_block_next_sec = block_next_sec; + return 0; } -void app_ibrt_if_audio_mute(void) -{ +static bool app_ibrt_if_tws_sniff_block_need(void) { + bool tws_sniff_block = false; + uint32_t passed_ticks = 0; + if (tws_sniff_block_start) { + tws_sniff_block = true; + passed_ticks = + hal_timer_get_passed_ticks(hal_sys_timer_get(), tws_sniff_block_start); + if (TICKS_TO_MS(passed_ticks) > (tws_sniff_block_next_sec * 1000)) { + tws_sniff_block_start = 0; + tws_sniff_block_next_sec = 0; + tws_sniff_block = false; + } + } else { + tws_sniff_block = false; + } + + return tws_sniff_block; } -void app_ibrt_if_audio_recover(void) -{ - -} - -int app_ibrt_if_tws_sniff_block(uint32_t block_next_sec) -{ - tws_sniff_block_start = hal_sys_timer_get(); - tws_sniff_block_next_sec = block_next_sec; - return 0; -} - -static bool app_ibrt_if_tws_sniff_block_need(void) -{ - bool tws_sniff_block = false; - uint32_t passed_ticks = 0; - - if (tws_sniff_block_start) - { - tws_sniff_block = true; - passed_ticks = hal_timer_get_passed_ticks(hal_sys_timer_get(), tws_sniff_block_start); - if (TICKS_TO_MS(passed_ticks) > (tws_sniff_block_next_sec * 1000)) - { - tws_sniff_block_start = 0; - tws_sniff_block_next_sec = 0; - tws_sniff_block = false; - } - } - else - { - tws_sniff_block = false; - } - - return tws_sniff_block; -} - -bool app_ibrt_if_tws_sniff_allowed(void) -{ - btif_avdtp_stream_state_t a2dp_state = BTIF_AVDTP_STRM_STATE_IDLE; - if (app_bt_get_mobile_a2dp_stream(BTIF_DEVICE_ID_1)) - { - a2dp_state = btif_a2dp_get_stream_state(app_bt_get_mobile_a2dp_stream(BTIF_DEVICE_ID_1)); - } - if (a2dp_state == BTIF_AVDTP_STRM_STATE_STREAMING || - btapp_hfp_is_sco_active() || - btapp_hfp_get_call_state() || - btapp_hfp_get_call_setup() != BTIF_HF_CALL_SETUP_NONE || - bt_media_cur_is_bt_stream_media()|| - app_ibrt_if_tws_sniff_block_need() || - app_ibrt_ui_wait_ibrt_connected() - #if defined(IBRT_OTA) - || ota_is_in_progress() - #endif - #ifdef TEST_OVER_THE_AIR_ENANBLED - || spp_tota_in_progress() - #endif - ) - { - TRACE(0,"ibrt_ui_log:sniff not allow\n"); - return false; - } - else - { - TRACE(0,"ibrt_ui_log:sniff allowed\n"); - return true; - } +bool app_ibrt_if_tws_sniff_allowed(void) { + btif_avdtp_stream_state_t a2dp_state = BTIF_AVDTP_STRM_STATE_IDLE; + if (app_bt_get_mobile_a2dp_stream(BTIF_DEVICE_ID_1)) { + a2dp_state = btif_a2dp_get_stream_state( + app_bt_get_mobile_a2dp_stream(BTIF_DEVICE_ID_1)); + } + if (a2dp_state == BTIF_AVDTP_STRM_STATE_STREAMING || + btapp_hfp_is_sco_active() || btapp_hfp_get_call_state() || + btapp_hfp_get_call_setup() != BTIF_HF_CALL_SETUP_NONE || + bt_media_cur_is_bt_stream_media() || app_ibrt_if_tws_sniff_block_need() || + app_ibrt_ui_wait_ibrt_connected() +#if defined(IBRT_OTA) + || ota_is_in_progress() +#endif +#ifdef TEST_OVER_THE_AIR_ENANBLED + || spp_tota_in_progress() +#endif + ) { + TRACE(0, "ibrt_ui_log:sniff not allow\n"); + return false; + } else { + TRACE(0, "ibrt_ui_log:sniff allowed\n"); + return true; + } } #define IBRT_IF_SNIFF_CHECKER_INTERVAL_MS (3000) static void app_ibrt_if_sniff_checker_handler(void const *param); osTimerDef(APP_IBRT_IF_SNIFF_CHECKER_TIMER, app_ibrt_if_sniff_checker_handler); static osTimerId app_ibrt_if_sniff_checker_timer = NULL; -static uint32_t app_ibrt_if_sniff_checker_interval_ms = IBRT_IF_SNIFF_CHECKER_INTERVAL_MS; +static uint32_t app_ibrt_if_sniff_checker_interval_ms = + IBRT_IF_SNIFF_CHECKER_INTERVAL_MS; static uint32_t app_ibrt_if_sniff_checker_user_map = 0; -static void app_ibrt_if_sniff_checker_handler(void const *param) -{ - app_ibrt_if_ctrl_t *p_ibrt_ctrl = app_ibrt_if_get_bt_ctrl_ctx(); - if (app_ibrt_if_tws_sniff_allowed()) - { - app_ibrt_if_sniff_checker_reset(); - } - else - { - if (app_tws_ibrt_mobile_link_connected()) - { - if (p_ibrt_ctrl->mobile_mode == IBRT_SNIFF_MODE) - { - TRACE(0,"ibrt_ui_log:force exit_sniff_with_mobile\n"); - app_tws_ibrt_exit_sniff_with_mobile(); - } - if (p_ibrt_ctrl->tws_mode == IBRT_SNIFF_MODE) - { - TRACE(0,"ibrt_ui_log:force exit_sniff_with_tws\n"); - app_tws_ibrt_exit_sniff_with_tws(); - } - osTimerStart(app_ibrt_if_sniff_checker_timer, app_ibrt_if_sniff_checker_interval_ms); - } - else if(app_tws_ibrt_slave_ibrt_link_connected()) - { - osTimerStart(app_ibrt_if_sniff_checker_timer, app_ibrt_if_sniff_checker_interval_ms); - } - else - { - app_ibrt_if_sniff_checker_reset(); - } +static void app_ibrt_if_sniff_checker_handler(void const *param) { + app_ibrt_if_ctrl_t *p_ibrt_ctrl = app_ibrt_if_get_bt_ctrl_ctx(); + if (app_ibrt_if_tws_sniff_allowed()) { + app_ibrt_if_sniff_checker_reset(); + } else { + if (app_tws_ibrt_mobile_link_connected()) { + if (p_ibrt_ctrl->mobile_mode == IBRT_SNIFF_MODE) { + TRACE(0, "ibrt_ui_log:force exit_sniff_with_mobile\n"); + app_tws_ibrt_exit_sniff_with_mobile(); + } + if (p_ibrt_ctrl->tws_mode == IBRT_SNIFF_MODE) { + TRACE(0, "ibrt_ui_log:force exit_sniff_with_tws\n"); + app_tws_ibrt_exit_sniff_with_tws(); + } + osTimerStart(app_ibrt_if_sniff_checker_timer, + app_ibrt_if_sniff_checker_interval_ms); + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + osTimerStart(app_ibrt_if_sniff_checker_timer, + app_ibrt_if_sniff_checker_interval_ms); + } else { + app_ibrt_if_sniff_checker_reset(); } + } } -int app_ibrt_if_sniff_checker_init(uint32_t delay_ms) -{ - TRACE(1,"ibrt_ui_log:sniff_checker_init interval:%d \n", delay_ms); - if (app_ibrt_if_sniff_checker_timer == NULL) - { - app_ibrt_if_sniff_checker_timer = osTimerCreate(osTimer(APP_IBRT_IF_SNIFF_CHECKER_TIMER), osTimerOnce, NULL); +int app_ibrt_if_sniff_checker_init(uint32_t delay_ms) { + TRACE(1, "ibrt_ui_log:sniff_checker_init interval:%d \n", delay_ms); + if (app_ibrt_if_sniff_checker_timer == NULL) { + app_ibrt_if_sniff_checker_timer = osTimerCreate( + osTimer(APP_IBRT_IF_SNIFF_CHECKER_TIMER), osTimerOnce, NULL); + } + app_ibrt_if_sniff_checker_interval_ms = delay_ms; + app_ibrt_if_sniff_checker_user_map = 0; + return 0; +} + +int app_ibrt_if_sniff_checker_start( + enum APP_IBRT_IF_SNIFF_CHECKER_USER_T user) { + if (app_ibrt_if_sniff_checker_timer) { + TRACE(1, "ibrt_ui_log:sniff_checker_start usr:%d\n", user); + app_ibrt_if_sniff_checker_user_map |= (1 << user); + osTimerStart(app_ibrt_if_sniff_checker_timer, + app_ibrt_if_sniff_checker_interval_ms); + } + return 0; +} + +int app_ibrt_if_sniff_checker_stop(enum APP_IBRT_IF_SNIFF_CHECKER_USER_T user) { + if (app_ibrt_if_sniff_checker_timer) { + app_ibrt_if_sniff_checker_user_map &= ~(1 << user); + if (!app_ibrt_if_sniff_checker_user_map) { + TRACE(1, "ibrt_ui_log:sniff_checker_stop usr:%d\n", user); + osTimerStop(app_ibrt_if_sniff_checker_timer); } - app_ibrt_if_sniff_checker_interval_ms = delay_ms; + } + return 0; +} + +int app_ibrt_if_sniff_checker_reset(void) { + if (app_ibrt_if_sniff_checker_timer) { + TRACE(0, "ibrt_ui_log:sniff_checker_reset\n"); app_ibrt_if_sniff_checker_user_map = 0; - return 0; -} - -int app_ibrt_if_sniff_checker_start(enum APP_IBRT_IF_SNIFF_CHECKER_USER_T user) -{ - if (app_ibrt_if_sniff_checker_timer) - { - TRACE(1,"ibrt_ui_log:sniff_checker_start usr:%d\n", user); - app_ibrt_if_sniff_checker_user_map |= (1 << user); - osTimerStart(app_ibrt_if_sniff_checker_timer, app_ibrt_if_sniff_checker_interval_ms); - } - return 0; -} - -int app_ibrt_if_sniff_checker_stop(enum APP_IBRT_IF_SNIFF_CHECKER_USER_T user) -{ - if (app_ibrt_if_sniff_checker_timer) - { - app_ibrt_if_sniff_checker_user_map &= ~(1 << user); - if (!app_ibrt_if_sniff_checker_user_map) - { - TRACE(1,"ibrt_ui_log:sniff_checker_stop usr:%d\n", user); - osTimerStop(app_ibrt_if_sniff_checker_timer); - } - } - return 0; -} - -int app_ibrt_if_sniff_checker_reset(void) -{ - if (app_ibrt_if_sniff_checker_timer) - { - TRACE(0,"ibrt_ui_log:sniff_checker_reset\n"); - app_ibrt_if_sniff_checker_user_map = 0; - osTimerStop(app_ibrt_if_sniff_checker_timer); - } - return 0; + osTimerStop(app_ibrt_if_sniff_checker_timer); + } + return 0; } static uint32_t sleep_hook_blocker = 0; -void app_ibrt_if_exec_sleep_hook_blocker_set(APP_IBRT_IF_SLEEP_HOOK_BLOCKER_T blocker) -{ - sleep_hook_blocker |= (uint32_t)blocker; +void app_ibrt_if_exec_sleep_hook_blocker_set( + APP_IBRT_IF_SLEEP_HOOK_BLOCKER_T blocker) { + sleep_hook_blocker |= (uint32_t)blocker; } -void app_ibrt_if_exec_sleep_hook_blocker_clr(APP_IBRT_IF_SLEEP_HOOK_BLOCKER_T blocker) -{ - sleep_hook_blocker &= ~(uint32_t)blocker; +void app_ibrt_if_exec_sleep_hook_blocker_clr( + APP_IBRT_IF_SLEEP_HOOK_BLOCKER_T blocker) { + sleep_hook_blocker &= ~(uint32_t)blocker; } -bool app_ibrt_if_exec_sleep_hook_blocker_is_hfp_sco(void) -{ - return sleep_hook_blocker & APP_IBRT_IF_SLEEP_HOOK_BLOCKER_HFP_SCO ? true : false; +bool app_ibrt_if_exec_sleep_hook_blocker_is_hfp_sco(void) { + return sleep_hook_blocker & APP_IBRT_IF_SLEEP_HOOK_BLOCKER_HFP_SCO ? true + : false; } -bool app_ibrt_if_exec_sleep_hook_blocker_is_a2dp_streaming(void) -{ - return sleep_hook_blocker & APP_IBRT_IF_SLEEP_HOOK_BLOCKER_A2DP_STREAMING ? true : false; +bool app_ibrt_if_exec_sleep_hook_blocker_is_a2dp_streaming(void) { + return sleep_hook_blocker & APP_IBRT_IF_SLEEP_HOOK_BLOCKER_A2DP_STREAMING + ? true + : false; } -bool app_ibrt_if_exec_sleep_hook_allowed(void) -{ - if (!sleep_hook_blocker) - { - return true; +bool app_ibrt_if_exec_sleep_hook_allowed(void) { + if (!sleep_hook_blocker) { + return true; + } + return false; +} + +void app_ibrt_ui_adaptive_fa_rx_gain(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (app_tws_ibrt_tws_link_connected()) { + rx_agc_t tws_agc = {0}; + bt_drv_reg_op_read_rssi_in_dbm(p_ibrt_ctrl->tws_conhandle, &tws_agc); + static int8_t old_tws_rssi = tws_agc.rssi; + if (tws_agc.rssi != old_tws_rssi) { + bt_drv_adaptive_fa_rx_gain(tws_agc.rssi); + old_tws_rssi = tws_agc.rssi; } - return false; + } } -void app_ibrt_ui_adaptive_fa_rx_gain(void) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if(app_tws_ibrt_tws_link_connected()) - { - rx_agc_t tws_agc = {0}; - bt_drv_reg_op_read_rssi_in_dbm(p_ibrt_ctrl->tws_conhandle,&tws_agc); - static int8_t old_tws_rssi = tws_agc.rssi; - if(tws_agc.rssi != old_tws_rssi) - { - bt_drv_adaptive_fa_rx_gain(tws_agc.rssi); - old_tws_rssi = tws_agc.rssi; - } - } +void app_tws_ibrt_record_sync_id(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + uint8_t sync_id = bt_drv_reg_op_get_sync_id_op(READ_OP, 0); + if (is_sco_mode() && sync_id != 0xff) { + uint16_t sync_id_mask = (1 << 8) | (sync_id & 0xff); + TRACE(3, "%s:sync id=%d, mask=0x%x", __func__, sync_id, sync_id_mask); + p_ibrt_ctrl->sync_id_mask = sync_id_mask; + } } -void app_tws_ibrt_record_sync_id(void) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - uint8_t sync_id = bt_drv_reg_op_get_sync_id_op(READ_OP, 0); - if(is_sco_mode() && sync_id != 0xff) - { - uint16_t sync_id_mask = (1<<8)|(sync_id&0xff); - TRACE(3,"%s:sync id=%d, mask=0x%x",__func__, sync_id, sync_id_mask); - p_ibrt_ctrl->sync_id_mask = sync_id_mask; +void app_tws_ibrt_resume_sync_id(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + uint8_t sync_id_mask = p_ibrt_ctrl->sync_id_mask >> 8; + uint8_t sync_id = p_ibrt_ctrl->sync_id_mask & 0xff; + if (sync_id_mask) { + p_ibrt_ctrl->sync_id_mask = 0; + if (is_sco_mode() && (sync_id != 0xff)) { + TRACE(2, "%s: sync id=%d", __func__, sync_id); + bt_drv_reg_op_get_sync_id_op(WRITE_OP, sync_id); } + } } -void app_tws_ibrt_resume_sync_id(void) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - uint8_t sync_id_mask = p_ibrt_ctrl->sync_id_mask>>8; - uint8_t sync_id = p_ibrt_ctrl->sync_id_mask&0xff; - if (sync_id_mask) - { - p_ibrt_ctrl->sync_id_mask = 0; - if(is_sco_mode() && (sync_id != 0xff)) - { - TRACE(2,"%s: sync id=%d",__func__, sync_id); - bt_drv_reg_op_get_sync_id_op(WRITE_OP, sync_id); - } - } +bool app_ibrt_if_start_ibrt_onporcess(void) { + app_ibrt_if_ui_t *p_ibrt_ui_ctx = app_ibrt_if_ui_get_ctx(); + if (p_ibrt_ui_ctx->super_state == IBRT_UI_W4_SET_ENV_COMPLETE) { + return true; + } + + if (p_ibrt_ui_ctx->super_state == IBRT_UI_W4_START_IBRT_COMPLETE) { + return true; + } + + if (p_ibrt_ui_ctx->super_state == IBRT_UI_W4_IBRT_DATA_EXCHANGE_COMPLETE) { + return true; + } + + return false; } -bool app_ibrt_if_start_ibrt_onporcess(void) -{ - app_ibrt_if_ui_t *p_ibrt_ui_ctx = app_ibrt_if_ui_get_ctx(); - if (p_ibrt_ui_ctx->super_state == IBRT_UI_W4_SET_ENV_COMPLETE) - { - return true; - } +bool app_ibrt_if_tws_switch_onporcess(void) { + app_ibrt_if_ui_t *p_ibrt_ui_ctx = app_ibrt_if_ui_get_ctx(); + if (p_ibrt_ui_ctx->super_state == IBRT_UI_W4_TWS_SWITCH_COMPLETE) { + return true; + } - if (p_ibrt_ui_ctx->super_state == IBRT_UI_W4_START_IBRT_COMPLETE) - { - return true; - } - - if (p_ibrt_ui_ctx->super_state == IBRT_UI_W4_IBRT_DATA_EXCHANGE_COMPLETE) - { - return true; - } - - return false; + return false; } -bool app_ibrt_if_tws_switch_onporcess(void) -{ - app_ibrt_if_ui_t *p_ibrt_ui_ctx = app_ibrt_if_ui_get_ctx(); - if (p_ibrt_ui_ctx->super_state == IBRT_UI_W4_TWS_SWITCH_COMPLETE) - { - return true; - } - - return false; -} - -AppIbrtStatus app_ibrt_if_get_a2dp_state(AppIbrtA2dpState *a2dp_state) -{ - if(app_tws_ibrt_mobile_link_connected() ||app_tws_ibrt_slave_ibrt_link_connected()) - { +AppIbrtStatus app_ibrt_if_get_a2dp_state(AppIbrtA2dpState *a2dp_state) { + if (app_tws_ibrt_mobile_link_connected() || + app_tws_ibrt_slave_ibrt_link_connected()) { #if defined(A2DP_AAC_ON) - if (btif_a2dp_get_stream_state(app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream) > BTIF_AVDTP_STRM_STATE_IDLE) - { - if(a2dp_state != NULL) - { - *a2dp_state = (AppIbrtA2dpState)btif_a2dp_get_stream_state(app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream); - } - } + if (btif_a2dp_get_stream_state( + app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream) > + BTIF_AVDTP_STRM_STATE_IDLE) { + if (a2dp_state != NULL) { + *a2dp_state = (AppIbrtA2dpState)btif_a2dp_get_stream_state( + app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream); + } + } #else - if(0); + if (0) + ; #endif - else if(btif_a2dp_get_stream_state(app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream) > BTIF_AVDTP_STRM_STATE_IDLE) - { - if(a2dp_state != NULL) - { - *a2dp_state = (AppIbrtA2dpState)btif_a2dp_get_stream_state(app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream); - } - } - else - { - if(a2dp_state != NULL) - { - *a2dp_state = APP_IBRT_IF_A2DP_IDLE; - } - } + else if (btif_a2dp_get_stream_state( + app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream) > + BTIF_AVDTP_STRM_STATE_IDLE) { + if (a2dp_state != NULL) { + *a2dp_state = (AppIbrtA2dpState)btif_a2dp_get_stream_state( + app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream); + } + } else { + if (a2dp_state != NULL) { + *a2dp_state = APP_IBRT_IF_A2DP_IDLE; + } } - else - { - if(a2dp_state != NULL) - { - *a2dp_state = APP_IBRT_IF_A2DP_IDLE; - } + } else { + if (a2dp_state != NULL) { + *a2dp_state = APP_IBRT_IF_A2DP_IDLE; } + } - return APP_IBRT_IF_STATUS_SUCCESS; + return APP_IBRT_IF_STATUS_SUCCESS; } - -AppIbrtStatus app_ibrt_if_get_avrcp_state(AppIbrtAvrcpState *avrcp_state) -{ - if(BTIF_AVRCP_STATE_DISCONNECTED != app_bt_device.avrcp_state[BT_DEVICE_ID_1]) - { - if(avrcp_state != NULL) - { - if(avrcp_get_media_status() == BTIF_AVRCP_MEDIA_PLAYING) - { - *avrcp_state = APP_IBRT_IF_AVRCP_PLAYING; - } - else if(avrcp_get_media_status() == BTIF_AVRCP_MEDIA_PAUSED) - { - *avrcp_state = APP_IBRT_IF_AVRCP_PAUSED; - } - else - { - *avrcp_state = APP_IBRT_IF_AVRCP_CONNECTED; - } - } +AppIbrtStatus app_ibrt_if_get_avrcp_state(AppIbrtAvrcpState *avrcp_state) { + if (BTIF_AVRCP_STATE_DISCONNECTED != + app_bt_device.avrcp_state[BT_DEVICE_ID_1]) { + if (avrcp_state != NULL) { + if (avrcp_get_media_status() == BTIF_AVRCP_MEDIA_PLAYING) { + *avrcp_state = APP_IBRT_IF_AVRCP_PLAYING; + } else if (avrcp_get_media_status() == BTIF_AVRCP_MEDIA_PAUSED) { + *avrcp_state = APP_IBRT_IF_AVRCP_PAUSED; + } else { + *avrcp_state = APP_IBRT_IF_AVRCP_CONNECTED; + } } - else - { - if(avrcp_state != NULL) - { - *avrcp_state = APP_IBRT_IF_AVRCP_DISCONNECTED; - } + } else { + if (avrcp_state != NULL) { + *avrcp_state = APP_IBRT_IF_AVRCP_DISCONNECTED; } - return APP_IBRT_IF_STATUS_SUCCESS; + } + return APP_IBRT_IF_STATUS_SUCCESS; } - -AppIbrtStatus app_ibrt_if_get_hfp_state(AppIbrtHfpState *hfp_state) -{ - if(btif_get_hf_chan_state(app_bt_device.hf_channel[BT_DEVICE_ID_1]) == BTIF_HF_STATE_OPEN) - { - if(app_bt_device.hf_audio_state[BT_DEVICE_ID_1] == BTIF_HF_AUDIO_CON) - { - if(hfp_state != NULL) - { - *hfp_state = APP_IBRT_IF_HFP_SCO_OPEN; - } - } - else - { - if(hfp_state != NULL) - { - *hfp_state = APP_IBRT_IF_HFP_SCO_CLOSED; - } - } +AppIbrtStatus app_ibrt_if_get_hfp_state(AppIbrtHfpState *hfp_state) { + if (btif_get_hf_chan_state(app_bt_device.hf_channel[BT_DEVICE_ID_1]) == + BTIF_HF_STATE_OPEN) { + if (app_bt_device.hf_audio_state[BT_DEVICE_ID_1] == BTIF_HF_AUDIO_CON) { + if (hfp_state != NULL) { + *hfp_state = APP_IBRT_IF_HFP_SCO_OPEN; + } + } else { + if (hfp_state != NULL) { + *hfp_state = APP_IBRT_IF_HFP_SCO_CLOSED; + } } - else - { - if(hfp_state != NULL) - { - *hfp_state = APP_IBRT_IF_HFP_SLC_DISCONNECTED; - } + } else { + if (hfp_state != NULL) { + *hfp_state = APP_IBRT_IF_HFP_SLC_DISCONNECTED; } - return APP_IBRT_IF_STATUS_SUCCESS; + } + return APP_IBRT_IF_STATUS_SUCCESS; } -AppIbrtStatus app_ibrt_if_get_hfp_call_status(AppIbrtCallStatus *call_status) -{ - if(call_status == NULL) - { - return APP_IBRT_IF_STATUS_ERROR_INVALID_PARAMETERS; - } +AppIbrtStatus app_ibrt_if_get_hfp_call_status(AppIbrtCallStatus *call_status) { + if (call_status == NULL) { + return APP_IBRT_IF_STATUS_ERROR_INVALID_PARAMETERS; + } - if (app_bt_device.hfchan_callSetup[BT_DEVICE_ID_1] == BTIF_HF_CALL_SETUP_IN) - { - *call_status = APP_IBRT_IF_SETUP_INCOMMING; - } - else if(app_bt_device.hfchan_callSetup[BT_DEVICE_ID_1] == BTIF_HF_CALL_SETUP_OUT) - { - *call_status = APP_IBRT_IF_SETUP_OUTGOING; - } - else if(app_bt_device.hfchan_callSetup[BT_DEVICE_ID_1] == BTIF_HF_CALL_SETUP_ALERT) - { - *call_status = APP_IBRT_IF_SETUP_ALERT; - } - else if((app_bt_device.hfchan_call[BT_DEVICE_ID_1] == BTIF_HF_CALL_ACTIVE) \ - && (app_bt_device.hf_audio_state[BT_DEVICE_ID_1] == BTIF_HF_AUDIO_CON) - ) - { - *call_status = APP_IBRT_IF_CALL_ACTIVE; - } - else if(app_bt_device.hf_callheld[BT_DEVICE_ID_1] == BTIF_HF_CALL_HELD_ACTIVE) - { - *call_status = APP_IBRT_IF_HOLD; - } - else - { - *call_status = APP_IBRT_IF_NO_CALL; - } + if (app_bt_device.hfchan_callSetup[BT_DEVICE_ID_1] == BTIF_HF_CALL_SETUP_IN) { + *call_status = APP_IBRT_IF_SETUP_INCOMMING; + } else if (app_bt_device.hfchan_callSetup[BT_DEVICE_ID_1] == + BTIF_HF_CALL_SETUP_OUT) { + *call_status = APP_IBRT_IF_SETUP_OUTGOING; + } else if (app_bt_device.hfchan_callSetup[BT_DEVICE_ID_1] == + BTIF_HF_CALL_SETUP_ALERT) { + *call_status = APP_IBRT_IF_SETUP_ALERT; + } else if ((app_bt_device.hfchan_call[BT_DEVICE_ID_1] == + BTIF_HF_CALL_ACTIVE) && + (app_bt_device.hf_audio_state[BT_DEVICE_ID_1] == + BTIF_HF_AUDIO_CON)) { + *call_status = APP_IBRT_IF_CALL_ACTIVE; + } else if (app_bt_device.hf_callheld[BT_DEVICE_ID_1] == + BTIF_HF_CALL_HELD_ACTIVE) { + *call_status = APP_IBRT_IF_HOLD; + } else { + *call_status = APP_IBRT_IF_NO_CALL; + } - return APP_IBRT_IF_STATUS_SUCCESS; + return APP_IBRT_IF_STATUS_SUCCESS; } +ibrt_role_e app_ibrt_if_get_ibrt_role() { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); -ibrt_role_e app_ibrt_if_get_ibrt_role() -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - - return (p_ibrt_ctrl->current_role); + return (p_ibrt_ctrl->current_role); } - #endif diff --git a/services/app_ibrt/src/app_ibrt_keyboard.cpp b/services/app_ibrt/src/app_ibrt_keyboard.cpp index 42ffb6d..3629566 100644 --- a/services/app_ibrt/src/app_ibrt_keyboard.cpp +++ b/services/app_ibrt/src/app_ibrt_keyboard.cpp @@ -13,29 +13,29 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "cmsis_os.h" -#include #include "app_ibrt_keyboard.h" -#include "app_tws_ibrt_trace.h" +#include "anc_wnr.h" +#include "app_anc.h" +#include "app_bt.h" +#include "app_factory_bt.h" #include "app_ibrt_if.h" #include "app_ibrt_ui_test.h" -#include "app_tws_ibrt_cmd_handler.h" #include "app_tws_ctrl_thread.h" -#include "btapp.h" -#include "apps.h" +#include "app_tws_ibrt_cmd_handler.h" +#include "app_tws_ibrt_trace.h" #include "app_tws_if.h" -#include "app_anc.h" -#include "anc_wnr.h" -#include "app_bt.h" -#include "norflash_api.h" +#include "apps.h" +#include "btapp.h" +#include "cmsis_os.h" #include "hal_bootmode.h" +#include "norflash_api.h" #include "pmu.h" -#include "app_factory_bt.h" +#include #if defined(IBRT) #ifdef TILE_DATAPATH extern "C" void app_tile_key_handler(APP_KEY_STATUS *status, void *param); #endif -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; extern void app_bt_volumedown(); extern void app_bt_volumeup(); extern void app_otaMode_enter(APP_KEY_STATUS *status, void *param); @@ -48,40 +48,33 @@ extern void app_ibrt_simulate_charger_plug_out_test(void); static bool qxw_dut_mode_enable = false; #ifdef IBRT_SEARCH_UI -void app_ibrt_search_ui_handle_key(APP_KEY_STATUS *status, void *param) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - TRACE(3,"%s %d,%d",__func__, status->code, status->event); +void app_ibrt_search_ui_handle_key(APP_KEY_STATUS *status, void *param) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + TRACE(3, "%s %d,%d", __func__, status->code, status->event); + if (APP_KEY_CODE_GOOGLE != status->code) { + switch (status->event) { + case APP_KEY_EVENT_CLICK: + app_tws_if_handle_click(); + break; - if (APP_KEY_CODE_GOOGLE != status->code) - { - switch(status->event) - { - case APP_KEY_EVENT_CLICK: - app_tws_if_handle_click(); - break; - - case APP_KEY_EVENT_DOUBLECLICK: - TRACE(0,"double kill"); - if(IBRT_UNKNOW==p_ibrt_ctrl->current_role) - { - app_start_tws_serching_direactly(); - } - else - { + case APP_KEY_EVENT_DOUBLECLICK: + TRACE(0, "double kill"); + if (IBRT_UNKNOW == p_ibrt_ctrl->current_role) { + app_start_tws_serching_direactly(); + } else { #if defined(__BT_DEBUG_TPORTS__) && !defined(TPORTS_KEY_COEXIST) - app_ibrt_simulate_charger_plug_in_test(); + app_ibrt_simulate_charger_plug_in_test(); #else - bt_key_handle_func_doubleclick(); + bt_key_handle_func_doubleclick(); #endif - } - break; + } + break; - case APP_KEY_EVENT_LONGPRESS: - // dont use this key for customer release due to - // it is auto triggered by circuit of 3s high-level voltage. - bt_key_handle_func_longpress(); + case APP_KEY_EVENT_LONGPRESS: + // dont use this key for customer release due to + // it is auto triggered by circuit of 3s high-level voltage. + bt_key_handle_func_longpress(); #if 0 app_ibrt_ui_judge_scan_type(IBRT_FREEMAN_PAIR_TRIGGER,NO_LINK_TYPE, IBRT_UI_NO_ERROR); app_ibrt_ui_set_freeman_enable(); @@ -95,308 +88,274 @@ void app_ibrt_search_ui_handle_key(APP_KEY_STATUS *status, void *param) } #endif #if defined(__BT_DEBUG_TPORTS__) && !defined(TPORTS_KEY_COEXIST) - app_ibrt_simulate_charger_plug_out_test(); + app_ibrt_simulate_charger_plug_out_test(); #endif - break; + break; - case APP_KEY_EVENT_TRIPLECLICK: - //bt_key_handle_func_tripleclick(); - /*#ifdef TILE_DATAPATH - app_tile_key_handler(status,NULL); - #else - app_otaMode_enter(NULL,NULL); - #endif*/ - break; - case HAL_KEY_EVENT_LONGLONGPRESS: - TRACE(0,"long long press"); - //if(qxw_dut_mode_enable){ - // qxw_dut_mode_enable = false; - app_bt_power_off_customize(); - - ///} - break; + case APP_KEY_EVENT_TRIPLECLICK: + // bt_key_handle_func_tripleclick(); + /*#ifdef TILE_DATAPATH + app_tile_key_handler(status,NULL); + #else + app_otaMode_enter(NULL,NULL); + #endif*/ + break; + case HAL_KEY_EVENT_LONGLONGPRESS: + TRACE(0, "long long press"); + // if(qxw_dut_mode_enable){ + // qxw_dut_mode_enable = false; + app_bt_power_off_customize(); - case APP_KEY_EVENT_ULTRACLICK: - TRACE(0,"ultra kill"); - if(IBRT_UNKNOW==p_ibrt_ctrl->nv_role){ - app_bt_enter_mono_pairing_mode(); - } - break; + ///} + break; - case APP_KEY_EVENT_RAMPAGECLICK: - TRACE(0,"rampage kill!you are crazy!"); - if(!app_device_bt_is_connected()&&(!app_tws_ibrt_tws_link_connected())){ - app_nvrecord_rebuild(); - osDelay(200); - hal_cmu_sys_reboot(); - } - break; - case APP_KEY_EVENT_SIXTHCLICK: - if(!app_device_bt_is_connected()&&(!app_tws_ibrt_tws_link_connected())){ - qxw_dut_mode_enable = true; + case APP_KEY_EVENT_ULTRACLICK: + TRACE(0, "ultra kill"); + if (IBRT_UNKNOW == p_ibrt_ctrl->nv_role) { + app_bt_enter_mono_pairing_mode(); + } + break; + + case APP_KEY_EVENT_RAMPAGECLICK: + TRACE(0, "rampage kill!you are crazy!"); + if (!app_device_bt_is_connected() && + (!app_tws_ibrt_tws_link_connected())) { + app_nvrecord_rebuild(); + osDelay(200); + hal_cmu_sys_reboot(); + } + break; + case APP_KEY_EVENT_SIXTHCLICK: + if (!app_device_bt_is_connected() && + (!app_tws_ibrt_tws_link_connected())) { + qxw_dut_mode_enable = true; #ifdef __FACTORY_MODE_SUPORT__ - app_factorymode_bt_signalingtest(NULL,NULL); + app_factorymode_bt_signalingtest(NULL, NULL); #endif - } - break; - case APP_KEY_EVENT_EIGHTHCLICK: - if(!app_device_bt_is_connected()){ - app_otaMode_enter(NULL,NULL); - } - break; - case APP_KEY_EVENT_UP: - break; - } + } + break; + case APP_KEY_EVENT_EIGHTHCLICK: + if (!app_device_bt_is_connected()) { + app_otaMode_enter(NULL, NULL); + } + break; + case APP_KEY_EVENT_UP: + break; } + } #ifdef TILE_DATAPATH - if(APP_KEY_CODE_TILE == status->code) - app_tile_key_handler(status,NULL); + if (APP_KEY_CODE_TILE == status->code) + app_tile_key_handler(status, NULL); #endif } #endif -void app_ibrt_normal_ui_handle_key(APP_KEY_STATUS *status, void *param) -{ - if (APP_KEY_CODE_GOOGLE != status->code) - { - switch(status->event) - { - case APP_KEY_EVENT_CLICK: - TRACE(0,"first blood."); - app_tws_if_handle_click(); - break; +void app_ibrt_normal_ui_handle_key(APP_KEY_STATUS *status, void *param) { + if (APP_KEY_CODE_GOOGLE != status->code) { + switch (status->event) { + case APP_KEY_EVENT_CLICK: + TRACE(0, "first blood."); + app_tws_if_handle_click(); + break; - case APP_KEY_EVENT_DOUBLECLICK: - TRACE(0,"double kill"); - app_ibrt_if_enter_freeman_pairing(); - break; + case APP_KEY_EVENT_DOUBLECLICK: + TRACE(0, "double kill"); + app_ibrt_if_enter_freeman_pairing(); + break; - case APP_KEY_EVENT_LONGPRESS: - app_ibrt_if_enter_pairing_after_tws_connected(); - break; + case APP_KEY_EVENT_LONGPRESS: + app_ibrt_if_enter_pairing_after_tws_connected(); + break; - case APP_KEY_EVENT_TRIPLECLICK: - #ifdef TILE_DATAPATH - app_tile_key_handler(status,NULL); - #endif - break; - - case HAL_KEY_EVENT_LONGLONGPRESS: - TRACE(0,"long long press"); - break; - - case APP_KEY_EVENT_ULTRACLICK: - TRACE(0,"ultra kill"); - app_shutdown(); - break; - - case APP_KEY_EVENT_RAMPAGECLICK: - TRACE(0,"rampage kill!you are crazy!"); -#ifndef HAL_TRACE_RX_ENABLE - hal_trace_rx_reopen(); + case APP_KEY_EVENT_TRIPLECLICK: +#ifdef TILE_DATAPATH + app_tile_key_handler(status, NULL); #endif - break; + break; - case APP_KEY_EVENT_UP: - break; - } + case HAL_KEY_EVENT_LONGLONGPRESS: + TRACE(0, "long long press"); + break; + + case APP_KEY_EVENT_ULTRACLICK: + TRACE(0, "ultra kill"); + app_shutdown(); + break; + + case APP_KEY_EVENT_RAMPAGECLICK: + TRACE(0, "rampage kill!you are crazy!"); +#ifndef HAL_TRACE_RX_ENABLE + hal_trace_rx_reopen(); +#endif + break; + + case APP_KEY_EVENT_UP: + break; } + } #ifdef TILE_DATAPATH - if(APP_KEY_CODE_TILE == status->code) - app_tile_key_handler(status,NULL); + if (APP_KEY_CODE_TILE == status->code) + app_tile_key_handler(status, NULL); #endif } extern void app_ibrt_customif_test1_cmd_send(uint8_t *p_buff, uint16_t length); -int app_ibrt_if_keyboard_notify(APP_KEY_STATUS *status, void *param) -{ - if (app_tws_ibrt_slave_ibrt_link_connected()) - { - tws_ctrl_send_cmd(APP_TWS_CMD_KEYBOARD_REQUEST, (uint8_t *)status, sizeof(APP_KEY_STATUS)); - } - return 0; +int app_ibrt_if_keyboard_notify(APP_KEY_STATUS *status, void *param) { + if (app_tws_ibrt_slave_ibrt_link_connected()) { + tws_ctrl_send_cmd(APP_TWS_CMD_KEYBOARD_REQUEST, (uint8_t *)status, + sizeof(APP_KEY_STATUS)); + } + return 0; } -#if(TWS_Sync_Shutdowm) -int app_ibrt_poweroff_notify_force(void) -{ - APP_KEY_STATUS status[] = {APP_KEY_CODE_FN2,HAL_KEY_EVENT_LONGLONGPRESS}; - - if (app_tws_ibrt_tws_link_connected()) - { - app_ibrt_customif_test1_cmd_send((uint8_t *)status, sizeof(APP_KEY_STATUS)); - } - return 0; +#if (TWS_Sync_Shutdowm) +int app_ibrt_poweroff_notify_force(void) { + APP_KEY_STATUS status[] = {APP_KEY_CODE_FN2, HAL_KEY_EVENT_LONGLONGPRESS}; + + if (app_tws_ibrt_tws_link_connected()) { + app_ibrt_customif_test1_cmd_send((uint8_t *)status, sizeof(APP_KEY_STATUS)); + } + return 0; } -int app_ibrt_reboot_notify_force(void) -{ - APP_KEY_STATUS status[] = {APP_KEY_CODE_FN1,HAL_KEY_EVENT_LONGLONGPRESS}; - - if (app_tws_ibrt_tws_link_connected()) - { - app_ibrt_customif_test1_cmd_send((uint8_t *)status, sizeof(APP_KEY_STATUS)); - } - return 0; +int app_ibrt_reboot_notify_force(void) { + APP_KEY_STATUS status[] = {APP_KEY_CODE_FN1, HAL_KEY_EVENT_LONGLONGPRESS}; + + if (app_tws_ibrt_tws_link_connected()) { + app_ibrt_customif_test1_cmd_send((uint8_t *)status, sizeof(APP_KEY_STATUS)); + } + return 0; } #endif -void app_ibrt_send_keyboard_request(uint8_t *p_buff, uint16_t length) -{ - if (app_tws_ibrt_slave_ibrt_link_connected()) - { - app_ibrt_send_cmd_without_rsp(APP_TWS_CMD_KEYBOARD_REQUEST, p_buff, length); - } +void app_ibrt_send_keyboard_request(uint8_t *p_buff, uint16_t length) { + if (app_tws_ibrt_slave_ibrt_link_connected()) { + app_ibrt_send_cmd_without_rsp(APP_TWS_CMD_KEYBOARD_REQUEST, p_buff, length); + } } bool Is_Slave_Key_Down_Event = false; -void app_ibrt_keyboard_request_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - APP_KEY_STATUS *key_status=(APP_KEY_STATUS *)p_buff; - if(key_status == NULL) - return ; +void app_ibrt_keyboard_request_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + APP_KEY_STATUS *key_status = (APP_KEY_STATUS *)p_buff; + if (key_status == NULL) + return; - if (app_tws_ibrt_mobile_link_connected()) - { + if (app_tws_ibrt_mobile_link_connected()) { #ifdef IBRT_SEARCH_UI - Is_Slave_Key_Down_Event = true; - if(key_status->code==APP_KEY_CODE_PWR) - { - app_ibrt_search_ui_handle_key(key_status, NULL); - } - else - { - app_ibrt_search_ui_gpio_key_handle(key_status,NULL); - } + Is_Slave_Key_Down_Event = true; + if (key_status->code == APP_KEY_CODE_PWR) { + app_ibrt_search_ui_handle_key(key_status, NULL); + } else { + app_ibrt_search_ui_gpio_key_handle(key_status, NULL); + } #else - app_ibrt_normal_ui_handle_key(key_status, NULL); + app_ibrt_normal_ui_handle_key(key_status, NULL); #endif - app_ibrt_ui_test_voice_assistant_key(key_status, NULL); - } + app_ibrt_ui_test_voice_assistant_key(key_status, NULL); + } } -void app_ibrt_if_start_user_action(uint8_t *p_buff, uint16_t length) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - TRACE(3,"%s role %d code %d",__func__, p_ibrt_ctrl->current_role, p_buff[0]); +void app_ibrt_if_start_user_action(uint8_t *p_buff, uint16_t length) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + TRACE(3, "%s role %d code %d", __func__, p_ibrt_ctrl->current_role, + p_buff[0]); - if (IBRT_SLAVE == p_ibrt_ctrl->current_role) - { - app_ibrt_ui_send_user_action(p_buff, length); - } - else - { - app_ibrt_ui_perform_user_action(p_buff, length); - } + if (IBRT_SLAVE == p_ibrt_ctrl->current_role) { + app_ibrt_ui_send_user_action(p_buff, length); + } else { + app_ibrt_ui_perform_user_action(p_buff, length); + } } extern void app_bt_volumeup(); extern void app_bt_volumedown(); -void app_ibrt_ui_perform_user_action(uint8_t *p_buff, uint16_t length) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); +void app_ibrt_ui_perform_user_action(uint8_t *p_buff, uint16_t length) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); #ifdef ANC_APP - app_anc_cmd_receive_process(p_buff, length); + app_anc_cmd_receive_process(p_buff, length); #endif #ifdef ANC_WNR_ENABLED - app_wnr_cmd_receive_process(p_buff, length); + app_wnr_cmd_receive_process(p_buff, length); #endif - if (IBRT_MASTER != p_ibrt_ctrl->current_role) - { - TRACE(2,"%s not ibrt master, skip cmd %02x\n", __func__, p_buff[0]); - return; - } + if (IBRT_MASTER != p_ibrt_ctrl->current_role) { + TRACE(2, "%s not ibrt master, skip cmd %02x\n", __func__, p_buff[0]); + return; + } - switch (p_buff[0]) - { - case IBRT_ACTION_PLAY: - a2dp_handleKey(AVRCP_KEY_PLAY); - break; - case IBRT_ACTION_PAUSE: - a2dp_handleKey(AVRCP_KEY_PAUSE); - break; - case IBRT_ACTION_FORWARD: - a2dp_handleKey(AVRCP_KEY_FORWARD); - break; - case IBRT_ACTION_BACKWARD: - a2dp_handleKey(AVRCP_KEY_BACKWARD); - break; - case IBRT_ACTION_AVRCP_VOLUP: - a2dp_handleKey(AVRCP_KEY_VOLUME_UP); - break; - case IBRT_ACTION_AVRCP_VOLDN: - a2dp_handleKey(AVRCP_KEY_VOLUME_DOWN); - break; - case IBRT_ACTION_HFSCO_CREATE: - if (!btif_hf_audio_link_is_up()) - { - btif_pts_hf_create_audio_link(); - } - else - { - TRACE(1,"%s cannot create audio link\n", __func__); - } - break; - case IBRT_ACTION_HFSCO_DISC: - if (btif_hf_audio_link_is_up()) - { - btif_pts_hf_disc_audio_link(); - } - else - { - TRACE(1,"%s cannot disc audio link\n", __func__); - } - break; - case IBRT_ACTION_REDIAL: - if (btif_hf_service_link_is_up()) - { - btif_pts_hf_redial_call(); - } - else - { - TRACE(1,"%s cannot redial call\n", __func__); - } - break; - case IBRT_ACTION_ANSWER: - if (btif_hf_service_link_is_up()) - { - btif_pts_hf_answer_call(); - } - else - { - TRACE(1,"%s cannot answer call\n", __func__); - } - break; - case IBRT_ACTION_HANGUP: - if (btif_hf_service_link_is_up()) - { - btif_pts_hf_hangup_call(); - } - else - { - TRACE(1,"%s cannot hangup call\n", __func__); - } - break; - case IBRT_ACTION_LOCAL_VOLUP: - app_bt_volumeup(); - app_ibrt_sync_volume_info(); - break; - case IBRT_ACTION_LOCAL_VOLDN: - app_bt_volumedown(); - app_ibrt_sync_volume_info(); - break; - default: - TRACE(2,"%s unknown user action %d\n", __func__, p_buff[0]); - break; + switch (p_buff[0]) { + case IBRT_ACTION_PLAY: + a2dp_handleKey(AVRCP_KEY_PLAY); + break; + case IBRT_ACTION_PAUSE: + a2dp_handleKey(AVRCP_KEY_PAUSE); + break; + case IBRT_ACTION_FORWARD: + a2dp_handleKey(AVRCP_KEY_FORWARD); + break; + case IBRT_ACTION_BACKWARD: + a2dp_handleKey(AVRCP_KEY_BACKWARD); + break; + case IBRT_ACTION_AVRCP_VOLUP: + a2dp_handleKey(AVRCP_KEY_VOLUME_UP); + break; + case IBRT_ACTION_AVRCP_VOLDN: + a2dp_handleKey(AVRCP_KEY_VOLUME_DOWN); + break; + case IBRT_ACTION_HFSCO_CREATE: + if (!btif_hf_audio_link_is_up()) { + btif_pts_hf_create_audio_link(); + } else { + TRACE(1, "%s cannot create audio link\n", __func__); } + break; + case IBRT_ACTION_HFSCO_DISC: + if (btif_hf_audio_link_is_up()) { + btif_pts_hf_disc_audio_link(); + } else { + TRACE(1, "%s cannot disc audio link\n", __func__); + } + break; + case IBRT_ACTION_REDIAL: + if (btif_hf_service_link_is_up()) { + btif_pts_hf_redial_call(); + } else { + TRACE(1, "%s cannot redial call\n", __func__); + } + break; + case IBRT_ACTION_ANSWER: + if (btif_hf_service_link_is_up()) { + btif_pts_hf_answer_call(); + } else { + TRACE(1, "%s cannot answer call\n", __func__); + } + break; + case IBRT_ACTION_HANGUP: + if (btif_hf_service_link_is_up()) { + btif_pts_hf_hangup_call(); + } else { + TRACE(1, "%s cannot hangup call\n", __func__); + } + break; + case IBRT_ACTION_LOCAL_VOLUP: + app_bt_volumeup(); + app_ibrt_sync_volume_info(); + break; + case IBRT_ACTION_LOCAL_VOLDN: + app_bt_volumedown(); + app_ibrt_sync_volume_info(); + break; + default: + TRACE(2, "%s unknown user action %d\n", __func__, p_buff[0]); + break; + } } #endif - diff --git a/services/app_ibrt/src/app_ibrt_nvrecord.cpp b/services/app_ibrt/src/app_ibrt_nvrecord.cpp index 815aa96..8156b37 100644 --- a/services/app_ibrt/src/app_ibrt_nvrecord.cpp +++ b/services/app_ibrt/src/app_ibrt_nvrecord.cpp @@ -13,15 +13,15 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "app_tws_ibrt_trace.h" -#include "app_ibrt_ui.h" -#include "factory_section.h" +#include "app_ibrt_nvrecord.h" #include "app_ibrt_if.h" +#include "app_ibrt_ui.h" +#include "app_tws_ibrt_trace.h" +#include "ddbif.h" +#include "factory_section.h" #include "nvrecord.h" #include "nvrecord_env.h" -#include "app_ibrt_nvrecord.h" -#include "ddbif.h" +#include /***************************************************************************** @@ -39,30 +39,23 @@ Author : bestechnic Modification : Created function *****************************************************************************/ -void app_ibrt_nvrecord_config_load(void *config) -{ - struct nvrecord_env_t *nvrecord_env; - ibrt_config_t *ibrt_config = (ibrt_config_t *)config; - //factory_section_original_btaddr_get(ibrt_config->local_addr.address); - nv_record_env_get(&nvrecord_env); - if(nvrecord_env->ibrt_mode.mode!=IBRT_UNKNOW) - { - ibrt_config->nv_role=nvrecord_env->ibrt_mode.mode; - ibrt_config->peer_addr=nvrecord_env->ibrt_mode.record.bdAddr; - ibrt_config->local_addr=nvrecord_env->ibrt_mode.record.bdAddr; - if(nvrecord_env->ibrt_mode.tws_connect_success == 0) - { - app_ibrt_ui_clear_tws_connect_success_last(); - } - else - { - app_ibrt_ui_set_tws_connect_success_last(); - } - } - else - { - ibrt_config->nv_role=IBRT_UNKNOW; +void app_ibrt_nvrecord_config_load(void *config) { + struct nvrecord_env_t *nvrecord_env; + ibrt_config_t *ibrt_config = (ibrt_config_t *)config; + // factory_section_original_btaddr_get(ibrt_config->local_addr.address); + nv_record_env_get(&nvrecord_env); + if (nvrecord_env->ibrt_mode.mode != IBRT_UNKNOW) { + ibrt_config->nv_role = nvrecord_env->ibrt_mode.mode; + ibrt_config->peer_addr = nvrecord_env->ibrt_mode.record.bdAddr; + ibrt_config->local_addr = nvrecord_env->ibrt_mode.record.bdAddr; + if (nvrecord_env->ibrt_mode.tws_connect_success == 0) { + app_ibrt_ui_clear_tws_connect_success_last(); + } else { + app_ibrt_ui_set_tws_connect_success_last(); } + } else { + ibrt_config->nv_role = IBRT_UNKNOW; + } } /***************************************************************************** @@ -80,9 +73,9 @@ Author : bestechnic Modification : Created function *****************************************************************************/ -int app_ibrt_nvrecord_find(const bt_bdaddr_t *bd_ddr, nvrec_btdevicerecord **record) -{ - return nv_record_btdevicerecord_find(bd_ddr, record); +int app_ibrt_nvrecord_find(const bt_bdaddr_t *bd_ddr, + nvrec_btdevicerecord **record) { + return nv_record_btdevicerecord_find(bd_ddr, record); } /***************************************************************************** @@ -100,15 +93,13 @@ Author : bestechnic Modification : Created function *****************************************************************************/ -void app_ibrt_nvrecord_update_ibrt_mode_tws(bool status) -{ - struct nvrecord_env_t *nvrecord_env; - - TRACE(2,"##%s,%d",__func__,status); - nv_record_env_get(&nvrecord_env); - nvrecord_env->ibrt_mode.tws_connect_success = status; - nv_record_env_set(nvrecord_env); +void app_ibrt_nvrecord_update_ibrt_mode_tws(bool status) { + struct nvrecord_env_t *nvrecord_env; + TRACE(2, "##%s,%d", __func__, status); + nv_record_env_get(&nvrecord_env); + nvrecord_env->ibrt_mode.tws_connect_success = status; + nv_record_env_set(nvrecord_env); } /***************************************************************************** Prototype : app_ibrt_nvrecord_get_latest_mobiles_addr @@ -125,70 +116,59 @@ void app_ibrt_nvrecord_update_ibrt_mode_tws(bool status) Modification : Created function *****************************************************************************/ -int app_ibrt_nvrecord_get_latest_mobiles_addr(bt_bdaddr_t *mobile_addr1, bt_bdaddr_t* mobile_addr2) -{ - btif_device_record_t record; - int found_mobile_addr_count = 0; - int paired_dev_count = nv_record_get_paired_dev_count(); +int app_ibrt_nvrecord_get_latest_mobiles_addr(bt_bdaddr_t *mobile_addr1, + bt_bdaddr_t *mobile_addr2) { + btif_device_record_t record; + int found_mobile_addr_count = 0; + int paired_dev_count = nv_record_get_paired_dev_count(); - /* the tail is latest, the head is oldest */ - for (int i = paired_dev_count - 1; i >= 0; --i) - { - if (BT_STS_SUCCESS != nv_record_enum_dev_records(i, &record)) - { - break; - } - - if (MOBILE_LINK == app_tws_ibrt_get_link_type_by_addr(&record.bdAddr)) - { - found_mobile_addr_count += 1; - - if (found_mobile_addr_count == 1) - { - *mobile_addr1 = record.bdAddr; - } - else if (found_mobile_addr_count == 2) - { - *mobile_addr2 = record.bdAddr; - break; - } - } + /* the tail is latest, the head is oldest */ + for (int i = paired_dev_count - 1; i >= 0; --i) { + if (BT_STS_SUCCESS != nv_record_enum_dev_records(i, &record)) { + break; } - return found_mobile_addr_count; + if (MOBILE_LINK == app_tws_ibrt_get_link_type_by_addr(&record.bdAddr)) { + found_mobile_addr_count += 1; + + if (found_mobile_addr_count == 1) { + *mobile_addr1 = record.bdAddr; + } else if (found_mobile_addr_count == 2) { + *mobile_addr2 = record.bdAddr; + break; + } + } + } + + return found_mobile_addr_count; } -int app_ibrt_nvrecord_choice_mobile_addr(bt_bdaddr_t *mobile_addr, uint8_t index) -{ - btif_device_record_t record; - int paired_dev_count = nv_record_get_paired_dev_count(); - int mobile_found_count = 0; - if (paired_dev_count < index + 1) - { - return 0; - } - - /* the tail is latest, the head is oldest */ - for (int i = paired_dev_count - 1; i >= 0; --i) - { - if (BT_STS_SUCCESS != nv_record_enum_dev_records(i, &record)) - { - break; - } - - if (MOBILE_LINK == app_tws_ibrt_get_link_type_by_addr(&record.bdAddr)) - { - if (mobile_found_count == index) - { - *mobile_addr = record.bdAddr; - return 1; - } - - mobile_found_count += 1; - } - } - +int app_ibrt_nvrecord_choice_mobile_addr(bt_bdaddr_t *mobile_addr, + uint8_t index) { + btif_device_record_t record; + int paired_dev_count = nv_record_get_paired_dev_count(); + int mobile_found_count = 0; + if (paired_dev_count < index + 1) { return 0; + } + + /* the tail is latest, the head is oldest */ + for (int i = paired_dev_count - 1; i >= 0; --i) { + if (BT_STS_SUCCESS != nv_record_enum_dev_records(i, &record)) { + break; + } + + if (MOBILE_LINK == app_tws_ibrt_get_link_type_by_addr(&record.bdAddr)) { + if (mobile_found_count == index) { + *mobile_addr = record.bdAddr; + return 1; + } + + mobile_found_count += 1; + } + } + + return 0; } /***************************************************************************** Prototype : app_ibrt_nvrecord_get_mobile_addr @@ -205,47 +185,42 @@ int app_ibrt_nvrecord_choice_mobile_addr(bt_bdaddr_t *mobile_addr, uint8_t index Modification : Created function *****************************************************************************/ -bt_status_t app_ibrt_nvrecord_get_mobile_addr(bt_bdaddr_t *mobile_addr) -{ +bt_status_t app_ibrt_nvrecord_get_mobile_addr(bt_bdaddr_t *mobile_addr) { #if !defined(FPGA) - btif_device_record_t record1; - btif_device_record_t record2; - btif_device_record_t record; - ibrt_link_type_e link_type; + btif_device_record_t record1; + btif_device_record_t record2; + btif_device_record_t record; + ibrt_link_type_e link_type; - uint8_t null_addr[6] = {0}; - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - int record_num = nv_record_enum_latest_two_paired_dev(&record1, &record2); + uint8_t null_addr[6] = {0}; + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + int record_num = nv_record_enum_latest_two_paired_dev(&record1, &record2); - if (memcmp(&p_ibrt_ctrl->mobile_addr.address[0], &null_addr[0], BTIF_BD_ADDR_SIZE) && - (ddbif_find_record((const bt_bdaddr_t *)&p_ibrt_ctrl->mobile_addr, &record) == BT_STS_SUCCESS)) - { - //first check if mobile addr exist in RAM - *mobile_addr = p_ibrt_ctrl->mobile_addr; + if (memcmp(&p_ibrt_ctrl->mobile_addr.address[0], &null_addr[0], + BTIF_BD_ADDR_SIZE) && + (ddbif_find_record((const bt_bdaddr_t *)&p_ibrt_ctrl->mobile_addr, + &record) == BT_STS_SUCCESS)) { + // first check if mobile addr exist in RAM + *mobile_addr = p_ibrt_ctrl->mobile_addr; + return BT_STS_SUCCESS; + } + + if ((record_num == 1) || (record_num == 2)) { + // check nv mobile addr + link_type = app_tws_ibrt_get_link_type_by_addr(&record1.bdAddr); + if (link_type == MOBILE_LINK) { + *mobile_addr = record1.bdAddr; + return BT_STS_SUCCESS; + } else if (record_num == 2) { + link_type = app_tws_ibrt_get_link_type_by_addr(&record2.bdAddr); + if (link_type == MOBILE_LINK) { + *mobile_addr = record2.bdAddr; return BT_STS_SUCCESS; + } } - - if ((record_num == 1) || (record_num == 2)) - { - //check nv mobile addr - link_type = app_tws_ibrt_get_link_type_by_addr(&record1.bdAddr); - if (link_type == MOBILE_LINK) - { - *mobile_addr = record1.bdAddr; - return BT_STS_SUCCESS; - } - else if (record_num == 2) - { - link_type = app_tws_ibrt_get_link_type_by_addr(&record2.bdAddr); - if (link_type == MOBILE_LINK) - { - *mobile_addr = record2.bdAddr; - return BT_STS_SUCCESS; - } - } - } + } #else -#if 0//for fpga test reconnect phone +#if 0 // for fpga test reconnect phone ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); uint8_t nv_slave_connect_addr[] = {0xaf,0x55,0x68,0x68,0x76,0x7c};//huawei @@ -258,7 +233,7 @@ bt_status_t app_ibrt_nvrecord_get_mobile_addr(bt_bdaddr_t *mobile_addr) } #endif #endif - return BT_STS_FAILED; + return BT_STS_FAILED; } /***************************************************************************** Prototype : app_ibrt_nvrecord_delete_all_mobile_record @@ -275,21 +250,18 @@ bt_status_t app_ibrt_nvrecord_get_mobile_addr(bt_bdaddr_t *mobile_addr) Modification : Created function *****************************************************************************/ -void app_ibrt_nvrecord_delete_all_mobile_record(void) -{ - btif_device_record_t record = {0}; - int paired_dev_count = nv_record_get_paired_dev_count(); +void app_ibrt_nvrecord_delete_all_mobile_record(void) { + btif_device_record_t record = {0}; + int paired_dev_count = nv_record_get_paired_dev_count(); - for (int i = paired_dev_count - 1; i >= 0; --i) - { - nv_record_enum_dev_records(i, &record); + for (int i = paired_dev_count - 1; i >= 0; --i) { + nv_record_enum_dev_records(i, &record); - if (MOBILE_LINK == app_tws_ibrt_get_link_type_by_addr(&record.bdAddr)) - { - nv_record_ddbrec_delete(&record.bdAddr); - } + if (MOBILE_LINK == app_tws_ibrt_get_link_type_by_addr(&record.bdAddr)) { + nv_record_ddbrec_delete(&record.bdAddr); } - app_ibrt_if_config_keeper_clear(); + } + app_ibrt_if_config_keeper_clear(); } /***************************************************************************** @@ -307,17 +279,16 @@ void app_ibrt_nvrecord_delete_all_mobile_record(void) Modification : Created function *****************************************************************************/ -void app_ibrt_nvrecord_rebuild(void) -{ - struct nvrecord_env_t *nvrecord_env; - nv_record_env_get(&nvrecord_env); +void app_ibrt_nvrecord_rebuild(void) { + struct nvrecord_env_t *nvrecord_env; + nv_record_env_get(&nvrecord_env); - nv_record_sector_clear(); - nv_record_env_init(); - nv_record_update_factory_tester_status(NVRAM_ENV_FACTORY_TESTER_STATUS_DEFAULT); - nv_record_env_set(nvrecord_env); - nv_record_flash_flush(); - app_ibrt_if_config_keeper_clear(); - app_ibrt_ui_reboot_sdk(); + nv_record_sector_clear(); + nv_record_env_init(); + nv_record_update_factory_tester_status( + NVRAM_ENV_FACTORY_TESTER_STATUS_DEFAULT); + nv_record_env_set(nvrecord_env); + nv_record_flash_flush(); + app_ibrt_if_config_keeper_clear(); + app_ibrt_ui_reboot_sdk(); } - diff --git a/services/app_ibrt/src/app_ibrt_ota_cmd.cpp b/services/app_ibrt/src/app_ibrt_ota_cmd.cpp index 70c31de..dd0979d 100644 --- a/services/app_ibrt/src/app_ibrt_ota_cmd.cpp +++ b/services/app_ibrt/src/app_ibrt_ota_cmd.cpp @@ -13,649 +13,627 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "string.h" -#include "app_tws_ibrt_trace.h" +#include "app_ibrt_ota_cmd.h" #include "app_tws_ctrl_thread.h" #include "app_tws_ibrt_cmd_handler.h" -#include "app_ibrt_ota_cmd.h" +#include "app_tws_ibrt_trace.h" +#include "string.h" #ifdef IBRT_OTA #include "../../ibrt_ota/inc/ota_control.h" -#include "ota_spp.h" #include "ota_common.h" +#include "ota_spp.h" static void app_ibrt_ota_get_version_cmd_send(uint8_t *p_buff, uint16_t length); -void app_ibrt_ota_get_version_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_get_version_cmd_send_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_get_version_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +void app_ibrt_ota_get_version_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_ota_get_version_cmd_send_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_ota_get_version_cmd_send_rsp_timeout_handler( + uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); static void app_ibrt_ota_select_side_cmd_send(uint8_t *p_buff, uint16_t length); -void app_ibrt_ota_select_side_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_select_side_cmd_send_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_select_side_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +void app_ibrt_ota_select_side_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_ota_select_side_cmd_send_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_ota_select_side_cmd_send_rsp_timeout_handler( + uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); static void app_ibrt_ota_bp_check_cmd_send(uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_bp_check_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_bp_check_cmd_send_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_bp_check_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +static void app_ibrt_ota_bp_check_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_ota_bp_check_cmd_send_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_ota_bp_check_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); static void app_ibrt_ota_start_cmd_send(uint8_t *p_buff, uint16_t length); -void app_ibrt_ota_start_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_start_cmd_send_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_start_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +void app_ibrt_ota_start_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length); +static void app_ibrt_ota_start_cmd_send_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_ota_start_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); static void app_ibrt_ota_config_cmd_send(uint8_t *p_buff, uint16_t length); -void app_ibrt_ota_config_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_config_cmd_send_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_config_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +void app_ibrt_ota_config_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length); +static void app_ibrt_ota_config_cmd_send_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_ota_config_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); static void app_ibrt_ota_segment_crc_cmd_send(uint8_t *p_buff, uint16_t length); -void app_ibrt_ota_segment_crc_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_segment_crc_cmd_send_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_segment_crc_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +void app_ibrt_ota_segment_crc_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_ota_segment_crc_cmd_send_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_ota_segment_crc_cmd_send_rsp_timeout_handler( + uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); static void app_ibrt_ota_image_crc_cmd_send(uint8_t *p_buff, uint16_t length); -void app_ibrt_ota_image_crc_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_image_crc_cmd_send_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_image_crc_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +void app_ibrt_ota_image_crc_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length); +static void app_ibrt_ota_image_crc_cmd_send_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_ota_image_crc_cmd_send_rsp_timeout_handler( + uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_image_overwrite_cmd_send(uint8_t *p_buff, uint16_t length); -void app_ibrt_ota_image_overwrite_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_image_overwrite_cmd_send_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_image_overwrite_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +static void app_ibrt_ota_image_overwrite_cmd_send(uint8_t *p_buff, + uint16_t length); +void app_ibrt_ota_image_overwrite_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_ota_image_overwrite_cmd_send_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_ota_image_overwrite_cmd_send_rsp_timeout_handler( + uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_start_role_switch_cmd_send(uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_start_role_switch_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +static void app_ibrt_ota_start_role_switch_cmd_send(uint8_t *p_buff, + uint16_t length); +static void app_ibrt_ota_start_role_switch_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); static void app_ibrt_ota_image_buff_cmd_send(uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_image_buff_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +static void app_ibrt_ota_image_buff_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); static void app_ibrt_common_ota_cmd_send(uint8_t *p_buff, uint16_t length); -static void app_ibrt_common_ota_cmd_received(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +static void app_ibrt_common_ota_cmd_received(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length); - -static app_tws_cmd_instance_t g_ibrt_ota_tws_cmd_handler_table[]= -{ - { - IBRT_OTA_TWS_GET_VERSION_CMD, "OTA_GET_VERSION", - app_ibrt_ota_get_version_cmd_send, - app_ibrt_ota_get_version_cmd_send_handler, RSP_TIMEOUT_DEFAULT, - app_ibrt_ota_get_version_cmd_send_rsp_timeout_handler, app_ibrt_ota_get_version_cmd_send_rsp_handler - }, - { - IBRT_OTA_TWS_SELECT_SIDE_CMD, "OTA_SELECT_SIDE", - app_ibrt_ota_select_side_cmd_send, - app_ibrt_ota_select_side_cmd_send_handler, RSP_TIMEOUT_DEFAULT, - app_ibrt_ota_select_side_cmd_send_rsp_timeout_handler, app_ibrt_ota_select_side_cmd_send_rsp_handler - }, - { - IBRT_OTA_TWS_BP_CHECK_CMD, "OTA_BP_CHECK",//Break-point - app_ibrt_ota_bp_check_cmd_send, - app_ibrt_ota_bp_check_cmd_send_handler, RSP_TIMEOUT_DEFAULT, - app_ibrt_ota_bp_check_cmd_send_rsp_timeout_handler, app_ibrt_ota_bp_check_cmd_send_rsp_handler - }, - { - IBRT_OTA_TWS_START_OTA_CMD, "OTA_START", - app_ibrt_ota_start_cmd_send, - app_ibrt_ota_start_cmd_send_handler, RSP_TIMEOUT_DEFAULT, - app_ibrt_ota_start_cmd_send_rsp_timeout_handler, app_ibrt_ota_start_cmd_send_rsp_handler - }, - { - IBRT_OTA_TWS_OTA_CONFIG_CMD, "OTA_CONFIG", - app_ibrt_ota_config_cmd_send, - app_ibrt_ota_config_cmd_send_handler, RSP_TIMEOUT_DEFAULT, - app_ibrt_ota_config_cmd_send_rsp_timeout_handler, app_ibrt_ota_config_cmd_send_rsp_handler - }, - { - IBRT_OTA_TWS_SEGMENT_CRC_CMD, "OTA_SEGMENT_CRC", - app_ibrt_ota_segment_crc_cmd_send, - app_ibrt_ota_segment_crc_cmd_send_handler, RSP_TIMEOUT_DEFAULT, - app_ibrt_ota_segment_crc_cmd_send_rsp_timeout_handler, app_ibrt_ota_segment_crc_cmd_send_rsp_handler - }, - { - IBRT_OTA_TWS_IMAGE_CRC_CMD, "OTA_IMAGE_CRC", - app_ibrt_ota_image_crc_cmd_send, - app_ibrt_ota_image_crc_cmd_send_handler, RSP_TIMEOUT_DEFAULT, - app_ibrt_ota_image_crc_cmd_send_rsp_timeout_handler, app_ibrt_ota_image_crc_cmd_send_rsp_handler - }, - { - IBRT_OTA_TWS_IMAGE_OVERWRITE_CMD, "OTA_IMAGE_OVERWRITE", - app_ibrt_ota_image_overwrite_cmd_send, - app_ibrt_ota_image_overwrite_cmd_send_handler, RSP_TIMEOUT_DEFAULT, - app_ibrt_ota_image_overwrite_cmd_send_rsp_timeout_handler, app_ibrt_ota_image_overwrite_cmd_send_rsp_handler - }, - { - IBRT_OTA_TWS_ROLE_SWITCH_CMD, "OTA_ROLE_SWITCH", - app_ibrt_ota_start_role_switch_cmd_send, - app_ibrt_ota_start_role_switch_cmd_send_handler, 0, - app_ibrt_ota_image_buff_cmd_rsp_timeout_handler_null, app_ibrt_ota_image_buff_cmd_rsp_handler_null - }, - { - IBRT_OTA_TWS_IMAGE_BUFF, "OTA_IMAGE_BUFF", - app_ibrt_ota_image_buff_cmd_send, - app_ibrt_ota_image_buff_cmd_send_handler, 0, - app_ibrt_ota_image_buff_cmd_rsp_timeout_handler_null, app_ibrt_ota_image_buff_cmd_rsp_handler_null - }, - { - IBRT_COMMON_OTA, "COMMON_OTA_CMD", - app_ibrt_common_ota_cmd_send, - app_ibrt_common_ota_cmd_received, 0, - app_ibrt_ota_image_buff_cmd_rsp_timeout_handler_null, app_ibrt_ota_image_buff_cmd_rsp_handler_null - }, +static app_tws_cmd_instance_t g_ibrt_ota_tws_cmd_handler_table[] = { + {IBRT_OTA_TWS_GET_VERSION_CMD, "OTA_GET_VERSION", + app_ibrt_ota_get_version_cmd_send, + app_ibrt_ota_get_version_cmd_send_handler, RSP_TIMEOUT_DEFAULT, + app_ibrt_ota_get_version_cmd_send_rsp_timeout_handler, + app_ibrt_ota_get_version_cmd_send_rsp_handler}, + {IBRT_OTA_TWS_SELECT_SIDE_CMD, "OTA_SELECT_SIDE", + app_ibrt_ota_select_side_cmd_send, + app_ibrt_ota_select_side_cmd_send_handler, RSP_TIMEOUT_DEFAULT, + app_ibrt_ota_select_side_cmd_send_rsp_timeout_handler, + app_ibrt_ota_select_side_cmd_send_rsp_handler}, + {IBRT_OTA_TWS_BP_CHECK_CMD, "OTA_BP_CHECK", // Break-point + app_ibrt_ota_bp_check_cmd_send, app_ibrt_ota_bp_check_cmd_send_handler, + RSP_TIMEOUT_DEFAULT, app_ibrt_ota_bp_check_cmd_send_rsp_timeout_handler, + app_ibrt_ota_bp_check_cmd_send_rsp_handler}, + {IBRT_OTA_TWS_START_OTA_CMD, "OTA_START", app_ibrt_ota_start_cmd_send, + app_ibrt_ota_start_cmd_send_handler, RSP_TIMEOUT_DEFAULT, + app_ibrt_ota_start_cmd_send_rsp_timeout_handler, + app_ibrt_ota_start_cmd_send_rsp_handler}, + {IBRT_OTA_TWS_OTA_CONFIG_CMD, "OTA_CONFIG", app_ibrt_ota_config_cmd_send, + app_ibrt_ota_config_cmd_send_handler, RSP_TIMEOUT_DEFAULT, + app_ibrt_ota_config_cmd_send_rsp_timeout_handler, + app_ibrt_ota_config_cmd_send_rsp_handler}, + {IBRT_OTA_TWS_SEGMENT_CRC_CMD, "OTA_SEGMENT_CRC", + app_ibrt_ota_segment_crc_cmd_send, + app_ibrt_ota_segment_crc_cmd_send_handler, RSP_TIMEOUT_DEFAULT, + app_ibrt_ota_segment_crc_cmd_send_rsp_timeout_handler, + app_ibrt_ota_segment_crc_cmd_send_rsp_handler}, + {IBRT_OTA_TWS_IMAGE_CRC_CMD, "OTA_IMAGE_CRC", + app_ibrt_ota_image_crc_cmd_send, app_ibrt_ota_image_crc_cmd_send_handler, + RSP_TIMEOUT_DEFAULT, app_ibrt_ota_image_crc_cmd_send_rsp_timeout_handler, + app_ibrt_ota_image_crc_cmd_send_rsp_handler}, + {IBRT_OTA_TWS_IMAGE_OVERWRITE_CMD, "OTA_IMAGE_OVERWRITE", + app_ibrt_ota_image_overwrite_cmd_send, + app_ibrt_ota_image_overwrite_cmd_send_handler, RSP_TIMEOUT_DEFAULT, + app_ibrt_ota_image_overwrite_cmd_send_rsp_timeout_handler, + app_ibrt_ota_image_overwrite_cmd_send_rsp_handler}, + {IBRT_OTA_TWS_ROLE_SWITCH_CMD, "OTA_ROLE_SWITCH", + app_ibrt_ota_start_role_switch_cmd_send, + app_ibrt_ota_start_role_switch_cmd_send_handler, 0, + app_ibrt_ota_image_buff_cmd_rsp_timeout_handler_null, + app_ibrt_ota_image_buff_cmd_rsp_handler_null}, + {IBRT_OTA_TWS_IMAGE_BUFF, "OTA_IMAGE_BUFF", + app_ibrt_ota_image_buff_cmd_send, app_ibrt_ota_image_buff_cmd_send_handler, + 0, app_ibrt_ota_image_buff_cmd_rsp_timeout_handler_null, + app_ibrt_ota_image_buff_cmd_rsp_handler_null}, + {IBRT_COMMON_OTA, "COMMON_OTA_CMD", app_ibrt_common_ota_cmd_send, + app_ibrt_common_ota_cmd_received, 0, + app_ibrt_ota_image_buff_cmd_rsp_timeout_handler_null, + app_ibrt_ota_image_buff_cmd_rsp_handler_null}, }; -int app_ibrt_ota_tws_cmd_table_get(void **cmd_tbl, uint16_t *cmd_size) -{ - *cmd_tbl = (void *)&g_ibrt_ota_tws_cmd_handler_table; - *cmd_size = ARRAY_SIZE(g_ibrt_ota_tws_cmd_handler_table); - return 0; +int app_ibrt_ota_tws_cmd_table_get(void **cmd_tbl, uint16_t *cmd_size) { + *cmd_tbl = (void *)&g_ibrt_ota_tws_cmd_handler_table; + *cmd_size = ARRAY_SIZE(g_ibrt_ota_tws_cmd_handler_table); + return 0; } -extern OTA_IBRT_TWS_CMD_EXECUTED_RESULT_FROM_SLAVE_T receivedResultAlreadyProcessedBySlave; +extern OTA_IBRT_TWS_CMD_EXECUTED_RESULT_FROM_SLAVE_T + receivedResultAlreadyProcessedBySlave; uint32_t ibrt_ota_cmd_type = 0; uint32_t twsBreakPoint = 0; uint8_t errOtaCode = 0; static uint8_t resend = RESEND_TIME; -static void app_ibrt_ota_cache_slave_info(uint8_t typeCode, uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - memcpy(&receivedResultAlreadyProcessedBySlave.typeCode, &typeCode, sizeof(typeCode)); - memcpy(&receivedResultAlreadyProcessedBySlave.rsp_seq, &rsp_seq, sizeof(rsp_seq)); - memcpy(&receivedResultAlreadyProcessedBySlave.length, &length, sizeof(length)); - memcpy(receivedResultAlreadyProcessedBySlave.p_buff, p_buff, length); +static void app_ibrt_ota_cache_slave_info(uint8_t typeCode, uint16_t rsp_seq, + uint8_t *p_buff, uint16_t length) { + memcpy(&receivedResultAlreadyProcessedBySlave.typeCode, &typeCode, + sizeof(typeCode)); + memcpy(&receivedResultAlreadyProcessedBySlave.rsp_seq, &rsp_seq, + sizeof(rsp_seq)); + memcpy(&receivedResultAlreadyProcessedBySlave.length, &length, + sizeof(length)); + memcpy(receivedResultAlreadyProcessedBySlave.p_buff, p_buff, length); } -static void app_ibrt_ota_get_version_cmd_send(uint8_t *p_buff, uint16_t length) -{ - app_ibrt_send_cmd_with_rsp(IBRT_OTA_TWS_GET_VERSION_CMD, p_buff, length); - TRACE(1,"%s", __func__); +static void app_ibrt_ota_get_version_cmd_send(uint8_t *p_buff, + uint16_t length) { + app_ibrt_send_cmd_with_rsp(IBRT_OTA_TWS_GET_VERSION_CMD, p_buff, length); + TRACE(1, "%s", __func__); } -void app_ibrt_ota_get_version_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - if(ibrt_ota_cmd_type == OTA_RSP_VERSION) - { - ibrt_ota_send_version_rsp(); - tws_ctrl_send_rsp(IBRT_OTA_TWS_GET_VERSION_CMD, rsp_seq, p_buff, length); - ibrt_ota_cmd_type = 0; - } - else - { - app_ibrt_ota_cache_slave_info(OTA_RSP_VERSION, rsp_seq, p_buff, length); - } - TRACE(1,"%s", __func__); +void app_ibrt_ota_get_version_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + if (ibrt_ota_cmd_type == OTA_RSP_VERSION) { + ibrt_ota_send_version_rsp(); + tws_ctrl_send_rsp(IBRT_OTA_TWS_GET_VERSION_CMD, rsp_seq, p_buff, length); + ibrt_ota_cmd_type = 0; + } else { + app_ibrt_ota_cache_slave_info(OTA_RSP_VERSION, rsp_seq, p_buff, length); + } + TRACE(1, "%s", __func__); } -static void app_ibrt_ota_get_version_cmd_send_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ +static void app_ibrt_ota_get_version_cmd_send_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + resend = RESEND_TIME; + TRACE(1, "%s", __func__); +} + +static void app_ibrt_ota_get_version_cmd_send_rsp_timeout_handler( + uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) { + if (resend > 0) { + tws_ctrl_send_cmd(IBRT_OTA_TWS_GET_VERSION_CMD, p_buff, length); + resend--; + } else { resend = RESEND_TIME; - TRACE(1,"%s", __func__); + } + TRACE(2, "%s, %d", __func__, resend); } -static void app_ibrt_ota_get_version_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - if(resend > 0) - { - tws_ctrl_send_cmd(IBRT_OTA_TWS_GET_VERSION_CMD, p_buff, length); - resend--; - } - else - { - resend = RESEND_TIME; - } - TRACE(2,"%s, %d", __func__, resend); +static void app_ibrt_ota_select_side_cmd_send(uint8_t *p_buff, + uint16_t length) { + app_ibrt_send_cmd_with_rsp(IBRT_OTA_TWS_SELECT_SIDE_CMD, p_buff, length); + TRACE(1, "%s", __func__); } -static void app_ibrt_ota_select_side_cmd_send(uint8_t *p_buff, uint16_t length) -{ - app_ibrt_send_cmd_with_rsp(IBRT_OTA_TWS_SELECT_SIDE_CMD, p_buff, length); - TRACE(1,"%s", __func__); +void app_ibrt_ota_select_side_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + if (ibrt_ota_cmd_type == OTA_RSP_SIDE_SELECTION) { + if (1 == p_buff[1]) { + ota_control_side_selection_rsp(true); + } else { + ota_control_side_selection_rsp(false); + } + tws_ctrl_send_rsp(IBRT_OTA_TWS_SELECT_SIDE_CMD, rsp_seq, p_buff, length); + ibrt_ota_cmd_type = 0; + } else { + app_ibrt_ota_cache_slave_info(OTA_RSP_SIDE_SELECTION, rsp_seq, p_buff, + length); + } + TRACE(1, "%s", __func__); } -void app_ibrt_ota_select_side_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - if(ibrt_ota_cmd_type == OTA_RSP_SIDE_SELECTION) - { - if(1 == p_buff[1]) - { - ota_control_side_selection_rsp(true); - } - else - { - ota_control_side_selection_rsp(false); - } - tws_ctrl_send_rsp(IBRT_OTA_TWS_SELECT_SIDE_CMD, rsp_seq, p_buff, length); - ibrt_ota_cmd_type = 0; - } - else - { - app_ibrt_ota_cache_slave_info(OTA_RSP_SIDE_SELECTION, rsp_seq, p_buff, length); - } - TRACE(1,"%s", __func__); +static void app_ibrt_ota_select_side_cmd_send_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + resend = RESEND_TIME; + TRACE(1, "%s", __func__); } -static void app_ibrt_ota_select_side_cmd_send_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ +static void app_ibrt_ota_select_side_cmd_send_rsp_timeout_handler( + uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) { + if (resend > 0) { + tws_ctrl_send_cmd(IBRT_OTA_TWS_SELECT_SIDE_CMD, p_buff, length); + resend--; + } else { resend = RESEND_TIME; - TRACE(1,"%s", __func__); + } + TRACE(2, "%s, %d", __func__, resend); } -static void app_ibrt_ota_select_side_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - if(resend > 0) - { - tws_ctrl_send_cmd(IBRT_OTA_TWS_SELECT_SIDE_CMD, p_buff, length); - resend--; - } - else - { - resend = RESEND_TIME; - } - TRACE(2,"%s, %d", __func__, resend); +static void app_ibrt_ota_bp_check_cmd_send(uint8_t *p_buff, uint16_t length) { + app_ibrt_send_cmd_with_rsp(IBRT_OTA_TWS_BP_CHECK_CMD, p_buff, length); + TRACE(1, "%s", __func__); } -static void app_ibrt_ota_bp_check_cmd_send(uint8_t *p_buff, uint16_t length) -{ - app_ibrt_send_cmd_with_rsp(IBRT_OTA_TWS_BP_CHECK_CMD, p_buff, length); - TRACE(1,"%s", __func__); -} - -static void app_ibrt_ota_bp_check_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - OTA_RSP_RESUME_VERIFY_T* tRsp = (OTA_RSP_RESUME_VERIFY_T *)p_buff; - if(ibrt_ota_cmd_type == OTA_RSP_RESUME_VERIFY) - { - TRACE(2,"breakPoint %d, tRsp->breakPoint %d", twsBreakPoint, tRsp->breakPoint); - if(twsBreakPoint == tRsp->breakPoint) - { - if(twsBreakPoint == 0) - { - LOG_DBG(0,"reset random code:"); - LOG_DUMP("%02x ", (uint8_t *)tRsp, sizeof(OTA_RSP_RESUME_VERIFY_T)); - ota_randomCode_log((uint8_t *)&tRsp->randomCode); - } - ota_control_send_resume_response(tRsp->breakPoint, tRsp->randomCode); - ibrt_ota_cmd_type = 0; - } - else - { - TRACE(1,"%s tws break-point is not synchronized", __func__); - ota_upgradeLog_destroy(); - ota_randomCode_log((uint8_t *)&tRsp->randomCode); - ota_control_reset_env(); - ota_status_change(true); - tRsp->breakPoint = 0xFFFFFFFF; - twsBreakPoint = 0; - } - tws_ctrl_send_rsp(IBRT_OTA_TWS_BP_CHECK_CMD, rsp_seq, (uint8_t *)tRsp, length); - } - TRACE(1,"%s", __func__); -} - -static void app_ibrt_ota_bp_check_cmd_send_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - resend = RESEND_TIME; - OTA_RSP_RESUME_VERIFY_T* tRsp = (OTA_RSP_RESUME_VERIFY_T *)p_buff; - if(tRsp->breakPoint == 0xFFFFFFFF) - { - TRACE(1,"%s tws break-point is not synchronized", __func__); - ota_upgradeLog_destroy(); +static void app_ibrt_ota_bp_check_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + OTA_RSP_RESUME_VERIFY_T *tRsp = (OTA_RSP_RESUME_VERIFY_T *)p_buff; + if (ibrt_ota_cmd_type == OTA_RSP_RESUME_VERIFY) { + TRACE(2, "breakPoint %d, tRsp->breakPoint %d", twsBreakPoint, + tRsp->breakPoint); + if (twsBreakPoint == tRsp->breakPoint) { + if (twsBreakPoint == 0) { + LOG_DBG(0, "reset random code:"); + LOG_DUMP("%02x ", (uint8_t *)tRsp, sizeof(OTA_RSP_RESUME_VERIFY_T)); ota_randomCode_log((uint8_t *)&tRsp->randomCode); - ota_control_reset_env(); - ota_status_change(true); - tRsp->breakPoint = 0; - tws_ctrl_send_cmd(IBRT_OTA_TWS_BP_CHECK_CMD, (uint8_t *)tRsp, length); + } + ota_control_send_resume_response(tRsp->breakPoint, tRsp->randomCode); + ibrt_ota_cmd_type = 0; + } else { + TRACE(1, "%s tws break-point is not synchronized", __func__); + ota_upgradeLog_destroy(); + ota_randomCode_log((uint8_t *)&tRsp->randomCode); + ota_control_reset_env(); + ota_status_change(true); + tRsp->breakPoint = 0xFFFFFFFF; + twsBreakPoint = 0; } - TRACE(1,"%s", __func__); -} -static void app_ibrt_ota_bp_check_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - if(resend > 0) - { - tws_ctrl_send_cmd(IBRT_OTA_TWS_BP_CHECK_CMD, p_buff, length); - resend--; - } - else - { - resend = RESEND_TIME; - } - TRACE(2,"%s, %d", __func__, resend); + tws_ctrl_send_rsp(IBRT_OTA_TWS_BP_CHECK_CMD, rsp_seq, (uint8_t *)tRsp, + length); + } + TRACE(1, "%s", __func__); } -static void app_ibrt_ota_start_cmd_send(uint8_t *p_buff, uint16_t length) -{ - app_ibrt_send_cmd_with_rsp(IBRT_OTA_TWS_START_OTA_CMD, p_buff, length); - TRACE(1,"%s", __func__); +static void app_ibrt_ota_bp_check_cmd_send_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + resend = RESEND_TIME; + OTA_RSP_RESUME_VERIFY_T *tRsp = (OTA_RSP_RESUME_VERIFY_T *)p_buff; + if (tRsp->breakPoint == 0xFFFFFFFF) { + TRACE(1, "%s tws break-point is not synchronized", __func__); + ota_upgradeLog_destroy(); + ota_randomCode_log((uint8_t *)&tRsp->randomCode); + ota_control_reset_env(); + ota_status_change(true); + tRsp->breakPoint = 0; + tws_ctrl_send_cmd(IBRT_OTA_TWS_BP_CHECK_CMD, (uint8_t *)tRsp, length); + } + TRACE(1, "%s", __func__); } - -void app_ibrt_ota_start_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - if(ibrt_ota_cmd_type == OTA_RSP_START) - { - ibrt_ota_send_start_response(*p_buff); - ibrt_ota_cmd_type = 0; - tws_ctrl_send_rsp(IBRT_OTA_TWS_START_OTA_CMD, rsp_seq, p_buff, length); - } - else - { - app_ibrt_ota_cache_slave_info(OTA_RSP_START, rsp_seq, p_buff, length); - } - TRACE(1,"%s", __func__); -} - -static void app_ibrt_ota_start_cmd_send_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ +static void app_ibrt_ota_bp_check_cmd_send_rsp_timeout_handler( + uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) { + if (resend > 0) { + tws_ctrl_send_cmd(IBRT_OTA_TWS_BP_CHECK_CMD, p_buff, length); + resend--; + } else { resend = RESEND_TIME; - TRACE(1,"%s", __func__); -} -static void app_ibrt_ota_start_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - if(resend > 0) - { - tws_ctrl_send_cmd(IBRT_OTA_TWS_START_OTA_CMD, p_buff, length); - resend--; - } - else - { - resend = RESEND_TIME; - } - TRACE(2,"%s, %d", __func__, resend); + } + TRACE(2, "%s, %d", __func__, resend); } -static void app_ibrt_ota_config_cmd_send(uint8_t *p_buff, uint16_t length) -{ - app_ibrt_send_cmd_with_rsp(IBRT_OTA_TWS_OTA_CONFIG_CMD, p_buff, length); - TRACE(1,"%s", __func__); +static void app_ibrt_ota_start_cmd_send(uint8_t *p_buff, uint16_t length) { + app_ibrt_send_cmd_with_rsp(IBRT_OTA_TWS_START_OTA_CMD, p_buff, length); + TRACE(1, "%s", __func__); } -void app_ibrt_ota_config_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - if(ibrt_ota_cmd_type == OTA_RSP_CONFIG) - { - if(*p_buff == 1 && errOtaCode == 1) - { - ibrt_ota_send_configuration_response(true); - tws_ctrl_send_rsp(IBRT_OTA_TWS_OTA_CONFIG_CMD, rsp_seq, p_buff, length); - } - else if(*p_buff == OTA_RESULT_ERR_IMAGE_SIZE || errOtaCode == OTA_RESULT_ERR_IMAGE_SIZE) - { - uint8_t errImageSize = OTA_RESULT_ERR_IMAGE_SIZE; - ibrt_ota_send_result_response(OTA_RESULT_ERR_IMAGE_SIZE); - tws_ctrl_send_rsp(IBRT_OTA_TWS_OTA_CONFIG_CMD, rsp_seq, (uint8_t *)&errImageSize, length); - } - else if(*p_buff == OTA_RESULT_ERR_BREAKPOINT || errOtaCode == OTA_RESULT_ERR_BREAKPOINT) - { - uint8_t errBreakPoint = OTA_RESULT_ERR_BREAKPOINT; - ota_upgradeLog_destroy(); - ibrt_ota_send_result_response(OTA_RESULT_ERR_BREAKPOINT); - tws_ctrl_send_rsp(IBRT_OTA_TWS_OTA_CONFIG_CMD, rsp_seq, (uint8_t *)&errBreakPoint, length); - } - else - { - ibrt_ota_send_configuration_response(false); - tws_ctrl_send_rsp(IBRT_OTA_TWS_OTA_CONFIG_CMD, rsp_seq, p_buff, length); - } - errOtaCode = 0; - ibrt_ota_cmd_type = 0; - } - else - { - app_ibrt_ota_cache_slave_info(OTA_RSP_CONFIG, rsp_seq, p_buff, length); - } - TRACE(1,"%s", __func__); +void app_ibrt_ota_start_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + if (ibrt_ota_cmd_type == OTA_RSP_START) { + ibrt_ota_send_start_response(*p_buff); + ibrt_ota_cmd_type = 0; + tws_ctrl_send_rsp(IBRT_OTA_TWS_START_OTA_CMD, rsp_seq, p_buff, length); + } else { + app_ibrt_ota_cache_slave_info(OTA_RSP_START, rsp_seq, p_buff, length); + } + TRACE(1, "%s", __func__); } -static void app_ibrt_ota_config_cmd_send_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ +static void app_ibrt_ota_start_cmd_send_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + resend = RESEND_TIME; + TRACE(1, "%s", __func__); +} +static void app_ibrt_ota_start_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + if (resend > 0) { + tws_ctrl_send_cmd(IBRT_OTA_TWS_START_OTA_CMD, p_buff, length); + resend--; + } else { resend = RESEND_TIME; - if(*p_buff == OTA_RESULT_ERR_BREAKPOINT) - { - ota_upgradeLog_destroy(); - } - TRACE(1,"%s", __func__); + } + TRACE(2, "%s, %d", __func__, resend); } -static void app_ibrt_ota_config_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - if(resend > 0) - { - tws_ctrl_send_cmd(IBRT_OTA_TWS_OTA_CONFIG_CMD, p_buff, length); - resend--; - } - else - { - resend = RESEND_TIME; - } - TRACE(2,"%s, %d", __func__, resend); +static void app_ibrt_ota_config_cmd_send(uint8_t *p_buff, uint16_t length) { + app_ibrt_send_cmd_with_rsp(IBRT_OTA_TWS_OTA_CONFIG_CMD, p_buff, length); + TRACE(1, "%s", __func__); } -static void app_ibrt_ota_segment_crc_cmd_send(uint8_t *p_buff, uint16_t length) -{ - app_ibrt_send_cmd_with_rsp(IBRT_OTA_TWS_SEGMENT_CRC_CMD, p_buff, length); - TRACE(1,"%s", __func__); +void app_ibrt_ota_config_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + if (ibrt_ota_cmd_type == OTA_RSP_CONFIG) { + if (*p_buff == 1 && errOtaCode == 1) { + ibrt_ota_send_configuration_response(true); + tws_ctrl_send_rsp(IBRT_OTA_TWS_OTA_CONFIG_CMD, rsp_seq, p_buff, length); + } else if (*p_buff == OTA_RESULT_ERR_IMAGE_SIZE || + errOtaCode == OTA_RESULT_ERR_IMAGE_SIZE) { + uint8_t errImageSize = OTA_RESULT_ERR_IMAGE_SIZE; + ibrt_ota_send_result_response(OTA_RESULT_ERR_IMAGE_SIZE); + tws_ctrl_send_rsp(IBRT_OTA_TWS_OTA_CONFIG_CMD, rsp_seq, + (uint8_t *)&errImageSize, length); + } else if (*p_buff == OTA_RESULT_ERR_BREAKPOINT || + errOtaCode == OTA_RESULT_ERR_BREAKPOINT) { + uint8_t errBreakPoint = OTA_RESULT_ERR_BREAKPOINT; + ota_upgradeLog_destroy(); + ibrt_ota_send_result_response(OTA_RESULT_ERR_BREAKPOINT); + tws_ctrl_send_rsp(IBRT_OTA_TWS_OTA_CONFIG_CMD, rsp_seq, + (uint8_t *)&errBreakPoint, length); + } else { + ibrt_ota_send_configuration_response(false); + tws_ctrl_send_rsp(IBRT_OTA_TWS_OTA_CONFIG_CMD, rsp_seq, p_buff, length); + } + errOtaCode = 0; + ibrt_ota_cmd_type = 0; + } else { + app_ibrt_ota_cache_slave_info(OTA_RSP_CONFIG, rsp_seq, p_buff, length); + } + TRACE(1, "%s", __func__); } -void app_ibrt_ota_segment_crc_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - if(ibrt_ota_cmd_type == OTA_RSP_SEGMENT_VERIFY) - { - TRACE(3,"%s: %d %d", __func__,*p_buff,errOtaCode); - if(*p_buff == 1 && errOtaCode == 1) - { - ibrt_ota_send_segment_verification_response(true); - tws_ctrl_send_rsp(IBRT_OTA_TWS_SEGMENT_CRC_CMD, rsp_seq, p_buff, length); - } - else if(*p_buff == OTA_RESULT_ERR_SEG_VERIFY || errOtaCode == OTA_RESULT_ERR_SEG_VERIFY) - { - uint8_t errSegVerify = OTA_RESULT_ERR_SEG_VERIFY; - ota_upgradeLog_destroy(); - ibrt_ota_send_result_response(OTA_RESULT_ERR_SEG_VERIFY); - tws_ctrl_send_rsp(IBRT_OTA_TWS_SEGMENT_CRC_CMD, rsp_seq, (uint8_t *)&errSegVerify, length); - } - else if(*p_buff == OTA_RESULT_ERR_FLASH_OFFSET || errOtaCode == OTA_RESULT_ERR_FLASH_OFFSET) - { - uint8_t errFlashOffset = OTA_RESULT_ERR_FLASH_OFFSET; - ota_upgradeLog_destroy(); - ibrt_ota_send_result_response(OTA_RESULT_ERR_FLASH_OFFSET); - tws_ctrl_send_rsp(IBRT_OTA_TWS_SEGMENT_CRC_CMD, rsp_seq, (uint8_t *)&errFlashOffset, length); - } - else - { - ibrt_ota_send_segment_verification_response(false); - tws_ctrl_send_rsp(IBRT_OTA_TWS_SEGMENT_CRC_CMD, rsp_seq, p_buff, length); - } - errOtaCode = 0; - ibrt_ota_cmd_type = 0; - } - else - { - app_ibrt_ota_cache_slave_info(OTA_RSP_SEGMENT_VERIFY, rsp_seq, p_buff, length); - } - TRACE(1,"%s", __func__); +static void app_ibrt_ota_config_cmd_send_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + resend = RESEND_TIME; + if (*p_buff == OTA_RESULT_ERR_BREAKPOINT) { + ota_upgradeLog_destroy(); + } + TRACE(1, "%s", __func__); } -static void app_ibrt_ota_segment_crc_cmd_send_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ +static void app_ibrt_ota_config_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + if (resend > 0) { + tws_ctrl_send_cmd(IBRT_OTA_TWS_OTA_CONFIG_CMD, p_buff, length); + resend--; + } else { resend = RESEND_TIME; - if(*p_buff == OTA_RESULT_ERR_SEG_VERIFY || *p_buff == OTA_RESULT_ERR_FLASH_OFFSET) - { - ota_upgradeLog_destroy(); - } - TRACE(1,"%s", __func__); + } + TRACE(2, "%s, %d", __func__, resend); } -static void app_ibrt_ota_segment_crc_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - if(resend > 0) - { - tws_ctrl_send_cmd(IBRT_OTA_TWS_SEGMENT_CRC_CMD, p_buff, length); - resend--; - } - else - { - resend = RESEND_TIME; - } - TRACE(2,"%s, %d", __func__, resend); +static void app_ibrt_ota_segment_crc_cmd_send(uint8_t *p_buff, + uint16_t length) { + app_ibrt_send_cmd_with_rsp(IBRT_OTA_TWS_SEGMENT_CRC_CMD, p_buff, length); + TRACE(1, "%s", __func__); } -static void app_ibrt_ota_image_crc_cmd_send(uint8_t *p_buff, uint16_t length) -{ - app_ibrt_send_cmd_with_rsp(IBRT_OTA_TWS_IMAGE_CRC_CMD, p_buff, length); - TRACE(1,"%s", __func__); +void app_ibrt_ota_segment_crc_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + if (ibrt_ota_cmd_type == OTA_RSP_SEGMENT_VERIFY) { + TRACE(3, "%s: %d %d", __func__, *p_buff, errOtaCode); + if (*p_buff == 1 && errOtaCode == 1) { + ibrt_ota_send_segment_verification_response(true); + tws_ctrl_send_rsp(IBRT_OTA_TWS_SEGMENT_CRC_CMD, rsp_seq, p_buff, length); + } else if (*p_buff == OTA_RESULT_ERR_SEG_VERIFY || + errOtaCode == OTA_RESULT_ERR_SEG_VERIFY) { + uint8_t errSegVerify = OTA_RESULT_ERR_SEG_VERIFY; + ota_upgradeLog_destroy(); + ibrt_ota_send_result_response(OTA_RESULT_ERR_SEG_VERIFY); + tws_ctrl_send_rsp(IBRT_OTA_TWS_SEGMENT_CRC_CMD, rsp_seq, + (uint8_t *)&errSegVerify, length); + } else if (*p_buff == OTA_RESULT_ERR_FLASH_OFFSET || + errOtaCode == OTA_RESULT_ERR_FLASH_OFFSET) { + uint8_t errFlashOffset = OTA_RESULT_ERR_FLASH_OFFSET; + ota_upgradeLog_destroy(); + ibrt_ota_send_result_response(OTA_RESULT_ERR_FLASH_OFFSET); + tws_ctrl_send_rsp(IBRT_OTA_TWS_SEGMENT_CRC_CMD, rsp_seq, + (uint8_t *)&errFlashOffset, length); + } else { + ibrt_ota_send_segment_verification_response(false); + tws_ctrl_send_rsp(IBRT_OTA_TWS_SEGMENT_CRC_CMD, rsp_seq, p_buff, length); + } + errOtaCode = 0; + ibrt_ota_cmd_type = 0; + } else { + app_ibrt_ota_cache_slave_info(OTA_RSP_SEGMENT_VERIFY, rsp_seq, p_buff, + length); + } + TRACE(1, "%s", __func__); } -void app_ibrt_ota_image_crc_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - if(ibrt_ota_cmd_type == OTA_RSP_RESULT) - { - if(*p_buff == 1 && errOtaCode == 1) - { - ibrt_ota_send_result_response(true); - tws_ctrl_send_rsp(IBRT_OTA_TWS_IMAGE_CRC_CMD, rsp_seq, p_buff, length); - errOtaCode = 0; - } - else - { - uint8_t crcErr = 0; - ibrt_ota_send_result_response(false); - ota_upgradeLog_destroy(); - ota_control_reset_env(); - tws_ctrl_send_rsp(IBRT_OTA_TWS_IMAGE_CRC_CMD, rsp_seq, (uint8_t *)&crcErr, length); - } - ibrt_ota_cmd_type = 0; - } - else - { - app_ibrt_ota_cache_slave_info(OTA_RSP_RESULT, rsp_seq, p_buff, length); - } - TRACE(1,"%s", __func__); +static void app_ibrt_ota_segment_crc_cmd_send_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + resend = RESEND_TIME; + if (*p_buff == OTA_RESULT_ERR_SEG_VERIFY || + *p_buff == OTA_RESULT_ERR_FLASH_OFFSET) { + ota_upgradeLog_destroy(); + } + TRACE(1, "%s", __func__); } -static void app_ibrt_ota_image_crc_cmd_send_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ +static void app_ibrt_ota_segment_crc_cmd_send_rsp_timeout_handler( + uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) { + if (resend > 0) { + tws_ctrl_send_cmd(IBRT_OTA_TWS_SEGMENT_CRC_CMD, p_buff, length); + resend--; + } else { resend = RESEND_TIME; - if(*p_buff == 0) - { - ota_upgradeLog_destroy(); - ota_control_reset_env(); - } - TRACE(1,"%s", __func__); + } + TRACE(2, "%s, %d", __func__, resend); } -static void app_ibrt_ota_image_crc_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - if(resend > 0) - { - tws_ctrl_send_cmd(IBRT_OTA_TWS_IMAGE_CRC_CMD, p_buff, length); - resend--; - } - else - { - resend = RESEND_TIME; - } - TRACE(2,"%s, %d", __func__, resend); +static void app_ibrt_ota_image_crc_cmd_send(uint8_t *p_buff, uint16_t length) { + app_ibrt_send_cmd_with_rsp(IBRT_OTA_TWS_IMAGE_CRC_CMD, p_buff, length); + TRACE(1, "%s", __func__); } -static void app_ibrt_ota_image_overwrite_cmd_send(uint8_t *p_buff, uint16_t length) -{ - app_ibrt_send_cmd_with_rsp(IBRT_OTA_TWS_IMAGE_OVERWRITE_CMD, p_buff, length); - TRACE(1,"%s", __func__); -} - -void app_ibrt_ota_image_overwrite_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - if(ibrt_ota_cmd_type == OTA_RSP_IMAGE_APPLY) - { - if(*p_buff == 1 && errOtaCode == 1) - { - int ret = tws_ctrl_send_rsp(IBRT_OTA_TWS_IMAGE_OVERWRITE_CMD, rsp_seq, p_buff, length); - if(0 == ret) - { - ota_update_info(); - ota_control_image_apply_rsp(true); - ota_check_and_reboot_to_use_new_image(); - } - } - else - { - uint8_t cantOverWrite = 0; - ota_control_image_apply_rsp(false); - tws_ctrl_send_rsp(IBRT_OTA_TWS_IMAGE_OVERWRITE_CMD, rsp_seq, (uint8_t *)&cantOverWrite, length); - } - errOtaCode = 0; - ibrt_ota_cmd_type = 0; +void app_ibrt_ota_image_crc_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + if (ibrt_ota_cmd_type == OTA_RSP_RESULT) { + if (*p_buff == 1 && errOtaCode == 1) { + ibrt_ota_send_result_response(true); + tws_ctrl_send_rsp(IBRT_OTA_TWS_IMAGE_CRC_CMD, rsp_seq, p_buff, length); + errOtaCode = 0; + } else { + uint8_t crcErr = 0; + ibrt_ota_send_result_response(false); + ota_upgradeLog_destroy(); + ota_control_reset_env(); + tws_ctrl_send_rsp(IBRT_OTA_TWS_IMAGE_CRC_CMD, rsp_seq, (uint8_t *)&crcErr, + length); } - TRACE(1,"%s", __func__); + ibrt_ota_cmd_type = 0; + } else { + app_ibrt_ota_cache_slave_info(OTA_RSP_RESULT, rsp_seq, p_buff, length); + } + TRACE(1, "%s", __func__); } -static void app_ibrt_ota_image_overwrite_cmd_send_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ +static void app_ibrt_ota_image_crc_cmd_send_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + resend = RESEND_TIME; + if (*p_buff == 0) { + ota_upgradeLog_destroy(); + ota_control_reset_env(); + } + TRACE(1, "%s", __func__); +} + +static void app_ibrt_ota_image_crc_cmd_send_rsp_timeout_handler( + uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) { + if (resend > 0) { + tws_ctrl_send_cmd(IBRT_OTA_TWS_IMAGE_CRC_CMD, p_buff, length); + resend--; + } else { resend = RESEND_TIME; - if(*p_buff == 1) - { + } + TRACE(2, "%s, %d", __func__, resend); +} + +static void app_ibrt_ota_image_overwrite_cmd_send(uint8_t *p_buff, + uint16_t length) { + app_ibrt_send_cmd_with_rsp(IBRT_OTA_TWS_IMAGE_OVERWRITE_CMD, p_buff, length); + TRACE(1, "%s", __func__); +} + +void app_ibrt_ota_image_overwrite_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + if (ibrt_ota_cmd_type == OTA_RSP_IMAGE_APPLY) { + if (*p_buff == 1 && errOtaCode == 1) { + int ret = tws_ctrl_send_rsp(IBRT_OTA_TWS_IMAGE_OVERWRITE_CMD, rsp_seq, + p_buff, length); + if (0 == ret) { ota_update_info(); + ota_control_image_apply_rsp(true); ota_check_and_reboot_to_use_new_image(); + } + } else { + uint8_t cantOverWrite = 0; + ota_control_image_apply_rsp(false); + tws_ctrl_send_rsp(IBRT_OTA_TWS_IMAGE_OVERWRITE_CMD, rsp_seq, + (uint8_t *)&cantOverWrite, length); } - TRACE(1,"%s", __func__); + errOtaCode = 0; + ibrt_ota_cmd_type = 0; + } + TRACE(1, "%s", __func__); } -static void app_ibrt_ota_image_overwrite_cmd_send_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - if(resend > 0) - { - tws_ctrl_send_cmd(IBRT_OTA_TWS_IMAGE_OVERWRITE_CMD, p_buff, length); - resend--; - } - else - { - resend = RESEND_TIME; - } - TRACE(2,"%s, %d", __func__, resend); +static void app_ibrt_ota_image_overwrite_cmd_send_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + resend = RESEND_TIME; + if (*p_buff == 1) { + ota_update_info(); + ota_check_and_reboot_to_use_new_image(); + } + TRACE(1, "%s", __func__); } -static void app_ibrt_ota_image_buff_cmd_send(uint8_t *p_buff, uint16_t length) -{ - app_ibrt_send_cmd_without_rsp(IBRT_OTA_TWS_IMAGE_BUFF, p_buff, length); - TRACE(1,"%s", __func__); +static void app_ibrt_ota_image_overwrite_cmd_send_rsp_timeout_handler( + uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) { + if (resend > 0) { + tws_ctrl_send_cmd(IBRT_OTA_TWS_IMAGE_OVERWRITE_CMD, p_buff, length); + resend--; + } else { + resend = RESEND_TIME; + } + TRACE(2, "%s, %d", __func__, resend); } -static void app_ibrt_ota_image_buff_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - ota_bes_handle_received_data(p_buff, true, length); - TRACE(1,"%s", __func__); +static void app_ibrt_ota_image_buff_cmd_send(uint8_t *p_buff, uint16_t length) { + app_ibrt_send_cmd_without_rsp(IBRT_OTA_TWS_IMAGE_BUFF, p_buff, length); + TRACE(1, "%s", __func__); } -static void app_ibrt_common_ota_cmd_send(uint8_t *p_buff, uint16_t length) -{ - app_ibrt_send_cmd_without_rsp(IBRT_COMMON_OTA, p_buff, length); - TRACE(1,"%s", __func__); +static void app_ibrt_ota_image_buff_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + ota_bes_handle_received_data(p_buff, true, length); + TRACE(1, "%s", __func__); } -static void app_ibrt_common_ota_cmd_received(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - ota_common_on_relay_data_received(p_buff, length); +static void app_ibrt_common_ota_cmd_send(uint8_t *p_buff, uint16_t length) { + app_ibrt_send_cmd_without_rsp(IBRT_COMMON_OTA, p_buff, length); + TRACE(1, "%s", __func__); +} + +static void app_ibrt_common_ota_cmd_received(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + ota_common_on_relay_data_received(p_buff, length); } #ifdef IBRT_OTA -static void app_ibrt_ota_start_role_switch_cmd_send(uint8_t *p_buff, uint16_t length) -{ - app_ibrt_send_cmd_without_rsp(IBRT_OTA_TWS_ROLE_SWITCH_CMD, p_buff, length); - TRACE(1,"%s", __func__); +static void app_ibrt_ota_start_role_switch_cmd_send(uint8_t *p_buff, + uint16_t length) { + app_ibrt_send_cmd_without_rsp(IBRT_OTA_TWS_ROLE_SWITCH_CMD, p_buff, length); + TRACE(1, "%s", __func__); } -static void app_ibrt_ota_start_role_switch_cmd_send_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - TRACE(2,"%s:%d %d", __func__,p_buff[0],length); +static void app_ibrt_ota_start_role_switch_cmd_send_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + TRACE(2, "%s:%d %d", __func__, p_buff[0], length); - if ((p_buff[0] == OTA_RS_INFO_MASTER_SEND_RS_REQ_CMD)&&(length == 1)) - { - bes_ota_send_role_switch_req(); - } - else if ((p_buff[0] == OTA_RS_INFO_MASTER_DISCONECT_CMD)&&(length == 1)) - { - ota_disconnect(); - } + if ((p_buff[0] == OTA_RS_INFO_MASTER_SEND_RS_REQ_CMD) && (length == 1)) { + bes_ota_send_role_switch_req(); + } else if ((p_buff[0] == OTA_RS_INFO_MASTER_DISCONECT_CMD) && (length == 1)) { + ota_disconnect(); + } } #endif #endif diff --git a/services/app_ibrt/src/app_ibrt_ota_update.cpp b/services/app_ibrt/src/app_ibrt_ota_update.cpp index f3cff5e..fcc89a6 100644 --- a/services/app_ibrt/src/app_ibrt_ota_update.cpp +++ b/services/app_ibrt/src/app_ibrt_ota_update.cpp @@ -12,27 +12,27 @@ * BES. which is protected by copyright, trade secret, * trademark and other intellectual property rights. * - ****************************************************************************/ + ****************************************************************************/ #ifdef __INTERACTION__ #if defined(IBRT) -#include "cmsis_os.h" -#include -#include "me_api.h" +#include "app_ibrt_ota_update.h" +#include "app_bt_stream.h" +#include "app_ibrt_if.h" +#include "app_interaction.h" +#include "app_interaction_ota.h" +#include "app_media_player.h" +#include "app_tws_ctrl_thread.h" +#include "app_tws_ibrt_cmd_handler.h" #include "app_tws_ibrt_trace.h" #include "audioflinger.h" -#include "app_bt_stream.h" -#include "app_media_player.h" #include "bt_drv_interface.h" -#include "app_ibrt_if.h" -#include "app_tws_ibrt_cmd_handler.h" -#include "app_tws_ctrl_thread.h" -#include "app_ibrt_ota_update.h" -#include "app_interaction_ota.h" -#include "app_interaction.h" -#include "hal_norflash.h" #include "cmsis.h" -#include "pmu.h" +#include "cmsis_os.h" #include "crc32.h" +#include "hal_norflash.h" +#include "me_api.h" +#include "pmu.h" +#include extern uint32_t __ota_upgrade_log_start[]; extern INTERACTION_OTA_VALIDATION_DONE_CFM_T Ota_validation_done_cfm; extern uint32_t get_upgradeSize_log(void); @@ -40,389 +40,425 @@ extern uint32_t breakPoint_local; extern uint32_t breakPoint_remote; extern app_ibrt_ota_cmd_code_e cmd_rsp_type; -uint8_t* ota_address = NULL; +uint8_t *ota_address = NULL; uint32_t ota_address_offset = 0; bool ota_check_md5 = 1; uint32_t error_list[16] = {0}; -static void app_ota_reset_timer_handler(void const *param) -{ - app_interaction_ota_finished_handler(); +static void app_ota_reset_timer_handler(void const *param) { + app_interaction_ota_finished_handler(); } -osTimerDef (APP_OTA_RESET, app_ota_reset_timer_handler); +osTimerDef(APP_OTA_RESET, app_ota_reset_timer_handler); static osTimerId app_ota_reset_timer = NULL; /* -* custom cmd handler add here, this is just a example -*/ + * custom cmd handler add here, this is just a example + */ static void app_ibrt_ota_update_now(uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_update_now_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_update_now_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_ota_update_now_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +static void app_ibrt_ota_update_now_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length); +static void app_ibrt_ota_update_now_rsp_timeout_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_ota_update_now_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); static void app_ibrt_check_update_info(uint8_t *p_buff, uint16_t length); -static void app_ibrt_check_update_info_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_check_update_info2_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +static void app_ibrt_check_update_info_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_check_update_info2_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); static void app_ibrt_sync_breakpoint(uint8_t *p_buff, uint16_t length); -static void app_ibrt_sync_breakpoint_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_sync_breakpoint_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_sync_breakpoint_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +static void app_ibrt_sync_breakpoint_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length); +static void app_ibrt_sync_breakpoint_rsp_timeout_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_sync_breakpoint_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); static void app_ibrt_validation(uint8_t *p_buff, uint16_t length); -static void app_ibrt_validation_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_validation_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_validation_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +static void app_ibrt_validation_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length); +static void app_ibrt_validation_rsp_timeout_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_validation_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length); static void app_ibrt_update_section(uint8_t *p_buff, uint16_t length); -static void app_ibrt_update_section_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_update_section_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -static void app_ibrt_update_section_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +static void app_ibrt_update_section_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length); +static void app_ibrt_update_section_rsp_timeout_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +static void app_ibrt_update_section_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); -void app_ibrt_view_update_list(void) -{ - TRACE(0,"view_update_list start: ====================="); - for(uint8_t i=0;i<16;i+=8) - TRACE(8,"0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x",error_list[i],error_list[i+1],error_list[i+2],error_list[i+3],error_list[i+4],error_list[i+5],error_list[i+6],error_list[i+7]); - TRACE(0,"view_update_list end: ====================="); +void app_ibrt_view_update_list(void) { + TRACE(0, "view_update_list start: ====================="); + for (uint8_t i = 0; i < 16; i += 8) + TRACE(8, "0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x", + error_list[i], error_list[i + 1], error_list[i + 2], + error_list[i + 3], error_list[i + 4], error_list[i + 5], + error_list[i + 6], error_list[i + 7]); + TRACE(0, "view_update_list end: ====================="); } -void app_ibrt_view_update_sector(void) -{ - TRACE(0,"view_update_sector start: ====================="); - TRACE(2,"0x%08x 0x%08x\n",__ota_upgrade_log_start[0],__ota_upgrade_log_start[1]); - for(uint16_t i=2;i<512;i+=8){ - if(i!=506){ - TRACE(9,"%d 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x",i,__ota_upgrade_log_start[i],__ota_upgrade_log_start[i+1],__ota_upgrade_log_start[i+2],__ota_upgrade_log_start[i+3],__ota_upgrade_log_start[i+4],__ota_upgrade_log_start[i+5],__ota_upgrade_log_start[i+6],__ota_upgrade_log_start[i+7]); - }else{ - TRACE(7,"%d 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x",i,__ota_upgrade_log_start[i],__ota_upgrade_log_start[i+1],__ota_upgrade_log_start[i+2],__ota_upgrade_log_start[i+3],__ota_upgrade_log_start[i+4],__ota_upgrade_log_start[i+5]); - } - } - TRACE(0,"view_update_sector end: ====================="); -} - -void reset_error_list() -{ - memset(error_list,0,sizeof(error_list)); -} - -void set_all_error_list() -{ - memset(error_list,0xFFFFFFFF,sizeof(error_list)); -} - -void set_error_list(uint16_t list) -{ - if(list < 512) - error_list[list/32] |= (1 << (31-list%32)); -} - -void clr_error_list(uint16_t list) -{ - if(list < 512) - error_list[list/32] &= ~(1 << (31-list%32)); -} - -uint32_t get_error_list() -{ - int8_t i,j; - for(i=0;i<16;i++){ - for(j=31;j>=0;j--){ - if(error_list[i]&(1<= 0; j--) { + if (error_list[i] & (1 << j)) + return (i * 32 + 32 - j) * 0x1000; + } + } + return 0; +} + +static app_tws_cmd_instance_t g_ibrt_ota_cmd_handler_table[] = { + {APP_TWS_CMD_OTA_UPDATE_NOW, "OTA_UPDATE_NOW", app_ibrt_ota_update_now, + app_ibrt_ota_update_now_handler, RSP_TIMEOUT_DEFAULT, + app_ibrt_ota_update_now_rsp_timeout_handler, + app_ibrt_ota_update_now_rsp_handler}, + {APP_TWS_CMD_CHECK_UPDATE_INFO, "CHECK_UPDATE_INFO", + app_ibrt_check_update_info, app_ibrt_check_update_info_handler, 0, 0, 0}, + {APP_TWS_CMD_CHECK_UPDATE_INFO2, "CHECK_UPDATE_INFO2", 0, + app_ibrt_check_update_info2_handler, 0, 0, 0}, + {APP_TWS_CMD_SYNC_BREAKPIONT, "SYNC_BREAKPIONT", app_ibrt_sync_breakpoint, + app_ibrt_sync_breakpoint_handler, RSP_TIMEOUT_DEFAULT, + app_ibrt_sync_breakpoint_rsp_timeout_handler, + app_ibrt_sync_breakpoint_rsp_handler}, + {APP_TWS_CMD_VALIDATION_DONE, "VALIDATION_DONE", app_ibrt_validation, + app_ibrt_validation_handler, RSP_TIMEOUT_DEFAULT, + app_ibrt_validation_rsp_timeout_handler, app_ibrt_validation_rsp_handler}, + {APP_TWS_CMD_UPDATE_SECTION, "UPDATE_SECTION", app_ibrt_update_section, + app_ibrt_update_section_handler, RSP_TIMEOUT_DEFAULT, + app_ibrt_update_section_rsp_timeout_handler, + app_ibrt_update_section_rsp_handler}, }; -int app_ibrt_ota_cmd_table_get(void **cmd_tbl, uint16_t *cmd_size) -{ - *cmd_tbl = (void *)&g_ibrt_ota_cmd_handler_table; - *cmd_size = ARRAY_SIZE(g_ibrt_ota_cmd_handler_table); - return 0; +int app_ibrt_ota_cmd_table_get(void **cmd_tbl, uint16_t *cmd_size) { + *cmd_tbl = (void *)&g_ibrt_ota_cmd_handler_table; + *cmd_size = ARRAY_SIZE(g_ibrt_ota_cmd_handler_table); + return 0; } /*===============================================================================*/ -void app_ibrt_ota_update_immediately(void) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (p_ibrt_ctrl->nv_role == IBRT_MASTER) - { - if (app_ota_reset_timer == NULL) - app_ota_reset_timer = osTimerCreate (osTimer(APP_OTA_RESET), osTimerOnce, NULL); - osTimerStop(app_ota_reset_timer); - osTimerStart(app_ota_reset_timer, 500); - tws_ctrl_send_cmd(APP_TWS_CMD_OTA_UPDATE_NOW, NULL, 0); - } +void app_ibrt_ota_update_immediately(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (p_ibrt_ctrl->nv_role == IBRT_MASTER) { + if (app_ota_reset_timer == NULL) + app_ota_reset_timer = + osTimerCreate(osTimer(APP_OTA_RESET), osTimerOnce, NULL); + osTimerStop(app_ota_reset_timer); + osTimerStart(app_ota_reset_timer, 500); + tws_ctrl_send_cmd(APP_TWS_CMD_OTA_UPDATE_NOW, NULL, 0); + } } -void app_ibrt_ota_update_now(uint8_t *p_buff, uint16_t length) -{ - app_ibrt_send_cmd_with_rsp(APP_TWS_CMD_OTA_UPDATE_NOW, NULL, 0); +void app_ibrt_ota_update_now(uint8_t *p_buff, uint16_t length) { + app_ibrt_send_cmd_with_rsp(APP_TWS_CMD_OTA_UPDATE_NOW, NULL, 0); } -void app_ibrt_ota_update_now_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - app_interaction_ota_finished_handler(); +void app_ibrt_ota_update_now_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + app_interaction_ota_finished_handler(); } -void app_ibrt_ota_update_now_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - TRACE(1,"ibrt_ui_log:%s",__func__); +void app_ibrt_ota_update_now_rsp_timeout_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + TRACE(1, "ibrt_ui_log:%s", __func__); } -void app_ibrt_ota_update_now_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - TRACE(2,"ibrt_ui_log:0x%08x,%d",p_buff,length); +void app_ibrt_ota_update_now_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + TRACE(2, "ibrt_ui_log:0x%08x,%d", p_buff, length); } /*===============================================================================*/ -void app_ibrt_ota_check_update_info(void) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - reset_error_list(); - if (p_ibrt_ctrl->nv_role == IBRT_MASTER) - tws_ctrl_send_cmd(APP_TWS_CMD_CHECK_UPDATE_INFO, NULL, 0); +void app_ibrt_ota_check_update_info(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + reset_error_list(); + if (p_ibrt_ctrl->nv_role == IBRT_MASTER) + tws_ctrl_send_cmd(APP_TWS_CMD_CHECK_UPDATE_INFO, NULL, 0); } -void app_ibrt_check_update_info(uint8_t *p_buff, uint16_t length) -{ - if(ota_address_offset >= FLASH_SECTOR_SIZE_IN_BYTES){ - TRACE(0,"ibrt_ui_log:app_ibrt_get_update_list before ota completed!!!!!!\n"); - ota_check_md5 = 1; - ota_address_offset = 0; - ota_address = (uint8_t*)__ota_upgrade_log_start; - app_ibrt_view_update_list(); - tws_ctrl_send_cmd(cmd_rsp_type, NULL, 0); - }else{ - ibrt_ota_check_cmd_t cmd; - cmd.length = APP_TWS_CTRL_BUFFER_LEN; - cmd.address = ota_address = (uint8_t*)__ota_upgrade_log_start + ota_address_offset; - breakPoint_local = breakPoint_remote = 0; - TRACE(2,"== > addr:0x%08x length:%d\n", cmd.address, cmd.length); - app_ibrt_send_cmd_without_rsp(APP_TWS_CMD_CHECK_UPDATE_INFO, (uint8_t*)&cmd, sizeof(ibrt_ota_check_cmd_t)); +void app_ibrt_check_update_info(uint8_t *p_buff, uint16_t length) { + if (ota_address_offset >= FLASH_SECTOR_SIZE_IN_BYTES) { + TRACE(0, + "ibrt_ui_log:app_ibrt_get_update_list before ota completed!!!!!!\n"); + ota_check_md5 = 1; + ota_address_offset = 0; + ota_address = (uint8_t *)__ota_upgrade_log_start; + app_ibrt_view_update_list(); + tws_ctrl_send_cmd(cmd_rsp_type, NULL, 0); + } else { + ibrt_ota_check_cmd_t cmd; + cmd.length = APP_TWS_CTRL_BUFFER_LEN; + cmd.address = ota_address = + (uint8_t *)__ota_upgrade_log_start + ota_address_offset; + breakPoint_local = breakPoint_remote = 0; + TRACE(2, "== > addr:0x%08x length:%d\n", cmd.address, cmd.length); + app_ibrt_send_cmd_without_rsp(APP_TWS_CMD_CHECK_UPDATE_INFO, + (uint8_t *)&cmd, + sizeof(ibrt_ota_check_cmd_t)); + } +} + +void app_ibrt_check_update_info_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + ibrt_ota_check_cmd_t *p_ibrt_ota_check_cmd = (ibrt_ota_check_cmd_t *)p_buff; + app_ibrt_send_cmd_without_rsp(APP_TWS_CMD_CHECK_UPDATE_INFO2, + p_ibrt_ota_check_cmd->address, + p_ibrt_ota_check_cmd->length); +} + +void app_ibrt_check_update_info2_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + for (uint16_t i = 0; i < length / 4; i += 2) { + if (ota_check_md5) { + ota_check_md5 = 0; + if (*((uint32_t *)ota_address) != *((uint32_t *)p_buff)) { + TRACE(0, "md5 header error!!!!!"); + TRACE(2, "== >>>0 0x%08x 0x%08x", *((uint32_t *)ota_address), + *((uint32_t *)p_buff)); + set_all_error_list(); + ota_address_offset = FLASH_SECTOR_SIZE_IN_BYTES; + break; + } + } else { + if ((*((uint32_t *)ota_address + i) != *((uint32_t *)p_buff + i)) || + (*((uint32_t *)ota_address + i + 1) != + *((uint32_t *)p_buff + i + 1))) { + TRACE(1, "%d offset or crc error!!!!!", i); + TRACE(2, "== >>>1 0x%08x 0x%08x", *((uint32_t *)ota_address + i), + *((uint32_t *)p_buff + i)); + TRACE(2, "== >>>2 0x%08x 0x%08x", *((uint32_t *)ota_address + i + 1), + *((uint32_t *)p_buff + i + 1)); + set_error_list(ota_address_offset / 8 + (i - 2) / 2); + } } + } + ota_address_offset += APP_TWS_CTRL_BUFFER_LEN; + app_ibrt_check_update_info(NULL, 0); } -void app_ibrt_check_update_info_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - ibrt_ota_check_cmd_t *p_ibrt_ota_check_cmd = (ibrt_ota_check_cmd_t *)p_buff; - app_ibrt_send_cmd_without_rsp(APP_TWS_CMD_CHECK_UPDATE_INFO2, p_ibrt_ota_check_cmd->address, p_ibrt_ota_check_cmd->length); -} - -void app_ibrt_check_update_info2_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - for(uint16_t i=0;i>>0 0x%08x 0x%08x",*((uint32_t*)ota_address),*((uint32_t*)p_buff)); - set_all_error_list(); - ota_address_offset = FLASH_SECTOR_SIZE_IN_BYTES; - break; - } - }else{ - if((*((uint32_t*)ota_address+i) != *((uint32_t*)p_buff+i))||(*((uint32_t*)ota_address+i+1) != *((uint32_t*)p_buff+i+1))){ - TRACE(1,"%d offset or crc error!!!!!",i); - TRACE(2,"== >>>1 0x%08x 0x%08x",*((uint32_t*)ota_address+i),*((uint32_t*)p_buff+i)); - TRACE(2,"== >>>2 0x%08x 0x%08x",*((uint32_t*)ota_address+i+1),*((uint32_t*)p_buff+i+1)); - set_error_list(ota_address_offset/8+(i-2)/2); - } - } - } - ota_address_offset += APP_TWS_CTRL_BUFFER_LEN; - app_ibrt_check_update_info(NULL,0); -} - - /*===============================================================================*/ -void app_ibrt_sync_breakpoint(uint8_t *p_buff, uint16_t length) -{ - ibrt_ota_sync_breakpoint_cmd_t cmd; - cmd.local_point = breakPoint_local = get_upgradeSize_log(); - cmd.remote_point = breakPoint_remote = get_error_list(); - app_ibrt_send_cmd_with_rsp(APP_TWS_CMD_SYNC_BREAKPIONT, (uint8_t*)&cmd, sizeof(ibrt_ota_check_cmd_t)); +void app_ibrt_sync_breakpoint(uint8_t *p_buff, uint16_t length) { + ibrt_ota_sync_breakpoint_cmd_t cmd; + cmd.local_point = breakPoint_local = get_upgradeSize_log(); + cmd.remote_point = breakPoint_remote = get_error_list(); + app_ibrt_send_cmd_with_rsp(APP_TWS_CMD_SYNC_BREAKPIONT, (uint8_t *)&cmd, + sizeof(ibrt_ota_check_cmd_t)); } -void app_ibrt_sync_breakpoint_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - ibrt_ota_sync_breakpoint_cmd_t* cmd = (ibrt_ota_sync_breakpoint_cmd_t *)p_buff; - breakPoint_local = cmd->local_point; - breakPoint_remote = cmd->remote_point; - tws_ctrl_send_rsp(APP_TWS_CMD_SYNC_BREAKPIONT, rsp_seq, NULL, 0); +void app_ibrt_sync_breakpoint_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + ibrt_ota_sync_breakpoint_cmd_t *cmd = + (ibrt_ota_sync_breakpoint_cmd_t *)p_buff; + breakPoint_local = cmd->local_point; + breakPoint_remote = cmd->remote_point; + tws_ctrl_send_rsp(APP_TWS_CMD_SYNC_BREAKPIONT, rsp_seq, NULL, 0); } -void app_ibrt_sync_breakpoint_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - app_interaction_ota_upgrade_sys_rsp(); +void app_ibrt_sync_breakpoint_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + app_interaction_ota_upgrade_sys_rsp(); } -void app_ibrt_sync_breakpoint_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ +void app_ibrt_sync_breakpoint_rsp_timeout_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) {} + +void app_ibrt_validation(uint8_t *p_buff, uint16_t length) { + ibrt_ota_sync_validation_cmd_t cmd; + if (get_error_list() == 0) { + cmd.flag = INTERACTION_SUCESS; + Ota_validation_done_cfm.status = INTERACTION_SUCESS; + } else { + cmd.flag = INTERACTION_VALIDATION_FAILURE; + Ota_validation_done_cfm.status = INTERACTION_VALIDATION_FAILURE; + } + app_interaction_ota_upgrade_is_validation_done_rsp(); + app_ibrt_send_cmd_with_rsp(APP_TWS_CMD_VALIDATION_DONE, (uint8_t *)&cmd, + sizeof(ibrt_ota_sync_validation_cmd_t)); } -void app_ibrt_validation(uint8_t *p_buff, uint16_t length) -{ - ibrt_ota_sync_validation_cmd_t cmd; - if(get_error_list() == 0){ - cmd.flag = INTERACTION_SUCESS; - Ota_validation_done_cfm.status = INTERACTION_SUCESS; - }else{ - cmd.flag = INTERACTION_VALIDATION_FAILURE; - Ota_validation_done_cfm.status = INTERACTION_VALIDATION_FAILURE; - } - app_interaction_ota_upgrade_is_validation_done_rsp(); - app_ibrt_send_cmd_with_rsp(APP_TWS_CMD_VALIDATION_DONE, (uint8_t*)&cmd, sizeof(ibrt_ota_sync_validation_cmd_t)); +void app_ibrt_validation_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + ibrt_ota_sync_validation_cmd_t *cmd = + (ibrt_ota_sync_validation_cmd_t *)p_buff; + if (cmd->flag == INTERACTION_SUCESS) { + app_interaction_ota_upgrade_is_complete_hanlder(); // for send 0x0305 cmd to + // phone; + } + tws_ctrl_send_rsp(APP_TWS_CMD_VALIDATION_DONE, rsp_seq, NULL, 0); + app_interaction_ota_finished_handler(); } -void app_ibrt_validation_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - ibrt_ota_sync_validation_cmd_t* cmd = (ibrt_ota_sync_validation_cmd_t *)p_buff; - if(cmd->flag == INTERACTION_SUCESS){ - app_interaction_ota_upgrade_is_complete_hanlder(); //for send 0x0305 cmd to phone; - } - tws_ctrl_send_rsp(APP_TWS_CMD_VALIDATION_DONE, rsp_seq, NULL, 0); - app_interaction_ota_finished_handler(); -} - -void app_ibrt_validation_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - app_interaction_ota_upgrade_is_complete_hanlder(); //for send 0x0305 cmd to phone; - app_interaction_ota_finished_handler(); -} - -void app_ibrt_validation_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ +void app_ibrt_validation_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + app_interaction_ota_upgrade_is_complete_hanlder(); // for send 0x0305 cmd to + // phone; + app_interaction_ota_finished_handler(); } +void app_ibrt_validation_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) {} /*===============================================================================*/ -void app_ibrt_ota_force_update(void) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (p_ibrt_ctrl->nv_role == IBRT_MASTER) - { - static uint8_t number = 0; - ibrt_ota_update_cmd_t cmd = {0}; - cmd.point = get_error_list(); - TRACE(1,"update_point: 0x%08x\n", cmd.point); - if(cmd.point != 0){ - cmd.length = APP_TWS_CTRL_BUFFER_LEN; - cmd.address = OTA_FLASH_ENTRY2_OFFSET + cmd.point + number*APP_TWS_CTRL_BUFFER_LEN; - memcpy(cmd.buff,(uint8_t*)cmd.address,APP_TWS_CTRL_BUFFER_LEN); - cmd.number = number%(FLASH_SECTOR_SIZE_IN_BYTES/APP_TWS_CTRL_BUFFER_LEN); - number++; - TRACE(3,"ibrt_ui_log:app_ibrt_ota_force_update addr:0x%08x length:%d no:%d\n", cmd.address, cmd.length, cmd.number); - tws_ctrl_send_cmd(APP_TWS_CMD_UPDATE_SECTION, (uint8_t*)&cmd, sizeof(ibrt_ota_update_cmd_t)); - //TRACE(0,"Calculate the crc32 of the segment."); - //uint32_t startFlashAddr = cmd.address/FLASH_SECTOR_SIZE_IN_BYTES; - //ota_crc = cmd.crc = crc32(0, (uint8_t *)(startFlashAddr), FLASH_SECTOR_SIZE_IN_BYTES); - //TRACE(1,"CRC32 of the segement is 0x%x", cmd.crc); - //TRACE(2,"startFlashAddr is 0x%x, length is %d",startFlashAddr,FLASH_SECTOR_SIZE_IN_BYTES); - }else{ - TRACE(0,"ibrt_ui_log:app_ibrt_ota_force_update completed!!!!!!\n"); - app_ibrt_ota_update_immediately(); - } - } -} - -void app_ibrt_update_section(uint8_t *p_buff, uint16_t length) -{ - app_ibrt_send_cmd_with_rsp(APP_TWS_CMD_UPDATE_SECTION, p_buff, length); -} - -void app_ibrt_update_section_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - ibrt_ota_update_cmd_t *p_ibrt_ota_update_cmd = (ibrt_ota_update_cmd_t *)p_buff; - uint32_t lock; - enum HAL_NORFLASH_RET_T ret = HAL_NORFLASH_OK; - TRACE(4,"ibrt_ui_log:app_ibrt_update_section_handler addr:0x%08x length:%d no:%d point:%d\n", p_ibrt_ota_update_cmd->address, p_ibrt_ota_update_cmd->length, p_ibrt_ota_update_cmd->number, p_ibrt_ota_update_cmd->point); - - lock = int_lock(); - pmu_flash_write_config(); - if(p_ibrt_ota_update_cmd->number == 0){ - ret = hal_norflash_erase(HAL_NORFLASH_ID_0, p_ibrt_ota_update_cmd->address, FLASH_SECTOR_SIZE_IN_BYTES); - TRACE(1,"hal_norflash_erase Sector. %d",ret); - } - - ret = hal_norflash_write(HAL_NORFLASH_ID_0, p_ibrt_ota_update_cmd->address, (uint8_t*)p_ibrt_ota_update_cmd->buff, p_ibrt_ota_update_cmd->length); - TRACE(1,"hal_norflash_write Sector. %d",ret); - pmu_flash_read_config(); - int_unlock(lock); - +void app_ibrt_ota_force_update(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (p_ibrt_ctrl->nv_role == IBRT_MASTER) { + static uint8_t number = 0; ibrt_ota_update_cmd_t cmd = {0}; - cmd.number = p_ibrt_ota_update_cmd->number; - cmd.point = p_ibrt_ota_update_cmd->point; -/* - if(p_ibrt_ota_update_cmd->number == FLASH_SECTOR_SIZE_IN_BYTES/APP_TWS_CTRL_BUFFER_LEN-1){ - TRACE(0,"Calculate the crc32 of the segment."); - uint32_t startFlashAddr = p_ibrt_ota_update_cmd->address - FLASH_SECTOR_SIZE_IN_BYTES + APP_TWS_CTRL_BUFFER_LEN; - cmd.crc = crc32(0, (uint8_t *)(startFlashAddr), FLASH_SECTOR_SIZE_IN_BYTES); - TRACE(1,"CRC32 of the segement is 0x%x", cmd.crc); - TRACE(2,"startFlashAddr is 0x%x, length is %d",startFlashAddr,FLASH_SECTOR_SIZE_IN_BYTES); + cmd.point = get_error_list(); + TRACE(1, "update_point: 0x%08x\n", cmd.point); + if (cmd.point != 0) { + cmd.length = APP_TWS_CTRL_BUFFER_LEN; + cmd.address = OTA_FLASH_ENTRY2_OFFSET + cmd.point + + number * APP_TWS_CTRL_BUFFER_LEN; + memcpy(cmd.buff, (uint8_t *)cmd.address, APP_TWS_CTRL_BUFFER_LEN); + cmd.number = + number % (FLASH_SECTOR_SIZE_IN_BYTES / APP_TWS_CTRL_BUFFER_LEN); + number++; + TRACE( + 3, + "ibrt_ui_log:app_ibrt_ota_force_update addr:0x%08x length:%d no:%d\n", + cmd.address, cmd.length, cmd.number); + tws_ctrl_send_cmd(APP_TWS_CMD_UPDATE_SECTION, (uint8_t *)&cmd, + sizeof(ibrt_ota_update_cmd_t)); + // TRACE(0,"Calculate the crc32 of the segment."); + // uint32_t startFlashAddr = cmd.address/FLASH_SECTOR_SIZE_IN_BYTES; + // ota_crc = cmd.crc = crc32(0, (uint8_t *)(startFlashAddr), + // FLASH_SECTOR_SIZE_IN_BYTES); TRACE(1,"CRC32 of the segement is 0x%x", + // cmd.crc); TRACE(2,"startFlashAddr is 0x%x, length is + // %d",startFlashAddr,FLASH_SECTOR_SIZE_IN_BYTES); + } else { + TRACE(0, "ibrt_ui_log:app_ibrt_ota_force_update completed!!!!!!\n"); + app_ibrt_ota_update_immediately(); } -*/ - tws_ctrl_send_rsp(APP_TWS_CMD_UPDATE_SECTION, rsp_seq, (uint8_t*)&cmd, sizeof(ibrt_ota_update_cmd_t)); + } } -void app_ibrt_update_section_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - TRACE(1,"ibrt_ui_log:%s",__func__); +void app_ibrt_update_section(uint8_t *p_buff, uint16_t length) { + app_ibrt_send_cmd_with_rsp(APP_TWS_CMD_UPDATE_SECTION, p_buff, length); } -void app_ibrt_update_section_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - ibrt_ota_update_cmd_t *p_ibrt_ota_update_rsp = (ibrt_ota_update_cmd_t *)p_buff; - TRACE(3,"ibrt_ui_log:app_ibrt_update_section_rsp_handler addr:0x%08x length:%d no:%d\n", p_ibrt_ota_update_rsp->address, p_ibrt_ota_update_rsp->length, p_ibrt_ota_update_rsp->number); - if(p_ibrt_ota_update_rsp->number == FLASH_SECTOR_SIZE_IN_BYTES/APP_TWS_CTRL_BUFFER_LEN-1){ - TRACE(1,"CRC32 of the update is 0x%08x",p_ibrt_ota_update_rsp->crc); - //if(p_ibrt_ota_update_rsp->crc == ota_crc) - clr_error_list(p_ibrt_ota_update_rsp->point); - app_ibrt_view_update_list(); - } - app_ibrt_ota_force_update(); +void app_ibrt_update_section_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + ibrt_ota_update_cmd_t *p_ibrt_ota_update_cmd = + (ibrt_ota_update_cmd_t *)p_buff; + uint32_t lock; + enum HAL_NORFLASH_RET_T ret = HAL_NORFLASH_OK; + TRACE(4, + "ibrt_ui_log:app_ibrt_update_section_handler addr:0x%08x length:%d " + "no:%d point:%d\n", + p_ibrt_ota_update_cmd->address, p_ibrt_ota_update_cmd->length, + p_ibrt_ota_update_cmd->number, p_ibrt_ota_update_cmd->point); + + lock = int_lock(); + pmu_flash_write_config(); + if (p_ibrt_ota_update_cmd->number == 0) { + ret = hal_norflash_erase(HAL_NORFLASH_ID_0, p_ibrt_ota_update_cmd->address, + FLASH_SECTOR_SIZE_IN_BYTES); + TRACE(1, "hal_norflash_erase Sector. %d", ret); + } + + ret = hal_norflash_write(HAL_NORFLASH_ID_0, p_ibrt_ota_update_cmd->address, + (uint8_t *)p_ibrt_ota_update_cmd->buff, + p_ibrt_ota_update_cmd->length); + TRACE(1, "hal_norflash_write Sector. %d", ret); + pmu_flash_read_config(); + int_unlock(lock); + + ibrt_ota_update_cmd_t cmd = {0}; + cmd.number = p_ibrt_ota_update_cmd->number; + cmd.point = p_ibrt_ota_update_cmd->point; + /* + if(p_ibrt_ota_update_cmd->number == + FLASH_SECTOR_SIZE_IN_BYTES/APP_TWS_CTRL_BUFFER_LEN-1){ TRACE(0,"Calculate + the crc32 of the segment."); uint32_t startFlashAddr = + p_ibrt_ota_update_cmd->address - FLASH_SECTOR_SIZE_IN_BYTES + + APP_TWS_CTRL_BUFFER_LEN; cmd.crc = crc32(0, (uint8_t *)(startFlashAddr), + FLASH_SECTOR_SIZE_IN_BYTES); TRACE(1,"CRC32 of the segement is 0x%x", + cmd.crc); TRACE(2,"startFlashAddr is 0x%x, length is + %d",startFlashAddr,FLASH_SECTOR_SIZE_IN_BYTES); + } + */ + tws_ctrl_send_rsp(APP_TWS_CMD_UPDATE_SECTION, rsp_seq, (uint8_t *)&cmd, + sizeof(ibrt_ota_update_cmd_t)); +} + +void app_ibrt_update_section_rsp_timeout_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + TRACE(1, "ibrt_ui_log:%s", __func__); +} + +void app_ibrt_update_section_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + ibrt_ota_update_cmd_t *p_ibrt_ota_update_rsp = + (ibrt_ota_update_cmd_t *)p_buff; + TRACE(3, + "ibrt_ui_log:app_ibrt_update_section_rsp_handler addr:0x%08x length:%d " + "no:%d\n", + p_ibrt_ota_update_rsp->address, p_ibrt_ota_update_rsp->length, + p_ibrt_ota_update_rsp->number); + if (p_ibrt_ota_update_rsp->number == + FLASH_SECTOR_SIZE_IN_BYTES / APP_TWS_CTRL_BUFFER_LEN - 1) { + TRACE(1, "CRC32 of the update is 0x%08x", p_ibrt_ota_update_rsp->crc); + // if(p_ibrt_ota_update_rsp->crc == ota_crc) + clr_error_list(p_ibrt_ota_update_rsp->point); + app_ibrt_view_update_list(); + } + app_ibrt_ota_force_update(); } #endif #endif diff --git a/services/app_ibrt/src/app_ibrt_peripheral_manager.cpp b/services/app_ibrt/src/app_ibrt_peripheral_manager.cpp index 6070a09..397d6c0 100644 --- a/services/app_ibrt/src/app_ibrt_peripheral_manager.cpp +++ b/services/app_ibrt/src/app_ibrt_peripheral_manager.cpp @@ -1,114 +1,112 @@ /*************************************************************************** -* -* Copyright 2015-2019 BES. -* All rights reserved. All unpublished rights reserved. -* -* No part of this work may be used or reproduced in any form or by any -* means, or stored in a database or retrieval system, without prior written -* permission of BES. -* -* Use of this work is governed by a license granted by BES. -* This work contains confidential and proprietary information of -* BES. which is protected by copyright, trade secret, -* trademark and other intellectual property rights. -* -****************************************************************************/ -#include -#include "cmsis_os.h" -#include "app_tws_ibrt_trace.h" -#include "bluetooth.h" -#include "crc16.h" -#include "heap_api.h" -#include "hci_api.h" -#include "me_api.h" -#include "app_tws_ibrt.h" -#include "app_tws_besaud.h" -#include "app_vendor_cmd_evt.h" -#include "tws_role_switch.h" -#include "l2cap_api.h" -#include "rfcomm_api.h" -#include "conmgr_api.h" -#include "bt_if.h" + * + * Copyright 2015-2019 BES. + * All rights reserved. All unpublished rights reserved. + * + * No part of this work may be used or reproduced in any form or by any + * means, or stored in a database or retrieval system, without prior written + * permission of BES. + * + * Use of this work is governed by a license granted by BES. + * This work contains confidential and proprietary information of + * BES. which is protected by copyright, trade secret, + * trademark and other intellectual property rights. + * + ****************************************************************************/ +#include "app_ibrt_peripheral_manager.h" #include "app_ibrt_if.h" -#include "app_tws_ibrt_cmd_handler.h" +#include "app_ibrt_ui.h" +#include "app_tws_besaud.h" #include "app_tws_ibrt.h" +#include "app_tws_ibrt_cmd_handler.h" +#include "app_tws_ibrt_trace.h" +#include "app_vendor_cmd_evt.h" +#include "bluetooth.h" #include "bt_drv_interface.h" #include "bt_drv_reg_op.h" -#include "app_ibrt_peripheral_manager.h" -#include "app_ibrt_ui.h" +#include "bt_if.h" +#include "cmsis_os.h" +#include "conmgr_api.h" +#include "crc16.h" +#include "hci_api.h" +#include "heap_api.h" +#include "l2cap_api.h" +#include "me_api.h" +#include "rfcomm_api.h" +#include "tws_role_switch.h" +#include #if defined(IBRT) osThreadId app_ibrt_peripheral_tid; static void app_ibrt_peripheral_thread(void const *argument); -osThreadDef(app_ibrt_peripheral_thread, osPriorityHigh,1, 2048,"app_ibrt_peripheral_thread"); +osThreadDef(app_ibrt_peripheral_thread, osPriorityHigh, 1, 2048, + "app_ibrt_peripheral_thread"); #define TWS_PERIPHERAL_DEVICE_MAILBOX_MAX (10) -osMailQDef (app_ibrt_peripheral_mailbox, TWS_PERIPHERAL_DEVICE_MAILBOX_MAX, TWS_PD_MSG_BLOCK); +osMailQDef(app_ibrt_peripheral_mailbox, TWS_PERIPHERAL_DEVICE_MAILBOX_MAX, + TWS_PD_MSG_BLOCK); static osMailQId app_ibrt_peripheral_mailbox = NULL; static uint8_t app_ibrt_peripheral_mailbox_cnt = 0; -static int app_ibrt_peripheral_mailbox_init(void) -{ - app_ibrt_peripheral_mailbox = osMailCreate(osMailQ(app_ibrt_peripheral_mailbox), NULL); - if (app_ibrt_peripheral_mailbox == NULL) { - TRACE(0,"Failed to Create app_ibrt_peripheral_mailbox\n"); - return -1; - } - app_ibrt_peripheral_mailbox_cnt = 0; - return 0; -} - -int app_ibrt_peripheral_mailbox_put(TWS_PD_MSG_BLOCK* msg_src) -{ - if(!msg_src){ - TRACE(0,"msg_src is a null pointer in app_ibrt_peripheral_mailbox_put!"); - return -1; - } - - osStatus status; - TWS_PD_MSG_BLOCK *msg_p = NULL; - msg_p = (TWS_PD_MSG_BLOCK*)osMailAlloc(app_ibrt_peripheral_mailbox, 0); - ASSERT(msg_p, "osMailAlloc error"); - msg_p->msg_body.message_id = msg_src->msg_body.message_id; - msg_p->msg_body.message_ptr = msg_src->msg_body.message_ptr; - msg_p->msg_body.message_Param0 = msg_src->msg_body.message_Param0; - msg_p->msg_body.message_Param1 = msg_src->msg_body.message_Param1; - msg_p->msg_body.message_Param2 = msg_src->msg_body.message_Param2; - - status = osMailPut(app_ibrt_peripheral_mailbox, msg_p); - if (osOK == status) - app_ibrt_peripheral_mailbox_cnt++; - return (int)status; -} - -int app_ibrt_peripheral_mailbox_free(TWS_PD_MSG_BLOCK* msg_p) -{ - if(!msg_p){ - TRACE(0,"msg_p is a null pointer in app_ibrt_peripheral_mailbox_free!"); - return -1; - } - osStatus status; - - status = osMailFree(app_ibrt_peripheral_mailbox, msg_p); - if (osOK == status) - app_ibrt_peripheral_mailbox_cnt--; - - return (int)status; -} - -int app_ibrt_peripheral_mailbox_get(TWS_PD_MSG_BLOCK** msg_p) -{ - if(!msg_p){ - TRACE(0,"msg_p is a null pointer in app_ibrt_peripheral_mailbox_get!"); - return -1; - } - - osEvent evt; - evt = osMailGet(app_ibrt_peripheral_mailbox, osWaitForever); - if (evt.status == osEventMail) { - *msg_p = (TWS_PD_MSG_BLOCK *)evt.value.p; - return 0; - } +static int app_ibrt_peripheral_mailbox_init(void) { + app_ibrt_peripheral_mailbox = + osMailCreate(osMailQ(app_ibrt_peripheral_mailbox), NULL); + if (app_ibrt_peripheral_mailbox == NULL) { + TRACE(0, "Failed to Create app_ibrt_peripheral_mailbox\n"); return -1; + } + app_ibrt_peripheral_mailbox_cnt = 0; + return 0; +} + +int app_ibrt_peripheral_mailbox_put(TWS_PD_MSG_BLOCK *msg_src) { + if (!msg_src) { + TRACE(0, "msg_src is a null pointer in app_ibrt_peripheral_mailbox_put!"); + return -1; + } + + osStatus status; + TWS_PD_MSG_BLOCK *msg_p = NULL; + msg_p = (TWS_PD_MSG_BLOCK *)osMailAlloc(app_ibrt_peripheral_mailbox, 0); + ASSERT(msg_p, "osMailAlloc error"); + msg_p->msg_body.message_id = msg_src->msg_body.message_id; + msg_p->msg_body.message_ptr = msg_src->msg_body.message_ptr; + msg_p->msg_body.message_Param0 = msg_src->msg_body.message_Param0; + msg_p->msg_body.message_Param1 = msg_src->msg_body.message_Param1; + msg_p->msg_body.message_Param2 = msg_src->msg_body.message_Param2; + + status = osMailPut(app_ibrt_peripheral_mailbox, msg_p); + if (osOK == status) + app_ibrt_peripheral_mailbox_cnt++; + return (int)status; +} + +int app_ibrt_peripheral_mailbox_free(TWS_PD_MSG_BLOCK *msg_p) { + if (!msg_p) { + TRACE(0, "msg_p is a null pointer in app_ibrt_peripheral_mailbox_free!"); + return -1; + } + osStatus status; + + status = osMailFree(app_ibrt_peripheral_mailbox, msg_p); + if (osOK == status) + app_ibrt_peripheral_mailbox_cnt--; + + return (int)status; +} + +int app_ibrt_peripheral_mailbox_get(TWS_PD_MSG_BLOCK **msg_p) { + if (!msg_p) { + TRACE(0, "msg_p is a null pointer in app_ibrt_peripheral_mailbox_get!"); + return -1; + } + + osEvent evt; + evt = osMailGet(app_ibrt_peripheral_mailbox, osWaitForever); + if (evt.status == osEventMail) { + *msg_p = (TWS_PD_MSG_BLOCK *)evt.value.p; + return 0; + } + return -1; } #ifdef BES_AUTOMATE_TEST @@ -116,45 +114,40 @@ int app_ibrt_peripheral_mailbox_get(TWS_PD_MSG_BLOCK** msg_p) static heap_handle_t app_ibrt_peripheral_heap; uint8_t app_ibrt_peripheral_buf[APP_IBRT_PERIPHERAL_BUF_SIZE]; bool app_ibrt_auto_test_started = false; -void app_ibrt_peripheral_heap_init(void) -{ - app_ibrt_auto_test_started = true; - app_ibrt_peripheral_heap = heap_register(app_ibrt_peripheral_buf, APP_IBRT_PERIPHERAL_BUF_SIZE); +void app_ibrt_peripheral_heap_init(void) { + app_ibrt_auto_test_started = true; + app_ibrt_peripheral_heap = + heap_register(app_ibrt_peripheral_buf, APP_IBRT_PERIPHERAL_BUF_SIZE); } -void *app_ibrt_peripheral_heap_malloc(uint32_t size) -{ - void *ptr = heap_malloc(app_ibrt_peripheral_heap,size); - ASSERT(ptr, "%s size:%d", __func__, size); - return ptr; +void *app_ibrt_peripheral_heap_malloc(uint32_t size) { + void *ptr = heap_malloc(app_ibrt_peripheral_heap, size); + ASSERT(ptr, "%s size:%d", __func__, size); + return ptr; } -void *app_ibrt_peripheral_heap_cmalloc(uint32_t size) -{ - void *ptr = heap_malloc(app_ibrt_peripheral_heap,size); - ASSERT(ptr, "%s size:%d", __func__, size); - memset(ptr, 0, size); - return ptr; +void *app_ibrt_peripheral_heap_cmalloc(uint32_t size) { + void *ptr = heap_malloc(app_ibrt_peripheral_heap, size); + ASSERT(ptr, "%s size:%d", __func__, size); + memset(ptr, 0, size); + return ptr; } -void *app_ibrt_peripheral_heap_realloc(void *rmem, uint32_t newsize) -{ - void *ptr = heap_realloc(app_ibrt_peripheral_heap, rmem, newsize); - ASSERT(ptr, "%s rmem:%p size:%d", __func__, rmem,newsize); - return ptr; +void *app_ibrt_peripheral_heap_realloc(void *rmem, uint32_t newsize) { + void *ptr = heap_realloc(app_ibrt_peripheral_heap, rmem, newsize); + ASSERT(ptr, "%s rmem:%p size:%d", __func__, rmem, newsize); + return ptr; } -void app_ibrt_peripheral_heap_free(void *rmem) -{ - ASSERT(rmem, "%s rmem:%p", __func__, rmem); - heap_free(app_ibrt_peripheral_heap, rmem); +void app_ibrt_peripheral_heap_free(void *rmem) { + ASSERT(rmem, "%s rmem:%p", __func__, rmem); + heap_free(app_ibrt_peripheral_heap, rmem); } #endif -void app_ibrt_peripheral_auto_test_stop(void) -{ +void app_ibrt_peripheral_auto_test_stop(void) { #ifdef BES_AUTOMATE_TEST - app_ibrt_auto_test_started = false; + app_ibrt_auto_test_started = false; #endif } @@ -176,160 +169,163 @@ void app_ibrt_peripheral_auto_test_stop(void) typedef void (*app_ibrt_peripheral_cb0)(void); typedef void (*app_ibrt_peripheral_cb1)(void *); typedef void (*app_ibrt_peripheral_cb2)(void *, void *); -void app_ibrt_peripheral_automate_test_handler(uint8_t *cmd_buf, uint32_t cmd_len); +void app_ibrt_peripheral_automate_test_handler(uint8_t *cmd_buf, + uint32_t cmd_len); -void app_ibrt_peripheral_thread(void const *argument) -{ - while(1){ - TWS_PD_MSG_BLOCK *msg_p = NULL; - if ((!app_ibrt_peripheral_mailbox_get(&msg_p))&&(!argument)) { - switch(msg_p->msg_body.message_id){ - case 0: - if(msg_p->msg_body.message_ptr){ - ((app_ibrt_peripheral_cb0)(msg_p->msg_body.message_ptr))(); - } - break; - case 1: - if(msg_p->msg_body.message_ptr){ - ((app_ibrt_peripheral_cb1)(msg_p->msg_body.message_ptr))((void *)msg_p->msg_body.message_Param0); - } - break; - case 2: - if(msg_p->msg_body.message_ptr){ - ((app_ibrt_peripheral_cb2)(msg_p->msg_body.message_ptr))((void *)msg_p->msg_body.message_Param0, - (void *)msg_p->msg_body.message_Param1); - } - break; - case 0xfe: - app_ibrt_peripheral_automate_test_handler((uint8_t*)msg_p->msg_body.message_Param0, - (uint32_t)msg_p->msg_body.message_Param1); - break; - case 0xff: {// ibrt test - char ibrt_cmd[20] = {0}; - memcpy(ibrt_cmd+0, &msg_p->msg_body.message_Param0, 4); - memcpy(ibrt_cmd+4, &msg_p->msg_body.message_Param1, 4); - memcpy(ibrt_cmd+8, &msg_p->msg_body.message_Param2, 4); - TRACE(1,"ibrt_ui_log: %s\n", ibrt_cmd); - app_ibrt_ui_test_cmd_handler((unsigned char*)ibrt_cmd, strlen(ibrt_cmd)+1); - } - break; - default: - break; - } - app_ibrt_peripheral_mailbox_free(msg_p); +void app_ibrt_peripheral_thread(void const *argument) { + while (1) { + TWS_PD_MSG_BLOCK *msg_p = NULL; + if ((!app_ibrt_peripheral_mailbox_get(&msg_p)) && (!argument)) { + switch (msg_p->msg_body.message_id) { + case 0: + if (msg_p->msg_body.message_ptr) { + ((app_ibrt_peripheral_cb0)(msg_p->msg_body.message_ptr))(); } + break; + case 1: + if (msg_p->msg_body.message_ptr) { + ((app_ibrt_peripheral_cb1)(msg_p->msg_body.message_ptr))( + (void *)msg_p->msg_body.message_Param0); + } + break; + case 2: + if (msg_p->msg_body.message_ptr) { + ((app_ibrt_peripheral_cb2)(msg_p->msg_body.message_ptr))( + (void *)msg_p->msg_body.message_Param0, + (void *)msg_p->msg_body.message_Param1); + } + break; + case 0xfe: + app_ibrt_peripheral_automate_test_handler( + (uint8_t *)msg_p->msg_body.message_Param0, + (uint32_t)msg_p->msg_body.message_Param1); + break; + case 0xff: { // ibrt test + char ibrt_cmd[20] = {0}; + memcpy(ibrt_cmd + 0, &msg_p->msg_body.message_Param0, 4); + memcpy(ibrt_cmd + 4, &msg_p->msg_body.message_Param1, 4); + memcpy(ibrt_cmd + 8, &msg_p->msg_body.message_Param2, 4); + TRACE(1, "ibrt_ui_log: %s\n", ibrt_cmd); + app_ibrt_ui_test_cmd_handler((unsigned char *)ibrt_cmd, + strlen(ibrt_cmd) + 1); + } break; + default: + break; + } + app_ibrt_peripheral_mailbox_free(msg_p); } + } } -void app_ibrt_peripheral_automate_test_handler(uint8_t* cmd_buf, uint32_t cmd_len) -{ +void app_ibrt_peripheral_automate_test_handler(uint8_t *cmd_buf, + uint32_t cmd_len) { #ifdef BES_AUTOMATE_TEST - AUTO_TEST_CMD_T *test_cmd = (AUTO_TEST_CMD_T *)cmd_buf; - static uint8_t last_group_code = 0xFF; - static uint8_t last_operation_code = 0xFF; + AUTO_TEST_CMD_T *test_cmd = (AUTO_TEST_CMD_T *)cmd_buf; + static uint8_t last_group_code = 0xFF; + static uint8_t last_operation_code = 0xFF; - //TRACE(4, "%s group 0x%x op 0x%x times %d len %d", __func__, - //test_cmd->group_code, test_cmd->opera_code, test_cmd->test_times, test_cmd->param_len); - //TRACE(2, "last group 0x%x last op 0x%x", last_group_code, last_operation_code); - if (last_group_code != test_cmd->group_code || last_operation_code != test_cmd->opera_code) - { - for (uint8_t i=0; itest_times; i++) - { - last_group_code = test_cmd->group_code; - last_operation_code = test_cmd->opera_code; - app_ibrt_ui_automate_test_cmd_handler(test_cmd->group_code, test_cmd->opera_code, test_cmd->param, test_cmd->param_len); - } + // TRACE(4, "%s group 0x%x op 0x%x times %d len %d", __func__, + // test_cmd->group_code, test_cmd->opera_code, test_cmd->test_times, + // test_cmd->param_len); + // TRACE(2, "last group 0x%x last op 0x%x", last_group_code, + // last_operation_code); + if (last_group_code != test_cmd->group_code || + last_operation_code != test_cmd->opera_code) { + for (uint8_t i = 0; i < test_cmd->test_times; i++) { + last_group_code = test_cmd->group_code; + last_operation_code = test_cmd->opera_code; + app_ibrt_ui_automate_test_cmd_handler( + test_cmd->group_code, test_cmd->opera_code, test_cmd->param, + test_cmd->param_len); } - app_ibrt_peripheral_heap_free(cmd_buf); + } + app_ibrt_peripheral_heap_free(cmd_buf); #endif } -extern "C" void app_ibrt_peripheral_automate_test(const char* ibrt_cmd, uint32_t cmd_len) -{ +extern "C" void app_ibrt_peripheral_automate_test(const char *ibrt_cmd, + uint32_t cmd_len) { #ifdef BES_AUTOMATE_TEST - uint16_t crc16_rec = 0; - uint16_t crc16_result = 0; - uint8_t *cmd_buf = NULL; - uint32_t _cmd_data_len = 0; - uint32_t _cmd_data_min_len = sizeof(AUTO_TEST_CMD_T)+AUTOMATE_TEST_CMD_CRC_RECORD_LEN; - TWS_PD_MSG_BLOCK msg; + uint16_t crc16_rec = 0; + uint16_t crc16_result = 0; + uint8_t *cmd_buf = NULL; + uint32_t _cmd_data_len = 0; + uint32_t _cmd_data_min_len = + sizeof(AUTO_TEST_CMD_T) + AUTOMATE_TEST_CMD_CRC_RECORD_LEN; + TWS_PD_MSG_BLOCK msg; - if (ibrt_cmd && cmd_len>=_cmd_data_min_len && cmd_len<=(_cmd_data_min_len+AUTOMATE_TEST_CMD_PARAM_MAX_LEN)) - { - _cmd_data_len = cmd_len-AUTOMATE_TEST_CMD_CRC_RECORD_LEN; - crc16_rec = *(uint16_t *)(&ibrt_cmd[_cmd_data_len]); - crc16_result = _crc16(crc16_result, (const unsigned char *)ibrt_cmd, _cmd_data_len); - //DUMP8("0x%x ", ibrt_cmd, cmd_len); - //TRACE(4, "%s crc16 rec 0x%x result 0x%x buf_len %d", __func__, crc16_rec, crc16_result, cmd_len); - if (crc16_rec == crc16_result && app_ibrt_auto_test_started) - { - app_ibrt_auto_test_inform_cmd_received(ibrt_cmd[0], ibrt_cmd[1]); - cmd_buf = (uint8_t *)app_ibrt_peripheral_heap_cmalloc(_cmd_data_len); - memcpy(cmd_buf, ibrt_cmd, _cmd_data_len); - msg.msg_body.message_id = 0xfe; - msg.msg_body.message_Param0 = (uint32_t)cmd_buf; - msg.msg_body.message_Param1 = _cmd_data_len; - app_ibrt_peripheral_mailbox_put(&msg); - } - return; + if (ibrt_cmd && cmd_len >= _cmd_data_min_len && + cmd_len <= (_cmd_data_min_len + AUTOMATE_TEST_CMD_PARAM_MAX_LEN)) { + _cmd_data_len = cmd_len - AUTOMATE_TEST_CMD_CRC_RECORD_LEN; + crc16_rec = *(uint16_t *)(&ibrt_cmd[_cmd_data_len]); + crc16_result = + _crc16(crc16_result, (const unsigned char *)ibrt_cmd, _cmd_data_len); + // DUMP8("0x%x ", ibrt_cmd, cmd_len); + // TRACE(4, "%s crc16 rec 0x%x result 0x%x buf_len %d", __func__, crc16_rec, + // crc16_result, cmd_len); + if (crc16_rec == crc16_result && app_ibrt_auto_test_started) { + app_ibrt_auto_test_inform_cmd_received(ibrt_cmd[0], ibrt_cmd[1]); + cmd_buf = (uint8_t *)app_ibrt_peripheral_heap_cmalloc(_cmd_data_len); + memcpy(cmd_buf, ibrt_cmd, _cmd_data_len); + msg.msg_body.message_id = 0xfe; + msg.msg_body.message_Param0 = (uint32_t)cmd_buf; + msg.msg_body.message_Param1 = _cmd_data_len; + app_ibrt_peripheral_mailbox_put(&msg); } - - //ASSERT(0, "%s ibrt_cmd %p cmd_len %d", __func__, ibrt_cmd, cmd_len); -#endif -} - -extern "C" void app_ibrt_peripheral_perform_test(const char* ibrt_cmd) -{ - TWS_PD_MSG_BLOCK msg; - msg.msg_body.message_id = 0xff; - memcpy(&msg.msg_body.message_Param0, ibrt_cmd+0, 4); - memcpy(&msg.msg_body.message_Param1, ibrt_cmd+4, 4); - memcpy(&msg.msg_body.message_Param2, ibrt_cmd+8, 4); - app_ibrt_peripheral_mailbox_put(&msg); -} - -void app_ibrt_peripheral_run0(uint32_t ptr) -{ - TWS_PD_MSG_BLOCK msg; - msg.msg_body.message_id = 0; - msg.msg_body.message_ptr = ptr; - app_ibrt_peripheral_mailbox_put(&msg); -} - -void app_ibrt_peripheral_run1(uint32_t ptr, uint32_t param0) -{ - TWS_PD_MSG_BLOCK msg; - msg.msg_body.message_id = 1; - msg.msg_body.message_ptr = ptr; - msg.msg_body.message_Param0 = param0; - app_ibrt_peripheral_mailbox_put(&msg); -} - -void app_ibrt_peripheral_run2(uint32_t ptr, uint32_t param0, uint32_t param1) -{ - TWS_PD_MSG_BLOCK msg; - msg.msg_body.message_id = 2; - msg.msg_body.message_ptr = ptr; - msg.msg_body.message_Param0 = param0; - msg.msg_body.message_Param1 = param1; - app_ibrt_peripheral_mailbox_put(&msg); -} - -void app_ibrt_peripheral_thread_init(void) -{ - if (app_ibrt_peripheral_mailbox_init()) - return; - - app_ibrt_peripheral_tid = osThreadCreate(osThread(app_ibrt_peripheral_thread), NULL); - if (app_ibrt_peripheral_tid == NULL) { - TRACE(0,"Failed to Create app_ibrt_peripheral_thread\n"); - return; - } - -#ifdef BES_AUTOMATE_TEST - app_ibrt_peripheral_heap_init(); -#endif return; + } + + // ASSERT(0, "%s ibrt_cmd %p cmd_len %d", __func__, ibrt_cmd, cmd_len); +#endif +} + +extern "C" void app_ibrt_peripheral_perform_test(const char *ibrt_cmd) { + TWS_PD_MSG_BLOCK msg; + msg.msg_body.message_id = 0xff; + memcpy(&msg.msg_body.message_Param0, ibrt_cmd + 0, 4); + memcpy(&msg.msg_body.message_Param1, ibrt_cmd + 4, 4); + memcpy(&msg.msg_body.message_Param2, ibrt_cmd + 8, 4); + app_ibrt_peripheral_mailbox_put(&msg); +} + +void app_ibrt_peripheral_run0(uint32_t ptr) { + TWS_PD_MSG_BLOCK msg; + msg.msg_body.message_id = 0; + msg.msg_body.message_ptr = ptr; + app_ibrt_peripheral_mailbox_put(&msg); +} + +void app_ibrt_peripheral_run1(uint32_t ptr, uint32_t param0) { + TWS_PD_MSG_BLOCK msg; + msg.msg_body.message_id = 1; + msg.msg_body.message_ptr = ptr; + msg.msg_body.message_Param0 = param0; + app_ibrt_peripheral_mailbox_put(&msg); +} + +void app_ibrt_peripheral_run2(uint32_t ptr, uint32_t param0, uint32_t param1) { + TWS_PD_MSG_BLOCK msg; + msg.msg_body.message_id = 2; + msg.msg_body.message_ptr = ptr; + msg.msg_body.message_Param0 = param0; + msg.msg_body.message_Param1 = param1; + app_ibrt_peripheral_mailbox_put(&msg); +} + +void app_ibrt_peripheral_thread_init(void) { + if (app_ibrt_peripheral_mailbox_init()) + return; + + app_ibrt_peripheral_tid = + osThreadCreate(osThread(app_ibrt_peripheral_thread), NULL); + if (app_ibrt_peripheral_tid == NULL) { + TRACE(0, "Failed to Create app_ibrt_peripheral_thread\n"); + return; + } + +#ifdef BES_AUTOMATE_TEST + app_ibrt_peripheral_heap_init(); +#endif + return; } #endif - diff --git a/services/app_ibrt/src/app_ibrt_rssi.cpp b/services/app_ibrt/src/app_ibrt_rssi.cpp index c71f36f..8c30de9 100644 --- a/services/app_ibrt/src/app_ibrt_rssi.cpp +++ b/services/app_ibrt/src/app_ibrt_rssi.cpp @@ -15,26 +15,27 @@ ****************************************************************************/ //#include "mbed.h" #if defined(IBRT) -#include #include +#include -#include "hal_trace.h" -#include "app_ibrt_if.h" -#include "app_tws_ctrl_thread.h" -#include "app_ibrt_rssi.h" #include "a2dp_decoder.h" +#include "app_ibrt_if.h" +#include "app_ibrt_rssi.h" +#include "app_tws_ctrl_thread.h" +#include "hal_trace.h" #define RSSI_WINDOW_SIZE 30 -static tota_stutter_t g_stutter = {0,}; +static tota_stutter_t g_stutter = { + 0, +}; extern float a2dp_audio_get_sample_reference(void); extern int8_t a2dp_audio_get_current_buf_size(void); -extern diff_us_t * app_tws_ibrt_audio_sync_get_diff_us(void); +extern diff_us_t *app_tws_ibrt_audio_sync_get_diff_us(void); -struct rssi_window_struct -{ - int8_t buf[RSSI_WINDOW_SIZE]; - uint8_t index; +struct rssi_window_struct { + int8_t buf[RSSI_WINDOW_SIZE]; + uint8_t index; }; extern osTimerId ibrt_ui_check_roleswitch_timer_id; @@ -42,66 +43,58 @@ static struct rssi_window_struct tws_rssi_window = {0}; static struct rssi_window_struct mobile_rssi_window = {0}; static bool need_roleswitch_with_rssi_bak = false; -static void rssi_window_push(struct rssi_window_struct *p, int8_t data) -{ - if(p == NULL) - { - return; +static void rssi_window_push(struct rssi_window_struct *p, int8_t data) { + if (p == NULL) { + return; + } + + if (p->index < RSSI_WINDOW_SIZE) { + for (uint8_t i = p->index; i > 0; i--) { + p->buf[i] = p->buf[i - 1]; } - - if(p->index < RSSI_WINDOW_SIZE) - { - for(uint8_t i=p->index; i>0; i--) - { - p->buf[i] = p->buf[i-1]; - } - p->buf[0] = data; - p->index++; - } - else - { - for(uint8_t i=p->index-1; i>0; i--) - { - p->buf[i] = p->buf[i-1]; - } - p->buf[0] = data; + p->buf[0] = data; + p->index++; + } else { + for (uint8_t i = p->index - 1; i > 0; i--) { + p->buf[i] = p->buf[i - 1]; } + p->buf[0] = data; + } } -void app_ibrt_ui_rssi_reset(void) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - memset(&tws_rssi_window,0,sizeof(rssi_window_struct)); - memset(&mobile_rssi_window,0,sizeof(rssi_window_struct)); - need_roleswitch_with_rssi_bak = false; - p_ibrt_ctrl->raw_rssi.agc_idx0 = 0; - p_ibrt_ctrl->raw_rssi.rssi0 = 0; - p_ibrt_ctrl->raw_rssi.rssi0_max = 0x7f; - p_ibrt_ctrl->raw_rssi.rssi0_min = 0x80; - p_ibrt_ctrl->raw_rssi.agc_idx1 = 0; - p_ibrt_ctrl->raw_rssi.rssi1 = 0; - p_ibrt_ctrl->raw_rssi.rssi1_max = 0x7f; - p_ibrt_ctrl->raw_rssi.rssi1_min = 0x80; - p_ibrt_ctrl->raw_rssi.rssi2 = 0; - p_ibrt_ctrl->raw_rssi.rssi2_max = 0x7f; - p_ibrt_ctrl->raw_rssi.rssi2_min = 0x80; - p_ibrt_ctrl->raw_rssi.ser = 0; - p_ibrt_ctrl->raw_rssi.rx_data_sum = 0; +void app_ibrt_ui_rssi_reset(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + memset(&tws_rssi_window, 0, sizeof(rssi_window_struct)); + memset(&mobile_rssi_window, 0, sizeof(rssi_window_struct)); + need_roleswitch_with_rssi_bak = false; + p_ibrt_ctrl->raw_rssi.agc_idx0 = 0; + p_ibrt_ctrl->raw_rssi.rssi0 = 0; + p_ibrt_ctrl->raw_rssi.rssi0_max = 0x7f; + p_ibrt_ctrl->raw_rssi.rssi0_min = 0x80; + p_ibrt_ctrl->raw_rssi.agc_idx1 = 0; + p_ibrt_ctrl->raw_rssi.rssi1 = 0; + p_ibrt_ctrl->raw_rssi.rssi1_max = 0x7f; + p_ibrt_ctrl->raw_rssi.rssi1_min = 0x80; + p_ibrt_ctrl->raw_rssi.rssi2 = 0; + p_ibrt_ctrl->raw_rssi.rssi2_max = 0x7f; + p_ibrt_ctrl->raw_rssi.rssi2_min = 0x80; + p_ibrt_ctrl->raw_rssi.ser = 0; + p_ibrt_ctrl->raw_rssi.rx_data_sum = 0; - p_ibrt_ctrl->peer_raw_rssi.agc_idx0 = 0; - p_ibrt_ctrl->peer_raw_rssi.rssi0 = 0; - p_ibrt_ctrl->peer_raw_rssi.rssi0_max = 0x7f; - p_ibrt_ctrl->peer_raw_rssi.rssi0_min = 0x80; - p_ibrt_ctrl->peer_raw_rssi.agc_idx1 = 0; - p_ibrt_ctrl->peer_raw_rssi.rssi1 = 0; - p_ibrt_ctrl->peer_raw_rssi.rssi1_max = 0x7f; - p_ibrt_ctrl->peer_raw_rssi.rssi1_min =0x80; - p_ibrt_ctrl->peer_raw_rssi.rssi2 = 0; - p_ibrt_ctrl->peer_raw_rssi.rssi2_max = 0x7f; - p_ibrt_ctrl->peer_raw_rssi.rssi2_min =0x80; - p_ibrt_ctrl->peer_raw_rssi.ser = 0; - p_ibrt_ctrl->peer_raw_rssi.rx_data_sum = 0; - p_ibrt_ctrl->role_switch_debonce_time = 0; + p_ibrt_ctrl->peer_raw_rssi.agc_idx0 = 0; + p_ibrt_ctrl->peer_raw_rssi.rssi0 = 0; + p_ibrt_ctrl->peer_raw_rssi.rssi0_max = 0x7f; + p_ibrt_ctrl->peer_raw_rssi.rssi0_min = 0x80; + p_ibrt_ctrl->peer_raw_rssi.agc_idx1 = 0; + p_ibrt_ctrl->peer_raw_rssi.rssi1 = 0; + p_ibrt_ctrl->peer_raw_rssi.rssi1_max = 0x7f; + p_ibrt_ctrl->peer_raw_rssi.rssi1_min = 0x80; + p_ibrt_ctrl->peer_raw_rssi.rssi2 = 0; + p_ibrt_ctrl->peer_raw_rssi.rssi2_max = 0x7f; + p_ibrt_ctrl->peer_raw_rssi.rssi2_min = 0x80; + p_ibrt_ctrl->peer_raw_rssi.ser = 0; + p_ibrt_ctrl->peer_raw_rssi.rx_data_sum = 0; + p_ibrt_ctrl->role_switch_debonce_time = 0; } /***************************************************************************** @@ -119,67 +112,70 @@ void app_ibrt_ui_rssi_reset(void) Modification : Created function *****************************************************************************/ -void app_ibrt_ui_rssi_process(void) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); +void app_ibrt_ui_rssi_process(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if(app_tws_ibrt_tws_link_connected()){ - rx_agc_t tws_agc = {0}; - bt_drv_reg_op_read_rssi_in_dbm(p_ibrt_ctrl->tws_conhandle,&tws_agc); - rssi_window_push(&tws_rssi_window, tws_agc.rssi); - if(tws_rssi_window.index >= RSSI_WINDOW_SIZE){ - int32_t tws_rssi_sum = 0; - for(uint8_t i=0; itws_conhandle, &tws_agc); + rssi_window_push(&tws_rssi_window, tws_agc.rssi); + if (tws_rssi_window.index >= RSSI_WINDOW_SIZE) { + int32_t tws_rssi_sum = 0; + for (uint8_t i = 0; i < RSSI_WINDOW_SIZE; i++) { + tws_rssi_sum += tws_rssi_window.buf[i]; + } - p_ibrt_ctrl->raw_rssi.rssi1 = tws_rssi_sum/RSSI_WINDOW_SIZE; - p_ibrt_ctrl->raw_rssi.agc_idx1 = tws_agc.rxgain; + p_ibrt_ctrl->raw_rssi.rssi1 = tws_rssi_sum / RSSI_WINDOW_SIZE; + p_ibrt_ctrl->raw_rssi.agc_idx1 = tws_agc.rxgain; - if(p_ibrt_ctrl->raw_rssi.rssi1 >= p_ibrt_ctrl->raw_rssi.rssi1_max) - p_ibrt_ctrl->raw_rssi.rssi1_max = p_ibrt_ctrl->raw_rssi.rssi1; - if(p_ibrt_ctrl->raw_rssi.rssi1 <= p_ibrt_ctrl->raw_rssi.rssi1_min) - p_ibrt_ctrl->raw_rssi.rssi1_min = p_ibrt_ctrl->raw_rssi.rssi1; - }else{ - p_ibrt_ctrl->raw_rssi.rssi1 = 0; - p_ibrt_ctrl->raw_rssi.rssi1_max = 0x80; - p_ibrt_ctrl->raw_rssi.rssi1_min = 0x7f; - p_ibrt_ctrl->raw_rssi.agc_idx1 = 0; - } + if (p_ibrt_ctrl->raw_rssi.rssi1 >= p_ibrt_ctrl->raw_rssi.rssi1_max) + p_ibrt_ctrl->raw_rssi.rssi1_max = p_ibrt_ctrl->raw_rssi.rssi1; + if (p_ibrt_ctrl->raw_rssi.rssi1 <= p_ibrt_ctrl->raw_rssi.rssi1_min) + p_ibrt_ctrl->raw_rssi.rssi1_min = p_ibrt_ctrl->raw_rssi.rssi1; + } else { + p_ibrt_ctrl->raw_rssi.rssi1 = 0; + p_ibrt_ctrl->raw_rssi.rssi1_max = 0x80; + p_ibrt_ctrl->raw_rssi.rssi1_min = 0x7f; + p_ibrt_ctrl->raw_rssi.agc_idx1 = 0; } + } - bool mobile_link_flag = app_tws_ibrt_mobile_link_connected(); - bool slave_ibrt_link_flag = app_tws_ibrt_slave_ibrt_link_connected(); + bool mobile_link_flag = app_tws_ibrt_mobile_link_connected(); + bool slave_ibrt_link_flag = app_tws_ibrt_slave_ibrt_link_connected(); - if(mobile_link_flag||slave_ibrt_link_flag){ - rx_agc_t mobile_agc= {0}; - if(mobile_link_flag){ - bt_drv_reg_op_read_rssi_in_dbm(p_ibrt_ctrl->mobile_conhandle,&mobile_agc); - }else if(slave_ibrt_link_flag){ - bt_drv_reg_op_read_rssi_in_dbm(p_ibrt_ctrl->ibrt_conhandle,&mobile_agc); - } - rssi_window_push(&mobile_rssi_window, mobile_agc.rssi); - if(mobile_rssi_window.index >= RSSI_WINDOW_SIZE){ - int32_t mobile_rssi_sum = 0; - for(uint8_t i=0; iraw_rssi.rssi0 = mobile_rssi_sum/RSSI_WINDOW_SIZE; - p_ibrt_ctrl->raw_rssi.agc_idx0 = mobile_agc.rxgain; - - if(p_ibrt_ctrl->raw_rssi.rssi0 >= p_ibrt_ctrl->raw_rssi.rssi0_max) - p_ibrt_ctrl->raw_rssi.rssi0_max = p_ibrt_ctrl->raw_rssi.rssi0; - if(p_ibrt_ctrl->raw_rssi.rssi0 <= p_ibrt_ctrl->raw_rssi.rssi0_min) - p_ibrt_ctrl->raw_rssi.rssi0_min = p_ibrt_ctrl->raw_rssi.rssi0; - }else{ - p_ibrt_ctrl->raw_rssi.rssi0 = 0; - p_ibrt_ctrl->raw_rssi.rssi0_max = 0x80; - p_ibrt_ctrl->raw_rssi.rssi0_min = 0x7f; - p_ibrt_ctrl->raw_rssi.agc_idx0 = 0; - } + if (mobile_link_flag || slave_ibrt_link_flag) { + rx_agc_t mobile_agc = {0}; + if (mobile_link_flag) { + bt_drv_reg_op_read_rssi_in_dbm(p_ibrt_ctrl->mobile_conhandle, + &mobile_agc); + } else if (slave_ibrt_link_flag) { + bt_drv_reg_op_read_rssi_in_dbm(p_ibrt_ctrl->ibrt_conhandle, &mobile_agc); } - //TRACE(5,"mobile -> %d:%d tws -> %d:%d SER:%d/100", p_ibrt_ctrl->raw_rssi.rssi0, p_ibrt_ctrl->raw_rssi.agc_idx0, p_ibrt_ctrl->raw_rssi.rssi1, p_ibrt_ctrl->raw_rssi.agc_idx1,p_ibrt_ctrl->raw_rssi.ser); + rssi_window_push(&mobile_rssi_window, mobile_agc.rssi); + if (mobile_rssi_window.index >= RSSI_WINDOW_SIZE) { + int32_t mobile_rssi_sum = 0; + for (uint8_t i = 0; i < RSSI_WINDOW_SIZE; i++) { + mobile_rssi_sum += mobile_rssi_window.buf[i]; + } + + p_ibrt_ctrl->raw_rssi.rssi0 = mobile_rssi_sum / RSSI_WINDOW_SIZE; + p_ibrt_ctrl->raw_rssi.agc_idx0 = mobile_agc.rxgain; + + if (p_ibrt_ctrl->raw_rssi.rssi0 >= p_ibrt_ctrl->raw_rssi.rssi0_max) + p_ibrt_ctrl->raw_rssi.rssi0_max = p_ibrt_ctrl->raw_rssi.rssi0; + if (p_ibrt_ctrl->raw_rssi.rssi0 <= p_ibrt_ctrl->raw_rssi.rssi0_min) + p_ibrt_ctrl->raw_rssi.rssi0_min = p_ibrt_ctrl->raw_rssi.rssi0; + } else { + p_ibrt_ctrl->raw_rssi.rssi0 = 0; + p_ibrt_ctrl->raw_rssi.rssi0_max = 0x80; + p_ibrt_ctrl->raw_rssi.rssi0_min = 0x7f; + p_ibrt_ctrl->raw_rssi.agc_idx0 = 0; + } + } + // TRACE(5,"mobile -> %d:%d tws -> %d:%d SER:%d/100", + // p_ibrt_ctrl->raw_rssi.rssi0, p_ibrt_ctrl->raw_rssi.agc_idx0, + // p_ibrt_ctrl->raw_rssi.rssi1, + // p_ibrt_ctrl->raw_rssi.agc_idx1,p_ibrt_ctrl->raw_rssi.ser); } /***************************************************************************** Prototype : app_ibrt_ui_tws_switch_according_rssi_needed @@ -196,25 +192,23 @@ void app_ibrt_ui_rssi_process(void) Modification : Created function *****************************************************************************/ -bool app_ibrt_ui_tws_switch_according_rssi_needed(void) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); +bool app_ibrt_ui_tws_switch_according_rssi_needed(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); - if ((p_ibrt_ctrl->raw_rssi.rssi0 != IBRT_UI_INVALID_RSSI)&& - (p_ibrt_ctrl->peer_raw_rssi.rssi0 != IBRT_UI_INVALID_RSSI)&& - (p_ibrt_ctrl->peer_raw_rssi.rssi0 >= IBRT_UI_MIN_RSSI) && - (p_ibrt_ctrl->raw_rssi.rssi0 >= IBRT_UI_MIN_RSSI)) - { - int8_t rssi_d_value_diff = p_ibrt_ctrl->peer_raw_rssi.rssi0 - p_ibrt_ctrl->raw_rssi.rssi0; - - if(rssi_d_value_diff >= p_ibrt_ui->config.rssi_threshold) - { - //local RSSI is stronger than peer and local role is SLAVE - return true; - } + if ((p_ibrt_ctrl->raw_rssi.rssi0 != IBRT_UI_INVALID_RSSI) && + (p_ibrt_ctrl->peer_raw_rssi.rssi0 != IBRT_UI_INVALID_RSSI) && + (p_ibrt_ctrl->peer_raw_rssi.rssi0 >= IBRT_UI_MIN_RSSI) && + (p_ibrt_ctrl->raw_rssi.rssi0 >= IBRT_UI_MIN_RSSI)) { + int8_t rssi_d_value_diff = + p_ibrt_ctrl->peer_raw_rssi.rssi0 - p_ibrt_ctrl->raw_rssi.rssi0; + + if (rssi_d_value_diff >= p_ibrt_ui->config.rssi_threshold) { + // local RSSI is stronger than peer and local role is SLAVE + return true; } - return false; + } + return false; } /***************************************************************************** @@ -232,21 +226,20 @@ bool app_ibrt_ui_tws_switch_according_rssi_needed(void) Modification : Created function *****************************************************************************/ -void app_ibrt_ui_check_roleswitch_timer_cb(void const *current_evt) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); +void app_ibrt_ui_check_roleswitch_timer_cb(void const *current_evt) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); - //app_ibrt_ui_rssi_process(); + // app_ibrt_ui_rssi_process(); - if (app_tws_ibrt_mobile_link_connected() && - app_ibrt_ui_is_profile_exchanged() && - (p_ibrt_ctrl->tws_mode == BTIF_BLM_ACTIVE_MODE)) - { - tws_ctrl_send_cmd(APP_TWS_CMD_GET_PEER_MOBILE_RSSI, NULL, 0); - } + if (app_tws_ibrt_mobile_link_connected() && + app_ibrt_ui_is_profile_exchanged() && + (p_ibrt_ctrl->tws_mode == BTIF_BLM_ACTIVE_MODE)) { + tws_ctrl_send_cmd(APP_TWS_CMD_GET_PEER_MOBILE_RSSI, NULL, 0); + } - osTimerStart(ibrt_ui_check_roleswitch_timer_id, p_ibrt_ui->config.rssi_monitor_timeout); + osTimerStart(ibrt_ui_check_roleswitch_timer_id, + p_ibrt_ui->config.rssi_monitor_timeout); } /***************************************************************************** @@ -265,9 +258,9 @@ void app_ibrt_ui_check_roleswitch_timer_cb(void const *current_evt) Modification : Created function *****************************************************************************/ -void app_ibrt_get_peer_mobile_rssi(uint8_t *p_buff, uint16_t length) -{ - app_ibrt_send_cmd_without_rsp(APP_TWS_CMD_GET_PEER_MOBILE_RSSI, p_buff, length); +void app_ibrt_get_peer_mobile_rssi(uint8_t *p_buff, uint16_t length) { + app_ibrt_send_cmd_without_rsp(APP_TWS_CMD_GET_PEER_MOBILE_RSSI, p_buff, + length); } /***************************************************************************** @@ -286,29 +279,27 @@ void app_ibrt_get_peer_mobile_rssi(uint8_t *p_buff, uint16_t length) Modification : Created function *****************************************************************************/ -void app_ibrt_get_peer_mobile_rssi_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - diff_us_t * p_diff_us = app_tws_ibrt_audio_sync_get_diff_us(); +void app_ibrt_get_peer_mobile_rssi_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + diff_us_t *p_diff_us = app_tws_ibrt_audio_sync_get_diff_us(); - if (app_tws_ibrt_slave_ibrt_link_connected() && - app_ibrt_ui_is_profile_exchanged() && - (p_ibrt_ctrl->tws_mode == BTIF_BLM_ACTIVE_MODE)) - { - app_ui_rssi_battery_info_t rssi_battery_buffer; - rssi_battery_buffer.battery_volt = p_ibrt_ctrl->local_battery_volt; - rssi_battery_buffer.raw_rssi = p_ibrt_ctrl->raw_rssi; - rssi_battery_buffer.mobile_conhandle = p_ibrt_ctrl->ibrt_conhandle; - rssi_battery_buffer.tws_conhandle = p_ibrt_ctrl->tws_conhandle; - rssi_battery_buffer.mobile_diff_us = p_diff_us->mobile_diff_us; - rssi_battery_buffer.tws_diff_us = p_diff_us->tws_diff_us; - rssi_battery_buffer.cur_buf_size = a2dp_audio_get_current_buf_size(); + if (app_tws_ibrt_slave_ibrt_link_connected() && + app_ibrt_ui_is_profile_exchanged() && + (p_ibrt_ctrl->tws_mode == BTIF_BLM_ACTIVE_MODE)) { + app_ui_rssi_battery_info_t rssi_battery_buffer; + rssi_battery_buffer.battery_volt = p_ibrt_ctrl->local_battery_volt; + rssi_battery_buffer.raw_rssi = p_ibrt_ctrl->raw_rssi; + rssi_battery_buffer.mobile_conhandle = p_ibrt_ctrl->ibrt_conhandle; + rssi_battery_buffer.tws_conhandle = p_ibrt_ctrl->tws_conhandle; + rssi_battery_buffer.mobile_diff_us = p_diff_us->mobile_diff_us; + rssi_battery_buffer.tws_diff_us = p_diff_us->tws_diff_us; + rssi_battery_buffer.cur_buf_size = a2dp_audio_get_current_buf_size(); - tws_ctrl_send_rsp(APP_TWS_CMD_GET_PEER_MOBILE_RSSI, \ - rsp_seq, \ - (uint8_t *)&rssi_battery_buffer, \ - sizeof(app_ui_rssi_battery_info_t)); - } + tws_ctrl_send_rsp(APP_TWS_CMD_GET_PEER_MOBILE_RSSI, rsp_seq, + (uint8_t *)&rssi_battery_buffer, + sizeof(app_ui_rssi_battery_info_t)); + } } /***************************************************************************** @@ -327,260 +318,233 @@ void app_ibrt_get_peer_mobile_rssi_handler(uint16_t rsp_seq, uint8_t *p_buff, ui Modification : Created function *****************************************************************************/ -static void app_ibrt_print_rssi_info(void) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - TRACE(0, "RSSI local mobile : local tws <> peer mobile : peer tws"); - TRACE(19,"RSSI %d %d %d %d : %d %d %d %d %d/100 <> %d %d %d %d : %d %d %d %d %d/100 %d", - p_ibrt_ctrl->raw_rssi.agc_idx0, - p_ibrt_ctrl->raw_rssi.rssi0, - p_ibrt_ctrl->raw_rssi.rssi0_max, - p_ibrt_ctrl->raw_rssi.rssi0_min, - p_ibrt_ctrl->raw_rssi.agc_idx1, - p_ibrt_ctrl->raw_rssi.rssi1, - p_ibrt_ctrl->raw_rssi.rssi1_max, - p_ibrt_ctrl->raw_rssi.rssi1_min, - p_ibrt_ctrl->raw_rssi.ser, - p_ibrt_ctrl->peer_raw_rssi.agc_idx0, - p_ibrt_ctrl->peer_raw_rssi.rssi0, - p_ibrt_ctrl->peer_raw_rssi.rssi0_max, - p_ibrt_ctrl->peer_raw_rssi.rssi0_min, - p_ibrt_ctrl->peer_raw_rssi.agc_idx1, - p_ibrt_ctrl->peer_raw_rssi.rssi1, - p_ibrt_ctrl->peer_raw_rssi.rssi1_max, - p_ibrt_ctrl->peer_raw_rssi.rssi1_min, - p_ibrt_ctrl->peer_raw_rssi.ser, - p_ibrt_ctrl->current_role); +static void app_ibrt_print_rssi_info(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + TRACE(0, "RSSI local mobile : local tws <> peer mobile : peer tws"); + TRACE(19, + "RSSI %d %d %d %d : %d %d %d %d %d/100 <> %d %d %d %d : %d %d %d %d " + "%d/100 %d", + p_ibrt_ctrl->raw_rssi.agc_idx0, p_ibrt_ctrl->raw_rssi.rssi0, + p_ibrt_ctrl->raw_rssi.rssi0_max, p_ibrt_ctrl->raw_rssi.rssi0_min, + p_ibrt_ctrl->raw_rssi.agc_idx1, p_ibrt_ctrl->raw_rssi.rssi1, + p_ibrt_ctrl->raw_rssi.rssi1_max, p_ibrt_ctrl->raw_rssi.rssi1_min, + p_ibrt_ctrl->raw_rssi.ser, p_ibrt_ctrl->peer_raw_rssi.agc_idx0, + p_ibrt_ctrl->peer_raw_rssi.rssi0, p_ibrt_ctrl->peer_raw_rssi.rssi0_max, + p_ibrt_ctrl->peer_raw_rssi.rssi0_min, + p_ibrt_ctrl->peer_raw_rssi.agc_idx1, p_ibrt_ctrl->peer_raw_rssi.rssi1, + p_ibrt_ctrl->peer_raw_rssi.rssi1_max, + p_ibrt_ctrl->peer_raw_rssi.rssi1_min, p_ibrt_ctrl->peer_raw_rssi.ser, + p_ibrt_ctrl->current_role); } -void app_ibrt_get_peer_mobile_rssi_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); +void app_ibrt_get_peer_mobile_rssi_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (app_tws_ibrt_mobile_link_connected() && - app_ibrt_ui_is_profile_exchanged() && - (p_ibrt_ctrl->tws_mode == BTIF_BLM_ACTIVE_MODE)) - { - if(p_ibrt_ctrl->role_switch_debonce_time == 0) - { - app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); - app_ui_rssi_battery_info_t rssi_battery_info = *(app_ui_rssi_battery_info_t *)p_buff; - p_ibrt_ctrl->peer_mobile_conhandle = rssi_battery_info.mobile_conhandle; - p_ibrt_ctrl->peer_tws_conhandle = rssi_battery_info.tws_conhandle; - p_ibrt_ctrl->peer_battery_volt = rssi_battery_info.battery_volt; - p_ibrt_ctrl->peer_raw_rssi = rssi_battery_info.raw_rssi; - p_ibrt_ctrl->mobile_diff_us = rssi_battery_info.mobile_diff_us; - p_ibrt_ctrl->tws_diff_us = rssi_battery_info.tws_diff_us; - p_ibrt_ctrl->cur_buf_size = rssi_battery_info.cur_buf_size; + if (app_tws_ibrt_mobile_link_connected() && + app_ibrt_ui_is_profile_exchanged() && + (p_ibrt_ctrl->tws_mode == BTIF_BLM_ACTIVE_MODE)) { + if (p_ibrt_ctrl->role_switch_debonce_time == 0) { + app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); + app_ui_rssi_battery_info_t rssi_battery_info = + *(app_ui_rssi_battery_info_t *)p_buff; + p_ibrt_ctrl->peer_mobile_conhandle = rssi_battery_info.mobile_conhandle; + p_ibrt_ctrl->peer_tws_conhandle = rssi_battery_info.tws_conhandle; + p_ibrt_ctrl->peer_battery_volt = rssi_battery_info.battery_volt; + p_ibrt_ctrl->peer_raw_rssi = rssi_battery_info.raw_rssi; + p_ibrt_ctrl->mobile_diff_us = rssi_battery_info.mobile_diff_us; + p_ibrt_ctrl->tws_diff_us = rssi_battery_info.tws_diff_us; + p_ibrt_ctrl->cur_buf_size = rssi_battery_info.cur_buf_size; - app_ibrt_print_rssi_info(); - - if(p_ibrt_ui->config.tws_switch_according_to_rssi_value) - { - bool need_roleswitch_with_rssi = app_ibrt_ui_tws_switch_according_rssi_needed(); + app_ibrt_print_rssi_info(); - if(need_roleswitch_with_rssi != need_roleswitch_with_rssi_bak){ - if(need_roleswitch_with_rssi){ - TRACE(2,"ibrt_ui_log:one headset far away cause tws switch used rssi %d %d",p_ibrt_ctrl->raw_rssi.rssi0,p_ibrt_ctrl->peer_raw_rssi.rssi0); - app_ibrt_ui_tws_switch(); - p_ibrt_ctrl->role_switch_debonce_time = p_ibrt_ui->config.role_switch_timer_threshold; - } - need_roleswitch_with_rssi_bak = need_roleswitch_with_rssi; - } - } - } - else - { - p_ibrt_ctrl->role_switch_debonce_time--; - } - } + if (p_ibrt_ui->config.tws_switch_according_to_rssi_value) { + bool need_roleswitch_with_rssi = + app_ibrt_ui_tws_switch_according_rssi_needed(); + + if (need_roleswitch_with_rssi != need_roleswitch_with_rssi_bak) { + if (need_roleswitch_with_rssi) { + TRACE(2, + "ibrt_ui_log:one headset far away cause tws switch used rssi " + "%d %d", + p_ibrt_ctrl->raw_rssi.rssi0, + p_ibrt_ctrl->peer_raw_rssi.rssi0); + app_ibrt_ui_tws_switch(); + p_ibrt_ctrl->role_switch_debonce_time = + p_ibrt_ui->config.role_switch_timer_threshold; + } + need_roleswitch_with_rssi_bak = need_roleswitch_with_rssi; + } + } + } else { + p_ibrt_ctrl->role_switch_debonce_time--; + } + } } -void app_ibrt_rssi_get_stutter(uint8_t * data,uint32_t * data_len) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - uint8_t temp; +void app_ibrt_rssi_get_stutter(uint8_t *data, uint32_t *data_len) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + uint8_t temp; - data[0] = p_ibrt_ctrl->raw_rssi.agc_idx0; - data[1] = p_ibrt_ctrl->raw_rssi.rssi0; - data[2] = p_ibrt_ctrl->raw_rssi.rssi0_max; - data[3] = p_ibrt_ctrl->raw_rssi.rssi0_min; + data[0] = p_ibrt_ctrl->raw_rssi.agc_idx0; + data[1] = p_ibrt_ctrl->raw_rssi.rssi0; + data[2] = p_ibrt_ctrl->raw_rssi.rssi0_max; + data[3] = p_ibrt_ctrl->raw_rssi.rssi0_min; - data[4] = p_ibrt_ctrl->raw_rssi.agc_idx1; - data[5] = p_ibrt_ctrl->raw_rssi.rssi1; - data[6] = p_ibrt_ctrl->raw_rssi.rssi1_max; - data[7] = p_ibrt_ctrl->raw_rssi.rssi1_min; - data[8] = p_ibrt_ctrl->raw_rssi.ser; + data[4] = p_ibrt_ctrl->raw_rssi.agc_idx1; + data[5] = p_ibrt_ctrl->raw_rssi.rssi1; + data[6] = p_ibrt_ctrl->raw_rssi.rssi1_max; + data[7] = p_ibrt_ctrl->raw_rssi.rssi1_min; + data[8] = p_ibrt_ctrl->raw_rssi.ser; - data[9] = p_ibrt_ctrl->peer_raw_rssi.agc_idx0; - data[10] = p_ibrt_ctrl->peer_raw_rssi.rssi0; - data[11] = p_ibrt_ctrl->peer_raw_rssi.rssi0_max; - data[12] = p_ibrt_ctrl->peer_raw_rssi.rssi0_min; + data[9] = p_ibrt_ctrl->peer_raw_rssi.agc_idx0; + data[10] = p_ibrt_ctrl->peer_raw_rssi.rssi0; + data[11] = p_ibrt_ctrl->peer_raw_rssi.rssi0_max; + data[12] = p_ibrt_ctrl->peer_raw_rssi.rssi0_min; - data[13] = p_ibrt_ctrl->peer_raw_rssi.agc_idx1; - data[14] = p_ibrt_ctrl->peer_raw_rssi.rssi1; - data[15] = p_ibrt_ctrl->peer_raw_rssi.rssi1_max; - data[16] = p_ibrt_ctrl->peer_raw_rssi.rssi1_min; - data[17] = p_ibrt_ctrl->peer_raw_rssi.ser; + data[13] = p_ibrt_ctrl->peer_raw_rssi.agc_idx1; + data[14] = p_ibrt_ctrl->peer_raw_rssi.rssi1; + data[15] = p_ibrt_ctrl->peer_raw_rssi.rssi1_max; + data[16] = p_ibrt_ctrl->peer_raw_rssi.rssi1_min; + data[17] = p_ibrt_ctrl->peer_raw_rssi.ser; - g_stutter.sample_ref = a2dp_audio_get_sample_reference(); - g_stutter.cur_buf_size_l = a2dp_audio_get_current_buf_size(); + g_stutter.sample_ref = a2dp_audio_get_sample_reference(); + g_stutter.cur_buf_size_l = a2dp_audio_get_current_buf_size(); - TRACE(2,"diff us: mobile:%d,tws:%d.", p_ibrt_ctrl->mobile_diff_us, p_ibrt_ctrl->tws_diff_us); + TRACE(2, "diff us: mobile:%d,tws:%d.", p_ibrt_ctrl->mobile_diff_us, + p_ibrt_ctrl->tws_diff_us); - TRACE(19,"%d %d %d %d : %d %d %d %d %d/100 <> %d %d %d %d : %d %d %d %d %d/100 %d", - p_ibrt_ctrl->raw_rssi.agc_idx0, - p_ibrt_ctrl->raw_rssi.rssi0, - p_ibrt_ctrl->raw_rssi.rssi0_max, - p_ibrt_ctrl->raw_rssi.rssi0_min, - p_ibrt_ctrl->raw_rssi.agc_idx1, - p_ibrt_ctrl->raw_rssi.rssi1, - p_ibrt_ctrl->raw_rssi.rssi1_max, - p_ibrt_ctrl->raw_rssi.rssi1_min, - p_ibrt_ctrl->raw_rssi.ser, - p_ibrt_ctrl->peer_raw_rssi.agc_idx0, - p_ibrt_ctrl->peer_raw_rssi.rssi0, - p_ibrt_ctrl->peer_raw_rssi.rssi0_max, - p_ibrt_ctrl->peer_raw_rssi.rssi0_min, - p_ibrt_ctrl->peer_raw_rssi.agc_idx1, - p_ibrt_ctrl->peer_raw_rssi.rssi1, - p_ibrt_ctrl->peer_raw_rssi.rssi1_max, - p_ibrt_ctrl->peer_raw_rssi.rssi1_min, - p_ibrt_ctrl->peer_raw_rssi.ser, - p_ibrt_ctrl->current_role); + TRACE( + 19, + "%d %d %d %d : %d %d %d %d %d/100 <> %d %d %d %d : %d %d %d %d %d/100 %d", + p_ibrt_ctrl->raw_rssi.agc_idx0, p_ibrt_ctrl->raw_rssi.rssi0, + p_ibrt_ctrl->raw_rssi.rssi0_max, p_ibrt_ctrl->raw_rssi.rssi0_min, + p_ibrt_ctrl->raw_rssi.agc_idx1, p_ibrt_ctrl->raw_rssi.rssi1, + p_ibrt_ctrl->raw_rssi.rssi1_max, p_ibrt_ctrl->raw_rssi.rssi1_min, + p_ibrt_ctrl->raw_rssi.ser, p_ibrt_ctrl->peer_raw_rssi.agc_idx0, + p_ibrt_ctrl->peer_raw_rssi.rssi0, p_ibrt_ctrl->peer_raw_rssi.rssi0_max, + p_ibrt_ctrl->peer_raw_rssi.rssi0_min, p_ibrt_ctrl->peer_raw_rssi.agc_idx1, + p_ibrt_ctrl->peer_raw_rssi.rssi1, p_ibrt_ctrl->peer_raw_rssi.rssi1_max, + p_ibrt_ctrl->peer_raw_rssi.rssi1_min, p_ibrt_ctrl->peer_raw_rssi.ser, + p_ibrt_ctrl->current_role); - if (p_ibrt_ctrl->current_role == IBRT_SLAVE) - { - for (int i = 0; i < 9; i++) - { - temp = data[i + 9]; - data[i + 9] = data[i]; - data[i] = temp; - } + if (p_ibrt_ctrl->current_role == IBRT_SLAVE) { + for (int i = 0; i < 9; i++) { + temp = data[i + 9]; + data[i + 9] = data[i]; + data[i] = temp; } - data[18] = p_ibrt_ctrl->current_role; + } + data[18] = p_ibrt_ctrl->current_role; - data[19] = bt_drv_reg_op_fa_gain_direct_get(); - data[20] = g_stutter.cur_buf_size_l; //L buffer size - data[21] = p_ibrt_ctrl->cur_buf_size; //R buffer size - //sample_reference - data[22] = *((int8_t *)&g_stutter.sample_ref); - data[23] = *((int8_t *)&g_stutter.sample_ref + 1); - data[24] = *((int8_t *)&g_stutter.sample_ref + 2); - data[25] = *((int8_t *)&g_stutter.sample_ref + 3); - //mobile diff / us - data[26] = *((int8_t *)&p_ibrt_ctrl->mobile_diff_us); - data[27] = *((int8_t *)&p_ibrt_ctrl->mobile_diff_us + 1); - data[28] = *((int8_t *)&p_ibrt_ctrl->mobile_diff_us + 2); - data[29] = *((int8_t *)&p_ibrt_ctrl->mobile_diff_us + 3); - //tws diff / us - data[30] = *((int8_t *)&p_ibrt_ctrl->tws_diff_us); - data[31] = *((int8_t *)&p_ibrt_ctrl->tws_diff_us + 1); - data[32] = *((int8_t *)&p_ibrt_ctrl->tws_diff_us + 2); - data[33] = *((int8_t *)&p_ibrt_ctrl->tws_diff_us + 3); + data[19] = bt_drv_reg_op_fa_gain_direct_get(); + data[20] = g_stutter.cur_buf_size_l; // L buffer size + data[21] = p_ibrt_ctrl->cur_buf_size; // R buffer size + // sample_reference + data[22] = *((int8_t *)&g_stutter.sample_ref); + data[23] = *((int8_t *)&g_stutter.sample_ref + 1); + data[24] = *((int8_t *)&g_stutter.sample_ref + 2); + data[25] = *((int8_t *)&g_stutter.sample_ref + 3); + // mobile diff / us + data[26] = *((int8_t *)&p_ibrt_ctrl->mobile_diff_us); + data[27] = *((int8_t *)&p_ibrt_ctrl->mobile_diff_us + 1); + data[28] = *((int8_t *)&p_ibrt_ctrl->mobile_diff_us + 2); + data[29] = *((int8_t *)&p_ibrt_ctrl->mobile_diff_us + 3); + // tws diff / us + data[30] = *((int8_t *)&p_ibrt_ctrl->tws_diff_us); + data[31] = *((int8_t *)&p_ibrt_ctrl->tws_diff_us + 1); + data[32] = *((int8_t *)&p_ibrt_ctrl->tws_diff_us + 2); + data[33] = *((int8_t *)&p_ibrt_ctrl->tws_diff_us + 3); - //L error_sum - data[34] = *((int8_t *)&p_ibrt_ctrl->raw_rssi.ser); - data[35] = *((int8_t *)&p_ibrt_ctrl->raw_rssi.ser+1); - //L Total_sum - data[36] = *((int8_t *)&p_ibrt_ctrl->raw_rssi.rx_data_sum); - data[37] = *((int8_t *)&p_ibrt_ctrl->raw_rssi.rx_data_sum+1); - //R error_sum - data[38] = *((int8_t *)&p_ibrt_ctrl->peer_raw_rssi.ser); - data[39] = *((int8_t *)&p_ibrt_ctrl->peer_raw_rssi.ser+1); - //R Total_sum - data[40] = *((int8_t *)&p_ibrt_ctrl->peer_raw_rssi.rx_data_sum); - data[41] = *((int8_t *)&p_ibrt_ctrl->peer_raw_rssi.rx_data_sum+1); + // L error_sum + data[34] = *((int8_t *)&p_ibrt_ctrl->raw_rssi.ser); + data[35] = *((int8_t *)&p_ibrt_ctrl->raw_rssi.ser + 1); + // L Total_sum + data[36] = *((int8_t *)&p_ibrt_ctrl->raw_rssi.rx_data_sum); + data[37] = *((int8_t *)&p_ibrt_ctrl->raw_rssi.rx_data_sum + 1); + // R error_sum + data[38] = *((int8_t *)&p_ibrt_ctrl->peer_raw_rssi.ser); + data[39] = *((int8_t *)&p_ibrt_ctrl->peer_raw_rssi.ser + 1); + // R Total_sum + data[40] = *((int8_t *)&p_ibrt_ctrl->peer_raw_rssi.rx_data_sum); + data[41] = *((int8_t *)&p_ibrt_ctrl->peer_raw_rssi.rx_data_sum + 1); - TRACE(1,"0x%08x", p_ibrt_ctrl->mobile_diff_us); - TRACE(1,"0x%08x", p_ibrt_ctrl->tws_diff_us); - TRACE(1,"0x%08x", p_ibrt_ctrl->raw_rssi.ser); - TRACE(1,"0x%08x", p_ibrt_ctrl->raw_rssi.rx_data_sum); - TRACE(1,"0x%08x", p_ibrt_ctrl->peer_raw_rssi.ser); - TRACE(1,"0x%08x", p_ibrt_ctrl->peer_raw_rssi.rx_data_sum); + TRACE(1, "0x%08x", p_ibrt_ctrl->mobile_diff_us); + TRACE(1, "0x%08x", p_ibrt_ctrl->tws_diff_us); + TRACE(1, "0x%08x", p_ibrt_ctrl->raw_rssi.ser); + TRACE(1, "0x%08x", p_ibrt_ctrl->raw_rssi.rx_data_sum); + TRACE(1, "0x%08x", p_ibrt_ctrl->peer_raw_rssi.ser); + TRACE(1, "0x%08x", p_ibrt_ctrl->peer_raw_rssi.rx_data_sum); - TRACE(23,"%d %d %d %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x", - data[19], - data[20], - data[21], - data[22], - data[23], - data[24], - data[25], - data[26], - data[27], - data[28], - data[29], - data[30], - data[31], - data[32], - data[33], - data[34], - data[35], - data[36], - data[37], - data[38], - data[39], - data[40], - data[41]); - *data_len = 42; + TRACE(23, + "%d %d %d %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x " + "%02x %02x %02x %02x %02x %02x %02x %02x", + data[19], data[20], data[21], data[22], data[23], data[24], data[25], + data[26], data[27], data[28], data[29], data[30], data[31], data[32], + data[33], data[34], data[35], data[36], data[37], data[38], data[39], + data[40], data[41]); + *data_len = 42; } -void app_ibrt_debug_parse(uint8_t *data, uint32_t data_len) -{ - bool do_it = false; - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - uint8_t *parse_p = data; +void app_ibrt_debug_parse(uint8_t *data, uint32_t data_len) { + bool do_it = false; + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + uint8_t *parse_p = data; - TRACE(2,"%s len:%d", __func__, data_len); - DUMP8("%02x ",data, data_len); + TRACE(2, "%s len:%d", __func__, data_len); + DUMP8("%02x ", data, data_len); - if (p_ibrt_ctrl->audio_chnl_sel == A2DP_AUDIO_CHANNEL_SELECT_LCHNL){ - if (*parse_p & 0x01){ - do_it = true; - } + if (p_ibrt_ctrl->audio_chnl_sel == A2DP_AUDIO_CHANNEL_SELECT_LCHNL) { + if (*parse_p & 0x01) { + do_it = true; } - if (p_ibrt_ctrl->audio_chnl_sel == A2DP_AUDIO_CHANNEL_SELECT_RCHNL){ - if (*parse_p & 0x02){ - do_it = true; - } + } + if (p_ibrt_ctrl->audio_chnl_sel == A2DP_AUDIO_CHANNEL_SELECT_RCHNL) { + if (*parse_p & 0x02) { + do_it = true; } + } + parse_p++; + if (do_it) { + uint8_t funcCode = *parse_p; parse_p++; - if (do_it){ - uint8_t funcCode = *parse_p; - parse_p++; - switch (funcCode) - { - case 1: - if (app_tws_ibrt_mobile_link_connected()){ - bt_drv_reg_op_dgb_link_gain_ctrl_set(p_ibrt_ctrl->mobile_conhandle, 0, *parse_p, *parse_p == 0xff ? 0 : 1); - }else if (app_tws_ibrt_slave_ibrt_link_connected()){ - bt_drv_reg_op_dgb_link_gain_ctrl_set(p_ibrt_ctrl->ibrt_conhandle, 0, *parse_p, *parse_p == 0xff ? 0 : 1); - } - break; - case 2: - bt_drv_reg_op_dgb_link_gain_ctrl_set(p_ibrt_ctrl->tws_conhandle, 0, *parse_p, *parse_p == 0xff ? 0 : 1); - break; - case 3: - bt_drv_reg_op_fa_gain_direct_set(*parse_p); - break; - case 4: - { - uint32_t data_format = 0; - data_format = be_to_host32(parse_p); - TRACE(1,"lowlayer_monitor len:%d", data_format); - if (app_tws_ibrt_mobile_link_connected()){ - btif_me_set_link_lowlayer_monitor(btif_me_get_remote_device_by_handle(p_ibrt_ctrl->mobile_conhandle), FLAG_START_DATA, REP_FORMAT_PACKET, data_format, 0); - }else if (app_tws_ibrt_slave_ibrt_link_connected()){ - btif_me_set_link_lowlayer_monitor(btif_me_get_remote_device_by_handle(p_ibrt_ctrl->ibrt_conhandle), FLAG_START_DATA, REP_FORMAT_PACKET, data_format, 0); - } - } - break; - default: - TRACE(1,"wrong cmd 0x%x",funcCode); - break; - } + switch (funcCode) { + case 1: + if (app_tws_ibrt_mobile_link_connected()) { + bt_drv_reg_op_dgb_link_gain_ctrl_set(p_ibrt_ctrl->mobile_conhandle, 0, + *parse_p, + *parse_p == 0xff ? 0 : 1); + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + bt_drv_reg_op_dgb_link_gain_ctrl_set( + p_ibrt_ctrl->ibrt_conhandle, 0, *parse_p, *parse_p == 0xff ? 0 : 1); + } + break; + case 2: + bt_drv_reg_op_dgb_link_gain_ctrl_set(p_ibrt_ctrl->tws_conhandle, 0, + *parse_p, *parse_p == 0xff ? 0 : 1); + break; + case 3: + bt_drv_reg_op_fa_gain_direct_set(*parse_p); + break; + case 4: { + uint32_t data_format = 0; + data_format = be_to_host32(parse_p); + TRACE(1, "lowlayer_monitor len:%d", data_format); + if (app_tws_ibrt_mobile_link_connected()) { + btif_me_set_link_lowlayer_monitor( + btif_me_get_remote_device_by_handle(p_ibrt_ctrl->mobile_conhandle), + FLAG_START_DATA, REP_FORMAT_PACKET, data_format, 0); + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + btif_me_set_link_lowlayer_monitor( + btif_me_get_remote_device_by_handle(p_ibrt_ctrl->ibrt_conhandle), + FLAG_START_DATA, REP_FORMAT_PACKET, data_format, 0); + } + } break; + default: + TRACE(1, "wrong cmd 0x%x", funcCode); + break; } + } } #endif - diff --git a/services/app_ibrt/src/app_ibrt_search_pair_ui.cpp b/services/app_ibrt/src/app_ibrt_search_pair_ui.cpp index 4fbbae6..136c6fa 100644 --- a/services/app_ibrt/src/app_ibrt_search_pair_ui.cpp +++ b/services/app_ibrt/src/app_ibrt_search_pair_ui.cpp @@ -13,57 +13,51 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "app_tws_ibrt_trace.h" -#include "app_tws_if.h" -#include "bluetooth.h" -#include "btapp.h" -#include "app_ibrt_ui.h" -#include "app_tws_ibrt_cmd_handler.h" -#include "app_tws_ctrl_thread.h" -#include "app_vendor_cmd_evt.h" -#include "cmsis_os.h" -#include "besbt.h" -#include "stdlib.h" -#include "app_bt.h" -#include "factory_section.h" -#include "app_ibrt_if.h" #include "a2dp_decoder.h" #include "app_battery.h" -#include "nvrecord.h" -#include "nvrecord_env.h" -#include "app_status_ind.h" +#include "app_bt.h" +#include "app_ibrt_if.h" #include "app_ibrt_peripheral_manager.h" +#include "app_ibrt_ui.h" +#include "app_status_ind.h" +#include "app_tws_ctrl_thread.h" +#include "app_tws_ibrt_cmd_handler.h" +#include "app_tws_ibrt_trace.h" +#include "app_tws_if.h" +#include "app_vendor_cmd_evt.h" +#include "besbt.h" +#include "bluetooth.h" +#include "btapp.h" +#include "cmsis_os.h" +#include "factory_section.h" +#include "nvrecord.h" #include "nvrecord_ble.h" +#include "nvrecord_env.h" +#include "stdlib.h" +#include - -extern "C" { - -} +extern "C" {} #ifdef IBRT_SEARCH_UI static void app_tws_inquiry_timeout_handler(void const *param); -osTimerDef (APP_TWS_INQ, app_tws_inquiry_timeout_handler); +osTimerDef(APP_TWS_INQ, app_tws_inquiry_timeout_handler); static osTimerId app_tws_timer = NULL; static void app_tws_delay_connect_handler(void const *param); -osTimerDef (APP_TWS_DELAY_CONNECT, app_tws_delay_connect_handler); +osTimerDef(APP_TWS_DELAY_CONNECT, app_tws_delay_connect_handler); static osTimerId app_tws_delay_connect_timer = NULL; - -static uint8_t tws_find_process=0; -static uint8_t tws_inquiry_count=0; -#define MAX_TWS_INQUIRY_TIMES 3 -#define IBRT_MAX_SEARCH_TIME 10 /* 12.8s */ +static uint8_t tws_find_process = 0; +static uint8_t tws_inquiry_count = 0; +#define MAX_TWS_INQUIRY_TIMES 3 +#define IBRT_MAX_SEARCH_TIME 10 /* 12.8s */ uint8_t tws_inq_addr_used; -typedef struct -{ - uint8_t used; - bt_bdaddr_t bdaddr; +typedef struct { + uint8_t used; + bt_bdaddr_t bdaddr; } TWS_INQ_ADDR_STRUCT; TWS_INQ_ADDR_STRUCT tws_inq_addr[5]; - #define IBRT_SEARCH_DEBUG #ifdef IBRT_SEARCH_DEBUG #define TWSCON_DBLOG TRACE @@ -71,84 +65,68 @@ TWS_INQ_ADDR_STRUCT tws_inq_addr[5]; #define TWSCON_DBLOG(...) #endif - -uint8_t box_event=IBRT_NONE_EVENT; +uint8_t box_event = IBRT_NONE_EVENT; static void app_box_handle_timehandler(void const *param); -osTimerDef (APP_BOX_HANDLE, app_box_handle_timehandler); +osTimerDef(APP_BOX_HANDLE, app_box_handle_timehandler); static osTimerId app_box_handle_timer = NULL; -static void app_box_handle_timehandler(void const *param) -{ - uint8_t *box_event_ptr=(uint8_t *)param; - uint8_t boxStatus=*box_event_ptr; - TRACE(1,"box event:%d",boxStatus); - app_ibrt_search_ui_init(true,boxStatus); - app_ibrt_if_event_entry(boxStatus); - if(IBRT_IN_BOX_CLOSED==boxStatus) - app_ibrt_search_ui_init(true,boxStatus); - +static void app_box_handle_timehandler(void const *param) { + uint8_t *box_event_ptr = (uint8_t *)param; + uint8_t boxStatus = *box_event_ptr; + TRACE(1, "box event:%d", boxStatus); + app_ibrt_search_ui_init(true, boxStatus); + app_ibrt_if_event_entry(boxStatus); + if (IBRT_IN_BOX_CLOSED == boxStatus) + app_ibrt_search_ui_init(true, boxStatus); } -static void app_tws_inquiry_timeout_handler(void const *param) -{ - - TWSCON_DBLOG(0,"app_tws_inquiry_timeout_handler\n"); - btif_me_inquiry(BTIF_BT_IAC_LIAC, IBRT_MAX_SEARCH_TIME, 0); +static void app_tws_inquiry_timeout_handler(void const *param) { + TWSCON_DBLOG(0, "app_tws_inquiry_timeout_handler\n"); + btif_me_inquiry(BTIF_BT_IAC_LIAC, IBRT_MAX_SEARCH_TIME, 0); } -static void app_tws_delay_connect_handler(void const *parma) -{ - TWSCON_DBLOG(1,"%s",__func__); - app_ibrt_if_enter_pairing_after_tws_connected(); - +static void app_tws_delay_connect_handler(void const *parma) { + TWSCON_DBLOG(1, "%s", __func__); + app_ibrt_if_enter_pairing_after_tws_connected(); } -bool app_tws_is_addr_in_tws_inq_array(const bt_bdaddr_t* addr) -{ - uint8_t i; - for(i=0; iaddress,BTIF_BD_ADDR_SIZE)) - return true; - } +bool app_tws_is_addr_in_tws_inq_array(const bt_bdaddr_t *addr) { + uint8_t i; + for (i = 0; i < sizeof(tws_inq_addr) / sizeof(tws_inq_addr[0]); i++) { + if (tws_inq_addr[i].used == 1) { + if (!memcmp(tws_inq_addr[i].bdaddr.address, addr->address, + BTIF_BD_ADDR_SIZE)) + return true; } - return false; + } + return false; } -void app_tws_clear_tws_inq_array(void) -{ - memset(&tws_inq_addr,0,sizeof(tws_inq_addr)); +void app_tws_clear_tws_inq_array(void) { + memset(&tws_inq_addr, 0, sizeof(tws_inq_addr)); } -int app_tws_fill_addr_to_array(const bt_bdaddr_t*addr) -{ - uint8_t i; - for(i=0; iaddress,BTIF_BD_ADDR_SIZE); - return 0; - } +int app_tws_fill_addr_to_array(const bt_bdaddr_t *addr) { + uint8_t i; + for (i = 0; i < sizeof(tws_inq_addr) / sizeof(tws_inq_addr[0]); i++) { + if (tws_inq_addr[i].used == 0) { + tws_inq_addr[i].used = 1; + memcpy(tws_inq_addr[i].bdaddr.address, addr->address, BTIF_BD_ADDR_SIZE); + return 0; } + } - return -1; + return -1; } -uint8_t app_tws_get_tws_addr_inq_num(void) -{ - uint8_t i,count=0; - for(i=0; inv_role ==IBRT_UNKNOW) - p_ibrt_ctrl->nv_role = ibrtRole; - if(NULL!=ibrtPeerAddr) - { - memcpy(p_ibrt_ctrl->peer_addr.address,ibrtPeerAddr->address, BD_ADDR_LEN); - nv_record_update_ibrt_info(p_ibrt_ctrl->nv_role,ibrtPeerAddr); +void app_tws_ibrt_update_info(ibrt_role_e ibrtRole, bt_bdaddr_t *ibrtPeerAddr) { + TRACE(1, "%s", __func__); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (p_ibrt_ctrl->nv_role == IBRT_UNKNOW) + p_ibrt_ctrl->nv_role = ibrtRole; + if (NULL != ibrtPeerAddr) { + memcpy(p_ibrt_ctrl->peer_addr.address, ibrtPeerAddr->address, BD_ADDR_LEN); + nv_record_update_ibrt_info(p_ibrt_ctrl->nv_role, ibrtPeerAddr); + } +} + +void tws_app_stop_find(void) { + tws_find_process = 0; + btif_me_unregister_globa_handler((btif_handler *)btif_me_get_bt_handler()); +} + +void app_bt_manager_ibrt_role_process(const btif_event_t *Event) { + switch (btif_me_get_callback_event_type(Event)) { + case BTIF_BTEVENT_LINK_CONNECT_IND: + case BTIF_BTEVENT_LINK_CONNECT_CNF: + if (BTIF_BEC_NO_ERROR == btif_me_get_callback_event_err_code(Event)) { + bt_bdaddr_t *p_remote_dev_addr = NULL; + ibrt_ctrl_t *p_ibrt_ctrl = NULL; + p_remote_dev_addr = btif_me_get_callback_event_rem_dev_bd_addr(Event); + p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (p_ibrt_ctrl->nv_role == IBRT_UNKNOW) + factory_section_original_btaddr_get(p_ibrt_ctrl->local_addr.address); + + TRACE(2, "local:%x remd:%x", p_ibrt_ctrl->local_addr.address[5], + p_remote_dev_addr->address[5]); + if ((p_ibrt_ctrl->local_addr.address[3] == + p_remote_dev_addr->address[3]) && + (p_ibrt_ctrl->local_addr.address[4] == + p_remote_dev_addr->address[4]) && + (p_ibrt_ctrl->local_addr.address[5] == + p_remote_dev_addr->address[5])) { + app_tws_ibrt_update_info(IBRT_SLAVE, p_remote_dev_addr); + if (app_ibrt_ui_get_tws_use_same_addr_enable()) { + memcpy(p_ibrt_ctrl->local_addr.address, p_remote_dev_addr->address, + 6); + } + if (app_tws_is_left_side()) { + p_ibrt_ctrl->audio_chnl_sel = A2DP_AUDIO_CHANNEL_SELECT_LCHNL; + } else { + p_ibrt_ctrl->audio_chnl_sel = A2DP_AUDIO_CHANNEL_SELECT_RCHNL; + } + + // #if 0 + // p_ibrt_ctrl->audio_chnl_sel = + // A2DP_AUDIO_CHANNEL_SELECT_LRMERGE; + // #else + // if(IBRT_MASTER == p_ibrt_ctrl->nv_role) + // { + // TRACE(0,"#right"); + // p_ibrt_ctrl->audio_chnl_sel = + // A2DP_AUDIO_CHANNEL_SELECT_RCHNL; + // } + // else if(IBRT_SLAVE == p_ibrt_ctrl->nv_role) + // { + // TRACE(0,"#left"); + // p_ibrt_ctrl->audio_chnl_sel = + // A2DP_AUDIO_CHANNEL_SELECT_LCHNL; + + // } + // #endif + } } + break; + default: + break; + } } -void tws_app_stop_find(void) -{ - tws_find_process=0; - btif_me_unregister_globa_handler((btif_handler *)btif_me_get_bt_handler()); -} +void app_ibrt_config_the_same_bd_addr(bt_bdaddr_t *ibrtSearchedAddr) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + app_tws_ibrt_set_access_mode(BTIF_BAM_NOT_ACCESSIBLE); -void app_bt_manager_ibrt_role_process(const btif_event_t *Event) -{ - switch (btif_me_get_callback_event_type(Event)) - { - case BTIF_BTEVENT_LINK_CONNECT_IND: - case BTIF_BTEVENT_LINK_CONNECT_CNF: - if (BTIF_BEC_NO_ERROR == btif_me_get_callback_event_err_code(Event)) - { - bt_bdaddr_t *p_remote_dev_addr=NULL; - ibrt_ctrl_t *p_ibrt_ctrl=NULL; - p_remote_dev_addr = btif_me_get_callback_event_rem_dev_bd_addr(Event); - p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if(p_ibrt_ctrl->nv_role ==IBRT_UNKNOW) - factory_section_original_btaddr_get(p_ibrt_ctrl->local_addr.address); - - TRACE(2,"local:%x remd:%x",p_ibrt_ctrl->local_addr.address[5],p_remote_dev_addr->address[5]); - if((p_ibrt_ctrl->local_addr.address[3]==p_remote_dev_addr->address[3]) - &&(p_ibrt_ctrl->local_addr.address[4]==p_remote_dev_addr->address[4]) - &&(p_ibrt_ctrl->local_addr.address[5]==p_remote_dev_addr->address[5])) - { - app_tws_ibrt_update_info(IBRT_SLAVE,p_remote_dev_addr); - if(app_ibrt_ui_get_tws_use_same_addr_enable()) - { - memcpy(p_ibrt_ctrl->local_addr.address,p_remote_dev_addr->address,6); - } - if (app_tws_is_left_side()){ - p_ibrt_ctrl->audio_chnl_sel = A2DP_AUDIO_CHANNEL_SELECT_LCHNL; - }else { - p_ibrt_ctrl->audio_chnl_sel = A2DP_AUDIO_CHANNEL_SELECT_RCHNL; - } - -// #if 0 -// p_ibrt_ctrl->audio_chnl_sel = A2DP_AUDIO_CHANNEL_SELECT_LRMERGE; -// #else -// if(IBRT_MASTER == p_ibrt_ctrl->nv_role) -// { -// TRACE(0,"#right"); -// p_ibrt_ctrl->audio_chnl_sel = A2DP_AUDIO_CHANNEL_SELECT_RCHNL; -// } -// else if(IBRT_SLAVE == p_ibrt_ctrl->nv_role) -// { -// TRACE(0,"#left"); -// p_ibrt_ctrl->audio_chnl_sel = A2DP_AUDIO_CHANNEL_SELECT_LCHNL; - -// } -// #endif - } - - } - break; - default: - break; - } - -} - -void app_ibrt_config_the_same_bd_addr(bt_bdaddr_t *ibrtSearchedAddr) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - app_tws_ibrt_set_access_mode(BTIF_BAM_NOT_ACCESSIBLE); - - memcpy(p_ibrt_ctrl->local_addr.address, ibrtSearchedAddr->address, BD_ADDR_LEN); - memcpy(p_ibrt_ctrl->peer_addr.address, ibrtSearchedAddr->address, BD_ADDR_LEN); - btif_me_set_bt_address(ibrtSearchedAddr->address); + memcpy(p_ibrt_ctrl->local_addr.address, ibrtSearchedAddr->address, + BD_ADDR_LEN); + memcpy(p_ibrt_ctrl->peer_addr.address, ibrtSearchedAddr->address, + BD_ADDR_LEN); + btif_me_set_bt_address(ibrtSearchedAddr->address); #ifdef __GMA_VOICE__ - btif_me_set_ble_bd_address(ibrtSearchedAddr->address); - bt_set_ble_local_address(ibrtSearchedAddr->address); - NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); - memcpy(pNvExtRec->tws_info.ble_info.ble_addr, ibrtSearchedAddr->address, BLE_IRK_SIZE); - nv_record_tws_exchange_ble_info(); + btif_me_set_ble_bd_address(ibrtSearchedAddr->address); + bt_set_ble_local_address(ibrtSearchedAddr->address); + NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); + memcpy(pNvExtRec->tws_info.ble_info.ble_addr, ibrtSearchedAddr->address, + BLE_IRK_SIZE); + nv_record_tws_exchange_ble_info(); #endif - TRACE(1,"%s", __func__); - DUMP8("%02x ", p_ibrt_ctrl->local_addr.address, BD_ADDR_LEN); + TRACE(1, "%s", __func__); + DUMP8("%02x ", p_ibrt_ctrl->local_addr.address, BD_ADDR_LEN); - //after change the bd_addr, we should reset access mode again - app_tws_ibrt_set_access_mode(BTIF_BAM_CONNECTABLE_ONLY); + // after change the bd_addr, we should reset access mode again + app_tws_ibrt_set_access_mode(BTIF_BAM_CONNECTABLE_ONLY); } -void app_ibrt_reconfig_btAddr_from_nv() -{ - struct nvrecord_env_t *nvrecord_env; - if(nv_record_env_get(&nvrecord_env)!=-1) - { - if(nvrecord_env->ibrt_mode.mode !=IBRT_UNKNOW) - { - TRACE(0,"reconfig addr from nv"); - DUMP8("%02x ",nvrecord_env->ibrt_mode.record.bdAddr.address, 6); - bt_set_local_address(nvrecord_env->ibrt_mode.record.bdAddr.address); - - bt_set_ble_local_address(nvrecord_env->ibrt_mode.record.bdAddr.address); - - } +void app_ibrt_reconfig_btAddr_from_nv() { + struct nvrecord_env_t *nvrecord_env; + if (nv_record_env_get(&nvrecord_env) != -1) { + if (nvrecord_env->ibrt_mode.mode != IBRT_UNKNOW) { + TRACE(0, "reconfig addr from nv"); + DUMP8("%02x ", nvrecord_env->ibrt_mode.record.bdAddr.address, 6); + bt_set_local_address(nvrecord_env->ibrt_mode.record.bdAddr.address); + bt_set_ble_local_address(nvrecord_env->ibrt_mode.record.bdAddr.address); } - + } } -void app_bt_inquiry_call_back(const btif_event_t* event) -{ - TWSCON_DBLOG(2,"\nenter: %s %d\n",__func__,__LINE__); - uint8_t device_name[64]; - uint8_t device_name_len; - app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - factory_section_original_btaddr_get(p_ibrt_ctrl->local_addr.address); +void app_bt_inquiry_call_back(const btif_event_t *event) { + TWSCON_DBLOG(2, "\nenter: %s %d\n", __func__, __LINE__); + uint8_t device_name[64]; + uint8_t device_name_len; + app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + factory_section_original_btaddr_get(p_ibrt_ctrl->local_addr.address); + switch (btif_me_get_callback_event_type(event)) { + case BTIF_BTEVENT_NAME_RESULT: + TWSCON_DBLOG(2, "\n%s %d BTEVENT_NAME_RESULT\n", __func__, __LINE__); + break; + case BTIF_BTEVENT_INQUIRY_RESULT: + TWSCON_DBLOG(2, "\n%s %d BTEVENT_INQUIRY_RESULT\n", __func__, __LINE__); + DUMP8("%02x ", btif_me_get_callback_event_inq_result_bd_addr_addr(event), + 6); + TWSCON_DBLOG(1, "inqmode = %x", + btif_me_get_callback_event_inq_result_inq_mode(event)); + DUMP8("%02x ", btif_me_get_callback_event_inq_result_ext_inq_resp(event), + 20); + /// check the uap and nap if equal ,get the name for tws slave + TRACE(1, "##RSSI:%d", (int8_t)btif_me_get_callback_event_rssi(event)); + TRACE( + 6, "local %02x %02x %02x %02x %02x %02x\n", + p_ibrt_ctrl->local_addr.address[0], p_ibrt_ctrl->local_addr.address[1], + p_ibrt_ctrl->local_addr.address[2], p_ibrt_ctrl->local_addr.address[3], + p_ibrt_ctrl->local_addr.address[4], p_ibrt_ctrl->local_addr.address[5]); + if ((btif_me_get_callback_event_inq_result_bd_addr(event)->address[5] == + p_ibrt_ctrl->local_addr.address[5]) && + (btif_me_get_callback_event_inq_result_bd_addr(event)->address[4] == + p_ibrt_ctrl->local_addr.address[4]) && + (btif_me_get_callback_event_inq_result_bd_addr(event)->address[3] == + p_ibrt_ctrl->local_addr.address[3])) { + /// check the device is already checked + TWSCON_DBLOG(0, "<1>"); + if (app_tws_is_addr_in_tws_inq_array( + btif_me_get_callback_event_inq_result_bd_addr(event))) { + break; + } + ////if rssi event is eir,so find name derictly + if (btif_me_get_callback_event_inq_result_inq_mode(event) == + BTIF_INQ_MODE_EXTENDED) { - switch(btif_me_get_callback_event_type(event)) - { - case BTIF_BTEVENT_NAME_RESULT: - TWSCON_DBLOG(2,"\n%s %d BTEVENT_NAME_RESULT\n",__func__,__LINE__); - break; - case BTIF_BTEVENT_INQUIRY_RESULT: - TWSCON_DBLOG(2,"\n%s %d BTEVENT_INQUIRY_RESULT\n",__func__,__LINE__); - DUMP8("%02x ", btif_me_get_callback_event_inq_result_bd_addr_addr(event), 6); - TWSCON_DBLOG(1,"inqmode = %x",btif_me_get_callback_event_inq_result_inq_mode(event)); - DUMP8("%02x ", btif_me_get_callback_event_inq_result_ext_inq_resp(event), 20); - ///check the uap and nap if equal ,get the name for tws slave - TRACE(1,"##RSSI:%d",(int8_t)btif_me_get_callback_event_rssi(event)); - TRACE(6,"local %02x %02x %02x %02x %02x %02x\n", - p_ibrt_ctrl->local_addr.address[0], - p_ibrt_ctrl->local_addr.address[1], - p_ibrt_ctrl->local_addr.address[2], - p_ibrt_ctrl->local_addr.address[3], - p_ibrt_ctrl->local_addr.address[4], - p_ibrt_ctrl->local_addr.address[5]); - if((btif_me_get_callback_event_inq_result_bd_addr(event)->address[5]== p_ibrt_ctrl->local_addr.address[5]) - && (btif_me_get_callback_event_inq_result_bd_addr(event)->address[4]== p_ibrt_ctrl->local_addr.address[4]) - && (btif_me_get_callback_event_inq_result_bd_addr(event)->address[3]== p_ibrt_ctrl->local_addr.address[3])) - { - ///check the device is already checked - TWSCON_DBLOG(0,"<1>"); - if(app_tws_is_addr_in_tws_inq_array(btif_me_get_callback_event_inq_result_bd_addr(event))) - { - break; - } - ////if rssi event is eir,so find name derictly - if(btif_me_get_callback_event_inq_result_inq_mode(event) == BTIF_INQ_MODE_EXTENDED) - { + TWSCON_DBLOG(0, "<2>"); + uint8_t *eir = + (uint8_t *)btif_me_get_callback_event_inq_result_ext_inq_resp( + event); + // device_name_len = + // ME_GetExtInqData(eir,0x09,device_name,sizeof(device_name)); + device_name_len = btif_me_get_ext_inq_data(eir, 0x09, device_name, + sizeof(device_name)); + if (device_name_len > 0) { + TWSCON_DBLOG(3, "<3> search name len %d %s local name %s\n", + device_name_len, device_name, bt_get_local_name()); + ////if name is the same as the local name so we think the device is + /// the tws slave + if (!memcmp(device_name, bt_get_local_name(), device_name_len)) { + TWSCON_DBLOG(0, "<4>"); - TWSCON_DBLOG(0,"<2>"); - uint8_t *eir = (uint8_t *)btif_me_get_callback_event_inq_result_ext_inq_resp(event); - //device_name_len = ME_GetExtInqData(eir,0x09,device_name,sizeof(device_name)); - device_name_len = btif_me_get_ext_inq_data(eir,0x09,device_name,sizeof(device_name)); - if(device_name_len>0) - { - TWSCON_DBLOG(3,"<3> search name len %d %s local name %s\n", device_name_len, device_name, bt_get_local_name()); - ////if name is the same as the local name so we think the device is the tws slave - if(!memcmp(device_name,bt_get_local_name(),device_name_len)) - { - TWSCON_DBLOG(0,"<4>"); - - //modify local addr - app_ibrt_config_the_same_bd_addr(btif_me_get_callback_event_inq_result_bd_addr(event)); - btif_me_cancel_inquiry(); - osTimerStop(app_tws_timer); - tws_app_stop_find(); - app_tws_ibrt_update_info(IBRT_MASTER,btif_me_get_callback_event_inq_result_bd_addr(event)); - p_ibrt_ctrl->audio_chnl_sel = A2DP_AUDIO_CHANNEL_SELECT_LRMERGE; - if(NULL !=app_tws_delay_connect_timer) - { - osTimerStop(app_tws_delay_connect_timer); - osTimerStart(app_tws_delay_connect_timer, 500); - } - - } - else - { - if(app_tws_get_tws_addr_inq_num()=MAX_TWS_INQUIRY_TIMES) - { - tws_app_stop_find(); - return; - } - if(p_ibrt_ui->super_state ==IBRT_UI_IDLE) - { - ////inquiry complete if bt don't find any slave ,so do inquiry again - - uint8_t rand_delay = rand() % 5; - tws_inquiry_count++; - - if(rand_delay == 0) - { - //btif_me_inquiry(BTIF_BT_IAC_GIAC, IBRT_MAX_SEARCH_TIME, 0); - btif_me_inquiry(BTIF_BT_IAC_LIAC, IBRT_MAX_SEARCH_TIME, 0); - } - else - { - osTimerStart(app_tws_timer, rand_delay*1000); - } - } - break; - /** The Inquiry process is canceled. */ - case BTIF_BTEVENT_INQUIRY_CANCELED: - TWSCON_DBLOG(2,"\n%s %d BTEVENT_INQUIRY_CANCELED\n",__FUNCTION__,__LINE__); - // tws.notify(&tws); - break; - case BTIF_BTEVENT_LINK_CONNECT_CNF: - TWSCON_DBLOG(3,"\n%s %d BTEVENT_LINK_CONNECT_CNF stats=%x\n",__FUNCTION__,__LINE__,btif_me_get_callback_event_err_code(event)); - - //connect fail start inquiry again - if(btif_me_get_callback_event_err_code(event) ==4 && tws_find_process == 1) - { - if(tws_inquiry_count>=MAX_TWS_INQUIRY_TIMES) - { - tws_app_stop_find(); - return; - } - uint8_t rand_delay = rand() % 5; - tws_inquiry_count++; - if(rand_delay == 0) - { - //btif_me_inquiry(BTIF_BT_IAC_GIAC, IBRT_MAX_SEARCH_TIME, 0); - btif_me_inquiry(BTIF_BT_IAC_LIAC, IBRT_MAX_SEARCH_TIME, 0); - } - else - { - osTimerStart(app_tws_timer, rand_delay*1000); - } - } - ///connect succ,so stop the finding tws procedure - else if(btif_me_get_callback_event_err_code(event) ==0) - { - tws_app_stop_find(); - } - break; - case BTIF_BTEVENT_LINK_CONNECT_IND: - TWSCON_DBLOG(3,"\n%s %d BTEVENT_LINK_CONNECT_IND stats=%x\n",__FUNCTION__,__LINE__,btif_me_get_callback_event_err_code(event)); - ////there is a incoming connect so cancel the inquiry and the timer and the connect creating + // modify local addr + app_ibrt_config_the_same_bd_addr( + btif_me_get_callback_event_inq_result_bd_addr(event)); btif_me_cancel_inquiry(); osTimerStop(app_tws_timer); - break; - default: - //TWS_DBLOG("\n%s %d etype:%d\n",__FUNCTION__,__LINE__,event->eType); - break; + tws_app_stop_find(); + app_tws_ibrt_update_info( + IBRT_MASTER, + btif_me_get_callback_event_inq_result_bd_addr(event)); + p_ibrt_ctrl->audio_chnl_sel = A2DP_AUDIO_CHANNEL_SELECT_LRMERGE; + if (NULL != app_tws_delay_connect_timer) { + osTimerStop(app_tws_delay_connect_timer); + osTimerStart(app_tws_delay_connect_timer, 500); + } - - } - - //TWS_DBLOG("\nexit: %s %d\n",__FUNCTION__,__LINE__); - -} - - - -uint8_t is_find_tws_peer_device_onprocess(void) -{ - return tws_find_process; -} - -void find_tws_peer_device_start(void) -{ - TWSCON_DBLOG(2,"\nibrt_ui_log: %s %d\n",__func__,__LINE__); - bt_status_t status; - app_tws_clear_tws_inq_array(); - if(tws_find_process ==0) - { - tws_find_process = 1; - tws_inquiry_count = 0; - if (app_tws_timer == NULL) - app_tws_timer = osTimerCreate(osTimer(APP_TWS_INQ), osTimerOnce, NULL); - btif_me_set_handler(btif_me_get_bt_handler(),app_bt_inquiry_call_back); - btif_me_register_global_handler(btif_me_get_bt_handler()); - - btif_me_set_event_mask(btif_me_get_bt_handler(), BTIF_BEM_LINK_DISCONNECT|BTIF_BEM_ROLE_CHANGE|BTIF_BEM_INQUIRY_RESULT| - BTIF_BEM_INQUIRY_COMPLETE|BTIF_BEM_INQUIRY_CANCELED|BTIF_BEM_LINK_CONNECT_CNF|BTIF_BEM_LINK_CONNECT_IND); - - again: - TWSCON_DBLOG(2,"\n%s %d\n",__func__,__LINE__); - - status = btif_me_inquiry(BTIF_BT_IAC_LIAC, IBRT_MAX_SEARCH_TIME, 0); - TWSCON_DBLOG(2,"\n%s %d\n",__func__,__LINE__); - if (status != BT_STS_PENDING) - { - osDelay(500); - goto again; + } else { + if (app_tws_get_tws_addr_inq_num() < + sizeof(tws_inq_addr) / sizeof(tws_inq_addr[0])) { + app_tws_fill_addr_to_array( + btif_me_get_callback_event_inq_result_bd_addr(event)); + if (app_tws_get_tws_addr_inq_num() == + sizeof(tws_inq_addr) / sizeof(tws_inq_addr[0])) { + /// fail to find a tws slave + btif_me_cancel_inquiry(); + tws_app_stop_find(); + } + } else { + /// fail to find a tws slave + btif_me_cancel_inquiry(); + tws_app_stop_find(); + } + } + break; } - TWSCON_DBLOG(2,"\n%s %d\n",__func__,__LINE__); + /////have no name so just wait for next device + //////we can do remote name req for tws slave if eir can't received + /// correctly + } } -} + break; + case BTIF_BTEVENT_INQUIRY_COMPLETE: + TWSCON_DBLOG(2, "\n%s %d BTEVENT_INQUIRY_COMPLETE\n", __FUNCTION__, + __LINE__); + if (tws_inquiry_count >= MAX_TWS_INQUIRY_TIMES) { + tws_app_stop_find(); + return; + } + if (p_ibrt_ui->super_state == IBRT_UI_IDLE) { + ////inquiry complete if bt don't find any slave ,so do inquiry again + uint8_t rand_delay = rand() % 5; + tws_inquiry_count++; -void find_tws_peer_device_stop(void) -{ + if (rand_delay == 0) { + // btif_me_inquiry(BTIF_BT_IAC_GIAC, IBRT_MAX_SEARCH_TIME, 0); + btif_me_inquiry(BTIF_BT_IAC_LIAC, IBRT_MAX_SEARCH_TIME, 0); + } else { + osTimerStart(app_tws_timer, rand_delay * 1000); + } + } + break; + /** The Inquiry process is canceled. */ + case BTIF_BTEVENT_INQUIRY_CANCELED: + TWSCON_DBLOG(2, "\n%s %d BTEVENT_INQUIRY_CANCELED\n", __FUNCTION__, + __LINE__); + // tws.notify(&tws); + break; + case BTIF_BTEVENT_LINK_CONNECT_CNF: + TWSCON_DBLOG(3, "\n%s %d BTEVENT_LINK_CONNECT_CNF stats=%x\n", __FUNCTION__, + __LINE__, btif_me_get_callback_event_err_code(event)); + + // connect fail start inquiry again + if (btif_me_get_callback_event_err_code(event) == 4 && + tws_find_process == 1) { + if (tws_inquiry_count >= MAX_TWS_INQUIRY_TIMES) { + tws_app_stop_find(); + return; + } + uint8_t rand_delay = rand() % 5; + tws_inquiry_count++; + if (rand_delay == 0) { + // btif_me_inquiry(BTIF_BT_IAC_GIAC, IBRT_MAX_SEARCH_TIME, 0); + btif_me_inquiry(BTIF_BT_IAC_LIAC, IBRT_MAX_SEARCH_TIME, 0); + } else { + osTimerStart(app_tws_timer, rand_delay * 1000); + } + } + /// connect succ,so stop the finding tws procedure + else if (btif_me_get_callback_event_err_code(event) == 0) { + tws_app_stop_find(); + } + break; + case BTIF_BTEVENT_LINK_CONNECT_IND: + TWSCON_DBLOG(3, "\n%s %d BTEVENT_LINK_CONNECT_IND stats=%x\n", __FUNCTION__, + __LINE__, btif_me_get_callback_event_err_code(event)); + ////there is a incoming connect so cancel the inquiry and the timer and the + /// connect creating btif_me_cancel_inquiry(); - tws_app_stop_find(); + osTimerStop(app_tws_timer); + break; + default: + // TWS_DBLOG("\n%s %d etype:%d\n",__FUNCTION__,__LINE__,event->eType); + break; + } + + // TWS_DBLOG("\nexit: %s %d\n",__FUNCTION__,__LINE__); } -void app_start_tws_serching_direactly() -{ - btif_accessible_mode_t mode; - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); +uint8_t is_find_tws_peer_device_onprocess(void) { return tws_find_process; } - mode = p_ibrt_ctrl->access_mode; - TWSCON_DBLOG(1,"ibrt_ui_log:search tws direactly access_mode:%d",mode); - //if ((BTIF_DEFAULT_ACCESS_MODE_PAIR==mode)||(BTIF_BAM_LIMITED_ACCESSIBLE==mode)) - if(BTIF_BAM_LIMITED_ACCESSIBLE==mode) - { - if(NULL==app_tws_delay_connect_timer) - app_tws_delay_connect_timer=osTimerCreate(osTimer(APP_TWS_DELAY_CONNECT),osTimerOnce,NULL ); - if (is_find_tws_peer_device_onprocess()) - { - find_tws_peer_device_stop(); - } - else - { - p_ibrt_ctrl->nv_role=IBRT_UNKNOW; - find_tws_peer_device_start(); +void find_tws_peer_device_start(void) { + TWSCON_DBLOG(2, "\nibrt_ui_log: %s %d\n", __func__, __LINE__); + bt_status_t status; + app_tws_clear_tws_inq_array(); + if (tws_find_process == 0) { + tws_find_process = 1; + tws_inquiry_count = 0; + if (app_tws_timer == NULL) + app_tws_timer = osTimerCreate(osTimer(APP_TWS_INQ), osTimerOnce, NULL); + btif_me_set_handler(btif_me_get_bt_handler(), app_bt_inquiry_call_back); + btif_me_register_global_handler(btif_me_get_bt_handler()); - //app_status_indication_set(APP_STATUS_INDICATION_CONNECTING); - } + btif_me_set_event_mask( + btif_me_get_bt_handler(), + BTIF_BEM_LINK_DISCONNECT | BTIF_BEM_ROLE_CHANGE | + BTIF_BEM_INQUIRY_RESULT | BTIF_BEM_INQUIRY_COMPLETE | + BTIF_BEM_INQUIRY_CANCELED | BTIF_BEM_LINK_CONNECT_CNF | + BTIF_BEM_LINK_CONNECT_IND); + + again: + TWSCON_DBLOG(2, "\n%s %d\n", __func__, __LINE__); + + status = btif_me_inquiry(BTIF_BT_IAC_LIAC, IBRT_MAX_SEARCH_TIME, 0); + TWSCON_DBLOG(2, "\n%s %d\n", __func__, __LINE__); + if (status != BT_STS_PENDING) { + osDelay(500); + goto again; } + TWSCON_DBLOG(2, "\n%s %d\n", __func__, __LINE__); + } } - -static void app_ibrt_battery_handle_process_normal(uint32_t status, union APP_BATTERY_MSG_PRAMS prams) -{ - app_ibrt_ui_t *p_ui_ctrl = app_ibrt_ui_get_ctx(); - - - switch (status) - { - case APP_BATTERY_STATUS_CHARGING: - - TWSCON_DBLOG(1,"charger:%d",prams.charger); - if (prams.charger == APP_BATTERY_CHARGER_PLUGIN) - { - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - TWSCON_DBLOG(1,"APP_BATTERY_CHARGER_PLUGIN nv_role %02x", p_ibrt_ctrl->nv_role); - /*if (p_ibrt_ctrl->nv_role == IBRT_UNKNOW) - { - return; - }*/ - if(p_ui_ctrl->config.check_plugin_excute_closedbox_event==true) - box_event=IBRT_CLOSE_BOX_EVENT; - else - box_event=IBRT_PUT_IN_EVENT; - - if(app_box_handle_timer!=NULL) - { - osTimerStop(app_box_handle_timer); - osTimerStart(app_box_handle_timer,500); - } - - } - else if (prams.charger == APP_BATTERY_CHARGER_PLUGOUT) - { - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - TWSCON_DBLOG(1,"APP_BATTERY_CHARGER_PLUGOUT nv_role %02x", p_ibrt_ctrl->nv_role); - if (p_ibrt_ctrl->nv_role == IBRT_UNKNOW) - { - return; - } - box_event=IBRT_FETCH_OUT_EVENT; - - if(app_box_handle_timer!=NULL) - { - osTimerStop(app_box_handle_timer); - osTimerStart(app_box_handle_timer,500); - } - } - break; - case APP_BATTERY_STATUS_INVALID: - default: - break; - - } - - +void find_tws_peer_device_stop(void) { + btif_me_cancel_inquiry(); + tws_app_stop_find(); } +void app_start_tws_serching_direactly() { + btif_accessible_mode_t mode; + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); -void app_ibrt_battery_callback(APP_BATTERY_MV_T currvolt, uint8_t currlevel,enum APP_BATTERY_STATUS_T curstatus,uint32_t status, union APP_BATTERY_MSG_PRAMS prams) -{ - switch (curstatus) - { - case APP_BATTERY_STATUS_NORMAL: - case APP_BATTERY_STATUS_CHARGING: - app_ibrt_battery_handle_process_normal(status,prams); - break; + mode = p_ibrt_ctrl->access_mode; + TWSCON_DBLOG(1, "ibrt_ui_log:search tws direactly access_mode:%d", mode); + // if + // ((BTIF_DEFAULT_ACCESS_MODE_PAIR==mode)||(BTIF_BAM_LIMITED_ACCESSIBLE==mode)) + if (BTIF_BAM_LIMITED_ACCESSIBLE == mode) { + if (NULL == app_tws_delay_connect_timer) + app_tws_delay_connect_timer = + osTimerCreate(osTimer(APP_TWS_DELAY_CONNECT), osTimerOnce, NULL); + if (is_find_tws_peer_device_onprocess()) { + find_tws_peer_device_stop(); + } else { + p_ibrt_ctrl->nv_role = IBRT_UNKNOW; + find_tws_peer_device_start(); - default: - break; + // app_status_indication_set(APP_STATUS_INDICATION_CONNECTING); } + } +} +static void +app_ibrt_battery_handle_process_normal(uint32_t status, + union APP_BATTERY_MSG_PRAMS prams) { + app_ibrt_ui_t *p_ui_ctrl = app_ibrt_ui_get_ctx(); + switch (status) { + case APP_BATTERY_STATUS_CHARGING: + + TWSCON_DBLOG(1, "charger:%d", prams.charger); + if (prams.charger == APP_BATTERY_CHARGER_PLUGIN) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + TWSCON_DBLOG(1, "APP_BATTERY_CHARGER_PLUGIN nv_role %02x", + p_ibrt_ctrl->nv_role); + /*if (p_ibrt_ctrl->nv_role == IBRT_UNKNOW) + { + return; + }*/ + if (p_ui_ctrl->config.check_plugin_excute_closedbox_event == true) + box_event = IBRT_CLOSE_BOX_EVENT; + else + box_event = IBRT_PUT_IN_EVENT; + + if (app_box_handle_timer != NULL) { + osTimerStop(app_box_handle_timer); + osTimerStart(app_box_handle_timer, 500); + } + + } else if (prams.charger == APP_BATTERY_CHARGER_PLUGOUT) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + TWSCON_DBLOG(1, "APP_BATTERY_CHARGER_PLUGOUT nv_role %02x", + p_ibrt_ctrl->nv_role); + if (p_ibrt_ctrl->nv_role == IBRT_UNKNOW) { + return; + } + box_event = IBRT_FETCH_OUT_EVENT; + + if (app_box_handle_timer != NULL) { + osTimerStop(app_box_handle_timer); + osTimerStart(app_box_handle_timer, 500); + } + } + break; + case APP_BATTERY_STATUS_INVALID: + default: + break; + } +} + +void app_ibrt_battery_callback(APP_BATTERY_MV_T currvolt, uint8_t currlevel, + enum APP_BATTERY_STATUS_T curstatus, + uint32_t status, + union APP_BATTERY_MSG_PRAMS prams) { + switch (curstatus) { + case APP_BATTERY_STATUS_NORMAL: + case APP_BATTERY_STATUS_CHARGING: + app_ibrt_battery_handle_process_normal(status, prams); + break; + + default: + break; + } } #ifdef BOX_DET_USE_GPIO @@ -605,172 +552,146 @@ void app_ibrt_battery_callback(APP_BATTERY_MV_T currvolt, uint8_t currlevel,enum static void box_det_pin_irq_set(enum HAL_GPIO_IRQ_POLARITY_T polarity); -static void box_det_pin_irq_update(void) -{ - if (hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)BOX_DET_PIN)) - box_det_pin_irq_set(HAL_GPIO_IRQ_POLARITY_LOW_FALLING); - else - box_det_pin_irq_set(HAL_GPIO_IRQ_POLARITY_HIGH_RISING); +static void box_det_pin_irq_update(void) { + if (hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)BOX_DET_PIN)) + box_det_pin_irq_set(HAL_GPIO_IRQ_POLARITY_LOW_FALLING); + else + box_det_pin_irq_set(HAL_GPIO_IRQ_POLARITY_HIGH_RISING); } -static void box_det_handler(uint32_t val) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - TRACE(2,"%s: %d", __func__, p_ibrt_ctrl->nv_role); - box_det_pin_irq_update(); - if (val) - { - box_event = IBRT_FETCH_OUT_EVENT; - } - else - { - box_event=IBRT_CLOSE_BOX_EVENT; - } +static void box_det_handler(uint32_t val) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + TRACE(2, "%s: %d", __func__, p_ibrt_ctrl->nv_role); + box_det_pin_irq_update(); + if (val) { + box_event = IBRT_FETCH_OUT_EVENT; + } else { + box_event = IBRT_CLOSE_BOX_EVENT; + } - if (p_ibrt_ctrl->nv_role == IBRT_UNKNOW) - return; + if (p_ibrt_ctrl->nv_role == IBRT_UNKNOW) + return; - if (app_box_handle_timer) - { - osTimerStop(app_box_handle_timer); - osTimerStart(app_box_handle_timer,500); - } + if (app_box_handle_timer) { + osTimerStop(app_box_handle_timer); + osTimerStart(app_box_handle_timer, 500); + } } -static void box_det_irq_handler(enum HAL_GPIO_PIN_T pin) -{ - uint8_t val = hal_gpio_pin_get_val(pin); - TRACE(3,"%s: %d, %d", __func__, pin, val); - app_ibrt_peripheral_run1((uint32_t)box_det_handler, (uint32_t)val); +static void box_det_irq_handler(enum HAL_GPIO_PIN_T pin) { + uint8_t val = hal_gpio_pin_get_val(pin); + TRACE(3, "%s: %d, %d", __func__, pin, val); + app_ibrt_peripheral_run1((uint32_t)box_det_handler, (uint32_t)val); } -static void box_det_pin_irq_set(enum HAL_GPIO_IRQ_POLARITY_T polarity) -{ - struct HAL_GPIO_IRQ_CFG_T box_det_pin_cfg; - box_det_pin_cfg.irq_debounce = true; - box_det_pin_cfg.irq_handler = box_det_irq_handler; - box_det_pin_cfg.irq_type = HAL_GPIO_IRQ_TYPE_EDGE_SENSITIVE; +static void box_det_pin_irq_set(enum HAL_GPIO_IRQ_POLARITY_T polarity) { + struct HAL_GPIO_IRQ_CFG_T box_det_pin_cfg; + box_det_pin_cfg.irq_debounce = true; + box_det_pin_cfg.irq_handler = box_det_irq_handler; + box_det_pin_cfg.irq_type = HAL_GPIO_IRQ_TYPE_EDGE_SENSITIVE; - box_det_pin_cfg.irq_enable = true; - box_det_pin_cfg.irq_polarity = polarity; - hal_gpio_setup_irq((enum HAL_GPIO_PIN_T)BOX_DET_PIN, &box_det_pin_cfg); + box_det_pin_cfg.irq_enable = true; + box_det_pin_cfg.irq_polarity = polarity; + hal_gpio_setup_irq((enum HAL_GPIO_PIN_T)BOX_DET_PIN, &box_det_pin_cfg); } -static void box_det_pin_init(void) -{ - const struct HAL_IOMUX_PIN_FUNCTION_MAP box_det_gpio_cfg = - { - BOX_DET_PIN, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE - }; +static void box_det_pin_init(void) { + const struct HAL_IOMUX_PIN_FUNCTION_MAP box_det_gpio_cfg = { + BOX_DET_PIN, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; - hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)&box_det_gpio_cfg, 1); - hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)box_det_gpio_cfg.pin, HAL_GPIO_DIR_IN, 1); + hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)&box_det_gpio_cfg, 1); + hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)box_det_gpio_cfg.pin, + HAL_GPIO_DIR_IN, 1); - box_det_pin_irq_update(); + box_det_pin_irq_update(); } #endif -void app_ibrt_search_ui_init(bool boxOperation,ibrt_event_type evt_type) -{ - app_ibrt_ui_t *p_ui_ctrl = app_ibrt_ui_get_ctx(); - if((true==p_ui_ctrl->config.check_plugin_excute_closedbox_event) || - (false==boxOperation)) - p_ui_ctrl->box_state = IBRT_IN_BOX_OPEN; +void app_ibrt_search_ui_init(bool boxOperation, ibrt_event_type evt_type) { + app_ibrt_ui_t *p_ui_ctrl = app_ibrt_ui_get_ctx(); + if ((true == p_ui_ctrl->config.check_plugin_excute_closedbox_event) || + (false == boxOperation)) + p_ui_ctrl->box_state = IBRT_IN_BOX_OPEN; - if(false==boxOperation) - { + if (false == boxOperation) { #ifdef BOX_DET_USE_GPIO - box_det_pin_init(); + box_det_pin_init(); #else - app_battery_register(app_ibrt_battery_callback); + app_battery_register(app_ibrt_battery_callback); #endif - if (app_box_handle_timer == NULL) - app_box_handle_timer = osTimerCreate(osTimer(APP_BOX_HANDLE), osTimerOnce, &box_event); - } - else if(evt_type !=IBRT_IN_BOX_CLOSED) - { - app_ibrt_ui_judge_scan_type(IBRT_OPEN_BOX_TRIGGER,NO_LINK_TYPE,IBRT_UI_NO_ERROR); - } - + if (app_box_handle_timer == NULL) + app_box_handle_timer = + osTimerCreate(osTimer(APP_BOX_HANDLE), osTimerOnce, &box_event); + } else if (evt_type != IBRT_IN_BOX_CLOSED) { + app_ibrt_ui_judge_scan_type(IBRT_OPEN_BOX_TRIGGER, NO_LINK_TYPE, + IBRT_UI_NO_ERROR); + } } +void app_ibrt_remove_history_paired_device(void) { + bt_status_t retStatus; + btif_device_record_t record; + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + int paired_dev_count = nv_record_get_paired_dev_count(); + TWSCON_DBLOG(0, "Remove all history tws nv records."); + TWSCON_DBLOG(0, "Master addr:"); + DUMP8("%02x ", p_ibrt_ctrl->local_addr.address, BTIF_BD_ADDR_SIZE); + TWSCON_DBLOG(0, "Slave addr:"); + DUMP8("%02x ", p_ibrt_ctrl->peer_addr.address, BTIF_BD_ADDR_SIZE); - -void app_ibrt_remove_history_paired_device(void) -{ - bt_status_t retStatus; - btif_device_record_t record; - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - int paired_dev_count = nv_record_get_paired_dev_count(); - - TWSCON_DBLOG(0,"Remove all history tws nv records."); - TWSCON_DBLOG(0,"Master addr:"); - DUMP8("%02x ",p_ibrt_ctrl->local_addr.address, BTIF_BD_ADDR_SIZE); - TWSCON_DBLOG(0,"Slave addr:"); - DUMP8("%02x ",p_ibrt_ctrl->peer_addr.address, BTIF_BD_ADDR_SIZE); - - for (int32_t index = paired_dev_count - 1; index >= 0; index--) - { - retStatus = nv_record_enum_dev_records(index, &record); - if (BT_STS_SUCCESS == retStatus) - { - TWSCON_DBLOG(1,"The index %d of nv records:", index); - DUMP8("%02x ", record.bdAddr.address, BTIF_BD_ADDR_SIZE); - if (!memcmp(record.bdAddr.address, p_ibrt_ctrl->local_addr.address, BTIF_BD_ADDR_SIZE) || - !memcmp(record.bdAddr.address, p_ibrt_ctrl->peer_addr.address, BTIF_BD_ADDR_SIZE)) - { - nv_record_ddbrec_delete(&record.bdAddr); - TWSCON_DBLOG(1,"Delete the nv record entry %d", index); - } - } + for (int32_t index = paired_dev_count - 1; index >= 0; index--) { + retStatus = nv_record_enum_dev_records(index, &record); + if (BT_STS_SUCCESS == retStatus) { + TWSCON_DBLOG(1, "The index %d of nv records:", index); + DUMP8("%02x ", record.bdAddr.address, BTIF_BD_ADDR_SIZE); + if (!memcmp(record.bdAddr.address, p_ibrt_ctrl->local_addr.address, + BTIF_BD_ADDR_SIZE) || + !memcmp(record.bdAddr.address, p_ibrt_ctrl->peer_addr.address, + BTIF_BD_ADDR_SIZE)) { + nv_record_ddbrec_delete(&record.bdAddr); + TWSCON_DBLOG(1, "Delete the nv record entry %d", index); + } } + } - memset(p_ibrt_ctrl->local_addr.address, 0, BTIF_BD_ADDR_SIZE); - memset(p_ibrt_ctrl->peer_addr.address, 0, BTIF_BD_ADDR_SIZE); + memset(p_ibrt_ctrl->local_addr.address, 0, BTIF_BD_ADDR_SIZE); + memset(p_ibrt_ctrl->peer_addr.address, 0, BTIF_BD_ADDR_SIZE); } +void app_bt_enter_mono_pairing_mode(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); -void app_bt_enter_mono_pairing_mode(void) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); + p_ibrt_ui->box_state = IBRT_OUT_BOX; - p_ibrt_ui->box_state = IBRT_OUT_BOX; - - TRACE(0,"ibrt_ui_log:app_bt_enter_mono_pairing_mode"); + TRACE(0, "ibrt_ui_log:app_bt_enter_mono_pairing_mode"); - if(!app_device_bt_is_connected()) - { - if(p_ibrt_ctrl->nv_role == IBRT_UNKNOW) - { - app_ibrt_ui_judge_scan_type(IBRT_FREEMAN_PAIR_TRIGGER,NO_LINK_TYPE, IBRT_UI_NO_ERROR); - app_ibrt_ui_set_freeman_enable(); - } - else - { - //app_tws_ibrt_set_access_mode(BTIF_BAM_GENERAL_ACCESSIBLE); - app_ibrt_ui_set_enter_pairing_mode(IBRT_CONNECT_MOBILE_FAILED); - app_ibrt_ui_judge_scan_type(IBRT_CONNECTE_TRIGGER,MOBILE_LINK, 0); - } - } - + if (!app_device_bt_is_connected()) { + if (p_ibrt_ctrl->nv_role == IBRT_UNKNOW) { + app_ibrt_ui_judge_scan_type(IBRT_FREEMAN_PAIR_TRIGGER, NO_LINK_TYPE, + IBRT_UI_NO_ERROR); + app_ibrt_ui_set_freeman_enable(); + } else { + // app_tws_ibrt_set_access_mode(BTIF_BAM_GENERAL_ACCESSIBLE); + app_ibrt_ui_set_enter_pairing_mode(IBRT_CONNECT_MOBILE_FAILED); + app_ibrt_ui_judge_scan_type(IBRT_CONNECTE_TRIGGER, MOBILE_LINK, 0); + } + } } -void app_ibrt_enter_limited_mode(void) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); +void app_ibrt_enter_limited_mode(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); - p_ibrt_ctrl->nv_role=IBRT_UNKNOW; - p_ibrt_ui->box_state = IBRT_OUT_BOX; - - app_ibrt_remove_history_paired_device(); - TRACE(0,"ibrt_ui_log:power on enter pairing"); - app_ibrt_ui_judge_scan_type(IBRT_SEARCH_SLAVE_TRIGGER,NO_LINK_TYPE,IBRT_UI_NO_ERROR); + p_ibrt_ctrl->nv_role = IBRT_UNKNOW; + p_ibrt_ui->box_state = IBRT_OUT_BOX; + app_ibrt_remove_history_paired_device(); + TRACE(0, "ibrt_ui_log:power on enter pairing"); + app_ibrt_ui_judge_scan_type(IBRT_SEARCH_SLAVE_TRIGGER, NO_LINK_TYPE, + IBRT_UI_NO_ERROR); } #endif - - diff --git a/services/app_ibrt/src/app_ibrt_ui_test.cpp b/services/app_ibrt/src/app_ibrt_ui_test.cpp index 8882a17..f9b4c54 100644 --- a/services/app_ibrt/src/app_ibrt_ui_test.cpp +++ b/services/app_ibrt/src/app_ibrt_ui_test.cpp @@ -13,33 +13,32 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "app_tws_ibrt_trace.h" -#include "factory_section.h" -#include "apps.h" -#include "app_battery.h" -#include "app_anc.h" -#include "app_key.h" -#include "app_ibrt_if.h" #include "app_ibrt_ui_test.h" -#include "app_ibrt_auto_test.h" -#include "app_ibrt_ui_test_cmd_if.h" -#include "app_ibrt_peripheral_manager.h" #include "a2dp_decoder.h" -#include "app_ibrt_keyboard.h" -#include "nvrecord_env.h" -#include "nvrecord_ble.h" -#include "app_tws_if.h" -#include "besbt.h" -#include "app_bt.h" +#include "app.h" #include "app_ai_if.h" #include "app_ai_manager_api.h" -#include "nvrecord_extension.h" -#include "app_key.h" +#include "app_anc.h" +#include "app_battery.h" #include "app_ble_mode_switch.h" -#include "app.h" -#include "norflash_api.h" +#include "app_bt.h" +#include "app_ibrt_auto_test.h" +#include "app_ibrt_if.h" +#include "app_ibrt_keyboard.h" +#include "app_ibrt_peripheral_manager.h" +#include "app_ibrt_ui_test_cmd_if.h" +#include "app_key.h" +#include "app_tws_ibrt_trace.h" +#include "app_tws_if.h" +#include "apps.h" +#include "besbt.h" #include "btapp.h" +#include "factory_section.h" +#include "norflash_api.h" +#include "nvrecord_ble.h" +#include "nvrecord_env.h" +#include "nvrecord_extension.h" +#include #if defined(BISTO_ENABLED) #include "gsound_custom_actions.h" #include "gsound_custom_ble.h" @@ -65,193 +64,168 @@ extern uint8_t avoid_even_packets_protect_flag; #endif #if defined(IBRT) #include "btapp.h" -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; bt_bdaddr_t master_ble_addr = {0x76, 0x33, 0x33, 0x22, 0x11, 0x11}; -bt_bdaddr_t slave_ble_addr = {0x77, 0x33, 0x33, 0x22, 0x11, 0x11}; -bt_bdaddr_t box_ble_addr = {0x78, 0x33, 0x33, 0x22, 0x11, 0x11}; +bt_bdaddr_t slave_ble_addr = {0x77, 0x33, 0x33, 0x22, 0x11, 0x11}; +bt_bdaddr_t box_ble_addr = {0x78, 0x33, 0x33, 0x22, 0x11, 0x11}; #ifdef IBRT_SEARCH_UI -void app_ibrt_battery_callback(APP_BATTERY_MV_T currvolt, uint8_t currlevel,enum APP_BATTERY_STATUS_T curstatus,uint32_t status, union APP_BATTERY_MSG_PRAMS prams); -void app_ibrt_simulate_charger_plug_in_test(void) -{ - union APP_BATTERY_MSG_PRAMS msg_prams; - msg_prams.charger = APP_BATTERY_CHARGER_PLUGIN; - app_ibrt_battery_callback(0, 0, APP_BATTERY_STATUS_CHARGING, 1, msg_prams); +void app_ibrt_battery_callback(APP_BATTERY_MV_T currvolt, uint8_t currlevel, + enum APP_BATTERY_STATUS_T curstatus, + uint32_t status, + union APP_BATTERY_MSG_PRAMS prams); +void app_ibrt_simulate_charger_plug_in_test(void) { + union APP_BATTERY_MSG_PRAMS msg_prams; + msg_prams.charger = APP_BATTERY_CHARGER_PLUGIN; + app_ibrt_battery_callback(0, 0, APP_BATTERY_STATUS_CHARGING, 1, msg_prams); } -void app_ibrt_simulate_charger_plug_out_test(void) -{ - union APP_BATTERY_MSG_PRAMS msg_prams; - msg_prams.charger = APP_BATTERY_CHARGER_PLUGOUT; - app_ibrt_battery_callback(0, 0, APP_BATTERY_STATUS_CHARGING, 1, msg_prams); +void app_ibrt_simulate_charger_plug_out_test(void) { + union APP_BATTERY_MSG_PRAMS msg_prams; + msg_prams.charger = APP_BATTERY_CHARGER_PLUGOUT; + app_ibrt_battery_callback(0, 0, APP_BATTERY_STATUS_CHARGING, 1, msg_prams); } -void app_ibrt_simulate_charger_plug_box_test(void) -{ - static int count = 0; - if (count++ % 2 == 0) - { - app_ibrt_simulate_charger_plug_in_test(); - } - else - { - app_ibrt_simulate_charger_plug_out_test(); - } +void app_ibrt_simulate_charger_plug_box_test(void) { + static int count = 0; + if (count++ % 2 == 0) { + app_ibrt_simulate_charger_plug_in_test(); + } else { + app_ibrt_simulate_charger_plug_out_test(); + } } extern void app_ibrt_sync_volume_info(); -void app_ibrt_search_ui_gpio_key_handle(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s,event:%d,code:%d",__func__,status->event,status->code); - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); +void app_ibrt_search_ui_gpio_key_handle(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s,event:%d,code:%d", __func__, status->event, status->code); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (IBRT_SLAVE == p_ibrt_ctrl->current_role && status->event == APP_KEY_EVENT_DOUBLECLICK) - { - app_ibrt_if_keyboard_notify(status,param); - } - else - { - switch (status->event) - { - case APP_KEY_EVENT_CLICK: - /*if (status->code == APP_KEY_CODE_FN1) - { - app_ibrt_simulate_charger_plug_in_test(); - } - else if(status->code == APP_KEY_CODE_FN2) - { - app_ibrt_simulate_charger_plug_out_test(); - } - else - { + if (IBRT_SLAVE == p_ibrt_ctrl->current_role && + status->event == APP_KEY_EVENT_DOUBLECLICK) { + app_ibrt_if_keyboard_notify(status, param); + } else { + switch (status->event) { + case APP_KEY_EVENT_CLICK: + /*if (status->code == APP_KEY_CODE_FN1) + { + app_ibrt_simulate_charger_plug_in_test(); + } + else if(status->code == APP_KEY_CODE_FN2) + { + app_ibrt_simulate_charger_plug_out_test(); + } + else + { - }*/ - break; - case APP_KEY_EVENT_DOUBLECLICK: - if (status->code == APP_KEY_CODE_FN1) - { - app_bt_volumeup(); - if(IBRT_MASTER==p_ibrt_ctrl->current_role) - { - TRACE(0,"ibrt master sync volume up to slave !"); - app_ibrt_sync_volume_info(); - } - - } - else if(status->code == APP_KEY_CODE_FN2) - { - app_bt_volumedown(); - if(IBRT_MASTER==p_ibrt_ctrl->current_role) - { - TRACE(0,"ibrt master sync volume up to slave !"); - app_ibrt_sync_volume_info(); - } - } - else - { - - } - break; - case APP_KEY_EVENT_LONGPRESS: - if (status->code == APP_KEY_CODE_FN1) - { -#ifdef TPORTS_KEY_COEXIST - app_ibrt_simulate_charger_plug_out_test(); -#else - app_ibrt_ui_tws_switch(); -#endif - } - else if(status->code == APP_KEY_CODE_FN2) - { - - } - else - { - - } - break; - default: - break; + }*/ + break; + case APP_KEY_EVENT_DOUBLECLICK: + if (status->code == APP_KEY_CODE_FN1) { + app_bt_volumeup(); + if (IBRT_MASTER == p_ibrt_ctrl->current_role) { + TRACE(0, "ibrt master sync volume up to slave !"); + app_ibrt_sync_volume_info(); } + + } else if (status->code == APP_KEY_CODE_FN2) { + app_bt_volumedown(); + if (IBRT_MASTER == p_ibrt_ctrl->current_role) { + TRACE(0, "ibrt master sync volume up to slave !"); + app_ibrt_sync_volume_info(); + } + } else { + } + break; + case APP_KEY_EVENT_LONGPRESS: + if (status->code == APP_KEY_CODE_FN1) { +#ifdef TPORTS_KEY_COEXIST + app_ibrt_simulate_charger_plug_out_test(); +#else + app_ibrt_ui_tws_switch(); +#endif + } else if (status->code == APP_KEY_CODE_FN2) { + + } else { + } + break; + default: + break; } + } } #endif - - -const app_uart_handle_t app_ibrt_uart_test_handle[]= -{ - {"factoryreset_test",app_ibrt_nvrecord_rebuild}, - {"roleswitch_test",app_ibrt_role_switch_test}, - {"inquiry_start_test",app_ibrt_inquiry_start_test}, - {"open_box_event_test",app_ibrt_ui_open_box_event_test}, - {"fetch_out_box_event_test",app_ibrt_ui_fetch_out_box_event_test}, - {"put_in_box_event_test",app_ibrt_ui_put_in_box_event_test}, - {"close_box_event_test",app_ibrt_ui_close_box_event_test}, - {"reconnect_event_test",app_ibrt_ui_reconnect_event_test}, - {"wear_up_event_test",app_ibrt_ui_ware_up_event_test}, - {"wear_down_event_test",app_ibrt_ui_ware_down_event_test}, - {"shut_down_test",app_ibrt_ui_shut_down_test}, - {"phone_connect_event_test",app_ibrt_ui_phone_connect_event_test}, - {"switch_ibrt_test",app_ibrt_ui_tws_swtich_test}, - {"suspend_ibrt_test",app_ibrt_ui_suspend_ibrt_test}, - {"resume_ibrt_test",app_ibrt_ui_resume_ibrt_test}, - {"conn_second_mobile_test",app_ibrt_ui_choice_connect_second_mobile}, - {"mobile_tws_disc_test",app_ibrt_if_disconnect_mobile_tws_link}, - {"pairing_mode_test",app_ibrt_ui_pairing_mode_test}, - {"freeman_mode_test",app_ibrt_ui_freeman_pairing_mode_test}, - {"audio_play",app_ibrt_ui_audio_play_test}, - {"audio_pause",app_ibrt_ui_audio_pause_test}, - {"audio_forward",app_ibrt_ui_audio_forward_test}, - {"audio_backward",app_ibrt_ui_audio_backward_test}, - {"avrcp_volup",app_ibrt_ui_avrcp_volume_up_test}, - {"avrcp_voldn",app_ibrt_ui_avrcp_volume_down_test}, - {"hfsco_create",app_ibrt_ui_hfsco_create_test}, - {"hfsco_disc",app_ibrt_ui_hfsco_disc_test}, - {"call_redial",app_ibrt_ui_call_redial_test}, - {"call_answer",app_ibrt_ui_call_answer_test}, - {"call_hangup",app_ibrt_ui_call_hangup_test}, - {"volume_up",app_ibrt_ui_local_volume_up_test}, - {"volume_down",app_ibrt_ui_local_volume_down_test}, - {"get_a2dp_state",app_ibrt_ui_get_a2dp_state_test}, - {"get_avrcp_state",app_ibrt_ui_get_avrcp_state_test}, - {"get_hfp_state",app_ibrt_ui_get_hfp_state_test}, - {"get_call_status",app_ibrt_ui_get_call_status_test}, - {"get_ibrt_role",app_ibrt_ui_get_ibrt_role_test}, - {"get_tws_state",app_ibrt_ui_get_tws_conn_state_test}, +const app_uart_handle_t app_ibrt_uart_test_handle[] = { + {"factoryreset_test", app_ibrt_nvrecord_rebuild}, + {"roleswitch_test", app_ibrt_role_switch_test}, + {"inquiry_start_test", app_ibrt_inquiry_start_test}, + {"open_box_event_test", app_ibrt_ui_open_box_event_test}, + {"fetch_out_box_event_test", app_ibrt_ui_fetch_out_box_event_test}, + {"put_in_box_event_test", app_ibrt_ui_put_in_box_event_test}, + {"close_box_event_test", app_ibrt_ui_close_box_event_test}, + {"reconnect_event_test", app_ibrt_ui_reconnect_event_test}, + {"wear_up_event_test", app_ibrt_ui_ware_up_event_test}, + {"wear_down_event_test", app_ibrt_ui_ware_down_event_test}, + {"shut_down_test", app_ibrt_ui_shut_down_test}, + {"phone_connect_event_test", app_ibrt_ui_phone_connect_event_test}, + {"switch_ibrt_test", app_ibrt_ui_tws_swtich_test}, + {"suspend_ibrt_test", app_ibrt_ui_suspend_ibrt_test}, + {"resume_ibrt_test", app_ibrt_ui_resume_ibrt_test}, + {"conn_second_mobile_test", app_ibrt_ui_choice_connect_second_mobile}, + {"mobile_tws_disc_test", app_ibrt_if_disconnect_mobile_tws_link}, + {"pairing_mode_test", app_ibrt_ui_pairing_mode_test}, + {"freeman_mode_test", app_ibrt_ui_freeman_pairing_mode_test}, + {"audio_play", app_ibrt_ui_audio_play_test}, + {"audio_pause", app_ibrt_ui_audio_pause_test}, + {"audio_forward", app_ibrt_ui_audio_forward_test}, + {"audio_backward", app_ibrt_ui_audio_backward_test}, + {"avrcp_volup", app_ibrt_ui_avrcp_volume_up_test}, + {"avrcp_voldn", app_ibrt_ui_avrcp_volume_down_test}, + {"hfsco_create", app_ibrt_ui_hfsco_create_test}, + {"hfsco_disc", app_ibrt_ui_hfsco_disc_test}, + {"call_redial", app_ibrt_ui_call_redial_test}, + {"call_answer", app_ibrt_ui_call_answer_test}, + {"call_hangup", app_ibrt_ui_call_hangup_test}, + {"volume_up", app_ibrt_ui_local_volume_up_test}, + {"volume_down", app_ibrt_ui_local_volume_down_test}, + {"get_a2dp_state", app_ibrt_ui_get_a2dp_state_test}, + {"get_avrcp_state", app_ibrt_ui_get_avrcp_state_test}, + {"get_hfp_state", app_ibrt_ui_get_hfp_state_test}, + {"get_call_status", app_ibrt_ui_get_call_status_test}, + {"get_ibrt_role", app_ibrt_ui_get_ibrt_role_test}, + {"get_tws_state", app_ibrt_ui_get_tws_conn_state_test}, {"iic_switch", app_ibrt_ui_iic_uart_switch_test}, {"soft_reset", app_ibrt_ui_soft_reset_test}, #ifdef IBRT_SEARCH_UI - {"plug_in_test",app_ibrt_simulate_charger_plug_in_test}, - {"plug_out_test",app_ibrt_simulate_charger_plug_out_test}, - {"plug_box_test",app_ibrt_simulate_charger_plug_box_test}, + {"plug_in_test", app_ibrt_simulate_charger_plug_in_test}, + {"plug_out_test", app_ibrt_simulate_charger_plug_out_test}, + {"plug_box_test", app_ibrt_simulate_charger_plug_box_test}, #endif #ifdef IBRT_ENHANCED_STACK_PTS - {"hf_create_service_link",btif_pts_hf_create_link_with_pts}, - {"hf_disc_service_link",btif_pts_hf_disc_service_link}, - {"hf_create_audio_link",btif_pts_hf_create_audio_link}, - {"hf_disc_audio_link",btif_pts_hf_disc_audio_link}, - {"hf_answer_call",btif_pts_hf_answer_call}, - {"hf_hangup_call",btif_pts_hf_hangup_call}, - {"rfc_register",btif_pts_rfc_register_channel}, - {"rfc_close",btif_pts_rfc_close}, - {"av_create_channel",btif_pts_av_create_channel_with_pts}, - {"av_disc_channel",btif_pts_av_disc_channel}, - {"ar_connect",btif_pts_ar_connect_with_pts}, - {"ar_disconnect",btif_pts_ar_disconnect}, - {"ar_panel_play",btif_pts_ar_panel_play}, - {"ar_panel_pause",btif_pts_ar_panel_pause}, - {"ar_panel_stop",btif_pts_ar_panel_stop}, - {"ar_panel_forward",btif_pts_ar_panel_forward}, - {"ar_panel_backward",btif_pts_ar_panel_backward}, - {"ar_volume_up",btif_pts_ar_volume_up}, - {"ar_volume_down",btif_pts_ar_volume_down}, - {"ar_volume_notify",btif_pts_ar_volume_notify}, - {"ar_volume_change",btif_pts_ar_volume_change}, - {"ar_set_absolute_volume",btif_pts_ar_set_absolute_volume}, + {"hf_create_service_link", btif_pts_hf_create_link_with_pts}, + {"hf_disc_service_link", btif_pts_hf_disc_service_link}, + {"hf_create_audio_link", btif_pts_hf_create_audio_link}, + {"hf_disc_audio_link", btif_pts_hf_disc_audio_link}, + {"hf_answer_call", btif_pts_hf_answer_call}, + {"hf_hangup_call", btif_pts_hf_hangup_call}, + {"rfc_register", btif_pts_rfc_register_channel}, + {"rfc_close", btif_pts_rfc_close}, + {"av_create_channel", btif_pts_av_create_channel_with_pts}, + {"av_disc_channel", btif_pts_av_disc_channel}, + {"ar_connect", btif_pts_ar_connect_with_pts}, + {"ar_disconnect", btif_pts_ar_disconnect}, + {"ar_panel_play", btif_pts_ar_panel_play}, + {"ar_panel_pause", btif_pts_ar_panel_pause}, + {"ar_panel_stop", btif_pts_ar_panel_stop}, + {"ar_panel_forward", btif_pts_ar_panel_forward}, + {"ar_panel_backward", btif_pts_ar_panel_backward}, + {"ar_volume_up", btif_pts_ar_volume_up}, + {"ar_volume_down", btif_pts_ar_volume_down}, + {"ar_volume_notify", btif_pts_ar_volume_notify}, + {"ar_volume_change", btif_pts_ar_volume_change}, + {"ar_set_absolute_volume", btif_pts_ar_set_absolute_volume}, #endif }; - /***************************************************************************** Prototype : app_ibrt_ui_find_uart_handle Description : find the test cmd handle @@ -267,19 +241,18 @@ const app_uart_handle_t app_ibrt_uart_test_handle[]= Modification : Created function *****************************************************************************/ -app_uart_test_function_handle app_ibrt_ui_find_uart_handle(unsigned char* buf) -{ - app_uart_test_function_handle p = NULL; - for(uint8_t i = 0; icode, status->event); - TWS_PD_MSG_BLOCK msg; - msg.msg_body.message_id = 0; - msg.msg_body.message_ptr = (uint32_t)NULL; - app_ibrt_peripheral_mailbox_put(&msg); +void app_ibrt_key1(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); + TWS_PD_MSG_BLOCK msg; + msg.msg_body.message_id = 0; + msg.msg_body.message_ptr = (uint32_t)NULL; + app_ibrt_peripheral_mailbox_put(&msg); } -void app_ibrt_key2(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); - TWS_PD_MSG_BLOCK msg; - msg.msg_body.message_id = 1; - msg.msg_body.message_ptr = (uint32_t)NULL; - app_ibrt_peripheral_mailbox_put(&msg); +void app_ibrt_key2(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); + TWS_PD_MSG_BLOCK msg; + msg.msg_body.message_id = 1; + msg.msg_body.message_ptr = (uint32_t)NULL; + app_ibrt_peripheral_mailbox_put(&msg); } -void app_ibrt_key3(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); - TWS_PD_MSG_BLOCK msg; - msg.msg_body.message_id = 2; - msg.msg_body.message_ptr = (uint32_t)NULL; - app_ibrt_peripheral_mailbox_put(&msg); +void app_ibrt_key3(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); + TWS_PD_MSG_BLOCK msg; + msg.msg_body.message_id = 2; + msg.msg_body.message_ptr = (uint32_t)NULL; + app_ibrt_peripheral_mailbox_put(&msg); } -void app_ibrt_key4(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); - TWS_PD_MSG_BLOCK msg; - msg.msg_body.message_id = 3; - msg.msg_body.message_ptr = (uint32_t)NULL; - app_ibrt_peripheral_mailbox_put(&msg); +void app_ibrt_key4(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); + TWS_PD_MSG_BLOCK msg; + msg.msg_body.message_id = 3; + msg.msg_body.message_ptr = (uint32_t)NULL; + app_ibrt_peripheral_mailbox_put(&msg); } -void app_ibrt_key5(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); - TWS_PD_MSG_BLOCK msg; - msg.msg_body.message_id = 4; - msg.msg_body.message_ptr = (uint32_t)NULL; - app_ibrt_peripheral_mailbox_put(&msg); +void app_ibrt_key5(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); + TWS_PD_MSG_BLOCK msg; + msg.msg_body.message_id = 4; + msg.msg_body.message_ptr = (uint32_t)NULL; + app_ibrt_peripheral_mailbox_put(&msg); } -void app_ibrt_key6(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); - TWS_PD_MSG_BLOCK msg; - msg.msg_body.message_id = 5; - msg.msg_body.message_ptr = (uint32_t)NULL; - app_ibrt_peripheral_mailbox_put(&msg); +void app_ibrt_key6(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); + TWS_PD_MSG_BLOCK msg; + msg.msg_body.message_id = 5; + msg.msg_body.message_ptr = (uint32_t)NULL; + app_ibrt_peripheral_mailbox_put(&msg); } #endif - -void app_bt_sleep(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); - //app_ibrt_ui_event_entry(IBRT_CLOSE_BOX_EVENT); - bt_key_handle_func_click(); +void app_bt_sleep(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); + // app_ibrt_ui_event_entry(IBRT_CLOSE_BOX_EVENT); + bt_key_handle_func_click(); } - - -void app_wakeup_sleep(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); - //app_ibrt_ui_event_entry(IBRT_FETCH_OUT_EVENT); - a2dp_handleKey(AVRCP_KEY_PLAY); +void app_wakeup_sleep(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); + // app_ibrt_ui_event_entry(IBRT_FETCH_OUT_EVENT); + a2dp_handleKey(AVRCP_KEY_PLAY); } -void app_test_key(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); - //app_ibrt_ui_event_entry(IBRT_FETCH_OUT_EVENT); - a2dp_handleKey(AVRCP_KEY_PLAY); +void app_test_key(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); + // app_ibrt_ui_event_entry(IBRT_FETCH_OUT_EVENT); + a2dp_handleKey(AVRCP_KEY_PLAY); } #if defined(__BT_DEBUG_TPORTS__) && !defined(TPORTS_KEY_COEXIST) -void app_ibrt_ui_test_key(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); - { +void app_ibrt_ui_test_key(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); + { #ifdef IBRT_SEARCH_UI - app_ibrt_search_ui_handle_key(status,param); + app_ibrt_search_ui_handle_key(status, param); #else - app_ibrt_normal_ui_handle_key(status,param); + app_ibrt_normal_ui_handle_key(status, param); #endif - } + } } #else -void app_ibrt_ui_test_key(APP_KEY_STATUS *status, void *param) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); +void app_ibrt_ui_test_key(APP_KEY_STATUS *status, void *param) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); #ifdef TILE_DATAPATH - uint8_t shutdown_key = HAL_KEY_EVENT_TRIPLECLICK; + uint8_t shutdown_key = HAL_KEY_EVENT_TRIPLECLICK; #else - uint8_t shutdown_key = HAL_KEY_EVENT_LONGLONGPRESS; + uint8_t shutdown_key = HAL_KEY_EVENT_LONGLONGPRESS; #endif - TRACE(3,"%s %d,%d",__func__, status->code, status->event); + TRACE(3, "%s %d,%d", __func__, status->code, status->event); -#if 0//def IBRT_OTA +#if 0 // def IBRT_OTA if ((status->code == HAL_KEY_CODE_PWR)&&\ (status->event == APP_KEY_EVENT_CLICK)&&\ (app_check_user_can_role_switch_in_ota())) @@ -435,243 +390,264 @@ void app_ibrt_ui_test_key(APP_KEY_STATUS *status, void *param) } #endif -if (IBRT_SLAVE == p_ibrt_ctrl->current_role && status->event != shutdown_key) - { - /* if(((status->code == HAL_KEY_CODE_PWR)&&(status->event == APP_KEY_EVENT_CLICK)) &&\ - ((p_ibrt_ctrl->master_tws_switch_pending != false) || \ - (p_ibrt_ctrl->slave_tws_switch_pending != false) || \ - (ota_role_switch_flag != 0)||\ - (avoid_even_packets_protect_flag != 0))) - { - TRACE(0, "[OTA] role switch in progress!"); - return ; - } -*/ - app_ibrt_if_keyboard_notify(status,param); - } + if (IBRT_SLAVE == p_ibrt_ctrl->current_role && + status->event != shutdown_key) { + /* if(((status->code == HAL_KEY_CODE_PWR)&&(status->event == + APP_KEY_EVENT_CLICK)) &&\ + ((p_ibrt_ctrl->master_tws_switch_pending != false) || \ + (p_ibrt_ctrl->slave_tws_switch_pending != false) || \ + (ota_role_switch_flag != 0)||\ + (avoid_even_packets_protect_flag != 0))) + { + TRACE(0, "[OTA] role switch in progress!"); + return ; + } + */ + app_ibrt_if_keyboard_notify(status, param); + } - else - { + else { #ifdef IBRT_SEARCH_UI - app_ibrt_search_ui_handle_key(status,param); + app_ibrt_search_ui_handle_key(status, param); #else - app_ibrt_normal_ui_handle_key(status,param); + app_ibrt_normal_ui_handle_key(status, param); #endif - } + } } #endif -void app_ibrt_ui_test_key_io_event(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); - switch(status->event) - { - case APP_KEY_EVENT_CLICK: - if (status->code== APP_KEY_CODE_FN1) - { - app_ibrt_if_event_entry(IBRT_OPEN_BOX_EVENT); - } - else if (status->code== APP_KEY_CODE_FN2) - { - app_ibrt_if_event_entry(IBRT_FETCH_OUT_EVENT); - } - else - { - app_ibrt_if_event_entry(IBRT_WEAR_UP_EVENT); - } - break; - - case APP_KEY_EVENT_DOUBLECLICK: - if (status->code== APP_KEY_CODE_FN1) - { - app_ibrt_if_event_entry(IBRT_CLOSE_BOX_EVENT); - } - else if (status->code== APP_KEY_CODE_FN2) - { - app_ibrt_if_event_entry(IBRT_PUT_IN_EVENT); - } - else - { - app_ibrt_if_event_entry(IBRT_WEAR_DOWN_EVENT); - } - break; - - case APP_KEY_EVENT_LONGPRESS: - break; - - case APP_KEY_EVENT_TRIPLECLICK: - break; - - case HAL_KEY_EVENT_LONGLONGPRESS: - break; - - case APP_KEY_EVENT_ULTRACLICK: - break; - - case APP_KEY_EVENT_RAMPAGECLICK: - break; +void app_ibrt_ui_test_key_io_event(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); + switch (status->event) { + case APP_KEY_EVENT_CLICK: + if (status->code == APP_KEY_CODE_FN1) { + app_ibrt_if_event_entry(IBRT_OPEN_BOX_EVENT); + } else if (status->code == APP_KEY_CODE_FN2) { + app_ibrt_if_event_entry(IBRT_FETCH_OUT_EVENT); + } else { + app_ibrt_if_event_entry(IBRT_WEAR_UP_EVENT); } + break; + + case APP_KEY_EVENT_DOUBLECLICK: + if (status->code == APP_KEY_CODE_FN1) { + app_ibrt_if_event_entry(IBRT_CLOSE_BOX_EVENT); + } else if (status->code == APP_KEY_CODE_FN2) { + app_ibrt_if_event_entry(IBRT_PUT_IN_EVENT); + } else { + app_ibrt_if_event_entry(IBRT_WEAR_DOWN_EVENT); + } + break; + + case APP_KEY_EVENT_LONGPRESS: + break; + + case APP_KEY_EVENT_TRIPLECLICK: + break; + + case HAL_KEY_EVENT_LONGLONGPRESS: + break; + + case APP_KEY_EVENT_ULTRACLICK: + break; + + case APP_KEY_EVENT_RAMPAGECLICK: + break; + } } -void app_ibrt_ui_test_key_custom_event(APP_KEY_STATUS *status, void *param) -{ - TRACE(3,"%s %d,%d",__func__, status->code, status->event); - switch(status->event) - { - case APP_KEY_EVENT_CLICK: - break; +void app_ibrt_ui_test_key_custom_event(APP_KEY_STATUS *status, void *param) { + TRACE(3, "%s %d,%d", __func__, status->code, status->event); + switch (status->event) { + case APP_KEY_EVENT_CLICK: + break; - case APP_KEY_EVENT_DOUBLECLICK: - break; + case APP_KEY_EVENT_DOUBLECLICK: + break; - case APP_KEY_EVENT_LONGPRESS: - break; + case APP_KEY_EVENT_LONGPRESS: + break; - case APP_KEY_EVENT_TRIPLECLICK: - break; + case APP_KEY_EVENT_TRIPLECLICK: + break; - case HAL_KEY_EVENT_LONGLONGPRESS: - break; + case HAL_KEY_EVENT_LONGLONGPRESS: + break; - case APP_KEY_EVENT_ULTRACLICK: - break; + case APP_KEY_EVENT_ULTRACLICK: + break; - case APP_KEY_EVENT_RAMPAGECLICK: - break; - } + case APP_KEY_EVENT_RAMPAGECLICK: + break; + } } -void app_ibrt_ui_test_voice_assistant_key(APP_KEY_STATUS *status, void *param) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); +void app_ibrt_ui_test_voice_assistant_key(APP_KEY_STATUS *status, void *param) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - TRACE(3,"%s code 0x%x event %d", __func__, status->code, status->event); + TRACE(3, "%s code 0x%x event %d", __func__, status->code, status->event); - if (APP_KEY_CODE_GOOGLE != status->code) - { - return; + if (APP_KEY_CODE_GOOGLE != status->code) { + return; + } else { + ibrt_ctrl_t *pIbrtCtrl = app_tws_ibrt_get_bt_ctrl_ctx(); + + if (IBRT_ACTIVE_MODE != pIbrtCtrl->tws_mode) { + app_tws_ibrt_exit_sniff_with_mobile(); } - else - { - ibrt_ctrl_t *pIbrtCtrl = app_tws_ibrt_get_bt_ctrl_ctx(); + } - if (IBRT_ACTIVE_MODE != pIbrtCtrl->tws_mode) - { - app_tws_ibrt_exit_sniff_with_mobile(); - } - } - - if (p_ibrt_ctrl->current_role != IBRT_MASTER) - { - app_ibrt_if_keyboard_notify(status, param); - TRACE(2,"%s isn't master %d", __func__, p_ibrt_ctrl->current_role); - return; - } + if (p_ibrt_ctrl->current_role != IBRT_MASTER) { + app_ibrt_if_keyboard_notify(status, param); + TRACE(2, "%s isn't master %d", __func__, p_ibrt_ctrl->current_role); + return; + } #ifdef IS_MULTI_AI_ENABLED - if (app_ai_manager_spec_get_status_is_in_invalid()) - { - TRACE(0,"AI feature has been diabled"); - return; - } + if (app_ai_manager_spec_get_status_is_in_invalid()) { + TRACE(0, "AI feature has been diabled"); + return; + } - if (app_ai_manager_is_need_reboot()) - { - TRACE(1, "%s ai need to reboot", __func__); - return; - } + if (app_ai_manager_is_need_reboot()) { + TRACE(1, "%s ai need to reboot", __func__); + return; + } #ifdef MAI_TYPE_REBOOT_WITHOUT_OEM_APP - if (app_ai_manager_get_spec_update_flag()) - { - TRACE(0,"device reboot is ongoing..."); - return; - } + if (app_ai_manager_get_spec_update_flag()) { + TRACE(0, "device reboot is ongoing..."); + return; + } #endif - if(app_ai_manager_voicekey_is_enable()) - { - if (AI_SPEC_GSOUND == app_ai_manager_get_current_spec()) - { + if (app_ai_manager_voicekey_is_enable()) { + if (AI_SPEC_GSOUND == app_ai_manager_get_current_spec()) { #ifdef BISTO_ENABLED - gsound_custom_actions_handle_key(status, param); + gsound_custom_actions_handle_key(status, param); #endif - } - else if(AI_SPEC_INIT != app_ai_manager_get_current_spec()) - { - app_ai_key_event_handle(status, 0); - } + } else if (AI_SPEC_INIT != app_ai_manager_get_current_spec()) { + app_ai_key_event_handle(status, 0); } + } #else #ifdef __AI_VOICE__ - app_ai_key_event_handle(status, 0); + app_ai_key_event_handle(status, 0); #endif #ifdef BISTO_ENABLED - gsound_custom_actions_handle_key(status, param); + gsound_custom_actions_handle_key(status, param); #endif #endif } -const APP_KEY_HANDLE app_ibrt_ui_test_key_cfg[] = -{ +const APP_KEY_HANDLE app_ibrt_ui_test_key_cfg[] = { #if defined(ANC_APP) #endif -#if defined(__BT_ANC_KEY__)&&defined(ANC_APP) +#if defined(__BT_ANC_KEY__) && defined(ANC_APP) //{{APP_KEY_CODE_PWR,APP_KEY_EVENT_CLICK},"bt anc key",app_anc_key, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_LONGPRESS},"app_ibrt_ui_test_key", app_anc_key, NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_LONGPRESS}, + "app_ibrt_ui_test_key", + app_anc_key, + NULL}, #else - //{{APP_KEY_CODE_PWR,APP_KEY_EVENT_CLICK},"app_ibrt_ui_test_key", app_ibrt_ui_test_key, NULL}, +//{{APP_KEY_CODE_PWR,APP_KEY_EVENT_CLICK},"app_ibrt_ui_test_key", +// app_ibrt_ui_test_key, NULL}, #endif - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_CLICK},"app_ibrt_ui_test_key", app_bt_sleep, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_DOUBLECLICK},"app_ibrt_ui_test_key", app_wakeup_sleep, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_TRIPLECLICK},"app_ibrt_ui_test_key", app_ibrt_ui_test_key, NULL}, - {{APP_KEY_CODE_PWR,APP_KEY_EVENT_ULTRACLICK},"app_ibrt_ui_test_key", app_ibrt_ui_test_key, NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_CLICK}, + "app_ibrt_ui_test_key", + app_bt_sleep, + NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_DOUBLECLICK}, + "app_ibrt_ui_test_key", + app_wakeup_sleep, + NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_TRIPLECLICK}, + "app_ibrt_ui_test_key", + app_ibrt_ui_test_key, + NULL}, + {{APP_KEY_CODE_PWR, APP_KEY_EVENT_ULTRACLICK}, + "app_ibrt_ui_test_key", + app_ibrt_ui_test_key, + NULL}, }; /* -* customer addr config here -*/ -ibrt_pairing_info_t g_ibrt_pairing_info[] = -{ - {{0x51, 0x33, 0x33, 0x22, 0x11, 0x11},{0x50, 0x33, 0x33, 0x22, 0x11, 0x11}}, - {{0x53, 0x33, 0x33, 0x22, 0x11, 0x11},{0x52, 0x33, 0x33, 0x22, 0x11, 0x11}}, /*LJH*/ - {{0x61, 0x33, 0x33, 0x22, 0x11, 0x11},{0x60, 0x33, 0x33, 0x22, 0x11, 0x11}}, - {{0x67, 0x66, 0x66, 0x22, 0x11, 0x11},{0x66, 0x66, 0x66, 0x22, 0x11, 0x11}}, /*bisto*/ - {{0x71, 0x33, 0x33, 0x22, 0x11, 0x11},{0x70, 0x33, 0x33, 0x22, 0x11, 0x11}}, - {{0x81, 0x33, 0x33, 0x22, 0x11, 0x11},{0x80, 0x33, 0x33, 0x22, 0x11, 0x11}}, - {{0x91, 0x33, 0x33, 0x22, 0x11, 0x11},{0x90, 0x33, 0x33, 0x22, 0x11, 0x11}}, /*Customer use*/ - {{0x05, 0x33, 0x33, 0x22, 0x11, 0x11},{0x04, 0x33, 0x33, 0x22, 0x11, 0x11}}, /*Rui*/ - {{0x07, 0x33, 0x33, 0x22, 0x11, 0x11},{0x06, 0x33, 0x33, 0x22, 0x11, 0x11}}, /*zsl*/ - {{0x88, 0xaa, 0x33, 0x22, 0x11, 0x11},{0x87, 0xaa, 0x33, 0x22, 0x11, 0x11}}, /*Lufang*/ - {{0x77, 0x22, 0x66, 0x22, 0x11, 0x11},{0x77, 0x33, 0x66, 0x22, 0x11, 0x11}}, /*xiao*/ - {{0xAA, 0x22, 0x66, 0x22, 0x11, 0x11},{0xBB, 0x33, 0x66, 0x22, 0x11, 0x11}}, /*LUOBIN*/ - {{0x08, 0x33, 0x66, 0x22, 0x11, 0x11},{0x07, 0x33, 0x66, 0x22, 0x11, 0x11}}, /*Yangbin1*/ - {{0x0B, 0x33, 0x66, 0x22, 0x11, 0x11},{0x0A, 0x33, 0x66, 0x22, 0x11, 0x11}}, /*Yangbin2*/ - {{0x35, 0x33, 0x66, 0x22, 0x11, 0x11},{0x34, 0x33, 0x66, 0x22, 0x11, 0x11}}, /*Lulu*/ - {{0xF8, 0x33, 0x66, 0x22, 0x11, 0x11},{0xF7, 0x33, 0x66, 0x22, 0x11, 0x11}}, /*jtx*/ - {{0xd3, 0x53, 0x86, 0x42, 0x71, 0x31},{0xd2, 0x53, 0x86, 0x42, 0x71, 0x31}}, /*shhx*/ - {{0xcc, 0xaa, 0x99, 0x88, 0x77, 0x66},{0xbb, 0xaa, 0x99, 0x88, 0x77, 0x66}}, /*mql*/ - {{0x95, 0x33, 0x69, 0x22, 0x11, 0x11},{0x94, 0x33, 0x69, 0x22, 0x11, 0x11}}, /*wyl*/ - {{0x82, 0x35, 0x68, 0x24, 0x19, 0x17},{0x81, 0x35, 0x68, 0x24, 0x19, 0x17}}, /*hy*/ - {{0x66, 0x66, 0x88, 0x66, 0x66, 0x88},{0x65, 0x66, 0x88, 0x66, 0x66, 0x88}}, /*xdl*/ - {{0x61, 0x66, 0x66, 0x66, 0x66, 0x81},{0x16, 0x66, 0x66, 0x66, 0x66, 0x18}}, /*test1*/ - {{0x62, 0x66, 0x66, 0x66, 0x66, 0x82},{0x26, 0x66, 0x66, 0x66, 0x66, 0x28}}, /*test2*/ - {{0x63, 0x66, 0x66, 0x66, 0x66, 0x83},{0x36, 0x66, 0x66, 0x66, 0x66, 0x38}}, /*test3*/ - {{0x64, 0x66, 0x66, 0x66, 0x66, 0x84},{0x46, 0x66, 0x66, 0x66, 0x66, 0x48}}, /*test4*/ - {{0x65, 0x66, 0x66, 0x66, 0x66, 0x85},{0x56, 0x66, 0x66, 0x66, 0x66, 0x58}}, /*test5*/ - {{0xaa, 0x66, 0x66, 0x66, 0x66, 0x86},{0xaa, 0x66, 0x66, 0x66, 0x66, 0x68}}, /*test6*/ - {{0x67, 0x66, 0x66, 0x66, 0x66, 0x87},{0x76, 0x66, 0x66, 0x66, 0x66, 0x78}}, /*test7*/ - {{0x68, 0x66, 0x66, 0x66, 0x66, 0xa8},{0x86, 0x66, 0x66, 0x66, 0x66, 0x8a}}, /*test8*/ - {{0x69, 0x66, 0x66, 0x66, 0x66, 0x89},{0x86, 0x66, 0x66, 0x66, 0x66, 0x18}}, /*test9*/ - {{0x93, 0x33, 0x33, 0x33, 0x33, 0x33},{0x92, 0x33, 0x33, 0x33, 0x33, 0x33}}, /*gxl*/ - {{0xae, 0x28, 0x00, 0xe9, 0xc6, 0x5c},{0xd8, 0x29, 0x00, 0xe9, 0xc6, 0x5c}}, /*lsk*/ - {{0x07, 0x13, 0x66, 0x22, 0x11, 0x11},{0x06, 0x13, 0x66, 0x22, 0x11, 0x11}}, /*yangguo*/ - {{0x02, 0x15, 0x66, 0x22, 0x11, 0x11},{0x01, 0x15, 0x66, 0x22, 0x11, 0x11}}, /*mql fpga*/ - + * customer addr config here + */ +ibrt_pairing_info_t g_ibrt_pairing_info[] = { + {{0x51, 0x33, 0x33, 0x22, 0x11, 0x11}, + {0x50, 0x33, 0x33, 0x22, 0x11, 0x11}}, + {{0x53, 0x33, 0x33, 0x22, 0x11, 0x11}, + {0x52, 0x33, 0x33, 0x22, 0x11, 0x11}}, /*LJH*/ + {{0x61, 0x33, 0x33, 0x22, 0x11, 0x11}, + {0x60, 0x33, 0x33, 0x22, 0x11, 0x11}}, + {{0x67, 0x66, 0x66, 0x22, 0x11, 0x11}, + {0x66, 0x66, 0x66, 0x22, 0x11, 0x11}}, /*bisto*/ + {{0x71, 0x33, 0x33, 0x22, 0x11, 0x11}, + {0x70, 0x33, 0x33, 0x22, 0x11, 0x11}}, + {{0x81, 0x33, 0x33, 0x22, 0x11, 0x11}, + {0x80, 0x33, 0x33, 0x22, 0x11, 0x11}}, + {{0x91, 0x33, 0x33, 0x22, 0x11, 0x11}, + {0x90, 0x33, 0x33, 0x22, 0x11, 0x11}}, /*Customer use*/ + {{0x05, 0x33, 0x33, 0x22, 0x11, 0x11}, + {0x04, 0x33, 0x33, 0x22, 0x11, 0x11}}, /*Rui*/ + {{0x07, 0x33, 0x33, 0x22, 0x11, 0x11}, + {0x06, 0x33, 0x33, 0x22, 0x11, 0x11}}, /*zsl*/ + {{0x88, 0xaa, 0x33, 0x22, 0x11, 0x11}, + {0x87, 0xaa, 0x33, 0x22, 0x11, 0x11}}, /*Lufang*/ + {{0x77, 0x22, 0x66, 0x22, 0x11, 0x11}, + {0x77, 0x33, 0x66, 0x22, 0x11, 0x11}}, /*xiao*/ + {{0xAA, 0x22, 0x66, 0x22, 0x11, 0x11}, + {0xBB, 0x33, 0x66, 0x22, 0x11, 0x11}}, /*LUOBIN*/ + {{0x08, 0x33, 0x66, 0x22, 0x11, 0x11}, + {0x07, 0x33, 0x66, 0x22, 0x11, 0x11}}, /*Yangbin1*/ + {{0x0B, 0x33, 0x66, 0x22, 0x11, 0x11}, + {0x0A, 0x33, 0x66, 0x22, 0x11, 0x11}}, /*Yangbin2*/ + {{0x35, 0x33, 0x66, 0x22, 0x11, 0x11}, + {0x34, 0x33, 0x66, 0x22, 0x11, 0x11}}, /*Lulu*/ + {{0xF8, 0x33, 0x66, 0x22, 0x11, 0x11}, + {0xF7, 0x33, 0x66, 0x22, 0x11, 0x11}}, /*jtx*/ + {{0xd3, 0x53, 0x86, 0x42, 0x71, 0x31}, + {0xd2, 0x53, 0x86, 0x42, 0x71, 0x31}}, /*shhx*/ + {{0xcc, 0xaa, 0x99, 0x88, 0x77, 0x66}, + {0xbb, 0xaa, 0x99, 0x88, 0x77, 0x66}}, /*mql*/ + {{0x95, 0x33, 0x69, 0x22, 0x11, 0x11}, + {0x94, 0x33, 0x69, 0x22, 0x11, 0x11}}, /*wyl*/ + {{0x82, 0x35, 0x68, 0x24, 0x19, 0x17}, + {0x81, 0x35, 0x68, 0x24, 0x19, 0x17}}, /*hy*/ + {{0x66, 0x66, 0x88, 0x66, 0x66, 0x88}, + {0x65, 0x66, 0x88, 0x66, 0x66, 0x88}}, /*xdl*/ + {{0x61, 0x66, 0x66, 0x66, 0x66, 0x81}, + {0x16, 0x66, 0x66, 0x66, 0x66, 0x18}}, /*test1*/ + {{0x62, 0x66, 0x66, 0x66, 0x66, 0x82}, + {0x26, 0x66, 0x66, 0x66, 0x66, 0x28}}, /*test2*/ + {{0x63, 0x66, 0x66, 0x66, 0x66, 0x83}, + {0x36, 0x66, 0x66, 0x66, 0x66, 0x38}}, /*test3*/ + {{0x64, 0x66, 0x66, 0x66, 0x66, 0x84}, + {0x46, 0x66, 0x66, 0x66, 0x66, 0x48}}, /*test4*/ + {{0x65, 0x66, 0x66, 0x66, 0x66, 0x85}, + {0x56, 0x66, 0x66, 0x66, 0x66, 0x58}}, /*test5*/ + {{0xaa, 0x66, 0x66, 0x66, 0x66, 0x86}, + {0xaa, 0x66, 0x66, 0x66, 0x66, 0x68}}, /*test6*/ + {{0x67, 0x66, 0x66, 0x66, 0x66, 0x87}, + {0x76, 0x66, 0x66, 0x66, 0x66, 0x78}}, /*test7*/ + {{0x68, 0x66, 0x66, 0x66, 0x66, 0xa8}, + {0x86, 0x66, 0x66, 0x66, 0x66, 0x8a}}, /*test8*/ + {{0x69, 0x66, 0x66, 0x66, 0x66, 0x89}, + {0x86, 0x66, 0x66, 0x66, 0x66, 0x18}}, /*test9*/ + {{0x93, 0x33, 0x33, 0x33, 0x33, 0x33}, + {0x92, 0x33, 0x33, 0x33, 0x33, 0x33}}, /*gxl*/ + {{0xae, 0x28, 0x00, 0xe9, 0xc6, 0x5c}, + {0xd8, 0x29, 0x00, 0xe9, 0xc6, 0x5c}}, /*lsk*/ + {{0x07, 0x13, 0x66, 0x22, 0x11, 0x11}, + {0x06, 0x13, 0x66, 0x22, 0x11, 0x11}}, /*yangguo*/ + {{0x02, 0x15, 0x66, 0x22, 0x11, 0x11}, + {0x01, 0x15, 0x66, 0x22, 0x11, 0x11}}, /*mql fpga*/ + }; // /******************************pwrkey_det_timer*********************************************************/ @@ -683,13 +659,14 @@ ibrt_pairing_info_t g_ibrt_pairing_info[] = // void pwrkey_detinit(void) // { // TRACE(3,"%s",__func__); -// pwrkey_detid = osTimerCreate(osTimer(defpwrkey_det),osTimerOnce,(void *)0); +// pwrkey_detid = osTimerCreate(osTimer(defpwrkey_det),osTimerOnce,(void +// *)0); // } -// extern void app_ibrt_customif_test1_cmd_send(uint8_t *p_buff, uint16_t length); -// static void pwrkey_detfun(const void *) +// extern void app_ibrt_customif_test1_cmd_send(uint8_t *p_buff, uint16_t +// length); static void pwrkey_detfun(const void *) // { - + // static ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); // static bool last_pwrkey = false; // bool curr_pwrkey_sta; @@ -705,17 +682,17 @@ ibrt_pairing_info_t g_ibrt_pairing_info[] = // app_voice_report(APP_STATUS_INDICATION_BOTHSCAN,0); // if (IBRT_SLAVE == p_ibrt_ctrl->current_role){ -// app_ibrt_customif_test1_cmd_send((uint8_t *)inear_status, sizeof(APP_KEY_STATUS)); -// }else{ -// a2dp_handleKey(AVRCP_KEY_PLAY); +// app_ibrt_customif_test1_cmd_send((uint8_t +// *)inear_status, sizeof(APP_KEY_STATUS)); }else{ +// a2dp_handleKey(AVRCP_KEY_PLAY); // } // }else{ // //app_bt_sleep(NULL,NULL); // TRACE(3,"%s PAUSE",__func__); // //a2dp_handleKey(AVRCP_KEY_PAUSE); // if (IBRT_SLAVE == p_ibrt_ctrl->current_role){ -// app_ibrt_customif_test1_cmd_send((uint8_t *)outear_status, sizeof(APP_KEY_STATUS)); -// }else{ +// app_ibrt_customif_test1_cmd_send((uint8_t +// *)outear_status, sizeof(APP_KEY_STATUS)); }else{ // a2dp_handleKey(AVRCP_KEY_PAUSE); // } // } @@ -736,78 +713,67 @@ ibrt_pairing_info_t g_ibrt_pairing_info[] = // osTimerStop(pwrkey_detid); // } - - /********************************pwrkey_det_timer*******************************************************/ -int app_ibrt_ui_test_config_load(void *config) -{ - ibrt_pairing_info_t *ibrt_pairing_info_lst = g_ibrt_pairing_info; - uint32_t lst_size = sizeof(g_ibrt_pairing_info)/sizeof(ibrt_pairing_info_t); - ibrt_config_t *ibrt_config = (ibrt_config_t *)config; - struct nvrecord_env_t *nvrecord_env; - uint8_t ble_address[6] = {0, 0, 0, 0, 0, 0}; +int app_ibrt_ui_test_config_load(void *config) { + ibrt_pairing_info_t *ibrt_pairing_info_lst = g_ibrt_pairing_info; + uint32_t lst_size = sizeof(g_ibrt_pairing_info) / sizeof(ibrt_pairing_info_t); + ibrt_config_t *ibrt_config = (ibrt_config_t *)config; + struct nvrecord_env_t *nvrecord_env; + uint8_t ble_address[6] = {0, 0, 0, 0, 0, 0}; - nv_record_env_get(&nvrecord_env); - if(nvrecord_env->ibrt_mode.tws_connect_success == 0) - { - app_ibrt_ui_clear_tws_connect_success_last(); - } - else - { - app_ibrt_ui_set_tws_connect_success_last(); - } + nv_record_env_get(&nvrecord_env); + if (nvrecord_env->ibrt_mode.tws_connect_success == 0) { + app_ibrt_ui_clear_tws_connect_success_last(); + } else { + app_ibrt_ui_set_tws_connect_success_last(); + } - if (memcmp(nv_record_tws_get_self_ble_info(), bt_get_ble_local_address(), BD_ADDR_LEN) && - memcmp(nv_record_tws_get_self_ble_info(), ble_address, BD_ADDR_LEN)) - { - nv_record_tws_exchange_ble_info(); - } + if (memcmp(nv_record_tws_get_self_ble_info(), bt_get_ble_local_address(), + BD_ADDR_LEN) && + memcmp(nv_record_tws_get_self_ble_info(), ble_address, BD_ADDR_LEN)) { + nv_record_tws_exchange_ble_info(); + } - factory_section_original_btaddr_get(ibrt_config->local_addr.address); - for(uint32_t i =0; ilocal_addr.address, BD_ADDR_LEN)) - { - ibrt_config->nv_role = IBRT_MASTER; - ibrt_config->audio_chnl_sel = AUDIO_CHANNEL_SELECT_RCHNL; - memcpy(ibrt_config->peer_addr.address, ibrt_pairing_info_lst[i].slave_bdaddr.address, BD_ADDR_LEN); - return 0; - } - else if (!memcmp(ibrt_pairing_info_lst[i].slave_bdaddr.address, ibrt_config->local_addr.address, BD_ADDR_LEN)) - { - ibrt_config->nv_role = IBRT_SLAVE; - ibrt_config->audio_chnl_sel = AUDIO_CHANNEL_SELECT_LCHNL; - memcpy(ibrt_config->peer_addr.address, ibrt_pairing_info_lst[i].master_bdaddr.address, BD_ADDR_LEN); - return 0; - } + factory_section_original_btaddr_get(ibrt_config->local_addr.address); + for (uint32_t i = 0; i < lst_size; i++) { + if (!memcmp(ibrt_pairing_info_lst[i].master_bdaddr.address, + ibrt_config->local_addr.address, BD_ADDR_LEN)) { + ibrt_config->nv_role = IBRT_MASTER; + ibrt_config->audio_chnl_sel = AUDIO_CHANNEL_SELECT_RCHNL; + memcpy(ibrt_config->peer_addr.address, + ibrt_pairing_info_lst[i].slave_bdaddr.address, BD_ADDR_LEN); + return 0; + } else if (!memcmp(ibrt_pairing_info_lst[i].slave_bdaddr.address, + ibrt_config->local_addr.address, BD_ADDR_LEN)) { + ibrt_config->nv_role = IBRT_SLAVE; + ibrt_config->audio_chnl_sel = AUDIO_CHANNEL_SELECT_LCHNL; + memcpy(ibrt_config->peer_addr.address, + ibrt_pairing_info_lst[i].master_bdaddr.address, BD_ADDR_LEN); + return 0; } - return -1; + } + return -1; } -void app_ibrt_ui_test_key_init(void) -{ - app_key_handle_clear(); - for (uint8_t i=0; i -#include "bt_if.h" -#include "app_tws_ibrt_trace.h" -#include "factory_section.h" -#include "apps.h" -#include "app_battery.h" -#include "app_anc.h" -#include "app_key.h" -#include "app_ibrt_if.h" -#include "app_ibrt_ui_test.h" -#include "app_ibrt_auto_test.h" -#include "app_ibrt_auto_test_cmd_handle.h" #include "app_ibrt_ui_test_cmd_if.h" -#include "app_ibrt_peripheral_manager.h" #include "a2dp_decoder.h" -#include "app_ibrt_keyboard.h" -#include "nvrecord_env.h" -#include "nvrecord_ble.h" -#include "norflash_api.h" -#include "me_api.h" -#include "app_tws_if.h" -#include "besbt.h" -#include "btapp.h" -#include "app_bt.h" #include "app_ai_if.h" #include "app_ai_manager_api.h" +#include "app_anc.h" +#include "app_battery.h" #include "app_ble_uart.h" +#include "app_bt.h" +#include "app_ibrt_auto_test.h" +#include "app_ibrt_auto_test_cmd_handle.h" +#include "app_ibrt_if.h" +#include "app_ibrt_keyboard.h" +#include "app_ibrt_peripheral_manager.h" +#include "app_ibrt_ui_test.h" +#include "app_key.h" +#include "app_tws_ibrt_trace.h" +#include "app_tws_if.h" +#include "apps.h" +#include "besbt.h" +#include "bt_if.h" +#include "btapp.h" +#include "factory_section.h" +#include "me_api.h" +#include "norflash_api.h" +#include "nvrecord_ble.h" +#include "nvrecord_env.h" +#include #if defined(BISTO_ENABLED) #include "gsound_custom_actions.h" -#include "gsound_custom_bt.h" #include "gsound_custom_ble.h" +#include "gsound_custom_bt.h" #endif #ifdef __IAG_BLE_INCLUDE__ @@ -60,99 +60,76 @@ static bt_bdaddr_t pts_bt_addr = {{ #if 0 0x14, 0x71, 0xda, 0x7d, 0x1a, 0x00 #else - 0x13, 0x71, 0xda, 0x7d, 0x1a, 0x00 + 0x13, 0x71, 0xda, 0x7d, 0x1a, 0x00 #endif - } -}; -void btif_pts_hf_create_link_with_pts(void) -{ - btif_pts_hf_create_service_link(&pts_bt_addr); +}}; +void btif_pts_hf_create_link_with_pts(void) { + btif_pts_hf_create_service_link(&pts_bt_addr); } -void btif_pts_av_create_channel_with_pts(void) -{ - btif_pts_av_create_channel(&pts_bt_addr); +void btif_pts_av_create_channel_with_pts(void) { + btif_pts_av_create_channel(&pts_bt_addr); } -void btif_pts_ar_connect_with_pts(void) -{ - btif_pts_ar_connect(&pts_bt_addr); +void btif_pts_ar_connect_with_pts(void) { btif_pts_ar_connect(&pts_bt_addr); } + +void app_ibrt_ui_audio_play_test(void) { + uint8_t action[] = {IBRT_ACTION_PLAY}; + app_ibrt_if_start_user_action(action, sizeof(action)); +} +void app_ibrt_ui_audio_pause_test(void) { + uint8_t action[] = {IBRT_ACTION_PAUSE}; + app_ibrt_if_start_user_action(action, sizeof(action)); +} +void app_ibrt_ui_audio_forward_test(void) { + uint8_t action[] = {IBRT_ACTION_FORWARD}; + app_ibrt_if_start_user_action(action, sizeof(action)); +} +void app_ibrt_ui_audio_backward_test(void) { + uint8_t action[] = {IBRT_ACTION_BACKWARD}; + app_ibrt_if_start_user_action(action, sizeof(action)); +} +void app_ibrt_ui_avrcp_volume_up_test(void) { + uint8_t action[] = {IBRT_ACTION_AVRCP_VOLUP}; + app_ibrt_if_start_user_action(action, sizeof(action)); +} +void app_ibrt_ui_avrcp_volume_down_test(void) { + uint8_t action[] = {IBRT_ACTION_AVRCP_VOLDN}; + app_ibrt_if_start_user_action(action, sizeof(action)); +} +void app_ibrt_ui_hfsco_create_test(void) { + uint8_t action[] = {IBRT_ACTION_HFSCO_CREATE}; + app_ibrt_if_start_user_action(action, sizeof(action)); +} +void app_ibrt_ui_hfsco_disc_test(void) { + uint8_t action[] = {IBRT_ACTION_HFSCO_DISC}; + app_ibrt_if_start_user_action(action, sizeof(action)); +} +void app_ibrt_ui_call_redial_test(void) { + uint8_t action[] = {IBRT_ACTION_REDIAL}; + app_ibrt_if_start_user_action(action, sizeof(action)); +} +void app_ibrt_ui_call_answer_test(void) { + uint8_t action[] = {IBRT_ACTION_ANSWER}; + app_ibrt_if_start_user_action(action, sizeof(action)); +} +void app_ibrt_ui_call_hangup_test(void) { + uint8_t action[] = {IBRT_ACTION_HANGUP}; + app_ibrt_if_start_user_action(action, sizeof(action)); +} +void app_ibrt_ui_local_volume_up_test(void) { + uint8_t action[] = {IBRT_ACTION_LOCAL_VOLUP}; + app_ibrt_if_start_user_action(action, sizeof(action)); +} +void app_ibrt_ui_local_volume_down_test(void) { + uint8_t action[] = {IBRT_ACTION_LOCAL_VOLDN}; + app_ibrt_if_start_user_action(action, sizeof(action)); } -void app_ibrt_ui_audio_play_test(void) -{ - uint8_t action[] = {IBRT_ACTION_PLAY}; - app_ibrt_if_start_user_action(action, sizeof(action)); -} -void app_ibrt_ui_audio_pause_test(void) -{ - uint8_t action[] = {IBRT_ACTION_PAUSE}; - app_ibrt_if_start_user_action(action, sizeof(action)); -} -void app_ibrt_ui_audio_forward_test(void) -{ - uint8_t action[] = {IBRT_ACTION_FORWARD}; - app_ibrt_if_start_user_action(action, sizeof(action)); -} -void app_ibrt_ui_audio_backward_test(void) -{ - uint8_t action[] = {IBRT_ACTION_BACKWARD}; - app_ibrt_if_start_user_action(action, sizeof(action)); -} -void app_ibrt_ui_avrcp_volume_up_test(void) -{ - uint8_t action[] = {IBRT_ACTION_AVRCP_VOLUP}; - app_ibrt_if_start_user_action(action, sizeof(action)); -} -void app_ibrt_ui_avrcp_volume_down_test(void) -{ - uint8_t action[] = {IBRT_ACTION_AVRCP_VOLDN}; - app_ibrt_if_start_user_action(action, sizeof(action)); -} -void app_ibrt_ui_hfsco_create_test(void) -{ - uint8_t action[] = {IBRT_ACTION_HFSCO_CREATE}; - app_ibrt_if_start_user_action(action, sizeof(action)); -} -void app_ibrt_ui_hfsco_disc_test(void) -{ - uint8_t action[] = {IBRT_ACTION_HFSCO_DISC}; - app_ibrt_if_start_user_action(action, sizeof(action)); -} -void app_ibrt_ui_call_redial_test(void) -{ - uint8_t action[] = {IBRT_ACTION_REDIAL}; - app_ibrt_if_start_user_action(action, sizeof(action)); -} -void app_ibrt_ui_call_answer_test(void) -{ - uint8_t action[] = {IBRT_ACTION_ANSWER}; - app_ibrt_if_start_user_action(action, sizeof(action)); -} -void app_ibrt_ui_call_hangup_test(void) -{ - uint8_t action[] = {IBRT_ACTION_HANGUP}; - app_ibrt_if_start_user_action(action, sizeof(action)); -} -void app_ibrt_ui_local_volume_up_test(void) -{ - uint8_t action[] = {IBRT_ACTION_LOCAL_VOLUP}; - app_ibrt_if_start_user_action(action, sizeof(action)); -} -void app_ibrt_ui_local_volume_down_test(void) -{ - uint8_t action[] = {IBRT_ACTION_LOCAL_VOLDN}; - app_ibrt_if_start_user_action(action, sizeof(action)); -} - -void app_ibrt_ui_get_tws_conn_state_test(void) -{ - if(app_tws_ibrt_tws_link_connected()) - { - TRACE(0,"ibrt_ui_log:TWS CONNECTED"); - } - else - { - TRACE(0,"ibrt_ui_log:TWS DISCONNECTED"); - } +void app_ibrt_ui_get_tws_conn_state_test(void) { + if (app_tws_ibrt_tws_link_connected()) { + TRACE(0, "ibrt_ui_log:TWS CONNECTED"); + } else { + TRACE(0, "ibrt_ui_log:TWS DISCONNECTED"); + } } /***************************************************************************** @@ -170,99 +147,75 @@ void app_ibrt_ui_get_tws_conn_state_test(void) Modification : Created function *****************************************************************************/ -void app_ibrt_ui_soft_reset_test(void) -{ - app_reset(); -} - +void app_ibrt_ui_soft_reset_test(void) { app_reset(); } extern void bt_change_to_iic(APP_KEY_STATUS *status, void *param); -void app_ibrt_ui_iic_uart_switch_test(void) -{ - bt_change_to_iic(NULL,NULL); +void app_ibrt_ui_iic_uart_switch_test(void) { bt_change_to_iic(NULL, NULL); } + +void app_ibrt_ui_get_a2dp_state_test(void) { + const char *a2dp_state_strings[] = { + "IDLE", "CODEC_CONFIGURED", "OPEN", "STREAMING", "CLOSED", "ABORTING"}; + AppIbrtA2dpState a2dp_state; + + AppIbrtStatus status = app_ibrt_if_get_a2dp_state(&a2dp_state); + if (APP_IBRT_IF_STATUS_SUCCESS == status) { + TRACE(0, "ibrt_ui_log:a2dp_state=%s", a2dp_state_strings[a2dp_state]); + } else { + TRACE(0, "ibrt_ui_log:get a2dp state error"); + } } -void app_ibrt_ui_get_a2dp_state_test(void) -{ - const char* a2dp_state_strings[] = {"IDLE", "CODEC_CONFIGURED", "OPEN","STREAMING","CLOSED","ABORTING"}; - AppIbrtA2dpState a2dp_state; +void app_ibrt_ui_get_avrcp_state_test(void) { + const char *avrcp_state_strings[] = {"DISCONNECTED", "CONNECTED", "PLAYING", + "PAUSED", "VOLUME_UPDATED"}; + AppIbrtAvrcpState avrcp_state; - AppIbrtStatus status = app_ibrt_if_get_a2dp_state(&a2dp_state); - if(APP_IBRT_IF_STATUS_SUCCESS == status) - { - TRACE(0,"ibrt_ui_log:a2dp_state=%s",a2dp_state_strings[a2dp_state]); - } - else - { - TRACE(0,"ibrt_ui_log:get a2dp state error"); - } + AppIbrtStatus status = app_ibrt_if_get_avrcp_state(&avrcp_state); + if (APP_IBRT_IF_STATUS_SUCCESS == status) { + TRACE(0, "ibrt_ui_log:avrcp_state=%s", avrcp_state_strings[avrcp_state]); + } else { + TRACE(0, "ibrt_ui_log:get avrcp state error"); + } } -void app_ibrt_ui_get_avrcp_state_test(void) -{ - const char* avrcp_state_strings[] = {"DISCONNECTED", "CONNECTED", "PLAYING","PAUSED", "VOLUME_UPDATED"}; - AppIbrtAvrcpState avrcp_state; +void app_ibrt_ui_get_hfp_state_test(void) { + const char *hfp_state_strings[] = { + "SLC_DISCONNECTED", "CLOSED", "SCO_CLOSED", "PENDING", + "SLC_OPEN", "NEGOTIATE", "CODEC_CONFIGURED", "SCO_OPEN", + "INCOMING_CALL", "OUTGOING_CALL", "RING_INDICATION"}; + AppIbrtHfpState hfp_state; + AppIbrtStatus status = app_ibrt_if_get_hfp_state(&hfp_state); - AppIbrtStatus status = app_ibrt_if_get_avrcp_state(&avrcp_state); - if(APP_IBRT_IF_STATUS_SUCCESS == status) - { - TRACE(0,"ibrt_ui_log:avrcp_state=%s",avrcp_state_strings[avrcp_state]); - } - else - { - TRACE(0,"ibrt_ui_log:get avrcp state error"); - } + if (APP_IBRT_IF_STATUS_SUCCESS == status) { + TRACE(0, "ibrt_ui_log:hfp_state=%s", hfp_state_strings[hfp_state]); + } else { + TRACE(0, "ibrt_ui_log:get hfp state error"); + } } -void app_ibrt_ui_get_hfp_state_test(void) -{ - const char* hfp_state_strings[] = {"SLC_DISCONNECTED", "CLOSED", "SCO_CLOSED","PENDING","SLC_OPEN", \ - "NEGOTIATE","CODEC_CONFIGURED","SCO_OPEN","INCOMING_CALL","OUTGOING_CALL","RING_INDICATION"}; - AppIbrtHfpState hfp_state; - AppIbrtStatus status = app_ibrt_if_get_hfp_state(&hfp_state); +void app_ibrt_ui_get_call_status_test() { + const char *call_status_strings[] = {"NO_CALL", "CALL_ACTIVE", "HOLD", + "INCOMMING", "OUTGOING", "ALERT"}; + AppIbrtCallStatus call_status; - if(APP_IBRT_IF_STATUS_SUCCESS == status) - { - TRACE(0,"ibrt_ui_log:hfp_state=%s",hfp_state_strings[hfp_state]); - } - else - { - TRACE(0,"ibrt_ui_log:get hfp state error"); - } + AppIbrtStatus status = app_ibrt_if_get_hfp_call_status(&call_status); + if (APP_IBRT_IF_STATUS_SUCCESS == status) { + TRACE(0, "ibrt_ui_log:call_status=%s", call_status_strings[call_status]); + } else { + TRACE(0, "ibrt_ui_log:get call status error"); + } } -void app_ibrt_ui_get_call_status_test() -{ - const char* call_status_strings[] = {"NO_CALL","CALL_ACTIVE","HOLD","INCOMMING","OUTGOING","ALERT"}; - AppIbrtCallStatus call_status; +void app_ibrt_ui_get_ibrt_role_test(void) { + ibrt_role_e role = app_ibrt_if_get_ibrt_role(); - AppIbrtStatus status = app_ibrt_if_get_hfp_call_status(&call_status); - if(APP_IBRT_IF_STATUS_SUCCESS == status) - { - TRACE(0,"ibrt_ui_log:call_status=%s",call_status_strings[call_status]); - } - else - { - TRACE(0,"ibrt_ui_log:get call status error"); - } -} - -void app_ibrt_ui_get_ibrt_role_test(void) -{ - ibrt_role_e role = app_ibrt_if_get_ibrt_role(); - - if(IBRT_MASTER == role) - { - TRACE(0,"ibrt_ui_log:ibrt role is MASTER"); - } - else if(IBRT_SLAVE == role) - { - TRACE(0,"ibrt_ui_log:ibrt role is SLAVE"); - } - else - { - TRACE(0,"ibrt_ui_log:ibrt role is UNKNOW"); - } + if (IBRT_MASTER == role) { + TRACE(0, "ibrt_ui_log:ibrt role is MASTER"); + } else if (IBRT_SLAVE == role) { + TRACE(0, "ibrt_ui_log:ibrt role is SLAVE"); + } else { + TRACE(0, "ibrt_ui_log:ibrt role is UNKNOW"); + } } /***************************************************************************** @@ -280,9 +233,8 @@ void app_ibrt_ui_get_ibrt_role_test(void) Modification : Created function *****************************************************************************/ -void app_ibrt_ui_open_box_event_test(void) -{ - app_ibrt_if_event_entry(IBRT_OPEN_BOX_EVENT); +void app_ibrt_ui_open_box_event_test(void) { + app_ibrt_if_event_entry(IBRT_OPEN_BOX_EVENT); } /***************************************************************************** Prototype : app_ibrt_ui_fetch_out_box_event_test @@ -299,9 +251,8 @@ void app_ibrt_ui_open_box_event_test(void) Modification : Created function *****************************************************************************/ -void app_ibrt_ui_fetch_out_box_event_test(void) -{ - app_ibrt_if_event_entry(IBRT_FETCH_OUT_EVENT); +void app_ibrt_ui_fetch_out_box_event_test(void) { + app_ibrt_if_event_entry(IBRT_FETCH_OUT_EVENT); } /***************************************************************************** Prototype : app_ibrt_ui_put_in_box_event_test @@ -318,9 +269,8 @@ void app_ibrt_ui_fetch_out_box_event_test(void) Modification : Created function *****************************************************************************/ -void app_ibrt_ui_put_in_box_event_test(void) -{ - app_ibrt_if_event_entry(IBRT_PUT_IN_EVENT); +void app_ibrt_ui_put_in_box_event_test(void) { + app_ibrt_if_event_entry(IBRT_PUT_IN_EVENT); } /***************************************************************************** Prototype : app_ibrt_ui_close_box_event_test @@ -337,9 +287,8 @@ void app_ibrt_ui_put_in_box_event_test(void) Modification : Created function *****************************************************************************/ -void app_ibrt_ui_close_box_event_test(void) -{ - app_ibrt_if_event_entry(IBRT_CLOSE_BOX_EVENT); +void app_ibrt_ui_close_box_event_test(void) { + app_ibrt_if_event_entry(IBRT_CLOSE_BOX_EVENT); } /***************************************************************************** Prototype : app_ibrt_ui_reconnect_event_test @@ -356,9 +305,8 @@ void app_ibrt_ui_close_box_event_test(void) Modification : Created function *****************************************************************************/ -void app_ibrt_ui_reconnect_event_test(void) -{ - app_ibrt_if_event_entry(IBRT_RECONNECT_EVENT); +void app_ibrt_ui_reconnect_event_test(void) { + app_ibrt_if_event_entry(IBRT_RECONNECT_EVENT); } /***************************************************************************** Prototype : app_ibrt_ui_ware_up_event_test @@ -375,9 +323,8 @@ void app_ibrt_ui_reconnect_event_test(void) Modification : Created function *****************************************************************************/ -void app_ibrt_ui_ware_up_event_test(void) -{ - app_ibrt_if_event_entry(IBRT_WEAR_UP_EVENT); +void app_ibrt_ui_ware_up_event_test(void) { + app_ibrt_if_event_entry(IBRT_WEAR_UP_EVENT); } /***************************************************************************** Prototype : app_ibrt_ui_ware_down_event_test @@ -394,9 +341,8 @@ void app_ibrt_ui_ware_up_event_test(void) Modification : Created function *****************************************************************************/ -void app_ibrt_ui_ware_down_event_test(void) -{ - app_ibrt_if_event_entry(IBRT_WEAR_DOWN_EVENT); +void app_ibrt_ui_ware_down_event_test(void) { + app_ibrt_if_event_entry(IBRT_WEAR_DOWN_EVENT); } /***************************************************************************** Prototype : app_ibrt_ui_phone_connect_event_test @@ -413,9 +359,8 @@ void app_ibrt_ui_ware_down_event_test(void) Modification : Created function *****************************************************************************/ -void app_ibrt_ui_phone_connect_event_test(void) -{ - app_ibrt_if_event_entry(IBRT_PHONE_CONNECT_EVENT); +void app_ibrt_ui_phone_connect_event_test(void) { + app_ibrt_if_event_entry(IBRT_PHONE_CONNECT_EVENT); } /***************************************************************************** Prototype : app_ibrt_ui_shut_down_test @@ -433,10 +378,9 @@ void app_ibrt_ui_phone_connect_event_test(void) *****************************************************************************/ extern "C" int app_shutdown(void); -void app_ibrt_ui_shut_down_test(void) -{ - app_ibrt_peripheral_auto_test_stop(); - app_shutdown(); +void app_ibrt_ui_shut_down_test(void) { + app_ibrt_peripheral_auto_test_stop(); + app_shutdown(); } /***************************************************************************** @@ -455,10 +399,7 @@ void app_ibrt_ui_shut_down_test(void) *****************************************************************************/ extern void bt_enable_tports(void); -void app_ibrt_enable_tports_test(void) -{ - bt_enable_tports(); -} +void app_ibrt_enable_tports_test(void) { bt_enable_tports(); } /***************************************************************************** Prototype : app_ibrt_ui_tws_swtich_test Description : tws switch test @@ -472,115 +413,96 @@ void app_ibrt_enable_tports_test(void) Date : 2019/4/10 Author : bestechnic Modification : Created function - - *****************************************************************************/ - void app_ibrt_ui_tws_swtich_test(void) - { - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - - if (p_ibrt_ctrl->current_role == IBRT_MASTER) - { - btif_me_ibrt_role_switch(p_ibrt_ctrl->mobile_conhandle); - } - else - { - TRACE(0,"ibrt_ui_log:local role is ibrt_slave, pls send tws switch in another dev"); - } - } - - /***************************************************************************** - Prototype : app_ibrt_ui_suspend_ibrt_test - Description : suspend ibrt fastack - Input : void - Output : None - Return Value : - Calls : - Called By : - - History : - Date : 2019/4/24 - Author : bestechnic - Modification : Created function - - *****************************************************************************/ - void app_ibrt_ui_suspend_ibrt_test(void) - { - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - - if (p_ibrt_ctrl->current_role== IBRT_MASTER) - { - btif_me_suspend_ibrt(); - } - else - { - TRACE(0,"ibrt_ui_log:local role is ibrt_slave, suspend ibrt failed"); - } - } - /***************************************************************************** - Prototype : app_ibrt_ui_resume_ibrt_test - Description : resume ibrt test - Input : void - Output : None - Return Value : - Calls : - Called By : - - History : - Date : 2019/4/27 - Author : bestechnic - Modification : Created function - - *****************************************************************************/ - void app_ibrt_ui_resume_ibrt_test(void) - { - btif_me_resume_ibrt(1); - } - /***************************************************************************** - Prototype : app_ibrt_ui_pairing_mode_test - Description : pairing mode test - Input : void - Output : None - Return Value : - Calls : - Called By : - - History : - Date : 2019/11/20 - Author : bestechnic - Modification : Created function - - *****************************************************************************/ - void app_ibrt_ui_pairing_mode_test(void) - { - app_ibrt_ui_event_entry(IBRT_TWS_PAIRING_EVENT); - } - /***************************************************************************** - Prototype : app_ibrt_ui_freeman_pairing_mode_test - Description : ibrt freeman pairing mode test - Input : void - Output : None - Return Value : - Calls : - Called By : - - History : - Date : 2019/11/21 - Author : bestechnic - Modification : Created function - - *****************************************************************************/ - void app_ibrt_ui_freeman_pairing_mode_test(void) - { - app_ibrt_ui_event_entry(IBRT_FREEMAN_PAIRING_EVENT); - } - - void app_ibrt_inquiry_start_test(void) - { - app_bt_start_search(); - } -void app_ibrt_role_switch_test(void) -{ - app_tws_if_trigger_role_switch(); + *****************************************************************************/ +void app_ibrt_ui_tws_swtich_test(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + + if (p_ibrt_ctrl->current_role == IBRT_MASTER) { + btif_me_ibrt_role_switch(p_ibrt_ctrl->mobile_conhandle); + } else { + TRACE(0, "ibrt_ui_log:local role is ibrt_slave, pls send tws switch in " + "another dev"); + } } +/***************************************************************************** + Prototype : app_ibrt_ui_suspend_ibrt_test + Description : suspend ibrt fastack + Input : void + Output : None + Return Value : + Calls : + Called By : + + History : + Date : 2019/4/24 + Author : bestechnic + Modification : Created function + +*****************************************************************************/ +void app_ibrt_ui_suspend_ibrt_test(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + + if (p_ibrt_ctrl->current_role == IBRT_MASTER) { + btif_me_suspend_ibrt(); + } else { + TRACE(0, "ibrt_ui_log:local role is ibrt_slave, suspend ibrt failed"); + } +} +/***************************************************************************** + Prototype : app_ibrt_ui_resume_ibrt_test + Description : resume ibrt test + Input : void + Output : None + Return Value : + Calls : + Called By : + + History : + Date : 2019/4/27 + Author : bestechnic + Modification : Created function + +*****************************************************************************/ +void app_ibrt_ui_resume_ibrt_test(void) { btif_me_resume_ibrt(1); } +/***************************************************************************** + Prototype : app_ibrt_ui_pairing_mode_test + Description : pairing mode test + Input : void + Output : None + Return Value : + Calls : + Called By : + + History : + Date : 2019/11/20 + Author : bestechnic + Modification : Created function + +*****************************************************************************/ +void app_ibrt_ui_pairing_mode_test(void) { + app_ibrt_ui_event_entry(IBRT_TWS_PAIRING_EVENT); +} +/***************************************************************************** + Prototype : app_ibrt_ui_freeman_pairing_mode_test + Description : ibrt freeman pairing mode test + Input : void + Output : None + Return Value : + Calls : + Called By : + + History : + Date : 2019/11/21 + Author : bestechnic + Modification : Created function + +*****************************************************************************/ +void app_ibrt_ui_freeman_pairing_mode_test(void) { + app_ibrt_ui_event_entry(IBRT_FREEMAN_PAIRING_EVENT); +} + +void app_ibrt_inquiry_start_test(void) { app_bt_start_search(); } + +void app_ibrt_role_switch_test(void) { app_tws_if_trigger_role_switch(); } diff --git a/services/app_ibrt/src/app_ibrt_voice_report.cpp b/services/app_ibrt/src/app_ibrt_voice_report.cpp index 3a07378..c8543f7 100644 --- a/services/app_ibrt/src/app_ibrt_voice_report.cpp +++ b/services/app_ibrt/src/app_ibrt_voice_report.cpp @@ -13,20 +13,20 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "cmsis_os.h" -#include -#include "me_api.h" -#include "app_tws_ibrt_trace.h" -#include "audioflinger.h" -#include "app_bt_stream.h" -#include "app_media_player.h" -#include "app_bt_media_manager.h" -#include "bt_drv_interface.h" -#include "app_ibrt_if.h" -#include "app_tws_ibrt_cmd_handler.h" -#include "app_tws_ctrl_thread.h" #include "app_ibrt_voice_report.h" #include "app_bt.h" +#include "app_bt_media_manager.h" +#include "app_bt_stream.h" +#include "app_ibrt_if.h" +#include "app_media_player.h" +#include "app_tws_ctrl_thread.h" +#include "app_tws_ibrt_cmd_handler.h" +#include "app_tws_ibrt_trace.h" +#include "audioflinger.h" +#include "bt_drv_interface.h" +#include "cmsis_os.h" +#include "me_api.h" +#include #ifdef TWS_PROMPT_SYNC #include "audio_prompt_sbc.h" #endif @@ -36,476 +36,441 @@ extern uint8_t g_findme_fadein_vol; typedef uint8_t voice_report_role_t; -#define VOICE_REPORT_MASTER 0x00 -#define VOICE_REPORT_SLAVE 0x01 -#define VOICE_REPORT_LOCAL 0x02 +#define VOICE_REPORT_MASTER 0x00 +#define VOICE_REPORT_SLAVE 0x01 +#define VOICE_REPORT_LOCAL 0x02 - -#define APP_PLAY_AUDIO_SYNC_DELAY_US (250*1000) -#define APP_PLAY_AUDIO_SYNC_TRIGGER_TIMEROUT (APP_PLAY_AUDIO_SYNC_DELAY_US/1000*2) +#define APP_PLAY_AUDIO_SYNC_DELAY_US (250 * 1000) +#define APP_PLAY_AUDIO_SYNC_TRIGGER_TIMEROUT \ + (APP_PLAY_AUDIO_SYNC_DELAY_US / 1000 * 2) static uint32_t app_ibrt_voice_tg_tick = 0; static uint32_t app_ibrt_voice_trigger_enable = 0; static void app_ibrt_voice_report_trigger_timeout_cb(void const *n); -osTimerDef(APP_IBRT_VOICE_REPORT_TRIGGER_TIMEOUT, app_ibrt_voice_report_trigger_timeout_cb); +osTimerDef(APP_IBRT_VOICE_REPORT_TRIGGER_TIMEOUT, + app_ibrt_voice_report_trigger_timeout_cb); osTimerId app_ibrt_voice_report_trigger_timeout_id = NULL; -static void app_ibrt_voice_report_trigger_timeout_cb(void const *n) -{ - TRACE_VOICE_RPT_D("[TRIG][TIMEOUT]"); - app_play_audio_stop(); +static void app_ibrt_voice_report_trigger_timeout_cb(void const *n) { + TRACE_VOICE_RPT_D("[TRIG][TIMEOUT]"); + app_play_audio_stop(); } -static int app_ibrt_voice_report_trigger_checker_init(void) -{ - if (app_ibrt_voice_report_trigger_timeout_id == NULL){ - app_ibrt_voice_report_trigger_timeout_id = osTimerCreate(osTimer(APP_IBRT_VOICE_REPORT_TRIGGER_TIMEOUT), osTimerOnce, NULL); - } +static int app_ibrt_voice_report_trigger_checker_init(void) { + if (app_ibrt_voice_report_trigger_timeout_id == NULL) { + app_ibrt_voice_report_trigger_timeout_id = osTimerCreate( + osTimer(APP_IBRT_VOICE_REPORT_TRIGGER_TIMEOUT), osTimerOnce, NULL); + } + return 0; +} + +static int app_ibrt_voice_report_trigger_checker_start(void) { + app_ibrt_voice_trigger_enable = true; + osTimerStart(app_ibrt_voice_report_trigger_timeout_id, + APP_PLAY_AUDIO_SYNC_TRIGGER_TIMEROUT); + return 0; +} + +static int app_ibrt_voice_report_trigger_checker_stop(void) { + app_ibrt_voice_trigger_enable = false; + osTimerStop(app_ibrt_voice_report_trigger_timeout_id); + return 0; +} + +int app_ibrt_voice_report_trigger_checker(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + + if (!p_ibrt_ctrl->init_done) { return 0; -} + } -static int app_ibrt_voice_report_trigger_checker_start(void) -{ - app_ibrt_voice_trigger_enable = true; - osTimerStart(app_ibrt_voice_report_trigger_timeout_id, APP_PLAY_AUDIO_SYNC_TRIGGER_TIMEROUT); - return 0; -} - -static int app_ibrt_voice_report_trigger_checker_stop(void) -{ + if (app_ibrt_voice_trigger_enable) { + TRACE_VOICE_RPT_I("[TRIG][OK]"); app_ibrt_voice_trigger_enable = false; osTimerStop(app_ibrt_voice_report_trigger_timeout_id); - return 0; + } + return 0; } -int app_ibrt_voice_report_trigger_checker(void) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - - if (!p_ibrt_ctrl->init_done){ - return 0; +voice_report_role_t app_ibrt_voice_report_get_role(void) { + voice_report_role_t report_role = VOICE_REPORT_LOCAL; + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (app_ibrt_ui_is_profile_exchanged()) { + if (app_tws_ibrt_mobile_link_connected()) { + report_role = VOICE_REPORT_MASTER; + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + report_role = VOICE_REPORT_SLAVE; + } else { + TRACE_VOICE_RPT_I("[GET_ROLE] skip it (profile_exchanged)"); + } + } else if (app_tws_ibrt_tws_link_connected()) { + if (app_tws_ibrt_mobile_link_connected()) { + report_role = VOICE_REPORT_MASTER; + } else if (p_ibrt_ctrl->current_role == IBRT_MASTER) { + report_role = VOICE_REPORT_MASTER; + } else { + report_role = VOICE_REPORT_SLAVE; } - if (app_ibrt_voice_trigger_enable){ - TRACE_VOICE_RPT_I("[TRIG][OK]"); - app_ibrt_voice_trigger_enable = false; - osTimerStop(app_ibrt_voice_report_trigger_timeout_id); - } - return 0; + } else { + TRACE_VOICE_RPT_I("[GET_ROLE] loc only"); + } + + TRACE_VOICE_RPT_I("[GET_ROLE] report_role: %d", report_role); + return report_role; } -voice_report_role_t app_ibrt_voice_report_get_role(void) -{ - voice_report_role_t report_role = VOICE_REPORT_LOCAL; - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (app_ibrt_ui_is_profile_exchanged()){ - if (app_tws_ibrt_mobile_link_connected()){ - report_role = VOICE_REPORT_MASTER; - }else if (app_tws_ibrt_slave_ibrt_link_connected()){ - report_role = VOICE_REPORT_SLAVE; - }else{ - TRACE_VOICE_RPT_I("[GET_ROLE] skip it (profile_exchanged)"); - } - }else if (app_tws_ibrt_tws_link_connected()){ - if (app_tws_ibrt_mobile_link_connected()){ - report_role = VOICE_REPORT_MASTER; - }else if(p_ibrt_ctrl->current_role == IBRT_MASTER){ - report_role = VOICE_REPORT_MASTER; - }else{ - report_role = VOICE_REPORT_SLAVE; - } - - }else{ - TRACE_VOICE_RPT_I("[GET_ROLE] loc only"); - } - - TRACE_VOICE_RPT_I("[GET_ROLE] report_role: %d", report_role); - return report_role; -} - -static void app_ibrt_voice_report_set_trigger_time(uint32_t tg_tick) -{ - if (tg_tick){ - ibrt_ctrl_t *p_ibrt_ctrl = app_ibrt_if_get_bt_ctrl_ctx(); - btif_connection_role_t connection_role = app_tws_ibrt_get_local_tws_role(); - btdrv_syn_trigger_codec_en(0); - btdrv_syn_clr_trigger(); - btdrv_enable_playback_triggler(ACL_TRIGGLE_MODE); - if (connection_role == BTIF_BCR_MASTER){ - bt_syn_set_tg_ticks(tg_tick, p_ibrt_ctrl->tws_conhandle, BT_TRIG_MASTER_ROLE); - }else if (connection_role == BTIF_BCR_SLAVE){ - bt_syn_set_tg_ticks(tg_tick, p_ibrt_ctrl->tws_conhandle, BT_TRIG_SLAVE_ROLE); - } - btdrv_syn_trigger_codec_en(1); - app_ibrt_voice_report_trigger_checker_start(); - TRACE_VOICE_RPT_I("[TRIG] set trigger tg_tick:%08x", tg_tick); - }else{ - btdrv_syn_trigger_codec_en(0); - btdrv_syn_clr_trigger(); - app_ibrt_voice_report_trigger_checker_stop(); - TRACE_VOICE_RPT_I("[TRIG] trigger clear"); - } -} - -int app_ibrt_voice_report_trigger_init(uint32_t aud_id, uint32_t aud_pram) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - - if (!p_ibrt_ctrl->init_done){ - TRACE_VOICE_RPT_I("ibrt not init done."); - return 0; - } - - app_ibrt_voice_report_trigger_checker_init(); - if (app_tws_ibrt_tws_link_connected()){ - ibrt_ctrl_t *p_ibrt_ctrl = app_ibrt_if_get_bt_ctrl_ctx(); - voice_report_role_t report_role = app_ibrt_voice_report_get_role(); - uint32_t curr_ticks = 0; - uint32_t tg_tick = 0; - app_ibrt_voice_report_trigger_deinit(); - - curr_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->tws_conhandle); - - if (report_role == VOICE_REPORT_MASTER){ - app_ibrt_voice_report_info_t voice_report_info; - - tg_tick = curr_ticks + US_TO_BTCLKS(APP_PLAY_AUDIO_SYNC_DELAY_US); -#ifdef PLAYBACK_USE_I2S - af_i2s_sync_config(AUD_STREAM_PLAYBACK, AF_I2S_SYNC_TYPE_BT, false); - af_i2s_sync_config(AUD_STREAM_PLAYBACK, AF_I2S_SYNC_TYPE_BT, true); -#else - af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, false); - af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, true); -#endif - app_ibrt_voice_report_set_trigger_time(tg_tick); - voice_report_info.aud_id = aud_id; - voice_report_info.aud_pram = aud_pram; - voice_report_info.tg_tick = tg_tick; -#ifdef __INTERACTION__ - voice_report_info.vol = g_findme_fadein_vol; -#endif - if (p_ibrt_ctrl->tws_mode == IBRT_SNIFF_MODE) - { - TRACE_VOICE_RPT_I("[TRIG][INIT][EXIT_SNIFF] force_exit_with_tws\n"); - app_tws_ibrt_exit_sniff_with_tws(); - } - tws_ctrl_send_cmd(APP_TWS_CMD_VOICE_REPORT_START, (uint8_t *)&voice_report_info, sizeof(app_ibrt_voice_report_info_t)); - TRACE_VOICE_RPT_I("[TRIG][INIT] MASTER aud_id:%d trigger [%08x]-->[%08x]", aud_id, bt_syn_get_curr_ticks(p_ibrt_ctrl->tws_conhandle), tg_tick); - }else if (report_role == VOICE_REPORT_SLAVE){ - tg_tick = app_ibrt_voice_tg_tick; - if (curr_ticks < tg_tick && tg_tick != 0) - { -#ifdef PLAYBACK_USE_I2S - af_i2s_sync_config(AUD_STREAM_PLAYBACK, AF_I2S_SYNC_TYPE_BT, false); - af_i2s_sync_config(AUD_STREAM_PLAYBACK, AF_I2S_SYNC_TYPE_BT, true); -#else - af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, false); - af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, true); -#endif - app_ibrt_voice_report_set_trigger_time(tg_tick); - } - app_ibrt_voice_tg_tick = 0; - if (tg_tick <= curr_ticks) - { - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_CLOSE, 0); - TRACE_VOICE_RPT_I("[TRIG][INIT] Prompt TRIGGER ERROR !!!"); - } - - TRACE_VOICE_RPT_I("[TRIG][INIT] SLAVE aud_id:%d trigger [%08x]-->[%08x]", aud_id, bt_syn_get_curr_ticks(p_ibrt_ctrl->tws_conhandle), tg_tick); - } - } - else - { - TRACE_VOICE_RPT_I("[TRIG][INIT] tws not connected."); - } - - return 0; -} - -int app_ibrt_voice_report_trigger_deinit(void) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - - if (!p_ibrt_ctrl->init_done){ - return 0; - } - -#ifdef PLAYBACK_USE_I2S - af_i2s_sync_config(AUD_STREAM_PLAYBACK, AF_I2S_SYNC_TYPE_BT, false); -#else - af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, false); -#endif - app_ibrt_voice_report_set_trigger_time(0); - - return 0; -} - -int app_ibrt_if_voice_report_filter(uint32_t aud_id) -{ - int nRet = 0; +static void app_ibrt_voice_report_set_trigger_time(uint32_t tg_tick) { + if (tg_tick) { ibrt_ctrl_t *p_ibrt_ctrl = app_ibrt_if_get_bt_ctrl_ctx(); - - switch (aud_id){ - case AUD_ID_BT_PAIRING_SUC: - nRet = 1; - break; - default: - break; + btif_connection_role_t connection_role = app_tws_ibrt_get_local_tws_role(); + btdrv_syn_trigger_codec_en(0); + btdrv_syn_clr_trigger(); + btdrv_enable_playback_triggler(ACL_TRIGGLE_MODE); + if (connection_role == BTIF_BCR_MASTER) { + bt_syn_set_tg_ticks(tg_tick, p_ibrt_ctrl->tws_conhandle, + BT_TRIG_MASTER_ROLE); + } else if (connection_role == BTIF_BCR_SLAVE) { + bt_syn_set_tg_ticks(tg_tick, p_ibrt_ctrl->tws_conhandle, + BT_TRIG_SLAVE_ROLE); } - - if (app_tws_ibrt_slave_ibrt_link_connected()){ - switch (aud_id){ - case AUD_ID_BT_CALL_INCOMING_CALL: - case AUD_ID_BT_CALL_INCOMING_NUMBER: - case AUD_ID_BT_CALL_OVER: - case AUD_ID_BT_CALL_ANSWER: - case AUD_ID_BT_CONNECTED: - case AUD_ID_BT_CALL_HUNG_UP: - case AUD_ID_BT_CALL_REFUSE: - nRet = 1; - break; - default: - break; - } - } - - if (!app_tws_ibrt_slave_ibrt_link_connected() && - !app_tws_ibrt_mobile_link_connected()){ - if (p_ibrt_ctrl->nv_role == IBRT_SLAVE){ - switch (aud_id){ - case AUD_ID_BT_CONNECTED: - nRet = 1; - break; - default: - break; - } - } - } - - return nRet; + btdrv_syn_trigger_codec_en(1); + app_ibrt_voice_report_trigger_checker_start(); + TRACE_VOICE_RPT_I("[TRIG] set trigger tg_tick:%08x", tg_tick); + } else { + btdrv_syn_trigger_codec_en(0); + btdrv_syn_clr_trigger(); + app_ibrt_voice_report_trigger_checker_stop(); + TRACE_VOICE_RPT_I("[TRIG] trigger clear"); + } } -int app_ibrt_if_voice_report_local_only(uint32_t aud_id) -{ - int nRet = 0; +int app_ibrt_voice_report_trigger_init(uint32_t aud_id, uint32_t aud_pram) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - switch (aud_id){ - default: - break; - } - - return nRet; -} - -int app_ibrt_if_voice_report_force_audio_retrigger_hander(uint32_t msg_id, uint32_t aud_id) -{ - if (msg_id == APP_BT_STREAM_MANAGER_STOP_MEDIA){ - if (aud_id == AUDIO_ID_BT_MUTE){ - TRACE_VOICE_RPT_I("[ID_BT_MUTE]"); -#ifdef MEDIA_PLAYER_SUPPORT - trigger_media_play((AUD_ID_ENUM)aud_id, 0, PROMOT_ID_BIT_MASK_CHNLSEl_ALL); -#endif - } - } + if (!p_ibrt_ctrl->init_done) { + TRACE_VOICE_RPT_I("ibrt not init done."); return 0; -} + } -static int app_ibrt_if_voice_report_init(uint32_t aud_id, uint16_t aud_pram, uint8_t init_play) -{ -#ifdef MEDIA_PLAYER_SUPPORT + app_ibrt_voice_report_trigger_checker_init(); + if (app_tws_ibrt_tws_link_connected()) { + ibrt_ctrl_t *p_ibrt_ctrl = app_ibrt_if_get_bt_ctrl_ctx(); + voice_report_role_t report_role = app_ibrt_voice_report_get_role(); + uint32_t curr_ticks = 0; + uint32_t tg_tick = 0; + app_ibrt_voice_report_trigger_deinit(); + curr_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->tws_conhandle); - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (report_role == VOICE_REPORT_MASTER) { + app_ibrt_voice_report_info_t voice_report_info; - if (!p_ibrt_ctrl->init_done) - { - trigger_media_play((AUD_ID_ENUM)aud_id, 0, aud_pram); - } - else if (app_ibrt_if_voice_report_filter(aud_id) && init_play) - { - TRACE_VOICE_RPT_I("[INIT] skip aud_id:%d%s", aud_id, aud_id2str(aud_id)); - } - else if (app_ibrt_if_voice_report_local_only(aud_id)) - { - trigger_media_play((AUD_ID_ENUM)aud_id, 0, aud_pram); - } - else if (!app_tws_ibrt_tws_link_connected()) - { - trigger_media_play((AUD_ID_ENUM)aud_id, 0, aud_pram); - } - else - { - voice_report_role_t report_role = app_ibrt_voice_report_get_role(); - - app_ibrt_if_tws_sniff_block(5); - if (report_role == VOICE_REPORT_MASTER) - { - TRACE_VOICE_RPT_I("[INIT] loc aud_id:%d%s aud_pram:%04x", aud_id, aud_id2str(aud_id), aud_pram); - - if (aud_id == AUDIO_ID_BT_MUTE) - { -#ifdef TWS_PROMPT_SYNC - audio_prompt_stop_playing(); + tg_tick = curr_ticks + US_TO_BTCLKS(APP_PLAY_AUDIO_SYNC_DELAY_US); +#ifdef PLAYBACK_USE_I2S + af_i2s_sync_config(AUD_STREAM_PLAYBACK, AF_I2S_SYNC_TYPE_BT, false); + af_i2s_sync_config(AUD_STREAM_PLAYBACK, AF_I2S_SYNC_TYPE_BT, true); +#else + af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, false); + af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, true); #endif - app_audio_manager_sendrequest_need_callback(APP_BT_STREAM_MANAGER_STOP_MEDIA, - BT_STREAM_MEDIA, - BT_DEVICE_ID_1, - 0, - (uintptr_t)app_ibrt_if_voice_report_force_audio_retrigger_hander, - AUDIO_ID_BT_MUTE); - } - else - { - trigger_media_play((AUD_ID_ENUM)aud_id, 0, aud_pram); - } - } - else if (report_role == VOICE_REPORT_SLAVE) - { - app_ibrt_voice_report_request_t voice_report_request; - TRACE_VOICE_RPT_I("[INIT] rmt aud_id:%d%s aud_pram:%04x", aud_id, aud_id2str(aud_id), aud_pram); - app_ibrt_voice_tg_tick = 0; - if (aud_id == AUDIO_ID_BT_MUTE) - { -#ifdef TWS_PROMPT_SYNC - audio_prompt_stop_playing(); -#endif - app_audio_manager_sendrequest_need_callback(APP_BT_STREAM_MANAGER_STOP_MEDIA, - BT_STREAM_MEDIA, - BT_DEVICE_ID_1, - 0, - 0, - 0); - } - - voice_report_request.aud_id = aud_id; - voice_report_request.aud_pram = aud_pram; - voice_report_request.vol = 0; - if((aud_id & AUDIO_ID_FIND_MY_BUDS) == AUDIO_ID_FIND_MY_BUDS) - { - trigger_media_play(( AUD_ID_ENUM )aud_id, 0, aud_pram); - } - else - tws_ctrl_send_cmd(APP_TWS_CMD_VOICE_REPORT_REQUEST, (uint8_t *)&voice_report_request, sizeof(voice_report_request)); - - } - else - { - TRACE_VOICE_RPT_I("[INIT] loc only aud_id:%d aud_pram:%04x", aud_id, aud_pram); -#ifdef MEDIA_PLAYER_SUPPORT - trigger_media_play((AUD_ID_ENUM)aud_id, 0, aud_pram); -#endif - } - } -#endif - return 0; -} - -int app_ibrt_if_voice_report_trig_retrigger(void) -{ - return app_ibrt_if_voice_report_handler(AUDIO_ID_BT_MUTE, PROMOT_ID_BIT_MASK_CHNLSEl_ALL); -} - -int app_ibrt_if_voice_report_handler(uint32_t aud_id, uint16_t aud_pram) -{ - return app_ibrt_if_voice_report_init(aud_id, aud_pram, true); -} - -void app_ibrt_send_voice_report_request_req(uint8_t *p_buff, uint16_t length) -{ - voice_report_role_t report_role = app_ibrt_voice_report_get_role(); - - if (report_role == VOICE_REPORT_SLAVE) - { - app_ibrt_send_cmd_without_rsp(APP_TWS_CMD_VOICE_REPORT_REQUEST, p_buff, length); - } -} - -void app_ibrt_voice_report_request_req_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - voice_report_role_t report_role = app_ibrt_voice_report_get_role(); - - if (report_role == VOICE_REPORT_MASTER) - { - app_ibrt_voice_report_request_t *voice_report_request = (app_ibrt_voice_report_request_t *)p_buff; - app_ibrt_if_voice_report_init(voice_report_request->aud_id, voice_report_request->aud_pram, false); - } - else - { - TRACE_VOICE_RPT_I("[REQUEST_REQ][HANDLER] role is :%d", report_role); - } -} - -void app_ibrt_send_voice_report_start_req(uint8_t *p_buff, uint16_t length) -{ - voice_report_role_t report_role = app_ibrt_voice_report_get_role(); - - if (report_role == VOICE_REPORT_MASTER) - - { - app_ibrt_send_cmd_without_rsp(APP_TWS_CMD_VOICE_REPORT_START, p_buff, length); - } - else - { - TRACE_VOICE_RPT_I("[START_REQ] role is :%d", report_role); - } -} - -void app_ibrt_voice_report_request_start_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ -#ifdef MEDIA_PLAYER_SUPPORT - voice_report_role_t report_role = app_ibrt_voice_report_get_role(); - - if (report_role == VOICE_REPORT_SLAVE) - { - app_ibrt_voice_report_info_t *voice_report_info = (app_ibrt_voice_report_info_t *)p_buff; - app_ibrt_voice_tg_tick = voice_report_info->tg_tick; + app_ibrt_voice_report_set_trigger_time(tg_tick); + voice_report_info.aud_id = aud_id; + voice_report_info.aud_pram = aud_pram; + voice_report_info.tg_tick = tg_tick; #ifdef __INTERACTION__ - g_findme_fadein_vol = voice_report_info->vol; + voice_report_info.vol = g_findme_fadein_vol; +#endif + if (p_ibrt_ctrl->tws_mode == IBRT_SNIFF_MODE) { + TRACE_VOICE_RPT_I("[TRIG][INIT][EXIT_SNIFF] force_exit_with_tws\n"); + app_tws_ibrt_exit_sniff_with_tws(); + } + tws_ctrl_send_cmd(APP_TWS_CMD_VOICE_REPORT_START, + (uint8_t *)&voice_report_info, + sizeof(app_ibrt_voice_report_info_t)); + TRACE_VOICE_RPT_I( + "[TRIG][INIT] MASTER aud_id:%d trigger [%08x]-->[%08x]", aud_id, + bt_syn_get_curr_ticks(p_ibrt_ctrl->tws_conhandle), tg_tick); + } else if (report_role == VOICE_REPORT_SLAVE) { + tg_tick = app_ibrt_voice_tg_tick; + if (curr_ticks < tg_tick && tg_tick != 0) { +#ifdef PLAYBACK_USE_I2S + af_i2s_sync_config(AUD_STREAM_PLAYBACK, AF_I2S_SYNC_TYPE_BT, false); + af_i2s_sync_config(AUD_STREAM_PLAYBACK, AF_I2S_SYNC_TYPE_BT, true); +#else + af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, false); + af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, true); +#endif + app_ibrt_voice_report_set_trigger_time(tg_tick); + } + app_ibrt_voice_tg_tick = 0; + if (tg_tick <= curr_ticks) { + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + TRACE_VOICE_RPT_I("[TRIG][INIT] Prompt TRIGGER ERROR !!!"); + } + + TRACE_VOICE_RPT_I( + "[TRIG][INIT] SLAVE aud_id:%d trigger [%08x]-->[%08x]", aud_id, + bt_syn_get_curr_ticks(p_ibrt_ctrl->tws_conhandle), tg_tick); + } + } else { + TRACE_VOICE_RPT_I("[TRIG][INIT] tws not connected."); + } + + return 0; +} + +int app_ibrt_voice_report_trigger_deinit(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + + if (!p_ibrt_ctrl->init_done) { + return 0; + } + +#ifdef PLAYBACK_USE_I2S + af_i2s_sync_config(AUD_STREAM_PLAYBACK, AF_I2S_SYNC_TYPE_BT, false); +#else + af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, false); +#endif + app_ibrt_voice_report_set_trigger_time(0); + + return 0; +} + +int app_ibrt_if_voice_report_filter(uint32_t aud_id) { + int nRet = 0; + ibrt_ctrl_t *p_ibrt_ctrl = app_ibrt_if_get_bt_ctrl_ctx(); + + switch (aud_id) { + case AUD_ID_BT_PAIRING_SUC: + nRet = 1; + break; + default: + break; + } + + if (app_tws_ibrt_slave_ibrt_link_connected()) { + switch (aud_id) { + case AUD_ID_BT_CALL_INCOMING_CALL: + case AUD_ID_BT_CALL_INCOMING_NUMBER: + case AUD_ID_BT_CALL_OVER: + case AUD_ID_BT_CALL_ANSWER: + case AUD_ID_BT_CONNECTED: + case AUD_ID_BT_CALL_HUNG_UP: + case AUD_ID_BT_CALL_REFUSE: + nRet = 1; + break; + default: + break; + } + } + + if (!app_tws_ibrt_slave_ibrt_link_connected() && + !app_tws_ibrt_mobile_link_connected()) { + if (p_ibrt_ctrl->nv_role == IBRT_SLAVE) { + switch (aud_id) { + case AUD_ID_BT_CONNECTED: + nRet = 1; + break; + default: + break; + } + } + } + + return nRet; +} + +int app_ibrt_if_voice_report_local_only(uint32_t aud_id) { + int nRet = 0; + + switch (aud_id) { + default: + break; + } + + return nRet; +} + +int app_ibrt_if_voice_report_force_audio_retrigger_hander(uint32_t msg_id, + uint32_t aud_id) { + if (msg_id == APP_BT_STREAM_MANAGER_STOP_MEDIA) { + if (aud_id == AUDIO_ID_BT_MUTE) { + TRACE_VOICE_RPT_I("[ID_BT_MUTE]"); +#ifdef MEDIA_PLAYER_SUPPORT + trigger_media_play((AUD_ID_ENUM)aud_id, 0, + PROMOT_ID_BIT_MASK_CHNLSEl_ALL); +#endif + } + } + return 0; +} + +static int app_ibrt_if_voice_report_init(uint32_t aud_id, uint16_t aud_pram, + uint8_t init_play) { +#ifdef MEDIA_PLAYER_SUPPORT + + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + + if (!p_ibrt_ctrl->init_done) { + trigger_media_play((AUD_ID_ENUM)aud_id, 0, aud_pram); + } else if (app_ibrt_if_voice_report_filter(aud_id) && init_play) { + TRACE_VOICE_RPT_I("[INIT] skip aud_id:%d%s", aud_id, aud_id2str(aud_id)); + } else if (app_ibrt_if_voice_report_local_only(aud_id)) { + trigger_media_play((AUD_ID_ENUM)aud_id, 0, aud_pram); + } else if (!app_tws_ibrt_tws_link_connected()) { + trigger_media_play((AUD_ID_ENUM)aud_id, 0, aud_pram); + } else { + voice_report_role_t report_role = app_ibrt_voice_report_get_role(); + + app_ibrt_if_tws_sniff_block(5); + if (report_role == VOICE_REPORT_MASTER) { + TRACE_VOICE_RPT_I("[INIT] loc aud_id:%d%s aud_pram:%04x", aud_id, + aud_id2str(aud_id), aud_pram); + + if (aud_id == AUDIO_ID_BT_MUTE) { +#ifdef TWS_PROMPT_SYNC + audio_prompt_stop_playing(); +#endif + app_audio_manager_sendrequest_need_callback( + APP_BT_STREAM_MANAGER_STOP_MEDIA, BT_STREAM_MEDIA, BT_DEVICE_ID_1, + 0, (uintptr_t)app_ibrt_if_voice_report_force_audio_retrigger_hander, + AUDIO_ID_BT_MUTE); + } else { + trigger_media_play((AUD_ID_ENUM)aud_id, 0, aud_pram); + } + } else if (report_role == VOICE_REPORT_SLAVE) { + app_ibrt_voice_report_request_t voice_report_request; + TRACE_VOICE_RPT_I("[INIT] rmt aud_id:%d%s aud_pram:%04x", aud_id, + aud_id2str(aud_id), aud_pram); + app_ibrt_voice_tg_tick = 0; + if (aud_id == AUDIO_ID_BT_MUTE) { +#ifdef TWS_PROMPT_SYNC + audio_prompt_stop_playing(); +#endif + app_audio_manager_sendrequest_need_callback( + APP_BT_STREAM_MANAGER_STOP_MEDIA, BT_STREAM_MEDIA, BT_DEVICE_ID_1, + 0, 0, 0); + } + + voice_report_request.aud_id = aud_id; + voice_report_request.aud_pram = aud_pram; + voice_report_request.vol = 0; + if ((aud_id & AUDIO_ID_FIND_MY_BUDS) == AUDIO_ID_FIND_MY_BUDS) { + trigger_media_play((AUD_ID_ENUM)aud_id, 0, aud_pram); + } else + tws_ctrl_send_cmd(APP_TWS_CMD_VOICE_REPORT_REQUEST, + (uint8_t *)&voice_report_request, + sizeof(voice_report_request)); + + } else { + TRACE_VOICE_RPT_I("[INIT] loc only aud_id:%d aud_pram:%04x", aud_id, + aud_pram); +#ifdef MEDIA_PLAYER_SUPPORT + trigger_media_play((AUD_ID_ENUM)aud_id, 0, aud_pram); +#endif + } + } +#endif + return 0; +} + +int app_ibrt_if_voice_report_trig_retrigger(void) { + return app_ibrt_if_voice_report_handler(AUDIO_ID_BT_MUTE, + PROMOT_ID_BIT_MASK_CHNLSEl_ALL); +} + +int app_ibrt_if_voice_report_handler(uint32_t aud_id, uint16_t aud_pram) { + return app_ibrt_if_voice_report_init(aud_id, aud_pram, true); +} + +void app_ibrt_send_voice_report_request_req(uint8_t *p_buff, uint16_t length) { + voice_report_role_t report_role = app_ibrt_voice_report_get_role(); + + if (report_role == VOICE_REPORT_SLAVE) { + app_ibrt_send_cmd_without_rsp(APP_TWS_CMD_VOICE_REPORT_REQUEST, p_buff, + length); + } +} + +void app_ibrt_voice_report_request_req_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + voice_report_role_t report_role = app_ibrt_voice_report_get_role(); + + if (report_role == VOICE_REPORT_MASTER) { + app_ibrt_voice_report_request_t *voice_report_request = + (app_ibrt_voice_report_request_t *)p_buff; + app_ibrt_if_voice_report_init(voice_report_request->aud_id, + voice_report_request->aud_pram, false); + } else { + TRACE_VOICE_RPT_I("[REQUEST_REQ][HANDLER] role is :%d", report_role); + } +} + +void app_ibrt_send_voice_report_start_req(uint8_t *p_buff, uint16_t length) { + voice_report_role_t report_role = app_ibrt_voice_report_get_role(); + + if (report_role == VOICE_REPORT_MASTER) + + { + app_ibrt_send_cmd_without_rsp(APP_TWS_CMD_VOICE_REPORT_START, p_buff, + length); + } else { + TRACE_VOICE_RPT_I("[START_REQ] role is :%d", report_role); + } +} + +void app_ibrt_voice_report_request_start_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { +#ifdef MEDIA_PLAYER_SUPPORT + voice_report_role_t report_role = app_ibrt_voice_report_get_role(); + + if (report_role == VOICE_REPORT_SLAVE) { + app_ibrt_voice_report_info_t *voice_report_info = + (app_ibrt_voice_report_info_t *)p_buff; + app_ibrt_voice_tg_tick = voice_report_info->tg_tick; +#ifdef __INTERACTION__ + g_findme_fadein_vol = voice_report_info->vol; #endif - if (voice_report_info->aud_id == AUDIO_ID_BT_MUTE) - { - app_audio_manager_sendrequest_need_callback(APP_BT_STREAM_MANAGER_STOP_MEDIA, - BT_STREAM_MEDIA, - BT_DEVICE_ID_1, - 0, - (uintptr_t)app_ibrt_if_voice_report_force_audio_retrigger_hander, - AUDIO_ID_BT_MUTE); - } - else - { - TRACE_VOICE_RPT_I("[START_REQ][HANDLER] aud id:%d", voice_report_info->aud_id); - trigger_media_play((AUD_ID_ENUM)voice_report_info->aud_id, 0, voice_report_info->aud_pram); - } - } - else - { - TRACE_VOICE_RPT_I("[START_REQ][HANDLER] role is :%d", report_role); + if (voice_report_info->aud_id == AUDIO_ID_BT_MUTE) { + app_audio_manager_sendrequest_need_callback( + APP_BT_STREAM_MANAGER_STOP_MEDIA, BT_STREAM_MEDIA, BT_DEVICE_ID_1, 0, + (uintptr_t)app_ibrt_if_voice_report_force_audio_retrigger_hander, + AUDIO_ID_BT_MUTE); + } else { + TRACE_VOICE_RPT_I("[START_REQ][HANDLER] aud id:%d", + voice_report_info->aud_id); + trigger_media_play((AUD_ID_ENUM)voice_report_info->aud_id, 0, + voice_report_info->aud_pram); } + } else { + TRACE_VOICE_RPT_I("[START_REQ][HANDLER] role is :%d", report_role); + } #endif } -bool app_ibrt_voice_report_is_me(uint32_t voice_chnlsel) -{ - bool is_me = true; - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - switch ((AUDIO_CHANNEL_SELECT_E)p_ibrt_ctrl->audio_chnl_sel) - { - case AUDIO_CHANNEL_SELECT_LCHNL: - if (IS_PROMPT_CHNLSEl_RCHNL(voice_chnlsel)){ - is_me = false; - } - break; - case AUDIO_CHANNEL_SELECT_RCHNL: - if (IS_PROMPT_CHNLSEl_LCHNL(voice_chnlsel)){ - is_me = false; - } - break; - default: - break; +bool app_ibrt_voice_report_is_me(uint32_t voice_chnlsel) { + bool is_me = true; + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + switch ((AUDIO_CHANNEL_SELECT_E)p_ibrt_ctrl->audio_chnl_sel) { + case AUDIO_CHANNEL_SELECT_LCHNL: + if (IS_PROMPT_CHNLSEl_RCHNL(voice_chnlsel)) { + is_me = false; } - return is_me; + break; + case AUDIO_CHANNEL_SELECT_RCHNL: + if (IS_PROMPT_CHNLSEl_LCHNL(voice_chnlsel)) { + is_me = false; + } + break; + default: + break; + } + return is_me; } #endif - diff --git a/services/app_tws/inc/app_tws_if.h b/services/app_tws/inc/app_tws_if.h index af352dd..7cf4dc5 100644 --- a/services/app_tws/inc/app_tws_if.h +++ b/services/app_tws/inc/app_tws_if.h @@ -1,21 +1,22 @@ /*************************************************************************** -* -*Copyright 2015-2019 BES. -*All rights reserved. All unpublished rights reserved. -* -*No part of this work may be used or reproduced in any form or by any -*means, or stored in a database or retrieval system, without prior written -*permission of BES. -* -*Use of this work is governed by a license granted by BES. -*This work contains confidential and proprietary information of -*BES. which is protected by copyright, trade secret, -*trademark and other intellectual property rights. -* -****************************************************************************/ + * + *Copyright 2015-2019 BES. + *All rights reserved. All unpublished rights reserved. + * + *No part of this work may be used or reproduced in any form or by any + *means, or stored in a database or retrieval system, without prior written + *permission of BES. + * + *Use of this work is governed by a license granted by BES. + *This work contains confidential and proprietary information of + *BES. which is protected by copyright, trade secret, + *trademark and other intellectual property rights. + * + ****************************************************************************/ #ifndef __APP_TWS_IF_H__ #define __APP_TWS_IF_H__ +#include #ifdef __cplusplus extern "C" { @@ -28,49 +29,49 @@ extern "C" { /******************************type defination******************************/ typedef enum { - EAR_SIDE_UNKNOWN = 0, - EAR_SIDE_LEFT = 1, - EAR_SIDE_RIGHT = 2, - EAR_SIDE_NUM, + EAR_SIDE_UNKNOWN = 0, + EAR_SIDE_LEFT = 1, + EAR_SIDE_RIGHT = 2, + EAR_SIDE_NUM, } APP_TWS_SIDE_T; enum { - DISCONNECTED = 0, - CONNECTED = 1, + DISCONNECTED = 0, + CONNECTED = 1, - CONNECTION_STATE_NUM, + CONNECTION_STATE_NUM, }; typedef enum { - TWS_SYNC_USER_BLE_INFO = 0, - TWS_SYNC_USER_OTA = 1, - TWS_SYNC_USER_AI_CONNECTION = 2, - TWS_SYNC_USER_GFPS_INFO = 3, - TWS_SYNC_USER_AI_INFO = 4, - TWS_SYNC_USER_AI_MANAGER = 5, - TWS_SYNC_USER_DIP = 6, + TWS_SYNC_USER_BLE_INFO = 0, + TWS_SYNC_USER_OTA = 1, + TWS_SYNC_USER_AI_CONNECTION = 2, + TWS_SYNC_USER_GFPS_INFO = 3, + TWS_SYNC_USER_AI_INFO = 4, + TWS_SYNC_USER_AI_MANAGER = 5, + TWS_SYNC_USER_DIP = 6, - TWS_SYNC_USER_NUM, + TWS_SYNC_USER_NUM, } TWS_SYNC_USER_E; typedef void (*TWS_SYNC_INFO_PREPARE_FUNC_T)(uint8_t *buf, uint16_t *len); typedef void (*TWS_INFO_SYNC_FUNC_T)(uint8_t *buf, uint16_t len); typedef struct { - TWS_SYNC_INFO_PREPARE_FUNC_T sync_info_prepare_handler; - TWS_INFO_SYNC_FUNC_T sync_info_received_handler; - TWS_SYNC_INFO_PREPARE_FUNC_T sync_info_prepare_rsp_handler; - TWS_INFO_SYNC_FUNC_T sync_info_rsp_received_handler; - TWS_INFO_SYNC_FUNC_T sync_info_rsp_timeout_handler; + TWS_SYNC_INFO_PREPARE_FUNC_T sync_info_prepare_handler; + TWS_INFO_SYNC_FUNC_T sync_info_received_handler; + TWS_SYNC_INFO_PREPARE_FUNC_T sync_info_prepare_rsp_handler; + TWS_INFO_SYNC_FUNC_T sync_info_rsp_received_handler; + TWS_INFO_SYNC_FUNC_T sync_info_rsp_timeout_handler; } TWS_SYNC_USER_T; typedef struct { - TWS_SYNC_USER_T syncUser[TWS_SYNC_USER_NUM]; + TWS_SYNC_USER_T syncUser[TWS_SYNC_USER_NUM]; } TWS_ENV_T; typedef struct { - TWS_SYNC_USER_E userId; - uint8_t info[TWS_SYNC_BUF_SIZE-1]; -}TWS_SYNC_DATA_T; + TWS_SYNC_USER_E userId; + uint8_t info[TWS_SYNC_BUF_SIZE - 1]; +} TWS_SYNC_DATA_T; /****************************function declearation**************************/ /*--------------------------------------------------------------------------- @@ -151,7 +152,8 @@ void app_tws_if_tws_role_updated_handler(uint8_t newRole); * Return: * void */ -void app_tws_if_sync_info_received_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +void app_tws_if_sync_info_received_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length); /*--------------------------------------------------------------------------- * app_tws_if_common_info_rsp_recieved_handler @@ -168,7 +170,9 @@ void app_tws_if_sync_info_received_handler(uint16_t rsp_seq, uint8_t *p_buff, ui * Return: * void */ -void app_tws_if_sync_info_rsp_received_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +void app_tws_if_sync_info_rsp_received_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); /*--------------------------------------------------------------------------- * app_tws_if_sync_info_rsp_timeout_handler @@ -185,7 +189,8 @@ void app_tws_if_sync_info_rsp_received_handler(uint16_t rsp_seq, uint8_t *p_buff * Return: * void */ -void app_tws_if_sync_info_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +void app_tws_if_sync_info_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length); /*--------------------------------------------------------------------------- * app_tws_if_mobile_connected_handler @@ -429,17 +434,27 @@ void app_tws_if_deregister_sync_user(uint8_t id); void app_tws_if_sync_info(TWS_SYNC_USER_E id); void app_tws_if_ai_send_cmd_to_peer(uint8_t *p_buff, uint16_t length); -void app_tws_if_ai_rev_peer_cmd_hanlder(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +void app_tws_if_ai_rev_peer_cmd_hanlder(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length); void app_tws_if_ai_send_cmd_with_rsp_to_peer(uint8_t *p_buff, uint16_t length); -void app_tws_if_ai_send_cmd_rsp_to_peer(uint8_t *p_buff, uint16_t rsp_seq, uint16_t length); -void app_tws_if_ai_rev_peer_cmd_with_rsp_hanlder(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -void app_tws_if_ai_rev_cmd_rsp_from_peer_hanlder(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -void app_tws_if_ai_rev_cmd_rsp_timeout_hanlder(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +void app_tws_if_ai_send_cmd_rsp_to_peer(uint8_t *p_buff, uint16_t rsp_seq, + uint16_t length); +void app_tws_if_ai_rev_peer_cmd_with_rsp_hanlder(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +void app_tws_if_ai_rev_cmd_rsp_from_peer_hanlder(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +void app_tws_if_ai_rev_cmd_rsp_timeout_hanlder(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); #ifdef GFPS_ENABLED void app_ibrt_share_fastpair_info(uint8_t *p_buff, uint16_t length); void app_tws_send_fastpair_info_to_slave(void); -void app_ibrt_shared_fastpair_info_received_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); +void app_ibrt_shared_fastpair_info_received_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); #endif bool app_tws_is_master_mode(void); diff --git a/services/app_tws/src/app_tws_if.cpp b/services/app_tws/src/app_tws_if.cpp index 4ef5d05..9f1a4c2 100644 --- a/services/app_tws/src/app_tws_if.cpp +++ b/services/app_tws/src/app_tws_if.cpp @@ -1,41 +1,41 @@ /*************************************************************************** -* -*Copyright 2015-2019 BES. -*All rights reserved. All unpublished rights reserved. -* -*No part of this work may be used or reproduced in any form or by any -*means, or stored in a database or retrieval system, without prior written -*permission of BES. -* -*Use of this work is governed by a license granted by BES. -*This work contains confidential and proprietary information of -*BES. which is protected by copyright, trade secret, -*trademark and other intellectual property rights. -* -****************************************************************************/ + * + *Copyright 2015-2019 BES. + *All rights reserved. All unpublished rights reserved. + * + *No part of this work may be used or reproduced in any form or by any + *means, or stored in a database or retrieval system, without prior written + *permission of BES. + * + *Use of this work is governed by a license granted by BES. + *This work contains confidential and proprietary information of + *BES. which is protected by copyright, trade secret, + *trademark and other intellectual property rights. + * + ****************************************************************************/ /*****************************header include********************************/ -#include "cmsis.h" -#include "hal_trace.h" -#include "me_api.h" -#include "besbt.h" +#include "app_tws_if.h" #include "app.h" +#include "app_ai_if.h" +#include "app_ai_manager_api.h" +#include "app_ai_tws.h" +#include "app_bt.h" +#include "app_bt_func.h" +#include "app_bt_stream.h" +#include "app_dip.h" +#include "app_ibrt_ui.h" #include "app_sec.h" #include "app_tws_ctrl_thread.h" #include "app_tws_ibrt_cmd_handler.h" -#include "app_tws_if.h" -#include "app_ibrt_ui.h" +#include "besbt.h" #include "btapp.h" +#include "cmsis.h" +#include "hal_trace.h" +#include "me_api.h" +#include "nvrecord_ble.h" #include "nvrecord_env.h" #include "nvrecord_extension.h" -#include "nvrecord_ble.h" -#include "app_ai_if.h" -#include "app_ai_tws.h" -#include "app_ai_manager_api.h" -#include "app_bt.h" -#include "app_bt_func.h" -#include "app_dip.h" -#include "app_bt_stream.h" #include "tgt_hardware.h" #ifdef __THIRDPARTY #include "app_thirdparty.h" @@ -43,8 +43,8 @@ #ifdef IBRT #include "app_ibrt_customif_cmd.h" -#include "app_ibrt_if.h" #include "app_ibrt_customif_ui.h" +#include "app_ibrt_if.h" #endif #ifdef BLE_ENABLE @@ -73,15 +73,14 @@ #endif #ifdef GFPS_ENABLED -#include "nvrecord_fp_account_key.h" #include "app_gfps.h" +#include "nvrecord_fp_account_key.h" #endif #ifdef __GMA_VOICE__ #include "app_gma_ota.h" #endif - /************************private macro defination***************************/ /************************private struct defination****************************/ @@ -95,591 +94,546 @@ static TWS_SYNC_DATA_T twsSyncBuf; osMutexId twsSyncBufMutexId = NULL; osMutexDef(twsSyncBufMutex); -#define POST_ROLESWITCH_STATE_STAYING_MS 15000 +#define POST_ROLESWITCH_STATE_STAYING_MS 15000 osTimerId app_post_roleswitch_handling_timer_id = NULL; static int app_post_roleswitch_handling_timer_handler(void const *param); -osTimerDef (APP_POST_ROLESWITCH_HANDLING_TIMER, (void (*)(void const *))app_post_roleswitch_handling_timer_handler); // define timers - +osTimerDef(APP_POST_ROLESWITCH_HANDLING_TIMER, + (void (*)(void const *)) + app_post_roleswitch_handling_timer_handler); // define timers /****************************function defination****************************/ extern int hfp_volume_get(enum BT_DEVICE_ID_T id); extern int a2dp_volume_get(enum BT_DEVICE_ID_T id); -static const char *tws_sync_user2str(TWS_SYNC_USER_E user) -{ - const char *str = NULL; -#define CASES(user) \ - case user: \ - str = "[" #user "]"; \ - break +static const char *tws_sync_user2str(TWS_SYNC_USER_E user) { + const char *str = NULL; +#define CASES(user) \ + case user: \ + str = "[" #user "]"; \ + break - switch (user) - { - CASES(TWS_SYNC_USER_BLE_INFO); - CASES(TWS_SYNC_USER_OTA); - CASES(TWS_SYNC_USER_AI_CONNECTION); - CASES(TWS_SYNC_USER_GFPS_INFO); - CASES(TWS_SYNC_USER_AI_INFO); - CASES(TWS_SYNC_USER_AI_MANAGER); - CASES(TWS_SYNC_USER_DIP); + switch (user) { + CASES(TWS_SYNC_USER_BLE_INFO); + CASES(TWS_SYNC_USER_OTA); + CASES(TWS_SYNC_USER_AI_CONNECTION); + CASES(TWS_SYNC_USER_GFPS_INFO); + CASES(TWS_SYNC_USER_AI_INFO); + CASES(TWS_SYNC_USER_AI_MANAGER); + CASES(TWS_SYNC_USER_DIP); - default: - str = "[INVALID]"; - break; - } + default: + str = "[INVALID]"; + break; + } - return str; + return str; } -void app_tws_if_init(void) -{ - // reset the environment - memset(&twsEnv, 0, sizeof(twsEnv)); - memset(&twsSyncBuf, 0, TWS_SYNC_BUF_SIZE); +void app_tws_if_init(void) { + // reset the environment + memset(&twsEnv, 0, sizeof(twsEnv)); + memset(&twsSyncBuf, 0, TWS_SYNC_BUF_SIZE); - // init the tws sync buffer mutex - if (NULL == twsSyncBufMutexId) - { - twsSyncBufMutexId = osMutexCreate(osMutex(twsSyncBufMutex)); - } + // init the tws sync buffer mutex + if (NULL == twsSyncBufMutexId) { + twsSyncBufMutexId = osMutexCreate(osMutex(twsSyncBufMutex)); + } - // register all users + // register all users #ifdef BLE_ENABLE - // init ble tws interface - app_ble_mode_tws_sync_init(); + // init ble tws interface + app_ble_mode_tws_sync_init(); #endif #ifdef OTA_ENABLED - ota_common_tws_sync_init(); + ota_common_tws_sync_init(); #endif #ifdef BISTO_ENABLED - // init gsound tws interface - app_ai_tws_gsound_sync_init(); + // init gsound tws interface + app_ai_tws_gsound_sync_init(); #endif #ifdef GFPS_ENABLED - app_gfps_tws_sync_init(); + app_gfps_tws_sync_init(); #endif #ifdef __AI_VOICE__ - app_ai_tws_sync_init(); + app_ai_tws_sync_init(); #endif #ifdef IS_MULTI_AI_ENABLED - ai_manager_sync_init(); + ai_manager_sync_init(); #endif #ifdef BTIF_DIP_DEVICE - app_dip_sync_init(); + app_dip_sync_init(); #endif } -void app_tws_if_role_switch_started_handler(void) -{ - TRACE(1,"[%s]+++", __func__); - if (NULL == app_post_roleswitch_handling_timer_id) - { - app_post_roleswitch_handling_timer_id = - osTimerCreate(osTimer(APP_POST_ROLESWITCH_HANDLING_TIMER), osTimerOnce, NULL); - } +void app_tws_if_role_switch_started_handler(void) { + TRACE(1, "[%s]+++", __func__); + if (NULL == app_post_roleswitch_handling_timer_id) { + app_post_roleswitch_handling_timer_id = osTimerCreate( + osTimer(APP_POST_ROLESWITCH_HANDLING_TIMER), osTimerOnce, NULL); + } - osTimerStop(app_post_roleswitch_handling_timer_id); + osTimerStop(app_post_roleswitch_handling_timer_id); - app_bt_active_mode_clear(ACTIVE_MODE_KEEPER_ROLE_SWITCH, UPDATE_ACTIVE_MODE_FOR_ALL_LINKS); + app_bt_active_mode_clear(ACTIVE_MODE_KEEPER_ROLE_SWITCH, + UPDATE_ACTIVE_MODE_FOR_ALL_LINKS); - TRACE(1,"[%s]---", __func__); + TRACE(1, "[%s]---", __func__); } -static int app_post_roleswitch_handling_timer_handler(void const *param) -{ - app_bt_start_custom_function_in_bt_thread( - ACTIVE_MODE_KEEPER_ROLE_SWITCH, - UPDATE_ACTIVE_MODE_FOR_ALL_LINKS, - (uint32_t)app_bt_active_mode_clear); - return 0; +static int app_post_roleswitch_handling_timer_handler(void const *param) { + app_bt_start_custom_function_in_bt_thread(ACTIVE_MODE_KEEPER_ROLE_SWITCH, + UPDATE_ACTIVE_MODE_FOR_ALL_LINKS, + (uint32_t)app_bt_active_mode_clear); + return 0; } -static void app_tws_if_post_roleswitch_handler(void) -{ - if (NULL == app_post_roleswitch_handling_timer_id) - { - app_post_roleswitch_handling_timer_id = - osTimerCreate(osTimer(APP_POST_ROLESWITCH_HANDLING_TIMER), osTimerOnce, NULL); - } +static void app_tws_if_post_roleswitch_handler(void) { + if (NULL == app_post_roleswitch_handling_timer_id) { + app_post_roleswitch_handling_timer_id = osTimerCreate( + osTimer(APP_POST_ROLESWITCH_HANDLING_TIMER), osTimerOnce, NULL); + } - osTimerStart(app_post_roleswitch_handling_timer_id, POST_ROLESWITCH_STATE_STAYING_MS); - // keep bt link in active mode right after role switch - app_bt_active_mode_set(ACTIVE_MODE_KEEPER_ROLE_SWITCH, UPDATE_ACTIVE_MODE_FOR_ALL_LINKS); + osTimerStart(app_post_roleswitch_handling_timer_id, + POST_ROLESWITCH_STATE_STAYING_MS); + // keep bt link in active mode right after role switch + app_bt_active_mode_set(ACTIVE_MODE_KEEPER_ROLE_SWITCH, + UPDATE_ACTIVE_MODE_FOR_ALL_LINKS); } -void app_tws_if_tws_role_switch_complete_handler(uint8_t newRole) -{ - TRACE(2,"[%s]+++ role %d", __func__, newRole); +void app_tws_if_tws_role_switch_complete_handler(uint8_t newRole) { + TRACE(2, "[%s]+++ role %d", __func__, newRole); #ifdef BISTO_ENABLED - gsound_on_system_role_switch_done(newRole); + gsound_on_system_role_switch_done(newRole); #endif - // update BLE info saved in flash after role switch complete - nv_record_tws_exchange_ble_info(); + // update BLE info saved in flash after role switch complete + nv_record_tws_exchange_ble_info(); #ifdef BLE_USE_RPA - appm_refresh_ble_irk(); + appm_refresh_ble_irk(); #else - btif_me_set_ble_bd_address(bt_get_ble_local_address()); + btif_me_set_ble_bd_address(bt_get_ble_local_address()); #endif #ifdef __AI_VOICE__ - app_ai_tws_role_switch_complete(); + app_ai_tws_role_switch_complete(); #endif #ifdef BLE_ENABLE - ble_callback_evnet_t event; - event.evt_type = BLE_CALLBACK_RS_COMPLETE; - event.p.rs_complete_handled.newRole = newRole; - app_ble_core_global_callback_event(&event, NULL); + ble_callback_evnet_t event; + event.evt_type = BLE_CALLBACK_RS_COMPLETE; + event.p.rs_complete_handled.newRole = newRole; + app_ble_core_global_callback_event(&event, NULL); #endif - app_tws_if_post_roleswitch_handler(); + app_tws_if_post_roleswitch_handler(); - TRACE(1,"[%s]---", __func__); + TRACE(1, "[%s]---", __func__); #ifdef IBRT_OTA - ota_control_send_role_switch_complete(); + ota_control_send_role_switch_complete(); #endif } -void app_tws_if_register_sync_user(uint8_t id, TWS_SYNC_USER_T *user) -{ - memcpy(&twsEnv.syncUser[id], user, sizeof(TWS_SYNC_USER_T)); +void app_tws_if_register_sync_user(uint8_t id, TWS_SYNC_USER_T *user) { + memcpy(&twsEnv.syncUser[id], user, sizeof(TWS_SYNC_USER_T)); } -void app_tws_if_deregister_sync_user(uint8_t id) -{ - memset(&twsEnv.syncUser[id], 0, sizeof(TWS_SYNC_USER_T)); +void app_tws_if_deregister_sync_user(uint8_t id) { + memset(&twsEnv.syncUser[id], 0, sizeof(TWS_SYNC_USER_T)); } -void app_tws_if_sync_info(TWS_SYNC_USER_E id) -{ - TRACE(1,"[%s]+++", __func__); - TRACE(1,"user:%s", tws_sync_user2str(id)); +void app_tws_if_sync_info(TWS_SYNC_USER_E id) { + TRACE(1, "[%s]+++", __func__); + TRACE(1, "user:%s", tws_sync_user2str(id)); - osMutexWait(twsSyncBufMutexId, osWaitForever); - if (twsEnv.syncUser[id].sync_info_prepare_handler) - { - uint16_t length = 0; - twsEnv.syncUser[id].sync_info_prepare_handler(twsSyncBuf.info, &length); + osMutexWait(twsSyncBufMutexId, osWaitForever); + if (twsEnv.syncUser[id].sync_info_prepare_handler) { + uint16_t length = 0; + twsEnv.syncUser[id].sync_info_prepare_handler(twsSyncBuf.info, &length); - if (length) - { - twsSyncBuf.userId = id; - length++; + if (length) { + twsSyncBuf.userId = id; + length++; - tws_ctrl_send_cmd(APP_TWS_CMD_SHARE_COMMON_INFO, ( uint8_t * )&twsSyncBuf, length); - } - else - { - TRACE(0,"no info to sync"); - } + tws_ctrl_send_cmd(APP_TWS_CMD_SHARE_COMMON_INFO, (uint8_t *)&twsSyncBuf, + length); + } else { + TRACE(0, "no info to sync"); } - else - { - TRACE(0,"prepare handler is null pointer"); - } - osMutexRelease(twsSyncBufMutexId); + } else { + TRACE(0, "prepare handler is null pointer"); + } + osMutexRelease(twsSyncBufMutexId); - TRACE(1,"[%s]---", __func__); + TRACE(1, "[%s]---", __func__); } -void app_tws_if_sync_info_received_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - TRACE(1,"[%s]+++", __func__); +void app_tws_if_sync_info_received_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + TRACE(1, "[%s]+++", __func__); - TWS_SYNC_DATA_T *pInfo = ( TWS_SYNC_DATA_T * )p_buff; - TRACE(1,"user:%s", tws_sync_user2str(pInfo->userId)); + TWS_SYNC_DATA_T *pInfo = (TWS_SYNC_DATA_T *)p_buff; + TRACE(1, "user:%s", tws_sync_user2str(pInfo->userId)); - // handle received data - if (twsEnv.syncUser[pInfo->userId].sync_info_received_handler) - { - twsEnv.syncUser[pInfo->userId].sync_info_received_handler(pInfo->info, (length - 1)); - } + // handle received data + if (twsEnv.syncUser[pInfo->userId].sync_info_received_handler) { + twsEnv.syncUser[pInfo->userId].sync_info_received_handler(pInfo->info, + (length - 1)); + } - // send response to peer device - uint16_t len = 0; - osMutexWait(twsSyncBufMutexId, osWaitForever); + // send response to peer device + uint16_t len = 0; + osMutexWait(twsSyncBufMutexId, osWaitForever); - if (twsEnv.syncUser[pInfo->userId].sync_info_prepare_rsp_handler) - { - twsEnv.syncUser[pInfo->userId].sync_info_prepare_rsp_handler(twsSyncBuf.info, &len); - } + if (twsEnv.syncUser[pInfo->userId].sync_info_prepare_rsp_handler) { + twsEnv.syncUser[pInfo->userId].sync_info_prepare_rsp_handler( + twsSyncBuf.info, &len); + } - twsSyncBuf.userId = pInfo->userId; - len++; + twsSyncBuf.userId = pInfo->userId; + len++; - tws_ctrl_send_rsp(APP_TWS_CMD_SHARE_COMMON_INFO, - rsp_seq, - ( uint8_t * )&twsSyncBuf, - len); - osMutexRelease(twsSyncBufMutexId); + tws_ctrl_send_rsp(APP_TWS_CMD_SHARE_COMMON_INFO, rsp_seq, + (uint8_t *)&twsSyncBuf, len); + osMutexRelease(twsSyncBufMutexId); - TRACE(1,"[%s]---", __func__); + TRACE(1, "[%s]---", __func__); } -void app_tws_if_sync_info_rsp_received_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - TRACE(1,"[%s]+++", __func__); +void app_tws_if_sync_info_rsp_received_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + TRACE(1, "[%s]+++", __func__); - TWS_SYNC_DATA_T *pInfo = ( TWS_SYNC_DATA_T * )p_buff; + TWS_SYNC_DATA_T *pInfo = (TWS_SYNC_DATA_T *)p_buff; - // handle received data - if (twsEnv.syncUser[pInfo->userId].sync_info_rsp_received_handler) - { - twsEnv.syncUser[pInfo->userId].sync_info_rsp_received_handler(pInfo->info, (length - 1)); - } + // handle received data + if (twsEnv.syncUser[pInfo->userId].sync_info_rsp_received_handler) { + twsEnv.syncUser[pInfo->userId].sync_info_rsp_received_handler(pInfo->info, + (length - 1)); + } - TRACE(1,"[%s]---", __func__); + TRACE(1, "[%s]---", __func__); } -void app_tws_if_sync_info_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - TRACE(1,"[%s]+++", __func__); +void app_tws_if_sync_info_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + TRACE(1, "[%s]+++", __func__); - TWS_SYNC_DATA_T *pInfo = ( TWS_SYNC_DATA_T * )p_buff; + TWS_SYNC_DATA_T *pInfo = (TWS_SYNC_DATA_T *)p_buff; - if (twsEnv.syncUser[pInfo->userId].sync_info_rsp_timeout_handler) - { - twsEnv.syncUser[pInfo->userId].sync_info_rsp_timeout_handler(pInfo->info, (length - 1)); - } + if (twsEnv.syncUser[pInfo->userId].sync_info_rsp_timeout_handler) { + twsEnv.syncUser[pInfo->userId].sync_info_rsp_timeout_handler(pInfo->info, + (length - 1)); + } - TRACE(1,"[%s]---", __func__); + TRACE(1, "[%s]---", __func__); } -void app_tws_if_tws_role_updated_handler(uint8_t newRole) -{ +void app_tws_if_tws_role_updated_handler(uint8_t newRole) { #ifdef BLE_ENABLE - ble_callback_evnet_t event; - event.evt_type = BLE_CALLBACK_ROLE_UPDATE; - event.p.role_update_handled.newRole = newRole; - app_ble_core_global_callback_event(&event, NULL); + ble_callback_evnet_t event; + event.evt_type = BLE_CALLBACK_ROLE_UPDATE; + event.p.role_update_handled.newRole = newRole; + app_ble_core_global_callback_event(&event, NULL); #endif #if defined(BISTO_ENABLED) && defined(IBRT) - gsound_on_tws_role_updated(newRole); + gsound_on_tws_role_updated(newRole); #endif } -void app_tws_if_tws_connected_sync_info(void) -{ - TRACE(2,"[%s]+++ role %d", __func__, app_tws_ibrt_role_get_callback(NULL)); +void app_tws_if_tws_connected_sync_info(void) { + TRACE(2, "[%s]+++ role %d", __func__, app_tws_ibrt_role_get_callback(NULL)); - if (IBRT_MASTER == app_tws_ibrt_role_get_callback(NULL)) - { - // inform peer to update the common info - app_tws_if_sync_info(TWS_SYNC_USER_BLE_INFO); - app_tws_if_sync_info(TWS_SYNC_USER_OTA); - // app_tws_if_sync_info(TWS_SYNC_USER_AI_CONNECTION); - app_tws_if_sync_info(TWS_SYNC_USER_GFPS_INFO); - app_tws_if_sync_info(TWS_SYNC_USER_AI_INFO); - app_tws_if_sync_info(TWS_SYNC_USER_AI_MANAGER); - app_tws_if_sync_info(TWS_SYNC_USER_DIP); + if (IBRT_MASTER == app_tws_ibrt_role_get_callback(NULL)) { + // inform peer to update the common info + app_tws_if_sync_info(TWS_SYNC_USER_BLE_INFO); + app_tws_if_sync_info(TWS_SYNC_USER_OTA); + // app_tws_if_sync_info(TWS_SYNC_USER_AI_CONNECTION); + app_tws_if_sync_info(TWS_SYNC_USER_GFPS_INFO); + app_tws_if_sync_info(TWS_SYNC_USER_AI_INFO); + app_tws_if_sync_info(TWS_SYNC_USER_AI_MANAGER); + app_tws_if_sync_info(TWS_SYNC_USER_DIP); #ifdef GFPS_ENABLED - if (!app_tws_ibrt_mobile_link_connected()) - { - app_enter_fastpairing_mode(); - } -#endif + if (!app_tws_ibrt_mobile_link_connected()) { + app_enter_fastpairing_mode(); } +#endif + } - TRACE(1,"[%s]---", __func__); + TRACE(1, "[%s]---", __func__); } -void app_tws_if_tws_connected_handler(void) -{ - TRACE(1, "twsif_tws_connected, role %d", app_tws_ibrt_role_get_callback(NULL)); +void app_tws_if_tws_connected_handler(void) { + TRACE(1, "twsif_tws_connected, role %d", + app_tws_ibrt_role_get_callback(NULL)); } -void app_tws_if_tws_disconnected_handler(void) -{ - TRACE(0, "twsif_tws_disconnected."); +void app_tws_if_tws_disconnected_handler(void) { + TRACE(0, "twsif_tws_disconnected."); #ifdef IBRT - if (IBRT_SLAVE == app_tws_ibrt_role_get_callback(NULL)) - { + if (IBRT_SLAVE == app_tws_ibrt_role_get_callback(NULL)) { #ifdef BISTO_ENABLED - gsound_set_ble_connect_state(GSOUND_CHANNEL_AUDIO, false); - gsound_set_ble_connect_state(GSOUND_CHANNEL_CONTROL, false); + gsound_set_ble_connect_state(GSOUND_CHANNEL_AUDIO, false); + gsound_set_ble_connect_state(GSOUND_CHANNEL_CONTROL, false); #endif - } + } #ifdef __GMA_VOICE__ - app_gma_ota_exception_reboot(); // shuailong + app_gma_ota_exception_reboot(); // shuailong #endif #endif } -void app_tws_if_mobile_connected_handler(uint8_t *addr) -{ - TRACE(0, "twsif_mobile_connected"); +void app_tws_if_mobile_connected_handler(uint8_t *addr) { + TRACE(0, "twsif_mobile_connected"); #ifdef IBRT - if (IBRT_MASTER == app_tws_ibrt_role_get_callback(NULL)) + if (IBRT_MASTER == app_tws_ibrt_role_get_callback(NULL)) #endif - { - // inform peer to update the common info - // app_tws_if_sync_info(TWS_SYNC_USER_AI_CONNECTION); - app_tws_if_sync_info(TWS_SYNC_USER_GFPS_INFO); - } + { + // inform peer to update the common info + // app_tws_if_sync_info(TWS_SYNC_USER_AI_CONNECTION); + app_tws_if_sync_info(TWS_SYNC_USER_GFPS_INFO); + } } -void app_tws_if_mobile_disconnected_handler(uint8_t *addr) -{ - TRACE(0, "twsif_mobile_disconnected"); +void app_tws_if_mobile_disconnected_handler(uint8_t *addr) { + TRACE(0, "twsif_mobile_disconnected"); } -void app_tws_if_ibrt_connected_handler(void) -{ - TRACE(0, "twsif_ibrt_connected"); +void app_tws_if_ibrt_connected_handler(void) { + TRACE(0, "twsif_ibrt_connected"); #ifdef IBRT - if (IBRT_MASTER == app_tws_ibrt_role_get_callback(NULL)) + if (IBRT_MASTER == app_tws_ibrt_role_get_callback(NULL)) #endif - { - // inform peer to update the common info - app_tws_if_sync_info(TWS_SYNC_USER_AI_INFO); - app_tws_if_sync_info(TWS_SYNC_USER_AI_MANAGER); - } + { + // inform peer to update the common info + app_tws_if_sync_info(TWS_SYNC_USER_AI_INFO); + app_tws_if_sync_info(TWS_SYNC_USER_AI_MANAGER); + } } -void app_tws_if_ibrt_disconnected_handler(void) -{ - TRACE(0, "twsif_ibrt_disconnected"); +void app_tws_if_ibrt_disconnected_handler(void) { + TRACE(0, "twsif_ibrt_disconnected"); } -void app_tws_if_ble_connected_handler(void) -{ - TRACE(0, "twsif_ble_connected"); +void app_tws_if_ble_connected_handler(void) { + TRACE(0, "twsif_ble_connected"); #ifdef IBRT - if (IBRT_MASTER == app_tws_ibrt_role_get_callback(NULL)) + if (IBRT_MASTER == app_tws_ibrt_role_get_callback(NULL)) #endif - { - // inform peer to update the common info - //app_tws_if_sync_info(TWS_SYNC_USER_BLE_INFO); - app_tws_if_sync_info(TWS_SYNC_USER_OTA); - // app_tws_if_sync_info(TWS_SYNC_USER_AI_CONNECTION); - app_tws_if_sync_info(TWS_SYNC_USER_GFPS_INFO); - } + { + // inform peer to update the common info + // app_tws_if_sync_info(TWS_SYNC_USER_BLE_INFO); + app_tws_if_sync_info(TWS_SYNC_USER_OTA); + // app_tws_if_sync_info(TWS_SYNC_USER_AI_CONNECTION); + app_tws_if_sync_info(TWS_SYNC_USER_GFPS_INFO); + } } -void app_tws_if_ble_disconnected_handler(void) -{ - TRACE(0, "twsif_ble_disconnected"); +void app_tws_if_ble_disconnected_handler(void) { + TRACE(0, "twsif_ble_disconnected"); #ifdef IBRT - if (IBRT_MASTER == app_tws_ibrt_role_get_callback(NULL)) + if (IBRT_MASTER == app_tws_ibrt_role_get_callback(NULL)) #endif - { - // inform peer to update the common info - // app_tws_if_sync_info(TWS_SYNC_USER_AI_CONNECTION); - } + { + // inform peer to update the common info + // app_tws_if_sync_info(TWS_SYNC_USER_AI_CONNECTION); + } } -void app_tws_if_trigger_role_switch(void) -{ - if (false == app_ibrt_ui_can_tws_switch()) - { - TRACE(1,"%s can't switch", __func__); - return; - } +void app_tws_if_trigger_role_switch(void) { + if (false == app_ibrt_ui_can_tws_switch()) { + TRACE(1, "%s can't switch", __func__); + return; + } - app_ibrt_customif_ui_tws_switch(); + app_ibrt_customif_ui_tws_switch(); } -void app_tws_if_handle_click(void) -{ - TRACE(1,"%s", __func__); +void app_tws_if_handle_click(void) { + TRACE(1, "%s", __func__); #if defined(BISTO_ENABLED) || defined(__AI_VOICE__) - app_tws_if_trigger_role_switch(); + app_tws_if_trigger_role_switch(); #else - bt_key_handle_func_click(); + bt_key_handle_func_click(); #endif } #ifdef IBRT -void app_tws_if_ai_send_cmd_to_peer(uint8_t *p_buff, uint16_t length) -{ - TRACE(1,"[%s]", __func__); +void app_tws_if_ai_send_cmd_to_peer(uint8_t *p_buff, uint16_t length) { + TRACE(1, "[%s]", __func__); - tws_ctrl_send_cmd(APP_TWS_CMD_AI_SEND_CMD_TO_PEER, p_buff, length); + tws_ctrl_send_cmd(APP_TWS_CMD_AI_SEND_CMD_TO_PEER, p_buff, length); } -void app_tws_if_ai_rev_peer_cmd_hanlder(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - TRACE(1,"[%s]", __func__); +void app_tws_if_ai_rev_peer_cmd_hanlder(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length) { + TRACE(1, "[%s]", __func__); #ifdef __AI_VOICE__ - app_ai_tws_rev_peer_cmd_hanlder(rsp_seq, p_buff, length); + app_ai_tws_rev_peer_cmd_hanlder(rsp_seq, p_buff, length); #endif } -void app_tws_if_ai_send_cmd_with_rsp_to_peer(uint8_t *p_buff, uint16_t length) -{ - TRACE(1,"[%s]", __func__); +void app_tws_if_ai_send_cmd_with_rsp_to_peer(uint8_t *p_buff, uint16_t length) { + TRACE(1, "[%s]", __func__); - tws_ctrl_send_cmd(APP_TWS_CMD_AI_SEND_CMD_TO_PEER_WITH_RSP, p_buff, length); + tws_ctrl_send_cmd(APP_TWS_CMD_AI_SEND_CMD_TO_PEER_WITH_RSP, p_buff, length); } -void app_tws_if_ai_send_cmd_rsp_to_peer(uint8_t *p_buff, uint16_t rsp_seq, uint16_t length) -{ - TRACE(1,"[%s]", __func__); +void app_tws_if_ai_send_cmd_rsp_to_peer(uint8_t *p_buff, uint16_t rsp_seq, + uint16_t length) { + TRACE(1, "[%s]", __func__); - tws_ctrl_send_rsp(APP_TWS_CMD_AI_SEND_CMD_TO_PEER_WITH_RSP, rsp_seq, p_buff, length); + tws_ctrl_send_rsp(APP_TWS_CMD_AI_SEND_CMD_TO_PEER_WITH_RSP, rsp_seq, p_buff, + length); } -void app_tws_if_ai_rev_peer_cmd_with_rsp_hanlder(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - TRACE(1,"[%s]", __func__); +void app_tws_if_ai_rev_peer_cmd_with_rsp_hanlder(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + TRACE(1, "[%s]", __func__); #ifdef __AI_VOICE__ - app_ai_tws_rev_peer_cmd_with_rsp_hanlder(rsp_seq, p_buff, length); + app_ai_tws_rev_peer_cmd_with_rsp_hanlder(rsp_seq, p_buff, length); #endif } -void app_tws_if_ai_rev_cmd_rsp_from_peer_hanlder(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - TRACE(1,"[%s]", __func__); - +void app_tws_if_ai_rev_cmd_rsp_from_peer_hanlder(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + TRACE(1, "[%s]", __func__); + #ifdef __AI_VOICE__ - app_ai_tws_rev_cmd_rsp_from_peer_hanlder(rsp_seq, p_buff, length); + app_ai_tws_rev_cmd_rsp_from_peer_hanlder(rsp_seq, p_buff, length); #endif } -void app_tws_if_ai_rev_cmd_rsp_timeout_hanlder(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - TRACE(1,"[%s]", __func__); +void app_tws_if_ai_rev_cmd_rsp_timeout_hanlder(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + TRACE(1, "[%s]", __func__); #ifdef __AI_VOICE__ - app_ai_tws_rev_cmd_rsp_timeout_hanlder(rsp_seq, p_buff, length); + app_ai_tws_rev_cmd_rsp_timeout_hanlder(rsp_seq, p_buff, length); #endif } -void app_tws_if_master_prepare_rs(uint8_t *p_buff, uint16_t length) -{ +void app_tws_if_master_prepare_rs(uint8_t *p_buff, uint16_t length) { #ifdef BLE_ENABLE - ble_callback_evnet_t event; - event.evt_type = BLE_CALLBACK_RS_START; - app_ble_core_global_callback_event(&event, NULL); + ble_callback_evnet_t event; + event.evt_type = BLE_CALLBACK_RS_START; + app_ble_core_global_callback_event(&event, NULL); #endif #ifdef BISTO_ENABLED - if (*p_buff == AI_SPEC_GSOUND) - { - gsound_tws_update_roleswitch_initiator(IBRT_SLAVE); - gsound_tws_request_roleswitch(); - } + if (*p_buff == AI_SPEC_GSOUND) { + gsound_tws_update_roleswitch_initiator(IBRT_SLAVE); + gsound_tws_request_roleswitch(); + } #endif #ifdef __AI_VOICE__ - if (*p_buff != AI_SPEC_GSOUND) - { - app_ai_tws_master_role_switch_prepare(); - } + if (*p_buff != AI_SPEC_GSOUND) { + app_ai_tws_master_role_switch_prepare(); + } #endif } -void app_tws_if_slave_continue_rs(uint8_t *p_buff, uint16_t length) -{ - TRACE(2,"%s len %d", __func__, length); - DUMP8("%x ", p_buff, length); +void app_tws_if_slave_continue_rs(uint8_t *p_buff, uint16_t length) { + TRACE(2, "%s len %d", __func__, length); + DUMP8("%x ", p_buff, length); #ifdef __AI_VOICE__ - if (*p_buff != AI_SPEC_GSOUND) - { - app_ai_tws_role_switch_prepare_done(); - } - else + if (*p_buff != AI_SPEC_GSOUND) { + app_ai_tws_role_switch_prepare_done(); + } else #endif - { - app_ibrt_if_tws_switch_prepare_done_in_bt_thread(IBRT_ROLE_SWITCH_USER_AI, (uint32_t)*p_buff); - } + { + app_ibrt_if_tws_switch_prepare_done_in_bt_thread(IBRT_ROLE_SWITCH_USER_AI, + (uint32_t)*p_buff); + } } #endif #if defined(GFPS_ENABLED) && defined(IBRT) -void app_ibrt_share_fastpair_info(uint8_t *p_buff, uint16_t length) -{ - app_ibrt_send_cmd_without_rsp(APP_TWS_CMD_SHARE_FASTPAIR_INFO, p_buff, length); +void app_ibrt_share_fastpair_info(uint8_t *p_buff, uint16_t length) { + app_ibrt_send_cmd_without_rsp(APP_TWS_CMD_SHARE_FASTPAIR_INFO, p_buff, + length); } -void app_tws_send_fastpair_info_to_slave(void) -{ - TRACE(0,"Send fastpair info to secondary device."); - NV_FP_ACCOUNT_KEY_RECORD_T *pFpData = nv_record_get_fp_data_structure_info(); - app_ibrt_share_fastpair_info(( uint8_t * )pFpData, sizeof(NV_FP_ACCOUNT_KEY_RECORD_T)); +void app_tws_send_fastpair_info_to_slave(void) { + TRACE(0, "Send fastpair info to secondary device."); + NV_FP_ACCOUNT_KEY_RECORD_T *pFpData = nv_record_get_fp_data_structure_info(); + app_ibrt_share_fastpair_info((uint8_t *)pFpData, + sizeof(NV_FP_ACCOUNT_KEY_RECORD_T)); } -void app_ibrt_shared_fastpair_info_received_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length) -{ - NV_FP_ACCOUNT_KEY_RECORD_T *pFpData = ( NV_FP_ACCOUNT_KEY_RECORD_T * )p_buff; - nv_record_update_fp_data_structure(pFpData); +void app_ibrt_shared_fastpair_info_received_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length) { + NV_FP_ACCOUNT_KEY_RECORD_T *pFpData = (NV_FP_ACCOUNT_KEY_RECORD_T *)p_buff; + nv_record_update_fp_data_structure(pFpData); } #endif #ifdef IBRT -bool app_tws_is_master_mode(void) -{ - return (IBRT_MASTER == app_tws_ibrt_role_get_callback(NULL))?true:false; +bool app_tws_is_master_mode(void) { + return (IBRT_MASTER == app_tws_ibrt_role_get_callback(NULL)) ? true : false; } -bool app_tws_is_slave_mode(void) -{ - return (IBRT_SLAVE == app_tws_ibrt_role_get_callback(NULL))?true:false; +bool app_tws_is_slave_mode(void) { + return (IBRT_SLAVE == app_tws_ibrt_role_get_callback(NULL)) ? true : false; } -bool app_tws_is_freeman_mode(void) -{ - return (IBRT_UNKNOW == app_tws_ibrt_role_get_callback(NULL))?true:false; +bool app_tws_is_freeman_mode(void) { + return (IBRT_UNKNOW == app_tws_ibrt_role_get_callback(NULL)) ? true : false; } -bool app_tws_nv_is_master_role(void) -{ - TRACE(1, "[ZYH]%s -> %d",__func__,app_tws_ibrt_nv_role_get_callback(NULL)); - return (IBRT_MASTER == app_tws_ibrt_nv_role_get_callback(NULL))?true:false; +bool app_tws_nv_is_master_role(void) { + TRACE(1, "[ZYH]%s -> %d", __func__, app_tws_ibrt_nv_role_get_callback(NULL)); + return (IBRT_MASTER == app_tws_ibrt_nv_role_get_callback(NULL)) ? true + : false; } - -void app_ibrt_sync_volume_info(void) -{ - if(app_tws_ibrt_tws_link_connected()) - { - ibrt_volume_info_t ibrt_volume_req; - ibrt_volume_req.a2dp_volume = a2dp_volume_get(BT_DEVICE_ID_1); - ibrt_volume_req.hfp_volume = hfp_volume_get(BT_DEVICE_ID_1); - tws_ctrl_send_cmd(APP_TWS_CMD_SYNC_VOLUME_INFO,(uint8_t*)&ibrt_volume_req, sizeof(ibrt_volume_req)); - } +void app_ibrt_sync_volume_info(void) { + if (app_tws_ibrt_tws_link_connected()) { + ibrt_volume_info_t ibrt_volume_req; + ibrt_volume_req.a2dp_volume = a2dp_volume_get(BT_DEVICE_ID_1); + ibrt_volume_req.hfp_volume = hfp_volume_get(BT_DEVICE_ID_1); + tws_ctrl_send_cmd(APP_TWS_CMD_SYNC_VOLUME_INFO, (uint8_t *)&ibrt_volume_req, + sizeof(ibrt_volume_req)); + } } static APP_TWS_SIDE_T app_tws_side = EAR_SIDE_UNKNOWN; -void app_tws_set_side(APP_TWS_SIDE_T side) -{ - ASSERT((EAR_SIDE_LEFT == side) || (EAR_SIDE_RIGHT == side), "Error: setting invalid side"); - TRACE(1,"Set TWS side to %d",side); - app_tws_side = side; +void app_tws_set_side(APP_TWS_SIDE_T side) { + ASSERT((EAR_SIDE_LEFT == side) || (EAR_SIDE_RIGHT == side), + "Error: setting invalid side"); + TRACE(1, "Set TWS side to %d", side); + app_tws_side = side; } -bool app_tws_is_left_side(void) -{ - return (app_tws_side == EAR_SIDE_LEFT); -} +bool app_tws_is_left_side(void) { return (app_tws_side == EAR_SIDE_LEFT); } -bool app_tws_is_right_side(void) -{ - return (app_tws_side == EAR_SIDE_RIGHT); -} +bool app_tws_is_right_side(void) { return (app_tws_side == EAR_SIDE_RIGHT); } -bool app_tws_is_unknown_side(void) -{ - return (app_tws_side == EAR_SIDE_UNKNOWN); +bool app_tws_is_unknown_side(void) { + return (app_tws_side == EAR_SIDE_UNKNOWN); } // void app_tws_set_side_from_addr(uint8_t *addr) @@ -694,13 +648,11 @@ bool app_tws_is_unknown_side(void) // } // } -void app_tws_set_side_from_gpio(void) -{ - if (tgt_tws_get_channel_is_right()){ - app_tws_set_side(EAR_SIDE_RIGHT); - }else { - app_tws_set_side(EAR_SIDE_LEFT); - } +void app_tws_set_side_from_gpio(void) { + if (tgt_tws_get_channel_is_right()) { + app_tws_set_side(EAR_SIDE_RIGHT); + } else { + app_tws_set_side(EAR_SIDE_LEFT); + } } #endif - diff --git a/services/audio_dump/include/audio_dump.h b/services/audio_dump/include/audio_dump.h index bee8707..c9a7f4a 100644 --- a/services/audio_dump/include/audio_dump.h +++ b/services/audio_dump/include/audio_dump.h @@ -15,6 +15,8 @@ ****************************************************************************/ #ifndef __AUDIO_DUMP_H__ #define __AUDIO_DUMP_H__ +#include +#include #ifdef __cplusplus extern "C" { @@ -27,7 +29,10 @@ extern "C" { void audio_dump_init(int frame_len, int sample_bytes, int channel_num); void audio_dump_deinit(void); void audio_dump_clear_up(void); -void audio_dump_add_channel_data_from_multi_channels(int channel_id, void *pcm_buf, int pcm_len, int channel_num, int channel_index); +void audio_dump_add_channel_data_from_multi_channels(int channel_id, + void *pcm_buf, int pcm_len, + int channel_num, + int channel_index); void audio_dump_add_channel_data(int channel_id, void *pcm_buf, int pcm_len); void audio_dump_run(void); diff --git a/services/audio_dump/src/audio_dump.c b/services/audio_dump/src/audio_dump.c index dabfe31..70c00e7 100644 --- a/services/audio_dump/src/audio_dump.c +++ b/services/audio_dump/src/audio_dump.c @@ -13,8 +13,8 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "hal_trace.h" #include "audio_dump.h" +#include "hal_trace.h" #include "string.h" #ifdef AUDIO_DEBUG_V0_1_0 @@ -27,16 +27,20 @@ #endif #ifdef AUDIO_DUMP -#define AUDIO_DUMP_HEAD_STR ("[audio dump]") -#define AUDIO_DUMP_HEAD_LEN (sizeof(AUDIO_DUMP_HEAD_STR)-1) -#define AUDIO_DUMP_INDEX_LEN (4) -#define AUDIO_DUMP_CRC_LEN (4) -#define AUDIO_DUMP_DATA_LEN (4) -#define AUDIO_DUMP_MAX_SAMPLE_BYTES (sizeof(int)) -#define AUDIO_DUMP_MAX_FRAME_LEN (512) -#define AUDIO_DUMP_MAX_CHANNEL_NUM (8) -#define AUDIO_DUMP_MAX_DATA_SIZE (AUDIO_DUMP_MAX_FRAME_LEN * AUDIO_DUMP_MAX_CHANNEL_NUM * AUDIO_DUMP_MAX_SAMPLE_BYTES / sizeof(char)) -#define AUDIO_DUMP_BUFFER_SIZE (AUDIO_DUMP_HEAD_LEN + AUDIO_DUMP_INDEX_LEN + AUDIO_DUMP_CRC_LEN + AUDIO_DUMP_DATA_LEN + AUDIO_DUMP_MAX_DATA_SIZE) +#define AUDIO_DUMP_HEAD_STR ("[audio dump]") +#define AUDIO_DUMP_HEAD_LEN (sizeof(AUDIO_DUMP_HEAD_STR) - 1) +#define AUDIO_DUMP_INDEX_LEN (4) +#define AUDIO_DUMP_CRC_LEN (4) +#define AUDIO_DUMP_DATA_LEN (4) +#define AUDIO_DUMP_MAX_SAMPLE_BYTES (sizeof(int)) +#define AUDIO_DUMP_MAX_FRAME_LEN (512) +#define AUDIO_DUMP_MAX_CHANNEL_NUM (8) +#define AUDIO_DUMP_MAX_DATA_SIZE \ + (AUDIO_DUMP_MAX_FRAME_LEN * AUDIO_DUMP_MAX_CHANNEL_NUM * \ + AUDIO_DUMP_MAX_SAMPLE_BYTES / sizeof(char)) +#define AUDIO_DUMP_BUFFER_SIZE \ + (AUDIO_DUMP_HEAD_LEN + AUDIO_DUMP_INDEX_LEN + AUDIO_DUMP_CRC_LEN + \ + AUDIO_DUMP_DATA_LEN + AUDIO_DUMP_MAX_DATA_SIZE) static int audio_dump_index = 0; static int audio_dump_crc = 0; @@ -49,108 +53,107 @@ static char *audio_dump_data_ptr = NULL; static char audio_dump_buf[AUDIO_DUMP_BUFFER_SIZE]; #endif -void audio_dump_clear_up(void) -{ +void audio_dump_clear_up(void) { #ifdef AUDIO_DUMP - memset(audio_dump_data_ptr, 0, audio_dump_data_size); + memset(audio_dump_data_ptr, 0, audio_dump_data_size); #endif } -void audio_dump_init(int frame_len, int sample_bytes, int channel_num) -{ +void audio_dump_init(int frame_len, int sample_bytes, int channel_num) { #ifdef AUDIO_DUMP - ASSERT(frame_len <= AUDIO_DUMP_MAX_FRAME_LEN, "[%s] frame_len(%d) is invalid", __func__, frame_len); - ASSERT(sample_bytes <= AUDIO_DUMP_MAX_SAMPLE_BYTES, "[%s] sample_bytes(%d) is invalid", __func__, sample_bytes); - ASSERT(channel_num <= AUDIO_DUMP_MAX_CHANNEL_NUM, "[%s] channel_num(%d) is invalid", __func__, channel_num); + ASSERT(frame_len <= AUDIO_DUMP_MAX_FRAME_LEN, "[%s] frame_len(%d) is invalid", + __func__, frame_len); + ASSERT(sample_bytes <= AUDIO_DUMP_MAX_SAMPLE_BYTES, + "[%s] sample_bytes(%d) is invalid", __func__, sample_bytes); + ASSERT(channel_num <= AUDIO_DUMP_MAX_CHANNEL_NUM, + "[%s] channel_num(%d) is invalid", __func__, channel_num); - char *buf_ptr = audio_dump_buf; - audio_dump_index = 0; - audio_dump_crc = 0; - audio_dump_frame_len = frame_len; - audio_dump_sample_bytes = sample_bytes / sizeof(char); - audio_dump_channel_num = channel_num; + char *buf_ptr = audio_dump_buf; + audio_dump_index = 0; + audio_dump_crc = 0; + audio_dump_frame_len = frame_len; + audio_dump_sample_bytes = sample_bytes / sizeof(char); + audio_dump_channel_num = channel_num; - memcpy(buf_ptr, AUDIO_DUMP_HEAD_STR, AUDIO_DUMP_HEAD_LEN); + memcpy(buf_ptr, AUDIO_DUMP_HEAD_STR, AUDIO_DUMP_HEAD_LEN); #ifdef DUMP_PLC_ENABLE - buf_ptr += AUDIO_DUMP_HEAD_LEN + AUDIO_DUMP_INDEX_LEN + AUDIO_DUMP_CRC_LEN; + buf_ptr += AUDIO_DUMP_HEAD_LEN + AUDIO_DUMP_INDEX_LEN + AUDIO_DUMP_CRC_LEN; #else - buf_ptr += AUDIO_DUMP_HEAD_LEN; + buf_ptr += AUDIO_DUMP_HEAD_LEN; #endif - int *data_len = (int *)buf_ptr; - *data_len = frame_len * channel_num * audio_dump_sample_bytes; - audio_dump_data_size = *data_len; + int *data_len = (int *)buf_ptr; + *data_len = frame_len * channel_num * audio_dump_sample_bytes; + audio_dump_data_size = *data_len; #ifdef DUMP_PLC_ENABLE - audio_dump_buf_size = AUDIO_DUMP_HEAD_LEN + AUDIO_DUMP_INDEX_LEN + AUDIO_DUMP_CRC_LEN + AUDIO_DUMP_DATA_LEN + audio_dump_data_size; + audio_dump_buf_size = AUDIO_DUMP_HEAD_LEN + AUDIO_DUMP_INDEX_LEN + + AUDIO_DUMP_CRC_LEN + AUDIO_DUMP_DATA_LEN + + audio_dump_data_size; #else - audio_dump_buf_size = AUDIO_DUMP_HEAD_LEN + AUDIO_DUMP_DATA_LEN + audio_dump_data_size; + audio_dump_buf_size = + AUDIO_DUMP_HEAD_LEN + AUDIO_DUMP_DATA_LEN + audio_dump_data_size; #endif - buf_ptr += AUDIO_DUMP_DATA_LEN; + buf_ptr += AUDIO_DUMP_DATA_LEN; - audio_dump_data_ptr = buf_ptr; + audio_dump_data_ptr = buf_ptr; - audio_dump_clear_up(); + audio_dump_clear_up(); #endif } -void audio_dump_deinit(void) -{ - ; -} +void audio_dump_deinit(void) { ; } -void audio_dump_add_channel_data_from_multi_channels(int channel_id, void *pcm_buf, int pcm_len, int channel_num, int channel_index) -{ +void audio_dump_add_channel_data_from_multi_channels(int channel_id, + void *pcm_buf, int pcm_len, + int channel_num, + int channel_index) { #ifdef AUDIO_DUMP - ASSERT(audio_dump_frame_len >= pcm_len, "[%s] frame_len(%d) < pcm_len(%d)", __func__, audio_dump_frame_len, pcm_len); + ASSERT(audio_dump_frame_len >= pcm_len, "[%s] frame_len(%d) < pcm_len(%d)", + __func__, audio_dump_frame_len, pcm_len); - if (channel_id >= audio_dump_channel_num) - { - return; - } + if (channel_id >= audio_dump_channel_num) { + return; + } - if (audio_dump_sample_bytes == sizeof(short)) - { - short *_pcm_buf = (short *)pcm_buf; - short *_dump_buf = (short *)audio_dump_data_ptr; + if (audio_dump_sample_bytes == sizeof(short)) { + short *_pcm_buf = (short *)pcm_buf; + short *_dump_buf = (short *)audio_dump_data_ptr; - for (int i = 0; i < pcm_len; i++) - { - _dump_buf[audio_dump_channel_num * i + channel_id] = _pcm_buf[i * channel_num + channel_index]; - } + for (int i = 0; i < pcm_len; i++) { + _dump_buf[audio_dump_channel_num * i + channel_id] = + _pcm_buf[i * channel_num + channel_index]; } - else if (audio_dump_sample_bytes == sizeof(int)) - { - int *_pcm_buf = (int *)pcm_buf; - int *_dump_buf = (int *)audio_dump_data_ptr; + } else if (audio_dump_sample_bytes == sizeof(int)) { + int *_pcm_buf = (int *)pcm_buf; + int *_dump_buf = (int *)audio_dump_data_ptr; - for (int i = 0; i < pcm_len; i++) - { - _dump_buf[audio_dump_channel_num * i + channel_id] = _pcm_buf[i * channel_num + channel_index]; - } - } - else - { - ASSERT(0, "[%s] audio_dump_sample_bytes(%d) is invalid", __func__, audio_dump_sample_bytes); + for (int i = 0; i < pcm_len; i++) { + _dump_buf[audio_dump_channel_num * i + channel_id] = + _pcm_buf[i * channel_num + channel_index]; } + } else { + ASSERT(0, "[%s] audio_dump_sample_bytes(%d) is invalid", __func__, + audio_dump_sample_bytes); + } #endif } -void audio_dump_add_channel_data(int channel_id, void *pcm_buf, int pcm_len) -{ - audio_dump_add_channel_data_from_multi_channels(channel_id, pcm_buf, pcm_len, 1, 0); +void audio_dump_add_channel_data(int channel_id, void *pcm_buf, int pcm_len) { + audio_dump_add_channel_data_from_multi_channels(channel_id, pcm_buf, pcm_len, + 1, 0); } #ifdef DUMP_PLC_ENABLE -static void audio_debug_add_index(void) -{ - int *index_ptr = (int *)(audio_dump_buf + AUDIO_DUMP_HEAD_LEN); +static void audio_debug_add_index(void) { + int *index_ptr = (int *)(audio_dump_buf + AUDIO_DUMP_HEAD_LEN); - *index_ptr = audio_dump_index; + *index_ptr = audio_dump_index; } -// unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned int len) +// unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned int +// len) // { // unsigned long c; @@ -165,114 +168,118 @@ static void audio_debug_add_index(void) // return c ^ 0xffffffffL; // } -static void audio_debug_add_crc(void) -{ - int *crc_ptr = (int *)(audio_dump_buf + AUDIO_DUMP_HEAD_LEN + AUDIO_DUMP_CRC_LEN); +static void audio_debug_add_crc(void) { + int *crc_ptr = + (int *)(audio_dump_buf + AUDIO_DUMP_HEAD_LEN + AUDIO_DUMP_CRC_LEN); - *crc_ptr = 0; + *crc_ptr = 0; } #endif -void audio_dump_run(void) -{ +void audio_dump_run(void) { #ifdef AUDIO_DUMP #ifdef DATA_DUMP_TOTA - int offset = AUDIO_DUMP_HEAD_LEN + AUDIO_DUMP_DATA_LEN; + int offset = AUDIO_DUMP_HEAD_LEN + AUDIO_DUMP_DATA_LEN; #ifdef DUMP_PLC_ENABLE - offset += AUDIO_DUMP_INDEX_LEN + AUDIO_DUMP_CRC_LEN; + offset += AUDIO_DUMP_INDEX_LEN + AUDIO_DUMP_CRC_LEN; #endif - app_tota_audio_dump_send((uint8_t *)&audio_dump_buf[offset], audio_dump_buf_size - offset); + app_tota_audio_dump_send((uint8_t *)&audio_dump_buf[offset], + audio_dump_buf_size - offset); #else #ifdef DUMP_PLC_ENABLE - audio_debug_add_index(); - audio_debug_add_crc(); - audio_dump_index++; + audio_debug_add_index(); + audio_debug_add_crc(); + audio_dump_index++; - // if (audio_dump_index % 20 == 0) - // { - // audio_dump_index++; - // } + // if (audio_dump_index % 20 == 0) + // { + // audio_dump_index++; + // } #endif - AUDIO_DEBUG_DUMP((const unsigned char *)audio_dump_buf, audio_dump_buf_size); + AUDIO_DEBUG_DUMP((const unsigned char *)audio_dump_buf, audio_dump_buf_size); #endif #endif } #ifdef AUDIO_DUMP // Make sure DATA_DUMP_BUF_SIZE < TRACE_BUF_SIZE -#define DATA_DUMP_BUF_SIZE (1024 * 6) +#define DATA_DUMP_BUF_SIZE (1024 * 6) static uint8_t data_dump_buf[DATA_DUMP_BUF_SIZE]; static int data_dump_index = 0; #endif -void data_dump_init(void) -{ +void data_dump_init(void) { #ifdef AUDIO_DUMP - data_dump_index = 0; + data_dump_index = 0; #endif } -void data_dump_deinit(void) -{ - ; -} +void data_dump_deinit(void) { ; } -void data_dump_run(const char *str, void *data_buf, uint32_t data_len) -{ +void data_dump_run(const char *str, void *data_buf, uint32_t data_len) { #ifdef AUDIO_DUMP - uint8_t *buf_ptr = data_dump_buf; - uint32_t len = 0; + uint8_t *buf_ptr = data_dump_buf; + uint32_t len = 0; - // head - memcpy(buf_ptr + len, str, strlen(str)); - len += strlen(str); + // head + memcpy(buf_ptr + len, str, strlen(str)); + len += strlen(str); #ifdef DUMP_PLC_ENABLE - int32_t *int_ptr = NULL; + int32_t *int_ptr = NULL; - // index - int_ptr = (int32_t *)(buf_ptr + len); - *int_ptr = data_dump_index; - len += sizeof(int32_t); + // index + int_ptr = (int32_t *)(buf_ptr + len); + *int_ptr = data_dump_index; + len += sizeof(int32_t); - // crc - int_ptr = (int32_t *)(buf_ptr + len); - *int_ptr = 0; - len += sizeof(int32_t); - - data_dump_index++; + // crc + int_ptr = (int32_t *)(buf_ptr + len); + *int_ptr = 0; + len += sizeof(int32_t); - // if (data_dump_index % 20 == 0) - // { - // data_dump_index++; - // } + data_dump_index++; + + // if (data_dump_index % 20 == 0) + // { + // data_dump_index++; + // } #endif - // length - memcpy(buf_ptr + len, &data_len, sizeof(uint32_t)); - len += sizeof(uint32_t); + // length + memcpy(buf_ptr + len, &data_len, sizeof(uint32_t)); + len += sizeof(uint32_t); - // data - memcpy(buf_ptr + len, (uint8_t *)data_buf, data_len); - len += data_len; + // data + memcpy(buf_ptr + len, (uint8_t *)data_buf, data_len); + len += data_len; - ASSERT(len < DATA_DUMP_BUF_SIZE, "[%s] len(%d) > DATA_DUMP_BUF_SIZE", __func__, len); + ASSERT(len < DATA_DUMP_BUF_SIZE, "[%s] len(%d) > DATA_DUMP_BUF_SIZE", + __func__, len); - // TRACE(5,"[%s] %d, %d, %d, %d", __func__, strlen(str), sizeof(uint32_t), data_len, len); - AUDIO_DEBUG_DUMP(buf_ptr, len); + // TRACE(5,"[%s] %d, %d, %d, %d", __func__, strlen(str), sizeof(uint32_t), + // data_len, len); + AUDIO_DEBUG_DUMP(buf_ptr, len); #endif } #else // AUDIO_DEBUG -void audio_dump_clear_up(void) {;} -void audio_dump_init(int frame_len, int sample_bytes, int channel_num) {;} -void audio_dump_deinit(void) {;} -void audio_dump_add_channel_data_from_multi_channels(int channel_id, void *pcm_buf, int pcm_len, int channel_num, int channel_index) {;} -void audio_dump_add_channel_data(int channel_id, void *pcm_buf, int pcm_len) {;} -void audio_dump_run(void) {;} -void data_dump_init(void) {;} -void data_dump_deinit(void) {;} -void data_dump_run(const char *str, void *data_buf, uint32_t data_len) {;} +void audio_dump_clear_up(void) { ; } +void audio_dump_init(int frame_len, int sample_bytes, int channel_num) { ; } +void audio_dump_deinit(void) { ; } +void audio_dump_add_channel_data_from_multi_channels(int channel_id, + void *pcm_buf, int pcm_len, + int channel_num, + int channel_index) { + ; +} +void audio_dump_add_channel_data(int channel_id, void *pcm_buf, int pcm_len) { + ; +} +void audio_dump_run(void) { ; } +void data_dump_init(void) { ; } +void data_dump_deinit(void) { ; } +void data_dump_run(const char *str, void *data_buf, uint32_t data_len) { ; } #endif diff --git a/services/audio_process/audio_cfg.c b/services/audio_process/audio_cfg.c index 454dc99..a45a95f 100644 --- a/services/audio_process/audio_cfg.c +++ b/services/audio_process/audio_cfg.c @@ -14,97 +14,78 @@ * ****************************************************************************/ #include "audio_cfg.h" -#include "iir_process.h" -#include "drc.h" -#include "limiter.h" #include "aud_section.h" -#include "string.h" +#include "drc.h" #include "hal_trace.h" +#include "iir_process.h" +#include "limiter.h" +#include "string.h" +#define TOOL_SUPPORT_MAX_IIR_EQ_BAND_NUM (20) -#define TOOL_SUPPORT_MAX_IIR_EQ_BAND_NUM (20) - -struct AUDIO_CFG_T_{ - IIR_CFG_T iir_eq; // Now just support one type - IIR_PARAM_T reserved[TOOL_SUPPORT_MAX_IIR_EQ_BAND_NUM - IIR_PARAM_NUM]; - DrcConfig drc; - LimiterConfig limiter; +struct AUDIO_CFG_T_ { + IIR_CFG_T iir_eq; // Now just support one type + IIR_PARAM_T reserved[TOOL_SUPPORT_MAX_IIR_EQ_BAND_NUM - IIR_PARAM_NUM]; + DrcConfig drc; + LimiterConfig limiter; }; typedef struct { - uint8_t reserved[AUDIO_SECTION_CFG_RESERVED_LEN]; - AUDIO_CFG_T cfg; + uint8_t reserved[AUDIO_SECTION_CFG_RESERVED_LEN]; + AUDIO_CFG_T cfg; } AUDIO_SECTION_AUDIO_CFG_T; static AUDIO_SECTION_AUDIO_CFG_T audio_section_audio_cfg; // Can not use sizeof(AUDIO_CFG_T), so define this function -int sizeof_audio_cfg(void) -{ - return sizeof(AUDIO_CFG_T); -} +int sizeof_audio_cfg(void) { return sizeof(AUDIO_CFG_T); } -int store_audio_cfg_into_audio_section(AUDIO_CFG_T *cfg) -{ - int res = 0; +int store_audio_cfg_into_audio_section(AUDIO_CFG_T *cfg) { + int res = 0; - memcpy(&audio_section_audio_cfg.cfg, cfg, sizeof(AUDIO_CFG_T)); + memcpy(&audio_section_audio_cfg.cfg, cfg, sizeof(AUDIO_CFG_T)); - res = audio_section_store_cfg(AUDIO_SECTION_DEVICE_AUDIO, + res = audio_section_store_cfg(AUDIO_SECTION_DEVICE_AUDIO, (uint8_t *)&audio_section_audio_cfg, sizeof(AUDIO_SECTION_AUDIO_CFG_T)); + if (res) { + TRACE(2, "[%s] ERROR: res = %d", __func__, res); + } else { + TRACE(1, "[%s] Store audio cfg into audio section!!!", __func__); + } - if(res) - { - TRACE(2,"[%s] ERROR: res = %d", __func__, res); - } - else - { - TRACE(1,"[%s] Store audio cfg into audio section!!!", __func__); - } - - return res; + return res; } -void *load_audio_cfg_from_audio_section(enum AUDIO_PROCESS_TYPE_T type) -{ - ASSERT(type < AUDIO_PROCESS_TYPE_NUM, "[%s] type(%d) is invalid", __func__, type); - int res = 0; - res = audio_section_load_cfg(AUDIO_SECTION_DEVICE_AUDIO, - (uint8_t *)&audio_section_audio_cfg, - sizeof(AUDIO_SECTION_AUDIO_CFG_T)); +void *load_audio_cfg_from_audio_section(enum AUDIO_PROCESS_TYPE_T type) { + ASSERT(type < AUDIO_PROCESS_TYPE_NUM, "[%s] type(%d) is invalid", __func__, + type); + int res = 0; + res = audio_section_load_cfg(AUDIO_SECTION_DEVICE_AUDIO, + (uint8_t *)&audio_section_audio_cfg, + sizeof(AUDIO_SECTION_AUDIO_CFG_T)); - void *res_ptr = NULL; + void *res_ptr = NULL; - if (res) - { - TRACE(2,"[%s] ERROR: res = %d", __func__, res); - res_ptr = NULL; - } - else - { - if (type == AUDIO_PROCESS_TYPE_IIR_EQ) - { - TRACE(1,"[%s] Load iir_eq from audio section!!!", __func__); - res_ptr = (void *)&audio_section_audio_cfg.cfg.iir_eq; - } - else if (type == AUDIO_PROCESS_TYPE_DRC) - { - TRACE(1,"[%s] Load drc from audio section!!!", __func__); - res_ptr = (void *)&audio_section_audio_cfg.cfg.drc; - } - else if (type == AUDIO_PROCESS_TYPE_LIMITER) - { - TRACE(1,"[%s] Load limiter from audio section!!!", __func__); - res_ptr = (void *)&audio_section_audio_cfg.cfg.limiter; - } - else - { - TRACE(2,"[%s] ERROR: Invalid type(%d)", __func__, type); - res_ptr = NULL; - } + if (res) { + TRACE(2, "[%s] ERROR: res = %d", __func__, res); + res_ptr = NULL; + } else { + if (type == AUDIO_PROCESS_TYPE_IIR_EQ) { + TRACE(1, "[%s] Load iir_eq from audio section!!!", __func__); + res_ptr = (void *)&audio_section_audio_cfg.cfg.iir_eq; + } else if (type == AUDIO_PROCESS_TYPE_DRC) { + TRACE(1, "[%s] Load drc from audio section!!!", __func__); + res_ptr = (void *)&audio_section_audio_cfg.cfg.drc; + } else if (type == AUDIO_PROCESS_TYPE_LIMITER) { + TRACE(1, "[%s] Load limiter from audio section!!!", __func__); + res_ptr = (void *)&audio_section_audio_cfg.cfg.limiter; + } else { + TRACE(2, "[%s] ERROR: Invalid type(%d)", __func__, type); + res_ptr = NULL; } + } - return res_ptr; + return res_ptr; } diff --git a/services/audio_process/audio_process.c b/services/audio_process/audio_process.c index 4070f17..9eee2d1 100644 --- a/services/audio_process/audio_process.c +++ b/services/audio_process/audio_process.c @@ -15,7 +15,8 @@ ****************************************************************************/ /******************************************************************************* ** namer : Audio Process -** description : Manage auido process algorithms, include :hw iir eq, sw iir eq, +** description : Manage auido process algorithms, include :hw iir eq, sw iir +*eq, ** hw fir eq, drc... ** version : V1.0 ** author : Yunjie Huo @@ -30,13 +31,14 @@ Audio Flow: DECODE --> SW IIR EQ --> DRC --> LIMTER --> VOLUME --> HW IIR EQ --> SPK +-----------------------------+ - | DAC | - | | -+--------+ +-----------+ +-----+ +--------+ | +--------+ +-----------+ | +-----+ -| | PCM | | | | | | | | | | | | | | -| DECODE +---->+ SW IIR EQ +--->+ DRC +--->+ LIMTER +--->+ VOLUME +--->+ HW IIR EQ +--->+ SPK | -| | | | | | | | | | | | | | | | -+--------+ +-----------+ +-----+ +--------+ | +--------+ +-----------+ | +-----+ + | DAC | | | ++--------+ +-----------+ +-----+ +--------+ | +--------+ ++-----------+ | +-----+ | | PCM | | | | | | +| | | | | | | | | DECODE +---->+ SW IIR EQ +--->+ DRC ++--->+ LIMTER +--->+ VOLUME +--->+ HW IIR EQ +--->+ SPK | | | | | | +| | | | | | | | | | | ++--------+ +-----------+ +-----+ +--------+ | +--------+ ++-----------+ | +-----+ +-----------------------------+ | ------------ | ------------------------- | -------- | ----------- | @@ -47,23 +49,24 @@ Audio Flow: | EQ | Equalizer | 1M/band | Almost zero | */ +#include "audio_process.h" +#include "audio_cfg.h" +#include "drc.h" +#include "hal_cmu.h" +#include "hal_location.h" #include "hal_timer.h" #include "hal_trace.h" -#include "hal_cmu.h" -#include "string.h" -#include "audio_process.h" -#include "stdbool.h" -#include "hal_location.h" #include "hw_codec_iir_process.h" #include "hw_iir_process.h" -#include "tgt_hardware.h" -#include "drc.h" #include "limiter.h" -#include "audio_cfg.h" +#include "stdbool.h" +#include "string.h" +#include "tgt_hardware.h" #if defined(USB_EQ_TUNING) #if !defined(__HW_DAC_IIR_EQ_PROCESS__) && !defined(__SW_IIR_EQ_PROCESS__) -#error "Either HW_DAC_IIR_EQ_PROCESS or SW_IIR_EQ_PROCESS should be defined when enabling USB_EQ_TUNING" +#error \ + "Either HW_DAC_IIR_EQ_PROCESS or SW_IIR_EQ_PROCESS should be defined when enabling USB_EQ_TUNING" #endif #endif @@ -97,19 +100,21 @@ Audio Flow: #endif #if defined(__SW_IIR_EQ_PROCESS__) -extern const IIR_CFG_T * const audio_eq_sw_iir_cfg_list[EQ_SW_IIR_LIST_NUM]; +extern const IIR_CFG_T *const audio_eq_sw_iir_cfg_list[EQ_SW_IIR_LIST_NUM]; #endif #if defined(__HW_DAC_IIR_EQ_PROCESS__) -extern const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_dac_iir_cfg_list[EQ_HW_DAC_IIR_LIST_NUM]; +extern const IIR_CFG_T *const POSSIBLY_UNUSED + audio_eq_hw_dac_iir_cfg_list[EQ_HW_DAC_IIR_LIST_NUM]; #endif #if defined(__HW_IIR_EQ_PROCESS__) -extern const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_iir_cfg_list[EQ_HW_IIR_LIST_NUM]; +extern const IIR_CFG_T *const POSSIBLY_UNUSED + audio_eq_hw_iir_cfg_list[EQ_HW_IIR_LIST_NUM]; #endif #ifdef __HW_FIR_EQ_PROCESS__ -extern const FIR_CFG_T * const audio_eq_hw_fir_cfg_list[EQ_HW_FIR_LIST_NUM]; +extern const FIR_CFG_T *const audio_eq_hw_fir_cfg_list[EQ_HW_FIR_LIST_NUM]; #endif #ifdef __AUDIO_DRC__ @@ -120,18 +125,22 @@ extern const DrcConfig audio_drc_cfg; extern const LimiterConfig audio_drc2_cfg; #endif -#if defined(AUDIO_EQ_SW_IIR_UPDATE_CFG) || defined(AUDIO_EQ_HW_FIR_UPDATE_CFG)|| defined(AUDIO_EQ_HW_DAC_IIR_UPDATE_CFG)|| defined(AUDIO_EQ_HW_IIR_UPDATE_CFG) || defined(AUDIO_DRC_UPDATE_CFG) || defined(AUDIO_DRC2_UPDATE_CFG) +#if defined(AUDIO_EQ_SW_IIR_UPDATE_CFG) || \ + defined(AUDIO_EQ_HW_FIR_UPDATE_CFG) || \ + defined(AUDIO_EQ_HW_DAC_IIR_UPDATE_CFG) || \ + defined(AUDIO_EQ_HW_IIR_UPDATE_CFG) || defined(AUDIO_DRC_UPDATE_CFG) || \ + defined(AUDIO_DRC2_UPDATE_CFG) #define AUDIO_UPDATE_CFG #endif #ifdef __AUDIO_DRC__ -#define AUDIO_DRC_NEEDED_SIZE (1024*13) +#define AUDIO_DRC_NEEDED_SIZE (1024 * 13) #else #define AUDIO_DRC_NEEDED_SIZE (0) #endif #ifdef __AUDIO_DRC2__ -#define AUDIO_DRC2_NEEDED_SIZE (1024*5) +#define AUDIO_DRC2_NEEDED_SIZE (1024 * 5) #else #define AUDIO_DRC2_NEEDED_SIZE (0) #endif @@ -143,79 +152,78 @@ extern const LimiterConfig audio_drc2_cfg; #endif #ifndef CODEC_OUTPUT_DEV -#define CODEC_OUTPUT_DEV CFG_HW_AUD_OUTPUT_PATH_SPEAKER_DEV +#define CODEC_OUTPUT_DEV CFG_HW_AUD_OUTPUT_PATH_SPEAKER_DEV #endif -typedef signed int pcm_24bits_t; -typedef signed short int pcm_16bits_t; +typedef signed int pcm_24bits_t; +typedef signed short int pcm_16bits_t; -typedef struct{ - enum AUD_BITS_T sample_bits; - enum AUD_SAMPRATE_T sample_rate; - enum AUD_CHANNEL_NUM_T sw_ch_num; - enum AUD_CHANNEL_NUM_T hw_ch_num; +typedef struct { + enum AUD_BITS_T sample_bits; + enum AUD_SAMPRATE_T sample_rate; + enum AUD_CHANNEL_NUM_T sw_ch_num; + enum AUD_CHANNEL_NUM_T hw_ch_num; #if defined(__SW_IIR_EQ_PROCESS__) - bool sw_iir_enable; + bool sw_iir_enable; #endif #if defined(__HW_DAC_IIR_EQ_PROCESS__) - bool hw_dac_iir_enable; + bool hw_dac_iir_enable; #endif #if defined(__HW_IIR_EQ_PROCESS__) - bool hw_iir_enable; + bool hw_iir_enable; #endif #if defined(__HW_FIR_EQ_PROCESS__) - bool hw_fir_enable; + bool hw_fir_enable; #endif #if AUDIO_MEMORY_SIZE > 0 - uint8_t *audio_heap; + uint8_t *audio_heap; #endif #ifdef __AUDIO_DRC__ - DrcState *drc_st; + DrcState *drc_st; #endif #ifdef __AUDIO_DRC2__ - LimiterState *drc2_st; + LimiterState *drc2_st; #endif #ifdef AUDIO_UPDATE_CFG - bool update_cfg; + bool update_cfg; #endif #ifdef USB_EQ_TUNING - bool eq_updated_cfg; + bool eq_updated_cfg; #endif - #ifdef AUDIO_EQ_SW_IIR_UPDATE_CFG - IIR_CFG_T sw_iir_cfg; + IIR_CFG_T sw_iir_cfg; #endif #ifdef AUDIO_EQ_HW_DAC_IIR_UPDATE_CFG - IIR_CFG_T hw_dac_iir_cfg; + IIR_CFG_T hw_dac_iir_cfg; #endif #ifdef AUDIO_EQ_HW_IIR_UPDATE_CFG - IIR_CFG_T hw_iir_cfg; + IIR_CFG_T hw_iir_cfg; #endif #ifdef AUDIO_EQ_HW_FIR_UPDATE_CFG - FIR_CFG_T hw_fir_cfg; + FIR_CFG_T hw_fir_cfg; #endif #ifdef AUDIO_DRC_UPDATE_CFG - bool drc_update; - DrcConfig drc_cfg; + bool drc_update; + DrcConfig drc_cfg; #endif #ifdef AUDIO_DRC2_UPDATE_CFG - bool drc2_update; - LimiterConfig drc2_cfg; + bool drc2_update; + LimiterConfig drc2_cfg; #endif } AUDIO_PROCESS_T; @@ -226,19 +234,19 @@ static AUDIO_PROCESS_T audio_process = { .hw_ch_num = AUD_CHANNEL_NUM_NULL, #if defined(__SW_IIR_EQ_PROCESS__) - .sw_iir_enable = false, + .sw_iir_enable = false, #endif #if defined(__HW_DAC_IIR_EQ_PROCESS__) - .hw_dac_iir_enable = false, + .hw_dac_iir_enable = false, #endif #if defined(__HW_IIR_EQ_PROCESS__) - .hw_iir_enable = false, + .hw_iir_enable = false, #endif #if defined(__HW_FIR_EQ_PROCESS__) - .hw_fir_enable = false, + .hw_fir_enable = false, #endif #ifdef AUDIO_UPDATE_CFG @@ -263,982 +271,968 @@ static AUDIO_PROCESS_T audio_process = { #ifdef AUDIO_DRC_UPDATE_CFG .drc_update = false, - .drc_cfg = { - .knee = 0, - .filter_type = {-1, -1}, - .band_num = 1, - .look_ahead_time = 0, - .band_settings = { - {0, 0, 1, 1, 1, 1}, - {0, 0, 1, 1, 1, 1}, - } - }, + .drc_cfg = {.knee = 0, + .filter_type = {-1, -1}, + .band_num = 1, + .look_ahead_time = 0, + .band_settings = + { + {0, 0, 1, 1, 1, 1}, + {0, 0, 1, 1, 1, 1}, + }}, #endif #ifdef AUDIO_DRC2_UPDATE_CFG .drc2_update = false, - .drc2_cfg = { - .knee = 0, - .look_ahead_time = 0, - .threshold = 0, - .makeup_gain = 0, - .ratio = 1000, - .attack_time = 1, - .release_time = 1, - }, + .drc2_cfg = + { + .knee = 0, + .look_ahead_time = 0, + .threshold = 0, + .makeup_gain = 0, + .ratio = 1000, + .attack_time = 1, + .release_time = 1, + }, #endif }; -int audio_eq_set_cfg(const FIR_CFG_T *fir_cfg, const IIR_CFG_T *iir_cfg, AUDIO_EQ_TYPE_T audio_eq_type) -{ -#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__)|| defined(__HW_DAC_IIR_EQ_PROCESS__)|| defined(__HW_IIR_EQ_PROCESS__) - switch (audio_eq_type) - { +int audio_eq_set_cfg(const FIR_CFG_T *fir_cfg, const IIR_CFG_T *iir_cfg, + AUDIO_EQ_TYPE_T audio_eq_type) { +#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__) || \ + defined(__HW_DAC_IIR_EQ_PROCESS__) || defined(__HW_IIR_EQ_PROCESS__) + switch (audio_eq_type) { #if defined(__SW_IIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_SW_IIR: - { - if(iir_cfg) - { - audio_process.sw_iir_enable = false; + case AUDIO_EQ_TYPE_SW_IIR: { + if (iir_cfg) { + audio_process.sw_iir_enable = false; #ifdef USB_EQ_TUNING - if (audio_process.eq_updated_cfg) { - iir_set_cfg(&audio_process.sw_iir_cfg); - } else + if (audio_process.eq_updated_cfg) { + iir_set_cfg(&audio_process.sw_iir_cfg); + } else #endif - { - iir_set_cfg(iir_cfg); - } - audio_process.sw_iir_enable = true; - } - else - { - audio_process.sw_iir_enable = false; - } - } - break; + { + iir_set_cfg(iir_cfg); + } + audio_process.sw_iir_enable = true; + } else { + audio_process.sw_iir_enable = false; + } + } break; #endif #if defined(__HW_FIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_HW_FIR: - { - if(fir_cfg) - { - audio_process.hw_fir_enable = false; - fir_set_cfg(fir_cfg); - audio_process.hw_fir_enable = true; - } - else - { - audio_process.hw_fir_enable = false; - } - } - break; + case AUDIO_EQ_TYPE_HW_FIR: { + if (fir_cfg) { + audio_process.hw_fir_enable = false; + fir_set_cfg(fir_cfg); + audio_process.hw_fir_enable = true; + } else { + audio_process.hw_fir_enable = false; + } + } break; #endif #if defined(__HW_DAC_IIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_HW_DAC_IIR: - { - if(iir_cfg) - { - HW_CODEC_IIR_CFG_T *hw_iir_cfg_dac=NULL; - enum AUD_SAMPRATE_T sample_rate_hw_dac_iir; + case AUDIO_EQ_TYPE_HW_DAC_IIR: { + if (iir_cfg) { + HW_CODEC_IIR_CFG_T *hw_iir_cfg_dac = NULL; + enum AUD_SAMPRATE_T sample_rate_hw_dac_iir; #ifdef __AUDIO_RESAMPLE__ - int i; - for(i=1;i<129;i++) - { - if(audio_process.sample_rate==AUD_SAMPRATE_7350*i)break; - if(audio_process.sample_rate==AUD_SAMPRATE_8000*i)break; - } - TRACE(1,"audio_process.sample_rate i:%d",i); - if(i==129) i=6; //set default eq parameter; - sample_rate_hw_dac_iir=i*8463.541666f;//AUD_SAMPRATE_8463 + int i; + for (i = 1; i < 129; i++) { + if (audio_process.sample_rate == AUD_SAMPRATE_7350 * i) + break; + if (audio_process.sample_rate == AUD_SAMPRATE_8000 * i) + break; + } + TRACE(1, "audio_process.sample_rate i:%d", i); + if (i == 129) + i = 6; // set default eq parameter; + sample_rate_hw_dac_iir = i * 8463.541666f; // AUD_SAMPRATE_8463 #else - sample_rate_hw_dac_iir=audio_process.sample_rate; + sample_rate_hw_dac_iir = audio_process.sample_rate; #endif - audio_process.hw_dac_iir_enable = false; + audio_process.hw_dac_iir_enable = false; #ifdef USB_EQ_TUNING - if (audio_process.eq_updated_cfg) { - hw_iir_cfg_dac = hw_codec_iir_get_cfg(sample_rate_hw_dac_iir, &audio_process.hw_dac_iir_cfg); - } else + if (audio_process.eq_updated_cfg) { + hw_iir_cfg_dac = hw_codec_iir_get_cfg(sample_rate_hw_dac_iir, + &audio_process.hw_dac_iir_cfg); + } else #endif - { - hw_iir_cfg_dac = hw_codec_iir_get_cfg(sample_rate_hw_dac_iir,iir_cfg); - } - ASSERT(hw_iir_cfg_dac != NULL, "[%s] codec IIR parameter error!", __func__); - hw_codec_iir_set_cfg(hw_iir_cfg_dac, sample_rate_hw_dac_iir, HW_CODEC_IIR_DAC); - audio_process.hw_dac_iir_enable = true; - } - else - { - audio_process.hw_dac_iir_enable = false; - } - } - break; + { + hw_iir_cfg_dac = hw_codec_iir_get_cfg(sample_rate_hw_dac_iir, iir_cfg); + } + ASSERT(hw_iir_cfg_dac != NULL, "[%s] codec IIR parameter error!", + __func__); + hw_codec_iir_set_cfg(hw_iir_cfg_dac, sample_rate_hw_dac_iir, + HW_CODEC_IIR_DAC); + audio_process.hw_dac_iir_enable = true; + } else { + audio_process.hw_dac_iir_enable = false; + } + } break; #endif #if defined(__HW_IIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_HW_IIR: - { - if(iir_cfg) - { - HW_IIR_CFG_T *hw_iir_cfg=NULL; - audio_process.hw_iir_enable = false; - hw_iir_cfg = hw_iir_get_cfg(audio_process.sample_rate,iir_cfg); - ASSERT(hw_iir_cfg != NULL,"[%s] 0x%x codec IIR parameter error!", __func__, (unsigned int)hw_iir_cfg); - hw_iir_set_cfg(hw_iir_cfg); - audio_process.hw_iir_enable = true; - } - else - { - audio_process.hw_iir_enable = false; - } - - } - break; -#endif - - default: - { - ASSERT(false,"[%s]Error eq type!",__func__); - } + case AUDIO_EQ_TYPE_HW_IIR: { + if (iir_cfg) { + HW_IIR_CFG_T *hw_iir_cfg = NULL; + audio_process.hw_iir_enable = false; + hw_iir_cfg = hw_iir_get_cfg(audio_process.sample_rate, iir_cfg); + ASSERT(hw_iir_cfg != NULL, "[%s] 0x%x codec IIR parameter error!", + __func__, (unsigned int)hw_iir_cfg); + hw_iir_set_cfg(hw_iir_cfg); + audio_process.hw_iir_enable = true; + } else { + audio_process.hw_iir_enable = false; } + + } break; #endif - return 0; + default: { + ASSERT(false, "[%s]Error eq type!", __func__); + } + } +#endif + + return 0; } -int SRAM_TEXT_LOC audio_process_run(uint8_t *buf, uint32_t len) -{ - int POSSIBLY_UNUSED pcm_len = 0; +int SRAM_TEXT_LOC audio_process_run(uint8_t *buf, uint32_t len) { + int POSSIBLY_UNUSED pcm_len = 0; - if(audio_process.sample_bits == AUD_BITS_16) - { - pcm_len = len / sizeof(pcm_16bits_t); - } - else if(audio_process.sample_bits == AUD_BITS_24) - { - pcm_len = len / sizeof(pcm_24bits_t); - } - else - { - ASSERT(0, "[%s] bits(%d) is invalid", __func__, audio_process.sample_bits); - } + if (audio_process.sample_bits == AUD_BITS_16) { + pcm_len = len / sizeof(pcm_16bits_t); + } else if (audio_process.sample_bits == AUD_BITS_24) { + pcm_len = len / sizeof(pcm_24bits_t); + } else { + ASSERT(0, "[%s] bits(%d) is invalid", __func__, audio_process.sample_bits); + } - if (audio_process.sw_ch_num == audio_process.hw_ch_num) { - // do nothing - } else if (audio_process.sw_ch_num == AUD_CHANNEL_NUM_1 && - audio_process.hw_ch_num == AUD_CHANNEL_NUM_2) { - if (audio_process.sample_bits == AUD_BITS_16) { - int16_t *pcm_buf = (int16_t *)buf; - for (uint32_t i = 0, j = 0; i < pcm_len; i += 2, j++) { - pcm_buf[j] = pcm_buf[i]; - } - } else { - int32_t *pcm_buf = (int32_t *)buf; - for (uint32_t i = 0, j = 0; i < pcm_len; i += 2, j++) { - pcm_buf[j] = pcm_buf[i]; - } - } - - pcm_len /= 2; + if (audio_process.sw_ch_num == audio_process.hw_ch_num) { + // do nothing + } else if (audio_process.sw_ch_num == AUD_CHANNEL_NUM_1 && + audio_process.hw_ch_num == AUD_CHANNEL_NUM_2) { + if (audio_process.sample_bits == AUD_BITS_16) { + int16_t *pcm_buf = (int16_t *)buf; + for (uint32_t i = 0, j = 0; i < pcm_len; i += 2, j++) { + pcm_buf[j] = pcm_buf[i]; + } } else { - ASSERT(0, "[%s] sw_ch_num(%d) or hw_ch_num(%d) is invalid", __FUNCTION__, audio_process.sw_ch_num, audio_process.hw_ch_num); + int32_t *pcm_buf = (int32_t *)buf; + for (uint32_t i = 0, j = 0; i < pcm_len; i += 2, j++) { + pcm_buf[j] = pcm_buf[i]; + } } + pcm_len /= 2; + } else { + ASSERT(0, "[%s] sw_ch_num(%d) or hw_ch_num(%d) is invalid", __FUNCTION__, + audio_process.sw_ch_num, audio_process.hw_ch_num); + } + #ifdef AUDIO_PROCESS_DUMP - int *buf32 = (int *)buf; - for(int i=0;i<1024;i++) - dump_buf[i] = buf32[2 * i]>>8; - audio_dump_clear_up(); - audio_dump_add_channel_data(0, dump_buf, 1024); + int *buf32 = (int *)buf; + for (int i = 0; i < 1024; i++) + dump_buf[i] = buf32[2 * i] >> 8; + audio_dump_clear_up(); + audio_dump_add_channel_data(0, dump_buf, 1024); #endif - //int32_t s_time,e_time; - //s_time = hal_fast_sys_timer_get(); + // int32_t s_time,e_time; + // s_time = hal_fast_sys_timer_get(); #ifdef __SW_IIR_EQ_PROCESS__ - if(audio_process.sw_iir_enable) - { - iir_run(buf, pcm_len); - } + if (audio_process.sw_iir_enable) { + iir_run(buf, pcm_len); + } #endif #ifdef __HW_FIR_EQ_PROCESS__ - if(audio_process.hw_fir_enable) - { - fir_run(buf, pcm_len); - } + if (audio_process.hw_fir_enable) { + fir_run(buf, pcm_len); + } #endif #ifdef __AUDIO_DRC__ #ifdef AUDIO_DRC_UPDATE_CFG - if(audio_process.drc_update) - { - drc_set_config(audio_process.drc_st, &audio_process.drc_cfg); - audio_process.drc_update =false; - } + if (audio_process.drc_update) { + drc_set_config(audio_process.drc_st, &audio_process.drc_cfg); + audio_process.drc_update = false; + } #endif - drc_process(audio_process.drc_st, buf, pcm_len); + drc_process(audio_process.drc_st, buf, pcm_len); #endif - //int32_t m_time = hal_fast_sys_timer_get(); + // int32_t m_time = hal_fast_sys_timer_get(); #ifdef __AUDIO_DRC2__ #ifdef AUDIO_DRC2_UPDATE_CFG - if(audio_process.drc2_update) - { - limiter_set_config(audio_process.drc2_st, &audio_process.drc2_cfg); - audio_process.drc2_update =false; - } + if (audio_process.drc2_update) { + limiter_set_config(audio_process.drc2_st, &audio_process.drc2_cfg); + audio_process.drc2_update = false; + } #endif - limiter_process(audio_process.drc2_st, buf, pcm_len); + limiter_process(audio_process.drc2_st, buf, pcm_len); #endif #ifdef __HW_IIR_EQ_PROCESS__ - if(audio_process.hw_iir_enable) - { - hw_iir_run(buf, pcm_len); - } + if (audio_process.hw_iir_enable) { + hw_iir_run(buf, pcm_len); + } #endif - if (audio_process.sw_ch_num == audio_process.hw_ch_num) { - // do nothing - } else if (audio_process.sw_ch_num == AUD_CHANNEL_NUM_1 && - audio_process.hw_ch_num == AUD_CHANNEL_NUM_2) { - if (audio_process.sample_bits == AUD_BITS_16) { - int16_t *pcm_buf = (int16_t *)buf; - for (int32_t i = pcm_len - 1, j = 2 * pcm_len - 1; i >= 0; i--, j -= 2) { - pcm_buf[j + 1] = pcm_buf[i]; - pcm_buf[j + 0] = pcm_buf[i]; - } - } else { - int32_t *pcm_buf = (int32_t *)buf; - for (int32_t i = pcm_len - 1, j = 2 * pcm_len - 2; i >= 0; i--, j -= 2) { - pcm_buf[j + 1] = pcm_buf[i]; - pcm_buf[j + 0] = pcm_buf[i]; - } - } - - pcm_len *= 2; + if (audio_process.sw_ch_num == audio_process.hw_ch_num) { + // do nothing + } else if (audio_process.sw_ch_num == AUD_CHANNEL_NUM_1 && + audio_process.hw_ch_num == AUD_CHANNEL_NUM_2) { + if (audio_process.sample_bits == AUD_BITS_16) { + int16_t *pcm_buf = (int16_t *)buf; + for (int32_t i = pcm_len - 1, j = 2 * pcm_len - 1; i >= 0; i--, j -= 2) { + pcm_buf[j + 1] = pcm_buf[i]; + pcm_buf[j + 0] = pcm_buf[i]; + } } else { - ASSERT(0, "[%s] sw_ch_num(%d) or hw_ch_num(%d) is invalid", __FUNCTION__, audio_process.sw_ch_num, audio_process.hw_ch_num); + int32_t *pcm_buf = (int32_t *)buf; + for (int32_t i = pcm_len - 1, j = 2 * pcm_len - 2; i >= 0; i--, j -= 2) { + pcm_buf[j + 1] = pcm_buf[i]; + pcm_buf[j + 0] = pcm_buf[i]; + } } + pcm_len *= 2; + } else { + ASSERT(0, "[%s] sw_ch_num(%d) or hw_ch_num(%d) is invalid", __FUNCTION__, + audio_process.sw_ch_num, audio_process.hw_ch_num); + } + #ifdef AUDIO_PROCESS_DUMP - //for(int i=0;i<1024;i++) - // dump_buf[i] = buf32[2 * i+0]>>8; - //audio_dump_add_channel_data(1, dump_buf, 1024); - audio_dump_run(); + // for(int i=0;i<1024;i++) + // dump_buf[i] = buf32[2 * i+0]>>8; + // audio_dump_add_channel_data(1, dump_buf, 1024); + audio_dump_run(); #endif - //e_time = hal_fast_sys_timer_get(); - //TRACE(4,"[%s] Sample len = %d, drc1 %d us, drc2 %d us", - // __func__, pcm_len, FAST_TICKS_TO_US(m_time - s_time), FAST_TICKS_TO_US(e_time - m_time)); + // e_time = hal_fast_sys_timer_get(); + // TRACE(4,"[%s] Sample len = %d, drc1 %d us, drc2 %d us", + // __func__, pcm_len, FAST_TICKS_TO_US(m_time - s_time), + // FAST_TICKS_TO_US(e_time - m_time)); - return 0; + return 0; } /* * frame_size stands for samples per channel */ -int audio_process_open(enum AUD_SAMPRATE_T sample_rate, enum AUD_BITS_T sample_bits, enum AUD_CHANNEL_NUM_T sw_ch_num, enum AUD_CHANNEL_NUM_T hw_ch_num, int32_t frame_size, void *eq_buf, uint32_t len) -{ - TRACE(5,"[%s] sample_rate = %d, sample_bits = %d, sw_ch_num = %d, hw_ch_num = %d", __func__, sample_rate, sample_bits, sw_ch_num, hw_ch_num); +int audio_process_open(enum AUD_SAMPRATE_T sample_rate, + enum AUD_BITS_T sample_bits, + enum AUD_CHANNEL_NUM_T sw_ch_num, + enum AUD_CHANNEL_NUM_T hw_ch_num, int32_t frame_size, + void *eq_buf, uint32_t len) { + TRACE( + 5, + "[%s] sample_rate = %d, sample_bits = %d, sw_ch_num = %d, hw_ch_num = %d", + __func__, sample_rate, sample_bits, sw_ch_num, hw_ch_num); #ifdef AUDIO_PROCESS_DUMP - audio_dump_init(1024, sizeof(short), 2); + audio_dump_init(1024, sizeof(short), 2); #endif - audio_process.sample_rate = sample_rate; - audio_process.sample_bits = sample_bits; - audio_process.sw_ch_num = sw_ch_num; - audio_process.hw_ch_num = hw_ch_num; + audio_process.sample_rate = sample_rate; + audio_process.sample_bits = sample_bits; + audio_process.sw_ch_num = sw_ch_num; + audio_process.hw_ch_num = hw_ch_num; #if defined(__HW_FIR_EQ_PROCESS__) && defined(__HW_IIR_EQ_PROCESS__) - void *fir_eq_buf = eq_buf; - uint32_t fir_len = len/2; - void *iir_eq_buf = (uint8_t *)eq_buf+fir_len; - uint32_t iir_len = len/2; + void *fir_eq_buf = eq_buf; + uint32_t fir_len = len / 2; + void *iir_eq_buf = (uint8_t *)eq_buf + fir_len; + uint32_t iir_len = len / 2; #elif defined(__HW_FIR_EQ_PROCESS__) && !defined(__HW_IIR_EQ_PROCESS__) - void *fir_eq_buf = eq_buf; - uint32_t fir_len = len; + void *fir_eq_buf = eq_buf; + uint32_t fir_len = len; #elif !defined(__HW_FIR_EQ_PROCESS__) && defined(__HW_IIR_EQ_PROCESS__) - void *iir_eq_buf = eq_buf; - uint32_t iir_len = len; + void *iir_eq_buf = eq_buf; + uint32_t iir_len = len; #endif #ifdef __SW_IIR_EQ_PROCESS__ - iir_open(sample_rate, sample_bits,sw_ch_num); + iir_open(sample_rate, sample_bits, sw_ch_num); #ifdef AUDIO_EQ_SW_IIR_UPDATE_CFG - audio_eq_set_cfg(NULL, &audio_process.sw_iir_cfg, AUDIO_EQ_TYPE_SW_IIR); + audio_eq_set_cfg(NULL, &audio_process.sw_iir_cfg, AUDIO_EQ_TYPE_SW_IIR); #endif #endif #ifdef __HW_DAC_IIR_EQ_PROCESS__ - enum AUD_SAMPRATE_T sample_rate_hw_dac_iir; + enum AUD_SAMPRATE_T sample_rate_hw_dac_iir; #ifdef __AUDIO_RESAMPLE__ - int i; - for(i=1;i<129;i++) - { - if(audio_process.sample_rate==AUD_SAMPRATE_7350*i)break; - if(audio_process.sample_rate==AUD_SAMPRATE_8000*i)break; - } - TRACE(1,"sample_rate i:%d",i); - if(i==129) i=6; //set default eq parameter; - sample_rate_hw_dac_iir=i*8463.541666f;//AUD_SAMPRATE_8463 + int i; + for (i = 1; i < 129; i++) { + if (audio_process.sample_rate == AUD_SAMPRATE_7350 * i) + break; + if (audio_process.sample_rate == AUD_SAMPRATE_8000 * i) + break; + } + TRACE(1, "sample_rate i:%d", i); + if (i == 129) + i = 6; // set default eq parameter; + sample_rate_hw_dac_iir = i * 8463.541666f; // AUD_SAMPRATE_8463 #else - sample_rate_hw_dac_iir = audio_process.sample_rate; + sample_rate_hw_dac_iir = audio_process.sample_rate; #endif - hw_codec_iir_open(sample_rate_hw_dac_iir, HW_CODEC_IIR_DAC, CODEC_OUTPUT_DEV); + hw_codec_iir_open(sample_rate_hw_dac_iir, HW_CODEC_IIR_DAC, CODEC_OUTPUT_DEV); #ifdef AUDIO_EQ_HW_DAC_IIR_UPDATE_CFG - audio_eq_set_cfg(NULL, &audio_process.hw_dac_iir_cfg, AUDIO_EQ_TYPE_HW_DAC_IIR); + audio_eq_set_cfg(NULL, &audio_process.hw_dac_iir_cfg, + AUDIO_EQ_TYPE_HW_DAC_IIR); #endif #endif #ifdef __HW_IIR_EQ_PROCESS__ - hw_iir_open(sample_rate, sample_bits, sw_ch_num, iir_eq_buf, iir_len); + hw_iir_open(sample_rate, sample_bits, sw_ch_num, iir_eq_buf, iir_len); #ifdef AUDIO_EQ_HW_IIR_UPDATE_CFG - audio_eq_set_cfg(NULL, &audio_process.hw_iir_cfg, AUDIO_EQ_TYPE_HW_IIR); + audio_eq_set_cfg(NULL, &audio_process.hw_iir_cfg, AUDIO_EQ_TYPE_HW_IIR); #endif #endif #ifdef __HW_FIR_EQ_PROCESS__ #if defined(CHIP_BEST1000) && defined(FIR_HIGHSPEED) - hal_cmu_fir_high_speed_enable(HAL_CMU_FIR_USER_EQ); + hal_cmu_fir_high_speed_enable(HAL_CMU_FIR_USER_EQ); #endif - fir_open(sample_rate, sample_bits, sw_ch_num, fir_eq_buf, fir_len); + fir_open(sample_rate, sample_bits, sw_ch_num, fir_eq_buf, fir_len); #ifdef AUDIO_EQ_HW_FIR_UPDATE_CFG - audio_eq_set_cfg(&audio_process.hw_fir_cfg, NULL, AUDIO_EQ_TYPE_HW_FIR); + audio_eq_set_cfg(&audio_process.hw_fir_cfg, NULL, AUDIO_EQ_TYPE_HW_FIR); #endif #endif #if AUDIO_MEMORY_SIZE > 0 - syspool_get_buff(&audio_process.audio_heap, AUDIO_MEMORY_SIZE); - audio_heap_init(audio_process.audio_heap, AUDIO_MEMORY_SIZE); + syspool_get_buff(&audio_process.audio_heap, AUDIO_MEMORY_SIZE); + audio_heap_init(audio_process.audio_heap, AUDIO_MEMORY_SIZE); #endif #ifdef __AUDIO_DRC__ - audio_process.drc_st = drc_create(sample_rate, frame_size, sample_bits, sw_ch_num, + audio_process.drc_st = + drc_create(sample_rate, frame_size, sample_bits, sw_ch_num, #ifdef AUDIO_DRC_UPDATE_CFG - &audio_process.drc_cfg + &audio_process.drc_cfg #else - &audio_drc_cfg + &audio_drc_cfg #endif - ); + ); #ifdef AUDIO_DRC_UPDATE_CFG - audio_process.drc_update = false; + audio_process.drc_update = false; #endif #endif #ifdef __AUDIO_DRC2__ - audio_process.drc2_st = limiter_create(sample_rate, frame_size, sample_bits, sw_ch_num, + audio_process.drc2_st = + limiter_create(sample_rate, frame_size, sample_bits, sw_ch_num, #ifdef AUDIO_DRC2_UPDATE_CFG - &audio_process.drc2_cfg + &audio_process.drc2_cfg #else - &audio_drc2_cfg + &audio_drc2_cfg #endif - ); + ); #ifdef AUDIO_DRC2_UPDATE_CFG - audio_process.drc2_update = false; + audio_process.drc2_update = false; #endif #endif #if defined(__PC_CMD_UART__) && defined(USB_AUDIO_APP) - hal_cmd_open(); + hal_cmd_open(); #endif - return 0; + return 0; } -int audio_process_close(void) -{ +int audio_process_close(void) { #ifdef __SW_IIR_EQ_PROCESS__ - audio_process.sw_iir_enable = false; - iir_close(); + audio_process.sw_iir_enable = false; + iir_close(); #endif #ifdef __HW_DAC_IIR_EQ_PROCESS__ - audio_process.hw_dac_iir_enable = false; - hw_codec_iir_close(HW_CODEC_IIR_DAC); + audio_process.hw_dac_iir_enable = false; + hw_codec_iir_close(HW_CODEC_IIR_DAC); #endif #ifdef __HW_IIR_EQ_PROCESS__ - audio_process.hw_iir_enable = false; - hw_iir_close(); + audio_process.hw_iir_enable = false; + hw_iir_close(); #endif #ifdef __HW_FIR_EQ_PROCESS__ - audio_process.hw_fir_enable = false; - fir_close(); + audio_process.hw_fir_enable = false; + fir_close(); #if defined(CHIP_BEST1000) && defined(FIR_HIGHSPEED) - hal_cmu_fir_high_speed_disable(HAL_CMU_FIR_USER_EQ); + hal_cmu_fir_high_speed_disable(HAL_CMU_FIR_USER_EQ); #endif #endif #ifdef __AUDIO_DRC__ #ifdef AUDIO_DRC_UPDATE_CFG - audio_process.drc_update = false; + audio_process.drc_update = false; #endif - drc_destroy(audio_process.drc_st); - audio_process.drc_st = NULL; + drc_destroy(audio_process.drc_st); + audio_process.drc_st = NULL; #endif #ifdef __AUDIO_DRC2__ #ifdef AUDIO_DRC2_UPDATE_CFG - audio_process.drc2_update = false; + audio_process.drc2_update = false; #endif - limiter_destroy(audio_process.drc2_st); - audio_process.drc2_st = NULL; + limiter_destroy(audio_process.drc2_st); + audio_process.drc2_st = NULL; #endif #if AUDIO_MEMORY_SIZE > 0 - size_t total = 0, used = 0, max_used = 0; - audio_memory_info(&total, &used, &max_used); - TRACE(3,"AUDIO MALLOC MEM: total - %d, used - %d, max_used - %d.", total, used, max_used); - ASSERT(used == 0, "[%s] used != 0", __func__); + size_t total = 0, used = 0, max_used = 0; + audio_memory_info(&total, &used, &max_used); + TRACE(3, "AUDIO MALLOC MEM: total - %d, used - %d, max_used - %d.", total, + used, max_used); + ASSERT(used == 0, "[%s] used != 0", __func__); #endif #if defined(__PC_CMD_UART__) && defined(USB_AUDIO_APP) - hal_cmd_close(); + hal_cmd_close(); #endif - return 0; + return 0; } #if defined(__PC_CMD_UART__) || defined(USB_EQ_TUNING) -int audio_ping_callback(uint8_t *buf, uint32_t len) -{ - //TRACE(0,""); - return 0; +int audio_ping_callback(uint8_t *buf, uint32_t len) { + // TRACE(0,""); + return 0; } #if defined(AUDIO_EQ_SW_IIR_UPDATE_CFG) && !defined(USB_EQ_TUNING) #ifndef USB_AUDIO_APP -int audio_eq_sw_iir_callback(uint8_t *buf, uint32_t len) -{ - TRACE(3,"[%s] len = %d, sizeof(struct) = %d", __func__, len, sizeof(IIR_CFG_T)); +int audio_eq_sw_iir_callback(uint8_t *buf, uint32_t len) { + TRACE(3, "[%s] len = %d, sizeof(struct) = %d", __func__, len, + sizeof(IIR_CFG_T)); - if (len != sizeof(IIR_CFG_T)) - { - return 1; - } + if (len != sizeof(IIR_CFG_T)) { + return 1; + } - memcpy(&audio_process.sw_iir_cfg, buf, sizeof(IIR_CFG_T)); - TRACE(3,"band num:%d gain0:%d, gain1:%d", - (int32_t)audio_process.sw_iir_cfg.num, - (int32_t)(audio_process.sw_iir_cfg.gain0*10), - (int32_t)(audio_process.sw_iir_cfg.gain1*10)); - for (uint8_t i = 0; igain0, rx_iir_cfg->gain1); + // TRACE(3,"[%s] left gain = %f, right gain = %f", __func__, + // rx_iir_cfg->gain0, rx_iir_cfg->gain1); - // for(int i=0; inum; i++) - // { - // TRACE(5,"[%s] iir[%d] gain = %f, f = %f, Q = %f", __func__, i, rx_iir_cfg->param[i].gain, rx_iir_cfg->param[i].fc, rx_iir_cfg->param[i].Q); - // } + // for(int i=0; inum; i++) + // { + // TRACE(5,"[%s] iir[%d] gain = %f, f = %f, Q = %f", __func__, i, + // rx_iir_cfg->param[i].gain, rx_iir_cfg->param[i].fc, + // rx_iir_cfg->param[i].Q); + // } - // audio_eq_set_cfg(NULL,(const IIR_CFG_T *)rx_iir_cfg,AUDIO_EQ_TYPE_SW_IIR); + // audio_eq_set_cfg(NULL,(const IIR_CFG_T *)rx_iir_cfg,AUDIO_EQ_TYPE_SW_IIR); - iir_update_cfg_tbl(buf, len); + iir_update_cfg_tbl(buf, len); - return 0; + return 0; } #endif #endif #ifdef AUDIO_EQ_HW_FIR_UPDATE_CFG -int audio_eq_hw_fir_callback(uint8_t *buf, uint32_t len) -{ - TRACE(3,"[%s] len = %d, sizeof(struct) = %d", __func__, len, sizeof(FIR_CFG_T)); +int audio_eq_hw_fir_callback(uint8_t *buf, uint32_t len) { + TRACE(3, "[%s] len = %d, sizeof(struct) = %d", __func__, len, + sizeof(FIR_CFG_T)); - if (len != sizeof(FIR_CFG_T)) - { - return 1; - } + if (len != sizeof(FIR_CFG_T)) { + return 1; + } - FIR_CFG_T *rx_fir_cfg = NULL; + FIR_CFG_T *rx_fir_cfg = NULL; - rx_fir_cfg = (FIR_CFG_T *)buf; + rx_fir_cfg = (FIR_CFG_T *)buf; - TRACE(3,"[%s] left gain = %d, right gain = %d", __func__, rx_fir_cfg->gain0, rx_fir_cfg->gain1); + TRACE(3, "[%s] left gain = %d, right gain = %d", __func__, rx_fir_cfg->gain0, + rx_fir_cfg->gain1); - TRACE(6,"[%s] len = %d, coef: %d, %d......%d, %d", __func__, rx_fir_cfg->len, rx_fir_cfg->coef[0], rx_fir_cfg->coef[1], rx_fir_cfg->coef[rx_fir_cfg->len-2], rx_fir_cfg->coef[rx_fir_cfg->len-1]); + TRACE(6, "[%s] len = %d, coef: %d, %d......%d, %d", __func__, rx_fir_cfg->len, + rx_fir_cfg->coef[0], rx_fir_cfg->coef[1], + rx_fir_cfg->coef[rx_fir_cfg->len - 2], + rx_fir_cfg->coef[rx_fir_cfg->len - 1]); - rx_fir_cfg->gain0 = 6; - rx_fir_cfg->gain1 = 6; + rx_fir_cfg->gain0 = 6; + rx_fir_cfg->gain1 = 6; - if(rx_fir_cfg) - { - memcpy(&audio_process.fir_cfg, rx_fir_cfg, sizeof(audio_process.fir_cfg)); - audio_process.fir_enable = true; - fir_set_cfg(&audio_process.fir_cfg); - } - else - { - audio_process.fir_enable = false; - } + if (rx_fir_cfg) { + memcpy(&audio_process.fir_cfg, rx_fir_cfg, sizeof(audio_process.fir_cfg)); + audio_process.fir_enable = true; + fir_set_cfg(&audio_process.fir_cfg); + } else { + audio_process.fir_enable = false; + } - return 0; + return 0; } #endif #ifdef AUDIO_DRC_UPDATE_CFG -int audio_drc_callback(uint8_t *buf, uint32_t len) -{ - TRACE(3,"[%s] len = %d, sizeof(struct) = %d", __func__, len, sizeof(DrcConfig)); +int audio_drc_callback(uint8_t *buf, uint32_t len) { + TRACE(3, "[%s] len = %d, sizeof(struct) = %d", __func__, len, + sizeof(DrcConfig)); - if (len != sizeof(DrcConfig)) - { - TRACE(1,"[%s] WARNING: Length is different", __func__); + if (len != sizeof(DrcConfig)) { + TRACE(1, "[%s] WARNING: Length is different", __func__); - return 1; - } + return 1; + } - if (audio_process.drc_st == NULL) - { - TRACE(1,"[%s] WARNING: audio_process.drc2_st = NULL", __func__); - TRACE(1,"[%s] WARNING: Please Play music, then tuning Limiter", __func__); + if (audio_process.drc_st == NULL) { + TRACE(1, "[%s] WARNING: audio_process.drc2_st = NULL", __func__); + TRACE(1, "[%s] WARNING: Please Play music, then tuning Limiter", __func__); - return 2; - } + return 2; + } - memcpy(&audio_process.drc_cfg, buf, sizeof(DrcConfig)); - audio_process.drc_update = true; + memcpy(&audio_process.drc_cfg, buf, sizeof(DrcConfig)); + audio_process.drc_update = true; - return 0; + return 0; } #endif #ifdef AUDIO_DRC2_UPDATE_CFG -int audio_drc2_callback(uint8_t *buf, uint32_t len) -{ - TRACE(3,"[%s] len = %d, sizeof(struct) = %d", __func__, len, sizeof(LimiterConfig)); +int audio_drc2_callback(uint8_t *buf, uint32_t len) { + TRACE(3, "[%s] len = %d, sizeof(struct) = %d", __func__, len, + sizeof(LimiterConfig)); - if (len != sizeof(LimiterConfig)) - { - TRACE(1,"[%s] WARNING: Length is different", __func__); + if (len != sizeof(LimiterConfig)) { + TRACE(1, "[%s] WARNING: Length is different", __func__); - return 1; - } + return 1; + } - if (audio_process.drc2_st == NULL) - { - TRACE(1,"[%s] WARNING: audio_process.drc2_st = NULL", __func__); - TRACE(1,"[%s] WARNING: Please Play music, then tuning Limiter", __func__); + if (audio_process.drc2_st == NULL) { + TRACE(1, "[%s] WARNING: audio_process.drc2_st = NULL", __func__); + TRACE(1, "[%s] WARNING: Please Play music, then tuning Limiter", __func__); - return 2; - } + return 2; + } - memcpy(&audio_process.drc2_cfg, buf, sizeof(LimiterConfig)); - audio_process.drc2_update = true; + memcpy(&audio_process.drc2_cfg, buf, sizeof(LimiterConfig)); + audio_process.drc2_update = true; - return 0; + return 0; } #endif #if defined(AUDIO_EQ_HW_DAC_IIR_UPDATE_CFG) && !defined(USB_EQ_TUNING) -int audio_eq_hw_dac_iir_callback(uint8_t *buf, uint32_t len) -{ - TRACE(3,"[%s] len = %d, sizeof(struct) = %d", __func__, len, sizeof(IIR_CFG_T)); +int audio_eq_hw_dac_iir_callback(uint8_t *buf, uint32_t len) { + TRACE(3, "[%s] len = %d, sizeof(struct) = %d", __func__, len, + sizeof(IIR_CFG_T)); - if (len != sizeof(IIR_CFG_T)) - { - return 1; - } + if (len != sizeof(IIR_CFG_T)) { + return 1; + } - memcpy(&audio_process.hw_dac_iir_cfg, buf, sizeof(IIR_CFG_T)); - TRACE(3,"band num:%d gain0:%d, gain1:%d", - (int32_t)audio_process.hw_dac_iir_cfg.num, - (int32_t)(audio_process.hw_dac_iir_cfg.gain0*10), - (int32_t)(audio_process.hw_dac_iir_cfg.gain1*10)); - for (uint8_t i = 0; i sample_rate[%d], num[%d]", /*cur_cfg->samplerate,*/ audio_process.sample_rate, cur_cfg->num); + cur_cfg = (IIR_CFG_T *)buf; + TRACE(2, "-> sample_rate[%d], num[%d]", + /*cur_cfg->samplerate,*/ audio_process.sample_rate, cur_cfg->num); #if defined(AUDIO_EQ_SW_IIR_UPDATE_CFG) - audio_process.sw_iir_cfg.gain0 = cur_cfg->gain0; - audio_process.sw_iir_cfg.gain1 = cur_cfg->gain1; + audio_process.sw_iir_cfg.gain0 = cur_cfg->gain0; + audio_process.sw_iir_cfg.gain1 = cur_cfg->gain1; #endif #if defined(AUDIO_EQ_HW_DAC_IIR_UPDATE_CFG) #if defined(AUDIO_EQ_SW_IIR_UPDATE_CFG) - audio_process.hw_dac_iir_cfg.gain0 = 0; - audio_process.hw_dac_iir_cfg.gain1 = 0; + audio_process.hw_dac_iir_cfg.gain0 = 0; + audio_process.hw_dac_iir_cfg.gain1 = 0; #else - audio_process.hw_dac_iir_cfg.gain0 = cur_cfg->gain0; - audio_process.hw_dac_iir_cfg.gain1 = cur_cfg->gain1; + audio_process.hw_dac_iir_cfg.gain0 = cur_cfg->gain0; + audio_process.hw_dac_iir_cfg.gain1 = cur_cfg->gain1; #endif #endif #if defined(AUDIO_EQ_HW_DAC_IIR_UPDATE_CFG) - if (cur_cfg->num > AUD_DAC_IIR_NUM_EQ) { - audio_process.hw_dac_iir_cfg.num = AUD_DAC_IIR_NUM_EQ; - } else { - audio_process.hw_dac_iir_cfg.num = cur_cfg->num; - } - TRACE(1,"-> hw_dac_iir_num[%d]", audio_process.hw_dac_iir_cfg.num); + if (cur_cfg->num > AUD_DAC_IIR_NUM_EQ) { + audio_process.hw_dac_iir_cfg.num = AUD_DAC_IIR_NUM_EQ; + } else { + audio_process.hw_dac_iir_cfg.num = cur_cfg->num; + } + TRACE(1, "-> hw_dac_iir_num[%d]", audio_process.hw_dac_iir_cfg.num); #endif #if defined(AUDIO_EQ_SW_IIR_UPDATE_CFG) - audio_process.sw_iir_cfg.num = cur_cfg->num - audio_process.hw_dac_iir_cfg.num; - TRACE(1,"-> sw_iir_num[%d]", audio_process.sw_iir_cfg.num); + audio_process.sw_iir_cfg.num = + cur_cfg->num - audio_process.hw_dac_iir_cfg.num; + TRACE(1, "-> sw_iir_num[%d]", audio_process.sw_iir_cfg.num); #endif - //TRACE(2,"-> iir_num[%d - %d]", audio_process.hw_dac_iir_cfg.num, audio_process.sw_iir_cfg.num); + // TRACE(2,"-> iir_num[%d - %d]", audio_process.hw_dac_iir_cfg.num, + // audio_process.sw_iir_cfg.num); #if defined(AUDIO_EQ_HW_DAC_IIR_UPDATE_CFG) - if (audio_process.hw_dac_iir_cfg.num) { - memcpy((void*)(&audio_process.hw_dac_iir_cfg.param[0]), - (void*)(&cur_cfg->param[0]), - audio_process.hw_dac_iir_cfg.num*sizeof(IIR_PARAM_T)); - } + if (audio_process.hw_dac_iir_cfg.num) { + memcpy((void *)(&audio_process.hw_dac_iir_cfg.param[0]), + (void *)(&cur_cfg->param[0]), + audio_process.hw_dac_iir_cfg.num * sizeof(IIR_PARAM_T)); + } #endif #if defined(AUDIO_EQ_SW_IIR_UPDATE_CFG) - if (audio_process.sw_iir_cfg.num) { + if (audio_process.sw_iir_cfg.num) { - memcpy((void*)(&audio_process.sw_iir_cfg.param[0]), - (void*)(&cur_cfg->param[audio_process.hw_dac_iir_cfg.num]), - audio_process.sw_iir_cfg.num * sizeof(IIR_PARAM_T)); + memcpy((void *)(&audio_process.sw_iir_cfg.param[0]), + (void *)(&cur_cfg->param[audio_process.hw_dac_iir_cfg.num]), + audio_process.sw_iir_cfg.num * sizeof(IIR_PARAM_T)); - } else { + } else { - // set a default filter - audio_process.sw_iir_cfg.num = 1; + // set a default filter + audio_process.sw_iir_cfg.num = 1; - audio_process.sw_iir_cfg.param[0].fc = 1000.0; - audio_process.sw_iir_cfg.param[0].gain = 0.0; - audio_process.sw_iir_cfg.param[0].type = IIR_TYPE_PEAK; - audio_process.sw_iir_cfg.param[0].Q = 1.0; - - } + audio_process.sw_iir_cfg.param[0].fc = 1000.0; + audio_process.sw_iir_cfg.param[0].gain = 0.0; + audio_process.sw_iir_cfg.param[0].type = IIR_TYPE_PEAK; + audio_process.sw_iir_cfg.param[0].Q = 1.0; + } #endif - if (audio_process.sample_rate) { - audio_process.update_cfg = true; - } + if (audio_process.sample_rate) { + audio_process.update_cfg = true; + } - audio_process.eq_updated_cfg = true; + audio_process.eq_updated_cfg = true; - return 0; + return 0; } -void audio_eq_usb_eq_update (void) -{ - if (audio_process.update_cfg) { +void audio_eq_usb_eq_update(void) { + if (audio_process.update_cfg) { #if defined(AUDIO_EQ_HW_DAC_IIR_UPDATE_CFG) - HW_CODEC_IIR_CFG_T *hw_iir_cfg_dac = NULL; + HW_CODEC_IIR_CFG_T *hw_iir_cfg_dac = NULL; - if (audio_process.hw_dac_iir_cfg.num) { - enum AUD_SAMPRATE_T sample_rate_hw_dac_iir; + if (audio_process.hw_dac_iir_cfg.num) { + enum AUD_SAMPRATE_T sample_rate_hw_dac_iir; #ifdef __AUDIO_RESAMPLE__ - int i; - for(i=1;i<129;i++) - { - if(audio_process.sample_rate==AUD_SAMPRATE_7350*i)break; - if(audio_process.sample_rate==AUD_SAMPRATE_8000*i)break; - } - TRACE(1,"audio_process.sample_rate i:%d",i); - if(i==129) i=6; //set default eq parameter; - sample_rate_hw_dac_iir=i*8463.541666f;//AUD_SAMPRATE_8463 + int i; + for (i = 1; i < 129; i++) { + if (audio_process.sample_rate == AUD_SAMPRATE_7350 * i) + break; + if (audio_process.sample_rate == AUD_SAMPRATE_8000 * i) + break; + } + TRACE(1, "audio_process.sample_rate i:%d", i); + if (i == 129) + i = 6; // set default eq parameter; + sample_rate_hw_dac_iir = i * 8463.541666f; // AUD_SAMPRATE_8463 #else - sample_rate_hw_dac_iir = audio_process.sample_rate; + sample_rate_hw_dac_iir = audio_process.sample_rate; #endif - hw_iir_cfg_dac = hw_codec_iir_get_cfg(sample_rate_hw_dac_iir, &audio_process.hw_dac_iir_cfg); + hw_iir_cfg_dac = hw_codec_iir_get_cfg(sample_rate_hw_dac_iir, + &audio_process.hw_dac_iir_cfg); - hw_codec_iir_set_cfg(hw_iir_cfg_dac, sample_rate_hw_dac_iir, HW_CODEC_IIR_DAC); - audio_process.hw_dac_iir_enable = true; + hw_codec_iir_set_cfg(hw_iir_cfg_dac, sample_rate_hw_dac_iir, + HW_CODEC_IIR_DAC); + audio_process.hw_dac_iir_enable = true; - } else { + } else { - audio_process.hw_dac_iir_enable = false; - } + audio_process.hw_dac_iir_enable = false; + } #endif #if defined(AUDIO_EQ_SW_IIR_UPDATE_CFG) - iir_set_cfg(&audio_process.sw_iir_cfg); - audio_process.sw_iir_enable = true; + iir_set_cfg(&audio_process.sw_iir_cfg); + audio_process.sw_iir_enable = true; #endif - audio_process.update_cfg = false; - -/* - TRACE(4,"USB EQ Update: en[%d-%d], num[%d-%d]", - audio_process.hw_dac_iir_enable, audio_process.sw_iir_enable, - audio_process.hw_dac_iir_cfg.num, audio_process.sw_iir_cfg.num); -*/ - } + audio_process.update_cfg = false; + /* + TRACE(4,"USB EQ Update: en[%d-%d], num[%d-%d]", + audio_process.hw_dac_iir_enable, + audio_process.sw_iir_enable, audio_process.hw_dac_iir_cfg.num, + audio_process.sw_iir_cfg.num); + */ + } } -#endif // USB_EQ_TUNING - +#endif // USB_EQ_TUNING typedef struct { - uint8_t type; - uint8_t maxEqBandNum; - uint16_t sample_rate_num; - uint8_t sample_rate[50]; + uint8_t type; + uint8_t maxEqBandNum; + uint16_t sample_rate_num; + uint8_t sample_rate[50]; } query_eq_info_t; - extern int getMaxEqBand(void); -extern int getSampleArray(uint8_t* buf, uint16_t *num); +extern int getSampleArray(uint8_t *buf, uint16_t *num); -extern void hal_cmd_set_res_playload(uint8_t* data, int len); -#define CMD_TYPE_QUERY_DUT_EQ_INFO 0x00 -int audio_cmd_callback(uint8_t *buf, uint32_t len) -{ - uint8_t type; - //uint32_t* sample_rate; - //uint8_t* p; - query_eq_info_t info; +extern void hal_cmd_set_res_playload(uint8_t *data, int len); +#define CMD_TYPE_QUERY_DUT_EQ_INFO 0x00 +int audio_cmd_callback(uint8_t *buf, uint32_t len) { + uint8_t type; + // uint32_t* sample_rate; + // uint8_t* p; + query_eq_info_t info; - type = buf[0]; - //p = buf + 1; + type = buf[0]; + // p = buf + 1; - TRACE(2,"%s type: %d", __func__, type); - switch (type) { - case CMD_TYPE_QUERY_DUT_EQ_INFO: - info.type = CMD_TYPE_QUERY_DUT_EQ_INFO; - info.maxEqBandNum = getMaxEqBand(); - getSampleArray(info.sample_rate, &info.sample_rate_num); + TRACE(2, "%s type: %d", __func__, type); + switch (type) { + case CMD_TYPE_QUERY_DUT_EQ_INFO: + info.type = CMD_TYPE_QUERY_DUT_EQ_INFO; + info.maxEqBandNum = getMaxEqBand(); + getSampleArray(info.sample_rate, &info.sample_rate_num); - hal_cmd_set_res_playload((uint8_t*)&info, 4 + info.sample_rate_num * 4); - break; - default: - break; - } + hal_cmd_set_res_playload((uint8_t *)&info, 4 + info.sample_rate_num * 4); + break; + default: + break; + } - return 0; + return 0; } #ifdef AUDIO_SECTION_ENABLE -int audio_cfg_burn_callback(uint8_t *buf, uint32_t len) -{ - TRACE(3,"[%s] len = %d, sizeof(struct) = %d", __func__, len, sizeof_audio_cfg()); +int audio_cfg_burn_callback(uint8_t *buf, uint32_t len) { + TRACE(3, "[%s] len = %d, sizeof(struct) = %d", __func__, len, + sizeof_audio_cfg()); - if (len != sizeof_audio_cfg()) - { - return 1; - } + if (len != sizeof_audio_cfg()) { + return 1; + } - int res = 0; - res = store_audio_cfg_into_audio_section((AUDIO_CFG_T *)buf); + int res = 0; + res = store_audio_cfg_into_audio_section((AUDIO_CFG_T *)buf); - if(res) - { - TRACE(2,"[%s] ERROR: res = %d", __func__, res); - res += 100; - } - else - { - TRACE(1,"[%s] Store audio cfg into audio section!!!", __func__); - } + if (res) { + TRACE(2, "[%s] ERROR: res = %d", __func__, res); + res += 100; + } else { + TRACE(1, "[%s] Store audio cfg into audio section!!!", __func__); + } - return res; + return res; } #endif -int audio_process_init(void) -{ +int audio_process_init(void) { #ifdef __PC_CMD_UART__ - hal_cmd_init(); + hal_cmd_init(); #ifdef AUDIO_EQ_SW_IIR_UPDATE_CFG - hal_cmd_register("iir_eq", audio_eq_sw_iir_callback); // Will be removed - hal_cmd_register("sw_iir_eq", audio_eq_sw_iir_callback); + hal_cmd_register("iir_eq", audio_eq_sw_iir_callback); // Will be removed + hal_cmd_register("sw_iir_eq", audio_eq_sw_iir_callback); #endif #ifdef AUDIO_EQ_HW_DAC_IIR_UPDATE_CFG - hal_cmd_register("iir_eq", audio_eq_hw_dac_iir_callback); // Will be removed - hal_cmd_register("dac_iir_eq", audio_eq_hw_dac_iir_callback); + hal_cmd_register("iir_eq", audio_eq_hw_dac_iir_callback); // Will be removed + hal_cmd_register("dac_iir_eq", audio_eq_hw_dac_iir_callback); #endif #ifdef AUDIO_EQ_HW_IIR_UPDATE_CFG - hal_cmd_register("iir_eq", audio_eq_hw_iir_callback); // Will be removed - hal_cmd_register("hw_iir_eq", audio_eq_hw_iir_callback); + hal_cmd_register("iir_eq", audio_eq_hw_iir_callback); // Will be removed + hal_cmd_register("hw_iir_eq", audio_eq_hw_iir_callback); #endif #ifdef AUDIO_EQ_HW_FIR_UPDATE_CFG - hal_cmd_register("fir_eq", audio_eq_hw_fir_callback); + hal_cmd_register("fir_eq", audio_eq_hw_fir_callback); #endif #ifdef AUDIO_DRC_UPDATE_CFG - hal_cmd_register("drc", audio_drc_callback); + hal_cmd_register("drc", audio_drc_callback); #endif #ifdef AUDIO_DRC2_UPDATE_CFG - hal_cmd_register("limiter", audio_drc2_callback); + hal_cmd_register("limiter", audio_drc2_callback); #endif #ifdef AUDIO_SECTION_ENABLE - hal_cmd_register("burn", audio_cfg_burn_callback); - hal_cmd_register("audio_burn", audio_cfg_burn_callback); + hal_cmd_register("burn", audio_cfg_burn_callback); + hal_cmd_register("audio_burn", audio_cfg_burn_callback); #endif - hal_cmd_register("cmd", audio_cmd_callback); - hal_cmd_register("ping", audio_ping_callback); + hal_cmd_register("cmd", audio_cmd_callback); + hal_cmd_register("ping", audio_ping_callback); #endif #ifdef USB_EQ_TUNING - hal_cmd_init(); + hal_cmd_init(); -#if defined(AUDIO_EQ_SW_IIR_UPDATE_CFG) || defined(AUDIO_EQ_HW_DAC_IIR_UPDATE_CFG) - hal_cmd_register("iir_eq", audio_eq_usb_iir_callback); +#if defined(AUDIO_EQ_SW_IIR_UPDATE_CFG) || \ + defined(AUDIO_EQ_HW_DAC_IIR_UPDATE_CFG) + hal_cmd_register("iir_eq", audio_eq_usb_iir_callback); #endif - hal_cmd_register("cmd", audio_cmd_callback); - hal_cmd_register("ping", audio_ping_callback); + hal_cmd_register("cmd", audio_cmd_callback); + hal_cmd_register("ping", audio_ping_callback); #endif - // load default cfg + // load default cfg #ifdef AUDIO_EQ_SW_IIR_UPDATE_CFG - memcpy(&audio_process.sw_iir_cfg, audio_eq_sw_iir_cfg_list[0], sizeof(IIR_CFG_T)); + memcpy(&audio_process.sw_iir_cfg, audio_eq_sw_iir_cfg_list[0], + sizeof(IIR_CFG_T)); #endif #ifdef AUDIO_EQ_HW_DAC_IIR_UPDATE_CFG - memcpy(&audio_process.hw_dac_iir_cfg, audio_eq_hw_dac_iir_cfg_list[0], sizeof(IIR_CFG_T)); + memcpy(&audio_process.hw_dac_iir_cfg, audio_eq_hw_dac_iir_cfg_list[0], + sizeof(IIR_CFG_T)); #endif #ifdef AUDIO_EQ_HW_IIR_UPDATE_CFG - memcpy(&audio_process.hw_iir_cfg, audio_eq_hw_iir_cfg_list[0], sizeof(IIR_CFG_T)); + memcpy(&audio_process.hw_iir_cfg, audio_eq_hw_iir_cfg_list[0], + sizeof(IIR_CFG_T)); #endif #ifdef AUDIO_EQ_HW_FIR_UPDATE_CFG - memcpy(&audio_process.hw_fir_cfg, audio_eq_hw_fir_cfg_list[0], sizeof(FIR_CFG_T)); + memcpy(&audio_process.hw_fir_cfg, audio_eq_hw_fir_cfg_list[0], + sizeof(FIR_CFG_T)); #endif #ifdef AUDIO_DRC_UPDATE_CFG - memcpy(&audio_process.drc_cfg, &audio_drc_cfg, sizeof(DrcConfig)); + memcpy(&audio_process.drc_cfg, &audio_drc_cfg, sizeof(DrcConfig)); #endif #ifdef AUDIO_DRC2_UPDATE_CFG - memcpy(&audio_process.drc2_cfg, &audio_drc2_cfg, sizeof(LimiterConfig)); + memcpy(&audio_process.drc2_cfg, &audio_drc2_cfg, sizeof(LimiterConfig)); #endif - return 0; + return 0; } diff --git a/services/audio_process/audio_spectrum.cpp b/services/audio_process/audio_spectrum.cpp index 9996efc..c4cb226 100644 --- a/services/audio_process/audio_spectrum.cpp +++ b/services/audio_process/audio_spectrum.cpp @@ -15,104 +15,99 @@ ****************************************************************************/ #ifdef SPEECH_LIB -#include "spectrum_fix.h" -#include "speech_memory.h" #include "hal_aud.h" #include "hal_trace.h" +#include "spectrum_fix.h" +#include "speech_memory.h" #define AUDIO_SPECTRUM_FRAME_SIZE (256) struct AudioSpectrum { - SpectrumFixState *state; - enum AUD_BITS_T bits; - int16_t *frame; - int16_t *data; + SpectrumFixState *state; + enum AUD_BITS_T bits; + int16_t *frame; + int16_t *data; }; static AudioSpectrum audio_spectrum; extern const SpectrumFixConfig audio_spectrum_cfg; -void audio_spectrum_open(int sample_rate, enum AUD_BITS_T sample_bits) -{ - uint8_t *speech_buf = NULL; - int speech_buf_size = 1024 * 5; +void audio_spectrum_open(int sample_rate, enum AUD_BITS_T sample_bits) { + uint8_t *speech_buf = NULL; + int speech_buf_size = 1024 * 5; - syspool_get_buff((uint8_t **)&(audio_spectrum.frame), AUDIO_SPECTRUM_FRAME_SIZE * sizeof(int16_t)); - syspool_get_buff((uint8_t **)&(audio_spectrum.data), audio_spectrum_cfg.freq_num * sizeof(int16_t)); - syspool_get_buff(&speech_buf, speech_buf_size); - speech_heap_init(speech_buf, speech_buf_size); + syspool_get_buff((uint8_t **)&(audio_spectrum.frame), + AUDIO_SPECTRUM_FRAME_SIZE * sizeof(int16_t)); + syspool_get_buff((uint8_t **)&(audio_spectrum.data), + audio_spectrum_cfg.freq_num * sizeof(int16_t)); + syspool_get_buff(&speech_buf, speech_buf_size); + speech_heap_init(speech_buf, speech_buf_size); - audio_spectrum.state = spectrum_fix_init(sample_rate, AUDIO_SPECTRUM_FRAME_SIZE, &audio_spectrum_cfg); - audio_spectrum.bits = sample_bits; + audio_spectrum.state = spectrum_fix_init( + sample_rate, AUDIO_SPECTRUM_FRAME_SIZE, &audio_spectrum_cfg); + audio_spectrum.bits = sample_bits; } -void audio_spectrum_close(void) -{ - spectrum_fix_destroy(audio_spectrum.state); +void audio_spectrum_close(void) { + spectrum_fix_destroy(audio_spectrum.state); - size_t total = 0, used = 0, max_used = 0; - speech_memory_info(&total, &used, &max_used); - TRACE(3,"SPEECH MALLOC MEM: total - %d, used - %d, max_used - %d.", total, used, max_used); - ASSERT(used == 0, "[%s] used != 0", __func__); + size_t total = 0, used = 0, max_used = 0; + speech_memory_info(&total, &used, &max_used); + TRACE(3, "SPEECH MALLOC MEM: total - %d, used - %d, max_used - %d.", total, + used, max_used); + ASSERT(used == 0, "[%s] used != 0", __func__); } -static inline int16_t convertTo16Bit(int16_t x) -{ - return x; -} - -static inline int16_t convertTo16Bit(int32_t x) -{ - return (x >> 8); -} +static inline int16_t convertTo16Bit(int16_t x) { return x; } +static inline int16_t convertTo16Bit(int32_t x) { return (x >> 8); } // convert stream to 16bit mono stream -template -static void convertToMono16Bit(int16_t *out, DataType *in, int frame_size) -{ - for (int i = 0; i < frame_size; i++) { - out[i] = convertTo16Bit(in[i * 2]) / 2 + convertTo16Bit(in[i * 2 + 1]) / 2; - } +template +static void convertToMono16Bit(int16_t *out, DataType *in, int frame_size) { + for (int i = 0; i < frame_size; i++) { + out[i] = convertTo16Bit(in[i * 2]) / 2 + convertTo16Bit(in[i * 2 + 1]) / 2; + } } -template -void audio_spectrum_run_impl(const uint8_t *buf, int len) -{ - int frame_size = len / sizeof(DataType); - DataType *pBuf = (DataType *)buf; +template +void audio_spectrum_run_impl(const uint8_t *buf, int len) { + int frame_size = len / sizeof(DataType); + DataType *pBuf = (DataType *)buf; - ASSERT(frame_size % (2 * AUDIO_SPECTRUM_FRAME_SIZE) == 0, - "[%s] only support N*%d frame size", __FUNCTION__, AUDIO_SPECTRUM_FRAME_SIZE); + ASSERT(frame_size % (2 * AUDIO_SPECTRUM_FRAME_SIZE) == 0, + "[%s] only support N*%d frame size", __FUNCTION__, + AUDIO_SPECTRUM_FRAME_SIZE); - int audio_spectrum_block_cnt = frame_size / 2 / AUDIO_SPECTRUM_FRAME_SIZE; + int audio_spectrum_block_cnt = frame_size / 2 / AUDIO_SPECTRUM_FRAME_SIZE; - for (int i = 0; i < audio_spectrum_block_cnt; i++) { - //stereo to mono, 24bit to 16bit - convertToMono16Bit(audio_spectrum.frame, pBuf + i * AUDIO_SPECTRUM_FRAME_SIZE * 2, AUDIO_SPECTRUM_FRAME_SIZE); + for (int i = 0; i < audio_spectrum_block_cnt; i++) { + // stereo to mono, 24bit to 16bit + convertToMono16Bit(audio_spectrum.frame, + pBuf + i * AUDIO_SPECTRUM_FRAME_SIZE * 2, + AUDIO_SPECTRUM_FRAME_SIZE); - //TRACE(0,"pcm:"); - //DUMP16("0x%x, ", audio_spectrum.frame, 8); + // TRACE(0,"pcm:"); + // DUMP16("0x%x, ", audio_spectrum.frame, 8); - spectrum_fix_analysis(audio_spectrum.state, audio_spectrum.frame); - if (i == 0) { - spectrum_fix_process(audio_spectrum.state, audio_spectrum.data, audio_spectrum_cfg.freq_num); - //TRACE(1,"spectrum: %d", sizeof(DataType)); - //DUMP16("0x%x, ", audio_spectrum.data, audio_spectrum_cfg.freq_num); - } + spectrum_fix_analysis(audio_spectrum.state, audio_spectrum.frame); + if (i == 0) { + spectrum_fix_process(audio_spectrum.state, audio_spectrum.data, + audio_spectrum_cfg.freq_num); + // TRACE(1,"spectrum: %d", sizeof(DataType)); + // DUMP16("0x%x, ", audio_spectrum.data, audio_spectrum_cfg.freq_num); } + } } -void audio_spectrum_run(const uint8_t *buf, int len) -{ - if (audio_spectrum.bits == AUD_BITS_16) - audio_spectrum_run_impl(buf, len); - else if (audio_spectrum.bits == AUD_BITS_24) - audio_spectrum_run_impl(buf, len); - else - TRACE(1,"[%s] warning not suitable callback available", __func__); +void audio_spectrum_run(const uint8_t *buf, int len) { + if (audio_spectrum.bits == AUD_BITS_16) + audio_spectrum_run_impl(buf, len); + else if (audio_spectrum.bits == AUD_BITS_24) + audio_spectrum_run_impl(buf, len); + else + TRACE(1, "[%s] warning not suitable callback available", __func__); } #endif - diff --git a/services/audioflinger/audioflinger.c b/services/audioflinger/audioflinger.c index 0bb2533..b33f04e 100644 --- a/services/audioflinger/audioflinger.c +++ b/services/audioflinger/audioflinger.c @@ -14,21 +14,21 @@ * ****************************************************************************/ #include "audioflinger.h" +#include "codec_int.h" +#include "codec_tlv32aic32.h" +#include "hal_btpcm.h" +#include "hal_codec.h" #include "hal_dma.h" #include "hal_i2s.h" -#include "hal_tdm.h" -#include "hal_codec.h" #include "hal_spdif.h" -#include "hal_btpcm.h" -#include "codec_tlv32aic32.h" -#include "codec_int.h" +#include "hal_tdm.h" -#include "string.h" -#include "hal_trace.h" +#include "analog.h" #include "hal_cmu.h" #include "hal_timer.h" +#include "hal_trace.h" #include "pmu.h" -#include "analog.h" +#include "string.h" #include "tgt_hardware.h" #include "cmsis.h" @@ -41,7 +41,6 @@ extern void tws_playback_ticks_check_for_mix_prompt(void); #endif - #ifdef RTOS #include "cmsis_os.h" #else @@ -56,7 +55,7 @@ extern void tws_playback_ticks_check_for_mix_prompt(void); #undef FPGA #endif -#define AF_TRACE_DEBUG() // TRACE(2,"%s:%d\n", __func__, __LINE__) +#define AF_TRACE_DEBUG() // TRACE(2,"%s:%d\n", __func__, __LINE__) //#define AF_STREAM_ID_0_PLAYBACK_FADEOUT @@ -75,49 +74,50 @@ extern void tws_playback_ticks_check_for_mix_prompt(void); #elif (defined(__TWS__) || defined(IBRT)) && !defined(ANC_APP) #define AUDIO_OUTPUT_PA_ON_FADE_IN #endif // !CHIP_BEST1000 && __TWS__ -#elif defined(AUDIO_OUTPUT_DC_CALIB_ANA) && (defined(__TWS__) || defined(IBRT)) && !defined(ANC_APP) +#elif defined(AUDIO_OUTPUT_DC_CALIB_ANA) && \ + (defined(__TWS__) || defined(IBRT)) && !defined(ANC_APP) #define AUDIO_OUTPUT_PA_ON_FADE_IN #endif // !AUDIO_OUTPUT_DC_CALIB && AUDIO_OUTPUT_DC_CALIB_ANA && __TWS__ -#define AF_FADE_OUT_SIGNAL_ID 15 -#define AF_FADE_IN_SIGNAL_ID 14 +#define AF_FADE_OUT_SIGNAL_ID 15 +#define AF_FADE_IN_SIGNAL_ID 14 /* config params */ #define AF_CODEC_INST HAL_CODEC_ID_0 #define AF_SPDIF_INST HAL_SPDIF_ID_0 #define AF_BTPCM_INST HAL_BTPCM_ID_0 -#define AF_CPU_WAKE_USER HAL_CPU_WAKE_LOCK_USER_AUDIOFLINGER +#define AF_CPU_WAKE_USER HAL_CPU_WAKE_LOCK_USER_AUDIOFLINGER -#define AF_CODEC_RIGHT_CHAN_ATTN 0.968277856 // -0.28 dB +#define AF_CODEC_RIGHT_CHAN_ATTN 0.968277856 // -0.28 dB -#define AF_CODEC_VOL_UPDATE_STEP 0.00002 +#define AF_CODEC_VOL_UPDATE_STEP 0.00002 -#define AF_CODEC_DC_MAX_SCALE 32767 +#define AF_CODEC_DC_MAX_SCALE 32767 -#define AF_CODEC_DC_STABLE_INTERVAL MS_TO_TICKS(4) +#define AF_CODEC_DC_STABLE_INTERVAL MS_TO_TICKS(4) #ifdef AUDIO_OUTPUT_PA_OFF_FADE_OUT -#define AF_CODEC_PA_RESTART_INTERVAL MS_TO_TICKS(160) +#define AF_CODEC_PA_RESTART_INTERVAL MS_TO_TICKS(160) #else -#define AF_CODEC_PA_RESTART_INTERVAL MS_TO_TICKS(8) +#define AF_CODEC_PA_RESTART_INTERVAL MS_TO_TICKS(8) #endif // The following might have been defined in tgt_hardware.h #ifndef AF_CODEC_FADE_IN_MS -#define AF_CODEC_FADE_IN_MS 20 +#define AF_CODEC_FADE_IN_MS 20 #endif #ifndef AF_CODEC_FADE_OUT_MS -#define AF_CODEC_FADE_OUT_MS 20 +#define AF_CODEC_FADE_OUT_MS 20 #endif -#define AF_CODEC_FADE_MIN_SAMPLE_CNT 200 +#define AF_CODEC_FADE_MIN_SAMPLE_CNT 200 -#define PP_PINGPANG(v) (v == PP_PING ? PP_PANG : PP_PING) +#define PP_PINGPANG(v) (v == PP_PING ? PP_PANG : PP_PING) #ifdef AUDIO_ANC_FB_ADJ_MC -#define AF_STACK_SIZE (1024*10) +#define AF_STACK_SIZE (1024 * 10) #else #ifndef AF_STACK_SIZE -#define AF_STACK_SIZE (1024*8) +#define AF_STACK_SIZE (1024 * 8) #endif #endif @@ -126,75 +126,69 @@ extern void tws_playback_ticks_check_for_mix_prompt(void); #endif #ifdef DYNAMIC_AUDIO_BUFFER_COUNT -#define MAX_AUDIO_BUFFER_COUNT 16 -#define MIN_AUDIO_BUFFER_COUNT 2 -#define AUDIO_BUFFER_COUNT (role->dma_desc_cnt) +#define MAX_AUDIO_BUFFER_COUNT 16 +#define MIN_AUDIO_BUFFER_COUNT 2 +#define AUDIO_BUFFER_COUNT (role->dma_desc_cnt) #else -#define MAX_AUDIO_BUFFER_COUNT 4 -#define AUDIO_BUFFER_COUNT MAX_AUDIO_BUFFER_COUNT +#define MAX_AUDIO_BUFFER_COUNT 4 +#define AUDIO_BUFFER_COUNT MAX_AUDIO_BUFFER_COUNT #if (AUDIO_BUFFER_COUNT & 0x1) #error "AUDIO_BUFFER_COUNT must be an even number" #endif #endif /* internal use */ -enum AF_BOOL_T{ - AF_FALSE = 0, - AF_TRUE = 1 -}; +enum AF_BOOL_T { AF_FALSE = 0, AF_TRUE = 1 }; -enum AF_RESULT_T{ - AF_RES_SUCCESS = 0, - AF_RES_FAILD = 1 -}; +enum AF_RESULT_T { AF_RES_SUCCESS = 0, AF_RES_FAILD = 1 }; enum AF_DAC_PA_STATE_T { - AF_DAC_PA_NULL, - AF_DAC_PA_ON_TRIGGER, - AF_DAC_PA_ON_SOFT_START, - AF_DAC_PA_OFF_TRIGGER, - AF_DAC_PA_OFF_SOFT_END, - AF_DAC_PA_OFF_SOFT_END_DONE, - AF_DAC_PA_OFF_DC_START, + AF_DAC_PA_NULL, + AF_DAC_PA_ON_TRIGGER, + AF_DAC_PA_ON_SOFT_START, + AF_DAC_PA_OFF_TRIGGER, + AF_DAC_PA_OFF_SOFT_END, + AF_DAC_PA_OFF_SOFT_END_DONE, + AF_DAC_PA_OFF_DC_START, }; -//status machine -enum AF_STATUS_T{ - AF_STATUS_NULL = 0x00, - AF_STATUS_OPEN_CLOSE = 0x01, - AF_STATUS_STREAM_OPEN_CLOSE = 0x02, - AF_STATUS_STREAM_START_STOP = 0x04, - AF_STATUS_STREAM_PAUSE_RESTART = 0x08, - AF_STATUS_MASK = 0x0F, +// status machine +enum AF_STATUS_T { + AF_STATUS_NULL = 0x00, + AF_STATUS_OPEN_CLOSE = 0x01, + AF_STATUS_STREAM_OPEN_CLOSE = 0x02, + AF_STATUS_STREAM_START_STOP = 0x04, + AF_STATUS_STREAM_PAUSE_RESTART = 0x08, + AF_STATUS_MASK = 0x0F, }; -struct af_stream_ctl_t{ - enum AF_PP_T pp_index; //pingpong operate - uint8_t pp_cnt; //use to count the lost signals - uint8_t status; //status machine - enum AUD_STREAM_USE_DEVICE_T use_device; +struct af_stream_ctl_t { + enum AF_PP_T pp_index; // pingpong operate + uint8_t pp_cnt; // use to count the lost signals + uint8_t status; // status machine + enum AUD_STREAM_USE_DEVICE_T use_device; }; struct af_stream_cfg_t { - //used inside - struct af_stream_ctl_t ctl; + // used inside + struct af_stream_ctl_t ctl; - //dma buf parameters, RAM can be alloced in different way - uint8_t *dma_buf_ptr; - uint32_t dma_buf_size; + // dma buf parameters, RAM can be alloced in different way + uint8_t *dma_buf_ptr; + uint32_t dma_buf_size; - //store stream cfg parameters - struct AF_STREAM_CONFIG_T cfg; + // store stream cfg parameters + struct AF_STREAM_CONFIG_T cfg; - //dma cfg parameters + // dma cfg parameters #ifdef DYNAMIC_AUDIO_BUFFER_COUNT - uint8_t dma_desc_cnt; + uint8_t dma_desc_cnt; #endif - struct HAL_DMA_DESC_T dma_desc[MAX_AUDIO_BUFFER_COUNT]; - struct HAL_DMA_CH_CFG_T dma_cfg; + struct HAL_DMA_DESC_T dma_desc[MAX_AUDIO_BUFFER_COUNT]; + struct HAL_DMA_CH_CFG_T dma_cfg; - //callback function - AF_STREAM_HANDLER_T handler; + // callback function + AF_STREAM_HANDLER_T handler; }; static struct af_stream_cfg_t af_stream[AUD_STREAM_ID_NUM][AUD_STREAM_NUM]; @@ -208,18 +202,19 @@ volatile static float saved_output_coef; static FloatLimiterPtr FloatLimiterP; #else typedef struct { - float coefs_b[3]; - float coefs_a[3]; - float history_x[2]; - float history_y[2]; -}SW_GAIN_IIR_T; -SW_GAIN_IIR_T sw_gain_iir= - { - .coefs_b={0.00000042780818597736f, 0.00000085561637195472f, 0.00000042780818597736f}, - .coefs_a={1.00000000000000000000f, -1.99738371810092970000f, 0.99738542933367369000f}, - .history_x={0,0}, - .history_y={0,0} , - }; + float coefs_b[3]; + float coefs_a[3]; + float history_x[2]; + float history_y[2]; +} SW_GAIN_IIR_T; +SW_GAIN_IIR_T sw_gain_iir = { + .coefs_b = {0.00000042780818597736f, 0.00000085561637195472f, + 0.00000042780818597736f}, + .coefs_a = {1.00000000000000000000f, -1.99738371810092970000f, + 0.99738542933367369000f}, + .history_x = {0, 0}, + .history_y = {0, 0}, +}; #endif #endif @@ -246,27 +241,28 @@ static osThreadId fade_thread_id; #ifdef RTOS #ifdef AF_STREAM_ID_0_PLAYBACK_FADEOUT -struct af_stream_fade_out_t{ - bool stop_on_process; - uint8_t stop_process_cnt; - osThreadId stop_request_tid; - uint32_t need_fadeout_len; - uint32_t need_fadeout_len_processed; +struct af_stream_fade_out_t { + bool stop_on_process; + uint8_t stop_process_cnt; + osThreadId stop_request_tid; + uint32_t need_fadeout_len; + uint32_t need_fadeout_len_processed; }; -static struct af_stream_fade_out_t af_stream_fade_out ={ - .stop_on_process = false, - .stop_process_cnt = 0, - .stop_request_tid = NULL, - .need_fadeout_len = 0, - .need_fadeout_len_processed = 0, +static struct af_stream_fade_out_t af_stream_fade_out = { + .stop_on_process = false, + .stop_process_cnt = 0, + .stop_request_tid = NULL, + .need_fadeout_len = 0, + .need_fadeout_len_processed = 0, }; #endif static osThreadId af_thread_tid; static void af_thread(void const *argument); -osThreadDef(af_thread, osPriorityAboveNormal, 1, AF_STACK_SIZE, "audio_flinger"); +osThreadDef(af_thread, osPriorityAboveNormal, 1, AF_STACK_SIZE, + "audio_flinger"); static int af_default_priority; osMutexId audioflinger_mutex_id = NULL; @@ -284,199 +280,202 @@ static volatile uint32_t af_flag_lock; static bool af_dsd_enabled; #endif -void af_lock_thread(void) -{ - void * POSSIBLY_UNUSED lr = __builtin_return_address(0); +void af_lock_thread(void) { + void *POSSIBLY_UNUSED lr = __builtin_return_address(0); #ifdef RTOS - osMutexWait(audioflinger_mutex_id, osWaitForever); + osMutexWait(audioflinger_mutex_id, osWaitForever); #else - static void * POSSIBLY_UNUSED locked_lr; - ASSERT(af_flag_lock == 0, "audioflinger has been locked by %p. LR=%p", (void *)locked_lr, (void *)lr); - af_flag_lock = 1; - locked_lr = lr; + static void *POSSIBLY_UNUSED locked_lr; + ASSERT(af_flag_lock == 0, "audioflinger has been locked by %p. LR=%p", + (void *)locked_lr, (void *)lr); + af_flag_lock = 1; + locked_lr = lr; #endif } -void af_unlock_thread(void) -{ - void * POSSIBLY_UNUSED lr = __builtin_return_address(0); +void af_unlock_thread(void) { + void *POSSIBLY_UNUSED lr = __builtin_return_address(0); #ifdef RTOS - osMutexRelease(audioflinger_mutex_id); + osMutexRelease(audioflinger_mutex_id); #else - static void * POSSIBLY_UNUSED unlocked_lr; - ASSERT(af_flag_lock == 1, "audioflinger not locked before (lastly unlocked by %p). LR=%p", (void *)unlocked_lr, (void *)lr); - af_flag_lock = 0; - unlocked_lr = lr; + static void *POSSIBLY_UNUSED unlocked_lr; + ASSERT(af_flag_lock == 1, + "audioflinger not locked before (lastly unlocked by %p). LR=%p", + (void *)unlocked_lr, (void *)lr); + af_flag_lock = 0; + unlocked_lr = lr; #endif } #if defined(RTOS) && defined(AF_STREAM_ID_0_PLAYBACK_FADEOUT) -int af_stream_fadeout_start(uint32_t sample) -{ - TRACE(1,"fadein_config sample:%d", sample); - af_stream_fade_out.need_fadeout_len = sample; - af_stream_fade_out.need_fadeout_len_processed = sample; - return 0; +int af_stream_fadeout_start(uint32_t sample) { + TRACE(1, "fadein_config sample:%d", sample); + af_stream_fade_out.need_fadeout_len = sample; + af_stream_fade_out.need_fadeout_len_processed = sample; + return 0; } -int af_stream_fadeout_stop(void) -{ - af_stream_fade_out.stop_process_cnt = 0; - af_stream_fade_out.stop_on_process = false; - return 0; +int af_stream_fadeout_stop(void) { + af_stream_fade_out.stop_process_cnt = 0; + af_stream_fade_out.stop_on_process = false; + return 0; } -uint32_t af_stream_fadeout(int16_t *buf, uint32_t len, enum AUD_CHANNEL_NUM_T num) -{ - uint32_t i; - uint32_t j = 0; - uint32_t start; - uint32_t end; +uint32_t af_stream_fadeout(int16_t *buf, uint32_t len, + enum AUD_CHANNEL_NUM_T num) { + uint32_t i; + uint32_t j = 0; + uint32_t start; + uint32_t end; - start = af_stream_fade_out.need_fadeout_len_processed; - end = af_stream_fade_out.need_fadeout_len_processed > len ? - af_stream_fade_out.need_fadeout_len_processed - len : 0; - - if (start <= end){ -// TRACE(0,"skip fadeout"); - memset(buf, 0, len*2); - return len; - } -// TRACE(3,"fadeout l:%d start:%d end:%d", len, start, end); -// DUMP16("%05d ", buf, 10); -// DUMP16("%05d ", buf+len-10, 10); - - - if (num == AUD_CHANNEL_NUM_1){ - for (i = start; i > end; i--){ - *(buf+j) = *(buf+j)*i/af_stream_fade_out.need_fadeout_len; - j++; - } - }else if (num == AUD_CHANNEL_NUM_2){ - for (i = start; i > end; i-=2){ - *(buf+j) = *(buf+j)*i/af_stream_fade_out.need_fadeout_len; - j++; - *(buf+j) = *(buf+j)*i/af_stream_fade_out.need_fadeout_len; - j++; - } - }else if (num == AUD_CHANNEL_NUM_4){ - for (i = start; i > end; i-=4){ - *(buf+j) = *(buf+j)*i/af_stream_fade_out.need_fadeout_len; - j++; - *(buf+j) = *(buf+j)*i/af_stream_fade_out.need_fadeout_len; - j++; - *(buf+j) = *(buf+j)*i/af_stream_fade_out.need_fadeout_len; - j++; - *(buf+j) = *(buf+j)*i/af_stream_fade_out.need_fadeout_len; - j++; - } - }else if (num == AUD_CHANNEL_NUM_8){ - for (i = start; i > end; i-=8){ - *(buf+j) = *(buf+j)*i/af_stream_fade_out.need_fadeout_len; - j++; - *(buf+j) = *(buf+j)*i/af_stream_fade_out.need_fadeout_len; - j++; - *(buf+j) = *(buf+j)*i/af_stream_fade_out.need_fadeout_len; - j++; - *(buf+j) = *(buf+j)*i/af_stream_fade_out.need_fadeout_len; - j++; - *(buf+j) = *(buf+j)*i/af_stream_fade_out.need_fadeout_len; - j++; - *(buf+j) = *(buf+j)*i/af_stream_fade_out.need_fadeout_len; - j++; - *(buf+j) = *(buf+j)*i/af_stream_fade_out.need_fadeout_len; - j++; - *(buf+j) = *(buf+j)*i/af_stream_fade_out.need_fadeout_len; - j++; - } - - } - af_stream_fade_out.need_fadeout_len_processed -= j; - -// TRACE(3,"out i:%d process:%d x:%d", i, af_stream_fade_out.need_fadeout_len_processed, end+((start-end)/AUD_CHANNEL_NUM_2)); -// DUMP16("%05d ", buf, 10); -// DUMP16("%05d ", buf+len-10, 10); + start = af_stream_fade_out.need_fadeout_len_processed; + end = af_stream_fade_out.need_fadeout_len_processed > len + ? af_stream_fade_out.need_fadeout_len_processed - len + : 0; + if (start <= end) { + // TRACE(0,"skip fadeout"); + memset(buf, 0, len * 2); return len; -} + } + // TRACE(3,"fadeout l:%d start:%d end:%d", len, start, end); + // DUMP16("%05d ", buf, 10); + // DUMP16("%05d ", buf+len-10, 10); -void af_stream_stop_wait_finish() -{ - af_stream_fade_out.stop_on_process = true; - af_stream_fade_out.stop_request_tid = osThreadGetId(); - osSignalClear(af_stream_fade_out.stop_request_tid, (1 << AF_FADE_OUT_SIGNAL_ID)); - af_unlock_thread(); - osSignalWait((1 << AF_FADE_OUT_SIGNAL_ID), 300); - af_lock_thread(); -} - -void af_stream_stop_process(struct af_stream_cfg_t *af_cfg, uint8_t *buf, uint32_t len) -{ - af_lock_thread(); - if (af_stream_fade_out.stop_on_process){ -// TRACE(5,"%s num:%d size:%d len:%d cnt:%d", __func__, af_cfg->cfg.channel_num, af_cfg->cfg.data_size, len, af_stream_fade_out.stop_process_cnt); - af_stream_fadeout((int16_t *)buf, len/2, af_cfg->cfg.channel_num); - -// TRACE(3,"process ret:%d %d %d", *(int16_t *)(buf+len-2-2-2), *(int16_t *)(buf+len-2-2), *(int16_t *)(buf+len-2)); - if (af_stream_fade_out.stop_process_cnt++>3){ - TRACE(0,"stop_process end"); - osSignalSet(af_stream_fade_out.stop_request_tid, (1 << AF_FADE_OUT_SIGNAL_ID)); - } + if (num == AUD_CHANNEL_NUM_1) { + for (i = start; i > end; i--) { + *(buf + j) = *(buf + j) * i / af_stream_fade_out.need_fadeout_len; + j++; } - af_unlock_thread(); + } else if (num == AUD_CHANNEL_NUM_2) { + for (i = start; i > end; i -= 2) { + *(buf + j) = *(buf + j) * i / af_stream_fade_out.need_fadeout_len; + j++; + *(buf + j) = *(buf + j) * i / af_stream_fade_out.need_fadeout_len; + j++; + } + } else if (num == AUD_CHANNEL_NUM_4) { + for (i = start; i > end; i -= 4) { + *(buf + j) = *(buf + j) * i / af_stream_fade_out.need_fadeout_len; + j++; + *(buf + j) = *(buf + j) * i / af_stream_fade_out.need_fadeout_len; + j++; + *(buf + j) = *(buf + j) * i / af_stream_fade_out.need_fadeout_len; + j++; + *(buf + j) = *(buf + j) * i / af_stream_fade_out.need_fadeout_len; + j++; + } + } else if (num == AUD_CHANNEL_NUM_8) { + for (i = start; i > end; i -= 8) { + *(buf + j) = *(buf + j) * i / af_stream_fade_out.need_fadeout_len; + j++; + *(buf + j) = *(buf + j) * i / af_stream_fade_out.need_fadeout_len; + j++; + *(buf + j) = *(buf + j) * i / af_stream_fade_out.need_fadeout_len; + j++; + *(buf + j) = *(buf + j) * i / af_stream_fade_out.need_fadeout_len; + j++; + *(buf + j) = *(buf + j) * i / af_stream_fade_out.need_fadeout_len; + j++; + *(buf + j) = *(buf + j) * i / af_stream_fade_out.need_fadeout_len; + j++; + *(buf + j) = *(buf + j) * i / af_stream_fade_out.need_fadeout_len; + j++; + *(buf + j) = *(buf + j) * i / af_stream_fade_out.need_fadeout_len; + j++; + } + } + af_stream_fade_out.need_fadeout_len_processed -= j; + + // TRACE(3,"out i:%d process:%d x:%d", i, + // af_stream_fade_out.need_fadeout_len_processed, + // end+((start-end)/AUD_CHANNEL_NUM_2)); DUMP16("%05d ", buf, 10); + // DUMP16("%05d ", buf+len-10, 10); + + return len; +} + +void af_stream_stop_wait_finish() { + af_stream_fade_out.stop_on_process = true; + af_stream_fade_out.stop_request_tid = osThreadGetId(); + osSignalClear(af_stream_fade_out.stop_request_tid, + (1 << AF_FADE_OUT_SIGNAL_ID)); + af_unlock_thread(); + osSignalWait((1 << AF_FADE_OUT_SIGNAL_ID), 300); + af_lock_thread(); +} + +void af_stream_stop_process(struct af_stream_cfg_t *af_cfg, uint8_t *buf, + uint32_t len) { + af_lock_thread(); + if (af_stream_fade_out.stop_on_process) { + // TRACE(5,"%s num:%d size:%d len:%d cnt:%d", __func__, + // af_cfg->cfg.channel_num, af_cfg->cfg.data_size, len, + // af_stream_fade_out.stop_process_cnt); + af_stream_fadeout((int16_t *)buf, len / 2, af_cfg->cfg.channel_num); + + // TRACE(3,"process ret:%d %d %d", *(int16_t *)(buf+len-2-2-2), + // *(int16_t *)(buf+len-2-2), *(int16_t *)(buf+len-2)); + if (af_stream_fade_out.stop_process_cnt++ > 3) { + TRACE(0, "stop_process end"); + osSignalSet(af_stream_fade_out.stop_request_tid, + (1 << AF_FADE_OUT_SIGNAL_ID)); + } + } + af_unlock_thread(); } #endif // RTOS && AF_STREAM_ID_0_PLAYBACK_FADEOUT -//used by dma irq and af_thread -static inline struct af_stream_cfg_t *af_get_stream_role(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) -{ - ASSERT(id < AUD_STREAM_ID_NUM, "[%s] Bad id=%d", __func__, id); - ASSERT(stream < AUD_STREAM_NUM, "[%s] Bad stream=%d", __func__, stream); +// used by dma irq and af_thread +static inline struct af_stream_cfg_t * +af_get_stream_role(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) { + ASSERT(id < AUD_STREAM_ID_NUM, "[%s] Bad id=%d", __func__, id); + ASSERT(stream < AUD_STREAM_NUM, "[%s] Bad stream=%d", __func__, stream); - return &af_stream[id][stream]; + return &af_stream[id][stream]; } -static void af_set_status(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream, enum AF_STATUS_T status) -{ - struct af_stream_cfg_t *role = NULL; +static void af_set_status(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream, + enum AF_STATUS_T status) { + struct af_stream_cfg_t *role = NULL; - role = af_get_stream_role(id, stream); + role = af_get_stream_role(id, stream); - role->ctl.status |= status; + role->ctl.status |= status; } -static void af_clear_status(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream, enum AF_STATUS_T status) -{ - struct af_stream_cfg_t *role = NULL; +static void af_clear_status(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream, + enum AF_STATUS_T status) { + struct af_stream_cfg_t *role = NULL; - role = af_get_stream_role(id, stream); + role = af_get_stream_role(id, stream); - role->ctl.status &= ~status; + role->ctl.status &= ~status; } -//get current stream config parameters -uint32_t af_stream_get_cfg(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream, struct AF_STREAM_CONFIG_T **cfg, bool needlock) -{ - AF_TRACE_DEBUG(); +// get current stream config parameters +uint32_t af_stream_get_cfg(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream, + struct AF_STREAM_CONFIG_T **cfg, bool needlock) { + AF_TRACE_DEBUG(); - struct af_stream_cfg_t *role; - enum AF_RESULT_T ret; + struct af_stream_cfg_t *role; + enum AF_RESULT_T ret; - if (needlock) { - af_lock_thread(); - } - role = af_get_stream_role(id, stream); - //check stream is open - if (role->ctl.status & AF_STATUS_STREAM_OPEN_CLOSE) { - *cfg = &(role->cfg); - ret = AF_RES_SUCCESS; - } else { - ret = AF_RES_FAILD; - } - if (needlock) { - af_unlock_thread(); - } - return ret; + if (needlock) { + af_lock_thread(); + } + role = af_get_stream_role(id, stream); + // check stream is open + if (role->ctl.status & AF_STATUS_STREAM_OPEN_CLOSE) { + *cfg = &(role->cfg); + ret = AF_RES_SUCCESS; + } else { + ret = AF_RES_FAILD; + } + if (needlock) { + af_unlock_thread(); + } + return ret; } #if 0 @@ -503,483 +502,472 @@ static void af_dump_cfg() #endif #ifdef AUDIO_OUTPUT_SW_GAIN -static void af_codec_output_gain_changed(float coef) -{ - saved_output_coef = coef; +static void af_codec_output_gain_changed(float coef) { + saved_output_coef = coef; } #ifndef AUDIO_OUTPUT_SW_LIMITER -static float af_codec_sw_gain_filter(float gain_in) -{ - float gain_out = saved_output_coef*sw_gain_iir.coefs_b[0] - +sw_gain_iir.history_x[0]*sw_gain_iir.coefs_b[1] - +sw_gain_iir.history_x[1]*sw_gain_iir.coefs_b[2] - -sw_gain_iir.history_y[0]*sw_gain_iir.coefs_a[1] - -sw_gain_iir.history_y[1]*sw_gain_iir.coefs_a[2]; +static float af_codec_sw_gain_filter(float gain_in) { + float gain_out = saved_output_coef * sw_gain_iir.coefs_b[0] + + sw_gain_iir.history_x[0] * sw_gain_iir.coefs_b[1] + + sw_gain_iir.history_x[1] * sw_gain_iir.coefs_b[2] - + sw_gain_iir.history_y[0] * sw_gain_iir.coefs_a[1] - + sw_gain_iir.history_y[1] * sw_gain_iir.coefs_a[2]; - sw_gain_iir.history_y[1]=sw_gain_iir.history_y[0]; - sw_gain_iir.history_y[0]=gain_out; - sw_gain_iir.history_x[1]=sw_gain_iir.history_x[0]; - sw_gain_iir.history_x[0]=saved_output_coef; + sw_gain_iir.history_y[1] = sw_gain_iir.history_y[0]; + sw_gain_iir.history_y[0] = gain_out; + sw_gain_iir.history_x[1] = sw_gain_iir.history_x[0]; + sw_gain_iir.history_x[0] = saved_output_coef; - return gain_out; + return gain_out; } -static void af_codec_sw_gain_process(uint8_t *buf, uint32_t size, enum AUD_BITS_T bits, enum AUD_CHANNEL_NUM_T chans) -{ - uint32_t i,pcm_len; - int32_t pcm_out; - float output_gain=1.0f; +static void af_codec_sw_gain_process(uint8_t *buf, uint32_t size, + enum AUD_BITS_T bits, + enum AUD_CHANNEL_NUM_T chans) { + uint32_t i, pcm_len; + int32_t pcm_out; + float output_gain = 1.0f; - //TRACE(1,"af_codec_sw_gain_process:%d",(int32_t)(saved_output_coef*1000)); - - if(chans==AUD_CHANNEL_NUM_1) - { - if (bits <= AUD_BITS_16) - { - pcm_len = size / sizeof(int16_t); - int16_t *pcm_buf = (int16_t *)buf; - for (i = 0; i < pcm_len; i++) - { - output_gain=af_codec_sw_gain_filter(saved_output_coef); + // TRACE(1,"af_codec_sw_gain_process:%d",(int32_t)(saved_output_coef*1000)); - pcm_out = (int32_t)(pcm_buf[i] * output_gain); - pcm_buf[i] = __SSAT(pcm_out, 16); - } - } - else - { - pcm_len = size / sizeof(int32_t); - int32_t *pcm_buf = (int32_t *)buf; - for (i = 0; i < pcm_len; i++) - { - output_gain=af_codec_sw_gain_filter(saved_output_coef); - - pcm_out = (int32_t)(pcm_buf[i] * output_gain); - pcm_buf[i] = __SSAT(pcm_out, 24); - } - } + if (chans == AUD_CHANNEL_NUM_1) { + if (bits <= AUD_BITS_16) { + pcm_len = size / sizeof(int16_t); + int16_t *pcm_buf = (int16_t *)buf; + for (i = 0; i < pcm_len; i++) { + output_gain = af_codec_sw_gain_filter(saved_output_coef); + + pcm_out = (int32_t)(pcm_buf[i] * output_gain); + pcm_buf[i] = __SSAT(pcm_out, 16); + } + } else { + pcm_len = size / sizeof(int32_t); + int32_t *pcm_buf = (int32_t *)buf; + for (i = 0; i < pcm_len; i++) { + output_gain = af_codec_sw_gain_filter(saved_output_coef); + + pcm_out = (int32_t)(pcm_buf[i] * output_gain); + pcm_buf[i] = __SSAT(pcm_out, 24); + } } - else if(chans==AUD_CHANNEL_NUM_2) - { - if (bits <= AUD_BITS_16) - { - pcm_len = size / sizeof(int16_t); - int16_t *pcm_buf = (int16_t *)buf; - for (i = 0; i < pcm_len; i=i+2) - { - output_gain=af_codec_sw_gain_filter(saved_output_coef); - - pcm_out = (int32_t)(pcm_buf[i] * output_gain); - pcm_buf[i] = __SSAT(pcm_out, 16); - pcm_out = (int32_t)(pcm_buf[i+1] * output_gain); - pcm_buf[i+1] = __SSAT(pcm_out, 16); - } - } - else - { - pcm_len = size / sizeof(int32_t); - int32_t *pcm_buf = (int32_t *)buf; - for (i = 0; i < pcm_len; i=i+2) - { - output_gain=af_codec_sw_gain_filter(saved_output_coef); + } else if (chans == AUD_CHANNEL_NUM_2) { + if (bits <= AUD_BITS_16) { + pcm_len = size / sizeof(int16_t); + int16_t *pcm_buf = (int16_t *)buf; + for (i = 0; i < pcm_len; i = i + 2) { + output_gain = af_codec_sw_gain_filter(saved_output_coef); - pcm_out = (int32_t)(pcm_buf[i] * output_gain); - pcm_buf[i] = __SSAT(pcm_out, 24); - pcm_out = (int32_t)(pcm_buf[i+1] * output_gain); - pcm_buf[i+1] = __SSAT(pcm_out, 24); - } - } + pcm_out = (int32_t)(pcm_buf[i] * output_gain); + pcm_buf[i] = __SSAT(pcm_out, 16); + pcm_out = (int32_t)(pcm_buf[i + 1] * output_gain); + pcm_buf[i + 1] = __SSAT(pcm_out, 16); + } + } else { + pcm_len = size / sizeof(int32_t); + int32_t *pcm_buf = (int32_t *)buf; + for (i = 0; i < pcm_len; i = i + 2) { + output_gain = af_codec_sw_gain_filter(saved_output_coef); + + pcm_out = (int32_t)(pcm_buf[i] * output_gain); + pcm_buf[i] = __SSAT(pcm_out, 24); + pcm_out = (int32_t)(pcm_buf[i + 1] * output_gain); + pcm_buf[i + 1] = __SSAT(pcm_out, 24); + } } + } } #endif #endif // AUDIO_OUTPUT_SW_GAIN -static uint32_t POSSIBLY_UNUSED af_codec_get_sample_count(uint32_t size, enum AUD_BITS_T bits, enum AUD_CHANNEL_NUM_T chans) -{ - uint32_t div; +static uint32_t POSSIBLY_UNUSED af_codec_get_sample_count( + uint32_t size, enum AUD_BITS_T bits, enum AUD_CHANNEL_NUM_T chans) { + uint32_t div; - if (bits <= AUD_BITS_16) { - div = 2; - } else { - div = 4; - } - div *= chans; - return size / div; + if (bits <= AUD_BITS_16) { + div = 2; + } else { + div = 4; + } + div *= chans; + return size / div; } -static void POSSIBLY_UNUSED af_zero_mem(void *dst, unsigned int size) -{ - uint32_t *d = dst; - uint32_t count = size / 4; +static void POSSIBLY_UNUSED af_zero_mem(void *dst, unsigned int size) { + uint32_t *d = dst; + uint32_t count = size / 4; - while (count--) { - *d++ = 0; - } + while (count--) { + *d++ = 0; + } } -static bool af_codec_playback_pre_handler(uint8_t *buf, uint32_t len, const struct af_stream_cfg_t *role) -{ - uint32_t POSSIBLY_UNUSED time; +static bool af_codec_playback_pre_handler(uint8_t *buf, uint32_t len, + const struct af_stream_cfg_t *role) { + uint32_t POSSIBLY_UNUSED time; - if (0) { + if (0) { #ifdef AUDIO_OUTPUT_PA_ON_FADE_IN - } else if (dac_pa_state == AF_DAC_PA_ON_TRIGGER && - (time = hal_sys_timer_get()) - dac_dc_start_time >= AF_CODEC_DC_STABLE_INTERVAL && - time - dac_pa_stop_time >= AF_CODEC_PA_RESTART_INTERVAL) { - analog_aud_codec_speaker_enable(true); - dac_pa_state = AF_DAC_PA_NULL; + } else if (dac_pa_state == AF_DAC_PA_ON_TRIGGER && + (time = hal_sys_timer_get()) - dac_dc_start_time >= + AF_CODEC_DC_STABLE_INTERVAL && + time - dac_pa_stop_time >= AF_CODEC_PA_RESTART_INTERVAL) { + analog_aud_codec_speaker_enable(true); + dac_pa_state = AF_DAC_PA_NULL; #endif // AUDIO_OUTPUT_PA_ON_FADE_IN #ifdef AUDIO_OUTPUT_PA_OFF_FADE_OUT - } else if (dac_pa_state == AF_DAC_PA_OFF_TRIGGER) { - dac_dc_start_time = hal_sys_timer_get(); - dac_pa_state = AF_DAC_PA_OFF_DC_START; - } else if (dac_pa_state == AF_DAC_PA_OFF_DC_START) { - time = hal_sys_timer_get(); - if (time - dac_dc_start_time >= AF_CODEC_DC_STABLE_INTERVAL) { - dac_pa_state = AF_DAC_PA_NULL; - analog_aud_codec_speaker_enable(false); - dac_pa_stop_time = time; + } else if (dac_pa_state == AF_DAC_PA_OFF_TRIGGER) { + dac_dc_start_time = hal_sys_timer_get(); + dac_pa_state = AF_DAC_PA_OFF_DC_START; + } else if (dac_pa_state == AF_DAC_PA_OFF_DC_START) { + time = hal_sys_timer_get(); + if (time - dac_dc_start_time >= AF_CODEC_DC_STABLE_INTERVAL) { + dac_pa_state = AF_DAC_PA_NULL; + analog_aud_codec_speaker_enable(false); + dac_pa_stop_time = time; #ifdef RTOS - osSignalSet(fade_thread_id, (1 << AF_FADE_OUT_SIGNAL_ID)); + osSignalSet(fade_thread_id, (1 << AF_FADE_OUT_SIGNAL_ID)); #endif - } -#endif // AUDIO_OUTPUT_PA_OFF_FADE_OUT - } +#endif // AUDIO_OUTPUT_PA_OFF_FADE_OUT + } #if defined(AUDIO_OUTPUT_PA_ON_FADE_IN) || defined(AUDIO_OUTPUT_PA_OFF_FADE_OUT) - if (dac_pa_state == AF_DAC_PA_ON_TRIGGER || dac_pa_state == AF_DAC_PA_OFF_DC_START) { - af_zero_mem(buf, len); - return true; - } + if (dac_pa_state == AF_DAC_PA_ON_TRIGGER || + dac_pa_state == AF_DAC_PA_OFF_DC_START) { + af_zero_mem(buf, len); + return true; + } #endif - return false; + return false; } #ifdef AUDIO_OUTPUT_DC_CALIB_SW -static void af_codec_playback_sw_dc_calib(uint8_t *buf, uint32_t len, enum AUD_BITS_T bits, enum AUD_CHANNEL_NUM_T chans) -{ - uint32_t cnt; +static void af_codec_playback_sw_dc_calib(uint8_t *buf, uint32_t len, + enum AUD_BITS_T bits, + enum AUD_CHANNEL_NUM_T chans) { + uint32_t cnt; - if (bits <= AUD_BITS_16) { - int16_t *ptr16 = (int16_t *)buf; + if (bits <= AUD_BITS_16) { + int16_t *ptr16 = (int16_t *)buf; #ifdef AUDIO_OUTPUT_DC_CALIB_SW - int16_t dc_l = dac_dc[0]; - int16_t dc_r = dac_dc[1]; + int16_t dc_l = dac_dc[0]; + int16_t dc_r = dac_dc[1]; #endif - if (chans == AUD_CHANNEL_NUM_1) { - cnt = len / sizeof(int16_t); - while (cnt-- > 0) { + if (chans == AUD_CHANNEL_NUM_1) { + cnt = len / sizeof(int16_t); + while (cnt-- > 0) { #ifdef AUDIO_OUTPUT_DC_CALIB_SW - *ptr16 = __SSAT(*ptr16 + dc_l, 16); + *ptr16 = __SSAT(*ptr16 + dc_l, 16); #endif - ptr16++; - } - } else { - cnt = len / sizeof(int16_t) / 2; - while (cnt-- > 0) { -#ifdef AUDIO_OUTPUT_DC_CALIB_SW - *ptr16 = __SSAT(*ptr16 + dc_l, 16); - *(ptr16 + 1) = __SSAT(*(ptr16 + 1) + dc_r, 16); -#endif - ptr16 += 2; - } - } + ptr16++; + } } else { - int32_t *ptr32 = (int32_t *)buf; - int32_t dac_bits = -#ifdef CHIP_BEST1000 - CODEC_PLAYBACK_BIT_DEPTH; -#else - 24; -#endif - int32_t val_shift; - - if (dac_bits < 24) { - val_shift = 24 - dac_bits; - } else { - val_shift = 0; - } - + cnt = len / sizeof(int16_t) / 2; + while (cnt-- > 0) { #ifdef AUDIO_OUTPUT_DC_CALIB_SW - int32_t dc_l = dac_dc[0] << 8; - int32_t dc_r = dac_dc[1] << 8; + *ptr16 = __SSAT(*ptr16 + dc_l, 16); + *(ptr16 + 1) = __SSAT(*(ptr16 + 1) + dc_r, 16); #endif - if (chans == AUD_CHANNEL_NUM_1) { - cnt = len / sizeof(int32_t); - while (cnt-- > 0) { -#ifdef CORRECT_SAMPLE_VALUE - *ptr32 = ((*ptr32) << (32 - dac_bits)) >> (32 - dac_bits); -#endif -#ifdef AUDIO_OUTPUT_DC_CALIB_SW - *ptr32 = __SSAT((*ptr32 + dc_l) >> val_shift, dac_bits); -#elif defined(CORRECT_SAMPLE_VALUE) - *ptr32 = __SSAT(*ptr32 >> val_shift, dac_bits); -#else - *ptr32 = *ptr32 >> val_shift; -#endif - ptr32++; - } - } else { - cnt = len / sizeof(int32_t) / 2; - while (cnt-- > 0) { -#ifdef CORRECT_SAMPLE_VALUE - *ptr32 = ((*ptr32) << (32 - dac_bits)) >> (32 - dac_bits); - *(ptr32 + 1) = ((*(ptr32 + 1)) << (32 - dac_bits)) >> (32 - dac_bits); -#endif -#ifdef AUDIO_OUTPUT_DC_CALIB_SW - *ptr32 = __SSAT((*ptr32 + dc_l) >> val_shift, dac_bits); - *(ptr32 + 1) = __SSAT((*(ptr32 + 1) + dc_r) >> val_shift, dac_bits); -#elif defined(CORRECT_SAMPLE_VALUE) - *ptr32 = __SSAT(*ptr32 >> val_shift, dac_bits); - *(ptr32 + 1) = __SSAT(*(ptr32 + 1) >> val_shift, dac_bits); -#else - *ptr32 = *ptr32 >> val_shift; - *(ptr32 + 1) = *(ptr32 + 1) >> val_shift; -#endif - ptr32 += 2; - } - } + ptr16 += 2; + } } + } else { + int32_t *ptr32 = (int32_t *)buf; + int32_t dac_bits = +#ifdef CHIP_BEST1000 + CODEC_PLAYBACK_BIT_DEPTH; +#else + 24; +#endif + int32_t val_shift; + + if (dac_bits < 24) { + val_shift = 24 - dac_bits; + } else { + val_shift = 0; + } + +#ifdef AUDIO_OUTPUT_DC_CALIB_SW + int32_t dc_l = dac_dc[0] << 8; + int32_t dc_r = dac_dc[1] << 8; +#endif + if (chans == AUD_CHANNEL_NUM_1) { + cnt = len / sizeof(int32_t); + while (cnt-- > 0) { +#ifdef CORRECT_SAMPLE_VALUE + *ptr32 = ((*ptr32) << (32 - dac_bits)) >> (32 - dac_bits); +#endif +#ifdef AUDIO_OUTPUT_DC_CALIB_SW + *ptr32 = __SSAT((*ptr32 + dc_l) >> val_shift, dac_bits); +#elif defined(CORRECT_SAMPLE_VALUE) + *ptr32 = __SSAT(*ptr32 >> val_shift, dac_bits); +#else + *ptr32 = *ptr32 >> val_shift; +#endif + ptr32++; + } + } else { + cnt = len / sizeof(int32_t) / 2; + while (cnt-- > 0) { +#ifdef CORRECT_SAMPLE_VALUE + *ptr32 = ((*ptr32) << (32 - dac_bits)) >> (32 - dac_bits); + *(ptr32 + 1) = ((*(ptr32 + 1)) << (32 - dac_bits)) >> (32 - dac_bits); +#endif +#ifdef AUDIO_OUTPUT_DC_CALIB_SW + *ptr32 = __SSAT((*ptr32 + dc_l) >> val_shift, dac_bits); + *(ptr32 + 1) = __SSAT((*(ptr32 + 1) + dc_r) >> val_shift, dac_bits); +#elif defined(CORRECT_SAMPLE_VALUE) + *ptr32 = __SSAT(*ptr32 >> val_shift, dac_bits); + *(ptr32 + 1) = __SSAT(*(ptr32 + 1) >> val_shift, dac_bits); +#else + *ptr32 = *ptr32 >> val_shift; + *(ptr32 + 1) = *(ptr32 + 1) >> val_shift; +#endif + ptr32 += 2; + } + } + } } #endif // AUDIO_OUTPUT_DC_CALIB_SW -static void af_codec_playback_post_handler(uint8_t *buf, uint32_t len, const struct af_stream_cfg_t *role) -{ - POSSIBLY_UNUSED enum AUD_BITS_T bits; - POSSIBLY_UNUSED enum AUD_CHANNEL_NUM_T chans; - POSSIBLY_UNUSED uint32_t cnt; +static void af_codec_playback_post_handler(uint8_t *buf, uint32_t len, + const struct af_stream_cfg_t *role) { + POSSIBLY_UNUSED enum AUD_BITS_T bits; + POSSIBLY_UNUSED enum AUD_CHANNEL_NUM_T chans; + POSSIBLY_UNUSED uint32_t cnt; - bits = role->cfg.bits; - chans = role->cfg.channel_num; + bits = role->cfg.bits; + chans = role->cfg.channel_num; #ifdef AUDIO_OUTPUT_SW_GAIN #ifdef AUDIO_OUTPUT_SW_LIMITER - if (bits <= AUD_BITS_16) { - cnt = len / sizeof(int16_t); - } else { - cnt = len / sizeof(int32_t); - } - ApplyFloatLimiter(FloatLimiterP, buf, saved_output_coef, cnt); + if (bits <= AUD_BITS_16) { + cnt = len / sizeof(int16_t); + } else { + cnt = len / sizeof(int32_t); + } + ApplyFloatLimiter(FloatLimiterP, buf, saved_output_coef, cnt); #else - af_codec_sw_gain_process(buf,len,bits,chans); + af_codec_sw_gain_process(buf, len, bits, chans); #endif #endif - if (codec_play_post_hdlr) { - codec_play_post_hdlr(buf, len, (void *)&role->cfg); - } + if (codec_play_post_hdlr) { + codec_play_post_hdlr(buf, len, (void *)&role->cfg); + } #if defined(AUDIO_OUTPUT_INVERT_RIGHT_CHANNEL) - if (chans == AUD_CHANNEL_NUM_2) { - if (bits == AUD_BITS_16) { - int16_t *buf16 = (int16_t *)buf; - for (int i = 1; i < len / sizeof(int16_t); i += 2) { - int32_t tmp = -buf16[i]; - buf16[i] = __SSAT(tmp, 16); - } - } else { - int32_t *buf32 = (int32_t *)buf; - for (int i = 1; i < len / sizeof(int32_t); i += 2) { - int32_t tmp = -buf32[i]; - buf32[i] = __SSAT(tmp, 24); - } - } + if (chans == AUD_CHANNEL_NUM_2) { + if (bits == AUD_BITS_16) { + int16_t *buf16 = (int16_t *)buf; + for (int i = 1; i < len / sizeof(int16_t); i += 2) { + int32_t tmp = -buf16[i]; + buf16[i] = __SSAT(tmp, 16); + } + } else { + int32_t *buf32 = (int32_t *)buf; + for (int i = 1; i < len / sizeof(int32_t); i += 2) { + int32_t tmp = -buf32[i]; + buf32[i] = __SSAT(tmp, 24); + } } + } #endif -#if (defined(CHIP_BEST1000) || defined(CHIP_BEST2000)) && defined(AUDIO_OUTPUT_CALIB_GAIN_MISSMATCH) - // gain must less than 1.0 - float gain = 0.9441f; - if (chans == AUD_CHANNEL_NUM_2) { - if (bits == AUD_BITS_16) { - int16_t *buf16 = (int16_t *)buf; - for (int i = 1; i < len / sizeof(int16_t); i += 2) { - int32_t tmp = (int)(buf16[i + 1] * gain); - buf16[i + 1] = __SSAT(tmp, 16); - } - } else { - int32_t *buf32 = (int32_t *)buf; - for (int i = 1; i < len / sizeof(int32_t); i += 2) { - int32_t tmp = (int)(buf32[i + 1] * gain); - buf32[i + 1] = __SSAT(tmp, 24); - } - } +#if (defined(CHIP_BEST1000) || defined(CHIP_BEST2000)) && \ + defined(AUDIO_OUTPUT_CALIB_GAIN_MISSMATCH) + // gain must less than 1.0 + float gain = 0.9441f; + if (chans == AUD_CHANNEL_NUM_2) { + if (bits == AUD_BITS_16) { + int16_t *buf16 = (int16_t *)buf; + for (int i = 1; i < len / sizeof(int16_t); i += 2) { + int32_t tmp = (int)(buf16[i + 1] * gain); + buf16[i + 1] = __SSAT(tmp, 16); + } + } else { + int32_t *buf32 = (int32_t *)buf; + for (int i = 1; i < len / sizeof(int32_t); i += 2) { + int32_t tmp = (int)(buf32[i + 1] * gain); + buf32[i + 1] = __SSAT(tmp, 24); + } } + } #endif #if defined(AUDIO_OUTPUT_DC_CALIB_SW) - af_codec_playback_sw_dc_calib(buf, len, bits, chans); + af_codec_playback_sw_dc_calib(buf, len, bits, chans); #elif defined(CHIP_BEST1000) - if (bits == AUD_BITS_24 || bits == AUD_BITS_32) { - int32_t *ptr32 = (int32_t *)buf; - int32_t val_shift; + if (bits == AUD_BITS_24 || bits == AUD_BITS_32) { + int32_t *ptr32 = (int32_t *)buf; + int32_t val_shift; - if (bits == AUD_BITS_24) { - val_shift = 24 - CODEC_PLAYBACK_BIT_DEPTH; - } else { - val_shift = 32 - CODEC_PLAYBACK_BIT_DEPTH; - } - - cnt = len / sizeof(int32_t); - while (cnt-- > 0) { - *ptr32 >>= val_shift; - ptr32++; - } + if (bits == AUD_BITS_24) { + val_shift = 24 - CODEC_PLAYBACK_BIT_DEPTH; + } else { + val_shift = 32 - CODEC_PLAYBACK_BIT_DEPTH; } + + cnt = len / sizeof(int32_t); + while (cnt-- > 0) { + *ptr32 >>= val_shift; + ptr32++; + } + } #endif #if defined(CHIP_BEST1000) && defined(AUDIO_OUTPUT_GAIN_M60DB_CHECK) - hal_codec_dac_gain_m60db_check(HAL_CODEC_PERF_TEST_M60DB); + hal_codec_dac_gain_m60db_check(HAL_CODEC_PERF_TEST_M60DB); #endif } -static inline void af_thread_stream_handler(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) -{ - uint32_t lock; - struct af_stream_cfg_t *role; - uint32_t dma_addr, hw_pos; - uint8_t *buf; - uint32_t len; - uint32_t pp_cnt; - bool codec_playback; - bool skip_handler; - enum AF_PP_T pp_index; +static inline void af_thread_stream_handler(enum AUD_STREAM_ID_T id, + enum AUD_STREAM_T stream) { + uint32_t lock; + struct af_stream_cfg_t *role; + uint32_t dma_addr, hw_pos; + uint8_t *buf; + uint32_t len; + uint32_t pp_cnt; + bool codec_playback; + bool skip_handler; + enum AF_PP_T pp_index; - role = af_get_stream_role(id, stream); + role = af_get_stream_role(id, stream); - af_lock_thread(); + af_lock_thread(); - if (role->handler && (role->ctl.status & AF_STATUS_STREAM_START_STOP)) { - lock = int_lock(); - pp_cnt = role->ctl.pp_cnt; - role->ctl.pp_cnt = 0; - int_unlock(lock); + if (role->handler && (role->ctl.status & AF_STATUS_STREAM_START_STOP)) { + lock = int_lock(); + pp_cnt = role->ctl.pp_cnt; + role->ctl.pp_cnt = 0; + int_unlock(lock); - af_sig_lost_cnt[id][stream] = pp_cnt - 1; - if (af_sig_lost_cnt[id][stream]) { - TRACE(3,"af_thread:WARNING: id=%d stream=%d lost %u signals", id, stream, af_sig_lost_cnt[id][stream]); - } - - pp_index = PP_PINGPANG(role->ctl.pp_index); - - // Get PP index from accurate DMA pos - dma_addr = af_stream_get_cur_dma_addr(id, stream); - hw_pos = dma_addr - (uint32_t)role->dma_buf_ptr; - if (hw_pos > role->dma_buf_size) { - TRACE(3,"af_thread: Failed to get valid dma addr for id=%d stream=%d: 0x%08x", id, stream, dma_addr); - } -#ifndef CHIP_BEST1000 - if (role->cfg.chan_sep_buf && role->cfg.channel_num > AUD_CHANNEL_NUM_1) { - uint32_t chan_size; - - chan_size = role->dma_buf_size / role->cfg.channel_num; - - if (hw_pos <= role->dma_buf_size) { - hw_pos = hw_pos % chan_size; - if (hw_pos < chan_size / 2) { - pp_index = PP_PANG; - } else if (hw_pos < chan_size) { - pp_index = PP_PING; - } - } - if (pp_index == PP_PING) { - buf = role->dma_buf_ptr; - } else { - buf = role->dma_buf_ptr + chan_size / 2; - } - } else -#endif - { - if (hw_pos < role->dma_buf_size / 2) { - pp_index = PP_PANG; - } else if (hw_pos < role->dma_buf_size) { - pp_index = PP_PING; - } - if (pp_index == PP_PING) { - buf = role->dma_buf_ptr; - } else { - buf = role->dma_buf_ptr + role->dma_buf_size / 2; - } - } - - if (stream == AUD_STREAM_PLAYBACK && role->ctl.use_device == AUD_STREAM_USE_INT_CODEC) { - codec_playback = true; - } else { - codec_playback = false; - } - - skip_handler = false; - len = role->dma_buf_size / 2; - - if (codec_playback) { - skip_handler = af_codec_playback_pre_handler(buf, len, role); - } - - if (!skip_handler) { -#ifdef __RAND_FROM_MIC__ - if ((AUD_STREAM_CAPTURE == stream) && (AUD_STREAM_USE_INT_CODEC == role->cfg.device)) - { - random_data_process(buf, role->dma_buf_size / 2, role->cfg.bits, role->cfg.channel_num); - } -#endif - role->handler(buf, len); - } - - if (codec_playback) { - af_codec_playback_post_handler(buf, len, role); - } - -#if defined(RTOS) && defined(AF_STREAM_ID_0_PLAYBACK_FADEOUT) - af_stream_stop_process(role, buf, len); -#endif - - if (role->ctl.pp_cnt) { - TRACE(3,"af_thread:WARNING: id=%d stream=%d hdlr ran too long (pp_cnt=%u)", id, stream, role->ctl.pp_cnt); - } + af_sig_lost_cnt[id][stream] = pp_cnt - 1; + if (af_sig_lost_cnt[id][stream]) { + TRACE(3, "af_thread:WARNING: id=%d stream=%d lost %u signals", id, stream, + af_sig_lost_cnt[id][stream]); } - af_unlock_thread(); + pp_index = PP_PINGPANG(role->ctl.pp_index); + + // Get PP index from accurate DMA pos + dma_addr = af_stream_get_cur_dma_addr(id, stream); + hw_pos = dma_addr - (uint32_t)role->dma_buf_ptr; + if (hw_pos > role->dma_buf_size) { + TRACE( + 3, + "af_thread: Failed to get valid dma addr for id=%d stream=%d: 0x%08x", + id, stream, dma_addr); + } +#ifndef CHIP_BEST1000 + if (role->cfg.chan_sep_buf && role->cfg.channel_num > AUD_CHANNEL_NUM_1) { + uint32_t chan_size; + + chan_size = role->dma_buf_size / role->cfg.channel_num; + + if (hw_pos <= role->dma_buf_size) { + hw_pos = hw_pos % chan_size; + if (hw_pos < chan_size / 2) { + pp_index = PP_PANG; + } else if (hw_pos < chan_size) { + pp_index = PP_PING; + } + } + if (pp_index == PP_PING) { + buf = role->dma_buf_ptr; + } else { + buf = role->dma_buf_ptr + chan_size / 2; + } + } else +#endif + { + if (hw_pos < role->dma_buf_size / 2) { + pp_index = PP_PANG; + } else if (hw_pos < role->dma_buf_size) { + pp_index = PP_PING; + } + if (pp_index == PP_PING) { + buf = role->dma_buf_ptr; + } else { + buf = role->dma_buf_ptr + role->dma_buf_size / 2; + } + } + + if (stream == AUD_STREAM_PLAYBACK && + role->ctl.use_device == AUD_STREAM_USE_INT_CODEC) { + codec_playback = true; + } else { + codec_playback = false; + } + + skip_handler = false; + len = role->dma_buf_size / 2; + + if (codec_playback) { + skip_handler = af_codec_playback_pre_handler(buf, len, role); + } + + if (!skip_handler) { +#ifdef __RAND_FROM_MIC__ + if ((AUD_STREAM_CAPTURE == stream) && + (AUD_STREAM_USE_INT_CODEC == role->cfg.device)) { + random_data_process(buf, role->dma_buf_size / 2, role->cfg.bits, + role->cfg.channel_num); + } +#endif + role->handler(buf, len); + } + + if (codec_playback) { + af_codec_playback_post_handler(buf, len, role); + } + +#if defined(RTOS) && defined(AF_STREAM_ID_0_PLAYBACK_FADEOUT) + af_stream_stop_process(role, buf, len); +#endif + + if (role->ctl.pp_cnt) { + TRACE(3, + "af_thread:WARNING: id=%d stream=%d hdlr ran too long (pp_cnt=%u)", + id, stream, role->ctl.pp_cnt); + } + } + + af_unlock_thread(); } #ifdef RTOS -static void af_thread(void const *argument) -{ - osEvent evt; - uint32_t signals = 0; - enum AUD_STREAM_ID_T id; - enum AUD_STREAM_T stream; +static void af_thread(void const *argument) { + osEvent evt; + uint32_t signals = 0; + enum AUD_STREAM_ID_T id; + enum AUD_STREAM_T stream; - while(1) - { - //wait any signal - evt = osSignalWait(0x0, osWaitForever); - signals = evt.value.signals; -// TRACE(3,"[%s] status = %x, signals = %d", __func__, evt.status, evt.value.signals); + while (1) { + // wait any signal + evt = osSignalWait(0x0, osWaitForever); + signals = evt.value.signals; + // TRACE(3,"[%s] status = %x, signals = %d", __func__, evt.status, + // evt.value.signals); - if(evt.status == osEventSignal) - { - for(uint8_t i=0; i> 1); - stream = (enum AUD_STREAM_T)(i & 1); + if (evt.status == osEventSignal) { + for (uint8_t i = 0; i < AUD_STREAM_ID_NUM * AUD_STREAM_NUM; i++) { + if (signals & (1 << i)) { + id = (enum AUD_STREAM_ID_T)(i >> 1); + stream = (enum AUD_STREAM_T)(i & 1); - af_thread_stream_handler(id, stream); - - } - } - } - else - { - TRACE(2,"[%s] ERROR: evt.status = %d", __func__, evt.status); - continue; + af_thread_stream_handler(id, stream); } + } + } else { + TRACE(2, "[%s] ERROR: evt.status = %d", __func__, evt.status); + continue; } + } } #else // !RTOS @@ -988,2271 +976,2179 @@ static void af_thread(void const *argument) static volatile uint32_t af_flag_open; static volatile uint32_t af_flag_signal; -static void af_set_flag(volatile uint32_t *flag, uint32_t set) -{ - uint32_t lock; +static void af_set_flag(volatile uint32_t *flag, uint32_t set) { + uint32_t lock; - lock = int_lock(); - *flag |= set; - int_unlock(lock); + lock = int_lock(); + *flag |= set; + int_unlock(lock); } -static void af_clear_flag(volatile uint32_t *flag, uint32_t clear) -{ - uint32_t lock; +static void af_clear_flag(volatile uint32_t *flag, uint32_t clear) { + uint32_t lock; - lock = int_lock(); - *flag &= ~clear; - int_unlock(lock); + lock = int_lock(); + *flag &= ~clear; + int_unlock(lock); } -static bool af_flag_active(volatile uint32_t *flag, uint32_t bits) -{ - return !!(*flag & bits); +static bool af_flag_active(volatile uint32_t *flag, uint32_t bits) { + return !!(*flag & bits); } -void af_thread(void const *argument) -{ - uint32_t lock; - uint32_t i; - enum AUD_STREAM_ID_T id; - enum AUD_STREAM_T stream; +void af_thread(void const *argument) { + uint32_t lock; + uint32_t i; + enum AUD_STREAM_ID_T id; + enum AUD_STREAM_T stream; - if (af_flag_open == 0) { - return; + if (af_flag_open == 0) { + return; + } + + for (i = 0; i < AUD_STREAM_ID_NUM * AUD_STREAM_NUM; i++) { + if (!af_flag_active(&af_flag_signal, 1 << i)) { + continue; } + af_clear_flag(&af_flag_signal, 1 << i); - for (i = 0; i < AUD_STREAM_ID_NUM * AUD_STREAM_NUM; i++) { - if (!af_flag_active(&af_flag_signal, 1 << i)) { - continue; - } - af_clear_flag(&af_flag_signal, 1 << i); + id = (enum AUD_STREAM_ID_T)(i >> 1); + stream = (enum AUD_STREAM_T)(i & 1); - id = (enum AUD_STREAM_ID_T)(i >> 1); - stream = (enum AUD_STREAM_T)(i & 1); + af_thread_stream_handler(id, stream); + } - af_thread_stream_handler(id, stream); - } - - lock = int_lock(); - if (af_flag_signal == 0) { - hal_cpu_wake_unlock(AF_CPU_WAKE_USER); - } - int_unlock(lock); + lock = int_lock(); + if (af_flag_signal == 0) { + hal_cpu_wake_unlock(AF_CPU_WAKE_USER); + } + int_unlock(lock); } #endif // !RTOS -static void af_dma_irq_handler(uint8_t ch, uint32_t remain_dst_tsize, uint32_t error, struct HAL_DMA_DESC_T *lli) -{ - struct af_stream_cfg_t *role = NULL; +static void af_dma_irq_handler(uint8_t ch, uint32_t remain_dst_tsize, + uint32_t error, struct HAL_DMA_DESC_T *lli) { + struct af_stream_cfg_t *role = NULL; - //initial parameter - for(uint8_t id=0; id< AUD_STREAM_ID_NUM; id++) - { - for(uint8_t stream=0; stream < AUD_STREAM_NUM; stream++) - { - role = af_get_stream_role((enum AUD_STREAM_ID_T)id, (enum AUD_STREAM_T)stream); + // initial parameter + for (uint8_t id = 0; id < AUD_STREAM_ID_NUM; id++) { + for (uint8_t stream = 0; stream < AUD_STREAM_NUM; stream++) { + role = af_get_stream_role((enum AUD_STREAM_ID_T)id, + (enum AUD_STREAM_T)stream); - if(role->dma_cfg.ch == ch) - { - role->ctl.pp_index = PP_PINGPANG(role->ctl.pp_index); - role->ctl.pp_cnt++; - //TRACE(4,"[%s] id = %d, stream = %d, ch = %d", __func__, id, stream, ch); - //TRACE(2,"[%s] PLAYBACK pp_cnt = %d", __func__, role->ctl.pp_cnt); + if (role->dma_cfg.ch == ch) { + role->ctl.pp_index = PP_PINGPANG(role->ctl.pp_index); + role->ctl.pp_cnt++; + // TRACE(4,"[%s] id = %d, stream = %d, ch = %d", __func__, id, stream, + // ch); TRACE(2,"[%s] PLAYBACK pp_cnt = %d", __func__, + // role->ctl.pp_cnt); #ifdef RTOS - if (irq_notif) { - irq_notif(id, stream); - } - osSignalSet(af_thread_tid, 0x01 << (id * 2 + stream)); -#else - af_set_flag(&af_flag_signal, 0x01 << (id * 2 + stream)); - hal_cpu_wake_lock(AF_CPU_WAKE_USER); -#endif - return; - } + if (irq_notif) { + irq_notif(id, stream); } + osSignalSet(af_thread_tid, 0x01 << (id * 2 + stream)); +#else + af_set_flag(&af_flag_signal, 0x01 << (id * 2 + stream)); + hal_cpu_wake_lock(AF_CPU_WAKE_USER); +#endif + return; + } } + } - //invalid dma irq - ASSERT(0, "[%s] ERROR: channel id = %d", __func__, ch); + // invalid dma irq + ASSERT(0, "[%s] ERROR: channel id = %d", __func__, ch); } #ifdef __CODEC_ASYNC_CLOSE__ -static void af_codec_async_close(void) -{ - af_lock_thread(); - codec_int_close(CODEC_CLOSE_ASYNC_REAL); - af_unlock_thread(); +static void af_codec_async_close(void) { + af_lock_thread(); + codec_int_close(CODEC_CLOSE_ASYNC_REAL); + af_unlock_thread(); } #endif -void *af_thread_tid_get(void) -{ +void *af_thread_tid_get(void) { #ifdef RTOS - return (void *)af_thread_tid; + return (void *)af_thread_tid; #else - return NULL; + return NULL; #endif } #ifdef CODEC_ANC_BOOST -static void af_codec_anc_boost_delay(uint32_t ms) -{ - af_unlock_thread(); +static void af_codec_anc_boost_delay(uint32_t ms) { + af_unlock_thread(); - osDelay(ms); + osDelay(ms); - af_lock_thread(); + af_lock_thread(); } #endif -uint32_t af_open(void) -{ - AF_TRACE_DEBUG(); - struct af_stream_cfg_t *role = NULL; +uint32_t af_open(void) { + AF_TRACE_DEBUG(); + struct af_stream_cfg_t *role = NULL; #ifdef RTOS - if (audioflinger_mutex_id == NULL) - { - audioflinger_mutex_id = osMutexCreate((osMutex(audioflinger_mutex))); - } + if (audioflinger_mutex_id == NULL) { + audioflinger_mutex_id = osMutexCreate((osMutex(audioflinger_mutex))); + } #endif - af_lock_thread(); + af_lock_thread(); #ifdef AUDIO_OUTPUT_DC_CALIB - if (!dac_dc_valid) { - int16_t dc_l, dc_r; - uint16_t max_dc; - float attn; + if (!dac_dc_valid) { + int16_t dc_l, dc_r; + uint16_t max_dc; + float attn; - dac_dc_valid = true; - analog_aud_get_dc_calib_value(&dc_l, &dc_r); - if (ABS(dc_l) >= ABS(dc_r)) { - max_dc = ABS(dc_l); - } else { - max_dc = ABS(dc_r); - } - ASSERT(max_dc + 1 < AF_CODEC_DC_MAX_SCALE, "Bad dc values: (%d, %d)", dc_l, dc_r); - if (max_dc) { - attn = 1 - (float)(max_dc + 1) / AF_CODEC_DC_MAX_SCALE; - } else { - attn = 1; - } - hal_codec_set_dac_dc_gain_attn(attn); -#ifdef AUDIO_OUTPUT_DC_CALIB_SW - dac_dc[0] = dc_l; - dac_dc[1] = dc_r; -#else - hal_codec_set_dac_dc_offset(dc_l, dc_r); -#endif + dac_dc_valid = true; + analog_aud_get_dc_calib_value(&dc_l, &dc_r); + if (ABS(dc_l) >= ABS(dc_r)) { + max_dc = ABS(dc_l); + } else { + max_dc = ABS(dc_r); } + ASSERT(max_dc + 1 < AF_CODEC_DC_MAX_SCALE, "Bad dc values: (%d, %d)", dc_l, + dc_r); + if (max_dc) { + attn = 1 - (float)(max_dc + 1) / AF_CODEC_DC_MAX_SCALE; + } else { + attn = 1; + } + hal_codec_set_dac_dc_gain_attn(attn); +#ifdef AUDIO_OUTPUT_DC_CALIB_SW + dac_dc[0] = dc_l; + dac_dc[1] = dc_r; +#else + hal_codec_set_dac_dc_offset(dc_l, dc_r); +#endif + } #endif #ifdef AUDIO_OUTPUT_SW_GAIN - hal_codec_set_sw_output_coef_callback(af_codec_output_gain_changed); + hal_codec_set_sw_output_coef_callback(af_codec_output_gain_changed); #endif #ifdef __CODEC_ASYNC_CLOSE__ - codec_int_set_close_handler(af_codec_async_close); + codec_int_set_close_handler(af_codec_async_close); #endif #ifdef CODEC_ANC_BOOST - codec_set_anc_boost_delay_func(af_codec_anc_boost_delay); + codec_set_anc_boost_delay_func(af_codec_anc_boost_delay); #endif - //initial parameters - for(uint8_t id=0; id< AUD_STREAM_ID_NUM; id++) - { - for(uint8_t stream=0; stream < AUD_STREAM_NUM; stream++) - { - role = af_get_stream_role((enum AUD_STREAM_ID_T)id, (enum AUD_STREAM_T)stream); + // initial parameters + for (uint8_t id = 0; id < AUD_STREAM_ID_NUM; id++) { + for (uint8_t stream = 0; stream < AUD_STREAM_NUM; stream++) { + role = af_get_stream_role((enum AUD_STREAM_ID_T)id, + (enum AUD_STREAM_T)stream); - if(role->ctl.status == AF_STATUS_NULL) - { - role->dma_buf_ptr = NULL; - role->dma_buf_size = 0; - role->ctl.pp_index = PP_PING; - role->ctl.status = AF_STATUS_OPEN_CLOSE; - role->ctl.use_device = AUD_STREAM_USE_DEVICE_NULL; - role->dma_cfg.ch = HAL_DMA_CHAN_NONE; - } - else - { - ASSERT(0, "[%s] ERROR: id = %d, stream = %d", __func__, id, stream); - } - } + if (role->ctl.status == AF_STATUS_NULL) { + role->dma_buf_ptr = NULL; + role->dma_buf_size = 0; + role->ctl.pp_index = PP_PING; + role->ctl.status = AF_STATUS_OPEN_CLOSE; + role->ctl.use_device = AUD_STREAM_USE_DEVICE_NULL; + role->dma_cfg.ch = HAL_DMA_CHAN_NONE; + } else { + ASSERT(0, "[%s] ERROR: id = %d, stream = %d", __func__, id, stream); + } } + } #ifdef RTOS - af_thread_tid = osThreadCreate(osThread(af_thread), NULL); - af_default_priority = af_get_priority(); - osSignalSet(af_thread_tid, 0x0); + af_thread_tid = osThreadCreate(osThread(af_thread), NULL); + af_default_priority = af_get_priority(); + osSignalSet(af_thread_tid, 0x0); #endif #ifdef __RAND_FROM_MIC__ - randInit(); + randInit(); #endif - af_unlock_thread(); + af_unlock_thread(); - return AF_RES_SUCCESS; + return AF_RES_SUCCESS; } -static void af_stream_update_dma_buffer(enum AUD_STREAM_T stream, struct af_stream_cfg_t *role, const struct AF_STREAM_CONFIG_T *cfg) -{ - int i; - enum HAL_DMA_RET_T dma_ret; - struct HAL_DMA_DESC_T *dma_desc, *next_desc; - struct HAL_DMA_CH_CFG_T *dma_cfg; - int irq; - uint32_t desc_xfer_size; - uint32_t align; - uint8_t samp_size; - enum HAL_DMA_WDITH_T width; +static void af_stream_update_dma_buffer(enum AUD_STREAM_T stream, + struct af_stream_cfg_t *role, + const struct AF_STREAM_CONFIG_T *cfg) { + int i; + enum HAL_DMA_RET_T dma_ret; + struct HAL_DMA_DESC_T *dma_desc, *next_desc; + struct HAL_DMA_CH_CFG_T *dma_cfg; + int irq; + uint32_t desc_xfer_size; + uint32_t align; + uint8_t samp_size; + enum HAL_DMA_WDITH_T width; #ifndef CHIP_BEST1000 - bool dma_2d_en; - uint32_t chan_desc_xfer_size = 0; + bool dma_2d_en; + uint32_t chan_desc_xfer_size = 0; #endif - dma_desc = &role->dma_desc[0]; - dma_cfg = &role->dma_cfg; + dma_desc = &role->dma_desc[0]; + dma_cfg = &role->dma_cfg; #ifdef CODEC_DSD - if (stream == AUD_STREAM_PLAYBACK && role->cfg.device == AUD_STREAM_USE_INT_CODEC) { - if (dma_cfg->dst_periph == HAL_AUDMA_DSD_TX) { - dma_cfg->dst_bsize = HAL_DMA_BSIZE_1; - } else { - dma_cfg->dst_bsize = HAL_DMA_BSIZE_4; - } + if (stream == AUD_STREAM_PLAYBACK && + role->cfg.device == AUD_STREAM_USE_INT_CODEC) { + if (dma_cfg->dst_periph == HAL_AUDMA_DSD_TX) { + dma_cfg->dst_bsize = HAL_DMA_BSIZE_1; + } else { + dma_cfg->dst_bsize = HAL_DMA_BSIZE_4; } + } #endif + if (role->cfg.device == AUD_STREAM_USE_BT_PCM) { + dma_cfg->dst_bsize = HAL_DMA_BSIZE_1; + dma_cfg->src_bsize = HAL_DMA_BSIZE_1; + dma_cfg->try_burst = 0; + } - if(role->cfg.device == AUD_STREAM_USE_BT_PCM) - { - dma_cfg->dst_bsize = HAL_DMA_BSIZE_1; - dma_cfg->src_bsize = HAL_DMA_BSIZE_1; - dma_cfg->try_burst = 0; - } + role->dma_buf_ptr = cfg->data_ptr; + role->dma_buf_size = cfg->data_size; - role->dma_buf_ptr = cfg->data_ptr; - role->dma_buf_size = cfg->data_size; - - if (cfg->bits == AUD_BITS_24 || cfg->bits == AUD_BITS_32) { - width = HAL_DMA_WIDTH_WORD; - samp_size = 4; - } else if (cfg->bits == AUD_BITS_16) { - width = HAL_DMA_WIDTH_HALFWORD; - samp_size = 2; - } else { - ASSERT(false, "%s: Invalid stream config bits=%d", __func__, cfg->bits); - width = HAL_DMA_WIDTH_BYTE; - samp_size = 1; - } + if (cfg->bits == AUD_BITS_24 || cfg->bits == AUD_BITS_32) { + width = HAL_DMA_WIDTH_WORD; + samp_size = 4; + } else if (cfg->bits == AUD_BITS_16) { + width = HAL_DMA_WIDTH_HALFWORD; + samp_size = 2; + } else { + ASSERT(false, "%s: Invalid stream config bits=%d", __func__, cfg->bits); + width = HAL_DMA_WIDTH_BYTE; + samp_size = 1; + } #ifdef DYNAMIC_AUDIO_BUFFER_COUNT - uint32_t desc_cnt; + uint32_t desc_cnt; - desc_cnt = (cfg->data_size / samp_size + HAL_DMA_MAX_DESC_XFER_SIZE - 1) / HAL_DMA_MAX_DESC_XFER_SIZE; - if (desc_cnt < 2) { - desc_cnt = 2; - } else if (desc_cnt & (desc_cnt - 1)) { - desc_cnt = 1 << (31 - __CLZ(desc_cnt) + 1); - } - TRACE(4,"%s: desc_cnt=%u data_size=%u samp_size=%u", __func__, desc_cnt, cfg->data_size, samp_size); - ASSERT(MIN_AUDIO_BUFFER_COUNT <= desc_cnt && desc_cnt <= MAX_AUDIO_BUFFER_COUNT, "%s: Bad desc_cnt=%u", __func__, desc_cnt); - role->dma_desc_cnt = desc_cnt; + desc_cnt = (cfg->data_size / samp_size + HAL_DMA_MAX_DESC_XFER_SIZE - 1) / + HAL_DMA_MAX_DESC_XFER_SIZE; + if (desc_cnt < 2) { + desc_cnt = 2; + } else if (desc_cnt & (desc_cnt - 1)) { + desc_cnt = 1 << (31 - __CLZ(desc_cnt) + 1); + } + TRACE(4, "%s: desc_cnt=%u data_size=%u samp_size=%u", __func__, desc_cnt, + cfg->data_size, samp_size); + ASSERT(MIN_AUDIO_BUFFER_COUNT <= desc_cnt && + desc_cnt <= MAX_AUDIO_BUFFER_COUNT, + "%s: Bad desc_cnt=%u", __func__, desc_cnt); + role->dma_desc_cnt = desc_cnt; #endif - desc_xfer_size = cfg->data_size / AUDIO_BUFFER_COUNT; + desc_xfer_size = cfg->data_size / AUDIO_BUFFER_COUNT; #ifndef CHIP_BEST1000 - if (cfg->chan_sep_buf && cfg->channel_num > AUD_CHANNEL_NUM_1) { - dma_2d_en = true; + if (cfg->chan_sep_buf && cfg->channel_num > AUD_CHANNEL_NUM_1) { + dma_2d_en = true; + } else { + dma_2d_en = false; + } + + if (dma_2d_en) { + enum HAL_DMA_BSIZE_T bsize; + uint8_t burst_size; + + chan_desc_xfer_size = desc_xfer_size / cfg->channel_num; + + if (stream == AUD_STREAM_PLAYBACK) { + bsize = dma_cfg->src_bsize; } else { - dma_2d_en = false; + bsize = dma_cfg->dst_bsize; } - - if (dma_2d_en) { - enum HAL_DMA_BSIZE_T bsize; - uint8_t burst_size; - - chan_desc_xfer_size = desc_xfer_size / cfg->channel_num; - - if (stream == AUD_STREAM_PLAYBACK) { - bsize = dma_cfg->src_bsize; - } else { - bsize = dma_cfg->dst_bsize; - } - if (bsize == HAL_DMA_BSIZE_1) { - burst_size = 1; - } else if (bsize == HAL_DMA_BSIZE_4) { - burst_size = 4; - } else { - burst_size = 8; - } - align = burst_size * samp_size * cfg->channel_num; - // Ensure word-aligned too - if (align & 0x1) { - align *= 4; - } else if (align & 0x2) { - align *= 2; - } - } else + if (bsize == HAL_DMA_BSIZE_1) { + burst_size = 1; + } else if (bsize == HAL_DMA_BSIZE_4) { + burst_size = 4; + } else { + burst_size = 8; + } + align = burst_size * samp_size * cfg->channel_num; + // Ensure word-aligned too + if (align & 0x1) { + align *= 4; + } else if (align & 0x2) { + align *= 2; + } + } else #endif - { - align = 4; + { + align = 4; + } + ASSERT(desc_xfer_size * AUDIO_BUFFER_COUNT == cfg->data_size && + (desc_xfer_size % align) == 0, + "%s: Dma data size is not aligned: data_size=%u AUDIO_BUFFER_COUNT=%u " + "align=%u", + __func__, cfg->data_size, AUDIO_BUFFER_COUNT, align); + + dma_cfg->dst_width = width; + dma_cfg->src_width = width; + dma_cfg->src_tsize = desc_xfer_size / samp_size; + + for (i = 0; i < AUDIO_BUFFER_COUNT; i++) { + if (i == AUDIO_BUFFER_COUNT - 1) { + next_desc = &dma_desc[0]; + irq = 1; + } else { + next_desc = &dma_desc[i + 1]; + if (i == AUDIO_BUFFER_COUNT / 2 - 1) { + irq = 1; + } else { + irq = 0; + } } - ASSERT(desc_xfer_size * AUDIO_BUFFER_COUNT == cfg->data_size && (desc_xfer_size % align) == 0, - "%s: Dma data size is not aligned: data_size=%u AUDIO_BUFFER_COUNT=%u align=%u", - __func__, cfg->data_size, AUDIO_BUFFER_COUNT, align); - dma_cfg->dst_width = width; - dma_cfg->src_width = width; - dma_cfg->src_tsize = desc_xfer_size / samp_size; - - for (i = 0; i < AUDIO_BUFFER_COUNT; i++) { - if (i == AUDIO_BUFFER_COUNT - 1) { - next_desc = &dma_desc[0]; - irq = 1; - } else { - next_desc = &dma_desc[i + 1]; - if (i == AUDIO_BUFFER_COUNT / 2 - 1) { - irq = 1; - } else { - irq = 0; - } - } - - if (stream == AUD_STREAM_PLAYBACK) { + if (stream == AUD_STREAM_PLAYBACK) { #ifndef CHIP_BEST1000 - if (dma_2d_en) { - dma_cfg->src = (uint32_t)(role->dma_buf_ptr + chan_desc_xfer_size * i); - } else + if (dma_2d_en) { + dma_cfg->src = (uint32_t)(role->dma_buf_ptr + chan_desc_xfer_size * i); + } else #endif - { - dma_cfg->src = (uint32_t)(role->dma_buf_ptr + desc_xfer_size * i); - } - } else { + { + dma_cfg->src = (uint32_t)(role->dma_buf_ptr + desc_xfer_size * i); + } + } else { #ifndef CHIP_BEST1000 - if (dma_2d_en) { - dma_cfg->dst = (uint32_t)(role->dma_buf_ptr + chan_desc_xfer_size * i); - } else + if (dma_2d_en) { + dma_cfg->dst = (uint32_t)(role->dma_buf_ptr + chan_desc_xfer_size * i); + } else #endif - { - dma_cfg->dst = (uint32_t)(role->dma_buf_ptr + desc_xfer_size * i); - } - } - - dma_ret = hal_audma_init_desc(&dma_desc[i], dma_cfg, next_desc, irq); - ASSERT(dma_ret == HAL_DMA_OK, "[%s] Failed to init dma desc for stream %d: ret=%d", __func__, stream, dma_ret); + { + dma_cfg->dst = (uint32_t)(role->dma_buf_ptr + desc_xfer_size * i); + } } + + dma_ret = hal_audma_init_desc(&dma_desc[i], dma_cfg, next_desc, irq); + ASSERT(dma_ret == HAL_DMA_OK, + "[%s] Failed to init dma desc for stream %d: ret=%d", __func__, + stream, dma_ret); + } } // Support memory<-->peripheral // Note: Do not support peripheral <--> peripheral -uint32_t af_stream_open(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream, const struct AF_STREAM_CONFIG_T *cfg) -{ - AF_TRACE_DEBUG(); - struct af_stream_cfg_t *role; - enum AF_RESULT_T ret; - enum AUD_STREAM_USE_DEVICE_T device; - struct HAL_DMA_CH_CFG_T *dma_cfg = NULL; +uint32_t af_stream_open(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream, + const struct AF_STREAM_CONFIG_T *cfg) { + AF_TRACE_DEBUG(); + struct af_stream_cfg_t *role; + enum AF_RESULT_T ret; + enum AUD_STREAM_USE_DEVICE_T device; + struct HAL_DMA_CH_CFG_T *dma_cfg = NULL; #ifdef __RAND_FROM_MIC__ - random_status_sync(); + random_status_sync(); #endif - role = af_get_stream_role(id, stream); - TRACE(3,"[%s] id = %d, stream = %d", __func__, id, stream); + role = af_get_stream_role(id, stream); + TRACE(3, "[%s] id = %d, stream = %d", __func__, id, stream); - ASSERT(cfg->data_ptr != NULL, "[%s] ERROR: data_ptr == NULL!!!", __func__); - ASSERT(((uint32_t)cfg->data_ptr) % 4 == 0, "[%s] ERROR: data_ptr(%p) is not align!!!", __func__, cfg->data_ptr); - ASSERT(cfg->data_size != 0, "[%s] ERROR: data_size == 0!!!", __func__); + ASSERT(cfg->data_ptr != NULL, "[%s] ERROR: data_ptr == NULL!!!", __func__); + ASSERT(((uint32_t)cfg->data_ptr) % 4 == 0, + "[%s] ERROR: data_ptr(%p) is not align!!!", __func__, cfg->data_ptr); + ASSERT(cfg->data_size != 0, "[%s] ERROR: data_size == 0!!!", __func__); #ifndef CHIP_BEST1000 - if (cfg->chan_sep_buf && cfg->channel_num > AUD_CHANNEL_NUM_1) { - ASSERT(cfg->device == AUD_STREAM_USE_INT_CODEC || - cfg->device == AUD_STREAM_USE_I2S0_MASTER || cfg->device == AUD_STREAM_USE_I2S0_SLAVE || - cfg->device == AUD_STREAM_USE_I2S1_MASTER || cfg->device == AUD_STREAM_USE_I2S1_SLAVE || - cfg->device == AUD_STREAM_USE_TDM0_MASTER || cfg->device == AUD_STREAM_USE_TDM0_SLAVE || - cfg->device == AUD_STREAM_USE_TDM1_MASTER || cfg->device == AUD_STREAM_USE_TDM1_SLAVE, - "[%s] ERROR: Unsupport chan_sep_buf for device %d", __func__, cfg->device); - } + if (cfg->chan_sep_buf && cfg->channel_num > AUD_CHANNEL_NUM_1) { + ASSERT(cfg->device == AUD_STREAM_USE_INT_CODEC || + cfg->device == AUD_STREAM_USE_I2S0_MASTER || + cfg->device == AUD_STREAM_USE_I2S0_SLAVE || + cfg->device == AUD_STREAM_USE_I2S1_MASTER || + cfg->device == AUD_STREAM_USE_I2S1_SLAVE || + cfg->device == AUD_STREAM_USE_TDM0_MASTER || + cfg->device == AUD_STREAM_USE_TDM0_SLAVE || + cfg->device == AUD_STREAM_USE_TDM1_MASTER || + cfg->device == AUD_STREAM_USE_TDM1_SLAVE, + "[%s] ERROR: Unsupport chan_sep_buf for device %d", __func__, + cfg->device); + } #endif - ret = AF_RES_FAILD; + ret = AF_RES_FAILD; - af_lock_thread(); + af_lock_thread(); - //check af is open - if(role->ctl.status != AF_STATUS_OPEN_CLOSE) - { - TRACE(2,"[%s] ERROR: status = %d",__func__, role->ctl.status); - goto _exit; - } + // check af is open + if (role->ctl.status != AF_STATUS_OPEN_CLOSE) { + TRACE(2, "[%s] ERROR: status = %d", __func__, role->ctl.status); + goto _exit; + } - role->cfg = *cfg; + role->cfg = *cfg; - device = cfg->device; - role->ctl.use_device = device; + device = cfg->device; + role->ctl.use_device = device; - dma_cfg = &role->dma_cfg; - memset(dma_cfg, 0, sizeof(*dma_cfg)); + dma_cfg = &role->dma_cfg; + memset(dma_cfg, 0, sizeof(*dma_cfg)); - if(device == AUD_STREAM_USE_BT_PCM) - { - dma_cfg->dst_bsize = HAL_DMA_BSIZE_1; - dma_cfg->src_bsize = HAL_DMA_BSIZE_1; - dma_cfg->try_burst = 0; - } - else - { - dma_cfg->dst_bsize = HAL_DMA_BSIZE_4; + if (device == AUD_STREAM_USE_BT_PCM) { + dma_cfg->dst_bsize = HAL_DMA_BSIZE_1; + dma_cfg->src_bsize = HAL_DMA_BSIZE_1; + dma_cfg->try_burst = 0; + } else { + dma_cfg->dst_bsize = HAL_DMA_BSIZE_4; #ifndef CHIP_BEST1000 - // If channel num > 1, burst size should be set to 1 for: - // 1) all playback streams with 2D DMA enabled; or - // 2) internal codec capture streams with 2D DMA disabled. - if (cfg->channel_num > AUD_CHANNEL_NUM_1 && - ((stream == AUD_STREAM_PLAYBACK && cfg->chan_sep_buf) || - (device == AUD_STREAM_USE_INT_CODEC && stream == AUD_STREAM_CAPTURE && !cfg->chan_sep_buf))) { - dma_cfg->src_bsize = HAL_DMA_BSIZE_1; - } else + // If channel num > 1, burst size should be set to 1 for: + // 1) all playback streams with 2D DMA enabled; or + // 2) internal codec capture streams with 2D DMA disabled. + if (cfg->channel_num > AUD_CHANNEL_NUM_1 && + ((stream == AUD_STREAM_PLAYBACK && cfg->chan_sep_buf) || + (device == AUD_STREAM_USE_INT_CODEC && stream == AUD_STREAM_CAPTURE && + !cfg->chan_sep_buf))) { + dma_cfg->src_bsize = HAL_DMA_BSIZE_1; + } else #endif - { - dma_cfg->src_bsize = HAL_DMA_BSIZE_4; - } - dma_cfg->try_burst = 1; - } - - dma_cfg->handler = af_dma_irq_handler; - - if (stream == AUD_STREAM_PLAYBACK) { - AF_TRACE_DEBUG(); - dma_cfg->src_periph = (enum HAL_DMA_PERIPH_T)0; - dma_cfg->type = HAL_DMA_FLOW_M2P_DMA; + dma_cfg->src_bsize = HAL_DMA_BSIZE_4; + } + dma_cfg->try_burst = 1; + } - //open device and stream - if(0) - { + dma_cfg->handler = af_dma_irq_handler; - } + if (stream == AUD_STREAM_PLAYBACK) { + AF_TRACE_DEBUG(); + dma_cfg->src_periph = (enum HAL_DMA_PERIPH_T)0; + dma_cfg->type = HAL_DMA_FLOW_M2P_DMA; + + // open device and stream + if (0) { + + } #ifdef AF_DEVICE_EXT_CODEC - else if(device == AUD_STREAM_USE_EXT_CODEC) - { - AF_TRACE_DEBUG(); - tlv32aic32_open(); - tlv32aic32_stream_open(stream); + else if (device == AUD_STREAM_USE_EXT_CODEC) { + AF_TRACE_DEBUG(); + tlv32aic32_open(); + tlv32aic32_stream_open(stream); - dma_cfg->dst_periph = HAL_AUDMA_I2S0_TX; - } + dma_cfg->dst_periph = HAL_AUDMA_I2S0_TX; + } #endif #ifdef AF_DEVICE_I2S - else if(device == AUD_STREAM_USE_I2S0_MASTER) - { - AF_TRACE_DEBUG(); - hal_i2s_open(HAL_I2S_ID_0, stream, HAL_I2S_MODE_MASTER); - dma_cfg->dst_periph = HAL_AUDMA_I2S0_TX; - } - else if(device == AUD_STREAM_USE_I2S0_SLAVE) - { - AF_TRACE_DEBUG(); - hal_i2s_open(HAL_I2S_ID_0, stream, HAL_I2S_MODE_SLAVE); - dma_cfg->dst_periph = HAL_AUDMA_I2S0_TX; - } + else if (device == AUD_STREAM_USE_I2S0_MASTER) { + AF_TRACE_DEBUG(); + hal_i2s_open(HAL_I2S_ID_0, stream, HAL_I2S_MODE_MASTER); + dma_cfg->dst_periph = HAL_AUDMA_I2S0_TX; + } else if (device == AUD_STREAM_USE_I2S0_SLAVE) { + AF_TRACE_DEBUG(); + hal_i2s_open(HAL_I2S_ID_0, stream, HAL_I2S_MODE_SLAVE); + dma_cfg->dst_periph = HAL_AUDMA_I2S0_TX; + } #if defined(CHIP_HAS_I2S) && (CHIP_HAS_I2S > 1) - else if(device == AUD_STREAM_USE_I2S1_MASTER) - { - AF_TRACE_DEBUG(); - hal_i2s_open(HAL_I2S_ID_1, stream, HAL_I2S_MODE_MASTER); - dma_cfg->dst_periph = HAL_AUDMA_I2S1_TX; - } - else if(device == AUD_STREAM_USE_I2S1_SLAVE) - { - AF_TRACE_DEBUG(); - hal_i2s_open(HAL_I2S_ID_1, stream, HAL_I2S_MODE_SLAVE); - dma_cfg->dst_periph = HAL_AUDMA_I2S1_TX; - } + else if (device == AUD_STREAM_USE_I2S1_MASTER) { + AF_TRACE_DEBUG(); + hal_i2s_open(HAL_I2S_ID_1, stream, HAL_I2S_MODE_MASTER); + dma_cfg->dst_periph = HAL_AUDMA_I2S1_TX; + } else if (device == AUD_STREAM_USE_I2S1_SLAVE) { + AF_TRACE_DEBUG(); + hal_i2s_open(HAL_I2S_ID_1, stream, HAL_I2S_MODE_SLAVE); + dma_cfg->dst_periph = HAL_AUDMA_I2S1_TX; + } #endif #endif #ifdef AF_DEVICE_TDM - else if(device == AUD_STREAM_USE_TDM0_MASTER) - { - AF_TRACE_DEBUG(); - hal_tdm_open(HAL_I2S_ID_0, stream, HAL_I2S_MODE_MASTER); - dma_cfg->dst_periph = HAL_AUDMA_I2S0_TX; - } - else if(device == AUD_STREAM_USE_TDM0_SLAVE) - { - AF_TRACE_DEBUG(); - hal_tdm_open(HAL_I2S_ID_0, stream, HAL_I2S_MODE_SLAVE); - dma_cfg->dst_periph = HAL_AUDMA_I2S0_TX; - } + else if (device == AUD_STREAM_USE_TDM0_MASTER) { + AF_TRACE_DEBUG(); + hal_tdm_open(HAL_I2S_ID_0, stream, HAL_I2S_MODE_MASTER); + dma_cfg->dst_periph = HAL_AUDMA_I2S0_TX; + } else if (device == AUD_STREAM_USE_TDM0_SLAVE) { + AF_TRACE_DEBUG(); + hal_tdm_open(HAL_I2S_ID_0, stream, HAL_I2S_MODE_SLAVE); + dma_cfg->dst_periph = HAL_AUDMA_I2S0_TX; + } #if defined(CHIP_HAS_I2S) && (CHIP_HAS_I2S > 1) - else if(device == AUD_STREAM_USE_TDM1_MASTER) - { - AF_TRACE_DEBUG(); - hal_tdm_open(HAL_I2S_ID_1, stream, HAL_I2S_MODE_MASTER); - dma_cfg->dst_periph = HAL_AUDMA_I2S1_TX; - } - else if(device == AUD_STREAM_USE_TDM1_SLAVE) - { - AF_TRACE_DEBUG(); - hal_tdm_open(HAL_I2S_ID_1, stream, HAL_I2S_MODE_SLAVE); - dma_cfg->dst_periph = HAL_AUDMA_I2S1_TX; - } + else if (device == AUD_STREAM_USE_TDM1_MASTER) { + AF_TRACE_DEBUG(); + hal_tdm_open(HAL_I2S_ID_1, stream, HAL_I2S_MODE_MASTER); + dma_cfg->dst_periph = HAL_AUDMA_I2S1_TX; + } else if (device == AUD_STREAM_USE_TDM1_SLAVE) { + AF_TRACE_DEBUG(); + hal_tdm_open(HAL_I2S_ID_1, stream, HAL_I2S_MODE_SLAVE); + dma_cfg->dst_periph = HAL_AUDMA_I2S1_TX; + } #endif #endif #ifdef AF_DEVICE_INT_CODEC - else if(device == AUD_STREAM_USE_INT_CODEC) - { - AF_TRACE_DEBUG(); - codec_int_open(); - codec_int_stream_open(stream); + else if (device == AUD_STREAM_USE_INT_CODEC) { + AF_TRACE_DEBUG(); + codec_int_open(); + codec_int_stream_open(stream); #ifdef AUDIO_OUTPUT_SW_GAIN #ifdef AUDIO_OUTPUT_SW_LIMITER - FLOATLIMITER_ERROR limiter_err; + FLOATLIMITER_ERROR limiter_err; - if (FloatLimiterP == NULL) { - FloatLimiterP = CreateFloatLimiter(FL_ATTACK_DEFAULT_MS, FL_RELEASE_DEFAULT_MS, FL_THRESHOLD, MAX_CHANEL, MAX_SAMPLERATE, MAX_SAMPLEBIT); - } + if (FloatLimiterP == NULL) { + FloatLimiterP = CreateFloatLimiter( + FL_ATTACK_DEFAULT_MS, FL_RELEASE_DEFAULT_MS, FL_THRESHOLD, + MAX_CHANEL, MAX_SAMPLERATE, MAX_SAMPLEBIT); + } - limiter_err = SetFloatLimiterNChannels(FloatLimiterP, cfg->channel_num); - if (limiter_err != FLOATLIMIT_OK) { - goto _exit; - } - limiter_err = SetFloatLimiterSampleRate(FloatLimiterP, cfg->sample_rate); - if (limiter_err != FLOATLIMIT_OK) { - goto _exit; - } - limiter_err = SetFloatLimiterSampleBit(FloatLimiterP, cfg->bits); - if (limiter_err != FLOATLIMIT_OK) { - goto _exit; - } + limiter_err = SetFloatLimiterNChannels(FloatLimiterP, cfg->channel_num); + if (limiter_err != FLOATLIMIT_OK) { + goto _exit; + } + limiter_err = SetFloatLimiterSampleRate(FloatLimiterP, cfg->sample_rate); + if (limiter_err != FLOATLIMIT_OK) { + goto _exit; + } + limiter_err = SetFloatLimiterSampleBit(FloatLimiterP, cfg->bits); + if (limiter_err != FLOATLIMIT_OK) { + goto _exit; + } #else - sw_gain_iir.history_x[0]=0.0f; - sw_gain_iir.history_x[1]=0.0f; - sw_gain_iir.history_y[0]=0.0f; - sw_gain_iir.history_y[1]=0.0f; + sw_gain_iir.history_x[0] = 0.0f; + sw_gain_iir.history_x[1] = 0.0f; + sw_gain_iir.history_y[0] = 0.0f; + sw_gain_iir.history_y[1] = 0.0f; +#endif #endif -#endif - #ifdef CODEC_DSD - if (af_dsd_enabled) { - dma_cfg->dst_periph = HAL_AUDMA_DSD_TX; - dma_cfg->dst_bsize = HAL_DMA_BSIZE_1; - } else + if (af_dsd_enabled) { + dma_cfg->dst_periph = HAL_AUDMA_DSD_TX; + dma_cfg->dst_bsize = HAL_DMA_BSIZE_1; + } else #endif - { - dma_cfg->dst_periph = HAL_AUDMA_CODEC_TX; - } - } + { + dma_cfg->dst_periph = HAL_AUDMA_CODEC_TX; + } + } #endif #ifdef AF_DEVICE_SPDIF - else if(device == AUD_STREAM_USE_INT_SPDIF) - { - AF_TRACE_DEBUG(); - hal_spdif_open(AF_SPDIF_INST, stream); - dma_cfg->dst_periph = HAL_AUDMA_SPDIF0_TX; - } + else if (device == AUD_STREAM_USE_INT_SPDIF) { + AF_TRACE_DEBUG(); + hal_spdif_open(AF_SPDIF_INST, stream); + dma_cfg->dst_periph = HAL_AUDMA_SPDIF0_TX; + } #endif #ifdef AF_DEVICE_BT_PCM - else if(device == AUD_STREAM_USE_BT_PCM) - { - AF_TRACE_DEBUG(); - hal_btpcm_open(AF_BTPCM_INST, stream); - dma_cfg->dst_periph = HAL_AUDMA_BTPCM_TX; - } + else if (device == AUD_STREAM_USE_BT_PCM) { + AF_TRACE_DEBUG(); + hal_btpcm_open(AF_BTPCM_INST, stream); + dma_cfg->dst_periph = HAL_AUDMA_BTPCM_TX; + } #endif #ifdef AUDIO_ANC_FB_MC - else if(device == AUD_STREAM_USE_MC) - { - AF_TRACE_DEBUG(); - dma_cfg->dst_periph = HAL_AUDMA_MC_RX; - } -#endif - else - { - ASSERT(0, "[%s] ERROR: device %d is not defined!", __func__, device); - } - - dma_cfg->ch = hal_audma_get_chan(dma_cfg->dst_periph, HAL_DMA_HIGH_PRIO); + else if (device == AUD_STREAM_USE_MC) { + AF_TRACE_DEBUG(); + dma_cfg->dst_periph = HAL_AUDMA_MC_RX; + } +#endif + else { + ASSERT(0, "[%s] ERROR: device %d is not defined!", __func__, device); } - else - { - AF_TRACE_DEBUG(); - dma_cfg->dst_periph = (enum HAL_DMA_PERIPH_T)0; - dma_cfg->type = HAL_DMA_FLOW_P2M_DMA; - //open device and stream - if(0) - { - } + dma_cfg->ch = hal_audma_get_chan(dma_cfg->dst_periph, HAL_DMA_HIGH_PRIO); + } else { + AF_TRACE_DEBUG(); + dma_cfg->dst_periph = (enum HAL_DMA_PERIPH_T)0; + dma_cfg->type = HAL_DMA_FLOW_P2M_DMA; + + // open device and stream + if (0) { + } #ifdef AF_DEVICE_EXT_CODEC - else if(device == AUD_STREAM_USE_EXT_CODEC) - { - AF_TRACE_DEBUG(); - tlv32aic32_open(); - tlv32aic32_stream_open(stream); + else if (device == AUD_STREAM_USE_EXT_CODEC) { + AF_TRACE_DEBUG(); + tlv32aic32_open(); + tlv32aic32_stream_open(stream); - dma_cfg->src_periph = HAL_AUDMA_I2S0_RX; - } + dma_cfg->src_periph = HAL_AUDMA_I2S0_RX; + } #endif #ifdef AF_DEVICE_I2S - else if(device == AUD_STREAM_USE_I2S0_MASTER) - { - AF_TRACE_DEBUG(); - hal_i2s_open(HAL_I2S_ID_0, stream, HAL_I2S_MODE_MASTER); - dma_cfg->src_periph = HAL_AUDMA_I2S0_RX; - } - else if(device == AUD_STREAM_USE_I2S0_SLAVE) - { - AF_TRACE_DEBUG(); - hal_i2s_open(HAL_I2S_ID_0, stream, HAL_I2S_MODE_SLAVE); - dma_cfg->src_periph = HAL_AUDMA_I2S0_RX; - } + else if (device == AUD_STREAM_USE_I2S0_MASTER) { + AF_TRACE_DEBUG(); + hal_i2s_open(HAL_I2S_ID_0, stream, HAL_I2S_MODE_MASTER); + dma_cfg->src_periph = HAL_AUDMA_I2S0_RX; + } else if (device == AUD_STREAM_USE_I2S0_SLAVE) { + AF_TRACE_DEBUG(); + hal_i2s_open(HAL_I2S_ID_0, stream, HAL_I2S_MODE_SLAVE); + dma_cfg->src_periph = HAL_AUDMA_I2S0_RX; + } #if defined(CHIP_HAS_I2S) && (CHIP_HAS_I2S > 1) - else if(device == AUD_STREAM_USE_I2S1_MASTER) - { - AF_TRACE_DEBUG(); - hal_i2s_open(HAL_I2S_ID_1, stream, HAL_I2S_MODE_MASTER); - dma_cfg->src_periph = HAL_AUDMA_I2S1_RX; - } - else if(device == AUD_STREAM_USE_I2S1_SLAVE) - { - AF_TRACE_DEBUG(); - hal_i2s_open(HAL_I2S_ID_1, stream, HAL_I2S_MODE_SLAVE); - dma_cfg->src_periph = HAL_AUDMA_I2S1_RX; - } + else if (device == AUD_STREAM_USE_I2S1_MASTER) { + AF_TRACE_DEBUG(); + hal_i2s_open(HAL_I2S_ID_1, stream, HAL_I2S_MODE_MASTER); + dma_cfg->src_periph = HAL_AUDMA_I2S1_RX; + } else if (device == AUD_STREAM_USE_I2S1_SLAVE) { + AF_TRACE_DEBUG(); + hal_i2s_open(HAL_I2S_ID_1, stream, HAL_I2S_MODE_SLAVE); + dma_cfg->src_periph = HAL_AUDMA_I2S1_RX; + } #endif #endif #ifdef AF_DEVICE_TDM - else if(device == AUD_STREAM_USE_TDM0_MASTER) - { - AF_TRACE_DEBUG(); - hal_tdm_open(HAL_I2S_ID_0, stream, HAL_I2S_MODE_MASTER); - dma_cfg->src_periph = HAL_AUDMA_I2S0_RX; - AF_TRACE_DEBUG(); - } - else if(device == AUD_STREAM_USE_TDM0_SLAVE) - { - AF_TRACE_DEBUG(); - hal_tdm_open(HAL_I2S_ID_0, stream, HAL_I2S_MODE_SLAVE); - dma_cfg->src_periph = HAL_AUDMA_I2S0_RX; - } + else if (device == AUD_STREAM_USE_TDM0_MASTER) { + AF_TRACE_DEBUG(); + hal_tdm_open(HAL_I2S_ID_0, stream, HAL_I2S_MODE_MASTER); + dma_cfg->src_periph = HAL_AUDMA_I2S0_RX; + AF_TRACE_DEBUG(); + } else if (device == AUD_STREAM_USE_TDM0_SLAVE) { + AF_TRACE_DEBUG(); + hal_tdm_open(HAL_I2S_ID_0, stream, HAL_I2S_MODE_SLAVE); + dma_cfg->src_periph = HAL_AUDMA_I2S0_RX; + } #if defined(CHIP_HAS_I2S) && (CHIP_HAS_I2S > 1) - else if(device == AUD_STREAM_USE_TDM1_MASTER) - { - AF_TRACE_DEBUG(); - hal_tdm_open(HAL_I2S_ID_1, stream, HAL_I2S_MODE_MASTER); - dma_cfg->src_periph = HAL_AUDMA_I2S1_RX; - } - else if(device == AUD_STREAM_USE_TDM1_SLAVE) - { - AF_TRACE_DEBUG(); - hal_tdm_open(HAL_I2S_ID_1, stream, HAL_I2S_MODE_SLAVE); - dma_cfg->src_periph = HAL_AUDMA_I2S1_RX; - } + else if (device == AUD_STREAM_USE_TDM1_MASTER) { + AF_TRACE_DEBUG(); + hal_tdm_open(HAL_I2S_ID_1, stream, HAL_I2S_MODE_MASTER); + dma_cfg->src_periph = HAL_AUDMA_I2S1_RX; + } else if (device == AUD_STREAM_USE_TDM1_SLAVE) { + AF_TRACE_DEBUG(); + hal_tdm_open(HAL_I2S_ID_1, stream, HAL_I2S_MODE_SLAVE); + dma_cfg->src_periph = HAL_AUDMA_I2S1_RX; + } #endif #endif #ifdef AF_DEVICE_INT_CODEC - else if(device == AUD_STREAM_USE_INT_CODEC) - { - AF_TRACE_DEBUG(); - codec_int_open(); - codec_int_stream_open(stream); + else if (device == AUD_STREAM_USE_INT_CODEC) { + AF_TRACE_DEBUG(); + codec_int_open(); + codec_int_stream_open(stream); - dma_cfg->src_periph = HAL_AUDMA_CODEC_RX; - } + dma_cfg->src_periph = HAL_AUDMA_CODEC_RX; + } #endif #ifdef AF_DEVICE_SPDIF - else if(device == AUD_STREAM_USE_INT_SPDIF) - { - AF_TRACE_DEBUG(); - hal_spdif_open(AF_SPDIF_INST, stream); + else if (device == AUD_STREAM_USE_INT_SPDIF) { + AF_TRACE_DEBUG(); + hal_spdif_open(AF_SPDIF_INST, stream); - dma_cfg->src_periph = HAL_AUDMA_SPDIF0_RX; - } + dma_cfg->src_periph = HAL_AUDMA_SPDIF0_RX; + } #endif #ifdef AF_DEVICE_BT_PCM - else if(device == AUD_STREAM_USE_BT_PCM) - { - AF_TRACE_DEBUG(); - hal_btpcm_open(AF_BTPCM_INST, stream); + else if (device == AUD_STREAM_USE_BT_PCM) { + AF_TRACE_DEBUG(); + hal_btpcm_open(AF_BTPCM_INST, stream); - dma_cfg->src_periph = HAL_AUDMA_BTPCM_RX; - } + dma_cfg->src_periph = HAL_AUDMA_BTPCM_RX; + } #endif #ifdef AF_DEVICE_DPD_RX - else if(device == AUD_STREAM_USE_DPD_RX) - { - AF_TRACE_DEBUG(); - dma_cfg->src_periph = HAL_AUDMA_DPD_RX; - } -#endif - else - { - ASSERT(0, "[%s] ERROR: device %d is not defined!", __func__, device); - } - dma_cfg->ch = hal_audma_get_chan(dma_cfg->src_periph, HAL_DMA_HIGH_PRIO); + else if (device == AUD_STREAM_USE_DPD_RX) { + AF_TRACE_DEBUG(); + dma_cfg->src_periph = HAL_AUDMA_DPD_RX; } - af_stream_update_dma_buffer(stream, role, cfg); - role->handler = cfg->handler; - - af_set_status(id, stream, AF_STATUS_STREAM_OPEN_CLOSE); +#endif + else { + ASSERT(0, "[%s] ERROR: device %d is not defined!", __func__, device); + } + dma_cfg->ch = hal_audma_get_chan(dma_cfg->src_periph, HAL_DMA_HIGH_PRIO); + } + af_stream_update_dma_buffer(stream, role, cfg); + role->handler = cfg->handler; + + af_set_status(id, stream, AF_STATUS_STREAM_OPEN_CLOSE); #ifndef RTOS - af_clear_flag(&af_flag_signal, 1 << (id * 2 + stream)); - af_set_flag(&af_flag_open, 1 << (id * 2 + stream)); + af_clear_flag(&af_flag_signal, 1 << (id * 2 + stream)); + af_set_flag(&af_flag_open, 1 << (id * 2 + stream)); #endif - AF_TRACE_DEBUG(); - ret = AF_RES_SUCCESS; + AF_TRACE_DEBUG(); + ret = AF_RES_SUCCESS; _exit: - af_unlock_thread(); - if (ret == AF_RES_SUCCESS) { - af_stream_setup(id, stream, &role->cfg); - } + af_unlock_thread(); + if (ret == AF_RES_SUCCESS) { + af_stream_setup(id, stream, &role->cfg); + } - return ret; + return ret; } -//volume, path, sample rate, channel num ... -uint32_t af_stream_setup(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream, const struct AF_STREAM_CONFIG_T *cfg) -{ - AF_TRACE_DEBUG(); +// volume, path, sample rate, channel num ... +uint32_t af_stream_setup(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream, + const struct AF_STREAM_CONFIG_T *cfg) { + AF_TRACE_DEBUG(); - struct af_stream_cfg_t *role; - enum AF_RESULT_T ret; - enum AUD_STREAM_USE_DEVICE_T device; + struct af_stream_cfg_t *role; + enum AF_RESULT_T ret; + enum AUD_STREAM_USE_DEVICE_T device; - role = af_get_stream_role(id, stream); - TRACE(3,"[%s] id = %d, stream = %d", __func__, id, stream); + role = af_get_stream_role(id, stream); + TRACE(3, "[%s] id = %d, stream = %d", __func__, id, stream); - ret = AF_RES_FAILD; + ret = AF_RES_FAILD; - af_lock_thread(); + af_lock_thread(); - //check stream is open - if(!(role->ctl.status & AF_STATUS_STREAM_OPEN_CLOSE)) - { - TRACE(2,"[%s] ERROR: status = %d", __func__, role->ctl.status); - goto _exit; + // check stream is open + if (!(role->ctl.status & AF_STATUS_STREAM_OPEN_CLOSE)) { + TRACE(2, "[%s] ERROR: status = %d", __func__, role->ctl.status); + goto _exit; + } + + device = role->ctl.use_device; + + if (&role->cfg != cfg) { + bool update_dma = false; + + if (role->cfg.bits != cfg->bits) { + TRACE(4, "[%s] Change bits from %d to %d for stream %d", __func__, + role->cfg.bits, cfg->bits, stream); + update_dma = true; + } + if (role->cfg.data_ptr != cfg->data_ptr) { + TRACE(4, "[%s] Change data_ptr from %p to %p for stream %d", __func__, + role->cfg.data_ptr, cfg->data_ptr, stream); + update_dma = true; + } + if (role->cfg.data_size != cfg->data_size) { + TRACE(4, "[%s] Change data_size from %d to %d for stream %d", __func__, + role->cfg.data_size, cfg->data_size, stream); + update_dma = true; + } + if (update_dma) { + // To avoid FIFO corruption, streams must be stopped before changing + // sample size + ASSERT((role->ctl.status & AF_STATUS_STREAM_START_STOP) == 0, + "[%s] ERROR: Update dma while stream %d started", __func__, + stream); + + af_stream_update_dma_buffer(stream, role, cfg); } - device = role->ctl.use_device; + if (role->cfg.sample_rate != cfg->sample_rate) { + TRACE(4, "[%s] Change sample rate from %d to %d for stream %d", __func__, + role->cfg.sample_rate, cfg->sample_rate, stream); - if (&role->cfg != cfg) { - bool update_dma = false; - - if (role->cfg.bits != cfg->bits) { - TRACE(4,"[%s] Change bits from %d to %d for stream %d", __func__, role->cfg.bits, cfg->bits, stream); - update_dma = true; - } - if (role->cfg.data_ptr != cfg->data_ptr) { - TRACE(4,"[%s] Change data_ptr from %p to %p for stream %d", __func__, role->cfg.data_ptr, cfg->data_ptr, stream); - update_dma = true; - } - if (role->cfg.data_size != cfg->data_size) { - TRACE(4,"[%s] Change data_size from %d to %d for stream %d", __func__, role->cfg.data_size, cfg->data_size, stream); - update_dma = true; - } - if (update_dma) { - // To avoid FIFO corruption, streams must be stopped before changing sample size - ASSERT((role->ctl.status & AF_STATUS_STREAM_START_STOP) == 0, - "[%s] ERROR: Update dma while stream %d started", __func__, stream); - - af_stream_update_dma_buffer(stream, role, cfg); - } - - if (role->cfg.sample_rate != cfg->sample_rate) { - TRACE(4,"[%s] Change sample rate from %d to %d for stream %d", __func__, role->cfg.sample_rate, cfg->sample_rate, stream); - - // To avoid L/R sample misalignment, streams must be stopped before changing sample rate - ASSERT((role->ctl.status & AF_STATUS_STREAM_START_STOP) == 0, - "[%s] ERROR: Change sample rate from %d to %d while stream %d started", __func__, role->cfg.sample_rate, cfg->sample_rate, stream); - } - - role->cfg = *cfg; + // To avoid L/R sample misalignment, streams must be stopped before + // changing sample rate + ASSERT((role->ctl.status & AF_STATUS_STREAM_START_STOP) == 0, + "[%s] ERROR: Change sample rate from %d to %d while stream %d " + "started", + __func__, role->cfg.sample_rate, cfg->sample_rate, stream); } - AF_TRACE_DEBUG(); - if(0) - { - } + role->cfg = *cfg; + } + + AF_TRACE_DEBUG(); + if (0) { + } #ifdef AF_DEVICE_EXT_CODEC - else if(device == AUD_STREAM_USE_EXT_CODEC) - { - AF_TRACE_DEBUG(); + else if (device == AUD_STREAM_USE_EXT_CODEC) { + AF_TRACE_DEBUG(); - struct tlv32aic32_config_t tlv32aic32_cfg; + struct tlv32aic32_config_t tlv32aic32_cfg; - memset(&tlv32aic32_cfg, 0, sizeof(tlv32aic32_cfg)); - tlv32aic32_cfg.bits = cfg->bits; - tlv32aic32_cfg.channel_num = cfg->channel_num; - tlv32aic32_cfg.channel_map = cfg->channel_map; - tlv32aic32_cfg.sample_rate = cfg->sample_rate; - tlv32aic32_cfg.use_dma = AF_TRUE; - tlv32aic32_cfg.chan_sep_buf = cfg->chan_sep_buf; - tlv32aic32_cfg.sync_start = cfg->sync_start; - tlv32aic32_cfg.slot_cycles = cfg->slot_cycles; - tlv32aic32_stream_setup(stream, &tlv32aic32_cfg); - } + memset(&tlv32aic32_cfg, 0, sizeof(tlv32aic32_cfg)); + tlv32aic32_cfg.bits = cfg->bits; + tlv32aic32_cfg.channel_num = cfg->channel_num; + tlv32aic32_cfg.channel_map = cfg->channel_map; + tlv32aic32_cfg.sample_rate = cfg->sample_rate; + tlv32aic32_cfg.use_dma = AF_TRUE; + tlv32aic32_cfg.chan_sep_buf = cfg->chan_sep_buf; + tlv32aic32_cfg.sync_start = cfg->sync_start; + tlv32aic32_cfg.slot_cycles = cfg->slot_cycles; + tlv32aic32_stream_setup(stream, &tlv32aic32_cfg); + } #endif #ifdef AF_DEVICE_I2S - else if(device == AUD_STREAM_USE_I2S0_MASTER || device == AUD_STREAM_USE_I2S0_SLAVE + else if (device == AUD_STREAM_USE_I2S0_MASTER || + device == AUD_STREAM_USE_I2S0_SLAVE #if defined(CHIP_HAS_I2S) && (CHIP_HAS_I2S > 1) - || device == AUD_STREAM_USE_I2S1_MASTER || device == AUD_STREAM_USE_I2S1_SLAVE + || device == AUD_STREAM_USE_I2S1_MASTER || + device == AUD_STREAM_USE_I2S1_SLAVE #endif - ) - { - AF_TRACE_DEBUG(); + ) { + AF_TRACE_DEBUG(); - struct HAL_I2S_CONFIG_T i2s_cfg; - enum HAL_I2S_ID_T i2s_id; + struct HAL_I2S_CONFIG_T i2s_cfg; + enum HAL_I2S_ID_T i2s_id; - i2s_id = HAL_I2S_ID_0; + i2s_id = HAL_I2S_ID_0; #if defined(CHIP_HAS_I2S) && (CHIP_HAS_I2S > 1) - if(device == AUD_STREAM_USE_I2S1_MASTER || device == AUD_STREAM_USE_I2S1_SLAVE) { - i2s_id = HAL_I2S_ID_1; - } -#endif - - memset(&i2s_cfg, 0, sizeof(i2s_cfg)); - i2s_cfg.use_dma = AF_TRUE; - i2s_cfg.chan_sep_buf = cfg->chan_sep_buf; - i2s_cfg.sync_start = cfg->sync_start; - i2s_cfg.cycles = cfg->slot_cycles; - i2s_cfg.bits = cfg->bits; - i2s_cfg.channel_num = cfg->channel_num; - i2s_cfg.channel_map = cfg->channel_map; - i2s_cfg.sample_rate = cfg->sample_rate; - hal_i2s_setup_stream(i2s_id, stream, &i2s_cfg); + if (device == AUD_STREAM_USE_I2S1_MASTER || + device == AUD_STREAM_USE_I2S1_SLAVE) { + i2s_id = HAL_I2S_ID_1; } #endif + + memset(&i2s_cfg, 0, sizeof(i2s_cfg)); + i2s_cfg.use_dma = AF_TRUE; + i2s_cfg.chan_sep_buf = cfg->chan_sep_buf; + i2s_cfg.sync_start = cfg->sync_start; + i2s_cfg.cycles = cfg->slot_cycles; + i2s_cfg.bits = cfg->bits; + i2s_cfg.channel_num = cfg->channel_num; + i2s_cfg.channel_map = cfg->channel_map; + i2s_cfg.sample_rate = cfg->sample_rate; + hal_i2s_setup_stream(i2s_id, stream, &i2s_cfg); + } +#endif #ifdef AF_DEVICE_TDM - else if(device == AUD_STREAM_USE_TDM0_MASTER || device == AUD_STREAM_USE_TDM0_SLAVE + else if (device == AUD_STREAM_USE_TDM0_MASTER || + device == AUD_STREAM_USE_TDM0_SLAVE #if defined(CHIP_HAS_I2S) && (CHIP_HAS_I2S > 1) - || device == AUD_STREAM_USE_TDM1_MASTER || device == AUD_STREAM_USE_TDM1_SLAVE + || device == AUD_STREAM_USE_TDM1_MASTER || + device == AUD_STREAM_USE_TDM1_SLAVE #endif - ) - { - AF_TRACE_DEBUG(); + ) { + AF_TRACE_DEBUG(); - struct HAL_TDM_CONFIG_T tdm_cfg; - enum HAL_I2S_ID_T i2s_id; + struct HAL_TDM_CONFIG_T tdm_cfg; + enum HAL_I2S_ID_T i2s_id; - i2s_id = HAL_I2S_ID_0; + i2s_id = HAL_I2S_ID_0; #if defined(CHIP_HAS_I2S) && (CHIP_HAS_I2S > 1) - if(device == AUD_STREAM_USE_TDM1_MASTER || device == AUD_STREAM_USE_TDM1_SLAVE) { - i2s_id = HAL_I2S_ID_1; - } -#endif - - memset(&tdm_cfg, 0, sizeof(tdm_cfg)); - tdm_cfg.mode = HAL_TDM_MODE_FS_ASSERTED_AT_FIRST; - tdm_cfg.edge = HAL_TDM_FS_EDGE_POSEDGE; - tdm_cfg.cycles = (cfg->channel_num * cfg->slot_cycles); - tdm_cfg.fs_cycles = cfg->fs_cycles; - tdm_cfg.slot_cycles = cfg->slot_cycles; - tdm_cfg.data_offset = 0; - tdm_cfg.sync_start = cfg->sync_start; - TRACE(5,"%s: cycle = %d, fs_cycles = %d, slot_cycles = %d,wait = %d.", - __func__, tdm_cfg.cycles, tdm_cfg.fs_cycles, tdm_cfg.slot_cycles,tdm_cfg.sync_start); - hal_tdm_setup_stream(i2s_id, stream, cfg->sample_rate, &tdm_cfg); + if (device == AUD_STREAM_USE_TDM1_MASTER || + device == AUD_STREAM_USE_TDM1_SLAVE) { + i2s_id = HAL_I2S_ID_1; } +#endif + + memset(&tdm_cfg, 0, sizeof(tdm_cfg)); + tdm_cfg.mode = HAL_TDM_MODE_FS_ASSERTED_AT_FIRST; + tdm_cfg.edge = HAL_TDM_FS_EDGE_POSEDGE; + tdm_cfg.cycles = (cfg->channel_num * cfg->slot_cycles); + tdm_cfg.fs_cycles = cfg->fs_cycles; + tdm_cfg.slot_cycles = cfg->slot_cycles; + tdm_cfg.data_offset = 0; + tdm_cfg.sync_start = cfg->sync_start; + TRACE(5, "%s: cycle = %d, fs_cycles = %d, slot_cycles = %d,wait = %d.", + __func__, tdm_cfg.cycles, tdm_cfg.fs_cycles, tdm_cfg.slot_cycles, + tdm_cfg.sync_start); + hal_tdm_setup_stream(i2s_id, stream, cfg->sample_rate, &tdm_cfg); + } #endif #ifdef AF_DEVICE_INT_CODEC - else if(device == AUD_STREAM_USE_INT_CODEC) - { - AF_TRACE_DEBUG(); - struct HAL_CODEC_CONFIG_T codec_cfg; - memset(&codec_cfg, 0, sizeof(codec_cfg)); - codec_cfg.bits = cfg->bits; - codec_cfg.sample_rate = cfg->sample_rate; - codec_cfg.channel_num = cfg->channel_num; - codec_cfg.channel_map = cfg->channel_map; - codec_cfg.use_dma = AF_TRUE; - codec_cfg.vol = cfg->vol; - codec_cfg.io_path = cfg->io_path; + else if (device == AUD_STREAM_USE_INT_CODEC) { + AF_TRACE_DEBUG(); + struct HAL_CODEC_CONFIG_T codec_cfg; + memset(&codec_cfg, 0, sizeof(codec_cfg)); + codec_cfg.bits = cfg->bits; + codec_cfg.sample_rate = cfg->sample_rate; + codec_cfg.channel_num = cfg->channel_num; + codec_cfg.channel_map = cfg->channel_map; + codec_cfg.use_dma = AF_TRUE; + codec_cfg.vol = cfg->vol; + codec_cfg.io_path = cfg->io_path; - AF_TRACE_DEBUG(); - codec_int_stream_setup(stream, &codec_cfg); - } + AF_TRACE_DEBUG(); + codec_int_stream_setup(stream, &codec_cfg); + } #endif #ifdef AF_DEVICE_SPDIF - else if(device == AUD_STREAM_USE_INT_SPDIF) - { - AF_TRACE_DEBUG(); - struct HAL_SPDIF_CONFIG_T spdif_cfg; + else if (device == AUD_STREAM_USE_INT_SPDIF) { + AF_TRACE_DEBUG(); + struct HAL_SPDIF_CONFIG_T spdif_cfg; - memset(&spdif_cfg, 0, sizeof(spdif_cfg)); - spdif_cfg.use_dma = AF_TRUE; - spdif_cfg.bits = cfg->bits; - spdif_cfg.channel_num = cfg->channel_num; - spdif_cfg.sample_rate = cfg->sample_rate; - hal_spdif_setup_stream(AF_SPDIF_INST, stream, &spdif_cfg); - } + memset(&spdif_cfg, 0, sizeof(spdif_cfg)); + spdif_cfg.use_dma = AF_TRUE; + spdif_cfg.bits = cfg->bits; + spdif_cfg.channel_num = cfg->channel_num; + spdif_cfg.sample_rate = cfg->sample_rate; + hal_spdif_setup_stream(AF_SPDIF_INST, stream, &spdif_cfg); + } #endif #ifdef AF_DEVICE_BT_PCM - else if(device == AUD_STREAM_USE_BT_PCM) - { - AF_TRACE_DEBUG(); - struct HAL_BTPCM_CONFIG_T btpcm_cfg; + else if (device == AUD_STREAM_USE_BT_PCM) { + AF_TRACE_DEBUG(); + struct HAL_BTPCM_CONFIG_T btpcm_cfg; - memset(&btpcm_cfg, 0, sizeof(btpcm_cfg)); - btpcm_cfg.use_dma = AF_TRUE; - btpcm_cfg.bits = cfg->bits; - btpcm_cfg.channel_num = cfg->channel_num; - btpcm_cfg.sample_rate = cfg->sample_rate; - hal_btpcm_setup_stream(AF_BTPCM_INST, stream, &btpcm_cfg); - } + memset(&btpcm_cfg, 0, sizeof(btpcm_cfg)); + btpcm_cfg.use_dma = AF_TRUE; + btpcm_cfg.bits = cfg->bits; + btpcm_cfg.channel_num = cfg->channel_num; + btpcm_cfg.sample_rate = cfg->sample_rate; + hal_btpcm_setup_stream(AF_BTPCM_INST, stream, &btpcm_cfg); + } #endif #ifdef AF_DEVICE_DPD_RX - else if(device == AUD_STREAM_USE_DPD_RX) - { - AF_TRACE_DEBUG(); - } + else if (device == AUD_STREAM_USE_DPD_RX) { + AF_TRACE_DEBUG(); + } #endif #ifdef AUDIO_ANC_FB_MC - else if(device == AUD_STREAM_USE_MC) - { - AF_TRACE_DEBUG(); - hal_codec_setup_mc(cfg->channel_num, cfg->bits); - } + else if (device == AUD_STREAM_USE_MC) { + AF_TRACE_DEBUG(); + hal_codec_setup_mc(cfg->channel_num, cfg->bits); + } #endif - else - { - ASSERT(0, "[%s] ERROR: device %d is not defined!", __func__, device); - } + else { + ASSERT(0, "[%s] ERROR: device %d is not defined!", __func__, device); + } - AF_TRACE_DEBUG(); + AF_TRACE_DEBUG(); + ret = AF_RES_SUCCESS; + +_exit: + af_unlock_thread(); + + return ret; +} + +uint32_t af_stream_mute(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream, + bool mute) { + AF_TRACE_DEBUG(); + + struct af_stream_cfg_t *role; + enum AF_RESULT_T ret; + enum AUD_STREAM_USE_DEVICE_T device; + + ret = AF_RES_FAILD; + role = af_get_stream_role(id, stream); + + af_lock_thread(); + + if ((role->ctl.status & AF_STATUS_STREAM_OPEN_CLOSE) == 0) { + TRACE(2, "[%s] ERROR: status = %d", __func__, role->ctl.status); + goto _exit; + } + + device = role->ctl.use_device; + + if (device == AUD_STREAM_USE_INT_CODEC) { + codec_int_stream_mute(stream, mute); ret = AF_RES_SUCCESS; + } _exit: - af_unlock_thread(); + af_unlock_thread(); - return ret; + return ret; } -uint32_t af_stream_mute(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream, bool mute) -{ - AF_TRACE_DEBUG(); +uint32_t af_stream_set_chan_vol(enum AUD_STREAM_ID_T id, + enum AUD_STREAM_T stream, + enum AUD_CHANNEL_MAP_T ch_map, uint8_t vol) { + AF_TRACE_DEBUG(); - struct af_stream_cfg_t *role; - enum AF_RESULT_T ret; - enum AUD_STREAM_USE_DEVICE_T device; + struct af_stream_cfg_t *role; + enum AF_RESULT_T ret; + enum AUD_STREAM_USE_DEVICE_T device; - ret = AF_RES_FAILD; - role = af_get_stream_role(id, stream); + ret = AF_RES_FAILD; + role = af_get_stream_role(id, stream); - af_lock_thread(); + af_lock_thread(); - if ((role->ctl.status & AF_STATUS_STREAM_OPEN_CLOSE) == 0) { - TRACE(2,"[%s] ERROR: status = %d", __func__, role->ctl.status); - goto _exit; - } + if ((role->ctl.status & AF_STATUS_STREAM_OPEN_CLOSE) == 0) { + TRACE(2, "[%s] ERROR: status = %d", __func__, role->ctl.status); + goto _exit; + } - device = role->ctl.use_device; + device = role->ctl.use_device; - if (device == AUD_STREAM_USE_INT_CODEC) { - codec_int_stream_mute(stream, mute); - ret = AF_RES_SUCCESS; - } + if (device == AUD_STREAM_USE_INT_CODEC) { + codec_int_stream_set_chan_vol(stream, ch_map, vol); + ret = AF_RES_SUCCESS; + } _exit: - af_unlock_thread(); + af_unlock_thread(); - return ret; + return ret; } -uint32_t af_stream_set_chan_vol(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream, enum AUD_CHANNEL_MAP_T ch_map, uint8_t vol) -{ - AF_TRACE_DEBUG(); +uint32_t af_stream_restore_chan_vol(enum AUD_STREAM_ID_T id, + enum AUD_STREAM_T stream) { + AF_TRACE_DEBUG(); - struct af_stream_cfg_t *role; - enum AF_RESULT_T ret; - enum AUD_STREAM_USE_DEVICE_T device; + struct af_stream_cfg_t *role; + enum AF_RESULT_T ret; + enum AUD_STREAM_USE_DEVICE_T device; - ret = AF_RES_FAILD; - role = af_get_stream_role(id, stream); + ret = AF_RES_FAILD; + role = af_get_stream_role(id, stream); - af_lock_thread(); + af_lock_thread(); - if ((role->ctl.status & AF_STATUS_STREAM_OPEN_CLOSE) == 0) { - TRACE(2,"[%s] ERROR: status = %d", __func__, role->ctl.status); - goto _exit; - } + if ((role->ctl.status & AF_STATUS_STREAM_OPEN_CLOSE) == 0) { + TRACE(2, "[%s] ERROR: status = %d", __func__, role->ctl.status); + goto _exit; + } - device = role->ctl.use_device; + device = role->ctl.use_device; - if (device == AUD_STREAM_USE_INT_CODEC) { - codec_int_stream_set_chan_vol(stream, ch_map, vol); - ret = AF_RES_SUCCESS; - } + if (device == AUD_STREAM_USE_INT_CODEC) { + codec_int_stream_restore_chan_vol(stream); + ret = AF_RES_SUCCESS; + } _exit: - af_unlock_thread(); + af_unlock_thread(); - return ret; -} - -uint32_t af_stream_restore_chan_vol(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) -{ - AF_TRACE_DEBUG(); - - struct af_stream_cfg_t *role; - enum AF_RESULT_T ret; - enum AUD_STREAM_USE_DEVICE_T device; - - ret = AF_RES_FAILD; - role = af_get_stream_role(id, stream); - - af_lock_thread(); - - if ((role->ctl.status & AF_STATUS_STREAM_OPEN_CLOSE) == 0) { - TRACE(2,"[%s] ERROR: status = %d", __func__, role->ctl.status); - goto _exit; - } - - device = role->ctl.use_device; - - if (device == AUD_STREAM_USE_INT_CODEC) { - codec_int_stream_restore_chan_vol(stream); - ret = AF_RES_SUCCESS; - } - -_exit: - af_unlock_thread(); - - return ret; + return ret; } #ifdef CODEC_PLAY_BEFORE_CAPTURE static struct af_stream_cfg_t *codec_capture_role; -static void af_codec_stream_pre_start(enum AUD_STREAM_T stream) -{ - struct af_stream_cfg_t *role = NULL; +static void af_codec_stream_pre_start(enum AUD_STREAM_T stream) { + struct af_stream_cfg_t *role = NULL; - if (stream == AUD_STREAM_CAPTURE) { - return; - } + if (stream == AUD_STREAM_CAPTURE) { + return; + } - for(uint8_t id=0; id< AUD_STREAM_ID_NUM; id++) - { - role = af_get_stream_role((enum AUD_STREAM_ID_T)id, AUD_STREAM_CAPTURE); - if (role->cfg.device == AUD_STREAM_USE_INT_CODEC && - role->ctl.status == (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE | AF_STATUS_STREAM_START_STOP)) { - hal_audma_stop(role->dma_cfg.ch); - codec_int_stream_stop(AUD_STREAM_CAPTURE); - codec_capture_role = role; - return; - } + for (uint8_t id = 0; id < AUD_STREAM_ID_NUM; id++) { + role = af_get_stream_role((enum AUD_STREAM_ID_T)id, AUD_STREAM_CAPTURE); + if (role->cfg.device == AUD_STREAM_USE_INT_CODEC && + role->ctl.status == + (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE | + AF_STATUS_STREAM_START_STOP)) { + hal_audma_stop(role->dma_cfg.ch); + codec_int_stream_stop(AUD_STREAM_CAPTURE); + codec_capture_role = role; + return; } + } } -static void af_codec_stream_post_start(enum AUD_STREAM_T stream) -{ - if (stream == AUD_STREAM_CAPTURE) { - return; - } +static void af_codec_stream_post_start(enum AUD_STREAM_T stream) { + if (stream == AUD_STREAM_CAPTURE) { + return; + } - if (codec_capture_role) { - hal_audma_sg_start(&codec_capture_role->dma_desc[0], &codec_capture_role->dma_cfg); - codec_int_stream_start(AUD_STREAM_CAPTURE); - codec_capture_role = NULL; - } + if (codec_capture_role) { + hal_audma_sg_start(&codec_capture_role->dma_desc[0], + &codec_capture_role->dma_cfg); + codec_int_stream_start(AUD_STREAM_CAPTURE); + codec_capture_role = NULL; + } } -static void af_codec_stream_pre_stop(enum AUD_STREAM_T stream) -{ - struct af_stream_cfg_t *role = NULL; +static void af_codec_stream_pre_stop(enum AUD_STREAM_T stream) { + struct af_stream_cfg_t *role = NULL; - if (stream == AUD_STREAM_CAPTURE) { - return; - } + if (stream == AUD_STREAM_CAPTURE) { + return; + } - for(uint8_t id=0; id< AUD_STREAM_ID_NUM; id++) - { - role = af_get_stream_role((enum AUD_STREAM_ID_T)id, AUD_STREAM_CAPTURE); - if (role->cfg.device == AUD_STREAM_USE_INT_CODEC && - role->ctl.status == (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE | AF_STATUS_STREAM_START_STOP)) { - hal_audma_stop(role->dma_cfg.ch); - codec_int_stream_stop(AUD_STREAM_CAPTURE); - codec_capture_role = role; - return; - } + for (uint8_t id = 0; id < AUD_STREAM_ID_NUM; id++) { + role = af_get_stream_role((enum AUD_STREAM_ID_T)id, AUD_STREAM_CAPTURE); + if (role->cfg.device == AUD_STREAM_USE_INT_CODEC && + role->ctl.status == + (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE | + AF_STATUS_STREAM_START_STOP)) { + hal_audma_stop(role->dma_cfg.ch); + codec_int_stream_stop(AUD_STREAM_CAPTURE); + codec_capture_role = role; + return; } + } } -static void af_codec_stream_post_stop(enum AUD_STREAM_T stream) -{ - if (stream == AUD_STREAM_CAPTURE) { - return; - } +static void af_codec_stream_post_stop(enum AUD_STREAM_T stream) { + if (stream == AUD_STREAM_CAPTURE) { + return; + } - if (codec_capture_role) { - hal_audma_sg_start(&codec_capture_role->dma_desc[0], &codec_capture_role->dma_cfg); - codec_int_stream_start(AUD_STREAM_CAPTURE); - codec_capture_role = NULL; - } + if (codec_capture_role) { + hal_audma_sg_start(&codec_capture_role->dma_desc[0], + &codec_capture_role->dma_cfg); + codec_int_stream_start(AUD_STREAM_CAPTURE); + codec_capture_role = NULL; + } } #endif -uint32_t af_stream_start(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) -{ - struct af_stream_cfg_t *role; - enum AF_RESULT_T ret; - enum AUD_STREAM_USE_DEVICE_T device; - enum HAL_DMA_RET_T dma_ret; +uint32_t af_stream_start(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) { + struct af_stream_cfg_t *role; + enum AF_RESULT_T ret; + enum AUD_STREAM_USE_DEVICE_T device; + enum HAL_DMA_RET_T dma_ret; - role = af_get_stream_role(id, stream); - TRACE(3,"[%s] id = %d, stream = %d", __func__, id, stream); + role = af_get_stream_role(id, stream); + TRACE(3, "[%s] id = %d, stream = %d", __func__, id, stream); - af_lock_thread(); + af_lock_thread(); - //check stream is open and not start. - if(role->ctl.status != (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE)) - { - TRACE(2,"[%s] ERROR: status = %d",__func__, role->ctl.status); - ret = AF_RES_FAILD; - goto _exit; - } + // check stream is open and not start. + if (role->ctl.status != + (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE)) { + TRACE(2, "[%s] ERROR: status = %d", __func__, role->ctl.status); + ret = AF_RES_FAILD; + goto _exit; + } - device = role->ctl.use_device; + device = role->ctl.use_device; - role->ctl.pp_index = PP_PING; - role->ctl.pp_cnt = 0; + role->ctl.pp_index = PP_PING; + role->ctl.pp_cnt = 0; #ifndef RTOS - af_clear_flag(&af_flag_signal, 1 << (id * 2 + stream)); + af_clear_flag(&af_flag_signal, 1 << (id * 2 + stream)); #endif - if (device == AUD_STREAM_USE_INT_CODEC && stream == AUD_STREAM_PLAYBACK) { + if (device == AUD_STREAM_USE_INT_CODEC && stream == AUD_STREAM_PLAYBACK) { #ifdef AUDIO_OUTPUT_PA_ON_FADE_IN - dac_pa_state = AF_DAC_PA_ON_TRIGGER; - // Has the buffer been zero-ed out? - af_zero_mem(role->dma_buf_ptr, role->dma_buf_size); + dac_pa_state = AF_DAC_PA_ON_TRIGGER; + // Has the buffer been zero-ed out? + af_zero_mem(role->dma_buf_ptr, role->dma_buf_size); #ifdef AUDIO_OUTPUT_DC_CALIB_SW - af_codec_playback_sw_dc_calib(role->dma_buf_ptr, role->dma_buf_size, role->cfg.bits, role->cfg.channel_num); + af_codec_playback_sw_dc_calib(role->dma_buf_ptr, role->dma_buf_size, + role->cfg.bits, role->cfg.channel_num); #endif - dac_dc_start_time = hal_sys_timer_get(); + dac_dc_start_time = hal_sys_timer_get(); #endif - } + } #ifndef CHIP_BEST1000 - if (role->cfg.chan_sep_buf && role->cfg.channel_num > AUD_CHANNEL_NUM_1) { - struct HAL_DMA_2D_CFG_T *src, *dst; - struct HAL_DMA_2D_CFG_T dma_2d_cfg; - uint8_t burst_size = 1; - uint32_t chan_xfer_cnt; + if (role->cfg.chan_sep_buf && role->cfg.channel_num > AUD_CHANNEL_NUM_1) { + struct HAL_DMA_2D_CFG_T *src, *dst; + struct HAL_DMA_2D_CFG_T dma_2d_cfg; + uint8_t burst_size = 1; + uint32_t chan_xfer_cnt; - src = NULL; - dst = NULL; - if (stream == AUD_STREAM_PLAYBACK) { - if (role->cfg.channel_num == AUD_CHANNEL_NUM_2) { - ASSERT(role->dma_cfg.src_bsize == HAL_DMA_BSIZE_1, - "Play 2D DMA: Bad src burst size: %d", role->dma_cfg.src_bsize); - burst_size = 1; - src = &dma_2d_cfg; - } + src = NULL; + dst = NULL; + if (stream == AUD_STREAM_PLAYBACK) { + if (role->cfg.channel_num == AUD_CHANNEL_NUM_2) { + ASSERT(role->dma_cfg.src_bsize == HAL_DMA_BSIZE_1, + "Play 2D DMA: Bad src burst size: %d", role->dma_cfg.src_bsize); + burst_size = 1; + src = &dma_2d_cfg; + } + } else { + if (role->cfg.channel_num > AUD_CHANNEL_NUM_1) { + ASSERT(role->dma_cfg.src_bsize == role->dma_cfg.dst_bsize, + "Cap 2D DMA: src burst size (%d) != dst (%d)", + role->dma_cfg.src_bsize, role->dma_cfg.dst_bsize); + if (role->dma_cfg.dst_bsize == HAL_DMA_BSIZE_1) { + burst_size = 1; + } else if (role->dma_cfg.dst_bsize == HAL_DMA_BSIZE_4) { + burst_size = 4; + } else if (role->dma_cfg.dst_bsize == HAL_DMA_BSIZE_8) { + burst_size = 8; } else { - if (role->cfg.channel_num > AUD_CHANNEL_NUM_1) { - ASSERT(role->dma_cfg.src_bsize == role->dma_cfg.dst_bsize, - "Cap 2D DMA: src burst size (%d) != dst (%d)", role->dma_cfg.src_bsize, role->dma_cfg.dst_bsize); - if (role->dma_cfg.dst_bsize == HAL_DMA_BSIZE_1) { - burst_size = 1; - } else if (role->dma_cfg.dst_bsize == HAL_DMA_BSIZE_4) { - burst_size = 4; - } else if (role->dma_cfg.dst_bsize == HAL_DMA_BSIZE_8) { - burst_size = 8; - } else { - ASSERT(false, "Cap 2D DMA: Bad dst burst size: %d", role->dma_cfg.dst_bsize); - } - dst = &dma_2d_cfg; - } + ASSERT(false, "Cap 2D DMA: Bad dst burst size: %d", + role->dma_cfg.dst_bsize); } + dst = &dma_2d_cfg; + } + } - if (src || dst) { - chan_xfer_cnt = role->dma_cfg.src_tsize * AUDIO_BUFFER_COUNT / role->cfg.channel_num; - dma_2d_cfg.xcount = role->cfg.channel_num; - dma_2d_cfg.xmodify = chan_xfer_cnt - burst_size; - dma_2d_cfg.ycount = chan_xfer_cnt / burst_size; - dma_2d_cfg.ymodify = -chan_xfer_cnt * (role->cfg.channel_num - 1); - } + if (src || dst) { + chan_xfer_cnt = + role->dma_cfg.src_tsize * AUDIO_BUFFER_COUNT / role->cfg.channel_num; + dma_2d_cfg.xcount = role->cfg.channel_num; + dma_2d_cfg.xmodify = chan_xfer_cnt - burst_size; + dma_2d_cfg.ycount = chan_xfer_cnt / burst_size; + dma_2d_cfg.ymodify = -chan_xfer_cnt * (role->cfg.channel_num - 1); + } - dma_ret = hal_dma_sg_2d_start(&role->dma_desc[0], &role->dma_cfg, src, dst); - } else + dma_ret = hal_dma_sg_2d_start(&role->dma_desc[0], &role->dma_cfg, src, dst); + } else #endif - { - dma_ret = hal_dma_sg_start(&role->dma_desc[0], &role->dma_cfg); - } - ASSERT(dma_ret == HAL_DMA_OK, "[%s] Failed to start dma for stream %d: ret=%d", __func__, stream, dma_ret); + { + dma_ret = hal_dma_sg_start(&role->dma_desc[0], &role->dma_cfg); + } + ASSERT(dma_ret == HAL_DMA_OK, + "[%s] Failed to start dma for stream %d: ret=%d", __func__, stream, + dma_ret); - AF_TRACE_DEBUG(); - if(0) - { - } + AF_TRACE_DEBUG(); + if (0) { + } #ifdef AF_DEVICE_EXT_CODEC - else if(device == AUD_STREAM_USE_EXT_CODEC) - { - AF_TRACE_DEBUG(); - tlv32aic32_stream_start(stream); - } + else if (device == AUD_STREAM_USE_EXT_CODEC) { + AF_TRACE_DEBUG(); + tlv32aic32_stream_start(stream); + } #endif #ifdef AF_DEVICE_I2S - else if(device == AUD_STREAM_USE_I2S0_MASTER || device == AUD_STREAM_USE_I2S0_SLAVE) - { - hal_i2s_start_stream(HAL_I2S_ID_0, stream); - } + else if (device == AUD_STREAM_USE_I2S0_MASTER || + device == AUD_STREAM_USE_I2S0_SLAVE) { + hal_i2s_start_stream(HAL_I2S_ID_0, stream); + } #if defined(CHIP_HAS_I2S) && (CHIP_HAS_I2S > 1) - else if(device == AUD_STREAM_USE_I2S1_MASTER || device == AUD_STREAM_USE_I2S1_SLAVE) - { - hal_i2s_start_stream(HAL_I2S_ID_1, stream); - } + else if (device == AUD_STREAM_USE_I2S1_MASTER || + device == AUD_STREAM_USE_I2S1_SLAVE) { + hal_i2s_start_stream(HAL_I2S_ID_1, stream); + } #endif #endif #ifdef AF_DEVICE_TDM - else if(device == AUD_STREAM_USE_TDM0_MASTER || device == AUD_STREAM_USE_TDM0_SLAVE) - { - hal_tdm_start_stream(HAL_I2S_ID_0, stream); - } + else if (device == AUD_STREAM_USE_TDM0_MASTER || + device == AUD_STREAM_USE_TDM0_SLAVE) { + hal_tdm_start_stream(HAL_I2S_ID_0, stream); + } #if defined(CHIP_HAS_I2S) && (CHIP_HAS_I2S > 1) - else if(device == AUD_STREAM_USE_TDM1_MASTER || device == AUD_STREAM_USE_TDM1_SLAVE) - { - hal_tdm_start_stream(HAL_I2S_ID_1, stream); - } + else if (device == AUD_STREAM_USE_TDM1_MASTER || + device == AUD_STREAM_USE_TDM1_SLAVE) { + hal_tdm_start_stream(HAL_I2S_ID_1, stream); + } #endif #endif #ifdef AF_DEVICE_INT_CODEC - else if(device == AUD_STREAM_USE_INT_CODEC) - { - AF_TRACE_DEBUG(); + else if (device == AUD_STREAM_USE_INT_CODEC) { + AF_TRACE_DEBUG(); #ifdef CODEC_PLAY_BEFORE_CAPTURE - af_codec_stream_pre_start(stream); + af_codec_stream_pre_start(stream); #endif - codec_int_stream_start(stream); + codec_int_stream_start(stream); #ifdef CODEC_PLAY_BEFORE_CAPTURE - af_codec_stream_post_start(stream); + af_codec_stream_post_start(stream); #endif - } + } #endif #ifdef AF_DEVICE_SPDIF - else if(device == AUD_STREAM_USE_INT_SPDIF) - { - AF_TRACE_DEBUG(); - hal_spdif_start_stream(AF_SPDIF_INST, stream); - } + else if (device == AUD_STREAM_USE_INT_SPDIF) { + AF_TRACE_DEBUG(); + hal_spdif_start_stream(AF_SPDIF_INST, stream); + } #endif #ifdef AF_DEVICE_BT_PCM - else if(device == AUD_STREAM_USE_BT_PCM) - { - AF_TRACE_DEBUG(); - hal_btpcm_start_stream(AF_BTPCM_INST, stream); - } + else if (device == AUD_STREAM_USE_BT_PCM) { + AF_TRACE_DEBUG(); + hal_btpcm_start_stream(AF_BTPCM_INST, stream); + } #endif #ifdef AF_DEVICE_DPD_RX - else if(device == AUD_STREAM_USE_DPD_RX) - { - AF_TRACE_DEBUG(); - hal_btpcm_start_stream(AF_BTPCM_INST, stream); - } + else if (device == AUD_STREAM_USE_DPD_RX) { + AF_TRACE_DEBUG(); + hal_btpcm_start_stream(AF_BTPCM_INST, stream); + } #endif #ifdef AUDIO_ANC_FB_MC - else if(device == AUD_STREAM_USE_MC) - { - AF_TRACE_DEBUG(); - } -#endif - else - { - ASSERT(0, "[%s] ERROR: device %d is not defined!", __func__, device); - } - + else if (device == AUD_STREAM_USE_MC) { AF_TRACE_DEBUG(); - af_set_status(id, stream, AF_STATUS_STREAM_START_STOP); + } +#endif + else { + ASSERT(0, "[%s] ERROR: device %d is not defined!", __func__, device); + } - ret = AF_RES_SUCCESS; + AF_TRACE_DEBUG(); + af_set_status(id, stream, AF_STATUS_STREAM_START_STOP); + + ret = AF_RES_SUCCESS; _exit: - af_unlock_thread(); + af_unlock_thread(); - return ret; + return ret; } -uint32_t af_stream_stop(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) -{ - struct af_stream_cfg_t *role; - enum AF_RESULT_T ret; - enum AUD_STREAM_USE_DEVICE_T device; +uint32_t af_stream_stop(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) { + struct af_stream_cfg_t *role; + enum AF_RESULT_T ret; + enum AUD_STREAM_USE_DEVICE_T device; - role = af_get_stream_role(id, stream); - TRACE(3,"[%s] id = %d, stream = %d", __func__, id, stream); + role = af_get_stream_role(id, stream); + TRACE(3, "[%s] id = %d, stream = %d", __func__, id, stream); - af_lock_thread(); + af_lock_thread(); - device = role->ctl.use_device; + device = role->ctl.use_device; - if (device == AUD_STREAM_USE_INT_CODEC && - role->ctl.status == (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE | AF_STATUS_STREAM_START_STOP | AF_STATUS_STREAM_PAUSE_RESTART)) - { - af_clear_status(id, stream, AF_STATUS_STREAM_PAUSE_RESTART); - goto _pause_stop; - } + if (device == AUD_STREAM_USE_INT_CODEC && + role->ctl.status == + (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE | + AF_STATUS_STREAM_START_STOP | AF_STATUS_STREAM_PAUSE_RESTART)) { + af_clear_status(id, stream, AF_STATUS_STREAM_PAUSE_RESTART); + goto _pause_stop; + } - //check stream is start and not stop - if (role->ctl.status != (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE | AF_STATUS_STREAM_START_STOP)) - { - TRACE(2,"[%s] ERROR: status = %d",__func__, role->ctl.status); - ret = AF_RES_FAILD; - goto _exit; - } + // check stream is start and not stop + if (role->ctl.status != (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE | + AF_STATUS_STREAM_START_STOP)) { + TRACE(2, "[%s] ERROR: status = %d", __func__, role->ctl.status); + ret = AF_RES_FAILD; + goto _exit; + } #if defined(RTOS) && defined(AF_STREAM_ID_0_PLAYBACK_FADEOUT) - if (id == AUD_STREAM_ID_0 && stream == AUD_STREAM_PLAYBACK){ - af_stream_fadeout_start(512); - af_stream_stop_wait_finish(); - } + if (id == AUD_STREAM_ID_0 && stream == AUD_STREAM_PLAYBACK) { + af_stream_fadeout_start(512); + af_stream_stop_wait_finish(); + } #endif - if (device == AUD_STREAM_USE_INT_CODEC && stream == AUD_STREAM_PLAYBACK) { + if (device == AUD_STREAM_USE_INT_CODEC && stream == AUD_STREAM_PLAYBACK) { #ifdef AUDIO_OUTPUT_PA_OFF_FADE_OUT - dac_pa_state = AF_DAC_PA_OFF_TRIGGER; - af_unlock_thread(); - while (dac_pa_state != AF_DAC_PA_NULL) { + dac_pa_state = AF_DAC_PA_OFF_TRIGGER; + af_unlock_thread(); + while (dac_pa_state != AF_DAC_PA_NULL) { #ifdef RTOS - osSignalWait((1 << AF_FADE_OUT_SIGNAL_ID), 300); - osSignalClear(fade_thread_id, (1 << AF_FADE_OUT_SIGNAL_ID)); + osSignalWait((1 << AF_FADE_OUT_SIGNAL_ID), 300); + osSignalClear(fade_thread_id, (1 << AF_FADE_OUT_SIGNAL_ID)); #else - af_thread(NULL); + af_thread(NULL); #endif - } - af_lock_thread(); -#elif defined(AUDIO_OUTPUT_PA_ON_FADE_IN) - dac_pa_state = AF_DAC_PA_NULL; - analog_aud_codec_speaker_enable(false); - dac_pa_stop_time = hal_sys_timer_get(); -#endif // !AUDIO_OUTPUT_PA_OFF_FADE_OUT && AUDIO_OUTPUT_PA_ON_FADE_IN } + af_lock_thread(); +#elif defined(AUDIO_OUTPUT_PA_ON_FADE_IN) + dac_pa_state = AF_DAC_PA_NULL; + analog_aud_codec_speaker_enable(false); + dac_pa_stop_time = hal_sys_timer_get(); +#endif // !AUDIO_OUTPUT_PA_OFF_FADE_OUT && AUDIO_OUTPUT_PA_ON_FADE_IN + } - hal_audma_stop(role->dma_cfg.ch); + hal_audma_stop(role->dma_cfg.ch); #if defined(RTOS) && defined(AF_STREAM_ID_0_PLAYBACK_FADEOUT) - if (id == AUD_STREAM_ID_0 && stream == AUD_STREAM_PLAYBACK){ - af_stream_fadeout_stop(); - } + if (id == AUD_STREAM_ID_0 && stream == AUD_STREAM_PLAYBACK) { + af_stream_fadeout_stop(); + } #endif - if(0) - { - } + if (0) { + } #ifdef AF_DEVICE_EXT_CODEC - else if(device == AUD_STREAM_USE_EXT_CODEC) - { - AF_TRACE_DEBUG(); - tlv32aic32_stream_stop(stream); - } + else if (device == AUD_STREAM_USE_EXT_CODEC) { + AF_TRACE_DEBUG(); + tlv32aic32_stream_stop(stream); + } #endif #ifdef AF_DEVICE_I2S - else if(device == AUD_STREAM_USE_I2S0_MASTER || device == AUD_STREAM_USE_I2S0_SLAVE) - { - AF_TRACE_DEBUG(); - hal_i2s_stop_stream(HAL_I2S_ID_0, stream); - } + else if (device == AUD_STREAM_USE_I2S0_MASTER || + device == AUD_STREAM_USE_I2S0_SLAVE) { + AF_TRACE_DEBUG(); + hal_i2s_stop_stream(HAL_I2S_ID_0, stream); + } #if defined(CHIP_HAS_I2S) && (CHIP_HAS_I2S > 1) - else if(device == AUD_STREAM_USE_I2S1_MASTER || device == AUD_STREAM_USE_I2S1_SLAVE) - { - AF_TRACE_DEBUG(); - hal_i2s_stop_stream(HAL_I2S_ID_1, stream); - } + else if (device == AUD_STREAM_USE_I2S1_MASTER || + device == AUD_STREAM_USE_I2S1_SLAVE) { + AF_TRACE_DEBUG(); + hal_i2s_stop_stream(HAL_I2S_ID_1, stream); + } #endif #endif #ifdef AF_DEVICE_TDM - else if(device == AUD_STREAM_USE_TDM0_MASTER || device == AUD_STREAM_USE_TDM0_SLAVE) - { - AF_TRACE_DEBUG(); - hal_tdm_stop_stream(HAL_I2S_ID_0, stream); - } + else if (device == AUD_STREAM_USE_TDM0_MASTER || + device == AUD_STREAM_USE_TDM0_SLAVE) { + AF_TRACE_DEBUG(); + hal_tdm_stop_stream(HAL_I2S_ID_0, stream); + } #if defined(CHIP_HAS_I2S) && (CHIP_HAS_I2S > 1) - else if(device == AUD_STREAM_USE_TDM1_MASTER || device == AUD_STREAM_USE_TDM1_SLAVE) - { - AF_TRACE_DEBUG(); - hal_tdm_stop_stream(HAL_I2S_ID_1, stream); - } + else if (device == AUD_STREAM_USE_TDM1_MASTER || + device == AUD_STREAM_USE_TDM1_SLAVE) { + AF_TRACE_DEBUG(); + hal_tdm_stop_stream(HAL_I2S_ID_1, stream); + } #endif #endif #ifdef AF_DEVICE_INT_CODEC - else if(device == AUD_STREAM_USE_INT_CODEC) - { - AF_TRACE_DEBUG(); + else if (device == AUD_STREAM_USE_INT_CODEC) { + AF_TRACE_DEBUG(); #ifdef CODEC_PLAY_BEFORE_CAPTURE - af_codec_stream_pre_stop(stream); + af_codec_stream_pre_stop(stream); #endif - codec_int_stream_stop(stream); + codec_int_stream_stop(stream); #ifdef CODEC_PLAY_BEFORE_CAPTURE - af_codec_stream_post_stop(stream); + af_codec_stream_post_stop(stream); #endif - } + } #endif #ifdef AF_DEVICE_SPDIF - else if(device == AUD_STREAM_USE_INT_SPDIF) - { - AF_TRACE_DEBUG(); - hal_spdif_stop_stream(AF_SPDIF_INST, stream); - } + else if (device == AUD_STREAM_USE_INT_SPDIF) { + AF_TRACE_DEBUG(); + hal_spdif_stop_stream(AF_SPDIF_INST, stream); + } #endif #ifdef AF_DEVICE_BT_PCM - else if(device == AUD_STREAM_USE_BT_PCM) - { - AF_TRACE_DEBUG(); - hal_btpcm_stop_stream(AF_BTPCM_INST, stream); - } + else if (device == AUD_STREAM_USE_BT_PCM) { + AF_TRACE_DEBUG(); + hal_btpcm_stop_stream(AF_BTPCM_INST, stream); + } #endif #ifdef AF_DEVICE_DPD_RX - else if(device == AUD_STREAM_USE_DPD_RX) - { - AF_TRACE_DEBUG(); - hal_btpcm_stop_stream(AF_BTPCM_INST, stream); - } + else if (device == AUD_STREAM_USE_DPD_RX) { + AF_TRACE_DEBUG(); + hal_btpcm_stop_stream(AF_BTPCM_INST, stream); + } #endif #ifdef AUDIO_ANC_FB_MC - else if(device == AUD_STREAM_USE_MC) - { - AF_TRACE_DEBUG(); - } + else if (device == AUD_STREAM_USE_MC) { + AF_TRACE_DEBUG(); + } #endif - else - { - ASSERT(0, "[%s] ERROR: device %d is not defined!", __func__, device); - } + else { + ASSERT(0, "[%s] ERROR: device %d is not defined!", __func__, device); + } _pause_stop: - AF_TRACE_DEBUG(); - af_clear_status(id, stream, AF_STATUS_STREAM_START_STOP); + AF_TRACE_DEBUG(); + af_clear_status(id, stream, AF_STATUS_STREAM_START_STOP); #ifndef RTOS - af_clear_flag(&af_flag_signal, 1 << (id * 2 + stream)); + af_clear_flag(&af_flag_signal, 1 << (id * 2 + stream)); #endif - ret = AF_RES_SUCCESS; + ret = AF_RES_SUCCESS; _exit: - af_unlock_thread(); + af_unlock_thread(); - return ret; + return ret; } -uint32_t af_stream_pause(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) -{ +uint32_t af_stream_pause(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) { #ifdef CHIP_BEST1000 - struct af_stream_cfg_t *role = NULL; - enum AF_RESULT_T ret; + struct af_stream_cfg_t *role = NULL; + enum AF_RESULT_T ret; - role = af_get_stream_role(id, stream); - TRACE(3,"[%s] id = %d, stream = %d", __func__, id, stream); + role = af_get_stream_role(id, stream); + TRACE(3, "[%s] id = %d, stream = %d", __func__, id, stream); - af_lock_thread(); + af_lock_thread(); - if (role->cfg.device != AUD_STREAM_USE_INT_CODEC) - { - ret = AF_RES_FAILD; - goto _exit; - } - if (role->ctl.status != (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE | AF_STATUS_STREAM_START_STOP)) - { - TRACE(2,"[%s] ERROR: status = %d",__func__, role->ctl.status); - ret = AF_RES_FAILD; - goto _exit; - } + if (role->cfg.device != AUD_STREAM_USE_INT_CODEC) { + ret = AF_RES_FAILD; + goto _exit; + } + if (role->ctl.status != (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE | + AF_STATUS_STREAM_START_STOP)) { + TRACE(2, "[%s] ERROR: status = %d", __func__, role->ctl.status); + ret = AF_RES_FAILD; + goto _exit; + } #if defined(AUDIO_OUTPUT_PA_ON_FADE_IN) || defined(AUDIO_OUTPUT_PA_OFF_FADE_OUT) - if (AUD_STREAM_PLAYBACK == stream) - { - dac_pa_state = AF_DAC_PA_NULL; - analog_aud_codec_speaker_enable(false); - dac_pa_stop_time = hal_sys_timer_get(); - } + if (AUD_STREAM_PLAYBACK == stream) { + dac_pa_state = AF_DAC_PA_NULL; + analog_aud_codec_speaker_enable(false); + dac_pa_stop_time = hal_sys_timer_get(); + } #endif - hal_audma_stop(role->dma_cfg.ch); + hal_audma_stop(role->dma_cfg.ch); #ifndef FPGA - codec_int_stream_stop(stream); + codec_int_stream_stop(stream); #endif - af_set_status(id, stream, AF_STATUS_STREAM_PAUSE_RESTART); + af_set_status(id, stream, AF_STATUS_STREAM_PAUSE_RESTART); - ret = AF_RES_SUCCESS; + ret = AF_RES_SUCCESS; _exit: - af_unlock_thread(); + af_unlock_thread(); - return ret; + return ret; #else - return af_stream_stop(id, stream); + return af_stream_stop(id, stream); #endif } -uint32_t af_stream_restart(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) -{ +uint32_t af_stream_restart(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) { #ifdef CHIP_BEST1000 - struct af_stream_cfg_t *role = NULL; - enum AF_RESULT_T ret; + struct af_stream_cfg_t *role = NULL; + enum AF_RESULT_T ret; - role = af_get_stream_role(id, stream); - TRACE(3,"[%s] id = %d, stream = %d", __func__, id, stream); + role = af_get_stream_role(id, stream); + TRACE(3, "[%s] id = %d, stream = %d", __func__, id, stream); - af_lock_thread(); + af_lock_thread(); - if (role->cfg.device != AUD_STREAM_USE_INT_CODEC) - { - ret = AF_RES_FAILD; - goto _exit; - } - if (role->ctl.status != (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE | AF_STATUS_STREAM_START_STOP | AF_STATUS_STREAM_PAUSE_RESTART)) - { - TRACE(2,"[%s] ERROR: status = %d",__func__, role->ctl.status); - ret = AF_RES_FAILD; - goto _exit; - } + if (role->cfg.device != AUD_STREAM_USE_INT_CODEC) { + ret = AF_RES_FAILD; + goto _exit; + } + if (role->ctl.status != + (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE | + AF_STATUS_STREAM_START_STOP | AF_STATUS_STREAM_PAUSE_RESTART)) { + TRACE(2, "[%s] ERROR: status = %d", __func__, role->ctl.status); + ret = AF_RES_FAILD; + goto _exit; + } - role->ctl.pp_index = PP_PING; - role->ctl.pp_cnt = 0; + role->ctl.pp_index = PP_PING; + role->ctl.pp_cnt = 0; #ifdef AUDIO_OUTPUT_PA_ON_FADE_IN - if (AUD_STREAM_PLAYBACK == stream) - { - dac_pa_state = AF_DAC_PA_ON_TRIGGER; - af_zero_mem(role->dma_buf_ptr, role->dma_buf_size); + if (AUD_STREAM_PLAYBACK == stream) { + dac_pa_state = AF_DAC_PA_ON_TRIGGER; + af_zero_mem(role->dma_buf_ptr, role->dma_buf_size); #ifdef AUDIO_OUTPUT_DC_CALIB_SW - af_codec_playback_sw_dc_calib(role->dma_buf_ptr, role->dma_buf_size, role->cfg.bits, role->cfg.channel_num); + af_codec_playback_sw_dc_calib(role->dma_buf_ptr, role->dma_buf_size, + role->cfg.bits, role->cfg.channel_num); #endif - dac_dc_start_time = hal_sys_timer_get(); - } + dac_dc_start_time = hal_sys_timer_get(); + } #endif - hal_audma_sg_start(&role->dma_desc[0], &role->dma_cfg); + hal_audma_sg_start(&role->dma_desc[0], &role->dma_cfg); #ifndef FPGA - codec_int_stream_start(stream); + codec_int_stream_start(stream); #endif - af_clear_status(id, stream, AF_STATUS_STREAM_PAUSE_RESTART); + af_clear_status(id, stream, AF_STATUS_STREAM_PAUSE_RESTART); - ret = AF_RES_SUCCESS; + ret = AF_RES_SUCCESS; _exit: - af_unlock_thread(); + af_unlock_thread(); - return ret; + return ret; #else - return af_stream_start(id, stream); + return af_stream_start(id, stream); #endif } -uint32_t af_stream_close(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) -{ - struct af_stream_cfg_t *role; - enum AF_RESULT_T ret; - enum AUD_STREAM_USE_DEVICE_T device; +uint32_t af_stream_close(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) { + struct af_stream_cfg_t *role; + enum AF_RESULT_T ret; + enum AUD_STREAM_USE_DEVICE_T device; - role = af_get_stream_role(id, stream); - TRACE(3,"[%s] id = %d, stream = %d", __func__, id, stream); + role = af_get_stream_role(id, stream); + TRACE(3, "[%s] id = %d, stream = %d", __func__, id, stream); - af_lock_thread(); + af_lock_thread(); - //check stream is stop and not close. - if(role->ctl.status != (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE)) - { - TRACE(2,"[%s] ERROR: status = %d",__func__, role->ctl.status); - ret = AF_RES_FAILD; - goto _exit; - } + // check stream is stop and not close. + if (role->ctl.status != + (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE)) { + TRACE(2, "[%s] ERROR: status = %d", __func__, role->ctl.status); + ret = AF_RES_FAILD; + goto _exit; + } - device = role->ctl.use_device; + device = role->ctl.use_device; - memset(role->dma_buf_ptr, 0, role->dma_buf_size); - hal_audma_free_chan(role->dma_cfg.ch); + memset(role->dma_buf_ptr, 0, role->dma_buf_size); + hal_audma_free_chan(role->dma_cfg.ch); - // TODO: more parameter should be set!!! -// memset(role, 0xff, sizeof(struct af_stream_cfg_t)); - role->handler = NULL; - role->ctl.pp_index = PP_PING; - role->ctl.use_device = AUD_STREAM_USE_DEVICE_NULL; - role->dma_buf_ptr = NULL; - role->dma_buf_size = 0; + // TODO: more parameter should be set!!! + // memset(role, 0xff, sizeof(struct af_stream_cfg_t)); + role->handler = NULL; + role->ctl.pp_index = PP_PING; + role->ctl.use_device = AUD_STREAM_USE_DEVICE_NULL; + role->dma_buf_ptr = NULL; + role->dma_buf_size = 0; - role->dma_cfg.ch = HAL_DMA_CHAN_NONE; + role->dma_cfg.ch = HAL_DMA_CHAN_NONE; - if(0) - { - } + if (0) { + } #ifdef AF_DEVICE_EXT_CODEC - else if(device == AUD_STREAM_USE_EXT_CODEC) - { - AF_TRACE_DEBUG(); - tlv32aic32_stream_close(stream); - } + else if (device == AUD_STREAM_USE_EXT_CODEC) { + AF_TRACE_DEBUG(); + tlv32aic32_stream_close(stream); + } #endif #ifdef AF_DEVICE_I2S - else if(device == AUD_STREAM_USE_I2S0_MASTER || device == AUD_STREAM_USE_I2S0_SLAVE) - { - AF_TRACE_DEBUG(); - hal_i2s_close(HAL_I2S_ID_0, stream); - } + else if (device == AUD_STREAM_USE_I2S0_MASTER || + device == AUD_STREAM_USE_I2S0_SLAVE) { + AF_TRACE_DEBUG(); + hal_i2s_close(HAL_I2S_ID_0, stream); + } #if defined(CHIP_HAS_I2S) && (CHIP_HAS_I2S > 1) - else if(device == AUD_STREAM_USE_I2S1_MASTER || device == AUD_STREAM_USE_I2S1_SLAVE) - { - AF_TRACE_DEBUG(); - hal_i2s_close(HAL_I2S_ID_1, stream); - } + else if (device == AUD_STREAM_USE_I2S1_MASTER || + device == AUD_STREAM_USE_I2S1_SLAVE) { + AF_TRACE_DEBUG(); + hal_i2s_close(HAL_I2S_ID_1, stream); + } #endif #endif #ifdef AF_DEVICE_TDM - else if(device == AUD_STREAM_USE_TDM0_MASTER || device == AUD_STREAM_USE_TDM0_SLAVE) - { - AF_TRACE_DEBUG(); - hal_tdm_close(HAL_I2S_ID_0, stream); - } + else if (device == AUD_STREAM_USE_TDM0_MASTER || + device == AUD_STREAM_USE_TDM0_SLAVE) { + AF_TRACE_DEBUG(); + hal_tdm_close(HAL_I2S_ID_0, stream); + } #if defined(CHIP_HAS_I2S) && (CHIP_HAS_I2S > 1) - else if(device == AUD_STREAM_USE_TDM1_MASTER || device == AUD_STREAM_USE_TDM1_SLAVE) - { - AF_TRACE_DEBUG(); - hal_tdm_close(HAL_I2S_ID_1, stream); - } + else if (device == AUD_STREAM_USE_TDM1_MASTER || + device == AUD_STREAM_USE_TDM1_SLAVE) { + AF_TRACE_DEBUG(); + hal_tdm_close(HAL_I2S_ID_1, stream); + } #endif #endif #ifdef AF_DEVICE_INT_CODEC - else if(device == AUD_STREAM_USE_INT_CODEC) - { - AF_TRACE_DEBUG(); - codec_int_stream_close(stream); - codec_int_close(CODEC_CLOSE_NORMAL); - } + else if (device == AUD_STREAM_USE_INT_CODEC) { + AF_TRACE_DEBUG(); + codec_int_stream_close(stream); + codec_int_close(CODEC_CLOSE_NORMAL); + } #endif #ifdef AF_DEVICE_SPDIF - else if(device == AUD_STREAM_USE_INT_SPDIF) - { - AF_TRACE_DEBUG(); - hal_spdif_close(AF_SPDIF_INST, stream); - } + else if (device == AUD_STREAM_USE_INT_SPDIF) { + AF_TRACE_DEBUG(); + hal_spdif_close(AF_SPDIF_INST, stream); + } #endif #ifdef AF_DEVICE_BT_PCM - else if(device == AUD_STREAM_USE_BT_PCM) - { - AF_TRACE_DEBUG(); - hal_btpcm_close(AF_BTPCM_INST, stream); - } + else if (device == AUD_STREAM_USE_BT_PCM) { + AF_TRACE_DEBUG(); + hal_btpcm_close(AF_BTPCM_INST, stream); + } #endif #ifdef AF_DEVICE_DPD_RX - else if(device == AUD_STREAM_USE_DPD_RX) - { - AF_TRACE_DEBUG(); - } + else if (device == AUD_STREAM_USE_DPD_RX) { + AF_TRACE_DEBUG(); + } #endif #ifdef AUDIO_ANC_FB_MC - else if(device == AUD_STREAM_USE_MC) - { - AF_TRACE_DEBUG(); - } -#endif - else - { - ASSERT(0, "[%s] ERROR: device %d is not defined!", __func__, device); - } - + else if (device == AUD_STREAM_USE_MC) { AF_TRACE_DEBUG(); - af_clear_status(id, stream, AF_STATUS_STREAM_OPEN_CLOSE); + } +#endif + else { + ASSERT(0, "[%s] ERROR: device %d is not defined!", __func__, device); + } + + AF_TRACE_DEBUG(); + af_clear_status(id, stream, AF_STATUS_STREAM_OPEN_CLOSE); #ifndef RTOS - af_clear_flag(&af_flag_open, 1 << (id * 2 + stream)); - if (af_flag_open == 0) { - hal_cpu_wake_unlock(AF_CPU_WAKE_USER); - } + af_clear_flag(&af_flag_open, 1 << (id * 2 + stream)); + if (af_flag_open == 0) { + hal_cpu_wake_unlock(AF_CPU_WAKE_USER); + } #endif - ret = AF_RES_SUCCESS; + ret = AF_RES_SUCCESS; _exit: - af_unlock_thread(); + af_unlock_thread(); - return ret; + return ret; } -uint32_t af_close(void) -{ - struct af_stream_cfg_t *role; +uint32_t af_close(void) { + struct af_stream_cfg_t *role; - // Avoid blocking shutdown process - //af_lock_thread(); + // Avoid blocking shutdown process + // af_lock_thread(); - for (uint8_t id=0; id < AUD_STREAM_ID_NUM; id++) - { - for (uint8_t stream=0; stream < AUD_STREAM_NUM; stream++) - { - role = af_get_stream_role((enum AUD_STREAM_ID_T)id, (enum AUD_STREAM_T)stream); - role->ctl.status = AF_STATUS_NULL; + for (uint8_t id = 0; id < AUD_STREAM_ID_NUM; id++) { + for (uint8_t stream = 0; stream < AUD_STREAM_NUM; stream++) { + role = af_get_stream_role((enum AUD_STREAM_ID_T)id, + (enum AUD_STREAM_T)stream); + role->ctl.status = AF_STATUS_NULL; + } + } + + codec_int_close(CODEC_CLOSE_FORCED); + + // af_unlock_thread(); + + return AF_RES_SUCCESS; +} + +uint32_t af_stream_get_cur_dma_addr(enum AUD_STREAM_ID_T id, + enum AUD_STREAM_T stream) { + struct af_stream_cfg_t *role; + int i; + uint32_t addr = 0; + + role = af_get_stream_role(id, stream); + + // check stream is start and not stop + if (role->ctl.status == (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE | + AF_STATUS_STREAM_START_STOP)) { + if (role->dma_cfg.ch != HAL_DMA_CHAN_NONE) { + for (i = 0; i < 2; i++) { + if (stream == AUD_STREAM_PLAYBACK) { + addr = hal_audma_get_cur_src_addr(role->dma_cfg.ch); + } else { + addr = hal_audma_get_cur_dst_addr(role->dma_cfg.ch); } - } - - codec_int_close(CODEC_CLOSE_FORCED); - - //af_unlock_thread(); - - return AF_RES_SUCCESS; -} - -uint32_t af_stream_get_cur_dma_addr(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) -{ - struct af_stream_cfg_t *role; - int i; - uint32_t addr = 0; - - role = af_get_stream_role(id, stream); - - //check stream is start and not stop - if (role->ctl.status == (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE | AF_STATUS_STREAM_START_STOP)) { - if (role->dma_cfg.ch != HAL_DMA_CHAN_NONE) { - for (i = 0; i < 2; i++) { - if (stream == AUD_STREAM_PLAYBACK) { - addr = hal_audma_get_cur_src_addr(role->dma_cfg.ch); - } else { - addr = hal_audma_get_cur_dst_addr(role->dma_cfg.ch); - } - if (addr) { - break; - } - // Previous link list item was just finished. Read current DMA address again. - } + if (addr) { + break; } + // Previous link list item was just finished. Read current DMA address + // again. + } } + } - return addr; + return addr; } -int af_stream_get_cur_dma_pos(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) -{ - struct af_stream_cfg_t *role; - uint32_t addr; - int pos; +int af_stream_get_cur_dma_pos(enum AUD_STREAM_ID_T id, + enum AUD_STREAM_T stream) { + struct af_stream_cfg_t *role; + uint32_t addr; + int pos; - role = af_get_stream_role(id, stream); + role = af_get_stream_role(id, stream); - addr = af_stream_get_cur_dma_addr(id, stream); + addr = af_stream_get_cur_dma_addr(id, stream); - pos = addr - (uint32_t)role->dma_buf_ptr; + pos = addr - (uint32_t)role->dma_buf_ptr; - if (pos < 0 || pos > role->dma_buf_size) { - return -1; - } + if (pos < 0 || pos > role->dma_buf_size) { + return -1; + } #ifndef CHIP_BEST1000 - if (role->cfg.chan_sep_buf && role->cfg.channel_num > AUD_CHANNEL_NUM_1) { - uint32_t chan_size; - uint8_t chan_idx; - uint8_t desc_idx; - uint16_t chan_desc_offset; - uint16_t chan_desc_xfer_size; - uint32_t chan_offset; + if (role->cfg.chan_sep_buf && role->cfg.channel_num > AUD_CHANNEL_NUM_1) { + uint32_t chan_size; + uint8_t chan_idx; + uint8_t desc_idx; + uint16_t chan_desc_offset; + uint16_t chan_desc_xfer_size; + uint32_t chan_offset; - chan_size = role->dma_buf_size / role->cfg.channel_num; - chan_desc_xfer_size = chan_size / AUDIO_BUFFER_COUNT; + chan_size = role->dma_buf_size / role->cfg.channel_num; + chan_desc_xfer_size = chan_size / AUDIO_BUFFER_COUNT; - chan_idx = pos / chan_size; - chan_offset = pos % chan_size; - desc_idx = chan_offset / chan_desc_xfer_size; - chan_desc_offset = chan_offset % chan_desc_xfer_size; + chan_idx = pos / chan_size; + chan_offset = pos % chan_size; + desc_idx = chan_offset / chan_desc_xfer_size; + chan_desc_offset = chan_offset % chan_desc_xfer_size; - pos = desc_idx * (role->dma_buf_size / AUDIO_BUFFER_COUNT) + chan_idx * chan_desc_xfer_size + chan_desc_offset; - } + pos = desc_idx * (role->dma_buf_size / AUDIO_BUFFER_COUNT) + + chan_idx * chan_desc_xfer_size + chan_desc_offset; + } #endif - return pos; + return pos; } -int af_stream_buffer_error(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) -{ - return af_sig_lost_cnt[id][stream]; +int af_stream_buffer_error(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) { + return af_sig_lost_cnt[id][stream]; } -uint32_t af_stream_dma_tc_irq_enable(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) -{ - struct af_stream_cfg_t *role; +uint32_t af_stream_dma_tc_irq_enable(enum AUD_STREAM_ID_T id, + enum AUD_STREAM_T stream) { + struct af_stream_cfg_t *role; - role = af_get_stream_role(id, stream); + role = af_get_stream_role(id, stream); - // Check if opened - if ((role->ctl.status & (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE)) == - (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE)) { - hal_dma_tc_irq_enable(role->dma_cfg.ch); - return AF_RES_SUCCESS; - } + // Check if opened + if ((role->ctl.status & + (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE)) == + (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE)) { + hal_dma_tc_irq_enable(role->dma_cfg.ch); + return AF_RES_SUCCESS; + } - return AF_RES_FAILD; + return AF_RES_FAILD; } -uint32_t af_stream_dma_tc_irq_disable(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) -{ - struct af_stream_cfg_t *role; +uint32_t af_stream_dma_tc_irq_disable(enum AUD_STREAM_ID_T id, + enum AUD_STREAM_T stream) { + struct af_stream_cfg_t *role; - role = af_get_stream_role(id, stream); + role = af_get_stream_role(id, stream); - // Check if opened - if ((role->ctl.status & (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE)) == - (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE)) { - hal_dma_tc_irq_disable(role->dma_cfg.ch); - return AF_RES_SUCCESS; - } + // Check if opened + if ((role->ctl.status & + (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE)) == + (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE)) { + hal_dma_tc_irq_disable(role->dma_cfg.ch); + return AF_RES_SUCCESS; + } - return AF_RES_FAILD; + return AF_RES_FAILD; } #ifdef RTOS -void af_set_irq_notification(AF_IRQ_NOTIFICATION_T notif) -{ - irq_notif = notif; -} +void af_set_irq_notification(AF_IRQ_NOTIFICATION_T notif) { irq_notif = notif; } static int af_priority[AF_USER_NUM]; -void af_set_priority(AF_USER_E user, int priority) -{ - uint8_t i = 0; - int max_priority = 0; - af_priority[user] = priority; +void af_set_priority(AF_USER_E user, int priority) { + uint8_t i = 0; + int max_priority = 0; + af_priority[user] = priority; - for (i=0; ictl.status & AF_STATUS_STREAM_OPEN_CLOSE) { - if (role->cfg.device == AUD_STREAM_USE_INT_CODEC && role->dma_cfg.dst_periph == HAL_AUDMA_CODEC_TX) { - ASSERT(role->ctl.status == (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE), - "Bad stream status when DSD enabled: 0x%X", role->ctl.status); - role->dma_cfg.dst_periph = HAL_AUDMA_DSD_TX; - af_stream_update_dma_buffer(AUD_STREAM_PLAYBACK, role, &role->cfg); - opened = true; - break; - } - } + for (id = AUD_STREAM_ID_0; id < AUD_STREAM_ID_NUM; id++) { + role = af_get_stream_role(id, AUD_STREAM_PLAYBACK); + if (role->ctl.status & AF_STATUS_STREAM_OPEN_CLOSE) { + if (role->cfg.device == AUD_STREAM_USE_INT_CODEC && + role->dma_cfg.dst_periph == HAL_AUDMA_CODEC_TX) { + ASSERT(role->ctl.status == + (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE), + "Bad stream status when DSD enabled: 0x%X", role->ctl.status); + role->dma_cfg.dst_periph = HAL_AUDMA_DSD_TX; + af_stream_update_dma_buffer(AUD_STREAM_PLAYBACK, role, &role->cfg); + opened = true; + break; + } } + } - hal_codec_dsd_enable(); - af_dsd_enabled = true; + hal_codec_dsd_enable(); + af_dsd_enabled = true; - af_unlock_thread(); + af_unlock_thread(); - if (opened) { - // Enable DSD sample rate handling - af_stream_setup(id, AUD_STREAM_PLAYBACK, &role->cfg); - } + if (opened) { + // Enable DSD sample rate handling + af_stream_setup(id, AUD_STREAM_PLAYBACK, &role->cfg); + } } -void af_dsd_disable(void) -{ - enum AUD_STREAM_ID_T id; - struct af_stream_cfg_t *role; - bool opened = false; +void af_dsd_disable(void) { + enum AUD_STREAM_ID_T id; + struct af_stream_cfg_t *role; + bool opened = false; - af_lock_thread(); + af_lock_thread(); - for (id = AUD_STREAM_ID_0; id < AUD_STREAM_ID_NUM; id++) { - role = af_get_stream_role(id, AUD_STREAM_PLAYBACK); - if (role->ctl.status & AF_STATUS_STREAM_OPEN_CLOSE) { - if (role->cfg.device == AUD_STREAM_USE_INT_CODEC && role->dma_cfg.dst_periph == HAL_AUDMA_DSD_TX) { - ASSERT(role->ctl.status == (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE), - "Bad stream status when DSD disabled: 0x%X", role->ctl.status); - role->dma_cfg.dst_periph = HAL_AUDMA_CODEC_TX; - af_stream_update_dma_buffer(AUD_STREAM_PLAYBACK, role, &role->cfg); - opened = true; - break; - } - } + for (id = AUD_STREAM_ID_0; id < AUD_STREAM_ID_NUM; id++) { + role = af_get_stream_role(id, AUD_STREAM_PLAYBACK); + if (role->ctl.status & AF_STATUS_STREAM_OPEN_CLOSE) { + if (role->cfg.device == AUD_STREAM_USE_INT_CODEC && + role->dma_cfg.dst_periph == HAL_AUDMA_DSD_TX) { + ASSERT(role->ctl.status == + (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE), + "Bad stream status when DSD disabled: 0x%X", role->ctl.status); + role->dma_cfg.dst_periph = HAL_AUDMA_CODEC_TX; + af_stream_update_dma_buffer(AUD_STREAM_PLAYBACK, role, &role->cfg); + opened = true; + break; + } } + } - hal_codec_dsd_disable(); - af_dsd_enabled = false; + hal_codec_dsd_disable(); + af_dsd_enabled = false; - af_unlock_thread(); + af_unlock_thread(); - if (opened) { - // Disable DSD sample rate handling - af_stream_setup(id, AUD_STREAM_PLAYBACK, &role->cfg); - } + if (opened) { + // Disable DSD sample rate handling + af_stream_setup(id, AUD_STREAM_PLAYBACK, &role->cfg); + } } #endif #ifdef __RAND_FROM_MIC__ - uint8_t random_mic_is_on(uint8_t *deviceId) - { - struct af_stream_cfg_t *role = NULL; +uint8_t random_mic_is_on(uint8_t *deviceId) { + struct af_stream_cfg_t *role = NULL; - *deviceId = 0; + *deviceId = 0; - for(uint8_t id=0; id< AUD_STREAM_ID_NUM; id++) - { - role = af_get_stream_role((enum AUD_STREAM_ID_T)id, AUD_STREAM_CAPTURE); - if (role->cfg.device == AUD_STREAM_USE_INT_CODEC && - role->ctl.status == (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE | AF_STATUS_STREAM_START_STOP)) { - return RAND_STATUS_MIC_STARTED; - } - else if (role->cfg.device == AUD_STREAM_USE_INT_CODEC && - role->ctl.status == (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE)) - { - *deviceId = id; - return RAND_STATUS_MIC_OPENED; - } - } - - return RAND_STATUS_CLOSE; + for (uint8_t id = 0; id < AUD_STREAM_ID_NUM; id++) { + role = af_get_stream_role((enum AUD_STREAM_ID_T)id, AUD_STREAM_CAPTURE); + if (role->cfg.device == AUD_STREAM_USE_INT_CODEC && + role->ctl.status == + (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE | + AF_STATUS_STREAM_START_STOP)) { + return RAND_STATUS_MIC_STARTED; + } else if (role->cfg.device == AUD_STREAM_USE_INT_CODEC && + role->ctl.status == + (AF_STATUS_OPEN_CLOSE | AF_STATUS_STREAM_OPEN_CLOSE)) { + *deviceId = id; + return RAND_STATUS_MIC_OPENED; } -#endif + } + return RAND_STATUS_CLOSE; +} +#endif diff --git a/services/auto_test/at_thread.cpp b/services/auto_test/at_thread.cpp index d61ea4f..4c6d969 100644 --- a/services/auto_test/at_thread.cpp +++ b/services/auto_test/at_thread.cpp @@ -13,125 +13,113 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "at_thread.h" #include "cmsis_os.h" #include "hal_trace.h" -#include "at_thread.h" static void at_thread(void const *argument); osThreadDef(at_thread, osPriorityNormal, 1, 1024, "AT_cmd"); -osMailQDef (at_mailbox, AT_MAILBOX_MAX, AT_MESSAGE); +osMailQDef(at_mailbox, AT_MAILBOX_MAX, AT_MESSAGE); static osMailQId at_mailbox = NULL; static uint8_t at_mailbox_cnt = 0; #define AT_DEBUG TRACE -static int at_mailbox_init(void) -{ - AT_DEBUG("%s,%d",__func__,__LINE__); - at_mailbox = osMailCreate(osMailQ(at_mailbox), NULL); - if (at_mailbox == NULL) { - AT_DEBUG("Failed to Create at_mailbox\n"); - return -1; - } - at_mailbox_cnt = 0; - return 0; +static int at_mailbox_init(void) { + AT_DEBUG("%s,%d", __func__, __LINE__); + at_mailbox = osMailCreate(osMailQ(at_mailbox), NULL); + if (at_mailbox == NULL) { + AT_DEBUG("Failed to Create at_mailbox\n"); + return -1; + } + at_mailbox_cnt = 0; + return 0; } -static int at_mailbox_put(AT_MESSAGE* msg_src) -{ - osStatus status; - AT_MESSAGE *msg_p = NULL; +static int at_mailbox_put(AT_MESSAGE *msg_src) { + osStatus status; + AT_MESSAGE *msg_p = NULL; - AT_DEBUG("%s,%d",__func__,__LINE__); - if(at_mailbox_cnt >= 1) - { - AT_DEBUG("%s,%d at_mailbox_cnt = %d.", - __func__,__LINE__,at_mailbox_cnt); - return 0; + AT_DEBUG("%s,%d", __func__, __LINE__); + if (at_mailbox_cnt >= 1) { + AT_DEBUG("%s,%d at_mailbox_cnt = %d.", __func__, __LINE__, at_mailbox_cnt); + return 0; + } + msg_p = (AT_MESSAGE *)osMailAlloc(at_mailbox, 0); + ASSERT(msg_p, "osMailAlloc error"); + msg_p->id = msg_src->id; + msg_p->ptr = msg_src->ptr; + msg_p->param0 = msg_src->param0; + msg_p->param1 = msg_src->param1; + + status = osMailPut(at_mailbox, msg_p); + if (osOK == status) + at_mailbox_cnt++; + AT_DEBUG("%s,%d,at_mailbox_cnt = %d.", __func__, __LINE__, at_mailbox_cnt); + return (int)status; +} + +static int at_mailbox_free(AT_MESSAGE *msg_p) { + osStatus status; + + AT_DEBUG("%s,%d", __func__, __LINE__); + status = osMailFree(at_mailbox, msg_p); + if (osOK == status) + at_mailbox_cnt--; + AT_DEBUG("%s,%d,at_mailbox_cnt = %d.", __func__, __LINE__, at_mailbox_cnt); + return (int)status; +} + +static int at_mailbox_get(AT_MESSAGE **msg_p) { + osEvent evt; + evt = osMailGet(at_mailbox, osWaitForever); + if (evt.status == osEventMail) { + *msg_p = (AT_MESSAGE *)evt.value.p; + return 0; + } + return -1; +} + +static void at_thread(void const *argument) { + AT_FUNC_T pfunc; + // USB_FUNC_T usb_funcp; + AT_DEBUG("%s,%d", __func__, __LINE__); + while (1) { + AT_MESSAGE *msg_p = NULL; + if (!at_mailbox_get(&msg_p)) { + AT_DEBUG("_debug: %s,%d", __func__, __LINE__); + AT_DEBUG("at_thread: id = 0x%x, ptr = 0x%x,param0 = 0x%x,param1 = 0x%x.", + msg_p->id, msg_p->ptr, msg_p->param0, msg_p->param1); + pfunc = (AT_FUNC_T)msg_p->ptr; + pfunc(msg_p->param0, msg_p->param1); + at_mailbox_free(msg_p); } - msg_p = (AT_MESSAGE*)osMailAlloc(at_mailbox, 0); - ASSERT(msg_p, "osMailAlloc error"); - msg_p->id = msg_src->id; - msg_p->ptr = msg_src->ptr; - msg_p->param0 = msg_src->param0; - msg_p->param1 = msg_src->param1; - - status = osMailPut(at_mailbox, msg_p); - if (osOK == status) - at_mailbox_cnt++; - AT_DEBUG("%s,%d,at_mailbox_cnt = %d.",__func__,__LINE__,at_mailbox_cnt); - return (int)status; + } } -static int at_mailbox_free(AT_MESSAGE* msg_p) -{ - osStatus status; +int at_os_init(void) { + osThreadId at_tid; - AT_DEBUG("%s,%d",__func__,__LINE__); - status = osMailFree(at_mailbox, msg_p); - if (osOK == status) - at_mailbox_cnt--; - AT_DEBUG("%s,%d,at_mailbox_cnt = %d.",__func__,__LINE__,at_mailbox_cnt); - return (int)status; + AT_DEBUG("%s,%d", __func__, __LINE__); + if (at_mailbox_init()) { + AT_DEBUG("_debug: %s,%d", __func__, __LINE__); + return -1; + } + at_tid = osThreadCreate(osThread(at_thread), NULL); + if (at_tid == NULL) { + AT_DEBUG("Failed to Create at_thread\n"); + return -2; + } + return 0; } -static int at_mailbox_get(AT_MESSAGE **msg_p) -{ - osEvent evt; - evt = osMailGet(at_mailbox, osWaitForever); - if (evt.status == osEventMail) { - *msg_p = (AT_MESSAGE*)evt.value.p; - return 0; - } - return -1; +int at_enqueue_cmd(uint32_t cmd_id, uint32_t param, uint32_t pfunc) { + AT_MESSAGE at_msg; + int32_t ret; + + at_msg.id = AT_MESSAGE_ID_CMD; + at_msg.param0 = param; + at_msg.param1 = cmd_id; + at_msg.ptr = pfunc; + ret = at_mailbox_put(&at_msg); + return ret; } - -static void at_thread(void const *argument) -{ - AT_FUNC_T pfunc; - // USB_FUNC_T usb_funcp; - AT_DEBUG("%s,%d",__func__,__LINE__); - while(1){ - AT_MESSAGE *msg_p = NULL; - if (!at_mailbox_get(&msg_p)) { - AT_DEBUG("_debug: %s,%d",__func__,__LINE__); - AT_DEBUG("at_thread: id = 0x%x, ptr = 0x%x,param0 = 0x%x,param1 = 0x%x.", - msg_p->id,msg_p->ptr,msg_p->param0,msg_p->param1); - pfunc = (AT_FUNC_T)msg_p->ptr; - pfunc(msg_p->param0,msg_p->param1); - at_mailbox_free(msg_p); - } - } -} - -int at_os_init(void) -{ - osThreadId at_tid; - - AT_DEBUG("%s,%d",__func__,__LINE__); - if (at_mailbox_init()) { - AT_DEBUG("_debug: %s,%d",__func__,__LINE__); - return -1; - } - at_tid = osThreadCreate(osThread(at_thread), NULL); - if (at_tid == NULL) { - AT_DEBUG("Failed to Create at_thread\n"); - return -2; - } - return 0; -} - -int at_enqueue_cmd(uint32_t cmd_id, uint32_t param,uint32_t pfunc) -{ - AT_MESSAGE at_msg; - int32_t ret; - - at_msg.id = AT_MESSAGE_ID_CMD; - at_msg.param0 = param; - at_msg.param1 = cmd_id; - at_msg.ptr = pfunc; - ret = at_mailbox_put(&at_msg); - return ret; -} - - - diff --git a/services/auto_test/at_thread_user.cpp b/services/auto_test/at_thread_user.cpp index 5793430..b754bad 100644 --- a/services/auto_test/at_thread_user.cpp +++ b/services/auto_test/at_thread_user.cpp @@ -13,263 +13,260 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "at_thread_user.h" +#include "at_thread.h" #include "cmsis_os.h" #include "hal_trace.h" -#include "at_thread.h" -#include "at_thread_user.h" #if 1 -#define AT_THREAD_TRACE TRACE +#define AT_THREAD_TRACE TRACE #else -#define AT_THREAD_TRACE(str,...) +#define AT_THREAD_TRACE(str, ...) #endif -//static osThreadId at_tid_user1 = NULL; +// static osThreadId at_tid_user1 = NULL; static void at_thread_user0(void const *argument); static void at_thread_user1(void const *argument); static void at_thread_user2(void const *argument); static void at_thread_user3(void const *argument); static void at_thread_user4(void const *argument); -//static osMailQId at_mailbox_user0 = NULL; -//static osMailQId at_mailbox_user1 = NULL; -//static osMailQId at_mailbox_user2 = NULL; -//static osMailQId at_mailbox_user3 = NULL; -//static osMailQId at_mailbox_user4 = NULL; +// static osMailQId at_mailbox_user0 = NULL; +// static osMailQId at_mailbox_user1 = NULL; +// static osMailQId at_mailbox_user2 = NULL; +// static osMailQId at_mailbox_user3 = NULL; +// static osMailQId at_mailbox_user4 = NULL; osThreadDef(at_thread_user0, osPriorityLow, 1, 1024, "at_user0"); -osMailQDef (at_mailbox_user0, AT_MAILBOX_MAX, AT_USER_MESSAGE); +osMailQDef(at_mailbox_user0, AT_MAILBOX_MAX, AT_USER_MESSAGE); osThreadDef(at_thread_user1, osPriorityLow, 1, 1024, "at_user1"); -osMailQDef (at_mailbox_user1, AT_MAILBOX_MAX, AT_USER_MESSAGE); +osMailQDef(at_mailbox_user1, AT_MAILBOX_MAX, AT_USER_MESSAGE); osThreadDef(at_thread_user2, osPriorityLow, 1, 1024, "at_user2"); -osMailQDef (at_mailbox_user2, AT_MAILBOX_MAX, AT_USER_MESSAGE); +osMailQDef(at_mailbox_user2, AT_MAILBOX_MAX, AT_USER_MESSAGE); osThreadDef(at_thread_user3, osPriorityNormal, 1, 512, "at_user3"); -osMailQDef (at_mailbox_user3, AT_MAILBOX_MAX, AT_USER_MESSAGE); +osMailQDef(at_mailbox_user3, AT_MAILBOX_MAX, AT_USER_MESSAGE); osThreadDef(at_thread_user4, osPriorityNormal, 1, 512, "at user4"); -osMailQDef (at_mailbox_user4, AT_MAILBOX_MAX, AT_USER_MESSAGE); +osMailQDef(at_mailbox_user4, AT_MAILBOX_MAX, AT_USER_MESSAGE); -typedef struct{ - bool is_inited; - osMailQId mid; - osThreadId til; - uint32_t mail_count; -}AT_TREAD_INFO; +typedef struct { + bool is_inited; + osMailQId mid; + osThreadId til; + uint32_t mail_count; +} AT_TREAD_INFO; -AT_TREAD_INFO at_thread_info[THREAD_USER_COUNT] = - { - {false,NULL,NULL,0}, - {false,NULL,NULL,0}, - {false,NULL,NULL,0}, - {false,NULL,NULL,0}, - {false,NULL,NULL,0}, - }; +AT_TREAD_INFO at_thread_info[THREAD_USER_COUNT] = { + {false, NULL, NULL, 0}, {false, NULL, NULL, 0}, {false, NULL, NULL, 0}, + {false, NULL, NULL, 0}, {false, NULL, NULL, 0}, +}; -static int at_mailbox_user_put(enum THREAD_USER_ID user_id,AT_MESSAGE* msg_src) -{ - osStatus status; - AT_MESSAGE *msg_p = NULL; +static int at_mailbox_user_put(enum THREAD_USER_ID user_id, + AT_MESSAGE *msg_src) { + osStatus status; + AT_MESSAGE *msg_p = NULL; - AT_THREAD_TRACE(3,"%s,%d,user_id = %d.",__func__,__LINE__,user_id); - if(at_thread_info[user_id].mail_count >= 1) - { - AT_THREAD_TRACE(3,"%s,%d mail_count = %d.", - __func__,__LINE__,at_thread_info[user_id].mail_count); - return 0; + AT_THREAD_TRACE(3, "%s,%d,user_id = %d.", __func__, __LINE__, user_id); + if (at_thread_info[user_id].mail_count >= 1) { + AT_THREAD_TRACE(3, "%s,%d mail_count = %d.", __func__, __LINE__, + at_thread_info[user_id].mail_count); + return 0; + } + msg_p = (AT_MESSAGE *)osMailAlloc(at_thread_info[user_id].mid, 0); + ASSERT(msg_p, "osMailAlloc error"); + msg_p->id = msg_src->id; + msg_p->ptr = msg_src->ptr; + msg_p->param0 = msg_src->param0; + msg_p->param1 = msg_src->param1; + + status = osMailPut(at_thread_info[user_id].mid, msg_p); + if (osOK == status) + at_thread_info[user_id].mail_count++; + AT_THREAD_TRACE(3, "%s,%d,at_mailbox_cnt = %d.", __func__, __LINE__, + at_thread_info[user_id].mail_count); + return (int)status; +} + +static int at_mailbox_user_free(enum THREAD_USER_ID user_id, + AT_MESSAGE *msg_p) { + osStatus status; + + AT_THREAD_TRACE(3, "%s,%d,user_id = %d.", __func__, __LINE__, user_id); + status = osMailFree(at_thread_info[user_id].mid, msg_p); + if (osOK == status) + at_thread_info[user_id].mail_count--; + AT_THREAD_TRACE(3, "%s,%d,at_mailbox_cnt = %d.", __func__, __LINE__, + at_thread_info[user_id].mail_count); + return (int)status; +} + +static int at_mailbox_user_get(enum THREAD_USER_ID user_id, + AT_MESSAGE **msg_p) { + osEvent evt; + evt = osMailGet(at_thread_info[user_id].mid, osWaitForever); + if (evt.status == osEventMail) { + *msg_p = (AT_MESSAGE *)evt.value.p; + return 0; + } + return -1; +} + +static void at_thread_user0(const void *argument) { + AT_FUNC_T pfunc; + // enum THREAD_USER_ID user_id = THREAD_USER_COUNT; + // uint32_t arg; + + AT_THREAD_TRACE(2, "%s,%d.", __func__, __LINE__); + // arg = (uint32_t)argument; + + // AT_THREAD_TRACE(3,"%s,%d,user_id = %d.",__func__,__LINE__,user_id); + while (1) { + AT_THREAD_TRACE(2, "%s,%d.", __func__, __LINE__); + AT_MESSAGE *msg_p = NULL; + if (!at_mailbox_user_get(THREAD_USER0, &msg_p)) { + AT_THREAD_TRACE(2, "_debug: %s,%d", __func__, __LINE__); + AT_THREAD_TRACE( + 4, + "at_thread_user1: id = 0x%x, ptr = 0x%x,param0 = 0x%x,param1 = 0x%x.", + msg_p->id, msg_p->ptr, msg_p->param0, msg_p->param1); + pfunc = (AT_FUNC_T)msg_p->ptr; + pfunc(msg_p->param0, msg_p->param1); + at_mailbox_user_free(THREAD_USER0, msg_p); } - msg_p = (AT_MESSAGE*)osMailAlloc(at_thread_info[user_id].mid, 0); - ASSERT(msg_p, "osMailAlloc error"); - msg_p->id = msg_src->id; - msg_p->ptr = msg_src->ptr; - msg_p->param0 = msg_src->param0; - msg_p->param1 = msg_src->param1; - - status = osMailPut(at_thread_info[user_id].mid, msg_p); - if (osOK == status) - at_thread_info[user_id].mail_count ++; - AT_THREAD_TRACE(3,"%s,%d,at_mailbox_cnt = %d.",__func__,__LINE__,at_thread_info[user_id].mail_count); - return (int)status; + AT_THREAD_TRACE(2, "%s,%d.", __func__, __LINE__); + } } -static int at_mailbox_user_free(enum THREAD_USER_ID user_id,AT_MESSAGE* msg_p) -{ - osStatus status; +static void at_thread_user1(void const *argument) { + AT_FUNC_T pfunc; - AT_THREAD_TRACE(3,"%s,%d,user_id = %d.",__func__,__LINE__,user_id); - status = osMailFree(at_thread_info[user_id].mid, msg_p); - if (osOK == status) - at_thread_info[user_id].mail_count --; - AT_THREAD_TRACE(3,"%s,%d,at_mailbox_cnt = %d.",__func__,__LINE__,at_thread_info[user_id].mail_count); - return (int)status; -} - -static int at_mailbox_user_get(enum THREAD_USER_ID user_id,AT_MESSAGE **msg_p) -{ - osEvent evt; - evt = osMailGet(at_thread_info[user_id].mid, osWaitForever); - if (evt.status == osEventMail) { - *msg_p = (AT_MESSAGE*)evt.value.p; - return 0; - } - return -1; -} - -static void at_thread_user0(const void *argument) -{ - AT_FUNC_T pfunc; - //enum THREAD_USER_ID user_id = THREAD_USER_COUNT; - //uint32_t arg; - - AT_THREAD_TRACE(2,"%s,%d.",__func__,__LINE__); - //arg = (uint32_t)argument; - - //AT_THREAD_TRACE(3,"%s,%d,user_id = %d.",__func__,__LINE__,user_id); - while(1){ - AT_THREAD_TRACE(2,"%s,%d.",__func__,__LINE__); - AT_MESSAGE *msg_p = NULL; - if (!at_mailbox_user_get(THREAD_USER0,&msg_p)) { - AT_THREAD_TRACE(2,"_debug: %s,%d",__func__,__LINE__); - AT_THREAD_TRACE(4,"at_thread_user1: id = 0x%x, ptr = 0x%x,param0 = 0x%x,param1 = 0x%x.", - msg_p->id,msg_p->ptr,msg_p->param0,msg_p->param1); - pfunc = (AT_FUNC_T)msg_p->ptr; - pfunc(msg_p->param0,msg_p->param1); - at_mailbox_user_free(THREAD_USER0,msg_p); - } - AT_THREAD_TRACE(2,"%s,%d.",__func__,__LINE__); - } -} - -static void at_thread_user1(void const *argument) -{ - AT_FUNC_T pfunc; - - AT_THREAD_TRACE(2,"%s,%d",__func__,__LINE__); - while(1){ - AT_MESSAGE *msg_p = NULL; - if (!at_mailbox_user_get(THREAD_USER1,&msg_p)) { - AT_THREAD_TRACE(2,"_debug: %s,%d",__func__,__LINE__); - AT_THREAD_TRACE(4,"at_thread_user1: id = 0x%x, ptr = 0x%x,param0 = 0x%x,param1 = 0x%x.", - msg_p->id,msg_p->ptr,msg_p->param0,msg_p->param1); - pfunc = (AT_FUNC_T)msg_p->ptr; - pfunc(msg_p->param0,msg_p->param1); - at_mailbox_user_free(THREAD_USER1,msg_p); - } - } + AT_THREAD_TRACE(2, "%s,%d", __func__, __LINE__); + while (1) { + AT_MESSAGE *msg_p = NULL; + if (!at_mailbox_user_get(THREAD_USER1, &msg_p)) { + AT_THREAD_TRACE(2, "_debug: %s,%d", __func__, __LINE__); + AT_THREAD_TRACE( + 4, + "at_thread_user1: id = 0x%x, ptr = 0x%x,param0 = 0x%x,param1 = 0x%x.", + msg_p->id, msg_p->ptr, msg_p->param0, msg_p->param1); + pfunc = (AT_FUNC_T)msg_p->ptr; + pfunc(msg_p->param0, msg_p->param1); + at_mailbox_user_free(THREAD_USER1, msg_p); + } + } } #if 1 -static void at_thread_user2(void const *argument) -{ - AT_FUNC_T pfunc; - AT_THREAD_TRACE(2,"%s,%d",__func__,__LINE__); - while(1){ - AT_MESSAGE *msg_p = NULL; - if (!at_mailbox_user_get(THREAD_USER2,&msg_p)) { - AT_THREAD_TRACE(2,"_debug: %s,%d",__func__,__LINE__); - AT_THREAD_TRACE(4,"at_thread_user1: id = 0x%x, ptr = 0x%x,param0 = 0x%x,param1 = 0x%x.", - msg_p->id,msg_p->ptr,msg_p->param0,msg_p->param1); - pfunc = (AT_FUNC_T)msg_p->ptr; - pfunc(msg_p->param0,msg_p->param1); - at_mailbox_user_free(THREAD_USER2,msg_p); - } - } +static void at_thread_user2(void const *argument) { + AT_FUNC_T pfunc; + AT_THREAD_TRACE(2, "%s,%d", __func__, __LINE__); + while (1) { + AT_MESSAGE *msg_p = NULL; + if (!at_mailbox_user_get(THREAD_USER2, &msg_p)) { + AT_THREAD_TRACE(2, "_debug: %s,%d", __func__, __LINE__); + AT_THREAD_TRACE( + 4, + "at_thread_user1: id = 0x%x, ptr = 0x%x,param0 = 0x%x,param1 = 0x%x.", + msg_p->id, msg_p->ptr, msg_p->param0, msg_p->param1); + pfunc = (AT_FUNC_T)msg_p->ptr; + pfunc(msg_p->param0, msg_p->param1); + at_mailbox_user_free(THREAD_USER2, msg_p); + } + } } -static void at_thread_user3(void const *argument) -{ - AT_FUNC_T pfunc; - AT_THREAD_TRACE(2,"%s,%d",__func__,__LINE__); - while(1){ - AT_MESSAGE *msg_p = NULL; - if (!at_mailbox_user_get(THREAD_USER3,&msg_p)) { - AT_THREAD_TRACE(2,"_debug: %s,%d",__func__,__LINE__); - AT_THREAD_TRACE(4,"at_thread_user1: id = 0x%x, ptr = 0x%x,param0 = 0x%x,param1 = 0x%x.", - msg_p->id,msg_p->ptr,msg_p->param0,msg_p->param1); - pfunc = (AT_FUNC_T)msg_p->ptr; - pfunc(msg_p->param0,msg_p->param1); - at_mailbox_user_free(THREAD_USER3,msg_p); - } - } +static void at_thread_user3(void const *argument) { + AT_FUNC_T pfunc; + AT_THREAD_TRACE(2, "%s,%d", __func__, __LINE__); + while (1) { + AT_MESSAGE *msg_p = NULL; + if (!at_mailbox_user_get(THREAD_USER3, &msg_p)) { + AT_THREAD_TRACE(2, "_debug: %s,%d", __func__, __LINE__); + AT_THREAD_TRACE( + 4, + "at_thread_user1: id = 0x%x, ptr = 0x%x,param0 = 0x%x,param1 = 0x%x.", + msg_p->id, msg_p->ptr, msg_p->param0, msg_p->param1); + pfunc = (AT_FUNC_T)msg_p->ptr; + pfunc(msg_p->param0, msg_p->param1); + at_mailbox_user_free(THREAD_USER3, msg_p); + } + } } -static void at_thread_user4(void const *argument) -{ - AT_FUNC_T pfunc; - AT_THREAD_TRACE(2,"%s,%d",__func__,__LINE__); - while(1){ - AT_MESSAGE *msg_p = NULL; - if (!at_mailbox_user_get(THREAD_USER4,&msg_p)) { - AT_THREAD_TRACE(2,"_debug: %s,%d",__func__,__LINE__); - AT_THREAD_TRACE(4,"at_thread_user1: id = 0x%x, ptr = 0x%x,param0 = 0x%x,param1 = 0x%x.", - msg_p->id,msg_p->ptr,msg_p->param0,msg_p->param1); - pfunc = (AT_FUNC_T)msg_p->ptr; - pfunc(msg_p->param0,msg_p->param1); - at_mailbox_user_free(THREAD_USER4,msg_p); - } - } +static void at_thread_user4(void const *argument) { + AT_FUNC_T pfunc; + AT_THREAD_TRACE(2, "%s,%d", __func__, __LINE__); + while (1) { + AT_MESSAGE *msg_p = NULL; + if (!at_mailbox_user_get(THREAD_USER4, &msg_p)) { + AT_THREAD_TRACE(2, "_debug: %s,%d", __func__, __LINE__); + AT_THREAD_TRACE( + 4, + "at_thread_user1: id = 0x%x, ptr = 0x%x,param0 = 0x%x,param1 = 0x%x.", + msg_p->id, msg_p->ptr, msg_p->param0, msg_p->param1); + pfunc = (AT_FUNC_T)msg_p->ptr; + pfunc(msg_p->param0, msg_p->param1); + at_mailbox_user_free(THREAD_USER4, msg_p); + } + } } #endif -int at_thread_user_init(enum THREAD_USER_ID user_id) -{ - AT_THREAD_TRACE(3,"%s,%d,user_id = %d.",__func__,__LINE__,user_id); +int at_thread_user_init(enum THREAD_USER_ID user_id) { + AT_THREAD_TRACE(3, "%s,%d,user_id = %d.", __func__, __LINE__, user_id); - if(user_id == THREAD_USER0) - { - at_thread_info[user_id].mid = osMailCreate(osMailQ(at_mailbox_user0), NULL); - at_thread_info[user_id].til = osThreadCreate(osThread(at_thread_user0), (void*)user_id); - } - if(user_id == THREAD_USER1) - { - at_thread_info[user_id].mid = osMailCreate(osMailQ(at_mailbox_user1), NULL); - at_thread_info[user_id].til = osThreadCreate(osThread(at_thread_user1), (void*)user_id); - } + if (user_id == THREAD_USER0) { + at_thread_info[user_id].mid = osMailCreate(osMailQ(at_mailbox_user0), NULL); + at_thread_info[user_id].til = + osThreadCreate(osThread(at_thread_user0), (void *)user_id); + } + if (user_id == THREAD_USER1) { + at_thread_info[user_id].mid = osMailCreate(osMailQ(at_mailbox_user1), NULL); + at_thread_info[user_id].til = + osThreadCreate(osThread(at_thread_user1), (void *)user_id); + } - if(user_id == THREAD_USER2) - { - at_thread_info[user_id].mid = osMailCreate(osMailQ(at_mailbox_user2), NULL); - at_thread_info[user_id].til = osThreadCreate(osThread(at_thread_user2), (void*)user_id); - } - if(user_id == THREAD_USER3) - { - at_thread_info[user_id].mid = osMailCreate(osMailQ(at_mailbox_user3), NULL); - at_thread_info[user_id].til = osThreadCreate(osThread(at_thread_user3), (void*)user_id); - } - if(user_id == THREAD_USER4) - { - at_thread_info[user_id].mid = osMailCreate(osMailQ(at_mailbox_user4), NULL); - at_thread_info[user_id].til = osThreadCreate(osThread(at_thread_user4), (void*)user_id); - } + if (user_id == THREAD_USER2) { + at_thread_info[user_id].mid = osMailCreate(osMailQ(at_mailbox_user2), NULL); + at_thread_info[user_id].til = + osThreadCreate(osThread(at_thread_user2), (void *)user_id); + } + if (user_id == THREAD_USER3) { + at_thread_info[user_id].mid = osMailCreate(osMailQ(at_mailbox_user3), NULL); + at_thread_info[user_id].til = + osThreadCreate(osThread(at_thread_user3), (void *)user_id); + } + if (user_id == THREAD_USER4) { + at_thread_info[user_id].mid = osMailCreate(osMailQ(at_mailbox_user4), NULL); + at_thread_info[user_id].til = + osThreadCreate(osThread(at_thread_user4), (void *)user_id); + } - if (at_thread_info[user_id].mid == NULL) { - AT_THREAD_TRACE(1,"Failed to Create mailbox, user_id = %d.",user_id); - return -1; - } - if (at_thread_info[user_id].til == NULL) { - AT_THREAD_TRACE(1,"Failed to Create thread for user. user_id = %d",user_id); - return -2; - } - at_thread_info[user_id].mail_count = 0; - at_thread_info[user_id].is_inited = true; - return 0; + if (at_thread_info[user_id].mid == NULL) { + AT_THREAD_TRACE(1, "Failed to Create mailbox, user_id = %d.", user_id); + return -1; + } + if (at_thread_info[user_id].til == NULL) { + AT_THREAD_TRACE(1, "Failed to Create thread for user. user_id = %d", + user_id); + return -2; + } + at_thread_info[user_id].mail_count = 0; + at_thread_info[user_id].is_inited = true; + return 0; } -bool at_thread_user_is_inited(enum THREAD_USER_ID user_id) -{ - return at_thread_info[user_id].is_inited; +bool at_thread_user_is_inited(enum THREAD_USER_ID user_id) { + return at_thread_info[user_id].is_inited; } -int at_thread_user_enqueue_cmd(enum THREAD_USER_ID user_id, - uint32_t cmd_id, - uint32_t param0, - uint32_t param1, - uint32_t pfunc - ) -{ - AT_MESSAGE at_msg; - int32_t ret; +int at_thread_user_enqueue_cmd(enum THREAD_USER_ID user_id, uint32_t cmd_id, + uint32_t param0, uint32_t param1, + uint32_t pfunc) { + AT_MESSAGE at_msg; + int32_t ret; - at_msg.id = cmd_id; - at_msg.param0 = param0; - at_msg.param1 = param1; - at_msg.ptr = pfunc; - ret = at_mailbox_user_put(user_id,&at_msg); - return ret; + at_msg.id = cmd_id; + at_msg.param0 = param0; + at_msg.param1 = param1; + at_msg.ptr = pfunc; + ret = at_mailbox_user_put(user_id, &at_msg); + return ret; } diff --git a/services/auto_test/auto_test.cpp b/services/auto_test/auto_test.cpp index 50e9888..e72edc3 100644 --- a/services/auto_test/auto_test.cpp +++ b/services/auto_test/auto_test.cpp @@ -14,49 +14,48 @@ * ****************************************************************************/ #if defined(_AUTO_TEST_) -#include "cmsis_os.h" -#include "pmu.h" -#include "hal_trace.h" -#include "hal_aud.h" -#include "hal_key.h" -#include "apps.h" -#include "app_thread.h" #include "app_status_ind.h" -#include "nvrecord.h" -#include "hal_timer.h" +#include "app_thread.h" +#include "apps.h" +#include "cmsis_os.h" +#include "hal_aud.h" #include "hal_chipid.h" +#include "hal_key.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "nvrecord.h" +#include "pmu.h" extern "C" { #include "besbt_cfg.h" #ifndef ENHANCED_STACK +#include "avrcpi.h" #include "eventmgr.h" #include "me.h" #include "sec.h" -#include "avrcpi.h" #include "sys/mei.h" #endif #include "a2dp.h" -#include "avdtp.h" #include "avctp.h" +#include "avdtp.h" #include "avrcp.h" } #include "app_bt.h" -#include "btapp.h" -#include "hal_norflash.h" -#include "norflash_api.h" #include "app_utils.h" #include "at_thread.h" #include "at_thread_user.h" +#include "btapp.h" +#include "hal_norflash.h" +#include "norflash_api.h" -#include "tgt_hardware.h" -#include "app_bt_stream.h" +#include "app_a2dp.h" #include "app_audio.h" -#include "hal_bootmode.h" -#include "bt_drv_interface.h" #include "app_battery.h" -#include "hal_sleep.h" #include "app_bt_stream.h" #include "app_hfp.h" -#include "app_a2dp.h" +#include "bt_drv_interface.h" +#include "hal_bootmode.h" +#include "hal_sleep.h" +#include "tgt_hardware.h" // ------------------------------------------------- // auto test command list. // AUTO_TEST AT_TEST Auto test ok. @@ -85,191 +84,185 @@ extern "C" { // NORFALSH_SUSPEND NORFLASH_SUSPEND Norflash suspend ok. // MEMORY MEMORY Memory ok. //--------------------------------------------------------- -typedef enum -{ - AT_CMD_ID_TEST , - AT_CMD_ID_POWER_OFF , - AT_CMD_ID_REBOOT , - AT_CMD_ID_PMU_SHUTDOWN, - AT_CMD_ID_CONNECT , - AT_CMD_ID_DISCONNECT , - AT_CMD_ID_PAIRING , - AT_CMD_ID_CONNECT_TWS , - AT_CMD_ID_CALL_SETUP , - AT_CMD_ID_CALL_HANGUP , - AT_CMD_ID_MUSIC_ON , - AT_CMD_ID_MUSIC_SUSPEND, - AT_CMD_ID_SLEEP , - AT_CMD_ID_SLEEP_CLEAN , - AT_CMD_ID_WAKEUP , - AT_CMD_ID_SWITCH_FREQ , - AT_CMD_ID_POWER_ON , - AT_CMD_ID_BT_INIT , - AT_CMD_ID_SIMULATE_KEY , - AT_CMD_ID_NORFLASH, - AT_CMD_ID_NORFLASH_SUSPEND, - AT_CMD_ID_MEMORY, - AT_CMD_ID_GET_MAC, - AT_CMD_ID_GET_NAME, - AT_CMD_ID_SET_LOOPBACK, - AT_CMD_ID_SET_LED, - AT_CMD_ID_ENTER_SIGNAL, - AT_CMD_ID_ENTER_NO_SIGNAL, - AT_CMD_ID_NO_SIGNAL_BLE, - AT_CMD_ID_NO_SIGNAL_BT, - AT_CMD_ID_GET_BATTERY, - AT_CMD_ID_SET_VOLUME, - AT_CMD_ID_GET_FWVER, - AT_CMD_ID_GET_BOOTMODE, - AT_CMD_ID_COUNT, +typedef enum { + AT_CMD_ID_TEST, + AT_CMD_ID_POWER_OFF, + AT_CMD_ID_REBOOT, + AT_CMD_ID_PMU_SHUTDOWN, + AT_CMD_ID_CONNECT, + AT_CMD_ID_DISCONNECT, + AT_CMD_ID_PAIRING, + AT_CMD_ID_CONNECT_TWS, + AT_CMD_ID_CALL_SETUP, + AT_CMD_ID_CALL_HANGUP, + AT_CMD_ID_MUSIC_ON, + AT_CMD_ID_MUSIC_SUSPEND, + AT_CMD_ID_SLEEP, + AT_CMD_ID_SLEEP_CLEAN, + AT_CMD_ID_WAKEUP, + AT_CMD_ID_SWITCH_FREQ, + AT_CMD_ID_POWER_ON, + AT_CMD_ID_BT_INIT, + AT_CMD_ID_SIMULATE_KEY, + AT_CMD_ID_NORFLASH, + AT_CMD_ID_NORFLASH_SUSPEND, + AT_CMD_ID_MEMORY, + AT_CMD_ID_GET_MAC, + AT_CMD_ID_GET_NAME, + AT_CMD_ID_SET_LOOPBACK, + AT_CMD_ID_SET_LED, + AT_CMD_ID_ENTER_SIGNAL, + AT_CMD_ID_ENTER_NO_SIGNAL, + AT_CMD_ID_NO_SIGNAL_BLE, + AT_CMD_ID_NO_SIGNAL_BT, + AT_CMD_ID_GET_BATTERY, + AT_CMD_ID_SET_VOLUME, + AT_CMD_ID_GET_FWVER, + AT_CMD_ID_GET_BOOTMODE, + AT_CMD_ID_COUNT, -}AT_CMD_ID_ENUM_T; +} AT_CMD_ID_ENUM_T; +#define AT_CMD_TEST "AUTO_TEST" +#define AT_CMD_POWER_OFF "POWER_OFF" +#define AT_CMD_REBOOT "SYS_RESET" +#define AT_CMD_PMU_SHUTDOWN "PMU_SHUTDOWN" +#define AT_CMD_CONNECT "CONNECT" +#define AT_CMD_DISCONNECT "DISCONNECT" +#define AT_CMD_PAIRING "PAIRING" +#define AT_CMD_CONNECT_TWS "CONNECT_TWS" +#define AT_CMD_CALL_SETUP "CALL_SETUP" +#define AT_CMD_CALL_HANGUP "CALL_HANGUP" +#define AT_CMD_MUSIC_ON "MUSIC_ON" +#define AT_CMD_MUSIC_SUSPEND "MUSIC_SUSPEND" +#define AT_CMD_SLEEP "SLEEP_ENTER" +#define AT_CMD_SLEEP_CLEAN "SLEEP_CLEAN" +#define AT_CMD_WAKEUP "WAKEUP" +#define AT_CMD_SWITCH_FREQ "SWITCH_FREQ" +#define AT_CMD_POWER_ON "POWER_ON" +#define AT_CMD_BT_INIT "BT_INIT" +#define AT_CMD_SIMULATE_KEY "SIMULATE_KEY" +#define AT_CMD_NORFLASH "NORFLASH" +#define AT_CMD_NORFLASH_SUSPEND "NORFLASH_SUSPEND" +#define AT_CMD_MEMORY "MEMORY" +#define AT_CMD_GET_MAC "GET_MAC" +#define AT_CMD_GET_NAME "GET_NAME" +#define AT_CMD_SET_LOOPBACK "SET_LOOPBACK" +#define AT_CMD_SET_LED "SET_LED" +#define AT_CMD_ENTER_SIGNAL "ENTER_SIGNAL" +#define AT_CMD_ENTER_NO_SIGNAL "ENTER_NO_SIGNAL" +#define AT_CMD_NO_SIGNAL_BLE "NO_SIGNAL_BLE" +#define AT_CMD_NO_SIGNAL_BT "NO_SIGNAL_BT" +#define AT_CMD_GET_BATTERY "GET_BATTERY" +#define AT_CMD_SET_VOLUME "SET_VOLUME" +#define AT_CMD_GET_FWVER "GET_FWVER" +#define AT_CMD_GET_BOOTMODE "GET_BOOTMODE" -#define AT_CMD_TEST "AUTO_TEST" -#define AT_CMD_POWER_OFF "POWER_OFF" -#define AT_CMD_REBOOT "SYS_RESET" -#define AT_CMD_PMU_SHUTDOWN "PMU_SHUTDOWN" -#define AT_CMD_CONNECT "CONNECT" -#define AT_CMD_DISCONNECT "DISCONNECT" -#define AT_CMD_PAIRING "PAIRING" -#define AT_CMD_CONNECT_TWS "CONNECT_TWS" -#define AT_CMD_CALL_SETUP "CALL_SETUP" -#define AT_CMD_CALL_HANGUP "CALL_HANGUP" -#define AT_CMD_MUSIC_ON "MUSIC_ON" -#define AT_CMD_MUSIC_SUSPEND "MUSIC_SUSPEND" -#define AT_CMD_SLEEP "SLEEP_ENTER" -#define AT_CMD_SLEEP_CLEAN "SLEEP_CLEAN" -#define AT_CMD_WAKEUP "WAKEUP" -#define AT_CMD_SWITCH_FREQ "SWITCH_FREQ" -#define AT_CMD_POWER_ON "POWER_ON" -#define AT_CMD_BT_INIT "BT_INIT" -#define AT_CMD_SIMULATE_KEY "SIMULATE_KEY" -#define AT_CMD_NORFLASH "NORFLASH" -#define AT_CMD_NORFLASH_SUSPEND "NORFLASH_SUSPEND" -#define AT_CMD_MEMORY "MEMORY" -#define AT_CMD_GET_MAC "GET_MAC" -#define AT_CMD_GET_NAME "GET_NAME" -#define AT_CMD_SET_LOOPBACK "SET_LOOPBACK" -#define AT_CMD_SET_LED "SET_LED" -#define AT_CMD_ENTER_SIGNAL "ENTER_SIGNAL" -#define AT_CMD_ENTER_NO_SIGNAL "ENTER_NO_SIGNAL" -#define AT_CMD_NO_SIGNAL_BLE "NO_SIGNAL_BLE" -#define AT_CMD_NO_SIGNAL_BT "NO_SIGNAL_BT" -#define AT_CMD_GET_BATTERY "GET_BATTERY" -#define AT_CMD_SET_VOLUME "SET_VOLUME" -#define AT_CMD_GET_FWVER "GET_FWVER" -#define AT_CMD_GET_BOOTMODE "GET_BOOTMODE" +#define AT_CMD_RESP_TEST "Auto test ok." +#define AT_CMD_RESP_POWER_OFF "System shutdown" +#define AT_CMD_RESP_REBOOT "System reset." +#define AT_CMD_RESP_PMU_SHUTDOWN "Pmu shutdown." +#define AT_CMD_RESP_CONNECT "Connect ok." +#define AT_CMD_RESP_DISCONNECT "Disconnect ok." +#define AT_CMD_RESP_PAIRING "Pairing ok." +#define AT_CMD_RESP_CONNECT_TWS "Connect tws ok." +#define AT_CMD_RESP_CALL_SETUP "Call setup ok." +#define AT_CMD_RESP_CALL_HANGUP "Call hangup ok." +#define AT_CMD_RESP_MUSIC_ON "Music on ok." +#define AT_CMD_RESP_MUSIC_SUSPEND "Music suspend ok." +#define AT_CMD_RESP_SLEEP "Sleep ok." +#define AT_CMD_RESP_SLEEP_CLEAN "Sleep clean ok." +#define AT_CMD_RESP_WAKEUP "Wakeup ok." +#define AT_CMD_RESP_SWITCH_FREQ "Switch freq ok." +#define AT_CMD_RESP_POWER_ON "Power on." +#define AT_CMD_RESP_BT_INIT "BT Init ok." +#define AT_CMD_RESP_SIMULATE_KEY "Simulate key ok." +#define AT_CMD_RESP_STANDBY "" +#define AT_CMD_RESP_NORFLASH "Norflash ok." +#define AT_CMD_RESP_NORFLASH_SUSPEND "Norflash suspend ok." +#define AT_CMD_RESP_MEMORY "Memory ok." +#define AT_CMD_RESP_LED "LED Display ok." +#define AT_CMD_RESP_BATTERY "Battery ok." +#define AT_CMD_RESP_LOOPBACK "LoopBack ok." +#define AT_CMD_RESP_MAC "Get MAC ok." +#define AT_CMD_RESP_FWVER "Get FWVER ok." +#define AT_CMD_RESP_BOOTMODE "Get Bootmode ok." +#define AT_CMD_RESP_TIME_OUT "Time out." +#define AT_CMD_RESP_ERROR "Error." -#define AT_CMD_RESP_TEST "Auto test ok." -#define AT_CMD_RESP_POWER_OFF "System shutdown" -#define AT_CMD_RESP_REBOOT "System reset." -#define AT_CMD_RESP_PMU_SHUTDOWN "Pmu shutdown." -#define AT_CMD_RESP_CONNECT "Connect ok." -#define AT_CMD_RESP_DISCONNECT "Disconnect ok." -#define AT_CMD_RESP_PAIRING "Pairing ok." -#define AT_CMD_RESP_CONNECT_TWS "Connect tws ok." -#define AT_CMD_RESP_CALL_SETUP "Call setup ok." -#define AT_CMD_RESP_CALL_HANGUP "Call hangup ok." -#define AT_CMD_RESP_MUSIC_ON "Music on ok." -#define AT_CMD_RESP_MUSIC_SUSPEND "Music suspend ok." -#define AT_CMD_RESP_SLEEP "Sleep ok." -#define AT_CMD_RESP_SLEEP_CLEAN "Sleep clean ok." -#define AT_CMD_RESP_WAKEUP "Wakeup ok." -#define AT_CMD_RESP_SWITCH_FREQ "Switch freq ok." -#define AT_CMD_RESP_POWER_ON "Power on." -#define AT_CMD_RESP_BT_INIT "BT Init ok." -#define AT_CMD_RESP_SIMULATE_KEY "Simulate key ok." -#define AT_CMD_RESP_STANDBY "" -#define AT_CMD_RESP_NORFLASH "Norflash ok." -#define AT_CMD_RESP_NORFLASH_SUSPEND "Norflash suspend ok." -#define AT_CMD_RESP_MEMORY "Memory ok." -#define AT_CMD_RESP_LED "LED Display ok." -#define AT_CMD_RESP_BATTERY "Battery ok." -#define AT_CMD_RESP_LOOPBACK "LoopBack ok." -#define AT_CMD_RESP_MAC "Get MAC ok." -#define AT_CMD_RESP_FWVER "Get FWVER ok." -#define AT_CMD_RESP_BOOTMODE "Get Bootmode ok." -#define AT_CMD_RESP_TIME_OUT "Time out." -#define AT_CMD_RESP_ERROR "Error." - -#define CMD_OUT_TIME_MS (30*1000) // millisecond. +#define CMD_OUT_TIME_MS (30 * 1000) // millisecond. typedef void (*APP_BT_AUTO_TEST_T)(uint32_t, uint32_t); -typedef enum -{ - AT_STATUS_FREE, - AT_STATUS_BUSY, -}AT_STATUS_T; +typedef enum { + AT_STATUS_FREE, + AT_STATUS_BUSY, +} AT_STATUS_T; -typedef struct -{ - AT_CMD_ID_ENUM_T cmd_id; - const char* cmd; - APP_BT_AUTO_TEST_T pFunc; +typedef struct { + AT_CMD_ID_ENUM_T cmd_id; + const char *cmd; + APP_BT_AUTO_TEST_T pFunc; } AT_CMD_FRAME_T; -typedef struct -{ - AT_CMD_ID_ENUM_T cmd_id; - const char* resp; - uint32_t count; -}AT_CMD_RESP; +typedef struct { + AT_CMD_ID_ENUM_T cmd_id; + const char *resp; + uint32_t count; +} AT_CMD_RESP; -typedef struct -{ - AT_CMD_ID_ENUM_T cur_cmd_id; - AT_STATUS_T status; - uint32_t start_time; - uint32_t param; - uint32_t pfunc; -}AT_STAUTS; +typedef struct { + AT_CMD_ID_ENUM_T cur_cmd_id; + AT_STATUS_T status; + uint32_t start_time; + uint32_t param; + uint32_t pfunc; +} AT_STAUTS; #if 1 -#define AT_TRACE TRACE +#define AT_TRACE TRACE #else -#define AT_TRACE(str,...) +#define AT_TRACE(str, ...) #endif -void at_test(uint32_t param0,uint32_t param1); -void at_power_off(uint32_t param0,uint32_t param1); -void at_reboot(uint32_t param0,uint32_t param1); -void at_pmu_shutdown(uint32_t param0,uint32_t param1); -void at_connet(uint32_t param0,uint32_t param1); -void at_disconnet(uint32_t param0,uint32_t param1); -void at_pairing(uint32_t param0,uint32_t param1); -void at_connect_tws(uint32_t param0,uint32_t param1); -void at_call_setup(uint32_t param0,uint32_t param1); -void at_call_hangup(uint32_t param0,uint32_t param1); -void at_music_on(uint32_t param0,uint32_t param1); -void at_music_suspend(uint32_t param0,uint32_t param1); -void at_sleep(uint32_t param0,uint32_t param1); -void at_sleep_clean(uint32_t param0,uint32_t param1); -void at_wakeup(uint32_t param0,uint32_t param1); -void at_switch_freq(uint32_t param0,uint32_t param1); -void at_power_on(uint32_t param0,uint32_t param1); -void at_bt_init(uint32_t param0,uint32_t param1); -void at_simulate_key(uint32_t param0,uint32_t param1); -void at_norflash(uint32_t param0,uint32_t param1); -void at_norflash_suspend(uint32_t param0,uint32_t param1); -void at_memory(uint32_t param0,uint32_t param1); -void at_get_mac(uint32_t param0,uint32_t param1); -void at_get_devicename(uint32_t param0,uint32_t param1); -void at_set_loopback(uint32_t param0,uint32_t param1); -void at_set_led(uint32_t param0,uint32_t param1); -void at_enter_signaling_mode(uint32_t param0,uint32_t param1); -void at_enter_no_signaling_mode(uint32_t param0,uint32_t param1); -void at_no_signaling_ble_test(uint32_t param0,uint32_t param1); -void at_no_signaling_bt_test(uint32_t param0,uint32_t param1); -void at_get_battery(uint32_t param0,uint32_t param1); -void at_set_volume(uint32_t param0,uint32_t param1); -void at_get_fwversion(uint32_t param0,uint32_t param1); -void at_get_bootmode(uint32_t param0,uint32_t param1); +void at_test(uint32_t param0, uint32_t param1); +void at_power_off(uint32_t param0, uint32_t param1); +void at_reboot(uint32_t param0, uint32_t param1); +void at_pmu_shutdown(uint32_t param0, uint32_t param1); +void at_connet(uint32_t param0, uint32_t param1); +void at_disconnet(uint32_t param0, uint32_t param1); +void at_pairing(uint32_t param0, uint32_t param1); +void at_connect_tws(uint32_t param0, uint32_t param1); +void at_call_setup(uint32_t param0, uint32_t param1); +void at_call_hangup(uint32_t param0, uint32_t param1); +void at_music_on(uint32_t param0, uint32_t param1); +void at_music_suspend(uint32_t param0, uint32_t param1); +void at_sleep(uint32_t param0, uint32_t param1); +void at_sleep_clean(uint32_t param0, uint32_t param1); +void at_wakeup(uint32_t param0, uint32_t param1); +void at_switch_freq(uint32_t param0, uint32_t param1); +void at_power_on(uint32_t param0, uint32_t param1); +void at_bt_init(uint32_t param0, uint32_t param1); +void at_simulate_key(uint32_t param0, uint32_t param1); +void at_norflash(uint32_t param0, uint32_t param1); +void at_norflash_suspend(uint32_t param0, uint32_t param1); +void at_memory(uint32_t param0, uint32_t param1); +void at_get_mac(uint32_t param0, uint32_t param1); +void at_get_devicename(uint32_t param0, uint32_t param1); +void at_set_loopback(uint32_t param0, uint32_t param1); +void at_set_led(uint32_t param0, uint32_t param1); +void at_enter_signaling_mode(uint32_t param0, uint32_t param1); +void at_enter_no_signaling_mode(uint32_t param0, uint32_t param1); +void at_no_signaling_ble_test(uint32_t param0, uint32_t param1); +void at_no_signaling_bt_test(uint32_t param0, uint32_t param1); +void at_get_battery(uint32_t param0, uint32_t param1); +void at_set_volume(uint32_t param0, uint32_t param1); +void at_get_fwversion(uint32_t param0, uint32_t param1); +void at_get_bootmode(uint32_t param0, uint32_t param1); extern "C" int system_shutdown(void); extern int system_reset(void); extern void bt_key_send(uint32_t code, uint16_t event); extern void system_get_fwversion(uint8_t *fw_rev_0, uint8_t *fw_rev_1, - uint8_t *fw_rev_2, uint8_t *fw_rev_3); + uint8_t *fw_rev_2, uint8_t *fw_rev_3); #if defined(BT_USB_AUDIO_DUAL_MODE_TEST) extern "C" void test_btusb_switch(void); @@ -279,117 +272,107 @@ extern "C" void test_btusb_switch_to_usb(void); #endif static const AT_CMD_FRAME_T g_at_cmd_frame[] = { - {AT_CMD_ID_TEST ,AT_CMD_TEST ,at_test }, - {AT_CMD_ID_POWER_OFF ,AT_CMD_POWER_OFF ,at_power_off }, - {AT_CMD_ID_REBOOT ,AT_CMD_REBOOT ,at_reboot }, - {AT_CMD_ID_PMU_SHUTDOWN ,AT_CMD_PMU_SHUTDOWN ,at_pmu_shutdown }, - {AT_CMD_ID_CONNECT ,AT_CMD_CONNECT ,at_connet }, - {AT_CMD_ID_DISCONNECT ,AT_CMD_DISCONNECT ,at_disconnet }, - {AT_CMD_ID_PAIRING ,AT_CMD_PAIRING ,at_pairing }, - {AT_CMD_ID_CONNECT_TWS ,AT_CMD_CONNECT_TWS ,at_connect_tws }, - {AT_CMD_ID_CALL_SETUP ,AT_CMD_CALL_SETUP ,at_call_setup }, - {AT_CMD_ID_CALL_HANGUP ,AT_CMD_CALL_HANGUP ,at_call_hangup }, - {AT_CMD_ID_MUSIC_ON ,AT_CMD_MUSIC_ON ,at_music_on }, - {AT_CMD_ID_MUSIC_SUSPEND ,AT_CMD_MUSIC_SUSPEND ,at_music_suspend }, - {AT_CMD_ID_SLEEP ,AT_CMD_SLEEP ,at_sleep }, - {AT_CMD_ID_SLEEP_CLEAN ,AT_CMD_SLEEP_CLEAN ,at_sleep_clean }, - {AT_CMD_ID_WAKEUP ,AT_CMD_WAKEUP ,at_wakeup }, - {AT_CMD_ID_SWITCH_FREQ ,AT_CMD_SWITCH_FREQ ,at_switch_freq }, - {AT_CMD_ID_POWER_ON ,AT_CMD_POWER_ON ,at_power_on }, - {AT_CMD_ID_BT_INIT ,AT_CMD_BT_INIT ,at_bt_init }, - {AT_CMD_ID_SIMULATE_KEY ,AT_CMD_SIMULATE_KEY ,at_simulate_key }, - {AT_CMD_ID_NORFLASH ,AT_CMD_NORFLASH ,at_norflash }, - {AT_CMD_ID_NORFLASH_SUSPEND ,AT_CMD_NORFLASH_SUSPEND ,at_norflash_suspend }, - {AT_CMD_ID_MEMORY ,AT_CMD_MEMORY ,at_memory }, - {AT_CMD_ID_GET_MAC ,AT_CMD_GET_MAC ,at_get_mac }, - {AT_CMD_ID_GET_NAME ,AT_CMD_GET_NAME ,at_get_devicename }, - {AT_CMD_ID_SET_LOOPBACK ,AT_CMD_SET_LOOPBACK ,at_set_loopback }, - {AT_CMD_ID_SET_LED ,AT_CMD_SET_LED ,at_set_led }, - {AT_CMD_ID_ENTER_SIGNAL ,AT_CMD_ENTER_SIGNAL ,at_enter_signaling_mode }, - {AT_CMD_ID_ENTER_NO_SIGNAL ,AT_CMD_ENTER_NO_SIGNAL ,at_enter_no_signaling_mode }, - {AT_CMD_ID_NO_SIGNAL_BLE ,AT_CMD_NO_SIGNAL_BLE ,at_no_signaling_ble_test }, - {AT_CMD_ID_NO_SIGNAL_BT ,AT_CMD_NO_SIGNAL_BT ,at_no_signaling_bt_test }, - {AT_CMD_ID_GET_BATTERY ,AT_CMD_GET_BATTERY ,at_get_battery }, - {AT_CMD_ID_SET_VOLUME ,AT_CMD_SET_VOLUME ,at_set_volume }, - {AT_CMD_ID_GET_FWVER ,AT_CMD_GET_FWVER ,at_get_fwversion }, - {AT_CMD_ID_GET_BOOTMODE ,AT_CMD_GET_BOOTMODE ,at_get_bootmode }, - {AT_CMD_ID_COUNT ,(const char*)NULL ,NULL}, + {AT_CMD_ID_TEST, AT_CMD_TEST, at_test}, + {AT_CMD_ID_POWER_OFF, AT_CMD_POWER_OFF, at_power_off}, + {AT_CMD_ID_REBOOT, AT_CMD_REBOOT, at_reboot}, + {AT_CMD_ID_PMU_SHUTDOWN, AT_CMD_PMU_SHUTDOWN, at_pmu_shutdown}, + {AT_CMD_ID_CONNECT, AT_CMD_CONNECT, at_connet}, + {AT_CMD_ID_DISCONNECT, AT_CMD_DISCONNECT, at_disconnet}, + {AT_CMD_ID_PAIRING, AT_CMD_PAIRING, at_pairing}, + {AT_CMD_ID_CONNECT_TWS, AT_CMD_CONNECT_TWS, at_connect_tws}, + {AT_CMD_ID_CALL_SETUP, AT_CMD_CALL_SETUP, at_call_setup}, + {AT_CMD_ID_CALL_HANGUP, AT_CMD_CALL_HANGUP, at_call_hangup}, + {AT_CMD_ID_MUSIC_ON, AT_CMD_MUSIC_ON, at_music_on}, + {AT_CMD_ID_MUSIC_SUSPEND, AT_CMD_MUSIC_SUSPEND, at_music_suspend}, + {AT_CMD_ID_SLEEP, AT_CMD_SLEEP, at_sleep}, + {AT_CMD_ID_SLEEP_CLEAN, AT_CMD_SLEEP_CLEAN, at_sleep_clean}, + {AT_CMD_ID_WAKEUP, AT_CMD_WAKEUP, at_wakeup}, + {AT_CMD_ID_SWITCH_FREQ, AT_CMD_SWITCH_FREQ, at_switch_freq}, + {AT_CMD_ID_POWER_ON, AT_CMD_POWER_ON, at_power_on}, + {AT_CMD_ID_BT_INIT, AT_CMD_BT_INIT, at_bt_init}, + {AT_CMD_ID_SIMULATE_KEY, AT_CMD_SIMULATE_KEY, at_simulate_key}, + {AT_CMD_ID_NORFLASH, AT_CMD_NORFLASH, at_norflash}, + {AT_CMD_ID_NORFLASH_SUSPEND, AT_CMD_NORFLASH_SUSPEND, at_norflash_suspend}, + {AT_CMD_ID_MEMORY, AT_CMD_MEMORY, at_memory}, + {AT_CMD_ID_GET_MAC, AT_CMD_GET_MAC, at_get_mac}, + {AT_CMD_ID_GET_NAME, AT_CMD_GET_NAME, at_get_devicename}, + {AT_CMD_ID_SET_LOOPBACK, AT_CMD_SET_LOOPBACK, at_set_loopback}, + {AT_CMD_ID_SET_LED, AT_CMD_SET_LED, at_set_led}, + {AT_CMD_ID_ENTER_SIGNAL, AT_CMD_ENTER_SIGNAL, at_enter_signaling_mode}, + {AT_CMD_ID_ENTER_NO_SIGNAL, AT_CMD_ENTER_NO_SIGNAL, + at_enter_no_signaling_mode}, + {AT_CMD_ID_NO_SIGNAL_BLE, AT_CMD_NO_SIGNAL_BLE, at_no_signaling_ble_test}, + {AT_CMD_ID_NO_SIGNAL_BT, AT_CMD_NO_SIGNAL_BT, at_no_signaling_bt_test}, + {AT_CMD_ID_GET_BATTERY, AT_CMD_GET_BATTERY, at_get_battery}, + {AT_CMD_ID_SET_VOLUME, AT_CMD_SET_VOLUME, at_set_volume}, + {AT_CMD_ID_GET_FWVER, AT_CMD_GET_FWVER, at_get_fwversion}, + {AT_CMD_ID_GET_BOOTMODE, AT_CMD_GET_BOOTMODE, at_get_bootmode}, + {AT_CMD_ID_COUNT, (const char *)NULL, NULL}, }; static AT_CMD_RESP g_at_cmd_resp[] = { - {AT_CMD_ID_TEST ,AT_CMD_RESP_TEST ,0 }, - {AT_CMD_ID_POWER_OFF ,AT_CMD_RESP_POWER_OFF ,0 }, - {AT_CMD_ID_REBOOT ,AT_CMD_RESP_REBOOT ,0 }, - {AT_CMD_ID_PMU_SHUTDOWN ,AT_CMD_RESP_PMU_SHUTDOWN ,0 }, - {AT_CMD_ID_CONNECT ,AT_CMD_RESP_CONNECT ,0 }, - {AT_CMD_ID_DISCONNECT ,AT_CMD_RESP_DISCONNECT ,0 }, - {AT_CMD_ID_PAIRING ,AT_CMD_RESP_PAIRING ,0 }, - {AT_CMD_ID_CONNECT_TWS ,AT_CMD_RESP_CONNECT_TWS ,0 }, - {AT_CMD_ID_CALL_SETUP ,AT_CMD_RESP_CALL_SETUP ,0 }, - {AT_CMD_ID_CALL_HANGUP ,AT_CMD_RESP_CALL_HANGUP ,0 }, - {AT_CMD_ID_MUSIC_ON ,AT_CMD_RESP_MUSIC_ON ,0 }, - {AT_CMD_ID_MUSIC_SUSPEND ,AT_CMD_RESP_MUSIC_SUSPEND ,0 }, - {AT_CMD_ID_SLEEP ,AT_CMD_RESP_SLEEP ,0 }, - {AT_CMD_ID_SLEEP_CLEAN ,AT_CMD_RESP_SLEEP_CLEAN ,0 }, - {AT_CMD_ID_WAKEUP ,AT_CMD_RESP_WAKEUP ,0 }, - {AT_CMD_ID_SWITCH_FREQ ,AT_CMD_RESP_SWITCH_FREQ ,0 }, - {AT_CMD_ID_POWER_ON ,AT_CMD_RESP_POWER_ON ,0 }, - {AT_CMD_ID_BT_INIT ,AT_CMD_RESP_BT_INIT ,0 }, - {AT_CMD_ID_SIMULATE_KEY ,AT_CMD_RESP_SIMULATE_KEY ,0 }, - {AT_CMD_ID_NORFLASH ,AT_CMD_RESP_NORFLASH ,0 }, - {AT_CMD_ID_NORFLASH_SUSPEND ,AT_CMD_RESP_NORFLASH_SUSPEND ,0 }, - {AT_CMD_ID_MEMORY ,AT_CMD_RESP_MEMORY ,0 }, - {AT_CMD_ID_COUNT ,(const char*)NULL ,0 }, + {AT_CMD_ID_TEST, AT_CMD_RESP_TEST, 0}, + {AT_CMD_ID_POWER_OFF, AT_CMD_RESP_POWER_OFF, 0}, + {AT_CMD_ID_REBOOT, AT_CMD_RESP_REBOOT, 0}, + {AT_CMD_ID_PMU_SHUTDOWN, AT_CMD_RESP_PMU_SHUTDOWN, 0}, + {AT_CMD_ID_CONNECT, AT_CMD_RESP_CONNECT, 0}, + {AT_CMD_ID_DISCONNECT, AT_CMD_RESP_DISCONNECT, 0}, + {AT_CMD_ID_PAIRING, AT_CMD_RESP_PAIRING, 0}, + {AT_CMD_ID_CONNECT_TWS, AT_CMD_RESP_CONNECT_TWS, 0}, + {AT_CMD_ID_CALL_SETUP, AT_CMD_RESP_CALL_SETUP, 0}, + {AT_CMD_ID_CALL_HANGUP, AT_CMD_RESP_CALL_HANGUP, 0}, + {AT_CMD_ID_MUSIC_ON, AT_CMD_RESP_MUSIC_ON, 0}, + {AT_CMD_ID_MUSIC_SUSPEND, AT_CMD_RESP_MUSIC_SUSPEND, 0}, + {AT_CMD_ID_SLEEP, AT_CMD_RESP_SLEEP, 0}, + {AT_CMD_ID_SLEEP_CLEAN, AT_CMD_RESP_SLEEP_CLEAN, 0}, + {AT_CMD_ID_WAKEUP, AT_CMD_RESP_WAKEUP, 0}, + {AT_CMD_ID_SWITCH_FREQ, AT_CMD_RESP_SWITCH_FREQ, 0}, + {AT_CMD_ID_POWER_ON, AT_CMD_RESP_POWER_ON, 0}, + {AT_CMD_ID_BT_INIT, AT_CMD_RESP_BT_INIT, 0}, + {AT_CMD_ID_SIMULATE_KEY, AT_CMD_RESP_SIMULATE_KEY, 0}, + {AT_CMD_ID_NORFLASH, AT_CMD_RESP_NORFLASH, 0}, + {AT_CMD_ID_NORFLASH_SUSPEND, AT_CMD_RESP_NORFLASH_SUSPEND, 0}, + {AT_CMD_ID_MEMORY, AT_CMD_RESP_MEMORY, 0}, + {AT_CMD_ID_COUNT, (const char *)NULL, 0}, }; -AT_STAUTS g_at_status = {AT_CMD_ID_COUNT,AT_STATUS_FREE,0,0,0}; +AT_STAUTS g_at_status = {AT_CMD_ID_COUNT, AT_STATUS_FREE, 0, 0, 0}; -void _at_trim(uint8_t* buff) -{ - uint8_t* p; - uint32_t len; - // int32_t i; +void _at_trim(uint8_t *buff) { + uint8_t *p; + uint32_t len; + // int32_t i; - len = strlen((char*)buff); - p = buff + (len - 1); + len = strlen((char *)buff); + p = buff + (len - 1); - while(1) - { - if(*p == 0x20 || *p == 0x09 || *p == 0x0A || *p == 0x0D) - { - *p = 0; - p--; - } - else - { - break; - } - if(p == buff) - { - break; - } + while (1) { + if (*p == 0x20 || *p == 0x09 || *p == 0x0A || *p == 0x0D) { + *p = 0; + p--; + } else { + break; } - - p = buff; - while(1) - { - if(*p == 0x20 || *p == 0x09) - { - p++; - } - else - { - break; - } + if (p == buff) { + break; } + } - while(*p) - { - *buff = *p; - buff ++; - p++; + p = buff; + while (1) { + if (*p == 0x20 || *p == 0x09) { + p++; + } else { + break; } + } + + while (*p) { + *buff = *p; + buff++; + p++; + } } /* @@ -423,39 +406,32 @@ static int _at_strtohex(uint8_t* hex, char* str, int len) return -1; } */ -static char* _at_get_cmd_resp(AT_CMD_ID_ENUM_T cmd_id) -{ - uint32_t i; - uint32_t cmd_count = 0; - char* resp = NULL; +static char *_at_get_cmd_resp(AT_CMD_ID_ENUM_T cmd_id) { + uint32_t i; + uint32_t cmd_count = 0; + char *resp = NULL; - cmd_count = sizeof(g_at_cmd_resp)/sizeof(AT_CMD_RESP); + cmd_count = sizeof(g_at_cmd_resp) / sizeof(AT_CMD_RESP); - for(i = 0; i < cmd_count; i++) - { - if(AT_CMD_ID_COUNT == g_at_cmd_resp[i].cmd_id) - { - AT_TRACE(1,"_debug: undefined at cmd resp, cmd_id = %d.",cmd_id); - resp = NULL; - goto _func_end; - } - if(cmd_id == g_at_cmd_resp[i].cmd_id) - { - if(g_at_cmd_resp[i].count > 0) - { - resp = (char*)g_at_cmd_resp[i].resp; - g_at_cmd_resp[i].count = 0; - AT_TRACE(2,"_debug: ount > 0,cmd_id = %d,resp = %s.",cmd_id,resp); - } - else - { - resp = NULL; - } - break; - } + for (i = 0; i < cmd_count; i++) { + if (AT_CMD_ID_COUNT == g_at_cmd_resp[i].cmd_id) { + AT_TRACE(1, "_debug: undefined at cmd resp, cmd_id = %d.", cmd_id); + resp = NULL; + goto _func_end; } + if (cmd_id == g_at_cmd_resp[i].cmd_id) { + if (g_at_cmd_resp[i].count > 0) { + resp = (char *)g_at_cmd_resp[i].resp; + g_at_cmd_resp[i].count = 0; + AT_TRACE(2, "_debug: ount > 0,cmd_id = %d,resp = %s.", cmd_id, resp); + } else { + resp = NULL; + } + break; + } + } _func_end: - return resp; + return resp; } /* @@ -467,602 +443,523 @@ static AT_STATUS_T _at_get_status(void) } */ -static AT_CMD_ID_ENUM_T _at_get_cur_cmd_id(void) -{ - return g_at_status.cur_cmd_id; +static AT_CMD_ID_ENUM_T _at_get_cur_cmd_id(void) { + return g_at_status.cur_cmd_id; } -static void _at_set_status(AT_CMD_ID_ENUM_T cmd_id,AT_STATUS_T status,uint32_t param,uint32_t pfuc) -{ - g_at_status.status = status; - if(status == AT_STATUS_BUSY) - { - g_at_status.cur_cmd_id = cmd_id; - g_at_status.start_time = hal_sys_timer_get(); - } - g_at_status.param = param; - g_at_status.pfunc = pfuc; +static void _at_set_status(AT_CMD_ID_ENUM_T cmd_id, AT_STATUS_T status, + uint32_t param, uint32_t pfuc) { + g_at_status.status = status; + if (status == AT_STATUS_BUSY) { + g_at_status.cur_cmd_id = cmd_id; + g_at_status.start_time = hal_sys_timer_get(); + } + g_at_status.param = param; + g_at_status.pfunc = pfuc; } -static void _at_resp(void) -{ - AT_CMD_ID_ENUM_T cur_cmd_id; - uint32_t wait_time; - char* resp; +static void _at_resp(void) { + AT_CMD_ID_ENUM_T cur_cmd_id; + uint32_t wait_time; + char *resp; - cur_cmd_id = _at_get_cur_cmd_id(); - if(cur_cmd_id == AT_CMD_ID_COUNT) - { - TRACE_IMM(1,"AUTO_TEST:%s",AT_CMD_RESP_ERROR); - return; - } - resp = _at_get_cmd_resp(cur_cmd_id); - if(resp) - { - //osDelay(64); - TRACE_IMM(1,"AUTO_TEST: %s",resp); - //osDelay(64); - _at_set_status(AT_CMD_ID_COUNT,AT_STATUS_FREE,0,0); - } - else - { - wait_time = TICKS_TO_MS(hal_sys_timer_get() - g_at_status.start_time); - if(wait_time < CMD_OUT_TIME_MS) - { - //osDelay(4); - //app_bt_send_request(APP_BT_REQ_AUTO_TEST, (uint32_t)g_at_status.param,cur_cmd_id, - //g_at_status.pfunc); - AT_TRACE(1,"_debug: _at_resp,auto_test wait : %d(ms)",wait_time); - } - else - { - _at_set_status(AT_CMD_ID_COUNT,AT_STATUS_FREE,0,0); - AT_TRACE(2,"AUTO_TEST:%s,wait time = %d(ms)",AT_CMD_RESP_TIME_OUT,wait_time); - } + cur_cmd_id = _at_get_cur_cmd_id(); + if (cur_cmd_id == AT_CMD_ID_COUNT) { + TRACE_IMM(1, "AUTO_TEST:%s", AT_CMD_RESP_ERROR); + return; + } + resp = _at_get_cmd_resp(cur_cmd_id); + if (resp) { + // osDelay(64); + TRACE_IMM(1, "AUTO_TEST: %s", resp); + // osDelay(64); + _at_set_status(AT_CMD_ID_COUNT, AT_STATUS_FREE, 0, 0); + } else { + wait_time = TICKS_TO_MS(hal_sys_timer_get() - g_at_status.start_time); + if (wait_time < CMD_OUT_TIME_MS) { + // osDelay(4); + // app_bt_send_request(APP_BT_REQ_AUTO_TEST, + // (uint32_t)g_at_status.param,cur_cmd_id, g_at_status.pfunc); + AT_TRACE(1, "_debug: _at_resp,auto_test wait : %d(ms)", wait_time); + } else { + _at_set_status(AT_CMD_ID_COUNT, AT_STATUS_FREE, 0, 0); + AT_TRACE(2, "AUTO_TEST:%s,wait time = %d(ms)", AT_CMD_RESP_TIME_OUT, + wait_time); } + } } -#define AT_PARAM_LEN 256 +#define AT_PARAM_LEN 256 uint8_t at_param_buff[AT_PARAM_LEN]; -extern "C" int auto_test_prase(uint8_t *cmd) -{ - int ret = 0; - uint8_t i; - uint8_t* cmd_name = NULL; - uint8_t* cmd_param = NULL; - uint8_t* p; - AT_CMD_ID_ENUM_T cmd_id; - uint32_t param_len; +extern "C" int auto_test_prase(uint8_t *cmd) { + int ret = 0; + uint8_t i; + uint8_t *cmd_name = NULL; + uint8_t *cmd_param = NULL; + uint8_t *p; + AT_CMD_ID_ENUM_T cmd_id; + uint32_t param_len; - if(NULL == cmd) - { - ret = -1; + if (NULL == cmd) { + ret = -1; + goto _func_end; + } + + AT_TRACE(1, "_debug: cmd = %s", cmd); + cmd_name = cmd; + p = (uint8_t *)strstr((char *)cmd, (char *)"="); + if (p) { + *p = 0; + cmd_param = (p + 1); + _at_trim(cmd_param); + } else { + cmd_param = NULL; + } + _at_trim(cmd_name); + + for (i = 0; i < sizeof(g_at_cmd_frame) / sizeof(AT_CMD_FRAME_T); i++) { + if (AT_CMD_ID_COUNT == g_at_cmd_frame[i].cmd_id) { + AT_TRACE(1, "_debug: undefined at cmd: %s.", cmd); + ret = -2; + goto _func_end; + } + if (!strcmp((const char *)cmd, (const char *)g_at_cmd_frame[i].cmd)) { + if (NULL == g_at_cmd_frame[i].pFunc) { + ret = -3; goto _func_end; - } + } - AT_TRACE(1,"_debug: cmd = %s",cmd); - cmd_name = cmd; - p = (uint8_t*)strstr((char*)cmd,(char*)"="); - if(p) - { - *p = 0; - cmd_param = (p + 1); - _at_trim(cmd_param); - } - else - { - cmd_param = NULL; - } - _at_trim(cmd_name); - - - for(i = 0; i < sizeof(g_at_cmd_frame)/sizeof(AT_CMD_FRAME_T); i++) - { - if(AT_CMD_ID_COUNT == g_at_cmd_frame[i].cmd_id) - { - AT_TRACE(1,"_debug: undefined at cmd: %s.",cmd); - ret = -2; - goto _func_end; + /* + if(AT_CMD_ID_REBOOT != g_at_cmd_frame[i].cmd_id) + { + if(_at_get_status() != AT_STATUS_FREE) + { + ret = -2; + AT_TRACE(3,"_debug: auto_test is busy. cmd = %s,cmd_id = + %d,cur_cmd_id = %d", g_at_cmd_frame[i].cmd_id,cmd,g_at_status.cur_cmd_id); + goto _func_end; + } + } + */ + cmd_id = g_at_cmd_frame[i].cmd_id; + // AT_TRACE(2,"_debug: %s,line= %d.",__func__,__LINE__); + // memset(at_param_buff,0,sizeof(at_param_buff)); + if (NULL != cmd_param) { + param_len = strlen((char *)cmd_param); + param_len = param_len < sizeof(at_param_buff) + ? param_len + : sizeof(at_param_buff) - 1; + if (param_len > 0) { + strncpy((char *)at_param_buff, (char *)cmd_param, param_len); } - if(!strcmp((const char *)cmd, (const char *)g_at_cmd_frame[i].cmd)) - { - if(NULL == g_at_cmd_frame[i].pFunc) - { - ret = -3; - goto _func_end; - } + } + _at_set_status(cmd_id, AT_STATUS_BUSY, (uint32_t)cmd_param, + (uint32_t)g_at_cmd_frame[i].pFunc); + at_enqueue_cmd((uint32_t)cmd_id, (uint32_t)at_param_buff, + (uint32_t)g_at_cmd_frame[i].pFunc); + // g_at_cmd_frame[i].pFunc((uint32_t)cmd_param,cmd_id); - /* - if(AT_CMD_ID_REBOOT != g_at_cmd_frame[i].cmd_id) - { - if(_at_get_status() != AT_STATUS_FREE) - { - ret = -2; - AT_TRACE(3,"_debug: auto_test is busy. cmd = %s,cmd_id = %d,cur_cmd_id = %d", - g_at_cmd_frame[i].cmd_id,cmd,g_at_status.cur_cmd_id); - goto _func_end; - } - } - */ - cmd_id = g_at_cmd_frame[i].cmd_id; - // AT_TRACE(2,"_debug: %s,line= %d.",__func__,__LINE__); - //memset(at_param_buff,0,sizeof(at_param_buff)); - if(NULL != cmd_param) - { - param_len = strlen((char*)cmd_param); - param_len = param_len < sizeof(at_param_buff) ? param_len : sizeof(at_param_buff) - 1; - if(param_len > 0) - { - strncpy((char*)at_param_buff,(char*)cmd_param,param_len); - } - } - _at_set_status(cmd_id,AT_STATUS_BUSY,(uint32_t)cmd_param,(uint32_t)g_at_cmd_frame[i].pFunc); - at_enqueue_cmd((uint32_t)cmd_id,(uint32_t)at_param_buff,(uint32_t)g_at_cmd_frame[i].pFunc); - //g_at_cmd_frame[i].pFunc((uint32_t)cmd_param,cmd_id); - - break; - } + break; } + } _func_end: - if(ret != 0) - { - AT_TRACE(1,"_debug: parse failed,ret = %d.",ret); - } - return ret; + if (ret != 0) { + AT_TRACE(1, "_debug: parse failed,ret = %d.", ret); + } + return ret; } -extern "C" int auto_test_send(char *resp) -{ - uint32_t i; - uint32_t cmd_count = 0; - int32_t ret = 0; +extern "C" int auto_test_send(char *resp) { + uint32_t i; + uint32_t cmd_count = 0; + int32_t ret = 0; - cmd_count = sizeof(g_at_cmd_resp)/sizeof(AT_CMD_RESP); - // AT_TRACE(1,"_debug: auto_test_send : %s",resp); - for(i = 0; i < cmd_count; i++) - { - if(AT_CMD_ID_COUNT == g_at_cmd_resp[i].cmd_id) - { - AT_TRACE(1,"_debug: auto_test_send: undefined at cmd resp, resp = %s.",resp); - ret = -1; - goto _func_end; - } - if(!strncmp((const char *)resp, (const char *)g_at_cmd_resp[i].resp,strlen((char*)g_at_cmd_resp[i].resp))) - { - if( g_at_cmd_resp[i].cmd_id == AT_CMD_ID_POWER_ON || - // g_at_cmd_resp[i].cmd_id == AT_CMD_ID_POWER_OFF || - // g_at_cmd_resp[i].cmd_id == AT_CMD_ID_REBOOT || - g_at_cmd_resp[i].cmd_id == g_at_status.cur_cmd_id) - { - TRACE_IMM(1,"AUTO_TEST:%s",resp); - _at_set_status(AT_CMD_ID_COUNT,AT_STATUS_FREE,0,0); - } - else - { - g_at_cmd_resp[i].count = 1; - AT_TRACE(2,"_debug: auto_test_send: set count to 1, i = %d, resp = %s.",i,resp); - } - break; - } + cmd_count = sizeof(g_at_cmd_resp) / sizeof(AT_CMD_RESP); + // AT_TRACE(1,"_debug: auto_test_send : %s",resp); + for (i = 0; i < cmd_count; i++) { + if (AT_CMD_ID_COUNT == g_at_cmd_resp[i].cmd_id) { + AT_TRACE(1, "_debug: auto_test_send: undefined at cmd resp, resp = %s.", + resp); + ret = -1; + goto _func_end; } + if (!strncmp((const char *)resp, (const char *)g_at_cmd_resp[i].resp, + strlen((char *)g_at_cmd_resp[i].resp))) { + if (g_at_cmd_resp[i].cmd_id == AT_CMD_ID_POWER_ON || + // g_at_cmd_resp[i].cmd_id == AT_CMD_ID_POWER_OFF || + // g_at_cmd_resp[i].cmd_id == AT_CMD_ID_REBOOT || + g_at_cmd_resp[i].cmd_id == g_at_status.cur_cmd_id) { + TRACE_IMM(1, "AUTO_TEST:%s", resp); + _at_set_status(AT_CMD_ID_COUNT, AT_STATUS_FREE, 0, 0); + } else { + g_at_cmd_resp[i].count = 1; + AT_TRACE(2, + "_debug: auto_test_send: set count to 1, i = %d, resp = %s.", + i, resp); + } + break; + } + } _func_end: - if(ret != 0) - { - AT_TRACE(1,"_debug: auto_test_send: %s undefine !!!!!",resp); - } - return ret; + if (ret != 0) { + AT_TRACE(1, "_debug: auto_test_send: %s undefine !!!!!", resp); + } + return ret; } -void at_test(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; +void at_test(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; - //AT_TRACE(0,"_debug: I am app_auto_test"); + // AT_TRACE(0,"_debug: I am app_auto_test"); - AUTO_TEST_SEND(AT_CMD_RESP_TEST); + AUTO_TEST_SEND(AT_CMD_RESP_TEST); } -void at_power_off(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; +void at_power_off(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; - AT_TRACE(0,"_debug: I am at_power_off"); - pmu_at_skip_shutdown(false); - system_shutdown(); + AT_TRACE(0, "_debug: I am at_power_off"); + pmu_at_skip_shutdown(false); + system_shutdown(); } -void at_reboot(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; +void at_reboot(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; - AT_TRACE(0,"_debug: I am at_reboot"); - //system_reset(); - app_reset(); + AT_TRACE(0, "_debug: I am at_reboot"); + // system_reset(); + app_reset(); } -void at_pmu_shutdown(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; +void at_pmu_shutdown(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; - //AT_TRACE(0,"_debug: I am at_reboot"); - //system_reset(); + // AT_TRACE(0,"_debug: I am at_reboot"); + // system_reset(); - AUTO_TEST_SEND(AT_CMD_RESP_PMU_SHUTDOWN); + AUTO_TEST_SEND(AT_CMD_RESP_PMU_SHUTDOWN); - // pmu_rtc_enable(); - // pmu_rtc_set(5); - // pmu_rtc_set_alarm(10); - pmu_at_skip_shutdown(true); - pmu_shutdown(); + // pmu_rtc_enable(); + // pmu_rtc_set(5); + // pmu_rtc_set_alarm(10); + pmu_at_skip_shutdown(true); + pmu_shutdown(); } -void at_connet(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; - //AT_TRACE(0,"_debug: I am at_connet"); - //app_tws_charger_box_opened(); - _at_resp(); +void at_connet(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; + // AT_TRACE(0,"_debug: I am at_connet"); + // app_tws_charger_box_opened(); + _at_resp(); } -void at_disconnet(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; +void at_disconnet(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; - //AT_TRACE(0,"_debug: I am at_disconnet"); - _at_resp(); + // AT_TRACE(0,"_debug: I am at_disconnet"); + _at_resp(); } -void at_pairing(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; +void at_pairing(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; - //AT_TRACE(0,"_debug: I am at_pairing"); - _at_resp(); + // AT_TRACE(0,"_debug: I am at_pairing"); + _at_resp(); } -void at_connect_tws(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; +void at_connect_tws(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; - //AT_TRACE(0,"_debug: I am at_connect_tws"); - _at_resp(); + // AT_TRACE(0,"_debug: I am at_connect_tws"); + _at_resp(); } -void at_call_setup(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; +void at_call_setup(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; - //AT_TRACE(0,"_debug: I am at_call_setup"); - _at_resp(); + // AT_TRACE(0,"_debug: I am at_call_setup"); + _at_resp(); } -void at_call_hangup(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; +void at_call_hangup(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; - //AT_TRACE(0,"_debug: I am at_call_hangup"); - _at_resp(); + // AT_TRACE(0,"_debug: I am at_call_hangup"); + _at_resp(); } static void music_on_callback(void); -#define MUSIC_ON_DELAY_MS 500 +#define MUSIC_ON_DELAY_MS 500 osTimerDef(MUSIC_ON_TIMER, (void (*)(void const *))music_on_callback); static osTimerId music_on_timer = NULL; static bool music_on_flag = 1; -static void music_on_callback(void) -{ - app_voice_report(APP_STATUS_INDICATION_WARNING, 0); +static void music_on_callback(void) { + app_voice_report(APP_STATUS_INDICATION_WARNING, 0); } -void at_music_on(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; +void at_music_on(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; - AT_TRACE(0,"_debug: I am at_music_on"); + AT_TRACE(0, "_debug: I am at_music_on"); - app_voice_report(APP_STATUS_INDICATION_WARNING, 0); - if(music_on_flag) - { - music_on_timer = osTimerCreate (osTimer(MUSIC_ON_TIMER), osTimerPeriodic, 0); - music_on_flag = 0; - } - osTimerStart(music_on_timer, MUSIC_ON_DELAY_MS); + app_voice_report(APP_STATUS_INDICATION_WARNING, 0); + if (music_on_flag) { + music_on_timer = osTimerCreate(osTimer(MUSIC_ON_TIMER), osTimerPeriodic, 0); + music_on_flag = 0; + } + osTimerStart(music_on_timer, MUSIC_ON_DELAY_MS); - _at_resp(); + _at_resp(); } -void at_music_suspend(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; +void at_music_suspend(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; - AT_TRACE(0,"_debug: I am at_music_suspend"); - osTimerStop(music_on_timer); - _at_resp(); + AT_TRACE(0, "_debug: I am at_music_suspend"); + osTimerStop(music_on_timer); + _at_resp(); } -void at_sleep(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; +void at_sleep(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; - AT_TRACE(0,"_debug: I am at_sleep"); + AT_TRACE(0, "_debug: I am at_sleep"); - //hal_sleep_enter_sleep(); - //app_bt_stop_sniff(); + // hal_sleep_enter_sleep(); + // app_bt_stop_sniff(); - _at_resp(); + _at_resp(); } -void at_sleep_clean(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; - unsigned int i; +void at_sleep_clean(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; + unsigned int i; - //AT_TRACE(0,"_debug: I am at_sleep_clean"); + // AT_TRACE(0,"_debug: I am at_sleep_clean"); - for(i = 0; i < sizeof(g_at_cmd_resp)/sizeof(AT_CMD_RESP); i++) - { - if(AT_CMD_ID_SLEEP_CLEAN == g_at_cmd_resp[i].cmd_id) - { - g_at_cmd_resp[i].count = 0; - break; - } - } - AUTO_TEST_SEND(AT_CMD_RESP_SLEEP_CLEAN); + for (i = 0; i < sizeof(g_at_cmd_resp) / sizeof(AT_CMD_RESP); i++) { + if (AT_CMD_ID_SLEEP_CLEAN == g_at_cmd_resp[i].cmd_id) { + g_at_cmd_resp[i].count = 0; + break; + } + } + AUTO_TEST_SEND(AT_CMD_RESP_SLEEP_CLEAN); } -void at_wakeup(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; +void at_wakeup(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; - //AT_TRACE(0,"_debug: I am at_wakeup"); - _at_resp(); + // AT_TRACE(0,"_debug: I am at_wakeup"); + _at_resp(); } -void at_switch_freq(uint32_t param0,uint32_t param1) -{ - char* p = (char*)param0; - char* user_str; - char* freq_str; - uint32_t user = 0xffffffff; - uint32_t freq = 0xffffffff; - int i; - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; +void at_switch_freq(uint32_t param0, uint32_t param1) { + char *p = (char *)param0; + char *user_str; + char *freq_str; + uint32_t user = 0xffffffff; + uint32_t freq = 0xffffffff; + int i; + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; - //AT_TRACE(0,"_debug: I am at_switch_freq"); - user_str = (char*)param0; - p = strstr(user_str,","); - if(p) - { - *p = 0; - p ++; - } - else - { - AT_TRACE(0,"_debug: at_switch_freq: param error 0."); - goto _func_end; - } - _at_trim((uint8_t*)user_str); - if(*user_str) - { - user = atoi(user_str); - } - else - { - AT_TRACE(0,"_debug: at_switch_freq: param error 1."); - goto _func_end; - } + // AT_TRACE(0,"_debug: I am at_switch_freq"); + user_str = (char *)param0; + p = strstr(user_str, ","); + if (p) { + *p = 0; + p++; + } else { + AT_TRACE(0, "_debug: at_switch_freq: param error 0."); + goto _func_end; + } + _at_trim((uint8_t *)user_str); + if (*user_str) { + user = atoi(user_str); + } else { + AT_TRACE(0, "_debug: at_switch_freq: param error 1."); + goto _func_end; + } - freq_str = p; - _at_trim((uint8_t*)freq_str); - if(*freq_str) - { - freq = atoi(freq_str); - } - else - { - AT_TRACE(0,"_debug: at_switch_freq: param error 2."); - goto _func_end; - } - if(user >= APP_SYSFREQ_USER_QTY || freq >= APP_SYSFREQ_FREQ_QTY) - { - AT_TRACE(0,"_debug: at_switch_freq: param error 3."); - goto _func_end; - } + freq_str = p; + _at_trim((uint8_t *)freq_str); + if (*freq_str) { + freq = atoi(freq_str); + } else { + AT_TRACE(0, "_debug: at_switch_freq: param error 2."); + goto _func_end; + } + if (user >= APP_SYSFREQ_USER_QTY || freq >= APP_SYSFREQ_FREQ_QTY) { + AT_TRACE(0, "_debug: at_switch_freq: param error 3."); + goto _func_end; + } - //AT_TRACE(2,"_debug: at_switch_freq: user = %d, freq = %d.",user,freq); - app_sysfreq_req((APP_SYSFREQ_USER_T)user,(APP_SYSFREQ_FREQ_T)freq); + // AT_TRACE(2,"_debug: at_switch_freq: user = %d, freq = %d.",user,freq); + app_sysfreq_req((APP_SYSFREQ_USER_T)user, (APP_SYSFREQ_FREQ_T)freq); - for(i = 0; i < 10000; i ++) - { - - } - AUTO_TEST_SEND("Switch freq ok."); + for (i = 0; i < 10000; i++) { + } + AUTO_TEST_SEND("Switch freq ok."); _func_end: - return; - + return; } -void at_power_on(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; +void at_power_on(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; - //AT_TRACE(0,"_debug: I am at_power_on"); - AUTO_TEST_SEND(AT_CMD_RESP_POWER_ON); + // AT_TRACE(0,"_debug: I am at_power_on"); + AUTO_TEST_SEND(AT_CMD_RESP_POWER_ON); } -void at_bt_init(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; - - //AT_TRACE(0,"_debug: I am at_bt_init"); - _at_resp(); +void at_bt_init(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; + // AT_TRACE(0,"_debug: I am at_bt_init"); + _at_resp(); } #include "app_key.h" - typedef struct - { - uint32_t key; - const char* key_str; - }AT_KEY_MAP; - AT_KEY_MAP key_code_map[] = - { - {(uint32_t)HAL_KEY_CODE_NONE,"KEY_CODE_NONE"}, - {(uint32_t)HAL_KEY_CODE_PWR ,"KEY_CODE_PWR" }, - {(uint32_t)HAL_KEY_CODE_FN1 ,"KEY_CODE_FN1" }, - {(uint32_t)HAL_KEY_CODE_FN2 ,"KEY_CODE_FN2" }, - {(uint32_t)HAL_KEY_CODE_FN3 ,"KEY_CODE_FN3" }, - {(uint32_t)HAL_KEY_CODE_FN4 ,"KEY_CODE_FN4" }, - {(uint32_t)HAL_KEY_CODE_FN5 ,"KEY_CODE_FN5" }, - {(uint32_t)HAL_KEY_CODE_FN6 ,"KEY_CODE_FN6" }, - {(uint32_t)HAL_KEY_CODE_FN7 ,"KEY_CODE_FN7" }, - {(uint32_t)HAL_KEY_CODE_FN8 ,"KEY_CODE_FN8" }, - {(uint32_t)HAL_KEY_CODE_FN9 ,"KEY_CODE_FN9" }, - {(uint32_t)HAL_KEY_CODE_FN10,"KEY_CODE_FN10"}, - {(uint32_t)HAL_KEY_CODE_FN11,"KEY_CODE_FN11"}, - {(uint32_t)HAL_KEY_CODE_FN12,"KEY_CODE_FN12"}, - {(uint32_t)HAL_KEY_CODE_FN13,"KEY_CODE_FN13"}, - {(uint32_t)HAL_KEY_CODE_FN14,"KEY_CODE_FN14"}, - {(uint32_t)HAL_KEY_CODE_FN15,"KEY_CODE_FN15"} - }; - AT_KEY_MAP key_event_map[] = - { - {(uint32_t)HAL_KEY_EVENT_NONE ,"KEY_EVENT_NONE" }, - {(uint32_t)HAL_KEY_EVENT_DOWN ,"KEY_EVENT_DOWN" }, - {(uint32_t)HAL_KEY_EVENT_FIRST_DOWN ,"KEY_EVENT_FIRST_DOWN" }, - {(uint32_t)HAL_KEY_EVENT_CONTINUED_DOWN ,"KEY_EVENT_CONTINUED_DOWN" }, - {(uint32_t)HAL_KEY_EVENT_UP ,"KEY_EVENT_UP" }, - {(uint32_t)HAL_KEY_EVENT_LONGPRESS ,"KEY_EVENT_LONGPRESS" }, - {(uint32_t)HAL_KEY_EVENT_LONGLONGPRESS ,"KEY_EVENT_LONGLONGPRESS" }, - {(uint32_t)HAL_KEY_EVENT_CLICK ,"KEY_EVENT_CLICK" }, - {(uint32_t)HAL_KEY_EVENT_DOUBLECLICK ,"KEY_EVENT_DOUBLECLICK" }, - {(uint32_t)HAL_KEY_EVENT_TRIPLECLICK ,"KEY_EVENT_TRIPLECLICK" }, - {(uint32_t)HAL_KEY_EVENT_ULTRACLICK ,"KEY_EVENT_ULTRACLICK" }, - {(uint32_t)HAL_KEY_EVENT_RAMPAGECLICK ,"KEY_EVENT_RAMPAGECLICK" }, - {(uint32_t)HAL_KEY_EVENT_REPEAT ,"KEY_EVENT_REPEAT" }, - {(uint32_t)HAL_KEY_EVENT_GROUPKEY_DOWN ,"KEY_EVENT_GROUPKEY_DOWN" }, - {(uint32_t)HAL_KEY_EVENT_GROUPKEY_REPEAT ,"KEY_EVENT_GROUPKEY_REPEAT" }, - {(uint32_t)HAL_KEY_EVENT_INITDOWN ,"KEY_EVENT_INITDOWN" }, - {(uint32_t)HAL_KEY_EVENT_INITUP ,"KEY_EVENT_INITUP" }, - {(uint32_t)HAL_KEY_EVENT_INITLONGPRESS ,"KEY_EVENT_INITLONGPRESS" }, - {(uint32_t)HAL_KEY_EVENT_INITLONGLONGPRESS,"KEY_EVENT_INITLONGLONGPRESS"}, - {(uint32_t)HAL_KEY_EVENT_INITFINISHED ,"KEY_EVENT_INITFINISHED" } - }; -void at_simulate_key(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - char* code_str; - char* event_str; - uint32_t key_code = 0; - uint16_t key_event = 0; - char* p; - uint32_t i; +typedef struct { + uint32_t key; + const char *key_str; +} AT_KEY_MAP; +AT_KEY_MAP key_code_map[] = {{(uint32_t)HAL_KEY_CODE_NONE, "KEY_CODE_NONE"}, + {(uint32_t)HAL_KEY_CODE_PWR, "KEY_CODE_PWR"}, + {(uint32_t)HAL_KEY_CODE_FN1, "KEY_CODE_FN1"}, + {(uint32_t)HAL_KEY_CODE_FN2, "KEY_CODE_FN2"}, + {(uint32_t)HAL_KEY_CODE_FN3, "KEY_CODE_FN3"}, + {(uint32_t)HAL_KEY_CODE_FN4, "KEY_CODE_FN4"}, + {(uint32_t)HAL_KEY_CODE_FN5, "KEY_CODE_FN5"}, + {(uint32_t)HAL_KEY_CODE_FN6, "KEY_CODE_FN6"}, + {(uint32_t)HAL_KEY_CODE_FN7, "KEY_CODE_FN7"}, + {(uint32_t)HAL_KEY_CODE_FN8, "KEY_CODE_FN8"}, + {(uint32_t)HAL_KEY_CODE_FN9, "KEY_CODE_FN9"}, + {(uint32_t)HAL_KEY_CODE_FN10, "KEY_CODE_FN10"}, + {(uint32_t)HAL_KEY_CODE_FN11, "KEY_CODE_FN11"}, + {(uint32_t)HAL_KEY_CODE_FN12, "KEY_CODE_FN12"}, + {(uint32_t)HAL_KEY_CODE_FN13, "KEY_CODE_FN13"}, + {(uint32_t)HAL_KEY_CODE_FN14, "KEY_CODE_FN14"}, + {(uint32_t)HAL_KEY_CODE_FN15, "KEY_CODE_FN15"}}; +AT_KEY_MAP key_event_map[] = { + {(uint32_t)HAL_KEY_EVENT_NONE, "KEY_EVENT_NONE"}, + {(uint32_t)HAL_KEY_EVENT_DOWN, "KEY_EVENT_DOWN"}, + {(uint32_t)HAL_KEY_EVENT_FIRST_DOWN, "KEY_EVENT_FIRST_DOWN"}, + {(uint32_t)HAL_KEY_EVENT_CONTINUED_DOWN, "KEY_EVENT_CONTINUED_DOWN"}, + {(uint32_t)HAL_KEY_EVENT_UP, "KEY_EVENT_UP"}, + {(uint32_t)HAL_KEY_EVENT_LONGPRESS, "KEY_EVENT_LONGPRESS"}, + {(uint32_t)HAL_KEY_EVENT_LONGLONGPRESS, "KEY_EVENT_LONGLONGPRESS"}, + {(uint32_t)HAL_KEY_EVENT_CLICK, "KEY_EVENT_CLICK"}, + {(uint32_t)HAL_KEY_EVENT_DOUBLECLICK, "KEY_EVENT_DOUBLECLICK"}, + {(uint32_t)HAL_KEY_EVENT_TRIPLECLICK, "KEY_EVENT_TRIPLECLICK"}, + {(uint32_t)HAL_KEY_EVENT_ULTRACLICK, "KEY_EVENT_ULTRACLICK"}, + {(uint32_t)HAL_KEY_EVENT_RAMPAGECLICK, "KEY_EVENT_RAMPAGECLICK"}, + {(uint32_t)HAL_KEY_EVENT_REPEAT, "KEY_EVENT_REPEAT"}, + {(uint32_t)HAL_KEY_EVENT_GROUPKEY_DOWN, "KEY_EVENT_GROUPKEY_DOWN"}, + {(uint32_t)HAL_KEY_EVENT_GROUPKEY_REPEAT, "KEY_EVENT_GROUPKEY_REPEAT"}, + {(uint32_t)HAL_KEY_EVENT_INITDOWN, "KEY_EVENT_INITDOWN"}, + {(uint32_t)HAL_KEY_EVENT_INITUP, "KEY_EVENT_INITUP"}, + {(uint32_t)HAL_KEY_EVENT_INITLONGPRESS, "KEY_EVENT_INITLONGPRESS"}, + {(uint32_t)HAL_KEY_EVENT_INITLONGLONGPRESS, "KEY_EVENT_INITLONGLONGPRESS"}, + {(uint32_t)HAL_KEY_EVENT_INITFINISHED, "KEY_EVENT_INITFINISHED"}}; +void at_simulate_key(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + char *code_str; + char *event_str; + uint32_t key_code = 0; + uint16_t key_event = 0; + char *p; + uint32_t i; - cmd_id = cmd_id; - AT_TRACE(0,"_debug: I am at_simulate_key"); - p = (char*)param0; - code_str = p; - p = strstr(p,","); - if(p) - { - *p = 0; - p++; - } - else - { - goto _func_end; - } + cmd_id = cmd_id; + AT_TRACE(0, "_debug: I am at_simulate_key"); + p = (char *)param0; + code_str = p; + p = strstr(p, ","); + if (p) { + *p = 0; + p++; + } else { + goto _func_end; + } - event_str = p; - _at_trim((uint8_t*)code_str); - _at_trim((uint8_t*)event_str); - AT_TRACE(2,"_debug: code_str = %s, event_str = %s.",code_str,event_str); - for(i = 0; i < sizeof(key_code_map)/sizeof(AT_KEY_MAP); i ++) - { - if(strncmp(code_str,key_code_map[i].key_str,strlen(code_str)) == 0) - { - key_code = key_code_map[i].key; - break; - } + event_str = p; + _at_trim((uint8_t *)code_str); + _at_trim((uint8_t *)event_str); + AT_TRACE(2, "_debug: code_str = %s, event_str = %s.", code_str, event_str); + for (i = 0; i < sizeof(key_code_map) / sizeof(AT_KEY_MAP); i++) { + if (strncmp(code_str, key_code_map[i].key_str, strlen(code_str)) == 0) { + key_code = key_code_map[i].key; + break; } + } - if(i == sizeof(key_code_map)/sizeof(AT_KEY_MAP)) - { - goto _func_end; + if (i == sizeof(key_code_map) / sizeof(AT_KEY_MAP)) { + goto _func_end; + } + + for (i = 0; i < sizeof(key_event_map) / sizeof(AT_KEY_MAP); i++) { + if (strncmp(event_str, key_event_map[i].key_str, strlen(event_str)) == 0) { + key_event = (key_event_map[i].key & 0xffff); + break; } + } - for(i = 0; i < sizeof(key_event_map)/sizeof(AT_KEY_MAP); i ++) - { - if(strncmp(event_str,key_event_map[i].key_str,strlen(event_str)) == 0) - { - key_event = (key_event_map[i].key & 0xffff); - break; - } - } + if (i == sizeof(key_event_map) / sizeof(AT_KEY_MAP)) { + goto _func_end; + } + AT_TRACE(2, "_debug: key_code = %d, key_event = %d.", key_code, key_event); - if(i == sizeof(key_event_map)/sizeof(AT_KEY_MAP)) - { - goto _func_end; - } - AT_TRACE(2,"_debug: key_code = %d, key_event = %d.",key_code,key_event); - - if(key_code == HAL_KEY_CODE_FN15 && key_event == HAL_KEY_EVENT_CLICK) - { + if (key_code == HAL_KEY_CODE_FN15 && key_event == HAL_KEY_EVENT_CLICK) { #if defined(BT_USB_AUDIO_DUAL_MODE_TEST) - test_btusb_switch_to_bt(); - //osDelay(5000); + test_btusb_switch_to_bt(); + // osDelay(5000); #endif - } - if(key_code == HAL_KEY_CODE_FN14 && key_event == HAL_KEY_EVENT_CLICK) - { + } + if (key_code == HAL_KEY_CODE_FN14 && key_event == HAL_KEY_EVENT_CLICK) { #if defined(BT_USB_AUDIO_DUAL_MODE_TEST) - test_btusb_switch_to_usb(); + test_btusb_switch_to_usb(); #endif - } - AUTO_TEST_SEND(AT_CMD_RESP_SIMULATE_KEY); - //simul_key_event_process((uint32_t)key_code,(uint16_t)key_event); - + } + AUTO_TEST_SEND(AT_CMD_RESP_SIMULATE_KEY); + // simul_key_event_process((uint32_t)key_code,(uint16_t)key_event); _func_end: - return; + return; } -enum AT_FLASH_REGION_ID -{ - FLASH_REGION_ID_CODE, - FLASH_REGION_ID_FREE, - FLASH_REGION_ID_CRASH_DUMP, - FLASH_REGION_ID_AUD, - FLASH_REGION_ID_USERDATA, - FLASH_REGION_ID_FACTORY, - FLASH_REGION_ID_NUMBER, - }; +enum AT_FLASH_REGION_ID { + FLASH_REGION_ID_CODE, + FLASH_REGION_ID_FREE, + FLASH_REGION_ID_CRASH_DUMP, + FLASH_REGION_ID_AUD, + FLASH_REGION_ID_USERDATA, + FLASH_REGION_ID_FACTORY, + FLASH_REGION_ID_NUMBER, +}; -typedef struct _flash_region_info -{ - enum AT_FLASH_REGION_ID id; - uint32_t start_addr; - uint32_t end_addr; -}AT_FLASH_REGION_INFO; -#define AT_ALIGN(x,a) (uint32_t)(((x + a - 1)/a) * a) +typedef struct _flash_region_info { + enum AT_FLASH_REGION_ID id; + uint32_t start_addr; + uint32_t end_addr; +} AT_FLASH_REGION_INFO; +#define AT_ALIGN(x, a) (uint32_t)(((x + a - 1) / a) * a) extern uint32_t __flash_start; extern uint32_t __flash_end; @@ -1081,303 +978,284 @@ extern uint32_t __userdata_end; extern uint32_t __factory_start; extern uint32_t __factory_end; extern uint32_t __free_flash; -#define AT_FLASH_SECTOR_SIZE 0x1000 -#define AT_FLASH_BLOCK_SIZE 0x10000 +#define AT_FLASH_SECTOR_SIZE 0x1000 +#define AT_FLASH_BLOCK_SIZE 0x10000 AT_FLASH_REGION_INFO region_info[] = { - {FLASH_REGION_ID_CODE, - FLASH_C_TO_NC(AT_ALIGN((uint32_t)(&__flash_start),AT_FLASH_SECTOR_SIZE)), - FLASH_C_TO_NC(AT_ALIGN((uint32_t)(&__flash_end),AT_FLASH_SECTOR_SIZE))}, - {FLASH_REGION_ID_FREE, - FLASH_C_TO_NC(AT_ALIGN((uint32_t)(&__flash_end + AT_FLASH_SECTOR_SIZE),AT_FLASH_SECTOR_SIZE)), - FLASH_C_TO_NC(AT_ALIGN((uint32_t)(&__flash_end + AT_FLASH_SECTOR_SIZE + 16*AT_FLASH_SECTOR_SIZE),AT_FLASH_SECTOR_SIZE))},//AT_ALIGN((uint32_t)(&__crash_dump_start),AT_FLASH_SECTOR_SIZE)}, - {FLASH_REGION_ID_CRASH_DUMP, - FLASH_C_TO_NC(AT_ALIGN((uint32_t)(&__flash_end + AT_FLASH_SECTOR_SIZE + 16*AT_FLASH_SECTOR_SIZE),AT_FLASH_SECTOR_SIZE)),//AT_ALIGN((uint32_t)(&__crash_dump_start),AT_FLASH_SECTOR_SIZE), - FLASH_C_TO_NC(AT_ALIGN((uint32_t)(&__flash_end + AT_FLASH_SECTOR_SIZE + 32*AT_FLASH_SECTOR_SIZE),AT_FLASH_SECTOR_SIZE))},//AT_ALIGN((uint32_t)(&__crash_dump_end),AT_FLASH_SECTOR_SIZE)}, - {FLASH_REGION_ID_AUD, - AT_ALIGN((uint32_t)(&__aud_start),AT_FLASH_SECTOR_SIZE), - AT_ALIGN((uint32_t)(&__aud_end),AT_FLASH_SECTOR_SIZE)}, - {FLASH_REGION_ID_USERDATA, - AT_ALIGN((uint32_t)(&__userdata_start),AT_FLASH_SECTOR_SIZE), - AT_ALIGN((uint32_t)(&__userdata_end),AT_FLASH_SECTOR_SIZE)}, - {FLASH_REGION_ID_FACTORY, - AT_ALIGN((uint32_t)(&__factory_start) + 20*AT_FLASH_SECTOR_SIZE,AT_FLASH_SECTOR_SIZE),//AT_ALIGN((uint32_t)(&__factory_start),AT_FLASH_SECTOR_SIZE), - AT_ALIGN((uint32_t)(&__flash_end) + 30*AT_FLASH_SECTOR_SIZE,AT_FLASH_SECTOR_SIZE)},//AT_ALIGN((uint32_t)(&__factory_end),AT_FLASH_SECTOR_SIZE)}, - }; + {FLASH_REGION_ID_CODE, + FLASH_C_TO_NC(AT_ALIGN((uint32_t)(&__flash_start), AT_FLASH_SECTOR_SIZE)), + FLASH_C_TO_NC(AT_ALIGN((uint32_t)(&__flash_end), AT_FLASH_SECTOR_SIZE))}, + {FLASH_REGION_ID_FREE, + FLASH_C_TO_NC(AT_ALIGN((uint32_t)(&__flash_end + AT_FLASH_SECTOR_SIZE), + AT_FLASH_SECTOR_SIZE)), + FLASH_C_TO_NC(AT_ALIGN( + (uint32_t)(&__flash_end + AT_FLASH_SECTOR_SIZE + + 16 * AT_FLASH_SECTOR_SIZE), + AT_FLASH_SECTOR_SIZE))}, // AT_ALIGN((uint32_t)(&__crash_dump_start),AT_FLASH_SECTOR_SIZE)}, + {FLASH_REGION_ID_CRASH_DUMP, + FLASH_C_TO_NC(AT_ALIGN( + (uint32_t)(&__flash_end + AT_FLASH_SECTOR_SIZE + + 16 * AT_FLASH_SECTOR_SIZE), + AT_FLASH_SECTOR_SIZE)), // AT_ALIGN((uint32_t)(&__crash_dump_start),AT_FLASH_SECTOR_SIZE), + FLASH_C_TO_NC(AT_ALIGN( + (uint32_t)(&__flash_end + AT_FLASH_SECTOR_SIZE + + 32 * AT_FLASH_SECTOR_SIZE), + AT_FLASH_SECTOR_SIZE))}, // AT_ALIGN((uint32_t)(&__crash_dump_end),AT_FLASH_SECTOR_SIZE)}, + {FLASH_REGION_ID_AUD, + AT_ALIGN((uint32_t)(&__aud_start), AT_FLASH_SECTOR_SIZE), + AT_ALIGN((uint32_t)(&__aud_end), AT_FLASH_SECTOR_SIZE)}, + {FLASH_REGION_ID_USERDATA, + AT_ALIGN((uint32_t)(&__userdata_start), AT_FLASH_SECTOR_SIZE), + AT_ALIGN((uint32_t)(&__userdata_end), AT_FLASH_SECTOR_SIZE)}, + {FLASH_REGION_ID_FACTORY, + AT_ALIGN( + (uint32_t)(&__factory_start) + 20 * AT_FLASH_SECTOR_SIZE, + AT_FLASH_SECTOR_SIZE), // AT_ALIGN((uint32_t)(&__factory_start),AT_FLASH_SECTOR_SIZE), + AT_ALIGN( + (uint32_t)(&__flash_end) + 30 * AT_FLASH_SECTOR_SIZE, + AT_FLASH_SECTOR_SIZE)}, // AT_ALIGN((uint32_t)(&__factory_end),AT_FLASH_SECTOR_SIZE)}, +}; uint8_t at_buff_r[AT_FLASH_SECTOR_SIZE]; uint8_t at_buff_r1[AT_FLASH_SECTOR_SIZE]; uint8_t at_buff_w[AT_FLASH_SECTOR_SIZE]; uint8_t at_buff_b[AT_FLASH_SECTOR_SIZE]; -int32_t _at_norflash_test(uint32_t addr,uint32_t size,uint8_t is_restore) -{ - uint32_t start_addr; - uint32_t i,j; - uint8_t value = 0; - int32_t ret = 0; - enum HAL_NORFLASH_RET_T result = HAL_NORFLASH_OK; - - for(i = 0; i < size/AT_FLASH_SECTOR_SIZE; i++) - { - // erase checking. - start_addr = addr + i * AT_FLASH_SECTOR_SIZE; - if(is_restore != 0) - { - result = hal_norflash_read(HAL_NORFLASH_ID_0,start_addr,at_buff_b,AT_FLASH_SECTOR_SIZE); - if(result != HAL_NORFLASH_OK) - { - ret = -2; - goto _func_end; - } - } - result = hal_norflash_erase(HAL_NORFLASH_ID_0,start_addr,AT_FLASH_SECTOR_SIZE); - if(result != HAL_NORFLASH_OK) - { - ret = -1; - goto _func_end; - } - result = hal_norflash_read(HAL_NORFLASH_ID_0,start_addr,at_buff_r,AT_FLASH_SECTOR_SIZE); - if(result != HAL_NORFLASH_OK) - { - ret = -2; - goto _func_end; - } - for(j = 0; j < AT_FLASH_SECTOR_SIZE; j++) - { - if(at_buff_r[j] != 0xff) - { - ret = -3; - goto _func_end; - } - } - - // write/read checking - for(j = 0; j < AT_FLASH_SECTOR_SIZE; j++) - { - at_buff_w[j] = value ++; - } - result = hal_norflash_write(HAL_NORFLASH_ID_0,start_addr,at_buff_w,AT_FLASH_SECTOR_SIZE); - if(result != HAL_NORFLASH_OK) - { - ret = -4; - goto _func_end; - } - - result = hal_norflash_read(HAL_NORFLASH_ID_0,start_addr,at_buff_r,AT_FLASH_SECTOR_SIZE); - if(result != HAL_NORFLASH_OK) - { - ret = -5; - goto _func_end; - } - for(j = 0; j < AT_FLASH_SECTOR_SIZE; j++) - { - if(at_buff_r[j] != at_buff_w[j]) - { - ret = -6; - goto _func_end; - } - } - if(is_restore != 0) - { - result = hal_norflash_erase(HAL_NORFLASH_ID_0,start_addr,AT_FLASH_SECTOR_SIZE); - if(result != HAL_NORFLASH_OK) - { - ret = -7; - break; - } - result = hal_norflash_write(HAL_NORFLASH_ID_0,start_addr,at_buff_b,AT_FLASH_SECTOR_SIZE); - if(result != HAL_NORFLASH_OK) - { - ret = -8; - break; - } - result = hal_norflash_read(HAL_NORFLASH_ID_0,start_addr,at_buff_r,AT_FLASH_SECTOR_SIZE); - if(result != HAL_NORFLASH_OK) - { - ret = -9; - goto _func_end; - } - for(j = 0; j < AT_FLASH_SECTOR_SIZE; j++) - { - if(at_buff_r[j] != at_buff_b[j]) - { - ret = -10; - goto _func_end; - } - } - - } +int32_t _at_norflash_test(uint32_t addr, uint32_t size, uint8_t is_restore) { + uint32_t start_addr; + uint32_t i, j; + uint8_t value = 0; + int32_t ret = 0; + enum HAL_NORFLASH_RET_T result = HAL_NORFLASH_OK; + for (i = 0; i < size / AT_FLASH_SECTOR_SIZE; i++) { + // erase checking. + start_addr = addr + i * AT_FLASH_SECTOR_SIZE; + if (is_restore != 0) { + result = hal_norflash_read(HAL_NORFLASH_ID_0, start_addr, at_buff_b, + AT_FLASH_SECTOR_SIZE); + if (result != HAL_NORFLASH_OK) { + ret = -2; + goto _func_end; + } } + result = + hal_norflash_erase(HAL_NORFLASH_ID_0, start_addr, AT_FLASH_SECTOR_SIZE); + if (result != HAL_NORFLASH_OK) { + ret = -1; + goto _func_end; + } + result = hal_norflash_read(HAL_NORFLASH_ID_0, start_addr, at_buff_r, + AT_FLASH_SECTOR_SIZE); + if (result != HAL_NORFLASH_OK) { + ret = -2; + goto _func_end; + } + for (j = 0; j < AT_FLASH_SECTOR_SIZE; j++) { + if (at_buff_r[j] != 0xff) { + ret = -3; + goto _func_end; + } + } + + // write/read checking + for (j = 0; j < AT_FLASH_SECTOR_SIZE; j++) { + at_buff_w[j] = value++; + } + result = hal_norflash_write(HAL_NORFLASH_ID_0, start_addr, at_buff_w, + AT_FLASH_SECTOR_SIZE); + if (result != HAL_NORFLASH_OK) { + ret = -4; + goto _func_end; + } + + result = hal_norflash_read(HAL_NORFLASH_ID_0, start_addr, at_buff_r, + AT_FLASH_SECTOR_SIZE); + if (result != HAL_NORFLASH_OK) { + ret = -5; + goto _func_end; + } + for (j = 0; j < AT_FLASH_SECTOR_SIZE; j++) { + if (at_buff_r[j] != at_buff_w[j]) { + ret = -6; + goto _func_end; + } + } + if (is_restore != 0) { + result = hal_norflash_erase(HAL_NORFLASH_ID_0, start_addr, + AT_FLASH_SECTOR_SIZE); + if (result != HAL_NORFLASH_OK) { + ret = -7; + break; + } + result = hal_norflash_write(HAL_NORFLASH_ID_0, start_addr, at_buff_b, + AT_FLASH_SECTOR_SIZE); + if (result != HAL_NORFLASH_OK) { + ret = -8; + break; + } + result = hal_norflash_read(HAL_NORFLASH_ID_0, start_addr, at_buff_r, + AT_FLASH_SECTOR_SIZE); + if (result != HAL_NORFLASH_OK) { + ret = -9; + goto _func_end; + } + for (j = 0; j < AT_FLASH_SECTOR_SIZE; j++) { + if (at_buff_r[j] != at_buff_b[j]) { + ret = -10; + goto _func_end; + } + } + } + } _func_end: - //AT_TRACE(1,"_debug: flash checking end. ret = %d.",ret); - return ret; - + // AT_TRACE(1,"_debug: flash checking end. ret = %d.",ret); + return ret; } +AT_FLASH_REGION_INFO *_at_norflash_get_region_info(enum AT_FLASH_REGION_ID id) { + uint32_t i; -AT_FLASH_REGION_INFO* _at_norflash_get_region_info(enum AT_FLASH_REGION_ID id) -{ - uint32_t i; - - for(i = 0; i < sizeof(region_info)/sizeof(AT_FLASH_REGION_INFO); i++) - { - if(region_info[i].id == id) - { - return ®ion_info[i]; - } + for (i = 0; i < sizeof(region_info) / sizeof(AT_FLASH_REGION_INFO); i++) { + if (region_info[i].id == id) { + return ®ion_info[i]; } - return NULL; + } + return NULL; } -void at_norflash(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - // uint32_t start_addr = 0; - // uint32_t end_addr = 0; - // uint32_t size = 0; - //uint8_t check_code = 1; - //uint8_t check_free = 1; - //uint8_t check_crash_dump = 1; - //uint8_t check_aud = 1; - //uint8_t check_userdata = 1; - //uint8_t check_factory = 1; - AT_FLASH_REGION_INFO* region_info; - int32_t result = 0; - uint8_t error_code = 0; - cmd_id = cmd_id; - uint32_t lock_pri; +void at_norflash(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + // uint32_t start_addr = 0; + // uint32_t end_addr = 0; + // uint32_t size = 0; + // uint8_t check_code = 1; + // uint8_t check_free = 1; + // uint8_t check_crash_dump = 1; + // uint8_t check_aud = 1; + // uint8_t check_userdata = 1; + // uint8_t check_factory = 1; + AT_FLASH_REGION_INFO *region_info; + int32_t result = 0; + uint8_t error_code = 0; + cmd_id = cmd_id; + uint32_t lock_pri; - int idex; - char *p; + int idex; + char *p; - p = (char*)param0; - idex = atoi(p); + p = (char *)param0; + idex = atoi(p); - error_code = error_code; - AT_TRACE(0,"_debug:at_norflash begin."); - switch(idex) - { - case 1: - { - AT_TRACE(0,"_debug:at_norflash check code region."); - region_info = _at_norflash_get_region_info(FLASH_REGION_ID_CODE); - AT_TRACE(4,"%s: region_info, id = %d,start = 0x%x,end = 0x%x.", - __func__,region_info->id,region_info->start_addr,region_info->end_addr); - lock_pri = int_lock(); - result = _at_norflash_test(region_info->start_addr, - (region_info->end_addr - region_info->start_addr), - 1); - int_unlock(lock_pri); - if(result != 0) - { - error_code = 1; - goto _func_fail; - } - break; - } - case 2: - { - AT_TRACE(0,"_debug:at_norflash check free region."); - region_info = _at_norflash_get_region_info(FLASH_REGION_ID_FREE); - AT_TRACE(4,"%s: region_info, id = %d,start = 0x%x,end = 0x%x.", - __func__,region_info->id,region_info->start_addr,region_info->end_addr); - lock_pri = int_lock(); - result = _at_norflash_test(region_info->start_addr, - (region_info->end_addr - region_info->start_addr), - 0); - int_unlock(lock_pri); - if(result != 0) - { - error_code = 2; - goto _func_fail; - } - break; - } - case 3: - { - AT_TRACE(0,"_debug:at_norflash check crash_dump region."); - region_info = _at_norflash_get_region_info(FLASH_REGION_ID_CRASH_DUMP); - AT_TRACE(4,"%s: region_info, id = %d,start = 0x%x,end = 0x%x.", - __func__,region_info->id,region_info->start_addr,region_info->end_addr); - lock_pri = int_lock(); - result = _at_norflash_test(region_info->start_addr, - (region_info->end_addr - region_info->start_addr), - 1); - int_unlock(lock_pri); - if(result != 0) - { - error_code = 3; - goto _func_fail; - } - break; - } - case 4: - { - AT_TRACE(0,"_debug:at_norflash check aud region."); - region_info = _at_norflash_get_region_info(FLASH_REGION_ID_AUD); - AT_TRACE(4,"%s: region_info, id = %d,start = 0x%x,end = 0x%x.", - __func__,region_info->id,region_info->start_addr,region_info->end_addr); - lock_pri = int_lock(); - result = _at_norflash_test(region_info->start_addr, - (region_info->end_addr - region_info->start_addr), - 1); - int_unlock(lock_pri); - if(result != 0) - { - error_code = 4; - goto _func_fail; - } - break; - } - case 5: - { - AT_TRACE(0,"_debug:at_norflash check userdata region."); - region_info = _at_norflash_get_region_info(FLASH_REGION_ID_USERDATA); - AT_TRACE(4,"%s: region_info, id = %d,start = 0x%x,end = 0x%x.", - __func__,region_info->id,region_info->start_addr,region_info->end_addr); - lock_pri = int_lock(); - result = _at_norflash_test(region_info->start_addr, - (region_info->end_addr - region_info->start_addr), - 1); - int_unlock(lock_pri); - if(result != 0) - { - error_code = 5; - goto _func_fail; - } - break; - } - case 6: - { - AT_TRACE(0,"_debug:at_norflash check factory region."); - region_info = _at_norflash_get_region_info(FLASH_REGION_ID_FACTORY); - AT_TRACE(4,"%s: region_info, id = %d,start = 0x%x,end = 0x%x.", - __func__,region_info->id,region_info->start_addr,region_info->end_addr); - lock_pri = int_lock(); - result = _at_norflash_test(region_info->start_addr, - (region_info->end_addr - region_info->start_addr), - 1); - int_unlock(lock_pri); - if(result != 0) - { - error_code = 6; - goto _func_fail; - } - break; - } - default: - AT_TRACE(0,"_debug:at_norflash idex default."); - break; + error_code = error_code; + AT_TRACE(0, "_debug:at_norflash begin."); + switch (idex) { + case 1: { + AT_TRACE(0, "_debug:at_norflash check code region."); + region_info = _at_norflash_get_region_info(FLASH_REGION_ID_CODE); + AT_TRACE(4, "%s: region_info, id = %d,start = 0x%x,end = 0x%x.", __func__, + region_info->id, region_info->start_addr, region_info->end_addr); + lock_pri = int_lock(); + result = + _at_norflash_test(region_info->start_addr, + (region_info->end_addr - region_info->start_addr), 1); + int_unlock(lock_pri); + if (result != 0) { + error_code = 1; + goto _func_fail; } - //AT_TRACE(0,"_debug: I am at_norflash"); - error_code = 0; - AUTO_TEST_SEND(AT_CMD_RESP_NORFLASH); + break; + } + case 2: { + AT_TRACE(0, "_debug:at_norflash check free region."); + region_info = _at_norflash_get_region_info(FLASH_REGION_ID_FREE); + AT_TRACE(4, "%s: region_info, id = %d,start = 0x%x,end = 0x%x.", __func__, + region_info->id, region_info->start_addr, region_info->end_addr); + lock_pri = int_lock(); + result = + _at_norflash_test(region_info->start_addr, + (region_info->end_addr - region_info->start_addr), 0); + int_unlock(lock_pri); + if (result != 0) { + error_code = 2; + goto _func_fail; + } + break; + } + case 3: { + AT_TRACE(0, "_debug:at_norflash check crash_dump region."); + region_info = _at_norflash_get_region_info(FLASH_REGION_ID_CRASH_DUMP); + AT_TRACE(4, "%s: region_info, id = %d,start = 0x%x,end = 0x%x.", __func__, + region_info->id, region_info->start_addr, region_info->end_addr); + lock_pri = int_lock(); + result = + _at_norflash_test(region_info->start_addr, + (region_info->end_addr - region_info->start_addr), 1); + int_unlock(lock_pri); + if (result != 0) { + error_code = 3; + goto _func_fail; + } + break; + } + case 4: { + AT_TRACE(0, "_debug:at_norflash check aud region."); + region_info = _at_norflash_get_region_info(FLASH_REGION_ID_AUD); + AT_TRACE(4, "%s: region_info, id = %d,start = 0x%x,end = 0x%x.", __func__, + region_info->id, region_info->start_addr, region_info->end_addr); + lock_pri = int_lock(); + result = + _at_norflash_test(region_info->start_addr, + (region_info->end_addr - region_info->start_addr), 1); + int_unlock(lock_pri); + if (result != 0) { + error_code = 4; + goto _func_fail; + } + break; + } + case 5: { + AT_TRACE(0, "_debug:at_norflash check userdata region."); + region_info = _at_norflash_get_region_info(FLASH_REGION_ID_USERDATA); + AT_TRACE(4, "%s: region_info, id = %d,start = 0x%x,end = 0x%x.", __func__, + region_info->id, region_info->start_addr, region_info->end_addr); + lock_pri = int_lock(); + result = + _at_norflash_test(region_info->start_addr, + (region_info->end_addr - region_info->start_addr), 1); + int_unlock(lock_pri); + if (result != 0) { + error_code = 5; + goto _func_fail; + } + break; + } + case 6: { + AT_TRACE(0, "_debug:at_norflash check factory region."); + region_info = _at_norflash_get_region_info(FLASH_REGION_ID_FACTORY); + AT_TRACE(4, "%s: region_info, id = %d,start = 0x%x,end = 0x%x.", __func__, + region_info->id, region_info->start_addr, region_info->end_addr); + lock_pri = int_lock(); + result = + _at_norflash_test(region_info->start_addr, + (region_info->end_addr - region_info->start_addr), 1); + int_unlock(lock_pri); + if (result != 0) { + error_code = 6; + goto _func_fail; + } + break; + } + default: + AT_TRACE(0, "_debug:at_norflash idex default."); + break; + } + // AT_TRACE(0,"_debug: I am at_norflash"); + error_code = 0; + AUTO_TEST_SEND(AT_CMD_RESP_NORFLASH); _func_fail: - AT_TRACE(1,"_debug:Flash testing fail.error_code = %d.",error_code); - + AT_TRACE(1, "_debug:Flash testing fail.error_code = %d.", error_code); } #if 0 @@ -1518,11 +1396,10 @@ void norflash_life_test(void) } #endif -enum NORFLASH_ASYNC_CMD -{ - NORFLASH_ASYNC_CMD_WRITE, - NORFLASH_ASYNC_CMD_ERASE, - NORFLASH_ASYNC_CMD_FLUSH, +enum NORFLASH_ASYNC_CMD { + NORFLASH_ASYNC_CMD_WRITE, + NORFLASH_ASYNC_CMD_ERASE, + NORFLASH_ASYNC_CMD_FLUSH, }; // regin[0]: start = 0x3c000000, end = 0x3c0cf000. -- code @@ -1537,900 +1414,806 @@ enum NORFLASH_ASYNC_CMD // regin[5]: start = 0x3c3ff000, end = 0x3c400000. -- __factory -enum NORFLASH_ASYNC_STATE -{ - NORFLASH_ASYNC_STATE_INIT, - NORFLASH_ASYNC_STATE_ERASE, - NORFLASH_ASYNC_STATE_WRITTING, - NORFLASH_ASYNC_STATE_WAIT, - NORFLASH_ASYNC_STATE_END, - NORFLASH_ASYNC_STATE_FAILED, +enum NORFLASH_ASYNC_STATE { + NORFLASH_ASYNC_STATE_INIT, + NORFLASH_ASYNC_STATE_ERASE, + NORFLASH_ASYNC_STATE_WRITTING, + NORFLASH_ASYNC_STATE_WAIT, + NORFLASH_ASYNC_STATE_END, + NORFLASH_ASYNC_STATE_FAILED, }; -typedef struct -{ - enum NORFLASH_ASYNC_STATE state; - AT_FLASH_REGION_INFO *region; - enum NORFLASH_API_MODULE_ID_T mod_id; - uint32_t buff_len; - uint32_t e_addr; - uint32_t w_offs; - uint32_t len_index; - uint32_t succ_count; - uint32_t fail_count; - uint32_t tried_count; -}ASYNC_SCENE; +typedef struct { + enum NORFLASH_ASYNC_STATE state; + AT_FLASH_REGION_INFO *region; + enum NORFLASH_API_MODULE_ID_T mod_id; + uint32_t buff_len; + uint32_t e_addr; + uint32_t w_offs; + uint32_t len_index; + uint32_t succ_count; + uint32_t fail_count; + uint32_t tried_count; +} ASYNC_SCENE; -uint32_t g_at_len[] = {1,255,256,512,1024,2048}; -ASYNC_SCENE at_async_scene[3] = -{ - {NORFLASH_ASYNC_STATE_INIT,®ion_info[FLASH_REGION_ID_FREE],NORFLASH_API_MODULE_ID_FREE,AT_FLASH_SECTOR_SIZE*2,0,0,0,0,0,0}, - {NORFLASH_ASYNC_STATE_INIT,®ion_info[FLASH_REGION_ID_CRASH_DUMP],NORFLASH_API_MODULE_ID_CRASH_DUMP,AT_FLASH_SECTOR_SIZE*2,0,0,0,0,0,0}, - {NORFLASH_ASYNC_STATE_INIT,®ion_info[FLASH_REGION_ID_FACTORY],NORFLASH_API_MODULE_ID_FACTORY,AT_FLASH_SECTOR_SIZE*1,0,0,0,0,0,0} -}; +uint32_t g_at_len[] = {1, 255, 256, 512, 1024, 2048}; +ASYNC_SCENE at_async_scene[3] = { + {NORFLASH_ASYNC_STATE_INIT, ®ion_info[FLASH_REGION_ID_FREE], + NORFLASH_API_MODULE_ID_FREE, AT_FLASH_SECTOR_SIZE * 2, 0, 0, 0, 0, 0, 0}, + {NORFLASH_ASYNC_STATE_INIT, ®ion_info[FLASH_REGION_ID_CRASH_DUMP], + NORFLASH_API_MODULE_ID_CRASH_DUMP, AT_FLASH_SECTOR_SIZE * 2, 0, 0, 0, 0, 0, + 0}, + {NORFLASH_ASYNC_STATE_INIT, ®ion_info[FLASH_REGION_ID_FACTORY], + NORFLASH_API_MODULE_ID_FACTORY, AT_FLASH_SECTOR_SIZE * 1, 0, 0, 0, 0, 0, + 0}}; bool g_at_test_break; -//uint8_t w_buff[AT_FLASH_SECTOR_SIZE]; -//uint8_t r_buff[AT_FLASH_SECTOR_SIZE]; -void at_w_buff_set(uint8_t* buff,uint32_t len) -{ - uint32_t i; - uint8_t val; +// uint8_t w_buff[AT_FLASH_SECTOR_SIZE]; +// uint8_t r_buff[AT_FLASH_SECTOR_SIZE]; +void at_w_buff_set(uint8_t *buff, uint32_t len) { + uint32_t i; + uint8_t val; - val = 0; - for(i= 0; i < len; i++) - { - buff[i] = val; - val ++; - } + val = 0; + for (i = 0; i < len; i++) { + buff[i] = val; + val++; + } } -uint32_t at_get_scene_index(uint32_t addr) -{ - uint32_t i; +uint32_t at_get_scene_index(uint32_t addr) { + uint32_t i; - for(i = 0; i < 3; i++) - { - if(addr >= at_async_scene[i].region->start_addr - && addr < at_async_scene[i].region->end_addr) - { - return i; - } + for (i = 0; i < 3; i++) { + if (addr >= at_async_scene[i].region->start_addr && + addr < at_async_scene[i].region->end_addr) { + return i; } - return i; + } + return i; } -void at_user_func(uint32_t param0,uint32_t param1); -void at_opera_result_notify(void* param) -{ - NORFLASH_API_OPERA_RESULT *opera_result; - enum NORFLASH_API_RET_T result; - uint32_t offs; - uint32_t index; - uint32_t i; - //enum THREAD_USER_ID user_id; - //uint32_t suspend = 1; +void at_user_func(uint32_t param0, uint32_t param1); +void at_opera_result_notify(void *param) { + NORFLASH_API_OPERA_RESULT *opera_result; + enum NORFLASH_API_RET_T result; + uint32_t offs; + uint32_t index; + uint32_t i; + // enum THREAD_USER_ID user_id; + // uint32_t suspend = 1; - opera_result = (NORFLASH_API_OPERA_RESULT*)param; + opera_result = (NORFLASH_API_OPERA_RESULT *)param; - AT_TRACE(6,"%s:type = %d, addr = 0x%x,len = 0x%x,remain_num = %d,result = %d.", - __func__, - opera_result->type, - opera_result->addr, - opera_result->len, - opera_result->remain_num, - opera_result->result); - // check. - index = at_get_scene_index(opera_result->addr); - ASSERT(index < 3, "%s:at_get_scene_index faile!,addr = 0x%x.",__func__,opera_result->addr); - offs = (opera_result->addr&0xffffff) - ((opera_result->addr&0xffffff)/4096)*4096; + AT_TRACE(6, + "%s:type = %d, addr = 0x%x,len = 0x%x,remain_num = %d,result = %d.", + __func__, opera_result->type, opera_result->addr, opera_result->len, + opera_result->remain_num, opera_result->result); + // check. + index = at_get_scene_index(opera_result->addr); + ASSERT(index < 3, "%s:at_get_scene_index faile!,addr = 0x%x.", __func__, + opera_result->addr); + offs = (opera_result->addr & 0xffffff) - + ((opera_result->addr & 0xffffff) / 4096) * 4096; - if(opera_result->remain_num == 0) - { - result = norflash_sync_read(at_async_scene[index].mod_id,opera_result->addr,at_buff_r,opera_result->len); - if(result != NORFLASH_API_OK) - { - ASSERT(0, "%s: hal_norflash_read failed, result = %d",__func__,result); + if (opera_result->remain_num == 0) { + result = + norflash_sync_read(at_async_scene[index].mod_id, opera_result->addr, + at_buff_r, opera_result->len); + if (result != NORFLASH_API_OK) { + ASSERT(0, "%s: hal_norflash_read failed, result = %d", __func__, result); + } + if (opera_result->type == NORFLASH_API_WRITTING) { + if (memcmp(at_buff_r, at_buff_w + offs, opera_result->len) == 0) { + AT_TRACE(4, + "%s: writting read back check ok.addr = 0x%x,len = 0x%x, offs " + "= 0x%x.", + __func__, opera_result->addr, opera_result->len, offs); + at_async_scene[index].succ_count++; + } else { + uint32_t remain_len; + AT_TRACE(4, + "%s: writting read back check failed.addr = 0x%x,len = " + "0x%x,offs = 0x%x.", + __func__, opera_result->addr, opera_result->len, offs); + for (i = 0; i < opera_result->len / 32; i++) { + DUMP8("0x%02x, ", at_buff_r + i * 32, 32); + + DUMP8("0x%02x, ", at_buff_w + offs + i * 32, 32); } - if(opera_result->type == NORFLASH_API_WRITTING) - { - if(memcmp(at_buff_r,at_buff_w + offs,opera_result->len) == 0) - { - AT_TRACE(4,"%s: writting read back check ok.addr = 0x%x,len = 0x%x, offs = 0x%x.", - __func__,opera_result->addr,opera_result->len,offs); - at_async_scene[index].succ_count ++; - } - else - { - uint32_t remain_len; - AT_TRACE(4,"%s: writting read back check failed.addr = 0x%x,len = 0x%x,offs = 0x%x.", - __func__,opera_result->addr,opera_result->len,offs); - for(i = 0; i < opera_result->len/32; i++) - { - DUMP8("0x%02x, ",at_buff_r + i*32,32); + remain_len = opera_result->len - (opera_result->len / 32) * 32; + if (remain_len > 0) { + DUMP8("0x%02x, ", at_buff_r + i * 32, remain_len); - DUMP8("0x%02x, ",at_buff_w + offs + i*32,32); - } - remain_len = opera_result->len - (opera_result->len/32)*32; - if(remain_len > 0) - { - DUMP8("0x%02x, ",at_buff_r + i*32,remain_len); - - DUMP8("0x%02x, ",at_buff_w + offs + i*32,remain_len); - } - at_async_scene[index].fail_count ++; - } - } - else - { - for(i = 0; i < AT_FLASH_SECTOR_SIZE; i++) - { - if(at_buff_r[i] != 0xff) - { - break; - } - } - if(i == AT_FLASH_SECTOR_SIZE) - { - at_async_scene[index].succ_count ++; - } - else - { - AT_TRACE(1,"%s: erasing operation read back check failed.",__func__); - at_async_scene[index].fail_count ++; - } - } - } - - //user_id = (enum THREAD_USER_ID)index; - //suspend = 1; - //at_thread_user_enqueue_cmd(user_id,0,user_id,suspend,(uint32_t)at_user_func); + DUMP8("0x%02x, ", at_buff_w + offs + i * 32, remain_len); + } + at_async_scene[index].fail_count++; + } + } else { + for (i = 0; i < AT_FLASH_SECTOR_SIZE; i++) { + if (at_buff_r[i] != 0xff) { + break; + } + } + if (i == AT_FLASH_SECTOR_SIZE) { + at_async_scene[index].succ_count++; + } else { + AT_TRACE(1, "%s: erasing operation read back check failed.", __func__); + at_async_scene[index].fail_count++; + } + } + } + // user_id = (enum THREAD_USER_ID)index; + // suspend = 1; + // at_thread_user_enqueue_cmd(user_id,0,user_id,suspend,(uint32_t)at_user_func); } -void at_user_func(uint32_t param0,uint32_t param1) -{ - enum NORFLASH_API_RET_T result; - ASYNC_SCENE *pscane; - enum THREAD_USER_ID user_id; - uint32_t suspend = 1; +void at_user_func(uint32_t param0, uint32_t param1) { + enum NORFLASH_API_RET_T result; + ASYNC_SCENE *pscane; + enum THREAD_USER_ID user_id; + uint32_t suspend = 1; - user_id = (enum THREAD_USER_ID)param0; - suspend = param1; - pscane = &at_async_scene[user_id]; - pscane->state = NORFLASH_ASYNC_STATE_INIT; + user_id = (enum THREAD_USER_ID)param0; + suspend = param1; + pscane = &at_async_scene[user_id]; + pscane->state = NORFLASH_ASYNC_STATE_INIT; - suspend = suspend; - AT_TRACE(4,"%s,%d:user_id = %d,suspend = %d.",__func__,__LINE__,user_id,suspend); - while(1) - { - if(g_at_test_break || pscane->fail_count > 0) - { - pscane->state = NORFLASH_ASYNC_STATE_END; - break; - } - - if(pscane->state == NORFLASH_ASYNC_STATE_INIT) - { - AT_TRACE(2,"%s,%d,NORFLASH_ASYNC_STATE_INIT",__func__,__LINE__); - pscane->e_addr = pscane->region->start_addr; - pscane->w_offs = 0; - pscane->len_index = 0; - pscane->succ_count = 0; - pscane->fail_count = 0; - pscane->tried_count = 0; - pscane->state = NORFLASH_ASYNC_STATE_ERASE; - } - else if(pscane->state == NORFLASH_ASYNC_STATE_ERASE) - { - if(pscane->e_addr >= pscane->region->end_addr) - { - AT_TRACE(3,"%s,%d: NORFLASH_ASYNC_STATE_ERASE, has arrived to end_addr.addr = 0x%x", - __func__, - __LINE__, - pscane->e_addr); - pscane->state = NORFLASH_ASYNC_STATE_WAIT; - continue; - } - result = norflash_api_erase(pscane->mod_id, - pscane->e_addr, - AT_FLASH_SECTOR_SIZE, - true); - if(result == NORFLASH_API_OK) - { - AT_TRACE(3,"%s,%d: NORFLASH_ASYNC_STATE_ERASE,erase ok!addr = 0x%x", - __func__, - __LINE__, - pscane->e_addr); - pscane->w_offs = 0; - pscane->len_index = 0; - pscane->state = NORFLASH_ASYNC_STATE_WRITTING; - pscane->tried_count = 0; - } - else if(result == NORFLASH_API_BUFFER_FULL) - { - if(pscane->tried_count == 0) - { - AT_TRACE(3,"%s,%d: NORFLASH_ASYNC_STATE_ERASE,too more!addr = 0x%x", - __func__, - __LINE__, - pscane->e_addr); - } - pscane->tried_count++; - norflash_api_flush(); - //osDelay(100); - } - else - { - AT_TRACE(4,"%s,%d: NORFLASH_ASYNC_STATE_ERASE,erase failed!addr = 0x%x,result = %d.", - __func__, - __LINE__, - pscane->e_addr,result); - } - } - else if(pscane->state == NORFLASH_ASYNC_STATE_WRITTING) - { - if(pscane->len_index >= sizeof(g_at_len)/sizeof(g_at_len[0])) - { - AT_TRACE(3,"%s,%d:NORFLASH_ASYNC_STATE_WRITTING,has arrived to sector end. w_offs = 0x%x", - __func__, - __LINE__, - pscane->w_offs); - pscane->e_addr += AT_FLASH_SECTOR_SIZE; - pscane->state = NORFLASH_ASYNC_STATE_ERASE; - continue; - } - - if(norflash_api_get_used_buffer_count(pscane->mod_id,NORFLASH_API_ALL) > 0) - { - norflash_api_flush(); - continue; - } - - result = norflash_api_write(pscane->mod_id, - pscane->e_addr + pscane->w_offs, - at_buff_w + pscane->w_offs, - g_at_len[pscane->len_index], - true); - if(result == NORFLASH_API_OK) - { - AT_TRACE(3,"%s,%d NORFLASH_ASYNC_STATE_WRITTING,norflash_api_write ok!addr = 0x%x", - __func__, - __LINE__, - pscane->e_addr + pscane->w_offs); - pscane->w_offs += g_at_len[pscane->len_index]; - pscane->len_index ++; - pscane->tried_count = 0; - } - else if(result == NORFLASH_API_BUFFER_FULL) - { - - if(pscane->tried_count == 0) - { - AT_TRACE(3,"%s,%d: NORFLASH_ASYNC_STATE_WRITTING, too more!addr = 0x%x", - __func__, - __LINE__, - pscane->e_addr + pscane->w_offs); - } - pscane->tried_count++; - norflash_api_flush(); - //osDelay(100); - } - else - { - AT_TRACE(4,"%s,%d: NORFLASH_ASYNC_STATE_WRITTING writting failed!addr = 0x%x,result = %d.", - __func__, - __LINE__, - pscane->e_addr + pscane->w_offs, - result); - goto _func_fail; - } - } - else if(pscane->state == NORFLASH_ASYNC_STATE_WAIT) - { - //AT_TRACE(2,"%s,%d,NORFLASH_ASYNC_STATE_WAIT",__func__,__LINE__); - if(norflash_api_buffer_is_free(pscane->mod_id)) - { - AT_TRACE(2,"%s,%d: NORFLASH_ASYNC_STATE_WAIT,norflash_api_buffer_is_free is true.", - __func__, - __LINE__); - pscane->state = NORFLASH_ASYNC_STATE_END; - pscane->tried_count = 0; - } - else - { - if(pscane->tried_count == 0) - { - AT_TRACE(2,"%s,%d: NORFLASH_ASYNC_STATE_WAIT,norflash_api_buffer_is_free is false ", - __func__, - __LINE__); - } - pscane->tried_count++; - norflash_api_flush(); - //osDelay(100); - } - } - else if(pscane->state == NORFLASH_ASYNC_STATE_END) - { - AT_TRACE(2,"%s,%d,NORFLASH_ASYNC_STATE_END",__func__,__LINE__); - break; - } + suspend = suspend; + AT_TRACE(4, "%s,%d:user_id = %d,suspend = %d.", __func__, __LINE__, user_id, + suspend); + while (1) { + if (g_at_test_break || pscane->fail_count > 0) { + pscane->state = NORFLASH_ASYNC_STATE_END; + break; } - AT_TRACE(3,"%s,%d,user_id = %d",__func__,__LINE__,user_id); - return; + + if (pscane->state == NORFLASH_ASYNC_STATE_INIT) { + AT_TRACE(2, "%s,%d,NORFLASH_ASYNC_STATE_INIT", __func__, __LINE__); + pscane->e_addr = pscane->region->start_addr; + pscane->w_offs = 0; + pscane->len_index = 0; + pscane->succ_count = 0; + pscane->fail_count = 0; + pscane->tried_count = 0; + pscane->state = NORFLASH_ASYNC_STATE_ERASE; + } else if (pscane->state == NORFLASH_ASYNC_STATE_ERASE) { + if (pscane->e_addr >= pscane->region->end_addr) { + AT_TRACE(3, + "%s,%d: NORFLASH_ASYNC_STATE_ERASE, has arrived to " + "end_addr.addr = 0x%x", + __func__, __LINE__, pscane->e_addr); + pscane->state = NORFLASH_ASYNC_STATE_WAIT; + continue; + } + result = norflash_api_erase(pscane->mod_id, pscane->e_addr, + AT_FLASH_SECTOR_SIZE, true); + if (result == NORFLASH_API_OK) { + AT_TRACE(3, "%s,%d: NORFLASH_ASYNC_STATE_ERASE,erase ok!addr = 0x%x", + __func__, __LINE__, pscane->e_addr); + pscane->w_offs = 0; + pscane->len_index = 0; + pscane->state = NORFLASH_ASYNC_STATE_WRITTING; + pscane->tried_count = 0; + } else if (result == NORFLASH_API_BUFFER_FULL) { + if (pscane->tried_count == 0) { + AT_TRACE(3, "%s,%d: NORFLASH_ASYNC_STATE_ERASE,too more!addr = 0x%x", + __func__, __LINE__, pscane->e_addr); + } + pscane->tried_count++; + norflash_api_flush(); + // osDelay(100); + } else { + AT_TRACE(4, + "%s,%d: NORFLASH_ASYNC_STATE_ERASE,erase failed!addr = " + "0x%x,result = %d.", + __func__, __LINE__, pscane->e_addr, result); + } + } else if (pscane->state == NORFLASH_ASYNC_STATE_WRITTING) { + if (pscane->len_index >= sizeof(g_at_len) / sizeof(g_at_len[0])) { + AT_TRACE(3, + "%s,%d:NORFLASH_ASYNC_STATE_WRITTING,has arrived to sector " + "end. w_offs = 0x%x", + __func__, __LINE__, pscane->w_offs); + pscane->e_addr += AT_FLASH_SECTOR_SIZE; + pscane->state = NORFLASH_ASYNC_STATE_ERASE; + continue; + } + + if (norflash_api_get_used_buffer_count(pscane->mod_id, NORFLASH_API_ALL) > + 0) { + norflash_api_flush(); + continue; + } + + result = norflash_api_write( + pscane->mod_id, pscane->e_addr + pscane->w_offs, + at_buff_w + pscane->w_offs, g_at_len[pscane->len_index], true); + if (result == NORFLASH_API_OK) { + AT_TRACE(3, + "%s,%d NORFLASH_ASYNC_STATE_WRITTING,norflash_api_write " + "ok!addr = 0x%x", + __func__, __LINE__, pscane->e_addr + pscane->w_offs); + pscane->w_offs += g_at_len[pscane->len_index]; + pscane->len_index++; + pscane->tried_count = 0; + } else if (result == NORFLASH_API_BUFFER_FULL) { + + if (pscane->tried_count == 0) { + AT_TRACE(3, + "%s,%d: NORFLASH_ASYNC_STATE_WRITTING, too more!addr = 0x%x", + __func__, __LINE__, pscane->e_addr + pscane->w_offs); + } + pscane->tried_count++; + norflash_api_flush(); + // osDelay(100); + } else { + AT_TRACE(4, + "%s,%d: NORFLASH_ASYNC_STATE_WRITTING writting failed!addr = " + "0x%x,result = %d.", + __func__, __LINE__, pscane->e_addr + pscane->w_offs, result); + goto _func_fail; + } + } else if (pscane->state == NORFLASH_ASYNC_STATE_WAIT) { + // AT_TRACE(2,"%s,%d,NORFLASH_ASYNC_STATE_WAIT",__func__,__LINE__); + if (norflash_api_buffer_is_free(pscane->mod_id)) { + AT_TRACE(2, + "%s,%d: NORFLASH_ASYNC_STATE_WAIT,norflash_api_buffer_is_free " + "is true.", + __func__, __LINE__); + pscane->state = NORFLASH_ASYNC_STATE_END; + pscane->tried_count = 0; + } else { + if (pscane->tried_count == 0) { + AT_TRACE( + 2, + "%s,%d: NORFLASH_ASYNC_STATE_WAIT,norflash_api_buffer_is_free is " + "false ", + __func__, __LINE__); + } + pscane->tried_count++; + norflash_api_flush(); + // osDelay(100); + } + } else if (pscane->state == NORFLASH_ASYNC_STATE_END) { + AT_TRACE(2, "%s,%d,NORFLASH_ASYNC_STATE_END", __func__, __LINE__); + break; + } + } + AT_TRACE(3, "%s,%d,user_id = %d", __func__, __LINE__, user_id); + return; _func_fail: - AT_TRACE(2,"%s: norflash_api failed! state = %d.", __func__, pscane->state); - + AT_TRACE(2, "%s: norflash_api failed! state = %d.", __func__, pscane->state); } -void at_norflash_async_init(enum THREAD_USER_ID user_id) -{ - ASYNC_SCENE *pscene; - enum NORFLASH_API_RET_T result; - uint32_t sector_size = 0; - uint32_t block_size = 0; - uint32_t page_size = 0; - - ASSERT(user_id < 3,"%s:user_id == %d.",__func__,user_id); - AT_TRACE(3,"%s,%d: user_id = %d.",__func__,__LINE__,user_id); - hal_norflash_get_size(HAL_NORFLASH_ID_0, - NULL, - &block_size, - §or_size, - &page_size); - pscene = &at_async_scene[user_id]; - result = norflash_api_register(pscene->mod_id, - HAL_NORFLASH_ID_0, - pscene->region->start_addr, - pscene->region->end_addr - pscene->region->start_addr, - block_size, - sector_size, - page_size, - pscene->buff_len, - at_opera_result_notify); - ASSERT(result == NORFLASH_API_OK, "%s:user_id == %d,result = %d.",__func__,user_id,(int)result); +void at_norflash_async_init(enum THREAD_USER_ID user_id) { + ASYNC_SCENE *pscene; + enum NORFLASH_API_RET_T result; + uint32_t sector_size = 0; + uint32_t block_size = 0; + uint32_t page_size = 0; + ASSERT(user_id < 3, "%s:user_id == %d.", __func__, user_id); + AT_TRACE(3, "%s,%d: user_id = %d.", __func__, __LINE__, user_id); + hal_norflash_get_size(HAL_NORFLASH_ID_0, NULL, &block_size, §or_size, + &page_size); + pscene = &at_async_scene[user_id]; + result = norflash_api_register( + pscene->mod_id, HAL_NORFLASH_ID_0, pscene->region->start_addr, + pscene->region->end_addr - pscene->region->start_addr, block_size, + sector_size, page_size, pscene->buff_len, at_opera_result_notify); + ASSERT(result == NORFLASH_API_OK, "%s:user_id == %d,result = %d.", __func__, + user_id, (int)result); } -void at_norflash_suspend(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - uint32_t i; - uint32_t start_time; - static bool is_fst = true; +void at_norflash_suspend(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + uint32_t i; + uint32_t start_time; + static bool is_fst = true; - param0 = param0; - cmd_id = cmd_id; - AT_TRACE(0,"I am at_norflash_suspend"); - g_at_test_break = false; - for(i = 0; i < sizeof(region_info)/sizeof(AT_FLASH_REGION_INFO); i++) - { - AT_TRACE(3,"regin[%d]: start = 0x%x, end = 0x%x.",region_info[i].id,region_info[i].start_addr,region_info[i].end_addr); + param0 = param0; + cmd_id = cmd_id; + AT_TRACE(0, "I am at_norflash_suspend"); + g_at_test_break = false; + for (i = 0; i < sizeof(region_info) / sizeof(AT_FLASH_REGION_INFO); i++) { + AT_TRACE(3, "regin[%d]: start = 0x%x, end = 0x%x.", region_info[i].id, + region_info[i].start_addr, region_info[i].end_addr); + } + if (is_fst) { + at_w_buff_set(at_buff_w, AT_FLASH_SECTOR_SIZE); - } - if(is_fst) - { - at_w_buff_set(at_buff_w,AT_FLASH_SECTOR_SIZE); + at_norflash_async_init(THREAD_USER0); + at_norflash_async_init(THREAD_USER1); + // at_norflash_async_init(THREAD_USER2); + is_fst = false; + } + if (!at_thread_user_is_inited(THREAD_USER0)) { + at_thread_user_init(THREAD_USER0); + } - at_norflash_async_init(THREAD_USER0); - at_norflash_async_init(THREAD_USER1); - // at_norflash_async_init(THREAD_USER2); - is_fst = false; - } - if(!at_thread_user_is_inited(THREAD_USER0)) - { - at_thread_user_init(THREAD_USER0); - } + if (!at_thread_user_is_inited(THREAD_USER1)) { + at_thread_user_init(THREAD_USER1); + } - if(!at_thread_user_is_inited(THREAD_USER1)) - { - at_thread_user_init(THREAD_USER1); - } - - // if(!at_thread_user_is_inited(THREAD_USER2)) - { - // at_thread_user_init(THREAD_USER2); - } - // param0: user_id - // praram1: suspend - osDelay(100); - at_thread_user_enqueue_cmd(THREAD_USER0,0,THREAD_USER0,1,(uint32_t)at_user_func); - //osDelay(100); - at_thread_user_enqueue_cmd(THREAD_USER1,0,THREAD_USER1,1,(uint32_t)at_user_func); - //osDelay(100); + // if(!at_thread_user_is_inited(THREAD_USER2)) + { + // at_thread_user_init(THREAD_USER2); + } + // param0: user_id + // praram1: suspend + osDelay(100); + at_thread_user_enqueue_cmd(THREAD_USER0, 0, THREAD_USER0, 1, + (uint32_t)at_user_func); + // osDelay(100); + at_thread_user_enqueue_cmd(THREAD_USER1, 0, THREAD_USER1, 1, + (uint32_t)at_user_func); + // osDelay(100); // at_thread_user_enqueue_cmd(THREAD_USER2,0,THREAD_USER2,1,(uint32_t)at_user_func); - start_time = hal_sys_timer_get(); - while(1) + start_time = hal_sys_timer_get(); + while (1) { + if (TICKS_TO_MS(hal_sys_timer_get() - start_time) >= + 1000 * 60) // timeout 60second { - if(TICKS_TO_MS(hal_sys_timer_get() - start_time) >= 1000*60) // timeout 60second - { - AT_TRACE(1,"%s: wait out time!"); - break; - } - if(at_async_scene[0].state == NORFLASH_ASYNC_STATE_END - && at_async_scene[1].state == NORFLASH_ASYNC_STATE_END - ) - { - if(at_async_scene[0].fail_count == 0 - && at_async_scene[1].fail_count == 0 - ) - { - AUTO_TEST_SEND(AT_CMD_RESP_NORFLASH_SUSPEND); - break; - } - else - { - break; - } - } - else if(at_async_scene[0].fail_count > 0 - || at_async_scene[1].fail_count > 0 - ) - { - g_at_test_break = true; - } - else - { - AT_TRACE(2,"%s: is runnig.time = %d(ms).",__func__,TICKS_TO_MS(hal_sys_timer_get() - start_time)); - osDelay(500); - } - + AT_TRACE(1, "%s: wait out time!"); + break; } + if (at_async_scene[0].state == NORFLASH_ASYNC_STATE_END && + at_async_scene[1].state == NORFLASH_ASYNC_STATE_END) { + if (at_async_scene[0].fail_count == 0 && + at_async_scene[1].fail_count == 0) { + AUTO_TEST_SEND(AT_CMD_RESP_NORFLASH_SUSPEND); + break; + } else { + break; + } + } else if (at_async_scene[0].fail_count > 0 || + at_async_scene[1].fail_count > 0) { + g_at_test_break = true; + } else { + AT_TRACE(2, "%s: is runnig.time = %d(ms).", __func__, + TICKS_TO_MS(hal_sys_timer_get() - start_time)); + osDelay(500); + } + } -//_func_fail: -// AT_TRACE(1,"_debug:Flash testing fail.error_code = %d.",error_code); - + //_func_fail: + // AT_TRACE(1,"_debug:Flash testing fail.error_code = %d.",error_code); } -int32_t _at_memory_test(uint8_t* buff,uint32_t size) -{ - uint8_t value; - uint32_t i; - int32_t ret = 0; +int32_t _at_memory_test(uint8_t *buff, uint32_t size) { + uint8_t value; + uint32_t i; + int32_t ret = 0; - value = 0; - for(i = 0; i < size; i++) - { - buff[i] = value++; - } - value = 0; - for(i = 0; i < size; i++) - { - if(buff[i] != value++) - { - ret = 2; - goto _func_end; - } + value = 0; + for (i = 0; i < size; i++) { + buff[i] = value++; + } + value = 0; + for (i = 0; i < size; i++) { + if (buff[i] != value++) { + ret = 2; + goto _func_end; } + } _func_end: - return ret; + return ret; } -void at_memory(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; - uint8_t *buff; - uint8_t error_code = 1; - int32_t result; +void at_memory(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; + uint8_t *buff; + uint8_t error_code = 1; + int32_t result; - error_code = error_code; - //AT_TRACE(0,"_debug: I am at_memory"); - buff = (uint8_t*)at_buff_r; - result = _at_memory_test(buff,AT_FLASH_SECTOR_SIZE); - if(result != 0) - { - error_code = 2; - goto _func_fail; - } + error_code = error_code; + // AT_TRACE(0,"_debug: I am at_memory"); + buff = (uint8_t *)at_buff_r; + result = _at_memory_test(buff, AT_FLASH_SECTOR_SIZE); + if (result != 0) { + error_code = 2; + goto _func_fail; + } - buff = (uint8_t*)at_buff_w; - result = _at_memory_test(buff,AT_FLASH_SECTOR_SIZE); - if(result != 0) - { - error_code = 2; - goto _func_fail; - } + buff = (uint8_t *)at_buff_w; + result = _at_memory_test(buff, AT_FLASH_SECTOR_SIZE); + if (result != 0) { + error_code = 2; + goto _func_fail; + } - buff = (uint8_t*)at_buff_b; - result = _at_memory_test(buff,AT_FLASH_SECTOR_SIZE); - if(result != 0) - { - error_code = 3; - goto _func_fail; - } - error_code = 0; - AUTO_TEST_SEND(AT_CMD_RESP_MEMORY); + buff = (uint8_t *)at_buff_b; + result = _at_memory_test(buff, AT_FLASH_SECTOR_SIZE); + if (result != 0) { + error_code = 3; + goto _func_fail; + } + error_code = 0; + AUTO_TEST_SEND(AT_CMD_RESP_MEMORY); _func_fail: - AT_TRACE(1,"_debug:Memory testing fail.error_code = %d.",error_code); - + AT_TRACE(1, "_debug:Memory testing fail.error_code = %d.", error_code); } -void at_get_mac(uint32_t param0,uint32_t param1) -{ - unsigned char *btd_addr; +void at_get_mac(uint32_t param0, uint32_t param1) { + unsigned char *btd_addr; - btd_addr = bt_addr; - if(NULL != btd_addr) - { - AT_TRACE(6,"GETMAC_TEST_OK:%x:%x:%x:%x:%x:%x",bt_addr[0],bt_addr[1],bt_addr[2],bt_addr[3],bt_addr[4],bt_addr[5]); - AUTO_TEST_SEND(AT_CMD_RESP_MAC); - } - else - { - AT_TRACE(0,"GETMAC_TEST_NG!"); - AUTO_TEST_SEND(AT_CMD_RESP_ERROR); - } + btd_addr = bt_addr; + if (NULL != btd_addr) { + AT_TRACE(6, "GETMAC_TEST_OK:%x:%x:%x:%x:%x:%x", bt_addr[0], bt_addr[1], + bt_addr[2], bt_addr[3], bt_addr[4], bt_addr[5]); + AUTO_TEST_SEND(AT_CMD_RESP_MAC); + } else { + AT_TRACE(0, "GETMAC_TEST_NG!"); + AUTO_TEST_SEND(AT_CMD_RESP_ERROR); + } - return; + return; } -void at_get_devicename(uint32_t param0,uint32_t param1) -{ - const char *localname; +void at_get_devicename(uint32_t param0, uint32_t param1) { + const char *localname; - localname = BT_LOCAL_NAME; - if(NULL != localname) - { - AT_TRACE(1,"GETNAME_TEST_OK:%s",localname); - } - else - { - AT_TRACE(0,"GETNAME_TEST_NG!"); - } + localname = BT_LOCAL_NAME; + if (NULL != localname) { + AT_TRACE(1, "GETNAME_TEST_OK:%s", localname); + } else { + AT_TRACE(0, "GETNAME_TEST_NG!"); + } - return; + return; } -void at_set_loopback(uint32_t param0,uint32_t param1) -{ - int idex; - char *p; +void at_set_loopback(uint32_t param0, uint32_t param1) { + int idex; + char *p; - p = (char*)param0; - idex = atoi(p); + p = (char *)param0; + idex = atoi(p); - AT_TRACE(1,"[%s]", __func__); + AT_TRACE(1, "[%s]", __func__); - switch(idex) - { - case 1: - app_audio_sendrequest(APP_FACTORYMODE_AUDIO_LOOP, (uint8_t)APP_BT_SETTING_OPEN, 0); - AT_TRACE(0,"LOOPBACK_TEST_OPEN!"); - AUTO_TEST_SEND(AT_CMD_RESP_LOOPBACK); - break; - case 2: - app_audio_sendrequest(APP_FACTORYMODE_AUDIO_LOOP, (uint8_t)APP_BT_SETTING_CLOSE, 0); - AT_TRACE(0,"LOOPBACK_TEST_CLOSED!"); - AUTO_TEST_SEND(AT_CMD_RESP_LOOPBACK); - break; - default: - AT_TRACE(1,"LOOPBACK_TEST param error: %s!",idex); - AUTO_TEST_SEND(AT_CMD_RESP_ERROR); - } + switch (idex) { + case 1: + app_audio_sendrequest(APP_FACTORYMODE_AUDIO_LOOP, + (uint8_t)APP_BT_SETTING_OPEN, 0); + AT_TRACE(0, "LOOPBACK_TEST_OPEN!"); + AUTO_TEST_SEND(AT_CMD_RESP_LOOPBACK); + break; + case 2: + app_audio_sendrequest(APP_FACTORYMODE_AUDIO_LOOP, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + AT_TRACE(0, "LOOPBACK_TEST_CLOSED!"); + AUTO_TEST_SEND(AT_CMD_RESP_LOOPBACK); + break; + default: + AT_TRACE(1, "LOOPBACK_TEST param error: %s!", idex); + AUTO_TEST_SEND(AT_CMD_RESP_ERROR); + } - return; + return; } -void at_set_led(uint32_t param0,uint32_t param1) -{ - char *p; - p = (char*)param0; +void at_set_led(uint32_t param0, uint32_t param1) { + char *p; + p = (char *)param0; - switch(*p) - { - case 0x31://'1': - AT_TRACE(0,"LED light 1"); - app_status_indication_set(APP_STATUS_INDICATION_CHARGING); - AUTO_TEST_SEND(AT_CMD_RESP_LED); - break; - case 0x32://'2': - AT_TRACE(0,"LED light 2"); - app_status_indication_set(APP_STATUS_INDICATION_FULLCHARGE); - AUTO_TEST_SEND(AT_CMD_RESP_LED); - break; - default: - AT_TRACE(0,"LED light all"); - app_status_indication_set(APP_STATUS_INDICATION_TESTMODE); - AUTO_TEST_SEND(AT_CMD_RESP_LED); - break; - } + switch (*p) { + case 0x31: //'1': + AT_TRACE(0, "LED light 1"); + app_status_indication_set(APP_STATUS_INDICATION_CHARGING); + AUTO_TEST_SEND(AT_CMD_RESP_LED); + break; + case 0x32: //'2': + AT_TRACE(0, "LED light 2"); + app_status_indication_set(APP_STATUS_INDICATION_FULLCHARGE); + AUTO_TEST_SEND(AT_CMD_RESP_LED); + break; + default: + AT_TRACE(0, "LED light all"); + app_status_indication_set(APP_STATUS_INDICATION_TESTMODE); + AUTO_TEST_SEND(AT_CMD_RESP_LED); + break; + } - AT_TRACE(0,"SETLED_TEST_OK!"); - return ; + AT_TRACE(0, "SETLED_TEST_OK!"); + return; } -void at_enter_signaling_mode(uint32_t param0,uint32_t param1) -{ - AT_TRACE(1,"%s",__func__); - hal_sw_bootmode_set(HAL_SW_BOOTMODE_TEST_MODE|HAL_SW_BOOTMODE_TEST_SIGNALINGMODE); - app_reset(); +void at_enter_signaling_mode(uint32_t param0, uint32_t param1) { + AT_TRACE(1, "%s", __func__); + hal_sw_bootmode_set(HAL_SW_BOOTMODE_TEST_MODE | + HAL_SW_BOOTMODE_TEST_SIGNALINGMODE); + app_reset(); } -void at_enter_no_signaling_mode(uint32_t param0,uint32_t param1) -{ - AT_TRACE(1,"[%s]", __func__); +void at_enter_no_signaling_mode(uint32_t param0, uint32_t param1) { + AT_TRACE(1, "[%s]", __func__); - hal_sw_bootmode_set(HAL_SW_BOOTMODE_TEST_MODE|HAL_SW_BOOTMODE_TEST_NOSIGNALINGMODE); - app_reset(); + hal_sw_bootmode_set(HAL_SW_BOOTMODE_TEST_MODE | + HAL_SW_BOOTMODE_TEST_NOSIGNALINGMODE); + app_reset(); } -const uint8_t hci_cmd_nonsig_ble_stop_pn9[] = { 0x01, 0x1f, 0x20, 0x00 }; +const uint8_t hci_cmd_nonsig_ble_stop_pn9[] = {0x01, 0x1f, 0x20, 0x00}; const uint8_t hci_cmd_stop_bt_no_signaling_test_configuration[] = { -0x01, 0x87, 0xfc, 0x14, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x01, 0x87, 0xfc, 0x14, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; const uint8_t hci_cmd_ble_no_signaling_test_configuration[3][7] = { -// 2402-----INDEX0 tx -{0x01, 0x1e, 0x20, 0x03, 0x00, 0x25, 0x03}, -// 2440-----INDEX1 -{0x01, 0x1e, 0x20, 0x03, 0x13, 0x25, 0x03}, -// 2480-----INDEX2 -{0x01, 0x1e, 0x20, 0x03, 0x27, 0x25, 0x03}, + // 2402-----INDEX0 tx + {0x01, 0x1e, 0x20, 0x03, 0x00, 0x25, 0x03}, + // 2440-----INDEX1 + {0x01, 0x1e, 0x20, 0x03, 0x13, 0x25, 0x03}, + // 2480-----INDEX2 + {0x01, 0x1e, 0x20, 0x03, 0x27, 0x25, 0x03}, }; const uint8_t hci_cmd_ble_rx_no_signaling_test_configuration[3][5] = { -// 2402-----INDEX0 rx -{0x01, 0x1d, 0x20, 0x01, 0x00}, -// 2440-----INDEX1 -{0x01, 0x1d, 0x20, 0x01, 0x13}, -// 2480-----INDEX2 -{0x01, 0x1d, 0x20, 0x01, 0x27}, + // 2402-----INDEX0 rx + {0x01, 0x1d, 0x20, 0x01, 0x00}, + // 2440-----INDEX1 + {0x01, 0x1d, 0x20, 0x01, 0x13}, + // 2480-----INDEX2 + {0x01, 0x1d, 0x20, 0x01, 0x27}, }; const uint8_t hci_cmd_bt_no_signaling_test_configuration[24][24] = { -// BR DH3, 2402, TX-----INDEX0 -{0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0b, 0x04, 0xB7, 0x00}, -// BR DH3, 2402, RX-----INDEX1 -{0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0b, 0x04, 0xb7, 0x00}, + // BR DH3, 2402, TX-----INDEX0 + {0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0b, 0x04, 0xB7, 0x00}, + // BR DH3, 2402, RX-----INDEX1 + {0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0b, 0x04, 0xb7, 0x00}, -// BR DH3, 2441, TX-----INDEX2 -{0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x27, 0x27, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0b, 0x04, 0xB7, 0x00}, -// BR DH3, 2441, RX-----INDEX3 -{0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x27, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0b, 0x04, 0xb7, 0x00}, + // BR DH3, 2441, TX-----INDEX2 + {0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x27, 0x27, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0b, 0x04, 0xB7, 0x00}, + // BR DH3, 2441, RX-----INDEX3 + {0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x27, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0b, 0x04, 0xb7, 0x00}, -// BR DH3, 2480, TX-----INDEX4 -{0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x4e, 0x4e, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0b, 0x04, 0xB7, 0x00}, -// BR DH3, 2480, RX-----INDEX5 -{0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x4e, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0b, 0x04, 0xb7, 0x00}, + // BR DH3, 2480, TX-----INDEX4 + {0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x4e, 0x4e, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0b, 0x04, 0xB7, 0x00}, + // BR DH3, 2480, RX-----INDEX5 + {0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x4e, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0b, 0x04, 0xb7, 0x00}, -// BR DH5, 2402, TX-----INDEX6 -{0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0f, 0x04, 0x53, 0x01}, -// BR DH5, 2402, RX-----INDEX7 -{0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0f, 0x04, 0x53, 0x01}, + // BR DH5, 2402, TX-----INDEX6 + {0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0f, 0x04, 0x53, 0x01}, + // BR DH5, 2402, RX-----INDEX7 + {0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0f, 0x04, 0x53, 0x01}, -// BR DH5, 2441, TX-----INDEX8 -{0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x27, 0x27, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0f, 0x04, 0x53, 0x01}, -// BR DH5, 2441, RX-----INDEX9 -{0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x27, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0f, 0x04, 0x53, 0x01}, + // BR DH5, 2441, TX-----INDEX8 + {0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x27, 0x27, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0f, 0x04, 0x53, 0x01}, + // BR DH5, 2441, RX-----INDEX9 + {0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x27, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0f, 0x04, 0x53, 0x01}, -// BR DH5, 2480, TX-----INDEX10 -{0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x4e, 0x4e, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0f, 0x04, 0x53, 0x01}, -// BR DH5, 2480, RX-----INDEX11 -{0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x4e, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0f, 0x04, 0x53, 0x01}, + // BR DH5, 2480, TX-----INDEX10 + {0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x4e, 0x4e, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0f, 0x04, 0x53, 0x01}, + // BR DH5, 2480, RX-----INDEX11 + {0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x4e, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x0f, 0x04, 0x53, 0x01}, -// BR 2DH5, 2402, TX----INDEX12 -{0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0e, 0x04, 0xa7, 0x02}, -// BR 2DH5, 2402, RX----INDEX13 -{0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0e, 0x04, 0xa7, 0x02}, + // BR 2DH5, 2402, TX----INDEX12 + {0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0e, 0x04, 0xa7, 0x02}, + // BR 2DH5, 2402, RX----INDEX13 + {0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0e, 0x04, 0xa7, 0x02}, -// BR 2DH5, 2441, TX----INDEX14 -{0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x27, 0x27, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0e, 0x04, 0xa7, 0x02}, -// BR 2DH5, 2441, RX----INDEX15 -{0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x27, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0e, 0x04, 0xa7, 0x02}, + // BR 2DH5, 2441, TX----INDEX14 + {0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x27, 0x27, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0e, 0x04, 0xa7, 0x02}, + // BR 2DH5, 2441, RX----INDEX15 + {0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x27, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0e, 0x04, 0xa7, 0x02}, -// BR 2DH5, 2480, TX----INDEX16 -{0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x4e, 0x4e, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0e, 0x04, 0xa7, 0x02}, -// BR 2DH5, 2480, RX----INDEX17 -{0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x4e, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0e, 0x04, 0xa7, 0x02}, + // BR 2DH5, 2480, TX----INDEX16 + {0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x4e, 0x4e, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0e, 0x04, 0xa7, 0x02}, + // BR 2DH5, 2480, RX----INDEX17 + {0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x4e, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0e, 0x04, 0xa7, 0x02}, -// BR 3DH5, 2402, TX----INDEX18 -{0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0f, 0x04, 0xfd, 0x03}, -// BR 3DH5, 2402, RX----INDEX19 -{0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0f, 0x04, 0xfd, 0x03}, + // BR 3DH5, 2402, TX----INDEX18 + {0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0f, 0x04, 0xfd, 0x03}, + // BR 3DH5, 2402, RX----INDEX19 + {0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0f, 0x04, 0xfd, 0x03}, -// BR 3DH5, 2441, TX----INDEX20 -{0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x27, 0x27, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0f, 0x04, 0xfd, 0x03}, -// BR 3DH5, 2441, RX----INDEX21 -{0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x27, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0f, 0x04, 0xfd, 0x03}, + // BR 3DH5, 2441, TX----INDEX20 + {0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x27, 0x27, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0f, 0x04, 0xfd, 0x03}, + // BR 3DH5, 2441, RX----INDEX21 + {0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x27, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0f, 0x04, 0xfd, 0x03}, -// BR 3DH5, 2480, TX----INDEX22 -{0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x4e, 0x4e, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0f, 0x04, 0xfd, 0x03}, -// BR 3DH5, 2480, RX----INDEX23 -{0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x4e, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0f, 0x04, 0xfd, 0x03}, + // BR 3DH5, 2480, TX----INDEX22 + {0x01, 0x87, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x4e, 0x4e, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0f, 0x04, 0xfd, 0x03}, + // BR 3DH5, 2480, RX----INDEX23 + {0x01, 0x87, 0xfc, 0x14, 0x01, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x4e, 0x02, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x01, 0x0f, 0x04, 0xfd, 0x03}, }; -static const uint8_t hci_cmd_nonsig_tx_dh1_pn9[] = -{ - 0x01, 0x60, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x04, 0x04, 0x1b, 0x00 -}; +static const uint8_t hci_cmd_nonsig_tx_dh1_pn9[] = { + 0x01, 0x60, 0xfc, 0x14, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, 0x00, 0x04, 0x04, 0x1b, 0x00}; -void BleFrequencyTestStop() -{ - btdrv_SendData(hci_cmd_nonsig_ble_stop_pn9, sizeof(hci_cmd_nonsig_ble_stop_pn9)); +void BleFrequencyTestStop() { + btdrv_SendData(hci_cmd_nonsig_ble_stop_pn9, + sizeof(hci_cmd_nonsig_ble_stop_pn9)); } -void BtFrequencyTestStop() -{ - btdrv_SendData(hci_cmd_stop_bt_no_signaling_test_configuration, sizeof(hci_cmd_stop_bt_no_signaling_test_configuration)); +void BtFrequencyTestStop() { + btdrv_SendData(hci_cmd_stop_bt_no_signaling_test_configuration, + sizeof(hci_cmd_stop_bt_no_signaling_test_configuration)); } -void BleFrequencyTestStart(uint8_t index) -{ - TRACE(2,"[%s] index is %d", __func__, index); +void BleFrequencyTestStart(uint8_t index) { + TRACE(2, "[%s] index is %d", __func__, index); - btdrv_SendData(hci_cmd_ble_no_signaling_test_configuration[index], sizeof(hci_cmd_ble_no_signaling_test_configuration[0])); + btdrv_SendData(hci_cmd_ble_no_signaling_test_configuration[index], + sizeof(hci_cmd_ble_no_signaling_test_configuration[0])); } -void BleFrequencyTestStartRx(uint8_t index) -{ - TRACE(2,"[%s] index is %d", __func__, index); +void BleFrequencyTestStartRx(uint8_t index) { + TRACE(2, "[%s] index is %d", __func__, index); - btdrv_SendData(hci_cmd_ble_rx_no_signaling_test_configuration[index], sizeof(hci_cmd_ble_rx_no_signaling_test_configuration[0])); + btdrv_SendData(hci_cmd_ble_rx_no_signaling_test_configuration[index], + sizeof(hci_cmd_ble_rx_no_signaling_test_configuration[0])); } -void BtFrequencyTestStart(uint8_t index) -{ +void BtFrequencyTestStart(uint8_t index) { - TRACE(2,"[%s] index is %d", __func__, index); - if (index < sizeof(hci_cmd_bt_no_signaling_test_configuration)/sizeof(hci_cmd_bt_no_signaling_test_configuration[0])) - { - btdrv_SendData(hci_cmd_bt_no_signaling_test_configuration[index], sizeof(hci_cmd_bt_no_signaling_test_configuration[0])); - } - else - { - btdrv_SendData(hci_cmd_nonsig_tx_dh1_pn9, sizeof(hci_cmd_nonsig_tx_dh1_pn9)); - } + TRACE(2, "[%s] index is %d", __func__, index); + if (index < sizeof(hci_cmd_bt_no_signaling_test_configuration) / + sizeof(hci_cmd_bt_no_signaling_test_configuration[0])) { + btdrv_SendData(hci_cmd_bt_no_signaling_test_configuration[index], + sizeof(hci_cmd_bt_no_signaling_test_configuration[0])); + } else { + btdrv_SendData(hci_cmd_nonsig_tx_dh1_pn9, + sizeof(hci_cmd_nonsig_tx_dh1_pn9)); + } } -void at_no_signaling_ble_test(uint32_t param0,uint32_t param1) -{ - AT_TRACE(1,"[%s]", __func__); +void at_no_signaling_ble_test(uint32_t param0, uint32_t param1) { + AT_TRACE(1, "[%s]", __func__); - char *p; - p = (char*)param0; + char *p; + p = (char *)param0; - switch(*p) - { - case RF_CHANNEL_BLE_STOP: - { - BleFrequencyTestStop(); - break; - } - case RF_FREQUENCY_2402: - { - BleFrequencyTestStart(0); - break; - } - case RF_FREQUENCY_2440: - { - BleFrequencyTestStart(1); - break; - } - case RF_FREQUENCY_2480: - { - BleFrequencyTestStart(2); - break; - } - case RF_FREQUENCY_2402_RX: - { - BleFrequencyTestStartRx(0); - break; - } - case RF_FREQUENCY_2440_RX: - { - BleFrequencyTestStartRx(1); - break; - } - case RF_FREQUENCY_2480_RX: - { - BleFrequencyTestStartRx(2); - break; - } - default: - break; + switch (*p) { + case RF_CHANNEL_BLE_STOP: { + BleFrequencyTestStop(); + break; + } + case RF_FREQUENCY_2402: { + BleFrequencyTestStart(0); + break; + } + case RF_FREQUENCY_2440: { + BleFrequencyTestStart(1); + break; + } + case RF_FREQUENCY_2480: { + BleFrequencyTestStart(2); + break; + } + case RF_FREQUENCY_2402_RX: { + BleFrequencyTestStartRx(0); + break; + } + case RF_FREQUENCY_2440_RX: { + BleFrequencyTestStartRx(1); + break; + } + case RF_FREQUENCY_2480_RX: { + BleFrequencyTestStartRx(2); + break; + } + default: + break; + } - } - - return; + return; } -void at_no_signaling_bt_test(uint32_t param0,uint32_t param1) -{ - AT_TRACE(1,"[%s]", __func__); +void at_no_signaling_bt_test(uint32_t param0, uint32_t param1) { + AT_TRACE(1, "[%s]", __func__); - int idex; - char *p; + int idex; + char *p; - p = (char*)param0; - idex = atoi(p); - BtFrequencyTestStart(idex); + p = (char *)param0; + idex = atoi(p); + BtFrequencyTestStart(idex); - return; + return; } -void at_get_battery(uint32_t param0,uint32_t param1) -{ - AT_TRACE(1,"[%s]", __func__); +void at_get_battery(uint32_t param0, uint32_t param1) { + AT_TRACE(1, "[%s]", __func__); - uint16_t batteryInfo = 0; - int getstatus = app_battery_get_info( &batteryInfo,NULL, NULL); - if(getstatus) - { - AUTO_TEST_SEND(AT_CMD_RESP_ERROR); - } - else - { - AT_TRACE(1,"battery voltage:%d mV",batteryInfo); - AUTO_TEST_SEND(AT_CMD_RESP_BATTERY); - } - return; + uint16_t batteryInfo = 0; + int getstatus = app_battery_get_info(&batteryInfo, NULL, NULL); + if (getstatus) { + AUTO_TEST_SEND(AT_CMD_RESP_ERROR); + } else { + AT_TRACE(1, "battery voltage:%d mV", batteryInfo); + AUTO_TEST_SEND(AT_CMD_RESP_BATTERY); + } + return; } -void at_set_volume(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; - int idex; - char *p; +void at_set_volume(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; + int idex; + char *p; - AT_TRACE(0,"_debug: I at_set_volume"); + AT_TRACE(0, "_debug: I at_set_volume"); - p = (char*)param0; - idex = atoi(p); - AT_TRACE(1,"_debug: volume set: %d",idex); + p = (char *)param0; + idex = atoi(p); + AT_TRACE(1, "_debug: volume set: %d", idex); - if(idex > TGT_VOLUME_LEVEL_15 ) - { - idex = 17; - } - if(idex < TGT_VOLUME_LEVEL_MUTE ) - { - idex = 1; - } + if (idex > TGT_VOLUME_LEVEL_15) { + idex = 17; + } + if (idex < TGT_VOLUME_LEVEL_MUTE) { + idex = 1; + } - //app_bt_set_volume(APP_BT_STREAM_HFP_PCM,idex); - app_bt_set_volume(APP_BT_STREAM_A2DP_SBC,idex); - //btapp_hfp_report_speak_gain(); - btapp_a2dp_report_speak_gain(); + // app_bt_set_volume(APP_BT_STREAM_HFP_PCM,idex); + app_bt_set_volume(APP_BT_STREAM_A2DP_SBC, idex); + // btapp_hfp_report_speak_gain(); + btapp_a2dp_report_speak_gain(); - _at_resp(); - return; + _at_resp(); + return; } -void at_get_fwversion(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; - uint8_t fw_rev[4]; +void at_get_fwversion(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; + uint8_t fw_rev[4]; - AT_TRACE(0,"_debug: I at_get_fwversion"); + AT_TRACE(0, "_debug: I at_get_fwversion"); - system_get_fwversion(&fw_rev[0], &fw_rev[1], &fw_rev[2], &fw_rev[3]); - AT_TRACE(4,"_debug: FwVersion: %d.%d.%d.%d",fw_rev[0], fw_rev[1], fw_rev[2], fw_rev[3]); - AUTO_TEST_SEND(AT_CMD_RESP_FWVER); + system_get_fwversion(&fw_rev[0], &fw_rev[1], &fw_rev[2], &fw_rev[3]); + AT_TRACE(4, "_debug: FwVersion: %d.%d.%d.%d", fw_rev[0], fw_rev[1], fw_rev[2], + fw_rev[3]); + AUTO_TEST_SEND(AT_CMD_RESP_FWVER); - _at_resp(); - return; + _at_resp(); + return; } -void at_get_bootmode(uint32_t param0,uint32_t param1) -{ - AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; - cmd_id = cmd_id; - uint32_t bootmode; +void at_get_bootmode(uint32_t param0, uint32_t param1) { + AT_CMD_ID_ENUM_T cmd_id = (AT_CMD_ID_ENUM_T)param1; + cmd_id = cmd_id; + uint32_t bootmode; - AT_TRACE(0,"_debug: I at_get_bootmode"); + AT_TRACE(0, "_debug: I at_get_bootmode"); - bootmode = hal_sw_bootmode_get(); - AT_TRACE(1,"_debug: bootmode: 0x%x.",bootmode); - AUTO_TEST_SEND(AT_CMD_RESP_BOOTMODE); + bootmode = hal_sw_bootmode_get(); + AT_TRACE(1, "_debug: bootmode: 0x%x.", bootmode); + AUTO_TEST_SEND(AT_CMD_RESP_BOOTMODE); - _at_resp(); - return; + _at_resp(); + return; } -int32_t at_Init(void) -{ - int32_t ret; +int32_t at_Init(void) { + int32_t ret; - AT_TRACE(0,"at_Init."); - ret = at_os_init(); - return ret; + AT_TRACE(0, "at_Init."); + ret = at_os_init(); + return ret; } -#endif// (_AUTO_TEST_) - - +#endif // (_AUTO_TEST_) diff --git a/services/ble_app/app_amsc/app_amsc.c b/services/ble_app/app_amsc/app_amsc.c index 001e702..47414bf 100644 --- a/services/ble_app/app_amsc/app_amsc.c +++ b/services/ble_app/app_amsc/app_amsc.c @@ -14,7 +14,6 @@ * ****************************************************************************/ - /** **************************************************************************************** * @addtogroup APP @@ -32,14 +31,14 @@ #if (BLE_APP_PRESENT) #if (BLE_AMS_CLIENT) -#include "app_amsc.h" // Health Thermometer Application Definitions -#include "app.h" // Application Definitions -#include "app_task.h" // application task definitions -#include "amsc_task.h" // health thermometer functions +#include "amsc_task.h" // health thermometer functions +#include "app.h" // Application Definitions +#include "app_amsc.h" // Health Thermometer Application Definitions +#include "app_task.h" // application task definitions +#include "arch.h" // Platform Definitions #include "co_bt.h" #include "prf_types.h" #include "prf_utils.h" -#include "arch.h" // Platform Definitions #include "co_math.h" #include "ke_timer.h" @@ -47,27 +46,26 @@ /* * FUNCTION DEFINITIONS **************************************************************************************** -*/ - -void app_amsc_add_amsc(void) -{ - struct gapm_profile_task_add_cmd *req = KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, - TASK_GAPM, TASK_APP, - gapm_profile_task_add_cmd, 0); - - // Fill message - req->operation = GAPM_PROFILE_TASK_ADD; -#if BLE_CONNECTION_MAX>1 - req->sec_lvl = PERM(SVC_AUTH, ENABLE)|PERM(SVC_MI, ENABLE); -#else - req->sec_lvl = PERM(SVC_AUTH, ENABLE); -#endif - req->prf_task_id = TASK_ID_AMSC; - req->app_task = TASK_APP; - req->start_hdl = 0; + */ - // Send the message - ke_msg_send(req); +void app_amsc_add_amsc(void) { + struct gapm_profile_task_add_cmd *req = + KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, TASK_GAPM, TASK_APP, + gapm_profile_task_add_cmd, 0); + + // Fill message + req->operation = GAPM_PROFILE_TASK_ADD; +#if BLE_CONNECTION_MAX > 1 + req->sec_lvl = PERM(SVC_AUTH, ENABLE) | PERM(SVC_MI, ENABLE); +#else + req->sec_lvl = PERM(SVC_AUTH, ENABLE); +#endif + req->prf_task_id = TASK_ID_AMSC; + req->app_task = TASK_APP; + req->start_hdl = 0; + + // Send the message + ke_msg_send(req); } /** @@ -76,21 +74,20 @@ void app_amsc_add_amsc(void) * **************************************************************************************** */ -void app_amsc_enable(uint8_t conidx) -{ - // Allocate the message - struct amsc_enable_req * req = KE_MSG_ALLOC(AMSC_ENABLE_REQ, - KE_BUILD_ID(prf_get_task_from_id(TASK_ID_AMSC), conidx), TASK_APP, - amsc_enable_req); +void app_amsc_enable(uint8_t conidx) { + // Allocate the message + struct amsc_enable_req *req = KE_MSG_ALLOC( + AMSC_ENABLE_REQ, KE_BUILD_ID(prf_get_task_from_id(TASK_ID_AMSC), conidx), + TASK_APP, amsc_enable_req); - // Fill in the parameter structure - req->conidx = conidx; - - // Send the message - ke_msg_send(req); + // Fill in the parameter structure + req->conidx = conidx; + + // Send the message + ke_msg_send(req); } -#endif //BLE_AMS_CLIENT -#endif //BLE_APP_PRESENT +#endif // BLE_AMS_CLIENT +#endif // BLE_APP_PRESENT /// @} APP diff --git a/services/ble_app/app_amsc/app_amsc_task.c b/services/ble_app/app_amsc/app_amsc_task.c index e02bba6..77fc704 100644 --- a/services/ble_app/app_amsc/app_amsc_task.c +++ b/services/ble_app/app_amsc/app_amsc_task.c @@ -14,7 +14,6 @@ * ****************************************************************************/ - /** **************************************************************************************** * @addtogroup APPTASK @@ -27,7 +26,7 @@ **************************************************************************************** */ -#include "rwip_config.h" // SW configuration +#include "rwip_config.h" // SW configuration #if (BLE_APP_PRESENT) @@ -35,8 +34,8 @@ #include "app_amsc.h" #include "app_amsc_task.h" -#include "app_task.h" // Application Task API #include "app_sec.h" +#include "app_task.h" // Application Task API #include "ke_msg.h" /* @@ -58,24 +57,23 @@ */ int amsc_anc_enable_rsp_handler(ke_msg_id_t const msgid, - struct amsc_enable_rsp const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - - return (KE_MSG_CONSUMED); + struct amsc_enable_rsp const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + + return (KE_MSG_CONSUMED); } /// Default State handlers definition -const struct ke_msg_handler app_amsc_msg_handler_list[] = -{ - {AMSC_ENABLE_RSP, (ke_msg_func_t)amsc_anc_enable_rsp_handler}, +const struct ke_msg_handler app_amsc_msg_handler_list[] = { + {AMSC_ENABLE_RSP, (ke_msg_func_t)amsc_anc_enable_rsp_handler}, }; -const struct ke_state_handler app_amsc_table_handler = - {&app_amsc_msg_handler_list[0], (sizeof(app_amsc_msg_handler_list)/sizeof(struct ke_msg_handler))}; +const struct ke_state_handler app_amsc_table_handler = { + &app_amsc_msg_handler_list[0], + (sizeof(app_amsc_msg_handler_list) / sizeof(struct ke_msg_handler))}; -#endif //BLE_AMS_CLIENT +#endif // BLE_AMS_CLIENT #endif //(BLE_APP_PRESENT) diff --git a/services/ble_app/app_ancc/app_ancc.c b/services/ble_app/app_ancc/app_ancc.c index f7996b7..4714b69 100644 --- a/services/ble_app/app_ancc/app_ancc.c +++ b/services/ble_app/app_ancc/app_ancc.c @@ -31,14 +31,14 @@ #if (BLE_APP_PRESENT) #if (BLE_ANC_CLIENT) -#include "app_ancc.h" // Health Thermometer Application Definitions -#include "app.h" // Application Definitions -#include "app_task.h" // application task definitions -#include "ancc_task.h" // health thermometer functions +#include "ancc_task.h" // health thermometer functions +#include "app.h" // Application Definitions +#include "app_ancc.h" // Health Thermometer Application Definitions +#include "app_task.h" // application task definitions +#include "arch.h" // Platform Definitions #include "co_bt.h" #include "prf_types.h" #include "prf_utils.h" -#include "arch.h" // Platform Definitions #include "co_math.h" #include "ke_timer.h" @@ -46,31 +46,28 @@ /* * FUNCTION DEFINITIONS **************************************************************************************** -*/ + */ -void app_ancc_add_ancc(void) -{ - BLE_APP_DBG("app_ancc_add_ancc"); - struct gapm_profile_task_add_cmd *req = KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, - TASK_GAPM, - TASK_APP, - gapm_profile_task_add_cmd, - 0); +void app_ancc_add_ancc(void) { + BLE_APP_DBG("app_ancc_add_ancc"); + struct gapm_profile_task_add_cmd *req = + KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, TASK_GAPM, TASK_APP, + gapm_profile_task_add_cmd, 0); - // Fill message - req->operation = GAPM_PROFILE_TASK_ADD; + // Fill message + req->operation = GAPM_PROFILE_TASK_ADD; #if BLE_CONNECTION_MAX > 1 - req->sec_lvl = PERM(SVC_AUTH, ENABLE) | PERM(SVC_MI, ENABLE); + req->sec_lvl = PERM(SVC_AUTH, ENABLE) | PERM(SVC_MI, ENABLE); #else - req->sec_lvl = PERM(SVC_AUTH, ENABLE); + req->sec_lvl = PERM(SVC_AUTH, ENABLE); #endif - req->prf_task_id = TASK_ID_ANCC; - req->app_task = TASK_APP; - req->start_hdl = 0; + req->prf_task_id = TASK_ID_ANCC; + req->app_task = TASK_APP; + req->start_hdl = 0; - // Send the message - ke_msg_send(req); + // Send the message + ke_msg_send(req); } /** @@ -79,25 +76,23 @@ void app_ancc_add_ancc(void) * **************************************************************************************** */ -void app_ancc_enable(uint8_t conidx) -{ - BLE_FUNC_ENTER(); +void app_ancc_enable(uint8_t conidx) { + BLE_FUNC_ENTER(); - // Allocate the message - struct ancc_enable_req *req = KE_MSG_ALLOC(ANCC_ENABLE_REQ, - KE_BUILD_ID(prf_get_task_from_id(TASK_ID_ANCC), conidx), - TASK_APP, - ancc_enable_req); + // Allocate the message + struct ancc_enable_req *req = KE_MSG_ALLOC( + ANCC_ENABLE_REQ, KE_BUILD_ID(prf_get_task_from_id(TASK_ID_ANCC), conidx), + TASK_APP, ancc_enable_req); - // Fill in the parameter structure + // Fill in the parameter structure - req->conidx = conidx; + req->conidx = conidx; - // Send the message - ke_msg_send(req); + // Send the message + ke_msg_send(req); } -#endif //BLE_ANC_CLIENT -#endif //BLE_APP_PRESENT +#endif // BLE_ANC_CLIENT +#endif // BLE_APP_PRESENT /// @} APP diff --git a/services/ble_app/app_ancc/app_ancc_task.c b/services/ble_app/app_ancc/app_ancc_task.c index 824c2b9..2ae3d78 100644 --- a/services/ble_app/app_ancc/app_ancc_task.c +++ b/services/ble_app/app_ancc/app_ancc_task.c @@ -14,7 +14,6 @@ * ****************************************************************************/ - /** **************************************************************************************** * @addtogroup APPTASK @@ -27,7 +26,7 @@ **************************************************************************************** */ -#include "rwip_config.h" // SW configuration +#include "rwip_config.h" // SW configuration #if (BLE_APP_PRESENT) @@ -35,8 +34,8 @@ #include "app_ancc.h" #include "app_ancc_task.h" -#include "app_task.h" // Application Task API #include "app_sec.h" +#include "app_task.h" // Application Task API /* * FUNCTION DEFINITIONS @@ -57,25 +56,23 @@ */ int ancc_anc_enable_rsp_handler(ke_msg_id_t const msgid, - struct ancc_enable_rsp const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - - - return (KE_MSG_CONSUMED); + struct ancc_enable_rsp const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + + return (KE_MSG_CONSUMED); } /// Default State handlers definition -const struct ke_msg_handler app_ancc_msg_handler_list[] = -{ - {ANCC_ENABLE_RSP, (ke_msg_func_t)ancc_anc_enable_rsp_handler}, +const struct ke_msg_handler app_ancc_msg_handler_list[] = { + {ANCC_ENABLE_RSP, (ke_msg_func_t)ancc_anc_enable_rsp_handler}, }; -const struct ke_state_handler app_ancc_table_handler = - {&app_ancc_msg_handler_list[0], (sizeof(app_ancc_msg_handler_list)/sizeof(struct ke_msg_handler))}; +const struct ke_state_handler app_ancc_table_handler = { + &app_ancc_msg_handler_list[0], + (sizeof(app_ancc_msg_handler_list) / sizeof(struct ke_msg_handler))}; -#endif //BLE_ANC_CLIENT +#endif // BLE_ANC_CLIENT #endif //(BLE_APP_PRESENT) diff --git a/services/ble_app/app_batt/app_batt.c b/services/ble_app/app_batt/app_batt.c index 0f26a7c..5d3f801 100644 --- a/services/ble_app/app_batt/app_batt.c +++ b/services/ble_app/app_batt/app_batt.c @@ -20,7 +20,7 @@ **************************************************************************************** */ -#include "rwip_config.h" // SW configuration +#include "rwip_config.h" // SW configuration #if (BLE_APP_BATT) @@ -29,14 +29,14 @@ **************************************************************************************** */ -#include "app_batt.h" // Battery Application Module Definitions -#include "app.h" // Application Definitions -#include "app_task.h" // application task definitions -#include "bass_task.h" // health thermometer functions +#include "app.h" // Application Definitions +#include "app_batt.h" // Battery Application Module Definitions +#include "app_task.h" // application task definitions +#include "arch.h" // Platform Definitions +#include "bass_task.h" // health thermometer functions #include "co_bt.h" -#include "prf_types.h" // Profile common types definition -#include "arch.h" // Platform Definitions #include "prf.h" +#include "prf_types.h" // Profile common types definition #include /* @@ -57,108 +57,98 @@ struct app_batt_env_tag app_batt_env; **************************************************************************************** */ -void app_batt_init(void) -{ - // Reset the environment - memset(&app_batt_env, 0, sizeof(struct app_batt_env_tag)); +void app_batt_init(void) { + // Reset the environment + memset(&app_batt_env, 0, sizeof(struct app_batt_env_tag)); - // Initial battery level: 100 - app_batt_env.batt_lvl = 100; + // Initial battery level: 100 + app_batt_env.batt_lvl = 100; } -void app_batt_add_bas(void) -{ - struct bass_db_cfg* db_cfg; - // Allocate the BASS_CREATE_DB_REQ - struct gapm_profile_task_add_cmd *req = KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, - TASK_GAPM, TASK_APP, - gapm_profile_task_add_cmd, sizeof(struct bass_db_cfg)); - // Fill message - req->operation = GAPM_PROFILE_TASK_ADD; -#if BLE_CONNECTION_MAX>1 - req->sec_lvl = PERM(SVC_AUTH, ENABLE)|PERM(SVC_MI, ENABLE); +void app_batt_add_bas(void) { + struct bass_db_cfg *db_cfg; + // Allocate the BASS_CREATE_DB_REQ + struct gapm_profile_task_add_cmd *req = + KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, TASK_GAPM, TASK_APP, + gapm_profile_task_add_cmd, sizeof(struct bass_db_cfg)); + // Fill message + req->operation = GAPM_PROFILE_TASK_ADD; +#if BLE_CONNECTION_MAX > 1 + req->sec_lvl = PERM(SVC_AUTH, ENABLE) | PERM(SVC_MI, ENABLE); #else - req->sec_lvl = PERM(SVC_AUTH, ENABLE); + req->sec_lvl = PERM(SVC_AUTH, ENABLE); #endif - req->prf_task_id = TASK_ID_BASS; - req->app_task = TASK_APP; - req->start_hdl = 0; + req->prf_task_id = TASK_ID_BASS; + req->app_task = TASK_APP; + req->start_hdl = 0; - // Set parameters - db_cfg = (struct bass_db_cfg* ) req->param; - - // Add a BAS instance - db_cfg->bas_nb = 1; - // Sending of notifications is supported - db_cfg->features[0] = BAS_BATT_LVL_NTF_SUP; + // Set parameters + db_cfg = (struct bass_db_cfg *)req->param; - // Send the message - ke_msg_send(req); + // Add a BAS instance + db_cfg->bas_nb = 1; + // Sending of notifications is supported + db_cfg->features[0] = BAS_BATT_LVL_NTF_SUP; + + // Send the message + ke_msg_send(req); } -void app_batt_enable_prf(uint8_t conidx) -{ - app_batt_env.conidx = conidx; +void app_batt_enable_prf(uint8_t conidx) { + app_batt_env.conidx = conidx; - // Allocate the message - struct bass_enable_req * req = KE_MSG_ALLOC(BASS_ENABLE_REQ, - KE_BUILD_ID(prf_get_task_from_id(TASK_ID_BASS), conidx), - TASK_APP, - bass_enable_req); + // Allocate the message + struct bass_enable_req *req = KE_MSG_ALLOC( + BASS_ENABLE_REQ, KE_BUILD_ID(prf_get_task_from_id(TASK_ID_BASS), conidx), + TASK_APP, bass_enable_req); - // Fill in the parameter structure - req->conidx = conidx; + // Fill in the parameter structure + req->conidx = conidx; - // NTF initial status - Disabled - req->ntf_cfg = PRF_CLI_STOP_NTFIND; - req->old_batt_lvl[0] = 50; + // NTF initial status - Disabled + req->ntf_cfg = PRF_CLI_STOP_NTFIND; + req->old_batt_lvl[0] = 50; - // Send the message - ke_msg_send(req); + // Send the message + ke_msg_send(req); } -void app_batt_send_lvl(uint8_t conidx, uint8_t batt_lvl) -{ - ASSERT_ERR(batt_lvl <= BAS_BATTERY_LVL_MAX); +void app_batt_send_lvl(uint8_t conidx, uint8_t batt_lvl) { + ASSERT_ERR(batt_lvl <= BAS_BATTERY_LVL_MAX); - // Allocate the message - struct bass_batt_level_upd_req * req = KE_MSG_ALLOC(BASS_BATT_LEVEL_UPD_REQ, - KE_BUILD_ID(prf_get_task_from_id(TASK_ID_BASS), conidx), - TASK_APP, - bass_batt_level_upd_req); + // Allocate the message + struct bass_batt_level_upd_req *req = + KE_MSG_ALLOC(BASS_BATT_LEVEL_UPD_REQ, + KE_BUILD_ID(prf_get_task_from_id(TASK_ID_BASS), conidx), + TASK_APP, bass_batt_level_upd_req); - // Fill in the parameter structure - req->bas_instance = 0; - req->batt_level = batt_lvl; + // Fill in the parameter structure + req->bas_instance = 0; + req->batt_level = batt_lvl; - // Send the message - ke_msg_send(req); + // Send the message + ke_msg_send(req); } -static int bass_batt_level_ntf_cfg_ind_handler(ke_msg_id_t const msgid, - struct bass_batt_level_ntf_cfg_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - return (KE_MSG_CONSUMED); +static int bass_batt_level_ntf_cfg_ind_handler( + ke_msg_id_t const msgid, struct bass_batt_level_ntf_cfg_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + return (KE_MSG_CONSUMED); } static int batt_level_upd_handler(ke_msg_id_t const msgid, - struct bass_batt_level_upd_rsp const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - return (KE_MSG_CONSUMED); + struct bass_batt_level_upd_rsp const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + return (KE_MSG_CONSUMED); } - static int bass_enable_rsp_handler(ke_msg_id_t const msgid, - struct bass_enable_rsp const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - return (KE_MSG_CONSUMED); + struct bass_enable_rsp const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + return (KE_MSG_CONSUMED); } /** @@ -173,14 +163,12 @@ static int bass_enable_rsp_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -static int app_batt_msg_dflt_handler(ke_msg_id_t const msgid, - void const *param, +static int app_batt_msg_dflt_handler(ke_msg_id_t const msgid, void const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Drop the message + ke_task_id_t const src_id) { + // Drop the message - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /* @@ -189,17 +177,19 @@ static int app_batt_msg_dflt_handler(ke_msg_id_t const msgid, */ /// Default State handlers definition -const struct ke_msg_handler app_batt_msg_handler_list[] = -{ - // Note: first message is latest message checked by kernel so default is put on top. - {KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_batt_msg_dflt_handler}, - {BASS_BATT_LEVEL_NTF_CFG_IND, (ke_msg_func_t)bass_batt_level_ntf_cfg_ind_handler}, - {BASS_BATT_LEVEL_UPD_RSP, (ke_msg_func_t)batt_level_upd_handler}, +const struct ke_msg_handler app_batt_msg_handler_list[] = { + // Note: first message is latest message checked by kernel so default is put + // on top. + {KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_batt_msg_dflt_handler}, + {BASS_BATT_LEVEL_NTF_CFG_IND, + (ke_msg_func_t)bass_batt_level_ntf_cfg_ind_handler}, + {BASS_BATT_LEVEL_UPD_RSP, (ke_msg_func_t)batt_level_upd_handler}, }; -const struct ke_state_handler app_batt_table_handler = - {&app_batt_msg_handler_list[0], (sizeof(app_batt_msg_handler_list)/sizeof(struct ke_msg_handler))}; +const struct ke_state_handler app_batt_table_handler = { + &app_batt_msg_handler_list[0], + (sizeof(app_batt_msg_handler_list) / sizeof(struct ke_msg_handler))}; -#endif //BLE_APP_BATT +#endif // BLE_APP_BATT /// @} APP diff --git a/services/ble_app/app_ble_key.cpp b/services/ble_app/app_ble_key.cpp index 69b4603..a4b9fd5 100644 --- a/services/ble_app/app_ble_key.cpp +++ b/services/ble_app/app_ble_key.cpp @@ -13,79 +13,74 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include -#include #include "app_key.h" #include "hal_trace.h" +#include +#include +#include -#define TEST_KEY_UP HAL_KEY_CODE_FN3 -#define TEST_KEY_DOWN HAL_KEY_CODE_FN4 +#define TEST_KEY_UP HAL_KEY_CODE_FN3 +#define TEST_KEY_DOWN HAL_KEY_CODE_FN4 -#define TEST_KEY_UP_VALUE 0x12 -#define TEST_KEY_DOWN_VALUE 0x34 +#define TEST_KEY_UP_VALUE 0x12 +#define TEST_KEY_DOWN_VALUE 0x34 extern void register_ble_key_handle_cb(void (*cb)(APP_KEY_STATUS)); extern "C" { - extern void app_ble_key_notify(uint8_t len, uint8_t* value); +extern void app_ble_key_notify(uint8_t len, uint8_t *value); } void app_ble_key_handle(APP_KEY_STATUS ble_key); -uint32_t app_ble_key_init() -{ - register_ble_key_handle_cb(app_ble_key_handle); +uint32_t app_ble_key_init() { register_ble_key_handle_cb(app_ble_key_handle); } + +void ble_key_handle_up_key(enum APP_KEY_EVENT_T event) { + uint8_t value = TEST_KEY_UP_VALUE; + switch (event) { + case APP_KEY_EVENT_UP: + app_ble_key_notify(sizeof(value), &value); + break; + case APP_KEY_EVENT_CLICK: + // app_ble_key_notify(sizeof(value), &value); + break; + case APP_KEY_EVENT_DOUBLECLICK: + break; + default: + TRACE(1, "unregister up key event=%x", event); + } } -void ble_key_handle_up_key(enum APP_KEY_EVENT_T event) -{ - uint8_t value = TEST_KEY_UP_VALUE; - switch(event) { - case APP_KEY_EVENT_UP: - app_ble_key_notify(sizeof(value), &value); - break; - case APP_KEY_EVENT_CLICK: - //app_ble_key_notify(sizeof(value), &value); - break; - case APP_KEY_EVENT_DOUBLECLICK: - break; - default: - TRACE(1,"unregister up key event=%x",event); - } +void ble_key_handle_down_key(enum APP_KEY_EVENT_T event) { + uint8_t value = TEST_KEY_DOWN_VALUE; + switch (event) { + case APP_KEY_EVENT_UP: + app_ble_key_notify(sizeof(value), &value); + break; + case APP_KEY_EVENT_CLICK: + // app_ble_key_notify(sizeof(value), &value); + break; + case APP_KEY_EVENT_DOUBLECLICK: + break; + default: + TRACE(1, "unregister up key event=%x", event); + } } -void ble_key_handle_down_key(enum APP_KEY_EVENT_T event) -{ - uint8_t value = TEST_KEY_DOWN_VALUE; - switch(event) { - case APP_KEY_EVENT_UP: - app_ble_key_notify(sizeof(value), &value); - break; - case APP_KEY_EVENT_CLICK: - //app_ble_key_notify(sizeof(value), &value); - break; - case APP_KEY_EVENT_DOUBLECLICK: - break; - default: - TRACE(1,"unregister up key event=%x",event); - } -} - -void app_ble_key_handle(APP_KEY_STATUS ble_key) -{ - if(ble_key.code != 0xff) { - TRACE(2,"app_ble_key_handle code:%x event:%x",ble_key.code, ble_key.event); - switch (ble_key.code) { - case TEST_KEY_UP: - ble_key_handle_up_key((enum APP_KEY_EVENT_T)ble_key.event); - break; - case TEST_KEY_DOWN: - ble_key_handle_down_key((enum APP_KEY_EVENT_T)ble_key.event); - break; - default: - TRACE(0,"app_ble_key_handle undefined key"); - break; - } +void app_ble_key_handle(APP_KEY_STATUS ble_key) { + if (ble_key.code != 0xff) { + TRACE(2, "app_ble_key_handle code:%x event:%x", ble_key.code, + ble_key.event); + switch (ble_key.code) { + case TEST_KEY_UP: + ble_key_handle_up_key((enum APP_KEY_EVENT_T)ble_key.event); + break; + case TEST_KEY_DOWN: + ble_key_handle_down_key((enum APP_KEY_EVENT_T)ble_key.event); + break; + default: + TRACE(0, "app_ble_key_handle undefined key"); + break; } + } } diff --git a/services/ble_app/app_ble_uart.cpp b/services/ble_app/app_ble_uart.cpp index 5160226..01e29cb 100644 --- a/services/ble_app/app_ble_uart.cpp +++ b/services/ble_app/app_ble_uart.cpp @@ -14,13 +14,13 @@ * ****************************************************************************/ //#include "mbed.h" -#include -#include -#include -#include "hal_uart.h" #include "hal_trace.h" +#include "hal_uart.h" +#include +#include +#include -#define APP_BLE_UART_BUFF_SIZE 50 //16 +#define APP_BLE_UART_BUFF_SIZE 50 // 16 enum HAL_UART_ID_T app_ble_uart_id = HAL_UART_ID_0; @@ -33,112 +33,107 @@ extern int gatt_loop_write(uint8_t *buffer, uint32_t length); static uint32_t app_ble_debug_cnt = 0; -void app_ble_send_data(uint8_t *buffer, uint32_t length) -{ - TRACE(1,"[%s]", __func__); - gatt_uart_write(buffer, length); -// gatt_loop_write(buffer, length); +void app_ble_send_data(uint8_t *buffer, uint32_t length) { + TRACE(1, "[%s]", __func__); + gatt_uart_write(buffer, length); + // gatt_loop_write(buffer, length); } -typedef struct -{ - volatile bool rx_done; - volatile bool tx_done; - uint8_t rx_data[APP_BLE_UART_BUFF_SIZE]; - uint32_t rx_len; +typedef struct { + volatile bool rx_done; + volatile bool tx_done; + uint8_t rx_data[APP_BLE_UART_BUFF_SIZE]; + uint32_t rx_len; } app_ble_uart_t; app_ble_uart_t app_ble_uart; -static void uart_rx(uint32_t xfer_size, int dma_error, union HAL_UART_IRQ_T status) -{ - app_ble_debug_cnt = 4; - if (dma_error) { -// TRACE(1,"uart_rx dma error: xfer_size=%d", xfer_size); - app_ble_debug_cnt = 0xfe; - app_ble_uart.rx_len = 0; - } else if (status.BE || status.FE || status.OE || status.PE) { -// TRACE(2,"uart_rx uart error: xfer_size=%d, status=0x%08x", xfer_size, status.reg); - app_ble_debug_cnt = 0xfd; - app_ble_uart.rx_len = 0; - } else { - app_ble_debug_cnt = 0xfc; - app_ble_uart.rx_len = xfer_size; -// hal_uart_dma_recv(app_ble_uart_id, app_ble_uart.rx_data, app_ble_uart.rx_len - 5, NULL, NULL); -// gatt_uart_write(app_ble_uart.rx_data, app_ble_uart.rx_len - 5); +static void uart_rx(uint32_t xfer_size, int dma_error, + union HAL_UART_IRQ_T status) { + app_ble_debug_cnt = 4; + if (dma_error) { + // TRACE(1,"uart_rx dma error: xfer_size=%d", xfer_size); + app_ble_debug_cnt = 0xfe; + app_ble_uart.rx_len = 0; + } else if (status.BE || status.FE || status.OE || status.PE) { + // TRACE(2,"uart_rx uart error: xfer_size=%d, status=0x%08x", + // xfer_size, status.reg); + app_ble_debug_cnt = 0xfd; + app_ble_uart.rx_len = 0; + } else { + app_ble_debug_cnt = 0xfc; + app_ble_uart.rx_len = xfer_size; + // hal_uart_dma_recv(app_ble_uart_id, app_ble_uart.rx_data, + // app_ble_uart.rx_len - 5, NULL, NULL); + // gatt_uart_write(app_ble_uart.rx_data, app_ble_uart.rx_len - 5); -// hal_uart_dma_recv(app_ble_uart_id, app_ble_uart.rx_data, 5, NULL, NULL); -// gatt_uart_write(app_ble_uart.rx_data, 5); + // hal_uart_dma_recv(app_ble_uart_id, app_ble_uart.rx_data, 5, NULL, + // NULL); gatt_uart_write(app_ble_uart.rx_data, 5); - hal_uart_dma_recv(app_ble_uart_id, app_ble_uart.rx_data, sizeof(app_ble_uart.rx_data), NULL, NULL); -// //hal_uart_dma_send(app_ble_uart_id, app_ble_uart.rx_data, app_ble_uart.rx_len, NULL, NULL); - gatt_uart_write(app_ble_uart.rx_data, app_ble_uart.rx_len); - } + hal_uart_dma_recv(app_ble_uart_id, app_ble_uart.rx_data, + sizeof(app_ble_uart.rx_data), NULL, NULL); + // //hal_uart_dma_send(app_ble_uart_id, app_ble_uart.rx_data, + // app_ble_uart.rx_len, NULL, NULL); + gatt_uart_write(app_ble_uart.rx_data, app_ble_uart.rx_len); + } - app_ble_uart.rx_done = true; + app_ble_uart.rx_done = true; } -static void uart_tx(uint32_t xfer_size, int dma_error) -{ - if (dma_error) - { -// TRACE(1,"uart_tx dma error: xfer_size=%d", xfer_size); - app_ble_debug_cnt = 0xfb; - } - app_ble_uart.tx_done = true; +static void uart_tx(uint32_t xfer_size, int dma_error) { + if (dma_error) { + // TRACE(1,"uart_tx dma error: xfer_size=%d", xfer_size); + app_ble_debug_cnt = 0xfb; + } + app_ble_uart.tx_done = true; } -void app_ble_uart_write_request_cb(uint8_t *buf, uint32_t len) -{ - //send data over uart. - hal_uart_dma_send(app_ble_uart_id, buf, len, NULL, NULL); - //DUMP8("%x ", buf, len); - +void app_ble_uart_write_request_cb(uint8_t *buf, uint32_t len) { + // send data over uart. + hal_uart_dma_send(app_ble_uart_id, buf, len, NULL, NULL); + // DUMP8("%x ", buf, len); } -uint32_t app_ble_uart_open() -{ +uint32_t app_ble_uart_open() { #if 1 - int ret; - union HAL_UART_IRQ_T mask; + int ret; + union HAL_UART_IRQ_T mask; - struct HAL_UART_CFG_T uart_cfg; + struct HAL_UART_CFG_T uart_cfg; - uart_cfg.parity = HAL_UART_PARITY_NONE, - uart_cfg.stop = HAL_UART_STOP_BITS_1, - uart_cfg.data = HAL_UART_DATA_BITS_8, - uart_cfg.flow = HAL_UART_FLOW_CONTROL_NONE, - uart_cfg.tx_level = HAL_UART_FIFO_LEVEL_1_2, - uart_cfg.rx_level = HAL_UART_FIFO_LEVEL_1_4, - uart_cfg.baud = 115200, - uart_cfg.dma_rx = true, - uart_cfg.dma_tx = true, - uart_cfg.dma_rx_stop_on_err = false; + uart_cfg.parity = HAL_UART_PARITY_NONE, uart_cfg.stop = HAL_UART_STOP_BITS_1, + uart_cfg.data = HAL_UART_DATA_BITS_8, + uart_cfg.flow = HAL_UART_FLOW_CONTROL_NONE, + uart_cfg.tx_level = HAL_UART_FIFO_LEVEL_1_2, + uart_cfg.rx_level = HAL_UART_FIFO_LEVEL_1_4, uart_cfg.baud = 115200, + uart_cfg.dma_rx = true, uart_cfg.dma_tx = true, + uart_cfg.dma_rx_stop_on_err = false; - app_ble_debug_cnt = 1; + app_ble_debug_cnt = 1; - ret = hal_uart_open(app_ble_uart_id, &uart_cfg); - if (ret) { - app_ble_debug_cnt = 0xff; -// TRACE(0,"Failed to open uart"); - return 1; - } + ret = hal_uart_open(app_ble_uart_id, &uart_cfg); + if (ret) { + app_ble_debug_cnt = 0xff; + // TRACE(0,"Failed to open uart"); + return 1; + } - app_ble_debug_cnt = 2; - hal_uart_irq_set_dma_handler(app_ble_uart_id, uart_rx, uart_tx); -// hal_uart_dma_recv(app_ble_uart_id, app_ble_uart.rx_data, sizeof(app_ble_uart.rx_data), NULL, NULL); - mask.reg = 0; - mask.BE = 1; - mask.FE = 1; - mask.OE = 1; - mask.PE = 1; - mask.RT = 1; - hal_uart_irq_set_mask(app_ble_uart_id, mask); - app_ble_debug_cnt = 3; + app_ble_debug_cnt = 2; + hal_uart_irq_set_dma_handler(app_ble_uart_id, uart_rx, uart_tx); + // hal_uart_dma_recv(app_ble_uart_id, app_ble_uart.rx_data, + // sizeof(app_ble_uart.rx_data), NULL, NULL); + mask.reg = 0; + mask.BE = 1; + mask.FE = 1; + mask.OE = 1; + mask.PE = 1; + mask.RT = 1; + hal_uart_irq_set_mask(app_ble_uart_id, mask); + app_ble_debug_cnt = 3; - app_ble_uart.rx_done = false; - app_ble_uart.tx_done = false; + app_ble_uart.rx_done = false; + app_ble_uart.tx_done = false; #endif - gatt_uart_register_write_request_cb(app_ble_uart_write_request_cb); - return 0; + gatt_uart_register_write_request_cb(app_ble_uart_write_request_cb); + return 0; } diff --git a/services/ble_app/app_datapath/app_ble_cmd_handler.c b/services/ble_app/app_datapath/app_ble_cmd_handler.c index 8f25f08..ed12b91 100644 --- a/services/ble_app/app_datapath/app_ble_cmd_handler.c +++ b/services/ble_app/app_datapath/app_ble_cmd_handler.c @@ -13,52 +13,51 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "string.h" -#include "bluetooth.h" -#include "cmsis_os.h" -#include "hal_trace.h" -#include "hal_timer.h" -#include "apps.h" -#include "stdbool.h" #include "app_ble_cmd_handler.h" #include "app_ble_custom_cmd.h" +#include "apps.h" +#include "bluetooth.h" +#include "cmsis_os.h" +#include "hal_timer.h" +#include "hal_trace.h" #include "rwapp_config.h" - +#include "stdbool.h" +#include "string.h" #ifdef BTIF_BLE_APP_DATAPATH_SERVER +#define BLE_CUSTOM_CMD_WAITING_RSP_TIMEOUT_COUNT 8 -#define BLE_CUSTOM_CMD_WAITING_RSP_TIMEOUT_COUNT 8 - -#define BLE_RAW_DATA_XFER_BUF_SIZE 80 +#define BLE_RAW_DATA_XFER_BUF_SIZE 80 /** * @brief waiting response timeout supervision data structure * */ -typedef struct -{ - uint16_t entryIndex; /**< The command waiting for the response */ - uint16_t msTillTimeout; /**< run-time timeout left milliseconds */ +typedef struct { + uint16_t entryIndex; /**< The command waiting for the response */ + uint16_t msTillTimeout; /**< run-time timeout left milliseconds */ } BLE_CUSTOM_CMD_WAITING_RSP_SUPERVISOR_T; /** * @brief Custom command handling environment * */ -typedef struct -{ - uint8_t isInRawDataXferStage; /**< true if the received data is raw data, - false if the received data is in the format of BLE_CUSTOM_CMD_PAYLOAD_T*/ - uint16_t lengthOfRawDataXferToReceive; - uint16_t lengthOfReceivedRawDataXfer; - uint8_t* ptrRawXferDstBuf; - BLE_RawDataReceived_Handler_t rawDataHandler; - BLE_CUSTOM_CMD_WAITING_RSP_SUPERVISOR_T waitingRspTimeoutInstance[BLE_CUSTOM_CMD_WAITING_RSP_TIMEOUT_COUNT]; - uint32_t lastSysTicks; - uint8_t timeoutSupervisorCount; - osTimerId supervisor_timer_id; - osMutexId mutex; - +typedef struct { + uint8_t isInRawDataXferStage; /**< true if the received data is raw data, + false if the + received data is in the format of + BLE_CUSTOM_CMD_PAYLOAD_T*/ + uint16_t lengthOfRawDataXferToReceive; + uint16_t lengthOfReceivedRawDataXfer; + uint8_t *ptrRawXferDstBuf; + BLE_RawDataReceived_Handler_t rawDataHandler; + BLE_CUSTOM_CMD_WAITING_RSP_SUPERVISOR_T + waitingRspTimeoutInstance[BLE_CUSTOM_CMD_WAITING_RSP_TIMEOUT_COUNT]; + uint32_t lastSysTicks; + uint8_t timeoutSupervisorCount; + osTimerId supervisor_timer_id; + osMutexId mutex; + } BLE_CUSTOM_CMD_ENV_T; static uint8_t rawDataXferBuf[BLE_RAW_DATA_XFER_BUF_SIZE]; @@ -67,258 +66,260 @@ static BLE_CUSTOM_CMD_ENV_T ble_custom_cmd_env; osMutexDef(app_ble_cmd_mutex); static void ble_custom_cmd_rsp_supervision_timer_cb(void const *n); -osTimerDef (APP_CUSTOM_CMD_RSP_SUPERVISION_TIMER, ble_custom_cmd_rsp_supervision_timer_cb); +osTimerDef(APP_CUSTOM_CMD_RSP_SUPERVISION_TIMER, + ble_custom_cmd_rsp_supervision_timer_cb); static void BLE_remove_waiting_rsp_timeout_supervision(uint16_t entryIndex); -extern void app_datapath_server_send_data_via_notification(uint8_t* ptrData, uint32_t length); -extern void app_datapath_server_send_data_via_indication(uint8_t* ptrData, uint32_t length); -extern void app_datapath_server_send_data_via_write_command(uint8_t* ptrData, uint32_t length); -extern void app_datapath_server_send_data_via_write_request(uint8_t* ptrData, uint32_t length); - +extern void app_datapath_server_send_data_via_notification(uint8_t *ptrData, + uint32_t length); +extern void app_datapath_server_send_data_via_indication(uint8_t *ptrData, + uint32_t length); +extern void app_datapath_server_send_data_via_write_command(uint8_t *ptrData, + uint32_t length); +extern void app_datapath_server_send_data_via_write_request(uint8_t *ptrData, + uint32_t length); /** * @brief Callback function of the waiting response supervisor timer. * */ -static void ble_custom_cmd_rsp_supervision_timer_cb(void const *n) -{ - uint32_t entryIndex = ble_custom_cmd_env.waitingRspTimeoutInstance[0].entryIndex; +static void ble_custom_cmd_rsp_supervision_timer_cb(void const *n) { + uint32_t entryIndex = + ble_custom_cmd_env.waitingRspTimeoutInstance[0].entryIndex; - BLE_remove_waiting_rsp_timeout_supervision(entryIndex); + BLE_remove_waiting_rsp_timeout_supervision(entryIndex); - // it means time-out happens before the response is received from the peer device, - // trigger the response handler - CUSTOM_COMMAND_PTR_FROM_ENTRY_INDEX(entryIndex)->cmdRspHandler(TIMEOUT_WAITING_RESPONSE, NULL, 0); + // it means time-out happens before the response is received from the peer + // device, trigger the response handler + CUSTOM_COMMAND_PTR_FROM_ENTRY_INDEX(entryIndex) + ->cmdRspHandler(TIMEOUT_WAITING_RESPONSE, NULL, 0); } -void BLE_get_response_handler(uint32_t funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - // parameter length check - if (paramLen > sizeof(BLE_CUSTOM_CMD_RSP_T)) - { - return; - } +void BLE_get_response_handler(uint32_t funcCode, uint8_t *ptrParam, + uint32_t paramLen) { + // parameter length check + if (paramLen > sizeof(BLE_CUSTOM_CMD_RSP_T)) { + return; + } - if (0 == ble_custom_cmd_env.timeoutSupervisorCount) - { - return; - } + if (0 == ble_custom_cmd_env.timeoutSupervisorCount) { + return; + } - BLE_CUSTOM_CMD_RSP_T* rsp = (BLE_CUSTOM_CMD_RSP_T *)ptrParam; + BLE_CUSTOM_CMD_RSP_T *rsp = (BLE_CUSTOM_CMD_RSP_T *)ptrParam; - BLE_CUSTOM_CMD_INSTANCE_T* ptCmdInstance = - BLE_custom_command_get_entry_pointer_from_cmd_code(rsp->cmdCodeToRsp); - if (NULL == ptCmdInstance) - { - return; - } - - // remove the function code from the time-out supervision chain - BLE_remove_waiting_rsp_timeout_supervision(rsp->cmdCodeToRsp); + BLE_CUSTOM_CMD_INSTANCE_T *ptCmdInstance = + BLE_custom_command_get_entry_pointer_from_cmd_code(rsp->cmdCodeToRsp); + if (NULL == ptCmdInstance) { + return; + } - // call the response handler - if (ptCmdInstance->cmdRspHandler) - { - ptCmdInstance->cmdRspHandler(rsp->cmdRetStatus, rsp->rspData, rsp->rspDataLen); - } + // remove the function code from the time-out supervision chain + BLE_remove_waiting_rsp_timeout_supervision(rsp->cmdCodeToRsp); + + // call the response handler + if (ptCmdInstance->cmdRspHandler) { + ptCmdInstance->cmdRspHandler(rsp->cmdRetStatus, rsp->rspData, + rsp->rspDataLen); + } } -void BLE_control_raw_data_xfer(bool isStartXfer) -{ - ble_custom_cmd_env.isInRawDataXferStage = isStartXfer; +void BLE_control_raw_data_xfer(bool isStartXfer) { + ble_custom_cmd_env.isInRawDataXferStage = isStartXfer; - if (true == isStartXfer) - { - ble_custom_cmd_env.lengthOfReceivedRawDataXfer = 0; - // default configuration, can be customized by BLE_config_raw_data_xfer - ble_custom_cmd_env.lengthOfRawDataXferToReceive = sizeof(rawDataXferBuf); - ble_custom_cmd_env.ptrRawXferDstBuf = (uint8_t *)&rawDataXferBuf; - ble_custom_cmd_env.rawDataHandler = NULL; - } + if (true == isStartXfer) { + ble_custom_cmd_env.lengthOfReceivedRawDataXfer = 0; + // default configuration, can be customized by BLE_config_raw_data_xfer + ble_custom_cmd_env.lengthOfRawDataXferToReceive = sizeof(rawDataXferBuf); + ble_custom_cmd_env.ptrRawXferDstBuf = (uint8_t *)&rawDataXferBuf; + ble_custom_cmd_env.rawDataHandler = NULL; + } } -void BLE_set_raw_data_xfer_received_callback(BLE_RawDataReceived_Handler_t callback) -{ - ble_custom_cmd_env.rawDataHandler = callback; +void BLE_set_raw_data_xfer_received_callback( + BLE_RawDataReceived_Handler_t callback) { + ble_custom_cmd_env.rawDataHandler = callback; } -void BLE_raw_data_xfer_control_handler(uint32_t funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - bool isStartXfer = false; - - if (OP_START_RAW_DATA_XFER == funcCode) - { - isStartXfer = true; - } +void BLE_raw_data_xfer_control_handler(uint32_t funcCode, uint8_t *ptrParam, + uint32_t paramLen) { + bool isStartXfer = false; - BLE_control_raw_data_xfer(isStartXfer); + if (OP_START_RAW_DATA_XFER == funcCode) { + isStartXfer = true; + } - BLE_send_response_to_command(funcCode, NO_ERROR, NULL, 0, TRANSMISSION_VIA_NOTIFICATION); + BLE_control_raw_data_xfer(isStartXfer); + + BLE_send_response_to_command(funcCode, NO_ERROR, NULL, 0, + TRANSMISSION_VIA_NOTIFICATION); } -void BLE_start_raw_data_xfer_control_rsp_handler(BLE_CUSTOM_CMD_RET_STATUS_E retStatus, uint8_t* ptrParam, uint32_t paramLen) -{ - if (NO_ERROR == retStatus) - { - /**< now the sending data api won't wrap BLE_CUSTOM_CMD_PAYLOAD_T but will directly send the raw data */ - ble_custom_cmd_env.isInRawDataXferStage = true; - } +void BLE_start_raw_data_xfer_control_rsp_handler( + BLE_CUSTOM_CMD_RET_STATUS_E retStatus, uint8_t *ptrParam, + uint32_t paramLen) { + if (NO_ERROR == retStatus) { + /**< now the sending data api won't wrap BLE_CUSTOM_CMD_PAYLOAD_T but will + * directly send the raw data */ + ble_custom_cmd_env.isInRawDataXferStage = true; + } } -void BLE_stop_raw_data_xfer_control_rsp_handler(BLE_CUSTOM_CMD_RET_STATUS_E retStatus, uint8_t* ptrParam, uint32_t paramLen) -{ - if (NO_ERROR == retStatus) - { - ble_custom_cmd_env.isInRawDataXferStage = false; - } +void BLE_stop_raw_data_xfer_control_rsp_handler( + BLE_CUSTOM_CMD_RET_STATUS_E retStatus, uint8_t *ptrParam, + uint32_t paramLen) { + if (NO_ERROR == retStatus) { + ble_custom_cmd_env.isInRawDataXferStage = false; + } } /** * @brief Refresh the waiting response supervisor list * */ -static void ble_custom_cmd_refresh_supervisor_env(void) -{ - // do nothing if no supervisor was added - if (ble_custom_cmd_env.timeoutSupervisorCount > 0) - { - uint32_t currentTicks = GET_CURRENT_TICKS(); - uint32_t passedTicks; - if (currentTicks >= ble_custom_cmd_env.lastSysTicks) - { - passedTicks = (currentTicks - ble_custom_cmd_env.lastSysTicks); - } - else - { - passedTicks = (hal_sys_timer_get_max() - ble_custom_cmd_env.lastSysTicks + 1) + currentTicks; - } - - uint32_t deltaMs = TICKS_TO_MS(passedTicks); - - BLE_CUSTOM_CMD_WAITING_RSP_SUPERVISOR_T* pRspSupervisor = &(ble_custom_cmd_env.waitingRspTimeoutInstance[0]); - for (uint32_t index = 0;index < ble_custom_cmd_env.timeoutSupervisorCount;index++) - { - ASSERT(pRspSupervisor[index].msTillTimeout > deltaMs, - "the waiting command response supervisor timer is missing!!!, \ - %d ms passed but the ms to trigger is %d", deltaMs, pRspSupervisor[index].msTillTimeout); - pRspSupervisor[index].msTillTimeout -= deltaMs; - } - } +static void ble_custom_cmd_refresh_supervisor_env(void) { + // do nothing if no supervisor was added + if (ble_custom_cmd_env.timeoutSupervisorCount > 0) { + uint32_t currentTicks = GET_CURRENT_TICKS(); + uint32_t passedTicks; + if (currentTicks >= ble_custom_cmd_env.lastSysTicks) { + passedTicks = (currentTicks - ble_custom_cmd_env.lastSysTicks); + } else { + passedTicks = + (hal_sys_timer_get_max() - ble_custom_cmd_env.lastSysTicks + 1) + + currentTicks; + } - ble_custom_cmd_env.lastSysTicks = GET_CURRENT_TICKS(); + uint32_t deltaMs = TICKS_TO_MS(passedTicks); + + BLE_CUSTOM_CMD_WAITING_RSP_SUPERVISOR_T *pRspSupervisor = + &(ble_custom_cmd_env.waitingRspTimeoutInstance[0]); + for (uint32_t index = 0; index < ble_custom_cmd_env.timeoutSupervisorCount; + index++) { + ASSERT(pRspSupervisor[index].msTillTimeout > deltaMs, + "the waiting command response supervisor timer is missing!!!, \ + %d ms passed but the ms to trigger is %d", + deltaMs, pRspSupervisor[index].msTillTimeout); + pRspSupervisor[index].msTillTimeout -= deltaMs; + } + } + + ble_custom_cmd_env.lastSysTicks = GET_CURRENT_TICKS(); } /** * @brief Remove the time-out supervision of waiting response * * @param entryIndex Entry index of the command table - * + * */ -static void BLE_remove_waiting_rsp_timeout_supervision(uint16_t entryIndex) -{ - ASSERT(ble_custom_cmd_env.timeoutSupervisorCount > 0, - "%s The BLE custom command time-out supervisor is already empty!!!", __FUNCTION__); +static void BLE_remove_waiting_rsp_timeout_supervision(uint16_t entryIndex) { + ASSERT(ble_custom_cmd_env.timeoutSupervisorCount > 0, + "%s The BLE custom command time-out supervisor is already empty!!!", + __FUNCTION__); - osMutexWait(ble_custom_cmd_env.mutex, osWaitForever); + osMutexWait(ble_custom_cmd_env.mutex, osWaitForever); - uint32_t index; - for (index = 0;index < ble_custom_cmd_env.timeoutSupervisorCount;index++) - { - if (ble_custom_cmd_env.waitingRspTimeoutInstance[index].entryIndex == entryIndex) - { - memcpy(&(ble_custom_cmd_env.waitingRspTimeoutInstance[index]), - &(ble_custom_cmd_env.waitingRspTimeoutInstance[index + 1]), - (ble_custom_cmd_env.timeoutSupervisorCount - index - 1)*sizeof(BLE_CUSTOM_CMD_WAITING_RSP_SUPERVISOR_T)); - break; - } - } + uint32_t index; + for (index = 0; index < ble_custom_cmd_env.timeoutSupervisorCount; index++) { + if (ble_custom_cmd_env.waitingRspTimeoutInstance[index].entryIndex == + entryIndex) { + memcpy(&(ble_custom_cmd_env.waitingRspTimeoutInstance[index]), + &(ble_custom_cmd_env.waitingRspTimeoutInstance[index + 1]), + (ble_custom_cmd_env.timeoutSupervisorCount - index - 1) * + sizeof(BLE_CUSTOM_CMD_WAITING_RSP_SUPERVISOR_T)); + break; + } + } - // cannot find it, directly return - if (index == ble_custom_cmd_env.timeoutSupervisorCount) - { - goto exit; - } - - ble_custom_cmd_env.timeoutSupervisorCount--; + // cannot find it, directly return + if (index == ble_custom_cmd_env.timeoutSupervisorCount) { + goto exit; + } - if (ble_custom_cmd_env.timeoutSupervisorCount > 0) - { - // refresh supervisor environment firstly - ble_custom_cmd_refresh_supervisor_env(); - - // start timer, the first entry is the most close one - osTimerStart(ble_custom_cmd_env.supervisor_timer_id, ble_custom_cmd_env.waitingRspTimeoutInstance[0].msTillTimeout); - } - else - { - // no supervisor, directly stop the timer - osTimerStop(ble_custom_cmd_env.supervisor_timer_id); - } + ble_custom_cmd_env.timeoutSupervisorCount--; + + if (ble_custom_cmd_env.timeoutSupervisorCount > 0) { + // refresh supervisor environment firstly + ble_custom_cmd_refresh_supervisor_env(); + + // start timer, the first entry is the most close one + osTimerStart(ble_custom_cmd_env.supervisor_timer_id, + ble_custom_cmd_env.waitingRspTimeoutInstance[0].msTillTimeout); + } else { + // no supervisor, directly stop the timer + osTimerStop(ble_custom_cmd_env.supervisor_timer_id); + } exit: - osMutexRelease(ble_custom_cmd_env.mutex); + osMutexRelease(ble_custom_cmd_env.mutex); } /** * @brief Add the time-out supervision of waiting response * * @param entryIndex Index of the command entry - * + * */ -static void BLE_add_waiting_rsp_timeout_supervision(uint16_t entryIndex) -{ - ASSERT(ble_custom_cmd_env.timeoutSupervisorCount < BLE_CUSTOM_CMD_WAITING_RSP_TIMEOUT_COUNT, - "%s The BLE custom command time-out supervisor is full!!!", __FUNCTION__); +static void BLE_add_waiting_rsp_timeout_supervision(uint16_t entryIndex) { + ASSERT(ble_custom_cmd_env.timeoutSupervisorCount < + BLE_CUSTOM_CMD_WAITING_RSP_TIMEOUT_COUNT, + "%s The BLE custom command time-out supervisor is full!!!", + __FUNCTION__); - osMutexWait(ble_custom_cmd_env.mutex, osWaitForever); + osMutexWait(ble_custom_cmd_env.mutex, osWaitForever); - // refresh supervisor environment firstly - ble_custom_cmd_refresh_supervisor_env(); + // refresh supervisor environment firstly + ble_custom_cmd_refresh_supervisor_env(); - BLE_CUSTOM_CMD_INSTANCE_T* pInstance = CUSTOM_COMMAND_PTR_FROM_ENTRY_INDEX(entryIndex); + BLE_CUSTOM_CMD_INSTANCE_T *pInstance = + CUSTOM_COMMAND_PTR_FROM_ENTRY_INDEX(entryIndex); - BLE_CUSTOM_CMD_WAITING_RSP_SUPERVISOR_T waitingRspTimeoutInstance[BLE_CUSTOM_CMD_WAITING_RSP_TIMEOUT_COUNT]; + BLE_CUSTOM_CMD_WAITING_RSP_SUPERVISOR_T + waitingRspTimeoutInstance[BLE_CUSTOM_CMD_WAITING_RSP_TIMEOUT_COUNT]; - uint32_t index = 0, insertedIndex = 0; - for (index = 0;index < ble_custom_cmd_env.timeoutSupervisorCount;index++) - { - uint32_t msTillTimeout = ble_custom_cmd_env.waitingRspTimeoutInstance[index].msTillTimeout; + uint32_t index = 0, insertedIndex = 0; + for (index = 0; index < ble_custom_cmd_env.timeoutSupervisorCount; index++) { + uint32_t msTillTimeout = + ble_custom_cmd_env.waitingRspTimeoutInstance[index].msTillTimeout; - // in the order of low to high - if ((ble_custom_cmd_env.waitingRspTimeoutInstance[index].entryIndex != entryIndex) && - (pInstance->timeoutWaitingRspInMs >= msTillTimeout)) - { - waitingRspTimeoutInstance[insertedIndex++] = ble_custom_cmd_env.waitingRspTimeoutInstance[index]; - } - else if (pInstance->timeoutWaitingRspInMs < msTillTimeout) - { - waitingRspTimeoutInstance[insertedIndex].entryIndex = entryIndex; - waitingRspTimeoutInstance[insertedIndex].msTillTimeout = pInstance->timeoutWaitingRspInMs; + // in the order of low to high + if ((ble_custom_cmd_env.waitingRspTimeoutInstance[index].entryIndex != + entryIndex) && + (pInstance->timeoutWaitingRspInMs >= msTillTimeout)) { + waitingRspTimeoutInstance[insertedIndex++] = + ble_custom_cmd_env.waitingRspTimeoutInstance[index]; + } else if (pInstance->timeoutWaitingRspInMs < msTillTimeout) { + waitingRspTimeoutInstance[insertedIndex].entryIndex = entryIndex; + waitingRspTimeoutInstance[insertedIndex].msTillTimeout = + pInstance->timeoutWaitingRspInMs; - insertedIndex++; - } - } + insertedIndex++; + } + } - // biggest one? then put it at the end of the list - if (ble_custom_cmd_env.timeoutSupervisorCount == index) - { - waitingRspTimeoutInstance[insertedIndex].entryIndex = entryIndex; - waitingRspTimeoutInstance[insertedIndex].msTillTimeout = pInstance->timeoutWaitingRspInMs; - - insertedIndex++; - } + // biggest one? then put it at the end of the list + if (ble_custom_cmd_env.timeoutSupervisorCount == index) { + waitingRspTimeoutInstance[insertedIndex].entryIndex = entryIndex; + waitingRspTimeoutInstance[insertedIndex].msTillTimeout = + pInstance->timeoutWaitingRspInMs; - // copy to the global variable - memcpy((uint8_t *)&(ble_custom_cmd_env.waitingRspTimeoutInstance), (uint8_t *)&waitingRspTimeoutInstance, - insertedIndex*sizeof(BLE_CUSTOM_CMD_WAITING_RSP_SUPERVISOR_T)); + insertedIndex++; + } - ble_custom_cmd_env.timeoutSupervisorCount = insertedIndex; + // copy to the global variable + memcpy((uint8_t *)&(ble_custom_cmd_env.waitingRspTimeoutInstance), + (uint8_t *)&waitingRspTimeoutInstance, + insertedIndex * sizeof(BLE_CUSTOM_CMD_WAITING_RSP_SUPERVISOR_T)); - // start timer, the first entry is the most close one - osTimerStart(ble_custom_cmd_env.supervisor_timer_id, ble_custom_cmd_env.waitingRspTimeoutInstance[0].msTillTimeout); + ble_custom_cmd_env.timeoutSupervisorCount = insertedIndex; - osMutexRelease(ble_custom_cmd_env.mutex); + // start timer, the first entry is the most close one + osTimerStart(ble_custom_cmd_env.supervisor_timer_id, + ble_custom_cmd_env.waitingRspTimeoutInstance[0].msTillTimeout); + + osMutexRelease(ble_custom_cmd_env.mutex); } /** @@ -326,9 +327,8 @@ static void BLE_add_waiting_rsp_timeout_supervision(uint16_t entryIndex) * * @return uint8_t* Pointer of the raw data buffer */ -uint8_t* BLE_custom_command_raw_data_buffer_pointer(void) -{ - return ble_custom_cmd_env.ptrRawXferDstBuf; +uint8_t *BLE_custom_command_raw_data_buffer_pointer(void) { + return ble_custom_cmd_env.ptrRawXferDstBuf; } /** @@ -336,9 +336,8 @@ uint8_t* BLE_custom_command_raw_data_buffer_pointer(void) * * @return uint16_t Pointer of the raw data buffer */ -uint16_t BLE_custom_command_received_raw_data_size(void) -{ - return ble_custom_cmd_env.lengthOfReceivedRawDataXfer; +uint16_t BLE_custom_command_received_raw_data_size(void) { + return ble_custom_cmd_env.lengthOfReceivedRawDataXfer; } /** @@ -346,149 +345,145 @@ uint16_t BLE_custom_command_received_raw_data_size(void) * * @param ptrData Pointer of the received data * @param dataLength Length of the received data - * + * * @return BLE_CUSTOM_CMD_RET_STATUS_E */ -BLE_CUSTOM_CMD_RET_STATUS_E BLE_custom_command_receive_data(uint8_t* ptrData, uint32_t dataLength) -{ - TRACE(1,"Receive length %d data: ", dataLength); - DUMP8("0x%02x ", ptrData, dataLength); - BLE_CUSTOM_CMD_PAYLOAD_T* pPayload = (BLE_CUSTOM_CMD_PAYLOAD_T *)ptrData; - - if ((OP_START_RAW_DATA_XFER == pPayload->cmdCode) || - (OP_STOP_RAW_DATA_XFER == pPayload->cmdCode) || - (!(ble_custom_cmd_env.isInRawDataXferStage))) - { - // check command code - if (pPayload->cmdCode >= OP_COMMAND_COUNT) - { - return INVALID_CMD_CODE; - } +BLE_CUSTOM_CMD_RET_STATUS_E +BLE_custom_command_receive_data(uint8_t *ptrData, uint32_t dataLength) { + TRACE(1, "Receive length %d data: ", dataLength); + DUMP8("0x%02x ", ptrData, dataLength); + BLE_CUSTOM_CMD_PAYLOAD_T *pPayload = (BLE_CUSTOM_CMD_PAYLOAD_T *)ptrData; - // check parameter length - if (pPayload->paramLen > sizeof(pPayload->param)) - { - return PARAMETER_LENGTH_OUT_OF_RANGE; - } + if ((OP_START_RAW_DATA_XFER == pPayload->cmdCode) || + (OP_STOP_RAW_DATA_XFER == pPayload->cmdCode) || + (!(ble_custom_cmd_env.isInRawDataXferStage))) { + // check command code + if (pPayload->cmdCode >= OP_COMMAND_COUNT) { + return INVALID_CMD_CODE; + } - BLE_CUSTOM_CMD_INSTANCE_T* pInstance = - BLE_custom_command_get_entry_pointer_from_cmd_code(pPayload->cmdCode); + // check parameter length + if (pPayload->paramLen > sizeof(pPayload->param)) { + return PARAMETER_LENGTH_OUT_OF_RANGE; + } - // execute the command handler - if(!pInstance) - pInstance->cmdHandler(pPayload->cmdCode, pPayload->param, pPayload->paramLen); - } - else - { - // the payload of the raw data xfer is 2 bytes cmd code + raw data - if (dataLength < sizeof(pPayload->cmdCode)) - { - return PARAMETER_LENGTH_TOO_SHORT; - } + BLE_CUSTOM_CMD_INSTANCE_T *pInstance = + BLE_custom_command_get_entry_pointer_from_cmd_code(pPayload->cmdCode); - dataLength -= sizeof(pPayload->cmdCode); - ptrData += sizeof(pPayload->cmdCode); + // execute the command handler + if (!pInstance) + pInstance->cmdHandler(pPayload->cmdCode, pPayload->param, + pPayload->paramLen); + } else { + // the payload of the raw data xfer is 2 bytes cmd code + raw data + if (dataLength < sizeof(pPayload->cmdCode)) { + return PARAMETER_LENGTH_TOO_SHORT; + } - if (NULL == ble_custom_cmd_env.rawDataHandler) - { - // default handler - - // save the received raw data into raw data buffer - uint32_t bytesToSave; - if ((dataLength + ble_custom_cmd_env.lengthOfReceivedRawDataXfer) > \ - ble_custom_cmd_env.lengthOfRawDataXferToReceive) - { - bytesToSave = ble_custom_cmd_env.lengthOfRawDataXferToReceive - \ - ble_custom_cmd_env.lengthOfReceivedRawDataXfer; - } - else - { - bytesToSave = dataLength; - } - memcpy((uint8_t *)&ble_custom_cmd_env.ptrRawXferDstBuf[ble_custom_cmd_env.lengthOfReceivedRawDataXfer], \ - ptrData, bytesToSave); + dataLength -= sizeof(pPayload->cmdCode); + ptrData += sizeof(pPayload->cmdCode); - - ble_custom_cmd_env.lengthOfReceivedRawDataXfer += bytesToSave; - } - else - { - // custom handler that is set by BLE_set_raw_data_xfer_received_callback - ble_custom_cmd_env.rawDataHandler(ptrData, dataLength); - } - } + if (NULL == ble_custom_cmd_env.rawDataHandler) { + // default handler - return NO_ERROR; + // save the received raw data into raw data buffer + uint32_t bytesToSave; + if ((dataLength + ble_custom_cmd_env.lengthOfReceivedRawDataXfer) > + ble_custom_cmd_env.lengthOfRawDataXferToReceive) { + bytesToSave = ble_custom_cmd_env.lengthOfRawDataXferToReceive - + ble_custom_cmd_env.lengthOfReceivedRawDataXfer; + } else { + bytesToSave = dataLength; + } + memcpy( + (uint8_t *)&ble_custom_cmd_env + .ptrRawXferDstBuf[ble_custom_cmd_env.lengthOfReceivedRawDataXfer], + ptrData, bytesToSave); + + ble_custom_cmd_env.lengthOfReceivedRawDataXfer += bytesToSave; + } else { + // custom handler that is set by BLE_set_raw_data_xfer_received_callback + ble_custom_cmd_env.rawDataHandler(ptrData, dataLength); + } + } + + return NO_ERROR; } -static void BLE_send_out_data(BLE_CUSTOM_CMD_TRANSMISSION_PATH_E path, BLE_CUSTOM_CMD_PAYLOAD_T* ptPayLoad) -{ - switch (path) - { - case TRANSMISSION_VIA_NOTIFICATION: - app_datapath_server_send_data_via_notification((uint8_t *)ptPayLoad, - (uint32_t)(&(((BLE_CUSTOM_CMD_PAYLOAD_T *)0)->param)) + ptPayLoad->paramLen); - break; - case TRANSMISSION_VIA_INDICATION: - app_datapath_server_send_data_via_indication((uint8_t *)ptPayLoad, - (uint32_t)(&(((BLE_CUSTOM_CMD_PAYLOAD_T *)0)->param)) + ptPayLoad->paramLen); - break; - case TRANSMISSION_VIA_WRITE_CMD: - app_datapath_server_send_data_via_write_command((uint8_t *)ptPayLoad, - (uint32_t)(&(((BLE_CUSTOM_CMD_PAYLOAD_T *)0)->param)) + ptPayLoad->paramLen); - break; - case TRANSMISSION_VIA_WRITE_REQ: - app_datapath_server_send_data_via_write_request((uint8_t *)ptPayLoad, - (uint32_t)(&(((BLE_CUSTOM_CMD_PAYLOAD_T *)0)->param)) + ptPayLoad->paramLen); - break; - default: - break; - } +static void BLE_send_out_data(BLE_CUSTOM_CMD_TRANSMISSION_PATH_E path, + BLE_CUSTOM_CMD_PAYLOAD_T *ptPayLoad) { + switch (path) { + case TRANSMISSION_VIA_NOTIFICATION: + app_datapath_server_send_data_via_notification( + (uint8_t *)ptPayLoad, + (uint32_t)(&(((BLE_CUSTOM_CMD_PAYLOAD_T *)0)->param)) + + ptPayLoad->paramLen); + break; + case TRANSMISSION_VIA_INDICATION: + app_datapath_server_send_data_via_indication( + (uint8_t *)ptPayLoad, + (uint32_t)(&(((BLE_CUSTOM_CMD_PAYLOAD_T *)0)->param)) + + ptPayLoad->paramLen); + break; + case TRANSMISSION_VIA_WRITE_CMD: + app_datapath_server_send_data_via_write_command( + (uint8_t *)ptPayLoad, + (uint32_t)(&(((BLE_CUSTOM_CMD_PAYLOAD_T *)0)->param)) + + ptPayLoad->paramLen); + break; + case TRANSMISSION_VIA_WRITE_REQ: + app_datapath_server_send_data_via_write_request( + (uint8_t *)ptPayLoad, + (uint32_t)(&(((BLE_CUSTOM_CMD_PAYLOAD_T *)0)->param)) + + ptPayLoad->paramLen); + break; + default: + break; + } } /** - * @brief Send response to the command request + * @brief Send response to the command request * * @param responsedCmdCode Command code of the responsed command request * @param returnStatus Handling result * @param rspData Pointer of the response data * @param rspDataLen Length of the response data * @param path Path of the data transmission - * + * * @return BLE_CUSTOM_CMD_RET_STATUS_E */ -BLE_CUSTOM_CMD_RET_STATUS_E BLE_send_response_to_command - (uint32_t responsedCmdCode, BLE_CUSTOM_CMD_RET_STATUS_E returnStatus, - uint8_t* rspData, uint32_t rspDataLen, BLE_CUSTOM_CMD_TRANSMISSION_PATH_E path) -{ - // check responsedCmdCode's validity - if (responsedCmdCode >= OP_COMMAND_COUNT) - { - return INVALID_CMD_CODE; - } +BLE_CUSTOM_CMD_RET_STATUS_E +BLE_send_response_to_command(uint32_t responsedCmdCode, + BLE_CUSTOM_CMD_RET_STATUS_E returnStatus, + uint8_t *rspData, uint32_t rspDataLen, + BLE_CUSTOM_CMD_TRANSMISSION_PATH_E path) { + // check responsedCmdCode's validity + if (responsedCmdCode >= OP_COMMAND_COUNT) { + return INVALID_CMD_CODE; + } - BLE_CUSTOM_CMD_PAYLOAD_T payload; + BLE_CUSTOM_CMD_PAYLOAD_T payload; - BLE_CUSTOM_CMD_RSP_T* pResponse = (BLE_CUSTOM_CMD_RSP_T *)&(payload.param); + BLE_CUSTOM_CMD_RSP_T *pResponse = (BLE_CUSTOM_CMD_RSP_T *)&(payload.param); - // check parameter length - if (rspDataLen > sizeof(pResponse->rspData)) - { - return PARAMETER_LENGTH_OUT_OF_RANGE; - } + // check parameter length + if (rspDataLen > sizeof(pResponse->rspData)) { + return PARAMETER_LENGTH_OUT_OF_RANGE; + } - pResponse->cmdCodeToRsp = responsedCmdCode; - pResponse->cmdRetStatus = returnStatus; - pResponse->rspDataLen = rspDataLen; - memcpy(pResponse->rspData, rspData, rspDataLen); + pResponse->cmdCodeToRsp = responsedCmdCode; + pResponse->cmdRetStatus = returnStatus; + pResponse->rspDataLen = rspDataLen; + memcpy(pResponse->rspData, rspData, rspDataLen); - payload.paramLen = 3*sizeof(uint16_t) + rspDataLen; + payload.paramLen = 3 * sizeof(uint16_t) + rspDataLen; - payload.cmdCode = OP_RESPONSE_TO_CMD; + payload.cmdCode = OP_RESPONSE_TO_CMD; - BLE_send_out_data(path, &payload); + BLE_send_out_data(path, &payload); - return NO_ERROR; + return NO_ERROR; } /** @@ -498,86 +493,82 @@ BLE_CUSTOM_CMD_RET_STATUS_E BLE_send_response_to_command * @param ptrParam Pointer of the output parameter * @param paramLen Length of the output parameter * @param path Path of the data transmission - * + * * @return BLE_CUSTOM_CMD_RET_STATUS_E */ -BLE_CUSTOM_CMD_RET_STATUS_E BLE_send_custom_command(uint32_t cmdCode, - uint8_t* ptrParam, uint32_t paramLen, BLE_CUSTOM_CMD_TRANSMISSION_PATH_E path) -{ - // check cmdCode's validity - if (cmdCode >= OP_COMMAND_COUNT) - { - return INVALID_CMD_CODE; - } +BLE_CUSTOM_CMD_RET_STATUS_E +BLE_send_custom_command(uint32_t cmdCode, uint8_t *ptrParam, uint32_t paramLen, + BLE_CUSTOM_CMD_TRANSMISSION_PATH_E path) { + // check cmdCode's validity + if (cmdCode >= OP_COMMAND_COUNT) { + return INVALID_CMD_CODE; + } - BLE_CUSTOM_CMD_PAYLOAD_T payload; + BLE_CUSTOM_CMD_PAYLOAD_T payload; - // check parameter length - if (paramLen > sizeof(payload.param)) - { - return PARAMETER_LENGTH_OUT_OF_RANGE; - } - - uint16_t entryIndex = BLE_custom_command_get_entry_index_from_cmd_code(cmdCode); - BLE_CUSTOM_CMD_INSTANCE_T* pInstance = CUSTOM_COMMAND_PTR_FROM_ENTRY_INDEX(entryIndex); + // check parameter length + if (paramLen > sizeof(payload.param)) { + return PARAMETER_LENGTH_OUT_OF_RANGE; + } - // wrap the command payload - payload.cmdCode = cmdCode; - payload.paramLen = paramLen; - memcpy(payload.param, ptrParam, paramLen); + uint16_t entryIndex = + BLE_custom_command_get_entry_index_from_cmd_code(cmdCode); + BLE_CUSTOM_CMD_INSTANCE_T *pInstance = + CUSTOM_COMMAND_PTR_FROM_ENTRY_INDEX(entryIndex); - // send out the data - BLE_send_out_data(path, &payload); + // wrap the command payload + payload.cmdCode = cmdCode; + payload.paramLen = paramLen; + memcpy(payload.param, ptrParam, paramLen); - // insert into time-out supervison - if (pInstance->isNeedResponse) - { - BLE_add_waiting_rsp_timeout_supervision(cmdCode); - } + // send out the data + BLE_send_out_data(path, &payload); - return NO_ERROR; + // insert into time-out supervison + if (pInstance->isNeedResponse) { + BLE_add_waiting_rsp_timeout_supervision(cmdCode); + } + + return NO_ERROR; } -BLE_CUSTOM_CMD_INSTANCE_T* BLE_custom_command_get_entry_pointer_from_cmd_code(uint16_t cmdCode) -{ - for (uint32_t index = 0; - index < ((uint32_t)__custom_handler_table_end-(uint32_t)__custom_handler_table_start)/sizeof(BLE_CUSTOM_CMD_INSTANCE_T);index++) - { - if (CUSTOM_COMMAND_PTR_FROM_ENTRY_INDEX(index)->cmdCode == cmdCode) - { - return CUSTOM_COMMAND_PTR_FROM_ENTRY_INDEX(index); - } - } +BLE_CUSTOM_CMD_INSTANCE_T * +BLE_custom_command_get_entry_pointer_from_cmd_code(uint16_t cmdCode) { + for (uint32_t index = 0; index < ((uint32_t)__custom_handler_table_end - + (uint32_t)__custom_handler_table_start) / + sizeof(BLE_CUSTOM_CMD_INSTANCE_T); + index++) { + if (CUSTOM_COMMAND_PTR_FROM_ENTRY_INDEX(index)->cmdCode == cmdCode) { + return CUSTOM_COMMAND_PTR_FROM_ENTRY_INDEX(index); + } + } - return NULL; + return NULL; } -uint16_t BLE_custom_command_get_entry_index_from_cmd_code(uint16_t cmdCode) -{ - for (uint32_t index = 0; - index < (__custom_handler_table_end-__custom_handler_table_start)/sizeof(BLE_CUSTOM_CMD_INSTANCE_T);index++) - { - if (CUSTOM_COMMAND_PTR_FROM_ENTRY_INDEX(index)->cmdCode == cmdCode) - { - return index; - } - } +uint16_t BLE_custom_command_get_entry_index_from_cmd_code(uint16_t cmdCode) { + for (uint32_t index = 0; + index < (__custom_handler_table_end - __custom_handler_table_start) / + sizeof(BLE_CUSTOM_CMD_INSTANCE_T); + index++) { + if (CUSTOM_COMMAND_PTR_FROM_ENTRY_INDEX(index)->cmdCode == cmdCode) { + return index; + } + } - return INVALID_CUSTOM_ENTRY_INDEX; + return INVALID_CUSTOM_ENTRY_INDEX; } /** * @brief Initialize the BLE custom command framework * */ -void BLE_custom_command_init(void) -{ - memset((uint8_t *)&ble_custom_cmd_env, 0, sizeof(ble_custom_cmd_env)); +void BLE_custom_command_init(void) { + memset((uint8_t *)&ble_custom_cmd_env, 0, sizeof(ble_custom_cmd_env)); - ble_custom_cmd_env.supervisor_timer_id = - osTimerCreate(osTimer(APP_CUSTOM_CMD_RSP_SUPERVISION_TIMER), osTimerOnce, NULL); + ble_custom_cmd_env.supervisor_timer_id = osTimerCreate( + osTimer(APP_CUSTOM_CMD_RSP_SUPERVISION_TIMER), osTimerOnce, NULL); - ble_custom_cmd_env.mutex = osMutexCreate((osMutex(app_ble_cmd_mutex))); + ble_custom_cmd_env.mutex = osMutexCreate((osMutex(app_ble_cmd_mutex))); } #endif - diff --git a/services/ble_app/app_datapath/app_ble_custom_cmd.c b/services/ble_app/app_datapath/app_ble_custom_cmd.c index 507c562..44e153a 100644 --- a/services/ble_app/app_datapath/app_ble_custom_cmd.c +++ b/services/ble_app/app_datapath/app_ble_custom_cmd.c @@ -13,100 +13,107 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "string.h" -#include "cmsis_os.h" -#include "hal_trace.h" -#include "hal_timer.h" -#include "stdbool.h" #include "apps.h" -#include "rwapp_config.h" -#include "hal_cmu.h" +#include "cmsis_os.h" #include "hal_bootmode.h" +#include "hal_cmu.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "rwapp_config.h" +#include "stdbool.h" +#include "string.h" #include "app_ble_cmd_handler.h" #include "app_ble_custom_cmd.h" #include "retention_ram.h" - #if (BTIF_BLE_APP_DATAPATH_SERVER) -extern void app_datapath_server_send_data_via_notification(uint8_t* ptrData, uint32_t length); +extern void app_datapath_server_send_data_via_notification(uint8_t *ptrData, + uint32_t length); +void BLE_dummy_handler(uint32_t funcCode, uint8_t *ptrParam, + uint32_t paramLen) {} -void BLE_dummy_handler(uint32_t funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - +void BLE_test_no_response_print_handler(uint32_t funcCode, uint8_t *ptrParam, + uint32_t paramLen) { + TRACE(1, "%s Get OP_TEST_NO_RESPONSE_PRINT command!!!", __FUNCTION__); } -void BLE_test_no_response_print_handler(uint32_t funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - TRACE(1,"%s Get OP_TEST_NO_RESPONSE_PRINT command!!!", __FUNCTION__); +void BLE_test_with_response_print_handler(uint32_t funcCode, uint8_t *ptrParam, + uint32_t paramLen) { + TRACE(1, "%s Get OP_TEST_WITH_RESPONSE_PRINT command!!!", __FUNCTION__); + + uint32_t currentTicks = GET_CURRENT_TICKS(); + BLE_send_response_to_command(funcCode, NO_ERROR, (uint8_t *)¤tTicks, + sizeof(currentTicks), + TRANSMISSION_VIA_NOTIFICATION); } -void BLE_test_with_response_print_handler(uint32_t funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - TRACE(1,"%s Get OP_TEST_WITH_RESPONSE_PRINT command!!!", __FUNCTION__); - - uint32_t currentTicks = GET_CURRENT_TICKS(); - BLE_send_response_to_command(funcCode, NO_ERROR, (uint8_t *)¤tTicks, sizeof(currentTicks), TRANSMISSION_VIA_NOTIFICATION); +void BLE_test_with_response_print_rsp_handler( + BLE_CUSTOM_CMD_RET_STATUS_E retStatus, uint8_t *ptrParam, + uint32_t paramLen) { + if (NO_ERROR == retStatus) { + TRACE(1, "%s Get the response of OP_TEST_WITH_RESPONSE_PRINT command!!!", + __FUNCTION__); + } else if (TIMEOUT_WAITING_RESPONSE == retStatus) { + TRACE(1, + "%s Timeout happens, doesn't get the response of " + "OP_TEST_WITH_RESPONSE_PRINT command!!!", + __FUNCTION__); + } } -void BLE_test_with_response_print_rsp_handler(BLE_CUSTOM_CMD_RET_STATUS_E retStatus, uint8_t* ptrParam, uint32_t paramLen) -{ - if (NO_ERROR == retStatus) - { - TRACE(1,"%s Get the response of OP_TEST_WITH_RESPONSE_PRINT command!!!", __FUNCTION__); - } - else if (TIMEOUT_WAITING_RESPONSE == retStatus) - { - TRACE(1,"%s Timeout happens, doesn't get the response of OP_TEST_WITH_RESPONSE_PRINT command!!!", __FUNCTION__); - } +static void app_otaMode_enter(void) { + TRACE(1, "%s", __func__); + hal_norflash_disable_protection(HAL_NORFLASH_ID_0); + hal_sw_bootmode_set(HAL_SW_BOOTMODE_ENTER_HIDE_BOOT); + /*hal_cmu_reset_set(HAL_CMU_MOD_P_GLOBAL);*/ } -static void app_otaMode_enter(void) -{ - TRACE(1,"%s",__func__); - hal_norflash_disable_protection(HAL_NORFLASH_ID_0); - hal_sw_bootmode_set(HAL_SW_BOOTMODE_ENTER_HIDE_BOOT); - /*hal_cmu_reset_set(HAL_CMU_MOD_P_GLOBAL);*/ -} - -void BLE_enter_OTA_mode_handler(uint32_t funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - fillBleBdAddrForOta(ptrParam); - app_otaMode_enter(); +void BLE_enter_OTA_mode_handler(uint32_t funcCode, uint8_t *ptrParam, + uint32_t paramLen) { + fillBleBdAddrForOta(ptrParam); + app_otaMode_enter(); } #ifdef __SW_IIR_EQ_PROCESS__ -int audio_config_eq_iir_via_config_structure(uint8_t *buf, uint32_t len); -void BLE_iir_eq_handler(uint32_t funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ +int audio_config_eq_iir_via_config_structure(uint8_t *buf, uint32_t len); +void BLE_iir_eq_handler(uint32_t funcCode, uint8_t *ptrParam, + uint32_t paramLen) { - audio_config_eq_iir_via_config_structure(BLE_custom_command_raw_data_buffer_pointer(), BLE_custom_command_received_raw_data_size()); + audio_config_eq_iir_via_config_structure( + BLE_custom_command_raw_data_buffer_pointer(), + BLE_custom_command_received_raw_data_size()); } #endif extern uint8_t bt_addr[6]; -void BLE_get_bt_address_handler(uint32_t funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - app_datapath_server_send_data_via_notification((uint8_t *)&bt_addr, sizeof(bt_addr)); +void BLE_get_bt_address_handler(uint32_t funcCode, uint8_t *ptrParam, + uint32_t paramLen) { + app_datapath_server_send_data_via_notification((uint8_t *)&bt_addr, + sizeof(bt_addr)); } -CUSTOM_COMMAND_TO_ADD(OP_RESPONSE_TO_CMD, BLE_get_response_handler, false, 0, NULL ); -CUSTOM_COMMAND_TO_ADD(OP_START_RAW_DATA_XFER, BLE_raw_data_xfer_control_handler, true, 2000, BLE_start_raw_data_xfer_control_rsp_handler ); -CUSTOM_COMMAND_TO_ADD(OP_STOP_RAW_DATA_XFER, BLE_raw_data_xfer_control_handler, true, 2000, BLE_stop_raw_data_xfer_control_rsp_handler ); -CUSTOM_COMMAND_TO_ADD(OP_TEST_NO_RESPONSE_PRINT, BLE_test_no_response_print_handler, false, 0, NULL ); -CUSTOM_COMMAND_TO_ADD(OP_TEST_WITH_RESPONSE_PRINT, BLE_test_with_response_print_handler, true, 5000, BLE_test_with_response_print_rsp_handler ); -CUSTOM_COMMAND_TO_ADD(OP_ENTER_OTA_MODE, BLE_enter_OTA_mode_handler, false, 0, NULL ); +CUSTOM_COMMAND_TO_ADD(OP_RESPONSE_TO_CMD, BLE_get_response_handler, false, 0, + NULL); +CUSTOM_COMMAND_TO_ADD(OP_START_RAW_DATA_XFER, BLE_raw_data_xfer_control_handler, + true, 2000, BLE_start_raw_data_xfer_control_rsp_handler); +CUSTOM_COMMAND_TO_ADD(OP_STOP_RAW_DATA_XFER, BLE_raw_data_xfer_control_handler, + true, 2000, BLE_stop_raw_data_xfer_control_rsp_handler); +CUSTOM_COMMAND_TO_ADD(OP_TEST_NO_RESPONSE_PRINT, + BLE_test_no_response_print_handler, false, 0, NULL); +CUSTOM_COMMAND_TO_ADD(OP_TEST_WITH_RESPONSE_PRINT, + BLE_test_with_response_print_handler, true, 5000, + BLE_test_with_response_print_rsp_handler); +CUSTOM_COMMAND_TO_ADD(OP_ENTER_OTA_MODE, BLE_enter_OTA_mode_handler, false, 0, + NULL); #ifdef __SW_IIR_EQ_PROCESS__ -CUSTOM_COMMAND_TO_ADD(OP_SW_IIR_EQ, BLE_iir_eq_handler, false, 0, NULL ); +CUSTOM_COMMAND_TO_ADD(OP_SW_IIR_EQ, BLE_iir_eq_handler, false, 0, NULL); #endif -CUSTOM_COMMAND_TO_ADD(OP_GET_BT_ADDRESS, BLE_get_bt_address_handler, false, 0, NULL ); - - - - +CUSTOM_COMMAND_TO_ADD(OP_GET_BT_ADDRESS, BLE_get_bt_address_handler, false, 0, + NULL); #if 0 /** \brief Instances list of BLE custom command handler, should be in the order of the @@ -136,4 +143,3 @@ BLE_CUSTOM_CMD_INSTANCE_T customCommandArray[] = }; #endif #endif - diff --git a/services/ble_app/app_datapath/app_datapath_server.c b/services/ble_app/app_datapath/app_datapath_server.c index f4dab11..0b8870b 100644 --- a/services/ble_app/app_datapath/app_datapath_server.c +++ b/services/ble_app/app_datapath/app_datapath_server.c @@ -20,8 +20,8 @@ **************************************************************************************** */ -#include "rwip_config.h" // SW configuration #include "app_ble_cmd_handler.h" +#include "rwip_config.h" // SW configuration #if (BLE_APP_DATAPATH_SERVER) @@ -30,15 +30,15 @@ **************************************************************************************** */ -#include "app_datapath_server.h" // Data Path Application Definitions -#include "app.h" // Application Definitions -#include "app_task.h" // application task definitions -#include "datapathps_task.h" +#include "app.h" // Application Definitions +#include "app_datapath_server.h" // Data Path Application Definitions +#include "app_task.h" // application task definitions +#include "arch.h" // Platform Definitions #include "co_bt.h" +#include "datapathps_task.h" +#include "prf.h" #include "prf_types.h" #include "prf_utils.h" -#include "arch.h" // Platform Definitions -#include "prf.h" #include "string.h" #ifdef IBRT #include "app_ibrt_ui.h" @@ -50,11 +50,8 @@ */ /// health thermometer application environment structure -struct app_datapath_server_env_tag app_datapath_server_env = -{ - BLE_INVALID_CONNECTION_INDEX, - false -}; +struct app_datapath_server_env_tag app_datapath_server_env = { + BLE_INVALID_CONNECTION_INDEX, false}; static app_datapath_server_tx_done_t tx_done_callback = NULL; @@ -62,125 +59,109 @@ static app_datapath_server_tx_done_t tx_done_callback = NULL; * GLOBAL FUNCTION DEFINITIONS **************************************************************************************** */ -void app_datapath_server_mtu_exchanged_handler(uint8_t conidx, uint16_t mtu) -{ +void app_datapath_server_mtu_exchanged_handler(uint8_t conidx, uint16_t mtu) {} -} - -void app_datapath_server_connected_evt_handler(uint8_t conidx) -{ - TRACE(0,"app datapath server connected."); - app_datapath_server_env.connectionIndex = conidx; +void app_datapath_server_connected_evt_handler(uint8_t conidx) { + TRACE(0, "app datapath server connected."); + app_datapath_server_env.connectionIndex = conidx; #ifdef IBRT - if (app_ibrt_ui_get_snoop_via_ble_enable()) - { - app_ibrt_ui_set_master_notify_flag(TRUE); - } + if (app_ibrt_ui_get_snoop_via_ble_enable()) { + app_ibrt_ui_set_master_notify_flag(TRUE); + } #endif } -void app_datapath_server_disconnected_evt_handler(uint8_t conidx) -{ - if (conidx == app_datapath_server_env.connectionIndex) - { - TRACE(0,"app datapath server dis-connected."); - app_datapath_server_env.connectionIndex = BLE_INVALID_CONNECTION_INDEX; - app_datapath_server_env.isNotificationEnabled = false; - - tx_done_callback = NULL; - } -} - -void app_datapath_server_init(void) -{ - // Reset the environment - app_datapath_server_env.connectionIndex = BLE_INVALID_CONNECTION_INDEX; +void app_datapath_server_disconnected_evt_handler(uint8_t conidx) { + if (conidx == app_datapath_server_env.connectionIndex) { + TRACE(0, "app datapath server dis-connected."); + app_datapath_server_env.connectionIndex = BLE_INVALID_CONNECTION_INDEX; app_datapath_server_env.isNotificationEnabled = false; + + tx_done_callback = NULL; + } } -void app_datapath_add_datapathps(void) -{ - BLE_APP_DBG("app_datapath_add_datapathps"); - struct gapm_profile_task_add_cmd *req = KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, - TASK_GAPM, TASK_APP, - gapm_profile_task_add_cmd, 0); - - // Fill message - req->operation = GAPM_PROFILE_TASK_ADD; - req->sec_lvl = PERM(SVC_AUTH, ENABLE); - req->prf_task_id = TASK_ID_DATAPATHPS; - req->app_task = TASK_APP; - req->start_hdl = 0; - - // Send the message - ke_msg_send(req); +void app_datapath_server_init(void) { + // Reset the environment + app_datapath_server_env.connectionIndex = BLE_INVALID_CONNECTION_INDEX; + app_datapath_server_env.isNotificationEnabled = false; } -void app_datapath_server_send_data_via_notification(uint8_t* ptrData, uint32_t length) -{ - struct ble_datapath_send_data_req_t * req = KE_MSG_ALLOC_DYN(DATAPATHPS_SEND_DATA_VIA_NOTIFICATION, - prf_get_task_from_id(TASK_ID_DATAPATHPS), - TASK_APP, - ble_datapath_send_data_req_t, - length); - req->connecionIndex = app_datapath_server_env.connectionIndex; - req->length = length; - memcpy(req->value, ptrData, length); +void app_datapath_add_datapathps(void) { + BLE_APP_DBG("app_datapath_add_datapathps"); + struct gapm_profile_task_add_cmd *req = + KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, TASK_GAPM, TASK_APP, + gapm_profile_task_add_cmd, 0); - ke_msg_send(req); + // Fill message + req->operation = GAPM_PROFILE_TASK_ADD; + req->sec_lvl = PERM(SVC_AUTH, ENABLE); + req->prf_task_id = TASK_ID_DATAPATHPS; + req->app_task = TASK_APP; + req->start_hdl = 0; + + // Send the message + ke_msg_send(req); } -void app_datapath_server_send_data_via_indication(uint8_t* ptrData, uint32_t length) -{ - struct ble_datapath_send_data_req_t * req = KE_MSG_ALLOC_DYN(DATAPATHPS_SEND_DATA_VIA_INDICATION, - prf_get_task_from_id(TASK_ID_DATAPATHPS), - TASK_APP, - ble_datapath_send_data_req_t, - length); - req->connecionIndex = app_datapath_server_env.connectionIndex; - req->length = length; - memcpy(req->value, ptrData, length); +void app_datapath_server_send_data_via_notification(uint8_t *ptrData, + uint32_t length) { + struct ble_datapath_send_data_req_t *req = + KE_MSG_ALLOC_DYN(DATAPATHPS_SEND_DATA_VIA_NOTIFICATION, + prf_get_task_from_id(TASK_ID_DATAPATHPS), TASK_APP, + ble_datapath_send_data_req_t, length); + req->connecionIndex = app_datapath_server_env.connectionIndex; + req->length = length; + memcpy(req->value, ptrData, length); - ke_msg_send(req); + ke_msg_send(req); } -void app_datapath_server_send_data_via_write_command(uint8_t* ptrData, uint32_t length) -{ - struct ble_datapath_send_data_req_t * req = KE_MSG_ALLOC_DYN(DATAPATHPS_SEND_DATA_VIA_WRITE_COMMAND, - prf_get_task_from_id(TASK_ID_DATAPATHPS), - TASK_APP, - ble_datapath_send_data_req_t, - length); - req->connecionIndex = app_datapath_server_env.connectionIndex; - req->length = length; - memcpy(req->value, ptrData, length); - ke_msg_send(req); +void app_datapath_server_send_data_via_indication(uint8_t *ptrData, + uint32_t length) { + struct ble_datapath_send_data_req_t *req = + KE_MSG_ALLOC_DYN(DATAPATHPS_SEND_DATA_VIA_INDICATION, + prf_get_task_from_id(TASK_ID_DATAPATHPS), TASK_APP, + ble_datapath_send_data_req_t, length); + req->connecionIndex = app_datapath_server_env.connectionIndex; + req->length = length; + memcpy(req->value, ptrData, length); + + ke_msg_send(req); } -void app_datapath_server_send_data_via_write_request(uint8_t* ptrData, uint32_t length) -{ - struct ble_datapath_send_data_req_t * req = KE_MSG_ALLOC_DYN(DATAPATHPS_SEND_DATA_VIA_WRITE_REQUEST, - prf_get_task_from_id(TASK_ID_DATAPATHPS), - TASK_APP, - ble_datapath_send_data_req_t, - length); - req->connecionIndex = app_datapath_server_env.connectionIndex; - req->length = length; - memcpy(req->value, ptrData, length); - ke_msg_send(req); +void app_datapath_server_send_data_via_write_command(uint8_t *ptrData, + uint32_t length) { + struct ble_datapath_send_data_req_t *req = + KE_MSG_ALLOC_DYN(DATAPATHPS_SEND_DATA_VIA_WRITE_COMMAND, + prf_get_task_from_id(TASK_ID_DATAPATHPS), TASK_APP, + ble_datapath_send_data_req_t, length); + req->connecionIndex = app_datapath_server_env.connectionIndex; + req->length = length; + memcpy(req->value, ptrData, length); + ke_msg_send(req); } -void app_datapath_server_control_notification(uint8_t conidx,bool isEnable) -{ - struct ble_datapath_control_notification_t * req = KE_MSG_ALLOC(DATAPATHPS_CONTROL_NOTIFICATION, - prf_get_task_from_id(TASK_ID_DATAPATHPS), - TASK_APP, - ble_datapath_control_notification_t); - req->isEnable = isEnable; - req->connecionIndex = conidx; - ke_msg_send(req); +void app_datapath_server_send_data_via_write_request(uint8_t *ptrData, + uint32_t length) { + struct ble_datapath_send_data_req_t *req = + KE_MSG_ALLOC_DYN(DATAPATHPS_SEND_DATA_VIA_WRITE_REQUEST, + prf_get_task_from_id(TASK_ID_DATAPATHPS), TASK_APP, + ble_datapath_send_data_req_t, length); + req->connecionIndex = app_datapath_server_env.connectionIndex; + req->length = length; + memcpy(req->value, ptrData, length); + ke_msg_send(req); } +void app_datapath_server_control_notification(uint8_t conidx, bool isEnable) { + struct ble_datapath_control_notification_t *req = KE_MSG_ALLOC( + DATAPATHPS_CONTROL_NOTIFICATION, prf_get_task_from_id(TASK_ID_DATAPATHPS), + TASK_APP, ble_datapath_control_notification_t); + req->isEnable = isEnable; + req->connecionIndex = conidx; + ke_msg_send(req); +} /** **************************************************************************************** @@ -195,77 +176,68 @@ void app_datapath_server_control_notification(uint8_t conidx,bool isEnable) **************************************************************************************** */ static int app_datapath_server_msg_handler(ke_msg_id_t const msgid, - void const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Do nothing + void const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Do nothing - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } -static int app_datapath_server_tx_ccc_changed_handler(ke_msg_id_t const msgid, - struct ble_datapath_tx_notif_config_t *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - app_datapath_server_env.isNotificationEnabled = param->isNotificationEnabled; +static int app_datapath_server_tx_ccc_changed_handler( + ke_msg_id_t const msgid, struct ble_datapath_tx_notif_config_t *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + app_datapath_server_env.isNotificationEnabled = param->isNotificationEnabled; - if (app_datapath_server_env.isNotificationEnabled) - { - // the app datapath server is connected when receiving the first enable CCC request - if (BLE_INVALID_CONNECTION_INDEX == app_datapath_server_env.connectionIndex) - { - uint8_t conidx = KE_IDX_GET(src_id); - app_datapath_server_connected_evt_handler(conidx); - } + if (app_datapath_server_env.isNotificationEnabled) { + // the app datapath server is connected when receiving the first enable CCC + // request + if (BLE_INVALID_CONNECTION_INDEX == + app_datapath_server_env.connectionIndex) { + uint8_t conidx = KE_IDX_GET(src_id); + app_datapath_server_connected_evt_handler(conidx); } + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } -static int app_datapath_server_tx_data_sent_handler(ke_msg_id_t const msgid, - struct ble_datapath_tx_sent_ind_t *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if (NULL != tx_done_callback) - { - tx_done_callback(); - } +static int app_datapath_server_tx_data_sent_handler( + ke_msg_id_t const msgid, struct ble_datapath_tx_sent_ind_t *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + if (NULL != tx_done_callback) { + tx_done_callback(); + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } extern void appm_restart_advertising(void); -static int app_datapath_server_rx_data_received_handler(ke_msg_id_t const msgid, - struct ble_datapath_rx_data_ind_t *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - - // loop back the received data - // app_datapath_server_send_data(param->data, param->length); +static int app_datapath_server_rx_data_received_handler( + ke_msg_id_t const msgid, struct ble_datapath_rx_data_ind_t *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + + // loop back the received data + // app_datapath_server_send_data(param->data, param->length); + + TRACE(2, "%s length %d", __func__, param->length); + // DUMP8("%02x ", (param->data+i), len); - TRACE(2,"%s length %d", __func__, param->length); - //DUMP8("%02x ", (param->data+i), len); - #ifndef __INTERCONNECTION__ - BLE_custom_command_receive_data(param->data, param->length); + BLE_custom_command_receive_data(param->data, param->length); #endif - + #ifdef IBRT - if (app_ibrt_ui_get_snoop_via_ble_enable()) - { - app_ibrt_ui_snoop_info_handler(param->data, param->length); - } + if (app_ibrt_ui_get_snoop_via_ble_enable()) { + app_ibrt_ui_snoop_info_handler(param->data, param->length); + } #endif - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } -void app_datapath_server_register_tx_done(app_datapath_server_tx_done_t callback) -{ - tx_done_callback = callback; +void app_datapath_server_register_tx_done( + app_datapath_server_tx_done_t callback) { + tx_done_callback = callback; } /* @@ -274,20 +246,26 @@ void app_datapath_server_register_tx_done(app_datapath_server_tx_done_t callback */ /// Default State handlers definition -const struct ke_msg_handler app_datapath_server_msg_handler_list[] = -{ - // Note: first message is latest message checked by kernel so default is put on top. - {KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_datapath_server_msg_handler}, +const struct ke_msg_handler app_datapath_server_msg_handler_list[] = { + // Note: first message is latest message checked by kernel so default is put + // on top. + {KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_datapath_server_msg_handler}, - {DATAPATHPS_TX_CCC_CHANGED, (ke_msg_func_t)app_datapath_server_tx_ccc_changed_handler}, - {DATAPATHPS_TX_DATA_SENT, (ke_msg_func_t)app_datapath_server_tx_data_sent_handler}, - {DATAPATHPS_RX_DATA_RECEIVED, (ke_msg_func_t)app_datapath_server_rx_data_received_handler}, - {DATAPATHPS_NOTIFICATION_RECEIVED, (ke_msg_func_t)app_datapath_server_rx_data_received_handler}, + {DATAPATHPS_TX_CCC_CHANGED, + (ke_msg_func_t)app_datapath_server_tx_ccc_changed_handler}, + {DATAPATHPS_TX_DATA_SENT, + (ke_msg_func_t)app_datapath_server_tx_data_sent_handler}, + {DATAPATHPS_RX_DATA_RECEIVED, + (ke_msg_func_t)app_datapath_server_rx_data_received_handler}, + {DATAPATHPS_NOTIFICATION_RECEIVED, + (ke_msg_func_t)app_datapath_server_rx_data_received_handler}, }; -const struct ke_state_handler app_datapath_server_table_handler = - {&app_datapath_server_msg_handler_list[0], (sizeof(app_datapath_server_msg_handler_list)/sizeof(struct ke_msg_handler))}; +const struct ke_state_handler app_datapath_server_table_handler = { + &app_datapath_server_msg_handler_list[0], + (sizeof(app_datapath_server_msg_handler_list) / + sizeof(struct ke_msg_handler))}; -#endif //BLE_APP_DATAPATH_SERVER +#endif // BLE_APP_DATAPATH_SERVER /// @} APP diff --git a/services/ble_app/app_dis/app_dis.c b/services/ble_app/app_dis/app_dis.c index 21b3a9e..70d7d0f 100644 --- a/services/ble_app/app_dis/app_dis.c +++ b/services/ble_app/app_dis/app_dis.c @@ -20,7 +20,7 @@ **************************************************************************************** */ -#include "rwip_config.h" // SW configuration +#include "rwip_config.h" // SW configuration #if (BLE_APP_DIS) @@ -29,11 +29,11 @@ **************************************************************************************** */ -#include "app.h" // Application Manager Definitions -#include "app_dis.h" // Device Information Service Application Definitions -#include "diss_task.h" // Device Information Profile Functions -#include "prf_types.h" // Profile Common Types Definitions -#include "gapm_task.h" // GAP Manager Task API +#include "app.h" // Application Manager Definitions +#include "app_dis.h" // Device Information Service Application Definitions +#include "diss_task.h" // Device Information Profile Functions +#include "gapm_task.h" // GAP Manager Task API +#include "prf_types.h" // Profile Common Types Definitions #include /* @@ -42,104 +42,90 @@ */ static int diss_value_req_ind_handler(ke_msg_id_t const msgid, - struct diss_value_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Initialize length - uint8_t len = 0; - // Pointer to the data - uint8_t *data = NULL; + struct diss_value_req_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Initialize length + uint8_t len = 0; + // Pointer to the data + uint8_t *data = NULL; - // Check requested value - switch (param->value) - { - case DIS_MANUFACTURER_NAME_CHAR: - { - // Set information - len = APP_DIS_MANUFACTURER_NAME_LEN; - data = (uint8_t *)APP_DIS_MANUFACTURER_NAME; - } break; + // Check requested value + switch (param->value) { + case DIS_MANUFACTURER_NAME_CHAR: { + // Set information + len = APP_DIS_MANUFACTURER_NAME_LEN; + data = (uint8_t *)APP_DIS_MANUFACTURER_NAME; + } break; - case DIS_MODEL_NB_STR_CHAR: - { - // Set information - len = APP_DIS_MODEL_NB_STR_LEN; - data = (uint8_t *)APP_DIS_MODEL_NB_STR; - } break; + case DIS_MODEL_NB_STR_CHAR: { + // Set information + len = APP_DIS_MODEL_NB_STR_LEN; + data = (uint8_t *)APP_DIS_MODEL_NB_STR; + } break; - case DIS_SYSTEM_ID_CHAR: - { - // Set information - len = APP_DIS_SYSTEM_ID_LEN; - data = (uint8_t *)APP_DIS_SYSTEM_ID; - } break; + case DIS_SYSTEM_ID_CHAR: { + // Set information + len = APP_DIS_SYSTEM_ID_LEN; + data = (uint8_t *)APP_DIS_SYSTEM_ID; + } break; - case DIS_PNP_ID_CHAR: - { - // Set information - len = APP_DIS_PNP_ID_LEN; - data = (uint8_t *)APP_DIS_PNP_ID; - } break; + case DIS_PNP_ID_CHAR: { + // Set information + len = APP_DIS_PNP_ID_LEN; + data = (uint8_t *)APP_DIS_PNP_ID; + } break; - case DIS_SERIAL_NB_STR_CHAR: - { - // Set information - len = APP_DIS_SERIAL_NB_STR_LEN; - data = (uint8_t *)APP_DIS_SERIAL_NB_STR; - } break; + case DIS_SERIAL_NB_STR_CHAR: { + // Set information + len = APP_DIS_SERIAL_NB_STR_LEN; + data = (uint8_t *)APP_DIS_SERIAL_NB_STR; + } break; - case DIS_HARD_REV_STR_CHAR: - { - // Set information - len = APP_DIS_HARD_REV_STR_LEN; - data = (uint8_t *)APP_DIS_HARD_REV_STR; - } break; + case DIS_HARD_REV_STR_CHAR: { + // Set information + len = APP_DIS_HARD_REV_STR_LEN; + data = (uint8_t *)APP_DIS_HARD_REV_STR; + } break; - case DIS_FIRM_REV_STR_CHAR: - { - // Set information - len = APP_DIS_FIRM_REV_STR_LEN; - data = (uint8_t *)APP_DIS_FIRM_REV_STR; - } break; + case DIS_FIRM_REV_STR_CHAR: { + // Set information + len = APP_DIS_FIRM_REV_STR_LEN; + data = (uint8_t *)APP_DIS_FIRM_REV_STR; + } break; - case DIS_SW_REV_STR_CHAR: - { - // Set information - len = APP_DIS_SW_REV_STR_LEN; - data = (uint8_t *)APP_DIS_SW_REV_STR; - } break; + case DIS_SW_REV_STR_CHAR: { + // Set information + len = APP_DIS_SW_REV_STR_LEN; + data = (uint8_t *)APP_DIS_SW_REV_STR; + } break; - case DIS_IEEE_CHAR: - { - // Set information - len = APP_DIS_IEEE_LEN; - data = (uint8_t *)APP_DIS_IEEE; - } break; + case DIS_IEEE_CHAR: { + // Set information + len = APP_DIS_IEEE_LEN; + data = (uint8_t *)APP_DIS_IEEE; + } break; - default: - ASSERT_ERR(0); - break; - } + default: + ASSERT_ERR(0); + break; + } - // Allocate confirmation to send the value - struct diss_value_cfm *cfm_value = KE_MSG_ALLOC_DYN(DISS_VALUE_CFM, - src_id, dest_id, - diss_value_cfm, - len); + // Allocate confirmation to send the value + struct diss_value_cfm *cfm_value = + KE_MSG_ALLOC_DYN(DISS_VALUE_CFM, src_id, dest_id, diss_value_cfm, len); - // Set parameters - cfm_value->value = param->value; - cfm_value->length = len; - if (len) - { - // Copy data - memcpy(&cfm_value->data[0], data, len); - } - // Send message - ke_msg_send(cfm_value); + // Set parameters + cfm_value->value = param->value; + cfm_value->length = len; + if (len) { + // Copy data + memcpy(&cfm_value->data[0], data, len); + } + // Send message + ke_msg_send(cfm_value); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /* @@ -147,36 +133,34 @@ static int diss_value_req_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ -void app_dis_init(void) -{ - // Nothing to do +void app_dis_init(void) { + // Nothing to do } -void app_dis_add_dis(void) -{ - struct diss_db_cfg* db_cfg; - // Allocate the DISS_CREATE_DB_REQ - struct gapm_profile_task_add_cmd *req = KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, - TASK_GAPM, TASK_APP, - gapm_profile_task_add_cmd, sizeof(struct diss_db_cfg)); - // Fill message - req->operation = GAPM_PROFILE_TASK_ADD; -#if BLE_CONNECTION_MAX>1 - req->sec_lvl = PERM(SVC_AUTH, ENABLE)|PERM(SVC_MI, ENABLE); +void app_dis_add_dis(void) { + struct diss_db_cfg *db_cfg; + // Allocate the DISS_CREATE_DB_REQ + struct gapm_profile_task_add_cmd *req = + KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, TASK_GAPM, TASK_APP, + gapm_profile_task_add_cmd, sizeof(struct diss_db_cfg)); + // Fill message + req->operation = GAPM_PROFILE_TASK_ADD; +#if BLE_CONNECTION_MAX > 1 + req->sec_lvl = PERM(SVC_AUTH, ENABLE) | PERM(SVC_MI, ENABLE); #else - req->sec_lvl = PERM(SVC_AUTH, ENABLE); + req->sec_lvl = PERM(SVC_AUTH, ENABLE); #endif - req->prf_task_id = TASK_ID_DISS; - req->app_task = TASK_APP; - req->start_hdl = 0; + req->prf_task_id = TASK_ID_DISS; + req->app_task = TASK_APP; + req->start_hdl = 0; - // Set parameters - db_cfg = (struct diss_db_cfg* ) req->param; - db_cfg->features = APP_DIS_FEATURES; + // Set parameters + db_cfg = (struct diss_db_cfg *)req->param; + db_cfg->features = APP_DIS_FEATURES; - // Send the message - ke_msg_send(req); + // Send the message + ke_msg_send(req); } /* @@ -185,14 +169,14 @@ void app_dis_add_dis(void) */ /// Default State handlers definition -const struct ke_msg_handler app_dis_msg_handler_list[] = -{ - {DISS_VALUE_REQ_IND, (ke_msg_func_t)diss_value_req_ind_handler}, +const struct ke_msg_handler app_dis_msg_handler_list[] = { + {DISS_VALUE_REQ_IND, (ke_msg_func_t)diss_value_req_ind_handler}, }; -const struct ke_state_handler app_dis_table_handler = - {&app_dis_msg_handler_list[0], (sizeof(app_dis_msg_handler_list)/sizeof(struct ke_msg_handler))}; +const struct ke_state_handler app_dis_table_handler = { + &app_dis_msg_handler_list[0], + (sizeof(app_dis_msg_handler_list) / sizeof(struct ke_msg_handler))}; -#endif //BLE_APP_DIS +#endif // BLE_APP_DIS /// @} APP diff --git a/services/ble_app/app_gfps/app_gfps.c b/services/ble_app/app_gfps/app_gfps.c index 68e3399..b17dbb7 100644 --- a/services/ble_app/app_gfps/app_gfps.c +++ b/services/ble_app/app_gfps/app_gfps.c @@ -20,7 +20,7 @@ **************************************************************************************** */ -#include "rwip_config.h" // SW configuration +#include "rwip_config.h" // SW configuration #if (BLE_APP_GFPS) @@ -28,26 +28,25 @@ * INCLUDE FILES **************************************************************************************** */ -#include "cmsis_os.h" -#include "app.h" // Application Manager Definitions +#include "app.h" // Application Manager Definitions +#include "app_ble_mode_switch.h" +#include "app_bt.h" +#include "app_gfps.h" // Device Information Service Application Definitions #include "apps.h" -#include "app_gfps.h" // Device Information Service Application Definitions -#include "gfps_provider_task.h" // Device Information Profile Functions -#include "prf_types.h" // Profile Common Types Definitions -#include "gapm_task.h" // GAP Manager Task API -#include +#include "bt_if.h" +#include "cmsis_os.h" +#include "gap.h" +#include "gapm.h" +#include "gapm_task.h" // GAP Manager Task API #include "gfps_crypto.h" #include "gfps_provider.h" #include "gfps_provider_errors.h" -#include "gap.h" -#include "app_ble_mode_switch.h" +#include "gfps_provider_task.h" // Device Information Profile Functions +#include "me_api.h" #include "nvrecord.h" #include "nvrecord_fp_account_key.h" -#include "gfps_crypto.h" -#include "gapm.h" -#include "me_api.h" -#include "app_bt.h" -#include "bt_if.h" +#include "prf_types.h" // Profile Common Types Definitions +#include #ifdef IBRT #include "app_tws_ibrt.h" @@ -59,12 +58,11 @@ #define USE_RANDOM_NUM_AS_SALT 1 #define GFPS_ACCOUNTKEY_SALT_TYPE USE_BLE_ADDR_AS_SALT -#define FP_SERVICE_LEN 0x06 -#define FP_SERVICE_UUID 0x2CFE -#define FP_DEVICE_MODEL_ID 0x2B677D +#define FP_SERVICE_LEN 0x06 +#define FP_SERVICE_UUID 0x2CFE +#define FP_DEVICE_MODEL_ID 0x2B677D - -#define GFPS_INITIAL_ADV_RAND_SALT 0xFF +#define GFPS_INITIAL_ADV_RAND_SALT 0xFF #define BLE_FASTPAIR_NORMAL_ADVERTISING_INTERVAL (160) #define BLE_FASTPAIR_FAST_ADVERTISING_INTERVAL (48) @@ -72,7 +70,8 @@ /************************private type defination****************************/ /************************extern function declearation***********************/ -extern void AES128_ECB_decrypt(uint8_t *input, const uint8_t *key, uint8_t *output); +extern void AES128_ECB_decrypt(uint8_t *input, const uint8_t *key, + uint8_t *output); /**********************private function declearation************************/ /*--------------------------------------------------------------------------- @@ -93,27 +92,26 @@ static void gfps_ble_data_fill_handler(void *param); /************************private variable defination************************/ struct app_gfps_env_tag app_gfps_env; -static char app_gfps_power_uuid[APP_GFPS_ADV_POWER_UUID_LEN] = APP_GFPS_ADV_POWER_UUID; +static char app_gfps_power_uuid[APP_GFPS_ADV_POWER_UUID_LEN] = + APP_GFPS_ADV_POWER_UUID; /****************************function defination****************************/ -static void app_gfps_init_env(void) -{ - memset(( uint8_t * )&app_gfps_env, 0, sizeof(struct app_gfps_env_tag)); - app_gfps_env.connectionIndex = BLE_INVALID_CONNECTION_INDEX; - app_gfps_env.batteryDataType = HIDE_UI_INDICATION; - app_gfps_env.advRandSalt = GFPS_INITIAL_ADV_RAND_SALT; - app_ble_register_data_fill_handle(USER_GFPS, ( BLE_DATA_FILL_FUNC_T )gfps_ble_data_fill_handler, false); +static void app_gfps_init_env(void) { + memset((uint8_t *)&app_gfps_env, 0, sizeof(struct app_gfps_env_tag)); + app_gfps_env.connectionIndex = BLE_INVALID_CONNECTION_INDEX; + app_gfps_env.batteryDataType = HIDE_UI_INDICATION; + app_gfps_env.advRandSalt = GFPS_INITIAL_ADV_RAND_SALT; + app_ble_register_data_fill_handle( + USER_GFPS, (BLE_DATA_FILL_FUNC_T)gfps_ble_data_fill_handler, false); } -static void big_little_switch(const uint8_t *in, uint8_t *out, uint8_t len) -{ - if (len < 1) - return; - for (int i = 0; i < len; i++) - { - out[i] = in[len - i - 1]; - } +static void big_little_switch(const uint8_t *in, uint8_t *out, uint8_t len) { + if (len < 1) return; + for (int i = 0; i < len; i++) { + out[i] = in[len - i - 1]; + } + return; } /* @@ -122,45 +120,40 @@ static void big_little_switch(const uint8_t *in, uint8_t *out, uint8_t len) */ extern uint8_t bt_addr[6]; -void app_gfps_connected_evt_handler(uint8_t conidx) -{ - app_gfps_env.connectionIndex = conidx; - TRACE(0,"local LE addr: "); +void app_gfps_connected_evt_handler(uint8_t conidx) { + app_gfps_env.connectionIndex = conidx; + TRACE(0, "local LE addr: "); - bd_addr_t *pBdAddr = gapm_get_connected_bdaddr(conidx); - big_little_switch(pBdAddr->addr, &app_gfps_env.local_le_addr.addr[0], 6); - DUMP8("0x%02x ", pBdAddr->addr, 6); -#if !defined(IBRT) - big_little_switch((&bt_addr[0]), &app_gfps_env.local_bt_addr.addr[0], 6); - TRACE(0,"local bt addr: "); - DUMP8("0x%02x ", &bt_addr[0], 6); + bd_addr_t *pBdAddr = gapm_get_connected_bdaddr(conidx); + big_little_switch(pBdAddr->addr, &app_gfps_env.local_le_addr.addr[0], 6); + DUMP8("0x%02x ", pBdAddr->addr, 6); +#if !defined(IBRT) + big_little_switch((&bt_addr[0]), &app_gfps_env.local_bt_addr.addr[0], 6); + TRACE(0, "local bt addr: "); + DUMP8("0x%02x ", &bt_addr[0], 6); #else - big_little_switch(app_tws_ibrt_get_bt_ctrl_ctx()->local_addr.address, - &app_gfps_env.local_bt_addr.addr[0], 6); - TRACE(0,"local bt addr: "); - DUMP8("0x%02x ", app_tws_ibrt_get_bt_ctrl_ctx()->local_addr.address, 6); + big_little_switch(app_tws_ibrt_get_bt_ctrl_ctx()->local_addr.address, + &app_gfps_env.local_bt_addr.addr[0], 6); + TRACE(0, "local bt addr: "); + DUMP8("0x%02x ", app_tws_ibrt_get_bt_ctrl_ctx()->local_addr.address, 6); #endif } -void app_gfps_disconnected_evt_handler(uint8_t conidx) -{ - if (conidx == app_gfps_env.connectionIndex) - { - //recover classic bt iocap - if (app_gfps_env.bt_set_iocap != NULL) - { - app_gfps_env.bt_set_iocap(app_gfps_env.bt_iocap); - } - if(app_gfps_env.bt_set_authrequirements!=NULL) - { - app_gfps_env.bt_set_authrequirements(app_gfps_env.bt_authrequirements); - } - - app_gfps_env.isKeyBasedPairingNotificationEnabled = false; - app_gfps_env.isPassKeyNotificationEnabled = false; - app_gfps_env.isPendingForWritingNameReq = false; - app_gfps_env.connectionIndex = BLE_INVALID_CONNECTION_INDEX; +void app_gfps_disconnected_evt_handler(uint8_t conidx) { + if (conidx == app_gfps_env.connectionIndex) { + // recover classic bt iocap + if (app_gfps_env.bt_set_iocap != NULL) { + app_gfps_env.bt_set_iocap(app_gfps_env.bt_iocap); } + if (app_gfps_env.bt_set_authrequirements != NULL) { + app_gfps_env.bt_set_authrequirements(app_gfps_env.bt_authrequirements); + } + + app_gfps_env.isKeyBasedPairingNotificationEnabled = false; + app_gfps_env.isPassKeyNotificationEnabled = false; + app_gfps_env.isPendingForWritingNameReq = false; + app_gfps_env.connectionIndex = BLE_INVALID_CONNECTION_INDEX; + } } /* @@ -171,886 +164,794 @@ void app_gfps_disconnected_evt_handler(uint8_t conidx) static int gfpsp_value_req_ind_handler(ke_msg_id_t const msgid, struct gfpsp_value_req_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Initialize length - uint8_t len = 0; - // Pointer to the data - uint8_t *data = NULL; - TRACE(1,"val %d", param->value); - // Check requested value - switch (param->value) - { - case GFPSP_MANUFACTURER_NAME_CHAR: - case GFPSP_MODEL_NB_STR_CHAR: - case GFPSP_SYSTEM_ID_CHAR: - case GFPSP_PNP_ID_CHAR: - case GFPSP_SERIAL_NB_STR_CHAR: - case GFPSP_HARD_REV_STR_CHAR: - case GFPSP_FIRM_REV_STR_CHAR: - case GFPSP_SW_REV_STR_CHAR: - case GFPSP_IEEE_CHAR: - { - // Set information - len = APP_GFPS_IEEE_LEN; - data = ( uint8_t * )APP_GFPS_IEEE; - } + ke_task_id_t const src_id) { + // Initialize length + uint8_t len = 0; + // Pointer to the data + uint8_t *data = NULL; + TRACE(1, "val %d", param->value); + // Check requested value + switch (param->value) { + case GFPSP_MANUFACTURER_NAME_CHAR: + case GFPSP_MODEL_NB_STR_CHAR: + case GFPSP_SYSTEM_ID_CHAR: + case GFPSP_PNP_ID_CHAR: + case GFPSP_SERIAL_NB_STR_CHAR: + case GFPSP_HARD_REV_STR_CHAR: + case GFPSP_FIRM_REV_STR_CHAR: + case GFPSP_SW_REV_STR_CHAR: + case GFPSP_IEEE_CHAR: { + // Set information + len = APP_GFPS_IEEE_LEN; + data = (uint8_t *)APP_GFPS_IEEE; + } break; + + default: + ASSERT_ERR(0); break; + } - default: - ASSERT_ERR(0); - break; - } + // Allocate confirmation to send the value + struct gfpsp_value_cfm *cfm_value = + KE_MSG_ALLOC_DYN(GFPSP_VALUE_CFM, src_id, dest_id, gfpsp_value_cfm, len); - // Allocate confirmation to send the value - struct gfpsp_value_cfm *cfm_value = KE_MSG_ALLOC_DYN(GFPSP_VALUE_CFM, - src_id, - dest_id, - gfpsp_value_cfm, - len); + // Set parameters + cfm_value->value = param->value; + cfm_value->length = len; + if (len) { + // Copy data + memcpy(&cfm_value->data[0], data, len); + } + // Send message + ke_msg_send(cfm_value); - // Set parameters - cfm_value->value = param->value; - cfm_value->length = len; - if (len) - { - // Copy data - memcpy(&cfm_value->data[0], data, len); - } - // Send message - ke_msg_send(cfm_value); - - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /* * GLOBAL FUNCTION DEFINITIONS **************************************************************************************** */ -//MSB->LSB +// MSB->LSB const uint8_t bes_demo_Public_anti_spoofing_key[64] = { - 0x3E,0x08,0x3B,0x0A,0x5C,0x04,0x78,0x84,0xBE,0x41, - 0xBE,0x7E,0x52,0xD1,0x0C,0x68,0x64,0x6C,0x4D,0xB6, - 0xD9,0x20,0x95,0xA7,0x32,0xE9,0x42,0x40,0xAC,0x02, - 0x54,0x48,0x99,0x49,0xDA,0xE1,0x0D,0x9C,0xF5,0xEB, - 0x29,0x35,0x7F,0xB1,0x70,0x55,0xCB,0x8C,0x8F,0xBF, - 0xEB,0x17,0x15,0x3F,0xA0,0xAA,0xA5,0xA2,0xC4,0x3C, - 0x1B,0x48,0x60,0xDA -}; + 0x3E, 0x08, 0x3B, 0x0A, 0x5C, 0x04, 0x78, 0x84, 0xBE, 0x41, 0xBE, + 0x7E, 0x52, 0xD1, 0x0C, 0x68, 0x64, 0x6C, 0x4D, 0xB6, 0xD9, 0x20, + 0x95, 0xA7, 0x32, 0xE9, 0x42, 0x40, 0xAC, 0x02, 0x54, 0x48, 0x99, + 0x49, 0xDA, 0xE1, 0x0D, 0x9C, 0xF5, 0xEB, 0x29, 0x35, 0x7F, 0xB1, + 0x70, 0x55, 0xCB, 0x8C, 0x8F, 0xBF, 0xEB, 0x17, 0x15, 0x3F, 0xA0, + 0xAA, 0xA5, 0xA2, 0xC4, 0x3C, 0x1B, 0x48, 0x60, 0xDA}; -//MSB->LSB -const uint8_t bes_demo_private_anti_spoofing_key[32]= { - 0xCD,0xF8,0xAA,0xC0,0xDF,0x4C,0x93,0x63,0x2F,0x48, - 0x20,0xA6,0xD8,0xAB,0x22,0xF3,0x3A,0x94,0xBF,0x8E, - 0x4C,0x90,0x25,0xB3,0x44,0xD2,0x2E,0xDE,0x0F,0xB7, - 0x22,0x1F - }; +// MSB->LSB +const uint8_t bes_demo_private_anti_spoofing_key[32] = { + 0xCD, 0xF8, 0xAA, 0xC0, 0xDF, 0x4C, 0x93, 0x63, 0x2F, 0x48, 0x20, + 0xA6, 0xD8, 0xAB, 0x22, 0xF3, 0x3A, 0x94, 0xBF, 0x8E, 0x4C, 0x90, + 0x25, 0xB3, 0x44, 0xD2, 0x2E, 0xDE, 0x0F, 0xB7, 0x22, 0x1F}; extern void fast_pair_enter_pairing_mode_handler(void); -void app_gfps_init(void) -{ - nv_record_fp_account_key_init(); - app_gfps_init_env(); - app_gfps_env.enter_pairing_mode =NULL; - app_gfps_env.bt_set_iocap =NULL; - app_gfps_env.bt_set_authrequirements =NULL; - gfps_crypto_init(); +void app_gfps_init(void) { + nv_record_fp_account_key_init(); + app_gfps_init_env(); + app_gfps_env.enter_pairing_mode = NULL; + app_gfps_env.bt_set_iocap = NULL; + app_gfps_env.bt_set_authrequirements = NULL; + gfps_crypto_init(); - app_bt_get_fast_pair_info(); + app_bt_get_fast_pair_info(); #ifndef IS_USE_CUSTOM_FP_INFO - gfps_crypto_set_p256_key(bes_demo_Public_anti_spoofing_key, bes_demo_private_anti_spoofing_key); + gfps_crypto_set_p256_key(bes_demo_Public_anti_spoofing_key, + bes_demo_private_anti_spoofing_key); #else - gfps_crypto_set_p256_key(app_bt_get_fast_pair_public_key(),app_bt_get_fast_pair_private_key()); + gfps_crypto_set_p256_key(app_bt_get_fast_pair_public_key(), + app_bt_get_fast_pair_private_key()); #endif - app_gfps_set_bt_access_mode(fast_pair_enter_pairing_mode_handler); - app_gfps_set_io_cap(( gfps_bt_io_cap_set )btif_sec_set_io_capabilities); + app_gfps_set_bt_access_mode(fast_pair_enter_pairing_mode_handler); + app_gfps_set_io_cap((gfps_bt_io_cap_set)btif_sec_set_io_capabilities); - app_gfps_set_authrequirements((gfps_bt_io_authrequirements_set)btif_sec_set_authrequirements); + app_gfps_set_authrequirements( + (gfps_bt_io_authrequirements_set)btif_sec_set_authrequirements); - app_gfps_enable_battery_info(true); + app_gfps_enable_battery_info(true); } -void app_gfps_set_bt_access_mode(gfps_enter_pairing_mode cb) -{ - app_gfps_env.enter_pairing_mode = cb; +void app_gfps_set_bt_access_mode(gfps_enter_pairing_mode cb) { + app_gfps_env.enter_pairing_mode = cb; } -void app_gfps_set_io_cap(gfps_bt_io_cap_set cb) -{ - app_gfps_env.bt_set_iocap = cb; +void app_gfps_set_io_cap(gfps_bt_io_cap_set cb) { + app_gfps_env.bt_set_iocap = cb; } -void app_gfps_set_authrequirements(gfps_bt_io_authrequirements_set cb) -{ - app_gfps_env.bt_set_authrequirements = cb; +void app_gfps_set_authrequirements(gfps_bt_io_authrequirements_set cb) { + app_gfps_env.bt_set_authrequirements = cb; } -void app_gfps_set_battery_info_acquire_handler(gfps_get_battery_info_handler cb) -{ - app_gfps_env.get_battery_info_handler = cb; +void app_gfps_set_battery_info_acquire_handler( + gfps_get_battery_info_handler cb) { + app_gfps_env.get_battery_info_handler = cb; } -void app_gfps_add_gfps(void) -{ - struct gfpsp_db_cfg *db_cfg; - // Allocate the DISS_CREATE_DB_REQ - struct gapm_profile_task_add_cmd *req = KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, - TASK_GAPM, - TASK_APP, - gapm_profile_task_add_cmd, - sizeof(struct gfpsp_db_cfg)); - // Fill message - req->operation = GAPM_PROFILE_TASK_ADD; +void app_gfps_add_gfps(void) { + struct gfpsp_db_cfg *db_cfg; + // Allocate the DISS_CREATE_DB_REQ + struct gapm_profile_task_add_cmd *req = + KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, TASK_GAPM, TASK_APP, + gapm_profile_task_add_cmd, sizeof(struct gfpsp_db_cfg)); + // Fill message + req->operation = GAPM_PROFILE_TASK_ADD; #if BLE_CONNECTION_MAX > 1 - req->sec_lvl = PERM(SVC_AUTH, ENABLE) | PERM(SVC_MI, ENABLE); + req->sec_lvl = PERM(SVC_AUTH, ENABLE) | PERM(SVC_MI, ENABLE); #else - req->sec_lvl = PERM(SVC_AUTH, ENABLE); + req->sec_lvl = PERM(SVC_AUTH, ENABLE); #endif - req->prf_task_id = TASK_ID_GFPSP; - req->app_task = TASK_APP; - req->start_hdl = 0; + req->prf_task_id = TASK_ID_GFPSP; + req->app_task = TASK_APP; + req->start_hdl = 0; - // Set parameters - db_cfg = ( struct gfpsp_db_cfg * )req->param; - db_cfg->features = APP_GFPS_FEATURES; + // Set parameters + db_cfg = (struct gfpsp_db_cfg *)req->param; + db_cfg->features = APP_GFPS_FEATURES; - // Send the message - ke_msg_send(req); + // Send the message + ke_msg_send(req); } -void app_gfps_send_keybase_pairing_via_notification(uint8_t *ptrData, uint32_t length) -{ - struct gfpsp_send_data_req_t *req = - KE_MSG_ALLOC_DYN(GFPSP_KEY_BASED_PAIRING_WRITE_NOTIFY, - KE_BUILD_ID(prf_get_task_from_id(TASK_ID_GFPSP), - app_gfps_env.connectionIndex), - TASK_APP, - gfpsp_send_data_req_t, - length); +void app_gfps_send_keybase_pairing_via_notification(uint8_t *ptrData, + uint32_t length) { + struct gfpsp_send_data_req_t *req = + KE_MSG_ALLOC_DYN(GFPSP_KEY_BASED_PAIRING_WRITE_NOTIFY, + KE_BUILD_ID(prf_get_task_from_id(TASK_ID_GFPSP), + app_gfps_env.connectionIndex), + TASK_APP, gfpsp_send_data_req_t, length); - req->connecionIndex = app_gfps_env.connectionIndex; - req->length = length; - memcpy(req->value, ptrData, length); + req->connecionIndex = app_gfps_env.connectionIndex; + req->length = length; + memcpy(req->value, ptrData, length); - ke_msg_send(req); + ke_msg_send(req); } -int app_gfps_send_passkey_via_notification(uint8_t *ptrData, uint32_t length) -{ - struct gfpsp_send_data_req_t *req = - KE_MSG_ALLOC_DYN(GFPSP_KEY_PASS_KEY_WRITE_NOTIFY, - KE_BUILD_ID(prf_get_task_from_id(TASK_ID_GFPSP), - app_gfps_env.connectionIndex), - TASK_APP, - gfpsp_send_data_req_t, - length); +int app_gfps_send_passkey_via_notification(uint8_t *ptrData, uint32_t length) { + struct gfpsp_send_data_req_t *req = + KE_MSG_ALLOC_DYN(GFPSP_KEY_PASS_KEY_WRITE_NOTIFY, + KE_BUILD_ID(prf_get_task_from_id(TASK_ID_GFPSP), + app_gfps_env.connectionIndex), + TASK_APP, gfpsp_send_data_req_t, length); - req->connecionIndex = app_gfps_env.connectionIndex; - req->length = length; - memcpy(req->value, ptrData, length); + req->connecionIndex = app_gfps_env.connectionIndex; + req->length = length; + memcpy(req->value, ptrData, length); - ke_msg_send(req); + ke_msg_send(req); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } -static void app_gfps_send_naming_packet_via_notification(uint8_t *ptrData, uint32_t length) -{ - struct gfpsp_send_data_req_t *req = - KE_MSG_ALLOC_DYN(GFPSP_NAME_NOTIFY, - KE_BUILD_ID(prf_get_task_from_id(TASK_ID_GFPSP), - app_gfps_env.connectionIndex), - TASK_APP, - gfpsp_send_data_req_t, - length); +static void app_gfps_send_naming_packet_via_notification(uint8_t *ptrData, + uint32_t length) { + struct gfpsp_send_data_req_t *req = + KE_MSG_ALLOC_DYN(GFPSP_NAME_NOTIFY, + KE_BUILD_ID(prf_get_task_from_id(TASK_ID_GFPSP), + app_gfps_env.connectionIndex), + TASK_APP, gfpsp_send_data_req_t, length); - req->connecionIndex = app_gfps_env.connectionIndex; - req->length = length; - memcpy(req->value, ptrData, length); + req->connecionIndex = app_gfps_env.connectionIndex; + req->length = length; + memcpy(req->value, ptrData, length); - ke_msg_send(req); + ke_msg_send(req); } -void app_gfps_handling_on_mobile_link_disconnection(btif_remote_device_t* pRemDev) -{ - bool isDisconnectedWithMobile = false; +void app_gfps_handling_on_mobile_link_disconnection( + btif_remote_device_t *pRemDev) { + bool isDisconnectedWithMobile = false; #ifdef IBRT - ibrt_link_type_e link_type = - app_tws_ibrt_get_remote_link_type(pRemDev); - if (MOBILE_LINK == link_type) - { - isDisconnectedWithMobile = true; - } -#else + ibrt_link_type_e link_type = app_tws_ibrt_get_remote_link_type(pRemDev); + if (MOBILE_LINK == link_type) { isDisconnectedWithMobile = true; + } +#else + isDisconnectedWithMobile = true; #endif - if (isDisconnectedWithMobile) - { - if (app_gfps_is_last_response_pending()) - { - app_gfps_enter_connectable_mode_req_handler(app_gfps_get_last_response()); - } - } + if (isDisconnectedWithMobile) { + if (app_gfps_is_last_response_pending()) { + app_gfps_enter_connectable_mode_req_handler(app_gfps_get_last_response()); + } + } } -void app_gfps_enter_connectable_mode_req_handler(uint8_t *response) -{ - TRACE(2,"%s isLastResponsePending:%d", __func__, app_gfps_env.isLastResponsePending); - TRACE(0,"response data:"); - DUMP8("%02x ", response, GFPSP_ENCRYPTED_RSP_LEN); +void app_gfps_enter_connectable_mode_req_handler(uint8_t *response) { + TRACE(2, "%s isLastResponsePending:%d", __func__, + app_gfps_env.isLastResponsePending); + TRACE(0, "response data:"); + DUMP8("%02x ", response, GFPSP_ENCRYPTED_RSP_LEN); #ifdef __BT_ONE_BRING_TWO__ - app_gfps_send_keybase_pairing_via_notification(response, GFPSP_ENCRYPTED_RSP_LEN); + app_gfps_send_keybase_pairing_via_notification(response, + GFPSP_ENCRYPTED_RSP_LEN); #else #ifndef IBRT - if (btif_me_get_activeCons() > 0) + if (btif_me_get_activeCons() > 0) #else - if (app_tws_ibrt_mobile_link_connected()) + if (app_tws_ibrt_mobile_link_connected()) #endif - { - memcpy(app_gfps_env.pendingLastResponse, response, GFPSP_ENCRYPTED_RSP_LEN); - app_gfps_env.isLastResponsePending = true; - #ifndef IBRT - app_disconnect_all_bt_connections(); - #else - app_tws_ibrt_disconnect_mobile(); - #endif + { + memcpy(app_gfps_env.pendingLastResponse, response, GFPSP_ENCRYPTED_RSP_LEN); + app_gfps_env.isLastResponsePending = true; +#ifndef IBRT + app_disconnect_all_bt_connections(); +#else + app_tws_ibrt_disconnect_mobile(); +#endif + } else { + app_gfps_env.isLastResponsePending = false; + app_gfps_send_keybase_pairing_via_notification(response, + GFPSP_ENCRYPTED_RSP_LEN); + TRACE(0, "wait for pair req maybe classic or ble"); + app_gfps_env.isWaitingForFpToConnect = true; + if (app_gfps_env.enter_pairing_mode != NULL) { + app_gfps_env.enter_pairing_mode(); } - else - { - app_gfps_env.isLastResponsePending = false; - app_gfps_send_keybase_pairing_via_notification(response, GFPSP_ENCRYPTED_RSP_LEN); - TRACE(0,"wait for pair req maybe classic or ble"); - app_gfps_env.isWaitingForFpToConnect = true; - if (app_gfps_env.enter_pairing_mode != NULL) - { - app_gfps_env.enter_pairing_mode(); - } - - if (app_gfps_env.bt_set_iocap != NULL) - { - TRACE(0,"SET IOC"); - app_gfps_env.bt_iocap = app_gfps_env.bt_set_iocap(1); //IO_display_yesno - } - - if(app_gfps_env.bt_set_authrequirements!=NULL) - { - TRACE(0,"SET authrequirements"); - app_gfps_env.bt_authrequirements = app_gfps_env.bt_set_authrequirements(1);//Man in the Middle protection req - } + if (app_gfps_env.bt_set_iocap != NULL) { + TRACE(0, "SET IOC"); + app_gfps_env.bt_iocap = app_gfps_env.bt_set_iocap(1); // IO_display_yesno } + + if (app_gfps_env.bt_set_authrequirements != NULL) { + TRACE(0, "SET authrequirements"); + app_gfps_env.bt_authrequirements = app_gfps_env.bt_set_authrequirements( + 1); // Man in the Middle protection req + } + } #endif } -uint8_t *app_gfps_get_last_response(void) -{ - return app_gfps_env.pendingLastResponse; +uint8_t *app_gfps_get_last_response(void) { + return app_gfps_env.pendingLastResponse; } -bool app_gfps_is_last_response_pending(void) -{ - return app_gfps_env.isLastResponsePending; +bool app_gfps_is_last_response_pending(void) { + return app_gfps_env.isLastResponsePending; } -static uint8_t app_gfps_handle_decrypted_keybase_pairing_request(gfpsp_req_resp *raw_req, - uint8_t *out_key) -{ - gfpsp_encrypted_resp en_rsp; - gfpsp_raw_resp raw_rsp; - memcpy(app_gfps_env.keybase_pair_key, out_key, 16); - memcpy(&app_gfps_env.seeker_bt_addr.addr[0] ,&raw_req->rx_tx.key_based_pairing_req.seeker_addr[0],6); - if(raw_req->rx_tx.key_based_pairing_req.flags_discoverability ==RAW_REQ_FLAGS_DISCOVERABILITY_BIT0_EN) - { - TRACE(0,"TODO discoverable 10S"); - //TODO start a timer keep discoverable 10S... - //TODO make sure there is no ble ADV with the MODEL ID data - } - raw_rsp.message_type = KEY_BASED_PAIRING_RSP;// Key-based Pairing Response - memcpy(raw_rsp.provider_addr, app_gfps_env.local_bt_addr.addr, 6); +static uint8_t +app_gfps_handle_decrypted_keybase_pairing_request(gfpsp_req_resp *raw_req, + uint8_t *out_key) { + gfpsp_encrypted_resp en_rsp; + gfpsp_raw_resp raw_rsp; + memcpy(app_gfps_env.keybase_pair_key, out_key, 16); + memcpy(&app_gfps_env.seeker_bt_addr.addr[0], + &raw_req->rx_tx.key_based_pairing_req.seeker_addr[0], 6); + if (raw_req->rx_tx.key_based_pairing_req.flags_discoverability == + RAW_REQ_FLAGS_DISCOVERABILITY_BIT0_EN) { + TRACE(0, "TODO discoverable 10S"); + // TODO start a timer keep discoverable 10S... + // TODO make sure there is no ble ADV with the MODEL ID data + } + raw_rsp.message_type = KEY_BASED_PAIRING_RSP; // Key-based Pairing Response + memcpy(raw_rsp.provider_addr, app_gfps_env.local_bt_addr.addr, 6); - TRACE(0,"raw_rsp.provider_addr:"); - DUMP8("%02x ",raw_rsp.provider_addr, 6); + TRACE(0, "raw_rsp.provider_addr:"); + DUMP8("%02x ", raw_rsp.provider_addr, 6); - for (uint8_t index = 0; index < 9; index++) - { - raw_rsp.salt[index] = ( uint8_t )rand(); - } + for (uint8_t index = 0; index < 9; index++) { + raw_rsp.salt[index] = (uint8_t)rand(); + } - gfps_crypto_encrypt(( const uint8_t * )(&raw_rsp.message_type), - sizeof(raw_rsp), - app_gfps_env.keybase_pair_key, - en_rsp.uint128_array); + gfps_crypto_encrypt((const uint8_t *)(&raw_rsp.message_type), sizeof(raw_rsp), + app_gfps_env.keybase_pair_key, en_rsp.uint128_array); - TRACE(1,"message type is 0x%x", raw_req->rx_tx.raw_req.message_type); - TRACE(4,"bit 0: %d, bit 1: %d, bit 2: %d, bit 3: %d", + TRACE(1, "message type is 0x%x", raw_req->rx_tx.raw_req.message_type); + TRACE(4, "bit 0: %d, bit 1: %d, bit 2: %d, bit 3: %d", raw_req->rx_tx.key_based_pairing_req.flags_discoverability, raw_req->rx_tx.key_based_pairing_req.flags_bonding_addr, raw_req->rx_tx.key_based_pairing_req.flags_get_existing_name, - raw_req->rx_tx.key_based_pairing_req.flags_retroactively_write_account_key); + raw_req->rx_tx.key_based_pairing_req + .flags_retroactively_write_account_key); - bool isReturnName = raw_req->rx_tx.key_based_pairing_req.flags_get_existing_name; + bool isReturnName = + raw_req->rx_tx.key_based_pairing_req.flags_get_existing_name; - if(raw_req->rx_tx.key_based_pairing_req.flags_bonding_addr == RAW_REQ_FLAGS_INTBONDING_SEEKERADDR_BIT1_EN) - { - TRACE(0,"try connect to remote BR/EDR addr"); - // TODO: - app_gfps_send_keybase_pairing_via_notification(( uint8_t * )en_rsp.uint128_array, sizeof(en_rsp)); - } - else if (raw_req->rx_tx.key_based_pairing_req.flags_retroactively_write_account_key) - { - // check whether the seeker's bd address is the same as already connected mobile - uint8_t swapedBtAddr[6]; - big_little_switch(app_gfps_env.seeker_bt_addr.addr, swapedBtAddr, sizeof(swapedBtAddr)); + if (raw_req->rx_tx.key_based_pairing_req.flags_bonding_addr == + RAW_REQ_FLAGS_INTBONDING_SEEKERADDR_BIT1_EN) { + TRACE(0, "try connect to remote BR/EDR addr"); + // TODO: + app_gfps_send_keybase_pairing_via_notification( + (uint8_t *)en_rsp.uint128_array, sizeof(en_rsp)); + } else if (raw_req->rx_tx.key_based_pairing_req + .flags_retroactively_write_account_key) { + // check whether the seeker's bd address is the same as already connected + // mobile + uint8_t swapedBtAddr[6]; + big_little_switch(app_gfps_env.seeker_bt_addr.addr, swapedBtAddr, + sizeof(swapedBtAddr)); - uint8_t isMatchMobileAddr = false; - for (uint32_t devId = 0; devId < btif_me_get_activeCons(); devId++) - { - uint8_t connectedAddr[6]; - app_bt_get_device_bdaddr(devId, connectedAddr); - if (!memcmp(connectedAddr, swapedBtAddr, 6)) - { - isMatchMobileAddr = true; - break; - } - } - - if (isMatchMobileAddr) - { - app_gfps_send_keybase_pairing_via_notification(( uint8_t * )en_rsp.uint128_array, sizeof(en_rsp)); - } - else - { - // reject the write request - return ATT_ERR_WRITE_NOT_PERMITTED; - } - } - else if (raw_req->rx_tx.key_based_pairing_req.flags_bonding_addr == RAW_REQ_FLAGS_INTBONDING_SEEKERADDR_BIT1_DIS) - { - app_gfps_enter_connectable_mode_req_handler((uint8_t *)en_rsp.uint128_array); - } - else - { - app_gfps_send_keybase_pairing_via_notification(( uint8_t * )en_rsp.uint128_array, sizeof(en_rsp)); + uint8_t isMatchMobileAddr = false; + for (uint32_t devId = 0; devId < btif_me_get_activeCons(); devId++) { + uint8_t connectedAddr[6]; + app_bt_get_device_bdaddr(devId, connectedAddr); + if (!memcmp(connectedAddr, swapedBtAddr, 6)) { + isMatchMobileAddr = true; + break; + } } - if (isReturnName) - { - app_gfps_env.isPendingForWritingNameReq = true; - TRACE(0,"get existing name."); - uint8_t response[16+FP_MAX_NAME_LEN]; - uint8_t* ptrRawName; - uint32_t rawNameLen; - ptrRawName = nv_record_fp_get_name_ptr(&rawNameLen); - - gfps_encrypt_name(app_gfps_env.keybase_pair_key, - ptrRawName, - rawNameLen, - &response[16], - response, - &response[8]); - - app_gfps_send_naming_packet_via_notification(response, 16 + rawNameLen); - } - else - { - TRACE(0,"Unusable bit."); + if (isMatchMobileAddr) { + app_gfps_send_keybase_pairing_via_notification( + (uint8_t *)en_rsp.uint128_array, sizeof(en_rsp)); + } else { + // reject the write request + return ATT_ERR_WRITE_NOT_PERMITTED; } + } else if (raw_req->rx_tx.key_based_pairing_req.flags_bonding_addr == + RAW_REQ_FLAGS_INTBONDING_SEEKERADDR_BIT1_DIS) { + app_gfps_enter_connectable_mode_req_handler( + (uint8_t *)en_rsp.uint128_array); + } else { + app_gfps_send_keybase_pairing_via_notification( + (uint8_t *)en_rsp.uint128_array, sizeof(en_rsp)); + } - return GAP_ERR_NO_ERROR; -} - -static void app_gfps_update_local_bt_name(void) -{ - uint8_t* ptrRawName; + if (isReturnName) { + app_gfps_env.isPendingForWritingNameReq = true; + TRACE(0, "get existing name."); + uint8_t response[16 + FP_MAX_NAME_LEN]; + uint8_t *ptrRawName; uint32_t rawNameLen; - // name has been updated to fp nv record ptrRawName = nv_record_fp_get_name_ptr(&rawNameLen); - if(rawNameLen > 0) - { - bt_set_local_dev_name((const unsigned char*)(ptrRawName), - strlen((char *)(ptrRawName)) + 1); - btif_update_bt_name((const unsigned char*)(ptrRawName), - strlen((char *)(ptrRawName)) + 1); - } + + gfps_encrypt_name(app_gfps_env.keybase_pair_key, ptrRawName, rawNameLen, + &response[16], response, &response[8]); + + app_gfps_send_naming_packet_via_notification(response, 16 + rawNameLen); + } else { + TRACE(0, "Unusable bit."); + } + + return GAP_ERR_NO_ERROR; } -static bool app_gfps_decrypt_keybase_pairing_request(uint8_t *pairing_req, uint8_t *output) -{ - uint8_t keyCount = nv_record_fp_account_key_count(); - if (0 == keyCount) - { - return false; - } - - gfpsp_req_resp raw_req; - uint8_t accountKey[FP_ACCOUNT_KEY_SIZE]; - for (uint8_t keyIndex = 0; keyIndex < keyCount; keyIndex++) - { - nv_record_fp_account_key_get_by_index(keyIndex, accountKey); - - AES128_ECB_decrypt(pairing_req, ( const uint8_t * )accountKey, ( uint8_t * )&raw_req); - TRACE(0,"Decrypted keybase pairing req result:"); - DUMP8("0x%02x ", ( uint8_t * )&raw_req, 16); - - if ((memcmp(raw_req.rx_tx.key_based_pairing_req.provider_addr, - app_gfps_env.local_bt_addr.addr , 6)==0) || - (memcmp(raw_req.rx_tx.key_based_pairing_req.provider_addr, - app_gfps_env.local_le_addr.addr , 6)==0)) - { - memcpy(output, accountKey, FP_ACCOUNT_KEY_SIZE); - TRACE(1,"fp message type 0x%02x.", raw_req.rx_tx.raw_req.message_type); - if (KEY_BASED_PAIRING_REQ == raw_req.rx_tx.raw_req.message_type) - { - app_gfps_handle_decrypted_keybase_pairing_request(&raw_req, accountKey); - return true; - } - else if (ACTION_REQUEST == raw_req.rx_tx.raw_req.message_type) - { - memcpy(app_gfps_env.keybase_pair_key, accountKey, 16); - memcpy(&app_gfps_env.seeker_bt_addr.addr[0], - &(raw_req.rx_tx.key_based_pairing_req.seeker_addr[0]), 6); - gfpsp_encrypted_resp en_rsp; - gfpsp_raw_resp raw_rsp; - - raw_rsp.message_type = KEY_BASED_PAIRING_RSP;// Key-based Pairing Response - memcpy(raw_rsp.provider_addr, app_gfps_env.local_bt_addr.addr, 6); - - TRACE(0,"raw_rsp.provider_addr:"); - DUMP8("%02x ",raw_rsp.provider_addr, 6); - - for (uint8_t index = 0;index < 9;index++) - { - raw_rsp.salt[index] = (uint8_t)rand(); - } - - gfps_crypto_encrypt((const uint8_t *)(&raw_rsp.message_type), sizeof(raw_rsp), - app_gfps_env.keybase_pair_key,en_rsp.uint128_array); - - app_gfps_send_keybase_pairing_via_notification((uint8_t *)en_rsp.uint128_array, sizeof(en_rsp)); - - if (raw_req.rx_tx.action_req.isDeviceAction) - { - // TODO: device action via BLE - } - else if (raw_req.rx_tx.action_req.isFollowedByAdditionalDataCh) - { - // write name request will be received - TRACE(0,"FP write name request will be received."); - app_gfps_env.isPendingForWritingNameReq = true; - } - return true; - } - } - - - } +static void app_gfps_update_local_bt_name(void) { + uint8_t *ptrRawName; + uint32_t rawNameLen; + // name has been updated to fp nv record + ptrRawName = nv_record_fp_get_name_ptr(&rawNameLen); + if (rawNameLen > 0) { + bt_set_local_dev_name((const unsigned char *)(ptrRawName), + strlen((char *)(ptrRawName)) + 1); + btif_update_bt_name((const unsigned char *)(ptrRawName), + strlen((char *)(ptrRawName)) + 1); + } +} +static bool app_gfps_decrypt_keybase_pairing_request(uint8_t *pairing_req, + uint8_t *output) { + uint8_t keyCount = nv_record_fp_account_key_count(); + if (0 == keyCount) { return false; -} + } -int app_gfps_write_key_based_pairing_ind_hander(ke_msg_id_t const msgid, - struct gfpsp_write_ind_t const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ + gfpsp_req_resp raw_req; + uint8_t accountKey[FP_ACCOUNT_KEY_SIZE]; + for (uint8_t keyIndex = 0; keyIndex < keyCount; keyIndex++) { + nv_record_fp_account_key_get_by_index(keyIndex, accountKey); - gfpsp_Key_based_Pairing_req en_req; - gfpsp_req_resp *ptr_raw_req; + AES128_ECB_decrypt(pairing_req, (const uint8_t *)accountKey, + (uint8_t *)&raw_req); + TRACE(0, "Decrypted keybase pairing req result:"); + DUMP8("0x%02x ", (uint8_t *)&raw_req, 16); - en_req.en_req = ( gfpsp_encrypted_req_uint128 * )&(param->data[0]); - en_req.pub_key = ( gfpsp_64B_public_key * )&(param->data[16]); - uint8_t out_key[16] = {0}; - uint8_t decryptdata[16] = {0}; - uint8_t write_rsp_status = GAP_ERR_NO_ERROR; + if ((memcmp(raw_req.rx_tx.key_based_pairing_req.provider_addr, + app_gfps_env.local_bt_addr.addr, 6) == 0) || + (memcmp(raw_req.rx_tx.key_based_pairing_req.provider_addr, + app_gfps_env.local_le_addr.addr, 6) == 0)) { + memcpy(output, accountKey, FP_ACCOUNT_KEY_SIZE); + TRACE(1, "fp message type 0x%02x.", raw_req.rx_tx.raw_req.message_type); + if (KEY_BASED_PAIRING_REQ == raw_req.rx_tx.raw_req.message_type) { + app_gfps_handle_decrypted_keybase_pairing_request(&raw_req, accountKey); + return true; + } else if (ACTION_REQUEST == raw_req.rx_tx.raw_req.message_type) { + memcpy(app_gfps_env.keybase_pair_key, accountKey, 16); + memcpy(&app_gfps_env.seeker_bt_addr.addr[0], + &(raw_req.rx_tx.key_based_pairing_req.seeker_addr[0]), 6); + gfpsp_encrypted_resp en_rsp; + gfpsp_raw_resp raw_rsp; - TRACE(3,"length = %d value = 0x%x 0x%x", param->length, param->data[0], param->data[1]); - DUMP8("%02x ", param->data, 80); + raw_rsp.message_type = + KEY_BASED_PAIRING_RSP; // Key-based Pairing Response + memcpy(raw_rsp.provider_addr, app_gfps_env.local_bt_addr.addr, 6); - if (param->length == GFPSP_KEY_BASED_PAIRING_REQ_LEN_WITH_PUBLIC_KEY) - { - memset(app_gfps_env.keybase_pair_key, 0, 6); - uint32_t gfps_state = gfps_crypto_get_secret_decrypt(( const uint8_t * )en_req.en_req, - ( const uint8_t * )en_req.pub_key, - out_key, - decryptdata); - if (gfps_state == GFPS_SUCCESS) - { - memcpy(app_gfps_env.aesKeyFromECDH, out_key, 16); - app_gfps_env.isInitialPairing = true; - ptr_raw_req = (gfpsp_req_resp *)decryptdata; - TRACE(0,"raw req provider's addr:"); - DUMP8("%02x ", ptr_raw_req->rx_tx.key_based_pairing_req.provider_addr, 6); - TRACE(0,"raw req seeker's addr:"); - DUMP8("%02x ", ptr_raw_req->rx_tx.key_based_pairing_req.seeker_addr, 6); - TRACE(1,"fp message type 0x%02x.", ptr_raw_req->rx_tx.raw_req.message_type); - if ((KEY_BASED_PAIRING_REQ == ptr_raw_req->rx_tx.raw_req.message_type) && - ((memcmp(ptr_raw_req->rx_tx.key_based_pairing_req.provider_addr, - app_gfps_env.local_bt_addr.addr , 6)==0) || - (memcmp(ptr_raw_req->rx_tx.key_based_pairing_req.provider_addr, - app_gfps_env.local_le_addr.addr , 6)==0))) - { - write_rsp_status = app_gfps_handle_decrypted_keybase_pairing_request(ptr_raw_req, out_key); - }else{ - TRACE(0,"decrypt false..ingore"); - } + TRACE(0, "raw_rsp.provider_addr:"); + DUMP8("%02x ", raw_rsp.provider_addr, 6); - }else{ - TRACE(1,"error = %x",gfps_state); + for (uint8_t index = 0; index < 9; index++) { + raw_rsp.salt[index] = (uint8_t)rand(); } - } - else if (param->length == GFPSP_KEY_BASED_PAIRING_REQ_LEN_WITHOUT_PUBLIC_KEY) - { + gfps_crypto_encrypt((const uint8_t *)(&raw_rsp.message_type), + sizeof(raw_rsp), app_gfps_env.keybase_pair_key, + en_rsp.uint128_array); - app_gfps_env.isInitialPairing = false; - bool isDecryptedSuccessful = - app_gfps_decrypt_keybase_pairing_request(( uint8_t * )en_req.en_req, out_key); - TRACE(1,"Decrypt keybase pairing req without public key result: %d", isDecryptedSuccessful); + app_gfps_send_keybase_pairing_via_notification( + (uint8_t *)en_rsp.uint128_array, sizeof(en_rsp)); + + if (raw_req.rx_tx.action_req.isDeviceAction) { + // TODO: device action via BLE + } else if (raw_req.rx_tx.action_req.isFollowedByAdditionalDataCh) { + // write name request will be received + TRACE(0, "FP write name request will be received."); + app_gfps_env.isPendingForWritingNameReq = true; + } + return true; + } } - else - { - TRACE(0,"who you are??"); + } + + return false; +} + +int app_gfps_write_key_based_pairing_ind_hander( + ke_msg_id_t const msgid, struct gfpsp_write_ind_t const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + + gfpsp_Key_based_Pairing_req en_req; + gfpsp_req_resp *ptr_raw_req; + + en_req.en_req = (gfpsp_encrypted_req_uint128 *)&(param->data[0]); + en_req.pub_key = (gfpsp_64B_public_key *)&(param->data[16]); + uint8_t out_key[16] = {0}; + uint8_t decryptdata[16] = {0}; + uint8_t write_rsp_status = GAP_ERR_NO_ERROR; + + TRACE(3, "length = %d value = 0x%x 0x%x", param->length, param->data[0], + param->data[1]); + DUMP8("%02x ", param->data, 80); + + if (param->length == GFPSP_KEY_BASED_PAIRING_REQ_LEN_WITH_PUBLIC_KEY) { + memset(app_gfps_env.keybase_pair_key, 0, 6); + uint32_t gfps_state = gfps_crypto_get_secret_decrypt( + (const uint8_t *)en_req.en_req, (const uint8_t *)en_req.pub_key, + out_key, decryptdata); + if (gfps_state == GFPS_SUCCESS) { + memcpy(app_gfps_env.aesKeyFromECDH, out_key, 16); + app_gfps_env.isInitialPairing = true; + ptr_raw_req = (gfpsp_req_resp *)decryptdata; + TRACE(0, "raw req provider's addr:"); + DUMP8("%02x ", ptr_raw_req->rx_tx.key_based_pairing_req.provider_addr, 6); + TRACE(0, "raw req seeker's addr:"); + DUMP8("%02x ", ptr_raw_req->rx_tx.key_based_pairing_req.seeker_addr, 6); + TRACE(1, "fp message type 0x%02x.", + ptr_raw_req->rx_tx.raw_req.message_type); + if ((KEY_BASED_PAIRING_REQ == ptr_raw_req->rx_tx.raw_req.message_type) && + ((memcmp(ptr_raw_req->rx_tx.key_based_pairing_req.provider_addr, + app_gfps_env.local_bt_addr.addr, 6) == 0) || + (memcmp(ptr_raw_req->rx_tx.key_based_pairing_req.provider_addr, + app_gfps_env.local_le_addr.addr, 6) == 0))) { + write_rsp_status = app_gfps_handle_decrypted_keybase_pairing_request( + ptr_raw_req, out_key); + } else { + TRACE(0, "decrypt false..ingore"); + } + + } else { + TRACE(1, "error = %x", gfps_state); } - struct gfpsp_send_write_rsp_t *response = KE_MSG_ALLOC( - GFPSP_SEND_WRITE_RESPONSE, src_id, dest_id, gfpsp_send_write_rsp_t); - *response = param->pendingWriteRsp; - response->status = write_rsp_status; - ke_msg_send(response); + } else if (param->length == + GFPSP_KEY_BASED_PAIRING_REQ_LEN_WITHOUT_PUBLIC_KEY) { - return (KE_MSG_CONSUMED); + app_gfps_env.isInitialPairing = false; + bool isDecryptedSuccessful = app_gfps_decrypt_keybase_pairing_request( + (uint8_t *)en_req.en_req, out_key); + TRACE(1, "Decrypt keybase pairing req without public key result: %d", + isDecryptedSuccessful); + } else { + TRACE(0, "who you are??"); + } + + struct gfpsp_send_write_rsp_t *response = KE_MSG_ALLOC( + GFPSP_SEND_WRITE_RESPONSE, src_id, dest_id, gfpsp_send_write_rsp_t); + *response = param->pendingWriteRsp; + response->status = write_rsp_status; + ke_msg_send(response); + + return (KE_MSG_CONSUMED); } int app_gfps_write_passkey_ind_hander(ke_msg_id_t const msgid, struct gfpsp_write_ind_t const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - gfpsp_raw_pass_key_resp raw_rsp; - gfpsp_encrypted_resp en_rsp; - uint8_t decryptdata[16] = {0}; - TRACE(1,"length = %d value = 0x", param->length); - DUMP8("%02X, ", param->data, 16); - gfps_crypto_decrypt(param->data, 16, app_gfps_env.keybase_pair_key, decryptdata); - TRACE(0,"decrypt data =0x"); - TRACE(0,"==============================="); - DUMP8("%02X", decryptdata, 16); - TRACE(0,"==============================="); + ke_task_id_t const src_id) { + gfpsp_raw_pass_key_resp raw_rsp; + gfpsp_encrypted_resp en_rsp; + uint8_t decryptdata[16] = {0}; + TRACE(1, "length = %d value = 0x", param->length); + DUMP8("%02X, ", param->data, 16); + gfps_crypto_decrypt(param->data, 16, app_gfps_env.keybase_pair_key, + decryptdata); + TRACE(0, "decrypt data =0x"); + TRACE(0, "==============================="); + DUMP8("%02X", decryptdata, 16); + TRACE(0, "==============================="); - TRACE(0,"pass key = 1-3 bytes"); + TRACE(0, "pass key = 1-3 bytes"); - raw_rsp.message_type = 0x03; //Provider's passkey - raw_rsp.passkey[0] = decryptdata[1]; - raw_rsp.passkey[1] = decryptdata[2]; - raw_rsp.passkey[2] = decryptdata[3]; - raw_rsp.reserved[0] = 0x38; //my magic num temp test - raw_rsp.reserved[1] = 0x30; - raw_rsp.reserved[2] = 0x23; - raw_rsp.reserved[3] = 0x30; - raw_rsp.reserved[4] = 0x06; - raw_rsp.reserved[5] = 0x10; - raw_rsp.reserved[6] = 0x05; - raw_rsp.reserved[7] = 0x13; - raw_rsp.reserved[8] = 0x06; - raw_rsp.reserved[9] = 0x12; - raw_rsp.reserved[10] = 0x12; - raw_rsp.reserved[11] = 0x01; - gfps_crypto_encrypt(( const uint8_t * )(&raw_rsp.message_type), sizeof(raw_rsp), app_gfps_env.keybase_pair_key, en_rsp.uint128_array); - app_gfps_send_passkey_via_notification(( uint8_t * )en_rsp.uint128_array, sizeof(en_rsp)); + raw_rsp.message_type = 0x03; // Provider's passkey + raw_rsp.passkey[0] = decryptdata[1]; + raw_rsp.passkey[1] = decryptdata[2]; + raw_rsp.passkey[2] = decryptdata[3]; + raw_rsp.reserved[0] = 0x38; // my magic num temp test + raw_rsp.reserved[1] = 0x30; + raw_rsp.reserved[2] = 0x23; + raw_rsp.reserved[3] = 0x30; + raw_rsp.reserved[4] = 0x06; + raw_rsp.reserved[5] = 0x10; + raw_rsp.reserved[6] = 0x05; + raw_rsp.reserved[7] = 0x13; + raw_rsp.reserved[8] = 0x06; + raw_rsp.reserved[9] = 0x12; + raw_rsp.reserved[10] = 0x12; + raw_rsp.reserved[11] = 0x01; + gfps_crypto_encrypt((const uint8_t *)(&raw_rsp.message_type), sizeof(raw_rsp), + app_gfps_env.keybase_pair_key, en_rsp.uint128_array); + app_gfps_send_passkey_via_notification((uint8_t *)en_rsp.uint128_array, + sizeof(en_rsp)); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } static int app_gfps_write_name_ind_hander(ke_msg_id_t const msgid, struct gfpsp_write_ind_t const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - bool isSuccessful = false; - - if (!app_gfps_env.isPendingForWritingNameReq) - { - TRACE(0,"Pre fp write name request is not received."); - } - else - { - uint8_t rawName[FP_MAX_NAME_LEN]; - - struct gfpsp_write_ind_t* pWriteInd = (struct gfpsp_write_ind_t *)param; - if (app_gfps_env.isInitialPairing) - { - isSuccessful = gfps_decrypt_name(app_gfps_env.aesKeyFromECDH, - pWriteInd->data, &(pWriteInd->data[8]), &(pWriteInd->data[16]), - rawName, pWriteInd->length-16); - } - else - { - isSuccessful = gfps_decrypt_name(app_gfps_env.keybase_pair_key, - pWriteInd->data, &(pWriteInd->data[8]), &(pWriteInd->data[16]), - rawName, pWriteInd->length-16); - } + ke_task_id_t const src_id) { + bool isSuccessful = false; - TRACE(1,"write name successful flag %d", isSuccessful); + if (!app_gfps_env.isPendingForWritingNameReq) { + TRACE(0, "Pre fp write name request is not received."); + } else { + uint8_t rawName[FP_MAX_NAME_LEN]; - if (isSuccessful) - { - nv_record_fp_update_name(rawName, pWriteInd->length-16); - TRACE(1,"Rename BT name: [%s]", rawName); - app_gfps_update_local_bt_name(); - #ifdef IBRT - app_tws_send_fastpair_info_to_slave(); - #endif - } + struct gfpsp_write_ind_t *pWriteInd = (struct gfpsp_write_ind_t *)param; + if (app_gfps_env.isInitialPairing) { + isSuccessful = gfps_decrypt_name( + app_gfps_env.aesKeyFromECDH, pWriteInd->data, &(pWriteInd->data[8]), + &(pWriteInd->data[16]), rawName, pWriteInd->length - 16); + } else { + isSuccessful = gfps_decrypt_name( + app_gfps_env.keybase_pair_key, pWriteInd->data, &(pWriteInd->data[8]), + &(pWriteInd->data[16]), rawName, pWriteInd->length - 16); + } - app_gfps_env.isPendingForWritingNameReq = false; + TRACE(1, "write name successful flag %d", isSuccessful); + + if (isSuccessful) { + nv_record_fp_update_name(rawName, pWriteInd->length - 16); + TRACE(1, "Rename BT name: [%s]", rawName); + app_gfps_update_local_bt_name(); +#ifdef IBRT + app_tws_send_fastpair_info_to_slave(); +#endif } - - struct gfpsp_send_write_rsp_t *response = KE_MSG_ALLOC( - GFPSP_SEND_WRITE_RESPONSE, src_id, dest_id, gfpsp_send_write_rsp_t); - *response = param->pendingWriteRsp; - if (isSuccessful) - { - response->status = ATT_ERR_NO_ERROR; - } - else - { - response->status = ATT_ERR_WRITE_NOT_PERMITTED; - } - ke_msg_send(response); - - return (KE_MSG_CONSUMED); + + app_gfps_env.isPendingForWritingNameReq = false; + } + + struct gfpsp_send_write_rsp_t *response = KE_MSG_ALLOC( + GFPSP_SEND_WRITE_RESPONSE, src_id, dest_id, gfpsp_send_write_rsp_t); + *response = param->pendingWriteRsp; + if (isSuccessful) { + response->status = ATT_ERR_NO_ERROR; + } else { + response->status = ATT_ERR_WRITE_NOT_PERMITTED; + } + ke_msg_send(response); + + return (KE_MSG_CONSUMED); } -static int app_gfps_write_accountkey_ind_hander(ke_msg_id_t const msgid, - struct gfpsp_write_ind_t const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - NV_FP_ACCOUNT_KEY_ENTRY_T accountkey; +static int app_gfps_write_accountkey_ind_hander( + ke_msg_id_t const msgid, struct gfpsp_write_ind_t const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + NV_FP_ACCOUNT_KEY_ENTRY_T accountkey; - TRACE(1,"length = %d value = 0x", param->length); - DUMP8("%02X, ", param->data, FP_ACCOUNT_KEY_SIZE); - gfps_crypto_decrypt(param->data, FP_ACCOUNT_KEY_SIZE, app_gfps_env.keybase_pair_key, accountkey.key); - TRACE(0,"decrypt account key:"); - //TRACE(0,"==============================="); - DUMP8("%02X", accountkey.key, FP_ACCOUNT_KEY_SIZE); - //TRACE(0,"==============================="); + TRACE(1, "length = %d value = 0x", param->length); + DUMP8("%02X, ", param->data, FP_ACCOUNT_KEY_SIZE); + gfps_crypto_decrypt(param->data, FP_ACCOUNT_KEY_SIZE, + app_gfps_env.keybase_pair_key, accountkey.key); + TRACE(0, "decrypt account key:"); + // TRACE(0,"==============================="); + DUMP8("%02X", accountkey.key, FP_ACCOUNT_KEY_SIZE); + // TRACE(0,"==============================="); - nv_record_fp_account_key_add(&accountkey); + nv_record_fp_account_key_add(&accountkey); #ifdef IBRT - app_tws_send_fastpair_info_to_slave(); + app_tws_send_fastpair_info_to_slave(); #endif - // update the BLE ADV as account key has been added - if (!app_is_in_fastpairing_mode()) - { - // restart the BLE adv if it's retro-active pairing - app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); - } - return (KE_MSG_CONSUMED); -} - -void app_gfps_set_battery_datatype(GFPS_BATTERY_DATA_TYPE_E batteryDataType) -{ - if (app_gfps_env.batteryDataType != batteryDataType) - { - app_gfps_env.batteryDataType = batteryDataType; - app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); - } -} - -GFPS_BATTERY_DATA_TYPE_E app_gfps_get_battery_datatype(void) -{ - return app_gfps_env.batteryDataType; -} - -void app_gfps_enable_battery_info(bool isEnable) -{ - app_gfps_env.isBatteryInfoIncluded = isEnable; + // update the BLE ADV as account key has been added + if (!app_is_in_fastpairing_mode()) { + // restart the BLE adv if it's retro-active pairing app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); + } + return (KE_MSG_CONSUMED); } -void app_gfps_get_battery_levels(uint8_t *pCount, uint8_t *pBatteryLevel) -{ - *pCount = 0; - if (app_gfps_env.get_battery_info_handler) - { - app_gfps_env.get_battery_info_handler( - pCount, pBatteryLevel); - } +void app_gfps_set_battery_datatype(GFPS_BATTERY_DATA_TYPE_E batteryDataType) { + if (app_gfps_env.batteryDataType != batteryDataType) { + app_gfps_env.batteryDataType = batteryDataType; + app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); + } } -void app_gfps_update_random_salt(void) -{ - app_gfps_env.advRandSalt = (uint8_t)rand(); +GFPS_BATTERY_DATA_TYPE_E app_gfps_get_battery_datatype(void) { + return app_gfps_env.batteryDataType; } -uint8_t app_gfps_generate_accountkey_data(uint8_t *outputData) -{ - uint8_t keyCount = nv_record_fp_account_key_count(); - if (0 == keyCount) - { - outputData[0] = 0; - outputData[1] = 0; - return 2; - } +void app_gfps_enable_battery_info(bool isEnable) { + app_gfps_env.isBatteryInfoIncluded = isEnable; + app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); +} - uint8_t accountKeyData[32]; - accountKeyData[0] = 0; +void app_gfps_get_battery_levels(uint8_t *pCount, uint8_t *pBatteryLevel) { + *pCount = 0; + if (app_gfps_env.get_battery_info_handler) { + app_gfps_env.get_battery_info_handler(pCount, pBatteryLevel); + } +} - uint8_t accountKeyDataLen = 2; - uint8_t hash256Result[32]; +void app_gfps_update_random_salt(void) { + app_gfps_env.advRandSalt = (uint8_t)rand(); +} - uint8_t sizeOfFilter = (((uint8_t)(( float )1.2 * keyCount)) + 3); - uint8_t FArray[2 * FP_ACCOUNT_KEY_RECORD_NUM + 3]; - memset(FArray, 0, sizeof(FArray)); +uint8_t app_gfps_generate_accountkey_data(uint8_t *outputData) { + uint8_t keyCount = nv_record_fp_account_key_count(); + if (0 == keyCount) { + outputData[0] = 0; + outputData[1] = 0; + return 2; + } + + uint8_t accountKeyData[32]; + accountKeyData[0] = 0; + + uint8_t accountKeyDataLen = 2; + uint8_t hash256Result[32]; + + uint8_t sizeOfFilter = (((uint8_t)((float)1.2 * keyCount)) + 3); + uint8_t FArray[2 * FP_ACCOUNT_KEY_RECORD_NUM + 3]; + memset(FArray, 0, sizeof(FArray)); #if GFPS_ACCOUNTKEY_SALT_TYPE == USE_BLE_ADDR_AS_SALT - uint8_t VArray[FP_ACCOUNT_KEY_SIZE + 6 + 4]; + uint8_t VArray[FP_ACCOUNT_KEY_SIZE + 6 + 4]; #else - uint8_t VArray[FP_ACCOUNT_KEY_SIZE + 1 + 4]; - uint8_t randomSalt; - if (GFPS_INITIAL_ADV_RAND_SALT != app_gfps_env.advRandSalt) - { - randomSalt = app_gfps_env.advRandSalt; - } - else - { - randomSalt = (uint8_t)rand(); - } + uint8_t VArray[FP_ACCOUNT_KEY_SIZE + 1 + 4]; + uint8_t randomSalt; + if (GFPS_INITIAL_ADV_RAND_SALT != app_gfps_env.advRandSalt) { + randomSalt = app_gfps_env.advRandSalt; + } else { + randomSalt = (uint8_t)rand(); + } #endif - uint8_t index; + uint8_t index; - uint8_t batteryFollowingData[1 + GFPS_BATTERY_VALUE_MAX_COUNT]; - uint8_t batteryFollowingDataLen = 0; + uint8_t batteryFollowingData[1 + GFPS_BATTERY_VALUE_MAX_COUNT]; + uint8_t batteryFollowingDataLen = 0; - for (uint8_t keyIndex = 0; keyIndex < keyCount; keyIndex++) - { - uint8_t offsetOfVArray; + for (uint8_t keyIndex = 0; keyIndex < keyCount; keyIndex++) { + uint8_t offsetOfVArray; - nv_record_fp_account_key_get_by_index(keyIndex, VArray); + nv_record_fp_account_key_get_by_index(keyIndex, VArray); #if GFPS_ACCOUNTKEY_SALT_TYPE == USE_BLE_ADDR_AS_SALT - uint8_t *currentBleAddr = appm_get_current_ble_addr(); - for (index = 0; index < 6; index++) - { - VArray[FP_ACCOUNT_KEY_SIZE + index] = currentBleAddr[5 - index]; - } - offsetOfVArray = FP_ACCOUNT_KEY_SIZE + 6; + uint8_t *currentBleAddr = appm_get_current_ble_addr(); + for (index = 0; index < 6; index++) { + VArray[FP_ACCOUNT_KEY_SIZE + index] = currentBleAddr[5 - index]; + } + offsetOfVArray = FP_ACCOUNT_KEY_SIZE + 6; #else - VArray[FP_ACCOUNT_KEY_SIZE] = randomSalt; - offsetOfVArray = FP_ACCOUNT_KEY_SIZE + 1; + VArray[FP_ACCOUNT_KEY_SIZE] = randomSalt; + offsetOfVArray = FP_ACCOUNT_KEY_SIZE + 1; #endif - if (app_gfps_env.isBatteryInfoIncluded) - { - uint8_t batteryLevelCount = 0; - uint8_t batteryLevel[GFPS_BATTERY_VALUE_MAX_COUNT]; - app_gfps_get_battery_levels(&batteryLevelCount, batteryLevel); + if (app_gfps_env.isBatteryInfoIncluded) { + uint8_t batteryLevelCount = 0; + uint8_t batteryLevel[GFPS_BATTERY_VALUE_MAX_COUNT]; + app_gfps_get_battery_levels(&batteryLevelCount, batteryLevel); - uint8_t startOffsetOfBatteryInfo = offsetOfVArray; + uint8_t startOffsetOfBatteryInfo = offsetOfVArray; - VArray[offsetOfVArray++] = app_gfps_env.batteryDataType | (batteryLevelCount << 4); - for (index = 0; index < batteryLevelCount; index++) - { - VArray[offsetOfVArray++] = batteryLevel[index]; - } + VArray[offsetOfVArray++] = + app_gfps_env.batteryDataType | (batteryLevelCount << 4); + for (index = 0; index < batteryLevelCount; index++) { + VArray[offsetOfVArray++] = batteryLevel[index]; + } - batteryFollowingDataLen = offsetOfVArray - startOffsetOfBatteryInfo; - memcpy(batteryFollowingData, &VArray[startOffsetOfBatteryInfo], batteryFollowingDataLen); - } - - TRACE(0,"To hash256 on:"); - DUMP8("%02x ", VArray, offsetOfVArray); - - gfps_SHA256_hash(VArray, offsetOfVArray, hash256Result); - - // K = Xi % (s * 8) - // F[K/8] = F[K/8] | (1 << (K % 8)) - uint32_t pX[8]; - for (index = 0; index < 8; index++) - { - pX[index] = (((uint32_t)(hash256Result[index * 4])) << 24) | - (((uint32_t)(hash256Result[index * 4 + 1])) << 16) | - (((uint32_t)(hash256Result[index * 4 + 2])) << 8) | - (((uint32_t)(hash256Result[index * 4 + 3])) << 0); - } - - for (index = 0; index < 8; index++) - { - uint32_t K = pX[index] % (sizeOfFilter * 8); - FArray[K / 8] = FArray[K / 8] | (1 << (K % 8)); - } + batteryFollowingDataLen = offsetOfVArray - startOffsetOfBatteryInfo; + memcpy(batteryFollowingData, &VArray[startOffsetOfBatteryInfo], + batteryFollowingDataLen); } - memcpy(&accountKeyData[2], FArray, sizeOfFilter); + TRACE(0, "To hash256 on:"); + DUMP8("%02x ", VArray, offsetOfVArray); - accountKeyDataLen += sizeOfFilter; + gfps_SHA256_hash(VArray, offsetOfVArray, hash256Result); - accountKeyData[1] = (sizeOfFilter<<4); + // K = Xi % (s * 8) + // F[K/8] = F[K/8] | (1 << (K % 8)) + uint32_t pX[8]; + for (index = 0; index < 8; index++) { + pX[index] = (((uint32_t)(hash256Result[index * 4])) << 24) | + (((uint32_t)(hash256Result[index * 4 + 1])) << 16) | + (((uint32_t)(hash256Result[index * 4 + 2])) << 8) | + (((uint32_t)(hash256Result[index * 4 + 3])) << 0); + } + for (index = 0; index < 8; index++) { + uint32_t K = pX[index] % (sizeOfFilter * 8); + FArray[K / 8] = FArray[K / 8] | (1 << (K % 8)); + } + } -#if GFPS_ACCOUNTKEY_SALT_TYPE==USE_RANDOM_NUM_AS_SALT - accountKeyData[2+sizeOfFilter] = 0x11; - accountKeyData[2 + sizeOfFilter + 1] = randomSalt; + memcpy(&accountKeyData[2], FArray, sizeOfFilter); - accountKeyDataLen += 2; + accountKeyDataLen += sizeOfFilter; + + accountKeyData[1] = (sizeOfFilter << 4); + +#if GFPS_ACCOUNTKEY_SALT_TYPE == USE_RANDOM_NUM_AS_SALT + accountKeyData[2 + sizeOfFilter] = 0x11; + accountKeyData[2 + sizeOfFilter + 1] = randomSalt; + + accountKeyDataLen += 2; #endif - TRACE(1,"Generated accountkey data len:%d", accountKeyDataLen); - DUMP8("%02x ", accountKeyData, accountKeyDataLen); + TRACE(1, "Generated accountkey data len:%d", accountKeyDataLen); + DUMP8("%02x ", accountKeyData, accountKeyDataLen); - memcpy(outputData, accountKeyData, accountKeyDataLen); + memcpy(outputData, accountKeyData, accountKeyDataLen); - memcpy(outputData + accountKeyDataLen, batteryFollowingData, batteryFollowingDataLen); + memcpy(outputData + accountKeyDataLen, batteryFollowingData, + batteryFollowingDataLen); - return (accountKeyDataLen + batteryFollowingDataLen); + return (accountKeyDataLen + batteryFollowingDataLen); } -static void gfpsp_update_connection_state(uint8_t conidx) -{ - if (BLE_INVALID_CONNECTION_INDEX == app_gfps_env.connectionIndex) - { - app_gfps_connected_evt_handler(conidx); - } +static void gfpsp_update_connection_state(uint8_t conidx) { + if (BLE_INVALID_CONNECTION_INDEX == app_gfps_env.connectionIndex) { + app_gfps_connected_evt_handler(conidx); + } } -static int app_gfpsp_key_based_pairing_ntf_handler(ke_msg_id_t const msgid, - struct app_gfps_key_based_notif_config_t *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - app_gfps_env.isKeyBasedPairingNotificationEnabled = param->isNotificationEnabled; - if (app_gfps_env.isKeyBasedPairingNotificationEnabled) - { - uint8_t conidx = KE_IDX_GET(src_id); - gfpsp_update_connection_state(conidx); - } +static int app_gfpsp_key_based_pairing_ntf_handler( + ke_msg_id_t const msgid, struct app_gfps_key_based_notif_config_t *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + app_gfps_env.isKeyBasedPairingNotificationEnabled = + param->isNotificationEnabled; + if (app_gfps_env.isKeyBasedPairingNotificationEnabled) { + uint8_t conidx = KE_IDX_GET(src_id); + gfpsp_update_connection_state(conidx); + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } -static int app_gfpsp_pass_key_ntf_handler(ke_msg_id_t const msgid, - struct app_gfps_pass_key_notif_config_t *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - app_gfps_env.isPassKeyNotificationEnabled = param->isNotificationEnabled; - if (app_gfps_env.isPassKeyNotificationEnabled) - { - uint8_t conidx = KE_IDX_GET(src_id); - gfpsp_update_connection_state(conidx); - } +static int app_gfpsp_pass_key_ntf_handler( + ke_msg_id_t const msgid, struct app_gfps_pass_key_notif_config_t *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + app_gfps_env.isPassKeyNotificationEnabled = param->isNotificationEnabled; + if (app_gfps_env.isPassKeyNotificationEnabled) { + uint8_t conidx = KE_IDX_GET(src_id); + gfpsp_update_connection_state(conidx); + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /* @@ -1059,15 +960,18 @@ static int app_gfpsp_pass_key_ntf_handler(ke_msg_id_t const msgid, */ /// Default State handlers definition -const struct ke_msg_handler app_gfps_msg_handler_list[] = - { - {GFPSP_VALUE_REQ_IND, ( ke_msg_func_t )gfpsp_value_req_ind_handler}, - {GFPSP_KEY_BASED_PAIRING_WRITE_IND, ( ke_msg_func_t )app_gfps_write_key_based_pairing_ind_hander}, - {GFPSP_KEY_PASS_KEY_WRITE_IND, ( ke_msg_func_t )app_gfps_write_passkey_ind_hander}, - {GFPSP_KEY_ACCOUNT_KEY_WRITE_IND, ( ke_msg_func_t )app_gfps_write_accountkey_ind_hander}, - {GFPSP_KEY_BASED_PAIRING_NTF_CFG, ( ke_msg_func_t )app_gfpsp_key_based_pairing_ntf_handler}, - {GFPSP_KEY_PASS_KEY_NTF_CFG, ( ke_msg_func_t )app_gfpsp_pass_key_ntf_handler}, - {GFPSP_NAME_WRITE_IND, ( ke_msg_func_t )app_gfps_write_name_ind_hander}, +const struct ke_msg_handler app_gfps_msg_handler_list[] = { + {GFPSP_VALUE_REQ_IND, (ke_msg_func_t)gfpsp_value_req_ind_handler}, + {GFPSP_KEY_BASED_PAIRING_WRITE_IND, + (ke_msg_func_t)app_gfps_write_key_based_pairing_ind_hander}, + {GFPSP_KEY_PASS_KEY_WRITE_IND, + (ke_msg_func_t)app_gfps_write_passkey_ind_hander}, + {GFPSP_KEY_ACCOUNT_KEY_WRITE_IND, + (ke_msg_func_t)app_gfps_write_accountkey_ind_hander}, + {GFPSP_KEY_BASED_PAIRING_NTF_CFG, + (ke_msg_func_t)app_gfpsp_key_based_pairing_ntf_handler}, + {GFPSP_KEY_PASS_KEY_NTF_CFG, (ke_msg_func_t)app_gfpsp_pass_key_ntf_handler}, + {GFPSP_NAME_WRITE_IND, (ke_msg_func_t)app_gfps_write_name_ind_hander}, }; @@ -1078,44 +982,34 @@ const struct ke_state_handler app_gfps_table_handler = { static uint8_t is_in_fastpairing_mode = false; -bool app_is_in_fastpairing_mode(void) -{ - return is_in_fastpairing_mode; +bool app_is_in_fastpairing_mode(void) { return is_in_fastpairing_mode; } + +void app_set_in_fastpairing_mode_flag(bool isEnabled) { + is_in_fastpairing_mode = isEnabled; + TRACE(1, "[FP]mode is set to %d", is_in_fastpairing_mode); } -void app_set_in_fastpairing_mode_flag(bool isEnabled) -{ - is_in_fastpairing_mode = isEnabled; - TRACE(1,"[FP]mode is set to %d", is_in_fastpairing_mode); +void app_exit_fastpairing_mode(void) { + + if (app_is_in_fastpairing_mode()) { + TRACE(0, "[FP]exit fast pair mode"); + app_stop_10_second_timer(APP_FASTPAIR_LASTING_TIMER_ID); + + app_set_in_fastpairing_mode_flag(false); + + // reset ble adv + app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); + } } -void app_exit_fastpairing_mode(void) -{ +void app_fast_pairing_timeout_timehandler(void) { app_exit_fastpairing_mode(); } - if (app_is_in_fastpairing_mode()) - { - TRACE(0,"[FP]exit fast pair mode"); - app_stop_10_second_timer(APP_FASTPAIR_LASTING_TIMER_ID); +void app_enter_fastpairing_mode(void) { + TRACE(0, "[FP] enter fast pair mode"); + app_set_in_fastpairing_mode_flag(true); - app_set_in_fastpairing_mode_flag(false); - - // reset ble adv - app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); - } -} - -void app_fast_pairing_timeout_timehandler(void) -{ - app_exit_fastpairing_mode(); -} - -void app_enter_fastpairing_mode(void) -{ - TRACE(0,"[FP] enter fast pair mode"); - app_set_in_fastpairing_mode_flag(true); - - app_ble_start_connectable_adv(BLE_FAST_ADVERTISING_INTERVAL); - app_start_10_second_timer(APP_FASTPAIR_LASTING_TIMER_ID); + app_ble_start_connectable_adv(BLE_FAST_ADVERTISING_INTERVAL); + app_start_10_second_timer(APP_FASTPAIR_LASTING_TIMER_ID); } /*--------------------------------------------------------------------------- @@ -1131,178 +1025,157 @@ void app_enter_fastpairing_mode(void) * Return: * void */ -static void gfps_ble_data_fill_handler(void *param) -{ - TRACE(1,"[%s]+++", __func__); - ASSERT(param, "invalid param"); +static void gfps_ble_data_fill_handler(void *param) { + TRACE(1, "[%s]+++", __func__); + ASSERT(param, "invalid param"); - bool adv_enable = false; - BLE_ADV_PARAM_T *advInfo = ( BLE_ADV_PARAM_T * )param; - TRACE(2,"adv data offset:%d, scan response data offset:%d", - advInfo->advDataLen, - advInfo->scanRspDataLen); + bool adv_enable = false; + BLE_ADV_PARAM_T *advInfo = (BLE_ADV_PARAM_T *)param; + TRACE(2, "adv data offset:%d, scan response data offset:%d", + advInfo->advDataLen, advInfo->scanRspDataLen); #ifdef IBRT - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - TRACE(1,"current role:%s", app_tws_ibrt_role2str(p_ibrt_ctrl->current_role)); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + TRACE(1, "current role:%s", app_tws_ibrt_role2str(p_ibrt_ctrl->current_role)); - if (IBRT_SLAVE != p_ibrt_ctrl->current_role && p_ibrt_ctrl->init_done) + if (IBRT_SLAVE != p_ibrt_ctrl->current_role && p_ibrt_ctrl->init_done) #endif - { - TRACE(0,"GFPS data will add in adv data"); + { + TRACE(0, "GFPS data will add in adv data"); - adv_enable = true; - if (app_is_in_fastpairing_mode()) - { - TRACE(0,"fast pair mode"); - advInfo->advInterval = BLE_FASTPAIR_FAST_ADVERTISING_INTERVAL; + adv_enable = true; + if (app_is_in_fastpairing_mode()) { + TRACE(0, "fast pair mode"); + advInfo->advInterval = BLE_FASTPAIR_FAST_ADVERTISING_INTERVAL; - advInfo->advData[advInfo->advDataLen++] = FP_SERVICE_LEN; - advInfo->advData[advInfo->advDataLen++] = BLE_ADV_SVC_FLAG; - advInfo->advData[advInfo->advDataLen++] = (FP_SERVICE_UUID >> 8) & 0xFF; - advInfo->advData[advInfo->advDataLen++] = (FP_SERVICE_UUID >> 0) & 0xFF; - uint32_t modelId; + advInfo->advData[advInfo->advDataLen++] = FP_SERVICE_LEN; + advInfo->advData[advInfo->advDataLen++] = BLE_ADV_SVC_FLAG; + advInfo->advData[advInfo->advDataLen++] = (FP_SERVICE_UUID >> 8) & 0xFF; + advInfo->advData[advInfo->advDataLen++] = (FP_SERVICE_UUID >> 0) & 0xFF; + uint32_t modelId; #ifndef IS_USE_CUSTOM_FP_INFO - modelId = FP_DEVICE_MODEL_ID; + modelId = FP_DEVICE_MODEL_ID; #else - modelId = app_bt_get_model_id(); + modelId = app_bt_get_model_id(); #endif - advInfo->advData[advInfo->advDataLen++] = (modelId >> 16) & 0xFF; - advInfo->advData[advInfo->advDataLen++] = (modelId >> 8) & 0xFF; - advInfo->advData[advInfo->advDataLen++] = (modelId >> 0) & 0xFF; + advInfo->advData[advInfo->advDataLen++] = (modelId >> 16) & 0xFF; + advInfo->advData[advInfo->advDataLen++] = (modelId >> 8) & 0xFF; + advInfo->advData[advInfo->advDataLen++] = (modelId >> 0) & 0xFF; #ifndef IS_USE_CUSTOM_FP_INFO - memcpy(&advInfo->advData[advInfo->advDataLen], - APP_GFPS_ADV_POWER_UUID, - APP_GFPS_ADV_POWER_UUID_LEN); + memcpy(&advInfo->advData[advInfo->advDataLen], APP_GFPS_ADV_POWER_UUID, + APP_GFPS_ADV_POWER_UUID_LEN); #else - memcpy(&advInfo->advData[advInfo->advDataLen], - app_gfps_power_uuid, - APP_GFPS_ADV_POWER_UUID_LEN); + memcpy(&advInfo->advData[advInfo->advDataLen], app_gfps_power_uuid, + APP_GFPS_ADV_POWER_UUID_LEN); #endif - advInfo->advDataLen += APP_GFPS_ADV_POWER_UUID_LEN; - } - else - { - TRACE(0,"not in fast pair mode"); - advInfo->advInterval = BLE_FASTPAIR_NORMAL_ADVERTISING_INTERVAL; + advInfo->advDataLen += APP_GFPS_ADV_POWER_UUID_LEN; + } else { + TRACE(0, "not in fast pair mode"); + advInfo->advInterval = BLE_FASTPAIR_NORMAL_ADVERTISING_INTERVAL; #if BLE_APP_GFPS_VER == FAST_PAIR_REV_2_0 - uint8_t serviceData[32]; + uint8_t serviceData[32]; - // service UUID part - serviceData[0] = 0x03; // original length of service length - serviceData[1] = BLE_ADV_SVC_FLAG; - serviceData[2] = (FP_SERVICE_UUID >> 8) & 0xFF;; - serviceData[3] = (FP_SERVICE_UUID >> 0) & 0xFF; + // service UUID part + serviceData[0] = 0x03; // original length of service length + serviceData[1] = BLE_ADV_SVC_FLAG; + serviceData[2] = (FP_SERVICE_UUID >> 8) & 0xFF; + ; + serviceData[3] = (FP_SERVICE_UUID >> 0) & 0xFF; - // account key part - uint8_t dataLen = app_gfps_generate_accountkey_data(&serviceData[4]); - serviceData[0] += dataLen; - memcpy(&advInfo->advData[advInfo->advDataLen], - serviceData, - serviceData[0] + 1); - advInfo->advDataLen += (serviceData[0] + 1); + // account key part + uint8_t dataLen = app_gfps_generate_accountkey_data(&serviceData[4]); + serviceData[0] += dataLen; + memcpy(&advInfo->advData[advInfo->advDataLen], serviceData, + serviceData[0] + 1); + advInfo->advDataLen += (serviceData[0] + 1); - // power part - memcpy(&advInfo->advData[advInfo->advDataLen], - APP_GFPS_ADV_POWER_UUID, - APP_GFPS_ADV_POWER_UUID_LEN); - advInfo->advDataLen += APP_GFPS_ADV_POWER_UUID_LEN; + // power part + memcpy(&advInfo->advData[advInfo->advDataLen], APP_GFPS_ADV_POWER_UUID, + APP_GFPS_ADV_POWER_UUID_LEN); + advInfo->advDataLen += APP_GFPS_ADV_POWER_UUID_LEN; #endif - } } + } - app_ble_data_fill_enable(USER_GFPS, adv_enable); - TRACE(1,"[%s]---", __func__); + app_ble_data_fill_enable(USER_GFPS, adv_enable); + TRACE(1, "[%s]---", __func__); } -void gfps_info_prepare_handler(uint8_t *buf, uint16_t *length) -{ - *length = sizeof(NV_FP_ACCOUNT_KEY_RECORD_T); +void gfps_info_prepare_handler(uint8_t *buf, uint16_t *length) { + *length = sizeof(NV_FP_ACCOUNT_KEY_RECORD_T); - NV_FP_ACCOUNT_KEY_RECORD_T *info = nv_record_get_fp_data_structure_info(); - memcpy(buf, info, *length); + NV_FP_ACCOUNT_KEY_RECORD_T *info = nv_record_get_fp_data_structure_info(); + memcpy(buf, info, *length); } -void gfps_info_received_handler(uint8_t *buf, uint16_t length) -{ - NV_FP_ACCOUNT_KEY_RECORD_T *pInfo = ( NV_FP_ACCOUNT_KEY_RECORD_T * )buf; - nv_record_fp_update_all(( uint8_t * )pInfo); +void gfps_info_received_handler(uint8_t *buf, uint16_t length) { + NV_FP_ACCOUNT_KEY_RECORD_T *pInfo = (NV_FP_ACCOUNT_KEY_RECORD_T *)buf; + nv_record_fp_update_all((uint8_t *)pInfo); } -void app_gfps_tws_sync_init(void) -{ +void app_gfps_tws_sync_init(void) { #ifdef IBRT - // TODO: freddie move to isolated ota file - TWS_SYNC_USER_T userGfps = { - gfps_info_prepare_handler, - gfps_info_received_handler, - NULL, - NULL, - NULL, - }; + // TODO: freddie move to isolated ota file + TWS_SYNC_USER_T userGfps = { + gfps_info_prepare_handler, gfps_info_received_handler, NULL, NULL, NULL, + }; - app_tws_if_register_sync_user(TWS_SYNC_USER_GFPS_INFO, &userGfps); -#endif + app_tws_if_register_sync_user(TWS_SYNC_USER_GFPS_INFO, &userGfps); +#endif } static FastPairInfo g_fast_pair_info; -uint32_t app_bt_get_model_id(void) -{ - return g_fast_pair_info.model_id; -} +uint32_t app_bt_get_model_id(void) { return g_fast_pair_info.model_id; } extern uint32_t Get_ModelId(); -void app_bt_get_fast_pair_info(void) -{ - g_fast_pair_info.model_id = Get_ModelId(); - switch(g_fast_pair_info.model_id) - { - //default model id(bes moddel id) - case FP_DEVICE_MODEL_ID: - { - memcpy (g_fast_pair_info.public_anti_spoofing_key, - bes_demo_Public_anti_spoofing_key, sizeof(bes_demo_Public_anti_spoofing_key)); - memcpy (g_fast_pair_info.private_anti_spoofing_key, - bes_demo_private_anti_spoofing_key, sizeof(bes_demo_private_anti_spoofing_key)); - } - break; +void app_bt_get_fast_pair_info(void) { + g_fast_pair_info.model_id = Get_ModelId(); + switch (g_fast_pair_info.model_id) { + // default model id(bes moddel id) + case FP_DEVICE_MODEL_ID: { + memcpy(g_fast_pair_info.public_anti_spoofing_key, + bes_demo_Public_anti_spoofing_key, + sizeof(bes_demo_Public_anti_spoofing_key)); + memcpy(g_fast_pair_info.private_anti_spoofing_key, + bes_demo_private_anti_spoofing_key, + sizeof(bes_demo_private_anti_spoofing_key)); + } break; - //customer add customer model id here; + // customer add customer model id here; - default: - { - g_fast_pair_info.model_id = FP_DEVICE_MODEL_ID; - memcpy (g_fast_pair_info.public_anti_spoofing_key, - bes_demo_Public_anti_spoofing_key, sizeof(bes_demo_Public_anti_spoofing_key)); - memcpy (g_fast_pair_info.private_anti_spoofing_key, - bes_demo_private_anti_spoofing_key, sizeof(bes_demo_private_anti_spoofing_key)); - } - } + default: { + g_fast_pair_info.model_id = FP_DEVICE_MODEL_ID; + memcpy(g_fast_pair_info.public_anti_spoofing_key, + bes_demo_Public_anti_spoofing_key, + sizeof(bes_demo_Public_anti_spoofing_key)); + memcpy(g_fast_pair_info.private_anti_spoofing_key, + bes_demo_private_anti_spoofing_key, + sizeof(bes_demo_private_anti_spoofing_key)); + } + } } -void app_bt_set_fast_pair_info(FastPairInfo fast_pair_info) -{ - memcpy(&g_fast_pair_info, &fast_pair_info,sizeof(fast_pair_info)); +void app_bt_set_fast_pair_info(FastPairInfo fast_pair_info) { + memcpy(&g_fast_pair_info, &fast_pair_info, sizeof(fast_pair_info)); } -void app_gfps_set_tx_power_in_adv(char rssi) -{ - app_gfps_power_uuid[APP_GFPS_ADV_POWER_UUID_LEN-1] = rssi; +void app_gfps_set_tx_power_in_adv(char rssi) { + app_gfps_power_uuid[APP_GFPS_ADV_POWER_UUID_LEN - 1] = rssi; } void app_bt_set_fast_pair_tx_power(int8_t tx_power) { app_gfps_set_tx_power_in_adv(tx_power); } -const uint8_t* app_bt_get_fast_pair_public_key(void) { - return g_fast_pair_info.public_anti_spoofing_key; +const uint8_t *app_bt_get_fast_pair_public_key(void) { + return g_fast_pair_info.public_anti_spoofing_key; } -const uint8_t* app_bt_get_fast_pair_private_key(void) { +const uint8_t *app_bt_get_fast_pair_private_key(void) { return g_fast_pair_info.private_anti_spoofing_key; } -#endif //BLE_APP_GFPS +#endif // BLE_APP_GFPS /// @} APP diff --git a/services/ble_app/app_hid/app_hid.c b/services/ble_app/app_hid/app_hid.c index 206c667..e5263ca 100644 --- a/services/ble_app/app_hid/app_hid.c +++ b/services/ble_app/app_hid/app_hid.c @@ -20,7 +20,7 @@ **************************************************************************************** */ -#include "rwip_config.h" // SW configuration +#include "rwip_config.h" // SW configuration #include #include @@ -32,25 +32,25 @@ **************************************************************************************** */ -#include "app.h" // Application Definitions -#include "app_sec.h" // Application Security Module API -#include "app_task.h" // Application task definitions -#include "app_hid.h" // HID Application Module Definitions -#include "hogpd_task.h" // HID Over GATT Profile Device Role Functions -#include "prf_types.h" // Profile common types Definition -#include "arch.h" // Platform Definitions +#include "app.h" // Application Definitions +#include "app_hid.h" // HID Application Module Definitions +#include "app_sec.h" // Application Security Module API +#include "app_task.h" // Application task definitions +#include "arch.h" // Platform Definitions +#include "hogpd_task.h" // HID Over GATT Profile Device Role Functions +#include "ke_timer.h" // kernel timer #include "prf.h" -#include "ke_timer.h" // kernel timer +#include "prf_types.h" // Profile common types Definition #if (NVDS_SUPPORT) -#include "nvds.h" // NVDS Definitions -#endif //(NVDS_SUPPORT) +#include "nvds.h" // NVDS Definitions +#endif //(NVDS_SUPPORT) #if (DISPLAY_SUPPORT) -#include "app_display.h" // Application Display Module -#endif //(DISPLAY_SUPPORT) +#include "app_display.h" // Application Display Module +#endif //(DISPLAY_SUPPORT) -#include "co_utils.h" // Common functions +#include "co_utils.h" // Common functions #if (KE_PROFILING) #include "ke_mem.h" @@ -62,17 +62,19 @@ */ /// Length of the HID Mouse Report -#define APP_HID_MOUSE_REPORT_LEN (6) +#define APP_HID_MOUSE_REPORT_LEN (6) /// Length of the Report Descriptor for an HID Mouse -#define APP_HID_MOUSE_REPORT_MAP_LEN (sizeof(app_hid_mouse_report_map)) +#define APP_HID_MOUSE_REPORT_MAP_LEN (sizeof(app_hid_mouse_report_map)) -/// Duration before connection update procedure if no report received (mouse is silent) - 20s -#define APP_HID_SILENCE_DURATION_1 (2000) -/// Duration before disconnection if no report is received after connection update - 60s -#define APP_HID_SILENCE_DURATION_2 (6000) +/// Duration before connection update procedure if no report received (mouse is +/// silent) - 20s +#define APP_HID_SILENCE_DURATION_1 (2000) +/// Duration before disconnection if no report is received after connection +/// update - 60s +#define APP_HID_SILENCE_DURATION_2 (6000) /// Number of reports that can be sent -#define APP_HID_NB_SEND_REPORT (10) +#define APP_HID_NB_SEND_REPORT (10) /* * ENUMERATIONS @@ -80,20 +82,19 @@ */ /// States of the Application HID Module -enum app_hid_states -{ - /// Module is disabled (Service not added in DB) - APP_HID_DISABLED, - /// Module is idle (Service added but profile not enabled) - APP_HID_IDLE, - /// Module is enabled (Device is connected and the profile is enabled) - APP_HID_ENABLED, - /// The application can send reports - APP_HID_READY, - /// Waiting for a report - APP_HID_WAIT_REP, +enum app_hid_states { + /// Module is disabled (Service not added in DB) + APP_HID_DISABLED, + /// Module is idle (Service added but profile not enabled) + APP_HID_IDLE, + /// Module is enabled (Device is connected and the profile is enabled) + APP_HID_ENABLED, + /// The application can send reports + APP_HID_READY, + /// Waiting for a report + APP_HID_WAIT_REP, - APP_HID_STATE_MAX, + APP_HID_STATE_MAX, }; /* @@ -105,66 +106,67 @@ enum app_hid_states static struct app_hid_env_tag app_hid_env; /// HID Mouse Report Descriptor -static const uint8_t app_hid_mouse_report_map[] = -{ +static const uint8_t app_hid_mouse_report_map[] = { /** * -------------------------------------------------------------------------- - * Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | + * Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | * -------------------------------------------------------------------------- - * Byte 0 | Not Used | Middle| Right | Left | + * Byte 0 | Not Used | Middle| Right | Left + * | * -------------------------------------------------------------------------- - * Byte 1 | X Axis Relative Movement | + * Byte 1 | X Axis Relative Movement | * -------------------------------------------------------------------------- - * Byte 2 | Y Axis Relative Movement | + * Byte 2 | Y Axis Relative Movement | * -------------------------------------------------------------------------- - * Byte 3 | Wheel Relative Movement | + * Byte 3 | Wheel Relative Movement | * -------------------------------------------------------------------------- */ - 0x05, 0x01, /// USAGE PAGE (Generic Desktop) - 0x09, 0x02, /// USAGE (Mouse) - 0xA1, 0x01, /// COLLECTION (Application) - 0x85, 0x01, /// REPORT ID (1) - MANDATORY - 0x09, 0x01, /// USAGE (Pointer) - 0xA1, 0x00, /// COLLECTION (Physical) + 0x05, + 0x01, /// USAGE PAGE (Generic Desktop) + 0x09, 0x02, /// USAGE (Mouse) + 0xA1, 0x01, /// COLLECTION (Application) + 0x85, 0x01, /// REPORT ID (1) - MANDATORY + 0x09, 0x01, /// USAGE (Pointer) + 0xA1, 0x00, /// COLLECTION (Physical) /** * ---------------------------------------------------------------------------- * BUTTONS * ---------------------------------------------------------------------------- */ - 0x05, 0x09, /// USAGE PAGE (Buttons) - 0x19, 0x01, /// USAGE MINIMUM (1) - 0x29, 0x08, /// USAGE MAXIMUM (8) - 0x15, 0x00, /// LOGICAL MINIMUM (0) - 0x25, 0x01, /// LOGICAL MAXIMUM (1) - 0x75, 0x01, /// REPORT SIZE (1) - 0x95, 0x08, /// REPORT COUNT (8) - 0x81, 0x02, /// INPUT (Data, Variable, Absolute) + 0x05, 0x09, /// USAGE PAGE (Buttons) + 0x19, 0x01, /// USAGE MINIMUM (1) + 0x29, 0x08, /// USAGE MAXIMUM (8) + 0x15, 0x00, /// LOGICAL MINIMUM (0) + 0x25, 0x01, /// LOGICAL MAXIMUM (1) + 0x75, 0x01, /// REPORT SIZE (1) + 0x95, 0x08, /// REPORT COUNT (8) + 0x81, 0x02, /// INPUT (Data, Variable, Absolute) /** * ---------------------------------------------------------------------------- * MOVEMENT DATA * ---------------------------------------------------------------------------- */ - 0x05, 0x01, /// USAGE PAGE (Generic Desktop) + 0x05, 0x01, /// USAGE PAGE (Generic Desktop) 0x16, 0x08, 0xFF, /// LOGICAL MINIMUM (-255) 0x26, 0xFF, 0x00, /// LOGICAL MAXIMUM (255) - 0x75, 0x10, /// REPORT SIZE (16) - 0x95, 0x02, /// REPORT COUNT (2) - 0x09, 0x30, /// USAGE (X) - 0x09, 0x31, /// USAGE (Y) - 0x81, 0x06, /// INPUT (Data, Variable, Relative) + 0x75, 0x10, /// REPORT SIZE (16) + 0x95, 0x02, /// REPORT COUNT (2) + 0x09, 0x30, /// USAGE (X) + 0x09, 0x31, /// USAGE (Y) + 0x81, 0x06, /// INPUT (Data, Variable, Relative) - 0x15, 0x81, /// LOGICAL MINIMUM (-127) - 0x25, 0x7F, /// LOGICAL MAXIMUM (127) - 0x75, 0x08, /// REPORT SIZE (8) - 0x95, 0x01, /// REPORT COUNT (1) - 0x09, 0x38, /// USAGE (Wheel) - 0x81, 0x06, /// INPUT (Data, Variable, Relative) + 0x15, 0x81, /// LOGICAL MINIMUM (-127) + 0x25, 0x7F, /// LOGICAL MAXIMUM (127) + 0x75, 0x08, /// REPORT SIZE (8) + 0x95, 0x01, /// REPORT COUNT (1) + 0x09, 0x38, /// USAGE (Wheel) + 0x81, 0x06, /// INPUT (Data, Variable, Relative) - 0xC0, /// END COLLECTION (Physical) - 0xC0 /// END COLLECTION (Application) + 0xC0, /// END COLLECTION (Physical) + 0xC0 /// END COLLECTION (Application) }; /* @@ -172,193 +174,183 @@ static const uint8_t app_hid_mouse_report_map[] = **************************************************************************************** */ -void app_hid_init(void) -{ +void app_hid_init(void) { #if (NVDS_SUPPORT) - // Length of the mouse timeout value - uint8_t length = NVDS_LEN_MOUSE_TIMEOUT; + // Length of the mouse timeout value + uint8_t length = NVDS_LEN_MOUSE_TIMEOUT; #endif - // Reset the environment - memset(&app_hid_env, 0, sizeof(app_hid_env)); + // Reset the environment + memset(&app_hid_env, 0, sizeof(app_hid_env)); - app_hid_env.nb_report = APP_HID_NB_SEND_REPORT; + app_hid_env.nb_report = APP_HID_NB_SEND_REPORT; - /* - * Get the timeout value from the NVDS - This value is used each time a report is received - * from the PS2 driver, store it in the environment. - */ + /* + * Get the timeout value from the NVDS - This value is used each time a report + * is received from the PS2 driver, store it in the environment. + */ #if (NVDS_SUPPORT) - if (nvds_get(NVDS_TAG_MOUSE_TIMEOUT, &length, (uint8_t *)&app_hid_env.timeout) != NVDS_OK) + if (nvds_get(NVDS_TAG_MOUSE_TIMEOUT, &length, + (uint8_t *)&app_hid_env.timeout) != NVDS_OK) #endif - { - app_hid_env.timeout = APP_HID_SILENCE_DURATION_1; - } + { + app_hid_env.timeout = APP_HID_SILENCE_DURATION_1; + } } - /* **************************************************************************************** * @brief Function called when get GAP manager command complete events. * **************************************************************************************** */ -void app_hid_start_mouse(void) -{ - /*----------------------------------------------------------------------------------- - * CONFIGURE THE MOUSE - *----------------------------------------------------------------------------------*/ - #if (PS2_SUPPORT) - // Default mouse rate (200 report/s) - uint8_t rate = 200; +void app_hid_start_mouse(void) { +/*----------------------------------------------------------------------------------- + * CONFIGURE THE MOUSE + *----------------------------------------------------------------------------------*/ +#if (PS2_SUPPORT) + // Default mouse rate (200 report/s) + uint8_t rate = 200; - #if (NVDS_SUPPORT) - uint8_t length = NVDS_LEN_MOUSE_SAMPLE_RATE; +#if (NVDS_SUPPORT) + uint8_t length = NVDS_LEN_MOUSE_SAMPLE_RATE; - // Get sample rate from NVDS - if (nvds_get(NVDS_TAG_MOUSE_SAMPLE_RATE, &length, &rate) == NVDS_OK) - { - // Check if value is among supported set - if ((rate != 10) && (rate != 20) && (rate != 40) && (rate != 60) && - (rate != 80) && (rate != 100) && (rate != 200) ) - { - // Default value - rate = 200; - } + // Get sample rate from NVDS + if (nvds_get(NVDS_TAG_MOUSE_SAMPLE_RATE, &length, &rate) == NVDS_OK) { + // Check if value is among supported set + if ((rate != 10) && (rate != 20) && (rate != 40) && (rate != 60) && + (rate != 80) && (rate != 100) && (rate != 200)) { + // Default value + rate = 200; } - #endif //(NVDS_SUPPORT) + } +#endif //(NVDS_SUPPORT) - // Start PS2_mouse - ps2_mouse_start(rate, &app_hid_send_mouse_report); - #endif //(PS2_SUPPORT) + // Start PS2_mouse + ps2_mouse_start(rate, &app_hid_send_mouse_report); +#endif //(PS2_SUPPORT) } -void app_hid_add_hids(void) -{ - struct hogpd_db_cfg *db_cfg; - // Prepare the HOGPD_CREATE_DB_REQ message - struct gapm_profile_task_add_cmd *req = KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, - TASK_GAPM, TASK_APP, - gapm_profile_task_add_cmd, sizeof(struct hogpd_db_cfg)); +void app_hid_add_hids(void) { + struct hogpd_db_cfg *db_cfg; + // Prepare the HOGPD_CREATE_DB_REQ message + struct gapm_profile_task_add_cmd *req = + KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, TASK_GAPM, TASK_APP, + gapm_profile_task_add_cmd, sizeof(struct hogpd_db_cfg)); - // Fill message - req->operation = GAPM_PROFILE_TASK_ADD; -#if BLE_CONNECTION_MAX>1 - req->sec_lvl = PERM(SVC_AUTH, ENABLE)|PERM(SVC_MI, ENABLE); + // Fill message + req->operation = GAPM_PROFILE_TASK_ADD; +#if BLE_CONNECTION_MAX > 1 + req->sec_lvl = PERM(SVC_AUTH, ENABLE) | PERM(SVC_MI, ENABLE); #else - req->sec_lvl = PERM(SVC_AUTH, ENABLE); -#endif + req->sec_lvl = PERM(SVC_AUTH, ENABLE); +#endif - req->prf_task_id = TASK_ID_HOGPD; - req->app_task = TASK_APP; - req->start_hdl = 0; + req->prf_task_id = TASK_ID_HOGPD; + req->app_task = TASK_APP; + req->start_hdl = 0; - // Set parameters - db_cfg = (struct hogpd_db_cfg* ) req->param; + // Set parameters + db_cfg = (struct hogpd_db_cfg *)req->param; - // Only one HIDS instance is useful - db_cfg->hids_nb = 1; + // Only one HIDS instance is useful + db_cfg->hids_nb = 1; - // The device is a mouse - db_cfg->cfg[0].svc_features = HOGPD_CFG_MOUSE; + // The device is a mouse + db_cfg->cfg[0].svc_features = HOGPD_CFG_MOUSE; - // Only one Report Characteristic is requested - db_cfg->cfg[0].report_nb = 1; - /// db_cfg->cfg[0].report_id = 1; - db_cfg->cfg[0].report_id[0] = 1; + // Only one Report Characteristic is requested + db_cfg->cfg[0].report_nb = 1; + /// db_cfg->cfg[0].report_id = 1; + db_cfg->cfg[0].report_id[0] = 1; - // The report is an input report - db_cfg->cfg[0].report_char_cfg[0] = HOGPD_CFG_REPORT_IN; + // The report is an input report + db_cfg->cfg[0].report_char_cfg[0] = HOGPD_CFG_REPORT_IN; - // HID Information - db_cfg->cfg[0].hid_info.bcdHID = 0x0111; // HID Version 1.11 - db_cfg->cfg[0].hid_info.bCountryCode = 0x00; - db_cfg->cfg[0].hid_info.flags = HIDS_REMOTE_WAKE_CAPABLE | HIDS_NORM_CONNECTABLE; + // HID Information + db_cfg->cfg[0].hid_info.bcdHID = 0x0111; // HID Version 1.11 + db_cfg->cfg[0].hid_info.bCountryCode = 0x00; + db_cfg->cfg[0].hid_info.flags = + HIDS_REMOTE_WAKE_CAPABLE | HIDS_NORM_CONNECTABLE; - // Send the message - ke_msg_send(req); + // Send the message + ke_msg_send(req); } - - - /* **************************************************************************************** * @brief Function called when get connection complete event from the GAP * **************************************************************************************** */ -void app_hid_enable_prf(uint8_t conidx) -{ - // Requested connection parameters - struct gapc_conn_param conn_param; +void app_hid_enable_prf(uint8_t conidx) { + // Requested connection parameters + struct gapc_conn_param conn_param; - uint16_t ntf_cfg; + uint16_t ntf_cfg; - // Store the connection handle - app_hid_env.conidx = conidx; + // Store the connection handle + app_hid_env.conidx = conidx; - // Allocate the message - struct hogpd_enable_req * req = KE_MSG_ALLOC(HOGPD_ENABLE_REQ, - KE_BUILD_ID(prf_get_task_from_id(TASK_ID_HOGPD), conidx), - TASK_APP, - hogpd_enable_req); + // Allocate the message + struct hogpd_enable_req *req = + KE_MSG_ALLOC(HOGPD_ENABLE_REQ, + KE_BUILD_ID(prf_get_task_from_id(TASK_ID_HOGPD), conidx), + TASK_APP, hogpd_enable_req); - // Fill in the parameter structure - req->conidx = conidx; - // Notifications are disabled - ntf_cfg = 0; + // Fill in the parameter structure + req->conidx = conidx; + // Notifications are disabled + ntf_cfg = 0; - // Go to Enabled state - app_hid_env.state = APP_HID_ENABLED; + // Go to Enabled state + app_hid_env.state = APP_HID_ENABLED; - #if (NVDS_SUPPORT) - // If first connection with the peer device - if (app_sec_get_bond_status()) - { - // Length of the value read in NVDS - uint8_t length = NVDS_LEN_MOUSE_NTF_CFG; - // Notification configuration +#if (NVDS_SUPPORT) + // If first connection with the peer device + if (app_sec_get_bond_status()) { + // Length of the value read in NVDS + uint8_t length = NVDS_LEN_MOUSE_NTF_CFG; + // Notification configuration - if (nvds_get(NVDS_TAG_MOUSE_NTF_CFG, &length, (uint8_t *)&ntf_cfg) != NVDS_OK) - { - // If we are bonded this information should be present in the NVDS - ASSERT_ERR(0); - } - - // CCC enable notification - if ((ntf_cfg & HOGPD_CFG_REPORT_NTF_EN ) != 0) - { - // The device is ready to send reports to the peer device - app_hid_env.state = APP_HID_READY; - app_hid_env.nb_report = APP_HID_NB_SEND_REPORT; - - // Restart the mouse timeout timer if needed - if (app_hid_env.timeout != 0) - { - ke_timer_set(APP_HID_MOUSE_TIMEOUT_TIMER, TASK_APP, (uint16_t)(app_hid_env.timeout)); - app_hid_env.timer_enabled = true; - } - } + if (nvds_get(NVDS_TAG_MOUSE_NTF_CFG, &length, (uint8_t *)&ntf_cfg) != + NVDS_OK) { + // If we are bonded this information should be present in the NVDS + ASSERT_ERR(0); } - #endif //(NVDS_SUPPORT) - req->ntf_cfg[conidx] = ntf_cfg; + // CCC enable notification + if ((ntf_cfg & HOGPD_CFG_REPORT_NTF_EN) != 0) { + // The device is ready to send reports to the peer device + app_hid_env.state = APP_HID_READY; + app_hid_env.nb_report = APP_HID_NB_SEND_REPORT; - /* - * Requested connection interval: 10ms - * Latency: 25 - * Supervision Timeout: 2s - */ - conn_param.intv_min = 8; - conn_param.intv_max = 8; - conn_param.latency = 25; - conn_param.time_out = 200; + // Restart the mouse timeout timer if needed + if (app_hid_env.timeout != 0) { + ke_timer_set(APP_HID_MOUSE_TIMEOUT_TIMER, TASK_APP, + (uint16_t)(app_hid_env.timeout)); + app_hid_env.timer_enabled = true; + } + } + } +#endif //(NVDS_SUPPORT) - appm_update_param(conidx, &conn_param); + req->ntf_cfg[conidx] = ntf_cfg; - // Send the message - ke_msg_send(req); + /* + * Requested connection interval: 10ms + * Latency: 25 + * Supervision Timeout: 2s + */ + conn_param.intv_min = 8; + conn_param.intv_max = 8; + conn_param.latency = 25; + conn_param.time_out = 200; + + appm_update_param(conidx, &conn_param); + + // Send the message + ke_msg_send(req); } /* @@ -367,450 +359,394 @@ void app_hid_enable_prf(uint8_t conidx) * **************************************************************************************** */ -void app_hid_send_mouse_report(struct ps2_mouse_msg report) -{ +void app_hid_send_mouse_report(struct ps2_mouse_msg report) { -// app_display_update_hid_value_screen(report.b, report.x, report.y, report.w); + // app_display_update_hid_value_screen(report.b, report.x, report.y, + // report.w); - switch (app_hid_env.state) - { - case (APP_HID_READY): - { - // Check if the report can be sent - if (app_hid_env.nb_report) - { - // Buffer used to create the Report - uint8_t report_buff[APP_HID_MOUSE_REPORT_LEN]; - // X, Y and wheel relative movements - int16_t x; - int16_t y; + switch (app_hid_env.state) { + case (APP_HID_READY): { + // Check if the report can be sent + if (app_hid_env.nb_report) { + // Buffer used to create the Report + uint8_t report_buff[APP_HID_MOUSE_REPORT_LEN]; + // X, Y and wheel relative movements + int16_t x; + int16_t y; - #if (DISPLAY_SUPPORT) - // Display all the received information on the LCD screen - //app_display_update_hid_value_screen(report.b, report.x, report.y, report.w); - #endif //(DISPLAY_SUPPORT) +#if (DISPLAY_SUPPORT) +// Display all the received information on the LCD screen +// app_display_update_hid_value_screen(report.b, report.x, report.y, report.w); +#endif //(DISPLAY_SUPPORT) - // Clean the report buffer - memset(&report_buff[0], 0, APP_HID_MOUSE_REPORT_LEN); + // Clean the report buffer + memset(&report_buff[0], 0, APP_HID_MOUSE_REPORT_LEN); - // Set the button states - report_buff[0] = (report.b & 0x07); + // Set the button states + report_buff[0] = (report.b & 0x07); - // If X value is negative - if (report.b & 0x10) - { - report.x = ~report.x; - report.x += 1; - x = (int16_t)report.x; - x *= (-1); - } - else - { - x = (int16_t)report.x; - } + // If X value is negative + if (report.b & 0x10) { + report.x = ~report.x; + report.x += 1; + x = (int16_t)report.x; + x *= (-1); + } else { + x = (int16_t)report.x; + } - // If Y value is negative - if (report.b & 0x20) - { - report.y = ~report.y; - report.y += 1; - y = (int16_t)report.y; - } - else - { - y = (int16_t)report.y; - y *= (-1); - } + // If Y value is negative + if (report.b & 0x20) { + report.y = ~report.y; + report.y += 1; + y = (int16_t)report.y; + } else { + y = (int16_t)report.y; + y *= (-1); + } + // Set the X and Y movement value in the report + co_write16p(&report_buff[1], x); + co_write16p(&report_buff[3], y); + report_buff[5] = (signed char)(-1) * report.w; - // Set the X and Y movement value in the report - co_write16p(&report_buff[1], x); - co_write16p(&report_buff[3], y); - report_buff[5] =(signed char) (-1) * report.w; + // Allocate the HOGPD_REPORT_UPD_REQ message + struct hogpd_report_upd_req *req = KE_MSG_ALLOC_DYN( + HOGPD_REPORT_UPD_REQ, prf_get_task_from_id(TASK_ID_HOGPD), TASK_APP, + hogpd_report_upd_req, APP_HID_MOUSE_REPORT_LEN); - // Allocate the HOGPD_REPORT_UPD_REQ message - struct hogpd_report_upd_req * req = KE_MSG_ALLOC_DYN(HOGPD_REPORT_UPD_REQ, - prf_get_task_from_id(TASK_ID_HOGPD), - TASK_APP, - hogpd_report_upd_req, - APP_HID_MOUSE_REPORT_LEN); + req->conidx = app_hid_env.conidx; + // now fill report + req->report.hid_idx = app_hid_env.conidx; + req->report.type = HOGPD_REPORT; // HOGPD_BOOT_MOUSE_INPUT_REPORT;// + req->report.idx = 0; // 0 for boot reports and report map + req->report.length = APP_HID_MOUSE_REPORT_LEN; + memcpy(&req->report.value[0], &report_buff[0], APP_HID_MOUSE_REPORT_LEN); - req->conidx = app_hid_env.conidx; - //now fill report - req->report.hid_idx = app_hid_env.conidx; - req->report.type = HOGPD_REPORT; //HOGPD_BOOT_MOUSE_INPUT_REPORT;// - req->report.idx = 0; //0 for boot reports and report map - req->report.length = APP_HID_MOUSE_REPORT_LEN; - memcpy(&req->report.value[0], &report_buff[0], APP_HID_MOUSE_REPORT_LEN); + ke_msg_send(req); - ke_msg_send(req); + app_hid_env.nb_report--; - app_hid_env.nb_report--; + // Restart the mouse timeout timer if needed + if (app_hid_env.timeout != 0) { + ke_timer_set(APP_HID_MOUSE_TIMEOUT_TIMER, TASK_APP, + (uint16_t)(app_hid_env.timeout)); + app_hid_env.timer_enabled = true; + } + } + } break; - // Restart the mouse timeout timer if needed - if (app_hid_env.timeout != 0) - { - ke_timer_set(APP_HID_MOUSE_TIMEOUT_TIMER, TASK_APP, (uint16_t)(app_hid_env.timeout)); - app_hid_env.timer_enabled = true; - } - } - } break; + case (APP_HID_WAIT_REP): { + // Requested connection parameters + struct gapc_conn_param conn_param; - case (APP_HID_WAIT_REP): - { - // Requested connection parameters - struct gapc_conn_param conn_param; + /* + * Requested connection interval: 10ms + * Latency: 25 + * Supervision Timeout: 2s + */ + conn_param.intv_min = 8; + conn_param.intv_max = 8; + conn_param.latency = 25; + conn_param.time_out = 200; - /* - * Requested connection interval: 10ms - * Latency: 25 - * Supervision Timeout: 2s - */ - conn_param.intv_min = 8; - conn_param.intv_max = 8; - conn_param.latency = 25; - conn_param.time_out = 200; + appm_update_param(app_hid_env.conidx, &conn_param); - appm_update_param(app_hid_env.conidx, &conn_param); - - // Restart the mouse timeout timer if needed - if (app_hid_env.timeout != 0) - { - ke_timer_set(APP_HID_MOUSE_TIMEOUT_TIMER, TASK_APP, (uint16_t)(app_hid_env.timeout)); - app_hid_env.timer_enabled = true; - } - - // Go back to the ready state - app_hid_env.state = APP_HID_READY; - } break; - - case (APP_HID_IDLE): - { - // Try to restart advertising if needed - } break; - - // DISABLE and ENABLED states - default: - { - // Drop the message - } break; + // Restart the mouse timeout timer if needed + if (app_hid_env.timeout != 0) { + ke_timer_set(APP_HID_MOUSE_TIMEOUT_TIMER, TASK_APP, + (uint16_t)(app_hid_env.timeout)); + app_hid_env.timer_enabled = true; } - #if (KE_PROFILING) -// app_display_hdl_env_size(0xFFFF, ke_get_mem_usage(KE_MEM_ENV)); -// app_display_hdl_db_size(0xFFFF, ke_get_mem_usage(KE_MEM_ATT_DB)); -// app_display_hdl_msg_size((uint16_t)ke_get_max_mem_usage(), ke_get_mem_usage(KE_MEM_KE_MSG)); - #endif //(KE_PROFILING) -} + // Go back to the ready state + app_hid_env.state = APP_HID_READY; + } break; + case (APP_HID_IDLE): { + // Try to restart advertising if needed + } break; + + // DISABLE and ENABLED states + default: { + // Drop the message + } break; + } + +#if (KE_PROFILING) + // app_display_hdl_env_size(0xFFFF, ke_get_mem_usage(KE_MEM_ENV)); + // app_display_hdl_db_size(0xFFFF, ke_get_mem_usage(KE_MEM_ATT_DB)); + // app_display_hdl_msg_size((uint16_t)ke_get_max_mem_usage(), + // ke_get_mem_usage(KE_MEM_KE_MSG)); +#endif //(KE_PROFILING) +} /* * MESSAGE HANDLERS **************************************************************************************** */ - static int hogpd_ctnl_pt_ind_handler(ke_msg_id_t const msgid, struct hogpd_ctnl_pt_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ + ke_task_id_t const src_id) { + if (param->conidx == app_hid_env.conidx) { + // make use of param->hid_ctnl_pt + struct hogpd_report_cfm *req = KE_MSG_ALLOC_DYN( + HOGPD_REPORT_CFM, prf_get_task_from_id(TASK_ID_HOGPD), /* src_id */ + TASK_APP, hogpd_report_cfm, 0); - if (param->conidx == app_hid_env.conidx) - { - //make use of param->hid_ctnl_pt - struct hogpd_report_cfm *req = KE_MSG_ALLOC_DYN(HOGPD_REPORT_CFM, - prf_get_task_from_id(TASK_ID_HOGPD),/* src_id */ - TASK_APP, - hogpd_report_cfm, - 0); + req->conidx = param->conidx; /// app_hid_env.conidx; ///??? + /// Operation requested (read/write @see enum hogpd_op) + req->operation = HOGPD_OP_REPORT_WRITE; + /// Status of the request + req->status = GAP_ERR_NO_ERROR; ///??? + /// Report Info + // req->report; + /// HIDS Instance + req->report.hid_idx = app_hid_env.conidx; ///??? + /// type of report (@see enum hogpd_report_type) + req->report.type = -1; // outside + /// Report Length (uint8_t) + req->report.length = 0; + /// Report Instance - 0 for boot reports and report map + req->report.idx = 0; + /// Report data - req->conidx = param->conidx; ///app_hid_env.conidx; ///??? - /// Operation requested (read/write @see enum hogpd_op) - req->operation = HOGPD_OP_REPORT_WRITE; - /// Status of the request - req->status = GAP_ERR_NO_ERROR; ///??? - /// Report Info - //req->report; - /// HIDS Instance - req->report.hid_idx = app_hid_env.conidx; ///??? - /// type of report (@see enum hogpd_report_type) - req->report.type = -1;//outside - /// Report Length (uint8_t) - req->report.length = 0; - /// Report Instance - 0 for boot reports and report map - req->report.idx = 0; - /// Report data - - - // Send the message - ke_msg_send(req); - } - return (KE_MSG_CONSUMED); + // Send the message + ke_msg_send(req); + } + return (KE_MSG_CONSUMED); } - - - static int hogpd_ntf_cfg_ind_handler(ke_msg_id_t const msgid, struct hogpd_ntf_cfg_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if (app_hid_env.conidx == param->conidx) - { - if ((param->ntf_cfg[param->conidx] & HOGPD_CFG_REPORT_NTF_EN ) != 0) - { - // The device is ready to send reports to the peer device - app_hid_env.state = APP_HID_READY; - } - else - { - // Come back to the Enabled state - if (app_hid_env.state == APP_HID_READY) - { - app_hid_env.state = APP_HID_ENABLED; - } - } + ke_task_id_t const src_id) { + if (app_hid_env.conidx == param->conidx) { + if ((param->ntf_cfg[param->conidx] & HOGPD_CFG_REPORT_NTF_EN) != 0) { + // The device is ready to send reports to the peer device + app_hid_env.state = APP_HID_READY; + } else { + // Come back to the Enabled state + if (app_hid_env.state == APP_HID_READY) { + app_hid_env.state = APP_HID_ENABLED; + } + } #if (NVDS_SUPPORT) - // Store the notification configuration in the database - if (nvds_put(NVDS_TAG_MOUSE_NTF_CFG, NVDS_LEN_MOUSE_NTF_CFG, - (uint8_t *)¶m->ntf_cfg[param->conidx]) != NVDS_OK) - { - // Should not happen - ASSERT_ERR(0); - } + // Store the notification configuration in the database + if (nvds_put(NVDS_TAG_MOUSE_NTF_CFG, NVDS_LEN_MOUSE_NTF_CFG, + (uint8_t *)¶m->ntf_cfg[param->conidx]) != NVDS_OK) { + // Should not happen + ASSERT_ERR(0); + } #endif - } + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } -static int hogpd_report_req_ind_handler(ke_msg_id_t const msgid, - struct hogpd_report_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ +static int hogpd_report_req_ind_handler( + ke_msg_id_t const msgid, struct hogpd_report_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { - if ((param->operation == HOGPD_OP_REPORT_READ) && (param->report.type == HOGPD_REPORT_MAP)) - { - struct hogpd_report_cfm *req = KE_MSG_ALLOC_DYN(HOGPD_REPORT_CFM, - src_id, ///prf_get_task_from_id(TASK_ID_HOGPD),/* src_id */ - dest_id, ///TASK_APP, - hogpd_report_cfm, - APP_HID_MOUSE_REPORT_MAP_LEN); + if ((param->operation == HOGPD_OP_REPORT_READ) && + (param->report.type == HOGPD_REPORT_MAP)) { + struct hogpd_report_cfm *req = KE_MSG_ALLOC_DYN( + HOGPD_REPORT_CFM, + src_id, /// prf_get_task_from_id(TASK_ID_HOGPD),/* src_id */ + dest_id, /// TASK_APP, + hogpd_report_cfm, APP_HID_MOUSE_REPORT_MAP_LEN); - req->conidx = app_hid_env.conidx; ///??? - /// Operation requested (read/write @see enum hogpd_op) - req->operation = HOGPD_OP_REPORT_READ; - /// Status of the request - req->status = GAP_ERR_NO_ERROR; ///??? - /// Report Info - //req->report; - /// HIDS Instance - req->report.hid_idx = param->report.hid_idx;/// ???///app_hid_env.conidx; ///??? - /// type of report (@see enum hogpd_report_type) - req->report.type = HOGPD_REPORT_MAP; - /// Report Length (uint8_t) - req->report.length = APP_HID_MOUSE_REPORT_MAP_LEN; - /// Report Instance - 0 for boot reports and report map - req->report.idx = 0; - /// Report data - memcpy(&req->report.value[0], &app_hid_mouse_report_map[0], APP_HID_MOUSE_REPORT_MAP_LEN); + req->conidx = app_hid_env.conidx; ///??? + /// Operation requested (read/write @see enum hogpd_op) + req->operation = HOGPD_OP_REPORT_READ; + /// Status of the request + req->status = GAP_ERR_NO_ERROR; ///??? + /// Report Info + // req->report; + /// HIDS Instance + req->report.hid_idx = + param->report.hid_idx; /// ???///app_hid_env.conidx; ///??? + /// type of report (@see enum hogpd_report_type) + req->report.type = HOGPD_REPORT_MAP; + /// Report Length (uint8_t) + req->report.length = APP_HID_MOUSE_REPORT_MAP_LEN; + /// Report Instance - 0 for boot reports and report map + req->report.idx = 0; + /// Report data + memcpy(&req->report.value[0], &app_hid_mouse_report_map[0], + APP_HID_MOUSE_REPORT_MAP_LEN); - // Send the message - ke_msg_send(req); + // Send the message + ke_msg_send(req); + } else { + if (param->report.type == + HOGPD_BOOT_MOUSE_INPUT_REPORT) { // request of boot mouse report + struct hogpd_report_cfm *req = KE_MSG_ALLOC_DYN( + HOGPD_REPORT_CFM, prf_get_task_from_id(TASK_ID_HOGPD), /* src_id */ + TASK_APP, hogpd_report_cfm, 0 /*param->report.length*/); + + req->conidx = param->conidx; /// app_hid_env.conidx; ///??? + /// Operation requested (read/write @see enum hogpd_op) + req->operation = HOGPD_OP_REPORT_READ; + /// Status of the request + req->status = GAP_ERR_NO_ERROR; ///??? + /// HIDS Instance + req->report.hid_idx = app_hid_env.conidx; ///??? + /// type of report (@see enum hogpd_report_type) + req->report.type = param->report.type; //-1;//outside + /// Report Length (uint8_t) + req->report.length = 0; // param->report.length; + /// Report Instance - 0 for boot reports and report map + req->report.idx = param->report.idx; // 0; + /// Report data + + // Send the message + ke_msg_send(req); + } else if (param->report.type == HOGPD_REPORT) { // request of mouse report + struct hogpd_report_cfm *req = KE_MSG_ALLOC_DYN( + HOGPD_REPORT_CFM, prf_get_task_from_id(TASK_ID_HOGPD), /* src_id */ + TASK_APP, hogpd_report_cfm, 8 /*param->report.length*/); + + req->conidx = param->conidx; /// app_hid_env.conidx; ///??? + /// Operation requested (read/write @see enum hogpd_op) + req->operation = HOGPD_OP_REPORT_READ; + /// Status of the request + req->status = GAP_ERR_NO_ERROR; ///??? + /// Report Info + // req->report; + /// HIDS Instance + req->report.hid_idx = app_hid_env.conidx; ///??? + /// type of report (@see enum hogpd_report_type) + req->report.type = param->report.type; //-1;//outside + /// Report Length (uint8_t) + req->report.length = 8; // param->report.length; + /// Report Instance - 0 for boot reports and report map + req->report.idx = param->report.idx; // 0; + /// Report data + memset(&req->report.value[0], 0, 8); //??? + req->report.value[0] = param->report.hid_idx; /// HIDS Instance + req->report.value[1] = + param->report.type; /// type of report (@see enum hogpd_report_type) + req->report.value[2] = param->report.length; /// Report Length (uint8_t) + req->report.value[3] = + param->report + .idx; /// Report Instance - 0 for boot reports and report map + + // Send the message + ke_msg_send(req); + } else { + struct hogpd_report_cfm *req = KE_MSG_ALLOC_DYN( + HOGPD_REPORT_CFM, prf_get_task_from_id(TASK_ID_HOGPD), /* src_id */ + TASK_APP, hogpd_report_cfm, 8 /*param->report.length*/); + + req->conidx = param->conidx; /// app_hid_env.conidx; ///??? + /// Operation requested (read/write @see enum hogpd_op) + req->operation = HOGPD_OP_REPORT_READ; + /// Status of the request + req->status = GAP_ERR_NO_ERROR; ///??? + /// Report Info + // req->report; + /// HIDS Instance + req->report.hid_idx = app_hid_env.conidx; ///??? + /// type of report (@see enum hogpd_report_type) + req->report.type = param->report.type; //-1;//outside + /// Report Length (uint8_t) + req->report.length = 8; // param->report.length; + /// Report Instance - 0 for boot reports and report map + req->report.idx = param->report.idx; // 0; + /// Report data + memset(&req->report.value[0], 0, 8); //??? + req->report.value[0] = param->report.hid_idx; /// HIDS Instance + req->report.value[1] = + param->report.type; /// type of report (@see enum hogpd_report_type) + req->report.value[2] = param->report.length; /// Report Length (uint8_t) + req->report.value[3] = + param->report + .idx; /// Report Instance - 0 for boot reports and report map + + // Send the message + ke_msg_send(req); } - else - { - if (param->report.type == HOGPD_BOOT_MOUSE_INPUT_REPORT) - { //request of boot mouse report - struct hogpd_report_cfm *req = KE_MSG_ALLOC_DYN(HOGPD_REPORT_CFM, - prf_get_task_from_id(TASK_ID_HOGPD),/* src_id */ - TASK_APP, - hogpd_report_cfm, - 0/*param->report.length*/); + } - req->conidx = param->conidx; ///app_hid_env.conidx; ///??? - /// Operation requested (read/write @see enum hogpd_op) - req->operation = HOGPD_OP_REPORT_READ; - /// Status of the request - req->status = GAP_ERR_NO_ERROR; ///??? - /// HIDS Instance - req->report.hid_idx = app_hid_env.conidx; ///??? - /// type of report (@see enum hogpd_report_type) - req->report.type = param->report.type;//-1;//outside - /// Report Length (uint8_t) - req->report.length = 0; //param->report.length; - /// Report Instance - 0 for boot reports and report map - req->report.idx = param->report.idx; //0; - /// Report data - - // Send the message - ke_msg_send(req); - } - else - if (param->report.type == HOGPD_REPORT) - { //request of mouse report - struct hogpd_report_cfm *req = KE_MSG_ALLOC_DYN(HOGPD_REPORT_CFM, - prf_get_task_from_id(TASK_ID_HOGPD),/* src_id */ - TASK_APP, - hogpd_report_cfm, - 8/*param->report.length*/); - - req->conidx = param->conidx; ///app_hid_env.conidx; ///??? - /// Operation requested (read/write @see enum hogpd_op) - req->operation = HOGPD_OP_REPORT_READ; - /// Status of the request - req->status = GAP_ERR_NO_ERROR; ///??? - /// Report Info - //req->report; - /// HIDS Instance - req->report.hid_idx = app_hid_env.conidx; ///??? - /// type of report (@see enum hogpd_report_type) - req->report.type = param->report.type;//-1;//outside - /// Report Length (uint8_t) - req->report.length = 8; //param->report.length; - /// Report Instance - 0 for boot reports and report map - req->report.idx = param->report.idx; //0; - /// Report data - memset(&req->report.value[0], 0, 8); //??? - req->report.value[0] = param->report.hid_idx; /// HIDS Instance - req->report.value[1] = param->report.type; /// type of report (@see enum hogpd_report_type) - req->report.value[2] = param->report.length; /// Report Length (uint8_t) - req->report.value[3] = param->report.idx; /// Report Instance - 0 for boot reports and report map - - // Send the message - ke_msg_send(req); - } - else - { - struct hogpd_report_cfm *req = KE_MSG_ALLOC_DYN(HOGPD_REPORT_CFM, - prf_get_task_from_id(TASK_ID_HOGPD),/* src_id */ - TASK_APP, - hogpd_report_cfm, - 8/*param->report.length*/); - - req->conidx = param->conidx; ///app_hid_env.conidx; ///??? - /// Operation requested (read/write @see enum hogpd_op) - req->operation = HOGPD_OP_REPORT_READ; - /// Status of the request - req->status = GAP_ERR_NO_ERROR; ///??? - /// Report Info - //req->report; - /// HIDS Instance - req->report.hid_idx = app_hid_env.conidx; ///??? - /// type of report (@see enum hogpd_report_type) - req->report.type = param->report.type;//-1;//outside - /// Report Length (uint8_t) - req->report.length = 8; //param->report.length; - /// Report Instance - 0 for boot reports and report map - req->report.idx = param->report.idx; //0; - /// Report data - memset(&req->report.value[0], 0, 8); //??? - req->report.value[0] = param->report.hid_idx; /// HIDS Instance - req->report.value[1] = param->report.type; /// type of report (@see enum hogpd_report_type) - req->report.value[2] = param->report.length; /// Report Length (uint8_t) - req->report.value[3] = param->report.idx; /// Report Instance - 0 for boot reports and report map - - // Send the message - ke_msg_send(req); - } - } - - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } -static int hogpd_proto_mode_req_ind_handler(ke_msg_id_t const msgid, - struct hogpd_proto_mode_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ +static int hogpd_proto_mode_req_ind_handler( + ke_msg_id_t const msgid, struct hogpd_proto_mode_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { - if ((param->conidx == app_hid_env.conidx) && (param->operation == HOGPD_OP_PROT_UPDATE)) - { + if ((param->conidx == app_hid_env.conidx) && + (param->operation == HOGPD_OP_PROT_UPDATE)) { - //make use of param->proto_mode - struct hogpd_proto_mode_cfm *req = KE_MSG_ALLOC_DYN(HOGPD_PROTO_MODE_CFM, - prf_get_task_from_id(TASK_ID_HOGPD),/* src_id */ - TASK_APP, - hogpd_proto_mode_cfm, - 0); - /// Connection Index - req->conidx = app_hid_env.conidx; - /// Status of the request - req->status = GAP_ERR_NO_ERROR; - /// HIDS Instance - req->hid_idx = app_hid_env.conidx; - /// New Protocol Mode Characteristic Value - req->proto_mode = param->proto_mode; - + // make use of param->proto_mode + struct hogpd_proto_mode_cfm *req = KE_MSG_ALLOC_DYN( + HOGPD_PROTO_MODE_CFM, prf_get_task_from_id(TASK_ID_HOGPD), /* src_id */ + TASK_APP, hogpd_proto_mode_cfm, 0); + /// Connection Index + req->conidx = app_hid_env.conidx; + /// Status of the request + req->status = GAP_ERR_NO_ERROR; + /// HIDS Instance + req->hid_idx = app_hid_env.conidx; + /// New Protocol Mode Characteristic Value + req->proto_mode = param->proto_mode; - // Send the message - ke_msg_send(req); - } - else - { - struct hogpd_proto_mode_cfm *req = KE_MSG_ALLOC_DYN(HOGPD_PROTO_MODE_CFM, - prf_get_task_from_id(TASK_ID_HOGPD),/* src_id */ - TASK_APP, - hogpd_proto_mode_cfm, - 0); - /// Status of the request - req->status = ATT_ERR_APP_ERROR; + // Send the message + ke_msg_send(req); + } else { + struct hogpd_proto_mode_cfm *req = KE_MSG_ALLOC_DYN( + HOGPD_PROTO_MODE_CFM, prf_get_task_from_id(TASK_ID_HOGPD), /* src_id */ + TASK_APP, hogpd_proto_mode_cfm, 0); + /// Status of the request + req->status = ATT_ERR_APP_ERROR; - /// Connection Index - req->conidx = app_hid_env.conidx; - /// HIDS Instance - req->hid_idx = app_hid_env.conidx; - /// New Protocol Mode Characteristic Value - req->proto_mode = param->proto_mode; - - // Send the message - ke_msg_send(req); - } - return (KE_MSG_CONSUMED); + /// Connection Index + req->conidx = app_hid_env.conidx; + /// HIDS Instance + req->hid_idx = app_hid_env.conidx; + /// New Protocol Mode Characteristic Value + req->proto_mode = param->proto_mode; + + // Send the message + ke_msg_send(req); + } + return (KE_MSG_CONSUMED); } - static int hogpd_report_upd_handler(ke_msg_id_t const msgid, - struct hogpd_report_upd_rsp const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if (app_hid_env.conidx == param->conidx) - { - if (GAP_ERR_NO_ERROR == param->status) - { - if (app_hid_env.nb_report < APP_HID_NB_SEND_REPORT) - { - app_hid_env.nb_report++; - } - } - else - { - // we get this message if error occur while sending report - // most likely - disconnect - // Go back to the ready state - app_hid_env.state = APP_HID_IDLE; - // change mode - // restart adv - // Try to restart advertising if needed - //report was not success - need to restart??? - } + struct hogpd_report_upd_rsp const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + if (app_hid_env.conidx == param->conidx) { + if (GAP_ERR_NO_ERROR == param->status) { + if (app_hid_env.nb_report < APP_HID_NB_SEND_REPORT) { + app_hid_env.nb_report++; + } + } else { + // we get this message if error occur while sending report + // most likely - disconnect + // Go back to the ready state + app_hid_env.state = APP_HID_IDLE; + // change mode + // restart adv + // Try to restart advertising if needed + // report was not success - need to restart??? } - return (KE_MSG_CONSUMED); + } + return (KE_MSG_CONSUMED); } static int hogpd_enable_rsp_handler(ke_msg_id_t const msgid, - struct hogpd_enable_rsp const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ + struct hogpd_enable_rsp const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -828,60 +764,56 @@ static int hogpd_enable_rsp_handler(ke_msg_id_t const msgid, static int app_hid_mouse_timeout_timer_handler(ke_msg_id_t const msgid, void const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - app_hid_env.timer_enabled = false; + ke_task_id_t const src_id) { + app_hid_env.timer_enabled = false; - if (app_hid_env.state == APP_HID_READY) - { - // Requested connection parameters - struct gapc_conn_param conn_param; - // Length + if (app_hid_env.state == APP_HID_READY) { + // Requested connection parameters + struct gapc_conn_param conn_param; + // Length #if (NVDS_SUPPORT) - uint8_t length = NVDS_LEN_MOUSE_TIMEOUT; + uint8_t length = NVDS_LEN_MOUSE_TIMEOUT; #endif - // Timer value - uint16_t timer_val; + // Timer value + uint16_t timer_val; - /* - * Request an update of the connection parameters - * Requested connection interval: 10ms - * Latency: 200 - * Supervision Timeout: 5s - */ - conn_param.intv_min = 8; - conn_param.intv_max = 8; - conn_param.latency = 200; - conn_param.time_out = 500; + /* + * Request an update of the connection parameters + * Requested connection interval: 10ms + * Latency: 200 + * Supervision Timeout: 5s + */ + conn_param.intv_min = 8; + conn_param.intv_max = 8; + conn_param.latency = 200; + conn_param.time_out = 500; - appm_update_param(app_hid_env.conidx, &conn_param); + appm_update_param(app_hid_env.conidx, &conn_param); - // Go to the Wait for Report state - app_hid_env.state = APP_HID_WAIT_REP; + // Go to the Wait for Report state + app_hid_env.state = APP_HID_WAIT_REP; #if (NVDS_SUPPORT) - // Get the timer value from the NVDS - if (nvds_get(NVDS_TAG_MOUSE_ENERGY_SAFE, &length, (uint8_t *)&timer_val) != NVDS_OK) + // Get the timer value from the NVDS + if (nvds_get(NVDS_TAG_MOUSE_ENERGY_SAFE, &length, (uint8_t *)&timer_val) != + NVDS_OK) #endif - { - timer_val = APP_HID_SILENCE_DURATION_2; - } - - // Relaunch the timer - ke_timer_set(APP_HID_MOUSE_TIMEOUT_TIMER, TASK_APP, timer_val); - app_hid_env.timer_enabled = true; - } - else if (app_hid_env.state == APP_HID_WAIT_REP) { - // Disconnect the link with the device - appm_disconnect(app_hid_env.conidx); - - - // Go back to the ready state - app_hid_env.state = APP_HID_IDLE; + timer_val = APP_HID_SILENCE_DURATION_2; } - return (KE_MSG_CONSUMED); + // Relaunch the timer + ke_timer_set(APP_HID_MOUSE_TIMEOUT_TIMER, TASK_APP, timer_val); + app_hid_env.timer_enabled = true; + } else if (app_hid_env.state == APP_HID_WAIT_REP) { + // Disconnect the link with the device + appm_disconnect(app_hid_env.conidx); + + // Go back to the ready state + app_hid_env.state = APP_HID_IDLE; + } + + return (KE_MSG_CONSUMED); } /** @@ -896,14 +828,12 @@ static int app_hid_mouse_timeout_timer_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -static int app_hid_msg_dflt_handler(ke_msg_id_t const msgid, - void const *param, +static int app_hid_msg_dflt_handler(ke_msg_id_t const msgid, void const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Drop the message + ke_task_id_t const src_id) { + // Drop the message - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -919,25 +849,27 @@ void app_hid_set_report_map(void); */ /// Default State handlers definition -const struct ke_msg_handler app_hid_msg_handler_list[] = -{ - // Note: first message is latest message checked by kernel so default is put on top. - {KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_hid_msg_dflt_handler}, +const struct ke_msg_handler app_hid_msg_handler_list[] = { + // Note: first message is latest message checked by kernel so default is put + // on top. + {KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_hid_msg_dflt_handler}, - {HOGPD_ENABLE_RSP, (ke_msg_func_t)hogpd_enable_rsp_handler}, -/// notification configuration changed - {HOGPD_NTF_CFG_IND, (ke_msg_func_t)hogpd_ntf_cfg_ind_handler}, - {HOGPD_REPORT_REQ_IND, (ke_msg_func_t)hogpd_report_req_ind_handler}, - {HOGPD_PROTO_MODE_REQ_IND, (ke_msg_func_t)hogpd_proto_mode_req_ind_handler}, + {HOGPD_ENABLE_RSP, (ke_msg_func_t)hogpd_enable_rsp_handler}, + /// notification configuration changed + {HOGPD_NTF_CFG_IND, (ke_msg_func_t)hogpd_ntf_cfg_ind_handler}, + {HOGPD_REPORT_REQ_IND, (ke_msg_func_t)hogpd_report_req_ind_handler}, + {HOGPD_PROTO_MODE_REQ_IND, (ke_msg_func_t)hogpd_proto_mode_req_ind_handler}, - {HOGPD_CTNL_PT_IND, (ke_msg_func_t)hogpd_ctnl_pt_ind_handler}, + {HOGPD_CTNL_PT_IND, (ke_msg_func_t)hogpd_ctnl_pt_ind_handler}, - {HOGPD_REPORT_UPD_RSP, (ke_msg_func_t)hogpd_report_upd_handler}, - {APP_HID_MOUSE_TIMEOUT_TIMER, (ke_msg_func_t)app_hid_mouse_timeout_timer_handler}, + {HOGPD_REPORT_UPD_RSP, (ke_msg_func_t)hogpd_report_upd_handler}, + {APP_HID_MOUSE_TIMEOUT_TIMER, + (ke_msg_func_t)app_hid_mouse_timeout_timer_handler}, }; -const struct ke_state_handler app_hid_table_handler = - {&app_hid_msg_handler_list[0], (sizeof(app_hid_msg_handler_list)/sizeof(struct ke_msg_handler))}; +const struct ke_state_handler app_hid_table_handler = { + &app_hid_msg_handler_list[0], + (sizeof(app_hid_msg_handler_list) / sizeof(struct ke_msg_handler))}; #endif //(BLE_APP_HID) diff --git a/services/ble_app/app_hrps/app_hrps.c b/services/ble_app/app_hrps/app_hrps.c index ff5fc76..d7a0cbf 100644 --- a/services/ble_app/app_hrps/app_hrps.c +++ b/services/ble_app/app_hrps/app_hrps.c @@ -13,144 +13,134 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "rwip_config.h" // SW configuration +#include "rwip_config.h" // SW configuration #if (BLE_APP_HR) #include "app_hrps.h" #include "hrps.h" #include "hrps_task.h" -#include "app.h" // Application Definitions -#include "app_task.h" // application task definitions +#include "app.h" // Application Definitions +#include "app_task.h" // application task definitions +#include "arch.h" // Platform Definitions #include "co_bt.h" +#include "prf.h" #include "prf_types.h" #include "prf_utils.h" -#include "arch.h" // Platform Definitions -#include "prf.h" #include "string.h" struct app_hrps_env_tag app_hrps_env; -void app_hrps_init(void) -{ - // Reset the environment - memset(&app_hrps_env, 0x00, sizeof(app_hrps_env)); +void app_hrps_init(void) { + // Reset the environment + memset(&app_hrps_env, 0x00, sizeof(app_hrps_env)); - app_hrps_env.connectionIndex = INVALID_CONNECTION_INDEX; - app_hrps_env.isNotificationEnabled = false; + app_hrps_env.connectionIndex = INVALID_CONNECTION_INDEX; + app_hrps_env.isNotificationEnabled = false; } -void app_hrps_connected_evt_handler(uint8_t conidx) -{ - app_hrps_env.connectionIndex = conidx; +void app_hrps_connected_evt_handler(uint8_t conidx) { + app_hrps_env.connectionIndex = conidx; } -void app_hrps_disconnected_evt_handler(void) -{ - app_hrps_env.connectionIndex = INVALID_CONNECTION_INDEX; - app_hrps_env.isNotificationEnabled = false; +void app_hrps_disconnected_evt_handler(void) { + app_hrps_env.connectionIndex = INVALID_CONNECTION_INDEX; + app_hrps_env.isNotificationEnabled = false; } +void app_hrps_send_measument_via_notification(void) { + if (app_hrps_env.isNotificationEnabled) { + struct hrps_meas_send_req *req = + KE_MSG_ALLOC(HRPS_MEAS_SEND_REQ, prf_get_task_from_id(TASK_ID_HRPS), + TASK_APP, hrps_meas_send_req); -void app_hrps_send_measument_via_notification(void) -{ - if (app_hrps_env.isNotificationEnabled) { - struct hrps_meas_send_req *req = KE_MSG_ALLOC(HRPS_MEAS_SEND_REQ, - prf_get_task_from_id(TASK_ID_HRPS), - TASK_APP, - hrps_meas_send_req); + memcpy(req, &app_hrps_env.meas, sizeof(struct hrps_meas_send_req)); - memcpy(req, &app_hrps_env.meas, sizeof(struct hrps_meas_send_req)); - - ke_msg_send(req); - } -} - -void app_hrps_add_profile(void) -{ - TRACE(0,"app_hrps_add_profile"); - struct hrps_db_cfg* db_cfg; - - struct gapm_profile_task_add_cmd *req = KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, - TASK_GAPM, TASK_APP, - gapm_profile_task_add_cmd, sizeof(struct hrps_db_cfg)); - - - // Fill message - req->operation = GAPM_PROFILE_TASK_ADD; -#if BLE_CONNECTION_MAX>1 - req->sec_lvl = PERM(SVC_AUTH, ENABLE)|PERM(SVC_MI, ENABLE); -#else - req->sec_lvl = PERM(SVC_AUTH, ENABLE); -#endif - - req->prf_task_id = TASK_ID_HRPS; - req->app_task = TASK_APP; - req->start_hdl = 0; - - db_cfg = (struct hrps_db_cfg*) req->param; - - db_cfg->features = HRPS_BODY_SENSOR_LOC_CHAR_SUP | HRPS_ENGY_EXP_FEAT_SUP | HRPS_HR_MEAS_NTF_CFG; - - db_cfg->body_sensor_loc = 0; - - // Send the message ke_msg_send(req); + } } -static int app_hrps_msg_handler(ke_msg_id_t const msgid, - void const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Do nothing +void app_hrps_add_profile(void) { + TRACE(0, "app_hrps_add_profile"); + struct hrps_db_cfg *db_cfg; - return (KE_MSG_CONSUMED); + struct gapm_profile_task_add_cmd *req = + KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, TASK_GAPM, TASK_APP, + gapm_profile_task_add_cmd, sizeof(struct hrps_db_cfg)); + + // Fill message + req->operation = GAPM_PROFILE_TASK_ADD; +#if BLE_CONNECTION_MAX > 1 + req->sec_lvl = PERM(SVC_AUTH, ENABLE) | PERM(SVC_MI, ENABLE); +#else + req->sec_lvl = PERM(SVC_AUTH, ENABLE); +#endif + + req->prf_task_id = TASK_ID_HRPS; + req->app_task = TASK_APP; + req->start_hdl = 0; + + db_cfg = (struct hrps_db_cfg *)req->param; + + db_cfg->features = HRPS_BODY_SENSOR_LOC_CHAR_SUP | HRPS_ENGY_EXP_FEAT_SUP | + HRPS_HR_MEAS_NTF_CFG; + + db_cfg->body_sensor_loc = 0; + + // Send the message + ke_msg_send(req); } -static int app_hrps_measurement_ccc_changed_handler(ke_msg_id_t const msgid, - struct hrps_cfg_indntf_ind *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - TRACE(2,"%s cfg: %d", __func__, param->cfg_val); +static int app_hrps_msg_handler(ke_msg_id_t const msgid, void const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Do nothing - app_hrps_env.isNotificationEnabled = param->cfg_val; - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); +} + +static int app_hrps_measurement_ccc_changed_handler( + ke_msg_id_t const msgid, struct hrps_cfg_indntf_ind *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + TRACE(2, "%s cfg: %d", __func__, param->cfg_val); + + app_hrps_env.isNotificationEnabled = param->cfg_val; + return (KE_MSG_CONSUMED); } static int app_hrps_measurement_sent_handler(ke_msg_id_t const msgid, - void const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ + void const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } -static int app_hrps_ctrl_point_received_handler(ke_msg_id_t const msgid, - struct hrps_energy_exp_reset_ind *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - TRACE(1,"%s", __func__); +static int app_hrps_ctrl_point_received_handler( + ke_msg_id_t const msgid, struct hrps_energy_exp_reset_ind *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + TRACE(1, "%s", __func__); - app_hrps_send_measument_via_notification(); - return (KE_MSG_CONSUMED); + app_hrps_send_measument_via_notification(); + return (KE_MSG_CONSUMED); } /// Default State handlers definition -const struct ke_msg_handler hrps_msg_handler_list[] = -{ - // Note: first message is latest message checked by kernel so default is put on top. - {KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_hrps_msg_handler}, +const struct ke_msg_handler hrps_msg_handler_list[] = { + // Note: first message is latest message checked by kernel so default is put + // on top. + {KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_hrps_msg_handler}, - {HRPS_CFG_INDNTF_IND, (ke_msg_func_t)app_hrps_measurement_ccc_changed_handler}, - {HRP_MEASUREMENT_DATA_SENT, (ke_msg_func_t)app_hrps_measurement_sent_handler}, - {HRPS_ENERGY_EXP_RESET_IND, (ke_msg_func_t)app_hrps_ctrl_point_received_handler}, + {HRPS_CFG_INDNTF_IND, + (ke_msg_func_t)app_hrps_measurement_ccc_changed_handler}, + {HRP_MEASUREMENT_DATA_SENT, + (ke_msg_func_t)app_hrps_measurement_sent_handler}, + {HRPS_ENERGY_EXP_RESET_IND, + (ke_msg_func_t)app_hrps_ctrl_point_received_handler}, }; -const struct ke_state_handler app_hrps_table_handler = - {&hrps_msg_handler_list[0], (sizeof(hrps_msg_handler_list)/sizeof(struct ke_msg_handler))}; +const struct ke_state_handler app_hrps_table_handler = { + &hrps_msg_handler_list[0], + (sizeof(hrps_msg_handler_list) / sizeof(struct ke_msg_handler))}; #endif diff --git a/services/ble_app/app_htp/app_ht.c b/services/ble_app/app_htp/app_ht.c index 3ea8f1a..3fc407d 100644 --- a/services/ble_app/app_htp/app_ht.c +++ b/services/ble_app/app_htp/app_ht.c @@ -20,7 +20,7 @@ **************************************************************************************** */ -#include "rwip_config.h" // SW configuration +#include "rwip_config.h" // SW configuration #if (BLE_APP_HT) @@ -29,14 +29,14 @@ **************************************************************************************** */ -#include "app_ht.h" // Health Thermometer Application Definitions -#include "app.h" // Application Definitions -#include "app_task.h" // application task definitions -#include "htpt_task.h" // health thermometer functions +#include "app.h" // Application Definitions +#include "app_ht.h" // Health Thermometer Application Definitions +#include "app_task.h" // application task definitions +#include "arch.h" // Platform Definitions #include "co_bt.h" +#include "htpt_task.h" // health thermometer functions #include "prf_types.h" #include "prf_utils.h" -#include "arch.h" // Platform Definitions #include "co_math.h" #include "ke_timer.h" @@ -44,7 +44,7 @@ #if (DISPLAY_SUPPORT) #include "app_display.h" #include "display.h" -#endif //DISPLAY_SUPPORT +#endif // DISPLAY_SUPPORT /* * DEFINES @@ -52,13 +52,13 @@ */ /// Initial Temperature Value : 37c -#define APP_HT_TEMP_VALUE_INIT (3700) +#define APP_HT_TEMP_VALUE_INIT (3700) /// Temperature Step -#define APP_HT_TEMP_STEP_INIT (10) +#define APP_HT_TEMP_STEP_INIT (10) /// Measurement Interval Value Min -#define APP_HT_MEAS_INTV_MIN (1) +#define APP_HT_MEAS_INTV_MIN (1) /// Measurement Interval Value Max -#define APP_HT_MEAS_INTV_MAX (30) +#define APP_HT_MEAS_INTV_MAX (30) /* * GLOBAL VARIABLE DEFINITIONS @@ -73,70 +73,66 @@ struct app_ht_env_tag app_ht_env; **************************************************************************************** */ -static void app_ht_temp_send(void) -{ - // Temperature Value - int32_t value = (int32_t)(app_ht_env.temp_value); +static void app_ht_temp_send(void) { + // Temperature Value + int32_t value = (int32_t)(app_ht_env.temp_value); - // The value is a float value, set the exponent - value |= 0xFE000000; + // The value is a float value, set the exponent + value |= 0xFE000000; - // Allocate the HTPT_TEMP_SEND_REQ message - struct htpt_temp_send_req * req = KE_MSG_ALLOC(HTPT_TEMP_SEND_REQ, - prf_get_task_from_id(TASK_ID_HTPT), - TASK_APP, - htpt_temp_send_req); + // Allocate the HTPT_TEMP_SEND_REQ message + struct htpt_temp_send_req *req = + KE_MSG_ALLOC(HTPT_TEMP_SEND_REQ, prf_get_task_from_id(TASK_ID_HTPT), + TASK_APP, htpt_temp_send_req); - // Stable => Temperature Measurement Char. - req->stable_meas = 0x01; + // Stable => Temperature Measurement Char. + req->stable_meas = 0x01; - // Temperature Measurement Value - req->temp_meas.temp = value; -// req->temp_meas.time_stamp = 0; - req->temp_meas.flags = HTP_FLAG_CELSIUS | HTP_FLAG_TYPE; - req->temp_meas.type = app_ht_env.temp_meas_type; + // Temperature Measurement Value + req->temp_meas.temp = value; + // req->temp_meas.time_stamp = 0; + req->temp_meas.flags = HTP_FLAG_CELSIUS | HTP_FLAG_TYPE; + req->temp_meas.type = app_ht_env.temp_meas_type; - ke_msg_send(req); + ke_msg_send(req); } -static void app_ht_update_type_string(uint8_t temp_type) -{ - switch (temp_type) - { - case 0: - strcpy(app_ht_env.temp_type_string, "NONE"); - break; - case 1: - strcpy(app_ht_env.temp_type_string, "ARMPIT"); - break; - case 2: - strcpy(app_ht_env.temp_type_string, "BODY"); - break; - case 3: - strcpy(app_ht_env.temp_type_string, "EAR"); - break; - case 4: - strcpy(app_ht_env.temp_type_string, "FINGER"); - break; - case 5: - strcpy(app_ht_env.temp_type_string, "GASTRO-INT"); - break; - case 6: - strcpy(app_ht_env.temp_type_string, "MOUTH"); - break; - case 7: - strcpy(app_ht_env.temp_type_string, "RECTUM"); - break; - case 8: - strcpy(app_ht_env.temp_type_string, "TOE"); - break; - case 9: - strcpy(app_ht_env.temp_type_string, "TYMPANUM"); - break; - default: - strcpy(app_ht_env.temp_type_string, "UNKNOWN"); - break; - } +static void app_ht_update_type_string(uint8_t temp_type) { + switch (temp_type) { + case 0: + strcpy(app_ht_env.temp_type_string, "NONE"); + break; + case 1: + strcpy(app_ht_env.temp_type_string, "ARMPIT"); + break; + case 2: + strcpy(app_ht_env.temp_type_string, "BODY"); + break; + case 3: + strcpy(app_ht_env.temp_type_string, "EAR"); + break; + case 4: + strcpy(app_ht_env.temp_type_string, "FINGER"); + break; + case 5: + strcpy(app_ht_env.temp_type_string, "GASTRO-INT"); + break; + case 6: + strcpy(app_ht_env.temp_type_string, "MOUTH"); + break; + case 7: + strcpy(app_ht_env.temp_type_string, "RECTUM"); + break; + case 8: + strcpy(app_ht_env.temp_type_string, "TOE"); + break; + case 9: + strcpy(app_ht_env.temp_type_string, "TYMPANUM"); + break; + default: + strcpy(app_ht_env.temp_type_string, "UNKNOWN"); + break; + } } /* @@ -144,85 +140,79 @@ static void app_ht_update_type_string(uint8_t temp_type) **************************************************************************************** */ -void app_ht_init(void) -{ - // Reset the environment - memset(&app_ht_env, 0, sizeof(app_ht_env)); +void app_ht_init(void) { + // Reset the environment + memset(&app_ht_env, 0, sizeof(app_ht_env)); - // Initial measurement interval : 0s - app_ht_env.htpt_meas_intv = 5; - // Initial temperature value : 37.00 C - app_ht_env.temp_value = APP_HT_TEMP_VALUE_INIT; - // Initial temperature step : 0.20 C - app_ht_env.temp_step = APP_HT_TEMP_STEP_INIT; - // Initial temperature type : ARMPIT - app_ht_env.temp_meas_type = 1; + // Initial measurement interval : 0s + app_ht_env.htpt_meas_intv = 5; + // Initial temperature value : 37.00 C + app_ht_env.temp_value = APP_HT_TEMP_VALUE_INIT; + // Initial temperature step : 0.20 C + app_ht_env.temp_step = APP_HT_TEMP_STEP_INIT; + // Initial temperature type : ARMPIT + app_ht_env.temp_meas_type = 1; - //TODO: Add a state for the module + // TODO: Add a state for the module } -void app_stop_timer (void) -{ - // Stop the timer used for the measurement interval if enabled - if (app_ht_env.timer_enable) - { - ke_timer_clear(APP_HT_MEAS_INTV_TIMER, TASK_APP); - app_ht_env.timer_enable = false; - } +void app_stop_timer(void) { + // Stop the timer used for the measurement interval if enabled + if (app_ht_env.timer_enable) { + ke_timer_clear(APP_HT_MEAS_INTV_TIMER, TASK_APP); + app_ht_env.timer_enable = false; + } } -void app_ht_add_hts(void) -{ - struct htpt_db_cfg* db_cfg; - // Allocate the HTPT_CREATE_DB_REQ - struct gapm_profile_task_add_cmd *req = KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, - TASK_GAPM, TASK_APP, - gapm_profile_task_add_cmd, sizeof(struct htpt_db_cfg)); - - // Fill message - req->operation = GAPM_PROFILE_TASK_ADD; -#if BLE_CONNECTION_MAX>1 - req->sec_lvl = PERM(SVC_AUTH, ENABLE)|PERM(SVC_MI, ENABLE); +void app_ht_add_hts(void) { + struct htpt_db_cfg *db_cfg; + // Allocate the HTPT_CREATE_DB_REQ + struct gapm_profile_task_add_cmd *req = + KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, TASK_GAPM, TASK_APP, + gapm_profile_task_add_cmd, sizeof(struct htpt_db_cfg)); + + // Fill message + req->operation = GAPM_PROFILE_TASK_ADD; +#if BLE_CONNECTION_MAX > 1 + req->sec_lvl = PERM(SVC_AUTH, ENABLE) | PERM(SVC_MI, ENABLE); #else - req->sec_lvl = PERM(SVC_AUTH, ENABLE); -#endif + req->sec_lvl = PERM(SVC_AUTH, ENABLE); +#endif - req->prf_task_id = TASK_ID_HTPT; - req->app_task = TASK_APP; - req->start_hdl = 0; + req->prf_task_id = TASK_ID_HTPT; + req->app_task = TASK_APP; + req->start_hdl = 0; - // Set parameters - db_cfg = (struct htpt_db_cfg* ) req->param; - // All features are supported - db_cfg->features = HTPT_ALL_FEAT_SUP; + // Set parameters + db_cfg = (struct htpt_db_cfg *)req->param; + // All features are supported + db_cfg->features = HTPT_ALL_FEAT_SUP; - // Measurement Interval range - db_cfg->valid_range_min = APP_HT_MEAS_INTV_MIN; - db_cfg->valid_range_max = APP_HT_MEAS_INTV_MAX; + // Measurement Interval range + db_cfg->valid_range_min = APP_HT_MEAS_INTV_MIN; + db_cfg->valid_range_max = APP_HT_MEAS_INTV_MAX; - // Measurement - db_cfg->temp_type = app_ht_env.temp_meas_type; - db_cfg->meas_intv = app_ht_env.htpt_meas_intv; + // Measurement + db_cfg->temp_type = app_ht_env.temp_meas_type; + db_cfg->meas_intv = app_ht_env.htpt_meas_intv; - // Send the message - ke_msg_send(req); + // Send the message + ke_msg_send(req); } -void app_ht_enable_prf(uint8_t conidx) -{ - // Allocate the message - struct htpt_enable_req * req = KE_MSG_ALLOC(HTPT_ENABLE_REQ, - prf_get_task_from_id(TASK_ID_HTPT), - TASK_APP, - htpt_enable_req); +void app_ht_enable_prf(uint8_t conidx) { + // Allocate the message + struct htpt_enable_req *req = + KE_MSG_ALLOC(HTPT_ENABLE_REQ, prf_get_task_from_id(TASK_ID_HTPT), + TASK_APP, htpt_enable_req); - // Fill in the parameter structure - req->conidx = conidx; - // NTF/IND initial status - Disabled - req->ntf_ind_cfg = PRF_CLI_STOP_NTFIND; + // Fill in the parameter structure + req->conidx = conidx; + // NTF/IND initial status - Disabled + req->ntf_ind_cfg = PRF_CLI_STOP_NTFIND; - // Send the message - ke_msg_send(req); + // Send the message + ke_msg_send(req); } /** @@ -231,53 +221,47 @@ void app_ht_enable_prf(uint8_t conidx) **************************************************************************************** */ -void app_ht_temp_inc(void) -{ - app_ht_env.temp_value += app_ht_env.temp_step; +void app_ht_temp_inc(void) { + app_ht_env.temp_value += app_ht_env.temp_step; - #if (DISPLAY_SUPPORT) - app_display_update_temp_val_screen(app_ht_env.temp_value); - #endif //DISPLAY_SUPPORT +#if (DISPLAY_SUPPORT) + app_display_update_temp_val_screen(app_ht_env.temp_value); +#endif // DISPLAY_SUPPORT - app_ht_temp_send(); + app_ht_temp_send(); } -void app_ht_temp_dec(void) -{ - app_ht_env.temp_value -= app_ht_env.temp_step; +void app_ht_temp_dec(void) { + app_ht_env.temp_value -= app_ht_env.temp_step; - #if (DISPLAY_SUPPORT) - app_display_update_temp_val_screen(app_ht_env.temp_value); - #endif //DISPLAY_SUPPORT +#if (DISPLAY_SUPPORT) + app_display_update_temp_val_screen(app_ht_env.temp_value); +#endif // DISPLAY_SUPPORT - app_ht_temp_send(); + app_ht_temp_send(); } -void app_ht_temp_type_inc(void) -{ - app_ht_env.temp_meas_type = (uint8_t)(((int)app_ht_env.temp_meas_type + 1)%10); +void app_ht_temp_type_inc(void) { + app_ht_env.temp_meas_type = + (uint8_t)(((int)app_ht_env.temp_meas_type + 1) % 10); - #if (DISPLAY_SUPPORT) - app_ht_update_type_string(app_ht_env.temp_meas_type); - app_display_update_temp_type_screen(app_ht_env.temp_type_string); - #endif //DISPLAY_SUPPORT +#if (DISPLAY_SUPPORT) + app_ht_update_type_string(app_ht_env.temp_meas_type); + app_display_update_temp_type_screen(app_ht_env.temp_type_string); +#endif // DISPLAY_SUPPORT } -void app_ht_temp_type_dec(void) -{ - if (((int)app_ht_env.temp_meas_type-1) < 0) - { - app_ht_env.temp_meas_type = 0x09; - } - else - { - app_ht_env.temp_meas_type = app_ht_env.temp_meas_type - 1; - } +void app_ht_temp_type_dec(void) { + if (((int)app_ht_env.temp_meas_type - 1) < 0) { + app_ht_env.temp_meas_type = 0x09; + } else { + app_ht_env.temp_meas_type = app_ht_env.temp_meas_type - 1; + } - #if DISPLAY_SUPPORT - app_ht_update_type_string(app_ht_env.temp_meas_type); - app_display_update_temp_type_screen(app_ht_env.temp_type_string); - #endif //DISPLAY_SUPPORT +#if DISPLAY_SUPPORT + app_ht_update_type_string(app_ht_env.temp_meas_type); + app_display_update_temp_type_screen(app_ht_env.temp_type_string); +#endif // DISPLAY_SUPPORT } /**************************************************************************************** @@ -286,9 +270,9 @@ void app_ht_temp_type_dec(void) /** **************************************************************************************** - * @brief Handles measurement interval start indication from the Health Thermometer - * profile. - * Start or stop a timer following the value of the param intv. + * @brief Handles measurement interval start indication from the Health + *Thermometer profile. Start or stop a timer following the value of the param + *intv. * * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. @@ -298,77 +282,66 @@ void app_ht_temp_type_dec(void) * @return If the message was consumed or not. **************************************************************************************** */ -static int htpt_meas_intv_chg_req_ind_handler(ke_msg_id_t const msgid, - struct htpt_meas_intv_chg_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Store the received Measurement Interval value - app_ht_env.htpt_meas_intv = param->intv; +static int htpt_meas_intv_chg_req_ind_handler( + ke_msg_id_t const msgid, struct htpt_meas_intv_chg_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Store the received Measurement Interval value + app_ht_env.htpt_meas_intv = param->intv; - // Check the new Measurement Interval Value - if (app_ht_env.htpt_meas_intv != 0) - { - // Check if a Timer already exists - if (!app_ht_env.timer_enable) - { - // Set a Timer - ke_timer_set(APP_HT_MEAS_INTV_TIMER, TASK_APP, app_ht_env.htpt_meas_intv*100); - app_ht_env.timer_enable = true; - } - else - { - // Clear the previous timer - ke_timer_clear(APP_HT_MEAS_INTV_TIMER, TASK_APP); - // Create a new timer with the received measurement interval - ke_timer_set(APP_HT_MEAS_INTV_TIMER, TASK_APP, app_ht_env.htpt_meas_intv*100); - } + // Check the new Measurement Interval Value + if (app_ht_env.htpt_meas_intv != 0) { + // Check if a Timer already exists + if (!app_ht_env.timer_enable) { + // Set a Timer + ke_timer_set(APP_HT_MEAS_INTV_TIMER, TASK_APP, + app_ht_env.htpt_meas_intv * 100); + app_ht_env.timer_enable = true; + } else { + // Clear the previous timer + ke_timer_clear(APP_HT_MEAS_INTV_TIMER, TASK_APP); + // Create a new timer with the received measurement interval + ke_timer_set(APP_HT_MEAS_INTV_TIMER, TASK_APP, + app_ht_env.htpt_meas_intv * 100); } - else - { - // Check if a Timer exists - if (app_ht_env.timer_enable) - { - // Measurement Interval is 0, clear the timer - ke_timer_clear(APP_HT_MEAS_INTV_TIMER, TASK_APP); - app_ht_env.timer_enable = false; - } + } else { + // Check if a Timer exists + if (app_ht_env.timer_enable) { + // Measurement Interval is 0, clear the timer + ke_timer_clear(APP_HT_MEAS_INTV_TIMER, TASK_APP); + app_ht_env.timer_enable = false; } + } - // Allocate the message - struct htpt_meas_intv_chg_cfm * cfm = KE_MSG_ALLOC(HTPT_MEAS_INTV_CHG_CFM, - prf_get_task_from_id(TASK_ID_HTPT), - TASK_APP, - htpt_meas_intv_chg_cfm); + // Allocate the message + struct htpt_meas_intv_chg_cfm *cfm = + KE_MSG_ALLOC(HTPT_MEAS_INTV_CHG_CFM, prf_get_task_from_id(TASK_ID_HTPT), + TASK_APP, htpt_meas_intv_chg_cfm); - // Set data - cfm->conidx = KE_IDX_GET(dest_id); - cfm->status = 0; + // Set data + cfm->conidx = KE_IDX_GET(dest_id); + cfm->status = 0; - // Send the message - ke_msg_send(cfm); + // Send the message + ke_msg_send(cfm); - - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } static int htpt_temp_send_rsp_handler(ke_msg_id_t const msgid, - struct htpt_temp_send_rsp const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Do nothing - return (KE_MSG_CONSUMED); + struct htpt_temp_send_rsp const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Do nothing + return (KE_MSG_CONSUMED); } static int htpt_cfg_indntf_ind_handler(ke_msg_id_t const msgid, - struct htpt_cfg_indntf_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Do nothing + struct htpt_cfg_indntf_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Do nothing - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -386,36 +359,35 @@ static int htpt_cfg_indntf_ind_handler(ke_msg_id_t const msgid, static int app_ht_meas_intv_timer_handler(ke_msg_id_t const msgid, void const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Random generation of a temperature value - uint32_t rand_temp_step; - // Sign used to know if the temperature will be increased or decreased - int8_t sign; + ke_task_id_t const src_id) { + // Random generation of a temperature value + uint32_t rand_temp_step; + // Sign used to know if the temperature will be increased or decreased + int8_t sign; - // Generate temperature step - rand_temp_step = (uint32_t)(co_rand_word()%20); - // Increase or decrease the temperature value - sign = (int8_t)(rand_temp_step & 0x00000001); + // Generate temperature step + rand_temp_step = (uint32_t)(co_rand_word() % 20); + // Increase or decrease the temperature value + sign = (int8_t)(rand_temp_step & 0x00000001); - if (!sign) - { - sign = -1; - } + if (!sign) { + sign = -1; + } - app_ht_env.temp_value += sign*rand_temp_step; + app_ht_env.temp_value += sign * rand_temp_step; - // Send the new temperature - app_ht_temp_send(); + // Send the new temperature + app_ht_temp_send(); - #if (DISPLAY_SUPPORT) - app_display_update_temp_val_screen(app_ht_env.temp_value); - #endif //DISPLAY_SUPPORT +#if (DISPLAY_SUPPORT) + app_display_update_temp_val_screen(app_ht_env.temp_value); +#endif // DISPLAY_SUPPORT - // Reset the Timer (Measurement Interval is not 0 if we are here) - ke_timer_set(APP_HT_MEAS_INTV_TIMER, TASK_APP, app_ht_env.htpt_meas_intv*100); + // Reset the Timer (Measurement Interval is not 0 if we are here) + ke_timer_set(APP_HT_MEAS_INTV_TIMER, TASK_APP, + app_ht_env.htpt_meas_intv * 100); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -430,14 +402,12 @@ static int app_ht_meas_intv_timer_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -static int app_ht_msg_handler(ke_msg_id_t const msgid, - void const *param, +static int app_ht_msg_handler(ke_msg_id_t const msgid, void const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Do nothing + ke_task_id_t const src_id) { + // Do nothing - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /* @@ -446,22 +416,24 @@ static int app_ht_msg_handler(ke_msg_id_t const msgid, */ /// Default State handlers definition -const struct ke_msg_handler app_ht_msg_handler_list[] = -{ - // Note: first message is latest message checked by kernel so default is put on top. - {KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_ht_msg_handler}, +const struct ke_msg_handler app_ht_msg_handler_list[] = { + // Note: first message is latest message checked by kernel so default is put + // on top. + {KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_ht_msg_handler}, -// {HTPT_ENABLE_RSP, (ke_msg_func_t)htpt_enable_rsp_handler}, - {HTPT_TEMP_SEND_RSP, (ke_msg_func_t)htpt_temp_send_rsp_handler}, - {HTPT_MEAS_INTV_CHG_REQ_IND, (ke_msg_func_t)htpt_meas_intv_chg_req_ind_handler}, - {HTPT_CFG_INDNTF_IND, (ke_msg_func_t)htpt_cfg_indntf_ind_handler}, + // {HTPT_ENABLE_RSP, (ke_msg_func_t)htpt_enable_rsp_handler}, + {HTPT_TEMP_SEND_RSP, (ke_msg_func_t)htpt_temp_send_rsp_handler}, + {HTPT_MEAS_INTV_CHG_REQ_IND, + (ke_msg_func_t)htpt_meas_intv_chg_req_ind_handler}, + {HTPT_CFG_INDNTF_IND, (ke_msg_func_t)htpt_cfg_indntf_ind_handler}, - {APP_HT_MEAS_INTV_TIMER, (ke_msg_func_t)app_ht_meas_intv_timer_handler}, + {APP_HT_MEAS_INTV_TIMER, (ke_msg_func_t)app_ht_meas_intv_timer_handler}, }; -const struct ke_state_handler app_ht_table_handler = - {&app_ht_msg_handler_list[0], (sizeof(app_ht_msg_handler_list)/sizeof(struct ke_msg_handler))}; +const struct ke_state_handler app_ht_table_handler = { + &app_ht_msg_handler_list[0], + (sizeof(app_ht_msg_handler_list) / sizeof(struct ke_msg_handler))}; -#endif //BLE_APP_HT +#endif // BLE_APP_HT /// @} APP diff --git a/services/ble_app/app_main/app.c b/services/ble_app/app_main/app.c index b23a700..44c0d56 100644 --- a/services/ble_app/app_main/app.c +++ b/services/ble_app/app_main/app.c @@ -24,22 +24,22 @@ **************************************************************************************** */ -#include "rwip_config.h" // SW configuration +#include "rwip_config.h" // SW configuration #if (BLE_APP_PRESENT) #include -#include "app_task.h" // Application task Definition -#include "app.h" // Application Definition -#include "gap.h" // GAP Definition -#include "tgt_hardware.h" +#include "app.h" // Application Definition +#include "app_task.h" // Application task Definition +#include "gap.h" // GAP Definition +#include "gapc_task.h" // GAP Controller Task API #include "gapm.h" -#include "gapm_task.h" // GAP Manager Task API -#include "gapc_task.h" // GAP Controller Task API +#include "gapm_task.h" // GAP Manager Task API +#include "tgt_hardware.h" #include "gattc_task.h" -#include "co_bt.h" // Common BT Definition -#include "co_math.h" // Common Maths Definition +#include "co_bt.h" // Common BT Definition +#include "co_math.h" // Common Maths Definition #include "l2cc.h" #include "l2cc_pdu.h" @@ -51,87 +51,86 @@ #include "tgt_hardware.h" #endif #ifdef __AI_VOICE__ -#include "app_ai_ble.h" // AI Voice Application Definitions -#endif //(__AI_VOICE__) +#include "app_ai_ble.h" // AI Voice Application Definitions +#endif //(__AI_VOICE__) #if (BLE_APP_SEC) -#include "app_sec.h" // Application security Definition -#endif // (BLE_APP_SEC) - +#include "app_sec.h" // Application security Definition +#endif // (BLE_APP_SEC) #if (BLE_APP_DATAPATH_SERVER) -#include "app_datapath_server.h" // Data Path Server Application Definitions -#endif //(BLE_APP_DATAPATH_SERVER) +#include "app_datapath_server.h" // Data Path Server Application Definitions +#endif //(BLE_APP_DATAPATH_SERVER) #if (BLE_APP_DIS) -#include "app_dis.h" // Device Information Service Application Definitions -#endif //(BLE_APP_DIS) +#include "app_dis.h" // Device Information Service Application Definitions +#endif //(BLE_APP_DIS) #if (BLE_APP_BATT) -#include "app_batt.h" // Battery Application Definitions -#endif //(BLE_APP_DIS) +#include "app_batt.h" // Battery Application Definitions +#endif //(BLE_APP_DIS) #if (BLE_APP_HID) -#include "app_hid.h" // HID Application Definitions -#endif //(BLE_APP_HID) +#include "app_hid.h" // HID Application Definitions +#endif //(BLE_APP_HID) #if (BLE_APP_VOICEPATH) -#include "app_voicepath_ble.h" // Voice Path Application Definitions -#endif //(BLE_APP_VOICEPATH) +#include "app_voicepath_ble.h" // Voice Path Application Definitions +#endif //(BLE_APP_VOICEPATH) #if (BLE_APP_OTA) -#include "app_ota.h" // OTA Application Definitions -#endif //(BLE_APP_OTA) +#include "app_ota.h" // OTA Application Definitions +#endif //(BLE_APP_OTA) #if (BLE_APP_TOTA) -#include "app_tota_ble.h" // OTA Application Definitions -#endif //(BLE_APP_TOTA) +#include "app_tota_ble.h" // OTA Application Definitions +#endif //(BLE_APP_TOTA) #if (BLE_APP_ANCC) -#include "app_ancc.h" // ANCC Application Definitions -#endif //(BLE_APP_ANCC) +#include "app_ancc.h" // ANCC Application Definitions +#endif //(BLE_APP_ANCC) #if (BLE_APP_AMS) -#include "app_amsc.h" // AMS Module Definition -#endif // (BLE_APP_AMS) +#include "app_amsc.h" // AMS Module Definition +#endif // (BLE_APP_AMS) #if (BLE_APP_GFPS) -#include "app_gfps.h" // Google Fast Pair Service Definitions +#include "app_gfps.h" // Google Fast Pair Service Definitions #endif #if (DISPLAY_SUPPORT) -#include "app_display.h" // Application Display Definition -#endif //(DISPLAY_SUPPORT) +#include "app_display.h" // Application Display Definition +#endif //(DISPLAY_SUPPORT) #ifdef BLE_APP_AM0 -#include "am0_app.h" // Audio Mode 0 Application -#endif //defined(BLE_APP_AM0) +#include "am0_app.h" // Audio Mode 0 Application +#endif // defined(BLE_APP_AM0) #if (NVDS_SUPPORT) -#include "nvds.h" // NVDS Definitions -#endif //(NVDS_SUPPORT) +#include "nvds.h" // NVDS Definitions +#endif //(NVDS_SUPPORT) +#include "app_ble_mode_switch.h" +#include "app_bt.h" +#include "apps.h" +#include "besbt.h" +#include "ble_app_dbg.h" #include "cmsis_os.h" +#include "crc16.h" #include "ke_timer.h" #include "nvrecord.h" -#include "ble_app_dbg.h" -#include "app_bt.h" -#include "app_ble_mode_switch.h" -#include "apps.h" -#include "crc16.h" -#include "besbt.h" #ifdef BISTO_ENABLED #include "gsound_service.h" #endif #if defined(__INTERCONNECTION__) -#include "app_bt.h" #include "app_battery.h" +#include "app_bt.h" #endif #if (BLE_APP_TILE) -#include "tile_target_ble.h" #include "tile_service.h" +#include "tile_target_ble.h" #endif #if defined(IBRT) @@ -151,17 +150,17 @@ **************************************************************************************** */ /// Default Device Name if no value can be found in NVDS -#define APP_DFLT_DEVICE_NAME ("BES_BLE") -#define APP_DFLT_DEVICE_NAME_LEN (sizeof(APP_DFLT_DEVICE_NAME)) +#define APP_DFLT_DEVICE_NAME ("BES_BLE") +#define APP_DFLT_DEVICE_NAME_LEN (sizeof(APP_DFLT_DEVICE_NAME)) #if (BLE_APP_HID) // HID Mouse -#define DEVICE_NAME "Hid Mouse" +#define DEVICE_NAME "Hid Mouse" #else -#define DEVICE_NAME "RW DEVICE" +#define DEVICE_NAME "RW DEVICE" #endif -#define DEVICE_NAME_SIZE sizeof(DEVICE_NAME) +#define DEVICE_NAME_SIZE sizeof(DEVICE_NAME) /** * UUID List part of ADV Data @@ -175,14 +174,13 @@ */ #if (BLE_APP_HT) -#define APP_HT_ADV_DATA_UUID "\x03\x03\x09\x18" -#define APP_HT_ADV_DATA_UUID_LEN (4) +#define APP_HT_ADV_DATA_UUID "\x03\x03\x09\x18" +#define APP_HT_ADV_DATA_UUID_LEN (4) #endif //(BLE_APP_HT) - #if (BLE_APP_HID) -#define APP_HID_ADV_DATA_UUID "\x03\x03\x12\x18" -#define APP_HID_ADV_DATA_UUID_LEN (4) +#define APP_HID_ADV_DATA_UUID "\x03\x03\x12\x18" +#define APP_HID_ADV_DATA_UUID_LEN (4) #endif //(BLE_APP_HID) #if (BLE_APP_DATAPATH_SERVER) @@ -191,8 +189,9 @@ * x07 - Complete list of 16-bit UUIDs available * .... the 128 bit UUIDs */ -#define APP_DATAPATH_SERVER_ADV_DATA_UUID "\x11\x07\x9e\x34\x9B\x5F\x80\x00\x00\x80\x00\x10\x00\x00\x00\x01\x00\x01" -#define APP_DATAPATH_SERVER_ADV_DATA_UUID_LEN (18) +#define APP_DATAPATH_SERVER_ADV_DATA_UUID \ + "\x11\x07\x9e\x34\x9B\x5F\x80\x00\x00\x80\x00\x10\x00\x00\x00\x01\x00\x01" +#define APP_DATAPATH_SERVER_ADV_DATA_UUID_LEN (18) #endif //(BLE_APP_HT) /** @@ -207,26 +206,24 @@ */ #if (BLE_APP_HT) -#define APP_HT_ADV_DATA_APPEARANCE "\x03\x19\x00\x03" +#define APP_HT_ADV_DATA_APPEARANCE "\x03\x19\x00\x03" #endif //(BLE_APP_HT) #if (BLE_APP_HID) -#define APP_HID_ADV_DATA_APPEARANCE "\x03\x19\xC2\x03" +#define APP_HID_ADV_DATA_APPEARANCE "\x03\x19\xC2\x03" #endif //(BLE_APP_HID) -#define APP_ADV_DATA_APPEARANCE_LEN (4) - - +#define APP_ADV_DATA_APPEARANCE_LEN (4) /** * Advertising Parameters */ #if (BLE_APP_HID) /// Default Advertising duration - 30s (in multiple of 10ms) -#define APP_DFLT_ADV_DURATION (3000) +#define APP_DFLT_ADV_DURATION (3000) #endif //(BLE_APP_HID) /// Advertising channel map - 37, 38, 39 -#define APP_ADV_CHMAP (0x07) +#define APP_ADV_CHMAP (0x07) /* * TYPE DEFINITIONS @@ -241,132 +238,132 @@ typedef void (*appm_add_svc_func_t)(void); */ /// List of service to add in the database -enum appm_svc_list -{ - #if (BLE_APP_HT) - APPM_SVC_HTS, - #endif //(BLE_APP_HT) - #if (BLE_APP_DIS) - APPM_SVC_DIS, - #endif //(BLE_APP_DIS) - #if (BLE_APP_BATT) - APPM_SVC_BATT, - #endif //(BLE_APP_BATT) - #if (BLE_APP_HID) - APPM_SVC_HIDS, - #endif //(BLE_APP_HID) - #ifdef BLE_APP_AM0 - APPM_SVC_AM0_HAS, - #endif //defined(BLE_APP_AM0) - #if (BLE_APP_HR) - APPM_SVC_HRP, - #endif - #if (BLE_APP_DATAPATH_SERVER) - APPM_SVC_DATAPATH_SERVER, - #endif //(BLE_APP_DATAPATH_SERVER) - #if (BLE_APP_VOICEPATH) - APPM_SVC_VOICEPATH, - #ifdef BISTO_ENABLED - APPM_SVC_BMS, - #endif - #endif //(BLE_APP_VOICEPATH) - #if (ANCS_PROXY_ENABLE) - APPM_SVC_ANCSP, - APPM_SVC_AMSP, - #endif - #if (BLE_APP_ANCC) - APPM_SVC_ANCC, - #endif //(BLE_APP_ANCC) - #if (BLE_APP_AMS) - APPM_SVC_AMSC, - #endif //(BLE_APP_AMS) - #if (BLE_APP_OTA) - APPM_SVC_OTA, - #endif //(BLE_APP_OTA) - #if (BLE_APP_GFPS) - APPM_SVC_GFPS, - #endif //(BLE_APP_GFPS) - #if (BLE_AI_VOICE) - APPM_AI_SMARTVOICE, - #endif //(BLE_AI_VOICE) - #if (BLE_APP_TOTA) - APPM_SVC_TOTA, - #endif //(BLE_APP_TOTA) +enum appm_svc_list { +#if (BLE_APP_HT) + APPM_SVC_HTS, +#endif //(BLE_APP_HT) +#if (BLE_APP_DIS) + APPM_SVC_DIS, +#endif //(BLE_APP_DIS) +#if (BLE_APP_BATT) + APPM_SVC_BATT, +#endif //(BLE_APP_BATT) +#if (BLE_APP_HID) + APPM_SVC_HIDS, +#endif //(BLE_APP_HID) +#ifdef BLE_APP_AM0 + APPM_SVC_AM0_HAS, +#endif // defined(BLE_APP_AM0) +#if (BLE_APP_HR) + APPM_SVC_HRP, +#endif +#if (BLE_APP_DATAPATH_SERVER) + APPM_SVC_DATAPATH_SERVER, +#endif //(BLE_APP_DATAPATH_SERVER) +#if (BLE_APP_VOICEPATH) + APPM_SVC_VOICEPATH, +#ifdef BISTO_ENABLED + APPM_SVC_BMS, +#endif +#endif //(BLE_APP_VOICEPATH) +#if (ANCS_PROXY_ENABLE) + APPM_SVC_ANCSP, + APPM_SVC_AMSP, +#endif +#if (BLE_APP_ANCC) + APPM_SVC_ANCC, +#endif //(BLE_APP_ANCC) +#if (BLE_APP_AMS) + APPM_SVC_AMSC, +#endif //(BLE_APP_AMS) +#if (BLE_APP_OTA) + APPM_SVC_OTA, +#endif //(BLE_APP_OTA) +#if (BLE_APP_GFPS) + APPM_SVC_GFPS, +#endif //(BLE_APP_GFPS) +#if (BLE_AI_VOICE) + APPM_AI_SMARTVOICE, +#endif //(BLE_AI_VOICE) +#if (BLE_APP_TOTA) + APPM_SVC_TOTA, +#endif //(BLE_APP_TOTA) - #if (BLE_APP_TILE) - APPM_SVC_TILE, - #endif //(BLE_APP_TILE) +#if (BLE_APP_TILE) + APPM_SVC_TILE, +#endif //(BLE_APP_TILE) - APPM_SVC_LIST_STOP, + APPM_SVC_LIST_STOP, }; /* * LOCAL VARIABLES DEFINITIONS **************************************************************************************** */ -//gattc_msg_handler_tab -//#define KE_MSG_HANDLER_TAB(task) __STATIC const struct ke_msg_handler task##_msg_handler_tab[] = +// gattc_msg_handler_tab +//#define KE_MSG_HANDLER_TAB(task) __STATIC const struct ke_msg_handler +// task##_msg_handler_tab[] = /// Application Task Descriptor -//static const struct ke_task_desc TASK_DESC_APP = {&appm_default_handler, -// appm_state, APPM_STATE_MAX, APP_IDX_MAX}; +// static const struct ke_task_desc TASK_DESC_APP = {&appm_default_handler, +// appm_state, APPM_STATE_MAX, +// APP_IDX_MAX}; extern const struct ke_task_desc TASK_DESC_APP; /// List of functions used to create the database -static const appm_add_svc_func_t appm_add_svc_func_list[APPM_SVC_LIST_STOP] = -{ - #if (BLE_APP_HT) +static const appm_add_svc_func_t appm_add_svc_func_list[APPM_SVC_LIST_STOP] = { +#if (BLE_APP_HT) (appm_add_svc_func_t)app_ht_add_hts, - #endif //(BLE_APP_HT) - #if (BLE_APP_DIS) +#endif //(BLE_APP_HT) +#if (BLE_APP_DIS) (appm_add_svc_func_t)app_dis_add_dis, - #endif //(BLE_APP_DIS) - #if (BLE_APP_BATT) +#endif //(BLE_APP_DIS) +#if (BLE_APP_BATT) (appm_add_svc_func_t)app_batt_add_bas, - #endif //(BLE_APP_BATT) - #if (BLE_APP_HID) +#endif //(BLE_APP_BATT) +#if (BLE_APP_HID) (appm_add_svc_func_t)app_hid_add_hids, - #endif //(BLE_APP_HID) - #ifdef BLE_APP_AM0 +#endif //(BLE_APP_HID) +#ifdef BLE_APP_AM0 (appm_add_svc_func_t)am0_app_add_has, - #endif //defined(BLE_APP_AM0) - #if (BLE_APP_HR) +#endif // defined(BLE_APP_AM0) +#if (BLE_APP_HR) (appm_add_svc_func_t)app_hrps_add_profile, - #endif - #if (BLE_APP_DATAPATH_SERVER) +#endif +#if (BLE_APP_DATAPATH_SERVER) (appm_add_svc_func_t)app_datapath_add_datapathps, - #endif //(BLE_APP_DATAPATH_SERVER) - #if (BLE_APP_VOICEPATH) +#endif //(BLE_APP_DATAPATH_SERVER) +#if (BLE_APP_VOICEPATH) (appm_add_svc_func_t)app_ble_voicepath_add_svc, - #ifdef BISTO_ENABLED +#ifdef BISTO_ENABLED (appm_add_svc_func_t)app_ble_bms_add_svc, - #endif - #endif //(BLE_APP_VOICEPATH) - #if (ANCS_PROXY_ENABLE) +#endif +#endif //(BLE_APP_VOICEPATH) +#if (ANCS_PROXY_ENABLE) (appm_add_svc_func_t)app_ble_ancsp_add_svc, (appm_add_svc_func_t)app_ble_amsp_add_svc, - #endif - #if (BLE_APP_ANCC) +#endif +#if (BLE_APP_ANCC) (appm_add_svc_func_t)app_ancc_add_ancc, - #endif - #if (BLE_APP_AMS) +#endif +#if (BLE_APP_AMS) (appm_add_svc_func_t)app_amsc_add_amsc, - #endif - #if (BLE_APP_OTA) +#endif +#if (BLE_APP_OTA) (appm_add_svc_func_t)app_ota_add_ota, - #endif //(BLE_APP_OTA) - #if (BLE_APP_GFPS) +#endif //(BLE_APP_OTA) +#if (BLE_APP_GFPS) (appm_add_svc_func_t)app_gfps_add_gfps, - #endif - #if (BLE_APP_AI_VOICE) +#endif +#if (BLE_APP_AI_VOICE) (appm_add_svc_func_t)app_ai_add_ai, - #endif //(BLE_APP_AI_VOICE) - #if (BLE_APP_TOTA) +#endif //(BLE_APP_AI_VOICE) +#if (BLE_APP_TOTA) (appm_add_svc_func_t)app_tota_add_tota, - #endif //(BLE_APP_TOTA) - #if (BLE_APP_TILE) +#endif //(BLE_APP_TOTA) +#if (BLE_APP_TILE) (appm_add_svc_func_t)app_ble_tile_add_svc, - #endif +#endif }; /* @@ -377,229 +374,220 @@ static const appm_add_svc_func_t appm_add_svc_func_list[APPM_SVC_LIST_STOP] = /// Application Environment Structure struct app_env_tag app_env; -static APP_BLE_NEGOTIATED_CONN_PARAM_T negotiatedBleConnParam[BLE_CONNECTION_MAX]; +static APP_BLE_NEGOTIATED_CONN_PARAM_T + negotiatedBleConnParam[BLE_CONNECTION_MAX]; /* * FUNCTION DEFINITIONS **************************************************************************************** */ -void appm_refresh_ble_irk(void) -{ - nv_record_blerec_get_local_irk(app_env.loc_irk); - LOG_I("local irk:"); - DUMP8("0x%02x ", app_env.loc_irk, 16); - gapm_update_irk(app_env.loc_irk); +void appm_refresh_ble_irk(void) { + nv_record_blerec_get_local_irk(app_env.loc_irk); + LOG_I("local irk:"); + DUMP8("0x%02x ", app_env.loc_irk, 16); + gapm_update_irk(app_env.loc_irk); } -uint8_t *appm_get_current_ble_irk(void) -{ - return app_env.loc_irk; -} +uint8_t *appm_get_current_ble_irk(void) { return app_env.loc_irk; } -void appm_init() -{ - BLE_APP_FUNC_ENTER(); +void appm_init() { + BLE_APP_FUNC_ENTER(); - // Reset the application manager environment - memset(&app_env, 0, sizeof(app_env)); + // Reset the application manager environment + memset(&app_env, 0, sizeof(app_env)); - // Create APP task - ke_task_create(TASK_APP, &TASK_DESC_APP); + // Create APP task + ke_task_create(TASK_APP, &TASK_DESC_APP); - // Initialize Task state - ke_state_set(TASK_APP, APPM_INIT); + // Initialize Task state + ke_state_set(TASK_APP, APPM_INIT); - // Load the device name from NVDS + // Load the device name from NVDS - // Get the Device Name to add in the Advertising Data (Default one or NVDS one) + // Get the Device Name to add in the Advertising Data (Default one or NVDS + // one) #ifdef _BLE_NVDS_ - const char* ble_name_in_nv = nvrec_dev_get_ble_name(); + const char *ble_name_in_nv = nvrec_dev_get_ble_name(); #else - const char* ble_name_in_nv = BLE_DEFAULT_NAME; + const char *ble_name_in_nv = BLE_DEFAULT_NAME; #endif - uint32_t nameLen = strlen(ble_name_in_nv) + 1; - if (nameLen > APP_DEVICE_NAME_MAX_LEN) - { - nameLen = APP_DEVICE_NAME_MAX_LEN; - } - // Get default Device Name (No name if not enough space) - memcpy(app_env.dev_name, ble_name_in_nv, nameLen); - app_env.dev_name[nameLen - 1] = '\0'; - app_env.dev_name_len = nameLen; - LOG_I("device ble name:%s", app_env.dev_name); + uint32_t nameLen = strlen(ble_name_in_nv) + 1; + if (nameLen > APP_DEVICE_NAME_MAX_LEN) { + nameLen = APP_DEVICE_NAME_MAX_LEN; + } + // Get default Device Name (No name if not enough space) + memcpy(app_env.dev_name, ble_name_in_nv, nameLen); + app_env.dev_name[nameLen - 1] = '\0'; + app_env.dev_name_len = nameLen; + LOG_I("device ble name:%s", app_env.dev_name); #ifdef _BLE_NVDS_ - nv_record_blerec_init(); + nv_record_blerec_init(); - nv_record_blerec_get_local_irk(app_env.loc_irk); + nv_record_blerec_get_local_irk(app_env.loc_irk); #else - uint8_t counter; + uint8_t counter; - //avoid ble irk collision low probability - uint32_t generatedSeed = hal_sys_timer_get(); - for (uint8_t index = 0; index < sizeof(bt_addr); index++) - { - generatedSeed ^= (((uint32_t)(bt_addr[index])) << (hal_sys_timer_get()&0xF)); - } - srand(generatedSeed); + // avoid ble irk collision low probability + uint32_t generatedSeed = hal_sys_timer_get(); + for (uint8_t index = 0; index < sizeof(bt_addr); index++) { + generatedSeed ^= + (((uint32_t)(bt_addr[index])) << (hal_sys_timer_get() & 0xF)); + } + srand(generatedSeed); - // generate a new IRK - for (counter = 0; counter < KEY_LEN; counter++) - { - app_env.loc_irk[counter] = (uint8_t)co_rand_word(); - } + // generate a new IRK + for (counter = 0; counter < KEY_LEN; counter++) { + app_env.loc_irk[counter] = (uint8_t)co_rand_word(); + } #endif - /*------------------------------------------------------ - * INITIALIZE ALL MODULES - *------------------------------------------------------*/ + /*------------------------------------------------------ + * INITIALIZE ALL MODULES + *------------------------------------------------------*/ - // load device information: + // load device information: - #if (DISPLAY_SUPPORT) - app_display_init(); - #endif //(DISPLAY_SUPPORT) +#if (DISPLAY_SUPPORT) + app_display_init(); +#endif //(DISPLAY_SUPPORT) - #if (BLE_APP_SEC) - // Security Module - app_sec_init(); - #endif // (BLE_APP_SEC) +#if (BLE_APP_SEC) + // Security Module + app_sec_init(); +#endif // (BLE_APP_SEC) - #if (BLE_APP_HT) - // Health Thermometer Module - app_ht_init(); - #endif //(BLE_APP_HT) +#if (BLE_APP_HT) + // Health Thermometer Module + app_ht_init(); +#endif //(BLE_APP_HT) - #if (BLE_APP_DIS) - // Device Information Module - app_dis_init(); - #endif //(BLE_APP_DIS) +#if (BLE_APP_DIS) + // Device Information Module + app_dis_init(); +#endif //(BLE_APP_DIS) - #if (BLE_APP_HID) - // HID Module - app_hid_init(); - #endif //(BLE_APP_HID) +#if (BLE_APP_HID) + // HID Module + app_hid_init(); +#endif //(BLE_APP_HID) - #if (BLE_APP_BATT) - // Battery Module - app_batt_init(); - #endif //(BLE_APP_BATT) +#if (BLE_APP_BATT) + // Battery Module + app_batt_init(); +#endif //(BLE_APP_BATT) - #ifdef BLE_APP_AM0 - // Audio Mode 0 Module - am0_app_init(); - #endif // defined(BLE_APP_AM0) +#ifdef BLE_APP_AM0 + // Audio Mode 0 Module + am0_app_init(); +#endif // defined(BLE_APP_AM0) - #if (BLE_APP_VOICEPATH) - // Voice Path Module - app_ble_voicepath_init(); - #endif //(BLE_APP_VOICEPATH) +#if (BLE_APP_VOICEPATH) + // Voice Path Module + app_ble_voicepath_init(); +#endif //(BLE_APP_VOICEPATH) - #if (BLE_APP_TILE) - app_ble_tile_init(); - #endif - - #if (BLE_APP_DATAPATH_SERVER) - // Data Path Server Module - app_datapath_server_init(); - #endif //(BLE_APP_DATAPATH_SERVER) - #if (BLE_APP_AI_VOICE) - // AI Voice Module - app_ai_init(); - #endif //(BLE_APP_AI_VOICE) +#if (BLE_APP_TILE) + app_ble_tile_init(); +#endif - #if (BLE_APP_OTA) - // OTA Module - app_ota_init(); - #endif //(BLE_APP_OTA) +#if (BLE_APP_DATAPATH_SERVER) + // Data Path Server Module + app_datapath_server_init(); +#endif //(BLE_APP_DATAPATH_SERVER) +#if (BLE_APP_AI_VOICE) + // AI Voice Module + app_ai_init(); +#endif //(BLE_APP_AI_VOICE) - #if (BLE_APP_TOTA) - // TOTA Module - app_tota_ble_init(); - #endif //(BLE_APP_TOTA) +#if (BLE_APP_OTA) + // OTA Module + app_ota_init(); +#endif //(BLE_APP_OTA) - #if (BLE_APP_GFPS) - // - app_gfps_init(); - #endif +#if (BLE_APP_TOTA) + // TOTA Module + app_tota_ble_init(); +#endif //(BLE_APP_TOTA) - #if (BLE_APP_TILE) - app_tile_init(); - #endif - - BLE_APP_FUNC_LEAVE(); +#if (BLE_APP_GFPS) + // + app_gfps_init(); +#endif + +#if (BLE_APP_TILE) + app_tile_init(); +#endif + + BLE_APP_FUNC_LEAVE(); } -bool appm_add_svc(void) -{ - // Indicate if more services need to be added in the database - bool more_svc = false; +bool appm_add_svc(void) { + // Indicate if more services need to be added in the database + bool more_svc = false; - // Check if another should be added in the database - if (app_env.next_svc != APPM_SVC_LIST_STOP) - { - ASSERT_INFO(appm_add_svc_func_list[app_env.next_svc] != NULL, app_env.next_svc, 1); + // Check if another should be added in the database + if (app_env.next_svc != APPM_SVC_LIST_STOP) { + ASSERT_INFO(appm_add_svc_func_list[app_env.next_svc] != NULL, + app_env.next_svc, 1); - BLE_APP_DBG("appm_add_svc adds service"); + BLE_APP_DBG("appm_add_svc adds service"); - // Call the function used to add the required service - appm_add_svc_func_list[app_env.next_svc](); + // Call the function used to add the required service + appm_add_svc_func_list[app_env.next_svc](); - // Select following service to add - app_env.next_svc++; - more_svc = true; - } - else - { - BLE_APP_DBG("appm_add_svc doesn't execute, next svc is %d", app_env.next_svc); - } + // Select following service to add + app_env.next_svc++; + more_svc = true; + } else { + BLE_APP_DBG("appm_add_svc doesn't execute, next svc is %d", + app_env.next_svc); + } - - return more_svc; + return more_svc; } -uint16_t appm_get_conhdl_from_conidx(uint8_t conidx) -{ - return app_env.context[conidx].conhdl; +uint16_t appm_get_conhdl_from_conidx(uint8_t conidx) { + return app_env.context[conidx].conhdl; } -void appm_disconnect(uint8_t conidx) -{ - if (BLE_DISCONNECTED != app_env.context[conidx].connectStatus) - { - struct gapc_disconnect_cmd *cmd = KE_MSG_ALLOC(GAPC_DISCONNECT_CMD, - KE_BUILD_ID(TASK_GAPC, conidx), - TASK_APP, - gapc_disconnect_cmd); +void appm_disconnect(uint8_t conidx) { + if (BLE_DISCONNECTED != app_env.context[conidx].connectStatus) { + struct gapc_disconnect_cmd *cmd = + KE_MSG_ALLOC(GAPC_DISCONNECT_CMD, KE_BUILD_ID(TASK_GAPC, conidx), + TASK_APP, gapc_disconnect_cmd); - cmd->operation = GAPC_DISCONNECT; - cmd->reason = CO_ERROR_REMOTE_USER_TERM_CON; + cmd->operation = GAPC_DISCONNECT; + cmd->reason = CO_ERROR_REMOTE_USER_TERM_CON; - // Send the message - ke_msg_send(cmd); - } + // Send the message + ke_msg_send(cmd); + } } // TODO: freddie modify this part #if (BLE_APP_GFPS) -#define UPDATE_BLE_ADV_DATA_RIGHT_BEFORE_STARTING_ADV_ENABLED 1 +#define UPDATE_BLE_ADV_DATA_RIGHT_BEFORE_STARTING_ADV_ENABLED 1 #else -#define UPDATE_BLE_ADV_DATA_RIGHT_BEFORE_STARTING_ADV_ENABLED 0 +#define UPDATE_BLE_ADV_DATA_RIGHT_BEFORE_STARTING_ADV_ENABLED 0 #endif -void gapm_update_ble_adv_data_right_before_started(uint8_t* pAdvData, uint8_t* advDataLen, - uint8_t* pScanRspData, uint8_t* scanRspDataLen, void* adv_cmd) -{ - // for the user case that the BLE adv data or scan rsp data need to be generated from the - // run-time BLE address. - // Just enable macro UPDATE_BLE_ADV_DATA_RIGHT_BEFORE_STARTING_ADV_ENABLED, - // and call appm_get_current_ble_addr to get the run-time used BLE address - // For fastpair GFPS_ACCOUNTKEY_SALT_TYPE==USE_BLE_ADDR_AS_SALT case, - // this macro must be enabled +void gapm_update_ble_adv_data_right_before_started(uint8_t *pAdvData, + uint8_t *advDataLen, + uint8_t *pScanRspData, + uint8_t *scanRspDataLen, + void *adv_cmd) { + // for the user case that the BLE adv data or scan rsp data need to be + // generated from the run-time BLE address. Just enable macro + // UPDATE_BLE_ADV_DATA_RIGHT_BEFORE_STARTING_ADV_ENABLED, and call + // appm_get_current_ble_addr to get the run-time used BLE address For fastpair + // GFPS_ACCOUNTKEY_SALT_TYPE==USE_BLE_ADDR_AS_SALT case, this macro must be + // enabled -// #if UPDATE_BLE_ADV_DATA_RIGHT_BEFORE_STARTING_ADV_ENABLED -// appm_fill_ble_adv_scan_rsp_data(pAdvData, advDataLen, pScanRspData, scanRspDataLen, adv_cmd); -// #endif - // TODO: freddie implement this API + // #if UPDATE_BLE_ADV_DATA_RIGHT_BEFORE_STARTING_ADV_ENABLED + // appm_fill_ble_adv_scan_rsp_data(pAdvData, advDataLen, pScanRspData, + // scanRspDataLen, adv_cmd); + // #endif + // TODO: freddie implement this API } /** @@ -607,577 +595,476 @@ void gapm_update_ble_adv_data_right_before_started(uint8_t* pAdvData, uint8_t* a * Advertising Functions **************************************************************************************** */ -void appm_start_advertising(void *param) -{ - BLE_APP_FUNC_ENTER(); +void appm_start_advertising(void *param) { + BLE_APP_FUNC_ENTER(); - LOG_I("%s state: %d", __func__, ke_state_get(TASK_APP)); + LOG_I("%s state: %d", __func__, ke_state_get(TASK_APP)); - // Prepare the GAPM_START_ADVERTISE_CMD message - struct gapm_start_advertise_cmd *cmd = KE_MSG_ALLOC(GAPM_START_ADVERTISE_CMD, - TASK_GAPM, TASK_APP, - gapm_start_advertise_cmd); + // Prepare the GAPM_START_ADVERTISE_CMD message + struct gapm_start_advertise_cmd *cmd = KE_MSG_ALLOC( + GAPM_START_ADVERTISE_CMD, TASK_GAPM, TASK_APP, gapm_start_advertise_cmd); - BLE_ADV_PARAM_T* advParam = (BLE_ADV_PARAM_T*)param; + BLE_ADV_PARAM_T *advParam = (BLE_ADV_PARAM_T *)param; #ifdef BLE_USE_RPA - cmd->op.addr_src = GAPM_GEN_RSLV_ADDR; - cmd->op.randomAddrRenewIntervalInSecond = (uint16_t)(60*15); + cmd->op.addr_src = GAPM_GEN_RSLV_ADDR; + cmd->op.randomAddrRenewIntervalInSecond = (uint16_t)(60 * 15); #else - cmd->op.addr_src = GAPM_STATIC_ADDR; + cmd->op.addr_src = GAPM_STATIC_ADDR; - // To use non-resolvable address - //cmd->op.addr_src = GAPM_GEN_NON_RSLV_ADDR; - //cmd->op.randomAddrRenewIntervalInSecond = (uint16_t)(60*15); + // To use non-resolvable address + // cmd->op.addr_src = GAPM_GEN_NON_RSLV_ADDR; + // cmd->op.randomAddrRenewIntervalInSecond = (uint16_t)(60*15); #endif - cmd->channel_map = APP_ADV_CHMAP; - cmd->intv_min = advParam->advInterval * 8 / 5; - cmd->intv_max = advParam->advInterval * 8 / 5; - cmd->op.code = advParam->advType; - cmd->info.host.mode = GAP_GEN_DISCOVERABLE; + cmd->channel_map = APP_ADV_CHMAP; + cmd->intv_min = advParam->advInterval * 8 / 5; + cmd->intv_max = advParam->advInterval * 8 / 5; + cmd->op.code = advParam->advType; + cmd->info.host.mode = GAP_GEN_DISCOVERABLE; - cmd->isIncludedFlags = advParam->withFlag; - cmd->info.host.flags = GAP_LE_GEN_DISCOVERABLE_FLG | GAP_BR_EDR_NOT_SUPPORTED; + cmd->isIncludedFlags = advParam->withFlag; + cmd->info.host.flags = GAP_LE_GEN_DISCOVERABLE_FLG | GAP_BR_EDR_NOT_SUPPORTED; - cmd->info.host.adv_data_len = advParam->advDataLen; - memcpy(cmd->info.host.adv_data, advParam->advData, cmd->info.host.adv_data_len); - cmd->info.host.scan_rsp_data_len = advParam->scanRspDataLen; - memcpy(cmd->info.host.scan_rsp_data, advParam->scanRspData, cmd->info.host.scan_rsp_data_len); + cmd->info.host.adv_data_len = advParam->advDataLen; + memcpy(cmd->info.host.adv_data, advParam->advData, + cmd->info.host.adv_data_len); + cmd->info.host.scan_rsp_data_len = advParam->scanRspDataLen; + memcpy(cmd->info.host.scan_rsp_data, advParam->scanRspData, + cmd->info.host.scan_rsp_data_len); - if (advParam->withFlag) - { - ASSERT(cmd->info.host.adv_data_len <= BLE_ADV_DATA_WITH_FLAG_LEN, "adv data exceed"); - } - else - { - ASSERT(cmd->info.host.adv_data_len <= BLE_ADV_DATA_WITHOUT_FLAG_LEN, "adv data exceed"); - } - ASSERT(cmd->info.host.scan_rsp_data_len <= SCAN_RSP_DATA_LEN, "scan rsp data exceed"); - LOG_I("[ADDR_TYPE]:%d", cmd->op.addr_src); - if (GAPM_GEN_RSLV_ADDR == cmd->op.addr_src) - { - LOG_I("[IRK]:"); - DUMP8("0x%02x ", appm_get_current_ble_irk(), KEY_LEN); - } - else if (GAPM_STATIC_ADDR == cmd->op.addr_src) - { - LOG_I("[ADDR]:"); - DUMP8("0x%02x ", bt_get_ble_local_address(), 6); - } + if (advParam->withFlag) { + ASSERT(cmd->info.host.adv_data_len <= BLE_ADV_DATA_WITH_FLAG_LEN, + "adv data exceed"); + } else { + ASSERT(cmd->info.host.adv_data_len <= BLE_ADV_DATA_WITHOUT_FLAG_LEN, + "adv data exceed"); + } + ASSERT(cmd->info.host.scan_rsp_data_len <= SCAN_RSP_DATA_LEN, + "scan rsp data exceed"); + LOG_I("[ADDR_TYPE]:%d", cmd->op.addr_src); + if (GAPM_GEN_RSLV_ADDR == cmd->op.addr_src) { + LOG_I("[IRK]:"); + DUMP8("0x%02x ", appm_get_current_ble_irk(), KEY_LEN); + } else if (GAPM_STATIC_ADDR == cmd->op.addr_src) { + LOG_I("[ADDR]:"); + DUMP8("0x%02x ", bt_get_ble_local_address(), 6); + } - LOG_I("[ADV_TYPE]:%d", cmd->op.code); - LOG_I("[ADV_INTERVAL]:%d", cmd->intv_min); + LOG_I("[ADV_TYPE]:%d", cmd->op.code); + LOG_I("[ADV_INTERVAL]:%d", cmd->intv_min); - // Send the message - ke_msg_send(cmd); + // Send the message + ke_msg_send(cmd); - // Set the state of the task to APPM_ADVERTISING - ke_state_set(TASK_APP, APPM_ADVERTISING); + // Set the state of the task to APPM_ADVERTISING + ke_state_set(TASK_APP, APPM_ADVERTISING); - BLE_APP_FUNC_LEAVE(); + BLE_APP_FUNC_LEAVE(); } +void appm_stop_advertising(void) { -void appm_stop_advertising(void) -{ +#if (BLE_APP_HID) + // Stop the advertising timer if needed + if (ke_timer_active(APP_ADV_TIMEOUT_TIMER, TASK_APP)) { + ke_timer_clear(APP_ADV_TIMEOUT_TIMER, TASK_APP); + } +#endif //(BLE_APP_HID) - #if (BLE_APP_HID) - // Stop the advertising timer if needed - if (ke_timer_active(APP_ADV_TIMEOUT_TIMER, TASK_APP)) - { - ke_timer_clear(APP_ADV_TIMEOUT_TIMER, TASK_APP); - } - #endif //(BLE_APP_HID) + // Go in ready state + ke_state_set(TASK_APP, APPM_READY); + // Prepare the GAPM_CANCEL_CMD message + struct gapm_cancel_cmd *cmd = + KE_MSG_ALLOC(GAPM_CANCEL_CMD, TASK_GAPM, TASK_APP, gapm_cancel_cmd); + + cmd->operation = GAPM_CANCEL; + + // Send the message + ke_msg_send(cmd); + +#if (DISPLAY_SUPPORT) + // Update advertising state screen + app_display_set_adv(false); +#endif //(DISPLAY_SUPPORT) +} +void appm_start_scanning(uint16_t intervalInMs, uint16_t windowInMs, + uint32_t filtPolicy) { + struct gapm_start_scan_cmd *cmd = KE_MSG_ALLOC(GAPM_START_SCAN_CMD, TASK_GAPM, + TASK_APP, gapm_start_scan_cmd); + + cmd->op.code = GAPM_SCAN_PASSIVE; + cmd->op.addr_src = GAPM_STATIC_ADDR; + + cmd->interval = intervalInMs * 1000 / 625; + cmd->window = windowInMs * 1000 / 625; + cmd->mode = GAP_OBSERVER_MODE; // GAP_GEN_DISCOVERY; + cmd->filt_policy = filtPolicy; + cmd->filter_duplic = SCAN_FILT_DUPLIC_DIS; + + ke_state_set(TASK_APP, APPM_SCANNING); + + ke_msg_send(cmd); +} + +void appm_stop_scanning(void) { + // if (ke_state_get(TASK_APP) == APPM_SCANNING) + { // Go in ready state ke_state_set(TASK_APP, APPM_READY); // Prepare the GAPM_CANCEL_CMD message - struct gapm_cancel_cmd *cmd = KE_MSG_ALLOC(GAPM_CANCEL_CMD, - TASK_GAPM, TASK_APP, - gapm_cancel_cmd); + struct gapm_cancel_cmd *cmd = + KE_MSG_ALLOC(GAPM_CANCEL_CMD, TASK_GAPM, TASK_APP, gapm_cancel_cmd); cmd->operation = GAPM_CANCEL; // Send the message ke_msg_send(cmd); - - #if (DISPLAY_SUPPORT) - // Update advertising state screen - app_display_set_adv(false); - #endif //(DISPLAY_SUPPORT) - -} -void appm_start_scanning(uint16_t intervalInMs, uint16_t windowInMs, uint32_t filtPolicy) -{ - struct gapm_start_scan_cmd *cmd = KE_MSG_ALLOC(GAPM_START_SCAN_CMD, - TASK_GAPM, - TASK_APP, - gapm_start_scan_cmd); - - cmd->op.code = GAPM_SCAN_PASSIVE; - cmd->op.addr_src = GAPM_STATIC_ADDR; - - cmd->interval = intervalInMs*1000/625; - cmd->window = windowInMs*1000/625; - cmd->mode = GAP_OBSERVER_MODE; //GAP_GEN_DISCOVERY; - cmd->filt_policy = filtPolicy; - cmd->filter_duplic = SCAN_FILT_DUPLIC_DIS; - - ke_state_set(TASK_APP, APPM_SCANNING); - - ke_msg_send(cmd); + } } -void appm_stop_scanning(void) -{ - //if (ke_state_get(TASK_APP) == APPM_SCANNING) - { - // Go in ready state - ke_state_set(TASK_APP, APPM_READY); +void appm_add_dev_into_whitelist(struct gap_bdaddr *ptBdAddr) { + struct gapm_white_list_mgt_cmd *cmd = + KE_MSG_ALLOC_DYN(GAPM_WHITE_LIST_MGT_CMD, TASK_GAPM, TASK_APP, + gapm_white_list_mgt_cmd, sizeof(struct gap_bdaddr)); + cmd->operation = GAPM_ADD_DEV_IN_WLIST; + cmd->nb = 1; - // Prepare the GAPM_CANCEL_CMD message - struct gapm_cancel_cmd *cmd = KE_MSG_ALLOC(GAPM_CANCEL_CMD, - TASK_GAPM, TASK_APP, - gapm_cancel_cmd); + memcpy(cmd->devices, ptBdAddr, sizeof(struct gap_bdaddr)); - cmd->operation = GAPM_CANCEL; - - // Send the message - ke_msg_send(cmd); - } + ke_msg_send(cmd); } -void appm_add_dev_into_whitelist(struct gap_bdaddr* ptBdAddr) -{ - struct gapm_white_list_mgt_cmd *cmd = KE_MSG_ALLOC_DYN(GAPM_WHITE_LIST_MGT_CMD, - TASK_GAPM, - TASK_APP, - gapm_white_list_mgt_cmd, - sizeof(struct gap_bdaddr)); - cmd->operation = GAPM_ADD_DEV_IN_WLIST; - cmd->nb = 1; - - memcpy(cmd->devices, ptBdAddr, sizeof(struct gap_bdaddr)); - - ke_msg_send(cmd); +struct gap_bdaddr BLE_BdAddr; //{{0x14, 0x71, 0xda, 0x7d, 0x1a, 0x00}, 0}; +void pts_ble_addr_init(void) { + uint8_t addr[6] = {0x14, 0x71, 0xda, 0x7d, 0x1a, 0x00}; + memcpy(BLE_BdAddr.addr.addr, addr, 6); + BLE_BdAddr.addr_type = 0; } +void appm_start_connecting(struct gap_bdaddr *ptBdAddr) { + struct gapm_start_connection_cmd *cmd = + KE_MSG_ALLOC_DYN(GAPM_START_CONNECTION_CMD, TASK_GAPM, TASK_APP, + gapm_start_connection_cmd, sizeof(struct gap_bdaddr)); + cmd->ce_len_max = 4; + cmd->ce_len_min = 0; + cmd->con_intv_max = 6; // in the unit of 1.25ms + cmd->con_intv_min = 6; // in the unit of 1.25ms + cmd->con_latency = 0; + cmd->superv_to = 1000; // in the unit of 10ms + cmd->op.code = GAPM_CONNECTION_DIRECT; + cmd->op.addr_src = GAPM_STATIC_ADDR; + cmd->nb_peers = 1; + cmd->scan_interval = ((60) * 1000 / 625); + cmd->scan_window = ((30) * 1000 / 625); -struct gap_bdaddr BLE_BdAddr;//{{0x14, 0x71, 0xda, 0x7d, 0x1a, 0x00}, 0}; -void pts_ble_addr_init(void) -{ - uint8_t addr[6] = {0x14, 0x71, 0xda, 0x7d, 0x1a, 0x00}; - memcpy(BLE_BdAddr.addr.addr, addr, 6); - BLE_BdAddr.addr_type = 0; + memcpy(cmd->peers, ptBdAddr, sizeof(struct gap_bdaddr)); + + ke_state_set(TASK_APP, APPM_CONNECTING); + + ke_msg_send(cmd); } -void appm_start_connecting(struct gap_bdaddr* ptBdAddr) -{ - struct gapm_start_connection_cmd *cmd = KE_MSG_ALLOC_DYN(GAPM_START_CONNECTION_CMD, - TASK_GAPM, - TASK_APP, - gapm_start_connection_cmd, - sizeof(struct gap_bdaddr)); - cmd->ce_len_max = 4; - cmd->ce_len_min = 0; - cmd->con_intv_max = 6; // in the unit of 1.25ms - cmd->con_intv_min = 6; // in the unit of 1.25ms - cmd->con_latency = 0; - cmd->superv_to = 1000; // in the unit of 10ms - cmd->op.code = GAPM_CONNECTION_DIRECT; - cmd->op.addr_src = GAPM_STATIC_ADDR; - cmd->nb_peers = 1; - cmd->scan_interval = ((60) * 1000 / 625); - cmd->scan_window = ((30) * 1000 / 625); +void appm_stop_connecting(void) { + // Go in ready state + ke_state_set(TASK_APP, APPM_READY); - memcpy(cmd->peers, ptBdAddr, sizeof(struct gap_bdaddr)); + // Prepare the GAPM_CANCEL_CMD message + struct gapm_cancel_cmd *cmd = + KE_MSG_ALLOC(GAPM_CANCEL_CMD, TASK_GAPM, TASK_APP, gapm_cancel_cmd); - ke_state_set(TASK_APP, APPM_CONNECTING); + cmd->operation = GAPM_CANCEL; - ke_msg_send(cmd); + // Send the message + ke_msg_send(cmd); } -void appm_stop_connecting(void) -{ - // Go in ready state - ke_state_set(TASK_APP, APPM_READY); +void appm_update_param(uint8_t conidx, struct gapc_conn_param *conn_param) { + // Prepare the GAPC_PARAM_UPDATE_CMD message + struct gapc_param_update_cmd *cmd = + KE_MSG_ALLOC(GAPC_PARAM_UPDATE_CMD, KE_BUILD_ID(TASK_GAPC, conidx), + TASK_APP, gapc_param_update_cmd); - // Prepare the GAPM_CANCEL_CMD message - struct gapm_cancel_cmd *cmd = KE_MSG_ALLOC(GAPM_CANCEL_CMD, - TASK_GAPM, - TASK_APP, - gapm_cancel_cmd); + cmd->operation = GAPC_UPDATE_PARAMS; + cmd->intv_min = conn_param->intv_min; + cmd->intv_max = conn_param->intv_max; + cmd->latency = conn_param->latency; + cmd->time_out = conn_param->time_out; - cmd->operation = GAPM_CANCEL; + // not used by a slave device + cmd->ce_len_min = 0xFFFF; + cmd->ce_len_max = 0xFFFF; - // Send the message - ke_msg_send(cmd); + // Send the message + ke_msg_send(cmd); } - -void appm_update_param(uint8_t conidx, struct gapc_conn_param *conn_param) -{ - // Prepare the GAPC_PARAM_UPDATE_CMD message - struct gapc_param_update_cmd *cmd = KE_MSG_ALLOC(GAPC_PARAM_UPDATE_CMD, - KE_BUILD_ID(TASK_GAPC, conidx), - TASK_APP, - gapc_param_update_cmd); - - cmd->operation = GAPC_UPDATE_PARAMS; - cmd->intv_min = conn_param->intv_min; - cmd->intv_max = conn_param->intv_max; - cmd->latency = conn_param->latency; - cmd->time_out = conn_param->time_out; - - // not used by a slave device - cmd->ce_len_min = 0xFFFF; - cmd->ce_len_max = 0xFFFF; - - // Send the message - ke_msg_send(cmd); -} - -void l2cap_update_param(uint8_t conidx, - uint32_t min_interval_in_ms, +void l2cap_update_param(uint8_t conidx, uint32_t min_interval_in_ms, uint32_t max_interval_in_ms, uint32_t supervision_timeout_in_ms, - uint8_t slaveLantency) -{ - struct l2cc_update_param_req *req = L2CC_SIG_PDU_ALLOC(conidx, - L2C_CODE_CONN_PARAM_UPD_REQ, - KE_BUILD_ID(TASK_GAPC, conidx), - l2cc_update_param_req); + uint8_t slaveLantency) { + struct l2cc_update_param_req *req = + L2CC_SIG_PDU_ALLOC(conidx, L2C_CODE_CONN_PARAM_UPD_REQ, + KE_BUILD_ID(TASK_GAPC, conidx), l2cc_update_param_req); - // generate packet identifier - uint8_t pkt_id = co_rand_word() & 0xFF; - if (pkt_id == 0) - { - pkt_id = 1; - } + // generate packet identifier + uint8_t pkt_id = co_rand_word() & 0xFF; + if (pkt_id == 0) { + pkt_id = 1; + } - /* fill up the parameters */ - req->intv_max = (uint16_t)(max_interval_in_ms/1.25); - req->intv_min = (uint16_t)(min_interval_in_ms/1.25); - req->latency = slaveLantency; - req->timeout = supervision_timeout_in_ms/10; - req->pkt_id = pkt_id; - LOG_I("%s val: 0x%x 0x%x 0x%x 0x%x 0x%x", - __func__, - req->intv_max, - req->intv_min, - req->latency, - req->timeout, - req->pkt_id); - l2cc_pdu_send(req); + /* fill up the parameters */ + req->intv_max = (uint16_t)(max_interval_in_ms / 1.25); + req->intv_min = (uint16_t)(min_interval_in_ms / 1.25); + req->latency = slaveLantency; + req->timeout = supervision_timeout_in_ms / 10; + req->pkt_id = pkt_id; + LOG_I("%s val: 0x%x 0x%x 0x%x 0x%x 0x%x", __func__, req->intv_max, + req->intv_min, req->latency, req->timeout, req->pkt_id); + l2cc_pdu_send(req); } -uint8_t appm_get_dev_name(uint8_t* name) -{ - // copy name to provided pointer - memcpy(name, app_env.dev_name, app_env.dev_name_len); - // return name length - return app_env.dev_name_len; +uint8_t appm_get_dev_name(uint8_t *name) { + // copy name to provided pointer + memcpy(name, app_env.dev_name, app_env.dev_name_len); + // return name length + return app_env.dev_name_len; } -void appm_exchange_mtu(uint8_t conidx) -{ - struct gattc_exc_mtu_cmd *cmd = KE_MSG_ALLOC(GATTC_EXC_MTU_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), - TASK_APP, - gattc_exc_mtu_cmd); +void appm_exchange_mtu(uint8_t conidx) { + struct gattc_exc_mtu_cmd *cmd = + KE_MSG_ALLOC(GATTC_EXC_MTU_CMD, KE_BUILD_ID(TASK_GATTC, conidx), TASK_APP, + gattc_exc_mtu_cmd); - cmd->operation = GATTC_MTU_EXCH; - cmd->seq_num= 0; + cmd->operation = GATTC_MTU_EXCH; + cmd->seq_num = 0; - ke_msg_send(cmd); + ke_msg_send(cmd); } -void appm_check_and_resolve_ble_address(uint8_t conidx) -{ - APP_BLE_CONN_CONTEXT_T* pContext = &(app_env.context[conidx]); +void appm_check_and_resolve_ble_address(uint8_t conidx) { + APP_BLE_CONN_CONTEXT_T *pContext = &(app_env.context[conidx]); #ifdef __GATT_OVER_BR_EDR__ - if (conidx == btif_btgatt_get_connection_index()) - { - pContext->isGotSolvedBdAddr = true; - pContext->isBdAddrResolvingInProgress = false; - btif_btgatt_get_device_address(pContext->solvedBdAddr); - } + if (conidx == btif_btgatt_get_connection_index()) { + pContext->isGotSolvedBdAddr = true; + pContext->isBdAddrResolvingInProgress = false; + btif_btgatt_get_device_address(pContext->solvedBdAddr); + } #endif - // solved already, return - if (pContext->isGotSolvedBdAddr) - { - LOG_I("Already get solved bd addr."); - return; - } - // not solved yet and the solving is in progress, return and wait - else if (app_is_resolving_ble_bd_addr()) - { - LOG_I("Random bd addr solving on going."); - return; - } + // solved already, return + if (pContext->isGotSolvedBdAddr) { + LOG_I("Already get solved bd addr."); + return; + } + // not solved yet and the solving is in progress, return and wait + else if (app_is_resolving_ble_bd_addr()) { + LOG_I("Random bd addr solving on going."); + return; + } - if (BLE_RANDOM_ADDR == pContext->peerAddrType) - { - memset(pContext->solvedBdAddr, 0, BD_ADDR_LEN); - bool isSuccessful = appm_resolve_random_ble_addr_from_nv(conidx, pContext->bdAddr); - LOG_I("%s isSuccessful %d", __func__, isSuccessful); - if (isSuccessful) - { - pContext->isBdAddrResolvingInProgress = true; - } - else - { - pContext->isGotSolvedBdAddr = true; - pContext->isBdAddrResolvingInProgress = false; - } + if (BLE_RANDOM_ADDR == pContext->peerAddrType) { + memset(pContext->solvedBdAddr, 0, BD_ADDR_LEN); + bool isSuccessful = + appm_resolve_random_ble_addr_from_nv(conidx, pContext->bdAddr); + LOG_I("%s isSuccessful %d", __func__, isSuccessful); + if (isSuccessful) { + pContext->isBdAddrResolvingInProgress = true; + } else { + pContext->isGotSolvedBdAddr = true; + pContext->isBdAddrResolvingInProgress = false; } - else - { - pContext->isGotSolvedBdAddr = true; - pContext->isBdAddrResolvingInProgress = false; - memcpy(pContext->solvedBdAddr, pContext->bdAddr, BD_ADDR_LEN); - } - + } else { + pContext->isGotSolvedBdAddr = true; + pContext->isBdAddrResolvingInProgress = false; + memcpy(pContext->solvedBdAddr, pContext->bdAddr, BD_ADDR_LEN); + } } -bool appm_resolve_random_ble_addr_from_nv(uint8_t conidx, uint8_t* randomAddr) -{ +bool appm_resolve_random_ble_addr_from_nv(uint8_t conidx, uint8_t *randomAddr) { #ifdef _BLE_NVDS_ - struct gapm_resolv_addr_cmd *cmd = KE_MSG_ALLOC_DYN(GAPM_RESOLV_ADDR_CMD, - KE_BUILD_ID(TASK_GAPM, conidx), - TASK_APP, - gapm_resolv_addr_cmd, - BLE_RECORD_NUM * GAP_KEY_LEN); + struct gapm_resolv_addr_cmd *cmd = KE_MSG_ALLOC_DYN( + GAPM_RESOLV_ADDR_CMD, KE_BUILD_ID(TASK_GAPM, conidx), TASK_APP, + gapm_resolv_addr_cmd, BLE_RECORD_NUM * GAP_KEY_LEN); - uint8_t irkeyNum = nv_record_ble_fill_irk((uint8_t *)(cmd->irk)); - if (0 == irkeyNum) - { - LOG_I("No history irk, cannot solve bd addr."); - KE_MSG_FREE(cmd); - return false; - } - - LOG_I("Start random bd addr solving."); - - cmd->operation = GAPM_RESOLV_ADDR; - cmd->nb_key = irkeyNum; - memcpy(cmd->addr.addr, randomAddr, GAP_BD_ADDR_LEN); - ke_msg_send(cmd); - return true; -#else + uint8_t irkeyNum = nv_record_ble_fill_irk((uint8_t *)(cmd->irk)); + if (0 == irkeyNum) { + LOG_I("No history irk, cannot solve bd addr."); + KE_MSG_FREE(cmd); return false; + } + + LOG_I("Start random bd addr solving."); + + cmd->operation = GAPM_RESOLV_ADDR; + cmd->nb_key = irkeyNum; + memcpy(cmd->addr.addr, randomAddr, GAP_BD_ADDR_LEN); + ke_msg_send(cmd); + return true; +#else + return false; #endif - } -void appm_resolve_random_ble_addr_with_sepcific_irk(uint8_t conidx, uint8_t* randomAddr, uint8_t* pIrk) -{ - struct gapm_resolv_addr_cmd *cmd = KE_MSG_ALLOC_DYN(GAPM_RESOLV_ADDR_CMD, - KE_BUILD_ID(TASK_GAPM, conidx), TASK_APP, - gapm_resolv_addr_cmd, - GAP_KEY_LEN); - cmd->operation = GAPM_RESOLV_ADDR; - cmd->nb_key = 1; - memcpy(cmd->addr.addr, randomAddr, GAP_BD_ADDR_LEN); - memcpy(cmd->irk, pIrk, GAP_KEY_LEN); - ke_msg_send(cmd); +void appm_resolve_random_ble_addr_with_sepcific_irk(uint8_t conidx, + uint8_t *randomAddr, + uint8_t *pIrk) { + struct gapm_resolv_addr_cmd *cmd = + KE_MSG_ALLOC_DYN(GAPM_RESOLV_ADDR_CMD, KE_BUILD_ID(TASK_GAPM, conidx), + TASK_APP, gapm_resolv_addr_cmd, GAP_KEY_LEN); + cmd->operation = GAPM_RESOLV_ADDR; + cmd->nb_key = 1; + memcpy(cmd->addr.addr, randomAddr, GAP_BD_ADDR_LEN); + memcpy(cmd->irk, pIrk, GAP_KEY_LEN); + ke_msg_send(cmd); } -void appm_random_ble_addr_solved(bool isSolvedSuccessfully, uint8_t* irkUsedForSolving) -{ - APP_BLE_CONN_CONTEXT_T* pContext; - uint32_t conidx; - for (conidx = 0;conidx < BLE_CONNECTION_MAX;conidx++) - { - pContext = &(app_env.context[conidx]); - if (pContext->isBdAddrResolvingInProgress) - { - break; - } +void appm_random_ble_addr_solved(bool isSolvedSuccessfully, + uint8_t *irkUsedForSolving) { + APP_BLE_CONN_CONTEXT_T *pContext; + uint32_t conidx; + for (conidx = 0; conidx < BLE_CONNECTION_MAX; conidx++) { + pContext = &(app_env.context[conidx]); + if (pContext->isBdAddrResolvingInProgress) { + break; } + } - if (conidx < BLE_CONNECTION_MAX) - { - pContext->isBdAddrResolvingInProgress = false; - pContext->isGotSolvedBdAddr = true; + if (conidx < BLE_CONNECTION_MAX) { + pContext->isBdAddrResolvingInProgress = false; + pContext->isGotSolvedBdAddr = true; - LOG_I("%s conidx %d isSolvedSuccessfully %d", __func__, conidx, isSolvedSuccessfully); - if (isSolvedSuccessfully) - { + LOG_I("%s conidx %d isSolvedSuccessfully %d", __func__, conidx, + isSolvedSuccessfully); + if (isSolvedSuccessfully) { #ifdef _BLE_NVDS_ - bool isSuccessful = nv_record_blerec_get_bd_addr_from_irk(app_env.context[conidx].solvedBdAddr, irkUsedForSolving); - if (isSuccessful) - { - LOG_I("[CONNECT]Connected random address's original addr is:"); - DUMP8("%02x ", app_env.context[conidx].solvedBdAddr, GAP_BD_ADDR_LEN); - } - else + bool isSuccessful = nv_record_blerec_get_bd_addr_from_irk( + app_env.context[conidx].solvedBdAddr, irkUsedForSolving); + if (isSuccessful) { + LOG_I("[CONNECT]Connected random address's original addr is:"); + DUMP8("%02x ", app_env.context[conidx].solvedBdAddr, GAP_BD_ADDR_LEN); + } else #endif - { - LOG_I("[CONNECT]Resolving of the connected BLE random addr failed."); - } - } - else - { - LOG_I("[CONNECT]random resolving failed."); - } + { + LOG_I("[CONNECT]Resolving of the connected BLE random addr failed."); + } + } else { + LOG_I("[CONNECT]random resolving failed."); } + } #if defined(CFG_VOICEPATH) - ke_task_msg_retrieve(prf_get_task_from_id(TASK_ID_VOICEPATH)); + ke_task_msg_retrieve(prf_get_task_from_id(TASK_ID_VOICEPATH)); #endif - ke_task_msg_retrieve(TASK_GAPC); - ke_task_msg_retrieve(TASK_APP); + ke_task_msg_retrieve(TASK_GAPC); + ke_task_msg_retrieve(TASK_APP); - app_ble_start_connectable_adv(BLE_ADVERTISING_INTERVAL); + app_ble_start_connectable_adv(BLE_ADVERTISING_INTERVAL); } -uint8_t app_ble_connection_count(void) -{ - return app_env.conn_cnt; -} +uint8_t app_ble_connection_count(void) { return app_env.conn_cnt; } -bool app_is_arrive_at_max_ble_connections(void) -{ - LOG_I("connection count %d", app_env.conn_cnt); +bool app_is_arrive_at_max_ble_connections(void) { + LOG_I("connection count %d", app_env.conn_cnt); -#if defined(GFPS_ENABLED) && (BLE_APP_GFPS_VER==FAST_PAIR_REV_2_0) - return (app_env.conn_cnt >= BLE_CONNECTION_MAX); +#if defined(GFPS_ENABLED) && (BLE_APP_GFPS_VER == FAST_PAIR_REV_2_0) + return (app_env.conn_cnt >= BLE_CONNECTION_MAX); #else - return (app_env.conn_cnt >= 1); + return (app_env.conn_cnt >= 1); #endif } -bool app_is_resolving_ble_bd_addr(void) -{ - for (uint32_t index = 0;index < BLE_CONNECTION_MAX;index++) - { - if (app_env.context[index].isBdAddrResolvingInProgress) - { - return true; - } +bool app_is_resolving_ble_bd_addr(void) { + for (uint32_t index = 0; index < BLE_CONNECTION_MAX; index++) { + if (app_env.context[index].isBdAddrResolvingInProgress) { + return true; } + } - return false; + return false; } -void app_trigger_ble_service_discovery(uint8_t conidx, uint16_t shl, uint16_t ehl) -{ - struct gattc_send_svc_changed_cmd *cmd = KE_MSG_ALLOC(GATTC_SEND_SVC_CHANGED_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), - TASK_APP, - gattc_send_svc_changed_cmd); - cmd->operation = GATTC_SVC_CHANGED; - cmd->svc_shdl = shl; - cmd->svc_ehdl = ehl; - ke_msg_send(cmd); +void app_trigger_ble_service_discovery(uint8_t conidx, uint16_t shl, + uint16_t ehl) { + struct gattc_send_svc_changed_cmd *cmd = + KE_MSG_ALLOC(GATTC_SEND_SVC_CHANGED_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + TASK_APP, gattc_send_svc_changed_cmd); + cmd->operation = GATTC_SVC_CHANGED; + cmd->svc_shdl = shl; + cmd->svc_ehdl = ehl; + ke_msg_send(cmd); } -void appm_update_adv_data(uint8_t *pAdvData, - uint32_t advDataLen, - uint8_t *pScanRspData, - uint32_t scanRspDataLen) -{ - LOG_I("%s", __func__); - ASSERT(advDataLen <= BLE_DATA_LEN, "adv data exceed"); - ASSERT(scanRspDataLen <= SCAN_RSP_DATA_LEN, "scan rsp data exceed"); +void appm_update_adv_data(uint8_t *pAdvData, uint32_t advDataLen, + uint8_t *pScanRspData, uint32_t scanRspDataLen) { + LOG_I("%s", __func__); + ASSERT(advDataLen <= BLE_DATA_LEN, "adv data exceed"); + ASSERT(scanRspDataLen <= SCAN_RSP_DATA_LEN, "scan rsp data exceed"); - struct gapm_update_advertise_data_cmd *cmd = KE_MSG_ALLOC(GAPM_UPDATE_ADVERTISE_DATA_CMD, - TASK_GAPM, TASK_APP, - gapm_update_advertise_data_cmd); - cmd->operation = GAPM_UPDATE_ADVERTISE_DATA; - memcpy(cmd->adv_data, pAdvData, advDataLen); - cmd->adv_data_len = advDataLen; + struct gapm_update_advertise_data_cmd *cmd = + KE_MSG_ALLOC(GAPM_UPDATE_ADVERTISE_DATA_CMD, TASK_GAPM, TASK_APP, + gapm_update_advertise_data_cmd); + cmd->operation = GAPM_UPDATE_ADVERTISE_DATA; + memcpy(cmd->adv_data, pAdvData, advDataLen); + cmd->adv_data_len = advDataLen; - memcpy(cmd->scan_rsp_data, pScanRspData, scanRspDataLen); - cmd->scan_rsp_data_len = scanRspDataLen; + memcpy(cmd->scan_rsp_data, pScanRspData, scanRspDataLen); + cmd->scan_rsp_data_len = scanRspDataLen; - ke_msg_send(cmd); + ke_msg_send(cmd); } -__attribute__((weak)) void app_ble_connected_evt_handler(uint8_t conidx, const uint8_t* pPeerBdAddress) -{ +__attribute__((weak)) void +app_ble_connected_evt_handler(uint8_t conidx, const uint8_t *pPeerBdAddress) {} -} +__attribute__((weak)) void app_ble_disconnected_evt_handler(uint8_t conidx) {} -__attribute__((weak)) void app_ble_disconnected_evt_handler(uint8_t conidx) -{ +__attribute__((weak)) void app_advertising_stopped(void) {} -} +__attribute__((weak)) void app_advertising_started(void) {} -__attribute__((weak)) void app_advertising_stopped(void) -{ +__attribute__((weak)) void app_connecting_started(void) {} -} +__attribute__((weak)) void app_scanning_stopped(void) {} -__attribute__((weak)) void app_advertising_started(void) -{ +__attribute__((weak)) void app_connecting_stopped(void) {} -} +__attribute__((weak)) void app_scanning_started(void) {} -__attribute__((weak)) void app_connecting_started(void) -{ +__attribute__((weak)) void app_ble_system_ready(void) {} -} +__attribute__((weak)) void +app_adv_reported_scanned(struct gapm_adv_report_ind *ptInd) {} -__attribute__((weak)) void app_scanning_stopped(void) -{ - -} - -__attribute__((weak)) void app_connecting_stopped(void) -{ - -} - - -__attribute__((weak)) void app_scanning_started(void) -{ - -} - -__attribute__((weak)) void app_ble_system_ready(void) -{ - -} - -__attribute__((weak)) void app_adv_reported_scanned(struct gapm_adv_report_ind* ptInd) -{ - -} - -uint8_t* appm_get_current_ble_addr(void) -{ +uint8_t *appm_get_current_ble_addr(void) { #ifdef BLE_USE_RPA - return (uint8_t *)gapm_get_bdaddr(); + return (uint8_t *)gapm_get_bdaddr(); #else - return ble_addr; + return ble_addr; #endif } #define IS_WORKAROUND_SAME_BT_BLE_ADDR_FOR_RPA_CASEx -uint8_t* appm_get_local_identity_ble_addr(void) -{ -#if defined(BLE_USE_RPA)&&defined(IS_WORKAROUND_SAME_BT_BLE_ADDR_FOR_RPA_CASE) - return (uint8_t *)gapm_get_bdaddr(); +uint8_t *appm_get_local_identity_ble_addr(void) { +#if defined(BLE_USE_RPA) && defined(IS_WORKAROUND_SAME_BT_BLE_ADDR_FOR_RPA_CASE) + return (uint8_t *)gapm_get_bdaddr(); #else - return ble_addr; + return ble_addr; #endif } // bit mask of the existing conn param modes static uint32_t existingBleConnParamModes[BLE_CONNECTION_MAX] = {0}; -static BLE_CONN_PARAM_CONFIG_T ble_conn_param_config[] = -{ +static BLE_CONN_PARAM_CONFIG_T ble_conn_param_config[] = { // default value: for the case of BLE just connected and the BT idle state {BLE_CONN_PARAM_MODE_DEFAULT, BLE_CONN_PARAM_PRIORITY_NORMAL, 24}, - {BLE_CONN_PARAM_MODE_AI_STREAM_ON, BLE_CONN_PARAM_PRIORITY_ABOVE_NORMAL1, 24}, + {BLE_CONN_PARAM_MODE_AI_STREAM_ON, BLE_CONN_PARAM_PRIORITY_ABOVE_NORMAL1, + 24}, //{BLE_CONN_PARAM_MODE_A2DP_ON, BLE_CONN_PARAM_PRIORITY_ABOVE_NORMAL0, 36}, @@ -1186,271 +1073,227 @@ static BLE_CONN_PARAM_CONFIG_T ble_conn_param_config[] = {BLE_CONN_PARAM_MODE_OTA, BLE_CONN_PARAM_PRIORITY_HIGH, 12}, {BLE_CONN_PARAM_MODE_OTA_SLOWER, BLE_CONN_PARAM_PRIORITY_HIGH, 20}, - + {BLE_CONN_PARAM_MODE_SNOOP_EXCHANGE, BLE_CONN_PARAM_PRIORITY_HIGH, 8}, // TODO: add mode cases if needed }; -void app_ble_reset_conn_param_mode(uint8_t conidx) -{ - uint32_t lock = int_lock_global(); - existingBleConnParamModes[conidx] = 0; - int_unlock_global(lock); +void app_ble_reset_conn_param_mode(uint8_t conidx) { + uint32_t lock = int_lock_global(); + existingBleConnParamModes[conidx] = 0; + int_unlock_global(lock); } -void app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_E mode, bool isEnable) -{ - for (uint8_t index = 0;index < BLE_CONNECTION_MAX;index++) - { - if (BLE_CONNECTED == app_env.context[index].connectStatus) - { - app_ble_update_conn_param_mode_of_specific_connection( - index, mode, isEnable); - } +void app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_E mode, bool isEnable) { + for (uint8_t index = 0; index < BLE_CONNECTION_MAX; index++) { + if (BLE_CONNECTED == app_env.context[index].connectStatus) { + app_ble_update_conn_param_mode_of_specific_connection(index, mode, + isEnable); } + } } -bool app_ble_is_parameter_mode_enabled(uint8_t conidx, BLE_CONN_PARAM_MODE_E mode) -{ - bool isEnabled = false; - uint32_t lock = int_lock_global(); - isEnabled = existingBleConnParamModes[conidx]&(1 << mode); - int_unlock_global(lock); +bool app_ble_is_parameter_mode_enabled(uint8_t conidx, + BLE_CONN_PARAM_MODE_E mode) { + bool isEnabled = false; + uint32_t lock = int_lock_global(); + isEnabled = existingBleConnParamModes[conidx] & (1 << mode); + int_unlock_global(lock); - return isEnabled; + return isEnabled; } -void app_ble_parameter_mode_clear(uint8_t conidx, BLE_CONN_PARAM_MODE_E mode) -{ - uint32_t lock = int_lock_global(); - existingBleConnParamModes[conidx] &= (~(1 << mode)); - int_unlock_global(lock); +void app_ble_parameter_mode_clear(uint8_t conidx, BLE_CONN_PARAM_MODE_E mode) { + uint32_t lock = int_lock_global(); + existingBleConnParamModes[conidx] &= (~(1 << mode)); + int_unlock_global(lock); } -void app_ble_update_conn_param_mode_of_specific_connection(uint8_t conidx, - BLE_CONN_PARAM_MODE_E mode, - bool isEnable) -{ - ASSERT(mode < BLE_CONN_PARAM_MODE_NUM, "Wrong ble conn param mode %d!", mode); +void app_ble_update_conn_param_mode_of_specific_connection( + uint8_t conidx, BLE_CONN_PARAM_MODE_E mode, bool isEnable) { + ASSERT(mode < BLE_CONN_PARAM_MODE_NUM, "Wrong ble conn param mode %d!", mode); - uint32_t lock = int_lock_global(); + uint32_t lock = int_lock_global(); - // locate the conn param mode - BLE_CONN_PARAM_CONFIG_T *pConfig = NULL; - uint8_t index; + // locate the conn param mode + BLE_CONN_PARAM_CONFIG_T *pConfig = NULL; + uint8_t index; - for (index = 0; - index < sizeof(ble_conn_param_config) / sizeof(BLE_CONN_PARAM_CONFIG_T); - index++) - { - if (mode == ble_conn_param_config[index].ble_conn_param_mode) - { - pConfig = &ble_conn_param_config[index]; - break; - } + for (index = 0; + index < sizeof(ble_conn_param_config) / sizeof(BLE_CONN_PARAM_CONFIG_T); + index++) { + if (mode == ble_conn_param_config[index].ble_conn_param_mode) { + pConfig = &ble_conn_param_config[index]; + break; } + } - if (NULL == pConfig) - { + if (NULL == pConfig) { + int_unlock_global(lock); + LOG_W("conn param mode %d not defined!", mode); + return; + } + + if (isEnable) { + if (0 == existingBleConnParamModes[conidx]) { + // no other params existing, just configure this one + existingBleConnParamModes[conidx] = 1 << mode; + } else { + // already existing, directly return + if (existingBleConnParamModes[conidx] & (1 << mode)) { int_unlock_global(lock); - LOG_W("conn param mode %d not defined!", mode); return; - } + } else { + // update the bit-mask + existingBleConnParamModes[conidx] |= (1 << mode); - if (isEnable) - { - if (0 == existingBleConnParamModes[conidx]) - { - // no other params existing, just configure this one - existingBleConnParamModes[conidx] = 1 << mode; - } - else - { - // already existing, directly return - if (existingBleConnParamModes[conidx]&(1 << mode)) - { - int_unlock_global(lock); - return; - } - else - { - // update the bit-mask - existingBleConnParamModes[conidx] |= (1 << mode); - - // not existing yet, need to go throuth the existing params to see whether - // we need to update the param - for (index = 0; - index < sizeof(ble_conn_param_config)/sizeof(BLE_CONN_PARAM_CONFIG_T); - index++) - { - if ((( uint32_t )1 << ( uint8_t )ble_conn_param_config[index].ble_conn_param_mode) & - existingBleConnParamModes[conidx]) - { - if (ble_conn_param_config[index].priority > pConfig->priority) - { - // one of the exiting param has higher priority than this one, - // so do nothing but update the bit-mask - int_unlock_global(lock); - return; - } - } - } - - // no higher priority conn param existing, so we need to apply this one + // not existing yet, need to go throuth the existing params to see + // whether we need to update the param + for (index = 0; index < sizeof(ble_conn_param_config) / + sizeof(BLE_CONN_PARAM_CONFIG_T); + index++) { + if (((uint32_t)1 + << (uint8_t)ble_conn_param_config[index].ble_conn_param_mode) & + existingBleConnParamModes[conidx]) { + if (ble_conn_param_config[index].priority > pConfig->priority) { + // one of the exiting param has higher priority than this one, + // so do nothing but update the bit-mask + int_unlock_global(lock); + return; } + } } + + // no higher priority conn param existing, so we need to apply this one + } } - else - { - if (0 == existingBleConnParamModes[conidx]) - { - // no other params existing, just return - int_unlock_global(lock); - return; + } else { + if (0 == existingBleConnParamModes[conidx]) { + // no other params existing, just return + int_unlock_global(lock); + return; + } else { + // doesn't exist, directly return + if (!(existingBleConnParamModes[conidx] & (1 << mode))) { + int_unlock_global(lock); + return; + } else { + // update the bit-mask + existingBleConnParamModes[conidx] &= (~(1 << mode)); + + if (0 == existingBleConnParamModes[conidx]) { + int_unlock_global(lock); + return; } - else - { - // doesn't exist, directly return - if (!(existingBleConnParamModes[conidx]&(1 << mode))) - { - int_unlock_global(lock); - return; - } - else - { - // update the bit-mask - existingBleConnParamModes[conidx] &= (~(1 << mode)); - - if (0 == existingBleConnParamModes[conidx]) - { - int_unlock_global(lock); - return; - } - - pConfig = NULL; - - // existing, need to apply for the highest priority conn param - for (index = 0; - index < sizeof(ble_conn_param_config) / sizeof(BLE_CONN_PARAM_CONFIG_T); - index++) - { - if ((( uint32_t )1 << ( uint8_t )ble_conn_param_config[index].ble_conn_param_mode) & - existingBleConnParamModes[conidx]) - { - if (NULL != pConfig) - { - if (ble_conn_param_config[index].priority > pConfig->priority) - { - pConfig = &ble_conn_param_config[index]; - } - } - else - { - pConfig = &ble_conn_param_config[index]; - } - } - } + + pConfig = NULL; + + // existing, need to apply for the highest priority conn param + for (index = 0; index < sizeof(ble_conn_param_config) / + sizeof(BLE_CONN_PARAM_CONFIG_T); + index++) { + if (((uint32_t)1 + << (uint8_t)ble_conn_param_config[index].ble_conn_param_mode) & + existingBleConnParamModes[conidx]) { + if (NULL != pConfig) { + if (ble_conn_param_config[index].priority > pConfig->priority) { + pConfig = &ble_conn_param_config[index]; + } + } else { + pConfig = &ble_conn_param_config[index]; } + } } + } } + } - int_unlock_global(lock); + int_unlock_global(lock); - // if we can arrive here, it means we have got one config to apply - ASSERT(NULL != pConfig, "It's strange that config pointer is still NULL."); + // if we can arrive here, it means we have got one config to apply + ASSERT(NULL != pConfig, "It's strange that config pointer is still NULL."); - APP_BLE_CONN_CONTEXT_T* pContext = &(app_env.context[conidx]); + APP_BLE_CONN_CONTEXT_T *pContext = &(app_env.context[conidx]); - if (pContext->connInterval != pConfig->conn_param_interval) - { - l2cap_update_param(conidx, pConfig->conn_param_interval*10/8, - pConfig->conn_param_interval*10/8, - BLE_CONN_PARAM_SUPERVISE_TIMEOUT_MS, - BLE_CONN_PARAM_SLAVE_LATENCY_CNT); - - LOG_I("try to update conn interval to %d", pConfig->conn_param_interval); - } + if (pContext->connInterval != pConfig->conn_param_interval) { + l2cap_update_param(conidx, pConfig->conn_param_interval * 10 / 8, + pConfig->conn_param_interval * 10 / 8, + BLE_CONN_PARAM_SUPERVISE_TIMEOUT_MS, + BLE_CONN_PARAM_SLAVE_LATENCY_CNT); - LOG_I("conn param mode of conidx %d switched to:0x%x", - conidx, existingBleConnParamModes[conidx]); + LOG_I("try to update conn interval to %d", pConfig->conn_param_interval); + } + LOG_I("conn param mode of conidx %d switched to:0x%x", conidx, + existingBleConnParamModes[conidx]); } -void app_ble_save_negotiated_conn_param(uint8_t conidx, APP_BLE_NEGOTIATED_CONN_PARAM_T* pConnParam) -{ - if (conidx < BLE_CONNECTION_MAX) - { - negotiatedBleConnParam[conidx] = *pConnParam; - } +void app_ble_save_negotiated_conn_param( + uint8_t conidx, APP_BLE_NEGOTIATED_CONN_PARAM_T *pConnParam) { + if (conidx < BLE_CONNECTION_MAX) { + negotiatedBleConnParam[conidx] = *pConnParam; + } } -bool app_ble_get_connection_interval(uint8_t conidx, APP_BLE_NEGOTIATED_CONN_PARAM_T* pConnParam) -{ - if ((conidx < BLE_CONNECTION_MAX) && - (BLE_CONNECTED == app_env.context[conidx].connectStatus)) - { - *pConnParam = negotiatedBleConnParam[conidx]; - return true; - } - else - { - return false; - } +bool app_ble_get_connection_interval( + uint8_t conidx, APP_BLE_NEGOTIATED_CONN_PARAM_T *pConnParam) { + if ((conidx < BLE_CONNECTION_MAX) && + (BLE_CONNECTED == app_env.context[conidx].connectStatus)) { + *pConnParam = negotiatedBleConnParam[conidx]; + return true; + } else { + return false; + } } #if GFPS_ENABLED uint8_t delay_update_conidx = BLE_INVALID_CONNECTION_INDEX; -#define FP_DELAY_UPDATE_BLE_CONN_PARAM_TIMER_VALUE (10000) +#define FP_DELAY_UPDATE_BLE_CONN_PARAM_TIMER_VALUE (10000) osTimerId fp_update_ble_param_timer = NULL; static void fp_update_ble_connect_param_timer_handler(void const *param); -osTimerDef (FP_UPDATE_BLE_CONNECT_PARAM_TIMER, (void (*)(void const *))fp_update_ble_connect_param_timer_handler); -extern uint8_t is_sco_mode (void); -static void fp_update_ble_connect_param_timer_handler(void const *param) -{ - LOG_I("fp_update_ble_connect_param_timer_handler"); - for (uint8_t index = 0;index < BLE_CONNECTION_MAX;index++) - { - if ((BLE_CONNECTED == app_env.context[index].connectStatus) && - (index == delay_update_conidx)) - { - LOG_I("update connection interval of conidx %d", delay_update_conidx); +osTimerDef(FP_UPDATE_BLE_CONNECT_PARAM_TIMER, + (void (*)(void const *))fp_update_ble_connect_param_timer_handler); +extern uint8_t is_sco_mode(void); +static void fp_update_ble_connect_param_timer_handler(void const *param) { + LOG_I("fp_update_ble_connect_param_timer_handler"); + for (uint8_t index = 0; index < BLE_CONNECTION_MAX; index++) { + if ((BLE_CONNECTED == app_env.context[index].connectStatus) && + (index == delay_update_conidx)) { + LOG_I("update connection interval of conidx %d", delay_update_conidx); - if (is_sco_mode()) - { - app_ble_update_conn_param_mode_of_specific_connection(delay_update_conidx, BLE_CONN_PARAM_MODE_HFP_ON, true); - } - else - { - app_ble_update_conn_param_mode_of_specific_connection(delay_update_conidx, BLE_CONN_PARAM_MODE_DEFAULT, true); - } - break; - } + if (is_sco_mode()) { + app_ble_update_conn_param_mode_of_specific_connection( + delay_update_conidx, BLE_CONN_PARAM_MODE_HFP_ON, true); + } else { + app_ble_update_conn_param_mode_of_specific_connection( + delay_update_conidx, BLE_CONN_PARAM_MODE_DEFAULT, true); + } + break; } - delay_update_conidx = BLE_INVALID_CONNECTION_INDEX; + } + delay_update_conidx = BLE_INVALID_CONNECTION_INDEX; } -void fp_update_ble_connect_param_start(uint8_t ble_conidx) -{ - if (fp_update_ble_param_timer == NULL) - { - fp_update_ble_param_timer = osTimerCreate(osTimer(FP_UPDATE_BLE_CONNECT_PARAM_TIMER), osTimerOnce, NULL); - return; - } +void fp_update_ble_connect_param_start(uint8_t ble_conidx) { + if (fp_update_ble_param_timer == NULL) { + fp_update_ble_param_timer = osTimerCreate( + osTimer(FP_UPDATE_BLE_CONNECT_PARAM_TIMER), osTimerOnce, NULL); + return; + } - delay_update_conidx = ble_conidx; + delay_update_conidx = ble_conidx; + if (fp_update_ble_param_timer) + osTimerStart(fp_update_ble_param_timer, + FP_DELAY_UPDATE_BLE_CONN_PARAM_TIMER_VALUE); +} + +void fp_update_ble_connect_param_stop(uint8_t ble_conidx) { + if (delay_update_conidx == ble_conidx) { if (fp_update_ble_param_timer) - osTimerStart(fp_update_ble_param_timer, FP_DELAY_UPDATE_BLE_CONN_PARAM_TIMER_VALUE); -} - -void fp_update_ble_connect_param_stop(uint8_t ble_conidx) -{ - if (delay_update_conidx == ble_conidx) - { - if (fp_update_ble_param_timer) - osTimerStop(fp_update_ble_param_timer); - delay_update_conidx = BLE_INVALID_CONNECTION_INDEX; - } + osTimerStop(fp_update_ble_param_timer); + delay_update_conidx = BLE_INVALID_CONNECTION_INDEX; + } } #endif diff --git a/services/ble_app/app_main/app_ble_core.c b/services/ble_app/app_main/app_ble_core.c index 87fbbed..14683f3 100644 --- a/services/ble_app/app_main/app_ble_core.c +++ b/services/ble_app/app_main/app_ble_core.c @@ -1,335 +1,298 @@ /*************************************************************************** -* -*Copyright 2015-2019 BES. -*All rights reserved. All unpublished rights reserved. -* -*No part of this work may be used or reproduced in any form or by any -*means, or stored in a database or retrieval system, without prior written -*permission of BES. -* -*Use of this work is governed by a license granted by BES. -*This work contains confidential and proprietary information of -*BES. which is protected by copyright, trade secret, -*trademark and other intellectual property rights. -* -****************************************************************************/ + * + *Copyright 2015-2019 BES. + *All rights reserved. All unpublished rights reserved. + * + *No part of this work may be used or reproduced in any form or by any + *means, or stored in a database or retrieval system, without prior written + *permission of BES. + * + *Use of this work is governed by a license granted by BES. + *This work contains confidential and proprietary information of + *BES. which is protected by copyright, trade secret, + *trademark and other intellectual property rights. + * + ****************************************************************************/ /*****************************header include********************************/ -#include "string.h" -#include "co_math.h" // Common Maths Definition -#include "cmsis_os.h" -#include "ble_app_dbg.h" -#include "stdbool.h" +#include "app_a2dp.h" #include "app_thread.h" #include "app_utils.h" -#include "app_a2dp.h" +#include "ble_app_dbg.h" +#include "cmsis_os.h" +#include "co_math.h" // Common Maths Definition +#include "stdbool.h" +#include "string.h" -#include "apps.h" #include "app.h" -#include "app_sec.h" -#include "app_ble_mode_switch.h" #include "app_ble_core.h" -#include "nvrecord.h" -#include "app_bt_func.h" -#include "hal_timer.h" +#include "app_ble_mode_switch.h" #include "app_bt.h" +#include "app_bt_func.h" #include "app_hfp.h" -#include "rwprf_config.h" -#include "nvrecord_ble.h" #include "app_sec.h" +#include "apps.h" +#include "hal_timer.h" +#include "nvrecord.h" +#include "nvrecord_ble.h" +#include "rwprf_config.h" #ifdef IBRT #include "app_ibrt_ui.h" #include "app_tws_if.h" #endif -extern uint8_t is_sco_mode (void); +extern uint8_t is_sco_mode(void); static APP_BLE_CORE_GLOBAL_HANDLER_FUNC g_ble_core_global_handler_ind = NULL; -static APP_BLE_CORE_GLOBAL_CALLBACK_HANDLER_FUNC g_ble_core_global_callback_handler_ind = NULL; +static APP_BLE_CORE_GLOBAL_CALLBACK_HANDLER_FUNC + g_ble_core_global_callback_handler_ind = NULL; -void app_ble_core_register_global_handler_ind(APP_BLE_CORE_GLOBAL_HANDLER_FUNC handler) -{ - g_ble_core_global_handler_ind = handler; +void app_ble_core_register_global_handler_ind( + APP_BLE_CORE_GLOBAL_HANDLER_FUNC handler) { + g_ble_core_global_handler_ind = handler; } -void app_ble_core_register_global_callback_handle_ind(APP_BLE_CORE_GLOBAL_CALLBACK_HANDLER_FUNC handler) -{ - g_ble_core_global_callback_handler_ind = handler; +void app_ble_core_register_global_callback_handle_ind( + APP_BLE_CORE_GLOBAL_CALLBACK_HANDLER_FUNC handler) { + g_ble_core_global_callback_handler_ind = handler; } -static void ble_connect_event_handler(ble_evnet_t *event, void *output) -{ +static void ble_connect_event_handler(ble_evnet_t *event, void *output) { #ifdef TWS_SYSTEM_ENABLED - app_tws_if_ble_connected_handler(); + app_tws_if_ble_connected_handler(); #endif #ifdef IBRT - bd_addr_t *box_ble_addr = (bd_addr_t *)app_ibrt_ui_get_box_ble_addr(); - if (app_ibrt_ui_get_snoop_via_ble_enable()) - { - if(!memcmp(box_ble_addr, event->p.connect_handled.peer_bdaddr, BTIF_BD_ADDR_SIZE)) - { - app_ibrt_ui_set_ble_connect_index(event->p.connect_handled.conidx); - app_ibrt_ui_set_box_connect_state(IBRT_BOX_CONNECT_MASTER, FALSE); - } + bd_addr_t *box_ble_addr = (bd_addr_t *)app_ibrt_ui_get_box_ble_addr(); + if (app_ibrt_ui_get_snoop_via_ble_enable()) { + if (!memcmp(box_ble_addr, event->p.connect_handled.peer_bdaddr, + BTIF_BD_ADDR_SIZE)) { + app_ibrt_ui_set_ble_connect_index(event->p.connect_handled.conidx); + app_ibrt_ui_set_box_connect_state(IBRT_BOX_CONNECT_MASTER, FALSE); } + } #endif } -static void ble_disconnect_event_handler(ble_evnet_t *event, void *output) -{ +static void ble_disconnect_event_handler(ble_evnet_t *event, void *output) { #ifdef IBRT - if (app_ibrt_ui_get_snoop_via_ble_enable()) - { - app_ibrt_ui_set_master_notify_flag(false); - app_ibrt_ui_clear_box_connect_state(IBRT_BOX_CONNECT_MASTER, FALSE); - } + if (app_ibrt_ui_get_snoop_via_ble_enable()) { + app_ibrt_ui_set_master_notify_flag(false); + app_ibrt_ui_clear_box_connect_state(IBRT_BOX_CONNECT_MASTER, FALSE); + } #endif } -static void ble_conn_param_update_req_event_handler(ble_evnet_t *event, void *output) -{ - if (a2dp_is_music_ongoing() || is_sco_mode()) - { - *(bool *)output = false; - } +static void ble_conn_param_update_req_event_handler(ble_evnet_t *event, + void *output) { + if (a2dp_is_music_ongoing() || is_sco_mode()) { + *(bool *)output = false; + } } -static void ble_set_random_bd_addr_event_handler(ble_evnet_t *event, void *output) -{ - // Indicate that a new random BD address set in lower layers +static void ble_set_random_bd_addr_event_handler(ble_evnet_t *event, + void *output) { + // Indicate that a new random BD address set in lower layers } -static const ble_event_handler_t ble_event_handler_tab[] = -{ +static const ble_event_handler_t ble_event_handler_tab[] = { {BLE_CONNECT_EVENT, ble_connect_event_handler}, {BLE_DISCONNECT_EVENT, ble_disconnect_event_handler}, {BLE_CONN_PARAM_UPDATE_REQ_EVENT, ble_conn_param_update_req_event_handler}, {BLE_SET_RANDOM_BD_ADDR_EVENT, ble_set_random_bd_addr_event_handler}, }; -//handle the event that from ble lower layers -void app_ble_core_global_handle(ble_evnet_t *event, void *output) -{ - uint8_t evt_type = event->evt_type; - uint16_t index = 0; - const ble_event_handler_t *p_ble_event_hand = NULL; +// handle the event that from ble lower layers +void app_ble_core_global_handle(ble_evnet_t *event, void *output) { + uint8_t evt_type = event->evt_type; + uint16_t index = 0; + const ble_event_handler_t *p_ble_event_hand = NULL; - for (index=0; indexevt_type == evt_type) - { - p_ble_event_hand->func(event, output); - break; - } + for (index = 0; index < BLE_EVENT_NUM_MAX; index++) { + p_ble_event_hand = &ble_event_handler_tab[index]; + if (p_ble_event_hand->evt_type == evt_type) { + p_ble_event_hand->func(event, output); + break; } + } - if (g_ble_core_global_handler_ind) - { - g_ble_core_global_handler_ind(event, output); - } + if (g_ble_core_global_handler_ind) { + g_ble_core_global_handler_ind(event, output); + } } - -static void ble_callback_roleswitch_start_handler(ble_callback_evnet_t *event, void *output) -{ - LOG_I("%s", __func__); - // disable adv after role switch start - app_ble_force_switch_adv(BLE_SWITCH_USER_RS, false); +static void ble_callback_roleswitch_start_handler(ble_callback_evnet_t *event, + void *output) { + LOG_I("%s", __func__); + // disable adv after role switch start + app_ble_force_switch_adv(BLE_SWITCH_USER_RS, false); } -static void ble_callback_roleswitch_complete_handler(ble_callback_evnet_t *event, void *output) -{ +static void +ble_callback_roleswitch_complete_handler(ble_callback_evnet_t *event, + void *output) { #if defined(IBRT) - // enable adv after role switch complete - uint8_t newRole = event->p.rs_complete_handled.newRole; - LOG_I("%s newRole %d", __func__, newRole); - app_ble_force_switch_adv(BLE_SWITCH_USER_RS, true); - if (newRole == IBRT_SLAVE) - { - app_ble_disconnect_all(); - } + // enable adv after role switch complete + uint8_t newRole = event->p.rs_complete_handled.newRole; + LOG_I("%s newRole %d", __func__, newRole); + app_ble_force_switch_adv(BLE_SWITCH_USER_RS, true); + if (newRole == IBRT_SLAVE) { + app_ble_disconnect_all(); + } #endif } -static void ble_callback_role_update_handler(ble_callback_evnet_t *event, void *output) -{ +static void ble_callback_role_update_handler(ble_callback_evnet_t *event, + void *output) { #if defined(IBRT) - uint8_t newRole = event->p.role_update_handled.newRole; - LOG_I("%s newRole %d", __func__, newRole); - app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); - if (newRole == IBRT_SLAVE) - { - app_ble_disconnect_all(); - } + uint8_t newRole = event->p.role_update_handled.newRole; + LOG_I("%s newRole %d", __func__, newRole); + app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); + if (newRole == IBRT_SLAVE) { + app_ble_disconnect_all(); + } #endif } -static void ble_callback_ibrt_event_entry_handler(ble_callback_evnet_t *event, void *output) -{ +static void ble_callback_ibrt_event_entry_handler(ble_callback_evnet_t *event, + void *output) { #if defined(IBRT) - uint8_t ibrt_evt_type = event->p.ibrt_event_entry_handled.event; - LOG_I("%s evt_type %d", __func__, ibrt_evt_type); - if (IBRT_OPEN_BOX_EVENT == ibrt_evt_type) - { - app_ble_force_switch_adv(BLE_SWITCH_USER_BOX, true); - } - else if (IBRT_FETCH_OUT_EVENT == ibrt_evt_type) - { - app_ble_force_switch_adv(BLE_SWITCH_USER_BOX, true); - } - else if (IBRT_CLOSE_BOX_EVENT == ibrt_evt_type) - { - app_ble_force_switch_adv(BLE_SWITCH_USER_BOX, false); - } + uint8_t ibrt_evt_type = event->p.ibrt_event_entry_handled.event; + LOG_I("%s evt_type %d", __func__, ibrt_evt_type); + if (IBRT_OPEN_BOX_EVENT == ibrt_evt_type) { + app_ble_force_switch_adv(BLE_SWITCH_USER_BOX, true); + } else if (IBRT_FETCH_OUT_EVENT == ibrt_evt_type) { + app_ble_force_switch_adv(BLE_SWITCH_USER_BOX, true); + } else if (IBRT_CLOSE_BOX_EVENT == ibrt_evt_type) { + app_ble_force_switch_adv(BLE_SWITCH_USER_BOX, false); + } #endif } -static const ble_callback_event_handler_t ble_callback_event_handler_tab[] = -{ +static const ble_callback_event_handler_t ble_callback_event_handler_tab[] = { {BLE_CALLBACK_RS_START, ble_callback_roleswitch_start_handler}, {BLE_CALLBACK_RS_COMPLETE, ble_callback_roleswitch_complete_handler}, {BLE_CALLBACK_ROLE_UPDATE, ble_callback_role_update_handler}, {BLE_CALLBACK_IBRT_EVENT_ENTRY, ble_callback_ibrt_event_entry_handler}, }; -//handle the event that from other module -void app_ble_core_global_callback_event(ble_callback_evnet_t *event, void *output) -{ - uint8_t evt_type = event->evt_type; - uint16_t index = 0; - const ble_callback_event_handler_t *p_ble_callback_event_hand = NULL; - - for (index=0; indexevt_type == evt_type) - { - p_ble_callback_event_hand->func(event, output); - break; - } - } +// handle the event that from other module +void app_ble_core_global_callback_event(ble_callback_evnet_t *event, + void *output) { + uint8_t evt_type = event->evt_type; + uint16_t index = 0; + const ble_callback_event_handler_t *p_ble_callback_event_hand = NULL; - if (g_ble_core_global_callback_handler_ind) - { - g_ble_core_global_callback_handler_ind(event, output); + for (index = 0; index < BLE_EVENT_NUM_MAX; index++) { + p_ble_callback_event_hand = &ble_callback_event_handler_tab[index]; + if (p_ble_callback_event_hand->evt_type == evt_type) { + p_ble_callback_event_hand->func(event, output); + break; } + } + + if (g_ble_core_global_callback_handler_ind) { + g_ble_core_global_callback_handler_ind(event, output); + } } -static void app_ble_stub_user_data_fill_handler(void *param) -{ - LOG_I("%s", __func__); - bool adv_enable = false; +static void app_ble_stub_user_data_fill_handler(void *param) { + LOG_I("%s", __func__); + bool adv_enable = false; #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (!p_ibrt_ctrl->init_done) - { - LOG_I("%s ibrt don't init", __func__); - } - else if (p_ibrt_ctrl->current_role != IBRT_MASTER) - { - LOG_I("%s role %d isn't MASTER", __func__, p_ibrt_ctrl->current_role); - } - else + if (!p_ibrt_ctrl->init_done) { + LOG_I("%s ibrt don't init", __func__); + } else if (p_ibrt_ctrl->current_role != IBRT_MASTER) { + LOG_I("%s role %d isn't MASTER", __func__, p_ibrt_ctrl->current_role); + } else #endif - if (app_ble_get_user_register() & ~(1 << USER_STUB)) - { - LOG_I("%s have other user register 0x%x", __func__, app_ble_get_user_register()); - } - else - { - adv_enable = true; - } + if (app_ble_get_user_register() & ~(1 << USER_STUB)) { + LOG_I("%s have other user register 0x%x", __func__, + app_ble_get_user_register()); + } else { + adv_enable = true; + } - app_ble_data_fill_enable(USER_STUB, adv_enable); + app_ble_data_fill_enable(USER_STUB, adv_enable); } -void app_ble_stub_user_init(void) -{ - LOG_I("%s", __func__); - app_ble_register_data_fill_handle(USER_STUB, (BLE_DATA_FILL_FUNC_T)app_ble_stub_user_data_fill_handler, false); +void app_ble_stub_user_init(void) { + LOG_I("%s", __func__); + app_ble_register_data_fill_handle( + USER_STUB, (BLE_DATA_FILL_FUNC_T)app_ble_stub_user_data_fill_handler, + false); } #ifdef TWS_SYSTEM_ENABLED -static void ble_sync_info_prepare_handler(uint8_t *buf, uint16_t *length) -{ - *length = sizeof(NV_RECORD_PAIRED_BLE_DEV_INFO_T); +static void ble_sync_info_prepare_handler(uint8_t *buf, uint16_t *length) { + *length = sizeof(NV_RECORD_PAIRED_BLE_DEV_INFO_T); - NV_RECORD_PAIRED_BLE_DEV_INFO_T *pBleInfo = nv_record_blerec_get_ptr(); + NV_RECORD_PAIRED_BLE_DEV_INFO_T *pBleInfo = nv_record_blerec_get_ptr(); - memcpy(buf, pBleInfo, *length); + memcpy(buf, pBleInfo, *length); } -static void ble_sync_info_received_handler(uint8_t *buf, uint16_t length) -{ - NV_RECORD_PAIRED_BLE_DEV_INFO_T *pReceivedBleInfo = (NV_RECORD_PAIRED_BLE_DEV_INFO_T *)buf; +static void ble_sync_info_received_handler(uint8_t *buf, uint16_t length) { + NV_RECORD_PAIRED_BLE_DEV_INFO_T *pReceivedBleInfo = + (NV_RECORD_PAIRED_BLE_DEV_INFO_T *)buf; - // basic info - nv_record_extension_update_tws_ble_info(pReceivedBleInfo); + // basic info + nv_record_extension_update_tws_ble_info(pReceivedBleInfo); - // pair info - for (uint32_t index = 0; index < pReceivedBleInfo->saved_list_num; index++) - { - nv_record_blerec_add(&pReceivedBleInfo->ble_nv[index]); - } + // pair info + for (uint32_t index = 0; index < pReceivedBleInfo->saved_list_num; index++) { + nv_record_blerec_add(&pReceivedBleInfo->ble_nv[index]); + } #ifdef CFG_APP_SEC - app_sec_init(); + app_sec_init(); #endif } -static void ble_sync_info_rsp_received_handler(uint8_t *buf, uint16_t length) -{ - NV_RECORD_PAIRED_BLE_DEV_INFO_T *pReceivedBleInfo = (NV_RECORD_PAIRED_BLE_DEV_INFO_T *)buf; +static void ble_sync_info_rsp_received_handler(uint8_t *buf, uint16_t length) { + NV_RECORD_PAIRED_BLE_DEV_INFO_T *pReceivedBleInfo = + (NV_RECORD_PAIRED_BLE_DEV_INFO_T *)buf; - nv_record_extension_update_tws_ble_info(pReceivedBleInfo); - for (uint32_t index = 0; index < pReceivedBleInfo->saved_list_num; index++) - { - nv_record_blerec_add(&pReceivedBleInfo->ble_nv[index]); - } + nv_record_extension_update_tws_ble_info(pReceivedBleInfo); + for (uint32_t index = 0; index < pReceivedBleInfo->saved_list_num; index++) { + nv_record_blerec_add(&pReceivedBleInfo->ble_nv[index]); + } } -void app_ble_mode_tws_sync_init(void) -{ - TWS_SYNC_USER_T userBle = { - ble_sync_info_prepare_handler, - ble_sync_info_received_handler, - ble_sync_info_prepare_handler, - ble_sync_info_rsp_received_handler, - NULL, - }; +void app_ble_mode_tws_sync_init(void) { + TWS_SYNC_USER_T userBle = { + ble_sync_info_prepare_handler, + ble_sync_info_received_handler, + ble_sync_info_prepare_handler, + ble_sync_info_rsp_received_handler, + NULL, + }; - app_tws_if_register_sync_user(TWS_SYNC_USER_BLE_INFO, &userBle); + app_tws_if_register_sync_user(TWS_SYNC_USER_BLE_INFO, &userBle); } -void app_ble_sync_ble_info(void) -{ - app_tws_if_sync_info(TWS_SYNC_USER_BLE_INFO); +void app_ble_sync_ble_info(void) { + app_tws_if_sync_info(TWS_SYNC_USER_BLE_INFO); } #endif -void ble_adv_data_parse(uint8_t *bleBdAddr, - int8_t rssi, - unsigned char *adv_buf, - unsigned char len) -{ +void ble_adv_data_parse(uint8_t *bleBdAddr, int8_t rssi, unsigned char *adv_buf, + unsigned char len) { #ifdef IBRT - bd_addr_t *box_ble_addr = (bd_addr_t *)app_ibrt_ui_get_box_ble_addr(); - LOG_I("%s", __func__); - //DUMP8("%02x ", (uint8_t *)box_ble_addr, BTIF_BD_ADDR_SIZE); - DUMP8("%02x ", bleBdAddr, BTIF_BD_ADDR_SIZE); + bd_addr_t *box_ble_addr = (bd_addr_t *)app_ibrt_ui_get_box_ble_addr(); + LOG_I("%s", __func__); + // DUMP8("%02x ", (uint8_t *)box_ble_addr, BTIF_BD_ADDR_SIZE); + DUMP8("%02x ", bleBdAddr, BTIF_BD_ADDR_SIZE); - if (app_ibrt_ui_get_snoop_via_ble_enable()) - { - if (!memcmp(box_ble_addr, bleBdAddr, BTIF_BD_ADDR_SIZE) && app_ibrt_ui_is_slave_scaning()) - { - app_ibrt_ui_set_slave_scaning(FALSE); - app_scanning_stopped(); - app_ble_start_connect((uint8_t *)box_ble_addr); - } + if (app_ibrt_ui_get_snoop_via_ble_enable()) { + if (!memcmp(box_ble_addr, bleBdAddr, BTIF_BD_ADDR_SIZE) && + app_ibrt_ui_is_slave_scaning()) { + app_ibrt_ui_set_slave_scaning(FALSE); + app_scanning_stopped(); + app_ble_start_connect((uint8_t *)box_ble_addr); } + } #endif } - diff --git a/services/ble_app/app_main/app_ble_customif.c b/services/ble_app/app_main/app_ble_customif.c index ed98545..0e3d531 100644 --- a/services/ble_app/app_main/app_ble_customif.c +++ b/services/ble_app/app_main/app_ble_customif.c @@ -1,133 +1,130 @@ /*************************************************************************** -* -*Copyright 2015-2019 BES. -*All rights reserved. All unpublished rights reserved. -* -*No part of this work may be used or reproduced in any form or by any -*means, or stored in a database or retrieval system, without prior written -*permission of BES. -* -*Use of this work is governed by a license granted by BES. -*This work contains confidential and proprietary information of -*BES. which is protected by copyright, trade secret, -*trademark and other intellectual property rights. -* -****************************************************************************/ + * + *Copyright 2015-2019 BES. + *All rights reserved. All unpublished rights reserved. + * + *No part of this work may be used or reproduced in any form or by any + *means, or stored in a database or retrieval system, without prior written + *permission of BES. + * + *Use of this work is governed by a license granted by BES. + *This work contains confidential and proprietary information of + *BES. which is protected by copyright, trade secret, + *trademark and other intellectual property rights. + * + ****************************************************************************/ /*****************************header include********************************/ -#include "string.h" -#include "co_math.h" // Common Maths Definition -#include "cmsis_os.h" -#include "ble_app_dbg.h" -#include "stdbool.h" +#include "app.h" +#include "app_ble_include.h" +#include "app_bt.h" +#include "app_bt_func.h" +#include "app_hfp.h" +#include "app_sec.h" #include "app_thread.h" #include "app_utils.h" #include "apps.h" -#include "app.h" -#include "app_sec.h" -#include "app_ble_include.h" -#include "nvrecord.h" -#include "app_bt_func.h" +#include "ble_app_dbg.h" +#include "cmsis_os.h" +#include "co_math.h" // Common Maths Definition #include "hal_timer.h" -#include "app_bt.h" -#include "app_hfp.h" -#include "rwprf_config.h" +#include "nvrecord.h" #include "nvrecord_ble.h" -#include "app_sec.h" +#include "rwprf_config.h" +#include "stdbool.h" +#include "string.h" #ifdef IBRT #include "app_ibrt_ui.h" #include "app_tws_if.h" #endif -static void app_ble_customif_connect_event_handler(ble_evnet_t *event, void *output) -{ +static void app_ble_customif_connect_event_handler(ble_evnet_t *event, + void *output) {} + +static void app_ble_customif_disconnect_event_handler(ble_evnet_t *event, + void *output) {} + +static void +app_ble_customif_conn_param_update_req_event_handler(ble_evnet_t *event, + void *output) {} + +static void +app_ble_customif_set_random_bd_addr_event_handler(ble_evnet_t *event, + void *output) { + // Indicate that a new random BD address set in lower layers } -static void app_ble_customif_disconnect_event_handler(ble_evnet_t *event, void *output) -{ -} - -static void app_ble_customif_conn_param_update_req_event_handler(ble_evnet_t *event, void *output) -{ -} - -static void app_ble_customif_set_random_bd_addr_event_handler(ble_evnet_t *event, void *output) -{ - // Indicate that a new random BD address set in lower layers -} - -static const ble_event_handler_t app_ble_customif_event_handler_tab[] = -{ +static const ble_event_handler_t app_ble_customif_event_handler_tab[] = { {BLE_CONNECT_EVENT, app_ble_customif_connect_event_handler}, {BLE_DISCONNECT_EVENT, app_ble_customif_disconnect_event_handler}, - {BLE_CONN_PARAM_UPDATE_REQ_EVENT, app_ble_customif_conn_param_update_req_event_handler}, - {BLE_SET_RANDOM_BD_ADDR_EVENT, app_ble_customif_set_random_bd_addr_event_handler}, + {BLE_CONN_PARAM_UPDATE_REQ_EVENT, + app_ble_customif_conn_param_update_req_event_handler}, + {BLE_SET_RANDOM_BD_ADDR_EVENT, + app_ble_customif_set_random_bd_addr_event_handler}, }; -//handle the event that from ble lower layers -void app_ble_customif_global_handler_ind(ble_evnet_t *event, void *output) -{ - uint8_t evt_type = event->evt_type; - uint16_t index = 0; - const ble_event_handler_t *p_ble_event_hand = NULL; +// handle the event that from ble lower layers +void app_ble_customif_global_handler_ind(ble_evnet_t *event, void *output) { + uint8_t evt_type = event->evt_type; + uint16_t index = 0; + const ble_event_handler_t *p_ble_event_hand = NULL; - for (index=0; indexevt_type == evt_type) - { - p_ble_event_hand->func(event, output); - break; - } + for (index = 0; index < BLE_EVENT_NUM_MAX; index++) { + p_ble_event_hand = &app_ble_customif_event_handler_tab[index]; + if (p_ble_event_hand->evt_type == evt_type) { + p_ble_event_hand->func(event, output); + break; } + } } -static void app_ble_customif_callback_roleswitch_start_handler(ble_callback_evnet_t *event, void *output) -{ -} +static void +app_ble_customif_callback_roleswitch_start_handler(ble_callback_evnet_t *event, + void *output) {} -static void app_ble_customif_callback_roleswitch_complete_handler(ble_callback_evnet_t *event, void *output) -{ -} +static void app_ble_customif_callback_roleswitch_complete_handler( + ble_callback_evnet_t *event, void *output) {} -static void app_ble_customif_callback_role_update_handler(ble_callback_evnet_t *event, void *output) -{ -} +static void +app_ble_customif_callback_role_update_handler(ble_callback_evnet_t *event, + void *output) {} -static void app_ble_customif_callback_ibrt_event_entry_handler(ble_callback_evnet_t *event, void *output) -{ -} +static void +app_ble_customif_callback_ibrt_event_entry_handler(ble_callback_evnet_t *event, + void *output) {} -static const ble_callback_event_handler_t app_ble_customif_callback_event_handler_tab[] = -{ - {BLE_CALLBACK_RS_START, app_ble_customif_callback_roleswitch_start_handler}, - {BLE_CALLBACK_RS_COMPLETE, app_ble_customif_callback_roleswitch_complete_handler}, - {BLE_CALLBACK_ROLE_UPDATE, app_ble_customif_callback_role_update_handler}, - {BLE_CALLBACK_IBRT_EVENT_ENTRY, app_ble_customif_callback_ibrt_event_entry_handler}, +static const ble_callback_event_handler_t + app_ble_customif_callback_event_handler_tab[] = { + {BLE_CALLBACK_RS_START, + app_ble_customif_callback_roleswitch_start_handler}, + {BLE_CALLBACK_RS_COMPLETE, + app_ble_customif_callback_roleswitch_complete_handler}, + {BLE_CALLBACK_ROLE_UPDATE, + app_ble_customif_callback_role_update_handler}, + {BLE_CALLBACK_IBRT_EVENT_ENTRY, + app_ble_customif_callback_ibrt_event_entry_handler}, }; -//handle the event that from other module -void app_ble_customif_global_callback_handler_ind(ble_callback_evnet_t *event, void *output) -{ - uint8_t evt_type = event->evt_type; - uint16_t index = 0; - const ble_callback_event_handler_t *p_ble_callback_event_hand = NULL; - - for (index=0; indexevt_type == evt_type) - { - p_ble_callback_event_hand->func(event, output); - break; - } - } +// handle the event that from other module +void app_ble_customif_global_callback_handler_ind(ble_callback_evnet_t *event, + void *output) { + uint8_t evt_type = event->evt_type; + uint16_t index = 0; + const ble_callback_event_handler_t *p_ble_callback_event_hand = NULL; + + for (index = 0; index < BLE_EVENT_NUM_MAX; index++) { + p_ble_callback_event_hand = + &app_ble_customif_callback_event_handler_tab[index]; + if (p_ble_callback_event_hand->evt_type == evt_type) { + p_ble_callback_event_hand->func(event, output); + break; + } + } } -void app_ble_customif_init(void) -{ - LOG_I("%s", __func__); - app_ble_core_register_global_handler_ind(app_ble_customif_global_handler_ind); - app_ble_core_register_global_callback_handle_ind(app_ble_customif_global_callback_handler_ind); +void app_ble_customif_init(void) { + LOG_I("%s", __func__); + app_ble_core_register_global_handler_ind(app_ble_customif_global_handler_ind); + app_ble_core_register_global_callback_handle_ind( + app_ble_customif_global_callback_handler_ind); } - diff --git a/services/ble_app/app_main/app_ble_mode_switch.c b/services/ble_app/app_main/app_ble_mode_switch.c index e66be14..db290a8 100644 --- a/services/ble_app/app_main/app_ble_mode_switch.c +++ b/services/ble_app/app_main/app_ble_mode_switch.c @@ -1,72 +1,68 @@ /*************************************************************************** -* -*Copyright 2015-2019 BES. -*All rights reserved. All unpublished rights reserved. -* -*No part of this work may be used or reproduced in any form or by any -*means, or stored in a database or retrieval system, without prior written -*permission of BES. -* -*Use of this work is governed by a license granted by BES. -*This work contains confidential and proprietary information of -*BES. which is protected by copyright, trade secret, -*trademark and other intellectual property rights. -* -****************************************************************************/ + * + *Copyright 2015-2019 BES. + *All rights reserved. All unpublished rights reserved. + * + *No part of this work may be used or reproduced in any form or by any + *means, or stored in a database or retrieval system, without prior written + *permission of BES. + * + *Use of this work is governed by a license granted by BES. + *This work contains confidential and proprietary information of + *BES. which is protected by copyright, trade secret, + *trademark and other intellectual property rights. + * + ****************************************************************************/ /*****************************header include********************************/ -#include "string.h" -#include "co_math.h" // Common Maths Definition -#include "cmsis_os.h" -#include "ble_app_dbg.h" -#include "stdbool.h" +#include "app.h" +#include "app_ble_include.h" +#include "app_bt.h" +#include "app_bt_func.h" +#include "app_hfp.h" +#include "app_sec.h" #include "app_thread.h" #include "app_utils.h" #include "apps.h" -#include "app.h" -#include "app_sec.h" -#include "app_ble_include.h" -#include "nvrecord.h" -#include "app_bt_func.h" +#include "ble_app_dbg.h" +#include "cmsis_os.h" +#include "co_math.h" // Common Maths Definition #include "hal_timer.h" -#include "app_bt.h" -#include "app_hfp.h" -#include "rwprf_config.h" +#include "nvrecord.h" #include "nvrecord_ble.h" -#include "app_sec.h" +#include "rwprf_config.h" +#include "stdbool.h" +#include "string.h" /************************private macro defination***************************/ #define DEBUG_BLE_STATE_MACHINE true #if DEBUG_BLE_STATE_MACHINE -#define SET_BLE_STATE(newState) \ - do \ - { \ - LOG_I("[STATE]%s->%s at line %d", ble_state2str(bleModeEnv.state), ble_state2str(newState), __LINE__); \ - bleModeEnv.state = (newState); \ - } while (0); +#define SET_BLE_STATE(newState) \ + do { \ + LOG_I("[STATE]%s->%s at line %d", ble_state2str(bleModeEnv.state), \ + ble_state2str(newState), __LINE__); \ + bleModeEnv.state = (newState); \ + } while (0); -#define SET_BLE_OP(newOp) \ - do \ - { \ - LOG_I("[OP]%s->%s at line %d", ble_op2str(bleModeEnv.op), ble_op2str(newOp), __LINE__); \ - bleModeEnv.op = (newOp); \ - } while (0); +#define SET_BLE_OP(newOp) \ + do { \ + LOG_I("[OP]%s->%s at line %d", ble_op2str(bleModeEnv.op), \ + ble_op2str(newOp), __LINE__); \ + bleModeEnv.op = (newOp); \ + } while (0); #else -#define SET_BLE_STATE(newState) \ - do \ - { \ - bleModeEnv.state = (newState); \ - } while (0); +#define SET_BLE_STATE(newState) \ + do { \ + bleModeEnv.state = (newState); \ + } while (0); -#define SET_BLE_OP(newOp) \ - do \ - { \ - bleModeEnv.op = (newOp); \ - } while (0); +#define SET_BLE_OP(newOp) \ + do { \ + bleModeEnv.op = (newOp); \ + } while (0); #endif - extern void bt_drv_reg_op_set_rand_seed(uint32_t seed); /************************private type defination****************************/ @@ -266,945 +262,807 @@ static BLE_SCAN_PARAM_T scanParam; /****************************function defination****************************/ // common used function #ifdef USE_LOG_I_ID -static inline char *ble_state2str(uint8_t state) -{ - return (char *)(uint32_t)state; +static inline char *ble_state2str(uint8_t state) { + return (char *)(uint32_t)state; } -static inline char *ble_op2str(uint8_t op) -{ - return (char *)(uint32_t)op; -} -static inline char *ble_adv_user2str(enum BLE_ADV_USER_E user) -{ - return (char *)(uint32_t)user; +static inline char *ble_op2str(uint8_t op) { return (char *)(uint32_t)op; } +static inline char *ble_adv_user2str(enum BLE_ADV_USER_E user) { + return (char *)(uint32_t)user; } #else -static char *ble_state2str(uint8_t state) -{ - char *str = NULL; +static char *ble_state2str(uint8_t state) { + char *str = NULL; -#define CASES(state) \ - case state: \ - str = "[" #state "]"; \ - break +#define CASES(state) \ + case state: \ + str = "[" #state "]"; \ + break - switch (state) - { - CASES(STATE_IDLE); - CASES(ADVERTISING); - CASES(STARTING_ADV); - CASES(STOPPING_ADV); - CASES(SCANNING); - CASES(STARTING_SCAN); - CASES(STOPPING_SCAN); - CASES(CONNECTING); - CASES(STARTING_CONNECT); - CASES(STOPPING_CONNECT); + switch (state) { + CASES(STATE_IDLE); + CASES(ADVERTISING); + CASES(STARTING_ADV); + CASES(STOPPING_ADV); + CASES(SCANNING); + CASES(STARTING_SCAN); + CASES(STOPPING_SCAN); + CASES(CONNECTING); + CASES(STARTING_CONNECT); + CASES(STOPPING_CONNECT); - default: - str = "[INVALID]"; - break; - } + default: + str = "[INVALID]"; + break; + } - return str; + return str; } -static char *ble_op2str(uint8_t op) -{ - char *str = NULL; +static char *ble_op2str(uint8_t op) { + char *str = NULL; -#define CASEO(op) \ - case op: \ - str = "[" #op "]"; \ - break +#define CASEO(op) \ + case op: \ + str = "[" #op "]"; \ + break - switch (op) - { - CASEO(OP_IDLE); - CASEO(START_ADV); - CASEO(START_SCAN); - CASEO(START_CONNECT); - CASEO(STOP_ADV); - CASEO(STOP_SCAN); - CASEO(STOP_CONNECT); + switch (op) { + CASEO(OP_IDLE); + CASEO(START_ADV); + CASEO(START_SCAN); + CASEO(START_CONNECT); + CASEO(STOP_ADV); + CASEO(STOP_SCAN); + CASEO(STOP_CONNECT); - default: - str = "[INVALID]"; - break; - } + default: + str = "[INVALID]"; + break; + } - return str; + return str; } -static char *ble_adv_user2str(enum BLE_ADV_USER_E user) -{ -#define CASE_S(s) \ - case s: \ - return "[" #s "]"; -#define CASE_D() \ - default: \ - return "[INVALID]"; +static char *ble_adv_user2str(enum BLE_ADV_USER_E user) { +#define CASE_S(s) \ + case s: \ + return "[" #s "]"; +#define CASE_D() \ + default: \ + return "[INVALID]"; - switch (user) - { - CASE_S(USER_STUB) - CASE_S(USER_GFPS) - CASE_S(USER_GSOUND) - CASE_S(USER_AI) - CASE_S(USER_INTERCONNECTION) - CASE_S(USER_TILE) - CASE_S(USER_OTA) - CASE_D() - } + switch (user) { + CASE_S(USER_STUB) + CASE_S(USER_GFPS) + CASE_S(USER_GSOUND) + CASE_S(USER_AI) + CASE_S(USER_INTERCONNECTION) + CASE_S(USER_TILE) + CASE_S(USER_OTA) + CASE_D() + } } #endif +void app_ble_mode_init(void) { + LOG_I("%s", __func__); -void app_ble_mode_init(void) -{ - LOG_I("%s", __func__); + memset(&bleModeEnv, 0, sizeof(bleModeEnv)); + SET_BLE_STATE(STATE_IDLE); + SET_BLE_OP(OP_IDLE); - memset(&bleModeEnv, 0, sizeof(bleModeEnv)); - SET_BLE_STATE(STATE_IDLE); - SET_BLE_OP(OP_IDLE); - - bleModeEnv.bleEnv = &app_env; + bleModeEnv.bleEnv = &app_env; } // ble advertisement used functions -static void ble_adv_config_param(uint8_t advType, uint16_t advInterval) -{ - uint8_t avail_space; - memset(&advParam, 0, sizeof(advParam)); +static void ble_adv_config_param(uint8_t advType, uint16_t advInterval) { + uint8_t avail_space; + memset(&advParam, 0, sizeof(advParam)); - advParam.advType = advType; - advParam.advInterval = advInterval; - advParam.withFlag = true; + advParam.advType = advType; + advParam.advInterval = advInterval; + advParam.withFlag = true; - // connectable adv is not allowed if max connection reaches - if (app_is_arrive_at_max_ble_connections() && (GAPM_ADV_UNDIRECT == advType)) - { - LOG_W("will change adv type to none-connectable because max ble connection reaches"); - advParam.advType = GAPM_ADV_NON_CONN; + // connectable adv is not allowed if max connection reaches + if (app_is_arrive_at_max_ble_connections() && + (GAPM_ADV_UNDIRECT == advType)) { + LOG_W("will change adv type to none-connectable because max ble connection " + "reaches"); + advParam.advType = GAPM_ADV_NON_CONN; + } + + for (uint8_t user = 0; user < BLE_ADV_USER_NUM; user++) { + if (bleModeEnv.bleDataFillFunc[user]) { + bleModeEnv.bleDataFillFunc[user]((void *)&advParam); + + // check if the adv/scan_rsp data length is legal + if (advParam.withFlag) { + ASSERT(BLE_ADV_DATA_WITH_FLAG_LEN >= advParam.advDataLen, + "[BLE][ADV]adv data exceed"); + } else { + ASSERT(BLE_ADV_DATA_WITHOUT_FLAG_LEN >= advParam.advDataLen, + "[BLE][ADV]adv data exceed"); + } + ASSERT(SCAN_RSP_DATA_LEN >= advParam.scanRspDataLen, + "[BLE][ADV]scan response data exceed"); } + } - for (uint8_t user = 0; user < BLE_ADV_USER_NUM; user++) - { - if (bleModeEnv.bleDataFillFunc[user]) - { - bleModeEnv.bleDataFillFunc[user]((void *)&advParam); + if (advParam.withFlag) { + avail_space = BLE_ADV_DATA_WITH_FLAG_LEN - advParam.advDataLen - + BLE_ADV_DATA_STRUCT_HEADER_LEN; + } else { + avail_space = BLE_ADV_DATA_WITHOUT_FLAG_LEN - advParam.advDataLen - + BLE_ADV_DATA_STRUCT_HEADER_LEN; + } - // check if the adv/scan_rsp data length is legal - if(advParam.withFlag) - { - ASSERT(BLE_ADV_DATA_WITH_FLAG_LEN >= advParam.advDataLen, "[BLE][ADV]adv data exceed"); - } - else - { - ASSERT(BLE_ADV_DATA_WITHOUT_FLAG_LEN >= advParam.advDataLen, "[BLE][ADV]adv data exceed"); - } - ASSERT(SCAN_RSP_DATA_LEN >= advParam.scanRspDataLen, "[BLE][ADV]scan response data exceed"); - } - } - - if(advParam.withFlag) - { - avail_space = BLE_ADV_DATA_WITH_FLAG_LEN - advParam.advDataLen - BLE_ADV_DATA_STRUCT_HEADER_LEN; - } - else - { - avail_space = BLE_ADV_DATA_WITHOUT_FLAG_LEN - advParam.advDataLen - BLE_ADV_DATA_STRUCT_HEADER_LEN; - } - - // Check if data can be added to the adv Data - if (avail_space > 2) - { - avail_space = co_min(avail_space, bleModeEnv.bleEnv->dev_name_len); - advParam.advData[advParam.advDataLen++] = avail_space + 1; - // Fill Device Name Flag - advParam.advData[advParam.advDataLen++] = - (avail_space == bleModeEnv.bleEnv->dev_name_len) ? '\x08' : '\x09'; - // Copy device name - memcpy(&advParam.advData[advParam.advDataLen], bleModeEnv.bleEnv->dev_name, avail_space); - // Update adv Data Length - advParam.advDataLen += avail_space; - } + // Check if data can be added to the adv Data + if (avail_space > 2) { + avail_space = co_min(avail_space, bleModeEnv.bleEnv->dev_name_len); + advParam.advData[advParam.advDataLen++] = avail_space + 1; + // Fill Device Name Flag + advParam.advData[advParam.advDataLen++] = + (avail_space == bleModeEnv.bleEnv->dev_name_len) ? '\x08' : '\x09'; + // Copy device name + memcpy(&advParam.advData[advParam.advDataLen], bleModeEnv.bleEnv->dev_name, + avail_space); + // Update adv Data Length + advParam.advDataLen += avail_space; + } } -static bool ble_adv_is_allowed(void) -{ - bool allowed_adv = true; - if (!app_is_stack_ready()) - { - LOG_I("reason: stack not ready"); - allowed_adv = false; - } +static bool ble_adv_is_allowed(void) { + bool allowed_adv = true; + if (!app_is_stack_ready()) { + LOG_I("reason: stack not ready"); + allowed_adv = false; + } - if (app_is_power_off_in_progress()) - { - LOG_I("reason: in power off mode"); - allowed_adv = false; - } + if (app_is_power_off_in_progress()) { + LOG_I("reason: in power off mode"); + allowed_adv = false; + } - if (bleModeEnv.advSwitch) - { - LOG_I("adv switched off:%d", bleModeEnv.advSwitch); - allowed_adv = false; - } + if (bleModeEnv.advSwitch) { + LOG_I("adv switched off:%d", bleModeEnv.advSwitch); + allowed_adv = false; + } - if (btapp_hfp_is_sco_active()) - { - LOG_I("SCO ongoing"); - allowed_adv = false; - } + if (btapp_hfp_is_sco_active()) { + LOG_I("SCO ongoing"); + allowed_adv = false; + } - if (false == allowed_adv) - { - app_ble_stop_activities(); - } + if (false == allowed_adv) { + app_ble_stop_activities(); + } - return allowed_adv; + return allowed_adv; } -static void ble_start_adv(void *param) -{ - switch (bleModeEnv.state) - { +static void ble_start_adv(void *param) { + switch (bleModeEnv.state) { + case ADVERTISING: + SET_BLE_STATE(STOPPING_ADV); + SET_BLE_OP(START_ADV); + appm_stop_advertising(); + break; + + case SCANNING: + SET_BLE_STATE(STOPPING_SCAN); + SET_BLE_OP(START_ADV); + appm_stop_scanning(); + break; + + case CONNECTING: + SET_BLE_STATE(STOPPING_CONNECT); + SET_BLE_OP(START_ADV); + appm_stop_connecting(); + break; + + case STARTING_ADV: + case STARTING_SCAN: + case STARTING_CONNECT: + case STOPPING_ADV: + case STOPPING_SCAN: + case STOPPING_CONNECT: + SET_BLE_OP(START_ADV); + break; + + case STATE_IDLE: + if (!ble_adv_is_allowed()) { + LOG_I("[ADV] not allowed."); + if (START_ADV == bleModeEnv.op) { + SET_BLE_OP(OP_IDLE); + } + break; + } + + memcpy(&bleModeEnv.advInfo, param, sizeof(bleModeEnv.advInfo)); + appm_start_advertising(&bleModeEnv.advInfo); + + SET_BLE_STATE(STARTING_ADV); + break; + + default: + break; + } +} + +static void ble_start_adv_failed_cb(void) { + if (STARTING_ADV == bleModeEnv.state) { + SET_BLE_STATE(STATE_IDLE); + } + + // start pending op(start adv again) +} + +static void ble_start_scan(void *param) { + switch (bleModeEnv.state) { + case ADVERTISING: + SET_BLE_STATE(STOPPING_ADV); + SET_BLE_OP(START_SCAN); + appm_stop_advertising(); + break; + + case SCANNING: + SET_BLE_STATE(STOPPING_SCAN); + SET_BLE_OP(START_SCAN); + appm_stop_scanning(); + break; + + case CONNECTING: + SET_BLE_STATE(STOPPING_CONNECT); + SET_BLE_OP(START_SCAN); + appm_stop_connecting(); + break; + + case STARTING_ADV: + case STARTING_SCAN: + case STARTING_CONNECT: + case STOPPING_ADV: + case STOPPING_SCAN: + case STOPPING_CONNECT: + SET_BLE_OP(START_SCAN); + break; + + case STATE_IDLE: + + SET_BLE_STATE(STARTING_SCAN); + memcpy(&bleModeEnv.scanInfo, param, sizeof(BLE_SCAN_PARAM_T)); + appm_start_scanning(bleModeEnv.scanInfo.scanInterval, + bleModeEnv.scanInfo.scanWindow, + bleModeEnv.scanInfo.scanType); + break; + + default: + break; + } +} + +static void ble_start_connect(uint8_t *bleBdAddr) { + SET_BLE_OP(START_CONNECT); + + if ((CONNECTING != bleModeEnv.state) && + (STARTING_CONNECT != bleModeEnv.state)) { + switch (bleModeEnv.state) { case ADVERTISING: - SET_BLE_STATE(STOPPING_ADV); - SET_BLE_OP(START_ADV); - appm_stop_advertising(); - break; + SET_BLE_STATE(STOPPING_ADV); + appm_stop_advertising(); + break; case SCANNING: - SET_BLE_STATE(STOPPING_SCAN); - SET_BLE_OP(START_ADV); - appm_stop_scanning(); - break; - - case CONNECTING: - SET_BLE_STATE(STOPPING_CONNECT); - SET_BLE_OP(START_ADV); - appm_stop_connecting(); - break; - - case STARTING_ADV: - case STARTING_SCAN: - case STARTING_CONNECT: - case STOPPING_ADV: - case STOPPING_SCAN: - case STOPPING_CONNECT: - SET_BLE_OP(START_ADV); - break; + SET_BLE_STATE(STOPPING_SCAN); + appm_stop_scanning(); + break; case STATE_IDLE: - if (!ble_adv_is_allowed()) - { - LOG_I("[ADV] not allowed."); - if (START_ADV == bleModeEnv.op) - { - SET_BLE_OP(OP_IDLE); - } - break; - } - - memcpy(&bleModeEnv.advInfo, param, sizeof(bleModeEnv.advInfo)); - appm_start_advertising(&bleModeEnv.advInfo); - - SET_BLE_STATE(STARTING_ADV); - break; + SET_BLE_STATE(STARTING_CONNECT); + struct gap_bdaddr bdAddr; + memcpy(bdAddr.addr.addr, bleBdAddr, BTIF_BD_ADDR_SIZE); + bdAddr.addr_type = 0; + LOG_I("Master paired with mobile dev is scanned, connect it via BLE."); + appm_start_connecting(&bdAddr); + break; default: - break; + break; } + } } -static void ble_start_adv_failed_cb(void) -{ - if (STARTING_ADV == bleModeEnv.state) - { - SET_BLE_STATE(STATE_IDLE); - } - - // start pending op(start adv again) -} - -static void ble_start_scan(void *param) -{ - switch (bleModeEnv.state) - { - case ADVERTISING: - SET_BLE_STATE(STOPPING_ADV); - SET_BLE_OP(START_SCAN); - appm_stop_advertising(); - break; - - case SCANNING: - SET_BLE_STATE(STOPPING_SCAN); - SET_BLE_OP(START_SCAN); - appm_stop_scanning(); - break; - - case CONNECTING: - SET_BLE_STATE(STOPPING_CONNECT); - SET_BLE_OP(START_SCAN); - appm_stop_connecting(); - break; - - case STARTING_ADV: - case STARTING_SCAN: - case STARTING_CONNECT: - case STOPPING_ADV: - case STOPPING_SCAN: - case STOPPING_CONNECT: - SET_BLE_OP(START_SCAN); - break; - - case STATE_IDLE: - - SET_BLE_STATE(STARTING_SCAN); - memcpy(&bleModeEnv.scanInfo, param, sizeof(BLE_SCAN_PARAM_T)); - appm_start_scanning(bleModeEnv.scanInfo.scanInterval, - bleModeEnv.scanInfo.scanWindow, - bleModeEnv.scanInfo.scanType); - break; - - default: - break; - } -} - -static void ble_start_connect(uint8_t *bleBdAddr) -{ - SET_BLE_OP(START_CONNECT); - - if ((CONNECTING != bleModeEnv.state) && - (STARTING_CONNECT != bleModeEnv.state)) - { - switch (bleModeEnv.state) - { - case ADVERTISING: - SET_BLE_STATE(STOPPING_ADV); - appm_stop_advertising(); - break; - - case SCANNING: - SET_BLE_STATE(STOPPING_SCAN); - appm_stop_scanning(); - break; - - case STATE_IDLE: - SET_BLE_STATE(STARTING_CONNECT); - struct gap_bdaddr bdAddr; - memcpy(bdAddr.addr.addr, bleBdAddr, BTIF_BD_ADDR_SIZE); - bdAddr.addr_type = 0; - LOG_I("Master paired with mobile dev is scanned, connect it via BLE."); - appm_start_connecting(&bdAddr); - break; - - default: - break; - } - } -} - -static void ble_stop_all_activities(void) -{ - switch (bleModeEnv.state) - { - case ADVERTISING: - SET_BLE_OP(OP_IDLE); - SET_BLE_STATE(STOPPING_ADV); - appm_stop_advertising(); - break; - - case SCANNING: - SET_BLE_OP(OP_IDLE); - SET_BLE_STATE(STOPPING_SCAN); - appm_stop_scanning(); - break; - - case CONNECTING: - SET_BLE_OP(OP_IDLE); - SET_BLE_STATE(STOPPING_CONNECT); - appm_stop_connecting(); - break; - - case STARTING_ADV: - SET_BLE_OP(STOP_ADV); - break; - - case STARTING_SCAN: - SET_BLE_OP(STOP_SCAN); - break; - - case STARTING_CONNECT: - SET_BLE_OP(STOP_CONNECT); - break; - - case STOPPING_ADV: - case STOPPING_SCAN: - case STOPPING_CONNECT: - SET_BLE_OP(OP_IDLE); - break; - - default: - break; - } -} - -static void ble_execute_pending_op(void) -{ - LOG_I("%s", __func__); - uint8_t op = bleModeEnv.op; +static void ble_stop_all_activities(void) { + switch (bleModeEnv.state) { + case ADVERTISING: SET_BLE_OP(OP_IDLE); + SET_BLE_STATE(STOPPING_ADV); + appm_stop_advertising(); + break; - switch (op) - { - case START_ADV: - ble_start_adv(&advParam); - break; + case SCANNING: + SET_BLE_OP(OP_IDLE); + SET_BLE_STATE(STOPPING_SCAN); + appm_stop_scanning(); + break; - case START_SCAN: - ble_start_scan(&scanParam); - break; + case CONNECTING: + SET_BLE_OP(OP_IDLE); + SET_BLE_STATE(STOPPING_CONNECT); + appm_stop_connecting(); + break; - case START_CONNECT: - ble_start_connect(bleModeEnv.bleAddrToConnect); - break; + case STARTING_ADV: + SET_BLE_OP(STOP_ADV); + break; - case STOP_ADV: - case STOP_SCAN: - case STOP_CONNECT: - ble_stop_all_activities(); - break; + case STARTING_SCAN: + SET_BLE_OP(STOP_SCAN); + break; - default: - break; - } + case STARTING_CONNECT: + SET_BLE_OP(STOP_CONNECT); + break; + + case STOPPING_ADV: + case STOPPING_SCAN: + case STOPPING_CONNECT: + SET_BLE_OP(OP_IDLE); + break; + + default: + break; + } } -static void ble_switch_activities(void) -{ - switch (bleModeEnv.state) - { - case STARTING_ADV: - SET_BLE_STATE(ADVERTISING); - break; +static void ble_execute_pending_op(void) { + LOG_I("%s", __func__); + uint8_t op = bleModeEnv.op; + SET_BLE_OP(OP_IDLE); - case STARTING_SCAN: - SET_BLE_STATE(SCANNING); - break; + switch (op) { + case START_ADV: + ble_start_adv(&advParam); + break; - case STARTING_CONNECT: - SET_BLE_STATE(CONNECTING); - break; + case START_SCAN: + ble_start_scan(&scanParam); + break; - case STOPPING_ADV: - SET_BLE_STATE(STATE_IDLE); - break; + case START_CONNECT: + ble_start_connect(bleModeEnv.bleAddrToConnect); + break; - case STOPPING_SCAN: - SET_BLE_STATE(STATE_IDLE); - break; + case STOP_ADV: + case STOP_SCAN: + case STOP_CONNECT: + ble_stop_all_activities(); + break; - case STOPPING_CONNECT: - SET_BLE_STATE(STATE_IDLE); - break; + default: + break; + } +} - default: - break; - } +static void ble_switch_activities(void) { + switch (bleModeEnv.state) { + case STARTING_ADV: + SET_BLE_STATE(ADVERTISING); + break; - ble_execute_pending_op(); + case STARTING_SCAN: + SET_BLE_STATE(SCANNING); + break; + + case STARTING_CONNECT: + SET_BLE_STATE(CONNECTING); + break; + + case STOPPING_ADV: + SET_BLE_STATE(STATE_IDLE); + break; + + case STOPPING_SCAN: + SET_BLE_STATE(STATE_IDLE); + break; + + case STOPPING_CONNECT: + SET_BLE_STATE(STATE_IDLE); + break; + + default: + break; + } + + ble_execute_pending_op(); } // BLE advertisement event callbacks -void app_advertising_started(void) -{ - app_bt_start_custom_function_in_bt_thread(0, - 0, - (uint32_t)ble_switch_activities); +void app_advertising_started(void) { + app_bt_start_custom_function_in_bt_thread(0, 0, + (uint32_t)ble_switch_activities); } -void app_advertising_starting_failed(void) -{ - memset(&bleModeEnv.advInfo, 0, sizeof(bleModeEnv.advInfo)); - app_bt_start_custom_function_in_bt_thread(0, - 0, - (uint32_t)ble_start_adv_failed_cb); +void app_advertising_starting_failed(void) { + memset(&bleModeEnv.advInfo, 0, sizeof(bleModeEnv.advInfo)); + app_bt_start_custom_function_in_bt_thread(0, 0, + (uint32_t)ble_start_adv_failed_cb); } -void app_advertising_stopped(void) -{ - memset(&bleModeEnv.advInfo, 0, sizeof(bleModeEnv.advInfo)); - app_bt_start_custom_function_in_bt_thread(0, - 0, - ( uint32_t )ble_switch_activities); +void app_advertising_stopped(void) { + memset(&bleModeEnv.advInfo, 0, sizeof(bleModeEnv.advInfo)); + app_bt_start_custom_function_in_bt_thread(0, 0, + (uint32_t)ble_switch_activities); } // BLE adv data updated event callback -void app_adv_data_updated(void) -{ - app_bt_start_custom_function_in_bt_thread(0, - 0, - (uint32_t)ble_switch_activities); +void app_adv_data_updated(void) { + app_bt_start_custom_function_in_bt_thread(0, 0, + (uint32_t)ble_switch_activities); } // BLE scan event callbacks -void app_scanning_started(void) -{ - app_bt_start_custom_function_in_bt_thread(0, - 0, - (uint32_t)ble_switch_activities); +void app_scanning_started(void) { + app_bt_start_custom_function_in_bt_thread(0, 0, + (uint32_t)ble_switch_activities); } -void app_scanning_stopped(void) -{ - app_bt_start_custom_function_in_bt_thread(0, - 0, - (uint32_t)ble_switch_activities); +void app_scanning_stopped(void) { + app_bt_start_custom_function_in_bt_thread(0, 0, + (uint32_t)ble_switch_activities); } // BLE connect event callbacks -void app_connecting_started(void) -{ - app_bt_start_custom_function_in_bt_thread(0, - 0, - (uint32_t)ble_switch_activities); +void app_connecting_started(void) { + app_bt_start_custom_function_in_bt_thread(0, 0, + (uint32_t)ble_switch_activities); } -void app_connecting_stopped(void) -{ - app_bt_start_custom_function_in_bt_thread(0, - 0, - (uint32_t)ble_switch_activities); +void app_connecting_stopped(void) { + app_bt_start_custom_function_in_bt_thread(0, 0, + (uint32_t)ble_switch_activities); } /** * @brief : callback function of BLE connect failed * */ -static void app_ble_connecting_failed_handler(void) -{ - if ((CONNECTING == bleModeEnv.state) || - (STOPPING_CONNECT == bleModeEnv.state) || - (STARTING_CONNECT == bleModeEnv.state) ) - { - SET_BLE_STATE(STATE_IDLE); - } +static void app_ble_connecting_failed_handler(void) { + if ((CONNECTING == bleModeEnv.state) || + (STOPPING_CONNECT == bleModeEnv.state) || + (STARTING_CONNECT == bleModeEnv.state)) { + SET_BLE_STATE(STATE_IDLE); + } } -void app_connecting_failed(void) -{ - app_bt_start_custom_function_in_bt_thread(0, - 0, - (uint32_t)app_ble_connecting_failed_handler); +void app_connecting_failed(void) { + app_bt_start_custom_function_in_bt_thread( + 0, 0, (uint32_t)app_ble_connecting_failed_handler); } -void app_ble_connected_evt_handler(uint8_t conidx, const uint8_t *pPeerBdAddress) -{ - ble_evnet_t event; +void app_ble_connected_evt_handler(uint8_t conidx, + const uint8_t *pPeerBdAddress) { + ble_evnet_t event; - if ((ADVERTISING == bleModeEnv.state) || - (STARTING_ADV == bleModeEnv.state) || - (CONNECTING == bleModeEnv.state)) - { - SET_BLE_STATE(STATE_IDLE); - } + if ((ADVERTISING == bleModeEnv.state) || (STARTING_ADV == bleModeEnv.state) || + (CONNECTING == bleModeEnv.state)) { + SET_BLE_STATE(STATE_IDLE); + } - if (START_CONNECT == bleModeEnv.op) - { - SET_BLE_OP(OP_IDLE); - } + if (START_CONNECT == bleModeEnv.op) { + SET_BLE_OP(OP_IDLE); + } - event.evt_type = BLE_CONNECT_EVENT; - event.p.connect_handled.conidx = conidx; - event.p.connect_handled.peer_bdaddr = pPeerBdAddress; - app_ble_core_global_handle(&event, NULL); + event.evt_type = BLE_CONNECT_EVENT; + event.p.connect_handled.conidx = conidx; + event.p.connect_handled.peer_bdaddr = pPeerBdAddress; + app_ble_core_global_handle(&event, NULL); - - app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); - app_stop_fast_connectable_ble_adv_timer(); + app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); + app_stop_fast_connectable_ble_adv_timer(); } -void app_ble_disconnected_evt_handler(uint8_t conidx) -{ - ble_evnet_t event; +void app_ble_disconnected_evt_handler(uint8_t conidx) { + ble_evnet_t event; - event.evt_type = BLE_DISCONNECT_EVENT; - event.p.disconnect_handled.conidx = conidx; - app_ble_core_global_handle(&event, NULL); + event.evt_type = BLE_DISCONNECT_EVENT; + event.p.disconnect_handled.conidx = conidx; + app_ble_core_global_handle(&event, NULL); - app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); + app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); } // BLE APIs for external use -void app_ble_data_fill_enable(enum BLE_ADV_USER_E user, bool enable) -{ - LOG_I("%s user %d%s enable %d", __func__, user, ble_adv_user2str(user), enable); +void app_ble_data_fill_enable(enum BLE_ADV_USER_E user, bool enable) { + LOG_I("%s user %d%s enable %d", __func__, user, ble_adv_user2str(user), + enable); - ASSERT(user < BLE_ADV_USER_NUM, "%s user %d", __func__, user); - if (enable) - { - bleModeEnv.adv_user_enable |= (1 << user); - } - else - { - bleModeEnv.adv_user_enable &= ~(1 << user); - } + ASSERT(user < BLE_ADV_USER_NUM, "%s user %d", __func__, user); + if (enable) { + bleModeEnv.adv_user_enable |= (1 << user); + } else { + bleModeEnv.adv_user_enable &= ~(1 << user); + } } -bool app_ble_get_data_fill_enable(enum BLE_ADV_USER_E user) -{ - bool enable = bleModeEnv.adv_user_enable & (1 << user); - LOG_I("%s user %d enable %d", __func__, user, enable); - return enable; +bool app_ble_get_data_fill_enable(enum BLE_ADV_USER_E user) { + bool enable = bleModeEnv.adv_user_enable & (1 << user); + LOG_I("%s user %d enable %d", __func__, user, enable); + return enable; } - /** * @brief : callback function of BLE scan starting failed * */ -static void app_ble_scanning_starting_failed_handler(void) -{ - if (STARTING_SCAN == bleModeEnv.state) - { - SET_BLE_STATE(STATE_IDLE); - } +static void app_ble_scanning_starting_failed_handler(void) { + if (STARTING_SCAN == bleModeEnv.state) { + SET_BLE_STATE(STATE_IDLE); + } } -void app_scanning_starting_failed(void) -{ - app_bt_start_custom_function_in_bt_thread(0, - 0, - (uint32_t)app_ble_scanning_starting_failed_handler); +void app_scanning_starting_failed(void) { + app_bt_start_custom_function_in_bt_thread( + 0, 0, (uint32_t)app_ble_scanning_starting_failed_handler); } // BLE APIs for external use -void app_ble_register_data_fill_handle(enum BLE_ADV_USER_E user, BLE_DATA_FILL_FUNC_T func, bool enable) -{ - bool needUpdateAdv = false; +void app_ble_register_data_fill_handle(enum BLE_ADV_USER_E user, + BLE_DATA_FILL_FUNC_T func, bool enable) { + bool needUpdateAdv = false; - if (BLE_ADV_USER_NUM <= user) - { - LOG_W("invalid user"); - } - else - { - if (func != bleModeEnv.bleDataFillFunc[user] && - NULL != func) - { - needUpdateAdv = true; - bleModeEnv.bleDataFillFunc[user] = func; - } + if (BLE_ADV_USER_NUM <= user) { + LOG_W("invalid user"); + } else { + if (func != bleModeEnv.bleDataFillFunc[user] && NULL != func) { + needUpdateAdv = true; + bleModeEnv.bleDataFillFunc[user] = func; } + } - bleModeEnv.adv_user_register |= (1 << user); - if (needUpdateAdv) - { - app_ble_data_fill_enable(user, enable); - } + bleModeEnv.adv_user_register |= (1 << user); + if (needUpdateAdv) { + app_ble_data_fill_enable(user, enable); + } } -void app_ble_system_ready(void) -{ - uint32_t generatedSeed = hal_sys_timer_get(); +void app_ble_system_ready(void) { + uint32_t generatedSeed = hal_sys_timer_get(); - for (uint8_t index = 0; index < sizeof(bt_addr); index++) - { - generatedSeed ^= (((uint32_t)(bt_addr[index])) << (hal_sys_timer_get() & 0xF)); - } + for (uint8_t index = 0; index < sizeof(bt_addr); index++) { + generatedSeed ^= + (((uint32_t)(bt_addr[index])) << (hal_sys_timer_get() & 0xF)); + } - bt_drv_reg_op_set_rand_seed(generatedSeed); + bt_drv_reg_op_set_rand_seed(generatedSeed); #if defined(ENHANCED_STACK) - app_notify_stack_ready(STACK_READY_BLE); + app_notify_stack_ready(STACK_READY_BLE); #else - app_notify_stack_ready(STACK_READY_BLE | STACK_READY_BT); + app_notify_stack_ready(STACK_READY_BLE | STACK_READY_BT); #endif } -static void ble_adv_refreshing(void *param) -{ - BLE_ADV_PARAM_T *pAdvParam = (BLE_ADV_PARAM_T *)param; - // four conditions that we just need to update the ble adv data instead of restarting ble adv - // 1. BLE advertising is on - // 2. No on-going BLE operation - // 3. BLE adv type is the same - // 4. BLE adv interval is the same - if ((ADVERTISING == bleModeEnv.state) && \ - (OP_IDLE == bleModeEnv.op) && \ - bleModeEnv.advInfo.advType == pAdvParam->advType && \ - bleModeEnv.advInfo.advInterval == pAdvParam->advInterval) - { - memcpy(&bleModeEnv.advInfo, param, sizeof(bleModeEnv.advInfo)); - SET_BLE_STATE(STARTING_ADV); - appm_update_adv_data(pAdvParam->advData, - pAdvParam->advDataLen, - pAdvParam->scanRspData, - pAdvParam->scanRspDataLen); - } - else - { - // otherwise, restart ble adv - ble_start_adv(param); - } +static void ble_adv_refreshing(void *param) { + BLE_ADV_PARAM_T *pAdvParam = (BLE_ADV_PARAM_T *)param; + // four conditions that we just need to update the ble adv data instead of + // restarting ble adv + // 1. BLE advertising is on + // 2. No on-going BLE operation + // 3. BLE adv type is the same + // 4. BLE adv interval is the same + if ((ADVERTISING == bleModeEnv.state) && (OP_IDLE == bleModeEnv.op) && + bleModeEnv.advInfo.advType == pAdvParam->advType && + bleModeEnv.advInfo.advInterval == pAdvParam->advInterval) { + memcpy(&bleModeEnv.advInfo, param, sizeof(bleModeEnv.advInfo)); + SET_BLE_STATE(STARTING_ADV); + appm_update_adv_data(pAdvParam->advData, pAdvParam->advDataLen, + pAdvParam->scanRspData, pAdvParam->scanRspDataLen); + } else { + // otherwise, restart ble adv + ble_start_adv(param); + } } -static bool app_ble_start_adv(uint8_t advType, uint16_t advInterval) -{ - uint32_t adv_user_enable = bleModeEnv.adv_user_enable; - LOG_I("[ADV]type:%d, interval:%d ca:%p", advType, advInterval, __builtin_return_address(0)); +static bool app_ble_start_adv(uint8_t advType, uint16_t advInterval) { + uint32_t adv_user_enable = bleModeEnv.adv_user_enable; + LOG_I("[ADV]type:%d, interval:%d ca:%p", advType, advInterval, + __builtin_return_address(0)); - if (!ble_adv_is_allowed()) - { - LOG_I("[ADV] not allowed."); - return false; - } + if (!ble_adv_is_allowed()) { + LOG_I("[ADV] not allowed."); + return false; + } - ble_adv_config_param(advType, advInterval); + ble_adv_config_param(advType, advInterval); - LOG_I("%s old_user_enable 0x%x new 0x%x", __func__, adv_user_enable, bleModeEnv.adv_user_enable); - if (!bleModeEnv.adv_user_enable) - { - LOG_I("no adv user enable"); - LOG_I("[ADV] not allowed."); - app_ble_stop_activities(); - return false; - } + LOG_I("%s old_user_enable 0x%x new 0x%x", __func__, adv_user_enable, + bleModeEnv.adv_user_enable); + if (!bleModeEnv.adv_user_enable) { + LOG_I("no adv user enable"); + LOG_I("[ADV] not allowed."); + app_ble_stop_activities(); + return false; + } - // param of adv request is exactly same as current adv - if (ADVERTISING == bleModeEnv.state && - !memcmp(&bleModeEnv.advInfo, &advParam, sizeof(advParam))) - { - LOG_I("reason: adv param not changed"); - LOG_I("[ADV] not allowed."); - return false; - } + // param of adv request is exactly same as current adv + if (ADVERTISING == bleModeEnv.state && + !memcmp(&bleModeEnv.advInfo, &advParam, sizeof(advParam))) { + LOG_I("reason: adv param not changed"); + LOG_I("[ADV] not allowed."); + return false; + } - LOG_I("[ADV_LEN] %d [DATA]:", advParam.advDataLen); - DUMP8("%02x ", advParam.advData, advParam.advDataLen); - LOG_I("[SCAN_RSP_LEN] %d [DATA]:", advParam.scanRspDataLen); - DUMP8("%02x ", advParam.scanRspData, advParam.scanRspDataLen); + LOG_I("[ADV_LEN] %d [DATA]:", advParam.advDataLen); + DUMP8("%02x ", advParam.advData, advParam.advDataLen); + LOG_I("[SCAN_RSP_LEN] %d [DATA]:", advParam.scanRspDataLen); + DUMP8("%02x ", advParam.scanRspData, advParam.scanRspDataLen); - ble_adv_refreshing(&advParam); + ble_adv_refreshing(&advParam); - return true; + return true; } -void app_ble_start_connectable_adv(uint16_t advInterval) -{ - LOG_D("%s", __func__); +void app_ble_start_connectable_adv(uint16_t advInterval) { + LOG_D("%s", __func__); + app_bt_start_custom_function_in_bt_thread((uint32_t)GAPM_ADV_UNDIRECT, + (uint32_t)advInterval, + (uint32_t)app_ble_start_adv); +} + +void app_ble_refresh_adv_state(uint16_t advInterval) { + LOG_D("%s", __func__); + app_bt_start_custom_function_in_bt_thread((uint32_t)GAPM_ADV_UNDIRECT, + (uint32_t)advInterval, + (uint32_t)app_ble_start_adv); +} + +void app_ble_start_scan(enum BLE_SCAN_FILTER_POLICY scanFilterPolicy, + uint16_t scanWindow, uint16_t scanInterval) { + scanParam.scanWindow = scanWindow; + scanParam.scanInterval = scanInterval; + scanParam.scanType = scanFilterPolicy; // BLE_SCAN_ALLOW_ADV_WLST + + app_bt_start_custom_function_in_bt_thread((uint32_t)(&scanParam), 0, + (uint32_t)ble_start_scan); +} + +void app_ble_start_connect(uint8_t *bdAddrToConnect) { + memcpy(bleModeEnv.bleAddrToConnect, bdAddrToConnect, BTIF_BD_ADDR_SIZE); + app_bt_start_custom_function_in_bt_thread( + (uint32_t)bleModeEnv.bleAddrToConnect, 0, (uint32_t)ble_start_connect); +} + +bool app_ble_is_connection_on(uint8_t index) { + return (BLE_CONNECTED == bleModeEnv.bleEnv->context[index].connectStatus); +} + +bool app_ble_is_any_connection_exist(void) { + bool ret = false; + for (uint8_t i = 0; i < BLE_CONNECTION_MAX; i++) { + if (app_ble_is_connection_on(i)) { + ret = true; + } + } + + return ret; +} + +void app_ble_start_disconnect(uint8_t conIdx) { + if (BLE_CONNECTED == bleModeEnv.bleEnv->context[conIdx].connectStatus) { + LOG_I("will disconnect connection:%d", conIdx); + bleModeEnv.bleEnv->context[conIdx].connectStatus = BLE_DISCONNECTING; + app_bt_start_custom_function_in_bt_thread((uint32_t)conIdx, 0, + (uint32_t)appm_disconnect); + } else { + LOG_I("will not execute disconnect since state is:%d", + bleModeEnv.bleEnv->context[conIdx].connectStatus); + } +} + +void app_ble_disconnect_all(void) { + for (uint8_t i = 0; i < BLE_CONNECTION_MAX; i++) { + app_ble_start_disconnect(i); + } +} + +void app_ble_stop_activities(void) { + LOG_I("%s %p", __func__, __builtin_return_address(0)); + + app_stop_fast_connectable_ble_adv_timer(); + if (bleModeEnv.state != OP_IDLE) { app_bt_start_custom_function_in_bt_thread( - (uint32_t)GAPM_ADV_UNDIRECT, (uint32_t)advInterval, - (uint32_t)app_ble_start_adv); + 0, 0, (uint32_t)ble_stop_all_activities); + } } -void app_ble_refresh_adv_state(uint16_t advInterval) -{ - LOG_D("%s", __func__); - app_bt_start_custom_function_in_bt_thread( - (uint32_t)GAPM_ADV_UNDIRECT, (uint32_t)advInterval, - (uint32_t)app_ble_start_adv); +void app_ble_force_switch_adv(uint8_t user, bool onOff) { + ASSERT(user < BLE_SWITCH_USER_NUM, "ble switch user exceed"); + + if (onOff) { + bleModeEnv.advSwitch &= ~(1 << user); + app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); + } else if ((bleModeEnv.advSwitch & (1 << user)) == 0) { + bleModeEnv.advSwitch |= (1 << user); + app_ble_stop_activities(); + + // disconnect all of the BLE connections if box is closed + if (BLE_SWITCH_USER_BOX == user) { + app_ble_disconnect_all(); + } + } + + LOG_I("%s user %d onoff %d switch 0x%x", __func__, user, onOff, + bleModeEnv.advSwitch); } -void app_ble_start_scan(enum BLE_SCAN_FILTER_POLICY scanFilterPolicy, uint16_t scanWindow, uint16_t scanInterval) -{ - scanParam.scanWindow = scanWindow; - scanParam.scanInterval = scanInterval; - scanParam.scanType = scanFilterPolicy; //BLE_SCAN_ALLOW_ADV_WLST - - app_bt_start_custom_function_in_bt_thread((uint32_t)(&scanParam), - 0, - (uint32_t)ble_start_scan); +bool app_ble_is_in_advertising_state(void) { + return (ADVERTISING == bleModeEnv.state) || + (STARTING_ADV == bleModeEnv.state) || + (STOPPING_ADV == bleModeEnv.state); } -void app_ble_start_connect(uint8_t *bdAddrToConnect) -{ - memcpy(bleModeEnv.bleAddrToConnect, bdAddrToConnect, BTIF_BD_ADDR_SIZE); - app_bt_start_custom_function_in_bt_thread((uint32_t)bleModeEnv.bleAddrToConnect, - 0, - (uint32_t)ble_start_connect); -} - -bool app_ble_is_connection_on(uint8_t index) -{ - return (BLE_CONNECTED == - bleModeEnv.bleEnv->context[index].connectStatus); -} - -bool app_ble_is_any_connection_exist(void) -{ - bool ret = false; - for (uint8_t i = 0; i < BLE_CONNECTION_MAX; i++) - { - if (app_ble_is_connection_on(i)) - { - ret = true; - } +static uint32_t POSSIBLY_UNUSED ble_get_manufacture_data_ptr( + uint8_t *advData, uint32_t dataLength, uint8_t *manufactureData) { + uint8_t followingDataLengthOfSection; + uint8_t rawContentDataLengthOfSection; + uint8_t flag; + while (dataLength > 0) { + followingDataLengthOfSection = *advData++; + dataLength--; + if (dataLength < followingDataLengthOfSection) { + return 0; // wrong adv data format } - return ret; -} + if (followingDataLengthOfSection > 0) { + flag = *advData++; + dataLength--; -void app_ble_start_disconnect(uint8_t conIdx) -{ - if (BLE_CONNECTED == bleModeEnv.bleEnv->context[conIdx].connectStatus) - { - LOG_I("will disconnect connection:%d", conIdx); - bleModeEnv.bleEnv->context[conIdx].connectStatus = BLE_DISCONNECTING; - app_bt_start_custom_function_in_bt_thread((uint32_t)conIdx, - 0, - (uint32_t)appm_disconnect); - } - else - { - LOG_I("will not execute disconnect since state is:%d", - bleModeEnv.bleEnv->context[conIdx].connectStatus); - } -} - -void app_ble_disconnect_all(void) -{ - for (uint8_t i = 0; i < BLE_CONNECTION_MAX; i++) - { - app_ble_start_disconnect(i); - } -} - -void app_ble_stop_activities(void) -{ - LOG_I("%s %p", __func__, __builtin_return_address(0)); - - app_stop_fast_connectable_ble_adv_timer(); - if (bleModeEnv.state != OP_IDLE) - { - app_bt_start_custom_function_in_bt_thread(0, - 0, - (uint32_t)ble_stop_all_activities); - } -} - -void app_ble_force_switch_adv(uint8_t user, bool onOff) -{ - ASSERT(user < BLE_SWITCH_USER_NUM, "ble switch user exceed"); - - if (onOff) - { - bleModeEnv.advSwitch &= ~(1 << user); - app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); - } - else if ((bleModeEnv.advSwitch & (1 << user)) == 0) - { - bleModeEnv.advSwitch |= (1 << user); - app_ble_stop_activities(); - - // disconnect all of the BLE connections if box is closed - if (BLE_SWITCH_USER_BOX == user) - { - app_ble_disconnect_all(); - } - } - - LOG_I("%s user %d onoff %d switch 0x%x", __func__, user, onOff, bleModeEnv.advSwitch); -} - -bool app_ble_is_in_advertising_state(void) -{ - return (ADVERTISING == bleModeEnv.state) || - (STARTING_ADV == bleModeEnv.state) || - (STOPPING_ADV == bleModeEnv.state); -} - -static uint32_t POSSIBLY_UNUSED ble_get_manufacture_data_ptr(uint8_t *advData, - uint32_t dataLength, - uint8_t *manufactureData) -{ - uint8_t followingDataLengthOfSection; - uint8_t rawContentDataLengthOfSection; - uint8_t flag; - while (dataLength > 0) - { - followingDataLengthOfSection = *advData++; - dataLength--; - if (dataLength < followingDataLengthOfSection) - { - return 0; // wrong adv data format + rawContentDataLengthOfSection = followingDataLengthOfSection - 1; + if (BLE_ADV_MANU_FLAG == flag) { + uint32_t lengthToCopy; + if (dataLength < rawContentDataLengthOfSection) { + lengthToCopy = dataLength; + } else { + lengthToCopy = rawContentDataLengthOfSection; } - if (followingDataLengthOfSection > 0) - { - flag = *advData++; - dataLength--; - - rawContentDataLengthOfSection = followingDataLengthOfSection - 1; - if (BLE_ADV_MANU_FLAG == flag) - { - uint32_t lengthToCopy; - if (dataLength < rawContentDataLengthOfSection) - { - lengthToCopy = dataLength; - } - else - { - lengthToCopy = rawContentDataLengthOfSection; - } - - memcpy(manufactureData, advData - 2, lengthToCopy + 2); - return lengthToCopy + 2; - } - else - { - advData += rawContentDataLengthOfSection; - dataLength -= rawContentDataLengthOfSection; - } - } + memcpy(manufactureData, advData - 2, lengthToCopy + 2); + return lengthToCopy + 2; + } else { + advData += rawContentDataLengthOfSection; + dataLength -= rawContentDataLengthOfSection; + } } + } - return 0; + return 0; } -//received adv data -void app_adv_reported_scanned(struct gapm_adv_report_ind *ptInd) -{ - /* - LOG_I("Scanned RSSI %d BD addr:", (int8_t)ptInd->report.rssi); - DUMP8("0x%02x ", ptInd->report.adv_addr.addr, BTIF_BD_ADDR_SIZE); - LOG_I("Scanned adv data:"); - DUMP8("0x%02x ", ptInd->report.data, ptInd->report.data_len); - */ +// received adv data +void app_adv_reported_scanned(struct gapm_adv_report_ind *ptInd) { + /* + LOG_I("Scanned RSSI %d BD addr:", (int8_t)ptInd->report.rssi); + DUMP8("0x%02x ", ptInd->report.adv_addr.addr, BTIF_BD_ADDR_SIZE); + LOG_I("Scanned adv data:"); + DUMP8("0x%02x ", ptInd->report.data, ptInd->report.data_len); + */ - ble_adv_data_parse(ptInd->report.adv_addr.addr, - (int8_t)ptInd->report.rssi, - ptInd->report.data, - (unsigned char)ptInd->report.data_len); + ble_adv_data_parse(ptInd->report.adv_addr.addr, (int8_t)ptInd->report.rssi, + ptInd->report.data, (unsigned char)ptInd->report.data_len); } -void app_ibrt_ui_disconnect_ble(void) -{ - app_ble_disconnect_all(); +void app_ibrt_ui_disconnect_ble(void) { app_ble_disconnect_all(); } + +uint32_t app_ble_get_user_register(void) { + return bleModeEnv.adv_user_register; } -uint32_t app_ble_get_user_register(void) -{ - return bleModeEnv.adv_user_register; -} +enum BLE_STATE_E app_ble_get_current_state(void) { return bleModeEnv.state; } -enum BLE_STATE_E app_ble_get_current_state(void) -{ - return bleModeEnv.state; -} +enum BLE_OP_E app_ble_get_current_operation(void) { return bleModeEnv.op; } -enum BLE_OP_E app_ble_get_current_operation(void) -{ - return bleModeEnv.op; +void app_ble_get_runtime_adv_param(uint8_t *pAdvType, + uint16_t *pAdvIntervalMs) { + *pAdvType = advParam.advType; + *pAdvIntervalMs = advParam.advInterval; } - -void app_ble_get_runtime_adv_param(uint8_t* pAdvType, uint16_t* pAdvIntervalMs) -{ - *pAdvType = advParam.advType; - *pAdvIntervalMs = advParam.advInterval; -} - diff --git a/services/ble_app/app_main/app_ble_rx_handler.c b/services/ble_app/app_main/app_ble_rx_handler.c index 4513e8d..655976b 100644 --- a/services/ble_app/app_main/app_ble_rx_handler.c +++ b/services/ble_app/app_main/app_ble_rx_handler.c @@ -1,42 +1,43 @@ -#include "cmsis_os.h" -#include "cmsis.h" -#include "ble_app_dbg.h" #include "app_ble_rx_handler.h" -#include "cqueue.h" #include "app_bt_func.h" +#include "ble_app_dbg.h" +#include "cmsis.h" +#include "cmsis_os.h" +#include "cqueue.h" #ifdef BISTO_ENABLED -#include "gsound_service.h" #include "gsound_custom_ble.h" +#include "gsound_service.h" #endif -#define BLE_RX_EVENT_MAX_MAILBOX 16 -#define BLE_RX_BUF_SIZE (2048) +#define BLE_RX_EVENT_MAX_MAILBOX 16 +#define BLE_RX_BUF_SIZE (2048) static uint8_t app_ble_rx_buf[BLE_RX_BUF_SIZE]; static CQueue app_ble_rx_cqueue; #define VOICEPATH_COMMON_OTA_BUFF_SIZE 4096 -uint8_t* app_voicepath_get_common_ota_databuf(void) -{ - static uint8_t voicepath_common_ota_buf[VOICEPATH_COMMON_OTA_BUFF_SIZE]; - return voicepath_common_ota_buf; +uint8_t *app_voicepath_get_common_ota_databuf(void) { + static uint8_t voicepath_common_ota_buf[VOICEPATH_COMMON_OTA_BUFF_SIZE]; + return voicepath_common_ota_buf; } #ifdef BES_OTA_BASIC -extern void ota_bes_handle_received_data(uint8_t *otaBuf, bool isViaBle,uint16_t dataLenth); +extern void ota_bes_handle_received_data(uint8_t *otaBuf, bool isViaBle, + uint16_t dataLenth); #if defined(IBRT) #ifdef IBRT_OTA -extern void ota_ibrt_handle_received_data(uint8_t *otaBuf, bool isViaBle, uint16_t len); +extern void ota_ibrt_handle_received_data(uint8_t *otaBuf, bool isViaBle, + uint16_t len); #endif #endif #endif #if (BLE_APP_TOTA) -extern void app_tota_handle_received_data(uint8_t* buffer, uint16_t maxBytes); +extern void app_tota_handle_received_data(uint8_t *buffer, uint16_t maxBytes); #endif static osThreadId app_ble_rx_thread = NULL; @@ -49,126 +50,112 @@ extern void app_ota_send_rx_cfm(uint8_t conidx); static void app_ble_rx_handler_thread(const void *arg); osThreadDef(app_ble_rx_handler_thread, osPriorityNormal, 1, 2048, "ble_rx"); -osMailQDef (ble_rx_event_mailbox, BLE_RX_EVENT_MAX_MAILBOX, BLE_RX_EVENT_T); +osMailQDef(ble_rx_event_mailbox, BLE_RX_EVENT_MAX_MAILBOX, BLE_RX_EVENT_T); static osMailQId app_ble_rx_event_mailbox = NULL; -static int32_t app_ble_rx_event_mailbox_init(void) -{ - app_ble_rx_event_mailbox = osMailCreate(osMailQ(ble_rx_event_mailbox), NULL); - if (app_ble_rx_event_mailbox == NULL) { - LOG_I("Failed to Create app_ble_rx_event_mailbox"); - return -1; - } - return 0; -} - -static void update_init_state(bool state) -{ - ble_rx_thread_init_done = state; -} - -static bool get_init_state(void) -{ - return ble_rx_thread_init_done; -} - -static void app_ble_rx_mailbox_free(BLE_RX_EVENT_T* rx_event) -{ - osStatus status; - - status = osMailFree(app_ble_rx_event_mailbox, rx_event); - ASSERT(osOK == status, "Free ble rx event mailbox failed!"); -} - -void app_ble_rx_handler_init(void) -{ - if (!get_init_state()) - { - InitCQueue(&app_ble_rx_cqueue, BLE_RX_BUF_SIZE, ( CQItemType * )app_ble_rx_buf); - app_ble_rx_event_mailbox_init(); - - app_ble_rx_thread = osThreadCreate(osThread(app_ble_rx_handler_thread), NULL); - update_init_state(true); - } - else - { - LOG_I("rx already initialized"); - } -} - -void app_ble_push_rx_data(uint8_t flag, uint8_t conidx, uint8_t* ptr, uint16_t len) -{ - uint32_t lock = int_lock(); - int32_t ret = EnCQueue(&app_ble_rx_cqueue, ptr, len); - int_unlock(lock); - ASSERT(CQ_OK == ret, "BLE rx buffer overflow! %d,%d",AvailableOfCQueue(&app_ble_rx_cqueue),len); - - BLE_RX_EVENT_T* event = (BLE_RX_EVENT_T*)osMailAlloc(app_ble_rx_event_mailbox, 0); - event->flag = flag; - event->conidx = conidx; - event->ptr = ptr; - event->len = len; - - osMailPut(app_ble_rx_event_mailbox, event); -} - -static int32_t app_ble_rx_mailbox_get(BLE_RX_EVENT_T** rx_event) -{ - osEvent evt; - evt = osMailGet(app_ble_rx_event_mailbox, osWaitForever); - if (evt.status == osEventMail) { - *rx_event = (BLE_RX_EVENT_T *)evt.value.p; - LOG_I("flag %d ptr %p len %d", (*rx_event)->flag, - (*rx_event)->ptr, (*rx_event)->len); - return 0; - } +static int32_t app_ble_rx_event_mailbox_init(void) { + app_ble_rx_event_mailbox = osMailCreate(osMailQ(ble_rx_event_mailbox), NULL); + if (app_ble_rx_event_mailbox == NULL) { + LOG_I("Failed to Create app_ble_rx_event_mailbox"); return -1; + } + return 0; +} + +static void update_init_state(bool state) { ble_rx_thread_init_done = state; } + +static bool get_init_state(void) { return ble_rx_thread_init_done; } + +static void app_ble_rx_mailbox_free(BLE_RX_EVENT_T *rx_event) { + osStatus status; + + status = osMailFree(app_ble_rx_event_mailbox, rx_event); + ASSERT(osOK == status, "Free ble rx event mailbox failed!"); +} + +void app_ble_rx_handler_init(void) { + if (!get_init_state()) { + InitCQueue(&app_ble_rx_cqueue, BLE_RX_BUF_SIZE, + (CQItemType *)app_ble_rx_buf); + app_ble_rx_event_mailbox_init(); + + app_ble_rx_thread = + osThreadCreate(osThread(app_ble_rx_handler_thread), NULL); + update_init_state(true); + } else { + LOG_I("rx already initialized"); + } +} + +void app_ble_push_rx_data(uint8_t flag, uint8_t conidx, uint8_t *ptr, + uint16_t len) { + uint32_t lock = int_lock(); + int32_t ret = EnCQueue(&app_ble_rx_cqueue, ptr, len); + int_unlock(lock); + ASSERT(CQ_OK == ret, "BLE rx buffer overflow! %d,%d", + AvailableOfCQueue(&app_ble_rx_cqueue), len); + + BLE_RX_EVENT_T *event = + (BLE_RX_EVENT_T *)osMailAlloc(app_ble_rx_event_mailbox, 0); + event->flag = flag; + event->conidx = conidx; + event->ptr = ptr; + event->len = len; + + osMailPut(app_ble_rx_event_mailbox, event); +} + +static int32_t app_ble_rx_mailbox_get(BLE_RX_EVENT_T **rx_event) { + osEvent evt; + evt = osMailGet(app_ble_rx_event_mailbox, osWaitForever); + if (evt.status == osEventMail) { + *rx_event = (BLE_RX_EVENT_T *)evt.value.p; + LOG_I("flag %d ptr %p len %d", (*rx_event)->flag, (*rx_event)->ptr, + (*rx_event)->len); + return 0; + } + return -1; } extern int app_ibrt_if_tws_sniff_block(uint32_t block_next_sec); -static void app_ble_rx_handler_thread(void const *argument) -{ - while (true) - { - BLE_RX_EVENT_T* rx_event = NULL; - if (!app_ble_rx_mailbox_get(&rx_event)) - { - uint8_t tmpData[512]; - uint32_t lock = int_lock(); - DeCQueue(&app_ble_rx_cqueue, tmpData, rx_event->len); - int_unlock(lock); - switch (rx_event->flag) - { - #ifdef BISTO_ENABLED - case BLE_RX_DATA_GSOUND_CONTROL: - #ifdef IBRT - app_ibrt_if_tws_sniff_block(5); - #endif - LOG_I("gsound processes %d control data.", rx_event->len); - app_gsound_rx_control_data_handler(rx_event->ptr, rx_event->len); - break; - #endif - #if (BLE_APP_OTA) - case BLE_RX_DATA_SELF_OTA: - #if defined(IBRT) - #ifdef IBRT_OTA - ota_ibrt_handle_received_data(tmpData, true, rx_event->len); - app_ota_send_rx_cfm(app_ota_get_conidx()); - #endif - #else - ota_bes_handle_received_data(tmpData, true,rx_event->len); - #endif - break; - #endif - #if (BLE_APP_TOTA) - case BLE_RX_DATA_SELF_TOTA: - app_tota_handle_received_data(tmpData, rx_event->len); - break; - #endif - default: - break; - } - app_ble_rx_mailbox_free(rx_event); - } +static void app_ble_rx_handler_thread(void const *argument) { + while (true) { + BLE_RX_EVENT_T *rx_event = NULL; + if (!app_ble_rx_mailbox_get(&rx_event)) { + uint8_t tmpData[512]; + uint32_t lock = int_lock(); + DeCQueue(&app_ble_rx_cqueue, tmpData, rx_event->len); + int_unlock(lock); + switch (rx_event->flag) { +#ifdef BISTO_ENABLED + case BLE_RX_DATA_GSOUND_CONTROL: +#ifdef IBRT + app_ibrt_if_tws_sniff_block(5); +#endif + LOG_I("gsound processes %d control data.", rx_event->len); + app_gsound_rx_control_data_handler(rx_event->ptr, rx_event->len); + break; +#endif +#if (BLE_APP_OTA) + case BLE_RX_DATA_SELF_OTA: +#if defined(IBRT) +#ifdef IBRT_OTA + ota_ibrt_handle_received_data(tmpData, true, rx_event->len); + app_ota_send_rx_cfm(app_ota_get_conidx()); +#endif +#else + ota_bes_handle_received_data(tmpData, true, rx_event->len); +#endif + break; +#endif +#if (BLE_APP_TOTA) + case BLE_RX_DATA_SELF_TOTA: + app_tota_handle_received_data(tmpData, rx_event->len); + break; +#endif + default: + break; + } + app_ble_rx_mailbox_free(rx_event); } + } } - diff --git a/services/ble_app/app_main/app_task.c b/services/ble_app/app_main/app_task.c index 9863ffb..005ca15 100644 --- a/services/ble_app/app_main/app_task.c +++ b/services/ble_app/app_main/app_task.c @@ -25,43 +25,43 @@ **************************************************************************************** */ -#include "rwip_config.h" // SW configuration +#include "rwip_config.h" // SW configuration #if (BLE_APP_PRESENT) -#include "app_task.h" // Application Manager Task API -#include "app.h" // Application Manager Definition -#include "gapc_task.h" // GAP Controller Task API -#include "gapm_task.h" // GAP Manager Task API -#include "arch.h" // Platform Definitions -#include -#include "ke_timer.h" // Kernel timer -#include "gattc_task.h" +#include "../l2cm/l2cm_int.h" +#include "app.h" // Application Manager Definition #include "app_ble_include.h" -#include "../l2cm/l2cm_int.h" +#include "app_task.h" // Application Manager Task API +#include "arch.h" // Platform Definitions +#include "gapc_task.h" // GAP Controller Task API +#include "gapm_task.h" // GAP Manager Task API +#include "gattc_task.h" +#include "ke_timer.h" // Kernel timer +#include #include "co_utils.h" #if (BLE_APP_SEC) -#include "app_sec.h" // Security Module Definition -#endif //(BLE_APP_SEC) +#include "app_sec.h" // Security Module Definition +#endif //(BLE_APP_SEC) #if (BLE_APP_HT) -#include "app_ht.h" // Health Thermometer Module Definition +#include "app_ht.h" // Health Thermometer Module Definition #include "htpt_task.h" #endif //(BLE_APP_HT) #if (BLE_APP_DIS) -#include "app_dis.h" // Device Information Module Definition +#include "app_dis.h" // Device Information Module Definition #include "diss_task.h" #endif //(BLE_APP_DIS) #if (BLE_APP_BATT) -#include "app_batt.h" // Battery Module Definition +#include "app_batt.h" // Battery Module Definition #include "bass_task.h" #endif //(BLE_APP_BATT) #if (BLE_APP_HID) -#include "app_hid.h" // HID Module Definition +#include "app_hid.h" // HID Module Definition #include "hogpd_task.h" #endif //(BLE_APP_HID) @@ -70,96 +70,92 @@ #endif #if (BLE_APP_VOICEPATH) -#include "app_voicepath_ble.h" // Voice Path Module Definition -#endif // (BLE_APP_VOICEPATH) +#include "app_voicepath_ble.h" // Voice Path Module Definition +#endif // (BLE_APP_VOICEPATH) #if (BLE_APP_DATAPATH_SERVER) -#include "app_datapath_server.h" // Data Path Server Module Definition +#include "app_datapath_server.h" // Data Path Server Module Definition #include "datapathps_task.h" #endif // (BLE_APP_DATAPATH_SERVER) #if (BLE_APP_AI_VOICE) -#include "app_ai_ble.h" // ama Voice Module Definition -#endif // (BLE_APP_AI_VOICE) +#include "app_ai_ble.h" // ama Voice Module Definition +#endif // (BLE_APP_AI_VOICE) #if (BLE_APP_OTA) -#include "app_ota.h" // OTA Module Definition +#include "app_ota.h" // OTA Module Definition #include "ota_task.h" #endif // (BLE_APP_OTA) #if (BLE_APP_TOTA) -#include "app_tota_ble.h" // TOTA Module Definition +#include "app_tota_ble.h" // TOTA Module Definition #include "tota_task.h" #endif // (BLE_APP_TOTA) #if (BLE_APP_ANCC) -#include "app_ancc.h" // ANC Module Definition -#include "app_ancc_task.h" #include "ancc_task.h" +#include "app_ancc.h" // ANC Module Definition +#include "app_ancc_task.h" #endif // (BLE_APP_ANCC) #if (BLE_APP_AMS) -#include "app_amsc.h" // AMS Module Definition -#include "app_amsc_task.h" #include "amsc_task.h" +#include "app_amsc.h" // AMS Module Definition +#include "app_amsc_task.h" #endif // (BLE_APP_AMS) #if (BLE_APP_GFPS) -#include "app_gfps.h" // google fast pair service provider +#include "app_gfps.h" // google fast pair service provider #include "gfps_provider_task.h" #endif // (BLE_APP_GFPS) #ifdef BLE_APP_AM0 -#include "am0_app.h" // Audio Mode 0 Application -#endif //defined(BLE_APP_AM0) +#include "am0_app.h" // Audio Mode 0 Application +#endif // defined(BLE_APP_AM0) #if (DISPLAY_SUPPORT) -#include "app_display.h" // Application Display Definition -#endif //(DISPLAY_SUPPORT) +#include "app_display.h" // Application Display Definition +#endif //(DISPLAY_SUPPORT) -#include "bt_drv_interface.h" -#include "ble_app_dbg.h" -#include "nvrecord_ble.h" #include "app_fp_rfcomm.h" +#include "ble_app_dbg.h" +#include "bt_drv_interface.h" +#include "nvrecord_ble.h" #if (BLE_APP_TILE) -#include "tile_target_ble.h" #include "tile_gatt_server.h" +#include "tile_target_ble.h" #endif /* * LOCAL FUNCTION DEFINITIONS **************************************************************************************** */ -#define APP_CONN_PARAM_INTERVEL_MIN (20) +#define APP_CONN_PARAM_INTERVEL_MIN (20) uint8_t ble_stack_ready = 0; extern bool app_factorymode_get(void); static uint8_t appm_get_handler(const struct ke_state_handler *handler_list, - ke_msg_id_t msgid, - void *param, - ke_task_id_t src_id) -{ - // Counter - uint8_t counter; + ke_msg_id_t msgid, void *param, + ke_task_id_t src_id) { + // Counter + uint8_t counter; - // Get the message handler function by parsing the message table - for (counter = handler_list->msg_cnt; 0 < counter; counter--) - { - struct ke_msg_handler handler = (struct ke_msg_handler)(*(handler_list->msg_table + counter - 1)); + // Get the message handler function by parsing the message table + for (counter = handler_list->msg_cnt; 0 < counter; counter--) { + struct ke_msg_handler handler = + (struct ke_msg_handler)(*(handler_list->msg_table + counter - 1)); - if ((handler.id == msgid) || - (handler.id == KE_MSG_DEFAULT_HANDLER)) - { - // If handler is NULL, message should not have been received in this state - ASSERT_ERR(handler.func); + if ((handler.id == msgid) || (handler.id == KE_MSG_DEFAULT_HANDLER)) { + // If handler is NULL, message should not have been received in this state + ASSERT_ERR(handler.func); - return (uint8_t)(handler.func(msgid, param, TASK_APP, src_id)); - } + return (uint8_t)(handler.func(msgid, param, TASK_APP, src_id)); } + } - // If we are here no handler has been found, drop the message - return (KE_MSG_CONSUMED); + // If we are here no handler has been found, drop the message + return (KE_MSG_CONSUMED); } /* @@ -179,18 +175,16 @@ static uint8_t appm_get_handler(const struct ke_state_handler *handler_list, * @return If the message was consumed or not. **************************************************************************************** */ -static int app_adv_timeout_handler(ke_msg_id_t const msgid, - void const *param, +static int app_adv_timeout_handler(ke_msg_id_t const msgid, void const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - #if (BLE_APP_HID) - #else - // Stop advertising - appm_stop_advertising(); - #endif + ke_task_id_t const src_id) { +#if (BLE_APP_HID) +#else + // Stop advertising + appm_stop_advertising(); +#endif - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -208,39 +202,35 @@ static int app_adv_timeout_handler(ke_msg_id_t const msgid, static int gapm_device_ready_ind_handler(ke_msg_id_t const msgid, void const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if (ble_stack_ready) - { - return KE_MSG_CONSUMED; - } - + ke_task_id_t const src_id) { + if (ble_stack_ready) { + return KE_MSG_CONSUMED; + } + #ifdef __FACTORY_MODE_SUPPORT__ - if (app_factorymode_get()) - { - return (KE_MSG_CONSUMED); - } + if (app_factorymode_get()) { + return (KE_MSG_CONSUMED); + } #endif - BLE_APP_FUNC_ENTER(); + BLE_APP_FUNC_ENTER(); - // Application has not been initialized - ASSERT_ERR(ke_state_get(dest_id) == APPM_INIT); + // Application has not been initialized + ASSERT_ERR(ke_state_get(dest_id) == APPM_INIT); - ble_stack_ready = 1; + ble_stack_ready = 1; - // Reset the stack - struct gapm_reset_cmd* cmd = KE_MSG_ALLOC(GAPM_RESET_CMD, - TASK_GAPM, TASK_APP, - gapm_reset_cmd); + // Reset the stack + struct gapm_reset_cmd *cmd = + KE_MSG_ALLOC(GAPM_RESET_CMD, TASK_GAPM, TASK_APP, gapm_reset_cmd); - cmd->operation = GAPM_RESET; + cmd->operation = GAPM_RESET; - ke_msg_send(cmd); + ke_msg_send(cmd); - BLE_APP_FUNC_LEAVE(); + BLE_APP_FUNC_LEAVE(); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -258,265 +248,218 @@ static int gapm_device_ready_ind_handler(ke_msg_id_t const msgid, static int gapm_cmp_evt_handler(ke_msg_id_t const msgid, struct gapm_cmp_evt const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - BLE_APP_FUNC_ENTER(); - BLE_APP_DBG("param->operation: %d status is %d app_env.next_svc is %d", - param->operation, param->status, app_env.next_svc); + ke_task_id_t const src_id) { + BLE_APP_FUNC_ENTER(); + BLE_APP_DBG("param->operation: %d status is %d app_env.next_svc is %d", + param->operation, param->status, app_env.next_svc); - switch(param->operation) - { - // Reset completed - case (GAPM_RESET): - { - if(param->status == GAP_ERR_NO_ERROR) - { - #if (BLE_APP_HID) - app_hid_start_mouse(); - #endif //(BLE_APP_HID) + switch (param->operation) { + // Reset completed + case (GAPM_RESET): { + if (param->status == GAP_ERR_NO_ERROR) { +#if (BLE_APP_HID) + app_hid_start_mouse(); +#endif //(BLE_APP_HID) - // Set Device configuration - struct gapm_set_dev_config_cmd* cmd = KE_MSG_ALLOC(GAPM_SET_DEV_CONFIG_CMD, - TASK_GAPM, TASK_APP, - gapm_set_dev_config_cmd); - // Set the operation - cmd->operation = GAPM_SET_DEV_CONFIG; - // Set the device role - Peripheral - cmd->role = GAP_ROLE_ALL; - // Set Data length parameters - cmd->sugg_max_tx_octets = APP_MAX_TX_OCTETS; - cmd->sugg_max_tx_time = APP_MAX_TX_TIME; - cmd->pairing_mode = GAPM_PAIRING_LEGACY; - #ifdef CFG_SEC_CON - cmd->pairing_mode |= GAPM_PAIRING_SEC_CON; - #endif - cmd->max_mtu = 512; - cmd->att_cfg = 0; - cmd->att_cfg |= GAPM_MASK_ATT_SVC_CHG_EN; - #if (BLE_APP_HID) - // Enable Slave Preferred Connection Parameters present - cmd->att_cfg |= GAPM_MASK_ATT_SLV_PREF_CON_PAR_EN; - #endif //(BLE_APP_HID) + // Set Device configuration + struct gapm_set_dev_config_cmd *cmd = + KE_MSG_ALLOC(GAPM_SET_DEV_CONFIG_CMD, TASK_GAPM, TASK_APP, + gapm_set_dev_config_cmd); + // Set the operation + cmd->operation = GAPM_SET_DEV_CONFIG; + // Set the device role - Peripheral + cmd->role = GAP_ROLE_ALL; + // Set Data length parameters + cmd->sugg_max_tx_octets = APP_MAX_TX_OCTETS; + cmd->sugg_max_tx_time = APP_MAX_TX_TIME; + cmd->pairing_mode = GAPM_PAIRING_LEGACY; +#ifdef CFG_SEC_CON + cmd->pairing_mode |= GAPM_PAIRING_SEC_CON; +#endif + cmd->max_mtu = 512; + cmd->att_cfg = 0; + cmd->att_cfg |= GAPM_MASK_ATT_SVC_CHG_EN; +#if (BLE_APP_HID) + // Enable Slave Preferred Connection Parameters present + cmd->att_cfg |= GAPM_MASK_ATT_SLV_PREF_CON_PAR_EN; +#endif //(BLE_APP_HID) - #ifdef BLE_APP_AM0 - cmd->addr_type = GAPM_CFG_ADDR_HOST_PRIVACY; - cmd->audio_cfg = GAPM_MASK_AUDIO_AM0_SUP; - #endif // BLE_APP_AM0 +#ifdef BLE_APP_AM0 + cmd->addr_type = GAPM_CFG_ADDR_HOST_PRIVACY; + cmd->audio_cfg = GAPM_MASK_AUDIO_AM0_SUP; +#endif // BLE_APP_AM0 - // load IRK - memcpy(cmd->irk.key, app_env.loc_irk, KEY_LEN); + // load IRK + memcpy(cmd->irk.key, app_env.loc_irk, KEY_LEN); - // Send message - ke_msg_send(cmd); - } - else - { - ASSERT_ERR(0); - } - } - break; - case (GAPM_PROFILE_TASK_ADD): - { - // ASSERT_INFO(param->status == GAP_ERR_NO_ERROR, param->operation, param->status); - // Add the next requested service - if (!appm_add_svc()) - { - // Go to the ready state - ke_state_set(TASK_APP, APPM_READY); - - // No more service to add - app_ble_system_ready(); - } - } - break; - // Device Configuration updated - case (GAPM_SET_DEV_CONFIG): - { - ASSERT_INFO(param->status == GAP_ERR_NO_ERROR, param->operation, param->status); - - // Go to the create db state - ke_state_set(TASK_APP, APPM_CREATE_DB); - - // Add the first required service in the database - // and wait for the PROFILE_ADDED_IND - appm_add_svc(); - } - break; - - case (GAPM_ADV_NON_CONN): - case (GAPM_ADV_UNDIRECT): - #if !(BLE_APP_HID) - case (GAPM_ADV_DIRECT): - #endif// !(BLE_APP_HID) - case (GAPM_ADV_DIRECT_LDC): - { - LOG_I("adv evt cmp status 0x%x", param->status); - ASSERT(GAP_ERR_ADV_DATA_INVALID != param->status, - "The BLE adv data or scan rsp data is invalid! Better check their length."); - - if (GAP_ERR_CANCELED == param->status) - { - app_advertising_stopped(); - } - else if (GAP_ERR_NO_ERROR == param->status) - { - if (ke_state_get(TASK_APP) == APPM_ADVERTISING) - { - app_advertising_started(); - } - else - { - app_advertising_stopped(); - } - } - else - { - app_advertising_starting_failed(); - } - - break; + // Send message + ke_msg_send(cmd); + } else { + ASSERT_ERR(0); } - case GAPM_UPDATE_ADVERTISE_DATA: - { - app_adv_data_updated(); - break; - } - case GAPM_SCAN_ACTIVE: - case GAPM_SCAN_PASSIVE: - { - LOG_I("scan evt cmp status %d", param->status); - if (GAP_ERR_CANCELED == param->status) - { - app_scanning_stopped(); - } - else if (GAP_ERR_NO_ERROR == param->status) - { - app_scanning_started(); - } - else - { - app_scanning_starting_failed(); - } - } - break; - case GAPM_CONNECTION_DIRECT: - case GAPM_CONNECTION_AUTO: - case GAPM_CONNECTION_SELECTIVE: - case GAPM_CONNECTION_NAME_REQUEST: - case GAPM_CONNECTION_GENERAL: - { - BLE_GAP_DBG("connecting cmp status %d", param->status); - if (GAP_ERR_CANCELED == param->status) - { - app_connecting_stopped(); - } - else if (GAP_ERR_NO_ERROR == param->status) - { - app_connecting_started(); - } - else - { - app_connecting_failed(); - } - } - break; + } break; + case (GAPM_PROFILE_TASK_ADD): { + // ASSERT_INFO(param->status == GAP_ERR_NO_ERROR, param->operation, + // param->status); Add the next requested service + if (!appm_add_svc()) { + // Go to the ready state + ke_state_set(TASK_APP, APPM_READY); - #if (BLE_APP_HID) - case (GAPM_ADV_DIRECT): - { - if (param->status == GAP_ERR_TIMEOUT) - { - ke_state_set(TASK_APP, APPM_READY); - } - } break; - #endif //(BLE_APP_HID) - case GAPM_RESOLV_ADDR: - { - LOG_I("Resolve result %d", param->status); - if (GAP_ERR_NOT_FOUND == param->status) - { - appm_random_ble_addr_solved(false, NULL); - } - break; - } - default: - { - // Drop the message - } - break; + // No more service to add + app_ble_system_ready(); + } + } break; + // Device Configuration updated + case (GAPM_SET_DEV_CONFIG): { + ASSERT_INFO(param->status == GAP_ERR_NO_ERROR, param->operation, + param->status); + + // Go to the create db state + ke_state_set(TASK_APP, APPM_CREATE_DB); + + // Add the first required service in the database + // and wait for the PROFILE_ADDED_IND + appm_add_svc(); + } break; + + case (GAPM_ADV_NON_CONN): + case (GAPM_ADV_UNDIRECT): +#if !(BLE_APP_HID) + case (GAPM_ADV_DIRECT): +#endif // !(BLE_APP_HID) + case (GAPM_ADV_DIRECT_LDC): { + LOG_I("adv evt cmp status 0x%x", param->status); + ASSERT(GAP_ERR_ADV_DATA_INVALID != param->status, + "The BLE adv data or scan rsp data is invalid! Better check their " + "length."); + + if (GAP_ERR_CANCELED == param->status) { + app_advertising_stopped(); + } else if (GAP_ERR_NO_ERROR == param->status) { + if (ke_state_get(TASK_APP) == APPM_ADVERTISING) { + app_advertising_started(); + } else { + app_advertising_stopped(); + } + } else { + app_advertising_starting_failed(); } - BLE_APP_FUNC_LEAVE(); + break; + } + case GAPM_UPDATE_ADVERTISE_DATA: { + app_adv_data_updated(); + break; + } + case GAPM_SCAN_ACTIVE: + case GAPM_SCAN_PASSIVE: { + LOG_I("scan evt cmp status %d", param->status); + if (GAP_ERR_CANCELED == param->status) { + app_scanning_stopped(); + } else if (GAP_ERR_NO_ERROR == param->status) { + app_scanning_started(); + } else { + app_scanning_starting_failed(); + } + } break; + case GAPM_CONNECTION_DIRECT: + case GAPM_CONNECTION_AUTO: + case GAPM_CONNECTION_SELECTIVE: + case GAPM_CONNECTION_NAME_REQUEST: + case GAPM_CONNECTION_GENERAL: { + BLE_GAP_DBG("connecting cmp status %d", param->status); + if (GAP_ERR_CANCELED == param->status) { + app_connecting_stopped(); + } else if (GAP_ERR_NO_ERROR == param->status) { + app_connecting_started(); + } else { + app_connecting_failed(); + } + } break; - return (KE_MSG_CONSUMED); +#if (BLE_APP_HID) + case (GAPM_ADV_DIRECT): { + if (param->status == GAP_ERR_TIMEOUT) { + ke_state_set(TASK_APP, APPM_READY); + } + } break; +#endif //(BLE_APP_HID) + case GAPM_RESOLV_ADDR: { + LOG_I("Resolve result %d", param->status); + if (GAP_ERR_NOT_FOUND == param->status) { + appm_random_ble_addr_solved(false, NULL); + } + break; + } + default: { + // Drop the message + } break; + } + + BLE_APP_FUNC_LEAVE(); + + return (KE_MSG_CONSUMED); } -static int gapc_get_dev_info_req_ind_handler(ke_msg_id_t const msgid, - struct gapc_get_dev_info_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - switch(param->req) - { - case GAPC_DEV_NAME: - { - struct gapc_get_dev_info_cfm * cfm = KE_MSG_ALLOC_DYN(GAPC_GET_DEV_INFO_CFM, - src_id, dest_id, - gapc_get_dev_info_cfm, APP_DEVICE_NAME_MAX_LEN); - cfm->req = param->req; - cfm->info.name.length = appm_get_dev_name(cfm->info.name.value); +static int gapc_get_dev_info_req_ind_handler( + ke_msg_id_t const msgid, struct gapc_get_dev_info_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + switch (param->req) { + case GAPC_DEV_NAME: { + struct gapc_get_dev_info_cfm *cfm = + KE_MSG_ALLOC_DYN(GAPC_GET_DEV_INFO_CFM, src_id, dest_id, + gapc_get_dev_info_cfm, APP_DEVICE_NAME_MAX_LEN); + cfm->req = param->req; + cfm->info.name.length = appm_get_dev_name(cfm->info.name.value); - // Send message - ke_msg_send(cfm); - } break; + // Send message + ke_msg_send(cfm); + } break; - case GAPC_DEV_APPEARANCE: - { - // Allocate message - struct gapc_get_dev_info_cfm *cfm = KE_MSG_ALLOC(GAPC_GET_DEV_INFO_CFM, - src_id, dest_id, - gapc_get_dev_info_cfm); - cfm->req = param->req; - // Set the device appearance - #if (BLE_APP_HT) - // Generic Thermometer - TODO: Use a flag - cfm->info.appearance = 728; - #elif (BLE_APP_HID) - // HID Mouse - cfm->info.appearance = 962; - #else - // No appearance - cfm->info.appearance = 0; - #endif + case GAPC_DEV_APPEARANCE: { + // Allocate message + struct gapc_get_dev_info_cfm *cfm = KE_MSG_ALLOC( + GAPC_GET_DEV_INFO_CFM, src_id, dest_id, gapc_get_dev_info_cfm); + cfm->req = param->req; +// Set the device appearance +#if (BLE_APP_HT) + // Generic Thermometer - TODO: Use a flag + cfm->info.appearance = 728; +#elif (BLE_APP_HID) + // HID Mouse + cfm->info.appearance = 962; +#else + // No appearance + cfm->info.appearance = 0; +#endif - // Send message - ke_msg_send(cfm); - } break; + // Send message + ke_msg_send(cfm); + } break; - case GAPC_DEV_SLV_PREF_PARAMS: - { - // Allocate message - struct gapc_get_dev_info_cfm *cfm = KE_MSG_ALLOC(GAPC_GET_DEV_INFO_CFM, - src_id, dest_id, - gapc_get_dev_info_cfm); - cfm->req = param->req; - // Slave preferred Connection interval Min - cfm->info.slv_params.con_intv_min = 8; - // Slave preferred Connection interval Max - cfm->info.slv_params.con_intv_max = 10; - // Slave preferred Connection latency - cfm->info.slv_params.slave_latency = 0; - // Slave preferred Link supervision timeout - cfm->info.slv_params.conn_timeout = 200; // 2s (500*10ms) + case GAPC_DEV_SLV_PREF_PARAMS: { + // Allocate message + struct gapc_get_dev_info_cfm *cfm = KE_MSG_ALLOC( + GAPC_GET_DEV_INFO_CFM, src_id, dest_id, gapc_get_dev_info_cfm); + cfm->req = param->req; + // Slave preferred Connection interval Min + cfm->info.slv_params.con_intv_min = 8; + // Slave preferred Connection interval Max + cfm->info.slv_params.con_intv_max = 10; + // Slave preferred Connection latency + cfm->info.slv_params.slave_latency = 0; + // Slave preferred Link supervision timeout + cfm->info.slv_params.conn_timeout = 200; // 2s (500*10ms) - // Send message - ke_msg_send(cfm); - } break; + // Send message + ke_msg_send(cfm); + } break; - default: /* Do Nothing */ break; - } + default: /* Do Nothing */ + break; + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** **************************************************************************************** @@ -530,93 +473,85 @@ static int gapc_get_dev_info_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -static int gapc_set_dev_info_req_ind_handler(ke_msg_id_t const msgid, - struct gapc_set_dev_info_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Set Device configuration - struct gapc_set_dev_info_cfm* cfm = KE_MSG_ALLOC(GAPC_SET_DEV_INFO_CFM, src_id, dest_id, - gapc_set_dev_info_cfm); - // Reject to change parameters - cfm->status = GAP_ERR_REJECTED; - cfm->req = param->req; - // Send message - ke_msg_send(cfm); +static int gapc_set_dev_info_req_ind_handler( + ke_msg_id_t const msgid, struct gapc_set_dev_info_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Set Device configuration + struct gapc_set_dev_info_cfm *cfm = KE_MSG_ALLOC( + GAPC_SET_DEV_INFO_CFM, src_id, dest_id, gapc_set_dev_info_cfm); + // Reject to change parameters + cfm->status = GAP_ERR_REJECTED; + cfm->req = param->req; + // Send message + ke_msg_send(cfm); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } -static void POSSIBLY_UNUSED gapc_refresh_remote_dev_feature(uint8_t conidx) -{ - // Send a GAPC_GET_INFO_CMD in order to read the device name characteristic value - struct gapc_get_info_cmd *p_cmd = KE_MSG_ALLOC(GAPC_GET_INFO_CMD, - KE_BUILD_ID(TASK_GAPC, conidx), TASK_GAPM, - gapc_get_info_cmd); +static void POSSIBLY_UNUSED gapc_refresh_remote_dev_feature(uint8_t conidx) { + // Send a GAPC_GET_INFO_CMD in order to read the device name characteristic + // value + struct gapc_get_info_cmd *p_cmd = + KE_MSG_ALLOC(GAPC_GET_INFO_CMD, KE_BUILD_ID(TASK_GAPC, conidx), TASK_GAPM, + gapc_get_info_cmd); - // request peer device name. - p_cmd->operation = GAPC_GET_PEER_FEATURES; + // request peer device name. + p_cmd->operation = GAPC_GET_PEER_FEATURES; - // send command - ke_msg_send(p_cmd); + // send command + ke_msg_send(p_cmd); } -static void POSSIBLY_UNUSED gpac_exchange_data_packet_length(uint8_t conidx) -{ +static void POSSIBLY_UNUSED gpac_exchange_data_packet_length(uint8_t conidx) { #if defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) - return; + return; #endif - - struct gapc_set_le_pkt_size_cmd *set_le_pakt_size_req = KE_MSG_ALLOC(GAPC_SET_LE_PKT_SIZE_CMD, - KE_BUILD_ID(TASK_GAPC, conidx), - TASK_APP, - gapc_set_le_pkt_size_cmd); - set_le_pakt_size_req->operation = GAPC_SET_LE_PKT_SIZE; - set_le_pakt_size_req->tx_octets = APP_MAX_TX_OCTETS; - set_le_pakt_size_req->tx_time = APP_MAX_TX_TIME; - // Send message - ke_msg_send(set_le_pakt_size_req); + struct gapc_set_le_pkt_size_cmd *set_le_pakt_size_req = + KE_MSG_ALLOC(GAPC_SET_LE_PKT_SIZE_CMD, KE_BUILD_ID(TASK_GAPC, conidx), + TASK_APP, gapc_set_le_pkt_size_cmd); + + set_le_pakt_size_req->operation = GAPC_SET_LE_PKT_SIZE; + set_le_pakt_size_req->tx_octets = APP_MAX_TX_OCTETS; + set_le_pakt_size_req->tx_time = APP_MAX_TX_TIME; + // Send message + ke_msg_send(set_le_pakt_size_req); } static int gapc_peer_features_ind_handler(ke_msg_id_t const msgid, - struct gapc_peer_features_ind* param, + struct gapc_peer_features_ind *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - LOG_I("Peer dev feature is:"); - DUMP8("0x%02x ", param->features, GAP_LE_FEATS_LEN); - uint8_t conidx = KE_IDX_GET(src_id); + ke_task_id_t const src_id) { + LOG_I("Peer dev feature is:"); + DUMP8("0x%02x ", param->features, GAP_LE_FEATS_LEN); + uint8_t conidx = KE_IDX_GET(src_id); - if (param->features[0] & GAPC_EXT_DATA_LEN_MASK) - { - gpac_exchange_data_packet_length(conidx); - } - return (KE_MSG_CONSUMED); + if (param->features[0] & GAPC_EXT_DATA_LEN_MASK) { + gpac_exchange_data_packet_length(conidx); + } + return (KE_MSG_CONSUMED); } -void app_exchange_remote_feature(uint8_t conidx) -{ - APP_BLE_CONN_CONTEXT_T *pContext = &(app_env.context[conidx]); +void app_exchange_remote_feature(uint8_t conidx) { + APP_BLE_CONN_CONTEXT_T *pContext = &(app_env.context[conidx]); - LOG_I("connectStatus:%d, isFeatureExchanged:%d, isGotSolvedBdAddr:%d", - pContext->connectStatus, - pContext->isFeatureExchanged, - pContext->isGotSolvedBdAddr); + LOG_I("connectStatus:%d, isFeatureExchanged:%d, isGotSolvedBdAddr:%d", + pContext->connectStatus, pContext->isFeatureExchanged, + pContext->isGotSolvedBdAddr); - if ((BLE_CONNECTED == pContext->connectStatus) && !pContext->isFeatureExchanged) - { - if (pContext->isGotSolvedBdAddr) - { - gapc_refresh_remote_dev_feature(conidx); - pContext->isFeatureExchanged = true; - } + if ((BLE_CONNECTED == pContext->connectStatus) && + !pContext->isFeatureExchanged) { + if (pContext->isGotSolvedBdAddr) { + gapc_refresh_remote_dev_feature(conidx); + pContext->isFeatureExchanged = true; } + } } /** **************************************************************************************** - * @brief Handles connection complete event from the GAP. Enable all required profiles + * @brief Handles connection complete event from the GAP. Enable all required + *profiles * * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. @@ -626,101 +561,96 @@ void app_exchange_remote_feature(uint8_t conidx) * @return If the message was consumed or not. **************************************************************************************** */ -static int gapc_connection_req_ind_handler(ke_msg_id_t const msgid, - struct gapc_connection_req_ind* param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t conidx = KE_IDX_GET(src_id); +static int gapc_connection_req_ind_handler( + ke_msg_id_t const msgid, struct gapc_connection_req_ind *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + uint8_t conidx = KE_IDX_GET(src_id); - APP_BLE_CONN_CONTEXT_T* pContext = &(app_env.context[conidx]); - - pContext->connectStatus = BLE_CONNECTED; + APP_BLE_CONN_CONTEXT_T *pContext = &(app_env.context[conidx]); - APP_BLE_NEGOTIATED_CONN_PARAM_T connParam; - connParam.con_interval = param->con_interval; - connParam.sup_to= param->sup_to; - connParam.con_latency = param->con_latency; - app_ble_save_negotiated_conn_param(conidx, &connParam); + pContext->connectStatus = BLE_CONNECTED; - ke_state_set(dest_id, APPM_CONNECTED); + APP_BLE_NEGOTIATED_CONN_PARAM_T connParam; + connParam.con_interval = param->con_interval; + connParam.sup_to = param->sup_to; + connParam.con_latency = param->con_latency; + app_ble_save_negotiated_conn_param(conidx, &connParam); - app_env.conn_cnt++; + ke_state_set(dest_id, APPM_CONNECTED); - if (app_is_resolving_ble_bd_addr()) - { - LOG_I("A ongoing ble addr solving is in progress, refuse the new connection."); - appm_disconnect(conidx); - return KE_MSG_CONSUMED; + app_env.conn_cnt++; + + if (app_is_resolving_ble_bd_addr()) { + LOG_I("A ongoing ble addr solving is in progress, refuse the new " + "connection."); + appm_disconnect(conidx); + return KE_MSG_CONSUMED; + } + + LOG_I("[CONNECT]device info:"); + LOG_I("peer addr:"); + DUMP8("%02x ", param->peer_addr.addr, 6); + LOG_I("peer addr type:%d", param->peer_addr_type); + LOG_I("connection index:%d, isGotSolvedBdAddr:%d", conidx, + pContext->isGotSolvedBdAddr); + LOG_I("conn interval:%d, timeout:%d", param->con_interval, param->sup_to); + + BLE_APP_FUNC_ENTER(); + + // Check if the received Connection Handle was valid + if (conidx != GAP_INVALID_CONIDX) { + pContext->peerAddrType = param->peer_addr_type; + memcpy(pContext->bdAddr, param->peer_addr.addr, BD_ADDR_LEN); + + // Retrieve the connection info from the parameters + pContext->conhdl = param->conhdl; + + if (BLE_RANDOM_ADDR == pContext->peerAddrType) { + pContext->isGotSolvedBdAddr = false; + } else { + pContext->isGotSolvedBdAddr = true; } - LOG_I("[CONNECT]device info:"); - LOG_I("peer addr:"); - DUMP8("%02x ", param->peer_addr.addr, 6); - LOG_I("peer addr type:%d", param->peer_addr_type); - LOG_I("connection index:%d, isGotSolvedBdAddr:%d", conidx, pContext->isGotSolvedBdAddr); - LOG_I("conn interval:%d, timeout:%d", param->con_interval, param->sup_to); - - BLE_APP_FUNC_ENTER(); - - // Check if the received Connection Handle was valid - if (conidx != GAP_INVALID_CONIDX) - { - pContext->peerAddrType = param->peer_addr_type; - memcpy(pContext->bdAddr, param->peer_addr.addr, BD_ADDR_LEN); - - // Retrieve the connection info from the parameters - pContext->conhdl = param->conhdl; - - if (BLE_RANDOM_ADDR == pContext->peerAddrType) - { - pContext->isGotSolvedBdAddr = false; - } - else - { - pContext->isGotSolvedBdAddr = true; - } - - // Clear the advertising timeout timer - if (ke_timer_active(APP_ADV_TIMEOUT_TIMER, TASK_APP)) - { - ke_timer_clear(APP_ADV_TIMEOUT_TIMER, TASK_APP); - } - - #if (BLE_APP_SEC) - app_sec_reset_env_on_connection(); - #endif - - // Send connection confirmation - struct gapc_connection_cfm *cfm = KE_MSG_ALLOC(GAPC_CONNECTION_CFM, - KE_BUILD_ID(TASK_GAPC, conidx), TASK_APP, - gapc_connection_cfm); - - #if (BLE_APP_SEC) - cfm->auth = app_sec_get_bond_status() ? BLE_AUTHENTICATION_LEVEL : GAP_AUTH_REQ_NO_MITM_NO_BOND; - #else // !(BLE_APP_SEC) - cfm->auth = GAP_AUTH_REQ_NO_MITM_NO_BOND; - #endif // (BLE_APP_SEC) - // Send the message - ke_msg_send(cfm); - - // We are now in connected State - ke_state_set(dest_id, APPM_CONNECTED); - app_exchange_remote_feature(conidx); - - app_ble_connected_evt_handler(conidx, param->peer_addr.addr); + // Clear the advertising timeout timer + if (ke_timer_active(APP_ADV_TIMEOUT_TIMER, TASK_APP)) { + ke_timer_clear(APP_ADV_TIMEOUT_TIMER, TASK_APP); } -#if (BLE_APP_TILE) - app_tile_connected_evt_handler(conidx, param); +#if (BLE_APP_SEC) + app_sec_reset_env_on_connection(); #endif - app_env.context[conidx].connInterval = param->con_interval; - - app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_DEFAULT, true); - BLE_APP_FUNC_LEAVE(); + // Send connection confirmation + struct gapc_connection_cfm *cfm = + KE_MSG_ALLOC(GAPC_CONNECTION_CFM, KE_BUILD_ID(TASK_GAPC, conidx), + TASK_APP, gapc_connection_cfm); - return (KE_MSG_CONSUMED); +#if (BLE_APP_SEC) + cfm->auth = app_sec_get_bond_status() ? BLE_AUTHENTICATION_LEVEL + : GAP_AUTH_REQ_NO_MITM_NO_BOND; +#else // !(BLE_APP_SEC) + cfm->auth = GAP_AUTH_REQ_NO_MITM_NO_BOND; +#endif // (BLE_APP_SEC) + // Send the message + ke_msg_send(cfm); + + // We are now in connected State + ke_state_set(dest_id, APPM_CONNECTED); + app_exchange_remote_feature(conidx); + + app_ble_connected_evt_handler(conidx, param->peer_addr.addr); + } + +#if (BLE_APP_TILE) + app_tile_connected_evt_handler(conidx, param); +#endif + + app_env.context[conidx].connInterval = param->con_interval; + + app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_DEFAULT, true); + BLE_APP_FUNC_LEAVE(); + + return (KE_MSG_CONSUMED); } /** @@ -738,24 +668,19 @@ static int gapc_connection_req_ind_handler(ke_msg_id_t const msgid, static int gapc_cmp_evt_handler(ke_msg_id_t const msgid, struct gapc_cmp_evt const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - switch(param->operation) - { - case (GAPC_UPDATE_PARAMS): - { - if (param->status != GAP_ERR_NO_ERROR) - { -// appm_disconnect(); - } - } break; - - default: - { - } break; + ke_task_id_t const src_id) { + switch (param->operation) { + case (GAPC_UPDATE_PARAMS): { + if (param->status != GAP_ERR_NO_ERROR) { + // appm_disconnect(); } + } break; - return (KE_MSG_CONSUMED); + default: { + } break; + } + + return (KE_MSG_CONSUMED); } /** @@ -771,76 +696,73 @@ static int gapc_cmp_evt_handler(ke_msg_id_t const msgid, **************************************************************************************** */ static int gapc_disconnect_ind_handler(ke_msg_id_t const msgid, - struct gapc_disconnect_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - LOG_I("[DISCONNECT] device info:"); - uint8_t conidx = KE_IDX_GET(src_id); - LOG_I("connection index:%d, reason:0x%x", conidx, param->reason); + struct gapc_disconnect_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + LOG_I("[DISCONNECT] device info:"); + uint8_t conidx = KE_IDX_GET(src_id); + LOG_I("connection index:%d, reason:0x%x", conidx, param->reason); - app_env.context[conidx].isBdAddrResolvingInProgress = false; - app_env.context[conidx].isGotSolvedBdAddr = false; + app_env.context[conidx].isBdAddrResolvingInProgress = false; + app_env.context[conidx].isGotSolvedBdAddr = false; - app_env.context[conidx].connectStatus = BLE_DISCONNECTED; - app_env.context[conidx].isFeatureExchanged = false; - app_env.context[conidx].connInterval = 0; - l2cm_buffer_reset(conidx); - - // Go to the ready state - ke_state_set(TASK_APP, APPM_READY); + app_env.context[conidx].connectStatus = BLE_DISCONNECTED; + app_env.context[conidx].isFeatureExchanged = false; + app_env.context[conidx].connInterval = 0; + l2cm_buffer_reset(conidx); - app_env.conn_cnt--; + // Go to the ready state + ke_state_set(TASK_APP, APPM_READY); - #if (BLE_VOICEPATH) - app_voicepath_disconnected_evt_handler(conidx); - #endif + app_env.conn_cnt--; - #if (BLE_DATAPATH_SERVER) - app_datapath_server_disconnected_evt_handler(conidx); - #endif +#if (BLE_VOICEPATH) + app_voicepath_disconnected_evt_handler(conidx); +#endif - #if (BLE_OTA) - app_ota_disconnected_evt_handler(conidx); - #endif - - #if (BLE_APP_TOTA) - app_tota_disconnected_evt_handler(conidx); - #endif +#if (BLE_DATAPATH_SERVER) + app_datapath_server_disconnected_evt_handler(conidx); +#endif - #if(BLE_APP_GFPS) - app_gfps_disconnected_evt_handler(conidx); - #endif - +#if (BLE_OTA) + app_ota_disconnected_evt_handler(conidx); +#endif - #if (BLE_AI_VOICE) - app_ai_disconnected_evt_handler(conidx); - #endif +#if (BLE_APP_TOTA) + app_tota_disconnected_evt_handler(conidx); +#endif - #if (BLE_APP_TILE) - app_tile_disconnected_evt_handler(conidx); - #endif +#if (BLE_APP_GFPS) + app_gfps_disconnected_evt_handler(conidx); +#endif - app_ble_disconnected_evt_handler(conidx); +#if (BLE_AI_VOICE) + app_ai_disconnected_evt_handler(conidx); +#endif - app_ble_reset_conn_param_mode(conidx); - return (KE_MSG_CONSUMED); +#if (BLE_APP_TILE) + app_tile_disconnected_evt_handler(conidx); +#endif + + app_ble_disconnected_evt_handler(conidx); + + app_ble_reset_conn_param_mode(conidx); + return (KE_MSG_CONSUMED); } - static int gapm_profile_added_ind_handler(ke_msg_id_t const msgid, struct gapm_profile_added_ind *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - LOG_I("prf_task_id %d is added.", param->prf_task_id); + ke_task_id_t const src_id) { + LOG_I("prf_task_id %d is added.", param->prf_task_id); - return KE_MSG_CONSUMED; + return KE_MSG_CONSUMED; } /** **************************************************************************************** - * @brief Handles reception of all messages sent from the lower layers to the application + * @brief Handles reception of all messages sent from the lower layers to the + *application * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance @@ -849,386 +771,345 @@ static int gapm_profile_added_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -static int appm_msg_handler(ke_msg_id_t const msgid, - void *param, +static int appm_msg_handler(ke_msg_id_t const msgid, void *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Retrieve identifier of the task from received message - ke_task_id_t src_task_id = MSG_T(msgid); - // Message policy - uint8_t msg_pol = KE_MSG_CONSUMED; + ke_task_id_t const src_id) { + // Retrieve identifier of the task from received message + ke_task_id_t src_task_id = MSG_T(msgid); + // Message policy + uint8_t msg_pol = KE_MSG_CONSUMED; - - switch (src_task_id) - { - case (TASK_ID_GAPC): - { - #if (BLE_APP_SEC) - if ((msgid >= GAPC_BOND_CMD) && - (msgid <= GAPC_SECURITY_IND)) - { - // Call the Security Module - msg_pol = appm_get_handler(&app_sec_table_handler, msgid, param, src_id); - } - #endif //(BLE_APP_SEC) - // else drop the message - } break; - - case (TASK_ID_GATTC): - { - // Service Changed - Drop - } break; - - #if (BLE_APP_HT) - case (TASK_ID_HTPT): - { - // Call the Health Thermometer Module - msg_pol = appm_get_handler(&app_ht_table_handler, msgid, param, src_id); - } break; - #endif //(BLE_APP_HT) - - #if (BLE_APP_DIS) - case (TASK_ID_DISS): - { - // Call the Device Information Module - msg_pol = appm_get_handler(&app_dis_table_handler, msgid, param, src_id); - } break; - #endif //(BLE_APP_DIS) - - #if (BLE_APP_HID) - case (TASK_ID_HOGPD): - { - // Call the HID Module - msg_pol = appm_get_handler(&app_hid_table_handler, msgid, param, src_id); - } break; - #endif //(BLE_APP_HID) - - #if (BLE_APP_BATT) - case (TASK_ID_BASS): - { - // Call the Battery Module - msg_pol = appm_get_handler(&app_batt_table_handler, msgid, param, src_id); - } break; - #endif //(BLE_APP_BATT) - - #if defined(BLE_APP_AM0) - case (TASK_ID_AM0): - { - // Call the Audio Mode 0 Module - msg_pol = appm_get_handler(&am0_app_table_handler, msgid, param, src_id); - } break; - case (TASK_ID_AM0_HAS): - { - // Call the Audio Mode 0 Module - msg_pol = appm_get_handler(&am0_app_has_table_handler, msgid, param, src_id); - } break; - #endif // defined(BLE_APP_AM0) - - #if (BLE_APP_HR) - case (TASK_ID_HRPS): - { - // Call the HRPS Module - msg_pol = appm_get_handler(&app_hrps_table_handler, msgid, param, src_id); - } break; - #endif - - #if (BLE_APP_VOICEPATH) - case (TASK_ID_VOICEPATH): - { - // Call the Voice Path Module - msg_pol = appm_get_handler(app_voicepath_ble_get_msg_handler_table(), msgid, param, src_id); - } break; - #endif //(BLE_APP_VOICEPATH) - - #if (BLE_APP_DATAPATH_SERVER) - case (TASK_ID_DATAPATHPS): - { - // Call the Data Path Module - msg_pol = appm_get_handler(&app_datapath_server_table_handler, msgid, param, src_id); - } break; - #endif //(BLE_APP_DATAPATH_SERVER) - #if (BLE_APP_TILE) - case (TASK_ID_TILE): - { - // Call the TILE Module - msg_pol = appm_get_handler(&app_tile_table_handler, msgid, param, src_id); - } - break; - #endif - - #if (BLE_APP_AI_VOICE) - case (TASK_ID_AI): - { - // Call the AI Voice - msg_pol = appm_get_handler(app_ai_table_handler, msgid, param, src_id); - } break; - #endif //(BLE_APP_AI_VOICE) - - #if (BLE_APP_OTA) - case (TASK_ID_OTA): - { - // Call the OTA - msg_pol = appm_get_handler(&app_ota_table_handler, msgid, param, src_id); - } break; - #endif //(BLE_APP_OTA) - - #if (BLE_APP_TOTA) - case (TASK_ID_TOTA): - { - // Call the TOTA - msg_pol = appm_get_handler(&app_tota_table_handler, msgid, param, src_id); - } break; - #endif //(BLE_APP_TOTA) - - #if (BLE_APP_ANCC) - case (TASK_ID_ANCC): - { - // Call the ANCC - msg_pol = appm_get_handler(&app_ancc_table_handler, msgid, param, src_id); - } break; - #endif //(BLE_APP_ANCC) - - #if (BLE_APP_AMS) - case (TASK_ID_AMSC): - { - // Call the AMS - msg_pol = appm_get_handler(&app_amsc_table_handler, msgid, param, src_id); - } break; - #endif //(BLE_APP_AMS) - #if (BLE_APP_GFPS) - case (TASK_ID_GFPSP): - { - msg_pol = appm_get_handler(&app_gfps_table_handler, msgid, param, src_id); - } break; - #endif - - default: - { - #if (BLE_APP_HT) - if (msgid == APP_HT_MEAS_INTV_TIMER) - { - msg_pol = appm_get_handler(&app_ht_table_handler, msgid, param, src_id); - } - #endif //(BLE_APP_HT) - - #if (BLE_APP_HID) - if (msgid == APP_HID_MOUSE_TIMEOUT_TIMER) - { - msg_pol = appm_get_handler(&app_hid_table_handler, msgid, param, src_id); - } - #endif //(BLE_APP_HID) - } break; + switch (src_task_id) { + case (TASK_ID_GAPC): { +#if (BLE_APP_SEC) + if ((msgid >= GAPC_BOND_CMD) && (msgid <= GAPC_SECURITY_IND)) { + // Call the Security Module + msg_pol = appm_get_handler(&app_sec_table_handler, msgid, param, src_id); } +#endif //(BLE_APP_SEC) + // else drop the message + } break; - return (msg_pol); + case (TASK_ID_GATTC): { + // Service Changed - Drop + } break; + +#if (BLE_APP_HT) + case (TASK_ID_HTPT): { + // Call the Health Thermometer Module + msg_pol = appm_get_handler(&app_ht_table_handler, msgid, param, src_id); + } break; +#endif //(BLE_APP_HT) + +#if (BLE_APP_DIS) + case (TASK_ID_DISS): { + // Call the Device Information Module + msg_pol = appm_get_handler(&app_dis_table_handler, msgid, param, src_id); + } break; +#endif //(BLE_APP_DIS) + +#if (BLE_APP_HID) + case (TASK_ID_HOGPD): { + // Call the HID Module + msg_pol = appm_get_handler(&app_hid_table_handler, msgid, param, src_id); + } break; +#endif //(BLE_APP_HID) + +#if (BLE_APP_BATT) + case (TASK_ID_BASS): { + // Call the Battery Module + msg_pol = appm_get_handler(&app_batt_table_handler, msgid, param, src_id); + } break; +#endif //(BLE_APP_BATT) + +#if defined(BLE_APP_AM0) + case (TASK_ID_AM0): { + // Call the Audio Mode 0 Module + msg_pol = appm_get_handler(&am0_app_table_handler, msgid, param, src_id); + } break; + case (TASK_ID_AM0_HAS): { + // Call the Audio Mode 0 Module + msg_pol = + appm_get_handler(&am0_app_has_table_handler, msgid, param, src_id); + } break; +#endif // defined(BLE_APP_AM0) + +#if (BLE_APP_HR) + case (TASK_ID_HRPS): { + // Call the HRPS Module + msg_pol = appm_get_handler(&app_hrps_table_handler, msgid, param, src_id); + } break; +#endif + +#if (BLE_APP_VOICEPATH) + case (TASK_ID_VOICEPATH): { + // Call the Voice Path Module + msg_pol = appm_get_handler(app_voicepath_ble_get_msg_handler_table(), msgid, + param, src_id); + } break; +#endif //(BLE_APP_VOICEPATH) + +#if (BLE_APP_DATAPATH_SERVER) + case (TASK_ID_DATAPATHPS): { + // Call the Data Path Module + msg_pol = appm_get_handler(&app_datapath_server_table_handler, msgid, param, + src_id); + } break; +#endif //(BLE_APP_DATAPATH_SERVER) +#if (BLE_APP_TILE) + case (TASK_ID_TILE): { + // Call the TILE Module + msg_pol = appm_get_handler(&app_tile_table_handler, msgid, param, src_id); + } break; +#endif + +#if (BLE_APP_AI_VOICE) + case (TASK_ID_AI): { + // Call the AI Voice + msg_pol = appm_get_handler(app_ai_table_handler, msgid, param, src_id); + } break; +#endif //(BLE_APP_AI_VOICE) + +#if (BLE_APP_OTA) + case (TASK_ID_OTA): { + // Call the OTA + msg_pol = appm_get_handler(&app_ota_table_handler, msgid, param, src_id); + } break; +#endif //(BLE_APP_OTA) + +#if (BLE_APP_TOTA) + case (TASK_ID_TOTA): { + // Call the TOTA + msg_pol = appm_get_handler(&app_tota_table_handler, msgid, param, src_id); + } break; +#endif //(BLE_APP_TOTA) + +#if (BLE_APP_ANCC) + case (TASK_ID_ANCC): { + // Call the ANCC + msg_pol = appm_get_handler(&app_ancc_table_handler, msgid, param, src_id); + } break; +#endif //(BLE_APP_ANCC) + +#if (BLE_APP_AMS) + case (TASK_ID_AMSC): { + // Call the AMS + msg_pol = appm_get_handler(&app_amsc_table_handler, msgid, param, src_id); + } break; +#endif //(BLE_APP_AMS) +#if (BLE_APP_GFPS) + case (TASK_ID_GFPSP): { + msg_pol = appm_get_handler(&app_gfps_table_handler, msgid, param, src_id); + } break; +#endif + + default: { +#if (BLE_APP_HT) + if (msgid == APP_HT_MEAS_INTV_TIMER) { + msg_pol = appm_get_handler(&app_ht_table_handler, msgid, param, src_id); + } +#endif //(BLE_APP_HT) + +#if (BLE_APP_HID) + if (msgid == APP_HID_MOUSE_TIMEOUT_TIMER) { + msg_pol = appm_get_handler(&app_hid_table_handler, msgid, param, src_id); + } +#endif //(BLE_APP_HID) + } break; + } + + return (msg_pol); } static int gapm_adv_report_ind_handler(ke_msg_id_t const msgid, - struct gapm_adv_report_ind *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - app_adv_reported_scanned(param); - return KE_MSG_CONSUMED; + struct gapm_adv_report_ind *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + app_adv_reported_scanned(param); + return KE_MSG_CONSUMED; } static int gapm_addr_solved_ind_handler(ke_msg_id_t const msgid, - struct gapm_addr_solved_ind *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - /// Indicate that resolvable random address has been solved - appm_random_ble_addr_solved(true, param->irk.key); - return KE_MSG_CONSUMED; + struct gapm_addr_solved_ind *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + /// Indicate that resolvable random address has been solved + appm_random_ble_addr_solved(true, param->irk.key); + return KE_MSG_CONSUMED; } -__STATIC int gattc_mtu_changed_ind_handler(ke_msg_id_t const msgid, - struct gattc_mtu_changed_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t conidx = KE_IDX_GET(src_id); - - LOG_I("MTU has been negotiated as %d conidx %d", param->mtu, conidx); - - +__STATIC int gattc_mtu_changed_ind_handler( + ke_msg_id_t const msgid, struct gattc_mtu_changed_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + uint8_t conidx = KE_IDX_GET(src_id); + + LOG_I("MTU has been negotiated as %d conidx %d", param->mtu, conidx); + #if (BLE_APP_DATAPATH_SERVER) - app_datapath_server_mtu_exchanged_handler(conidx, param->mtu); + app_datapath_server_mtu_exchanged_handler(conidx, param->mtu); #endif #if (BLE_VOICEPATH) - app_voicepath_mtu_exchanged_handler(conidx, param->mtu); + app_voicepath_mtu_exchanged_handler(conidx, param->mtu); #endif #if (BLE_OTA) - app_ota_mtu_exchanged_handler(conidx, param->mtu); + app_ota_mtu_exchanged_handler(conidx, param->mtu); #endif #if (BLE_APP_TOTA) - app_tota_mtu_exchanged_handler(conidx, param->mtu); + app_tota_mtu_exchanged_handler(conidx, param->mtu); #endif #if (BLE_AI_VOICE) - app_ai_mtu_exchanged_handler(conidx, param->mtu); + app_ai_mtu_exchanged_handler(conidx, param->mtu); #endif - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } -#define APP_CONN_PARAM_INTERVEL_MAX (30) -__STATIC int gapc_conn_param_update_req_ind_handler(ke_msg_id_t const msgid, - struct gapc_param_update_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - bool accept = true; - ble_evnet_t event; +#define APP_CONN_PARAM_INTERVEL_MAX (30) +__STATIC int gapc_conn_param_update_req_ind_handler( + ke_msg_id_t const msgid, struct gapc_param_update_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + bool accept = true; + ble_evnet_t event; - LOG_I("Receive the conn param update request: min %d max %d latency %d timeout %d", - param->intv_min, - param->intv_max, - param->latency, - param->time_out); + LOG_I("Receive the conn param update request: min %d max %d latency %d " + "timeout %d", + param->intv_min, param->intv_max, param->latency, param->time_out); - struct gapc_param_update_cfm* cfm = KE_MSG_ALLOC(GAPC_PARAM_UPDATE_CFM, src_id, dest_id, - gapc_param_update_cfm); + struct gapc_param_update_cfm *cfm = KE_MSG_ALLOC( + GAPC_PARAM_UPDATE_CFM, src_id, dest_id, gapc_param_update_cfm); - event.evt_type = BLE_CONN_PARAM_UPDATE_REQ_EVENT; - event.p.conn_param_update_req_handled.intv_min = param->intv_min; - event.p.conn_param_update_req_handled.intv_max = param->intv_max; - event.p.conn_param_update_req_handled.latency = param->latency; - event.p.conn_param_update_req_handled.time_out = param->time_out; - - app_ble_core_global_handle(&event, &accept); - LOG_I("%s ret %d ", __func__, accept); + event.evt_type = BLE_CONN_PARAM_UPDATE_REQ_EVENT; + event.p.conn_param_update_req_handled.intv_min = param->intv_min; + event.p.conn_param_update_req_handled.intv_max = param->intv_max; + event.p.conn_param_update_req_handled.latency = param->latency; + event.p.conn_param_update_req_handled.time_out = param->time_out; - cfm->accept = accept; + app_ble_core_global_handle(&event, &accept); + LOG_I("%s ret %d ", __func__, accept); + + cfm->accept = accept; #ifdef GFPS_ENABLED - // if fastpair doesn't have the requirement of finishing - // pairing in a really short period, just comment out this - // code block to avoid audio glitch if this event happens during music - // playback and interval is smaller than 15ms - if (param->intv_min < (uint16_t)(15/1.25)) - { - LOG_I("accept"); - cfm->accept = true; - fp_update_ble_connect_param_start(KE_IDX_GET(src_id)); - } - else - { - fp_update_ble_connect_param_stop(KE_IDX_GET(src_id)); - } + // if fastpair doesn't have the requirement of finishing + // pairing in a really short period, just comment out this + // code block to avoid audio glitch if this event happens during music + // playback and interval is smaller than 15ms + if (param->intv_min < (uint16_t)(15 / 1.25)) { + LOG_I("accept"); + cfm->accept = true; + fp_update_ble_connect_param_start(KE_IDX_GET(src_id)); + } else { + fp_update_ble_connect_param_stop(KE_IDX_GET(src_id)); + } #endif - ke_msg_send(cfm); + ke_msg_send(cfm); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } static int gapc_conn_param_updated_handler(ke_msg_id_t const msgid, - struct gapc_param_updated_ind* param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t conidx = KE_IDX_GET(src_id); - LOG_I("Conidx %d conn parameter is updated as interval %d timeout %d", - conidx, - param->con_interval, - param->sup_to); + struct gapc_param_updated_ind *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t conidx = KE_IDX_GET(src_id); + LOG_I("Conidx %d conn parameter is updated as interval %d timeout %d", conidx, + param->con_interval, param->sup_to); + + APP_BLE_NEGOTIATED_CONN_PARAM_T connParam; + connParam.con_interval = param->con_interval; + connParam.sup_to = param->sup_to; + connParam.con_latency = param->con_latency; + app_ble_save_negotiated_conn_param(conidx, &connParam); - APP_BLE_NEGOTIATED_CONN_PARAM_T connParam; - connParam.con_interval = param->con_interval; - connParam.sup_to= param->sup_to; - connParam.con_latency = param->con_latency; - app_ble_save_negotiated_conn_param(conidx, &connParam); - #if (BLE_VOICEPATH) - app_voicepath_ble_conn_parameter_updated(conidx, param->con_interval, param->con_latency); + app_voicepath_ble_conn_parameter_updated(conidx, param->con_interval, + param->con_latency); #endif #if BLE_APP_TILE - app_tile_ble_conn_parameter_updated(conidx, param); + app_tile_ble_conn_parameter_updated(conidx, param); #endif - app_env.context[conidx].connInterval = param->con_interval; - - if (param->con_interval >= 32) - { - if (app_ble_is_parameter_mode_enabled(conidx, BLE_CONN_PARAM_MODE_OTA)) - { - app_ble_parameter_mode_clear(conidx, BLE_CONN_PARAM_MODE_OTA); - app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_OTA_SLOWER, true); - } - else if (app_ble_is_parameter_mode_enabled(conidx, BLE_CONN_PARAM_MODE_AI_STREAM_ON)) - { - app_ble_parameter_mode_clear(conidx, BLE_CONN_PARAM_MODE_AI_STREAM_ON); - app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_AI_STREAM_ON, true); - } + app_env.context[conidx].connInterval = param->con_interval; + + if (param->con_interval >= 32) { + if (app_ble_is_parameter_mode_enabled(conidx, BLE_CONN_PARAM_MODE_OTA)) { + app_ble_parameter_mode_clear(conidx, BLE_CONN_PARAM_MODE_OTA); + app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_OTA_SLOWER, true); + } else if (app_ble_is_parameter_mode_enabled( + conidx, BLE_CONN_PARAM_MODE_AI_STREAM_ON)) { + app_ble_parameter_mode_clear(conidx, BLE_CONN_PARAM_MODE_AI_STREAM_ON); + app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_AI_STREAM_ON, true); } - - return (KE_MSG_CONSUMED); + } + + return (KE_MSG_CONSUMED); } static int gapm_dev_addr_ind_handler(ke_msg_id_t const msgid, - struct gapm_dev_bdaddr_ind *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - ble_evnet_t event; + struct gapm_dev_bdaddr_ind *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + ble_evnet_t event; - // Indicate that a new random BD address set in lower layers - LOG_I("New dev addr:"); - DUMP8("%02x ", param->addr.addr.addr, 6); + // Indicate that a new random BD address set in lower layers + LOG_I("New dev addr:"); + DUMP8("%02x ", param->addr.addr.addr, 6); #ifdef GFPS_ENABLED - app_fp_msg_send_updated_ble_addr(); - app_gfps_update_random_salt(); + app_fp_msg_send_updated_ble_addr(); + app_gfps_update_random_salt(); #endif + event.evt_type = BLE_SET_RANDOM_BD_ADDR_EVENT; + event.p.set_random_bd_addr_handled.new_bdaddr = param->addr.addr.addr; + app_ble_core_global_handle(&event, NULL); - event.evt_type = BLE_SET_RANDOM_BD_ADDR_EVENT; - event.p.set_random_bd_addr_handled.new_bdaddr = param->addr.addr.addr; - app_ble_core_global_handle(&event, NULL); - - return KE_MSG_CONSUMED; + return KE_MSG_CONSUMED; } - /* * GLOBAL VARIABLES DEFINITION **************************************************************************************** */ /* Default State handlers definition. */ -KE_MSG_HANDLER_TAB(appm) -{ - // Note: first message is latest message checked by kernel so default is put on top. - {KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)appm_msg_handler}, +KE_MSG_HANDLER_TAB(appm){ + // Note: first message is latest message checked by kernel so default is put + // on top. + {KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)appm_msg_handler}, - {APP_ADV_TIMEOUT_TIMER, (ke_msg_func_t)app_adv_timeout_handler}, + {APP_ADV_TIMEOUT_TIMER, (ke_msg_func_t)app_adv_timeout_handler}, - {GAPM_DEVICE_READY_IND, (ke_msg_func_t)gapm_device_ready_ind_handler}, - {GAPM_CMP_EVT, (ke_msg_func_t)gapm_cmp_evt_handler}, - {GAPC_GET_DEV_INFO_REQ_IND, (ke_msg_func_t)gapc_get_dev_info_req_ind_handler}, - {GAPC_SET_DEV_INFO_REQ_IND, (ke_msg_func_t)gapc_set_dev_info_req_ind_handler}, - {GAPC_CONNECTION_REQ_IND, (ke_msg_func_t)gapc_connection_req_ind_handler}, - {GAPC_CMP_EVT, (ke_msg_func_t)gapc_cmp_evt_handler}, - {GAPC_DISCONNECT_IND, (ke_msg_func_t)gapc_disconnect_ind_handler}, - {GAPM_PROFILE_ADDED_IND, (ke_msg_func_t)gapm_profile_added_ind_handler}, - {GATTC_MTU_CHANGED_IND, (ke_msg_func_t)gattc_mtu_changed_ind_handler}, - {GAPC_PARAM_UPDATE_REQ_IND, (ke_msg_func_t)gapc_conn_param_update_req_ind_handler}, - {GAPC_PARAM_UPDATED_IND, (ke_msg_func_t)gapc_conn_param_updated_handler}, - {GAPM_ADV_REPORT_IND, (ke_msg_func_t)gapm_adv_report_ind_handler}, - {GAPC_PEER_FEATURES_IND, (ke_msg_func_t)gapc_peer_features_ind_handler}, - {GAPM_ADDR_SOLVED_IND, (ke_msg_func_t)gapm_addr_solved_ind_handler}, - {GAPM_DEV_BDADDR_IND, (ke_msg_func_t)gapm_dev_addr_ind_handler}, + {GAPM_DEVICE_READY_IND, (ke_msg_func_t)gapm_device_ready_ind_handler}, + {GAPM_CMP_EVT, (ke_msg_func_t)gapm_cmp_evt_handler}, + {GAPC_GET_DEV_INFO_REQ_IND, + (ke_msg_func_t)gapc_get_dev_info_req_ind_handler}, + {GAPC_SET_DEV_INFO_REQ_IND, + (ke_msg_func_t)gapc_set_dev_info_req_ind_handler}, + {GAPC_CONNECTION_REQ_IND, (ke_msg_func_t)gapc_connection_req_ind_handler}, + {GAPC_CMP_EVT, (ke_msg_func_t)gapc_cmp_evt_handler}, + {GAPC_DISCONNECT_IND, (ke_msg_func_t)gapc_disconnect_ind_handler}, + {GAPM_PROFILE_ADDED_IND, (ke_msg_func_t)gapm_profile_added_ind_handler}, + {GATTC_MTU_CHANGED_IND, (ke_msg_func_t)gattc_mtu_changed_ind_handler}, + {GAPC_PARAM_UPDATE_REQ_IND, + (ke_msg_func_t)gapc_conn_param_update_req_ind_handler}, + {GAPC_PARAM_UPDATED_IND, (ke_msg_func_t)gapc_conn_param_updated_handler}, + {GAPM_ADV_REPORT_IND, (ke_msg_func_t)gapm_adv_report_ind_handler}, + {GAPC_PEER_FEATURES_IND, (ke_msg_func_t)gapc_peer_features_ind_handler}, + {GAPM_ADDR_SOLVED_IND, (ke_msg_func_t)gapm_addr_solved_ind_handler}, + {GAPM_DEV_BDADDR_IND, (ke_msg_func_t)gapm_dev_addr_ind_handler}, }; - /* Defines the place holder for the states of all the task instances. */ ke_state_t appm_state[APP_IDX_MAX]; -const struct ke_task_desc TASK_DESC_APP = {appm_msg_handler_tab, appm_state, APP_IDX_MAX, ARRAY_LEN(appm_msg_handler_tab)}; +const struct ke_task_desc TASK_DESC_APP = {appm_msg_handler_tab, appm_state, + APP_IDX_MAX, + ARRAY_LEN(appm_msg_handler_tab)}; #endif //(BLE_APP_PRESENT) diff --git a/services/ble_app/app_ota/app_ota.c b/services/ble_app/app_ota/app_ota.c index ae1e092..0a267bc 100644 --- a/services/ble_app/app_ota/app_ota.c +++ b/services/ble_app/app_ota/app_ota.c @@ -14,7 +14,6 @@ * ****************************************************************************/ - /** **************************************************************************************** * @addtogroup APP @@ -22,7 +21,7 @@ **************************************************************************************** */ -#include "rwip_config.h" // SW configuration +#include "rwip_config.h" // SW configuration #if (BLE_APP_OTA) @@ -31,21 +30,21 @@ **************************************************************************************** */ -#include "app_ota.h" // OTA Application Definitions -#include "app.h" // Application Definitions -#include "app_task.h" // application task definitions -#include "ota_task.h" +#include "app.h" // Application Definitions +#include "app_ota.h" // OTA Application Definitions +#include "app_task.h" // application task definitions +#include "arch.h" // Platform Definitions #include "co_bt.h" +#include "ota_bes.h" +#include "ota_control.h" +#include "ota_task.h" +#include "prf.h" #include "prf_types.h" #include "prf_utils.h" -#include "arch.h" // Platform Definitions -#include "prf.h" #include "string.h" -#include "ota_control.h" -#include "ota_bes.h" -#include "app_ble_rx_handler.h" #include "app_ble_mode_switch.h" +#include "app_ble_rx_handler.h" #if defined(IBRT) #include "app_tws_ibrt.h" #endif @@ -62,225 +61,196 @@ static app_ota_tx_done_t ota_data_tx_done_callback = NULL; * GLOBAL FUNCTION DEFINITIONS **************************************************************************************** */ -void app_ota_connected_evt_handler(uint8_t conidx) -{ - app_ota_env.connectionIndex = conidx; - app_ota_connected(APP_OTA_CONNECTED); - ota_control_set_datapath_type(DATA_PATH_BLE); - ota_control_register_transmitter(app_ota_send_notification); - l2cap_update_param(conidx, 10, 15, 20000, 0); +void app_ota_connected_evt_handler(uint8_t conidx) { + app_ota_env.connectionIndex = conidx; + app_ota_connected(APP_OTA_CONNECTED); + ota_control_set_datapath_type(DATA_PATH_BLE); + ota_control_register_transmitter(app_ota_send_notification); + l2cap_update_param(conidx, 10, 15, 20000, 0); } -void app_ota_disconnected_evt_handler(uint8_t conidx) -{ - if (conidx == app_ota_env.connectionIndex) - { - app_ota_env.connectionIndex = BLE_INVALID_CONNECTION_INDEX; - app_ota_env.isNotificationEnabled = false; - app_ota_env.mtu[conidx] = 0; - app_ota_disconnected(APP_OTA_DISCONNECTED); - } +void app_ota_disconnected_evt_handler(uint8_t conidx) { + if (conidx == app_ota_env.connectionIndex) { + app_ota_env.connectionIndex = BLE_INVALID_CONNECTION_INDEX; + app_ota_env.isNotificationEnabled = false; + app_ota_env.mtu[conidx] = 0; + app_ota_disconnected(APP_OTA_DISCONNECTED); + } } -static void app_ota_ble_data_fill_handler(void *param) -{ - // normally we won't allow OTA owned adv when there is already - // an existing BLE connection. For special requirement, you can - // disable this limitation - if (app_ble_connection_count() > 0) - { - app_ble_data_fill_enable(USER_OTA, false); - return; - } +static void app_ota_ble_data_fill_handler(void *param) { + // normally we won't allow OTA owned adv when there is already + // an existing BLE connection. For special requirement, you can + // disable this limitation + if (app_ble_connection_count() > 0) { + app_ble_data_fill_enable(USER_OTA, false); + return; + } - bool adv_enable = false; + bool adv_enable = false; #if defined(IBRT) - if (app_tws_ibrt_get_bt_ctrl_ctx()->init_done) - { - if (app_tws_ibrt_role_get_callback(NULL) != IBRT_MASTER) - { - TRACE(2,"%s role %d isn't MASTER", __func__, app_tws_ibrt_role_get_callback(NULL)); - } - else if (!app_tws_ibrt_mobile_link_connected()) - { - TRACE(1,"%s don't connect mobile", __func__); - } - else - { - adv_enable = true; - } + if (app_tws_ibrt_get_bt_ctrl_ctx()->init_done) { + if (app_tws_ibrt_role_get_callback(NULL) != IBRT_MASTER) { + TRACE(2, "%s role %d isn't MASTER", __func__, + app_tws_ibrt_role_get_callback(NULL)); + } else if (!app_tws_ibrt_mobile_link_connected()) { + TRACE(1, "%s don't connect mobile", __func__); + } else { + adv_enable = true; } + } #else - adv_enable = true; + adv_enable = true; #endif - app_ble_data_fill_enable(USER_OTA, adv_enable); + app_ble_data_fill_enable(USER_OTA, adv_enable); } -void app_ota_init(void) -{ - // Reset the environment - app_ota_env.connectionIndex = BLE_INVALID_CONNECTION_INDEX; - app_ota_env.isNotificationEnabled = false; - memset((uint8_t *)&(app_ota_env.mtu), 0, sizeof(app_ota_env.mtu)); +void app_ota_init(void) { + // Reset the environment + app_ota_env.connectionIndex = BLE_INVALID_CONNECTION_INDEX; + app_ota_env.isNotificationEnabled = false; + memset((uint8_t *)&(app_ota_env.mtu), 0, sizeof(app_ota_env.mtu)); - app_ble_register_data_fill_handle(USER_OTA, - ( BLE_DATA_FILL_FUNC_T )app_ota_ble_data_fill_handler, false); + app_ble_register_data_fill_handle( + USER_OTA, (BLE_DATA_FILL_FUNC_T)app_ota_ble_data_fill_handler, false); } -void app_ota_add_ota(void) -{ - BLE_APP_DBG("app_ota_add_ota"); - struct gapm_profile_task_add_cmd *req = KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, - TASK_GAPM, TASK_APP, - gapm_profile_task_add_cmd, 0); - - // Fill message - req->operation = GAPM_PROFILE_TASK_ADD; -#if BLE_CONNECTION_MAX>1 - req->sec_lvl = PERM(SVC_AUTH, ENABLE)|PERM(SVC_MI, ENABLE); +void app_ota_add_ota(void) { + BLE_APP_DBG("app_ota_add_ota"); + struct gapm_profile_task_add_cmd *req = + KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, TASK_GAPM, TASK_APP, + gapm_profile_task_add_cmd, 0); + + // Fill message + req->operation = GAPM_PROFILE_TASK_ADD; +#if BLE_CONNECTION_MAX > 1 + req->sec_lvl = PERM(SVC_AUTH, ENABLE) | PERM(SVC_MI, ENABLE); #else - req->sec_lvl = PERM(SVC_AUTH, ENABLE); -#endif + req->sec_lvl = PERM(SVC_AUTH, ENABLE); +#endif - req->prf_task_id = TASK_ID_OTA; - req->app_task = TASK_APP; - req->start_hdl = 0; + req->prf_task_id = TASK_ID_OTA; + req->app_task = TASK_APP; + req->start_hdl = 0; - // Send the message - ke_msg_send(req); + // Send the message + ke_msg_send(req); } -void app_ota_send_notification(uint8_t* ptrData, uint32_t length) -{ - TRACE(0,"Send ota rsp:"); - DUMP8("%02x ", ptrData, length); - - struct ble_ota_send_data_req_t * req = KE_MSG_ALLOC_DYN(OTA_SEND_NOTIFICATION, - KE_BUILD_ID(prf_get_task_from_id(TASK_ID_OTA), app_ota_env.connectionIndex), - TASK_APP, - ble_ota_send_data_req_t, - length); - req->connecionIndex = app_ota_env.connectionIndex; - req->length = length; - memcpy(req->value, ptrData, length); +void app_ota_send_notification(uint8_t *ptrData, uint32_t length) { + TRACE(0, "Send ota rsp:"); + DUMP8("%02x ", ptrData, length); - ke_msg_send(req); + struct ble_ota_send_data_req_t *req = + KE_MSG_ALLOC_DYN(OTA_SEND_NOTIFICATION, + KE_BUILD_ID(prf_get_task_from_id(TASK_ID_OTA), + app_ota_env.connectionIndex), + TASK_APP, ble_ota_send_data_req_t, length); + req->connecionIndex = app_ota_env.connectionIndex; + req->length = length; + memcpy(req->value, ptrData, length); + + ke_msg_send(req); } -void app_ota_send_indication(uint8_t* ptrData, uint32_t length) -{ - struct ble_ota_send_data_req_t * req = KE_MSG_ALLOC_DYN(OTA_SEND_INDICATION, - KE_BUILD_ID(prf_get_task_from_id(TASK_ID_OTA), app_ota_env.connectionIndex), - TASK_APP, - ble_ota_send_data_req_t, - length); - req->connecionIndex = app_ota_env.connectionIndex; - req->length = length; - memcpy(req->value, ptrData, length); +void app_ota_send_indication(uint8_t *ptrData, uint32_t length) { + struct ble_ota_send_data_req_t *req = + KE_MSG_ALLOC_DYN(OTA_SEND_INDICATION, + KE_BUILD_ID(prf_get_task_from_id(TASK_ID_OTA), + app_ota_env.connectionIndex), + TASK_APP, ble_ota_send_data_req_t, length); + req->connecionIndex = app_ota_env.connectionIndex; + req->length = length; + memcpy(req->value, ptrData, length); - ke_msg_send(req); + ke_msg_send(req); } -static int app_ota_msg_handler(ke_msg_id_t const msgid, - void const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Do nothing - return (KE_MSG_CONSUMED); +static int app_ota_msg_handler(ke_msg_id_t const msgid, void const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Do nothing + return (KE_MSG_CONSUMED); } static int app_ota_ccc_changed_handler(ke_msg_id_t const msgid, - struct ble_ota_tx_notif_config_t *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - TRACE(1,"ota data ccc changed to %d", param->isNotificationEnabled); - app_ota_env.isNotificationEnabled = param->isNotificationEnabled; + struct ble_ota_tx_notif_config_t *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + TRACE(1, "ota data ccc changed to %d", param->isNotificationEnabled); + app_ota_env.isNotificationEnabled = param->isNotificationEnabled; - if (app_ota_env.isNotificationEnabled) - { - if (BLE_INVALID_CONNECTION_INDEX == app_ota_env.connectionIndex) - { - uint8_t conidx = KE_IDX_GET(src_id); - app_ota_connected_evt_handler(conidx); + if (app_ota_env.isNotificationEnabled) { + if (BLE_INVALID_CONNECTION_INDEX == app_ota_env.connectionIndex) { + uint8_t conidx = KE_IDX_GET(src_id); + app_ota_connected_evt_handler(conidx); - if (app_ota_env.mtu[conidx]) - { - ota_control_update_MTU(app_ota_env.mtu[conidx]); - } - } + if (app_ota_env.mtu[conidx]) { + ota_control_update_MTU(app_ota_env.mtu[conidx]); + } } - - return (KE_MSG_CONSUMED); + } + + return (KE_MSG_CONSUMED); } static int app_ota_tx_data_sent_handler(ke_msg_id_t const msgid, - struct ble_ota_tx_sent_ind_t *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if (NULL != ota_data_tx_done_callback) - { - ota_data_tx_done_callback(); - } + struct ble_ota_tx_sent_ind_t *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + if (NULL != ota_data_tx_done_callback) { + ota_data_tx_done_callback(); + } - //ota_data_transmission_done_callback(); + // ota_data_transmission_done_callback(); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } static int app_ota_data_received_handler(ke_msg_id_t const msgid, - struct ble_ota_rx_data_ind_t *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - app_ble_push_rx_data(BLE_RX_DATA_SELF_OTA, app_ota_env.connectionIndex, param->data, param->length); - return (KE_MSG_CONSUMED); + struct ble_ota_rx_data_ind_t *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + app_ble_push_rx_data(BLE_RX_DATA_SELF_OTA, app_ota_env.connectionIndex, + param->data, param->length); + return (KE_MSG_CONSUMED); } -void app_ota_register_tx_done(app_ota_tx_done_t callback) -{ - ota_data_tx_done_callback = callback; +void app_ota_register_tx_done(app_ota_tx_done_t callback) { + ota_data_tx_done_callback = callback; } -void app_ota_mtu_exchanged_handler(uint8_t conidx, uint16_t MTU) -{ - if (conidx == app_ota_env.connectionIndex) - { - ota_control_update_MTU(MTU); - } - else - { - app_ota_env.mtu[conidx] = MTU; - } +void app_ota_mtu_exchanged_handler(uint8_t conidx, uint16_t MTU) { + if (conidx == app_ota_env.connectionIndex) { + ota_control_update_MTU(MTU); + } else { + app_ota_env.mtu[conidx] = MTU; + } } -uint8_t app_ota_get_conidx(void) -{ - return app_ota_env.connectionIndex; -} +uint8_t app_ota_get_conidx(void) { return app_ota_env.connectionIndex; } /* * LOCAL VARIABLE DEFINITIONS **************************************************************************************** */ /// Default State handlers definition -const struct ke_msg_handler app_ota_msg_handler_list[] = -{ - // Note: first message is latest message checked by kernel so default is put on top. - {KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_ota_msg_handler}, +const struct ke_msg_handler app_ota_msg_handler_list[] = { + // Note: first message is latest message checked by kernel so default is put + // on top. + {KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_ota_msg_handler}, - {OTA_CCC_CHANGED, (ke_msg_func_t)app_ota_ccc_changed_handler}, - {OTA_TX_DATA_SENT, (ke_msg_func_t)app_ota_tx_data_sent_handler}, - {OTA_DATA_RECEIVED, (ke_msg_func_t)app_ota_data_received_handler}, + {OTA_CCC_CHANGED, (ke_msg_func_t)app_ota_ccc_changed_handler}, + {OTA_TX_DATA_SENT, (ke_msg_func_t)app_ota_tx_data_sent_handler}, + {OTA_DATA_RECEIVED, (ke_msg_func_t)app_ota_data_received_handler}, }; -const struct ke_state_handler app_ota_table_handler = - {&app_ota_msg_handler_list[0], (sizeof(app_ota_msg_handler_list)/sizeof(struct ke_msg_handler))}; +const struct ke_state_handler app_ota_table_handler = { + &app_ota_msg_handler_list[0], + (sizeof(app_ota_msg_handler_list) / sizeof(struct ke_msg_handler))}; -#endif //BLE_APP_OTA +#endif // BLE_APP_OTA /// @} APP diff --git a/services/ble_app/app_sec/app_sec.c b/services/ble_app/app_sec/app_sec.c index cf1cd49..ecc2f95 100644 --- a/services/ble_app/app_sec/app_sec.c +++ b/services/ble_app/app_sec/app_sec.c @@ -29,42 +29,42 @@ #if (BLE_APP_SEC) -#include #include "co_math.h" -#include "gapc_task.h" // GAP Controller Task API Definition -#include "gap.h" // GAP Definition -#include "gapc.h" // GAPC Definition +#include "gap.h" // GAP Definition +#include "gapc.h" // GAPC Definition +#include "gapc_task.h" // GAP Controller Task API Definition #include "prf_types.h" +#include -#include "app.h" // Application API Definition +#include "app.h" // Application API Definition #include "app_ble_include.h" -#include "app_sec.h" // Application Security API Definition -#include "app_task.h" // Application Manager API Definition +#include "app_sec.h" // Application Security API Definition +#include "app_task.h" // Application Manager API Definition #if (DISPLAY_SUPPORT) -#include "app_display.h" // Display Application Definitions -#endif //(DISPLAY_SUPPORT) +#include "app_display.h" // Display Application Definitions +#endif //(DISPLAY_SUPPORT) #if (NVDS_SUPPORT) -#include "nvds.h" // NVDS API Definitions -#endif //(NVDS_SUPPORT) +#include "nvds.h" // NVDS API Definitions +#endif //(NVDS_SUPPORT) #ifdef BLE_APP_AM0 #include "am0_app.h" #endif // BLE_APP_AM0 #if (BLE_APP_ANCC) -#include "app_ancc.h" // ANC Module Definition -#endif // (BLE_APP_ANCC) +#include "app_ancc.h" // ANC Module Definition +#endif // (BLE_APP_ANCC) #if (BLE_APP_AMS) -#include "app_amsc.h" // AMS Module Definition -#endif // (BLE_APP_AMS) +#include "app_amsc.h" // AMS Module Definition +#endif // (BLE_APP_AMS) #include "app_gfps.h" #include "nvrecord_ble.h" -#include "tgt_hardware.h" #include "nvrecord_extension.h" +#include "tgt_hardware.h" #ifdef _BLE_NVDS_ #define BLE_KEY_PRINT @@ -75,8 +75,6 @@ BleDeviceinfo ble_save_info; #include "app_tws_if.h" #endif - - /* * GLOBAL VARIABLE DEFINITIONS **************************************************************************************** @@ -90,40 +88,32 @@ struct app_sec_env_tag app_sec_env; **************************************************************************************** */ -void app_sec_init(void) -{ +void app_sec_init(void) { #ifdef _BLE_NVDS_ - if (nv_record_ble_record_Once_a_device_has_been_bonded()) - { - app_sec_env.bonded = true; - } - else - { - app_sec_env.bonded = false; - } + if (nv_record_ble_record_Once_a_device_has_been_bonded()) { + app_sec_env.bonded = true; + } else { + app_sec_env.bonded = false; + } - TRACE(2,"[%s] once bonded:%d", __func__, app_sec_env.bonded); + TRACE(2, "[%s] once bonded:%d", __func__, app_sec_env.bonded); #endif } -bool app_sec_get_bond_status(void) -{ - return app_sec_env.bonded; -} +bool app_sec_get_bond_status(void) { return app_sec_env.bonded; } -void app_sec_send_security_req(uint8_t conidx, enum gap_auth authority) -{ - // Send security request - struct gapc_security_cmd *cmd = KE_MSG_ALLOC(GAPC_SECURITY_CMD, - KE_BUILD_ID(TASK_GAPC, conidx), TASK_APP, - gapc_security_cmd); +void app_sec_send_security_req(uint8_t conidx, enum gap_auth authority) { + // Send security request + struct gapc_security_cmd *cmd = + KE_MSG_ALLOC(GAPC_SECURITY_CMD, KE_BUILD_ID(TASK_GAPC, conidx), TASK_APP, + gapc_security_cmd); - cmd->operation = GAPC_SECURITY_REQ; + cmd->operation = GAPC_SECURITY_REQ; - cmd->auth = authority; + cmd->auth = authority; - // Send the message - ke_msg_send(cmd); + // Send the message + ke_msg_send(cmd); } /* @@ -134,314 +124,290 @@ void app_sec_send_security_req(uint8_t conidx, enum gap_auth authority) static int gapc_bond_req_ind_handler(ke_msg_id_t const msgid, struct gapc_bond_req_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - TRACE(1,"Get bond req %d", param->request); + ke_task_id_t const src_id) { + TRACE(1, "Get bond req %d", param->request); - // Prepare the GAPC_BOND_CFM message - struct gapc_bond_cfm *cfm = KE_MSG_ALLOC(GAPC_BOND_CFM, - src_id, TASK_APP, - gapc_bond_cfm); + // Prepare the GAPC_BOND_CFM message + struct gapc_bond_cfm *cfm = + KE_MSG_ALLOC(GAPC_BOND_CFM, src_id, TASK_APP, gapc_bond_cfm); - switch (param->request) - { - case (GAPC_PAIRING_REQ): - { - cfm->request = GAPC_PAIRING_RSP; + switch (param->request) { + case (GAPC_PAIRING_REQ): { + cfm->request = GAPC_PAIRING_RSP; - cfm->accept = true; + cfm->accept = true; - cfm->data.pairing_feat.auth = BLE_AUTHENTICATION_LEVEL; + cfm->data.pairing_feat.auth = BLE_AUTHENTICATION_LEVEL; - #if (BLE_APP_GFPS) - cfm->data.pairing_feat.iocap = GAP_IO_CAP_DISPLAY_YES_NO; - #else - cfm->data.pairing_feat.iocap = GAP_IO_CAP_NO_INPUT_NO_OUTPUT; - #endif +#if (BLE_APP_GFPS) + cfm->data.pairing_feat.iocap = GAP_IO_CAP_DISPLAY_YES_NO; +#else + cfm->data.pairing_feat.iocap = GAP_IO_CAP_NO_INPUT_NO_OUTPUT; +#endif - cfm->data.pairing_feat.key_size = 16; - cfm->data.pairing_feat.oob = GAP_OOB_AUTH_DATA_NOT_PRESENT; - #if (BLE_APP_GFPS) - cfm->data.pairing_feat.sec_req = GAP_SEC1_SEC_CON_PAIR_ENC; - #else - cfm->data.pairing_feat.sec_req = GAP_SEC1_NOAUTH_PAIR_ENC; - #endif + cfm->data.pairing_feat.key_size = 16; + cfm->data.pairing_feat.oob = GAP_OOB_AUTH_DATA_NOT_PRESENT; +#if (BLE_APP_GFPS) + cfm->data.pairing_feat.sec_req = GAP_SEC1_SEC_CON_PAIR_ENC; +#else + cfm->data.pairing_feat.sec_req = GAP_SEC1_NOAUTH_PAIR_ENC; +#endif - cfm->data.pairing_feat.ikey_dist = GAP_KDIST_ENCKEY | GAP_KDIST_IDKEY | GAP_KDIST_LINKKEY; - cfm->data.pairing_feat.rkey_dist = GAP_KDIST_ENCKEY | GAP_KDIST_IDKEY | GAP_KDIST_LINKKEY; - } break; + cfm->data.pairing_feat.ikey_dist = + GAP_KDIST_ENCKEY | GAP_KDIST_IDKEY | GAP_KDIST_LINKKEY; + cfm->data.pairing_feat.rkey_dist = + GAP_KDIST_ENCKEY | GAP_KDIST_IDKEY | GAP_KDIST_LINKKEY; + } break; - case (GAPC_LTK_EXCH): - { - // Counter - uint8_t counter; + case (GAPC_LTK_EXCH): { + // Counter + uint8_t counter; - cfm->accept = true; - cfm->request = GAPC_LTK_EXCH; + cfm->accept = true; + cfm->request = GAPC_LTK_EXCH; - // Generate all the values - cfm->data.ltk.ediv = (uint16_t)co_rand_word(); + // Generate all the values + cfm->data.ltk.ediv = (uint16_t)co_rand_word(); - for (counter = 0; counter < RAND_NB_LEN; counter++) - { - cfm->data.ltk.randnb.nb[counter] = (uint8_t)co_rand_word(); - } + for (counter = 0; counter < RAND_NB_LEN; counter++) { + cfm->data.ltk.randnb.nb[counter] = (uint8_t)co_rand_word(); + } - for (counter = 0; counter < GAP_KEY_LEN; counter++) - { - cfm->data.ltk.ltk.key[counter] = (uint8_t)co_rand_word(); - } + for (counter = 0; counter < GAP_KEY_LEN; counter++) { + cfm->data.ltk.ltk.key[counter] = (uint8_t)co_rand_word(); + } #ifdef _BLE_NVDS_ #ifdef BLE_KEY_PRINT - TRACE(0,"<==============>LTK IS:"); - DUMP8("%02x ",(uint8_t *)&cfm->data.ltk,16); - TRACE(1,"<==============>EDIV IS: %04x:",cfm->data.ltk.ediv); - TRACE(0,"<==============>RANDOM IS:"); - DUMP8("%02x ",(uint8_t *)&cfm->data.ltk.randnb.nb,8); + TRACE(0, "<==============>LTK IS:"); + DUMP8("%02x ", (uint8_t *)&cfm->data.ltk, 16); + TRACE(1, "<==============>EDIV IS: %04x:", cfm->data.ltk.ediv); + TRACE(0, "<==============>RANDOM IS:"); + DUMP8("%02x ", (uint8_t *)&cfm->data.ltk.randnb.nb, 8); #endif - ble_save_info.EDIV = cfm->data.ltk.ediv; - memcpy(&ble_save_info.RANDOM, (uint8_t *)&cfm->data.ltk.randnb.nb, 8); - memcpy(&ble_save_info.LTK, (uint8_t *)&cfm->data.ltk, 16); + ble_save_info.EDIV = cfm->data.ltk.ediv; + memcpy(&ble_save_info.RANDOM, (uint8_t *)&cfm->data.ltk.randnb.nb, 8); + memcpy(&ble_save_info.LTK, (uint8_t *)&cfm->data.ltk, 16); - ble_save_info.bonded = false; + ble_save_info.bonded = false; #endif - } break; + } break; - case (GAPC_IRK_EXCH): - { - cfm->accept = true; - cfm->request = GAPC_IRK_EXCH; + case (GAPC_IRK_EXCH): { + cfm->accept = true; + cfm->request = GAPC_IRK_EXCH; - // Load IRK - memcpy(cfm->data.irk.irk.key, app_env.loc_irk, KEY_LEN); - // load identity ble address - memcpy(cfm->data.irk.addr.addr.addr, ble_addr, BLE_ADDR_SIZE); - cfm->data.irk.addr.addr_type = ADDR_PUBLIC; - } break; - case (GAPC_TK_EXCH): - { - // Generate a PIN Code- (Between 100000 and 999999) - uint32_t pin_code = (100000 + (co_rand_word()%900000)); + // Load IRK + memcpy(cfm->data.irk.irk.key, app_env.loc_irk, KEY_LEN); + // load identity ble address + memcpy(cfm->data.irk.addr.addr.addr, ble_addr, BLE_ADDR_SIZE); + cfm->data.irk.addr.addr_type = ADDR_PUBLIC; + } break; + case (GAPC_TK_EXCH): { + // Generate a PIN Code- (Between 100000 and 999999) + uint32_t pin_code = (100000 + (co_rand_word() % 900000)); - cfm->accept = true; - cfm->request = GAPC_TK_EXCH; + cfm->accept = true; + cfm->request = GAPC_TK_EXCH; - // Set the TK value - memset(cfm->data.tk.key, 0, KEY_LEN); + // Set the TK value + memset(cfm->data.tk.key, 0, KEY_LEN); - cfm->data.tk.key[0] = (uint8_t)((pin_code & 0x000000FF) >> 0); - cfm->data.tk.key[1] = (uint8_t)((pin_code & 0x0000FF00) >> 8); - cfm->data.tk.key[2] = (uint8_t)((pin_code & 0x00FF0000) >> 16); - cfm->data.tk.key[3] = (uint8_t)((pin_code & 0xFF000000) >> 24); - } break; - case GAPC_NC_EXCH: - cfm->accept = true; - cfm->request = GAPC_NC_EXCH; - break; - default: - { - ASSERT_ERR(0); - } break; - } + cfm->data.tk.key[0] = (uint8_t)((pin_code & 0x000000FF) >> 0); + cfm->data.tk.key[1] = (uint8_t)((pin_code & 0x0000FF00) >> 8); + cfm->data.tk.key[2] = (uint8_t)((pin_code & 0x00FF0000) >> 16); + cfm->data.tk.key[3] = (uint8_t)((pin_code & 0xFF000000) >> 24); + } break; + case GAPC_NC_EXCH: + cfm->accept = true; + cfm->request = GAPC_NC_EXCH; + break; + default: { + ASSERT_ERR(0); + } break; + } - // Send the message - ke_msg_send(cfm); + // Send the message + ke_msg_send(cfm); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } -void app_sec_reset_env_on_connection(void) -{ +void app_sec_reset_env_on_connection(void) { #ifdef _BLE_NVDS_ - memset(&ble_save_info, 0, sizeof(BleDeviceinfo)); + memset(&ble_save_info, 0, sizeof(BleDeviceinfo)); #endif } static int gapc_bond_ind_handler(ke_msg_id_t const msgid, struct gapc_bond_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t conidx = KE_IDX_GET(src_id); - switch (param->info) - { - case (GAPC_PAIRING_SUCCEED): - { - TRACE(0,"GAPC_PAIRING_SUCCEED"); - // Update the bonding status in the environment - app_sec_env.bonded = true; + ke_task_id_t const src_id) { + uint8_t conidx = KE_IDX_GET(src_id); + switch (param->info) { + case (GAPC_PAIRING_SUCCEED): { + TRACE(0, "GAPC_PAIRING_SUCCEED"); + // Update the bonding status in the environment + app_sec_env.bonded = true; #ifdef _BLE_NVDS_ - ble_save_info.bonded = true; + ble_save_info.bonded = true; - if (!nv_record_blerec_add(&ble_save_info)) - { + if (!nv_record_blerec_add(&ble_save_info)) { #ifdef TWS_SYSTEM_ENABLED - app_ble_sync_ble_info(); - TRACE(0,"BLE NVDS SETUP SUCCESS!!!,the key is the newest"); + app_ble_sync_ble_info(); + TRACE(0, "BLE NVDS SETUP SUCCESS!!!,the key is the newest"); #endif - } -#endif - break; - } - case (GAPC_REPEATED_ATTEMPT): - { - appm_disconnect(conidx); - break; - } - case (GAPC_IRK_EXCH): - { - TRACE(0,"Peer device IRK is:"); -#ifdef _BLE_NVDS_ - DUMP8("%02x ", param->data.irk.irk.key, BLE_IRK_SIZE); - DUMP8("%02x ", (uint8_t *)&(param->data.irk.addr), BLE_ADDR_SIZE+1); - app_env.context[conidx].isBdAddrResolvingInProgress = false; - app_env.context[conidx].isGotSolvedBdAddr = true; - memcpy(app_env.context[conidx].solvedBdAddr, param->data.irk.addr.addr.addr, BLE_ADDR_SIZE); - memcpy(ble_save_info.IRK, param->data.irk.irk.key, BLE_IRK_SIZE); - memcpy(ble_save_info.peer_bleAddr, param->data.irk.addr.addr.addr, BLE_ADDR_SIZE); -#endif - app_exchange_remote_feature(conidx); - break; - } - case (GAPC_PAIRING_FAILED): - { - TRACE(1,"GAPC_PAIRING_FAILED!!! Error code 0x%x", param->data.reason); -#ifdef _BLE_NVDS_ - nv_record_ble_delete_entry(app_env.context[conidx].solvedBdAddr); - app_sec_env.bonded = false; -#endif - break; - } - case GAPC_LTK_EXCH: - { -#ifdef _BLE_NVDS_ - TRACE(1,"isLocal %d", param->data.ltk.isLocal); - TRACE(0,"Peer device LTK is:"); - - DUMP8("%02x ", param->data.ltk.ltk.key, BLE_LTK_SIZE); - TRACE(1,"EDIV %04x ", param->data.ltk.ediv); - TRACE(0,"Peer device random number is:"); - DUMP8("%02x ", param->data.ltk.randnb.nb, BLE_ENC_RANDOM_SIZE); - - - if (param->data.ltk.isLocal) - { - ble_save_info.EDIV = param->data.ltk.ediv; - memcpy(&ble_save_info.RANDOM, (uint8_t *)¶m->data.ltk.randnb.nb, BLE_ENC_RANDOM_SIZE); - memcpy(&ble_save_info.LTK, (uint8_t *)¶m->data.ltk, BLE_LTK_SIZE); - } -#endif - break; - } - default: - { - ASSERT_ERR(0); - break; - } - } - - return (KE_MSG_CONSUMED); -} - -static int gapc_encrypt_req_ind_handler(ke_msg_id_t const msgid, - struct gapc_encrypt_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - TRACE(1,"%s, master ask for LTK TO encrypt!!!!", __FUNCTION__); - - uint8_t conidx = KE_IDX_GET(src_id); - - appm_check_and_resolve_ble_address(conidx); - - if (!app_env.context[conidx].isGotSolvedBdAddr) - { - return (KE_MSG_SAVED); - } - - TRACE(0,"Random ble address solved. Can rsp enc req."); - - // Prepare the GAPC_ENCRYPT_CFM message - struct gapc_encrypt_cfm *cfm = KE_MSG_ALLOC(GAPC_ENCRYPT_CFM, - src_id, TASK_APP, - gapc_encrypt_cfm); - - cfm->found = false; - -#ifdef _BLE_NVDS_ - - struct gapc_ltk ltk; - - bool ret; - ret = nv_record_ble_record_find_ltk_through_static_bd_addr( - app_env.context[conidx].solvedBdAddr, ltk.ltk.key); - if(ret){ - TRACE(0,"FIND LTK SUCCESSED!!!"); -#ifdef BLE_KEY_PRINT - DUMP8("%02x ", (uint8_t *)ltk.ltk.key, 16); -#endif - cfm->found = true; - cfm->key_size = 16; - memcpy(&cfm->ltk, ltk.ltk.key, sizeof(struct gap_sec_key)); - - }else{ - TRACE(0,"FIND LTK failed!!!"); } #endif - - TRACE(2,"%s app_sec_env.bonded %d", __FUNCTION__, app_sec_env.bonded); - - // Send the message - ke_msg_send(cfm); - - // encryption has been completed, we can start exchanging remote features now + break; + } + case (GAPC_REPEATED_ATTEMPT): { + appm_disconnect(conidx); + break; + } + case (GAPC_IRK_EXCH): { + TRACE(0, "Peer device IRK is:"); +#ifdef _BLE_NVDS_ + DUMP8("%02x ", param->data.irk.irk.key, BLE_IRK_SIZE); + DUMP8("%02x ", (uint8_t *)&(param->data.irk.addr), BLE_ADDR_SIZE + 1); + app_env.context[conidx].isBdAddrResolvingInProgress = false; + app_env.context[conidx].isGotSolvedBdAddr = true; + memcpy(app_env.context[conidx].solvedBdAddr, param->data.irk.addr.addr.addr, + BLE_ADDR_SIZE); + memcpy(ble_save_info.IRK, param->data.irk.irk.key, BLE_IRK_SIZE); + memcpy(ble_save_info.peer_bleAddr, param->data.irk.addr.addr.addr, + BLE_ADDR_SIZE); +#endif app_exchange_remote_feature(conidx); + break; + } + case (GAPC_PAIRING_FAILED): { + TRACE(1, "GAPC_PAIRING_FAILED!!! Error code 0x%x", param->data.reason); +#ifdef _BLE_NVDS_ + nv_record_ble_delete_entry(app_env.context[conidx].solvedBdAddr); + app_sec_env.bonded = false; +#endif + break; + } + case GAPC_LTK_EXCH: { +#ifdef _BLE_NVDS_ + TRACE(1, "isLocal %d", param->data.ltk.isLocal); + TRACE(0, "Peer device LTK is:"); - return (KE_MSG_CONSUMED); + DUMP8("%02x ", param->data.ltk.ltk.key, BLE_LTK_SIZE); + TRACE(1, "EDIV %04x ", param->data.ltk.ediv); + TRACE(0, "Peer device random number is:"); + DUMP8("%02x ", param->data.ltk.randnb.nb, BLE_ENC_RANDOM_SIZE); + + if (param->data.ltk.isLocal) { + ble_save_info.EDIV = param->data.ltk.ediv; + memcpy(&ble_save_info.RANDOM, (uint8_t *)¶m->data.ltk.randnb.nb, + BLE_ENC_RANDOM_SIZE); + memcpy(&ble_save_info.LTK, (uint8_t *)¶m->data.ltk, BLE_LTK_SIZE); + } +#endif + break; + } + default: { + ASSERT_ERR(0); + break; + } + } + + return (KE_MSG_CONSUMED); } +static int gapc_encrypt_req_ind_handler( + ke_msg_id_t const msgid, struct gapc_encrypt_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + TRACE(1, "%s, master ask for LTK TO encrypt!!!!", __FUNCTION__); + + uint8_t conidx = KE_IDX_GET(src_id); + + appm_check_and_resolve_ble_address(conidx); + + if (!app_env.context[conidx].isGotSolvedBdAddr) { + return (KE_MSG_SAVED); + } + + TRACE(0, "Random ble address solved. Can rsp enc req."); + + // Prepare the GAPC_ENCRYPT_CFM message + struct gapc_encrypt_cfm *cfm = + KE_MSG_ALLOC(GAPC_ENCRYPT_CFM, src_id, TASK_APP, gapc_encrypt_cfm); + + cfm->found = false; + +#ifdef _BLE_NVDS_ + + struct gapc_ltk ltk; + + bool ret; + ret = nv_record_ble_record_find_ltk_through_static_bd_addr( + app_env.context[conidx].solvedBdAddr, ltk.ltk.key); + if (ret) { + TRACE(0, "FIND LTK SUCCESSED!!!"); +#ifdef BLE_KEY_PRINT + DUMP8("%02x ", (uint8_t *)ltk.ltk.key, 16); +#endif + cfm->found = true; + cfm->key_size = 16; + memcpy(&cfm->ltk, ltk.ltk.key, sizeof(struct gap_sec_key)); + + } else { + TRACE(0, "FIND LTK failed!!!"); + } +#endif + + TRACE(2, "%s app_sec_env.bonded %d", __FUNCTION__, app_sec_env.bonded); + + // Send the message + ke_msg_send(cfm); + + // encryption has been completed, we can start exchanging remote features now + app_exchange_remote_feature(conidx); + + return (KE_MSG_CONSUMED); +} static int gapc_encrypt_ind_handler(ke_msg_id_t const msgid, struct gapc_encrypt_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - TRACE(2,"%s param->auth %d", __FUNCTION__, param->auth); + ke_task_id_t const src_id) { + TRACE(2, "%s param->auth %d", __FUNCTION__, param->auth); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } -static int app_sec_msg_dflt_handler(ke_msg_id_t const msgid, - void *param, +static int app_sec_msg_dflt_handler(ke_msg_id_t const msgid, void *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Drop the message + ke_task_id_t const src_id) { + // Drop the message - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } - /* - * LOCAL VARIABLE DEFINITIONS - **************************************************************************************** - */ +/* + * LOCAL VARIABLE DEFINITIONS + **************************************************************************************** + */ /// Default State handlers definition -const struct ke_msg_handler app_sec_msg_handler_list[] = -{ - // Note: first message is latest message checked by kernel so default is put on top. - {KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_sec_msg_dflt_handler}, +const struct ke_msg_handler app_sec_msg_handler_list[] = { + // Note: first message is latest message checked by kernel so default is put + // on top. + {KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_sec_msg_dflt_handler}, - {GAPC_BOND_REQ_IND, (ke_msg_func_t)gapc_bond_req_ind_handler}, - {GAPC_BOND_IND, (ke_msg_func_t)gapc_bond_ind_handler}, + {GAPC_BOND_REQ_IND, (ke_msg_func_t)gapc_bond_req_ind_handler}, + {GAPC_BOND_IND, (ke_msg_func_t)gapc_bond_ind_handler}, - {GAPC_ENCRYPT_REQ_IND, (ke_msg_func_t)gapc_encrypt_req_ind_handler}, - {GAPC_ENCRYPT_IND, (ke_msg_func_t)gapc_encrypt_ind_handler}, + {GAPC_ENCRYPT_REQ_IND, (ke_msg_func_t)gapc_encrypt_req_ind_handler}, + {GAPC_ENCRYPT_IND, (ke_msg_func_t)gapc_encrypt_ind_handler}, }; -const struct ke_state_handler app_sec_table_handler = - {&app_sec_msg_handler_list[0], (sizeof(app_sec_msg_handler_list)/sizeof(struct ke_msg_handler))}; +const struct ke_state_handler app_sec_table_handler = { + &app_sec_msg_handler_list[0], + (sizeof(app_sec_msg_handler_list) / sizeof(struct ke_msg_handler))}; #endif //(BLE_APP_SEC) diff --git a/services/ble_app/app_tota/app_tota_ble.c b/services/ble_app/app_tota/app_tota_ble.c index 69a4f02..8d3f691 100644 --- a/services/ble_app/app_tota/app_tota_ble.c +++ b/services/ble_app/app_tota/app_tota_ble.c @@ -14,7 +14,6 @@ * ****************************************************************************/ - /** **************************************************************************************** * @addtogroup APP @@ -22,7 +21,7 @@ **************************************************************************************** */ -#include "rwip_config.h" // SW configuration +#include "rwip_config.h" // SW configuration #if (BLE_APP_TOTA) @@ -31,21 +30,20 @@ **************************************************************************************** */ -#include "string.h" -#include "arch.h" // Platform Definitions +#include "app.h" // Application Definitions +#include "app_ble_rx_handler.h" +#include "app_task.h" // application task definitions +#include "app_tota.h" +#include "app_tota_ble.h" // TOTA Application Definitions +#include "app_tota_cmd_handler.h" +#include "app_tota_data_handler.h" +#include "arch.h" // Platform Definitions #include "co_bt.h" #include "prf.h" #include "prf_types.h" #include "prf_utils.h" -#include "app.h" // Application Definitions -#include "app_task.h" // application task definitions -#include "app_ble_rx_handler.h" -#include "tota_task.h" -#include "app_tota_ble.h" // TOTA Application Definitions -#include "app_tota_data_handler.h" -#include "app_tota_cmd_handler.h" -#include "app_tota.h" - +#include "string.h" +#include "tota_task.h" /* * GLOBAL VARIABLE DEFINITIONS @@ -60,174 +58,151 @@ static app_tota_tx_done_t tota_data_tx_done_callback = NULL; * GLOBAL FUNCTION DEFINITIONS **************************************************************************************** */ -void app_tota_connected_evt_handler(uint8_t conidx) -{ - TOTA_LOG_DBG(1,"[%s]TOTA",__func__); - app_tota_env.connectionIndex = conidx; - app_tota_update_datapath(APP_TOTA_VIA_NOTIFICATION); - //tota_register_transmitter(app_tota_send_notification); +void app_tota_connected_evt_handler(uint8_t conidx) { + TOTA_LOG_DBG(1, "[%s]TOTA", __func__); + app_tota_env.connectionIndex = conidx; + app_tota_update_datapath(APP_TOTA_VIA_NOTIFICATION); + // tota_register_transmitter(app_tota_send_notification); } -void app_tota_disconnected_evt_handler(uint8_t conidx) -{ - TOTA_LOG_DBG(3,"[%s], condix = %d Index = %d",__func__, conidx, app_tota_env.connectionIndex); - if (conidx == app_tota_env.connectionIndex) - { - app_tota_env.connectionIndex = BLE_INVALID_CONNECTION_INDEX; - app_tota_env.isNotificationEnabled = false; - app_tota_env.mtu[conidx] = 0; - app_tota_update_datapath(APP_TOTA_PATH_IDLE); - //tota_disconnection_handler(); - } +void app_tota_disconnected_evt_handler(uint8_t conidx) { + TOTA_LOG_DBG(3, "[%s], condix = %d Index = %d", __func__, conidx, + app_tota_env.connectionIndex); + if (conidx == app_tota_env.connectionIndex) { + app_tota_env.connectionIndex = BLE_INVALID_CONNECTION_INDEX; + app_tota_env.isNotificationEnabled = false; + app_tota_env.mtu[conidx] = 0; + app_tota_update_datapath(APP_TOTA_PATH_IDLE); + // tota_disconnection_handler(); + } } -void app_tota_ble_init(void) -{ - app_tota_env.connectionIndex = BLE_INVALID_CONNECTION_INDEX; - app_tota_env.isNotificationEnabled = false; - memset((uint8_t *)&(app_tota_env.mtu), 0, sizeof(app_tota_env.mtu)); +void app_tota_ble_init(void) { + app_tota_env.connectionIndex = BLE_INVALID_CONNECTION_INDEX; + app_tota_env.isNotificationEnabled = false; + memset((uint8_t *)&(app_tota_env.mtu), 0, sizeof(app_tota_env.mtu)); } -void app_tota_add_tota(void) -{ - struct gapm_profile_task_add_cmd *req = KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, - TASK_GAPM, TASK_APP, - gapm_profile_task_add_cmd, 0); - - // Fill message - req->operation = GAPM_PROFILE_TASK_ADD; -#if BLE_CONNECTION_MAX>1 - req->sec_lvl = PERM(SVC_AUTH, ENABLE)|PERM(SVC_MI, ENABLE); +void app_tota_add_tota(void) { + struct gapm_profile_task_add_cmd *req = + KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, TASK_GAPM, TASK_APP, + gapm_profile_task_add_cmd, 0); + + // Fill message + req->operation = GAPM_PROFILE_TASK_ADD; +#if BLE_CONNECTION_MAX > 1 + req->sec_lvl = PERM(SVC_AUTH, ENABLE) | PERM(SVC_MI, ENABLE); #else - req->sec_lvl = PERM(SVC_AUTH, ENABLE); -#endif + req->sec_lvl = PERM(SVC_AUTH, ENABLE); +#endif - req->prf_task_id = TASK_ID_TOTA; - req->app_task = TASK_APP; - req->start_hdl = 0; + req->prf_task_id = TASK_ID_TOTA; + req->app_task = TASK_APP; + req->start_hdl = 0; - // Send the message - ke_msg_send(req); + // Send the message + ke_msg_send(req); } -void app_tota_send_notification(uint8_t* ptrData, uint32_t length) -{ - TOTA_LOG_DBG(1,"[%s]TOTA",__func__); - - struct ble_tota_send_data_req_t * req = KE_MSG_ALLOC_DYN(TOTA_SEND_NOTIFICATION, - KE_BUILD_ID(prf_get_task_from_id(TASK_ID_TOTA), app_tota_env.connectionIndex), - TASK_APP, - ble_tota_send_data_req_t, - length); - req->connecionIndex = app_tota_env.connectionIndex; - req->length = length; - memcpy(req->value, ptrData, length); +void app_tota_send_notification(uint8_t *ptrData, uint32_t length) { + TOTA_LOG_DBG(1, "[%s]TOTA", __func__); - ke_msg_send(req); + struct ble_tota_send_data_req_t *req = + KE_MSG_ALLOC_DYN(TOTA_SEND_NOTIFICATION, + KE_BUILD_ID(prf_get_task_from_id(TASK_ID_TOTA), + app_tota_env.connectionIndex), + TASK_APP, ble_tota_send_data_req_t, length); + req->connecionIndex = app_tota_env.connectionIndex; + req->length = length; + memcpy(req->value, ptrData, length); + + ke_msg_send(req); } -void app_tota_send_indication(uint8_t* ptrData, uint32_t length) -{ - TOTA_LOG_DBG(1,"[%s]TOTA",__func__); - struct ble_tota_send_data_req_t * req = KE_MSG_ALLOC_DYN(TOTA_SEND_INDICATION, - KE_BUILD_ID(prf_get_task_from_id(TASK_ID_TOTA), app_tota_env.connectionIndex), - TASK_APP, - ble_tota_send_data_req_t, - length); - req->connecionIndex = app_tota_env.connectionIndex; - req->length = length; - memcpy(req->value, ptrData, length); +void app_tota_send_indication(uint8_t *ptrData, uint32_t length) { + TOTA_LOG_DBG(1, "[%s]TOTA", __func__); + struct ble_tota_send_data_req_t *req = + KE_MSG_ALLOC_DYN(TOTA_SEND_INDICATION, + KE_BUILD_ID(prf_get_task_from_id(TASK_ID_TOTA), + app_tota_env.connectionIndex), + TASK_APP, ble_tota_send_data_req_t, length); + req->connecionIndex = app_tota_env.connectionIndex; + req->length = length; + memcpy(req->value, ptrData, length); - ke_msg_send(req); + ke_msg_send(req); } -static int app_tota_msg_handler(ke_msg_id_t const msgid, - void const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Do nothing - TOTA_LOG_DBG(1,"[%s]TOTA",__func__); - return (KE_MSG_CONSUMED); +static int app_tota_msg_handler(ke_msg_id_t const msgid, void const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Do nothing + TOTA_LOG_DBG(1, "[%s]TOTA", __func__); + return (KE_MSG_CONSUMED); } -void tota_update_MTU(uint16_t mtu) -{ - // remove the 3 bytes of overhead - app_tota_env.mtu[app_tota_env.connectionIndex] = mtu; - TRACE(1,"updated data packet size is %d", app_tota_env.mtu[app_tota_env.connectionIndex]); +void tota_update_MTU(uint16_t mtu) { + // remove the 3 bytes of overhead + app_tota_env.mtu[app_tota_env.connectionIndex] = mtu; + TRACE(1, "updated data packet size is %d", + app_tota_env.mtu[app_tota_env.connectionIndex]); } -static int app_tota_ccc_changed_handler(ke_msg_id_t const msgid, - struct ble_tota_tx_notif_config_t *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - TOTA_LOG_DBG(1,"tota data ccc changed to %d", param->isNotificationEnabled); - app_tota_env.isNotificationEnabled = param->isNotificationEnabled; +static int app_tota_ccc_changed_handler( + ke_msg_id_t const msgid, struct ble_tota_tx_notif_config_t *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + TOTA_LOG_DBG(1, "tota data ccc changed to %d", param->isNotificationEnabled); + app_tota_env.isNotificationEnabled = param->isNotificationEnabled; - if (app_tota_env.isNotificationEnabled) - { - if (BLE_INVALID_CONNECTION_INDEX == app_tota_env.connectionIndex) - { - uint8_t conidx = KE_IDX_GET(src_id); - app_tota_connected_evt_handler(conidx); + if (app_tota_env.isNotificationEnabled) { + if (BLE_INVALID_CONNECTION_INDEX == app_tota_env.connectionIndex) { + uint8_t conidx = KE_IDX_GET(src_id); + app_tota_connected_evt_handler(conidx); - if (app_tota_env.mtu[conidx]) - { - // tota_update_MTU(app_tota_env.mtu[conidx]); - } - } - } - else - { - app_tota_update_datapath(APP_TOTA_VIA_INDICATION); + if (app_tota_env.mtu[conidx]) { + // tota_update_MTU(app_tota_env.mtu[conidx]); + } } - - - return (KE_MSG_CONSUMED); + } else { + app_tota_update_datapath(APP_TOTA_VIA_INDICATION); + } + + return (KE_MSG_CONSUMED); } static int app_tota_tx_data_sent_handler(ke_msg_id_t const msgid, - struct ble_tota_tx_sent_ind_t *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if (NULL != tota_data_tx_done_callback) - { - tota_data_tx_done_callback(); - } + struct ble_tota_tx_sent_ind_t *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + if (NULL != tota_data_tx_done_callback) { + tota_data_tx_done_callback(); + } - //tota_data_transmission_done_callback(); + // tota_data_transmission_done_callback(); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } static int app_tota_data_received_handler(ke_msg_id_t const msgid, - struct ble_tota_rx_data_ind_t *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - app_ble_push_rx_data(BLE_RX_DATA_SELF_TOTA, app_tota_env.connectionIndex, param->data, param->length); - return (KE_MSG_CONSUMED); + struct ble_tota_rx_data_ind_t *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + app_ble_push_rx_data(BLE_RX_DATA_SELF_TOTA, app_tota_env.connectionIndex, + param->data, param->length); + return (KE_MSG_CONSUMED); } -void app_tota_register_tx_done(app_tota_tx_done_t callback) -{ - tota_data_tx_done_callback = callback; +void app_tota_register_tx_done(app_tota_tx_done_t callback) { + tota_data_tx_done_callback = callback; } -void app_tota_mtu_exchanged_handler(uint8_t conidx, uint16_t MTU) -{ - TOTA_LOG_DBG(1,"[%s]TOTA",__func__); - if (conidx == app_tota_env.connectionIndex) - { - tota_update_MTU(MTU); - } - else - { - app_tota_env.mtu[conidx] = MTU; - } +void app_tota_mtu_exchanged_handler(uint8_t conidx, uint16_t MTU) { + TOTA_LOG_DBG(1, "[%s]TOTA", __func__); + if (conidx == app_tota_env.connectionIndex) { + tota_update_MTU(MTU); + } else { + app_tota_env.mtu[conidx] = MTU; + } } /* @@ -236,19 +211,20 @@ void app_tota_mtu_exchanged_handler(uint8_t conidx, uint16_t MTU) */ /// Default State handlers definition -const struct ke_msg_handler app_tota_msg_handler_list[] = -{ - // Note: first message is latest message checked by kernel so default is put on top. - {KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_tota_msg_handler}, +const struct ke_msg_handler app_tota_msg_handler_list[] = { + // Note: first message is latest message checked by kernel so default is put + // on top. + {KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_tota_msg_handler}, - {TOTA_CCC_CHANGED, (ke_msg_func_t)app_tota_ccc_changed_handler}, - {TOTA_TX_DATA_SENT, (ke_msg_func_t)app_tota_tx_data_sent_handler}, - {TOTA_DATA_RECEIVED, (ke_msg_func_t)app_tota_data_received_handler}, + {TOTA_CCC_CHANGED, (ke_msg_func_t)app_tota_ccc_changed_handler}, + {TOTA_TX_DATA_SENT, (ke_msg_func_t)app_tota_tx_data_sent_handler}, + {TOTA_DATA_RECEIVED, (ke_msg_func_t)app_tota_data_received_handler}, }; -const struct ke_state_handler app_tota_table_handler = - {&app_tota_msg_handler_list[0], (sizeof(app_tota_msg_handler_list)/sizeof(struct ke_msg_handler))}; +const struct ke_state_handler app_tota_table_handler = { + &app_tota_msg_handler_list[0], + (sizeof(app_tota_msg_handler_list) / sizeof(struct ke_msg_handler))}; -#endif //BLE_APP_TOTA +#endif // BLE_APP_TOTA /// @} APP diff --git a/services/ble_app/app_vob/voice_over_ble.c b/services/ble_app/app_vob/voice_over_ble.c index 81d8cfb..8d86421 100644 --- a/services/ble_app/app_vob/voice_over_ble.c +++ b/services/ble_app/app_vob/voice_over_ble.c @@ -15,58 +15,57 @@ ****************************************************************************/ #if __VOICE_OVER_BLE_ENABLED__ -#include "string.h" -#include "cmsis_os.h" -#include "hal_trace.h" -#include "hal_iomux.h" -#include "app_thread.h" -#include "app_utils.h" -#include "Pcm8k_Cvsd.h" -#include "app_audio.h" -#include "apps.h" -#include "app.h" -#include "audioflinger.h" #include "voice_over_ble.h" +#include "Pcm8k_Cvsd.h" +#include "app.h" +#include "app_audio.h" #include "app_ble_cmd_handler.h" #include "app_ble_custom_cmd.h" #include "app_datapath_server.h" - +#include "app_thread.h" +#include "app_utils.h" +#include "apps.h" +#include "audioflinger.h" +#include "cmsis_os.h" +#include "hal_iomux.h" +#include "hal_trace.h" +#include "string.h" /** * @brief The states of the VOB state machine * */ -typedef enum -{ - VOB_STATE_IDLE = 0, - VOB_STATE_ADVERTISING, - VOB_STATE_STOPPING_ADV, - VOB_STATE_ADV_STOPPED, - VOB_STATE_CONNECTING, - VOB_STATE_STOPPING_CONNECTING, - VOB_STATE_CONNECTED, - VOB_STATE_DISCONNECTED, - VOB_STATE_VOICE_STREAM, +typedef enum { + VOB_STATE_IDLE = 0, + VOB_STATE_ADVERTISING, + VOB_STATE_STOPPING_ADV, + VOB_STATE_ADV_STOPPED, + VOB_STATE_CONNECTING, + VOB_STATE_STOPPING_CONNECTING, + VOB_STATE_CONNECTED, + VOB_STATE_DISCONNECTED, + VOB_STATE_VOICE_STREAM, } VOB_STATE_E; /** * @brief Buffer management of the VOB * */ -typedef struct -{ - /**< for SRC: the encoder will encode the PCM data into the audio data and fill them into encodedDataBuf - for DST: the received encoded data will be pushed into encodedDataBuf pending for decoding and playing */ - uint32_t encodedDataIndexToFill; +typedef struct { + /**< for SRC: the encoder will encode the PCM data into the audio data and + fill them into encodedDataBuf for DST: the received encoded data will be + pushed into encodedDataBuf pending for decoding and playing */ + uint32_t encodedDataIndexToFill; - /**< for SRC: the BLE will fetch data at this index from the encodedDataBuf and send them - for DST: the player will fetch data at this index from the encodedDataBuf, decode them and play */ - uint32_t encodedDataIndexToFetch; + /**< for SRC: the BLE will fetch data at this index from the encodedDataBuf + and send them for DST: the player will fetch data at this index from the + encodedDataBuf, decode them and play */ + uint32_t encodedDataIndexToFetch; - uint32_t encodedDataLength; + uint32_t encodedDataLength; + + uint8_t isCachingDone; - uint8_t isCachingDone; - } VOB_DATA_BUF_MANAGEMENT_T; /** @@ -74,62 +73,64 @@ typedef struct * * @param pcmDataPtr Pointer of the input PCM data to be encoded * @param pcmDataLen Length of the input PCM data to be encoded - * @param encodedDataPtr Pointer of the output encoded data + * @param encodedDataPtr Pointer of the output encoded data * @param encodedDataLen Length of the output encoded data - * + * */ -typedef void (*PCM_Encoder_Handler_t)(uint8_t* pcmDataPtr, uint32_t pcmDataLen, encodedDataPtr, encodedDataLen); - +typedef void (*PCM_Encoder_Handler_t)(uint8_t *pcmDataPtr, uint32_t pcmDataLen, + encodedDataPtr, encodedDataLen); /**< configure the voice settings */ -#define VOB_VOICE_BIT_NUMBER (AUD_BITS_16) -#define VOB_VOICE_SAMPLE_RATE (AUD_SAMPRATE_8000) -#define VOB_VOICE_VOLUME (10) +#define VOB_VOICE_BIT_NUMBER (AUD_BITS_16) +#define VOB_VOICE_SAMPLE_RATE (AUD_SAMPRATE_8000) +#define VOB_VOICE_VOLUME (10) /**< signal of the VOB application thread */ -#define VOB_SIGNAL_GET_RESPONSE 0x80 +#define VOB_SIGNAL_GET_RESPONSE 0x80 /**< signal of the BLE thread */ -#define BLE_SIGNAL_VOB_GET_ENCODED_AUDIO_DATA 0x01 -#define BLE_SIGNAL_VOB_DATA_SENT_OUT 0x02 -#define BLE_SIGNAL_VOB_RECEIVED_DATA 0x04 -#define BLE_SIGNAL_VOB_CONNECTED 0x08 -#define BLE_SIGNAL_VOB_DISCONNECTED 0x10 +#define BLE_SIGNAL_VOB_GET_ENCODED_AUDIO_DATA 0x01 +#define BLE_SIGNAL_VOB_DATA_SENT_OUT 0x02 +#define BLE_SIGNAL_VOB_RECEIVED_DATA 0x04 +#define BLE_SIGNAL_VOB_CONNECTED 0x08 +#define BLE_SIGNAL_VOB_DISCONNECTED 0x10 +/**< for SRC, the buffer is used to save the collected PCM data via the MIC + for DST, the buffer is used to save the decoded PCM data pending for + playing back*/ +#define VOB_VOICE_PCM_DATA_CHUNK_SIZE (2048) +#define VOB_VOICE_PCM_DATA_CHUNK_COUNT (8) +#define VOB_VOICE_PCM_DATA_STORAGE_BUF_SIZE \ + (VOB_VOICE_PCM_DATA_CHUNK_SIZE * VOB_VOICE_PCM_DATA_CHUNK_SIZE) -/**< for SRC, the buffer is used to save the collected PCM data via the MIC - for DST, the buffer is used to save the decoded PCM data pending for playing back*/ -#define VOB_VOICE_PCM_DATA_CHUNK_SIZE (2048) -#define VOB_VOICE_PCM_DATA_CHUNK_COUNT (8) -#define VOB_VOICE_PCM_DATA_STORAGE_BUF_SIZE (VOB_VOICE_PCM_DATA_CHUNK_SIZE*VOB_VOICE_PCM_DATA_CHUNK_SIZE) - -#define VOB_ENCODED_DATA_CACHE_SIZE (2048) +#define VOB_ENCODED_DATA_CACHE_SIZE (2048) /**< for SRC, the buffer is used to save the encoded audio data, - for DST, the buffer is used to save the received encoded audio data via the BLE*/ -#define VOB_ENCODED_DATA_STORAGE_BUF_SIZE (2048*2) + for DST, the buffer is used to save the received encoded audio data via the + BLE*/ +#define VOB_ENCODED_DATA_STORAGE_BUF_SIZE (2048 * 2) /**< timeout in ms of waiting for the response */ -#define VOB_WAITING_RESPONSE_TIMEOUT_IN_MS (5000) +#define VOB_WAITING_RESPONSE_TIMEOUT_IN_MS (5000) /**< connection parameter */ -#define VOB_CONNECTION_INTERVAL_IN_MS 5 -#define VOB_CONNECTION_SUPERVISION_TIMEOUT_IN_MS 5000 +#define VOB_CONNECTION_INTERVAL_IN_MS 5 +#define VOB_CONNECTION_SUPERVISION_TIMEOUT_IN_MS 5000 /**< depends on the compression ratio of the codec algrithm */ /**< now the cvsd is used, so the ratio is 50% */ -#define VOB_PCM_SIZE_TO_AUDIO_SIZE(size) ((size)/2) -#define VOB_AUDIO_SIZE_TO_PCM_SIZE(size) ((size)*2) - +#define VOB_PCM_SIZE_TO_AUDIO_SIZE(size) ((size) / 2) +#define VOB_AUDIO_SIZE_TO_PCM_SIZE(size) ((size)*2) static osThreadId ble_app_tid; static void ble_app_thread(void const *argument); osThreadDef(ble_app_thread, osPriorityNormal, 1, 512, "ble_app"); -/**< connecting supervisor timer, if timeout happened, the connecting try will be stopped */ -#define VOB_CONNECTING_TIMEOUT_IN_MS (10*1000) +/**< connecting supervisor timer, if timeout happened, the connecting try will + * be stopped */ +#define VOB_CONNECTING_TIMEOUT_IN_MS (10 * 1000) static void connecting_supervisor_timer_cb(void const *n); -osTimerDef (APP_VOB_CONNECTING_SUPERVISOR_TIMER, connecting_supervisor_timer_cb); +osTimerDef(APP_VOB_CONNECTING_SUPERVISOR_TIMER, connecting_supervisor_timer_cb); static osTimerId vob_connecting_supervisor_timer; /**< state machine of the VOB */ @@ -149,192 +150,179 @@ VOB_DATA_BUF_MANAGEMENT_T vob_data_management; osMutexId vob_env_mutex_id; osMutexDef(vob_env_mutex); +#define STREAM_A2DP_SPEAKER 0 -#define STREAM_A2DP_SPEAKER 0 +#define STREAM_A2DP_PCM_DATA_BUF_SIZE 1024 +#define STREAM_A2DP_ENCODED_DATA_BUF_SIZE 1024 +static const VOB_FUNCTIONALITY_CONFIG_T vob_func_config[] = { + {STREAM_A2DP_PCM_DATA_BUF_SIZE, STREAM_A2DP_ENCODED_DATA_BUF_SIZE - -#define STREAM_A2DP_PCM_DATA_BUF_SIZE 1024 -#define STREAM_A2DP_ENCODED_DATA_BUF_SIZE 1024 -static const VOB_FUNCTIONALITY_CONFIG_T vob_func_config[] = -{ - { - STREAM_A2DP_PCM_DATA_BUF_SIZE, - STREAM_A2DP_ENCODED_DATA_BUF_SIZE - - }, + }, }; -static VOB_DATA_BUF_MANAGEMENT_T stream_a2dp_data_management; +static VOB_DATA_BUF_MANAGEMENT_T stream_a2dp_data_management; -#define STREAM_DATA_PROCESSING_UNIT_IN_BYTES 1024 +#define STREAM_DATA_PROCESSING_UNIT_IN_BYTES 1024 struct gap_bdaddr DST_BLE_BdAddr = {{0x11, 0x22, 0x33, 0x44, 0x55, 0x66}, 0}; #if defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE) -#define RESAMPLE_ITER_LEN (128 * 2 * 2) +#define RESAMPLE_ITER_LEN (128 * 2 * 2) static struct APP_RESAMPLE_T *ble_resample; -static int ble_resample_iter(uint8_t *buf, uint32_t len) -{ - uint32_t acquiredPCMDataLength = decode_sbc_frame(buf, len); +static int ble_resample_iter(uint8_t *buf, uint32_t len) { + uint32_t acquiredPCMDataLength = decode_sbc_frame(buf, len); - if (acquiredPCMDataLength < len) - { - TRACE(0,"Start encoded data caching again."); - stream_a2dp_data_management.isCachingDone = false; - return 1; - } - return 0; + if (acquiredPCMDataLength < len) { + TRACE(0, "Start encoded data caching again."); + stream_a2dp_data_management.isCachingDone = false; + return 1; + } + return 0; } #endif -uint32_t a2dp_audio_prepare_pcm_data(uint8_t *buf, uint32_t len) -{ - if (stream_a2dp_data_management.isCachingDone) - { - // the caching stage has been done, decode the encoded data and feed the PCM +uint32_t a2dp_audio_prepare_pcm_data(uint8_t *buf, uint32_t len) { + if (stream_a2dp_data_management.isCachingDone) { + // the caching stage has been done, decode the encoded data and feed the PCM #if defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE) - if (allow_resample) - { - app_playback_resample_run(ble_resample, buf, len); - } - else + if (allow_resample) { + app_playback_resample_run(ble_resample, buf, len); + } else #endif - { - uint32_t acquiredPCMDataLength = decode_sbc_frame(buf, len); - // the queued encoded data does't meet the PCM data requirement, - // need to cache again - if (acquiredPCMDataLength < len) - { - TRACE(2,"Need %d PCM data, but the queue encoded data can only provide %d bytes", - len, acquiredPCMDataLength); - - memset(buf+acquiredPCMDataLength, 0, len-acquiredPCMDataLength); + { + uint32_t acquiredPCMDataLength = decode_sbc_frame(buf, len); + // the queued encoded data does't meet the PCM data requirement, + // need to cache again + if (acquiredPCMDataLength < len) { + TRACE(2, + "Need %d PCM data, but the queue encoded data can only provide " + "%d bytes", + len, acquiredPCMDataLength); - TRACE(0,"Start encoded data caching again."); - stream_a2dp_data_management.isCachingDone = false; - } - } - } - else - { - memset(buf, 0, len); - } - - return len; + memset(buf + acquiredPCMDataLength, 0, len - acquiredPCMDataLength); + + TRACE(0, "Start encoded data caching again."); + stream_a2dp_data_management.isCachingDone = false; + } + } + } else { + memset(buf, 0, len); + } + + return len; } -static uint32_t stream_a2dp_speaker_more_pcm_data(uint8_t* buf, uint32_t len) -{ +static uint32_t stream_a2dp_speaker_more_pcm_data(uint8_t *buf, uint32_t len) { #ifdef BT_XTAL_SYNC #ifndef __TWS__ - bt_xtal_sync(BT_XTAL_SYNC_MODE_MUSIC); -#endif // #ifndef __TWS__ -#endif // #ifdef BT_XTAL_SYNC + bt_xtal_sync(BT_XTAL_SYNC_MODE_MUSIC); +#endif // #ifndef __TWS__ +#endif // #ifdef BT_XTAL_SYNC #ifdef __TWS__ - tws_audout_pcm_more_data(buf, len); -#else // __TWS__ + tws_audout_pcm_more_data(buf, len); +#else // __TWS__ #if defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE) - app_playback_resample_run(ble_resample, buf, len); + app_playback_resample_run(ble_resample, buf, len); #else - a2dp_audio_more_data(buf, len); + a2dp_audio_more_data(buf, len); #endif - app_ring_merge_more_data(buf, len); + app_ring_merge_more_data(buf, len); #ifdef __AUDIO_OUTPUT_MONO_MODE__ - merge_stereo_to_mono_16bits((int16_t *)buf, (int16_t *)buf, len/2); -#endif // #ifdef __AUDIO_OUTPUT_MONO_MODE__ + merge_stereo_to_mono_16bits((int16_t *)buf, (int16_t *)buf, len / 2); +#endif // #ifdef __AUDIO_OUTPUT_MONO_MODE__ -#endif // #ifdef __TWS__ +#endif // #ifdef __TWS__ -#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__) || defined(__AUDIO_DRC__) - // app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_104M); +#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__) || \ + defined(__AUDIO_DRC__) + // app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_104M); - audio_process_run(buf, len); + audio_process_run(buf, len); - // app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_52M); -#endif // #if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__) || defined(__AUDIO_DRC__) + // app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_52M); +#endif // #if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__) + // || defined(__AUDIO_DRC__) - return len; + return len; } -int encoded_data_received(unsigned char *buf, unsigned int len) -{ - int32_t ret, size; - LOCK_APP_AUDIO_QUEUE(); +int encoded_data_received(unsigned char *buf, unsigned int len) { + int32_t ret, size; + LOCK_APP_AUDIO_QUEUE(); - // push the encoded data into the queue - ret = APP_AUDIO_EnCQueueByForce(&sbc_queue, buf, len); - size = APP_AUDIO_LengthOfCQueue(&sbc_queue); - UNLOCK_APP_AUDIO_QUEUE(); + // push the encoded data into the queue + ret = APP_AUDIO_EnCQueueByForce(&sbc_queue, buf, len); + size = APP_AUDIO_LengthOfCQueue(&sbc_queue); + UNLOCK_APP_AUDIO_QUEUE(); - // the queue is full, overwrite the oldest data - if (CQ_ERR == ret) - { - TRACE(0,"Encoded data cache is overflow."); - } - - if ((!(stream_a2dp_data_management.isCachingDone)) && - (size >= stream_a2dp_data_management.initialCachedEncodedDataSize)) - { - // the cached encoded data is ready, time to start decoding and feeding to the codec - stream_a2dp_data_management.isCachingDone = true; - } - - return 0; + // the queue is full, overwrite the oldest data + if (CQ_ERR == ret) { + TRACE(0, "Encoded data cache is overflow."); + } + + if ((!(stream_a2dp_data_management.isCachingDone)) && + (size >= stream_a2dp_data_management.initialCachedEncodedDataSize)) { + // the cached encoded data is ready, time to start decoding and feeding to + // the codec + stream_a2dp_data_management.isCachingDone = true; + } + + return 0; } - /** * @brief Start the A2DP speaker output stream * */ -void kick_off_a2dp_speaker_stream(void) -{ - // clean up the data management structure - memset((uint8_t *)&stream_a2dp_data_management, 0, sizeof(stream_a2dp_data_management)); +void kick_off_a2dp_speaker_stream(void) { + // clean up the data management structure + memset((uint8_t *)&stream_a2dp_data_management, 0, + sizeof(stream_a2dp_data_management)); - // prepare the buffer - app_audio_mempool_init(); - - app_audio_mempool_get_buff(&(stream_a2dp_data_management.pcmDataBuf), - vob_func_config[STREAM_A2DP_SPEAKER].pcmDataBufSize); - app_audio_mempool_get_buff(&(stream_a2dp_data_management.encodedDataBuf), - vob_func_config[STREAM_A2DP_SPEAKER].encodedDataBufSize); + // prepare the buffer + app_audio_mempool_init(); + app_audio_mempool_get_buff( + &(stream_a2dp_data_management.pcmDataBuf), + vob_func_config[STREAM_A2DP_SPEAKER].pcmDataBufSize); + app_audio_mempool_get_buff( + &(stream_a2dp_data_management.encodedDataBuf), + vob_func_config[STREAM_A2DP_SPEAKER].encodedDataBufSize); - // acuqire the sufficient system clock - app_sysfreq_req(APP_SYSFREQ_VOICE_OVER_BLE, APP_SYSFREQ_52M); + // acuqire the sufficient system clock + app_sysfreq_req(APP_SYSFREQ_VOICE_OVER_BLE, APP_SYSFREQ_52M); - // create the audio flinger stream - struct AF_STREAM_CONFIG_T stream_cfg; - - stream_cfg.bits = stream_a2dp_data_management.pcmBitNumber; - stream_cfg.channel_num = AUD_CHANNEL_NUM_2; - stream_cfg.sample_rate = stream_a2dp_data_management.pcmSampleRate; - stream_cfg.vol = VOB_VOICE_VOLUME; + // create the audio flinger stream + struct AF_STREAM_CONFIG_T stream_cfg; - stream_cfg.device = AUD_STREAM_USE_OPTIMIZED_STREAM; + stream_cfg.bits = stream_a2dp_data_management.pcmBitNumber; + stream_cfg.channel_num = AUD_CHANNEL_NUM_2; + stream_cfg.sample_rate = stream_a2dp_data_management.pcmSampleRate; + stream_cfg.vol = VOB_VOICE_VOLUME; - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; - stream_cfg.handler = vob_func_config[STREAM_A2DP_SPEAKER].dataCallback; + stream_cfg.device = AUD_STREAM_USE_OPTIMIZED_STREAM; - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(vob_data_management.pcmDataBufSize); - - stream_cfg.data_size = STREAM_DATA_PROCESSING_UNIT_IN_BYTES; - stream_cfg.data_chunk_count = 2; - - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; + stream_cfg.handler = vob_func_config[STREAM_A2DP_SPEAKER].dataCallback; + + stream_cfg.data_ptr = + BT_AUDIO_CACHE_2_UNCACHE(vob_data_management.pcmDataBufSize); + + stream_cfg.data_size = STREAM_DATA_PROCESSING_UNIT_IN_BYTES; + stream_cfg.data_chunk_count = 2; + + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); } - static osThreadId vob_ThreadId; /**< The negotiated MTU size between SRC and DST */ @@ -345,13 +333,12 @@ static uint16_t negotiatedMTUSize; * * @param ptrBuf Pointer of the data to send * @param length Length of the data in bytes - * + * * @return ture if the data is successfully sent out. */ -bool ble_send_data(uint8_t* ptrBuf, uint32_t length) -{ - app_datapath_server_send_data(ptrBuf, length); - return true; +bool ble_send_data(uint8_t *ptrBuf, uint32_t length) { + app_datapath_server_send_data(ptrBuf, length); + return true; } /** @@ -359,493 +346,464 @@ bool ble_send_data(uint8_t* ptrBuf, uint32_t length) * * @param ptrBuf Pointer of the data to send * @param length Length of the data in bytes - * + * * @return ture if the data is successfully sent out. */ -bool ble_receive_data(uint8_t* ptrBuf, uint32_t length) -{ - -} +bool ble_receive_data(uint8_t *ptrBuf, uint32_t length) {} /** * @brief Stop the MIC voice input stream * */ -void vob_stop_mic_input_stream(void) -{ - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - - // release the acquired system clock - app_sysfreq_req(APP_SYSFREQ_VOICE_OVER_BLE, APP_SYSFREQ_32K); +void vob_stop_mic_input_stream(void) { + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + + // release the acquired system clock + app_sysfreq_req(APP_SYSFREQ_VOICE_OVER_BLE, APP_SYSFREQ_32K); } /** * @brief Stop the speaker output stream * */ -void vob_stop_speaker_output_stream(void) -{ - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - - // release the acquired system clock - app_sysfreq_req(APP_SYSFREQ_VOICE_OVER_BLE, APP_SYSFREQ_32K); +void vob_stop_speaker_output_stream(void) { + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + + // release the acquired system clock + app_sysfreq_req(APP_SYSFREQ_VOICE_OVER_BLE, APP_SYSFREQ_32K); } /** * @brief Stop the voice stream * */ -static void vob_stop_voice_stream(void) -{ - if (VOB_ROLE_SRC == vob_role) - { - // stop the MIC voice input stream - vob_stop_mic_input_stream(); - } - else - { - // stop the speaker output stream - vob_stop_speaker_output_stream(); - } - - VOB_CMD_RSP_T cmd; +static void vob_stop_voice_stream(void) { + if (VOB_ROLE_SRC == vob_role) { + // stop the MIC voice input stream + vob_stop_mic_input_stream(); + } else { + // stop the speaker output stream + vob_stop_speaker_output_stream(); + } - // send start voice stream command to the DST - cmd.magicCode = VOB_MAGICCODE_OF_CMD_RSP; - cmd.cmdRspCode = VOB_CMD_STOP_VOICE_STREAM; + VOB_CMD_RSP_T cmd; - bool ret = ble_send_data((uint8_t *)&cmd, &(((VOB_CMD_RSP_T *)0)->lengthOfParm)) - ASSERT_SIMPLIFIED(ret); + // send start voice stream command to the DST + cmd.magicCode = VOB_MAGICCODE_OF_CMD_RSP; + cmd.cmdRspCode = VOB_CMD_STOP_VOICE_STREAM; - // waiting until it recieves the response from the other side or timeout happens - osEvent event = osSignalWait(VOB_SIGNAL_GET_RESPONSE, VOB_WAITING_RESPONSE_TIMEOUT_IN_MS); - if (osEventSignal != event.status) - { - TRACE(0,"Time-out happens when waiting the response of stopping voice stream from DST."); - } + bool ret = + ble_send_data((uint8_t *)&cmd, &(((VOB_CMD_RSP_T *)0)->lengthOfParm)) + ASSERT_SIMPLIFIED(ret); - // reset the state anyway - vob_state = VOB_STATE_CONNECTED; + // waiting until it recieves the response from the other side or timeout + // happens + osEvent event = + osSignalWait(VOB_SIGNAL_GET_RESPONSE, VOB_WAITING_RESPONSE_TIMEOUT_IN_MS); + if (osEventSignal != event.status) { + TRACE(0, "Time-out happens when waiting the response of stopping voice " + "stream from DST."); + } + + // reset the state anyway + vob_state = VOB_STATE_CONNECTED; } /** * @brief Handler when receiving the stop the voice stream command * */ -static void vob_receiving_stop_voice_stream_handler(void) -{ - if (VOB_ROLE_SRC == vob_role) - { - // stop the MIC voice input stream - vob_stop_mic_input_stream(); - } - else - { - // stop the speaker output stream - vob_stop_speaker_output_stream(); - } - - VOB_CMD_RSP_T cmd; +static void vob_receiving_stop_voice_stream_handler(void) { + if (VOB_ROLE_SRC == vob_role) { + // stop the MIC voice input stream + vob_stop_mic_input_stream(); + } else { + // stop the speaker output stream + vob_stop_speaker_output_stream(); + } - // send start voice stream command to the DST + VOB_CMD_RSP_T cmd; - cmd.magicCode = VOB_MAGICCODE_OF_CMD_RSP; - cmd.cmdRspCode = VOB_RSP_READY_TO_STOP_VOICE_STREAM; + // send start voice stream command to the DST - bool ret = ble_send_data((uint8_t *)&cmd, &(((VOB_CMD_RSP_T *)0)->lengthOfParm)) - ASSERT_SIMPLIFIED(ret); + cmd.magicCode = VOB_MAGICCODE_OF_CMD_RSP; + cmd.cmdRspCode = VOB_RSP_READY_TO_STOP_VOICE_STREAM; - // reset the state anyway - vob_state = VOB_STATE_CONNECTED; + bool ret = + ble_send_data((uint8_t *)&cmd, &(((VOB_CMD_RSP_T *)0)->lengthOfParm)) + ASSERT_SIMPLIFIED(ret); + + // reset the state anyway + vob_state = VOB_STATE_CONNECTED; } - /** * @brief Start advertising * */ -static void vob_start_advertising(void) -{ - // start advertising - appm_start_advertising(); +static void vob_start_advertising(void) { + // start advertising + appm_start_advertising(); - vob_state = VOB_STATE_ADVERTISING; + vob_state = VOB_STATE_ADVERTISING; } /** - * @brief Process the recevied audio data from BLE, encode them and feed them to the speaker + * @brief Process the recevied audio data from BLE, encode them and feed them to + * the speaker * * @param ptrBuf Pointer of the PCM data buffer to feed. * @param length Length of the asked PCM data. * * @return uint32_t 0 means no error happens */ -static uint32_t vob_need_more_voice_data(uint8_t* ptrBuf, uint32_t length) -{ - if (vob_data_management.isCachingDone) - { - // caching has been done, can decoded the received encoded data to PCM and feed them to the buffer - uint32_t remainingPCMBytesToFeed = length; - uint32_t pcmBytesToDecode; - do - { - pcmBytesToDecode = (remainingPCMBytesToFeed > (2*MAXNUMOFSAMPLES*src_mic_stream_env.bitNumber/AUD_BITS_8))?\ - (2*MAXNUMOFSAMPLES*src_mic_stream_env.bitNumber/AUD_BITS_8):remainingPCMBytesToFeed; +static uint32_t vob_need_more_voice_data(uint8_t *ptrBuf, uint32_t length) { + if (vob_data_management.isCachingDone) { + // caching has been done, can decoded the received encoded data to PCM and + // feed them to the buffer + uint32_t remainingPCMBytesToFeed = length; + uint32_t pcmBytesToDecode; + do { + pcmBytesToDecode = + (remainingPCMBytesToFeed > + (2 * MAXNUMOFSAMPLES * src_mic_stream_env.bitNumber / AUD_BITS_8)) + ? (2 * MAXNUMOFSAMPLES * src_mic_stream_env.bitNumber / + AUD_BITS_8) + : remainingPCMBytesToFeed; - // cvsd's compression ratio is 50% - if ((VOB_PCM_SIZE_TO_AUDIO_SIZE(pcmBytesToDecode) + vob_data_management.encodedDataIndexToFetch) > - src_mic_stream_env.encodedDataBufSize) - { - pcmBytesToDecode = VOB_AUDIO_SIZE_TO_PCM_SIZE(src_mic_stream_env.encodedDataBufSize - - vob_data_management.encodedDataIndexToFetch); - } + // cvsd's compression ratio is 50% + if ((VOB_PCM_SIZE_TO_AUDIO_SIZE(pcmBytesToDecode) + + vob_data_management.encodedDataIndexToFetch) > + src_mic_stream_env.encodedDataBufSize) { + pcmBytesToDecode = VOB_AUDIO_SIZE_TO_PCM_SIZE( + src_mic_stream_env.encodedDataBufSize - + vob_data_management.encodedDataIndexToFetch); + } - // decode to generate the PCM data - CvsdToPcm8k(vob_data_management.encodedDataBuf + vob_data_management.encodedDataIndexToFetch, (short *)ptrBuf, - pcmBytesToDecode / sizeof(short)); + // decode to generate the PCM data + CvsdToPcm8k(vob_data_management.encodedDataBuf + + vob_data_management.encodedDataIndexToFetch, + (short *)ptrBuf, pcmBytesToDecode / sizeof(short)); - // update the index - ptrBuf += pcmBytesToDecode; - remainingPCMBytesToFeed -= pcmBytesToDecode; - - vob_data_management.encodedDataIndexToFetch += VOB_PCM_SIZE_TO_AUDIO_SIZE(pcmBytesToDecode); - - if (src_mic_stream_env.encodedDataBufSize == vob_data_management.encodedDataIndexToFetch) - { - vob_data_management.encodedDataIndexToFetch = 0; - } - - } while (remainingPCMBytesToFeed > 0); + // update the index + ptrBuf += pcmBytesToDecode; + remainingPCMBytesToFeed -= pcmBytesToDecode; - osMutexWait(vob_env_mutex_id, osWaitForever); + vob_data_management.encodedDataIndexToFetch += + VOB_PCM_SIZE_TO_AUDIO_SIZE(pcmBytesToDecode); - // update the bytes to decode and feed to codec - vob_data_management.encodedDataLength -= VOB_PCM_SIZE_TO_AUDIO_SIZE(length); + if (src_mic_stream_env.encodedDataBufSize == + vob_data_management.encodedDataIndexToFetch) { + vob_data_management.encodedDataIndexToFetch = 0; + } - osMutexRelease(vob_env_mutex_id); - } - else - { - // caching is not done yet, just fill all ZERO - memset(ptrBuf, 0, length); - } - - return len; + } while (remainingPCMBytesToFeed > 0); + + osMutexWait(vob_env_mutex_id, osWaitForever); + + // update the bytes to decode and feed to codec + vob_data_management.encodedDataLength -= VOB_PCM_SIZE_TO_AUDIO_SIZE(length); + + osMutexRelease(vob_env_mutex_id); + } else { + // caching is not done yet, just fill all ZERO + memset(ptrBuf, 0, length); + } + + return len; } /** * @brief Start the speaker output stream * */ -void vob_kick_off_speaker_output_stream(void) -{ - // prepare the memory buffer - app_audio_mempool_init(); - // PCM data buffer - app_audio_mempool_get_buff(&(dst_speaker_stream_env.pcmDataBuf), - src_mic_stream_env.pcmDataChunkCount*dst_speaker_stream_env.pcmDataChunkSize); - - // encoded data buffer - app_audio_mempool_get_buff(&(dst_speaker_stream_env.encodedDataBuf), - dst_speaker_stream_env.encodedDataBufSize); +void vob_kick_off_speaker_output_stream(void) { + // prepare the memory buffer + app_audio_mempool_init(); + // PCM data buffer + app_audio_mempool_get_buff(&(dst_speaker_stream_env.pcmDataBuf), + src_mic_stream_env.pcmDataChunkCount * + dst_speaker_stream_env.pcmDataChunkSize); - // encoded data queue - APP_AUDIO_InitCQueue(&(dst_speaker_stream_env.queue), dst_speaker_stream_env.encodedDataBufSize, - dst_speaker_stream_env.encodedDataBuf); - - // acuqire the sufficient system clock - app_sysfreq_req(APP_SYSFREQ_VOICE_OVER_BLE, APP_SYSFREQ_26M); + // encoded data buffer + app_audio_mempool_get_buff(&(dst_speaker_stream_env.encodedDataBuf), + dst_speaker_stream_env.encodedDataBufSize); - // create the audio flinger stream - struct AF_STREAM_CONFIG_T stream_cfg; - - stream_cfg.bits = dst_speaker_stream_env.bitNumber; - stream_cfg.sample_rate = dst_speaker_stream_env.sampleRate; - stream_cfg.channel_num = dst_speaker_stream_env.channelCount; - stream_cfg.vol = VOB_VOICE_VOLUME; + // encoded data queue + APP_AUDIO_InitCQueue(&(dst_speaker_stream_env.queue), + dst_speaker_stream_env.encodedDataBufSize, + dst_speaker_stream_env.encodedDataBuf); - stream_cfg.device = AUD_STREAM_USE_OPTIMIZED_STREAM; + // acuqire the sufficient system clock + app_sysfreq_req(APP_SYSFREQ_VOICE_OVER_BLE, APP_SYSFREQ_26M); - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; - stream_cfg.handler = dst_speaker_stream_env.morePcmHandler; + // create the audio flinger stream + struct AF_STREAM_CONFIG_T stream_cfg; - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(dst_speaker_stream_env.pcmDataBuf); - stream_cfg.data_size = dst_speaker_stream_env.pcmDataChunkSize; - - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + stream_cfg.bits = dst_speaker_stream_env.bitNumber; + stream_cfg.sample_rate = dst_speaker_stream_env.sampleRate; + stream_cfg.channel_num = dst_speaker_stream_env.channelCount; + stream_cfg.vol = VOB_VOICE_VOLUME; + + stream_cfg.device = AUD_STREAM_USE_OPTIMIZED_STREAM; + + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; + stream_cfg.handler = dst_speaker_stream_env.morePcmHandler; + + stream_cfg.data_ptr = + BT_AUDIO_CACHE_2_UNCACHE(dst_speaker_stream_env.pcmDataBuf); + stream_cfg.data_size = dst_speaker_stream_env.pcmDataChunkSize; + + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); } /** * @brief Send the encoded audio data to DST via BLE * */ -static void vob_send_encoded_audio_data(void) -{ - uint32_t dataBytesToSend = 0; - uint32_t offsetInEncodedDatabuf = vob_data_management.indexToFetch; - - osMutexWait(vob_env_mutex_id, osWaitForever); +static void vob_send_encoded_audio_data(void) { + uint32_t dataBytesToSend = 0; + uint32_t offsetInEncodedDatabuf = vob_data_management.indexToFetch; - if (vob_data_management.encodedDataLength > 0) - { - if (vob_data_management.encodedDataLength > negotiatedMTUSize) - { - dataBytesToSend = negotiatedMTUSize; - } - else - { - dataBytesToSend = vob_data_management.encodedDataLength; - } + osMutexWait(vob_env_mutex_id, osWaitForever); - if ((vob_data_management.indexToFetch + dataBytesToSend) > src_mic_stream_env.encodedDataBufSize) - { - dataBytesToSend = src_mic_stream_env.encodedDataBufSize - vob_data_management.indexToFetch; - } - - // update the index - vob_data_management.encodedDataLength += dataBytesToSend; - if (src_mic_stream_env.encodedDataBufSize == (vob_data_management.indexToFetch + dataBytesToSend)) - { - vob_data_management.indexToFetch = 0; - } - else - { - vob_data_management.indexToFetch += dataBytesToSend; - } + if (vob_data_management.encodedDataLength > 0) { + if (vob_data_management.encodedDataLength > negotiatedMTUSize) { + dataBytesToSend = negotiatedMTUSize; + } else { + dataBytesToSend = vob_data_management.encodedDataLength; } - osMutexRelease(vob_env_mutex_id); + if ((vob_data_management.indexToFetch + dataBytesToSend) > + src_mic_stream_env.encodedDataBufSize) { + dataBytesToSend = src_mic_stream_env.encodedDataBufSize - + vob_data_management.indexToFetch; + } - if (dataBytesToSend > 0) - { - // send out the data via the BLE - ble_send_data((vob_data_management.encodedDataBuf + offsetInEncodedDatabuf), - dataBytesToSend); - } + // update the index + vob_data_management.encodedDataLength += dataBytesToSend; + if (src_mic_stream_env.encodedDataBufSize == + (vob_data_management.indexToFetch + dataBytesToSend)) { + vob_data_management.indexToFetch = 0; + } else { + vob_data_management.indexToFetch += dataBytesToSend; + } + } + + osMutexRelease(vob_env_mutex_id); + + if (dataBytesToSend > 0) { + // send out the data via the BLE + ble_send_data((vob_data_management.encodedDataBuf + offsetInEncodedDatabuf), + dataBytesToSend); + } } /** * @brief Hanlder of the BLE data sent out event * */ -void vob_data_sent_out_handler(void) -{ - vob_send_encoded_audio_data(); -} +void vob_data_sent_out_handler(void) { vob_send_encoded_audio_data(); } /** - * @brief Hanlder of the response to start VOB voice stream command, called on the SRC side + * @brief Hanlder of the response to start VOB voice stream command, called on + * the SRC side * */ -void vob_start_voice_stream_rsp_handler(BLE_CUSTOM_CMD_RET_STATUS_E retStatus, uint8_t* ptrParam, uint32_t paramLen) -{ - - if (NO_ERROR == retStatus) - { - TRACE(0,"voice stream is successfully started!" +void vob_start_voice_stream_rsp_handler(BLE_CUSTOM_CMD_RET_STATUS_E retStatus, + uint8_t *ptrParam, uint32_t paramLen) { + + if (NO_ERROR == retStatus) { + TRACE(0,"voice stream is successfully started!" // kick off the voice input stream from MIC vob_kick_off_mic_input_stream(); // update the state vob_state = VOB_STATE_VOICE_STREAM; - } - else - { - TRACE(0,"starting voice stream failed!" - } + } else { + TRACE(0,"starting voice stream failed!" + } } -void vob_audio_data_reiceived_handler(uint8_t* ptrBuf, uint32_t length) -{ - // only for DST, receive the encoded audio data - if (VOB_ROLE_DST == vob_role) - { - // push into the encoded data buffer - ASSERT((vob_data_management.encodedDataLength + length) <= dst_speaker_stream_env.encodedDataBufSize, - "The left voice over ble buffer space is not suitable for the coming audio data."); +void vob_audio_data_reiceived_handler(uint8_t *ptrBuf, uint32_t length) { + // only for DST, receive the encoded audio data + if (VOB_ROLE_DST == vob_role) { + // push into the encoded data buffer + ASSERT((vob_data_management.encodedDataLength + length) <= + dst_speaker_stream_env.encodedDataBufSize, + "The left voice over ble buffer space is not suitable for the " + "coming audio data."); - uint32_t bytesToTheEnd = dst_speaker_stream_env.encodedDataBufSize - - vob_data_management.encodedDataIndexToFill; - if (length > bytesToTheEnd) - { - memcpy((dst_speaker_stream_env.encodedDataBuf + vob_data_management.encodedDataIndexToFill), - ptrBuf, length); - } - else - { - memcpy((dst_speaker_stream_env.encodedDataBuf + vob_data_management.encodedDataIndexToFill), - ptrBuf, bytesToTheEnd); - memcpy(dst_speaker_stream_env.encodedDataBuf, ptrBuf + bytesToTheEnd, length - bytesToTheEnd); - } - - osMutexWait(vob_env_mutex_id, osWaitForever); - - // update the bytes to transmit via BLE - vob_data_management.encodedDataLength += length; - - osMutexRelease(vob_env_mutex_id); - - if ((!vob_data_management.isCachingDone) && - (vob_data_management.encodedDataLength >= src_mic_stream_env.cachedEncodedDataSize)) - { - vob_data_management.isCachingDone = true; - } + uint32_t bytesToTheEnd = dst_speaker_stream_env.encodedDataBufSize - + vob_data_management.encodedDataIndexToFill; + if (length > bytesToTheEnd) { + memcpy((dst_speaker_stream_env.encodedDataBuf + + vob_data_management.encodedDataIndexToFill), + ptrBuf, length); + } else { + memcpy((dst_speaker_stream_env.encodedDataBuf + + vob_data_management.encodedDataIndexToFill), + ptrBuf, bytesToTheEnd); + memcpy(dst_speaker_stream_env.encodedDataBuf, ptrBuf + bytesToTheEnd, + length - bytesToTheEnd); } + + osMutexWait(vob_env_mutex_id, osWaitForever); + + // update the bytes to transmit via BLE + vob_data_management.encodedDataLength += length; + + osMutexRelease(vob_env_mutex_id); + + if ((!vob_data_management.isCachingDone) && + (vob_data_management.encodedDataLength >= + src_mic_stream_env.cachedEncodedDataSize)) { + vob_data_management.isCachingDone = true; + } + } } /** * @brief Hanlder of the start VOB voice stream command, called on the DST side * */ -void vob_start_voice_stream_cmd_handler(uint32_t funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - BLE_CUSTOM_CMD_RET_STATUS_E retStatus = NO_ERROR; +void vob_start_voice_stream_cmd_handler(uint32_t funcCode, uint8_t *ptrParam, + uint32_t paramLen) { + BLE_CUSTOM_CMD_RET_STATUS_E retStatus = NO_ERROR; - if (VOB_STATE_CONNECTED == vob_state) - { - // update the state - vob_state = VOB_STATE_VOICE_STREAM; + if (VOB_STATE_CONNECTED == vob_state) { + // update the state + vob_state = VOB_STATE_VOICE_STREAM; - // start raw data xfer - BLE_control_raw_data_xfer(true); + // start raw data xfer + BLE_control_raw_data_xfer(true); - // configure raw data handler - BLE_set_raw_data_xfer_received_callback(vob_audio_data_reiceived_handler); + // configure raw data handler + BLE_set_raw_data_xfer_received_callback(vob_audio_data_reiceived_handler); - // kick off the speaker stream - vob_kick_off_speaker_output_stream(); - } - else - { - retStatus = HANDLING_FAILED; - } + // kick off the speaker stream + vob_kick_off_speaker_output_stream(); + } else { + retStatus = HANDLING_FAILED; + } - BLE_send_response_to_command(funcCode, retStatus, NULL, TRANSMISSION_VIA_WRITE_CMD); + BLE_send_response_to_command(funcCode, retStatus, NULL, + TRANSMISSION_VIA_WRITE_CMD); } /** - * @brief Hanlder of the response to stop VOB voice stream command, called on the SRC side + * @brief Hanlder of the response to stop VOB voice stream command, called on + * the SRC side * */ -void vob_stop_voice_stream_rsp_handler(BLE_CUSTOM_CMD_RET_STATUS_E retStatus, uint8_t* ptrParam, uint32_t paramLen) -{ - // stop the MIC voice input stream - vob_stop_mic_input_stream(); +void vob_stop_voice_stream_rsp_handler(BLE_CUSTOM_CMD_RET_STATUS_E retStatus, + uint8_t *ptrParam, uint32_t paramLen) { + // stop the MIC voice input stream + vob_stop_mic_input_stream(); - vob_state = VOB_STATE_CONNECTED; + vob_state = VOB_STATE_CONNECTED; } /** * @brief Hanlder of the stop VOB voice stream command, called on the DST side * */ -void vob_stop_voice_stream_cmd_handler(uint32_t funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - BLE_CUSTOM_CMD_RET_STATUS_E retStatus = NO_ERROR; +void vob_stop_voice_stream_cmd_handler(uint32_t funcCode, uint8_t *ptrParam, + uint32_t paramLen) { + BLE_CUSTOM_CMD_RET_STATUS_E retStatus = NO_ERROR; - if (VOB_STATE_VOICE_STREAM == vob_state) - { - // update the state - vob_state = VOB_STATE_CONNECTED; + if (VOB_STATE_VOICE_STREAM == vob_state) { + // update the state + vob_state = VOB_STATE_CONNECTED; - // stop raw data xfer - BLE_control_raw_data_xfer(false); + // stop raw data xfer + BLE_control_raw_data_xfer(false); - // stop the speaker output stream - vob_stop_speaker_output_stream(); - } - else - { - retStatus = HANDLING_FAILED; - } + // stop the speaker output stream + vob_stop_speaker_output_stream(); + } else { + retStatus = HANDLING_FAILED; + } - BLE_send_response_to_command(funcCode, retStatus, NULL, TRANSMISSION_VIA_WRITE_CMD); + BLE_send_response_to_command(funcCode, retStatus, NULL, + TRANSMISSION_VIA_WRITE_CMD); } -static void vob_encoded_data_sent_done(void) -{ - if ((VOB_STATE_VOICE_STREAM == vob_state) && - (vob_data_management.encodedDataLength > 0)) - { - // inform the ble application thread to continue sending the encoded data if any in the buffer - osSignalSet(ble_app_tid, BLE_SIGNAL_VOB_DATA_SENT_OUT); - } +static void vob_encoded_data_sent_done(void) { + if ((VOB_STATE_VOICE_STREAM == vob_state) && + (vob_data_management.encodedDataLength > 0)) { + // inform the ble application thread to continue sending the encoded data if + // any in the buffer + osSignalSet(ble_app_tid, BLE_SIGNAL_VOB_DATA_SENT_OUT); + } } /** * @brief Hanlder of the BLE connected event * */ -void vob_connected_evt_handler(void) -{ - if (VOB_ROLE_SRC == vob_role) - { - l2cap_update_param(VOB_CONNECTION_INTERVAL_IN_MS, - VOB_CONNECTION_INTERVAL_IN_MS, VOB_CONNECTION_SUPERVISION_TIMEOUT_IN_MS); - - vob_data_management.encodedDataIndexToFetch = 0; - vob_data_management.encodedDataIndexToFill = 0; - vob_data_management.encodedDataLength = 0; - - // register the BLE tx done callback function - app_datapath_server_register_tx_done(vob_encoded_data_sent_done); - - // delete the timer - osTimerDelete(vob_connecting_supervisor_timer); - } +void vob_connected_evt_handler(void) { + if (VOB_ROLE_SRC == vob_role) { + l2cap_update_param(VOB_CONNECTION_INTERVAL_IN_MS, + VOB_CONNECTION_INTERVAL_IN_MS, + VOB_CONNECTION_SUPERVISION_TIMEOUT_IN_MS); - vob_data_management.isCachingDone = false; - - // play the connected sound - app_voice_report(APP_STATUS_INDICATION_CONNECTED, 0); + vob_data_management.encodedDataIndexToFetch = 0; + vob_data_management.encodedDataIndexToFill = 0; + vob_data_management.encodedDataLength = 0; - // update the state - vob_state = VOB_STATE_CONNECTED; + // register the BLE tx done callback function + app_datapath_server_register_tx_done(vob_encoded_data_sent_done); + + // delete the timer + osTimerDelete(vob_connecting_supervisor_timer); + } + + vob_data_management.isCachingDone = false; + + // play the connected sound + app_voice_report(APP_STATUS_INDICATION_CONNECTED, 0); + + // update the state + vob_state = VOB_STATE_CONNECTED; } /** * @brief Hanlder of the BLE disconnected event * */ -void vob_disconnected_evt_handler(void) -{ - ASSERT_SIMPLIFIED((VOB_STATE_VOICE_STREAM == vob_state) || (VOB_STATE_CONNECTED == vob_state)); - - vob_state = VOB_STATE_DISCONNECTED; +void vob_disconnected_evt_handler(void) { + ASSERT_SIMPLIFIED((VOB_STATE_VOICE_STREAM == vob_state) || + (VOB_STATE_CONNECTED == vob_state)); - // stop raw data xfer - BLE_control_raw_data_xfer(false); + vob_state = VOB_STATE_DISCONNECTED; - // play the disconnected sound - app_voice_report(APP_STATUS_INDICATION_DISCONNECTED, 0); + // stop raw data xfer + BLE_control_raw_data_xfer(false); - // stop the voice stream if it's in progress - if (VOB_STATE_VOICE_STREAM == vob_state) - { - if (VOB_ROLE_SRC == vob_role) - { - vob_stop_mic_input_stream(); - } - else - { - vob_stop_speaker_output_stream(); - } + // play the disconnected sound + app_voice_report(APP_STATUS_INDICATION_DISCONNECTED, 0); + + // stop the voice stream if it's in progress + if (VOB_STATE_VOICE_STREAM == vob_state) { + if (VOB_ROLE_SRC == vob_role) { + vob_stop_mic_input_stream(); + } else { + vob_stop_speaker_output_stream(); } + } - if (VOB_ROLE_SRC == vob_role) - { - // try to re-connect - vob_start_connecting(); - } - else - { - // re-start advertising - vob_start_advertising(); - } + if (VOB_ROLE_SRC == vob_role) { + // try to re-connect + vob_start_connecting(); + } else { + // re-start advertising + vob_start_advertising(); + } } /** @@ -854,44 +812,32 @@ void vob_disconnected_evt_handler(void) * @param argument Parameter imported during the thread creation. * */ -static void ble_app_thread(void const *argument) -{ - while(1) - { - osEvent evt; - // wait any signal - evt = osSignalWait(0x0, osWaitForever); +static void ble_app_thread(void const *argument) { + while (1) { + osEvent evt; + // wait any signal + evt = osSignalWait(0x0, osWaitForever); - // get role from signal value - if (evt.status == osEventSignal) - { - if (evt.value.signals & BLE_SIGNAL_VOB_GET_ENCODED_AUDIO_DATA) - { - vob_send_encoded_audio_data(); - break; - } - else if (evt.value.signals & BLE_SIGNAL_VOB_DATA_SENT_OUT) - { - vob_data_sent_out_handler(); - break; - } - else if (evt.value.signals & BLE_SIGNAL_VOB_RECEIVED_DATA) - { - vob_data_reiceived_handler(); - break; - } - else if (evt.value.signals & BLE_SIGNAL_VOB_CONNECTED) - { - vob_connected_evt_handler(); - break; - } - else if (evt.value.signals & BLE_SIGNAL_VOB_DISCONNECTED) - { - vob_disconnected_evt_handler(); - break; - } - } - } + // get role from signal value + if (evt.status == osEventSignal) { + if (evt.value.signals & BLE_SIGNAL_VOB_GET_ENCODED_AUDIO_DATA) { + vob_send_encoded_audio_data(); + break; + } else if (evt.value.signals & BLE_SIGNAL_VOB_DATA_SENT_OUT) { + vob_data_sent_out_handler(); + break; + } else if (evt.value.signals & BLE_SIGNAL_VOB_RECEIVED_DATA) { + vob_data_reiceived_handler(); + break; + } else if (evt.value.signals & BLE_SIGNAL_VOB_CONNECTED) { + vob_connected_evt_handler(); + break; + } else if (evt.value.signals & BLE_SIGNAL_VOB_DISCONNECTED) { + vob_disconnected_evt_handler(); + break; + } + } + } } /** @@ -900,14 +846,13 @@ static void ble_app_thread(void const *argument) * @return 0 if successful, -1 if failed * */ -int ble_app_init(void) -{ - ble_app_tid = osThreadCreate(osThread(ble_app_thread), NULL); - if (ble_app_tid == NULL) { - TRACE(0,"Failed to Create ble_app_thread\n"); - return 0; - } - return 0; +int ble_app_init(void) { + ble_app_tid = osThreadCreate(osThread(ble_app_thread), NULL); + if (ble_app_tid == NULL) { + TRACE(0, "Failed to Create ble_app_thread\n"); + return 0; + } + return 0; } /** @@ -916,42 +861,40 @@ int ble_app_init(void) * @param n Parameter imported during the timer creation osTimerCreate. * */ -static void connecting_supervisor_timer_cb(void const *n) -{ - if (VOB_STATE_CONNECTING == vob_state) - { - // time-out happens at the time of connecting. - // it means the slave is not present or cannot be connected, so just stop connecting - appm_stop_connecting(); +static void connecting_supervisor_timer_cb(void const *n) { + if (VOB_STATE_CONNECTING == vob_state) { + // time-out happens at the time of connecting. + // it means the slave is not present or cannot be connected, so just stop + // connecting + appm_stop_connecting(); - vob_state = VOB_STATE_STOPPING_CONNECTING; - } + vob_state = VOB_STATE_STOPPING_CONNECTING; + } - osTimerDelete(vob_connecting_supervisor_timer); + osTimerDelete(vob_connecting_supervisor_timer); } /** * @brief Start connecting to DST - * this can happen for two cases: + * this can happen for two cases: * 1. Key press to start connecting * 2. Re-connecting when disconnection happened * */ -void vob_start_connecting(void) -{ - // play the connecting sound - app_voice_report(APP_STATUS_INDICATION_CONNECTING, 0); - - // start connecting - appm_start_connecting(&DST_BLE_BdAddr); +void vob_start_connecting(void) { + // play the connecting sound + app_voice_report(APP_STATUS_INDICATION_CONNECTING, 0); - // create and start a timer to supervise the connecting procedure - vob_connecting_supervisor_timer = - osTimerCreate(osTimer(APP_VOB_CONNECTING_SUPERVISOR_TIMER), osTimerOnce, NULL); + // start connecting + appm_start_connecting(&DST_BLE_BdAddr); - osTimerStart(vob_connecting_supervisor_timer, VOB_CONNECTING_TIMEOUT_IN_MS); + // create and start a timer to supervise the connecting procedure + vob_connecting_supervisor_timer = osTimerCreate( + osTimer(APP_VOB_CONNECTING_SUPERVISOR_TIMER), osTimerOnce, NULL); - vob_state = VOB_STATE_CONNECTING; + osTimerStart(vob_connecting_supervisor_timer, VOB_CONNECTING_TIMEOUT_IN_MS); + + vob_state = VOB_STATE_CONNECTING; } /** @@ -962,211 +905,204 @@ void vob_start_connecting(void) * * @return uint32_t 0 means no error happens */ -static uint32_t vob_voice_data_come(uint8_t* ptrBuf, uint32_t length) -{ - // encode the voice PCM data into cvsd - uint32_t remainingBytesToEncode = length; - uint32_t pcmBytesToEncode; - do - { - pcmBytesToEncode = (remainingBytesToEncode > (MAXNUMOFSAMPLES*src_mic_stream_env.bitNumber/AUD_BITS_8))?\ - (MAXNUMOFSAMPLES*src_mic_stream_env.bitNumber/AUD_BITS_8):remainingBytesToEncode; +static uint32_t vob_voice_data_come(uint8_t *ptrBuf, uint32_t length) { + // encode the voice PCM data into cvsd + uint32_t remainingBytesToEncode = length; + uint32_t pcmBytesToEncode; + do { + pcmBytesToEncode = + (remainingBytesToEncode > + (MAXNUMOFSAMPLES * src_mic_stream_env.bitNumber / AUD_BITS_8)) + ? (MAXNUMOFSAMPLES * src_mic_stream_env.bitNumber / AUD_BITS_8) + : remainingBytesToEncode; - // cvsd's compression ratio is 50% - if ((VOB_PCM_SIZE_TO_AUDIO_SIZE(pcmBytesToEncode) + vob_data_management.encodedDataIndexToFill) > - src_mic_stream_env.encodedDataBufSize) - { - pcmBytesToEncode = VOB_AUDIO_SIZE_TO_PCM_SIZE(src_mic_stream_env.encodedDataBufSize - - vob_data_management.encodedDataIndexToFill); - } + // cvsd's compression ratio is 50% + if ((VOB_PCM_SIZE_TO_AUDIO_SIZE(pcmBytesToEncode) + + vob_data_management.encodedDataIndexToFill) > + src_mic_stream_env.encodedDataBufSize) { + pcmBytesToEncode = VOB_AUDIO_SIZE_TO_PCM_SIZE( + src_mic_stream_env.encodedDataBufSize - + vob_data_management.encodedDataIndexToFill); + } - // encode the PCM data - Pcm8kToCvsd((short *)ptrBuf, vob_data_management.encodedDataBuf + vob_data_management.encodedDataIndexToFill, - pcmBytesToEncode / sizeof(short)); + // encode the PCM data + Pcm8kToCvsd((short *)ptrBuf, + vob_data_management.encodedDataBuf + + vob_data_management.encodedDataIndexToFill, + pcmBytesToEncode / sizeof(short)); - // update the index - ptrBuf += pcmBytesToEncode; - remainingBytesToEncode -= pcmBytesToEncode; - - vob_data_management.encodedDataIndexToFill += VOB_PCM_SIZE_TO_AUDIO_SIZE(pcmBytesToEncode); - - if (src_mic_stream_env.encodedDataBufSize == vob_data_management.encodedDataIndexToFill) - { - vob_data_management.encodedDataIndexToFill = 0; - } - - } while (remainingBytesToEncode > 0); + // update the index + ptrBuf += pcmBytesToEncode; + remainingBytesToEncode -= pcmBytesToEncode; - osMutexWait(vob_env_mutex_id, osWaitForever); + vob_data_management.encodedDataIndexToFill += + VOB_PCM_SIZE_TO_AUDIO_SIZE(pcmBytesToEncode); - // update the bytes to transmit via BLE - vob_data_management.encodedDataLength += VOB_PCM_SIZE_TO_AUDIO_SIZE(length); + if (src_mic_stream_env.encodedDataBufSize == + vob_data_management.encodedDataIndexToFill) { + vob_data_management.encodedDataIndexToFill = 0; + } - osMutexRelease(vob_env_mutex_id); + } while (remainingBytesToEncode > 0); - if ((!vob_data_management.isCachingDone) && - (vob_data_management.encodedDataLength >= src_mic_stream_env.cachedEncodedDataSize)) - { - vob_data_management.isCachingDone = true; - - // inform the ble application thread to send out the encoded data - osSignalSet(ble_app_tid, BLE_SIGNAL_VOB_GET_ENCODED_AUDIO_DATA) - } - return 0; + osMutexWait(vob_env_mutex_id, osWaitForever); + + // update the bytes to transmit via BLE + vob_data_management.encodedDataLength += VOB_PCM_SIZE_TO_AUDIO_SIZE(length); + + osMutexRelease(vob_env_mutex_id); + + if ((!vob_data_management.isCachingDone) && + (vob_data_management.encodedDataLength >= + src_mic_stream_env.cachedEncodedDataSize)) { + vob_data_management.isCachingDone = true; + + // inform the ble application thread to send out the encoded data + osSignalSet(ble_app_tid, BLE_SIGNAL_VOB_GET_ENCODED_AUDIO_DATA) + } + return 0; } /** * @brief Init the MIC and Speaker audio streams * */ -static void vob_init_audio_streams(void) -{ - src_mic_stream_env.bitNumber = VOB_VOICE_BIT_NUMBER; - src_mic_stream_env.sampleRate = VOB_VOICE_SAMPLE_RATE; - src_mic_stream_env.channelCount = AUD_CHANNEL_NUM_1; - src_mic_stream_env.morePcmHandler = vob_voice_data_come; - src_mic_stream_env.pcmDataChunkCount = VOB_VOICE_PCM_DATA_CHUNK_COUNT; - src_mic_stream_env.pcmDataChunkSize = VOB_VOICE_PCM_DATA_CHUNK_SIZE; - src_mic_stream_env.cachedEncodedDataSize = VOB_ENCODED_DATA_CACHE_SIZE; - src_mic_stream_env.encodedDataBufSize = VOB_ENCODED_DATA_STORAGE_BUF_SIZE; +static void vob_init_audio_streams(void) { + src_mic_stream_env.bitNumber = VOB_VOICE_BIT_NUMBER; + src_mic_stream_env.sampleRate = VOB_VOICE_SAMPLE_RATE; + src_mic_stream_env.channelCount = AUD_CHANNEL_NUM_1; + src_mic_stream_env.morePcmHandler = vob_voice_data_come; + src_mic_stream_env.pcmDataChunkCount = VOB_VOICE_PCM_DATA_CHUNK_COUNT; + src_mic_stream_env.pcmDataChunkSize = VOB_VOICE_PCM_DATA_CHUNK_SIZE; + src_mic_stream_env.cachedEncodedDataSize = VOB_ENCODED_DATA_CACHE_SIZE; + src_mic_stream_env.encodedDataBufSize = VOB_ENCODED_DATA_STORAGE_BUF_SIZE; - dst_speaker_stream_env.bitNumber = VOB_VOICE_BIT_NUMBER; - dst_speaker_stream_env.sampleRate = VOB_VOICE_SAMPLE_RATE; - dst_speaker_stream_env.channelCount = AUD_CHANNEL_NUM_2; - dst_speaker_stream_env.morePcmHandler = vob_need_more_voice_data; - dst_speaker_stream_env.pcmDataChunkCount = VOB_VOICE_PCM_DATA_CHUNK_COUNT; - dst_speaker_stream_env.pcmDataChunkSize = VOB_VOICE_PCM_DATA_CHUNK_SIZE; - dst_speaker_stream_env.cachedEncodedDataSize = VOB_ENCODED_DATA_CACHE_SIZE; - dst_speaker_stream_env.encodedDataBufSize = VOB_ENCODED_DATA_STORAGE_BUF_SIZE; + dst_speaker_stream_env.bitNumber = VOB_VOICE_BIT_NUMBER; + dst_speaker_stream_env.sampleRate = VOB_VOICE_SAMPLE_RATE; + dst_speaker_stream_env.channelCount = AUD_CHANNEL_NUM_2; + dst_speaker_stream_env.morePcmHandler = vob_need_more_voice_data; + dst_speaker_stream_env.pcmDataChunkCount = VOB_VOICE_PCM_DATA_CHUNK_COUNT; + dst_speaker_stream_env.pcmDataChunkSize = VOB_VOICE_PCM_DATA_CHUNK_SIZE; + dst_speaker_stream_env.cachedEncodedDataSize = VOB_ENCODED_DATA_CACHE_SIZE; + dst_speaker_stream_env.encodedDataBufSize = VOB_ENCODED_DATA_STORAGE_BUF_SIZE; } /** * @brief Start the voice input stream from the MIC * */ -void vob_kick_off_mic_input_stream(void) -{ - // prepare the memory buffer - app_audio_mempool_init(); - // PCM data buffer - app_audio_mempool_get_buff(&(src_mic_stream_env.pcmDataBuf), - src_mic_stream_env.pcmDataChunkCount*src_mic_stream_env.pcmDataChunkSize); - - // encoded data buffer - app_audio_mempool_get_buff(&(src_mic_stream_env.encodedDataBuf), - src_mic_stream_env.encodedDataBufSize); +void vob_kick_off_mic_input_stream(void) { + // prepare the memory buffer + app_audio_mempool_init(); + // PCM data buffer + app_audio_mempool_get_buff(&(src_mic_stream_env.pcmDataBuf), + src_mic_stream_env.pcmDataChunkCount * + src_mic_stream_env.pcmDataChunkSize); - // encoded data queue - APP_AUDIO_InitCQueue(&(src_mic_stream_env.queue), src_mic_stream_env.encodedDataBufSize, - src_mic_stream_env.encodedDataBuf); - - // acuqire the sufficient system clock - app_sysfreq_req(APP_SYSFREQ_VOICE_OVER_BLE, APP_SYSFREQ_26M); + // encoded data buffer + app_audio_mempool_get_buff(&(src_mic_stream_env.encodedDataBuf), + src_mic_stream_env.encodedDataBufSize); - // create the audio flinger stream - struct AF_STREAM_CONFIG_T stream_cfg; - - stream_cfg.bits = src_mic_stream_env.bitNumber; - stream_cfg.sample_rate = src_mic_stream_env.sampleRate; - stream_cfg.channel_num = src_mic_stream_env.channelCount; - stream_cfg.vol = VOB_VOICE_VOLUME; + // encoded data queue + APP_AUDIO_InitCQueue(&(src_mic_stream_env.queue), + src_mic_stream_env.encodedDataBufSize, + src_mic_stream_env.encodedDataBuf); - stream_cfg.device = AUD_STREAM_USE_OPTIMIZED_STREAM; + // acuqire the sufficient system clock + app_sysfreq_req(APP_SYSFREQ_VOICE_OVER_BLE, APP_SYSFREQ_26M); - stream_cfg.io_path = AUD_INPUT_PATH_MAINMIC; - stream_cfg.handler = src_mic_stream_env.morePcmHandler; + // create the audio flinger stream + struct AF_STREAM_CONFIG_T stream_cfg; - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(src_mic_stream_env.pcmDataBuf); - stream_cfg.data_size = src_mic_stream_env.pcmDataChunkSize; - - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + stream_cfg.bits = src_mic_stream_env.bitNumber; + stream_cfg.sample_rate = src_mic_stream_env.sampleRate; + stream_cfg.channel_num = src_mic_stream_env.channelCount; + stream_cfg.vol = VOB_VOICE_VOLUME; + + stream_cfg.device = AUD_STREAM_USE_OPTIMIZED_STREAM; + + stream_cfg.io_path = AUD_INPUT_PATH_MAINMIC; + stream_cfg.handler = src_mic_stream_env.morePcmHandler; + + stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(src_mic_stream_env.pcmDataBuf); + stream_cfg.data_size = src_mic_stream_env.pcmDataChunkSize; + + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); } /** * @brief Start the voice stream, this can only be triggered by SRC * */ -static void vob_start_voice_stream(void) -{ - BLE_send_custom_command(OP_VOB_CMD_START_VOICE_STREAM, NULL, 0); +static void vob_start_voice_stream(void) { + BLE_send_custom_command(OP_VOB_CMD_START_VOICE_STREAM, NULL, 0); } /** - * @brief Callback function called when the BLE activity(adv/connecting/scanning is stopped) + * @brief Callback function called when the BLE activity(adv/connecting/scanning + * is stopped) * */ -static void vob_ble_activity_stopped(void) -{ - if (VOB_STATE_STOPPING_ADV == vob_state) - { - vob_state = VOB_STATE_ADV_STOPPED; +static void vob_ble_activity_stopped(void) { + if (VOB_STATE_STOPPING_ADV == vob_state) { + vob_state = VOB_STATE_ADV_STOPPED; - // should switch to connecting state - vob_switch_state_handler(); - } - else if (VOB_STATE_STOPPING_CONNECTING == vob_state) - { - // start advertising - vob_start_advertising(); - } + // should switch to connecting state + vob_switch_state_handler(); + } else if (VOB_STATE_STOPPING_CONNECTING == vob_state) { + // start advertising + vob_start_advertising(); + } } /** * @brief The handler of switching VOB state * */ -void vob_switch_state_handler(void) -{ - switch (vob_state) - { - case VOB_STATE_ADV_STOPPED: - { - if (VOB_ROLE_SRC == vob_role) - { - // start connecting - vob_start_connecting(); - } - break; - } - case VOB_STATE_CONNECTED: - { - // start voice stream - vob_start_voice_stream(); - break; - } - case VOB_STATE_VOICE_STREAM: - { - // stop voice stream - vob_stop_voice_stream(); - break; - } +void vob_switch_state_handler(void) { + switch (vob_state) { + case VOB_STATE_ADV_STOPPED: { + if (VOB_ROLE_SRC == vob_role) { + // start connecting + vob_start_connecting(); } + break; + } + case VOB_STATE_CONNECTED: { + // start voice stream + vob_start_voice_stream(); + break; + } + case VOB_STATE_VOICE_STREAM: { + // stop voice stream + vob_stop_voice_stream(); + break; + } + } } /** * @brief Process the message sent to the VOB application thread * */ -static int voice_over_ble_handler(APP_MESSAGE_BODY *msg_body) -{ - switch (msg_body->message_id) - { - case VOB_START_AS_SRC: - // change role - vob_role = VOB_ROLE_SRC; - // stop advertising, and start connecting when adv is stopped - appm_stop_advertising(); - // change state - vob_state = VOB_STATE_STOPPING_ADV; - break; - case VOB_SWITCH_STATE: - vob_switch_state_handler(); - break; - default: - break; - } - return 0; +static int voice_over_ble_handler(APP_MESSAGE_BODY *msg_body) { + switch (msg_body->message_id) { + case VOB_START_AS_SRC: + // change role + vob_role = VOB_ROLE_SRC; + // stop advertising, and start connecting when adv is stopped + appm_stop_advertising(); + // change state + vob_state = VOB_STATE_STOPPING_ADV; + break; + case VOB_SWITCH_STATE: + vob_switch_state_handler(); + break; + default: + break; + } + return 0; } /** @@ -1177,54 +1113,54 @@ static int voice_over_ble_handler(APP_MESSAGE_BODY *msg_body) * @param paramLen Length of the parameter in bytes * */ -void notify_vob(VOB_MESSAGE_ID_E message, uint8_t* ptrParam, uint32_t paramLen) -{ - APP_MESSAGE_BLOCK msg; +void notify_vob(VOB_MESSAGE_ID_E message, uint8_t *ptrParam, + uint32_t paramLen) { + APP_MESSAGE_BLOCK msg; - msg.mod_id = APP_MODUAL_VOB; + msg.mod_id = APP_MODUAL_VOB; - msg.msg_body.message_id = message; + msg.msg_body.message_id = message; - /**< reserved for future usage */ - // ASSERT(paramLen <= 8, "The parameter length %d exceeds the maximum supported length 8!", paramLen); - // memcpy((uint8_t *)&(msg.msg_body.message_Param0), ptrParam, paramLen); - - app_mailbox_put(&msg); + /**< reserved for future usage */ + // ASSERT(paramLen <= 8, "The parameter length %d exceeds the maximum + // supported length 8!", paramLen); memcpy((uint8_t + // *)&(msg.msg_body.message_Param0), ptrParam, paramLen); + + app_mailbox_put(&msg); } /** * @brief Initialize the voice over BLE system * */ -void voice_over_ble_init(void) -{ - // create the mutext - vob_env_mutex_id = osMutexCreate((osMutex(vob_env_mutex))); +void voice_over_ble_init(void) { + // create the mutext + vob_env_mutex_id = osMutexCreate((osMutex(vob_env_mutex))); - // initialize the audio streams - vob_init_audio_streams(); - - // initialize the state machine - vob_state = VOB_STATE_IDLE; + // initialize the audio streams + vob_init_audio_streams(); - // thread id used for os signal communication between VOB thread and BLE thread - vob_ThreadId = osThreadGetId(); - - // add the voice over ble handler into the application thread - app_set_threadhandle(APP_MODUAL_VOB, voice_over_ble_handler); - - // initialize the cvsd library - Pcm8k_CvsdInit(); - - // default role is DST - vob_role = VOB_ROLE_DST; + // initialize the state machine + vob_state = VOB_STATE_IDLE; - // register the BLE adv and connecting activity stopped callback function - app_datapath_server_register_activity_stopped_cb(vob_ble_activity_stopped); - - // start advertising if DST - vob_start_advertising(); + // thread id used for os signal communication between VOB thread and BLE + // thread + vob_ThreadId = osThreadGetId(); + + // add the voice over ble handler into the application thread + app_set_threadhandle(APP_MODUAL_VOB, voice_over_ble_handler); + + // initialize the cvsd library + Pcm8k_CvsdInit(); + + // default role is DST + vob_role = VOB_ROLE_DST; + + // register the BLE adv and connecting activity stopped callback function + app_datapath_server_register_activity_stopped_cb(vob_ble_activity_stopped); + + // start advertising if DST + vob_start_advertising(); } #endif // #if __VOICE_OVER_BLE_ENABLED__ - diff --git a/services/ble_app/app_voice/app_voicepath_ble.c b/services/ble_app/app_voice/app_voicepath_ble.c index 141b67e..30a8bc2 100644 --- a/services/ble_app/app_voice/app_voicepath_ble.c +++ b/services/ble_app/app_voice/app_voicepath_ble.c @@ -1,30 +1,30 @@ /*************************************************************************** -* -*Copyright 2015-2019 BES. -*All rights reserved. All unpublished rights reserved. -* -*No part of this work may be used or reproduced in any form or by any -*means, or stored in a database or retrieval system, without prior written -*permission of BES. -* -*Use of this work is governed by a license granted by BES. -*This work contains confidential and proprietary information of -*BES. which is protected by copyright, trade secret, -*trademark and other intellectual property rights. -* -****************************************************************************/ + * + *Copyright 2015-2019 BES. + *All rights reserved. All unpublished rights reserved. + * + *No part of this work may be used or reproduced in any form or by any + *means, or stored in a database or retrieval system, without prior written + *permission of BES. + * + *Use of this work is governed by a license granted by BES. + *This work contains confidential and proprietary information of + *BES. which is protected by copyright, trade secret, + *trademark and other intellectual property rights. + * + ****************************************************************************/ /*****************************header include********************************/ -#include "cmsis_os.h" -#include "rwip_config.h" -#include "ke_msg.h" -#include "att.h" -#include "gapm_task.h" #include "app_voicepath_ble.h" +#include "att.h" +#include "cmsis_os.h" +#include "gapm_task.h" +#include "ke_msg.h" +#include "rwip_config.h" #ifdef BISTO_ENABLED -#include "gsound_gatt_server.h" #include "gsound_custom_ble.h" +#include "gsound_gatt_server.h" #endif /************************private macro defination***************************/ @@ -36,116 +36,93 @@ /************************private variable defination************************/ /****************************function defination****************************/ -void app_ble_voicepath_init(void) -{ - app_gsound_ble_init(); +void app_ble_voicepath_init(void) { app_gsound_ble_init(); } + +const struct ke_state_handler *app_voicepath_ble_get_msg_handler_table(void) { + return gsound_ble_get_msg_handler_table(); } -const struct ke_state_handler *app_voicepath_ble_get_msg_handler_table(void) -{ - return gsound_ble_get_msg_handler_table(); +void app_ble_voicepath_add_svc(void) { return app_gsound_ble_add_svc(); } + +const struct prf_task_cbs *voicepath_prf_itf_get(void) { + return gsound_prf_itf_get(); } -void app_ble_voicepath_add_svc(void) -{ - return app_gsound_ble_add_svc(); -} +void app_ble_bms_add_svc(void) { -const struct prf_task_cbs *voicepath_prf_itf_get(void) -{ - return gsound_prf_itf_get(); -} + // Register the BMS service + struct gapm_profile_task_add_cmd *req = + KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, TASK_GAPM, TASK_APP, + gapm_profile_task_add_cmd, 0); -void app_ble_bms_add_svc(void) -{ - - // Register the BMS service - struct gapm_profile_task_add_cmd *req = KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, - TASK_GAPM, - TASK_APP, - gapm_profile_task_add_cmd, - 0); - - req->operation = GAPM_PROFILE_TASK_ADD; + req->operation = GAPM_PROFILE_TASK_ADD; #if BLE_CONNECTION_MAX > 1 - req->sec_lvl = PERM(SVC_AUTH, SEC_CON) | PERM(SVC_MI, ENABLE); + req->sec_lvl = PERM(SVC_AUTH, SEC_CON) | PERM(SVC_MI, ENABLE); #else - req->sec_lvl = PERM(SVC_AUTH, SEC_CON); + req->sec_lvl = PERM(SVC_AUTH, SEC_CON); #endif - req->prf_task_id = TASK_ID_BMS; - req->app_task = TASK_APP; - req->start_hdl = 0; + req->prf_task_id = TASK_ID_BMS; + req->app_task = TASK_APP; + req->start_hdl = 0; - ke_msg_send(req); + ke_msg_send(req); } #if (ANCS_PROXY_ENABLE) -void app_ble_ancsp_add_svc(void) -{ - TRACE(0,"Registering ANCS Proxy GATT Service"); - struct gapm_profile_task_add_cmd *req = - KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, - TASK_GAPM, - TASK_APP, - gapm_profile_task_add_cmd, - 0); +void app_ble_ancsp_add_svc(void) { + TRACE(0, "Registering ANCS Proxy GATT Service"); + struct gapm_profile_task_add_cmd *req = + KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, TASK_GAPM, TASK_APP, + gapm_profile_task_add_cmd, 0); - req->operation = GAPM_PROFILE_TASK_ADD; + req->operation = GAPM_PROFILE_TASK_ADD; #if BLE_CONNECTION_MAX > 1 - req->sec_lvl = PERM(SVC_AUTH, SEC_CON) | PERM(SVC_MI, ENABLE); + req->sec_lvl = PERM(SVC_AUTH, SEC_CON) | PERM(SVC_MI, ENABLE); #else - req->sec_lvl = PERM(SVC_AUTH, SEC_CON); + req->sec_lvl = PERM(SVC_AUTH, SEC_CON); #endif - req->prf_task_id = TASK_ID_ANCSP; - req->app_task = TASK_APP; - req->start_hdl = 0; + req->prf_task_id = TASK_ID_ANCSP; + req->app_task = TASK_APP; + req->start_hdl = 0; - ke_msg_send(req); + ke_msg_send(req); } -void app_ble_amsp_add_svc(void) -{ - TRACE(0,"Registering AMS Proxy GATT Service"); - struct gapm_profile_task_add_cmd *req = - KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, - TASK_GAPM, - TASK_APP, - gapm_profile_task_add_cmd, - 0); +void app_ble_amsp_add_svc(void) { + TRACE(0, "Registering AMS Proxy GATT Service"); + struct gapm_profile_task_add_cmd *req = + KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, TASK_GAPM, TASK_APP, + gapm_profile_task_add_cmd, 0); - req->operation = GAPM_PROFILE_TASK_ADD; + req->operation = GAPM_PROFILE_TASK_ADD; #if BLE_CONNECTION_MAX > 1 - req->sec_lvl = PERM(SVC_AUTH, ENABLE) | PERM(SVC_MI, ENABLE); + req->sec_lvl = PERM(SVC_AUTH, ENABLE) | PERM(SVC_MI, ENABLE); #else - req->sec_lvl = PERM(SVC_AUTH, ENABLE); + req->sec_lvl = PERM(SVC_AUTH, ENABLE); #endif - req->prf_task_id = TASK_ID_AMSP; - req->app_task = TASK_APP; - req->start_hdl = 0; + req->prf_task_id = TASK_ID_AMSP; + req->app_task = TASK_APP; + req->start_hdl = 0; - ke_msg_send(req); + ke_msg_send(req); } #endif -void app_voicepath_mtu_exchanged_handler(uint8_t conidx, uint16_t MTU) -{ - app_gsound_ble_mtu_exchanged_handler(conidx, MTU); +void app_voicepath_mtu_exchanged_handler(uint8_t conidx, uint16_t MTU) { + app_gsound_ble_mtu_exchanged_handler(conidx, MTU); } -void app_voicepath_disconnected_evt_handler(uint8_t conidx) -{ - if (app_gsound_ble_get_connection_index() == conidx) - { - app_gsound_ble_disconnected_evt_handler(conidx); - } - else - { - TRACE(2,"disconnect idx:%d, gsound idx:%d", conidx, app_gsound_ble_get_connection_index()); - } +void app_voicepath_disconnected_evt_handler(uint8_t conidx) { + if (app_gsound_ble_get_connection_index() == conidx) { + app_gsound_ble_disconnected_evt_handler(conidx); + } else { + TRACE(2, "disconnect idx:%d, gsound idx:%d", conidx, + app_gsound_ble_get_connection_index()); + } } void app_voicepath_ble_conn_parameter_updated(uint8_t conidx, - uint16_t connInterval, uint16_t connSlavelatency) -{ - gsound_ble_conn_parameter_updated(conidx, connInterval, connSlavelatency); + uint16_t connInterval, + uint16_t connSlavelatency) { + gsound_ble_conn_parameter_updated(conidx, connInterval, connSlavelatency); } \ No newline at end of file diff --git a/services/ble_profiles/ams/amsc/amsc.c b/services/ble_profiles/ams/amsc/amsc.c index 1936b69..4fcae45 100644 --- a/services/ble_profiles/ams/amsc/amsc.c +++ b/services/ble_profiles/ams/amsc/amsc.c @@ -14,8 +14,6 @@ * ****************************************************************************/ - - /** **************************************************************************************** * @addtogroup AMSC @@ -27,15 +25,15 @@ * INCLUDE FILES **************************************************************************************** */ - + #include "rwip_config.h" #if (BLE_AMS_CLIENT) #include "ams_common.h" #include "amsc.h" #include "amsc_task.h" -#include "ke_timer.h" #include "ke_mem.h" +#include "ke_timer.h" /** **************************************************************************************** @@ -49,44 +47,49 @@ * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t amsc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t idx; - //-------------------- allocate memory required for the profile --------------------- +static uint8_t amsc_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t idx; + //-------------------- allocate memory required for the profile + //--------------------- - BLE_FUNC_ENTER(); + BLE_FUNC_ENTER(); - struct amsc_env_tag* amsc_env = - (struct amsc_env_tag* ) ke_malloc(sizeof(struct amsc_env_tag), KE_MEM_ATT_DB); + struct amsc_env_tag *amsc_env = (struct amsc_env_tag *)ke_malloc( + sizeof(struct amsc_env_tag), KE_MEM_ATT_DB); - // allocate AMSC required environment variable - env->env = (prf_env_t*) amsc_env; + // allocate AMSC required environment variable + env->env = (prf_env_t *)amsc_env; - amsc_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - amsc_env->prf_env.prf_task = env->task | - (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); + amsc_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + amsc_env->prf_env.prf_task = + env->task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); - // initialize environment variable - env->id = TASK_ID_AMSC; - amsc_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_AMSC; + amsc_task_init(&(env->desc)); - for(idx = 0; idx < AMSC_IDX_MAX ; idx++) - { - amsc_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), AMSC_FREE); - } + for (idx = 0; idx < AMSC_IDX_MAX; idx++) { + amsc_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), AMSC_FREE); + } - return GAP_ERR_NO_ERROR; + return GAP_ERR_NO_ERROR; } /** @@ -98,47 +101,45 @@ static uint8_t amsc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t * @param[in] reason Detach reason **************************************************************************************** */ -static void amsc_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct amsc_env_tag* amsc_env = (struct amsc_env_tag*) env->env; +static void amsc_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct amsc_env_tag *amsc_env = (struct amsc_env_tag *)env->env; - BLE_FUNC_ENTER(); + BLE_FUNC_ENTER(); - // clean-up environment variable allocated for task instance - if(amsc_env->env[conidx] != NULL) - { - ke_timer_clear(AMSC_TIMEOUT_TIMER_IND, prf_src_task_get(&amsc_env->prf_env, conidx)); - ke_free(amsc_env->env[conidx]); - amsc_env->env[conidx] = NULL; - } + // clean-up environment variable allocated for task instance + if (amsc_env->env[conidx] != NULL) { + ke_timer_clear(AMSC_TIMEOUT_TIMER_IND, + prf_src_task_get(&amsc_env->prf_env, conidx)); + ke_free(amsc_env->env[conidx]); + amsc_env->env[conidx] = NULL; + } - /* Put AMS Client in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), AMSC_FREE); + /* Put AMS Client in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), AMSC_FREE); } /** **************************************************************************************** * @brief Destruction of the AMSC module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void amsc_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct amsc_env_tag* amsc_env = (struct amsc_env_tag*) env->env; +static void amsc_destroy(struct prf_task_env *env) { + uint8_t idx; + struct amsc_env_tag *amsc_env = (struct amsc_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < AMSC_IDX_MAX ; idx++) - { - amsc_cleanup(env, idx, 0); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < AMSC_IDX_MAX; idx++) { + amsc_cleanup(env, idx, 0); + } - // free profile environment variables - env->env = NULL; - ke_free(amsc_env); + // free profile environment variables + env->env = NULL; + ke_free(amsc_env); } /** @@ -149,38 +150,33 @@ static void amsc_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void amsc_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Put AMS Client in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), AMSC_IDLE); +static void amsc_create(struct prf_task_env *env, uint8_t conidx) { + /* Put AMS Client in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), AMSC_IDLE); } /// AMSC Task interface required by profile manager -const struct prf_task_cbs amsc_itf = -{ - amsc_init, - amsc_destroy, - amsc_create, - amsc_cleanup, +const struct prf_task_cbs amsc_itf = { + amsc_init, + amsc_destroy, + amsc_create, + amsc_cleanup, }; -const struct prf_task_cbs* amsc_prf_itf_get(void) -{ - return &amsc_itf; -} +const struct prf_task_cbs *amsc_prf_itf_get(void) { return &amsc_itf; } -void amsc_enable_rsp_send(struct amsc_env_tag *amsc_env, uint8_t conidx, uint8_t status) -{ - BLE_FUNC_ENTER(); - - //ASSERT(status == GAP_ERR_NO_ERROR, "%s error %d", __func__, status); - if (status == GAP_ERR_NO_ERROR) - { - // Register AMSC task in gatt for indication/notifications - prf_register_atthdl2gatt(&(amsc_env->prf_env), conidx, &(amsc_env->env[conidx]->ams.svc)); - // Go to connected state - ke_state_set(prf_src_task_get(&(amsc_env->prf_env), conidx), AMSC_IDLE); - } +void amsc_enable_rsp_send(struct amsc_env_tag *amsc_env, uint8_t conidx, + uint8_t status) { + BLE_FUNC_ENTER(); + + // ASSERT(status == GAP_ERR_NO_ERROR, "%s error %d", __func__, status); + if (status == GAP_ERR_NO_ERROR) { + // Register AMSC task in gatt for indication/notifications + prf_register_atthdl2gatt(&(amsc_env->prf_env), conidx, + &(amsc_env->env[conidx]->ams.svc)); + // Go to connected state + ke_state_set(prf_src_task_get(&(amsc_env->prf_env), conidx), AMSC_IDLE); + } } #endif //(BLE_AMS_CLIENT) diff --git a/services/ble_profiles/ams/amsc/amsc_task.c b/services/ble_profiles/ams/amsc/amsc_task.c index ed518ea..7e6433d 100644 --- a/services/ble_profiles/ams/amsc/amsc_task.c +++ b/services/ble_profiles/ams/amsc/amsc_task.c @@ -14,7 +14,6 @@ * ****************************************************************************/ - /** **************************************************************************************** * @addtogroup AMSCTASK @@ -119,13 +118,12 @@ static int amsc_enable_req_handler(ke_msg_id_t const msgid, // Get connection index uint8_t conidx = param->conidx; uint8_t state = ke_state_get(dest_id); - TRACE(3,"AMSC %s Entry. state=%d, conidx=%d", - __func__, state, conidx); + TRACE(3, "AMSC %s Entry. state=%d, conidx=%d", __func__, state, conidx); - TRACE(3,"AMSC %s amsc_env->env[%d] = 0x%8.8x", __func__, conidx, + TRACE(3, "AMSC %s amsc_env->env[%d] = 0x%8.8x", __func__, conidx, (uint32_t)amsc_env->env[conidx]); if ((state == AMSC_IDLE) && (amsc_env->env[conidx] == NULL)) { - TRACE(1,"AMSC %s passed state check", __func__); + TRACE(1, "AMSC %s passed state check", __func__); // allocate environment variable for task instance amsc_env->env[conidx] = (struct amsc_cnx_env *)ke_malloc( sizeof(struct amsc_cnx_env), KE_MEM_ATT_DB); @@ -172,7 +170,7 @@ static int amsc_read_cmd_handler(ke_msg_id_t const msgid, struct gattc_read_cmd *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { - TRACE(5,"AMSC %s Entry. hdl=0x%4.4x, op=%d, len=%d, off=%d", __func__, + TRACE(5, "AMSC %s Entry. hdl=0x%4.4x, op=%d, len=%d, off=%d", __func__, param->req.simple.handle, param->operation, param->req.simple.length, param->req.simple.offset); @@ -202,17 +200,16 @@ static int gattc_read_ind_handler(ke_msg_id_t const msgid, ke_task_id_t const src_id) { // Get the address of the environment struct amsc_env_tag *amsc_env = PRF_ENV_GET(AMSC, amsc); - TRACE(3,"AMSC %s param->handle=%x param->length=%d", __func__, param->handle, + TRACE(3, "AMSC %s param->handle=%x param->length=%d", __func__, param->handle, param->length); uint8_t conidx = KE_IDX_GET(src_id); if (amsc_env != NULL) { - amsc_last_read_handle = BTIF_INVALID_HCI_HANDLE; - struct gattc_read_cfm *cfm = - KE_MSG_ALLOC_DYN(GATTC_READ_CFM, - KE_BUILD_ID(prf_get_task_from_id(TASK_ID_AMSP), conidx), - dest_id, gattc_read_cfm, param->length); - cfm->status = 0; // read_ind has no status??? + amsc_last_read_handle = BTIF_INVALID_HCI_HANDLE; + struct gattc_read_cfm *cfm = KE_MSG_ALLOC_DYN( + GATTC_READ_CFM, KE_BUILD_ID(prf_get_task_from_id(TASK_ID_AMSP), conidx), + dest_id, gattc_read_cfm, param->length); + cfm->status = 0; // read_ind has no status??? cfm->handle = param->handle; cfm->length = param->length; memcpy(cfm->value, param->value, param->length); @@ -235,8 +232,8 @@ static int amsc_write_cmd_handler(ke_msg_id_t const msgid, struct gattc_write_cmd *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { - TRACE(4,"AMSC %s Entry. hdl=0x%4.4x, op=%d, len=%d", __func__, - param->handle, param->operation, param->length); + TRACE(4, "AMSC %s Entry. hdl=0x%4.4x, op=%d, len=%d", __func__, param->handle, + param->operation, param->length); uint8_t conidx = KE_IDX_GET(dest_id); @@ -246,9 +243,9 @@ static int amsc_write_cmd_handler(ke_msg_id_t const msgid, if (amsc_env != NULL) { amsc_env->last_write_handle[conidx] = param->handle; // TODO(jkessinger): Use ke_msg_forward. - struct gattc_write_cmd *wr_char = KE_MSG_ALLOC_DYN( - GATTC_WRITE_CMD, KE_BUILD_ID(TASK_GATTC, conidx), - dest_id, gattc_write_cmd, param->length); + struct gattc_write_cmd *wr_char = + KE_MSG_ALLOC_DYN(GATTC_WRITE_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + dest_id, gattc_write_cmd, param->length); memcpy(wr_char, param, sizeof(struct gattc_write_cmd) + param->length); // Send the message ke_msg_send(wr_char); @@ -278,14 +275,17 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, ke_task_id_t const src_id) { uint8_t state = ke_state_get(dest_id); - TRACE(4,"AMSC %s Entry. end_hdl=0x%4.4x, start_hdl=0x%4.4x, att.att_type=%d", - __func__, ind->end_hdl, ind->start_hdl, ind->info[0].att.att_type); - TRACE(3,"AMSC att_char.prop=%d, att_char.handle=0x%4.4x, att_char.att_type=%d", - ind->info[0].att_char.prop, ind->info[0].att_char.handle, - ind->info[0].att_char.att_type); - TRACE(4,"AMSC inc_svc.att_type=%d, inc_svc.end_hdl=0x%4.4x, inc_svc.start_hdl=0x%4.4x, state=%d", - ind->info[0].att_type, ind->info[0].inc_svc.att_type, - ind->info[0].inc_svc.start_hdl, state); + TRACE(4, "AMSC %s Entry. end_hdl=0x%4.4x, start_hdl=0x%4.4x, att.att_type=%d", + __func__, ind->end_hdl, ind->start_hdl, ind->info[0].att.att_type); + TRACE(3, + "AMSC att_char.prop=%d, att_char.handle=0x%4.4x, att_char.att_type=%d", + ind->info[0].att_char.prop, ind->info[0].att_char.handle, + ind->info[0].att_char.att_type); + TRACE(4, + "AMSC inc_svc.att_type=%d, inc_svc.end_hdl=0x%4.4x, " + "inc_svc.start_hdl=0x%4.4x, state=%d", + ind->info[0].att_type, ind->info[0].inc_svc.att_type, + ind->info[0].inc_svc.start_hdl, state); if (state == AMSC_DISCOVERING) { uint8_t conidx = KE_IDX_GET(src_id); @@ -296,7 +296,7 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, ASSERT_INFO(amsc_env->env[conidx] != NULL, dest_id, src_id); if (amsc_env->env[conidx]->nb_svc == 0) { - TRACE(0,"AMSC retrieving characteristics and descriptors."); + TRACE(0, "AMSC retrieving characteristics and descriptors."); // Retrieve AMS characteristics and descriptors prf_extract_svc_info_128(ind, AMSC_CHAR_MAX, &amsc_ams_char[0], &amsc_env->env[conidx]->ams.chars[0], @@ -331,15 +331,15 @@ static int amsc_gattc_cmp_evt_handler(ke_msg_id_t const msgid, // Get the address of the environment struct amsc_env_tag *amsc_env = PRF_ENV_GET(AMSC, amsc); uint8_t conidx = KE_IDX_GET(dest_id); - TRACE(5,"AMSC %s entry. op=%d, seq=%d, status=%d, conidx=%d", - __func__, param->operation, param->seq_num, param->status, conidx); + TRACE(5, "AMSC %s entry. op=%d, seq=%d, status=%d, conidx=%d", __func__, + param->operation, param->seq_num, param->status, conidx); // Status uint8_t status; if (amsc_env->env[conidx] != NULL) { uint8_t state = ke_state_get(dest_id); - TRACE(2,"AMSC %s state=%d", __func__, state); + TRACE(2, "AMSC %s state=%d", __func__, state); if (state == AMSC_DISCOVERING) { status = param->status; @@ -370,24 +370,26 @@ static int amsc_gattc_cmp_evt_handler(ke_msg_id_t const msgid, amsc_enable_rsp_send(amsc_env, conidx, status); #if (ANCS_PROXY_ENABLE) - TRACE(4,"AMSC %s rmtChar=0x%4.4x, rmtVal=0x%4.4x, rmtCfg=0x%4.4x", - __func__, + TRACE(4, "AMSC %s rmtChar=0x%4.4x, rmtVal=0x%4.4x, rmtCfg=0x%4.4x", + __func__, amsc_env->env[conidx]->ams.chars[AMSC_REMOTE_COMMAND_CHAR].char_hdl, amsc_env->env[conidx]->ams.chars[AMSC_REMOTE_COMMAND_CHAR].val_hdl, amsc_env->env[conidx] ->ams.descs[AMSC_DESC_REMOTE_CMD_CL_CFG] .desc_hdl); - TRACE(4,"AMSC %s EnUpChar=0x%4.4x EnUpVal=0x%4.4x, EnUpCfg=0x%4.4x", + TRACE(4, "AMSC %s EnUpChar=0x%4.4x EnUpVal=0x%4.4x, EnUpCfg=0x%4.4x", __func__, amsc_env->env[conidx]->ams.chars[AMSC_ENTITY_UPDATE_CHAR].char_hdl, amsc_env->env[conidx]->ams.chars[AMSC_ENTITY_UPDATE_CHAR].val_hdl, amsc_env->env[conidx] ->ams.descs[AMSC_DESC_ENTITY_UPDATE_CL_CFG] .desc_hdl); - TRACE(3,"AMSC %s EnAtrChar=0x%4.4x, EnAtrVal=0x%4.4x", __func__, + TRACE( + 3, "AMSC %s EnAtrChar=0x%4.4x, EnAtrVal=0x%4.4x", __func__, amsc_env->env[conidx]->ams.chars[AMSC_ENTITY_ATTRIBUTE_CHAR].char_hdl, amsc_env->env[conidx]->ams.chars[AMSC_ENTITY_ATTRIBUTE_CHAR].val_hdl); - ams_proxy_set_ready_flag(conidx, + ams_proxy_set_ready_flag( + conidx, amsc_env->env[conidx]->ams.chars[AMSC_REMOTE_COMMAND_CHAR].char_hdl, amsc_env->env[conidx]->ams.chars[AMSC_REMOTE_COMMAND_CHAR].val_hdl, amsc_env->env[conidx] @@ -404,49 +406,50 @@ static int amsc_gattc_cmp_evt_handler(ke_msg_id_t const msgid, #endif } else { switch (param->operation) { - case GATTC_READ: { - TRACE(3,"AMSC %s read complete status=%d amsc_last_read_handle %d", - __func__, param->status, amsc_last_read_handle); - if ((0 != param->status) && - (BTIF_INVALID_HCI_HANDLE != amsc_last_read_handle)) { - struct gattc_read_cfm *cfm = KE_MSG_ALLOC_DYN( - GATTC_READ_CFM, KE_BUILD_ID(prf_get_task_from_id(TASK_ID_AMSP), conidx), - dest_id, - gattc_read_cfm, 0); - cfm->status = 0; - cfm->handle = amsc_last_read_handle; - cfm->length = 0; - ke_msg_send(cfm); - } - amsc_last_read_handle = BTIF_INVALID_HCI_HANDLE; - break; - } - case GATTC_WRITE: { - struct gattc_write_cfm *cfm = - KE_MSG_ALLOC(GATTC_WRITE_CFM, - KE_BUILD_ID(prf_get_task_from_id(TASK_ID_AMSP), conidx), - dest_id, gattc_write_cfm); - cfm->handle = amsc_env->last_write_handle[conidx]; - amsc_env->last_write_handle[conidx] = ATT_INVALID_HANDLE; - cfm->status = param->status; + case GATTC_READ: { + TRACE(3, "AMSC %s read complete status=%d amsc_last_read_handle %d", + __func__, param->status, amsc_last_read_handle); + if ((0 != param->status) && + (BTIF_INVALID_HCI_HANDLE != amsc_last_read_handle)) { + struct gattc_read_cfm *cfm = KE_MSG_ALLOC_DYN( + GATTC_READ_CFM, + KE_BUILD_ID(prf_get_task_from_id(TASK_ID_AMSP), conidx), dest_id, + gattc_read_cfm, 0); + cfm->status = 0; + cfm->handle = amsc_last_read_handle; + cfm->length = 0; ke_msg_send(cfm); - break; } - case GATTC_WRITE_NO_RESPONSE: - // There's currently no need to notify the proxy task that this completed. - break; - case GATTC_NOTIFY: - case GATTC_INDICATE: - // Nothing to do. Notify sent. - case GATTC_REGISTER: - case GATTC_UNREGISTER: - case GATTC_SDP_DISC_SVC: - // Do nothing - break; + amsc_last_read_handle = BTIF_INVALID_HCI_HANDLE; + break; + } + case GATTC_WRITE: { + struct gattc_write_cfm *cfm = KE_MSG_ALLOC( + GATTC_WRITE_CFM, + KE_BUILD_ID(prf_get_task_from_id(TASK_ID_AMSP), conidx), dest_id, + gattc_write_cfm); + cfm->handle = amsc_env->last_write_handle[conidx]; + amsc_env->last_write_handle[conidx] = ATT_INVALID_HANDLE; + cfm->status = param->status; + ke_msg_send(cfm); + break; + } + case GATTC_WRITE_NO_RESPONSE: + // There's currently no need to notify the proxy task that this + // completed. + break; + case GATTC_NOTIFY: + case GATTC_INDICATE: + // Nothing to do. Notify sent. + case GATTC_REGISTER: + case GATTC_UNREGISTER: + case GATTC_SDP_DISC_SVC: + // Do nothing + break; - default: - ASSERT_ERR(0); - break; + default: + ASSERT_ERR(0); + break; } } } @@ -469,14 +472,15 @@ static int gattc_event_ind_handler(ke_msg_id_t const msgid, ke_task_id_t const dest_id, ke_task_id_t const src_id) { BLE_FUNC_ENTER(); - TRACE(5,"AMSC %s Entry. handle=0x%x, len=%d, type=%d, val[0]=0x%x", - __func__, param->handle, param->length, param->type, param->value[0]); + TRACE(5, "AMSC %s Entry. handle=0x%x, len=%d, type=%d, val[0]=0x%x", __func__, + param->handle, param->length, param->type, param->value[0]); uint8_t conidx = KE_IDX_GET(src_id); - + struct gattc_send_evt_cmd *cmd; - cmd = KE_MSG_ALLOC_DYN(AMS_PROXY_IND_EVT, - KE_BUILD_ID(prf_get_task_from_id(TASK_ID_AMSP), conidx), - dest_id, gattc_send_evt_cmd, param->length); + cmd = + KE_MSG_ALLOC_DYN(AMS_PROXY_IND_EVT, + KE_BUILD_ID(prf_get_task_from_id(TASK_ID_AMSP), conidx), + dest_id, gattc_send_evt_cmd, param->length); cmd->handle = param->handle; cmd->operation = GATTC_NOTIFY; cmd->seq_num = 0; @@ -506,7 +510,7 @@ KE_MSG_HANDLER_TAB(amsc){ }; void amsc_task_init(struct ke_task_desc *task_desc) { - TRACE(1,"AMSC %s Entry.", __func__); + TRACE(1, "AMSC %s Entry.", __func__); // Get the address of the environment struct amsc_env_tag *amsc_env = PRF_ENV_GET(AMSC, amsc); @@ -516,6 +520,6 @@ void amsc_task_init(struct ke_task_desc *task_desc) { task_desc->idx_max = AMSC_IDX_MAX; } -#endif //(BLE_AMS_CLIENT) +#endif //(BLE_AMS_CLIENT) /// @} AMSCTASK diff --git a/services/ble_profiles/anc/ancc/ancc.c b/services/ble_profiles/anc/ancc/ancc.c index 6337bc7..9d05240 100644 --- a/services/ble_profiles/anc/ancc/ancc.c +++ b/services/ble_profiles/anc/ancc/ancc.c @@ -14,8 +14,6 @@ * ****************************************************************************/ - - /** **************************************************************************************** * @addtogroup ANCC @@ -27,15 +25,15 @@ * INCLUDE FILES **************************************************************************************** */ - + #include "rwip_config.h" #if (BLE_ANC_CLIENT) #include "anc_common.h" #include "ancc.h" #include "ancc_task.h" -#include "ke_timer.h" #include "ke_mem.h" +#include "ke_timer.h" /** **************************************************************************************** @@ -49,44 +47,49 @@ * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t ancc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t idx; - //-------------------- allocate memory required for the profile --------------------- +static uint8_t ancc_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t idx; + //-------------------- allocate memory required for the profile + //--------------------- - BLE_FUNC_ENTER(); + BLE_FUNC_ENTER(); - struct ancc_env_tag* ancc_env = - (struct ancc_env_tag* ) ke_malloc(sizeof(struct ancc_env_tag), KE_MEM_ATT_DB); + struct ancc_env_tag *ancc_env = (struct ancc_env_tag *)ke_malloc( + sizeof(struct ancc_env_tag), KE_MEM_ATT_DB); - // allocate ANCC required environment variable - env->env = (prf_env_t*) ancc_env; + // allocate ANCC required environment variable + env->env = (prf_env_t *)ancc_env; - ancc_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - ancc_env->prf_env.prf_task = env->task | - (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); + ancc_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + ancc_env->prf_env.prf_task = + env->task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); - // initialize environment variable - env->id = TASK_ID_ANCC; - ancc_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_ANCC; + ancc_task_init(&(env->desc)); - for(idx = 0; idx < ANCC_IDX_MAX ; idx++) - { - ancc_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), ANCC_FREE); - } + for (idx = 0; idx < ANCC_IDX_MAX; idx++) { + ancc_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), ANCC_FREE); + } - return GAP_ERR_NO_ERROR; + return GAP_ERR_NO_ERROR; } /** @@ -98,47 +101,45 @@ static uint8_t ancc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t * @param[in] reason Detach reason **************************************************************************************** */ -static void ancc_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct ancc_env_tag* ancc_env = (struct ancc_env_tag*) env->env; +static void ancc_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct ancc_env_tag *ancc_env = (struct ancc_env_tag *)env->env; - BLE_FUNC_ENTER(); + BLE_FUNC_ENTER(); - // clean-up environment variable allocated for task instance - if(ancc_env->env[conidx] != NULL) - { - ke_timer_clear(ANCC_TIMEOUT_TIMER_IND, prf_src_task_get(&ancc_env->prf_env, conidx)); - ke_free(ancc_env->env[conidx]); - ancc_env->env[conidx] = NULL; - } + // clean-up environment variable allocated for task instance + if (ancc_env->env[conidx] != NULL) { + ke_timer_clear(ANCC_TIMEOUT_TIMER_IND, + prf_src_task_get(&ancc_env->prf_env, conidx)); + ke_free(ancc_env->env[conidx]); + ancc_env->env[conidx] = NULL; + } - /* Put ANC Client in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), ANCC_FREE); + /* Put ANC Client in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), ANCC_FREE); } /** **************************************************************************************** * @brief Destruction of the ANCC module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void ancc_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct ancc_env_tag* ancc_env = (struct ancc_env_tag*) env->env; +static void ancc_destroy(struct prf_task_env *env) { + uint8_t idx; + struct ancc_env_tag *ancc_env = (struct ancc_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < ANCC_IDX_MAX ; idx++) - { - ancc_cleanup(env, idx, 0); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < ANCC_IDX_MAX; idx++) { + ancc_cleanup(env, idx, 0); + } - // free profile environment variables - env->env = NULL; - ke_free(ancc_env); + // free profile environment variables + env->env = NULL; + ke_free(ancc_env); } /** @@ -149,38 +150,33 @@ static void ancc_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void ancc_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Put ANC Client in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), ANCC_IDLE); +static void ancc_create(struct prf_task_env *env, uint8_t conidx) { + /* Put ANC Client in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), ANCC_IDLE); } /// ANCC Task interface required by profile manager -const struct prf_task_cbs ancc_itf = -{ - ancc_init, - ancc_destroy, - ancc_create, - ancc_cleanup, +const struct prf_task_cbs ancc_itf = { + ancc_init, + ancc_destroy, + ancc_create, + ancc_cleanup, }; -const struct prf_task_cbs* ancc_prf_itf_get(void) -{ - return &ancc_itf; -} +const struct prf_task_cbs *ancc_prf_itf_get(void) { return &ancc_itf; } -void ancc_enable_rsp_send(struct ancc_env_tag *ancc_env, uint8_t conidx, uint8_t status) -{ - BLE_FUNC_ENTER(); - - //ASSERT(status == GAP_ERR_NO_ERROR, "%s error %d", __func__, status); - if (status == GAP_ERR_NO_ERROR) - { - // Register ANCC task in gatt for indication/notifications - prf_register_atthdl2gatt(&(ancc_env->prf_env), conidx, &(ancc_env->env[conidx]->anc.svc)); - // Go to connected state - ke_state_set(prf_src_task_get(&(ancc_env->prf_env), conidx), ANCC_IDLE); - } +void ancc_enable_rsp_send(struct ancc_env_tag *ancc_env, uint8_t conidx, + uint8_t status) { + BLE_FUNC_ENTER(); + + // ASSERT(status == GAP_ERR_NO_ERROR, "%s error %d", __func__, status); + if (status == GAP_ERR_NO_ERROR) { + // Register ANCC task in gatt for indication/notifications + prf_register_atthdl2gatt(&(ancc_env->prf_env), conidx, + &(ancc_env->env[conidx]->anc.svc)); + // Go to connected state + ke_state_set(prf_src_task_get(&(ancc_env->prf_env), conidx), ANCC_IDLE); + } } #endif //(BLE_ANC_CLIENT) diff --git a/services/ble_profiles/anc/ancc/ancc_task.c b/services/ble_profiles/anc/ancc/ancc_task.c index 9cc578a..a22aef8 100644 --- a/services/ble_profiles/anc/ancc/ancc_task.c +++ b/services/ble_profiles/anc/ancc/ancc_task.c @@ -14,7 +14,6 @@ * ****************************************************************************/ - /** **************************************************************************************** * @addtogroup ANCCTASK @@ -117,11 +116,10 @@ static int ancc_enable_req_handler(ke_msg_id_t const msgid, // Get connection index uint8_t conidx = param->conidx; uint8_t state = ke_state_get(dest_id); - TRACE(3,"ANCSC %s Entry. state=%d, conidx=%d", - __func__, state, conidx); + TRACE(3, "ANCSC %s Entry. state=%d, conidx=%d", __func__, state, conidx); if ((state == ANCC_IDLE) && (ancc_env->env[conidx] == NULL)) { - TRACE(1,"ANCSC %s passed state check", __func__); + TRACE(1, "ANCSC %s passed state check", __func__); // allocate environment variable for task instance ancc_env->env[conidx] = (struct ancc_cnx_env *)ke_malloc( sizeof(struct ancc_cnx_env), KE_MEM_ATT_DB); @@ -170,9 +168,9 @@ static int ancc_read_cmd_handler(ke_msg_id_t const msgid, ke_task_id_t const src_id) { uint8_t conidx = KE_IDX_GET(dest_id); - TRACE(6,"ANCSC %s Entry. conidex %d hdl=0x%4.4x, op=%d, len=%d, off=%d", __func__, - conidx, param->req.simple.handle, param->operation, param->req.simple.length, - param->req.simple.offset); + TRACE(6, "ANCSC %s Entry. conidex %d hdl=0x%4.4x, op=%d, len=%d, off=%d", + __func__, conidx, param->req.simple.handle, param->operation, + param->req.simple.length, param->req.simple.offset); // Get the address of the environment struct ancc_env_tag *ancc_env = PRF_ENV_GET(ANCC, ancc); @@ -197,16 +195,16 @@ static int gattc_read_ind_handler(ke_msg_id_t const msgid, ke_task_id_t const src_id) { // Get the address of the environment struct amsc_env_tag *amsc_env = PRF_ENV_GET(ANCC, amsc); - TRACE(3,"ANCSC %s param->handle=0x%x param->length=%d", __func__, param->handle, - param->length); - + TRACE(3, "ANCSC %s param->handle=0x%x param->length=%d", __func__, + param->handle, param->length); + if (amsc_env != NULL) { uint8_t conidx = KE_IDX_GET(src_id); - struct gattc_read_cfm *cfm = - KE_MSG_ALLOC_DYN(GATTC_READ_CFM, - KE_BUILD_ID(prf_get_task_from_id(TASK_ID_ANCSP), conidx), - dest_id, gattc_read_cfm, param->length); - cfm->status = 0; // read_ind has no status??? + struct gattc_read_cfm *cfm = KE_MSG_ALLOC_DYN( + GATTC_READ_CFM, + KE_BUILD_ID(prf_get_task_from_id(TASK_ID_ANCSP), conidx), dest_id, + gattc_read_cfm, param->length); + cfm->status = 0; // read_ind has no status??? cfm->handle = param->handle; cfm->length = param->length; memcpy(cfm->value, param->value, param->length); @@ -229,7 +227,7 @@ static int ancc_write_cmd_handler(ke_msg_id_t const msgid, struct gattc_write_cmd *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { - TRACE(4,"ANCSC %s Entry. hdl=0x%4.4x, op=%d, len=%d", __func__, + TRACE(4, "ANCSC %s Entry. hdl=0x%4.4x, op=%d, len=%d", __func__, param->handle, param->operation, param->length); uint8_t conidx = KE_IDX_GET(dest_id); @@ -240,9 +238,9 @@ static int ancc_write_cmd_handler(ke_msg_id_t const msgid, if (ancc_env != NULL) { ancc_env->last_write_handle[conidx] = param->handle; // TODO(jkessinger): Use ke_msg_forward. - struct gattc_write_cmd *wr_char = KE_MSG_ALLOC_DYN( - GATTC_WRITE_CMD, KE_BUILD_ID(TASK_GATTC, conidx), - dest_id, gattc_write_cmd, param->length); + struct gattc_write_cmd *wr_char = + KE_MSG_ALLOC_DYN(GATTC_WRITE_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + dest_id, gattc_write_cmd, param->length); memcpy(wr_char, param, sizeof(struct gattc_write_cmd) + param->length); // Send the message ke_msg_send(wr_char); @@ -272,14 +270,18 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, ke_task_id_t const src_id) { uint8_t state = ke_state_get(dest_id); - TRACE(4,"ANCSC %s Entry. end_hdl=0x%4.4x, start_hdl=0x%4.4x, att.att_type=%d", - __func__, ind->end_hdl, ind->start_hdl, ind->info[0].att.att_type); - TRACE(3,"ANCSC att_char.prop=%d, att_char.handle=0x%4.4x, att_char.att_type=%d", - ind->info[0].att_char.prop, ind->info[0].att_char.handle, - ind->info[0].att_char.att_type); - TRACE(4,"ANCSC inc_svc.att_type=%d, inc_svc.end_hdl=0x%4.4x, inc_svc.start_hdl=0x%4.4x, state=%d", - ind->info[0].att_type, ind->info[0].inc_svc.att_type, - ind->info[0].inc_svc.start_hdl, state); + TRACE(4, + "ANCSC %s Entry. end_hdl=0x%4.4x, start_hdl=0x%4.4x, att.att_type=%d", + __func__, ind->end_hdl, ind->start_hdl, ind->info[0].att.att_type); + TRACE(3, + "ANCSC att_char.prop=%d, att_char.handle=0x%4.4x, att_char.att_type=%d", + ind->info[0].att_char.prop, ind->info[0].att_char.handle, + ind->info[0].att_char.att_type); + TRACE(4, + "ANCSC inc_svc.att_type=%d, inc_svc.end_hdl=0x%4.4x, " + "inc_svc.start_hdl=0x%4.4x, state=%d", + ind->info[0].att_type, ind->info[0].inc_svc.att_type, + ind->info[0].inc_svc.start_hdl, state); if (state == ANCC_DISCOVERING) { uint8_t conidx = KE_IDX_GET(src_id); @@ -290,7 +292,7 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, ASSERT_INFO(ancc_env->env[conidx] != NULL, dest_id, src_id); if (ancc_env->env[conidx]->nb_svc == 0) { - TRACE(0,"ANCSC retrieving characteristics and descriptors."); + TRACE(0, "ANCSC retrieving characteristics and descriptors."); // Retrieve ANC characteristics and descriptors prf_extract_svc_info_128(ind, ANCC_CHAR_MAX, &ancc_anc_char[0], &ancc_env->env[conidx]->anc.chars[0], @@ -325,15 +327,15 @@ static int gattc_cmp_evt_handler(ke_msg_id_t const msgid, // Get the address of the environment struct ancc_env_tag *ancc_env = PRF_ENV_GET(ANCC, ancc); uint8_t conidx = KE_IDX_GET(dest_id); - TRACE(5,"ANCSC %s entry. op=%d, seq=%d, status=%d, conidx=%d", - __func__, param->operation, param->seq_num, param->status, conidx); + TRACE(5, "ANCSC %s entry. op=%d, seq=%d, status=%d, conidx=%d", __func__, + param->operation, param->seq_num, param->status, conidx); // Status uint8_t status; if (ancc_env->env[conidx] != NULL) { uint8_t state = ke_state_get(dest_id); - TRACE(2,"ANCSC %s state=%d", __func__, state); + TRACE(2, "ANCSC %s state=%d", __func__, state); if (state == ANCC_DISCOVERING) { status = param->status; @@ -364,19 +366,21 @@ static int gattc_cmp_evt_handler(ke_msg_id_t const msgid, ancc_enable_rsp_send(ancc_env, conidx, status); #if (ANCS_PROXY_ENABLE) - TRACE(4,"ANCSC %s NSChar=0x%4.4x, NSVal=0x%4.4x, NSCfg=0x%4.4x", __func__, + TRACE( + 4, "ANCSC %s NSChar=0x%4.4x, NSVal=0x%4.4x, NSCfg=0x%4.4x", __func__, ancc_env->env[conidx]->anc.chars[ANCC_CHAR_NTF_SRC].char_hdl, ancc_env->env[conidx]->anc.chars[ANCC_CHAR_NTF_SRC].val_hdl, ancc_env->env[conidx]->anc.descs[ANCC_DESC_NTF_SRC_CL_CFG].desc_hdl); - TRACE(4,"ANCSC %s DSChar=0x%4.4x DSVal=0x%4.4x, DSCfg=0x%4.4x", __func__, + TRACE( + 4, "ANCSC %s DSChar=0x%4.4x DSVal=0x%4.4x, DSCfg=0x%4.4x", __func__, ancc_env->env[conidx]->anc.chars[ANCC_CHAR_DATA_SRC].char_hdl, ancc_env->env[conidx]->anc.chars[ANCC_CHAR_DATA_SRC].val_hdl, ancc_env->env[conidx]->anc.descs[ANCC_DESC_DATA_SRC_CL_CFG].desc_hdl); - TRACE(3,"ANCSC %s CPChar=0x%4.4x, CPVal=0x%4.4x", __func__, + TRACE(3, "ANCSC %s CPChar=0x%4.4x, CPVal=0x%4.4x", __func__, ancc_env->env[conidx]->anc.chars[ANCC_CHAR_CTRL_PT].char_hdl, ancc_env->env[conidx]->anc.chars[ANCC_CHAR_CTRL_PT].val_hdl); - ancs_proxy_set_ready_flag(conidx, - ancc_env->env[conidx]->anc.chars[ANCC_CHAR_NTF_SRC].char_hdl, + ancs_proxy_set_ready_flag( + conidx, ancc_env->env[conidx]->anc.chars[ANCC_CHAR_NTF_SRC].char_hdl, ancc_env->env[conidx]->anc.chars[ANCC_CHAR_NTF_SRC].val_hdl, ancc_env->env[conidx]->anc.descs[ANCC_DESC_NTF_SRC_CL_CFG].desc_hdl, ancc_env->env[conidx]->anc.chars[ANCC_CHAR_DATA_SRC].char_hdl, @@ -388,37 +392,37 @@ static int gattc_cmp_evt_handler(ke_msg_id_t const msgid, #endif } else { switch (param->operation) { - case GATTC_READ: { - TRACE(2,"ANCSC %s read complete status=%d", __func__, - param->status); - break; - } - case GATTC_WRITE: { - struct gattc_write_cfm *cfm = - KE_MSG_ALLOC(GATTC_WRITE_CFM, - KE_BUILD_ID(prf_get_task_from_id(TASK_ID_ANCSP), conidx), - dest_id, gattc_write_cfm); - cfm->handle = ancc_env->last_write_handle[conidx]; - ancc_env->last_write_handle[conidx] = ATT_INVALID_HANDLE; - cfm->status = param->status; - ke_msg_send(cfm); - break; - } - case GATTC_WRITE_NO_RESPONSE: - // There's currently no need to notify the proxy task that this completed. - break; - case GATTC_NOTIFY: - case GATTC_INDICATE: - // Nothing to do. Notification sent. - case GATTC_REGISTER: - case GATTC_UNREGISTER: - case GATTC_SDP_DISC_SVC: - // Do nothing - break; + case GATTC_READ: { + TRACE(2, "ANCSC %s read complete status=%d", __func__, param->status); + break; + } + case GATTC_WRITE: { + struct gattc_write_cfm *cfm = KE_MSG_ALLOC( + GATTC_WRITE_CFM, + KE_BUILD_ID(prf_get_task_from_id(TASK_ID_ANCSP), conidx), dest_id, + gattc_write_cfm); + cfm->handle = ancc_env->last_write_handle[conidx]; + ancc_env->last_write_handle[conidx] = ATT_INVALID_HANDLE; + cfm->status = param->status; + ke_msg_send(cfm); + break; + } + case GATTC_WRITE_NO_RESPONSE: + // There's currently no need to notify the proxy task that this + // completed. + break; + case GATTC_NOTIFY: + case GATTC_INDICATE: + // Nothing to do. Notification sent. + case GATTC_REGISTER: + case GATTC_UNREGISTER: + case GATTC_SDP_DISC_SVC: + // Do nothing + break; - default: - ASSERT_ERR(0); - break; + default: + ASSERT_ERR(0); + break; } } } @@ -441,12 +445,12 @@ static int gattc_event_ind_handler(ke_msg_id_t const msgid, ke_task_id_t const dest_id, ke_task_id_t const src_id) { BLE_FUNC_ENTER(); - TRACE(5,"ANCSC %s Entry. handle=0x%x, len=%d, type=%d, val[0]=0x%x", + TRACE(5, "ANCSC %s Entry. handle=0x%x, len=%d, type=%d, val[0]=0x%x", __func__, param->handle, param->length, param->type, param->value[0]); uint8_t conidx = KE_IDX_GET(src_id); struct gattc_send_evt_cmd *cmd; cmd = - KE_MSG_ALLOC_DYN(ANCS_PROXY_IND_EVT, + KE_MSG_ALLOC_DYN(ANCS_PROXY_IND_EVT, KE_BUILD_ID(prf_get_task_from_id(TASK_ID_ANCSP), conidx), dest_id, gattc_send_evt_cmd, param->length); cmd->handle = param->handle; @@ -476,7 +480,7 @@ KE_MSG_HANDLER_TAB(ancc){ }; void ancc_task_init(struct ke_task_desc *task_desc) { - TRACE(1,"ANCSC %s Entry.", __func__); + TRACE(1, "ANCSC %s Entry.", __func__); // Get the address of the environment struct ancc_env_tag *ancc_env = PRF_ENV_GET(ANCC, ancc); @@ -486,6 +490,6 @@ void ancc_task_init(struct ke_task_desc *task_desc) { task_desc->idx_max = ANCC_IDX_MAX; } -#endif //(BLE_ANC_CLIENT) +#endif //(BLE_ANC_CLIENT) /// @} ANCCTASK diff --git a/services/ble_profiles/anp/anpc/src/anpc.c b/services/ble_profiles/anp/anpc/src/anpc.c index a9d2f69..e532fcd 100644 --- a/services/ble_profiles/anp/anpc/src/anpc.c +++ b/services/ble_profiles/anp/anpc/src/anpc.c @@ -36,41 +36,45 @@ * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t anpc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t idx; - //-------------------- allocate memory required for the profile --------------------- +static uint8_t anpc_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t idx; + //-------------------- allocate memory required for the profile + //--------------------- - struct anpc_env_tag* anpc_env = - (struct anpc_env_tag* ) ke_malloc(sizeof(struct anpc_env_tag), KE_MEM_ATT_DB); + struct anpc_env_tag *anpc_env = (struct anpc_env_tag *)ke_malloc( + sizeof(struct anpc_env_tag), KE_MEM_ATT_DB); - // allocate ANPC required environment variable - env->env = (prf_env_t*) anpc_env; + // allocate ANPC required environment variable + env->env = (prf_env_t *)anpc_env; - anpc_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - anpc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + anpc_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + anpc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_ANPC; - anpc_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_ANPC; + anpc_task_init(&(env->desc)); - for(idx = 0; idx < ANPC_IDX_MAX ; idx++) - { - anpc_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), ANPC_FREE); - } + for (idx = 0; idx < ANPC_IDX_MAX; idx++) { + anpc_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), ANPC_FREE); + } - return GAP_ERR_NO_ERROR; + return GAP_ERR_NO_ERROR; } /** @@ -82,44 +86,41 @@ static uint8_t anpc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t * @param[in] reason Detach reason **************************************************************************************** */ -static void anpc_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct anpc_env_tag* anpc_env = (struct anpc_env_tag*) env->env; +static void anpc_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct anpc_env_tag *anpc_env = (struct anpc_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(anpc_env->env[conidx] != NULL) - { - ke_free(anpc_env->env[conidx]); - anpc_env->env[conidx] = NULL; - } + // clean-up environment variable allocated for task instance + if (anpc_env->env[conidx] != NULL) { + ke_free(anpc_env->env[conidx]); + anpc_env->env[conidx] = NULL; + } - /* Put ANP Client in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), ANPC_FREE); + /* Put ANP Client in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), ANPC_FREE); } /** **************************************************************************************** * @brief Destruction of the ANPC module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void anpc_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct anpc_env_tag* anpc_env = (struct anpc_env_tag*) env->env; +static void anpc_destroy(struct prf_task_env *env) { + uint8_t idx; + struct anpc_env_tag *anpc_env = (struct anpc_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < ANPC_IDX_MAX ; idx++) - { - anpc_cleanup(env, idx, 0); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < ANPC_IDX_MAX; idx++) { + anpc_cleanup(env, idx, 0); + } - // free profile environment variables - env->env = NULL; - ke_free(anpc_env); + // free profile environment variables + env->env = NULL; + ke_free(anpc_env); } /** @@ -130,19 +131,17 @@ static void anpc_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void anpc_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Put ANP Client in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), ANPC_IDLE); +static void anpc_create(struct prf_task_env *env, uint8_t conidx) { + /* Put ANP Client in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), ANPC_IDLE); } /// ANPC Task interface required by profile manager -const struct prf_task_cbs anpc_itf = -{ - anpc_init, - anpc_destroy, - anpc_create, - anpc_cleanup, +const struct prf_task_cbs anpc_itf = { + anpc_init, + anpc_destroy, + anpc_create, + anpc_cleanup, }; /* @@ -150,107 +149,98 @@ const struct prf_task_cbs anpc_itf = **************************************************************************************** */ -const struct prf_task_cbs* anpc_prf_itf_get(void) -{ - return &anpc_itf; +const struct prf_task_cbs *anpc_prf_itf_get(void) { return &anpc_itf; } + +void anpc_enable_rsp_send(struct anpc_env_tag *anpc_env, uint8_t conidx, + uint8_t status) { + // Send to APP the details of the discovered attributes on ANPS + struct anpc_enable_rsp *rsp = KE_MSG_ALLOC( + ANPC_ENABLE_RSP, prf_dst_task_get(&(anpc_env->prf_env), conidx), + prf_src_task_get(&(anpc_env->prf_env), conidx), anpc_enable_rsp); + rsp->status = status; + + if (status == GAP_ERR_NO_ERROR) { + rsp->ans = anpc_env->env[conidx]->ans; + // Register ANPC task in gatt for indication/notifications + prf_register_atthdl2gatt(&(anpc_env->prf_env), conidx, + &(anpc_env->env[conidx]->ans.svc)); + // Go to connected state + ke_state_set(prf_src_task_get(&(anpc_env->prf_env), conidx), ANPC_IDLE); + } + + ke_msg_send(rsp); } -void anpc_enable_rsp_send(struct anpc_env_tag *anpc_env, uint8_t conidx, uint8_t status) -{ - // Send to APP the details of the discovered attributes on ANPS - struct anpc_enable_rsp * rsp = KE_MSG_ALLOC( - ANPC_ENABLE_RSP, - prf_dst_task_get(&(anpc_env->prf_env), conidx), - prf_src_task_get(&(anpc_env->prf_env), conidx), - anpc_enable_rsp); - rsp->status = status; +bool anpc_found_next_alert_cat(struct anpc_env_tag *idx_env, uint8_t conidx, + struct anp_cat_id_bit_mask cat_id) { + // Next Category Found ? + bool found = false; - if (status == GAP_ERR_NO_ERROR) - { - rsp->ans = anpc_env->env[conidx]->ans; - // Register ANPC task in gatt for indication/notifications - prf_register_atthdl2gatt(&(anpc_env->prf_env), conidx, &(anpc_env->env[conidx]->ans.svc)); - // Go to connected state - ke_state_set(prf_src_task_get(&(anpc_env->prf_env), conidx), ANPC_IDLE); + if (idx_env->env[conidx]->last_uuid_req < CAT_ID_HIGH_PRTY_ALERT) { + // Look in the first part of the categories + while ((idx_env->env[conidx]->last_uuid_req < CAT_ID_HIGH_PRTY_ALERT) && + (!found)) { + if (((cat_id.cat_id_mask_0 >> idx_env->env[conidx]->last_uuid_req) & 1) == + 1) { + found = true; + } + + idx_env->env[conidx]->last_uuid_req++; } + } - ke_msg_send(rsp); + if (idx_env->env[conidx]->last_uuid_req >= CAT_ID_HIGH_PRTY_ALERT) { + // Look in the first part of the categories + while ((idx_env->env[conidx]->last_uuid_req < CAT_ID_NB) && (!found)) { + if (((cat_id.cat_id_mask_1 >> + (idx_env->env[conidx]->last_uuid_req - CAT_ID_HIGH_PRTY_ALERT)) & + 1) == 1) { + found = true; + } + + idx_env->env[conidx]->last_uuid_req++; + } + } + + return found; } -bool anpc_found_next_alert_cat(struct anpc_env_tag *idx_env, uint8_t conidx, struct anp_cat_id_bit_mask cat_id) -{ - // Next Category Found ? - bool found = false; +void anpc_write_alert_ntf_ctnl_pt(struct anpc_env_tag *idx_env, uint8_t conidx, + uint8_t cmd_id, uint8_t cat_id) { + struct anp_ctnl_pt ctnl_pt = {cmd_id, cat_id}; - if (idx_env->env[conidx]->last_uuid_req < CAT_ID_HIGH_PRTY_ALERT) - { - // Look in the first part of the categories - while ((idx_env->env[conidx]->last_uuid_req < CAT_ID_HIGH_PRTY_ALERT) && (!found)) - { - if (((cat_id.cat_id_mask_0 >> idx_env->env[conidx]->last_uuid_req) & 1) == 1) - { - found = true; - } - - idx_env->env[conidx]->last_uuid_req++; - } - } - - if (idx_env->env[conidx]->last_uuid_req >= CAT_ID_HIGH_PRTY_ALERT) - { - // Look in the first part of the categories - while ((idx_env->env[conidx]->last_uuid_req < CAT_ID_NB) && (!found)) - { - if (((cat_id.cat_id_mask_1 >> (idx_env->env[conidx]->last_uuid_req - CAT_ID_HIGH_PRTY_ALERT)) & 1) == 1) - { - found = true; - } - - idx_env->env[conidx]->last_uuid_req++; - } - } - - return found; + // Send the write request + prf_gatt_write( + &(idx_env->prf_env), conidx, + idx_env->env[conidx]->ans.chars[ANPC_CHAR_ALERT_NTF_CTNL_PT].val_hdl, + (uint8_t *)&ctnl_pt, sizeof(struct anp_ctnl_pt), GATTC_WRITE); } -void anpc_write_alert_ntf_ctnl_pt(struct anpc_env_tag *idx_env, uint8_t conidx, uint8_t cmd_id, uint8_t cat_id) -{ - struct anp_ctnl_pt ctnl_pt = {cmd_id, cat_id}; - - // Send the write request - prf_gatt_write(&(idx_env->prf_env), conidx, - idx_env->env[conidx]->ans.chars[ANPC_CHAR_ALERT_NTF_CTNL_PT].val_hdl, - (uint8_t *)&ctnl_pt, sizeof(struct anp_ctnl_pt), GATTC_WRITE); -} - -void anpc_send_cmp_evt(struct anpc_env_tag *anpc_env, uint8_t conidx, uint8_t operation, uint8_t status) -{ - if (anpc_env->env[conidx] != NULL) - { - // Free the stored operation if needed - if (anpc_env->env[conidx]->operation != NULL) - { - ke_msg_free(ke_param2msg(anpc_env->env[conidx]->operation)); - anpc_env->env[conidx]->operation = NULL; - } +void anpc_send_cmp_evt(struct anpc_env_tag *anpc_env, uint8_t conidx, + uint8_t operation, uint8_t status) { + if (anpc_env->env[conidx] != NULL) { + // Free the stored operation if needed + if (anpc_env->env[conidx]->operation != NULL) { + ke_msg_free(ke_param2msg(anpc_env->env[conidx]->operation)); + anpc_env->env[conidx]->operation = NULL; } + } - // Go back to the CONNECTED state if the state is busy - if (ke_state_get(prf_src_task_get(&(anpc_env->prf_env), conidx)) == ANPC_BUSY) - { - ke_state_set(prf_src_task_get(&anpc_env->prf_env, conidx), ANPC_IDLE); - } + // Go back to the CONNECTED state if the state is busy + if (ke_state_get(prf_src_task_get(&(anpc_env->prf_env), conidx)) == + ANPC_BUSY) { + ke_state_set(prf_src_task_get(&anpc_env->prf_env, conidx), ANPC_IDLE); + } - // Send the message - struct anpc_cmp_evt *evt = KE_MSG_ALLOC(ANPC_CMP_EVT, - prf_dst_task_get(&(anpc_env->prf_env), conidx), - prf_src_task_get(&(anpc_env->prf_env), conidx), - anpc_cmp_evt); + // Send the message + struct anpc_cmp_evt *evt = KE_MSG_ALLOC( + ANPC_CMP_EVT, prf_dst_task_get(&(anpc_env->prf_env), conidx), + prf_src_task_get(&(anpc_env->prf_env), conidx), anpc_cmp_evt); - evt->operation = operation; - evt->status = status; + evt->operation = operation; + evt->status = status; - ke_msg_send(evt); + ke_msg_send(evt); } #endif //(BLE_AN_CLIENT) diff --git a/services/ble_profiles/anp/anpc/src/anpc_task.c b/services/ble_profiles/anp/anpc/src/anpc_task.c index 7dac6bf..89b0bf3 100644 --- a/services/ble_profiles/anp/anpc/src/anpc_task.c +++ b/services/ble_profiles/anp/anpc/src/anpc_task.c @@ -15,55 +15,49 @@ #if (BLE_AN_CLIENT) #include "anp_common.h" -#include "gap.h" #include "anpc.h" #include "anpc_task.h" +#include "gap.h" #include "gattm_task.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * STRUCTURES **************************************************************************************** */ -/// State machine used to retrieve Alert Notification service characteristics information -const struct prf_char_def anpc_ans_char[ANPC_CHAR_MAX] = -{ +/// State machine used to retrieve Alert Notification service characteristics +/// information +const struct prf_char_def anpc_ans_char[ANPC_CHAR_MAX] = { /// Supported New Alert Category - [ANPC_CHAR_SUP_NEW_ALERT_CAT] = {ATT_CHAR_SUP_NEW_ALERT_CAT, - ATT_MANDATORY, - ATT_CHAR_PROP_RD}, + [ANPC_CHAR_SUP_NEW_ALERT_CAT] = {ATT_CHAR_SUP_NEW_ALERT_CAT, ATT_MANDATORY, + ATT_CHAR_PROP_RD}, /// New Alert - [ANPC_CHAR_NEW_ALERT] = {ATT_CHAR_NEW_ALERT, - ATT_MANDATORY, - ATT_CHAR_PROP_NTF}, + [ANPC_CHAR_NEW_ALERT] = {ATT_CHAR_NEW_ALERT, ATT_MANDATORY, + ATT_CHAR_PROP_NTF}, /// Supported Unread Alert Category - [ANPC_CHAR_SUP_UNREAD_ALERT_CAT] = {ATT_CHAR_SUP_UNREAD_ALERT_CAT, - ATT_MANDATORY, - ATT_CHAR_PROP_RD}, + [ANPC_CHAR_SUP_UNREAD_ALERT_CAT] = {ATT_CHAR_SUP_UNREAD_ALERT_CAT, + ATT_MANDATORY, ATT_CHAR_PROP_RD}, /// Unread Alert Status - [ANPC_CHAR_UNREAD_ALERT_STATUS] = {ATT_CHAR_UNREAD_ALERT_STATUS, - ATT_MANDATORY, - ATT_CHAR_PROP_NTF}, + [ANPC_CHAR_UNREAD_ALERT_STATUS] = {ATT_CHAR_UNREAD_ALERT_STATUS, + ATT_MANDATORY, ATT_CHAR_PROP_NTF}, /// Alert Notification Control Point - [ANPC_CHAR_ALERT_NTF_CTNL_PT] = {ATT_CHAR_ALERT_NTF_CTNL_PT, - ATT_MANDATORY, - ATT_CHAR_PROP_WR}, + [ANPC_CHAR_ALERT_NTF_CTNL_PT] = {ATT_CHAR_ALERT_NTF_CTNL_PT, ATT_MANDATORY, + ATT_CHAR_PROP_WR}, }; -/// State machine used to retrieve Phone Alert Status service characteristic descriptor information -const struct prf_char_desc_def anpc_ans_char_desc[ANPC_DESC_MAX] = -{ +/// State machine used to retrieve Phone Alert Status service characteristic +/// descriptor information +const struct prf_char_desc_def anpc_ans_char_desc[ANPC_DESC_MAX] = { /// New Alert Char. - Client Characteristic Configuration - [ANPC_DESC_NEW_ALERT_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, - ATT_MANDATORY, - ANPC_CHAR_NEW_ALERT}, + [ANPC_DESC_NEW_ALERT_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, + ANPC_CHAR_NEW_ALERT}, /// Unread Alert Status Char. - Client Characteristic Configuration - [ANPC_DESC_UNREAD_ALERT_STATUS_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, - ATT_MANDATORY, - ANPC_CHAR_UNREAD_ALERT_STATUS}, + [ANPC_DESC_UNREAD_ALERT_STATUS_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + ATT_MANDATORY, + ANPC_CHAR_UNREAD_ALERT_STATUS}, }; /* @@ -82,60 +76,56 @@ const struct prf_char_desc_def anpc_ans_char_desc[ANPC_DESC_MAX] = **************************************************************************************** */ __STATIC int anpc_enable_req_handler(ke_msg_id_t const msgid, - struct anpc_enable_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; - // Phone Alert Status Profile Client Role Task Environment - struct anpc_env_tag *anpc_env = PRF_ENV_GET(ANPC, anpc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); + struct anpc_enable_req *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; + // Phone Alert Status Profile Client Role Task Environment + struct anpc_env_tag *anpc_env = PRF_ENV_GET(ANPC, anpc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t state = ke_state_get(dest_id); - if ((state == ANPC_IDLE) && (anpc_env->env[conidx] == NULL)) - { - // allocate environment variable for task instance - anpc_env->env[conidx] = (struct anpc_cnx_env*) ke_malloc(sizeof(struct anpc_cnx_env),KE_MEM_ATT_DB); - memset(anpc_env->env[conidx], 0, sizeof(struct anpc_cnx_env)); + if ((state == ANPC_IDLE) && (anpc_env->env[conidx] == NULL)) { + // allocate environment variable for task instance + anpc_env->env[conidx] = (struct anpc_cnx_env *)ke_malloc( + sizeof(struct anpc_cnx_env), KE_MEM_ATT_DB); + memset(anpc_env->env[conidx], 0, sizeof(struct anpc_cnx_env)); - anpc_env->env[conidx]->last_char_code = ANPC_ENABLE_OP_CODE; + anpc_env->env[conidx]->last_char_code = ANPC_ENABLE_OP_CODE; - // Start discovering - if (param->con_type == PRF_CON_DISCOVERY) - { - prf_disc_svc_send(&(anpc_env->prf_env), conidx, ATT_SVC_ALERT_NTF); + // Start discovering + if (param->con_type == PRF_CON_DISCOVERY) { + prf_disc_svc_send(&(anpc_env->prf_env), conidx, ATT_SVC_ALERT_NTF); - // Go to DISCOVERING state - ke_state_set(dest_id, ANPC_DISCOVERING); + // Go to DISCOVERING state + ke_state_set(dest_id, ANPC_DISCOVERING); - // Configure the environment for a discovery procedure - anpc_env->env[conidx]->last_uuid_req = ATT_SVC_ALERT_NTF; - } - // Bond information is provided - else - { - // Keep the provided database content - memcpy(&anpc_env->env[conidx]->ans, ¶m->ans, sizeof(struct anpc_ans_content)); - - //send APP confirmation that can start normal connection to TH - anpc_enable_rsp_send(anpc_env, conidx, GAP_ERR_NO_ERROR); - } + // Configure the environment for a discovery procedure + anpc_env->env[conidx]->last_uuid_req = ATT_SVC_ALERT_NTF; } + // Bond information is provided + else { + // Keep the provided database content + memcpy(&anpc_env->env[conidx]->ans, ¶m->ans, + sizeof(struct anpc_ans_content)); - else if (state != ANPC_FREE) - { - status = PRF_ERR_REQ_DISALLOWED; + // send APP confirmation that can start normal connection to TH + anpc_enable_rsp_send(anpc_env, conidx, GAP_ERR_NO_ERROR); } + } - // send an error if request fails - if(status != GAP_ERR_NO_ERROR) - { - anpc_enable_rsp_send(anpc_env, conidx, status); - } + else if (state != ANPC_FREE) { + status = PRF_ERR_REQ_DISALLOWED; + } - return (KE_MSG_CONSUMED); + // send an error if request fails + if (status != GAP_ERR_NO_ERROR) { + anpc_enable_rsp_send(anpc_env, conidx, status); + } + + return (KE_MSG_CONSUMED); } /** @@ -149,105 +139,97 @@ __STATIC int anpc_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int anpc_read_cmd_handler(ke_msg_id_t const msgid, - struct anpc_read_cmd *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct anpc_env_tag *anpc_env = PRF_ENV_GET(ANPC, anpc); + struct anpc_read_cmd *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct anpc_env_tag *anpc_env = PRF_ENV_GET(ANPC, anpc); - if (anpc_env->env[conidx] != NULL) - { - // Attribute Handle - uint16_t handle = ATT_INVALID_SEARCH_HANDLE; - // Status - uint8_t status = GAP_ERR_NO_ERROR; + if (anpc_env->env[conidx] != NULL) { + // Attribute Handle + uint16_t handle = ATT_INVALID_SEARCH_HANDLE; + // Status + uint8_t status = GAP_ERR_NO_ERROR; - // Check the provided connection handle - do - { - // Check the current state - if (ke_state_get(dest_id) == ANPC_BUSY) - { - // Keep the request for later, status is GAP_ERR_NO_ERROR - msg_status = KE_MSG_SAVED; - break; - } + // Check the provided connection handle + do { + // Check the current state + if (ke_state_get(dest_id) == ANPC_BUSY) { + // Keep the request for later, status is GAP_ERR_NO_ERROR + msg_status = KE_MSG_SAVED; + break; + } - switch (param->read_code) - { - // Read Supported New Alert - case (ANPC_RD_SUP_NEW_ALERT_CAT): - { - handle = anpc_env->env[conidx]->ans.chars[ANPC_CHAR_SUP_NEW_ALERT_CAT].val_hdl; - } break; + switch (param->read_code) { + // Read Supported New Alert + case (ANPC_RD_SUP_NEW_ALERT_CAT): { + handle = anpc_env->env[conidx] + ->ans.chars[ANPC_CHAR_SUP_NEW_ALERT_CAT] + .val_hdl; + } break; - // Read Supported Unread Alert - case (ANPC_RD_SUP_UNREAD_ALERT_CAT): - { - handle = anpc_env->env[conidx]->ans.chars[ANPC_CHAR_SUP_UNREAD_ALERT_CAT].val_hdl; - } break; + // Read Supported Unread Alert + case (ANPC_RD_SUP_UNREAD_ALERT_CAT): { + handle = anpc_env->env[conidx] + ->ans.chars[ANPC_CHAR_SUP_UNREAD_ALERT_CAT] + .val_hdl; + } break; - // Read New Alert Characteristic Client Char. Cfg. Descriptor Value - case (ANPC_RD_WR_NEW_ALERT_CFG): - { - handle = anpc_env->env[conidx]->ans.descs[ANPC_DESC_NEW_ALERT_CL_CFG].desc_hdl; - } break; + // Read New Alert Characteristic Client Char. Cfg. Descriptor Value + case (ANPC_RD_WR_NEW_ALERT_CFG): { + handle = anpc_env->env[conidx] + ->ans.descs[ANPC_DESC_NEW_ALERT_CL_CFG] + .desc_hdl; + } break; - // Read Unread Alert Characteristic Client Char. Cfg. Descriptor Value - case (ANPC_RD_WR_UNREAD_ALERT_STATUS_CFG): - { - handle = anpc_env->env[conidx]->ans.descs[ANPC_DESC_UNREAD_ALERT_STATUS_CL_CFG].desc_hdl; - } break; + // Read Unread Alert Characteristic Client Char. Cfg. Descriptor Value + case (ANPC_RD_WR_UNREAD_ALERT_STATUS_CFG): { + handle = anpc_env->env[conidx] + ->ans.descs[ANPC_DESC_UNREAD_ALERT_STATUS_CL_CFG] + .desc_hdl; + } break; - default: - { - status = PRF_ERR_INVALID_PARAM; - } break; - } + default: { + status = PRF_ERR_INVALID_PARAM; + } break; + } - // Check if handle is viable - if ((handle != ATT_INVALID_SEARCH_HANDLE) && - (status == GAP_ERR_NO_ERROR)) - { - // Force the operation value - param->operation = ANPC_READ_OP_CODE; + // Check if handle is viable + if ((handle != ATT_INVALID_SEARCH_HANDLE) && + (status == GAP_ERR_NO_ERROR)) { + // Force the operation value + param->operation = ANPC_READ_OP_CODE; - // Store the command structure - anpc_env->env[conidx]->operation = param; - msg_status = KE_MSG_NO_FREE; + // Store the command structure + anpc_env->env[conidx]->operation = param; + msg_status = KE_MSG_NO_FREE; - // Send the read request - prf_read_char_send(&(anpc_env->prf_env), conidx, - anpc_env->env[conidx]->ans.svc.shdl, - anpc_env->env[conidx]->ans.svc.ehdl, - handle); + // Send the read request + prf_read_char_send(&(anpc_env->prf_env), conidx, + anpc_env->env[conidx]->ans.svc.shdl, + anpc_env->env[conidx]->ans.svc.ehdl, handle); - // Go to the Busy state - ke_state_set(dest_id, ANPC_BUSY); - } - else - { - status = PRF_ERR_INEXISTENT_HDL; - } - }while(0); + // Go to the Busy state + ke_state_set(dest_id, ANPC_BUSY); + } else { + status = PRF_ERR_INEXISTENT_HDL; + } + } while (0); - if (status != GAP_ERR_NO_ERROR) - { - anpc_send_cmp_evt(anpc_env, conidx, ANPC_READ_OP_CODE, status); - } - } - else - { - // No connection exists - anpc_send_cmp_evt(anpc_env, conidx, ANPC_READ_OP_CODE, PRF_ERR_REQ_DISALLOWED); + if (status != GAP_ERR_NO_ERROR) { + anpc_send_cmp_evt(anpc_env, conidx, ANPC_READ_OP_CODE, status); } + } else { + // No connection exists + anpc_send_cmp_evt(anpc_env, conidx, ANPC_READ_OP_CODE, + PRF_ERR_REQ_DISALLOWED); + } - return (int)msg_status; + return (int)msg_status; } /** @@ -261,124 +243,107 @@ __STATIC int anpc_read_cmd_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int anpc_write_cmd_handler(ke_msg_id_t const msgid, - struct anpc_write_cmd *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; + struct anpc_write_cmd *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; - // Get the address of the environment - struct anpc_env_tag *anpc_env = PRF_ENV_GET(ANPC, anpc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct anpc_env_tag *anpc_env = PRF_ENV_GET(ANPC, anpc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - if (anpc_env->env[conidx] != NULL) - { - do - { - // Check the current state - if (ke_state_get(dest_id) != ANPC_IDLE) - { - msg_status = KE_MSG_SAVED; - break; - } - // Attribute handle - uint16_t handle = ATT_INVALID_SEARCH_HANDLE; - // Length - uint8_t length; + if (anpc_env->env[conidx] != NULL) { + do { + // Check the current state + if (ke_state_get(dest_id) != ANPC_IDLE) { + msg_status = KE_MSG_SAVED; + break; + } + // Attribute handle + uint16_t handle = ATT_INVALID_SEARCH_HANDLE; + // Length + uint8_t length; - switch (param->write_code) - { - // Write Alert Notification Control Point Characteristic Value - case (ANPC_WR_ALERT_NTF_CTNL_PT): - { - // Check the Category ID and the Command ID - if ((param->value.ctnl_pt.cmd_id < CMD_ID_NB) && - ((param->value.ctnl_pt.cat_id < CAT_ID_NB) || (param->value.ctnl_pt.cat_id == CAT_ID_ALL_SUPPORTED_CAT))) - { - handle = anpc_env->env[conidx]->ans.chars[ANPC_CHAR_ALERT_NTF_CTNL_PT].val_hdl; - length = sizeof(struct anp_ctnl_pt); - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } break; + switch (param->write_code) { + // Write Alert Notification Control Point Characteristic Value + case (ANPC_WR_ALERT_NTF_CTNL_PT): { + // Check the Category ID and the Command ID + if ((param->value.ctnl_pt.cmd_id < CMD_ID_NB) && + ((param->value.ctnl_pt.cat_id < CAT_ID_NB) || + (param->value.ctnl_pt.cat_id == CAT_ID_ALL_SUPPORTED_CAT))) { + handle = anpc_env->env[conidx] + ->ans.chars[ANPC_CHAR_ALERT_NTF_CTNL_PT] + .val_hdl; + length = sizeof(struct anp_ctnl_pt); + } else { + status = PRF_ERR_INVALID_PARAM; + } + } break; - // Write New Alert Characteristic Client Char. Cfg. Descriptor Value - case (ANPC_RD_WR_NEW_ALERT_CFG): - { - if (param->value.new_alert_ntf_cfg <= PRF_CLI_START_NTF) - { - handle = anpc_env->env[conidx]->ans.descs[ANPC_DESC_NEW_ALERT_CL_CFG].desc_hdl; - length = sizeof(uint16_t); - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } break; + // Write New Alert Characteristic Client Char. Cfg. Descriptor Value + case (ANPC_RD_WR_NEW_ALERT_CFG): { + if (param->value.new_alert_ntf_cfg <= PRF_CLI_START_NTF) { + handle = anpc_env->env[conidx] + ->ans.descs[ANPC_DESC_NEW_ALERT_CL_CFG] + .desc_hdl; + length = sizeof(uint16_t); + } else { + status = PRF_ERR_INVALID_PARAM; + } + } break; - // Write Unread Alert Status Characteristic Client Char. Cfg. Descriptor Value - case (ANPC_RD_WR_UNREAD_ALERT_STATUS_CFG): - { - if (param->value.unread_alert_status_ntf_cfg <= PRF_CLI_START_NTF) - { - handle = anpc_env->env[conidx]->ans.descs[ANPC_DESC_UNREAD_ALERT_STATUS_CL_CFG].desc_hdl; - length = sizeof(uint16_t); - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } break; + // Write Unread Alert Status Characteristic Client Char. Cfg. Descriptor + // Value + case (ANPC_RD_WR_UNREAD_ALERT_STATUS_CFG): { + if (param->value.unread_alert_status_ntf_cfg <= PRF_CLI_START_NTF) { + handle = anpc_env->env[conidx] + ->ans.descs[ANPC_DESC_UNREAD_ALERT_STATUS_CL_CFG] + .desc_hdl; + length = sizeof(uint16_t); + } else { + status = PRF_ERR_INVALID_PARAM; + } + } break; - default: - { - status = PRF_ERR_INVALID_PARAM; - } break; - } + default: { + status = PRF_ERR_INVALID_PARAM; + } break; + } - if (status == GAP_ERR_NO_ERROR) - { - // Check if handle is viable - if (handle != ATT_INVALID_SEARCH_HANDLE) - { - // Send the write request - prf_gatt_write(&(anpc_env->prf_env), conidx, handle, - (uint8_t *)¶m->value, length, GATTC_WRITE); + if (status == GAP_ERR_NO_ERROR) { + // Check if handle is viable + if (handle != ATT_INVALID_SEARCH_HANDLE) { + // Send the write request + prf_gatt_write(&(anpc_env->prf_env), conidx, handle, + (uint8_t *)¶m->value, length, GATTC_WRITE); - // Force the operation value - param->operation = ANPC_WRITE_OP_CODE; - // Store the command structure - anpc_env->env[conidx]->operation = param; + // Force the operation value + param->operation = ANPC_WRITE_OP_CODE; + // Store the command structure + anpc_env->env[conidx]->operation = param; - msg_status = KE_MSG_NO_FREE; + msg_status = KE_MSG_NO_FREE; - // Go to the Busy state - ke_state_set(dest_id, ANPC_BUSY); - } - else - { - status = PRF_ERR_INEXISTENT_HDL; - } - } - }while(0); - } - else - { - status = PRF_ERR_REQ_DISALLOWED; - } + // Go to the Busy state + ke_state_set(dest_id, ANPC_BUSY); + } else { + status = PRF_ERR_INEXISTENT_HDL; + } + } + } while (0); + } else { + status = PRF_ERR_REQ_DISALLOWED; + } - if (status != GAP_ERR_NO_ERROR) - { - anpc_send_cmp_evt(anpc_env, conidx, ANPC_WRITE_OP_CODE, status); - } + if (status != GAP_ERR_NO_ERROR) { + anpc_send_cmp_evt(anpc_env, conidx, ANPC_WRITE_OP_CODE, status); + } - return (int)msg_status; + return (int)msg_status; } /** @@ -392,250 +357,250 @@ __STATIC int anpc_write_cmd_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, - struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct anpc_env_tag *anpc_env = PRF_ENV_GET(ANPC, anpc); - uint8_t conidx = KE_IDX_GET(dest_id); - // Status - uint8_t status; + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct anpc_env_tag *anpc_env = PRF_ENV_GET(ANPC, anpc); + uint8_t conidx = KE_IDX_GET(dest_id); + // Status + uint8_t status; + if (anpc_env->env[conidx] != NULL) { + uint8_t state = ke_state_get(dest_id); - if (anpc_env->env[conidx] != NULL) - { - uint8_t state = ke_state_get(dest_id); + if (state == ANPC_DISCOVERING) { + status = param->status; - if (state == ANPC_DISCOVERING) - { - status = param->status; - - if ((status == ATT_ERR_ATTRIBUTE_NOT_FOUND) || - (status == ATT_ERR_NO_ERROR)) - { - // Discovery - // check characteristic validity - if(anpc_env->env[conidx]->nb_svc == 1) - { - status = prf_check_svc_char_validity(ANPC_CHAR_MAX, - anpc_env->env[conidx]->ans.chars, - anpc_ans_char); - } - // too much services - else if (anpc_env->env[conidx]->nb_svc > 1) - { - status = PRF_ERR_MULTIPLE_SVC; - } - // no services found - else - { - status = PRF_ERR_STOP_DISC_CHAR_MISSING; - } - - // check descriptor validity - if (status == GAP_ERR_NO_ERROR) - { - status = prf_check_svc_char_desc_validity(ANPC_DESC_MAX, - anpc_env->env[conidx]->ans.descs, - anpc_ans_char_desc, - anpc_env->env[conidx]->ans.chars); - } - } - - anpc_enable_rsp_send(anpc_env, conidx, status); + if ((status == ATT_ERR_ATTRIBUTE_NOT_FOUND) || + (status == ATT_ERR_NO_ERROR)) { + // Discovery + // check characteristic validity + if (anpc_env->env[conidx]->nb_svc == 1) { + status = prf_check_svc_char_validity( + ANPC_CHAR_MAX, anpc_env->env[conidx]->ans.chars, anpc_ans_char); + } + // too much services + else if (anpc_env->env[conidx]->nb_svc > 1) { + status = PRF_ERR_MULTIPLE_SVC; + } + // no services found + else { + status = PRF_ERR_STOP_DISC_CHAR_MISSING; } - else if (state == ANPC_BUSY) - { - switch (param->operation) - { - case GATTC_READ: - { - switch (((struct anpc_cmd *)anpc_env->env[conidx]->operation)->operation) - { - // Read Supported New Alert Category Characteristic value - case (ANPC_ENABLE_RD_NEW_ALERT_OP_CODE): - { - if (param->status == GAP_ERR_NO_ERROR) - { - // Force the operation value - ((struct anpc_cmd *)anpc_env->env[conidx]->operation)->operation = ANPC_ENABLE_RD_UNREAD_ALERT_OP_CODE; - // Check Supported Unread Alert Category - prf_read_char_send(&(anpc_env->prf_env), conidx, - anpc_env->env[conidx]->ans.svc.shdl, anpc_env->env[conidx]->ans.svc.ehdl, - anpc_env->env[conidx]->ans.chars[ANPC_CHAR_SUP_UNREAD_ALERT_CAT].val_hdl); - } - else - { - anpc_send_cmp_evt(anpc_env, conidx, ANPC_ENABLE_OP_CODE, param->status); - } - } break; - - case (ANPC_ENABLE_RD_UNREAD_ALERT_OP_CODE): - { - if (param->status == GAP_ERR_NO_ERROR) - { - // If peer device was unknown, stop the procedure - if (((struct anpc_enable_req *)anpc_env->env[conidx]->operation)->con_type == PRF_CON_DISCOVERY) - { - anpc_send_cmp_evt(anpc_env, conidx, ANPC_ENABLE_OP_CODE, GAP_ERR_NO_ERROR); - } - // If peer device was already known (bonded), start Recovery from Connection Loss procedure - else - { - // Reset the environment - anpc_env->env[conidx]->last_uuid_req = CAT_ID_SPL_ALERT; - - if (anpc_found_next_alert_cat(anpc_env, conidx, ((struct anpc_enable_req *)anpc_env->env[conidx]->operation)->new_alert_enable)) - { - // Force the operation value - ((struct anpc_cmd *)anpc_env->env[conidx]->operation)->operation = ANPC_ENABLE_WR_NEW_ALERT_OP_CODE; - // Enable sending of notifications for the found category ID - anpc_write_alert_ntf_ctnl_pt(anpc_env, conidx, CMD_ID_EN_NEW_IN_ALERT_NTF, anpc_env->env[conidx]->last_uuid_req - 1); - } - else - { - // Reset the environment - anpc_env->env[conidx]->last_uuid_req = CAT_ID_SPL_ALERT; - - if (anpc_found_next_alert_cat(anpc_env, conidx, ((struct anpc_enable_req *)anpc_env->env[conidx]->operation)->unread_alert_enable)) - { - // Force the operation value - ((struct anpc_cmd *)anpc_env->env[conidx]->operation)->operation = ANPC_ENABLE_WR_UNREAD_ALERT_OP_CODE; - // Enable sending of notifications for the found category ID - anpc_write_alert_ntf_ctnl_pt(anpc_env, conidx, CMD_ID_EN_UNREAD_CAT_STATUS_NTF, anpc_env->env[conidx]->last_uuid_req - 1); - } - else - { - anpc_send_cmp_evt(anpc_env, conidx, ANPC_ENABLE_OP_CODE, GAP_ERR_NO_ERROR); - } - } - } - } - else - { - anpc_send_cmp_evt(anpc_env, conidx, ANPC_ENABLE_OP_CODE, param->status); - } - } break; - - case (ANPC_READ_OP_CODE): - { - // Inform the requester that the read procedure is over - anpc_send_cmp_evt(anpc_env, conidx, ANPC_READ_OP_CODE, param->status); - } break; - - default: - { - ASSERT_ERR(0); - } - } - } break; - - case GATTC_WRITE: - case GATTC_WRITE_NO_RESPONSE: - { - // Retrieve the operation currently performed - uint8_t operation = ((struct anpc_cmd *)anpc_env->env[conidx]->operation)->operation; - - switch (operation) - { - case (ANPC_WRITE_OP_CODE): - { - uint8_t wr_code = ((struct anpc_write_cmd *)anpc_env->env[conidx]->operation)->write_code; - - if ((wr_code == ANPC_RD_WR_NEW_ALERT_CFG) || - (wr_code == ANPC_RD_WR_UNREAD_ALERT_STATUS_CFG) || - (wr_code == ANPC_WR_ALERT_NTF_CTNL_PT)) - { - anpc_send_cmp_evt(anpc_env, conidx, ANPC_WRITE_OP_CODE, param->status); - } - else - { - ASSERT_ERR(0); - } - } break; - - case (ANPC_ENABLE_WR_NEW_ALERT_OP_CODE): - { - // Look for the next category to enable - if (anpc_found_next_alert_cat(anpc_env, conidx, ((struct anpc_enable_req *)anpc_env->env[conidx]->operation)->new_alert_enable)) - { - // Enable sending of notifications for the found category ID - anpc_write_alert_ntf_ctnl_pt(anpc_env, conidx, CMD_ID_EN_NEW_IN_ALERT_NTF, anpc_env->env[conidx]->last_uuid_req - 1); - } - else - { - // Force the operation value - ((struct anpc_cmd *)anpc_env->env[conidx]->operation)->operation = ANPC_ENABLE_WR_NTF_NEW_ALERT_OP_CODE; - // Send a "Notify New Alert Immediately" command with the Category ID field set to 0xFF - anpc_write_alert_ntf_ctnl_pt(anpc_env, conidx, CMD_ID_NTF_NEW_IN_ALERT_IMM, CAT_ID_ALL_SUPPORTED_CAT); - } - } break; - - case (ANPC_ENABLE_WR_NTF_NEW_ALERT_OP_CODE): - { - // Reset the environment - anpc_env->env[conidx]->last_uuid_req = CAT_ID_SPL_ALERT; - - if (anpc_found_next_alert_cat(anpc_env, conidx, ((struct anpc_enable_req *)anpc_env->env[conidx]->operation)->unread_alert_enable)) - { - // Force the operation value - ((struct anpc_cmd *)anpc_env->env[conidx]->operation)->operation = ANPC_ENABLE_WR_UNREAD_ALERT_OP_CODE; - // Enable sending of notifications for the found category ID - anpc_write_alert_ntf_ctnl_pt(anpc_env, conidx, CMD_ID_EN_UNREAD_CAT_STATUS_NTF, anpc_env->env[conidx]->last_uuid_req - 1); - } - else - { - anpc_send_cmp_evt(anpc_env, conidx, ANPC_ENABLE_OP_CODE, GAP_ERR_NO_ERROR); - } - } break; - - case (ANPC_ENABLE_WR_UNREAD_ALERT_OP_CODE): - { - // Look for the next category to enable - if (anpc_found_next_alert_cat(anpc_env, conidx, ((struct anpc_enable_req *)anpc_env->env[conidx]->operation)->unread_alert_enable)) - { - // Enable sending of notifications for the found category ID - anpc_write_alert_ntf_ctnl_pt(anpc_env, conidx, CMD_ID_EN_UNREAD_CAT_STATUS_NTF, anpc_env->env[conidx]->last_uuid_req - 1); - } - else - { - // Force the operation value - ((struct anpc_cmd *)anpc_env->env[conidx]->operation)->operation = ANPC_ENABLE_WR_NTF_UNREAD_ALERT_OP_CODE; - // Send a "Notify New Alert Immediately" command with the Category ID field set to 0xFF - anpc_write_alert_ntf_ctnl_pt(anpc_env, conidx, CMD_ID_NTF_UNREAD_CAT_STATUS_IMM, CAT_ID_ALL_SUPPORTED_CAT); - } - } break; - - case (ANPC_ENABLE_WR_NTF_UNREAD_ALERT_OP_CODE): - { - // The discovery procedure is over - anpc_send_cmp_evt(anpc_env, conidx, ANPC_ENABLE_OP_CODE, param->status); - } break; - - default: - { - ASSERT_ERR(0); - } break; - } - } break; - - case GATTC_REGISTER: - case GATTC_UNREGISTER: - { - // Do nothing - } break; - - default: - { - ASSERT_ERR(0); - } break; - } + // check descriptor validity + if (status == GAP_ERR_NO_ERROR) { + status = prf_check_svc_char_desc_validity( + ANPC_DESC_MAX, anpc_env->env[conidx]->ans.descs, + anpc_ans_char_desc, anpc_env->env[conidx]->ans.chars); } + } + + anpc_enable_rsp_send(anpc_env, conidx, status); } - // else ignore the message - return (KE_MSG_CONSUMED); + + else if (state == ANPC_BUSY) { + switch (param->operation) { + case GATTC_READ: { + switch ( + ((struct anpc_cmd *)anpc_env->env[conidx]->operation)->operation) { + // Read Supported New Alert Category Characteristic value + case (ANPC_ENABLE_RD_NEW_ALERT_OP_CODE): { + if (param->status == GAP_ERR_NO_ERROR) { + // Force the operation value + ((struct anpc_cmd *)anpc_env->env[conidx]->operation)->operation = + ANPC_ENABLE_RD_UNREAD_ALERT_OP_CODE; + // Check Supported Unread Alert Category + prf_read_char_send(&(anpc_env->prf_env), conidx, + anpc_env->env[conidx]->ans.svc.shdl, + anpc_env->env[conidx]->ans.svc.ehdl, + anpc_env->env[conidx] + ->ans.chars[ANPC_CHAR_SUP_UNREAD_ALERT_CAT] + .val_hdl); + } else { + anpc_send_cmp_evt(anpc_env, conidx, ANPC_ENABLE_OP_CODE, + param->status); + } + } break; + + case (ANPC_ENABLE_RD_UNREAD_ALERT_OP_CODE): { + if (param->status == GAP_ERR_NO_ERROR) { + // If peer device was unknown, stop the procedure + if (((struct anpc_enable_req *)anpc_env->env[conidx]->operation) + ->con_type == PRF_CON_DISCOVERY) { + anpc_send_cmp_evt(anpc_env, conidx, ANPC_ENABLE_OP_CODE, + GAP_ERR_NO_ERROR); + } + // If peer device was already known (bonded), start Recovery from + // Connection Loss procedure + else { + // Reset the environment + anpc_env->env[conidx]->last_uuid_req = CAT_ID_SPL_ALERT; + + if (anpc_found_next_alert_cat( + anpc_env, conidx, + ((struct anpc_enable_req *)anpc_env->env[conidx] + ->operation) + ->new_alert_enable)) { + // Force the operation value + ((struct anpc_cmd *)anpc_env->env[conidx]->operation) + ->operation = ANPC_ENABLE_WR_NEW_ALERT_OP_CODE; + // Enable sending of notifications for the found category ID + anpc_write_alert_ntf_ctnl_pt( + anpc_env, conidx, CMD_ID_EN_NEW_IN_ALERT_NTF, + anpc_env->env[conidx]->last_uuid_req - 1); + } else { + // Reset the environment + anpc_env->env[conidx]->last_uuid_req = CAT_ID_SPL_ALERT; + + if (anpc_found_next_alert_cat( + anpc_env, conidx, + ((struct anpc_enable_req *)anpc_env->env[conidx] + ->operation) + ->unread_alert_enable)) { + // Force the operation value + ((struct anpc_cmd *)anpc_env->env[conidx]->operation) + ->operation = ANPC_ENABLE_WR_UNREAD_ALERT_OP_CODE; + // Enable sending of notifications for the found category ID + anpc_write_alert_ntf_ctnl_pt( + anpc_env, conidx, CMD_ID_EN_UNREAD_CAT_STATUS_NTF, + anpc_env->env[conidx]->last_uuid_req - 1); + } else { + anpc_send_cmp_evt(anpc_env, conidx, ANPC_ENABLE_OP_CODE, + GAP_ERR_NO_ERROR); + } + } + } + } else { + anpc_send_cmp_evt(anpc_env, conidx, ANPC_ENABLE_OP_CODE, + param->status); + } + } break; + + case (ANPC_READ_OP_CODE): { + // Inform the requester that the read procedure is over + anpc_send_cmp_evt(anpc_env, conidx, ANPC_READ_OP_CODE, param->status); + } break; + + default: { + ASSERT_ERR(0); + } + } + } break; + + case GATTC_WRITE: + case GATTC_WRITE_NO_RESPONSE: { + // Retrieve the operation currently performed + uint8_t operation = + ((struct anpc_cmd *)anpc_env->env[conidx]->operation)->operation; + + switch (operation) { + case (ANPC_WRITE_OP_CODE): { + uint8_t wr_code = + ((struct anpc_write_cmd *)anpc_env->env[conidx]->operation) + ->write_code; + + if ((wr_code == ANPC_RD_WR_NEW_ALERT_CFG) || + (wr_code == ANPC_RD_WR_UNREAD_ALERT_STATUS_CFG) || + (wr_code == ANPC_WR_ALERT_NTF_CTNL_PT)) { + anpc_send_cmp_evt(anpc_env, conidx, ANPC_WRITE_OP_CODE, + param->status); + } else { + ASSERT_ERR(0); + } + } break; + + case (ANPC_ENABLE_WR_NEW_ALERT_OP_CODE): { + // Look for the next category to enable + if (anpc_found_next_alert_cat( + anpc_env, conidx, + ((struct anpc_enable_req *)anpc_env->env[conidx]->operation) + ->new_alert_enable)) { + // Enable sending of notifications for the found category ID + anpc_write_alert_ntf_ctnl_pt( + anpc_env, conidx, CMD_ID_EN_NEW_IN_ALERT_NTF, + anpc_env->env[conidx]->last_uuid_req - 1); + } else { + // Force the operation value + ((struct anpc_cmd *)anpc_env->env[conidx]->operation)->operation = + ANPC_ENABLE_WR_NTF_NEW_ALERT_OP_CODE; + // Send a "Notify New Alert Immediately" command with the Category + // ID field set to 0xFF + anpc_write_alert_ntf_ctnl_pt(anpc_env, conidx, + CMD_ID_NTF_NEW_IN_ALERT_IMM, + CAT_ID_ALL_SUPPORTED_CAT); + } + } break; + + case (ANPC_ENABLE_WR_NTF_NEW_ALERT_OP_CODE): { + // Reset the environment + anpc_env->env[conidx]->last_uuid_req = CAT_ID_SPL_ALERT; + + if (anpc_found_next_alert_cat( + anpc_env, conidx, + ((struct anpc_enable_req *)anpc_env->env[conidx]->operation) + ->unread_alert_enable)) { + // Force the operation value + ((struct anpc_cmd *)anpc_env->env[conidx]->operation)->operation = + ANPC_ENABLE_WR_UNREAD_ALERT_OP_CODE; + // Enable sending of notifications for the found category ID + anpc_write_alert_ntf_ctnl_pt( + anpc_env, conidx, CMD_ID_EN_UNREAD_CAT_STATUS_NTF, + anpc_env->env[conidx]->last_uuid_req - 1); + } else { + anpc_send_cmp_evt(anpc_env, conidx, ANPC_ENABLE_OP_CODE, + GAP_ERR_NO_ERROR); + } + } break; + + case (ANPC_ENABLE_WR_UNREAD_ALERT_OP_CODE): { + // Look for the next category to enable + if (anpc_found_next_alert_cat( + anpc_env, conidx, + ((struct anpc_enable_req *)anpc_env->env[conidx]->operation) + ->unread_alert_enable)) { + // Enable sending of notifications for the found category ID + anpc_write_alert_ntf_ctnl_pt( + anpc_env, conidx, CMD_ID_EN_UNREAD_CAT_STATUS_NTF, + anpc_env->env[conidx]->last_uuid_req - 1); + } else { + // Force the operation value + ((struct anpc_cmd *)anpc_env->env[conidx]->operation)->operation = + ANPC_ENABLE_WR_NTF_UNREAD_ALERT_OP_CODE; + // Send a "Notify New Alert Immediately" command with the Category + // ID field set to 0xFF + anpc_write_alert_ntf_ctnl_pt(anpc_env, conidx, + CMD_ID_NTF_UNREAD_CAT_STATUS_IMM, + CAT_ID_ALL_SUPPORTED_CAT); + } + } break; + + case (ANPC_ENABLE_WR_NTF_UNREAD_ALERT_OP_CODE): { + // The discovery procedure is over + anpc_send_cmp_evt(anpc_env, conidx, ANPC_ENABLE_OP_CODE, + param->status); + } break; + + default: { + ASSERT_ERR(0); + } break; + } + } break; + + case GATTC_REGISTER: + case GATTC_UNREGISTER: { + // Do nothing + } break; + + default: { + ASSERT_ERR(0); + } break; + } + } + } + // else ignore the message + return (KE_MSG_CONSUMED); } /** @@ -650,36 +615,35 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, - struct gattc_sdp_svc_ind const *ind, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_sdp_svc_ind const *ind, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == ANPC_DISCOVERING) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == ANPC_DISCOVERING) { + uint8_t conidx = KE_IDX_GET(dest_id); - struct anpc_env_tag *anpc_env = PRF_ENV_GET(ANPC, anpc); + struct anpc_env_tag *anpc_env = PRF_ENV_GET(ANPC, anpc); - ASSERT_INFO(anpc_env != NULL, dest_id, src_id); - ASSERT_INFO(anpc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(anpc_env != NULL, dest_id, src_id); + ASSERT_INFO(anpc_env->env[conidx] != NULL, dest_id, src_id); - if(anpc_env->env[conidx]->nb_svc == 0) - { - // Retrieve ANS characteristics and descriptors - prf_extract_svc_info(ind, ANPC_CHAR_MAX, &anpc_ans_char[0], &anpc_env->env[conidx]->ans.chars[0], - ANPC_DESC_MAX, &anpc_ans_char_desc[0], &anpc_env->env[conidx]->ans.descs[0]); + if (anpc_env->env[conidx]->nb_svc == 0) { + // Retrieve ANS characteristics and descriptors + prf_extract_svc_info(ind, ANPC_CHAR_MAX, &anpc_ans_char[0], + &anpc_env->env[conidx]->ans.chars[0], ANPC_DESC_MAX, + &anpc_ans_char_desc[0], + &anpc_env->env[conidx]->ans.descs[0]); - //Even if we get multiple responses we only store 1 range - anpc_env->env[conidx]->ans.svc.shdl = ind->start_hdl; - anpc_env->env[conidx]->ans.svc.ehdl = ind->end_hdl; - } - - anpc_env->env[conidx]->nb_svc++; + // Even if we get multiple responses we only store 1 range + anpc_env->env[conidx]->ans.svc.shdl = ind->start_hdl; + anpc_env->env[conidx]->ans.svc.ehdl = ind->end_hdl; } - return (KE_MSG_CONSUMED); + anpc_env->env[conidx]->nb_svc++; + } + + return (KE_MSG_CONSUMED); } /** @@ -696,61 +660,54 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, struct gattc_read_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct anpc_env_tag *anpc_env = PRF_ENV_GET(ANPC, anpc); - uint8_t conidx = KE_IDX_GET(dest_id); + ke_task_id_t const src_id) { + // Get the address of the environment + struct anpc_env_tag *anpc_env = PRF_ENV_GET(ANPC, anpc); + uint8_t conidx = KE_IDX_GET(dest_id); - if (anpc_env->env[conidx] != NULL) - { - ASSERT_ERR(ke_state_get(dest_id) == ANPC_BUSY); + if (anpc_env->env[conidx] != NULL) { + ASSERT_ERR(ke_state_get(dest_id) == ANPC_BUSY); - // Prepare the indication to send to the application - struct anpc_value_ind *ind = KE_MSG_ALLOC(ANPC_VALUE_IND, - prf_dst_task_get(&(anpc_env->prf_env), conidx), - dest_id, - anpc_value_ind); + // Prepare the indication to send to the application + struct anpc_value_ind *ind = KE_MSG_ALLOC( + ANPC_VALUE_IND, prf_dst_task_get(&(anpc_env->prf_env), conidx), dest_id, + anpc_value_ind); - switch (((struct anpc_cmd *)anpc_env->env[conidx]->operation)->operation) - { - // Read Supported New Alert Category Characteristic value - case (ANPC_ENABLE_RD_NEW_ALERT_OP_CODE): - { - ind->att_code = ANPC_RD_SUP_NEW_ALERT_CAT; - ind->value.supp_cat.cat_id_mask_0 = param->value[0]; - // If cat_id_mask_1 not present, shall be considered as 0 - ind->value.supp_cat.cat_id_mask_1 = (param->length > 1) - ? param->value[1] : 0x00; - } break; + switch (((struct anpc_cmd *)anpc_env->env[conidx]->operation)->operation) { + // Read Supported New Alert Category Characteristic value + case (ANPC_ENABLE_RD_NEW_ALERT_OP_CODE): { + ind->att_code = ANPC_RD_SUP_NEW_ALERT_CAT; + ind->value.supp_cat.cat_id_mask_0 = param->value[0]; + // If cat_id_mask_1 not present, shall be considered as 0 + ind->value.supp_cat.cat_id_mask_1 = + (param->length > 1) ? param->value[1] : 0x00; + } break; - case (ANPC_ENABLE_RD_UNREAD_ALERT_OP_CODE): - { - ind->att_code = ANPC_RD_SUP_UNREAD_ALERT_CAT; - ind->value.supp_cat.cat_id_mask_0 = param->value[0]; - // If cat_id_mask_1 not present, shall be considered as 0 - ind->value.supp_cat.cat_id_mask_1 = (param->length > 1) - ? param->value[1] : 0; - } break; + case (ANPC_ENABLE_RD_UNREAD_ALERT_OP_CODE): { + ind->att_code = ANPC_RD_SUP_UNREAD_ALERT_CAT; + ind->value.supp_cat.cat_id_mask_0 = param->value[0]; + // If cat_id_mask_1 not present, shall be considered as 0 + ind->value.supp_cat.cat_id_mask_1 = + (param->length > 1) ? param->value[1] : 0; + } break; - case (ANPC_READ_OP_CODE): - { - ind->att_code = ((struct anpc_read_cmd *)anpc_env->env[conidx]->operation)->read_code; - ind->value.ntf_cfg = co_read16(¶m->value[0]); - } break; + case (ANPC_READ_OP_CODE): { + ind->att_code = + ((struct anpc_read_cmd *)anpc_env->env[conidx]->operation)->read_code; + ind->value.ntf_cfg = co_read16(¶m->value[0]); + } break; - default: - { - ASSERT_ERR(0); - } break; - } - - // Send the indication - ke_msg_send(ind); + default: { + ASSERT_ERR(0); + } break; } - // else ignore the message - return (KE_MSG_CONSUMED); + // Send the indication + ke_msg_send(ind); + } + // else ignore the message + + return (KE_MSG_CONSUMED); } /** @@ -764,76 +721,70 @@ __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, - struct gattc_event_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct anpc_env_tag *anpc_env = PRF_ENV_GET(ANPC, anpc); - uint8_t conidx = KE_IDX_GET(dest_id); + struct gattc_event_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct anpc_env_tag *anpc_env = PRF_ENV_GET(ANPC, anpc); + uint8_t conidx = KE_IDX_GET(dest_id); - if (anpc_env->env[conidx] != NULL) - { - // Check the category ID - if (param->value[0] < CAT_ID_NB) - { - // New Alert Characteristic Value - if (param->handle == anpc_env->env[conidx]->ans.chars[ANPC_CHAR_NEW_ALERT].val_hdl) - { - // Text String information Length - uint8_t length = param->length - 2; + if (anpc_env->env[conidx] != NULL) { + // Check the category ID + if (param->value[0] < CAT_ID_NB) { + // New Alert Characteristic Value + if (param->handle == + anpc_env->env[conidx]->ans.chars[ANPC_CHAR_NEW_ALERT].val_hdl) { + // Text String information Length + uint8_t length = param->length - 2; - if (length > ANS_NEW_ALERT_STRING_INFO_MAX_LEN) - { - length = ANS_NEW_ALERT_STRING_INFO_MAX_LEN; - } - - // Send an indication to the application - struct anpc_value_ind *new_alert_ind = KE_MSG_ALLOC_DYN(ANPC_VALUE_IND, - prf_dst_task_get(&anpc_env->prf_env, conidx), - prf_src_task_get(&anpc_env->prf_env, conidx), - anpc_value_ind, - length); - - new_alert_ind->att_code = ANPC_NTF_NEW_ALERT; - - // Fulfill the characteristic value - new_alert_ind->value.new_alert.cat_id = param->value[0]; - new_alert_ind->value.new_alert.nb_new_alert = param->value[1]; - new_alert_ind->value.new_alert.info_str_len = length; - memcpy(&new_alert_ind->value.new_alert.str_info[0], ¶m->value[2], length); - - // Send the message - ke_msg_send(new_alert_ind); - } - // Unread Alert Status Characteristic Value - else if (param->handle == anpc_env->env[conidx]->ans.chars[ANPC_CHAR_UNREAD_ALERT_STATUS].val_hdl) - { - // Send an indication to the application - struct anpc_value_ind *unrd_alert_ind = KE_MSG_ALLOC(ANPC_VALUE_IND, - prf_dst_task_get(&anpc_env->prf_env, conidx), - prf_src_task_get(&anpc_env->prf_env, conidx), - anpc_value_ind); - - unrd_alert_ind->att_code = ANPC_NTF_UNREAD_ALERT; - - // Fulfill the characteristic value - unrd_alert_ind->value.unread_alert.cat_id = param->value[0]; - unrd_alert_ind->value.unread_alert.nb_unread_alert = param->value[1]; - - // Send the message - ke_msg_send(unrd_alert_ind); - } - else - { - ASSERT_ERR(0); - } + if (length > ANS_NEW_ALERT_STRING_INFO_MAX_LEN) { + length = ANS_NEW_ALERT_STRING_INFO_MAX_LEN; } - // else ignore the message + + // Send an indication to the application + struct anpc_value_ind *new_alert_ind = KE_MSG_ALLOC_DYN( + ANPC_VALUE_IND, prf_dst_task_get(&anpc_env->prf_env, conidx), + prf_src_task_get(&anpc_env->prf_env, conidx), anpc_value_ind, + length); + + new_alert_ind->att_code = ANPC_NTF_NEW_ALERT; + + // Fulfill the characteristic value + new_alert_ind->value.new_alert.cat_id = param->value[0]; + new_alert_ind->value.new_alert.nb_new_alert = param->value[1]; + new_alert_ind->value.new_alert.info_str_len = length; + memcpy(&new_alert_ind->value.new_alert.str_info[0], ¶m->value[2], + length); + + // Send the message + ke_msg_send(new_alert_ind); + } + // Unread Alert Status Characteristic Value + else if (param->handle == anpc_env->env[conidx] + ->ans.chars[ANPC_CHAR_UNREAD_ALERT_STATUS] + .val_hdl) { + // Send an indication to the application + struct anpc_value_ind *unrd_alert_ind = KE_MSG_ALLOC( + ANPC_VALUE_IND, prf_dst_task_get(&anpc_env->prf_env, conidx), + prf_src_task_get(&anpc_env->prf_env, conidx), anpc_value_ind); + + unrd_alert_ind->att_code = ANPC_NTF_UNREAD_ALERT; + + // Fulfill the characteristic value + unrd_alert_ind->value.unread_alert.cat_id = param->value[0]; + unrd_alert_ind->value.unread_alert.nb_unread_alert = param->value[1]; + + // Send the message + ke_msg_send(unrd_alert_ind); + } else { + ASSERT_ERR(0); + } } // else ignore the message + } + // else ignore the message - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /* @@ -842,31 +793,28 @@ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, */ /// Specifies the default message handlers -KE_MSG_HANDLER_TAB(anpc) -{ - {ANPC_ENABLE_REQ, (ke_msg_func_t)anpc_enable_req_handler}, - {ANPC_READ_CMD, (ke_msg_func_t)anpc_read_cmd_handler}, - {ANPC_WRITE_CMD, (ke_msg_func_t)anpc_write_cmd_handler}, +KE_MSG_HANDLER_TAB(anpc){ + {ANPC_ENABLE_REQ, (ke_msg_func_t)anpc_enable_req_handler}, + {ANPC_READ_CMD, (ke_msg_func_t)anpc_read_cmd_handler}, + {ANPC_WRITE_CMD, (ke_msg_func_t)anpc_write_cmd_handler}, - {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, + {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, - {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, - {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, + {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, + {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void anpc_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct anpc_env_tag *anpc_env = PRF_ENV_GET(ANPC, anpc); +void anpc_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct anpc_env_tag *anpc_env = PRF_ENV_GET(ANPC, anpc); - task_desc->msg_handler_tab = anpc_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(anpc_msg_handler_tab); - task_desc->state = anpc_env->state; - task_desc->idx_max = ANPC_IDX_MAX; + task_desc->msg_handler_tab = anpc_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(anpc_msg_handler_tab); + task_desc->state = anpc_env->state; + task_desc->idx_max = ANPC_IDX_MAX; } - #endif //(BLE_AN_CLIENT) /// @} ANPCTASK diff --git a/services/ble_profiles/anp/anps/src/anps.c b/services/ble_profiles/anp/anps/src/anps.c index b89281c..27ecb9c 100644 --- a/services/ble_profiles/anp/anps/src/anps.c +++ b/services/ble_profiles/anp/anps/src/anps.c @@ -14,11 +14,11 @@ #if (BLE_AN_SERVER) +#include "anp_common.h" #include "anps.h" #include "anps_task.h" -#include "anp_common.h" -#include "prf_utils.h" #include "prf_types.h" +#include "prf_utils.h" #include "ke_mem.h" @@ -28,39 +28,58 @@ */ /// Full ANS Database Description - Used to add attributes into the database -const struct attm_desc anps_att_db[ANS_IDX_NB] = -{ +const struct attm_desc anps_att_db[ANS_IDX_NB] = { /// Alert Notification Service Declaration - [ANS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [ANS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, /// Supported New Alert Category Characteristic Declaration - [ANS_IDX_SUPP_NEW_ALERT_CAT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [ANS_IDX_SUPP_NEW_ALERT_CAT_CHAR] = {ATT_DECL_CHARACTERISTIC, + PERM(RD, ENABLE), 0, 0}, /// Supported New Alert Category Characteristic Value - [ANS_IDX_SUPP_NEW_ALERT_CAT_VAL] = {ATT_CHAR_SUP_NEW_ALERT_CAT, PERM(RD, ENABLE), PERM(RI, ENABLE), sizeof(struct anp_cat_id_bit_mask)}, + [ANS_IDX_SUPP_NEW_ALERT_CAT_VAL] = {ATT_CHAR_SUP_NEW_ALERT_CAT, + PERM(RD, ENABLE), PERM(RI, ENABLE), + sizeof(struct anp_cat_id_bit_mask)}, /// New Alert Characteristic Declaration - [ANS_IDX_NEW_ALERT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [ANS_IDX_NEW_ALERT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, /// New Alert Characteristic Value - [ANS_IDX_NEW_ALERT_VAL] = {ATT_CHAR_NEW_ALERT, PERM(NTF, ENABLE), PERM(RI, ENABLE), ANS_NEW_ALERT_MAX_LEN}, + [ANS_IDX_NEW_ALERT_VAL] = {ATT_CHAR_NEW_ALERT, PERM(NTF, ENABLE), + PERM(RI, ENABLE), ANS_NEW_ALERT_MAX_LEN}, /// New Alert Characteristic - Client Char. Configuration Descriptor - [ANS_IDX_NEW_ALERT_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [ANS_IDX_NEW_ALERT_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, + 0}, /// Supported Unread Alert Category Characteristic Declaration - [ANS_IDX_SUPP_UNREAD_ALERT_CAT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [ANS_IDX_SUPP_UNREAD_ALERT_CAT_CHAR] = {ATT_DECL_CHARACTERISTIC, + PERM(RD, ENABLE), 0, 0}, /// Supported New Alert Category Characteristic Value - [ANS_IDX_SUPP_UNREAD_ALERT_CAT_VAL] = {ATT_CHAR_SUP_UNREAD_ALERT_CAT, PERM(RD, ENABLE), PERM(RI, ENABLE), sizeof(struct anp_cat_id_bit_mask)}, + [ANS_IDX_SUPP_UNREAD_ALERT_CAT_VAL] = {ATT_CHAR_SUP_UNREAD_ALERT_CAT, + PERM(RD, ENABLE), PERM(RI, ENABLE), + sizeof(struct anp_cat_id_bit_mask)}, /// Unread Alert Status Characteristic Declaration - [ANS_IDX_UNREAD_ALERT_STATUS_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [ANS_IDX_UNREAD_ALERT_STATUS_CHAR] = {ATT_DECL_CHARACTERISTIC, + PERM(RD, ENABLE), 0, 0}, /// Unread Alert Status Characteristic Value - [ANS_IDX_UNREAD_ALERT_STATUS_VAL] = {ATT_CHAR_UNREAD_ALERT_STATUS, PERM(NTF, ENABLE), PERM(RI, ENABLE), sizeof(struct anp_unread_alert)}, - /// Unread Alert Status Characteristic - Client Char. Configuration Descriptor - [ANS_IDX_UNREAD_ALERT_STATUS_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [ANS_IDX_UNREAD_ALERT_STATUS_VAL] = {ATT_CHAR_UNREAD_ALERT_STATUS, + PERM(NTF, ENABLE), PERM(RI, ENABLE), + sizeof(struct anp_unread_alert)}, + /// Unread Alert Status Characteristic - Client Char. Configuration + /// Descriptor + [ANS_IDX_UNREAD_ALERT_STATUS_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | + PERM(WRITE_REQ, ENABLE), + 0, 0}, /// Alert Notification Control Point Characteristic Declaration - [ANS_IDX_ALERT_NTF_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [ANS_IDX_ALERT_NTF_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, + PERM(RD, ENABLE), 0, 0}, /// Alert Notification Control Point Characteristic Value - [ANS_IDX_ALERT_NTF_CTNL_PT_VAL] = {ATT_CHAR_ALERT_NTF_CTNL_PT, PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE), 2*sizeof(uint8_t)}, + [ANS_IDX_ALERT_NTF_CTNL_PT_VAL] = {ATT_CHAR_ALERT_NTF_CTNL_PT, + PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE), 2 * sizeof(uint8_t)}, }; /* @@ -80,89 +99,95 @@ const struct attm_desc anps_att_db[ANS_IDX_NB] = * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t anps_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, struct anps_db_cfg* params) -{ - //------------------ create the attribute database for the profile ------------------- - // Service content flag - uint32_t cfg_flag = ANPS_DB_CONFIG_MASK; - // DB Creation Status - uint8_t status = ATT_ERR_NO_ERROR; +static uint8_t anps_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, + struct anps_db_cfg *params) { + //------------------ create the attribute database for the profile + //------------------- + // Service content flag + uint32_t cfg_flag = ANPS_DB_CONFIG_MASK; + // DB Creation Status + uint8_t status = ATT_ERR_NO_ERROR; - // Add service in the database - status = attm_svc_create_db(start_hdl, ATT_SVC_ALERT_NTF, (uint8_t *)&cfg_flag, - ANS_IDX_NB, NULL, env->task, &anps_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | PERM(SVC_MI, ENABLE)); + // Add service in the database + status = attm_svc_create_db( + start_hdl, ATT_SVC_ALERT_NTF, (uint8_t *)&cfg_flag, ANS_IDX_NB, NULL, + env->task, &anps_att_db[0], + (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, ENABLE)); - //-------------------- allocate memory required for the profile --------------------- - if (status == ATT_ERR_NO_ERROR) - { - // Allocate ANPS required environment variable - struct anps_env_tag* anps_env = - (struct anps_env_tag* ) ke_malloc(sizeof(struct anps_env_tag), KE_MEM_ATT_DB); + //-------------------- allocate memory required for the profile + //--------------------- + if (status == ATT_ERR_NO_ERROR) { + // Allocate ANPS required environment variable + struct anps_env_tag *anps_env = (struct anps_env_tag *)ke_malloc( + sizeof(struct anps_env_tag), KE_MEM_ATT_DB); - // Initialize ANPS environment - env->env = (prf_env_t*) anps_env; - anps_env->shdl = *start_hdl; + // Initialize ANPS environment + env->env = (prf_env_t *)anps_env; + anps_env->shdl = *start_hdl; - memcpy(&anps_env->supp_new_alert_cat, ¶ms->supp_new_alert_cat, sizeof(struct anp_cat_id_bit_mask)); - memcpy(&anps_env->supp_unread_alert_cat, ¶ms->supp_unread_alert_cat, sizeof(struct anp_cat_id_bit_mask)); + memcpy(&anps_env->supp_new_alert_cat, ¶ms->supp_new_alert_cat, + sizeof(struct anp_cat_id_bit_mask)); + memcpy(&anps_env->supp_unread_alert_cat, ¶ms->supp_unread_alert_cat, + sizeof(struct anp_cat_id_bit_mask)); - anps_env->operation = ANPS_RESERVED_OP_CODE; + anps_env->operation = ANPS_RESERVED_OP_CODE; - anps_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - // Multi Instantiated task - anps_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + anps_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + // Multi Instantiated task + anps_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_ANPS; - anps_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_ANPS; + anps_task_init(&(env->desc)); - for(uint8_t idx = 0; idx < BLE_CONNECTION_MAX ; idx++) - { - anps_env->env[idx] = NULL; - /* Put ANS in disabled state */ - ke_state_set(KE_BUILD_ID(env->task, idx), ANPS_FREE); - } + for (uint8_t idx = 0; idx < BLE_CONNECTION_MAX; idx++) { + anps_env->env[idx] = NULL; + /* Put ANS in disabled state */ + ke_state_set(KE_BUILD_ID(env->task, idx), ANPS_FREE); } + } - return (status); + return (status); } /** **************************************************************************************** * @brief Destruction of the ANPS module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void anps_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct anps_env_tag* anps_env = (struct anps_env_tag*) env->env; +static void anps_destroy(struct prf_task_env *env) { + uint8_t idx; + struct anps_env_tag *anps_env = (struct anps_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < BLE_CONNECTION_MAX ; idx++) - { - if(anps_env->env[idx] != NULL) - { - ke_free(anps_env->env[idx]); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < BLE_CONNECTION_MAX; idx++) { + if (anps_env->env[idx] != NULL) { + ke_free(anps_env->env[idx]); } + } - // free profile environment variables - env->env = NULL; - ke_free(anps_env); + // free profile environment variables + env->env = NULL; + ke_free(anps_env); } /** @@ -173,16 +198,14 @@ static void anps_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void anps_create(struct prf_task_env* env, uint8_t conidx) -{ - struct anps_env_tag* anps_env = (struct anps_env_tag*) env->env; - anps_env->env[conidx] = (struct anps_cnx_env*) - ke_malloc(sizeof(struct anps_cnx_env), KE_MEM_ATT_DB); - - memset(anps_env->env[conidx], 0, sizeof(struct anps_cnx_env)); - /* Put ANS in idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), ANPS_IDLE); +static void anps_create(struct prf_task_env *env, uint8_t conidx) { + struct anps_env_tag *anps_env = (struct anps_env_tag *)env->env; + anps_env->env[conidx] = (struct anps_cnx_env *)ke_malloc( + sizeof(struct anps_cnx_env), KE_MEM_ATT_DB); + memset(anps_env->env[conidx], 0, sizeof(struct anps_cnx_env)); + /* Put ANS in idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), ANPS_IDLE); } /** @@ -194,19 +217,18 @@ static void anps_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void anps_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct anps_env_tag* anps_env = (struct anps_env_tag*) env->env; +static void anps_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct anps_env_tag *anps_env = (struct anps_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(anps_env->env[conidx] != NULL) - { - ke_free(anps_env->env[conidx]); - anps_env->env[conidx] = NULL; - } + // clean-up environment variable allocated for task instance + if (anps_env->env[conidx] != NULL) { + ke_free(anps_env->env[conidx]); + anps_env->env[conidx] = NULL; + } - /* Put ANS in disabled state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), ANPS_FREE); + /* Put ANS in disabled state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), ANPS_FREE); } /* @@ -215,12 +237,11 @@ static void anps_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reaso */ /// ANPS Task interface required by profile manager -const struct prf_task_cbs anps_itf = -{ - (prf_init_fnct) anps_init, - anps_destroy, - anps_create, - anps_cleanup, +const struct prf_task_cbs anps_itf = { + (prf_init_fnct)anps_init, + anps_destroy, + anps_create, + anps_cleanup, }; /* @@ -228,10 +249,7 @@ const struct prf_task_cbs anps_itf = **************************************************************************************** */ -const struct prf_task_cbs* anps_prf_itf_get(void) -{ - return &anps_itf; -} +const struct prf_task_cbs *anps_prf_itf_get(void) { return &anps_itf; } /* * FUNCTION DEFINITIONS @@ -239,92 +257,83 @@ const struct prf_task_cbs* anps_prf_itf_get(void) */ void anps_send_cmp_evt(ke_task_id_t src_id, ke_task_id_t dest_id, - uint8_t operation, uint8_t status) -{ - // Come back to the Connected state if the state was busy. - if (ke_state_get(src_id) == ANPS_BUSY) - { - ke_state_set(src_id, ANPS_IDLE); - } + uint8_t operation, uint8_t status) { + // Come back to the Connected state if the state was busy. + if (ke_state_get(src_id) == ANPS_BUSY) { + ke_state_set(src_id, ANPS_IDLE); + } - // Send the message to the application - struct anps_cmp_evt *evt = KE_MSG_ALLOC(ANPS_CMP_EVT, - dest_id, src_id, - anps_cmp_evt); + // Send the message to the application + struct anps_cmp_evt *evt = + KE_MSG_ALLOC(ANPS_CMP_EVT, dest_id, src_id, anps_cmp_evt); - evt->operation = operation; - evt->status = status; + evt->operation = operation; + evt->status = status; - ke_msg_send(evt); + ke_msg_send(evt); } -void anps_send_ntf_status_update_ind(uint8_t conidx, struct anps_env_tag *idx_env, uint8_t alert_type) -{ - // Send the message to the application - struct anps_ntf_status_update_ind *ind = KE_MSG_ALLOC(ANPS_NTF_STATUS_UPDATE_IND, - prf_dst_task_get(&idx_env->prf_env, conidx), - prf_src_task_get(&idx_env->prf_env, conidx), - anps_ntf_status_update_ind); +void anps_send_ntf_status_update_ind(uint8_t conidx, + struct anps_env_tag *idx_env, + uint8_t alert_type) { + // Send the message to the application + struct anps_ntf_status_update_ind *ind = KE_MSG_ALLOC( + ANPS_NTF_STATUS_UPDATE_IND, prf_dst_task_get(&idx_env->prf_env, conidx), + prf_src_task_get(&idx_env->prf_env, conidx), anps_ntf_status_update_ind); - ind->alert_type = alert_type; - ind->ntf_ccc_cfg = ANPS_IS_ALERT_ENABLED(conidx, idx_env, alert_type) ? PRF_CLI_START_NTF : PRF_CLI_STOP_NTFIND; + ind->alert_type = alert_type; + ind->ntf_ccc_cfg = ANPS_IS_ALERT_ENABLED(conidx, idx_env, alert_type) + ? PRF_CLI_START_NTF + : PRF_CLI_STOP_NTFIND; - if (alert_type == ANP_NEW_ALERT) - { - ind->cat_ntf_cfg.cat_id_mask_0 = (uint8_t)(idx_env->env[conidx]->ntf_new_alert_cfg & 0x00FF); - ind->cat_ntf_cfg.cat_id_mask_1 = (uint8_t)((idx_env->env[conidx]->ntf_new_alert_cfg & 0xFF00) >> 8); - } - else - { - ind->cat_ntf_cfg.cat_id_mask_0 = (uint8_t)(idx_env->env[conidx]->ntf_unread_alert_cfg & 0x00FF); - ind->cat_ntf_cfg.cat_id_mask_1 = (uint8_t)(idx_env->env[conidx]->ntf_unread_alert_cfg >> 8); - } + if (alert_type == ANP_NEW_ALERT) { + ind->cat_ntf_cfg.cat_id_mask_0 = + (uint8_t)(idx_env->env[conidx]->ntf_new_alert_cfg & 0x00FF); + ind->cat_ntf_cfg.cat_id_mask_1 = + (uint8_t)((idx_env->env[conidx]->ntf_new_alert_cfg & 0xFF00) >> 8); + } else { + ind->cat_ntf_cfg.cat_id_mask_0 = + (uint8_t)(idx_env->env[conidx]->ntf_unread_alert_cfg & 0x00FF); + ind->cat_ntf_cfg.cat_id_mask_1 = + (uint8_t)(idx_env->env[conidx]->ntf_unread_alert_cfg >> 8); + } - ke_msg_send(ind); + ke_msg_send(ind); } -void anps_send_ntf_immediate_req_ind(uint8_t conidx, struct anps_env_tag *idx_env, uint8_t alert_type, - uint8_t category_id) -{ - uint16_t req_cat; +void anps_send_ntf_immediate_req_ind(uint8_t conidx, + struct anps_env_tag *idx_env, + uint8_t alert_type, uint8_t category_id) { + uint16_t req_cat; - // Send the message to the application - struct anps_ntf_immediate_req_ind *ind = KE_MSG_ALLOC(ANPS_NTF_IMMEDIATE_REQ_IND, - prf_dst_task_get(&idx_env->prf_env, conidx), - prf_src_task_get(&idx_env->prf_env, conidx), - anps_ntf_immediate_req_ind); + // Send the message to the application + struct anps_ntf_immediate_req_ind *ind = KE_MSG_ALLOC( + ANPS_NTF_IMMEDIATE_REQ_IND, prf_dst_task_get(&idx_env->prf_env, conidx), + prf_src_task_get(&idx_env->prf_env, conidx), anps_ntf_immediate_req_ind); - ind->alert_type = alert_type; + ind->alert_type = alert_type; - if (alert_type == ANP_NEW_ALERT) - { - if (category_id == CAT_ID_ALL_SUPPORTED_CAT) - { - // All category that are supported and enabled shall be notified - req_cat = idx_env->env[conidx]->ntf_new_alert_cfg; - } - else - { - req_cat = (1 << category_id); - } + if (alert_type == ANP_NEW_ALERT) { + if (category_id == CAT_ID_ALL_SUPPORTED_CAT) { + // All category that are supported and enabled shall be notified + req_cat = idx_env->env[conidx]->ntf_new_alert_cfg; + } else { + req_cat = (1 << category_id); } - else // Unread alert - { - if (category_id == CAT_ID_ALL_SUPPORTED_CAT) - { - // All category that are supported and enabled shall be notified - req_cat = idx_env->env[conidx]->ntf_unread_alert_cfg; - } - else - { - req_cat = (1 << category_id); - } + } else // Unread alert + { + if (category_id == CAT_ID_ALL_SUPPORTED_CAT) { + // All category that are supported and enabled shall be notified + req_cat = idx_env->env[conidx]->ntf_unread_alert_cfg; + } else { + req_cat = (1 << category_id); } + } - ind->cat_ntf_cfg.cat_id_mask_0 = (uint8_t)(req_cat & 0x00FF); - ind->cat_ntf_cfg.cat_id_mask_1 = (uint8_t)((req_cat & 0xFF00) >> 8); + ind->cat_ntf_cfg.cat_id_mask_0 = (uint8_t)(req_cat & 0x00FF); + ind->cat_ntf_cfg.cat_id_mask_1 = (uint8_t)((req_cat & 0xFF00) >> 8); - ke_msg_send(ind); + ke_msg_send(ind); } #endif //(BLE_AN_SERVER) diff --git a/services/ble_profiles/anp/anps/src/anps_task.c b/services/ble_profiles/anp/anps/src/anps_task.c index 000e5e6..4d26c21 100644 --- a/services/ble_profiles/anp/anps/src/anps_task.c +++ b/services/ble_profiles/anp/anps/src/anps_task.c @@ -14,13 +14,13 @@ #if (BLE_AN_SERVER) -#include "gapm.h" -#include "gattc_task.h" #include "anps.h" #include "anps_task.h" +#include "gapm.h" +#include "gattc_task.h" -#include "prf_utils.h" #include "prf_types.h" +#include "prf_utils.h" #include "co_utils.h" @@ -40,52 +40,48 @@ **************************************************************************************** */ __STATIC int anps_enable_req_handler(ke_msg_id_t const msgid, - struct anps_enable_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Alert Notification Profile Server Role Task Index Environment - struct anps_env_tag *anps_env = PRF_ENV_GET(ANPS, anps); - uint8_t conidx = KE_IDX_GET(src_id); - // Status - uint8_t status = PRF_ERR_REQ_DISALLOWED; + struct anps_enable_req *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Alert Notification Profile Server Role Task Index Environment + struct anps_env_tag *anps_env = PRF_ENV_GET(ANPS, anps); + uint8_t conidx = KE_IDX_GET(src_id); + // Status + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if(ke_state_get(dest_id) == ANPS_IDLE) - { - if (anps_env->env[conidx] != NULL) - { - // Bonded data was not used before - if (!ANPS_IS_ALERT_ENABLED(conidx, anps_env, ANPS_FLAG_CFG_PERFORMED_OK)) - { - status = GAP_ERR_NO_ERROR; - // Update the state in the environment - if (param->new_alert_ntf_cfg != PRF_CLI_STOP_NTFIND) - { - // Force to PRF_CLI_START_NTF - param->new_alert_ntf_cfg = PRF_CLI_START_NTF; + if (ke_state_get(dest_id) == ANPS_IDLE) { + if (anps_env->env[conidx] != NULL) { + // Bonded data was not used before + if (!ANPS_IS_ALERT_ENABLED(conidx, anps_env, + ANPS_FLAG_CFG_PERFORMED_OK)) { + status = GAP_ERR_NO_ERROR; + // Update the state in the environment + if (param->new_alert_ntf_cfg != PRF_CLI_STOP_NTFIND) { + // Force to PRF_CLI_START_NTF + param->new_alert_ntf_cfg = PRF_CLI_START_NTF; - ANPS_ENABLE_ALERT(conidx, anps_env, ANP_NEW_ALERT); - } - - if (param->unread_alert_status_ntf_cfg != PRF_CLI_STOP_NTFIND) - { - // Force to PRF_CLI_START_NTF - param->unread_alert_status_ntf_cfg = PRF_CLI_START_NTF; - - ANPS_ENABLE_ALERT(conidx, anps_env, ANP_UNREAD_ALERT); - } - } - // Enable Bonded Data - ANPS_ENABLE_ALERT(conidx, anps_env, ANPS_FLAG_CFG_PERFORMED_OK); + ANPS_ENABLE_ALERT(conidx, anps_env, ANP_NEW_ALERT); } - } - // send completed information to APP task that contains error status - struct anps_enable_rsp *cmp_evt = KE_MSG_ALLOC(ANPS_ENABLE_RSP, src_id, dest_id, anps_enable_rsp); - cmp_evt->status = status; - ke_msg_send(cmp_evt); + if (param->unread_alert_status_ntf_cfg != PRF_CLI_STOP_NTFIND) { + // Force to PRF_CLI_START_NTF + param->unread_alert_status_ntf_cfg = PRF_CLI_START_NTF; - return (KE_MSG_CONSUMED); + ANPS_ENABLE_ALERT(conidx, anps_env, ANP_UNREAD_ALERT); + } + } + // Enable Bonded Data + ANPS_ENABLE_ALERT(conidx, anps_env, ANPS_FLAG_CFG_PERFORMED_OK); + } + } + + // send completed information to APP task that contains error status + struct anps_enable_rsp *cmp_evt = + KE_MSG_ALLOC(ANPS_ENABLE_RSP, src_id, dest_id, anps_enable_rsp); + cmp_evt->status = status; + ke_msg_send(cmp_evt); + + return (KE_MSG_CONSUMED); } /** @@ -99,161 +95,140 @@ __STATIC int anps_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int anps_ntf_alert_cmd_handler(ke_msg_id_t const msgid, - struct anps_ntf_alert_cmd const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = PRF_ERR_INVALID_PARAM; - // Message Status - uint8_t msg_status = KE_MSG_CONSUMED; - // Task environment - struct anps_env_tag *anps_env = PRF_ENV_GET(ANPS, anps); - uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); + struct anps_ntf_alert_cmd const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = PRF_ERR_INVALID_PARAM; + // Message Status + uint8_t msg_status = KE_MSG_CONSUMED; + // Task environment + struct anps_env_tag *anps_env = PRF_ENV_GET(ANPS, anps); + uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t state = ke_state_get(dest_id); - if(state == ANPS_IDLE) - { - // Category ID - uint8_t cat_id; - // Is the category supported ? - bool cat_supported; - // Handle - uint16_t handle = ATT_ERR_INVALID_HANDLE; + if (state == ANPS_IDLE) { + // Category ID + uint8_t cat_id; + // Is the category supported ? + bool cat_supported; + // Handle + uint16_t handle = ATT_ERR_INVALID_HANDLE; - ASSERT_ERR(anps_env != NULL); - ASSERT_ERR(anps_env->env[conidx] != NULL); + ASSERT_ERR(anps_env != NULL); + ASSERT_ERR(anps_env->env[conidx] != NULL); - do - { - // Check the operation code, get the category ID. - if (param->operation == ANPS_UPD_NEW_ALERT_OP_CODE) - { - // Check the length of the string info value - if (param->value.new_alert.info_str_len > ANS_NEW_ALERT_STRING_INFO_MAX_LEN) - { - status = PRF_ERR_INVALID_PARAM; - break; - } + do { + // Check the operation code, get the category ID. + if (param->operation == ANPS_UPD_NEW_ALERT_OP_CODE) { + // Check the length of the string info value + if (param->value.new_alert.info_str_len > + ANS_NEW_ALERT_STRING_INFO_MAX_LEN) { + status = PRF_ERR_INVALID_PARAM; + break; + } - // Get the category ID - cat_id = param->value.new_alert.cat_id; - // Check if the category is supported - cat_supported = ANPS_IS_NEW_ALERT_CATEGORY_SUPPORTED(cat_id); - } - else if (param->operation == ANPS_UPD_UNREAD_ALERT_STATUS_OP_CODE) - { - // Get the category ID - cat_id = param->value.unread_alert_status.cat_id; - // Check if the category is supported - cat_supported = ANPS_IS_UNREAD_ALERT_CATEGORY_SUPPORTED(cat_id); - } - else - { - status = PRF_ERR_INVALID_PARAM; - break; - } + // Get the category ID + cat_id = param->value.new_alert.cat_id; + // Check if the category is supported + cat_supported = ANPS_IS_NEW_ALERT_CATEGORY_SUPPORTED(cat_id); + } else if (param->operation == ANPS_UPD_UNREAD_ALERT_STATUS_OP_CODE) { + // Get the category ID + cat_id = param->value.unread_alert_status.cat_id; + // Check if the category is supported + cat_supported = ANPS_IS_UNREAD_ALERT_CATEGORY_SUPPORTED(cat_id); + } else { + status = PRF_ERR_INVALID_PARAM; + break; + } - // Check the category ID - if ((cat_id >= CAT_ID_NB) || (!cat_supported)) - { - status = PRF_ERR_INVALID_PARAM; - break; - } + // Check the category ID + if ((cat_id >= CAT_ID_NB) || (!cat_supported)) { + status = PRF_ERR_INVALID_PARAM; + break; + } - if (param->operation == ANPS_UPD_NEW_ALERT_OP_CODE) - { - // Check if sending of notification is enabled for the provided category - if (ANPS_IS_NEW_ALERT_CATEGORY_ENABLED(conidx, cat_id, anps_env) && - ANPS_IS_ALERT_ENABLED(conidx, anps_env, ANP_NEW_ALERT)) - { - handle = anps_env->shdl + ANS_IDX_NEW_ALERT_VAL; + if (param->operation == ANPS_UPD_NEW_ALERT_OP_CODE) { + // Check if sending of notification is enabled for the provided category + if (ANPS_IS_NEW_ALERT_CATEGORY_ENABLED(conidx, cat_id, anps_env) && + ANPS_IS_ALERT_ENABLED(conidx, anps_env, ANP_NEW_ALERT)) { + handle = anps_env->shdl + ANS_IDX_NEW_ALERT_VAL; - // Allocate the GATT notification message - struct gattc_send_evt_cmd *ntf = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), dest_id, - gattc_send_evt_cmd, 2 + param->value.new_alert.info_str_len); + // Allocate the GATT notification message + struct gattc_send_evt_cmd *ntf = KE_MSG_ALLOC_DYN( + GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), dest_id, + gattc_send_evt_cmd, 2 + param->value.new_alert.info_str_len); - // Fill in the parameter structure - ntf->operation = GATTC_NOTIFY; - ntf->handle = handle; - // pack measured value in database - ntf->length = 2 + param->value.new_alert.info_str_len; - // Fill data - memcpy(&ntf->value, ¶m->value.new_alert.cat_id, ntf->length); + // Fill in the parameter structure + ntf->operation = GATTC_NOTIFY; + ntf->handle = handle; + // pack measured value in database + ntf->length = 2 + param->value.new_alert.info_str_len; + // Fill data + memcpy(&ntf->value, ¶m->value.new_alert.cat_id, ntf->length); - // The notification can be sent, send the notification - status = GAP_ERR_NO_ERROR; - ke_msg_send(ntf); - } - else - { - status = PRF_ERR_NTF_DISABLED; - break; - } - } - else - { - if (ANPS_IS_UNREAD_ALERT_CATEGORY_ENABLED(conidx, cat_id, anps_env) && - ANPS_IS_ALERT_ENABLED(conidx, anps_env, ANP_UNREAD_ALERT)) - { - handle = anps_env->shdl + ANS_IDX_UNREAD_ALERT_STATUS_VAL; + // The notification can be sent, send the notification + status = GAP_ERR_NO_ERROR; + ke_msg_send(ntf); + } else { + status = PRF_ERR_NTF_DISABLED; + break; + } + } else { + if (ANPS_IS_UNREAD_ALERT_CATEGORY_ENABLED(conidx, cat_id, anps_env) && + ANPS_IS_ALERT_ENABLED(conidx, anps_env, ANP_UNREAD_ALERT)) { + handle = anps_env->shdl + ANS_IDX_UNREAD_ALERT_STATUS_VAL; - // Allocate the GATT notification message - struct gattc_send_evt_cmd *ntf = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), dest_id, - gattc_send_evt_cmd, sizeof(struct anp_unread_alert)); + // Allocate the GATT notification message + struct gattc_send_evt_cmd *ntf = KE_MSG_ALLOC_DYN( + GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), dest_id, + gattc_send_evt_cmd, sizeof(struct anp_unread_alert)); - // Fill in the parameter structure - ntf->operation = GATTC_NOTIFY; - ntf->handle = handle; - // pack measured value in database - ntf->length = sizeof(struct anp_unread_alert); - // Fill data - memcpy(&ntf->value, ¶m->value.unread_alert_status, ntf->length); + // Fill in the parameter structure + ntf->operation = GATTC_NOTIFY; + ntf->handle = handle; + // pack measured value in database + ntf->length = sizeof(struct anp_unread_alert); + // Fill data + memcpy(&ntf->value, ¶m->value.unread_alert_status, ntf->length); - // The notification can be sent, send the notification - status = GAP_ERR_NO_ERROR; - ke_msg_send(ntf); - } - else - { - status = PRF_ERR_NTF_DISABLED; - break; - } - } + // The notification can be sent, send the notification + status = GAP_ERR_NO_ERROR; + ke_msg_send(ntf); + } else { + status = PRF_ERR_NTF_DISABLED; + break; + } + } - // Configure the environment - anps_env->operation = param->operation; - // Go to Busy state - ke_state_set(dest_id, ANPS_BUSY); - } while(0); - } - else if (state == ANPS_BUSY) - { - // Save it for later - msg_status = KE_MSG_SAVED; - status = GAP_ERR_NO_ERROR; - } - // no connection - else - { - status = GAP_ERR_DISCONNECTED; - } + // Configure the environment + anps_env->operation = param->operation; + // Go to Busy state + ke_state_set(dest_id, ANPS_BUSY); + } while (0); + } else if (state == ANPS_BUSY) { + // Save it for later + msg_status = KE_MSG_SAVED; + status = GAP_ERR_NO_ERROR; + } + // no connection + else { + status = GAP_ERR_DISCONNECTED; + } - if(status != GAP_ERR_NO_ERROR) - { - // Send the message to the application - anps_send_cmp_evt(dest_id, src_id, param->operation, status); - } + if (status != GAP_ERR_NO_ERROR) { + // Send the message to the application + anps_send_cmp_evt(dest_id, src_id, param->operation, status); + } - return (int)msg_status; + return (int)msg_status; } /** **************************************************************************************** - * @brief Handles @ref GATTC_CMP_EVT message meaning that a notification or an indication - * has been correctly sent to peer device (but not confirmed by peer device). + * @brief Handles @ref GATTC_CMP_EVT message meaning that a notification or an + *indication has been correctly sent to peer device (but not confirmed by peer + *device). * * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. @@ -263,24 +238,22 @@ __STATIC int anps_ntf_alert_cmd_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, - struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct anps_env_tag *anps_env = PRF_ENV_GET(ANPS, anps); - uint8_t conidx = KE_IDX_GET(src_id); + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct anps_env_tag *anps_env = PRF_ENV_GET(ANPS, anps); + uint8_t conidx = KE_IDX_GET(src_id); - if (anps_env != NULL) - { - // Send a complete event status to the application - anps_send_cmp_evt(prf_src_task_get(&anps_env->prf_env, conidx), - prf_dst_task_get(&anps_env->prf_env, conidx), - anps_env->operation, param->status); - } - // else ignore the message + if (anps_env != NULL) { + // Send a complete event status to the application + anps_send_cmp_evt(prf_src_task_get(&anps_env->prf_env, conidx), + prf_dst_task_get(&anps_env->prf_env, conidx), + anps_env->operation, param->status); + } + // else ignore the message - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -295,71 +268,65 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_read_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if(ke_state_get(dest_id) == ANPS_IDLE) - { - // Get the address of the environment - struct anps_env_tag *anps_env = PRF_ENV_GET(ANPS, anps); - uint8_t conidx = KE_IDX_GET(src_id); - uint8_t att_idx = param->handle - anps_env->shdl; + struct gattc_read_req_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + if (ke_state_get(dest_id) == ANPS_IDLE) { + // Get the address of the environment + struct anps_env_tag *anps_env = PRF_ENV_GET(ANPS, anps); + uint8_t conidx = KE_IDX_GET(src_id); + uint8_t att_idx = param->handle - anps_env->shdl; - uint8_t value[2]; - uint8_t value_size = 0; - uint8_t status = ATT_ERR_NO_ERROR; + uint8_t value[2]; + uint8_t value_size = 0; + uint8_t status = ATT_ERR_NO_ERROR; - switch(att_idx) - { - case ANS_IDX_SUPP_NEW_ALERT_CAT_VAL: - { - // Fill data - value_size = sizeof(uint16_t); - co_write16p(value, anps_env->supp_new_alert_cat); - } break; + switch (att_idx) { + case ANS_IDX_SUPP_NEW_ALERT_CAT_VAL: { + // Fill data + value_size = sizeof(uint16_t); + co_write16p(value, anps_env->supp_new_alert_cat); + } break; - case ANS_IDX_NEW_ALERT_CFG: - { - // Fill data - value_size = sizeof(uint16_t); - co_write16p(value, ANPS_IS_ALERT_ENABLED(conidx, anps_env, ANP_NEW_ALERT)); - } break; + case ANS_IDX_NEW_ALERT_CFG: { + // Fill data + value_size = sizeof(uint16_t); + co_write16p(value, + ANPS_IS_ALERT_ENABLED(conidx, anps_env, ANP_NEW_ALERT)); + } break; - case ANS_IDX_SUPP_UNREAD_ALERT_CAT_VAL: - { - // Fill data - value_size = sizeof(uint16_t); - co_write16p(value, anps_env->supp_unread_alert_cat); - } break; + case ANS_IDX_SUPP_UNREAD_ALERT_CAT_VAL: { + // Fill data + value_size = sizeof(uint16_t); + co_write16p(value, anps_env->supp_unread_alert_cat); + } break; - case ANS_IDX_UNREAD_ALERT_STATUS_CFG: - { - // Fill data - value_size = sizeof(uint16_t); - co_write16p(value, ANPS_IS_ALERT_ENABLED(conidx, anps_env, ANP_UNREAD_ALERT)); - } break; + case ANS_IDX_UNREAD_ALERT_STATUS_CFG: { + // Fill data + value_size = sizeof(uint16_t); + co_write16p(value, + ANPS_IS_ALERT_ENABLED(conidx, anps_env, ANP_UNREAD_ALERT)); + } break; - default: - { - status = ATT_ERR_REQUEST_NOT_SUPPORTED; - } break; - } - - // Send data to peer device - struct gattc_read_cfm* cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, value_size); - cfm->length = value_size; - memcpy(cfm->value, value, value_size); - cfm->handle = param->handle; - cfm->status = status; - - // Send value to peer device. - ke_msg_send(cfm); + default: { + status = ATT_ERR_REQUEST_NOT_SUPPORTED; + } break; } - return (KE_MSG_CONSUMED); -} + // Send data to peer device + struct gattc_read_cfm *cfm = KE_MSG_ALLOC_DYN( + GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, value_size); + cfm->length = value_size; + memcpy(cfm->value, value, value_size); + cfm->handle = param->handle; + cfm->status = status; + // Send value to peer device. + ke_msg_send(cfm); + } + + return (KE_MSG_CONSUMED); +} /** **************************************************************************************** @@ -371,257 +338,227 @@ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_write_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; - // Get the conidx - uint8_t conidx = KE_IDX_GET(src_id); - // Get the address of the environment - struct anps_env_tag *anps_env = PRF_ENV_GET(ANPS, anps); +__STATIC int gattc_write_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; + // Get the conidx + uint8_t conidx = KE_IDX_GET(src_id); + // Get the address of the environment + struct anps_env_tag *anps_env = PRF_ENV_GET(ANPS, anps); - // Check if the connection exists - if (anps_env != NULL) - { - /* - * --------------------------------------------------------------------------------------------- - * New Alert Client Characteristic Configuration Descriptor Value - Write - * --------------------------------------------------------------------------------------------- - * Unread Status Alert Client Characteristic Configuration Descriptor Value - Write - * --------------------------------------------------------------------------------------------- - */ - if ((param->handle == (anps_env->shdl + ANS_IDX_NEW_ALERT_CFG)) || - (param->handle == (anps_env->shdl + ANS_IDX_UNREAD_ALERT_STATUS_CFG))) - { - // Received configuration value - uint16_t ntf_cfg = co_read16p(¶m->value[0]); + // Check if the connection exists + if (anps_env != NULL) { + /* + * --------------------------------------------------------------------------------------------- + * New Alert Client Characteristic Configuration Descriptor Value - Write + * --------------------------------------------------------------------------------------------- + * Unread Status Alert Client Characteristic Configuration Descriptor Value + * - Write + * --------------------------------------------------------------------------------------------- + */ + if ((param->handle == (anps_env->shdl + ANS_IDX_NEW_ALERT_CFG)) || + (param->handle == (anps_env->shdl + ANS_IDX_UNREAD_ALERT_STATUS_CFG))) { + // Received configuration value + uint16_t ntf_cfg = co_read16p(¶m->value[0]); - if (ntf_cfg <= PRF_CLI_START_NTF) - { - // Alert type - uint8_t alert_type = (param->handle == (anps_env->shdl + ANS_IDX_NEW_ALERT_CFG)) - ? ANP_NEW_ALERT : ANP_UNREAD_ALERT; + if (ntf_cfg <= PRF_CLI_START_NTF) { + // Alert type + uint8_t alert_type = + (param->handle == (anps_env->shdl + ANS_IDX_NEW_ALERT_CFG)) + ? ANP_NEW_ALERT + : ANP_UNREAD_ALERT; - // Update the status in the environment - if (ntf_cfg == PRF_CLI_START_NTF) - { - ANPS_ENABLE_ALERT(conidx, anps_env, alert_type); - } - else - { - ANPS_DISABLE_ALERT(conidx, anps_env, alert_type); - } - - // Inform the HL that the notification configuration status has been written - anps_send_ntf_status_update_ind(conidx, anps_env, alert_type); - // Enable bond Data - ANPS_ENABLE_ALERT(conidx, anps_env, ANPS_FLAG_CFG_PERFORMED_OK); - } - else - { - status = PRF_APP_ERROR; - } + // Update the status in the environment + if (ntf_cfg == PRF_CLI_START_NTF) { + ANPS_ENABLE_ALERT(conidx, anps_env, alert_type); + } else { + ANPS_DISABLE_ALERT(conidx, anps_env, alert_type); } - /* - * --------------------------------------------------------------------------------------------- - * Alert Notification Control Point Characteristic Value - Write - * --------------------------------------------------------------------------------------------- - */ - else if (param->handle == (anps_env->shdl + ANS_IDX_ALERT_NTF_CTNL_PT_VAL)) - { - do - { - // Check the command ID value - if (param->value[0] >= CMD_ID_NB) - { - status = ANP_CMD_NOT_SUPPORTED; - break; - } - // Check the category ID value - if ((param->value[1] >= CAT_ID_NB) && - (param->value[1] != CAT_ID_ALL_SUPPORTED_CAT)) - { - status = ANP_CAT_NOT_SUPPORTED; - break; - } - - if (param->value[1] < CAT_ID_NB) - { - // New Alert - if ((param->value[0] % 2) == 0) - { - // Check if the category is supported - if (!ANPS_IS_NEW_ALERT_CATEGORY_SUPPORTED(param->value[1])) - { - status = ANP_CAT_NOT_SUPPORTED; - break; - } - } - // Unread Alert Status - else - { - // Check if the category is supported - if (!ANPS_IS_UNREAD_ALERT_CATEGORY_SUPPORTED(param->value[1])) - { - status = ANP_CAT_NOT_SUPPORTED; - break; - } - } - } - - // React according to the received command id value - switch (param->value[0]) - { - // Enable New Alert Notification - case (CMD_ID_EN_NEW_IN_ALERT_NTF): - { - if (param->value[1] != CAT_ID_ALL_SUPPORTED_CAT) - { - // Enable sending of new alert notification for the specified category - ANPS_ENABLE_NEW_ALERT_CATEGORY(conidx, param->value[1], anps_env); - } - else - { - // Enable sending of new alert notification for all supported category - anps_env->env[conidx]->ntf_new_alert_cfg |= anps_env->supp_new_alert_cat; - } - - anps_send_ntf_status_update_ind(conidx, anps_env, ANP_NEW_ALERT); - } break; - - // Enable Unread Alert Status Notification - case (CMD_ID_EN_UNREAD_CAT_STATUS_NTF): - { - if (param->value[1] != CAT_ID_ALL_SUPPORTED_CAT) - { - // Enable sending of unread alert notification for the specified category - ANPS_ENABLE_UNREAD_ALERT_CATEGORY(conidx, param->value[1], anps_env); - } - else - { - // Enable sending of unread alert notification for all supported category - anps_env->env[conidx]->ntf_unread_alert_cfg |= anps_env->supp_unread_alert_cat; - } - - anps_send_ntf_status_update_ind(conidx, anps_env, ANP_UNREAD_ALERT); - } break; - - // Disable New Alert Notification - case (CMD_ID_DIS_NEW_IN_ALERT_NTF): - { - if (param->value[1] != CAT_ID_ALL_SUPPORTED_CAT) - { - // Disable sending of new alert notification for the specified category - ANPS_DISABLE_NEW_ALERT_CATEGORY(conidx, param->value[1], anps_env); - } - else - { - // Disable sending of new alert notification for all supported category - anps_env->env[conidx]->ntf_new_alert_cfg &= ~anps_env->supp_new_alert_cat; - } - - anps_send_ntf_status_update_ind(conidx, anps_env, ANP_NEW_ALERT); - } break; - - // Disable Unread Alert Status Notification - case (CMD_ID_DIS_UNREAD_CAT_STATUS_NTF): - { - if (param->value[1] != CAT_ID_ALL_SUPPORTED_CAT) - { - // Disable sending of unread alert notification for the specified category - ANPS_DISABLE_UNREAD_ALERT_CATEGORY(conidx, param->value[1], anps_env); - } - else - { - // Enable sending of unread alert notification for all supported category - anps_env->env[conidx]->ntf_unread_alert_cfg &= ~anps_env->supp_unread_alert_cat; - } - - anps_send_ntf_status_update_ind(conidx, anps_env, ANP_UNREAD_ALERT); - } break; - - // Notify New Alert immediately - case (CMD_ID_NTF_NEW_IN_ALERT_IMM): - { - // Check if sending of notification is enabled - if (ANPS_IS_ALERT_ENABLED(conidx, anps_env, ANP_NEW_ALERT)) - { - if (param->value[1] == CAT_ID_ALL_SUPPORTED_CAT) - { - // Check if at least one category can be notified - if (anps_env->env[conidx]->ntf_new_alert_cfg != 0) - { - anps_send_ntf_immediate_req_ind(conidx, anps_env, ANP_NEW_ALERT, - CAT_ID_ALL_SUPPORTED_CAT); - } - } - else - { - // Check if sending of notifications has been enabled for the specified category. - if (ANPS_IS_NEW_ALERT_CATEGORY_ENABLED(conidx, param->value[1], anps_env)) - { - anps_send_ntf_immediate_req_ind(conidx, anps_env, ANP_NEW_ALERT, - param->value[1]); - } - } - } - } break; - - // Notify Unread Alert Status immediately - case (CMD_ID_NTF_UNREAD_CAT_STATUS_IMM): - { - if (ANPS_IS_ALERT_ENABLED(conidx, anps_env, ANP_UNREAD_ALERT)) - { - // Check if sending of notification is enabled - if (ANPS_IS_ALERT_ENABLED(conidx, anps_env, ANP_UNREAD_ALERT)) - { - if (param->value[1] == CAT_ID_ALL_SUPPORTED_CAT) - { - // Check if at least one category can be notified - if (anps_env->env[conidx]->ntf_unread_alert_cfg != 0) - { - anps_send_ntf_immediate_req_ind(conidx, anps_env, ANP_UNREAD_ALERT, - CAT_ID_ALL_SUPPORTED_CAT); - } - } - else - { - // Check if sending of notifications has been enabled for the specified category. - if (ANPS_IS_UNREAD_ALERT_CATEGORY_ENABLED(conidx, param->value[1], anps_env)) - { - anps_send_ntf_immediate_req_ind(conidx, anps_env, ANP_UNREAD_ALERT, - param->value[1]); - } - } - } - } - } break; - - default: - { - ASSERT_ERR(0); - } break; - } - } while (0); - } - else - { - ASSERT_ERR(0); - } - // Send the write response to the peer device - struct gattc_write_cfm *cfm = KE_MSG_ALLOC( - GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = status; - ke_msg_send(cfm); + // Inform the HL that the notification configuration status has been + // written + anps_send_ntf_status_update_ind(conidx, anps_env, alert_type); + // Enable bond Data + ANPS_ENABLE_ALERT(conidx, anps_env, ANPS_FLAG_CFG_PERFORMED_OK); + } else { + status = PRF_APP_ERROR; + } } - // else ignore the message + /* + * --------------------------------------------------------------------------------------------- + * Alert Notification Control Point Characteristic Value - Write + * --------------------------------------------------------------------------------------------- + */ + else if (param->handle == + (anps_env->shdl + ANS_IDX_ALERT_NTF_CTNL_PT_VAL)) { + do { + // Check the command ID value + if (param->value[0] >= CMD_ID_NB) { + status = ANP_CMD_NOT_SUPPORTED; + break; + } - return (KE_MSG_CONSUMED); + // Check the category ID value + if ((param->value[1] >= CAT_ID_NB) && + (param->value[1] != CAT_ID_ALL_SUPPORTED_CAT)) { + status = ANP_CAT_NOT_SUPPORTED; + break; + } + + if (param->value[1] < CAT_ID_NB) { + // New Alert + if ((param->value[0] % 2) == 0) { + // Check if the category is supported + if (!ANPS_IS_NEW_ALERT_CATEGORY_SUPPORTED(param->value[1])) { + status = ANP_CAT_NOT_SUPPORTED; + break; + } + } + // Unread Alert Status + else { + // Check if the category is supported + if (!ANPS_IS_UNREAD_ALERT_CATEGORY_SUPPORTED(param->value[1])) { + status = ANP_CAT_NOT_SUPPORTED; + break; + } + } + } + + // React according to the received command id value + switch (param->value[0]) { + // Enable New Alert Notification + case (CMD_ID_EN_NEW_IN_ALERT_NTF): { + if (param->value[1] != CAT_ID_ALL_SUPPORTED_CAT) { + // Enable sending of new alert notification for the specified + // category + ANPS_ENABLE_NEW_ALERT_CATEGORY(conidx, param->value[1], anps_env); + } else { + // Enable sending of new alert notification for all supported + // category + anps_env->env[conidx]->ntf_new_alert_cfg |= + anps_env->supp_new_alert_cat; + } + + anps_send_ntf_status_update_ind(conidx, anps_env, ANP_NEW_ALERT); + } break; + + // Enable Unread Alert Status Notification + case (CMD_ID_EN_UNREAD_CAT_STATUS_NTF): { + if (param->value[1] != CAT_ID_ALL_SUPPORTED_CAT) { + // Enable sending of unread alert notification for the specified + // category + ANPS_ENABLE_UNREAD_ALERT_CATEGORY(conidx, param->value[1], + anps_env); + } else { + // Enable sending of unread alert notification for all supported + // category + anps_env->env[conidx]->ntf_unread_alert_cfg |= + anps_env->supp_unread_alert_cat; + } + + anps_send_ntf_status_update_ind(conidx, anps_env, ANP_UNREAD_ALERT); + } break; + + // Disable New Alert Notification + case (CMD_ID_DIS_NEW_IN_ALERT_NTF): { + if (param->value[1] != CAT_ID_ALL_SUPPORTED_CAT) { + // Disable sending of new alert notification for the specified + // category + ANPS_DISABLE_NEW_ALERT_CATEGORY(conidx, param->value[1], anps_env); + } else { + // Disable sending of new alert notification for all supported + // category + anps_env->env[conidx]->ntf_new_alert_cfg &= + ~anps_env->supp_new_alert_cat; + } + + anps_send_ntf_status_update_ind(conidx, anps_env, ANP_NEW_ALERT); + } break; + + // Disable Unread Alert Status Notification + case (CMD_ID_DIS_UNREAD_CAT_STATUS_NTF): { + if (param->value[1] != CAT_ID_ALL_SUPPORTED_CAT) { + // Disable sending of unread alert notification for the specified + // category + ANPS_DISABLE_UNREAD_ALERT_CATEGORY(conidx, param->value[1], + anps_env); + } else { + // Enable sending of unread alert notification for all supported + // category + anps_env->env[conidx]->ntf_unread_alert_cfg &= + ~anps_env->supp_unread_alert_cat; + } + + anps_send_ntf_status_update_ind(conidx, anps_env, ANP_UNREAD_ALERT); + } break; + + // Notify New Alert immediately + case (CMD_ID_NTF_NEW_IN_ALERT_IMM): { + // Check if sending of notification is enabled + if (ANPS_IS_ALERT_ENABLED(conidx, anps_env, ANP_NEW_ALERT)) { + if (param->value[1] == CAT_ID_ALL_SUPPORTED_CAT) { + // Check if at least one category can be notified + if (anps_env->env[conidx]->ntf_new_alert_cfg != 0) { + anps_send_ntf_immediate_req_ind(conidx, anps_env, ANP_NEW_ALERT, + CAT_ID_ALL_SUPPORTED_CAT); + } + } else { + // Check if sending of notifications has been enabled for the + // specified category. + if (ANPS_IS_NEW_ALERT_CATEGORY_ENABLED(conidx, param->value[1], + anps_env)) { + anps_send_ntf_immediate_req_ind(conidx, anps_env, ANP_NEW_ALERT, + param->value[1]); + } + } + } + } break; + + // Notify Unread Alert Status immediately + case (CMD_ID_NTF_UNREAD_CAT_STATUS_IMM): { + if (ANPS_IS_ALERT_ENABLED(conidx, anps_env, ANP_UNREAD_ALERT)) { + // Check if sending of notification is enabled + if (ANPS_IS_ALERT_ENABLED(conidx, anps_env, ANP_UNREAD_ALERT)) { + if (param->value[1] == CAT_ID_ALL_SUPPORTED_CAT) { + // Check if at least one category can be notified + if (anps_env->env[conidx]->ntf_unread_alert_cfg != 0) { + anps_send_ntf_immediate_req_ind(conidx, anps_env, + ANP_UNREAD_ALERT, + CAT_ID_ALL_SUPPORTED_CAT); + } + } else { + // Check if sending of notifications has been enabled for the + // specified category. + if (ANPS_IS_UNREAD_ALERT_CATEGORY_ENABLED( + conidx, param->value[1], anps_env)) { + anps_send_ntf_immediate_req_ind( + conidx, anps_env, ANP_UNREAD_ALERT, param->value[1]); + } + } + } + } + } break; + + default: { + ASSERT_ERR(0); + } break; + } + } while (0); + } else { + ASSERT_ERR(0); + } + // Send the write response to the peer device + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = status; + ke_msg_send(cfm); + } + // else ignore the message + + return (KE_MSG_CONSUMED); } /* @@ -630,24 +567,22 @@ __STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, */ /// Specifies the default message handlers -KE_MSG_HANDLER_TAB(anps) -{ - {ANPS_ENABLE_REQ, (ke_msg_func_t)anps_enable_req_handler}, - {ANPS_NTF_ALERT_CMD, (ke_msg_func_t)anps_ntf_alert_cmd_handler}, - {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, - {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, +KE_MSG_HANDLER_TAB(anps){ + {ANPS_ENABLE_REQ, (ke_msg_func_t)anps_enable_req_handler}, + {ANPS_NTF_ALERT_CMD, (ke_msg_func_t)anps_ntf_alert_cmd_handler}, + {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, + {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void anps_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct anps_env_tag *anps_env = PRF_ENV_GET(ANPS, anps); +void anps_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct anps_env_tag *anps_env = PRF_ENV_GET(ANPS, anps); - task_desc->msg_handler_tab = anps_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(anps_msg_handler_tab); - task_desc->state = anps_env->state; - task_desc->idx_max = ANPS_IDX_MAX; + task_desc->msg_handler_tab = anps_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(anps_msg_handler_tab); + task_desc->state = anps_env->state; + task_desc->idx_max = ANPS_IDX_MAX; } #endif //(BLE_AN_SERVER) diff --git a/services/ble_profiles/bas/basc/src/basc.c b/services/ble_profiles/bas/basc/src/basc.c index 1c445f9..6fb1842 100644 --- a/services/ble_profiles/bas/basc/src/basc.c +++ b/services/ble_profiles/bas/basc/src/basc.c @@ -13,10 +13,10 @@ #if (BLE_BATT_CLIENT) -#include "gap.h" #include "basc.h" #include "basc_task.h" #include "co_math.h" +#include "gap.h" #include "ke_mem.h" @@ -36,74 +36,73 @@ * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t basc_init (struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t idx; - //-------------------- allocate memory required for the profile --------------------- +static uint8_t basc_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t idx; + //-------------------- allocate memory required for the profile + //--------------------- - struct basc_env_tag* basc_env = - (struct basc_env_tag* ) ke_malloc(sizeof(struct basc_env_tag), KE_MEM_ATT_DB); + struct basc_env_tag *basc_env = (struct basc_env_tag *)ke_malloc( + sizeof(struct basc_env_tag), KE_MEM_ATT_DB); - // allocate BASC required environment variable - env->env = (prf_env_t*) basc_env; + // allocate BASC required environment variable + env->env = (prf_env_t *)basc_env; - basc_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - basc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + basc_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + basc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_BASC; - basc_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_BASC; + basc_task_init(&(env->desc)); - for(idx = 0; idx < BASC_IDX_MAX ; idx++) - { - basc_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), BASC_FREE); - } + for (idx = 0; idx < BASC_IDX_MAX; idx++) { + basc_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), BASC_FREE); + } - - return GAP_ERR_NO_ERROR; + return GAP_ERR_NO_ERROR; } /** **************************************************************************************** * @brief Destruction of the BASC module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void basc_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct basc_env_tag* basc_env = (struct basc_env_tag*) env->env; +static void basc_destroy(struct prf_task_env *env) { + uint8_t idx; + struct basc_env_tag *basc_env = (struct basc_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < BASC_IDX_MAX ; idx++) - { - if(basc_env->env[idx] != NULL) - { - if(basc_env->env[idx]->operation != NULL) - { - ke_free(basc_env->env[idx]->operation); - } - ke_free(basc_env->env[idx]); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < BASC_IDX_MAX; idx++) { + if (basc_env->env[idx] != NULL) { + if (basc_env->env[idx]->operation != NULL) { + ke_free(basc_env->env[idx]->operation); + } + ke_free(basc_env->env[idx]); } + } - // free profile environment variables - env->env = NULL; - ke_free(basc_env); + // free profile environment variables + env->env = NULL; + ke_free(basc_env); } /** @@ -114,10 +113,9 @@ static void basc_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void basc_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Put BAS Client in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), BASC_IDLE); +static void basc_create(struct prf_task_env *env, uint8_t conidx) { + /* Put BAS Client in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), BASC_IDLE); } /** @@ -129,23 +127,21 @@ static void basc_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void basc_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct basc_env_tag* basc_env = (struct basc_env_tag*) env->env; +static void basc_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct basc_env_tag *basc_env = (struct basc_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(basc_env->env[conidx] != NULL) - { - if(basc_env->env[conidx]->operation != NULL) - { - ke_free(basc_env->env[conidx]->operation); - } - ke_free(basc_env->env[conidx]); - basc_env->env[conidx] = NULL; + // clean-up environment variable allocated for task instance + if (basc_env->env[conidx] != NULL) { + if (basc_env->env[conidx]->operation != NULL) { + ke_free(basc_env->env[conidx]->operation); } + ke_free(basc_env->env[conidx]); + basc_env->env[conidx] = NULL; + } - /* Put BAS Client in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), BASC_FREE); + /* Put BAS Client in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), BASC_FREE); } /* @@ -154,52 +150,46 @@ static void basc_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reaso */ /// BASC Task interface required by profile manager -const struct prf_task_cbs basc_itf = -{ - basc_init, - basc_destroy, - basc_create, - basc_cleanup, +const struct prf_task_cbs basc_itf = { + basc_init, + basc_destroy, + basc_create, + basc_cleanup, }; - /* * GLOBAL FUNCTIONS DEFINITIONS **************************************************************************************** */ -const struct prf_task_cbs* basc_prf_itf_get(void) -{ - return &basc_itf; -} +const struct prf_task_cbs *basc_prf_itf_get(void) { return &basc_itf; } +void basc_enable_rsp_send(struct basc_env_tag *basc_env, uint8_t conidx, + uint8_t status) { + // Counter + uint8_t svc_inst; -void basc_enable_rsp_send(struct basc_env_tag *basc_env, uint8_t conidx, uint8_t status) -{ - // Counter - uint8_t svc_inst; + // Send APP the details of the discovered attributes on BASC + struct basc_enable_rsp *rsp = KE_MSG_ALLOC( + BASC_ENABLE_RSP, prf_dst_task_get(&(basc_env->prf_env), conidx), + prf_src_task_get(&(basc_env->prf_env), conidx), basc_enable_rsp); + rsp->status = status; + rsp->bas_nb = 0; + if (status == GAP_ERR_NO_ERROR) { + rsp->bas_nb = basc_env->env[conidx]->bas_nb; - // Send APP the details of the discovered attributes on BASC - struct basc_enable_rsp * rsp = KE_MSG_ALLOC(BASC_ENABLE_RSP, - prf_dst_task_get(&(basc_env->prf_env) ,conidx), - prf_src_task_get(&(basc_env->prf_env) ,conidx), - basc_enable_rsp); - rsp->status = status; - rsp->bas_nb = 0; - if (status == GAP_ERR_NO_ERROR) - { - rsp->bas_nb = basc_env->env[conidx]->bas_nb; + for (svc_inst = 0; svc_inst < co_min(basc_env->env[conidx]->bas_nb, + BASC_NB_BAS_INSTANCES_MAX); + svc_inst++) { + rsp->bas[svc_inst] = basc_env->env[conidx]->bas[svc_inst]; - for (svc_inst = 0; svc_inst < co_min(basc_env->env[conidx]->bas_nb, BASC_NB_BAS_INSTANCES_MAX) ; svc_inst++) - { - rsp->bas[svc_inst] = basc_env->env[conidx]->bas[svc_inst]; - - // Register BASC task in gatt for indication/notifications - prf_register_atthdl2gatt(&(basc_env->prf_env), conidx, &basc_env->env[conidx]->bas[svc_inst].svc); - } + // Register BASC task in gatt for indication/notifications + prf_register_atthdl2gatt(&(basc_env->prf_env), conidx, + &basc_env->env[conidx]->bas[svc_inst].svc); } + } - ke_msg_send(rsp); + ke_msg_send(rsp); } #endif /* (BLE_BATT_CLIENT) */ diff --git a/services/ble_profiles/bas/basc/src/basc_task.c b/services/ble_profiles/bas/basc/src/basc_task.c index 1e59722..5bfd77f 100644 --- a/services/ble_profiles/bas/basc/src/basc_task.c +++ b/services/ble_profiles/bas/basc/src/basc_task.c @@ -14,14 +14,14 @@ #if (BLE_BATT_CLIENT) -#include "gap.h" #include "basc.h" #include "basc_task.h" -#include "gattc_task.h" #include "co_math.h" +#include "gap.h" +#include "gattc_task.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * TYPE DEFINITIONS @@ -29,21 +29,21 @@ */ /// State machine used to retrieve Battery Service characteristics information -const struct prf_char_def basc_bas_char[BAS_CHAR_MAX] = -{ +const struct prf_char_def basc_bas_char[BAS_CHAR_MAX] = { /// Battery Level - [BAS_CHAR_BATT_LEVEL] = {ATT_CHAR_BATTERY_LEVEL, - ATT_MANDATORY, - ATT_CHAR_PROP_RD}, + [BAS_CHAR_BATT_LEVEL] = {ATT_CHAR_BATTERY_LEVEL, ATT_MANDATORY, + ATT_CHAR_PROP_RD}, }; -/// State machine used to retrieve Battery Service characteristic description information -const struct prf_char_desc_def basc_bas_char_desc[BAS_DESC_MAX] = -{ +/// State machine used to retrieve Battery Service characteristic description +/// information +const struct prf_char_desc_def basc_bas_char_desc[BAS_DESC_MAX] = { /// Battery Level Characteristic Presentation Format - [BAS_DESC_BATT_LEVEL_PRES_FORMAT] = {ATT_DESC_CHAR_PRES_FORMAT, ATT_OPTIONAL, BAS_CHAR_BATT_LEVEL}, + [BAS_DESC_BATT_LEVEL_PRES_FORMAT] = {ATT_DESC_CHAR_PRES_FORMAT, + ATT_OPTIONAL, BAS_CHAR_BATT_LEVEL}, /// Battery Level Client Config - [BAS_DESC_BATT_LEVEL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_OPTIONAL, BAS_CHAR_BATT_LEVEL}, + [BAS_DESC_BATT_LEVEL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_OPTIONAL, + BAS_CHAR_BATT_LEVEL}, }; @@ -64,62 +64,56 @@ const struct prf_char_desc_def basc_bas_char_desc[BAS_DESC_MAX] = **************************************************************************************** */ __STATIC int basc_enable_req_handler(ke_msg_id_t const msgid, - struct basc_enable_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; - int msg_status = KE_MSG_CONSUMED; + struct basc_enable_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; + int msg_status = KE_MSG_CONSUMED; - uint8_t state = ke_state_get(dest_id); - uint8_t conidx = KE_IDX_GET(dest_id); - // Battery service Client Role Task Environment - struct basc_env_tag *basc_env = PRF_ENV_GET(BASC, basc); + uint8_t state = ke_state_get(dest_id); + uint8_t conidx = KE_IDX_GET(dest_id); + // Battery service Client Role Task Environment + struct basc_env_tag *basc_env = PRF_ENV_GET(BASC, basc); - ASSERT_INFO(basc_env != NULL, dest_id, src_id); - if((state == BASC_IDLE) && (basc_env->env[conidx] == NULL)) - { - // allocate environment variable for task instance - basc_env->env[conidx] = (struct basc_cnx_env*) ke_malloc(sizeof(struct basc_cnx_env),KE_MEM_ATT_DB); - memset(basc_env->env[conidx], 0, sizeof(struct basc_cnx_env)); + ASSERT_INFO(basc_env != NULL, dest_id, src_id); + if ((state == BASC_IDLE) && (basc_env->env[conidx] == NULL)) { + // allocate environment variable for task instance + basc_env->env[conidx] = (struct basc_cnx_env *)ke_malloc( + sizeof(struct basc_cnx_env), KE_MEM_ATT_DB); + memset(basc_env->env[conidx], 0, sizeof(struct basc_cnx_env)); - //Config connection, start discovering - if(param->con_type == PRF_CON_DISCOVERY) - { - //start discovering BAS on peer - prf_disc_svc_send(&(basc_env->prf_env), conidx, ATT_SVC_BATTERY_SERVICE); + // Config connection, start discovering + if (param->con_type == PRF_CON_DISCOVERY) { + // start discovering BAS on peer + prf_disc_svc_send(&(basc_env->prf_env), conidx, ATT_SVC_BATTERY_SERVICE); - // Go to DISCOVERING state - ke_state_set(dest_id, BASC_BUSY); - basc_env->env[conidx]->operation = ke_param2msg(param); - msg_status = KE_MSG_NO_FREE; - } - //normal connection, get saved att details - else - { - basc_env->env[conidx]->bas_nb = param->bas_nb; - memcpy(&(basc_env->env[conidx]->bas[0]), &(param->bas[0]), sizeof(struct bas_content) * BASC_NB_BAS_INSTANCES_MAX); - - //send APP confirmation that can start normal connection to TH - basc_enable_rsp_send(basc_env, conidx, GAP_ERR_NO_ERROR); - } - } - else if(state != BASC_FREE) - { - status = PRF_ERR_REQ_DISALLOWED; + // Go to DISCOVERING state + ke_state_set(dest_id, BASC_BUSY); + basc_env->env[conidx]->operation = ke_param2msg(param); + msg_status = KE_MSG_NO_FREE; } + // normal connection, get saved att details + else { + basc_env->env[conidx]->bas_nb = param->bas_nb; + memcpy(&(basc_env->env[conidx]->bas[0]), &(param->bas[0]), + sizeof(struct bas_content) * BASC_NB_BAS_INSTANCES_MAX); - // send an error if request fails - if(status != GAP_ERR_NO_ERROR) - { - basc_enable_rsp_send(basc_env, conidx, status); + // send APP confirmation that can start normal connection to TH + basc_enable_rsp_send(basc_env, conidx, GAP_ERR_NO_ERROR); } + } else if (state != BASC_FREE) { + status = PRF_ERR_REQ_DISALLOWED; + } - return (msg_status); + // send an error if request fails + if (status != GAP_ERR_NO_ERROR) { + basc_enable_rsp_send(basc_env, conidx, status); + } + + return (msg_status); } - /** **************************************************************************************** * @brief Handles reception of the @ref GATTC_SDP_SVC_IND_HANDLER message. @@ -132,38 +126,40 @@ __STATIC int basc_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, - struct gattc_sdp_svc_ind const *ind, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_sdp_svc_ind const *ind, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == BASC_BUSY) - { - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct basc_env_tag *basc_env = PRF_ENV_GET(BASC, basc); + if (state == BASC_BUSY) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct basc_env_tag *basc_env = PRF_ENV_GET(BASC, basc); - ASSERT_INFO(basc_env != NULL, dest_id, src_id); - ASSERT_INFO(basc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(basc_env != NULL, dest_id, src_id); + ASSERT_INFO(basc_env->env[conidx] != NULL, dest_id, src_id); - if(basc_env->env[conidx]->bas_nb < BASC_NB_BAS_INSTANCES_MAX) - { - // Retrieve DIS characteristics - prf_extract_svc_info(ind, BAS_CHAR_MAX, &basc_bas_char[0], - &(basc_env->env[conidx]->bas[basc_env->env[conidx]->bas_nb].chars[0]), - BAS_DESC_MAX, &basc_bas_char_desc[0], - &(basc_env->env[conidx]->bas[basc_env->env[conidx]->bas_nb].descs[0])); + if (basc_env->env[conidx]->bas_nb < BASC_NB_BAS_INSTANCES_MAX) { + // Retrieve DIS characteristics + prf_extract_svc_info( + ind, BAS_CHAR_MAX, &basc_bas_char[0], + &(basc_env->env[conidx]->bas[basc_env->env[conidx]->bas_nb].chars[0]), + BAS_DESC_MAX, &basc_bas_char_desc[0], + &(basc_env->env[conidx] + ->bas[basc_env->env[conidx]->bas_nb] + .descs[0])); - //Even if we get multiple responses we only store 1 range - basc_env->env[conidx]->bas[basc_env->env[conidx]->bas_nb].svc.shdl = ind->start_hdl; - basc_env->env[conidx]->bas[basc_env->env[conidx]->bas_nb].svc.ehdl = ind->end_hdl; - } - - basc_env->env[conidx]->bas_nb++; + // Even if we get multiple responses we only store 1 range + basc_env->env[conidx]->bas[basc_env->env[conidx]->bas_nb].svc.shdl = + ind->start_hdl; + basc_env->env[conidx]->bas[basc_env->env[conidx]->bas_nb].svc.ehdl = + ind->end_hdl; } - return (KE_MSG_CONSUMED); + basc_env->env[conidx]->bas_nb++; + } + + return (KE_MSG_CONSUMED); } /** @@ -176,103 +172,100 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int basc_read_info_req_handler(ke_msg_id_t const msgid, struct basc_read_info_req const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - int msg_status = KE_MSG_CONSUMED; - uint8_t state = ke_state_get(dest_id); - uint8_t status = PRF_ERR_REQ_DISALLOWED; +__STATIC int basc_read_info_req_handler(ke_msg_id_t const msgid, + struct basc_read_info_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + int msg_status = KE_MSG_CONSUMED; + uint8_t state = ke_state_get(dest_id); + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if(state == BASC_IDLE) - { - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct basc_env_tag *basc_env = PRF_ENV_GET(BASC, basc); - ASSERT_INFO(basc_env != NULL, dest_id, src_id); - // environment variable not ready - if(basc_env->env[conidx] == NULL) - { - status = PRF_APP_ERROR; - } - // check parameter range - else if(param->bas_nb > basc_env->env[conidx]->bas_nb) - { - status = PRF_ERR_INVALID_PARAM; - } - else - { - uint16_t handle = ATT_INVALID_HANDLE; - status = PRF_ERR_INEXISTENT_HDL; - - // check requested info - switch(param->info) - { - /// Battery Level value - case BASC_BATT_LVL_VAL: - { - handle = basc_env->env[conidx]->bas[param->bas_nb].chars[BAS_CHAR_BATT_LEVEL].val_hdl; - }break; - /// Battery Level Client Characteristic Configuration - case BASC_NTF_CFG: - { - handle = basc_env->env[conidx]->bas[param->bas_nb].descs[BAS_DESC_BATT_LEVEL_CFG].desc_hdl; - }break; - /// Battery Level Characteristic Presentation Format - case BASC_BATT_LVL_PRES_FORMAT: - { - handle = basc_env->env[conidx]->bas[param->bas_nb].descs[BAS_DESC_BATT_LEVEL_PRES_FORMAT].desc_hdl; - }break; - - default: - { - status = PRF_ERR_INVALID_PARAM; - }break; - } - - if(handle != ATT_INVALID_HANDLE) - { - status = GAP_ERR_NO_ERROR; - // read information - prf_read_char_send(&(basc_env->prf_env), conidx, - basc_env->env[conidx]->bas[param->bas_nb].svc.shdl, - basc_env->env[conidx]->bas[param->bas_nb].svc.ehdl, handle); - - // store context of request and go into busy state - basc_env->env[conidx]->operation = ke_param2msg(param); - ke_state_set(dest_id, BASC_BUSY); - msg_status = KE_MSG_NO_FREE; - } - } + if (state == BASC_IDLE) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct basc_env_tag *basc_env = PRF_ENV_GET(BASC, basc); + ASSERT_INFO(basc_env != NULL, dest_id, src_id); + // environment variable not ready + if (basc_env->env[conidx] == NULL) { + status = PRF_APP_ERROR; } - // process message later - else if (state == BASC_BUSY) - { + // check parameter range + else if (param->bas_nb > basc_env->env[conidx]->bas_nb) { + status = PRF_ERR_INVALID_PARAM; + } else { + uint16_t handle = ATT_INVALID_HANDLE; + status = PRF_ERR_INEXISTENT_HDL; + + // check requested info + switch (param->info) { + /// Battery Level value + case BASC_BATT_LVL_VAL: { + handle = basc_env->env[conidx] + ->bas[param->bas_nb] + .chars[BAS_CHAR_BATT_LEVEL] + .val_hdl; + } break; + /// Battery Level Client Characteristic Configuration + case BASC_NTF_CFG: { + handle = basc_env->env[conidx] + ->bas[param->bas_nb] + .descs[BAS_DESC_BATT_LEVEL_CFG] + .desc_hdl; + } break; + /// Battery Level Characteristic Presentation Format + case BASC_BATT_LVL_PRES_FORMAT: { + handle = basc_env->env[conidx] + ->bas[param->bas_nb] + .descs[BAS_DESC_BATT_LEVEL_PRES_FORMAT] + .desc_hdl; + } break; + + default: { + status = PRF_ERR_INVALID_PARAM; + } break; + } + + if (handle != ATT_INVALID_HANDLE) { status = GAP_ERR_NO_ERROR; - msg_status = KE_MSG_SAVED; + // read information + prf_read_char_send(&(basc_env->prf_env), conidx, + basc_env->env[conidx]->bas[param->bas_nb].svc.shdl, + basc_env->env[conidx]->bas[param->bas_nb].svc.ehdl, + handle); + + // store context of request and go into busy state + basc_env->env[conidx]->operation = ke_param2msg(param); + ke_state_set(dest_id, BASC_BUSY); + msg_status = KE_MSG_NO_FREE; + } } + } + // process message later + else if (state == BASC_BUSY) { + status = GAP_ERR_NO_ERROR; + msg_status = KE_MSG_SAVED; + } + // request cannot be performed + if (status != GAP_ERR_NO_ERROR) { + struct basc_read_info_rsp *rsp = + KE_MSG_ALLOC(BASC_READ_INFO_RSP, src_id, dest_id, basc_read_info_rsp); + // set error status + rsp->status = status; + rsp->info = param->info; + rsp->bas_nb = param->bas_nb; - // request cannot be performed - if(status != GAP_ERR_NO_ERROR) - { - struct basc_read_info_rsp * rsp = KE_MSG_ALLOC(BASC_READ_INFO_RSP, - src_id, dest_id, basc_read_info_rsp); - // set error status - rsp->status = status; - rsp->info = param->info; - rsp->bas_nb = param->bas_nb; + ke_msg_send(rsp); + } - ke_msg_send(rsp); - } - - return (msg_status); + return (msg_status); } /** **************************************************************************************** * @brief Handles reception of the @ref BASC_BATT_LEVEL_NTF_CFG_REQ message. - * It allows configuration of the peer ntf/stop characteristic for Battery Level Characteristic. - * Will return an error code if that cfg char does not exist. + * It allows configuration of the peer ntf/stop characteristic for Battery Level + *Characteristic. Will return an error code if that cfg char does not exist. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -280,75 +273,67 @@ __STATIC int basc_read_info_req_handler(ke_msg_id_t const msgid, struct basc_rea * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int basc_batt_level_ntf_cfg_req_handler(ke_msg_id_t const msgid, - struct basc_batt_level_ntf_cfg_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ +__STATIC int basc_batt_level_ntf_cfg_req_handler( + ke_msg_id_t const msgid, struct basc_batt_level_ntf_cfg_req const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { - int msg_status = KE_MSG_CONSUMED; - uint8_t state = ke_state_get(dest_id); - uint8_t status = PRF_ERR_REQ_DISALLOWED; + int msg_status = KE_MSG_CONSUMED; + uint8_t state = ke_state_get(dest_id); + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if(state == BASC_IDLE) - { - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct basc_env_tag *basc_env = PRF_ENV_GET(BASC, basc); - ASSERT_INFO(basc_env != NULL, dest_id, src_id); - // environment variable not ready - if(basc_env->env[conidx] == NULL) - { - status = PRF_APP_ERROR; - } - // check parameter range - else if((param->bas_nb > basc_env->env[conidx]->bas_nb) - || (param->ntf_cfg > PRF_CLI_START_NTF)) - { - status = PRF_ERR_INVALID_PARAM; - } - else - { - uint16_t handle = basc_env->env[conidx]->bas[param->bas_nb].descs[BAS_DESC_BATT_LEVEL_CFG].desc_hdl; - status = PRF_ERR_INEXISTENT_HDL; - - if(handle == ATT_INVALID_HDL) - { - status = PRF_ERR_INEXISTENT_HDL; - } - else - { - status = GAP_ERR_NO_ERROR; - // Send GATT Write Request - prf_gatt_write_ntf_ind(&basc_env->prf_env, conidx, handle, param->ntf_cfg); - // store context of request and go into busy state - basc_env->env[conidx]->operation = ke_param2msg(param); - ke_state_set(dest_id, BASC_BUSY); - msg_status = KE_MSG_NO_FREE; - } - } + if (state == BASC_IDLE) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct basc_env_tag *basc_env = PRF_ENV_GET(BASC, basc); + ASSERT_INFO(basc_env != NULL, dest_id, src_id); + // environment variable not ready + if (basc_env->env[conidx] == NULL) { + status = PRF_APP_ERROR; } - // process message later - else if (state == BASC_BUSY) - { + // check parameter range + else if ((param->bas_nb > basc_env->env[conidx]->bas_nb) || + (param->ntf_cfg > PRF_CLI_START_NTF)) { + status = PRF_ERR_INVALID_PARAM; + } else { + uint16_t handle = basc_env->env[conidx] + ->bas[param->bas_nb] + .descs[BAS_DESC_BATT_LEVEL_CFG] + .desc_hdl; + status = PRF_ERR_INEXISTENT_HDL; + + if (handle == ATT_INVALID_HDL) { + status = PRF_ERR_INEXISTENT_HDL; + } else { status = GAP_ERR_NO_ERROR; - msg_status = KE_MSG_SAVED; + // Send GATT Write Request + prf_gatt_write_ntf_ind(&basc_env->prf_env, conidx, handle, + param->ntf_cfg); + // store context of request and go into busy state + basc_env->env[conidx]->operation = ke_param2msg(param); + ke_state_set(dest_id, BASC_BUSY); + msg_status = KE_MSG_NO_FREE; + } } + } + // process message later + else if (state == BASC_BUSY) { + status = GAP_ERR_NO_ERROR; + msg_status = KE_MSG_SAVED; + } + // request cannot be performed + if (status != GAP_ERR_NO_ERROR) { + struct basc_batt_level_ntf_cfg_rsp *rsp = + KE_MSG_ALLOC(BASC_BATT_LEVEL_NTF_CFG_RSP, src_id, dest_id, + basc_batt_level_ntf_cfg_rsp); + // set error status + rsp->status = status; + rsp->bas_nb = param->bas_nb; - // request cannot be performed - if(status != GAP_ERR_NO_ERROR) - { - struct basc_batt_level_ntf_cfg_rsp * rsp = KE_MSG_ALLOC(BASC_BATT_LEVEL_NTF_CFG_RSP, - src_id, dest_id, basc_batt_level_ntf_cfg_rsp); - // set error status - rsp->status = status; - rsp->bas_nb = param->bas_nb; + ke_msg_send(rsp); + } - ke_msg_send(rsp); - } - - return (msg_status); + return (msg_status); } /** @@ -363,107 +348,107 @@ __STATIC int basc_batt_level_ntf_cfg_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, - struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct basc_env_tag *basc_env = PRF_ENV_GET(BASC, basc); + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct basc_env_tag *basc_env = PRF_ENV_GET(BASC, basc); - // sanity check - if((state == BASC_BUSY) && (basc_env->env[conidx] != NULL) - && (basc_env->env[conidx]->operation != NULL)) - { - switch(basc_env->env[conidx]->operation->id) - { - case BASC_ENABLE_REQ: - { - uint8_t status = param->status; + // sanity check + if ((state == BASC_BUSY) && (basc_env->env[conidx] != NULL) && + (basc_env->env[conidx]->operation != NULL)) { + switch (basc_env->env[conidx]->operation->id) { + case BASC_ENABLE_REQ: { + uint8_t status = param->status; - if (param->status == ATT_ERR_NO_ERROR) - { - // check characteristic validity - if(basc_env->env[conidx]->bas_nb > 0) - { - uint8_t i; - for (i = 0 ; (i < co_min(basc_env->env[conidx]->bas_nb, BASC_NB_BAS_INSTANCES_MAX)) - && (status == GAP_ERR_NO_ERROR) ; i++) - { - status = prf_check_svc_char_validity(BAS_CHAR_MAX, basc_env->env[conidx]->bas[i].chars, - basc_bas_char); + if (param->status == ATT_ERR_NO_ERROR) { + // check characteristic validity + if (basc_env->env[conidx]->bas_nb > 0) { + uint8_t i; + for (i = 0; (i < co_min(basc_env->env[conidx]->bas_nb, + BASC_NB_BAS_INSTANCES_MAX)) && + (status == GAP_ERR_NO_ERROR); + i++) { + status = prf_check_svc_char_validity( + BAS_CHAR_MAX, basc_env->env[conidx]->bas[i].chars, + basc_bas_char); - // check descriptor validity - if(status == GAP_ERR_NO_ERROR) - { - struct prf_char_desc_def bas_desc[BAS_DESC_MAX]; - memcpy(bas_desc, basc_bas_char_desc, sizeof(basc_bas_char_desc)); + // check descriptor validity + if (status == GAP_ERR_NO_ERROR) { + struct prf_char_desc_def bas_desc[BAS_DESC_MAX]; + memcpy(bas_desc, basc_bas_char_desc, sizeof(basc_bas_char_desc)); - if (basc_env->env[conidx]->bas_nb > 1) - { - bas_desc[BAS_DESC_BATT_LEVEL_PRES_FORMAT].req_flag = ATT_MANDATORY; - } - if ((basc_env->env[conidx]->bas[i].chars[BAS_CHAR_BATT_LEVEL].prop & ATT_CHAR_PROP_NTF) == ATT_CHAR_PROP_NTF) - { - bas_desc[BAS_DESC_BATT_LEVEL_CFG].req_flag = ATT_MANDATORY; - } + if (basc_env->env[conidx]->bas_nb > 1) { + bas_desc[BAS_DESC_BATT_LEVEL_PRES_FORMAT].req_flag = + ATT_MANDATORY; + } + if ((basc_env->env[conidx] + ->bas[i] + .chars[BAS_CHAR_BATT_LEVEL] + .prop & + ATT_CHAR_PROP_NTF) == ATT_CHAR_PROP_NTF) { + bas_desc[BAS_DESC_BATT_LEVEL_CFG].req_flag = ATT_MANDATORY; + } - status = prf_check_svc_char_desc_validity(BAS_DESC_MAX, - basc_env->env[conidx]->bas[i].descs, bas_desc, - basc_env->env[conidx]->bas[i].chars); - } - } - } - // no services found - else - { - status = PRF_ERR_STOP_DISC_CHAR_MISSING; - } - - } - basc_enable_rsp_send(basc_env, conidx, status); - }break; - case BASC_READ_INFO_REQ: - { - struct basc_read_info_req* req = (struct basc_read_info_req*) ke_msg2param(basc_env->env[conidx]->operation); - - struct basc_read_info_rsp * rsp = KE_MSG_ALLOC(BASC_READ_INFO_RSP, - prf_dst_task_get(&(basc_env->prf_env), conidx), dest_id, basc_read_info_rsp); - // set error status - rsp->status = param->status; - rsp->bas_nb = req->bas_nb; - rsp->info = req->info; - - ke_msg_send(rsp); - - }break; - case BASC_BATT_LEVEL_NTF_CFG_REQ: - { - struct basc_batt_level_ntf_cfg_req* req = (struct basc_batt_level_ntf_cfg_req*) ke_msg2param(basc_env->env[conidx]->operation); - - struct basc_batt_level_ntf_cfg_rsp * rsp = KE_MSG_ALLOC(BASC_BATT_LEVEL_NTF_CFG_RSP, - prf_dst_task_get(&(basc_env->prf_env), conidx), dest_id, basc_batt_level_ntf_cfg_rsp); - // set error status - rsp->status =param->status; - rsp->bas_nb = req->bas_nb; - - ke_msg_send(rsp); - }break; - default: - { - // Not Expected at all - ASSERT_ERR(0); - }break; + status = prf_check_svc_char_desc_validity( + BAS_DESC_MAX, basc_env->env[conidx]->bas[i].descs, bas_desc, + basc_env->env[conidx]->bas[i].chars); + } + } } + // no services found + else { + status = PRF_ERR_STOP_DISC_CHAR_MISSING; + } + } + basc_enable_rsp_send(basc_env, conidx, status); + } break; + case BASC_READ_INFO_REQ: { + struct basc_read_info_req *req = + (struct basc_read_info_req *)ke_msg2param( + basc_env->env[conidx]->operation); - // operation is over - go back to idle state - ke_free(basc_env->env[conidx]->operation); - basc_env->env[conidx]->operation = NULL; - ke_state_set(dest_id, BASC_IDLE); + struct basc_read_info_rsp *rsp = KE_MSG_ALLOC( + BASC_READ_INFO_RSP, prf_dst_task_get(&(basc_env->prf_env), conidx), + dest_id, basc_read_info_rsp); + // set error status + rsp->status = param->status; + rsp->bas_nb = req->bas_nb; + rsp->info = req->info; + + ke_msg_send(rsp); + + } break; + case BASC_BATT_LEVEL_NTF_CFG_REQ: { + struct basc_batt_level_ntf_cfg_req *req = + (struct basc_batt_level_ntf_cfg_req *)ke_msg2param( + basc_env->env[conidx]->operation); + + struct basc_batt_level_ntf_cfg_rsp *rsp = + KE_MSG_ALLOC(BASC_BATT_LEVEL_NTF_CFG_RSP, + prf_dst_task_get(&(basc_env->prf_env), conidx), dest_id, + basc_batt_level_ntf_cfg_rsp); + // set error status + rsp->status = param->status; + rsp->bas_nb = req->bas_nb; + + ke_msg_send(rsp); + } break; + default: { + // Not Expected at all + ASSERT_ERR(0); + } break; } - return (KE_MSG_CONSUMED); + // operation is over - go back to idle state + ke_free(basc_env->env[conidx]->operation); + basc_env->env[conidx]->operation = NULL; + ke_state_set(dest_id, BASC_IDLE); + } + + return (KE_MSG_CONSUMED); } /** @@ -480,63 +465,57 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, struct gattc_read_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == BASC_BUSY) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == BASC_BUSY) { + uint8_t conidx = KE_IDX_GET(dest_id); - struct basc_env_tag *basc_env = PRF_ENV_GET(BASC, basc); - struct basc_read_info_req* req = (struct basc_read_info_req*) ke_msg2param(basc_env->env[conidx]->operation); + struct basc_env_tag *basc_env = PRF_ENV_GET(BASC, basc); + struct basc_read_info_req *req = (struct basc_read_info_req *)ke_msg2param( + basc_env->env[conidx]->operation); - ASSERT_INFO(basc_env != NULL, dest_id, src_id); - ASSERT_INFO(basc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(basc_env != NULL, dest_id, src_id); + ASSERT_INFO(basc_env->env[conidx] != NULL, dest_id, src_id); + struct basc_read_info_rsp *rsp = KE_MSG_ALLOC( + BASC_READ_INFO_RSP, prf_dst_task_get(&(basc_env->prf_env), conidx), + dest_id, basc_read_info_rsp); + // set error status + rsp->status = GAP_ERR_NO_ERROR; + rsp->bas_nb = req->bas_nb; + rsp->info = req->info; - struct basc_read_info_rsp * rsp = KE_MSG_ALLOC(BASC_READ_INFO_RSP, - prf_dst_task_get(&(basc_env->prf_env),conidx), dest_id, basc_read_info_rsp); - // set error status - rsp->status = GAP_ERR_NO_ERROR; - rsp->bas_nb = req->bas_nb; - rsp->info = req->info; + switch (req->info) { + /// Battery Level value + case BASC_BATT_LVL_VAL: { + rsp->data.batt_level = param->value[0]; + } break; + /// Battery Level Client Characteristic Configuration + case BASC_NTF_CFG: { + rsp->data.ntf_cfg = co_read16p(¶m->value[0]); - switch(req->info) - { - /// Battery Level value - case BASC_BATT_LVL_VAL: - { - rsp->data.batt_level = param->value[0]; - }break; - /// Battery Level Client Characteristic Configuration - case BASC_NTF_CFG: - { - rsp->data.ntf_cfg = co_read16p(¶m->value[0]); + } break; + /// Battery Level Characteristic Presentation Format + case BASC_BATT_LVL_PRES_FORMAT: { + prf_unpack_char_pres_fmt(¶m->value[0], &rsp->data.char_pres_format); + } break; - }break; - /// Battery Level Characteristic Presentation Format - case BASC_BATT_LVL_PRES_FORMAT: - { - prf_unpack_char_pres_fmt(¶m->value[0], &rsp->data.char_pres_format); - }break; - - default: - { - ASSERT_ERR(0); - }break; - } - - // send response - ke_msg_send(rsp); - - // operation is over - go back to idle state - ke_free(basc_env->env[conidx]->operation); - basc_env->env[conidx]->operation = NULL; - ke_state_set(dest_id, BASC_IDLE); + default: { + ASSERT_ERR(0); + } break; } - return (KE_MSG_CONSUMED); + // send response + ke_msg_send(rsp); + + // operation is over - go back to idle state + ke_free(basc_env->env[conidx]->operation); + basc_env->env[conidx]->operation = NULL; + ke_state_set(dest_id, BASC_IDLE); + } + + return (KE_MSG_CONSUMED); } /** @@ -550,41 +529,40 @@ __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, - struct gattc_event_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_event_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state != BASC_FREE) - { + if (state != BASC_FREE) { - // BAS Instance - uint8_t bas_nb; - uint8_t conidx = KE_IDX_GET(src_id); - // Get the address of the environment - struct basc_env_tag *basc_env = PRF_ENV_GET(BASC, basc); + // BAS Instance + uint8_t bas_nb; + uint8_t conidx = KE_IDX_GET(src_id); + // Get the address of the environment + struct basc_env_tag *basc_env = PRF_ENV_GET(BASC, basc); - //Battery Level - BAS instance is unknown. - for (bas_nb = 0; (bas_nb < basc_env->env[conidx]->bas_nb); bas_nb++) - { - if (param->handle == basc_env->env[conidx]->bas[bas_nb].chars[BAS_CHAR_BATT_LEVEL].val_hdl) - { - struct basc_batt_level_ind * ind = KE_MSG_ALLOC(BASC_BATT_LEVEL_IND, - prf_dst_task_get(&(basc_env->prf_env), conidx), dest_id, - basc_batt_level_ind); + // Battery Level - BAS instance is unknown. + for (bas_nb = 0; (bas_nb < basc_env->env[conidx]->bas_nb); bas_nb++) { + if (param->handle == basc_env->env[conidx] + ->bas[bas_nb] + .chars[BAS_CHAR_BATT_LEVEL] + .val_hdl) { + struct basc_batt_level_ind *ind = KE_MSG_ALLOC( + BASC_BATT_LEVEL_IND, prf_dst_task_get(&(basc_env->prf_env), conidx), + dest_id, basc_batt_level_ind); - ind->batt_level = param->value[0]; - ind->bas_nb = bas_nb; + ind->batt_level = param->value[0]; + ind->bas_nb = bas_nb; - //Send Battery Level value to APP - ke_msg_send(ind); - break; - } - } + // Send Battery Level value to APP + ke_msg_send(ind); + break; + } } + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /* @@ -592,32 +570,28 @@ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ - /// Default State handlers definition -KE_MSG_HANDLER_TAB(basc) -{ - {BASC_ENABLE_REQ, (ke_msg_func_t)basc_enable_req_handler}, - {BASC_READ_INFO_REQ, (ke_msg_func_t)basc_read_info_req_handler}, - {BASC_BATT_LEVEL_NTF_CFG_REQ, (ke_msg_func_t)basc_batt_level_ntf_cfg_req_handler}, - {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, - {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, - {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, +KE_MSG_HANDLER_TAB(basc){ + {BASC_ENABLE_REQ, (ke_msg_func_t)basc_enable_req_handler}, + {BASC_READ_INFO_REQ, (ke_msg_func_t)basc_read_info_req_handler}, + {BASC_BATT_LEVEL_NTF_CFG_REQ, + (ke_msg_func_t)basc_batt_level_ntf_cfg_req_handler}, + {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, + {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, + {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void basc_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct basc_env_tag *basc_env = PRF_ENV_GET(BASC, basc); +void basc_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct basc_env_tag *basc_env = PRF_ENV_GET(BASC, basc); - task_desc->msg_handler_tab = basc_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(basc_msg_handler_tab); - task_desc->state = basc_env->state; - task_desc->idx_max = BASC_IDX_MAX; + task_desc->msg_handler_tab = basc_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(basc_msg_handler_tab); + task_desc->state = basc_env->state; + task_desc->idx_max = BASC_IDX_MAX; } - - #endif /* (BLE_BATT_CLIENT) */ /// @} BASCTASK diff --git a/services/ble_profiles/bas/bass/src/bass.c b/services/ble_profiles/bas/bass/src/bass.c index 50b89ab..cc78e9c 100644 --- a/services/ble_profiles/bas/bass/src/bass.c +++ b/services/ble_profiles/bas/bass/src/bass.c @@ -15,8 +15,8 @@ #if (BLE_BATT_SERVER) #include "bass.h" #include "bass_task.h" -#include "prf_utils.h" #include "prf.h" +#include "prf_utils.h" #include "ke_mem.h" @@ -26,22 +26,26 @@ */ /// Full BAS Database Description - Used to add attributes into the database -const struct attm_desc bas_att_db[BAS_IDX_NB] = -{ +const struct attm_desc bas_att_db[BAS_IDX_NB] = { // Battery Service Declaration - [BAS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [BAS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // Battery Level Characteristic Declaration - [BAS_IDX_BATT_LVL_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [BAS_IDX_BATT_LVL_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, // Battery Level Characteristic Value - [BAS_IDX_BATT_LVL_VAL] = {ATT_CHAR_BATTERY_LEVEL, PERM(RD, ENABLE), PERM(RI, ENABLE), 0}, - // Battery Level Characteristic - Client Characteristic Configuration Descriptor - [BAS_IDX_BATT_LVL_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE)|PERM(WRITE_REQ, ENABLE), 0, 0}, - // Battery Level Characteristic - Characteristic Presentation Format Descriptor - [BAS_IDX_BATT_LVL_PRES_FMT] = {ATT_DESC_CHAR_PRES_FORMAT, PERM(RD, ENABLE), PERM(RI, ENABLE), 0}, + [BAS_IDX_BATT_LVL_VAL] = {ATT_CHAR_BATTERY_LEVEL, PERM(RD, ENABLE), + PERM(RI, ENABLE), 0}, + // Battery Level Characteristic - Client Characteristic Configuration + // Descriptor + [BAS_IDX_BATT_LVL_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, + 0}, + // Battery Level Characteristic - Characteristic Presentation Format + // Descriptor + [BAS_IDX_BATT_LVL_PRES_FMT] = {ATT_DESC_CHAR_PRES_FORMAT, PERM(RD, ENABLE), + PERM(RI, ENABLE), 0}, }; - /* * LOCAL FUNCTION DEFINITIONS **************************************************************************************** @@ -59,136 +63,135 @@ const struct attm_desc bas_att_db[BAS_IDX_NB] = * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t bass_init (struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, struct bass_db_cfg* params) -{ - uint16_t shdl[BASS_NB_BAS_INSTANCES_MAX]; - struct bass_env_tag* bass_env = NULL; - // Status - uint8_t status = GAP_ERR_NO_ERROR; - // Counter - uint8_t i; +static uint8_t bass_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, + struct bass_db_cfg *params) { + uint16_t shdl[BASS_NB_BAS_INSTANCES_MAX]; + struct bass_env_tag *bass_env = NULL; + // Status + uint8_t status = GAP_ERR_NO_ERROR; + // Counter + uint8_t i; - // Check number of BAS instances - if ((params->bas_nb > 0) && (params->bas_nb <= BASS_NB_BAS_INSTANCES_MAX)) - { - //-------------------- allocate memory required for the profile --------------------- - bass_env = (struct bass_env_tag* ) ke_malloc(sizeof(struct bass_env_tag), KE_MEM_ATT_DB); - memset(bass_env, 0 , sizeof(struct bass_env_tag)); + // Check number of BAS instances + if ((params->bas_nb > 0) && (params->bas_nb <= BASS_NB_BAS_INSTANCES_MAX)) { + //-------------------- allocate memory required for the profile + //--------------------- + bass_env = (struct bass_env_tag *)ke_malloc(sizeof(struct bass_env_tag), + KE_MEM_ATT_DB); + memset(bass_env, 0, sizeof(struct bass_env_tag)); - // Save number of BAS - bass_env->svc_nb = params->bas_nb; + // Save number of BAS + bass_env->svc_nb = params->bas_nb; - for (i = 0; ((i < params->bas_nb) && (status == GAP_ERR_NO_ERROR)); i++) - { - // Service content flag - uint8_t cfg_flag = BAS_CFG_FLAG_MANDATORY_MASK; + for (i = 0; ((i < params->bas_nb) && (status == GAP_ERR_NO_ERROR)); i++) { + // Service content flag + uint8_t cfg_flag = BAS_CFG_FLAG_MANDATORY_MASK; - // Save database configuration - bass_env->features |= (params->features[i]) << i; - bass_env->batt_level_pres_format[i] = params->batt_level_pres_format[i]; + // Save database configuration + bass_env->features |= (params->features[i]) << i; + bass_env->batt_level_pres_format[i] = params->batt_level_pres_format[i]; - // Check if notifications are supported - if (params->features[i] == BAS_BATT_LVL_NTF_SUP) - { - cfg_flag |= BAS_CFG_FLAG_NTF_SUP_MASK; - } + // Check if notifications are supported + if (params->features[i] == BAS_BATT_LVL_NTF_SUP) { + cfg_flag |= BAS_CFG_FLAG_NTF_SUP_MASK; + } - // Check if multiple instances - if (bass_env->svc_nb > 1) - { - cfg_flag |= BAS_CFG_FLAG_MTP_BAS_MASK; - } + // Check if multiple instances + if (bass_env->svc_nb > 1) { + cfg_flag |= BAS_CFG_FLAG_MTP_BAS_MASK; + } - shdl[i] = *start_hdl; + shdl[i] = *start_hdl; - //Create BAS in the DB - //------------------ create the attribute database for the profile ------------------- - status = attm_svc_create_db(&(shdl[i]), ATT_SVC_BATTERY_SERVICE, (uint8_t *)&cfg_flag, - BAS_IDX_NB, NULL, env->task, bas_att_db, - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS))); + // Create BAS in the DB + //------------------ create the attribute database for the profile + //------------------- + status = attm_svc_create_db( + &(shdl[i]), ATT_SVC_BATTERY_SERVICE, (uint8_t *)&cfg_flag, BAS_IDX_NB, + NULL, env->task, bas_att_db, + (sec_lvl & + (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS))); - //Set optional permissions - if (status == GAP_ERR_NO_ERROR) - { - // update start handle for next service - only useful if multiple service, else not used. - // 4 characteristics + optional notification characteristic. - *start_hdl = shdl[i] + BAS_IDX_NB - ((params->features[i] == BAS_BATT_LVL_NTF_SUP) ? 0 : 1); + // Set optional permissions + if (status == GAP_ERR_NO_ERROR) { + // update start handle for next service - only useful if multiple + // service, else not used. 4 characteristics + optional notification + // characteristic. + *start_hdl = shdl[i] + BAS_IDX_NB - + ((params->features[i] == BAS_BATT_LVL_NTF_SUP) ? 0 : 1); - //Set optional permissions - if(params->features[i] == BAS_BATT_LVL_NTF_SUP) - { - // Battery Level characteristic value permissions - uint16_t perm = PERM(RD, ENABLE) | PERM(NTF, ENABLE); + // Set optional permissions + if (params->features[i] == BAS_BATT_LVL_NTF_SUP) { + // Battery Level characteristic value permissions + uint16_t perm = PERM(RD, ENABLE) | PERM(NTF, ENABLE); - attm_att_set_permission(shdl[i] + BAS_IDX_BATT_LVL_VAL, perm, 0); - } - } - - // Reset configuration flag - cfg_flag = BAS_CFG_FLAG_MANDATORY_MASK; + attm_att_set_permission(shdl[i] + BAS_IDX_BATT_LVL_VAL, perm, 0); } + } + + // Reset configuration flag + cfg_flag = BAS_CFG_FLAG_MANDATORY_MASK; } - else - { - status = PRF_ERR_INVALID_PARAM; - } + } else { + status = PRF_ERR_INVALID_PARAM; + } - //-------------------- Update profile task information --------------------- - if (status == ATT_ERR_NO_ERROR) - { + //-------------------- Update profile task information --------------------- + if (status == ATT_ERR_NO_ERROR) { - // allocate BASS required environment variable - env->env = (prf_env_t*) bass_env; - *start_hdl = shdl[0]; - bass_env->start_hdl = *start_hdl; - bass_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - bass_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); + // allocate BASS required environment variable + env->env = (prf_env_t *)bass_env; + *start_hdl = shdl[0]; + bass_env->start_hdl = *start_hdl; + bass_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + bass_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); - // initialize environment variable - env->id = TASK_ID_BASS; - bass_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_BASS; + bass_task_init(&(env->desc)); - // service is ready, go into an Idle state - ke_state_set(env->task, BASS_IDLE); - } - else if(bass_env != NULL) - { - ke_free(bass_env); - } + // service is ready, go into an Idle state + ke_state_set(env->task, BASS_IDLE); + } else if (bass_env != NULL) { + ke_free(bass_env); + } - return (status); + return (status); } /** **************************************************************************************** * @brief Destruction of the BASS module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void bass_destroy(struct prf_task_env* env) -{ - struct bass_env_tag* bass_env = (struct bass_env_tag*) env->env; +static void bass_destroy(struct prf_task_env *env) { + struct bass_env_tag *bass_env = (struct bass_env_tag *)env->env; - // clear on-going operation - if(bass_env->operation != NULL) - { - ke_free(bass_env->operation); - } + // clear on-going operation + if (bass_env->operation != NULL) { + ke_free(bass_env->operation); + } - // free profile environment variables - env->env = NULL; - ke_free(bass_env); + // free profile environment variables + env->env = NULL; + ke_free(bass_env); } /** @@ -199,13 +202,12 @@ static void bass_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void bass_create(struct prf_task_env* env, uint8_t conidx) -{ - struct bass_env_tag* bass_env = (struct bass_env_tag*) env->env; - ASSERT_ERR(conidx < BLE_CONNECTION_MAX); +static void bass_create(struct prf_task_env *env, uint8_t conidx) { + struct bass_env_tag *bass_env = (struct bass_env_tag *)env->env; + ASSERT_ERR(conidx < BLE_CONNECTION_MAX); - // force notification config to zero when peer device is connected - bass_env->ntf_cfg[conidx] = 0; + // force notification config to zero when peer device is connected + bass_env->ntf_cfg[conidx] = 0; } /** @@ -217,16 +219,15 @@ static void bass_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void bass_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct bass_env_tag* bass_env = (struct bass_env_tag*) env->env; +static void bass_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct bass_env_tag *bass_env = (struct bass_env_tag *)env->env; - ASSERT_ERR(conidx < BLE_CONNECTION_MAX); - // force notification config to zero when peer device is disconnected - bass_env->ntf_cfg[conidx] = 0; + ASSERT_ERR(conidx < BLE_CONNECTION_MAX); + // force notification config to zero when peer device is disconnected + bass_env->ntf_cfg[conidx] = 0; } - /** **************************************************************************************** * @brief Trigger battery level notification @@ -236,22 +237,23 @@ static void bass_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reaso * @param svc_idx Service index **************************************************************************************** */ -static void bass_notify_batt_lvl(struct bass_env_tag* bass_env, uint8_t conidx, uint8_t svc_idx) -{ - // Allocate the GATT notification message - struct gattc_send_evt_cmd *batt_lvl = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(&(bass_env->prf_env),0), - gattc_send_evt_cmd, sizeof(uint8_t)); +static void bass_notify_batt_lvl(struct bass_env_tag *bass_env, uint8_t conidx, + uint8_t svc_idx) { + // Allocate the GATT notification message + struct gattc_send_evt_cmd *batt_lvl = + KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&(bass_env->prf_env), 0), + gattc_send_evt_cmd, sizeof(uint8_t)); - // Fill in the parameter structure - batt_lvl->operation = GATTC_NOTIFY; - batt_lvl->handle = bass_get_att_handle(svc_idx, BAS_IDX_BATT_LVL_VAL); - // pack measured value in database - batt_lvl->length = sizeof(uint8_t); - batt_lvl->value[0] = bass_env->batt_lvl[svc_idx]; + // Fill in the parameter structure + batt_lvl->operation = GATTC_NOTIFY; + batt_lvl->handle = bass_get_att_handle(svc_idx, BAS_IDX_BATT_LVL_VAL); + // pack measured value in database + batt_lvl->length = sizeof(uint8_t); + batt_lvl->value[0] = bass_env->batt_lvl[svc_idx]; - // send notification to peer device - ke_msg_send(batt_lvl); + // send notification to peer device + ke_msg_send(batt_lvl); } /* @@ -260,202 +262,184 @@ static void bass_notify_batt_lvl(struct bass_env_tag* bass_env, uint8_t conidx, */ /// BASS Task interface required by profile manager -const struct prf_task_cbs bass_itf = -{ - (prf_init_fnct) bass_init, - bass_destroy, - bass_create, - bass_cleanup, +const struct prf_task_cbs bass_itf = { + (prf_init_fnct)bass_init, + bass_destroy, + bass_create, + bass_cleanup, }; - /* * GLOBAL FUNCTIONS DEFINITIONS **************************************************************************************** */ -const struct prf_task_cbs* bass_prf_itf_get(void) -{ - return &bass_itf; +const struct prf_task_cbs *bass_prf_itf_get(void) { return &bass_itf; } + +uint16_t bass_get_att_handle(uint8_t svc_idx, uint8_t att_idx) { + struct bass_env_tag *bass_env = PRF_ENV_GET(BASS, bass); + uint16_t handle = ATT_INVALID_HDL; + uint8_t i = 0; + + if (svc_idx < bass_env->svc_nb) { + handle = bass_env->start_hdl; + + for (i = 0; i < svc_idx; i++) { + // update start handle for next service - only useful if multiple service, + // else not used. 4 characteristics + optional notification + // characteristic. + handle += + BAS_IDX_NB - + ((((bass_env->features >> i) & 0x01) == BAS_BATT_LVL_NTF_SUP) ? 0 + : 1); + } + + // increment index according to expected index + if (att_idx < BAS_IDX_BATT_LVL_NTF_CFG) { + handle += att_idx; + } + // Battery notification + else if ((att_idx == BAS_IDX_BATT_LVL_NTF_CFG) && + (((bass_env->features >> i) & 0x01) == BAS_BATT_LVL_NTF_SUP)) { + handle += BAS_IDX_BATT_LVL_NTF_CFG; + } + // Battery Level format + else if ((att_idx == BAS_IDX_BATT_LVL_PRES_FMT) && (bass_env->svc_nb > 1)) { + handle += + BAS_IDX_BATT_LVL_PRES_FMT - + ((((bass_env->features >> i) & 0x01) == BAS_BATT_LVL_NTF_SUP) ? 0 + : 1); + } else { + handle = ATT_INVALID_HDL; + } + } + + return handle; } -uint16_t bass_get_att_handle(uint8_t svc_idx, uint8_t att_idx) -{ - struct bass_env_tag* bass_env = PRF_ENV_GET(BASS, bass); - uint16_t handle = ATT_INVALID_HDL; - uint8_t i = 0; +uint8_t bass_get_att_idx(uint16_t handle, uint8_t *svc_idx, uint8_t *att_idx) { + struct bass_env_tag *bass_env = PRF_ENV_GET(BASS, bass); + uint16_t hdl_cursor = bass_env->start_hdl; + uint8_t status = PRF_APP_ERROR; - - if(svc_idx < bass_env ->svc_nb) - { - handle = bass_env->start_hdl; - - for(i = 0 ; i < svc_idx ; i++) - { - // update start handle for next service - only useful if multiple service, else not used. - // 4 characteristics + optional notification characteristic. - handle += BAS_IDX_NB - ((((bass_env->features >> i) & 0x01) == BAS_BATT_LVL_NTF_SUP) ? 0 : 1); - } - - // increment index according to expected index - if(att_idx < BAS_IDX_BATT_LVL_NTF_CFG) - { - handle += att_idx; - } - // Battery notification - else if((att_idx == BAS_IDX_BATT_LVL_NTF_CFG) && (((bass_env->features >> i) & 0x01) == BAS_BATT_LVL_NTF_SUP)) - { - handle += BAS_IDX_BATT_LVL_NTF_CFG; - } - // Battery Level format - else if((att_idx == BAS_IDX_BATT_LVL_PRES_FMT) && (bass_env->svc_nb > 1)) - { - handle += BAS_IDX_BATT_LVL_PRES_FMT - ((((bass_env->features >> i) & 0x01) == BAS_BATT_LVL_NTF_SUP) ? 0 : 1); - } - else - { - handle = ATT_INVALID_HDL; - } + // Browse list of services + // handle must be greater than current index + for (*svc_idx = 0; (*svc_idx < bass_env->svc_nb) && (handle >= hdl_cursor); + (*svc_idx)++) { + // check if it's a mandatory index + if (handle <= (hdl_cursor + BAS_IDX_BATT_LVL_VAL)) { + *att_idx = handle - hdl_cursor; + status = GAP_ERR_NO_ERROR; + break; } - return handle; + hdl_cursor += BAS_IDX_BATT_LVL_VAL; + + // check if it's a notify index + if (((bass_env->features >> *svc_idx) & 0x01) == BAS_BATT_LVL_NTF_SUP) { + hdl_cursor++; + if (handle == hdl_cursor) { + *att_idx = BAS_IDX_BATT_LVL_NTF_CFG; + status = GAP_ERR_NO_ERROR; + break; + } + } + + // check if it's battery level format + if (bass_env->svc_nb > 1) { + hdl_cursor++; + if (handle == hdl_cursor) { + *att_idx = BAS_IDX_BATT_LVL_PRES_FMT; + status = GAP_ERR_NO_ERROR; + break; + } + } + + hdl_cursor++; + } + + return (status); } -uint8_t bass_get_att_idx(uint16_t handle, uint8_t *svc_idx, uint8_t *att_idx) -{ - struct bass_env_tag* bass_env = PRF_ENV_GET(BASS, bass); - uint16_t hdl_cursor = bass_env->start_hdl; - uint8_t status = PRF_APP_ERROR; +void bass_exe_operation(void) { + struct bass_env_tag *bass_env = PRF_ENV_GET(BASS, bass); + ASSERT_ERR(bass_env->operation != NULL); + bool finished = true; + uint8_t conidx = GAP_INVALID_CONIDX; - // Browse list of services - // handle must be greater than current index - for(*svc_idx = 0 ; (*svc_idx < bass_env->svc_nb) && (handle >= hdl_cursor) ; (*svc_idx)++) - { - // check if it's a mandatory index - if(handle <= (hdl_cursor + BAS_IDX_BATT_LVL_VAL)) - { - *att_idx = handle -hdl_cursor; - status = GAP_ERR_NO_ERROR; - break; - } + // Restoring connection information requested + if (bass_env->operation->id == BASS_ENABLE_REQ) { + struct bass_enable_req *enable = + (struct bass_enable_req *)ke_msg2param(bass_env->operation); + conidx = enable->conidx; + // loop on all services to check if notification should be triggered + while (bass_env->cursor < BASS_NB_BAS_INSTANCES_MAX) { + if (((bass_env->ntf_cfg[enable->conidx] & (1 << bass_env->cursor)) != + 0) && + (enable->old_batt_lvl[bass_env->cursor] != + bass_env->batt_lvl[bass_env->cursor])) { + // trigger notification + bass_notify_batt_lvl(bass_env, enable->conidx, bass_env->cursor); - hdl_cursor += BAS_IDX_BATT_LVL_VAL; + finished = false; + bass_env->cursor++; + break; + } + bass_env->cursor++; + } + } + // Battery level updated + else if (bass_env->operation->id == BASS_BATT_LEVEL_UPD_REQ) { + struct bass_batt_level_upd_req *update = + (struct bass_batt_level_upd_req *)ke_msg2param(bass_env->operation); - // check if it's a notify index - if(((bass_env->features >> *svc_idx) & 0x01) == BAS_BATT_LVL_NTF_SUP) - { - hdl_cursor++; - if(handle == hdl_cursor) - { - *att_idx = BAS_IDX_BATT_LVL_NTF_CFG; - status = GAP_ERR_NO_ERROR; - break; - } - } - - // check if it's battery level format - if(bass_env->svc_nb > 1) - { - hdl_cursor++; - if(handle == hdl_cursor) - { - *att_idx = BAS_IDX_BATT_LVL_PRES_FMT; - status = GAP_ERR_NO_ERROR; - break; - } - } - - hdl_cursor++; + // loop on all connection + while (bass_env->cursor < BLE_CONNECTION_MAX) { + if ((bass_env->ntf_cfg[bass_env->cursor] & (1 << update->bas_instance)) != + 0) { + // trigger notification + bass_notify_batt_lvl(bass_env, bass_env->cursor, update->bas_instance); + finished = false; + bass_env->cursor++; + break; + } + bass_env->cursor++; } - return (status); + } + // default, should not happen + else { + ASSERT_ERR(0); + } + + // check if operation is finished + if (finished) { + // trigger response message + if (bass_env->operation->id == BASS_ENABLE_REQ) { + struct bass_enable_rsp *rsp = + KE_MSG_ALLOC(BASS_ENABLE_RSP, bass_env->operation->src_id, + bass_env->operation->dest_id, bass_enable_rsp); + + rsp->conidx = conidx; + rsp->status = GAP_ERR_NO_ERROR; + ke_msg_send(rsp); + } else if (bass_env->operation->id == BASS_BATT_LEVEL_UPD_REQ) { + struct bass_batt_level_upd_rsp *rsp = + KE_MSG_ALLOC(BASS_BATT_LEVEL_UPD_RSP, bass_env->operation->src_id, + bass_env->operation->dest_id, bass_batt_level_upd_rsp); + + rsp->status = GAP_ERR_NO_ERROR; + ke_msg_send(rsp); + } + + // free operation + ke_free(bass_env->operation); + bass_env->operation = NULL; + // go back to idle state + ke_state_set(prf_src_task_get(&(bass_env->prf_env), 0), BASS_IDLE); + } } -void bass_exe_operation(void) -{ - struct bass_env_tag* bass_env = PRF_ENV_GET(BASS, bass); - ASSERT_ERR(bass_env->operation != NULL); - bool finished = true; - uint8_t conidx = GAP_INVALID_CONIDX; - - // Restoring connection information requested - if(bass_env->operation->id == BASS_ENABLE_REQ) - { - struct bass_enable_req * enable = (struct bass_enable_req *) ke_msg2param(bass_env->operation); - conidx = enable->conidx; - // loop on all services to check if notification should be triggered - while(bass_env->cursor < BASS_NB_BAS_INSTANCES_MAX) - { - if(((bass_env->ntf_cfg[enable->conidx] & (1 << bass_env->cursor)) != 0) - && (enable->old_batt_lvl[bass_env->cursor] != bass_env->batt_lvl[bass_env->cursor])) - { - // trigger notification - bass_notify_batt_lvl(bass_env, enable->conidx, bass_env->cursor); - - finished = false; - bass_env->cursor++; - break; - } - bass_env->cursor++; - } - } - // Battery level updated - else if(bass_env->operation->id == BASS_BATT_LEVEL_UPD_REQ) - { - struct bass_batt_level_upd_req * update = (struct bass_batt_level_upd_req *) ke_msg2param(bass_env->operation); - - // loop on all connection - while(bass_env->cursor < BLE_CONNECTION_MAX) - { - if((bass_env->ntf_cfg[bass_env->cursor] & (1 << update->bas_instance)) != 0) - { - // trigger notification - bass_notify_batt_lvl(bass_env, bass_env->cursor, update->bas_instance); - finished = false; - bass_env->cursor++; - break; - } - bass_env->cursor++; - } - - } - // default, should not happen - else - { - ASSERT_ERR(0); - } - - // check if operation is finished - if(finished) - { - // trigger response message - if(bass_env->operation->id == BASS_ENABLE_REQ) - { - struct bass_enable_rsp * rsp = KE_MSG_ALLOC(BASS_ENABLE_RSP, bass_env->operation->src_id, - bass_env->operation->dest_id, bass_enable_rsp); - - rsp->conidx = conidx; - rsp->status = GAP_ERR_NO_ERROR; - ke_msg_send(rsp); - } - else if(bass_env->operation->id == BASS_BATT_LEVEL_UPD_REQ) - { - struct bass_batt_level_upd_rsp * rsp = KE_MSG_ALLOC(BASS_BATT_LEVEL_UPD_RSP, bass_env->operation->src_id, - bass_env->operation->dest_id, bass_batt_level_upd_rsp); - - rsp->status = GAP_ERR_NO_ERROR; - ke_msg_send(rsp); - } - - // free operation - ke_free(bass_env->operation); - bass_env->operation = NULL; - // go back to idle state - ke_state_set(prf_src_task_get(&(bass_env->prf_env), 0), BASS_IDLE); - } -} - - #endif // (BLE_BATT_SERVER) /// @} BASS diff --git a/services/ble_profiles/bas/bass/src/bass_task.c b/services/ble_profiles/bas/bass/src/bass_task.c index e881e3c..eea50ca 100644 --- a/services/ble_profiles/bas/bass/src/bass_task.c +++ b/services/ble_profiles/bas/bass/src/bass_task.c @@ -29,7 +29,6 @@ **************************************************************************************** */ - /** **************************************************************************************** * @brief Handles reception of the @ref BAPS_ENABLE_REQ message. @@ -42,46 +41,43 @@ **************************************************************************************** */ __STATIC int bass_enable_req_handler(ke_msg_id_t const msgid, - struct bass_enable_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - int msg_status = KE_MSG_SAVED; - uint8_t state = ke_state_get(dest_id); + struct bass_enable_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + int msg_status = KE_MSG_SAVED; + uint8_t state = ke_state_get(dest_id); - // check state of the task - if(state == BASS_IDLE) - { - struct bass_env_tag* bass_env = PRF_ENV_GET(BASS, bass); + // check state of the task + if (state == BASS_IDLE) { + struct bass_env_tag *bass_env = PRF_ENV_GET(BASS, bass); - // Check provided values - if((param->conidx > BLE_CONNECTION_MAX) - || (gapc_get_conhdl(param->conidx) == GAP_INVALID_CONHDL)) - { - // an error occurs, trigg it. - struct bass_enable_rsp* rsp = KE_MSG_ALLOC(BASS_ENABLE_RSP, src_id, - dest_id, bass_enable_rsp); - rsp->conidx = param->conidx; - rsp->status = (param->conidx > BLE_CONNECTION_MAX) ? GAP_ERR_INVALID_PARAM : PRF_ERR_REQ_DISALLOWED; - ke_msg_send(rsp); + // Check provided values + if ((param->conidx > BLE_CONNECTION_MAX) || + (gapc_get_conhdl(param->conidx) == GAP_INVALID_CONHDL)) { + // an error occurs, trigg it. + struct bass_enable_rsp *rsp = + KE_MSG_ALLOC(BASS_ENABLE_RSP, src_id, dest_id, bass_enable_rsp); + rsp->conidx = param->conidx; + rsp->status = (param->conidx > BLE_CONNECTION_MAX) + ? GAP_ERR_INVALID_PARAM + : PRF_ERR_REQ_DISALLOWED; + ke_msg_send(rsp); - msg_status = KE_MSG_CONSUMED; - } - else - { - // put task in a busy state - msg_status = KE_MSG_NO_FREE; - ke_state_set(dest_id, BASS_BUSY); - bass_env->ntf_cfg[param->conidx] = param->ntf_cfg; - bass_env->operation = ke_param2msg(param); - bass_env->cursor = 0; + msg_status = KE_MSG_CONSUMED; + } else { + // put task in a busy state + msg_status = KE_MSG_NO_FREE; + ke_state_set(dest_id, BASS_BUSY); + bass_env->ntf_cfg[param->conidx] = param->ntf_cfg; + bass_env->operation = ke_param2msg(param); + bass_env->cursor = 0; - // trigger notification - bass_exe_operation(); - } + // trigger notification + bass_exe_operation(); } + } - return msg_status; + return msg_status; } /** @@ -94,47 +90,42 @@ __STATIC int bass_enable_req_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int bass_batt_level_upd_req_handler(ke_msg_id_t const msgid, - struct bass_batt_level_upd_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - int msg_status = KE_MSG_SAVED; - uint8_t state = ke_state_get(dest_id); +__STATIC int bass_batt_level_upd_req_handler( + ke_msg_id_t const msgid, struct bass_batt_level_upd_req const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + int msg_status = KE_MSG_SAVED; + uint8_t state = ke_state_get(dest_id); - // check state of the task - if(state == BASS_IDLE) - { - struct bass_env_tag* bass_env = PRF_ENV_GET(BASS, bass); + // check state of the task + if (state == BASS_IDLE) { + struct bass_env_tag *bass_env = PRF_ENV_GET(BASS, bass); - // Check provided values - if((param->bas_instance < bass_env->svc_nb) && (param->batt_level <= BAS_BATTERY_LVL_MAX)) - { - // update the battery level value - bass_env->batt_lvl[param->bas_instance] = param->batt_level; + // Check provided values + if ((param->bas_instance < bass_env->svc_nb) && + (param->batt_level <= BAS_BATTERY_LVL_MAX)) { + // update the battery level value + bass_env->batt_lvl[param->bas_instance] = param->batt_level; - // put task in a busy state - msg_status = KE_MSG_NO_FREE; - ke_state_set(dest_id, BASS_BUSY); - bass_env->operation = ke_param2msg(param); - bass_env->cursor = 0; + // put task in a busy state + msg_status = KE_MSG_NO_FREE; + ke_state_set(dest_id, BASS_BUSY); + bass_env->operation = ke_param2msg(param); + bass_env->cursor = 0; - // trigger notification - bass_exe_operation(); - } - else - { - // an error occurs, trigg it. - struct bass_batt_level_upd_rsp * rsp = KE_MSG_ALLOC(BASS_BATT_LEVEL_UPD_RSP, src_id, - dest_id, bass_batt_level_upd_rsp); + // trigger notification + bass_exe_operation(); + } else { + // an error occurs, trigg it. + struct bass_batt_level_upd_rsp *rsp = KE_MSG_ALLOC( + BASS_BATT_LEVEL_UPD_RSP, src_id, dest_id, bass_batt_level_upd_rsp); - rsp->status = PRF_ERR_INVALID_PARAM; - ke_msg_send(rsp); - msg_status = KE_MSG_CONSUMED; - } + rsp->status = PRF_ERR_INVALID_PARAM; + ke_msg_send(rsp); + msg_status = KE_MSG_CONSUMED; } + } - return (msg_status); + return (msg_status); } /** @@ -148,44 +139,38 @@ __STATIC int bass_batt_level_upd_req_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_att_info_req_ind *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ +__STATIC int gattc_att_info_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_att_info_req_ind *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { - struct gattc_att_info_cfm * cfm; - uint8_t svc_idx = 0, att_idx = 0; - // retrieve handle information - uint8_t status = bass_get_att_idx(param->handle, &svc_idx, &att_idx); + struct gattc_att_info_cfm *cfm; + uint8_t svc_idx = 0, att_idx = 0; + // retrieve handle information + uint8_t status = bass_get_att_idx(param->handle, &svc_idx, &att_idx); - //Send write response - cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); - cfm->handle = param->handle; + // Send write response + cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); + cfm->handle = param->handle; - if(status == GAP_ERR_NO_ERROR) - { - // check if it's a client configuration char - if(att_idx == BAS_IDX_BATT_LVL_NTF_CFG) - { - // CCC attribute length = 2 - cfm->length = 2; - } - // not expected request - else - { - cfm->length = 0; - status = ATT_ERR_WRITE_NOT_PERMITTED; - } + if (status == GAP_ERR_NO_ERROR) { + // check if it's a client configuration char + if (att_idx == BAS_IDX_BATT_LVL_NTF_CFG) { + // CCC attribute length = 2 + cfm->length = 2; } + // not expected request + else { + cfm->length = 0; + status = ATT_ERR_WRITE_NOT_PERMITTED; + } + } - cfm->status = status; - ke_msg_send(cfm); + cfm->status = status; + ke_msg_send(cfm); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } - /** **************************************************************************************** * @brief Handles reception of the @ref GATTC_WRITE_REQ_IND message. @@ -196,65 +181,57 @@ __STATIC int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - struct gattc_write_cfm * cfm; - uint8_t svc_idx = 0, att_idx = 0; - uint8_t conidx = KE_IDX_GET(src_id); - // retrieve handle information - uint8_t status = bass_get_att_idx(param->handle, &svc_idx, &att_idx); +__STATIC int gattc_write_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + struct gattc_write_cfm *cfm; + uint8_t svc_idx = 0, att_idx = 0; + uint8_t conidx = KE_IDX_GET(src_id); + // retrieve handle information + uint8_t status = bass_get_att_idx(param->handle, &svc_idx, &att_idx); - // If the attribute has been found, status is GAP_ERR_NO_ERROR - if (status == GAP_ERR_NO_ERROR) - { - struct bass_env_tag* bass_env = PRF_ENV_GET(BASS, bass); - // Extract value before check - uint16_t ntf_cfg = co_read16p(¶m->value[0]); + // If the attribute has been found, status is GAP_ERR_NO_ERROR + if (status == GAP_ERR_NO_ERROR) { + struct bass_env_tag *bass_env = PRF_ENV_GET(BASS, bass); + // Extract value before check + uint16_t ntf_cfg = co_read16p(¶m->value[0]); - // Only update configuration if value for stop or notification enable - if ((att_idx == BAS_IDX_BATT_LVL_NTF_CFG) - && ((ntf_cfg == PRF_CLI_STOP_NTFIND) || (ntf_cfg == PRF_CLI_START_NTF))) - { + // Only update configuration if value for stop or notification enable + if ((att_idx == BAS_IDX_BATT_LVL_NTF_CFG) && + ((ntf_cfg == PRF_CLI_STOP_NTFIND) || (ntf_cfg == PRF_CLI_START_NTF))) { - // Conserve information in environment - if (ntf_cfg == PRF_CLI_START_NTF) - { - // Ntf cfg bit set to 1 - bass_env->ntf_cfg[conidx] |= (BAS_BATT_LVL_NTF_SUP << svc_idx); - } - else - { - // Ntf cfg bit set to 0 - bass_env->ntf_cfg[conidx] &= ~(BAS_BATT_LVL_NTF_SUP << svc_idx); - } + // Conserve information in environment + if (ntf_cfg == PRF_CLI_START_NTF) { + // Ntf cfg bit set to 1 + bass_env->ntf_cfg[conidx] |= (BAS_BATT_LVL_NTF_SUP << svc_idx); + } else { + // Ntf cfg bit set to 0 + bass_env->ntf_cfg[conidx] &= ~(BAS_BATT_LVL_NTF_SUP << svc_idx); + } - // Inform APP of configuration change - struct bass_batt_level_ntf_cfg_ind * ind = KE_MSG_ALLOC(BASS_BATT_LEVEL_NTF_CFG_IND, - prf_dst_task_get(&(bass_env->prf_env), conidx), dest_id, - bass_batt_level_ntf_cfg_ind); - ind->conidx = conidx; - ind->ntf_cfg = bass_env->ntf_cfg[conidx]; - - ke_msg_send(ind); - } - else - { - status = PRF_APP_ERROR; - } + // Inform APP of configuration change + struct bass_batt_level_ntf_cfg_ind *ind = + KE_MSG_ALLOC(BASS_BATT_LEVEL_NTF_CFG_IND, + prf_dst_task_get(&(bass_env->prf_env), conidx), dest_id, + bass_batt_level_ntf_cfg_ind); + ind->conidx = conidx; + ind->ntf_cfg = bass_env->ntf_cfg[conidx]; + ke_msg_send(ind); + } else { + status = PRF_APP_ERROR; } + } - //Send write response - cfm = KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = status; - ke_msg_send(cfm); + // Send write response + cfm = KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = status; + ke_msg_send(cfm); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } - /** **************************************************************************************** * @brief Handles reception of the @ref GATTC_READ_REQ_IND message. @@ -265,78 +242,72 @@ __STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, struct gattc_w * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, struct gattc_read_req_ind const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - struct gattc_read_cfm * cfm; - uint8_t svc_idx = 0, att_idx = 0; - uint8_t conidx = KE_IDX_GET(src_id); - // retrieve handle information - uint8_t status = bass_get_att_idx(param->handle, &svc_idx, &att_idx); - uint16_t length = 0; - struct bass_env_tag* bass_env = PRF_ENV_GET(BASS, bass); +__STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, + struct gattc_read_req_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + struct gattc_read_cfm *cfm; + uint8_t svc_idx = 0, att_idx = 0; + uint8_t conidx = KE_IDX_GET(src_id); + // retrieve handle information + uint8_t status = bass_get_att_idx(param->handle, &svc_idx, &att_idx); + uint16_t length = 0; + struct bass_env_tag *bass_env = PRF_ENV_GET(BASS, bass); - // If the attribute has been found, status is GAP_ERR_NO_ERROR - if (status == GAP_ERR_NO_ERROR) - { - // read notification information - if (att_idx == BAS_IDX_BATT_LVL_VAL) - { - length = sizeof(uint8_t); - } - // read notification information - else if (att_idx == BAS_IDX_BATT_LVL_NTF_CFG) - { - length = sizeof(uint16_t); - } - else if(att_idx == BAS_IDX_BATT_LVL_PRES_FMT) - { - length = PRF_CHAR_PRES_FMT_SIZE; - } - else - { - status = PRF_APP_ERROR; - } + // If the attribute has been found, status is GAP_ERR_NO_ERROR + if (status == GAP_ERR_NO_ERROR) { + // read notification information + if (att_idx == BAS_IDX_BATT_LVL_VAL) { + length = sizeof(uint8_t); } - - //Send write response - cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, length); - cfm->handle = param->handle; - cfm->status = status; - cfm->length = length; - - if (status == GAP_ERR_NO_ERROR) - { - // read notification information - if (att_idx == BAS_IDX_BATT_LVL_VAL) - { - cfm->value[0] = bass_env->batt_lvl[svc_idx]; - } - // retrieve notification config - else if (att_idx == BAS_IDX_BATT_LVL_NTF_CFG) - { - uint16_t ntf_cfg = (bass_env->ntf_cfg[conidx] >> svc_idx & BAS_BATT_LVL_NTF_SUP) ? PRF_CLI_START_NTF : PRF_CLI_STOP_NTFIND; - co_write16p(cfm->value, ntf_cfg); - } - // retrieve battery level format - else if(att_idx == BAS_IDX_BATT_LVL_PRES_FMT) - { - prf_pack_char_pres_fmt(cfm->value, &(bass_env->batt_level_pres_format[svc_idx])); - } - else - { - /* Not Possible */ - } + // read notification information + else if (att_idx == BAS_IDX_BATT_LVL_NTF_CFG) { + length = sizeof(uint16_t); + } else if (att_idx == BAS_IDX_BATT_LVL_PRES_FMT) { + length = PRF_CHAR_PRES_FMT_SIZE; + } else { + status = PRF_APP_ERROR; } + } - ke_msg_send(cfm); + // Send write response + cfm = + KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, length); + cfm->handle = param->handle; + cfm->status = status; + cfm->length = length; - return (KE_MSG_CONSUMED); + if (status == GAP_ERR_NO_ERROR) { + // read notification information + if (att_idx == BAS_IDX_BATT_LVL_VAL) { + cfm->value[0] = bass_env->batt_lvl[svc_idx]; + } + // retrieve notification config + else if (att_idx == BAS_IDX_BATT_LVL_NTF_CFG) { + uint16_t ntf_cfg = + (bass_env->ntf_cfg[conidx] >> svc_idx & BAS_BATT_LVL_NTF_SUP) + ? PRF_CLI_START_NTF + : PRF_CLI_STOP_NTFIND; + co_write16p(cfm->value, ntf_cfg); + } + // retrieve battery level format + else if (att_idx == BAS_IDX_BATT_LVL_PRES_FMT) { + prf_pack_char_pres_fmt(cfm->value, + &(bass_env->batt_level_pres_format[svc_idx])); + } else { + /* Not Possible */ + } + } + + ke_msg_send(cfm); + + return (KE_MSG_CONSUMED); } /** **************************************************************************************** - * @brief Handles @ref GATTC_CMP_EVT for GATTC_NOTIFY message meaning that Measurement - * notification has been correctly sent to peer device (but not confirmed by peer device). + * @brief Handles @ref GATTC_CMP_EVT for GATTC_NOTIFY message meaning that + *Measurement notification has been correctly sent to peer device (but not + *confirmed by peer device). * * * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. @@ -345,15 +316,15 @@ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, struct gattc_re * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - if(param->operation == GATTC_NOTIFY) - { - // continue operation execution - bass_exe_operation(); - } - return (KE_MSG_CONSUMED); +__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + if (param->operation == GATTC_NOTIFY) { + // continue operation execution + bass_exe_operation(); + } + return (KE_MSG_CONSUMED); } /* @@ -362,29 +333,25 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_ev */ /// Default State handlers definition -KE_MSG_HANDLER_TAB(bass) -{ - {BASS_ENABLE_REQ, (ke_msg_func_t) bass_enable_req_handler}, - {BASS_BATT_LEVEL_UPD_REQ, (ke_msg_func_t) bass_batt_level_upd_req_handler}, - {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t) gattc_att_info_req_ind_handler}, - {GATTC_WRITE_REQ_IND, (ke_msg_func_t) gattc_write_req_ind_handler}, - {GATTC_READ_REQ_IND, (ke_msg_func_t) gattc_read_req_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t) gattc_cmp_evt_handler}, +KE_MSG_HANDLER_TAB(bass){ + {BASS_ENABLE_REQ, (ke_msg_func_t)bass_enable_req_handler}, + {BASS_BATT_LEVEL_UPD_REQ, (ke_msg_func_t)bass_batt_level_upd_req_handler}, + {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t)gattc_att_info_req_ind_handler}, + {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, + {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void bass_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct bass_env_tag *bass_env = PRF_ENV_GET(BASS, bass); +void bass_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct bass_env_tag *bass_env = PRF_ENV_GET(BASS, bass); - task_desc->msg_handler_tab = bass_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(bass_msg_handler_tab); - task_desc->state = bass_env->state; - task_desc->idx_max = BASS_IDX_MAX; + task_desc->msg_handler_tab = bass_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(bass_msg_handler_tab); + task_desc->state = bass_env->state; + task_desc->idx_max = BASS_IDX_MAX; } - - #endif /* #if (BLE_BATT_SERVER) */ /// @} BASSTASK diff --git a/services/ble_profiles/blp/blpc/src/blpc.c b/services/ble_profiles/blp/blpc/src/blpc.c index 8500eb1..65bbd89 100644 --- a/services/ble_profiles/blp/blpc/src/blpc.c +++ b/services/ble_profiles/blp/blpc/src/blpc.c @@ -16,8 +16,8 @@ #include "blpc_task.h" #include "gap.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * LOCAL FUNCTIONS DEFINITIONS @@ -36,41 +36,45 @@ * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t blpc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t idx; - //-------------------- allocate memory required for the profile --------------------- +static uint8_t blpc_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t idx; + //-------------------- allocate memory required for the profile + //--------------------- - struct blpc_env_tag* blpc_env = - (struct blpc_env_tag* ) ke_malloc(sizeof(struct blpc_env_tag), KE_MEM_ATT_DB); + struct blpc_env_tag *blpc_env = (struct blpc_env_tag *)ke_malloc( + sizeof(struct blpc_env_tag), KE_MEM_ATT_DB); - // allocate BLPC required environment variable - env->env = (prf_env_t*) blpc_env; + // allocate BLPC required environment variable + env->env = (prf_env_t *)blpc_env; - blpc_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - blpc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + blpc_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + blpc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_BLPC; - blpc_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_BLPC; + blpc_task_init(&(env->desc)); - for(idx = 0; idx < BLPC_IDX_MAX ; idx++) - { - blpc_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), BLPC_FREE); - } + for (idx = 0; idx < BLPC_IDX_MAX; idx++) { + blpc_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), BLPC_FREE); + } - return GAP_ERR_NO_ERROR; + return GAP_ERR_NO_ERROR; } /** @@ -82,44 +86,41 @@ static uint8_t blpc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t * @param[in] reason Detach reason **************************************************************************************** */ -static void blpc_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct blpc_env_tag* blpc_env = (struct blpc_env_tag*) env->env; +static void blpc_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct blpc_env_tag *blpc_env = (struct blpc_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(blpc_env->env[conidx] != NULL) - { - ke_free(blpc_env->env[conidx]); - blpc_env->env[conidx] = NULL; - } + // clean-up environment variable allocated for task instance + if (blpc_env->env[conidx] != NULL) { + ke_free(blpc_env->env[conidx]); + blpc_env->env[conidx] = NULL; + } - /* Put BLP Client in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), BLPC_FREE); + /* Put BLP Client in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), BLPC_FREE); } /** **************************************************************************************** * @brief Destruction of the BLPC module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void blpc_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct blpc_env_tag* blpc_env = (struct blpc_env_tag*) env->env; +static void blpc_destroy(struct prf_task_env *env) { + uint8_t idx; + struct blpc_env_tag *blpc_env = (struct blpc_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < BLPC_IDX_MAX ; idx++) - { - blpc_cleanup(env, idx, 0); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < BLPC_IDX_MAX; idx++) { + blpc_cleanup(env, idx, 0); + } - // free profile environment variables - env->env = NULL; - ke_free(blpc_env); + // free profile environment variables + env->env = NULL; + ke_free(blpc_env); } /** @@ -130,19 +131,17 @@ static void blpc_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void blpc_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Put BLP Client in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), BLPC_IDLE); +static void blpc_create(struct prf_task_env *env, uint8_t conidx) { + /* Put BLP Client in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), BLPC_IDLE); } /// BLPC Task interface required by profile manager -const struct prf_task_cbs blpc_itf = -{ - blpc_init, - blpc_destroy, - blpc_create, - blpc_cleanup, +const struct prf_task_cbs blpc_itf = { + blpc_init, + blpc_destroy, + blpc_create, + blpc_cleanup, }; /* @@ -150,84 +149,79 @@ const struct prf_task_cbs blpc_itf = **************************************************************************************** */ -const struct prf_task_cbs* blpc_prf_itf_get(void) -{ - return &blpc_itf; -} +const struct prf_task_cbs *blpc_prf_itf_get(void) { return &blpc_itf; } /* * EXPORTED FUNCTIONS DEFINITIONS **************************************************************************************** */ -void blpc_enable_rsp_send(struct blpc_env_tag *blpc_env, uint8_t conidx, uint8_t status) -{ - // Send to APP the details of the discovered attributes on BLPS - struct blpc_enable_rsp * rsp = KE_MSG_ALLOC( - BLPC_ENABLE_RSP, - prf_dst_task_get(&(blpc_env->prf_env), conidx), - prf_src_task_get(&(blpc_env->prf_env), conidx), - blpc_enable_rsp); +void blpc_enable_rsp_send(struct blpc_env_tag *blpc_env, uint8_t conidx, + uint8_t status) { + // Send to APP the details of the discovered attributes on BLPS + struct blpc_enable_rsp *rsp = KE_MSG_ALLOC( + BLPC_ENABLE_RSP, prf_dst_task_get(&(blpc_env->prf_env), conidx), + prf_src_task_get(&(blpc_env->prf_env), conidx), blpc_enable_rsp); - rsp->status = status; + rsp->status = status; - if (status == GAP_ERR_NO_ERROR) - { - rsp->bps = blpc_env->env[conidx]->bps; + if (status == GAP_ERR_NO_ERROR) { + rsp->bps = blpc_env->env[conidx]->bps; - prf_register_atthdl2gatt(&(blpc_env->prf_env), conidx, &(blpc_env->env[conidx]->bps.svc)); + prf_register_atthdl2gatt(&(blpc_env->prf_env), conidx, + &(blpc_env->env[conidx]->bps.svc)); - // Go to connected state - ke_state_set(prf_src_task_get(&(blpc_env->prf_env), conidx), BLPC_IDLE); - } + // Go to connected state + ke_state_set(prf_src_task_get(&(blpc_env->prf_env), conidx), BLPC_IDLE); + } - ke_msg_send(rsp); + ke_msg_send(rsp); } -void blpc_unpack_meas_value(struct bps_bp_meas* pmeas_val, uint8_t* packed_bp) -{ - uint8_t cursor; +void blpc_unpack_meas_value(struct bps_bp_meas *pmeas_val, uint8_t *packed_bp) { + uint8_t cursor; - // blood pressure measurement flags - pmeas_val->flags = packed_bp[0]; + // blood pressure measurement flags + pmeas_val->flags = packed_bp[0]; - // Blood Pressure Measurement Compound Value - Systolic - pmeas_val->systolic = co_read16p(&(packed_bp[1])); + // Blood Pressure Measurement Compound Value - Systolic + pmeas_val->systolic = co_read16p(&(packed_bp[1])); - // Blood Pressure Measurement Compound Value - Diastolic (mmHg) - pmeas_val->diastolic = co_read16p(&(packed_bp[3])); + // Blood Pressure Measurement Compound Value - Diastolic (mmHg) + pmeas_val->diastolic = co_read16p(&(packed_bp[3])); - // Blood Pressure Measurement Compound Value - Mean Arterial Pressure (mmHg) - pmeas_val->mean_arterial_pressure = co_read16p(&(packed_bp[5])); + // Blood Pressure Measurement Compound Value - Mean Arterial Pressure (mmHg) + pmeas_val->mean_arterial_pressure = co_read16p(&(packed_bp[5])); - cursor = 7; + cursor = 7; - // time flag set - if ((pmeas_val->flags & BPS_FLAG_TIME_STAMP_PRESENT) == BPS_FLAG_TIME_STAMP_PRESENT) - { - cursor += prf_unpack_date_time(packed_bp + cursor, &(pmeas_val->time_stamp)); - } + // time flag set + if ((pmeas_val->flags & BPS_FLAG_TIME_STAMP_PRESENT) == + BPS_FLAG_TIME_STAMP_PRESENT) { + cursor += + prf_unpack_date_time(packed_bp + cursor, &(pmeas_val->time_stamp)); + } - // pulse rate flag set - if ((pmeas_val->flags & BPS_FLAG_PULSE_RATE_PRESENT) == BPS_FLAG_PULSE_RATE_PRESENT) - { - pmeas_val->pulse_rate = co_read16p(&(packed_bp[cursor + 0])); - cursor += 2; - } + // pulse rate flag set + if ((pmeas_val->flags & BPS_FLAG_PULSE_RATE_PRESENT) == + BPS_FLAG_PULSE_RATE_PRESENT) { + pmeas_val->pulse_rate = co_read16p(&(packed_bp[cursor + 0])); + cursor += 2; + } - // User ID flag set - if ((pmeas_val->flags & BPS_FLAG_USER_ID_PRESENT) == BPS_FLAG_USER_ID_PRESENT) - { - pmeas_val->user_id = packed_bp[cursor + 0]; - cursor += 1; - } + // User ID flag set + if ((pmeas_val->flags & BPS_FLAG_USER_ID_PRESENT) == + BPS_FLAG_USER_ID_PRESENT) { + pmeas_val->user_id = packed_bp[cursor + 0]; + cursor += 1; + } - // measurement status flag set - if ((pmeas_val->flags & BPS_FLAG_MEAS_STATUS_PRESENT) == BPS_FLAG_MEAS_STATUS_PRESENT) - { - pmeas_val->meas_status = co_read16p(&(packed_bp[cursor + 0])); - cursor += 2; - } + // measurement status flag set + if ((pmeas_val->flags & BPS_FLAG_MEAS_STATUS_PRESENT) == + BPS_FLAG_MEAS_STATUS_PRESENT) { + pmeas_val->meas_status = co_read16p(&(packed_bp[cursor + 0])); + cursor += 2; + } } #endif /* (BLE_BP_COLLECTOR) */ diff --git a/services/ble_profiles/blp/blpc/src/blpc_task.c b/services/ble_profiles/blp/blpc/src/blpc_task.c index 707c530..7082a71 100644 --- a/services/ble_profiles/blp/blpc/src/blpc_task.c +++ b/services/ble_profiles/blp/blpc/src/blpc_task.c @@ -13,13 +13,13 @@ #include "rwip_config.h" #if (BLE_BP_COLLECTOR) -#include "co_utils.h" -#include "blpc_task.h" -#include "blpc.h" -#include "gap.h" #include "att.h" -#include "gattc_task.h" +#include "blpc.h" +#include "blpc_task.h" +#include "co_utils.h" +#include "gap.h" #include "gapc_task.h" +#include "gattc_task.h" #include "ke_mem.h" /* @@ -27,30 +27,29 @@ **************************************************************************************** */ -/// State machine used to retrieve blood pressure service characteristics information -const struct prf_char_def blpc_bps_char[BLPC_CHAR_MAX] = -{ +/// State machine used to retrieve blood pressure service characteristics +/// information +const struct prf_char_def blpc_bps_char[BLPC_CHAR_MAX] = { /// Blood Pressure Measurement - [BLPC_CHAR_BP_MEAS] = {ATT_CHAR_BLOOD_PRESSURE_MEAS, - ATT_MANDATORY, - ATT_CHAR_PROP_IND}, + [BLPC_CHAR_BP_MEAS] = {ATT_CHAR_BLOOD_PRESSURE_MEAS, ATT_MANDATORY, + ATT_CHAR_PROP_IND}, /// Intermediate Cuff pressure - [BLPC_CHAR_CP_MEAS] = {ATT_CHAR_INTERMEDIATE_CUFF_PRESSURE, - ATT_OPTIONAL, - ATT_CHAR_PROP_NTF}, + [BLPC_CHAR_CP_MEAS] = {ATT_CHAR_INTERMEDIATE_CUFF_PRESSURE, ATT_OPTIONAL, + ATT_CHAR_PROP_NTF}, /// Blood Pressure Feature - [BLPC_CHAR_BP_FEATURE] = {ATT_CHAR_BLOOD_PRESSURE_FEATURE, - ATT_MANDATORY, - ATT_CHAR_PROP_RD}, + [BLPC_CHAR_BP_FEATURE] = {ATT_CHAR_BLOOD_PRESSURE_FEATURE, ATT_MANDATORY, + ATT_CHAR_PROP_RD}, }; -/// State machine used to retrieve blood pressure service characteristic description information -const struct prf_char_desc_def blpc_bps_char_desc[BLPC_DESC_MAX] = -{ +/// State machine used to retrieve blood pressure service characteristic +/// description information +const struct prf_char_desc_def blpc_bps_char_desc[BLPC_DESC_MAX] = { /// Blood Pressure Measurement client config - [BLPC_DESC_BP_MEAS_CLI_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, BLPC_CHAR_BP_MEAS}, + [BLPC_DESC_BP_MEAS_CLI_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, + BLPC_CHAR_BP_MEAS}, /// Intermediate Cuff pressure client config - [BLPC_DESC_IC_MEAS_CLI_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, BLPC_CHAR_CP_MEAS}, + [BLPC_DESC_IC_MEAS_CLI_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, + BLPC_CHAR_CP_MEAS}, }; /* @@ -70,36 +69,35 @@ const struct prf_char_desc_def blpc_bps_char_desc[BLPC_DESC_MAX] = **************************************************************************************** */ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, - struct gattc_sdp_svc_ind const *ind, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_sdp_svc_ind const *ind, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == BLPC_DISCOVERING) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == BLPC_DISCOVERING) { + uint8_t conidx = KE_IDX_GET(dest_id); - struct blpc_env_tag *blpc_env = PRF_ENV_GET(BLPC, blpc); + struct blpc_env_tag *blpc_env = PRF_ENV_GET(BLPC, blpc); - ASSERT_INFO(blpc_env != NULL, dest_id, src_id); - ASSERT_INFO(blpc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(blpc_env != NULL, dest_id, src_id); + ASSERT_INFO(blpc_env->env[conidx] != NULL, dest_id, src_id); - if(blpc_env->env[conidx]->nb_svc == 0) - { - // Retrieve BLS characteristics and descriptors - prf_extract_svc_info(ind, BLPC_CHAR_MAX, &blpc_bps_char[0], &blpc_env->env[conidx]->bps.chars[0], - BLPC_DESC_MAX, &blpc_bps_char_desc[0], &blpc_env->env[conidx]->bps.descs[0]); + if (blpc_env->env[conidx]->nb_svc == 0) { + // Retrieve BLS characteristics and descriptors + prf_extract_svc_info(ind, BLPC_CHAR_MAX, &blpc_bps_char[0], + &blpc_env->env[conidx]->bps.chars[0], BLPC_DESC_MAX, + &blpc_bps_char_desc[0], + &blpc_env->env[conidx]->bps.descs[0]); - //Even if we get multiple responses we only store 1 range - blpc_env->env[conidx]->bps.svc.shdl = ind->start_hdl; - blpc_env->env[conidx]->bps.svc.ehdl = ind->end_hdl; - } - - blpc_env->env[conidx]->nb_svc++; + // Even if we get multiple responses we only store 1 range + blpc_env->env[conidx]->bps.svc.shdl = ind->start_hdl; + blpc_env->env[conidx]->bps.svc.ehdl = ind->end_hdl; } - return (KE_MSG_CONSUMED); + blpc_env->env[conidx]->nb_svc++; + } + + return (KE_MSG_CONSUMED); } /** @@ -114,60 +112,55 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int blpc_enable_req_handler(ke_msg_id_t const msgid, - struct blpc_enable_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); - // Get state - uint8_t state = ke_state_get(dest_id); + struct blpc_enable_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); + // Get state + uint8_t state = ke_state_get(dest_id); - // Blood pressure Client Role Task Environment - struct blpc_env_tag *blpc_env = PRF_ENV_GET(BLPC, blpc); + // Blood pressure Client Role Task Environment + struct blpc_env_tag *blpc_env = PRF_ENV_GET(BLPC, blpc); - ASSERT_INFO(blpc_env != NULL, dest_id, src_id); - if((state == BLPC_IDLE) && (blpc_env->env[conidx] == NULL)) - { - // allocate environment variable for task instance - blpc_env->env[conidx] = (struct blpc_cnx_env*) ke_malloc(sizeof(struct blpc_cnx_env),KE_MEM_ATT_DB); - memset(blpc_env->env[conidx], 0, sizeof(struct blpc_cnx_env)); + ASSERT_INFO(blpc_env != NULL, dest_id, src_id); + if ((state == BLPC_IDLE) && (blpc_env->env[conidx] == NULL)) { + // allocate environment variable for task instance + blpc_env->env[conidx] = (struct blpc_cnx_env *)ke_malloc( + sizeof(struct blpc_cnx_env), KE_MEM_ATT_DB); + memset(blpc_env->env[conidx], 0, sizeof(struct blpc_cnx_env)); - //Config connection, start discovering - if(param->con_type == PRF_CON_DISCOVERY) - { - //start discovering BPS on peer - prf_disc_svc_send(&(blpc_env->prf_env), conidx, ATT_SVC_BLOOD_PRESSURE); + // Config connection, start discovering + if (param->con_type == PRF_CON_DISCOVERY) { + // start discovering BPS on peer + prf_disc_svc_send(&(blpc_env->prf_env), conidx, ATT_SVC_BLOOD_PRESSURE); - blpc_env->env[conidx]->last_uuid_req = ATT_SVC_BLOOD_PRESSURE; + blpc_env->env[conidx]->last_uuid_req = ATT_SVC_BLOOD_PRESSURE; - // Go to DISCOVERING state - ke_state_set(dest_id, BLPC_DISCOVERING); - } - //normal connection, get saved att details - else - { - blpc_env->env[conidx]->bps = param->bps; - - //send APP confirmation that can start normal connection to TH - blpc_enable_rsp_send(blpc_env, conidx, GAP_ERR_NO_ERROR); - } + // Go to DISCOVERING state + ke_state_set(dest_id, BLPC_DISCOVERING); } + // normal connection, get saved att details + else { + blpc_env->env[conidx]->bps = param->bps; - else if(state != BLPC_FREE) - { - status = PRF_ERR_REQ_DISALLOWED; + // send APP confirmation that can start normal connection to TH + blpc_enable_rsp_send(blpc_env, conidx, GAP_ERR_NO_ERROR); } + } - // send an error if request fails - if(status != GAP_ERR_NO_ERROR) - { - blpc_enable_rsp_send(blpc_env, conidx, status); - } + else if (state != BLPC_FREE) { + status = PRF_ERR_REQ_DISALLOWED; + } - return (KE_MSG_CONSUMED); + // send an error if request fails + if (status != GAP_ERR_NO_ERROR) { + blpc_enable_rsp_send(blpc_env, conidx, status); + } + + return (KE_MSG_CONSUMED); } /** @@ -182,106 +175,87 @@ __STATIC int blpc_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, - struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { - // Get the address of the environment - struct blpc_env_tag *blpc_env = PRF_ENV_GET(BLPC, blpc); - // Status - uint8_t status; + // Get the address of the environment + struct blpc_env_tag *blpc_env = PRF_ENV_GET(BLPC, blpc); + // Status + uint8_t status; - if (blpc_env != NULL) - { - uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); + if (blpc_env != NULL) { + uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t state = ke_state_get(dest_id); - if(state == BLPC_DISCOVERING) - { - status = param->status; + if (state == BLPC_DISCOVERING) { + status = param->status; - if ((status == ATT_ERR_ATTRIBUTE_NOT_FOUND)|| - (status == ATT_ERR_NO_ERROR)) - { - // Discovery - // check characteristic validity - if(blpc_env->env[conidx]->nb_svc == 1) - { - status = prf_check_svc_char_validity(BLPC_CHAR_MAX, - blpc_env->env[conidx]->bps.chars, - blpc_bps_char); - } - // too much services - else if (blpc_env->env[conidx]->nb_svc > 1) - { - status = PRF_ERR_MULTIPLE_SVC; - } - // no services found - else - { - status = PRF_ERR_STOP_DISC_CHAR_MISSING; - } - - // check descriptor validity - if (status == GAP_ERR_NO_ERROR) - { - status = prf_check_svc_char_desc_validity(BLPC_DESC_MAX, - blpc_env->env[conidx]->bps.descs, - blpc_bps_char_desc, - blpc_env->env[conidx]->bps.chars); - } - } - - blpc_enable_rsp_send(blpc_env, conidx, status); + if ((status == ATT_ERR_ATTRIBUTE_NOT_FOUND) || + (status == ATT_ERR_NO_ERROR)) { + // Discovery + // check characteristic validity + if (blpc_env->env[conidx]->nb_svc == 1) { + status = prf_check_svc_char_validity( + BLPC_CHAR_MAX, blpc_env->env[conidx]->bps.chars, blpc_bps_char); + } + // too much services + else if (blpc_env->env[conidx]->nb_svc > 1) { + status = PRF_ERR_MULTIPLE_SVC; + } + // no services found + else { + status = PRF_ERR_STOP_DISC_CHAR_MISSING; } - else if(BLPC_BUSY) - { - switch(param->operation) - { - - case GATTC_WRITE: - case GATTC_WRITE_NO_RESPONSE: - { - struct blpc_cfg_indntf_rsp *wr_cfm = KE_MSG_ALLOC( - BLPC_CFG_INDNTF_RSP, - prf_dst_task_get(&(blpc_env->prf_env), conidx), - prf_src_task_get(&(blpc_env->prf_env), conidx), - blpc_cfg_indntf_rsp); - //it will be a GATT status code - wr_cfm->status = param->status; - // send the message - ke_msg_send(wr_cfm); - } - break; - - case GATTC_READ: - { - if(param->status != GAP_ERR_NO_ERROR) - { - prf_client_att_info_rsp( - (prf_env_t*) blpc_env->env[conidx], - conidx, BLPC_RD_CHAR_RSP, - param->status, NULL); - } - } - break; - - default: break; - } - - ke_state_set(prf_src_task_get(&blpc_env->prf_env, conidx), BLPC_IDLE); + // check descriptor validity + if (status == GAP_ERR_NO_ERROR) { + status = prf_check_svc_char_desc_validity( + BLPC_DESC_MAX, blpc_env->env[conidx]->bps.descs, + blpc_bps_char_desc, blpc_env->env[conidx]->bps.chars); } + } + + blpc_enable_rsp_send(blpc_env, conidx, status); } - return (KE_MSG_CONSUMED); + + else if (BLPC_BUSY) { + switch (param->operation) { + + case GATTC_WRITE: + case GATTC_WRITE_NO_RESPONSE: { + struct blpc_cfg_indntf_rsp *wr_cfm = KE_MSG_ALLOC( + BLPC_CFG_INDNTF_RSP, prf_dst_task_get(&(blpc_env->prf_env), conidx), + prf_src_task_get(&(blpc_env->prf_env), conidx), + blpc_cfg_indntf_rsp); + // it will be a GATT status code + wr_cfm->status = param->status; + // send the message + ke_msg_send(wr_cfm); + } break; + + case GATTC_READ: { + if (param->status != GAP_ERR_NO_ERROR) { + prf_client_att_info_rsp((prf_env_t *)blpc_env->env[conidx], conidx, + BLPC_RD_CHAR_RSP, param->status, NULL); + } + } break; + + default: + break; + } + + ke_state_set(prf_src_task_get(&blpc_env->prf_env, conidx), BLPC_IDLE); + } + } + return (KE_MSG_CONSUMED); } /** **************************************************************************************** * @brief Handles reception of the @ref BLPC_RD_CHAR_REQ message. - * Check if the handle exists in profile(already discovered) and send request, otherwise - * error to APP. + * Check if the handle exists in profile(already discovered) and send request, + *otherwise error to APP. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -290,57 +264,46 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int blpc_rd_char_req_handler(ke_msg_id_t const msgid, - struct blpc_rd_char_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - uint8_t status = PRF_ERR_REQ_DISALLOWED; + struct blpc_rd_char_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + uint8_t status = PRF_ERR_REQ_DISALLOWED; - // Get the address of the environment - struct blpc_env_tag *blpc_env = PRF_ENV_GET(BLPC, blpc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct blpc_env_tag *blpc_env = PRF_ENV_GET(BLPC, blpc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - if((state == BLPC_IDLE) && (blpc_env->env[conidx] != NULL)) - { - uint16_t search_hdl = ATT_INVALID_SEARCH_HANDLE; + if ((state == BLPC_IDLE) && (blpc_env->env[conidx] != NULL)) { + uint16_t search_hdl = ATT_INVALID_SEARCH_HANDLE; - if((param->char_code & BLPC_DESC_MASK) == BLPC_DESC_MASK) - { - search_hdl = blpc_env->env[conidx]->bps.descs[param->char_code & ~BLPC_DESC_MASK].desc_hdl; - } - else - { - search_hdl = blpc_env->env[conidx]->bps.chars[param->char_code].val_hdl; - } - - //check if handle is viable - if (search_hdl != ATT_INVALID_SEARCH_HANDLE) - { - prf_read_char_send( - &(blpc_env->prf_env), conidx, - blpc_env->env[conidx]->bps.svc.shdl, - blpc_env->env[conidx]->bps.svc.ehdl, - search_hdl); - - status = GAP_ERR_NO_ERROR; - } - else - { - status = PRF_ERR_INEXISTENT_HDL; - } + if ((param->char_code & BLPC_DESC_MASK) == BLPC_DESC_MASK) { + search_hdl = blpc_env->env[conidx] + ->bps.descs[param->char_code & ~BLPC_DESC_MASK] + .desc_hdl; + } else { + search_hdl = blpc_env->env[conidx]->bps.chars[param->char_code].val_hdl; } - if (status != GAP_ERR_NO_ERROR) - { - prf_client_att_info_rsp( - (prf_env_t*) blpc_env->env[conidx], - conidx, BLPC_RD_CHAR_RSP, - status, NULL); - } + // check if handle is viable + if (search_hdl != ATT_INVALID_SEARCH_HANDLE) { + prf_read_char_send(&(blpc_env->prf_env), conidx, + blpc_env->env[conidx]->bps.svc.shdl, + blpc_env->env[conidx]->bps.svc.ehdl, search_hdl); - return (KE_MSG_CONSUMED); + status = GAP_ERR_NO_ERROR; + } else { + status = PRF_ERR_INEXISTENT_HDL; + } + } + + if (status != GAP_ERR_NO_ERROR) { + prf_client_att_info_rsp((prf_env_t *)blpc_env->env[conidx], conidx, + BLPC_RD_CHAR_RSP, status, NULL); + } + + return (KE_MSG_CONSUMED); } /** @@ -357,24 +320,24 @@ __STATIC int blpc_rd_char_req_handler(ke_msg_id_t const msgid, __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, struct gattc_read_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct blpc_env_tag *blpc_env = PRF_ENV_GET(BLPC, blpc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + ke_task_id_t const src_id) { + // Get the address of the environment + struct blpc_env_tag *blpc_env = PRF_ENV_GET(BLPC, blpc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - prf_client_att_info_rsp(&blpc_env->prf_env, conidx, BLPC_RD_CHAR_RSP, - GAP_ERR_NO_ERROR, param); + prf_client_att_info_rsp(&blpc_env->prf_env, conidx, BLPC_RD_CHAR_RSP, + GAP_ERR_NO_ERROR, param); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** **************************************************************************************** * @brief Handles reception of the @ref BLPC_CFG_INDNTF_REQ message. - * It allows configuration of the peer ind/ntf/stop characteristic for a specified characteristic. - * Will return an error code if that cfg char does not exist. + * It allows configuration of the peer ind/ntf/stop characteristic for a + *specified characteristic. Will return an error code if that cfg char does not + *exist. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -382,72 +345,70 @@ __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int blpc_cfg_indntf_req_handler(ke_msg_id_t const msgid, - struct blpc_cfg_indntf_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint16_t cfg_hdl = ATT_INVALID_SEARCH_HANDLE; - // Get the address of the environment - struct blpc_env_tag *blpc_env = PRF_ENV_GET(BLPC, blpc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); - // Status - uint8_t status = PRF_ERR_REQ_DISALLOWED; +__STATIC int blpc_cfg_indntf_req_handler( + ke_msg_id_t const msgid, struct blpc_cfg_indntf_req const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + uint16_t cfg_hdl = ATT_INVALID_SEARCH_HANDLE; + // Get the address of the environment + struct blpc_env_tag *blpc_env = PRF_ENV_GET(BLPC, blpc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); + // Status + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if((blpc_env->env[conidx] != NULL) && (ke_state_get(dest_id) == BLPC_IDLE)) + if ((blpc_env->env[conidx] != NULL) && (ke_state_get(dest_id) == BLPC_IDLE)) { + status = PRF_ERR_INVALID_PARAM; + // get handle of the configuration characteristic to set and check if value + // matches property + switch (param->char_code) { + case BLPC_CHAR_BP_MEAS: // can only IND { - status = PRF_ERR_INVALID_PARAM; - //get handle of the configuration characteristic to set and check if value matches property - switch(param->char_code) - { - case BLPC_CHAR_BP_MEAS://can only IND - { - if((param->cfg_val == PRF_CLI_STOP_NTFIND)|| - (param->cfg_val == PRF_CLI_START_IND)) - { - cfg_hdl = blpc_env->env[conidx]->bps.descs[BLPC_DESC_BP_MEAS_CLI_CFG].desc_hdl; - } - }break; + if ((param->cfg_val == PRF_CLI_STOP_NTFIND) || + (param->cfg_val == PRF_CLI_START_IND)) { + cfg_hdl = blpc_env->env[conidx] + ->bps.descs[BLPC_DESC_BP_MEAS_CLI_CFG] + .desc_hdl; + } + } break; - case BLPC_CHAR_CP_MEAS://can only NTF - { - if((param->cfg_val == PRF_CLI_STOP_NTFIND)|| - (param->cfg_val == PRF_CLI_START_NTF)) - { - cfg_hdl = blpc_env->env[conidx]->bps.descs[BLPC_DESC_IC_MEAS_CLI_CFG].desc_hdl; - } + case BLPC_CHAR_CP_MEAS: // can only NTF + { + if ((param->cfg_val == PRF_CLI_STOP_NTFIND) || + (param->cfg_val == PRF_CLI_START_NTF)) { + cfg_hdl = blpc_env->env[conidx] + ->bps.descs[BLPC_DESC_IC_MEAS_CLI_CFG] + .desc_hdl; + } - }break; + } break; - default: - { - status = PRF_ERR_INEXISTENT_HDL; - }break; - } - - //check if the handle value exists - if (cfg_hdl != ATT_INVALID_SEARCH_HANDLE) - { - // Send GATT Write Request - prf_gatt_write_ntf_ind(&blpc_env->prf_env, conidx, cfg_hdl, param->cfg_val); - // Set status - status = GAP_ERR_NO_ERROR; - } + default: { + status = PRF_ERR_INEXISTENT_HDL; + } break; } - if (status != GAP_ERR_NO_ERROR) - { - struct blpc_cfg_indntf_rsp *rsp = KE_MSG_ALLOC(BLPC_CFG_INDNTF_RSP, src_id, dest_id, blpc_cfg_indntf_rsp); - - // It will be an PRF status code - rsp->status = status; - - // Send the message - ke_msg_send(rsp); + // check if the handle value exists + if (cfg_hdl != ATT_INVALID_SEARCH_HANDLE) { + // Send GATT Write Request + prf_gatt_write_ntf_ind(&blpc_env->prf_env, conidx, cfg_hdl, + param->cfg_val); + // Set status + status = GAP_ERR_NO_ERROR; } + } - return (KE_MSG_CONSUMED); + if (status != GAP_ERR_NO_ERROR) { + struct blpc_cfg_indntf_rsp *rsp = + KE_MSG_ALLOC(BLPC_CFG_INDNTF_RSP, src_id, dest_id, blpc_cfg_indntf_rsp); + + // It will be an PRF status code + rsp->status = status; + + // Send the message + ke_msg_send(rsp); + } + + return (KE_MSG_CONSUMED); } /** @@ -461,53 +422,50 @@ __STATIC int blpc_cfg_indntf_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, - struct gattc_event_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct blpc_env_tag *blpc_env = PRF_ENV_GET(BLPC, blpc); + struct gattc_event_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct blpc_env_tag *blpc_env = PRF_ENV_GET(BLPC, blpc); - if(blpc_env->env[conidx] != NULL) - { - switch(param->type) - { - case GATTC_INDICATE: - { - // confirm that indication has been correctly received - struct gattc_event_cfm * cfm = KE_MSG_ALLOC(GATTC_EVENT_CFM, src_id, dest_id, gattc_event_cfm); - cfm->handle = param->handle; - ke_msg_send(cfm); - } - /* no break */ - - case GATTC_NOTIFY: - { - if((param->handle == blpc_env->env[conidx]->bps.chars[BLPC_CHAR_CP_MEAS].val_hdl) - || ((param->handle == blpc_env->env[conidx]->bps.chars[BLPC_CHAR_BP_MEAS].val_hdl))) - { - //build a BLPC_BP_MEAD_IND message with stable blood pressure value code. - struct blpc_bp_meas_ind * ind = KE_MSG_ALLOC( - BLPC_BP_MEAS_IND, - prf_dst_task_get(&(blpc_env->prf_env), conidx), - prf_src_task_get(&(blpc_env->prf_env), conidx), - blpc_bp_meas_ind); - - // Intermediate cuff pressure value - ind->flag_interm_cp = ((param->type == GATTC_NOTIFY) ? 0x01 : 0x00); - - // unpack blood pressure measurement. - blpc_unpack_meas_value(&(ind->meas_val), (uint8_t*) param->value); - - ke_msg_send(ind); - } - } break; - - default: break; - } + if (blpc_env->env[conidx] != NULL) { + switch (param->type) { + case GATTC_INDICATE: { + // confirm that indication has been correctly received + struct gattc_event_cfm *cfm = + KE_MSG_ALLOC(GATTC_EVENT_CFM, src_id, dest_id, gattc_event_cfm); + cfm->handle = param->handle; + ke_msg_send(cfm); } - return (KE_MSG_CONSUMED); + /* no break */ + + case GATTC_NOTIFY: { + if ((param->handle == + blpc_env->env[conidx]->bps.chars[BLPC_CHAR_CP_MEAS].val_hdl) || + ((param->handle == + blpc_env->env[conidx]->bps.chars[BLPC_CHAR_BP_MEAS].val_hdl))) { + // build a BLPC_BP_MEAD_IND message with stable blood pressure value + // code. + struct blpc_bp_meas_ind *ind = KE_MSG_ALLOC( + BLPC_BP_MEAS_IND, prf_dst_task_get(&(blpc_env->prf_env), conidx), + prf_src_task_get(&(blpc_env->prf_env), conidx), blpc_bp_meas_ind); + + // Intermediate cuff pressure value + ind->flag_interm_cp = ((param->type == GATTC_NOTIFY) ? 0x01 : 0x00); + + // unpack blood pressure measurement. + blpc_unpack_meas_value(&(ind->meas_val), (uint8_t *)param->value); + + ke_msg_send(ind); + } + } break; + + default: + break; + } + } + return (KE_MSG_CONSUMED); } /* @@ -516,27 +474,25 @@ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, */ /// Default State handlers definition -KE_MSG_HANDLER_TAB(blpc) -{ - {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, - {BLPC_ENABLE_REQ, (ke_msg_func_t)blpc_enable_req_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, - {BLPC_RD_CHAR_REQ, (ke_msg_func_t)blpc_rd_char_req_handler}, - {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, - {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, - {GATTC_EVENT_REQ_IND, (ke_msg_func_t)gattc_event_ind_handler}, - {BLPC_CFG_INDNTF_REQ, (ke_msg_func_t)blpc_cfg_indntf_req_handler}, +KE_MSG_HANDLER_TAB(blpc){ + {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, + {BLPC_ENABLE_REQ, (ke_msg_func_t)blpc_enable_req_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, + {BLPC_RD_CHAR_REQ, (ke_msg_func_t)blpc_rd_char_req_handler}, + {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, + {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {GATTC_EVENT_REQ_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {BLPC_CFG_INDNTF_REQ, (ke_msg_func_t)blpc_cfg_indntf_req_handler}, }; -void blpc_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct blpc_env_tag *blpc_env = PRF_ENV_GET(BLPC, blpc); +void blpc_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct blpc_env_tag *blpc_env = PRF_ENV_GET(BLPC, blpc); - task_desc->msg_handler_tab = blpc_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(blpc_msg_handler_tab); - task_desc->state = blpc_env->state; - task_desc->idx_max = BLPC_IDX_MAX; + task_desc->msg_handler_tab = blpc_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(blpc_msg_handler_tab); + task_desc->state = blpc_env->state; + task_desc->idx_max = BLPC_IDX_MAX; } #endif /* (BLE_BP_COLLECTOR) */ diff --git a/services/ble_profiles/blp/blps/src/blps.c b/services/ble_profiles/blp/blps/src/blps.c index 0fd5563..9738b1d 100644 --- a/services/ble_profiles/blp/blps/src/blps.c +++ b/services/ble_profiles/blp/blps/src/blps.c @@ -13,14 +13,14 @@ #include "rwip_config.h" #if (BLE_BP_SENSOR) -#include "gap.h" -#include "gattc_task.h" #include "blps.h" #include "blps_task.h" +#include "gap.h" +#include "gattc_task.h" #include "prf_utils.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * BLPS PROFILE ATTRIBUTES @@ -28,29 +28,42 @@ */ /// Full BLPS Database Description - Used to add attributes into the database -const struct attm_desc blps_att_db[BPS_IDX_NB] = -{ +const struct attm_desc blps_att_db[BPS_IDX_NB] = { // Blood Pressure Service Declaration - [BPS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [BPS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // Blood Pressure Measurement Characteristic Declaration - [BPS_IDX_BP_MEAS_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [BPS_IDX_BP_MEAS_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, // Blood Pressure Measurement Characteristic Value - [BPS_IDX_BP_MEAS_VAL] = {ATT_CHAR_BLOOD_PRESSURE_MEAS, PERM(IND, ENABLE), PERM(RI, ENABLE), BLPS_BP_MEAS_MAX_LEN}, - // Blood Pressure Measurement Characteristic - Client Characteristic Configuration Descriptor - [BPS_IDX_BP_MEAS_IND_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [BPS_IDX_BP_MEAS_VAL] = {ATT_CHAR_BLOOD_PRESSURE_MEAS, PERM(IND, ENABLE), + PERM(RI, ENABLE), BLPS_BP_MEAS_MAX_LEN}, + // Blood Pressure Measurement Characteristic - Client Characteristic + // Configuration Descriptor + [BPS_IDX_BP_MEAS_IND_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, + 0}, // Blood Pressure Feature Characteristic Declaration - [BPS_IDX_BP_FEATURE_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [BPS_IDX_BP_FEATURE_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Blood Pressure Feature Characteristic Value - [BPS_IDX_BP_FEATURE_VAL] = {ATT_CHAR_BLOOD_PRESSURE_FEATURE, PERM(RD, ENABLE), PERM(RI, ENABLE), sizeof(uint16_t)}, + [BPS_IDX_BP_FEATURE_VAL] = {ATT_CHAR_BLOOD_PRESSURE_FEATURE, + PERM(RD, ENABLE), PERM(RI, ENABLE), + sizeof(uint16_t)}, // Intermediate Cuff Pressure Characteristic Declaration - [BPS_IDX_INTM_CUFF_PRESS_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [BPS_IDX_INTM_CUFF_PRESS_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), + 0, 0}, // Intermediate Cuff Pressure Characteristic Value - [BPS_IDX_INTM_CUFF_PRESS_VAL] = {ATT_CHAR_INTERMEDIATE_CUFF_PRESSURE, PERM(NTF, ENABLE), PERM(RI, ENABLE), BLPS_BP_MEAS_MAX_LEN}, - // Intermediate Cuff Pressure Characteristic - Client Characteristic Configuration Descriptor - [BPS_IDX_INTM_CUFF_PRESS_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [BPS_IDX_INTM_CUFF_PRESS_VAL] = {ATT_CHAR_INTERMEDIATE_CUFF_PRESSURE, + PERM(NTF, ENABLE), PERM(RI, ENABLE), + BLPS_BP_MEAS_MAX_LEN}, + // Intermediate Cuff Pressure Characteristic - Client Characteristic + // Configuration Descriptor + [BPS_IDX_INTM_CUFF_PRESS_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | + PERM(WRITE_REQ, ENABLE), + 0, 0}, }; /* @@ -70,80 +83,86 @@ const struct attm_desc blps_att_db[BPS_IDX_NB] = * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t blps_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, struct blps_db_cfg* params) -{ - //------------------ create the attribute database for the profile ------------------- - // Service content flag - uint32_t cfg_flag= BLPS_MANDATORY_MASK; - // DB Creation Status - uint8_t status = ATT_ERR_NO_ERROR; +static uint8_t blps_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, + struct blps_db_cfg *params) { + //------------------ create the attribute database for the profile + //------------------- + // Service content flag + uint32_t cfg_flag = BLPS_MANDATORY_MASK; + // DB Creation Status + uint8_t status = ATT_ERR_NO_ERROR; - //Set Configuration Flag Value - if (params->prfl_cfg & BLPS_INTM_CUFF_PRESS_SUP) - { - cfg_flag |= BLPS_INTM_CUFF_PRESS_MASK; - } + // Set Configuration Flag Value + if (params->prfl_cfg & BLPS_INTM_CUFF_PRESS_SUP) { + cfg_flag |= BLPS_INTM_CUFF_PRESS_MASK; + } - // Add service in the database - status = attm_svc_create_db(start_hdl, ATT_SVC_BLOOD_PRESSURE, (uint8_t *)&cfg_flag, - BPS_IDX_NB, NULL, env->task, &blps_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | PERM(SVC_MI, DISABLE)); + // Add service in the database + status = attm_svc_create_db( + start_hdl, ATT_SVC_BLOOD_PRESSURE, (uint8_t *)&cfg_flag, BPS_IDX_NB, NULL, + env->task, &blps_att_db[0], + (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, DISABLE)); - //-------------------- allocate memory required for the profile --------------------- - if (status == ATT_ERR_NO_ERROR) - { - // Allocate BLPS required environment variable - struct blps_env_tag* blps_env = - (struct blps_env_tag* ) ke_malloc(sizeof(struct blps_env_tag), KE_MEM_ATT_DB); + //-------------------- allocate memory required for the profile + //--------------------- + if (status == ATT_ERR_NO_ERROR) { + // Allocate BLPS required environment variable + struct blps_env_tag *blps_env = (struct blps_env_tag *)ke_malloc( + sizeof(struct blps_env_tag), KE_MEM_ATT_DB); - // Initialize BLPS environment - env->env = (prf_env_t*) blps_env; - blps_env->shdl = *start_hdl; - blps_env->features = params->features; - blps_env->prfl_cfg = params->prfl_cfg; + // Initialize BLPS environment + env->env = (prf_env_t *)blps_env; + blps_env->shdl = *start_hdl; + blps_env->features = params->features; + blps_env->prfl_cfg = params->prfl_cfg; - blps_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - // Multi Instantiated task - blps_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + blps_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + // Multi Instantiated task + blps_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_BLPS; - blps_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_BLPS; + blps_task_init(&(env->desc)); - memset(blps_env->prfl_ntf_ind_cfg, 0, BLE_CONNECTION_MAX); + memset(blps_env->prfl_ntf_ind_cfg, 0, BLE_CONNECTION_MAX); - /* Put BLS in disabled state */ - ke_state_set(env->task, BLPS_IDLE); - } + /* Put BLS in disabled state */ + ke_state_set(env->task, BLPS_IDLE); + } - return (status); + return (status); } /** **************************************************************************************** * @brief Destruction of the BLPS module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void blps_destroy(struct prf_task_env* env) -{ - struct blps_env_tag* blps_env = (struct blps_env_tag*) env->env; +static void blps_destroy(struct prf_task_env *env) { + struct blps_env_tag *blps_env = (struct blps_env_tag *)env->env; - // free profile environment variables - env->env = NULL; - ke_free(blps_env); + // free profile environment variables + env->env = NULL; + ke_free(blps_env); } /** @@ -154,13 +173,12 @@ static void blps_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void blps_create(struct prf_task_env* env, uint8_t conidx) -{ - struct blps_env_tag* blps_env = (struct blps_env_tag*) env->env; - blps_env->prfl_ntf_ind_cfg[conidx] = 0; +static void blps_create(struct prf_task_env *env, uint8_t conidx) { + struct blps_env_tag *blps_env = (struct blps_env_tag *)env->env; + blps_env->prfl_ntf_ind_cfg[conidx] = 0; - /* Put BLS in idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), BLPS_IDLE); + /* Put BLS in idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), BLPS_IDLE); } /** @@ -172,12 +190,12 @@ static void blps_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void blps_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct blps_env_tag* blps_env = (struct blps_env_tag*) env->env; +static void blps_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct blps_env_tag *blps_env = (struct blps_env_tag *)env->env; - // clean-up environment variable allocated for task instance - blps_env->prfl_ntf_ind_cfg[conidx] = 0; + // clean-up environment variable allocated for task instance + blps_env->prfl_ntf_ind_cfg[conidx] = 0; } /* @@ -186,12 +204,11 @@ static void blps_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reaso */ /// BLPS Task interface required by profile manager -const struct prf_task_cbs blps_itf = -{ - (prf_init_fnct) blps_init, - blps_destroy, - blps_create, - blps_cleanup, +const struct prf_task_cbs blps_itf = { + (prf_init_fnct)blps_init, + blps_destroy, + blps_create, + blps_cleanup, }; /* @@ -199,78 +216,72 @@ const struct prf_task_cbs blps_itf = **************************************************************************************** */ -const struct prf_task_cbs* blps_prf_itf_get(void) -{ - return &blps_itf; +const struct prf_task_cbs *blps_prf_itf_get(void) { return &blps_itf; } + +uint8_t blps_pack_meas_value(uint8_t *packed_bp, + const struct bps_bp_meas *pmeas_val) { + uint8_t cursor; + + *(packed_bp) = pmeas_val->flags; + + // Blood Pressure Measurement Compound Value - Systolic + co_write16p(packed_bp + 1, pmeas_val->systolic); + + // Blood Pressure Measurement Compound Value - Diastolic (mmHg) + co_write16p(packed_bp + 3, pmeas_val->diastolic); + + // Blood Pressure Measurement Compound Value - Mean Arterial Pressure (mmHg) + co_write16p(packed_bp + 5, pmeas_val->mean_arterial_pressure); + + cursor = 7; + + // time flag set + if ((pmeas_val->flags & BPS_FLAG_TIME_STAMP_PRESENT) == + BPS_FLAG_TIME_STAMP_PRESENT) { + cursor += prf_pack_date_time(packed_bp + cursor, &(pmeas_val->time_stamp)); + } + + // Pulse rate flag set + if ((pmeas_val->flags & BPS_FLAG_PULSE_RATE_PRESENT) == + BPS_FLAG_PULSE_RATE_PRESENT) { + co_write16p(packed_bp + cursor, pmeas_val->pulse_rate); + cursor += 2; + } + + // User ID flag set + if ((pmeas_val->flags & BPS_FLAG_USER_ID_PRESENT) == + BPS_FLAG_USER_ID_PRESENT) { + *(packed_bp + cursor) = pmeas_val->user_id; + cursor += 1; + } + + // Measurement status flag set + if ((pmeas_val->flags & BPS_FLAG_MEAS_STATUS_PRESENT) == + BPS_FLAG_MEAS_STATUS_PRESENT) { + co_write16p(packed_bp + cursor, pmeas_val->meas_status); + cursor += 2; + } + + // clear unused packet data + if (cursor < BLPS_BP_MEAS_MAX_LEN) { + memset(packed_bp + cursor, 0, BLPS_BP_MEAS_MAX_LEN - cursor); + } + + return cursor; } -uint8_t blps_pack_meas_value(uint8_t *packed_bp, const struct bps_bp_meas* pmeas_val) -{ - uint8_t cursor; +void blps_meas_send_rsp_send(uint8_t conidx, uint8_t status) { + // Get the address of the environment + struct blps_env_tag *blps_env = PRF_ENV_GET(BLPS, blps); - *(packed_bp) = pmeas_val->flags; + struct blps_meas_send_rsp *rsp = KE_MSG_ALLOC( + BLPS_MEAS_SEND_RSP, prf_dst_task_get(&blps_env->prf_env, conidx), + prf_src_task_get(&blps_env->prf_env, conidx), blps_meas_send_rsp); - // Blood Pressure Measurement Compound Value - Systolic - co_write16p(packed_bp + 1, pmeas_val->systolic); + rsp->conidx = conidx; + rsp->status = status; - // Blood Pressure Measurement Compound Value - Diastolic (mmHg) - co_write16p(packed_bp + 3, pmeas_val->diastolic); - - // Blood Pressure Measurement Compound Value - Mean Arterial Pressure (mmHg) - co_write16p(packed_bp + 5, pmeas_val->mean_arterial_pressure); - - cursor = 7; - - // time flag set - if ((pmeas_val->flags & BPS_FLAG_TIME_STAMP_PRESENT) == BPS_FLAG_TIME_STAMP_PRESENT) - { - cursor += prf_pack_date_time(packed_bp + cursor, &(pmeas_val->time_stamp)); - } - - // Pulse rate flag set - if ((pmeas_val->flags & BPS_FLAG_PULSE_RATE_PRESENT) == BPS_FLAG_PULSE_RATE_PRESENT) - { - co_write16p(packed_bp + cursor, pmeas_val->pulse_rate); - cursor += 2; - } - - // User ID flag set - if ((pmeas_val->flags & BPS_FLAG_USER_ID_PRESENT) == BPS_FLAG_USER_ID_PRESENT) - { - *(packed_bp + cursor) = pmeas_val->user_id; - cursor += 1; - } - - // Measurement status flag set - if ((pmeas_val->flags & BPS_FLAG_MEAS_STATUS_PRESENT) == BPS_FLAG_MEAS_STATUS_PRESENT) - { - co_write16p(packed_bp + cursor, pmeas_val->meas_status); - cursor += 2; - } - - // clear unused packet data - if(cursor < BLPS_BP_MEAS_MAX_LEN) - { - memset(packed_bp + cursor, 0, BLPS_BP_MEAS_MAX_LEN - cursor); - } - - return cursor; -} - -void blps_meas_send_rsp_send(uint8_t conidx, uint8_t status) -{ - // Get the address of the environment - struct blps_env_tag *blps_env = PRF_ENV_GET(BLPS, blps); - - struct blps_meas_send_rsp * rsp = KE_MSG_ALLOC(BLPS_MEAS_SEND_RSP, - prf_dst_task_get(&blps_env->prf_env, conidx), - prf_src_task_get(&blps_env->prf_env, conidx), - blps_meas_send_rsp); - - rsp->conidx = conidx; - rsp->status = status; - - ke_msg_send(rsp); + ke_msg_send(rsp); } #endif /* BLE_BP_SENSOR */ diff --git a/services/ble_profiles/blp/blps/src/blps_task.c b/services/ble_profiles/blp/blps/src/blps_task.c index fb839d6..907956b 100644 --- a/services/ble_profiles/blp/blps/src/blps_task.c +++ b/services/ble_profiles/blp/blps/src/blps_task.c @@ -14,14 +14,12 @@ #if (BLE_BP_SENSOR) #include "co_utils.h" -#include "gap.h" -#include "gattc_task.h" #include "blps.h" #include "blps_task.h" +#include "gap.h" +#include "gattc_task.h" #include "prf_utils.h" - - /* * LOCAL FUNCTIONS DEFINITIONS **************************************************************************************** @@ -30,7 +28,8 @@ /** **************************************************************************************** * @brief Handles reception of the @ref BLPS_ENABLE_REQ message. - * The handler enables the Blood Pressure Sensor Profile and initialize readable values. + * The handler enables the Blood Pressure Sensor Profile and initialize readable + *values. * @param[in] msgid Id of the message received (probably unused).off * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -39,44 +38,39 @@ **************************************************************************************** */ __STATIC int blps_enable_req_handler(ke_msg_id_t const msgid, - struct blps_enable_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct blps_env_tag *blps_env = PRF_ENV_GET(BLPS, blps); + struct blps_enable_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct blps_env_tag *blps_env = PRF_ENV_GET(BLPS, blps); - // Status - uint8_t status = PRF_ERR_REQ_DISALLOWED; + // Status + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if(gapc_get_conhdl(param->conidx) == GAP_INVALID_CONHDL) - { - status = PRF_ERR_DISCONNECTED; - } - else if(ke_state_get(dest_id) == BLPS_IDLE) - { - if (param->interm_cp_ntf_en == PRF_CLI_START_NTF) - { - // Enable Bonded Data - blps_env->prfl_ntf_ind_cfg[param->conidx] |= BLPS_INTM_CUFF_PRESS_NTF_CFG; - } + if (gapc_get_conhdl(param->conidx) == GAP_INVALID_CONHDL) { + status = PRF_ERR_DISCONNECTED; + } else if (ke_state_get(dest_id) == BLPS_IDLE) { + if (param->interm_cp_ntf_en == PRF_CLI_START_NTF) { + // Enable Bonded Data + blps_env->prfl_ntf_ind_cfg[param->conidx] |= BLPS_INTM_CUFF_PRESS_NTF_CFG; + } - if (param->bp_meas_ind_en == PRF_CLI_START_IND) - { - // Enable Bonded Data - blps_env->prfl_ntf_ind_cfg[param->conidx] |= BLPS_BP_MEAS_IND_CFG; - } + if (param->bp_meas_ind_en == PRF_CLI_START_IND) { + // Enable Bonded Data + blps_env->prfl_ntf_ind_cfg[param->conidx] |= BLPS_BP_MEAS_IND_CFG; + } - status = GAP_ERR_NO_ERROR; - } + status = GAP_ERR_NO_ERROR; + } - // send completed information to APP task that contains error status - struct blps_enable_rsp *cmp_evt = KE_MSG_ALLOC(BLPS_ENABLE_RSP, src_id, dest_id, blps_enable_rsp); - cmp_evt->status = status; - cmp_evt->conidx = param->conidx; - ke_msg_send(cmp_evt); + // send completed information to APP task that contains error status + struct blps_enable_rsp *cmp_evt = + KE_MSG_ALLOC(BLPS_ENABLE_RSP, src_id, dest_id, blps_enable_rsp); + cmp_evt->status = status; + cmp_evt->conidx = param->conidx; + ke_msg_send(cmp_evt); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -91,65 +85,59 @@ __STATIC int blps_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_read_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if(ke_state_get(dest_id) == BLPS_IDLE) - { - // Get the address of the environment - struct blps_env_tag *blps_env = PRF_ENV_GET(BLPS, blps); - uint8_t conidx = KE_IDX_GET(src_id); - uint8_t att_idx = param->handle - blps_env->shdl; + struct gattc_read_req_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + if (ke_state_get(dest_id) == BLPS_IDLE) { + // Get the address of the environment + struct blps_env_tag *blps_env = PRF_ENV_GET(BLPS, blps); + uint8_t conidx = KE_IDX_GET(src_id); + uint8_t att_idx = param->handle - blps_env->shdl; - uint16_t value = 0; - uint8_t status = ATT_ERR_NO_ERROR; + uint16_t value = 0; + uint8_t status = ATT_ERR_NO_ERROR; - switch(att_idx) - { - case BPS_IDX_BP_FEATURE_VAL: - { - value = blps_env->features; - } break; + switch (att_idx) { + case BPS_IDX_BP_FEATURE_VAL: { + value = blps_env->features; + } break; - case BPS_IDX_BP_MEAS_IND_CFG: - { - value = (blps_env->prfl_ntf_ind_cfg[conidx] & BLPS_BP_MEAS_IND_CFG) - ? PRF_CLI_START_IND : PRF_CLI_STOP_NTFIND; - } break; - case BPS_IDX_INTM_CUFF_PRESS_NTF_CFG: - { - // Characteristic is profile specific - if (BLPS_IS_SUPPORTED(BLPS_INTM_CUFF_PRESS_SUP)) - { - // Fill data - value = (blps_env->prfl_ntf_ind_cfg[conidx] & BLPS_INTM_CUFF_PRESS_NTF_CFG) - ? PRF_CLI_START_NTF : PRF_CLI_STOP_NTFIND; - } - else - { - status = ATT_ERR_ATTRIBUTE_NOT_FOUND; - } - } break; + case BPS_IDX_BP_MEAS_IND_CFG: { + value = (blps_env->prfl_ntf_ind_cfg[conidx] & BLPS_BP_MEAS_IND_CFG) + ? PRF_CLI_START_IND + : PRF_CLI_STOP_NTFIND; + } break; + case BPS_IDX_INTM_CUFF_PRESS_NTF_CFG: { + // Characteristic is profile specific + if (BLPS_IS_SUPPORTED(BLPS_INTM_CUFF_PRESS_SUP)) { + // Fill data + value = + (blps_env->prfl_ntf_ind_cfg[conidx] & BLPS_INTM_CUFF_PRESS_NTF_CFG) + ? PRF_CLI_START_NTF + : PRF_CLI_STOP_NTFIND; + } else { + status = ATT_ERR_ATTRIBUTE_NOT_FOUND; + } + } break; - default: - { - status = ATT_ERR_REQUEST_NOT_SUPPORTED; - } break; - } - - // Send data to peer device - struct gattc_read_cfm* cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(uint16_t)); - cfm->length = sizeof(uint16_t); - memcpy(cfm->value, &value, sizeof(uint16_t)); - cfm->handle = param->handle; - cfm->status = status; - - // Send value to peer device. - ke_msg_send(cfm); + default: { + status = ATT_ERR_REQUEST_NOT_SUPPORTED; + } break; } - return (KE_MSG_CONSUMED); + // Send data to peer device + struct gattc_read_cfm *cfm = KE_MSG_ALLOC_DYN( + GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(uint16_t)); + cfm->length = sizeof(uint16_t); + memcpy(cfm->value, &value, sizeof(uint16_t)); + cfm->handle = param->handle; + cfm->status = status; + + // Send value to peer device. + ke_msg_send(cfm); + } + + return (KE_MSG_CONSUMED); } /** @@ -163,96 +151,81 @@ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int blps_meas_send_req_handler(ke_msg_id_t const msgid, - struct blps_meas_send_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; - // Status - uint8_t status = GAP_ERR_NO_ERROR; + struct blps_meas_send_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; + // Status + uint8_t status = GAP_ERR_NO_ERROR; - if(gapc_get_conhdl(param->conidx) == GAP_INVALID_CONHDL) - { - status = PRF_ERR_DISCONNECTED; - } - else if(ke_state_get(dest_id) == BLPS_IDLE) - { - // Get the address of the environment - struct blps_env_tag *blps_env = PRF_ENV_GET(BLPS, blps); + if (gapc_get_conhdl(param->conidx) == GAP_INVALID_CONHDL) { + status = PRF_ERR_DISCONNECTED; + } else if (ke_state_get(dest_id) == BLPS_IDLE) { + // Get the address of the environment + struct blps_env_tag *blps_env = PRF_ENV_GET(BLPS, blps); - //Intermediary blood pressure, must be notified if enabled - if (param->flag_interm_cp) - { - // Check if supported - if (BLPS_IS_SUPPORTED(BLPS_INTM_CUFF_PRESS_SUP)) - { - if (!BLPS_IS_ENABLED(BLPS_INTM_CUFF_PRESS_NTF_CFG, param->conidx)) - { - status = PRF_ERR_NTF_DISABLED; - } - } - else - { - status = PRF_ERR_FEATURE_NOT_SUPPORTED; - } + // Intermediary blood pressure, must be notified if enabled + if (param->flag_interm_cp) { + // Check if supported + if (BLPS_IS_SUPPORTED(BLPS_INTM_CUFF_PRESS_SUP)) { + if (!BLPS_IS_ENABLED(BLPS_INTM_CUFF_PRESS_NTF_CFG, param->conidx)) { + status = PRF_ERR_NTF_DISABLED; } - - //Stable Blood Pressure Measurement, must be indicated if enabled - else if(! BLPS_IS_ENABLED(BLPS_BP_MEAS_IND_CFG, param->conidx)) - { - status = PRF_ERR_IND_DISABLED; - } - - // Check if message can be sent - if (status == GAP_ERR_NO_ERROR) - { - // Allocate the GATT notification message - struct gattc_send_evt_cmd *meas_val = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, param->conidx), dest_id, - gattc_send_evt_cmd, BLPS_BP_MEAS_MAX_LEN); - - // Fill event type and handle which trigger event - if (param->flag_interm_cp) - { - meas_val->operation = GATTC_NOTIFY; - meas_val->handle = blps_env->shdl + BPS_IDX_INTM_CUFF_PRESS_VAL; - } - else - { - // Fill in the parameter structure - meas_val->operation = GATTC_INDICATE; - meas_val->handle = blps_env->shdl + BPS_IDX_BP_MEAS_VAL; - } - - //Pack the BP Measurement value - meas_val->length = blps_pack_meas_value(meas_val->value, ¶m->meas_val); - - // Send the event - ke_msg_send(meas_val); - // Go to busy state - ke_state_set(dest_id, BLPS_BUSY); - } - } - else - { - // Save it for later - msg_status = KE_MSG_SAVED; + } else { + status = PRF_ERR_FEATURE_NOT_SUPPORTED; + } } - if(status != GAP_ERR_NO_ERROR) - { - // Send error message to application - blps_meas_send_rsp_send(param->conidx, status); + // Stable Blood Pressure Measurement, must be indicated if enabled + else if (!BLPS_IS_ENABLED(BLPS_BP_MEAS_IND_CFG, param->conidx)) { + status = PRF_ERR_IND_DISABLED; } - return (msg_status); + // Check if message can be sent + if (status == GAP_ERR_NO_ERROR) { + // Allocate the GATT notification message + struct gattc_send_evt_cmd *meas_val = KE_MSG_ALLOC_DYN( + GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, param->conidx), dest_id, + gattc_send_evt_cmd, BLPS_BP_MEAS_MAX_LEN); + + // Fill event type and handle which trigger event + if (param->flag_interm_cp) { + meas_val->operation = GATTC_NOTIFY; + meas_val->handle = blps_env->shdl + BPS_IDX_INTM_CUFF_PRESS_VAL; + } else { + // Fill in the parameter structure + meas_val->operation = GATTC_INDICATE; + meas_val->handle = blps_env->shdl + BPS_IDX_BP_MEAS_VAL; + } + + // Pack the BP Measurement value + meas_val->length = + blps_pack_meas_value(meas_val->value, ¶m->meas_val); + + // Send the event + ke_msg_send(meas_val); + // Go to busy state + ke_state_set(dest_id, BLPS_BUSY); + } + } else { + // Save it for later + msg_status = KE_MSG_SAVED; + } + + if (status != GAP_ERR_NO_ERROR) { + // Send error message to application + blps_meas_send_rsp_send(param->conidx, status); + } + + return (msg_status); } /** **************************************************************************************** * @brief Handles reception of the @ref GL2C_CODE_ATT_WR_CMD_IND message. - * The handler compares the new values with current ones and notifies them if they changed. + * The handler compares the new values with current ones and notifies them if + *they changed. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -260,95 +233,78 @@ __STATIC int blps_meas_send_req_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_write_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct blps_env_tag *blps_env = PRF_ENV_GET(BLPS, blps); - uint8_t conidx = KE_IDX_GET(src_id); +__STATIC int gattc_write_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Get the address of the environment + struct blps_env_tag *blps_env = PRF_ENV_GET(BLPS, blps); + uint8_t conidx = KE_IDX_GET(src_id); - uint16_t value = 0x0000; - uint8_t status = GAP_ERR_NO_ERROR; - uint8_t char_code = 0; + uint16_t value = 0x0000; + uint8_t status = GAP_ERR_NO_ERROR; + uint8_t char_code = 0; - //Extract value before check - memcpy(&value, &(param->value), sizeof(uint16_t)); + // Extract value before check + memcpy(&value, &(param->value), sizeof(uint16_t)); - //BP Measurement Char. - Client Char. Configuration - if (param->handle == (blps_env->shdl + BPS_IDX_BP_MEAS_IND_CFG)) - { - if ((value == PRF_CLI_STOP_NTFIND) || (value == PRF_CLI_START_IND)) - { - char_code = BPS_BP_MEAS_CHAR; + // BP Measurement Char. - Client Char. Configuration + if (param->handle == (blps_env->shdl + BPS_IDX_BP_MEAS_IND_CFG)) { + if ((value == PRF_CLI_STOP_NTFIND) || (value == PRF_CLI_START_IND)) { + char_code = BPS_BP_MEAS_CHAR; - if (value == PRF_CLI_STOP_NTFIND) - { - blps_env->prfl_ntf_ind_cfg[conidx] &= ~BLPS_BP_MEAS_IND_CFG; - } - else //PRF_CLI_START_IND - { - blps_env->prfl_ntf_ind_cfg[conidx] |= BLPS_BP_MEAS_IND_CFG; - } - } - else - { - status = PRF_APP_ERROR; - } + if (value == PRF_CLI_STOP_NTFIND) { + blps_env->prfl_ntf_ind_cfg[conidx] &= ~BLPS_BP_MEAS_IND_CFG; + } else // PRF_CLI_START_IND + { + blps_env->prfl_ntf_ind_cfg[conidx] |= BLPS_BP_MEAS_IND_CFG; + } + } else { + status = PRF_APP_ERROR; } - else if (param->handle == (blps_env->shdl + BPS_IDX_INTM_CUFF_PRESS_NTF_CFG)) - { - if ((value == PRF_CLI_STOP_NTFIND) || (value == PRF_CLI_START_NTF)) - { - char_code = BPS_INTM_CUFF_MEAS_CHAR; + } else if (param->handle == + (blps_env->shdl + BPS_IDX_INTM_CUFF_PRESS_NTF_CFG)) { + if ((value == PRF_CLI_STOP_NTFIND) || (value == PRF_CLI_START_NTF)) { + char_code = BPS_INTM_CUFF_MEAS_CHAR; - if (value == PRF_CLI_STOP_NTFIND) - { - blps_env->prfl_ntf_ind_cfg[conidx] &= ~BLPS_INTM_CUFF_PRESS_NTF_CFG; - } - else //PRF_CLI_START_NTF - { - blps_env->prfl_ntf_ind_cfg[conidx] |= BLPS_INTM_CUFF_PRESS_NTF_CFG; - } - } - else - { - status = PRF_APP_ERROR; - } + if (value == PRF_CLI_STOP_NTFIND) { + blps_env->prfl_ntf_ind_cfg[conidx] &= ~BLPS_INTM_CUFF_PRESS_NTF_CFG; + } else // PRF_CLI_START_NTF + { + blps_env->prfl_ntf_ind_cfg[conidx] |= BLPS_INTM_CUFF_PRESS_NTF_CFG; + } + } else { + status = PRF_APP_ERROR; } + } - if (status == GAP_ERR_NO_ERROR) - { - //Inform APP of configuration change - struct blps_cfg_indntf_ind * ind = KE_MSG_ALLOC( - BLPS_CFG_INDNTF_IND, - prf_dst_task_get(&blps_env->prf_env, conidx), - prf_src_task_get(&blps_env->prf_env, conidx), - blps_cfg_indntf_ind); + if (status == GAP_ERR_NO_ERROR) { + // Inform APP of configuration change + struct blps_cfg_indntf_ind *ind = KE_MSG_ALLOC( + BLPS_CFG_INDNTF_IND, prf_dst_task_get(&blps_env->prf_env, conidx), + prf_src_task_get(&blps_env->prf_env, conidx), blps_cfg_indntf_ind); - ind->conidx = conidx; - ind->char_code = char_code; - memcpy(&ind->cfg_val, &value, sizeof(uint16_t)); + ind->conidx = conidx; + ind->char_code = char_code; + memcpy(&ind->cfg_val, &value, sizeof(uint16_t)); - ke_msg_send(ind); - } + ke_msg_send(ind); + } + // Send write response + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = status; + ke_msg_send(cfm); - //Send write response - struct gattc_write_cfm *cfm = KE_MSG_ALLOC( - GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = status; - ke_msg_send(cfm); - - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** **************************************************************************************** - * @brief Handles @ref GATTC_CMP_EVT for GATTC_NOTIFY and GATT_INDICATE message meaning - * that Measurement notification/indication has been correctly sent to peer device + * @brief Handles @ref GATTC_CMP_EVT for GATTC_NOTIFY and GATT_INDICATE message + *meaning that Measurement notification/indication has been correctly sent to + *peer device * * * @param[in] msgid Id of the message received. @@ -358,27 +314,26 @@ __STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - uint8_t conidx = KE_IDX_GET(src_id); +__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t conidx = KE_IDX_GET(src_id); - switch(param->operation) - { - case GATTC_NOTIFY: - case GATTC_INDICATE: - { - // Send confirmation - blps_meas_send_rsp_send(conidx, param->status); - // Go to idle state - ke_state_set(dest_id, BLPS_IDLE); - } - break; + switch (param->operation) { + case GATTC_NOTIFY: + case GATTC_INDICATE: { + // Send confirmation + blps_meas_send_rsp_send(conidx, param->status); + // Go to idle state + ke_state_set(dest_id, BLPS_IDLE); + } break; - default: break; - } + default: + break; + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /* @@ -387,24 +342,22 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt */ /// Default State handlers definition -KE_MSG_HANDLER_TAB(blps) -{ - {BLPS_ENABLE_REQ, (ke_msg_func_t) blps_enable_req_handler}, - {GATTC_READ_REQ_IND, (ke_msg_func_t) gattc_read_req_ind_handler}, - {BLPS_MEAS_SEND_REQ, (ke_msg_func_t) blps_meas_send_req_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t) gattc_cmp_evt_handler}, - {GATTC_WRITE_REQ_IND, (ke_msg_func_t) gattc_write_req_ind_handler}, +KE_MSG_HANDLER_TAB(blps){ + {BLPS_ENABLE_REQ, (ke_msg_func_t)blps_enable_req_handler}, + {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, + {BLPS_MEAS_SEND_REQ, (ke_msg_func_t)blps_meas_send_req_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, + {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, }; -void blps_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct blps_env_tag *blps_env = PRF_ENV_GET(BLPS, blps); +void blps_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct blps_env_tag *blps_env = PRF_ENV_GET(BLPS, blps); - task_desc->msg_handler_tab = blps_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(blps_msg_handler_tab); - task_desc->state = blps_env->state; - task_desc->idx_max = BLPS_IDX_MAX; + task_desc->msg_handler_tab = blps_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(blps_msg_handler_tab); + task_desc->state = blps_env->state; + task_desc->idx_max = BLPS_IDX_MAX; } #endif /* #if (BLE_BP_SENSOR) */ diff --git a/services/ble_profiles/cpp/cppc/src/cppc.c b/services/ble_profiles/cpp/cppc/src/cppc.c index dd7f3f9..423e919 100644 --- a/services/ble_profiles/cpp/cppc/src/cppc.c +++ b/services/ble_profiles/cpp/cppc/src/cppc.c @@ -17,15 +17,14 @@ #include "cppc_task.h" #include "ke_timer.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * GLOBAL VARIABLES DECLARATION **************************************************************************************** */ - /* * LOCAL FUNCTION DEFINITIONS **************************************************************************************** @@ -43,41 +42,45 @@ * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t cppc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t idx; - //-------------------- allocate memory required for the profile --------------------- +static uint8_t cppc_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t idx; + //-------------------- allocate memory required for the profile + //--------------------- - struct cppc_env_tag* cppc_env = - (struct cppc_env_tag* ) ke_malloc(sizeof(struct cppc_env_tag), KE_MEM_ATT_DB); + struct cppc_env_tag *cppc_env = (struct cppc_env_tag *)ke_malloc( + sizeof(struct cppc_env_tag), KE_MEM_ATT_DB); - // allocate CPPC required environment variable - env->env = (prf_env_t*) cppc_env; + // allocate CPPC required environment variable + env->env = (prf_env_t *)cppc_env; - cppc_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - cppc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + cppc_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + cppc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_CPPC; - cppc_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_CPPC; + cppc_task_init(&(env->desc)); - for(idx = 0; idx < CPPC_IDX_MAX ; idx++) - { - cppc_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), CPPC_FREE); - } + for (idx = 0; idx < CPPC_IDX_MAX; idx++) { + cppc_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), CPPC_FREE); + } - return GAP_ERR_NO_ERROR; + return GAP_ERR_NO_ERROR; } /** @@ -89,49 +92,46 @@ static uint8_t cppc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t * @param[in] reason Detach reason **************************************************************************************** */ -static void cppc_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct cppc_env_tag* cppc_env = (struct cppc_env_tag*) env->env; +static void cppc_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct cppc_env_tag *cppc_env = (struct cppc_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(cppc_env->env[conidx] != NULL) - { - if (cppc_env->env[conidx]->operation != NULL) - { - ke_free(ke_param2msg(cppc_env->env[conidx]->operation)); - } - ke_timer_clear(CPPC_TIMEOUT_TIMER_IND, prf_src_task_get(&cppc_env->prf_env, conidx)); - ke_free(cppc_env->env[conidx]); - cppc_env->env[conidx] = NULL; + // clean-up environment variable allocated for task instance + if (cppc_env->env[conidx] != NULL) { + if (cppc_env->env[conidx]->operation != NULL) { + ke_free(ke_param2msg(cppc_env->env[conidx]->operation)); } + ke_timer_clear(CPPC_TIMEOUT_TIMER_IND, + prf_src_task_get(&cppc_env->prf_env, conidx)); + ke_free(cppc_env->env[conidx]); + cppc_env->env[conidx] = NULL; + } - /* Put CPP Client in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), CPPC_FREE); + /* Put CPP Client in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), CPPC_FREE); } /** **************************************************************************************** * @brief Destruction of the CPPC module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void cppc_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct cppc_env_tag* cppc_env = (struct cppc_env_tag*) env->env; +static void cppc_destroy(struct prf_task_env *env) { + uint8_t idx; + struct cppc_env_tag *cppc_env = (struct cppc_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < CPPC_IDX_MAX ; idx++) - { - cppc_cleanup(env, idx, 0); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < CPPC_IDX_MAX; idx++) { + cppc_cleanup(env, idx, 0); + } - // free profile environment variables - env->env = NULL; - ke_free(cppc_env); + // free profile environment variables + env->env = NULL; + ke_free(cppc_env); } /** @@ -142,19 +142,17 @@ static void cppc_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void cppc_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Put CPP Client in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), CPPC_IDLE); +static void cppc_create(struct prf_task_env *env, uint8_t conidx) { + /* Put CPP Client in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), CPPC_IDLE); } /// CPPC Task interface required by profile manager -const struct prf_task_cbs cppc_itf = -{ - cppc_init, - cppc_destroy, - cppc_create, - cppc_cleanup, +const struct prf_task_cbs cppc_itf = { + cppc_init, + cppc_destroy, + cppc_create, + cppc_cleanup, }; /* @@ -162,73 +160,63 @@ const struct prf_task_cbs cppc_itf = **************************************************************************************** */ -const struct prf_task_cbs* cppc_prf_itf_get(void) -{ - return &cppc_itf; +const struct prf_task_cbs *cppc_prf_itf_get(void) { return &cppc_itf; } + +void cppc_enable_rsp_send(struct cppc_env_tag *cppc_env, uint8_t conidx, + uint8_t status) { + // Send to APP the details of the discovered attributes on CPPS + struct cppc_enable_rsp *rsp = KE_MSG_ALLOC( + CPPC_ENABLE_RSP, prf_dst_task_get(&(cppc_env->prf_env), conidx), + prf_src_task_get(&(cppc_env->prf_env), conidx), cppc_enable_rsp); + rsp->status = status; + + if (status == GAP_ERR_NO_ERROR) { + rsp->cps = cppc_env->env[conidx]->cps; + // Register CPPC task in gatt for indication/notifications + prf_register_atthdl2gatt(&(cppc_env->prf_env), conidx, + &(cppc_env->env[conidx]->cps.svc)); + // Go to connected state + ke_state_set(prf_src_task_get(&(cppc_env->prf_env), conidx), CPPC_IDLE); + } + + ke_msg_send(rsp); } +void cppc_send_no_conn_cmp_evt(uint8_t src_id, uint8_t dest_id, + uint8_t operation) { + // Send the message + struct cppc_cmp_evt *evt = + KE_MSG_ALLOC(CPPC_CMP_EVT, dest_id, src_id, cppc_cmp_evt); -void cppc_enable_rsp_send(struct cppc_env_tag *cppc_env, uint8_t conidx, uint8_t status) -{ - // Send to APP the details of the discovered attributes on CPPS - struct cppc_enable_rsp * rsp = KE_MSG_ALLOC( - CPPC_ENABLE_RSP, - prf_dst_task_get(&(cppc_env->prf_env), conidx), - prf_src_task_get(&(cppc_env->prf_env), conidx), - cppc_enable_rsp); - rsp->status = status; + evt->operation = operation; + evt->status = PRF_ERR_REQ_DISALLOWED; - if (status == GAP_ERR_NO_ERROR) - { - rsp->cps = cppc_env->env[conidx]->cps; - // Register CPPC task in gatt for indication/notifications - prf_register_atthdl2gatt(&(cppc_env->prf_env), conidx, &(cppc_env->env[conidx]->cps.svc)); - // Go to connected state - ke_state_set(prf_src_task_get(&(cppc_env->prf_env), conidx), CPPC_IDLE); - } - - ke_msg_send(rsp); + ke_msg_send(evt); } +void cppc_send_cmp_evt(struct cppc_env_tag *cppc_env, uint8_t conidx, + uint8_t operation, uint8_t status) { + // Free the stored operation if needed + if (cppc_env->env[conidx]->operation != NULL) { + ke_msg_free(ke_param2msg(cppc_env->env[conidx]->operation)); + cppc_env->env[conidx]->operation = NULL; + } -void cppc_send_no_conn_cmp_evt(uint8_t src_id, uint8_t dest_id, uint8_t operation) -{ - // Send the message - struct cppc_cmp_evt *evt = KE_MSG_ALLOC(CPPC_CMP_EVT, - dest_id, src_id, - cppc_cmp_evt); + // Go back to the IDLE state if the state is busy + if (ke_state_get(prf_src_task_get(&(cppc_env->prf_env), conidx)) == + CPPC_BUSY) { + ke_state_set(prf_src_task_get(&cppc_env->prf_env, conidx), CPPC_IDLE); + } - evt->operation = operation; - evt->status = PRF_ERR_REQ_DISALLOWED; + // Send the message + struct cppc_cmp_evt *evt = KE_MSG_ALLOC( + CPPC_CMP_EVT, prf_dst_task_get(&(cppc_env->prf_env), conidx), + prf_src_task_get(&(cppc_env->prf_env), conidx), cppc_cmp_evt); - ke_msg_send(evt); -} + evt->operation = operation; + evt->status = status; -void cppc_send_cmp_evt(struct cppc_env_tag *cppc_env, uint8_t conidx, uint8_t operation, uint8_t status) -{ - // Free the stored operation if needed - if (cppc_env->env[conidx]->operation != NULL) - { - ke_msg_free(ke_param2msg(cppc_env->env[conidx]->operation)); - cppc_env->env[conidx]->operation = NULL; - } - - // Go back to the IDLE state if the state is busy - if (ke_state_get(prf_src_task_get(&(cppc_env->prf_env), conidx)) == CPPC_BUSY) - { - ke_state_set(prf_src_task_get(&cppc_env->prf_env, conidx), CPPC_IDLE); - } - - // Send the message - struct cppc_cmp_evt *evt = KE_MSG_ALLOC(CPPC_CMP_EVT, - prf_dst_task_get(&(cppc_env->prf_env), conidx), - prf_src_task_get(&(cppc_env->prf_env), conidx), - cppc_cmp_evt); - - evt->operation = operation; - evt->status = status; - - ke_msg_send(evt); + ke_msg_send(evt); } /* @@ -236,515 +224,460 @@ void cppc_send_cmp_evt(struct cppc_env_tag *cppc_env, uint8_t conidx, uint8_t op **************************************************************************************** */ -uint16_t cppc_get_read_handle_req (struct cppc_env_tag *cppc_env, uint8_t conidx, struct cpps_read_cmd *param) -{ - // Attribute Handle - uint16_t handle = ATT_INVALID_SEARCH_HANDLE; +uint16_t cppc_get_read_handle_req(struct cppc_env_tag *cppc_env, uint8_t conidx, + struct cpps_read_cmd *param) { + // Attribute Handle + uint16_t handle = ATT_INVALID_SEARCH_HANDLE; - switch (param->read_code) - { - // Read CP Feature - case (CPPC_RD_CP_FEAT): - { - handle = cppc_env->env[conidx]->cps.chars[CPP_CPS_FEAT_CHAR].val_hdl; - } break; + switch (param->read_code) { + // Read CP Feature + case (CPPC_RD_CP_FEAT): { + handle = cppc_env->env[conidx]->cps.chars[CPP_CPS_FEAT_CHAR].val_hdl; + } break; - // Read Sensor Location - case (CPPC_RD_SENSOR_LOC): - { - handle = cppc_env->env[conidx]->cps.chars[CPP_CPS_SENSOR_LOC_CHAR].val_hdl; - } break; + // Read Sensor Location + case (CPPC_RD_SENSOR_LOC): { + handle = cppc_env->env[conidx]->cps.chars[CPP_CPS_SENSOR_LOC_CHAR].val_hdl; + } break; - // Read CP Measurement Characteristic Client Char. Cfg. Descriptor Value - case (CPPC_RD_WR_CP_MEAS_CL_CFG): - { - handle = cppc_env->env[conidx]->cps.descs[CPPC_DESC_CP_MEAS_CL_CFG].desc_hdl; - } break; + // Read CP Measurement Characteristic Client Char. Cfg. Descriptor Value + case (CPPC_RD_WR_CP_MEAS_CL_CFG): { + handle = + cppc_env->env[conidx]->cps.descs[CPPC_DESC_CP_MEAS_CL_CFG].desc_hdl; + } break; - // Read CP Measurement Characteristic Server Char. Cfg. Descriptor Value - case (CPPC_RD_WR_CP_MEAS_SV_CFG): - { - handle = cppc_env->env[conidx]->cps.descs[CPPC_DESC_CP_MEAS_SV_CFG].desc_hdl; - } break; + // Read CP Measurement Characteristic Server Char. Cfg. Descriptor Value + case (CPPC_RD_WR_CP_MEAS_SV_CFG): { + handle = + cppc_env->env[conidx]->cps.descs[CPPC_DESC_CP_MEAS_SV_CFG].desc_hdl; + } break; - // Read CP Vector Characteristic Server Char. Cfg. Descriptor Value - case (CPPC_RD_WR_VECTOR_CFG): - { - handle = cppc_env->env[conidx]->cps.descs[CPPC_DESC_VECTOR_CL_CFG].desc_hdl; - } break; + // Read CP Vector Characteristic Server Char. Cfg. Descriptor Value + case (CPPC_RD_WR_VECTOR_CFG): { + handle = cppc_env->env[conidx]->cps.descs[CPPC_DESC_VECTOR_CL_CFG].desc_hdl; + } break; - // Read Unread Alert Characteristic Client Char. Cfg. Descriptor Value - case (CPPC_RD_WR_CTNL_PT_CFG): - { - handle = cppc_env->env[conidx]->cps.descs[CPPC_DESC_CTNL_PT_CL_CFG].desc_hdl; - } break; + // Read Unread Alert Characteristic Client Char. Cfg. Descriptor Value + case (CPPC_RD_WR_CTNL_PT_CFG): { + handle = + cppc_env->env[conidx]->cps.descs[CPPC_DESC_CTNL_PT_CL_CFG].desc_hdl; + } break; - default: - { - handle = ATT_INVALID_SEARCH_HANDLE; - } break; - } + default: { + handle = ATT_INVALID_SEARCH_HANDLE; + } break; + } - return handle; + return handle; } -uint8_t cppc_get_write_desc_handle_req (uint8_t conidx, struct cppc_cfg_ntfind_cmd *param, struct cppc_env_tag *cppc_env, uint16_t *handle) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; +uint8_t cppc_get_write_desc_handle_req(uint8_t conidx, + struct cppc_cfg_ntfind_cmd *param, + struct cppc_env_tag *cppc_env, + uint16_t *handle) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; - switch(param->desc_code) - { - // Write CP Measurement Characteristic Client Char. Cfg. Descriptor Value - case (CPPC_RD_WR_CP_MEAS_CL_CFG): - { - if (param->ntfind_cfg <= PRF_CLI_START_NTF) - { - *handle = cppc_env->env[conidx]->cps.descs[CPPC_DESC_CP_MEAS_CL_CFG].desc_hdl; + switch (param->desc_code) { + // Write CP Measurement Characteristic Client Char. Cfg. Descriptor Value + case (CPPC_RD_WR_CP_MEAS_CL_CFG): { + if (param->ntfind_cfg <= PRF_CLI_START_NTF) { + *handle = + cppc_env->env[conidx]->cps.descs[CPPC_DESC_CP_MEAS_CL_CFG].desc_hdl; - // The descriptor is mandatory - ASSERT_ERR(*handle != ATT_INVALID_SEARCH_HANDLE); - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } break; - - // Write CP Measurement Characteristic Server Char. Cfg. Descriptor Value - case (CPPC_RD_WR_CP_MEAS_SV_CFG): - { - if (param->ntfind_cfg <= PRF_SRV_START_BCST) - { - *handle = cppc_env->env[conidx]->cps.descs[CPPC_DESC_CP_MEAS_SV_CFG].desc_hdl; - - if (*handle == ATT_INVALID_SEARCH_HANDLE) - { - // The descriptor has not been found. - status = PRF_ERR_INEXISTENT_HDL; - } - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } - break; - - // Write CP Vector Characteristic Client Char. Cfg. Descriptor Value - case (CPPC_RD_WR_VECTOR_CFG): - { - if (param->ntfind_cfg <= PRF_CLI_START_NTF) - { - *handle = cppc_env->env[conidx]->cps.descs[CPPC_DESC_VECTOR_CL_CFG].desc_hdl; - - if (*handle == ATT_INVALID_SEARCH_HANDLE) - { - // The descriptor has not been found. - status = PRF_ERR_INEXISTENT_HDL; - } - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } - break; - - // Write SC Control Point Characteristic Client Char. Cfg. Descriptor Value - case (CPPC_RD_WR_CTNL_PT_CFG): - { - if ((param->ntfind_cfg == PRF_CLI_STOP_NTFIND) || - (param->ntfind_cfg == PRF_CLI_START_IND)) - { - *handle = cppc_env->env[conidx]->cps.descs[CPPC_DESC_CTNL_PT_CL_CFG].desc_hdl; - - if (*handle == ATT_INVALID_SEARCH_HANDLE) - { - // The descriptor has not been found. - status = PRF_ERR_INEXISTENT_HDL; - } - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } break; - - default: - { - status = PRF_ERR_INVALID_PARAM; - } break; + // The descriptor is mandatory + ASSERT_ERR(*handle != ATT_INVALID_SEARCH_HANDLE); + } else { + status = PRF_ERR_INVALID_PARAM; } + } break; - return (status); + // Write CP Measurement Characteristic Server Char. Cfg. Descriptor Value + case (CPPC_RD_WR_CP_MEAS_SV_CFG): { + if (param->ntfind_cfg <= PRF_SRV_START_BCST) { + *handle = + cppc_env->env[conidx]->cps.descs[CPPC_DESC_CP_MEAS_SV_CFG].desc_hdl; + + if (*handle == ATT_INVALID_SEARCH_HANDLE) { + // The descriptor has not been found. + status = PRF_ERR_INEXISTENT_HDL; + } + } else { + status = PRF_ERR_INVALID_PARAM; + } + } break; + + // Write CP Vector Characteristic Client Char. Cfg. Descriptor Value + case (CPPC_RD_WR_VECTOR_CFG): { + if (param->ntfind_cfg <= PRF_CLI_START_NTF) { + *handle = + cppc_env->env[conidx]->cps.descs[CPPC_DESC_VECTOR_CL_CFG].desc_hdl; + + if (*handle == ATT_INVALID_SEARCH_HANDLE) { + // The descriptor has not been found. + status = PRF_ERR_INEXISTENT_HDL; + } + } else { + status = PRF_ERR_INVALID_PARAM; + } + } break; + + // Write SC Control Point Characteristic Client Char. Cfg. Descriptor Value + case (CPPC_RD_WR_CTNL_PT_CFG): { + if ((param->ntfind_cfg == PRF_CLI_STOP_NTFIND) || + (param->ntfind_cfg == PRF_CLI_START_IND)) { + *handle = + cppc_env->env[conidx]->cps.descs[CPPC_DESC_CTNL_PT_CL_CFG].desc_hdl; + + if (*handle == ATT_INVALID_SEARCH_HANDLE) { + // The descriptor has not been found. + status = PRF_ERR_INEXISTENT_HDL; + } + } else { + status = PRF_ERR_INVALID_PARAM; + } + } break; + + default: { + status = PRF_ERR_INVALID_PARAM; + } break; + } + + return (status); } -uint8_t cppc_unpack_meas_ind (uint8_t conidx, struct gattc_event_ind const *param, struct cppc_env_tag *cppc_env) -{ - // CP Measurement value has been received - struct cppc_value_meas_ind *ind = KE_MSG_ALLOC( - CPPC_VALUE_IND, - prf_dst_task_get(&(cppc_env->prf_env), conidx), - prf_src_task_get(&(cppc_env->prf_env), conidx), - cppc_value_meas_ind); +uint8_t cppc_unpack_meas_ind(uint8_t conidx, + struct gattc_event_ind const *param, + struct cppc_env_tag *cppc_env) { + // CP Measurement value has been received + struct cppc_value_meas_ind *ind = KE_MSG_ALLOC( + CPPC_VALUE_IND, prf_dst_task_get(&(cppc_env->prf_env), conidx), + prf_src_task_get(&(cppc_env->prf_env), conidx), cppc_value_meas_ind); - // Offset - uint8_t offset = CPP_CP_MEAS_NTF_MIN_LEN; + // Offset + uint8_t offset = CPP_CP_MEAS_NTF_MIN_LEN; - // Attribute code - ind->att_code = CPPC_NTF_CP_MEAS; + // Attribute code + ind->att_code = CPPC_NTF_CP_MEAS; - // Flags - ind->value.cp_meas.flags = co_read16p(¶m->value[0]); - // Instant power - ind->value.cp_meas.inst_power = co_read16p(¶m->value[2]); + // Flags + ind->value.cp_meas.flags = co_read16p(¶m->value[0]); + // Instant power + ind->value.cp_meas.inst_power = co_read16p(¶m->value[2]); - if (ind->value.cp_meas.flags & CPP_MEAS_PEDAL_POWER_BALANCE_PRESENT) - { - //Unpack Pedal Power Balance info - ind->value.cp_meas.pedal_power_balance = param->value[offset]; + if (ind->value.cp_meas.flags & CPP_MEAS_PEDAL_POWER_BALANCE_PRESENT) { + // Unpack Pedal Power Balance info + ind->value.cp_meas.pedal_power_balance = param->value[offset]; + offset++; + } + + if (ind->value.cp_meas.flags & CPP_MEAS_ACCUM_TORQUE_PRESENT) { + // Unpack Accumulated Torque info + ind->value.cp_meas.accum_torque = co_read16p(¶m->value[offset]); + offset += 2; + } + + if (ind->value.cp_meas.flags & CPP_MEAS_WHEEL_REV_DATA_PRESENT) { + // Unpack Wheel Revolution Data (Cumulative Wheel & Last Wheel Event Time) + ind->value.cp_meas.cumul_wheel_rev = co_read32p(¶m->value[offset]); + offset += 4; + ind->value.cp_meas.last_wheel_evt_time = co_read16p(¶m->value[offset]); + offset += 2; + } + + if (ind->value.cp_meas.flags & CPP_MEAS_CRANK_REV_DATA_PRESENT) { + // Unpack Crank Revolution Data (Cumulative Crank & Last Crank Event Time) + ind->value.cp_meas.cumul_crank_rev = co_read16p(¶m->value[offset]); + offset += 2; + ind->value.cp_meas.last_crank_evt_time = co_read16p(¶m->value[offset]); + offset += 2; + } + + if (ind->value.cp_meas.flags & CPP_MEAS_EXTREME_FORCE_MAGNITUDES_PRESENT) { + // Unpack Extreme Force Magnitudes (Maximum Force Magnitude & Minimum Force + // Magnitude) + ind->value.cp_meas.max_force_magnitude = co_read16p(¶m->value[offset]); + offset += 2; + ind->value.cp_meas.min_force_magnitude = co_read16p(¶m->value[offset]); + offset += 2; + } + + else if (ind->value.cp_meas.flags & + CPP_MEAS_EXTREME_TORQUE_MAGNITUDES_PRESENT) { + // Unpack Extreme Force Magnitudes (Maximum Force Magnitude & Minimum Force + // Magnitude) + ind->value.cp_meas.max_torque_magnitude = co_read16p(¶m->value[offset]); + offset += 2; + ind->value.cp_meas.min_torque_magnitude = co_read16p(¶m->value[offset]); + offset += 2; + } + + if (ind->value.cp_meas.flags & CPP_MEAS_EXTREME_ANGLES_PRESENT) { + // Unpack Extreme Angles (Maximum Angle & Minimum Angle) + uint32_t angle = co_read24p(¶m->value[offset]); + offset += 3; + + // Force to 12 bits + ind->value.cp_meas.max_angle = (angle & (0x0FFF)); + ind->value.cp_meas.min_angle = ((angle >> 12) & 0x0FFF); + } + + if (ind->value.cp_meas.flags & CPP_MEAS_TOP_DEAD_SPOT_ANGLE_PRESENT) { + // Unpack Top Dead Spot Angle + ind->value.cp_meas.top_dead_spot_angle = co_read16p(¶m->value[offset]); + offset += 2; + } + + if (ind->value.cp_meas.flags & CPP_MEAS_BOTTOM_DEAD_SPOT_ANGLE_PRESENT) { + // Unpack Bottom Dead Spot Angle + ind->value.cp_meas.bot_dead_spot_angle = co_read16p(¶m->value[offset]); + offset += 2; + } + + if (ind->value.cp_meas.flags & CPP_MEAS_ACCUM_ENERGY_PRESENT) { + // Unpack Accumulated Energy + ind->value.cp_meas.accum_energy = co_read16p(¶m->value[offset]); + offset += 2; + } + + // Send the message + ke_msg_send(ind); + + return offset; +} + +uint8_t cppc_unpack_vector_ind(uint8_t conidx, + struct gattc_event_ind const *param, + struct cppc_env_tag *cppc_env) { + // CP Measurement value has been received + struct cppc_value_ind *ind = KE_MSG_ALLOC_DYN( + CPPC_VALUE_IND, prf_dst_task_get(&cppc_env->prf_env, conidx), + prf_src_task_get(&cppc_env->prf_env, conidx), cppc_value_ind, + param->length); + + // Offset + uint8_t offset = CPP_CP_VECTOR_MIN_LEN; + + // Attribute code + ind->att_code = CPPC_NTF_CP_VECTOR; + + // Flags + ind->value.cp_vector.flags = param->value[0]; + + if (ind->value.cp_vector.flags & CPP_VECTOR_CRANK_REV_DATA_PRESENT) { + // Unpack Crank Revolution Data + ind->value.cp_vector.cumul_crank_rev = co_read16p(¶m->value[offset]); + offset += 2; + // Unpack Last Crank Evt time + ind->value.cp_vector.last_crank_evt_time = + co_read16p(¶m->value[offset]); + offset += 2; + } + + if (ind->value.cp_vector.flags & CPP_VECTOR_FIRST_CRANK_MEAS_ANGLE_PRESENT) { + // Unpack First Crank Measurement Angle + ind->value.cp_vector.first_crank_meas_angle = + co_read16p(¶m->value[offset]); + offset += 2; + } + + if (!(ind->value.cp_vector.flags & + CPP_VECTOR_INST_FORCE_MAGNITUDE_ARRAY_PRESENT) != + !(ind->value.cp_vector.flags & + CPP_VECTOR_INST_TORQUE_MAGNITUDE_ARRAY_PRESENT)) { + // Unpack Force or Torque magnitude (mutually excluded) + ind->value.cp_vector.nb = (param->length - offset) / 2; + if (ind->value.cp_vector.nb) { + for (int i = 0; i < ind->value.cp_vector.nb; i++) { + // Handle the array buffer to extract parameters + ind->value.cp_vector.force_torque_magnitude[i] = + co_read16p(¶m->value[offset]); + offset += 2; + } + } + } + + // if ((ind->value.cp_vector.flags & CPP_VECTOR_INST_MEAS_DIRECTION_LSB) || + // (ind->value.cp_vector.flags & + // CPP_VECTOR_INST_MEAS_DIRECTION_MSB)) + // { + // + // } + + // Send the message + ke_msg_send(ind); + + return offset; +} + +uint8_t cppc_pack_ctnl_pt_req(struct cppc_ctnl_pt_cfg_req *param, uint8_t *req, + uint8_t *status) { + // Request Length + uint8_t req_len = CPP_CP_CNTL_PT_REQ_MIN_LEN; + + // Set the operation code + req[0] = param->ctnl_pt.op_code; + + // Fulfill the message according to the operation code + switch (param->ctnl_pt.op_code) { + case (CPP_CTNL_PT_SET_CUMUL_VAL): { + // Set the cumulative value + co_write32p(&req[req_len], param->ctnl_pt.value.cumul_val); + // Update length + req_len += 4; + } break; + + case (CPP_CTNL_PT_UPD_SENSOR_LOC): { + // Set the sensor location + req[req_len] = param->ctnl_pt.value.sensor_loc; + // Update length + req_len++; + } break; + + case (CPP_CTNL_PT_SET_CRANK_LENGTH): { + // Set the crank length + co_write16p(&req[req_len], param->ctnl_pt.value.crank_length); + // Update length + req_len += 2; + } break; + + case (CPP_CTNL_PT_SET_CHAIN_LENGTH): { + // Set the chain length + co_write16p(&req[req_len], param->ctnl_pt.value.chain_length); + // Update length + req_len += 2; + } break; + + case (CPP_CTNL_PT_SET_CHAIN_WEIGHT): { + // Set the chain weight + co_write16p(&req[req_len], param->ctnl_pt.value.chain_weight); + // Update length + req_len += 2; + } break; + + case (CPP_CTNL_PT_SET_SPAN_LENGTH): { + // Set the span length + co_write16p(&req[req_len], param->ctnl_pt.value.span_length); + // Update length + req_len += 2; + } break; + + case (CPP_CTNL_MASK_CP_MEAS_CH_CONTENT): { + // Set the Content Mask + co_write16p(&req[req_len], param->ctnl_pt.value.mask_content); + // Update length + req_len += 2; + } break; + + case (CPP_CTNL_PT_REQ_SUPP_SENSOR_LOC): + case (CPP_CTNL_PT_REQ_CRANK_LENGTH): + case (CPP_CTNL_PT_REQ_CHAIN_LENGTH): + case (CPP_CTNL_PT_REQ_CHAIN_WEIGHT): + case (CPP_CTNL_PT_REQ_SPAN_LENGTH): + case (CPP_CTNL_PT_START_OFFSET_COMP): + case (CPP_CTNL_REQ_SAMPLING_RATE): + case (CPP_CTNL_REQ_FACTORY_CALIBRATION_DATE): { + // Nothing more to do + } break; + + default: { + *status = PRF_ERR_INVALID_PARAM; + } break; + } + + return req_len; +} + +uint8_t cppc_unpack_ctln_pt_ind(uint8_t conidx, + struct gattc_event_ind const *param, + struct cppc_env_tag *cppc_env) { + // Offset + uint8_t offset = CPP_CP_CNTL_PT_RSP_MIN_LEN; + + // Control Point value has been received + struct cppc_ctnl_pt_rsp *ind = KE_MSG_ALLOC( + CPPC_CTNL_PT_RSP, prf_dst_task_get(&cppc_env->prf_env, conidx), + prf_src_task_get(&cppc_env->prf_env, conidx), cppc_ctnl_pt_rsp); + + // Requested operation code + ind->rsp.req_op_code = param->value[1]; + // Response value + ind->rsp.resp_value = param->value[2]; + + if ((ind->rsp.resp_value == CPP_CTNL_PT_RESP_SUCCESS) && + (param->length >= 3)) { + switch (ind->rsp.req_op_code) { + case (CPP_CTNL_PT_REQ_SUPP_SENSOR_LOC): { + // Get the number of supported locations that have been received + uint8_t nb_supp_loc = (param->length - 3); + // Location + uint8_t loc; + + for (uint8_t counter = 0; counter < nb_supp_loc; counter++) { + loc = param->value[counter + CPP_CP_CNTL_PT_RSP_MIN_LEN]; + // Check if valid + if (loc < CPP_LOC_MAX) { + ind->rsp.value.supp_loc |= (1 << loc); + } offset++; + } + } break; + + case (CPP_CTNL_PT_REQ_CRANK_LENGTH): { + ind->rsp.value.crank_length = co_read16p(¶m->value[offset]); + offset += 2; + } break; + + case (CPP_CTNL_PT_REQ_CHAIN_LENGTH): { + ind->rsp.value.chain_length = co_read16p(¶m->value[offset]); + offset += 2; + } break; + + case (CPP_CTNL_PT_REQ_CHAIN_WEIGHT): { + ind->rsp.value.chain_weight = co_read16p(¶m->value[offset]); + offset += 2; + } break; + + case (CPP_CTNL_PT_REQ_SPAN_LENGTH): { + ind->rsp.value.span_length = co_read16p(¶m->value[offset]); + offset += 2; + } break; + + case (CPP_CTNL_PT_START_OFFSET_COMP): { + ind->rsp.value.offset_comp = co_read16p(¶m->value[offset]); + offset += 2; + } break; + + case (CPP_CTNL_REQ_SAMPLING_RATE): { + ind->rsp.value.sampling_rate = param->value[offset]; + offset++; + } break; + + case (CPP_CTNL_REQ_FACTORY_CALIBRATION_DATE): { + offset += prf_unpack_date_time((uint8_t *)&(param->value[offset]), + &(ind->rsp.value.factory_calibration)); + } break; + + case (CPP_CTNL_PT_SET_CUMUL_VAL): + case (CPP_CTNL_PT_UPD_SENSOR_LOC): + case (CPP_CTNL_PT_SET_CRANK_LENGTH): + case (CPP_CTNL_PT_SET_CHAIN_LENGTH): + case (CPP_CTNL_PT_SET_CHAIN_WEIGHT): + case (CPP_CTNL_PT_SET_SPAN_LENGTH): + case (CPP_CTNL_MASK_CP_MEAS_CH_CONTENT): { + // No parameters + } break; + + default: { + + } break; } + } - if (ind->value.cp_meas.flags & CPP_MEAS_ACCUM_TORQUE_PRESENT) - { - //Unpack Accumulated Torque info - ind->value.cp_meas.accum_torque = co_read16p(¶m->value[offset]); - offset += 2; - } + // Send the message + ke_msg_send(ind); - if (ind->value.cp_meas.flags & CPP_MEAS_WHEEL_REV_DATA_PRESENT) - { - //Unpack Wheel Revolution Data (Cumulative Wheel & Last Wheel Event Time) - ind->value.cp_meas.cumul_wheel_rev = co_read32p(¶m->value[offset]); - offset += 4; - ind->value.cp_meas.last_wheel_evt_time = co_read16p(¶m->value[offset]); - offset += 2; - } - - if (ind->value.cp_meas.flags & CPP_MEAS_CRANK_REV_DATA_PRESENT) - { - //Unpack Crank Revolution Data (Cumulative Crank & Last Crank Event Time) - ind->value.cp_meas.cumul_crank_rev = co_read16p(¶m->value[offset]); - offset += 2; - ind->value.cp_meas.last_crank_evt_time = co_read16p(¶m->value[offset]); - offset += 2; - } - - if (ind->value.cp_meas.flags & CPP_MEAS_EXTREME_FORCE_MAGNITUDES_PRESENT) - { - //Unpack Extreme Force Magnitudes (Maximum Force Magnitude & Minimum Force Magnitude) - ind->value.cp_meas.max_force_magnitude = co_read16p(¶m->value[offset]); - offset += 2; - ind->value.cp_meas.min_force_magnitude = co_read16p(¶m->value[offset]); - offset += 2; - } - - else if (ind->value.cp_meas.flags & CPP_MEAS_EXTREME_TORQUE_MAGNITUDES_PRESENT) - { - //Unpack Extreme Force Magnitudes (Maximum Force Magnitude & Minimum Force Magnitude) - ind->value.cp_meas.max_torque_magnitude = co_read16p(¶m->value[offset]); - offset += 2; - ind->value.cp_meas.min_torque_magnitude = co_read16p(¶m->value[offset]); - offset += 2; - } - - if (ind->value.cp_meas.flags & CPP_MEAS_EXTREME_ANGLES_PRESENT) - { - //Unpack Extreme Angles (Maximum Angle & Minimum Angle) - uint32_t angle = co_read24p(¶m->value[offset]); - offset += 3; - - //Force to 12 bits - ind->value.cp_meas.max_angle = (angle & (0x0FFF)); - ind->value.cp_meas.min_angle = ((angle>>12) & 0x0FFF); - } - - if (ind->value.cp_meas.flags & CPP_MEAS_TOP_DEAD_SPOT_ANGLE_PRESENT) - { - //Unpack Top Dead Spot Angle - ind->value.cp_meas.top_dead_spot_angle = co_read16p(¶m->value[offset]); - offset += 2; - } - - if (ind->value.cp_meas.flags & CPP_MEAS_BOTTOM_DEAD_SPOT_ANGLE_PRESENT) - { - //Unpack Bottom Dead Spot Angle - ind->value.cp_meas.bot_dead_spot_angle = co_read16p(¶m->value[offset]); - offset += 2; - } - - if (ind->value.cp_meas.flags & CPP_MEAS_ACCUM_ENERGY_PRESENT) - { - //Unpack Accumulated Energy - ind->value.cp_meas.accum_energy = co_read16p(¶m->value[offset]); - offset += 2; - } - - // Send the message - ke_msg_send(ind); - - return offset; -} - -uint8_t cppc_unpack_vector_ind (uint8_t conidx, struct gattc_event_ind const *param, struct cppc_env_tag *cppc_env) -{ - // CP Measurement value has been received - struct cppc_value_ind *ind = KE_MSG_ALLOC_DYN( - CPPC_VALUE_IND, - prf_dst_task_get(&cppc_env->prf_env, conidx), - prf_src_task_get(&cppc_env->prf_env, conidx), - cppc_value_ind, - param->length); - - // Offset - uint8_t offset = CPP_CP_VECTOR_MIN_LEN; - - // Attribute code - ind->att_code = CPPC_NTF_CP_VECTOR; - - // Flags - ind->value.cp_vector.flags = param->value[0]; - - if (ind->value.cp_vector.flags & CPP_VECTOR_CRANK_REV_DATA_PRESENT) - { - // Unpack Crank Revolution Data - ind->value.cp_vector.cumul_crank_rev = co_read16p(¶m->value[offset]); - offset += 2; - // Unpack Last Crank Evt time - ind->value.cp_vector.last_crank_evt_time = co_read16p(¶m->value[offset]); - offset += 2; - } - - if (ind->value.cp_vector.flags & CPP_VECTOR_FIRST_CRANK_MEAS_ANGLE_PRESENT) - { - // Unpack First Crank Measurement Angle - ind->value.cp_vector.first_crank_meas_angle = co_read16p(¶m->value[offset]); - offset += 2; - } - - if (!(ind->value.cp_vector.flags & CPP_VECTOR_INST_FORCE_MAGNITUDE_ARRAY_PRESENT) != - !(ind->value.cp_vector.flags & CPP_VECTOR_INST_TORQUE_MAGNITUDE_ARRAY_PRESENT)) - { - // Unpack Force or Torque magnitude (mutually excluded) - ind->value.cp_vector.nb = (param->length - offset)/2; - if (ind->value.cp_vector.nb) - { - for (int i = 0; i < ind->value.cp_vector.nb; i++) - { - // Handle the array buffer to extract parameters - ind->value.cp_vector.force_torque_magnitude[i] = co_read16p(¶m->value[offset]); - offset += 2; - } - } - } - -// if ((ind->value.cp_vector.flags & CPP_VECTOR_INST_MEAS_DIRECTION_LSB) || -// (ind->value.cp_vector.flags & CPP_VECTOR_INST_MEAS_DIRECTION_MSB)) -// { -// -// } - - // Send the message - ke_msg_send(ind); - - return offset; - -} - -uint8_t cppc_pack_ctnl_pt_req (struct cppc_ctnl_pt_cfg_req *param, uint8_t *req, uint8_t *status) -{ - // Request Length - uint8_t req_len = CPP_CP_CNTL_PT_REQ_MIN_LEN; - - // Set the operation code - req[0] = param->ctnl_pt.op_code; - - // Fulfill the message according to the operation code - switch (param->ctnl_pt.op_code) - { - case (CPP_CTNL_PT_SET_CUMUL_VAL): - { - // Set the cumulative value - co_write32p(&req[req_len], param->ctnl_pt.value.cumul_val); - // Update length - req_len += 4; - } break; - - case (CPP_CTNL_PT_UPD_SENSOR_LOC): - { - // Set the sensor location - req[req_len] = param->ctnl_pt.value.sensor_loc; - // Update length - req_len++; - } break; - - case (CPP_CTNL_PT_SET_CRANK_LENGTH): - { - // Set the crank length - co_write16p(&req[req_len], param->ctnl_pt.value.crank_length); - // Update length - req_len += 2; - } break; - - case (CPP_CTNL_PT_SET_CHAIN_LENGTH): - { - // Set the chain length - co_write16p(&req[req_len], param->ctnl_pt.value.chain_length); - // Update length - req_len += 2; - } break; - - case (CPP_CTNL_PT_SET_CHAIN_WEIGHT): - { - // Set the chain weight - co_write16p(&req[req_len], param->ctnl_pt.value.chain_weight); - // Update length - req_len += 2; - } break; - - case (CPP_CTNL_PT_SET_SPAN_LENGTH): - { - // Set the span length - co_write16p(&req[req_len], param->ctnl_pt.value.span_length); - // Update length - req_len += 2; - } break; - - case (CPP_CTNL_MASK_CP_MEAS_CH_CONTENT): - { - // Set the Content Mask - co_write16p(&req[req_len], param->ctnl_pt.value.mask_content); - // Update length - req_len += 2; - } break; - - case (CPP_CTNL_PT_REQ_SUPP_SENSOR_LOC): - case (CPP_CTNL_PT_REQ_CRANK_LENGTH): - case (CPP_CTNL_PT_REQ_CHAIN_LENGTH): - case (CPP_CTNL_PT_REQ_CHAIN_WEIGHT): - case (CPP_CTNL_PT_REQ_SPAN_LENGTH): - case (CPP_CTNL_PT_START_OFFSET_COMP): - case (CPP_CTNL_REQ_SAMPLING_RATE): - case (CPP_CTNL_REQ_FACTORY_CALIBRATION_DATE): - { - // Nothing more to do - } break; - - default: - { - *status = PRF_ERR_INVALID_PARAM; - } break; - } - - return req_len; -} - -uint8_t cppc_unpack_ctln_pt_ind (uint8_t conidx, struct gattc_event_ind const *param, struct cppc_env_tag *cppc_env) -{ - // Offset - uint8_t offset = CPP_CP_CNTL_PT_RSP_MIN_LEN; - - // Control Point value has been received - struct cppc_ctnl_pt_rsp *ind = KE_MSG_ALLOC( - CPPC_CTNL_PT_RSP, - prf_dst_task_get(&cppc_env->prf_env, conidx), - prf_src_task_get(&cppc_env->prf_env, conidx), - cppc_ctnl_pt_rsp); - - // Requested operation code - ind->rsp.req_op_code = param->value[1]; - // Response value - ind->rsp.resp_value = param->value[2]; - - if ((ind->rsp.resp_value == CPP_CTNL_PT_RESP_SUCCESS) && (param->length >= 3)) - { - switch (ind->rsp.req_op_code) - { - case (CPP_CTNL_PT_REQ_SUPP_SENSOR_LOC): - { - // Get the number of supported locations that have been received - uint8_t nb_supp_loc = (param->length - 3); - // Location - uint8_t loc; - - for (uint8_t counter = 0; counter < nb_supp_loc; counter++) - { - loc = param->value[counter + CPP_CP_CNTL_PT_RSP_MIN_LEN]; - // Check if valid - if (loc < CPP_LOC_MAX) - { - ind->rsp.value.supp_loc |= (1 << loc); - } - offset++; - } - } break; - - case (CPP_CTNL_PT_REQ_CRANK_LENGTH): - { - ind->rsp.value.crank_length = co_read16p(¶m->value[offset]); - offset += 2; - } break; - - case (CPP_CTNL_PT_REQ_CHAIN_LENGTH): - { - ind->rsp.value.chain_length = co_read16p(¶m->value[offset]); - offset += 2; - } break; - - case (CPP_CTNL_PT_REQ_CHAIN_WEIGHT): - { - ind->rsp.value.chain_weight = co_read16p(¶m->value[offset]); - offset += 2; - } break; - - case (CPP_CTNL_PT_REQ_SPAN_LENGTH): - { - ind->rsp.value.span_length = co_read16p(¶m->value[offset]); - offset += 2; - } break; - - case (CPP_CTNL_PT_START_OFFSET_COMP): - { - ind->rsp.value.offset_comp = co_read16p(¶m->value[offset]); - offset += 2; - } break; - - case (CPP_CTNL_REQ_SAMPLING_RATE): - { - ind->rsp.value.sampling_rate = param->value[offset]; - offset++; - } break; - - case (CPP_CTNL_REQ_FACTORY_CALIBRATION_DATE): - { - offset += prf_unpack_date_time( - (uint8_t *) &(param->value[offset]), &(ind->rsp.value.factory_calibration)); - } break; - - case (CPP_CTNL_PT_SET_CUMUL_VAL): - case (CPP_CTNL_PT_UPD_SENSOR_LOC): - case (CPP_CTNL_PT_SET_CRANK_LENGTH): - case (CPP_CTNL_PT_SET_CHAIN_LENGTH): - case (CPP_CTNL_PT_SET_CHAIN_WEIGHT): - case (CPP_CTNL_PT_SET_SPAN_LENGTH): - case (CPP_CTNL_MASK_CP_MEAS_CH_CONTENT): - { - // No parameters - } break; - - default: - { - - } break; - } - } - - // Send the message - ke_msg_send(ind); - - return offset; + return offset; } #endif //(BLE_CP_COLLECTOR) diff --git a/services/ble_profiles/cpp/cppc/src/cppc_task.c b/services/ble_profiles/cpp/cppc/src/cppc_task.c index 5cde3f2..f7eae05 100644 --- a/services/ble_profiles/cpp/cppc/src/cppc_task.c +++ b/services/ble_profiles/cpp/cppc/src/cppc_task.c @@ -14,14 +14,14 @@ #if (BLE_CP_COLLECTOR) #include "cpp_common.h" -#include "cppc_task.h" #include "cppc.h" +#include "cppc_task.h" #include "gap.h" #include "gattc_task.h" -#include "ke_timer.h" #include "ke_mem.h" +#include "ke_timer.h" #include "co_utils.h" @@ -30,53 +30,42 @@ **************************************************************************************** */ -/// State machine used to retrieve Cycling Power service characteristics information -const struct prf_char_def cppc_cps_char[CPP_CPS_CHAR_MAX] = -{ +/// State machine used to retrieve Cycling Power service characteristics +/// information +const struct prf_char_def cppc_cps_char[CPP_CPS_CHAR_MAX] = { /// CP Measurement - [CPP_CPS_MEAS_CHAR] = {ATT_CHAR_CP_MEAS, - ATT_MANDATORY, - ATT_CHAR_PROP_NTF}, + [CPP_CPS_MEAS_CHAR] = {ATT_CHAR_CP_MEAS, ATT_MANDATORY, ATT_CHAR_PROP_NTF}, /// CP Feature - [CPP_CPS_FEAT_CHAR] = {ATT_CHAR_CP_FEAT, - ATT_MANDATORY, - ATT_CHAR_PROP_RD}, + [CPP_CPS_FEAT_CHAR] = {ATT_CHAR_CP_FEAT, ATT_MANDATORY, ATT_CHAR_PROP_RD}, /// Sensor Location - [CPP_CPS_SENSOR_LOC_CHAR] = {ATT_CHAR_SENSOR_LOC, - ATT_MANDATORY, - ATT_CHAR_PROP_RD}, - ///Vector - [CPP_CPS_VECTOR_CHAR] = {ATT_CHAR_CP_VECTOR, - ATT_OPTIONAL, - ATT_CHAR_PROP_NTF}, + [CPP_CPS_SENSOR_LOC_CHAR] = {ATT_CHAR_SENSOR_LOC, ATT_MANDATORY, + ATT_CHAR_PROP_RD}, + /// Vector + [CPP_CPS_VECTOR_CHAR] = {ATT_CHAR_CP_VECTOR, ATT_OPTIONAL, + ATT_CHAR_PROP_NTF}, /// SC Control Point - [CPP_CPS_CTNL_PT_CHAR] = {ATT_CHAR_CP_CNTL_PT, - ATT_OPTIONAL, - ATT_CHAR_PROP_WR | ATT_CHAR_PROP_IND}, + [CPP_CPS_CTNL_PT_CHAR] = {ATT_CHAR_CP_CNTL_PT, ATT_OPTIONAL, + ATT_CHAR_PROP_WR | ATT_CHAR_PROP_IND}, }; -/// State machine used to retrieve Cycling Power service characteristic descriptor information -const struct prf_char_desc_def cppc_cps_char_desc[CPPC_DESC_MAX] = -{ +/// State machine used to retrieve Cycling Power service characteristic +/// descriptor information +const struct prf_char_desc_def cppc_cps_char_desc[CPPC_DESC_MAX] = { /// CP Measurement Char. - Client Characteristic Configuration - [CPPC_DESC_CP_MEAS_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, - ATT_MANDATORY, - CPP_CPS_MEAS_CHAR}, + [CPPC_DESC_CP_MEAS_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, + CPP_CPS_MEAS_CHAR}, /// CP Measurement Char. - Server Characteristic Configuration - [CPPC_DESC_CP_MEAS_SV_CFG] = {ATT_DESC_SERVER_CHAR_CFG, - ATT_OPTIONAL, - CPP_CPS_MEAS_CHAR}, + [CPPC_DESC_CP_MEAS_SV_CFG] = {ATT_DESC_SERVER_CHAR_CFG, ATT_OPTIONAL, + CPP_CPS_MEAS_CHAR}, /// CP Vector Char. - Client Characteristic Configuration - [CPPC_DESC_VECTOR_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, - ATT_OPTIONAL, - CPP_CPS_VECTOR_CHAR}, + [CPPC_DESC_VECTOR_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_OPTIONAL, + CPP_CPS_VECTOR_CHAR}, /// Control Point Char. - Client Characteristic Configuration - [CPPC_DESC_CTNL_PT_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, - ATT_OPTIONAL, - CPP_CPS_CTNL_PT_CHAR}, + [CPPC_DESC_CTNL_PT_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_OPTIONAL, + CPP_CPS_CTNL_PT_CHAR}, }; /* @@ -95,60 +84,54 @@ const struct prf_char_desc_def cppc_cps_char_desc[CPPC_DESC_MAX] = **************************************************************************************** */ __STATIC int cppc_enable_req_handler(ke_msg_id_t const msgid, - struct cppc_enable_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + struct cppc_enable_req *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); - // Cycling Power Profile Collector Role Task Environment - struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); + uint8_t state = ke_state_get(dest_id); + // Cycling Power Profile Collector Role Task Environment + struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); - ASSERT_INFO(cppc_env != NULL, dest_id, src_id); - if((state == CPPC_IDLE) && (cppc_env->env[conidx] == NULL)) - { - // allocate environment variable for task instance - cppc_env->env[conidx] = (struct cppc_cnx_env*) ke_malloc(sizeof(struct cppc_cnx_env),KE_MEM_ATT_DB); - memset(cppc_env->env[conidx], 0, sizeof(struct cppc_cnx_env)); + ASSERT_INFO(cppc_env != NULL, dest_id, src_id); + if ((state == CPPC_IDLE) && (cppc_env->env[conidx] == NULL)) { + // allocate environment variable for task instance + cppc_env->env[conidx] = (struct cppc_cnx_env *)ke_malloc( + sizeof(struct cppc_cnx_env), KE_MEM_ATT_DB); + memset(cppc_env->env[conidx], 0, sizeof(struct cppc_cnx_env)); - //Config connection, start discovering - if(param->con_type == PRF_CON_DISCOVERY) - { - //start discovering CPS on peer - prf_disc_svc_send(&(cppc_env->prf_env), conidx, ATT_SVC_CYCLING_POWER); + // Config connection, start discovering + if (param->con_type == PRF_CON_DISCOVERY) { + // start discovering CPS on peer + prf_disc_svc_send(&(cppc_env->prf_env), conidx, ATT_SVC_CYCLING_POWER); - // Go to DISCOVERING state - ke_state_set(dest_id, CPPC_DISCOVERING); - } - //normal connection, get saved att details - else - { - cppc_env->env[conidx]->cps = param->cps; - - //send APP confirmation that can start normal connection to TH - cppc_enable_rsp_send(cppc_env, conidx, GAP_ERR_NO_ERROR); - } + // Go to DISCOVERING state + ke_state_set(dest_id, CPPC_DISCOVERING); } + // normal connection, get saved att details + else { + cppc_env->env[conidx]->cps = param->cps; - else if(state != CPPC_FREE) - { - status = PRF_ERR_REQ_DISALLOWED; + // send APP confirmation that can start normal connection to TH + cppc_enable_rsp_send(cppc_env, conidx, GAP_ERR_NO_ERROR); } + } - // send an error if request fails - if(status != GAP_ERR_NO_ERROR) - { - cppc_enable_rsp_send(cppc_env, conidx, status); - } + else if (state != CPPC_FREE) { + status = PRF_ERR_REQ_DISALLOWED; + } - return (KE_MSG_CONSUMED); + // send an error if request fails + if (status != GAP_ERR_NO_ERROR) { + cppc_enable_rsp_send(cppc_env, conidx, status); + } + + return (KE_MSG_CONSUMED); } - /** **************************************************************************************** * @brief Handles reception of the @ref CPPC_READ_CMD message. @@ -160,77 +143,63 @@ __STATIC int cppc_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int cppc_read_req_handler(ke_msg_id_t const msgid, - struct cpps_read_cmd *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - uint8_t status = PRF_ERR_REQ_DISALLOWED; - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; - // Get the address of the environment - struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + struct cpps_read_cmd *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + uint8_t status = PRF_ERR_REQ_DISALLOWED; + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; + // Get the address of the environment + struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - if(state == CPPC_IDLE) - { - ASSERT_INFO(cppc_env != NULL, dest_id, src_id); - // environment variable not ready - if(cppc_env->env[conidx] == NULL) - { - status = PRF_APP_ERROR; - } - else - { - // Get the handler - uint16_t hdl = cppc_get_read_handle_req (cppc_env, conidx, param); + if (state == CPPC_IDLE) { + ASSERT_INFO(cppc_env != NULL, dest_id, src_id); + // environment variable not ready + if (cppc_env->env[conidx] == NULL) { + status = PRF_APP_ERROR; + } else { + // Get the handler + uint16_t hdl = cppc_get_read_handle_req(cppc_env, conidx, param); - // Check if handle is viable - if (hdl != ATT_INVALID_SEARCH_HANDLE) - { - // Force the operation value - param->operation = CPPC_READ_OP_CODE; + // Check if handle is viable + if (hdl != ATT_INVALID_SEARCH_HANDLE) { + // Force the operation value + param->operation = CPPC_READ_OP_CODE; - // Store the command structure - cppc_env->env[conidx]->operation = param; - msg_status = KE_MSG_NO_FREE; + // Store the command structure + cppc_env->env[conidx]->operation = param; + msg_status = KE_MSG_NO_FREE; - // Send the read request - prf_read_char_send( &(cppc_env->prf_env), conidx, - cppc_env->env[conidx]->cps.svc.shdl, - cppc_env->env[conidx]->cps.svc.ehdl, - hdl); + // Send the read request + prf_read_char_send(&(cppc_env->prf_env), conidx, + cppc_env->env[conidx]->cps.svc.shdl, + cppc_env->env[conidx]->cps.svc.ehdl, hdl); - // Go to the Busy state - ke_state_set(dest_id, CPPC_BUSY); + // Go to the Busy state + ke_state_set(dest_id, CPPC_BUSY); - status = ATT_ERR_NO_ERROR; - } - else - { - status = PRF_ERR_INEXISTENT_HDL; - } - } - } - else if(state == CPPC_FREE) - { - status = GAP_ERR_DISCONNECTED; - } - else - { - // Another procedure is pending, keep the command for later - msg_status = KE_MSG_SAVED; - status = GAP_ERR_NO_ERROR; + status = ATT_ERR_NO_ERROR; + } else { + status = PRF_ERR_INEXISTENT_HDL; + } } + } else if (state == CPPC_FREE) { + status = GAP_ERR_DISCONNECTED; + } else { + // Another procedure is pending, keep the command for later + msg_status = KE_MSG_SAVED; + status = GAP_ERR_NO_ERROR; + } - if (status != GAP_ERR_NO_ERROR) - { - // Send the complete event message to the task id stored in the environment - cppc_send_cmp_evt(cppc_env, conidx, CPPC_READ_OP_CODE, status); - } + if (status != GAP_ERR_NO_ERROR) { + // Send the complete event message to the task id stored in the environment + cppc_send_cmp_evt(cppc_env, conidx, CPPC_READ_OP_CODE, status); + } - return (int)msg_status; + return (int)msg_status; } /** @@ -244,63 +213,57 @@ __STATIC int cppc_read_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int cppc_cfg_ntfind_cmd_handler(ke_msg_id_t const msgid, - struct cppc_cfg_ntfind_cmd *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); + struct cppc_cfg_ntfind_cmd *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); - uint8_t state = ke_state_get(dest_id); - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; + uint8_t state = ke_state_get(dest_id); + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; - if (cppc_env != NULL) - { - // Status - uint8_t status = PRF_ERR_REQ_DISALLOWED; - // Handle - uint16_t handle = ATT_INVALID_SEARCH_HANDLE; - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + if (cppc_env != NULL) { + // Status + uint8_t status = PRF_ERR_REQ_DISALLOWED; + // Handle + uint16_t handle = ATT_INVALID_SEARCH_HANDLE; + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - do - { - if (state != CPPC_IDLE) - { - // Another procedure is pending, keep the command for later - msg_status = KE_MSG_SAVED; - break; - } + do { + if (state != CPPC_IDLE) { + // Another procedure is pending, keep the command for later + msg_status = KE_MSG_SAVED; + break; + } - ASSERT_ERR(cppc_env->env[conidx] != NULL); + ASSERT_ERR(cppc_env->env[conidx] != NULL); - // Get handle - status = cppc_get_write_desc_handle_req (conidx, param, cppc_env, &handle); - } while (0); + // Get handle + status = cppc_get_write_desc_handle_req(conidx, param, cppc_env, &handle); + } while (0); - if ((status == GAP_ERR_NO_ERROR) && (handle != ATT_INVALID_SEARCH_HANDLE)) - { - // Set the operation code - param->operation = CPPC_CFG_NTF_IND_OP_CODE; + if ((status == GAP_ERR_NO_ERROR) && (handle != ATT_INVALID_SEARCH_HANDLE)) { + // Set the operation code + param->operation = CPPC_CFG_NTF_IND_OP_CODE; - // Store the command structure - cppc_env->env[conidx]->operation = param; - msg_status = KE_MSG_NO_FREE; + // Store the command structure + cppc_env->env[conidx]->operation = param; + msg_status = KE_MSG_NO_FREE; - // Go to the Busy state - ke_state_set(dest_id, CPPC_BUSY); + // Go to the Busy state + ke_state_set(dest_id, CPPC_BUSY); - // Send GATT Write Request - prf_gatt_write_ntf_ind(&cppc_env->prf_env, conidx, handle, param->ntfind_cfg); - } - } - else - { - cppc_send_no_conn_cmp_evt(dest_id, src_id, CPPC_CFG_NTF_IND_OP_CODE); + // Send GATT Write Request + prf_gatt_write_ntf_ind(&cppc_env->prf_env, conidx, handle, + param->ntfind_cfg); } + } else { + cppc_send_no_conn_cmp_evt(dest_id, src_id, CPPC_CFG_NTF_IND_OP_CODE); + } - return (int)msg_status; + return (int)msg_status; } /** @@ -314,93 +277,85 @@ __STATIC int cppc_cfg_ntfind_cmd_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int cppc_ctnl_pt_cfg_req_handler(ke_msg_id_t const msgid, - struct cppc_ctnl_pt_cfg_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; - // Get the address of the environment - struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + struct cppc_ctnl_pt_cfg_req *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; + // Get the address of the environment + struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - if (cppc_env != NULL) - { - // Status - uint8_t status = GAP_ERR_NO_ERROR; + if (cppc_env != NULL) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; - do - { - // State is Connected or Busy - ASSERT_ERR(ke_state_get(dest_id) > CPPC_FREE); - // Check the provided connection handle - if (cppc_env->env[conidx] == NULL) - { - status = PRF_ERR_INVALID_PARAM; - break; - } + do { + // State is Connected or Busy + ASSERT_ERR(ke_state_get(dest_id) > CPPC_FREE); + // Check the provided connection handle + if (cppc_env->env[conidx] == NULL) { + status = PRF_ERR_INVALID_PARAM; + break; + } - if (ke_state_get(dest_id) != CPPC_IDLE) - { - // Another procedure is pending, keep the command for later - msg_status = KE_MSG_SAVED; - // Status is GAP_ERR_NO_ERROR, no message will be sent to the application - break; - } + if (ke_state_get(dest_id) != CPPC_IDLE) { + // Another procedure is pending, keep the command for later + msg_status = KE_MSG_SAVED; + // Status is GAP_ERR_NO_ERROR, no message will be sent to the + // application + break; + } - // Check if the characteristic has been found - if (cppc_env->env[conidx]->cps.descs[CPPC_DESC_CTNL_PT_CL_CFG].desc_hdl != ATT_INVALID_SEARCH_HANDLE) - { - // Request array declaration - uint8_t req[CPP_CP_CNTL_PT_REQ_MAX_LEN]; - // Pack request - uint8_t nb = cppc_pack_ctnl_pt_req (param, req, &status); + // Check if the characteristic has been found + if (cppc_env->env[conidx]->cps.descs[CPPC_DESC_CTNL_PT_CL_CFG].desc_hdl != + ATT_INVALID_SEARCH_HANDLE) { + // Request array declaration + uint8_t req[CPP_CP_CNTL_PT_REQ_MAX_LEN]; + // Pack request + uint8_t nb = cppc_pack_ctnl_pt_req(param, req, &status); - if (status == GAP_ERR_NO_ERROR) - { - // Set the operation code - param->operation = CPPC_CTNL_PT_CFG_WR_OP_CODE; + if (status == GAP_ERR_NO_ERROR) { + // Set the operation code + param->operation = CPPC_CTNL_PT_CFG_WR_OP_CODE; - // Store the command structure - cppc_env->env[conidx]->operation = param; - // Store the command information - msg_status = KE_MSG_NO_FREE; + // Store the command structure + cppc_env->env[conidx]->operation = param; + // Store the command information + msg_status = KE_MSG_NO_FREE; - // Go to the Busy state - ke_state_set(dest_id, CPPC_BUSY); + // Go to the Busy state + ke_state_set(dest_id, CPPC_BUSY); - // Send the write request - prf_gatt_write(&(cppc_env->prf_env), conidx, cppc_env->env[conidx]->cps.chars[CPP_CPS_CTNL_PT_CHAR].val_hdl, - (uint8_t *)&req[0], nb, GATTC_WRITE); - } - } - else - { - status = PRF_ERR_INEXISTENT_HDL; - } - } while (0); - - if (status != GAP_ERR_NO_ERROR) - { - // Send a complete event status to the application - cppc_send_cmp_evt(cppc_env, conidx, CPPC_CTNL_PT_CFG_WR_OP_CODE, status); + // Send the write request + prf_gatt_write( + &(cppc_env->prf_env), conidx, + cppc_env->env[conidx]->cps.chars[CPP_CPS_CTNL_PT_CHAR].val_hdl, + (uint8_t *)&req[0], nb, GATTC_WRITE); } - } - else - { - // No connection - cppc_send_no_conn_cmp_evt(dest_id, src_id, CPPC_CTNL_PT_CFG_WR_OP_CODE); - } + } else { + status = PRF_ERR_INEXISTENT_HDL; + } + } while (0); - return (int)msg_status; + if (status != GAP_ERR_NO_ERROR) { + // Send a complete event status to the application + cppc_send_cmp_evt(cppc_env, conidx, CPPC_CTNL_PT_CFG_WR_OP_CODE, status); + } + } else { + // No connection + cppc_send_no_conn_cmp_evt(dest_id, src_id, CPPC_CTNL_PT_CFG_WR_OP_CODE); + } + + return (int)msg_status; } /** **************************************************************************************** - * @brief Handles reception of the @ref CPPC_TIMEOUT_TIMER_IND message. This message is - * received when the peer device doesn't send a SC Control Point indication within 30s - * after reception of the write response. + * @brief Handles reception of the @ref CPPC_TIMEOUT_TIMER_IND message. This + *message is received when the peer device doesn't send a SC Control Point + *indication within 30s after reception of the write response. * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance. @@ -409,26 +364,27 @@ __STATIC int cppc_ctnl_pt_cfg_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int cppc_timeout_timer_ind_handler(ke_msg_id_t const msgid, - void const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + void const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - if (cppc_env != NULL) - { - ASSERT_ERR(cppc_env->env[conidx]->operation != NULL); - ASSERT_ERR(((struct cppc_cmd *)cppc_env->env[conidx]->operation)->operation == CPPC_CTNL_PT_CFG_IND_OP_CODE); + if (cppc_env != NULL) { + ASSERT_ERR(cppc_env->env[conidx]->operation != NULL); + ASSERT_ERR( + ((struct cppc_cmd *)cppc_env->env[conidx]->operation)->operation == + CPPC_CTNL_PT_CFG_IND_OP_CODE); - // Send the complete event message - cppc_send_cmp_evt(cppc_env, conidx, CPPC_CTNL_PT_CFG_WR_OP_CODE, PRF_ERR_PROC_TIMEOUT); - } - // else drop the message + // Send the complete event message + cppc_send_cmp_evt(cppc_env, conidx, CPPC_CTNL_PT_CFG_WR_OP_CODE, + PRF_ERR_PROC_TIMEOUT); + } + // else drop the message - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -443,36 +399,35 @@ __STATIC int cppc_timeout_timer_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, - struct gattc_sdp_svc_ind const *ind, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_sdp_svc_ind const *ind, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == CPPC_DISCOVERING) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == CPPC_DISCOVERING) { + uint8_t conidx = KE_IDX_GET(dest_id); - struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); + struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); - ASSERT_INFO(cppc_env != NULL, dest_id, src_id); - ASSERT_INFO(cppc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(cppc_env != NULL, dest_id, src_id); + ASSERT_INFO(cppc_env->env[conidx] != NULL, dest_id, src_id); - if(cppc_env->env[conidx]->nb_svc == 0) - { - // Retrieve CPS characteristics and descriptors - prf_extract_svc_info(ind, CPP_CPS_CHAR_MAX, &cppc_cps_char[0], &cppc_env->env[conidx]->cps.chars[0], - CPPC_DESC_MAX, &cppc_cps_char_desc[0], &cppc_env->env[conidx]->cps.descs[0]); + if (cppc_env->env[conidx]->nb_svc == 0) { + // Retrieve CPS characteristics and descriptors + prf_extract_svc_info(ind, CPP_CPS_CHAR_MAX, &cppc_cps_char[0], + &cppc_env->env[conidx]->cps.chars[0], CPPC_DESC_MAX, + &cppc_cps_char_desc[0], + &cppc_env->env[conidx]->cps.descs[0]); - //Even if we get multiple responses we only store 1 range - cppc_env->env[conidx]->cps.svc.shdl = ind->start_hdl; - cppc_env->env[conidx]->cps.svc.ehdl = ind->end_hdl; - } - - cppc_env->env[conidx]->nb_svc++; + // Even if we get multiple responses we only store 1 range + cppc_env->env[conidx]->cps.svc.shdl = ind->start_hdl; + cppc_env->env[conidx]->cps.svc.ehdl = ind->end_hdl; } - return (KE_MSG_CONSUMED); + cppc_env->env[conidx]->nb_svc++; + } + + return (KE_MSG_CONSUMED); } /** @@ -486,116 +441,96 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, - struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); - // Status - uint8_t status; + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); + // Status + uint8_t status; + if (cppc_env != NULL) { + uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t state = ke_state_get(dest_id); - if (cppc_env != NULL) - { - uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); + if (state == CPPC_DISCOVERING) { + status = param->status; - if (state == CPPC_DISCOVERING) - { - status = param->status; - - if ((status == ATT_ERR_ATTRIBUTE_NOT_FOUND) || - (status == ATT_ERR_NO_ERROR)) - { - // Discovery - // check characteristic validity - if(cppc_env->env[conidx]->nb_svc == 1) - { - status = prf_check_svc_char_validity(CPP_CPS_CHAR_MAX, - cppc_env->env[conidx]->cps.chars, - cppc_cps_char); - } - // too much services - else if (cppc_env->env[conidx]->nb_svc > 1) - { - status = PRF_ERR_MULTIPLE_SVC; - } - // no services found - else - { - status = PRF_ERR_STOP_DISC_CHAR_MISSING; - } - - // check descriptor validity - if (status == GAP_ERR_NO_ERROR) - { - status = prf_check_svc_char_desc_validity(CPPC_DESC_MAX, - cppc_env->env[conidx]->cps.descs, - cppc_cps_char_desc, - cppc_env->env[conidx]->cps.chars); - } - } - - cppc_enable_rsp_send(cppc_env, conidx, status); + if ((status == ATT_ERR_ATTRIBUTE_NOT_FOUND) || + (status == ATT_ERR_NO_ERROR)) { + // Discovery + // check characteristic validity + if (cppc_env->env[conidx]->nb_svc == 1) { + status = prf_check_svc_char_validity(CPP_CPS_CHAR_MAX, + cppc_env->env[conidx]->cps.chars, + cppc_cps_char); + } + // too much services + else if (cppc_env->env[conidx]->nb_svc > 1) { + status = PRF_ERR_MULTIPLE_SVC; + } + // no services found + else { + status = PRF_ERR_STOP_DISC_CHAR_MISSING; } - else if (state == CPPC_BUSY) - { - switch (param->operation) - { - case GATTC_READ: - { - // Send the complete event status - cppc_send_cmp_evt(cppc_env, conidx, CPPC_READ_OP_CODE, param->status); - } break; - - case GATTC_WRITE: - case GATTC_WRITE_NO_RESPONSE: - { - uint8_t operation = ((struct cppc_cmd *)cppc_env->env[conidx]->operation)->operation; - - if (operation == CPPC_CFG_NTF_IND_OP_CODE) - { - // Send the complete event status - cppc_send_cmp_evt(cppc_env, conidx, operation, param->status); - } - - else if (operation == CPPC_CTNL_PT_CFG_WR_OP_CODE) - { - if (param->status == GAP_ERR_NO_ERROR) - { - // Start Timeout Procedure - ke_timer_set(CPPC_TIMEOUT_TIMER_IND, dest_id, ATT_TRANS_RTX); - - // Wait for the response indication - ((struct cppc_cmd *)cppc_env->env[conidx]->operation)->operation = CPPC_CTNL_PT_CFG_IND_OP_CODE; - } - else - { - // Send the complete event status - cppc_send_cmp_evt(cppc_env, conidx, operation, param->status); - } - } - } break; - - case GATTC_REGISTER: - case GATTC_UNREGISTER: - { - // Do nothing - } break; - - default: - { - ASSERT_ERR(0); - } break; - } + // check descriptor validity + if (status == GAP_ERR_NO_ERROR) { + status = prf_check_svc_char_desc_validity( + CPPC_DESC_MAX, cppc_env->env[conidx]->cps.descs, + cppc_cps_char_desc, cppc_env->env[conidx]->cps.chars); } + } + cppc_enable_rsp_send(cppc_env, conidx, status); } - // else ignore the message - return (KE_MSG_CONSUMED); + else if (state == CPPC_BUSY) { + switch (param->operation) { + case GATTC_READ: { + // Send the complete event status + cppc_send_cmp_evt(cppc_env, conidx, CPPC_READ_OP_CODE, param->status); + } break; + + case GATTC_WRITE: + case GATTC_WRITE_NO_RESPONSE: { + uint8_t operation = + ((struct cppc_cmd *)cppc_env->env[conidx]->operation)->operation; + + if (operation == CPPC_CFG_NTF_IND_OP_CODE) { + // Send the complete event status + cppc_send_cmp_evt(cppc_env, conidx, operation, param->status); + } + + else if (operation == CPPC_CTNL_PT_CFG_WR_OP_CODE) { + if (param->status == GAP_ERR_NO_ERROR) { + // Start Timeout Procedure + ke_timer_set(CPPC_TIMEOUT_TIMER_IND, dest_id, ATT_TRANS_RTX); + + // Wait for the response indication + ((struct cppc_cmd *)cppc_env->env[conidx]->operation)->operation = + CPPC_CTNL_PT_CFG_IND_OP_CODE; + } else { + // Send the complete event status + cppc_send_cmp_evt(cppc_env, conidx, operation, param->status); + } + } + } break; + + case GATTC_REGISTER: + case GATTC_UNREGISTER: { + // Do nothing + } break; + + default: { + ASSERT_ERR(0); + } break; + } + } + } + // else ignore the message + + return (KE_MSG_CONSUMED); } /** @@ -612,70 +547,62 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, struct gattc_read_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - // Get the address of the environment - struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); + // Get the address of the environment + struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); - if (state == CPPC_BUSY) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == CPPC_BUSY) { + uint8_t conidx = KE_IDX_GET(dest_id); - ASSERT_INFO(cppc_env != NULL, dest_id, src_id); - ASSERT_INFO(cppc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(cppc_env != NULL, dest_id, src_id); + ASSERT_INFO(cppc_env->env[conidx] != NULL, dest_id, src_id); - // Send the read value to the HL - struct cppc_value_ind *ind = KE_MSG_ALLOC( - CPPC_VALUE_IND, - prf_dst_task_get(&(cppc_env->prf_env), conidx), - dest_id, - cppc_value_ind); + // Send the read value to the HL + struct cppc_value_ind *ind = KE_MSG_ALLOC( + CPPC_VALUE_IND, prf_dst_task_get(&(cppc_env->prf_env), conidx), dest_id, + cppc_value_ind); - switch (((struct cpps_read_cmd *)cppc_env->env[conidx]->operation)->read_code) - { - // Read CP Feature Characteristic value - case (CPPC_RD_CP_FEAT): - { - ind->value.sensor_feat = co_read32p(¶m->value[0]); + switch ( + ((struct cpps_read_cmd *)cppc_env->env[conidx]->operation)->read_code) { + // Read CP Feature Characteristic value + case (CPPC_RD_CP_FEAT): { + ind->value.sensor_feat = co_read32p(¶m->value[0]); - // Mask the reserved bits -// ind->value.sensor_feat &= CPP_FEAT_ALL_SUPP; - } break; + // Mask the reserved bits + // ind->value.sensor_feat &= CPP_FEAT_ALL_SUPP; + } break; - // Read Sensor Location Characteristic value - case (CPPC_RD_SENSOR_LOC): - { - ind->value.sensor_loc = param->value[0]; - } break; + // Read Sensor Location Characteristic value + case (CPPC_RD_SENSOR_LOC): { + ind->value.sensor_loc = param->value[0]; + } break; - // Read Client Characteristic Configuration Descriptor value - case (CPPC_RD_WR_CP_MEAS_CL_CFG): - case (CPPC_RD_WR_CP_MEAS_SV_CFG): - case (CPPC_RD_WR_VECTOR_CFG): - case (CPPC_RD_WR_CTNL_PT_CFG): - { - co_write16p(&ind->value.ntf_cfg, param->value[0]); - } break; + // Read Client Characteristic Configuration Descriptor value + case (CPPC_RD_WR_CP_MEAS_CL_CFG): + case (CPPC_RD_WR_CP_MEAS_SV_CFG): + case (CPPC_RD_WR_VECTOR_CFG): + case (CPPC_RD_WR_CTNL_PT_CFG): { + co_write16p(&ind->value.ntf_cfg, param->value[0]); + } break; - default: - { - ASSERT_ERR(0); - } break; - } - - ind->att_code = ((struct cpps_read_cmd *)cppc_env->env[conidx]->operation)->read_code; - - // Send the message to the application - ke_msg_send(ind); + default: { + ASSERT_ERR(0); + } break; } - // else drop the message - return (KE_MSG_CONSUMED); + ind->att_code = + ((struct cpps_read_cmd *)cppc_env->env[conidx]->operation)->read_code; + + // Send the message to the application + ke_msg_send(ind); + } + // else drop the message + + return (KE_MSG_CONSUMED); } - /** **************************************************************************************** * @brief Handles reception of the @ref GATTC_EVENT_IND message. @@ -687,71 +614,64 @@ __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, - struct gattc_event_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); + struct gattc_event_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); - if (cppc_env != NULL) - { - switch (param->type) - { - case (GATTC_NOTIFY): - { + if (cppc_env != NULL) { + switch (param->type) { + case (GATTC_NOTIFY): { - if (param->handle == cppc_env->env[conidx]->cps.chars[CPP_CPS_MEAS_CHAR].val_hdl) - { - //Unpack measurement - cppc_unpack_meas_ind (conidx, param, cppc_env); - } - else if (param->handle == cppc_env->env[conidx]->cps.chars[CPP_CPS_VECTOR_CHAR].val_hdl) - { - //Unpack vector - cppc_unpack_vector_ind (conidx, param, cppc_env); - } - else - { - ASSERT_ERR(0); - } - } break; + if (param->handle == + cppc_env->env[conidx]->cps.chars[CPP_CPS_MEAS_CHAR].val_hdl) { + // Unpack measurement + cppc_unpack_meas_ind(conidx, param, cppc_env); + } else if (param->handle == cppc_env->env[conidx] + ->cps.chars[CPP_CPS_VECTOR_CHAR] + .val_hdl) { + // Unpack vector + cppc_unpack_vector_ind(conidx, param, cppc_env); + } else { + ASSERT_ERR(0); + } + } break; - case (GATTC_INDICATE): - { - // confirm that indication has been correctly received - struct gattc_event_cfm * cfm = KE_MSG_ALLOC(GATTC_EVENT_CFM, src_id, dest_id, gattc_event_cfm); - cfm->handle = param->handle; - ke_msg_send(cfm); + case (GATTC_INDICATE): { + // confirm that indication has been correctly received + struct gattc_event_cfm *cfm = + KE_MSG_ALLOC(GATTC_EVENT_CFM, src_id, dest_id, gattc_event_cfm); + cfm->handle = param->handle; + ke_msg_send(cfm); - // Check if we were waiting for the indication - if (cppc_env->env[conidx]->operation != NULL) - { - if (((struct cppc_cmd *)cppc_env->env[conidx]->operation)->operation == CPPC_CTNL_PT_CFG_IND_OP_CODE) - { - // Stop the procedure timeout timer - ke_timer_clear(CPPC_TIMEOUT_TIMER_IND, dest_id); + // Check if we were waiting for the indication + if (cppc_env->env[conidx]->operation != NULL) { + if (((struct cppc_cmd *)cppc_env->env[conidx]->operation)->operation == + CPPC_CTNL_PT_CFG_IND_OP_CODE) { + // Stop the procedure timeout timer + ke_timer_clear(CPPC_TIMEOUT_TIMER_IND, dest_id); - //Unpack control point - cppc_unpack_ctln_pt_ind (conidx, param, cppc_env); + // Unpack control point + cppc_unpack_ctln_pt_ind(conidx, param, cppc_env); - // Send the complete event message - cppc_send_cmp_evt(cppc_env, conidx, CPPC_CTNL_PT_CFG_WR_OP_CODE, GAP_ERR_NO_ERROR); - } - // else drop the message - } - // else drop the message - } break; - - default: - { - ASSERT_ERR(0); - } break; + // Send the complete event message + cppc_send_cmp_evt(cppc_env, conidx, CPPC_CTNL_PT_CFG_WR_OP_CODE, + GAP_ERR_NO_ERROR); } - } + // else drop the message + } + // else drop the message + } break; - return (KE_MSG_CONSUMED); + default: { + ASSERT_ERR(0); + } break; + } + } + + return (KE_MSG_CONSUMED); } /* @@ -760,29 +680,27 @@ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, */ /// Specifies the default message handlers -KE_MSG_HANDLER_TAB(cppc) -{ - {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, - {CPPC_READ_CMD, (ke_msg_func_t)cppc_read_req_handler}, - {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, - {CPPC_CFG_NTFIND_CMD, (ke_msg_func_t)cppc_cfg_ntfind_cmd_handler}, - {CPPC_CTNL_PT_CFG_REQ, (ke_msg_func_t)cppc_ctnl_pt_cfg_req_handler}, - {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, - {GATTC_EVENT_REQ_IND, (ke_msg_func_t)gattc_event_ind_handler}, - {CPPC_TIMEOUT_TIMER_IND, (ke_msg_func_t)cppc_timeout_timer_ind_handler}, - {CPPC_ENABLE_REQ, (ke_msg_func_t)cppc_enable_req_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, +KE_MSG_HANDLER_TAB(cppc){ + {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, + {CPPC_READ_CMD, (ke_msg_func_t)cppc_read_req_handler}, + {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, + {CPPC_CFG_NTFIND_CMD, (ke_msg_func_t)cppc_cfg_ntfind_cmd_handler}, + {CPPC_CTNL_PT_CFG_REQ, (ke_msg_func_t)cppc_ctnl_pt_cfg_req_handler}, + {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {GATTC_EVENT_REQ_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {CPPC_TIMEOUT_TIMER_IND, (ke_msg_func_t)cppc_timeout_timer_ind_handler}, + {CPPC_ENABLE_REQ, (ke_msg_func_t)cppc_enable_req_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void cppc_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); +void cppc_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct cppc_env_tag *cppc_env = PRF_ENV_GET(CPPC, cppc); - task_desc->msg_handler_tab = cppc_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(cppc_msg_handler_tab); - task_desc->state = cppc_env->state; - task_desc->idx_max = CPPC_IDX_MAX; + task_desc->msg_handler_tab = cppc_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(cppc_msg_handler_tab); + task_desc->state = cppc_env->state; + task_desc->idx_max = CPPC_IDX_MAX; } #endif //(BLE_CP_COLLECTOR) diff --git a/services/ble_profiles/cpp/cpps/src/cpps.c b/services/ble_profiles/cpp/cpps/src/cpps.c index 95fce70..5cb974f 100644 --- a/services/ble_profiles/cpp/cpps/src/cpps.c +++ b/services/ble_profiles/cpp/cpps/src/cpps.c @@ -10,20 +10,19 @@ **************************************************************************************** */ - #include "rwip_config.h" #if (BLE_CP_SENSOR) +#include "co_math.h" #include "cpp_common.h" -#include "gap.h" -#include "gattc_task.h" -#include "gattc.h" #include "cpps.h" #include "cpps_task.h" +#include "gap.h" +#include "gattc.h" +#include "gattc_task.h" #include "prf_utils.h" -#include "co_math.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * GLOBAL VARIABLE DEFINITIONS @@ -31,47 +30,63 @@ */ /// Full CPPS Database Description - Used to add attributes into the database -static const struct attm_desc cpps_att_db[CPS_IDX_NB] = -{ +static const struct attm_desc cpps_att_db[CPS_IDX_NB] = { // Cycling Power Service Declaration - [CPS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [CPS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // CP Measurement Characteristic Declaration - [CPS_IDX_CP_MEAS_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [CPS_IDX_CP_MEAS_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, // CP Measurement Characteristic Value - [CPS_IDX_CP_MEAS_VAL] = {ATT_CHAR_CP_MEAS, PERM(NTF, ENABLE), PERM(RI, ENABLE), CPP_CP_MEAS_NTF_MAX_LEN}, - // CP Measurement Characteristic - Client Characteristic Configuration Descriptor - [CPS_IDX_CP_MEAS_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, - // CP Measurement Characteristic - Server Characteristic Configuration Descriptor - [CPS_IDX_CP_MEAS_BCST_CFG] = {ATT_DESC_SERVER_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [CPS_IDX_CP_MEAS_VAL] = {ATT_CHAR_CP_MEAS, PERM(NTF, ENABLE), + PERM(RI, ENABLE), CPP_CP_MEAS_NTF_MAX_LEN}, + // CP Measurement Characteristic - Client Characteristic Configuration + // Descriptor + [CPS_IDX_CP_MEAS_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, + 0}, + // CP Measurement Characteristic - Server Characteristic Configuration + // Descriptor + [CPS_IDX_CP_MEAS_BCST_CFG] = {ATT_DESC_SERVER_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, + 0}, // CP Feature Characteristic Declaration - [CPS_IDX_CP_FEAT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [CPS_IDX_CP_FEAT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, // CP Feature Characteristic Value - [CPS_IDX_CP_FEAT_VAL] = {ATT_CHAR_CP_FEAT, PERM(RD, ENABLE), PERM(RI, ENABLE), sizeof(uint32_t)}, + [CPS_IDX_CP_FEAT_VAL] = {ATT_CHAR_CP_FEAT, PERM(RD, ENABLE), + PERM(RI, ENABLE), sizeof(uint32_t)}, // Sensor Location Characteristic Declaration - [CPS_IDX_SENSOR_LOC_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [CPS_IDX_SENSOR_LOC_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Sensor Location Characteristic Value - [CPS_IDX_SENSOR_LOC_VAL] = {ATT_CHAR_SENSOR_LOC, PERM(RD, ENABLE), PERM(RI, ENABLE), sizeof(uint8_t)}, + [CPS_IDX_SENSOR_LOC_VAL] = {ATT_CHAR_SENSOR_LOC, PERM(RD, ENABLE), + PERM(RI, ENABLE), sizeof(uint8_t)}, // CP Vector Characteristic Declaration - [CPS_IDX_VECTOR_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [CPS_IDX_VECTOR_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, // CP Vector Characteristic Value - [CPS_IDX_VECTOR_VAL] = {ATT_CHAR_CP_VECTOR, PERM(NTF, ENABLE), PERM(RI, ENABLE), CPP_CP_VECTOR_MAX_LEN}, + [CPS_IDX_VECTOR_VAL] = {ATT_CHAR_CP_VECTOR, PERM(NTF, ENABLE), + PERM(RI, ENABLE), CPP_CP_VECTOR_MAX_LEN}, // CP Vector Characteristic - Client Characteristic Configuration Descriptor - [CPS_IDX_VECTOR_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [CPS_IDX_VECTOR_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, + 0}, // CP Control Point Characteristic Declaration - [CPS_IDX_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, - // CP Control Point Characteristic Value - The response has the maximal length - [CPS_IDX_CTNL_PT_VAL] = {ATT_CHAR_CP_CNTL_PT, PERM(IND, ENABLE) | PERM(WRITE_REQ, ENABLE), - PERM(RI, ENABLE), CPP_CP_CNTL_PT_RSP_MAX_LEN}, - // CP Control Point Characteristic - Client Characteristic Configuration Descriptor - [CPS_IDX_CTNL_PT_IND_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [CPS_IDX_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + // CP Control Point Characteristic Value - The response has the maximal + // length + [CPS_IDX_CTNL_PT_VAL] = {ATT_CHAR_CP_CNTL_PT, + PERM(IND, ENABLE) | PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE), CPP_CP_CNTL_PT_RSP_MAX_LEN}, + // CP Control Point Characteristic - Client Characteristic Configuration + // Descriptor + [CPS_IDX_CTNL_PT_IND_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, + 0}, }; - /* * EXPORTED FUNCTIONS DEFINITIONS **************************************************************************************** @@ -89,138 +104,152 @@ static const struct attm_desc cpps_att_db[CPS_IDX_NB] = * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t cpps_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, struct cpps_db_cfg* params) -{ - //------------------ create the attribute database for the profile ------------------- - // Service content flag - uint32_t cfg_flag= CPPS_MANDATORY_MASK; - // DB Creation Status - uint8_t status = ATT_ERR_NO_ERROR; +static uint8_t cpps_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, + struct cpps_db_cfg *params) { + //------------------ create the attribute database for the profile + //------------------- + // Service content flag + uint32_t cfg_flag = CPPS_MANDATORY_MASK; + // DB Creation Status + uint8_t status = ATT_ERR_NO_ERROR; + + /* + * Check if Broadcaster role shall be added. + */ + if (CPPS_IS_FEATURE_SUPPORTED(params->prfl_config, + CPPS_BROADCASTER_SUPP_FLAG)) { + // Add configuration to the database + cfg_flag |= CPPS_MEAS_BCST_MASK; + } + /* + * Check if the CP Vector characteristic shall be added. + * Mandatory if at least one Vector procedure is supported, otherwise + * excluded. + */ + if ((CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, + CPP_FEAT_CRANK_REV_DATA_SUPP)) || + (CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, + CPP_FEAT_EXTREME_ANGLES_SUPP)) || + (CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, + CPP_FEAT_INSTANT_MEAS_DIRECTION_SUPP))) { + cfg_flag |= CPPS_VECTOR_MASK; + } + /* + * Check if the Control Point characteristic shall be added + * Mandatory if server supports: + * - Wheel Revolution Data + * - Multiple Sensor Locations + * - Configurable Settings (CPP_CTNL_PT_SET codes) + * - Offset Compensation + * - Server allows to be requested for parameters (CPP_CTNL_PT_REQ codes) + */ + if ((CPPS_IS_FEATURE_SUPPORTED(params->prfl_config, + CPPS_CTNL_PT_CHAR_SUPP_FLAG)) || + (CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, + CPP_FEAT_WHEEL_REV_DATA_SUPP)) || + (CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, + CPP_FEAT_MULT_SENSOR_LOC_SUPP)) || + (CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, + CPP_FEAT_CRANK_LENGTH_ADJ_SUPP)) || + (CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, + CPP_FEAT_CHAIN_LENGTH_ADJ_SUPP)) || + (CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, + CPP_FEAT_CHAIN_WEIGHT_ADJ_SUPP)) || + (CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, + CPP_FEAT_SPAN_LENGTH_ADJ_SUPP)) || + (CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, + CPP_FEAT_OFFSET_COMP_SUPP))) { + cfg_flag |= CPPS_CTNL_PT_MASK; + } + + // Add service in the database + status = attm_svc_create_db( + start_hdl, ATT_SVC_CYCLING_POWER, (uint8_t *)&cfg_flag, CPS_IDX_NB, NULL, + env->task, &cpps_att_db[0], + (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, DISABLE)); + + //-------------------- allocate memory required for the profile + //--------------------- + if (status == ATT_ERR_NO_ERROR) { + // Allocate CPPS required environment variable + struct cpps_env_tag *cpps_env = (struct cpps_env_tag *)ke_malloc( + sizeof(struct cpps_env_tag), KE_MEM_ATT_DB); + + // Initialize CPPS environment + env->env = (prf_env_t *)cpps_env; + cpps_env->shdl = *start_hdl; + cpps_env->prfl_cfg = cfg_flag; + cpps_env->features = params->cp_feature; + cpps_env->sensor_loc = params->sensor_loc; + cpps_env->cumul_wheel_rev = params->wheel_rev; + cpps_env->operation = CPPS_RESERVED_OP_CODE; + + cpps_env->op_data = NULL; + memset(cpps_env->env, 0, sizeof(cpps_env->env)); + + cpps_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + // Mono Instantiated task + cpps_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); + + // initialize environment variable + env->id = TASK_ID_CPPS; + cpps_task_init(&(env->desc)); /* - * Check if Broadcaster role shall be added. + * Check if the Broadcaster role shall be added. */ - if(CPPS_IS_FEATURE_SUPPORTED(params->prfl_config, CPPS_BROADCASTER_SUPP_FLAG)) - { - //Add configuration to the database - cfg_flag |= CPPS_MEAS_BCST_MASK; - } - /* - * Check if the CP Vector characteristic shall be added. - * Mandatory if at least one Vector procedure is supported, otherwise excluded. - */ - if ((CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, CPP_FEAT_CRANK_REV_DATA_SUPP)) || - (CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, CPP_FEAT_EXTREME_ANGLES_SUPP)) || - (CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, CPP_FEAT_INSTANT_MEAS_DIRECTION_SUPP))) - { - cfg_flag |= CPPS_VECTOR_MASK; - } - /* - * Check if the Control Point characteristic shall be added - * Mandatory if server supports: - * - Wheel Revolution Data - * - Multiple Sensor Locations - * - Configurable Settings (CPP_CTNL_PT_SET codes) - * - Offset Compensation - * - Server allows to be requested for parameters (CPP_CTNL_PT_REQ codes) - */ - if ((CPPS_IS_FEATURE_SUPPORTED(params->prfl_config, CPPS_CTNL_PT_CHAR_SUPP_FLAG)) || - (CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, CPP_FEAT_WHEEL_REV_DATA_SUPP)) || - (CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, CPP_FEAT_MULT_SENSOR_LOC_SUPP)) || - (CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, CPP_FEAT_CRANK_LENGTH_ADJ_SUPP)) || - (CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, CPP_FEAT_CHAIN_LENGTH_ADJ_SUPP)) || - (CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, CPP_FEAT_CHAIN_WEIGHT_ADJ_SUPP)) || - (CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, CPP_FEAT_SPAN_LENGTH_ADJ_SUPP)) || - (CPPS_IS_FEATURE_SUPPORTED(params->cp_feature, CPP_FEAT_OFFSET_COMP_SUPP))) - { - cfg_flag |= CPPS_CTNL_PT_MASK; + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->prfl_cfg, CPPS_MEAS_BCST_MASK)) { + // Optional Permissions + uint16_t perm = PERM(NTF, ENABLE) | PERM(BROADCAST, ENABLE); + // Add configuration to the database + attm_att_set_permission(CPPS_HANDLE(CPS_IDX_CP_MEAS_VAL), perm, 0); } - // Add service in the database - status = attm_svc_create_db(start_hdl, ATT_SVC_CYCLING_POWER, (uint8_t *)&cfg_flag, - CPS_IDX_NB, NULL, env->task, &cpps_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | PERM(SVC_MI, DISABLE)); + /* Put CPS in Idle state */ + ke_state_set(env->task, CPPS_IDLE); + } - //-------------------- allocate memory required for the profile --------------------- - if (status == ATT_ERR_NO_ERROR) - { - // Allocate CPPS required environment variable - struct cpps_env_tag* cpps_env = - (struct cpps_env_tag* ) ke_malloc(sizeof(struct cpps_env_tag), KE_MEM_ATT_DB); - - // Initialize CPPS environment - env->env = (prf_env_t*) cpps_env; - cpps_env->shdl = *start_hdl; - cpps_env->prfl_cfg = cfg_flag; - cpps_env->features = params->cp_feature; - cpps_env->sensor_loc = params->sensor_loc; - cpps_env->cumul_wheel_rev = params->wheel_rev; - cpps_env->operation = CPPS_RESERVED_OP_CODE; - - cpps_env->op_data = NULL; - memset(cpps_env->env, 0, sizeof(cpps_env->env)); - - cpps_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - // Mono Instantiated task - cpps_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); - - // initialize environment variable - env->id = TASK_ID_CPPS; - cpps_task_init(&(env->desc)); - - /* - * Check if the Broadcaster role shall be added. - */ - if(CPPS_IS_FEATURE_SUPPORTED(cpps_env->prfl_cfg, CPPS_MEAS_BCST_MASK)) - { - // Optional Permissions - uint16_t perm = PERM(NTF, ENABLE) | PERM(BROADCAST,ENABLE); - //Add configuration to the database - attm_att_set_permission(CPPS_HANDLE(CPS_IDX_CP_MEAS_VAL), perm, 0); - } - - /* Put CPS in Idle state */ - ke_state_set(env->task, CPPS_IDLE); - } - - return (status); + return (status); } /** **************************************************************************************** * @brief Destruction of the CPPS module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void cpps_destroy(struct prf_task_env* env) -{ - struct cpps_env_tag* cpps_env = (struct cpps_env_tag*) env->env; +static void cpps_destroy(struct prf_task_env *env) { + struct cpps_env_tag *cpps_env = (struct cpps_env_tag *)env->env; - if (cpps_env->op_data != NULL) - { - ke_free(cpps_env->op_data->cmd); - if(cpps_env->op_data->ntf_pending) - { - ke_free(cpps_env->op_data->ntf_pending); - } - ke_free(cpps_env->op_data); + if (cpps_env->op_data != NULL) { + ke_free(cpps_env->op_data->cmd); + if (cpps_env->op_data->ntf_pending) { + ke_free(cpps_env->op_data->ntf_pending); } + ke_free(cpps_env->op_data); + } - // free profile environment variables - env->env = NULL; - ke_free(cpps_env); + // free profile environment variables + env->env = NULL; + ke_free(cpps_env); } /** @@ -231,11 +260,10 @@ static void cpps_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void cpps_create(struct prf_task_env* env, uint8_t conidx) -{ - struct cpps_env_tag* cpps_env = (struct cpps_env_tag*) env->env; +static void cpps_create(struct prf_task_env *env, uint8_t conidx) { + struct cpps_env_tag *cpps_env = (struct cpps_env_tag *)env->env; - memset(&(cpps_env->env[conidx]), 0, sizeof(struct cpps_cnx_env)); + memset(&(cpps_env->env[conidx]), 0, sizeof(struct cpps_cnx_env)); } /** @@ -247,12 +275,12 @@ static void cpps_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void cpps_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct cpps_env_tag* cpps_env = (struct cpps_env_tag*) env->env; +static void cpps_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct cpps_env_tag *cpps_env = (struct cpps_env_tag *)env->env; - // clean-up environment variable allocated for task instance - memset(&(cpps_env->env[conidx]), 0, sizeof(struct cpps_cnx_env)); + // clean-up environment variable allocated for task instance + memset(&(cpps_env->env[conidx]), 0, sizeof(struct cpps_cnx_env)); } /* @@ -261,12 +289,11 @@ static void cpps_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reaso */ /// CPPS Task interface required by profile manager -const struct prf_task_cbs cpps_itf = -{ - (prf_init_fnct) cpps_init, - cpps_destroy, - cpps_create, - cpps_cleanup, +const struct prf_task_cbs cpps_itf = { + (prf_init_fnct)cpps_init, + cpps_destroy, + cpps_create, + cpps_cleanup, }; /* @@ -274,1177 +301,1056 @@ const struct prf_task_cbs cpps_itf = **************************************************************************************** */ -const struct prf_task_cbs* cpps_prf_itf_get(void) -{ - return &cpps_itf; +const struct prf_task_cbs *cpps_prf_itf_get(void) { return &cpps_itf; } + +uint8_t cpps_pack_meas_ntf(struct cpp_cp_meas *param, uint8_t *pckd_meas) { + // Packed Measurement length + uint8_t pckd_meas_len = CPP_CP_MEAS_NTF_MIN_LEN; + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); + + // Check provided flags + if (CPPS_IS_PRESENT(param->flags, CPP_MEAS_PEDAL_POWER_BALANCE_PRESENT)) { + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_PEDAL_POWER_BALANCE_SUPP)) { + // Pack Pedal Power Balance info + pckd_meas[pckd_meas_len] = param->pedal_power_balance; + pckd_meas_len++; + } else // Not supported by the profile + { + // Force to not supported + param->flags &= ~CPP_MEAS_PEDAL_POWER_BALANCE_PRESENT; + } + } + + if (CPPS_IS_PRESENT(param->flags, CPP_MEAS_ACCUM_TORQUE_PRESENT)) { + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_ACCUM_TORQUE_SUPP)) { + // Pack Accumulated Torque info + co_write16p(&pckd_meas[pckd_meas_len], param->accum_torque); + pckd_meas_len += 2; + } else // Not supported by the profile + { + // Force to not supported + param->flags &= ~CPP_MEAS_ACCUM_TORQUE_PRESENT; + } + } + + if (CPPS_IS_PRESENT(param->flags, CPP_MEAS_WHEEL_REV_DATA_PRESENT)) { + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_WHEEL_REV_DATA_SUPP)) { + // Pack Wheel Revolution Data (Cumulative Wheel & Last Wheel Event Time) + co_write32p(&pckd_meas[pckd_meas_len], cpps_env->cumul_wheel_rev); + pckd_meas_len += 4; + co_write16p(&pckd_meas[pckd_meas_len], param->last_wheel_evt_time); + pckd_meas_len += 2; + } else // Not supported by the profile + { + // Force to not supported + param->flags &= ~CPP_MEAS_WHEEL_REV_DATA_PRESENT; + } + } + + if (CPPS_IS_PRESENT(param->flags, CPP_MEAS_CRANK_REV_DATA_PRESENT)) { + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_CRANK_REV_DATA_SUPP)) { + // Pack Crank Revolution Data (Cumulative Crank & Last Crank Event Time) + co_write16p(&pckd_meas[pckd_meas_len], param->cumul_crank_rev); + pckd_meas_len += 2; + co_write16p(&pckd_meas[pckd_meas_len], param->last_crank_evt_time); + pckd_meas_len += 2; + } else // Not supported by the profile + { + // Force to not supported + param->flags &= ~CPP_MEAS_CRANK_REV_DATA_PRESENT; + } + } + + if (CPPS_IS_PRESENT(param->flags, + CPP_MEAS_EXTREME_FORCE_MAGNITUDES_PRESENT)) { + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_EXTREME_MAGNITUDES_SUPP) && + CPPS_IS_CLEAR(cpps_env->features, CPP_FEAT_SENSOR_MEAS_CONTEXT)) { + // Pack Extreme Force Magnitudes (Maximum Force Magnitude & Minimum Force + // Magnitude) + co_write16p(&pckd_meas[pckd_meas_len], param->max_force_magnitude); + pckd_meas_len += 2; + co_write16p(&pckd_meas[pckd_meas_len], param->min_force_magnitude); + pckd_meas_len += 2; + } else // Not supported by the profile + { + // Force to not supported + param->flags &= ~CPP_MEAS_EXTREME_FORCE_MAGNITUDES_PRESENT; + } + } + + if (CPPS_IS_PRESENT(param->flags, + CPP_MEAS_EXTREME_TORQUE_MAGNITUDES_PRESENT)) { + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_EXTREME_MAGNITUDES_SUPP) && + CPPS_IS_SET(cpps_env->features, CPP_FEAT_SENSOR_MEAS_CONTEXT)) { + // Pack Extreme Force Magnitudes (Maximum Force Magnitude & Minimum Force + // Magnitude) + co_write16p(&pckd_meas[pckd_meas_len], param->max_torque_magnitude); + pckd_meas_len += 2; + co_write16p(&pckd_meas[pckd_meas_len], param->min_torque_magnitude); + pckd_meas_len += 2; + } else // Not supported by the profile + { + // Force to not supported + param->flags &= ~CPP_MEAS_EXTREME_TORQUE_MAGNITUDES_PRESENT; + } + } + + if (CPPS_IS_PRESENT(param->flags, CPP_MEAS_EXTREME_ANGLES_PRESENT)) { + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_EXTREME_ANGLES_SUPP)) { + // Pack Extreme Angles (Maximum Angle & Minimum Angle) + // Force to 12 bits + param->max_angle &= 0x0FFF; + param->min_angle &= 0x0FFF; + uint32_t angle = (uint32_t)(param->max_angle | (param->min_angle << 12)); + co_write24p(&pckd_meas[pckd_meas_len], angle); + pckd_meas_len += 3; + + } else // Not supported by the profile + { + // Force to not supported + param->flags &= ~CPP_MEAS_EXTREME_ANGLES_PRESENT; + } + } + + if (CPPS_IS_PRESENT(param->flags, CPP_MEAS_TOP_DEAD_SPOT_ANGLE_PRESENT)) { + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_TOPBOT_DEAD_SPOT_ANGLES_SUPP)) { + // Pack Top Dead Spot Angle + co_write16p(&pckd_meas[pckd_meas_len], param->top_dead_spot_angle); + pckd_meas_len += 2; + } else { + // Force to not supported + param->flags &= ~CPP_MEAS_TOP_DEAD_SPOT_ANGLE_PRESENT; + } + } + + if (CPPS_IS_PRESENT(param->flags, CPP_MEAS_BOTTOM_DEAD_SPOT_ANGLE_PRESENT)) { + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_TOPBOT_DEAD_SPOT_ANGLES_SUPP)) { + // Pack Bottom Dead Spot Angle + co_write16p(&pckd_meas[pckd_meas_len], param->bot_dead_spot_angle); + pckd_meas_len += 2; + } else { + // Force to not supported + param->flags &= ~CPP_MEAS_BOTTOM_DEAD_SPOT_ANGLE_PRESENT; + } + } + + if (CPPS_IS_PRESENT(param->flags, CPP_MEAS_ACCUM_ENERGY_PRESENT)) { + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_ACCUM_ENERGY_SUPP)) { + // Pack Accumulated Energy + co_write16p(&pckd_meas[pckd_meas_len], param->accum_energy); + pckd_meas_len += 2; + } else { + // Force to not supported + param->flags &= ~CPP_MEAS_ACCUM_ENERGY_PRESENT; + } + } + + // Allow to use reserved flags according to PTS Test + // param->flags &= CPP_MEAS_ALL_SUPP; + // Flags value + co_write16p(&pckd_meas[0], param->flags); + // Instant Power (Mandatory) + co_write16p(&pckd_meas[2], param->inst_power); + + return pckd_meas_len; } -uint8_t cpps_pack_meas_ntf(struct cpp_cp_meas *param, uint8_t *pckd_meas) -{ - // Packed Measurement length - uint8_t pckd_meas_len = CPP_CP_MEAS_NTF_MIN_LEN; - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); +uint8_t cpps_split_meas_ntf(uint8_t conidx, + struct gattc_send_evt_cmd *meas_ntf1) { + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); + // Extract flags info + uint16_t flags = co_read16p(&meas_ntf1->value[0]); + // Allocate the GATT notification message + struct gattc_send_evt_cmd *meas_ntf2 = + KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&cpps_env->prf_env, conidx), + gattc_send_evt_cmd, CPP_CP_MEAS_NTF_MAX_LEN); - // Check provided flags - if (CPPS_IS_PRESENT(param->flags, CPP_MEAS_PEDAL_POWER_BALANCE_PRESENT)) - { - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_PEDAL_POWER_BALANCE_SUPP)) - { - //Pack Pedal Power Balance info - pckd_meas[pckd_meas_len] = param->pedal_power_balance; - pckd_meas_len++; - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~CPP_MEAS_PEDAL_POWER_BALANCE_PRESENT; - } + // Fill in the parameter structure + meas_ntf2->operation = GATTC_NOTIFY; + meas_ntf2->handle = CPPS_HANDLE(CPS_IDX_CP_MEAS_VAL); + meas_ntf2->length = CPP_CP_MEAS_NTF_MIN_LEN; + + // Copy status flags + co_write16p(&meas_ntf2->value[0], + (flags & (CPP_MEAS_PEDAL_POWER_BALANCE_REFERENCE | + CPP_MEAS_ACCUM_TORQUE_SOURCE | + CPP_MEAS_OFFSET_COMPENSATION_INDICATOR))); + // Copy Instantaneous power + memcpy(&meas_ntf2->value[2], &meas_ntf1->value[2], 2); + + // Current position + uint8_t len = 0; + + for (uint16_t feat = CPP_MEAS_PEDAL_POWER_BALANCE_PRESENT; + feat <= CPP_MEAS_OFFSET_COMPENSATION_INDICATOR; feat <<= 1) { + // First message fits within the MTU + if (meas_ntf1->length <= gattc_get_mtu(conidx) - 3) { + // Stop splitting + break; } - if (CPPS_IS_PRESENT(param->flags, CPP_MEAS_ACCUM_TORQUE_PRESENT)) - { - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_ACCUM_TORQUE_SUPP)) - { - //Pack Accumulated Torque info - co_write16p(&pckd_meas[pckd_meas_len], param->accum_torque); - pckd_meas_len += 2; - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~CPP_MEAS_ACCUM_TORQUE_PRESENT; - } + if (CPPS_IS_PRESENT(flags, feat)) { + switch (feat) { + case CPP_MEAS_PEDAL_POWER_BALANCE_PRESENT: + // Copy uint8 + meas_ntf2->value[meas_ntf2->length] = + meas_ntf1->value[CPP_CP_MEAS_NTF_MIN_LEN]; + len = 1; + break; + + case CPP_MEAS_ACCUM_TORQUE_PRESENT: + case CPP_MEAS_TOP_DEAD_SPOT_ANGLE_PRESENT: + case CPP_MEAS_ACCUM_ENERGY_PRESENT: + case CPP_MEAS_BOTTOM_DEAD_SPOT_ANGLE_PRESENT: + // Copy uint16 + memcpy(&meas_ntf2->value[meas_ntf2->length], + &meas_ntf1->value[CPP_CP_MEAS_NTF_MIN_LEN], 2); + len = 2; + break; + + case CPP_MEAS_EXTREME_ANGLES_PRESENT: + // Copy uint24 + memcpy(&meas_ntf2->value[meas_ntf2->length], + &meas_ntf1->value[CPP_CP_MEAS_NTF_MIN_LEN], 3); + len = 3; + break; + + case CPP_MEAS_CRANK_REV_DATA_PRESENT: + case CPP_MEAS_EXTREME_FORCE_MAGNITUDES_PRESENT: + case CPP_MEAS_EXTREME_TORQUE_MAGNITUDES_PRESENT: + // Copy uint16 + uint16 + memcpy(&meas_ntf2->value[meas_ntf2->length], + &meas_ntf1->value[CPP_CP_MEAS_NTF_MIN_LEN], 4); + len = 4; + break; + + case CPP_MEAS_WHEEL_REV_DATA_PRESENT: + // Copy uint32 + uint16 + memcpy(&meas_ntf2->value[meas_ntf2->length], + &meas_ntf1->value[CPP_CP_MEAS_NTF_MIN_LEN], 6); + len = 6; + break; + + default: + len = 0; + break; + } + + if (len) { + // Update values + meas_ntf2->length += len; + // Remove field and flags from the first ntf + meas_ntf1->length -= len; + memcpy(&meas_ntf1->value[CPP_CP_MEAS_NTF_MIN_LEN], + &meas_ntf1->value[CPP_CP_MEAS_NTF_MIN_LEN + len], + meas_ntf1->length); + // Update flags + meas_ntf1->value[0] &= ~feat; + meas_ntf2->value[0] |= feat; + } } + } - if (CPPS_IS_PRESENT(param->flags, CPP_MEAS_WHEEL_REV_DATA_PRESENT)) - { - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_WHEEL_REV_DATA_SUPP)) - { - //Pack Wheel Revolution Data (Cumulative Wheel & Last Wheel Event Time) - co_write32p(&pckd_meas[pckd_meas_len], cpps_env->cumul_wheel_rev); - pckd_meas_len += 4; - co_write16p(&pckd_meas[pckd_meas_len], param->last_wheel_evt_time); - pckd_meas_len += 2; - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~CPP_MEAS_WHEEL_REV_DATA_PRESENT; - } - } + // store the pending notification to send + cpps_env->op_data->ntf_pending = meas_ntf2; - if (CPPS_IS_PRESENT(param->flags, CPP_MEAS_CRANK_REV_DATA_PRESENT)) - { - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_CRANK_REV_DATA_SUPP)) - { - //Pack Crank Revolution Data (Cumulative Crank & Last Crank Event Time) - co_write16p(&pckd_meas[pckd_meas_len], param->cumul_crank_rev); - pckd_meas_len += 2; - co_write16p(&pckd_meas[pckd_meas_len], param->last_crank_evt_time); - pckd_meas_len += 2; - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~CPP_MEAS_CRANK_REV_DATA_PRESENT; - } - } - - if (CPPS_IS_PRESENT(param->flags, CPP_MEAS_EXTREME_FORCE_MAGNITUDES_PRESENT)) - { - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_EXTREME_MAGNITUDES_SUPP) - && CPPS_IS_CLEAR(cpps_env->features, CPP_FEAT_SENSOR_MEAS_CONTEXT)) - { - //Pack Extreme Force Magnitudes (Maximum Force Magnitude & Minimum Force Magnitude) - co_write16p(&pckd_meas[pckd_meas_len], param->max_force_magnitude); - pckd_meas_len += 2; - co_write16p(&pckd_meas[pckd_meas_len], param->min_force_magnitude); - pckd_meas_len += 2; - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~CPP_MEAS_EXTREME_FORCE_MAGNITUDES_PRESENT; - } - } - - if (CPPS_IS_PRESENT(param->flags, CPP_MEAS_EXTREME_TORQUE_MAGNITUDES_PRESENT)) - { - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_EXTREME_MAGNITUDES_SUPP) - && CPPS_IS_SET(cpps_env->features, CPP_FEAT_SENSOR_MEAS_CONTEXT)) - { - //Pack Extreme Force Magnitudes (Maximum Force Magnitude & Minimum Force Magnitude) - co_write16p(&pckd_meas[pckd_meas_len], param->max_torque_magnitude); - pckd_meas_len += 2; - co_write16p(&pckd_meas[pckd_meas_len], param->min_torque_magnitude); - pckd_meas_len += 2; - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~CPP_MEAS_EXTREME_TORQUE_MAGNITUDES_PRESENT; - } - } - - if (CPPS_IS_PRESENT(param->flags, CPP_MEAS_EXTREME_ANGLES_PRESENT)) - { - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_EXTREME_ANGLES_SUPP)) - { - //Pack Extreme Angles (Maximum Angle & Minimum Angle) - //Force to 12 bits - param->max_angle &= 0x0FFF; - param->min_angle &= 0x0FFF; - uint32_t angle = (uint32_t) (param->max_angle | (param->min_angle<<12)); - co_write24p(&pckd_meas[pckd_meas_len], angle); - pckd_meas_len += 3; - - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~CPP_MEAS_EXTREME_ANGLES_PRESENT; - } - } - - if (CPPS_IS_PRESENT(param->flags, CPP_MEAS_TOP_DEAD_SPOT_ANGLE_PRESENT)) - { - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_TOPBOT_DEAD_SPOT_ANGLES_SUPP)) - { - //Pack Top Dead Spot Angle - co_write16p(&pckd_meas[pckd_meas_len], param->top_dead_spot_angle); - pckd_meas_len += 2; - } - else - { - //Force to not supported - param->flags &= ~CPP_MEAS_TOP_DEAD_SPOT_ANGLE_PRESENT; - } - } - - if (CPPS_IS_PRESENT(param->flags, CPP_MEAS_BOTTOM_DEAD_SPOT_ANGLE_PRESENT)) - { - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_TOPBOT_DEAD_SPOT_ANGLES_SUPP)) - { - //Pack Bottom Dead Spot Angle - co_write16p(&pckd_meas[pckd_meas_len], param->bot_dead_spot_angle); - pckd_meas_len += 2; - } - else - { - //Force to not supported - param->flags &= ~CPP_MEAS_BOTTOM_DEAD_SPOT_ANGLE_PRESENT; - } - } - - if (CPPS_IS_PRESENT(param->flags, CPP_MEAS_ACCUM_ENERGY_PRESENT)) - { - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_ACCUM_ENERGY_SUPP)) - { - //Pack Accumulated Energy - co_write16p(&pckd_meas[pckd_meas_len], param->accum_energy); - pckd_meas_len += 2; - } - else - { - //Force to not supported - param->flags &= ~CPP_MEAS_ACCUM_ENERGY_PRESENT; - } - } - - // Allow to use reserved flags according to PTS Test - //param->flags &= CPP_MEAS_ALL_SUPP; - // Flags value - co_write16p(&pckd_meas[0], param->flags); - //Instant Power (Mandatory) - co_write16p(&pckd_meas[2], param->inst_power); - - return pckd_meas_len; + return meas_ntf2->length; } -uint8_t cpps_split_meas_ntf(uint8_t conidx, struct gattc_send_evt_cmd *meas_ntf1) -{ - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - // Extract flags info - uint16_t flags = co_read16p(&meas_ntf1->value[0]); - // Allocate the GATT notification message - struct gattc_send_evt_cmd *meas_ntf2 = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(&cpps_env->prf_env, conidx), - gattc_send_evt_cmd, CPP_CP_MEAS_NTF_MAX_LEN); +uint8_t +cpps_update_characteristic_config(uint8_t conidx, uint8_t prfl_config, + struct gattc_write_req_ind const *param) { + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - // Fill in the parameter structure - meas_ntf2->operation = GATTC_NOTIFY; - meas_ntf2->handle = CPPS_HANDLE(CPS_IDX_CP_MEAS_VAL); - meas_ntf2->length = CPP_CP_MEAS_NTF_MIN_LEN; + // Status + uint8_t status = GAP_ERR_NO_ERROR; + // Get the value + uint16_t ntf_cfg = co_read16p(¶m->value[0]); - // Copy status flags - co_write16p(&meas_ntf2->value[0], (flags & (CPP_MEAS_PEDAL_POWER_BALANCE_REFERENCE | - CPP_MEAS_ACCUM_TORQUE_SOURCE | - CPP_MEAS_OFFSET_COMPENSATION_INDICATOR))); - // Copy Instantaneous power - memcpy(&meas_ntf2->value[2], &meas_ntf1->value[2], 2); - - // Current position - uint8_t len = 0; - - for (uint16_t feat = CPP_MEAS_PEDAL_POWER_BALANCE_PRESENT; - feat <= CPP_MEAS_OFFSET_COMPENSATION_INDICATOR; - feat <<= 1) - { - // First message fits within the MTU - if (meas_ntf1->length <= gattc_get_mtu(conidx) - 3) - { - // Stop splitting - break; - } - - if (CPPS_IS_PRESENT(flags, feat)) - { - switch (feat) - { - case CPP_MEAS_PEDAL_POWER_BALANCE_PRESENT: - // Copy uint8 - meas_ntf2->value[meas_ntf2->length] = meas_ntf1->value[CPP_CP_MEAS_NTF_MIN_LEN]; - len = 1; - break; - - case CPP_MEAS_ACCUM_TORQUE_PRESENT: - case CPP_MEAS_TOP_DEAD_SPOT_ANGLE_PRESENT: - case CPP_MEAS_ACCUM_ENERGY_PRESENT: - case CPP_MEAS_BOTTOM_DEAD_SPOT_ANGLE_PRESENT: - // Copy uint16 - memcpy(&meas_ntf2->value[meas_ntf2->length], &meas_ntf1->value[CPP_CP_MEAS_NTF_MIN_LEN], 2); - len = 2; - break; - - case CPP_MEAS_EXTREME_ANGLES_PRESENT: - // Copy uint24 - memcpy(&meas_ntf2->value[meas_ntf2->length], &meas_ntf1->value[CPP_CP_MEAS_NTF_MIN_LEN], 3); - len = 3; - break; - - case CPP_MEAS_CRANK_REV_DATA_PRESENT: - case CPP_MEAS_EXTREME_FORCE_MAGNITUDES_PRESENT: - case CPP_MEAS_EXTREME_TORQUE_MAGNITUDES_PRESENT: - // Copy uint16 + uint16 - memcpy(&meas_ntf2->value[meas_ntf2->length], &meas_ntf1->value[CPP_CP_MEAS_NTF_MIN_LEN], 4); - len = 4; - break; - - case CPP_MEAS_WHEEL_REV_DATA_PRESENT: - // Copy uint32 + uint16 - memcpy(&meas_ntf2->value[meas_ntf2->length], &meas_ntf1->value[CPP_CP_MEAS_NTF_MIN_LEN], 6); - len = 6; - break; - - default: - len = 0; - break; - } - - if (len) - { - // Update values - meas_ntf2->length += len; - // Remove field and flags from the first ntf - meas_ntf1->length -= len; - memcpy(&meas_ntf1->value[CPP_CP_MEAS_NTF_MIN_LEN], - &meas_ntf1->value[CPP_CP_MEAS_NTF_MIN_LEN + len], - meas_ntf1->length); - // Update flags - meas_ntf1->value[0] &= ~feat; - meas_ntf2->value[0] |= feat; - } - } + switch (prfl_config) { + case CPP_PRF_CFG_FLAG_CTNL_PT_IND: + // Check CCC configuration + if ((ntf_cfg == PRF_CLI_STOP_NTFIND) || (ntf_cfg == PRF_CLI_START_IND)) { + // Save the new configuration in the environment + (ntf_cfg == PRF_CLI_STOP_NTFIND) + ? CPPS_DISABLE_NTF_IND_BCST(conidx, prfl_config) + : CPPS_ENABLE_NTF_IND_BCST(conidx, prfl_config); + } else { + status = PRF_ERR_INVALID_PARAM; } + break; - // store the pending notification to send - cpps_env->op_data->ntf_pending = meas_ntf2; + case CPP_PRF_CFG_FLAG_VECTOR_NTF: + // Do not save until confirmation + break; - return meas_ntf2->length; -} + case CPP_PRF_CFG_FLAG_SP_MEAS_NTF: + // Check CCC configuration + if ((ntf_cfg == PRF_SRV_STOP_BCST) || (ntf_cfg == PRF_SRV_START_BCST)) { + // Save the new configuration in the environment + cpps_env->broadcast_enabled = + (ntf_cfg == PRF_SRV_STOP_BCST) ? false : true; -uint8_t cpps_update_characteristic_config(uint8_t conidx, uint8_t prfl_config, struct gattc_write_req_ind const *param) -{ - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - - // Status - uint8_t status = GAP_ERR_NO_ERROR; - // Get the value - uint16_t ntf_cfg = co_read16p(¶m->value[0]); - - switch (prfl_config) - { - case CPP_PRF_CFG_FLAG_CTNL_PT_IND: - // Check CCC configuration - if ((ntf_cfg == PRF_CLI_STOP_NTFIND) || (ntf_cfg == PRF_CLI_START_IND)) - { - // Save the new configuration in the environment - (ntf_cfg == PRF_CLI_STOP_NTFIND) ? - CPPS_DISABLE_NTF_IND_BCST(conidx, prfl_config) : CPPS_ENABLE_NTF_IND_BCST(conidx, prfl_config); - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - break; - - case CPP_PRF_CFG_FLAG_VECTOR_NTF: - // Do not save until confirmation - break; - - case CPP_PRF_CFG_FLAG_SP_MEAS_NTF: - // Check CCC configuration - if ((ntf_cfg == PRF_SRV_STOP_BCST) || (ntf_cfg == PRF_SRV_START_BCST)) - { - // Save the new configuration in the environment - cpps_env->broadcast_enabled = (ntf_cfg == PRF_SRV_STOP_BCST) ? - false : true; - - // Update value for every connection (useful for bond data) - for (uint8_t i=0; iprf_env, conidx), prf_src_task_get(&cpps_env->prf_env, conidx), - cpps_vector_cfg_req_ind); - //Inform APP of configuration change - ind->char_code = prfl_config; - ind->ntf_cfg = ntf_cfg; - ind->conidx = conidx; - ke_msg_send(ind); - } - else - { - // Allocate message to inform application - struct cpps_cfg_ntfind_ind *ind = KE_MSG_ALLOC(CPPS_CFG_NTFIND_IND, - prf_dst_task_get(&cpps_env->prf_env, conidx), prf_src_task_get(&cpps_env->prf_env, conidx), - cpps_cfg_ntfind_ind); - //Inform APP of configuration change - ind->char_code = prfl_config; - ind->ntf_cfg = ntf_cfg; - ind->conidx = conidx; - ke_msg_send(ind); - } - // Enable Bonded Data - CPPS_ENABLE_NTF_IND_BCST(conidx, CPP_PRF_CFG_PERFORMED_OK); - } - return (status); -} - -uint8_t cpps_pack_vector_ntf(struct cpp_cp_vector *param, uint8_t *pckd_vector) -{ - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - // Packed Measurement length - uint8_t pckd_vector_len = CPP_CP_VECTOR_MIN_LEN; - - // Check provided flags - if (CPPS_IS_PRESENT(param->flags, CPP_VECTOR_CRANK_REV_DATA_PRESENT)) - { - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_CRANK_REV_DATA_SUPP)) - { - //Pack Crank Revolution Data (Cumulative Crank & Last Crank Event Time) - co_write16p(&pckd_vector[pckd_vector_len], param->cumul_crank_rev); - pckd_vector_len += 2; - co_write16p(&pckd_vector[pckd_vector_len], param->last_crank_evt_time); - pckd_vector_len += 2; - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~CPP_VECTOR_CRANK_REV_DATA_PRESENT; - } - } - - if (CPPS_IS_PRESENT(param->flags, CPP_VECTOR_FIRST_CRANK_MEAS_ANGLE_PRESENT)) - { - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_EXTREME_ANGLES_SUPP)) - { - //Pack First Crank Measurement Angle - co_write16p(&pckd_vector[pckd_vector_len], param->first_crank_meas_angle); - pckd_vector_len += 2; - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~CPP_VECTOR_FIRST_CRANK_MEAS_ANGLE_PRESENT; - } - } - - if (CPPS_IS_PRESENT(param->flags, CPP_VECTOR_INST_FORCE_MAGNITUDE_ARRAY_PRESENT)) - { - if (CPPS_IS_CLEAR(cpps_env->features, CPP_FEAT_SENSOR_MEAS_CONTEXT)) - { - //Pack Instantaneous Force Magnitude Array - if ((param->nb > CPP_CP_VECTOR_MIN_LEN) && - (param->nb <= CPP_CP_VECTOR_MAX_LEN - pckd_vector_len)) - { - for(int j=0; jnb; j++) - { - co_write16p(&pckd_vector[pckd_vector_len], param->force_torque_magnitude[j]); - pckd_vector_len += 2; - } - } - else - { - return 0; - } - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~CPP_VECTOR_INST_FORCE_MAGNITUDE_ARRAY_PRESENT; - } - } - - if (CPPS_IS_PRESENT(param->flags, CPP_VECTOR_INST_TORQUE_MAGNITUDE_ARRAY_PRESENT)) - { - if (CPPS_IS_SET(cpps_env->features, CPP_FEAT_SENSOR_MEAS_CONTEXT)) - { - //Pack Instantaneous Torque Magnitude Array - if ((param->nb > CPP_CP_VECTOR_MIN_LEN) && - (param->nb <= CPP_CP_VECTOR_MAX_LEN - pckd_vector_len)) - { - for(int j=0; jnb; j++) - { - co_write16p(&pckd_vector[pckd_vector_len], param->force_torque_magnitude[j]); - pckd_vector_len += 2; - } - } - else - { - return 0; - } - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~CPP_VECTOR_INST_TORQUE_MAGNITUDE_ARRAY_PRESENT; - } - } - - // Allow to use reserved flags - //param->flags &= CPP_VECTOR_ALL_SUPP; - // Flags value - pckd_vector[0] = param->flags; - - return pckd_vector_len; -} - -void cpps_send_rsp_ind(uint8_t conidx, uint8_t req_op_code, uint8_t status) -{ - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - - // Allocate the GATT notification message - struct gattc_send_evt_cmd *ctl_pt_rsp = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), - prf_src_task_get(&cpps_env->prf_env, conidx), - gattc_send_evt_cmd, CPP_CP_CNTL_PT_RSP_MIN_LEN); - - // Fill in the parameter structure - ctl_pt_rsp->operation = GATTC_INDICATE; - ctl_pt_rsp->handle = CPPS_HANDLE(CPS_IDX_CTNL_PT_VAL); - // Pack Control Point confirmation - ctl_pt_rsp->length = CPP_CP_CNTL_PT_RSP_MIN_LEN; - // Response Code - ctl_pt_rsp->value[0] = CPP_CTNL_PT_RSP_CODE; - // Request Operation Code - ctl_pt_rsp->value[1] = req_op_code; - // Response value - ctl_pt_rsp->value[2] = status; - - // Send the event - ke_msg_send(ctl_pt_rsp); -} - -uint8_t cpps_unpack_ctnl_point_ind (uint8_t conidx, struct gattc_write_req_ind const *param) -{ - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - - // Indication Status - uint8_t ind_status = CPP_CTNL_PT_RESP_NOT_SUPP; - - // Allocate a request indication message for the application - struct cpps_ctnl_pt_req_ind *req_ind = KE_MSG_ALLOC(CPPS_CTNL_PT_REQ_IND, - prf_dst_task_get(&cpps_env->prf_env, conidx), prf_src_task_get(&cpps_env->prf_env, conidx), cpps_ctnl_pt_req_ind); - // Operation Code - req_ind->op_code = param->value[0]; - req_ind->conidx = conidx; - - // Operation Code - switch(req_ind->op_code) - { - case (CPP_CTNL_PT_SET_CUMUL_VAL): - { - // Check if the Wheel Revolution Data feature is supported - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_WHEEL_REV_DATA_SUPP)) - { - // Provided parameter in not within the defined range - ind_status = CPP_CTNL_PT_RESP_INV_PARAM; - - if (param->length == 5) - { - // The request can be handled - ind_status = CPP_CTNL_PT_RESP_SUCCESS; - // Update the environment - cpps_env->operation = CPPS_CTNL_PT_SET_CUMUL_VAL_OP_CODE; - // Cumulative value - req_ind->value.cumul_val = co_read32p(¶m->value[1]); - } - } - } break; - - case (CPP_CTNL_PT_UPD_SENSOR_LOC): - { - // Check if the Multiple Sensor Location feature is supported - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_MULT_SENSOR_LOC_SUPP)) - { - // Provided parameter in not within the defined range - ind_status = CPP_CTNL_PT_RESP_INV_PARAM; - - if (param->length == 2) - { - // Check the sensor location value - if (param->value[1] < CPP_LOC_MAX) - { - // The request can be handled - ind_status = CPP_CTNL_PT_RESP_SUCCESS; - // Update the environment - cpps_env->operation = CPPS_CTNL_PT_UPD_SENSOR_LOC_OP_CODE; - // Sensor Location - req_ind->value.sensor_loc = param->value[1]; - } - } - } - } break; - - case (CPP_CTNL_PT_REQ_SUPP_SENSOR_LOC): - { - // Check if the Multiple Sensor Location feature is supported - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_MULT_SENSOR_LOC_SUPP)) - { - // The request can be handled - ind_status = CPP_CTNL_PT_RESP_SUCCESS; - // Update the environment - cpps_env->operation = CPPS_CTNL_PT_REQ_SUPP_SENSOR_LOC_OP_CODE; - } - } break; - - case (CPP_CTNL_PT_SET_CRANK_LENGTH): - { - // Check if the Crank Length Adjustment feature is supported - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_CRANK_LENGTH_ADJ_SUPP)) - { - // Provided parameter in not within the defined range - ind_status = CPP_CTNL_PT_RESP_INV_PARAM; - - if (param->length == 3) - { - // The request can be handled - ind_status = CPP_CTNL_PT_RESP_SUCCESS; - // Update the environment - cpps_env->operation = CPPS_CTNL_PT_SET_CRANK_LENGTH_OP_CODE; - // Crank Length - req_ind->value.crank_length = co_read16p(¶m->value[1]); - } - } - - } break; - - case (CPP_CTNL_PT_REQ_CRANK_LENGTH): - { - // Optional even if feature not supported - ind_status = CPP_CTNL_PT_RESP_SUCCESS; - // Update the environment - cpps_env->operation = CPPS_CTNL_PT_REQ_CRANK_LENGTH_OP_CODE; - } break; - - case (CPP_CTNL_PT_SET_CHAIN_LENGTH): - { - // Check if the Chain Length Adjustment feature is supported - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_CHAIN_LENGTH_ADJ_SUPP)) - { - // Provided parameter in not within the defined range - ind_status = CPP_CTNL_PT_RESP_INV_PARAM; - - if (param->length == 3) - { - // The request can be handled - ind_status = CPP_CTNL_PT_RESP_SUCCESS; - // Update the environment - cpps_env->operation = CPPS_CTNL_PT_SET_CHAIN_LENGTH_OP_CODE; - // Chain Length - req_ind->value.crank_length = co_read16p(¶m->value[1]); - } - } - - } break; - - case (CPP_CTNL_PT_REQ_CHAIN_LENGTH): - { - // Optional even if feature not supported - ind_status = CPP_CTNL_PT_RESP_SUCCESS; - // Update the environment - cpps_env->operation = CPPS_CTNL_PT_REQ_CHAIN_LENGTH_OP_CODE; - } break; - - case (CPP_CTNL_PT_SET_CHAIN_WEIGHT): - { - // Check if the Chain Weight Adjustment feature is supported - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_CHAIN_WEIGHT_ADJ_SUPP)) - { - // Provided parameter in not within the defined range - ind_status = CPP_CTNL_PT_RESP_INV_PARAM; - - if (param->length == 3) - { - // The request can be handled - ind_status = CPP_CTNL_PT_RESP_SUCCESS; - // Update the environment - cpps_env->operation = CPPS_CTNL_PT_SET_CHAIN_WEIGHT_OP_CODE; - // Chain Weight - req_ind->value.chain_weight = co_read16p(¶m->value[1]); - } - } - - } break; - - case (CPP_CTNL_PT_REQ_CHAIN_WEIGHT): - { - // Optional even if feature not supported - ind_status = CPP_CTNL_PT_RESP_SUCCESS; - // Update the environment - cpps_env->operation = CPPS_CTNL_PT_REQ_CHAIN_WEIGHT_OP_CODE; - } break; - - case (CPP_CTNL_PT_SET_SPAN_LENGTH): - { - // Check if the Span Length Adjustment feature is supported - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_SPAN_LENGTH_ADJ_SUPP)) - { - // Provided parameter in not within the defined range - ind_status = CPP_CTNL_PT_RESP_INV_PARAM; - - if (param->length == 3) - { - // The request can be handled - ind_status = CPP_CTNL_PT_RESP_SUCCESS; - // Update the environment - cpps_env->operation = CPPS_CTNL_PT_SET_SPAN_LENGTH_OP_CODE; - // Span Length - req_ind->value.span_length = co_read16p(¶m->value[1]); - } - } - - } break; - - case (CPP_CTNL_PT_REQ_SPAN_LENGTH): - { - // Optional even if feature not supported - ind_status = CPP_CTNL_PT_RESP_SUCCESS; - // Update the environment - cpps_env->operation = CPPS_CTNL_PT_REQ_SPAN_LENGTH_OP_CODE; - } break; - - case (CPP_CTNL_PT_START_OFFSET_COMP): - { - // Check if the Offset Compensation feature is supported - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_OFFSET_COMP_SUPP)) - { - // The request can be handled - ind_status = CPP_CTNL_PT_RESP_SUCCESS; - // Update the environment - cpps_env->operation = CPPS_CTNL_PT_START_OFFSET_COMP_OP_CODE; - } - } break; - - case (CPP_CTNL_MASK_CP_MEAS_CH_CONTENT): - { - // Check if the CP Masking feature is supported - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_CP_MEAS_CH_CONTENT_MASKING_SUPP)) - { - // Provided parameter in not within the defined range - ind_status = CPP_CTNL_PT_RESP_INV_PARAM; - - if (param->length == 3) - { - // The request can be handled - ind_status = CPP_CTNL_PT_RESP_SUCCESS; - // Update the environment - cpps_env->operation = CPPS_CTNL_MASK_CP_MEAS_CH_CONTENT_OP_CODE; - // Mask content - req_ind->value.mask_content = co_read16p(¶m->value[1]); - } - } - } break; - - case (CPP_CTNL_REQ_SAMPLING_RATE): - { - // Optional even if feature not supported - ind_status = CPP_CTNL_PT_RESP_SUCCESS; - // Update the environment - cpps_env->operation = CPPS_CTNL_REQ_SAMPLING_RATE_OP_CODE; - } break; - - case (CPP_CTNL_REQ_FACTORY_CALIBRATION_DATE): - { - // Optional even if feature not supported - ind_status = CPP_CTNL_PT_RESP_SUCCESS; - // Update the environment - cpps_env->operation = CPPS_CTNL_REQ_FACTORY_CALIBRATION_DATE_OP_CODE; - } break; - - default: - { - // Operation Code is invalid, status is already CPP_CTNL_PT_RESP_NOT_SUPP - } break; - } - - // If no error raised, inform the application about the request - if (ind_status == CPP_CTNL_PT_RESP_SUCCESS) - { - // Send the request indication to the application - ke_msg_send(req_ind); - // Go to the Busy status - ke_state_set(prf_src_task_get(&cpps_env->prf_env, conidx), CPPS_BUSY); - } - else - { - // Free the allocated message - ke_msg_free(ke_param2msg(req_ind)); - } - - return ind_status; -} - -uint8_t cpps_pack_ctnl_point_cfm (uint8_t conidx, struct cpps_ctnl_pt_cfm *param, uint8_t *rsp) -{ - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - // Response Length (At least 3) - uint8_t rsp_len = CPP_CP_CNTL_PT_RSP_MIN_LEN; - - // Set the Response Code - rsp[0] = CPP_CTNL_PT_RSP_CODE; - // Set the Response Value - rsp[2] = (param->status > CPP_CTNL_PT_RESP_FAILED) ? CPP_CTNL_PT_RESP_FAILED : param->status; - - switch (cpps_env->operation) - { - case (CPPS_CTNL_PT_SET_CUMUL_VAL_OP_CODE): - { - // Set the request operation code - rsp[1] = CPP_CTNL_PT_SET_CUMUL_VAL; - - if (param->status == CPP_CTNL_PT_RESP_SUCCESS) - { - // Save in the environment - cpps_env->cumul_wheel_rev = param->value.cumul_wheel_rev; - } - } break; - - case (CPPS_CTNL_PT_UPD_SENSOR_LOC_OP_CODE): - { - // Set the request operation code - rsp[1] = CPP_CTNL_PT_UPD_SENSOR_LOC; - - if (param->status == CPP_CTNL_PT_RESP_SUCCESS) - { - // Store the new value in the environment - cpps_env->sensor_loc = param->value.sensor_loc; - } - } break; - - case (CPPS_CTNL_PT_REQ_SUPP_SENSOR_LOC_OP_CODE): - { - // Set the request operation code - rsp[1] = CPP_CTNL_PT_REQ_SUPP_SENSOR_LOC; - - if (param->status == CPP_CTNL_PT_RESP_SUCCESS) - { - // Set the list of supported location - for (uint8_t counter = 0; counter < CPP_LOC_MAX; counter++) - { - if ((param->value.supp_sensor_loc >> counter) & 0x0001) - { - rsp[rsp_len] = counter; - rsp_len++; - } - } - } - } break; - - case (CPPS_CTNL_PT_SET_CRANK_LENGTH_OP_CODE): - { - // Set the request operation code - rsp[1] = CPP_CTNL_PT_SET_CRANK_LENGTH; - } break; - - case (CPPS_CTNL_PT_REQ_CRANK_LENGTH_OP_CODE): - { - // Set the request operation code - rsp[1] = CPP_CTNL_PT_REQ_CRANK_LENGTH; - if (param->status == CPP_CTNL_PT_RESP_SUCCESS) - { - // Set the response parameter - co_write16p(&rsp[rsp_len], param->value.crank_length); - rsp_len += 2; - } - } break; - - case (CPPS_CTNL_PT_SET_CHAIN_LENGTH_OP_CODE): - { - // Set the request operation code - rsp[1] = CPP_CTNL_PT_SET_CHAIN_LENGTH; - } break; - - case (CPPS_CTNL_PT_REQ_CHAIN_LENGTH_OP_CODE): - { - // Set the request operation code - rsp[1] = CPP_CTNL_PT_REQ_CHAIN_LENGTH; - if (param->status == CPP_CTNL_PT_RESP_SUCCESS) - { - // Set the response parameter - co_write16p(&rsp[rsp_len], param->value.chain_length); - rsp_len += 2; - } - } break; - - case (CPPS_CTNL_PT_SET_CHAIN_WEIGHT_OP_CODE): - { - // Set the request operation code - rsp[1] = CPP_CTNL_PT_SET_CHAIN_WEIGHT; - } break; - - - case (CPPS_CTNL_PT_REQ_CHAIN_WEIGHT_OP_CODE): - { - // Set the request operation code - rsp[1] = CPP_CTNL_PT_REQ_CHAIN_WEIGHT; - if (param->status == CPP_CTNL_PT_RESP_SUCCESS) - { - // Set the response parameter - co_write16p(&rsp[rsp_len], param->value.chain_weight); - rsp_len += 2; - } - } break; - - case (CPPS_CTNL_PT_SET_SPAN_LENGTH_OP_CODE): - { - // Set the request operation code - rsp[1] = CPP_CTNL_PT_SET_SPAN_LENGTH; - } break; - - case (CPPS_CTNL_PT_REQ_SPAN_LENGTH_OP_CODE): - { - // Set the request operation code - rsp[1] = CPP_CTNL_PT_REQ_SPAN_LENGTH; - if (param->status == CPP_CTNL_PT_RESP_SUCCESS) - { - // Set the response parameter - co_write16p(&rsp[rsp_len], param->value.span_length); - rsp_len += 2; - } - } break; - - case (CPPS_CTNL_PT_START_OFFSET_COMP_OP_CODE): - { - // Set the request operation code - rsp[1] = CPP_CTNL_PT_START_OFFSET_COMP; - if (param->status == CPP_CTNL_PT_RESP_SUCCESS) - { - // Set the response parameter - co_write16p(&rsp[rsp_len], param->value.offset_comp); - rsp_len += 2; - } - } break; - - case (CPPS_CTNL_MASK_CP_MEAS_CH_CONTENT_OP_CODE): - { - // Set the request operation code - rsp[1] = CPP_CTNL_MASK_CP_MEAS_CH_CONTENT; - if (param->status == CPP_CTNL_PT_RESP_SUCCESS) - { - uint16_t cpp_mask_cp_meas_flags [] = - { - CPP_MEAS_PEDAL_POWER_BALANCE_PRESENT, - CPP_MEAS_ACCUM_TORQUE_PRESENT, - CPP_MEAS_WHEEL_REV_DATA_PRESENT, - CPP_MEAS_CRANK_REV_DATA_PRESENT, - CPP_MEAS_EXTREME_FORCE_MAGNITUDES_PRESENT | - CPP_MEAS_EXTREME_TORQUE_MAGNITUDES_PRESENT, - CPP_MEAS_EXTREME_ANGLES_PRESENT, - CPP_MEAS_TOP_DEAD_SPOT_ANGLE_PRESENT, - CPP_MEAS_BOTTOM_DEAD_SPOT_ANGLE_PRESENT, - CPP_MEAS_ACCUM_ENERGY_PRESENT, - }; - - uint16_t mask = 0; - for (uint8_t count = 0; count < 9; count++) - { - if ((param->value.mask_meas_content >> count) & 0x0001) - { - mask |= cpp_mask_cp_meas_flags[count]; - } - } - cpps_env->env[conidx].mask_meas_content = mask; - } - } break; - - case (CPPS_CTNL_REQ_SAMPLING_RATE_OP_CODE): - { - // Set the request operation code - rsp[1] = CPP_CTNL_REQ_SAMPLING_RATE; - if (param->status == CPP_CTNL_PT_RESP_SUCCESS) - { - // Set the response parameter - rsp[rsp_len] = param->value.sampling_rate; - rsp_len ++; - } - } break; - - case (CPPS_CTNL_REQ_FACTORY_CALIBRATION_DATE_OP_CODE): - { - // Set the request operation code - rsp[1] = CPP_CTNL_REQ_FACTORY_CALIBRATION_DATE; - if (param->status == CPP_CTNL_PT_RESP_SUCCESS) - { - // Set the response parameter - rsp_len += prf_pack_date_time(&rsp[rsp_len], &(param->value.factory_calibration)); - } - } break; - - default: - { - rsp[2] = CPP_CTNL_PT_RESP_NOT_SUPP; - } break; - } - - return rsp_len; -} - - -int cpps_update_cfg_char_value (uint8_t conidx, uint8_t con_type, uint8_t handle, uint16_t ntf_cfg, uint16_t cfg_flag) -{ - uint8_t status = ATT_ERR_NO_ERROR; - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - - if (con_type != PRF_CON_DISCOVERY) - { + // Update value for every connection (useful for bond data) + for (uint8_t i = 0; i < BLE_CONNECTION_MAX; i++) { // Save the new configuration in the environment - ((ntf_cfg & cfg_flag) == 0) ? - CPPS_DISABLE_NTF_IND_BCST(conidx, cfg_flag) : - CPPS_ENABLE_NTF_IND_BCST(conidx, cfg_flag); + (ntf_cfg == PRF_SRV_STOP_BCST) + ? CPPS_DISABLE_NTF_IND_BCST(conidx, prfl_config) + : CPPS_ENABLE_NTF_IND_BCST(conidx, prfl_config); + } + } else { + status = PRF_ERR_INVALID_PARAM; } + break; - return (status); + case CPP_PRF_CFG_FLAG_CP_MEAS_NTF: + + // Check CCC configuration + if ((ntf_cfg == PRF_CLI_STOP_NTFIND) || (ntf_cfg == PRF_CLI_START_NTF)) { + // Save the new configuration in the environment + (ntf_cfg == PRF_CLI_STOP_NTFIND) + ? CPPS_DISABLE_NTF_IND_BCST(conidx, prfl_config) + : CPPS_ENABLE_NTF_IND_BCST(conidx, prfl_config); + } else { + status = PRF_APP_ERROR; + } + break; + + default: + status = ATT_ERR_INVALID_HANDLE; + break; + } + + if (status == GAP_ERR_NO_ERROR) { + if (prfl_config == CPP_PRF_CFG_FLAG_VECTOR_NTF) { + // Allocate message to inform application + struct cpps_vector_cfg_req_ind *ind = KE_MSG_ALLOC( + CPPS_VECTOR_CFG_REQ_IND, prf_dst_task_get(&cpps_env->prf_env, conidx), + prf_src_task_get(&cpps_env->prf_env, conidx), + cpps_vector_cfg_req_ind); + // Inform APP of configuration change + ind->char_code = prfl_config; + ind->ntf_cfg = ntf_cfg; + ind->conidx = conidx; + ke_msg_send(ind); + } else { + // Allocate message to inform application + struct cpps_cfg_ntfind_ind *ind = KE_MSG_ALLOC( + CPPS_CFG_NTFIND_IND, prf_dst_task_get(&cpps_env->prf_env, conidx), + prf_src_task_get(&cpps_env->prf_env, conidx), cpps_cfg_ntfind_ind); + // Inform APP of configuration change + ind->char_code = prfl_config; + ind->ntf_cfg = ntf_cfg; + ind->conidx = conidx; + ke_msg_send(ind); + } + // Enable Bonded Data + CPPS_ENABLE_NTF_IND_BCST(conidx, CPP_PRF_CFG_PERFORMED_OK); + } + return (status); } -void cpps_send_cmp_evt(uint8_t conidx, uint8_t src_id, uint8_t dest_id, uint8_t operation, uint8_t status) -{ - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - // Go back to the IDLE if the state is busy - if (ke_state_get(src_id) == CPPS_BUSY) +uint8_t cpps_pack_vector_ntf(struct cpp_cp_vector *param, + uint8_t *pckd_vector) { + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); + // Packed Measurement length + uint8_t pckd_vector_len = CPP_CP_VECTOR_MIN_LEN; + + // Check provided flags + if (CPPS_IS_PRESENT(param->flags, CPP_VECTOR_CRANK_REV_DATA_PRESENT)) { + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_CRANK_REV_DATA_SUPP)) { + // Pack Crank Revolution Data (Cumulative Crank & Last Crank Event Time) + co_write16p(&pckd_vector[pckd_vector_len], param->cumul_crank_rev); + pckd_vector_len += 2; + co_write16p(&pckd_vector[pckd_vector_len], param->last_crank_evt_time); + pckd_vector_len += 2; + } else // Not supported by the profile { - ke_state_set(src_id, CPPS_IDLE); + // Force to not supported + param->flags &= ~CPP_VECTOR_CRANK_REV_DATA_PRESENT; + } + } + + if (CPPS_IS_PRESENT(param->flags, + CPP_VECTOR_FIRST_CRANK_MEAS_ANGLE_PRESENT)) { + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_EXTREME_ANGLES_SUPP)) { + // Pack First Crank Measurement Angle + co_write16p(&pckd_vector[pckd_vector_len], param->first_crank_meas_angle); + pckd_vector_len += 2; + } else // Not supported by the profile + { + // Force to not supported + param->flags &= ~CPP_VECTOR_FIRST_CRANK_MEAS_ANGLE_PRESENT; + } + } + + if (CPPS_IS_PRESENT(param->flags, + CPP_VECTOR_INST_FORCE_MAGNITUDE_ARRAY_PRESENT)) { + if (CPPS_IS_CLEAR(cpps_env->features, CPP_FEAT_SENSOR_MEAS_CONTEXT)) { + // Pack Instantaneous Force Magnitude Array + if ((param->nb > CPP_CP_VECTOR_MIN_LEN) && + (param->nb <= CPP_CP_VECTOR_MAX_LEN - pckd_vector_len)) { + for (int j = 0; j < param->nb; j++) { + co_write16p(&pckd_vector[pckd_vector_len], + param->force_torque_magnitude[j]); + pckd_vector_len += 2; + } + } else { + return 0; + } + } else // Not supported by the profile + { + // Force to not supported + param->flags &= ~CPP_VECTOR_INST_FORCE_MAGNITUDE_ARRAY_PRESENT; + } + } + + if (CPPS_IS_PRESENT(param->flags, + CPP_VECTOR_INST_TORQUE_MAGNITUDE_ARRAY_PRESENT)) { + if (CPPS_IS_SET(cpps_env->features, CPP_FEAT_SENSOR_MEAS_CONTEXT)) { + // Pack Instantaneous Torque Magnitude Array + if ((param->nb > CPP_CP_VECTOR_MIN_LEN) && + (param->nb <= CPP_CP_VECTOR_MAX_LEN - pckd_vector_len)) { + for (int j = 0; j < param->nb; j++) { + co_write16p(&pckd_vector[pckd_vector_len], + param->force_torque_magnitude[j]); + pckd_vector_len += 2; + } + } else { + return 0; + } + } else // Not supported by the profile + { + // Force to not supported + param->flags &= ~CPP_VECTOR_INST_TORQUE_MAGNITUDE_ARRAY_PRESENT; + } + } + + // Allow to use reserved flags + // param->flags &= CPP_VECTOR_ALL_SUPP; + // Flags value + pckd_vector[0] = param->flags; + + return pckd_vector_len; +} + +void cpps_send_rsp_ind(uint8_t conidx, uint8_t req_op_code, uint8_t status) { + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); + + // Allocate the GATT notification message + struct gattc_send_evt_cmd *ctl_pt_rsp = + KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&cpps_env->prf_env, conidx), + gattc_send_evt_cmd, CPP_CP_CNTL_PT_RSP_MIN_LEN); + + // Fill in the parameter structure + ctl_pt_rsp->operation = GATTC_INDICATE; + ctl_pt_rsp->handle = CPPS_HANDLE(CPS_IDX_CTNL_PT_VAL); + // Pack Control Point confirmation + ctl_pt_rsp->length = CPP_CP_CNTL_PT_RSP_MIN_LEN; + // Response Code + ctl_pt_rsp->value[0] = CPP_CTNL_PT_RSP_CODE; + // Request Operation Code + ctl_pt_rsp->value[1] = req_op_code; + // Response value + ctl_pt_rsp->value[2] = status; + + // Send the event + ke_msg_send(ctl_pt_rsp); +} + +uint8_t cpps_unpack_ctnl_point_ind(uint8_t conidx, + struct gattc_write_req_ind const *param) { + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); + + // Indication Status + uint8_t ind_status = CPP_CTNL_PT_RESP_NOT_SUPP; + + // Allocate a request indication message for the application + struct cpps_ctnl_pt_req_ind *req_ind = KE_MSG_ALLOC( + CPPS_CTNL_PT_REQ_IND, prf_dst_task_get(&cpps_env->prf_env, conidx), + prf_src_task_get(&cpps_env->prf_env, conidx), cpps_ctnl_pt_req_ind); + // Operation Code + req_ind->op_code = param->value[0]; + req_ind->conidx = conidx; + + // Operation Code + switch (req_ind->op_code) { + case (CPP_CTNL_PT_SET_CUMUL_VAL): { + // Check if the Wheel Revolution Data feature is supported + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_WHEEL_REV_DATA_SUPP)) { + // Provided parameter in not within the defined range + ind_status = CPP_CTNL_PT_RESP_INV_PARAM; + + if (param->length == 5) { + // The request can be handled + ind_status = CPP_CTNL_PT_RESP_SUCCESS; + // Update the environment + cpps_env->operation = CPPS_CTNL_PT_SET_CUMUL_VAL_OP_CODE; + // Cumulative value + req_ind->value.cumul_val = co_read32p(¶m->value[1]); + } + } + } break; + + case (CPP_CTNL_PT_UPD_SENSOR_LOC): { + // Check if the Multiple Sensor Location feature is supported + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_MULT_SENSOR_LOC_SUPP)) { + // Provided parameter in not within the defined range + ind_status = CPP_CTNL_PT_RESP_INV_PARAM; + + if (param->length == 2) { + // Check the sensor location value + if (param->value[1] < CPP_LOC_MAX) { + // The request can be handled + ind_status = CPP_CTNL_PT_RESP_SUCCESS; + // Update the environment + cpps_env->operation = CPPS_CTNL_PT_UPD_SENSOR_LOC_OP_CODE; + // Sensor Location + req_ind->value.sensor_loc = param->value[1]; + } + } + } + } break; + + case (CPP_CTNL_PT_REQ_SUPP_SENSOR_LOC): { + // Check if the Multiple Sensor Location feature is supported + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_MULT_SENSOR_LOC_SUPP)) { + // The request can be handled + ind_status = CPP_CTNL_PT_RESP_SUCCESS; + // Update the environment + cpps_env->operation = CPPS_CTNL_PT_REQ_SUPP_SENSOR_LOC_OP_CODE; + } + } break; + + case (CPP_CTNL_PT_SET_CRANK_LENGTH): { + // Check if the Crank Length Adjustment feature is supported + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_CRANK_LENGTH_ADJ_SUPP)) { + // Provided parameter in not within the defined range + ind_status = CPP_CTNL_PT_RESP_INV_PARAM; + + if (param->length == 3) { + // The request can be handled + ind_status = CPP_CTNL_PT_RESP_SUCCESS; + // Update the environment + cpps_env->operation = CPPS_CTNL_PT_SET_CRANK_LENGTH_OP_CODE; + // Crank Length + req_ind->value.crank_length = co_read16p(¶m->value[1]); + } } + } break; + + case (CPP_CTNL_PT_REQ_CRANK_LENGTH): { + // Optional even if feature not supported + ind_status = CPP_CTNL_PT_RESP_SUCCESS; + // Update the environment + cpps_env->operation = CPPS_CTNL_PT_REQ_CRANK_LENGTH_OP_CODE; + } break; + + case (CPP_CTNL_PT_SET_CHAIN_LENGTH): { + // Check if the Chain Length Adjustment feature is supported + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_CHAIN_LENGTH_ADJ_SUPP)) { + // Provided parameter in not within the defined range + ind_status = CPP_CTNL_PT_RESP_INV_PARAM; + + if (param->length == 3) { + // The request can be handled + ind_status = CPP_CTNL_PT_RESP_SUCCESS; + // Update the environment + cpps_env->operation = CPPS_CTNL_PT_SET_CHAIN_LENGTH_OP_CODE; + // Chain Length + req_ind->value.crank_length = co_read16p(¶m->value[1]); + } + } + + } break; + + case (CPP_CTNL_PT_REQ_CHAIN_LENGTH): { + // Optional even if feature not supported + ind_status = CPP_CTNL_PT_RESP_SUCCESS; + // Update the environment + cpps_env->operation = CPPS_CTNL_PT_REQ_CHAIN_LENGTH_OP_CODE; + } break; + + case (CPP_CTNL_PT_SET_CHAIN_WEIGHT): { + // Check if the Chain Weight Adjustment feature is supported + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_CHAIN_WEIGHT_ADJ_SUPP)) { + // Provided parameter in not within the defined range + ind_status = CPP_CTNL_PT_RESP_INV_PARAM; + + if (param->length == 3) { + // The request can be handled + ind_status = CPP_CTNL_PT_RESP_SUCCESS; + // Update the environment + cpps_env->operation = CPPS_CTNL_PT_SET_CHAIN_WEIGHT_OP_CODE; + // Chain Weight + req_ind->value.chain_weight = co_read16p(¶m->value[1]); + } + } + + } break; + + case (CPP_CTNL_PT_REQ_CHAIN_WEIGHT): { + // Optional even if feature not supported + ind_status = CPP_CTNL_PT_RESP_SUCCESS; + // Update the environment + cpps_env->operation = CPPS_CTNL_PT_REQ_CHAIN_WEIGHT_OP_CODE; + } break; + + case (CPP_CTNL_PT_SET_SPAN_LENGTH): { + // Check if the Span Length Adjustment feature is supported + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_SPAN_LENGTH_ADJ_SUPP)) { + // Provided parameter in not within the defined range + ind_status = CPP_CTNL_PT_RESP_INV_PARAM; + + if (param->length == 3) { + // The request can be handled + ind_status = CPP_CTNL_PT_RESP_SUCCESS; + // Update the environment + cpps_env->operation = CPPS_CTNL_PT_SET_SPAN_LENGTH_OP_CODE; + // Span Length + req_ind->value.span_length = co_read16p(¶m->value[1]); + } + } + + } break; + + case (CPP_CTNL_PT_REQ_SPAN_LENGTH): { + // Optional even if feature not supported + ind_status = CPP_CTNL_PT_RESP_SUCCESS; + // Update the environment + cpps_env->operation = CPPS_CTNL_PT_REQ_SPAN_LENGTH_OP_CODE; + } break; + + case (CPP_CTNL_PT_START_OFFSET_COMP): { + // Check if the Offset Compensation feature is supported + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_OFFSET_COMP_SUPP)) { + // The request can be handled + ind_status = CPP_CTNL_PT_RESP_SUCCESS; + // Update the environment + cpps_env->operation = CPPS_CTNL_PT_START_OFFSET_COMP_OP_CODE; + } + } break; + + case (CPP_CTNL_MASK_CP_MEAS_CH_CONTENT): { + // Check if the CP Masking feature is supported + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_CP_MEAS_CH_CONTENT_MASKING_SUPP)) { + // Provided parameter in not within the defined range + ind_status = CPP_CTNL_PT_RESP_INV_PARAM; + + if (param->length == 3) { + // The request can be handled + ind_status = CPP_CTNL_PT_RESP_SUCCESS; + // Update the environment + cpps_env->operation = CPPS_CTNL_MASK_CP_MEAS_CH_CONTENT_OP_CODE; + // Mask content + req_ind->value.mask_content = co_read16p(¶m->value[1]); + } + } + } break; + + case (CPP_CTNL_REQ_SAMPLING_RATE): { + // Optional even if feature not supported + ind_status = CPP_CTNL_PT_RESP_SUCCESS; + // Update the environment + cpps_env->operation = CPPS_CTNL_REQ_SAMPLING_RATE_OP_CODE; + } break; + + case (CPP_CTNL_REQ_FACTORY_CALIBRATION_DATE): { + // Optional even if feature not supported + ind_status = CPP_CTNL_PT_RESP_SUCCESS; + // Update the environment + cpps_env->operation = CPPS_CTNL_REQ_FACTORY_CALIBRATION_DATE_OP_CODE; + } break; + + default: { + // Operation Code is invalid, status is already CPP_CTNL_PT_RESP_NOT_SUPP + } break; + } + + // If no error raised, inform the application about the request + if (ind_status == CPP_CTNL_PT_RESP_SUCCESS) { + // Send the request indication to the application + ke_msg_send(req_ind); + // Go to the Busy status + ke_state_set(prf_src_task_get(&cpps_env->prf_env, conidx), CPPS_BUSY); + } else { + // Free the allocated message + ke_msg_free(ke_param2msg(req_ind)); + } + + return ind_status; +} + +uint8_t cpps_pack_ctnl_point_cfm(uint8_t conidx, struct cpps_ctnl_pt_cfm *param, + uint8_t *rsp) { + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); + // Response Length (At least 3) + uint8_t rsp_len = CPP_CP_CNTL_PT_RSP_MIN_LEN; + + // Set the Response Code + rsp[0] = CPP_CTNL_PT_RSP_CODE; + // Set the Response Value + rsp[2] = (param->status > CPP_CTNL_PT_RESP_FAILED) ? CPP_CTNL_PT_RESP_FAILED + : param->status; + + switch (cpps_env->operation) { + case (CPPS_CTNL_PT_SET_CUMUL_VAL_OP_CODE): { + // Set the request operation code + rsp[1] = CPP_CTNL_PT_SET_CUMUL_VAL; + + if (param->status == CPP_CTNL_PT_RESP_SUCCESS) { + // Save in the environment + cpps_env->cumul_wheel_rev = param->value.cumul_wheel_rev; + } + } break; + + case (CPPS_CTNL_PT_UPD_SENSOR_LOC_OP_CODE): { + // Set the request operation code + rsp[1] = CPP_CTNL_PT_UPD_SENSOR_LOC; + + if (param->status == CPP_CTNL_PT_RESP_SUCCESS) { + // Store the new value in the environment + cpps_env->sensor_loc = param->value.sensor_loc; + } + } break; + + case (CPPS_CTNL_PT_REQ_SUPP_SENSOR_LOC_OP_CODE): { + // Set the request operation code + rsp[1] = CPP_CTNL_PT_REQ_SUPP_SENSOR_LOC; + + if (param->status == CPP_CTNL_PT_RESP_SUCCESS) { + // Set the list of supported location + for (uint8_t counter = 0; counter < CPP_LOC_MAX; counter++) { + if ((param->value.supp_sensor_loc >> counter) & 0x0001) { + rsp[rsp_len] = counter; + rsp_len++; + } + } + } + } break; + + case (CPPS_CTNL_PT_SET_CRANK_LENGTH_OP_CODE): { + // Set the request operation code + rsp[1] = CPP_CTNL_PT_SET_CRANK_LENGTH; + } break; + + case (CPPS_CTNL_PT_REQ_CRANK_LENGTH_OP_CODE): { + // Set the request operation code + rsp[1] = CPP_CTNL_PT_REQ_CRANK_LENGTH; + if (param->status == CPP_CTNL_PT_RESP_SUCCESS) { + // Set the response parameter + co_write16p(&rsp[rsp_len], param->value.crank_length); + rsp_len += 2; + } + } break; + + case (CPPS_CTNL_PT_SET_CHAIN_LENGTH_OP_CODE): { + // Set the request operation code + rsp[1] = CPP_CTNL_PT_SET_CHAIN_LENGTH; + } break; + + case (CPPS_CTNL_PT_REQ_CHAIN_LENGTH_OP_CODE): { + // Set the request operation code + rsp[1] = CPP_CTNL_PT_REQ_CHAIN_LENGTH; + if (param->status == CPP_CTNL_PT_RESP_SUCCESS) { + // Set the response parameter + co_write16p(&rsp[rsp_len], param->value.chain_length); + rsp_len += 2; + } + } break; + + case (CPPS_CTNL_PT_SET_CHAIN_WEIGHT_OP_CODE): { + // Set the request operation code + rsp[1] = CPP_CTNL_PT_SET_CHAIN_WEIGHT; + } break; + + case (CPPS_CTNL_PT_REQ_CHAIN_WEIGHT_OP_CODE): { + // Set the request operation code + rsp[1] = CPP_CTNL_PT_REQ_CHAIN_WEIGHT; + if (param->status == CPP_CTNL_PT_RESP_SUCCESS) { + // Set the response parameter + co_write16p(&rsp[rsp_len], param->value.chain_weight); + rsp_len += 2; + } + } break; + + case (CPPS_CTNL_PT_SET_SPAN_LENGTH_OP_CODE): { + // Set the request operation code + rsp[1] = CPP_CTNL_PT_SET_SPAN_LENGTH; + } break; + + case (CPPS_CTNL_PT_REQ_SPAN_LENGTH_OP_CODE): { + // Set the request operation code + rsp[1] = CPP_CTNL_PT_REQ_SPAN_LENGTH; + if (param->status == CPP_CTNL_PT_RESP_SUCCESS) { + // Set the response parameter + co_write16p(&rsp[rsp_len], param->value.span_length); + rsp_len += 2; + } + } break; + + case (CPPS_CTNL_PT_START_OFFSET_COMP_OP_CODE): { + // Set the request operation code + rsp[1] = CPP_CTNL_PT_START_OFFSET_COMP; + if (param->status == CPP_CTNL_PT_RESP_SUCCESS) { + // Set the response parameter + co_write16p(&rsp[rsp_len], param->value.offset_comp); + rsp_len += 2; + } + } break; + + case (CPPS_CTNL_MASK_CP_MEAS_CH_CONTENT_OP_CODE): { + // Set the request operation code + rsp[1] = CPP_CTNL_MASK_CP_MEAS_CH_CONTENT; + if (param->status == CPP_CTNL_PT_RESP_SUCCESS) { + uint16_t cpp_mask_cp_meas_flags[] = { + CPP_MEAS_PEDAL_POWER_BALANCE_PRESENT, + CPP_MEAS_ACCUM_TORQUE_PRESENT, + CPP_MEAS_WHEEL_REV_DATA_PRESENT, + CPP_MEAS_CRANK_REV_DATA_PRESENT, + CPP_MEAS_EXTREME_FORCE_MAGNITUDES_PRESENT | + CPP_MEAS_EXTREME_TORQUE_MAGNITUDES_PRESENT, + CPP_MEAS_EXTREME_ANGLES_PRESENT, + CPP_MEAS_TOP_DEAD_SPOT_ANGLE_PRESENT, + CPP_MEAS_BOTTOM_DEAD_SPOT_ANGLE_PRESENT, + CPP_MEAS_ACCUM_ENERGY_PRESENT, + }; + + uint16_t mask = 0; + for (uint8_t count = 0; count < 9; count++) { + if ((param->value.mask_meas_content >> count) & 0x0001) { + mask |= cpp_mask_cp_meas_flags[count]; + } + } + cpps_env->env[conidx].mask_meas_content = mask; + } + } break; + + case (CPPS_CTNL_REQ_SAMPLING_RATE_OP_CODE): { + // Set the request operation code + rsp[1] = CPP_CTNL_REQ_SAMPLING_RATE; + if (param->status == CPP_CTNL_PT_RESP_SUCCESS) { + // Set the response parameter + rsp[rsp_len] = param->value.sampling_rate; + rsp_len++; + } + } break; + + case (CPPS_CTNL_REQ_FACTORY_CALIBRATION_DATE_OP_CODE): { + // Set the request operation code + rsp[1] = CPP_CTNL_REQ_FACTORY_CALIBRATION_DATE; + if (param->status == CPP_CTNL_PT_RESP_SUCCESS) { + // Set the response parameter + rsp_len += prf_pack_date_time(&rsp[rsp_len], + &(param->value.factory_calibration)); + } + } break; + + default: { + rsp[2] = CPP_CTNL_PT_RESP_NOT_SUPP; + } break; + } + + return rsp_len; +} + +int cpps_update_cfg_char_value(uint8_t conidx, uint8_t con_type, uint8_t handle, + uint16_t ntf_cfg, uint16_t cfg_flag) { + uint8_t status = ATT_ERR_NO_ERROR; + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); + + if (con_type != PRF_CON_DISCOVERY) { + // Save the new configuration in the environment + ((ntf_cfg & cfg_flag) == 0) ? CPPS_DISABLE_NTF_IND_BCST(conidx, cfg_flag) + : CPPS_ENABLE_NTF_IND_BCST(conidx, cfg_flag); + } + + return (status); +} + +void cpps_send_cmp_evt(uint8_t conidx, uint8_t src_id, uint8_t dest_id, + uint8_t operation, uint8_t status) { + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); + // Go back to the IDLE if the state is busy + if (ke_state_get(src_id) == CPPS_BUSY) { + ke_state_set(src_id, CPPS_IDLE); + } + + // Set the operation code + cpps_env->operation = CPPS_RESERVED_OP_CODE; + + // Send the message + struct cpps_cmp_evt *evt = + KE_MSG_ALLOC(CPPS_CMP_EVT, dest_id, src_id, cpps_cmp_evt); + + evt->conidx = conidx; + evt->operation = operation; + evt->status = status; + + ke_msg_send(evt); +} + +void cpps_exe_operation(void) { + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); + + ASSERT_ERR(cpps_env->op_data != NULL); + + bool finished = true; + + while ((cpps_env->op_data->cursor < BLE_CONNECTION_MAX) && finished) { + uint8_t conidx = cpps_env->op_data->cursor; + + switch (cpps_env->operation) { + case CPPS_NTF_MEAS_OP_CODE: { + // notification is pending, send it first + if (cpps_env->op_data->ntf_pending != NULL) { + ke_msg_send(cpps_env->op_data->ntf_pending); + cpps_env->op_data->ntf_pending = NULL; + finished = false; + } + // Check if sending of notifications has been enabled + else if (CPPS_IS_NTF_IND_BCST_ENABLED(conidx, + CPP_PRF_CFG_FLAG_CP_MEAS_NTF)) { + struct cpps_ntf_cp_meas_req *meas_cmd = + (struct cpps_ntf_cp_meas_req *)ke_msg2param(cpps_env->op_data->cmd); + // Save flags value + uint16_t flags = meas_cmd->parameters.flags; + + // Mask unwanted fields if supported + if (CPPS_IS_FEATURE_SUPPORTED( + cpps_env->features, CPP_FEAT_CP_MEAS_CH_CONTENT_MASKING_SUPP)) { + meas_cmd->parameters.flags &= + ~cpps_env->env[conidx].mask_meas_content; + } + + // Allocate the GATT notification message + struct gattc_send_evt_cmd *meas_val = KE_MSG_ALLOC_DYN( + GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&(cpps_env->prf_env), conidx), gattc_send_evt_cmd, + CPP_CP_MEAS_NTF_MAX_LEN); + + // Fill in the parameter structure + meas_val->operation = GATTC_NOTIFY; + meas_val->handle = CPPS_HANDLE(CPS_IDX_CP_MEAS_VAL); + // pack measured value in database + meas_val->length = + cpps_pack_meas_ntf(&meas_cmd->parameters, meas_val->value); + + if (meas_val->length > gattc_get_mtu(conidx) - 3) { + // Split (if necessary) + cpps_split_meas_ntf(conidx, meas_val); + } + + // Restore flags value + meas_cmd->parameters.flags = flags; + + // Send the event + ke_msg_send(meas_val); + + finished = false; + } + // update cursor only if all notification has been sent + if (cpps_env->op_data->ntf_pending == NULL) { + cpps_env->op_data->cursor++; + } + } break; + + case CPPS_NTF_VECTOR_OP_CODE: { + struct cpps_ntf_cp_vector_req *vector_cmd = + (struct cpps_ntf_cp_vector_req *)ke_msg2param(cpps_env->op_data->cmd); + + // Check if sending of notifications has been enabled + if (CPPS_IS_NTF_IND_BCST_ENABLED(conidx, CPP_PRF_CFG_FLAG_VECTOR_NTF)) { + // Allocate the GATT notification message + struct gattc_send_evt_cmd *vector_val = KE_MSG_ALLOC_DYN( + GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&(cpps_env->prf_env), conidx), gattc_send_evt_cmd, + CPP_CP_VECTOR_MAX_LEN); + + // Fill in the parameter structure + vector_val->operation = GATTC_NOTIFY; + vector_val->handle = CPPS_HANDLE(CPS_IDX_VECTOR_VAL); + // pack measured value in database + vector_val->length = + cpps_pack_vector_ntf(&vector_cmd->parameters, vector_val->value); + + // Send the event + ke_msg_send(vector_val); + + finished = false; + } + + cpps_env->op_data->cursor++; + } break; + + default: + ASSERT_ERR(0); + break; + } + } + + // check if operation is finished + if (finished) { + if (cpps_env->operation == CPPS_NTF_MEAS_OP_CODE) { + // send response to requester + struct cpps_ntf_cp_meas_rsp *rsp = + KE_MSG_ALLOC(CPPS_NTF_CP_MEAS_RSP, cpps_env->op_data->cmd->src_id, + cpps_env->op_data->cmd->dest_id, cpps_ntf_cp_meas_rsp); + + rsp->status = GAP_ERR_NO_ERROR; + ke_msg_send(rsp); + } else if (cpps_env->operation == CPPS_NTF_VECTOR_OP_CODE) { + // send response to requester + struct cpps_ntf_cp_vector_rsp *rsp = + KE_MSG_ALLOC(CPPS_NTF_CP_VECTOR_RSP, cpps_env->op_data->cmd->src_id, + cpps_env->op_data->cmd->dest_id, cpps_ntf_cp_vector_rsp); + + rsp->status = GAP_ERR_NO_ERROR; + ke_msg_send(rsp); + } + + // free operation data + ke_msg_free(cpps_env->op_data->cmd); + ke_free(cpps_env->op_data); + cpps_env->op_data = NULL; // Set the operation code cpps_env->operation = CPPS_RESERVED_OP_CODE; - - // Send the message - struct cpps_cmp_evt *evt = KE_MSG_ALLOC(CPPS_CMP_EVT, - dest_id, src_id, - cpps_cmp_evt); - - evt->conidx = conidx; - evt->operation = operation; - evt->status = status; - - ke_msg_send(evt); -} - -void cpps_exe_operation(void) -{ - struct cpps_env_tag* cpps_env = PRF_ENV_GET(CPPS, cpps); - - ASSERT_ERR(cpps_env->op_data != NULL); - - bool finished = true; - - while((cpps_env->op_data->cursor < BLE_CONNECTION_MAX) && finished) - { - uint8_t conidx = cpps_env->op_data->cursor; - - switch(cpps_env->operation) - { - case CPPS_NTF_MEAS_OP_CODE: - { - // notification is pending, send it first - if(cpps_env->op_data->ntf_pending != NULL) - { - ke_msg_send(cpps_env->op_data->ntf_pending); - cpps_env->op_data->ntf_pending = NULL; - finished = false; - } - // Check if sending of notifications has been enabled - else if (CPPS_IS_NTF_IND_BCST_ENABLED(conidx, CPP_PRF_CFG_FLAG_CP_MEAS_NTF)) - { - struct cpps_ntf_cp_meas_req *meas_cmd = - (struct cpps_ntf_cp_meas_req *) ke_msg2param(cpps_env->op_data->cmd); - // Save flags value - uint16_t flags = meas_cmd->parameters.flags; - - // Mask unwanted fields if supported - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_CP_MEAS_CH_CONTENT_MASKING_SUPP)) - { - meas_cmd->parameters.flags &= ~cpps_env->env[conidx].mask_meas_content; - } - - // Allocate the GATT notification message - struct gattc_send_evt_cmd *meas_val = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(&(cpps_env->prf_env),conidx), - gattc_send_evt_cmd, CPP_CP_MEAS_NTF_MAX_LEN); - - // Fill in the parameter structure - meas_val->operation = GATTC_NOTIFY; - meas_val->handle = CPPS_HANDLE(CPS_IDX_CP_MEAS_VAL); - // pack measured value in database - meas_val->length = cpps_pack_meas_ntf(&meas_cmd->parameters, meas_val->value); - - if (meas_val->length > gattc_get_mtu(conidx) - 3) - { - // Split (if necessary) - cpps_split_meas_ntf(conidx, meas_val); - } - - // Restore flags value - meas_cmd->parameters.flags = flags; - - // Send the event - ke_msg_send(meas_val); - - finished = false; - } - // update cursor only if all notification has been sent - if(cpps_env->op_data->ntf_pending == NULL) - { - cpps_env->op_data->cursor++; - } - } break; - - case CPPS_NTF_VECTOR_OP_CODE: - { - struct cpps_ntf_cp_vector_req *vector_cmd = - (struct cpps_ntf_cp_vector_req *) ke_msg2param(cpps_env->op_data->cmd); - - // Check if sending of notifications has been enabled - if (CPPS_IS_NTF_IND_BCST_ENABLED(conidx, CPP_PRF_CFG_FLAG_VECTOR_NTF)) - { - // Allocate the GATT notification message - struct gattc_send_evt_cmd *vector_val = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(&(cpps_env->prf_env),conidx), - gattc_send_evt_cmd, CPP_CP_VECTOR_MAX_LEN); - - // Fill in the parameter structure - vector_val->operation = GATTC_NOTIFY; - vector_val->handle = CPPS_HANDLE(CPS_IDX_VECTOR_VAL); - // pack measured value in database - vector_val->length = cpps_pack_vector_ntf(&vector_cmd->parameters, vector_val->value); - - // Send the event - ke_msg_send(vector_val); - - finished = false; - } - - cpps_env->op_data->cursor++; - } break; - - default: ASSERT_ERR(0); break; - } - } - - // check if operation is finished - if(finished) - { - if (cpps_env->operation == CPPS_NTF_MEAS_OP_CODE) - { - // send response to requester - struct cpps_ntf_cp_meas_rsp * rsp = KE_MSG_ALLOC( - CPPS_NTF_CP_MEAS_RSP, - cpps_env->op_data->cmd->src_id, - cpps_env->op_data->cmd->dest_id, - cpps_ntf_cp_meas_rsp); - - rsp->status = GAP_ERR_NO_ERROR; - ke_msg_send(rsp); - } - else if (cpps_env->operation == CPPS_NTF_VECTOR_OP_CODE) - { - // send response to requester - struct cpps_ntf_cp_vector_rsp * rsp = KE_MSG_ALLOC( - CPPS_NTF_CP_VECTOR_RSP, - cpps_env->op_data->cmd->src_id, - cpps_env->op_data->cmd->dest_id, - cpps_ntf_cp_vector_rsp); - - rsp->status = GAP_ERR_NO_ERROR; - ke_msg_send(rsp); - } - - // free operation data - ke_msg_free(cpps_env->op_data->cmd); - ke_free(cpps_env->op_data); - cpps_env->op_data = NULL; - // Set the operation code - cpps_env->operation = CPPS_RESERVED_OP_CODE; - // go back to idle state - ke_state_set(prf_src_task_get(&(cpps_env->prf_env), 0), CPPS_IDLE); - } + // go back to idle state + ke_state_set(prf_src_task_get(&(cpps_env->prf_env), 0), CPPS_IDLE); + } } #endif //(BLE_CP_SENSOR) diff --git a/services/ble_profiles/cpp/cpps/src/cpps_task.c b/services/ble_profiles/cpp/cpps/src/cpps_task.c index 3869934..dfe0a5d 100644 --- a/services/ble_profiles/cpp/cpps/src/cpps_task.c +++ b/services/ble_profiles/cpp/cpps/src/cpps_task.c @@ -10,29 +10,26 @@ **************************************************************************************** */ - #include "rwip_config.h" #if (BLE_CP_SENSOR) #include "cpp_common.h" +#include "co_math.h" +#include "cpps.h" +#include "cpps_task.h" #include "gapc.h" #include "gattc.h" #include "gattc_task.h" -#include "cpps.h" -#include "cpps_task.h" #include "prf_utils.h" -#include "co_math.h" -#include "ke_mem.h" #include "co_utils.h" - +#include "ke_mem.h" /* * CYCLING POWER SERVICE ATTRIBUTES **************************************************************************************** */ - /* * LOCAL FUNCTIONS DEFINITIONS **************************************************************************************** @@ -50,36 +47,35 @@ */ static int cpps_enable_req_handler(ke_msg_id_t const msgid, - struct cpps_enable_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); + struct cpps_enable_req *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - // Status - uint8_t status = PRF_ERR_REQ_DISALLOWED; + // Status + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if(ke_state_get(dest_id) == CPPS_IDLE) - { - // Bonded data was not used before - if (!CPPS_IS_PRESENT(cpps_env->env[param->conidx].prfl_ntf_ind_cfg, CPP_PRF_CFG_PERFORMED_OK)) - { - status = GAP_ERR_NO_ERROR; - // Save configuration and set flag - cpps_env->env[param->conidx].prfl_ntf_ind_cfg = param->prfl_ntf_ind_cfg; - // Enable Bonded Data - CPPS_ENABLE_NTF_IND_BCST(param->conidx, CPP_PRF_CFG_PERFORMED_OK); - } + if (ke_state_get(dest_id) == CPPS_IDLE) { + // Bonded data was not used before + if (!CPPS_IS_PRESENT(cpps_env->env[param->conidx].prfl_ntf_ind_cfg, + CPP_PRF_CFG_PERFORMED_OK)) { + status = GAP_ERR_NO_ERROR; + // Save configuration and set flag + cpps_env->env[param->conidx].prfl_ntf_ind_cfg = param->prfl_ntf_ind_cfg; + // Enable Bonded Data + CPPS_ENABLE_NTF_IND_BCST(param->conidx, CPP_PRF_CFG_PERFORMED_OK); } + } - // send completed information to APP task that contains error status - struct cpps_enable_rsp *cmp_evt = KE_MSG_ALLOC(CPPS_ENABLE_RSP, src_id, dest_id, cpps_enable_rsp); - cmp_evt->status = status; - cmp_evt->conidx = param->conidx; - ke_msg_send(cmp_evt); + // send completed information to APP task that contains error status + struct cpps_enable_rsp *cmp_evt = + KE_MSG_ALLOC(CPPS_ENABLE_RSP, src_id, dest_id, cpps_enable_rsp); + cmp_evt->status = status; + cmp_evt->conidx = param->conidx; + ke_msg_send(cmp_evt); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -93,57 +89,53 @@ static int cpps_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ static int cpps_get_adv_data_req_handler(ke_msg_id_t const msgid, - struct cpps_get_adv_data_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; + struct cpps_get_adv_data_req *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; - // State shall not be Connected or Busy - if (ke_state_get(dest_id) == CPPS_IDLE) - { - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); + // State shall not be Connected or Busy + if (ke_state_get(dest_id) == CPPS_IDLE) { + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - // Allocate the message - struct cpps_get_adv_data_rsp *rsp = KE_MSG_ALLOC_DYN(CPPS_GET_ADV_DATA_RSP, - src_id, dest_id, - cpps_get_adv_data_rsp, CPP_CP_MEAS_ADV_MAX_LEN); + // Allocate the message + struct cpps_get_adv_data_rsp *rsp = + KE_MSG_ALLOC_DYN(CPPS_GET_ADV_DATA_RSP, src_id, dest_id, + cpps_get_adv_data_rsp, CPP_CP_MEAS_ADV_MAX_LEN); + // Set status + rsp->status = GAP_ERR_COMMAND_DISALLOWED; + // Set length + rsp->data_len = 0; + + // Check Broadcast is supported + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->prfl_cfg, CPPS_MEAS_BCST_MASK)) { + // Check if broadcast has been enabled + if (cpps_env->broadcast_enabled) { + // Pack Cp Measurement + rsp->adv_data[0] = + cpps_pack_meas_ntf(¶m->parameters, &rsp->adv_data[4]) + + CPP_CP_ADV_HEADER_LEN; + // Pack Service Data AD type + rsp->adv_data[1] = GAP_AD_TYPE_SERVICE_16_BIT_DATA; + // Pack UUID of CPS + co_write16p(&rsp->adv_data[2], ATT_SVC_CYCLING_POWER); + + // Set data length + rsp->data_len = rsp->adv_data[0] + CPP_CP_ADV_LENGTH_LEN; // Set status - rsp->status = GAP_ERR_COMMAND_DISALLOWED; - // Set length - rsp->data_len = 0; - - // Check Broadcast is supported - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->prfl_cfg, CPPS_MEAS_BCST_MASK)) - { - // Check if broadcast has been enabled - if (cpps_env->broadcast_enabled) - { - // Pack Cp Measurement - rsp->adv_data[0] = cpps_pack_meas_ntf(¶m->parameters, &rsp->adv_data[4]) + CPP_CP_ADV_HEADER_LEN; - // Pack Service Data AD type - rsp->adv_data[1] = GAP_AD_TYPE_SERVICE_16_BIT_DATA; - // Pack UUID of CPS - co_write16p(&rsp->adv_data[2], ATT_SVC_CYCLING_POWER); - - // Set data length - rsp->data_len = rsp->adv_data[0] + CPP_CP_ADV_LENGTH_LEN; - // Set status - rsp->status = GAP_ERR_NO_ERROR; - } - } - - // Send message - ke_msg_send(rsp); - } - else - { - msg_status = KE_MSG_SAVED; + rsp->status = GAP_ERR_NO_ERROR; + } } - return (msg_status); + // Send message + ke_msg_send(rsp); + } else { + msg_status = KE_MSG_SAVED; + } + + return (msg_status); } /** **************************************************************************************** @@ -156,59 +148,57 @@ static int cpps_get_adv_data_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ static int cpps_ntf_cp_meas_req_handler(ke_msg_id_t const msgid, - struct cpps_ntf_cp_meas_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Message status - uint8_t msg_status = KE_MSG_NO_FREE; + struct cpps_ntf_cp_meas_req *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Message status + uint8_t msg_status = KE_MSG_NO_FREE; - // State shall not be Connected or Busy - if (ke_state_get(dest_id) == CPPS_IDLE) - { - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); + // State shall not be Connected or Busy + if (ke_state_get(dest_id) == CPPS_IDLE) { + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - // Configure the environment - cpps_env->operation = CPPS_NTF_MEAS_OP_CODE; - // allocate operation data - cpps_env->op_data = (struct cpps_op*) ke_malloc(sizeof(struct cpps_op), KE_MEM_KE_MSG); - cpps_env->op_data->cmd = ke_param2msg(param); - cpps_env->op_data->cursor = 0; - cpps_env->op_data->ntf_pending = NULL; + // Configure the environment + cpps_env->operation = CPPS_NTF_MEAS_OP_CODE; + // allocate operation data + cpps_env->op_data = + (struct cpps_op *)ke_malloc(sizeof(struct cpps_op), KE_MEM_KE_MSG); + cpps_env->op_data->cmd = ke_param2msg(param); + cpps_env->op_data->cursor = 0; + cpps_env->op_data->ntf_pending = NULL; - // Go to busy state - ke_state_set(dest_id, CPPS_BUSY); + // Go to busy state + ke_state_set(dest_id, CPPS_BUSY); - // Should be updated just once - if (CPPS_IS_PRESENT(param->parameters.flags, CPP_MEAS_WHEEL_REV_DATA_PRESENT)) - { - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, CPP_FEAT_WHEEL_REV_DATA_SUPP)) - { - // Update the cumulative wheel revolutions value stored in the environment - // The value shall not decrement below zero - if (param->parameters.cumul_wheel_rev < 0) - { - cpps_env->cumul_wheel_rev = (co_abs(param->parameters.cumul_wheel_rev) > cpps_env->cumul_wheel_rev) ? - 0 : cpps_env->cumul_wheel_rev + param->parameters.cumul_wheel_rev; - } - else - { - cpps_env->cumul_wheel_rev += param->parameters.cumul_wheel_rev; - } - } + // Should be updated just once + if (CPPS_IS_PRESENT(param->parameters.flags, + CPP_MEAS_WHEEL_REV_DATA_PRESENT)) { + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->features, + CPP_FEAT_WHEEL_REV_DATA_SUPP)) { + // Update the cumulative wheel revolutions value stored in the + // environment The value shall not decrement below zero + if (param->parameters.cumul_wheel_rev < 0) { + cpps_env->cumul_wheel_rev = + (co_abs(param->parameters.cumul_wheel_rev) > + cpps_env->cumul_wheel_rev) + ? 0 + : cpps_env->cumul_wheel_rev + + param->parameters.cumul_wheel_rev; + } else { + cpps_env->cumul_wheel_rev += param->parameters.cumul_wheel_rev; } - - // start operation execution - cpps_exe_operation(); - } - else - { - // Save it for later - msg_status = KE_MSG_SAVED; + } } - return (msg_status); + // start operation execution + cpps_exe_operation(); + } else { + // Save it for later + msg_status = KE_MSG_SAVED; + } + + return (msg_status); } /** @@ -224,56 +214,46 @@ static int cpps_ntf_cp_meas_req_handler(ke_msg_id_t const msgid, static int cpps_ntf_cp_vector_req_handler(ke_msg_id_t const msgid, struct cpps_ntf_cp_vector_req *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; + ke_task_id_t const src_id) { + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; - // State shall be Connected or Busy - if (ke_state_get(dest_id) == CPPS_IDLE) - { - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - // Check Vector characteristic is supported - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->prfl_cfg, CPPS_VECTOR_MASK)) - { - // Configure the environment - cpps_env->operation = CPPS_NTF_VECTOR_OP_CODE; - // allocate operation data - cpps_env->op_data = (struct cpps_op*) ke_malloc(sizeof(struct cpps_op), KE_MEM_KE_MSG); - cpps_env->op_data->cmd = ke_param2msg(param); - cpps_env->op_data->cursor = 0; - cpps_env->op_data->ntf_pending = NULL; - // Go to busy state - ke_state_set(dest_id, CPPS_BUSY); - // start operation execution - cpps_exe_operation(); + // State shall be Connected or Busy + if (ke_state_get(dest_id) == CPPS_IDLE) { + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); + // Check Vector characteristic is supported + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->prfl_cfg, CPPS_VECTOR_MASK)) { + // Configure the environment + cpps_env->operation = CPPS_NTF_VECTOR_OP_CODE; + // allocate operation data + cpps_env->op_data = + (struct cpps_op *)ke_malloc(sizeof(struct cpps_op), KE_MEM_KE_MSG); + cpps_env->op_data->cmd = ke_param2msg(param); + cpps_env->op_data->cursor = 0; + cpps_env->op_data->ntf_pending = NULL; + // Go to busy state + ke_state_set(dest_id, CPPS_BUSY); + // start operation execution + cpps_exe_operation(); - msg_status = KE_MSG_NO_FREE; - } - else - { - // send response to requester - struct cpps_ntf_cp_vector_rsp * rsp = KE_MSG_ALLOC( - CPPS_NTF_CP_VECTOR_RSP, - src_id, - dest_id, - cpps_ntf_cp_vector_rsp); + msg_status = KE_MSG_NO_FREE; + } else { + // send response to requester + struct cpps_ntf_cp_vector_rsp *rsp = KE_MSG_ALLOC( + CPPS_NTF_CP_VECTOR_RSP, src_id, dest_id, cpps_ntf_cp_vector_rsp); - rsp->status = PRF_ERR_FEATURE_NOT_SUPPORTED; - ke_msg_send(rsp); - } - } - else - { - // Keep the message for later - msg_status = KE_MSG_SAVED; + rsp->status = PRF_ERR_FEATURE_NOT_SUPPORTED; + ke_msg_send(rsp); } + } else { + // Keep the message for later + msg_status = KE_MSG_SAVED; + } - return (int)msg_status; + return (int)msg_status; } - /** **************************************************************************************** * @brief Handles reception of the @ref GATTC_WRITE_REQ_IND message. @@ -287,126 +267,108 @@ static int cpps_ntf_cp_vector_req_handler(ke_msg_id_t const msgid, static int gattc_write_req_ind_handler(ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - uint8_t conidx = KE_IDX_GET(src_id); - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; - // Status - uint8_t status = GAP_ERR_NO_ERROR; - // Control Point Status - uint8_t ctl_pt_status = CPP_CTNL_PT_RESP_SUCCESS; + ke_task_id_t const src_id) { + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); + uint8_t conidx = KE_IDX_GET(src_id); + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; + // Status + uint8_t status = GAP_ERR_NO_ERROR; + // Control Point Status + uint8_t ctl_pt_status = CPP_CTNL_PT_RESP_SUCCESS; - if (cpps_env != NULL) - { - // CP Measurement Characteristic, Client Characteristic Configuration Descriptor - if (param->handle == (CPPS_HANDLE(CPS_IDX_CP_MEAS_NTF_CFG))) - { - // Update value - status = cpps_update_characteristic_config(conidx, CPP_PRF_CFG_FLAG_CP_MEAS_NTF, param); - } - // CP Measurement Characteristic, Server Characteristic Configuration Descriptor - else if (param->handle == (CPPS_HANDLE(CPS_IDX_CP_MEAS_BCST_CFG))) - { - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->prfl_cfg, CPPS_MEAS_BCST_MASK)) - { - // Save value - status = cpps_update_characteristic_config(conidx, CPP_PRF_CFG_FLAG_SP_MEAS_NTF, param); - } - else - { - status = ATT_ERR_ATTRIBUTE_NOT_FOUND; - } - } - // CP Vector Characteristic, Client Characteristic Configuration Descriptor - else if (param->handle == (CPPS_HANDLE(CPS_IDX_VECTOR_NTF_CFG))) - { - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->prfl_cfg, CPPS_VECTOR_MASK)) - { - // Update value - status = cpps_update_characteristic_config(conidx, CPP_PRF_CFG_FLAG_VECTOR_NTF, param); - } - else - { - status = ATT_ERR_ATTRIBUTE_NOT_FOUND; - } + if (cpps_env != NULL) { + // CP Measurement Characteristic, Client Characteristic Configuration + // Descriptor + if (param->handle == (CPPS_HANDLE(CPS_IDX_CP_MEAS_NTF_CFG))) { + // Update value + status = cpps_update_characteristic_config( + conidx, CPP_PRF_CFG_FLAG_CP_MEAS_NTF, param); + } + // CP Measurement Characteristic, Server Characteristic Configuration + // Descriptor + else if (param->handle == (CPPS_HANDLE(CPS_IDX_CP_MEAS_BCST_CFG))) { + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->prfl_cfg, CPPS_MEAS_BCST_MASK)) { + // Save value + status = cpps_update_characteristic_config( + conidx, CPP_PRF_CFG_FLAG_SP_MEAS_NTF, param); + } else { + status = ATT_ERR_ATTRIBUTE_NOT_FOUND; + } + } + // CP Vector Characteristic, Client Characteristic Configuration Descriptor + else if (param->handle == (CPPS_HANDLE(CPS_IDX_VECTOR_NTF_CFG))) { + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->prfl_cfg, CPPS_VECTOR_MASK)) { + // Update value + status = cpps_update_characteristic_config( + conidx, CPP_PRF_CFG_FLAG_VECTOR_NTF, param); + } else { + status = ATT_ERR_ATTRIBUTE_NOT_FOUND; + } + } + // CP Control Point Characteristic + else { + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->prfl_cfg, CPPS_CTNL_PT_MASK)) { + // CP Control Point, Client Characteristic Configuration Descriptor + if (param->handle == (CPPS_HANDLE(CPS_IDX_CTNL_PT_IND_CFG))) { + // Update value + status = cpps_update_characteristic_config( + conidx, CPP_PRF_CFG_FLAG_CTNL_PT_IND, param); } // CP Control Point Characteristic - else - { - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->prfl_cfg, CPPS_CTNL_PT_MASK)) - { - // CP Control Point, Client Characteristic Configuration Descriptor - if (param->handle == (CPPS_HANDLE(CPS_IDX_CTNL_PT_IND_CFG))) - { - // Update value - status = cpps_update_characteristic_config(conidx, CPP_PRF_CFG_FLAG_CTNL_PT_IND, param); - } - // CP Control Point Characteristic - else if (param->handle == (CPPS_HANDLE(CPS_IDX_CTNL_PT_VAL))) - { - do - { - // Check if sending of indications has been enabled - if (!CPPS_IS_NTF_IND_BCST_ENABLED(conidx, CPP_PRF_CFG_FLAG_CTNL_PT_IND)) - { - // CPP improperly configured - status = PRF_CCCD_IMPR_CONFIGURED; - break; - } - - if (cpps_env->operation >= CPPS_CTNL_PT_SET_CUMUL_VAL_OP_CODE) - { - // A procedure is already in progress - status = CPP_ERROR_PROC_IN_PROGRESS; - break; - } - - if (cpps_env->operation == CPPS_NTF_MEAS_OP_CODE) - { - // Keep the message until the end of the current procedure - msg_status = KE_MSG_NO_FREE; - break; - } - // Unpack Control Point parameters - ctl_pt_status = cpps_unpack_ctnl_point_ind (conidx, param); - - } while (0); - } - else - { - ASSERT_ERR(0); - } + else if (param->handle == (CPPS_HANDLE(CPS_IDX_CTNL_PT_VAL))) { + do { + // Check if sending of indications has been enabled + if (!CPPS_IS_NTF_IND_BCST_ENABLED(conidx, + CPP_PRF_CFG_FLAG_CTNL_PT_IND)) { + // CPP improperly configured + status = PRF_CCCD_IMPR_CONFIGURED; + break; } - else - { - status = ATT_ERR_ATTRIBUTE_NOT_FOUND; - } - } - - // Vector confirmation is sent by calling cpps_vector_cfg_cfm_handler - if (param->handle != (CPPS_HANDLE(CPS_IDX_VECTOR_NTF_CFG))) - { - //Send write response - struct gattc_write_cfm *cfm = KE_MSG_ALLOC( - GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = status; - ke_msg_send(cfm); - - // Check if control point failed - if ((param->handle == (CPPS_HANDLE(CPS_IDX_CTNL_PT_VAL))) && - (ctl_pt_status != CPP_CTNL_PT_RESP_SUCCESS)) - { - // Send response to peer - cpps_send_rsp_ind(conidx, param->value[0], ctl_pt_status); + + if (cpps_env->operation >= CPPS_CTNL_PT_SET_CUMUL_VAL_OP_CODE) { + // A procedure is already in progress + status = CPP_ERROR_PROC_IN_PROGRESS; + break; } + + if (cpps_env->operation == CPPS_NTF_MEAS_OP_CODE) { + // Keep the message until the end of the current procedure + msg_status = KE_MSG_NO_FREE; + break; + } + // Unpack Control Point parameters + ctl_pt_status = cpps_unpack_ctnl_point_ind(conidx, param); + + } while (0); + } else { + ASSERT_ERR(0); } + } else { + status = ATT_ERR_ATTRIBUTE_NOT_FOUND; + } } - return (int)msg_status; + // Vector confirmation is sent by calling cpps_vector_cfg_cfm_handler + if (param->handle != (CPPS_HANDLE(CPS_IDX_VECTOR_NTF_CFG))) { + // Send write response + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = status; + ke_msg_send(cfm); + + // Check if control point failed + if ((param->handle == (CPPS_HANDLE(CPS_IDX_CTNL_PT_VAL))) && + (ctl_pt_status != CPP_CTNL_PT_RESP_SUCCESS)) { + // Send response to peer + cpps_send_rsp_ind(conidx, param->value[0], ctl_pt_status); + } + } + } + + return (int)msg_status; } /** @@ -421,51 +383,45 @@ static int gattc_write_req_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ static int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_att_info_req_ind *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if(ke_state_get(dest_id) == CPPS_IDLE) - { - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - uint8_t att_idx = CPPS_IDX(param->handle); - struct gattc_att_info_cfm * cfm; + struct gattc_att_info_req_ind *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + if (ke_state_get(dest_id) == CPPS_IDLE) { + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); + uint8_t att_idx = CPPS_IDX(param->handle); + struct gattc_att_info_cfm *cfm; - //Send write response - cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); - cfm->handle = param->handle; + // Send write response + cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); + cfm->handle = param->handle; - // check if it's a client configuration char - if((att_idx == CPS_IDX_CP_MEAS_NTF_CFG) - || (att_idx == CPS_IDX_CP_MEAS_BCST_CFG) - || (att_idx == CPS_IDX_VECTOR_NTF_CFG) - || (att_idx == CPS_IDX_CTNL_PT_IND_CFG)) - { - // CCC attribute length = 2 - cfm->length = 2; - cfm->status = GAP_ERR_NO_ERROR; - } + // check if it's a client configuration char + if ((att_idx == CPS_IDX_CP_MEAS_NTF_CFG) || + (att_idx == CPS_IDX_CP_MEAS_BCST_CFG) || + (att_idx == CPS_IDX_VECTOR_NTF_CFG) || + (att_idx == CPS_IDX_CTNL_PT_IND_CFG)) { + // CCC attribute length = 2 + cfm->length = 2; + cfm->status = GAP_ERR_NO_ERROR; + } - else if (att_idx == CPS_IDX_CTNL_PT_VAL) - { - // force length to zero to reject any write starting from something != 0 - cfm->length = 0; - cfm->status = GAP_ERR_NO_ERROR; - } - // not expected request - else - { - cfm->length = 0; - cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; - } - ke_msg_send(cfm); - } + else if (att_idx == CPS_IDX_CTNL_PT_VAL) { + // force length to zero to reject any write starting from something != 0 + cfm->length = 0; + cfm->status = GAP_ERR_NO_ERROR; + } + // not expected request + else { + cfm->length = 0; + cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; + } + ke_msg_send(cfm); + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } - /** **************************************************************************************** * @brief Handles reception of the read request from peer device @@ -480,95 +436,91 @@ static int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, static int gattc_read_req_ind_handler(ke_msg_id_t const msgid, struct gattc_read_req_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if(ke_state_get(dest_id) == CPPS_IDLE) - { - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - uint8_t conidx = KE_IDX_GET(src_id); - uint8_t att_idx = CPPS_IDX(param->handle); + ke_task_id_t const src_id) { + if (ke_state_get(dest_id) == CPPS_IDLE) { + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); + uint8_t conidx = KE_IDX_GET(src_id); + uint8_t att_idx = CPPS_IDX(param->handle); - uint8_t value[4]; - uint8_t value_size = 0; - uint8_t status = ATT_ERR_NO_ERROR; + uint8_t value[4]; + uint8_t value_size = 0; + uint8_t status = ATT_ERR_NO_ERROR; - switch(att_idx) - { - case CPS_IDX_CP_MEAS_NTF_CFG: - { - value_size = sizeof(uint16_t); - co_write16p(value, (cpps_env->env[conidx].prfl_ntf_ind_cfg & CPP_PRF_CFG_FLAG_CP_MEAS_NTF) - ? PRF_CLI_START_NTF : PRF_CLI_STOP_NTFIND); - } break; + switch (att_idx) { + case CPS_IDX_CP_MEAS_NTF_CFG: { + value_size = sizeof(uint16_t); + co_write16p(value, (cpps_env->env[conidx].prfl_ntf_ind_cfg & + CPP_PRF_CFG_FLAG_CP_MEAS_NTF) + ? PRF_CLI_START_NTF + : PRF_CLI_STOP_NTFIND); + } break; - case CPS_IDX_CP_MEAS_BCST_CFG: - { - // Broadcast feature is profile specific - if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->prfl_cfg, CPPS_MEAS_BCST_MASK)) - { - // Fill data - value_size = sizeof(uint16_t); - // Broadcast status is also masked per connection (useful for bonding data) - co_write16p(value, (cpps_env->env[conidx].prfl_ntf_ind_cfg & CPP_PRF_CFG_FLAG_SP_MEAS_NTF) - ? PRF_SRV_START_BCST : PRF_SRV_STOP_BCST); - } - else - { - status = ATT_ERR_ATTRIBUTE_NOT_FOUND; - } - } break; + case CPS_IDX_CP_MEAS_BCST_CFG: { + // Broadcast feature is profile specific + if (CPPS_IS_FEATURE_SUPPORTED(cpps_env->prfl_cfg, CPPS_MEAS_BCST_MASK)) { + // Fill data + value_size = sizeof(uint16_t); + // Broadcast status is also masked per connection (useful for bonding + // data) + co_write16p(value, (cpps_env->env[conidx].prfl_ntf_ind_cfg & + CPP_PRF_CFG_FLAG_SP_MEAS_NTF) + ? PRF_SRV_START_BCST + : PRF_SRV_STOP_BCST); + } else { + status = ATT_ERR_ATTRIBUTE_NOT_FOUND; + } + } break; - case CPS_IDX_VECTOR_NTF_CFG: - { - // Fill data - value_size = sizeof(uint16_t); - co_write16p(value, (cpps_env->env[conidx].prfl_ntf_ind_cfg & CPP_PRF_CFG_FLAG_VECTOR_NTF) - ? PRF_CLI_START_NTF : PRF_CLI_STOP_NTFIND); - } break; + case CPS_IDX_VECTOR_NTF_CFG: { + // Fill data + value_size = sizeof(uint16_t); + co_write16p(value, (cpps_env->env[conidx].prfl_ntf_ind_cfg & + CPP_PRF_CFG_FLAG_VECTOR_NTF) + ? PRF_CLI_START_NTF + : PRF_CLI_STOP_NTFIND); + } break; - case CPS_IDX_CTNL_PT_IND_CFG: - { - // Fill data - value_size = sizeof(uint16_t); - co_write16p(value, (cpps_env->env[conidx].prfl_ntf_ind_cfg & CPP_PRF_CFG_FLAG_CTNL_PT_IND) - ? PRF_CLI_START_IND : PRF_CLI_STOP_NTFIND); - } break; + case CPS_IDX_CTNL_PT_IND_CFG: { + // Fill data + value_size = sizeof(uint16_t); + co_write16p(value, (cpps_env->env[conidx].prfl_ntf_ind_cfg & + CPP_PRF_CFG_FLAG_CTNL_PT_IND) + ? PRF_CLI_START_IND + : PRF_CLI_STOP_NTFIND); + } break; - case CPS_IDX_CP_FEAT_VAL: - { - // Fill data - value_size = sizeof(uint32_t); - co_write32p(value, cpps_env->features); - } break; + case CPS_IDX_CP_FEAT_VAL: { + // Fill data + value_size = sizeof(uint32_t); + co_write32p(value, cpps_env->features); + } break; - case CPS_IDX_SENSOR_LOC_VAL: - { - // Fill data - value_size = sizeof(uint8_t); - value[0] = cpps_env->sensor_loc; - } break; + case CPS_IDX_SENSOR_LOC_VAL: { + // Fill data + value_size = sizeof(uint8_t); + value[0] = cpps_env->sensor_loc; + } break; - default: - { - status = ATT_ERR_REQUEST_NOT_SUPPORTED; - } break; - } - - // Send data to peer device - struct gattc_read_cfm* cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, value_size); - cfm->length = value_size; - memcpy(cfm->value, value, value_size); - cfm->handle = param->handle; - cfm->status = status; - - // Send value to peer device. - ke_msg_send(cfm); + default: { + status = ATT_ERR_REQUEST_NOT_SUPPORTED; + } break; } - return (KE_MSG_CONSUMED); -} + // Send data to peer device + struct gattc_read_cfm *cfm = KE_MSG_ALLOC_DYN( + GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, value_size); + cfm->length = value_size; + memcpy(cfm->value, value, value_size); + cfm->handle = param->handle; + cfm->status = status; + // Send value to peer device. + ke_msg_send(cfm); + } + + return (KE_MSG_CONSUMED); +} /** **************************************************************************************** @@ -581,39 +533,39 @@ static int gattc_read_req_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ static int cpps_vector_cfg_cfm_handler(ke_msg_id_t const msgid, - struct cpps_vector_cfg_cfm *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - // Status - uint8_t status = PRF_APP_ERROR; + struct cpps_vector_cfg_cfm *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); + // Status + uint8_t status = PRF_APP_ERROR; - if (ke_state_get(dest_id) == CPPS_IDLE) - { - if (param->status == GAP_ERR_NO_ERROR) - { - if ((param->ntf_cfg == PRF_CLI_STOP_NTFIND) || (param->ntf_cfg == PRF_CLI_START_NTF)) - { - // Save the new configuration in the environment - (param->ntf_cfg == PRF_CLI_STOP_NTFIND) ? - CPPS_DISABLE_NTF_IND_BCST(param->conidx, CPP_PRF_CFG_FLAG_VECTOR_NTF) : - CPPS_ENABLE_NTF_IND_BCST(param->conidx, CPP_PRF_CFG_FLAG_VECTOR_NTF); + if (ke_state_get(dest_id) == CPPS_IDLE) { + if (param->status == GAP_ERR_NO_ERROR) { + if ((param->ntf_cfg == PRF_CLI_STOP_NTFIND) || + (param->ntf_cfg == PRF_CLI_START_NTF)) { + // Save the new configuration in the environment + (param->ntf_cfg == PRF_CLI_STOP_NTFIND) + ? CPPS_DISABLE_NTF_IND_BCST(param->conidx, + CPP_PRF_CFG_FLAG_VECTOR_NTF) + : CPPS_ENABLE_NTF_IND_BCST(param->conidx, + CPP_PRF_CFG_FLAG_VECTOR_NTF); - status = GAP_ERR_NO_ERROR; - } - } - - //Send write response - struct gattc_write_cfm *cfm = KE_MSG_ALLOC( - GATTC_WRITE_CFM, KE_BUILD_ID(TASK_GATTC, param->conidx), dest_id, gattc_write_cfm); - cfm->handle = CPPS_HANDLE(CPS_IDX_VECTOR_NTF_CFG); - cfm->status = status; - ke_msg_send(cfm); + status = GAP_ERR_NO_ERROR; + } } - return (KE_MSG_CONSUMED); + // Send write response + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, KE_BUILD_ID(TASK_GATTC, param->conidx), + dest_id, gattc_write_cfm); + cfm->handle = CPPS_HANDLE(CPS_IDX_VECTOR_NTF_CFG); + cfm->status = status; + ke_msg_send(cfm); + } + + return (KE_MSG_CONSUMED); } /** @@ -627,74 +579,69 @@ static int cpps_vector_cfg_cfm_handler(ke_msg_id_t const msgid, **************************************************************************************** */ static int cpps_ctnl_pt_cfm_handler(ke_msg_id_t const msgid, - struct cpps_ctnl_pt_cfm *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - uint8_t status = GAP_ERR_NO_ERROR; + struct cpps_ctnl_pt_cfm *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); + uint8_t status = GAP_ERR_NO_ERROR; - if (ke_state_get(dest_id) == CPPS_BUSY) - { - do - { - // Check the current operation - if (cpps_env->operation < CPPS_CTNL_PT_SET_CUMUL_VAL_OP_CODE) - { - // The confirmation has been sent without request indication, ignore - break; - } + if (ke_state_get(dest_id) == CPPS_BUSY) { + do { + // Check the current operation + if (cpps_env->operation < CPPS_CTNL_PT_SET_CUMUL_VAL_OP_CODE) { + // The confirmation has been sent without request indication, ignore + break; + } - // The CP Control Point Characteristic must be supported if we are here - if (!CPPS_IS_FEATURE_SUPPORTED(cpps_env->prfl_cfg, CPPS_CTNL_PT_MASK)) - { - status = PRF_ERR_REQ_DISALLOWED; - break; - } + // The CP Control Point Characteristic must be supported if we are here + if (!CPPS_IS_FEATURE_SUPPORTED(cpps_env->prfl_cfg, CPPS_CTNL_PT_MASK)) { + status = PRF_ERR_REQ_DISALLOWED; + break; + } - // Check if sending of indications has been enabled - if (!CPPS_IS_NTF_IND_BCST_ENABLED(param->conidx, CPP_PRF_CFG_FLAG_CTNL_PT_IND)) - { - // CPP improperly configured - status = PRF_CCCD_IMPR_CONFIGURED; - break; - } + // Check if sending of indications has been enabled + if (!CPPS_IS_NTF_IND_BCST_ENABLED(param->conidx, + CPP_PRF_CFG_FLAG_CTNL_PT_IND)) { + // CPP improperly configured + status = PRF_CCCD_IMPR_CONFIGURED; + break; + } - // Allocate the GATT notification message - struct gattc_send_evt_cmd *ctl_pt_rsp = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, param->conidx), dest_id, - gattc_send_evt_cmd, CPP_CP_CNTL_PT_RSP_MAX_LEN); + // Allocate the GATT notification message + struct gattc_send_evt_cmd *ctl_pt_rsp = KE_MSG_ALLOC_DYN( + GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, param->conidx), dest_id, + gattc_send_evt_cmd, CPP_CP_CNTL_PT_RSP_MAX_LEN); - // Fill in the parameter structure - ctl_pt_rsp->operation = GATTC_INDICATE; - ctl_pt_rsp->handle = CPPS_HANDLE(CPS_IDX_CTNL_PT_VAL); - // Pack Control Point confirmation - ctl_pt_rsp->length = cpps_pack_ctnl_point_cfm (param->conidx, param, ctl_pt_rsp->value); + // Fill in the parameter structure + ctl_pt_rsp->operation = GATTC_INDICATE; + ctl_pt_rsp->handle = CPPS_HANDLE(CPS_IDX_CTNL_PT_VAL); + // Pack Control Point confirmation + ctl_pt_rsp->length = + cpps_pack_ctnl_point_cfm(param->conidx, param, ctl_pt_rsp->value); - // Send the event - ke_msg_send(ctl_pt_rsp); + // Send the event + ke_msg_send(ctl_pt_rsp); - } while (0); + } while (0); - if (status != GAP_ERR_NO_ERROR) - { - // Inform the application that a procedure has been completed - cpps_send_cmp_evt(param->conidx, - prf_src_task_get(&cpps_env->prf_env, param->conidx), - prf_dst_task_get(&cpps_env->prf_env, param->conidx), - cpps_env->operation, status); - } + if (status != GAP_ERR_NO_ERROR) { + // Inform the application that a procedure has been completed + cpps_send_cmp_evt(param->conidx, + prf_src_task_get(&cpps_env->prf_env, param->conidx), + prf_dst_task_get(&cpps_env->prf_env, param->conidx), + cpps_env->operation, status); } + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } - /** **************************************************************************************** - * @brief Handles @ref GATT_NOTIFY_CMP_EVT message meaning that a notification or an indication - * has been correctly sent to peer device (but not confirmed by peer device). + * @brief Handles @ref GATT_NOTIFY_CMP_EVT message meaning that a notification + *or an indication has been correctly sent to peer device (but not confirmed by + *peer device). * * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. @@ -703,44 +650,40 @@ static int cpps_ctnl_pt_cfm_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -static int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - uint8_t conidx = KE_IDX_GET(src_id); - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); +static int gattc_cmp_evt_handler(ke_msg_id_t const msgid, + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t conidx = KE_IDX_GET(src_id); + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - // Check if a connection exists - if (ke_state_get(dest_id) == CPPS_BUSY) - { - switch (param->operation) - { - case (GATTC_NOTIFY): - { - // On-going operation execution - cpps_exe_operation(); - } break; + // Check if a connection exists + if (ke_state_get(dest_id) == CPPS_BUSY) { + switch (param->operation) { + case (GATTC_NOTIFY): { + // On-going operation execution + cpps_exe_operation(); + } break; - case (GATTC_INDICATE): - { - ASSERT_INFO(cpps_env->operation >= CPPS_CTNL_PT_SET_CUMUL_VAL_OP_CODE, 0, 0); + case (GATTC_INDICATE): { + ASSERT_INFO(cpps_env->operation >= CPPS_CTNL_PT_SET_CUMUL_VAL_OP_CODE, 0, + 0); - // Inform the application that a procedure has been completed - cpps_send_cmp_evt(conidx, - prf_src_task_get(&cpps_env->prf_env, conidx), + // Inform the application that a procedure has been completed + cpps_send_cmp_evt(conidx, prf_src_task_get(&cpps_env->prf_env, conidx), prf_dst_task_get(&cpps_env->prf_env, conidx), cpps_env->operation, param->status); - // else ignore the message - } break; + // else ignore the message + } break; - default: - { - ASSERT_ERR(0); - } break; - } + default: { + ASSERT_ERR(0); + } break; } + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /* @@ -749,29 +692,27 @@ static int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt */ /// Specifies the default message handlers -KE_MSG_HANDLER_TAB(cpps) -{ - {CPPS_ENABLE_REQ, (ke_msg_func_t) cpps_enable_req_handler}, - {GATTC_WRITE_REQ_IND, (ke_msg_func_t) gattc_write_req_ind_handler}, - {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t) gattc_att_info_req_ind_handler}, - {GATTC_READ_REQ_IND, (ke_msg_func_t) gattc_read_req_ind_handler}, - {CPPS_GET_ADV_DATA_REQ, (ke_msg_func_t) cpps_get_adv_data_req_handler}, - {CPPS_NTF_CP_MEAS_REQ, (ke_msg_func_t) cpps_ntf_cp_meas_req_handler}, - {CPPS_NTF_CP_VECTOR_REQ, (ke_msg_func_t) cpps_ntf_cp_vector_req_handler}, - {CPPS_CTNL_PT_CFM, (ke_msg_func_t) cpps_ctnl_pt_cfm_handler}, - {CPPS_VECTOR_CFG_CFM, (ke_msg_func_t) cpps_vector_cfg_cfm_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t) gattc_cmp_evt_handler}, +KE_MSG_HANDLER_TAB(cpps){ + {CPPS_ENABLE_REQ, (ke_msg_func_t)cpps_enable_req_handler}, + {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, + {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t)gattc_att_info_req_ind_handler}, + {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, + {CPPS_GET_ADV_DATA_REQ, (ke_msg_func_t)cpps_get_adv_data_req_handler}, + {CPPS_NTF_CP_MEAS_REQ, (ke_msg_func_t)cpps_ntf_cp_meas_req_handler}, + {CPPS_NTF_CP_VECTOR_REQ, (ke_msg_func_t)cpps_ntf_cp_vector_req_handler}, + {CPPS_CTNL_PT_CFM, (ke_msg_func_t)cpps_ctnl_pt_cfm_handler}, + {CPPS_VECTOR_CFG_CFM, (ke_msg_func_t)cpps_vector_cfg_cfm_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void cpps_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); +void cpps_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct cpps_env_tag *cpps_env = PRF_ENV_GET(CPPS, cpps); - task_desc->msg_handler_tab = cpps_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(cpps_msg_handler_tab); - task_desc->state = cpps_env->state; - task_desc->idx_max = CPPS_IDX_MAX; + task_desc->msg_handler_tab = cpps_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(cpps_msg_handler_tab); + task_desc->state = cpps_env->state; + task_desc->idx_max = CPPS_IDX_MAX; } #endif //(BLE_CSC_SENSOR) diff --git a/services/ble_profiles/cscp/cscpc/src/cscpc.c b/services/ble_profiles/cscp/cscpc/src/cscpc.c index b603cbc..cf0ce63 100644 --- a/services/ble_profiles/cscp/cscpc/src/cscpc.c +++ b/services/ble_profiles/cscp/cscpc/src/cscpc.c @@ -18,15 +18,14 @@ #include "cscpc_task.h" #include "ke_timer.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * GLOBAL VARIABLES DECLARATION **************************************************************************************** */ - /* * GLOBAL FUNCTIONS DEFINITIONS **************************************************************************************** @@ -44,41 +43,45 @@ * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t cscpc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t idx; - //-------------------- allocate memory required for the profile --------------------- +static uint8_t cscpc_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t idx; + //-------------------- allocate memory required for the profile + //--------------------- - struct cscpc_env_tag* cscpc_env = - (struct cscpc_env_tag* ) ke_malloc(sizeof(struct cscpc_env_tag), KE_MEM_ATT_DB); + struct cscpc_env_tag *cscpc_env = (struct cscpc_env_tag *)ke_malloc( + sizeof(struct cscpc_env_tag), KE_MEM_ATT_DB); - // allocate CSCPC required environment variable - env->env = (prf_env_t*) cscpc_env; + // allocate CSCPC required environment variable + env->env = (prf_env_t *)cscpc_env; - cscpc_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - cscpc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + cscpc_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + cscpc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_CSCPC; - cscpc_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_CSCPC; + cscpc_task_init(&(env->desc)); - for(idx = 0; idx < CSCPC_IDX_MAX ; idx++) - { - cscpc_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), CSCPC_FREE); - } + for (idx = 0; idx < CSCPC_IDX_MAX; idx++) { + cscpc_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), CSCPC_FREE); + } - return GAP_ERR_NO_ERROR; + return GAP_ERR_NO_ERROR; } /** @@ -90,50 +93,47 @@ static uint8_t cscpc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_ * @param[in] reason Detach reason **************************************************************************************** */ -static void cscpc_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct cscpc_env_tag* cscpc_env = (struct cscpc_env_tag*) env->env; +static void cscpc_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct cscpc_env_tag *cscpc_env = (struct cscpc_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(cscpc_env->env[conidx] != NULL) - { - if (cscpc_env->env[conidx]->operation != NULL) - { - ke_free(ke_param2msg(cscpc_env->env[conidx]->operation)); - } - ke_timer_clear(CSCPC_TIMEOUT_TIMER_IND, prf_src_task_get(&cscpc_env->prf_env, conidx)); - - ke_free(cscpc_env->env[conidx]); - cscpc_env->env[conidx] = NULL; + // clean-up environment variable allocated for task instance + if (cscpc_env->env[conidx] != NULL) { + if (cscpc_env->env[conidx]->operation != NULL) { + ke_free(ke_param2msg(cscpc_env->env[conidx]->operation)); } + ke_timer_clear(CSCPC_TIMEOUT_TIMER_IND, + prf_src_task_get(&cscpc_env->prf_env, conidx)); - /* Put CSCP Client in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), CSCPC_FREE); + ke_free(cscpc_env->env[conidx]); + cscpc_env->env[conidx] = NULL; + } + + /* Put CSCP Client in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), CSCPC_FREE); } /** **************************************************************************************** * @brief Destruction of the CSCPC module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void cscpc_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct cscpc_env_tag* cscpc_env = (struct cscpc_env_tag*) env->env; +static void cscpc_destroy(struct prf_task_env *env) { + uint8_t idx; + struct cscpc_env_tag *cscpc_env = (struct cscpc_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < CSCPC_IDX_MAX ; idx++) - { - cscpc_cleanup(env, idx, 0); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < CSCPC_IDX_MAX; idx++) { + cscpc_cleanup(env, idx, 0); + } - // free profile environment variables - env->env = NULL; - ke_free(cscpc_env); + // free profile environment variables + env->env = NULL; + ke_free(cscpc_env); } /** @@ -144,19 +144,17 @@ static void cscpc_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void cscpc_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Put CSCP Client in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), CSCPC_IDLE); +static void cscpc_create(struct prf_task_env *env, uint8_t conidx) { + /* Put CSCP Client in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), CSCPC_IDLE); } /// CSCPC Task interface required by profile manager -const struct prf_task_cbs cscpc_itf = -{ - cscpc_init, - cscpc_destroy, - cscpc_create, - cscpc_cleanup, +const struct prf_task_cbs cscpc_itf = { + cscpc_init, + cscpc_destroy, + cscpc_create, + cscpc_cleanup, }; /* @@ -164,72 +162,63 @@ const struct prf_task_cbs cscpc_itf = **************************************************************************************** */ -const struct prf_task_cbs* cscpc_prf_itf_get(void) -{ - return &cscpc_itf; +const struct prf_task_cbs *cscpc_prf_itf_get(void) { return &cscpc_itf; } + +void cscpc_enable_rsp_send(struct cscpc_env_tag *cscpc_env, uint8_t conidx, + uint8_t status) { + // Send to APP the details of the discovered attributes on CSCPS + struct cscpc_enable_rsp *rsp = KE_MSG_ALLOC( + CSCPC_ENABLE_RSP, prf_dst_task_get(&(cscpc_env->prf_env), conidx), + prf_src_task_get(&(cscpc_env->prf_env), conidx), cscpc_enable_rsp); + rsp->status = status; + + if (status == GAP_ERR_NO_ERROR) { + rsp->cscs = cscpc_env->env[conidx]->cscs; + // Register CSCPC task in gatt for indication/notifications + prf_register_atthdl2gatt(&(cscpc_env->prf_env), conidx, + &(cscpc_env->env[conidx]->cscs.svc)); + // Go to connected state + ke_state_set(prf_src_task_get(&(cscpc_env->prf_env), conidx), CSCPC_IDLE); + } + + ke_msg_send(rsp); } +void cscpc_send_no_conn_cmp_evt(uint8_t src_id, uint8_t dest_id, + uint8_t operation) { + // Send the message + struct cscpc_cmp_evt *evt = + KE_MSG_ALLOC(CSCPC_CMP_EVT, dest_id, src_id, cscpc_cmp_evt); -void cscpc_enable_rsp_send(struct cscpc_env_tag *cscpc_env, uint8_t conidx, uint8_t status) -{ - // Send to APP the details of the discovered attributes on CSCPS - struct cscpc_enable_rsp * rsp = KE_MSG_ALLOC( - CSCPC_ENABLE_RSP, - prf_dst_task_get(&(cscpc_env->prf_env), conidx), - prf_src_task_get(&(cscpc_env->prf_env), conidx), - cscpc_enable_rsp); - rsp->status = status; + evt->operation = operation; + evt->status = PRF_ERR_REQ_DISALLOWED; - if (status == GAP_ERR_NO_ERROR) - { - rsp->cscs = cscpc_env->env[conidx]->cscs; - // Register CSCPC task in gatt for indication/notifications - prf_register_atthdl2gatt(&(cscpc_env->prf_env), conidx, &(cscpc_env->env[conidx]->cscs.svc)); - // Go to connected state - ke_state_set(prf_src_task_get(&(cscpc_env->prf_env), conidx), CSCPC_IDLE); - } - - ke_msg_send(rsp); + ke_msg_send(evt); } -void cscpc_send_no_conn_cmp_evt(uint8_t src_id, uint8_t dest_id, uint8_t operation) -{ - // Send the message - struct cscpc_cmp_evt *evt = KE_MSG_ALLOC(CSCPC_CMP_EVT, - dest_id, src_id, - cscpc_cmp_evt); +void cscpc_send_cmp_evt(struct cscpc_env_tag *cscpc_env, uint8_t conidx, + uint8_t operation, uint8_t status) { + // Free the stored operation if needed + if (cscpc_env->env[conidx]->operation != NULL) { + ke_msg_free(ke_param2msg(cscpc_env->env[conidx]->operation)); + cscpc_env->env[conidx]->operation = NULL; + } - evt->operation = operation; - evt->status = PRF_ERR_REQ_DISALLOWED; + // Go back to the CONNECTED state if the state is busy + if (ke_state_get(prf_src_task_get(&(cscpc_env->prf_env), conidx)) == + CSCPC_BUSY) { + ke_state_set(prf_src_task_get(&(cscpc_env->prf_env), conidx), CSCPC_IDLE); + } - ke_msg_send(evt); -} + // Send the message + struct cscpc_cmp_evt *evt = KE_MSG_ALLOC( + CSCPC_CMP_EVT, prf_dst_task_get(&(cscpc_env->prf_env), conidx), + prf_src_task_get(&(cscpc_env->prf_env), conidx), cscpc_cmp_evt); -void cscpc_send_cmp_evt(struct cscpc_env_tag *cscpc_env, uint8_t conidx, uint8_t operation, uint8_t status) -{ - // Free the stored operation if needed - if (cscpc_env->env[conidx]->operation != NULL) - { - ke_msg_free(ke_param2msg(cscpc_env->env[conidx]->operation)); - cscpc_env->env[conidx]->operation = NULL; - } + evt->operation = operation; + evt->status = status; - // Go back to the CONNECTED state if the state is busy - if (ke_state_get(prf_src_task_get(&(cscpc_env->prf_env), conidx)) == CSCPC_BUSY) - { - ke_state_set(prf_src_task_get(&(cscpc_env->prf_env), conidx), CSCPC_IDLE); - } - - // Send the message - struct cscpc_cmp_evt *evt = KE_MSG_ALLOC(CSCPC_CMP_EVT, - prf_dst_task_get(&(cscpc_env->prf_env), conidx), - prf_src_task_get(&(cscpc_env->prf_env), conidx), - cscpc_cmp_evt); - - evt->operation = operation; - evt->status = status; - - ke_msg_send(evt); + ke_msg_send(evt); } #endif //(BLE_CSC_COLLECTOR) diff --git a/services/ble_profiles/cscp/cscpc/src/cscpc_task.c b/services/ble_profiles/cscp/cscpc/src/cscpc_task.c index 702e5fd..3c09b28 100644 --- a/services/ble_profiles/cscp/cscpc/src/cscpc_task.c +++ b/services/ble_profiles/cscp/cscpc/src/cscpc_task.c @@ -14,54 +14,48 @@ #if (BLE_CSC_COLLECTOR) #include "cscp_common.h" -#include "cscpc_task.h" #include "cscpc.h" +#include "cscpc_task.h" #include "gap.h" #include "gattc_task.h" -#include "ke_timer.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" +#include "ke_timer.h" /* * STRUCTURES **************************************************************************************** */ -/// State machine used to retrieve Cycling Speed and Cadence service characteristics information -const struct prf_char_def cscpc_cscs_char[CSCP_CSCS_CHAR_MAX] = -{ +/// State machine used to retrieve Cycling Speed and Cadence service +/// characteristics information +const struct prf_char_def cscpc_cscs_char[CSCP_CSCS_CHAR_MAX] = { /// CSC Measurement - [CSCP_CSCS_CSC_MEAS_CHAR] = {ATT_CHAR_CSC_MEAS, - ATT_MANDATORY, - ATT_CHAR_PROP_NTF}, + [CSCP_CSCS_CSC_MEAS_CHAR] = {ATT_CHAR_CSC_MEAS, ATT_MANDATORY, + ATT_CHAR_PROP_NTF}, /// CSC Feature - [CSCP_CSCS_CSC_FEAT_CHAR] = {ATT_CHAR_CSC_FEAT, - ATT_MANDATORY, - ATT_CHAR_PROP_RD}, + [CSCP_CSCS_CSC_FEAT_CHAR] = {ATT_CHAR_CSC_FEAT, ATT_MANDATORY, + ATT_CHAR_PROP_RD}, /// Sensor Location - [CSCP_CSCS_SENSOR_LOC_CHAR] = {ATT_CHAR_SENSOR_LOC, - ATT_OPTIONAL, - ATT_CHAR_PROP_RD}, + [CSCP_CSCS_SENSOR_LOC_CHAR] = {ATT_CHAR_SENSOR_LOC, ATT_OPTIONAL, + ATT_CHAR_PROP_RD}, /// SC Control Point - [CSCP_CSCS_SC_CTNL_PT_CHAR] = {ATT_CHAR_SC_CNTL_PT, - ATT_OPTIONAL, - ATT_CHAR_PROP_WR | ATT_CHAR_PROP_IND}, + [CSCP_CSCS_SC_CTNL_PT_CHAR] = {ATT_CHAR_SC_CNTL_PT, ATT_OPTIONAL, + ATT_CHAR_PROP_WR | ATT_CHAR_PROP_IND}, }; -/// State machine used to retrieve Cycling Speed and Cadence service characteristic descriptor information -const struct prf_char_desc_def cscpc_cscs_char_desc[CSCPC_DESC_MAX] = -{ +/// State machine used to retrieve Cycling Speed and Cadence service +/// characteristic descriptor information +const struct prf_char_desc_def cscpc_cscs_char_desc[CSCPC_DESC_MAX] = { /// CSC Measurement Char. - Client Characteristic Configuration - [CSCPC_DESC_CSC_MEAS_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, - ATT_MANDATORY, - CSCP_CSCS_CSC_MEAS_CHAR}, + [CSCPC_DESC_CSC_MEAS_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, + CSCP_CSCS_CSC_MEAS_CHAR}, /// SC Control Point Char. - Client Characteristic Configuration - [CSCPC_DESC_SC_CTNL_PT_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, - ATT_OPTIONAL, - CSCP_CSCS_SC_CTNL_PT_CHAR}, + [CSCPC_DESC_SC_CTNL_PT_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_OPTIONAL, + CSCP_CSCS_SC_CTNL_PT_CHAR}, }; /* @@ -81,40 +75,37 @@ const struct prf_char_desc_def cscpc_cscs_char_desc[CSCPC_DESC_MAX] = **************************************************************************************** */ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, - struct gattc_sdp_svc_ind const *ind, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_sdp_svc_ind const *ind, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == CSCPC_DISCOVERING) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == CSCPC_DISCOVERING) { + uint8_t conidx = KE_IDX_GET(dest_id); - struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); + struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); - ASSERT_INFO(cscpc_env != NULL, dest_id, src_id); - ASSERT_INFO(cscpc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(cscpc_env != NULL, dest_id, src_id); + ASSERT_INFO(cscpc_env->env[conidx] != NULL, dest_id, src_id); - if(cscpc_env->env[conidx]->nb_svc == 0) - { - // Retrieve CSCS characteristics and descriptors - prf_extract_svc_info(ind, CSCP_CSCS_CHAR_MAX, &cscpc_cscs_char[0], &cscpc_env->env[conidx]->cscs.chars[0], - CSCPC_DESC_MAX, &cscpc_cscs_char_desc[0], &cscpc_env->env[conidx]->cscs.descs[0]); + if (cscpc_env->env[conidx]->nb_svc == 0) { + // Retrieve CSCS characteristics and descriptors + prf_extract_svc_info(ind, CSCP_CSCS_CHAR_MAX, &cscpc_cscs_char[0], + &cscpc_env->env[conidx]->cscs.chars[0], + CSCPC_DESC_MAX, &cscpc_cscs_char_desc[0], + &cscpc_env->env[conidx]->cscs.descs[0]); - //Even if we get multiple responses we only store 1 range - cscpc_env->env[conidx]->cscs.svc.shdl = ind->start_hdl; - cscpc_env->env[conidx]->cscs.svc.ehdl = ind->end_hdl; - } - - cscpc_env->env[conidx]->nb_svc++; + // Even if we get multiple responses we only store 1 range + cscpc_env->env[conidx]->cscs.svc.shdl = ind->start_hdl; + cscpc_env->env[conidx]->cscs.svc.ehdl = ind->end_hdl; } - return (KE_MSG_CONSUMED); + cscpc_env->env[conidx]->nb_svc++; + } + + return (KE_MSG_CONSUMED); } - - /** **************************************************************************************** * @brief Handles reception of the @ref CSCPC_ENABLE_REQ message. @@ -126,56 +117,52 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int cscpc_enable_req_handler(ke_msg_id_t const msgid, - struct cscpc_enable_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + struct cscpc_enable_req *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); - // Cycling Speed and Cadence Profile Collector Role Task Environment - struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); + uint8_t state = ke_state_get(dest_id); + // Cycling Speed and Cadence Profile Collector Role Task Environment + struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); - ASSERT_INFO(cscpc_env != NULL, dest_id, src_id); - if ((state == CSCPC_IDLE) && (cscpc_env->env[conidx] == NULL)) - { - // allocate environment variable for task instance - cscpc_env->env[conidx] = (struct cscpc_cnx_env*) ke_malloc(sizeof(struct cscpc_cnx_env),KE_MEM_ATT_DB); - memset(cscpc_env->env[conidx], 0, sizeof(struct cscpc_cnx_env)); + ASSERT_INFO(cscpc_env != NULL, dest_id, src_id); + if ((state == CSCPC_IDLE) && (cscpc_env->env[conidx] == NULL)) { + // allocate environment variable for task instance + cscpc_env->env[conidx] = (struct cscpc_cnx_env *)ke_malloc( + sizeof(struct cscpc_cnx_env), KE_MEM_ATT_DB); + memset(cscpc_env->env[conidx], 0, sizeof(struct cscpc_cnx_env)); - // Start discovering - if (param->con_type == PRF_CON_DISCOVERY) - { - prf_disc_svc_send(&(cscpc_env->prf_env), conidx, ATT_SVC_CYCLING_SPEED_CADENCE); + // Start discovering + if (param->con_type == PRF_CON_DISCOVERY) { + prf_disc_svc_send(&(cscpc_env->prf_env), conidx, + ATT_SVC_CYCLING_SPEED_CADENCE); - // Go to DISCOVERING state - ke_state_set(dest_id, CSCPC_DISCOVERING); - } - // Bond information are provided - else - { - cscpc_env->env[conidx]->cscs = param->cscs; - - //send APP confirmation that can start normal connection to TH - cscpc_enable_rsp_send(cscpc_env, conidx, GAP_ERR_NO_ERROR); - } - } - else if (state != CSCPC_FREE) - { - // The message will be forwarded towards the good task instance - status = PRF_ERR_REQ_DISALLOWED; + // Go to DISCOVERING state + ke_state_set(dest_id, CSCPC_DISCOVERING); } + // Bond information are provided + else { + cscpc_env->env[conidx]->cscs = param->cscs; - if(status != GAP_ERR_NO_ERROR) - { - // The request is disallowed (profile already enabled for this connection, or not enough memory, ...) - cscpc_enable_rsp_send(cscpc_env, conidx, status); + // send APP confirmation that can start normal connection to TH + cscpc_enable_rsp_send(cscpc_env, conidx, GAP_ERR_NO_ERROR); } + } else if (state != CSCPC_FREE) { + // The message will be forwarded towards the good task instance + status = PRF_ERR_REQ_DISALLOWED; + } - return (KE_MSG_CONSUMED); + if (status != GAP_ERR_NO_ERROR) { + // The request is disallowed (profile already enabled for this connection, + // or not enough memory, ...) + cscpc_enable_rsp_send(cscpc_env, conidx, status); + } + + return (KE_MSG_CONSUMED); } /** @@ -189,110 +176,98 @@ __STATIC int cscpc_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int cscpc_read_cmd_handler(ke_msg_id_t const msgid, - struct cscpc_read_cmd *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - uint8_t status = PRF_ERR_REQ_DISALLOWED; - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; - // Get the address of the environment - struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + struct cscpc_read_cmd *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + uint8_t status = PRF_ERR_REQ_DISALLOWED; + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; + // Get the address of the environment + struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - if (state == CSCPC_IDLE) - { - ASSERT_INFO(cscpc_env != NULL, dest_id, src_id); - // environment variable not ready - if(cscpc_env->env[conidx] == NULL) - { - status = PRF_APP_ERROR; - } - else - { - // Attribute Handle - uint16_t handle = ATT_INVALID_SEARCH_HANDLE; + if (state == CSCPC_IDLE) { + ASSERT_INFO(cscpc_env != NULL, dest_id, src_id); + // environment variable not ready + if (cscpc_env->env[conidx] == NULL) { + status = PRF_APP_ERROR; + } else { + // Attribute Handle + uint16_t handle = ATT_INVALID_SEARCH_HANDLE; - switch (param->read_code) - { - // Read CSC Feature - case (CSCPC_RD_CSC_FEAT): - { - handle = cscpc_env->env[conidx]->cscs.chars[CSCP_CSCS_CSC_FEAT_CHAR].val_hdl; - } break; + switch (param->read_code) { + // Read CSC Feature + case (CSCPC_RD_CSC_FEAT): { + handle = + cscpc_env->env[conidx]->cscs.chars[CSCP_CSCS_CSC_FEAT_CHAR].val_hdl; + } break; - // Read Sensor Location - case (CSCPC_RD_SENSOR_LOC): - { - handle = cscpc_env->env[conidx]->cscs.chars[CSCP_CSCS_SENSOR_LOC_CHAR].val_hdl; - } break; + // Read Sensor Location + case (CSCPC_RD_SENSOR_LOC): { + handle = cscpc_env->env[conidx] + ->cscs.chars[CSCP_CSCS_SENSOR_LOC_CHAR] + .val_hdl; + } break; - // Read CSC Measurement Characteristic Client Char. Cfg. Descriptor Value - case (CSCPC_RD_WR_CSC_MEAS_CFG): - { - handle = cscpc_env->env[conidx]->cscs.descs[CSCPC_DESC_CSC_MEAS_CL_CFG].desc_hdl; - } break; + // Read CSC Measurement Characteristic Client Char. Cfg. Descriptor Value + case (CSCPC_RD_WR_CSC_MEAS_CFG): { + handle = cscpc_env->env[conidx] + ->cscs.descs[CSCPC_DESC_CSC_MEAS_CL_CFG] + .desc_hdl; + } break; - // Read Unread Alert Characteristic Client Char. Cfg. Descriptor Value - case (CSCPC_RD_WR_SC_CTNL_PT_CFG): - { - handle = cscpc_env->env[conidx]->cscs.descs[CSCPC_DESC_SC_CTNL_PT_CL_CFG].desc_hdl; - } break; + // Read Unread Alert Characteristic Client Char. Cfg. Descriptor Value + case (CSCPC_RD_WR_SC_CTNL_PT_CFG): { + handle = cscpc_env->env[conidx] + ->cscs.descs[CSCPC_DESC_SC_CTNL_PT_CL_CFG] + .desc_hdl; + } break; - default: - { - status = PRF_ERR_INVALID_PARAM; - } break; - } + default: { + status = PRF_ERR_INVALID_PARAM; + } break; + } - // Check if handle is viable - if (handle != ATT_INVALID_SEARCH_HANDLE) - { - // Force the operation value - param->operation = CSCPC_READ_OP_CODE; + // Check if handle is viable + if (handle != ATT_INVALID_SEARCH_HANDLE) { + // Force the operation value + param->operation = CSCPC_READ_OP_CODE; - // Store the command structure - cscpc_env->env[conidx]->operation = param; - msg_status = KE_MSG_NO_FREE; + // Store the command structure + cscpc_env->env[conidx]->operation = param; + msg_status = KE_MSG_NO_FREE; - // Send the read request - prf_read_char_send(&(cscpc_env->prf_env), conidx, - cscpc_env->env[conidx]->cscs.svc.shdl, - cscpc_env->env[conidx]->cscs.svc.ehdl, - handle); + // Send the read request + prf_read_char_send(&(cscpc_env->prf_env), conidx, + cscpc_env->env[conidx]->cscs.svc.shdl, + cscpc_env->env[conidx]->cscs.svc.ehdl, handle); - // Go to the Busy state - ke_state_set(dest_id, CSCPC_BUSY); + // Go to the Busy state + ke_state_set(dest_id, CSCPC_BUSY); - status = ATT_ERR_NO_ERROR; - } - else - { - status = PRF_ERR_INEXISTENT_HDL; - } - } + status = ATT_ERR_NO_ERROR; + } else { + status = PRF_ERR_INEXISTENT_HDL; + } } + } - else if (state == CSCPC_FREE) - { - status = GAP_ERR_DISCONNECTED; - } - else - { - // Another procedure is pending, keep the command for later - msg_status = KE_MSG_SAVED; - status = GAP_ERR_NO_ERROR; - } + else if (state == CSCPC_FREE) { + status = GAP_ERR_DISCONNECTED; + } else { + // Another procedure is pending, keep the command for later + msg_status = KE_MSG_SAVED; + status = GAP_ERR_NO_ERROR; + } - if (status != GAP_ERR_NO_ERROR) - { - // Send the complete event message to the task id stored in the environment - cscpc_send_cmp_evt(cscpc_env, conidx, CSCPC_READ_OP_CODE, status); - } + if (status != GAP_ERR_NO_ERROR) { + // Send the complete event message to the task id stored in the environment + cscpc_send_cmp_evt(cscpc_env, conidx, CSCPC_READ_OP_CODE, status); + } - return (int)msg_status; + return (int)msg_status; } /** @@ -306,107 +281,96 @@ __STATIC int cscpc_read_cmd_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int cscpc_cfg_ntfind_cmd_handler(ke_msg_id_t const msgid, - struct cscpc_cfg_ntfind_cmd *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); + struct cscpc_cfg_ntfind_cmd *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); - uint8_t state = ke_state_get(dest_id); - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; + uint8_t state = ke_state_get(dest_id); + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; - if (cscpc_env != NULL) - { - // Status - uint8_t status = PRF_ERR_REQ_DISALLOWED; - // Handle - uint16_t handle = ATT_INVALID_SEARCH_HANDLE; - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + if (cscpc_env != NULL) { + // Status + uint8_t status = PRF_ERR_REQ_DISALLOWED; + // Handle + uint16_t handle = ATT_INVALID_SEARCH_HANDLE; + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - do - { - if (state != CSCPC_IDLE) - { - // Another procedure is pending, keep the command for later - msg_status = KE_MSG_SAVED; - // Status is GAP_ERR_NO_ERROR, no message will be sent to the application - break; - } + do { + if (state != CSCPC_IDLE) { + // Another procedure is pending, keep the command for later + msg_status = KE_MSG_SAVED; + // Status is GAP_ERR_NO_ERROR, no message will be sent to the + // application + break; + } - // state = CSCPC_CONNECTED - ASSERT_ERR(cscpc_env->env[conidx] != NULL); + // state = CSCPC_CONNECTED + ASSERT_ERR(cscpc_env->env[conidx] != NULL); - switch(param->desc_code) - { - // Write CSC Measurement Characteristic Client Char. Cfg. Descriptor Value - case (CSCPC_RD_WR_CSC_MEAS_CFG): - { - if (param->ntfind_cfg <= PRF_CLI_START_NTF) - { - handle = cscpc_env->env[conidx]->cscs.descs[CSCPC_DESC_CSC_MEAS_CL_CFG].desc_hdl; - // The descriptor is mandatory - ASSERT_ERR(handle != ATT_INVALID_SEARCH_HANDLE); - status = GAP_ERR_NO_ERROR; - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } break; - - // Write SC Control Point Characteristic Client Char. Cfg. Descriptor Value - case (CSCPC_RD_WR_SC_CTNL_PT_CFG): - { - if ((param->ntfind_cfg == PRF_CLI_STOP_NTFIND) || - (param->ntfind_cfg == PRF_CLI_START_IND)) - { - handle = cscpc_env->env[conidx]->cscs.descs[CSCPC_DESC_SC_CTNL_PT_CL_CFG].desc_hdl; - - status = GAP_ERR_NO_ERROR; - if (handle == ATT_INVALID_SEARCH_HANDLE) - { - // The descriptor has not been found. - status = PRF_ERR_INEXISTENT_HDL; - } - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } break; - - default: - { - status = PRF_ERR_INVALID_PARAM; - } break; - } - } while (0); - - if ((status == GAP_ERR_NO_ERROR) && (handle != ATT_INVALID_SEARCH_HANDLE)) - { - // Set the operation code - param->operation = CSCPC_CFG_NTF_IND_OP_CODE; - - // Store the command structure - cscpc_env->env[conidx]->operation = param; - msg_status = KE_MSG_NO_FREE; - - // Go to the Busy state - ke_state_set(dest_id, CSCPC_BUSY); - - // Send GATT Write Request - prf_gatt_write_ntf_ind(&cscpc_env->prf_env, conidx, handle, param->ntfind_cfg); + switch (param->desc_code) { + // Write CSC Measurement Characteristic Client Char. Cfg. Descriptor Value + case (CSCPC_RD_WR_CSC_MEAS_CFG): { + if (param->ntfind_cfg <= PRF_CLI_START_NTF) { + handle = cscpc_env->env[conidx] + ->cscs.descs[CSCPC_DESC_CSC_MEAS_CL_CFG] + .desc_hdl; + // The descriptor is mandatory + ASSERT_ERR(handle != ATT_INVALID_SEARCH_HANDLE); + status = GAP_ERR_NO_ERROR; + } else { + status = PRF_ERR_INVALID_PARAM; } - } - else - { - cscpc_send_no_conn_cmp_evt(dest_id, src_id, CSCPC_CFG_NTF_IND_OP_CODE); - } + } break; - return (int)msg_status; + // Write SC Control Point Characteristic Client Char. Cfg. Descriptor + // Value + case (CSCPC_RD_WR_SC_CTNL_PT_CFG): { + if ((param->ntfind_cfg == PRF_CLI_STOP_NTFIND) || + (param->ntfind_cfg == PRF_CLI_START_IND)) { + handle = cscpc_env->env[conidx] + ->cscs.descs[CSCPC_DESC_SC_CTNL_PT_CL_CFG] + .desc_hdl; + + status = GAP_ERR_NO_ERROR; + if (handle == ATT_INVALID_SEARCH_HANDLE) { + // The descriptor has not been found. + status = PRF_ERR_INEXISTENT_HDL; + } + } else { + status = PRF_ERR_INVALID_PARAM; + } + } break; + + default: { + status = PRF_ERR_INVALID_PARAM; + } break; + } + } while (0); + + if ((status == GAP_ERR_NO_ERROR) && (handle != ATT_INVALID_SEARCH_HANDLE)) { + // Set the operation code + param->operation = CSCPC_CFG_NTF_IND_OP_CODE; + + // Store the command structure + cscpc_env->env[conidx]->operation = param; + msg_status = KE_MSG_NO_FREE; + + // Go to the Busy state + ke_state_set(dest_id, CSCPC_BUSY); + + // Send GATT Write Request + prf_gatt_write_ntf_ind(&cscpc_env->prf_env, conidx, handle, + param->ntfind_cfg); + } + } else { + cscpc_send_no_conn_cmp_evt(dest_id, src_id, CSCPC_CFG_NTF_IND_OP_CODE); + } + + return (int)msg_status; } /** @@ -420,129 +384,119 @@ __STATIC int cscpc_cfg_ntfind_cmd_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int cscpc_ctnl_pt_cfg_req_handler(ke_msg_id_t const msgid, - struct cscpc_ctnl_pt_cfg_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; - // Get the address of the environment - struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + struct cscpc_ctnl_pt_cfg_req *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; + // Get the address of the environment + struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - if (cscpc_env != NULL) - { - // Status - uint8_t status = GAP_ERR_NO_ERROR; + if (cscpc_env != NULL) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; - do - { - // State is Connected or Busy - ASSERT_ERR(ke_state_get(dest_id) > CSCPC_FREE); + do { + // State is Connected or Busy + ASSERT_ERR(ke_state_get(dest_id) > CSCPC_FREE); - // Check the provided connection handle - if (cscpc_env->env[conidx] == NULL) - { - status = PRF_ERR_INVALID_PARAM; - break; - } + // Check the provided connection handle + if (cscpc_env->env[conidx] == NULL) { + status = PRF_ERR_INVALID_PARAM; + break; + } - if (ke_state_get(dest_id) != CSCPC_IDLE) - { - // Another procedure is pending, keep the command for later - msg_status = KE_MSG_NO_FREE; - // Status is GAP_ERR_NO_ERROR, no message will be sent to the application - break; - } + if (ke_state_get(dest_id) != CSCPC_IDLE) { + // Another procedure is pending, keep the command for later + msg_status = KE_MSG_NO_FREE; + // Status is GAP_ERR_NO_ERROR, no message will be sent to the + // application + break; + } - // Check if the characteristic has been found - if (cscpc_env->env[conidx]->cscs.descs[CSCPC_DESC_SC_CTNL_PT_CL_CFG].desc_hdl != ATT_INVALID_SEARCH_HANDLE) - { - // Packed request - uint8_t req[CSCP_SC_CNTL_PT_REQ_MAX_LEN]; - // Request Length - uint8_t req_len = CSCP_SC_CNTL_PT_REQ_MIN_LEN; + // Check if the characteristic has been found + if (cscpc_env->env[conidx] + ->cscs.descs[CSCPC_DESC_SC_CTNL_PT_CL_CFG] + .desc_hdl != ATT_INVALID_SEARCH_HANDLE) { + // Packed request + uint8_t req[CSCP_SC_CNTL_PT_REQ_MAX_LEN]; + // Request Length + uint8_t req_len = CSCP_SC_CNTL_PT_REQ_MIN_LEN; - // Set the operation code - req[0] = param->sc_ctnl_pt.op_code; + // Set the operation code + req[0] = param->sc_ctnl_pt.op_code; - // Fulfill the message according to the operation code - switch (param->sc_ctnl_pt.op_code) - { - case (CSCP_CTNL_PT_OP_SET_CUMUL_VAL): - { - // Set the cumulative value - co_write32p(&req[req_len], param->sc_ctnl_pt.value.cumul_val); - // Update length - req_len += 4; - } break; + // Fulfill the message according to the operation code + switch (param->sc_ctnl_pt.op_code) { + case (CSCP_CTNL_PT_OP_SET_CUMUL_VAL): { + // Set the cumulative value + co_write32p(&req[req_len], param->sc_ctnl_pt.value.cumul_val); + // Update length + req_len += 4; + } break; - case (CSCP_CTNL_PT_OP_UPD_LOC): - { - // Set the sensor location - req[req_len] = param->sc_ctnl_pt.value.sensor_loc; - // Update length - req_len++; - } break; + case (CSCP_CTNL_PT_OP_UPD_LOC): { + // Set the sensor location + req[req_len] = param->sc_ctnl_pt.value.sensor_loc; + // Update length + req_len++; + } break; - case (CSCP_CTNL_PT_OP_RESERVED): - case (CSCP_CTNL_PT_OP_START_CALIB): - case (CSCP_CTNL_PT_OP_REQ_SUPP_LOC): - { - // Nothing more to do - } break; + case (CSCP_CTNL_PT_OP_RESERVED): + case (CSCP_CTNL_PT_OP_START_CALIB): + case (CSCP_CTNL_PT_OP_REQ_SUPP_LOC): { + // Nothing more to do + } break; - default: - { - status = PRF_ERR_INVALID_PARAM; - } break; - } - - if (status == GAP_ERR_NO_ERROR) - { - // Set the operation code - param->operation = CSCPC_CTNL_PT_CFG_WR_OP_CODE; - - // Store the command structure - cscpc_env->env[conidx]->operation = param; - // Store the command information - msg_status = KE_MSG_NO_FREE; - - // Go to the Busy state - ke_state_set(dest_id, CSCPC_BUSY); - - // Send the write request - prf_gatt_write(&(cscpc_env->prf_env), conidx, cscpc_env->env[conidx]->cscs.chars[CSCP_CSCS_SC_CTNL_PT_CHAR].val_hdl, - (uint8_t *)&req[0], req_len, GATTC_WRITE); - } - } - else - { - status = PRF_ERR_INEXISTENT_HDL; - } - } while (0); - - if (status != GAP_ERR_NO_ERROR) - { - // Send a complete event status to the application - cscpc_send_cmp_evt(cscpc_env, conidx, CSCPC_CTNL_PT_CFG_WR_OP_CODE, status); + default: { + status = PRF_ERR_INVALID_PARAM; + } break; } - } - else - { - // No connection - cscpc_send_no_conn_cmp_evt(dest_id, src_id, CSCPC_CTNL_PT_CFG_WR_OP_CODE); - } - return (int)msg_status; + if (status == GAP_ERR_NO_ERROR) { + // Set the operation code + param->operation = CSCPC_CTNL_PT_CFG_WR_OP_CODE; + + // Store the command structure + cscpc_env->env[conidx]->operation = param; + // Store the command information + msg_status = KE_MSG_NO_FREE; + + // Go to the Busy state + ke_state_set(dest_id, CSCPC_BUSY); + + // Send the write request + prf_gatt_write(&(cscpc_env->prf_env), conidx, + cscpc_env->env[conidx] + ->cscs.chars[CSCP_CSCS_SC_CTNL_PT_CHAR] + .val_hdl, + (uint8_t *)&req[0], req_len, GATTC_WRITE); + } + } else { + status = PRF_ERR_INEXISTENT_HDL; + } + } while (0); + + if (status != GAP_ERR_NO_ERROR) { + // Send a complete event status to the application + cscpc_send_cmp_evt(cscpc_env, conidx, CSCPC_CTNL_PT_CFG_WR_OP_CODE, + status); + } + } else { + // No connection + cscpc_send_no_conn_cmp_evt(dest_id, src_id, CSCPC_CTNL_PT_CFG_WR_OP_CODE); + } + + return (int)msg_status; } /** **************************************************************************************** - * @brief Handles reception of the @ref CSCPC_TIMEOUT_TIMER_IND message. This message is - * received when the peer device doesn't send a SC Control Point indication within 30s - * after reception of the write response. + * @brief Handles reception of the @ref CSCPC_TIMEOUT_TIMER_IND message. This + *message is received when the peer device doesn't send a SC Control Point + *indication within 30s after reception of the write response. * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance. @@ -551,26 +505,27 @@ __STATIC int cscpc_ctnl_pt_cfg_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int cscpc_timeout_timer_ind_handler(ke_msg_id_t const msgid, - void const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + void const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - if (cscpc_env != NULL) - { - ASSERT_ERR(cscpc_env->env[conidx]->operation != NULL); - ASSERT_ERR(((struct cscpc_cmd *)cscpc_env->env[conidx]->operation)->operation == CSCPC_CTNL_PT_CFG_IND_OP_CODE); + if (cscpc_env != NULL) { + ASSERT_ERR(cscpc_env->env[conidx]->operation != NULL); + ASSERT_ERR( + ((struct cscpc_cmd *)cscpc_env->env[conidx]->operation)->operation == + CSCPC_CTNL_PT_CFG_IND_OP_CODE); - // Send the complete event message - cscpc_send_cmp_evt(cscpc_env, conidx, CSCPC_CTNL_PT_CFG_WR_OP_CODE, PRF_ERR_PROC_TIMEOUT); - } - // else drop the message + // Send the complete event message + cscpc_send_cmp_evt(cscpc_env, conidx, CSCPC_CTNL_PT_CFG_WR_OP_CODE, + PRF_ERR_PROC_TIMEOUT); + } + // else drop the message - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -584,114 +539,97 @@ __STATIC int cscpc_timeout_timer_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, - struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); - // Status - uint8_t status; + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); + // Status + uint8_t status; - if (cscpc_env != NULL) - { - uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); + if (cscpc_env != NULL) { + uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t state = ke_state_get(dest_id); - if (state == CSCPC_DISCOVERING) - { - status = param->status; + if (state == CSCPC_DISCOVERING) { + status = param->status; - if ((status == ATT_ERR_ATTRIBUTE_NOT_FOUND) || - (status == ATT_ERR_NO_ERROR)) - { - // Discovery - // check characteristic validity - if(cscpc_env->env[conidx]->nb_svc == 1) - { - status = prf_check_svc_char_validity(CSCP_CSCS_CHAR_MAX, - cscpc_env->env[conidx]->cscs.chars, - cscpc_cscs_char); - } - // too much services - else if (cscpc_env->env[conidx]->nb_svc > 1) - { - status = PRF_ERR_MULTIPLE_SVC; - } - // no services found - else - { - status = PRF_ERR_STOP_DISC_CHAR_MISSING; - } - - // check descriptor validity - if (status == GAP_ERR_NO_ERROR) - { - status = prf_check_svc_char_desc_validity(CSCPC_DESC_MAX, - cscpc_env->env[conidx]->cscs.descs, - cscpc_cscs_char_desc, - cscpc_env->env[conidx]->cscs.chars); - } - } - - cscpc_enable_rsp_send(cscpc_env, conidx, status); + if ((status == ATT_ERR_ATTRIBUTE_NOT_FOUND) || + (status == ATT_ERR_NO_ERROR)) { + // Discovery + // check characteristic validity + if (cscpc_env->env[conidx]->nb_svc == 1) { + status = prf_check_svc_char_validity( + CSCP_CSCS_CHAR_MAX, cscpc_env->env[conidx]->cscs.chars, + cscpc_cscs_char); + } + // too much services + else if (cscpc_env->env[conidx]->nb_svc > 1) { + status = PRF_ERR_MULTIPLE_SVC; + } + // no services found + else { + status = PRF_ERR_STOP_DISC_CHAR_MISSING; } - else if (state == CSCPC_BUSY) - { - switch (param->operation) - { - case GATTC_READ: - { - // Send the complete event status - cscpc_send_cmp_evt(cscpc_env, conidx, CSCPC_READ_OP_CODE, param->status); - } break; - - case GATTC_WRITE: - case GATTC_WRITE_NO_RESPONSE: - { - uint8_t operation = ((struct cscpc_cmd *)cscpc_env->env[conidx]->operation)->operation; - - if (operation == CSCPC_CFG_NTF_IND_OP_CODE) - { - // Send the complete event status - cscpc_send_cmp_evt(cscpc_env, conidx, operation, param->status); - } - - else if (operation == CSCPC_CTNL_PT_CFG_WR_OP_CODE) - { - if (param->status == GAP_ERR_NO_ERROR) - { - // Start Timeout Procedure - ke_timer_set(CSCPC_TIMEOUT_TIMER_IND, dest_id, ATT_TRANS_RTX); - - // Wait for the response indication - ((struct cscpc_cmd *)cscpc_env->env[conidx]->operation)->operation = CSCPC_CTNL_PT_CFG_IND_OP_CODE; - } - else - { - // Send the complete event status - cscpc_send_cmp_evt(cscpc_env, conidx, operation, param->status); - } - } - } break; - - case GATTC_REGISTER: - case GATTC_UNREGISTER: - { - // Do nothing - } break; - - default: - { - ASSERT_ERR(0); - } break; - } + // check descriptor validity + if (status == GAP_ERR_NO_ERROR) { + status = prf_check_svc_char_desc_validity( + CSCPC_DESC_MAX, cscpc_env->env[conidx]->cscs.descs, + cscpc_cscs_char_desc, cscpc_env->env[conidx]->cscs.chars); } + } + + cscpc_enable_rsp_send(cscpc_env, conidx, status); } - // else ignore the message - return (KE_MSG_CONSUMED); + else if (state == CSCPC_BUSY) { + switch (param->operation) { + case GATTC_READ: { + // Send the complete event status + cscpc_send_cmp_evt(cscpc_env, conidx, CSCPC_READ_OP_CODE, + param->status); + } break; + + case GATTC_WRITE: + case GATTC_WRITE_NO_RESPONSE: { + uint8_t operation = + ((struct cscpc_cmd *)cscpc_env->env[conidx]->operation)->operation; + + if (operation == CSCPC_CFG_NTF_IND_OP_CODE) { + // Send the complete event status + cscpc_send_cmp_evt(cscpc_env, conidx, operation, param->status); + } + + else if (operation == CSCPC_CTNL_PT_CFG_WR_OP_CODE) { + if (param->status == GAP_ERR_NO_ERROR) { + // Start Timeout Procedure + ke_timer_set(CSCPC_TIMEOUT_TIMER_IND, dest_id, ATT_TRANS_RTX); + + // Wait for the response indication + ((struct cscpc_cmd *)cscpc_env->env[conidx]->operation)->operation = + CSCPC_CTNL_PT_CFG_IND_OP_CODE; + } else { + // Send the complete event status + cscpc_send_cmp_evt(cscpc_env, conidx, operation, param->status); + } + } + } break; + + case GATTC_REGISTER: + case GATTC_UNREGISTER: { + // Do nothing + } break; + + default: { + ASSERT_ERR(0); + } break; + } + } + } + // else ignore the message + + return (KE_MSG_CONSUMED); } /** @@ -708,63 +646,56 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, struct gattc_read_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); + ke_task_id_t const src_id) { + // Get the address of the environment + struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); - if (ke_state_get(dest_id) == CSCPC_BUSY) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (ke_state_get(dest_id) == CSCPC_BUSY) { + uint8_t conidx = KE_IDX_GET(dest_id); - ASSERT_INFO(cscpc_env != NULL, dest_id, src_id); - ASSERT_INFO(cscpc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(cscpc_env != NULL, dest_id, src_id); + ASSERT_INFO(cscpc_env->env[conidx] != NULL, dest_id, src_id); - // Send the read value to the HL - struct cscpc_value_ind *ind = KE_MSG_ALLOC(CSCPC_VALUE_IND, - prf_dst_task_get(&(cscpc_env->prf_env), conidx), - dest_id, - cscpc_value_ind); + // Send the read value to the HL + struct cscpc_value_ind *ind = KE_MSG_ALLOC( + CSCPC_VALUE_IND, prf_dst_task_get(&(cscpc_env->prf_env), conidx), + dest_id, cscpc_value_ind); + switch (((struct cscpc_read_cmd *)cscpc_env->env[conidx]->operation) + ->read_code) { + // Read CSC Feature Characteristic value + case (CSCPC_RD_CSC_FEAT): { + ind->value.sensor_feat = co_read16p(param->value); - switch (((struct cscpc_read_cmd *)cscpc_env->env[conidx]->operation)->read_code) - { - // Read CSC Feature Characteristic value - case (CSCPC_RD_CSC_FEAT): - { - ind->value.sensor_feat = co_read16p(param->value); + // Mask the reserved bits + // ind->value.sensor_feat &= CSCP_FEAT_ALL_SUPP; + } break; - // Mask the reserved bits -// ind->value.sensor_feat &= CSCP_FEAT_ALL_SUPP; - } break; + // Read Sensor Location Characteristic value + case (CSCPC_RD_SENSOR_LOC): { + ind->value.sensor_loc = param->value[0]; + } break; - // Read Sensor Location Characteristic value - case (CSCPC_RD_SENSOR_LOC): - { - ind->value.sensor_loc = param->value[0]; - } break; + // Read Client Characteristic Configuration Descriptor value + case (CSCPC_RD_WR_CSC_MEAS_CFG): + case (CSCPC_RD_WR_SC_CTNL_PT_CFG): { + co_write16p(&ind->value.ntf_cfg, param->value[0]); + } break; - // Read Client Characteristic Configuration Descriptor value - case (CSCPC_RD_WR_CSC_MEAS_CFG): - case (CSCPC_RD_WR_SC_CTNL_PT_CFG): - { - co_write16p(&ind->value.ntf_cfg, param->value[0]); - } break; - - default: - { - ASSERT_ERR(0); - } break; - } - - ind->att_code = ((struct cscpc_read_cmd *)cscpc_env->env[conidx]->operation)->read_code; - - // Send the message to the application - ke_msg_send(ind); + default: { + ASSERT_ERR(0); + } break; } - // else drop the message - return (KE_MSG_CONSUMED); + ind->att_code = + ((struct cscpc_read_cmd *)cscpc_env->env[conidx]->operation)->read_code; + + // Send the message to the application + ke_msg_send(ind); + } + // else drop the message + + return (KE_MSG_CONSUMED); } /** @@ -778,135 +709,127 @@ __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, - struct gattc_event_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); + struct gattc_event_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); - if (cscpc_env != NULL) - { - switch (param->type) - { - case (GATTC_NOTIFY): - { - // Offset - uint8_t offset = CSCP_CSC_MEAS_MIN_LEN; + if (cscpc_env != NULL) { + switch (param->type) { + case (GATTC_NOTIFY): { + // Offset + uint8_t offset = CSCP_CSC_MEAS_MIN_LEN; - // CSC Measurement value has been received - struct cscpc_value_ind *ind = KE_MSG_ALLOC(CSCPC_VALUE_IND, - prf_dst_task_get(&(cscpc_env->prf_env), conidx), - prf_src_task_get(&(cscpc_env->prf_env), conidx), - cscpc_value_ind); - // Attribute code - ind->att_code = CSCPC_NTF_CSC_MEAS; + // CSC Measurement value has been received + struct cscpc_value_ind *ind = KE_MSG_ALLOC( + CSCPC_VALUE_IND, prf_dst_task_get(&(cscpc_env->prf_env), conidx), + prf_src_task_get(&(cscpc_env->prf_env), conidx), cscpc_value_ind); + // Attribute code + ind->att_code = CSCPC_NTF_CSC_MEAS; - /*---------------------------------------------------- - * Unpack Measurement -------------------------------- - *----------------------------------------------------*/ + /*---------------------------------------------------- + * Unpack Measurement -------------------------------- + *----------------------------------------------------*/ - // Flags - ind->value.csc_meas.flags = param->value[0]; + // Flags + ind->value.csc_meas.flags = param->value[0]; - // Cumulative Wheel Revolutions - // Last Wheel Event Time - if (param->value[0] & CSCP_MEAS_WHEEL_REV_DATA_PRESENT) - { - // Cumulative Wheel Revolutions - ind->value.csc_meas.cumul_wheel_rev = co_read32p(¶m->value[offset]); - offset += 4; + // Cumulative Wheel Revolutions + // Last Wheel Event Time + if (param->value[0] & CSCP_MEAS_WHEEL_REV_DATA_PRESENT) { + // Cumulative Wheel Revolutions + ind->value.csc_meas.cumul_wheel_rev = co_read32p(¶m->value[offset]); + offset += 4; - // Last Wheel Event Time - ind->value.csc_meas.last_wheel_evt_time = co_read16p(¶m->value[offset]); - offset += 2; - } + // Last Wheel Event Time + ind->value.csc_meas.last_wheel_evt_time = + co_read16p(¶m->value[offset]); + offset += 2; + } - // Cumulative Crank Revolutions - // Last Crank Event Time - if (param->value[0] & CSCP_MEAS_CRANK_REV_DATA_PRESENT) - { - // Cumulative Crank Revolutions - ind->value.csc_meas.cumul_crank_rev = co_read16p(¶m->value[offset]); - offset += 2; + // Cumulative Crank Revolutions + // Last Crank Event Time + if (param->value[0] & CSCP_MEAS_CRANK_REV_DATA_PRESENT) { + // Cumulative Crank Revolutions + ind->value.csc_meas.cumul_crank_rev = co_read16p(¶m->value[offset]); + offset += 2; - // Last Crank Event Time - ind->value.csc_meas.last_crank_evt_time = co_read16p(¶m->value[offset]); - } + // Last Crank Event Time + ind->value.csc_meas.last_crank_evt_time = + co_read16p(¶m->value[offset]); + } - ke_msg_send(ind); - } break; + ke_msg_send(ind); + } break; - case (GATTC_INDICATE): - { - // confirm that indication has been correctly received - struct gattc_event_cfm * cfm = KE_MSG_ALLOC(GATTC_EVENT_CFM, src_id, dest_id, gattc_event_cfm); - cfm->handle = param->handle; - ke_msg_send(cfm); + case (GATTC_INDICATE): { + // confirm that indication has been correctly received + struct gattc_event_cfm *cfm = + KE_MSG_ALLOC(GATTC_EVENT_CFM, src_id, dest_id, gattc_event_cfm); + cfm->handle = param->handle; + ke_msg_send(cfm); - // Check if we were waiting for the indication - if (cscpc_env->env[conidx]->operation != NULL) - { - if (((struct cscpc_cmd *)cscpc_env->env[conidx]->operation)->operation == CSCPC_CTNL_PT_CFG_IND_OP_CODE) - { - // Stop the procedure timeout timer - ke_timer_clear(CSCPC_TIMEOUT_TIMER_IND, dest_id); + // Check if we were waiting for the indication + if (cscpc_env->env[conidx]->operation != NULL) { + if (((struct cscpc_cmd *)cscpc_env->env[conidx]->operation) + ->operation == CSCPC_CTNL_PT_CFG_IND_OP_CODE) { + // Stop the procedure timeout timer + ke_timer_clear(CSCPC_TIMEOUT_TIMER_IND, dest_id); - // CSC Measurement value has been received - struct cscpc_ctnl_pt_rsp *ind = KE_MSG_ALLOC(CSCPC_CTNL_PT_RSP, - prf_dst_task_get(&(cscpc_env->prf_env), conidx), - prf_src_task_get(&(cscpc_env->prf_env), conidx), - cscpc_ctnl_pt_rsp); + // CSC Measurement value has been received + struct cscpc_ctnl_pt_rsp *ind = + KE_MSG_ALLOC(CSCPC_CTNL_PT_RSP, + prf_dst_task_get(&(cscpc_env->prf_env), conidx), + prf_src_task_get(&(cscpc_env->prf_env), conidx), + cscpc_ctnl_pt_rsp); - // Requested operation code - ind->ctnl_pt_rsp.req_op_code = param->value[1]; - // Response value - ind->ctnl_pt_rsp.resp_value = param->value[2]; + // Requested operation code + ind->ctnl_pt_rsp.req_op_code = param->value[1]; + // Response value + ind->ctnl_pt_rsp.resp_value = param->value[2]; - // Get the list of supported sensor locations if needed - if ((ind->ctnl_pt_rsp.req_op_code == CSCP_CTNL_PT_OP_REQ_SUPP_LOC) && - (ind->ctnl_pt_rsp.resp_value == CSCP_CTNL_PT_RESP_SUCCESS) && - (param->length > 3)) - { - // Get the number of supported locations that have been received - uint8_t nb_supp_loc = (param->length - 3); - // Counter - uint8_t counter; - // Location - uint8_t loc; + // Get the list of supported sensor locations if needed + if ((ind->ctnl_pt_rsp.req_op_code == CSCP_CTNL_PT_OP_REQ_SUPP_LOC) && + (ind->ctnl_pt_rsp.resp_value == CSCP_CTNL_PT_RESP_SUCCESS) && + (param->length > 3)) { + // Get the number of supported locations that have been received + uint8_t nb_supp_loc = (param->length - 3); + // Counter + uint8_t counter; + // Location + uint8_t loc; - for (counter = 0; counter < nb_supp_loc; counter++) - { - loc = param->value[counter + 3]; + for (counter = 0; counter < nb_supp_loc; counter++) { + loc = param->value[counter + 3]; - // Check if valid - if (loc < CSCP_LOC_MAX) - { - ind->ctnl_pt_rsp.supp_loc |= (1 << loc); - } - } - } + // Check if valid + if (loc < CSCP_LOC_MAX) { + ind->ctnl_pt_rsp.supp_loc |= (1 << loc); + } + } + } - // Send the message - ke_msg_send(ind); + // Send the message + ke_msg_send(ind); - // Send the complete event message - cscpc_send_cmp_evt(cscpc_env, conidx, CSCPC_CTNL_PT_CFG_WR_OP_CODE, GAP_ERR_NO_ERROR); - } - // else drop the message - } - // else drop the message - } break; - - default: - { - ASSERT_ERR(0); - } break; + // Send the complete event message + cscpc_send_cmp_evt(cscpc_env, conidx, CSCPC_CTNL_PT_CFG_WR_OP_CODE, + GAP_ERR_NO_ERROR); } - } + // else drop the message + } + // else drop the message + } break; - return (KE_MSG_CONSUMED); + default: { + ASSERT_ERR(0); + } break; + } + } + + return (KE_MSG_CONSUMED); } /* @@ -915,29 +838,27 @@ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, */ /// Specifies the default message handlers -KE_MSG_HANDLER_TAB(cscpc) -{ - {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, - {CSCPC_ENABLE_REQ, (ke_msg_func_t)cscpc_enable_req_handler}, - {CSCPC_READ_CMD, (ke_msg_func_t)cscpc_read_cmd_handler}, - {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, - {CSCPC_CFG_NTFIND_CMD, (ke_msg_func_t)cscpc_cfg_ntfind_cmd_handler}, - {CSCPC_CTNL_PT_CFG_REQ, (ke_msg_func_t)cscpc_ctnl_pt_cfg_req_handler}, - {CSCPC_TIMEOUT_TIMER_IND, (ke_msg_func_t)cscpc_timeout_timer_ind_handler}, - {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, - {GATTC_EVENT_REQ_IND, (ke_msg_func_t)gattc_event_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, +KE_MSG_HANDLER_TAB(cscpc){ + {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, + {CSCPC_ENABLE_REQ, (ke_msg_func_t)cscpc_enable_req_handler}, + {CSCPC_READ_CMD, (ke_msg_func_t)cscpc_read_cmd_handler}, + {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, + {CSCPC_CFG_NTFIND_CMD, (ke_msg_func_t)cscpc_cfg_ntfind_cmd_handler}, + {CSCPC_CTNL_PT_CFG_REQ, (ke_msg_func_t)cscpc_ctnl_pt_cfg_req_handler}, + {CSCPC_TIMEOUT_TIMER_IND, (ke_msg_func_t)cscpc_timeout_timer_ind_handler}, + {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {GATTC_EVENT_REQ_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void cscpc_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); +void cscpc_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct cscpc_env_tag *cscpc_env = PRF_ENV_GET(CSCPC, cscpc); - task_desc->msg_handler_tab = cscpc_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(cscpc_msg_handler_tab); - task_desc->state = cscpc_env->state; - task_desc->idx_max = CSCPC_IDX_MAX; + task_desc->msg_handler_tab = cscpc_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(cscpc_msg_handler_tab); + task_desc->state = cscpc_env->state; + task_desc->idx_max = CSCPC_IDX_MAX; } #endif //(BLE_CSC_COLLECTOR) diff --git a/services/ble_profiles/cscp/cscps/src/cscps.c b/services/ble_profiles/cscp/cscps/src/cscps.c index 20e2721..e6dabf2 100644 --- a/services/ble_profiles/cscp/cscps/src/cscps.c +++ b/services/ble_profiles/cscp/cscps/src/cscps.c @@ -15,10 +15,10 @@ #if (BLE_CSC_SENSOR) #include "cscp_common.h" -#include "gap.h" -#include "gattc_task.h" #include "cscps.h" #include "cscps_task.h" +#include "gap.h" +#include "gattc_task.h" #include "prf_utils.h" #include "ke_mem.h" @@ -29,35 +29,49 @@ */ /// Full CSCPS Database Description - Used to add attributes into the database -static const struct attm_desc cscps_att_db[CSCS_IDX_NB] = -{ +static const struct attm_desc cscps_att_db[CSCS_IDX_NB] = { // Cycling Speed and Cadence Service Declaration - [CSCS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [CSCS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // CSC Measurement Characteristic Declaration - [CSCS_IDX_CSC_MEAS_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [CSCS_IDX_CSC_MEAS_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // CSC Measurement Characteristic Value - [CSCS_IDX_CSC_MEAS_VAL] = {ATT_CHAR_CSC_MEAS, PERM(NTF, ENABLE), PERM(RI, ENABLE), CSCP_CSC_MEAS_MAX_LEN}, - // CSC Measurement Characteristic - Client Characteristic Configuration Descriptor - [CSCS_IDX_CSC_MEAS_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [CSCS_IDX_CSC_MEAS_VAL] = {ATT_CHAR_CSC_MEAS, PERM(NTF, ENABLE), + PERM(RI, ENABLE), CSCP_CSC_MEAS_MAX_LEN}, + // CSC Measurement Characteristic - Client Characteristic Configuration + // Descriptor + [CSCS_IDX_CSC_MEAS_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + 0, 0}, // CSC Feature Characteristic Declaration - [CSCS_IDX_CSC_FEAT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [CSCS_IDX_CSC_FEAT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // CSC Feature Characteristic Value - [CSCS_IDX_CSC_FEAT_VAL] = {ATT_CHAR_CSC_FEAT, PERM(RD, ENABLE), PERM(RI, ENABLE), sizeof(uint16_t)}, + [CSCS_IDX_CSC_FEAT_VAL] = {ATT_CHAR_CSC_FEAT, PERM(RD, ENABLE), + PERM(RI, ENABLE), sizeof(uint16_t)}, // Sensor Location Characteristic Declaration - [CSCS_IDX_SENSOR_LOC_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [CSCS_IDX_SENSOR_LOC_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Sensor Location Characteristic Value - [CSCS_IDX_SENSOR_LOC_VAL] = {ATT_CHAR_SENSOR_LOC, PERM(RD, ENABLE), PERM(RI, ENABLE), sizeof(uint8_t)}, + [CSCS_IDX_SENSOR_LOC_VAL] = {ATT_CHAR_SENSOR_LOC, PERM(RD, ENABLE), + PERM(RI, ENABLE), sizeof(uint8_t)}, // SC Control Point Characteristic Declaration - [CSCS_IDX_SC_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), CSCS_IDX_SC_CTNL_PT_VAL, 0}, - // SC Control Point Characteristic Value - The response has the maximal length - [CSCS_IDX_SC_CTNL_PT_VAL] = {ATT_CHAR_SC_CNTL_PT, PERM(IND, ENABLE) | PERM(WRITE_REQ, ENABLE), - PERM(RI, ENABLE), CSCP_SC_CNTL_PT_RSP_MAX_LEN}, - // SC Control Point Characteristic - Client Characteristic Configuration Descriptor - [CSCS_IDX_SC_CTNL_PT_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [CSCS_IDX_SC_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), + CSCS_IDX_SC_CTNL_PT_VAL, 0}, + // SC Control Point Characteristic Value - The response has the maximal + // length + [CSCS_IDX_SC_CTNL_PT_VAL] = {ATT_CHAR_SC_CNTL_PT, + PERM(IND, ENABLE) | PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE), CSCP_SC_CNTL_PT_RSP_MAX_LEN}, + // SC Control Point Characteristic - Client Characteristic Configuration + // Descriptor + [CSCS_IDX_SC_CTNL_PT_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + 0, 0}, }; /* @@ -77,112 +91,122 @@ static const struct attm_desc cscps_att_db[CSCS_IDX_NB] = * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t cscps_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, struct cscps_db_cfg* param) -{ - //------------------ create the attribute database for the profile ------------------- - // Service content flag - uint32_t cfg_flag= CSCPS_MANDATORY_MASK; - // DB Creation Status - uint8_t status = ATT_ERR_NO_ERROR; +static uint8_t cscps_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, + struct cscps_db_cfg *param) { + //------------------ create the attribute database for the profile + //------------------- + // Service content flag + uint32_t cfg_flag = CSCPS_MANDATORY_MASK; + // DB Creation Status + uint8_t status = ATT_ERR_NO_ERROR; - /* - * Check if the Sensor Location characteristic shall be added. - * Mandatory if the Multiple Sensor Location feature is supported, otherwise optional. - */ - if ((param->sensor_loc_supp == CSCPS_SENSOR_LOC_SUPP) || - (CSCPS_IS_FEATURE_SUPPORTED(param->csc_feature, CSCP_FEAT_MULT_SENSOR_LOC_SUPP))) - { - cfg_flag |= CSCPS_SENSOR_LOC_MASK; + /* + * Check if the Sensor Location characteristic shall be added. + * Mandatory if the Multiple Sensor Location feature is supported, otherwise + * optional. + */ + if ((param->sensor_loc_supp == CSCPS_SENSOR_LOC_SUPP) || + (CSCPS_IS_FEATURE_SUPPORTED(param->csc_feature, + CSCP_FEAT_MULT_SENSOR_LOC_SUPP))) { + cfg_flag |= CSCPS_SENSOR_LOC_MASK; + } + + /* + * Check if the SC Control Point characteristic shall be added + * Mandatory if at least one SC Control Point procedure is supported, + * otherwise excluded. + */ + if (CSCPS_IS_FEATURE_SUPPORTED(param->csc_feature, + CSCP_FEAT_WHEEL_REV_DATA_SUPP) || + CSCPS_IS_FEATURE_SUPPORTED(param->csc_feature, + CSCP_FEAT_MULT_SENSOR_LOC_SUPP)) { + cfg_flag |= CSCPS_SC_CTNL_PT_MASK; + } + + // Add service in the database + status = attm_svc_create_db( + start_hdl, ATT_SVC_CYCLING_SPEED_CADENCE, (uint8_t *)&cfg_flag, + CSCS_IDX_NB, NULL, env->task, &cscps_att_db[0], + (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, DISABLE)); + + // Check if an error has occured + if (status == ATT_ERR_NO_ERROR) { + // Allocate CSCPS required environment variable + struct cscps_env_tag *cscps_env = (struct cscps_env_tag *)ke_malloc( + sizeof(struct cscps_env_tag), KE_MEM_ATT_DB); + + // Initialize CSCPS environment + + env->env = (prf_env_t *)cscps_env; + cscps_env->shdl = *start_hdl; + cscps_env->prfl_cfg = cfg_flag; + cscps_env->features = param->csc_feature; + cscps_env->operation = CSCPS_RESERVED_OP_CODE; + + if (CSCPS_IS_FEATURE_SUPPORTED(cscps_env->prfl_cfg, + CSCPS_SENSOR_LOC_MASK)) { + cscps_env->sensor_loc = (param->sensor_loc >= CSCP_LOC_MAX) + ? CSCP_LOC_OTHER + : param->sensor_loc; } - /* - * Check if the SC Control Point characteristic shall be added - * Mandatory if at least one SC Control Point procedure is supported, otherwise excluded. - */ - if (CSCPS_IS_FEATURE_SUPPORTED(param->csc_feature, CSCP_FEAT_WHEEL_REV_DATA_SUPP) || - CSCPS_IS_FEATURE_SUPPORTED(param->csc_feature, CSCP_FEAT_MULT_SENSOR_LOC_SUPP)) - { - cfg_flag |= CSCPS_SC_CTNL_PT_MASK; - } + cscps_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + // Mono Instantiated task + cscps_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); - // Add service in the database - status = attm_svc_create_db(start_hdl, ATT_SVC_CYCLING_SPEED_CADENCE, (uint8_t *)&cfg_flag, - CSCS_IDX_NB, NULL, env->task, &cscps_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | PERM(SVC_MI, DISABLE)); + // initialize environment variable + env->id = TASK_ID_CSCPS; + cscps_task_init(&(env->desc)); - // Check if an error has occured - if (status == ATT_ERR_NO_ERROR) - { - // Allocate CSCPS required environment variable - struct cscps_env_tag* cscps_env = - (struct cscps_env_tag* ) ke_malloc(sizeof(struct cscps_env_tag), KE_MEM_ATT_DB); + // Store the provided cumulative wheel revolution value + cscps_env->tot_wheel_rev = param->wheel_rev; + cscps_env->ntf = NULL; - // Initialize CSCPS environment + memset(cscps_env->prfl_ntf_ind_cfg, 0, BLE_CONNECTION_MAX); - env->env = (prf_env_t*) cscps_env; - cscps_env->shdl = *start_hdl; - cscps_env->prfl_cfg = cfg_flag; - cscps_env->features = param->csc_feature; - cscps_env->operation = CSCPS_RESERVED_OP_CODE; + // If we are here, database has been fulfilled with success, go to idle + // state + ke_state_set(env->task, CSCPS_IDLE); + } - if (CSCPS_IS_FEATURE_SUPPORTED(cscps_env->prfl_cfg, CSCPS_SENSOR_LOC_MASK)) - { - cscps_env->sensor_loc = (param->sensor_loc >= CSCP_LOC_MAX) ? - CSCP_LOC_OTHER : param->sensor_loc; - } - - cscps_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - // Mono Instantiated task - cscps_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); - - // initialize environment variable - env->id = TASK_ID_CSCPS; - cscps_task_init(&(env->desc)); - - // Store the provided cumulative wheel revolution value - cscps_env->tot_wheel_rev = param->wheel_rev; - cscps_env->ntf = NULL; - - memset(cscps_env->prfl_ntf_ind_cfg, 0, BLE_CONNECTION_MAX); - - // If we are here, database has been fulfilled with success, go to idle state - ke_state_set(env->task, CSCPS_IDLE); - } - - return (status); + return (status); } /** **************************************************************************************** * @brief Destruction of the CSCPS module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void cscps_destroy(struct prf_task_env* env) -{ - struct cscps_env_tag* cscps_env = (struct cscps_env_tag*) env->env; +static void cscps_destroy(struct prf_task_env *env) { + struct cscps_env_tag *cscps_env = (struct cscps_env_tag *)env->env; - // cleanup environment variable for each task instances - if(cscps_env->ntf != NULL) - { - ke_free(cscps_env->ntf); - } + // cleanup environment variable for each task instances + if (cscps_env->ntf != NULL) { + ke_free(cscps_env->ntf); + } - // free profile environment variables - env->env = NULL; - ke_free(cscps_env); + // free profile environment variables + env->env = NULL; + ke_free(cscps_env); } /** @@ -193,10 +217,9 @@ static void cscps_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void cscps_create(struct prf_task_env* env, uint8_t conidx) -{ - struct cscps_env_tag* cscps_env = (struct cscps_env_tag*) env->env; - cscps_env->prfl_ntf_ind_cfg[conidx] = 0; +static void cscps_create(struct prf_task_env *env, uint8_t conidx) { + struct cscps_env_tag *cscps_env = (struct cscps_env_tag *)env->env; + cscps_env->prfl_ntf_ind_cfg[conidx] = 0; } /** @@ -208,12 +231,12 @@ static void cscps_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void cscps_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct cscps_env_tag* cscps_env = (struct cscps_env_tag*) env->env; +static void cscps_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct cscps_env_tag *cscps_env = (struct cscps_env_tag *)env->env; - // clean-up environment variable allocated for task instance - cscps_env->prfl_ntf_ind_cfg[conidx] = 0; + // clean-up environment variable allocated for task instance + cscps_env->prfl_ntf_ind_cfg[conidx] = 0; } /* @@ -222,12 +245,11 @@ static void cscps_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reas */ /// CSCPS Task interface required by profile manager -const struct prf_task_cbs cscps_itf = -{ - (prf_init_fnct) cscps_init, - cscps_destroy, - cscps_create, - cscps_cleanup, +const struct prf_task_cbs cscps_itf = { + (prf_init_fnct)cscps_init, + cscps_destroy, + cscps_create, + cscps_cleanup, }; /* @@ -235,121 +257,110 @@ const struct prf_task_cbs cscps_itf = **************************************************************************************** */ -const struct prf_task_cbs* cscps_prf_itf_get(void) -{ - return &cscps_itf; +const struct prf_task_cbs *cscps_prf_itf_get(void) { return &cscps_itf; } + +void cscps_send_cmp_evt(uint8_t conidx, uint8_t src_id, uint8_t dest_id, + uint8_t operation, uint8_t status) { + // Get the address of the environment + struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); + + // Go back to the Connected state if the state is busy + if (ke_state_get(src_id) == CSCPS_BUSY) { + ke_state_set(src_id, CSCPS_IDLE); + } + + // Set the operation code + cscps_env->operation = CSCPS_RESERVED_OP_CODE; + + // Send the message + struct cscps_cmp_evt *evt = + KE_MSG_ALLOC(CSCPS_CMP_EVT, dest_id, src_id, cscps_cmp_evt); + + evt->conidx = conidx; + evt->operation = operation; + evt->status = status; + + ke_msg_send(evt); } -void cscps_send_cmp_evt(uint8_t conidx, uint8_t src_id, uint8_t dest_id, uint8_t operation, uint8_t status) -{ - // Get the address of the environment - struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); +void cscps_exe_operation(void) { + struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); - // Go back to the Connected state if the state is busy - if (ke_state_get(src_id) == CSCPS_BUSY) - { - ke_state_set(src_id, CSCPS_IDLE); + ASSERT_ERR(cscps_env->ntf != NULL); + + bool finished = true; + + while (cscps_env->ntf->cursor < BLE_CONNECTION_MAX) { + // Check if notifications are enabled + if (CSCPS_IS_NTFIND_ENABLED(cscps_env->ntf->cursor, + CSCP_PRF_CFG_FLAG_CSC_MEAS_NTF)) { + // Allocate the GATT notification message + struct gattc_send_evt_cmd *meas_val = KE_MSG_ALLOC_DYN( + GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, cscps_env->ntf->cursor), + prf_src_task_get(&(cscps_env->prf_env), 0), gattc_send_evt_cmd, + cscps_env->ntf->length); + + // Fill in the parameter structure + meas_val->operation = GATTC_NOTIFY; + meas_val->handle = CSCPS_HANDLE(CSCS_IDX_CSC_MEAS_VAL); + meas_val->length = cscps_env->ntf->length; + memcpy(meas_val->value, cscps_env->ntf->value, cscps_env->ntf->length); + + // Send the event + ke_msg_send(meas_val); + + finished = false; + cscps_env->ntf->cursor++; + break; } - // Set the operation code + cscps_env->ntf->cursor++; + } + + // check if operation is finished + if (finished) { + // Inform the application that a procedure has been completed + struct cscps_ntf_csc_meas_rsp *rsp = KE_MSG_ALLOC( + CSCPS_NTF_CSC_MEAS_RSP, prf_dst_task_get(&(cscps_env->prf_env), 0), + prf_src_task_get(&(cscps_env->prf_env), 0), cscps_ntf_csc_meas_rsp); + + rsp->status = GAP_ERR_NO_ERROR; + rsp->tot_wheel_rev = cscps_env->tot_wheel_rev; + ke_msg_send(rsp); + + // free operation + ke_free(cscps_env->ntf); + cscps_env->ntf = NULL; cscps_env->operation = CSCPS_RESERVED_OP_CODE; - // Send the message - struct cscps_cmp_evt *evt = KE_MSG_ALLOC(CSCPS_CMP_EVT, - dest_id, src_id, - cscps_cmp_evt); - - evt->conidx = conidx; - evt->operation = operation; - evt->status = status; - - ke_msg_send(evt); + ke_state_set(prf_src_task_get(&(cscps_env->prf_env), 0), CSCPS_IDLE); + } } +void cscps_send_rsp_ind(uint8_t conidx, uint8_t req_op_code, uint8_t status) { + // Get the address of the environment + struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); -void cscps_exe_operation(void) -{ - struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); + // Allocate the GATT notification message + struct gattc_send_evt_cmd *ctl_pt_rsp = + KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&cscps_env->prf_env, conidx), + gattc_send_evt_cmd, CSCP_SC_CNTL_PT_RSP_MIN_LEN); - ASSERT_ERR(cscps_env->ntf != NULL); + // Fill in the parameter structure + ctl_pt_rsp->operation = GATTC_INDICATE; + ctl_pt_rsp->handle = CSCPS_HANDLE(CSCS_IDX_SC_CTNL_PT_VAL); + // Pack Control Point confirmation + ctl_pt_rsp->length = CSCP_SC_CNTL_PT_RSP_MIN_LEN; + // Response Code + ctl_pt_rsp->value[0] = CSCP_CTNL_PT_RSP_CODE; + // Request Operation Code + ctl_pt_rsp->value[1] = req_op_code; + // Response value + ctl_pt_rsp->value[2] = status; - bool finished = true; - - while(cscps_env->ntf->cursor < BLE_CONNECTION_MAX) - { - // Check if notifications are enabled - if(CSCPS_IS_NTFIND_ENABLED(cscps_env->ntf->cursor, CSCP_PRF_CFG_FLAG_CSC_MEAS_NTF)) - { - // Allocate the GATT notification message - struct gattc_send_evt_cmd *meas_val = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, cscps_env->ntf->cursor), - prf_src_task_get(&(cscps_env->prf_env), 0), - gattc_send_evt_cmd, cscps_env->ntf->length); - - // Fill in the parameter structure - meas_val->operation = GATTC_NOTIFY; - meas_val->handle = CSCPS_HANDLE(CSCS_IDX_CSC_MEAS_VAL); - meas_val->length = cscps_env->ntf->length; - memcpy(meas_val->value, cscps_env->ntf->value, cscps_env->ntf->length); - - // Send the event - ke_msg_send(meas_val); - - finished = false; - cscps_env->ntf->cursor++; - break; - } - - cscps_env->ntf->cursor++; - } - - // check if operation is finished - if(finished) - { - // Inform the application that a procedure has been completed - struct cscps_ntf_csc_meas_rsp *rsp = KE_MSG_ALLOC(CSCPS_NTF_CSC_MEAS_RSP, - prf_dst_task_get(&(cscps_env->prf_env), 0), - prf_src_task_get(&(cscps_env->prf_env), 0), - cscps_ntf_csc_meas_rsp); - - rsp->status = GAP_ERR_NO_ERROR; - rsp->tot_wheel_rev = cscps_env->tot_wheel_rev; - ke_msg_send(rsp); - - // free operation - ke_free(cscps_env->ntf); - cscps_env->ntf = NULL; - cscps_env->operation = CSCPS_RESERVED_OP_CODE; - - ke_state_set(prf_src_task_get(&(cscps_env->prf_env), 0), CSCPS_IDLE); - } -} - -void cscps_send_rsp_ind(uint8_t conidx, uint8_t req_op_code, uint8_t status) -{ - // Get the address of the environment - struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); - - // Allocate the GATT notification message - struct gattc_send_evt_cmd *ctl_pt_rsp = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), - prf_src_task_get(&cscps_env->prf_env, conidx), - gattc_send_evt_cmd, CSCP_SC_CNTL_PT_RSP_MIN_LEN); - - // Fill in the parameter structure - ctl_pt_rsp->operation = GATTC_INDICATE; - ctl_pt_rsp->handle = CSCPS_HANDLE(CSCS_IDX_SC_CTNL_PT_VAL); - // Pack Control Point confirmation - ctl_pt_rsp->length = CSCP_SC_CNTL_PT_RSP_MIN_LEN; - // Response Code - ctl_pt_rsp->value[0] = CSCP_CTNL_PT_RSP_CODE; - // Request Operation Code - ctl_pt_rsp->value[1] = req_op_code; - // Response value - ctl_pt_rsp->value[2] = status; - - // Send the event - ke_msg_send(ctl_pt_rsp); + // Send the event + ke_msg_send(ctl_pt_rsp); } #endif //(BLE_CSC_SENSOR) diff --git a/services/ble_profiles/cscp/cscps/src/cscps_task.c b/services/ble_profiles/cscp/cscps/src/cscps_task.c index 6ec34e8..3f13e9d 100644 --- a/services/ble_profiles/cscp/cscps/src/cscps_task.c +++ b/services/ble_profiles/cscp/cscps/src/cscps_task.c @@ -14,15 +14,15 @@ #if (BLE_CSC_SENSOR) -#include "gapc.h" -#include "gattc_task.h" +#include "co_math.h" #include "cscps.h" #include "cscps_task.h" +#include "gapc.h" +#include "gattc_task.h" #include "prf_utils.h" -#include "co_math.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * LOCAL FUNCTIONS DEFINITIONS @@ -40,49 +40,46 @@ **************************************************************************************** */ __STATIC int cscps_enable_req_handler(ke_msg_id_t const msgid, - struct cscps_enable_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); - // Status - uint8_t status = PRF_ERR_REQ_DISALLOWED; + struct cscps_enable_req *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); + // Status + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if(ke_state_get(dest_id) == CSCPS_IDLE) - { - status = GAP_ERR_NO_ERROR; + if (ke_state_get(dest_id) == CSCPS_IDLE) { + status = GAP_ERR_NO_ERROR; - if (!CSCPS_IS_PRESENT(cscps_env->prfl_ntf_ind_cfg[param->conidx], CSCP_PRF_CFG_PERFORMED_OK)) - { - // Check the provided value - if (param->csc_meas_ntf_cfg == PRF_CLI_START_NTF) - { - // Store the status - CSCPS_ENABLE_NTFIND(param->conidx, CSCP_PRF_CFG_FLAG_CSC_MEAS_NTF); - } + if (!CSCPS_IS_PRESENT(cscps_env->prfl_ntf_ind_cfg[param->conidx], + CSCP_PRF_CFG_PERFORMED_OK)) { + // Check the provided value + if (param->csc_meas_ntf_cfg == PRF_CLI_START_NTF) { + // Store the status + CSCPS_ENABLE_NTFIND(param->conidx, CSCP_PRF_CFG_FLAG_CSC_MEAS_NTF); + } - if (CSCPS_IS_FEATURE_SUPPORTED(cscps_env->prfl_cfg, CSCPS_SC_CTNL_PT_MASK)) - { - // Check the provided value - if (param->sc_ctnl_pt_ntf_cfg == PRF_CLI_START_IND) - { - // Store the status - CSCPS_ENABLE_NTFIND(param->conidx, CSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND); - } - } - // Enable Bonded Data - CSCPS_ENABLE_NTFIND(param->conidx, CSCP_PRF_CFG_PERFORMED_OK); + if (CSCPS_IS_FEATURE_SUPPORTED(cscps_env->prfl_cfg, + CSCPS_SC_CTNL_PT_MASK)) { + // Check the provided value + if (param->sc_ctnl_pt_ntf_cfg == PRF_CLI_START_IND) { + // Store the status + CSCPS_ENABLE_NTFIND(param->conidx, CSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND); } + } + // Enable Bonded Data + CSCPS_ENABLE_NTFIND(param->conidx, CSCP_PRF_CFG_PERFORMED_OK); } + } - // send completed information to APP task that contains error status - struct cscps_enable_rsp *cmp_evt = KE_MSG_ALLOC(CSCPS_ENABLE_RSP, src_id, dest_id, cscps_enable_rsp); - cmp_evt->status = status; - cmp_evt->conidx = param->conidx; - ke_msg_send(cmp_evt); + // send completed information to APP task that contains error status + struct cscps_enable_rsp *cmp_evt = + KE_MSG_ALLOC(CSCPS_ENABLE_RSP, src_id, dest_id, cscps_enable_rsp); + cmp_evt->status = status; + cmp_evt->conidx = param->conidx; + ke_msg_send(cmp_evt); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -97,74 +94,74 @@ __STATIC int cscps_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_read_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if(ke_state_get(dest_id) == CSCPS_IDLE) - { - // Get the address of the environment - struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); - uint8_t conidx = KE_IDX_GET(src_id); - uint8_t att_idx = CSCPS_IDX(param->handle); + struct gattc_read_req_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + if (ke_state_get(dest_id) == CSCPS_IDLE) { + // Get the address of the environment + struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); + uint8_t conidx = KE_IDX_GET(src_id); + uint8_t att_idx = CSCPS_IDX(param->handle); - // Send data to peer device - struct gattc_read_cfm* cfm = NULL; + // Send data to peer device + struct gattc_read_cfm *cfm = NULL; - uint8_t status = ATT_ERR_NO_ERROR; + uint8_t status = ATT_ERR_NO_ERROR; - switch(att_idx) - { - case CSCS_IDX_CSC_MEAS_NTF_CFG: - { - // Fill data - cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(uint16_t)); - cfm->length = sizeof(uint16_t); - co_write16p(cfm->value, (cscps_env->prfl_ntf_ind_cfg[conidx] & CSCP_PRF_CFG_FLAG_CSC_MEAS_NTF) - ? PRF_CLI_START_NTF : PRF_CLI_STOP_NTFIND); - } break; + switch (att_idx) { + case CSCS_IDX_CSC_MEAS_NTF_CFG: { + // Fill data + cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, + sizeof(uint16_t)); + cfm->length = sizeof(uint16_t); + co_write16p(cfm->value, (cscps_env->prfl_ntf_ind_cfg[conidx] & + CSCP_PRF_CFG_FLAG_CSC_MEAS_NTF) + ? PRF_CLI_START_NTF + : PRF_CLI_STOP_NTFIND); + } break; - case CSCS_IDX_CSC_FEAT_VAL: - { - // Fill data - cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(uint16_t)); - cfm->length = sizeof(uint16_t); - co_write16p(cfm->value, cscps_env->features); - } break; + case CSCS_IDX_CSC_FEAT_VAL: { + // Fill data + cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, + sizeof(uint16_t)); + cfm->length = sizeof(uint16_t); + co_write16p(cfm->value, cscps_env->features); + } break; - case CSCS_IDX_SENSOR_LOC_VAL: - { - // Fill data - cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(uint8_t)); - cfm->length = sizeof(uint8_t); - cfm->value[0] = cscps_env->sensor_loc; - } break; + case CSCS_IDX_SENSOR_LOC_VAL: { + // Fill data + cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, + sizeof(uint8_t)); + cfm->length = sizeof(uint8_t); + cfm->value[0] = cscps_env->sensor_loc; + } break; - case CSCS_IDX_SC_CTNL_PT_NTF_CFG: - { - // Fill data - cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(uint16_t)); - cfm->length = sizeof(uint16_t); - co_write16p(cfm->value, (cscps_env->prfl_ntf_ind_cfg[conidx] & CSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND) - ? PRF_CLI_START_IND : PRF_CLI_STOP_NTFIND); - } break; + case CSCS_IDX_SC_CTNL_PT_NTF_CFG: { + // Fill data + cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, + sizeof(uint16_t)); + cfm->length = sizeof(uint16_t); + co_write16p(cfm->value, (cscps_env->prfl_ntf_ind_cfg[conidx] & + CSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND) + ? PRF_CLI_START_IND + : PRF_CLI_STOP_NTFIND); + } break; - default: - { - cfm = KE_MSG_ALLOC(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm); - cfm->length = 0; - status = ATT_ERR_REQUEST_NOT_SUPPORTED; - } break; - } - - cfm->handle = param->handle; - cfm->status = status; - - // Send value to peer device. - ke_msg_send(cfm); + default: { + cfm = KE_MSG_ALLOC(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm); + cfm->length = 0; + status = ATT_ERR_REQUEST_NOT_SUPPORTED; + } break; } - return (KE_MSG_CONSUMED); + cfm->handle = param->handle; + cfm->status = status; + + // Send value to peer device. + ke_msg_send(cfm); + } + + return (KE_MSG_CONSUMED); } /** @@ -178,46 +175,39 @@ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_att_info_req_ind *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if(ke_state_get(dest_id) == CSCPS_IDLE) - { - // Get the address of the environment - struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); - uint8_t att_idx = CSCPS_IDX(param->handle); - struct gattc_att_info_cfm * cfm; +__STATIC int gattc_att_info_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_att_info_req_ind *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + if (ke_state_get(dest_id) == CSCPS_IDLE) { + // Get the address of the environment + struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); + uint8_t att_idx = CSCPS_IDX(param->handle); + struct gattc_att_info_cfm *cfm; - //Send write response - cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); - cfm->handle = param->handle; + // Send write response + cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); + cfm->handle = param->handle; - // check if it's a client configuration char - if((att_idx == CSCS_IDX_CSC_MEAS_NTF_CFG) - || (att_idx == CSCS_IDX_SC_CTNL_PT_NTF_CFG)) - { - // CCC attribute length = 2 - cfm->length = 2; - cfm->status = GAP_ERR_NO_ERROR; - } - else if (att_idx == CSCS_IDX_SC_CTNL_PT_VAL) - { - // force length to zero to reject any write starting from something != 0 - cfm->length = 0; - cfm->status = GAP_ERR_NO_ERROR; - } - // not expected request - else - { - cfm->length = 0; - cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; - } - ke_msg_send(cfm); - } + // check if it's a client configuration char + if ((att_idx == CSCS_IDX_CSC_MEAS_NTF_CFG) || + (att_idx == CSCS_IDX_SC_CTNL_PT_NTF_CFG)) { + // CCC attribute length = 2 + cfm->length = 2; + cfm->status = GAP_ERR_NO_ERROR; + } else if (att_idx == CSCS_IDX_SC_CTNL_PT_VAL) { + // force length to zero to reject any write starting from something != 0 + cfm->length = 0; + cfm->status = GAP_ERR_NO_ERROR; + } + // not expected request + else { + cfm->length = 0; + cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; + } + ke_msg_send(cfm); + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -230,105 +220,97 @@ __STATIC int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int cscps_ntf_csc_meas_req_handler(ke_msg_id_t const msgid, - struct cscps_ntf_csc_meas_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; +__STATIC int cscps_ntf_csc_meas_req_handler( + ke_msg_id_t const msgid, struct cscps_ntf_csc_meas_req *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; - // State shall be Connected or Busy - if (ke_state_get(dest_id) == CSCPS_IDLE) - { - // Get the address of the environment - struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); + // State shall be Connected or Busy + if (ke_state_get(dest_id) == CSCPS_IDLE) { + // Get the address of the environment + struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); - // allocate and prepare data to notify - cscps_env->ntf = (struct cscps_ntf*) ke_malloc(sizeof(struct cscps_ntf), KE_MEM_KE_MSG); + // allocate and prepare data to notify + cscps_env->ntf = + (struct cscps_ntf *)ke_malloc(sizeof(struct cscps_ntf), KE_MEM_KE_MSG); - // pack measured value in database - cscps_env->ntf->length = CSCP_CSC_MEAS_MIN_LEN; + // pack measured value in database + cscps_env->ntf->length = CSCP_CSC_MEAS_MIN_LEN; - // Check the provided flags value - if (!CSCPS_IS_FEATURE_SUPPORTED(cscps_env->prfl_cfg, CSCP_FEAT_WHEEL_REV_DATA_SUPP) && - CSCPS_IS_PRESENT(param->flags, CSCP_MEAS_WHEEL_REV_DATA_PRESENT)) - { - // Force Wheel Revolution Data to No (Not supported) - param->flags &= ~CSCP_MEAS_WHEEL_REV_DATA_PRESENT; - } - - if (!CSCPS_IS_FEATURE_SUPPORTED(cscps_env->prfl_cfg, CSCP_FEAT_CRANK_REV_DATA_SUPP) && - CSCPS_IS_PRESENT(param->flags, CSCP_MEAS_CRANK_REV_DATA_PRESENT)) - { - // Force Crank Revolution Data Present to No (Not supported) - param->flags &= ~CSCP_MEAS_CRANK_REV_DATA_PRESENT; - } - - // Force the unused bits of the flag value to 0 - cscps_env->ntf->value[0] = param->flags & CSCP_MEAS_ALL_PRESENT; - - // Cumulative Wheel Resolutions - // Last Wheel Event Time - if (CSCPS_IS_PRESENT(param->flags, CSCP_MEAS_WHEEL_REV_DATA_PRESENT)) - { - // Update the cumulative wheel revolutions value stored in the environment - if (param->wheel_rev < 0) - { - // The value shall not decrement below zero - if (co_abs(param->wheel_rev) > cscps_env->tot_wheel_rev) - { - cscps_env->tot_wheel_rev = 0; - } - else - { - cscps_env->tot_wheel_rev += param->wheel_rev; - } - } - else - { - cscps_env->tot_wheel_rev += param->wheel_rev; - } - - // Cumulative Wheel Resolutions - co_write32p(&cscps_env->ntf->value[cscps_env->ntf->length], cscps_env->tot_wheel_rev); - cscps_env->ntf->length += 4; - - // Last Wheel Event Time - co_write16p(&cscps_env->ntf->value[cscps_env->ntf->length], param->last_wheel_evt_time); - cscps_env->ntf->length += 2; - } - - // Cumulative Crank Revolutions - // Last Crank Event Time - if (CSCPS_IS_PRESENT(param->flags, CSCP_MEAS_CRANK_REV_DATA_PRESENT)) - { - // Cumulative Crank Revolutions - co_write32p(&cscps_env->ntf->value[cscps_env->ntf->length], param->cumul_crank_rev); - cscps_env->ntf->length += 2; - - // Last Crank Event Time - co_write16p(&cscps_env->ntf->value[cscps_env->ntf->length], param->last_crank_evt_time); - cscps_env->ntf->length += 2; - } - - // Configure the environment - cscps_env->operation = CSCPS_SEND_CSC_MEAS_OP_CODE; - cscps_env->ntf->cursor = 0; - - // Go to busy state - ke_state_set(dest_id, CSCPS_BUSY); - - // start operation execution - cscps_exe_operation(); - } - else - { - // Save it for later - msg_status = KE_MSG_SAVED; + // Check the provided flags value + if (!CSCPS_IS_FEATURE_SUPPORTED(cscps_env->prfl_cfg, + CSCP_FEAT_WHEEL_REV_DATA_SUPP) && + CSCPS_IS_PRESENT(param->flags, CSCP_MEAS_WHEEL_REV_DATA_PRESENT)) { + // Force Wheel Revolution Data to No (Not supported) + param->flags &= ~CSCP_MEAS_WHEEL_REV_DATA_PRESENT; } - return (int)msg_status; + if (!CSCPS_IS_FEATURE_SUPPORTED(cscps_env->prfl_cfg, + CSCP_FEAT_CRANK_REV_DATA_SUPP) && + CSCPS_IS_PRESENT(param->flags, CSCP_MEAS_CRANK_REV_DATA_PRESENT)) { + // Force Crank Revolution Data Present to No (Not supported) + param->flags &= ~CSCP_MEAS_CRANK_REV_DATA_PRESENT; + } + + // Force the unused bits of the flag value to 0 + cscps_env->ntf->value[0] = param->flags & CSCP_MEAS_ALL_PRESENT; + + // Cumulative Wheel Resolutions + // Last Wheel Event Time + if (CSCPS_IS_PRESENT(param->flags, CSCP_MEAS_WHEEL_REV_DATA_PRESENT)) { + // Update the cumulative wheel revolutions value stored in the environment + if (param->wheel_rev < 0) { + // The value shall not decrement below zero + if (co_abs(param->wheel_rev) > cscps_env->tot_wheel_rev) { + cscps_env->tot_wheel_rev = 0; + } else { + cscps_env->tot_wheel_rev += param->wheel_rev; + } + } else { + cscps_env->tot_wheel_rev += param->wheel_rev; + } + + // Cumulative Wheel Resolutions + co_write32p(&cscps_env->ntf->value[cscps_env->ntf->length], + cscps_env->tot_wheel_rev); + cscps_env->ntf->length += 4; + + // Last Wheel Event Time + co_write16p(&cscps_env->ntf->value[cscps_env->ntf->length], + param->last_wheel_evt_time); + cscps_env->ntf->length += 2; + } + + // Cumulative Crank Revolutions + // Last Crank Event Time + if (CSCPS_IS_PRESENT(param->flags, CSCP_MEAS_CRANK_REV_DATA_PRESENT)) { + // Cumulative Crank Revolutions + co_write32p(&cscps_env->ntf->value[cscps_env->ntf->length], + param->cumul_crank_rev); + cscps_env->ntf->length += 2; + + // Last Crank Event Time + co_write16p(&cscps_env->ntf->value[cscps_env->ntf->length], + param->last_crank_evt_time); + cscps_env->ntf->length += 2; + } + + // Configure the environment + cscps_env->operation = CSCPS_SEND_CSC_MEAS_OP_CODE; + cscps_env->ntf->cursor = 0; + + // Go to busy state + ke_state_set(dest_id, CSCPS_BUSY); + + // start operation execution + cscps_exe_operation(); + } else { + // Save it for later + msg_status = KE_MSG_SAVED; + } + + return (int)msg_status; } /** @@ -344,129 +326,117 @@ __STATIC int cscps_ntf_csc_meas_req_handler(ke_msg_id_t const msgid, __STATIC int cscps_sc_ctnl_pt_cfm_handler(ke_msg_id_t const msgid, struct cscps_sc_ctnl_pt_cfm *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); - uint8_t conidx = KE_IDX_GET(src_id); - // Status - uint8_t status = PRF_ERR_REQ_DISALLOWED; + ke_task_id_t const src_id) { + // Get the address of the environment + struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); + uint8_t conidx = KE_IDX_GET(src_id); + // Status + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if (ke_state_get(dest_id) == CSCPS_BUSY) - { - do - { // check if op code valid - if((param->op_code < CSCPS_CTNL_PT_CUMUL_VAL_OP_CODE) - || (param->op_code > CSCPS_CTNL_ERR_IND_OP_CODE)) - { - //Wrong op code - status = PRF_ERR_INVALID_PARAM; - break; + if (ke_state_get(dest_id) == CSCPS_BUSY) { + do { // check if op code valid + if ((param->op_code < CSCPS_CTNL_PT_CUMUL_VAL_OP_CODE) || + (param->op_code > CSCPS_CTNL_ERR_IND_OP_CODE)) { + // Wrong op code + status = PRF_ERR_INVALID_PARAM; + break; + } + + // Check the current operation + if ((cscps_env->operation < CSCPS_CTNL_PT_CUMUL_VAL_OP_CODE) || + (param->op_code != cscps_env->operation)) { + // The confirmation has been sent without request indication, ignore + status = PRF_ERR_REQ_DISALLOWED; + break; + } + + // The CP Control Point Characteristic must be supported if we are here + if (CSCPS_IS_FEATURE_SUPPORTED(cscps_env->prfl_cfg, + CSCPS_SC_CTNL_PT_MASK)) { + // Allocate the GATT notification message + struct gattc_send_evt_cmd *ctl_pt_rsp = KE_MSG_ALLOC_DYN( + GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, param->conidx), dest_id, + gattc_send_evt_cmd, CSCP_SC_CNTL_PT_RSP_MAX_LEN); + + // Fill in the parameter structure + ctl_pt_rsp->operation = GATTC_INDICATE; + ctl_pt_rsp->handle = CSCPS_HANDLE(CSCS_IDX_SC_CTNL_PT_VAL); + // Pack Control Point confirmation + ctl_pt_rsp->length = CSCP_SC_CNTL_PT_RSP_MIN_LEN; + + // Set the operation code (Response Code) + ctl_pt_rsp->value[0] = CSCP_CTNL_PT_RSP_CODE; + // Set the response value + ctl_pt_rsp->value[2] = (param->status > CSCP_CTNL_PT_RESP_FAILED) + ? CSCP_CTNL_PT_RESP_FAILED + : param->status; + + switch (cscps_env->operation) { + // Set cumulative value + case (CSCPS_CTNL_PT_CUMUL_VAL_OP_CODE): { + // Set the request operation code + ctl_pt_rsp->value[1] = CSCP_CTNL_PT_OP_SET_CUMUL_VAL; + + // Store the new value in the environment + cscps_env->tot_wheel_rev = param->value.cumul_wheel_rev; + status = GAP_ERR_NO_ERROR; + } break; + + // Update Sensor Location + case (CSCPS_CTNL_PT_UPD_LOC_OP_CODE): { + // Set the request operation code + ctl_pt_rsp->value[1] = CSCP_CTNL_PT_OP_UPD_LOC; + + if (param->status == CSCP_CTNL_PT_RESP_SUCCESS) { + // The CP Control Point Characteristic must be supported if we are + // here + if (CSCPS_IS_FEATURE_SUPPORTED(cscps_env->prfl_cfg, + CSCPS_SENSOR_LOC_MASK)) { + cscps_env->sensor_loc = param->value.sensor_loc; + status = GAP_ERR_NO_ERROR; } + } + } break; - // Check the current operation - if ((cscps_env->operation < CSCPS_CTNL_PT_CUMUL_VAL_OP_CODE) || - (param->op_code != cscps_env->operation)) - { - // The confirmation has been sent without request indication, ignore - status = PRF_ERR_REQ_DISALLOWED; - break; + case (CSCPS_CTNL_PT_SUPP_LOC_OP_CODE): { + // Set the request operation code + ctl_pt_rsp->value[1] = CSCP_CTNL_PT_OP_REQ_SUPP_LOC; + + if (param->status == CSCP_CTNL_PT_RESP_SUCCESS) { + // Counter + uint8_t counter; + + // Set the list of supported location + for (counter = 0; counter < CSCP_LOC_MAX; counter++) { + if (((param->value.supp_sensor_loc >> counter) & 0x0001) == + 0x0001) { + ctl_pt_rsp->value[ctl_pt_rsp->length] = counter; + ctl_pt_rsp->length++; + } } + status = GAP_ERR_NO_ERROR; + } + } break; - // The CP Control Point Characteristic must be supported if we are here - if (CSCPS_IS_FEATURE_SUPPORTED(cscps_env->prfl_cfg, CSCPS_SC_CTNL_PT_MASK)) - { - // Allocate the GATT notification message - struct gattc_send_evt_cmd *ctl_pt_rsp = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, param->conidx), dest_id, - gattc_send_evt_cmd, CSCP_SC_CNTL_PT_RSP_MAX_LEN); - - // Fill in the parameter structure - ctl_pt_rsp->operation = GATTC_INDICATE; - ctl_pt_rsp->handle = CSCPS_HANDLE(CSCS_IDX_SC_CTNL_PT_VAL); - // Pack Control Point confirmation - ctl_pt_rsp->length = CSCP_SC_CNTL_PT_RSP_MIN_LEN; - - // Set the operation code (Response Code) - ctl_pt_rsp->value[0] = CSCP_CTNL_PT_RSP_CODE; - // Set the response value - ctl_pt_rsp->value[2] = (param->status > CSCP_CTNL_PT_RESP_FAILED) ? CSCP_CTNL_PT_RESP_FAILED : param->status; - - switch (cscps_env->operation) - { - // Set cumulative value - case (CSCPS_CTNL_PT_CUMUL_VAL_OP_CODE): - { - // Set the request operation code - ctl_pt_rsp->value[1] = CSCP_CTNL_PT_OP_SET_CUMUL_VAL; - - // Store the new value in the environment - cscps_env->tot_wheel_rev = param->value.cumul_wheel_rev; - status = GAP_ERR_NO_ERROR; - } break; - - // Update Sensor Location - case (CSCPS_CTNL_PT_UPD_LOC_OP_CODE): - { - // Set the request operation code - ctl_pt_rsp->value[1] = CSCP_CTNL_PT_OP_UPD_LOC; - - if (param->status == CSCP_CTNL_PT_RESP_SUCCESS) - { - // The CP Control Point Characteristic must be supported if we are here - if (CSCPS_IS_FEATURE_SUPPORTED(cscps_env->prfl_cfg, CSCPS_SENSOR_LOC_MASK)) - { - cscps_env->sensor_loc = param->value.sensor_loc; - status = GAP_ERR_NO_ERROR; - } - } - } break; - - case (CSCPS_CTNL_PT_SUPP_LOC_OP_CODE): - { - // Set the request operation code - ctl_pt_rsp->value[1] = CSCP_CTNL_PT_OP_REQ_SUPP_LOC; - - if (param->status == CSCP_CTNL_PT_RESP_SUCCESS) - { - // Counter - uint8_t counter; - - // Set the list of supported location - for (counter = 0; counter < CSCP_LOC_MAX; counter++) - { - if (((param->value.supp_sensor_loc >> counter) & 0x0001) == 0x0001) - { - ctl_pt_rsp->value[ctl_pt_rsp->length] = counter; - ctl_pt_rsp->length++; - } - } - status = GAP_ERR_NO_ERROR; - } - } break; - - default: - { - ASSERT_ERR(0); - } break; - } - - // Send the event - ke_msg_send(ctl_pt_rsp); - } - } while (0); - - if (status != GAP_ERR_NO_ERROR) - { - // Inform the application that a procedure has been completed - cscps_send_cmp_evt(conidx, - prf_src_task_get(&cscps_env->prf_env, conidx), - prf_dst_task_get(&cscps_env->prf_env, conidx), - cscps_env->operation, param->status); + default: { + ASSERT_ERR(0); + } break; } - } - return (KE_MSG_CONSUMED); + // Send the event + ke_msg_send(ctl_pt_rsp); + } + } while (0); + + if (status != GAP_ERR_NO_ERROR) { + // Inform the application that a procedure has been completed + cscps_send_cmp_evt(conidx, prf_src_task_get(&cscps_env->prf_env, conidx), + prf_dst_task_get(&cscps_env->prf_env, conidx), + cscps_env->operation, param->status); + } + } + + return (KE_MSG_CONSUMED); } /** @@ -479,276 +449,251 @@ __STATIC int cscps_sc_ctnl_pt_cfm_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_write_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); - uint8_t conidx = KE_IDX_GET(src_id); - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; +__STATIC int gattc_write_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Get the address of the environment + struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); + uint8_t conidx = KE_IDX_GET(src_id); + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; - // Check the connection handle - if (cscps_env != NULL) + // Check the connection handle + if (cscps_env != NULL) { + // CSC Measurement Characteristic, Client Characteristic Configuration + // Descriptor + if (param->handle == (CSCPS_HANDLE(CSCS_IDX_CSC_MEAS_NTF_CFG))) { + uint16_t ntf_cfg; + // Status + uint8_t status = PRF_ERR_INVALID_PARAM; + + // Get the value + co_write16p(&ntf_cfg, param->value[0]); + + // Check if the value is correct + if (ntf_cfg <= PRF_CLI_START_NTF) { + status = GAP_ERR_NO_ERROR; + + // Save the new configuration in the environment + if (ntf_cfg == PRF_CLI_STOP_NTFIND) { + CSCPS_DISABLE_NTFIND(conidx, CSCP_PRF_CFG_FLAG_CSC_MEAS_NTF); + } else // ntf_cfg == PRF_CLI_START_NTF + { + CSCPS_ENABLE_NTFIND(conidx, CSCP_PRF_CFG_FLAG_CSC_MEAS_NTF); + } + + // Inform the HL about the new configuration + struct cscps_cfg_ntfind_ind *ind = KE_MSG_ALLOC( + CSCPS_CFG_NTFIND_IND, prf_dst_task_get(&cscps_env->prf_env, conidx), + prf_src_task_get(&cscps_env->prf_env, conidx), + cscps_cfg_ntfind_ind); + + ind->char_code = CSCP_CSCS_CSC_MEAS_CHAR; + ind->ntf_cfg = ntf_cfg; + + ke_msg_send(ind); + + // Enable Bonded Data + CSCPS_ENABLE_NTFIND(conidx, CSCP_PRF_CFG_PERFORMED_OK); + } + // else status is PRF_ERR_INVALID_PARAM + + // Send the write response to the peer device + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = status; + ke_msg_send(cfm); + } else // Should be the SC Control Point Characteristic { - // CSC Measurement Characteristic, Client Characteristic Configuration Descriptor - if (param->handle == (CSCPS_HANDLE(CSCS_IDX_CSC_MEAS_NTF_CFG))) - { - uint16_t ntf_cfg; - // Status - uint8_t status = PRF_ERR_INVALID_PARAM; + if (CSCPS_IS_FEATURE_SUPPORTED(cscps_env->prfl_cfg, + CSCPS_SC_CTNL_PT_MASK)) { + // SC Control Point, Client Characteristic Configuration Descriptor + if (param->handle == (CSCPS_HANDLE(CSCS_IDX_SC_CTNL_PT_NTF_CFG))) { + uint16_t ntf_cfg; + // Status + uint8_t status = PRF_ERR_INVALID_PARAM; - // Get the value - co_write16p(&ntf_cfg, param->value[0]); + // Get the value + co_write16p(&ntf_cfg, param->value[0]); - // Check if the value is correct - if (ntf_cfg <= PRF_CLI_START_NTF) + // Check if the value is correct + if ((ntf_cfg == PRF_CLI_STOP_NTFIND) || + (ntf_cfg == PRF_CLI_START_IND)) { + status = GAP_ERR_NO_ERROR; + + // Save the new configuration in the environment + if (ntf_cfg == PRF_CLI_STOP_NTFIND) { + CSCPS_DISABLE_NTFIND(conidx, CSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND); + } else // ntf_cfg == PRF_CLI_START_IND { - status = GAP_ERR_NO_ERROR; - - // Save the new configuration in the environment - if (ntf_cfg == PRF_CLI_STOP_NTFIND) - { - CSCPS_DISABLE_NTFIND(conidx, CSCP_PRF_CFG_FLAG_CSC_MEAS_NTF); - } - else // ntf_cfg == PRF_CLI_START_NTF - { - CSCPS_ENABLE_NTFIND(conidx, CSCP_PRF_CFG_FLAG_CSC_MEAS_NTF); - } - - // Inform the HL about the new configuration - struct cscps_cfg_ntfind_ind *ind = KE_MSG_ALLOC(CSCPS_CFG_NTFIND_IND, - prf_dst_task_get(&cscps_env->prf_env, conidx), - prf_src_task_get(&cscps_env->prf_env, conidx), - cscps_cfg_ntfind_ind); - - ind->char_code = CSCP_CSCS_CSC_MEAS_CHAR; - ind->ntf_cfg = ntf_cfg; - - ke_msg_send(ind); - - // Enable Bonded Data - CSCPS_ENABLE_NTFIND(conidx, CSCP_PRF_CFG_PERFORMED_OK); + CSCPS_ENABLE_NTFIND(conidx, CSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND); } - // else status is PRF_ERR_INVALID_PARAM - // Send the write response to the peer device - struct gattc_write_cfm *cfm = KE_MSG_ALLOC( - GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = status; - ke_msg_send(cfm); + // Inform the HL about the new configuration + struct cscps_cfg_ntfind_ind *ind = + KE_MSG_ALLOC(CSCPS_CFG_NTFIND_IND, + prf_dst_task_get(&cscps_env->prf_env, conidx), + prf_src_task_get(&cscps_env->prf_env, conidx), + cscps_cfg_ntfind_ind); + + ind->char_code = CSCP_CSCS_SC_CTNL_PT_CHAR; + ind->ntf_cfg = ntf_cfg; + + ke_msg_send(ind); + + // Enable Bonded Data + CSCPS_ENABLE_NTFIND(conidx, CSCP_PRF_CFG_PERFORMED_OK); + } + // else status is PRF_ERR_INVALID_PARAM + + // Send the write response to the peer device + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = status; + ke_msg_send(cfm); } - else // Should be the SC Control Point Characteristic - { - if (CSCPS_IS_FEATURE_SUPPORTED(cscps_env->prfl_cfg, CSCPS_SC_CTNL_PT_MASK)) - { - // SC Control Point, Client Characteristic Configuration Descriptor - if (param->handle == (CSCPS_HANDLE(CSCS_IDX_SC_CTNL_PT_NTF_CFG))) - { - uint16_t ntf_cfg; - // Status - uint8_t status = PRF_ERR_INVALID_PARAM; + // SC Control Point Characteristic + else if (param->handle == (CSCPS_HANDLE(CSCS_IDX_SC_CTNL_PT_VAL))) { + // Write Response Status + uint8_t wr_status = ATT_ERR_NO_ERROR; + // Indication Status + uint8_t ind_status = CSCP_CTNL_PT_RESP_NOT_SUPP; - // Get the value - co_write16p(&ntf_cfg, param->value[0]); - - // Check if the value is correct - if ((ntf_cfg == PRF_CLI_STOP_NTFIND) || (ntf_cfg == PRF_CLI_START_IND)) - { - status = GAP_ERR_NO_ERROR; - - // Save the new configuration in the environment - if (ntf_cfg == PRF_CLI_STOP_NTFIND) - { - CSCPS_DISABLE_NTFIND(conidx, CSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND); - } - else // ntf_cfg == PRF_CLI_START_IND - { - CSCPS_ENABLE_NTFIND(conidx, CSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND); - } - - // Inform the HL about the new configuration - struct cscps_cfg_ntfind_ind *ind = KE_MSG_ALLOC(CSCPS_CFG_NTFIND_IND, - prf_dst_task_get(&cscps_env->prf_env, conidx), - prf_src_task_get(&cscps_env->prf_env, conidx), - cscps_cfg_ntfind_ind); - - ind->char_code = CSCP_CSCS_SC_CTNL_PT_CHAR; - ind->ntf_cfg = ntf_cfg; - - ke_msg_send(ind); - - // Enable Bonded Data - CSCPS_ENABLE_NTFIND(conidx, CSCP_PRF_CFG_PERFORMED_OK); - } - // else status is PRF_ERR_INVALID_PARAM - - // Send the write response to the peer device - struct gattc_write_cfm *cfm = KE_MSG_ALLOC( - GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = status; - ke_msg_send(cfm); - } - // SC Control Point Characteristic - else if (param->handle == (CSCPS_HANDLE(CSCS_IDX_SC_CTNL_PT_VAL))) - { - // Write Response Status - uint8_t wr_status = ATT_ERR_NO_ERROR; - // Indication Status - uint8_t ind_status = CSCP_CTNL_PT_RESP_NOT_SUPP; - - do - { - // Check if sending of indications has been enabled - if (!CSCPS_IS_NTFIND_ENABLED(conidx, CSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND)) - { - // CCC improperly configured - wr_status = CSCP_ERROR_CCC_INVALID_PARAM; - ind_status = CSCP_CTNL_PT_RESP_FAILED; - break; - } - - if (cscps_env->operation >= CSCPS_CTNL_PT_CUMUL_VAL_OP_CODE) - { - // A procedure is already in progress - wr_status = CSCP_ERROR_PROC_IN_PROGRESS; - ind_status = CSCP_CTNL_PT_RESP_FAILED; - break; - } - - if (cscps_env->operation == CSCPS_SEND_CSC_MEAS_OP_CODE) - { - // Keep the message until the end of the current procedure - msg_status = KE_MSG_NO_FREE; - break; - } - - // Allocate a request indication message for the application - struct cscps_sc_ctnl_pt_req_ind *req_ind = KE_MSG_ALLOC(CSCPS_SC_CTNL_PT_REQ_IND, - prf_dst_task_get(&cscps_env->prf_env, conidx), - prf_src_task_get(&cscps_env->prf_env, conidx), - cscps_sc_ctnl_pt_req_ind); - - // Operation Code - req_ind->op_code = param->value[0]; - // Connection index - req_ind->conidx = conidx; - - // Operation Code - switch(param->value[0]) - { - // Set Cumulative value - case (CSCP_CTNL_PT_OP_SET_CUMUL_VAL): - { - // Check if the Wheel Revolution Data feature is supported - if (CSCPS_IS_FEATURE_SUPPORTED(cscps_env->features, CSCP_FEAT_WHEEL_REV_DATA_SUPP)) - { - // The request can be handled - ind_status = CSCP_CTNL_PT_RESP_SUCCESS; - cscps_env->operation = CSCPS_CTNL_PT_CUMUL_VAL_OP_CODE; - - // Cumulative value - req_ind->value.cumul_value = co_read32p(¶m->value[1]); - } - } break; - - // Update sensor location - case (CSCP_CTNL_PT_OP_UPD_LOC): - { - // Check if the Multiple Sensor Location feature is supported - if (CSCPS_IS_FEATURE_SUPPORTED(cscps_env->features, CSCP_FEAT_MULT_SENSOR_LOC_SUPP)) - { - // Check the sensor location value - if (param->value[1] < CSCP_LOC_MAX) - { - // The request can be handled - ind_status = CSCP_CTNL_PT_RESP_SUCCESS; - - cscps_env->operation = CSCPS_CTNL_PT_UPD_LOC_OP_CODE; - - // Sensor Location - req_ind->value.sensor_loc = param->value[1]; - } - else - { - // The request can be handled - ind_status = CSCP_CTNL_PT_RESP_INV_PARAM; - } - } - } break; - - // Request supported sensor locations - case (CSCP_CTNL_PT_OP_REQ_SUPP_LOC): - { - // Check if the Multiple Sensor Location feature is supported - if (CSCPS_IS_FEATURE_SUPPORTED(cscps_env->features, CSCP_FEAT_MULT_SENSOR_LOC_SUPP)) - { - // The request can be handled - ind_status = CSCP_CTNL_PT_RESP_SUCCESS; - - cscps_env->operation = CSCPS_CTNL_PT_SUPP_LOC_OP_CODE; - } - - } break; - - default: - { - // Operation Code is invalid, status is already CSCP_CTNL_PT_RESP_NOT_SUPP - } break; - } - - // If no error raised, inform the application about the request - if (ind_status == CSCP_CTNL_PT_RESP_SUCCESS) - { - // Send the request indication to the application - ke_msg_send(req_ind); - // Go to the Busy status - ke_state_set(dest_id, CSCPS_BUSY); - // Align error code - wr_status = GAP_ERR_NO_ERROR; - } - else - { - // Free the allocated message - ke_msg_free(ke_param2msg(req_ind)); - } - } while (0); - - - // Send the write response to the peer device - struct gattc_write_cfm *cfm = KE_MSG_ALLOC( - GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = wr_status; - ke_msg_send(cfm); - - // If error raised in control point, inform the peer - if ((ind_status != CSCP_CTNL_PT_RESP_SUCCESS) && - (param->handle == (CSCPS_HANDLE(CSCS_IDX_SC_CTNL_PT_VAL)))) - { - cscps_send_rsp_ind(conidx, param->value[0], ind_status); - } - } + do { + // Check if sending of indications has been enabled + if (!CSCPS_IS_NTFIND_ENABLED(conidx, + CSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND)) { + // CCC improperly configured + wr_status = CSCP_ERROR_CCC_INVALID_PARAM; + ind_status = CSCP_CTNL_PT_RESP_FAILED; + break; } - else - { - ASSERT_ERR(0); + + if (cscps_env->operation >= CSCPS_CTNL_PT_CUMUL_VAL_OP_CODE) { + // A procedure is already in progress + wr_status = CSCP_ERROR_PROC_IN_PROGRESS; + ind_status = CSCP_CTNL_PT_RESP_FAILED; + break; } + + if (cscps_env->operation == CSCPS_SEND_CSC_MEAS_OP_CODE) { + // Keep the message until the end of the current procedure + msg_status = KE_MSG_NO_FREE; + break; + } + + // Allocate a request indication message for the application + struct cscps_sc_ctnl_pt_req_ind *req_ind = + KE_MSG_ALLOC(CSCPS_SC_CTNL_PT_REQ_IND, + prf_dst_task_get(&cscps_env->prf_env, conidx), + prf_src_task_get(&cscps_env->prf_env, conidx), + cscps_sc_ctnl_pt_req_ind); + + // Operation Code + req_ind->op_code = param->value[0]; + // Connection index + req_ind->conidx = conidx; + + // Operation Code + switch (param->value[0]) { + // Set Cumulative value + case (CSCP_CTNL_PT_OP_SET_CUMUL_VAL): { + // Check if the Wheel Revolution Data feature is supported + if (CSCPS_IS_FEATURE_SUPPORTED(cscps_env->features, + CSCP_FEAT_WHEEL_REV_DATA_SUPP)) { + // The request can be handled + ind_status = CSCP_CTNL_PT_RESP_SUCCESS; + cscps_env->operation = CSCPS_CTNL_PT_CUMUL_VAL_OP_CODE; + + // Cumulative value + req_ind->value.cumul_value = co_read32p(¶m->value[1]); + } + } break; + + // Update sensor location + case (CSCP_CTNL_PT_OP_UPD_LOC): { + // Check if the Multiple Sensor Location feature is supported + if (CSCPS_IS_FEATURE_SUPPORTED(cscps_env->features, + CSCP_FEAT_MULT_SENSOR_LOC_SUPP)) { + // Check the sensor location value + if (param->value[1] < CSCP_LOC_MAX) { + // The request can be handled + ind_status = CSCP_CTNL_PT_RESP_SUCCESS; + + cscps_env->operation = CSCPS_CTNL_PT_UPD_LOC_OP_CODE; + + // Sensor Location + req_ind->value.sensor_loc = param->value[1]; + } else { + // The request can be handled + ind_status = CSCP_CTNL_PT_RESP_INV_PARAM; + } + } + } break; + + // Request supported sensor locations + case (CSCP_CTNL_PT_OP_REQ_SUPP_LOC): { + // Check if the Multiple Sensor Location feature is supported + if (CSCPS_IS_FEATURE_SUPPORTED(cscps_env->features, + CSCP_FEAT_MULT_SENSOR_LOC_SUPP)) { + // The request can be handled + ind_status = CSCP_CTNL_PT_RESP_SUCCESS; + + cscps_env->operation = CSCPS_CTNL_PT_SUPP_LOC_OP_CODE; + } + + } break; + + default: { + // Operation Code is invalid, status is already + // CSCP_CTNL_PT_RESP_NOT_SUPP + } break; + } + + // If no error raised, inform the application about the request + if (ind_status == CSCP_CTNL_PT_RESP_SUCCESS) { + // Send the request indication to the application + ke_msg_send(req_ind); + // Go to the Busy status + ke_state_set(dest_id, CSCPS_BUSY); + // Align error code + wr_status = GAP_ERR_NO_ERROR; + } else { + // Free the allocated message + ke_msg_free(ke_param2msg(req_ind)); + } + } while (0); + + // Send the write response to the peer device + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = wr_status; + ke_msg_send(cfm); + + // If error raised in control point, inform the peer + if ((ind_status != CSCP_CTNL_PT_RESP_SUCCESS) && + (param->handle == (CSCPS_HANDLE(CSCS_IDX_SC_CTNL_PT_VAL)))) { + cscps_send_rsp_ind(conidx, param->value[0], ind_status); + } } + } else { + ASSERT_ERR(0); + } } - // else drop the message + } + // else drop the message - return (int)msg_status; + return (int)msg_status; } /** **************************************************************************************** - * @brief Handles @ref GATT_NOTIFY_CMP_EVT message meaning that a notification or an indication - * has been correctly sent to peer device (but not confirmed by peer device). + * @brief Handles @ref GATT_NOTIFY_CMP_EVT message meaning that a notification + *or an indication has been correctly sent to peer device (but not confirmed by + *peer device). * * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. @@ -757,45 +702,40 @@ __STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - uint8_t conidx = KE_IDX_GET(src_id); - // Get the address of the environment - struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); +__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t conidx = KE_IDX_GET(src_id); + // Get the address of the environment + struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); - // Check if a connection exists - if (ke_state_get(dest_id) == CSCPS_BUSY) - { - switch (param->operation) - { - case (GATTC_NOTIFY): - { - ASSERT_ERR(cscps_env->operation == CSCPS_SEND_CSC_MEAS_OP_CODE); - // continuer operation execution - cscps_exe_operation(); - } break; + // Check if a connection exists + if (ke_state_get(dest_id) == CSCPS_BUSY) { + switch (param->operation) { + case (GATTC_NOTIFY): { + ASSERT_ERR(cscps_env->operation == CSCPS_SEND_CSC_MEAS_OP_CODE); + // continuer operation execution + cscps_exe_operation(); + } break; - case (GATTC_INDICATE): - { - ASSERT_ERR(cscps_env->operation >= CSCPS_CTNL_PT_CUMUL_VAL_OP_CODE); + case (GATTC_INDICATE): { + ASSERT_ERR(cscps_env->operation >= CSCPS_CTNL_PT_CUMUL_VAL_OP_CODE); - // Inform the application that a procedure has been completed - cscps_send_cmp_evt(conidx, - prf_src_task_get(&cscps_env->prf_env, conidx), - prf_dst_task_get(&cscps_env->prf_env, conidx), - cscps_env->operation, param->status); - // else ignore the message - } break; + // Inform the application that a procedure has been completed + cscps_send_cmp_evt(conidx, prf_src_task_get(&cscps_env->prf_env, conidx), + prf_dst_task_get(&cscps_env->prf_env, conidx), + cscps_env->operation, param->status); + // else ignore the message + } break; - default: - { - ASSERT_ERR(0); - } break; - } + default: { + ASSERT_ERR(0); + } break; } + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /* @@ -804,26 +744,24 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_ev */ /// Specifies the default message handlers -KE_MSG_HANDLER_TAB(cscps) -{ - {CSCPS_ENABLE_REQ, (ke_msg_func_t) cscps_enable_req_handler}, - {GATTC_READ_REQ_IND, (ke_msg_func_t) gattc_read_req_ind_handler}, - {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t) gattc_att_info_req_ind_handler}, - {CSCPS_NTF_CSC_MEAS_REQ, (ke_msg_func_t) cscps_ntf_csc_meas_req_handler}, - {CSCPS_SC_CTNL_PT_CFM, (ke_msg_func_t) cscps_sc_ctnl_pt_cfm_handler}, - {GATTC_WRITE_REQ_IND, (ke_msg_func_t) gattc_write_req_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t) gattc_cmp_evt_handler}, +KE_MSG_HANDLER_TAB(cscps){ + {CSCPS_ENABLE_REQ, (ke_msg_func_t)cscps_enable_req_handler}, + {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, + {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t)gattc_att_info_req_ind_handler}, + {CSCPS_NTF_CSC_MEAS_REQ, (ke_msg_func_t)cscps_ntf_csc_meas_req_handler}, + {CSCPS_SC_CTNL_PT_CFM, (ke_msg_func_t)cscps_sc_ctnl_pt_cfm_handler}, + {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void cscps_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); +void cscps_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct cscps_env_tag *cscps_env = PRF_ENV_GET(CSCPS, cscps); - task_desc->msg_handler_tab = cscps_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(cscps_msg_handler_tab); - task_desc->state = cscps_env->state; - task_desc->idx_max = CSCPS_IDX_MAX; + task_desc->msg_handler_tab = cscps_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(cscps_msg_handler_tab); + task_desc->state = cscps_env->state; + task_desc->idx_max = CSCPS_IDX_MAX; } #endif //(BLE_CSC_SENSOR) diff --git a/services/ble_profiles/datapath/datapathps/src/datapathps.c b/services/ble_profiles/datapath/datapathps/src/datapathps.c index f1a6e40..60f9ea4 100644 --- a/services/ble_profiles/datapath/datapathps/src/datapathps.c +++ b/services/ble_profiles/datapath/datapathps/src/datapathps.c @@ -12,16 +12,16 @@ #include "rwip_config.h" #if (BLE_DATAPATH_SERVER) -#include "gap.h" -#include "gattc_task.h" #include "attm.h" -#include "gapc_task.h" #include "datapathps.h" #include "datapathps_task.h" +#include "gap.h" +#include "gapc_task.h" +#include "gattc_task.h" #include "prf_utils.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * DATAPATH SRVER PROFILE ATTRIBUTES @@ -32,66 +32,108 @@ #if USE_128BIT_UUID -#define datapath_service_uuid_128_content {0x12, 0x34, 0x56, 0x78, 0x90, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01 } -#define datapath_tx_char_val_uuid_128_content {0x12, 0x34, 0x56, 0x78, 0x91, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02 } -#define datapath_rx_char_val_uuid_128_content {0x12, 0x34, 0x56, 0x78, 0x92, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03 } +#define datapath_service_uuid_128_content \ + { \ + 0x12, 0x34, 0x56, 0x78, 0x90, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, \ + 0x00, 0x01, 0x00, 0x01 \ + } +#define datapath_tx_char_val_uuid_128_content \ + { \ + 0x12, 0x34, 0x56, 0x78, 0x91, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, \ + 0x00, 0x02, 0x00, 0x02 \ + } +#define datapath_rx_char_val_uuid_128_content \ + { \ + 0x12, 0x34, 0x56, 0x78, 0x92, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, \ + 0x00, 0x03, 0x00, 0x03 \ + } -#define ATT_DECL_PRIMARY_SERVICE_UUID { 0x00, 0x28 } -#define ATT_DECL_CHARACTERISTIC_UUID { 0x03, 0x28 } -#define ATT_DESC_CLIENT_CHAR_CFG_UUID { 0x02, 0x29 } -#define ATT_DESC_CHAR_USER_DESCRIPTION_UUID { 0x01, 0x29 } +#define ATT_DECL_PRIMARY_SERVICE_UUID \ + { 0x00, 0x28 } +#define ATT_DECL_CHARACTERISTIC_UUID \ + { 0x03, 0x28 } +#define ATT_DESC_CLIENT_CHAR_CFG_UUID \ + { 0x02, 0x29 } +#define ATT_DESC_CHAR_USER_DESCRIPTION_UUID \ + { 0x01, 0x29 } +static const uint8_t DATAPATH_SERVICE_UUID_128[ATT_UUID_128_LEN] = + datapath_service_uuid_128_content; -static const uint8_t DATAPATH_SERVICE_UUID_128[ATT_UUID_128_LEN] = datapath_service_uuid_128_content; - -/// Full DATAPATH SERVER Database Description - Used to add attributes into the database -const struct attm_desc_128 datapathps_att_db[DATAPATHPS_IDX_NB] = -{ +/// Full DATAPATH SERVER Database Description - Used to add attributes into the +/// database +const struct attm_desc_128 datapathps_att_db[DATAPATHPS_IDX_NB] = { // Service Declaration - [DATAPATHPS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE_UUID, PERM(RD, ENABLE), 0, 0}, + [DATAPATHPS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE_UUID, PERM(RD, ENABLE), 0, + 0}, // TX Characteristic Declaration - [DATAPATHPS_IDX_TX_CHAR] = {ATT_DECL_CHARACTERISTIC_UUID, PERM(RD, ENABLE), 0, 0}, + [DATAPATHPS_IDX_TX_CHAR] = {ATT_DECL_CHARACTERISTIC_UUID, PERM(RD, ENABLE), + 0, 0}, // TX Characteristic Value - [DATAPATHPS_IDX_TX_VAL] = {datapath_tx_char_val_uuid_128_content, PERM(NTF, ENABLE) | PERM(RD, ENABLE), PERM(RI, ENABLE) | PERM_VAL(UUID_LEN, PERM_UUID_128), DATAPATHPS_MAX_LEN}, + [DATAPATHPS_IDX_TX_VAL] = {datapath_tx_char_val_uuid_128_content, + PERM(NTF, ENABLE) | PERM(RD, ENABLE), + PERM(RI, ENABLE) | + PERM_VAL(UUID_LEN, PERM_UUID_128), + DATAPATHPS_MAX_LEN}, // TX Characteristic - Client Characteristic Configuration Descriptor - [DATAPATHPS_IDX_TX_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG_UUID, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [DATAPATHPS_IDX_TX_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG_UUID, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + 0, 0}, // TX Characteristic - Characteristic User Description Descriptor - [DATAPATHPS_IDX_TX_DESC] = {ATT_DESC_CHAR_USER_DESCRIPTION_UUID, PERM(RD, ENABLE), PERM(RI, ENABLE), 32}, + [DATAPATHPS_IDX_TX_DESC] = {ATT_DESC_CHAR_USER_DESCRIPTION_UUID, + PERM(RD, ENABLE), PERM(RI, ENABLE), 32}, // RX Characteristic Declaration - [DATAPATHPS_IDX_RX_CHAR] = {ATT_DECL_CHARACTERISTIC_UUID, PERM(RD, ENABLE), 0, 0}, + [DATAPATHPS_IDX_RX_CHAR] = {ATT_DECL_CHARACTERISTIC_UUID, PERM(RD, ENABLE), + 0, 0}, // RX Characteristic Value - [DATAPATHPS_IDX_RX_VAL] = {datapath_rx_char_val_uuid_128_content, PERM(WRITE_REQ, ENABLE) | PERM(WRITE_COMMAND, ENABLE), PERM(RI, ENABLE) | PERM_VAL(UUID_LEN, PERM_UUID_128), DATAPATHPS_MAX_LEN}, + [DATAPATHPS_IDX_RX_VAL] = {datapath_rx_char_val_uuid_128_content, + PERM(WRITE_REQ, ENABLE) | + PERM(WRITE_COMMAND, ENABLE), + PERM(RI, ENABLE) | + PERM_VAL(UUID_LEN, PERM_UUID_128), + DATAPATHPS_MAX_LEN}, // RX Characteristic - Characteristic User Description Descriptor - [DATAPATHPS_IDX_RX_DESC] = {ATT_DESC_CHAR_USER_DESCRIPTION_UUID, PERM(RD, ENABLE), PERM(RI, ENABLE), 32}, + [DATAPATHPS_IDX_RX_DESC] = {ATT_DESC_CHAR_USER_DESCRIPTION_UUID, + PERM(RD, ENABLE), PERM(RI, ENABLE), 32}, }; #else -#define DATAPATHPS_SERVICE_UUID_16BIT 0xFEF8 -#define DATAPATHPS_TX_CHAR_VAL_UUID_16BIT 0xFEF9 -#define DATAPATHPS_RX_CHAR_VAL_UUID_16BIT 0xFEFA +#define DATAPATHPS_SERVICE_UUID_16BIT 0xFEF8 +#define DATAPATHPS_TX_CHAR_VAL_UUID_16BIT 0xFEF9 +#define DATAPATHPS_RX_CHAR_VAL_UUID_16BIT 0xFEFA -const struct attm_desc datapathps_att_db[DATAPATHPS_IDX_NB] = -{ +const struct attm_desc datapathps_att_db[DATAPATHPS_IDX_NB] = { // Service Declaration - [DATAPATHPS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [DATAPATHPS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // TX Characteristic Declaration - [DATAPATHPS_IDX_TX_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [DATAPATHPS_IDX_TX_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // TX Characteristic Value - [DATAPATHPS_IDX_TX_VAL] = {DATAPATHPS_TX_CHAR_VAL_UUID_16BIT, PERM(NTF, ENABLE), PERM(RI, ENABLE), DATAPATHPS_MAX_LEN}, + [DATAPATHPS_IDX_TX_VAL] = {DATAPATHPS_TX_CHAR_VAL_UUID_16BIT, + PERM(NTF, ENABLE), PERM(RI, ENABLE), + DATAPATHPS_MAX_LEN}, // TX Characteristic - Client Characteristic Configuration Descriptor - [DATAPATHPS_IDX_TX_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [DATAPATHPS_IDX_TX_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + 0, 0}, // TX Characteristic - Characteristic User Description Descriptor - [DATAPATHPS_IDX_TX_DESC] = {ATT_DESC_CHAR_USER_DESCRIPTION, PERM(RD, ENABLE), PERM(RI, ENABLE), 32}, + [DATAPATHPS_IDX_TX_DESC] = {ATT_DESC_CHAR_USER_DESCRIPTION, + PERM(RD, ENABLE), PERM(RI, ENABLE), 32}, // RX Characteristic Declaration - [DATAPATHPS_IDX_RX_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [DATAPATHPS_IDX_RX_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // RX Characteristic Value - [DATAPATHPS_IDX_RX_VAL] = {DATAPATHPS_RX_CHAR_VAL_UUID_16BIT, PERM(WRITE_REQ, ENABLE) | PERM(WRITE_COMMAND, ENABLE), PERM(RI, ENABLE), DATAPATHPS_MAX_LEN}, + [DATAPATHPS_IDX_RX_VAL] = {DATAPATHPS_RX_CHAR_VAL_UUID_16BIT, + PERM(WRITE_REQ, ENABLE) | + PERM(WRITE_COMMAND, ENABLE), + PERM(RI, ENABLE), DATAPATHPS_MAX_LEN}, // RX Characteristic - Characteristic User Description Descriptor - [DATAPATHPS_IDX_RX_DESC] = {ATT_DESC_CHAR_USER_DESCRIPTION, PERM(RD, ENABLE), PERM(RI, ENABLE), 32}, + [DATAPATHPS_IDX_RX_DESC] = {ATT_DESC_CHAR_USER_DESCRIPTION, + PERM(RD, ENABLE), PERM(RI, ENABLE), 32}, }; #endif @@ -107,78 +149,87 @@ const struct attm_desc datapathps_att_db[DATAPATHPS_IDX_NB] = * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t datapathps_init(struct prf_task_env* env, uint16_t* start_hdl, - uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t status; +static uint8_t datapathps_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, + void *params) { + uint8_t status; - //Add Service Into Database + // Add Service Into Database #if USE_128BIT_UUID - status = attm_svc_create_db_128(start_hdl, DATAPATH_SERVICE_UUID_128, NULL, - DATAPATHPS_IDX_NB, NULL, env->task, &datapathps_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS))| PERM(SVC_MI, DISABLE) - | PERM_VAL(SVC_UUID_LEN, PERM_UUID_128)); + status = attm_svc_create_db_128( + start_hdl, DATAPATH_SERVICE_UUID_128, NULL, DATAPATHPS_IDX_NB, NULL, + env->task, &datapathps_att_db[0], + (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, DISABLE) | PERM_VAL(SVC_UUID_LEN, PERM_UUID_128)); #else - status = attm_svc_create_db(start_hdl, DATAPATHPS_SERVICE_UUID_16BIT, NULL, - DATAPATHPS_IDX_NB, NULL, env->task, &datapathps_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | PERM(SVC_MI, DISABLE) ); + status = attm_svc_create_db( + start_hdl, DATAPATHPS_SERVICE_UUID_16BIT, NULL, DATAPATHPS_IDX_NB, NULL, + env->task, &datapathps_att_db[0], + (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, DISABLE)); #endif - BLE_GATT_DBG("attm_svc_create_db_128 returns %d start handle is %d", status, *start_hdl); + BLE_GATT_DBG("attm_svc_create_db_128 returns %d start handle is %d", status, + *start_hdl); - //-------------------- allocate memory required for the profile --------------------- - if (status == ATT_ERR_NO_ERROR) - { - // Allocate DATAPATHPS required environment variable - struct datapathps_env_tag* datapathps_env = - (struct datapathps_env_tag* ) ke_malloc(sizeof(struct datapathps_env_tag), KE_MEM_ATT_DB); + //-------------------- allocate memory required for the profile + //--------------------- + if (status == ATT_ERR_NO_ERROR) { + // Allocate DATAPATHPS required environment variable + struct datapathps_env_tag *datapathps_env = + (struct datapathps_env_tag *)ke_malloc( + sizeof(struct datapathps_env_tag), KE_MEM_ATT_DB); - memset((uint8_t *)datapathps_env, 0, sizeof(struct datapathps_env_tag)); - // Initialize DATAPATHPS environment - env->env = (prf_env_t*) datapathps_env; - datapathps_env->shdl = *start_hdl; + memset((uint8_t *)datapathps_env, 0, sizeof(struct datapathps_env_tag)); + // Initialize DATAPATHPS environment + env->env = (prf_env_t *)datapathps_env; + datapathps_env->shdl = *start_hdl; - datapathps_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - // Mono Instantiated task - datapathps_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); + datapathps_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + // Mono Instantiated task + datapathps_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); - // initialize environment variable - env->id = TASK_ID_DATAPATHPS; - datapathps_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_DATAPATHPS; + datapathps_task_init(&(env->desc)); - /* Put HRS in Idle state */ - ke_state_set(env->task, DATAPATHPS_IDLE); - } + /* Put HRS in Idle state */ + ke_state_set(env->task, DATAPATHPS_IDLE); + } - return (status); + return (status); } /** **************************************************************************************** * @brief Destruction of the DATAPATHPS module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void datapathps_destroy(struct prf_task_env* env) -{ - struct datapathps_env_tag* datapathps_env = (struct datapathps_env_tag*) env->env; +static void datapathps_destroy(struct prf_task_env *env) { + struct datapathps_env_tag *datapathps_env = + (struct datapathps_env_tag *)env->env; - // free profile environment variables - env->env = NULL; - ke_free(datapathps_env); + // free profile environment variables + env->env = NULL; + ke_free(datapathps_env); } /** @@ -189,11 +240,12 @@ static void datapathps_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void datapathps_create(struct prf_task_env* env, uint8_t conidx) -{ - struct datapathps_env_tag* datapathps_env = (struct datapathps_env_tag*) env->env; - struct prf_svc datapathps_svc = {datapathps_env->shdl, datapathps_env->shdl + DATAPATHPS_IDX_NB}; - prf_register_atthdl2gatt(env->env, conidx, &datapathps_svc); +static void datapathps_create(struct prf_task_env *env, uint8_t conidx) { + struct datapathps_env_tag *datapathps_env = + (struct datapathps_env_tag *)env->env; + struct prf_svc datapathps_svc = {datapathps_env->shdl, + datapathps_env->shdl + DATAPATHPS_IDX_NB}; + prf_register_atthdl2gatt(env->env, conidx, &datapathps_svc); } /** @@ -205,9 +257,9 @@ static void datapathps_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void datapathps_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - /* Nothing to do */ +static void datapathps_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + /* Nothing to do */ } /* @@ -216,9 +268,8 @@ static void datapathps_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t */ /// DATAPATHPS Task interface required by profile manager -const struct prf_task_cbs datapathps_itf = -{ - (prf_init_fnct) datapathps_init, +const struct prf_task_cbs datapathps_itf = { + (prf_init_fnct)datapathps_init, datapathps_destroy, datapathps_create, datapathps_cleanup, @@ -229,12 +280,10 @@ const struct prf_task_cbs datapathps_itf = **************************************************************************************** */ -const struct prf_task_cbs* datapathps_prf_itf_get(void) -{ - return &datapathps_itf; +const struct prf_task_cbs *datapathps_prf_itf_get(void) { + return &datapathps_itf; } - #endif /* BLE_DATAPATH_SERVER */ /// @} DATAPATHPS diff --git a/services/ble_profiles/datapath/datapathps/src/datapathps_task.c b/services/ble_profiles/datapath/datapathps/src/datapathps_task.c index 608d5d7..0e88ec1 100644 --- a/services/ble_profiles/datapath/datapathps/src/datapathps_task.c +++ b/services/ble_profiles/datapath/datapathps/src/datapathps_task.c @@ -12,37 +12,38 @@ #include "rwip_config.h" #if (BLE_DATAPATH_SERVER) -#include "gap.h" -#include "gattc_task.h" -#include "gapc_task.h" #include "attm.h" #include "datapathps.h" #include "datapathps_task.h" +#include "gap.h" +#include "gapc_task.h" +#include "gattc_task.h" #include "prf_utils.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * LOCAL FUNCTIONS DEFINITIONS **************************************************************************************** */ static int gapc_disconnect_ind_handler(ke_msg_id_t const msgid, - struct gapc_disconnect_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - struct datapathps_env_tag *datapathps_env = PRF_ENV_GET(DATAPATHPS, datapathps); - uint8_t conidx = KE_IDX_GET(src_id); - datapathps_env->isNotificationEnabled[conidx] = false; - return KE_MSG_CONSUMED; + struct gapc_disconnect_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + struct datapathps_env_tag *datapathps_env = + PRF_ENV_GET(DATAPATHPS, datapathps); + uint8_t conidx = KE_IDX_GET(src_id); + datapathps_env->isNotificationEnabled[conidx] = false; + return KE_MSG_CONSUMED; } /** **************************************************************************************** * @brief Handles reception of the @ref GL2C_CODE_ATT_WR_CMD_IND message. - * The handler compares the new values with current ones and notifies them if they changed. + * The handler compares the new values with current ones and notifies them if + *they changed. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -50,86 +51,83 @@ static int gapc_disconnect_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_write_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct datapathps_env_tag *datapathps_env = PRF_ENV_GET(DATAPATHPS, datapathps); - uint8_t conidx = KE_IDX_GET(src_id); +__STATIC int gattc_write_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Get the address of the environment + struct datapathps_env_tag *datapathps_env = + PRF_ENV_GET(DATAPATHPS, datapathps); + uint8_t conidx = KE_IDX_GET(src_id); - uint8_t status = GAP_ERR_NO_ERROR; + uint8_t status = GAP_ERR_NO_ERROR; - BLE_GATT_DBG("gattc_write_req_ind_handler datapathps_env 0x%x write handle %d shdl %d", - datapathps_env, param->handle, datapathps_env->shdl); + BLE_GATT_DBG( + "gattc_write_req_ind_handler datapathps_env 0x%x write handle %d shdl %d", + datapathps_env, param->handle, datapathps_env->shdl); + if (datapathps_env != NULL) { + // TX ccc + if (param->handle == (datapathps_env->shdl + DATAPATHPS_IDX_TX_NTF_CFG)) { + uint16_t value = 0x0000; - if (datapathps_env != NULL) - { - // TX ccc - if (param->handle == (datapathps_env->shdl + DATAPATHPS_IDX_TX_NTF_CFG)) - { - uint16_t value = 0x0000; - - //Extract value before check - memcpy(&value, &(param->value), sizeof(uint16_t)); + // Extract value before check + memcpy(&value, &(param->value), sizeof(uint16_t)); - if (value == PRF_CLI_STOP_NTFIND) { - datapathps_env->isNotificationEnabled[conidx] = false; - } else if (value == PRF_CLI_START_NTF) { - datapathps_env->isNotificationEnabled[conidx] = true; - } else { - status = PRF_APP_ERROR; - } + if (value == PRF_CLI_STOP_NTFIND) { + datapathps_env->isNotificationEnabled[conidx] = false; + } else if (value == PRF_CLI_START_NTF) { + datapathps_env->isNotificationEnabled[conidx] = true; + } else { + status = PRF_APP_ERROR; + } - if (status == GAP_ERR_NO_ERROR) { - //Inform APP of TX ccc change - struct ble_datapath_tx_notif_config_t * ind = KE_MSG_ALLOC(DATAPATHPS_TX_CCC_CHANGED, - prf_dst_task_get(&datapathps_env->prf_env, conidx), - prf_src_task_get(&datapathps_env->prf_env, conidx), - ble_datapath_tx_notif_config_t); + if (status == GAP_ERR_NO_ERROR) { + // Inform APP of TX ccc change + struct ble_datapath_tx_notif_config_t *ind = + KE_MSG_ALLOC(DATAPATHPS_TX_CCC_CHANGED, + prf_dst_task_get(&datapathps_env->prf_env, conidx), + prf_src_task_get(&datapathps_env->prf_env, conidx), + ble_datapath_tx_notif_config_t); - ind->isNotificationEnabled = datapathps_env->isNotificationEnabled[conidx]; + ind->isNotificationEnabled = + datapathps_env->isNotificationEnabled[conidx]; - ke_msg_send(ind); - } - } - // RX data - else if (param->handle == (datapathps_env->shdl + DATAPATHPS_IDX_RX_VAL)) - { - //inform APP of data - struct ble_datapath_rx_data_ind_t * ind = KE_MSG_ALLOC_DYN(DATAPATHPS_RX_DATA_RECEIVED, - prf_dst_task_get(&datapathps_env->prf_env, conidx), - prf_src_task_get(&datapathps_env->prf_env, conidx), - ble_datapath_rx_data_ind_t, - param->length); - - ind->length = param->length; - memcpy((uint8_t *)(ind->data), &(param->value), param->length); - - ke_msg_send(ind); - } - else - { - status = PRF_APP_ERROR; - } + ke_msg_send(ind); + } } + // RX data + else if (param->handle == (datapathps_env->shdl + DATAPATHPS_IDX_RX_VAL)) { + // inform APP of data + struct ble_datapath_rx_data_ind_t *ind = + KE_MSG_ALLOC_DYN(DATAPATHPS_RX_DATA_RECEIVED, + prf_dst_task_get(&datapathps_env->prf_env, conidx), + prf_src_task_get(&datapathps_env->prf_env, conidx), + ble_datapath_rx_data_ind_t, param->length); - //Send write response - struct gattc_write_cfm *cfm = KE_MSG_ALLOC( - GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = status; - ke_msg_send(cfm); + ind->length = param->length; + memcpy((uint8_t *)(ind->data), &(param->value), param->length); - return (KE_MSG_CONSUMED); + ke_msg_send(ind); + } else { + status = PRF_APP_ERROR; + } + } + + // Send write response + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = status; + ke_msg_send(cfm); + + return (KE_MSG_CONSUMED); } /** **************************************************************************************** - * @brief Handles @ref GATTC_CMP_EVT for GATTC_NOTIFY message meaning that Measurement - * notification has been correctly sent to peer device (but not confirmed by peer device). + * @brief Handles @ref GATTC_CMP_EVT for GATTC_NOTIFY message meaning that + *Measurement notification has been correctly sent to peer device (but not + *confirmed by peer device). * * * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. @@ -138,32 +136,34 @@ __STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - // Get the address of the environment - struct datapathps_env_tag *datapathps_env = PRF_ENV_GET(DATAPATHPS, datapathps); +__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct datapathps_env_tag *datapathps_env = + PRF_ENV_GET(DATAPATHPS, datapathps); - uint8_t conidx = KE_IDX_GET(dest_id); - - // notification has been sent out - if ((GATTC_NOTIFY == param->operation) || (GATTC_WRITE_NO_RESPONSE == param->operation)) - { - - struct ble_datapath_tx_sent_ind_t * ind = KE_MSG_ALLOC(DATAPATHPS_TX_DATA_SENT, - prf_dst_task_get(&datapathps_env->prf_env, conidx), - prf_src_task_get(&datapathps_env->prf_env, conidx), - ble_datapath_tx_sent_ind_t); + uint8_t conidx = KE_IDX_GET(dest_id); - ind->status = param->status; + // notification has been sent out + if ((GATTC_NOTIFY == param->operation) || + (GATTC_WRITE_NO_RESPONSE == param->operation)) { - ke_msg_send(ind); + struct ble_datapath_tx_sent_ind_t *ind = + KE_MSG_ALLOC(DATAPATHPS_TX_DATA_SENT, + prf_dst_task_get(&datapathps_env->prf_env, conidx), + prf_src_task_get(&datapathps_env->prf_env, conidx), + ble_datapath_tx_sent_ind_t); - } + ind->status = param->status; - ke_state_set(dest_id, DATAPATHPS_IDLE); - - return (KE_MSG_CONSUMED); + ke_msg_send(ind); + } + + ke_state_set(dest_id, DATAPATHPS_IDLE); + + return (KE_MSG_CONSUMED); } /** @@ -178,205 +178,205 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_ev **************************************************************************************** */ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_read_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct datapathps_env_tag *datapathps_env = PRF_ENV_GET(DATAPATHPS, datapathps); + struct gattc_read_req_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct datapathps_env_tag *datapathps_env = + PRF_ENV_GET(DATAPATHPS, datapathps); - struct gattc_read_cfm* cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, - gattc_read_cfm, BLE_MAXIMUM_CHARACTERISTIC_DESCRIPTION); + struct gattc_read_cfm *cfm = + KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, + BLE_MAXIMUM_CHARACTERISTIC_DESCRIPTION); - uint8_t conidx = KE_IDX_GET(src_id); - uint8_t status = GAP_ERR_NO_ERROR; + uint8_t conidx = KE_IDX_GET(src_id); + uint8_t status = GAP_ERR_NO_ERROR; - BLE_GATT_DBG("gattc_read_req_ind_handler read handle %d shdl %d", param->handle, datapathps_env->shdl); - - if (param->handle == (datapathps_env->shdl + DATAPATHPS_IDX_TX_DESC)) { - cfm->length = sizeof(custom_tx_desc); - memcpy(cfm->value, custom_tx_desc, cfm->length); - } else if (param->handle == (datapathps_env->shdl + DATAPATHPS_IDX_RX_DESC)) { - cfm->length = sizeof(custom_rx_desc); - memcpy(cfm->value, custom_rx_desc, cfm->length); - } else if (param->handle == (datapathps_env->shdl + DATAPATHPS_IDX_TX_NTF_CFG)) { - uint16_t notify_ccc; - if (datapathps_env->isNotificationEnabled[conidx]) { - notify_ccc = 1; - } else { - notify_ccc = 0; - } - cfm->length = sizeof(notify_ccc); - memcpy(cfm->value, (uint8_t *)¬ify_ccc, cfm->length); - } - - else { - cfm->length = 0; - status = ATT_ERR_REQUEST_NOT_SUPPORTED; - } - - cfm->handle = param->handle; - - cfm->status = status; - - ke_msg_send(cfm); - - ke_state_set(dest_id, DATAPATHPS_IDLE); - - return (KE_MSG_CONSUMED); -} - -static void send_notifiction(uint8_t conidx, const uint8_t* ptrData, uint32_t length) -{ - struct datapathps_env_tag *datapathps_env = PRF_ENV_GET(DATAPATHPS, datapathps); + BLE_GATT_DBG("gattc_read_req_ind_handler read handle %d shdl %d", + param->handle, datapathps_env->shdl); + if (param->handle == (datapathps_env->shdl + DATAPATHPS_IDX_TX_DESC)) { + cfm->length = sizeof(custom_tx_desc); + memcpy(cfm->value, custom_tx_desc, cfm->length); + } else if (param->handle == (datapathps_env->shdl + DATAPATHPS_IDX_RX_DESC)) { + cfm->length = sizeof(custom_rx_desc); + memcpy(cfm->value, custom_rx_desc, cfm->length); + } else if (param->handle == + (datapathps_env->shdl + DATAPATHPS_IDX_TX_NTF_CFG)) { + uint16_t notify_ccc; if (datapathps_env->isNotificationEnabled[conidx]) { - // Allocate the GATT notification message - struct gattc_send_evt_cmd *report_ntf = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(&datapathps_env->prf_env, conidx), - gattc_send_evt_cmd, length); - - // Fill in the parameter structure - report_ntf->operation = GATTC_NOTIFY; - report_ntf->handle = datapathps_env->shdl + DATAPATHPS_IDX_TX_VAL; - // pack measured value in database - report_ntf->length = length; - memcpy(report_ntf->value, ptrData, length); - // send notification to peer device - ke_msg_send(report_ntf); + notify_ccc = 1; + } else { + notify_ccc = 0; } + cfm->length = sizeof(notify_ccc); + memcpy(cfm->value, (uint8_t *)¬ify_ccc, cfm->length); + } + + else { + cfm->length = 0; + status = ATT_ERR_REQUEST_NOT_SUPPORTED; + } + + cfm->handle = param->handle; + + cfm->status = status; + + ke_msg_send(cfm); + + ke_state_set(dest_id, DATAPATHPS_IDLE); + + return (KE_MSG_CONSUMED); } -__STATIC int send_data_via_notification_handler(ke_msg_id_t const msgid, - struct ble_datapath_send_data_req_t const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - send_notifiction(param->connecionIndex, param->value, param->length); - return (KE_MSG_CONSUMED); +static void send_notifiction(uint8_t conidx, const uint8_t *ptrData, + uint32_t length) { + struct datapathps_env_tag *datapathps_env = + PRF_ENV_GET(DATAPATHPS, datapathps); + + if (datapathps_env->isNotificationEnabled[conidx]) { + // Allocate the GATT notification message + struct gattc_send_evt_cmd *report_ntf = + KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&datapathps_env->prf_env, conidx), + gattc_send_evt_cmd, length); + + // Fill in the parameter structure + report_ntf->operation = GATTC_NOTIFY; + report_ntf->handle = datapathps_env->shdl + DATAPATHPS_IDX_TX_VAL; + // pack measured value in database + report_ntf->length = length; + memcpy(report_ntf->value, ptrData, length); + // send notification to peer device + ke_msg_send(report_ntf); + } } -static void send_indication(uint8_t conidx, const uint8_t* ptrData, uint32_t length) -{ - struct datapathps_env_tag *datapathps_env = PRF_ENV_GET(DATAPATHPS, datapathps); - - if (datapathps_env->isNotificationEnabled[conidx]) { - // Allocate the GATT notification message - struct gattc_send_evt_cmd *report_ntf = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(&datapathps_env->prf_env, conidx), - gattc_send_evt_cmd, length); - - // Fill in the parameter structure - report_ntf->operation = GATTC_INDICATE; - report_ntf->handle = datapathps_env->shdl + DATAPATHPS_IDX_TX_VAL; - // pack measured value in database - report_ntf->length = length; - memcpy(report_ntf->value, ptrData, length); - // send notification to peer device - ke_msg_send(report_ntf); - } +__STATIC int send_data_via_notification_handler( + ke_msg_id_t const msgid, struct ble_datapath_send_data_req_t const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + send_notifiction(param->connecionIndex, param->value, param->length); + return (KE_MSG_CONSUMED); } -__STATIC int send_data_via_indication_handler(ke_msg_id_t const msgid, - struct ble_datapath_send_data_req_t const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - send_indication(param->connecionIndex, param->value, param->length); - return (KE_MSG_CONSUMED); +static void send_indication(uint8_t conidx, const uint8_t *ptrData, + uint32_t length) { + struct datapathps_env_tag *datapathps_env = + PRF_ENV_GET(DATAPATHPS, datapathps); + + if (datapathps_env->isNotificationEnabled[conidx]) { + // Allocate the GATT notification message + struct gattc_send_evt_cmd *report_ntf = + KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&datapathps_env->prf_env, conidx), + gattc_send_evt_cmd, length); + + // Fill in the parameter structure + report_ntf->operation = GATTC_INDICATE; + report_ntf->handle = datapathps_env->shdl + DATAPATHPS_IDX_TX_VAL; + // pack measured value in database + report_ntf->length = length; + memcpy(report_ntf->value, ptrData, length); + // send notification to peer device + ke_msg_send(report_ntf); + } } -__STATIC int send_data_via_write_command_handler(ke_msg_id_t const msgid, - struct ble_datapath_send_data_req_t const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - struct datapathps_env_tag *datapathps_env = PRF_ENV_GET(DATAPATHPS, datapathps); - - prf_gatt_write(&(datapathps_env->prf_env), KE_IDX_GET(dest_id), datapathps_env->shdl + DATAPATHPS_IDX_RX_VAL, - (uint8_t *)¶m->value, param->length, GATTC_WRITE_NO_RESPONSE); - - ke_state_set(dest_id, DATAPATHPS_BUSY); - return (KE_MSG_CONSUMED); +__STATIC int send_data_via_indication_handler( + ke_msg_id_t const msgid, struct ble_datapath_send_data_req_t const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + send_indication(param->connecionIndex, param->value, param->length); + return (KE_MSG_CONSUMED); } -__STATIC int send_data_via_write_request_handler(ke_msg_id_t const msgid, - struct ble_datapath_send_data_req_t const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - struct datapathps_env_tag *datapathps_env = PRF_ENV_GET(DATAPATHPS, datapathps); +__STATIC int send_data_via_write_command_handler( + ke_msg_id_t const msgid, struct ble_datapath_send_data_req_t const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + struct datapathps_env_tag *datapathps_env = + PRF_ENV_GET(DATAPATHPS, datapathps); - prf_gatt_write(&(datapathps_env->prf_env), KE_IDX_GET(dest_id), datapathps_env->shdl + DATAPATHPS_IDX_RX_VAL, - (uint8_t *)¶m->value, param->length, GATTC_WRITE); + prf_gatt_write(&(datapathps_env->prf_env), KE_IDX_GET(dest_id), + datapathps_env->shdl + DATAPATHPS_IDX_RX_VAL, + (uint8_t *)¶m->value, param->length, + GATTC_WRITE_NO_RESPONSE); - ke_state_set(dest_id, DATAPATHPS_BUSY); - return (KE_MSG_CONSUMED); + ke_state_set(dest_id, DATAPATHPS_BUSY); + return (KE_MSG_CONSUMED); +} + +__STATIC int send_data_via_write_request_handler( + ke_msg_id_t const msgid, struct ble_datapath_send_data_req_t const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + struct datapathps_env_tag *datapathps_env = + PRF_ENV_GET(DATAPATHPS, datapathps); + + prf_gatt_write(&(datapathps_env->prf_env), KE_IDX_GET(dest_id), + datapathps_env->shdl + DATAPATHPS_IDX_RX_VAL, + (uint8_t *)¶m->value, param->length, GATTC_WRITE); + + ke_state_set(dest_id, DATAPATHPS_BUSY); + return (KE_MSG_CONSUMED); } __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, - struct gattc_event_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct datapathps_env_tag *datapathps_env = PRF_ENV_GET(DATAPATHPS, datapathps); + struct gattc_event_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct datapathps_env_tag *datapathps_env = + PRF_ENV_GET(DATAPATHPS, datapathps); - switch(param->type) - { - case GATTC_INDICATE: - { - // confirm that indication has been correctly received - struct gattc_event_cfm * cfm = KE_MSG_ALLOC(GATTC_EVENT_CFM, src_id, dest_id, gattc_event_cfm); - cfm->handle = param->handle; - ke_msg_send(cfm); - } - /* no break */ + switch (param->type) { + case GATTC_INDICATE: { + // confirm that indication has been correctly received + struct gattc_event_cfm *cfm = + KE_MSG_ALLOC(GATTC_EVENT_CFM, src_id, dest_id, gattc_event_cfm); + cfm->handle = param->handle; + ke_msg_send(cfm); + } + /* no break */ - case GATTC_NOTIFY: - { - if (param->handle == datapathps_env->shdl + DATAPATHPS_IDX_TX_VAL) - { - //inform APP of data - struct ble_datapath_rx_data_ind_t * ind = KE_MSG_ALLOC_DYN(DATAPATHPS_NOTIFICATION_RECEIVED, - prf_dst_task_get(&datapathps_env->prf_env, conidx), - prf_src_task_get(&datapathps_env->prf_env, conidx), - ble_datapath_rx_data_ind_t, - param->length); - - ind->length = param->length; - memcpy((uint8_t *)(ind->data), &(param->value), param->length); - - ke_msg_send(ind); + case GATTC_NOTIFY: { + if (param->handle == datapathps_env->shdl + DATAPATHPS_IDX_TX_VAL) { + // inform APP of data + struct ble_datapath_rx_data_ind_t *ind = + KE_MSG_ALLOC_DYN(DATAPATHPS_NOTIFICATION_RECEIVED, + prf_dst_task_get(&datapathps_env->prf_env, conidx), + prf_src_task_get(&datapathps_env->prf_env, conidx), + ble_datapath_rx_data_ind_t, param->length); - } - } break; + ind->length = param->length; + memcpy((uint8_t *)(ind->data), &(param->value), param->length); - default: - break; + ke_msg_send(ind); } + } break; - return (KE_MSG_CONSUMED); + default: + break; + } + + return (KE_MSG_CONSUMED); } -__STATIC int control_notification_handler(ke_msg_id_t const msgid, - struct ble_datapath_control_notification_t const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - struct datapathps_env_tag *datapathps_env = PRF_ENV_GET(DATAPATHPS, datapathps); - uint16_t ccc_write_val = 0; - if (param->isEnable) - { - ccc_write_val = 1; - } +__STATIC int control_notification_handler( + ke_msg_id_t const msgid, + struct ble_datapath_control_notification_t const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + struct datapathps_env_tag *datapathps_env = + PRF_ENV_GET(DATAPATHPS, datapathps); + uint16_t ccc_write_val = 0; + if (param->isEnable) { + ccc_write_val = 1; + } - prf_gatt_write(&(datapathps_env->prf_env), param->connecionIndex, datapathps_env->shdl + DATAPATHPS_IDX_TX_NTF_CFG, - (uint8_t *)&ccc_write_val, sizeof(ccc_write_val), GATTC_WRITE); + prf_gatt_write(&(datapathps_env->prf_env), param->connecionIndex, + datapathps_env->shdl + DATAPATHPS_IDX_TX_NTF_CFG, + (uint8_t *)&ccc_write_val, sizeof(ccc_write_val), GATTC_WRITE); - ke_state_set(dest_id, DATAPATHPS_BUSY); - return (KE_MSG_CONSUMED); + ke_state_set(dest_id, DATAPATHPS_BUSY); + return (KE_MSG_CONSUMED); } /** @@ -391,74 +391,73 @@ __STATIC int control_notification_handler(ke_msg_id_t const msgid, **************************************************************************************** */ static int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_att_info_req_ind *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct gattc_att_info_cfm * cfm; + struct gattc_att_info_req_ind *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct gattc_att_info_cfm *cfm; - //Send write response - cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); - cfm->handle = param->handle; + // Send write response + cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); + cfm->handle = param->handle; - struct datapathps_env_tag *datapathps_env = PRF_ENV_GET(DATAPATHPS, datapathps); - // check if it's a client configuration char - if (param->handle == datapathps_env->shdl + DATAPATHPS_IDX_TX_NTF_CFG) - { - // CCC attribute length = 2 - cfm->length = 2; - cfm->status = GAP_ERR_NO_ERROR; - } - else if (param->handle == datapathps_env->shdl + DATAPATHPS_IDX_RX_VAL) - { - // force length to zero to reject any write starting from something != 0 - cfm->length = 0; - cfm->status = GAP_ERR_NO_ERROR; - } - // not expected request - else - { - cfm->length = 0; - cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; - } - ke_msg_send(cfm); + struct datapathps_env_tag *datapathps_env = + PRF_ENV_GET(DATAPATHPS, datapathps); + // check if it's a client configuration char + if (param->handle == datapathps_env->shdl + DATAPATHPS_IDX_TX_NTF_CFG) { + // CCC attribute length = 2 + cfm->length = 2; + cfm->status = GAP_ERR_NO_ERROR; + } else if (param->handle == datapathps_env->shdl + DATAPATHPS_IDX_RX_VAL) { + // force length to zero to reject any write starting from something != 0 + cfm->length = 0; + cfm->status = GAP_ERR_NO_ERROR; + } + // not expected request + else { + cfm->length = 0; + cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; + } + ke_msg_send(cfm); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } - /* * GLOBAL VARIABLE DEFINITIONS **************************************************************************************** */ /* Default State handlers definition. */ -KE_MSG_HANDLER_TAB(datapathps) -{ - {GAPC_DISCONNECT_IND, (ke_msg_func_t) gapc_disconnect_ind_handler}, - {GATTC_WRITE_REQ_IND, (ke_msg_func_t) gattc_write_req_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t) gattc_cmp_evt_handler}, - {GATTC_READ_REQ_IND, (ke_msg_func_t) gattc_read_req_ind_handler}, - {DATAPATHPS_SEND_DATA_VIA_NOTIFICATION, (ke_msg_func_t) send_data_via_notification_handler}, - {DATAPATHPS_SEND_DATA_VIA_INDICATION, (ke_msg_func_t) send_data_via_indication_handler}, - {DATAPATHPS_SEND_DATA_VIA_WRITE_COMMAND, (ke_msg_func_t) send_data_via_write_command_handler}, - {DATAPATHPS_SEND_DATA_VIA_WRITE_REQUEST, (ke_msg_func_t) send_data_via_write_request_handler}, - {GATTC_EVENT_IND, (ke_msg_func_t) gattc_event_ind_handler}, - {DATAPATHPS_CONTROL_NOTIFICATION, (ke_msg_func_t) control_notification_handler}, - {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t) gattc_att_info_req_ind_handler }, - +KE_MSG_HANDLER_TAB(datapathps){ + {GAPC_DISCONNECT_IND, (ke_msg_func_t)gapc_disconnect_ind_handler}, + {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, + {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, + {DATAPATHPS_SEND_DATA_VIA_NOTIFICATION, + (ke_msg_func_t)send_data_via_notification_handler}, + {DATAPATHPS_SEND_DATA_VIA_INDICATION, + (ke_msg_func_t)send_data_via_indication_handler}, + {DATAPATHPS_SEND_DATA_VIA_WRITE_COMMAND, + (ke_msg_func_t)send_data_via_write_command_handler}, + {DATAPATHPS_SEND_DATA_VIA_WRITE_REQUEST, + (ke_msg_func_t)send_data_via_write_request_handler}, + {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {DATAPATHPS_CONTROL_NOTIFICATION, + (ke_msg_func_t)control_notification_handler}, + {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t)gattc_att_info_req_ind_handler}, + }; -void datapathps_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct datapathps_env_tag *datapathps_env = PRF_ENV_GET(DATAPATHPS, datapathps); +void datapathps_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct datapathps_env_tag *datapathps_env = + PRF_ENV_GET(DATAPATHPS, datapathps); - task_desc->msg_handler_tab = datapathps_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(datapathps_msg_handler_tab); - task_desc->state = &(datapathps_env->state); - task_desc->idx_max = BLE_CONNECTION_MAX; + task_desc->msg_handler_tab = datapathps_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(datapathps_msg_handler_tab); + task_desc->state = &(datapathps_env->state); + task_desc->idx_max = BLE_CONNECTION_MAX; } #endif /* #if (BLE_DATAPATH_SERVER) */ diff --git a/services/ble_profiles/dis/disc/src/disc.c b/services/ble_profiles/dis/disc/src/disc.c index 21ac429..7697d80 100644 --- a/services/ble_profiles/dis/disc/src/disc.c +++ b/services/ble_profiles/dis/disc/src/disc.c @@ -19,7 +19,6 @@ #include "ke_mem.h" - /* * LOCAL FUNCTION DEFINITIONS **************************************************************************************** @@ -36,70 +35,70 @@ * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t disc_init (struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t idx; - //-------------------- allocate memory required for the profile --------------------- +static uint8_t disc_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t idx; + //-------------------- allocate memory required for the profile + //--------------------- - struct disc_env_tag* disc_env = - (struct disc_env_tag* ) ke_malloc(sizeof(struct disc_env_tag), KE_MEM_ATT_DB); + struct disc_env_tag *disc_env = (struct disc_env_tag *)ke_malloc( + sizeof(struct disc_env_tag), KE_MEM_ATT_DB); - // allocate DISC required environment variable - env->env = (prf_env_t*) disc_env; + // allocate DISC required environment variable + env->env = (prf_env_t *)disc_env; - disc_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - disc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + disc_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + disc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_DISC; - disc_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_DISC; + disc_task_init(&(env->desc)); - for(idx = 0; idx < DISC_IDX_MAX ; idx++) - { - disc_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), DISC_FREE); - } + for (idx = 0; idx < DISC_IDX_MAX; idx++) { + disc_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), DISC_FREE); + } - - return GAP_ERR_NO_ERROR; + return GAP_ERR_NO_ERROR; } /** **************************************************************************************** * @brief Destruction of the DISC module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void disc_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct disc_env_tag* disc_env = (struct disc_env_tag*) env->env; +static void disc_destroy(struct prf_task_env *env) { + uint8_t idx; + struct disc_env_tag *disc_env = (struct disc_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < DISC_IDX_MAX ; idx++) - { - if(disc_env->env[idx] != NULL) - { - ke_free(disc_env->env[idx]); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < DISC_IDX_MAX; idx++) { + if (disc_env->env[idx] != NULL) { + ke_free(disc_env->env[idx]); } + } - // free profile environment variables - env->env = NULL; - ke_free(disc_env); + // free profile environment variables + env->env = NULL; + ke_free(disc_env); } /** @@ -110,10 +109,9 @@ static void disc_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void disc_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Put DIS Client in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), DISC_IDLE); +static void disc_create(struct prf_task_env *env, uint8_t conidx) { + /* Put DIS Client in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), DISC_IDLE); } /** @@ -125,19 +123,18 @@ static void disc_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void disc_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct disc_env_tag* disc_env = (struct disc_env_tag*) env->env; +static void disc_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct disc_env_tag *disc_env = (struct disc_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(disc_env->env[conidx] != NULL) - { - ke_free(disc_env->env[conidx]); - disc_env->env[conidx] = NULL; - } + // clean-up environment variable allocated for task instance + if (disc_env->env[conidx] != NULL) { + ke_free(disc_env->env[conidx]); + disc_env->env[conidx] = NULL; + } - /* Put DIS Client in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), DISC_FREE); + /* Put DIS Client in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), DISC_FREE); } /* @@ -146,53 +143,43 @@ static void disc_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reaso */ /// DISC Task interface required by profile manager -const struct prf_task_cbs disc_itf = -{ - disc_init, - disc_destroy, - disc_create, - disc_cleanup, +const struct prf_task_cbs disc_itf = { + disc_init, + disc_destroy, + disc_create, + disc_cleanup, }; - /* * FUNCTION DEFINITIONS **************************************************************************************** */ -const struct prf_task_cbs* disc_prf_itf_get(void) -{ - return &disc_itf; +const struct prf_task_cbs *disc_prf_itf_get(void) { return &disc_itf; } + +void disc_enable_rsp_send(struct disc_env_tag *disc_env, uint8_t conidx, + uint8_t status) { + // Send APP the details of the discovered attributes on DISC + struct disc_enable_rsp *rsp = KE_MSG_ALLOC( + DISC_ENABLE_RSP, prf_dst_task_get(&(disc_env->prf_env), conidx), + prf_src_task_get(&(disc_env->prf_env), conidx), disc_enable_rsp); + + rsp->status = status; + + if (status == GAP_ERR_NO_ERROR) { + rsp->dis = disc_env->env[conidx]->dis; + + // Go to connected state + ke_state_set(prf_src_task_get(&(disc_env->prf_env), conidx), DISC_IDLE); + } else { + // clean-up environment variable allocated for task instance + ke_free(disc_env->env[conidx]); + disc_env->env[conidx] = NULL; + } + + ke_msg_send(rsp); } - -void disc_enable_rsp_send(struct disc_env_tag *disc_env, uint8_t conidx, uint8_t status) -{ - // Send APP the details of the discovered attributes on DISC - struct disc_enable_rsp * rsp = KE_MSG_ALLOC(DISC_ENABLE_RSP, - prf_dst_task_get(&(disc_env->prf_env), conidx), - prf_src_task_get(&(disc_env->prf_env), conidx), - disc_enable_rsp); - - rsp->status = status; - - if (status == GAP_ERR_NO_ERROR) - { - rsp->dis = disc_env->env[conidx]->dis; - - // Go to connected state - ke_state_set(prf_src_task_get(&(disc_env->prf_env), conidx), DISC_IDLE); - } - else - { - // clean-up environment variable allocated for task instance - ke_free(disc_env->env[conidx]); - disc_env->env[conidx] = NULL; - } - - ke_msg_send(rsp); -} - -#endif //BLE_DIS_CLIENT +#endif // BLE_DIS_CLIENT /// @} DISC diff --git a/services/ble_profiles/dis/disc/src/disc_task.c b/services/ble_profiles/dis/disc/src/disc_task.c index 585a1b3..d61b624 100644 --- a/services/ble_profiles/dis/disc/src/disc_task.c +++ b/services/ble_profiles/dis/disc/src/disc_task.c @@ -13,35 +13,39 @@ #if (BLE_DIS_CLIENT) #include "co_utils.h" -#include "gap.h" -#include "disc_task.h" #include "disc.h" +#include "disc_task.h" +#include "gap.h" #include "gattc_task.h" #include "ke_mem.h" - -/// State machine used to retrieve Device Information Service characteristics information -const struct prf_char_def disc_dis_char[DISC_CHAR_MAX] = -{ +/// State machine used to retrieve Device Information Service characteristics +/// information +const struct prf_char_def disc_dis_char[DISC_CHAR_MAX] = { /// Manufacturer Name - [DISC_MANUFACTURER_NAME_CHAR] = {ATT_CHAR_MANUF_NAME, ATT_OPTIONAL, ATT_CHAR_PROP_RD}, + [DISC_MANUFACTURER_NAME_CHAR] = {ATT_CHAR_MANUF_NAME, ATT_OPTIONAL, + ATT_CHAR_PROP_RD}, /// Model Number String - [DISC_MODEL_NB_STR_CHAR] = {ATT_CHAR_MODEL_NB, ATT_OPTIONAL, ATT_CHAR_PROP_RD}, + [DISC_MODEL_NB_STR_CHAR] = {ATT_CHAR_MODEL_NB, ATT_OPTIONAL, + ATT_CHAR_PROP_RD}, /// Serial Number String - [DISC_SERIAL_NB_STR_CHAR] = {ATT_CHAR_SERIAL_NB, ATT_OPTIONAL, ATT_CHAR_PROP_RD}, + [DISC_SERIAL_NB_STR_CHAR] = {ATT_CHAR_SERIAL_NB, ATT_OPTIONAL, + ATT_CHAR_PROP_RD}, /// Hardware Revision String - [DISC_HARD_REV_STR_CHAR] = {ATT_CHAR_HW_REV, ATT_OPTIONAL, ATT_CHAR_PROP_RD}, + [DISC_HARD_REV_STR_CHAR] = {ATT_CHAR_HW_REV, ATT_OPTIONAL, + ATT_CHAR_PROP_RD}, /// Firmware Revision String - [DISC_FIRM_REV_STR_CHAR] = {ATT_CHAR_FW_REV, ATT_OPTIONAL, ATT_CHAR_PROP_RD}, + [DISC_FIRM_REV_STR_CHAR] = {ATT_CHAR_FW_REV, ATT_OPTIONAL, + ATT_CHAR_PROP_RD}, /// TSoftware Revision String - [DISC_SW_REV_STR_CHAR] = {ATT_CHAR_SW_REV, ATT_OPTIONAL, ATT_CHAR_PROP_RD}, + [DISC_SW_REV_STR_CHAR] = {ATT_CHAR_SW_REV, ATT_OPTIONAL, ATT_CHAR_PROP_RD}, /// System ID - [DISC_SYSTEM_ID_CHAR] = {ATT_CHAR_SYS_ID, ATT_OPTIONAL, ATT_CHAR_PROP_RD}, + [DISC_SYSTEM_ID_CHAR] = {ATT_CHAR_SYS_ID, ATT_OPTIONAL, ATT_CHAR_PROP_RD}, /// IEEE - [DISC_IEEE_CHAR] = {ATT_CHAR_IEEE_CERTIF, ATT_OPTIONAL, ATT_CHAR_PROP_RD}, + [DISC_IEEE_CHAR] = {ATT_CHAR_IEEE_CERTIF, ATT_OPTIONAL, ATT_CHAR_PROP_RD}, /// PnP ID - [DISC_PNP_ID_CHAR] = {ATT_CHAR_PNP_ID, ATT_OPTIONAL, ATT_CHAR_PROP_RD}, + [DISC_PNP_ID_CHAR] = {ATT_CHAR_PNP_ID, ATT_OPTIONAL, ATT_CHAR_PROP_RD}, }; /* @@ -61,56 +65,49 @@ const struct prf_char_def disc_dis_char[DISC_CHAR_MAX] = **************************************************************************************** */ __STATIC int disc_enable_req_handler(ke_msg_id_t const msgid, - struct disc_enable_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; + struct disc_enable_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; - uint8_t state = ke_state_get(dest_id); - uint8_t conidx = KE_IDX_GET(dest_id); - // Device Information Service Client Role Task Environment - struct disc_env_tag *disc_env = PRF_ENV_GET(DISC, disc); + uint8_t state = ke_state_get(dest_id); + uint8_t conidx = KE_IDX_GET(dest_id); + // Device Information Service Client Role Task Environment + struct disc_env_tag *disc_env = PRF_ENV_GET(DISC, disc); + ASSERT_INFO(disc_env != NULL, dest_id, src_id); + if ((state == DISC_IDLE) && (disc_env->env[conidx] == NULL)) { + // allocate environment variable for task instance + disc_env->env[conidx] = (struct disc_cnx_env *)ke_malloc( + sizeof(struct disc_cnx_env), KE_MEM_ATT_DB); + memset(disc_env->env[conidx], 0, sizeof(struct disc_cnx_env)); - ASSERT_INFO(disc_env != NULL, dest_id, src_id); - if((state == DISC_IDLE) && (disc_env->env[conidx] == NULL)) - { - // allocate environment variable for task instance - disc_env->env[conidx] = (struct disc_cnx_env*) ke_malloc(sizeof(struct disc_cnx_env),KE_MEM_ATT_DB); - memset(disc_env->env[conidx], 0, sizeof(struct disc_cnx_env)); + // Config connection, start discovering + if (param->con_type == PRF_CON_DISCOVERY) { + // start discovering HTS on peer + prf_disc_svc_send(&(disc_env->prf_env), conidx, ATT_SVC_DEVICE_INFO); - //Config connection, start discovering - if(param->con_type == PRF_CON_DISCOVERY) - { - //start discovering HTS on peer - prf_disc_svc_send(&(disc_env->prf_env), conidx, ATT_SVC_DEVICE_INFO); - - // Go to DISCOVERING state - ke_state_set(dest_id, DISC_DISCOVERING); - } - //normal connection, get saved att details - else - { - disc_env->env[conidx]->dis = param->dis; - - //send APP confirmation that can start normal connection to TH - disc_enable_rsp_send(disc_env, conidx, GAP_ERR_NO_ERROR); - } - } - else if(state != DISC_FREE) - { - status = PRF_ERR_REQ_DISALLOWED; + // Go to DISCOVERING state + ke_state_set(dest_id, DISC_DISCOVERING); } + // normal connection, get saved att details + else { + disc_env->env[conidx]->dis = param->dis; - // send an error if request fails - if(status != GAP_ERR_NO_ERROR) - { - disc_enable_rsp_send(disc_env, conidx, status); + // send APP confirmation that can start normal connection to TH + disc_enable_rsp_send(disc_env, conidx, GAP_ERR_NO_ERROR); } + } else if (state != DISC_FREE) { + status = PRF_ERR_REQ_DISALLOWED; + } - return (KE_MSG_CONSUMED); + // send an error if request fails + if (status != GAP_ERR_NO_ERROR) { + disc_enable_rsp_send(disc_env, conidx, status); + } + + return (KE_MSG_CONSUMED); } /** @@ -125,36 +122,34 @@ __STATIC int disc_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, - struct gattc_sdp_svc_ind const *ind, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_sdp_svc_ind const *ind, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == DISC_DISCOVERING) - { - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct disc_env_tag *disc_env = PRF_ENV_GET(DISC, disc); + if (state == DISC_DISCOVERING) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct disc_env_tag *disc_env = PRF_ENV_GET(DISC, disc); - ASSERT_INFO(disc_env != NULL, dest_id, src_id); - ASSERT_INFO(disc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(disc_env != NULL, dest_id, src_id); + ASSERT_INFO(disc_env->env[conidx] != NULL, dest_id, src_id); - if(disc_env->env[conidx]->nb_svc == 0) - { - // Retrieve DIS characteristics - prf_extract_svc_info(ind, DISC_CHAR_MAX, &disc_dis_char[0], &(disc_env->env[conidx]->dis.chars[0]), - 0, NULL, NULL); + if (disc_env->env[conidx]->nb_svc == 0) { + // Retrieve DIS characteristics + prf_extract_svc_info(ind, DISC_CHAR_MAX, &disc_dis_char[0], + &(disc_env->env[conidx]->dis.chars[0]), 0, NULL, + NULL); - //Even if we get multiple responses we only store 1 range - disc_env->env[conidx]->dis.svc.shdl = ind->start_hdl; - disc_env->env[conidx]->dis.svc.ehdl = ind->end_hdl; - } - - disc_env->env[conidx]->nb_svc++; + // Even if we get multiple responses we only store 1 range + disc_env->env[conidx]->dis.svc.shdl = ind->start_hdl; + disc_env->env[conidx]->dis.svc.ehdl = ind->end_hdl; } - return (KE_MSG_CONSUMED); + disc_env->env[conidx]->nb_svc++; + } + + return (KE_MSG_CONSUMED); } /** **************************************************************************************** @@ -168,61 +163,52 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, - struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - // Get the address of the environment - struct disc_env_tag *disc_env = PRF_ENV_GET(DISC, disc); - uint8_t conidx = KE_IDX_GET(dest_id); + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + // Get the address of the environment + struct disc_env_tag *disc_env = PRF_ENV_GET(DISC, disc); + uint8_t conidx = KE_IDX_GET(dest_id); + if (state == DISC_DISCOVERING) { + uint8_t status = param->status; - if(state == DISC_DISCOVERING) - { - uint8_t status = param->status; - - if (param->status == ATT_ERR_NO_ERROR) - { - if(disc_env->env[conidx]->nb_svc == 1) - { - status = prf_check_svc_char_validity(DISC_CHAR_MAX, disc_env->env[conidx]->dis.chars, - disc_dis_char); - } - // too much services - else if (disc_env->env[conidx]->nb_svc > 1) - { - status = PRF_ERR_MULTIPLE_SVC; - } - // no services found - else - { - status = PRF_ERR_STOP_DISC_CHAR_MISSING; - } - } - - disc_enable_rsp_send(disc_env, conidx, status); - } - else if (state == DISC_BUSY) - { - // an error occurs while performing read request - if((param->operation == GATTC_READ) && (param->status != GAP_ERR_NO_ERROR)) - { - prf_client_att_info_rsp(&(disc_env->prf_env), conidx, DISC_RD_CHAR_RSP, - param->status, NULL); - } - - ke_state_set(dest_id, DISC_IDLE); + if (param->status == ATT_ERR_NO_ERROR) { + if (disc_env->env[conidx]->nb_svc == 1) { + status = prf_check_svc_char_validity( + DISC_CHAR_MAX, disc_env->env[conidx]->dis.chars, disc_dis_char); + } + // too much services + else if (disc_env->env[conidx]->nb_svc > 1) { + status = PRF_ERR_MULTIPLE_SVC; + } + // no services found + else { + status = PRF_ERR_STOP_DISC_CHAR_MISSING; + } } - return (KE_MSG_CONSUMED); + disc_enable_rsp_send(disc_env, conidx, status); + } else if (state == DISC_BUSY) { + // an error occurs while performing read request + if ((param->operation == GATTC_READ) && + (param->status != GAP_ERR_NO_ERROR)) { + prf_client_att_info_rsp(&(disc_env->prf_env), conidx, DISC_RD_CHAR_RSP, + param->status, NULL); + } + + ke_state_set(dest_id, DISC_IDLE); + } + + return (KE_MSG_CONSUMED); } /** **************************************************************************************** * @brief Handles reception of the @ref HTPC_RD_DATETIME_REQ message. - * Check if the handle exists in profile(already discovered) and send request, otherwise - * error to APP. + * Check if the handle exists in profile(already discovered) and send request, + *otherwise error to APP. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -231,60 +217,52 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int disc_rd_char_req_handler(ke_msg_id_t const msgid, - struct disc_rd_char_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; + struct disc_rd_char_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; - uint8_t state = ke_state_get(dest_id); - uint8_t conidx = KE_IDX_GET(dest_id); - // Device Information Service Client Role Task Environment - struct disc_env_tag *disc_env = PRF_ENV_GET(DISC, disc); + uint8_t state = ke_state_get(dest_id); + uint8_t conidx = KE_IDX_GET(dest_id); + // Device Information Service Client Role Task Environment + struct disc_env_tag *disc_env = PRF_ENV_GET(DISC, disc); - ASSERT_INFO(disc_env != NULL, dest_id, src_id); - if((state == DISC_IDLE) && (disc_env->env[conidx] != NULL)) - { - uint16_t search_hdl = ATT_INVALID_HDL; + ASSERT_INFO(disc_env != NULL, dest_id, src_id); + if ((state == DISC_IDLE) && (disc_env->env[conidx] != NULL)) { + uint16_t search_hdl = ATT_INVALID_HDL; - // retrieve search handle - if (param->char_code < DISC_CHAR_MAX) - { - search_hdl = disc_env->env[conidx]->dis.chars[param->char_code].val_hdl; - } - - //Check if handle is viable - if (search_hdl != ATT_INVALID_HDL) - { - // perform read request - disc_env->env[conidx]->last_char_code = param->char_code; - prf_read_char_send(&(disc_env->prf_env), conidx, disc_env->env[conidx]->dis.svc.shdl, - disc_env->env[conidx]->dis.svc.ehdl, search_hdl); - - // enter in a busy state - ke_state_set(dest_id, DISC_BUSY); - } - else - { - // invalid handle requested - status = PRF_ERR_INEXISTENT_HDL; - } - } - else if(state != DISC_FREE) - { - // request cannot be performed - status = PRF_ERR_REQ_DISALLOWED; + // retrieve search handle + if (param->char_code < DISC_CHAR_MAX) { + search_hdl = disc_env->env[conidx]->dis.chars[param->char_code].val_hdl; } - // send error response if request fails - if(status != GAP_ERR_NO_ERROR) - { - prf_client_att_info_rsp(&(disc_env->prf_env), conidx, DISC_RD_CHAR_RSP, - status, NULL); - } + // Check if handle is viable + if (search_hdl != ATT_INVALID_HDL) { + // perform read request + disc_env->env[conidx]->last_char_code = param->char_code; + prf_read_char_send(&(disc_env->prf_env), conidx, + disc_env->env[conidx]->dis.svc.shdl, + disc_env->env[conidx]->dis.svc.ehdl, search_hdl); - return (KE_MSG_CONSUMED); + // enter in a busy state + ke_state_set(dest_id, DISC_BUSY); + } else { + // invalid handle requested + status = PRF_ERR_INEXISTENT_HDL; + } + } else if (state != DISC_FREE) { + // request cannot be performed + status = PRF_ERR_REQ_DISALLOWED; + } + + // send error response if request fails + if (status != GAP_ERR_NO_ERROR) { + prf_client_att_info_rsp(&(disc_env->prf_env), conidx, DISC_RD_CHAR_RSP, + status, NULL); + } + + return (KE_MSG_CONSUMED); } /** @@ -299,47 +277,43 @@ __STATIC int disc_rd_char_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, - struct gattc_read_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_read_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == DISC_BUSY) - { - // Get the address of the environment - struct disc_env_tag *disc_env = PRF_ENV_GET(DISC, disc); - - ASSERT_INFO(disc_env != NULL, dest_id, src_id); - ASSERT_INFO(disc_env->env[KE_IDX_GET(dest_id)] != NULL, dest_id, src_id); - prf_client_att_info_rsp(&(disc_env->prf_env), KE_IDX_GET(dest_id), DISC_RD_CHAR_RSP, - GAP_ERR_NO_ERROR, param); - } - - return (KE_MSG_CONSUMED); -} - -/// Default State handlers definition -KE_MSG_HANDLER_TAB(disc) -{ - {DISC_RD_CHAR_REQ, (ke_msg_func_t)disc_rd_char_req_handler}, - {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, - {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, - {DISC_ENABLE_REQ, (ke_msg_func_t)disc_enable_req_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, -}; - -void disc_task_init(struct ke_task_desc *task_desc) -{ + if (state == DISC_BUSY) { // Get the address of the environment struct disc_env_tag *disc_env = PRF_ENV_GET(DISC, disc); - task_desc->msg_handler_tab = disc_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(disc_msg_handler_tab); - task_desc->state = disc_env->state; - task_desc->idx_max = DISC_IDX_MAX; + ASSERT_INFO(disc_env != NULL, dest_id, src_id); + ASSERT_INFO(disc_env->env[KE_IDX_GET(dest_id)] != NULL, dest_id, src_id); + prf_client_att_info_rsp(&(disc_env->prf_env), KE_IDX_GET(dest_id), + DISC_RD_CHAR_RSP, GAP_ERR_NO_ERROR, param); + } + + return (KE_MSG_CONSUMED); } -#endif //BLE_DIS_CLIENT +/// Default State handlers definition +KE_MSG_HANDLER_TAB(disc){ + {DISC_RD_CHAR_REQ, (ke_msg_func_t)disc_rd_char_req_handler}, + {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, + {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, + {DISC_ENABLE_REQ, (ke_msg_func_t)disc_enable_req_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, +}; + +void disc_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct disc_env_tag *disc_env = PRF_ENV_GET(DISC, disc); + + task_desc->msg_handler_tab = disc_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(disc_msg_handler_tab); + task_desc->state = disc_env->state; + task_desc->idx_max = DISC_IDX_MAX; +} + +#endif // BLE_DIS_CLIENT /// @} DISCTASK diff --git a/services/ble_profiles/dis/diss/src/diss.c b/services/ble_profiles/dis/diss/src/diss.c index c16808b..961d1fa 100644 --- a/services/ble_profiles/dis/diss/src/diss.c +++ b/services/ble_profiles/dis/diss/src/diss.c @@ -15,8 +15,8 @@ #include "attm.h" #include "diss.h" #include "diss_task.h" -#include "prf_utils.h" #include "prf.h" +#include "prf_utils.h" #include "ke_mem.h" @@ -26,14 +26,13 @@ */ /// Maximal length for Characteristic values - 128 bytes -#define DIS_VAL_MAX_LEN (128) -///System ID string length -#define DIS_SYS_ID_LEN (0x08) -///IEEE Certif length (min 6 bytes) -#define DIS_IEEE_CERTIF_MIN_LEN (0x06) -///PnP ID length -#define DIS_PNP_ID_LEN (0x07) - +#define DIS_VAL_MAX_LEN (128) +/// System ID string length +#define DIS_SYS_ID_LEN (0x08) +/// IEEE Certif length (min 6 bytes) +#define DIS_IEEE_CERTIF_MIN_LEN (0x06) +/// PnP ID length +#define DIS_PNP_ID_LEN (0x07) /* * DIS ATTRIBUTES @@ -41,59 +40,73 @@ */ /// Full DIS Database Description - Used to add attributes into the database -const struct attm_desc diss_att_db[DIS_IDX_NB] = -{ +const struct attm_desc diss_att_db[DIS_IDX_NB] = { // Device Information Service Declaration - [DIS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [DIS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // Manufacturer Name Characteristic Declaration - [DIS_IDX_MANUFACTURER_NAME_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [DIS_IDX_MANUFACTURER_NAME_CHAR] = {ATT_DECL_CHARACTERISTIC, + PERM(RD, ENABLE), 0, 0}, // Manufacturer Name Characteristic Value - [DIS_IDX_MANUFACTURER_NAME_VAL] = {ATT_CHAR_MANUF_NAME, PERM(RD, ENABLE), PERM(RI, ENABLE), DIS_VAL_MAX_LEN}, + [DIS_IDX_MANUFACTURER_NAME_VAL] = {ATT_CHAR_MANUF_NAME, PERM(RD, ENABLE), + PERM(RI, ENABLE), DIS_VAL_MAX_LEN}, // Model Number String Characteristic Declaration - [DIS_IDX_MODEL_NB_STR_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [DIS_IDX_MODEL_NB_STR_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Model Number String Characteristic Value - [DIS_IDX_MODEL_NB_STR_VAL] = {ATT_CHAR_MODEL_NB, PERM(RD, ENABLE), PERM(RI, ENABLE), DIS_VAL_MAX_LEN}, + [DIS_IDX_MODEL_NB_STR_VAL] = {ATT_CHAR_MODEL_NB, PERM(RD, ENABLE), + PERM(RI, ENABLE), DIS_VAL_MAX_LEN}, // Serial Number String Characteristic Declaration - [DIS_IDX_SERIAL_NB_STR_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [DIS_IDX_SERIAL_NB_STR_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), + 0, 0}, // Serial Number String Characteristic Value - [DIS_IDX_SERIAL_NB_STR_VAL] = {ATT_CHAR_SERIAL_NB, PERM(RD, ENABLE), PERM(RI, ENABLE), DIS_VAL_MAX_LEN}, + [DIS_IDX_SERIAL_NB_STR_VAL] = {ATT_CHAR_SERIAL_NB, PERM(RD, ENABLE), + PERM(RI, ENABLE), DIS_VAL_MAX_LEN}, // Hardware Revision String Characteristic Declaration - [DIS_IDX_HARD_REV_STR_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [DIS_IDX_HARD_REV_STR_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Hardware Revision String Characteristic Value - [DIS_IDX_HARD_REV_STR_VAL] = {ATT_CHAR_HW_REV, PERM(RD, ENABLE), PERM(RI, ENABLE), DIS_VAL_MAX_LEN}, + [DIS_IDX_HARD_REV_STR_VAL] = {ATT_CHAR_HW_REV, PERM(RD, ENABLE), + PERM(RI, ENABLE), DIS_VAL_MAX_LEN}, // Firmware Revision String Characteristic Declaration - [DIS_IDX_FIRM_REV_STR_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [DIS_IDX_FIRM_REV_STR_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Firmware Revision String Characteristic Value - [DIS_IDX_FIRM_REV_STR_VAL] = {ATT_CHAR_FW_REV, PERM(RD, ENABLE), PERM(RI, ENABLE), DIS_VAL_MAX_LEN}, + [DIS_IDX_FIRM_REV_STR_VAL] = {ATT_CHAR_FW_REV, PERM(RD, ENABLE), + PERM(RI, ENABLE), DIS_VAL_MAX_LEN}, // Software Revision String Characteristic Declaration - [DIS_IDX_SW_REV_STR_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [DIS_IDX_SW_REV_STR_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Software Revision String Characteristic Value - [DIS_IDX_SW_REV_STR_VAL] = {ATT_CHAR_SW_REV, PERM(RD, ENABLE), PERM(RI, ENABLE), DIS_VAL_MAX_LEN}, + [DIS_IDX_SW_REV_STR_VAL] = {ATT_CHAR_SW_REV, PERM(RD, ENABLE), + PERM(RI, ENABLE), DIS_VAL_MAX_LEN}, // System ID Characteristic Declaration - [DIS_IDX_SYSTEM_ID_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [DIS_IDX_SYSTEM_ID_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // System ID Characteristic Value - [DIS_IDX_SYSTEM_ID_VAL] = {ATT_CHAR_SYS_ID, PERM(RD, ENABLE), PERM(RI, ENABLE), DIS_SYS_ID_LEN}, + [DIS_IDX_SYSTEM_ID_VAL] = {ATT_CHAR_SYS_ID, PERM(RD, ENABLE), + PERM(RI, ENABLE), DIS_SYS_ID_LEN}, - // IEEE 11073-20601 Regulatory Certification Data List Characteristic Declaration - [DIS_IDX_IEEE_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + // IEEE 11073-20601 Regulatory Certification Data List Characteristic + // Declaration + [DIS_IDX_IEEE_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, // IEEE 11073-20601 Regulatory Certification Data List Characteristic Value - [DIS_IDX_IEEE_VAL] = {ATT_CHAR_IEEE_CERTIF, PERM(RD, ENABLE), PERM(RI, ENABLE), DIS_SYS_ID_LEN}, + [DIS_IDX_IEEE_VAL] = {ATT_CHAR_IEEE_CERTIF, PERM(RD, ENABLE), + PERM(RI, ENABLE), DIS_SYS_ID_LEN}, // PnP ID Characteristic Declaration - [DIS_IDX_PNP_ID_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [DIS_IDX_PNP_ID_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, // PnP ID Characteristic Value - [DIS_IDX_PNP_ID_VAL] = {ATT_CHAR_PNP_ID, PERM(RD, ENABLE), PERM(RI, ENABLE), DIS_PNP_ID_LEN}, + [DIS_IDX_PNP_ID_VAL] = {ATT_CHAR_PNP_ID, PERM(RD, ENABLE), PERM(RI, ENABLE), + DIS_PNP_ID_LEN}, }; - - /* * LOCAL FUNCTION DEFINITIONS **************************************************************************************** @@ -111,78 +124,83 @@ const struct attm_desc diss_att_db[DIS_IDX_NB] = * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t diss_init (struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, struct diss_db_cfg* params) -{ - //------------------ create the attribute database for the profile ------------------- +static uint8_t diss_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, + struct diss_db_cfg *params) { + //------------------ create the attribute database for the profile + //------------------- - // Service content flag - uint32_t cfg_flag; - // DB Creation Statis - uint8_t status = ATT_ERR_NO_ERROR; + // Service content flag + uint32_t cfg_flag; + // DB Creation Statis + uint8_t status = ATT_ERR_NO_ERROR; - // Compute Attribute Table and save it in environment - cfg_flag = diss_compute_cfg_flag(params->features); + // Compute Attribute Table and save it in environment + cfg_flag = diss_compute_cfg_flag(params->features); - status = attm_svc_create_db(start_hdl, ATT_SVC_DEVICE_INFO, (uint8_t *)&cfg_flag, - DIS_IDX_NB, NULL, env->task, &diss_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS))); + status = attm_svc_create_db( + start_hdl, ATT_SVC_DEVICE_INFO, (uint8_t *)&cfg_flag, DIS_IDX_NB, NULL, + env->task, &diss_att_db[0], + (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS))); - //-------------------- allocate memory required for the profile --------------------- - if (status == ATT_ERR_NO_ERROR) - { - struct diss_env_tag* diss_env = - (struct diss_env_tag* ) ke_malloc(sizeof(struct diss_env_tag), KE_MEM_ATT_DB); + //-------------------- allocate memory required for the profile + //--------------------- + if (status == ATT_ERR_NO_ERROR) { + struct diss_env_tag *diss_env = (struct diss_env_tag *)ke_malloc( + sizeof(struct diss_env_tag), KE_MEM_ATT_DB); - // allocate DISS required environment variable - env->env = (prf_env_t*) diss_env; - diss_env->start_hdl = *start_hdl; - diss_env->features = params->features; - diss_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - diss_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); + // allocate DISS required environment variable + env->env = (prf_env_t *)diss_env; + diss_env->start_hdl = *start_hdl; + diss_env->features = params->features; + diss_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + diss_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); - // initialize environment variable - env->id = TASK_ID_DISS; - diss_task_init(&(env->desc)); - co_list_init(&(diss_env->values)); + // initialize environment variable + env->id = TASK_ID_DISS; + diss_task_init(&(env->desc)); + co_list_init(&(diss_env->values)); - // service is ready, go into an Idle state - ke_state_set(env->task, DISS_IDLE); - } + // service is ready, go into an Idle state + ke_state_set(env->task, DISS_IDLE); + } - return (status); + return (status); } /** **************************************************************************************** * @brief Destruction of the DISS module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void diss_destroy(struct prf_task_env* env) -{ - struct diss_env_tag* diss_env = (struct diss_env_tag*) env->env; +static void diss_destroy(struct prf_task_env *env) { + struct diss_env_tag *diss_env = (struct diss_env_tag *)env->env; - // remove all values present in list - while(!co_list_is_empty(&(diss_env->values))) - { - struct co_list_hdr* hdr = co_list_pop_front(&(diss_env->values)); - ke_free(hdr); - } + // remove all values present in list + while (!co_list_is_empty(&(diss_env->values))) { + struct co_list_hdr *hdr = co_list_pop_front(&(diss_env->values)); + ke_free(hdr); + } - // free profile environment variables - env->env = NULL; - ke_free(diss_env); + // free profile environment variables + env->env = NULL; + ke_free(diss_env); } /** @@ -193,9 +211,8 @@ static void diss_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void diss_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Nothing to do */ +static void diss_create(struct prf_task_env *env, uint8_t conidx) { + /* Nothing to do */ } /** @@ -207,9 +224,9 @@ static void diss_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void diss_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - /* Nothing to do */ +static void diss_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + /* Nothing to do */ } /* @@ -218,12 +235,11 @@ static void diss_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reaso */ /// DISS Task interface required by profile manager -const struct prf_task_cbs diss_itf = -{ - (prf_init_fnct) diss_init, - diss_destroy, - diss_create, - diss_cleanup, +const struct prf_task_cbs diss_itf = { + (prf_init_fnct)diss_init, + diss_destroy, + diss_create, + diss_cleanup, }; /* @@ -231,117 +247,92 @@ const struct prf_task_cbs diss_itf = **************************************************************************************** */ -const struct prf_task_cbs* diss_prf_itf_get(void) -{ - return &diss_itf; -} +const struct prf_task_cbs *diss_prf_itf_get(void) { return &diss_itf; } -uint32_t diss_compute_cfg_flag(uint16_t features) -{ - //Service Declaration - uint32_t cfg_flag = 1; +uint32_t diss_compute_cfg_flag(uint16_t features) { + // Service Declaration + uint32_t cfg_flag = 1; - for (uint8_t i = 0; i> i) & 1) == 1) - { - cfg_flag |= (3 << (i*2 + 1)); - } + for (uint8_t i = 0; i < DIS_CHAR_MAX; i++) { + if (((features >> i) & 1) == 1) { + cfg_flag |= (3 << (i * 2 + 1)); } + } - return cfg_flag; + return cfg_flag; } +uint8_t diss_handle_to_value(struct diss_env_tag *env, uint16_t handle) { + uint8_t value = DIS_CHAR_MAX; -uint8_t diss_handle_to_value(struct diss_env_tag* env, uint16_t handle) -{ - uint8_t value = DIS_CHAR_MAX; + // handle cursor, start from first characteristic of service handle + uint16_t cur_hdl = env->start_hdl + 1; - // handle cursor, start from first characteristic of service handle - uint16_t cur_hdl = env->start_hdl + 1; - - for (uint8_t i = 0; ifeatures >> i) & 1) == 1) - { - // check if value handle correspond to requested handle - if((cur_hdl +1) == handle) - { - value = i; - break; - } - cur_hdl += 2; - } + for (uint8_t i = 0; i < DIS_CHAR_MAX; i++) { + if (((env->features >> i) & 1) == 1) { + // check if value handle correspond to requested handle + if ((cur_hdl + 1) == handle) { + value = i; + break; + } + cur_hdl += 2; } + } - return value; + return value; } -uint16_t diss_value_to_handle(struct diss_env_tag* env, uint8_t value) -{ - uint16_t handle = env->start_hdl + 1; - int8_t i; +uint16_t diss_value_to_handle(struct diss_env_tag *env, uint8_t value) { + uint16_t handle = env->start_hdl + 1; + int8_t i; - for (i = 0; ifeatures >> i) & 1) == 1) - { - // requested value - if(value == i) - { - handle += 1; - break; - } - handle += 2; - } + for (i = 0; i < DIS_CHAR_MAX; i++) { + if (((env->features >> i) & 1) == 1) { + // requested value + if (value == i) { + handle += 1; + break; + } + handle += 2; } + } - // check if handle found - return ((i == DIS_CHAR_MAX) ? ATT_INVALID_HDL : handle); + // check if handle found + return ((i == DIS_CHAR_MAX) ? ATT_INVALID_HDL : handle); } -uint8_t diss_check_val_len(uint8_t char_code, uint8_t val_len) -{ - uint8_t status = GAP_ERR_NO_ERROR; +uint8_t diss_check_val_len(uint8_t char_code, uint8_t val_len) { + uint8_t status = GAP_ERR_NO_ERROR; - // Check if length is upper than the general maximal length - if (val_len > DIS_VAL_MAX_LEN) - { + // Check if length is upper than the general maximal length + if (val_len > DIS_VAL_MAX_LEN) { + status = PRF_ERR_UNEXPECTED_LEN; + } else { + // Check if length matches particular requirements + switch (char_code) { + case DIS_SYSTEM_ID_CHAR: + if (val_len != DIS_SYS_ID_LEN) { status = PRF_ERR_UNEXPECTED_LEN; + } + break; + case DIS_IEEE_CHAR: + if (val_len < DIS_IEEE_CERTIF_MIN_LEN) { + status = PRF_ERR_UNEXPECTED_LEN; + } + break; + case DIS_PNP_ID_CHAR: + if (val_len != DIS_PNP_ID_LEN) { + status = PRF_ERR_UNEXPECTED_LEN; + } + break; + default: + break; } - else - { - // Check if length matches particular requirements - switch (char_code) - { - case DIS_SYSTEM_ID_CHAR: - if (val_len != DIS_SYS_ID_LEN) - { - status = PRF_ERR_UNEXPECTED_LEN; - } - break; - case DIS_IEEE_CHAR: - if (val_len < DIS_IEEE_CERTIF_MIN_LEN) - { - status = PRF_ERR_UNEXPECTED_LEN; - } - break; - case DIS_PNP_ID_CHAR: - if (val_len != DIS_PNP_ID_LEN) - { - status = PRF_ERR_UNEXPECTED_LEN; - } - break; - default: - break; - } - } + } - return (status); + return (status); } - - -#endif //BLE_DIS_SERVER +#endif // BLE_DIS_SERVER /// @} DISS diff --git a/services/ble_profiles/dis/diss/src/diss_task.c b/services/ble_profiles/dis/diss/src/diss_task.c index 3a741fd..c59db1e 100644 --- a/services/ble_profiles/dis/diss/src/diss_task.c +++ b/services/ble_profiles/dis/diss/src/diss_task.c @@ -5,7 +5,6 @@ **************************************************************************************** */ - /* * INCLUDE FILES **************************************************************************************** @@ -14,10 +13,10 @@ #if (BLE_DIS_SERVER) #include "co_utils.h" -#include "gap.h" -#include "gattc_task.h" #include "diss.h" #include "diss_task.h" +#include "gap.h" +#include "gattc_task.h" #include "prf_utils.h" #include "ke_mem.h" @@ -39,77 +38,66 @@ **************************************************************************************** */ __STATIC int diss_set_value_req_handler(ke_msg_id_t const msgid, - struct diss_set_value_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Request status - uint8_t status; - // Characteristic Declaration attribute handle - uint16_t handle; + struct diss_set_value_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Request status + uint8_t status; + // Characteristic Declaration attribute handle + uint16_t handle; - struct diss_env_tag* diss_env = PRF_ENV_GET(DISS, diss); - struct diss_set_value_rsp* rsp; - // Check Characteristic Code - if (param->value < DIS_CHAR_MAX) - { - // Get Characteristic Declaration attribute handle - handle = diss_value_to_handle(diss_env, param->value); + struct diss_env_tag *diss_env = PRF_ENV_GET(DISS, diss); + struct diss_set_value_rsp *rsp; + // Check Characteristic Code + if (param->value < DIS_CHAR_MAX) { + // Get Characteristic Declaration attribute handle + handle = diss_value_to_handle(diss_env, param->value); - // Check if the Characteristic exists in the database - if (handle != ATT_INVALID_HDL) - { - // Check the value length - status = diss_check_val_len(param->value, param->length); + // Check if the Characteristic exists in the database + if (handle != ATT_INVALID_HDL) { + // Check the value length + status = diss_check_val_len(param->value, param->length); - if (status == GAP_ERR_NO_ERROR) - { - // Check value in already present in service - struct diss_val_elmt *val = (struct diss_val_elmt *) co_list_pick(&(diss_env->values)); - // loop until value found - while(val != NULL) - { - // if value already present, remove old one - if(val->value == param->value) - { - co_list_extract(&(diss_env->values), &(val->hdr)); - ke_free(val); - break; - } - val = (struct diss_val_elmt *)val->hdr.next; - } - - // allocate value data - val = (struct diss_val_elmt *) ke_malloc(sizeof(struct diss_val_elmt) + param->length, KE_MEM_ATT_DB); - val->value = param->value; - val->length = param->length; - memcpy(val->data, param->data, param->length); - // insert value into the list - co_list_push_back(&(diss_env->values), &(val->hdr)); - } - } - else - { - status = PRF_ERR_INEXISTENT_HDL; + if (status == GAP_ERR_NO_ERROR) { + // Check value in already present in service + struct diss_val_elmt *val = + (struct diss_val_elmt *)co_list_pick(&(diss_env->values)); + // loop until value found + while (val != NULL) { + // if value already present, remove old one + if (val->value == param->value) { + co_list_extract(&(diss_env->values), &(val->hdr)); + ke_free(val); + break; + } + val = (struct diss_val_elmt *)val->hdr.next; } + + // allocate value data + val = (struct diss_val_elmt *)ke_malloc( + sizeof(struct diss_val_elmt) + param->length, KE_MEM_ATT_DB); + val->value = param->value; + val->length = param->length; + memcpy(val->data, param->data, param->length); + // insert value into the list + co_list_push_back(&(diss_env->values), &(val->hdr)); + } + } else { + status = PRF_ERR_INEXISTENT_HDL; } - else - { - status = PRF_ERR_INVALID_PARAM; - } + } else { + status = PRF_ERR_INVALID_PARAM; + } - // send response to application - rsp = KE_MSG_ALLOC(DISS_SET_VALUE_RSP, src_id, dest_id, diss_set_value_rsp); - rsp->value = param->value; - rsp->status = status; - ke_msg_send(rsp); + // send response to application + rsp = KE_MSG_ALLOC(DISS_SET_VALUE_RSP, src_id, dest_id, diss_set_value_rsp); + rsp->value = param->value; + rsp->status = status; + ke_msg_send(rsp); - - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } - - /** **************************************************************************************** * @brief Handles reception of the read request from peer device @@ -122,80 +110,72 @@ __STATIC int diss_set_value_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_read_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - int msg_status = KE_MSG_CONSUMED; - ke_state_t state = ke_state_get(dest_id); + struct gattc_read_req_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + int msg_status = KE_MSG_CONSUMED; + ke_state_t state = ke_state_get(dest_id); - if(state == DISS_IDLE) - { - struct diss_env_tag* diss_env = PRF_ENV_GET(DISS, diss); - // retrieve value attribute - uint8_t value = diss_handle_to_value(diss_env, param->handle); + if (state == DISS_IDLE) { + struct diss_env_tag *diss_env = PRF_ENV_GET(DISS, diss); + // retrieve value attribute + uint8_t value = diss_handle_to_value(diss_env, param->handle); - // Check Characteristic Code - if (value < DIS_CHAR_MAX) - { - // Check value in already present in service - struct diss_val_elmt *val = (struct diss_val_elmt *) co_list_pick(&(diss_env->values)); - // loop until value found - while(val != NULL) - { - // value is present in service - if(val->value == value) - { - break; - } - val = (struct diss_val_elmt *)val->hdr.next; - } - - if(val != NULL) - { - // Send value to peer device. - struct gattc_read_cfm* cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, val->length); - cfm->handle = param->handle; - cfm->status = ATT_ERR_NO_ERROR; - cfm->length = val->length; - memcpy(cfm->value, val->data, val->length); - ke_msg_send(cfm); - } - else - { - // request value to application - diss_env->req_val = value; - diss_env->req_conidx = KE_IDX_GET(src_id); - - struct diss_value_req_ind* req_ind = KE_MSG_ALLOC(DISS_VALUE_REQ_IND, - prf_dst_task_get(&(diss_env->prf_env), KE_IDX_GET(src_id)), - dest_id, diss_value_req_ind); - req_ind->value = value; - ke_msg_send(req_ind); - - // Put Service in a busy state - ke_state_set(dest_id, DISS_BUSY); - } + // Check Characteristic Code + if (value < DIS_CHAR_MAX) { + // Check value in already present in service + struct diss_val_elmt *val = + (struct diss_val_elmt *)co_list_pick(&(diss_env->values)); + // loop until value found + while (val != NULL) { + // value is present in service + if (val->value == value) { + break; } - else - { - // application error, value cannot be retrieved - struct gattc_read_cfm* cfm = KE_MSG_ALLOC(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm); - cfm->handle = param->handle; - cfm->status = ATT_ERR_APP_ERROR; - ke_msg_send(cfm); - } - } - // postpone request if profile is in a busy state - required for multipoint - else if(state == DISS_BUSY) - { - msg_status = KE_MSG_SAVED; - } + val = (struct diss_val_elmt *)val->hdr.next; + } - return (msg_status); + if (val != NULL) { + // Send value to peer device. + struct gattc_read_cfm *cfm = KE_MSG_ALLOC_DYN( + GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, val->length); + cfm->handle = param->handle; + cfm->status = ATT_ERR_NO_ERROR; + cfm->length = val->length; + memcpy(cfm->value, val->data, val->length); + ke_msg_send(cfm); + } else { + // request value to application + diss_env->req_val = value; + diss_env->req_conidx = KE_IDX_GET(src_id); + + struct diss_value_req_ind *req_ind = KE_MSG_ALLOC( + DISS_VALUE_REQ_IND, + prf_dst_task_get(&(diss_env->prf_env), KE_IDX_GET(src_id)), dest_id, + diss_value_req_ind); + req_ind->value = value; + ke_msg_send(req_ind); + + // Put Service in a busy state + ke_state_set(dest_id, DISS_BUSY); + } + } else { + // application error, value cannot be retrieved + struct gattc_read_cfm *cfm = + KE_MSG_ALLOC(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm); + cfm->handle = param->handle; + cfm->status = ATT_ERR_APP_ERROR; + ke_msg_send(cfm); + } + } + // postpone request if profile is in a busy state - required for multipoint + else if (state == DISS_BUSY) { + msg_status = KE_MSG_SAVED; + } + + return (msg_status); } - /** **************************************************************************************** * @brief Handles reception of the value confirmation from application @@ -208,44 +188,44 @@ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int diss_value_cfm_handler(ke_msg_id_t const msgid, - struct diss_value_cfm const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - ke_state_t state = ke_state_get(dest_id); + struct diss_value_cfm const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + ke_state_t state = ke_state_get(dest_id); - if(state == DISS_BUSY) - { - struct diss_env_tag* diss_env = PRF_ENV_GET(DISS, diss); - // retrieve value attribute - uint16_t handle = diss_value_to_handle(diss_env, diss_env->req_val); + if (state == DISS_BUSY) { + struct diss_env_tag *diss_env = PRF_ENV_GET(DISS, diss); + // retrieve value attribute + uint16_t handle = diss_value_to_handle(diss_env, diss_env->req_val); - // chack if application provide correct value - if (diss_env->req_val == param->value) - { - // Send value to peer device. - struct gattc_read_cfm* cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, KE_BUILD_ID(TASK_GATTC, diss_env->req_conidx), dest_id, gattc_read_cfm, param->length); - cfm->handle = handle; - cfm->status = ATT_ERR_NO_ERROR; - cfm->length = param->length; - memcpy(cfm->value, param->data, param->length); - ke_msg_send(cfm); - } - else - { - // application error, value provided by application is not the expected one - struct gattc_read_cfm* cfm = KE_MSG_ALLOC(GATTC_READ_CFM, KE_BUILD_ID(TASK_GATTC, diss_env->req_conidx), dest_id, gattc_read_cfm); - cfm->handle = handle; - cfm->status = ATT_ERR_APP_ERROR; - ke_msg_send(cfm); - } - - // return to idle state - ke_state_set(dest_id, DISS_IDLE); + // chack if application provide correct value + if (diss_env->req_val == param->value) { + // Send value to peer device. + struct gattc_read_cfm *cfm = KE_MSG_ALLOC_DYN( + GATTC_READ_CFM, KE_BUILD_ID(TASK_GATTC, diss_env->req_conidx), + dest_id, gattc_read_cfm, param->length); + cfm->handle = handle; + cfm->status = ATT_ERR_NO_ERROR; + cfm->length = param->length; + memcpy(cfm->value, param->data, param->length); + ke_msg_send(cfm); + } else { + // application error, value provided by application is not the expected + // one + struct gattc_read_cfm *cfm = KE_MSG_ALLOC( + GATTC_READ_CFM, KE_BUILD_ID(TASK_GATTC, diss_env->req_conidx), + dest_id, gattc_read_cfm); + cfm->handle = handle; + cfm->status = ATT_ERR_APP_ERROR; + ke_msg_send(cfm); } - // else ignore request if not in busy state - return (KE_MSG_CONSUMED); + // return to idle state + ke_state_set(dest_id, DISS_IDLE); + } + // else ignore request if not in busy state + + return (KE_MSG_CONSUMED); } /* @@ -254,24 +234,22 @@ __STATIC int diss_value_cfm_handler(ke_msg_id_t const msgid, */ /// Default State handlers definition -KE_MSG_HANDLER_TAB(diss) -{ - {DISS_SET_VALUE_REQ, (ke_msg_func_t)diss_set_value_req_handler}, - {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, - {DISS_VALUE_CFM, (ke_msg_func_t)diss_value_cfm_handler}, +KE_MSG_HANDLER_TAB(diss){ + {DISS_SET_VALUE_REQ, (ke_msg_func_t)diss_set_value_req_handler}, + {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, + {DISS_VALUE_CFM, (ke_msg_func_t)diss_value_cfm_handler}, }; -void diss_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct diss_env_tag *diss_env = PRF_ENV_GET(DISS, diss); +void diss_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct diss_env_tag *diss_env = PRF_ENV_GET(DISS, diss); - task_desc->msg_handler_tab = diss_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(diss_msg_handler_tab); - task_desc->state = diss_env->state; - task_desc->idx_max = DISS_IDX_MAX; + task_desc->msg_handler_tab = diss_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(diss_msg_handler_tab); + task_desc->state = diss_env->state; + task_desc->idx_max = DISS_IDX_MAX; } -#endif //BLE_DIS_SERVER +#endif // BLE_DIS_SERVER /// @} DISSTASK diff --git a/services/ble_profiles/find/findl/src/findl.c b/services/ble_profiles/find/findl/src/findl.c index 6ed43fa..7914838 100644 --- a/services/ble_profiles/find/findl/src/findl.c +++ b/services/ble_profiles/find/findl/src/findl.c @@ -15,8 +15,8 @@ #if (BLE_FINDME_LOCATOR) #include "findl.h" #include "findl_task.h" -#include "prf_utils.h" #include "gap.h" +#include "prf_utils.h" #include "ke_mem.h" @@ -36,70 +36,70 @@ * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t findl_init (struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, - uint8_t sec_lvl, void* params) -{ - uint8_t idx; - //-------------------- allocate memory required for the profile --------------------- +static uint8_t findl_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t idx; + //-------------------- allocate memory required for the profile + //--------------------- - struct findl_env_tag* findl_env = - (struct findl_env_tag* ) ke_malloc(sizeof(struct findl_env_tag), KE_MEM_ATT_DB); + struct findl_env_tag *findl_env = (struct findl_env_tag *)ke_malloc( + sizeof(struct findl_env_tag), KE_MEM_ATT_DB); - // allocate FINDL required environment variable - env->env = (prf_env_t*) findl_env; + // allocate FINDL required environment variable + env->env = (prf_env_t *)findl_env; - findl_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - findl_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + findl_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + findl_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_FINDL; - findl_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_FINDL; + findl_task_init(&(env->desc)); - for(idx = 0; idx < FINDL_IDX_MAX ; idx++) - { - findl_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), FINDL_FREE); - } + for (idx = 0; idx < FINDL_IDX_MAX; idx++) { + findl_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), FINDL_FREE); + } - return GAP_ERR_NO_ERROR; + return GAP_ERR_NO_ERROR; } /** **************************************************************************************** * @brief Destruction of the FINDL module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void findl_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct findl_env_tag* findl_env = (struct findl_env_tag*) env->env; +static void findl_destroy(struct prf_task_env *env) { + uint8_t idx; + struct findl_env_tag *findl_env = (struct findl_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < FINDL_IDX_MAX ; idx++) - { - if(findl_env->env[idx] != NULL) - { - ke_free(findl_env->env[idx]); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < FINDL_IDX_MAX; idx++) { + if (findl_env->env[idx] != NULL) { + ke_free(findl_env->env[idx]); } + } - // free profile environment variables - env->env = NULL; - ke_free(findl_env); + // free profile environment variables + env->env = NULL; + ke_free(findl_env); } /** @@ -110,10 +110,9 @@ static void findl_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void findl_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Put FINDL in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), FINDL_IDLE); +static void findl_create(struct prf_task_env *env, uint8_t conidx) { + /* Put FINDL in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), FINDL_IDLE); } /** @@ -125,19 +124,18 @@ static void findl_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void findl_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct findl_env_tag* findl_env = (struct findl_env_tag*) env->env; +static void findl_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct findl_env_tag *findl_env = (struct findl_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(findl_env->env[conidx] != NULL) - { - ke_free(findl_env->env[conidx]); - findl_env->env[conidx] = NULL; - } + // clean-up environment variable allocated for task instance + if (findl_env->env[conidx] != NULL) { + ke_free(findl_env->env[conidx]); + findl_env->env[conidx] = NULL; + } - /* Put FINDL in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), FINDL_FREE); + /* Put FINDL in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), FINDL_FREE); } /* @@ -145,14 +143,12 @@ static void findl_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reas **************************************************************************************** */ - /// FINDL Task interface required by profile manager -const struct prf_task_cbs findl_itf = -{ - (prf_init_fnct) findl_init, - findl_destroy, - findl_create, - findl_cleanup, +const struct prf_task_cbs findl_itf = { + (prf_init_fnct)findl_init, + findl_destroy, + findl_create, + findl_cleanup, }; /* @@ -160,37 +156,30 @@ const struct prf_task_cbs findl_itf = **************************************************************************************** */ -const struct prf_task_cbs* findl_prf_itf_get(void) -{ - return &findl_itf; +const struct prf_task_cbs *findl_prf_itf_get(void) { return &findl_itf; } + +void findl_enable_rsp_send(struct findl_env_tag *findl_env, uint8_t conidx, + uint8_t status) { + // send response to app + struct findl_enable_rsp *cfm = KE_MSG_ALLOC( + FINDL_ENABLE_RSP, prf_dst_task_get(&(findl_env->prf_env), conidx), + prf_src_task_get(&(findl_env->prf_env), conidx), findl_enable_rsp); + + cfm->ias = findl_env->env[conidx]->ias; + cfm->status = status; + + if (status == GAP_ERR_NO_ERROR) { + // Go to idle state + ke_state_set(prf_src_task_get(&(findl_env->prf_env), conidx), FINDL_IDLE); + } else { + // clean-up environment variable allocated for task instance + ke_free(findl_env->env[conidx]); + findl_env->env[conidx] = NULL; + } + + ke_msg_send(cfm); } -void findl_enable_rsp_send(struct findl_env_tag *findl_env, uint8_t conidx, uint8_t status) -{ - //send response to app - struct findl_enable_rsp * cfm = KE_MSG_ALLOC(FINDL_ENABLE_RSP, - prf_dst_task_get(&(findl_env->prf_env), conidx), - prf_src_task_get(&(findl_env->prf_env), conidx), - findl_enable_rsp); - - cfm->ias = findl_env->env[conidx]->ias; - cfm->status = status; - - if (status == GAP_ERR_NO_ERROR) - { - // Go to idle state - ke_state_set(prf_src_task_get(&(findl_env->prf_env), conidx), FINDL_IDLE); - } - else - { - // clean-up environment variable allocated for task instance - ke_free(findl_env->env[conidx]); - findl_env->env[conidx] = NULL; - } - - ke_msg_send(cfm); -} - -#endif //BLE_FINDME_LOCATOR +#endif // BLE_FINDME_LOCATOR /// @} FINDL diff --git a/services/ble_profiles/find/findl/src/findl_task.c b/services/ble_profiles/find/findl/src/findl_task.c index b1e2019..3d51d53 100644 --- a/services/ble_profiles/find/findl/src/findl_task.c +++ b/services/ble_profiles/find/findl/src/findl_task.c @@ -14,26 +14,23 @@ #if (BLE_FINDME_LOCATOR) #include "co_utils.h" -#include "findl_task.h" #include "findl.h" -#include "gattc_task.h" -#include "prf_utils.h" +#include "findl_task.h" #include "gap.h" #include "gapc.h" #include "gapc_task.h" +#include "gattc_task.h" +#include "prf_utils.h" #include #include "ke_mem.h" /// table used to retrieve immediate alert service characteristics information -const struct prf_char_def findl_ias_char[FINDL_IAS_CHAR_MAX] = -{ - [FINDL_ALERT_LVL_CHAR] = {ATT_CHAR_ALERT_LEVEL, - ATT_MANDATORY, - ATT_CHAR_PROP_WR_NO_RESP}, +const struct prf_char_def findl_ias_char[FINDL_IAS_CHAR_MAX] = { + [FINDL_ALERT_LVL_CHAR] = {ATT_CHAR_ALERT_LEVEL, ATT_MANDATORY, + ATT_CHAR_PROP_WR_NO_RESP}, }; - /* * FUNCTION DEFINITIONS **************************************************************************************** @@ -51,55 +48,49 @@ const struct prf_char_def findl_ias_char[FINDL_IAS_CHAR_MAX] = **************************************************************************************** */ __STATIC int findl_enable_req_handler(ke_msg_id_t const msgid, - struct findl_enable_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; + struct findl_enable_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; - uint8_t state = ke_state_get(dest_id); - uint8_t conidx = KE_IDX_GET(dest_id); - // Find me Locator Role Task Environment - struct findl_env_tag *findl_env = PRF_ENV_GET(FINDL, findl); + uint8_t state = ke_state_get(dest_id); + uint8_t conidx = KE_IDX_GET(dest_id); + // Find me Locator Role Task Environment + struct findl_env_tag *findl_env = PRF_ENV_GET(FINDL, findl); - ASSERT_INFO(findl_env != NULL, dest_id, src_id); - if((state == FINDL_IDLE) && (findl_env->env[conidx] == NULL)) - { - // allocate environment variable for task instance - findl_env->env[conidx] = (struct findl_cnx_env*) ke_malloc(sizeof(struct findl_cnx_env),KE_MEM_ATT_DB); - memset(findl_env->env[conidx], 0, sizeof(struct findl_cnx_env)); + ASSERT_INFO(findl_env != NULL, dest_id, src_id); + if ((state == FINDL_IDLE) && (findl_env->env[conidx] == NULL)) { + // allocate environment variable for task instance + findl_env->env[conidx] = (struct findl_cnx_env *)ke_malloc( + sizeof(struct findl_cnx_env), KE_MEM_ATT_DB); + memset(findl_env->env[conidx], 0, sizeof(struct findl_cnx_env)); - //Config connection, start discovering - if(param->con_type == PRF_CON_DISCOVERY) - { - //start discovering IAS on peer - prf_disc_svc_send(&(findl_env->prf_env), conidx, ATT_SVC_IMMEDIATE_ALERT); + // Config connection, start discovering + if (param->con_type == PRF_CON_DISCOVERY) { + // start discovering IAS on peer + prf_disc_svc_send(&(findl_env->prf_env), conidx, ATT_SVC_IMMEDIATE_ALERT); - // Go to DISCOVERING state - ke_state_set(dest_id, FINDL_DISCOVERING); - } - //normal connection, get saved att details - else - { - findl_env->env[conidx]->ias = param->ias; - - //send APP confirmation that can start normal connection to TH - findl_enable_rsp_send(findl_env, conidx, GAP_ERR_NO_ERROR); - } - } - else if(state != FINDL_FREE) - { - status = PRF_ERR_REQ_DISALLOWED; + // Go to DISCOVERING state + ke_state_set(dest_id, FINDL_DISCOVERING); } + // normal connection, get saved att details + else { + findl_env->env[conidx]->ias = param->ias; - // send an error if request fails - if(status != GAP_ERR_NO_ERROR) - { - findl_enable_rsp_send(findl_env, conidx, status); + // send APP confirmation that can start normal connection to TH + findl_enable_rsp_send(findl_env, conidx, GAP_ERR_NO_ERROR); } + } else if (state != FINDL_FREE) { + status = PRF_ERR_REQ_DISALLOWED; + } - return (KE_MSG_CONSUMED); + // send an error if request fails + if (status != GAP_ERR_NO_ERROR) { + findl_enable_rsp_send(findl_env, conidx, status); + } + + return (KE_MSG_CONSUMED); } /** @@ -114,36 +105,34 @@ __STATIC int findl_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, - struct gattc_sdp_svc_ind const *ind, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_sdp_svc_ind const *ind, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == FINDL_DISCOVERING) - { - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct findl_env_tag *findl_env = PRF_ENV_GET(FINDL, findl); + if (state == FINDL_DISCOVERING) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct findl_env_tag *findl_env = PRF_ENV_GET(FINDL, findl); - ASSERT_INFO(findl_env != NULL, dest_id, src_id); - ASSERT_INFO(findl_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(findl_env != NULL, dest_id, src_id); + ASSERT_INFO(findl_env->env[conidx] != NULL, dest_id, src_id); - if(findl_env->env[conidx]->nb_svc == 0) - { - // Retrieve IAS characteristic - prf_extract_svc_info(ind, FINDL_IAS_CHAR_MAX, &findl_ias_char[0], - &(findl_env->env[conidx]->ias.alert_lvl_char), 0, NULL, NULL); + if (findl_env->env[conidx]->nb_svc == 0) { + // Retrieve IAS characteristic + prf_extract_svc_info(ind, FINDL_IAS_CHAR_MAX, &findl_ias_char[0], + &(findl_env->env[conidx]->ias.alert_lvl_char), 0, + NULL, NULL); - //Even if we get multiple responses we only store 1 range - findl_env->env[conidx]->ias.svc.shdl = ind->start_hdl; - findl_env->env[conidx]->ias.svc.ehdl = ind->end_hdl; - } - - findl_env->env[conidx]->nb_svc++; + // Even if we get multiple responses we only store 1 range + findl_env->env[conidx]->ias.svc.shdl = ind->start_hdl; + findl_env->env[conidx]->ias.svc.ehdl = ind->end_hdl; } - return (KE_MSG_CONSUMED); + findl_env->env[conidx]->nb_svc++; + } + + return (KE_MSG_CONSUMED); } /** @@ -157,66 +146,56 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int findl_set_alert_req_handler(ke_msg_id_t const msgid, - struct findl_set_alert_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; - // Get the address of the environment - struct findl_env_tag *findl_env = PRF_ENV_GET(FINDL, findl); - uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); - int msg_status = KE_MSG_CONSUMED; +__STATIC int findl_set_alert_req_handler( + ke_msg_id_t const msgid, struct findl_set_alert_req const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; + // Get the address of the environment + struct findl_env_tag *findl_env = PRF_ENV_GET(FINDL, findl); + uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t state = ke_state_get(dest_id); + int msg_status = KE_MSG_CONSUMED; - if(state == FINDL_IDLE) - { - // check if discovery performed - if(findl_env->env[conidx] == NULL) - { - status = PRF_ERR_REQ_DISALLOWED; - } - //Check we're sending a correct value - else if ((param->alert_lvl == FINDL_ALERT_NONE) || - (param->alert_lvl == FINDL_ALERT_MILD) || - (param->alert_lvl == FINDL_ALERT_HIGH)) - { - if(findl_env->env[conidx]->ias.alert_lvl_char.char_hdl != 0x0000) - { - // Send GATT Write Request - prf_gatt_write(&findl_env->prf_env, conidx, - findl_env->env[conidx]->ias.alert_lvl_char.val_hdl, - (uint8_t *)¶m->alert_lvl, sizeof(uint8_t), GATTC_WRITE_NO_RESPONSE); - // wait for end of write request - ke_state_set(dest_id, FINDL_BUSY); - } - else - { - //cannot set alert level because have no char handle for it - status = PRF_ERR_INEXISTENT_HDL; - } - } - else - { - //wrong level - not one of the possible 3 - status = PRF_ERR_INVALID_PARAM; - } - - struct findl_set_alert_rsp *rsp = KE_MSG_ALLOC(FINDL_SET_ALERT_RSP, - src_id, dest_id, findl_set_alert_rsp); - // set error status - rsp->status = status; - - ke_msg_send(rsp); + if (state == FINDL_IDLE) { + // check if discovery performed + if (findl_env->env[conidx] == NULL) { + status = PRF_ERR_REQ_DISALLOWED; } - else if(state != FINDL_FREE) - { - msg_status = KE_MSG_SAVED;; + // Check we're sending a correct value + else if ((param->alert_lvl == FINDL_ALERT_NONE) || + (param->alert_lvl == FINDL_ALERT_MILD) || + (param->alert_lvl == FINDL_ALERT_HIGH)) { + if (findl_env->env[conidx]->ias.alert_lvl_char.char_hdl != 0x0000) { + // Send GATT Write Request + prf_gatt_write(&findl_env->prf_env, conidx, + findl_env->env[conidx]->ias.alert_lvl_char.val_hdl, + (uint8_t *)¶m->alert_lvl, sizeof(uint8_t), + GATTC_WRITE_NO_RESPONSE); + // wait for end of write request + ke_state_set(dest_id, FINDL_BUSY); + } else { + // cannot set alert level because have no char handle for it + status = PRF_ERR_INEXISTENT_HDL; + } + } else { + // wrong level - not one of the possible 3 + status = PRF_ERR_INVALID_PARAM; } - // else nothing to do - ignore message - return (msg_status); + struct findl_set_alert_rsp *rsp = + KE_MSG_ALLOC(FINDL_SET_ALERT_RSP, src_id, dest_id, findl_set_alert_rsp); + // set error status + rsp->status = status; + + ke_msg_send(rsp); + } else if (state != FINDL_FREE) { + msg_status = KE_MSG_SAVED; + ; + } + // else nothing to do - ignore message + + return (msg_status); } /** @@ -231,47 +210,39 @@ __STATIC int findl_set_alert_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, - struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - // Get the address of the environment - struct findl_env_tag *findl_env = PRF_ENV_GET(FINDL, findl); - uint8_t conidx = KE_IDX_GET(dest_id); + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + // Get the address of the environment + struct findl_env_tag *findl_env = PRF_ENV_GET(FINDL, findl); + uint8_t conidx = KE_IDX_GET(dest_id); + if (state == FINDL_DISCOVERING) { + uint8_t status = param->status; - if(state == FINDL_DISCOVERING) - { - uint8_t status = param->status; - - if (param->status == ATT_ERR_NO_ERROR) - { - if(findl_env->env[conidx]->nb_svc == 1) - { - status = prf_check_svc_char_validity(FINDL_IAS_CHAR_MAX, - &(findl_env->env[conidx]->ias.alert_lvl_char), findl_ias_char); - } - // too much services - else if (findl_env->env[conidx]->nb_svc > 1) - { - status = PRF_ERR_MULTIPLE_SVC; - } - // no services found - else - { - status = PRF_ERR_INVALID_PARAM; - } - } - - findl_enable_rsp_send(findl_env, conidx, status); - } - else if (state == FINDL_BUSY) - { - ke_state_set(dest_id, FINDL_IDLE); + if (param->status == ATT_ERR_NO_ERROR) { + if (findl_env->env[conidx]->nb_svc == 1) { + status = prf_check_svc_char_validity( + FINDL_IAS_CHAR_MAX, &(findl_env->env[conidx]->ias.alert_lvl_char), + findl_ias_char); + } + // too much services + else if (findl_env->env[conidx]->nb_svc > 1) { + status = PRF_ERR_MULTIPLE_SVC; + } + // no services found + else { + status = PRF_ERR_INVALID_PARAM; + } } - return (KE_MSG_CONSUMED); + findl_enable_rsp_send(findl_env, conidx, status); + } else if (state == FINDL_BUSY) { + ke_state_set(dest_id, FINDL_IDLE); + } + + return (KE_MSG_CONSUMED); } /* @@ -279,27 +250,24 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, **************************************************************************************** */ - /// Default State handlers definition -KE_MSG_HANDLER_TAB(findl) -{ - {FINDL_ENABLE_REQ, (ke_msg_func_t)findl_enable_req_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, - {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, - {FINDL_SET_ALERT_REQ, (ke_msg_func_t)findl_set_alert_req_handler}, +KE_MSG_HANDLER_TAB(findl){ + {FINDL_ENABLE_REQ, (ke_msg_func_t)findl_enable_req_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, + {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, + {FINDL_SET_ALERT_REQ, (ke_msg_func_t)findl_set_alert_req_handler}, }; -void findl_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct findl_env_tag *findl_env = PRF_ENV_GET(FINDL, findl); +void findl_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct findl_env_tag *findl_env = PRF_ENV_GET(FINDL, findl); - task_desc->msg_handler_tab = findl_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(findl_msg_handler_tab); - task_desc->state = findl_env->state; - task_desc->idx_max = FINDL_IDX_MAX; + task_desc->msg_handler_tab = findl_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(findl_msg_handler_tab); + task_desc->state = findl_env->state; + task_desc->idx_max = FINDL_IDX_MAX; } -#endif //BLE_FINDME_LOCATOR +#endif // BLE_FINDME_LOCATOR /// @} FINDLTASK diff --git a/services/ble_profiles/find/findt/src/findt.c b/services/ble_profiles/find/findt/src/findt.c index 25ab80f..d5cf63b 100644 --- a/services/ble_profiles/find/findt/src/findt.c +++ b/services/ble_profiles/find/findt/src/findt.c @@ -23,14 +23,16 @@ **************************************************************************************** */ /// Full IAS Database Description - Used to add attributes into the database -const struct attm_desc findt_att_db[FINDT_IAS_IDX_NB] = -{ +const struct attm_desc findt_att_db[FINDT_IAS_IDX_NB] = { // Immediate Alert Service Declaration - [FINDT_IAS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [FINDT_IAS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // Alert Level Characteristic Declaration - [FINDT_IAS_IDX_ALERT_LVL_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [FINDT_IAS_IDX_ALERT_LVL_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), + 0, 0}, // Alert Level Characteristic Value - [FINDT_IAS_IDX_ALERT_LVL_VAL] = {ATT_CHAR_ALERT_LEVEL, PERM(WRITE_COMMAND, ENABLE), PERM(RI, ENABLE), sizeof(uint8_t)}, + [FINDT_IAS_IDX_ALERT_LVL_VAL] = {ATT_CHAR_ALERT_LEVEL, + PERM(WRITE_COMMAND, ENABLE), + PERM(RI, ENABLE), sizeof(uint8_t)}, }; /* @@ -50,68 +52,73 @@ const struct attm_desc findt_att_db[FINDT_IAS_IDX_NB] = * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t findt_init (struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, - uint8_t sec_lvl, struct findt_db_cfg* params) -{ - //------------------ create the attribute database for the profile ------------------- +static uint8_t findt_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, + struct findt_db_cfg *params) { + //------------------ create the attribute database for the profile + //------------------- - // Service content flag - uint32_t cfg_flag = FINDT_MANDATORY_MASK; - // DB Creation Status - uint8_t status = ATT_ERR_NO_ERROR; + // Service content flag + uint32_t cfg_flag = FINDT_MANDATORY_MASK; + // DB Creation Status + uint8_t status = ATT_ERR_NO_ERROR; - status = attm_svc_create_db(start_hdl, ATT_SVC_IMMEDIATE_ALERT, (uint8_t *)&cfg_flag, - FINDT_IAS_IDX_NB, NULL, env->task, &findt_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | PERM(SVC_MI, DISABLE) ); + status = attm_svc_create_db( + start_hdl, ATT_SVC_IMMEDIATE_ALERT, (uint8_t *)&cfg_flag, + FINDT_IAS_IDX_NB, NULL, env->task, &findt_att_db[0], + (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, DISABLE)); - //-------------------- allocate memory required for the profile --------------------- - if (status == ATT_ERR_NO_ERROR) - { - struct findt_env_tag* findt_env = - (struct findt_env_tag* ) ke_malloc(sizeof(struct findt_env_tag), KE_MEM_ATT_DB); + //-------------------- allocate memory required for the profile + //--------------------- + if (status == ATT_ERR_NO_ERROR) { + struct findt_env_tag *findt_env = (struct findt_env_tag *)ke_malloc( + sizeof(struct findt_env_tag), KE_MEM_ATT_DB); - // allocate FINDT required environment variable - env->env = (prf_env_t*) findt_env; - findt_env->shdl = *start_hdl; - findt_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - findt_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); + // allocate FINDT required environment variable + env->env = (prf_env_t *)findt_env; + findt_env->shdl = *start_hdl; + findt_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + findt_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); + // initialize environment variable + env->id = TASK_ID_FINDT; + findt_task_init(&(env->desc)); - // initialize environment variable - env->id = TASK_ID_FINDT; - findt_task_init(&(env->desc)); - - // service is ready, go into an Idle state - ke_state_set(env->task, FINDT_IDLE); - } - return (status); + // service is ready, go into an Idle state + ke_state_set(env->task, FINDT_IDLE); + } + return (status); } /** **************************************************************************************** * @brief Destruction of the FINDT module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void findt_destroy(struct prf_task_env* env) -{ - struct findt_env_tag* findt_env = (struct findt_env_tag*) env->env; +static void findt_destroy(struct prf_task_env *env) { + struct findt_env_tag *findt_env = (struct findt_env_tag *)env->env; - // free profile environment variables - env->env = NULL; - ke_free(findt_env); + // free profile environment variables + env->env = NULL; + ke_free(findt_env); } /** @@ -122,9 +129,8 @@ static void findt_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void findt_create(struct prf_task_env* env, uint8_t conidx) -{ - /* nothing to do */ +static void findt_create(struct prf_task_env *env, uint8_t conidx) { + /* nothing to do */ } /** @@ -136,9 +142,9 @@ static void findt_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void findt_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - /* nothing to do */ +static void findt_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + /* nothing to do */ } /* @@ -147,12 +153,11 @@ static void findt_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reas */ /// FINDT Task interface required by profile manager -const struct prf_task_cbs findt_itf = -{ - (prf_init_fnct) findt_init, - findt_destroy, - findt_create, - findt_cleanup, +const struct prf_task_cbs findt_itf = { + (prf_init_fnct)findt_init, + findt_destroy, + findt_create, + findt_cleanup, }; /* @@ -160,12 +165,8 @@ const struct prf_task_cbs findt_itf = **************************************************************************************** */ -const struct prf_task_cbs* findt_prf_itf_get(void) -{ - return &findt_itf; -} +const struct prf_task_cbs *findt_prf_itf_get(void) { return &findt_itf; } - -#endif //BLE_FINDME_TARGET +#endif // BLE_FINDME_TARGET /// @} FINDT diff --git a/services/ble_profiles/find/findt/src/findt_task.c b/services/ble_profiles/find/findt/src/findt_task.c index ccb9303..1fa7e0b 100644 --- a/services/ble_profiles/find/findt/src/findt_task.c +++ b/services/ble_profiles/find/findt/src/findt_task.c @@ -12,14 +12,13 @@ #include "rwip_config.h" #if (BLE_FINDME_TARGET) -#include "co_utils.h" -#include "gattc_task.h" -#include "findt_task.h" -#include "findt.h" #include "attm.h" +#include "co_utils.h" +#include "findt.h" +#include "findt_task.h" +#include "gattc_task.h" #include "prf_utils.h" - /* * FUNCTION DEFINITIONS **************************************************************************************** @@ -28,10 +27,10 @@ /** **************************************************************************************** * @brief Handles reception of the @ref GATTC_WRITE_REQ_IND message. - * The message is redirected from TASK_SVC because at profile enable, the ATT handle is - * register for TASK_FINDT. In the handler, an ATT Write Response/Error Response should - * be sent for ATT protocol, but Alert Level Characteristic only supports WNR so no - * response PDU is needed. + * The message is redirected from TASK_SVC because at profile enable, the ATT + *handle is register for TASK_FINDT. In the handler, an ATT Write Response/Error + *Response should be sent for ATT protocol, but Alert Level Characteristic only + *supports WNR so no response PDU is needed. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -39,47 +38,45 @@ * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_write_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t alert_lvl = 0x0000; - uint8_t conidx = KE_IDX_GET(src_id); - // Allocate write confirmation message. - struct gattc_write_cfm *cfm = KE_MSG_ALLOC(GATTC_WRITE_CFM, - src_id, dest_id, gattc_write_cfm); +__STATIC int gattc_write_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + uint8_t alert_lvl = 0x0000; + uint8_t conidx = KE_IDX_GET(src_id); + // Allocate write confirmation message. + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - // Get the address of the environment - struct findt_env_tag *findt_env = PRF_ENV_GET(FINDT, findt); - uint8_t att_idx = FINDT_IDX(param->handle); + // Get the address of the environment + struct findt_env_tag *findt_env = PRF_ENV_GET(FINDT, findt); + uint8_t att_idx = FINDT_IDX(param->handle); + // Fill in the parameter structure + cfm->handle = param->handle; + cfm->status = PRF_APP_ERROR; + + // Check if Alert Level is valid + if ((att_idx == FINDT_IAS_IDX_ALERT_LVL_VAL) && + (param->value[0] <= FINDT_ALERT_HIGH)) { + alert_lvl = param->value[0]; + cfm->status = GAP_ERR_NO_ERROR; + + // Allocate the alert value change indication + struct findt_alert_ind *ind = KE_MSG_ALLOC( + FINDT_ALERT_IND, prf_dst_task_get(&(findt_env->prf_env), conidx), + dest_id, findt_alert_ind); // Fill in the parameter structure - cfm->handle = param->handle; - cfm->status = PRF_APP_ERROR; - - //Check if Alert Level is valid - if((att_idx == FINDT_IAS_IDX_ALERT_LVL_VAL) && (param->value[0] <= FINDT_ALERT_HIGH)) - { - alert_lvl = param->value[0]; - cfm->status = GAP_ERR_NO_ERROR; - - // Allocate the alert value change indication - struct findt_alert_ind *ind = KE_MSG_ALLOC(FINDT_ALERT_IND, - prf_dst_task_get(&(findt_env->prf_env), conidx), - dest_id, findt_alert_ind); - // Fill in the parameter structure - ind->alert_lvl = alert_lvl; - ind->conidx = conidx; - - // Send the message - ke_msg_send(ind); - } + ind->alert_lvl = alert_lvl; + ind->conidx = conidx; // Send the message - ke_msg_send(cfm); + ke_msg_send(ind); + } - return (KE_MSG_CONSUMED); + // Send the message + ke_msg_send(cfm); + + return (KE_MSG_CONSUMED); } /* @@ -88,22 +85,20 @@ __STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, */ /// Default State handlers definition -KE_MSG_HANDLER_TAB(findt) -{ - {GATTC_WRITE_REQ_IND, (ke_msg_func_t) gattc_write_req_ind_handler}, +KE_MSG_HANDLER_TAB(findt){ + {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, }; -void findt_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct findt_env_tag *findt_env = PRF_ENV_GET(FINDT, findt); +void findt_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct findt_env_tag *findt_env = PRF_ENV_GET(FINDT, findt); - task_desc->msg_handler_tab = findt_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(findt_msg_handler_tab); - task_desc->state = findt_env->state; - task_desc->idx_max = FINDT_IDX_MAX; + task_desc->msg_handler_tab = findt_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(findt_msg_handler_tab); + task_desc->state = findt_env->state; + task_desc->idx_max = FINDT_IDX_MAX; } -#endif //BLE_FINDME_TARGET +#endif // BLE_FINDME_TARGET /// @} FINDTTASK diff --git a/services/ble_profiles/gfps/gfps_provider/src/gfps_provider.c b/services/ble_profiles/gfps/gfps_provider/src/gfps_provider.c index 05994ec..4e01925 100644 --- a/services/ble_profiles/gfps/gfps_provider/src/gfps_provider.c +++ b/services/ble_profiles/gfps/gfps_provider/src/gfps_provider.c @@ -13,11 +13,11 @@ #if (BLE_GFPS_PROVIDER) #include "attm.h" +#include "gfps_crypto.h" #include "gfps_provider.h" #include "gfps_provider_task.h" -#include "gfps_crypto.h" -#include "prf_utils.h" #include "prf.h" +#include "prf_utils.h" #include "ke_mem.h" @@ -29,104 +29,178 @@ */ /// Maximal length for Characteristic values - 128 bytes -#define GFPSP_VAL_MAX_LEN (128) -///System ID string length -#define GFPSP_SYS_ID_LEN (0x08) -///IEEE Certif length (min 6 bytes) -#define GFPSP_IEEE_CERTIF_MIN_LEN (0x06) -///PnP ID length -#define GFPSP_PNP_ID_LEN (0x07) +#define GFPSP_VAL_MAX_LEN (128) +/// System ID string length +#define GFPSP_SYS_ID_LEN (0x08) +/// IEEE Certif length (min 6 bytes) +#define GFPSP_IEEE_CERTIF_MIN_LEN (0x06) +/// PnP ID length +#define GFPSP_PNP_ID_LEN (0x07) #define GFPS_USE_128BIT_UUIDx #ifdef GFPS_USE_128BIT_UUID -static const uint8_t ATT_SVC_GOOGLE_FAST_PAIR_PROVIDER[ATT_UUID_16_LEN] = {0x2C, 0xFE}; +static const uint8_t ATT_SVC_GOOGLE_FAST_PAIR_PROVIDER[ATT_UUID_16_LEN] = { + 0x2C, 0xFE}; /*------------------- UNITS ---------------------*/ /*---------------- DECLARATIONS -----------------*/ -#define ATT_DECL_PRIMARY_SERVICE_UUID { 0x00, 0x28 } -#define ATT_DECL_CHARACTERISTIC_UUID { 0x03, 0x28 } -#define ATT_DESC_CLIENT_CHAR_CFG_UUID { 0x02, 0x29 } +#define ATT_DECL_PRIMARY_SERVICE_UUID \ + { 0x00, 0x28 } +#define ATT_DECL_CHARACTERISTIC_UUID \ + { 0x03, 0x28 } +#define ATT_DESC_CLIENT_CHAR_CFG_UUID \ + { 0x02, 0x29 } /*----------------- DESCRIPTORS -----------------*/ /*--------------- CHARACTERISTICS ---------------*/ -#define ATT_CHAR_KEY_BASED_PAIRING {0xEA, 0x0B, 0x10, 0x32, 0xDE, 0x01, 0xB0, 0x8E, 0x14, 0x48, 0x66, 0x83, 0x34, 0x12, 0x2C, 0xFE} -#define ATT_CHAR_PASSKEY {0xEA, 0x0B, 0x10, 0x32, 0xDE, 0x01, 0xB0, 0x8E, 0x14, 0x48, 0x66, 0x83, 0x35, 0x12, 0x2C, 0xFE} -#define ATT_CHAR_ACCOUNTKEY {0xEA, 0x0B, 0x10, 0x32, 0xDE, 0x01, 0xB0, 0x8E, 0x14, 0x48, 0x66, 0x83, 0x36, 0x12, 0x2C, 0xFE} -#define ATT_CHAR_NAME {0xEA, 0x0B, 0x10, 0x32, 0xDE, 0x01, 0xB0, 0x8E, 0x14, 0x48, 0x66, 0x83, 0x37, 0x12, 0x2C, 0xFE} +#define ATT_CHAR_KEY_BASED_PAIRING \ + { \ + 0xEA, 0x0B, 0x10, 0x32, 0xDE, 0x01, 0xB0, 0x8E, 0x14, 0x48, 0x66, 0x83, \ + 0x34, 0x12, 0x2C, 0xFE \ + } +#define ATT_CHAR_PASSKEY \ + { \ + 0xEA, 0x0B, 0x10, 0x32, 0xDE, 0x01, 0xB0, 0x8E, 0x14, 0x48, 0x66, 0x83, \ + 0x35, 0x12, 0x2C, 0xFE \ + } +#define ATT_CHAR_ACCOUNTKEY \ + { \ + 0xEA, 0x0B, 0x10, 0x32, 0xDE, 0x01, 0xB0, 0x8E, 0x14, 0x48, 0x66, 0x83, \ + 0x36, 0x12, 0x2C, 0xFE \ + } +#define ATT_CHAR_NAME \ + { \ + 0xEA, 0x0B, 0x10, 0x32, 0xDE, 0x01, 0xB0, 0x8E, 0x14, 0x48, 0x66, 0x83, \ + 0x37, 0x12, 0x2C, 0xFE \ + } /* * DIS ATTRIBUTES **************************************************************************************** - */ - -const struct attm_desc_128 gfpsp_att_db[GFPSP_IDX_NB] = -{ + */ + +const struct attm_desc_128 gfpsp_att_db[GFPSP_IDX_NB] = { // Google fast pair service provider Declaration - [GFPSP_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE_UUID, PERM(RD, ENABLE), 0, 0}, + [GFPSP_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE_UUID, PERM(RD, ENABLE), 0, 0}, - [GFPSP_IDX_KEY_BASED_PAIRING_CHAR] = {ATT_DECL_CHARACTERISTIC_UUID, PERM(RD, ENABLE), 0, 0}, - [GFPSP_IDX_KEY_BASED_PAIRING_VAL] = {ATT_CHAR_KEY_BASED_PAIRING, PERM(NTF, ENABLE) | PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE) | PERM_VAL(UUID_LEN, PERM_UUID_128), GFPSP_VAL_MAX_LEN}, - [GFPSP_IDX_KEY_BASED_PAIRING_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG_UUID, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE), sizeof(uint16_t)}, - - - [GFPSP_IDX_PASSKEY_CHAR] = {ATT_DECL_CHARACTERISTIC_UUID, PERM(RD, ENABLE), 0, 0}, - [GFPSP_IDX_PASSKEY_VAL] = {ATT_CHAR_PASSKEY, PERM(NTF, ENABLE) | PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE) | PERM_VAL(UUID_LEN, PERM_UUID_128), GFPSP_VAL_MAX_LEN}, - [GFPSP_IDX_PASSKEY_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG_UUID, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE), sizeof(uint16_t)}, - - [GFPSP_IDX_ACCOUNT_KEY_CHAR] = {ATT_DECL_CHARACTERISTIC_UUID, PERM(RD, ENABLE)|PERM(WRITE_REQ, ENABLE), 0, GFPSP_VAL_MAX_LEN}, - [GFPSP_IDX_ACCOUNT_KEY_VAL] = {ATT_CHAR_ACCOUNTKEY, PERM(NTF, ENABLE) |PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE) | PERM_VAL(UUID_LEN, PERM_UUID_128), GFPSP_VAL_MAX_LEN}, - [GFPSP_IDX_ACCOUNT_KEY_CFG] = {ATT_DESC_CLIENT_CHAR_CFG_UUID, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE), GFPSP_VAL_MAX_LEN}, + [GFPSP_IDX_KEY_BASED_PAIRING_CHAR] = {ATT_DECL_CHARACTERISTIC_UUID, + PERM(RD, ENABLE), 0, 0}, + [GFPSP_IDX_KEY_BASED_PAIRING_VAL] = {ATT_CHAR_KEY_BASED_PAIRING, + PERM(NTF, ENABLE) | + PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE) | + PERM_VAL(UUID_LEN, PERM_UUID_128), + GFPSP_VAL_MAX_LEN}, + [GFPSP_IDX_KEY_BASED_PAIRING_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG_UUID, + PERM(RD, ENABLE) | + PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE), + sizeof(uint16_t)}, - [GFPSP_IDX_NAME_CHAR] = {ATT_DECL_CHARACTERISTIC_UUID, PERM(RD, ENABLE)|PERM(WRITE_REQ, ENABLE), 0, GFPSP_VAL_MAX_LEN}, - [GFPSP_IDX_NAME_VAL] = {ATT_CHAR_NAME, PERM(NTF, ENABLE) |PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE) | PERM_VAL(UUID_LEN, PERM_UUID_128), GFPSP_VAL_MAX_LEN}, - [GFPSP_IDX_NAME_CFG] = {ATT_DESC_CLIENT_CHAR_CFG_UUID, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE), GFPSP_VAL_MAX_LEN}, + [GFPSP_IDX_PASSKEY_CHAR] = {ATT_DECL_CHARACTERISTIC_UUID, PERM(RD, ENABLE), + 0, 0}, + [GFPSP_IDX_PASSKEY_VAL] = {ATT_CHAR_PASSKEY, + PERM(NTF, ENABLE) | PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE) | + PERM_VAL(UUID_LEN, PERM_UUID_128), + GFPSP_VAL_MAX_LEN}, + [GFPSP_IDX_PASSKEY_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG_UUID, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE), sizeof(uint16_t)}, + + [GFPSP_IDX_ACCOUNT_KEY_CHAR] = {ATT_DECL_CHARACTERISTIC_UUID, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + 0, GFPSP_VAL_MAX_LEN}, + [GFPSP_IDX_ACCOUNT_KEY_VAL] = {ATT_CHAR_ACCOUNTKEY, + PERM(NTF, ENABLE) | PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE) | + PERM_VAL(UUID_LEN, PERM_UUID_128), + GFPSP_VAL_MAX_LEN}, + [GFPSP_IDX_ACCOUNT_KEY_CFG] = {ATT_DESC_CLIENT_CHAR_CFG_UUID, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE), GFPSP_VAL_MAX_LEN}, + + [GFPSP_IDX_NAME_CHAR] = {ATT_DECL_CHARACTERISTIC_UUID, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, + GFPSP_VAL_MAX_LEN}, + [GFPSP_IDX_NAME_VAL] = {ATT_CHAR_NAME, + PERM(NTF, ENABLE) | PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE) | + PERM_VAL(UUID_LEN, PERM_UUID_128), + GFPSP_VAL_MAX_LEN}, + [GFPSP_IDX_NAME_CFG] = {ATT_DESC_CLIENT_CHAR_CFG_UUID, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE), GFPSP_VAL_MAX_LEN}, }; #else enum { -/*----------------- SERVICES ---------------------*/ -/// -ATT_SVC_GOOGLE_FAST_PAIR_PROVIDER = ATT_UUID_16(0xFE2C), -/*------------------- UNITS ---------------------*/ + /*----------------- SERVICES ---------------------*/ + /// + ATT_SVC_GOOGLE_FAST_PAIR_PROVIDER = ATT_UUID_16(0xFE2C), + /*------------------- UNITS ---------------------*/ -/*---------------- DECLARATIONS -----------------*/ -/*----------------- DESCRIPTORS -----------------*/ -/*--------------- CHARACTERISTICS ---------------*/ -ATT_CHAR_KEY_BASED_PAIRING = ATT_UUID_16(0x1234), -ATT_CHAR_PASSKEY = ATT_UUID_16(0x1235), -ATT_CHAR_ACCOUNTKEY = ATT_UUID_16(0x1236), -ATT_CHAR_NAME = ATT_UUID_16(0x1237), + /*---------------- DECLARATIONS -----------------*/ + /*----------------- DESCRIPTORS -----------------*/ + /*--------------- CHARACTERISTICS ---------------*/ + ATT_CHAR_KEY_BASED_PAIRING = ATT_UUID_16(0x1234), + ATT_CHAR_PASSKEY = ATT_UUID_16(0x1235), + ATT_CHAR_ACCOUNTKEY = ATT_UUID_16(0x1236), + ATT_CHAR_NAME = ATT_UUID_16(0x1237), }; /* * DIS ATTRIBUTES **************************************************************************************** - */ - -const struct attm_desc gfpsp_att_db[GFPSP_IDX_NB] = -{ + */ + +const struct attm_desc gfpsp_att_db[GFPSP_IDX_NB] = { // Google fast pair service provider Declaration - [GFPSP_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [GFPSP_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, - [GFPSP_IDX_KEY_BASED_PAIRING_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, - [GFPSP_IDX_KEY_BASED_PAIRING_VAL] = {ATT_CHAR_KEY_BASED_PAIRING, PERM(NTF, ENABLE) | PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE), GFPSP_VAL_MAX_LEN}, - [GFPSP_IDX_KEY_BASED_PAIRING_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE), sizeof(uint16_t)}, - - - [GFPSP_IDX_PASSKEY_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, - [GFPSP_IDX_PASSKEY_VAL] = {ATT_CHAR_PASSKEY, PERM(NTF, ENABLE) | PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE), GFPSP_VAL_MAX_LEN}, - [GFPSP_IDX_PASSKEY_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE), sizeof(uint16_t)}, - - [GFPSP_IDX_ACCOUNT_KEY_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE)|PERM(WRITE_REQ, ENABLE), 0, GFPSP_VAL_MAX_LEN}, - [GFPSP_IDX_ACCOUNT_KEY_VAL] = {ATT_CHAR_ACCOUNTKEY, PERM(NTF, ENABLE) |PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE), GFPSP_VAL_MAX_LEN}, - [GFPSP_IDX_ACCOUNT_KEY_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE), GFPSP_VAL_MAX_LEN}, + [GFPSP_IDX_KEY_BASED_PAIRING_CHAR] = {ATT_DECL_CHARACTERISTIC, + PERM(RD, ENABLE), 0, 0}, + [GFPSP_IDX_KEY_BASED_PAIRING_VAL] = {ATT_CHAR_KEY_BASED_PAIRING, + PERM(NTF, ENABLE) | + PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE), GFPSP_VAL_MAX_LEN}, + [GFPSP_IDX_KEY_BASED_PAIRING_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | + PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE), + sizeof(uint16_t)}, - [GFPSP_IDX_NAME_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE)|PERM(WRITE_REQ, ENABLE), 0, GFPSP_VAL_MAX_LEN}, - [GFPSP_IDX_NAME_VAL] = {ATT_CHAR_NAME, PERM(NTF, ENABLE) |PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE), GFPSP_VAL_MAX_LEN}, - [GFPSP_IDX_NAME_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE), GFPSP_VAL_MAX_LEN}, + [GFPSP_IDX_PASSKEY_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, + [GFPSP_IDX_PASSKEY_VAL] = {ATT_CHAR_PASSKEY, + PERM(NTF, ENABLE) | PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE), GFPSP_VAL_MAX_LEN}, + [GFPSP_IDX_PASSKEY_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE), sizeof(uint16_t)}, + + [GFPSP_IDX_ACCOUNT_KEY_CHAR] = {ATT_DECL_CHARACTERISTIC, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + 0, GFPSP_VAL_MAX_LEN}, + [GFPSP_IDX_ACCOUNT_KEY_VAL] = {ATT_CHAR_ACCOUNTKEY, + PERM(NTF, ENABLE) | PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE), GFPSP_VAL_MAX_LEN}, + [GFPSP_IDX_ACCOUNT_KEY_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE), GFPSP_VAL_MAX_LEN}, + + [GFPSP_IDX_NAME_CHAR] = {ATT_DECL_CHARACTERISTIC, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, + GFPSP_VAL_MAX_LEN}, + [GFPSP_IDX_NAME_VAL] = {ATT_CHAR_NAME, + PERM(NTF, ENABLE) | PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE), GFPSP_VAL_MAX_LEN}, + [GFPSP_IDX_NAME_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE), GFPSP_VAL_MAX_LEN}, }; #endif @@ -148,86 +222,92 @@ const struct attm_desc gfpsp_att_db[GFPSP_IDX_NB] = * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t gfpsp_init (struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, struct gfpsp_db_cfg* params) -{ - //------------------ create the attribute database for the profile ------------------- +static uint8_t gfpsp_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, + struct gfpsp_db_cfg *params) { + //------------------ create the attribute database for the profile + //------------------- - // Service content flag - uint32_t cfg_flag; - // DB Creation Statis - uint8_t status = ATT_ERR_NO_ERROR; + // Service content flag + uint32_t cfg_flag; + // DB Creation Statis + uint8_t status = ATT_ERR_NO_ERROR; - - // Compute Attribute Table and save it in environment - cfg_flag = gfpsp_compute_cfg_flag(params->features); + // Compute Attribute Table and save it in environment + cfg_flag = gfpsp_compute_cfg_flag(params->features); #ifdef GFPS_USE_128BIT_UUID - status = attm_svc_create_db_128(start_hdl, ATT_SVC_GOOGLE_FAST_PAIR_PROVIDER, (uint8_t *)&cfg_flag, - GFPSP_IDX_NB, NULL, env->task, &gfpsp_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS))); + status = attm_svc_create_db_128( + start_hdl, ATT_SVC_GOOGLE_FAST_PAIR_PROVIDER, (uint8_t *)&cfg_flag, + GFPSP_IDX_NB, NULL, env->task, &gfpsp_att_db[0], + (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS))); #else - status = attm_svc_create_db(start_hdl, ATT_SVC_GOOGLE_FAST_PAIR_PROVIDER, (uint8_t *)&cfg_flag, - GFPSP_IDX_NB, NULL, env->task, &gfpsp_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS))); + status = attm_svc_create_db( + start_hdl, ATT_SVC_GOOGLE_FAST_PAIR_PROVIDER, (uint8_t *)&cfg_flag, + GFPSP_IDX_NB, NULL, env->task, &gfpsp_att_db[0], + (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS))); #endif - //-------------------- allocate memory required for the profile --------------------- - if (status == ATT_ERR_NO_ERROR) - { - struct gfpsp_env_tag* gfpsp_env = - (struct gfpsp_env_tag* ) ke_malloc(sizeof(struct gfpsp_env_tag), KE_MEM_ATT_DB); + //-------------------- allocate memory required for the profile + //--------------------- + if (status == ATT_ERR_NO_ERROR) { + struct gfpsp_env_tag *gfpsp_env = (struct gfpsp_env_tag *)ke_malloc( + sizeof(struct gfpsp_env_tag), KE_MEM_ATT_DB); - // allocate GFPSP required environment variable - env->env = (prf_env_t*) gfpsp_env; - gfpsp_env->start_hdl = *start_hdl; - gfpsp_env->features = params->features; - gfpsp_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - gfpsp_env->prf_env.prf_task = env->task | - (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); + // allocate GFPSP required environment variable + env->env = (prf_env_t *)gfpsp_env; + gfpsp_env->start_hdl = *start_hdl; + gfpsp_env->features = params->features; + gfpsp_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + gfpsp_env->prf_env.prf_task = + env->task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); - // initialize environment variable - env->id = TASK_ID_GFPSP; - gfpsp_task_init(&(env->desc)); - co_list_init(&(gfpsp_env->values)); + // initialize environment variable + env->id = TASK_ID_GFPSP; + gfpsp_task_init(&(env->desc)); + co_list_init(&(gfpsp_env->values)); - // service is ready, go into an Idle state - ke_state_set(env->task, GFPSP_IDLE); - } + // service is ready, go into an Idle state + ke_state_set(env->task, GFPSP_IDLE); + } - return (status); + return (status); } /** **************************************************************************************** * @brief Destruction of the GFPSP module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void gfpsp_destroy(struct prf_task_env* env) -{ - struct gfpsp_env_tag* gfpsp_env = (struct gfpsp_env_tag*) env->env; +static void gfpsp_destroy(struct prf_task_env *env) { + struct gfpsp_env_tag *gfpsp_env = (struct gfpsp_env_tag *)env->env; - // remove all values present in list - while(!co_list_is_empty(&(gfpsp_env->values))) - { - struct co_list_hdr* hdr = co_list_pop_front(&(gfpsp_env->values)); - ke_free(hdr); - } + // remove all values present in list + while (!co_list_is_empty(&(gfpsp_env->values))) { + struct co_list_hdr *hdr = co_list_pop_front(&(gfpsp_env->values)); + ke_free(hdr); + } - // free profile environment variables - env->env = NULL; - ke_free(gfpsp_env); + // free profile environment variables + env->env = NULL; + ke_free(gfpsp_env); } /** @@ -238,9 +318,8 @@ static void gfpsp_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void gfpsp_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Nothing to do */ +static void gfpsp_create(struct prf_task_env *env, uint8_t conidx) { + /* Nothing to do */ } /** @@ -252,9 +331,9 @@ static void gfpsp_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void gfpsp_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - /* Nothing to do */ +static void gfpsp_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + /* Nothing to do */ } /* @@ -263,12 +342,11 @@ static void gfpsp_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reas */ /// GFPSP Task interface required by profile manager -const struct prf_task_cbs gfpsp_itf = -{ - (prf_init_fnct) gfpsp_init, - gfpsp_destroy, - gfpsp_create, - gfpsp_cleanup, +const struct prf_task_cbs gfpsp_itf = { + (prf_init_fnct)gfpsp_init, + gfpsp_destroy, + gfpsp_create, + gfpsp_cleanup, }; /* @@ -276,138 +354,116 @@ const struct prf_task_cbs gfpsp_itf = **************************************************************************************** */ -const struct prf_task_cbs* gfpsp_prf_itf_get(void) -{ - return &gfpsp_itf; -} +const struct prf_task_cbs *gfpsp_prf_itf_get(void) { return &gfpsp_itf; } -uint32_t gfpsp_compute_cfg_flag(uint16_t features) -{ - //Service Declaration - uint32_t cfg_flag = 1; +uint32_t gfpsp_compute_cfg_flag(uint16_t features) { + // Service Declaration + uint32_t cfg_flag = 1; - for (uint8_t i = 0; i> i) & 1) == 1) - { - cfg_flag |= (3 << (i*2 + 1)); - } + for (uint8_t i = 0; i < GFPSP_CHAR_MAX; i++) { + if (((features >> i) & 1) == 1) { + cfg_flag |= (3 << (i * 2 + 1)); } + } - return cfg_flag; + return cfg_flag; } +uint8_t gfpsp_handle_to_value(struct gfpsp_env_tag *env, uint16_t handle) { + uint8_t value = GFPSP_CHAR_MAX; -uint8_t gfpsp_handle_to_value(struct gfpsp_env_tag* env, uint16_t handle) -{ - uint8_t value = GFPSP_CHAR_MAX; + // handle cursor, start from first characteristic of service handle + uint16_t cur_hdl = env->start_hdl + 1; - // handle cursor, start from first characteristic of service handle - uint16_t cur_hdl = env->start_hdl + 1; - - for (uint8_t i = 0; ifeatures >> i) & 1) == 1) - { - // check if value handle correspond to requested handle - if((cur_hdl +1) == handle) - { - value = i; - break; - } - cur_hdl += 2; - } + for (uint8_t i = 0; i < GFPSP_CHAR_MAX; i++) { + if (((env->features >> i) & 1) == 1) { + // check if value handle correspond to requested handle + if ((cur_hdl + 1) == handle) { + value = i; + break; + } + cur_hdl += 2; } + } - return value; + return value; } -uint16_t gfpsp_value_to_handle(struct gfpsp_env_tag* env, uint8_t value) -{ - uint16_t handle = env->start_hdl + 1; - int8_t i; +uint16_t gfpsp_value_to_handle(struct gfpsp_env_tag *env, uint8_t value) { + uint16_t handle = env->start_hdl + 1; + int8_t i; - for (i = 0; ifeatures >> i) & 1) == 1) - { - // requested value - if(value == i) - { - handle += 1; - break; - } - handle += 2; - } + for (i = 0; i < GFPSP_CHAR_MAX; i++) { + if (((env->features >> i) & 1) == 1) { + // requested value + if (value == i) { + handle += 1; + break; + } + handle += 2; } + } - // check if handle found - return ((i == GFPSP_CHAR_MAX) ? ATT_INVALID_HDL : handle); + // check if handle found + return ((i == GFPSP_CHAR_MAX) ? ATT_INVALID_HDL : handle); } -uint8_t gfpsp_check_val_len(uint8_t char_code, uint8_t val_len) -{ - uint8_t status = GAP_ERR_NO_ERROR; +uint8_t gfpsp_check_val_len(uint8_t char_code, uint8_t val_len) { + uint8_t status = GAP_ERR_NO_ERROR; - // Check if length is upper than the general maximal length - if (val_len > GFPSP_VAL_MAX_LEN) - { + // Check if length is upper than the general maximal length + if (val_len > GFPSP_VAL_MAX_LEN) { + status = PRF_ERR_UNEXPECTED_LEN; + } else { + // Check if length matches particular requirements + switch (char_code) { + case GFPSP_SYSTEM_ID_CHAR: + if (val_len != GFPSP_SYS_ID_LEN) { status = PRF_ERR_UNEXPECTED_LEN; + } + break; + case GFPSP_IEEE_CHAR: + if (val_len < GFPSP_IEEE_CERTIF_MIN_LEN) { + status = PRF_ERR_UNEXPECTED_LEN; + } + break; + case GFPSP_PNP_ID_CHAR: + if (val_len != GFPSP_PNP_ID_LEN) { + status = PRF_ERR_UNEXPECTED_LEN; + } + break; + default: + break; } - else - { - // Check if length matches particular requirements - switch (char_code) - { - case GFPSP_SYSTEM_ID_CHAR: - if (val_len != GFPSP_SYS_ID_LEN) - { - status = PRF_ERR_UNEXPECTED_LEN; - } - break; - case GFPSP_IEEE_CHAR: - if (val_len < GFPSP_IEEE_CERTIF_MIN_LEN) - { - status = PRF_ERR_UNEXPECTED_LEN; - } - break; - case GFPSP_PNP_ID_CHAR: - if (val_len != GFPSP_PNP_ID_LEN) - { - status = PRF_ERR_UNEXPECTED_LEN; - } - break; - default: - break; - } - } + } - return (status); + return (status); } - -uint32_t gfpsp_crypto_gen_DHKey(const uint8_t *in_PubKey,const uint8_t *in_PrivateKey,uint8_t *out_DHKey) -{ - return gfps_crypto_gen_DHKey(in_PubKey,in_PrivateKey,out_DHKey); +uint32_t gfpsp_crypto_gen_DHKey(const uint8_t *in_PubKey, + const uint8_t *in_PrivateKey, + uint8_t *out_DHKey) { + return gfps_crypto_gen_DHKey(in_PubKey, in_PrivateKey, out_DHKey); } -uint32_t gfpsp_crypto_make_P256_key(uint8_t * out_public_key,uint8_t * out_private_key) -{ - return gfps_crypto_make_P256_key(out_public_key,out_private_key); +uint32_t gfpsp_crypto_make_P256_key(uint8_t *out_public_key, + uint8_t *out_private_key) { + return gfps_crypto_make_P256_key(out_public_key, out_private_key); } #else -uint32_t gfpsp_crypto_gen_DHKey(const uint8_t *in_PubKey,const uint8_t *in_PrivateKey,uint8_t *out_DHKey) -{ - return 1; +uint32_t gfpsp_crypto_gen_DHKey(const uint8_t *in_PubKey, + const uint8_t *in_PrivateKey, + uint8_t *out_DHKey) { + return 1; } -uint32_t gfpsp_crypto_make_P256_key(uint8_t * out_public_key,uint8_t * out_private_key) -{ - return 1; +uint32_t gfpsp_crypto_make_P256_key(uint8_t *out_public_key, + uint8_t *out_private_key) { + return 1; } -#endif //BLE_GFPSP_SERVER +#endif // BLE_GFPSP_SERVER /// @} GFPSP diff --git a/services/ble_profiles/gfps/gfps_provider/src/gfps_provider_task.c b/services/ble_profiles/gfps/gfps_provider/src/gfps_provider_task.c index 739994f..933b619 100644 --- a/services/ble_profiles/gfps/gfps_provider/src/gfps_provider_task.c +++ b/services/ble_profiles/gfps/gfps_provider/src/gfps_provider_task.c @@ -5,7 +5,6 @@ **************************************************************************************** */ - /* * INCLUDE FILES **************************************************************************************** @@ -29,53 +28,52 @@ * FUNCTION DEFINITIONS **************************************************************************************** */ -static void send_notifiction(uint8_t conidx, uint8_t contentType, const uint8_t* ptrData, uint32_t length) -{ - struct gfpsp_env_tag* gfpsp_env = PRF_ENV_GET(GFPSP, gfpsp); +static void send_notifiction(uint8_t conidx, uint8_t contentType, + const uint8_t *ptrData, uint32_t length) { + struct gfpsp_env_tag *gfpsp_env = PRF_ENV_GET(GFPSP, gfpsp); - // Allocate the GATT notification message - struct gattc_send_evt_cmd *report_ntf = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(&gfpsp_env->prf_env, conidx), - gattc_send_evt_cmd, length); + // Allocate the GATT notification message + struct gattc_send_evt_cmd *report_ntf = + KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&gfpsp_env->prf_env, conidx), + gattc_send_evt_cmd, length); - // Fill in the parameter structure - report_ntf->operation = GATTC_NOTIFY; - report_ntf->handle = gfpsp_env->start_hdl + contentType;//GFPSP_IDX_KEY_BASED_PAIRING_VAL;//handle_offset; - // pack measured value in database - report_ntf->length = length; - memcpy(report_ntf->value, ptrData, length); - // send notification to peer device - ke_msg_send(report_ntf); + // Fill in the parameter structure + report_ntf->operation = GATTC_NOTIFY; + report_ntf->handle = + gfpsp_env->start_hdl + + contentType; // GFPSP_IDX_KEY_BASED_PAIRING_VAL;//handle_offset; + // pack measured value in database + report_ntf->length = length; + memcpy(report_ntf->value, ptrData, length); + // send notification to peer device + ke_msg_send(report_ntf); } -__STATIC int send_data_via_notification_handler(ke_msg_id_t const msgid, - struct gfpsp_send_data_req_t const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - send_notifiction(param->connecionIndex, GFPSP_IDX_KEY_BASED_PAIRING_VAL, param->value, param->length); - return (KE_MSG_CONSUMED); +__STATIC int send_data_via_notification_handler( + ke_msg_id_t const msgid, struct gfpsp_send_data_req_t const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + send_notifiction(param->connecionIndex, GFPSP_IDX_KEY_BASED_PAIRING_VAL, + param->value, param->length); + return (KE_MSG_CONSUMED); } -__STATIC int send_passkey_data_via_notification_handler(ke_msg_id_t const msgid, - struct gfpsp_send_data_req_t const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - send_notifiction(param->connecionIndex, GFPSP_IDX_PASSKEY_VAL, param->value, param->length); - return (KE_MSG_CONSUMED); +__STATIC int send_passkey_data_via_notification_handler( + ke_msg_id_t const msgid, struct gfpsp_send_data_req_t const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + send_notifiction(param->connecionIndex, GFPSP_IDX_PASSKEY_VAL, param->value, + param->length); + return (KE_MSG_CONSUMED); } -__STATIC int send_name_via_notification_handler(ke_msg_id_t const msgid, - struct gfpsp_send_data_req_t const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - send_notifiction(param->connecionIndex, GFPSP_IDX_NAME_VAL, param->value, param->length); - return (KE_MSG_CONSUMED); +__STATIC int send_name_via_notification_handler( + ke_msg_id_t const msgid, struct gfpsp_send_data_req_t const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + send_notifiction(param->connecionIndex, GFPSP_IDX_NAME_VAL, param->value, + param->length); + return (KE_MSG_CONSUMED); } - /* * FUNCTION DEFINITIONS **************************************************************************************** @@ -92,218 +90,206 @@ __STATIC int send_name_via_notification_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -uint8_t Encrypted_req[80]={ - 0xb9,0x7b,0x2c,0x4b,0x84,0x59,0x3e,0x69,0xf9,0xc5, - 0x1c,0x6f,0xf9,0xba,0x7e,0xc0,0x27,0xa6,0x13,0x55, - 0x26,0x84,0xbc,0xa2,0xd8,0x95,0xd6,0xf8,0xdd,0x5e, - 0xb5,0x91,0xfe,0xf7,0x31,0x1c,0x19,0x3e,0x38,0x8e, - 0x5f,0x3a,0xe6,0x6b,0x68,0x46,0xc4,0x14,0x1c,0x03, - 0xcb,0xc3,0x18,0x06,0x6b,0x52,0xd9,0x5c,0xa0,0xa2, - 0xb5,0x80,0xd9,0x90,0x4b,0xed,0x46,0x23,0x22,0x9b, - 0x42,0xe7,0xc2,0xde,0x2e,0x2a,0xba,0x7c,0xac,0x2b -}; +uint8_t Encrypted_req[80] = { + 0xb9, 0x7b, 0x2c, 0x4b, 0x84, 0x59, 0x3e, 0x69, 0xf9, 0xc5, 0x1c, 0x6f, + 0xf9, 0xba, 0x7e, 0xc0, 0x27, 0xa6, 0x13, 0x55, 0x26, 0x84, 0xbc, 0xa2, + 0xd8, 0x95, 0xd6, 0xf8, 0xdd, 0x5e, 0xb5, 0x91, 0xfe, 0xf7, 0x31, 0x1c, + 0x19, 0x3e, 0x38, 0x8e, 0x5f, 0x3a, 0xe6, 0x6b, 0x68, 0x46, 0xc4, 0x14, + 0x1c, 0x03, 0xcb, 0xc3, 0x18, 0x06, 0x6b, 0x52, 0xd9, 0x5c, 0xa0, 0xa2, + 0xb5, 0x80, 0xd9, 0x90, 0x4b, 0xed, 0x46, 0x23, 0x22, 0x9b, 0x42, 0xe7, + 0xc2, 0xde, 0x2e, 0x2a, 0xba, 0x7c, 0xac, 0x2b}; -__STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_write_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct gfpsp_env_tag* gfpsp_env = PRF_ENV_GET(GFPSP, gfpsp); - uint8_t conidx = KE_IDX_GET(src_id); +__STATIC int gattc_write_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Get the address of the environment + struct gfpsp_env_tag *gfpsp_env = PRF_ENV_GET(GFPSP, gfpsp); + uint8_t conidx = KE_IDX_GET(src_id); - uint8_t status = GAP_ERR_NO_ERROR; + uint8_t status = GAP_ERR_NO_ERROR; - if (GFPSP_IDX_KEY_BASED_PAIRING_VAL != (param->handle-gfpsp_env->start_hdl) && - (GFPSP_IDX_NAME_VAL != (param->handle-gfpsp_env->start_hdl))) - { - //Send write response - struct gattc_write_cfm *cfm = KE_MSG_ALLOC( - GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = status; - ke_msg_send(cfm); + if (GFPSP_IDX_KEY_BASED_PAIRING_VAL != + (param->handle - gfpsp_env->start_hdl) && + (GFPSP_IDX_NAME_VAL != (param->handle - gfpsp_env->start_hdl))) { + // Send write response + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = status; + ke_msg_send(cfm); + } + + if (gfpsp_env != NULL) { + switch (param->handle - gfpsp_env->start_hdl) { + case GFPSP_IDX_KEY_BASED_PAIRING_VAL: { + // inform APP of data + struct gfpsp_write_ind_t *ind = + KE_MSG_ALLOC_DYN(GFPSP_KEY_BASED_PAIRING_WRITE_IND, + prf_dst_task_get(&gfpsp_env->prf_env, conidx), + prf_src_task_get(&gfpsp_env->prf_env, conidx), + gfpsp_write_ind_t, param->length); + ind->length = param->length; + ind->pendingWriteRsp.dst_task_id = src_id; + ind->pendingWriteRsp.src_task_id = dest_id; + ind->pendingWriteRsp.handle = param->handle; + memcpy((uint8_t *)(ind->data), &(param->value), param->length); + + ke_msg_send(ind); + break; } - - if (gfpsp_env != NULL) - { - switch (param->handle-gfpsp_env->start_hdl) - { - case GFPSP_IDX_KEY_BASED_PAIRING_VAL: - { - //inform APP of data - struct gfpsp_write_ind_t * ind = KE_MSG_ALLOC_DYN(GFPSP_KEY_BASED_PAIRING_WRITE_IND, - prf_dst_task_get(&gfpsp_env->prf_env, conidx), - prf_src_task_get(&gfpsp_env->prf_env, conidx), - gfpsp_write_ind_t, - param->length); - ind->length = param->length; - ind->pendingWriteRsp.dst_task_id = src_id; - ind->pendingWriteRsp.src_task_id = dest_id; - ind->pendingWriteRsp.handle = param->handle; - memcpy((uint8_t *)(ind->data),&(param->value), param->length); + case GFPSP_IDX_KEY_BASED_PAIRING_NTF_CFG: { + uint16_t value = 0x0000; + memcpy(&value, &(param->value), sizeof(uint16_t)); + struct app_gfps_key_based_notif_config_t *ind = + KE_MSG_ALLOC(GFPSP_KEY_BASED_PAIRING_NTF_CFG, + prf_dst_task_get(&gfpsp_env->prf_env, conidx), + prf_src_task_get(&gfpsp_env->prf_env, conidx), + app_gfps_key_based_notif_config_t); - ke_msg_send(ind); - break; - } - case GFPSP_IDX_KEY_BASED_PAIRING_NTF_CFG: - { - uint16_t value = 0x0000; - memcpy(&value, &(param->value), sizeof(uint16_t)); - struct app_gfps_key_based_notif_config_t * ind = KE_MSG_ALLOC(GFPSP_KEY_BASED_PAIRING_NTF_CFG, - prf_dst_task_get(&gfpsp_env->prf_env, conidx), - prf_src_task_get(&gfpsp_env->prf_env, conidx), - app_gfps_key_based_notif_config_t); - - ind->isNotificationEnabled = value; - ke_msg_send(ind); - break; - } - case GFPSP_IDX_PASSKEY_NTF_CFG: - { - uint16_t value = 0x0000; - memcpy(&value, &(param->value), sizeof(uint16_t)); - struct app_gfps_pass_key_notif_config_t * ind = KE_MSG_ALLOC(GFPSP_KEY_PASS_KEY_NTF_CFG, - prf_dst_task_get(&gfpsp_env->prf_env, conidx), - prf_src_task_get(&gfpsp_env->prf_env, conidx), - app_gfps_pass_key_notif_config_t); - - ind->isNotificationEnabled = value; - ke_msg_send(ind); - break; - } - case GFPSP_IDX_PASSKEY_VAL: - { - //inform APP of data - struct gfpsp_write_ind_t * ind = KE_MSG_ALLOC_DYN(GFPSP_KEY_PASS_KEY_WRITE_IND, - prf_dst_task_get(&gfpsp_env->prf_env, conidx), - prf_src_task_get(&gfpsp_env->prf_env, conidx), - gfpsp_write_ind_t, - param->length); - ind->length = param->length; - memcpy((uint8_t *)(ind->data),&(param->value), param->length); - - ke_msg_send(ind); - break; - } - case GFPSP_IDX_ACCOUNT_KEY_VAL: - { - TRACE(0,"Get account key:"); - DUMP8("%02x ", param->value, param->length); - struct gfpsp_write_ind_t * ind = KE_MSG_ALLOC_DYN(GFPSP_KEY_ACCOUNT_KEY_WRITE_IND, - prf_dst_task_get(&gfpsp_env->prf_env, conidx), - prf_src_task_get(&gfpsp_env->prf_env, conidx), - gfpsp_write_ind_t, - param->length); - ind->length = param->length; - memcpy((uint8_t *)(ind->data),&(param->value), param->length); - - ke_msg_send(ind); - break; - } - case GFPSP_IDX_NAME_VAL: - { - TRACE(0,"Get updated name:"); - DUMP8("%02x ", param->value, param->length); - - struct gfpsp_write_ind_t * ind = KE_MSG_ALLOC_DYN(GFPSP_NAME_WRITE_IND, - prf_dst_task_get(&gfpsp_env->prf_env, conidx), - prf_src_task_get(&gfpsp_env->prf_env, conidx), - gfpsp_write_ind_t, - param->length); - ind->length = param->length; - ind->pendingWriteRsp.dst_task_id = src_id; - ind->pendingWriteRsp.src_task_id = dest_id; - ind->pendingWriteRsp.handle = param->handle; - memcpy((uint8_t *)(ind->data),&(param->value), param->length); - - ke_msg_send(ind); - break; - } - default: - { - break; - } - } + ind->isNotificationEnabled = value; + ke_msg_send(ind); + break; } + case GFPSP_IDX_PASSKEY_NTF_CFG: { + uint16_t value = 0x0000; + memcpy(&value, &(param->value), sizeof(uint16_t)); + struct app_gfps_pass_key_notif_config_t *ind = + KE_MSG_ALLOC(GFPSP_KEY_PASS_KEY_NTF_CFG, + prf_dst_task_get(&gfpsp_env->prf_env, conidx), + prf_src_task_get(&gfpsp_env->prf_env, conidx), + app_gfps_pass_key_notif_config_t); - return (KE_MSG_CONSUMED); + ind->isNotificationEnabled = value; + ke_msg_send(ind); + break; + } + case GFPSP_IDX_PASSKEY_VAL: { + // inform APP of data + struct gfpsp_write_ind_t *ind = + KE_MSG_ALLOC_DYN(GFPSP_KEY_PASS_KEY_WRITE_IND, + prf_dst_task_get(&gfpsp_env->prf_env, conidx), + prf_src_task_get(&gfpsp_env->prf_env, conidx), + gfpsp_write_ind_t, param->length); + ind->length = param->length; + memcpy((uint8_t *)(ind->data), &(param->value), param->length); + + ke_msg_send(ind); + break; + } + case GFPSP_IDX_ACCOUNT_KEY_VAL: { + TRACE(0, "Get account key:"); + DUMP8("%02x ", param->value, param->length); + struct gfpsp_write_ind_t *ind = + KE_MSG_ALLOC_DYN(GFPSP_KEY_ACCOUNT_KEY_WRITE_IND, + prf_dst_task_get(&gfpsp_env->prf_env, conidx), + prf_src_task_get(&gfpsp_env->prf_env, conidx), + gfpsp_write_ind_t, param->length); + ind->length = param->length; + memcpy((uint8_t *)(ind->data), &(param->value), param->length); + + ke_msg_send(ind); + break; + } + case GFPSP_IDX_NAME_VAL: { + TRACE(0, "Get updated name:"); + DUMP8("%02x ", param->value, param->length); + + struct gfpsp_write_ind_t *ind = KE_MSG_ALLOC_DYN( + GFPSP_NAME_WRITE_IND, prf_dst_task_get(&gfpsp_env->prf_env, conidx), + prf_src_task_get(&gfpsp_env->prf_env, conidx), gfpsp_write_ind_t, + param->length); + ind->length = param->length; + ind->pendingWriteRsp.dst_task_id = src_id; + ind->pendingWriteRsp.src_task_id = dest_id; + ind->pendingWriteRsp.handle = param->handle; + memcpy((uint8_t *)(ind->data), &(param->value), param->length); + + ke_msg_send(ind); + break; + } + default: { + break; + } + } + } + + return (KE_MSG_CONSUMED); } -__STATIC int gfpsp_send_write_rsp_handler(ke_msg_id_t const msgid, - struct gfpsp_send_write_rsp_t const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - //Send write response - struct gattc_write_cfm *cfm = KE_MSG_ALLOC( - GATTC_WRITE_CFM, param->dst_task_id, param->src_task_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = param->status; - ke_msg_send(cfm); +__STATIC int gfpsp_send_write_rsp_handler( + ke_msg_id_t const msgid, struct gfpsp_send_write_rsp_t const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Send write response + struct gattc_write_cfm *cfm = KE_MSG_ALLOC( + GATTC_WRITE_CFM, param->dst_task_id, param->src_task_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = param->status; + ke_msg_send(cfm); - return KE_MSG_CONSUMED; + return KE_MSG_CONSUMED; } static int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_att_info_req_ind *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct gattc_att_info_cfm * cfm; + struct gattc_att_info_req_ind *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct gattc_att_info_cfm *cfm; - + // Send write response + cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); + cfm->handle = param->handle; - //Send write response - cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); - cfm->handle = param->handle; + struct gfpsp_env_tag *gfpsp_env = PRF_ENV_GET(GFPSP, gfpsp); - struct gfpsp_env_tag* gfpsp_env = PRF_ENV_GET(GFPSP, gfpsp); + TRACE(1, "gattc_att_info_req_ind_handler, is %d", + param->handle - gfpsp_env->start_hdl); - TRACE(1,"gattc_att_info_req_ind_handler, is %d",param->handle-gfpsp_env->start_hdl); + if (param->handle == + (gfpsp_env->start_hdl + GFPSP_KEY_BASED_PAIRING_NTF_CFG)) { + // CCC attribute length = 2 + cfm->length = 2; + cfm->status = GAP_ERR_NO_ERROR; + } else if (param->handle == + (gfpsp_env->start_hdl + GFPSP_KEY_PASS_KEY_NTF_CFG)) { + // CCC attribute length = 2 + cfm->length = 2; + cfm->status = GAP_ERR_NO_ERROR; + } else if (param->handle == + (gfpsp_env->start_hdl + GFPSP_IDX_ACCOUNT_KEY_CFG)) { + // CCC attribute length = 2 + cfm->length = 2; + cfm->status = GAP_ERR_NO_ERROR; + } else if (param->handle == (gfpsp_env->start_hdl + GFPSP_IDX_NAME_CFG)) { + // CCC attribute length = 2 + cfm->length = 2; + cfm->status = GAP_ERR_NO_ERROR; + } else if (param->handle == + (gfpsp_env->start_hdl + GFPSP_IDX_KEY_BASED_PAIRING_VAL)) { + // force length to zero to reject any write starting from something != 0 + cfm->length = 0; + cfm->status = GAP_ERR_NO_ERROR; + } else if (param->handle == (gfpsp_env->start_hdl + GFPSP_IDX_PASSKEY_VAL)) { + // force length to zero to reject any write starting from something != 0 + cfm->length = 0; + cfm->status = GAP_ERR_NO_ERROR; + } else if (param->handle == + (gfpsp_env->start_hdl + GFPSP_IDX_ACCOUNT_KEY_VAL)) { + // force length to zero to reject any write starting from something != 0 + cfm->length = 0; + cfm->status = GAP_ERR_NO_ERROR; + } else if (param->handle == (gfpsp_env->start_hdl + GFPSP_IDX_NAME_VAL)) { + // force length to zero to reject any write starting from something != 0 + cfm->length = 0; + cfm->status = GAP_ERR_NO_ERROR; + } else { + cfm->length = 0; + cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; + } - if (param->handle == (gfpsp_env->start_hdl + GFPSP_KEY_BASED_PAIRING_NTF_CFG)) { - // CCC attribute length = 2 - cfm->length = 2; - cfm->status = GAP_ERR_NO_ERROR; - } else if (param->handle == (gfpsp_env->start_hdl + GFPSP_KEY_PASS_KEY_NTF_CFG)) { - // CCC attribute length = 2 - cfm->length = 2; - cfm->status = GAP_ERR_NO_ERROR; - } else if (param->handle == (gfpsp_env->start_hdl + GFPSP_IDX_ACCOUNT_KEY_CFG)) { - // CCC attribute length = 2 - cfm->length = 2; - cfm->status = GAP_ERR_NO_ERROR; - } else if (param->handle == (gfpsp_env->start_hdl + GFPSP_IDX_NAME_CFG)) { - // CCC attribute length = 2 - cfm->length = 2; - cfm->status = GAP_ERR_NO_ERROR; - } else if (param->handle == (gfpsp_env->start_hdl + GFPSP_IDX_KEY_BASED_PAIRING_VAL)) { - // force length to zero to reject any write starting from something != 0 - cfm->length = 0; - cfm->status = GAP_ERR_NO_ERROR; - } else if (param->handle == (gfpsp_env->start_hdl + GFPSP_IDX_PASSKEY_VAL)) { - // force length to zero to reject any write starting from something != 0 - cfm->length = 0; - cfm->status = GAP_ERR_NO_ERROR; - } else if (param->handle == (gfpsp_env->start_hdl + GFPSP_IDX_ACCOUNT_KEY_VAL)) { - // force length to zero to reject any write starting from something != 0 - cfm->length = 0; - cfm->status = GAP_ERR_NO_ERROR; - } else if (param->handle == (gfpsp_env->start_hdl + GFPSP_IDX_NAME_VAL)) { - // force length to zero to reject any write starting from something != 0 - cfm->length = 0; - cfm->status = GAP_ERR_NO_ERROR; - } - else { - cfm->length = 0; - cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; - } + ke_msg_send(cfm); - ke_msg_send(cfm); - - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /* @@ -312,27 +298,27 @@ static int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, */ // /// Default State handlers definition -KE_MSG_HANDLER_TAB(gfpsp) -{ - {GATTC_WRITE_REQ_IND, (ke_msg_func_t) gattc_write_req_ind_handler}, - {GFPSP_KEY_BASED_PAIRING_WRITE_NOTIFY, (ke_msg_func_t)send_data_via_notification_handler}, - {GFPSP_KEY_PASS_KEY_WRITE_NOTIFY, (ke_msg_func_t)send_passkey_data_via_notification_handler}, - {GFPSP_NAME_NOTIFY, (ke_msg_func_t)send_name_via_notification_handler}, - {GFPSP_SEND_WRITE_RESPONSE, (ke_msg_func_t)gfpsp_send_write_rsp_handler}, - {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t)gattc_att_info_req_ind_handler }, +KE_MSG_HANDLER_TAB(gfpsp){ + {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, + {GFPSP_KEY_BASED_PAIRING_WRITE_NOTIFY, + (ke_msg_func_t)send_data_via_notification_handler}, + {GFPSP_KEY_PASS_KEY_WRITE_NOTIFY, + (ke_msg_func_t)send_passkey_data_via_notification_handler}, + {GFPSP_NAME_NOTIFY, (ke_msg_func_t)send_name_via_notification_handler}, + {GFPSP_SEND_WRITE_RESPONSE, (ke_msg_func_t)gfpsp_send_write_rsp_handler}, + {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t)gattc_att_info_req_ind_handler}, }; -void gfpsp_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct gfpsp_env_tag *gfpsp_env = PRF_ENV_GET(GFPSP, gfpsp); +void gfpsp_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct gfpsp_env_tag *gfpsp_env = PRF_ENV_GET(GFPSP, gfpsp); - task_desc->msg_handler_tab = gfpsp_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(gfpsp_msg_handler_tab); - task_desc->state = gfpsp_env->state; - task_desc->idx_max = GFPSP_IDX_MAX; + task_desc->msg_handler_tab = gfpsp_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(gfpsp_msg_handler_tab); + task_desc->state = gfpsp_env->state; + task_desc->idx_max = GFPSP_IDX_MAX; } -#endif //BLE_GFPS_SERVER +#endif // BLE_GFPS_SERVER /// @} DISSTASK diff --git a/services/ble_profiles/glp/glpc/src/glpc.c b/services/ble_profiles/glp/glpc/src/glpc.c index 87827b9..53c88d1 100644 --- a/services/ble_profiles/glp/glpc/src/glpc.c +++ b/services/ble_profiles/glp/glpc/src/glpc.c @@ -13,13 +13,12 @@ #include "rwip_config.h" #if (BLE_GL_COLLECTOR) +#include "gap.h" #include "glpc.h" #include "glpc_task.h" -#include "gap.h" -#include "ke_mem.h" #include "co_utils.h" - +#include "ke_mem.h" /* * TYPE DEFINITIONS @@ -42,69 +41,70 @@ * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t glpc_init (struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t idx; - //-------------------- allocate memory required for the profile --------------------- +static uint8_t glpc_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t idx; + //-------------------- allocate memory required for the profile + //--------------------- - struct glpc_env_tag* glpc_env = - (struct glpc_env_tag* ) ke_malloc(sizeof(struct glpc_env_tag), KE_MEM_ATT_DB); + struct glpc_env_tag *glpc_env = (struct glpc_env_tag *)ke_malloc( + sizeof(struct glpc_env_tag), KE_MEM_ATT_DB); - // allocate GLPC required environment variable - env->env = (prf_env_t*) glpc_env; + // allocate GLPC required environment variable + env->env = (prf_env_t *)glpc_env; - glpc_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - glpc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + glpc_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + glpc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_GLPC; - glpc_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_GLPC; + glpc_task_init(&(env->desc)); - for(idx = 0; idx < GLPC_IDX_MAX ; idx++) - { - glpc_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), GLPC_FREE); - } + for (idx = 0; idx < GLPC_IDX_MAX; idx++) { + glpc_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), GLPC_FREE); + } - return GAP_ERR_NO_ERROR; + return GAP_ERR_NO_ERROR; } /** **************************************************************************************** * @brief Destruction of the GLPC module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void glpc_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct glpc_env_tag* glpc_env = (struct glpc_env_tag*) env->env; +static void glpc_destroy(struct prf_task_env *env) { + uint8_t idx; + struct glpc_env_tag *glpc_env = (struct glpc_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < GLPC_IDX_MAX ; idx++) - { - if(glpc_env->env[idx] != NULL) - { - ke_free(glpc_env->env[idx]); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < GLPC_IDX_MAX; idx++) { + if (glpc_env->env[idx] != NULL) { + ke_free(glpc_env->env[idx]); } + } - // free profile environment variables - env->env = NULL; - ke_free(glpc_env); + // free profile environment variables + env->env = NULL; + ke_free(glpc_env); } /** @@ -115,10 +115,9 @@ static void glpc_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void glpc_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Put GLP Client in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), GLPC_IDLE); +static void glpc_create(struct prf_task_env *env, uint8_t conidx) { + /* Put GLP Client in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), GLPC_IDLE); } /** @@ -130,19 +129,18 @@ static void glpc_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void glpc_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct glpc_env_tag* glpc_env = (struct glpc_env_tag*) env->env; +static void glpc_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct glpc_env_tag *glpc_env = (struct glpc_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(glpc_env->env[conidx] != NULL) - { - ke_free(glpc_env->env[conidx]); - glpc_env->env[conidx] = NULL; - } + // clean-up environment variable allocated for task instance + if (glpc_env->env[conidx] != NULL) { + ke_free(glpc_env->env[conidx]); + glpc_env->env[conidx] = NULL; + } - /* Put GLP Client in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), GLPC_FREE); + /* Put GLP Client in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), GLPC_FREE); } /* @@ -151,12 +149,11 @@ static void glpc_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reaso */ /// GLPC Task interface required by profile manager -const struct prf_task_cbs glpc_itf = -{ - glpc_init, - glpc_destroy, - glpc_create, - glpc_cleanup, +const struct prf_task_cbs glpc_itf = { + glpc_init, + glpc_destroy, + glpc_create, + glpc_cleanup, }; /* @@ -164,277 +161,247 @@ const struct prf_task_cbs glpc_itf = **************************************************************************************** */ -const struct prf_task_cbs* glpc_prf_itf_get(void) -{ - return &glpc_itf; +const struct prf_task_cbs *glpc_prf_itf_get(void) { return &glpc_itf; } + +void glpc_enable_rsp_send(struct glpc_env_tag *glpc_env, uint8_t conidx, + uint8_t status) { + // Send to APP the details of the discovered attributes on GLPS + struct glpc_enable_rsp *rsp = KE_MSG_ALLOC( + GLPC_ENABLE_RSP, prf_dst_task_get(&(glpc_env->prf_env), conidx), + prf_src_task_get(&(glpc_env->prf_env), conidx), glpc_enable_rsp); + rsp->status = status; + + if (status == GAP_ERR_NO_ERROR) { + rsp->gls = glpc_env->env[conidx]->gls; + // Register GLPC task in gatt for indication/notifications + prf_register_atthdl2gatt(&(glpc_env->prf_env), conidx, + &(glpc_env->env[conidx]->gls.svc)); + // Go to IDLE state + ke_state_set(prf_src_task_get(&(glpc_env->prf_env), conidx), GLPC_IDLE); + } + + ke_msg_send(rsp); } +uint8_t glpc_unpack_meas_value(uint8_t *packed_meas, struct glp_meas *meas_val, + uint16_t *seq_num) { + uint8_t cursor = 0; -void glpc_enable_rsp_send(struct glpc_env_tag *glpc_env, uint8_t conidx, uint8_t status) -{ - // Send to APP the details of the discovered attributes on GLPS - struct glpc_enable_rsp * rsp = KE_MSG_ALLOC(GLPC_ENABLE_RSP, - prf_dst_task_get(&(glpc_env->prf_env), conidx), - prf_src_task_get(&(glpc_env->prf_env), conidx), - glpc_enable_rsp); - rsp->status = status; + // Flags + meas_val->flags = packed_meas[cursor]; + cursor += 1; - if (status == GAP_ERR_NO_ERROR) - { - rsp->gls = glpc_env->env[conidx]->gls; - // Register GLPC task in gatt for indication/notifications - prf_register_atthdl2gatt(&(glpc_env->prf_env), conidx, &(glpc_env->env[conidx]->gls.svc)); - // Go to IDLE state - ke_state_set(prf_src_task_get(&(glpc_env->prf_env), conidx), GLPC_IDLE); - } + // Sequence Number + *seq_num = co_read16p(packed_meas + cursor); + cursor += 2; - ke_msg_send(rsp); -} + // Base Time + cursor += prf_unpack_date_time(packed_meas + cursor, &(meas_val->base_time)); -uint8_t glpc_unpack_meas_value(uint8_t *packed_meas, struct glp_meas* meas_val, - uint16_t *seq_num) -{ - uint8_t cursor = 0; + // Time Offset + if ((meas_val->flags & GLP_MEAS_TIME_OFF_PRES) != 0) { + meas_val->time_offset = co_read16p(packed_meas + cursor); + cursor += 2; + } - // Flags - meas_val->flags = packed_meas[cursor]; - cursor += 1; - - // Sequence Number - *seq_num = co_read16p(packed_meas + cursor); + // Glucose Concentration, type and location + if ((meas_val->flags & GLP_MEAS_GL_CTR_TYPE_AND_SPL_LOC_PRES) != 0) { + meas_val->concentration = co_read16p(packed_meas + cursor); cursor += 2; - // Base Time - cursor += prf_unpack_date_time(packed_meas + cursor, &(meas_val->base_time)); + /* type and location are 2 nibble values */ + meas_val->location = packed_meas[cursor] >> 4; + meas_val->type = packed_meas[cursor] & 0xF; - //Time Offset - if((meas_val->flags & GLP_MEAS_TIME_OFF_PRES) != 0) - { - meas_val->time_offset = co_read16p(packed_meas + cursor); - cursor += 2; - } + cursor += 1; + } - // Glucose Concentration, type and location - if((meas_val->flags & GLP_MEAS_GL_CTR_TYPE_AND_SPL_LOC_PRES) != 0) - { - meas_val->concentration = co_read16p(packed_meas + cursor); - cursor += 2; - - /* type and location are 2 nibble values */ - meas_val->location = packed_meas[cursor] >> 4; - meas_val->type = packed_meas[cursor] & 0xF; - - cursor += 1; - } - - // Sensor Status Annunciation - if((meas_val->flags & GLP_MEAS_SENS_STAT_ANNUN_PRES) != 0) - { - meas_val->status = co_read16p(packed_meas + cursor); - cursor += 2; - } - - return cursor;} + // Sensor Status Annunciation + if ((meas_val->flags & GLP_MEAS_SENS_STAT_ANNUN_PRES) != 0) { + meas_val->status = co_read16p(packed_meas + cursor); + cursor += 2; + } + return cursor; +} uint8_t glpc_unpack_meas_ctx_value(uint8_t *packed_meas_ctx, - struct glp_meas_ctx* meas_ctx_val, - uint16_t* seq_num) -{ - uint8_t cursor = 0; - // Flags - meas_ctx_val->flags = packed_meas_ctx[cursor]; - cursor += 1; + struct glp_meas_ctx *meas_ctx_val, + uint16_t *seq_num) { + uint8_t cursor = 0; + // Flags + meas_ctx_val->flags = packed_meas_ctx[cursor]; + cursor += 1; - // Sequence Number - *seq_num = co_read16p(packed_meas_ctx + cursor); + // Sequence Number + *seq_num = co_read16p(packed_meas_ctx + cursor); + cursor += 2; + + // Extended Flags + if ((meas_ctx_val->flags & GLP_CTX_EXTD_F_PRES) != 0) { + meas_ctx_val->ext_flags = packed_meas_ctx[cursor]; + cursor += 1; + } + + // Carbohydrate ID And Carbohydrate Present + if ((meas_ctx_val->flags & GLP_CTX_CRBH_ID_AND_CRBH_PRES) != 0) { + // Carbohydrate ID + meas_ctx_val->carbo_id = packed_meas_ctx[cursor]; + cursor += 1; + // Carbohydrate Present + meas_ctx_val->carbo_val = co_read16p(packed_meas_ctx + cursor); + cursor += 2; + } + + // Meal Present + if ((meas_ctx_val->flags & GLP_CTX_MEAL_PRES) != 0) { + meas_ctx_val->meal = packed_meas_ctx[cursor]; + cursor += 1; + } + + // Tester-Health Present + if ((meas_ctx_val->flags & GLP_CTX_TESTER_HEALTH_PRES) != 0) { + // Tester and Health are 2 nibble values + meas_ctx_val->health = packed_meas_ctx[cursor] >> 4; + meas_ctx_val->tester = packed_meas_ctx[cursor] & 0xF; + cursor += 1; + } + + // Exercise Duration & Exercise Intensity Present + if ((meas_ctx_val->flags & GLP_CTX_EXE_DUR_AND_EXE_INTENS_PRES) != 0) { + // Exercise Duration + meas_ctx_val->exercise_dur = co_read16p(packed_meas_ctx + cursor); cursor += 2; - // Extended Flags - if((meas_ctx_val->flags & GLP_CTX_EXTD_F_PRES) != 0) - { - meas_ctx_val->ext_flags = packed_meas_ctx[cursor]; - cursor += 1; - } + // Exercise Intensity + meas_ctx_val->exercise_intens = packed_meas_ctx[cursor]; + cursor += 1; + } - // Carbohydrate ID And Carbohydrate Present - if((meas_ctx_val->flags & GLP_CTX_CRBH_ID_AND_CRBH_PRES) != 0) - { - // Carbohydrate ID - meas_ctx_val->carbo_id = packed_meas_ctx[cursor]; - cursor += 1; - // Carbohydrate Present - meas_ctx_val->carbo_val = co_read16p(packed_meas_ctx + cursor); - cursor += 2; - } + // Medication ID And Medication Present + if ((meas_ctx_val->flags & GLP_CTX_MEDIC_ID_AND_MEDIC_PRES) != 0) { + // Medication ID + meas_ctx_val->med_id = packed_meas_ctx[cursor]; + cursor += 1; - // Meal Present - if((meas_ctx_val->flags & GLP_CTX_MEAL_PRES) != 0) - { - meas_ctx_val->meal = packed_meas_ctx[cursor]; - cursor += 1; - } + // Medication Present + meas_ctx_val->med_val = co_read16p(packed_meas_ctx + cursor); + cursor += 2; + } - // Tester-Health Present - if((meas_ctx_val->flags & GLP_CTX_TESTER_HEALTH_PRES) != 0) - { - // Tester and Health are 2 nibble values - meas_ctx_val->health = packed_meas_ctx[cursor] >> 4; - meas_ctx_val->tester = packed_meas_ctx[cursor] & 0xF; - cursor += 1; - } + // HbA1c Present + if ((meas_ctx_val->flags & GLP_CTX_HBA1C_PRES) != 0) { + // HbA1c + meas_ctx_val->hba1c_val = co_read16p(packed_meas_ctx + cursor); + cursor += 2; + } - // Exercise Duration & Exercise Intensity Present - if((meas_ctx_val->flags & GLP_CTX_EXE_DUR_AND_EXE_INTENS_PRES) != 0) - { - // Exercise Duration - meas_ctx_val->exercise_dur = co_read16p(packed_meas_ctx + cursor); - cursor += 2; - - // Exercise Intensity - meas_ctx_val->exercise_intens = packed_meas_ctx[cursor]; - cursor += 1; - } - - // Medication ID And Medication Present - if((meas_ctx_val->flags & GLP_CTX_MEDIC_ID_AND_MEDIC_PRES) != 0) - { - // Medication ID - meas_ctx_val->med_id = packed_meas_ctx[cursor]; - cursor += 1; - - // Medication Present - meas_ctx_val->med_val = co_read16p(packed_meas_ctx + cursor); - cursor += 2; - } - - // HbA1c Present - if((meas_ctx_val->flags & GLP_CTX_HBA1C_PRES) != 0) - { - // HbA1c - meas_ctx_val->hba1c_val = co_read16p(packed_meas_ctx + cursor); - cursor += 2; - } - - return cursor; + return cursor; } uint8_t glpc_pack_racp_req(uint8_t *packed_val, - const struct glp_racp_req* racp_req) -{ - uint8_t cursor = 0; + const struct glp_racp_req *racp_req) { + uint8_t cursor = 0; - // command op code - packed_val[cursor] = racp_req->op_code; - cursor++; + // command op code + packed_val[cursor] = racp_req->op_code; + cursor++; - // operator of the function - packed_val[cursor] = racp_req->filter.operator; - cursor++; - - // Abort operation don't require any other parameter - if(racp_req->op_code == GLP_REQ_ABORT_OP) - { - return cursor; - } - - // check if request requires operand (filter) - if((racp_req->filter.operator >= GLP_OP_LT_OR_EQ) - && (racp_req->filter.operator <= GLP_OP_WITHIN_RANGE_OF)) - { - - // command filter type - packed_val[cursor] = racp_req->filter.filter_type; - cursor++; - - // filter uses sequence number - if(racp_req->filter.filter_type == GLP_FILTER_SEQ_NUMBER) - { - // minimum value - if((racp_req->filter.operator == GLP_OP_GT_OR_EQ) - || (racp_req->filter.operator == GLP_OP_WITHIN_RANGE_OF)) - { - // minimum value - co_write16p(packed_val + cursor,racp_req->filter.val.seq_num.min); - cursor +=2; - } - - // maximum value - if((racp_req->filter.operator == GLP_OP_LT_OR_EQ) - || (racp_req->filter.operator == GLP_OP_WITHIN_RANGE_OF)) - { - // maximum value - co_write16p(packed_val + cursor,racp_req->filter.val.seq_num.max); - cursor +=2; - } - } - // filter uses user facing time - else - { - // retrieve minimum value - if((racp_req->filter.operator == GLP_OP_GT_OR_EQ) - || (racp_req->filter.operator == GLP_OP_WITHIN_RANGE_OF)) - { - // retrieve minimum facing time - cursor += prf_pack_date_time((packed_val + cursor), - &(racp_req->filter.val.time.facetime_min)); - } - - // retrieve maximum value - if((racp_req->filter.operator == GLP_OP_LT_OR_EQ) - || (racp_req->filter.operator == GLP_OP_WITHIN_RANGE_OF)) - { - // retrieve maximum facing time - cursor += prf_pack_date_time((packed_val + cursor), - &(racp_req->filter.val.time.facetime_max)); - } - } - } + // operator of the function + packed_val[cursor] = racp_req->filter.operator; + cursor++; + // Abort operation don't require any other parameter + if (racp_req->op_code == GLP_REQ_ABORT_OP) { return cursor; + } + + // check if request requires operand (filter) + if ((racp_req->filter.operator>= GLP_OP_LT_OR_EQ) && + (racp_req->filter.operator<= GLP_OP_WITHIN_RANGE_OF)) { + + // command filter type + packed_val[cursor] = racp_req->filter.filter_type; + cursor++; + + // filter uses sequence number + if (racp_req->filter.filter_type == GLP_FILTER_SEQ_NUMBER) { + // minimum value + if ((racp_req->filter.operator== GLP_OP_GT_OR_EQ) || + (racp_req->filter.operator== GLP_OP_WITHIN_RANGE_OF)) { + // minimum value + co_write16p(packed_val + cursor, racp_req->filter.val.seq_num.min); + cursor += 2; + } + + // maximum value + if ((racp_req->filter.operator== GLP_OP_LT_OR_EQ) || + (racp_req->filter.operator== GLP_OP_WITHIN_RANGE_OF)) { + // maximum value + co_write16p(packed_val + cursor, racp_req->filter.val.seq_num.max); + cursor += 2; + } + } + // filter uses user facing time + else { + // retrieve minimum value + if ((racp_req->filter.operator== GLP_OP_GT_OR_EQ) || + (racp_req->filter.operator== GLP_OP_WITHIN_RANGE_OF)) { + // retrieve minimum facing time + cursor += prf_pack_date_time((packed_val + cursor), + &(racp_req->filter.val.time.facetime_min)); + } + + // retrieve maximum value + if ((racp_req->filter.operator== GLP_OP_LT_OR_EQ) || + (racp_req->filter.operator== GLP_OP_WITHIN_RANGE_OF)) { + // retrieve maximum facing time + cursor += prf_pack_date_time((packed_val + cursor), + &(racp_req->filter.val.time.facetime_max)); + } + } + } + + return cursor; } uint8_t glpc_unpack_racp_rsp(uint8_t *packed_val, - struct glp_racp_rsp* racp_rsp) -{ - uint8_t cursor = 0; + struct glp_racp_rsp *racp_rsp) { + uint8_t cursor = 0; - // response op code - racp_rsp->op_code = packed_val[cursor]; + // response op code + racp_rsp->op_code = packed_val[cursor]; + cursor++; + + // operator (null) + cursor++; + + // number of records + if (racp_rsp->op_code == GLP_REQ_NUM_OF_STRD_RECS_RSP) { + racp_rsp->operand.num_of_record = co_read16p(packed_val + cursor); + cursor += 2; + } else { + // requested opcode + racp_rsp->operand.rsp.op_code_req = packed_val[cursor]; cursor++; - - // operator (null) + // command status + racp_rsp->operand.rsp.status = packed_val[cursor]; cursor++; + } - // number of records - if(racp_rsp->op_code == GLP_REQ_NUM_OF_STRD_RECS_RSP) - { - racp_rsp->operand.num_of_record = co_read16p(packed_val + cursor); - cursor += 2; - } - else - { - // requested opcode - racp_rsp->operand.rsp.op_code_req = packed_val[cursor]; - cursor++; - // command status - racp_rsp->operand.rsp.status = packed_val[cursor]; - cursor++; - } - - return cursor; + return cursor; } -uint8_t glpc_validate_request(struct glpc_env_tag *glpc_env, uint8_t conidx, uint8_t char_code) -{ - uint8_t status = GAP_ERR_NO_ERROR; - // check if feature val characteristic exists - if(glpc_env->env[conidx]->gls.chars[char_code].val_hdl == ATT_INVALID_HANDLE) - { - status = PRF_ERR_INEXISTENT_HDL; - } +uint8_t glpc_validate_request(struct glpc_env_tag *glpc_env, uint8_t conidx, + uint8_t char_code) { + uint8_t status = GAP_ERR_NO_ERROR; + // check if feature val characteristic exists + if (glpc_env->env[conidx]->gls.chars[char_code].val_hdl == + ATT_INVALID_HANDLE) { + status = PRF_ERR_INEXISTENT_HDL; + } - return (status); + return (status); } #endif /* (BLE_GL_COLLECTOR) */ diff --git a/services/ble_profiles/glp/glpc/src/glpc_task.c b/services/ble_profiles/glp/glpc/src/glpc_task.c index 5c4628b..e57cdad 100644 --- a/services/ble_profiles/glp/glpc/src/glpc_task.c +++ b/services/ble_profiles/glp/glpc/src/glpc_task.c @@ -13,64 +13,60 @@ #include "rwip_config.h" #if (BLE_GL_COLLECTOR) -#include "gap.h" #include "attm.h" -#include "glpc_task.h" -#include "glpc.h" -#include "gattc_task.h" +#include "gap.h" #include "gapc_task.h" +#include "gattc_task.h" +#include "glpc.h" +#include "glpc_task.h" #include "ke_timer.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * TYPE DEFINITIONS **************************************************************************************** */ - /* * DEFINES **************************************************************************************** */ /// State machine used to retrieve Glucose service characteristics information -const struct prf_char_def glpc_gls_char[GLPC_CHAR_MAX] = -{ +const struct prf_char_def glpc_gls_char[GLPC_CHAR_MAX] = { /// Glucose Measurement - [GLPC_CHAR_MEAS] = {ATT_CHAR_GLUCOSE_MEAS, - ATT_MANDATORY, - ATT_CHAR_PROP_NTF}, + [GLPC_CHAR_MEAS] = {ATT_CHAR_GLUCOSE_MEAS, ATT_MANDATORY, + ATT_CHAR_PROP_NTF}, /// Glucose Measurement Context - [GLPC_CHAR_MEAS_CTX] = {ATT_CHAR_GLUCOSE_MEAS_CTX, - ATT_OPTIONAL, - ATT_CHAR_PROP_NTF}, + [GLPC_CHAR_MEAS_CTX] = {ATT_CHAR_GLUCOSE_MEAS_CTX, ATT_OPTIONAL, + ATT_CHAR_PROP_NTF}, /// Glucose Feature - [GLPC_CHAR_FEATURE] = {ATT_CHAR_GLUCOSE_FEATURE, - ATT_MANDATORY, - ATT_CHAR_PROP_RD}, + [GLPC_CHAR_FEATURE] = {ATT_CHAR_GLUCOSE_FEATURE, ATT_MANDATORY, + ATT_CHAR_PROP_RD}, /// Record Access control point - [GLPC_CHAR_RACP] = {ATT_CHAR_REC_ACCESS_CTRL_PT, - ATT_MANDATORY, - ATT_CHAR_PROP_WR|ATT_CHAR_PROP_IND}, + [GLPC_CHAR_RACP] = {ATT_CHAR_REC_ACCESS_CTRL_PT, ATT_MANDATORY, + ATT_CHAR_PROP_WR | ATT_CHAR_PROP_IND}, }; -/// State machine used to retrieve Glucose service characteristic description information -const struct prf_char_desc_def glpc_gls_char_desc[GLPC_DESC_MAX] = -{ - /// Glucose Measurement client config - [GLPC_DESC_MEAS_CLI_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, GLPC_CHAR_MEAS}, +/// State machine used to retrieve Glucose service characteristic description +/// information +const struct prf_char_desc_def glpc_gls_char_desc[GLPC_DESC_MAX] = { + /// Glucose Measurement client config + [GLPC_DESC_MEAS_CLI_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, + GLPC_CHAR_MEAS}, - /// Glucose Measurement context client config - [GLPC_DESC_MEAS_CTX_CLI_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, GLPC_CHAR_MEAS_CTX}, + /// Glucose Measurement context client config + [GLPC_DESC_MEAS_CTX_CLI_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, + GLPC_CHAR_MEAS_CTX}, - /// Record Access control point client config - [GLPC_DESC_RACP_CLI_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, GLPC_CHAR_RACP}, + /// Record Access control point client config + [GLPC_DESC_RACP_CLI_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, + GLPC_CHAR_RACP}, }; - /* * LOCAL FUNCTIONS DEFINITIONS **************************************************************************************** @@ -88,56 +84,51 @@ const struct prf_char_desc_def glpc_gls_char_desc[GLPC_DESC_MAX] = **************************************************************************************** */ __STATIC int glpc_enable_req_handler(ke_msg_id_t const msgid, - struct glpc_enable_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; + struct glpc_enable_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; - uint8_t state = ke_state_get(dest_id); - uint8_t conidx = KE_IDX_GET(dest_id); - // Glucose Profile Client Role Task Environment - struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); + uint8_t state = ke_state_get(dest_id); + uint8_t conidx = KE_IDX_GET(dest_id); + // Glucose Profile Client Role Task Environment + struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); - ASSERT_INFO(glpc_env != NULL, dest_id, src_id); - if((state == GLPC_IDLE) && (glpc_env->env[conidx] == NULL)) - { - // allocate environment variable for task instance - glpc_env->env[conidx] = (struct glpc_cnx_env*) ke_malloc(sizeof(struct glpc_cnx_env),KE_MEM_ATT_DB); - memset(glpc_env->env[conidx], 0, sizeof(struct glpc_cnx_env)); + ASSERT_INFO(glpc_env != NULL, dest_id, src_id); + if ((state == GLPC_IDLE) && (glpc_env->env[conidx] == NULL)) { + // allocate environment variable for task instance + glpc_env->env[conidx] = (struct glpc_cnx_env *)ke_malloc( + sizeof(struct glpc_cnx_env), KE_MEM_ATT_DB); + memset(glpc_env->env[conidx], 0, sizeof(struct glpc_cnx_env)); - //Config connection, start discovering - if(param->con_type == PRF_CON_DISCOVERY) - { - //start discovering GLS on peer - prf_disc_svc_send(&(glpc_env->prf_env), conidx, ATT_SVC_GLUCOSE); + // Config connection, start discovering + if (param->con_type == PRF_CON_DISCOVERY) { + // start discovering GLS on peer + prf_disc_svc_send(&(glpc_env->prf_env), conidx, ATT_SVC_GLUCOSE); - // Go to DISCOVERING state - ke_state_set(dest_id, GLPC_DISCOVERING); - } - //normal connection, get saved att details - else - { - glpc_env->env[conidx]->gls = param->gls; - - //send APP confirmation that can start normal connection to TH - glpc_enable_rsp_send(glpc_env, conidx, GAP_ERR_NO_ERROR); - } + // Go to DISCOVERING state + ke_state_set(dest_id, GLPC_DISCOVERING); } + // normal connection, get saved att details + else { + glpc_env->env[conidx]->gls = param->gls; - else if(state != GLPC_FREE) - { - status = PRF_ERR_REQ_DISALLOWED; + // send APP confirmation that can start normal connection to TH + glpc_enable_rsp_send(glpc_env, conidx, GAP_ERR_NO_ERROR); } + } - // send an error if request fails - if(status != GAP_ERR_NO_ERROR) - { - glpc_enable_rsp_send(glpc_env, conidx, status); - } + else if (state != GLPC_FREE) { + status = PRF_ERR_REQ_DISALLOWED; + } - return (KE_MSG_CONSUMED); + // send an error if request fails + if (status != GAP_ERR_NO_ERROR) { + glpc_enable_rsp_send(glpc_env, conidx, status); + } + + return (KE_MSG_CONSUMED); } /** @@ -152,36 +143,35 @@ __STATIC int glpc_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, - struct gattc_sdp_svc_ind const *ind, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_sdp_svc_ind const *ind, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == GLPC_DISCOVERING) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == GLPC_DISCOVERING) { + uint8_t conidx = KE_IDX_GET(dest_id); - struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); + struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); - ASSERT_INFO(glpc_env != NULL, dest_id, src_id); - ASSERT_INFO(glpc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(glpc_env != NULL, dest_id, src_id); + ASSERT_INFO(glpc_env->env[conidx] != NULL, dest_id, src_id); - if(glpc_env->env[conidx]->nb_svc == 0) - { - // Retrieve GLS characteristics and descriptors - prf_extract_svc_info(ind, GLPC_CHAR_MAX, &glpc_gls_char[0], &glpc_env->env[conidx]->gls.chars[0], - GLPC_DESC_MAX, &glpc_gls_char_desc[0], &glpc_env->env[conidx]->gls.descs[0]); + if (glpc_env->env[conidx]->nb_svc == 0) { + // Retrieve GLS characteristics and descriptors + prf_extract_svc_info(ind, GLPC_CHAR_MAX, &glpc_gls_char[0], + &glpc_env->env[conidx]->gls.chars[0], GLPC_DESC_MAX, + &glpc_gls_char_desc[0], + &glpc_env->env[conidx]->gls.descs[0]); - //Even if we get multiple responses we only store 1 range - glpc_env->env[conidx]->gls.svc.shdl = ind->start_hdl; - glpc_env->env[conidx]->gls.svc.ehdl = ind->end_hdl; - } - - glpc_env->env[conidx]->nb_svc++; + // Even if we get multiple responses we only store 1 range + glpc_env->env[conidx]->gls.svc.shdl = ind->start_hdl; + glpc_env->env[conidx]->gls.svc.ehdl = ind->end_hdl; } - return (KE_MSG_CONSUMED); + glpc_env->env[conidx]->nb_svc++; + } + + return (KE_MSG_CONSUMED); } /** @@ -196,157 +186,137 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, - struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - uint8_t status; - // Get the address of the environment - struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); - uint8_t conidx = KE_IDX_GET(dest_id); + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + uint8_t status; + // Get the address of the environment + struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); + uint8_t conidx = KE_IDX_GET(dest_id); - if(state == GLPC_DISCOVERING) - { - status = param->status; + if (state == GLPC_DISCOVERING) { + status = param->status; - if (param->status == ATT_ERR_NO_ERROR) - { - // check characteristic validity - if(glpc_env->env[conidx]->nb_svc == 1) - { - status = prf_check_svc_char_validity(GLPC_CHAR_MAX, glpc_env->env[conidx]->gls.chars, - glpc_gls_char); - } - // too much services - else if (glpc_env->env[conidx]->nb_svc > 1) - { - status = PRF_ERR_MULTIPLE_SVC; - } - // no services found - else - { - status = PRF_ERR_STOP_DISC_CHAR_MISSING; - } + if (param->status == ATT_ERR_NO_ERROR) { + // check characteristic validity + if (glpc_env->env[conidx]->nb_svc == 1) { + status = prf_check_svc_char_validity( + GLPC_CHAR_MAX, glpc_env->env[conidx]->gls.chars, glpc_gls_char); + } + // too much services + else if (glpc_env->env[conidx]->nb_svc > 1) { + status = PRF_ERR_MULTIPLE_SVC; + } + // no services found + else { + status = PRF_ERR_STOP_DISC_CHAR_MISSING; + } - // check descriptor validity - if(status == GAP_ERR_NO_ERROR) - { - status = prf_check_svc_char_desc_validity(GLPC_DESC_MAX, - glpc_env->env[conidx]->gls.descs, - glpc_gls_char_desc, - glpc_env->env[conidx]->gls.chars); - } - } - - glpc_enable_rsp_send(glpc_env, conidx, status); - - - } - else if (state == GLPC_IDLE) - { - switch(param->operation) - { - case GATTC_WRITE: - case GATTC_WRITE_NO_RESPONSE: - { - // RACP write done. - if(glpc_env->env[conidx]->last_uuid_req == ATT_CHAR_REC_ACCESS_CTRL_PT) - { - // an error occurs while writing RACP command - if(param->status != GAP_ERR_NO_ERROR) - { - struct glpc_racp_rsp * rsp = KE_MSG_ALLOC(GLPC_RACP_RSP, - prf_dst_task_get(&(glpc_env->prf_env), conidx), dest_id, - glpc_racp_rsp); - - // set error status - rsp->status = param->status; - - // stop timer. - ke_timer_clear(GLPC_RACP_REQ_TIMEOUT, dest_id); - - ke_msg_send(rsp); - glpc_env->env[conidx]->last_uuid_req = 0; - } - } - else - { - bool finished = false; - - // Restore if measurement context notification should be register in from - // unused variable - bool meas_ctx_en = glpc_env->env[conidx]->meas_ctx_en; - - // Registration succeed - if(param->status == GAP_ERR_NO_ERROR) - { - // Glucose measurement notification registration done - if(glpc_env->env[conidx]->last_uuid_req == GLPC_DESC_MEAS_CLI_CFG) - { - // register to RACP indications - prf_gatt_write_ntf_ind(&(glpc_env->prf_env), conidx, - glpc_env->env[conidx]->gls.descs[GLPC_DESC_RACP_CLI_CFG].desc_hdl, - PRF_CLI_START_IND); - glpc_env->env[conidx]->last_uuid_req = GLPC_DESC_RACP_CLI_CFG; - } - // Record access control point indication registration done - // Register to Glucose Measurement Context notifications if requested. - else if((glpc_env->env[conidx]->last_uuid_req == GLPC_DESC_RACP_CLI_CFG) - && meas_ctx_en) - { - // register to Glucose Measurement Context notifications - prf_gatt_write_ntf_ind(&(glpc_env->prf_env), conidx, - glpc_env->env[conidx]->gls.descs[GLPC_DESC_MEAS_CTX_CLI_CFG].desc_hdl, - PRF_CLI_START_NTF); - glpc_env->env[conidx]->last_uuid_req = GLPC_DESC_MEAS_CTX_CLI_CFG; - } - // All registration done - else - { - // indication/notification registration finished - finished = true; - } - } - - // send status if registration done or if an error occurs. - if((param->status != GAP_ERR_NO_ERROR) || (finished)) - { - struct glpc_register_rsp * cfm = KE_MSG_ALLOC(GLPC_REGISTER_RSP, - prf_dst_task_get(&(glpc_env->prf_env), conidx), dest_id, - glpc_register_rsp); - // set error status - cfm->status = param->status; - - ke_msg_send(cfm); - } - } - } - break; - - case GATTC_READ: - { - if(param->status != GAP_ERR_NO_ERROR) - { - struct glpc_read_features_rsp * rsp = KE_MSG_ALLOC(GLPC_READ_FEATURES_RSP, - prf_dst_task_get(&(glpc_env->prf_env), conidx), dest_id, - glpc_read_features_rsp); - - // set error status - rsp->status = param->status; - - ke_msg_send(rsp); - } - } - break; - default: break; - } + // check descriptor validity + if (status == GAP_ERR_NO_ERROR) { + status = prf_check_svc_char_desc_validity( + GLPC_DESC_MAX, glpc_env->env[conidx]->gls.descs, glpc_gls_char_desc, + glpc_env->env[conidx]->gls.chars); + } } - return (KE_MSG_CONSUMED); + glpc_enable_rsp_send(glpc_env, conidx, status); + + } else if (state == GLPC_IDLE) { + switch (param->operation) { + case GATTC_WRITE: + case GATTC_WRITE_NO_RESPONSE: { + // RACP write done. + if (glpc_env->env[conidx]->last_uuid_req == ATT_CHAR_REC_ACCESS_CTRL_PT) { + // an error occurs while writing RACP command + if (param->status != GAP_ERR_NO_ERROR) { + struct glpc_racp_rsp *rsp = KE_MSG_ALLOC( + GLPC_RACP_RSP, prf_dst_task_get(&(glpc_env->prf_env), conidx), + dest_id, glpc_racp_rsp); + + // set error status + rsp->status = param->status; + + // stop timer. + ke_timer_clear(GLPC_RACP_REQ_TIMEOUT, dest_id); + + ke_msg_send(rsp); + glpc_env->env[conidx]->last_uuid_req = 0; + } + } else { + bool finished = false; + + // Restore if measurement context notification should be register in + // from unused variable + bool meas_ctx_en = glpc_env->env[conidx]->meas_ctx_en; + + // Registration succeed + if (param->status == GAP_ERR_NO_ERROR) { + // Glucose measurement notification registration done + if (glpc_env->env[conidx]->last_uuid_req == GLPC_DESC_MEAS_CLI_CFG) { + // register to RACP indications + prf_gatt_write_ntf_ind(&(glpc_env->prf_env), conidx, + glpc_env->env[conidx] + ->gls.descs[GLPC_DESC_RACP_CLI_CFG] + .desc_hdl, + PRF_CLI_START_IND); + glpc_env->env[conidx]->last_uuid_req = GLPC_DESC_RACP_CLI_CFG; + } + // Record access control point indication registration done + // Register to Glucose Measurement Context notifications if requested. + else if ((glpc_env->env[conidx]->last_uuid_req == + GLPC_DESC_RACP_CLI_CFG) && + meas_ctx_en) { + // register to Glucose Measurement Context notifications + prf_gatt_write_ntf_ind(&(glpc_env->prf_env), conidx, + glpc_env->env[conidx] + ->gls.descs[GLPC_DESC_MEAS_CTX_CLI_CFG] + .desc_hdl, + PRF_CLI_START_NTF); + glpc_env->env[conidx]->last_uuid_req = GLPC_DESC_MEAS_CTX_CLI_CFG; + } + // All registration done + else { + // indication/notification registration finished + finished = true; + } + } + + // send status if registration done or if an error occurs. + if ((param->status != GAP_ERR_NO_ERROR) || (finished)) { + struct glpc_register_rsp *cfm = KE_MSG_ALLOC( + GLPC_REGISTER_RSP, prf_dst_task_get(&(glpc_env->prf_env), conidx), + dest_id, glpc_register_rsp); + // set error status + cfm->status = param->status; + + ke_msg_send(cfm); + } + } + } break; + + case GATTC_READ: { + if (param->status != GAP_ERR_NO_ERROR) { + struct glpc_read_features_rsp *rsp = + KE_MSG_ALLOC(GLPC_READ_FEATURES_RSP, + prf_dst_task_get(&(glpc_env->prf_env), conidx), + dest_id, glpc_read_features_rsp); + + // set error status + rsp->status = param->status; + + ke_msg_send(rsp); + } + } break; + default: + break; + } + } + + return (KE_MSG_CONSUMED); } - /** **************************************************************************************** * @brief Handles reception of the @ref GLPC_READ_FEATURES_REQ message. @@ -360,55 +330,49 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int glpc_read_features_req_handler(ke_msg_id_t const msgid, - void const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - uint8_t status = PRF_ERR_REQ_DISALLOWED; + void const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if(state == GLPC_IDLE) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == GLPC_IDLE) { + uint8_t conidx = KE_IDX_GET(dest_id); - struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); + struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); - ASSERT_INFO(glpc_env != NULL, dest_id, src_id); + ASSERT_INFO(glpc_env != NULL, dest_id, src_id); - // environment variable not ready - if(glpc_env->env[conidx] == NULL) - { - status = PRF_APP_ERROR; - } - else - { - status = glpc_validate_request(glpc_env, conidx, GLPC_CHAR_FEATURE); + // environment variable not ready + if (glpc_env->env[conidx] == NULL) { + status = PRF_APP_ERROR; + } else { + status = glpc_validate_request(glpc_env, conidx, GLPC_CHAR_FEATURE); - // request can be performed - if(status == GAP_ERR_NO_ERROR) - { - // read glucose sensor featur - prf_read_char_send(&(glpc_env->prf_env), conidx, glpc_env->env[conidx]->gls.svc.shdl, - glpc_env->env[conidx]->gls.svc.ehdl, glpc_env->env[conidx]->gls.chars[GLPC_CHAR_FEATURE].val_hdl); - } - } + // request can be performed + if (status == GAP_ERR_NO_ERROR) { + // read glucose sensor featur + prf_read_char_send( + &(glpc_env->prf_env), conidx, glpc_env->env[conidx]->gls.svc.shdl, + glpc_env->env[conidx]->gls.svc.ehdl, + glpc_env->env[conidx]->gls.chars[GLPC_CHAR_FEATURE].val_hdl); + } } + } - // request cannot be performed - if(status != GAP_ERR_NO_ERROR) - { - struct glpc_read_features_rsp * rsp = KE_MSG_ALLOC(GLPC_READ_FEATURES_RSP, - src_id, dest_id, glpc_read_features_rsp); - // set error status - rsp->status = status; + // request cannot be performed + if (status != GAP_ERR_NO_ERROR) { + struct glpc_read_features_rsp *rsp = KE_MSG_ALLOC( + GLPC_READ_FEATURES_RSP, src_id, dest_id, glpc_read_features_rsp); + // set error status + rsp->status = status; - ke_msg_send(rsp); - } + ke_msg_send(rsp); + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } - /** **************************************************************************************** * @brief Handles reception of the @ref GATTC_READ_IND message. @@ -423,38 +387,36 @@ __STATIC int glpc_read_features_req_handler(ke_msg_id_t const msgid, __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, struct gattc_read_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == GLPC_IDLE) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == GLPC_IDLE) { + uint8_t conidx = KE_IDX_GET(dest_id); - struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); + struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); - ASSERT_INFO(glpc_env != NULL, dest_id, src_id); - ASSERT_INFO(glpc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(glpc_env != NULL, dest_id, src_id); + ASSERT_INFO(glpc_env->env[conidx] != NULL, dest_id, src_id); - struct glpc_read_features_rsp * rsp = KE_MSG_ALLOC(GLPC_READ_FEATURES_RSP, - prf_dst_task_get(&(glpc_env->prf_env), conidx), dest_id, - glpc_read_features_rsp); - // set error status - rsp->status = ATT_ERR_NO_ERROR; - // unpack feature information - rsp->features = co_read16p(param->value); + struct glpc_read_features_rsp *rsp = KE_MSG_ALLOC( + GLPC_READ_FEATURES_RSP, prf_dst_task_get(&(glpc_env->prf_env), conidx), + dest_id, glpc_read_features_rsp); + // set error status + rsp->status = ATT_ERR_NO_ERROR; + // unpack feature information + rsp->features = co_read16p(param->value); - ke_msg_send(rsp); - } + ke_msg_send(rsp); + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** **************************************************************************************** * @brief Handles reception of the @ref GLPC_REGISTER_REQ message. - * When receiving this request, Glucose collector register to measurement notifications - * and RACP indications. + * When receiving this request, Glucose collector register to measurement + *notifications and RACP indications. * * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. @@ -464,68 +426,70 @@ __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int glpc_register_req_handler(ke_msg_id_t const msgid, - struct glpc_register_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - uint8_t status = PRF_ERR_REQ_DISALLOWED; + struct glpc_register_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if(state == GLPC_IDLE) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == GLPC_IDLE) { + uint8_t conidx = KE_IDX_GET(dest_id); - struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); + struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); - ASSERT_INFO(glpc_env != NULL, dest_id, src_id); + ASSERT_INFO(glpc_env != NULL, dest_id, src_id); - // environment variable not ready - if(glpc_env->env[conidx] == NULL) - { - status = PRF_APP_ERROR; - } - // check if client characteristics are present - else if ((glpc_env->env[conidx]->gls.descs[GLPC_DESC_MEAS_CLI_CFG].desc_hdl == ATT_INVALID_HANDLE) - || (glpc_env->env[conidx]->gls.descs[GLPC_DESC_RACP_CLI_CFG].desc_hdl == ATT_INVALID_HANDLE) - || ((param->meas_ctx_en) - && (glpc_env->env[conidx]->gls.descs[GLPC_DESC_MEAS_CTX_CLI_CFG].desc_hdl == ATT_INVALID_HANDLE))) - { - status = PRF_ERR_INEXISTENT_HDL; - } - // request can be performed - else - { - // register to notification - prf_gatt_write_ntf_ind(&(glpc_env->prf_env), conidx, - glpc_env->env[conidx]->gls.descs[GLPC_DESC_MEAS_CLI_CFG].desc_hdl, - PRF_CLI_START_NTF); - glpc_env->env[conidx]->last_uuid_req = GLPC_DESC_MEAS_CLI_CFG; - - // save if measurement context notification should be register in an unused variable - glpc_env->env[conidx]->meas_ctx_en = param->meas_ctx_en; - - status = GAP_ERR_NO_ERROR; - } + // environment variable not ready + if (glpc_env->env[conidx] == NULL) { + status = PRF_APP_ERROR; } - - // request cannot be performed - if(status != GAP_ERR_NO_ERROR) - { - struct glpc_register_rsp * cfm = KE_MSG_ALLOC(GLPC_REGISTER_RSP, src_id, dest_id, glpc_register_rsp); - // set error status - cfm->status = status; - ke_msg_send(cfm); + // check if client characteristics are present + else if ((glpc_env->env[conidx] + ->gls.descs[GLPC_DESC_MEAS_CLI_CFG] + .desc_hdl == ATT_INVALID_HANDLE) || + (glpc_env->env[conidx] + ->gls.descs[GLPC_DESC_RACP_CLI_CFG] + .desc_hdl == ATT_INVALID_HANDLE) || + ((param->meas_ctx_en) && + (glpc_env->env[conidx] + ->gls.descs[GLPC_DESC_MEAS_CTX_CLI_CFG] + .desc_hdl == ATT_INVALID_HANDLE))) { + status = PRF_ERR_INEXISTENT_HDL; } + // request can be performed + else { + // register to notification + prf_gatt_write_ntf_ind( + &(glpc_env->prf_env), conidx, + glpc_env->env[conidx]->gls.descs[GLPC_DESC_MEAS_CLI_CFG].desc_hdl, + PRF_CLI_START_NTF); + glpc_env->env[conidx]->last_uuid_req = GLPC_DESC_MEAS_CLI_CFG; - return (KE_MSG_CONSUMED); + // save if measurement context notification should be register in an + // unused variable + glpc_env->env[conidx]->meas_ctx_en = param->meas_ctx_en; + + status = GAP_ERR_NO_ERROR; + } + } + + // request cannot be performed + if (status != GAP_ERR_NO_ERROR) { + struct glpc_register_rsp *cfm = + KE_MSG_ALLOC(GLPC_REGISTER_RSP, src_id, dest_id, glpc_register_rsp); + // set error status + cfm->status = status; + ke_msg_send(cfm); + } + + return (KE_MSG_CONSUMED); } - - /** **************************************************************************************** * @brief Handles reception of the @ref GLPC_RACP_REQ message. - * When receiving this request, Glucose collector send a RACP command to Glucose sensor. + * When receiving this request, Glucose collector send a RACP command to Glucose + *sensor. * * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. @@ -535,63 +499,57 @@ __STATIC int glpc_register_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int glpc_racp_req_handler(ke_msg_id_t const msgid, - struct glpc_racp_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - uint8_t status = PRF_ERR_REQ_DISALLOWED; + struct glpc_racp_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if(state == GLPC_IDLE) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == GLPC_IDLE) { + uint8_t conidx = KE_IDX_GET(dest_id); - struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); + struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); - ASSERT_INFO(glpc_env != NULL, dest_id, src_id); + ASSERT_INFO(glpc_env != NULL, dest_id, src_id); - // environment variable not ready - if(glpc_env->env[conidx] == NULL) - { - status = PRF_APP_ERROR; - } - else - { - status = glpc_validate_request(glpc_env, conidx, GLPC_CHAR_RACP); + // environment variable not ready + if (glpc_env->env[conidx] == NULL) { + status = PRF_APP_ERROR; + } else { + status = glpc_validate_request(glpc_env, conidx, GLPC_CHAR_RACP); - // request can be performed - if(status == GAP_ERR_NO_ERROR) - { - // send command request - uint8_t value[GLP_REC_ACCESS_CTRL_MAX_LEN]; - uint16_t length; + // request can be performed + if (status == GAP_ERR_NO_ERROR) { + // send command request + uint8_t value[GLP_REC_ACCESS_CTRL_MAX_LEN]; + uint16_t length; - // pack Record Access Control Point request - length = glpc_pack_racp_req((uint8_t*)&(value[0]), &(param->racp_req)); + // pack Record Access Control Point request + length = glpc_pack_racp_req((uint8_t *)&(value[0]), &(param->racp_req)); - // write Record Access Control Point request - prf_gatt_write(&(glpc_env->prf_env), conidx, - glpc_env->env[conidx]->gls.chars[GLPC_CHAR_RACP].val_hdl, - &(value[0]),length, GATTC_WRITE); + // write Record Access Control Point request + prf_gatt_write(&(glpc_env->prf_env), conidx, + glpc_env->env[conidx]->gls.chars[GLPC_CHAR_RACP].val_hdl, + &(value[0]), length, GATTC_WRITE); - glpc_env->env[conidx]->last_uuid_req = ATT_CHAR_REC_ACCESS_CTRL_PT; + glpc_env->env[conidx]->last_uuid_req = ATT_CHAR_REC_ACCESS_CTRL_PT; - // start the timer; will destroy the link if it expires - ke_timer_set(GLPC_RACP_REQ_TIMEOUT, dest_id, GLPC_RACP_TIMEOUT); - } - } + // start the timer; will destroy the link if it expires + ke_timer_set(GLPC_RACP_REQ_TIMEOUT, dest_id, GLPC_RACP_TIMEOUT); + } } + } - // request cannot be performed - if(status != GAP_ERR_NO_ERROR) - { - struct glpc_racp_rsp * rsp = KE_MSG_ALLOC(GLPC_RACP_RSP, src_id, dest_id, glpc_racp_rsp); - // set error status - rsp->status = status; - ke_msg_send(rsp); - } + // request cannot be performed + if (status != GAP_ERR_NO_ERROR) { + struct glpc_racp_rsp *rsp = + KE_MSG_ALLOC(GLPC_RACP_RSP, src_id, dest_id, glpc_racp_rsp); + // set error status + rsp->status = status; + ke_msg_send(rsp); + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -605,100 +563,97 @@ __STATIC int glpc_racp_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, - struct gattc_event_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_event_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state != GLPC_FREE) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state != GLPC_FREE) { + uint8_t conidx = KE_IDX_GET(dest_id); - struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); + struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); - ASSERT_INFO(glpc_env != NULL, dest_id, src_id); - ASSERT_INFO(glpc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(glpc_env != NULL, dest_id, src_id); + ASSERT_INFO(glpc_env->env[conidx] != NULL, dest_id, src_id); - switch(param->type) - { - case GATTC_INDICATE: - { - // confirm that indication has been correctly received - struct gattc_event_cfm * cfm = KE_MSG_ALLOC(GATTC_EVENT_CFM, src_id, dest_id, gattc_event_cfm); - cfm->handle = param->handle; - ke_msg_send(cfm); + switch (param->type) { + case GATTC_INDICATE: { + // confirm that indication has been correctly received + struct gattc_event_cfm *cfm = + KE_MSG_ALLOC(GATTC_EVENT_CFM, src_id, dest_id, gattc_event_cfm); + cfm->handle = param->handle; + ke_msg_send(cfm); - // check if it's a RACP indication - if (glpc_env->env[conidx]->gls.chars[GLPC_CHAR_RACP].val_hdl == param->handle) - { - struct glpc_racp_rsp * rsp = KE_MSG_ALLOC(GLPC_RACP_RSP, - prf_dst_task_get(&(glpc_env->prf_env), conidx), dest_id, - glpc_racp_rsp); + // check if it's a RACP indication + if (glpc_env->env[conidx]->gls.chars[GLPC_CHAR_RACP].val_hdl == + param->handle) { + struct glpc_racp_rsp *rsp = KE_MSG_ALLOC( + GLPC_RACP_RSP, prf_dst_task_get(&(glpc_env->prf_env), conidx), + dest_id, glpc_racp_rsp); - // set error status - rsp->status = GAP_ERR_NO_ERROR; + // set error status + rsp->status = GAP_ERR_NO_ERROR; - // stop timer. - ke_timer_clear(GLPC_RACP_REQ_TIMEOUT, dest_id); + // stop timer. + ke_timer_clear(GLPC_RACP_REQ_TIMEOUT, dest_id); - // unpack RACP response indication. - glpc_unpack_racp_rsp((uint8_t*)param->value, &(rsp->racp_rsp)); - ke_msg_send(rsp); - } - } - break; - case GATTC_NOTIFY: - { - // check if it's a Glucose measurement notification - if (glpc_env->env[conidx]->gls.chars[GLPC_CHAR_MEAS].val_hdl == param->handle) - { + // unpack RACP response indication. + glpc_unpack_racp_rsp((uint8_t *)param->value, &(rsp->racp_rsp)); + ke_msg_send(rsp); + } + } break; + case GATTC_NOTIFY: { + // check if it's a Glucose measurement notification + if (glpc_env->env[conidx]->gls.chars[GLPC_CHAR_MEAS].val_hdl == + param->handle) { - // build a GLPC_MEAS_IND message with glucose measurement value - struct glpc_meas_ind * ind = KE_MSG_ALLOC(GLPC_MEAS_IND, - prf_dst_task_get(&(glpc_env->prf_env), conidx), dest_id, - glpc_meas_ind); + // build a GLPC_MEAS_IND message with glucose measurement value + struct glpc_meas_ind *ind = KE_MSG_ALLOC( + GLPC_MEAS_IND, prf_dst_task_get(&(glpc_env->prf_env), conidx), + dest_id, glpc_meas_ind); - // unpack Glucose measurement. - glpc_unpack_meas_value((uint8_t*) param->value, &(ind->meas_val), &(ind->seq_num)); + // unpack Glucose measurement. + glpc_unpack_meas_value((uint8_t *)param->value, &(ind->meas_val), + &(ind->seq_num)); - if(glpc_env->env[conidx]->last_uuid_req == ATT_CHAR_REC_ACCESS_CTRL_PT) - { - // restart the timer; will destroy the link if it expires - ke_timer_set(GLPC_RACP_REQ_TIMEOUT, dest_id, GLPC_RACP_TIMEOUT); - } - - ke_msg_send(ind); - } - // check if it's a Glucose measurement context notification - else if(glpc_env->env[conidx]->gls.chars[GLPC_CHAR_MEAS_CTX].val_hdl == param->handle) - { - // build a GLPC_MEAS_CTX_IND message with glucose measurement context value - struct glpc_meas_ctx_ind * ind = KE_MSG_ALLOC(GLPC_MEAS_CTX_IND, - prf_dst_task_get(&(glpc_env->prf_env), conidx), dest_id, - glpc_meas_ctx_ind); - - // unpack Glucose measurement context. - glpc_unpack_meas_ctx_value((uint8_t*) param->value, &(ind->ctx), &(ind->seq_num)); - - if(glpc_env->env[conidx]->last_uuid_req == ATT_CHAR_REC_ACCESS_CTRL_PT) - { - // restart the timer; will destroy the link if it expires - ke_timer_set(GLPC_RACP_REQ_TIMEOUT, dest_id, GLPC_RACP_TIMEOUT); - } - - ke_msg_send(ind); - } - } - break; - default: break; + if (glpc_env->env[conidx]->last_uuid_req == + ATT_CHAR_REC_ACCESS_CTRL_PT) { + // restart the timer; will destroy the link if it expires + ke_timer_set(GLPC_RACP_REQ_TIMEOUT, dest_id, GLPC_RACP_TIMEOUT); } + + ke_msg_send(ind); + } + // check if it's a Glucose measurement context notification + else if (glpc_env->env[conidx]->gls.chars[GLPC_CHAR_MEAS_CTX].val_hdl == + param->handle) { + // build a GLPC_MEAS_CTX_IND message with glucose measurement context + // value + struct glpc_meas_ctx_ind *ind = KE_MSG_ALLOC( + GLPC_MEAS_CTX_IND, prf_dst_task_get(&(glpc_env->prf_env), conidx), + dest_id, glpc_meas_ctx_ind); + + // unpack Glucose measurement context. + glpc_unpack_meas_ctx_value((uint8_t *)param->value, &(ind->ctx), + &(ind->seq_num)); + + if (glpc_env->env[conidx]->last_uuid_req == + ATT_CHAR_REC_ACCESS_CTRL_PT) { + // restart the timer; will destroy the link if it expires + ke_timer_set(GLPC_RACP_REQ_TIMEOUT, dest_id, GLPC_RACP_TIMEOUT); + } + + ke_msg_send(ind); + } + } break; + default: + break; } + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } - /** **************************************************************************************** * @brief RACP request not executed by peer device or is freezed. @@ -713,29 +668,30 @@ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, * **************************************************************************************** */ -__STATIC int glpc_racp_req_timeout_handler(ke_msg_id_t const msgid, void const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); +__STATIC int glpc_racp_req_timeout_handler(ke_msg_id_t const msgid, + void const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state != GLPC_FREE) - { - uint8_t conidx = KE_IDX_GET(dest_id); - struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); + if (state != GLPC_FREE) { + uint8_t conidx = KE_IDX_GET(dest_id); + struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); - ASSERT_INFO(glpc_env != NULL, dest_id, src_id); - ASSERT_INFO(glpc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(glpc_env != NULL, dest_id, src_id); + ASSERT_INFO(glpc_env->env[conidx] != NULL, dest_id, src_id); - // inform that racp execution is into a timeout state - struct glpc_racp_rsp * rsp = KE_MSG_ALLOC(GLPC_RACP_RSP, - prf_dst_task_get(&(glpc_env->prf_env), conidx), dest_id, glpc_racp_rsp); - // set error status - rsp->status = PRF_ERR_PROC_TIMEOUT; + // inform that racp execution is into a timeout state + struct glpc_racp_rsp *rsp = KE_MSG_ALLOC( + GLPC_RACP_RSP, prf_dst_task_get(&(glpc_env->prf_env), conidx), dest_id, + glpc_racp_rsp); + // set error status + rsp->status = PRF_ERR_PROC_TIMEOUT; - ke_msg_send(rsp); - } + ke_msg_send(rsp); + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /* @@ -744,29 +700,27 @@ __STATIC int glpc_racp_req_timeout_handler(ke_msg_id_t const msgid, void const * */ /// Default State handlers definition -KE_MSG_HANDLER_TAB(glpc) -{ - {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, - {GLPC_READ_FEATURES_REQ, (ke_msg_func_t)glpc_read_features_req_handler}, - {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, - {GLPC_REGISTER_REQ, (ke_msg_func_t)glpc_register_req_handler}, - {GLPC_RACP_REQ, (ke_msg_func_t)glpc_racp_req_handler}, - {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, - {GATTC_EVENT_REQ_IND, (ke_msg_func_t)gattc_event_ind_handler}, - {GLPC_RACP_REQ_TIMEOUT, (ke_msg_func_t)glpc_racp_req_timeout_handler}, - {GLPC_ENABLE_REQ, (ke_msg_func_t)glpc_enable_req_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, +KE_MSG_HANDLER_TAB(glpc){ + {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, + {GLPC_READ_FEATURES_REQ, (ke_msg_func_t)glpc_read_features_req_handler}, + {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, + {GLPC_REGISTER_REQ, (ke_msg_func_t)glpc_register_req_handler}, + {GLPC_RACP_REQ, (ke_msg_func_t)glpc_racp_req_handler}, + {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {GATTC_EVENT_REQ_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {GLPC_RACP_REQ_TIMEOUT, (ke_msg_func_t)glpc_racp_req_timeout_handler}, + {GLPC_ENABLE_REQ, (ke_msg_func_t)glpc_enable_req_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void glpc_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); +void glpc_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct glpc_env_tag *glpc_env = PRF_ENV_GET(GLPC, glpc); - task_desc->msg_handler_tab = glpc_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(glpc_msg_handler_tab); - task_desc->state = glpc_env->state; - task_desc->idx_max = GLPC_IDX_MAX; + task_desc->msg_handler_tab = glpc_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(glpc_msg_handler_tab); + task_desc->state = glpc_env->state; + task_desc->idx_max = GLPC_IDX_MAX; } #endif /* (BLE_GL_COLLECTOR) */ diff --git a/services/ble_profiles/glp/glps/src/glps.c b/services/ble_profiles/glp/glps/src/glps.c index 16adb7e..18bc55c 100644 --- a/services/ble_profiles/glp/glps/src/glps.c +++ b/services/ble_profiles/glp/glps/src/glps.c @@ -12,15 +12,15 @@ #include "rwip_config.h" #if (BLE_GL_SENSOR) +#include "attm.h" #include "gap.h" #include "gattc_task.h" -#include "attm.h" #include "glps.h" #include "glps_task.h" #include "prf_utils.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * GLOBAL VARIABLE DEFINITIONS @@ -28,40 +28,54 @@ */ /// Full GLPS Database Description - Used to add attributes into the database -static const struct attm_desc glps_att_db[GLS_IDX_NB] = -{ +static const struct attm_desc glps_att_db[GLS_IDX_NB] = { // Glucose Service Declaration - [GLS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [GLS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // Glucose Measurement Characteristic Declaration - [GLS_IDX_MEAS_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [GLS_IDX_MEAS_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, // Glucose Measurement Characteristic Value - [GLS_IDX_MEAS_VAL] = {ATT_CHAR_GLUCOSE_MEAS, PERM(NTF, ENABLE), PERM(RI, ENABLE), 0}, - // Glucose Measurement Characteristic - Client Characteristic Configuration Descriptor - [GLS_IDX_MEAS_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE)|PERM(WRITE_REQ, ENABLE), 0, 0}, + [GLS_IDX_MEAS_VAL] = {ATT_CHAR_GLUCOSE_MEAS, PERM(NTF, ENABLE), + PERM(RI, ENABLE), 0}, + // Glucose Measurement Characteristic - Client Characteristic Configuration + // Descriptor + [GLS_IDX_MEAS_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, // Glucose Measurement Context Characteristic Declaration - [GLS_IDX_MEAS_CTX_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [GLS_IDX_MEAS_CTX_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, // Glucose Measurement Context Characteristic Value - [GLS_IDX_MEAS_CTX_VAL] = {ATT_CHAR_GLUCOSE_MEAS_CTX, PERM(NTF, ENABLE), PERM(RI, ENABLE), 0}, - // Glucose Measurement Context Characteristic - Client Characteristic Configuration Descriptor - [GLS_IDX_MEAS_CTX_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE)|PERM(WRITE_REQ, ENABLE), 0, 0}, + [GLS_IDX_MEAS_CTX_VAL] = {ATT_CHAR_GLUCOSE_MEAS_CTX, PERM(NTF, ENABLE), + PERM(RI, ENABLE), 0}, + // Glucose Measurement Context Characteristic - Client Characteristic + // Configuration Descriptor + [GLS_IDX_MEAS_CTX_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, + 0}, // Glucose Features Characteristic Declaration - [GLS_IDX_FEATURE_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [GLS_IDX_FEATURE_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, // Glucose Features Characteristic Value - [GLS_IDX_FEATURE_VAL] = {ATT_CHAR_GLUCOSE_FEATURE, PERM(RD, ENABLE), PERM(RI, ENABLE) | sizeof(uint16_t), 0}, + [GLS_IDX_FEATURE_VAL] = {ATT_CHAR_GLUCOSE_FEATURE, PERM(RD, ENABLE), + PERM(RI, ENABLE) | sizeof(uint16_t), 0}, // Record Access Control Point characteristic Declaration - [GLS_IDX_REC_ACCESS_CTRL_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [GLS_IDX_REC_ACCESS_CTRL_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), + 0, 0}, // Record Access Control Point characteristic Value - [GLS_IDX_REC_ACCESS_CTRL_VAL] = {ATT_CHAR_REC_ACCESS_CTRL_PT, PERM(IND, ENABLE)|PERM(WP, UNAUTH)|PERM(WRITE_REQ, ENABLE), - PERM(RI, ENABLE), GLP_REC_ACCESS_CTRL_MAX_LEN}, - // Record Access Control Point characteristic - Client Characteristic Configuration Descriptor - [GLS_IDX_REC_ACCESS_CTRL_IND_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE)|PERM(WRITE_REQ, ENABLE), 0, 0}, + [GLS_IDX_REC_ACCESS_CTRL_VAL] = {ATT_CHAR_REC_ACCESS_CTRL_PT, + PERM(IND, ENABLE) | PERM(WP, UNAUTH) | + PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE), + GLP_REC_ACCESS_CTRL_MAX_LEN}, + // Record Access Control Point characteristic - Client Characteristic + // Configuration Descriptor + [GLS_IDX_REC_ACCESS_CTRL_IND_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | + PERM(WRITE_REQ, ENABLE), + 0, 0}, }; - /* * DEFINES **************************************************************************************** @@ -85,91 +99,94 @@ static const struct attm_desc glps_att_db[GLS_IDX_NB] = * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t glps_init (struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, struct glps_db_cfg* params) -{ - //------------------ create the attribute database for the profile ------------------- - uint8_t idx; - // Service content flag - uint32_t cfg_flag= GLPS_MANDATORY_MASK; - // DB Creation Statis - uint8_t status = ATT_ERR_NO_ERROR; +static uint8_t glps_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, + struct glps_db_cfg *params) { + //------------------ create the attribute database for the profile + //------------------- + uint8_t idx; + // Service content flag + uint32_t cfg_flag = GLPS_MANDATORY_MASK; + // DB Creation Statis + uint8_t status = ATT_ERR_NO_ERROR; - //Set Configuration Flag Value - if (params->meas_ctx_supported) - { - cfg_flag |= GLPS_MEAS_CTX_PRES_MASK; + // Set Configuration Flag Value + if (params->meas_ctx_supported) { + cfg_flag |= GLPS_MEAS_CTX_PRES_MASK; + } + + // Create Glucose Database + status = attm_svc_create_db( + start_hdl, ATT_SVC_GLUCOSE, (uint8_t *)&cfg_flag, GLS_IDX_NB, NULL, + env->task, &glps_att_db[0], + (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, ENABLE)); + + //-------------------- allocate memory required for the profile + //--------------------- + if (status == ATT_ERR_NO_ERROR) { + // Allocate GLPS required environment variable + struct glps_env_tag *glps_env = (struct glps_env_tag *)ke_malloc( + sizeof(struct glps_env_tag), KE_MEM_ATT_DB); + + // Initialize GLPS environment + env->env = (prf_env_t *)glps_env; + glps_env->start_hdl = *start_hdl; + glps_env->meas_ctx_supported = params->meas_ctx_supported; + glps_env->features = params->features; + glps_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + glps_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + + // initialize environment variable + env->id = TASK_ID_GLPS; + glps_task_init(&(env->desc)); + + for (idx = 0; idx < GLPS_IDX_MAX; idx++) { + glps_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), GLPS_FREE); } + } - // Create Glucose Database - status = attm_svc_create_db(start_hdl, ATT_SVC_GLUCOSE, (uint8_t *)&cfg_flag, - GLS_IDX_NB, NULL, env->task, &glps_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | PERM(SVC_MI, ENABLE)); - - //-------------------- allocate memory required for the profile --------------------- - if (status == ATT_ERR_NO_ERROR) - { - // Allocate GLPS required environment variable - struct glps_env_tag* glps_env = - (struct glps_env_tag* ) ke_malloc(sizeof(struct glps_env_tag), KE_MEM_ATT_DB); - - // Initialize GLPS environment - env->env = (prf_env_t*) glps_env; - glps_env->start_hdl = *start_hdl; - glps_env->meas_ctx_supported = params->meas_ctx_supported; - glps_env->features = params->features; - glps_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - glps_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - - // initialize environment variable - env->id = TASK_ID_GLPS; - glps_task_init(&(env->desc)); - - for(idx = 0; idx < GLPS_IDX_MAX ; idx++) - { - glps_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), GLPS_FREE); - } - } - - return (status); + return (status); } /** **************************************************************************************** * @brief Destruction of the GLPS module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void glps_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct glps_env_tag* glps_env = (struct glps_env_tag*) env->env; +static void glps_destroy(struct prf_task_env *env) { + uint8_t idx; + struct glps_env_tag *glps_env = (struct glps_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < GLPS_IDX_MAX ; idx++) - { - if(glps_env->env[idx] != NULL) - { - ke_free(glps_env->env[idx]); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < GLPS_IDX_MAX; idx++) { + if (glps_env->env[idx] != NULL) { + ke_free(glps_env->env[idx]); } + } - // free profile environment variables - env->env = NULL; - ke_free(glps_env); + // free profile environment variables + env->env = NULL; + ke_free(glps_env); } /** @@ -180,16 +197,15 @@ static void glps_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void glps_create(struct prf_task_env* env, uint8_t conidx) -{ - struct glps_env_tag* glps_env = (struct glps_env_tag*) env->env; - glps_env->env[conidx] = (struct glps_cnx_env*) - ke_malloc(sizeof(struct glps_cnx_env), KE_MEM_ATT_DB); +static void glps_create(struct prf_task_env *env, uint8_t conidx) { + struct glps_env_tag *glps_env = (struct glps_env_tag *)env->env; + glps_env->env[conidx] = (struct glps_cnx_env *)ke_malloc( + sizeof(struct glps_cnx_env), KE_MEM_ATT_DB); - memset(glps_env->env[conidx], 0, sizeof(struct glps_cnx_env)); + memset(glps_env->env[conidx], 0, sizeof(struct glps_cnx_env)); - /* Put GLS in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), GLPS_IDLE); + /* Put GLS in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), GLPS_IDLE); } /** @@ -201,19 +217,18 @@ static void glps_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void glps_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct glps_env_tag* glps_env = (struct glps_env_tag*) env->env; +static void glps_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct glps_env_tag *glps_env = (struct glps_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(glps_env->env[conidx] != NULL) - { - ke_free(glps_env->env[conidx]); - glps_env->env[conidx] = NULL; - } + // clean-up environment variable allocated for task instance + if (glps_env->env[conidx] != NULL) { + ke_free(glps_env->env[conidx]); + glps_env->env[conidx] = NULL; + } - /* Put GLS in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), GLPS_FREE); + /* Put GLS in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), GLPS_FREE); } /* @@ -222,12 +237,11 @@ static void glps_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reaso */ /// GLPS Task interface required by profile manager -const struct prf_task_cbs glps_itf = -{ - (prf_init_fnct) glps_init, - glps_destroy, - glps_create, - glps_cleanup, +const struct prf_task_cbs glps_itf = { + (prf_init_fnct)glps_init, + glps_destroy, + glps_create, + glps_cleanup, }; /* @@ -235,315 +249,273 @@ const struct prf_task_cbs glps_itf = **************************************************************************************** */ -const struct prf_task_cbs* glps_prf_itf_get(void) -{ - return &glps_itf; -} +const struct prf_task_cbs *glps_prf_itf_get(void) { return &glps_itf; } -uint8_t glps_pack_meas_value(uint8_t *packed_meas, const struct glp_meas* meas_val, - uint16_t seq_num) -{ - uint8_t cursor = 0; +uint8_t glps_pack_meas_value(uint8_t *packed_meas, + const struct glp_meas *meas_val, + uint16_t seq_num) { + uint8_t cursor = 0; - // Flags - packed_meas[cursor] = meas_val->flags; - cursor += 1; + // Flags + packed_meas[cursor] = meas_val->flags; + cursor += 1; - // Sequence Number - co_write16p(packed_meas + cursor, seq_num); + // Sequence Number + co_write16p(packed_meas + cursor, seq_num); + cursor += 2; + + // Base Time + cursor += prf_pack_date_time(packed_meas + cursor, &(meas_val->base_time)); + + // Time Offset + if ((meas_val->flags & GLP_MEAS_TIME_OFF_PRES) != 0) { + co_write16p(packed_meas + cursor, meas_val->time_offset); + cursor += 2; + } + + // Glucose Concentration, type and location + if ((meas_val->flags & GLP_MEAS_GL_CTR_TYPE_AND_SPL_LOC_PRES) != 0) { + co_write16p(packed_meas + cursor, meas_val->concentration); cursor += 2; - // Base Time - cursor += prf_pack_date_time(packed_meas + cursor, &(meas_val->base_time)); + /* type and location are 2 nibble values */ + packed_meas[cursor] = (meas_val->location << 4) | (meas_val->type); + cursor += 1; + } - //Time Offset - if((meas_val->flags & GLP_MEAS_TIME_OFF_PRES) != 0) - { - co_write16p(packed_meas + cursor, meas_val->time_offset); - cursor += 2; - } + // Sensor Status Annunciation + if ((meas_val->flags & GLP_MEAS_SENS_STAT_ANNUN_PRES) != 0) { + co_write16p(packed_meas + cursor, meas_val->status); + cursor += 2; + } - // Glucose Concentration, type and location - if((meas_val->flags & GLP_MEAS_GL_CTR_TYPE_AND_SPL_LOC_PRES) != 0) - { - co_write16p(packed_meas + cursor, meas_val->concentration); - cursor += 2; - - /* type and location are 2 nibble values */ - packed_meas[cursor] = (meas_val->location << 4) | (meas_val->type); - cursor += 1; - } - - // Sensor Status Annunciation - if((meas_val->flags & GLP_MEAS_SENS_STAT_ANNUN_PRES) != 0) - { - co_write16p(packed_meas + cursor, meas_val->status); - cursor += 2; - } - - return cursor; + return cursor; } - uint8_t glps_pack_meas_ctx_value(uint8_t *packed_meas_ctx, - const struct glp_meas_ctx* meas_ctx_val, - uint16_t seq_num) -{ - uint8_t cursor = 0; - // Flags - packed_meas_ctx[cursor] = meas_ctx_val->flags; - cursor += 1; + const struct glp_meas_ctx *meas_ctx_val, + uint16_t seq_num) { + uint8_t cursor = 0; + // Flags + packed_meas_ctx[cursor] = meas_ctx_val->flags; + cursor += 1; - // Sequence Number - co_write16p(packed_meas_ctx + cursor, seq_num); + // Sequence Number + co_write16p(packed_meas_ctx + cursor, seq_num); + cursor += 2; + + // Extended Flags + if ((meas_ctx_val->flags & GLP_CTX_EXTD_F_PRES) != 0) { + packed_meas_ctx[cursor] = meas_ctx_val->ext_flags; + cursor += 1; + } + + // Carbohydrate ID And Carbohydrate Present + if ((meas_ctx_val->flags & GLP_CTX_CRBH_ID_AND_CRBH_PRES) != 0) { + // Carbohydrate ID + packed_meas_ctx[cursor] = meas_ctx_val->carbo_id; + cursor += 1; + // Carbohydrate Present + co_write16p(packed_meas_ctx + cursor, meas_ctx_val->carbo_val); + cursor += 2; + } + + // Meal Present + if ((meas_ctx_val->flags & GLP_CTX_MEAL_PRES) != 0) { + packed_meas_ctx[cursor] = meas_ctx_val->meal; + cursor += 1; + } + + // Tester-Health Present + if ((meas_ctx_val->flags & GLP_CTX_TESTER_HEALTH_PRES) != 0) { + // Tester and Health are 2 nibble values + packed_meas_ctx[cursor] = + (meas_ctx_val->health << 4) | (meas_ctx_val->tester); + cursor += 1; + } + + // Exercise Duration & Exercise Intensity Present + if ((meas_ctx_val->flags & GLP_CTX_EXE_DUR_AND_EXE_INTENS_PRES) != 0) { + // Exercise Duration + co_write16p(packed_meas_ctx + cursor, meas_ctx_val->exercise_dur); cursor += 2; - // Extended Flags - if((meas_ctx_val->flags & GLP_CTX_EXTD_F_PRES) != 0) - { - packed_meas_ctx[cursor] = meas_ctx_val->ext_flags; - cursor += 1; - } + // Exercise Intensity + packed_meas_ctx[cursor] = meas_ctx_val->exercise_intens; + cursor += 1; + } - // Carbohydrate ID And Carbohydrate Present - if((meas_ctx_val->flags & GLP_CTX_CRBH_ID_AND_CRBH_PRES) != 0) - { - // Carbohydrate ID - packed_meas_ctx[cursor] = meas_ctx_val->carbo_id; - cursor += 1; - // Carbohydrate Present - co_write16p(packed_meas_ctx + cursor, meas_ctx_val->carbo_val); - cursor += 2; - } + // Medication ID And Medication Present + if ((meas_ctx_val->flags & GLP_CTX_MEDIC_ID_AND_MEDIC_PRES) != 0) { + // Medication ID + packed_meas_ctx[cursor] = meas_ctx_val->med_id; + cursor += 1; - // Meal Present - if((meas_ctx_val->flags & GLP_CTX_MEAL_PRES) != 0) - { - packed_meas_ctx[cursor] = meas_ctx_val->meal; - cursor += 1; - } + // Medication Present + co_write16p(packed_meas_ctx + cursor, meas_ctx_val->med_val); + cursor += 2; + } - // Tester-Health Present - if((meas_ctx_val->flags & GLP_CTX_TESTER_HEALTH_PRES) != 0) - { - // Tester and Health are 2 nibble values - packed_meas_ctx[cursor] = (meas_ctx_val->health << 4) | (meas_ctx_val->tester); - cursor += 1; - } + // HbA1c Present + if ((meas_ctx_val->flags & GLP_CTX_HBA1C_PRES) != 0) { + // HbA1c + co_write16p(packed_meas_ctx + cursor, meas_ctx_val->hba1c_val); + cursor += 2; + } - // Exercise Duration & Exercise Intensity Present - if((meas_ctx_val->flags & GLP_CTX_EXE_DUR_AND_EXE_INTENS_PRES) != 0) - { - // Exercise Duration - co_write16p(packed_meas_ctx + cursor, meas_ctx_val->exercise_dur); - cursor += 2; - - // Exercise Intensity - packed_meas_ctx[cursor] = meas_ctx_val->exercise_intens; - cursor += 1; - } - - // Medication ID And Medication Present - if((meas_ctx_val->flags & GLP_CTX_MEDIC_ID_AND_MEDIC_PRES) != 0) - { - // Medication ID - packed_meas_ctx[cursor] = meas_ctx_val->med_id; - cursor += 1; - - // Medication Present - co_write16p(packed_meas_ctx + cursor, meas_ctx_val->med_val); - cursor += 2; - } - - // HbA1c Present - if((meas_ctx_val->flags & GLP_CTX_HBA1C_PRES) != 0) - { - // HbA1c - co_write16p(packed_meas_ctx + cursor, meas_ctx_val->hba1c_val); - cursor += 2; - } - - return cursor; + return cursor; } uint8_t glps_unpack_racp_req(uint8_t *packed_val, uint16_t length, - struct glp_racp_req* racp_req) -{ - uint8_t cursor = 0; + struct glp_racp_req *racp_req) { + uint8_t cursor = 0; - // verify that enough data present to load operation filter - if(length < 2) - { - return PRF_APP_ERROR; - } + // verify that enough data present to load operation filter + if (length < 2) { + return PRF_APP_ERROR; + } - // retrieve command op code - racp_req->op_code = packed_val[cursor]; - cursor++; + // retrieve command op code + racp_req->op_code = packed_val[cursor]; + cursor++; - // clear filter structure - memset(&(racp_req->filter), 0, sizeof(struct glp_filter)); + // clear filter structure + memset(&(racp_req->filter), 0, sizeof(struct glp_filter)); + // retrieve operator of the function + racp_req->filter.operator= packed_val[cursor]; + cursor++; - // retrieve operator of the function - racp_req->filter.operator = packed_val[cursor]; - cursor++; + // check if opcode is supported + if ((racp_req->op_code < GLP_REQ_REP_STRD_RECS) || + (racp_req->op_code > GLP_REQ_REP_NUM_OF_STRD_RECS)) { + return GLP_RSP_OP_CODE_NOT_SUP; + } - // check if opcode is supported - if((racp_req->op_code < GLP_REQ_REP_STRD_RECS) - || (racp_req->op_code > GLP_REQ_REP_NUM_OF_STRD_RECS)) - { - return GLP_RSP_OP_CODE_NOT_SUP; - } - - // Abort operation don't require any other parameter - if(racp_req->op_code == GLP_REQ_ABORT_OP) - { - return GAP_ERR_NO_ERROR; - } - - // check if operator is valid - if(racp_req->filter.operator < GLP_OP_ALL_RECS) - { - return GLP_RSP_INVALID_OPERATOR; - } - // check if operator is supported - else if(racp_req->filter.operator > GLP_OP_LAST_REC) - { - return GLP_RSP_OPERATOR_NOT_SUP; - } - - // check if request requires operand (filter) - if((racp_req->filter.operator >= GLP_OP_LT_OR_EQ) - && (racp_req->filter.operator <= GLP_OP_WITHIN_RANGE_OF)) - { - // verify that enough data present to load operand filter - if(length < cursor) - { - return GLP_RSP_INVALID_OPERAND; - } - - // retrieve command filter type - racp_req->filter.filter_type = packed_val[cursor]; - cursor++; - - // filter uses sequence number - if(racp_req->filter.filter_type == GLP_FILTER_SEQ_NUMBER) - { - // retrieve minimum value - if((racp_req->filter.operator == GLP_OP_GT_OR_EQ) - || (racp_req->filter.operator == GLP_OP_WITHIN_RANGE_OF)) - { - // check sufficient data available - if((length - cursor) < 2) - { - return GLP_RSP_INVALID_OPERAND; - } - - // retrieve minimum value - racp_req->filter.val.seq_num.min = co_read16p(packed_val + cursor); - cursor +=2; - } - - // retrieve maximum value - if((racp_req->filter.operator == GLP_OP_LT_OR_EQ) - || (racp_req->filter.operator == GLP_OP_WITHIN_RANGE_OF)) - { - if((length - cursor) < 2) - { - return GLP_RSP_INVALID_OPERAND; - } - - // retrieve maximum value - racp_req->filter.val.seq_num.max = co_read16p(packed_val + cursor); - cursor +=2; - } - - - // check that range value is valid - if((racp_req->filter.operator == GLP_OP_WITHIN_RANGE_OF) - && (racp_req->filter.val.seq_num.min > racp_req->filter.val.seq_num.max)) - { - return GLP_RSP_INVALID_OPERAND; - } - } - // filter uses user facing time - else if (racp_req->filter.filter_type == GLP_FILTER_USER_FACING_TIME) - { - // retrieve minimum value - if((racp_req->filter.operator == GLP_OP_GT_OR_EQ) - || (racp_req->filter.operator == GLP_OP_WITHIN_RANGE_OF)) - { - // check sufficient data available - if((length - cursor) < GLPS_FILTER_USER_FACING_TIME_SIZE) - { - return GLP_RSP_INVALID_OPERAND; - } - - // retrieve minimum facing time - cursor += prf_unpack_date_time((packed_val + cursor), - &(racp_req->filter.val.time.facetime_min)); - cursor +=2; - } - - // retrieve maximum value - if((racp_req->filter.operator == GLP_OP_LT_OR_EQ) - || (racp_req->filter.operator == GLP_OP_WITHIN_RANGE_OF)) - { - if((length - cursor) < GLPS_FILTER_USER_FACING_TIME_SIZE) - { - return GLP_RSP_INVALID_OPERAND; - } - - // retrieve maximum facing time - cursor += prf_unpack_date_time((packed_val + cursor), - &(racp_req->filter.val.time.facetime_max)); - } - } - else - { - return GLP_RSP_OPERAND_NOT_SUP; - } - } - else if ((length - cursor) != 0) - { - return GLP_RSP_INVALID_OPERAND; - } - - // Check that operand is valid + // Abort operation don't require any other parameter + if (racp_req->op_code == GLP_REQ_ABORT_OP) { return GAP_ERR_NO_ERROR; + } + + // check if operator is valid + if (racp_req->filter.operatorfilter.operator> GLP_OP_LAST_REC) { + return GLP_RSP_OPERATOR_NOT_SUP; + } + + // check if request requires operand (filter) + if ((racp_req->filter.operator>= GLP_OP_LT_OR_EQ) && + (racp_req->filter.operator<= GLP_OP_WITHIN_RANGE_OF)) { + // verify that enough data present to load operand filter + if (length < cursor) { + return GLP_RSP_INVALID_OPERAND; + } + + // retrieve command filter type + racp_req->filter.filter_type = packed_val[cursor]; + cursor++; + + // filter uses sequence number + if (racp_req->filter.filter_type == GLP_FILTER_SEQ_NUMBER) { + // retrieve minimum value + if ((racp_req->filter.operator== GLP_OP_GT_OR_EQ) || + (racp_req->filter.operator== GLP_OP_WITHIN_RANGE_OF)) { + // check sufficient data available + if ((length - cursor) < 2) { + return GLP_RSP_INVALID_OPERAND; + } + + // retrieve minimum value + racp_req->filter.val.seq_num.min = co_read16p(packed_val + cursor); + cursor += 2; + } + + // retrieve maximum value + if ((racp_req->filter.operator== GLP_OP_LT_OR_EQ) || + (racp_req->filter.operator== GLP_OP_WITHIN_RANGE_OF)) { + if ((length - cursor) < 2) { + return GLP_RSP_INVALID_OPERAND; + } + + // retrieve maximum value + racp_req->filter.val.seq_num.max = co_read16p(packed_val + cursor); + cursor += 2; + } + + // check that range value is valid + if ((racp_req->filter.operator== GLP_OP_WITHIN_RANGE_OF) && + (racp_req->filter.val.seq_num.min > + racp_req->filter.val.seq_num.max)) { + return GLP_RSP_INVALID_OPERAND; + } + } + // filter uses user facing time + else if (racp_req->filter.filter_type == GLP_FILTER_USER_FACING_TIME) { + // retrieve minimum value + if ((racp_req->filter.operator== GLP_OP_GT_OR_EQ) || + (racp_req->filter.operator== GLP_OP_WITHIN_RANGE_OF)) { + // check sufficient data available + if ((length - cursor) < GLPS_FILTER_USER_FACING_TIME_SIZE) { + return GLP_RSP_INVALID_OPERAND; + } + + // retrieve minimum facing time + cursor += prf_unpack_date_time( + (packed_val + cursor), &(racp_req->filter.val.time.facetime_min)); + cursor += 2; + } + + // retrieve maximum value + if ((racp_req->filter.operator== GLP_OP_LT_OR_EQ) || + (racp_req->filter.operator== GLP_OP_WITHIN_RANGE_OF)) { + if ((length - cursor) < GLPS_FILTER_USER_FACING_TIME_SIZE) { + return GLP_RSP_INVALID_OPERAND; + } + + // retrieve maximum facing time + cursor += prf_unpack_date_time( + (packed_val + cursor), &(racp_req->filter.val.time.facetime_max)); + } + } else { + return GLP_RSP_OPERAND_NOT_SUP; + } + } else if ((length - cursor) != 0) { + return GLP_RSP_INVALID_OPERAND; + } + + // Check that operand is valid + return GAP_ERR_NO_ERROR; } -uint8_t glps_pack_racp_rsp(uint8_t *packed_val, - struct glp_racp_rsp* racp_rsp) -{ - uint8_t cursor = 0; +uint8_t glps_pack_racp_rsp(uint8_t *packed_val, struct glp_racp_rsp *racp_rsp) { + uint8_t cursor = 0; - // set response op code - packed_val[cursor] = racp_rsp->op_code; + // set response op code + packed_val[cursor] = racp_rsp->op_code; + cursor++; + + // set operator (null) + packed_val[cursor] = 0; + cursor++; + + // number of record + if (racp_rsp->op_code == GLP_REQ_NUM_OF_STRD_RECS_RSP) { + co_write16(packed_val + cursor, racp_rsp->operand.num_of_record); + cursor += 2; + } else { + // requested opcode + packed_val[cursor] = racp_rsp->operand.rsp.op_code_req; + ; cursor++; - - // set operator (null) - packed_val[cursor] = 0; + // command status + packed_val[cursor] = racp_rsp->operand.rsp.status; cursor++; + } - // number of record - if(racp_rsp->op_code == GLP_REQ_NUM_OF_STRD_RECS_RSP) - { - co_write16(packed_val+cursor, racp_rsp->operand.num_of_record); - cursor += 2; - } - else - { - // requested opcode - packed_val[cursor] = racp_rsp->operand.rsp.op_code_req;; - cursor++; - // command status - packed_val[cursor] = racp_rsp->operand.rsp.status; - cursor++; - } - - return cursor; + return cursor; } #endif /* BLE_GL_SENSOR */ diff --git a/services/ble_profiles/glp/glps/src/glps_task.c b/services/ble_profiles/glp/glps/src/glps_task.c index 2a67cfc..0f24a38 100644 --- a/services/ble_profiles/glp/glps/src/glps_task.c +++ b/services/ble_profiles/glp/glps/src/glps_task.c @@ -20,15 +20,14 @@ #include "glps_task.h" #include "prf_utils.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * GLUCOSE PROFILE ATTRIBUTES **************************************************************************************** */ - /* * LOCAL FUNCTIONS DEFINITIONS **************************************************************************************** @@ -37,7 +36,8 @@ /** **************************************************************************************** * @brief Handles reception of the @ref GLPS_ENABLE_REQ message. - * The handler enables the Glucose Sensor Profile and initialize readable values. + * The handler enables the Glucose Sensor Profile and initialize readable + *values. * @param[in] msgid Id of the message received (probably unused).off * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -46,33 +46,30 @@ **************************************************************************************** */ __STATIC int glps_enable_req_handler(ke_msg_id_t const msgid, - struct glps_enable_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - uint8_t status = PRF_ERR_REQ_DISALLOWED; - struct glps_enable_rsp * cmp_evt; + struct glps_enable_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + uint8_t status = PRF_ERR_REQ_DISALLOWED; + struct glps_enable_rsp *cmp_evt; - if(state == GLPS_IDLE) - { - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct glps_env_tag *glps_env = PRF_ENV_GET(GLPS, glps); - if(!GLPS_IS(conidx, BOND_DATA_PRESENT)) - { - GLPS_SET(conidx, BOND_DATA_PRESENT); - status = GAP_ERR_NO_ERROR; - glps_env->env[conidx]->evt_cfg = param->evt_cfg; - } + if (state == GLPS_IDLE) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct glps_env_tag *glps_env = PRF_ENV_GET(GLPS, glps); + if (!GLPS_IS(conidx, BOND_DATA_PRESENT)) { + GLPS_SET(conidx, BOND_DATA_PRESENT); + status = GAP_ERR_NO_ERROR; + glps_env->env[conidx]->evt_cfg = param->evt_cfg; } + } - // send completed information to APP task that contains error status - cmp_evt = KE_MSG_ALLOC(GLPS_ENABLE_RSP, src_id, dest_id, glps_enable_rsp); - cmp_evt->status = status; - ke_msg_send(cmp_evt); + // send completed information to APP task that contains error status + cmp_evt = KE_MSG_ALLOC(GLPS_ENABLE_RSP, src_id, dest_id, glps_enable_rsp); + cmp_evt->status = status; + ke_msg_send(cmp_evt); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -85,107 +82,97 @@ __STATIC int glps_enable_req_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int glps_meas_send_req_handler(ke_msg_id_t const msgid, - struct glps_send_meas_with_ctx_cmd const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); - uint8_t status = PRF_ERR_REQ_DISALLOWED; +__STATIC int glps_meas_send_req_handler( + ke_msg_id_t const msgid, struct glps_send_meas_with_ctx_cmd const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t state = ke_state_get(dest_id); + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if(state == GLPS_IDLE) - { - // Get the address of the environment - struct glps_env_tag *glps_env = PRF_ENV_GET(GLPS, glps); + if (state == GLPS_IDLE) { + // Get the address of the environment + struct glps_env_tag *glps_env = PRF_ENV_GET(GLPS, glps); - //Cannot send another measurement in parallel - if(!GLPS_IS(conidx, SENDING_MEAS)) - { - // inform that device is sending a measurement - GLPS_SET(conidx, SENDING_MEAS); + // Cannot send another measurement in parallel + if (!GLPS_IS(conidx, SENDING_MEAS)) { + // inform that device is sending a measurement + GLPS_SET(conidx, SENDING_MEAS); - // check if context is supported - if((msgid == GLPS_SEND_MEAS_WITH_CTX_CMD) && !(glps_env->meas_ctx_supported)) - { - // Context not supported - status = (PRF_ERR_FEATURE_NOT_SUPPORTED); - } - // check if notifications enabled - else if(((glps_env->env[conidx]->evt_cfg & GLPS_MEAS_NTF_CFG) == 0) - || (((glps_env->env[conidx]->evt_cfg & GLPS_MEAS_CTX_NTF_CFG) == 0) - && (msgid == GLPS_SEND_MEAS_WITH_CTX_CMD))) - { - // Not allowed to send measurement if Notifications not enabled. - status = (PRF_ERR_NTF_DISABLED); - } - else - { - // Allocate the GATT notification message - struct gattc_send_evt_cmd *meas_val = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), dest_id, - gattc_send_evt_cmd, GLP_MEAS_MAX_LEN); + // check if context is supported + if ((msgid == GLPS_SEND_MEAS_WITH_CTX_CMD) && + !(glps_env->meas_ctx_supported)) { + // Context not supported + status = (PRF_ERR_FEATURE_NOT_SUPPORTED); + } + // check if notifications enabled + else if (((glps_env->env[conidx]->evt_cfg & GLPS_MEAS_NTF_CFG) == 0) || + (((glps_env->env[conidx]->evt_cfg & GLPS_MEAS_CTX_NTF_CFG) == + 0) && + (msgid == GLPS_SEND_MEAS_WITH_CTX_CMD))) { + // Not allowed to send measurement if Notifications not enabled. + status = (PRF_ERR_NTF_DISABLED); + } else { + // Allocate the GATT notification message + struct gattc_send_evt_cmd *meas_val = KE_MSG_ALLOC_DYN( + GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), dest_id, + gattc_send_evt_cmd, GLP_MEAS_MAX_LEN); - // Fill in the parameter structure - meas_val->operation = GATTC_NOTIFY; - meas_val->handle = GLPS_HANDLE(GLS_IDX_MEAS_VAL); - // pack measured value in database - meas_val->length = glps_pack_meas_value(meas_val->value, &(param->meas), param->seq_num); + // Fill in the parameter structure + meas_val->operation = GATTC_NOTIFY; + meas_val->handle = GLPS_HANDLE(GLS_IDX_MEAS_VAL); + // pack measured value in database + meas_val->length = glps_pack_meas_value(meas_val->value, &(param->meas), + param->seq_num); - // Measurement value notification not yet sent - GLPS_CLEAR(conidx, MEAS_SENT); + // Measurement value notification not yet sent + GLPS_CLEAR(conidx, MEAS_SENT); - // Send the event - ke_msg_send(meas_val); + // Send the event + ke_msg_send(meas_val); - if(msgid == GLPS_SEND_MEAS_WITH_CTX_CMD) - { - // Allocate the GATT notification message - struct gattc_send_evt_cmd *meas_ctx_val = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), dest_id, - gattc_send_evt_cmd, GLP_MEAS_CTX_MAX_LEN); + if (msgid == GLPS_SEND_MEAS_WITH_CTX_CMD) { + // Allocate the GATT notification message + struct gattc_send_evt_cmd *meas_ctx_val = KE_MSG_ALLOC_DYN( + GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), dest_id, + gattc_send_evt_cmd, GLP_MEAS_CTX_MAX_LEN); - // Fill in the parameter structure - meas_ctx_val->operation = GATTC_NOTIFY; - meas_ctx_val->handle = GLPS_HANDLE(GLS_IDX_MEAS_CTX_VAL); - // pack measured value in database - meas_ctx_val->length = glps_pack_meas_ctx_value(meas_ctx_val->value, &(param->ctx), param->seq_num); + // Fill in the parameter structure + meas_ctx_val->operation = GATTC_NOTIFY; + meas_ctx_val->handle = GLPS_HANDLE(GLS_IDX_MEAS_CTX_VAL); + // pack measured value in database + meas_ctx_val->length = glps_pack_meas_ctx_value( + meas_ctx_val->value, &(param->ctx), param->seq_num); - // 2 notification complete messages expected - GLPS_SET(conidx, MEAS_CTX_SENT); + // 2 notification complete messages expected + GLPS_SET(conidx, MEAS_CTX_SENT); - // Send the event - ke_msg_send(meas_ctx_val); - } - else - { - // 1 notification complete messages expected - GLPS_CLEAR(conidx, MEAS_CTX_SENT); - } - - status = (GAP_ERR_NO_ERROR); - } + // Send the event + ke_msg_send(meas_ctx_val); + } else { + // 1 notification complete messages expected + GLPS_CLEAR(conidx, MEAS_CTX_SENT); } + + status = (GAP_ERR_NO_ERROR); + } } + } - // send command complete if an error occurs - if(status != GAP_ERR_NO_ERROR) - { - // send completed information to APP task that contains error status - struct glps_cmp_evt * cmp_evt = KE_MSG_ALLOC(GLPS_CMP_EVT, src_id, - dest_id, glps_cmp_evt); + // send command complete if an error occurs + if (status != GAP_ERR_NO_ERROR) { + // send completed information to APP task that contains error status + struct glps_cmp_evt *cmp_evt = + KE_MSG_ALLOC(GLPS_CMP_EVT, src_id, dest_id, glps_cmp_evt); - cmp_evt->request = GLPS_SEND_MEAS_REQ_NTF_CMP; - cmp_evt->status = status; + cmp_evt->request = GLPS_SEND_MEAS_REQ_NTF_CMP; + cmp_evt->status = status; - ke_msg_send(cmp_evt); - } + ke_msg_send(cmp_evt); + } - - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } - /** **************************************************************************************** * @brief Handles reception of the @ref GLPS_SEND_RACP_RSP_CMD message. @@ -198,92 +185,83 @@ __STATIC int glps_meas_send_req_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int glps_send_racp_rsp_cmd_handler(ke_msg_id_t const msgid, - struct glps_send_racp_rsp_cmd const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = PRF_ERR_REQ_DISALLOWED; - uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); +__STATIC int glps_send_racp_rsp_cmd_handler( + ke_msg_id_t const msgid, struct glps_send_racp_rsp_cmd const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Status + uint8_t status = PRF_ERR_REQ_DISALLOWED; + uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t state = ke_state_get(dest_id); - if(state == GLPS_IDLE) - { - // Get the address of the environment - struct glps_env_tag *glps_env = PRF_ENV_GET(GLPS, glps); + if (state == GLPS_IDLE) { + // Get the address of the environment + struct glps_env_tag *glps_env = PRF_ENV_GET(GLPS, glps); - // check if op code valid - if((param->op_code < GLP_REQ_REP_STRD_RECS) - || (param->op_code > GLP_REQ_REP_NUM_OF_STRD_RECS)) - { - //Wrong op code - status = PRF_ERR_INVALID_PARAM; - } - // check if RACP on going - else if((param->op_code != GLP_REQ_ABORT_OP) && !(GLPS_IS(conidx, RACP_ON_GOING))) - { - //Cannot send response since no RACP on going - status = PRF_ERR_REQ_DISALLOWED; - } - // Indication not enabled on peer device - else if((glps_env->env[conidx]->evt_cfg & GLPS_RACP_IND_CFG) == 0) - { - status = PRF_ERR_IND_DISABLED; - // There is no more RACP on going - GLPS_CLEAR(conidx, RACP_ON_GOING); - } - else - { - struct glp_racp_rsp racp_rsp; - // Allocate the GATT indication message - struct gattc_send_evt_cmd *racp_rsp_val = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), dest_id, - gattc_send_evt_cmd, GLP_REC_ACCESS_CTRL_MAX_LEN); - - // Fill in the parameter structure - racp_rsp_val->operation = GATTC_INDICATE; - racp_rsp_val->handle = GLPS_HANDLE(GLS_IDX_REC_ACCESS_CTRL_VAL); - - // Number of stored record calculation succeed. - if((param->op_code == GLP_REQ_REP_NUM_OF_STRD_RECS) - && ( param->status == GLP_RSP_SUCCESS)) - { - racp_rsp.op_code = GLP_REQ_NUM_OF_STRD_RECS_RSP; - racp_rsp.operand.num_of_record = param->num_of_record; - } - // Send back status information - else - { - racp_rsp.op_code = GLP_REQ_RSP_CODE; - racp_rsp.operand.rsp.op_code_req = param->op_code; - racp_rsp.operand.rsp.status = param->status; - } - - // pack measured value in database - racp_rsp_val->length = glps_pack_racp_rsp(racp_rsp_val->value, &racp_rsp); - - // There is no more RACP on going - GLPS_CLEAR(conidx, RACP_ON_GOING); - status = GAP_ERR_NO_ERROR; - - // Store that response sent by application - GLPS_SET(conidx, RACP_RSP_SENT_BY_APP); - - // send RACP Response indication - ke_msg_send(racp_rsp_val); - } + // check if op code valid + if ((param->op_code < GLP_REQ_REP_STRD_RECS) || + (param->op_code > GLP_REQ_REP_NUM_OF_STRD_RECS)) { + // Wrong op code + status = PRF_ERR_INVALID_PARAM; } - - if (status != GAP_ERR_NO_ERROR) - { - // send completed information about request failed - struct glps_cmp_evt * cmp_evt = KE_MSG_ALLOC(GLPS_CMP_EVT, src_id, dest_id, glps_cmp_evt); - cmp_evt->request = GLPS_SEND_RACP_RSP_IND_CMP; - cmp_evt->status = status; - ke_msg_send(cmp_evt); + // check if RACP on going + else if ((param->op_code != GLP_REQ_ABORT_OP) && + !(GLPS_IS(conidx, RACP_ON_GOING))) { + // Cannot send response since no RACP on going + status = PRF_ERR_REQ_DISALLOWED; } - return (KE_MSG_CONSUMED); + // Indication not enabled on peer device + else if ((glps_env->env[conidx]->evt_cfg & GLPS_RACP_IND_CFG) == 0) { + status = PRF_ERR_IND_DISABLED; + // There is no more RACP on going + GLPS_CLEAR(conidx, RACP_ON_GOING); + } else { + struct glp_racp_rsp racp_rsp; + // Allocate the GATT indication message + struct gattc_send_evt_cmd *racp_rsp_val = KE_MSG_ALLOC_DYN( + GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), dest_id, + gattc_send_evt_cmd, GLP_REC_ACCESS_CTRL_MAX_LEN); + + // Fill in the parameter structure + racp_rsp_val->operation = GATTC_INDICATE; + racp_rsp_val->handle = GLPS_HANDLE(GLS_IDX_REC_ACCESS_CTRL_VAL); + + // Number of stored record calculation succeed. + if ((param->op_code == GLP_REQ_REP_NUM_OF_STRD_RECS) && + (param->status == GLP_RSP_SUCCESS)) { + racp_rsp.op_code = GLP_REQ_NUM_OF_STRD_RECS_RSP; + racp_rsp.operand.num_of_record = param->num_of_record; + } + // Send back status information + else { + racp_rsp.op_code = GLP_REQ_RSP_CODE; + racp_rsp.operand.rsp.op_code_req = param->op_code; + racp_rsp.operand.rsp.status = param->status; + } + + // pack measured value in database + racp_rsp_val->length = glps_pack_racp_rsp(racp_rsp_val->value, &racp_rsp); + + // There is no more RACP on going + GLPS_CLEAR(conidx, RACP_ON_GOING); + status = GAP_ERR_NO_ERROR; + + // Store that response sent by application + GLPS_SET(conidx, RACP_RSP_SENT_BY_APP); + + // send RACP Response indication + ke_msg_send(racp_rsp_val); + } + } + + if (status != GAP_ERR_NO_ERROR) { + // send completed information about request failed + struct glps_cmp_evt *cmp_evt = + KE_MSG_ALLOC(GLPS_CMP_EVT, src_id, dest_id, glps_cmp_evt); + cmp_evt->request = GLPS_SEND_RACP_RSP_IND_CMP; + cmp_evt->status = status; + ke_msg_send(cmp_evt); + } + return (KE_MSG_CONSUMED); } /** @@ -297,55 +275,48 @@ __STATIC int glps_send_racp_rsp_cmd_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_att_info_req_ind *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); +__STATIC int gattc_att_info_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_att_info_req_ind *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == GLPS_IDLE) - { - struct glps_env_tag *glps_env = PRF_ENV_GET(GLPS, glps); - uint8_t att_idx = GLPS_IDX(param->handle); - struct gattc_att_info_cfm * cfm; + if (state == GLPS_IDLE) { + struct glps_env_tag *glps_env = PRF_ENV_GET(GLPS, glps); + uint8_t att_idx = GLPS_IDX(param->handle); + struct gattc_att_info_cfm *cfm; - //Send write response - cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); - cfm->handle = param->handle; + // Send write response + cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); + cfm->handle = param->handle; - // check if it's a client configuration char - if((att_idx == GLS_IDX_MEAS_NTF_CFG) - || (att_idx == GLS_IDX_MEAS_CTX_NTF_CFG) - || (att_idx == GLS_IDX_REC_ACCESS_CTRL_IND_CFG)) - { - // CCC attribute length = 2 - cfm->length = 2; - cfm->status = GAP_ERR_NO_ERROR; - } - else if (att_idx == GLS_IDX_REC_ACCESS_CTRL_VAL) - { - // force length to zero to reject any write starting from something != 0 - cfm->length = 0; - cfm->status = GAP_ERR_NO_ERROR; - } - // not expected request - else - { - cfm->length = 0; - cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; - } - ke_msg_send(cfm); - } + // check if it's a client configuration char + if ((att_idx == GLS_IDX_MEAS_NTF_CFG) || + (att_idx == GLS_IDX_MEAS_CTX_NTF_CFG) || + (att_idx == GLS_IDX_REC_ACCESS_CTRL_IND_CFG)) { + // CCC attribute length = 2 + cfm->length = 2; + cfm->status = GAP_ERR_NO_ERROR; + } else if (att_idx == GLS_IDX_REC_ACCESS_CTRL_VAL) { + // force length to zero to reject any write starting from something != 0 + cfm->length = 0; + cfm->status = GAP_ERR_NO_ERROR; + } + // not expected request + else { + cfm->length = 0; + cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; + } + ke_msg_send(cfm); + } - - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** **************************************************************************************** * @brief Handles reception of the @ref GATT_CODE_ATT_WR_CMD_IND message. - * The handler compares the new values with current ones and notifies them if they changed. + * The handler compares the new values with current ones and notifies them if + *they changed. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -354,192 +325,164 @@ __STATIC int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_write_req_ind *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - struct glp_racp_rsp racp_rsp; - racp_rsp.op_code = 0; + struct gattc_write_req_ind *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + struct glp_racp_rsp racp_rsp; + racp_rsp.op_code = 0; - if(state == GLPS_IDLE) - { - uint8_t status = GAP_ERR_NO_ERROR; - struct gattc_write_cfm * cfm; - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct glps_env_tag *glps_env = PRF_ENV_GET(GLPS, glps); - uint8_t att_idx = GLPS_IDX(param->handle); + if (state == GLPS_IDLE) { + uint8_t status = GAP_ERR_NO_ERROR; + struct gattc_write_cfm *cfm; + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct glps_env_tag *glps_env = PRF_ENV_GET(GLPS, glps); + uint8_t att_idx = GLPS_IDX(param->handle); - if(param->offset != 0) - { - status = ATT_ERR_UNLIKELY_ERR; - } - // check if it's a client configuration char - else if((att_idx == GLS_IDX_MEAS_NTF_CFG) - || (att_idx == GLS_IDX_MEAS_CTX_NTF_CFG) - || (att_idx == GLS_IDX_REC_ACCESS_CTRL_IND_CFG)) - { - uint16_t cli_cfg; - uint8_t evt_mask = GLPS_IND_NTF_EVT(att_idx); + if (param->offset != 0) { + status = ATT_ERR_UNLIKELY_ERR; + } + // check if it's a client configuration char + else if ((att_idx == GLS_IDX_MEAS_NTF_CFG) || + (att_idx == GLS_IDX_MEAS_CTX_NTF_CFG) || + (att_idx == GLS_IDX_REC_ACCESS_CTRL_IND_CFG)) { + uint16_t cli_cfg; + uint8_t evt_mask = GLPS_IND_NTF_EVT(att_idx); - // get client configuration - cli_cfg = co_read16(&(param->value)); + // get client configuration + cli_cfg = co_read16(&(param->value)); - // stop indication/notification - if(cli_cfg == PRF_CLI_STOP_NTFIND) - { - glps_env->env[conidx]->evt_cfg &= ~evt_mask; - } - // start indication/notification (check that char value accept it) - else if(((att_idx == GLS_IDX_REC_ACCESS_CTRL_IND_CFG) && (cli_cfg == PRF_CLI_START_IND)) - ||((att_idx != GLS_IDX_REC_ACCESS_CTRL_IND_CFG) && (cli_cfg == PRF_CLI_START_NTF))) - { - glps_env->env[conidx]->evt_cfg |= evt_mask; - } - // improper value - else - { - status = GLP_ERR_IMPROPER_CLI_CHAR_CFG; - } + // stop indication/notification + if (cli_cfg == PRF_CLI_STOP_NTFIND) { + glps_env->env[conidx]->evt_cfg &= ~evt_mask; + } + // start indication/notification (check that char value accept it) + else if (((att_idx == GLS_IDX_REC_ACCESS_CTRL_IND_CFG) && + (cli_cfg == PRF_CLI_START_IND)) || + ((att_idx != GLS_IDX_REC_ACCESS_CTRL_IND_CFG) && + (cli_cfg == PRF_CLI_START_NTF))) { + glps_env->env[conidx]->evt_cfg |= evt_mask; + } + // improper value + else { + status = GLP_ERR_IMPROPER_CLI_CHAR_CFG; + } - if (status == GAP_ERR_NO_ERROR) - { - //Inform APP of configuration change - struct glps_cfg_indntf_ind * ind = KE_MSG_ALLOC(GLPS_CFG_INDNTF_IND, - prf_dst_task_get(&(glps_env->prf_env), conidx), dest_id, glps_cfg_indntf_ind); - ind->evt_cfg = glps_env->env[conidx]->evt_cfg; - ke_msg_send(ind); - } - } - - else if (att_idx == GLS_IDX_REC_ACCESS_CTRL_VAL) - { - if((glps_env->env[conidx]->evt_cfg & GLPS_RACP_IND_CFG) == 0) - { - // do nothing since indication not enabled for this characteristic - status = GLP_ERR_IMPROPER_CLI_CHAR_CFG; - } - // If a request is on going - else if(GLPS_IS(conidx, RACP_ON_GOING)) - { - // if it's an abort command, execute it. - if((param->offset == 0) && (param->value[0] == GLP_REQ_ABORT_OP)) - { - //forward abort operation to application - struct glps_racp_req_rcv_ind * req = KE_MSG_ALLOC(GLPS_RACP_REQ_RCV_IND, - prf_dst_task_get(&(glps_env->prf_env), conidx), dest_id, glps_racp_req_rcv_ind); - req->racp_req.op_code = GLP_REQ_ABORT_OP; - req->racp_req.filter.operator = 0; - ke_msg_send(req); - } - else - { - // do nothing since a procedure already in progress - status = GLP_ERR_PROC_ALREADY_IN_PROGRESS; - } - } - else - { - struct glp_racp_req racp_req; - // unpack record access control point value - uint8_t reqstatus = glps_unpack_racp_req(param->value, param->length, &racp_req); - - // check unpacked status - switch(reqstatus) - { - case PRF_APP_ERROR: - { - /* Request failed */ - status = ATT_ERR_UNLIKELY_ERR; - } - break; - case GAP_ERR_NO_ERROR: - { - // check wich request shall be send to api task - switch(racp_req.op_code) - { - case GLP_REQ_REP_STRD_RECS: - case GLP_REQ_DEL_STRD_RECS: - case GLP_REQ_REP_NUM_OF_STRD_RECS: - { - //forward request operation to application - struct glps_racp_req_rcv_ind * req = KE_MSG_ALLOC(GLPS_RACP_REQ_RCV_IND, - prf_dst_task_get(&(glps_env->prf_env), conidx), dest_id, - glps_racp_req_rcv_ind); - req->racp_req = racp_req; - // RACP on going. - GLPS_SET(conidx, RACP_ON_GOING); - ke_msg_send(req); - } - break; - case GLP_REQ_ABORT_OP: - { - // nothing to abort, send an error message. - racp_rsp.op_code = GLP_REQ_RSP_CODE; - racp_rsp.operand.rsp.op_code_req = - racp_req.op_code; - racp_rsp.operand.rsp.status = GLP_RSP_ABORT_UNSUCCESSFUL; - } - break; - default: - { - // nothing to do since it's handled during unpack - } - break; - } - } - break; - default: - { - /* There is an error in record access control request, inform peer - * device that request is incorrect. */ - racp_rsp.op_code = GLP_REQ_RSP_CODE; - racp_rsp.operand.rsp.op_code_req = racp_req.op_code; - racp_rsp.operand.rsp.status = reqstatus; - } - break; - } - } - } - // not expected request - else - { - status = ATT_ERR_WRITE_NOT_PERMITTED; - } - - //Send write response - cfm = KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = status; - ke_msg_send(cfm); - - /* The racp response has to be sent - after write confirm */ - if(racp_rsp.op_code != 0) - { - // Allocate the GATT indication message - struct gattc_send_evt_cmd *racp_rsp_val = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), dest_id, - gattc_send_evt_cmd, GLP_REC_ACCESS_CTRL_MAX_LEN); - - racp_rsp_val->operation = GATTC_INDICATE; - racp_rsp_val->handle = param->handle; - // pack measured value in database - racp_rsp_val->length = glps_pack_racp_rsp(racp_rsp_val->value, &racp_rsp); - - // Store that response internally sent by profile - GLPS_CLEAR(conidx, RACP_RSP_SENT_BY_APP); - - // send RACP Response indication - ke_msg_send(racp_rsp_val); - } + if (status == GAP_ERR_NO_ERROR) { + // Inform APP of configuration change + struct glps_cfg_indntf_ind *ind = KE_MSG_ALLOC( + GLPS_CFG_INDNTF_IND, prf_dst_task_get(&(glps_env->prf_env), conidx), + dest_id, glps_cfg_indntf_ind); + ind->evt_cfg = glps_env->env[conidx]->evt_cfg; + ke_msg_send(ind); + } } + else if (att_idx == GLS_IDX_REC_ACCESS_CTRL_VAL) { + if ((glps_env->env[conidx]->evt_cfg & GLPS_RACP_IND_CFG) == 0) { + // do nothing since indication not enabled for this characteristic + status = GLP_ERR_IMPROPER_CLI_CHAR_CFG; + } + // If a request is on going + else if (GLPS_IS(conidx, RACP_ON_GOING)) { + // if it's an abort command, execute it. + if ((param->offset == 0) && (param->value[0] == GLP_REQ_ABORT_OP)) { + // forward abort operation to application + struct glps_racp_req_rcv_ind *req = + KE_MSG_ALLOC(GLPS_RACP_REQ_RCV_IND, + prf_dst_task_get(&(glps_env->prf_env), conidx), + dest_id, glps_racp_req_rcv_ind); + req->racp_req.op_code = GLP_REQ_ABORT_OP; + req->racp_req.filter.operator= 0; + ke_msg_send(req); + } else { + // do nothing since a procedure already in progress + status = GLP_ERR_PROC_ALREADY_IN_PROGRESS; + } + } else { + struct glp_racp_req racp_req; + // unpack record access control point value + uint8_t reqstatus = + glps_unpack_racp_req(param->value, param->length, &racp_req); - return (KE_MSG_CONSUMED); + // check unpacked status + switch (reqstatus) { + case PRF_APP_ERROR: { + /* Request failed */ + status = ATT_ERR_UNLIKELY_ERR; + } break; + case GAP_ERR_NO_ERROR: { + // check wich request shall be send to api task + switch (racp_req.op_code) { + case GLP_REQ_REP_STRD_RECS: + case GLP_REQ_DEL_STRD_RECS: + case GLP_REQ_REP_NUM_OF_STRD_RECS: { + // forward request operation to application + struct glps_racp_req_rcv_ind *req = + KE_MSG_ALLOC(GLPS_RACP_REQ_RCV_IND, + prf_dst_task_get(&(glps_env->prf_env), conidx), + dest_id, glps_racp_req_rcv_ind); + req->racp_req = racp_req; + // RACP on going. + GLPS_SET(conidx, RACP_ON_GOING); + ke_msg_send(req); + } break; + case GLP_REQ_ABORT_OP: { + // nothing to abort, send an error message. + racp_rsp.op_code = GLP_REQ_RSP_CODE; + racp_rsp.operand.rsp.op_code_req = racp_req.op_code; + racp_rsp.operand.rsp.status = GLP_RSP_ABORT_UNSUCCESSFUL; + } break; + default: { + // nothing to do since it's handled during unpack + } break; + } + } break; + default: { + /* There is an error in record access control request, inform peer + * device that request is incorrect. */ + racp_rsp.op_code = GLP_REQ_RSP_CODE; + racp_rsp.operand.rsp.op_code_req = racp_req.op_code; + racp_rsp.operand.rsp.status = reqstatus; + } break; + } + } + } + // not expected request + else { + status = ATT_ERR_WRITE_NOT_PERMITTED; + } + + // Send write response + cfm = KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = status; + ke_msg_send(cfm); + + /* The racp response has to be sent - after write confirm */ + if (racp_rsp.op_code != 0) { + // Allocate the GATT indication message + struct gattc_send_evt_cmd *racp_rsp_val = KE_MSG_ALLOC_DYN( + GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), dest_id, + gattc_send_evt_cmd, GLP_REC_ACCESS_CTRL_MAX_LEN); + + racp_rsp_val->operation = GATTC_INDICATE; + racp_rsp_val->handle = param->handle; + // pack measured value in database + racp_rsp_val->length = glps_pack_racp_rsp(racp_rsp_val->value, &racp_rsp); + + // Store that response internally sent by profile + GLPS_CLEAR(conidx, RACP_RSP_SENT_BY_APP); + + // send RACP Response indication + ke_msg_send(racp_rsp_val); + } + } + + return (KE_MSG_CONSUMED); } - /** **************************************************************************************** * @brief Handles reception of the read request from peer device @@ -552,69 +495,62 @@ __STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_read_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - ke_state_t state = ke_state_get(dest_id); + struct gattc_read_req_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + ke_state_t state = ke_state_get(dest_id); - if(state == GLPS_IDLE) - { - // Send value to peer device. - struct gattc_read_cfm* cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(uint16_t)); - cfm->handle = param->handle; - cfm->status = ATT_ERR_NO_ERROR; - cfm->length = sizeof(uint16_t); + if (state == GLPS_IDLE) { + // Send value to peer device. + struct gattc_read_cfm *cfm = KE_MSG_ALLOC_DYN( + GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(uint16_t)); + cfm->handle = param->handle; + cfm->status = ATT_ERR_NO_ERROR; + cfm->length = sizeof(uint16_t); + // Get the address of the environment + struct glps_env_tag *glps_env = PRF_ENV_GET(GLPS, glps); + uint8_t att_idx = GLPS_IDX(param->handle); + uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct glps_env_tag *glps_env = PRF_ENV_GET(GLPS, glps); - uint8_t att_idx = GLPS_IDX(param->handle); - uint8_t conidx = KE_IDX_GET(dest_id); - - switch(att_idx) - { - case GLS_IDX_MEAS_NTF_CFG: - { - co_write16p(cfm->value, (glps_env->env[conidx]->evt_cfg & GLPS_MEAS_NTF_CFG) - ? PRF_CLI_START_NTF : PRF_CLI_STOP_NTFIND); - } - break; - case GLS_IDX_MEAS_CTX_NTF_CFG: - { - co_write16p(cfm->value, (glps_env->env[conidx]->evt_cfg & GLPS_MEAS_CTX_NTF_CFG) - ? PRF_CLI_START_NTF : PRF_CLI_STOP_NTFIND); - } - break; - case GLS_IDX_REC_ACCESS_CTRL_IND_CFG: - { - co_write16p(cfm->value, (glps_env->env[conidx]->evt_cfg & GLPS_RACP_IND_CFG) - ? PRF_CLI_START_IND : PRF_CLI_STOP_NTFIND); - } - break; - case GLS_IDX_FEATURE_VAL: - { - co_write16p(cfm->value, glps_env->features); - } - break; - default: - { - cfm->status = ATT_ERR_INSUFF_AUTHOR; - } - break; - } - - ke_msg_send(cfm); + switch (att_idx) { + case GLS_IDX_MEAS_NTF_CFG: { + co_write16p(cfm->value, + (glps_env->env[conidx]->evt_cfg & GLPS_MEAS_NTF_CFG) + ? PRF_CLI_START_NTF + : PRF_CLI_STOP_NTFIND); + } break; + case GLS_IDX_MEAS_CTX_NTF_CFG: { + co_write16p(cfm->value, + (glps_env->env[conidx]->evt_cfg & GLPS_MEAS_CTX_NTF_CFG) + ? PRF_CLI_START_NTF + : PRF_CLI_STOP_NTFIND); + } break; + case GLS_IDX_REC_ACCESS_CTRL_IND_CFG: { + co_write16p(cfm->value, + (glps_env->env[conidx]->evt_cfg & GLPS_RACP_IND_CFG) + ? PRF_CLI_START_IND + : PRF_CLI_STOP_NTFIND); + } break; + case GLS_IDX_FEATURE_VAL: { + co_write16p(cfm->value, glps_env->features); + } break; + default: { + cfm->status = ATT_ERR_INSUFF_AUTHOR; + } break; } - return (KE_MSG_CONSUMED); -} + ke_msg_send(cfm); + } + return (KE_MSG_CONSUMED); +} /** **************************************************************************************** - * @brief Handles @ref GATTC_CMP_EVT for GATTC_NOTIFY and GATT_INDICATE message meaning - * that Measurement notification/indication has been correctly sent to peer device + * @brief Handles @ref GATTC_CMP_EVT for GATTC_NOTIFY and GATT_INDICATE message + *meaning that Measurement notification/indication has been correctly sent to + *peer device * * * @param[in] msgid Id of the message received. @@ -624,70 +560,64 @@ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); +__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t state = ke_state_get(dest_id); - if(state == GLPS_IDLE) - { - // Get the address of the environment - struct glps_env_tag *glps_env = PRF_ENV_GET(GLPS, glps); + if (state == GLPS_IDLE) { + // Get the address of the environment + struct glps_env_tag *glps_env = PRF_ENV_GET(GLPS, glps); - switch(param->operation) - { - case GATTC_NOTIFY: - { - /* send message indication if an error occurs, - * or if all notification complete event has been received - */ - if((param->status != GAP_ERR_NO_ERROR) - || (!(GLPS_IS(conidx, MEAS_CTX_SENT))) - || (GLPS_IS(conidx, MEAS_CTX_SENT) && (GLPS_IS(conidx, MEAS_SENT)))) - { - GLPS_CLEAR(conidx, SENDING_MEAS); + switch (param->operation) { + case GATTC_NOTIFY: { + /* send message indication if an error occurs, + * or if all notification complete event has been received + */ + if ((param->status != GAP_ERR_NO_ERROR) || + (!(GLPS_IS(conidx, MEAS_CTX_SENT))) || + (GLPS_IS(conidx, MEAS_CTX_SENT) && (GLPS_IS(conidx, MEAS_SENT)))) { + GLPS_CLEAR(conidx, SENDING_MEAS); - // send completed information to APP task - struct glps_cmp_evt * cmp_evt = KE_MSG_ALLOC(GLPS_CMP_EVT, prf_dst_task_get(&(glps_env->prf_env), conidx), - dest_id, glps_cmp_evt); + // send completed information to APP task + struct glps_cmp_evt *cmp_evt = KE_MSG_ALLOC( + GLPS_CMP_EVT, prf_dst_task_get(&(glps_env->prf_env), conidx), + dest_id, glps_cmp_evt); - cmp_evt->request = GLPS_SEND_MEAS_REQ_NTF_CMP; - cmp_evt->status = param->status; + cmp_evt->request = GLPS_SEND_MEAS_REQ_NTF_CMP; + cmp_evt->status = param->status; - ke_msg_send(cmp_evt); - } - else - { - // Measurement value notification sent - GLPS_SET(conidx, MEAS_SENT); - } - } - break; - case GATTC_INDICATE: - { - // verify if indication should be conveyed to application task - if(GLPS_IS(conidx, RACP_RSP_SENT_BY_APP)) - { - // send completed information to APP task - struct glps_cmp_evt * cmp_evt = KE_MSG_ALLOC(GLPS_CMP_EVT, prf_dst_task_get(&(glps_env->prf_env), conidx), - dest_id, glps_cmp_evt); + ke_msg_send(cmp_evt); + } else { + // Measurement value notification sent + GLPS_SET(conidx, MEAS_SENT); + } + } break; + case GATTC_INDICATE: { + // verify if indication should be conveyed to application task + if (GLPS_IS(conidx, RACP_RSP_SENT_BY_APP)) { + // send completed information to APP task + struct glps_cmp_evt *cmp_evt = KE_MSG_ALLOC( + GLPS_CMP_EVT, prf_dst_task_get(&(glps_env->prf_env), conidx), + dest_id, glps_cmp_evt); - cmp_evt->request = GLPS_SEND_RACP_RSP_IND_CMP; - cmp_evt->status = param->status; + cmp_evt->request = GLPS_SEND_RACP_RSP_IND_CMP; + cmp_evt->status = param->status; - ke_msg_send(cmp_evt); - } + ke_msg_send(cmp_evt); + } - GLPS_CLEAR(conidx, RACP_RSP_SENT_BY_APP); - } - break; + GLPS_CLEAR(conidx, RACP_RSP_SENT_BY_APP); + } break; - default: break; - } + default: + break; } + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /* @@ -696,27 +626,25 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt */ /// Default State handlers definition -KE_MSG_HANDLER_TAB(glps) -{ - {GLPS_ENABLE_REQ, (ke_msg_func_t) glps_enable_req_handler}, - {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t) gattc_att_info_req_ind_handler}, - {GATTC_WRITE_REQ_IND, (ke_msg_func_t) gattc_write_req_ind_handler}, - {GATTC_READ_REQ_IND, (ke_msg_func_t) gattc_read_req_ind_handler}, - {GLPS_SEND_MEAS_WITH_CTX_CMD, (ke_msg_func_t) glps_meas_send_req_handler}, - {GLPS_SEND_MEAS_WITHOUT_CTX_CMD, (ke_msg_func_t) glps_meas_send_req_handler}, - {GLPS_SEND_RACP_RSP_CMD, (ke_msg_func_t) glps_send_racp_rsp_cmd_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t) gattc_cmp_evt_handler}, +KE_MSG_HANDLER_TAB(glps){ + {GLPS_ENABLE_REQ, (ke_msg_func_t)glps_enable_req_handler}, + {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t)gattc_att_info_req_ind_handler}, + {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, + {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, + {GLPS_SEND_MEAS_WITH_CTX_CMD, (ke_msg_func_t)glps_meas_send_req_handler}, + {GLPS_SEND_MEAS_WITHOUT_CTX_CMD, (ke_msg_func_t)glps_meas_send_req_handler}, + {GLPS_SEND_RACP_RSP_CMD, (ke_msg_func_t)glps_send_racp_rsp_cmd_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void glps_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct glps_env_tag *glps_env = PRF_ENV_GET(GLPS, glps); +void glps_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct glps_env_tag *glps_env = PRF_ENV_GET(GLPS, glps); - task_desc->msg_handler_tab = glps_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(glps_msg_handler_tab); - task_desc->state = glps_env->state; - task_desc->idx_max = GLPS_IDX_MAX; + task_desc->msg_handler_tab = glps_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(glps_msg_handler_tab); + task_desc->state = glps_env->state; + task_desc->idx_max = GLPS_IDX_MAX; } #endif /* #if (BLE_GL_SENSOR) */ diff --git a/services/ble_profiles/hogp/hogpbh/src/hogpbh.c b/services/ble_profiles/hogp/hogpbh/src/hogpbh.c index df59171..898553e 100644 --- a/services/ble_profiles/hogp/hogpbh/src/hogpbh.c +++ b/services/ble_profiles/hogp/hogpbh/src/hogpbh.c @@ -13,10 +13,10 @@ #include "rwip_config.h" #if (BLE_HID_BOOT_HOST) -#include "hogpbh.h" -#include "hogpbh_task.h" #include "co_math.h" #include "gap.h" +#include "hogpbh.h" +#include "hogpbh_task.h" #include "ke_mem.h" @@ -37,74 +37,73 @@ * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t hogpbh_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t idx; - //-------------------- allocate memory required for the profile --------------------- +static uint8_t hogpbh_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t idx; + //-------------------- allocate memory required for the profile + //--------------------- - struct hogpbh_env_tag* hogpbh_env = - (struct hogpbh_env_tag* ) ke_malloc(sizeof(struct hogpbh_env_tag), KE_MEM_ATT_DB); + struct hogpbh_env_tag *hogpbh_env = (struct hogpbh_env_tag *)ke_malloc( + sizeof(struct hogpbh_env_tag), KE_MEM_ATT_DB); - // allocate HOGPBH required environment variable - env->env = (prf_env_t*) hogpbh_env; + // allocate HOGPBH required environment variable + env->env = (prf_env_t *)hogpbh_env; - hogpbh_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - hogpbh_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + hogpbh_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + hogpbh_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_HOGPBH; - hogpbh_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_HOGPBH; + hogpbh_task_init(&(env->desc)); - for(idx = 0; idx < HOGPBH_IDX_MAX ; idx++) - { - hogpbh_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), HOGPBH_FREE); - } + for (idx = 0; idx < HOGPBH_IDX_MAX; idx++) { + hogpbh_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), HOGPBH_FREE); + } - - return GAP_ERR_NO_ERROR; + return GAP_ERR_NO_ERROR; } /** **************************************************************************************** * @brief Destruction of the HOGPBH module - due to a reset for instance. - * This function clean-up allocated memory (attribute datahide is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute datahide is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void hogpbh_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct hogpbh_env_tag* hogpbh_env = (struct hogpbh_env_tag*) env->env; +static void hogpbh_destroy(struct prf_task_env *env) { + uint8_t idx; + struct hogpbh_env_tag *hogpbh_env = (struct hogpbh_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < HOGPBH_IDX_MAX ; idx++) - { - if(hogpbh_env->env[idx] != NULL) - { - if(hogpbh_env->env[idx]->operation != NULL) - { - ke_free(hogpbh_env->env[idx]->operation); - } - ke_free(hogpbh_env->env[idx]); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < HOGPBH_IDX_MAX; idx++) { + if (hogpbh_env->env[idx] != NULL) { + if (hogpbh_env->env[idx]->operation != NULL) { + ke_free(hogpbh_env->env[idx]->operation); + } + ke_free(hogpbh_env->env[idx]); } + } - // free profile environment variables - env->env = NULL; - ke_free(hogpbh_env); + // free profile environment variables + env->env = NULL; + ke_free(hogpbh_env); } /** @@ -115,10 +114,9 @@ static void hogpbh_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void hogpbh_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Put HID Client in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), HOGPBH_IDLE); +static void hogpbh_create(struct prf_task_env *env, uint8_t conidx) { + /* Put HID Client in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), HOGPBH_IDLE); } /** @@ -130,23 +128,21 @@ static void hogpbh_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void hogpbh_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct hogpbh_env_tag* hogpbh_env = (struct hogpbh_env_tag*) env->env; +static void hogpbh_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct hogpbh_env_tag *hogpbh_env = (struct hogpbh_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(hogpbh_env->env[conidx] != NULL) - { - if(hogpbh_env->env[conidx]->operation != NULL) - { - ke_free(hogpbh_env->env[conidx]->operation); - } - ke_free(hogpbh_env->env[conidx]); - hogpbh_env->env[conidx] = NULL; + // clean-up environment variable allocated for task instance + if (hogpbh_env->env[conidx] != NULL) { + if (hogpbh_env->env[conidx]->operation != NULL) { + ke_free(hogpbh_env->env[conidx]->operation); } + ke_free(hogpbh_env->env[conidx]); + hogpbh_env->env[conidx] = NULL; + } - /* Put HID Client in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), HOGPBH_FREE); + /* Put HID Client in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), HOGPBH_FREE); } /* @@ -155,51 +151,46 @@ static void hogpbh_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t rea */ /// HOGPBH Task interface required by profile manager -const struct prf_task_cbs hogpbh_itf = -{ - hogpbh_init, - hogpbh_destroy, - hogpbh_create, - hogpbh_cleanup, +const struct prf_task_cbs hogpbh_itf = { + hogpbh_init, + hogpbh_destroy, + hogpbh_create, + hogpbh_cleanup, }; - /* * GLOBAL FUNCTIONS DEFINITIONS **************************************************************************************** */ -const struct prf_task_cbs* hogpbh_prf_itf_get(void) -{ - return &hogpbh_itf; -} +const struct prf_task_cbs *hogpbh_prf_itf_get(void) { return &hogpbh_itf; } -void hogpbh_enable_rsp_send(struct hogpbh_env_tag *hogpbh_env, uint8_t conidx, uint8_t status) -{ - // Counter - uint8_t svc_inst; +void hogpbh_enable_rsp_send(struct hogpbh_env_tag *hogpbh_env, uint8_t conidx, + uint8_t status) { + // Counter + uint8_t svc_inst; - // Send APP the details of the discovered attributes on HOGPBH - struct hogpbh_enable_rsp * rsp = KE_MSG_ALLOC(HOGPBH_ENABLE_RSP, - prf_dst_task_get(&(hogpbh_env->prf_env) ,conidx), - prf_src_task_get(&(hogpbh_env->prf_env) ,conidx), - hogpbh_enable_rsp); - rsp->status = status; - rsp->hids_nb = 0; - if (status == GAP_ERR_NO_ERROR) - { - rsp->hids_nb = hogpbh_env->env[conidx]->hids_nb; + // Send APP the details of the discovered attributes on HOGPBH + struct hogpbh_enable_rsp *rsp = KE_MSG_ALLOC( + HOGPBH_ENABLE_RSP, prf_dst_task_get(&(hogpbh_env->prf_env), conidx), + prf_src_task_get(&(hogpbh_env->prf_env), conidx), hogpbh_enable_rsp); + rsp->status = status; + rsp->hids_nb = 0; + if (status == GAP_ERR_NO_ERROR) { + rsp->hids_nb = hogpbh_env->env[conidx]->hids_nb; - for (svc_inst = 0; svc_inst < co_min(hogpbh_env->env[conidx]->hids_nb, HOGPBH_NB_HIDS_INST_MAX) ; svc_inst++) - { - rsp->hids[svc_inst] = hogpbh_env->env[conidx]->hids[svc_inst]; + for (svc_inst = 0; svc_inst < co_min(hogpbh_env->env[conidx]->hids_nb, + HOGPBH_NB_HIDS_INST_MAX); + svc_inst++) { + rsp->hids[svc_inst] = hogpbh_env->env[conidx]->hids[svc_inst]; - // Register HOGPBH task in gatt for indication/notifications - prf_register_atthdl2gatt(&(hogpbh_env->prf_env), conidx, &hogpbh_env->env[conidx]->hids[svc_inst].svc); - } + // Register HOGPBH task in gatt for indication/notifications + prf_register_atthdl2gatt(&(hogpbh_env->prf_env), conidx, + &hogpbh_env->env[conidx]->hids[svc_inst].svc); } + } - ke_msg_send(rsp); + ke_msg_send(rsp); } #endif /* (BLE_HID_BOOT_HOST) */ diff --git a/services/ble_profiles/hogp/hogpbh/src/hogpbh_task.c b/services/ble_profiles/hogp/hogpbh/src/hogpbh_task.c index 42145c6..b4e94b7 100644 --- a/services/ble_profiles/hogp/hogpbh/src/hogpbh_task.c +++ b/services/ble_profiles/hogp/hogpbh/src/hogpbh_task.c @@ -14,16 +14,16 @@ #if (BLE_HID_BOOT_HOST) -#include "gap.h" #include "attm.h" -#include "hogpbh_task.h" -#include "hogpbh.h" +#include "gap.h" #include "gattc_task.h" #include "hogp_common.h" +#include "hogpbh.h" +#include "hogpbh_task.h" -#include "ke_mem.h" -#include "co_utils.h" #include "co_math.h" +#include "co_utils.h" +#include "ke_mem.h" /* * LOCAL VARIABLES DEFINITION @@ -31,33 +31,34 @@ */ /// State machine used to retrieve HID Service characteristics information -const struct prf_char_def hogpbh_hids_char[HOGPBH_CHAR_MAX] = -{ +const struct prf_char_def hogpbh_hids_char[HOGPBH_CHAR_MAX] = { /// Protocol Mode - [HOGPBH_CHAR_PROTO_MODE] = {ATT_CHAR_PROTOCOL_MODE, - ATT_MANDATORY, - ATT_CHAR_PROP_RD | ATT_CHAR_PROP_WR_NO_RESP}, + [HOGPBH_CHAR_PROTO_MODE] = {ATT_CHAR_PROTOCOL_MODE, ATT_MANDATORY, + ATT_CHAR_PROP_RD | ATT_CHAR_PROP_WR_NO_RESP}, /// Boot Keyboard Input Report - [HOGPBH_CHAR_BOOT_KB_IN_REPORT] = {ATT_CHAR_BOOT_KB_IN_REPORT, - ATT_OPTIONAL, - ATT_CHAR_PROP_RD | ATT_CHAR_PROP_NTF}, + [HOGPBH_CHAR_BOOT_KB_IN_REPORT] = {ATT_CHAR_BOOT_KB_IN_REPORT, ATT_OPTIONAL, + ATT_CHAR_PROP_RD | ATT_CHAR_PROP_NTF}, /// Boot Keyboard Output Report - [HOGPBH_CHAR_BOOT_KB_OUT_REPORT] = {ATT_CHAR_BOOT_KB_OUT_REPORT, - ATT_OPTIONAL, - ATT_CHAR_PROP_RD | ATT_CHAR_PROP_WR}, + [HOGPBH_CHAR_BOOT_KB_OUT_REPORT] = {ATT_CHAR_BOOT_KB_OUT_REPORT, + ATT_OPTIONAL, + ATT_CHAR_PROP_RD | ATT_CHAR_PROP_WR}, /// Boot Keyboard Output Report - [HOGPBH_CHAR_BOOT_MOUSE_IN_REPORT] = {ATT_CHAR_BOOT_MOUSE_IN_REPORT, - ATT_OPTIONAL, - ATT_CHAR_PROP_RD | ATT_CHAR_PROP_NTF}, + [HOGPBH_CHAR_BOOT_MOUSE_IN_REPORT] = {ATT_CHAR_BOOT_MOUSE_IN_REPORT, + ATT_OPTIONAL, + ATT_CHAR_PROP_RD | ATT_CHAR_PROP_NTF}, }; -/// State machine used to retrieve HID Service characteristic description information -const struct prf_char_desc_def hogpbh_hids_char_desc[HOGPBH_DESC_MAX] = -{ +/// State machine used to retrieve HID Service characteristic description +/// information +const struct prf_char_desc_def hogpbh_hids_char_desc[HOGPBH_DESC_MAX] = { /// Boot Keyboard Input Report Client Config - [HOGPBH_DESC_BOOT_KB_IN_REPORT_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_OPTIONAL, HOGPBH_CHAR_BOOT_KB_IN_REPORT}, + [HOGPBH_DESC_BOOT_KB_IN_REPORT_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + ATT_OPTIONAL, + HOGPBH_CHAR_BOOT_KB_IN_REPORT}, /// Boot Mouse Input Report Client Config - [HOGPBH_DESC_BOOT_MOUSE_IN_REPORT_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_OPTIONAL, HOGPBH_CHAR_BOOT_MOUSE_IN_REPORT}, + [HOGPBH_DESC_BOOT_MOUSE_IN_REPORT_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + ATT_OPTIONAL, + HOGPBH_CHAR_BOOT_MOUSE_IN_REPORT}, }; /* @@ -77,62 +78,56 @@ const struct prf_char_desc_def hogpbh_hids_char_desc[HOGPBH_DESC_MAX] = **************************************************************************************** */ __STATIC int hogpbh_enable_req_handler(ke_msg_id_t const msgid, - struct hogpbh_enable_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; - int msg_status = KE_MSG_CONSUMED; + struct hogpbh_enable_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; + int msg_status = KE_MSG_CONSUMED; - uint8_t state = ke_state_get(dest_id); - uint8_t conidx = KE_IDX_GET(dest_id); - // Battery service Client Role Task Environment - struct hogpbh_env_tag *hogpbh_env = PRF_ENV_GET(HOGPBH, hogpbh); + uint8_t state = ke_state_get(dest_id); + uint8_t conidx = KE_IDX_GET(dest_id); + // Battery service Client Role Task Environment + struct hogpbh_env_tag *hogpbh_env = PRF_ENV_GET(HOGPBH, hogpbh); - ASSERT_INFO(hogpbh_env != NULL, dest_id, src_id); - if((state == HOGPBH_IDLE) && (hogpbh_env->env[conidx] == NULL)) - { - // allocate environment variable for task instance - hogpbh_env->env[conidx] = (struct hogpbh_cnx_env*) ke_malloc(sizeof(struct hogpbh_cnx_env),KE_MEM_ATT_DB); - memset(hogpbh_env->env[conidx], 0, sizeof(struct hogpbh_cnx_env)); + ASSERT_INFO(hogpbh_env != NULL, dest_id, src_id); + if ((state == HOGPBH_IDLE) && (hogpbh_env->env[conidx] == NULL)) { + // allocate environment variable for task instance + hogpbh_env->env[conidx] = (struct hogpbh_cnx_env *)ke_malloc( + sizeof(struct hogpbh_cnx_env), KE_MEM_ATT_DB); + memset(hogpbh_env->env[conidx], 0, sizeof(struct hogpbh_cnx_env)); - //Config connection, start discovering - if(param->con_type == PRF_CON_DISCOVERY) - { - //start discovering HID on peer - prf_disc_svc_send(&(hogpbh_env->prf_env), conidx, ATT_SVC_HID); + // Config connection, start discovering + if (param->con_type == PRF_CON_DISCOVERY) { + // start discovering HID on peer + prf_disc_svc_send(&(hogpbh_env->prf_env), conidx, ATT_SVC_HID); - // Go to DISCOVERING state - ke_state_set(dest_id, HOGPBH_BUSY); - hogpbh_env->env[conidx]->operation = ke_param2msg(param); - msg_status = KE_MSG_NO_FREE; - } - //normal connection, get saved att details - else - { - hogpbh_env->env[conidx]->hids_nb = param->hids_nb; - memcpy(&(hogpbh_env->env[conidx]->hids[0]), &(param->hids[0]), sizeof(struct hogpbh_content) * HOGPBH_NB_HIDS_INST_MAX); - - //send APP confirmation that can start normal connection to TH - hogpbh_enable_rsp_send(hogpbh_env, conidx, GAP_ERR_NO_ERROR); - } - } - else if(state != HOGPBH_FREE) - { - status = PRF_ERR_REQ_DISALLOWED; + // Go to DISCOVERING state + ke_state_set(dest_id, HOGPBH_BUSY); + hogpbh_env->env[conidx]->operation = ke_param2msg(param); + msg_status = KE_MSG_NO_FREE; } + // normal connection, get saved att details + else { + hogpbh_env->env[conidx]->hids_nb = param->hids_nb; + memcpy(&(hogpbh_env->env[conidx]->hids[0]), &(param->hids[0]), + sizeof(struct hogpbh_content) * HOGPBH_NB_HIDS_INST_MAX); - // send an error if request fails - if(status != GAP_ERR_NO_ERROR) - { - hogpbh_enable_rsp_send(hogpbh_env, conidx, status); + // send APP confirmation that can start normal connection to TH + hogpbh_enable_rsp_send(hogpbh_env, conidx, GAP_ERR_NO_ERROR); } + } else if (state != HOGPBH_FREE) { + status = PRF_ERR_REQ_DISALLOWED; + } - return (msg_status); + // send an error if request fails + if (status != GAP_ERR_NO_ERROR) { + hogpbh_enable_rsp_send(hogpbh_env, conidx, status); + } + + return (msg_status); } - /** **************************************************************************************** * @brief Handles reception of the @ref GATTC_SDP_SVC_IND_HANDLER message. @@ -145,40 +140,42 @@ __STATIC int hogpbh_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, - struct gattc_sdp_svc_ind const *ind, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_sdp_svc_ind const *ind, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == HOGPBH_BUSY) - { - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct hogpbh_env_tag *hogpbh_env = PRF_ENV_GET(HOGPBH, hogpbh); + if (state == HOGPBH_BUSY) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct hogpbh_env_tag *hogpbh_env = PRF_ENV_GET(HOGPBH, hogpbh); - ASSERT_INFO(hogpbh_env != NULL, dest_id, src_id); - ASSERT_INFO(hogpbh_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(hogpbh_env != NULL, dest_id, src_id); + ASSERT_INFO(hogpbh_env->env[conidx] != NULL, dest_id, src_id); - if(hogpbh_env->env[conidx]->hids_nb < HOGPBH_NB_HIDS_INST_MAX) - { - // Retrieve HID characteristics - prf_extract_svc_info(ind, HOGPBH_CHAR_MAX, &hogpbh_hids_char[0], - &(hogpbh_env->env[conidx]->hids[hogpbh_env->env[conidx]->hids_nb].chars[0]), - HOGPBH_DESC_MAX, &hogpbh_hids_char_desc[0], - &(hogpbh_env->env[conidx]->hids[hogpbh_env->env[conidx]->hids_nb].descs[0])); + if (hogpbh_env->env[conidx]->hids_nb < HOGPBH_NB_HIDS_INST_MAX) { + // Retrieve HID characteristics + prf_extract_svc_info(ind, HOGPBH_CHAR_MAX, &hogpbh_hids_char[0], + &(hogpbh_env->env[conidx] + ->hids[hogpbh_env->env[conidx]->hids_nb] + .chars[0]), + HOGPBH_DESC_MAX, &hogpbh_hids_char_desc[0], + &(hogpbh_env->env[conidx] + ->hids[hogpbh_env->env[conidx]->hids_nb] + .descs[0])); - // Store service range - hogpbh_env->env[conidx]->hids[hogpbh_env->env[conidx]->hids_nb].svc.shdl = ind->start_hdl; - hogpbh_env->env[conidx]->hids[hogpbh_env->env[conidx]->hids_nb].svc.ehdl = ind->end_hdl; - } - - hogpbh_env->env[conidx]->hids_nb++; + // Store service range + hogpbh_env->env[conidx]->hids[hogpbh_env->env[conidx]->hids_nb].svc.shdl = + ind->start_hdl; + hogpbh_env->env[conidx]->hids[hogpbh_env->env[conidx]->hids_nb].svc.ehdl = + ind->end_hdl; } - return (KE_MSG_CONSUMED); -} + hogpbh_env->env[conidx]->hids_nb++; + } + return (KE_MSG_CONSUMED); +} /** **************************************************************************************** @@ -190,114 +187,115 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int hogpbh_read_info_req_handler(ke_msg_id_t const msgid, struct hogpbh_read_info_req const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - int msg_status = KE_MSG_CONSUMED; - uint8_t state = ke_state_get(dest_id); - uint8_t status = PRF_ERR_REQ_DISALLOWED; +__STATIC int hogpbh_read_info_req_handler( + ke_msg_id_t const msgid, struct hogpbh_read_info_req const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + int msg_status = KE_MSG_CONSUMED; + uint8_t state = ke_state_get(dest_id); + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if(state == HOGPBH_IDLE) - { - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct hogpbh_env_tag *hogpbh_env = PRF_ENV_GET(HOGPBH, hogpbh); - ASSERT_INFO(hogpbh_env != NULL, dest_id, src_id); - // environment variable not ready - if(hogpbh_env->env[conidx] == NULL) - { - status = PRF_APP_ERROR; - } - // check parameter range - else if(param->hid_idx > hogpbh_env->env[conidx]->hids_nb) - { - status = PRF_ERR_INVALID_PARAM; - } - else - { - uint16_t handle = ATT_INVALID_HANDLE; - status = PRF_ERR_INEXISTENT_HDL; - - // check requested info - switch(param->info) - { - /// Protocol Mode - case HOGPBH_PROTO_MODE: - { - handle = hogpbh_env->env[conidx]->hids[param->hid_idx].chars[HOGPBH_CHAR_PROTO_MODE].val_hdl; - }break; - /// Boot Keyboard Input Report - case HOGPBH_BOOT_KB_IN_REPORT: - { - handle = hogpbh_env->env[conidx]->hids[param->hid_idx].chars[HOGPBH_CHAR_BOOT_KB_IN_REPORT].val_hdl; - }break; - /// Boot Keyboard Output Report - case HOGPBH_BOOT_KB_OUT_REPORT: - { - handle = hogpbh_env->env[conidx]->hids[param->hid_idx].chars[HOGPBH_CHAR_BOOT_KB_OUT_REPORT].val_hdl; - }break; - /// Boot Mouse Input Report - case HOGPBH_BOOT_MOUSE_IN_REPORT: - { - handle = hogpbh_env->env[conidx]->hids[param->hid_idx].chars[HOGPBH_CHAR_BOOT_MOUSE_IN_REPORT].val_hdl; - }break; - /// Boot Keyboard Input Report Client Config - case HOGPBH_BOOT_KB_IN_NTF_CFG: - { - handle = hogpbh_env->env[conidx]->hids[param->hid_idx].descs[HOGPBH_DESC_BOOT_KB_IN_REPORT_CFG].desc_hdl; - }break; - /// Boot Mouse Input Report Client Config - case HOGPBH_BOOT_MOUSE_IN_NTF_CFG: - { - handle = hogpbh_env->env[conidx]->hids[param->hid_idx].descs[HOGPBH_DESC_BOOT_MOUSE_IN_REPORT_CFG].desc_hdl; - }break; - - default: - { - status = PRF_ERR_INVALID_PARAM; - }break; - } - - if(handle != ATT_INVALID_HANDLE) - { - status = GAP_ERR_NO_ERROR; - // read information - prf_read_char_send(&(hogpbh_env->prf_env), conidx, - hogpbh_env->env[conidx]->hids[param->hid_idx].svc.shdl, - hogpbh_env->env[conidx]->hids[param->hid_idx].svc.ehdl, handle); - - // store context of request and go into busy state - hogpbh_env->env[conidx]->operation = ke_param2msg(param); - ke_state_set(dest_id, HOGPBH_BUSY); - msg_status = KE_MSG_NO_FREE; - } - } + if (state == HOGPBH_IDLE) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct hogpbh_env_tag *hogpbh_env = PRF_ENV_GET(HOGPBH, hogpbh); + ASSERT_INFO(hogpbh_env != NULL, dest_id, src_id); + // environment variable not ready + if (hogpbh_env->env[conidx] == NULL) { + status = PRF_APP_ERROR; } - // process message later - else if (state == HOGPBH_BUSY) - { + // check parameter range + else if (param->hid_idx > hogpbh_env->env[conidx]->hids_nb) { + status = PRF_ERR_INVALID_PARAM; + } else { + uint16_t handle = ATT_INVALID_HANDLE; + status = PRF_ERR_INEXISTENT_HDL; + + // check requested info + switch (param->info) { + /// Protocol Mode + case HOGPBH_PROTO_MODE: { + handle = hogpbh_env->env[conidx] + ->hids[param->hid_idx] + .chars[HOGPBH_CHAR_PROTO_MODE] + .val_hdl; + } break; + /// Boot Keyboard Input Report + case HOGPBH_BOOT_KB_IN_REPORT: { + handle = hogpbh_env->env[conidx] + ->hids[param->hid_idx] + .chars[HOGPBH_CHAR_BOOT_KB_IN_REPORT] + .val_hdl; + } break; + /// Boot Keyboard Output Report + case HOGPBH_BOOT_KB_OUT_REPORT: { + handle = hogpbh_env->env[conidx] + ->hids[param->hid_idx] + .chars[HOGPBH_CHAR_BOOT_KB_OUT_REPORT] + .val_hdl; + } break; + /// Boot Mouse Input Report + case HOGPBH_BOOT_MOUSE_IN_REPORT: { + handle = hogpbh_env->env[conidx] + ->hids[param->hid_idx] + .chars[HOGPBH_CHAR_BOOT_MOUSE_IN_REPORT] + .val_hdl; + } break; + /// Boot Keyboard Input Report Client Config + case HOGPBH_BOOT_KB_IN_NTF_CFG: { + handle = hogpbh_env->env[conidx] + ->hids[param->hid_idx] + .descs[HOGPBH_DESC_BOOT_KB_IN_REPORT_CFG] + .desc_hdl; + } break; + /// Boot Mouse Input Report Client Config + case HOGPBH_BOOT_MOUSE_IN_NTF_CFG: { + handle = hogpbh_env->env[conidx] + ->hids[param->hid_idx] + .descs[HOGPBH_DESC_BOOT_MOUSE_IN_REPORT_CFG] + .desc_hdl; + } break; + + default: { + status = PRF_ERR_INVALID_PARAM; + } break; + } + + if (handle != ATT_INVALID_HANDLE) { status = GAP_ERR_NO_ERROR; - msg_status = KE_MSG_SAVED; + // read information + prf_read_char_send( + &(hogpbh_env->prf_env), conidx, + hogpbh_env->env[conidx]->hids[param->hid_idx].svc.shdl, + hogpbh_env->env[conidx]->hids[param->hid_idx].svc.ehdl, handle); + + // store context of request and go into busy state + hogpbh_env->env[conidx]->operation = ke_param2msg(param); + ke_state_set(dest_id, HOGPBH_BUSY); + msg_status = KE_MSG_NO_FREE; + } } + } + // process message later + else if (state == HOGPBH_BUSY) { + status = GAP_ERR_NO_ERROR; + msg_status = KE_MSG_SAVED; + } + // request cannot be performed + if (status != GAP_ERR_NO_ERROR) { + struct hogpbh_read_info_rsp *rsp = KE_MSG_ALLOC( + HOGPBH_READ_INFO_RSP, src_id, dest_id, hogpbh_read_info_rsp); + // set error status + rsp->status = status; + rsp->info = param->info; + rsp->hid_idx = param->hid_idx; - // request cannot be performed - if(status != GAP_ERR_NO_ERROR) - { - struct hogpbh_read_info_rsp * rsp = KE_MSG_ALLOC(HOGPBH_READ_INFO_RSP, - src_id, dest_id, hogpbh_read_info_rsp); - // set error status - rsp->status = status; - rsp->info = param->info; - rsp->hid_idx = param->hid_idx; + ke_msg_send(rsp); + } - ke_msg_send(rsp); - } - - return (msg_status); + return (msg_status); } - /** **************************************************************************************** * @brief Handles reception of the @ref HOGPBH_WRITE_REQ message. @@ -308,117 +306,130 @@ __STATIC int hogpbh_read_info_req_handler(ke_msg_id_t const msgid, struct hogpbh * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int hogpbh_write_req_handler(ke_msg_id_t const msgid, struct hogpbh_write_req const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - int msg_status = KE_MSG_CONSUMED; - uint8_t state = ke_state_get(dest_id); - uint8_t status = PRF_ERR_REQ_DISALLOWED; +__STATIC int hogpbh_write_req_handler(ke_msg_id_t const msgid, + struct hogpbh_write_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + int msg_status = KE_MSG_CONSUMED; + uint8_t state = ke_state_get(dest_id); + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if(state == HOGPBH_IDLE) - { - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct hogpbh_env_tag *hogpbh_env = PRF_ENV_GET(HOGPBH, hogpbh); - ASSERT_INFO(hogpbh_env != NULL, dest_id, src_id); - // environment variable not ready - if(hogpbh_env->env[conidx] == NULL) - { - status = PRF_APP_ERROR; - } - // check parameter range - else if((param->hid_idx > hogpbh_env->env[conidx]->hids_nb) - || (param->info > HOGPBH_INFO_MAX) - || ((param->info >= HOGPBH_BOOT_KB_IN_NTF_CFG) && (param->data.ntf_cfg > PRF_CLI_START_NTF))) - { - status = PRF_ERR_INVALID_PARAM; - } - else - { - uint16_t handle = ATT_INVALID_HANDLE; - status = PRF_ERR_INEXISTENT_HDL; - - // check requested info - switch(param->info) - { - // Protocol Mode - case HOGPBH_PROTO_MODE: - { - handle = hogpbh_env->env[conidx]->hids[param->hid_idx].chars[HOGPBH_CHAR_PROTO_MODE].val_hdl; - prf_gatt_write(&hogpbh_env->prf_env, conidx, handle, (uint8_t*)¶m->data.proto_mode, 1, GATTC_WRITE_NO_RESPONSE); - }break; - // Boot Keyboard Input Report - case HOGPBH_BOOT_KB_IN_REPORT: - { - handle = hogpbh_env->env[conidx]->hids[param->hid_idx].chars[HOGPBH_CHAR_BOOT_KB_IN_REPORT].val_hdl; - prf_gatt_write(&hogpbh_env->prf_env, conidx, handle, (uint8_t*)param->data.report.value, param->data.report.length, GATTC_WRITE); - }break; - // Boot Keyboard Output Report - case HOGPBH_BOOT_KB_OUT_REPORT: - { - handle = hogpbh_env->env[conidx]->hids[param->hid_idx].chars[HOGPBH_CHAR_BOOT_KB_OUT_REPORT].val_hdl; - prf_gatt_write(&hogpbh_env->prf_env, conidx, handle, (uint8_t*)param->data.report.value, param->data.report.length, param->wr_cmd ? GATTC_WRITE_NO_RESPONSE : GATTC_WRITE); - }break; - // Boot Mouse Input Report - case HOGPBH_BOOT_MOUSE_IN_REPORT: - { - handle = hogpbh_env->env[conidx]->hids[param->hid_idx].chars[HOGPBH_CHAR_BOOT_MOUSE_IN_REPORT].val_hdl; - prf_gatt_write(&hogpbh_env->prf_env, conidx, handle, (uint8_t*)param->data.report.value, param->data.report.length, GATTC_WRITE); - }break; - // Boot Keyboard Input Report Client Config - case HOGPBH_BOOT_KB_IN_NTF_CFG: - { - handle = hogpbh_env->env[conidx]->hids[param->hid_idx].descs[HOGPBH_DESC_BOOT_KB_IN_REPORT_CFG].desc_hdl; - prf_gatt_write_ntf_ind(&hogpbh_env->prf_env, conidx, handle, param->data.ntf_cfg); - }break; - // Boot Mouse Input Report Client Config - case HOGPBH_BOOT_MOUSE_IN_NTF_CFG: - { - handle = hogpbh_env->env[conidx]->hids[param->hid_idx].descs[HOGPBH_DESC_BOOT_MOUSE_IN_REPORT_CFG].desc_hdl; - prf_gatt_write_ntf_ind(&hogpbh_env->prf_env, conidx, handle, param->data.ntf_cfg); - }break; - default: - { - status = PRF_ERR_INVALID_PARAM; - }break; - } - - if(handle != ATT_INVALID_HANDLE) - { - status = GAP_ERR_NO_ERROR; - - // store context of request and go into busy state - hogpbh_env->env[conidx]->operation = ke_param2msg(param); - ke_state_set(dest_id, HOGPBH_BUSY); - msg_status = KE_MSG_NO_FREE; - } - } + if (state == HOGPBH_IDLE) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct hogpbh_env_tag *hogpbh_env = PRF_ENV_GET(HOGPBH, hogpbh); + ASSERT_INFO(hogpbh_env != NULL, dest_id, src_id); + // environment variable not ready + if (hogpbh_env->env[conidx] == NULL) { + status = PRF_APP_ERROR; } - // process message later - else if (state == HOGPBH_BUSY) - { + // check parameter range + else if ((param->hid_idx > hogpbh_env->env[conidx]->hids_nb) || + (param->info > HOGPBH_INFO_MAX) || + ((param->info >= HOGPBH_BOOT_KB_IN_NTF_CFG) && + (param->data.ntf_cfg > PRF_CLI_START_NTF))) { + status = PRF_ERR_INVALID_PARAM; + } else { + uint16_t handle = ATT_INVALID_HANDLE; + status = PRF_ERR_INEXISTENT_HDL; + + // check requested info + switch (param->info) { + // Protocol Mode + case HOGPBH_PROTO_MODE: { + handle = hogpbh_env->env[conidx] + ->hids[param->hid_idx] + .chars[HOGPBH_CHAR_PROTO_MODE] + .val_hdl; + prf_gatt_write(&hogpbh_env->prf_env, conidx, handle, + (uint8_t *)¶m->data.proto_mode, 1, + GATTC_WRITE_NO_RESPONSE); + } break; + // Boot Keyboard Input Report + case HOGPBH_BOOT_KB_IN_REPORT: { + handle = hogpbh_env->env[conidx] + ->hids[param->hid_idx] + .chars[HOGPBH_CHAR_BOOT_KB_IN_REPORT] + .val_hdl; + prf_gatt_write(&hogpbh_env->prf_env, conidx, handle, + (uint8_t *)param->data.report.value, + param->data.report.length, GATTC_WRITE); + } break; + // Boot Keyboard Output Report + case HOGPBH_BOOT_KB_OUT_REPORT: { + handle = hogpbh_env->env[conidx] + ->hids[param->hid_idx] + .chars[HOGPBH_CHAR_BOOT_KB_OUT_REPORT] + .val_hdl; + prf_gatt_write(&hogpbh_env->prf_env, conidx, handle, + (uint8_t *)param->data.report.value, + param->data.report.length, + param->wr_cmd ? GATTC_WRITE_NO_RESPONSE : GATTC_WRITE); + } break; + // Boot Mouse Input Report + case HOGPBH_BOOT_MOUSE_IN_REPORT: { + handle = hogpbh_env->env[conidx] + ->hids[param->hid_idx] + .chars[HOGPBH_CHAR_BOOT_MOUSE_IN_REPORT] + .val_hdl; + prf_gatt_write(&hogpbh_env->prf_env, conidx, handle, + (uint8_t *)param->data.report.value, + param->data.report.length, GATTC_WRITE); + } break; + // Boot Keyboard Input Report Client Config + case HOGPBH_BOOT_KB_IN_NTF_CFG: { + handle = hogpbh_env->env[conidx] + ->hids[param->hid_idx] + .descs[HOGPBH_DESC_BOOT_KB_IN_REPORT_CFG] + .desc_hdl; + prf_gatt_write_ntf_ind(&hogpbh_env->prf_env, conidx, handle, + param->data.ntf_cfg); + } break; + // Boot Mouse Input Report Client Config + case HOGPBH_BOOT_MOUSE_IN_NTF_CFG: { + handle = hogpbh_env->env[conidx] + ->hids[param->hid_idx] + .descs[HOGPBH_DESC_BOOT_MOUSE_IN_REPORT_CFG] + .desc_hdl; + prf_gatt_write_ntf_ind(&hogpbh_env->prf_env, conidx, handle, + param->data.ntf_cfg); + } break; + default: { + status = PRF_ERR_INVALID_PARAM; + } break; + } + + if (handle != ATT_INVALID_HANDLE) { status = GAP_ERR_NO_ERROR; - msg_status = KE_MSG_SAVED; + + // store context of request and go into busy state + hogpbh_env->env[conidx]->operation = ke_param2msg(param); + ke_state_set(dest_id, HOGPBH_BUSY); + msg_status = KE_MSG_NO_FREE; + } } + } + // process message later + else if (state == HOGPBH_BUSY) { + status = GAP_ERR_NO_ERROR; + msg_status = KE_MSG_SAVED; + } + // request cannot be performed + if (status != GAP_ERR_NO_ERROR) { + struct hogpbh_write_rsp *rsp = + KE_MSG_ALLOC(HOGPBH_WRITE_RSP, src_id, dest_id, hogpbh_write_rsp); + // set error status + rsp->status = status; + rsp->info = param->info; + rsp->hid_idx = param->hid_idx; - // request cannot be performed - if(status != GAP_ERR_NO_ERROR) - { - struct hogpbh_write_rsp * rsp = KE_MSG_ALLOC(HOGPBH_WRITE_RSP, - src_id, dest_id, hogpbh_write_rsp); - // set error status - rsp->status = status; - rsp->info = param->info; - rsp->hid_idx = param->hid_idx; + ke_msg_send(rsp); + } - ke_msg_send(rsp); - } - - return (msg_status); + return (msg_status); } - /** **************************************************************************************** * @brief Handles reception of the @ref GATTC_CMP_EVT message. @@ -431,96 +442,93 @@ __STATIC int hogpbh_write_req_handler(ke_msg_id_t const msgid, struct hogpbh_wri **************************************************************************************** */ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, - struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct hogpbh_env_tag *hogpbh_env = PRF_ENV_GET(HOGPBH, hogpbh); + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct hogpbh_env_tag *hogpbh_env = PRF_ENV_GET(HOGPBH, hogpbh); - // sanity check - if((state == HOGPBH_BUSY) && (hogpbh_env->env[conidx] != NULL) - && (hogpbh_env->env[conidx]->operation != NULL)) - { - switch(hogpbh_env->env[conidx]->operation->id) - { - case HOGPBH_ENABLE_REQ: - { - uint8_t status = param->status; + // sanity check + if ((state == HOGPBH_BUSY) && (hogpbh_env->env[conidx] != NULL) && + (hogpbh_env->env[conidx]->operation != NULL)) { + switch (hogpbh_env->env[conidx]->operation->id) { + case HOGPBH_ENABLE_REQ: { + uint8_t status = param->status; - if (param->status == ATT_ERR_NO_ERROR) - { - // check characteristic validity - if(hogpbh_env->env[conidx]->hids_nb > 0) - { - uint8_t i; - for (i = 0 ; (i < co_min(hogpbh_env->env[conidx]->hids_nb, HOGPBH_NB_HIDS_INST_MAX)) - && (status == GAP_ERR_NO_ERROR) ; i++) - { - status = prf_check_svc_char_validity(HOGPBH_CHAR_MAX, hogpbh_env->env[conidx]->hids[i].chars, - hogpbh_hids_char); + if (param->status == ATT_ERR_NO_ERROR) { + // check characteristic validity + if (hogpbh_env->env[conidx]->hids_nb > 0) { + uint8_t i; + for (i = 0; (i < co_min(hogpbh_env->env[conidx]->hids_nb, + HOGPBH_NB_HIDS_INST_MAX)) && + (status == GAP_ERR_NO_ERROR); + i++) { + status = prf_check_svc_char_validity( + HOGPBH_CHAR_MAX, hogpbh_env->env[conidx]->hids[i].chars, + hogpbh_hids_char); - // check descriptor validity - if(status == GAP_ERR_NO_ERROR) - { - status = prf_check_svc_char_desc_validity(HOGPBH_DESC_MAX, - hogpbh_env->env[conidx]->hids[i].descs, hogpbh_hids_char_desc, - hogpbh_env->env[conidx]->hids[i].chars); - } - } - } - // no services found - else - { - status = PRF_ERR_STOP_DISC_CHAR_MISSING; - } - - } - hogpbh_enable_rsp_send(hogpbh_env, conidx, status); - }break; - case HOGPBH_READ_INFO_REQ: - { - struct hogpbh_read_info_req* req = (struct hogpbh_read_info_req*) ke_msg2param(hogpbh_env->env[conidx]->operation); - - struct hogpbh_read_info_rsp * rsp = KE_MSG_ALLOC(HOGPBH_READ_INFO_RSP, - prf_dst_task_get(&(hogpbh_env->prf_env), conidx), dest_id, hogpbh_read_info_rsp); - // set error status - rsp->status = param->status; - rsp->hid_idx = req->hid_idx; - rsp->info = req->info; - - ke_msg_send(rsp); - - }break; - case HOGPBH_WRITE_REQ: - { - struct hogpbh_write_req* req = (struct hogpbh_write_req*) ke_msg2param(hogpbh_env->env[conidx]->operation); - - struct hogpbh_write_rsp * rsp = KE_MSG_ALLOC(HOGPBH_WRITE_RSP, - prf_dst_task_get(&(hogpbh_env->prf_env), conidx), dest_id, hogpbh_write_rsp); - // set error status - rsp->status =param->status; - rsp->hid_idx = req->hid_idx; - rsp->info = req->info; - - ke_msg_send(rsp); - }break; - default: - { - // Not Expected at all - ASSERT_ERR(0); - }break; + // check descriptor validity + if (status == GAP_ERR_NO_ERROR) { + status = prf_check_svc_char_desc_validity( + HOGPBH_DESC_MAX, hogpbh_env->env[conidx]->hids[i].descs, + hogpbh_hids_char_desc, + hogpbh_env->env[conidx]->hids[i].chars); + } + } } + // no services found + else { + status = PRF_ERR_STOP_DISC_CHAR_MISSING; + } + } + hogpbh_enable_rsp_send(hogpbh_env, conidx, status); + } break; + case HOGPBH_READ_INFO_REQ: { + struct hogpbh_read_info_req *req = + (struct hogpbh_read_info_req *)ke_msg2param( + hogpbh_env->env[conidx]->operation); - // operation is over - go back to idle state - ke_free(hogpbh_env->env[conidx]->operation); - hogpbh_env->env[conidx]->operation = NULL; - ke_state_set(dest_id, HOGPBH_IDLE); + struct hogpbh_read_info_rsp *rsp = + KE_MSG_ALLOC(HOGPBH_READ_INFO_RSP, + prf_dst_task_get(&(hogpbh_env->prf_env), conidx), + dest_id, hogpbh_read_info_rsp); + // set error status + rsp->status = param->status; + rsp->hid_idx = req->hid_idx; + rsp->info = req->info; + + ke_msg_send(rsp); + + } break; + case HOGPBH_WRITE_REQ: { + struct hogpbh_write_req *req = (struct hogpbh_write_req *)ke_msg2param( + hogpbh_env->env[conidx]->operation); + + struct hogpbh_write_rsp *rsp = KE_MSG_ALLOC( + HOGPBH_WRITE_RSP, prf_dst_task_get(&(hogpbh_env->prf_env), conidx), + dest_id, hogpbh_write_rsp); + // set error status + rsp->status = param->status; + rsp->hid_idx = req->hid_idx; + rsp->info = req->info; + + ke_msg_send(rsp); + } break; + default: { + // Not Expected at all + ASSERT_ERR(0); + } break; } - return (KE_MSG_CONSUMED); + // operation is over - go back to idle state + ke_free(hogpbh_env->env[conidx]->operation); + hogpbh_env->env[conidx]->operation = NULL; + ke_state_set(dest_id, HOGPBH_IDLE); + } + + return (KE_MSG_CONSUMED); } /** @@ -537,69 +545,64 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, struct gattc_read_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == HOGPBH_BUSY) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == HOGPBH_BUSY) { + uint8_t conidx = KE_IDX_GET(dest_id); - struct hogpbh_env_tag *hogpbh_env = PRF_ENV_GET(HOGPBH, hogpbh); - struct hogpbh_read_info_req* req = (struct hogpbh_read_info_req*) ke_msg2param(hogpbh_env->env[conidx]->operation); + struct hogpbh_env_tag *hogpbh_env = PRF_ENV_GET(HOGPBH, hogpbh); + struct hogpbh_read_info_req *req = + (struct hogpbh_read_info_req *)ke_msg2param( + hogpbh_env->env[conidx]->operation); - ASSERT_INFO(hogpbh_env != NULL, dest_id, src_id); - ASSERT_INFO(hogpbh_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(hogpbh_env != NULL, dest_id, src_id); + ASSERT_INFO(hogpbh_env->env[conidx] != NULL, dest_id, src_id); + struct hogpbh_read_info_rsp *rsp = KE_MSG_ALLOC_DYN( + HOGPBH_READ_INFO_RSP, prf_dst_task_get(&(hogpbh_env->prf_env), conidx), + dest_id, hogpbh_read_info_rsp, param->length); - struct hogpbh_read_info_rsp * rsp = KE_MSG_ALLOC_DYN(HOGPBH_READ_INFO_RSP, - prf_dst_task_get(&(hogpbh_env->prf_env),conidx), dest_id, hogpbh_read_info_rsp, param->length); + // set error status + rsp->status = GAP_ERR_NO_ERROR; + rsp->hid_idx = req->hid_idx; + rsp->info = req->info; - // set error status - rsp->status = GAP_ERR_NO_ERROR; - rsp->hid_idx = req->hid_idx; - rsp->info = req->info; - - switch(req->info) - { - /// Protocol Mode - case HOGPBH_PROTO_MODE: - { - rsp->data.proto_mode = param->value[0]; - }break; - /// Boot Keyboard Input Report - case HOGPBH_BOOT_KB_IN_REPORT: - /// Boot Keyboard Output Report - case HOGPBH_BOOT_KB_OUT_REPORT: - /// Boot Mouse Input Report - case HOGPBH_BOOT_MOUSE_IN_REPORT: - { - rsp->data.report.length = param->length; - memcpy(rsp->data.report.value, param->value, param->length); - }break; - /// Boot Keyboard Input Report Client Config - case HOGPBH_BOOT_KB_IN_NTF_CFG: - /// Boot Mouse Input Report Client Config - case HOGPBH_BOOT_MOUSE_IN_NTF_CFG: - { - rsp->data.ntf_cfg = co_read16p(param->value); - }break; - default: - { - ASSERT_ERR(0); - }break; - } - - // send response - ke_msg_send(rsp); - - // operation is over - go back to idle state - ke_free(hogpbh_env->env[conidx]->operation); - hogpbh_env->env[conidx]->operation = NULL; - ke_state_set(dest_id, HOGPBH_IDLE); + switch (req->info) { + /// Protocol Mode + case HOGPBH_PROTO_MODE: { + rsp->data.proto_mode = param->value[0]; + } break; + /// Boot Keyboard Input Report + case HOGPBH_BOOT_KB_IN_REPORT: + /// Boot Keyboard Output Report + case HOGPBH_BOOT_KB_OUT_REPORT: + /// Boot Mouse Input Report + case HOGPBH_BOOT_MOUSE_IN_REPORT: { + rsp->data.report.length = param->length; + memcpy(rsp->data.report.value, param->value, param->length); + } break; + /// Boot Keyboard Input Report Client Config + case HOGPBH_BOOT_KB_IN_NTF_CFG: + /// Boot Mouse Input Report Client Config + case HOGPBH_BOOT_MOUSE_IN_NTF_CFG: { + rsp->data.ntf_cfg = co_read16p(param->value); + } break; + default: { + ASSERT_ERR(0); + } break; } - return (KE_MSG_CONSUMED); + // send response + ke_msg_send(rsp); + + // operation is over - go back to idle state + ke_free(hogpbh_env->env[conidx]->operation); + hogpbh_env->env[conidx]->operation = NULL; + ke_state_set(dest_id, HOGPBH_IDLE); + } + + return (KE_MSG_CONSUMED); } /** @@ -613,56 +616,55 @@ __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, - struct gattc_event_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_event_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state != HOGPBH_FREE) - { - // HID Instance - uint8_t hid_nb; - uint8_t att_info = HOGPBH_INFO_MAX; - uint8_t conidx = KE_IDX_GET(src_id); - // Get the address of the environment - struct hogpbh_env_tag *hogpbh_env = PRF_ENV_GET(HOGPBH, hogpbh); + if (state != HOGPBH_FREE) { + // HID Instance + uint8_t hid_nb; + uint8_t att_info = HOGPBH_INFO_MAX; + uint8_t conidx = KE_IDX_GET(src_id); + // Get the address of the environment + struct hogpbh_env_tag *hogpbh_env = PRF_ENV_GET(HOGPBH, hogpbh); - // BOOT Report - HID instance is unknown. - for (hid_nb = 0; (hid_nb < hogpbh_env->env[conidx]->hids_nb); hid_nb++) - { - if (param->handle == hogpbh_env->env[conidx]->hids[hid_nb].chars[HOGPBH_CHAR_BOOT_KB_IN_REPORT].val_hdl) - { - att_info = HOGPBH_BOOT_KB_IN_REPORT; - break; - } - else if (param->handle == hogpbh_env->env[conidx]->hids[hid_nb].chars[HOGPBH_CHAR_BOOT_MOUSE_IN_REPORT].val_hdl) - { - att_info = HOGPBH_BOOT_MOUSE_IN_REPORT; - break; - } - } - - // check if indication can be handled - if(att_info != HOGPBH_INFO_MAX) - { - // send boot report indication - struct hogpbh_boot_report_ind* ind = KE_MSG_ALLOC_DYN(HOGPBH_BOOT_REPORT_IND, - prf_dst_task_get(&(hogpbh_env->prf_env), conidx), dest_id, - hogpbh_boot_report_ind, param->length); - - ind->hid_idx = hid_nb; - ind->info = att_info; - ind->report.length = param->length; - memcpy(ind->report.value, param->value, param->length); - - ke_msg_send(ind); - } + // BOOT Report - HID instance is unknown. + for (hid_nb = 0; (hid_nb < hogpbh_env->env[conidx]->hids_nb); hid_nb++) { + if (param->handle == hogpbh_env->env[conidx] + ->hids[hid_nb] + .chars[HOGPBH_CHAR_BOOT_KB_IN_REPORT] + .val_hdl) { + att_info = HOGPBH_BOOT_KB_IN_REPORT; + break; + } else if (param->handle == hogpbh_env->env[conidx] + ->hids[hid_nb] + .chars[HOGPBH_CHAR_BOOT_MOUSE_IN_REPORT] + .val_hdl) { + att_info = HOGPBH_BOOT_MOUSE_IN_REPORT; + break; + } } - return (KE_MSG_CONSUMED); -} + // check if indication can be handled + if (att_info != HOGPBH_INFO_MAX) { + // send boot report indication + struct hogpbh_boot_report_ind *ind = + KE_MSG_ALLOC_DYN(HOGPBH_BOOT_REPORT_IND, + prf_dst_task_get(&(hogpbh_env->prf_env), conidx), + dest_id, hogpbh_boot_report_ind, param->length); + ind->hid_idx = hid_nb; + ind->info = att_info; + ind->report.length = param->length; + memcpy(ind->report.value, param->value, param->length); + + ke_msg_send(ind); + } + } + + return (KE_MSG_CONSUMED); +} /* * GLOBAL VARIABLE DEFINITIONS @@ -670,29 +672,27 @@ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, */ /// Default State handlers definition -KE_MSG_HANDLER_TAB(hogpbh) -{ - {HOGPBH_ENABLE_REQ, (ke_msg_func_t)hogpbh_enable_req_handler}, - {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, +KE_MSG_HANDLER_TAB(hogpbh){ + {HOGPBH_ENABLE_REQ, (ke_msg_func_t)hogpbh_enable_req_handler}, + {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, - {HOGPBH_READ_INFO_REQ, (ke_msg_func_t)hogpbh_read_info_req_handler}, - {HOGPBH_WRITE_REQ, (ke_msg_func_t)hogpbh_write_req_handler}, + {HOGPBH_READ_INFO_REQ, (ke_msg_func_t)hogpbh_read_info_req_handler}, + {HOGPBH_WRITE_REQ, (ke_msg_func_t)hogpbh_write_req_handler}, - {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, - {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, + {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void hogpbh_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct hogpbh_env_tag *hogpbh_env = PRF_ENV_GET(HOGPBH, hogpbh); +void hogpbh_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct hogpbh_env_tag *hogpbh_env = PRF_ENV_GET(HOGPBH, hogpbh); - task_desc->msg_handler_tab = hogpbh_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(hogpbh_msg_handler_tab); - task_desc->state = hogpbh_env->state; - task_desc->idx_max = HOGPBH_IDX_MAX; + task_desc->msg_handler_tab = hogpbh_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(hogpbh_msg_handler_tab); + task_desc->state = hogpbh_env->state; + task_desc->idx_max = HOGPBH_IDX_MAX; } #endif /* (BLE_HOG_BOOT_HOST) */ diff --git a/services/ble_profiles/hogp/hogpd/src/hogpd.c b/services/ble_profiles/hogp/hogpd/src/hogpd.c index 9dd5217..d253f33 100644 --- a/services/ble_profiles/hogp/hogpd/src/hogpd.c +++ b/services/ble_profiles/hogp/hogpd/src/hogpd.c @@ -13,9 +13,9 @@ #if (BLE_HID_DEVICE) +#include "attm.h" #include "gap.h" #include "gattc_task.h" -#include "attm.h" #include "hogpd.h" #include "hogpd_task.h" #include "prf_utils.h" @@ -26,23 +26,23 @@ * DEFINES **************************************************************************************** */ -#define HIDS_CFG_FLAG_MANDATORY_MASK ((uint32_t)0x000FD) -#define HIDS_MANDATORY_ATT_NB (7) -#define HIDS_CFG_FLAG_MAP_EXT_MASK ((uint32_t)0x00102) -#define HIDS_MAP_EXT_ATT_NB (2) -#define HIDS_CFG_FLAG_PROTO_MODE_MASK ((uint32_t)0x00600) -#define HIDS_PROTO_MODE_ATT_NB (2) -#define HIDS_CFG_FLAG_KEYBOARD_MASK ((uint32_t)0x0F800) -#define HIDS_KEYBOARD_ATT_NB (5) -#define HIDS_CFG_FLAG_MOUSE_MASK ((uint32_t)0x70000) -#define HIDS_MOUSE_ATT_NB (3) +#define HIDS_CFG_FLAG_MANDATORY_MASK ((uint32_t)0x000FD) +#define HIDS_MANDATORY_ATT_NB (7) +#define HIDS_CFG_FLAG_MAP_EXT_MASK ((uint32_t)0x00102) +#define HIDS_MAP_EXT_ATT_NB (2) +#define HIDS_CFG_FLAG_PROTO_MODE_MASK ((uint32_t)0x00600) +#define HIDS_PROTO_MODE_ATT_NB (2) +#define HIDS_CFG_FLAG_KEYBOARD_MASK ((uint32_t)0x0F800) +#define HIDS_KEYBOARD_ATT_NB (5) +#define HIDS_CFG_FLAG_MOUSE_MASK ((uint32_t)0x70000) +#define HIDS_MOUSE_ATT_NB (3) -#define HIDS_CFG_REPORT_MANDATORY_MASK ((uint32_t)0x7) -#define HIDS_REPORT_MANDATORY_ATT_NB (3) -#define HIDS_CFG_REPORT_IN_MASK ((uint32_t)0x8) -#define HIDS_REPORT_IN_ATT_NB (1) +#define HIDS_CFG_REPORT_MANDATORY_MASK ((uint32_t)0x7) +#define HIDS_REPORT_MANDATORY_ATT_NB (3) +#define HIDS_CFG_REPORT_IN_MASK ((uint32_t)0x8) +#define HIDS_REPORT_IN_ATT_NB (1) // number of attribute index for a report -#define HIDS_REPORT_NB_IDX (4) +#define HIDS_REPORT_NB_IDX (4) /* * HIDS ATTRIBUTES DEFINITION @@ -50,66 +50,108 @@ */ /// Full HIDS Database Description - Used to add attributes into the database -const struct attm_desc hids_att_db[HOGPD_IDX_NB] = -{ +const struct attm_desc hids_att_db[HOGPD_IDX_NB] = { // HID Service Declaration - [HOGPD_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [HOGPD_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // HID Service Declaration - [HOGPD_IDX_INCL_SVC] = {ATT_DECL_INCLUDE, PERM(RD, ENABLE), 0, 0}, + [HOGPD_IDX_INCL_SVC] = {ATT_DECL_INCLUDE, PERM(RD, ENABLE), 0, 0}, // HID Information Characteristic Declaration - [HOGPD_IDX_HID_INFO_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE),0, 0}, + [HOGPD_IDX_HID_INFO_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // HID Information Characteristic Value - [HOGPD_IDX_HID_INFO_VAL] = {ATT_CHAR_HID_INFO, PERM(RD, ENABLE), 0, sizeof(struct hids_hid_info)}, + [HOGPD_IDX_HID_INFO_VAL] = {ATT_CHAR_HID_INFO, PERM(RD, ENABLE), 0, + sizeof(struct hids_hid_info)}, // HID Control Point Characteristic Declaration - [HOGPD_IDX_HID_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [HOGPD_IDX_HID_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), + 0, 0}, // HID Control Point Characteristic Value - [HOGPD_IDX_HID_CTNL_PT_VAL] = {ATT_CHAR_HID_CTNL_PT, PERM(WRITE_COMMAND, ENABLE), PERM(RI, ENABLE), sizeof(uint8_t)}, + [HOGPD_IDX_HID_CTNL_PT_VAL] = {ATT_CHAR_HID_CTNL_PT, + PERM(WRITE_COMMAND, ENABLE), + PERM(RI, ENABLE), sizeof(uint8_t)}, // Report Map Characteristic Declaration - [HOGPD_IDX_REPORT_MAP_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [HOGPD_IDX_REPORT_MAP_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Report Map Characteristic Value - [HOGPD_IDX_REPORT_MAP_VAL] = {ATT_CHAR_REPORT_MAP, PERM(RD, ENABLE), PERM(RI, ENABLE), HOGPD_REPORT_MAP_MAX_LEN}, + [HOGPD_IDX_REPORT_MAP_VAL] = {ATT_CHAR_REPORT_MAP, PERM(RD, ENABLE), + PERM(RI, ENABLE), HOGPD_REPORT_MAP_MAX_LEN}, // Report Map Characteristic - External Report Reference Descriptor - [HOGPD_IDX_REPORT_MAP_EXT_REP_REF] = {ATT_DESC_EXT_REPORT_REF, PERM(RD, ENABLE), 0, sizeof(uint16_t)}, + [HOGPD_IDX_REPORT_MAP_EXT_REP_REF] = {ATT_DESC_EXT_REPORT_REF, + PERM(RD, ENABLE), 0, + sizeof(uint16_t)}, // Protocol Mode Characteristic Declaration - [HOGPD_IDX_PROTO_MODE_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [HOGPD_IDX_PROTO_MODE_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Protocol Mode Characteristic Value - [HOGPD_IDX_PROTO_MODE_VAL] = {ATT_CHAR_PROTOCOL_MODE, (PERM(RD, ENABLE) | PERM(WRITE_COMMAND, ENABLE)), PERM(RI, ENABLE), sizeof(uint8_t)}, + [HOGPD_IDX_PROTO_MODE_VAL] = {ATT_CHAR_PROTOCOL_MODE, + (PERM(RD, ENABLE) | + PERM(WRITE_COMMAND, ENABLE)), + PERM(RI, ENABLE), sizeof(uint8_t)}, // Boot Keyboard Input Report Characteristic Declaration - [HOGPD_IDX_BOOT_KB_IN_REPORT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [HOGPD_IDX_BOOT_KB_IN_REPORT_CHAR] = {ATT_DECL_CHARACTERISTIC, + PERM(RD, ENABLE), 0, 0}, // Boot Keyboard Input Report Characteristic Value - [HOGPD_IDX_BOOT_KB_IN_REPORT_VAL] = {ATT_CHAR_BOOT_KB_IN_REPORT, (PERM(RD, ENABLE) | PERM(NTF, ENABLE)), PERM(RI, ENABLE), HOGPD_BOOT_REPORT_MAX_LEN}, - // Boot Keyboard Input Report Characteristic - Client Characteristic Configuration Descriptor - [HOGPD_IDX_BOOT_KB_IN_REPORT_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE)|PERM(WRITE_REQ, ENABLE), 0, 0}, + [HOGPD_IDX_BOOT_KB_IN_REPORT_VAL] = {ATT_CHAR_BOOT_KB_IN_REPORT, + (PERM(RD, ENABLE) | PERM(NTF, ENABLE)), + PERM(RI, ENABLE), + HOGPD_BOOT_REPORT_MAX_LEN}, + // Boot Keyboard Input Report Characteristic - Client Characteristic + // Configuration Descriptor + [HOGPD_IDX_BOOT_KB_IN_REPORT_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | + PERM(WRITE_REQ, ENABLE), + 0, 0}, // Boot Keyboard Output Report Characteristic Declaration - [HOGPD_IDX_BOOT_KB_OUT_REPORT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [HOGPD_IDX_BOOT_KB_OUT_REPORT_CHAR] = {ATT_DECL_CHARACTERISTIC, + PERM(RD, ENABLE), 0, 0}, // Boot Keyboard Output Report Characteristic Value - [HOGPD_IDX_BOOT_KB_OUT_REPORT_VAL] = {ATT_CHAR_BOOT_KB_OUT_REPORT, (PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE) | PERM(WRITE_COMMAND, ENABLE)), PERM(RI, ENABLE), HOGPD_BOOT_REPORT_MAX_LEN}, + [HOGPD_IDX_BOOT_KB_OUT_REPORT_VAL] = {ATT_CHAR_BOOT_KB_OUT_REPORT, + (PERM(RD, ENABLE) | + PERM(WRITE_REQ, ENABLE) | + PERM(WRITE_COMMAND, ENABLE)), + PERM(RI, ENABLE), + HOGPD_BOOT_REPORT_MAX_LEN}, // Boot Mouse Input Report Characteristic Declaration - [HOGPD_IDX_BOOT_MOUSE_IN_REPORT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [HOGPD_IDX_BOOT_MOUSE_IN_REPORT_CHAR] = {ATT_DECL_CHARACTERISTIC, + PERM(RD, ENABLE), 0, 0}, // Boot Mouse Input Report Characteristic Value - [HOGPD_IDX_BOOT_MOUSE_IN_REPORT_VAL] = {ATT_CHAR_BOOT_MOUSE_IN_REPORT, (PERM(RD, ENABLE) | PERM(NTF, ENABLE)), PERM(RI, ENABLE), HOGPD_BOOT_REPORT_MAX_LEN,}, - // Boot Mouse Input Report Characteristic - Client Characteristic Configuration Descriptor - [HOGPD_IDX_BOOT_MOUSE_IN_REPORT_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE)|PERM(WRITE_REQ, ENABLE) | PERM(WRITE_COMMAND, ENABLE), 0, 0}, + [HOGPD_IDX_BOOT_MOUSE_IN_REPORT_VAL] = + { + ATT_CHAR_BOOT_MOUSE_IN_REPORT, + (PERM(RD, ENABLE) | PERM(NTF, ENABLE)), + PERM(RI, ENABLE), + HOGPD_BOOT_REPORT_MAX_LEN, + }, + // Boot Mouse Input Report Characteristic - Client Characteristic + // Configuration Descriptor + [HOGPD_IDX_BOOT_MOUSE_IN_REPORT_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | + PERM(WRITE_REQ, ENABLE) | + PERM(WRITE_COMMAND, ENABLE), + 0, 0}, // Report Characteristic Declaration - [HOGPD_IDX_REPORT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [HOGPD_IDX_REPORT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, // Report Characteristic Value - [HOGPD_IDX_REPORT_VAL] = {ATT_CHAR_REPORT, PERM(RD, ENABLE), PERM(RI, ENABLE), HOGPD_REPORT_MAX_LEN}, + [HOGPD_IDX_REPORT_VAL] = {ATT_CHAR_REPORT, PERM(RD, ENABLE), + PERM(RI, ENABLE), HOGPD_REPORT_MAX_LEN}, // Report Characteristic - Report Reference Descriptor - [HOGPD_IDX_REPORT_REP_REF] = {ATT_DESC_REPORT_REF, PERM(RD, ENABLE), 0, sizeof(struct hids_report_ref)}, + [HOGPD_IDX_REPORT_REP_REF] = {ATT_DESC_REPORT_REF, PERM(RD, ENABLE), 0, + sizeof(struct hids_report_ref)}, // Report Characteristic - Client Characteristic Configuration Descriptor - [HOGPD_IDX_REPORT_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE)|PERM(WRITE_REQ, ENABLE) | PERM(WRITE_COMMAND, ENABLE), 0, 0}, + [HOGPD_IDX_REPORT_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE) | + PERM(WRITE_COMMAND, ENABLE), + 0, 0}, }; - /** **************************************************************************************** * @brief Initialization of the HOGPD module. @@ -122,290 +164,311 @@ const struct attm_desc hids_att_db[HOGPD_IDX_NB] = * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t hogpd_init (struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, struct hogpd_db_cfg* params) -{ - struct hogpd_env_tag* hogpd_env = NULL; - // Service content flag - Without Report Characteristics - uint32_t cfg_flag[HOGPD_NB_HIDS_INST_MAX][(HOGPD_ATT_MAX/32) +1]; - // Start handle used to allocate service. - uint16_t shdl; +static uint8_t hogpd_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, + struct hogpd_db_cfg *params) { + struct hogpd_env_tag *hogpd_env = NULL; + // Service content flag - Without Report Characteristics + uint32_t cfg_flag[HOGPD_NB_HIDS_INST_MAX][(HOGPD_ATT_MAX / 32) + 1]; + // Start handle used to allocate service. + uint16_t shdl; - // Total number of attributes - uint8_t tot_nb_att = 0; + // Total number of attributes + uint8_t tot_nb_att = 0; - // array of service description used to allocate the service - struct attm_desc * hids_db[HOGPD_NB_HIDS_INST_MAX]; - // Status - uint8_t status = GAP_ERR_NO_ERROR; - // Service Instance Counter, Counter - uint8_t svc_idx, report_idx; - // Report Char. Report Ref value - struct hids_report_ref report_ref; + // array of service description used to allocate the service + struct attm_desc *hids_db[HOGPD_NB_HIDS_INST_MAX]; + // Status + uint8_t status = GAP_ERR_NO_ERROR; + // Service Instance Counter, Counter + uint8_t svc_idx, report_idx; + // Report Char. Report Ref value + struct hids_report_ref report_ref; - //-------------------- allocate memory required for the profile --------------------- - hogpd_env = (struct hogpd_env_tag* ) ke_malloc(sizeof(struct hogpd_env_tag), KE_MEM_ATT_DB); + //-------------------- allocate memory required for the profile + //--------------------- + hogpd_env = (struct hogpd_env_tag *)ke_malloc(sizeof(struct hogpd_env_tag), + KE_MEM_ATT_DB); - // ensure that everything is initialized - memset(hids_db, 0, sizeof(hids_db)); - memset(cfg_flag, 0, sizeof(cfg_flag)); - memset(hogpd_env, 0, sizeof(struct hogpd_env_tag)); + // ensure that everything is initialized + memset(hids_db, 0, sizeof(hids_db)); + memset(cfg_flag, 0, sizeof(cfg_flag)); + memset(hogpd_env, 0, sizeof(struct hogpd_env_tag)); + // Check number of HID instances + if ((params->hids_nb == 0) || (params->hids_nb > HOGPD_NB_HIDS_INST_MAX)) { + // Invalid number of service instances + status = PRF_ERR_INVALID_PARAM; + } - // Check number of HID instances - if ((params->hids_nb == 0) || (params->hids_nb > HOGPD_NB_HIDS_INST_MAX)) - { - // Invalid number of service instances + // For each required HIDS instance + for (svc_idx = 0; + ((svc_idx < params->hids_nb) && (status == GAP_ERR_NO_ERROR)); + svc_idx++) { + // Check number of Report Char. instances + if (params->cfg[svc_idx].report_nb > HOGPD_NB_REPORT_INST_MAX) { + // Too many Report Char. Instances + status = PRF_ERR_INVALID_PARAM; + break; + } + + // retrieve features + hogpd_env->svcs[svc_idx].features = + params->cfg[svc_idx].svc_features & HOGPD_CFG_MASK; + hogpd_env->svcs[svc_idx].nb_report = params->cfg[svc_idx].report_nb; + + hids_db[svc_idx] = (struct attm_desc *)ke_malloc( + HOGPD_ATT_MAX * sizeof(struct attm_desc), KE_MEM_NON_RETENTION); + + cfg_flag[svc_idx][0] = HIDS_CFG_FLAG_MANDATORY_MASK; + hogpd_env->svcs[svc_idx].nb_att += HIDS_MANDATORY_ATT_NB; + + // copy default definition of the HID attribute database + memcpy(hids_db[svc_idx], hids_att_db, + sizeof(struct attm_desc) * HOGPD_ATT_UNIQ_NB); + + //-------------------------------------------------------------------- + // Compute cfg_flag[i] without Report Characteristics + //-------------------------------------------------------------------- + if ((params->cfg[svc_idx].svc_features & HOGPD_CFG_MAP_EXT_REF) == + HOGPD_CFG_MAP_EXT_REF) { + cfg_flag[svc_idx][0] |= HIDS_CFG_FLAG_MAP_EXT_MASK; + hogpd_env->svcs[svc_idx].nb_att += HIDS_MAP_EXT_ATT_NB; + // store reference handle in database + hids_db[svc_idx][HOGPD_IDX_INCL_SVC].max_size = + params->cfg[svc_idx].ext_ref.inc_svc_hdl; + } + + if ((params->cfg[svc_idx].svc_features & HOGPD_CFG_PROTO_MODE) == + HOGPD_CFG_PROTO_MODE) { + cfg_flag[svc_idx][0] |= HIDS_CFG_FLAG_PROTO_MODE_MASK; + hogpd_env->svcs[svc_idx].nb_att += HIDS_PROTO_MODE_ATT_NB; + } + + if ((params->cfg[svc_idx].svc_features & HOGPD_CFG_KEYBOARD) == + HOGPD_CFG_KEYBOARD) { + cfg_flag[svc_idx][0] |= HIDS_CFG_FLAG_KEYBOARD_MASK; + hogpd_env->svcs[svc_idx].nb_att += HIDS_KEYBOARD_ATT_NB; + + if ((params->cfg[svc_idx].svc_features & HOGPD_CFG_BOOT_KB_WR) == + HOGPD_CFG_BOOT_KB_WR) { + // Adds write permissions on report + hids_db[svc_idx][HOGPD_IDX_BOOT_KB_IN_REPORT_VAL].perm |= + (PERM(WRITE_REQ, ENABLE)); + } + } + + if ((params->cfg[svc_idx].svc_features & HOGPD_CFG_MOUSE) == + HOGPD_CFG_MOUSE) { + cfg_flag[svc_idx][0] |= HIDS_CFG_FLAG_MOUSE_MASK; + hogpd_env->svcs[svc_idx].nb_att += HIDS_MOUSE_ATT_NB; + + if ((params->cfg[svc_idx].svc_features & HOGPD_CFG_BOOT_MOUSE_WR) == + HOGPD_CFG_BOOT_MOUSE_WR) { + // Adds write permissions on report + hids_db[svc_idx][HOGPD_IDX_BOOT_MOUSE_IN_REPORT_VAL].perm |= + (PERM(WRITE_REQ, ENABLE)); + } + } + + // set report handle offset + hogpd_env->svcs[svc_idx].report_hdl_offset = + hogpd_env->svcs[svc_idx].nb_att; + + //-------------------------------------------------------------------- + // Update cfg_flag_rep[i] with Report Characteristics + //-------------------------------------------------------------------- + for (report_idx = 0; report_idx < params->cfg[svc_idx].report_nb; + report_idx++) { + uint16_t perm = 0; + uint16_t report_offset = HIDS_REPORT_NB_IDX * report_idx; + + // update config for current report + cfg_flag[svc_idx][(HOGPD_IDX_REPORT_CHAR + report_offset) / 32] |= + (1 << ((HOGPD_IDX_REPORT_CHAR + report_offset) % 32)); + cfg_flag[svc_idx][(HOGPD_IDX_REPORT_VAL + report_offset) / 32] |= + (1 << ((HOGPD_IDX_REPORT_VAL + report_offset) % 32)); + cfg_flag[svc_idx][(HOGPD_IDX_REPORT_REP_REF + report_offset) / 32] |= + (1 << ((HOGPD_IDX_REPORT_REP_REF + report_offset) % 32)); + hogpd_env->svcs[svc_idx].nb_att += HIDS_REPORT_MANDATORY_ATT_NB; + + // copy default definition of the HID report database + memcpy(&(hids_db[svc_idx][HOGPD_IDX_REPORT_CHAR + report_offset]), + &(hids_att_db[HOGPD_IDX_REPORT_CHAR]), + sizeof(struct attm_desc) * HIDS_REPORT_NB_IDX); + + // according to the report type, update value property + switch (params->cfg[svc_idx].report_char_cfg[report_idx] & + HOGPD_CFG_REPORT_FEAT) { + // Input Report + case HOGPD_CFG_REPORT_IN: { + // add notification permission on report + perm = PERM(RD, ENABLE) | PERM(NTF, ENABLE); + // Report Char. supports NTF => Client Characteristic Configuration + // Descriptor + cfg_flag[svc_idx][(HOGPD_IDX_REPORT_NTF_CFG + report_offset) / 32] |= + (1 << ((HOGPD_IDX_REPORT_NTF_CFG + report_offset) % 32)); + hogpd_env->svcs[svc_idx].nb_att += HIDS_REPORT_IN_ATT_NB; + + // update feature flag + hogpd_env->svcs[svc_idx].features |= + (HOGPD_CFG_REPORT_NTF_EN << report_idx); + + // check if attribute value could be written + if ((params->cfg[svc_idx].report_char_cfg[report_idx] & + HOGPD_CFG_REPORT_WR) == HOGPD_CFG_REPORT_WR) { + perm |= PERM(WRITE_REQ, ENABLE); + } + } break; + + // Output Report + case HOGPD_CFG_REPORT_OUT: { + perm = PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE) | + PERM(WRITE_COMMAND, ENABLE); + } break; + + // Feature Report + case HOGPD_CFG_REPORT_FEAT: { + perm = PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE); + } break; + + default: { status = PRF_ERR_INVALID_PARAM; + } break; + } + + hids_db[svc_idx][HOGPD_IDX_REPORT_VAL + (HIDS_REPORT_NB_IDX * report_idx)] + .perm = perm; } - // For each required HIDS instance - for (svc_idx = 0; ((svc_idx < params->hids_nb) && (status == GAP_ERR_NO_ERROR)); svc_idx++) - { - // Check number of Report Char. instances - if (params->cfg[svc_idx].report_nb > HOGPD_NB_REPORT_INST_MAX) - { - // Too many Report Char. Instances - status = PRF_ERR_INVALID_PARAM; - break; - } + // increment total number of attributes to allocate. + tot_nb_att += hogpd_env->svcs[svc_idx].nb_att; + } - // retrieve features - hogpd_env->svcs[svc_idx].features = params->cfg[svc_idx].svc_features & HOGPD_CFG_MASK; - hogpd_env->svcs[svc_idx].nb_report = params->cfg[svc_idx].report_nb; + // Check that attribute list can be allocated. + if (status == ATT_ERR_NO_ERROR) { + status = attm_reserve_handle_range(start_hdl, tot_nb_att); + } - hids_db[svc_idx] = (struct attm_desc *) ke_malloc(HOGPD_ATT_MAX * sizeof(struct attm_desc), KE_MEM_NON_RETENTION); + // used start handle calculated when handle range reservation has been + // performed + shdl = *start_hdl; + hogpd_env->start_hdl = *start_hdl; + hogpd_env->hids_nb = params->hids_nb; + // Initialize the Report ID + report_ref.report_id = 0; - cfg_flag[svc_idx][0] = HIDS_CFG_FLAG_MANDATORY_MASK; - hogpd_env->svcs[svc_idx].nb_att += HIDS_MANDATORY_ATT_NB; + // allocate services + for (svc_idx = 0; + ((svc_idx < params->hids_nb) && (status == GAP_ERR_NO_ERROR)); + svc_idx++) { + uint16_t handle; + status = attm_svc_create_db( + &shdl, ATT_SVC_HID, (uint8_t *)&(cfg_flag[svc_idx][0]), HOGPD_ATT_MAX, + NULL, env->task, hids_db[svc_idx], + (sec_lvl & + (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS))); + // update start handle for next service + shdl += hogpd_env->svcs[svc_idx].nb_att; - // copy default definition of the HID attribute database - memcpy(hids_db[svc_idx], hids_att_db, sizeof(struct attm_desc) * HOGPD_ATT_UNIQ_NB); - - //-------------------------------------------------------------------- - // Compute cfg_flag[i] without Report Characteristics - //-------------------------------------------------------------------- - if ((params->cfg[svc_idx].svc_features & HOGPD_CFG_MAP_EXT_REF) == HOGPD_CFG_MAP_EXT_REF) - { - cfg_flag[svc_idx][0] |= HIDS_CFG_FLAG_MAP_EXT_MASK; - hogpd_env->svcs[svc_idx].nb_att += HIDS_MAP_EXT_ATT_NB; - // store reference handle in database - hids_db[svc_idx][HOGPD_IDX_INCL_SVC].max_size = params->cfg[svc_idx].ext_ref.inc_svc_hdl; - } - - if ((params->cfg[svc_idx].svc_features & HOGPD_CFG_PROTO_MODE) == HOGPD_CFG_PROTO_MODE) - { - cfg_flag[svc_idx][0] |= HIDS_CFG_FLAG_PROTO_MODE_MASK; - hogpd_env->svcs[svc_idx].nb_att += HIDS_PROTO_MODE_ATT_NB; - } - - if ((params->cfg[svc_idx].svc_features & HOGPD_CFG_KEYBOARD) == HOGPD_CFG_KEYBOARD) - { - cfg_flag[svc_idx][0] |= HIDS_CFG_FLAG_KEYBOARD_MASK; - hogpd_env->svcs[svc_idx].nb_att += HIDS_KEYBOARD_ATT_NB; - - if ((params->cfg[svc_idx].svc_features & HOGPD_CFG_BOOT_KB_WR) == HOGPD_CFG_BOOT_KB_WR) - { - // Adds write permissions on report - hids_db[svc_idx][HOGPD_IDX_BOOT_KB_IN_REPORT_VAL].perm |= (PERM(WRITE_REQ, ENABLE)); - } - } - - if ((params->cfg[svc_idx].svc_features & HOGPD_CFG_MOUSE) == HOGPD_CFG_MOUSE) - { - cfg_flag[svc_idx][0] |= HIDS_CFG_FLAG_MOUSE_MASK; - hogpd_env->svcs[svc_idx].nb_att += HIDS_MOUSE_ATT_NB; - - if ((params->cfg[svc_idx].svc_features & HOGPD_CFG_BOOT_MOUSE_WR) == HOGPD_CFG_BOOT_MOUSE_WR) - { - // Adds write permissions on report - hids_db[svc_idx][HOGPD_IDX_BOOT_MOUSE_IN_REPORT_VAL].perm |= (PERM(WRITE_REQ, ENABLE)); - } - } - - // set report handle offset - hogpd_env->svcs[svc_idx].report_hdl_offset = hogpd_env->svcs[svc_idx].nb_att; - - //-------------------------------------------------------------------- - // Update cfg_flag_rep[i] with Report Characteristics - //-------------------------------------------------------------------- - for (report_idx = 0; report_idx < params->cfg[svc_idx].report_nb; report_idx++) - { - uint16_t perm = 0; - uint16_t report_offset = HIDS_REPORT_NB_IDX*report_idx; - - // update config for current report - cfg_flag[svc_idx][(HOGPD_IDX_REPORT_CHAR + report_offset) / 32] |= (1 << ((HOGPD_IDX_REPORT_CHAR + report_offset) % 32)); - cfg_flag[svc_idx][(HOGPD_IDX_REPORT_VAL + report_offset) / 32] |= (1 << ((HOGPD_IDX_REPORT_VAL + report_offset) % 32)); - cfg_flag[svc_idx][(HOGPD_IDX_REPORT_REP_REF + report_offset) / 32] |= (1 << ((HOGPD_IDX_REPORT_REP_REF + report_offset) % 32)); - hogpd_env->svcs[svc_idx].nb_att += HIDS_REPORT_MANDATORY_ATT_NB; - - // copy default definition of the HID report database - memcpy(&(hids_db[svc_idx][HOGPD_IDX_REPORT_CHAR + report_offset]), &(hids_att_db[HOGPD_IDX_REPORT_CHAR]), sizeof(struct attm_desc) * HIDS_REPORT_NB_IDX); - - // according to the report type, update value property - switch (params->cfg[svc_idx].report_char_cfg[report_idx] & HOGPD_CFG_REPORT_FEAT) - { - // Input Report - case HOGPD_CFG_REPORT_IN: - { - // add notification permission on report - perm = PERM(RD, ENABLE) | PERM(NTF, ENABLE); - // Report Char. supports NTF => Client Characteristic Configuration Descriptor - cfg_flag[svc_idx][(HOGPD_IDX_REPORT_NTF_CFG + report_offset) / 32] |= (1 << ((HOGPD_IDX_REPORT_NTF_CFG + report_offset) % 32)); - hogpd_env->svcs[svc_idx].nb_att += HIDS_REPORT_IN_ATT_NB; - - // update feature flag - hogpd_env->svcs[svc_idx].features |= (HOGPD_CFG_REPORT_NTF_EN << report_idx); - - // check if attribute value could be written - if ((params->cfg[svc_idx].report_char_cfg[report_idx] & HOGPD_CFG_REPORT_WR) == HOGPD_CFG_REPORT_WR) - { - perm |= PERM(WRITE_REQ, ENABLE); - } - } break; - - // Output Report - case HOGPD_CFG_REPORT_OUT: - { - perm = PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE) | PERM(WRITE_COMMAND, ENABLE); - } break; - - // Feature Report - case HOGPD_CFG_REPORT_FEAT: - { - perm = PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE); - } break; - - default: - { - status = PRF_ERR_INVALID_PARAM; - } break; - } - - hids_db[svc_idx][HOGPD_IDX_REPORT_VAL + (HIDS_REPORT_NB_IDX*report_idx)].perm = perm; - } - - // increment total number of attributes to allocate. - tot_nb_att += hogpd_env->svcs[svc_idx].nb_att; + // Set HID Information Char. Value + if (status == GAP_ERR_NO_ERROR) { + handle = + hogpd_get_att_handle(hogpd_env, svc_idx, HOGPD_IDX_HID_INFO_VAL, 0); + ASSERT_ERR(handle != ATT_INVALID_HDL); + status = attm_att_set_value(handle, sizeof(struct hids_hid_info), 0, + (uint8_t *)¶ms->cfg[svc_idx].hid_info); } - // Check that attribute list can be allocated. - if(status == ATT_ERR_NO_ERROR) - { - status = attm_reserve_handle_range(start_hdl, tot_nb_att); + // Set Report Map Char. External Report Ref value + if ((status == GAP_ERR_NO_ERROR) && + ((params->cfg[svc_idx].svc_features & HOGPD_CFG_MAP_EXT_REF) == + HOGPD_CFG_MAP_EXT_REF)) { + handle = hogpd_get_att_handle(hogpd_env, svc_idx, + HOGPD_IDX_REPORT_MAP_EXT_REP_REF, 0); + ASSERT_ERR(handle != ATT_INVALID_HDL); + status = attm_att_set_value( + handle, sizeof(uint16_t), 0, + (uint8_t *)¶ms->cfg[svc_idx].ext_ref.rep_ref_uuid); } - // used start handle calculated when handle range reservation has been performed - shdl = *start_hdl; - hogpd_env->start_hdl = *start_hdl; - hogpd_env->hids_nb = params->hids_nb; - // Initialize the Report ID - report_ref.report_id = 0; - - // allocate services - for (svc_idx = 0; ((svc_idx < params->hids_nb) && (status == GAP_ERR_NO_ERROR)); svc_idx++) - { - uint16_t handle; - status = attm_svc_create_db(&shdl, ATT_SVC_HID, (uint8_t *)&(cfg_flag[svc_idx][0]), - HOGPD_ATT_MAX, NULL, env->task, hids_db[svc_idx], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS))); - // update start handle for next service - shdl += hogpd_env->svcs[svc_idx].nb_att; - - // Set HID Information Char. Value - if(status == GAP_ERR_NO_ERROR) - { - handle = hogpd_get_att_handle(hogpd_env, svc_idx, HOGPD_IDX_HID_INFO_VAL, 0); - ASSERT_ERR(handle != ATT_INVALID_HDL); - status = attm_att_set_value(handle, sizeof(struct hids_hid_info), 0, (uint8_t *)¶ms->cfg[svc_idx].hid_info); - } - - // Set Report Map Char. External Report Ref value - if((status == GAP_ERR_NO_ERROR) - && ((params->cfg[svc_idx].svc_features & HOGPD_CFG_MAP_EXT_REF) == HOGPD_CFG_MAP_EXT_REF)) - { - handle = hogpd_get_att_handle(hogpd_env, svc_idx, HOGPD_IDX_REPORT_MAP_EXT_REP_REF, 0); - ASSERT_ERR(handle != ATT_INVALID_HDL); - status = attm_att_set_value(handle, sizeof(uint16_t), 0, (uint8_t *)¶ms->cfg[svc_idx].ext_ref.rep_ref_uuid); - } - - // Set Report External Ref value - for(report_idx = 0 ; (status == GAP_ERR_NO_ERROR) - && (report_idx < params->cfg[svc_idx].report_nb) ; report_idx++) - { - // Save the Report ID - report_ref.report_id = params->cfg[svc_idx].report_id[report_idx]; - // Set Report Type - report_ref.report_type = (params->cfg[svc_idx].report_char_cfg[report_idx] & HOGPD_CFG_REPORT_FEAT); - - handle = hogpd_get_att_handle(hogpd_env, svc_idx, HOGPD_IDX_REPORT_REP_REF, report_idx); - ASSERT_ERR(handle != ATT_INVALID_HDL); - // Set value in the database - status = attm_att_set_value(handle, sizeof(struct hids_report_ref), 0, (uint8_t *)&report_ref); - } - - - // by default in Report protocol mode. - hogpd_env->svcs[svc_idx].proto_mode = HOGP_REPORT_PROTOCOL_MODE; + // Set Report External Ref value + for (report_idx = 0; (status == GAP_ERR_NO_ERROR) && + (report_idx < params->cfg[svc_idx].report_nb); + report_idx++) { + // Save the Report ID + report_ref.report_id = params->cfg[svc_idx].report_id[report_idx]; + // Set Report Type + report_ref.report_type = + (params->cfg[svc_idx].report_char_cfg[report_idx] & + HOGPD_CFG_REPORT_FEAT); + handle = hogpd_get_att_handle(hogpd_env, svc_idx, + HOGPD_IDX_REPORT_REP_REF, report_idx); + ASSERT_ERR(handle != ATT_INVALID_HDL); + // Set value in the database + status = attm_att_set_value(handle, sizeof(struct hids_report_ref), 0, + (uint8_t *)&report_ref); } - //-------------------- Update profile task information --------------------- - if (status == ATT_ERR_NO_ERROR) - { - // allocate HOGPD required environment variable - env->env = (prf_env_t*) hogpd_env; - hogpd_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - hogpd_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); - // initialize environment variable - env->id = TASK_ID_HOGPD; - hogpd_task_init(&(env->desc)); + // by default in Report protocol mode. + hogpd_env->svcs[svc_idx].proto_mode = HOGP_REPORT_PROTOCOL_MODE; + } - // service is ready, go into an Idle state - ke_state_set(env->task, HOGPD_IDLE); - } - else if(hogpd_env != NULL) - { - ke_free(hogpd_env); - } + //-------------------- Update profile task information --------------------- + if (status == ATT_ERR_NO_ERROR) { + // allocate HOGPD required environment variable + env->env = (prf_env_t *)hogpd_env; + hogpd_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + hogpd_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); + // initialize environment variable + env->id = TASK_ID_HOGPD; + hogpd_task_init(&(env->desc)); - // ensure that temporary allocated databases description is correctly free - for (svc_idx = 0; svc_idx < HOGPD_NB_HIDS_INST_MAX; svc_idx++) - { - if(hids_db[svc_idx] != NULL) - { - ke_free(hids_db[svc_idx]); - } - } + // service is ready, go into an Idle state + ke_state_set(env->task, HOGPD_IDLE); + } else if (hogpd_env != NULL) { + ke_free(hogpd_env); + } - return (status); + // ensure that temporary allocated databases description is correctly free + for (svc_idx = 0; svc_idx < HOGPD_NB_HIDS_INST_MAX; svc_idx++) { + if (hids_db[svc_idx] != NULL) { + ke_free(hids_db[svc_idx]); + } + } + + return (status); } /** **************************************************************************************** * @brief Destruction of the HOGPD module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void hogpd_destroy(struct prf_task_env* env) -{ - struct hogpd_env_tag* hogpd_env = (struct hogpd_env_tag*) env->env; +static void hogpd_destroy(struct prf_task_env *env) { + struct hogpd_env_tag *hogpd_env = (struct hogpd_env_tag *)env->env; - // free profile environment variables - env->env = NULL; - ke_free(hogpd_env); + // free profile environment variables + env->env = NULL; + ke_free(hogpd_env); } /** @@ -416,9 +479,8 @@ static void hogpd_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void hogpd_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Nothing to do */ +static void hogpd_create(struct prf_task_env *env, uint8_t conidx) { + /* Nothing to do */ } /** @@ -430,472 +492,408 @@ static void hogpd_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void hogpd_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct hogpd_env_tag* hogpd_env = (struct hogpd_env_tag*) env->env; - uint8_t svc_idx; - ASSERT_ERR(conidx < BLE_CONNECTION_MAX); +static void hogpd_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct hogpd_env_tag *hogpd_env = (struct hogpd_env_tag *)env->env; + uint8_t svc_idx; + ASSERT_ERR(conidx < BLE_CONNECTION_MAX); - // Reset the notification configuration to ensure that no notification will be sent on - // a disconnected link - for (svc_idx = 0; svc_idx < hogpd_env->hids_nb; svc_idx++) - { - hogpd_env->svcs[svc_idx].ntf_cfg[conidx] = 0; - } + // Reset the notification configuration to ensure that no notification will be + // sent on a disconnected link + for (svc_idx = 0; svc_idx < hogpd_env->hids_nb; svc_idx++) { + hogpd_env->svcs[svc_idx].ntf_cfg[conidx] = 0; + } } - - /* * GLOBAL VARIABLE DEFINITIONS **************************************************************************************** */ /// HOGPD Task interface required by profile manager -const struct prf_task_cbs hogpd_itf = -{ - (prf_init_fnct) hogpd_init, - hogpd_destroy, - hogpd_create, - hogpd_cleanup, +const struct prf_task_cbs hogpd_itf = { + (prf_init_fnct)hogpd_init, + hogpd_destroy, + hogpd_create, + hogpd_cleanup, }; - /* * GLOBAL FUNCTIONS DEFINITIONS **************************************************************************************** */ -const struct prf_task_cbs* hogpd_prf_itf_get(void) -{ - return &hogpd_itf; -} +const struct prf_task_cbs *hogpd_prf_itf_get(void) { return &hogpd_itf; } +uint16_t hogpd_get_att_handle(struct hogpd_env_tag *hogpd_env, uint8_t svc_idx, + uint8_t att_idx, uint8_t report_idx) { + uint16_t handle = ATT_INVALID_HDL; + uint8_t i = 0; -uint16_t hogpd_get_att_handle(struct hogpd_env_tag* hogpd_env, uint8_t svc_idx, uint8_t att_idx, uint8_t report_idx) -{ - uint16_t handle = ATT_INVALID_HDL; - uint8_t i = 0; + // Sanity check + if ((svc_idx < hogpd_env->hids_nb) && (att_idx < HOGPD_IDX_NB) && + ((att_idx < HOGPD_ATT_UNIQ_NB) || + (report_idx < hogpd_env->svcs[svc_idx].nb_report))) { + handle = hogpd_env->start_hdl; - // Sanity check - if((svc_idx < hogpd_env ->hids_nb) && (att_idx < HOGPD_IDX_NB) - && ((att_idx < HOGPD_ATT_UNIQ_NB) || (report_idx < hogpd_env->svcs[svc_idx].nb_report))) - { - handle = hogpd_env->start_hdl; - - for(i = 0 ; i < svc_idx ; i++) - { - // update start handle for next service - only useful if multiple service, else not used. - handle += hogpd_env->svcs[i].nb_att; - } - - // increment index according to expected index - if(att_idx < HOGPD_ATT_UNIQ_NB) - { - handle += att_idx; - - // check if Keyboard feature active - if((hogpd_env->svcs[svc_idx].features & HOGPD_CFG_KEYBOARD) == 0) - { - if(att_idx > HOGPD_IDX_BOOT_KB_OUT_REPORT_VAL) - { - handle -= HIDS_KEYBOARD_ATT_NB; - } - // Error Case - else if ((att_idx >= HOGPD_IDX_BOOT_KB_IN_REPORT_CHAR) - && (att_idx <= HOGPD_IDX_BOOT_KB_OUT_REPORT_VAL)) - { - handle = ATT_INVALID_HANDLE; - } - } - - // check if Mouse feature active - if((hogpd_env->svcs[svc_idx].features & HOGPD_CFG_MOUSE) == 0) - { - if(att_idx > HOGPD_IDX_BOOT_MOUSE_IN_REPORT_NTF_CFG) - { - handle -= HIDS_MOUSE_ATT_NB; - } - // Error Case - else if ((att_idx >= HOGPD_IDX_BOOT_MOUSE_IN_REPORT_CHAR) - && (att_idx <= HOGPD_IDX_BOOT_MOUSE_IN_REPORT_NTF_CFG)) - { - handle = ATT_INVALID_HANDLE; - } - } - - // check if Protocol Mode feature active - if((hogpd_env->svcs[svc_idx].features & HOGPD_CFG_PROTO_MODE) == 0) - { - if(att_idx > HOGPD_IDX_PROTO_MODE_VAL) - { - handle -= HIDS_PROTO_MODE_ATT_NB; - } - // Error Case - else if ((att_idx >= HOGPD_IDX_PROTO_MODE_CHAR) - && (att_idx <= HOGPD_IDX_PROTO_MODE_VAL)) - { - handle = ATT_INVALID_HANDLE; - } - } - - // check if Ext Ref feature active - if((hogpd_env->svcs[svc_idx].features & HOGPD_CFG_MAP_EXT_REF) == 0) - { - if(att_idx > HOGPD_IDX_REPORT_MAP_EXT_REP_REF) - { - handle -= HIDS_MAP_EXT_ATT_NB; - } - else if(att_idx > HOGPD_IDX_INCL_SVC) - { - handle -= 1; - } - // Error Case - else if ((att_idx == HOGPD_IDX_INCL_SVC) - || (att_idx == HOGPD_IDX_REPORT_MAP_EXT_REP_REF)) - { - handle = ATT_INVALID_HANDLE; - } - } - } - else - { - handle += hogpd_env->svcs[svc_idx].report_hdl_offset; - - // increment attribute handle with other reports - for(i = 0 ; i < report_idx; i++) - { - handle += HIDS_REPORT_MANDATORY_ATT_NB; - // check if it's a Report input - if((hogpd_env->svcs[svc_idx].features & (HOGPD_CFG_REPORT_NTF_EN << i)) != 0) - { - handle += HIDS_REPORT_IN_ATT_NB; - } - } - - // Error check - if((att_idx == HOGPD_IDX_REPORT_NTF_CFG) - && ((hogpd_env->svcs[svc_idx].features & (HOGPD_CFG_REPORT_NTF_EN << report_idx)) != 0)) - { - handle = ATT_INVALID_HANDLE; - } - else - { - // update handle cursor - handle += att_idx - HOGPD_ATT_UNIQ_NB; - } - } + for (i = 0; i < svc_idx; i++) { + // update start handle for next service - only useful if multiple service, + // else not used. + handle += hogpd_env->svcs[i].nb_att; } - return handle; + // increment index according to expected index + if (att_idx < HOGPD_ATT_UNIQ_NB) { + handle += att_idx; + + // check if Keyboard feature active + if ((hogpd_env->svcs[svc_idx].features & HOGPD_CFG_KEYBOARD) == 0) { + if (att_idx > HOGPD_IDX_BOOT_KB_OUT_REPORT_VAL) { + handle -= HIDS_KEYBOARD_ATT_NB; + } + // Error Case + else if ((att_idx >= HOGPD_IDX_BOOT_KB_IN_REPORT_CHAR) && + (att_idx <= HOGPD_IDX_BOOT_KB_OUT_REPORT_VAL)) { + handle = ATT_INVALID_HANDLE; + } + } + + // check if Mouse feature active + if ((hogpd_env->svcs[svc_idx].features & HOGPD_CFG_MOUSE) == 0) { + if (att_idx > HOGPD_IDX_BOOT_MOUSE_IN_REPORT_NTF_CFG) { + handle -= HIDS_MOUSE_ATT_NB; + } + // Error Case + else if ((att_idx >= HOGPD_IDX_BOOT_MOUSE_IN_REPORT_CHAR) && + (att_idx <= HOGPD_IDX_BOOT_MOUSE_IN_REPORT_NTF_CFG)) { + handle = ATT_INVALID_HANDLE; + } + } + + // check if Protocol Mode feature active + if ((hogpd_env->svcs[svc_idx].features & HOGPD_CFG_PROTO_MODE) == 0) { + if (att_idx > HOGPD_IDX_PROTO_MODE_VAL) { + handle -= HIDS_PROTO_MODE_ATT_NB; + } + // Error Case + else if ((att_idx >= HOGPD_IDX_PROTO_MODE_CHAR) && + (att_idx <= HOGPD_IDX_PROTO_MODE_VAL)) { + handle = ATT_INVALID_HANDLE; + } + } + + // check if Ext Ref feature active + if ((hogpd_env->svcs[svc_idx].features & HOGPD_CFG_MAP_EXT_REF) == 0) { + if (att_idx > HOGPD_IDX_REPORT_MAP_EXT_REP_REF) { + handle -= HIDS_MAP_EXT_ATT_NB; + } else if (att_idx > HOGPD_IDX_INCL_SVC) { + handle -= 1; + } + // Error Case + else if ((att_idx == HOGPD_IDX_INCL_SVC) || + (att_idx == HOGPD_IDX_REPORT_MAP_EXT_REP_REF)) { + handle = ATT_INVALID_HANDLE; + } + } + } else { + handle += hogpd_env->svcs[svc_idx].report_hdl_offset; + + // increment attribute handle with other reports + for (i = 0; i < report_idx; i++) { + handle += HIDS_REPORT_MANDATORY_ATT_NB; + // check if it's a Report input + if ((hogpd_env->svcs[svc_idx].features & + (HOGPD_CFG_REPORT_NTF_EN << i)) != 0) { + handle += HIDS_REPORT_IN_ATT_NB; + } + } + + // Error check + if ((att_idx == HOGPD_IDX_REPORT_NTF_CFG) && + ((hogpd_env->svcs[svc_idx].features & + (HOGPD_CFG_REPORT_NTF_EN << report_idx)) != 0)) { + handle = ATT_INVALID_HANDLE; + } else { + // update handle cursor + handle += att_idx - HOGPD_ATT_UNIQ_NB; + } + } + } + + return handle; } -uint8_t hogpd_get_att_idx(struct hogpd_env_tag* hogpd_env, uint16_t handle, uint8_t *svc_idx, uint8_t *att_idx, uint8_t *report_idx) -{ - uint16_t hdl_cursor = hogpd_env->start_hdl; - uint8_t status = PRF_APP_ERROR; +uint8_t hogpd_get_att_idx(struct hogpd_env_tag *hogpd_env, uint16_t handle, + uint8_t *svc_idx, uint8_t *att_idx, + uint8_t *report_idx) { + uint16_t hdl_cursor = hogpd_env->start_hdl; + uint8_t status = PRF_APP_ERROR; - // invalid index - *att_idx = HOGPD_IDX_NB; + // invalid index + *att_idx = HOGPD_IDX_NB; - // Browse list of services - // handle must be greater than current index - for(*svc_idx = 0 ; (*svc_idx < hogpd_env->hids_nb) && (handle >= hdl_cursor) ; (*svc_idx)++) - { - // check if handle is on current service - if(handle >= (hdl_cursor + hogpd_env->svcs[*svc_idx].nb_att)) - { - hdl_cursor += hogpd_env->svcs[*svc_idx].nb_att; - continue; - } + // Browse list of services + // handle must be greater than current index + for (*svc_idx = 0; (*svc_idx < hogpd_env->hids_nb) && (handle >= hdl_cursor); + (*svc_idx)++) { + // check if handle is on current service + if (handle >= (hdl_cursor + hogpd_env->svcs[*svc_idx].nb_att)) { + hdl_cursor += hogpd_env->svcs[*svc_idx].nb_att; + continue; + } - // if we are here, we are sure that handle is valid - status = GAP_ERR_NO_ERROR; - *report_idx = 0; + // if we are here, we are sure that handle is valid + status = GAP_ERR_NO_ERROR; + *report_idx = 0; - // check if handle is in reports or not - if(handle < (hdl_cursor + hogpd_env->svcs[*svc_idx].report_hdl_offset)) - { - if(handle == hdl_cursor) - { - *att_idx = HOGPD_IDX_SVC; - break; - } - - // check if Ext Ref feature active - if((hogpd_env->svcs[*svc_idx].features & HOGPD_CFG_MAP_EXT_REF) != 0) - { - hdl_cursor += 1; - if(handle == hdl_cursor) - { - *att_idx = HOGPD_IDX_INCL_SVC; - break; - } - } - - // check if handle is in mandatory range - hdl_cursor += HIDS_MANDATORY_ATT_NB; - if(handle <= hdl_cursor) - { - *att_idx = HOGPD_IDX_REPORT_MAP_VAL - (hdl_cursor - handle - 1); - break; - } - - // check if Ext Ref feature active - if((hogpd_env->svcs[*svc_idx].features & HOGPD_CFG_MAP_EXT_REF) != 0) - { - hdl_cursor += 1; - if(handle == hdl_cursor) - { - *att_idx = HOGPD_IDX_REPORT_MAP_EXT_REP_REF; - break; - } - } - - // check if Protocol Mode feature active - if((hogpd_env->svcs[*svc_idx].features & HOGPD_CFG_PROTO_MODE) != 0) - { - hdl_cursor += HIDS_PROTO_MODE_ATT_NB; - if(handle <= hdl_cursor) - { - *att_idx = HOGPD_IDX_PROTO_MODE_VAL - (hdl_cursor - handle - 1); - break; - } - } - - // check if Keyboard feature active - if((hogpd_env->svcs[*svc_idx].features & HOGPD_CFG_KEYBOARD) != 0) - { - hdl_cursor += HIDS_KEYBOARD_ATT_NB; - if(handle <= hdl_cursor) - { - *att_idx = HOGPD_IDX_BOOT_KB_OUT_REPORT_VAL - (hdl_cursor - handle - 1); - break; - } - } - - // check if Mouse feature active - if((hogpd_env->svcs[*svc_idx].features & HOGPD_CFG_MOUSE) != 0) - { - hdl_cursor += HIDS_MOUSE_ATT_NB; - if(handle <= hdl_cursor) - { - *att_idx = HOGPD_IDX_BOOT_MOUSE_IN_REPORT_NTF_CFG - (hdl_cursor - handle - 1); - break; - } - } - - // not expected - ASSERT_ERR(0); - } - else - { - // add handle offset - hdl_cursor += hogpd_env->svcs[*svc_idx].report_hdl_offset; - - for(*report_idx = 0 ; (*report_idx < hogpd_env->svcs[*svc_idx].nb_report) ; (*report_idx)++) - { - hdl_cursor += HIDS_REPORT_MANDATORY_ATT_NB; - if(handle <= hdl_cursor) - { - *att_idx = HOGPD_IDX_REPORT_REP_REF - (hdl_cursor - handle - 1); - break; - } - - if((hogpd_env->svcs[*svc_idx].features & (HOGPD_CFG_REPORT_NTF_EN << *report_idx)) != 0) - { - hdl_cursor += HIDS_REPORT_IN_ATT_NB; - if(handle == hdl_cursor) - { - *att_idx = HOGPD_IDX_REPORT_NTF_CFG; - break; - } - } - } - - // not expected - ASSERT_ERR(*att_idx != HOGPD_IDX_NB); - } - // loop not expected here + // check if handle is in reports or not + if (handle < (hdl_cursor + hogpd_env->svcs[*svc_idx].report_hdl_offset)) { + if (handle == hdl_cursor) { + *att_idx = HOGPD_IDX_SVC; break; - } + } - return (status); + // check if Ext Ref feature active + if ((hogpd_env->svcs[*svc_idx].features & HOGPD_CFG_MAP_EXT_REF) != 0) { + hdl_cursor += 1; + if (handle == hdl_cursor) { + *att_idx = HOGPD_IDX_INCL_SVC; + break; + } + } + + // check if handle is in mandatory range + hdl_cursor += HIDS_MANDATORY_ATT_NB; + if (handle <= hdl_cursor) { + *att_idx = HOGPD_IDX_REPORT_MAP_VAL - (hdl_cursor - handle - 1); + break; + } + + // check if Ext Ref feature active + if ((hogpd_env->svcs[*svc_idx].features & HOGPD_CFG_MAP_EXT_REF) != 0) { + hdl_cursor += 1; + if (handle == hdl_cursor) { + *att_idx = HOGPD_IDX_REPORT_MAP_EXT_REP_REF; + break; + } + } + + // check if Protocol Mode feature active + if ((hogpd_env->svcs[*svc_idx].features & HOGPD_CFG_PROTO_MODE) != 0) { + hdl_cursor += HIDS_PROTO_MODE_ATT_NB; + if (handle <= hdl_cursor) { + *att_idx = HOGPD_IDX_PROTO_MODE_VAL - (hdl_cursor - handle - 1); + break; + } + } + + // check if Keyboard feature active + if ((hogpd_env->svcs[*svc_idx].features & HOGPD_CFG_KEYBOARD) != 0) { + hdl_cursor += HIDS_KEYBOARD_ATT_NB; + if (handle <= hdl_cursor) { + *att_idx = + HOGPD_IDX_BOOT_KB_OUT_REPORT_VAL - (hdl_cursor - handle - 1); + break; + } + } + + // check if Mouse feature active + if ((hogpd_env->svcs[*svc_idx].features & HOGPD_CFG_MOUSE) != 0) { + hdl_cursor += HIDS_MOUSE_ATT_NB; + if (handle <= hdl_cursor) { + *att_idx = HOGPD_IDX_BOOT_MOUSE_IN_REPORT_NTF_CFG - + (hdl_cursor - handle - 1); + break; + } + } + + // not expected + ASSERT_ERR(0); + } else { + // add handle offset + hdl_cursor += hogpd_env->svcs[*svc_idx].report_hdl_offset; + + for (*report_idx = 0; (*report_idx < hogpd_env->svcs[*svc_idx].nb_report); + (*report_idx)++) { + hdl_cursor += HIDS_REPORT_MANDATORY_ATT_NB; + if (handle <= hdl_cursor) { + *att_idx = HOGPD_IDX_REPORT_REP_REF - (hdl_cursor - handle - 1); + break; + } + + if ((hogpd_env->svcs[*svc_idx].features & + (HOGPD_CFG_REPORT_NTF_EN << *report_idx)) != 0) { + hdl_cursor += HIDS_REPORT_IN_ATT_NB; + if (handle == hdl_cursor) { + *att_idx = HOGPD_IDX_REPORT_NTF_CFG; + break; + } + } + } + + // not expected + ASSERT_ERR(*att_idx != HOGPD_IDX_NB); + } + // loop not expected here + break; + } + + return (status); } +uint8_t hogpd_ntf_send(uint8_t conidx, const struct hogpd_report_info *report) { + struct hogpd_env_tag *hogpd_env = PRF_ENV_GET(HOGPD, hogpd); + uint8_t status = GAP_ERR_NO_ERROR; + uint16_t handle = ATT_INVALID_HANDLE; + uint8_t att_idx = HOGPD_IDX_NB; + uint16_t max_report_len = 0; + uint16_t feature_mask = 0; + uint8_t exp_prot_mode = 0; -uint8_t hogpd_ntf_send(uint8_t conidx, const struct hogpd_report_info* report) -{ - struct hogpd_env_tag* hogpd_env = PRF_ENV_GET(HOGPD, hogpd); - uint8_t status = GAP_ERR_NO_ERROR; - uint16_t handle = ATT_INVALID_HANDLE; - uint8_t att_idx = HOGPD_IDX_NB; - uint16_t max_report_len= 0; - uint16_t feature_mask = 0; - uint8_t exp_prot_mode = 0; + // According to the report type retrieve: + // - Attribute index + // - Attribute max length + // - Feature to use + // - Expected protocol mode + switch (report->type) { + // An Input Report + case HOGPD_REPORT: { + att_idx = HOGPD_IDX_REPORT_VAL; + max_report_len = HOGPD_REPORT_MAX_LEN; + feature_mask = HOGPD_CFG_REPORT_NTF_EN << report->idx; + exp_prot_mode = HOGP_REPORT_PROTOCOL_MODE; + } break; + // Boot Keyboard input report + case HOGPD_BOOT_KEYBOARD_INPUT_REPORT: { + att_idx = HOGPD_IDX_BOOT_KB_IN_REPORT_VAL; + max_report_len = HOGPD_BOOT_REPORT_MAX_LEN; + feature_mask = HOGPD_CFG_KEYBOARD; + exp_prot_mode = HOGP_BOOT_PROTOCOL_MODE; + } break; + // Boot Mouse input report + case HOGPD_BOOT_MOUSE_INPUT_REPORT: { + att_idx = HOGPD_IDX_BOOT_MOUSE_IN_REPORT_VAL; + max_report_len = HOGPD_BOOT_REPORT_MAX_LEN; + feature_mask = HOGPD_CFG_MOUSE; + exp_prot_mode = HOGP_BOOT_PROTOCOL_MODE; + } break; - // According to the report type retrieve: - // - Attribute index - // - Attribute max length - // - Feature to use - // - Expected protocol mode - switch(report->type) - { - // An Input Report - case HOGPD_REPORT: - { - att_idx = HOGPD_IDX_REPORT_VAL; - max_report_len = HOGPD_REPORT_MAX_LEN; - feature_mask = HOGPD_CFG_REPORT_NTF_EN << report->idx; - exp_prot_mode = HOGP_REPORT_PROTOCOL_MODE; - }break; - // Boot Keyboard input report - case HOGPD_BOOT_KEYBOARD_INPUT_REPORT: - { - att_idx = HOGPD_IDX_BOOT_KB_IN_REPORT_VAL; - max_report_len = HOGPD_BOOT_REPORT_MAX_LEN; - feature_mask = HOGPD_CFG_KEYBOARD; - exp_prot_mode = HOGP_BOOT_PROTOCOL_MODE; - }break; - // Boot Mouse input report - case HOGPD_BOOT_MOUSE_INPUT_REPORT: - { - att_idx = HOGPD_IDX_BOOT_MOUSE_IN_REPORT_VAL; - max_report_len = HOGPD_BOOT_REPORT_MAX_LEN; - feature_mask = HOGPD_CFG_MOUSE; - exp_prot_mode = HOGP_BOOT_PROTOCOL_MODE; - }break; + default: /* Nothing to do */ + break; + } - default: /* Nothing to do */ break; + handle = + hogpd_get_att_handle(hogpd_env, report->hid_idx, att_idx, report->idx); + + // check if attribute is found + if (handle == ATT_INVALID_HANDLE) { + // check if it's an unsupported feature + if ((feature_mask != 0) && (report->hid_idx < hogpd_env->hids_nb) && + (report->idx < hogpd_env->svcs[report->hid_idx].nb_report) && + ((hogpd_env->svcs[report->hid_idx].features & feature_mask) == 0)) { + status = PRF_ERR_FEATURE_NOT_SUPPORTED; } - - handle = hogpd_get_att_handle(hogpd_env, report->hid_idx, att_idx, report->idx); - - // check if attribute is found - if(handle == ATT_INVALID_HANDLE) - { - // check if it's an unsupported feature - if((feature_mask != 0) && (report->hid_idx < hogpd_env->hids_nb) - && (report->idx < hogpd_env->svcs[report->hid_idx].nb_report) - && ((hogpd_env->svcs[report->hid_idx].features & feature_mask) == 0)) - { - status = PRF_ERR_FEATURE_NOT_SUPPORTED; - } - // or an invalid param - else - { - status = PRF_ERR_INVALID_PARAM; - } - } - // check if length is valid - else if(report->length > max_report_len) - { - status = PRF_ERR_UNEXPECTED_LEN; - } - // check if notification is enabled - else if ((hogpd_env->svcs[report->hid_idx].ntf_cfg[conidx] & feature_mask) == 0) - { - status = PRF_ERR_NTF_DISABLED; - } - // check if protocol mode is valid - else if((hogpd_env->svcs[report->hid_idx].proto_mode != exp_prot_mode) - && ((hogpd_env->svcs[report->hid_idx].features & HOGPD_CFG_PROTO_MODE) != 0)) - { - status = PRF_ERR_REQ_DISALLOWED; + // or an invalid param + else { + status = PRF_ERR_INVALID_PARAM; } + } + // check if length is valid + else if (report->length > max_report_len) { + status = PRF_ERR_UNEXPECTED_LEN; + } + // check if notification is enabled + else if ((hogpd_env->svcs[report->hid_idx].ntf_cfg[conidx] & feature_mask) == + 0) { + status = PRF_ERR_NTF_DISABLED; + } + // check if protocol mode is valid + else if ((hogpd_env->svcs[report->hid_idx].proto_mode != exp_prot_mode) && + ((hogpd_env->svcs[report->hid_idx].features & + HOGPD_CFG_PROTO_MODE) != 0)) { + status = PRF_ERR_REQ_DISALLOWED; + } - if(status == GAP_ERR_NO_ERROR) - { - // Allocate the GATT notification message - struct gattc_send_evt_cmd *report_ntf = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(&(hogpd_env->prf_env), conidx), - gattc_send_evt_cmd, report->length); + if (status == GAP_ERR_NO_ERROR) { + // Allocate the GATT notification message + struct gattc_send_evt_cmd *report_ntf = + KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&(hogpd_env->prf_env), conidx), + gattc_send_evt_cmd, report->length); - // Fill in the parameter structure - report_ntf->operation = GATTC_NOTIFY; - report_ntf->handle = handle; - // pack measured value in database - report_ntf->length = report->length; - memcpy(report_ntf->value, report->value, report->length); - // send notification to peer device - ke_msg_send(report_ntf); - } + // Fill in the parameter structure + report_ntf->operation = GATTC_NOTIFY; + report_ntf->handle = handle; + // pack measured value in database + report_ntf->length = report->length; + memcpy(report_ntf->value, report->value, report->length); + // send notification to peer device + ke_msg_send(report_ntf); + } - return (status); + return (status); } -uint8_t hogpd_ntf_cfg_ind_send(uint8_t conidx, uint8_t svc_idx, uint8_t att_idx, uint8_t report_idx, uint16_t ntf_cfg) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; - uint16_t mask = 0; +uint8_t hogpd_ntf_cfg_ind_send(uint8_t conidx, uint8_t svc_idx, uint8_t att_idx, + uint8_t report_idx, uint16_t ntf_cfg) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; + uint16_t mask = 0; - struct hogpd_env_tag* hogpd_env = PRF_ENV_GET(HOGPD, hogpd); + struct hogpd_env_tag *hogpd_env = PRF_ENV_GET(HOGPD, hogpd); - // set notification config update mask - switch(att_idx) - { - // An Input Report - case HOGPD_IDX_REPORT_NTF_CFG: - { - mask = HOGPD_CFG_REPORT_NTF_EN << report_idx; - }break; - // Boot Keyboard input report - case HOGPD_IDX_BOOT_KB_IN_REPORT_NTF_CFG: - { - mask = HOGPD_CFG_KEYBOARD; - }break; - // Boot Mouse input report - case HOGPD_IDX_BOOT_MOUSE_IN_REPORT_NTF_CFG: - { - mask = HOGPD_CFG_MOUSE; - }break; + // set notification config update mask + switch (att_idx) { + // An Input Report + case HOGPD_IDX_REPORT_NTF_CFG: { + mask = HOGPD_CFG_REPORT_NTF_EN << report_idx; + } break; + // Boot Keyboard input report + case HOGPD_IDX_BOOT_KB_IN_REPORT_NTF_CFG: { + mask = HOGPD_CFG_KEYBOARD; + } break; + // Boot Mouse input report + case HOGPD_IDX_BOOT_MOUSE_IN_REPORT_NTF_CFG: { + mask = HOGPD_CFG_MOUSE; + } break; - default: - { - ASSERT_ERR(0); - }break; + default: { + ASSERT_ERR(0); + } break; + } + + // Stop notification + if (ntf_cfg == PRF_CLI_STOP_NTFIND) { + hogpd_env->svcs[svc_idx].ntf_cfg[conidx] &= ~mask; + } + // Start notification + else if (ntf_cfg == PRF_CLI_START_NTF) { + hogpd_env->svcs[svc_idx].ntf_cfg[conidx] |= mask; + } + // Provided value is incorrect + else { + status = PRF_APP_ERROR; + } + + // inform application about updated notification configuration + if (status == GAP_ERR_NO_ERROR) { + // Allocate the GATT notification message + struct hogpd_ntf_cfg_ind *ntf_cfg_ind = KE_MSG_ALLOC( + HOGPD_NTF_CFG_IND, prf_dst_task_get(&(hogpd_env->prf_env), conidx), + prf_src_task_get(&(hogpd_env->prf_env), conidx), hogpd_ntf_cfg_ind); + + // Fill in the parameter structure + ntf_cfg_ind->conidx = conidx; + + for (svc_idx = 0; svc_idx < HOGPD_NB_HIDS_INST_MAX; svc_idx++) { + ntf_cfg_ind->ntf_cfg[svc_idx] = hogpd_env->svcs[svc_idx].ntf_cfg[conidx]; } - // Stop notification - if (ntf_cfg == PRF_CLI_STOP_NTFIND) - { - hogpd_env->svcs[svc_idx].ntf_cfg[conidx] &= ~mask; - } - // Start notification - else if(ntf_cfg == PRF_CLI_START_NTF) - { - hogpd_env->svcs[svc_idx].ntf_cfg[conidx] |= mask; - } - // Provided value is incorrect - else - { - status = PRF_APP_ERROR; - } + // send indication to application + ke_msg_send(ntf_cfg_ind); + } - - // inform application about updated notification configuration - if(status == GAP_ERR_NO_ERROR) - { - // Allocate the GATT notification message - struct hogpd_ntf_cfg_ind *ntf_cfg_ind = KE_MSG_ALLOC(HOGPD_NTF_CFG_IND, - prf_dst_task_get(&(hogpd_env->prf_env), conidx), - prf_src_task_get(&(hogpd_env->prf_env), conidx), - hogpd_ntf_cfg_ind); - - // Fill in the parameter structure - ntf_cfg_ind->conidx = conidx; - - for(svc_idx = 0 ; svc_idx < HOGPD_NB_HIDS_INST_MAX; svc_idx++) - { - ntf_cfg_ind->ntf_cfg[svc_idx] = hogpd_env->svcs[svc_idx].ntf_cfg[conidx]; - } - - // send indication to application - ke_msg_send(ntf_cfg_ind); - } - - return (status); + return (status); } #endif /* BLE_HID_DEVICE */ diff --git a/services/ble_profiles/hogp/hogpd/src/hogpd_task.c b/services/ble_profiles/hogp/hogpd/src/hogpd_task.c index 7d96bf7..27244a6 100644 --- a/services/ble_profiles/hogp/hogpd/src/hogpd_task.c +++ b/services/ble_profiles/hogp/hogpd/src/hogpd_task.c @@ -16,7 +16,7 @@ #include "gap.h" #include "gattc_task.h" -//HID Over GATT Profile Device Role Functions +// HID Over GATT Profile Device Role Functions #include "hogpd.h" #include "hogpd_task.h" @@ -34,8 +34,6 @@ **************************************************************************************** */ - - /** **************************************************************************************** * @brief Handles reception of the @ref HOGPD_ENABLE_REQ message. @@ -48,41 +46,38 @@ **************************************************************************************** */ __STATIC int hogpd_enable_req_handler(ke_msg_id_t const msgid, - struct hogpd_enable_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Counter for HIDS instance - uint8_t svc_idx; - uint8_t status = GAP_ERR_NO_ERROR; + struct hogpd_enable_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Counter for HIDS instance + uint8_t svc_idx; + uint8_t status = GAP_ERR_NO_ERROR; - struct hogpd_env_tag* hogpd_env = PRF_ENV_GET(HOGPD, hogpd); + struct hogpd_env_tag *hogpd_env = PRF_ENV_GET(HOGPD, hogpd); - ASSERT_ERR(hogpd_env!=NULL); + ASSERT_ERR(hogpd_env != NULL); - // Check provided values and check if connection exists - if((param->conidx > BLE_CONNECTION_MAX) - || (gapc_get_conhdl(param->conidx) == GAP_INVALID_CONHDL)) - { - // an error occurs, trigg it. - status = (param->conidx > BLE_CONNECTION_MAX) ? GAP_ERR_INVALID_PARAM : PRF_ERR_REQ_DISALLOWED; - } - else - { - for (svc_idx = 0; svc_idx < hogpd_env->hids_nb; svc_idx++) - { - // Retrieve notification configuration - hogpd_env->svcs[svc_idx].ntf_cfg[param->conidx] = param->ntf_cfg[svc_idx]; - } + // Check provided values and check if connection exists + if ((param->conidx > BLE_CONNECTION_MAX) || + (gapc_get_conhdl(param->conidx) == GAP_INVALID_CONHDL)) { + // an error occurs, trigg it. + status = (param->conidx > BLE_CONNECTION_MAX) ? GAP_ERR_INVALID_PARAM + : PRF_ERR_REQ_DISALLOWED; + } else { + for (svc_idx = 0; svc_idx < hogpd_env->hids_nb; svc_idx++) { + // Retrieve notification configuration + hogpd_env->svcs[svc_idx].ntf_cfg[param->conidx] = param->ntf_cfg[svc_idx]; } + } - // Send back response - struct hogpd_enable_rsp* rsp = KE_MSG_ALLOC(HOGPD_ENABLE_RSP, src_id, dest_id, hogpd_enable_rsp); - rsp->conidx = param->conidx; - rsp->status = status; - ke_msg_send(rsp); + // Send back response + struct hogpd_enable_rsp *rsp = + KE_MSG_ALLOC(HOGPD_ENABLE_RSP, src_id, dest_id, hogpd_enable_rsp); + rsp->conidx = param->conidx; + rsp->status = status; + ke_msg_send(rsp); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -96,53 +91,45 @@ __STATIC int hogpd_enable_req_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int hogpd_report_upd_req_handler(ke_msg_id_t const msgid, - struct hogpd_report_upd_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - int msg_status = KE_MSG_CONSUMED; - uint8_t state = ke_state_get(dest_id); +__STATIC int hogpd_report_upd_req_handler( + ke_msg_id_t const msgid, struct hogpd_report_upd_req const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + int msg_status = KE_MSG_CONSUMED; + uint8_t state = ke_state_get(dest_id); - // check that task is in idle state - if((state & HOGPD_REQ_BUSY) == HOGPD_IDLE) - { - // Status - uint8_t status = PRF_ERR_INVALID_PARAM; - // Check provided values and check if connection exists - if((param->conidx > BLE_CONNECTION_MAX) - || (gapc_get_conhdl(param->conidx) == GAP_INVALID_CONHDL)) - { - status = (param->conidx > BLE_CONNECTION_MAX) ? GAP_ERR_INVALID_PARAM : PRF_ERR_REQ_DISALLOWED; - } - else - { - status = hogpd_ntf_send(param->conidx, &(param->report)); - } - - // an error occurs inform application - if (status != GAP_ERR_NO_ERROR) - { - // send report update response - struct hogpd_report_upd_rsp *rsp = KE_MSG_ALLOC(HOGPD_REPORT_UPD_RSP, - src_id, dest_id, hogpd_report_upd_rsp); - rsp->conidx = param->conidx; - rsp->status = status; - ke_msg_send(rsp); - } - // go in a busy state - else - { - ke_state_set(dest_id, state | HOGPD_REQ_BUSY); - } - } - // else process it later - else - { - msg_status = KE_MSG_SAVED; + // check that task is in idle state + if ((state & HOGPD_REQ_BUSY) == HOGPD_IDLE) { + // Status + uint8_t status = PRF_ERR_INVALID_PARAM; + // Check provided values and check if connection exists + if ((param->conidx > BLE_CONNECTION_MAX) || + (gapc_get_conhdl(param->conidx) == GAP_INVALID_CONHDL)) { + status = (param->conidx > BLE_CONNECTION_MAX) ? GAP_ERR_INVALID_PARAM + : PRF_ERR_REQ_DISALLOWED; + } else { + status = hogpd_ntf_send(param->conidx, &(param->report)); } - return (msg_status); + // an error occurs inform application + if (status != GAP_ERR_NO_ERROR) { + // send report update response + struct hogpd_report_upd_rsp *rsp = KE_MSG_ALLOC( + HOGPD_REPORT_UPD_RSP, src_id, dest_id, hogpd_report_upd_rsp); + rsp->conidx = param->conidx; + rsp->status = status; + ke_msg_send(rsp); + } + // go in a busy state + else { + ke_state_set(dest_id, state | HOGPD_REQ_BUSY); + } + } + // else process it later + else { + msg_status = KE_MSG_SAVED; + } + + return (msg_status); } /** @@ -157,104 +144,95 @@ __STATIC int hogpd_report_upd_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int hogpd_report_cfm_handler(ke_msg_id_t const msgid, - struct hogpd_report_cfm const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ + struct hogpd_report_cfm const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { - uint8_t state = ke_state_get(dest_id); + uint8_t state = ke_state_get(dest_id); - // check that an operation is ongoing - if((state & HOGPD_OP_BUSY) == HOGPD_OP_BUSY) - { - uint16_t handle = ATT_INVALID_HANDLE; - uint8_t status = PRF_APP_ERROR; - struct hogpd_env_tag* hogpd_env = PRF_ENV_GET(HOGPD, hogpd); + // check that an operation is ongoing + if ((state & HOGPD_OP_BUSY) == HOGPD_OP_BUSY) { + uint16_t handle = ATT_INVALID_HANDLE; + uint8_t status = PRF_APP_ERROR; + struct hogpd_env_tag *hogpd_env = PRF_ENV_GET(HOGPD, hogpd); - // check received status - if(param->status != GAP_ERR_NO_ERROR) - { - status = param->status; - } - // perform operation sanity check - else if((param->operation == hogpd_env->op.operation) && (param->conidx == hogpd_env->op.conidx)) - { - // retrieve attribute index. - uint8_t att_idx = 0; - switch(param->report.type) - { - case HOGPD_REPORT: - { - att_idx = HOGPD_IDX_REPORT_VAL; - }break; - case HOGPD_REPORT_MAP: - { - att_idx = HOGPD_IDX_REPORT_MAP_VAL; - }break; - case HOGPD_BOOT_KEYBOARD_INPUT_REPORT: - { - att_idx = HOGPD_IDX_BOOT_KB_IN_REPORT_VAL; - }break; - case HOGPD_BOOT_KEYBOARD_OUTPUT_REPORT: - { - att_idx = HOGPD_IDX_BOOT_KB_OUT_REPORT_VAL; - }break; - case HOGPD_BOOT_MOUSE_INPUT_REPORT: - { - att_idx = HOGPD_IDX_BOOT_MOUSE_IN_REPORT_VAL; - }break; - default: /* Nothing to do */ break; - } + // check received status + if (param->status != GAP_ERR_NO_ERROR) { + status = param->status; + } + // perform operation sanity check + else if ((param->operation == hogpd_env->op.operation) && + (param->conidx == hogpd_env->op.conidx)) { + // retrieve attribute index. + uint8_t att_idx = 0; + switch (param->report.type) { + case HOGPD_REPORT: { + att_idx = HOGPD_IDX_REPORT_VAL; + } break; + case HOGPD_REPORT_MAP: { + att_idx = HOGPD_IDX_REPORT_MAP_VAL; + } break; + case HOGPD_BOOT_KEYBOARD_INPUT_REPORT: { + att_idx = HOGPD_IDX_BOOT_KB_IN_REPORT_VAL; + } break; + case HOGPD_BOOT_KEYBOARD_OUTPUT_REPORT: { + att_idx = HOGPD_IDX_BOOT_KB_OUT_REPORT_VAL; + } break; + case HOGPD_BOOT_MOUSE_INPUT_REPORT: { + att_idx = HOGPD_IDX_BOOT_MOUSE_IN_REPORT_VAL; + } break; + default: /* Nothing to do */ + break; + } - // retrieve handle - handle = hogpd_get_att_handle(hogpd_env, param->report.hid_idx, att_idx, param->report.idx); + // retrieve handle + handle = hogpd_get_att_handle(hogpd_env, param->report.hid_idx, att_idx, + param->report.idx); - // check if answer correspond to expected one - if(handle == hogpd_env->op.handle) - { - status = GAP_ERR_NO_ERROR; - } - } - - // read operation - if(hogpd_env->op.operation == HOGPD_OP_REPORT_READ) - { - uint16_t length = (status == GAP_ERR_NO_ERROR) ? param->report.length : 0; - //Send read response - struct gattc_read_cfm * rd_cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, - KE_BUILD_ID(TASK_GATTC, hogpd_env->op.conidx), dest_id, gattc_read_cfm, length); - rd_cfm->handle = hogpd_env->op.handle; - rd_cfm->status = status; - rd_cfm->length = length; - - if(status == GAP_ERR_NO_ERROR) - { - memcpy(rd_cfm->value, param->report.value, length); - } - - ke_msg_send(rd_cfm); - } - // write operation - else - { - //Send write response - struct gattc_write_cfm * wr_cfm = KE_MSG_ALLOC(GATTC_WRITE_CFM, - KE_BUILD_ID(TASK_GATTC, hogpd_env->op.conidx), dest_id, gattc_write_cfm); - wr_cfm->handle = hogpd_env->op.handle; - wr_cfm->status = status; - ke_msg_send(wr_cfm); - } - - // cleanup environment - hogpd_env->op.operation = HOGPD_OP_NO; - hogpd_env->op.handle = ATT_INVALID_HDL; - hogpd_env->op.conidx = 0xFF; - - // go back in idle state - ke_state_set(dest_id, state & ~HOGPD_OP_BUSY); + // check if answer correspond to expected one + if (handle == hogpd_env->op.handle) { + status = GAP_ERR_NO_ERROR; + } } - return (KE_MSG_CONSUMED); + // read operation + if (hogpd_env->op.operation == HOGPD_OP_REPORT_READ) { + uint16_t length = (status == GAP_ERR_NO_ERROR) ? param->report.length : 0; + // Send read response + struct gattc_read_cfm *rd_cfm = KE_MSG_ALLOC_DYN( + GATTC_READ_CFM, KE_BUILD_ID(TASK_GATTC, hogpd_env->op.conidx), + dest_id, gattc_read_cfm, length); + rd_cfm->handle = hogpd_env->op.handle; + rd_cfm->status = status; + rd_cfm->length = length; + + if (status == GAP_ERR_NO_ERROR) { + memcpy(rd_cfm->value, param->report.value, length); + } + + ke_msg_send(rd_cfm); + } + // write operation + else { + // Send write response + struct gattc_write_cfm *wr_cfm = KE_MSG_ALLOC( + GATTC_WRITE_CFM, KE_BUILD_ID(TASK_GATTC, hogpd_env->op.conidx), + dest_id, gattc_write_cfm); + wr_cfm->handle = hogpd_env->op.handle; + wr_cfm->status = status; + ke_msg_send(wr_cfm); + } + + // cleanup environment + hogpd_env->op.operation = HOGPD_OP_NO; + hogpd_env->op.handle = ATT_INVALID_HDL; + hogpd_env->op.conidx = 0xFF; + + // go back in idle state + ke_state_set(dest_id, state & ~HOGPD_OP_BUSY); + } + + return (KE_MSG_CONSUMED); } /** @@ -268,75 +246,69 @@ __STATIC int hogpd_report_cfm_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int hogpd_proto_mode_cfm_handler(ke_msg_id_t const msgid, - struct hogpd_proto_mode_cfm const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ +__STATIC int hogpd_proto_mode_cfm_handler( + ke_msg_id_t const msgid, struct hogpd_proto_mode_cfm const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { - uint8_t state = ke_state_get(dest_id); + uint8_t state = ke_state_get(dest_id); - // check that an operation is ongoing - if((state & HOGPD_OP_BUSY) == HOGPD_OP_BUSY) - { - uint16_t handle = ATT_INVALID_HANDLE; - uint8_t status = PRF_APP_ERROR; - struct hogpd_env_tag* hogpd_env = PRF_ENV_GET(HOGPD, hogpd); + // check that an operation is ongoing + if ((state & HOGPD_OP_BUSY) == HOGPD_OP_BUSY) { + uint16_t handle = ATT_INVALID_HANDLE; + uint8_t status = PRF_APP_ERROR; + struct hogpd_env_tag *hogpd_env = PRF_ENV_GET(HOGPD, hogpd); - // check received status - if(param->status != GAP_ERR_NO_ERROR) - { - status = param->status; - } - // perform operation sanity check - else if((hogpd_env->op.operation == HOGPD_OP_PROT_UPDATE) && (param->conidx == hogpd_env->op.conidx)) - { - // retrieve handle - handle = hogpd_get_att_handle(hogpd_env, param->hid_idx, HOGPD_IDX_PROTO_MODE_VAL, 0); + // check received status + if (param->status != GAP_ERR_NO_ERROR) { + status = param->status; + } + // perform operation sanity check + else if ((hogpd_env->op.operation == HOGPD_OP_PROT_UPDATE) && + (param->conidx == hogpd_env->op.conidx)) { + // retrieve handle + handle = hogpd_get_att_handle(hogpd_env, param->hid_idx, + HOGPD_IDX_PROTO_MODE_VAL, 0); - // check if answer correspond to expected one - if(handle == hogpd_env->op.handle) - { - status = GAP_ERR_NO_ERROR; - hogpd_env->svcs[param->hid_idx].proto_mode = param->proto_mode; - } - } - - // read operation/something failed - if(hogpd_env->op.operation == HOGPD_OP_REPORT_READ) - { - //Send read response - struct gattc_read_cfm * rd_cfm = KE_MSG_ALLOC(GATTC_READ_CFM, - KE_BUILD_ID(TASK_GATTC, hogpd_env->op.conidx), dest_id, gattc_read_cfm); - rd_cfm->handle = hogpd_env->op.handle; - rd_cfm->status = status; - ke_msg_send(rd_cfm); - } - // write operation - else - { - //Send write response - struct gattc_write_cfm * wr_cfm = KE_MSG_ALLOC(GATTC_WRITE_CFM, - KE_BUILD_ID(TASK_GATTC, hogpd_env->op.conidx), dest_id, gattc_write_cfm); - wr_cfm->handle = hogpd_env->op.handle; - wr_cfm->status = status; - ke_msg_send(wr_cfm); - } - - // cleanup environment - hogpd_env->op.operation = HOGPD_OP_NO; - hogpd_env->op.handle = ATT_INVALID_HDL; - hogpd_env->op.conidx = 0xFF; - - // go back in idle state - ke_state_set(dest_id, state & ~HOGPD_OP_BUSY); + // check if answer correspond to expected one + if (handle == hogpd_env->op.handle) { + status = GAP_ERR_NO_ERROR; + hogpd_env->svcs[param->hid_idx].proto_mode = param->proto_mode; + } } - return (KE_MSG_CONSUMED); + // read operation/something failed + if (hogpd_env->op.operation == HOGPD_OP_REPORT_READ) { + // Send read response + struct gattc_read_cfm *rd_cfm = KE_MSG_ALLOC( + GATTC_READ_CFM, KE_BUILD_ID(TASK_GATTC, hogpd_env->op.conidx), + dest_id, gattc_read_cfm); + rd_cfm->handle = hogpd_env->op.handle; + rd_cfm->status = status; + ke_msg_send(rd_cfm); + } + // write operation + else { + // Send write response + struct gattc_write_cfm *wr_cfm = KE_MSG_ALLOC( + GATTC_WRITE_CFM, KE_BUILD_ID(TASK_GATTC, hogpd_env->op.conidx), + dest_id, gattc_write_cfm); + wr_cfm->handle = hogpd_env->op.handle; + wr_cfm->status = status; + ke_msg_send(wr_cfm); + } + + // cleanup environment + hogpd_env->op.operation = HOGPD_OP_NO; + hogpd_env->op.handle = ATT_INVALID_HDL; + hogpd_env->op.conidx = 0xFF; + + // go back in idle state + ke_state_set(dest_id, state & ~HOGPD_OP_BUSY); + } + + return (KE_MSG_CONSUMED); } - - /** **************************************************************************************** * @brief Handles reception of the @ref GATTC_ATT_INFO_REQ_IND message. @@ -347,59 +319,51 @@ __STATIC int hogpd_proto_mode_cfm_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_att_info_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t hid_idx, att_idx, report_idx; - struct gattc_att_info_cfm * cfm; - struct hogpd_env_tag* hogpd_env = PRF_ENV_GET(HOGPD, hogpd); - // retrieve attribute requested - uint8_t status = hogpd_get_att_idx(hogpd_env, param->handle, &hid_idx, &att_idx, &report_idx); +__STATIC int gattc_att_info_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_att_info_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + uint8_t hid_idx, att_idx, report_idx; + struct gattc_att_info_cfm *cfm; + struct hogpd_env_tag *hogpd_env = PRF_ENV_GET(HOGPD, hogpd); + // retrieve attribute requested + uint8_t status = hogpd_get_att_idx(hogpd_env, param->handle, &hid_idx, + &att_idx, &report_idx); - //Send write response - cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); - cfm->handle = param->handle; + // Send write response + cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); + cfm->handle = param->handle; - if(status == GAP_ERR_NO_ERROR) - { - // check which attribute is requested by peer device - switch(att_idx) - { - case HOGPD_IDX_BOOT_KB_IN_REPORT_VAL: - case HOGPD_IDX_BOOT_KB_OUT_REPORT_VAL: - case HOGPD_IDX_BOOT_MOUSE_IN_REPORT_VAL: - case HOGPD_IDX_REPORT_VAL: - { - cfm->length = 0; - }break; + if (status == GAP_ERR_NO_ERROR) { + // check which attribute is requested by peer device + switch (att_idx) { + case HOGPD_IDX_BOOT_KB_IN_REPORT_VAL: + case HOGPD_IDX_BOOT_KB_OUT_REPORT_VAL: + case HOGPD_IDX_BOOT_MOUSE_IN_REPORT_VAL: + case HOGPD_IDX_REPORT_VAL: { + cfm->length = 0; + } break; - // Notification configuration - case HOGPD_IDX_BOOT_KB_IN_REPORT_NTF_CFG: - case HOGPD_IDX_BOOT_MOUSE_IN_REPORT_NTF_CFG: - case HOGPD_IDX_REPORT_NTF_CFG: - { - cfm->length = 2; - }break; + // Notification configuration + case HOGPD_IDX_BOOT_KB_IN_REPORT_NTF_CFG: + case HOGPD_IDX_BOOT_MOUSE_IN_REPORT_NTF_CFG: + case HOGPD_IDX_REPORT_NTF_CFG: { + cfm->length = 2; + } break; - default: - { - cfm->length = 0; - status = ATT_ERR_WRITE_NOT_PERMITTED; - } break; - } + default: { + cfm->length = 0; + status = ATT_ERR_WRITE_NOT_PERMITTED; + } break; } + } - cfm->status = status; + cfm->status = status; - ke_msg_send(cfm); + ke_msg_send(cfm); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } - - /** **************************************************************************************** * @brief Handles reception of the @ref GATTC_WRITE_REQ_IND message. @@ -410,162 +374,145 @@ __STATIC int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_write_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - int msg_status = KE_MSG_CONSUMED; - uint8_t state = ke_state_get(dest_id); +__STATIC int gattc_write_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + int msg_status = KE_MSG_CONSUMED; + uint8_t state = ke_state_get(dest_id); - // check that task is in idle state - if((state & HOGPD_OP_BUSY) == HOGPD_IDLE) - { - uint8_t hid_idx, att_idx, report_idx; + // check that task is in idle state + if ((state & HOGPD_OP_BUSY) == HOGPD_IDLE) { + uint8_t hid_idx, att_idx, report_idx; - // used to know if gatt_write confirmation should be sent immediately - uint8_t conidx = KE_IDX_GET(src_id); + // used to know if gatt_write confirmation should be sent immediately + uint8_t conidx = KE_IDX_GET(src_id); - struct hogpd_env_tag* hogpd_env = PRF_ENV_GET(HOGPD, hogpd); - // retrieve attribute requested - uint8_t status = hogpd_get_att_idx(hogpd_env, param->handle, &hid_idx, &att_idx, &report_idx); + struct hogpd_env_tag *hogpd_env = PRF_ENV_GET(HOGPD, hogpd); + // retrieve attribute requested + uint8_t status = hogpd_get_att_idx(hogpd_env, param->handle, &hid_idx, + &att_idx, &report_idx); + // prepare operation info + hogpd_env->op.conidx = conidx; + hogpd_env->op.operation = HOGPD_OP_NO; + hogpd_env->op.handle = param->handle; - // prepare operation info - hogpd_env->op.conidx = conidx; - hogpd_env->op.operation = HOGPD_OP_NO; - hogpd_env->op.handle = param->handle; + if (status == GAP_ERR_NO_ERROR) { - if(status == GAP_ERR_NO_ERROR) - { + // check which attribute is requested by peer device + switch (att_idx) { + // Control point value updated + case HOGPD_IDX_HID_CTNL_PT_VAL: { + // send control point indication + struct hogpd_ctnl_pt_ind *cp_ind = KE_MSG_ALLOC( + HOGPD_CTNL_PT_IND, prf_dst_task_get(&(hogpd_env->prf_env), conidx), + dest_id, hogpd_ctnl_pt_ind); + cp_ind->conidx = conidx; + cp_ind->hid_idx = hid_idx; + cp_ind->hid_ctnl_pt = param->value[0]; + ke_msg_send(cp_ind); + } break; - // check which attribute is requested by peer device - switch(att_idx) - { - // Control point value updated - case HOGPD_IDX_HID_CTNL_PT_VAL: - { - // send control point indication - struct hogpd_ctnl_pt_ind *cp_ind = KE_MSG_ALLOC(HOGPD_CTNL_PT_IND, - prf_dst_task_get(&(hogpd_env->prf_env), conidx), dest_id, - hogpd_ctnl_pt_ind); - cp_ind->conidx = conidx; - cp_ind->hid_idx = hid_idx; - cp_ind->hid_ctnl_pt = param->value[0]; - ke_msg_send(cp_ind); - }break; + // Modification of protocol mode requested + case HOGPD_IDX_PROTO_MODE_VAL: { + // send control point indication + struct hogpd_proto_mode_req_ind *prot_ind = + KE_MSG_ALLOC(HOGPD_PROTO_MODE_REQ_IND, + prf_dst_task_get(&(hogpd_env->prf_env), conidx), + dest_id, hogpd_proto_mode_req_ind); + prot_ind->conidx = conidx; + prot_ind->operation = HOGPD_OP_PROT_UPDATE; + prot_ind->hid_idx = hid_idx; + prot_ind->proto_mode = param->value[0]; + ke_msg_send(prot_ind); - // Modification of protocol mode requested - case HOGPD_IDX_PROTO_MODE_VAL: - { - // send control point indication - struct hogpd_proto_mode_req_ind *prot_ind = KE_MSG_ALLOC(HOGPD_PROTO_MODE_REQ_IND, - prf_dst_task_get(&(hogpd_env->prf_env), conidx), dest_id, - hogpd_proto_mode_req_ind); - prot_ind->conidx = conidx; - prot_ind->operation = HOGPD_OP_PROT_UPDATE; - prot_ind->hid_idx = hid_idx; - prot_ind->proto_mode = param->value[0]; - ke_msg_send(prot_ind); + hogpd_env->op.operation = HOGPD_OP_PROT_UPDATE; + } break; - hogpd_env->op.operation = HOGPD_OP_PROT_UPDATE; - }break; + // Modification of report value requested + case HOGPD_IDX_BOOT_KB_IN_REPORT_VAL: + case HOGPD_IDX_BOOT_KB_OUT_REPORT_VAL: + case HOGPD_IDX_BOOT_MOUSE_IN_REPORT_VAL: + case HOGPD_IDX_REPORT_VAL: { + // send report indication + struct hogpd_report_req_ind *report_ind = + KE_MSG_ALLOC_DYN(HOGPD_REPORT_REQ_IND, + prf_dst_task_get(&(hogpd_env->prf_env), conidx), + dest_id, hogpd_report_req_ind, param->length); - // Modification of report value requested - case HOGPD_IDX_BOOT_KB_IN_REPORT_VAL: - case HOGPD_IDX_BOOT_KB_OUT_REPORT_VAL: - case HOGPD_IDX_BOOT_MOUSE_IN_REPORT_VAL: - case HOGPD_IDX_REPORT_VAL: - { - // send report indication - struct hogpd_report_req_ind *report_ind = KE_MSG_ALLOC_DYN(HOGPD_REPORT_REQ_IND, - prf_dst_task_get(&(hogpd_env->prf_env), conidx), dest_id, - hogpd_report_req_ind, param->length); + report_ind->conidx = conidx; + report_ind->operation = HOGPD_OP_REPORT_WRITE; + report_ind->report.length = param->length; + report_ind->report.hid_idx = hid_idx; + report_ind->report.idx = report_idx; - report_ind->conidx = conidx; - report_ind->operation = HOGPD_OP_REPORT_WRITE; - report_ind->report.length = param->length; - report_ind->report.hid_idx = hid_idx; - report_ind->report.idx = report_idx; + memcpy(report_ind->report.value, param->value, param->length); - memcpy(report_ind->report.value, param->value, param->length); + // retrieve report type + switch (att_idx) { + // An Input Report + case HOGPD_IDX_BOOT_KB_IN_REPORT_VAL: { + report_ind->report.type = HOGPD_BOOT_KEYBOARD_INPUT_REPORT; + } break; + // Boot Keyboard input report + case HOGPD_IDX_BOOT_KB_OUT_REPORT_VAL: { + report_ind->report.type = HOGPD_BOOT_KEYBOARD_OUTPUT_REPORT; + } break; + // Boot Mouse input report + case HOGPD_IDX_BOOT_MOUSE_IN_REPORT_VAL: { + report_ind->report.type = HOGPD_BOOT_MOUSE_INPUT_REPORT; + } break; + // Normal report + case HOGPD_IDX_REPORT_VAL: { + report_ind->report.type = HOGPD_REPORT; + } break; - // retrieve report type - switch(att_idx) - { - // An Input Report - case HOGPD_IDX_BOOT_KB_IN_REPORT_VAL: - { - report_ind->report.type = HOGPD_BOOT_KEYBOARD_INPUT_REPORT; - }break; - // Boot Keyboard input report - case HOGPD_IDX_BOOT_KB_OUT_REPORT_VAL: - { - report_ind->report.type = HOGPD_BOOT_KEYBOARD_OUTPUT_REPORT; - }break; - // Boot Mouse input report - case HOGPD_IDX_BOOT_MOUSE_IN_REPORT_VAL: - { - report_ind->report.type = HOGPD_BOOT_MOUSE_INPUT_REPORT; - }break; - // Normal report - case HOGPD_IDX_REPORT_VAL: - { - report_ind->report.type = HOGPD_REPORT; - }break; - - default: - { - ASSERT_ERR(0); - }break; - } - - ke_msg_send(report_ind); - - hogpd_env->op.operation = HOGPD_OP_REPORT_WRITE; - }break; - - // Notification configuration update - case HOGPD_IDX_BOOT_KB_IN_REPORT_NTF_CFG: - case HOGPD_IDX_BOOT_MOUSE_IN_REPORT_NTF_CFG: - case HOGPD_IDX_REPORT_NTF_CFG: - { - uint16_t ntf_cfg = co_read16p(param->value); - status = hogpd_ntf_cfg_ind_send(conidx, hid_idx, att_idx, report_idx, ntf_cfg); - }break; - - default: - { - status = PRF_APP_ERROR; - } break; - } + default: { + ASSERT_ERR(0); + } break; } - // check if peer operation is over - if(hogpd_env->op.operation == HOGPD_OP_NO) - { - //Send write response - struct gattc_write_cfm * cfm = KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = status; - ke_msg_send(cfm); - } - else - { - // go into operation busy state - ke_state_set(dest_id, state | HOGPD_OP_BUSY); - } - } - // else process it later - else - { - msg_status = KE_MSG_SAVED; + ke_msg_send(report_ind); + + hogpd_env->op.operation = HOGPD_OP_REPORT_WRITE; + } break; + + // Notification configuration update + case HOGPD_IDX_BOOT_KB_IN_REPORT_NTF_CFG: + case HOGPD_IDX_BOOT_MOUSE_IN_REPORT_NTF_CFG: + case HOGPD_IDX_REPORT_NTF_CFG: { + uint16_t ntf_cfg = co_read16p(param->value); + status = hogpd_ntf_cfg_ind_send(conidx, hid_idx, att_idx, report_idx, + ntf_cfg); + } break; + + default: { + status = PRF_APP_ERROR; + } break; + } } - return (msg_status); + // check if peer operation is over + if (hogpd_env->op.operation == HOGPD_OP_NO) { + // Send write response + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = status; + ke_msg_send(cfm); + } else { + // go into operation busy state + ke_state_set(dest_id, state | HOGPD_OP_BUSY); + } + } + // else process it later + else { + msg_status = KE_MSG_SAVED; + } + + return (msg_status); } - /** **************************************************************************************** * @brief Handles reception of the @ref GATTC_READ_REQ_IND message. @@ -577,146 +524,136 @@ __STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_read_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - int msg_status = KE_MSG_CONSUMED; - uint8_t state = ke_state_get(dest_id); + struct gattc_read_req_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + int msg_status = KE_MSG_CONSUMED; + uint8_t state = ke_state_get(dest_id); - // check that task is in idle state - if((state & HOGPD_OP_BUSY) == HOGPD_IDLE) - { - uint8_t hid_idx, att_idx, report_idx; - bool finished = true; - uint8_t report_type = 0; - uint16_t value = 0; - uint16_t length = 0; + // check that task is in idle state + if ((state & HOGPD_OP_BUSY) == HOGPD_IDLE) { + uint8_t hid_idx, att_idx, report_idx; + bool finished = true; + uint8_t report_type = 0; + uint16_t value = 0; + uint16_t length = 0; - struct hogpd_env_tag* hogpd_env = PRF_ENV_GET(HOGPD, hogpd); + struct hogpd_env_tag *hogpd_env = PRF_ENV_GET(HOGPD, hogpd); - // used to know if gatt_write confirmation should be sent immediately - uint8_t conidx = KE_IDX_GET(src_id); + // used to know if gatt_write confirmation should be sent immediately + uint8_t conidx = KE_IDX_GET(src_id); - // retrieve attribute requested - uint8_t status = hogpd_get_att_idx(hogpd_env, param->handle, &hid_idx, &att_idx, &report_idx); + // retrieve attribute requested + uint8_t status = hogpd_get_att_idx(hogpd_env, param->handle, &hid_idx, + &att_idx, &report_idx); - if(status == GAP_ERR_NO_ERROR) - { - // check which attribute is requested by peer device - switch(att_idx) - { - // ------------ READ report value requested - case HOGPD_IDX_BOOT_KB_IN_REPORT_VAL: - { - report_type = HOGPD_BOOT_KEYBOARD_INPUT_REPORT; - finished = false; - }break; - case HOGPD_IDX_BOOT_KB_OUT_REPORT_VAL: - { - report_type = HOGPD_BOOT_KEYBOARD_OUTPUT_REPORT; - finished = false; - }break; - case HOGPD_IDX_BOOT_MOUSE_IN_REPORT_VAL: - { - report_type = HOGPD_BOOT_MOUSE_INPUT_REPORT; - finished = false; - }break; - case HOGPD_IDX_REPORT_VAL: - { - report_type = HOGPD_REPORT; - finished = false; - }break; - case HOGPD_IDX_REPORT_MAP_VAL: - { - report_type = HOGPD_REPORT_MAP; - finished = false; - }break; + if (status == GAP_ERR_NO_ERROR) { + // check which attribute is requested by peer device + switch (att_idx) { + // ------------ READ report value requested + case HOGPD_IDX_BOOT_KB_IN_REPORT_VAL: { + report_type = HOGPD_BOOT_KEYBOARD_INPUT_REPORT; + finished = false; + } break; + case HOGPD_IDX_BOOT_KB_OUT_REPORT_VAL: { + report_type = HOGPD_BOOT_KEYBOARD_OUTPUT_REPORT; + finished = false; + } break; + case HOGPD_IDX_BOOT_MOUSE_IN_REPORT_VAL: { + report_type = HOGPD_BOOT_MOUSE_INPUT_REPORT; + finished = false; + } break; + case HOGPD_IDX_REPORT_VAL: { + report_type = HOGPD_REPORT; + finished = false; + } break; + case HOGPD_IDX_REPORT_MAP_VAL: { + report_type = HOGPD_REPORT_MAP; + finished = false; + } break; - // ------------ READ active protocol mode - case HOGPD_IDX_PROTO_MODE_VAL: - { - value = hogpd_env->svcs[hid_idx].proto_mode; - length = sizeof(uint8_t); - }break; + // ------------ READ active protocol mode + case HOGPD_IDX_PROTO_MODE_VAL: { + value = hogpd_env->svcs[hid_idx].proto_mode; + length = sizeof(uint8_t); + } break; - // ------------ READ Notification configuration - case HOGPD_IDX_BOOT_KB_IN_REPORT_NTF_CFG: - { - value = ((hogpd_env->svcs[hid_idx].ntf_cfg[conidx] & HOGPD_CFG_KEYBOARD) != 0) - ? PRF_CLI_START_NTF : PRF_CLI_STOP_NTFIND; + // ------------ READ Notification configuration + case HOGPD_IDX_BOOT_KB_IN_REPORT_NTF_CFG: { + value = ((hogpd_env->svcs[hid_idx].ntf_cfg[conidx] & + HOGPD_CFG_KEYBOARD) != 0) + ? PRF_CLI_START_NTF + : PRF_CLI_STOP_NTFIND; - length = sizeof(uint16_t); - }break; - case HOGPD_IDX_BOOT_MOUSE_IN_REPORT_NTF_CFG: - { - value = ((hogpd_env->svcs[hid_idx].ntf_cfg[conidx] & HOGPD_CFG_MOUSE) != 0) - ? PRF_CLI_START_NTF : PRF_CLI_STOP_NTFIND; - length = sizeof(uint16_t); - }break; - case HOGPD_IDX_REPORT_NTF_CFG: - { - value = ((hogpd_env->svcs[hid_idx].ntf_cfg[conidx] & (HOGPD_CFG_REPORT_NTF_EN << report_idx)) != 0) - ? PRF_CLI_START_NTF : PRF_CLI_STOP_NTFIND; - length = sizeof(uint16_t); - }break; + length = sizeof(uint16_t); + } break; + case HOGPD_IDX_BOOT_MOUSE_IN_REPORT_NTF_CFG: { + value = + ((hogpd_env->svcs[hid_idx].ntf_cfg[conidx] & HOGPD_CFG_MOUSE) != 0) + ? PRF_CLI_START_NTF + : PRF_CLI_STOP_NTFIND; + length = sizeof(uint16_t); + } break; + case HOGPD_IDX_REPORT_NTF_CFG: { + value = ((hogpd_env->svcs[hid_idx].ntf_cfg[conidx] & + (HOGPD_CFG_REPORT_NTF_EN << report_idx)) != 0) + ? PRF_CLI_START_NTF + : PRF_CLI_STOP_NTFIND; + length = sizeof(uint16_t); + } break; - default: - { - status = PRF_APP_ERROR; - } break; - } - } - - // check if peer operation is over - if(finished) - { - //Send write response - struct gattc_read_cfm * cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, length); - cfm->handle = param->handle; - cfm->status = status; - cfm->length = length; - memcpy(cfm->value, &value, length); - ke_msg_send(cfm); - } - else - { - // send report indication - struct hogpd_report_req_ind *report_ind = KE_MSG_ALLOC(HOGPD_REPORT_REQ_IND, - prf_dst_task_get(&(hogpd_env->prf_env), conidx), dest_id, - hogpd_report_req_ind); - - report_ind->conidx = conidx; - report_ind->operation = HOGPD_OP_REPORT_READ; - report_ind->report.length = 0; - report_ind->report.hid_idx = hid_idx; - report_ind->report.type = report_type; - report_ind->report.idx = report_idx; - - ke_msg_send(report_ind); - - hogpd_env->op.conidx = conidx; - hogpd_env->op.operation = HOGPD_OP_REPORT_READ; - hogpd_env->op.handle = param->handle; - - // go into operation busy state - ke_state_set(dest_id, state | HOGPD_OP_BUSY); - } - } - // else process it later - else - { - msg_status = KE_MSG_SAVED; + default: { + status = PRF_APP_ERROR; + } break; + } } - return (msg_status); + // check if peer operation is over + if (finished) { + // Send write response + struct gattc_read_cfm *cfm = KE_MSG_ALLOC_DYN( + GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, length); + cfm->handle = param->handle; + cfm->status = status; + cfm->length = length; + memcpy(cfm->value, &value, length); + ke_msg_send(cfm); + } else { + // send report indication + struct hogpd_report_req_ind *report_ind = KE_MSG_ALLOC( + HOGPD_REPORT_REQ_IND, prf_dst_task_get(&(hogpd_env->prf_env), conidx), + dest_id, hogpd_report_req_ind); + + report_ind->conidx = conidx; + report_ind->operation = HOGPD_OP_REPORT_READ; + report_ind->report.length = 0; + report_ind->report.hid_idx = hid_idx; + report_ind->report.type = report_type; + report_ind->report.idx = report_idx; + + ke_msg_send(report_ind); + + hogpd_env->op.conidx = conidx; + hogpd_env->op.operation = HOGPD_OP_REPORT_READ; + hogpd_env->op.handle = param->handle; + + // go into operation busy state + ke_state_set(dest_id, state | HOGPD_OP_BUSY); + } + } + // else process it later + else { + msg_status = KE_MSG_SAVED; + } + + return (msg_status); } - /** **************************************************************************************** - * @brief Handles @ref GATT_NOTIFY_CMP_EVT message meaning that Report notification - * has been correctly sent to peer device (but not confirmed by peer device). + * @brief Handles @ref GATT_NOTIFY_CMP_EVT message meaning that Report + *notification has been correctly sent to peer device (but not confirmed by peer + *device). * * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. @@ -725,27 +662,27 @@ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - if(param->operation == GATTC_NOTIFY) - { - uint8_t conidx = KE_IDX_GET(src_id); - struct hogpd_env_tag* hogpd_env = PRF_ENV_GET(HOGPD, hogpd); +__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + if (param->operation == GATTC_NOTIFY) { + uint8_t conidx = KE_IDX_GET(src_id); + struct hogpd_env_tag *hogpd_env = PRF_ENV_GET(HOGPD, hogpd); - // send report update response - struct hogpd_report_upd_rsp *rsp = KE_MSG_ALLOC(HOGPD_REPORT_UPD_RSP, - prf_dst_task_get(&(hogpd_env->prf_env), conidx), - dest_id, hogpd_report_upd_rsp); - rsp->conidx = conidx; - rsp->status = param->status; - ke_msg_send(rsp); + // send report update response + struct hogpd_report_upd_rsp *rsp = KE_MSG_ALLOC( + HOGPD_REPORT_UPD_RSP, prf_dst_task_get(&(hogpd_env->prf_env), conidx), + dest_id, hogpd_report_upd_rsp); + rsp->conidx = conidx; + rsp->status = param->status; + ke_msg_send(rsp); - // go back in to idle mode - ke_state_set(dest_id, ke_state_get(dest_id) & ~HOGPD_REQ_BUSY); - } // else ignore the message + // go back in to idle mode + ke_state_set(dest_id, ke_state_get(dest_id) & ~HOGPD_REQ_BUSY); + } // else ignore the message - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /* @@ -753,30 +690,27 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_ev **************************************************************************************** */ - /// Default State handlers definition -KE_MSG_HANDLER_TAB(hogpd) -{ - { HOGPD_ENABLE_REQ, (ke_msg_func_t) hogpd_enable_req_handler }, - { HOGPD_REPORT_UPD_REQ, (ke_msg_func_t) hogpd_report_upd_req_handler }, - { HOGPD_REPORT_CFM, (ke_msg_func_t) hogpd_report_cfm_handler }, - { HOGPD_PROTO_MODE_CFM, (ke_msg_func_t) hogpd_proto_mode_cfm_handler }, +KE_MSG_HANDLER_TAB(hogpd){ + {HOGPD_ENABLE_REQ, (ke_msg_func_t)hogpd_enable_req_handler}, + {HOGPD_REPORT_UPD_REQ, (ke_msg_func_t)hogpd_report_upd_req_handler}, + {HOGPD_REPORT_CFM, (ke_msg_func_t)hogpd_report_cfm_handler}, + {HOGPD_PROTO_MODE_CFM, (ke_msg_func_t)hogpd_proto_mode_cfm_handler}, - { GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t) gattc_att_info_req_ind_handler }, - { GATTC_WRITE_REQ_IND, (ke_msg_func_t) gattc_write_req_ind_handler }, - { GATTC_READ_REQ_IND, (ke_msg_func_t) gattc_read_req_ind_handler }, - { GATTC_CMP_EVT, (ke_msg_func_t) gattc_cmp_evt_handler }, + {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t)gattc_att_info_req_ind_handler}, + {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, + {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void hogpd_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct hogpd_env_tag *hogpd_env = PRF_ENV_GET(HOGPD, hogpd); +void hogpd_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct hogpd_env_tag *hogpd_env = PRF_ENV_GET(HOGPD, hogpd); - task_desc->msg_handler_tab = hogpd_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(hogpd_msg_handler_tab); - task_desc->state = hogpd_env->state; - task_desc->idx_max = HOGPD_IDX_MAX; + task_desc->msg_handler_tab = hogpd_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(hogpd_msg_handler_tab); + task_desc->state = hogpd_env->state; + task_desc->idx_max = HOGPD_IDX_MAX; } #endif /* #if (BLE_HID_DEVICE) */ diff --git a/services/ble_profiles/hogp/hogprh/src/hogprh.c b/services/ble_profiles/hogp/hogprh/src/hogprh.c index 1b8cafe..7a4ed18 100644 --- a/services/ble_profiles/hogp/hogprh/src/hogprh.c +++ b/services/ble_profiles/hogp/hogprh/src/hogprh.c @@ -14,10 +14,10 @@ #if (BLE_HID_REPORT_HOST) -#include "hogprh.h" -#include "hogprh_task.h" #include "co_math.h" #include "gap.h" +#include "hogprh.h" +#include "hogprh_task.h" #include "ke_mem.h" @@ -33,74 +33,73 @@ * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t hogprh_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t idx; - //-------------------- allocate memory required for the profile --------------------- +static uint8_t hogprh_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t idx; + //-------------------- allocate memory required for the profile + //--------------------- - struct hogprh_env_tag* hogprh_env = - (struct hogprh_env_tag* ) ke_malloc(sizeof(struct hogprh_env_tag), KE_MEM_ATT_DB); + struct hogprh_env_tag *hogprh_env = (struct hogprh_env_tag *)ke_malloc( + sizeof(struct hogprh_env_tag), KE_MEM_ATT_DB); - // allocate HOGPRH required environment variable - env->env = (prf_env_t*) hogprh_env; + // allocate HOGPRH required environment variable + env->env = (prf_env_t *)hogprh_env; - hogprh_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - hogprh_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + hogprh_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + hogprh_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_HOGPRH; - hogprh_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_HOGPRH; + hogprh_task_init(&(env->desc)); - for(idx = 0; idx < HOGPRH_IDX_MAX ; idx++) - { - hogprh_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), HOGPRH_FREE); - } + for (idx = 0; idx < HOGPRH_IDX_MAX; idx++) { + hogprh_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), HOGPRH_FREE); + } - - return GAP_ERR_NO_ERROR; + return GAP_ERR_NO_ERROR; } /** **************************************************************************************** * @brief Destruction of the HOGPRH module - due to a reset for instance. - * This function clean-up allocated memory (attribute datahide is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute datahide is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void hogprh_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct hogprh_env_tag* hogprh_env = (struct hogprh_env_tag*) env->env; +static void hogprh_destroy(struct prf_task_env *env) { + uint8_t idx; + struct hogprh_env_tag *hogprh_env = (struct hogprh_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < HOGPRH_IDX_MAX ; idx++) - { - if(hogprh_env->env[idx] != NULL) - { - if(hogprh_env->env[idx]->operation != NULL) - { - ke_free(hogprh_env->env[idx]->operation); - } - ke_free(hogprh_env->env[idx]); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < HOGPRH_IDX_MAX; idx++) { + if (hogprh_env->env[idx] != NULL) { + if (hogprh_env->env[idx]->operation != NULL) { + ke_free(hogprh_env->env[idx]->operation); + } + ke_free(hogprh_env->env[idx]); } + } - // free profile environment variables - env->env = NULL; - ke_free(hogprh_env); + // free profile environment variables + env->env = NULL; + ke_free(hogprh_env); } /** @@ -111,10 +110,9 @@ static void hogprh_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void hogprh_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Put HID Client in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), HOGPRH_IDLE); +static void hogprh_create(struct prf_task_env *env, uint8_t conidx) { + /* Put HID Client in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), HOGPRH_IDLE); } /** @@ -126,23 +124,21 @@ static void hogprh_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void hogprh_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct hogprh_env_tag* hogprh_env = (struct hogprh_env_tag*) env->env; +static void hogprh_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct hogprh_env_tag *hogprh_env = (struct hogprh_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(hogprh_env->env[conidx] != NULL) - { - if(hogprh_env->env[conidx]->operation != NULL) - { - ke_free(hogprh_env->env[conidx]->operation); - } - ke_free(hogprh_env->env[conidx]); - hogprh_env->env[conidx] = NULL; + // clean-up environment variable allocated for task instance + if (hogprh_env->env[conidx] != NULL) { + if (hogprh_env->env[conidx]->operation != NULL) { + ke_free(hogprh_env->env[conidx]->operation); } + ke_free(hogprh_env->env[conidx]); + hogprh_env->env[conidx] = NULL; + } - /* Put HID Client in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), HOGPRH_FREE); + /* Put HID Client in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), HOGPRH_FREE); } /* @@ -151,51 +147,46 @@ static void hogprh_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t rea */ /// HOGPRH Task interface required by profile manager -const struct prf_task_cbs hogprh_itf = -{ - hogprh_init, - hogprh_destroy, - hogprh_create, - hogprh_cleanup, +const struct prf_task_cbs hogprh_itf = { + hogprh_init, + hogprh_destroy, + hogprh_create, + hogprh_cleanup, }; - /* * GLOBAL FUNCTIONS DEFINITIONS **************************************************************************************** */ -const struct prf_task_cbs* hogprh_prf_itf_get(void) -{ - return &hogprh_itf; -} +const struct prf_task_cbs *hogprh_prf_itf_get(void) { return &hogprh_itf; } -void hogprh_enable_rsp_send(struct hogprh_env_tag *hogprh_env, uint8_t conidx, uint8_t status) -{ - // Counter - uint8_t svc_inst; +void hogprh_enable_rsp_send(struct hogprh_env_tag *hogprh_env, uint8_t conidx, + uint8_t status) { + // Counter + uint8_t svc_inst; - // Send APP the details of the discovered attributes on HOGPRH - struct hogprh_enable_rsp * rsp = KE_MSG_ALLOC(HOGPRH_ENABLE_RSP, - prf_dst_task_get(&(hogprh_env->prf_env) ,conidx), - prf_src_task_get(&(hogprh_env->prf_env) ,conidx), - hogprh_enable_rsp); - rsp->status = status; - rsp->hids_nb = 0; - if (status == GAP_ERR_NO_ERROR) - { - rsp->hids_nb = hogprh_env->env[conidx]->hids_nb; + // Send APP the details of the discovered attributes on HOGPRH + struct hogprh_enable_rsp *rsp = KE_MSG_ALLOC( + HOGPRH_ENABLE_RSP, prf_dst_task_get(&(hogprh_env->prf_env), conidx), + prf_src_task_get(&(hogprh_env->prf_env), conidx), hogprh_enable_rsp); + rsp->status = status; + rsp->hids_nb = 0; + if (status == GAP_ERR_NO_ERROR) { + rsp->hids_nb = hogprh_env->env[conidx]->hids_nb; - for (svc_inst = 0; svc_inst < co_min(hogprh_env->env[conidx]->hids_nb, HOGPRH_NB_HIDS_INST_MAX) ; svc_inst++) - { - rsp->hids[svc_inst] = hogprh_env->env[conidx]->hids[svc_inst]; + for (svc_inst = 0; svc_inst < co_min(hogprh_env->env[conidx]->hids_nb, + HOGPRH_NB_HIDS_INST_MAX); + svc_inst++) { + rsp->hids[svc_inst] = hogprh_env->env[conidx]->hids[svc_inst]; - // Register HOGPRH task in gatt for indication/notifications - prf_register_atthdl2gatt(&(hogprh_env->prf_env), conidx, &hogprh_env->env[conidx]->hids[svc_inst].svc); - } + // Register HOGPRH task in gatt for indication/notifications + prf_register_atthdl2gatt(&(hogprh_env->prf_env), conidx, + &hogprh_env->env[conidx]->hids[svc_inst].svc); } + } - ke_msg_send(rsp); + ke_msg_send(rsp); } #endif /* (BLE_HID_REPORT_HOST) */ diff --git a/services/ble_profiles/hogp/hogprh/src/hogprh_task.c b/services/ble_profiles/hogp/hogprh/src/hogprh_task.c index a4f67e7..7bd364f 100644 --- a/services/ble_profiles/hogp/hogprh/src/hogprh_task.c +++ b/services/ble_profiles/hogp/hogprh/src/hogprh_task.c @@ -14,17 +14,17 @@ #if (BLE_HID_REPORT_HOST) -#include "gap.h" #include "attm.h" -#include "hogprh_task.h" -#include "hogprh.h" -#include "gattc_task.h" +#include "gap.h" #include "gattc.h" +#include "gattc_task.h" #include "hogp_common.h" +#include "hogprh.h" +#include "hogprh_task.h" -#include "ke_mem.h" -#include "co_utils.h" #include "co_math.h" +#include "co_utils.h" +#include "ke_mem.h" /* * LOCAL VARIABLES DEFINITION @@ -32,18 +32,22 @@ */ /// State machine used to retrieve HID Service characteristics information -const struct prf_char_def hogprh_hids_char[HOGPRH_CHAR_REPORT + 1] = -{ +const struct prf_char_def hogprh_hids_char[HOGPRH_CHAR_REPORT + 1] = { /// Report Map - [HOGPRH_CHAR_REPORT_MAP] = {ATT_CHAR_REPORT_MAP, ATT_MANDATORY, ATT_CHAR_PROP_RD}, + [HOGPRH_CHAR_REPORT_MAP] = {ATT_CHAR_REPORT_MAP, ATT_MANDATORY, + ATT_CHAR_PROP_RD}, /// HID Information - [HOGPRH_CHAR_HID_INFO] = {ATT_CHAR_HID_INFO, ATT_MANDATORY, ATT_CHAR_PROP_RD}, + [HOGPRH_CHAR_HID_INFO] = {ATT_CHAR_HID_INFO, ATT_MANDATORY, + ATT_CHAR_PROP_RD}, /// HID Control Point - [HOGPRH_CHAR_HID_CTNL_PT] = {ATT_CHAR_HID_CTNL_PT, ATT_MANDATORY, ATT_CHAR_PROP_WR_NO_RESP}, + [HOGPRH_CHAR_HID_CTNL_PT] = {ATT_CHAR_HID_CTNL_PT, ATT_MANDATORY, + ATT_CHAR_PROP_WR_NO_RESP}, /// Protocol Mode - [HOGPRH_CHAR_PROTOCOL_MODE] = {ATT_CHAR_PROTOCOL_MODE, ATT_OPTIONAL, (ATT_CHAR_PROP_RD | ATT_CHAR_PROP_WR_NO_RESP)}, + [HOGPRH_CHAR_PROTOCOL_MODE] = {ATT_CHAR_PROTOCOL_MODE, ATT_OPTIONAL, + (ATT_CHAR_PROP_RD | + ATT_CHAR_PROP_WR_NO_RESP)}, /// Report - [HOGPRH_CHAR_REPORT] = {ATT_CHAR_REPORT, ATT_MANDATORY, ATT_CHAR_PROP_RD}, + [HOGPRH_CHAR_REPORT] = {ATT_CHAR_REPORT, ATT_MANDATORY, ATT_CHAR_PROP_RD}, }; /* @@ -51,7 +55,6 @@ const struct prf_char_def hogprh_hids_char[HOGPRH_CHAR_REPORT + 1] = **************************************************************************************** */ - /** **************************************************************************************** * @brief Handles reception of the @ref HOGPRH_ENABLE_REQ message. @@ -64,62 +67,56 @@ const struct prf_char_def hogprh_hids_char[HOGPRH_CHAR_REPORT + 1] = **************************************************************************************** */ __STATIC int hogprh_enable_req_handler(ke_msg_id_t const msgid, - struct hogprh_enable_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; - int msg_status = KE_MSG_CONSUMED; + struct hogprh_enable_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; + int msg_status = KE_MSG_CONSUMED; - uint8_t state = ke_state_get(dest_id); - uint8_t conidx = KE_IDX_GET(dest_id); - // Battery service Client Role Task Environment - struct hogprh_env_tag *hogprh_env = PRF_ENV_GET(HOGPRH, hogprh); + uint8_t state = ke_state_get(dest_id); + uint8_t conidx = KE_IDX_GET(dest_id); + // Battery service Client Role Task Environment + struct hogprh_env_tag *hogprh_env = PRF_ENV_GET(HOGPRH, hogprh); - ASSERT_INFO(hogprh_env != NULL, dest_id, src_id); - if((state == HOGPRH_IDLE) && (hogprh_env->env[conidx] == NULL)) - { - // allocate environment variable for task instance - hogprh_env->env[conidx] = (struct hogprh_cnx_env*) ke_malloc(sizeof(struct hogprh_cnx_env),KE_MEM_ATT_DB); - memset(hogprh_env->env[conidx], 0, sizeof(struct hogprh_cnx_env)); + ASSERT_INFO(hogprh_env != NULL, dest_id, src_id); + if ((state == HOGPRH_IDLE) && (hogprh_env->env[conidx] == NULL)) { + // allocate environment variable for task instance + hogprh_env->env[conidx] = (struct hogprh_cnx_env *)ke_malloc( + sizeof(struct hogprh_cnx_env), KE_MEM_ATT_DB); + memset(hogprh_env->env[conidx], 0, sizeof(struct hogprh_cnx_env)); - //Config connection, start discovering - if(param->con_type == PRF_CON_DISCOVERY) - { - //start discovering HID on peer - prf_disc_svc_send(&(hogprh_env->prf_env), conidx, ATT_SVC_HID); + // Config connection, start discovering + if (param->con_type == PRF_CON_DISCOVERY) { + // start discovering HID on peer + prf_disc_svc_send(&(hogprh_env->prf_env), conidx, ATT_SVC_HID); - // Go to DISCOVERING state - ke_state_set(dest_id, HOGPRH_BUSY); - hogprh_env->env[conidx]->operation = ke_param2msg(param); - msg_status = KE_MSG_NO_FREE; - } - //normal connection, get saved att details - else - { - hogprh_env->env[conidx]->hids_nb = param->hids_nb; - memcpy(&(hogprh_env->env[conidx]->hids[0]), &(param->hids[0]), sizeof(struct hogprh_content) * HOGPRH_NB_HIDS_INST_MAX); - - //send APP confirmation that can start normal connection to TH - hogprh_enable_rsp_send(hogprh_env, conidx, GAP_ERR_NO_ERROR); - } - } - else if(state != HOGPRH_FREE) - { - status = PRF_ERR_REQ_DISALLOWED; + // Go to DISCOVERING state + ke_state_set(dest_id, HOGPRH_BUSY); + hogprh_env->env[conidx]->operation = ke_param2msg(param); + msg_status = KE_MSG_NO_FREE; } + // normal connection, get saved att details + else { + hogprh_env->env[conidx]->hids_nb = param->hids_nb; + memcpy(&(hogprh_env->env[conidx]->hids[0]), &(param->hids[0]), + sizeof(struct hogprh_content) * HOGPRH_NB_HIDS_INST_MAX); - // send an error if request fails - if(status != GAP_ERR_NO_ERROR) - { - hogprh_enable_rsp_send(hogprh_env, conidx, status); + // send APP confirmation that can start normal connection to TH + hogprh_enable_rsp_send(hogprh_env, conidx, GAP_ERR_NO_ERROR); } + } else if (state != HOGPRH_FREE) { + status = PRF_ERR_REQ_DISALLOWED; + } - return (msg_status); + // send an error if request fails + if (status != GAP_ERR_NO_ERROR) { + hogprh_enable_rsp_send(hogprh_env, conidx, status); + } + + return (msg_status); } - /** **************************************************************************************** * @brief Handles reception of the @ref GATTC_SDP_SVC_IND_HANDLER message. @@ -132,93 +129,96 @@ __STATIC int hogprh_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, - struct gattc_sdp_svc_ind const *ind, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_sdp_svc_ind const *ind, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == HOGPRH_BUSY) - { - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct hogprh_env_tag *hogprh_env = PRF_ENV_GET(HOGPRH, hogprh); + if (state == HOGPRH_BUSY) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct hogprh_env_tag *hogprh_env = PRF_ENV_GET(HOGPRH, hogprh); - ASSERT_INFO(hogprh_env != NULL, dest_id, src_id); - ASSERT_INFO(hogprh_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(hogprh_env != NULL, dest_id, src_id); + ASSERT_INFO(hogprh_env->env[conidx] != NULL, dest_id, src_id); - if(hogprh_env->env[conidx]->hids_nb < HOGPRH_NB_HIDS_INST_MAX) - { - uint8_t i; - struct prf_char_def hids_char[HOGPRH_CHAR_MAX]; - struct prf_char_desc_def hids_char_desc[HOGPRH_DESC_MAX]; - uint8_t hid_idx = hogprh_env->env[conidx]->hids_nb; - uint8_t fnd_att; + if (hogprh_env->env[conidx]->hids_nb < HOGPRH_NB_HIDS_INST_MAX) { + uint8_t i; + struct prf_char_def hids_char[HOGPRH_CHAR_MAX]; + struct prf_char_desc_def hids_char_desc[HOGPRH_DESC_MAX]; + uint8_t hid_idx = hogprh_env->env[conidx]->hids_nb; + uint8_t fnd_att; + // 1. Create characteristic reference + memcpy(hids_char, hogprh_hids_char, + sizeof(struct prf_char_def) * HOGPRH_CHAR_REPORT); + for (i = HOGPRH_CHAR_REPORT; i < HOGPRH_CHAR_MAX; i++) { + hids_char[i] = hogprh_hids_char[HOGPRH_CHAR_REPORT]; + } + // 2. create descriptor reference + // Report Map Char. External Report Reference Descriptor + hids_char_desc[HOGPRH_DESC_REPORT_MAP_EXT_REP_REF].char_code = + HOGPRH_CHAR_REPORT_MAP; + hids_char_desc[HOGPRH_DESC_REPORT_MAP_EXT_REP_REF].req_flag = + ATT_OPTIONAL; + hids_char_desc[HOGPRH_DESC_REPORT_MAP_EXT_REP_REF].uuid = + ATT_DESC_EXT_REPORT_REF; - // 1. Create characteristic reference - memcpy(hids_char, hogprh_hids_char, sizeof(struct prf_char_def) * HOGPRH_CHAR_REPORT); - for(i = HOGPRH_CHAR_REPORT ; i < HOGPRH_CHAR_MAX ; i++) - { - hids_char[i] = hogprh_hids_char[HOGPRH_CHAR_REPORT]; - } + for (i = 0; i < HOGPRH_NB_REPORT_INST_MAX; i++) { + // Report Char. Report Reference + hids_char_desc[HOGPRH_DESC_REPORT_REF + i].char_code = + HOGPRH_CHAR_REPORT + i; + hids_char_desc[HOGPRH_DESC_REPORT_REF + i].req_flag = ATT_OPTIONAL; + hids_char_desc[HOGPRH_DESC_REPORT_REF + i].uuid = ATT_DESC_REPORT_REF; + // Report Client Config + hids_char_desc[HOGPRH_DESC_REPORT_CFG + i].char_code = + HOGPRH_CHAR_REPORT + i; + hids_char_desc[HOGPRH_DESC_REPORT_CFG + i].req_flag = ATT_OPTIONAL; + hids_char_desc[HOGPRH_DESC_REPORT_CFG + i].uuid = + ATT_DESC_CLIENT_CHAR_CFG; + } - // 2. create descriptor reference - // Report Map Char. External Report Reference Descriptor - hids_char_desc[HOGPRH_DESC_REPORT_MAP_EXT_REP_REF].char_code = HOGPRH_CHAR_REPORT_MAP; - hids_char_desc[HOGPRH_DESC_REPORT_MAP_EXT_REP_REF].req_flag = ATT_OPTIONAL; - hids_char_desc[HOGPRH_DESC_REPORT_MAP_EXT_REP_REF].uuid = ATT_DESC_EXT_REPORT_REF; + // 3. Retrieve HID characteristics + prf_extract_svc_info(ind, HOGPRH_CHAR_MAX, &hids_char[0], + &(hogprh_env->env[conidx]->hids[hid_idx].chars[0]), + HOGPRH_DESC_MAX, &hids_char_desc[0], + &(hogprh_env->env[conidx]->hids[hid_idx].descs[0])); - for(i = 0 ; i < HOGPRH_NB_REPORT_INST_MAX ; i++) - { - // Report Char. Report Reference - hids_char_desc[HOGPRH_DESC_REPORT_REF + i].char_code = HOGPRH_CHAR_REPORT + i; - hids_char_desc[HOGPRH_DESC_REPORT_REF + i].req_flag = ATT_OPTIONAL; - hids_char_desc[HOGPRH_DESC_REPORT_REF + i].uuid = ATT_DESC_REPORT_REF; - // Report Client Config - hids_char_desc[HOGPRH_DESC_REPORT_CFG + i].char_code = HOGPRH_CHAR_REPORT + i; - hids_char_desc[HOGPRH_DESC_REPORT_CFG + i].req_flag = ATT_OPTIONAL; - hids_char_desc[HOGPRH_DESC_REPORT_CFG + i].uuid = ATT_DESC_CLIENT_CHAR_CFG; - } + // 4. Store service range + hogprh_env->env[conidx]->hids[hid_idx].svc.shdl = ind->start_hdl; + hogprh_env->env[conidx]->hids[hid_idx].svc.ehdl = ind->end_hdl; - // 3. Retrieve HID characteristics - prf_extract_svc_info(ind, HOGPRH_CHAR_MAX, &hids_char[0], - &(hogprh_env->env[conidx]->hids[hid_idx].chars[0]), - HOGPRH_DESC_MAX, &hids_char_desc[0], - &(hogprh_env->env[conidx]->hids[hid_idx].descs[0])); - - // 4. Store service range - hogprh_env->env[conidx]->hids[hid_idx].svc.shdl = ind->start_hdl; - hogprh_env->env[conidx]->hids[hid_idx].svc.ehdl = ind->end_hdl; - - // 5. Search for an included service - for (fnd_att=0; fnd_att< (ind->end_hdl - ind->start_hdl); fnd_att++) - { - if(ind->info[fnd_att].att_type == GATTC_SDP_INC_SVC) - { - hogprh_env->env[conidx]->hids[hid_idx].incl_svc.handle = ind->start_hdl + fnd_att + 1; - hogprh_env->env[conidx]->hids[hid_idx].incl_svc.start_hdl = ind->info[fnd_att].inc_svc.start_hdl; - hogprh_env->env[conidx]->hids[hid_idx].incl_svc.end_hdl = ind->info[fnd_att].inc_svc.end_hdl; - hogprh_env->env[conidx]->hids[hid_idx].incl_svc.uuid_len = ind->info[fnd_att].inc_svc.uuid_len; - memcpy(hogprh_env->env[conidx]->hids[hid_idx].incl_svc.uuid, ind->info[fnd_att].inc_svc.uuid, - ind->info[fnd_att].inc_svc.uuid_len); - } - if((ind->info[fnd_att].att_type == GATTC_SDP_ATT_VAL) - && (attm_uuid16_comp((uint8_t*)ind->info[fnd_att].att.uuid, ind->info[fnd_att].att.uuid_len, ATT_CHAR_REPORT))) - { - hogprh_env->env[conidx]->hids[hid_idx].report_nb++; - } - } - - hogprh_env->env[conidx]->hids_nb++; + // 5. Search for an included service + for (fnd_att = 0; fnd_att < (ind->end_hdl - ind->start_hdl); fnd_att++) { + if (ind->info[fnd_att].att_type == GATTC_SDP_INC_SVC) { + hogprh_env->env[conidx]->hids[hid_idx].incl_svc.handle = + ind->start_hdl + fnd_att + 1; + hogprh_env->env[conidx]->hids[hid_idx].incl_svc.start_hdl = + ind->info[fnd_att].inc_svc.start_hdl; + hogprh_env->env[conidx]->hids[hid_idx].incl_svc.end_hdl = + ind->info[fnd_att].inc_svc.end_hdl; + hogprh_env->env[conidx]->hids[hid_idx].incl_svc.uuid_len = + ind->info[fnd_att].inc_svc.uuid_len; + memcpy(hogprh_env->env[conidx]->hids[hid_idx].incl_svc.uuid, + ind->info[fnd_att].inc_svc.uuid, + ind->info[fnd_att].inc_svc.uuid_len); } + if ((ind->info[fnd_att].att_type == GATTC_SDP_ATT_VAL) && + (attm_uuid16_comp((uint8_t *)ind->info[fnd_att].att.uuid, + ind->info[fnd_att].att.uuid_len, + ATT_CHAR_REPORT))) { + hogprh_env->env[conidx]->hids[hid_idx].report_nb++; + } + } + + hogprh_env->env[conidx]->hids_nb++; } + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } - /** **************************************************************************************** * @brief Handles reception of the @ref HOGPRH_READ_INFO_REQ message. @@ -229,119 +229,123 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int hogprh_read_info_req_handler(ke_msg_id_t const msgid, struct hogprh_read_info_req const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - int msg_status = KE_MSG_CONSUMED; - uint8_t state = ke_state_get(dest_id); - uint8_t status = PRF_ERR_REQ_DISALLOWED; +__STATIC int hogprh_read_info_req_handler( + ke_msg_id_t const msgid, struct hogprh_read_info_req const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + int msg_status = KE_MSG_CONSUMED; + uint8_t state = ke_state_get(dest_id); + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if(state == HOGPRH_IDLE) - { - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct hogprh_env_tag *hogprh_env = PRF_ENV_GET(HOGPRH, hogprh); - ASSERT_INFO(hogprh_env != NULL, dest_id, src_id); - // environment variable not ready - if(hogprh_env->env[conidx] == NULL) - { - status = PRF_APP_ERROR; - } - // check parameter range - else if((param->hid_idx > hogprh_env->env[conidx]->hids_nb) || (param->report_idx >= HOGPRH_NB_REPORT_INST_MAX)) - { - status = PRF_ERR_INVALID_PARAM; - } - else - { - uint16_t handle = ATT_INVALID_HANDLE; - status = PRF_ERR_INEXISTENT_HDL; - - // check requested info - switch(param->info) - { - /// Protocol Mode - case HOGPRH_PROTO_MODE: - { - handle = hogprh_env->env[conidx]->hids[param->hid_idx].chars[HOGPRH_CHAR_PROTOCOL_MODE].val_hdl; - }break; - /// Report Map - case HOGPRH_REPORT_MAP: - { - handle = hogprh_env->env[conidx]->hids[param->hid_idx].chars[HOGPRH_CHAR_REPORT_MAP].val_hdl; - }break; - /// Report Map Char. External Report Reference Descriptor - case HOGPRH_REPORT_MAP_EXT_REP_REF: - { - handle = hogprh_env->env[conidx]->hids[param->hid_idx].descs[HOGPRH_DESC_REPORT_MAP_EXT_REP_REF].desc_hdl; - }break; - /// HID Information - case HOGPRH_HID_INFO: - { - handle = hogprh_env->env[conidx]->hids[param->hid_idx].chars[HOGPRH_CHAR_HID_INFO].val_hdl; - }break; - /// Report - case HOGPRH_REPORT: - { - handle = hogprh_env->env[conidx]->hids[param->hid_idx].chars[HOGPRH_CHAR_REPORT + param->report_idx].val_hdl; - }break; - /// Report Char. Report Reference - case HOGPRH_REPORT_REF: - { - handle = hogprh_env->env[conidx]->hids[param->hid_idx].descs[HOGPRH_DESC_REPORT_REF + param->report_idx].desc_hdl; - }break; - /// Report Notification config - case HOGPRH_REPORT_NTF_CFG: - { - handle = hogprh_env->env[conidx]->hids[param->hid_idx].descs[HOGPRH_DESC_REPORT_CFG + param->report_idx].desc_hdl; - }break; - - default: - { - status = PRF_ERR_INVALID_PARAM; - }break; - } - - if(handle != ATT_INVALID_HANDLE) - { - status = GAP_ERR_NO_ERROR; - // read information - prf_read_char_send(&(hogprh_env->prf_env), conidx, - hogprh_env->env[conidx]->hids[param->hid_idx].svc.shdl, - hogprh_env->env[conidx]->hids[param->hid_idx].svc.ehdl, handle); - - // store context of request and go into busy state - hogprh_env->env[conidx]->operation = ke_param2msg(param); - ke_state_set(dest_id, HOGPRH_BUSY); - msg_status = KE_MSG_NO_FREE; - } - } + if (state == HOGPRH_IDLE) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct hogprh_env_tag *hogprh_env = PRF_ENV_GET(HOGPRH, hogprh); + ASSERT_INFO(hogprh_env != NULL, dest_id, src_id); + // environment variable not ready + if (hogprh_env->env[conidx] == NULL) { + status = PRF_APP_ERROR; } - // process message later - else if (state == HOGPRH_BUSY) - { + // check parameter range + else if ((param->hid_idx > hogprh_env->env[conidx]->hids_nb) || + (param->report_idx >= HOGPRH_NB_REPORT_INST_MAX)) { + status = PRF_ERR_INVALID_PARAM; + } else { + uint16_t handle = ATT_INVALID_HANDLE; + status = PRF_ERR_INEXISTENT_HDL; + + // check requested info + switch (param->info) { + /// Protocol Mode + case HOGPRH_PROTO_MODE: { + handle = hogprh_env->env[conidx] + ->hids[param->hid_idx] + .chars[HOGPRH_CHAR_PROTOCOL_MODE] + .val_hdl; + } break; + /// Report Map + case HOGPRH_REPORT_MAP: { + handle = hogprh_env->env[conidx] + ->hids[param->hid_idx] + .chars[HOGPRH_CHAR_REPORT_MAP] + .val_hdl; + } break; + /// Report Map Char. External Report Reference Descriptor + case HOGPRH_REPORT_MAP_EXT_REP_REF: { + handle = hogprh_env->env[conidx] + ->hids[param->hid_idx] + .descs[HOGPRH_DESC_REPORT_MAP_EXT_REP_REF] + .desc_hdl; + } break; + /// HID Information + case HOGPRH_HID_INFO: { + handle = hogprh_env->env[conidx] + ->hids[param->hid_idx] + .chars[HOGPRH_CHAR_HID_INFO] + .val_hdl; + } break; + /// Report + case HOGPRH_REPORT: { + handle = hogprh_env->env[conidx] + ->hids[param->hid_idx] + .chars[HOGPRH_CHAR_REPORT + param->report_idx] + .val_hdl; + } break; + /// Report Char. Report Reference + case HOGPRH_REPORT_REF: { + handle = hogprh_env->env[conidx] + ->hids[param->hid_idx] + .descs[HOGPRH_DESC_REPORT_REF + param->report_idx] + .desc_hdl; + } break; + /// Report Notification config + case HOGPRH_REPORT_NTF_CFG: { + handle = hogprh_env->env[conidx] + ->hids[param->hid_idx] + .descs[HOGPRH_DESC_REPORT_CFG + param->report_idx] + .desc_hdl; + } break; + + default: { + status = PRF_ERR_INVALID_PARAM; + } break; + } + + if (handle != ATT_INVALID_HANDLE) { status = GAP_ERR_NO_ERROR; - msg_status = KE_MSG_SAVED; + // read information + prf_read_char_send( + &(hogprh_env->prf_env), conidx, + hogprh_env->env[conidx]->hids[param->hid_idx].svc.shdl, + hogprh_env->env[conidx]->hids[param->hid_idx].svc.ehdl, handle); + + // store context of request and go into busy state + hogprh_env->env[conidx]->operation = ke_param2msg(param); + ke_state_set(dest_id, HOGPRH_BUSY); + msg_status = KE_MSG_NO_FREE; + } } + } + // process message later + else if (state == HOGPRH_BUSY) { + status = GAP_ERR_NO_ERROR; + msg_status = KE_MSG_SAVED; + } + // request cannot be performed + if (status != GAP_ERR_NO_ERROR) { + struct hogprh_read_info_rsp *rsp = KE_MSG_ALLOC( + HOGPRH_READ_INFO_RSP, src_id, dest_id, hogprh_read_info_rsp); + // set error status + rsp->status = status; + rsp->info = param->info; + rsp->hid_idx = param->hid_idx; - // request cannot be performed - if(status != GAP_ERR_NO_ERROR) - { - struct hogprh_read_info_rsp * rsp = KE_MSG_ALLOC(HOGPRH_READ_INFO_RSP, - src_id, dest_id, hogprh_read_info_rsp); - // set error status - rsp->status = status; - rsp->info = param->info; - rsp->hid_idx = param->hid_idx; + ke_msg_send(rsp); + } - ke_msg_send(rsp); - } - - return (msg_status); + return (msg_status); } - /** **************************************************************************************** * @brief Handles reception of the @ref HOGPRH_WRITE_REQ message. @@ -352,112 +356,117 @@ __STATIC int hogprh_read_info_req_handler(ke_msg_id_t const msgid, struct hogprh * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int hogprh_write_req_handler(ke_msg_id_t const msgid, struct hogprh_write_req *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - int msg_status = KE_MSG_CONSUMED; - uint8_t state = ke_state_get(dest_id); - uint8_t status = PRF_ERR_REQ_DISALLOWED; +__STATIC int hogprh_write_req_handler(ke_msg_id_t const msgid, + struct hogprh_write_req *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + int msg_status = KE_MSG_CONSUMED; + uint8_t state = ke_state_get(dest_id); + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if(state == HOGPRH_IDLE) - { - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct hogprh_env_tag *hogprh_env = PRF_ENV_GET(HOGPRH, hogprh); - ASSERT_INFO(hogprh_env != NULL, dest_id, src_id); - // environment variable not ready - if(hogprh_env->env[conidx] == NULL) - { - status = PRF_APP_ERROR; - } - // check parameter range - else if((param->hid_idx > hogprh_env->env[conidx]->hids_nb) || (param->report_idx >= HOGPRH_NB_REPORT_INST_MAX) - || (param->info > HOGPRH_INFO_MAX) - || ((param->info == HOGPRH_REPORT_NTF_CFG) && (param->data.report_cfg > PRF_CLI_START_NTF))) - { - status = PRF_ERR_INVALID_PARAM; - } - else - { - uint16_t handle = ATT_INVALID_HANDLE; - status = PRF_ERR_INEXISTENT_HDL; - - // check requested info - switch(param->info) - { - // Protocol Mode - case HOGPRH_PROTO_MODE: - { - handle = hogprh_env->env[conidx]->hids[param->hid_idx].chars[HOGPRH_CHAR_PROTOCOL_MODE].val_hdl; - prf_gatt_write(&hogprh_env->prf_env, conidx, handle, (uint8_t*)¶m->data.proto_mode, 1, GATTC_WRITE_NO_RESPONSE); - }break; - // HID Control Point - case HOGPRH_HID_CTNL_PT: - { - handle = hogprh_env->env[conidx]->hids[param->hid_idx].chars[HOGPRH_CHAR_HID_CTNL_PT].val_hdl; - prf_gatt_write(&hogprh_env->prf_env, conidx, handle, (uint8_t*)¶m->data.hid_ctnl_pt, 1, GATTC_WRITE_NO_RESPONSE); - }break; - // Report Char. Report Reference - case HOGPRH_REPORT: - { - // Get MTU to select between GATT_WRITE_LONG_CHAR and GATT_WRITE_CHAR - if (param->data.report.length > (gattc_get_mtu(conidx) - 3)) - { - param->wr_cmd = false; - } - - handle = hogprh_env->env[conidx]->hids[param->hid_idx].chars[HOGPRH_CHAR_REPORT + param->report_idx].val_hdl; - prf_gatt_write(&hogprh_env->prf_env, conidx, handle, (uint8_t*)param->data.report.value , - param->data.report.length, (param->wr_cmd ? GATTC_WRITE_NO_RESPONSE : GATTC_WRITE)); - }break; - // Report Notification config - case HOGPRH_REPORT_NTF_CFG: - { - handle = hogprh_env->env[conidx]->hids[param->hid_idx].descs[HOGPRH_DESC_REPORT_CFG + param->report_idx].desc_hdl; - prf_gatt_write_ntf_ind(&hogprh_env->prf_env, conidx, handle, param->data.report_cfg); - }break; - default: - { - status = PRF_ERR_INVALID_PARAM; - }break; - } - - if(handle != ATT_INVALID_HANDLE) - { - status = GAP_ERR_NO_ERROR; - - // store context of request and go into busy state - hogprh_env->env[conidx]->operation = ke_param2msg(param); - ke_state_set(dest_id, HOGPRH_BUSY); - msg_status = KE_MSG_NO_FREE; - } - } + if (state == HOGPRH_IDLE) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct hogprh_env_tag *hogprh_env = PRF_ENV_GET(HOGPRH, hogprh); + ASSERT_INFO(hogprh_env != NULL, dest_id, src_id); + // environment variable not ready + if (hogprh_env->env[conidx] == NULL) { + status = PRF_APP_ERROR; } - // process message later - else if (state == HOGPRH_BUSY) - { + // check parameter range + else if ((param->hid_idx > hogprh_env->env[conidx]->hids_nb) || + (param->report_idx >= HOGPRH_NB_REPORT_INST_MAX) || + (param->info > HOGPRH_INFO_MAX) || + ((param->info == HOGPRH_REPORT_NTF_CFG) && + (param->data.report_cfg > PRF_CLI_START_NTF))) { + status = PRF_ERR_INVALID_PARAM; + } else { + uint16_t handle = ATT_INVALID_HANDLE; + status = PRF_ERR_INEXISTENT_HDL; + + // check requested info + switch (param->info) { + // Protocol Mode + case HOGPRH_PROTO_MODE: { + handle = hogprh_env->env[conidx] + ->hids[param->hid_idx] + .chars[HOGPRH_CHAR_PROTOCOL_MODE] + .val_hdl; + prf_gatt_write(&hogprh_env->prf_env, conidx, handle, + (uint8_t *)¶m->data.proto_mode, 1, + GATTC_WRITE_NO_RESPONSE); + } break; + // HID Control Point + case HOGPRH_HID_CTNL_PT: { + handle = hogprh_env->env[conidx] + ->hids[param->hid_idx] + .chars[HOGPRH_CHAR_HID_CTNL_PT] + .val_hdl; + prf_gatt_write(&hogprh_env->prf_env, conidx, handle, + (uint8_t *)¶m->data.hid_ctnl_pt, 1, + GATTC_WRITE_NO_RESPONSE); + } break; + // Report Char. Report Reference + case HOGPRH_REPORT: { + // Get MTU to select between GATT_WRITE_LONG_CHAR and GATT_WRITE_CHAR + if (param->data.report.length > (gattc_get_mtu(conidx) - 3)) { + param->wr_cmd = false; + } + + handle = hogprh_env->env[conidx] + ->hids[param->hid_idx] + .chars[HOGPRH_CHAR_REPORT + param->report_idx] + .val_hdl; + prf_gatt_write(&hogprh_env->prf_env, conidx, handle, + (uint8_t *)param->data.report.value, + param->data.report.length, + (param->wr_cmd ? GATTC_WRITE_NO_RESPONSE : GATTC_WRITE)); + } break; + // Report Notification config + case HOGPRH_REPORT_NTF_CFG: { + handle = hogprh_env->env[conidx] + ->hids[param->hid_idx] + .descs[HOGPRH_DESC_REPORT_CFG + param->report_idx] + .desc_hdl; + prf_gatt_write_ntf_ind(&hogprh_env->prf_env, conidx, handle, + param->data.report_cfg); + } break; + default: { + status = PRF_ERR_INVALID_PARAM; + } break; + } + + if (handle != ATT_INVALID_HANDLE) { status = GAP_ERR_NO_ERROR; - msg_status = KE_MSG_SAVED; + + // store context of request and go into busy state + hogprh_env->env[conidx]->operation = ke_param2msg(param); + ke_state_set(dest_id, HOGPRH_BUSY); + msg_status = KE_MSG_NO_FREE; + } } + } + // process message later + else if (state == HOGPRH_BUSY) { + status = GAP_ERR_NO_ERROR; + msg_status = KE_MSG_SAVED; + } + // request cannot be performed + if (status != GAP_ERR_NO_ERROR) { + struct hogprh_write_rsp *rsp = + KE_MSG_ALLOC(HOGPRH_WRITE_RSP, src_id, dest_id, hogprh_write_rsp); + // set error status + rsp->status = status; + rsp->info = param->info; + rsp->hid_idx = param->hid_idx; - // request cannot be performed - if(status != GAP_ERR_NO_ERROR) - { - struct hogprh_write_rsp * rsp = KE_MSG_ALLOC(HOGPRH_WRITE_RSP, - src_id, dest_id, hogprh_write_rsp); - // set error status - rsp->status = status; - rsp->info = param->info; - rsp->hid_idx = param->hid_idx; + ke_msg_send(rsp); + } - ke_msg_send(rsp); - } - - return (msg_status); + return (msg_status); } - /** **************************************************************************************** * @brief Handles reception of the @ref GATTC_CMP_EVT message. @@ -470,133 +479,138 @@ __STATIC int hogprh_write_req_handler(ke_msg_id_t const msgid, struct hogprh_wri **************************************************************************************** */ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, - struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct hogprh_env_tag *hogprh_env = PRF_ENV_GET(HOGPRH, hogprh); + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct hogprh_env_tag *hogprh_env = PRF_ENV_GET(HOGPRH, hogprh); - // sanity check - if((state == HOGPRH_BUSY) && (hogprh_env->env[conidx] != NULL) - && (hogprh_env->env[conidx]->operation != NULL)) - { - switch(hogprh_env->env[conidx]->operation->id) - { - case HOGPRH_ENABLE_REQ: - { - uint8_t status = param->status; + // sanity check + if ((state == HOGPRH_BUSY) && (hogprh_env->env[conidx] != NULL) && + (hogprh_env->env[conidx]->operation != NULL)) { + switch (hogprh_env->env[conidx]->operation->id) { + case HOGPRH_ENABLE_REQ: { + uint8_t status = param->status; - if (param->status == ATT_ERR_NO_ERROR) - { - // check characteristic validity - if(hogprh_env->env[conidx]->hids_nb > 0) - { - uint8_t report_idx; - uint8_t hid_idx; - for (hid_idx = 0 ; (hid_idx < co_min(hogprh_env->env[conidx]->hids_nb, HOGPRH_NB_HIDS_INST_MAX)) - && (status == GAP_ERR_NO_ERROR) ; hid_idx++) - { + if (param->status == ATT_ERR_NO_ERROR) { + // check characteristic validity + if (hogprh_env->env[conidx]->hids_nb > 0) { + uint8_t report_idx; + uint8_t hid_idx; + for (hid_idx = 0; (hid_idx < co_min(hogprh_env->env[conidx]->hids_nb, + HOGPRH_NB_HIDS_INST_MAX)) && + (status == GAP_ERR_NO_ERROR); + hid_idx++) { - struct prf_char_def hids_char[HOGPRH_CHAR_MAX]; - struct prf_char_desc_def hids_char_desc[HOGPRH_DESC_MAX]; + struct prf_char_def hids_char[HOGPRH_CHAR_MAX]; + struct prf_char_desc_def hids_char_desc[HOGPRH_DESC_MAX]; - // 1. Create characteristic reference - memcpy(hids_char, hogprh_hids_char, sizeof(struct prf_char_def) * HOGPRH_CHAR_REPORT); - for(report_idx = HOGPRH_CHAR_REPORT ; report_idx < HOGPRH_CHAR_MAX ; report_idx++) - { - hids_char[report_idx] = hogprh_hids_char[HOGPRH_CHAR_REPORT]; - hids_char[report_idx].req_flag = ATT_OPTIONAL; - } + // 1. Create characteristic reference + memcpy(hids_char, hogprh_hids_char, + sizeof(struct prf_char_def) * HOGPRH_CHAR_REPORT); + for (report_idx = HOGPRH_CHAR_REPORT; report_idx < HOGPRH_CHAR_MAX; + report_idx++) { + hids_char[report_idx] = hogprh_hids_char[HOGPRH_CHAR_REPORT]; + hids_char[report_idx].req_flag = ATT_OPTIONAL; + } - // 2. create descriptor reference - // Report Map Char. External Report Reference Descriptor - hids_char_desc[HOGPRH_DESC_REPORT_MAP_EXT_REP_REF].char_code = HOGPRH_CHAR_REPORT_MAP; - hids_char_desc[HOGPRH_DESC_REPORT_MAP_EXT_REP_REF].req_flag = ATT_OPTIONAL; - hids_char_desc[HOGPRH_DESC_REPORT_MAP_EXT_REP_REF].uuid = ATT_DESC_EXT_REPORT_REF; + // 2. create descriptor reference + // Report Map Char. External Report Reference Descriptor + hids_char_desc[HOGPRH_DESC_REPORT_MAP_EXT_REP_REF].char_code = + HOGPRH_CHAR_REPORT_MAP; + hids_char_desc[HOGPRH_DESC_REPORT_MAP_EXT_REP_REF].req_flag = + ATT_OPTIONAL; + hids_char_desc[HOGPRH_DESC_REPORT_MAP_EXT_REP_REF].uuid = + ATT_DESC_EXT_REPORT_REF; - for(report_idx = 0 ; report_idx < HOGPRH_NB_REPORT_INST_MAX ; report_idx++) - { - // Report Char. Report Reference - hids_char_desc[HOGPRH_DESC_REPORT_REF + report_idx].char_code = HOGPRH_CHAR_REPORT + report_idx; - hids_char_desc[HOGPRH_DESC_REPORT_REF + report_idx].req_flag = ATT_OPTIONAL; - hids_char_desc[HOGPRH_DESC_REPORT_REF + report_idx].uuid = ATT_DESC_REPORT_REF; - // Report Client Config - hids_char_desc[HOGPRH_DESC_REPORT_CFG + report_idx].char_code = HOGPRH_CHAR_REPORT + report_idx; - hids_char_desc[HOGPRH_DESC_REPORT_CFG + report_idx].req_flag = ATT_OPTIONAL; - hids_char_desc[HOGPRH_DESC_REPORT_CFG + report_idx].uuid = ATT_DESC_CLIENT_CHAR_CFG; - } + for (report_idx = 0; report_idx < HOGPRH_NB_REPORT_INST_MAX; + report_idx++) { + // Report Char. Report Reference + hids_char_desc[HOGPRH_DESC_REPORT_REF + report_idx].char_code = + HOGPRH_CHAR_REPORT + report_idx; + hids_char_desc[HOGPRH_DESC_REPORT_REF + report_idx].req_flag = + ATT_OPTIONAL; + hids_char_desc[HOGPRH_DESC_REPORT_REF + report_idx].uuid = + ATT_DESC_REPORT_REF; + // Report Client Config + hids_char_desc[HOGPRH_DESC_REPORT_CFG + report_idx].char_code = + HOGPRH_CHAR_REPORT + report_idx; + hids_char_desc[HOGPRH_DESC_REPORT_CFG + report_idx].req_flag = + ATT_OPTIONAL; + hids_char_desc[HOGPRH_DESC_REPORT_CFG + report_idx].uuid = + ATT_DESC_CLIENT_CHAR_CFG; + } - // 3. Check Characteristic validity - status = prf_check_svc_char_validity(HOGPRH_CHAR_MAX, hogprh_env->env[conidx]->hids[hid_idx].chars, - hids_char); + // 3. Check Characteristic validity + status = prf_check_svc_char_validity( + HOGPRH_CHAR_MAX, hogprh_env->env[conidx]->hids[hid_idx].chars, + hids_char); - // 4. check descriptor validity - if(status == GAP_ERR_NO_ERROR) - { - status = prf_check_svc_char_desc_validity(HOGPRH_DESC_MAX, - hogprh_env->env[conidx]->hids[hid_idx].descs, hids_char_desc, - hogprh_env->env[conidx]->hids[hid_idx].chars); - } - } - } - // no services found - else - { - status = PRF_ERR_STOP_DISC_CHAR_MISSING; - } - - } - hogprh_enable_rsp_send(hogprh_env, conidx, status); - }break; - case HOGPRH_READ_INFO_REQ: - { - // do not send anything if it's a local request - if(hogprh_env->env[conidx]->operation->src_id != dest_id) - { - struct hogprh_read_info_req* req = (struct hogprh_read_info_req*) ke_msg2param(hogprh_env->env[conidx]->operation); - struct hogprh_read_info_rsp * rsp = KE_MSG_ALLOC(HOGPRH_READ_INFO_RSP, - prf_dst_task_get(&(hogprh_env->prf_env), conidx), dest_id, hogprh_read_info_rsp); - // set error status - rsp->status = param->status; - rsp->hid_idx = req->hid_idx; - rsp->info = req->info; - rsp->report_idx = req->report_idx; - - ke_msg_send(rsp); - } - - }break; - case HOGPRH_WRITE_REQ: - { - struct hogprh_write_req* req = (struct hogprh_write_req*) ke_msg2param(hogprh_env->env[conidx]->operation); - - struct hogprh_write_rsp * rsp = KE_MSG_ALLOC(HOGPRH_WRITE_RSP, - prf_dst_task_get(&(hogprh_env->prf_env), conidx), dest_id, hogprh_write_rsp); - // set error status - rsp->status = param->status; - rsp->hid_idx = req->hid_idx; - rsp->info = req->info; - rsp->report_idx = req->report_idx; - - ke_msg_send(rsp); - }break; - default: - { - // Not Expected at all - ASSERT_ERR(0); - }break; + // 4. check descriptor validity + if (status == GAP_ERR_NO_ERROR) { + status = prf_check_svc_char_desc_validity( + HOGPRH_DESC_MAX, hogprh_env->env[conidx]->hids[hid_idx].descs, + hids_char_desc, hogprh_env->env[conidx]->hids[hid_idx].chars); + } + } } + // no services found + else { + status = PRF_ERR_STOP_DISC_CHAR_MISSING; + } + } + hogprh_enable_rsp_send(hogprh_env, conidx, status); + } break; + case HOGPRH_READ_INFO_REQ: { + // do not send anything if it's a local request + if (hogprh_env->env[conidx]->operation->src_id != dest_id) { + struct hogprh_read_info_req *req = + (struct hogprh_read_info_req *)ke_msg2param( + hogprh_env->env[conidx]->operation); + struct hogprh_read_info_rsp *rsp = + KE_MSG_ALLOC(HOGPRH_READ_INFO_RSP, + prf_dst_task_get(&(hogprh_env->prf_env), conidx), + dest_id, hogprh_read_info_rsp); + // set error status + rsp->status = param->status; + rsp->hid_idx = req->hid_idx; + rsp->info = req->info; + rsp->report_idx = req->report_idx; - // operation is over - go back to idle state - ke_free(hogprh_env->env[conidx]->operation); - hogprh_env->env[conidx]->operation = NULL; - ke_state_set(dest_id, HOGPRH_IDLE); + ke_msg_send(rsp); + } + + } break; + case HOGPRH_WRITE_REQ: { + struct hogprh_write_req *req = (struct hogprh_write_req *)ke_msg2param( + hogprh_env->env[conidx]->operation); + + struct hogprh_write_rsp *rsp = KE_MSG_ALLOC( + HOGPRH_WRITE_RSP, prf_dst_task_get(&(hogprh_env->prf_env), conidx), + dest_id, hogprh_write_rsp); + // set error status + rsp->status = param->status; + rsp->hid_idx = req->hid_idx; + rsp->info = req->info; + rsp->report_idx = req->report_idx; + + ke_msg_send(rsp); + } break; + default: { + // Not Expected at all + ASSERT_ERR(0); + } break; } - return (KE_MSG_CONSUMED); + // operation is over - go back to idle state + ke_free(hogprh_env->env[conidx]->operation); + hogprh_env->env[conidx]->operation = NULL; + ke_state_set(dest_id, HOGPRH_IDLE); + } + + return (KE_MSG_CONSUMED); } /** @@ -613,107 +627,99 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, struct gattc_read_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == HOGPRH_BUSY) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == HOGPRH_BUSY) { + uint8_t conidx = KE_IDX_GET(dest_id); - struct hogprh_env_tag *hogprh_env = PRF_ENV_GET(HOGPRH, hogprh); - struct hogprh_read_info_req* req = (struct hogprh_read_info_req*) ke_msg2param(hogprh_env->env[conidx]->operation); + struct hogprh_env_tag *hogprh_env = PRF_ENV_GET(HOGPRH, hogprh); + struct hogprh_read_info_req *req = + (struct hogprh_read_info_req *)ke_msg2param( + hogprh_env->env[conidx]->operation); - ASSERT_INFO(hogprh_env != NULL, dest_id, src_id); - ASSERT_INFO(hogprh_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(hogprh_env != NULL, dest_id, src_id); + ASSERT_INFO(hogprh_env->env[conidx] != NULL, dest_id, src_id); - // check if read is requested locally due to a received notification or b - if(hogprh_env->env[conidx]->operation->src_id == dest_id) - { - // send report indication - struct hogprh_report_ind* ind = KE_MSG_ALLOC_DYN(HOGPRH_REPORT_IND, - prf_dst_task_get(&(hogprh_env->prf_env), conidx), dest_id, - hogprh_report_ind, param->length); + // check if read is requested locally due to a received notification or b + if (hogprh_env->env[conidx]->operation->src_id == dest_id) { + // send report indication + struct hogprh_report_ind *ind = KE_MSG_ALLOC_DYN( + HOGPRH_REPORT_IND, prf_dst_task_get(&(hogprh_env->prf_env), conidx), + dest_id, hogprh_report_ind, param->length); - ind->hid_idx = req->hid_idx; - ind->report_idx = req->report_idx; - ind->report.length = param->length; - memcpy(ind->report.value, param->value, param->length); + ind->hid_idx = req->hid_idx; + ind->report_idx = req->report_idx; + ind->report.length = param->length; + memcpy(ind->report.value, param->value, param->length); - ke_msg_send(ind); - } - // or by the HID Client application - else - { - struct hogprh_read_info_rsp * rsp = KE_MSG_ALLOC_DYN(HOGPRH_READ_INFO_RSP, - prf_dst_task_get(&(hogprh_env->prf_env),conidx), dest_id, hogprh_read_info_rsp, param->length); + ke_msg_send(ind); + } + // or by the HID Client application + else { + struct hogprh_read_info_rsp *rsp = + KE_MSG_ALLOC_DYN(HOGPRH_READ_INFO_RSP, + prf_dst_task_get(&(hogprh_env->prf_env), conidx), + dest_id, hogprh_read_info_rsp, param->length); - // set error status - rsp->status = GAP_ERR_NO_ERROR; - rsp->hid_idx = req->hid_idx; - rsp->info = req->info; - rsp->report_idx = req->report_idx; + // set error status + rsp->status = GAP_ERR_NO_ERROR; + rsp->hid_idx = req->hid_idx; + rsp->info = req->info; + rsp->report_idx = req->report_idx; - switch(req->info) - { - /// Protocol Mode - case HOGPRH_PROTO_MODE: - { - rsp->data.proto_mode = param->value[0]; - }break; - /// Report Map - case HOGPRH_REPORT_MAP: - { - rsp->data.report_map.length = param->length; - memcpy(rsp->data.report_map.value, param->value, param->length); - }break; - /// Report Map Char. External Report Reference Descriptor - case HOGPRH_REPORT_MAP_EXT_REP_REF: - { - rsp->data.report_map_ref.uuid_len = param->length; - memcpy(rsp->data.report_map_ref.uuid, param->value, co_min(param->length, ATT_UUID_128_LEN)); - }break; - /// HID Information - case HOGPRH_HID_INFO: - { - rsp->data.hid_info.bcdHID = co_read16p(param->value); - rsp->data.hid_info.bCountryCode = param->value[2]; - rsp->data.hid_info.flags = param->value[3]; - }break; - /// Report - case HOGPRH_REPORT: - { - rsp->data.report.length = param->length; - memcpy(rsp->data.report.value, param->value, param->length); - }break; - /// Report Char. Report Reference - case HOGPRH_REPORT_REF: - { - rsp->data.report_ref.id = param->value[0]; - rsp->data.report_ref.type = param->value[1]; - }break; - /// Report Notification config - case HOGPRH_REPORT_NTF_CFG: - { - rsp->data.report_cfg = co_read16p(param->value); - }break; - default: - { - ASSERT_ERR(0); - }break; - } + switch (req->info) { + /// Protocol Mode + case HOGPRH_PROTO_MODE: { + rsp->data.proto_mode = param->value[0]; + } break; + /// Report Map + case HOGPRH_REPORT_MAP: { + rsp->data.report_map.length = param->length; + memcpy(rsp->data.report_map.value, param->value, param->length); + } break; + /// Report Map Char. External Report Reference Descriptor + case HOGPRH_REPORT_MAP_EXT_REP_REF: { + rsp->data.report_map_ref.uuid_len = param->length; + memcpy(rsp->data.report_map_ref.uuid, param->value, + co_min(param->length, ATT_UUID_128_LEN)); + } break; + /// HID Information + case HOGPRH_HID_INFO: { + rsp->data.hid_info.bcdHID = co_read16p(param->value); + rsp->data.hid_info.bCountryCode = param->value[2]; + rsp->data.hid_info.flags = param->value[3]; + } break; + /// Report + case HOGPRH_REPORT: { + rsp->data.report.length = param->length; + memcpy(rsp->data.report.value, param->value, param->length); + } break; + /// Report Char. Report Reference + case HOGPRH_REPORT_REF: { + rsp->data.report_ref.id = param->value[0]; + rsp->data.report_ref.type = param->value[1]; + } break; + /// Report Notification config + case HOGPRH_REPORT_NTF_CFG: { + rsp->data.report_cfg = co_read16p(param->value); + } break; + default: { + ASSERT_ERR(0); + } break; + } - // send response - ke_msg_send(rsp); - } - - // operation is over - go back to idle state - ke_free(hogprh_env->env[conidx]->operation); - hogprh_env->env[conidx]->operation = NULL; - ke_state_set(dest_id, HOGPRH_IDLE); + // send response + ke_msg_send(rsp); } - return (KE_MSG_CONSUMED); + // operation is over - go back to idle state + ke_free(hogprh_env->env[conidx]->operation); + hogprh_env->env[conidx]->operation = NULL; + ke_state_set(dest_id, HOGPRH_IDLE); + } + + return (KE_MSG_CONSUMED); } /** @@ -727,97 +733,93 @@ __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, - struct gattc_event_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_event_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state != HOGPRH_FREE) - { - // HID Instance - uint8_t hid_nb; - uint8_t report_idx; - uint8_t conidx = KE_IDX_GET(src_id); - bool finished = false; - // Get the address of the environment - struct hogprh_env_tag *hogprh_env = PRF_ENV_GET(HOGPRH, hogprh); + if (state != HOGPRH_FREE) { + // HID Instance + uint8_t hid_nb; + uint8_t report_idx; + uint8_t conidx = KE_IDX_GET(src_id); + bool finished = false; + // Get the address of the environment + struct hogprh_env_tag *hogprh_env = PRF_ENV_GET(HOGPRH, hogprh); - // BOOT Report - HID instance is unknown. - for (hid_nb = 0; (hid_nb < hogprh_env->env[conidx]->hids_nb) && !finished; hid_nb++) - { - for (report_idx = 0; (report_idx < HOGPRH_NB_REPORT_INST_MAX) && !finished; report_idx++) - { - if (param->handle == hogprh_env->env[conidx]->hids[hid_nb].chars[HOGPRH_CHAR_REPORT + report_idx].val_hdl) - { + // BOOT Report - HID instance is unknown. + for (hid_nb = 0; (hid_nb < hogprh_env->env[conidx]->hids_nb) && !finished; + hid_nb++) { + for (report_idx = 0; + (report_idx < HOGPRH_NB_REPORT_INST_MAX) && !finished; + report_idx++) { + if (param->handle == hogprh_env->env[conidx] + ->hids[hid_nb] + .chars[HOGPRH_CHAR_REPORT + report_idx] + .val_hdl) { - // Check if size of the data is lower than [ATT_MTU-3] - if (param->length < (gattc_get_mtu(conidx) - 3)) - { - // send report indication - struct hogprh_report_ind* ind = KE_MSG_ALLOC_DYN(HOGPRH_REPORT_IND, - prf_dst_task_get(&(hogprh_env->prf_env), conidx), dest_id, - hogprh_report_ind, param->length); + // Check if size of the data is lower than [ATT_MTU-3] + if (param->length < (gattc_get_mtu(conidx) - 3)) { + // send report indication + struct hogprh_report_ind *ind = KE_MSG_ALLOC_DYN( + HOGPRH_REPORT_IND, + prf_dst_task_get(&(hogprh_env->prf_env), conidx), dest_id, + hogprh_report_ind, param->length); - ind->hid_idx = hid_nb; - ind->report_idx = report_idx; - ind->report.length = param->length; - memcpy(ind->report.value, param->value, param->length); + ind->hid_idx = hid_nb; + ind->report_idx = report_idx; + ind->report.length = param->length; + memcpy(ind->report.value, param->value, param->length); - ke_msg_send(ind); - } - else - { - // data is maybe incomplete so perform an attribute read - struct hogprh_read_info_req* req = KE_MSG_ALLOC(HOGPRH_READ_INFO_REQ, - dest_id, dest_id, hogprh_read_info_req); + ke_msg_send(ind); + } else { + // data is maybe incomplete so perform an attribute read + struct hogprh_read_info_req *req = KE_MSG_ALLOC( + HOGPRH_READ_INFO_REQ, dest_id, dest_id, hogprh_read_info_req); - req->info = HOGPRH_REPORT; - req->hid_idx = hid_nb; - req->report_idx = report_idx; + req->info = HOGPRH_REPORT; + req->hid_idx = hid_nb; + req->report_idx = report_idx; - ke_msg_send(req); - } + ke_msg_send(req); + } - finished = true; - } - } + finished = true; } + } } + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } - /* * GLOBAL VARIABLE DEFINITIONS **************************************************************************************** */ /// Default State handlers definition -KE_MSG_HANDLER_TAB(hogprh) -{ - {HOGPRH_ENABLE_REQ, (ke_msg_func_t)hogprh_enable_req_handler}, - {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, +KE_MSG_HANDLER_TAB(hogprh){ + {HOGPRH_ENABLE_REQ, (ke_msg_func_t)hogprh_enable_req_handler}, + {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, - {HOGPRH_READ_INFO_REQ, (ke_msg_func_t)hogprh_read_info_req_handler}, - {HOGPRH_WRITE_REQ, (ke_msg_func_t)hogprh_write_req_handler}, + {HOGPRH_READ_INFO_REQ, (ke_msg_func_t)hogprh_read_info_req_handler}, + {HOGPRH_WRITE_REQ, (ke_msg_func_t)hogprh_write_req_handler}, - {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, - {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, + {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void hogprh_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct hogprh_env_tag *hogprh_env = PRF_ENV_GET(HOGPRH, hogprh); +void hogprh_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct hogprh_env_tag *hogprh_env = PRF_ENV_GET(HOGPRH, hogprh); - task_desc->msg_handler_tab = hogprh_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(hogprh_msg_handler_tab); - task_desc->state = hogprh_env->state; - task_desc->idx_max = HOGPRH_IDX_MAX; + task_desc->msg_handler_tab = hogprh_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(hogprh_msg_handler_tab); + task_desc->state = hogprh_env->state; + task_desc->idx_max = HOGPRH_IDX_MAX; } #endif /* (BLE_HID_REPORT_HOST) */ diff --git a/services/ble_profiles/hrp/hrpc/src/hrpc.c b/services/ble_profiles/hrp/hrpc/src/hrpc.c index c5fe7e6..1684d80 100644 --- a/services/ble_profiles/hrp/hrpc/src/hrpc.c +++ b/services/ble_profiles/hrp/hrpc/src/hrpc.c @@ -17,11 +17,11 @@ #include "hrpc.h" #include "hrpc_task.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * LOCAL FUNCTIONS DEFINITIONS @@ -40,41 +40,45 @@ * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t hrpc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t idx; - //-------------------- allocate memory required for the profile --------------------- +static uint8_t hrpc_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t idx; + //-------------------- allocate memory required for the profile + //--------------------- - struct hrpc_env_tag* hrpc_env = - (struct hrpc_env_tag* ) ke_malloc(sizeof(struct hrpc_env_tag), KE_MEM_ATT_DB); + struct hrpc_env_tag *hrpc_env = (struct hrpc_env_tag *)ke_malloc( + sizeof(struct hrpc_env_tag), KE_MEM_ATT_DB); - // allocate HRPC required environment variable - env->env = (prf_env_t*) hrpc_env; + // allocate HRPC required environment variable + env->env = (prf_env_t *)hrpc_env; - hrpc_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - hrpc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + hrpc_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + hrpc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_HRPC; - hrpc_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_HRPC; + hrpc_task_init(&(env->desc)); - for(idx = 0; idx < HRPC_IDX_MAX ; idx++) - { - hrpc_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), HRPC_FREE); - } + for (idx = 0; idx < HRPC_IDX_MAX; idx++) { + hrpc_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), HRPC_FREE); + } - return GAP_ERR_NO_ERROR; + return GAP_ERR_NO_ERROR; } /** @@ -86,44 +90,41 @@ static uint8_t hrpc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t * @param[in] reason Detach reason **************************************************************************************** */ -static void hrpc_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct hrpc_env_tag* hrpc_env = (struct hrpc_env_tag*) env->env; +static void hrpc_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct hrpc_env_tag *hrpc_env = (struct hrpc_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(hrpc_env->env[conidx] != NULL) - { - ke_free(hrpc_env->env[conidx]); - hrpc_env->env[conidx] = NULL; - } + // clean-up environment variable allocated for task instance + if (hrpc_env->env[conidx] != NULL) { + ke_free(hrpc_env->env[conidx]); + hrpc_env->env[conidx] = NULL; + } - /* Put HRP Client in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), HRPC_FREE); + /* Put HRP Client in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), HRPC_FREE); } /** **************************************************************************************** * @brief Destruction of the HRPC module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void hrpc_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct hrpc_env_tag* hrpc_env = (struct hrpc_env_tag*) env->env; +static void hrpc_destroy(struct prf_task_env *env) { + uint8_t idx; + struct hrpc_env_tag *hrpc_env = (struct hrpc_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < HRPC_IDX_MAX ; idx++) - { - hrpc_cleanup(env, idx, 0); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < HRPC_IDX_MAX; idx++) { + hrpc_cleanup(env, idx, 0); + } - // free profile environment variables - env->env = NULL; - ke_free(hrpc_env); + // free profile environment variables + env->env = NULL; + ke_free(hrpc_env); } /** @@ -134,19 +135,17 @@ static void hrpc_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void hrpc_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Put HRP Client in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), HRPC_IDLE); +static void hrpc_create(struct prf_task_env *env, uint8_t conidx) { + /* Put HRP Client in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), HRPC_IDLE); } /// HRPC Task interface required by profile manager -const struct prf_task_cbs hrpc_itf = -{ - hrpc_init, - hrpc_destroy, - hrpc_create, - hrpc_cleanup, +const struct prf_task_cbs hrpc_itf = { + hrpc_init, + hrpc_destroy, + hrpc_create, + hrpc_cleanup, }; /* @@ -154,84 +153,75 @@ const struct prf_task_cbs hrpc_itf = **************************************************************************************** */ -const struct prf_task_cbs* hrpc_prf_itf_get(void) -{ - return &hrpc_itf; -} - +const struct prf_task_cbs *hrpc_prf_itf_get(void) { return &hrpc_itf; } /* * EXPORTED FUNCTIONS DEFINITIONS **************************************************************************************** */ -void hrpc_enable_rsp_send(struct hrpc_env_tag *hrpc_env, uint8_t conidx, uint8_t status) -{ - //send APP the details of the discovered attributes on HTPT - struct hrpc_enable_rsp * rsp = KE_MSG_ALLOC( - HRPC_ENABLE_RSP, - prf_dst_task_get(&(hrpc_env->prf_env), conidx), - prf_src_task_get(&(hrpc_env->prf_env), conidx), - hrpc_enable_rsp); +void hrpc_enable_rsp_send(struct hrpc_env_tag *hrpc_env, uint8_t conidx, + uint8_t status) { + // send APP the details of the discovered attributes on HTPT + struct hrpc_enable_rsp *rsp = KE_MSG_ALLOC( + HRPC_ENABLE_RSP, prf_dst_task_get(&(hrpc_env->prf_env), conidx), + prf_src_task_get(&(hrpc_env->prf_env), conidx), hrpc_enable_rsp); - rsp->status = status; + rsp->status = status; - if (status == GAP_ERR_NO_ERROR) - { - rsp->hrs = hrpc_env->env[conidx]->hrs; - //register HRPC task in gatt for indication/notifications - prf_register_atthdl2gatt(&hrpc_env->prf_env, conidx, &hrpc_env->env[conidx]->hrs.svc); - // Go to connected state - ke_state_set(prf_src_task_get(&(hrpc_env->prf_env), conidx), HRPC_IDLE); - } + if (status == GAP_ERR_NO_ERROR) { + rsp->hrs = hrpc_env->env[conidx]->hrs; + // register HRPC task in gatt for indication/notifications + prf_register_atthdl2gatt(&hrpc_env->prf_env, conidx, + &hrpc_env->env[conidx]->hrs.svc); + // Go to connected state + ke_state_set(prf_src_task_get(&(hrpc_env->prf_env), conidx), HRPC_IDLE); + } - ke_msg_send(rsp); + ke_msg_send(rsp); } -void hrpc_unpack_meas_value(struct hrs_hr_meas* pmeas_val, uint8_t* packed_hr, uint8_t size) -{ - int8_t cursor = 0; - int8_t i = 0; +void hrpc_unpack_meas_value(struct hrs_hr_meas *pmeas_val, uint8_t *packed_hr, + uint8_t size) { + int8_t cursor = 0; + int8_t i = 0; - // Heart Rate measurement flags - pmeas_val->flags = packed_hr[0]; + // Heart Rate measurement flags + pmeas_val->flags = packed_hr[0]; + cursor += 1; + + if ((pmeas_val->flags & HRS_FLAG_HR_16BITS_VALUE) == + HRS_FLAG_HR_16BITS_VALUE) { + // Heart Rate Measurement Value 16 bits + pmeas_val->heart_rate = co_read16p(&packed_hr[cursor]); + cursor += 2; + } else { + // Heart Rate Measurement Value 8 bits + pmeas_val->heart_rate = (uint16_t)packed_hr[cursor]; cursor += 1; + } - if ((pmeas_val->flags & HRS_FLAG_HR_16BITS_VALUE) == HRS_FLAG_HR_16BITS_VALUE) - { - // Heart Rate Measurement Value 16 bits - pmeas_val->heart_rate = co_read16p(&packed_hr[cursor]); - cursor += 2; - } - else - { - // Heart Rate Measurement Value 8 bits - pmeas_val->heart_rate = (uint16_t) packed_hr[cursor]; - cursor += 1; - } + if ((pmeas_val->flags & HRS_FLAG_ENERGY_EXPENDED_PRESENT) == + HRS_FLAG_ENERGY_EXPENDED_PRESENT) { + // Energy Expended present + pmeas_val->energy_expended = co_read16p(&packed_hr[cursor]); + cursor += 2; + } - if ((pmeas_val->flags & HRS_FLAG_ENERGY_EXPENDED_PRESENT) == HRS_FLAG_ENERGY_EXPENDED_PRESENT) - { - // Energy Expended present - pmeas_val->energy_expended = co_read16p(&packed_hr[cursor]); - cursor += 2; - } + // retrieve number of rr intervals + pmeas_val->nb_rr_interval = + ((size - cursor) > 0 ? ((size - cursor) / 2) : (0)); - // retrieve number of rr intervals - pmeas_val->nb_rr_interval = ((size - cursor) > 0 ? ((size - cursor)/ 2) : (0)); - - for(i = 0 ; (i < (pmeas_val->nb_rr_interval)) && (i < (HRS_MAX_RR_INTERVAL)) ; i++) - { - // RR-Intervals - pmeas_val->rr_intervals[i] = co_read16p(&packed_hr[cursor]); - cursor += 2; - } + for (i = 0; (i < (pmeas_val->nb_rr_interval)) && (i < (HRS_MAX_RR_INTERVAL)); + i++) { + // RR-Intervals + pmeas_val->rr_intervals[i] = co_read16p(&packed_hr[cursor]); + cursor += 2; + } } -void hrpc_error_ind_send(struct hrpc_env_tag *hrpc_env, uint8_t conidx, uint8_t status) -{ - -} +void hrpc_error_ind_send(struct hrpc_env_tag *hrpc_env, uint8_t conidx, + uint8_t status) {} #endif /* (BLE_HR_COLLECTOR) */ diff --git a/services/ble_profiles/hrp/hrpc/src/hrpc_task.c b/services/ble_profiles/hrp/hrpc/src/hrpc_task.c index b61bf70..14b425d 100644 --- a/services/ble_profiles/hrp/hrpc/src/hrpc_task.c +++ b/services/ble_profiles/hrp/hrpc/src/hrpc_task.c @@ -10,16 +10,16 @@ **************************************************************************************** */ -#include "rwip_config.h" #include "hrp_common.h" +#include "rwip_config.h" #if (BLE_HR_COLLECTOR) +#include "attm.h" #include "co_utils.h" #include "gap.h" -#include "attm.h" -#include "hrpc_task.h" -#include "hrpc.h" #include "gattc_task.h" +#include "hrpc.h" +#include "hrpc_task.h" #include "ke_mem.h" @@ -28,28 +28,26 @@ **************************************************************************************** */ -/// State machine used to retrieve heart rate service characteristics information -const struct prf_char_def hrpc_hrs_char[HRPC_CHAR_MAX] = -{ +/// State machine used to retrieve heart rate service characteristics +/// information +const struct prf_char_def hrpc_hrs_char[HRPC_CHAR_MAX] = { /// Heart Rate Measurement - [HRPC_CHAR_HR_MEAS] = {ATT_CHAR_HEART_RATE_MEAS, - ATT_MANDATORY, - ATT_CHAR_PROP_NTF}, + [HRPC_CHAR_HR_MEAS] = {ATT_CHAR_HEART_RATE_MEAS, ATT_MANDATORY, + ATT_CHAR_PROP_NTF}, /// Body Sensor Location [HRPC_CHAR_BODY_SENSOR_LOCATION] = {ATT_CHAR_BODY_SENSOR_LOCATION, - ATT_OPTIONAL, - ATT_CHAR_PROP_RD}, + ATT_OPTIONAL, ATT_CHAR_PROP_RD}, /// Heart Rate Control Point - [HRPC_CHAR_HR_CNTL_POINT] = {ATT_CHAR_HEART_RATE_CNTL_POINT, - ATT_OPTIONAL, - ATT_CHAR_PROP_WR}, + [HRPC_CHAR_HR_CNTL_POINT] = {ATT_CHAR_HEART_RATE_CNTL_POINT, ATT_OPTIONAL, + ATT_CHAR_PROP_WR}, }; -/// State machine used to retrieve heart rate service characteristic description information -const struct prf_char_desc_def hrpc_hrs_char_desc[HRPC_DESC_MAX] = -{ +/// State machine used to retrieve heart rate service characteristic description +/// information +const struct prf_char_desc_def hrpc_hrs_char_desc[HRPC_DESC_MAX] = { /// Heart Rate Measurement client config - [HRPC_DESC_HR_MEAS_CLI_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, HRPC_CHAR_HR_MEAS}, + [HRPC_DESC_HR_MEAS_CLI_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, + HRPC_CHAR_HR_MEAS}, }; /* @@ -69,36 +67,35 @@ const struct prf_char_desc_def hrpc_hrs_char_desc[HRPC_DESC_MAX] = **************************************************************************************** */ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, - struct gattc_sdp_svc_ind const *ind, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_sdp_svc_ind const *ind, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == HRPC_DISCOVERING) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == HRPC_DISCOVERING) { + uint8_t conidx = KE_IDX_GET(dest_id); - struct hrpc_env_tag *hrpc_env = PRF_ENV_GET(HRPC, hrpc); + struct hrpc_env_tag *hrpc_env = PRF_ENV_GET(HRPC, hrpc); - ASSERT_INFO(hrpc_env != NULL, dest_id, src_id); - ASSERT_INFO(hrpc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(hrpc_env != NULL, dest_id, src_id); + ASSERT_INFO(hrpc_env->env[conidx] != NULL, dest_id, src_id); - if(hrpc_env->env[conidx]->nb_svc == 0) - { - // Retrieve HRS characteristics and descriptors - prf_extract_svc_info(ind, HRPC_CHAR_MAX, &hrpc_hrs_char[0], &hrpc_env->env[conidx]->hrs.chars[0], - HRPC_DESC_MAX, &hrpc_hrs_char_desc[0], &hrpc_env->env[conidx]->hrs.descs[0]); + if (hrpc_env->env[conidx]->nb_svc == 0) { + // Retrieve HRS characteristics and descriptors + prf_extract_svc_info(ind, HRPC_CHAR_MAX, &hrpc_hrs_char[0], + &hrpc_env->env[conidx]->hrs.chars[0], HRPC_DESC_MAX, + &hrpc_hrs_char_desc[0], + &hrpc_env->env[conidx]->hrs.descs[0]); - //Even if we get multiple responses we only store 1 range - hrpc_env->env[conidx]->hrs.svc.shdl = ind->start_hdl; - hrpc_env->env[conidx]->hrs.svc.ehdl = ind->end_hdl; - } - - hrpc_env->env[conidx]->nb_svc++; + // Even if we get multiple responses we only store 1 range + hrpc_env->env[conidx]->hrs.svc.shdl = ind->start_hdl; + hrpc_env->env[conidx]->hrs.svc.ehdl = ind->end_hdl; } - return (KE_MSG_CONSUMED); + hrpc_env->env[conidx]->nb_svc++; + } + + return (KE_MSG_CONSUMED); } /** @@ -113,56 +110,53 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int hrpc_enable_req_handler(ke_msg_id_t const msgid, - struct hrpc_enable_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = PRF_ERR_REQ_DISALLOWED; - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + struct hrpc_enable_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = PRF_ERR_REQ_DISALLOWED; + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); - // Heart Rate Profile Client Role Task Environment - struct hrpc_env_tag *hrpc_env = PRF_ENV_GET(HRPC, hrpc);; + uint8_t state = ke_state_get(dest_id); + // Heart Rate Profile Client Role Task Environment + struct hrpc_env_tag *hrpc_env = PRF_ENV_GET(HRPC, hrpc); + ; + + ASSERT_INFO(hrpc_env != NULL, dest_id, src_id); + // Config connection, start discovering + if ((state == HRPC_IDLE) && (hrpc_env->env[conidx] == NULL)) { + // allocate environment variable for task instance + hrpc_env->env[conidx] = (struct hrpc_cnx_env *)ke_malloc( + sizeof(struct hrpc_cnx_env), KE_MEM_ATT_DB); + memset(hrpc_env->env[conidx], 0, sizeof(struct hrpc_cnx_env)); - ASSERT_INFO(hrpc_env != NULL, dest_id, src_id); // Config connection, start discovering - if((state == HRPC_IDLE) && (hrpc_env->env[conidx] == NULL)) - { - // allocate environment variable for task instance - hrpc_env->env[conidx] = (struct hrpc_cnx_env*) ke_malloc(sizeof(struct hrpc_cnx_env),KE_MEM_ATT_DB); - memset(hrpc_env->env[conidx], 0, sizeof(struct hrpc_cnx_env)); + if (param->con_type == PRF_CON_DISCOVERY) { + // start discovering HRS on peer + prf_disc_svc_send(&(hrpc_env->prf_env), conidx, ATT_SVC_HEART_RATE); - //Config connection, start discovering - if(param->con_type == PRF_CON_DISCOVERY) - { - //start discovering HRS on peer - prf_disc_svc_send(&(hrpc_env->prf_env), conidx, ATT_SVC_HEART_RATE); + hrpc_env->env[conidx]->last_uuid_req = ATT_SVC_HEART_RATE; - hrpc_env->env[conidx]->last_uuid_req = ATT_SVC_HEART_RATE; - - // Go to DISCOVERING state - ke_state_set(dest_id, HRPC_DISCOVERING); - } - //normal connection, get saved att details - else - { - hrpc_env->env[conidx]->hrs = param->hrs; - //send APP confirmation that can start normal connection to TH - hrpc_enable_rsp_send(hrpc_env, conidx, GAP_ERR_NO_ERROR); - } - - status = GAP_ERR_NO_ERROR; + // Go to DISCOVERING state + ke_state_set(dest_id, HRPC_DISCOVERING); + } + // normal connection, get saved att details + else { + hrpc_env->env[conidx]->hrs = param->hrs; + // send APP confirmation that can start normal connection to TH + hrpc_enable_rsp_send(hrpc_env, conidx, GAP_ERR_NO_ERROR); } - // send an error if request fails - if(status != GAP_ERR_NO_ERROR) - { - hrpc_enable_rsp_send(hrpc_env, conidx, status); - } + status = GAP_ERR_NO_ERROR; + } - return (KE_MSG_CONSUMED); + // send an error if request fails + if (status != GAP_ERR_NO_ERROR) { + hrpc_enable_rsp_send(hrpc_env, conidx, status); + } + + return (KE_MSG_CONSUMED); } /** @@ -177,110 +171,90 @@ __STATIC int hrpc_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, - struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct hrpc_env_tag *hrpc_env = PRF_ENV_GET(HRPC, hrpc); - // Status - uint8_t status; + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct hrpc_env_tag *hrpc_env = PRF_ENV_GET(HRPC, hrpc); + // Status + uint8_t status; - if (hrpc_env != NULL) - { - uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); + if (hrpc_env != NULL) { + uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t state = ke_state_get(dest_id); - if(state == HRPC_DISCOVERING) - { - status = param->status; + if (state == HRPC_DISCOVERING) { + status = param->status; - if ((status == ATT_ERR_ATTRIBUTE_NOT_FOUND)|| - (status == ATT_ERR_NO_ERROR)) - { - // Discovery - // check characteristic validity - if(hrpc_env->env[conidx]->nb_svc == 1) - { - status = prf_check_svc_char_validity(HRPC_CHAR_MAX, - hrpc_env->env[conidx]->hrs.chars, - hrpc_hrs_char); - } - // too much services - else if (hrpc_env->env[conidx]->nb_svc > 1) - { - status = PRF_ERR_MULTIPLE_SVC; - } - // no services found - else - { - status = PRF_ERR_STOP_DISC_CHAR_MISSING; - } - - // check descriptor validity - if (status == GAP_ERR_NO_ERROR) - { - status = prf_check_svc_char_desc_validity(HRPC_DESC_MAX, - hrpc_env->env[conidx]->hrs.descs, - hrpc_hrs_char_desc, - hrpc_env->env[conidx]->hrs.chars); - } - } - - hrpc_enable_rsp_send(hrpc_env, conidx, status); + if ((status == ATT_ERR_ATTRIBUTE_NOT_FOUND) || + (status == ATT_ERR_NO_ERROR)) { + // Discovery + // check characteristic validity + if (hrpc_env->env[conidx]->nb_svc == 1) { + status = prf_check_svc_char_validity( + HRPC_CHAR_MAX, hrpc_env->env[conidx]->hrs.chars, hrpc_hrs_char); + } + // too much services + else if (hrpc_env->env[conidx]->nb_svc > 1) { + status = PRF_ERR_MULTIPLE_SVC; + } + // no services found + else { + status = PRF_ERR_STOP_DISC_CHAR_MISSING; } - else if(state == HRPC_BUSY) - { - switch(param->operation) - { - case GATTC_WRITE: - case GATTC_WRITE_NO_RESPONSE: - { - uint16_t rsp_msg_id = HRPC_CFG_INDNTF_RSP; - if(hrpc_env->env[conidx]->last_char_code != HRPC_DESC_HR_MEAS_CLI_CFG) - { - rsp_msg_id = HRPC_WR_CNTL_POINT_RSP; - } - - struct hrpc_cfg_indntf_rsp *rsp = KE_MSG_ALLOC(rsp_msg_id, - prf_dst_task_get(&(hrpc_env->prf_env), conidx), dest_id, - hrpc_cfg_indntf_rsp); - rsp->status = param->status; - // Send the message - ke_msg_send(rsp); - } - break; - - case GATTC_READ: - { - if(param->status != GAP_ERR_NO_ERROR) - { - // an error occurs while reading peer device attribute - prf_client_att_info_rsp( - (prf_env_t*) hrpc_env->env[conidx], - conidx, - HRPC_RD_CHAR_RSP, - param->status, - NULL); - } - } - break; - - default: break; - } - - ke_state_set(prf_src_task_get(&hrpc_env->prf_env, conidx), HRPC_IDLE); + // check descriptor validity + if (status == GAP_ERR_NO_ERROR) { + status = prf_check_svc_char_desc_validity( + HRPC_DESC_MAX, hrpc_env->env[conidx]->hrs.descs, + hrpc_hrs_char_desc, hrpc_env->env[conidx]->hrs.chars); } + } + + hrpc_enable_rsp_send(hrpc_env, conidx, status); } - return (KE_MSG_CONSUMED); + + else if (state == HRPC_BUSY) { + switch (param->operation) { + case GATTC_WRITE: + case GATTC_WRITE_NO_RESPONSE: { + uint16_t rsp_msg_id = HRPC_CFG_INDNTF_RSP; + if (hrpc_env->env[conidx]->last_char_code != + HRPC_DESC_HR_MEAS_CLI_CFG) { + rsp_msg_id = HRPC_WR_CNTL_POINT_RSP; + } + + struct hrpc_cfg_indntf_rsp *rsp = KE_MSG_ALLOC( + rsp_msg_id, prf_dst_task_get(&(hrpc_env->prf_env), conidx), dest_id, + hrpc_cfg_indntf_rsp); + rsp->status = param->status; + // Send the message + ke_msg_send(rsp); + } break; + + case GATTC_READ: { + if (param->status != GAP_ERR_NO_ERROR) { + // an error occurs while reading peer device attribute + prf_client_att_info_rsp((prf_env_t *)hrpc_env->env[conidx], conidx, + HRPC_RD_CHAR_RSP, param->status, NULL); + } + } break; + + default: + break; + } + + ke_state_set(prf_src_task_get(&hrpc_env->prf_env, conidx), HRPC_IDLE); + } + } + return (KE_MSG_CONSUMED); } /** **************************************************************************************** * @brief Handles reception of the @ref HRPC_RD_DATETIME_REQ message. - * Check if the handle exists in profile(already discovered) and send request, otherwise - * error to APP. + * Check if the handle exists in profile(already discovered) and send request, + *otherwise error to APP. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -289,81 +263,66 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int hrpc_rd_char_req_handler(ke_msg_id_t const msgid, - struct hrpc_rd_char_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - uint8_t status = PRF_ERR_REQ_DISALLOWED; - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; - // Get the address of the environment - struct hrpc_env_tag *hrpc_env = PRF_ENV_GET(HRPC, hrpc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + struct hrpc_rd_char_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + uint8_t status = PRF_ERR_REQ_DISALLOWED; + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; + // Get the address of the environment + struct hrpc_env_tag *hrpc_env = PRF_ENV_GET(HRPC, hrpc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - if(state == HRPC_IDLE) - { - ASSERT_INFO(hrpc_env != NULL, dest_id, src_id); - // environment variable not ready - if(hrpc_env->env[conidx] == NULL) - { - status = PRF_APP_ERROR; - } - else - { - uint16_t search_hdl = ATT_INVALID_SEARCH_HANDLE; + if (state == HRPC_IDLE) { + ASSERT_INFO(hrpc_env != NULL, dest_id, src_id); + // environment variable not ready + if (hrpc_env->env[conidx] == NULL) { + status = PRF_APP_ERROR; + } else { + uint16_t search_hdl = ATT_INVALID_SEARCH_HANDLE; - if(((param->char_code & HRPC_DESC_MASK) == HRPC_DESC_MASK) && - ((param->char_code & ~HRPC_DESC_MASK) < HRPC_DESC_MAX)) - { - search_hdl = hrpc_env->env[conidx]->hrs.descs[param->char_code & ~HRPC_DESC_MASK].desc_hdl; - } - else if (param->char_code < HRPC_CHAR_MAX) - { - search_hdl = hrpc_env->env[conidx]->hrs.chars[param->char_code].val_hdl; - } + if (((param->char_code & HRPC_DESC_MASK) == HRPC_DESC_MASK) && + ((param->char_code & ~HRPC_DESC_MASK) < HRPC_DESC_MAX)) { + search_hdl = hrpc_env->env[conidx] + ->hrs.descs[param->char_code & ~HRPC_DESC_MASK] + .desc_hdl; + } else if (param->char_code < HRPC_CHAR_MAX) { + search_hdl = hrpc_env->env[conidx]->hrs.chars[param->char_code].val_hdl; + } - //check if handle is viable - if (search_hdl != ATT_INVALID_SEARCH_HANDLE) - { - // Store the command - hrpc_env->env[conidx]->last_char_code = param->char_code; - // Send the read request - prf_read_char_send(&(hrpc_env->prf_env), conidx, - hrpc_env->env[conidx]->hrs.svc.shdl, - hrpc_env->env[conidx]->hrs.svc.ehdl, - search_hdl); + // check if handle is viable + if (search_hdl != ATT_INVALID_SEARCH_HANDLE) { + // Store the command + hrpc_env->env[conidx]->last_char_code = param->char_code; + // Send the read request + prf_read_char_send(&(hrpc_env->prf_env), conidx, + hrpc_env->env[conidx]->hrs.svc.shdl, + hrpc_env->env[conidx]->hrs.svc.ehdl, search_hdl); - // Go to the Busy state - ke_state_set(dest_id, HRPC_BUSY); + // Go to the Busy state + ke_state_set(dest_id, HRPC_BUSY); - status = ATT_ERR_NO_ERROR; - } - else - { - status = PRF_ERR_INEXISTENT_HDL; - } - } - } - else if (state == HRPC_FREE) - { - status = GAP_ERR_DISCONNECTED; - } - else - { - // Another procedure is pending, keep the command for later - msg_status = KE_MSG_SAVED; - status = GAP_ERR_NO_ERROR; + status = ATT_ERR_NO_ERROR; + } else { + status = PRF_ERR_INEXISTENT_HDL; + } } + } else if (state == HRPC_FREE) { + status = GAP_ERR_DISCONNECTED; + } else { + // Another procedure is pending, keep the command for later + msg_status = KE_MSG_SAVED; + status = GAP_ERR_NO_ERROR; + } - if (status != GAP_ERR_NO_ERROR) - { - prf_client_att_info_rsp(&hrpc_env->prf_env, conidx, HRPC_RD_CHAR_RSP, - status, NULL); - } + if (status != GAP_ERR_NO_ERROR) { + prf_client_att_info_rsp(&hrpc_env->prf_env, conidx, HRPC_RD_CHAR_RSP, + status, NULL); + } - return (msg_status); + return (msg_status); } /** @@ -380,24 +339,24 @@ __STATIC int hrpc_rd_char_req_handler(ke_msg_id_t const msgid, __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, struct gattc_read_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct hrpc_env_tag *hrpc_env = PRF_ENV_GET(HRPC, hrpc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + ke_task_id_t const src_id) { + // Get the address of the environment + struct hrpc_env_tag *hrpc_env = PRF_ENV_GET(HRPC, hrpc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - prf_client_att_info_rsp(&hrpc_env->prf_env, conidx, HRPC_RD_CHAR_RSP, - GAP_ERR_NO_ERROR, param); + prf_client_att_info_rsp(&hrpc_env->prf_env, conidx, HRPC_RD_CHAR_RSP, + GAP_ERR_NO_ERROR, param); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** **************************************************************************************** * @brief Handles reception of the @ref HRPC_CFG_INDNTF_REQ message. - * It allows configuration of the peer ind/ntf/stop characteristic for a specified characteristic. - * Will return an error code if that cfg char does not exist. + * It allows configuration of the peer ind/ntf/stop characteristic for a + *specified characteristic. Will return an error code if that cfg char does not + *exist. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -405,83 +364,73 @@ __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int hrpc_cfg_indntf_req_handler(ke_msg_id_t const msgid, - struct hrpc_cfg_indntf_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct hrpc_env_tag *hrpc_env = PRF_ENV_GET(HRPC, hrpc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); - // Status - uint8_t status = PRF_ERR_REQ_DISALLOWED; +__STATIC int hrpc_cfg_indntf_req_handler( + ke_msg_id_t const msgid, struct hrpc_cfg_indntf_req const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Get the address of the environment + struct hrpc_env_tag *hrpc_env = PRF_ENV_GET(HRPC, hrpc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); + // Status + uint8_t status = PRF_ERR_REQ_DISALLOWED; - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; - uint8_t state = ke_state_get(dest_id); + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; + uint8_t state = ke_state_get(dest_id); - if(state == HRPC_IDLE) - { - if(hrpc_env->env[conidx] != NULL) - { + if (state == HRPC_IDLE) { + if (hrpc_env->env[conidx] != NULL) { - // Status - status = PRF_ERR_INVALID_PARAM; - // Check if parameter is OK - if((param->cfg_val == PRF_CLI_STOP_NTFIND) || - (param->cfg_val == PRF_CLI_START_NTF)) - { - // Status - status = PRF_ERR_INEXISTENT_HDL; - // Get handle of the client configuration - uint16_t cfg_hdl = - hrpc_env->env[conidx]->hrs.descs[HRPC_DESC_HR_MEAS_CLI_CFG].desc_hdl; - //check if the handle value exists - if (cfg_hdl != ATT_INVALID_SEARCH_HANDLE) - { - hrpc_env->env[conidx]->last_char_code = HRPC_DESC_HR_MEAS_CLI_CFG; + // Status + status = PRF_ERR_INVALID_PARAM; + // Check if parameter is OK + if ((param->cfg_val == PRF_CLI_STOP_NTFIND) || + (param->cfg_val == PRF_CLI_START_NTF)) { + // Status + status = PRF_ERR_INEXISTENT_HDL; + // Get handle of the client configuration + uint16_t cfg_hdl = hrpc_env->env[conidx] + ->hrs.descs[HRPC_DESC_HR_MEAS_CLI_CFG] + .desc_hdl; + // check if the handle value exists + if (cfg_hdl != ATT_INVALID_SEARCH_HANDLE) { + hrpc_env->env[conidx]->last_char_code = HRPC_DESC_HR_MEAS_CLI_CFG; - status = GAP_ERR_NO_ERROR; - // Go to the Busy state - ke_state_set(dest_id, HRPC_BUSY); - // Send GATT Write Request - prf_gatt_write_ntf_ind(&hrpc_env->prf_env, conidx, cfg_hdl, param->cfg_val); - } - } - } - else - { - status = PRF_APP_ERROR; + status = GAP_ERR_NO_ERROR; + // Go to the Busy state + ke_state_set(dest_id, HRPC_BUSY); + // Send GATT Write Request + prf_gatt_write_ntf_ind(&hrpc_env->prf_env, conidx, cfg_hdl, + param->cfg_val); } + } + } else { + status = PRF_APP_ERROR; } - else if (state == HRPC_FREE) - { - status = GAP_ERR_DISCONNECTED; - } - else - { - // Another procedure is pending, keep the command for later - msg_status = KE_MSG_SAVED; - status = GAP_ERR_NO_ERROR; - } + } else if (state == HRPC_FREE) { + status = GAP_ERR_DISCONNECTED; + } else { + // Another procedure is pending, keep the command for later + msg_status = KE_MSG_SAVED; + status = GAP_ERR_NO_ERROR; + } - if (status != GAP_ERR_NO_ERROR) - { - struct hrpc_cfg_indntf_rsp *rsp = KE_MSG_ALLOC(HRPC_CFG_INDNTF_RSP, src_id, dest_id, hrpc_cfg_indntf_rsp); - rsp->status = status; - // Send the message - ke_msg_send(rsp); - } + if (status != GAP_ERR_NO_ERROR) { + struct hrpc_cfg_indntf_rsp *rsp = + KE_MSG_ALLOC(HRPC_CFG_INDNTF_RSP, src_id, dest_id, hrpc_cfg_indntf_rsp); + rsp->status = status; + // Send the message + ke_msg_send(rsp); + } - return (msg_status); + return (msg_status); } /** **************************************************************************************** * @brief Handles reception of the @ref HRPC_WR_CNTL_POINT_REQ message. -* Check if the handle exists in profile(already discovered) and send request, otherwise -* error to APP. +* Check if the handle exists in profile(already discovered) and send request, +*otherwise error to APP. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -489,76 +438,66 @@ __STATIC int hrpc_cfg_indntf_req_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int hrpc_wr_cntl_point_req_handler(ke_msg_id_t const msgid, - struct hrpc_wr_cntl_point_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct hrpc_env_tag *hrpc_env = PRF_ENV_GET(HRPC, hrpc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t status = GAP_ERR_NO_ERROR; +__STATIC int hrpc_wr_cntl_point_req_handler( + ke_msg_id_t const msgid, struct hrpc_wr_cntl_point_req const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Get the address of the environment + struct hrpc_env_tag *hrpc_env = PRF_ENV_GET(HRPC, hrpc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t status = GAP_ERR_NO_ERROR; - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; - uint8_t state = ke_state_get(dest_id); + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; + uint8_t state = ke_state_get(dest_id); - if(state == HRPC_IDLE) - { - //this is mandatory readable if it is included in the peer's DB - if(hrpc_env->env[conidx] != NULL) - { - //this is mandatory readable if it is included in the peer's DB - if (hrpc_env->env[conidx]->hrs.chars[HRPC_CHAR_HR_CNTL_POINT].char_hdl != ATT_INVALID_SEARCH_HANDLE) - { - if ((hrpc_env->env[conidx]->hrs.chars[HRPC_CHAR_HR_CNTL_POINT].prop & ATT_CHAR_PROP_WR) == ATT_CHAR_PROP_WR) - { - hrpc_env->env[conidx]->last_char_code = HRPC_CHAR_HR_CNTL_POINT; + if (state == HRPC_IDLE) { + // this is mandatory readable if it is included in the peer's DB + if (hrpc_env->env[conidx] != NULL) { + // this is mandatory readable if it is included in the peer's DB + if (hrpc_env->env[conidx]->hrs.chars[HRPC_CHAR_HR_CNTL_POINT].char_hdl != + ATT_INVALID_SEARCH_HANDLE) { + if ((hrpc_env->env[conidx]->hrs.chars[HRPC_CHAR_HR_CNTL_POINT].prop & + ATT_CHAR_PROP_WR) == ATT_CHAR_PROP_WR) { + hrpc_env->env[conidx]->last_char_code = HRPC_CHAR_HR_CNTL_POINT; - // Send GATT Write Request - prf_gatt_write(&hrpc_env->prf_env, conidx, hrpc_env->env[conidx]->hrs.chars[HRPC_CHAR_HR_CNTL_POINT].val_hdl, - (uint8_t *)¶m->val, sizeof(uint8_t), GATTC_WRITE); - // Go to the Busy state - ke_state_set(dest_id, HRPC_BUSY); - } - //write not allowed, so no point in continuing - else - { - status = PRF_ERR_NOT_WRITABLE; - } - } - //send app error indication for inexistent handle for this characteristic - else - { - status = PRF_ERR_INEXISTENT_HDL; - } + // Send GATT Write Request + prf_gatt_write( + &hrpc_env->prf_env, conidx, + hrpc_env->env[conidx]->hrs.chars[HRPC_CHAR_HR_CNTL_POINT].val_hdl, + (uint8_t *)¶m->val, sizeof(uint8_t), GATTC_WRITE); + // Go to the Busy state + ke_state_set(dest_id, HRPC_BUSY); } - else - { - status = PRF_APP_ERROR; + // write not allowed, so no point in continuing + else { + status = PRF_ERR_NOT_WRITABLE; } + } + // send app error indication for inexistent handle for this characteristic + else { + status = PRF_ERR_INEXISTENT_HDL; + } + } else { + status = PRF_APP_ERROR; } - else if (state == HRPC_FREE) - { - status = GAP_ERR_DISCONNECTED; - } - else - { - // Another procedure is pending, keep the command for later - msg_status = KE_MSG_SAVED; - status = GAP_ERR_NO_ERROR; - } + } else if (state == HRPC_FREE) { + status = GAP_ERR_DISCONNECTED; + } else { + // Another procedure is pending, keep the command for later + msg_status = KE_MSG_SAVED; + status = GAP_ERR_NO_ERROR; + } - if(status != GAP_ERR_NO_ERROR) - { - struct hrpc_wr_cntl_point_rsp *rsp = KE_MSG_ALLOC(HRPC_WR_CNTL_POINT_RSP, src_id, dest_id, hrpc_wr_cntl_point_rsp); - rsp->status = status; - // Send the message - ke_msg_send(rsp); - } + if (status != GAP_ERR_NO_ERROR) { + struct hrpc_wr_cntl_point_rsp *rsp = KE_MSG_ALLOC( + HRPC_WR_CNTL_POINT_RSP, src_id, dest_id, hrpc_wr_cntl_point_rsp); + rsp->status = status; + // Send the message + ke_msg_send(rsp); + } - return (msg_status); + return (msg_status); } /** @@ -572,33 +511,30 @@ __STATIC int hrpc_wr_cntl_point_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, - struct gattc_event_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct hrpc_env_tag *hrpc_env = PRF_ENV_GET(HRPC, hrpc); + struct gattc_event_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct hrpc_env_tag *hrpc_env = PRF_ENV_GET(HRPC, hrpc); - if(hrpc_env != NULL) - { - if((param->handle == hrpc_env->env[conidx]->hrs.chars[HRPC_CHAR_HR_MEAS].val_hdl) && - (param->type == GATTC_NOTIFY)) - { - //build a HRPC_HR_MEAS_IND message with stable heart rate value code. - struct hrpc_hr_meas_ind * ind = KE_MSG_ALLOC( - HRPC_HR_MEAS_IND, - prf_dst_task_get(&(hrpc_env->prf_env), conidx), - prf_src_task_get(&(hrpc_env->prf_env), conidx), - hrpc_hr_meas_ind); + if (hrpc_env != NULL) { + if ((param->handle == + hrpc_env->env[conidx]->hrs.chars[HRPC_CHAR_HR_MEAS].val_hdl) && + (param->type == GATTC_NOTIFY)) { + // build a HRPC_HR_MEAS_IND message with stable heart rate value code. + struct hrpc_hr_meas_ind *ind = KE_MSG_ALLOC( + HRPC_HR_MEAS_IND, prf_dst_task_get(&(hrpc_env->prf_env), conidx), + prf_src_task_get(&(hrpc_env->prf_env), conidx), hrpc_hr_meas_ind); - // unpack heart rate measurement. - hrpc_unpack_meas_value(&(ind->meas_val), (uint8_t*) param->value, param->length); + // unpack heart rate measurement. + hrpc_unpack_meas_value(&(ind->meas_val), (uint8_t *)param->value, + param->length); - ke_msg_send(ind); - } + ke_msg_send(ind); } - return (KE_MSG_CONSUMED); + } + return (KE_MSG_CONSUMED); } /* @@ -606,27 +542,25 @@ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ /// Specifies the default message handlers -KE_MSG_HANDLER_TAB(hrpc) -{ - {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, - {HRPC_ENABLE_REQ, (ke_msg_func_t)hrpc_enable_req_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, - {HRPC_CFG_INDNTF_REQ, (ke_msg_func_t)hrpc_cfg_indntf_req_handler}, - {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, - {HRPC_RD_CHAR_REQ, (ke_msg_func_t)hrpc_rd_char_req_handler}, - {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, - {HRPC_WR_CNTL_POINT_REQ, (ke_msg_func_t)hrpc_wr_cntl_point_req_handler}, +KE_MSG_HANDLER_TAB(hrpc){ + {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, + {HRPC_ENABLE_REQ, (ke_msg_func_t)hrpc_enable_req_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, + {HRPC_CFG_INDNTF_REQ, (ke_msg_func_t)hrpc_cfg_indntf_req_handler}, + {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {HRPC_RD_CHAR_REQ, (ke_msg_func_t)hrpc_rd_char_req_handler}, + {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, + {HRPC_WR_CNTL_POINT_REQ, (ke_msg_func_t)hrpc_wr_cntl_point_req_handler}, }; -void hrpc_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct hrpc_env_tag *hrpc_env = PRF_ENV_GET(HRPC, hrpc); +void hrpc_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct hrpc_env_tag *hrpc_env = PRF_ENV_GET(HRPC, hrpc); - task_desc->msg_handler_tab = hrpc_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(hrpc_msg_handler_tab); - task_desc->state = hrpc_env->state; - task_desc->idx_max = HRPC_IDX_MAX; + task_desc->msg_handler_tab = hrpc_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(hrpc_msg_handler_tab); + task_desc->state = hrpc_env->state; + task_desc->idx_max = HRPC_IDX_MAX; } #endif /* (BLE_HR_COLLECTOR) */ diff --git a/services/ble_profiles/hrp/hrps/src/hrps.c b/services/ble_profiles/hrp/hrps/src/hrps.c index f56bbe7..fbe7dcf 100644 --- a/services/ble_profiles/hrp/hrps/src/hrps.c +++ b/services/ble_profiles/hrp/hrps/src/hrps.c @@ -12,16 +12,16 @@ #include "rwip_config.h" #if (BLE_HR_SENSOR) -#include "gap.h" -#include "gattc_task.h" #include "attm.h" +#include "gap.h" #include "gapc_task.h" +#include "gattc_task.h" #include "hrps.h" #include "hrps_task.h" #include "prf_utils.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * HTPT PROFILE ATTRIBUTES @@ -29,27 +29,36 @@ */ /// Full HRS Database Description - Used to add attributes into the database -const struct attm_desc hrps_att_db[HRS_IDX_NB] = -{ +const struct attm_desc hrps_att_db[HRS_IDX_NB] = { // Heart Rate Service Declaration - [HRS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [HRS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // Heart Rate Measurement Characteristic Declaration - [HRS_IDX_HR_MEAS_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [HRS_IDX_HR_MEAS_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, // Heart Rate Measurement Characteristic Value - [HRS_IDX_HR_MEAS_VAL] = {ATT_CHAR_HEART_RATE_MEAS, PERM(NTF, ENABLE), PERM(RI, ENABLE), HRPS_HT_MEAS_MAX_LEN}, - // Heart Rate Measurement Characteristic - Client Characteristic Configuration Descriptor - [HRS_IDX_HR_MEAS_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [HRS_IDX_HR_MEAS_VAL] = {ATT_CHAR_HEART_RATE_MEAS, PERM(NTF, ENABLE), + PERM(RI, ENABLE), HRPS_HT_MEAS_MAX_LEN}, + // Heart Rate Measurement Characteristic - Client Characteristic + // Configuration Descriptor + [HRS_IDX_HR_MEAS_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, + 0}, // Body Sensor Location Characteristic Declaration - [HRS_IDX_BODY_SENSOR_LOC_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [HRS_IDX_BODY_SENSOR_LOC_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), + 0, 0}, // Body Sensor Location Characteristic Value - [HRS_IDX_BODY_SENSOR_LOC_VAL] = {ATT_CHAR_BODY_SENSOR_LOCATION, PERM(RD, ENABLE), PERM(RI, ENABLE), sizeof(uint8_t)}, + [HRS_IDX_BODY_SENSOR_LOC_VAL] = {ATT_CHAR_BODY_SENSOR_LOCATION, + PERM(RD, ENABLE), PERM(RI, ENABLE), + sizeof(uint8_t)}, // Heart Rate Control Point Characteristic Declaration - [HRS_IDX_HR_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [HRS_IDX_HR_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Heart Rate Control Point Characteristic Value - [HRS_IDX_HR_CTNL_PT_VAL] = {ATT_CHAR_HEART_RATE_CNTL_POINT, PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE), sizeof(uint8_t)}, + [HRS_IDX_HR_CTNL_PT_VAL] = {ATT_CHAR_HEART_RATE_CNTL_POINT, + PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE), + sizeof(uint8_t)}, }; /** @@ -64,87 +73,90 @@ const struct attm_desc hrps_att_db[HRS_IDX_NB] = * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t hrps_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, struct hrps_db_cfg* params) -{ - //------------------ create the attribute database for the profile ------------------- - //Service Configuration Flag - uint8_t cfg_flag = HRPS_MANDATORY_MASK; - //Database Creation Status - uint8_t status = ATT_ERR_NO_ERROR; +static uint8_t hrps_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, + struct hrps_db_cfg *params) { + //------------------ create the attribute database for the profile + //------------------- Service Configuration Flag + uint8_t cfg_flag = HRPS_MANDATORY_MASK; + // Database Creation Status + uint8_t status = ATT_ERR_NO_ERROR; - //Set Configuration Flag Value - if (HRPS_IS_SUPPORTED(params->features, HRPS_BODY_SENSOR_LOC_CHAR_SUP)) - { - cfg_flag |= HRPS_BODY_SENSOR_LOC_MASK; - } - if (HRPS_IS_SUPPORTED(params->features, HRPS_ENGY_EXP_FEAT_SUP)) - { - cfg_flag |= HRPS_HR_CTNL_PT_MASK; - } + // Set Configuration Flag Value + if (HRPS_IS_SUPPORTED(params->features, HRPS_BODY_SENSOR_LOC_CHAR_SUP)) { + cfg_flag |= HRPS_BODY_SENSOR_LOC_MASK; + } + if (HRPS_IS_SUPPORTED(params->features, HRPS_ENGY_EXP_FEAT_SUP)) { + cfg_flag |= HRPS_HR_CTNL_PT_MASK; + } - //Add Service Into Database - status = attm_svc_create_db(start_hdl, ATT_SVC_HEART_RATE, (uint8_t *)&cfg_flag, - HRS_IDX_NB, NULL, env->task, &hrps_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS))| PERM(SVC_MI, DISABLE)); + // Add Service Into Database + status = attm_svc_create_db( + start_hdl, ATT_SVC_HEART_RATE, (uint8_t *)&cfg_flag, HRS_IDX_NB, NULL, + env->task, &hrps_att_db[0], + (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, DISABLE)); - //-------------------- allocate memory required for the profile --------------------- - if (status == ATT_ERR_NO_ERROR) - { - // Allocate HRPS required environment variable - struct hrps_env_tag* hrps_env = - (struct hrps_env_tag* ) ke_malloc(sizeof(struct hrps_env_tag), KE_MEM_ATT_DB); + //-------------------- allocate memory required for the profile + //--------------------- + if (status == ATT_ERR_NO_ERROR) { + // Allocate HRPS required environment variable + struct hrps_env_tag *hrps_env = (struct hrps_env_tag *)ke_malloc( + sizeof(struct hrps_env_tag), KE_MEM_ATT_DB); - // Initialize HRPS environment - env->env = (prf_env_t*) hrps_env; - hrps_env->shdl = *start_hdl; - hrps_env->features = params->features; - hrps_env->sensor_location = params->body_sensor_loc; - hrps_env->operation = NULL; + // Initialize HRPS environment + env->env = (prf_env_t *)hrps_env; + hrps_env->shdl = *start_hdl; + hrps_env->features = params->features; + hrps_env->sensor_location = params->body_sensor_loc; + hrps_env->operation = NULL; - hrps_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - // Mono Instantiated task - hrps_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); + hrps_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + // Mono Instantiated task + hrps_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); - // initialize environment variable - env->id = TASK_ID_HRPS; - hrps_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_HRPS; + hrps_task_init(&(env->desc)); - /* Put HRS in Idle state */ - ke_state_set(env->task, HRPS_IDLE); - } + /* Put HRS in Idle state */ + ke_state_set(env->task, HRPS_IDLE); + } - return (status); + return (status); } /** **************************************************************************************** * @brief Destruction of the HRPS module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void hrps_destroy(struct prf_task_env* env) -{ - struct hrps_env_tag* hrps_env = (struct hrps_env_tag*) env->env; +static void hrps_destroy(struct prf_task_env *env) { + struct hrps_env_tag *hrps_env = (struct hrps_env_tag *)env->env; - // free profile environment variables - if(hrps_env->operation != NULL) - { - ke_free(hrps_env->operation); - } - env->env = NULL; - ke_free(hrps_env); + // free profile environment variables + if (hrps_env->operation != NULL) { + ke_free(hrps_env->operation); + } + env->env = NULL; + ke_free(hrps_env); } /** @@ -155,9 +167,8 @@ static void hrps_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void hrps_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Nothing to do */ +static void hrps_create(struct prf_task_env *env, uint8_t conidx) { + /* Nothing to do */ } /** @@ -169,9 +180,9 @@ static void hrps_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void hrps_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - /* Nothing to do */ +static void hrps_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + /* Nothing to do */ } /* @@ -180,12 +191,11 @@ static void hrps_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reaso */ /// HRPS Task interface required by profile manager -const struct prf_task_cbs hrps_itf = -{ - (prf_init_fnct) hrps_init, - hrps_destroy, - hrps_create, - hrps_cleanup, +const struct prf_task_cbs hrps_itf = { + (prf_init_fnct)hrps_init, + hrps_destroy, + hrps_create, + hrps_cleanup, }; /* @@ -193,130 +203,119 @@ const struct prf_task_cbs hrps_itf = **************************************************************************************** */ -const struct prf_task_cbs* hrps_prf_itf_get(void) -{ - return &hrps_itf; -} - +const struct prf_task_cbs *hrps_prf_itf_get(void) { return &hrps_itf; } /* * EXPORTED FUNCTIONS DEFINITIONS **************************************************************************************** */ -void hrps_meas_send_rsp_send(uint8_t status) -{ - // Get the address of the environment - struct hrps_env_tag *hrps_env = PRF_ENV_GET(HRPS, hrps); +void hrps_meas_send_rsp_send(uint8_t status) { + // Get the address of the environment + struct hrps_env_tag *hrps_env = PRF_ENV_GET(HRPS, hrps); - // Send CFM to APP that value has been sent or not - struct hrps_meas_send_rsp * cfm = KE_MSG_ALLOC( - HRPS_MEAS_SEND_RSP, - prf_dst_task_get(&hrps_env->prf_env, 0), - prf_src_task_get(&hrps_env->prf_env, 0), - hrps_meas_send_rsp); + // Send CFM to APP that value has been sent or not + struct hrps_meas_send_rsp *cfm = + KE_MSG_ALLOC(HRPS_MEAS_SEND_RSP, prf_dst_task_get(&hrps_env->prf_env, 0), + prf_src_task_get(&hrps_env->prf_env, 0), hrps_meas_send_rsp); - cfm->status = status; + cfm->status = status; - ke_msg_send(cfm); + ke_msg_send(cfm); } -uint8_t hrps_pack_meas_value(uint8_t *packed_hr, const struct hrs_hr_meas* pmeas_val) -{ - uint8_t cursor = 0; - uint8_t i = 0; +uint8_t hrps_pack_meas_value(uint8_t *packed_hr, + const struct hrs_hr_meas *pmeas_val) { + uint8_t cursor = 0; + uint8_t i = 0; - // Heart Rate measurement flags - *(packed_hr) = pmeas_val->flags; + // Heart Rate measurement flags + *(packed_hr) = pmeas_val->flags; - if ((pmeas_val->flags & HRS_FLAG_HR_16BITS_VALUE) == HRS_FLAG_HR_16BITS_VALUE) - { - // Heart Rate Measurement Value 16 bits - co_write16p(packed_hr + 1, pmeas_val->heart_rate); - cursor += 3; - } - else - { - // Heart Rate Measurement Value 8 bits - *(packed_hr + 1) = pmeas_val->heart_rate; - cursor += 2; + if ((pmeas_val->flags & HRS_FLAG_HR_16BITS_VALUE) == + HRS_FLAG_HR_16BITS_VALUE) { + // Heart Rate Measurement Value 16 bits + co_write16p(packed_hr + 1, pmeas_val->heart_rate); + cursor += 3; + } else { + // Heart Rate Measurement Value 8 bits + *(packed_hr + 1) = pmeas_val->heart_rate; + cursor += 2; + } + + if ((pmeas_val->flags & HRS_FLAG_ENERGY_EXPENDED_PRESENT) == + HRS_FLAG_ENERGY_EXPENDED_PRESENT) { + // Energy Expended present + co_write16p(packed_hr + cursor, pmeas_val->energy_expended); + cursor += 2; + } + + if ((pmeas_val->flags & HRS_FLAG_RR_INTERVAL_PRESENT) == + HRS_FLAG_RR_INTERVAL_PRESENT) { + for (i = 0; + (i < (pmeas_val->nb_rr_interval)) && (i < (HRS_MAX_RR_INTERVAL)); + i++) { + // RR-Intervals + co_write16p(packed_hr + cursor, pmeas_val->rr_intervals[i]); + cursor += 2; } + } - if ((pmeas_val->flags & HRS_FLAG_ENERGY_EXPENDED_PRESENT) == HRS_FLAG_ENERGY_EXPENDED_PRESENT) - { - // Energy Expended present - co_write16p(packed_hr + cursor, pmeas_val->energy_expended); - cursor += 2; - } + // Clear unused packet data + if (cursor < HRPS_HT_MEAS_MAX_LEN) { + memset(packed_hr + cursor, 0, HRPS_HT_MEAS_MAX_LEN - cursor); + } - if ((pmeas_val->flags & HRS_FLAG_RR_INTERVAL_PRESENT) == HRS_FLAG_RR_INTERVAL_PRESENT) - { - for(i = 0 ; (i < (pmeas_val->nb_rr_interval)) && (i < (HRS_MAX_RR_INTERVAL)) ; i++) - { - // RR-Intervals - co_write16p(packed_hr + cursor, pmeas_val->rr_intervals[i]); - cursor += 2; - } - } - - // Clear unused packet data - if(cursor < HRPS_HT_MEAS_MAX_LEN) - { - memset(packed_hr + cursor, 0, HRPS_HT_MEAS_MAX_LEN - cursor); - } - - return cursor; + return cursor; } +void hrps_exe_operation(void) { + struct hrps_env_tag *hrps_env = PRF_ENV_GET(HRPS, hrps); -void hrps_exe_operation(void) -{ - struct hrps_env_tag *hrps_env = PRF_ENV_GET(HRPS, hrps); + ASSERT_ERR(hrps_env->operation != NULL); - ASSERT_ERR(hrps_env->operation != NULL); + bool finished = true; - bool finished = true; + while (hrps_env->operation->cursor < BLE_CONNECTION_MAX) { + // Check if notifications are enabled + if ((hrps_env->hr_meas_ntf[hrps_env->operation->cursor] & + ~HRP_PRF_CFG_PERFORMED_OK) == PRF_CLI_START_NTF) { + // Allocate the GATT notification message + struct gattc_send_evt_cmd *meas_val = + KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, + KE_BUILD_ID(TASK_GATTC, hrps_env->operation->cursor), + prf_src_task_get(&(hrps_env->prf_env), 0), + gattc_send_evt_cmd, hrps_env->operation->length); - while(hrps_env->operation->cursor < BLE_CONNECTION_MAX) - { - // Check if notifications are enabled - if((hrps_env->hr_meas_ntf[hrps_env->operation->cursor] & ~HRP_PRF_CFG_PERFORMED_OK) == PRF_CLI_START_NTF) - { - // Allocate the GATT notification message - struct gattc_send_evt_cmd *meas_val = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, hrps_env->operation->cursor), - prf_src_task_get(&(hrps_env->prf_env), 0), - gattc_send_evt_cmd, hrps_env->operation->length); + // Fill in the parameter structure + meas_val->operation = GATTC_NOTIFY; + meas_val->handle = hrps_env->shdl + HRS_IDX_HR_MEAS_VAL; + meas_val->length = hrps_env->operation->length; + memcpy(meas_val->value, hrps_env->operation->data, + hrps_env->operation->length); - // Fill in the parameter structure - meas_val->operation = GATTC_NOTIFY; - meas_val->handle = hrps_env->shdl + HRS_IDX_HR_MEAS_VAL; - meas_val->length = hrps_env->operation->length; - memcpy(meas_val->value, hrps_env->operation->data, hrps_env->operation->length); + // Send the event + ke_msg_send(meas_val); - // Send the event - ke_msg_send(meas_val); - - finished = false; - hrps_env->operation->cursor++; - break; - } - - hrps_env->operation->cursor++; + finished = false; + hrps_env->operation->cursor++; + break; } - // check if operation is finished - if(finished) - { - // Send confirmation - hrps_meas_send_rsp_send(GAP_ERR_NO_ERROR); + hrps_env->operation->cursor++; + } - // free operation - ke_free(hrps_env->operation); - hrps_env->operation = NULL; - // go back to idle state - ke_state_set(prf_src_task_get(&(hrps_env->prf_env), 0), HRPS_IDLE); - } + // check if operation is finished + if (finished) { + // Send confirmation + hrps_meas_send_rsp_send(GAP_ERR_NO_ERROR); + + // free operation + ke_free(hrps_env->operation); + hrps_env->operation = NULL; + // go back to idle state + ke_state_set(prf_src_task_get(&(hrps_env->prf_env), 0), HRPS_IDLE); + } } #endif /* BLE_HR_SENSOR */ diff --git a/services/ble_profiles/hrp/hrps/src/hrps_task.c b/services/ble_profiles/hrp/hrps/src/hrps_task.c index fab0781..76ca159 100644 --- a/services/ble_profiles/hrp/hrps/src/hrps_task.c +++ b/services/ble_profiles/hrp/hrps/src/hrps_task.c @@ -12,16 +12,16 @@ #include "rwip_config.h" #if (BLE_HR_SENSOR) +#include "attm.h" #include "gap.h" #include "gattc_task.h" -#include "attm.h" #include "hrps.h" #include "hrps_task.h" #include "prf_utils.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * LOCAL FUNCTIONS DEFINITIONS @@ -40,44 +40,40 @@ **************************************************************************************** */ __STATIC int hrps_enable_req_handler(ke_msg_id_t const msgid, - struct hrps_enable_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct hrps_env_tag *hrps_env = PRF_ENV_GET(HRPS, hrps); + struct hrps_enable_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct hrps_env_tag *hrps_env = PRF_ENV_GET(HRPS, hrps); - // Status - uint8_t status = PRF_ERR_REQ_DISALLOWED; + // Status + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if(ke_state_get(dest_id) == HRPS_IDLE) - { - if ((param->conidx < BLE_CONNECTION_MAX) && - (param->hr_meas_ntf <= PRF_CLI_START_NTF)) - { - // Bonded data was not used before - if (!HRPS_IS_SUPPORTED(hrps_env->hr_meas_ntf[param->conidx], HRP_PRF_CFG_PERFORMED_OK)) - { - // Save notification config - hrps_env->hr_meas_ntf[param->conidx] = param->hr_meas_ntf; - // Enable Bonded Data - hrps_env->hr_meas_ntf[param->conidx] |= HRP_PRF_CFG_PERFORMED_OK; - status = GAP_ERR_NO_ERROR; - } - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } + if (ke_state_get(dest_id) == HRPS_IDLE) { + if ((param->conidx < BLE_CONNECTION_MAX) && + (param->hr_meas_ntf <= PRF_CLI_START_NTF)) { + // Bonded data was not used before + if (!HRPS_IS_SUPPORTED(hrps_env->hr_meas_ntf[param->conidx], + HRP_PRF_CFG_PERFORMED_OK)) { + // Save notification config + hrps_env->hr_meas_ntf[param->conidx] = param->hr_meas_ntf; + // Enable Bonded Data + hrps_env->hr_meas_ntf[param->conidx] |= HRP_PRF_CFG_PERFORMED_OK; + status = GAP_ERR_NO_ERROR; + } + } else { + status = PRF_ERR_INVALID_PARAM; + } + } - // send completed information to APP task that contains error status - struct hrps_enable_rsp *cmp_evt = KE_MSG_ALLOC(HRPS_ENABLE_RSP, src_id, dest_id, hrps_enable_rsp); - cmp_evt->status = status; - cmp_evt->conidx = param->conidx; - ke_msg_send(cmp_evt); + // send completed information to APP task that contains error status + struct hrps_enable_rsp *cmp_evt = + KE_MSG_ALLOC(HRPS_ENABLE_RSP, src_id, dest_id, hrps_enable_rsp); + cmp_evt->status = status; + cmp_evt->conidx = param->conidx; + ke_msg_send(cmp_evt); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -91,52 +87,48 @@ __STATIC int hrps_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int hrps_meas_send_req_handler(ke_msg_id_t const msgid, - struct hrps_meas_send_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; + struct hrps_meas_send_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; - // State shall not be Connected or Busy - if (ke_state_get(dest_id) == HRPS_IDLE) - { - if(param->meas_val.nb_rr_interval <= HRS_MAX_RR_INTERVAL) - { + // State shall not be Connected or Busy + if (ke_state_get(dest_id) == HRPS_IDLE) { + if (param->meas_val.nb_rr_interval <= HRS_MAX_RR_INTERVAL) { - // Get the address of the environment - struct hrps_env_tag *hrps_env = PRF_ENV_GET(HRPS, hrps); + // Get the address of the environment + struct hrps_env_tag *hrps_env = PRF_ENV_GET(HRPS, hrps); - // allocate and prepare data to notify - hrps_env->operation = (struct hrps_op*) ke_malloc(sizeof(struct hrps_op), KE_MEM_KE_MSG); - hrps_env->operation->length = hrps_pack_meas_value(hrps_env->operation->data, ¶m->meas_val); - hrps_env->operation->cursor = 0; + // allocate and prepare data to notify + hrps_env->operation = + (struct hrps_op *)ke_malloc(sizeof(struct hrps_op), KE_MEM_KE_MSG); + hrps_env->operation->length = + hrps_pack_meas_value(hrps_env->operation->data, ¶m->meas_val); + hrps_env->operation->cursor = 0; - // start operation execution - hrps_exe_operation(); + // start operation execution + hrps_exe_operation(); - // Go to busy state - ke_state_set(dest_id, HRPS_BUSY); - } - else - { - // Send confirmation - hrps_meas_send_rsp_send(PRF_ERR_INVALID_PARAM); - } - } - else - { - // Save it for later - msg_status = KE_MSG_SAVED; + // Go to busy state + ke_state_set(dest_id, HRPS_BUSY); + } else { + // Send confirmation + hrps_meas_send_rsp_send(PRF_ERR_INVALID_PARAM); } + } else { + // Save it for later + msg_status = KE_MSG_SAVED; + } - return (msg_status); + return (msg_status); } /** **************************************************************************************** * @brief Handles reception of the @ref GL2C_CODE_ATT_WR_CMD_IND message. - * The handler compares the new values with current ones and notifies them if they changed. + * The handler compares the new values with current ones and notifies them if + *they changed. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -144,95 +136,81 @@ __STATIC int hrps_meas_send_req_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_write_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct hrps_env_tag *hrps_env = PRF_ENV_GET(HRPS, hrps); - uint8_t conidx = KE_IDX_GET(src_id); +__STATIC int gattc_write_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Get the address of the environment + struct hrps_env_tag *hrps_env = PRF_ENV_GET(HRPS, hrps); + uint8_t conidx = KE_IDX_GET(src_id); - uint16_t value = 0x0000; - uint8_t status = GAP_ERR_NO_ERROR; + uint16_t value = 0x0000; + uint8_t status = GAP_ERR_NO_ERROR; - if (hrps_env != NULL) - { - //BP Measurement Char. - Client Char. Configuration - if (param->handle == (hrps_env->shdl + HRS_IDX_HR_MEAS_NTF_CFG)) - { - //Extract value before check - memcpy(&value, &(param->value), sizeof(uint16_t)); + if (hrps_env != NULL) { + // BP Measurement Char. - Client Char. Configuration + if (param->handle == (hrps_env->shdl + HRS_IDX_HR_MEAS_NTF_CFG)) { + // Extract value before check + memcpy(&value, &(param->value), sizeof(uint16_t)); - if ((value == PRF_CLI_STOP_NTFIND) || (value == PRF_CLI_START_NTF)) - { - hrps_env->hr_meas_ntf[conidx] = value | HRP_PRF_CFG_PERFORMED_OK; - } - else - { - status = PRF_APP_ERROR; - } + if ((value == PRF_CLI_STOP_NTFIND) || (value == PRF_CLI_START_NTF)) { + hrps_env->hr_meas_ntf[conidx] = value | HRP_PRF_CFG_PERFORMED_OK; + } else { + status = PRF_APP_ERROR; + } - if (status == GAP_ERR_NO_ERROR) - { - //Inform APP of configuration change - struct hrps_cfg_indntf_ind * ind = KE_MSG_ALLOC(HRPS_CFG_INDNTF_IND, - prf_dst_task_get(&hrps_env->prf_env, conidx), - prf_src_task_get(&hrps_env->prf_env, conidx), - hrps_cfg_indntf_ind); + if (status == GAP_ERR_NO_ERROR) { + // Inform APP of configuration change + struct hrps_cfg_indntf_ind *ind = KE_MSG_ALLOC( + HRPS_CFG_INDNTF_IND, prf_dst_task_get(&hrps_env->prf_env, conidx), + prf_src_task_get(&hrps_env->prf_env, conidx), hrps_cfg_indntf_ind); - ind->conidx = conidx; - ind->cfg_val = value; + ind->conidx = conidx; + ind->cfg_val = value; - ke_msg_send(ind); - } - } - //HR Control Point Char. Value - else - { - if (HRPS_IS_SUPPORTED(hrps_env->features, HRPS_ENGY_EXP_FEAT_SUP)) - { - //Extract value - memcpy(&value, &(param->value), sizeof(uint8_t)); - - if (value == 0x1) - { - //inform APP of configuration change - struct hrps_energy_exp_reset_ind * ind = KE_MSG_ALLOC(HRPS_ENERGY_EXP_RESET_IND, - prf_dst_task_get(&hrps_env->prf_env, conidx), - prf_src_task_get(&hrps_env->prf_env, conidx), - hrps_energy_exp_reset_ind); - - ind->conidx = conidx; - ke_msg_send(ind); - } - else - { - status = HRS_ERR_HR_CNTL_POINT_NOT_SUPPORTED; - } - } - else - { - //Allowed to send Application Error if value inconvenient - status = HRS_ERR_HR_CNTL_POINT_NOT_SUPPORTED; - } - } + ke_msg_send(ind); + } } + // HR Control Point Char. Value + else { + if (HRPS_IS_SUPPORTED(hrps_env->features, HRPS_ENGY_EXP_FEAT_SUP)) { + // Extract value + memcpy(&value, &(param->value), sizeof(uint8_t)); - //Send write response - struct gattc_write_cfm *cfm = KE_MSG_ALLOC( - GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = status; - ke_msg_send(cfm); + if (value == 0x1) { + // inform APP of configuration change + struct hrps_energy_exp_reset_ind *ind = + KE_MSG_ALLOC(HRPS_ENERGY_EXP_RESET_IND, + prf_dst_task_get(&hrps_env->prf_env, conidx), + prf_src_task_get(&hrps_env->prf_env, conidx), + hrps_energy_exp_reset_ind); - return (KE_MSG_CONSUMED); + ind->conidx = conidx; + ke_msg_send(ind); + } else { + status = HRS_ERR_HR_CNTL_POINT_NOT_SUPPORTED; + } + } else { + // Allowed to send Application Error if value inconvenient + status = HRS_ERR_HR_CNTL_POINT_NOT_SUPPORTED; + } + } + } + + // Send write response + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = status; + ke_msg_send(cfm); + + return (KE_MSG_CONSUMED); } /** **************************************************************************************** - * @brief Handles @ref GATTC_CMP_EVT for GATTC_NOTIFY message meaning that Measurement - * notification has been correctly sent to peer device (but not confirmed by peer device). + * @brief Handles @ref GATTC_CMP_EVT for GATTC_NOTIFY message meaning that + *Measurement notification has been correctly sent to peer device (but not + *confirmed by peer device). * * * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. @@ -241,15 +219,16 @@ __STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - if((ke_state_get(dest_id) == HRPS_BUSY) && (param->operation == GATTC_NOTIFY)) - { - // continue operation execution - hrps_exe_operation(); - } - return (KE_MSG_CONSUMED); +__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + if ((ke_state_get(dest_id) == HRPS_BUSY) && + (param->operation == GATTC_NOTIFY)) { + // continue operation execution + hrps_exe_operation(); + } + return (KE_MSG_CONSUMED); } /** @@ -264,62 +243,56 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_ev **************************************************************************************** */ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_read_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if(ke_state_get(dest_id) == HRPS_IDLE) - { - // Get the address of the environment - struct hrps_env_tag *hrps_env = PRF_ENV_GET(HRPS, hrps); - uint8_t conidx = KE_IDX_GET(src_id); - uint8_t att_idx = param->handle - hrps_env->shdl; + struct gattc_read_req_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + if (ke_state_get(dest_id) == HRPS_IDLE) { + // Get the address of the environment + struct hrps_env_tag *hrps_env = PRF_ENV_GET(HRPS, hrps); + uint8_t conidx = KE_IDX_GET(src_id); + uint8_t att_idx = param->handle - hrps_env->shdl; - uint8_t value[4]; - uint8_t value_size = 0; - uint8_t status = ATT_ERR_NO_ERROR; + uint8_t value[4]; + uint8_t value_size = 0; + uint8_t status = ATT_ERR_NO_ERROR; - switch(att_idx) - { - case HRS_IDX_HR_MEAS_NTF_CFG: - { - value_size = sizeof(uint16_t); - co_write16p(value, hrps_env->hr_meas_ntf[conidx] & ~HRP_PRF_CFG_PERFORMED_OK); - } break; + switch (att_idx) { + case HRS_IDX_HR_MEAS_NTF_CFG: { + value_size = sizeof(uint16_t); + co_write16p(value, + hrps_env->hr_meas_ntf[conidx] & ~HRP_PRF_CFG_PERFORMED_OK); + } break; - case HRS_IDX_BODY_SENSOR_LOC_VAL: - { - // Broadcast feature is profile specific - if (HRPS_IS_SUPPORTED(hrps_env->features, HRPS_BODY_SENSOR_LOC_CHAR_SUP)) - { - // Fill data - value_size = sizeof(uint8_t); - value[0] = hrps_env->sensor_location; - } - else - { - status = ATT_ERR_ATTRIBUTE_NOT_FOUND; - } - } break; + case HRS_IDX_BODY_SENSOR_LOC_VAL: { + // Broadcast feature is profile specific + if (HRPS_IS_SUPPORTED(hrps_env->features, + HRPS_BODY_SENSOR_LOC_CHAR_SUP)) { + // Fill data + value_size = sizeof(uint8_t); + value[0] = hrps_env->sensor_location; + } else { + status = ATT_ERR_ATTRIBUTE_NOT_FOUND; + } + } break; - default: - { - status = ATT_ERR_REQUEST_NOT_SUPPORTED; - } break; - } - - // Send data to peer device - struct gattc_read_cfm* cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, value_size); - cfm->length = value_size; - memcpy(cfm->value, value, value_size); - cfm->handle = param->handle; - cfm->status = status; - - // Send value to peer device. - ke_msg_send(cfm); + default: { + status = ATT_ERR_REQUEST_NOT_SUPPORTED; + } break; } - return (KE_MSG_CONSUMED); + // Send data to peer device + struct gattc_read_cfm *cfm = KE_MSG_ALLOC_DYN( + GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, value_size); + cfm->length = value_size; + memcpy(cfm->value, value, value_size); + cfm->handle = param->handle; + cfm->status = status; + + // Send value to peer device. + ke_msg_send(cfm); + } + + return (KE_MSG_CONSUMED); } /* @@ -328,24 +301,22 @@ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, */ /* Default State handlers definition. */ -KE_MSG_HANDLER_TAB(hrps) -{ - {HRPS_ENABLE_REQ, (ke_msg_func_t) hrps_enable_req_handler}, - {GATTC_WRITE_REQ_IND, (ke_msg_func_t) gattc_write_req_ind_handler}, - {HRPS_MEAS_SEND_REQ, (ke_msg_func_t) hrps_meas_send_req_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t) gattc_cmp_evt_handler}, - {GATTC_READ_REQ_IND, (ke_msg_func_t) gattc_read_req_ind_handler}, +KE_MSG_HANDLER_TAB(hrps){ + {HRPS_ENABLE_REQ, (ke_msg_func_t)hrps_enable_req_handler}, + {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, + {HRPS_MEAS_SEND_REQ, (ke_msg_func_t)hrps_meas_send_req_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, + {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, }; -void hrps_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct hrps_env_tag *hrps_env = PRF_ENV_GET(HRPS, hrps); +void hrps_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct hrps_env_tag *hrps_env = PRF_ENV_GET(HRPS, hrps); - task_desc->msg_handler_tab = hrps_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(hrps_msg_handler_tab); - task_desc->state = hrps_env->state; - task_desc->idx_max = HRPS_IDX_MAX; + task_desc->msg_handler_tab = hrps_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(hrps_msg_handler_tab); + task_desc->state = hrps_env->state; + task_desc->idx_max = HRPS_IDX_MAX; } #endif /* #if (BLE_HR_SENSOR) */ diff --git a/services/ble_profiles/htp/htpc/src/htpc.c b/services/ble_profiles/htp/htpc/src/htpc.c index 5d54251..6d7902e 100644 --- a/services/ble_profiles/htp/htpc/src/htpc.c +++ b/services/ble_profiles/htp/htpc/src/htpc.c @@ -12,12 +12,12 @@ #include "rwip_config.h" #if (BLE_HT_COLLECTOR) +#include "gap.h" #include "htpc.h" #include "htpc_task.h" -#include "gap.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * LOCAL FUNCTION DEFINITIONS @@ -36,75 +36,74 @@ * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t htpc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, - uint8_t sec_lvl, void* params) -{ - uint8_t idx; - //-------------------- allocate memory required for the profile --------------------- +static uint8_t htpc_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t idx; + //-------------------- allocate memory required for the profile + //--------------------- - struct htpc_env_tag* htpc_env = - (struct htpc_env_tag* ) ke_malloc(sizeof(struct htpc_env_tag), KE_MEM_ATT_DB); + struct htpc_env_tag *htpc_env = (struct htpc_env_tag *)ke_malloc( + sizeof(struct htpc_env_tag), KE_MEM_ATT_DB); - // allocate HTPC required environment variable - env->env = (prf_env_t*) htpc_env; + // allocate HTPC required environment variable + env->env = (prf_env_t *)htpc_env; - htpc_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - htpc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + htpc_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + htpc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_HTPC; - htpc_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_HTPC; + htpc_task_init(&(env->desc)); - for(idx = 0; idx < HTPC_IDX_MAX ; idx++) - { - htpc_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), HTPC_FREE); - } + for (idx = 0; idx < HTPC_IDX_MAX; idx++) { + htpc_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), HTPC_FREE); + } - return GAP_ERR_NO_ERROR; + return GAP_ERR_NO_ERROR; } /** **************************************************************************************** * @brief Destruction of the HTPC module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void htpc_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct htpc_env_tag* htpc_env = (struct htpc_env_tag*) env->env; +static void htpc_destroy(struct prf_task_env *env) { + uint8_t idx; + struct htpc_env_tag *htpc_env = (struct htpc_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < HTPC_IDX_MAX ; idx++) - { - if(htpc_env->env[idx] != NULL) - { - if(htpc_env->env[idx]->operation != NULL) - { - ke_msg_free(htpc_env->env[idx]->operation); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < HTPC_IDX_MAX; idx++) { + if (htpc_env->env[idx] != NULL) { + if (htpc_env->env[idx]->operation != NULL) { + ke_msg_free(htpc_env->env[idx]->operation); + } - ke_free(htpc_env->env[idx]); - } + ke_free(htpc_env->env[idx]); } + } - // free profile environment variables - env->env = NULL; - ke_free(htpc_env); + // free profile environment variables + env->env = NULL; + ke_free(htpc_env); } /** @@ -115,10 +114,9 @@ static void htpc_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void htpc_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Put HTP Client in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), HTPC_IDLE); +static void htpc_create(struct prf_task_env *env, uint8_t conidx) { + /* Put HTP Client in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), HTPC_IDLE); } /** @@ -130,68 +128,61 @@ static void htpc_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void htpc_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct htpc_env_tag* htpc_env = (struct htpc_env_tag*) env->env; +static void htpc_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct htpc_env_tag *htpc_env = (struct htpc_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(htpc_env->env[conidx] != NULL) - { - if(htpc_env->env[conidx]->operation != NULL) - { - ke_msg_free(htpc_env->env[conidx]->operation); - } - - ke_free(htpc_env->env[conidx]); - htpc_env->env[conidx] = NULL; + // clean-up environment variable allocated for task instance + if (htpc_env->env[conidx] != NULL) { + if (htpc_env->env[conidx]->operation != NULL) { + ke_msg_free(htpc_env->env[conidx]->operation); } - /* Put HTP Client in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), HTPC_FREE); + ke_free(htpc_env->env[conidx]); + htpc_env->env[conidx] = NULL; + } + + /* Put HTP Client in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), HTPC_FREE); } - void htpc_unpack_temp(struct htpc_env_tag *htpc_env, uint8_t *packed_temp, - uint8_t length, uint8_t flag_stable_meas, uint8_t conidx) -{ - // Cursor used to read parameter in the packed temperature value - uint8_t cursor = 0; + uint8_t length, uint8_t flag_stable_meas, + uint8_t conidx) { + // Cursor used to read parameter in the packed temperature value + uint8_t cursor = 0; + // Checked the length of the received value + if (length >= HTPC_PACKED_TEMP_MIN_LEN) { + // Prepare the message to send to the application + struct htpc_temp_ind *ind = KE_MSG_ALLOC( + HTPC_TEMP_IND, prf_dst_task_get(&htpc_env->prf_env, conidx), + prf_src_task_get(&htpc_env->prf_env, conidx), htpc_temp_ind); - // Checked the length of the received value - if (length >= HTPC_PACKED_TEMP_MIN_LEN) - { - // Prepare the message to send to the application - struct htpc_temp_ind *ind = KE_MSG_ALLOC(HTPC_TEMP_IND, - prf_dst_task_get(&htpc_env->prf_env, conidx), - prf_src_task_get(&htpc_env->prf_env, conidx), - htpc_temp_ind); + // Unpack Temp Measurement + ind->temp_meas.flags = *(packed_temp + cursor); + cursor += 1; - // Unpack Temp Measurement - ind->temp_meas.flags = *(packed_temp + cursor); - cursor += 1; + ind->temp_meas.temp = co_read32p(packed_temp + cursor); + cursor += 4; - ind->temp_meas.temp = co_read32p(packed_temp + cursor); - cursor += 4; - - // Time Flag Set - if ((ind->temp_meas.flags & HTP_FLAG_TIME) == HTP_FLAG_TIME) - { - cursor += prf_unpack_date_time(packed_temp+cursor, &(ind->temp_meas.time_stamp)); - } - - // Type Flag set - if ((ind->temp_meas.flags & HTP_FLAG_TYPE) == HTP_FLAG_TYPE) - { - ind->temp_meas.type = *(packed_temp + cursor); - } - - // Stable or intermediary type of temperature - ind->stable_meas = flag_stable_meas; - - //Send request to ATT - ke_msg_send(ind); + // Time Flag Set + if ((ind->temp_meas.flags & HTP_FLAG_TIME) == HTP_FLAG_TIME) { + cursor += prf_unpack_date_time(packed_temp + cursor, + &(ind->temp_meas.time_stamp)); } + + // Type Flag set + if ((ind->temp_meas.flags & HTP_FLAG_TYPE) == HTP_FLAG_TYPE) { + ind->temp_meas.type = *(packed_temp + cursor); + } + + // Stable or intermediary type of temperature + ind->stable_meas = flag_stable_meas; + + // Send request to ATT + ke_msg_send(ind); + } } #if 0 uint8_t htpc_get_next_desc_char_code(struct htpc_env_tag *htpc_env, @@ -226,12 +217,11 @@ uint8_t htpc_get_next_desc_char_code(struct htpc_env_tag *htpc_env, */ /// HTPC Task interface required by profile manager -const struct prf_task_cbs htpc_itf = -{ - (prf_init_fnct) htpc_init, - htpc_destroy, - htpc_create, - htpc_cleanup, +const struct prf_task_cbs htpc_itf = { + (prf_init_fnct)htpc_init, + htpc_destroy, + htpc_create, + htpc_cleanup, }; /* @@ -239,49 +229,41 @@ const struct prf_task_cbs htpc_itf = **************************************************************************************** */ -const struct prf_task_cbs* htpc_prf_itf_get(void) -{ - return &htpc_itf; +const struct prf_task_cbs *htpc_prf_itf_get(void) { return &htpc_itf; } + +void htpc_enable_rsp_send(struct htpc_env_tag *htpc_env, uint8_t conidx, + uint8_t status) { + // Inform the APP about the status of the enabling of the Health Thermometer + // Profile Collector role 5awk + struct htpc_enable_rsp *cfm = KE_MSG_ALLOC( + HTPC_ENABLE_RSP, prf_dst_task_get(&(htpc_env->prf_env), conidx), + prf_src_task_get(&(htpc_env->prf_env), conidx), htpc_enable_rsp); + + // Status + cfm->status = status; + + if (status == GAP_ERR_NO_ERROR) { + cfm->hts = htpc_env->env[conidx]->hts; + // Go to IDLE state + ke_state_set(prf_src_task_get(&(htpc_env->prf_env), conidx), HTPC_IDLE); + + // Register profile handle to catch gatt indications + prf_register_atthdl2gatt(&(htpc_env->prf_env), conidx, + &htpc_env->env[conidx]->hts.svc); + } else { + if (htpc_env->env[conidx] != NULL) { + // clean-up environment variable allocated for task instance + if (htpc_env->env[conidx]->operation != NULL) { + ke_free(htpc_env->env[conidx]->operation); + } + ke_free(htpc_env->env[conidx]); + htpc_env->env[conidx] = NULL; + } + } + + // Send the confirmation to the application + ke_msg_send(cfm); } - -void htpc_enable_rsp_send(struct htpc_env_tag *htpc_env, uint8_t conidx, uint8_t status) -{ - // Inform the APP about the status of the enabling of the Health Thermometer Profile Collector role 5awk - struct htpc_enable_rsp *cfm = KE_MSG_ALLOC(HTPC_ENABLE_RSP, - prf_dst_task_get(&(htpc_env->prf_env), conidx), - prf_src_task_get(&(htpc_env->prf_env), conidx), - htpc_enable_rsp); - - // Status - cfm->status = status; - - if (status == GAP_ERR_NO_ERROR) - { - cfm->hts = htpc_env->env[conidx]->hts; - // Go to IDLE state - ke_state_set(prf_src_task_get(&(htpc_env->prf_env), conidx), HTPC_IDLE); - - // Register profile handle to catch gatt indications - prf_register_atthdl2gatt(&(htpc_env->prf_env), conidx, &htpc_env->env[conidx]->hts.svc ); - } - else - { - if(htpc_env->env[conidx] != NULL) - { - // clean-up environment variable allocated for task instance - if(htpc_env->env[conidx]->operation != NULL) - { - ke_free(htpc_env->env[conidx]->operation); - } - ke_free(htpc_env->env[conidx]); - htpc_env->env[conidx] = NULL; - } - } - - // Send the confirmation to the application - ke_msg_send(cfm); -} - -#endif //BLE_HT_COLLECTOR +#endif // BLE_HT_COLLECTOR /// @} HTPC diff --git a/services/ble_profiles/htp/htpc/src/htpc_task.c b/services/ble_profiles/htp/htpc/src/htpc_task.c index dd1b434..e67c086 100644 --- a/services/ble_profiles/htp/htpc/src/htpc_task.c +++ b/services/ble_profiles/htp/htpc/src/htpc_task.c @@ -12,40 +12,49 @@ #include "rwip_config.h" #if (BLE_HT_COLLECTOR) +#include "attm.h" #include "co_utils.h" #include "gap.h" -#include "attm.h" -#include "htpc_task.h" -#include "htpc.h" #include "gapc.h" #include "gapc_task.h" +#include "htpc.h" +#include "htpc_task.h" #include "ke_mem.h" -/// State machine used to retrieve Health Thermometer service characteristics information -const struct prf_char_def htpc_hts_char[HTPC_CHAR_HTS_MAX] = -{ +/// State machine used to retrieve Health Thermometer service characteristics +/// information +const struct prf_char_def htpc_hts_char[HTPC_CHAR_HTS_MAX] = { /// Temperature Measurement - [HTPC_CHAR_HTS_TEMP_MEAS] = {ATT_CHAR_TEMPERATURE_MEAS, ATT_MANDATORY, ATT_CHAR_PROP_IND}, + [HTPC_CHAR_HTS_TEMP_MEAS] = {ATT_CHAR_TEMPERATURE_MEAS, ATT_MANDATORY, + ATT_CHAR_PROP_IND}, /// Temperature Type - [HTPC_CHAR_HTS_TEMP_TYPE] = {ATT_CHAR_TEMPERATURE_TYPE, ATT_OPTIONAL, ATT_CHAR_PROP_RD}, + [HTPC_CHAR_HTS_TEMP_TYPE] = {ATT_CHAR_TEMPERATURE_TYPE, ATT_OPTIONAL, + ATT_CHAR_PROP_RD}, /// Intermediate Temperature - [HTPC_CHAR_HTS_INTM_TEMP] = {ATT_CHAR_INTERMED_TEMPERATURE, ATT_OPTIONAL, ATT_CHAR_PROP_NTF}, + [HTPC_CHAR_HTS_INTM_TEMP] = {ATT_CHAR_INTERMED_TEMPERATURE, ATT_OPTIONAL, + ATT_CHAR_PROP_NTF}, /// Measurement Interval - [HTPC_CHAR_HTS_MEAS_INTV] = {ATT_CHAR_MEAS_INTERVAL, ATT_OPTIONAL, ATT_CHAR_PROP_RD}, + [HTPC_CHAR_HTS_MEAS_INTV] = {ATT_CHAR_MEAS_INTERVAL, ATT_OPTIONAL, + ATT_CHAR_PROP_RD}, }; -/// State machine used to retrieve Health Thermometer service characteristics description information -const struct prf_char_desc_def htpc_hts_char_desc[HTPC_DESC_HTS_MAX] = -{ +/// State machine used to retrieve Health Thermometer service characteristics +/// description information +const struct prf_char_desc_def htpc_hts_char_desc[HTPC_DESC_HTS_MAX] = { /// Temperature Measurement Client Config - [HTPC_DESC_HTS_TEMP_MEAS_CLI_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, HTPC_CHAR_HTS_TEMP_MEAS}, + [HTPC_DESC_HTS_TEMP_MEAS_CLI_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + ATT_MANDATORY, + HTPC_CHAR_HTS_TEMP_MEAS}, /// Intermediate Temperature Client Config - [HTPC_DESC_HTS_INTM_MEAS_CLI_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_OPTIONAL, HTPC_CHAR_HTS_INTM_TEMP}, + [HTPC_DESC_HTS_INTM_MEAS_CLI_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_OPTIONAL, + HTPC_CHAR_HTS_INTM_TEMP}, /// Measurement Interval Client Config - [HTPC_DESC_HTS_MEAS_INTV_CLI_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_OPTIONAL, HTPC_CHAR_HTS_MEAS_INTV}, + [HTPC_DESC_HTS_MEAS_INTV_CLI_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_OPTIONAL, + HTPC_CHAR_HTS_MEAS_INTV}, /// Measurement Interval valid range - [HTPC_DESC_HTS_MEAS_INTV_VAL_RGE] = {ATT_DESC_VALID_RANGE, ATT_OPTIONAL, HTPC_CHAR_HTS_MEAS_INTV}, + [HTPC_DESC_HTS_MEAS_INTV_VAL_RGE] = {ATT_DESC_VALID_RANGE, ATT_OPTIONAL, + HTPC_CHAR_HTS_MEAS_INTV}, }; /* @@ -65,58 +74,51 @@ const struct prf_char_desc_def htpc_hts_char_desc[HTPC_DESC_HTS_MAX] = **************************************************************************************** */ __STATIC int htpc_enable_req_handler(ke_msg_id_t const msgid, - struct htpc_enable_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - int msg_status = KE_MSG_CONSUMED; - uint8_t status = GAP_ERR_NO_ERROR; - uint8_t state = ke_state_get(dest_id); - uint8_t conidx = KE_IDX_GET(dest_id); - // Health Thermometer Profile Collector Role Task Environment - struct htpc_env_tag *htpc_env = PRF_ENV_GET(HTPC, htpc); + struct htpc_enable_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + int msg_status = KE_MSG_CONSUMED; + uint8_t status = GAP_ERR_NO_ERROR; + uint8_t state = ke_state_get(dest_id); + uint8_t conidx = KE_IDX_GET(dest_id); + // Health Thermometer Profile Collector Role Task Environment + struct htpc_env_tag *htpc_env = PRF_ENV_GET(HTPC, htpc); - if((state == HTPC_IDLE) && (htpc_env->env[conidx] == NULL)) - { - // allocate environment variable for task instance - htpc_env->env[conidx] = (struct htpc_cnx_env*) ke_malloc(sizeof(struct htpc_cnx_env),KE_MEM_ATT_DB); - memset(htpc_env->env[conidx], 0, sizeof(struct htpc_cnx_env)); + if ((state == HTPC_IDLE) && (htpc_env->env[conidx] == NULL)) { + // allocate environment variable for task instance + htpc_env->env[conidx] = (struct htpc_cnx_env *)ke_malloc( + sizeof(struct htpc_cnx_env), KE_MEM_ATT_DB); + memset(htpc_env->env[conidx], 0, sizeof(struct htpc_cnx_env)); - //Config connection, start discovering - if(param->con_type == PRF_CON_DISCOVERY) - { - //start discovering HTS on peer - prf_disc_svc_send(&(htpc_env->prf_env), conidx, ATT_SVC_HEALTH_THERMOM); + // Config connection, start discovering + if (param->con_type == PRF_CON_DISCOVERY) { + // start discovering HTS on peer + prf_disc_svc_send(&(htpc_env->prf_env), conidx, ATT_SVC_HEALTH_THERMOM); - // store context of request and go into busy state - htpc_env->env[conidx]->operation = ke_param2msg(param); - msg_status = KE_MSG_NO_FREE; - ke_state_set(dest_id, HTPC_BUSY); - } - //normal connection, get saved att details - else - { - htpc_env->env[conidx]->hts = param->hts; - - //send APP confirmation that can start normal connection to TH - htpc_enable_rsp_send(htpc_env, conidx, GAP_ERR_NO_ERROR); - } - } - else - { - status = PRF_ERR_REQ_DISALLOWED; + // store context of request and go into busy state + htpc_env->env[conidx]->operation = ke_param2msg(param); + msg_status = KE_MSG_NO_FREE; + ke_state_set(dest_id, HTPC_BUSY); } + // normal connection, get saved att details + else { + htpc_env->env[conidx]->hts = param->hts; - // send an error if request fails - if(status != GAP_ERR_NO_ERROR) - { - htpc_enable_rsp_send(htpc_env, conidx, status); + // send APP confirmation that can start normal connection to TH + htpc_enable_rsp_send(htpc_env, conidx, GAP_ERR_NO_ERROR); } + } else { + status = PRF_ERR_REQ_DISALLOWED; + } - return (msg_status); + // send an error if request fails + if (status != GAP_ERR_NO_ERROR) { + htpc_enable_rsp_send(htpc_env, conidx, status); + } + + return (msg_status); } - /** **************************************************************************************** * @brief Handles reception of the @ref GATTC_SDP_SVC_IND_HANDLER message. @@ -129,46 +131,40 @@ __STATIC int htpc_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, - struct gattc_sdp_svc_ind const *ind, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_sdp_svc_ind const *ind, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == HTPC_BUSY) - { - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct htpc_env_tag *htpc_env = PRF_ENV_GET(HTPC, htpc); + if (state == HTPC_BUSY) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct htpc_env_tag *htpc_env = PRF_ENV_GET(HTPC, htpc); - ASSERT_INFO(htpc_env != NULL, dest_id, src_id); - ASSERT_INFO(htpc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(htpc_env != NULL, dest_id, src_id); + ASSERT_INFO(htpc_env->env[conidx] != NULL, dest_id, src_id); - if(htpc_env->env[conidx]->nb_svc == 0) - { - // Retrieve IAS characteristic - prf_extract_svc_info(ind, HTPC_CHAR_HTS_MAX, &htpc_hts_char[0], - htpc_env->env[conidx]->hts.chars, - HTPC_DESC_HTS_MAX, - &htpc_hts_char_desc[0], - &(htpc_env->env[conidx]->hts.descs[0]) ); + if (htpc_env->env[conidx]->nb_svc == 0) { + // Retrieve IAS characteristic + prf_extract_svc_info(ind, HTPC_CHAR_HTS_MAX, &htpc_hts_char[0], + htpc_env->env[conidx]->hts.chars, HTPC_DESC_HTS_MAX, + &htpc_hts_char_desc[0], + &(htpc_env->env[conidx]->hts.descs[0])); - //Even if we get multiple responses we only store 1 range - htpc_env->env[conidx]->hts.svc.shdl = ind->start_hdl; - htpc_env->env[conidx]->hts.svc.ehdl = ind->end_hdl; - } - htpc_env->env[conidx]->nb_svc++; + // Even if we get multiple responses we only store 1 range + htpc_env->env[conidx]->hts.svc.shdl = ind->start_hdl; + htpc_env->env[conidx]->hts.svc.ehdl = ind->end_hdl; } - return (KE_MSG_CONSUMED); + htpc_env->env[conidx]->nb_svc++; + } + return (KE_MSG_CONSUMED); } - - /** **************************************************************************************** * @brief Handles reception of the @ref HTPC_WR_MEAS_INTV_REQ message. - * Check if the handle exists in profile(already discovered) and send request, otherwise - * error to APP. + * Check if the handle exists in profile(already discovered) and send request, + *otherwise error to APP. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -176,77 +172,66 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int htpc_wr_meas_intv_req_handler(ke_msg_id_t const msgid, - struct htpc_wr_meas_intv_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - int msg_status = KE_MSG_CONSUMED; - // Status - uint8_t status = GAP_ERR_NO_ERROR; +__STATIC int htpc_wr_meas_intv_req_handler( + ke_msg_id_t const msgid, struct htpc_wr_meas_intv_req const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + int msg_status = KE_MSG_CONSUMED; + // Status + uint8_t status = GAP_ERR_NO_ERROR; - uint8_t state = ke_state_get(dest_id); - uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t state = ke_state_get(dest_id); + uint8_t conidx = KE_IDX_GET(dest_id); - // Device Information Service Client Role Task Environment - struct htpc_env_tag *htpc_env = PRF_ENV_GET(HTPC, htpc); + // Device Information Service Client Role Task Environment + struct htpc_env_tag *htpc_env = PRF_ENV_GET(HTPC, htpc); - ASSERT_INFO(htpc_env != NULL, dest_id, src_id); - if((state == HTPC_IDLE) && (htpc_env->env[conidx] != NULL)) - { - uint16_t val_hdl = ATT_INVALID_HANDLE; + ASSERT_INFO(htpc_env != NULL, dest_id, src_id); + if ((state == HTPC_IDLE) && (htpc_env->env[conidx] != NULL)) { + uint16_t val_hdl = ATT_INVALID_HANDLE; - if ((htpc_env->env[conidx]->hts.chars[HTPC_CHAR_HTS_MEAS_INTV].prop & ATT_CHAR_PROP_WR) != ATT_CHAR_PROP_WR) - { - status = PRF_ERR_NOT_WRITABLE; - } - else - { - val_hdl = htpc_env->env[conidx]->hts.chars[HTPC_CHAR_HTS_MEAS_INTV].val_hdl; + if ((htpc_env->env[conidx]->hts.chars[HTPC_CHAR_HTS_MEAS_INTV].prop & + ATT_CHAR_PROP_WR) != ATT_CHAR_PROP_WR) { + status = PRF_ERR_NOT_WRITABLE; + } else { + val_hdl = + htpc_env->env[conidx]->hts.chars[HTPC_CHAR_HTS_MEAS_INTV].val_hdl; - if (val_hdl != ATT_INVALID_HANDLE) - { - // Send GATT Write Request - prf_gatt_write(&(htpc_env->prf_env), conidx, val_hdl, - (uint8_t *)¶m->intv, sizeof(uint16_t), GATTC_WRITE); + if (val_hdl != ATT_INVALID_HANDLE) { + // Send GATT Write Request + prf_gatt_write(&(htpc_env->prf_env), conidx, val_hdl, + (uint8_t *)¶m->intv, sizeof(uint16_t), GATTC_WRITE); - // store context of request and go into busy state - htpc_env->env[conidx]->operation = ke_param2msg(param); - msg_status = KE_MSG_NO_FREE; - ke_state_set(dest_id, HTPC_BUSY); - } - else - { - // invalid handle requested - status = PRF_ERR_INEXISTENT_HDL; - } - } - } - else if(state != HTPC_FREE) - { - // request cannot be performed - status = PRF_ERR_REQ_DISALLOWED; + // store context of request and go into busy state + htpc_env->env[conidx]->operation = ke_param2msg(param); + msg_status = KE_MSG_NO_FREE; + ke_state_set(dest_id, HTPC_BUSY); + } else { + // invalid handle requested + status = PRF_ERR_INEXISTENT_HDL; + } } + } else if (state != HTPC_FREE) { + // request cannot be performed + status = PRF_ERR_REQ_DISALLOWED; + } - // send error response if request fails - if(status != GAP_ERR_NO_ERROR) - { - struct htpc_wr_meas_intv_rsp *rsp = KE_MSG_ALLOC(HTPC_WR_MEAS_INTV_RSP, src_id, dest_id, htpc_wr_meas_intv_rsp); - rsp->status = status; - ke_msg_send(rsp); - } + // send error response if request fails + if (status != GAP_ERR_NO_ERROR) { + struct htpc_wr_meas_intv_rsp *rsp = KE_MSG_ALLOC( + HTPC_WR_MEAS_INTV_RSP, src_id, dest_id, htpc_wr_meas_intv_rsp); + rsp->status = status; + ke_msg_send(rsp); + } - return (msg_status); + return (msg_status); } - - - /** **************************************************************************************** * @brief Handles reception of the @ref HTPC_HEALTH_TEMP_NTF_CFG_REQ message. - * It allows configuration of the peer ind/ntf/stop characteristic for a specified characteristic. - * Will return an error code if that cfg char does not exist. + * It allows configuration of the peer ind/ntf/stop characteristic for a + *specified characteristic. Will return an error code if that cfg char does not + *exist. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -254,90 +239,86 @@ __STATIC int htpc_wr_meas_intv_req_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int htpc_health_temp_ntf_cfg_req_handler(ke_msg_id_t const msgid, - struct htpc_health_temp_ntf_cfg_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Client Characteristic Configuration Descriptor Handle - uint16_t cfg_hdl = 0x0000; - // Status - uint8_t status = GAP_ERR_NO_ERROR; - int msg_status = KE_MSG_CONSUMED; - // Get the address of the environment - struct htpc_env_tag *htpc_env = PRF_ENV_GET(HTPC, htpc); - uint8_t conidx = KE_IDX_GET(dest_id); +__STATIC int htpc_health_temp_ntf_cfg_req_handler( + ke_msg_id_t const msgid, struct htpc_health_temp_ntf_cfg_req const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Client Characteristic Configuration Descriptor Handle + uint16_t cfg_hdl = 0x0000; + // Status + uint8_t status = GAP_ERR_NO_ERROR; + int msg_status = KE_MSG_CONSUMED; + // Get the address of the environment + struct htpc_env_tag *htpc_env = PRF_ENV_GET(HTPC, htpc); + uint8_t conidx = KE_IDX_GET(dest_id); - switch(param->char_code) - { - case HTPC_CHAR_HTS_TEMP_MEAS://can only IND - cfg_hdl = htpc_env->env[conidx]->hts.descs[HTPC_DESC_HTS_TEMP_MEAS_CLI_CFG].desc_hdl; - if(!((param->cfg_val == PRF_CLI_STOP_NTFIND)|| - (param->cfg_val == PRF_CLI_START_IND))) - { - status = PRF_ERR_INVALID_PARAM; - } - break; - - case HTPC_CHAR_HTS_MEAS_INTV://can only IND - cfg_hdl = htpc_env->env[conidx]->hts.descs[HTPC_DESC_HTS_MEAS_INTV_CLI_CFG].desc_hdl; - if(!((param->cfg_val == PRF_CLI_STOP_NTFIND)|| - (param->cfg_val == PRF_CLI_START_IND))) - { - status = PRF_ERR_INVALID_PARAM; - } - break; - - case HTPC_CHAR_HTS_INTM_TEMP://can only NTF - cfg_hdl = htpc_env->env[conidx]->hts.descs[HTPC_DESC_HTS_INTM_MEAS_CLI_CFG].desc_hdl; - if(!((param->cfg_val == PRF_CLI_STOP_NTFIND)|| - (param->cfg_val == PRF_CLI_START_NTF))) - { - status = PRF_ERR_INVALID_PARAM; - } - break; - - default: - //Let app know that one of the request params is incorrect - status = PRF_ERR_INVALID_PARAM; - break; + switch (param->char_code) { + case HTPC_CHAR_HTS_TEMP_MEAS: // can only IND + cfg_hdl = htpc_env->env[conidx] + ->hts.descs[HTPC_DESC_HTS_TEMP_MEAS_CLI_CFG] + .desc_hdl; + if (!((param->cfg_val == PRF_CLI_STOP_NTFIND) || + (param->cfg_val == PRF_CLI_START_IND))) { + status = PRF_ERR_INVALID_PARAM; } + break; - //Check if the handle value exists - if ((cfg_hdl == ATT_INVALID_HANDLE)) - { - status = PRF_ERR_INEXISTENT_HDL; + case HTPC_CHAR_HTS_MEAS_INTV: // can only IND + cfg_hdl = htpc_env->env[conidx] + ->hts.descs[HTPC_DESC_HTS_MEAS_INTV_CLI_CFG] + .desc_hdl; + if (!((param->cfg_val == PRF_CLI_STOP_NTFIND) || + (param->cfg_val == PRF_CLI_START_IND))) { + status = PRF_ERR_INVALID_PARAM; } + break; - // no error detected - if (status == GAP_ERR_NO_ERROR) - { - // Send GATT Write Request - prf_gatt_write_ntf_ind(&htpc_env->prf_env, conidx, cfg_hdl, param->cfg_val); - // store context of request and go into busy state - htpc_env->env[conidx]->operation = ke_param2msg(param); - ke_state_set(dest_id, HTPC_BUSY); - msg_status = KE_MSG_NO_FREE; - } - // an error occurs send back response message - else - { - struct htpc_health_temp_ntf_cfg_rsp* rsp = KE_MSG_ALLOC(HTPC_HEALTH_TEMP_NTF_CFG_RSP, - src_id, dest_id, - htpc_health_temp_ntf_cfg_rsp); - rsp->status = status; - ke_msg_send(rsp); + case HTPC_CHAR_HTS_INTM_TEMP: // can only NTF + cfg_hdl = htpc_env->env[conidx] + ->hts.descs[HTPC_DESC_HTS_INTM_MEAS_CLI_CFG] + .desc_hdl; + if (!((param->cfg_val == PRF_CLI_STOP_NTFIND) || + (param->cfg_val == PRF_CLI_START_NTF))) { + status = PRF_ERR_INVALID_PARAM; } + break; - return (msg_status); + default: + // Let app know that one of the request params is incorrect + status = PRF_ERR_INVALID_PARAM; + break; + } + + // Check if the handle value exists + if ((cfg_hdl == ATT_INVALID_HANDLE)) { + status = PRF_ERR_INEXISTENT_HDL; + } + + // no error detected + if (status == GAP_ERR_NO_ERROR) { + // Send GATT Write Request + prf_gatt_write_ntf_ind(&htpc_env->prf_env, conidx, cfg_hdl, param->cfg_val); + // store context of request and go into busy state + htpc_env->env[conidx]->operation = ke_param2msg(param); + ke_state_set(dest_id, HTPC_BUSY); + msg_status = KE_MSG_NO_FREE; + } + // an error occurs send back response message + else { + struct htpc_health_temp_ntf_cfg_rsp *rsp = + KE_MSG_ALLOC(HTPC_HEALTH_TEMP_NTF_CFG_RSP, src_id, dest_id, + htpc_health_temp_ntf_cfg_rsp); + rsp->status = status; + ke_msg_send(rsp); + } + + return (msg_status); } - /** **************************************************************************************** * @brief Handles reception of the @ref HTPC_RD_REQ message. - * Check if the handle exists in profile(already discovered) and send request, otherwise - * error to APP. + * Check if the handle exists in profile(already discovered) and send request, + *otherwise error to APP. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -346,96 +327,91 @@ __STATIC int htpc_health_temp_ntf_cfg_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int htpc_rd_char_req_handler(ke_msg_id_t const msgid, - struct htpc_rd_char_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - int msg_status = KE_MSG_CONSUMED; - // Status - uint8_t status = GAP_ERR_NO_ERROR; + struct htpc_rd_char_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + int msg_status = KE_MSG_CONSUMED; + // Status + uint8_t status = GAP_ERR_NO_ERROR; - uint8_t state = ke_state_get(dest_id); - uint8_t conidx = KE_IDX_GET(dest_id); - // Device Information Service Client Role Task Environment - struct htpc_env_tag *htpc_env = PRF_ENV_GET(HTPC, htpc); + uint8_t state = ke_state_get(dest_id); + uint8_t conidx = KE_IDX_GET(dest_id); + // Device Information Service Client Role Task Environment + struct htpc_env_tag *htpc_env = PRF_ENV_GET(HTPC, htpc); - ASSERT_INFO(htpc_env != NULL, dest_id, src_id); - if((state == HTPC_IDLE) && (htpc_env->env[conidx] != NULL)) - { - uint16_t search_hdl = ATT_INVALID_HDL; + ASSERT_INFO(htpc_env != NULL, dest_id, src_id); + if ((state == HTPC_IDLE) && (htpc_env->env[conidx] != NULL)) { + uint16_t search_hdl = ATT_INVALID_HDL; - switch (param->char_code) - { - ///Read HTS Temp. Type - case HTPC_RD_TEMP_TYPE: - { - search_hdl = htpc_env->env[conidx]->hts.chars[HTPC_CHAR_HTS_TEMP_TYPE].val_hdl; - }break; - ///Read HTS Measurement Interval - case HTPC_RD_MEAS_INTV: - { - search_hdl = htpc_env->env[conidx]->hts.chars[HTPC_CHAR_HTS_MEAS_INTV].val_hdl; - }break; + switch (param->char_code) { + /// Read HTS Temp. Type + case HTPC_RD_TEMP_TYPE: { + search_hdl = + htpc_env->env[conidx]->hts.chars[HTPC_CHAR_HTS_TEMP_TYPE].val_hdl; + } break; + /// Read HTS Measurement Interval + case HTPC_RD_MEAS_INTV: { + search_hdl = + htpc_env->env[conidx]->hts.chars[HTPC_CHAR_HTS_MEAS_INTV].val_hdl; + } break; - ///Read HTS Temperature Measurement Client Cfg. Desc - case HTPC_RD_TEMP_MEAS_CLI_CFG: - { - search_hdl = htpc_env->env[conidx]->hts.descs[HTPC_DESC_HTS_TEMP_MEAS_CLI_CFG].desc_hdl; - }break; - ///Read HTS Intermediate Temperature Client Cfg. Desc - case HTPC_RD_INTM_TEMP_CLI_CFG: - { - search_hdl = htpc_env->env[conidx]->hts.descs[HTPC_DESC_HTS_INTM_MEAS_CLI_CFG].desc_hdl; - }break; - ///Read HTS Measurement Interval Client Cfg. Desc - case HTPC_RD_MEAS_INTV_CLI_CFG: - { - search_hdl = htpc_env->env[conidx]->hts.descs[HTPC_DESC_HTS_MEAS_INTV_CLI_CFG].desc_hdl; - }break; - ///Read HTS Measurement Interval Client Cfg. Desc - case HTPC_RD_MEAS_INTV_VAL_RGE: - { - search_hdl = htpc_env->env[conidx]->hts.descs[HTPC_DESC_HTS_MEAS_INTV_VAL_RGE].desc_hdl; - }break; - default: - { - status = GAP_ERR_INVALID_PARAM; - }break; - } - - //Check if handle is viable - if (search_hdl != ATT_INVALID_HDL) - { - // perform read request - //htpc_env->env[conidx]->last_char_code = param->char_code; - prf_read_char_send(&(htpc_env->prf_env), conidx, htpc_env->env[conidx]->hts.svc.shdl, - htpc_env->env[conidx]->hts.svc.ehdl, search_hdl); - - // store context of request and go into busy state - htpc_env->env[conidx]->operation = ke_param2msg(param); - msg_status = KE_MSG_NO_FREE; - ke_state_set(dest_id, HTPC_BUSY); - } - else if(status == GAP_ERR_NO_ERROR) - { - // invalid handle requested - status = PRF_ERR_INEXISTENT_HDL; - } - } - else if(state != HTPC_FREE) - { - // request cannot be performed - status = PRF_ERR_REQ_DISALLOWED; + /// Read HTS Temperature Measurement Client Cfg. Desc + case HTPC_RD_TEMP_MEAS_CLI_CFG: { + search_hdl = htpc_env->env[conidx] + ->hts.descs[HTPC_DESC_HTS_TEMP_MEAS_CLI_CFG] + .desc_hdl; + } break; + /// Read HTS Intermediate Temperature Client Cfg. Desc + case HTPC_RD_INTM_TEMP_CLI_CFG: { + search_hdl = htpc_env->env[conidx] + ->hts.descs[HTPC_DESC_HTS_INTM_MEAS_CLI_CFG] + .desc_hdl; + } break; + /// Read HTS Measurement Interval Client Cfg. Desc + case HTPC_RD_MEAS_INTV_CLI_CFG: { + search_hdl = htpc_env->env[conidx] + ->hts.descs[HTPC_DESC_HTS_MEAS_INTV_CLI_CFG] + .desc_hdl; + } break; + /// Read HTS Measurement Interval Client Cfg. Desc + case HTPC_RD_MEAS_INTV_VAL_RGE: { + search_hdl = htpc_env->env[conidx] + ->hts.descs[HTPC_DESC_HTS_MEAS_INTV_VAL_RGE] + .desc_hdl; + } break; + default: { + status = GAP_ERR_INVALID_PARAM; + } break; } - // send error response if request fails - if(status != GAP_ERR_NO_ERROR) - { - prf_client_att_info_rsp(&(htpc_env->prf_env), conidx, HTPC_RD_CHAR_RSP, - status, NULL); - } + // Check if handle is viable + if (search_hdl != ATT_INVALID_HDL) { + // perform read request + // htpc_env->env[conidx]->last_char_code = param->char_code; + prf_read_char_send(&(htpc_env->prf_env), conidx, + htpc_env->env[conidx]->hts.svc.shdl, + htpc_env->env[conidx]->hts.svc.ehdl, search_hdl); - return (msg_status); + // store context of request and go into busy state + htpc_env->env[conidx]->operation = ke_param2msg(param); + msg_status = KE_MSG_NO_FREE; + ke_state_set(dest_id, HTPC_BUSY); + } else if (status == GAP_ERR_NO_ERROR) { + // invalid handle requested + status = PRF_ERR_INEXISTENT_HDL; + } + } else if (state != HTPC_FREE) { + // request cannot be performed + status = PRF_ERR_REQ_DISALLOWED; + } + + // send error response if request fails + if (status != GAP_ERR_NO_ERROR) { + prf_client_att_info_rsp(&(htpc_env->prf_env), conidx, HTPC_RD_CHAR_RSP, + status, NULL); + } + + return (msg_status); } /** @@ -452,16 +428,16 @@ __STATIC int htpc_rd_char_req_handler(ke_msg_id_t const msgid, __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, struct gattc_read_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct htpc_env_tag *htpc_env = PRF_ENV_GET(HTPC, htpc); - uint8_t conidx = KE_IDX_GET(dest_id); + ke_task_id_t const src_id) { + // Get the address of the environment + struct htpc_env_tag *htpc_env = PRF_ENV_GET(HTPC, htpc); + uint8_t conidx = KE_IDX_GET(dest_id); - // send attribute information - prf_client_att_info_rsp(&(htpc_env->prf_env), conidx, HTPC_RD_CHAR_RSP, GAP_ERR_NO_ERROR, param); + // send attribute information + prf_client_att_info_rsp(&(htpc_env->prf_env), conidx, HTPC_RD_CHAR_RSP, + GAP_ERR_NO_ERROR, param); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -476,88 +452,78 @@ __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, - struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - uint8_t conidx = KE_IDX_GET(dest_id); + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct htpc_env_tag *htpc_env = PRF_ENV_GET(HTPC, htpc); + // Get the address of the environment + struct htpc_env_tag *htpc_env = PRF_ENV_GET(HTPC, htpc); - if(state == HTPC_BUSY) - { - switch(htpc_env->env[conidx]->operation->id) - { - case HTPC_ENABLE_REQ: - { - uint8_t status; - if(htpc_env->env[conidx]->nb_svc == 1) - { - status = prf_check_svc_char_validity(HTPC_CHAR_HTS_MAX, - htpc_env->env[conidx]->hts.chars, htpc_hts_char); + if (state == HTPC_BUSY) { + switch (htpc_env->env[conidx]->operation->id) { + case HTPC_ENABLE_REQ: { + uint8_t status; + if (htpc_env->env[conidx]->nb_svc == 1) { + status = prf_check_svc_char_validity( + HTPC_CHAR_HTS_MAX, htpc_env->env[conidx]->hts.chars, htpc_hts_char); - htpc_env->env[conidx]->nb_svc =0; - } - // Too many services found only one such service should exist - else if(htpc_env->env[conidx]->nb_svc > 1) - { - status = PRF_ERR_MULTIPLE_SVC; - } - else - { - status = PRF_ERR_STOP_DISC_CHAR_MISSING; - } + htpc_env->env[conidx]->nb_svc = 0; + } + // Too many services found only one such service should exist + else if (htpc_env->env[conidx]->nb_svc > 1) { + status = PRF_ERR_MULTIPLE_SVC; + } else { + status = PRF_ERR_STOP_DISC_CHAR_MISSING; + } - htpc_enable_rsp_send(htpc_env, conidx, status); - }break; + htpc_enable_rsp_send(htpc_env, conidx, status); + } break; + case HTPC_HEALTH_TEMP_NTF_CFG_REQ: { + // send response of the notification configuration request + struct htpc_health_temp_ntf_cfg_rsp *rsp = + KE_MSG_ALLOC(HTPC_HEALTH_TEMP_NTF_CFG_RSP, + prf_dst_task_get(&(htpc_env->prf_env), conidx), dest_id, + htpc_health_temp_ntf_cfg_rsp); + // set error status + rsp->status = param->status; + ke_msg_send(rsp); + } break; - case HTPC_HEALTH_TEMP_NTF_CFG_REQ: - { - // send response of the notification configuration request - struct htpc_health_temp_ntf_cfg_rsp * rsp = KE_MSG_ALLOC(HTPC_HEALTH_TEMP_NTF_CFG_RSP, - prf_dst_task_get(&(htpc_env->prf_env), conidx), dest_id, htpc_health_temp_ntf_cfg_rsp); - // set error status - rsp->status =param->status; - ke_msg_send(rsp); - }break; + case HTPC_RD_CHAR_REQ: { + if (param->status != GAP_ERR_NO_ERROR) { + // send attribute information + prf_client_att_info_rsp(&(htpc_env->prf_env), conidx, HTPC_RD_CHAR_RSP, + param->status, NULL); + } + } break; - case HTPC_RD_CHAR_REQ: - { - if(param->status != GAP_ERR_NO_ERROR) - { - // send attribute information - prf_client_att_info_rsp(&(htpc_env->prf_env), conidx, HTPC_RD_CHAR_RSP, param->status, NULL); - } - }break; + case HTPC_WR_MEAS_INTV_REQ: { + struct htpc_wr_meas_intv_rsp *rsp = KE_MSG_ALLOC( + HTPC_WR_MEAS_INTV_RSP, prf_dst_task_get(&(htpc_env->prf_env), conidx), + dest_id, htpc_wr_meas_intv_rsp); + rsp->status = param->status; + ke_msg_send(rsp); + } break; - case HTPC_WR_MEAS_INTV_REQ: - { - struct htpc_wr_meas_intv_rsp *rsp = KE_MSG_ALLOC(HTPC_WR_MEAS_INTV_RSP, - prf_dst_task_get(&(htpc_env->prf_env), conidx), dest_id, htpc_wr_meas_intv_rsp); - rsp->status = param->status; - ke_msg_send(rsp); - }break; - - default: break; - } - - - //free operation - if((htpc_env->env[conidx] != NULL) && (htpc_env->env[conidx]->operation != NULL)) - { - ke_free(htpc_env->env[conidx]->operation); - htpc_env->env[conidx]->operation = NULL; - } - // set state to IDLE - ke_state_set(dest_id, HTPC_IDLE); + default: + break; } - return (KE_MSG_CONSUMED); -} + // free operation + if ((htpc_env->env[conidx] != NULL) && + (htpc_env->env[conidx]->operation != NULL)) { + ke_free(htpc_env->env[conidx]->operation); + htpc_env->env[conidx]->operation = NULL; + } + // set state to IDLE + ke_state_set(dest_id, HTPC_IDLE); + } + return (KE_MSG_CONSUMED); +} /** **************************************************************************************** @@ -570,49 +536,53 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, - struct gattc_event_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct htpc_env_tag *htpc_env = PRF_ENV_GET(HTPC, htpc); - uint8_t conidx = KE_IDX_GET(dest_id); + struct gattc_event_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct htpc_env_tag *htpc_env = PRF_ENV_GET(HTPC, htpc); + uint8_t conidx = KE_IDX_GET(dest_id); - // Temperature Measurement Char. - if(param->handle == htpc_env->env[conidx]->hts.chars[HTPC_CHAR_HTS_TEMP_MEAS].val_hdl) - { - // confirm that indication has been correctly received - struct gattc_event_cfm * cfm = KE_MSG_ALLOC(GATTC_EVENT_CFM, src_id, dest_id, gattc_event_cfm); - cfm->handle = param->handle; - ke_msg_send(cfm); + // Temperature Measurement Char. + if (param->handle == + htpc_env->env[conidx]->hts.chars[HTPC_CHAR_HTS_TEMP_MEAS].val_hdl) { + // confirm that indication has been correctly received + struct gattc_event_cfm *cfm = + KE_MSG_ALLOC(GATTC_EVENT_CFM, src_id, dest_id, gattc_event_cfm); + cfm->handle = param->handle; + ke_msg_send(cfm); - htpc_unpack_temp(htpc_env, (uint8_t *)&(param->value), param->length, - ((param->type == GATTC_NOTIFY) ? HTP_TEMP_INTERM : HTP_TEMP_STABLE), conidx); - } - // Intermediate Temperature Measurement Char. - else if(param->handle == htpc_env->env[conidx]->hts.chars[HTPC_CHAR_HTS_INTM_TEMP].val_hdl) - { - htpc_unpack_temp(htpc_env, (uint8_t *)&(param->value), param->length, - ((param->type == GATTC_NOTIFY) ? HTP_TEMP_INTERM : HTP_TEMP_STABLE), conidx); - } - // Measurement Interval Char. - else if (param->handle == htpc_env->env[conidx]->hts.chars[HTPC_CHAR_HTS_MEAS_INTV].val_hdl) - { - // confirm that indication has been correctly received - struct gattc_event_cfm * cfm = KE_MSG_ALLOC(GATTC_EVENT_CFM, src_id, dest_id, gattc_event_cfm); - cfm->handle = param->handle; - ke_msg_send(cfm); + htpc_unpack_temp( + htpc_env, (uint8_t *)&(param->value), param->length, + ((param->type == GATTC_NOTIFY) ? HTP_TEMP_INTERM : HTP_TEMP_STABLE), + conidx); + } + // Intermediate Temperature Measurement Char. + else if (param->handle == + htpc_env->env[conidx]->hts.chars[HTPC_CHAR_HTS_INTM_TEMP].val_hdl) { + htpc_unpack_temp( + htpc_env, (uint8_t *)&(param->value), param->length, + ((param->type == GATTC_NOTIFY) ? HTP_TEMP_INTERM : HTP_TEMP_STABLE), + conidx); + } + // Measurement Interval Char. + else if (param->handle == + htpc_env->env[conidx]->hts.chars[HTPC_CHAR_HTS_MEAS_INTV].val_hdl) { + // confirm that indication has been correctly received + struct gattc_event_cfm *cfm = + KE_MSG_ALLOC(GATTC_EVENT_CFM, src_id, dest_id, gattc_event_cfm); + cfm->handle = param->handle; + ke_msg_send(cfm); - struct htpc_meas_intv_ind * ind = KE_MSG_ALLOC(HTPC_MEAS_INTV_IND, - prf_dst_task_get(&htpc_env->prf_env, conidx), - prf_src_task_get(&htpc_env->prf_env, conidx), - htpc_meas_intv_ind); + struct htpc_meas_intv_ind *ind = KE_MSG_ALLOC( + HTPC_MEAS_INTV_IND, prf_dst_task_get(&htpc_env->prf_env, conidx), + prf_src_task_get(&htpc_env->prf_env, conidx), htpc_meas_intv_ind); - memcpy(&ind->intv, ¶m->value[0], sizeof(uint16_t)); + memcpy(&ind->intv, ¶m->value[0], sizeof(uint16_t)); - ke_msg_send(ind); - } - return (KE_MSG_CONSUMED); + ke_msg_send(ind); + } + return (KE_MSG_CONSUMED); } /* @@ -620,32 +590,30 @@ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ - /* Default State handlers definition. */ -KE_MSG_HANDLER_TAB(htpc) -{ - {HTPC_ENABLE_REQ, (ke_msg_func_t) htpc_enable_req_handler}, - {GATTC_SDP_SVC_IND, (ke_msg_func_t) gattc_sdp_svc_ind_handler}, - {HTPC_HEALTH_TEMP_NTF_CFG_REQ, (ke_msg_func_t) htpc_health_temp_ntf_cfg_req_handler}, - {HTPC_WR_MEAS_INTV_REQ, (ke_msg_func_t) htpc_wr_meas_intv_req_handler}, - {HTPC_RD_CHAR_REQ, (ke_msg_func_t) htpc_rd_char_req_handler}, - {GATTC_READ_IND, (ke_msg_func_t) gattc_read_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t) gattc_cmp_evt_handler}, - {GATTC_EVENT_IND, (ke_msg_func_t) gattc_event_ind_handler}, - {GATTC_EVENT_REQ_IND, (ke_msg_func_t) gattc_event_ind_handler}, +KE_MSG_HANDLER_TAB(htpc){ + {HTPC_ENABLE_REQ, (ke_msg_func_t)htpc_enable_req_handler}, + {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, + {HTPC_HEALTH_TEMP_NTF_CFG_REQ, + (ke_msg_func_t)htpc_health_temp_ntf_cfg_req_handler}, + {HTPC_WR_MEAS_INTV_REQ, (ke_msg_func_t)htpc_wr_meas_intv_req_handler}, + {HTPC_RD_CHAR_REQ, (ke_msg_func_t)htpc_rd_char_req_handler}, + {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, + {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {GATTC_EVENT_REQ_IND, (ke_msg_func_t)gattc_event_ind_handler}, }; -void htpc_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct htpc_env_tag *htpc_env = PRF_ENV_GET(HTPC, htpc); +void htpc_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct htpc_env_tag *htpc_env = PRF_ENV_GET(HTPC, htpc); - task_desc->msg_handler_tab = htpc_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(htpc_msg_handler_tab); - task_desc->state = htpc_env->state; - task_desc->idx_max = HTPC_IDX_MAX; + task_desc->msg_handler_tab = htpc_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(htpc_msg_handler_tab); + task_desc->state = htpc_env->state; + task_desc->idx_max = HTPC_IDX_MAX; } -#endif //BLE_HT_COLLECTOR +#endif // BLE_HT_COLLECTOR /// @} HTPCTASK diff --git a/services/ble_profiles/htp/htpt/src/htpt.c b/services/ble_profiles/htp/htpt/src/htpt.c index 0861152..4060d00 100644 --- a/services/ble_profiles/htp/htpt/src/htpt.c +++ b/services/ble_profiles/htp/htpt/src/htpt.c @@ -13,51 +13,68 @@ #if (BLE_HT_THERMOM) #include "attm.h" +#include "co_utils.h" #include "htpt.h" #include "htpt_task.h" -#include "co_utils.h" #include "prf_utils.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * HTPT PROFILE ATTRIBUTES **************************************************************************************** */ /// Full HTS Database Description - Used to add attributes into the database -const struct attm_desc htpt_att_db[HTS_IDX_NB] = -{ +const struct attm_desc htpt_att_db[HTS_IDX_NB] = { // Health Thermometer Service Declaration - [HTS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [HTS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // Temperature Measurement Characteristic Declaration - [HTS_IDX_TEMP_MEAS_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [HTS_IDX_TEMP_MEAS_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Temperature Measurement Characteristic Value - [HTS_IDX_TEMP_MEAS_VAL] = {ATT_CHAR_TEMPERATURE_MEAS, PERM(IND, ENABLE), PERM(RI, ENABLE), 0}, - // Temperature Measurement Characteristic - Client Characteristic Configuration Descriptor - [HTS_IDX_TEMP_MEAS_IND_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE)|PERM(WRITE_REQ, ENABLE), 0, 0}, + [HTS_IDX_TEMP_MEAS_VAL] = {ATT_CHAR_TEMPERATURE_MEAS, PERM(IND, ENABLE), + PERM(RI, ENABLE), 0}, + // Temperature Measurement Characteristic - Client Characteristic + // Configuration Descriptor + [HTS_IDX_TEMP_MEAS_IND_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + 0, 0}, // Temperature Type Characteristic Declaration - [HTS_IDX_TEMP_TYPE_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [HTS_IDX_TEMP_TYPE_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Temperature Type Characteristic Value - [HTS_IDX_TEMP_TYPE_VAL] = {ATT_CHAR_TEMPERATURE_TYPE, PERM(RD, ENABLE), PERM(RI, ENABLE), 0}, + [HTS_IDX_TEMP_TYPE_VAL] = {ATT_CHAR_TEMPERATURE_TYPE, PERM(RD, ENABLE), + PERM(RI, ENABLE), 0}, // Intermediate Measurement Characteristic Declaration - [HTS_IDX_INTERM_TEMP_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [HTS_IDX_INTERM_TEMP_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Intermediate Measurement Characteristic Value - [HTS_IDX_INTERM_TEMP_VAL] = {ATT_CHAR_INTERMED_TEMPERATURE, PERM(NTF, ENABLE), PERM(RI, ENABLE), 0}, - // Intermediate Measurement Characteristic - Client Characteristic Configuration Descriptor - [HTS_IDX_INTERM_TEMP_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE)|PERM(WRITE_REQ, ENABLE), 0, 0}, + [HTS_IDX_INTERM_TEMP_VAL] = {ATT_CHAR_INTERMED_TEMPERATURE, + PERM(NTF, ENABLE), PERM(RI, ENABLE), 0}, + // Intermediate Measurement Characteristic - Client Characteristic + // Configuration Descriptor + [HTS_IDX_INTERM_TEMP_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, + 0}, // Measurement Interval Characteristic Declaration - [HTS_IDX_MEAS_INTV_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [HTS_IDX_MEAS_INTV_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Measurement Interval Characteristic Value - [HTS_IDX_MEAS_INTV_VAL] = {ATT_CHAR_MEAS_INTERVAL, PERM(RD, ENABLE), PERM(RI, ENABLE), HTPT_MEAS_INTV_MAX_LEN}, - // Measurement Interval Characteristic - Client Characteristic Configuration Descriptor - [HTS_IDX_MEAS_INTV_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE)|PERM(WRITE_REQ, ENABLE), 0, 0}, + [HTS_IDX_MEAS_INTV_VAL] = {ATT_CHAR_MEAS_INTERVAL, PERM(RD, ENABLE), + PERM(RI, ENABLE), HTPT_MEAS_INTV_MAX_LEN}, + // Measurement Interval Characteristic - Client Characteristic Configuration + // Descriptor + [HTS_IDX_MEAS_INTV_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, + 0}, // Measurement Interval Characteristic - Valid Range Descriptor - [HTS_IDX_MEAS_INTV_VAL_RANGE] = {ATT_DESC_VALID_RANGE, PERM(RD, ENABLE), PERM(RI, ENABLE), 0}, + [HTS_IDX_MEAS_INTV_VAL_RANGE] = {ATT_DESC_VALID_RANGE, PERM(RD, ENABLE), + PERM(RI, ENABLE), 0}, }; static uint16_t htpt_compute_att_table(uint16_t features); @@ -67,520 +84,469 @@ static uint16_t htpt_compute_att_table(uint16_t features); **************************************************************************************** */ -static uint8_t htpt_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, - uint8_t sec_lvl, struct htpt_db_cfg* params) -{ - // Service content flag - uint16_t cfg_flag; - // DB Creation Status - uint8_t status = ATT_ERR_NO_ERROR; +static uint8_t htpt_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, + struct htpt_db_cfg *params) { + // Service content flag + uint16_t cfg_flag; + // DB Creation Status + uint8_t status = ATT_ERR_NO_ERROR; - BLE_PRF_HP_FUNC_ENTER(); + BLE_PRF_HP_FUNC_ENTER(); - cfg_flag = htpt_compute_att_table(params->features); + cfg_flag = htpt_compute_att_table(params->features); - status = attm_svc_create_db(start_hdl, ATT_SVC_HEALTH_THERMOM, (uint8_t *)&cfg_flag, - HTS_IDX_NB, NULL, env->task, &htpt_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | PERM(SVC_MI, DISABLE) ); + status = attm_svc_create_db( + start_hdl, ATT_SVC_HEALTH_THERMOM, (uint8_t *)&cfg_flag, HTS_IDX_NB, NULL, + env->task, &htpt_att_db[0], + (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, DISABLE)); - if( status == ATT_ERR_NO_ERROR ) - { - //-------------------- allocate memory required for the profile --------------------- - struct htpt_env_tag* htpt_env = - (struct htpt_env_tag* ) ke_malloc(sizeof(struct htpt_env_tag), KE_MEM_ATT_DB); + if (status == ATT_ERR_NO_ERROR) { + //-------------------- allocate memory required for the profile + //--------------------- + struct htpt_env_tag *htpt_env = (struct htpt_env_tag *)ke_malloc( + sizeof(struct htpt_env_tag), KE_MEM_ATT_DB); - // allocate PROXR required environment variable - env->env = (prf_env_t*) htpt_env; + // allocate PROXR required environment variable + env->env = (prf_env_t *)htpt_env; - htpt_env->shdl = *start_hdl; - htpt_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - htpt_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); + htpt_env->shdl = *start_hdl; + htpt_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + htpt_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); - // initialize environment variable - env->id = TASK_ID_HTPT; - htpt_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_HTPT; + htpt_task_init(&(env->desc)); - //Save features on the environment - htpt_env->features = params->features; - htpt_env->meas_intv = params->meas_intv; - htpt_env->meas_intv_min = params->valid_range_min; - htpt_env->meas_intv_max = params->valid_range_max; - htpt_env->temp_type = params->temp_type; - htpt_env->operation = NULL; - memset(htpt_env->ntf_ind_cfg, 0 , sizeof(htpt_env->ntf_ind_cfg)); + // Save features on the environment + htpt_env->features = params->features; + htpt_env->meas_intv = params->meas_intv; + htpt_env->meas_intv_min = params->valid_range_min; + htpt_env->meas_intv_max = params->valid_range_max; + htpt_env->temp_type = params->temp_type; + htpt_env->operation = NULL; + memset(htpt_env->ntf_ind_cfg, 0, sizeof(htpt_env->ntf_ind_cfg)); - // Update measurement interval permissions - if (HTPT_IS_FEATURE_SUPPORTED(params->features, HTPT_MEAS_INTV_CHAR_SUP)) - { - uint16_t perm = PERM(RD, ENABLE); + // Update measurement interval permissions + if (HTPT_IS_FEATURE_SUPPORTED(params->features, HTPT_MEAS_INTV_CHAR_SUP)) { + uint16_t perm = PERM(RD, ENABLE); - //Check if Measurement Interval Char. supports indications - if (HTPT_IS_FEATURE_SUPPORTED(params->features, HTPT_MEAS_INTV_IND_SUP)) - { - perm |= PERM(IND, ENABLE); - } + // Check if Measurement Interval Char. supports indications + if (HTPT_IS_FEATURE_SUPPORTED(params->features, HTPT_MEAS_INTV_IND_SUP)) { + perm |= PERM(IND, ENABLE); + } - //Check if Measurement Interval Char. is writable - if (HTPT_IS_FEATURE_SUPPORTED(params->features, HTPT_MEAS_INTV_WR_SUP)) - { - perm |= PERM(WP, UNAUTH)|PERM(WRITE_REQ, ENABLE); - } + // Check if Measurement Interval Char. is writable + if (HTPT_IS_FEATURE_SUPPORTED(params->features, HTPT_MEAS_INTV_WR_SUP)) { + perm |= PERM(WP, UNAUTH) | PERM(WRITE_REQ, ENABLE); + } - attm_att_set_permission(HTPT_HANDLE(HTS_IDX_MEAS_INTV_VAL), perm, 0); - } - - // service is ready, go into an Idle state - ke_state_set(env->task, HTPT_IDLE); + attm_att_set_permission(HTPT_HANDLE(HTS_IDX_MEAS_INTV_VAL), perm, 0); } - BLE_PRF_HP_FUNC_LEAVE(); + // service is ready, go into an Idle state + ke_state_set(env->task, HTPT_IDLE); + } - return (status); + BLE_PRF_HP_FUNC_LEAVE(); + + return (status); } -static void htpt_destroy(struct prf_task_env* env) -{ - struct htpt_env_tag* htpt_env = (struct htpt_env_tag*) env->env; +static void htpt_destroy(struct prf_task_env *env) { + struct htpt_env_tag *htpt_env = (struct htpt_env_tag *)env->env; - BLE_PRF_HP_FUNC_ENTER(); + BLE_PRF_HP_FUNC_ENTER(); - // free profile environment variables - if(htpt_env->operation != NULL) - { - ke_free(htpt_env->operation); - } + // free profile environment variables + if (htpt_env->operation != NULL) { + ke_free(htpt_env->operation); + } - env->env = NULL; - ke_free(htpt_env); + env->env = NULL; + ke_free(htpt_env); - BLE_PRF_HP_FUNC_LEAVE(); + BLE_PRF_HP_FUNC_LEAVE(); } -static void htpt_create(struct prf_task_env* env, uint8_t conidx) -{ - BLE_PRF_HP_FUNC_ENTER(); +static void htpt_create(struct prf_task_env *env, uint8_t conidx) { + BLE_PRF_HP_FUNC_ENTER(); - /* Clear configuration for this connection */ - struct htpt_env_tag* htpt_env = (struct htpt_env_tag*) env->env; - htpt_env->ntf_ind_cfg[conidx] = 0; + /* Clear configuration for this connection */ + struct htpt_env_tag *htpt_env = (struct htpt_env_tag *)env->env; + htpt_env->ntf_ind_cfg[conidx] = 0; - BLE_PRF_HP_FUNC_LEAVE(); + BLE_PRF_HP_FUNC_LEAVE(); } -static void htpt_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - BLE_PRF_HP_FUNC_ENTER(); +static void htpt_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + BLE_PRF_HP_FUNC_ENTER(); - /* Clear configuration for this connection */ - struct htpt_env_tag* htpt_env = (struct htpt_env_tag*) env->env; - htpt_env->ntf_ind_cfg[conidx] = 0; + /* Clear configuration for this connection */ + struct htpt_env_tag *htpt_env = (struct htpt_env_tag *)env->env; + htpt_env->ntf_ind_cfg[conidx] = 0; - BLE_PRF_HP_FUNC_LEAVE(); + BLE_PRF_HP_FUNC_LEAVE(); } /** **************************************************************************************** * @brief Compute a flag allowing to know attributes to add into the database * - * @return a 16-bit flag whose each bit matches an attribute. If the bit is set to 1, the - * attribute will be added into the database. + * @return a 16-bit flag whose each bit matches an attribute. If the bit is set + *to 1, the attribute will be added into the database. **************************************************************************************** */ -static uint16_t htpt_compute_att_table(uint16_t features) -{ - BLE_PRF_HP_FUNC_ENTER(); +static uint16_t htpt_compute_att_table(uint16_t features) { + BLE_PRF_HP_FUNC_ENTER(); - //Temperature Measurement Characteristic is mandatory - uint16_t att_table = HTPT_TEMP_MEAS_MASK; + // Temperature Measurement Characteristic is mandatory + uint16_t att_table = HTPT_TEMP_MEAS_MASK; - //Check if Temperature Type Char. is supported - if (HTPT_IS_FEATURE_SUPPORTED(features, HTPT_TEMP_TYPE_CHAR_SUP)) - { - att_table |= HTPT_TEMP_TYPE_MASK; + // Check if Temperature Type Char. is supported + if (HTPT_IS_FEATURE_SUPPORTED(features, HTPT_TEMP_TYPE_CHAR_SUP)) { + att_table |= HTPT_TEMP_TYPE_MASK; + } + + // Check if Intermediate Temperature Char. is supported + if (HTPT_IS_FEATURE_SUPPORTED(features, HTPT_INTERM_TEMP_CHAR_SUP)) { + att_table |= HTPT_INTM_TEMP_MASK; + } + + // Check if Measurement Interval Char. is supported + if (HTPT_IS_FEATURE_SUPPORTED(features, HTPT_MEAS_INTV_CHAR_SUP)) { + att_table |= HTPT_MEAS_INTV_MASK; + + // Check if Measurement Interval Char. supports indications + if (HTPT_IS_FEATURE_SUPPORTED(features, HTPT_MEAS_INTV_IND_SUP)) { + att_table |= HTPT_MEAS_INTV_CCC_MASK; } - //Check if Intermediate Temperature Char. is supported - if (HTPT_IS_FEATURE_SUPPORTED(features, HTPT_INTERM_TEMP_CHAR_SUP)) - { - att_table |= HTPT_INTM_TEMP_MASK; + // Check if Measurement Interval Char. is writable + if (HTPT_IS_FEATURE_SUPPORTED(features, HTPT_MEAS_INTV_WR_SUP)) { + att_table |= HTPT_MEAS_INTV_VALID_RGE_MASK; } + } - //Check if Measurement Interval Char. is supported - if (HTPT_IS_FEATURE_SUPPORTED(features, HTPT_MEAS_INTV_CHAR_SUP)) - { - att_table |= HTPT_MEAS_INTV_MASK; + BLE_PRF_HP_FUNC_LEAVE(); - //Check if Measurement Interval Char. supports indications - if (HTPT_IS_FEATURE_SUPPORTED(features, HTPT_MEAS_INTV_IND_SUP)) - { - att_table |= HTPT_MEAS_INTV_CCC_MASK; - } - - //Check if Measurement Interval Char. is writable - if (HTPT_IS_FEATURE_SUPPORTED(features, HTPT_MEAS_INTV_WR_SUP)) - { - att_table |= HTPT_MEAS_INTV_VALID_RGE_MASK; - } - } - - BLE_PRF_HP_FUNC_LEAVE(); - - return att_table; + return att_table; } - /* * GLOBAL VARIABLE DEFINITIONS **************************************************************************************** */ /// HTPT Task interface required by profile manager -const struct prf_task_cbs htpt_itf = -{ - (prf_init_fnct) htpt_init, +const struct prf_task_cbs htpt_itf = { + (prf_init_fnct)htpt_init, htpt_destroy, htpt_create, htpt_cleanup, }; - /* * FUNCTION DEFINITIONS **************************************************************************************** */ -uint8_t htpt_get_valid_rge_offset(uint16_t features) -{ - uint8_t offset = 0; +uint8_t htpt_get_valid_rge_offset(uint16_t features) { + uint8_t offset = 0; - if (HTPT_IS_FEATURE_SUPPORTED(features, HTPT_MEAS_INTV_WR_SUP)) - { - offset += 1; + if (HTPT_IS_FEATURE_SUPPORTED(features, HTPT_MEAS_INTV_WR_SUP)) { + offset += 1; - if (HTPT_IS_FEATURE_SUPPORTED(features, HTPT_MEAS_INTV_IND_SUP)) - { - offset += 1; - } + if (HTPT_IS_FEATURE_SUPPORTED(features, HTPT_MEAS_INTV_IND_SUP)) { + offset += 1; } + } - return offset; + return offset; } -uint8_t htpt_pack_temp_value(uint8_t *packed_temp, struct htp_temp_meas temp_meas) -{ - uint8_t cursor = 0; +uint8_t htpt_pack_temp_value(uint8_t *packed_temp, + struct htp_temp_meas temp_meas) { + uint8_t cursor = 0; - *(packed_temp + cursor) = temp_meas.flags; + *(packed_temp + cursor) = temp_meas.flags; + cursor += 1; + + co_write32p(packed_temp + cursor, temp_meas.temp); + cursor += 4; + + // Time Flag Set + if ((temp_meas.flags & HTP_FLAG_TIME) == HTP_FLAG_TIME) { + cursor += prf_pack_date_time(packed_temp + cursor, &(temp_meas.time_stamp)); + } + + // Type flag set + if ((temp_meas.flags & HTP_FLAG_TYPE) == HTP_FLAG_TYPE) { + *(packed_temp + cursor) = temp_meas.type; cursor += 1; + } - co_write32p(packed_temp + cursor, temp_meas.temp); - cursor += 4; + // Clear unused packet data + if (cursor < HTPT_TEMP_MEAS_MAX_LEN) { + memset(packed_temp + cursor, 0, (HTPT_TEMP_MEAS_MAX_LEN - cursor)); + } - //Time Flag Set - if ((temp_meas.flags & HTP_FLAG_TIME) == HTP_FLAG_TIME) - { - cursor += prf_pack_date_time(packed_temp + cursor, &(temp_meas.time_stamp)); - } - - //Type flag set - if ((temp_meas.flags & HTP_FLAG_TYPE) == HTP_FLAG_TYPE) - { - *(packed_temp + cursor) = temp_meas.type; - cursor += 1; - } - - //Clear unused packet data - if(cursor < HTPT_TEMP_MEAS_MAX_LEN) - { - memset(packed_temp + cursor, 0, (HTPT_TEMP_MEAS_MAX_LEN - cursor)); - } - - return cursor; + return cursor; } -void htpt_exe_operation(void) -{ - BLE_PRF_HP_FUNC_ENTER(); +void htpt_exe_operation(void) { + BLE_PRF_HP_FUNC_ENTER(); - struct htpt_env_tag* htpt_env = PRF_ENV_GET(HTPT, htpt); + struct htpt_env_tag *htpt_env = PRF_ENV_GET(HTPT, htpt); - ASSERT_ERR(htpt_env->operation != NULL); + ASSERT_ERR(htpt_env->operation != NULL); - bool finished = true; + bool finished = true; - while(htpt_env->operation->cursor < BLE_CONNECTION_MAX) - { - // check if this type of event is enabled - if(((htpt_env->ntf_ind_cfg[htpt_env->operation->cursor] & htpt_env->operation->op) != 0) - // and event not filtered on current connection - && (htpt_env->operation->conidx != htpt_env->operation->cursor)) - { - // trigger the event - struct gattc_send_evt_cmd * evt = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC , htpt_env->operation->cursor), prf_src_task_get(&htpt_env->prf_env, 0), - gattc_send_evt_cmd, htpt_env->operation->length); + while (htpt_env->operation->cursor < BLE_CONNECTION_MAX) { + // check if this type of event is enabled + if (((htpt_env->ntf_ind_cfg[htpt_env->operation->cursor] & + htpt_env->operation->op) != 0) + // and event not filtered on current connection + && (htpt_env->operation->conidx != htpt_env->operation->cursor)) { + // trigger the event + struct gattc_send_evt_cmd *evt = + KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, + KE_BUILD_ID(TASK_GATTC, htpt_env->operation->cursor), + prf_src_task_get(&htpt_env->prf_env, 0), + gattc_send_evt_cmd, htpt_env->operation->length); - evt->operation = (htpt_env->operation->op != HTPT_CFG_INTERM_MEAS_NTF) ? GATTC_INDICATE : GATTC_NOTIFY; - evt->length = htpt_env->operation->length; - evt->handle = htpt_env->operation->handle; - memcpy(evt->value, htpt_env->operation->data, evt->length); + evt->operation = (htpt_env->operation->op != HTPT_CFG_INTERM_MEAS_NTF) + ? GATTC_INDICATE + : GATTC_NOTIFY; + evt->length = htpt_env->operation->length; + evt->handle = htpt_env->operation->handle; + memcpy(evt->value, htpt_env->operation->data, evt->length); - ke_msg_send(evt); + ke_msg_send(evt); - finished = false; - htpt_env->operation->cursor++; - break; - } - htpt_env->operation->cursor++; + finished = false; + htpt_env->operation->cursor++; + break; + } + htpt_env->operation->cursor++; + } + + // check if operation is finished + if (finished) { + // do not send response if operation has been locally requested + if (htpt_env->operation->dest_id != + prf_src_task_get(&htpt_env->prf_env, 0)) { + // send response to requester + struct htpt_meas_intv_upd_rsp *rsp = KE_MSG_ALLOC( + ((htpt_env->operation->op == HTPT_CFG_MEAS_INTV_IND) + ? HTPT_MEAS_INTV_UPD_RSP + : HTPT_TEMP_SEND_RSP), + htpt_env->operation->dest_id, prf_src_task_get(&htpt_env->prf_env, 0), + htpt_meas_intv_upd_rsp); + rsp->status = GAP_ERR_NO_ERROR; + ke_msg_send(rsp); } + // free operation + ke_free(htpt_env->operation); + htpt_env->operation = NULL; + // go back to idle state + ke_state_set(prf_src_task_get(&(htpt_env->prf_env), 0), HTPT_IDLE); + } - // check if operation is finished - if(finished) - { - // do not send response if operation has been locally requested - if(htpt_env->operation->dest_id != prf_src_task_get(&htpt_env->prf_env, 0)) - { - // send response to requester - struct htpt_meas_intv_upd_rsp * rsp = - KE_MSG_ALLOC(((htpt_env->operation->op == HTPT_CFG_MEAS_INTV_IND) ? HTPT_MEAS_INTV_UPD_RSP : HTPT_TEMP_SEND_RSP), - htpt_env->operation->dest_id, prf_src_task_get(&htpt_env->prf_env, 0), - htpt_meas_intv_upd_rsp); - rsp->status = GAP_ERR_NO_ERROR; - ke_msg_send(rsp); - } - - // free operation - ke_free(htpt_env->operation); - htpt_env->operation = NULL; - // go back to idle state - ke_state_set(prf_src_task_get(&(htpt_env->prf_env), 0), HTPT_IDLE); - } - - BLE_PRF_HP_FUNC_LEAVE(); + BLE_PRF_HP_FUNC_LEAVE(); } +uint8_t htpt_update_ntf_ind_cfg(uint8_t conidx, uint8_t cfg, uint16_t valid_val, + uint16_t value) { + struct htpt_env_tag *htpt_env = PRF_ENV_GET(HTPT, htpt); + uint8_t status = GAP_ERR_NO_ERROR; -uint8_t htpt_update_ntf_ind_cfg(uint8_t conidx, uint8_t cfg, uint16_t valid_val, uint16_t value) -{ - struct htpt_env_tag* htpt_env = PRF_ENV_GET(HTPT, htpt); - uint8_t status = GAP_ERR_NO_ERROR; + BLE_PRF_HP_FUNC_ENTER(); - BLE_PRF_HP_FUNC_ENTER(); + if ((value != valid_val) && (value != PRF_CLI_STOP_NTFIND)) { + status = PRF_APP_ERROR; - if((value != valid_val) && (value != PRF_CLI_STOP_NTFIND)) - { - status = PRF_APP_ERROR; + } else if (value == valid_val) { + htpt_env->ntf_ind_cfg[conidx] |= cfg; + } else { + htpt_env->ntf_ind_cfg[conidx] &= ~cfg; + } - } - else if (value == valid_val) - { - htpt_env->ntf_ind_cfg[conidx] |= cfg; - } - else - { - htpt_env->ntf_ind_cfg[conidx] &= ~cfg; - } + if (status == GAP_ERR_NO_ERROR) { + // inform application that notification/indication configuration has changed + struct htpt_cfg_indntf_ind *ind = KE_MSG_ALLOC( + HTPT_CFG_INDNTF_IND, prf_dst_task_get(&htpt_env->prf_env, conidx), + prf_src_task_get(&htpt_env->prf_env, conidx), htpt_cfg_indntf_ind); + ind->conidx = conidx; + ind->ntf_ind_cfg = htpt_env->ntf_ind_cfg[conidx]; + ke_msg_send(ind); + } - if(status == GAP_ERR_NO_ERROR) - { - // inform application that notification/indication configuration has changed - struct htpt_cfg_indntf_ind * ind = KE_MSG_ALLOC(HTPT_CFG_INDNTF_IND, - prf_dst_task_get(&htpt_env->prf_env, conidx), prf_src_task_get(&htpt_env->prf_env, conidx), - htpt_cfg_indntf_ind); - ind->conidx = conidx; - ind->ntf_ind_cfg = htpt_env->ntf_ind_cfg[conidx]; - ke_msg_send(ind); - } + BLE_PRF_HP_FUNC_LEAVE(); - BLE_PRF_HP_FUNC_LEAVE(); - - return (status); + return (status); } +const struct prf_task_cbs *htpt_prf_itf_get(void) { return &htpt_itf; } -const struct prf_task_cbs* htpt_prf_itf_get(void) -{ - return &htpt_itf; +uint16_t htpt_att_hdl_get(struct htpt_env_tag *htpt_env, uint8_t att_idx) { + uint16_t handle = htpt_env->shdl; + + do { + // Mandatory attribute handle + if (att_idx > HTS_IDX_TEMP_MEAS_IND_CFG) { + handle += HTPT_TEMP_MEAS_ATT_NB; + } else { + handle += att_idx; + break; + } + + // Temperature Type + if ((HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, + HTPT_TEMP_TYPE_CHAR_SUP)) && + (att_idx > HTS_IDX_TEMP_TYPE_VAL)) { + handle += HTPT_TEMP_TYPE_ATT_NB; + } else if (!HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, + HTPT_TEMP_TYPE_CHAR_SUP)) { + handle = ATT_INVALID_HANDLE; + break; + } else { + handle += att_idx - HTS_IDX_TEMP_TYPE_CHAR; + break; + } + + // Intermediate Temperature Measurement + if ((HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, + HTPT_INTERM_TEMP_CHAR_SUP)) && + (att_idx > HTS_IDX_INTERM_TEMP_CFG)) { + handle += HTPT_INTERM_MEAS_ATT_NB; + } else if (!HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, + HTPT_INTERM_TEMP_CHAR_SUP)) { + handle = ATT_INVALID_HANDLE; + break; + } else { + handle += att_idx - HTS_IDX_INTERM_TEMP_CHAR; + break; + } + + // Measurement Interval + if (!HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, + HTPT_MEAS_INTV_CHAR_SUP) || + (att_idx >= HTS_IDX_NB)) { + handle = ATT_INVALID_HANDLE; + break; + } + + if (att_idx <= HTS_IDX_MEAS_INTV_VAL) { + handle += att_idx - HTS_IDX_MEAS_INTV_CHAR; + break; + } else { + handle += HTPT_MEAS_INTV_ATT_NB; + } + + // Measurement Interval Indication + if (att_idx == HTS_IDX_MEAS_INTV_CFG) { + if (!HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, + HTPT_MEAS_INTV_IND_SUP)) { + handle = ATT_INVALID_HANDLE; + break; + } + } + // Measurement Interval Write permission + else if (HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, + HTPT_MEAS_INTV_WR_SUP)) { + handle += HTPT_MEAS_INTV_CCC_ATT_NB; + + if (!HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, + HTPT_MEAS_INTV_WR_SUP)) { + handle = ATT_INVALID_HANDLE; + break; + } + } + } while (0); + + return handle; } +uint8_t htpt_att_idx_get(struct htpt_env_tag *htpt_env, uint16_t handle) { + uint16_t handle_ref = htpt_env->shdl; + uint8_t att_idx = ATT_INVALID_IDX; -uint16_t htpt_att_hdl_get(struct htpt_env_tag* htpt_env, uint8_t att_idx) -{ - uint16_t handle = htpt_env->shdl; + do { + // not valid hande + if (handle < handle_ref) { + break; + } - do - { - // Mandatory attribute handle - if(att_idx > HTS_IDX_TEMP_MEAS_IND_CFG) - { - handle += HTPT_TEMP_MEAS_ATT_NB; - } - else - { - handle += att_idx; - break; + // Mandatory attribute handle + handle_ref += HTPT_TEMP_MEAS_ATT_NB; + + if (handle < handle_ref) { + att_idx = HTS_IDX_TEMP_TYPE_CHAR - (handle_ref - handle); + break; + } + + // Temperature Type + if (HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, + HTPT_TEMP_TYPE_CHAR_SUP)) { + handle_ref += HTPT_TEMP_TYPE_ATT_NB; + + if (handle < handle_ref) { + att_idx = HTS_IDX_INTERM_TEMP_CHAR - (handle_ref - handle); + break; + } + } + + // Intermediate Temperature Measurement + if (HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, + HTPT_INTERM_TEMP_CHAR_SUP)) { + handle_ref += HTPT_INTERM_MEAS_ATT_NB; + + if (handle < handle_ref) { + att_idx = HTS_IDX_MEAS_INTV_CHAR - (handle_ref - handle); + break; + } + } + + // Measurement Interval + if (HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, + HTPT_MEAS_INTV_CHAR_SUP)) { + handle_ref += HTPT_MEAS_INTV_ATT_NB; + + if (handle < handle_ref) { + att_idx = HTS_IDX_MEAS_INTV_CFG - (handle_ref - handle); + break; + } + + if (HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, + HTPT_MEAS_INTV_IND_SUP)) { + if (handle == handle_ref) { + att_idx = HTS_IDX_MEAS_INTV_CFG; + break; } - // Temperature Type - if((HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, HTPT_TEMP_TYPE_CHAR_SUP)) && (att_idx > HTS_IDX_TEMP_TYPE_VAL)) - { - handle += HTPT_TEMP_TYPE_ATT_NB; - } - else if(!HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, HTPT_TEMP_TYPE_CHAR_SUP)) - { - handle = ATT_INVALID_HANDLE; - break; - } - else - { - handle += att_idx - HTS_IDX_TEMP_TYPE_CHAR; - break; - } + handle_ref += HTPT_MEAS_INTV_CCC_ATT_NB; + } - // Intermediate Temperature Measurement - if((HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, HTPT_INTERM_TEMP_CHAR_SUP)) && (att_idx > HTS_IDX_INTERM_TEMP_CFG)) - { - handle += HTPT_INTERM_MEAS_ATT_NB; - } - else if(!HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, HTPT_INTERM_TEMP_CHAR_SUP)) - { - handle = ATT_INVALID_HANDLE; - break; - } - else - { - handle += att_idx - HTS_IDX_INTERM_TEMP_CHAR; - break; + if (HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, + HTPT_MEAS_INTV_WR_SUP)) { + if (handle == handle_ref) { + att_idx = HTS_IDX_MEAS_INTV_VAL_RANGE; + break; } + } + } + } while (0); - // Measurement Interval - if(!HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, HTPT_MEAS_INTV_CHAR_SUP) || (att_idx >= HTS_IDX_NB)) - { - handle = ATT_INVALID_HANDLE; - break; - } - - if(att_idx <= HTS_IDX_MEAS_INTV_VAL) - { - handle += att_idx - HTS_IDX_MEAS_INTV_CHAR; - break; - } - else - { - handle += HTPT_MEAS_INTV_ATT_NB; - } - - // Measurement Interval Indication - if(att_idx == HTS_IDX_MEAS_INTV_CFG) - { - if(!HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, HTPT_MEAS_INTV_IND_SUP)) - { - handle = ATT_INVALID_HANDLE; - break; - } - } - // Measurement Interval Write permission - else if(HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, HTPT_MEAS_INTV_WR_SUP)) - { - handle += HTPT_MEAS_INTV_CCC_ATT_NB; - - if(!HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, HTPT_MEAS_INTV_WR_SUP)) - { - handle = ATT_INVALID_HANDLE; - break; - } - } - } while (0); - - return handle; + return att_idx; } -uint8_t htpt_att_idx_get(struct htpt_env_tag* htpt_env, uint16_t handle) -{ - uint16_t handle_ref = htpt_env->shdl; - uint8_t att_idx = ATT_INVALID_IDX; - - do - { - // not valid hande - if(handle < handle_ref) - { - break; - } - - // Mandatory attribute handle - handle_ref += HTPT_TEMP_MEAS_ATT_NB; - - if(handle < handle_ref) - { - att_idx = HTS_IDX_TEMP_TYPE_CHAR - (handle_ref - handle); - break; - } - - // Temperature Type - if(HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, HTPT_TEMP_TYPE_CHAR_SUP)) - { - handle_ref += HTPT_TEMP_TYPE_ATT_NB; - - if(handle < handle_ref) - { - att_idx = HTS_IDX_INTERM_TEMP_CHAR - (handle_ref - handle); - break; - } - } - - // Intermediate Temperature Measurement - if(HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, HTPT_INTERM_TEMP_CHAR_SUP)) - { - handle_ref += HTPT_INTERM_MEAS_ATT_NB; - - if(handle < handle_ref) - { - att_idx = HTS_IDX_MEAS_INTV_CHAR - (handle_ref - handle); - break; - } - } - - // Measurement Interval - if(HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, HTPT_MEAS_INTV_CHAR_SUP)) - { - handle_ref += HTPT_MEAS_INTV_ATT_NB; - - if(handle < handle_ref) - { - att_idx = HTS_IDX_MEAS_INTV_CFG - (handle_ref - handle); - break; - } - - if(HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, HTPT_MEAS_INTV_IND_SUP)) - { - if(handle == handle_ref) - { - att_idx = HTS_IDX_MEAS_INTV_CFG; - break; - } - - handle_ref += HTPT_MEAS_INTV_CCC_ATT_NB; - } - - if(HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, HTPT_MEAS_INTV_WR_SUP)) - { - if(handle == handle_ref) - { - att_idx = HTS_IDX_MEAS_INTV_VAL_RANGE; - break; - } - } - } - } while (0); - - return att_idx; -} - - - -#endif //BLE_HT_THERMOM +#endif // BLE_HT_THERMOM /// @} HTPT diff --git a/services/ble_profiles/htp/htpt/src/htpt_task.c b/services/ble_profiles/htp/htpt/src/htpt_task.c index 8c7f5a9..0958bb1 100644 --- a/services/ble_profiles/htp/htpt/src/htpt_task.c +++ b/services/ble_profiles/htp/htpt/src/htpt_task.c @@ -5,7 +5,6 @@ **************************************************************************************** */ - /* * INCLUDE FILES **************************************************************************************** @@ -14,15 +13,15 @@ #if (BLE_HT_THERMOM) +#include "attm.h" #include "gap.h" #include "gattc_task.h" -#include "attm.h" #include "htpt.h" #include "htpt_task.h" #include "prf_utils.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * FUNCTION DEFINITIONS @@ -41,32 +40,29 @@ **************************************************************************************** */ __STATIC int htpt_enable_req_handler(ke_msg_id_t const msgid, - struct htpt_enable_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t status = PRF_ERR_REQ_DISALLOWED; + struct htpt_enable_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t status = PRF_ERR_REQ_DISALLOWED; - // check state of the task - if(gapc_get_conhdl(param->conidx) != GAP_INVALID_CONHDL) - { - // restore Bond Data - struct htpt_env_tag* htpt_env = PRF_ENV_GET(HTPT, htpt); - htpt_env->ntf_ind_cfg[param->conidx] = param->ntf_ind_cfg; - status = GAP_ERR_NO_ERROR; + // check state of the task + if (gapc_get_conhdl(param->conidx) != GAP_INVALID_CONHDL) { + // restore Bond Data + struct htpt_env_tag *htpt_env = PRF_ENV_GET(HTPT, htpt); + htpt_env->ntf_ind_cfg[param->conidx] = param->ntf_ind_cfg; + status = GAP_ERR_NO_ERROR; + } - } + // send response + struct htpt_enable_rsp *rsp = + KE_MSG_ALLOC(HTPT_ENABLE_RSP, src_id, dest_id, htpt_enable_rsp); + rsp->conidx = param->conidx; + rsp->status = status; + ke_msg_send(rsp); - // send response - struct htpt_enable_rsp *rsp = KE_MSG_ALLOC(HTPT_ENABLE_RSP, src_id, dest_id, htpt_enable_rsp); - rsp->conidx = param->conidx; - rsp->status = status; - ke_msg_send(rsp); - - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } - /** **************************************************************************************** * @brief Handles reception of the @ref HTPT_TEMP_SEND_REQ message. @@ -78,65 +74,61 @@ __STATIC int htpt_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int htpt_temp_send_req_handler(ke_msg_id_t const msgid, - struct htpt_temp_send_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - int msg_status = KE_MSG_SAVED; - uint8_t state = ke_state_get(dest_id); + struct htpt_temp_send_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + int msg_status = KE_MSG_SAVED; + uint8_t state = ke_state_get(dest_id); - // check state of the task - if(state == HTPT_IDLE) - { - // Get the address of the environment - struct htpt_env_tag *htpt_env = PRF_ENV_GET(HTPT, htpt); + // check state of the task + if (state == HTPT_IDLE) { + // Get the address of the environment + struct htpt_env_tag *htpt_env = PRF_ENV_GET(HTPT, htpt); - // for intermediate measurement, feature must be enabled - if(!(param->stable_meas) && (!HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, HTPT_INTERM_TEMP_CHAR_SUP))) - { - struct htpt_temp_send_rsp *rsp = KE_MSG_ALLOC(HTPT_TEMP_SEND_RSP, src_id, dest_id, htpt_temp_send_rsp); - rsp->status = PRF_ERR_FEATURE_NOT_SUPPORTED; - ke_msg_send(rsp); - } - else - { - // allocate operation to execute - htpt_env->operation = (struct htpt_op *) ke_malloc(sizeof(struct htpt_op) + HTPT_TEMP_MEAS_MAX_LEN, KE_MEM_ATT_DB); + // for intermediate measurement, feature must be enabled + if (!(param->stable_meas) && + (!HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, + HTPT_INTERM_TEMP_CHAR_SUP))) { + struct htpt_temp_send_rsp *rsp = + KE_MSG_ALLOC(HTPT_TEMP_SEND_RSP, src_id, dest_id, htpt_temp_send_rsp); + rsp->status = PRF_ERR_FEATURE_NOT_SUPPORTED; + ke_msg_send(rsp); + } else { + // allocate operation to execute + htpt_env->operation = (struct htpt_op *)ke_malloc( + sizeof(struct htpt_op) + HTPT_TEMP_MEAS_MAX_LEN, KE_MEM_ATT_DB); - // Initialize operation parameters - htpt_env->operation->cursor = 0; - htpt_env->operation->dest_id = src_id; - htpt_env->operation->conidx = GAP_INVALID_CONIDX; + // Initialize operation parameters + htpt_env->operation->cursor = 0; + htpt_env->operation->dest_id = src_id; + htpt_env->operation->conidx = GAP_INVALID_CONIDX; - // Stable measurement indication or intermediate measurement notification - if(param->stable_meas) - { - htpt_env->operation->op = HTPT_CFG_STABLE_MEAS_IND; - htpt_env->operation->handle = HTPT_HANDLE(HTS_IDX_TEMP_MEAS_VAL); - } - else - { - htpt_env->operation->op = HTPT_CFG_INTERM_MEAS_NTF; - htpt_env->operation->handle = HTPT_HANDLE(HTS_IDX_INTERM_TEMP_VAL); - } + // Stable measurement indication or intermediate measurement notification + if (param->stable_meas) { + htpt_env->operation->op = HTPT_CFG_STABLE_MEAS_IND; + htpt_env->operation->handle = HTPT_HANDLE(HTS_IDX_TEMP_MEAS_VAL); + } else { + htpt_env->operation->op = HTPT_CFG_INTERM_MEAS_NTF; + htpt_env->operation->handle = HTPT_HANDLE(HTS_IDX_INTERM_TEMP_VAL); + } - //Pack the temperature measurement value - htpt_env->operation->length = htpt_pack_temp_value(&(htpt_env->operation->data[0]), param->temp_meas); + // Pack the temperature measurement value + htpt_env->operation->length = htpt_pack_temp_value( + &(htpt_env->operation->data[0]), param->temp_meas); - // put task in a busy state - ke_state_set(dest_id, HTPT_BUSY); + // put task in a busy state + ke_state_set(dest_id, HTPT_BUSY); - // execute operation - htpt_exe_operation(); - } - - msg_status = KE_MSG_CONSUMED; + // execute operation + htpt_exe_operation(); } - return (msg_status); -} + msg_status = KE_MSG_CONSUMED; + } + return (msg_status); +} /** **************************************************************************************** @@ -148,71 +140,68 @@ __STATIC int htpt_temp_send_req_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int htpt_meas_intv_upd_req_handler(ke_msg_id_t const msgid, - struct htpt_meas_intv_upd_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - int msg_status = KE_MSG_SAVED; - uint8_t state = ke_state_get(dest_id); +__STATIC int htpt_meas_intv_upd_req_handler( + ke_msg_id_t const msgid, struct htpt_meas_intv_upd_req const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + int msg_status = KE_MSG_SAVED; + uint8_t state = ke_state_get(dest_id); - // check state of the task - if(state == HTPT_IDLE) - { - // Get the address of the environment - struct htpt_env_tag *htpt_env = PRF_ENV_GET(HTPT, htpt); + // check state of the task + if (state == HTPT_IDLE) { + // Get the address of the environment + struct htpt_env_tag *htpt_env = PRF_ENV_GET(HTPT, htpt); - // update measurement interval - htpt_env->meas_intv = param->meas_intv; + // update measurement interval + htpt_env->meas_intv = param->meas_intv; - //Check if Measurement Interval indication is supported - if(!HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, HTPT_MEAS_INTV_CHAR_SUP)) - { - struct htpt_meas_intv_upd_rsp *rsp = KE_MSG_ALLOC(HTPT_MEAS_INTV_UPD_RSP, src_id, dest_id, htpt_meas_intv_upd_rsp); - rsp->status = PRF_ERR_FEATURE_NOT_SUPPORTED; - ke_msg_send(rsp); - } - else - { - // update internal measurement interval value - htpt_env->meas_intv = param->meas_intv; + // Check if Measurement Interval indication is supported + if (!HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, + HTPT_MEAS_INTV_CHAR_SUP)) { + struct htpt_meas_intv_upd_rsp *rsp = KE_MSG_ALLOC( + HTPT_MEAS_INTV_UPD_RSP, src_id, dest_id, htpt_meas_intv_upd_rsp); + rsp->status = PRF_ERR_FEATURE_NOT_SUPPORTED; + ke_msg_send(rsp); + } else { + // update internal measurement interval value + htpt_env->meas_intv = param->meas_intv; - // no indication to trigger - if(!HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, HTPT_MEAS_INTV_IND_SUP)) - { - struct htpt_meas_intv_upd_rsp *rsp = KE_MSG_ALLOC(HTPT_MEAS_INTV_UPD_RSP, src_id, dest_id, htpt_meas_intv_upd_rsp); - rsp->status = GAP_ERR_NO_ERROR; - ke_msg_send(rsp); - } - // trigger measurement update indication - else - { - // allocate operation to execute - htpt_env->operation = (struct htpt_op *) ke_malloc(sizeof(struct htpt_op) + HTPT_MEAS_INTV_MAX_LEN, KE_MEM_ATT_DB); + // no indication to trigger + if (!HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, + HTPT_MEAS_INTV_IND_SUP)) { + struct htpt_meas_intv_upd_rsp *rsp = KE_MSG_ALLOC( + HTPT_MEAS_INTV_UPD_RSP, src_id, dest_id, htpt_meas_intv_upd_rsp); + rsp->status = GAP_ERR_NO_ERROR; + ke_msg_send(rsp); + } + // trigger measurement update indication + else { + // allocate operation to execute + htpt_env->operation = (struct htpt_op *)ke_malloc( + sizeof(struct htpt_op) + HTPT_MEAS_INTV_MAX_LEN, KE_MEM_ATT_DB); - // Initialize operation parameters - htpt_env->operation->op = HTPT_CFG_MEAS_INTV_IND; - htpt_env->operation->handle = HTPT_HANDLE(HTS_IDX_MEAS_INTV_VAL); - htpt_env->operation->dest_id = src_id; - htpt_env->operation->cursor = 0; - htpt_env->operation->conidx = GAP_INVALID_CONIDX; + // Initialize operation parameters + htpt_env->operation->op = HTPT_CFG_MEAS_INTV_IND; + htpt_env->operation->handle = HTPT_HANDLE(HTS_IDX_MEAS_INTV_VAL); + htpt_env->operation->dest_id = src_id; + htpt_env->operation->cursor = 0; + htpt_env->operation->conidx = GAP_INVALID_CONIDX; - // Pack the interval value - htpt_env->operation->length = HTPT_MEAS_INTV_MAX_LEN; - co_write16p(htpt_env->operation->data, param->meas_intv); + // Pack the interval value + htpt_env->operation->length = HTPT_MEAS_INTV_MAX_LEN; + co_write16p(htpt_env->operation->data, param->meas_intv); - // put task in a busy state - ke_state_set(dest_id, HTPT_BUSY); + // put task in a busy state + ke_state_set(dest_id, HTPT_BUSY); - // execute operation - htpt_exe_operation(); - } - } - - msg_status = KE_MSG_CONSUMED; + // execute operation + htpt_exe_operation(); + } } - return (msg_status); + msg_status = KE_MSG_CONSUMED; + } + + return (msg_status); } /** @@ -226,53 +215,46 @@ __STATIC int htpt_meas_intv_upd_req_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_att_info_req_ind *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - struct htpt_env_tag* htpt_env = PRF_ENV_GET(HTPT, htpt); - uint8_t att_idx = HTPT_IDX(param->handle); - struct gattc_att_info_cfm * cfm; +__STATIC int gattc_att_info_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_att_info_req_ind *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + struct htpt_env_tag *htpt_env = PRF_ENV_GET(HTPT, htpt); + uint8_t att_idx = HTPT_IDX(param->handle); + struct gattc_att_info_cfm *cfm; - //Send write response - cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); - cfm->handle = param->handle; + // Send write response + cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); + cfm->handle = param->handle; - switch(att_idx) - { - case HTS_IDX_MEAS_INTV_VAL: - { - // force length to zero to reject any write starting from something != 0 - cfm->length = 0; - cfm->status = GAP_ERR_NO_ERROR; - }break; + switch (att_idx) { + case HTS_IDX_MEAS_INTV_VAL: { + // force length to zero to reject any write starting from something != 0 + cfm->length = 0; + cfm->status = GAP_ERR_NO_ERROR; + } break; - case HTS_IDX_TEMP_MEAS_IND_CFG: - case HTS_IDX_INTERM_TEMP_CFG: - case HTS_IDX_MEAS_INTV_CFG: - { - cfm->length = HTPT_IND_NTF_CFG_MAX_LEN; - cfm->status = GAP_ERR_NO_ERROR; - }break; + case HTS_IDX_TEMP_MEAS_IND_CFG: + case HTS_IDX_INTERM_TEMP_CFG: + case HTS_IDX_MEAS_INTV_CFG: { + cfm->length = HTPT_IND_NTF_CFG_MAX_LEN; + cfm->status = GAP_ERR_NO_ERROR; + } break; - default: - { - cfm->status = ATT_ERR_REQUEST_NOT_SUPPORTED; - }break; - } + default: { + cfm->status = ATT_ERR_REQUEST_NOT_SUPPORTED; + } break; + } - ke_msg_send(cfm); + ke_msg_send(cfm); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } - - /** **************************************************************************************** * @brief Handles reception of the @ref GL2C_CODE_ATT_WR_CMD_IND message. - * The handler compares the new values with current ones and notifies them if they changed. + * The handler compares the new values with current ones and notifies them if + *they changed. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -280,118 +262,111 @@ __STATIC int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_write_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ +__STATIC int gattc_write_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { - struct htpt_env_tag* htpt_env = PRF_ENV_GET(HTPT, htpt); - uint8_t conidx = KE_IDX_GET(src_id); - uint8_t status = ATT_ERR_NO_ERROR; - int msg_status = KE_MSG_CONSUMED; + struct htpt_env_tag *htpt_env = PRF_ENV_GET(HTPT, htpt); + uint8_t conidx = KE_IDX_GET(src_id); + uint8_t status = ATT_ERR_NO_ERROR; + int msg_status = KE_MSG_CONSUMED; - // to check if confirmation message should be send - bool send_cfm = true; + // to check if confirmation message should be send + bool send_cfm = true; - // retrieve handle information - uint8_t att_idx = HTPT_IDX(param->handle); + // retrieve handle information + uint8_t att_idx = HTPT_IDX(param->handle); - if(param->length != HTPT_MEAS_INTV_MAX_LEN) - { - status = PRF_ERR_UNEXPECTED_LEN; - } - else - { - switch(att_idx) - { - case HTS_IDX_MEAS_INTV_VAL: - { - uint16_t meas_intv = co_read16p(param->value); + if (param->length != HTPT_MEAS_INTV_MAX_LEN) { + status = PRF_ERR_UNEXPECTED_LEN; + } else { + switch (att_idx) { + case HTS_IDX_MEAS_INTV_VAL: { + uint16_t meas_intv = co_read16p(param->value); - // check measurement length validity - if(((meas_intv >= htpt_env->meas_intv_min) && (meas_intv <= htpt_env->meas_intv_max)) - // notification can be disabled anyway - || (meas_intv == 0)) - { - uint8_t state = ke_state_get(dest_id); - send_cfm = false; + // check measurement length validity + if (((meas_intv >= htpt_env->meas_intv_min) && + (meas_intv <= htpt_env->meas_intv_max)) + // notification can be disabled anyway + || (meas_intv == 0)) { + uint8_t state = ke_state_get(dest_id); + send_cfm = false; - // check state of the task to know if it can be proceed immediately - if(state == HTPT_IDLE) - { - // inform application that update of measurement interval is requested by peer device. - struct htpt_meas_intv_chg_req_ind * req_ind = KE_MSG_ALLOC(HTPT_MEAS_INTV_CHG_REQ_IND, - prf_dst_task_get(&htpt_env->prf_env, conidx), dest_id, htpt_meas_intv_chg_req_ind); - req_ind->conidx = conidx; - req_ind->intv = meas_intv; - ke_msg_send(req_ind); + // check state of the task to know if it can be proceed immediately + if (state == HTPT_IDLE) { + // inform application that update of measurement interval is requested + // by peer device. + struct htpt_meas_intv_chg_req_ind *req_ind = + KE_MSG_ALLOC(HTPT_MEAS_INTV_CHG_REQ_IND, + prf_dst_task_get(&htpt_env->prf_env, conidx), + dest_id, htpt_meas_intv_chg_req_ind); + req_ind->conidx = conidx; + req_ind->intv = meas_intv; + ke_msg_send(req_ind); - // allocate operation to execute - htpt_env->operation = (struct htpt_op *) ke_malloc(sizeof(struct htpt_op) + HTPT_MEAS_INTV_MAX_LEN, KE_MEM_ATT_DB); + // allocate operation to execute + htpt_env->operation = (struct htpt_op *)ke_malloc( + sizeof(struct htpt_op) + HTPT_MEAS_INTV_MAX_LEN, KE_MEM_ATT_DB); - // Initialize operation parameters - htpt_env->operation->op = HTPT_CFG_MEAS_INTV_IND; - htpt_env->operation->handle = HTPT_HANDLE(HTS_IDX_MEAS_INTV_VAL); - htpt_env->operation->dest_id = dest_id; - htpt_env->operation->conidx = conidx; - // to be sure that no notification will be triggered - htpt_env->operation->cursor = 0xFF; + // Initialize operation parameters + htpt_env->operation->op = HTPT_CFG_MEAS_INTV_IND; + htpt_env->operation->handle = HTPT_HANDLE(HTS_IDX_MEAS_INTV_VAL); + htpt_env->operation->dest_id = dest_id; + htpt_env->operation->conidx = conidx; + // to be sure that no notification will be triggered + htpt_env->operation->cursor = 0xFF; - // Pack the interval value - htpt_env->operation->length = HTPT_MEAS_INTV_MAX_LEN; - co_write16p(htpt_env->operation->data, meas_intv); + // Pack the interval value + htpt_env->operation->length = HTPT_MEAS_INTV_MAX_LEN; + co_write16p(htpt_env->operation->data, meas_intv); - // put task in a busy state - ke_state_set(dest_id, HTPT_BUSY); - } - else - { - msg_status = KE_MSG_SAVED; - } - } - else - { - // value not in expected range - status = HTP_OUT_OF_RANGE_ERR_CODE; - } - }break; - - case HTS_IDX_TEMP_MEAS_IND_CFG: - { - status = htpt_update_ntf_ind_cfg(conidx, HTPT_CFG_STABLE_MEAS_IND, PRF_CLI_START_IND, co_read16p(param->value)); - }break; - - case HTS_IDX_INTERM_TEMP_CFG: - { - status = htpt_update_ntf_ind_cfg(conidx, HTPT_CFG_INTERM_MEAS_NTF, PRF_CLI_START_NTF, co_read16p(param->value)); - }break; - - case HTS_IDX_MEAS_INTV_CFG: - { - status = htpt_update_ntf_ind_cfg(conidx, HTPT_CFG_MEAS_INTV_IND, PRF_CLI_START_IND, co_read16p(param->value)); - }break; - - default: - { - status = ATT_ERR_REQUEST_NOT_SUPPORTED; - }break; + // put task in a busy state + ke_state_set(dest_id, HTPT_BUSY); + } else { + msg_status = KE_MSG_SAVED; } - } + } else { + // value not in expected range + status = HTP_OUT_OF_RANGE_ERR_CODE; + } + } break; - if(send_cfm) - { - //Send write response - struct gattc_write_cfm * cfm = KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = status; - ke_msg_send(cfm); - } + case HTS_IDX_TEMP_MEAS_IND_CFG: { + status = + htpt_update_ntf_ind_cfg(conidx, HTPT_CFG_STABLE_MEAS_IND, + PRF_CLI_START_IND, co_read16p(param->value)); + } break; - return (msg_status); + case HTS_IDX_INTERM_TEMP_CFG: { + status = + htpt_update_ntf_ind_cfg(conidx, HTPT_CFG_INTERM_MEAS_NTF, + PRF_CLI_START_NTF, co_read16p(param->value)); + } break; + + case HTS_IDX_MEAS_INTV_CFG: { + status = + htpt_update_ntf_ind_cfg(conidx, HTPT_CFG_MEAS_INTV_IND, + PRF_CLI_START_IND, co_read16p(param->value)); + } break; + + default: { + status = ATT_ERR_REQUEST_NOT_SUPPORTED; + } break; + } + } + + if (send_cfm) { + // Send write response + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = status; + ke_msg_send(cfm); + } + + return (msg_status); } - /** **************************************************************************************** * @brief Handles reception of the @ref GATTC_READ_REQ_IND message. @@ -402,74 +377,77 @@ __STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - struct htpt_env_tag* htpt_env = PRF_ENV_GET(HTPT, htpt); - uint8_t conidx = KE_IDX_GET(src_id); - uint8_t value[HTPT_MEAS_INTV_RANGE_MAX_LEN]; - uint8_t value_size = 0; - uint8_t status = ATT_ERR_NO_ERROR; +__STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, + struct gattc_write_req_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + struct htpt_env_tag *htpt_env = PRF_ENV_GET(HTPT, htpt); + uint8_t conidx = KE_IDX_GET(src_id); + uint8_t value[HTPT_MEAS_INTV_RANGE_MAX_LEN]; + uint8_t value_size = 0; + uint8_t status = ATT_ERR_NO_ERROR; - // retrieve handle information - uint8_t att_idx = HTPT_IDX(param->handle); + // retrieve handle information + uint8_t att_idx = HTPT_IDX(param->handle); - switch(att_idx) - { - case HTS_IDX_MEAS_INTV_VAL: - { - value_size = HTPT_MEAS_INTV_MAX_LEN; - co_write16p(&(value[0]), htpt_env->meas_intv); - }break; + switch (att_idx) { + case HTS_IDX_MEAS_INTV_VAL: { + value_size = HTPT_MEAS_INTV_MAX_LEN; + co_write16p(&(value[0]), htpt_env->meas_intv); + } break; - case HTS_IDX_MEAS_INTV_VAL_RANGE: - { - value_size = HTPT_MEAS_INTV_RANGE_MAX_LEN; - co_write16p(&(value[0]), htpt_env->meas_intv_min); - co_write16p(&(value[2]), htpt_env->meas_intv_max); - }break; + case HTS_IDX_MEAS_INTV_VAL_RANGE: { + value_size = HTPT_MEAS_INTV_RANGE_MAX_LEN; + co_write16p(&(value[0]), htpt_env->meas_intv_min); + co_write16p(&(value[2]), htpt_env->meas_intv_max); + } break; - case HTS_IDX_TEMP_MEAS_IND_CFG: - { - value_size = HTPT_IND_NTF_CFG_MAX_LEN; - co_write16p(value, ((htpt_env->ntf_ind_cfg[conidx] & HTPT_CFG_STABLE_MEAS_IND) != 0) ? PRF_CLI_START_IND : PRF_CLI_STOP_NTFIND); - }break; + case HTS_IDX_TEMP_MEAS_IND_CFG: { + value_size = HTPT_IND_NTF_CFG_MAX_LEN; + co_write16p( + value, ((htpt_env->ntf_ind_cfg[conidx] & HTPT_CFG_STABLE_MEAS_IND) != 0) + ? PRF_CLI_START_IND + : PRF_CLI_STOP_NTFIND); + } break; - case HTS_IDX_INTERM_TEMP_CFG: - { - value_size = HTPT_IND_NTF_CFG_MAX_LEN; - co_write16p(value, ((htpt_env->ntf_ind_cfg[conidx] & HTPT_CFG_INTERM_MEAS_NTF) != 0) ? PRF_CLI_START_NTF : PRF_CLI_STOP_NTFIND); - }break; + case HTS_IDX_INTERM_TEMP_CFG: { + value_size = HTPT_IND_NTF_CFG_MAX_LEN; + co_write16p( + value, ((htpt_env->ntf_ind_cfg[conidx] & HTPT_CFG_INTERM_MEAS_NTF) != 0) + ? PRF_CLI_START_NTF + : PRF_CLI_STOP_NTFIND); + } break; - case HTS_IDX_MEAS_INTV_CFG: - { - value_size = HTPT_IND_NTF_CFG_MAX_LEN; - co_write16p(value, ((htpt_env->ntf_ind_cfg[conidx] & HTPT_CFG_MEAS_INTV_IND) != 0) ? PRF_CLI_START_IND : PRF_CLI_STOP_NTFIND); - }break; + case HTS_IDX_MEAS_INTV_CFG: { + value_size = HTPT_IND_NTF_CFG_MAX_LEN; + co_write16p(value, + ((htpt_env->ntf_ind_cfg[conidx] & HTPT_CFG_MEAS_INTV_IND) != 0) + ? PRF_CLI_START_IND + : PRF_CLI_STOP_NTFIND); + } break; - case HTS_IDX_TEMP_TYPE_VAL: - { - value_size = HTPT_TEMP_TYPE_MAX_LEN; - value[0] = htpt_env->temp_type; - }break; + case HTS_IDX_TEMP_TYPE_VAL: { + value_size = HTPT_TEMP_TYPE_MAX_LEN; + value[0] = htpt_env->temp_type; + } break; - default: - { - status = ATT_ERR_REQUEST_NOT_SUPPORTED; - }break; - } + default: { + status = ATT_ERR_REQUEST_NOT_SUPPORTED; + } break; + } - // Send data to peer device - struct gattc_read_cfm* cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, value_size); - cfm->length = value_size; - memcpy(cfm->value, value, value_size); - cfm->handle = param->handle; - cfm->status = status; + // Send data to peer device + struct gattc_read_cfm *cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, + gattc_read_cfm, value_size); + cfm->length = value_size; + memcpy(cfm->value, value, value_size); + cfm->handle = param->handle; + cfm->status = status; - // Send value to peer device. - ke_msg_send(cfm); + // Send value to peer device. + ke_msg_send(cfm); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -482,55 +460,51 @@ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, struct gattc_wr * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int htpt_meas_intv_chg_cfm_handler(ke_msg_id_t const msgid, struct htpt_meas_intv_chg_cfm const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - struct htpt_env_tag* htpt_env = PRF_ENV_GET(HTPT, htpt); +__STATIC int htpt_meas_intv_chg_cfm_handler( + ke_msg_id_t const msgid, struct htpt_meas_intv_chg_cfm const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + struct htpt_env_tag *htpt_env = PRF_ENV_GET(HTPT, htpt); - uint8_t state = ke_state_get(dest_id); + uint8_t state = ke_state_get(dest_id); - // check state of the task - if(state == HTPT_BUSY) - { - // retrieve connection index from operation - uint8_t conidx = htpt_env->operation->conidx; + // check state of the task + if (state == HTPT_BUSY) { + // retrieve connection index from operation + uint8_t conidx = htpt_env->operation->conidx; - //Send write response - struct gattc_write_cfm * cfm = KE_MSG_ALLOC(GATTC_WRITE_CFM, - KE_BUILD_ID(TASK_GATTC, conidx), dest_id, gattc_write_cfm); - cfm->handle = HTPT_HANDLE(HTS_IDX_MEAS_INTV_VAL); - cfm->status = (param->conidx == conidx) ? param->status : PRF_APP_ERROR; - ke_msg_send(cfm); + // Send write response + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, KE_BUILD_ID(TASK_GATTC, conidx), dest_id, + gattc_write_cfm); + cfm->handle = HTPT_HANDLE(HTS_IDX_MEAS_INTV_VAL); + cfm->status = (param->conidx == conidx) ? param->status : PRF_APP_ERROR; + ke_msg_send(cfm); + // check if no error occurs + if (cfm->status == GAP_ERR_NO_ERROR) { + // update the current measurement interval + htpt_env->meas_intv = co_read16p(htpt_env->operation->data); - // check if no error occurs - if(cfm->status == GAP_ERR_NO_ERROR) - { - // update the current measurement interval - htpt_env->meas_intv = co_read16p(htpt_env->operation->data); - - // check if an indication of new measurement interval should be triggered - if(HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, HTPT_MEAS_INTV_IND_SUP)) - { - // set back cursor to zero in order to send indication - htpt_env->operation->cursor = 0; - } - } - - // send indication or terminate operation - htpt_exe_operation(); + // check if an indication of new measurement interval should be triggered + if (HTPT_IS_FEATURE_SUPPORTED(htpt_env->features, + HTPT_MEAS_INTV_IND_SUP)) { + // set back cursor to zero in order to send indication + htpt_env->operation->cursor = 0; + } } - return (KE_MSG_CONSUMED); + // send indication or terminate operation + htpt_exe_operation(); + } + + return (KE_MSG_CONSUMED); } - - - /** **************************************************************************************** - * @brief Handles @ref GATTC_CMP_EVT for GATTC_NOTIFY and GATT_INDICATE message meaning - * that Measurement notification/indication has been correctly sent to peer device + * @brief Handles @ref GATTC_CMP_EVT for GATTC_NOTIFY and GATT_INDICATE message + *meaning that Measurement notification/indication has been correctly sent to + *peer device * * * @param[in] msgid Id of the message received. @@ -540,13 +514,14 @@ __STATIC int htpt_meas_intv_chg_cfm_handler(ke_msg_id_t const msgid, struct htpt * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - // continue operation execution - htpt_exe_operation(); +__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // continue operation execution + htpt_exe_operation(); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /* @@ -555,35 +530,33 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt */ /// Default State handlers definition -KE_MSG_HANDLER_TAB(htpt) -{ - {HTPT_ENABLE_REQ, (ke_msg_func_t) htpt_enable_req_handler}, +KE_MSG_HANDLER_TAB(htpt){ + {HTPT_ENABLE_REQ, (ke_msg_func_t)htpt_enable_req_handler}, - {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t) gattc_att_info_req_ind_handler}, - {GATTC_WRITE_REQ_IND, (ke_msg_func_t) gattc_write_req_ind_handler}, - {GATTC_READ_REQ_IND, (ke_msg_func_t) gattc_read_req_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t) gattc_cmp_evt_handler}, + {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t)gattc_att_info_req_ind_handler}, + {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, + {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, - {HTPT_TEMP_SEND_REQ, (ke_msg_func_t) htpt_temp_send_req_handler}, - {HTPT_MEAS_INTV_UPD_REQ, (ke_msg_func_t) htpt_meas_intv_upd_req_handler}, - {HTPT_MEAS_INTV_CHG_CFM, (ke_msg_func_t) htpt_meas_intv_chg_cfm_handler}, + {HTPT_TEMP_SEND_REQ, (ke_msg_func_t)htpt_temp_send_req_handler}, + {HTPT_MEAS_INTV_UPD_REQ, (ke_msg_func_t)htpt_meas_intv_upd_req_handler}, + {HTPT_MEAS_INTV_CHG_CFM, (ke_msg_func_t)htpt_meas_intv_chg_cfm_handler}, }; -void htpt_task_init(struct ke_task_desc *task_desc) -{ - BLE_PRF_HP_FUNC_ENTER(); +void htpt_task_init(struct ke_task_desc *task_desc) { + BLE_PRF_HP_FUNC_ENTER(); - // Get the address of the environment - struct htpt_env_tag *htpt_env = PRF_ENV_GET(HTPT, htpt); + // Get the address of the environment + struct htpt_env_tag *htpt_env = PRF_ENV_GET(HTPT, htpt); - task_desc->msg_handler_tab = htpt_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(htpt_msg_handler_tab); - task_desc->state = htpt_env->state; - task_desc->idx_max = HTPT_IDX_MAX; + task_desc->msg_handler_tab = htpt_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(htpt_msg_handler_tab); + task_desc->state = htpt_env->state; + task_desc->idx_max = HTPT_IDX_MAX; - BLE_PRF_HP_FUNC_LEAVE(); + BLE_PRF_HP_FUNC_LEAVE(); } -#endif //BLE_HT_THERMOM +#endif // BLE_HT_THERMOM /// @} HTPTTASK diff --git a/services/ble_profiles/lan/lanc/src/lanc.c b/services/ble_profiles/lan/lanc/src/lanc.c index ccbb4b4..eaab1d7 100644 --- a/services/ble_profiles/lan/lanc/src/lanc.c +++ b/services/ble_profiles/lan/lanc/src/lanc.c @@ -17,16 +17,15 @@ #include "lanc.h" #include "lanc_task.h" -#include "ke_timer.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" +#include "ke_timer.h" /* * GLOBAL VARIABLES DECLARATION **************************************************************************************** */ - /* * LOCAL FUNCTION DEFINITIONS **************************************************************************************** @@ -44,42 +43,46 @@ * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t lanc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t idx; - //-------------------- allocate memory required for the profile --------------------- +static uint8_t lanc_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t idx; + //-------------------- allocate memory required for the profile + //--------------------- - struct lanc_env_tag* lanc_env = - (struct lanc_env_tag* ) ke_malloc(sizeof(struct lanc_env_tag), KE_MEM_ATT_DB); + struct lanc_env_tag *lanc_env = (struct lanc_env_tag *)ke_malloc( + sizeof(struct lanc_env_tag), KE_MEM_ATT_DB); - // allocate LANC required environment variable - env->env = (prf_env_t*) lanc_env; + // allocate LANC required environment variable + env->env = (prf_env_t *)lanc_env; - lanc_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - lanc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + lanc_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + lanc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_LANC; - lanc_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_LANC; + lanc_task_init(&(env->desc)); - for(idx = 0; idx < LANC_IDX_MAX ; idx++) - { - lanc_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), LANC_FREE); - } + for (idx = 0; idx < LANC_IDX_MAX; idx++) { + lanc_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), LANC_FREE); + } - return GAP_ERR_NO_ERROR; + return GAP_ERR_NO_ERROR; } /** @@ -91,50 +94,47 @@ static uint8_t lanc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_ * @param[in] reason Detach reason **************************************************************************************** */ -static void lanc_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct lanc_env_tag* lanc_env = (struct lanc_env_tag*) env->env; +static void lanc_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct lanc_env_tag *lanc_env = (struct lanc_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(lanc_env->env[conidx] != NULL) - { - if (lanc_env->env[conidx]->operation != NULL) - { - ke_free(ke_param2msg(lanc_env->env[conidx]->operation)); - } - ke_timer_clear(LANC_TIMEOUT_TIMER_IND, prf_src_task_get(&lanc_env->prf_env, conidx)); - - ke_free(lanc_env->env[conidx]); - lanc_env->env[conidx] = NULL; + // clean-up environment variable allocated for task instance + if (lanc_env->env[conidx] != NULL) { + if (lanc_env->env[conidx]->operation != NULL) { + ke_free(ke_param2msg(lanc_env->env[conidx]->operation)); } + ke_timer_clear(LANC_TIMEOUT_TIMER_IND, + prf_src_task_get(&lanc_env->prf_env, conidx)); - /* Put LAN Client in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), LANC_FREE); + ke_free(lanc_env->env[conidx]); + lanc_env->env[conidx] = NULL; + } + + /* Put LAN Client in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), LANC_FREE); } /** **************************************************************************************** * @brief Destruction of the LANC module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void lanc_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct lanc_env_tag* lanc_env = (struct lanc_env_tag*) env->env; +static void lanc_destroy(struct prf_task_env *env) { + uint8_t idx; + struct lanc_env_tag *lanc_env = (struct lanc_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < LANC_IDX_MAX ; idx++) - { - lanc_cleanup(env, idx, 0); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < LANC_IDX_MAX; idx++) { + lanc_cleanup(env, idx, 0); + } - // free profile environment variables - env->env = NULL; - ke_free(lanc_env); + // free profile environment variables + env->env = NULL; + ke_free(lanc_env); } /** @@ -145,20 +145,17 @@ static void lanc_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void lanc_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Put LAN Client in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), LANC_IDLE); +static void lanc_create(struct prf_task_env *env, uint8_t conidx) { + /* Put LAN Client in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), LANC_IDLE); } - /// LANC Task interface required by profile manager -const struct prf_task_cbs lanc_itf = -{ - lanc_init, - lanc_destroy, - lanc_create, - lanc_cleanup, +const struct prf_task_cbs lanc_itf = { + lanc_init, + lanc_destroy, + lanc_create, + lanc_cleanup, }; /* @@ -166,520 +163,464 @@ const struct prf_task_cbs lanc_itf = **************************************************************************************** */ -const struct prf_task_cbs* lanc_prf_itf_get(void) -{ - return &lanc_itf; +const struct prf_task_cbs *lanc_prf_itf_get(void) { return &lanc_itf; } + +void lanc_enable_rsp_send(struct lanc_env_tag *lanc_env, uint8_t conidx, + uint8_t status) { + // Send to APP the details of the discovered attributes on LANS + struct lanc_enable_rsp *rsp = KE_MSG_ALLOC( + LANC_ENABLE_RSP, prf_dst_task_get(&(lanc_env->prf_env), conidx), + prf_src_task_get(&(lanc_env->prf_env), conidx), lanc_enable_rsp); + rsp->status = status; + + if (status == GAP_ERR_NO_ERROR) { + rsp->lns = lanc_env->env[conidx]->lans; + // Register LANC task in gatt for indication/notifications + prf_register_atthdl2gatt(&(lanc_env->prf_env), conidx, + &(lanc_env->env[conidx]->lans.svc)); + // Go to connected state + ke_state_set(prf_src_task_get(&(lanc_env->prf_env), conidx), LANC_IDLE); + } + + ke_msg_send(rsp); } -void lanc_enable_rsp_send(struct lanc_env_tag *lanc_env, uint8_t conidx, uint8_t status) -{ - // Send to APP the details of the discovered attributes on LANS - struct lanc_enable_rsp * rsp = KE_MSG_ALLOC( - LANC_ENABLE_RSP, - prf_dst_task_get(&(lanc_env->prf_env), conidx), - prf_src_task_get(&(lanc_env->prf_env), conidx), - lanc_enable_rsp); - rsp->status = status; +void lanc_send_no_conn_cmp_evt(uint8_t src_id, uint8_t dest_id, + uint8_t operation) { + // Send the message + struct lanc_cmp_evt *evt = + KE_MSG_ALLOC(LANC_CMP_EVT, dest_id, src_id, lanc_cmp_evt); - if (status == GAP_ERR_NO_ERROR) - { - rsp->lns = lanc_env->env[conidx]->lans; - // Register LANC task in gatt for indication/notifications - prf_register_atthdl2gatt(&(lanc_env->prf_env), conidx, &(lanc_env->env[conidx]->lans.svc)); - // Go to connected state - ke_state_set(prf_src_task_get(&(lanc_env->prf_env), conidx), LANC_IDLE); + evt->operation = operation; + evt->status = PRF_ERR_REQ_DISALLOWED; + + ke_msg_send(evt); +} + +void lanc_send_cmp_evt(struct lanc_env_tag *lanc_env, uint8_t conidx, + uint8_t operation, uint8_t status) { + // Free the stored operation if needed + if (lanc_env->env[conidx]->operation != NULL) { + ke_msg_free(ke_param2msg(lanc_env->env[conidx]->operation)); + lanc_env->env[conidx]->operation = NULL; + } + + // Go back to the CONNECTED state if the state is busy + if (ke_state_get(prf_src_task_get(&(lanc_env->prf_env), conidx)) == + LANC_BUSY) { + ke_state_set(prf_src_task_get(&(lanc_env->prf_env), conidx), LANC_IDLE); + } + + // Send the message + struct lanc_cmp_evt *evt = KE_MSG_ALLOC( + LANC_CMP_EVT, prf_dst_task_get(&(lanc_env->prf_env), conidx), + prf_src_task_get(&(lanc_env->prf_env), conidx), lanc_cmp_evt); + + evt->operation = operation; + evt->status = status; + + ke_msg_send(evt); +} + +uint16_t lanc_get_read_handle_req(struct lanc_env_tag *lanc_env, uint8_t conidx, + struct lanc_read_cmd *param) { + // Attribute Handle + uint16_t handle = ATT_INVALID_SEARCH_HANDLE; + + switch (param->read_code) { + // Read LN Feature + case (LANC_RD_LN_FEAT): { + handle = lanc_env->env[conidx]->lans.chars[LANP_LANS_LN_FEAT_CHAR].val_hdl; + } break; + + // Read Position Quality + case (LANC_RD_POS_Q): { + handle = lanc_env->env[conidx]->lans.chars[LANP_LANS_POS_Q_CHAR].val_hdl; + } break; + + // Read Location and Speed Characteristic Client Char. Cfg. Descriptor Value + case (LANC_RD_WR_LOC_SPEED_CL_CFG): { + handle = + lanc_env->env[conidx]->lans.descs[LANC_DESC_LOC_SPEED_CL_CFG].desc_hdl; + } break; + + // Read Unread Alert Characteristic Client Char. Cfg. Descriptor Value + case (LANC_RD_WR_LN_CTNL_PT_CFG): { + handle = + lanc_env->env[conidx]->lans.descs[LANC_DESC_LN_CTNL_PT_CL_CFG].desc_hdl; + } break; + + // Read Navigation Characteristic Server Char. Cfg. Descriptor Value + case (LANC_RD_WR_NAVIGATION_CFG): { + handle = + lanc_env->env[conidx]->lans.descs[LANC_DESC_NAVIGATION_CL_CFG].desc_hdl; + } break; + + default: { + handle = ATT_INVALID_SEARCH_HANDLE; + } break; + } + + return handle; +} + +uint8_t lanc_get_write_desc_handle_req(uint8_t conidx, + struct lanc_cfg_ntfind_cmd *param, + struct lanc_env_tag *lanc_env, + uint16_t *handle) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; + + switch (param->desc_code) { + // Write Location and speed Characteristic Client Char. Cfg. Descriptor Value + case (LANC_RD_WR_LOC_SPEED_CL_CFG): { + if (param->ntfind_cfg <= PRF_CLI_START_NTF) { + *handle = lanc_env->env[conidx] + ->lans.descs[LANC_DESC_LOC_SPEED_CL_CFG] + .desc_hdl; + + // The descriptor is mandatory + ASSERT_ERR(*handle != ATT_INVALID_SEARCH_HANDLE); + } else { + status = PRF_ERR_INVALID_PARAM; } + } break; - ke_msg_send(rsp); -} + // Write LN Control Point Characteristic Client Char. Cfg. Descriptor Value + case (LANC_RD_WR_LN_CTNL_PT_CFG): { + if ((param->ntfind_cfg == PRF_CLI_STOP_NTFIND) || + (param->ntfind_cfg == PRF_CLI_START_IND)) { + *handle = lanc_env->env[conidx] + ->lans.descs[LANC_DESC_LN_CTNL_PT_CL_CFG] + .desc_hdl; -void lanc_send_no_conn_cmp_evt(uint8_t src_id, uint8_t dest_id, uint8_t operation) -{ - // Send the message - struct lanc_cmp_evt *evt = KE_MSG_ALLOC(LANC_CMP_EVT, - dest_id, src_id, - lanc_cmp_evt); - - evt->operation = operation; - evt->status = PRF_ERR_REQ_DISALLOWED; - - ke_msg_send(evt); -} - -void lanc_send_cmp_evt(struct lanc_env_tag *lanc_env, uint8_t conidx, uint8_t operation, uint8_t status) -{ - // Free the stored operation if needed - if (lanc_env->env[conidx]->operation != NULL) - { - ke_msg_free(ke_param2msg(lanc_env->env[conidx]->operation)); - lanc_env->env[conidx]->operation = NULL; + if (*handle == ATT_INVALID_SEARCH_HANDLE) { + // The descriptor has not been found. + status = PRF_ERR_INEXISTENT_HDL; + } + } else { + status = PRF_ERR_INVALID_PARAM; } + } break; - // Go back to the CONNECTED state if the state is busy - if (ke_state_get(prf_src_task_get(&(lanc_env->prf_env), conidx)) == LANC_BUSY) - { - ke_state_set(prf_src_task_get(&(lanc_env->prf_env), conidx), LANC_IDLE); + // Write Navigation Characteristic Client Char. Cfg. Descriptor Value + case (LANC_RD_WR_NAVIGATION_CFG): { + if (param->ntfind_cfg <= PRF_CLI_START_NTF) { + *handle = lanc_env->env[conidx] + ->lans.descs[LANC_DESC_NAVIGATION_CL_CFG] + .desc_hdl; + + if (*handle == ATT_INVALID_SEARCH_HANDLE) { + // The descriptor has not been found. + status = PRF_ERR_INEXISTENT_HDL; + } + } else { + status = PRF_ERR_INVALID_PARAM; } + } break; - // Send the message - struct lanc_cmp_evt *evt = KE_MSG_ALLOC(LANC_CMP_EVT, - prf_dst_task_get(&(lanc_env->prf_env), conidx), - prf_src_task_get(&(lanc_env->prf_env), conidx), - lanc_cmp_evt); + default: { + status = PRF_ERR_INVALID_PARAM; + } break; + } - evt->operation = operation; - evt->status = status; - - ke_msg_send(evt); + return (status); } -uint16_t lanc_get_read_handle_req (struct lanc_env_tag *lanc_env, uint8_t conidx, struct lanc_read_cmd *param) -{ - // Attribute Handle - uint16_t handle = ATT_INVALID_SEARCH_HANDLE; +uint8_t lanc_unpack_loc_speed_ind(uint8_t conidx, + struct gattc_event_ind const *param, + struct lanc_env_tag *lanc_env) { + // Offset + uint8_t offset = LANP_LAN_LOC_SPEED_MIN_LEN; - switch (param->read_code) - { - // Read LN Feature - case (LANC_RD_LN_FEAT): - { - handle = lanc_env->env[conidx]->lans.chars[LANP_LANS_LN_FEAT_CHAR].val_hdl; - } break; + // LN Measurement value has been received + struct lanc_value_ind *ind = KE_MSG_ALLOC( + LANC_VALUE_IND, prf_dst_task_get(&(lanc_env->prf_env), conidx), + prf_src_task_get(&(lanc_env->prf_env), conidx), lanc_value_ind); - // Read Position Quality - case (LANC_RD_POS_Q): - { - handle = lanc_env->env[conidx]->lans.chars[LANP_LANS_POS_Q_CHAR].val_hdl; - } break; - - // Read Location and Speed Characteristic Client Char. Cfg. Descriptor Value - case (LANC_RD_WR_LOC_SPEED_CL_CFG): - { - handle = lanc_env->env[conidx]->lans.descs[LANC_DESC_LOC_SPEED_CL_CFG].desc_hdl; - } break; - - // Read Unread Alert Characteristic Client Char. Cfg. Descriptor Value - case (LANC_RD_WR_LN_CTNL_PT_CFG): - { - handle = lanc_env->env[conidx]->lans.descs[LANC_DESC_LN_CTNL_PT_CL_CFG].desc_hdl; - } break; - - // Read Navigation Characteristic Server Char. Cfg. Descriptor Value - case (LANC_RD_WR_NAVIGATION_CFG): - { - handle = lanc_env->env[conidx]->lans.descs[LANC_DESC_NAVIGATION_CL_CFG].desc_hdl; - } break; - - - default: - { - handle = ATT_INVALID_SEARCH_HANDLE; - } break; - } - - return handle; -} - -uint8_t lanc_get_write_desc_handle_req (uint8_t conidx, struct lanc_cfg_ntfind_cmd *param, struct lanc_env_tag *lanc_env, uint16_t *handle) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; - - switch(param->desc_code) - { - // Write Location and speed Characteristic Client Char. Cfg. Descriptor Value - case (LANC_RD_WR_LOC_SPEED_CL_CFG): - { - if (param->ntfind_cfg <= PRF_CLI_START_NTF) - { - *handle = lanc_env->env[conidx]->lans.descs[LANC_DESC_LOC_SPEED_CL_CFG].desc_hdl; - - // The descriptor is mandatory - ASSERT_ERR(*handle != ATT_INVALID_SEARCH_HANDLE); - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } break; - - // Write LN Control Point Characteristic Client Char. Cfg. Descriptor Value - case (LANC_RD_WR_LN_CTNL_PT_CFG): - { - if ((param->ntfind_cfg == PRF_CLI_STOP_NTFIND) || - (param->ntfind_cfg == PRF_CLI_START_IND)) - { - *handle = lanc_env->env[conidx]->lans.descs[LANC_DESC_LN_CTNL_PT_CL_CFG].desc_hdl; - - if (*handle == ATT_INVALID_SEARCH_HANDLE) - { - // The descriptor has not been found. - status = PRF_ERR_INEXISTENT_HDL; - } - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } break; - - // Write Navigation Characteristic Client Char. Cfg. Descriptor Value - case (LANC_RD_WR_NAVIGATION_CFG): - { - if (param->ntfind_cfg <= PRF_CLI_START_NTF) - { - *handle = lanc_env->env[conidx]->lans.descs[LANC_DESC_NAVIGATION_CL_CFG].desc_hdl; - - if (*handle == ATT_INVALID_SEARCH_HANDLE) - { - // The descriptor has not been found. - status = PRF_ERR_INEXISTENT_HDL; - } - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } - break; - - default: - { - status = PRF_ERR_INVALID_PARAM; - } break; - } - - return (status); -} - -uint8_t lanc_unpack_loc_speed_ind (uint8_t conidx, struct gattc_event_ind const *param, struct lanc_env_tag *lanc_env) -{ - // Offset - uint8_t offset = LANP_LAN_LOC_SPEED_MIN_LEN; - - // LN Measurement value has been received - struct lanc_value_ind *ind = KE_MSG_ALLOC(LANC_VALUE_IND, - prf_dst_task_get(&(lanc_env->prf_env), conidx), - prf_src_task_get(&(lanc_env->prf_env), conidx), - lanc_value_ind); - - // Attribute code - ind->att_code = LANC_NTF_LOC_SPEED; - - if ((param->length >= LANP_LAN_LOC_SPEED_MIN_LEN) && - (param->length <= LANP_LAN_LOC_SPEED_MAX_LEN)) - { - // Flags - ind->value.loc_speed.flags = co_read16p(¶m->value[0]); - - if (ind->value.loc_speed.flags & LANP_LSPEED_INST_SPEED_PRESENT) - { - //Unpack instantaneous speed - ind->value.loc_speed.inst_speed = co_read16p(¶m->value[offset]); - offset += 2; - } - - if (ind->value.loc_speed.flags & LANP_LSPEED_TOTAL_DISTANCE_PRESENT) - { - //Unpack Total distance (24 bits) - ind->value.loc_speed.total_dist = co_read24p(¶m->value[offset]); - offset += 3; - } - - if (ind->value.loc_speed.flags & LANP_LSPEED_LOCATION_PRESENT) - { - //Unpack Location - ind->value.loc_speed.latitude = co_read32p(¶m->value[offset]); - offset += 4; - ind->value.loc_speed.longitude = co_read32p(¶m->value[offset]); - offset += 4; - } - - if (ind->value.loc_speed.flags & LANP_LSPEED_ELEVATION_PRESENT) - { - // Unpack Elevation (24 bits) - ind->value.loc_speed.elevation = co_read24p(¶m->value[offset]); - offset += 3; - } - - if (ind->value.loc_speed.flags & LANP_LSPEED_HEADING_PRESENT) - { - // Unpack heading - ind->value.loc_speed.heading = co_read16p(¶m->value[offset]); - offset += 2; - } - - if (ind->value.loc_speed.flags & LANP_LSPEED_ROLLING_TIME_PRESENT) - { - // Unpack rolling time - ind->value.loc_speed.rolling_time = param->value[offset]; - offset++; - } - - if (ind->value.loc_speed.flags & LANP_LSPEED_UTC_TIME_PRESENT) - { - //Unpack UTC time - offset += prf_unpack_date_time( - (uint8_t *) &(param->value[offset]), &(ind->value.loc_speed.date_time)); - } - } - - // Send the message - ke_msg_send(ind); - - return offset; -} - -uint8_t lanc_unpack_navigation_ind (uint8_t conidx, struct gattc_event_ind const *param, struct lanc_env_tag *lanc_env) -{ - // Offset - uint8_t offset = LANP_LAN_NAVIGATION_MIN_LEN; - - // LN Measurement value has been received - struct lanc_value_ind *ind = KE_MSG_ALLOC(LANC_VALUE_IND, - prf_dst_task_get(&(lanc_env->prf_env), conidx), - prf_src_task_get(&(lanc_env->prf_env), conidx), - lanc_value_ind); - - // Attribute code - ind->att_code = LANC_NTF_NAVIGATION; - - if ((param->length >= LANP_LAN_NAVIGATION_MIN_LEN) && - (param->length <= LANP_LAN_NAVIGATION_MAX_LEN)) - { - // Flags - ind->value.navigation.flags = co_read16p(¶m->value[0]); - // Bearing - ind->value.navigation.bearing = co_read16p(¶m->value[2]); - // Heading - ind->value.navigation.heading = co_read16p(¶m->value[4]); - - if (ind->value.navigation.flags & LANP_NAVI_REMAINING_DIS_PRESENT) - { - //Unpack remaining distance (24 bits) - ind->value.navigation.remaining_distance = co_read24p(¶m->value[offset]); - offset += 3; - } - - if (ind->value.navigation.flags & LANP_NAVI_REMAINING_VER_DIS_PRESENT) - { - //Unpack remaining vertical distance (24 bits) - ind->value.navigation.remaining_ver_distance = co_read24p(¶m->value[offset]); - offset += 3; - } - - if (ind->value.navigation.flags & LANP_NAVI_ESTIMATED_TIME_OF_ARRIVAL_PRESENT) - { - //Unpack time - offset += prf_unpack_date_time( - (uint8_t *) &(param->value[offset]), &(ind->value.navigation.estimated_arrival_time)); - } - } - - // Send the message - ke_msg_send(ind); - - return offset; -} - - -uint8_t lanc_unpack_pos_q_ind (struct gattc_read_ind const *param, struct lanc_value_ind *ind) -{ - /*---------------------------------------------------- - * Unpack Position Quality --------------------------- - *----------------------------------------------------*/ - // Offset - uint8_t offset = LANP_LAN_POSQ_MIN_LEN; + // Attribute code + ind->att_code = LANC_NTF_LOC_SPEED; + if ((param->length >= LANP_LAN_LOC_SPEED_MIN_LEN) && + (param->length <= LANP_LAN_LOC_SPEED_MAX_LEN)) { // Flags - ind->value.pos_q.flags = co_read16p(¶m->value[0]); + ind->value.loc_speed.flags = co_read16p(¶m->value[0]); - if (ind->value.pos_q.flags & LANP_POSQ_NUMBER_OF_BEACONS_IN_SOLUTION_PRESENT) - { - //Unpack beacons in solution - ind->value.pos_q.n_beacons_solution = param->value[offset]; - offset++; + if (ind->value.loc_speed.flags & LANP_LSPEED_INST_SPEED_PRESENT) { + // Unpack instantaneous speed + ind->value.loc_speed.inst_speed = co_read16p(¶m->value[offset]); + offset += 2; } - if (ind->value.pos_q.flags & LANP_POSQ_NUMBER_OF_BEACONS_IN_VIEW_PRESENT) - { - //Unpack beacons in view - ind->value.pos_q.n_beacons_view = param->value[offset]; - offset++; + if (ind->value.loc_speed.flags & LANP_LSPEED_TOTAL_DISTANCE_PRESENT) { + // Unpack Total distance (24 bits) + ind->value.loc_speed.total_dist = co_read24p(¶m->value[offset]); + offset += 3; } - if (ind->value.pos_q.flags & LANP_POSQ_TIME_TO_FIRST_FIX_PRESENT) - { - //Unpack time first fix - ind->value.pos_q.time_first_fix = co_read16p(¶m->value[offset]); - offset += 2; + if (ind->value.loc_speed.flags & LANP_LSPEED_LOCATION_PRESENT) { + // Unpack Location + ind->value.loc_speed.latitude = co_read32p(¶m->value[offset]); + offset += 4; + ind->value.loc_speed.longitude = co_read32p(¶m->value[offset]); + offset += 4; } - if (ind->value.pos_q.flags & LANP_POSQ_EHPE_PRESENT) - { - //Unpack ehpe - ind->value.pos_q.ehpe = co_read32p(¶m->value[offset]); - offset += 4; + if (ind->value.loc_speed.flags & LANP_LSPEED_ELEVATION_PRESENT) { + // Unpack Elevation (24 bits) + ind->value.loc_speed.elevation = co_read24p(¶m->value[offset]); + offset += 3; } - if (ind->value.pos_q.flags & LANP_POSQ_EVPE_PRESENT) - { - //Unpack evpe - ind->value.pos_q.evpe = co_read32p(¶m->value[offset]); - offset += 4; + if (ind->value.loc_speed.flags & LANP_LSPEED_HEADING_PRESENT) { + // Unpack heading + ind->value.loc_speed.heading = co_read16p(¶m->value[offset]); + offset += 2; } - if (ind->value.pos_q.flags & LANP_POSQ_HDOP_PRESENT) - { - //Unpack hdop - ind->value.pos_q.hdop = param->value[offset]; - offset++; + if (ind->value.loc_speed.flags & LANP_LSPEED_ROLLING_TIME_PRESENT) { + // Unpack rolling time + ind->value.loc_speed.rolling_time = param->value[offset]; + offset++; } - if (ind->value.pos_q.flags & LANP_POSQ_VDOP_PRESENT) - { - //Unpack vdop - ind->value.pos_q.vdop = param->value[offset]; - offset++; + if (ind->value.loc_speed.flags & LANP_LSPEED_UTC_TIME_PRESENT) { + // Unpack UTC time + offset += prf_unpack_date_time((uint8_t *)&(param->value[offset]), + &(ind->value.loc_speed.date_time)); } + } - return offset; + // Send the message + ke_msg_send(ind); + + return offset; } -uint8_t lanc_pack_ln_ctnl_pt_req (struct lanc_ln_ctnl_pt_cfg_req *param, uint8_t *req, uint8_t *status) -{ - // Request Length - uint8_t req_len = LANP_LAN_LN_CNTL_PT_REQ_MIN_LEN; +uint8_t lanc_unpack_navigation_ind(uint8_t conidx, + struct gattc_event_ind const *param, + struct lanc_env_tag *lanc_env) { + // Offset + uint8_t offset = LANP_LAN_NAVIGATION_MIN_LEN; - // Set the operation code - req[0] = param->ln_ctnl_pt.op_code; + // LN Measurement value has been received + struct lanc_value_ind *ind = KE_MSG_ALLOC( + LANC_VALUE_IND, prf_dst_task_get(&(lanc_env->prf_env), conidx), + prf_src_task_get(&(lanc_env->prf_env), conidx), lanc_value_ind); - // Fulfill the message according to the operation code - switch (param->ln_ctnl_pt.op_code) - { - case (LANP_LN_CTNL_PT_SET_CUMUL_VALUE): - { - // Set the cumulative value (24 bits) - co_write24p(&req[req_len], param->ln_ctnl_pt.value.cumul_val); - // Update length - req_len += 3; - } break; + // Attribute code + ind->att_code = LANC_NTF_NAVIGATION; - case (LANP_LN_CTNL_PT_MASK_LSPEED_CHAR_CT): - { - // Set mask content - co_write16p(&req[req_len], param->ln_ctnl_pt.value.mask_content); - // Update length - req_len += 2; - } break; + if ((param->length >= LANP_LAN_NAVIGATION_MIN_LEN) && + (param->length <= LANP_LAN_NAVIGATION_MAX_LEN)) { + // Flags + ind->value.navigation.flags = co_read16p(¶m->value[0]); + // Bearing + ind->value.navigation.bearing = co_read16p(¶m->value[2]); + // Heading + ind->value.navigation.heading = co_read16p(¶m->value[4]); - case (LANP_LN_CTNL_PT_NAVIGATION_CONTROL): - { - // Set control value - req[req_len] = param->ln_ctnl_pt.value.control_value; - // Update length - req_len++; - } break; - - case (LANP_LN_CTNL_PT_REQ_NAME_OF_ROUTE): - case (LANP_LN_CTNL_PT_SELECT_ROUTE): - { - // Set route number - co_write16p(&req[req_len], param->ln_ctnl_pt.value.route_number); - // Update length - req_len += 2; - } break; - - case (LANP_LN_CTNL_PT_SET_FIX_RATE): - { - // Set the fix rate - req[req_len] = param->ln_ctnl_pt.value.fix_rate; - // Update length - req_len++; - } break; - - case (LANP_LN_CTNL_PT_SET_ELEVATION): - { - // Set elevation (24 bits) - co_write24p(&req[req_len], param->ln_ctnl_pt.value.elevation); - // Update length - req_len += 3; - } break; - - case (LANP_LN_CTNL_PT_REQ_NUMBER_OF_ROUTES): - { - // Nothing more to do - } break; - - default: - { - *status = PRF_ERR_INVALID_PARAM; - } break; + if (ind->value.navigation.flags & LANP_NAVI_REMAINING_DIS_PRESENT) { + // Unpack remaining distance (24 bits) + ind->value.navigation.remaining_distance = + co_read24p(¶m->value[offset]); + offset += 3; } - return req_len; + if (ind->value.navigation.flags & LANP_NAVI_REMAINING_VER_DIS_PRESENT) { + // Unpack remaining vertical distance (24 bits) + ind->value.navigation.remaining_ver_distance = + co_read24p(¶m->value[offset]); + offset += 3; + } + + if (ind->value.navigation.flags & + LANP_NAVI_ESTIMATED_TIME_OF_ARRIVAL_PRESENT) { + // Unpack time + offset += + prf_unpack_date_time((uint8_t *)&(param->value[offset]), + &(ind->value.navigation.estimated_arrival_time)); + } + } + + // Send the message + ke_msg_send(ind); + + return offset; } -uint8_t lanc_unpack_ln_ctln_pt_ind (struct gattc_event_ind const *param, ke_task_id_t src, ke_task_id_t dest) -{ - // Offset - uint8_t offset = LANP_LAN_LN_CNTL_PT_RSP_MIN_LEN; +uint8_t lanc_unpack_pos_q_ind(struct gattc_read_ind const *param, + struct lanc_value_ind *ind) { + /*---------------------------------------------------- + * Unpack Position Quality --------------------------- + *----------------------------------------------------*/ + // Offset + uint8_t offset = LANP_LAN_POSQ_MIN_LEN; - // Control Point value has been received - struct lanc_ln_ctnl_pt_rsp *ind = KE_MSG_ALLOC_DYN(LANC_LN_CTNL_PT_RSP, - dest, - src, - lanc_ln_ctnl_pt_rsp, - param->length); - // Requested operation code - ind->rsp.req_op_code = param->value[1]; - // Response value - ind->rsp.resp_value = param->value[2]; + // Flags + ind->value.pos_q.flags = co_read16p(¶m->value[0]); + if (ind->value.pos_q.flags & + LANP_POSQ_NUMBER_OF_BEACONS_IN_SOLUTION_PRESENT) { + // Unpack beacons in solution + ind->value.pos_q.n_beacons_solution = param->value[offset]; + offset++; + } - if ((ind->rsp.resp_value == LANP_LN_CTNL_PT_RESP_SUCCESS) && (param->length >= 3)) - { - switch (ind->rsp.req_op_code) - { - case (LANP_LN_CTNL_PT_REQ_NUMBER_OF_ROUTES): - { - ind->rsp.value.number_of_routes = co_read16p(¶m->value[offset]); - offset += 2; + if (ind->value.pos_q.flags & LANP_POSQ_NUMBER_OF_BEACONS_IN_VIEW_PRESENT) { + // Unpack beacons in view + ind->value.pos_q.n_beacons_view = param->value[offset]; + offset++; + } - } break; + if (ind->value.pos_q.flags & LANP_POSQ_TIME_TO_FIRST_FIX_PRESENT) { + // Unpack time first fix + ind->value.pos_q.time_first_fix = co_read16p(¶m->value[offset]); + offset += 2; + } - case (LANP_LN_CTNL_PT_REQ_NAME_OF_ROUTE): - { - // Get the length of the route - ind->rsp.value.route.length = (param->length - 3); - for (int i = 0; irsp.value.route.length; i++) - { - ind->rsp.value.route.name[i] = param->value[i + 3]; - offset++; - } - } break; + if (ind->value.pos_q.flags & LANP_POSQ_EHPE_PRESENT) { + // Unpack ehpe + ind->value.pos_q.ehpe = co_read32p(¶m->value[offset]); + offset += 4; + } - case (LANP_LN_CTNL_PT_SET_CUMUL_VALUE): - case (LANP_LN_CTNL_PT_MASK_LSPEED_CHAR_CT): - case (LANP_LN_CTNL_PT_NAVIGATION_CONTROL): - case (LANP_LN_CTNL_PT_SELECT_ROUTE): - case (LANP_LN_CTNL_PT_SET_FIX_RATE): - case (LANP_LN_CTNL_PT_SET_ELEVATION): - { - // No parameters - } break; + if (ind->value.pos_q.flags & LANP_POSQ_EVPE_PRESENT) { + // Unpack evpe + ind->value.pos_q.evpe = co_read32p(¶m->value[offset]); + offset += 4; + } - default: - { + if (ind->value.pos_q.flags & LANP_POSQ_HDOP_PRESENT) { + // Unpack hdop + ind->value.pos_q.hdop = param->value[offset]; + offset++; + } - } break; - } + if (ind->value.pos_q.flags & LANP_POSQ_VDOP_PRESENT) { + // Unpack vdop + ind->value.pos_q.vdop = param->value[offset]; + offset++; + } + + return offset; +} + +uint8_t lanc_pack_ln_ctnl_pt_req(struct lanc_ln_ctnl_pt_cfg_req *param, + uint8_t *req, uint8_t *status) { + // Request Length + uint8_t req_len = LANP_LAN_LN_CNTL_PT_REQ_MIN_LEN; + + // Set the operation code + req[0] = param->ln_ctnl_pt.op_code; + + // Fulfill the message according to the operation code + switch (param->ln_ctnl_pt.op_code) { + case (LANP_LN_CTNL_PT_SET_CUMUL_VALUE): { + // Set the cumulative value (24 bits) + co_write24p(&req[req_len], param->ln_ctnl_pt.value.cumul_val); + // Update length + req_len += 3; + } break; + + case (LANP_LN_CTNL_PT_MASK_LSPEED_CHAR_CT): { + // Set mask content + co_write16p(&req[req_len], param->ln_ctnl_pt.value.mask_content); + // Update length + req_len += 2; + } break; + + case (LANP_LN_CTNL_PT_NAVIGATION_CONTROL): { + // Set control value + req[req_len] = param->ln_ctnl_pt.value.control_value; + // Update length + req_len++; + } break; + + case (LANP_LN_CTNL_PT_REQ_NAME_OF_ROUTE): + case (LANP_LN_CTNL_PT_SELECT_ROUTE): { + // Set route number + co_write16p(&req[req_len], param->ln_ctnl_pt.value.route_number); + // Update length + req_len += 2; + } break; + + case (LANP_LN_CTNL_PT_SET_FIX_RATE): { + // Set the fix rate + req[req_len] = param->ln_ctnl_pt.value.fix_rate; + // Update length + req_len++; + } break; + + case (LANP_LN_CTNL_PT_SET_ELEVATION): { + // Set elevation (24 bits) + co_write24p(&req[req_len], param->ln_ctnl_pt.value.elevation); + // Update length + req_len += 3; + } break; + + case (LANP_LN_CTNL_PT_REQ_NUMBER_OF_ROUTES): { + // Nothing more to do + } break; + + default: { + *status = PRF_ERR_INVALID_PARAM; + } break; + } + + return req_len; +} + +uint8_t lanc_unpack_ln_ctln_pt_ind(struct gattc_event_ind const *param, + ke_task_id_t src, ke_task_id_t dest) { + // Offset + uint8_t offset = LANP_LAN_LN_CNTL_PT_RSP_MIN_LEN; + + // Control Point value has been received + struct lanc_ln_ctnl_pt_rsp *ind = KE_MSG_ALLOC_DYN( + LANC_LN_CTNL_PT_RSP, dest, src, lanc_ln_ctnl_pt_rsp, param->length); + // Requested operation code + ind->rsp.req_op_code = param->value[1]; + // Response value + ind->rsp.resp_value = param->value[2]; + + if ((ind->rsp.resp_value == LANP_LN_CTNL_PT_RESP_SUCCESS) && + (param->length >= 3)) { + switch (ind->rsp.req_op_code) { + case (LANP_LN_CTNL_PT_REQ_NUMBER_OF_ROUTES): { + ind->rsp.value.number_of_routes = co_read16p(¶m->value[offset]); + offset += 2; + + } break; + + case (LANP_LN_CTNL_PT_REQ_NAME_OF_ROUTE): { + // Get the length of the route + ind->rsp.value.route.length = (param->length - 3); + for (int i = 0; i < ind->rsp.value.route.length; i++) { + ind->rsp.value.route.name[i] = param->value[i + 3]; + offset++; + } + } break; + + case (LANP_LN_CTNL_PT_SET_CUMUL_VALUE): + case (LANP_LN_CTNL_PT_MASK_LSPEED_CHAR_CT): + case (LANP_LN_CTNL_PT_NAVIGATION_CONTROL): + case (LANP_LN_CTNL_PT_SELECT_ROUTE): + case (LANP_LN_CTNL_PT_SET_FIX_RATE): + case (LANP_LN_CTNL_PT_SET_ELEVATION): { + // No parameters + } break; + + default: { + + } break; } + } - // Send the message - ke_msg_send(ind); + // Send the message + ke_msg_send(ind); - return offset; + return offset; } #endif //(BLE_LN_COLLECTOR) diff --git a/services/ble_profiles/lan/lanc/src/lanc_task.c b/services/ble_profiles/lan/lanc/src/lanc_task.c index 9888515..78fe463 100644 --- a/services/ble_profiles/lan/lanc/src/lanc_task.c +++ b/services/ble_profiles/lan/lanc/src/lanc_task.c @@ -15,63 +15,55 @@ #if (BLE_LN_COLLECTOR) #include "lan_common.h" -#include "gap.h" #include "attm.h" -#include "lanc_task.h" -#include "lanc.h" +#include "gap.h" #include "gattc_task.h" #include "ke_timer.h" +#include "lanc.h" +#include "lanc_task.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * STRUCTURES **************************************************************************************** */ -/// State machine used to retrieve Location and Navigation service characteristics information -const struct prf_char_def lanc_lns_char[LANP_LANS_CHAR_MAX] = -{ +/// State machine used to retrieve Location and Navigation service +/// characteristics information +const struct prf_char_def lanc_lns_char[LANP_LANS_CHAR_MAX] = { /// LN Feature - [LANP_LANS_LN_FEAT_CHAR] = {ATT_CHAR_LN_FEAT, - ATT_MANDATORY, - ATT_CHAR_PROP_RD}, + [LANP_LANS_LN_FEAT_CHAR] = {ATT_CHAR_LN_FEAT, ATT_MANDATORY, + ATT_CHAR_PROP_RD}, /// LN Measurement - [LANP_LANS_LOC_SPEED_CHAR] = {ATT_CHAR_LOC_SPEED, - ATT_MANDATORY, - ATT_CHAR_PROP_NTF}, + [LANP_LANS_LOC_SPEED_CHAR] = {ATT_CHAR_LOC_SPEED, ATT_MANDATORY, + ATT_CHAR_PROP_NTF}, /// Position Quality - [LANP_LANS_POS_Q_CHAR] = {ATT_CHAR_POS_QUALITY, - ATT_OPTIONAL, - ATT_CHAR_PROP_RD}, + [LANP_LANS_POS_Q_CHAR] = {ATT_CHAR_POS_QUALITY, ATT_OPTIONAL, + ATT_CHAR_PROP_RD}, /// SC Control Point - [LANP_LANS_LN_CTNL_PT_CHAR] = {ATT_CHAR_LN_CNTL_PT, - ATT_OPTIONAL, - ATT_CHAR_PROP_WR | ATT_CHAR_PROP_IND}, + [LANP_LANS_LN_CTNL_PT_CHAR] = {ATT_CHAR_LN_CNTL_PT, ATT_OPTIONAL, + ATT_CHAR_PROP_WR | ATT_CHAR_PROP_IND}, /// Navigation - [LANP_LANS_NAVIG_CHAR] = {ATT_CHAR_NAVIGATION, - ATT_OPTIONAL, - ATT_CHAR_PROP_NTF}, + [LANP_LANS_NAVIG_CHAR] = {ATT_CHAR_NAVIGATION, ATT_OPTIONAL, + ATT_CHAR_PROP_NTF}, }; -/// State machine used to retrieve Location and Navigation service characteristic descriptor information -const struct prf_char_desc_def lanc_lns_char_desc[LANC_DESC_MAX] = -{ +/// State machine used to retrieve Location and Navigation service +/// characteristic descriptor information +const struct prf_char_desc_def lanc_lns_char_desc[LANC_DESC_MAX] = { /// Location and Speed Char. - Client Characteristic Configuration - [LANC_DESC_LOC_SPEED_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, - ATT_MANDATORY, - LANP_LANS_LOC_SPEED_CHAR}, + [LANC_DESC_LOC_SPEED_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, + LANP_LANS_LOC_SPEED_CHAR}, /// Control Point Char. - Client Characteristic Configuration - [LANC_DESC_LN_CTNL_PT_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, - ATT_OPTIONAL, - LANP_LANS_LN_CTNL_PT_CHAR}, + [LANC_DESC_LN_CTNL_PT_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_OPTIONAL, + LANP_LANS_LN_CTNL_PT_CHAR}, /// Navigation Char. - Client Characteristic Configuration - [LANC_DESC_NAVIGATION_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, - ATT_OPTIONAL, - LANP_LANS_NAVIG_CHAR}, + [LANC_DESC_NAVIGATION_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_OPTIONAL, + LANP_LANS_NAVIG_CHAR}, }; /* @@ -91,36 +83,35 @@ const struct prf_char_desc_def lanc_lns_char_desc[LANC_DESC_MAX] = **************************************************************************************** */ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, - struct gattc_sdp_svc_ind const *ind, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_sdp_svc_ind const *ind, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == LANC_DISCOVERING) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == LANC_DISCOVERING) { + uint8_t conidx = KE_IDX_GET(dest_id); - struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); + struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); - ASSERT_INFO(lanc_env != NULL, dest_id, src_id); - ASSERT_INFO(lanc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(lanc_env != NULL, dest_id, src_id); + ASSERT_INFO(lanc_env->env[conidx] != NULL, dest_id, src_id); - if(lanc_env->env[conidx]->nb_svc == 0) - { - // Retrieve CPS characteristics and descriptors - prf_extract_svc_info(ind, LANP_LANS_CHAR_MAX, &lanc_lns_char[0], &lanc_env->env[conidx]->lans.chars[0], - LANC_DESC_MAX, &lanc_lns_char_desc[0], &lanc_env->env[conidx]->lans.descs[0]); + if (lanc_env->env[conidx]->nb_svc == 0) { + // Retrieve CPS characteristics and descriptors + prf_extract_svc_info(ind, LANP_LANS_CHAR_MAX, &lanc_lns_char[0], + &lanc_env->env[conidx]->lans.chars[0], LANC_DESC_MAX, + &lanc_lns_char_desc[0], + &lanc_env->env[conidx]->lans.descs[0]); - //Even if we get multiple responses we only store 1 range - lanc_env->env[conidx]->lans.svc.shdl = ind->start_hdl; - lanc_env->env[conidx]->lans.svc.ehdl = ind->end_hdl; - } - - lanc_env->env[conidx]->nb_svc++; + // Even if we get multiple responses we only store 1 range + lanc_env->env[conidx]->lans.svc.shdl = ind->start_hdl; + lanc_env->env[conidx]->lans.svc.ehdl = ind->end_hdl; } - return (KE_MSG_CONSUMED); + lanc_env->env[conidx]->nb_svc++; + } + + return (KE_MSG_CONSUMED); } /** @@ -134,57 +125,53 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int lanc_enable_req_handler(ke_msg_id_t const msgid, - struct lanc_enable_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + struct lanc_enable_req *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); - // Location and Navigation Profile Collector Role Task Environment - struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); + uint8_t state = ke_state_get(dest_id); + // Location and Navigation Profile Collector Role Task Environment + struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); - ASSERT_INFO(lanc_env != NULL, dest_id, src_id); - if((state == LANC_IDLE) && (lanc_env->env[conidx] == NULL)) - { - // allocate environment variable for task instance - lanc_env->env[conidx] = (struct lanc_cnx_env*) ke_malloc(sizeof(struct lanc_cnx_env),KE_MEM_ATT_DB); - memset(lanc_env->env[conidx], 0, sizeof(struct lanc_cnx_env)); + ASSERT_INFO(lanc_env != NULL, dest_id, src_id); + if ((state == LANC_IDLE) && (lanc_env->env[conidx] == NULL)) { + // allocate environment variable for task instance + lanc_env->env[conidx] = (struct lanc_cnx_env *)ke_malloc( + sizeof(struct lanc_cnx_env), KE_MEM_ATT_DB); + memset(lanc_env->env[conidx], 0, sizeof(struct lanc_cnx_env)); - //Config connection, start discovering - if(param->con_type == PRF_CON_DISCOVERY) - { - //start discovering CPS on peer - prf_disc_svc_send(&(lanc_env->prf_env), conidx, ATT_SVC_LOCATION_AND_NAVIGATION); + // Config connection, start discovering + if (param->con_type == PRF_CON_DISCOVERY) { + // start discovering CPS on peer + prf_disc_svc_send(&(lanc_env->prf_env), conidx, + ATT_SVC_LOCATION_AND_NAVIGATION); - // Go to DISCOVERING state - ke_state_set(dest_id, LANC_DISCOVERING); - } - //normal connection, get saved att details - else - { - lanc_env->env[conidx]->lans = param->lans; - - //send APP confirmation that can start normal connection to TH - lanc_enable_rsp_send(lanc_env, conidx, GAP_ERR_NO_ERROR); - } + // Go to DISCOVERING state + ke_state_set(dest_id, LANC_DISCOVERING); } + // normal connection, get saved att details + else { + lanc_env->env[conidx]->lans = param->lans; - else if(state != LANC_FREE) - { - status = PRF_ERR_REQ_DISALLOWED; + // send APP confirmation that can start normal connection to TH + lanc_enable_rsp_send(lanc_env, conidx, GAP_ERR_NO_ERROR); } + } - // send an error if request fails - if(status != GAP_ERR_NO_ERROR) - { - lanc_enable_rsp_send(lanc_env, conidx, status); - } + else if (state != LANC_FREE) { + status = PRF_ERR_REQ_DISALLOWED; + } - return (KE_MSG_CONSUMED); + // send an error if request fails + if (status != GAP_ERR_NO_ERROR) { + lanc_enable_rsp_send(lanc_env, conidx, status); + } + + return (KE_MSG_CONSUMED); } /** @@ -198,77 +185,63 @@ __STATIC int lanc_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int lanc_read_cmd_handler(ke_msg_id_t const msgid, - struct lanc_read_cmd *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - uint8_t status = PRF_ERR_REQ_DISALLOWED; - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; - // Get the address of the environment - struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + struct lanc_read_cmd *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + uint8_t status = PRF_ERR_REQ_DISALLOWED; + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; + // Get the address of the environment + struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - if (state == LANC_IDLE) - { - ASSERT_INFO(lanc_env != NULL, dest_id, src_id); - // environment variable not ready - if(lanc_env->env[conidx] == NULL) - { - status = PRF_APP_ERROR; - } - else - { - // Get the handler - uint16_t hdl = lanc_get_read_handle_req (lanc_env, conidx, param); + if (state == LANC_IDLE) { + ASSERT_INFO(lanc_env != NULL, dest_id, src_id); + // environment variable not ready + if (lanc_env->env[conidx] == NULL) { + status = PRF_APP_ERROR; + } else { + // Get the handler + uint16_t hdl = lanc_get_read_handle_req(lanc_env, conidx, param); - // Check if handle is viable - if (hdl != ATT_INVALID_SEARCH_HANDLE) - { - // Force the operation value - param->operation = LANC_READ_OP_CODE; + // Check if handle is viable + if (hdl != ATT_INVALID_SEARCH_HANDLE) { + // Force the operation value + param->operation = LANC_READ_OP_CODE; - // Store the command structure - lanc_env->env[conidx]->operation = param; - msg_status = KE_MSG_NO_FREE; + // Store the command structure + lanc_env->env[conidx]->operation = param; + msg_status = KE_MSG_NO_FREE; - // Send the read request - prf_read_char_send(&(lanc_env->prf_env), conidx, - lanc_env->env[conidx]->lans.svc.shdl, - lanc_env->env[conidx]->lans.svc.ehdl, - hdl); + // Send the read request + prf_read_char_send(&(lanc_env->prf_env), conidx, + lanc_env->env[conidx]->lans.svc.shdl, + lanc_env->env[conidx]->lans.svc.ehdl, hdl); - // Go to the Busy state - ke_state_set(dest_id, LANC_BUSY); + // Go to the Busy state + ke_state_set(dest_id, LANC_BUSY); - status = ATT_ERR_NO_ERROR; - } - else - { - status = PRF_ERR_INEXISTENT_HDL; - } - } - } - else if(state == LANC_FREE) - { - status = GAP_ERR_DISCONNECTED; - } - else - { - // Another procedure is pending, keep the command for later - msg_status = KE_MSG_SAVED; - status = GAP_ERR_NO_ERROR; + status = ATT_ERR_NO_ERROR; + } else { + status = PRF_ERR_INEXISTENT_HDL; + } } + } else if (state == LANC_FREE) { + status = GAP_ERR_DISCONNECTED; + } else { + // Another procedure is pending, keep the command for later + msg_status = KE_MSG_SAVED; + status = GAP_ERR_NO_ERROR; + } - if (status != GAP_ERR_NO_ERROR) - { - // Send the complete event message to the task id stored in the environment - lanc_send_cmp_evt(lanc_env, conidx, LANC_READ_OP_CODE, status); - } + if (status != GAP_ERR_NO_ERROR) { + // Send the complete event message to the task id stored in the environment + lanc_send_cmp_evt(lanc_env, conidx, LANC_READ_OP_CODE, status); + } - return (int)msg_status; + return (int)msg_status; } /** @@ -282,67 +255,59 @@ __STATIC int lanc_read_cmd_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int lanc_cfg_ntfind_cmd_handler(ke_msg_id_t const msgid, - struct lanc_cfg_ntfind_cmd *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); + struct lanc_cfg_ntfind_cmd *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); - uint8_t state = ke_state_get(dest_id); - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; + uint8_t state = ke_state_get(dest_id); + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; - if (lanc_env != NULL) - { - // Status - uint8_t status = PRF_ERR_REQ_DISALLOWED; - // Handle - uint16_t handle = ATT_INVALID_SEARCH_HANDLE; - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + if (lanc_env != NULL) { + // Status + uint8_t status = PRF_ERR_REQ_DISALLOWED; + // Handle + uint16_t handle = ATT_INVALID_SEARCH_HANDLE; + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - do - { - if (state != LANC_IDLE) - { - // Another procedure is pending, keep the command for later - msg_status = KE_MSG_SAVED; - break; - } + do { + if (state != LANC_IDLE) { + // Another procedure is pending, keep the command for later + msg_status = KE_MSG_SAVED; + break; + } - ASSERT_ERR(lanc_env->env[conidx] != NULL); + ASSERT_ERR(lanc_env->env[conidx] != NULL); - // Get handle - status = lanc_get_write_desc_handle_req (conidx, param, lanc_env, &handle); - } while (0); + // Get handle + status = lanc_get_write_desc_handle_req(conidx, param, lanc_env, &handle); + } while (0); - if ((status == GAP_ERR_NO_ERROR) && (handle != ATT_INVALID_SEARCH_HANDLE)) - { - // Set the operation code - param->operation = LANC_CFG_NTF_IND_OP_CODE; + if ((status == GAP_ERR_NO_ERROR) && (handle != ATT_INVALID_SEARCH_HANDLE)) { + // Set the operation code + param->operation = LANC_CFG_NTF_IND_OP_CODE; - // Store the command structure - lanc_env->env[conidx]->operation = param; - msg_status = KE_MSG_NO_FREE; + // Store the command structure + lanc_env->env[conidx]->operation = param; + msg_status = KE_MSG_NO_FREE; - // Go to the Busy state - ke_state_set(dest_id, LANC_BUSY); + // Go to the Busy state + ke_state_set(dest_id, LANC_BUSY); - // Send GATT Write Request - prf_gatt_write_ntf_ind(&lanc_env->prf_env, conidx, handle, param->ntfind_cfg); - } - } - else - { - lanc_send_no_conn_cmp_evt(dest_id, src_id, LANC_CFG_NTF_IND_OP_CODE); + // Send GATT Write Request + prf_gatt_write_ntf_ind(&lanc_env->prf_env, conidx, handle, + param->ntfind_cfg); } + } else { + lanc_send_no_conn_cmp_evt(dest_id, src_id, LANC_CFG_NTF_IND_OP_CODE); + } - return (int)msg_status; + return (int)msg_status; } - - /** **************************************************************************************** * @brief Handles reception of the @ref LANC_LN_CTNL_PT_CFG_REQ message. @@ -353,95 +318,88 @@ __STATIC int lanc_cfg_ntfind_cmd_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int lanc_ln_ctnl_pt_cfg_req_handler(ke_msg_id_t const msgid, - struct lanc_ln_ctnl_pt_cfg_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; - // Get the address of the environment - struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); +__STATIC int lanc_ln_ctnl_pt_cfg_req_handler( + ke_msg_id_t const msgid, struct lanc_ln_ctnl_pt_cfg_req *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; + // Get the address of the environment + struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - if (lanc_env != NULL) - { - // Status - uint8_t status = GAP_ERR_NO_ERROR; + if (lanc_env != NULL) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; - do - { - // State is Connected or Busy - ASSERT_ERR(ke_state_get(dest_id) > LANC_FREE); + do { + // State is Connected or Busy + ASSERT_ERR(ke_state_get(dest_id) > LANC_FREE); - // Check the provided connection handle - if (lanc_env->env[conidx] == NULL) - { - status = PRF_ERR_INVALID_PARAM; - break; - } + // Check the provided connection handle + if (lanc_env->env[conidx] == NULL) { + status = PRF_ERR_INVALID_PARAM; + break; + } - if (ke_state_get(dest_id) != LANC_IDLE) - { - // Another procedure is pending, keep the command for later - msg_status = KE_MSG_SAVED; - // Status is PRF_ERR_OK, no message will be sent to the application - break; - } + if (ke_state_get(dest_id) != LANC_IDLE) { + // Another procedure is pending, keep the command for later + msg_status = KE_MSG_SAVED; + // Status is PRF_ERR_OK, no message will be sent to the application + break; + } - // Check if the characteristic has been found - if (lanc_env->env[conidx]->lans.descs[LANC_DESC_LN_CTNL_PT_CL_CFG].desc_hdl != ATT_INVALID_SEARCH_HANDLE) - { - // Request array declaration - uint8_t req[LANP_LAN_LN_CNTL_PT_REQ_MAX_LEN]; - // Pack request - uint8_t nb = lanc_pack_ln_ctnl_pt_req (param, req, &status); + // Check if the characteristic has been found + if (lanc_env->env[conidx] + ->lans.descs[LANC_DESC_LN_CTNL_PT_CL_CFG] + .desc_hdl != ATT_INVALID_SEARCH_HANDLE) { + // Request array declaration + uint8_t req[LANP_LAN_LN_CNTL_PT_REQ_MAX_LEN]; + // Pack request + uint8_t nb = lanc_pack_ln_ctnl_pt_req(param, req, &status); - if (status == GAP_ERR_NO_ERROR) - { - // Set the operation code - param->operation = LANC_LN_CTNL_PT_CFG_WR_OP_CODE; + if (status == GAP_ERR_NO_ERROR) { + // Set the operation code + param->operation = LANC_LN_CTNL_PT_CFG_WR_OP_CODE; - // Store the command structure - lanc_env->env[conidx]->operation = param; - // Store the command information - msg_status = KE_MSG_NO_FREE; + // Store the command structure + lanc_env->env[conidx]->operation = param; + // Store the command information + msg_status = KE_MSG_NO_FREE; - // Go to the Busy state - ke_state_set(dest_id, LANC_BUSY); + // Go to the Busy state + ke_state_set(dest_id, LANC_BUSY); - // Send the write request - prf_gatt_write(&(lanc_env->prf_env), conidx, lanc_env->env[conidx]->lans.chars[LANP_LANS_LN_CTNL_PT_CHAR].val_hdl, - (uint8_t *)&req[0], nb, GATTC_WRITE); - } - } - else - { - status = PRF_ERR_INEXISTENT_HDL; - } - } while (0); - - if (status != GAP_ERR_NO_ERROR) - { - // Send a complete event status to the application - lanc_send_cmp_evt(lanc_env, conidx, LANC_LN_CTNL_PT_CFG_WR_OP_CODE, status); + // Send the write request + prf_gatt_write(&(lanc_env->prf_env), conidx, + lanc_env->env[conidx] + ->lans.chars[LANP_LANS_LN_CTNL_PT_CHAR] + .val_hdl, + (uint8_t *)&req[0], nb, GATTC_WRITE); } - } - else - { - // No connection - lanc_send_no_conn_cmp_evt(dest_id, src_id, LANC_LN_CTNL_PT_CFG_WR_OP_CODE); - } + } else { + status = PRF_ERR_INEXISTENT_HDL; + } + } while (0); - return (int)msg_status; + if (status != GAP_ERR_NO_ERROR) { + // Send a complete event status to the application + lanc_send_cmp_evt(lanc_env, conidx, LANC_LN_CTNL_PT_CFG_WR_OP_CODE, + status); + } + } else { + // No connection + lanc_send_no_conn_cmp_evt(dest_id, src_id, LANC_LN_CTNL_PT_CFG_WR_OP_CODE); + } + + return (int)msg_status; } /** **************************************************************************************** - * @brief Handles reception of the @ref LANC_TIMEOUT_TIMER_IND message. This message is - * received when the peer device doesn't send a SC Control Point indication within 30s - * after reception of the write response. + * @brief Handles reception of the @ref LANC_TIMEOUT_TIMER_IND message. This + *message is received when the peer device doesn't send a SC Control Point + *indication within 30s after reception of the write response. * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance. @@ -450,26 +408,27 @@ __STATIC int lanc_ln_ctnl_pt_cfg_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int lanc_timeout_timer_ind_handler(ke_msg_id_t const msgid, - void const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + void const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - if (lanc_env != NULL) - { - ASSERT_ERR(lanc_env->env[conidx]->operation != NULL); - ASSERT_ERR(((struct lanc_cmd *)lanc_env->env[conidx]->operation)->operation == LANC_LN_CTNL_PT_CFG_IND_OP_CODE); + if (lanc_env != NULL) { + ASSERT_ERR(lanc_env->env[conidx]->operation != NULL); + ASSERT_ERR( + ((struct lanc_cmd *)lanc_env->env[conidx]->operation)->operation == + LANC_LN_CTNL_PT_CFG_IND_OP_CODE); - // Send the complete event message - lanc_send_cmp_evt(lanc_env, conidx, LANC_LN_CTNL_PT_CFG_WR_OP_CODE, PRF_ERR_PROC_TIMEOUT); - } - // else drop the message + // Send the complete event message + lanc_send_cmp_evt(lanc_env, conidx, LANC_LN_CTNL_PT_CFG_WR_OP_CODE, + PRF_ERR_PROC_TIMEOUT); + } + // else drop the message - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -483,117 +442,98 @@ __STATIC int lanc_timeout_timer_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, - struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); - // Status - uint8_t status; + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); + // Status + uint8_t status; - if (lanc_env != NULL) - { - uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); + if (lanc_env != NULL) { + uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t state = ke_state_get(dest_id); - if (state == LANC_DISCOVERING) - { - status = param->status; + if (state == LANC_DISCOVERING) { + status = param->status; - if ((status == ATT_ERR_ATTRIBUTE_NOT_FOUND) || - (status == ATT_ERR_NO_ERROR)) - { - // Discovery - // check characteristic validity - if(lanc_env->env[conidx]->nb_svc == 1) - { - status = prf_check_svc_char_validity(LANP_LANS_CHAR_MAX, - lanc_env->env[conidx]->lans.chars, - lanc_lns_char); - } - // too much services - else if (lanc_env->env[conidx]->nb_svc > 1) - { - status = PRF_ERR_MULTIPLE_SVC; - } - // no services found - else - { - status = PRF_ERR_STOP_DISC_CHAR_MISSING; - } - - // check descriptor validity - if (status == GAP_ERR_NO_ERROR) - { - status = prf_check_svc_char_desc_validity(LANC_DESC_MAX, - lanc_env->env[conidx]->lans.descs, - lanc_lns_char_desc, - lanc_env->env[conidx]->lans.chars); - } - } - - lanc_enable_rsp_send(lanc_env, conidx, status); + if ((status == ATT_ERR_ATTRIBUTE_NOT_FOUND) || + (status == ATT_ERR_NO_ERROR)) { + // Discovery + // check characteristic validity + if (lanc_env->env[conidx]->nb_svc == 1) { + status = prf_check_svc_char_validity( + LANP_LANS_CHAR_MAX, lanc_env->env[conidx]->lans.chars, + lanc_lns_char); + } + // too much services + else if (lanc_env->env[conidx]->nb_svc > 1) { + status = PRF_ERR_MULTIPLE_SVC; + } + // no services found + else { + status = PRF_ERR_STOP_DISC_CHAR_MISSING; } - else if (state == LANC_BUSY) - { - switch (param->operation) - { - case GATTC_READ: - { - // Send the complete event status - lanc_send_cmp_evt(lanc_env, conidx, LANC_READ_OP_CODE, param->status); - } break; - - case GATTC_WRITE: - case GATTC_WRITE_NO_RESPONSE: - { - uint8_t operation = ((struct lanc_cmd *)lanc_env->env[conidx]->operation)->operation; - - if (operation == LANC_CFG_NTF_IND_OP_CODE) - { - // Send the complete event status - lanc_send_cmp_evt(lanc_env, conidx, operation, param->status); - } - - else if (operation == LANC_LN_CTNL_PT_CFG_WR_OP_CODE) - { - if (param->status == GAP_ERR_NO_ERROR) - { - // Start Timeout Procedure - ke_timer_set(LANC_TIMEOUT_TIMER_IND, dest_id, ATT_TRANS_RTX); - - // Wait for the response indication - ((struct lanc_cmd *)lanc_env->env[conidx]->operation)->operation = LANC_LN_CTNL_PT_CFG_IND_OP_CODE; - } - else - { - // Send the complete event status - lanc_send_cmp_evt(lanc_env, conidx, operation, param->status); - } - } - } break; - - case GATTC_REGISTER: - case GATTC_UNREGISTER: - { - // Do nothing - } break; - - default: - { - ASSERT_ERR(0); - } break; - } + // check descriptor validity + if (status == GAP_ERR_NO_ERROR) { + status = prf_check_svc_char_desc_validity( + LANC_DESC_MAX, lanc_env->env[conidx]->lans.descs, + lanc_lns_char_desc, lanc_env->env[conidx]->lans.chars); } + } + + lanc_enable_rsp_send(lanc_env, conidx, status); } - // else ignore the message - return (KE_MSG_CONSUMED); + else if (state == LANC_BUSY) { + switch (param->operation) { + case GATTC_READ: { + // Send the complete event status + lanc_send_cmp_evt(lanc_env, conidx, LANC_READ_OP_CODE, param->status); + } break; + + case GATTC_WRITE: + case GATTC_WRITE_NO_RESPONSE: { + uint8_t operation = + ((struct lanc_cmd *)lanc_env->env[conidx]->operation)->operation; + + if (operation == LANC_CFG_NTF_IND_OP_CODE) { + // Send the complete event status + lanc_send_cmp_evt(lanc_env, conidx, operation, param->status); + } + + else if (operation == LANC_LN_CTNL_PT_CFG_WR_OP_CODE) { + if (param->status == GAP_ERR_NO_ERROR) { + // Start Timeout Procedure + ke_timer_set(LANC_TIMEOUT_TIMER_IND, dest_id, ATT_TRANS_RTX); + + // Wait for the response indication + ((struct lanc_cmd *)lanc_env->env[conidx]->operation)->operation = + LANC_LN_CTNL_PT_CFG_IND_OP_CODE; + } else { + // Send the complete event status + lanc_send_cmp_evt(lanc_env, conidx, operation, param->status); + } + } + } break; + + case GATTC_REGISTER: + case GATTC_UNREGISTER: { + // Do nothing + } break; + + default: { + ASSERT_ERR(0); + } break; + } + } + } + // else ignore the message + + return (KE_MSG_CONSUMED); } - /** **************************************************************************************** * @brief Handles reception of the @ref GATTC_READ_IND message. @@ -608,67 +548,61 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, struct gattc_read_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - // Get the address of the environment - struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); + // Get the address of the environment + struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); - if (state == LANC_BUSY) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == LANC_BUSY) { + uint8_t conidx = KE_IDX_GET(dest_id); - ASSERT_INFO(lanc_env != NULL, dest_id, src_id); - ASSERT_INFO(lanc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(lanc_env != NULL, dest_id, src_id); + ASSERT_INFO(lanc_env->env[conidx] != NULL, dest_id, src_id); - // Send the read value to the HL - struct lanc_value_ind *ind = KE_MSG_ALLOC(LANC_VALUE_IND, - prf_dst_task_get(&(lanc_env->prf_env), conidx), - dest_id, - lanc_value_ind); + // Send the read value to the HL + struct lanc_value_ind *ind = KE_MSG_ALLOC( + LANC_VALUE_IND, prf_dst_task_get(&(lanc_env->prf_env), conidx), dest_id, + lanc_value_ind); - switch (((struct lanc_read_cmd *)lanc_env->env[conidx]->operation)->read_code) - { - // Read LN Feature Characteristic value - case (LANC_RD_LN_FEAT): - { - ind->value.LN_feat = co_read32p(¶m->value[0]); + switch ( + ((struct lanc_read_cmd *)lanc_env->env[conidx]->operation)->read_code) { + // Read LN Feature Characteristic value + case (LANC_RD_LN_FEAT): { + ind->value.LN_feat = co_read32p(¶m->value[0]); - // Mask the reserved bits -// ind->value.LN_feat &= LANP_FEAT_ALL_SUPP; - } break; + // Mask the reserved bits + // ind->value.LN_feat &= LANP_FEAT_ALL_SUPP; + } break; - // Read Position Quality - case (LANC_RD_POS_Q): - { - // Read position quality - lanc_unpack_pos_q_ind (param, ind); + // Read Position Quality + case (LANC_RD_POS_Q): { + // Read position quality + lanc_unpack_pos_q_ind(param, ind); - } break; + } break; - // Read Client Characteristic Configuration Descriptor value - case (LANC_RD_WR_LOC_SPEED_CL_CFG): - case (LANC_RD_WR_LN_CTNL_PT_CFG): - case (LANC_RD_WR_NAVIGATION_CFG): - { - ind->value.ntf_cfg = co_read16p(¶m->value[0]); - } break; + // Read Client Characteristic Configuration Descriptor value + case (LANC_RD_WR_LOC_SPEED_CL_CFG): + case (LANC_RD_WR_LN_CTNL_PT_CFG): + case (LANC_RD_WR_NAVIGATION_CFG): { + ind->value.ntf_cfg = co_read16p(¶m->value[0]); + } break; - default: - { - ASSERT_ERR(0); - } break; - } - - ind->att_code = ((struct lanc_read_cmd *)lanc_env->env[conidx]->operation)->read_code; - - // Send the message to the application - ke_msg_send(ind); + default: { + ASSERT_ERR(0); + } break; } - // else drop the message - return (KE_MSG_CONSUMED); + ind->att_code = + ((struct lanc_read_cmd *)lanc_env->env[conidx]->operation)->read_code; + + // Send the message to the application + ke_msg_send(ind); + } + // else drop the message + + return (KE_MSG_CONSUMED); } /** @@ -682,70 +616,65 @@ __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, - struct gattc_event_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); + struct gattc_event_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); - if (lanc_env != NULL) - { - switch (param->type) - { - case (GATTC_NOTIFY): - { - if (param->handle == lanc_env->env[conidx]->lans.chars[LANP_LANS_LOC_SPEED_CHAR].val_hdl) - { - //Unpack location and speed - lanc_unpack_loc_speed_ind(conidx, param, lanc_env); - } - else if (param->handle == lanc_env->env[conidx]->lans.chars[LANP_LANS_NAVIG_CHAR].val_hdl) - { - // Unpack navigation - lanc_unpack_navigation_ind(conidx, param, lanc_env); - } - else - { - ASSERT_ERR(0); - } - } break; + if (lanc_env != NULL) { + switch (param->type) { + case (GATTC_NOTIFY): { + if (param->handle == + lanc_env->env[conidx]->lans.chars[LANP_LANS_LOC_SPEED_CHAR].val_hdl) { + // Unpack location and speed + lanc_unpack_loc_speed_ind(conidx, param, lanc_env); + } else if (param->handle == lanc_env->env[conidx] + ->lans.chars[LANP_LANS_NAVIG_CHAR] + .val_hdl) { + // Unpack navigation + lanc_unpack_navigation_ind(conidx, param, lanc_env); + } else { + ASSERT_ERR(0); + } + } break; - case (GATTC_INDICATE): - { - // confirm that indication has been correctly received - struct gattc_event_cfm * cfm = KE_MSG_ALLOC(GATTC_EVENT_CFM, src_id, dest_id, gattc_event_cfm); - cfm->handle = param->handle; - ke_msg_send(cfm); + case (GATTC_INDICATE): { + // confirm that indication has been correctly received + struct gattc_event_cfm *cfm = + KE_MSG_ALLOC(GATTC_EVENT_CFM, src_id, dest_id, gattc_event_cfm); + cfm->handle = param->handle; + ke_msg_send(cfm); - // Check if we were waiting for the indication - if (lanc_env->env[conidx]->operation != NULL) - { - if (((struct lanc_cmd *)lanc_env->env[conidx]->operation)->operation == LANC_LN_CTNL_PT_CFG_IND_OP_CODE) - { - // Stop the procedure timeout timer - ke_timer_clear(LANC_TIMEOUT_TIMER_IND, dest_id); + // Check if we were waiting for the indication + if (lanc_env->env[conidx]->operation != NULL) { + if (((struct lanc_cmd *)lanc_env->env[conidx]->operation)->operation == + LANC_LN_CTNL_PT_CFG_IND_OP_CODE) { + // Stop the procedure timeout timer + ke_timer_clear(LANC_TIMEOUT_TIMER_IND, dest_id); - //Unpack control point - lanc_unpack_ln_ctln_pt_ind(param, prf_src_task_get(&(lanc_env->prf_env), conidx), prf_dst_task_get(&(lanc_env->prf_env), conidx)); + // Unpack control point + lanc_unpack_ln_ctln_pt_ind( + param, prf_src_task_get(&(lanc_env->prf_env), conidx), + prf_dst_task_get(&(lanc_env->prf_env), conidx)); - // Send the complete event message - lanc_send_cmp_evt(lanc_env, conidx, LANC_LN_CTNL_PT_CFG_WR_OP_CODE, GAP_ERR_NO_ERROR); - } - // else drop the message - } - // else drop the message - } break; - - default: - { - ASSERT_ERR(0); - } break; + // Send the complete event message + lanc_send_cmp_evt(lanc_env, conidx, LANC_LN_CTNL_PT_CFG_WR_OP_CODE, + GAP_ERR_NO_ERROR); } - } + // else drop the message + } + // else drop the message + } break; - return (KE_MSG_CONSUMED); + default: { + ASSERT_ERR(0); + } break; + } + } + + return (KE_MSG_CONSUMED); } /* @@ -754,29 +683,27 @@ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, */ /// Specifies the default message handlers -KE_MSG_HANDLER_TAB(lanc) -{ - {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, - {LANC_ENABLE_REQ, (ke_msg_func_t)lanc_enable_req_handler}, - {LANC_READ_CMD, (ke_msg_func_t)lanc_read_cmd_handler}, - {LANC_CFG_NTFIND_CMD, (ke_msg_func_t)lanc_cfg_ntfind_cmd_handler}, - {LANC_LN_CTNL_PT_CFG_REQ, (ke_msg_func_t)lanc_ln_ctnl_pt_cfg_req_handler}, - {LANC_TIMEOUT_TIMER_IND, (ke_msg_func_t)lanc_timeout_timer_ind_handler}, - {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, - {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, - {GATTC_EVENT_REQ_IND, (ke_msg_func_t)gattc_event_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, +KE_MSG_HANDLER_TAB(lanc){ + {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, + {LANC_ENABLE_REQ, (ke_msg_func_t)lanc_enable_req_handler}, + {LANC_READ_CMD, (ke_msg_func_t)lanc_read_cmd_handler}, + {LANC_CFG_NTFIND_CMD, (ke_msg_func_t)lanc_cfg_ntfind_cmd_handler}, + {LANC_LN_CTNL_PT_CFG_REQ, (ke_msg_func_t)lanc_ln_ctnl_pt_cfg_req_handler}, + {LANC_TIMEOUT_TIMER_IND, (ke_msg_func_t)lanc_timeout_timer_ind_handler}, + {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, + {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {GATTC_EVENT_REQ_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void lanc_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); +void lanc_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct lanc_env_tag *lanc_env = PRF_ENV_GET(LANC, lanc); - task_desc->msg_handler_tab = lanc_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(lanc_msg_handler_tab); - task_desc->state = lanc_env->state; - task_desc->idx_max = LANC_IDX_MAX; + task_desc->msg_handler_tab = lanc_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(lanc_msg_handler_tab); + task_desc->state = lanc_env->state; + task_desc->idx_max = LANC_IDX_MAX; } #endif //(BLE_LN_COLLECTOR) diff --git a/services/ble_profiles/lan/lans/src/lans.c b/services/ble_profiles/lan/lans/src/lans.c index 0da319c..6964cec 100644 --- a/services/ble_profiles/lan/lans/src/lans.c +++ b/services/ble_profiles/lan/lans/src/lans.c @@ -15,16 +15,16 @@ #if (BLE_LN_SENSOR) #include "lan_common.h" -#include "gap.h" -#include "gattc_task.h" -#include "gattc.h" #include "attm.h" +#include "gap.h" +#include "gattc.h" +#include "gattc_task.h" #include "lans.h" #include "lans_task.h" #include "prf_utils.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * CYCLING POWER SERVICE ATTRIBUTES @@ -32,42 +32,60 @@ */ /// Full LANS Database Description - Used to add attributes into the database -static const struct attm_desc lans_att_db[LNS_IDX_NB] = -{ +static const struct attm_desc lans_att_db[LNS_IDX_NB] = { // Location and Navigation Service Declaration - [LNS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [LNS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // LN Feature Characteristic Declaration - [LNS_IDX_LN_FEAT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [LNS_IDX_LN_FEAT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, // LN Feature Characteristic Value - [LNS_IDX_LN_FEAT_VAL] = {ATT_CHAR_LN_FEAT, PERM(RD, ENABLE), PERM(RI, ENABLE), sizeof(uint32_t)}, + [LNS_IDX_LN_FEAT_VAL] = {ATT_CHAR_LN_FEAT, PERM(RD, ENABLE), + PERM(RI, ENABLE), sizeof(uint32_t)}, // Location and Speed Characteristic Declaration - [LNS_IDX_LOC_SPEED_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [LNS_IDX_LOC_SPEED_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Location and Speed Characteristic Value - [LNS_IDX_LOC_SPEED_VAL] = {ATT_CHAR_LOC_SPEED, PERM(NTF, ENABLE), PERM(RI, ENABLE), LANP_LAN_LOC_SPEED_MAX_LEN}, - // Location and Speed Characteristic - Client Characteristic Configuration Descriptor - [LNS_IDX_LOC_SPEED_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [LNS_IDX_LOC_SPEED_VAL] = {ATT_CHAR_LOC_SPEED, PERM(NTF, ENABLE), + PERM(RI, ENABLE), LANP_LAN_LOC_SPEED_MAX_LEN}, + // Location and Speed Characteristic - Client Characteristic Configuration + // Descriptor + [LNS_IDX_LOC_SPEED_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + 0, 0}, // Position Quality Characteristic Declaration - [LNS_IDX_POS_Q_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [LNS_IDX_POS_Q_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, // Position Quality Characteristic Value - [LNS_IDX_POS_Q_VAL] = {ATT_CHAR_POS_QUALITY, PERM(RD, ENABLE), PERM(RI, ENABLE), LANP_LAN_POSQ_MAX_LEN}, + [LNS_IDX_POS_Q_VAL] = {ATT_CHAR_POS_QUALITY, PERM(RD, ENABLE), + PERM(RI, ENABLE), LANP_LAN_POSQ_MAX_LEN}, // LN Control Point Characteristic Declaration - [LNS_IDX_LN_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, - // LN Control Point Characteristic Value - The response has the maximal length - [LNS_IDX_LN_CTNL_PT_VAL] = {ATT_CHAR_LN_CNTL_PT, PERM(IND, ENABLE) | PERM(WRITE_REQ, ENABLE), - PERM(RI, ENABLE), LANP_LAN_LN_CNTL_PT_RSP_MAX_LEN}, - // LN Control Point Characteristic - Client Characteristic Configuration Descriptor - [LNS_IDX_LN_CTNL_PT_IND_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [LNS_IDX_LN_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, + // LN Control Point Characteristic Value - The response has the maximal + // length + [LNS_IDX_LN_CTNL_PT_VAL] = {ATT_CHAR_LN_CNTL_PT, + PERM(IND, ENABLE) | PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE), + LANP_LAN_LN_CNTL_PT_RSP_MAX_LEN}, + // LN Control Point Characteristic - Client Characteristic Configuration + // Descriptor + [LNS_IDX_LN_CTNL_PT_IND_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + 0, 0}, // Navigation Characteristic Declaration - [LNS_IDX_NAVIGATION_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [LNS_IDX_NAVIGATION_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Navigation Characteristic Value - [LNS_IDX_NAVIGATION_VAL] = {ATT_CHAR_NAVIGATION, PERM(NTF, ENABLE), PERM(RI, ENABLE), LANP_LAN_NAVIGATION_MAX_LEN}, - // Navigation Characteristic - Client Characteristic Configuration Descriptor - [LNS_IDX_NAVIGATION_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [LNS_IDX_NAVIGATION_VAL] = {ATT_CHAR_NAVIGATION, PERM(NTF, ENABLE), + PERM(RI, ENABLE), LANP_LAN_NAVIGATION_MAX_LEN}, + // Navigation Characteristic - Client Characteristic Configuration + // Descriptor + [LNS_IDX_NAVIGATION_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + 0, 0}, }; /* @@ -87,136 +105,159 @@ static const struct attm_desc lans_att_db[LNS_IDX_NB] = * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t lans_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, struct lans_db_cfg* params) -{ - //------------------ create the attribute database for the profile ------------------- - // Service Configuration Flag - uint16_t cfg_flag = LANS_MANDATORY_MASK; - // Database Creation Status - uint8_t status = ATT_ERR_NO_ERROR; +static uint8_t lans_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, + struct lans_db_cfg *params) { + //------------------ create the attribute database for the profile + //------------------- + // Service Configuration Flag + uint16_t cfg_flag = LANS_MANDATORY_MASK; + // Database Creation Status + uint8_t status = ATT_ERR_NO_ERROR; - /* - * Check if Position Quality shall be added. - */ - if((LANS_IS_FEATURE_SUPPORTED(params->ln_feature, LANP_FEAT_NUMBER_OF_BEACONS_IN_SOLUTION_SUPP)) || - (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, LANP_FEAT_NUMBER_OF_BEACONS_IN_VIEW_SUPP)) || - (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, LANP_FEAT_TIME_TO_FIRST_FIX_SUPP)) || - (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, LANP_FEAT_ESTIMATED_HOR_POSITION_ERROR_SUPP)) || - (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, LANP_FEAT_ESTIMATED_VER_POSITION_ERROR_SUPP)) || - (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, LANP_FEAT_HOR_DILUTION_OF_PRECISION_SUPP)) || - (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, LANP_FEAT_VER_DILUTION_OF_PRECISION_SUPP)) || - (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, LANP_FEAT_POSITION_STATUS_SUPP))) - { - //Add configuration to the database - cfg_flag |= LANS_POS_Q_MASK; - } + /* + * Check if Position Quality shall be added. + */ + if ((LANS_IS_FEATURE_SUPPORTED( + params->ln_feature, LANP_FEAT_NUMBER_OF_BEACONS_IN_SOLUTION_SUPP)) || + (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, + LANP_FEAT_NUMBER_OF_BEACONS_IN_VIEW_SUPP)) || + (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, + LANP_FEAT_TIME_TO_FIRST_FIX_SUPP)) || + (LANS_IS_FEATURE_SUPPORTED( + params->ln_feature, LANP_FEAT_ESTIMATED_HOR_POSITION_ERROR_SUPP)) || + (LANS_IS_FEATURE_SUPPORTED( + params->ln_feature, LANP_FEAT_ESTIMATED_VER_POSITION_ERROR_SUPP)) || + (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, + LANP_FEAT_HOR_DILUTION_OF_PRECISION_SUPP)) || + (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, + LANP_FEAT_VER_DILUTION_OF_PRECISION_SUPP)) || + (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, + LANP_FEAT_POSITION_STATUS_SUPP))) { + // Add configuration to the database + cfg_flag |= LANS_POS_Q_MASK; + } - /* - * Check if the Navigation characteristic shall be added. - */ - if ((LANS_IS_FEATURE_SUPPORTED(params->prfl_config, LANS_NAVIGATION_SUPP_FLAG)) || - (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, LANP_FEAT_NUMBER_OF_BEACONS_IN_SOLUTION_SUPP)) || - (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, LANP_FEAT_REMAINING_DISTANCE_SUPP)) || - (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, LANP_FEAT_REMAINING_VERTICAL_DISTANCE_SUPP)) || - (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, LANP_FEAT_ESTIMATED_TIME_OF_ARRIVAL_SUPP)) || - (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, LANP_FEAT_POSITION_STATUS_SUPP))) - { - cfg_flag |= LANS_NAVI_MASK; - } - /* - * Check if the LN Control Point characteristic shall be added - */ - if ((LANS_IS_FEATURE_SUPPORTED(cfg_flag, LANS_NAVI_MASK)) || - (LANS_IS_FEATURE_SUPPORTED(params->prfl_config, LANS_CTNL_PT_CHAR_SUPP_FLAG)) || - (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, LANP_FEAT_TOTAL_DISTANCE_SUPP)) || - (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, LANP_FEAT_LSPEED_CHAR_CT_MASKING_SUPP)) || - (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, LANP_FEAT_FIX_RATE_SETTING_SUPP)) || - ((LANS_IS_FEATURE_SUPPORTED(params->ln_feature, LANP_FEAT_ELEVATION_SUPP)) && - (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, LANP_FEAT_ELEVATION_SETTING_SUPP)))) - { - cfg_flag |= LANS_LN_CTNL_PT_MASK; - } + /* + * Check if the Navigation characteristic shall be added. + */ + if ((LANS_IS_FEATURE_SUPPORTED(params->prfl_config, + LANS_NAVIGATION_SUPP_FLAG)) || + (LANS_IS_FEATURE_SUPPORTED( + params->ln_feature, LANP_FEAT_NUMBER_OF_BEACONS_IN_SOLUTION_SUPP)) || + (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, + LANP_FEAT_REMAINING_DISTANCE_SUPP)) || + (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, + LANP_FEAT_REMAINING_VERTICAL_DISTANCE_SUPP)) || + (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, + LANP_FEAT_ESTIMATED_TIME_OF_ARRIVAL_SUPP)) || + (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, + LANP_FEAT_POSITION_STATUS_SUPP))) { + cfg_flag |= LANS_NAVI_MASK; + } + /* + * Check if the LN Control Point characteristic shall be added + */ + if ((LANS_IS_FEATURE_SUPPORTED(cfg_flag, LANS_NAVI_MASK)) || + (LANS_IS_FEATURE_SUPPORTED(params->prfl_config, + LANS_CTNL_PT_CHAR_SUPP_FLAG)) || + (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, + LANP_FEAT_TOTAL_DISTANCE_SUPP)) || + (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, + LANP_FEAT_LSPEED_CHAR_CT_MASKING_SUPP)) || + (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, + LANP_FEAT_FIX_RATE_SETTING_SUPP)) || + ((LANS_IS_FEATURE_SUPPORTED(params->ln_feature, + LANP_FEAT_ELEVATION_SUPP)) && + (LANS_IS_FEATURE_SUPPORTED(params->ln_feature, + LANP_FEAT_ELEVATION_SETTING_SUPP)))) { + cfg_flag |= LANS_LN_CTNL_PT_MASK; + } - // Add service in the database - status = attm_svc_create_db(start_hdl, ATT_SVC_LOCATION_AND_NAVIGATION, (uint8_t *)&cfg_flag, - LNS_IDX_NB, NULL, env->task, &lans_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | PERM(SVC_MI, DISABLE)); + // Add service in the database + status = attm_svc_create_db( + start_hdl, ATT_SVC_LOCATION_AND_NAVIGATION, (uint8_t *)&cfg_flag, + LNS_IDX_NB, NULL, env->task, &lans_att_db[0], + (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, DISABLE)); - //-------------------- allocate memory required for the profile --------------------- - if (status == ATT_ERR_NO_ERROR) - { - // Allocate LANS required environment variable - struct lans_env_tag* lans_env = - (struct lans_env_tag* ) ke_malloc(sizeof(struct lans_env_tag), KE_MEM_ATT_DB); + //-------------------- allocate memory required for the profile + //--------------------- + if (status == ATT_ERR_NO_ERROR) { + // Allocate LANS required environment variable + struct lans_env_tag *lans_env = (struct lans_env_tag *)ke_malloc( + sizeof(struct lans_env_tag), KE_MEM_ATT_DB); - // Initialize LANS environment - env->env = (prf_env_t*) lans_env; - lans_env->shdl = *start_hdl; - lans_env->prfl_cfg = cfg_flag; - lans_env->features = params->ln_feature; - lans_env->operation = LANS_RESERVED_OP_CODE; - lans_env->posq = (LANS_IS_FEATURE_SUPPORTED(cfg_flag, LANS_POS_Q_MASK)) ? - (struct lanp_posq* ) ke_malloc(sizeof(struct lanp_posq), KE_MEM_ATT_DB) : NULL; + // Initialize LANS environment + env->env = (prf_env_t *)lans_env; + lans_env->shdl = *start_hdl; + lans_env->prfl_cfg = cfg_flag; + lans_env->features = params->ln_feature; + lans_env->operation = LANS_RESERVED_OP_CODE; + lans_env->posq = (LANS_IS_FEATURE_SUPPORTED(cfg_flag, LANS_POS_Q_MASK)) + ? (struct lanp_posq *)ke_malloc( + sizeof(struct lanp_posq), KE_MEM_ATT_DB) + : NULL; - lans_env->op_data = NULL; - memset(lans_env->env, 0, sizeof(lans_env->env)); + lans_env->op_data = NULL; + memset(lans_env->env, 0, sizeof(lans_env->env)); - lans_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - // Mono Instantiated task - lans_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); + lans_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + // Mono Instantiated task + lans_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); - // initialize environment variable - env->id = TASK_ID_LANS; - lans_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_LANS; + lans_task_init(&(env->desc)); - /* Put CPS in Idle state */ - ke_state_set(env->task, LANS_IDLE); - } + /* Put CPS in Idle state */ + ke_state_set(env->task, LANS_IDLE); + } - return (status); + return (status); } /** **************************************************************************************** * @brief Destruction of the LANS module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void lans_destroy(struct prf_task_env* env) -{ - struct lans_env_tag* lans_env = (struct lans_env_tag*) env->env; +static void lans_destroy(struct prf_task_env *env) { + struct lans_env_tag *lans_env = (struct lans_env_tag *)env->env; - // free profile environment variables - env->env = NULL; + // free profile environment variables + env->env = NULL; - if (lans_env->posq != NULL) - { - ke_free(lans_env->posq); + if (lans_env->posq != NULL) { + ke_free(lans_env->posq); + } + + if (lans_env->op_data != NULL) { + ke_free(lans_env->op_data->cmd); + if (lans_env->op_data->ntf_pending) { + ke_free(lans_env->op_data->ntf_pending); } + ke_free(lans_env->op_data); + } - if (lans_env->op_data != NULL) - { - ke_free(lans_env->op_data->cmd); - if(lans_env->op_data->ntf_pending) - { - ke_free(lans_env->op_data->ntf_pending); - } - ke_free(lans_env->op_data); - } - - ke_free(lans_env); + ke_free(lans_env); } /** @@ -227,11 +268,10 @@ static void lans_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void lans_create(struct prf_task_env* env, uint8_t conidx) -{ - struct lans_env_tag* lans_env = (struct lans_env_tag*) env->env; +static void lans_create(struct prf_task_env *env, uint8_t conidx) { + struct lans_env_tag *lans_env = (struct lans_env_tag *)env->env; - memset(&(lans_env->env[conidx]), 0, sizeof(struct lans_cnx_env)); + memset(&(lans_env->env[conidx]), 0, sizeof(struct lans_cnx_env)); } /** @@ -243,21 +283,20 @@ static void lans_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void lans_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct lans_env_tag* lans_env = (struct lans_env_tag*) env->env; +static void lans_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct lans_env_tag *lans_env = (struct lans_env_tag *)env->env; - // clean-up environment variable allocated for task instance - memset(&(lans_env->env[conidx]), 0, sizeof(struct lans_cnx_env)); + // clean-up environment variable allocated for task instance + memset(&(lans_env->env[conidx]), 0, sizeof(struct lans_cnx_env)); } /// LANS Task interface required by profile manager -const struct prf_task_cbs lans_itf = -{ - (prf_init_fnct) lans_init, - lans_destroy, - lans_create, - lans_cleanup, +const struct prf_task_cbs lans_itf = { + (prf_init_fnct)lans_init, + lans_destroy, + lans_create, + lans_cleanup, }; /* @@ -265,1098 +304,991 @@ const struct prf_task_cbs lans_itf = **************************************************************************************** */ -const struct prf_task_cbs* lans_prf_itf_get(void) -{ - return &lans_itf; +const struct prf_task_cbs *lans_prf_itf_get(void) { return &lans_itf; } + +void lans_send_cmp_evt(uint8_t conidx, uint8_t src_id, uint8_t dest_id, + uint8_t operation, uint8_t status) { + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + + // Go back to the Connected state if the state is busy + if (ke_state_get(src_id) == LANS_BUSY) { + ke_state_set(src_id, LANS_IDLE); + } + + // Set the operation code + lans_env->operation = LANS_RESERVED_OP_CODE; + + // Send the message + struct lans_cmp_evt *evt = + KE_MSG_ALLOC(LANS_CMP_EVT, dest_id, src_id, lans_cmp_evt); + + evt->conidx = conidx; + evt->operation = operation; + evt->status = status; + + ke_msg_send(evt); } -void lans_send_cmp_evt(uint8_t conidx, uint8_t src_id, uint8_t dest_id, uint8_t operation, uint8_t status) -{ - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); +uint8_t lans_pack_loc_speed_ntf(struct lanp_loc_speed *param, + uint8_t *pckd_loc_speed) { + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + // Packed Measurement length + uint8_t pckd_loc_speed_len = LANP_LAN_LOC_SPEED_MIN_LEN; - // Go back to the Connected state if the state is busy - if (ke_state_get(src_id) == LANS_BUSY) + // Check provided flags + if (LANS_IS_PRESENT(param->flags, LANP_LSPEED_INST_SPEED_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_INSTANTANEOUS_SPEED_SUPP)) { + // Pack instantaneous speed + co_write16p(&pckd_loc_speed[pckd_loc_speed_len], param->inst_speed); + pckd_loc_speed_len += 2; + } else // Not supported by the profile { - ke_state_set(src_id, LANS_IDLE); + // Force to not supported + param->flags &= ~LANP_LSPEED_INST_SPEED_PRESENT; + } + } + + if (LANS_IS_PRESENT(param->flags, LANP_LSPEED_TOTAL_DISTANCE_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_TOTAL_DISTANCE_SUPP)) { + // Pack total distance (24bits) + co_write24p(&pckd_loc_speed[pckd_loc_speed_len], param->total_dist); + pckd_loc_speed_len += 3; + } else // Not supported by the profile + { + // Force to not supported + param->flags &= ~LANP_LSPEED_TOTAL_DISTANCE_PRESENT; + } + } + + if (LANS_IS_PRESENT(param->flags, LANP_LSPEED_LOCATION_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_LOCATION_SUPP)) { + // Pack Location + co_write32p(&pckd_loc_speed[pckd_loc_speed_len], param->latitude); + pckd_loc_speed_len += 4; + co_write32p(&pckd_loc_speed[pckd_loc_speed_len], param->longitude); + pckd_loc_speed_len += 4; + } else // Not supported by the profile + { + // Force to not supported + param->flags &= ~LANP_LSPEED_LOCATION_PRESENT; + } + } + + if (LANS_IS_PRESENT(param->flags, LANP_LSPEED_ELEVATION_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_ELEVATION_SUPP)) { + // Pack elevation (24 bits) + co_write24p(&pckd_loc_speed[pckd_loc_speed_len], param->elevation); + pckd_loc_speed_len += 3; + } else // Not supported by the profile + { + // Force to not supported + param->flags &= ~LANP_LSPEED_ELEVATION_PRESENT; + } + } + + if (LANS_IS_PRESENT(param->flags, LANP_LSPEED_HEADING_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_HEADING_SUPP)) { + // Pack Extreme Force Magnitudes (Maximum Force Magnitude & Minimum Force + // Magnitude) + co_write16p(&pckd_loc_speed[pckd_loc_speed_len], param->heading); + pckd_loc_speed_len += 2; + } else // Not supported by the profile + { + // Force to not supported + param->flags &= ~LANP_LSPEED_HEADING_PRESENT; + } + } + + if (LANS_IS_PRESENT(param->flags, LANP_LSPEED_ROLLING_TIME_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_ROLLING_TIME_SUPP)) { + // Pack rolling time + pckd_loc_speed[pckd_loc_speed_len] = param->rolling_time; + pckd_loc_speed_len++; + } else // Not supported by the profile + { + // Force to not supported + param->flags &= ~LANP_LSPEED_ROLLING_TIME_PRESENT; + } + } + + if (LANS_IS_PRESENT(param->flags, LANP_LSPEED_UTC_TIME_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_UTC_TIME_SUPP)) { + // Pack UTC time + pckd_loc_speed_len += prf_pack_date_time( + &pckd_loc_speed[pckd_loc_speed_len], &(param->date_time)); + + } else // Not supported by the profile + { + // Force to not supported + param->flags &= ~LANP_LSPEED_UTC_TIME_PRESENT; + } + } + + // Force the unused bits of the flag value to 0 + // param->flags &= LANP_LSPEED_ALL_PRESENT; + // Flags value + co_write16p(&pckd_loc_speed[0], param->flags); + + return pckd_loc_speed_len; +} + +uint8_t lans_split_loc_speed_ntf(uint8_t conidx, + struct gattc_send_evt_cmd *loc_speed_ntf1) { + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + // Extract flags info + uint16_t flags = co_read16p(&loc_speed_ntf1->value[0]); + // Allocate the GATT notification message + struct gattc_send_evt_cmd *loc_speed_ntf2 = + KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&(lans_env->prf_env), conidx), + gattc_send_evt_cmd, LANP_LAN_LOC_SPEED_MAX_LEN); + + // Fill in the parameter structure + loc_speed_ntf2->operation = GATTC_NOTIFY; + loc_speed_ntf2->handle = LANS_HANDLE(LNS_IDX_LOC_SPEED_VAL); + loc_speed_ntf2->length = LANP_LAN_LOC_SPEED_MIN_LEN; + + // Copy status flags + co_write16p( + &loc_speed_ntf2->value[0], + (flags & + (LANP_LSPEED_POSITION_STATUS_LSB | LANP_LSPEED_POSITION_STATUS_MSB | + LANP_LSPEED_SPEED_AND_DISTANCE_FORMAT | + LANP_LSPEED_ELEVATION_SOURCE_LSB | LANP_LSPEED_ELEVATION_SOURCE_MSB | + LANP_LSPEED_HEADING_SOURCE))); + // Current position + uint8_t len = 0; + + for (uint16_t feat = LANP_LSPEED_INST_SPEED_PRESENT; + feat <= LANP_LSPEED_POSITION_STATUS_LSB; feat <<= 1) { + // First message fits within the MTU + if (loc_speed_ntf1->length <= gattc_get_mtu(conidx) - 3) { + // Stop splitting + break; } + if (LANS_IS_PRESENT(flags, feat)) { + switch (feat) { + case LANP_LSPEED_ROLLING_TIME_PRESENT: + // Copy uint8 + loc_speed_ntf2->value[loc_speed_ntf2->length] = + loc_speed_ntf1->value[LANP_LAN_LOC_SPEED_MIN_LEN]; + len = 1; + break; + + case LANP_LSPEED_INST_SPEED_PRESENT: + case LANP_LSPEED_HEADING_PRESENT: + // Copy uint16 + memcpy(&loc_speed_ntf2->value[loc_speed_ntf2->length], + &loc_speed_ntf1->value[LANP_LAN_LOC_SPEED_MIN_LEN], 2); + len = 2; + break; + + case LANP_LSPEED_TOTAL_DISTANCE_PRESENT: + case LANP_LSPEED_ELEVATION_PRESENT: + // Copy uint24 + memcpy(&loc_speed_ntf2->value[loc_speed_ntf2->length], + &loc_speed_ntf1->value[LANP_LAN_LOC_SPEED_MIN_LEN], 3); + len = 3; + break; + + case LANP_LSPEED_LOCATION_PRESENT: + // Copy latitude and longitude + memcpy(&loc_speed_ntf2->value[loc_speed_ntf2->length], + &loc_speed_ntf1->value[LANP_LAN_LOC_SPEED_MIN_LEN], 8); + len = 8; + break; + + case LANP_LSPEED_UTC_TIME_PRESENT: + // Copy time + memcpy(&loc_speed_ntf2->value[loc_speed_ntf2->length], + &loc_speed_ntf1->value[LANP_LAN_LOC_SPEED_MIN_LEN], 7); + len = 7; + break; + + default: + len = 0; + break; + } + + if (len) { + // Update values + loc_speed_ntf2->length += len; + // Remove field and flags from the first ntf + loc_speed_ntf1->length -= len; + memcpy(&loc_speed_ntf1->value[LANP_LAN_LOC_SPEED_MIN_LEN], + &loc_speed_ntf1->value[LANP_LAN_LOC_SPEED_MIN_LEN + len], + loc_speed_ntf1->length); + // Update flags + loc_speed_ntf1->value[0] &= ~feat; + loc_speed_ntf2->value[0] |= feat; + } + } + } + + // store the pending notification to send + lans_env->op_data->ntf_pending = loc_speed_ntf2; + + return loc_speed_ntf2->length; +} + +uint8_t +lans_update_characteristic_config(uint8_t conidx, uint8_t prfl_config, + struct gattc_write_req_ind const *param) { + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + // Status + uint8_t status = GAP_ERR_NO_ERROR; + // Get the value + uint16_t ntf_cfg = co_read16p(¶m->value[0]); + + // Check if the value is correct + if (prfl_config == LANS_PRF_CFG_FLAG_LN_CTNL_PT_IND) { + if ((ntf_cfg == PRF_CLI_STOP_NTFIND) || (ntf_cfg == PRF_CLI_START_IND)) { + // Save the new configuration in the environment + (ntf_cfg == PRF_CLI_STOP_NTFIND) + ? LANS_DISABLE_NTF_IND(conidx, prfl_config) + : LANS_ENABLE_NTF_IND(conidx, prfl_config); + } else { + status = PRF_ERR_INVALID_PARAM; + } + } else { + if ((ntf_cfg == PRF_CLI_STOP_NTFIND) || (ntf_cfg == PRF_CLI_START_NTF)) { + // Save the new configuration in the environment + (ntf_cfg == PRF_CLI_STOP_NTFIND) + ? LANS_DISABLE_NTF_IND(conidx, prfl_config) + : LANS_ENABLE_NTF_IND(conidx, prfl_config); + } else { + status = PRF_ERR_INVALID_PARAM; + } + } + + if (status == GAP_ERR_NO_ERROR) { + // Allocate message to inform application + struct lans_cfg_ntfind_ind *ind = KE_MSG_ALLOC( + LANS_CFG_NTFIND_IND, prf_dst_task_get(&(lans_env->prf_env), conidx), + prf_src_task_get(&(lans_env->prf_env), conidx), lans_cfg_ntfind_ind); + // Inform APP of configuration change + ind->char_code = prfl_config; + ind->ntf_cfg = ntf_cfg; + ind->conidx = conidx; + ke_msg_send(ind); + + // Enable Bonded Data + LANS_ENABLE_NTF_IND(conidx, LANS_PRF_CFG_PERFORMED_OK); + } + + return (status); +} + +uint8_t lans_pack_navigation_ntf(struct lanp_navigation *param, + uint8_t *pckd_navigation) { + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + // Packed Measurement length + uint8_t pckd_navigation_len = LANP_LAN_NAVIGATION_MIN_LEN; + + // Check provided flags + if (LANS_IS_PRESENT(param->flags, LANP_NAVI_REMAINING_DIS_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_REMAINING_DISTANCE_SUPP)) { + // Pack distance (24bits) + co_write24p(&pckd_navigation[pckd_navigation_len], + param->remaining_distance); + pckd_navigation_len += 3; + } else // Not supported by the profile + { + // Force to not supported + param->flags &= ~LANP_NAVI_REMAINING_DIS_PRESENT; + } + } + + if (LANS_IS_PRESENT(param->flags, LANP_NAVI_REMAINING_VER_DIS_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_REMAINING_VERTICAL_DISTANCE_SUPP)) { + // Pack vertical distance (24bits) + co_write24p(&pckd_navigation[pckd_navigation_len], + param->remaining_ver_distance); + pckd_navigation_len += 3; + } else // Not supported by the profile + { + // Force to not supported + param->flags &= ~LANP_NAVI_REMAINING_VER_DIS_PRESENT; + } + } + + if (LANS_IS_PRESENT(param->flags, + LANP_NAVI_ESTIMATED_TIME_OF_ARRIVAL_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_ESTIMATED_TIME_OF_ARRIVAL_SUPP)) { + // Pack time + pckd_navigation_len += + prf_pack_date_time(&pckd_navigation[pckd_navigation_len], + &(param->estimated_arrival_time)); + + } else // Not supported by the profile + { + // Force to not supported + param->flags &= ~LANP_NAVI_ESTIMATED_TIME_OF_ARRIVAL_PRESENT; + } + } + + // Force the unused bits of the flag value to 0 + // param->flags &= LANP_NAVI_ALL_PRESENT; + // Flags value + co_write16p(&pckd_navigation[0], param->flags); + // Bearing value + co_write16p(&pckd_navigation[2], param->bearing); + // heading value + co_write16p(&pckd_navigation[4], param->heading); + + return pckd_navigation_len; +} + +void lans_upd_posq(struct lanp_posq param) { + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + + // Check provided flags + if (LANS_IS_PRESENT(param.flags, + LANP_POSQ_NUMBER_OF_BEACONS_IN_SOLUTION_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED( + lans_env->features, LANP_FEAT_NUMBER_OF_BEACONS_IN_SOLUTION_SUPP)) { + // Pack beacons in solution + lans_env->posq->n_beacons_solution = param.n_beacons_solution; + } else // Not supported by the profile + { + // Force to not supported + param.flags &= ~LANP_POSQ_NUMBER_OF_BEACONS_IN_SOLUTION_PRESENT; + } + } + + if (LANS_IS_PRESENT(param.flags, + LANP_POSQ_NUMBER_OF_BEACONS_IN_VIEW_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_NUMBER_OF_BEACONS_IN_VIEW_SUPP)) { + // Pack beacons in view + lans_env->posq->n_beacons_view = param.n_beacons_view; + } else // Not supported by the profile + { + // Force to not supported + param.flags &= ~LANP_POSQ_NUMBER_OF_BEACONS_IN_VIEW_PRESENT; + } + } + + if (LANS_IS_PRESENT(param.flags, LANP_POSQ_TIME_TO_FIRST_FIX_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_TIME_TO_FIRST_FIX_SUPP)) { + // Pack time to fix + lans_env->posq->time_first_fix = param.time_first_fix; + } else // Not supported by the profile + { + // Force to not supported + param.flags &= ~LANP_POSQ_TIME_TO_FIRST_FIX_PRESENT; + } + } + + if (LANS_IS_PRESENT(param.flags, LANP_POSQ_EHPE_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED( + lans_env->features, LANP_FEAT_ESTIMATED_HOR_POSITION_ERROR_SUPP)) { + // Pack ehpe + lans_env->posq->ehpe = param.ehpe; + } else // Not supported by the profile + { + // Force to not supported + param.flags &= ~LANP_POSQ_EHPE_PRESENT; + } + } + + if (LANS_IS_PRESENT(param.flags, LANP_POSQ_EVPE_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED( + lans_env->features, LANP_FEAT_ESTIMATED_VER_POSITION_ERROR_SUPP)) { + // Pack evpe + lans_env->posq->evpe = param.evpe; + } else // Not supported by the profile + { + // Force to not supported + param.flags &= ~LANP_POSQ_EVPE_PRESENT; + } + } + + if (LANS_IS_PRESENT(param.flags, LANP_POSQ_HDOP_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_HOR_DILUTION_OF_PRECISION_SUPP)) { + // Pack hdop + lans_env->posq->hdop = param.hdop; + } else // Not supported by the profile + { + // Force to not supported + param.flags &= ~LANP_POSQ_HDOP_PRESENT; + } + } + + if (LANS_IS_PRESENT(param.flags, LANP_POSQ_VDOP_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_VER_DILUTION_OF_PRECISION_SUPP)) { + // Pack vdop + lans_env->posq->vdop = param.vdop; + } else // Not supported by the profile + { + // Force to not supported + param.flags &= ~LANP_POSQ_VDOP_PRESENT; + } + } + + // Force the unused bits of the flag value to 0 + // param.flags &= LANP_POSQ_ALL_PRESENT; + // Flags value + lans_env->posq->flags = param.flags; +} + +uint8_t lans_pack_posq(uint8_t *pckd_posq) { + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + + // Packed length + uint8_t pckd_posq_len = LANP_LAN_POSQ_MIN_LEN; + + // Check provided flags + if (LANS_IS_PRESENT(lans_env->posq->flags, + LANP_POSQ_NUMBER_OF_BEACONS_IN_SOLUTION_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED( + lans_env->features, LANP_FEAT_NUMBER_OF_BEACONS_IN_SOLUTION_SUPP)) { + // Pack beacons in solution + pckd_posq[pckd_posq_len] = lans_env->posq->n_beacons_solution; + pckd_posq_len++; + } else // Not supported by the profile + { + // Force to not supported + lans_env->posq->flags &= ~LANP_POSQ_NUMBER_OF_BEACONS_IN_SOLUTION_PRESENT; + } + } + + if (LANS_IS_PRESENT(lans_env->posq->flags, + LANP_POSQ_NUMBER_OF_BEACONS_IN_VIEW_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_NUMBER_OF_BEACONS_IN_VIEW_SUPP)) { + // Pack beacons in view + pckd_posq[pckd_posq_len] = lans_env->posq->n_beacons_view; + pckd_posq_len++; + } else // Not supported by the profile + { + // Force to not supported + lans_env->posq->flags &= ~LANP_POSQ_NUMBER_OF_BEACONS_IN_VIEW_PRESENT; + } + } + + if (LANS_IS_PRESENT(lans_env->posq->flags, + LANP_POSQ_TIME_TO_FIRST_FIX_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_TIME_TO_FIRST_FIX_SUPP)) { + // Pack time to fix + co_write16p(&pckd_posq[pckd_posq_len], lans_env->posq->time_first_fix); + pckd_posq_len += 2; + } else // Not supported by the profile + { + // Force to not supported + lans_env->posq->flags &= ~LANP_POSQ_TIME_TO_FIRST_FIX_PRESENT; + } + } + + if (LANS_IS_PRESENT(lans_env->posq->flags, LANP_POSQ_EHPE_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED( + lans_env->features, LANP_FEAT_ESTIMATED_HOR_POSITION_ERROR_SUPP)) { + // Pack ehpe + co_write32p(&pckd_posq[pckd_posq_len], lans_env->posq->ehpe); + pckd_posq_len += 4; + } else // Not supported by the profile + { + // Force to not supported + lans_env->posq->flags &= ~LANP_POSQ_EHPE_PRESENT; + } + } + + if (LANS_IS_PRESENT(lans_env->posq->flags, LANP_POSQ_EVPE_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED( + lans_env->features, LANP_FEAT_ESTIMATED_VER_POSITION_ERROR_SUPP)) { + // Pack ehpe + co_write32p(&pckd_posq[pckd_posq_len], lans_env->posq->evpe); + pckd_posq_len += 4; + } else // Not supported by the profile + { + // Force to not supported + lans_env->posq->flags &= ~LANP_POSQ_EVPE_PRESENT; + } + } + + if (LANS_IS_PRESENT(lans_env->posq->flags, LANP_POSQ_HDOP_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_HOR_DILUTION_OF_PRECISION_SUPP)) { + // Pack ehpe + pckd_posq[pckd_posq_len] = lans_env->posq->hdop; + pckd_posq_len++; + } else // Not supported by the profile + { + // Force to not supported + lans_env->posq->flags &= ~LANP_POSQ_HDOP_PRESENT; + } + } + + if (LANS_IS_PRESENT(lans_env->posq->flags, LANP_POSQ_VDOP_PRESENT)) { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_VER_DILUTION_OF_PRECISION_SUPP)) { + // Pack ehpe + pckd_posq[pckd_posq_len] = lans_env->posq->vdop; + pckd_posq_len++; + } else // Not supported by the profile + { + // Force to not supported + lans_env->posq->flags &= ~LANP_POSQ_VDOP_PRESENT; + } + } + + // Force the unused bits of the flag value to 0 + // lans_env->posq->flags &= LANP_POSQ_ALL_PRESENT; + // Flags value + co_write16p(&pckd_posq[0], lans_env->posq->flags); + + return pckd_posq_len; +} + +uint8_t lans_pack_ln_ctnl_point_cfm(uint8_t conidx, + struct lans_ln_ctnl_pt_cfm *param, + uint8_t *rsp) { + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + // Response Length (At least 3) + uint8_t rsp_len = LANP_LAN_LN_CNTL_PT_RSP_MIN_LEN; + + // Set the Response Code + rsp[0] = LANP_LN_CTNL_PT_RESPONSE_CODE; + // Set the Response Value + rsp[2] = (param->status > LANP_LN_CTNL_PT_RESP_FAILED) + ? LANP_LN_CTNL_PT_RESP_FAILED + : param->status; + + switch (lans_env->operation) { + case (LANS_SET_CUMUL_VALUE_OP_CODE): { + // Set the request operation code + rsp[1] = LANP_LN_CTNL_PT_SET_CUMUL_VALUE; + } break; + + case (LANS_MASK_LSPEED_CHAR_CT_OP_CODE): { + // Set the request operation code + rsp[1] = LANP_LN_CTNL_PT_MASK_LSPEED_CHAR_CT; + if (param->status == LANP_LN_CTNL_PT_RESP_SUCCESS) { + lans_env->env[conidx].mask_lspeed_content = + param->value.mask_lspeed_content & 0x007F; + } + } break; + + case (LANS_NAVIGATION_CONTROL_OP_CODE): { + // Set the request operation code + rsp[1] = LANP_LN_CTNL_PT_NAVIGATION_CONTROL; + if (param->status == LANP_LN_CTNL_PT_RESP_SUCCESS) { + switch (LANS_GET_NAV_MODE(conidx)) { + // Disable notifications + case LANP_LN_CTNL_STOP_NAVI: + case LANP_LN_CTNL_PAUSE_NAVI: + LANS_SET_NAV_EN(conidx, false); + break; + + // Enable notifications + case LANP_LN_CTNL_START_NAVI: + case LANP_LN_CTNL_RESUME_NAVI: + case LANP_LN_CTNL_START_NST_WPT: + LANS_SET_NAV_EN(conidx, true); + break; + + // Do nothing + case LANP_LN_CTNL_SKIP_WPT: + default: + break; + } + } + } break; + + case (LANS_REQ_NUMBER_OF_ROUTES_OP_CODE): { + // Set the request operation code + rsp[1] = LANP_LN_CTNL_PT_REQ_NUMBER_OF_ROUTES; + if (param->status == LANP_LN_CTNL_PT_RESP_SUCCESS) { + co_write16p(&rsp[rsp_len], param->value.number_of_routes); + rsp_len += 2; + } + } break; + + case (LANS_REQ_NAME_OF_ROUTE_OP_CODE): { + // Set the request operation code + rsp[1] = LANP_LN_CTNL_PT_REQ_NAME_OF_ROUTE; + if (param->status == LANP_LN_CTNL_PT_RESP_SUCCESS) { + // pack name of route + for (int i = 0; i < param->value.route.length; i++) { + rsp[i + 3] = param->value.route.name[i]; + rsp_len++; + } + } + } break; + + case (LANS_SELECT_ROUTE_OP_CODE): { + // Set the request operation code + rsp[1] = LANP_LN_CTNL_PT_SELECT_ROUTE; + } break; + + case (LANS_SET_FIX_RATE_OP_CODE): { + // Set the request operation code + rsp[1] = LANP_LN_CTNL_PT_SET_FIX_RATE; + } break; + + case (LANS_SET_ELEVATION_OP_CODE): { + // Set the request operation code + rsp[1] = LANP_LN_CTNL_PT_SET_ELEVATION; + } break; + + default: { + param->status = LANP_LN_CTNL_PT_RESP_NOT_SUPP; + } break; + } + + return rsp_len; +} + +uint8_t lans_unpack_ln_ctnl_point_ind(uint8_t conidx, + struct gattc_write_req_ind const *param) { + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + + // Indication Status + uint8_t ind_status = LANP_LN_CTNL_PT_RESP_NOT_SUPP; + + // Allocate a request indication message for the application + struct lans_ln_ctnl_pt_req_ind *req_ind = KE_MSG_ALLOC( + LANS_LN_CTNL_PT_REQ_IND, prf_dst_task_get(&(lans_env->prf_env), conidx), + prf_src_task_get(&(lans_env->prf_env), conidx), lans_ln_ctnl_pt_req_ind); + // Operation Code + req_ind->op_code = param->value[0]; + req_ind->conidx = conidx; + + // Operation Code + switch (req_ind->op_code) { + case (LANP_LN_CTNL_PT_SET_CUMUL_VALUE): { + // Check if total distance feature is supported + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_TOTAL_DISTANCE_SUPP)) { + // Provided parameter in not within the defined range + ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM; + + if (param->length == 4) { + // The request can be handled + ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS; + // Update the environment + lans_env->operation = LANS_SET_CUMUL_VALUE_OP_CODE; + // Cumulative value + req_ind->value.cumul_val = co_read24p(¶m->value[1]); + } + } + } break; + + case (LANP_LN_CTNL_PT_MASK_LSPEED_CHAR_CT): { + // Check if the LN Masking feature is supported + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_LSPEED_CHAR_CT_MASKING_SUPP)) { + // Provided parameter in not within the defined range + ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM; + + if (param->length == 3) { + // The request can be handled + ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS; + // Update the environment + lans_env->operation = LANS_MASK_LSPEED_CHAR_CT_OP_CODE; + // Mask content + req_ind->value.mask_content = co_read16p(¶m->value[1]); + } + } + } break; + + case (LANP_LN_CTNL_PT_NAVIGATION_CONTROL): { + // Check if navigation feature is supported + if ((LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_NAVI_MASK)) && + (LANS_IS_NTF_IND_ENABLED(conidx, LANS_PRF_CFG_FLAG_NAVIGATION_NTF))) { + // Provided parameter in not within the defined range + ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM; + + if (param->length == 2) { + if (param->value[1] <= 0x05) { + // The request can be handled + ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS; + // Update the environment + lans_env->operation = LANS_NAVIGATION_CONTROL_OP_CODE; + // Control value + req_ind->value.control_value = param->value[1]; + // Store value in the environment + LANS_SET_NAV_MODE(conidx, req_ind->value.control_value); + } + } + } + } break; + + case (LANP_LN_CTNL_PT_REQ_NUMBER_OF_ROUTES): { + // Check if navigation feature is supported + if (LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_NAVI_MASK)) { + // The request can be handled + ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS; + // Update the environment + lans_env->operation = LANS_REQ_NUMBER_OF_ROUTES_OP_CODE; + } + } break; + + case (LANP_LN_CTNL_PT_REQ_NAME_OF_ROUTE): { + // Check if navigation feature is supported + if (LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_NAVI_MASK)) { + // Provided parameter in not within the defined range + ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM; + + if (param->length == 3) { + // The request can be handled + ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS; + // Update the environment + lans_env->operation = LANS_REQ_NAME_OF_ROUTE_OP_CODE; + // Route number + req_ind->value.route_number = co_read16p(¶m->value[1]); + } + } + } break; + + case (LANP_LN_CTNL_PT_SELECT_ROUTE): { + // Check if navigation feature is supported + if (LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_NAVI_MASK)) { + // Provided parameter in not within the defined range + ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM; + + if (param->length == 3) { + // The request can be handled + ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS; + // Update the environment + lans_env->operation = LANS_SELECT_ROUTE_OP_CODE; + // route number + req_ind->value.route_number = co_read16p(¶m->value[1]); + } + } + } break; + + case (LANP_LN_CTNL_PT_SET_FIX_RATE): { + // Check if the LN Masking feature is supported + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_FIX_RATE_SETTING_SUPP)) { + // Provided parameter in not within the defined range + ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM; + + if (param->length == 2) { + // The request can be handled + ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS; + // Update the environment + lans_env->operation = LANS_SET_FIX_RATE_OP_CODE; + // fix rate + req_ind->value.fix_rate = param->value[1]; + } + } + } break; + + case (LANP_LN_CTNL_PT_SET_ELEVATION): { + // Check if the Chain Weight Adjustment feature is supported + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_ELEVATION_SETTING_SUPP)) { + // Provided parameter in not within the defined range + ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM; + + if (param->length == 4) { + // The request can be handled + ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS; + // Update the environment + lans_env->operation = LANS_SET_ELEVATION_OP_CODE; + // elevation + req_ind->value.elevation = co_read24p(¶m->value[1]); + } + } + } break; + + default: { + // Operation Code is invalid, status is already LAN_CTNL_PT_RESP_NOT_SUPP + } break; + } + + // If no error raised, inform the application about the request + if (ind_status == LANP_LN_CTNL_PT_RESP_SUCCESS) { + // Send the request indication to the application + ke_msg_send(req_ind); + // Go to the Busy status + ke_state_set(prf_src_task_get(&(lans_env->prf_env), conidx), LANS_BUSY); + } else { + // Free the allocated message + ke_msg_free(ke_param2msg(req_ind)); + } + + return ind_status; +} + +void lans_exe_operation(void) { + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + + ASSERT_ERR(lans_env->op_data != NULL); + + bool finished = true; + + while ((lans_env->op_data->cursor < BLE_CONNECTION_MAX) && finished) { + uint8_t conidx = lans_env->op_data->cursor; + + switch (lans_env->operation) { + case LANS_NTF_LOC_SPEED_OP_CODE: { + // notification is pending, send it first + if (lans_env->op_data->ntf_pending != NULL) { + ke_msg_send(lans_env->op_data->ntf_pending); + lans_env->op_data->ntf_pending = NULL; + finished = false; + } + // Check if sending of notifications has been enabled + else if (LANS_IS_NTF_IND_ENABLED(conidx, + LANS_PRF_CFG_FLAG_LOC_SPEED_NTF)) { + struct lans_ntf_loc_speed_req *speed_cmd = + (struct lans_ntf_loc_speed_req *)ke_msg2param( + lans_env->op_data->cmd); + + // Save flags value + uint16_t flags = speed_cmd->parameters.flags; + + // Mask unwanted fields if supported + if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, + LANP_FEAT_LSPEED_CHAR_CT_MASKING_SUPP)) { + speed_cmd->parameters.flags &= + ~lans_env->env[conidx].mask_lspeed_content; + } + + // Allocate the GATT notification message + struct gattc_send_evt_cmd *meas_val = KE_MSG_ALLOC_DYN( + GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&(lans_env->prf_env), conidx), gattc_send_evt_cmd, + LANP_LAN_LOC_SPEED_MAX_LEN); + + // Fill in the parameter structure + meas_val->operation = GATTC_NOTIFY; + meas_val->handle = LANS_HANDLE(LNS_IDX_LOC_SPEED_VAL); + // pack measured value in database + meas_val->length = + lans_pack_loc_speed_ntf(&speed_cmd->parameters, meas_val->value); + + if (meas_val->length > gattc_get_mtu(conidx) - 3) { + // Split (if necessary) + lans_split_loc_speed_ntf(conidx, meas_val); + } + + // Restore flags value + speed_cmd->parameters.flags = flags; + + // Send the event + ke_msg_send(meas_val); + + finished = false; + } + + // update cursor only if all notification has been sent + if (lans_env->op_data->ntf_pending == NULL) { + lans_env->op_data->cursor++; + } + } break; + + case LANS_NTF_NAVIGATION_OP_CODE: { + struct lans_ntf_navigation_req *nav_cmd = + (struct lans_ntf_navigation_req *)ke_msg2param( + lans_env->op_data->cmd); + + // Check if sending of notifications has been enabled + if (LANS_IS_NTF_IND_ENABLED(conidx, LANS_PRF_CFG_FLAG_NAVIGATION_NTF) + // and if navigation is enabled + && LANS_IS_NAV_EN(conidx)) { + // Allocate the GATT notification message + struct gattc_send_evt_cmd *meas_val = KE_MSG_ALLOC_DYN( + GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&(lans_env->prf_env), conidx), gattc_send_evt_cmd, + LANP_LAN_NAVIGATION_MAX_LEN); + + // Fill in the parameter structure + meas_val->operation = GATTC_NOTIFY; + meas_val->handle = LANS_HANDLE(LNS_IDX_NAVIGATION_VAL); + // pack measured value in database + meas_val->length = + lans_pack_navigation_ntf(&nav_cmd->parameters, meas_val->value); + + // Send the event + ke_msg_send(meas_val); + + finished = false; + } + + lans_env->op_data->cursor++; + } break; + default: + ASSERT_ERR(0); + break; + } + } + + // check if operation is finished + if (finished) { + // send response to requester + struct lans_ntf_navigation_rsp *rsp = + KE_MSG_ALLOC(((lans_env->operation == LANS_NTF_NAVIGATION_OP_CODE) + ? LANS_NTF_NAVIGATION_RSP + : LANS_NTF_LOC_SPEED_RSP), + lans_env->op_data->cmd->src_id, + lans_env->op_data->cmd->dest_id, lans_ntf_navigation_rsp); + rsp->status = GAP_ERR_NO_ERROR; + ke_msg_send(rsp); + + // free operation data + ke_msg_free(lans_env->op_data->cmd); + ke_free(lans_env->op_data); + lans_env->op_data = NULL; // Set the operation code lans_env->operation = LANS_RESERVED_OP_CODE; - - // Send the message - struct lans_cmp_evt *evt = KE_MSG_ALLOC(LANS_CMP_EVT, - dest_id, src_id, - lans_cmp_evt); - - evt->conidx = conidx; - evt->operation = operation; - evt->status = status; - - ke_msg_send(evt); + // go back to idle state + ke_state_set(prf_src_task_get(&(lans_env->prf_env), 0), LANS_IDLE); + } } -uint8_t lans_pack_loc_speed_ntf(struct lanp_loc_speed *param, uint8_t *pckd_loc_speed) -{ - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); - // Packed Measurement length - uint8_t pckd_loc_speed_len = LANP_LAN_LOC_SPEED_MIN_LEN; +void lans_send_rsp_ind(uint8_t conidx, uint8_t req_op_code, uint8_t status) { + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); - // Check provided flags - if (LANS_IS_PRESENT(param->flags, LANP_LSPEED_INST_SPEED_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_INSTANTANEOUS_SPEED_SUPP)) - { - //Pack instantaneous speed - co_write16p(&pckd_loc_speed[pckd_loc_speed_len], param->inst_speed); - pckd_loc_speed_len += 2; - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~LANP_LSPEED_INST_SPEED_PRESENT; - } - } + // Allocate the GATT notification message + struct gattc_send_evt_cmd *ctl_pt_rsp = + KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&lans_env->prf_env, conidx), + gattc_send_evt_cmd, LANP_LAN_LN_CNTL_PT_RSP_MIN_LEN); - if (LANS_IS_PRESENT(param->flags, LANP_LSPEED_TOTAL_DISTANCE_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_TOTAL_DISTANCE_SUPP)) - { - //Pack total distance (24bits) - co_write24p(&pckd_loc_speed[pckd_loc_speed_len], param->total_dist); - pckd_loc_speed_len += 3; - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~LANP_LSPEED_TOTAL_DISTANCE_PRESENT; - } - } + // Fill in the parameter structure + ctl_pt_rsp->operation = GATTC_INDICATE; + ctl_pt_rsp->handle = LANS_HANDLE(LNS_IDX_LN_CTNL_PT_VAL); + // Pack Control Point confirmation + ctl_pt_rsp->length = LANP_LAN_LN_CNTL_PT_RSP_MIN_LEN; + // Response Code + ctl_pt_rsp->value[0] = LANP_LN_CTNL_PT_RESPONSE_CODE; + // Request Operation Code + ctl_pt_rsp->value[1] = req_op_code; + // Response value + ctl_pt_rsp->value[2] = status; - if (LANS_IS_PRESENT(param->flags, LANP_LSPEED_LOCATION_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_LOCATION_SUPP)) - { - //Pack Location - co_write32p(&pckd_loc_speed[pckd_loc_speed_len], param->latitude); - pckd_loc_speed_len += 4; - co_write32p(&pckd_loc_speed[pckd_loc_speed_len], param->longitude); - pckd_loc_speed_len += 4; - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~LANP_LSPEED_LOCATION_PRESENT; - } - } - - if (LANS_IS_PRESENT(param->flags, LANP_LSPEED_ELEVATION_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_ELEVATION_SUPP)) - { - //Pack elevation (24 bits) - co_write24p(&pckd_loc_speed[pckd_loc_speed_len], param->elevation); - pckd_loc_speed_len += 3; - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~LANP_LSPEED_ELEVATION_PRESENT; - } - } - - if (LANS_IS_PRESENT(param->flags, LANP_LSPEED_HEADING_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_HEADING_SUPP)) - { - //Pack Extreme Force Magnitudes (Maximum Force Magnitude & Minimum Force Magnitude) - co_write16p(&pckd_loc_speed[pckd_loc_speed_len], param->heading); - pckd_loc_speed_len += 2; - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~LANP_LSPEED_HEADING_PRESENT; - } - } - - if (LANS_IS_PRESENT(param->flags, LANP_LSPEED_ROLLING_TIME_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_ROLLING_TIME_SUPP)) - { - //Pack rolling time - pckd_loc_speed[pckd_loc_speed_len] = param->rolling_time; - pckd_loc_speed_len++; - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~LANP_LSPEED_ROLLING_TIME_PRESENT; - } - } - - if (LANS_IS_PRESENT(param->flags, LANP_LSPEED_UTC_TIME_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_UTC_TIME_SUPP)) - { - // Pack UTC time - pckd_loc_speed_len += prf_pack_date_time(&pckd_loc_speed[pckd_loc_speed_len], &(param->date_time)); - - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~LANP_LSPEED_UTC_TIME_PRESENT; - } - } - - // Force the unused bits of the flag value to 0 -// param->flags &= LANP_LSPEED_ALL_PRESENT; - // Flags value - co_write16p(&pckd_loc_speed[0], param->flags); - - return pckd_loc_speed_len; + // Send the event + ke_msg_send(ctl_pt_rsp); } -uint8_t lans_split_loc_speed_ntf(uint8_t conidx, struct gattc_send_evt_cmd *loc_speed_ntf1) -{ - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); - // Extract flags info - uint16_t flags = co_read16p(&loc_speed_ntf1->value[0]); - // Allocate the GATT notification message - struct gattc_send_evt_cmd *loc_speed_ntf2 = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(&(lans_env->prf_env), conidx), - gattc_send_evt_cmd, LANP_LAN_LOC_SPEED_MAX_LEN); - - // Fill in the parameter structure - loc_speed_ntf2->operation = GATTC_NOTIFY; - loc_speed_ntf2->handle = LANS_HANDLE(LNS_IDX_LOC_SPEED_VAL); - loc_speed_ntf2->length = LANP_LAN_LOC_SPEED_MIN_LEN; - - // Copy status flags - co_write16p(&loc_speed_ntf2->value[0], (flags & (LANP_LSPEED_POSITION_STATUS_LSB | - LANP_LSPEED_POSITION_STATUS_MSB | - LANP_LSPEED_SPEED_AND_DISTANCE_FORMAT | - LANP_LSPEED_ELEVATION_SOURCE_LSB | - LANP_LSPEED_ELEVATION_SOURCE_MSB | - LANP_LSPEED_HEADING_SOURCE))); - // Current position - uint8_t len = 0; - - for (uint16_t feat = LANP_LSPEED_INST_SPEED_PRESENT; - feat <= LANP_LSPEED_POSITION_STATUS_LSB; - feat <<= 1) - { - // First message fits within the MTU - if (loc_speed_ntf1->length <= gattc_get_mtu(conidx) - 3) - { - // Stop splitting - break; - } - - if (LANS_IS_PRESENT(flags, feat)) - { - switch (feat) - { - case LANP_LSPEED_ROLLING_TIME_PRESENT: - // Copy uint8 - loc_speed_ntf2->value[loc_speed_ntf2->length] = - loc_speed_ntf1->value[LANP_LAN_LOC_SPEED_MIN_LEN]; - len = 1; - break; - - case LANP_LSPEED_INST_SPEED_PRESENT: - case LANP_LSPEED_HEADING_PRESENT: - // Copy uint16 - memcpy(&loc_speed_ntf2->value[loc_speed_ntf2->length], - &loc_speed_ntf1->value[LANP_LAN_LOC_SPEED_MIN_LEN], - 2); - len = 2; - break; - - case LANP_LSPEED_TOTAL_DISTANCE_PRESENT: - case LANP_LSPEED_ELEVATION_PRESENT: - // Copy uint24 - memcpy(&loc_speed_ntf2->value[loc_speed_ntf2->length], - &loc_speed_ntf1->value[LANP_LAN_LOC_SPEED_MIN_LEN], - 3); - len = 3; - break; - - case LANP_LSPEED_LOCATION_PRESENT: - // Copy latitude and longitude - memcpy(&loc_speed_ntf2->value[loc_speed_ntf2->length], - &loc_speed_ntf1->value[LANP_LAN_LOC_SPEED_MIN_LEN], - 8); - len = 8; - break; - - case LANP_LSPEED_UTC_TIME_PRESENT: - // Copy time - memcpy(&loc_speed_ntf2->value[loc_speed_ntf2->length], - &loc_speed_ntf1->value[LANP_LAN_LOC_SPEED_MIN_LEN], - 7); - len = 7; - break; - - default: - len = 0; - break; - } - - if (len) - { - // Update values - loc_speed_ntf2->length += len; - // Remove field and flags from the first ntf - loc_speed_ntf1->length -= len; - memcpy(&loc_speed_ntf1->value[LANP_LAN_LOC_SPEED_MIN_LEN], - &loc_speed_ntf1->value[LANP_LAN_LOC_SPEED_MIN_LEN + len], - loc_speed_ntf1->length); - // Update flags - loc_speed_ntf1->value[0] &= ~feat; - loc_speed_ntf2->value[0] |= feat; - } - } - } - - // store the pending notification to send - lans_env->op_data->ntf_pending = loc_speed_ntf2; - - return loc_speed_ntf2->length; -} - -uint8_t lans_update_characteristic_config(uint8_t conidx, uint8_t prfl_config, struct gattc_write_req_ind const *param) -{ - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); - // Status - uint8_t status = GAP_ERR_NO_ERROR; - // Get the value - uint16_t ntf_cfg = co_read16p(¶m->value[0]); - - // Check if the value is correct - if (prfl_config == LANS_PRF_CFG_FLAG_LN_CTNL_PT_IND) - { - if ((ntf_cfg == PRF_CLI_STOP_NTFIND) || (ntf_cfg == PRF_CLI_START_IND)) - { - // Save the new configuration in the environment - (ntf_cfg == PRF_CLI_STOP_NTFIND) ? - LANS_DISABLE_NTF_IND(conidx, prfl_config) : LANS_ENABLE_NTF_IND(conidx, prfl_config); - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } - else - { - if ((ntf_cfg == PRF_CLI_STOP_NTFIND) || (ntf_cfg == PRF_CLI_START_NTF)) - { - // Save the new configuration in the environment - (ntf_cfg == PRF_CLI_STOP_NTFIND) ? - LANS_DISABLE_NTF_IND(conidx, prfl_config) : LANS_ENABLE_NTF_IND(conidx, prfl_config); - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } - - if (status == GAP_ERR_NO_ERROR) - { - // Allocate message to inform application - struct lans_cfg_ntfind_ind *ind = KE_MSG_ALLOC(LANS_CFG_NTFIND_IND, - prf_dst_task_get(&(lans_env->prf_env), conidx), prf_src_task_get(&(lans_env->prf_env), conidx), - lans_cfg_ntfind_ind); - // Inform APP of configuration change - ind->char_code = prfl_config; - ind->ntf_cfg = ntf_cfg; - ind->conidx = conidx; - ke_msg_send(ind); - - // Enable Bonded Data - LANS_ENABLE_NTF_IND(conidx, LANS_PRF_CFG_PERFORMED_OK); - } - - return (status); -} - -uint8_t lans_pack_navigation_ntf(struct lanp_navigation *param, uint8_t *pckd_navigation) -{ - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); - // Packed Measurement length - uint8_t pckd_navigation_len = LANP_LAN_NAVIGATION_MIN_LEN; - - // Check provided flags - if (LANS_IS_PRESENT(param->flags, LANP_NAVI_REMAINING_DIS_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_REMAINING_DISTANCE_SUPP)) - { - //Pack distance (24bits) - co_write24p(&pckd_navigation[pckd_navigation_len], param->remaining_distance); - pckd_navigation_len += 3; - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~LANP_NAVI_REMAINING_DIS_PRESENT; - } - } - - if (LANS_IS_PRESENT(param->flags, LANP_NAVI_REMAINING_VER_DIS_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_REMAINING_VERTICAL_DISTANCE_SUPP)) - { - //Pack vertical distance (24bits) - co_write24p(&pckd_navigation[pckd_navigation_len], param->remaining_ver_distance); - pckd_navigation_len += 3; - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~LANP_NAVI_REMAINING_VER_DIS_PRESENT; - } - } - - if (LANS_IS_PRESENT(param->flags, LANP_NAVI_ESTIMATED_TIME_OF_ARRIVAL_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_ESTIMATED_TIME_OF_ARRIVAL_SUPP)) - { - //Pack time - pckd_navigation_len += prf_pack_date_time( - &pckd_navigation[pckd_navigation_len], &(param->estimated_arrival_time)); - - } - else //Not supported by the profile - { - //Force to not supported - param->flags &= ~LANP_NAVI_ESTIMATED_TIME_OF_ARRIVAL_PRESENT; - } - } - - // Force the unused bits of the flag value to 0 -// param->flags &= LANP_NAVI_ALL_PRESENT; - // Flags value - co_write16p(&pckd_navigation[0], param->flags); - // Bearing value - co_write16p(&pckd_navigation[2], param->bearing); - // heading value - co_write16p(&pckd_navigation[4], param->heading); - - return pckd_navigation_len; -} - -void lans_upd_posq(struct lanp_posq param) -{ - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); - - // Check provided flags - if (LANS_IS_PRESENT(param.flags, LANP_POSQ_NUMBER_OF_BEACONS_IN_SOLUTION_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_NUMBER_OF_BEACONS_IN_SOLUTION_SUPP)) - { - //Pack beacons in solution - lans_env->posq->n_beacons_solution = param.n_beacons_solution; - } - else //Not supported by the profile - { - //Force to not supported - param.flags &= ~LANP_POSQ_NUMBER_OF_BEACONS_IN_SOLUTION_PRESENT; - } - } - - if (LANS_IS_PRESENT(param.flags, LANP_POSQ_NUMBER_OF_BEACONS_IN_VIEW_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_NUMBER_OF_BEACONS_IN_VIEW_SUPP)) - { - //Pack beacons in view - lans_env->posq->n_beacons_view = param.n_beacons_view; - } - else //Not supported by the profile - { - //Force to not supported - param.flags &= ~LANP_POSQ_NUMBER_OF_BEACONS_IN_VIEW_PRESENT; - } - } - - if (LANS_IS_PRESENT(param.flags, LANP_POSQ_TIME_TO_FIRST_FIX_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_TIME_TO_FIRST_FIX_SUPP)) - { - //Pack time to fix - lans_env->posq->time_first_fix = param.time_first_fix; - } - else //Not supported by the profile - { - //Force to not supported - param.flags &= ~LANP_POSQ_TIME_TO_FIRST_FIX_PRESENT; - } - } - - if (LANS_IS_PRESENT(param.flags, LANP_POSQ_EHPE_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_ESTIMATED_HOR_POSITION_ERROR_SUPP)) - { - //Pack ehpe - lans_env->posq->ehpe = param.ehpe; - } - else //Not supported by the profile - { - //Force to not supported - param.flags &= ~LANP_POSQ_EHPE_PRESENT; - } - } - - if (LANS_IS_PRESENT(param.flags, LANP_POSQ_EVPE_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_ESTIMATED_VER_POSITION_ERROR_SUPP)) - { - //Pack evpe - lans_env->posq->evpe = param.evpe; - } - else //Not supported by the profile - { - //Force to not supported - param.flags &= ~LANP_POSQ_EVPE_PRESENT; - } - } - - if (LANS_IS_PRESENT(param.flags, LANP_POSQ_HDOP_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_HOR_DILUTION_OF_PRECISION_SUPP)) - { - //Pack hdop - lans_env->posq->hdop = param.hdop; - } - else //Not supported by the profile - { - //Force to not supported - param.flags &= ~LANP_POSQ_HDOP_PRESENT; - } - } - - if (LANS_IS_PRESENT(param.flags, LANP_POSQ_VDOP_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_VER_DILUTION_OF_PRECISION_SUPP)) - { - //Pack vdop - lans_env->posq->vdop = param.vdop; - } - else //Not supported by the profile - { - //Force to not supported - param.flags &= ~LANP_POSQ_VDOP_PRESENT; - } - } - - // Force the unused bits of the flag value to 0 -// param.flags &= LANP_POSQ_ALL_PRESENT; - // Flags value - lans_env->posq->flags = param.flags; -} - -uint8_t lans_pack_posq(uint8_t *pckd_posq) -{ - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); - - // Packed length - uint8_t pckd_posq_len = LANP_LAN_POSQ_MIN_LEN; - - // Check provided flags - if (LANS_IS_PRESENT(lans_env->posq->flags, LANP_POSQ_NUMBER_OF_BEACONS_IN_SOLUTION_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_NUMBER_OF_BEACONS_IN_SOLUTION_SUPP)) - { - //Pack beacons in solution - pckd_posq[pckd_posq_len] = lans_env->posq->n_beacons_solution; - pckd_posq_len++; - } - else //Not supported by the profile - { - //Force to not supported - lans_env->posq->flags &= ~LANP_POSQ_NUMBER_OF_BEACONS_IN_SOLUTION_PRESENT; - } - } - - if (LANS_IS_PRESENT(lans_env->posq->flags, LANP_POSQ_NUMBER_OF_BEACONS_IN_VIEW_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_NUMBER_OF_BEACONS_IN_VIEW_SUPP)) - { - //Pack beacons in view - pckd_posq[pckd_posq_len] = lans_env->posq->n_beacons_view; - pckd_posq_len++; - } - else //Not supported by the profile - { - //Force to not supported - lans_env->posq->flags &= ~LANP_POSQ_NUMBER_OF_BEACONS_IN_VIEW_PRESENT; - } - } - - if (LANS_IS_PRESENT(lans_env->posq->flags, LANP_POSQ_TIME_TO_FIRST_FIX_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_TIME_TO_FIRST_FIX_SUPP)) - { - //Pack time to fix - co_write16p(&pckd_posq[pckd_posq_len], lans_env->posq->time_first_fix); - pckd_posq_len += 2; - } - else //Not supported by the profile - { - //Force to not supported - lans_env->posq->flags &= ~LANP_POSQ_TIME_TO_FIRST_FIX_PRESENT; - } - } - - if (LANS_IS_PRESENT(lans_env->posq->flags, LANP_POSQ_EHPE_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_ESTIMATED_HOR_POSITION_ERROR_SUPP)) - { - //Pack ehpe - co_write32p(&pckd_posq[pckd_posq_len], lans_env->posq->ehpe); - pckd_posq_len += 4; - } - else //Not supported by the profile - { - //Force to not supported - lans_env->posq->flags &= ~LANP_POSQ_EHPE_PRESENT; - } - } - - if (LANS_IS_PRESENT(lans_env->posq->flags, LANP_POSQ_EVPE_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_ESTIMATED_VER_POSITION_ERROR_SUPP)) - { - //Pack ehpe - co_write32p(&pckd_posq[pckd_posq_len], lans_env->posq->evpe); - pckd_posq_len += 4; - } - else //Not supported by the profile - { - //Force to not supported - lans_env->posq->flags &= ~LANP_POSQ_EVPE_PRESENT; - } - } - - if (LANS_IS_PRESENT(lans_env->posq->flags, LANP_POSQ_HDOP_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_HOR_DILUTION_OF_PRECISION_SUPP)) - { - //Pack ehpe - pckd_posq[pckd_posq_len] = lans_env->posq->hdop; - pckd_posq_len++; - } - else //Not supported by the profile - { - //Force to not supported - lans_env->posq->flags &= ~LANP_POSQ_HDOP_PRESENT; - } - } - - if (LANS_IS_PRESENT(lans_env->posq->flags, LANP_POSQ_VDOP_PRESENT)) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_VER_DILUTION_OF_PRECISION_SUPP)) - { - //Pack ehpe - pckd_posq[pckd_posq_len] = lans_env->posq->vdop; - pckd_posq_len++; - } - else //Not supported by the profile - { - //Force to not supported - lans_env->posq->flags &= ~LANP_POSQ_VDOP_PRESENT; - } - } - - // Force the unused bits of the flag value to 0 -// lans_env->posq->flags &= LANP_POSQ_ALL_PRESENT; - // Flags value - co_write16p(&pckd_posq[0], lans_env->posq->flags); - - return pckd_posq_len; -} - -uint8_t lans_pack_ln_ctnl_point_cfm (uint8_t conidx, struct lans_ln_ctnl_pt_cfm *param, uint8_t *rsp) -{ - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); - // Response Length (At least 3) - uint8_t rsp_len = LANP_LAN_LN_CNTL_PT_RSP_MIN_LEN; - - // Set the Response Code - rsp[0] = LANP_LN_CTNL_PT_RESPONSE_CODE; - // Set the Response Value - rsp[2] = (param->status > LANP_LN_CTNL_PT_RESP_FAILED) ? LANP_LN_CTNL_PT_RESP_FAILED : param->status; - - switch (lans_env->operation) - { - case (LANS_SET_CUMUL_VALUE_OP_CODE): - { - // Set the request operation code - rsp[1] = LANP_LN_CTNL_PT_SET_CUMUL_VALUE; - } break; - - case (LANS_MASK_LSPEED_CHAR_CT_OP_CODE): - { - // Set the request operation code - rsp[1] = LANP_LN_CTNL_PT_MASK_LSPEED_CHAR_CT; - if (param->status == LANP_LN_CTNL_PT_RESP_SUCCESS) - { - lans_env->env[conidx].mask_lspeed_content = - param->value.mask_lspeed_content & 0x007F; - } - } break; - - case (LANS_NAVIGATION_CONTROL_OP_CODE): - { - // Set the request operation code - rsp[1] = LANP_LN_CTNL_PT_NAVIGATION_CONTROL; - if (param->status == LANP_LN_CTNL_PT_RESP_SUCCESS) - { - switch(LANS_GET_NAV_MODE(conidx)) - { - // Disable notifications - case LANP_LN_CTNL_STOP_NAVI: - case LANP_LN_CTNL_PAUSE_NAVI: - LANS_SET_NAV_EN(conidx, false); - break; - - // Enable notifications - case LANP_LN_CTNL_START_NAVI: - case LANP_LN_CTNL_RESUME_NAVI: - case LANP_LN_CTNL_START_NST_WPT: - LANS_SET_NAV_EN(conidx, true); - break; - - // Do nothing - case LANP_LN_CTNL_SKIP_WPT: - default: - break; - } - } - } break; - - case (LANS_REQ_NUMBER_OF_ROUTES_OP_CODE): - { - // Set the request operation code - rsp[1] = LANP_LN_CTNL_PT_REQ_NUMBER_OF_ROUTES; - if (param->status == LANP_LN_CTNL_PT_RESP_SUCCESS) - { - co_write16p(&rsp[rsp_len], param->value.number_of_routes); - rsp_len += 2; - } - } break; - - case (LANS_REQ_NAME_OF_ROUTE_OP_CODE): - { - // Set the request operation code - rsp[1] = LANP_LN_CTNL_PT_REQ_NAME_OF_ROUTE; - if (param->status == LANP_LN_CTNL_PT_RESP_SUCCESS) - { - // pack name of route - for (int i=0; ivalue.route.length; i++) - { - rsp[i + 3] = param->value.route.name[i]; - rsp_len++; - } - } - } break; - - case (LANS_SELECT_ROUTE_OP_CODE): - { - // Set the request operation code - rsp[1] = LANP_LN_CTNL_PT_SELECT_ROUTE; - } break; - - case (LANS_SET_FIX_RATE_OP_CODE): - { - // Set the request operation code - rsp[1] = LANP_LN_CTNL_PT_SET_FIX_RATE; - } break; - - case (LANS_SET_ELEVATION_OP_CODE): - { - // Set the request operation code - rsp[1] = LANP_LN_CTNL_PT_SET_ELEVATION; - } break; - - default: - { - param->status = LANP_LN_CTNL_PT_RESP_NOT_SUPP; - } break; - } - - return rsp_len; -} - -uint8_t lans_unpack_ln_ctnl_point_ind (uint8_t conidx, struct gattc_write_req_ind const *param) -{ - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); - - // Indication Status - uint8_t ind_status = LANP_LN_CTNL_PT_RESP_NOT_SUPP; - - // Allocate a request indication message for the application - struct lans_ln_ctnl_pt_req_ind *req_ind = KE_MSG_ALLOC(LANS_LN_CTNL_PT_REQ_IND, - prf_dst_task_get(&(lans_env->prf_env), conidx), prf_src_task_get(&(lans_env->prf_env), conidx), - lans_ln_ctnl_pt_req_ind); - // Operation Code - req_ind->op_code = param->value[0]; - req_ind->conidx = conidx; - - // Operation Code - switch(req_ind->op_code) - { - case (LANP_LN_CTNL_PT_SET_CUMUL_VALUE): - { - // Check if total distance feature is supported - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_TOTAL_DISTANCE_SUPP)) - { - // Provided parameter in not within the defined range - ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM; - - if (param->length == 4) - { - // The request can be handled - ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS; - // Update the environment - lans_env->operation = LANS_SET_CUMUL_VALUE_OP_CODE; - // Cumulative value - req_ind->value.cumul_val = co_read24p(¶m->value[1]); - } - } - } break; - - case (LANP_LN_CTNL_PT_MASK_LSPEED_CHAR_CT): - { - // Check if the LN Masking feature is supported - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_LSPEED_CHAR_CT_MASKING_SUPP)) - { - // Provided parameter in not within the defined range - ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM; - - if (param->length == 3) - { - // The request can be handled - ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS; - // Update the environment - lans_env->operation = LANS_MASK_LSPEED_CHAR_CT_OP_CODE; - // Mask content - req_ind->value.mask_content = co_read16p(¶m->value[1]); - } - } - } break; - - case (LANP_LN_CTNL_PT_NAVIGATION_CONTROL): - { - // Check if navigation feature is supported - if ((LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_NAVI_MASK)) && - (LANS_IS_NTF_IND_ENABLED(conidx, LANS_PRF_CFG_FLAG_NAVIGATION_NTF))) - { - // Provided parameter in not within the defined range - ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM; - - if (param->length == 2) - { - if (param->value[1] <= 0x05) - { - // The request can be handled - ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS; - // Update the environment - lans_env->operation = LANS_NAVIGATION_CONTROL_OP_CODE; - // Control value - req_ind->value.control_value = param->value[1]; - // Store value in the environment - LANS_SET_NAV_MODE(conidx, req_ind->value.control_value); - } - } - } - } break; - - case (LANP_LN_CTNL_PT_REQ_NUMBER_OF_ROUTES): - { - // Check if navigation feature is supported - if (LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_NAVI_MASK)) - { - // The request can be handled - ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS; - // Update the environment - lans_env->operation = LANS_REQ_NUMBER_OF_ROUTES_OP_CODE; - } - } break; - - case (LANP_LN_CTNL_PT_REQ_NAME_OF_ROUTE): - { - // Check if navigation feature is supported - if (LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_NAVI_MASK)) - { - // Provided parameter in not within the defined range - ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM; - - if (param->length == 3) - { - // The request can be handled - ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS; - // Update the environment - lans_env->operation = LANS_REQ_NAME_OF_ROUTE_OP_CODE; - // Route number - req_ind->value.route_number = co_read16p(¶m->value[1]); - } - } - } break; - - case (LANP_LN_CTNL_PT_SELECT_ROUTE): - { - // Check if navigation feature is supported - if (LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_NAVI_MASK)) - { - // Provided parameter in not within the defined range - ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM; - - if (param->length == 3) - { - // The request can be handled - ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS; - // Update the environment - lans_env->operation = LANS_SELECT_ROUTE_OP_CODE; - // route number - req_ind->value.route_number = co_read16p(¶m->value[1]); - } - } - } break; - - case (LANP_LN_CTNL_PT_SET_FIX_RATE): - { - // Check if the LN Masking feature is supported - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_FIX_RATE_SETTING_SUPP)) - { - // Provided parameter in not within the defined range - ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM; - - if (param->length == 2) - { - // The request can be handled - ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS; - // Update the environment - lans_env->operation = LANS_SET_FIX_RATE_OP_CODE; - // fix rate - req_ind->value.fix_rate = param->value[1]; - } - } - } break; - - case (LANP_LN_CTNL_PT_SET_ELEVATION): - { - // Check if the Chain Weight Adjustment feature is supported - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_ELEVATION_SETTING_SUPP)) - { - // Provided parameter in not within the defined range - ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM; - - if (param->length == 4) - { - // The request can be handled - ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS; - // Update the environment - lans_env->operation = LANS_SET_ELEVATION_OP_CODE; - // elevation - req_ind->value.elevation = co_read24p(¶m->value[1]); - } - } - } break; - - default: - { - // Operation Code is invalid, status is already LAN_CTNL_PT_RESP_NOT_SUPP - } break; - } - - // If no error raised, inform the application about the request - if (ind_status == LANP_LN_CTNL_PT_RESP_SUCCESS) - { - // Send the request indication to the application - ke_msg_send(req_ind); - // Go to the Busy status - ke_state_set(prf_src_task_get(&(lans_env->prf_env), conidx), LANS_BUSY); - } - else - { - // Free the allocated message - ke_msg_free(ke_param2msg(req_ind)); - } - - return ind_status; -} - - - - -void lans_exe_operation(void) -{ - struct lans_env_tag* lans_env = PRF_ENV_GET(LANS, lans); - - ASSERT_ERR(lans_env->op_data != NULL); - - bool finished = true; - - while((lans_env->op_data->cursor < BLE_CONNECTION_MAX) && finished) - { - uint8_t conidx = lans_env->op_data->cursor; - - switch(lans_env->operation) - { - case LANS_NTF_LOC_SPEED_OP_CODE: - { - // notification is pending, send it first - if(lans_env->op_data->ntf_pending != NULL) - { - ke_msg_send(lans_env->op_data->ntf_pending); - lans_env->op_data->ntf_pending = NULL; - finished = false; - } - // Check if sending of notifications has been enabled - else if (LANS_IS_NTF_IND_ENABLED(conidx, LANS_PRF_CFG_FLAG_LOC_SPEED_NTF)) - { - struct lans_ntf_loc_speed_req *speed_cmd = - (struct lans_ntf_loc_speed_req *) ke_msg2param(lans_env->op_data->cmd); - - // Save flags value - uint16_t flags = speed_cmd->parameters.flags; - - // Mask unwanted fields if supported - if (LANS_IS_FEATURE_SUPPORTED(lans_env->features, LANP_FEAT_LSPEED_CHAR_CT_MASKING_SUPP)) - { - speed_cmd->parameters.flags &= ~lans_env->env[conidx].mask_lspeed_content; - } - - // Allocate the GATT notification message - struct gattc_send_evt_cmd *meas_val = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(&(lans_env->prf_env),conidx), - gattc_send_evt_cmd, LANP_LAN_LOC_SPEED_MAX_LEN); - - // Fill in the parameter structure - meas_val->operation = GATTC_NOTIFY; - meas_val->handle = LANS_HANDLE(LNS_IDX_LOC_SPEED_VAL); - // pack measured value in database - meas_val->length = lans_pack_loc_speed_ntf(&speed_cmd->parameters, meas_val->value); - - if (meas_val->length > gattc_get_mtu(conidx) - 3) - { - // Split (if necessary) - lans_split_loc_speed_ntf(conidx, meas_val); - } - - // Restore flags value - speed_cmd->parameters.flags = flags; - - // Send the event - ke_msg_send(meas_val); - - finished = false; - } - - // update cursor only if all notification has been sent - if(lans_env->op_data->ntf_pending == NULL) - { - lans_env->op_data->cursor++; - } - } - break; - - case LANS_NTF_NAVIGATION_OP_CODE: - { - struct lans_ntf_navigation_req *nav_cmd = - (struct lans_ntf_navigation_req *) ke_msg2param(lans_env->op_data->cmd); - - // Check if sending of notifications has been enabled - if (LANS_IS_NTF_IND_ENABLED(conidx, LANS_PRF_CFG_FLAG_NAVIGATION_NTF) - // and if navigation is enabled - && LANS_IS_NAV_EN(conidx)) - { - // Allocate the GATT notification message - struct gattc_send_evt_cmd *meas_val = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(&(lans_env->prf_env),conidx), - gattc_send_evt_cmd, LANP_LAN_NAVIGATION_MAX_LEN); - - // Fill in the parameter structure - meas_val->operation = GATTC_NOTIFY; - meas_val->handle = LANS_HANDLE(LNS_IDX_NAVIGATION_VAL); - // pack measured value in database - meas_val->length = lans_pack_navigation_ntf(&nav_cmd->parameters, meas_val->value); - - // Send the event - ke_msg_send(meas_val); - - finished = false; - } - - lans_env->op_data->cursor++; - } - break; - default: ASSERT_ERR(0); break; - } - } - - - // check if operation is finished - if(finished) - { - // send response to requester - struct lans_ntf_navigation_rsp * rsp = - KE_MSG_ALLOC(((lans_env->operation == LANS_NTF_NAVIGATION_OP_CODE) ? - LANS_NTF_NAVIGATION_RSP : LANS_NTF_LOC_SPEED_RSP), - lans_env->op_data->cmd->src_id, - lans_env->op_data->cmd->dest_id, - lans_ntf_navigation_rsp); - rsp->status = GAP_ERR_NO_ERROR; - ke_msg_send(rsp); - - // free operation data - ke_msg_free(lans_env->op_data->cmd); - ke_free(lans_env->op_data); - lans_env->op_data = NULL; - // Set the operation code - lans_env->operation = LANS_RESERVED_OP_CODE; - // go back to idle state - ke_state_set(prf_src_task_get(&(lans_env->prf_env), 0), LANS_IDLE); - } -} - -void lans_send_rsp_ind(uint8_t conidx, uint8_t req_op_code, uint8_t status) -{ - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); - - // Allocate the GATT notification message - struct gattc_send_evt_cmd *ctl_pt_rsp = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), - prf_src_task_get(&lans_env->prf_env, conidx), - gattc_send_evt_cmd, LANP_LAN_LN_CNTL_PT_RSP_MIN_LEN); - - // Fill in the parameter structure - ctl_pt_rsp->operation = GATTC_INDICATE; - ctl_pt_rsp->handle = LANS_HANDLE(LNS_IDX_LN_CTNL_PT_VAL); - // Pack Control Point confirmation - ctl_pt_rsp->length = LANP_LAN_LN_CNTL_PT_RSP_MIN_LEN; - // Response Code - ctl_pt_rsp->value[0] = LANP_LN_CTNL_PT_RESPONSE_CODE; - // Request Operation Code - ctl_pt_rsp->value[1] = req_op_code; - // Response value - ctl_pt_rsp->value[2] = status; - - // Send the event - ke_msg_send(ctl_pt_rsp); -} - - #endif //(BLE_LN_SENSOR) /// @} LANS diff --git a/services/ble_profiles/lan/lans/src/lans_task.c b/services/ble_profiles/lan/lans/src/lans_task.c index 492f63d..9e6a570 100644 --- a/services/ble_profiles/lan/lans/src/lans_task.c +++ b/services/ble_profiles/lan/lans/src/lans_task.c @@ -15,17 +15,17 @@ #if (BLE_LN_SENSOR) #include "lan_common.h" +#include "attm.h" #include "gapc.h" #include "gattc.h" #include "gattc_task.h" -#include "attm.h" #include "lans.h" #include "lans_task.h" #include "prf_utils.h" -#include "ke_mem.h" -#include "co_utils.h" #include "co_math.h" +#include "co_utils.h" +#include "ke_mem.h" /* * LOCAL FUNCTIONS DEFINITIONS @@ -44,34 +44,33 @@ */ __STATIC int lans_enable_req_handler(ke_msg_id_t const msgid, - struct lans_enable_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); - // Status - uint8_t status = PRF_ERR_REQ_DISALLOWED; + struct lans_enable_req *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + // Status + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if(ke_state_get(dest_id) == LANS_IDLE) - { - // Bonded data was not used before - if (!LANS_IS_PRESENT(lans_env->env[param->conidx].prfl_ntf_ind_cfg, LANS_PRF_CFG_PERFORMED_OK)) - { - status = GAP_ERR_NO_ERROR; - lans_env->env[param->conidx].prfl_ntf_ind_cfg = param->prfl_ntf_ind_cfg; - } - // Enable Bonded Data - LANS_ENABLE_NTF_IND(param->conidx, LANS_PRF_CFG_PERFORMED_OK); + if (ke_state_get(dest_id) == LANS_IDLE) { + // Bonded data was not used before + if (!LANS_IS_PRESENT(lans_env->env[param->conidx].prfl_ntf_ind_cfg, + LANS_PRF_CFG_PERFORMED_OK)) { + status = GAP_ERR_NO_ERROR; + lans_env->env[param->conidx].prfl_ntf_ind_cfg = param->prfl_ntf_ind_cfg; } + // Enable Bonded Data + LANS_ENABLE_NTF_IND(param->conidx, LANS_PRF_CFG_PERFORMED_OK); + } - // send completed information to APP task that contains error status - struct lans_enable_rsp *cmp_evt = KE_MSG_ALLOC(LANS_ENABLE_RSP, src_id, dest_id, lans_enable_rsp); - cmp_evt->status = status; - cmp_evt->conidx = param->conidx; - ke_msg_send(cmp_evt); + // send completed information to APP task that contains error status + struct lans_enable_rsp *cmp_evt = + KE_MSG_ALLOC(LANS_ENABLE_RSP, src_id, dest_id, lans_enable_rsp); + cmp_evt->status = status; + cmp_evt->conidx = param->conidx; + ke_msg_send(cmp_evt); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -86,115 +85,107 @@ __STATIC int lans_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_read_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if(ke_state_get(dest_id) == LANS_IDLE) - { - // Pointer to the response message - struct gattc_read_cfm* cfm = NULL; + struct gattc_read_req_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + if (ke_state_get(dest_id) == LANS_IDLE) { + // Pointer to the response message + struct gattc_read_cfm *cfm = NULL; - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); - uint8_t conidx = KE_IDX_GET(src_id); - uint8_t att_idx = LANS_IDX(param->handle); + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + uint8_t conidx = KE_IDX_GET(src_id); + uint8_t att_idx = LANS_IDX(param->handle); - uint8_t status = ATT_ERR_NO_ERROR; + uint8_t status = ATT_ERR_NO_ERROR; - switch(att_idx) - { - case LNS_IDX_LN_FEAT_VAL: - { - // Allocate structure - cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(uint32_t)); - cfm->length = sizeof(uint32_t); - // Fill data - co_write32p(cfm->value, lans_env->features); - } break; + switch (att_idx) { + case LNS_IDX_LN_FEAT_VAL: { + // Allocate structure + cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, + sizeof(uint32_t)); + cfm->length = sizeof(uint32_t); + // Fill data + co_write32p(cfm->value, lans_env->features); + } break; - case LNS_IDX_POS_Q_VAL: - { - // Check if Position Quality Char. has been added in the database - if (LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_POS_Q_MASK)) - { - // Allocate structure - cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(struct lanp_posq)); - // Fill data - cfm->length = lans_pack_posq(cfm->value); - } - else - { - status = PRF_ERR_FEATURE_NOT_SUPPORTED; - } + case LNS_IDX_POS_Q_VAL: { + // Check if Position Quality Char. has been added in the database + if (LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_POS_Q_MASK)) { + // Allocate structure + cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, + sizeof(struct lanp_posq)); + // Fill data + cfm->length = lans_pack_posq(cfm->value); + } else { + status = PRF_ERR_FEATURE_NOT_SUPPORTED; + } - } break; + } break; - case LNS_IDX_LOC_SPEED_NTF_CFG: - { - // allocate structure - cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(uint16_t)); - cfm->length = sizeof(uint16_t); - // Fill data - co_write16p(cfm->value, (lans_env->env[conidx].prfl_ntf_ind_cfg & LANS_PRF_CFG_FLAG_LOC_SPEED_NTF) - ? PRF_CLI_START_NTF : PRF_CLI_STOP_NTFIND); - } break; + case LNS_IDX_LOC_SPEED_NTF_CFG: { + // allocate structure + cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, + sizeof(uint16_t)); + cfm->length = sizeof(uint16_t); + // Fill data + co_write16p(cfm->value, (lans_env->env[conidx].prfl_ntf_ind_cfg & + LANS_PRF_CFG_FLAG_LOC_SPEED_NTF) + ? PRF_CLI_START_NTF + : PRF_CLI_STOP_NTFIND); + } break; - case LNS_IDX_NAVIGATION_NTF_CFG: - { - // Check if Navigation Char. has been added in the database - if (LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_NAVI_MASK)) - { - // allocate structure - cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(uint16_t)); - cfm->length = sizeof(uint16_t); - co_write16p(cfm->value, (lans_env->env[conidx].prfl_ntf_ind_cfg & LANS_PRF_CFG_FLAG_NAVIGATION_NTF) - ? PRF_CLI_START_NTF : PRF_CLI_STOP_NTFIND); - } - else - { - status = PRF_ERR_FEATURE_NOT_SUPPORTED; - } - } break; + case LNS_IDX_NAVIGATION_NTF_CFG: { + // Check if Navigation Char. has been added in the database + if (LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_NAVI_MASK)) { + // allocate structure + cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, + sizeof(uint16_t)); + cfm->length = sizeof(uint16_t); + co_write16p(cfm->value, (lans_env->env[conidx].prfl_ntf_ind_cfg & + LANS_PRF_CFG_FLAG_NAVIGATION_NTF) + ? PRF_CLI_START_NTF + : PRF_CLI_STOP_NTFIND); + } else { + status = PRF_ERR_FEATURE_NOT_SUPPORTED; + } + } break; - case LNS_IDX_LN_CTNL_PT_IND_CFG: - { - // Check if LN control point has been added in the database - if (LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_LN_CTNL_PT_MASK)) - { - // allocate structure - cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(uint16_t)); - cfm->length = sizeof(uint16_t); - // Fill data - co_write16p(cfm->value, (lans_env->env[conidx].prfl_ntf_ind_cfg & LANS_PRF_CFG_FLAG_LN_CTNL_PT_IND) - ? PRF_CLI_START_IND : PRF_CLI_STOP_NTFIND); - } - else - { - status = PRF_ERR_FEATURE_NOT_SUPPORTED; - } - } break; + case LNS_IDX_LN_CTNL_PT_IND_CFG: { + // Check if LN control point has been added in the database + if (LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_LN_CTNL_PT_MASK)) { + // allocate structure + cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, + sizeof(uint16_t)); + cfm->length = sizeof(uint16_t); + // Fill data + co_write16p(cfm->value, (lans_env->env[conidx].prfl_ntf_ind_cfg & + LANS_PRF_CFG_FLAG_LN_CTNL_PT_IND) + ? PRF_CLI_START_IND + : PRF_CLI_STOP_NTFIND); + } else { + status = PRF_ERR_FEATURE_NOT_SUPPORTED; + } + } break; - default: - { - status = ATT_ERR_REQUEST_NOT_SUPPORTED; - } break; - } - - if (status != ATT_ERR_NO_ERROR) - { - cfm = KE_MSG_ALLOC(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm); - cfm->length = 0; - } - - cfm->handle = param->handle; - cfm->status = status; - - // Send value to peer device. - ke_msg_send(cfm); + default: { + status = ATT_ERR_REQUEST_NOT_SUPPORTED; + } break; } - return (KE_MSG_CONSUMED); + if (status != ATT_ERR_NO_ERROR) { + cfm = KE_MSG_ALLOC(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm); + cfm->length = 0; + } + + cfm->handle = param->handle; + cfm->status = status; + + // Send value to peer device. + ke_msg_send(cfm); + } + + return (KE_MSG_CONSUMED); } /** @@ -208,47 +199,40 @@ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_att_info_req_ind *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if(ke_state_get(dest_id) == LANS_IDLE) - { - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); - uint8_t att_idx = LANS_IDX(param->handle); - struct gattc_att_info_cfm * cfm; +__STATIC int gattc_att_info_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_att_info_req_ind *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + if (ke_state_get(dest_id) == LANS_IDLE) { + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + uint8_t att_idx = LANS_IDX(param->handle); + struct gattc_att_info_cfm *cfm; - //Send write response - cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); - cfm->handle = param->handle; + // Send write response + cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); + cfm->handle = param->handle; - // check if it's a client configuration char - if((att_idx == LNS_IDX_LOC_SPEED_NTF_CFG) - || (att_idx == LNS_IDX_NAVIGATION_NTF_CFG) - || (att_idx == LNS_IDX_LN_CTNL_PT_IND_CFG)) - { - // CCC attribute length = 2 - cfm->length = 2; - cfm->status = GAP_ERR_NO_ERROR; - } - else if (att_idx == LNS_IDX_LN_CTNL_PT_VAL) - { - // force length to zero to reject any write starting from something != 0 - cfm->length = 0; - cfm->status = GAP_ERR_NO_ERROR; - } - // not expected request - else - { - cfm->length = 0; - cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; - } - ke_msg_send(cfm); - } + // check if it's a client configuration char + if ((att_idx == LNS_IDX_LOC_SPEED_NTF_CFG) || + (att_idx == LNS_IDX_NAVIGATION_NTF_CFG) || + (att_idx == LNS_IDX_LN_CTNL_PT_IND_CFG)) { + // CCC attribute length = 2 + cfm->length = 2; + cfm->status = GAP_ERR_NO_ERROR; + } else if (att_idx == LNS_IDX_LN_CTNL_PT_VAL) { + // force length to zero to reject any write starting from something != 0 + cfm->length = 0; + cfm->status = GAP_ERR_NO_ERROR; + } + // not expected request + else { + cfm->length = 0; + cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; + } + ke_msg_send(cfm); + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -261,41 +245,37 @@ __STATIC int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int lans_ntf_loc_speed_req_handler(ke_msg_id_t const msgid, - struct lans_ntf_loc_speed_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Message status - uint8_t msg_status = KE_MSG_NO_FREE; +__STATIC int lans_ntf_loc_speed_req_handler( + ke_msg_id_t const msgid, struct lans_ntf_loc_speed_req *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Message status + uint8_t msg_status = KE_MSG_NO_FREE; - // State shall be Connected or Busy - if (ke_state_get(dest_id) == LANS_IDLE) - { - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + // State shall be Connected or Busy + if (ke_state_get(dest_id) == LANS_IDLE) { + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); - // Configure the environment - lans_env->operation = LANS_NTF_LOC_SPEED_OP_CODE; - // allocate operation data - lans_env->op_data = (struct lans_op*) ke_malloc(sizeof(struct lans_op), KE_MEM_KE_MSG); - lans_env->op_data->cmd = ke_param2msg(param); - lans_env->op_data->cursor = 0; - lans_env->op_data->ntf_pending = NULL; + // Configure the environment + lans_env->operation = LANS_NTF_LOC_SPEED_OP_CODE; + // allocate operation data + lans_env->op_data = + (struct lans_op *)ke_malloc(sizeof(struct lans_op), KE_MEM_KE_MSG); + lans_env->op_data->cmd = ke_param2msg(param); + lans_env->op_data->cursor = 0; + lans_env->op_data->ntf_pending = NULL; - // Go to busy state - ke_state_set(dest_id, LANS_BUSY); + // Go to busy state + ke_state_set(dest_id, LANS_BUSY); - // start operation execution - lans_exe_operation(); - } - else - { - // Save it for later - msg_status = KE_MSG_SAVED; - } + // start operation execution + lans_exe_operation(); + } else { + // Save it for later + msg_status = KE_MSG_SAVED; + } - return (int)msg_status; + return (int)msg_status; } /** @@ -309,38 +289,33 @@ __STATIC int lans_ntf_loc_speed_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int lans_upd_pos_q_req_handler(ke_msg_id_t const msgid, - struct lans_upd_pos_q_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); - // Allocate response message - struct lans_upd_pos_q_rsp *rsp = KE_MSG_ALLOC(LANS_UPD_POS_Q_RSP, - src_id, dest_id, lans_upd_pos_q_rsp); - rsp->status = PRF_ERR_FEATURE_NOT_SUPPORTED; + struct lans_upd_pos_q_req *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + // Allocate response message + struct lans_upd_pos_q_rsp *rsp = + KE_MSG_ALLOC(LANS_UPD_POS_Q_RSP, src_id, dest_id, lans_upd_pos_q_rsp); + rsp->status = PRF_ERR_FEATURE_NOT_SUPPORTED; - // Check if Position Quality Char. has been added in the database - if (LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_POS_Q_MASK)) - { - if (lans_env->posq != NULL) - { - // Update position quality - lans_upd_posq(param->parameters); - // Set status value - rsp->status = GAP_ERR_NO_ERROR; - } - else - { - // Set status value - rsp->status = PRF_APP_ERROR; - } + // Check if Position Quality Char. has been added in the database + if (LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_POS_Q_MASK)) { + if (lans_env->posq != NULL) { + // Update position quality + lans_upd_posq(param->parameters); + // Set status value + rsp->status = GAP_ERR_NO_ERROR; + } else { + // Set status value + rsp->status = PRF_APP_ERROR; } + } - // Send response to the application - ke_msg_send(rsp); + // Send response to the application + ke_msg_send(rsp); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -353,42 +328,37 @@ __STATIC int lans_upd_pos_q_req_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int lans_ntf_navigation_req_handler(ke_msg_id_t const msgid, - struct lans_ntf_navigation_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Message status - uint8_t msg_status = KE_MSG_NO_FREE; +__STATIC int lans_ntf_navigation_req_handler( + ke_msg_id_t const msgid, struct lans_ntf_navigation_req *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Message status + uint8_t msg_status = KE_MSG_NO_FREE; - // State shall be Connected or Busy - if (ke_state_get(dest_id) == LANS_IDLE) - { - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + // State shall be Connected or Busy + if (ke_state_get(dest_id) == LANS_IDLE) { + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + // Configure the environment + lans_env->operation = LANS_NTF_NAVIGATION_OP_CODE; + // allocate operation data + lans_env->op_data = + (struct lans_op *)ke_malloc(sizeof(struct lans_op), KE_MEM_KE_MSG); + lans_env->op_data->cmd = ke_param2msg(param); + lans_env->op_data->cursor = 0; + lans_env->op_data->ntf_pending = NULL; - // Configure the environment - lans_env->operation = LANS_NTF_NAVIGATION_OP_CODE; - // allocate operation data - lans_env->op_data = (struct lans_op*) ke_malloc(sizeof(struct lans_op), KE_MEM_KE_MSG); - lans_env->op_data->cmd = ke_param2msg(param); - lans_env->op_data->cursor = 0; - lans_env->op_data->ntf_pending = NULL; + // Go to busy state + ke_state_set(dest_id, LANS_BUSY); - // Go to busy state - ke_state_set(dest_id, LANS_BUSY); + // start operation execution + lans_exe_operation(); + } else { + // Save it for later + msg_status = KE_MSG_SAVED; + } - // start operation execution - lans_exe_operation(); - } - else - { - // Save it for later - msg_status = KE_MSG_SAVED; - } - - return (int)msg_status; + return (int)msg_status; } /** @@ -402,70 +372,65 @@ __STATIC int lans_ntf_navigation_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int lans_ln_ctnl_pt_cfm_handler(ke_msg_id_t const msgid, - struct lans_ln_ctnl_pt_cfm *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); - uint8_t status = GAP_ERR_NO_ERROR; + struct lans_ln_ctnl_pt_cfm *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + uint8_t status = GAP_ERR_NO_ERROR; - if (ke_state_get(dest_id) == LANS_BUSY) - { - do - { - // Check the current operation - if (lans_env->operation < LANS_SET_CUMUL_VALUE_OP_CODE) - { - // The confirmation has been sent without request indication, ignore - break; - } + if (ke_state_get(dest_id) == LANS_BUSY) { + do { + // Check the current operation + if (lans_env->operation < LANS_SET_CUMUL_VALUE_OP_CODE) { + // The confirmation has been sent without request indication, ignore + break; + } - // The LN Control Point Characteristic must be supported if we are here - if (!LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_LN_CTNL_PT_MASK)) - { - status = PRF_ERR_REQ_DISALLOWED; - break; - } + // The LN Control Point Characteristic must be supported if we are here + if (!LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, + LANS_LN_CTNL_PT_MASK)) { + status = PRF_ERR_REQ_DISALLOWED; + break; + } - // Check if sending of indications has been enabled - if (!LANS_IS_NTF_IND_ENABLED(param->conidx, LANS_PRF_CFG_FLAG_LN_CTNL_PT_IND)) - { - // CCC improperly configured - status = PRF_CCCD_IMPR_CONFIGURED; - break; - } + // Check if sending of indications has been enabled + if (!LANS_IS_NTF_IND_ENABLED(param->conidx, + LANS_PRF_CFG_FLAG_LN_CTNL_PT_IND)) { + // CCC improperly configured + status = PRF_CCCD_IMPR_CONFIGURED; + break; + } - // Allocate the GATT notification message - struct gattc_send_evt_cmd *ctl_pt_rsp = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, param->conidx), dest_id, - gattc_send_evt_cmd, LANP_LAN_LN_CNTL_PT_RSP_MAX_LEN); + // Allocate the GATT notification message + struct gattc_send_evt_cmd *ctl_pt_rsp = KE_MSG_ALLOC_DYN( + GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, param->conidx), dest_id, + gattc_send_evt_cmd, LANP_LAN_LN_CNTL_PT_RSP_MAX_LEN); - // Fill in the parameter structure - ctl_pt_rsp->operation = GATTC_INDICATE; - ctl_pt_rsp->handle = LANS_HANDLE(LNS_IDX_LN_CTNL_PT_VAL); - // Pack Control Point confirmation - ctl_pt_rsp->length = lans_pack_ln_ctnl_point_cfm (param->conidx, param, ctl_pt_rsp->value); + // Fill in the parameter structure + ctl_pt_rsp->operation = GATTC_INDICATE; + ctl_pt_rsp->handle = LANS_HANDLE(LNS_IDX_LN_CTNL_PT_VAL); + // Pack Control Point confirmation + ctl_pt_rsp->length = + lans_pack_ln_ctnl_point_cfm(param->conidx, param, ctl_pt_rsp->value); - // Send the event - ke_msg_send(ctl_pt_rsp); + // Send the event + ke_msg_send(ctl_pt_rsp); - } while (0); + } while (0); - if (status != GAP_ERR_NO_ERROR) - { - // Inform the application that a procedure has been completed - lans_send_cmp_evt(param->conidx, - prf_src_task_get(&lans_env->prf_env, param->conidx), - prf_dst_task_get(&lans_env->prf_env, param->conidx), - lans_env->operation, status); - } + if (status != GAP_ERR_NO_ERROR) { + // Inform the application that a procedure has been completed + lans_send_cmp_evt(param->conidx, + prf_src_task_get(&lans_env->prf_env, param->conidx), + prf_dst_task_get(&lans_env->prf_env, param->conidx), + lans_env->operation, status); } + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } - /** **************************************************************************************** * @brief Handles reception of the @ref GATTC_WRITE_REQ_IND message. @@ -476,120 +441,105 @@ __STATIC int lans_ln_ctnl_pt_cfm_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_write_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); - uint8_t conidx = KE_IDX_GET(src_id); - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; - // Status - uint8_t status = GAP_ERR_NO_ERROR; - // Control Point Status - uint8_t ctl_pt_status = LANP_LN_CTNL_PT_RESP_SUCCESS; +__STATIC int gattc_write_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + uint8_t conidx = KE_IDX_GET(src_id); + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; + // Status + uint8_t status = GAP_ERR_NO_ERROR; + // Control Point Status + uint8_t ctl_pt_status = LANP_LN_CTNL_PT_RESP_SUCCESS; - if (lans_env != NULL) - { - // Location and speed Characteristic, Client Characteristic Configuration Descriptor - if (param->handle == (LANS_HANDLE(LNS_IDX_LOC_SPEED_NTF_CFG))) - { - // Update value - status = lans_update_characteristic_config(conidx, LANS_PRF_CFG_FLAG_LOC_SPEED_NTF, param); - } + if (lans_env != NULL) { + // Location and speed Characteristic, Client Characteristic Configuration + // Descriptor + if (param->handle == (LANS_HANDLE(LNS_IDX_LOC_SPEED_NTF_CFG))) { + // Update value + status = lans_update_characteristic_config( + conidx, LANS_PRF_CFG_FLAG_LOC_SPEED_NTF, param); + } - // Navigation Characteristic, Client Characteristic Configuration Descriptor - else if (param->handle == (LANS_HANDLE(LNS_IDX_NAVIGATION_NTF_CFG))) - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_NAVI_MASK)) - { - // Update value - status = lans_update_characteristic_config(conidx, LANS_PRF_CFG_FLAG_NAVIGATION_NTF, param); - } - else - { - status = ATT_ERR_ATTRIBUTE_NOT_FOUND; - } + // Navigation Characteristic, Client Characteristic Configuration Descriptor + else if (param->handle == (LANS_HANDLE(LNS_IDX_NAVIGATION_NTF_CFG))) { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_NAVI_MASK)) { + // Update value + status = lans_update_characteristic_config( + conidx, LANS_PRF_CFG_FLAG_NAVIGATION_NTF, param); + } else { + status = ATT_ERR_ATTRIBUTE_NOT_FOUND; + } + } + // LN Control Point Characteristic + else { + if (LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_LN_CTNL_PT_MASK)) { + // LN Control Point, Client Characteristic Configuration Descriptor + if (param->handle == (LANS_HANDLE(LNS_IDX_LN_CTNL_PT_IND_CFG))) { + // Update value + status = lans_update_characteristic_config( + conidx, LANS_PRF_CFG_FLAG_LN_CTNL_PT_IND, param); } // LN Control Point Characteristic - else - { - if (LANS_IS_FEATURE_SUPPORTED(lans_env->prfl_cfg, LANS_LN_CTNL_PT_MASK)) - { - // LN Control Point, Client Characteristic Configuration Descriptor - if (param->handle == (LANS_HANDLE(LNS_IDX_LN_CTNL_PT_IND_CFG))) - { - // Update value - status = lans_update_characteristic_config(conidx, LANS_PRF_CFG_FLAG_LN_CTNL_PT_IND, param); - } - // LN Control Point Characteristic - else if (param->handle == (LANS_HANDLE(LNS_IDX_LN_CTNL_PT_VAL))) - { - do - { - // Check if sending of indications has been enabled - if (!LANS_IS_NTF_IND_ENABLED(conidx, LANS_PRF_CFG_FLAG_LN_CTNL_PT_IND)) - { - // CCC improperly configured - status = PRF_CCCD_IMPR_CONFIGURED; - break; - } - - if (lans_env->operation >= LANS_SET_CUMUL_VALUE_OP_CODE) - { - // A procedure is already in progress - status = LAN_ERROR_PROC_IN_PROGRESS; - break; - } - - if (lans_env->operation == LANS_NTF_LOC_SPEED_OP_CODE) - { - // Keep the message until the end of the current procedure - msg_status = KE_MSG_SAVED; - break; - } - - // Unpack Control Point parameters - ctl_pt_status = lans_unpack_ln_ctnl_point_ind (conidx, param); - - } while (0); - } - else - { - ASSERT_ERR(0); - } + else if (param->handle == (LANS_HANDLE(LNS_IDX_LN_CTNL_PT_VAL))) { + do { + // Check if sending of indications has been enabled + if (!LANS_IS_NTF_IND_ENABLED(conidx, + LANS_PRF_CFG_FLAG_LN_CTNL_PT_IND)) { + // CCC improperly configured + status = PRF_CCCD_IMPR_CONFIGURED; + break; } - else - { - status = ATT_ERR_ATTRIBUTE_NOT_FOUND; + + if (lans_env->operation >= LANS_SET_CUMUL_VALUE_OP_CODE) { + // A procedure is already in progress + status = LAN_ERROR_PROC_IN_PROGRESS; + break; } + + if (lans_env->operation == LANS_NTF_LOC_SPEED_OP_CODE) { + // Keep the message until the end of the current procedure + msg_status = KE_MSG_SAVED; + break; + } + + // Unpack Control Point parameters + ctl_pt_status = lans_unpack_ln_ctnl_point_ind(conidx, param); + + } while (0); + } else { + ASSERT_ERR(0); } + } else { + status = ATT_ERR_ATTRIBUTE_NOT_FOUND; + } } + } - //Send write response - struct gattc_write_cfm *cfm = KE_MSG_ALLOC( - GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = status; - ke_msg_send(cfm); + // Send write response + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = status; + ke_msg_send(cfm); - // Check if control point failed - if ((param->handle == (LANS_HANDLE(LNS_IDX_LN_CTNL_PT_VAL))) && - (ctl_pt_status != LANP_LN_CTNL_PT_RESP_SUCCESS)) - { - // Send response to peer - lans_send_rsp_ind(conidx, param->value[0], ctl_pt_status); - } + // Check if control point failed + if ((param->handle == (LANS_HANDLE(LNS_IDX_LN_CTNL_PT_VAL))) && + (ctl_pt_status != LANP_LN_CTNL_PT_RESP_SUCCESS)) { + // Send response to peer + lans_send_rsp_ind(conidx, param->value[0], ctl_pt_status); + } - return (int)msg_status; + return (int)msg_status; } /** **************************************************************************************** - * @brief Handles @ref GATT_NOTIFY_CMP_EVT message meaning that a notification or an indication - * has been correctly sent to peer device (but not confirmed by peer device). + * @brief Handles @ref GATT_NOTIFY_CMP_EVT message meaning that a notification + *or an indication has been correctly sent to peer device (but not confirmed by + *peer device). * * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. @@ -598,41 +548,38 @@ __STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - uint8_t conidx = KE_IDX_GET(src_id); - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); - // Check if a connection exists - if (ke_state_get(dest_id) == LANS_BUSY) - { - switch (param->operation) - { - case (GATTC_NOTIFY): - { - lans_exe_operation(); - // else ignore the message - } break; +__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t conidx = KE_IDX_GET(src_id); + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); + // Check if a connection exists + if (ke_state_get(dest_id) == LANS_BUSY) { + switch (param->operation) { + case (GATTC_NOTIFY): { + lans_exe_operation(); + // else ignore the message + } break; - case (GATTC_INDICATE): - { - ASSERT_ERR(lans_env->operation >= LANS_SET_CUMUL_VALUE_OP_CODE); + case (GATTC_INDICATE): { + ASSERT_ERR(lans_env->operation >= LANS_SET_CUMUL_VALUE_OP_CODE); - // Inform the application that a procedure has been completed - lans_send_cmp_evt(conidx, prf_src_task_get(&(lans_env->prf_env), conidx), prf_dst_task_get(&(lans_env->prf_env), conidx), - lans_env->operation, param->status); - // else ignore the message - } break; + // Inform the application that a procedure has been completed + lans_send_cmp_evt(conidx, prf_src_task_get(&(lans_env->prf_env), conidx), + prf_dst_task_get(&(lans_env->prf_env), conidx), + lans_env->operation, param->status); + // else ignore the message + } break; - default: - { - ASSERT_ERR(0); - } break; - } + default: { + ASSERT_ERR(0); + } break; } + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /* @@ -641,28 +588,26 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_ev */ /// Specifies the default message handlers -KE_MSG_HANDLER_TAB(lans) -{ - {LANS_ENABLE_REQ, (ke_msg_func_t)lans_enable_req_handler}, - {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, - {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t) gattc_att_info_req_ind_handler}, - {LANS_NTF_LOC_SPEED_REQ, (ke_msg_func_t)lans_ntf_loc_speed_req_handler}, - {LANS_UPD_POS_Q_REQ, (ke_msg_func_t)lans_upd_pos_q_req_handler}, - {LANS_NTF_NAVIGATION_REQ, (ke_msg_func_t)lans_ntf_navigation_req_handler}, - {LANS_LN_CTNL_PT_CFM, (ke_msg_func_t)lans_ln_ctnl_pt_cfm_handler}, - {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, +KE_MSG_HANDLER_TAB(lans){ + {LANS_ENABLE_REQ, (ke_msg_func_t)lans_enable_req_handler}, + {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, + {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t)gattc_att_info_req_ind_handler}, + {LANS_NTF_LOC_SPEED_REQ, (ke_msg_func_t)lans_ntf_loc_speed_req_handler}, + {LANS_UPD_POS_Q_REQ, (ke_msg_func_t)lans_upd_pos_q_req_handler}, + {LANS_NTF_NAVIGATION_REQ, (ke_msg_func_t)lans_ntf_navigation_req_handler}, + {LANS_LN_CTNL_PT_CFM, (ke_msg_func_t)lans_ln_ctnl_pt_cfm_handler}, + {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void lans_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); +void lans_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct lans_env_tag *lans_env = PRF_ENV_GET(LANS, lans); - task_desc->msg_handler_tab = lans_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(lans_msg_handler_tab); - task_desc->state = lans_env->state; - task_desc->idx_max = LANS_IDX_MAX; + task_desc->msg_handler_tab = lans_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(lans_msg_handler_tab); + task_desc->state = lans_env->state; + task_desc->idx_max = LANS_IDX_MAX; } #endif //(BLE_LN_SENSOR) diff --git a/services/ble_profiles/ota/ota.c b/services/ble_profiles/ota/ota.c index 68a6e86..2db4926 100644 --- a/services/ble_profiles/ota/ota.c +++ b/services/ble_profiles/ota/ota.c @@ -14,8 +14,6 @@ * ****************************************************************************/ - - /* * INCLUDE FILES **************************************************************************************** @@ -23,16 +21,16 @@ #include "rwip_config.h" #if (BLE_OTA) -#include "gap.h" -#include "gattc_task.h" #include "attm.h" +#include "co_utils.h" +#include "gap.h" #include "gapc_task.h" +#include "gattc_task.h" +#include "ke_mem.h" #include "ota.h" +#include "ota_bes.h" #include "ota_task.h" #include "prf_utils.h" -#include "ke_mem.h" -#include "co_utils.h" -#include "ota_bes.h" #ifdef __GATT_OVER_BR_EDR__ #include "app_btgatt.h" #endif @@ -42,27 +40,28 @@ **************************************************************************************** */ -static const uint8_t OTA_SERVICE_UUID_128[ATT_UUID_128_LEN] = BES_OTA_UUID_128; +static const uint8_t OTA_SERVICE_UUID_128[ATT_UUID_128_LEN] = BES_OTA_UUID_128; #define RD_PERM PERM(RD, ENABLE) #define VAL_PERM PERM(WRITE_REQ, ENABLE) | PERM(NTF, ENABLE) #define NTF_CFG_PERM PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE) -/// Full OTA SERVER Database Description - Used to add attributes into the database -const struct attm_desc_128 ota_att_db[OTA_IDX_NB] = -{ +/// Full OTA SERVER Database Description - Used to add attributes into the +/// database +const struct attm_desc_128 ota_att_db[OTA_IDX_NB] = { // OTA Service Declaration - [OTA_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE_UUID, RD_PERM, 0, 0}, + [OTA_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE_UUID, RD_PERM, 0, 0}, // OTA Characteristic Declaration - [OTA_IDX_CHAR] = {ATT_DECL_CHARACTERISTIC_UUID, RD_PERM, 0, 0}, + [OTA_IDX_CHAR] = {ATT_DECL_CHARACTERISTIC_UUID, RD_PERM, 0, 0}, // OTA service - [OTA_IDX_VAL] = {ota_val_char_val_uuid_128_content, VAL_PERM, PERM(RI, ENABLE) | PERM_VAL(UUID_LEN, PERM_UUID_128), OTA_MAX_LEN}, + [OTA_IDX_VAL] = {ota_val_char_val_uuid_128_content, VAL_PERM, + PERM(RI, ENABLE) | PERM_VAL(UUID_LEN, PERM_UUID_128), + OTA_MAX_LEN}, // OTA Characteristic - [OTA_IDX_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG_UUID, NTF_CFG_PERM, 0, 0}, + [OTA_IDX_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG_UUID, NTF_CFG_PERM, 0, 0}, }; - /** **************************************************************************************** * @brief Initialization of the OTA module. @@ -75,76 +74,80 @@ const struct attm_desc_128 ota_att_db[OTA_IDX_NB] = * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t ota_init(struct prf_task_env* env, uint16_t* start_hdl, - uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t status; - - //Add Service Into Database - status = attm_svc_create_db_128(start_hdl, OTA_SERVICE_UUID_128, NULL, - OTA_IDX_NB, NULL, env->task, &ota_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS))| PERM(SVC_MI, DISABLE) - | PERM_VAL(SVC_UUID_LEN, PERM_UUID_128)); +static uint8_t ota_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t status; + // Add Service Into Database + status = attm_svc_create_db_128( + start_hdl, OTA_SERVICE_UUID_128, NULL, OTA_IDX_NB, NULL, env->task, + &ota_att_db[0], + (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, DISABLE) | PERM_VAL(SVC_UUID_LEN, PERM_UUID_128)); - BLE_GATT_DBG("attm_svc_create_db_128 returns %d start handle is %d", status, *start_hdl); + BLE_GATT_DBG("attm_svc_create_db_128 returns %d start handle is %d", status, + *start_hdl); #ifdef __GATT_OVER_BR_EDR__ - app_btgatt_addsdp(ATT_SERVICE_UUID, *start_hdl, *start_hdl+OTA_IDX_NB-1); + app_btgatt_addsdp(ATT_SERVICE_UUID, *start_hdl, *start_hdl + OTA_IDX_NB - 1); #endif - //-------------------- allocate memory required for the profile --------------------- - if (status == ATT_ERR_NO_ERROR) - { - // Allocate OTA required environment variable - struct ota_env_tag* ota_env = - (struct ota_env_tag* ) ke_malloc(sizeof(struct ota_env_tag), KE_MEM_ATT_DB); + //-------------------- allocate memory required for the profile + //--------------------- + if (status == ATT_ERR_NO_ERROR) { + // Allocate OTA required environment variable + struct ota_env_tag *ota_env = (struct ota_env_tag *)ke_malloc( + sizeof(struct ota_env_tag), KE_MEM_ATT_DB); - // Initialize OTA environment - env->env = (prf_env_t*) ota_env; - ota_env->shdl = *start_hdl; + // Initialize OTA environment + env->env = (prf_env_t *)ota_env; + ota_env->shdl = *start_hdl; - ota_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - // Mono Instantiated task - ota_env->prf_env.prf_task = env->task | - (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); + ota_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + // Mono Instantiated task + ota_env->prf_env.prf_task = + env->task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); - // initialize environment variable - env->id = TASK_ID_OTA; - ota_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_OTA; + ota_task_init(&(env->desc)); - /* Put HRS in Idle state */ - ke_state_set(env->task, OTA_IDLE); - } + /* Put HRS in Idle state */ + ke_state_set(env->task, OTA_IDLE); + } - return (status); + return (status); } /** **************************************************************************************** * @brief Destruction of the OTA module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void ota_destroy(struct prf_task_env* env) -{ - struct ota_env_tag* ota_env = (struct ota_env_tag*) env->env; +static void ota_destroy(struct prf_task_env *env) { + struct ota_env_tag *ota_env = (struct ota_env_tag *)env->env; - // free profile environment variables - env->env = NULL; - ke_free(ota_env); + // free profile environment variables + env->env = NULL; + ke_free(ota_env); } /** @@ -155,11 +158,10 @@ static void ota_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void ota_create(struct prf_task_env* env, uint8_t conidx) -{ - struct ota_env_tag* ota_env = (struct ota_env_tag*) env->env; - struct prf_svc ota_ota_svc = {ota_env->shdl, ota_env->shdl + OTA_IDX_NB}; - prf_register_atthdl2gatt(env->env, conidx, &ota_ota_svc); +static void ota_create(struct prf_task_env *env, uint8_t conidx) { + struct ota_env_tag *ota_env = (struct ota_env_tag *)env->env; + struct prf_svc ota_ota_svc = {ota_env->shdl, ota_env->shdl + OTA_IDX_NB}; + prf_register_atthdl2gatt(env->env, conidx, &ota_ota_svc); } /** @@ -171,9 +173,9 @@ static void ota_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void ota_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - /* Nothing to do */ +static void ota_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + /* Nothing to do */ } /* @@ -182,9 +184,8 @@ static void ota_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason */ /// OTA Task interface required by profile manager -const struct prf_task_cbs ota_itf = -{ - (prf_init_fnct) ota_init, +const struct prf_task_cbs ota_itf = { + (prf_init_fnct)ota_init, ota_destroy, ota_create, ota_cleanup, @@ -195,13 +196,8 @@ const struct prf_task_cbs ota_itf = **************************************************************************************** */ -const struct prf_task_cbs* ota_prf_itf_get(void) -{ - return &ota_itf; -} - +const struct prf_task_cbs *ota_prf_itf_get(void) { return &ota_itf; } #endif /* BLE_OTA */ /// @} OTA - diff --git a/services/ble_profiles/ota/ota_task.c b/services/ble_profiles/ota/ota_task.c index c4b2167..f3158ea 100644 --- a/services/ble_profiles/ota/ota_task.c +++ b/services/ble_profiles/ota/ota_task.c @@ -14,8 +14,6 @@ * ****************************************************************************/ - - /** **************************************************************************************** * @addtogroup OTATASK @@ -30,50 +28,48 @@ #include "rwip_config.h" #if (BLE_OTA) -#include "gap.h" -#include "gattc_task.h" -#include "gapc_task.h" #include "attm.h" +#include "gap.h" +#include "gapc_task.h" +#include "gattc_task.h" #include "ota.h" #include "ota_task.h" #include "prf_utils.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * LOCAL FUNCTIONS DEFINITIONS **************************************************************************************** */ static int gapc_disconnect_ind_handler(ke_msg_id_t const msgid, - struct gapc_disconnect_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t conidx = KE_IDX_GET(src_id); - struct ota_env_tag *ota_env = PRF_ENV_GET(OTA, ota); - ota_env->isNotificationEnabled[conidx] = false; - return KE_MSG_CONSUMED; + struct gapc_disconnect_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t conidx = KE_IDX_GET(src_id); + struct ota_env_tag *ota_env = PRF_ENV_GET(OTA, ota); + ota_env->isNotificationEnabled[conidx] = false; + return KE_MSG_CONSUMED; } -void app_ota_send_rx_cfm(uint8_t conidx) -{ - struct ota_env_tag *ota_env = PRF_ENV_GET(OTA, ota); +void app_ota_send_rx_cfm(uint8_t conidx) { + struct ota_env_tag *ota_env = PRF_ENV_GET(OTA, ota); - struct gattc_write_cfm *cfm = KE_MSG_ALLOC(GATTC_WRITE_CFM, - KE_BUILD_ID(TASK_GATTC, conidx), - prf_src_task_get(&ota_env->prf_env, conidx), - gattc_write_cfm); - cfm->handle = ota_env->shdl + OTA_IDX_VAL; - cfm->status = GAP_ERR_NO_ERROR; - ke_msg_send(cfm); + struct gattc_write_cfm *cfm = KE_MSG_ALLOC( + GATTC_WRITE_CFM, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&ota_env->prf_env, conidx), gattc_write_cfm); + cfm->handle = ota_env->shdl + OTA_IDX_VAL; + cfm->status = GAP_ERR_NO_ERROR; + ke_msg_send(cfm); } /** **************************************************************************************** * @brief Handles reception of the @ref GL2C_CODE_ATT_WR_CMD_IND message. - * The handler compares the new values with current ones and notifies them if they changed. + * The handler compares the new values with current ones and notifies them if + *they changed. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -81,22 +77,21 @@ void app_ota_send_rx_cfm(uint8_t conidx) * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_write_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct ota_env_tag *ota_env = PRF_ENV_GET(OTA, ota); - uint8_t conidx = KE_IDX_GET(src_id); +__STATIC int gattc_write_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Get the address of the environment + struct ota_env_tag *ota_env = PRF_ENV_GET(OTA, ota); + uint8_t conidx = KE_IDX_GET(src_id); - uint8_t status = GAP_ERR_NO_ERROR; + uint8_t status = GAP_ERR_NO_ERROR; - BLE_GATT_DBG("gattc_write_req_ind_handler ota_env 0x%x write handle %d shdl %d", - ota_env, param->handle, ota_env->shdl); + BLE_GATT_DBG( + "gattc_write_req_ind_handler ota_env 0x%x write handle %d shdl %d", + ota_env, param->handle, ota_env->shdl); -#if 0 //reply write-response so fast which results in rx queue oveflow - //Send write response +#if 0 // reply write-response so fast which results in rx queue oveflow + // Send write response struct gattc_write_cfm *cfm = KE_MSG_ALLOC( GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); cfm->handle = param->handle; @@ -104,74 +99,63 @@ __STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, ke_msg_send(cfm); #endif - if (ota_env != NULL) - { - if (param->handle == (ota_env->shdl + OTA_IDX_NTF_CFG)) - { - uint16_t value = 0x0000; - struct gattc_write_cfm *cfm = KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = status; - ke_msg_send(cfm); - - //Extract value before check - memcpy(&value, &(param->value), sizeof(uint16_t)); + if (ota_env != NULL) { + if (param->handle == (ota_env->shdl + OTA_IDX_NTF_CFG)) { + uint16_t value = 0x0000; + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = status; + ke_msg_send(cfm); - if (value == PRF_CLI_STOP_NTFIND) - { - ota_env->isNotificationEnabled[conidx] = false; - } - else if (value == PRF_CLI_START_NTF) - { - ota_env->isNotificationEnabled[conidx] = true; - } - else - { - status = PRF_APP_ERROR; - } + // Extract value before check + memcpy(&value, &(param->value), sizeof(uint16_t)); - if (status == GAP_ERR_NO_ERROR) - { - //Inform APP of TX ccc change - struct ble_ota_tx_notif_config_t * ind = KE_MSG_ALLOC(OTA_CCC_CHANGED, - prf_dst_task_get(&ota_env->prf_env, conidx), - prf_src_task_get(&ota_env->prf_env, conidx), - ble_ota_tx_notif_config_t); + if (value == PRF_CLI_STOP_NTFIND) { + ota_env->isNotificationEnabled[conidx] = false; + } else if (value == PRF_CLI_START_NTF) { + ota_env->isNotificationEnabled[conidx] = true; + } else { + status = PRF_APP_ERROR; + } - ind->isNotificationEnabled = ota_env->isNotificationEnabled[conidx]; + if (status == GAP_ERR_NO_ERROR) { + // Inform APP of TX ccc change + struct ble_ota_tx_notif_config_t *ind = KE_MSG_ALLOC( + OTA_CCC_CHANGED, prf_dst_task_get(&ota_env->prf_env, conidx), + prf_src_task_get(&ota_env->prf_env, conidx), + ble_ota_tx_notif_config_t); - ke_msg_send(ind); - } - } - else if (param->handle == (ota_env->shdl + OTA_IDX_VAL)) - { - TRACE(1,"[OTA] ble cmd %x",param->value[0]); - //inform APP of data - struct ble_ota_rx_data_ind_t * ind = KE_MSG_ALLOC_DYN(OTA_DATA_RECEIVED, - prf_dst_task_get(&ota_env->prf_env, conidx), - prf_src_task_get(&ota_env->prf_env, conidx), - ble_ota_rx_data_ind_t, - sizeof(struct ble_ota_rx_data_ind_t) + param->length); + ind->isNotificationEnabled = ota_env->isNotificationEnabled[conidx]; - ind->length = param->length; - memcpy((uint8_t *)(ind->data), &(param->value), param->length); + ke_msg_send(ind); + } + } else if (param->handle == (ota_env->shdl + OTA_IDX_VAL)) { + TRACE(1, "[OTA] ble cmd %x", param->value[0]); + // inform APP of data + struct ble_ota_rx_data_ind_t *ind = KE_MSG_ALLOC_DYN( + OTA_DATA_RECEIVED, prf_dst_task_get(&ota_env->prf_env, conidx), + prf_src_task_get(&ota_env->prf_env, conidx), ble_ota_rx_data_ind_t, + sizeof(struct ble_ota_rx_data_ind_t) + param->length); - ke_msg_send(ind); + ind->length = param->length; + memcpy((uint8_t *)(ind->data), &(param->value), param->length); - return KE_MSG_CONSUMED; - } - else - { - status = PRF_APP_ERROR; - } + ke_msg_send(ind); + + return KE_MSG_CONSUMED; + } else { + status = PRF_APP_ERROR; } - return (KE_MSG_CONSUMED); + } + return (KE_MSG_CONSUMED); } /** **************************************************************************************** - * @brief Handles @ref GATTC_CMP_EVT for GATTC_NOTIFY message meaning that Measurement - * notification has been correctly sent to peer device (but not confirmed by peer device). + * @brief Handles @ref GATTC_CMP_EVT for GATTC_NOTIFY message meaning that + *Measurement notification has been correctly sent to peer device (but not + *confirmed by peer device). * * * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. @@ -180,32 +164,31 @@ __STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - // Get the address of the environment - struct ota_env_tag *ota_env = PRF_ENV_GET(OTA, ota); +__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct ota_env_tag *ota_env = PRF_ENV_GET(OTA, ota); - uint8_t conidx = KE_IDX_GET(dest_id); - - // notification or write request has been sent out - if ((GATTC_NOTIFY == param->operation) || (GATTC_INDICATE == param->operation)) - { - - struct ble_ota_tx_sent_ind_t * ind = KE_MSG_ALLOC(OTA_TX_DATA_SENT, - prf_dst_task_get(&ota_env->prf_env, conidx), - prf_src_task_get(&ota_env->prf_env, conidx), - ble_ota_tx_sent_ind_t); + uint8_t conidx = KE_IDX_GET(dest_id); - ind->status = param->status; + // notification or write request has been sent out + if ((GATTC_NOTIFY == param->operation) || + (GATTC_INDICATE == param->operation)) { - ke_msg_send(ind); + struct ble_ota_tx_sent_ind_t *ind = KE_MSG_ALLOC( + OTA_TX_DATA_SENT, prf_dst_task_get(&ota_env->prf_env, conidx), + prf_src_task_get(&ota_env->prf_env, conidx), ble_ota_tx_sent_ind_t); - } + ind->status = param->status; - ke_state_set(dest_id, OTA_IDLE); - - return (KE_MSG_CONSUMED); + ke_msg_send(ind); + } + + ke_state_set(dest_id, OTA_IDLE); + + return (KE_MSG_CONSUMED); } /** @@ -220,133 +203,121 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_ev **************************************************************************************** */ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_read_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct ota_env_tag *ota_env = PRF_ENV_GET(OTA, ota); + struct gattc_read_req_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct ota_env_tag *ota_env = PRF_ENV_GET(OTA, ota); - struct gattc_read_cfm* cfm; + struct gattc_read_cfm *cfm; - uint8_t status = GAP_ERR_NO_ERROR; - uint8_t conidx = KE_IDX_GET(src_id); + uint8_t status = GAP_ERR_NO_ERROR; + uint8_t conidx = KE_IDX_GET(src_id); - BLE_GATT_DBG("gattc_read_req_ind_handler read handle %d shdl %d", param->handle, ota_env->shdl); + BLE_GATT_DBG("gattc_read_req_ind_handler read handle %d shdl %d", + param->handle, ota_env->shdl); - if (param->handle == (ota_env->shdl + OTA_IDX_NTF_CFG)) - { - uint16_t notify_ccc; - cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(notify_ccc)); - - if (ota_env->isNotificationEnabled[conidx]) - { - notify_ccc = 1; - } - else - { - notify_ccc = 0; - } - cfm->length = sizeof(notify_ccc); - memcpy(cfm->value, (uint8_t *)¬ify_ccc, cfm->length); - } - else - { - cfm = KE_MSG_ALLOC(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm); - cfm->length = 0; - status = ATT_ERR_REQUEST_NOT_SUPPORTED; - } + if (param->handle == (ota_env->shdl + OTA_IDX_NTF_CFG)) { + uint16_t notify_ccc; + cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, + sizeof(notify_ccc)); - cfm->handle = param->handle; + if (ota_env->isNotificationEnabled[conidx]) { + notify_ccc = 1; + } else { + notify_ccc = 0; + } + cfm->length = sizeof(notify_ccc); + memcpy(cfm->value, (uint8_t *)¬ify_ccc, cfm->length); + } else { + cfm = KE_MSG_ALLOC(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm); + cfm->length = 0; + status = ATT_ERR_REQUEST_NOT_SUPPORTED; + } - cfm->status = status; + cfm->handle = param->handle; - ke_msg_send(cfm); + cfm->status = status; - ke_state_set(dest_id, OTA_IDLE); + ke_msg_send(cfm); - return (KE_MSG_CONSUMED); + ke_state_set(dest_id, OTA_IDLE); + + return (KE_MSG_CONSUMED); } -static void send_notifiction(uint8_t conidx, const uint8_t* ptrData, uint32_t length) -{ - uint16_t handle_offset = 0xFFFF; - struct ota_env_tag *ota_env = PRF_ENV_GET(OTA, ota); +static void send_notifiction(uint8_t conidx, const uint8_t *ptrData, + uint32_t length) { + uint16_t handle_offset = 0xFFFF; + struct ota_env_tag *ota_env = PRF_ENV_GET(OTA, ota); - if (ota_env->isNotificationEnabled[conidx]) - { - handle_offset = OTA_IDX_VAL; - } + if (ota_env->isNotificationEnabled[conidx]) { + handle_offset = OTA_IDX_VAL; + } - TRACE(1,"Send ota notificationto handle offset %d:", handle_offset); - DUMP8("%02x ", ptrData, length); - + TRACE(1, "Send ota notificationto handle offset %d:", handle_offset); + DUMP8("%02x ", ptrData, length); - if (0xFFFF != handle_offset) - { - // Allocate the GATT notification message - struct gattc_send_evt_cmd *report_ntf = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(&ota_env->prf_env, conidx), - gattc_send_evt_cmd, length); + if (0xFFFF != handle_offset) { + // Allocate the GATT notification message + struct gattc_send_evt_cmd *report_ntf = + KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&ota_env->prf_env, conidx), + gattc_send_evt_cmd, length); - // Fill in the parameter structure - report_ntf->operation = GATTC_NOTIFY; - report_ntf->handle = ota_env->shdl + handle_offset; - // pack measured value in database - report_ntf->length = length; - memcpy(report_ntf->value, ptrData, length); - // send notification to peer device - ke_msg_send(report_ntf); - } + // Fill in the parameter structure + report_ntf->operation = GATTC_NOTIFY; + report_ntf->handle = ota_env->shdl + handle_offset; + // pack measured value in database + report_ntf->length = length; + memcpy(report_ntf->value, ptrData, length); + // send notification to peer device + ke_msg_send(report_ntf); + } } -static void send_indication(uint8_t conidx, const uint8_t* ptrData, uint32_t length) -{ - uint16_t handle_offset = 0xFFFF; - struct ota_env_tag *ota_env = PRF_ENV_GET(OTA, ota); +static void send_indication(uint8_t conidx, const uint8_t *ptrData, + uint32_t length) { + uint16_t handle_offset = 0xFFFF; + struct ota_env_tag *ota_env = PRF_ENV_GET(OTA, ota); - if (ota_env->isNotificationEnabled[conidx]) - { - handle_offset = OTA_IDX_VAL; - } + if (ota_env->isNotificationEnabled[conidx]) { + handle_offset = OTA_IDX_VAL; + } - if (0xFFFF != handle_offset) - { - // Allocate the GATT notification message - struct gattc_send_evt_cmd *report_ntf = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(&ota_env->prf_env, conidx), - gattc_send_evt_cmd, length); + if (0xFFFF != handle_offset) { + // Allocate the GATT notification message + struct gattc_send_evt_cmd *report_ntf = + KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&ota_env->prf_env, conidx), + gattc_send_evt_cmd, length); - // Fill in the parameter structure - report_ntf->operation = GATTC_INDICATE; - report_ntf->handle = ota_env->shdl + handle_offset; - // pack measured value in database - report_ntf->length = length; - memcpy(report_ntf->value, ptrData, length); - // send notification to peer device - ke_msg_send(report_ntf); - } + // Fill in the parameter structure + report_ntf->operation = GATTC_INDICATE; + report_ntf->handle = ota_env->shdl + handle_offset; + // pack measured value in database + report_ntf->length = length; + memcpy(report_ntf->value, ptrData, length); + // send notification to peer device + ke_msg_send(report_ntf); + } } -__STATIC int send_notification_handler(ke_msg_id_t const msgid, - struct ble_ota_send_data_req_t const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - send_notifiction(param->connecionIndex, param->value, param->length); - return (KE_MSG_CONSUMED); +__STATIC int send_notification_handler( + ke_msg_id_t const msgid, struct ble_ota_send_data_req_t const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + send_notifiction(param->connecionIndex, param->value, param->length); + return (KE_MSG_CONSUMED); } -__STATIC int send_indication_handler(ke_msg_id_t const msgid, - struct ble_ota_send_data_req_t const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - send_indication(param->connecionIndex, param->value, param->length); - return (KE_MSG_CONSUMED); +__STATIC int +send_indication_handler(ke_msg_id_t const msgid, + struct ble_ota_send_data_req_t const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + send_indication(param->connecionIndex, param->value, param->length); + return (KE_MSG_CONSUMED); } - /** **************************************************************************************** * @brief Handles reception of the attribute info request message. @@ -359,69 +330,60 @@ __STATIC int send_indication_handler(ke_msg_id_t const msgid, **************************************************************************************** */ static int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_att_info_req_ind *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct gattc_att_info_cfm * cfm; + struct gattc_att_info_req_ind *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct gattc_att_info_cfm *cfm; - //Send write response - cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); - cfm->handle = param->handle; + // Send write response + cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); + cfm->handle = param->handle; - struct ota_env_tag *ota_env = PRF_ENV_GET(OTA, ota); + struct ota_env_tag *ota_env = PRF_ENV_GET(OTA, ota); - if (param->handle == (ota_env->shdl + OTA_IDX_NTF_CFG)) - { - // CCC attribute length = 2 - cfm->length = 2; - cfm->status = GAP_ERR_NO_ERROR; - } - else if (param->handle == (ota_env->shdl + OTA_IDX_VAL)) - { - // force length to zero to reject any write starting from something != 0 - cfm->length = 0; - cfm->status = GAP_ERR_NO_ERROR; - } - else - { - cfm->length = 0; - cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; - } + if (param->handle == (ota_env->shdl + OTA_IDX_NTF_CFG)) { + // CCC attribute length = 2 + cfm->length = 2; + cfm->status = GAP_ERR_NO_ERROR; + } else if (param->handle == (ota_env->shdl + OTA_IDX_VAL)) { + // force length to zero to reject any write starting from something != 0 + cfm->length = 0; + cfm->status = GAP_ERR_NO_ERROR; + } else { + cfm->length = 0; + cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; + } - ke_msg_send(cfm); + ke_msg_send(cfm); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } - /* * GLOBAL VARIABLE DEFINITIONS **************************************************************************************** */ /* Default State handlers definition. */ -KE_MSG_HANDLER_TAB(ota) -{ - {GAPC_DISCONNECT_IND, (ke_msg_func_t) gapc_disconnect_ind_handler}, - {GATTC_WRITE_REQ_IND, (ke_msg_func_t) gattc_write_req_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t) gattc_cmp_evt_handler}, - {GATTC_READ_REQ_IND, (ke_msg_func_t) gattc_read_req_ind_handler}, - {OTA_SEND_NOTIFICATION, (ke_msg_func_t) send_notification_handler}, - {OTA_SEND_INDICATION, (ke_msg_func_t) send_indication_handler}, - {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t) gattc_att_info_req_ind_handler }, +KE_MSG_HANDLER_TAB(ota){ + {GAPC_DISCONNECT_IND, (ke_msg_func_t)gapc_disconnect_ind_handler}, + {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, + {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, + {OTA_SEND_NOTIFICATION, (ke_msg_func_t)send_notification_handler}, + {OTA_SEND_INDICATION, (ke_msg_func_t)send_indication_handler}, + {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t)gattc_att_info_req_ind_handler}, }; -void ota_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct ota_env_tag *ota_env = PRF_ENV_GET(OTA, ota); +void ota_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct ota_env_tag *ota_env = PRF_ENV_GET(OTA, ota); - task_desc->msg_handler_tab = ota_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(ota_msg_handler_tab); - task_desc->state = &(ota_env->state); - task_desc->idx_max = BLE_CONNECTION_MAX; + task_desc->msg_handler_tab = ota_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(ota_msg_handler_tab); + task_desc->state = &(ota_env->state); + task_desc->idx_max = BLE_CONNECTION_MAX; } #endif /* #if (BLE_OTA) */ diff --git a/services/ble_profiles/pasp/paspc/src/paspc.c b/services/ble_profiles/pasp/paspc/src/paspc.c index ad7cf96..ae2890e 100644 --- a/services/ble_profiles/pasp/paspc/src/paspc.c +++ b/services/ble_profiles/pasp/paspc/src/paspc.c @@ -17,8 +17,8 @@ #include "paspc.h" #include "paspc_task.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * LOCAL FUNCTIONS DEFINITIONS @@ -37,41 +37,45 @@ * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t paspc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t idx; - //-------------------- allocate memory required for the profile --------------------- +static uint8_t paspc_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t idx; + //-------------------- allocate memory required for the profile + //--------------------- - struct paspc_env_tag* paspc_env = - (struct paspc_env_tag* ) ke_malloc(sizeof(struct paspc_env_tag), KE_MEM_ATT_DB); + struct paspc_env_tag *paspc_env = (struct paspc_env_tag *)ke_malloc( + sizeof(struct paspc_env_tag), KE_MEM_ATT_DB); - // allocate PASPC required environment variable - env->env = (prf_env_t*) paspc_env; + // allocate PASPC required environment variable + env->env = (prf_env_t *)paspc_env; - paspc_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - paspc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + paspc_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + paspc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_PASPC; - paspc_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_PASPC; + paspc_task_init(&(env->desc)); - for(idx = 0; idx < PASPC_IDX_MAX ; idx++) - { - paspc_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), PASPC_FREE); - } + for (idx = 0; idx < PASPC_IDX_MAX; idx++) { + paspc_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), PASPC_FREE); + } - return GAP_ERR_NO_ERROR; + return GAP_ERR_NO_ERROR; } /** @@ -83,44 +87,41 @@ static uint8_t paspc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_ * @param[in] reason Detach reason **************************************************************************************** */ -static void paspc_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct paspc_env_tag* paspc_env = (struct paspc_env_tag*) env->env; +static void paspc_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct paspc_env_tag *paspc_env = (struct paspc_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(paspc_env->env[conidx] != NULL) - { - ke_free(paspc_env->env[conidx]); - paspc_env->env[conidx] = NULL; - } + // clean-up environment variable allocated for task instance + if (paspc_env->env[conidx] != NULL) { + ke_free(paspc_env->env[conidx]); + paspc_env->env[conidx] = NULL; + } - /* Put PASP Client in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), PASPC_FREE); + /* Put PASP Client in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), PASPC_FREE); } /** **************************************************************************************** * @brief Destruction of the PASPC module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void paspc_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct paspc_env_tag* paspc_env = (struct paspc_env_tag*) env->env; +static void paspc_destroy(struct prf_task_env *env) { + uint8_t idx; + struct paspc_env_tag *paspc_env = (struct paspc_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < PASPC_IDX_MAX ; idx++) - { - paspc_cleanup(env, idx, 0); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < PASPC_IDX_MAX; idx++) { + paspc_cleanup(env, idx, 0); + } - // free profile environment variables - env->env = NULL; - ke_free(paspc_env); + // free profile environment variables + env->env = NULL; + ke_free(paspc_env); } /** @@ -131,19 +132,17 @@ static void paspc_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void paspc_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Put PASP Client in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), PASPC_IDLE); +static void paspc_create(struct prf_task_env *env, uint8_t conidx) { + /* Put PASP Client in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), PASPC_IDLE); } /// PASPC Task interface required by profile manager -const struct prf_task_cbs paspc_itf = -{ - paspc_init, - paspc_destroy, - paspc_create, - paspc_cleanup, +const struct prf_task_cbs paspc_itf = { + paspc_init, + paspc_destroy, + paspc_create, + paspc_cleanup, }; /* @@ -151,52 +150,45 @@ const struct prf_task_cbs paspc_itf = **************************************************************************************** */ -const struct prf_task_cbs* paspc_prf_itf_get(void) -{ - return &paspc_itf; -} +const struct prf_task_cbs *paspc_prf_itf_get(void) { return &paspc_itf; } -void paspc_enable_rsp_send(struct paspc_env_tag *paspc_env, uint8_t conidx, uint8_t status) -{ - // Send to APP the details of the discovered attributes on PASPS - struct paspc_enable_rsp * rsp = KE_MSG_ALLOC( - PASPC_ENABLE_RSP, - prf_dst_task_get(&(paspc_env->prf_env), conidx), - prf_src_task_get(&(paspc_env->prf_env), conidx), - paspc_enable_rsp); - rsp->status = status; +void paspc_enable_rsp_send(struct paspc_env_tag *paspc_env, uint8_t conidx, + uint8_t status) { + // Send to APP the details of the discovered attributes on PASPS + struct paspc_enable_rsp *rsp = KE_MSG_ALLOC( + PASPC_ENABLE_RSP, prf_dst_task_get(&(paspc_env->prf_env), conidx), + prf_src_task_get(&(paspc_env->prf_env), conidx), paspc_enable_rsp); + rsp->status = status; - if (status == GAP_ERR_NO_ERROR) - { - rsp->pass = paspc_env->env[conidx]->pass; - // Register PASPC task in gatt for indication/notifications - prf_register_atthdl2gatt(&(paspc_env->prf_env), conidx, &(paspc_env->env[conidx]->pass.svc)); - // Go to connected state - ke_state_set(prf_src_task_get(&(paspc_env->prf_env), conidx), PASPC_IDLE); - } + if (status == GAP_ERR_NO_ERROR) { + rsp->pass = paspc_env->env[conidx]->pass; + // Register PASPC task in gatt for indication/notifications + prf_register_atthdl2gatt(&(paspc_env->prf_env), conidx, + &(paspc_env->env[conidx]->pass.svc)); + // Go to connected state + ke_state_set(prf_src_task_get(&(paspc_env->prf_env), conidx), PASPC_IDLE); + } - ke_msg_send(rsp); + ke_msg_send(rsp); } void paspc_send_cmp_evt(struct paspc_env_tag *paspc_env, uint8_t conidx, - uint8_t operation, uint8_t status) -{ - // Go back to the CONNECTED state if the state is busy - if (ke_state_get(prf_src_task_get(&(paspc_env->prf_env), conidx)) == PASPC_BUSY) - { - ke_state_set(prf_src_task_get(&paspc_env->prf_env, conidx), PASPC_IDLE); - } + uint8_t operation, uint8_t status) { + // Go back to the CONNECTED state if the state is busy + if (ke_state_get(prf_src_task_get(&(paspc_env->prf_env), conidx)) == + PASPC_BUSY) { + ke_state_set(prf_src_task_get(&paspc_env->prf_env, conidx), PASPC_IDLE); + } - // Send the message - struct paspc_cmp_evt *evt = KE_MSG_ALLOC(PASPC_CMP_EVT, - prf_dst_task_get(&(paspc_env->prf_env), conidx), - prf_src_task_get(&(paspc_env->prf_env), conidx), - paspc_cmp_evt); + // Send the message + struct paspc_cmp_evt *evt = KE_MSG_ALLOC( + PASPC_CMP_EVT, prf_dst_task_get(&(paspc_env->prf_env), conidx), + prf_src_task_get(&(paspc_env->prf_env), conidx), paspc_cmp_evt); - evt->operation = operation; - evt->status = status; + evt->operation = operation; + evt->status = status; - ke_msg_send(evt); + ke_msg_send(evt); } #endif //(BLE_PAS_CLIENT) diff --git a/services/ble_profiles/pasp/paspc/src/paspc_task.c b/services/ble_profiles/pasp/paspc/src/paspc_task.c index 4e470d6..911884a 100644 --- a/services/ble_profiles/pasp/paspc/src/paspc_task.c +++ b/services/ble_profiles/pasp/paspc/src/paspc_task.c @@ -14,45 +14,41 @@ #if (BLE_PAS_CLIENT) #include "pasp_common.h" -#include "paspc_task.h" #include "paspc.h" +#include "paspc_task.h" -#include "gap.h" #include "attm.h" +#include "gap.h" #include "gattc_task.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * STRUCTURES **************************************************************************************** */ -/// State machine used to retrieve Phone Alert Status service characteristics information -const struct prf_char_def paspc_pass_char[PASPC_CHAR_MAX] = -{ +/// State machine used to retrieve Phone Alert Status service characteristics +/// information +const struct prf_char_def paspc_pass_char[PASPC_CHAR_MAX] = { /// Alert Status - [PASPC_CHAR_ALERT_STATUS] = {ATT_CHAR_ALERT_STATUS, - ATT_MANDATORY, - ATT_CHAR_PROP_RD | ATT_CHAR_PROP_NTF}, + [PASPC_CHAR_ALERT_STATUS] = {ATT_CHAR_ALERT_STATUS, ATT_MANDATORY, + ATT_CHAR_PROP_RD | ATT_CHAR_PROP_NTF}, /// Ringer Setting - [PASPC_CHAR_RINGER_SETTING] = {ATT_CHAR_RINGER_SETTING, - ATT_MANDATORY, - ATT_CHAR_PROP_RD | ATT_CHAR_PROP_NTF}, + [PASPC_CHAR_RINGER_SETTING] = {ATT_CHAR_RINGER_SETTING, ATT_MANDATORY, + ATT_CHAR_PROP_RD | ATT_CHAR_PROP_NTF}, /// Ringer Control Point - [PASPC_CHAR_RINGER_CTNL_PT] = {ATT_CHAR_RINGER_CNTL_POINT, - ATT_MANDATORY, - ATT_CHAR_PROP_WR_NO_RESP}, + [PASPC_CHAR_RINGER_CTNL_PT] = {ATT_CHAR_RINGER_CNTL_POINT, ATT_MANDATORY, + ATT_CHAR_PROP_WR_NO_RESP}, }; -/// State machine used to retrieve Phone Alert Status service characteristic descriptor information -const struct prf_char_desc_def paspc_pass_char_desc[PASPC_DESC_MAX] = -{ +/// State machine used to retrieve Phone Alert Status service characteristic +/// descriptor information +const struct prf_char_desc_def paspc_pass_char_desc[PASPC_DESC_MAX] = { /// Alert Status Client Characteristic Configuration - [PASPC_DESC_ALERT_STATUS_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, - ATT_MANDATORY, - PASPC_CHAR_ALERT_STATUS}, + [PASPC_DESC_ALERT_STATUS_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, + PASPC_CHAR_ALERT_STATUS}, /// Ringer Setting Client Characteristic Configuration [PASPC_DESC_RINGER_SETTING_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, @@ -75,75 +71,72 @@ const struct prf_char_desc_def paspc_pass_char_desc[PASPC_DESC_MAX] = **************************************************************************************** */ __STATIC int paspc_enable_req_handler(ke_msg_id_t const msgid, - struct paspc_enable_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; - // Phone Alert Status Profile Client Role Task Environment - struct paspc_env_tag *paspc_env = PRF_ENV_GET(PASPC, paspc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); + struct paspc_enable_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; + // Phone Alert Status Profile Client Role Task Environment + struct paspc_env_tag *paspc_env = PRF_ENV_GET(PASPC, paspc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t state = ke_state_get(dest_id); - if ((state == PASPC_IDLE) && (paspc_env->env[conidx] == NULL)) - { - // allocate environment variable for task instance - paspc_env->env[conidx] = (struct paspc_cnx_env*) ke_malloc(sizeof(struct paspc_cnx_env),KE_MEM_ATT_DB); - memset(paspc_env->env[conidx], 0, sizeof(struct paspc_cnx_env)); + if ((state == PASPC_IDLE) && (paspc_env->env[conidx] == NULL)) { + // allocate environment variable for task instance + paspc_env->env[conidx] = (struct paspc_cnx_env *)ke_malloc( + sizeof(struct paspc_cnx_env), KE_MEM_ATT_DB); + memset(paspc_env->env[conidx], 0, sizeof(struct paspc_cnx_env)); - paspc_env->env[conidx]->operation = PASPC_ENABLE_OP_CODE; + paspc_env->env[conidx]->operation = PASPC_ENABLE_OP_CODE; - // Start discovering - if (param->con_type == PRF_CON_DISCOVERY) - { - prf_disc_svc_send(&(paspc_env->prf_env), conidx, ATT_SVC_PHONE_ALERT_STATUS); + // Start discovering + if (param->con_type == PRF_CON_DISCOVERY) { + prf_disc_svc_send(&(paspc_env->prf_env), conidx, + ATT_SVC_PHONE_ALERT_STATUS); - // Go to DISCOVERING state - ke_state_set(dest_id, PASPC_DISCOVERING); + // Go to DISCOVERING state + ke_state_set(dest_id, PASPC_DISCOVERING); - // Configure the environment for a discovery procedure - paspc_env->env[conidx]->last_uuid_req = ATT_SVC_PHONE_ALERT_STATUS; - } - // Bond information is provided - else - { - // Keep the provided database content - memcpy(&paspc_env->env[conidx]->pass, ¶m->pass, sizeof(struct paspc_pass_content)); - - //send APP confirmation that can start normal connection to TH - paspc_enable_rsp_send(paspc_env, conidx, GAP_ERR_NO_ERROR); - - /* -------------------------------------------------------------------------------- - * After connection establishment, once the discovery procedure is successful, - * the client shall read the Alert Status - * -------------------------------------------------------------------------------- */ - // Configure the environment for a read procedure - paspc_env->env[conidx]->last_char_code = PASPC_RD_ALERT_STATUS; - - // Send the read request - prf_read_char_send(&(paspc_env->prf_env), - conidx, paspc_env->env[conidx]->pass.svc.shdl, - paspc_env->env[conidx]->pass.svc.ehdl, - paspc_env->env[conidx]->pass.chars[PASPC_CHAR_ALERT_STATUS].val_hdl); - - // Go to BUSY state - ke_state_set(dest_id, PASPC_BUSY); - } - } - else if (state != PASPC_FREE) - { - status = PRF_ERR_REQ_DISALLOWED; + // Configure the environment for a discovery procedure + paspc_env->env[conidx]->last_uuid_req = ATT_SVC_PHONE_ALERT_STATUS; } + // Bond information is provided + else { + // Keep the provided database content + memcpy(&paspc_env->env[conidx]->pass, ¶m->pass, + sizeof(struct paspc_pass_content)); - // send an error if request fails - if(status != GAP_ERR_NO_ERROR) - { - paspc_enable_rsp_send(paspc_env, conidx, status); - } + // send APP confirmation that can start normal connection to TH + paspc_enable_rsp_send(paspc_env, conidx, GAP_ERR_NO_ERROR); - return (KE_MSG_CONSUMED); + /* -------------------------------------------------------------------------------- + * After connection establishment, once the discovery procedure is + * successful, the client shall read the Alert Status + * -------------------------------------------------------------------------------- + */ + // Configure the environment for a read procedure + paspc_env->env[conidx]->last_char_code = PASPC_RD_ALERT_STATUS; + + // Send the read request + prf_read_char_send( + &(paspc_env->prf_env), conidx, paspc_env->env[conidx]->pass.svc.shdl, + paspc_env->env[conidx]->pass.svc.ehdl, + paspc_env->env[conidx]->pass.chars[PASPC_CHAR_ALERT_STATUS].val_hdl); + + // Go to BUSY state + ke_state_set(dest_id, PASPC_BUSY); + } + } else if (state != PASPC_FREE) { + status = PRF_ERR_REQ_DISALLOWED; + } + + // send an error if request fails + if (status != GAP_ERR_NO_ERROR) { + paspc_enable_rsp_send(paspc_env, conidx, status); + } + + return (KE_MSG_CONSUMED); } /** @@ -157,105 +150,96 @@ __STATIC int paspc_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int paspc_read_cmd_handler(ke_msg_id_t const msgid, - struct paspc_read_cmd const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct paspc_env_tag *paspc_idx_env = PRF_ENV_GET(PASPC, paspc); + struct paspc_read_cmd const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct paspc_env_tag *paspc_idx_env = PRF_ENV_GET(PASPC, paspc); - if (paspc_idx_env != NULL) - { - // Attribute Handle - uint16_t handle = ATT_INVALID_SEARCH_HANDLE; - // Status - uint8_t status = GAP_ERR_NO_ERROR; + if (paspc_idx_env != NULL) { + // Attribute Handle + uint16_t handle = ATT_INVALID_SEARCH_HANDLE; + // Status + uint8_t status = GAP_ERR_NO_ERROR; - // Check the provided connection handle - do - { - // Check the current state - if (ke_state_get(dest_id) == PASPC_BUSY) - { - // Keep the request for later, state is GAP_ERR_NO_ERROR - msg_status = KE_MSG_SAVED; - break; - } + // Check the provided connection handle + do { + // Check the current state + if (ke_state_get(dest_id) == PASPC_BUSY) { + // Keep the request for later, state is GAP_ERR_NO_ERROR + msg_status = KE_MSG_SAVED; + break; + } - switch (param->read_code) - { - // Read Alert Status Characteristic Value - case (PASPC_RD_ALERT_STATUS): - { - handle = paspc_idx_env->env[conidx]->pass.chars[PASPC_CHAR_ALERT_STATUS].val_hdl; - } break; + switch (param->read_code) { + // Read Alert Status Characteristic Value + case (PASPC_RD_ALERT_STATUS): { + handle = paspc_idx_env->env[conidx] + ->pass.chars[PASPC_CHAR_ALERT_STATUS] + .val_hdl; + } break; - // Read Ringer Setting Characteristic Value - case (PASPC_RD_RINGER_SETTING): - { - handle = paspc_idx_env->env[conidx]->pass.chars[PASPC_CHAR_RINGER_SETTING].val_hdl; - } break; + // Read Ringer Setting Characteristic Value + case (PASPC_RD_RINGER_SETTING): { + handle = paspc_idx_env->env[conidx] + ->pass.chars[PASPC_CHAR_RINGER_SETTING] + .val_hdl; + } break; - // Read Alert Status Characteristic Client Char. Cfg. Descriptor Value - case (PASPC_RD_WR_ALERT_STATUS_CFG): - { - handle = paspc_idx_env->env[conidx]->pass.descs[PASPC_DESC_ALERT_STATUS_CL_CFG].desc_hdl; - } break; + // Read Alert Status Characteristic Client Char. Cfg. Descriptor Value + case (PASPC_RD_WR_ALERT_STATUS_CFG): { + handle = paspc_idx_env->env[conidx] + ->pass.descs[PASPC_DESC_ALERT_STATUS_CL_CFG] + .desc_hdl; + } break; - // Read Ringer Setting Characteristic Client Char. Cfg. Descriptor Value - case (PASPC_RD_WR_RINGER_SETTING_CFG): - { - handle = paspc_idx_env->env[conidx]->pass.descs[PASPC_DESC_RINGER_SETTING_CL_CFG].desc_hdl; - } break; + // Read Ringer Setting Characteristic Client Char. Cfg. Descriptor Value + case (PASPC_RD_WR_RINGER_SETTING_CFG): { + handle = paspc_idx_env->env[conidx] + ->pass.descs[PASPC_DESC_RINGER_SETTING_CL_CFG] + .desc_hdl; + } break; - default: - { - // Handle is ATT_INVALID_SEARCH_HANDLE - status = PRF_ERR_INVALID_PARAM; - } break; - } + default: { + // Handle is ATT_INVALID_SEARCH_HANDLE + status = PRF_ERR_INVALID_PARAM; + } break; + } - if (status == GAP_ERR_NO_ERROR) - { - // Check if handle is viable - if (handle != ATT_INVALID_SEARCH_HANDLE) - { - // Configure the environment for a read operation - paspc_idx_env->env[conidx]->operation = PASPC_READ_OP_CODE; - paspc_idx_env->env[conidx]->last_char_code = param->read_code; + if (status == GAP_ERR_NO_ERROR) { + // Check if handle is viable + if (handle != ATT_INVALID_SEARCH_HANDLE) { + // Configure the environment for a read operation + paspc_idx_env->env[conidx]->operation = PASPC_READ_OP_CODE; + paspc_idx_env->env[conidx]->last_char_code = param->read_code; - // Send the read request - prf_read_char_send(&(paspc_idx_env->prf_env), conidx, - paspc_idx_env->env[conidx]->pass.svc.shdl, - paspc_idx_env->env[conidx]->pass.svc.ehdl, - handle); + // Send the read request + prf_read_char_send(&(paspc_idx_env->prf_env), conidx, + paspc_idx_env->env[conidx]->pass.svc.shdl, + paspc_idx_env->env[conidx]->pass.svc.ehdl, handle); - // Go to the Busy state - ke_state_set(dest_id, PASPC_BUSY); - } - else - { - status = PRF_ERR_INEXISTENT_HDL; - } - } - } while(0); - - if (status != GAP_ERR_NO_ERROR) - { - paspc_send_cmp_evt(paspc_idx_env, conidx, PASPC_READ_OP_CODE, status); + // Go to the Busy state + ke_state_set(dest_id, PASPC_BUSY); + } else { + status = PRF_ERR_INEXISTENT_HDL; } - } - else - { - // No connection exists - paspc_send_cmp_evt(paspc_idx_env, conidx, PASPC_READ_OP_CODE, PRF_ERR_REQ_DISALLOWED); - } + } + } while (0); - return (int)msg_status; + if (status != GAP_ERR_NO_ERROR) { + paspc_send_cmp_evt(paspc_idx_env, conidx, PASPC_READ_OP_CODE, status); + } + } else { + // No connection exists + paspc_send_cmp_evt(paspc_idx_env, conidx, PASPC_READ_OP_CODE, + PRF_ERR_REQ_DISALLOWED); + } + + return (int)msg_status; } /** @@ -269,126 +253,108 @@ __STATIC int paspc_read_cmd_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int paspc_write_cmd_handler(ke_msg_id_t const msgid, - struct paspc_write_cmd const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; + struct paspc_write_cmd const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; - // Get the address of the environment - struct paspc_env_tag *paspc_idx_env = PRF_ENV_GET(PASPC, paspc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct paspc_env_tag *paspc_idx_env = PRF_ENV_GET(PASPC, paspc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - if (paspc_idx_env != NULL) - { - do - { - // Check the current state - if (ke_state_get(dest_id) != PASPC_IDLE) - { - // Another procedure is pending, keep the command for later - msg_status = KE_MSG_SAVED; - break; - } + if (paspc_idx_env != NULL) { + do { + // Check the current state + if (ke_state_get(dest_id) != PASPC_IDLE) { + // Another procedure is pending, keep the command for later + msg_status = KE_MSG_SAVED; + break; + } - // Attribute handle - uint16_t handle = ATT_INVALID_SEARCH_HANDLE; - // Write type - uint8_t wr_type; - // Length - uint8_t length; + // Attribute handle + uint16_t handle = ATT_INVALID_SEARCH_HANDLE; + // Write type + uint8_t wr_type; + // Length + uint8_t length; - switch (param->write_code) - { - // Write Ringer Control Point Characteristic Value - case (PASPC_WR_RINGER_CTNL_PT): - { - if ((param->value.ringer_ctnl_pt >= PASP_SILENT_MODE) && - (param->value.ringer_ctnl_pt <= PASP_CANCEL_SILENT_MODE)) - { - handle = paspc_idx_env->env[conidx]->pass.chars[PASPC_CHAR_RINGER_CTNL_PT].val_hdl; - length = sizeof(uint8_t); - wr_type = GATTC_WRITE_NO_RESPONSE; - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } break; + switch (param->write_code) { + // Write Ringer Control Point Characteristic Value + case (PASPC_WR_RINGER_CTNL_PT): { + if ((param->value.ringer_ctnl_pt >= PASP_SILENT_MODE) && + (param->value.ringer_ctnl_pt <= PASP_CANCEL_SILENT_MODE)) { + handle = paspc_idx_env->env[conidx] + ->pass.chars[PASPC_CHAR_RINGER_CTNL_PT] + .val_hdl; + length = sizeof(uint8_t); + wr_type = GATTC_WRITE_NO_RESPONSE; + } else { + status = PRF_ERR_INVALID_PARAM; + } + } break; - // Write Alert Status Characteristic Client Char. Cfg. Descriptor Value - case (PASPC_RD_WR_ALERT_STATUS_CFG): - { - if (param->value.alert_status_ntf_cfg <= PRF_CLI_START_NTF) - { - handle = paspc_idx_env->env[conidx]->pass.descs[PASPC_DESC_ALERT_STATUS_CL_CFG].desc_hdl; - length = sizeof(uint16_t); - wr_type = GATTC_WRITE; - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } break; + // Write Alert Status Characteristic Client Char. Cfg. Descriptor Value + case (PASPC_RD_WR_ALERT_STATUS_CFG): { + if (param->value.alert_status_ntf_cfg <= PRF_CLI_START_NTF) { + handle = paspc_idx_env->env[conidx] + ->pass.descs[PASPC_DESC_ALERT_STATUS_CL_CFG] + .desc_hdl; + length = sizeof(uint16_t); + wr_type = GATTC_WRITE; + } else { + status = PRF_ERR_INVALID_PARAM; + } + } break; - // Write Ringer Setting Characteristic Client Char. Cfg. Descriptor Value - case (PASPC_RD_WR_RINGER_SETTING_CFG): - { - if (param->value.ringer_setting_ntf_cfg <= PRF_CLI_START_NTF) - { - handle = paspc_idx_env->env[conidx]->pass.descs[PASPC_DESC_RINGER_SETTING_CL_CFG].desc_hdl; - length = sizeof(uint16_t); - wr_type = GATTC_WRITE; - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } break; + // Write Ringer Setting Characteristic Client Char. Cfg. Descriptor Value + case (PASPC_RD_WR_RINGER_SETTING_CFG): { + if (param->value.ringer_setting_ntf_cfg <= PRF_CLI_START_NTF) { + handle = paspc_idx_env->env[conidx] + ->pass.descs[PASPC_DESC_RINGER_SETTING_CL_CFG] + .desc_hdl; + length = sizeof(uint16_t); + wr_type = GATTC_WRITE; + } else { + status = PRF_ERR_INVALID_PARAM; + } + } break; - default: - { - status = PRF_ERR_INVALID_PARAM; - } break; - } + default: { + status = PRF_ERR_INVALID_PARAM; + } break; + } - if (status == GAP_ERR_NO_ERROR) - { - // Check if handle is viable - if (handle != ATT_INVALID_SEARCH_HANDLE) - { - // Send the write request - prf_gatt_write(&(paspc_idx_env->prf_env), conidx, handle, (uint8_t *)¶m->value, length, wr_type); + if (status == GAP_ERR_NO_ERROR) { + // Check if handle is viable + if (handle != ATT_INVALID_SEARCH_HANDLE) { + // Send the write request + prf_gatt_write(&(paspc_idx_env->prf_env), conidx, handle, + (uint8_t *)¶m->value, length, wr_type); - // Configure the environment for a write operation - paspc_idx_env->env[conidx]->operation = PASPC_WRITE_OP_CODE; - paspc_idx_env->env[conidx]->last_char_code = param->write_code; + // Configure the environment for a write operation + paspc_idx_env->env[conidx]->operation = PASPC_WRITE_OP_CODE; + paspc_idx_env->env[conidx]->last_char_code = param->write_code; - // Go to the Busy state - ke_state_set(dest_id, PASPC_BUSY); - } - else - { - status = PRF_ERR_INEXISTENT_HDL; - } - } - } while (0); - } - else - { - status = PRF_ERR_REQ_DISALLOWED; - } + // Go to the Busy state + ke_state_set(dest_id, PASPC_BUSY); + } else { + status = PRF_ERR_INEXISTENT_HDL; + } + } + } while (0); + } else { + status = PRF_ERR_REQ_DISALLOWED; + } - if (status != GAP_ERR_NO_ERROR) - { - paspc_send_cmp_evt(paspc_idx_env, conidx, PASPC_WRITE_OP_CODE, status); - } + if (status != GAP_ERR_NO_ERROR) { + paspc_send_cmp_evt(paspc_idx_env, conidx, PASPC_WRITE_OP_CODE, status); + } - return (int)msg_status; + return (int)msg_status; } /** @@ -403,36 +369,35 @@ __STATIC int paspc_write_cmd_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, - struct gattc_sdp_svc_ind const *ind, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_sdp_svc_ind const *ind, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == PASPC_DISCOVERING) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == PASPC_DISCOVERING) { + uint8_t conidx = KE_IDX_GET(dest_id); - struct paspc_env_tag *paspc_env = PRF_ENV_GET(PASPC, paspc); + struct paspc_env_tag *paspc_env = PRF_ENV_GET(PASPC, paspc); - ASSERT_INFO(paspc_env != NULL, dest_id, src_id); - ASSERT_INFO(paspc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(paspc_env != NULL, dest_id, src_id); + ASSERT_INFO(paspc_env->env[conidx] != NULL, dest_id, src_id); - if(paspc_env->env[conidx]->nb_svc == 0) - { - // Retrieve PASS characteristics and descriptors - prf_extract_svc_info(ind, PASPC_CHAR_MAX, &paspc_pass_char[0], &paspc_env->env[conidx]->pass.chars[0], - PASPC_DESC_MAX, &paspc_pass_char_desc[0], &paspc_env->env[conidx]->pass.descs[0]); + if (paspc_env->env[conidx]->nb_svc == 0) { + // Retrieve PASS characteristics and descriptors + prf_extract_svc_info(ind, PASPC_CHAR_MAX, &paspc_pass_char[0], + &paspc_env->env[conidx]->pass.chars[0], + PASPC_DESC_MAX, &paspc_pass_char_desc[0], + &paspc_env->env[conidx]->pass.descs[0]); - //Even if we get multiple responses we only store 1 range - paspc_env->env[conidx]->pass.svc.shdl = ind->start_hdl; - paspc_env->env[conidx]->pass.svc.ehdl = ind->end_hdl; - } - - paspc_env->env[conidx]->nb_svc++; + // Even if we get multiple responses we only store 1 range + paspc_env->env[conidx]->pass.svc.shdl = ind->start_hdl; + paspc_env->env[conidx]->pass.svc.ehdl = ind->end_hdl; } - return (KE_MSG_CONSUMED); + paspc_env->env[conidx]->nb_svc++; + } + + return (KE_MSG_CONSUMED); } /** @@ -446,98 +411,81 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, - struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct paspc_env_tag *paspc_env = PRF_ENV_GET(PASPC, paspc); - // Status - uint8_t status; + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct paspc_env_tag *paspc_env = PRF_ENV_GET(PASPC, paspc); + // Status + uint8_t status; + if (paspc_env != NULL) { + uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t state = ke_state_get(dest_id); - if (paspc_env != NULL) - { - uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); + if (state == PASPC_DISCOVERING) { + status = param->status; - if (state == PASPC_DISCOVERING) - { - status = param->status; - - if ((status == ATT_ERR_ATTRIBUTE_NOT_FOUND) || - (status == ATT_ERR_NO_ERROR)) - { - // Discovery - // check characteristic validity - if(paspc_env->env[conidx]->nb_svc == 1) - { - status = prf_check_svc_char_validity(PASPC_CHAR_MAX, - paspc_env->env[conidx]->pass.chars, - paspc_pass_char); - } - // too much services - else if (paspc_env->env[conidx]->nb_svc > 1) - { - status = PRF_ERR_MULTIPLE_SVC; - } - // no services found - else - { - status = PRF_ERR_STOP_DISC_CHAR_MISSING; - } - - // check descriptor validity - if (status == GAP_ERR_NO_ERROR) - { - status = prf_check_svc_char_desc_validity(PASPC_DESC_MAX, - paspc_env->env[conidx]->pass.descs, - paspc_pass_char_desc, - paspc_env->env[conidx]->pass.chars); - } - } - - paspc_enable_rsp_send(paspc_env, conidx, status); + if ((status == ATT_ERR_ATTRIBUTE_NOT_FOUND) || + (status == ATT_ERR_NO_ERROR)) { + // Discovery + // check characteristic validity + if (paspc_env->env[conidx]->nb_svc == 1) { + status = prf_check_svc_char_validity( + PASPC_CHAR_MAX, paspc_env->env[conidx]->pass.chars, + paspc_pass_char); + } + // too much services + else if (paspc_env->env[conidx]->nb_svc > 1) { + status = PRF_ERR_MULTIPLE_SVC; + } + // no services found + else { + status = PRF_ERR_STOP_DISC_CHAR_MISSING; } - else if (state == PASPC_BUSY) - { - switch (param->operation) - { - case GATTC_READ: - { - // Send the complete event status - paspc_send_cmp_evt(paspc_env, conidx, PASPC_READ_OP_CODE, param->status); - } break; - - case GATTC_WRITE: - case GATTC_WRITE_NO_RESPONSE: - { - if (paspc_env->env[conidx]->operation == PASPC_WRITE_OP_CODE) - { - // Send the complete event status - paspc_send_cmp_evt(paspc_env, conidx, PASPC_WRITE_OP_CODE, param->status); - } - } break; - - case GATTC_REGISTER: - case GATTC_UNREGISTER: - { - // Do nothing - } break; - - default: - { - ASSERT_ERR(0); - } break; - } + // check descriptor validity + if (status == GAP_ERR_NO_ERROR) { + status = prf_check_svc_char_desc_validity( + PASPC_DESC_MAX, paspc_env->env[conidx]->pass.descs, + paspc_pass_char_desc, paspc_env->env[conidx]->pass.chars); } + } + + paspc_enable_rsp_send(paspc_env, conidx, status); } - // else ignore the message + else if (state == PASPC_BUSY) { + switch (param->operation) { + case GATTC_READ: { + // Send the complete event status + paspc_send_cmp_evt(paspc_env, conidx, PASPC_READ_OP_CODE, + param->status); + } break; + case GATTC_WRITE: + case GATTC_WRITE_NO_RESPONSE: { + if (paspc_env->env[conidx]->operation == PASPC_WRITE_OP_CODE) { + // Send the complete event status + paspc_send_cmp_evt(paspc_env, conidx, PASPC_WRITE_OP_CODE, + param->status); + } + } break; - return (KE_MSG_CONSUMED); + case GATTC_REGISTER: + case GATTC_UNREGISTER: { + // Do nothing + } break; + + default: { + ASSERT_ERR(0); + } break; + } + } + } + // else ignore the message + + return (KE_MSG_CONSUMED); } /** @@ -554,62 +502,53 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, struct gattc_read_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct paspc_env_tag *paspc_env = PRF_ENV_GET(PASPC, paspc); - uint8_t conidx = KE_IDX_GET(dest_id); + ke_task_id_t const src_id) { + // Get the address of the environment + struct paspc_env_tag *paspc_env = PRF_ENV_GET(PASPC, paspc); + uint8_t conidx = KE_IDX_GET(dest_id); - if (paspc_env != NULL) - { - ASSERT_ERR(ke_state_get(dest_id) == PASPC_BUSY); + if (paspc_env != NULL) { + ASSERT_ERR(ke_state_get(dest_id) == PASPC_BUSY); - // Prepare the indication message for the HL - struct paspc_value_ind *ind = KE_MSG_ALLOC(PASPC_VALUE_IND, - prf_dst_task_get(&(paspc_env->prf_env), conidx), - dest_id, - paspc_value_ind); + // Prepare the indication message for the HL + struct paspc_value_ind *ind = KE_MSG_ALLOC( + PASPC_VALUE_IND, prf_dst_task_get(&(paspc_env->prf_env), conidx), + dest_id, paspc_value_ind); - switch (paspc_env->env[conidx]->last_char_code) - { - // Read Alert Status Characteristic Value - case (PASPC_RD_ALERT_STATUS): - { - ind->value.alert_status = param->value[0]; - } break; + switch (paspc_env->env[conidx]->last_char_code) { + // Read Alert Status Characteristic Value + case (PASPC_RD_ALERT_STATUS): { + ind->value.alert_status = param->value[0]; + } break; - // Read Ringer Setting Characteristic Value - case (PASPC_RD_RINGER_SETTING): - { - ind->value.ringer_setting = param->value[0]; - } break; + // Read Ringer Setting Characteristic Value + case (PASPC_RD_RINGER_SETTING): { + ind->value.ringer_setting = param->value[0]; + } break; - // Read Alert Status Characteristic Client Char. Cfg. Descriptor Value - case (PASPC_RD_WR_ALERT_STATUS_CFG): - { - ind->value.alert_status_ntf_cfg = co_read16p(¶m->value[0]); - } break; + // Read Alert Status Characteristic Client Char. Cfg. Descriptor Value + case (PASPC_RD_WR_ALERT_STATUS_CFG): { + ind->value.alert_status_ntf_cfg = co_read16p(¶m->value[0]); + } break; - // Read Ringer Setting Characteristic Client Char. Cfg. Descriptor Value - case (PASPC_RD_WR_RINGER_SETTING_CFG): - { - ind->value.ringer_setting_ntf_cfg = co_read16p(¶m->value[0]); - } break; + // Read Ringer Setting Characteristic Client Char. Cfg. Descriptor Value + case (PASPC_RD_WR_RINGER_SETTING_CFG): { + ind->value.ringer_setting_ntf_cfg = co_read16p(¶m->value[0]); + } break; - default: - { - ASSERT_ERR(0); - } break; - } - - ind->att_code = paspc_env->env[conidx]->last_char_code; - - // Send the message - ke_msg_send(ind); + default: { + ASSERT_ERR(0); + } break; } - // else ignore the message - return (KE_MSG_CONSUMED); + ind->att_code = paspc_env->env[conidx]->last_char_code; + + // Send the message + ke_msg_send(ind); + } + // else ignore the message + + return (KE_MSG_CONSUMED); } /** @@ -623,44 +562,44 @@ __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, - struct gattc_event_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct paspc_env_tag *paspc_env = PRF_ENV_GET(PASPC, paspc); - uint8_t conidx = KE_IDX_GET(dest_id); + struct gattc_event_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct paspc_env_tag *paspc_env = PRF_ENV_GET(PASPC, paspc); + uint8_t conidx = KE_IDX_GET(dest_id); - if (paspc_env != NULL) - { - ASSERT_ERR((param->handle == paspc_env->env[conidx]->pass.chars[PASPC_CHAR_ALERT_STATUS].val_hdl) || - (param->handle == paspc_env->env[conidx]->pass.chars[PASPC_CHAR_RINGER_SETTING].val_hdl)); + if (paspc_env != NULL) { + ASSERT_ERR( + (param->handle == + paspc_env->env[conidx]->pass.chars[PASPC_CHAR_ALERT_STATUS].val_hdl) || + (param->handle == paspc_env->env[conidx] + ->pass.chars[PASPC_CHAR_RINGER_SETTING] + .val_hdl)); - // Prepare the indication message for the HL - struct paspc_value_ind *ind = KE_MSG_ALLOC(PASPC_VALUE_IND, - prf_dst_task_get(&paspc_env->prf_env, conidx), - prf_src_task_get(&paspc_env->prf_env, conidx), - paspc_value_ind); + // Prepare the indication message for the HL + struct paspc_value_ind *ind = KE_MSG_ALLOC( + PASPC_VALUE_IND, prf_dst_task_get(&paspc_env->prf_env, conidx), + prf_src_task_get(&paspc_env->prf_env, conidx), paspc_value_ind); - // Alert Status Characteristic Value - if (param->handle == paspc_env->env[conidx]->pass.chars[PASPC_CHAR_ALERT_STATUS].val_hdl) - { - ind->value.alert_status = param->value[0]; - ind->att_code = PASPC_RD_ALERT_STATUS; - } - // Ringer Setting Characteristic Value - else - { - ind->value.ringer_setting = param->value[0]; - ind->att_code = PASPC_RD_RINGER_SETTING; - } - - // Send the message - ke_msg_send(ind); + // Alert Status Characteristic Value + if (param->handle == + paspc_env->env[conidx]->pass.chars[PASPC_CHAR_ALERT_STATUS].val_hdl) { + ind->value.alert_status = param->value[0]; + ind->att_code = PASPC_RD_ALERT_STATUS; + } + // Ringer Setting Characteristic Value + else { + ind->value.ringer_setting = param->value[0]; + ind->att_code = PASPC_RD_RINGER_SETTING; } - // else ignore the message - return (KE_MSG_CONSUMED); + // Send the message + ke_msg_send(ind); + } + // else ignore the message + + return (KE_MSG_CONSUMED); } /* @@ -669,26 +608,24 @@ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, */ /// Specifies the default message handlers -KE_MSG_HANDLER_TAB(paspc) -{ - {PASPC_ENABLE_REQ, (ke_msg_func_t)paspc_enable_req_handler}, - {PASPC_READ_CMD, (ke_msg_func_t)paspc_read_cmd_handler}, - {PASPC_WRITE_CMD, (ke_msg_func_t)paspc_write_cmd_handler}, - {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, - {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, - {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, +KE_MSG_HANDLER_TAB(paspc){ + {PASPC_ENABLE_REQ, (ke_msg_func_t)paspc_enable_req_handler}, + {PASPC_READ_CMD, (ke_msg_func_t)paspc_read_cmd_handler}, + {PASPC_WRITE_CMD, (ke_msg_func_t)paspc_write_cmd_handler}, + {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, + {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, + {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void paspc_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct paspc_env_tag *paspc_env = PRF_ENV_GET(PASPC, paspc); +void paspc_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct paspc_env_tag *paspc_env = PRF_ENV_GET(PASPC, paspc); - task_desc->msg_handler_tab = paspc_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(paspc_msg_handler_tab); - task_desc->state = paspc_env->state; - task_desc->idx_max = PASPC_IDX_MAX; + task_desc->msg_handler_tab = paspc_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(paspc_msg_handler_tab); + task_desc->state = paspc_env->state; + task_desc->idx_max = PASPC_IDX_MAX; } #endif //(BLE_PAS_CLIENT) diff --git a/services/ble_profiles/pasp/pasps/src/pasps.c b/services/ble_profiles/pasp/pasps/src/pasps.c index 7767d27..bfcd6a6 100644 --- a/services/ble_profiles/pasp/pasps/src/pasps.c +++ b/services/ble_profiles/pasp/pasps/src/pasps.c @@ -14,8 +14,8 @@ #if (BLE_PAS_SERVER) #include "pasp_common.h" -#include "pasps_task.h" #include "pasps.h" +#include "pasps_task.h" #include "prf_utils.h" #include "ke_mem.h" @@ -26,29 +26,43 @@ */ /// Full PAS Database Description - Used to add attributes into the database -const struct attm_desc pasps_att_db[PASS_IDX_NB] = -{ +const struct attm_desc pasps_att_db[PASS_IDX_NB] = { // Phone Alert Status Service Declaration - [PASS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [PASS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // Alert Status Characteristic Declaration - [PASS_IDX_ALERT_STATUS_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [PASS_IDX_ALERT_STATUS_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), + 0, 0}, // Alert Status Characteristic Value - [PASS_IDX_ALERT_STATUS_VAL] = {ATT_CHAR_ALERT_STATUS, PERM(RD, ENABLE) | PERM(NTF, ENABLE), PERM(RI, ENABLE), sizeof(uint8_t)}, - // Alert Status Characteristic - Client Characteristic Configuration Descriptor - [PASS_IDX_ALERT_STATUS_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [PASS_IDX_ALERT_STATUS_VAL] = {ATT_CHAR_ALERT_STATUS, + PERM(RD, ENABLE) | PERM(NTF, ENABLE), + PERM(RI, ENABLE), sizeof(uint8_t)}, + // Alert Status Characteristic - Client Characteristic Configuration + // Descriptor + [PASS_IDX_ALERT_STATUS_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + 0, 0}, // Ringer Setting Characteristic Declaration - [PASS_IDX_RINGER_SETTING_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [PASS_IDX_RINGER_SETTING_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), + 0, 0}, // Ringer Settings Characteristic Value - [PASS_IDX_RINGER_SETTING_VAL] = {ATT_CHAR_RINGER_SETTING, PERM(RD, ENABLE) | PERM(NTF, ENABLE), PERM(RI, ENABLE), sizeof(uint8_t)}, - // Ringer Settings Characteristic - Client Characteristic Configuration Descriptor - [PASS_IDX_RINGER_SETTING_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [PASS_IDX_RINGER_SETTING_VAL] = {ATT_CHAR_RINGER_SETTING, + PERM(RD, ENABLE) | PERM(NTF, ENABLE), + PERM(RI, ENABLE), sizeof(uint8_t)}, + // Ringer Settings Characteristic - Client Characteristic Configuration + // Descriptor + [PASS_IDX_RINGER_SETTING_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + 0, 0}, // Ringer Control Point Characteristic Declaration - [PASS_IDX_RINGER_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [PASS_IDX_RINGER_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), + 0, 0}, // Ringer Control Point Characteristic Value - [PASS_IDX_RINGER_CTNL_PT_VAL] = {ATT_CHAR_RINGER_CNTL_POINT, PERM(WRITE_COMMAND, ENABLE), PERM(RI, ENABLE), sizeof(uint8_t)}, + [PASS_IDX_RINGER_CTNL_PT_VAL] = {ATT_CHAR_RINGER_CNTL_POINT, + PERM(WRITE_COMMAND, ENABLE), + PERM(RI, ENABLE), sizeof(uint8_t)}, }; /* @@ -68,89 +82,93 @@ const struct attm_desc pasps_att_db[PASS_IDX_NB] = * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t pasps_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, struct pasps_db_cfg* params) -{ - //------------------ create the attribute database for the profile ------------------- - // Service content flag - uint32_t cfg_flag= PASPS_DB_CFG_FLAG; - // DB Creation Status - uint8_t status = ATT_ERR_NO_ERROR; +static uint8_t pasps_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, + struct pasps_db_cfg *params) { + //------------------ create the attribute database for the profile + //------------------- + // Service content flag + uint32_t cfg_flag = PASPS_DB_CFG_FLAG; + // DB Creation Status + uint8_t status = ATT_ERR_NO_ERROR; - // Add service in the database - status = attm_svc_create_db(start_hdl, ATT_SVC_PHONE_ALERT_STATUS, (uint8_t *)&cfg_flag, - PASS_IDX_NB, NULL, env->task, &pasps_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | PERM(SVC_MI, ENABLE)); + // Add service in the database + status = attm_svc_create_db( + start_hdl, ATT_SVC_PHONE_ALERT_STATUS, (uint8_t *)&cfg_flag, PASS_IDX_NB, + NULL, env->task, &pasps_att_db[0], + (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, ENABLE)); - //-------------------- allocate memory required for the profile --------------------- - if (status == ATT_ERR_NO_ERROR) - { - // Allocate PASPS required environment variable - struct pasps_env_tag* pasps_env = - (struct pasps_env_tag* ) ke_malloc(sizeof(struct pasps_env_tag), KE_MEM_ATT_DB); + //-------------------- allocate memory required for the profile + //--------------------- + if (status == ATT_ERR_NO_ERROR) { + // Allocate PASPS required environment variable + struct pasps_env_tag *pasps_env = (struct pasps_env_tag *)ke_malloc( + sizeof(struct pasps_env_tag), KE_MEM_ATT_DB); - // Initialize PASPS environment - env->env = (prf_env_t*) pasps_env; - pasps_env->shdl = *start_hdl; + // Initialize PASPS environment + env->env = (prf_env_t *)pasps_env; + pasps_env->shdl = *start_hdl; - pasps_env->alert_status = params->alert_status; - pasps_env->ringer_setting = params->ringer_setting; + pasps_env->alert_status = params->alert_status; + pasps_env->ringer_setting = params->ringer_setting; - pasps_env->operation = PASPS_RESERVED_OP_CODE; + pasps_env->operation = PASPS_RESERVED_OP_CODE; - pasps_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - // Multi Instantiated task - pasps_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + pasps_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + // Multi Instantiated task + pasps_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_PASPS; - pasps_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_PASPS; + pasps_task_init(&(env->desc)); - for(uint8_t idx = 0; idx < BLE_CONNECTION_MAX ; idx++) - { - pasps_env->env[idx] = NULL; - /* Put PASS in disabled state */ - ke_state_set(KE_BUILD_ID(env->task, idx), PASPS_FREE); - } + for (uint8_t idx = 0; idx < BLE_CONNECTION_MAX; idx++) { + pasps_env->env[idx] = NULL; + /* Put PASS in disabled state */ + ke_state_set(KE_BUILD_ID(env->task, idx), PASPS_FREE); } + } - return (status); + return (status); } /** **************************************************************************************** * @brief Destruction of the PASPS module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void pasps_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct pasps_env_tag* pasps_env = (struct pasps_env_tag*) env->env; +static void pasps_destroy(struct prf_task_env *env) { + uint8_t idx; + struct pasps_env_tag *pasps_env = (struct pasps_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < BLE_CONNECTION_MAX ; idx++) - { - if(pasps_env->env[idx] != NULL) - { - ke_free(pasps_env->env[idx]); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < BLE_CONNECTION_MAX; idx++) { + if (pasps_env->env[idx] != NULL) { + ke_free(pasps_env->env[idx]); } + } - // free profile environment variables - env->env = NULL; - ke_free(pasps_env); + // free profile environment variables + env->env = NULL; + ke_free(pasps_env); } /** @@ -161,17 +179,16 @@ static void pasps_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void pasps_create(struct prf_task_env* env, uint8_t conidx) -{ - struct pasps_env_tag* pasps_env = (struct pasps_env_tag*) env->env; - pasps_env->env[conidx] = (struct pasps_cnx_env*) - ke_malloc(sizeof(struct pasps_cnx_env), KE_MEM_ATT_DB); +static void pasps_create(struct prf_task_env *env, uint8_t conidx) { + struct pasps_env_tag *pasps_env = (struct pasps_env_tag *)env->env; + pasps_env->env[conidx] = (struct pasps_cnx_env *)ke_malloc( + sizeof(struct pasps_cnx_env), KE_MEM_ATT_DB); - memset(pasps_env->env[conidx], 0, sizeof(struct pasps_cnx_env)); + memset(pasps_env->env[conidx], 0, sizeof(struct pasps_cnx_env)); - pasps_env->env[conidx]->ringer_state = pasps_env->ringer_setting; - /* Put PASS in idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), PASPS_IDLE); + pasps_env->env[conidx]->ringer_state = pasps_env->ringer_setting; + /* Put PASS in idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), PASPS_IDLE); } /** @@ -183,19 +200,18 @@ static void pasps_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void pasps_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct pasps_env_tag* pasps_env = (struct pasps_env_tag*) env->env; +static void pasps_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct pasps_env_tag *pasps_env = (struct pasps_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(pasps_env->env[conidx] != NULL) - { - ke_free(pasps_env->env[conidx]); - pasps_env->env[conidx] = NULL; - } + // clean-up environment variable allocated for task instance + if (pasps_env->env[conidx] != NULL) { + ke_free(pasps_env->env[conidx]); + pasps_env->env[conidx] = NULL; + } - /* Put PASS in disabled state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), PASPS_FREE); + /* Put PASS in disabled state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), PASPS_FREE); } /* @@ -204,12 +220,11 @@ static void pasps_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reas */ /// PASPS Task interface required by profile manager -const struct prf_task_cbs pasps_itf = -{ - (prf_init_fnct) pasps_init, - pasps_destroy, - pasps_create, - pasps_cleanup, +const struct prf_task_cbs pasps_itf = { + (prf_init_fnct)pasps_init, + pasps_destroy, + pasps_create, + pasps_cleanup, }; /* @@ -217,11 +232,7 @@ const struct prf_task_cbs pasps_itf = **************************************************************************************** */ -const struct prf_task_cbs* pasps_prf_itf_get(void) -{ - return &pasps_itf; -} - +const struct prf_task_cbs *pasps_prf_itf_get(void) { return &pasps_itf; } ///* // * FUNCTION DEFINITIONS @@ -229,23 +240,20 @@ const struct prf_task_cbs* pasps_prf_itf_get(void) // */ void pasps_send_cmp_evt(ke_task_id_t src_id, ke_task_id_t dest_id, - uint8_t operation, uint8_t status) -{ - // Come back to the Connected state if the state was busy. - if (ke_state_get(src_id) == PASPS_BUSY) - { - ke_state_set(src_id, PASPS_IDLE); - } + uint8_t operation, uint8_t status) { + // Come back to the Connected state if the state was busy. + if (ke_state_get(src_id) == PASPS_BUSY) { + ke_state_set(src_id, PASPS_IDLE); + } - // Send the message to the application - struct pasps_cmp_evt *evt = KE_MSG_ALLOC(PASPS_CMP_EVT, - dest_id, src_id, - pasps_cmp_evt); + // Send the message to the application + struct pasps_cmp_evt *evt = + KE_MSG_ALLOC(PASPS_CMP_EVT, dest_id, src_id, pasps_cmp_evt); - evt->operation = operation; - evt->status = status; + evt->operation = operation; + evt->status = status; - ke_msg_send(evt); + ke_msg_send(evt); } #endif //(BLE_PASP_SERVER) diff --git a/services/ble_profiles/pasp/pasps/src/pasps_task.c b/services/ble_profiles/pasp/pasps/src/pasps_task.c index a58692e..3c35e78 100644 --- a/services/ble_profiles/pasp/pasps/src/pasps_task.c +++ b/services/ble_profiles/pasp/pasps/src/pasps_task.c @@ -5,7 +5,6 @@ **************************************************************************************** */ - /* * INCLUDE FILES **************************************************************************************** @@ -14,9 +13,9 @@ #if (BLE_PAS_SERVER) #include "pasp_common.h" +#include "attm.h" #include "gap.h" #include "gattc_task.h" -#include "attm.h" #include "pasps.h" #include "pasps_task.h" #include "prf_utils.h" @@ -39,49 +38,45 @@ **************************************************************************************** */ __STATIC int pasps_enable_req_handler(ke_msg_id_t const msgid, - struct pasps_enable_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct pasps_env_tag *pasps_env = PRF_ENV_GET(PASPS, pasps); - uint8_t conidx = KE_IDX_GET(src_id); - // Status - uint8_t status = PRF_ERR_REQ_DISALLOWED; + struct pasps_enable_req *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct pasps_env_tag *pasps_env = PRF_ENV_GET(PASPS, pasps); + uint8_t conidx = KE_IDX_GET(src_id); + // Status + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if(ke_state_get(dest_id) == PASPS_IDLE) - { - // Bonded data was not used before - if (!(pasps_env->env[conidx]->ntf_state & PASPS_FLAG_CFG_PERFORMED_OK)) - { - status = GAP_ERR_NO_ERROR; - if (param->alert_status_ntf_cfg != PRF_CLI_STOP_NTFIND) - { - // Force to PRF_CLI_START_NTF - param->alert_status_ntf_cfg = PRF_CLI_START_NTF; + if (ke_state_get(dest_id) == PASPS_IDLE) { + // Bonded data was not used before + if (!(pasps_env->env[conidx]->ntf_state & PASPS_FLAG_CFG_PERFORMED_OK)) { + status = GAP_ERR_NO_ERROR; + if (param->alert_status_ntf_cfg != PRF_CLI_STOP_NTFIND) { + // Force to PRF_CLI_START_NTF + param->alert_status_ntf_cfg = PRF_CLI_START_NTF; - PASPS_ENABLE_NTF(conidx, pasps_env, PASPS_FLAG_ALERT_STATUS_CFG); - } + PASPS_ENABLE_NTF(conidx, pasps_env, PASPS_FLAG_ALERT_STATUS_CFG); + } - if (param->ringer_setting_ntf_cfg != PRF_CLI_STOP_NTFIND) - { - // Force to PRF_CLI_START_NTF - param->ringer_setting_ntf_cfg = PRF_CLI_START_NTF; + if (param->ringer_setting_ntf_cfg != PRF_CLI_STOP_NTFIND) { + // Force to PRF_CLI_START_NTF + param->ringer_setting_ntf_cfg = PRF_CLI_START_NTF; - PASPS_ENABLE_NTF(conidx, pasps_env, PASPS_FLAG_RINGER_SETTING_CFG); - } - } - // Enable Bonded Data - PASPS_ENABLE_NTF(conidx, pasps_env, PASPS_FLAG_CFG_PERFORMED_OK); + PASPS_ENABLE_NTF(conidx, pasps_env, PASPS_FLAG_RINGER_SETTING_CFG); + } } + // Enable Bonded Data + PASPS_ENABLE_NTF(conidx, pasps_env, PASPS_FLAG_CFG_PERFORMED_OK); + } - // send completed information to APP task that contains error status - struct pasps_enable_rsp *cmp_evt = KE_MSG_ALLOC(PASPS_ENABLE_RSP, src_id, dest_id, pasps_enable_rsp); - cmp_evt->status = status; + // send completed information to APP task that contains error status + struct pasps_enable_rsp *cmp_evt = + KE_MSG_ALLOC(PASPS_ENABLE_RSP, src_id, dest_id, pasps_enable_rsp); + cmp_evt->status = status; - ke_msg_send(cmp_evt); + ke_msg_send(cmp_evt); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -94,132 +89,116 @@ __STATIC int pasps_enable_req_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int pasps_update_char_val_cmd_handler(ke_msg_id_t const msgid, - struct pasps_update_char_val_cmd *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = PRF_ERR_INVALID_PARAM; - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; +__STATIC int pasps_update_char_val_cmd_handler( + ke_msg_id_t const msgid, struct pasps_update_char_val_cmd *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Status + uint8_t status = PRF_ERR_INVALID_PARAM; + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; - uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); + uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t state = ke_state_get(dest_id); - if (state == PASPS_IDLE) - { - // Get the address of the environment - struct pasps_env_tag *pasps_env = PRF_ENV_GET(PASPS, pasps); - // Handle - uint16_t handle = ATT_ERR_INVALID_HANDLE; - // Notification status flag - uint8_t flag = 0; + if (state == PASPS_IDLE) { + // Get the address of the environment + struct pasps_env_tag *pasps_env = PRF_ENV_GET(PASPS, pasps); + // Handle + uint16_t handle = ATT_ERR_INVALID_HANDLE; + // Notification status flag + uint8_t flag = 0; - ASSERT_ERR(pasps_env != NULL); - ASSERT_ERR(pasps_env->env[conidx] != NULL); + ASSERT_ERR(pasps_env != NULL); + ASSERT_ERR(pasps_env->env[conidx] != NULL); - // Check the connection handle - switch (param->operation) - { - // Alert Status Characteristic - case (PASPS_UPD_ALERT_STATUS_OP_CODE): - { - // Check the provided value - if (param->value <= PASP_ALERT_STATUS_VAL_MAX) - { - // Set the handle value - handle = pasps_env->shdl + PASS_IDX_ALERT_STATUS_VAL; - // Set the flag - flag = PASPS_FLAG_ALERT_STATUS_CFG; - // Update the ringer state value - pasps_env->alert_status = param->value; + // Check the connection handle + switch (param->operation) { + // Alert Status Characteristic + case (PASPS_UPD_ALERT_STATUS_OP_CODE): { + // Check the provided value + if (param->value <= PASP_ALERT_STATUS_VAL_MAX) { + // Set the handle value + handle = pasps_env->shdl + PASS_IDX_ALERT_STATUS_VAL; + // Set the flag + flag = PASPS_FLAG_ALERT_STATUS_CFG; + // Update the ringer state value + pasps_env->alert_status = param->value; - status = GAP_ERR_NO_ERROR; - } - // else status is PRF_ERR_INVALID_PARAM - } break; - - // Ringer Setting Characteristic - case (PASPS_UPD_RINGER_SETTING_OP_CODE): - { - // Check the provided value - if (param->value <= PASP_RINGER_NORMAL) - { - // Set the handle value - handle = pasps_env->shdl + PASS_IDX_RINGER_SETTING_VAL; - // Set the flag - flag = PASPS_FLAG_RINGER_SETTING_CFG; - // Update the ringer state value - pasps_env->ringer_setting = param->value; - - status = GAP_ERR_NO_ERROR; - } - // else status is PRF_ERR_INVALID_PARAM - } break; - - default: - { - // Nothing more to do, status is PRF_ERR_INVALID_PARAM - } break; - } - - if (status == GAP_ERR_NO_ERROR) - { - // Check if sending of notifications is enabled for this connection - if (PASPS_IS_NTF_ENABLED(conidx, pasps_env, flag)) - { - // Configure the environment for the operation - pasps_env->operation = param->operation; - // Go to the Busy state - ke_state_set(dest_id, PASPS_BUSY); - - // Allocate the GATT notification message - struct gattc_send_evt_cmd *ntf = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), dest_id, - gattc_send_evt_cmd, sizeof(uint8_t)); - - // Fill in the parameter structure - ntf->operation = GATTC_NOTIFY; - ntf->handle = handle; - // pack measured value in database - ntf->length = sizeof(uint8_t); - // Fill data - ntf->value[0] = param->value; - - // The notification can be sent, send the notification - ke_msg_send(ntf); - } - else - { - status = PRF_ERR_NTF_DISABLED; - } - } - } - else if (state == PASPS_BUSY) - { - // Save it for later - msg_status = KE_MSG_SAVED; status = GAP_ERR_NO_ERROR; - } - // no connection - else - { - status = GAP_ERR_DISCONNECTED; + } + // else status is PRF_ERR_INVALID_PARAM + } break; + + // Ringer Setting Characteristic + case (PASPS_UPD_RINGER_SETTING_OP_CODE): { + // Check the provided value + if (param->value <= PASP_RINGER_NORMAL) { + // Set the handle value + handle = pasps_env->shdl + PASS_IDX_RINGER_SETTING_VAL; + // Set the flag + flag = PASPS_FLAG_RINGER_SETTING_CFG; + // Update the ringer state value + pasps_env->ringer_setting = param->value; + + status = GAP_ERR_NO_ERROR; + } + // else status is PRF_ERR_INVALID_PARAM + } break; + + default: { + // Nothing more to do, status is PRF_ERR_INVALID_PARAM + } break; } - if(status != GAP_ERR_NO_ERROR) - { - // Send the message to the application - struct pasps_cmp_evt *evt = KE_MSG_ALLOC(PASPS_CMP_EVT, src_id, dest_id, pasps_cmp_evt); + if (status == GAP_ERR_NO_ERROR) { + // Check if sending of notifications is enabled for this connection + if (PASPS_IS_NTF_ENABLED(conidx, pasps_env, flag)) { + // Configure the environment for the operation + pasps_env->operation = param->operation; + // Go to the Busy state + ke_state_set(dest_id, PASPS_BUSY); - evt->operation = param->operation; - evt->status = status; + // Allocate the GATT notification message + struct gattc_send_evt_cmd *ntf = KE_MSG_ALLOC_DYN( + GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), dest_id, + gattc_send_evt_cmd, sizeof(uint8_t)); - ke_msg_send(evt); + // Fill in the parameter structure + ntf->operation = GATTC_NOTIFY; + ntf->handle = handle; + // pack measured value in database + ntf->length = sizeof(uint8_t); + // Fill data + ntf->value[0] = param->value; + + // The notification can be sent, send the notification + ke_msg_send(ntf); + } else { + status = PRF_ERR_NTF_DISABLED; + } } + } else if (state == PASPS_BUSY) { + // Save it for later + msg_status = KE_MSG_SAVED; + status = GAP_ERR_NO_ERROR; + } + // no connection + else { + status = GAP_ERR_DISCONNECTED; + } - return (int)msg_status; + if (status != GAP_ERR_NO_ERROR) { + // Send the message to the application + struct pasps_cmp_evt *evt = + KE_MSG_ALLOC(PASPS_CMP_EVT, src_id, dest_id, pasps_cmp_evt); + + evt->operation = param->operation; + evt->status = status; + + ke_msg_send(evt); + } + + return (int)msg_status; } /** @@ -233,46 +212,39 @@ __STATIC int pasps_update_char_val_cmd_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_att_info_req_ind *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if(ke_state_get(dest_id) == PASPS_IDLE) - { - // Get the address of the environment - struct pasps_env_tag *pasps_env = PRF_ENV_GET(PASPS, pasps); - uint8_t att_idx = param->handle - pasps_env->shdl; - struct gattc_att_info_cfm * cfm; +__STATIC int gattc_att_info_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_att_info_req_ind *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + if (ke_state_get(dest_id) == PASPS_IDLE) { + // Get the address of the environment + struct pasps_env_tag *pasps_env = PRF_ENV_GET(PASPS, pasps); + uint8_t att_idx = param->handle - pasps_env->shdl; + struct gattc_att_info_cfm *cfm; - //Send write response - cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); - cfm->handle = param->handle; + // Send write response + cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); + cfm->handle = param->handle; - // check if it's a client configuration char - if((att_idx == PASS_IDX_ALERT_STATUS_CFG) - || (att_idx == PASS_IDX_RINGER_SETTING_CFG)) - { - // CCC attribute length = 2 - cfm->length = 2; - cfm->status = GAP_ERR_NO_ERROR; - } - else if (att_idx == PASS_IDX_RINGER_CTNL_PT_VAL) - { - // attribute length = 1 - cfm->length = 1; - cfm->status = GAP_ERR_NO_ERROR; - } - // not expected request - else - { - cfm->length = 0; - cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; - } - ke_msg_send(cfm); - } + // check if it's a client configuration char + if ((att_idx == PASS_IDX_ALERT_STATUS_CFG) || + (att_idx == PASS_IDX_RINGER_SETTING_CFG)) { + // CCC attribute length = 2 + cfm->length = 2; + cfm->status = GAP_ERR_NO_ERROR; + } else if (att_idx == PASS_IDX_RINGER_CTNL_PT_VAL) { + // attribute length = 1 + cfm->length = 1; + cfm->status = GAP_ERR_NO_ERROR; + } + // not expected request + else { + cfm->length = 0; + cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; + } + ke_msg_send(cfm); + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -287,71 +259,68 @@ __STATIC int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_read_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if(ke_state_get(dest_id) == PASPS_IDLE) - { - // Get the address of the environment - struct pasps_env_tag *pasps_env = PRF_ENV_GET(PASPS, pasps); - uint8_t conidx = KE_IDX_GET(src_id); - uint8_t att_idx = param->handle - pasps_env->shdl; + struct gattc_read_req_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + if (ke_state_get(dest_id) == PASPS_IDLE) { + // Get the address of the environment + struct pasps_env_tag *pasps_env = PRF_ENV_GET(PASPS, pasps); + uint8_t conidx = KE_IDX_GET(src_id); + uint8_t att_idx = param->handle - pasps_env->shdl; - uint8_t value[2]; - uint8_t value_size = 0; - uint8_t status = ATT_ERR_NO_ERROR; + uint8_t value[2]; + uint8_t value_size = 0; + uint8_t status = ATT_ERR_NO_ERROR; - switch(att_idx) - { - case PASS_IDX_ALERT_STATUS_VAL: - { - // Fill data - value_size = sizeof(uint8_t); - value[0] = pasps_env->alert_status; - } break; + switch (att_idx) { + case PASS_IDX_ALERT_STATUS_VAL: { + // Fill data + value_size = sizeof(uint8_t); + value[0] = pasps_env->alert_status; + } break; - case PASS_IDX_RINGER_SETTING_VAL: - { - // Fill data - value_size = sizeof(uint8_t); - value[0] = pasps_env->ringer_setting; - } break; + case PASS_IDX_RINGER_SETTING_VAL: { + // Fill data + value_size = sizeof(uint8_t); + value[0] = pasps_env->ringer_setting; + } break; - case PASS_IDX_ALERT_STATUS_CFG: - { - // Fill data - value_size = sizeof(uint16_t); - co_write16p(value, (pasps_env->env[conidx]->ntf_state & PASPS_FLAG_ALERT_STATUS_CFG) - ? PRF_CLI_START_NTF : PRF_CLI_STOP_NTFIND); - } break; + case PASS_IDX_ALERT_STATUS_CFG: { + // Fill data + value_size = sizeof(uint16_t); + co_write16p(value, (pasps_env->env[conidx]->ntf_state & + PASPS_FLAG_ALERT_STATUS_CFG) + ? PRF_CLI_START_NTF + : PRF_CLI_STOP_NTFIND); + } break; - case PASS_IDX_RINGER_SETTING_CFG: - { - // Fill data - value_size = sizeof(uint16_t); - co_write16p(value, (pasps_env->env[conidx]->ntf_state & PASPS_FLAG_RINGER_SETTING_CFG) - ? PRF_CLI_START_NTF : PRF_CLI_STOP_NTFIND); - } break; + case PASS_IDX_RINGER_SETTING_CFG: { + // Fill data + value_size = sizeof(uint16_t); + co_write16p(value, (pasps_env->env[conidx]->ntf_state & + PASPS_FLAG_RINGER_SETTING_CFG) + ? PRF_CLI_START_NTF + : PRF_CLI_STOP_NTFIND); + } break; - default: - { - status = ATT_ERR_REQUEST_NOT_SUPPORTED; - } break; - } - - // Send data to peer device - struct gattc_read_cfm* cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, value_size); - cfm->length = value_size; - memcpy(cfm->value, value, value_size); - cfm->handle = param->handle; - cfm->status = status; - - // Send value to peer device. - ke_msg_send(cfm); + default: { + status = ATT_ERR_REQUEST_NOT_SUPPORTED; + } break; } - return (KE_MSG_CONSUMED); + // Send data to peer device + struct gattc_read_cfm *cfm = KE_MSG_ALLOC_DYN( + GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, value_size); + cfm->length = value_size; + memcpy(cfm->value, value, value_size); + cfm->handle = param->handle; + cfm->status = status; + + // Send value to peer device. + ke_msg_send(cfm); + } + + return (KE_MSG_CONSUMED); } /** @@ -364,149 +333,130 @@ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_write_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; - // Get the conidx - uint8_t conidx = KE_IDX_GET(src_id); - // Get the address of the environment - struct pasps_env_tag *pasps_env = PRF_ENV_GET(PASPS, pasps); +__STATIC int gattc_write_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; + // Get the conidx + uint8_t conidx = KE_IDX_GET(src_id); + // Get the address of the environment + struct pasps_env_tag *pasps_env = PRF_ENV_GET(PASPS, pasps); - // Check if the connection exists - if (pasps_env->env[conidx] != NULL) - { - /* - * --------------------------------------------------------------------------------------------- - * Alert Status Client Characteristic Configuration Descriptor Value - Write - * --------------------------------------------------------------------------------------------- - * Ringer Setting Client Characteristic Configuration Descriptor Value - Write - * --------------------------------------------------------------------------------------------- - */ - if ((param->handle == (pasps_env->shdl + PASS_IDX_ALERT_STATUS_CFG)) || - (param->handle == (pasps_env->shdl + PASS_IDX_RINGER_SETTING_CFG))) - { - // Received configuration value - uint16_t ntf_cfg = co_read16p(¶m->value[0]); + // Check if the connection exists + if (pasps_env->env[conidx] != NULL) { + /* + * --------------------------------------------------------------------------------------------- + * Alert Status Client Characteristic Configuration Descriptor Value - Write + * --------------------------------------------------------------------------------------------- + * Ringer Setting Client Characteristic Configuration Descriptor Value - + * Write + * --------------------------------------------------------------------------------------------- + */ + if ((param->handle == (pasps_env->shdl + PASS_IDX_ALERT_STATUS_CFG)) || + (param->handle == (pasps_env->shdl + PASS_IDX_RINGER_SETTING_CFG))) { + // Received configuration value + uint16_t ntf_cfg = co_read16p(¶m->value[0]); - if ((ntf_cfg == PRF_CLI_STOP_NTFIND) || (ntf_cfg == PRF_CLI_START_NTF)) - { - struct pasps_written_char_val_ind *ind = KE_MSG_ALLOC(PASPS_WRITTEN_CHAR_VAL_IND, - prf_dst_task_get(&pasps_env->prf_env, conidx), - prf_src_task_get(&pasps_env->prf_env, conidx), - pasps_written_char_val_ind); + if ((ntf_cfg == PRF_CLI_STOP_NTFIND) || (ntf_cfg == PRF_CLI_START_NTF)) { + struct pasps_written_char_val_ind *ind = + KE_MSG_ALLOC(PASPS_WRITTEN_CHAR_VAL_IND, + prf_dst_task_get(&pasps_env->prf_env, conidx), + prf_src_task_get(&pasps_env->prf_env, conidx), + pasps_written_char_val_ind); - if (param->handle == pasps_env->shdl + PASS_IDX_ALERT_STATUS_CFG) - { - ind->value.alert_status_ntf_cfg = ntf_cfg; - ind->att_code = PASPS_ALERT_STATUS_NTF_CFG; + if (param->handle == pasps_env->shdl + PASS_IDX_ALERT_STATUS_CFG) { + ind->value.alert_status_ntf_cfg = ntf_cfg; + ind->att_code = PASPS_ALERT_STATUS_NTF_CFG; - if (ntf_cfg == PRF_CLI_STOP_NTFIND) - { - PASPS_DISABLE_NTF(conidx, pasps_env, PASPS_FLAG_ALERT_STATUS_CFG); - } - else - { - PASPS_ENABLE_NTF(conidx, pasps_env, PASPS_FLAG_ALERT_STATUS_CFG); - } - } - else - { - ind->value.ringer_setting_ntf_cfg = ntf_cfg; - ind->att_code = PASPS_RINGER_SETTING_NTF_CFG; + if (ntf_cfg == PRF_CLI_STOP_NTFIND) { + PASPS_DISABLE_NTF(conidx, pasps_env, PASPS_FLAG_ALERT_STATUS_CFG); + } else { + PASPS_ENABLE_NTF(conidx, pasps_env, PASPS_FLAG_ALERT_STATUS_CFG); + } + } else { + ind->value.ringer_setting_ntf_cfg = ntf_cfg; + ind->att_code = PASPS_RINGER_SETTING_NTF_CFG; - if (ntf_cfg == PRF_CLI_STOP_NTFIND) - { - PASPS_DISABLE_NTF(conidx, pasps_env, PASPS_FLAG_RINGER_SETTING_CFG); - } - else - { - PASPS_ENABLE_NTF(conidx, pasps_env, PASPS_FLAG_RINGER_SETTING_CFG); - } - } - - ke_msg_send(ind); - - // Enable Bonded Data - PASPS_ENABLE_NTF(conidx, pasps_env, PASPS_FLAG_CFG_PERFORMED_OK); - } - else - { - status = PRF_APP_ERROR; - } + if (ntf_cfg == PRF_CLI_STOP_NTFIND) { + PASPS_DISABLE_NTF(conidx, pasps_env, PASPS_FLAG_RINGER_SETTING_CFG); + } else { + PASPS_ENABLE_NTF(conidx, pasps_env, PASPS_FLAG_RINGER_SETTING_CFG); + } } - /* - * --------------------------------------------------------------------------------------------- - * Ringer Control Point Characteristic Value - Write Without Response - * --------------------------------------------------------------------------------------------- - */ - else if (param->handle == (pasps_env->shdl + PASS_IDX_RINGER_CTNL_PT_VAL)) - { - // Inform the HL ? - bool inform_hl = false; - // Check the received value - switch (param->value[0]) - { - case (PASP_SILENT_MODE): - { - // Ignore if ringer is already silent - if (pasps_env->env[conidx]->ringer_state == PASP_RINGER_NORMAL) - { - inform_hl = true; - } - } break; + ke_msg_send(ind); - case (PASP_CANCEL_SILENT_MODE): - { - // Ignore if ringer is not silent - if (pasps_env->env[conidx]->ringer_state == PASP_RINGER_SILENT) - { - inform_hl = true; - } - } break; - - case (PASP_MUTE_ONCE): - { - inform_hl = true; - } break; - - // No need to respond with an error (Write Without Response) - default: break; - } - - if (inform_hl) - { - struct pasps_written_char_val_ind *ind = KE_MSG_ALLOC(PASPS_WRITTEN_CHAR_VAL_IND, - prf_dst_task_get(&pasps_env->prf_env, conidx), - prf_src_task_get(&pasps_env->prf_env, conidx), - pasps_written_char_val_ind); - - ind->att_code = PASPS_RINGER_CTNL_PT_CHAR_VAL; - ind->value.ringer_ctnl_pt = param->value[0]; - - ke_msg_send(ind); - } - } - // Send the write response to the peer device - struct gattc_write_cfm *cfm = KE_MSG_ALLOC( - GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = status; - ke_msg_send(cfm); + // Enable Bonded Data + PASPS_ENABLE_NTF(conidx, pasps_env, PASPS_FLAG_CFG_PERFORMED_OK); + } else { + status = PRF_APP_ERROR; + } } - // else ignore the message + /* + * --------------------------------------------------------------------------------------------- + * Ringer Control Point Characteristic Value - Write Without Response + * --------------------------------------------------------------------------------------------- + */ + else if (param->handle == (pasps_env->shdl + PASS_IDX_RINGER_CTNL_PT_VAL)) { + // Inform the HL ? + bool inform_hl = false; - return (KE_MSG_CONSUMED); + // Check the received value + switch (param->value[0]) { + case (PASP_SILENT_MODE): { + // Ignore if ringer is already silent + if (pasps_env->env[conidx]->ringer_state == PASP_RINGER_NORMAL) { + inform_hl = true; + } + } break; + + case (PASP_CANCEL_SILENT_MODE): { + // Ignore if ringer is not silent + if (pasps_env->env[conidx]->ringer_state == PASP_RINGER_SILENT) { + inform_hl = true; + } + } break; + + case (PASP_MUTE_ONCE): { + inform_hl = true; + } break; + + // No need to respond with an error (Write Without Response) + default: + break; + } + + if (inform_hl) { + struct pasps_written_char_val_ind *ind = + KE_MSG_ALLOC(PASPS_WRITTEN_CHAR_VAL_IND, + prf_dst_task_get(&pasps_env->prf_env, conidx), + prf_src_task_get(&pasps_env->prf_env, conidx), + pasps_written_char_val_ind); + + ind->att_code = PASPS_RINGER_CTNL_PT_CHAR_VAL; + ind->value.ringer_ctnl_pt = param->value[0]; + + ke_msg_send(ind); + } + } + // Send the write response to the peer device + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = status; + ke_msg_send(cfm); + } + // else ignore the message + + return (KE_MSG_CONSUMED); } /** **************************************************************************************** - * @brief Handles @ref GATTC_CMP_EVT message meaning that a notification or an indication - * has been correctly sent to peer device (but not confirmed by peer device). + * @brief Handles @ref GATTC_CMP_EVT message meaning that a notification or an + *indication has been correctly sent to peer device (but not confirmed by peer + *device). * * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. @@ -515,23 +465,23 @@ __STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - // Get the address of the environment - struct pasps_env_tag *pasps_env = PRF_ENV_GET(PASPS, pasps); - uint8_t conidx = KE_IDX_GET(src_id); +__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct pasps_env_tag *pasps_env = PRF_ENV_GET(PASPS, pasps); + uint8_t conidx = KE_IDX_GET(src_id); - if (pasps_env != NULL) - { - // Send a complete event status to the application - pasps_send_cmp_evt(prf_src_task_get(&pasps_env->prf_env, conidx), - prf_dst_task_get(&pasps_env->prf_env, conidx), - pasps_env->operation, param->status); - } - // else ignore the message + if (pasps_env != NULL) { + // Send a complete event status to the application + pasps_send_cmp_evt(prf_src_task_get(&pasps_env->prf_env, conidx), + prf_dst_task_get(&pasps_env->prf_env, conidx), + pasps_env->operation, param->status); + } + // else ignore the message - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /* @@ -540,25 +490,24 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_ev */ /// Specifies the default message handlers -KE_MSG_HANDLER_TAB(pasps) -{ - {PASPS_ENABLE_REQ, (ke_msg_func_t) pasps_enable_req_handler}, - {PASPS_UPDATE_CHAR_VAL_CMD, (ke_msg_func_t) pasps_update_char_val_cmd_handler}, - {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t) gattc_att_info_req_ind_handler}, - {GATTC_READ_REQ_IND, (ke_msg_func_t) gattc_read_req_ind_handler}, - {GATTC_WRITE_REQ_IND, (ke_msg_func_t) gattc_write_req_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t) gattc_cmp_evt_handler}, +KE_MSG_HANDLER_TAB(pasps){ + {PASPS_ENABLE_REQ, (ke_msg_func_t)pasps_enable_req_handler}, + {PASPS_UPDATE_CHAR_VAL_CMD, + (ke_msg_func_t)pasps_update_char_val_cmd_handler}, + {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t)gattc_att_info_req_ind_handler}, + {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, + {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void pasps_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct pasps_env_tag *pasps_env = PRF_ENV_GET(PASPS, pasps); +void pasps_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct pasps_env_tag *pasps_env = PRF_ENV_GET(PASPS, pasps); - task_desc->msg_handler_tab = pasps_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(pasps_msg_handler_tab); - task_desc->state = pasps_env->state; - task_desc->idx_max = PASPS_IDX_MAX; + task_desc->msg_handler_tab = pasps_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(pasps_msg_handler_tab); + task_desc->state = pasps_env->state; + task_desc->idx_max = PASPS_IDX_MAX; } #endif //(BLE_PASS_SERVER) diff --git a/services/ble_profiles/prf/prf.c b/services/ble_profiles/prf/prf.c index b259bdc..51e85a5 100644 --- a/services/ble_profiles/prf/prf.c +++ b/services/ble_profiles/prf/prf.c @@ -13,238 +13,236 @@ #include "rwip_config.h" #if (BLE_PROFILES) -#include "prf.h" #include "att.h" - +#include "prf.h" #if (BLE_HT_THERMOM) -extern const struct prf_task_cbs* htpt_prf_itf_get(void); +extern const struct prf_task_cbs *htpt_prf_itf_get(void); #endif // (BLE_HT_THERMOM) #if (BLE_HT_COLLECTOR) -extern const struct prf_task_cbs* htpc_prf_itf_get(void); +extern const struct prf_task_cbs *htpc_prf_itf_get(void); #endif // (BLE_HT_COLLECTOR) #if (BLE_DIS_SERVER) -extern const struct prf_task_cbs* diss_prf_itf_get(void); +extern const struct prf_task_cbs *diss_prf_itf_get(void); #endif // (BLE_HT_THERMOM) #if (BLE_DIS_CLIENT) -extern const struct prf_task_cbs* disc_prf_itf_get(void); +extern const struct prf_task_cbs *disc_prf_itf_get(void); #endif // (BLE_DIS_CLIENT) #if (BLE_BP_SENSOR) -extern const struct prf_task_cbs* blps_prf_itf_get(void); +extern const struct prf_task_cbs *blps_prf_itf_get(void); #endif // (BLE_BP_SENSOR) #if (BLE_BP_COLLECTOR) -extern const struct prf_task_cbs* blpc_prf_itf_get(void); +extern const struct prf_task_cbs *blpc_prf_itf_get(void); #endif // (BLE_BP_COLLECTOR) #if (BLE_TIP_SERVER) -extern const struct prf_task_cbs* tips_prf_itf_get(void); +extern const struct prf_task_cbs *tips_prf_itf_get(void); #endif // (BLE_TIP_SERVER) #if (BLE_TIP_CLIENT) -extern const struct prf_task_cbs* tipc_prf_itf_get(void); +extern const struct prf_task_cbs *tipc_prf_itf_get(void); #endif // (BLE_TIP_CLIENT) #if (BLE_HR_SENSOR) -extern const struct prf_task_cbs* hrps_prf_itf_get(void); +extern const struct prf_task_cbs *hrps_prf_itf_get(void); #endif // (BLE_HR_SENSOR) #if (BLE_HR_COLLECTOR) -extern const struct prf_task_cbs* hrpc_prf_itf_get(void); +extern const struct prf_task_cbs *hrpc_prf_itf_get(void); #endif // (BLE_HR_COLLECTOR) #if (BLE_FINDME_LOCATOR) -extern const struct prf_task_cbs* findl_prf_itf_get(void); +extern const struct prf_task_cbs *findl_prf_itf_get(void); #endif // (BLE_FINDME_LOCATOR) #if (BLE_FINDME_TARGET) -extern const struct prf_task_cbs* findt_prf_itf_get(void); +extern const struct prf_task_cbs *findt_prf_itf_get(void); #endif // (BLE_FINDME_TARGET) #if (BLE_PROX_MONITOR) -extern const struct prf_task_cbs* proxm_prf_itf_get(void); +extern const struct prf_task_cbs *proxm_prf_itf_get(void); #endif // (BLE_PROX_MONITOR) #if (BLE_PROX_REPORTER) -extern const struct prf_task_cbs* proxr_prf_itf_get(void); +extern const struct prf_task_cbs *proxr_prf_itf_get(void); #endif // (BLE_PROX_REPORTER) #if (BLE_SP_CLIENT) -extern const struct prf_task_cbs* scppc_prf_itf_get(void); +extern const struct prf_task_cbs *scppc_prf_itf_get(void); #endif // (BLE_SP_CLENT) #if (BLE_SP_SERVER) -extern const struct prf_task_cbs* scpps_prf_itf_get(void); +extern const struct prf_task_cbs *scpps_prf_itf_get(void); #endif // (BLE_SP_SERVER) #if (BLE_BATT_CLIENT) -extern const struct prf_task_cbs* basc_prf_itf_get(void); +extern const struct prf_task_cbs *basc_prf_itf_get(void); #endif // (BLE_BATT_CLIENT) #if (BLE_BATT_SERVER) -extern const struct prf_task_cbs* bass_prf_itf_get(void); +extern const struct prf_task_cbs *bass_prf_itf_get(void); #endif // (BLE_BATT_SERVER) #if (BLE_HID_DEVICE) -extern const struct prf_task_cbs* hogpd_prf_itf_get(void); +extern const struct prf_task_cbs *hogpd_prf_itf_get(void); #endif // (BLE_HID_DEVICE) #if (BLE_HID_BOOT_HOST) -extern const struct prf_task_cbs* hogpbh_prf_itf_get(void); +extern const struct prf_task_cbs *hogpbh_prf_itf_get(void); #endif // (BLE_HID_BOOT_HOST) #if (BLE_HID_REPORT_HOST) -extern const struct prf_task_cbs* hogprh_prf_itf_get(void); +extern const struct prf_task_cbs *hogprh_prf_itf_get(void); #endif // (BLE_HID_REPORT_HOST) #if (BLE_GL_COLLECTOR) -extern const struct prf_task_cbs* glpc_prf_itf_get(void); +extern const struct prf_task_cbs *glpc_prf_itf_get(void); #endif // (BLE_GL_COLLECTOR) #if (BLE_GL_SENSOR) -extern const struct prf_task_cbs* glps_prf_itf_get(void); +extern const struct prf_task_cbs *glps_prf_itf_get(void); #endif // (BLE_GL_SENSOR) #if (BLE_RSC_COLLECTOR) -extern const struct prf_task_cbs* rscpc_prf_itf_get(void); +extern const struct prf_task_cbs *rscpc_prf_itf_get(void); #endif // (BLE_RSC_COLLECTOR) #if (BLE_RSC_SENSOR) -extern const struct prf_task_cbs* rscps_prf_itf_get(void); +extern const struct prf_task_cbs *rscps_prf_itf_get(void); #endif // (BLE_RSC_COLLECTOR) #if (BLE_CSC_COLLECTOR) -extern const struct prf_task_cbs* cscpc_prf_itf_get(void); +extern const struct prf_task_cbs *cscpc_prf_itf_get(void); #endif // (BLE_CSC_COLLECTOR) #if (BLE_CSC_SENSOR) -extern const struct prf_task_cbs* cscps_prf_itf_get(void); +extern const struct prf_task_cbs *cscps_prf_itf_get(void); #endif // (BLE_CSC_COLLECTOR) #if (BLE_AN_CLIENT) -extern const struct prf_task_cbs* anpc_prf_itf_get(void); +extern const struct prf_task_cbs *anpc_prf_itf_get(void); #endif // (BLE_AN_CLIENT) #if (BLE_AN_SERVER) -extern const struct prf_task_cbs* anps_prf_itf_get(void); +extern const struct prf_task_cbs *anps_prf_itf_get(void); #endif // (BLE_AN_SERVER) #if (BLE_PAS_CLIENT) -extern const struct prf_task_cbs* paspc_prf_itf_get(void); +extern const struct prf_task_cbs *paspc_prf_itf_get(void); #endif // (BLE_PAS_CLIENT) #if (BLE_PAS_SERVER) -extern const struct prf_task_cbs* pasps_prf_itf_get(void); +extern const struct prf_task_cbs *pasps_prf_itf_get(void); #endif // (BLE_PAS_SERVER) #if (BLE_CP_COLLECTOR) -extern const struct prf_task_cbs* cppc_prf_itf_get(void); +extern const struct prf_task_cbs *cppc_prf_itf_get(void); #endif //(BLE_CP_COLLECTOR) #if (BLE_CP_SENSOR) -extern const struct prf_task_cbs* cpps_prf_itf_get(void); +extern const struct prf_task_cbs *cpps_prf_itf_get(void); #endif //(BLE_CP_SENSOR) #if (BLE_LN_COLLECTOR) -extern const struct prf_task_cbs* lanc_prf_itf_get(void); +extern const struct prf_task_cbs *lanc_prf_itf_get(void); #endif //(BLE_CP_COLLECTOR) #if (BLE_LN_SENSOR) -extern const struct prf_task_cbs* lans_prf_itf_get(void); +extern const struct prf_task_cbs *lans_prf_itf_get(void); #endif //(BLE_CP_SENSOR) #if (BLE_IPS_SERVER) -extern const struct prf_task_cbs* ipss_prf_itf_get(void); +extern const struct prf_task_cbs *ipss_prf_itf_get(void); #endif //(BLE_IPS_SERVER) #if (BLE_IPS_CLIENT) -extern const struct prf_task_cbs* ipsc_prf_itf_get(void); +extern const struct prf_task_cbs *ipsc_prf_itf_get(void); #endif //(BLE_IPS_CLIENT) #if (BLE_ENV_SERVER) -extern const struct prf_task_cbs* envs_prf_itf_get(void); +extern const struct prf_task_cbs *envs_prf_itf_get(void); #endif //(BLE_ENV_SERVER) #if (BLE_ENV_CLIENT) -extern const struct prf_task_cbs* envc_prf_itf_get(void); +extern const struct prf_task_cbs *envc_prf_itf_get(void); #endif //(BLE_ENV_CLIENT #if (BLE_WSC_SERVER) -extern const struct prf_task_cbs* wscs_prf_itf_get(void); +extern const struct prf_task_cbs *wscs_prf_itf_get(void); #endif //(BLE_WSC_SERVER) #if (BLE_WSC_CLIENT) -extern const struct prf_task_cbs* wscc_prf_itf_get(void); +extern const struct prf_task_cbs *wscc_prf_itf_get(void); #endif //(BLE_WSC_CLIENT #if (BLE_BCS_SERVER) -extern const struct prf_task_cbs* bcss_prf_itf_get(void); +extern const struct prf_task_cbs *bcss_prf_itf_get(void); #endif //(BLE_BCS_SERVER) #if (BLE_BCS_CLIENT) -extern const struct prf_task_cbs* bcsc_prf_itf_get(void); +extern const struct prf_task_cbs *bcsc_prf_itf_get(void); #endif //(BLE_BCS_CLIENT) #ifdef BLE_AM0_HEARING_AID_SERV -extern const struct prf_task_cbs* am0_has_prf_itf_get(void); +extern const struct prf_task_cbs *am0_has_prf_itf_get(void); #endif // BLE_AM0_HEARING_AID_SERV #if (BLE_UDS_SERVER) -extern const struct prf_task_cbs* udss_prf_itf_get(void); +extern const struct prf_task_cbs *udss_prf_itf_get(void); #endif //(BLE_UDS_SERVER) #if (BLE_UDS_CLIENT) -extern const struct prf_task_cbs* udsc_prf_itf_get(void); +extern const struct prf_task_cbs *udsc_prf_itf_get(void); #endif //(BLE_UDS_CLIENT) #if (BLE_VOICEPATH) -extern const struct prf_task_cbs* voicepath_prf_itf_get(void); +extern const struct prf_task_cbs *voicepath_prf_itf_get(void); #endif //(BLE_VOICEPATH) #if (BLE_DATAPATH_SERVER) -extern const struct prf_task_cbs* datapathps_prf_itf_get(void); +extern const struct prf_task_cbs *datapathps_prf_itf_get(void); #endif //(BLE_DATAPATH_SERVER) #if (BLE_OTA) -extern const struct prf_task_cbs* ota_prf_itf_get(void); +extern const struct prf_task_cbs *ota_prf_itf_get(void); #endif //(BLE_OTA) #if (BLE_TOTA) -extern const struct prf_task_cbs* tota_prf_itf_get(void); +extern const struct prf_task_cbs *tota_prf_itf_get(void); #endif //(BLE_TOTA) #if (BLE_BMS) -extern const struct prf_task_cbs* bms_prf_itf_get(void); +extern const struct prf_task_cbs *bms_prf_itf_get(void); #endif //(BLE_BMS) - #if (BLE_ANC_CLIENT) -extern const struct prf_task_cbs* ancc_prf_itf_get(void); +extern const struct prf_task_cbs *ancc_prf_itf_get(void); #endif //(BLE_ANC_CLIENT) #if (BLE_AMS_CLIENT) -extern const struct prf_task_cbs* amsc_prf_itf_get(void); +extern const struct prf_task_cbs *amsc_prf_itf_get(void); #endif //(BLE_AMS_CLIENT) #if (BLE_GFPS_PROVIDER) -extern const struct prf_task_cbs* gfpsp_prf_itf_get(void); +extern const struct prf_task_cbs *gfpsp_prf_itf_get(void); #endif //(BLE_GFPS_PROVIDER) #ifdef BLE_AI_VOICE -extern const struct prf_task_cbs* ai_prf_itf_get(void); +extern const struct prf_task_cbs *ai_prf_itf_get(void); #endif #if (ANCS_PROXY_ENABLE) -extern const struct prf_task_cbs* ancs_proxy_prf_itf_get(void); -extern const struct prf_task_cbs* ams_proxy_prf_itf_get(void); +extern const struct prf_task_cbs *ancs_proxy_prf_itf_get(void); +extern const struct prf_task_cbs *ams_proxy_prf_itf_get(void); #endif #if (BLE_TILE) -extern const struct prf_task_cbs* tile_prf_itf_get(void); +extern const struct prf_task_cbs *tile_prf_itf_get(void); #endif //(BLE_TILE) /* @@ -252,7 +250,6 @@ extern const struct prf_task_cbs* tile_prf_itf_get(void); **************************************************************************************** */ - /* * DEFINES **************************************************************************************** @@ -263,7 +260,6 @@ extern const struct prf_task_cbs* tile_prf_itf_get(void); **************************************************************************************** */ - /* * GLOBAL VARIABLE DEFINITIONS **************************************************************************************** @@ -280,615 +276,573 @@ struct prf_env_tag prf_env; * @brief Retrieve profile interface **************************************************************************************** */ -static const struct prf_task_cbs * prf_itf_get(uint16_t task_id) -{ - const struct prf_task_cbs* prf_cbs = NULL; +static const struct prf_task_cbs *prf_itf_get(uint16_t task_id) { + const struct prf_task_cbs *prf_cbs = NULL; - BLE_DBG(">>>>>> prf_itf_get task_id: %d task_id %d<<<<<<\n", KE_TYPE_GET(task_id), task_id); - switch(KE_TYPE_GET(task_id)) - { - #if (BLE_HT_THERMOM) - case TASK_ID_HTPT: - prf_cbs = htpt_prf_itf_get(); - break; - #endif // (BLE_HT_THERMOM) + BLE_DBG(">>>>>> prf_itf_get task_id: %d task_id %d<<<<<<\n", + KE_TYPE_GET(task_id), task_id); + switch (KE_TYPE_GET(task_id)) { +#if (BLE_HT_THERMOM) + case TASK_ID_HTPT: + prf_cbs = htpt_prf_itf_get(); + break; +#endif // (BLE_HT_THERMOM) - #if (BLE_HT_COLLECTOR) - case TASK_ID_HTPC: - prf_cbs = htpc_prf_itf_get(); - break; - #endif // (BLE_HT_COLLECTOR) +#if (BLE_HT_COLLECTOR) + case TASK_ID_HTPC: + prf_cbs = htpc_prf_itf_get(); + break; +#endif // (BLE_HT_COLLECTOR) - #if (BLE_DIS_SERVER) - case TASK_ID_DISS: - prf_cbs = diss_prf_itf_get(); - break; - #endif // (BLE_DIS_SERVER) +#if (BLE_DIS_SERVER) + case TASK_ID_DISS: + prf_cbs = diss_prf_itf_get(); + break; +#endif // (BLE_DIS_SERVER) - #if (BLE_DIS_CLIENT) - case TASK_ID_DISC: - prf_cbs = disc_prf_itf_get(); - break; - #endif // (BLE_DIS_CLIENT) +#if (BLE_DIS_CLIENT) + case TASK_ID_DISC: + prf_cbs = disc_prf_itf_get(); + break; +#endif // (BLE_DIS_CLIENT) - #if (BLE_BP_SENSOR) - case TASK_ID_BLPS: - prf_cbs = blps_prf_itf_get(); - break; - #endif // (BLE_BP_SENSOR) +#if (BLE_BP_SENSOR) + case TASK_ID_BLPS: + prf_cbs = blps_prf_itf_get(); + break; +#endif // (BLE_BP_SENSOR) - #if (BLE_BP_COLLECTOR) - case TASK_ID_BLPC: - prf_cbs = blpc_prf_itf_get(); - break; - #endif // (BLE_BP_COLLECTOR) +#if (BLE_BP_COLLECTOR) + case TASK_ID_BLPC: + prf_cbs = blpc_prf_itf_get(); + break; +#endif // (BLE_BP_COLLECTOR) - #if (BLE_TIP_SERVER) - case TASK_ID_TIPS: - prf_cbs = tips_prf_itf_get(); - break; - #endif // (BLE_TIP_SERVER) +#if (BLE_TIP_SERVER) + case TASK_ID_TIPS: + prf_cbs = tips_prf_itf_get(); + break; +#endif // (BLE_TIP_SERVER) - #if (BLE_TIP_CLIENT) - case TASK_ID_TIPC: - prf_cbs = tipc_prf_itf_get(); - break; - #endif // (BLE_TIP_CLIENT) +#if (BLE_TIP_CLIENT) + case TASK_ID_TIPC: + prf_cbs = tipc_prf_itf_get(); + break; +#endif // (BLE_TIP_CLIENT) - #if (BLE_HR_SENSOR) - case TASK_ID_HRPS: - prf_cbs = hrps_prf_itf_get(); - break; - #endif // (BLE_HR_SENSOR) +#if (BLE_HR_SENSOR) + case TASK_ID_HRPS: + prf_cbs = hrps_prf_itf_get(); + break; +#endif // (BLE_HR_SENSOR) - #if (BLE_HR_COLLECTOR) - case TASK_ID_HRPC: - prf_cbs = hrpc_prf_itf_get(); - break; - #endif // (BLE_HR_COLLECTOR) +#if (BLE_HR_COLLECTOR) + case TASK_ID_HRPC: + prf_cbs = hrpc_prf_itf_get(); + break; +#endif // (BLE_HR_COLLECTOR) - #if (BLE_FINDME_LOCATOR) - case TASK_ID_FINDL: - prf_cbs = findl_prf_itf_get(); - break; - #endif // (BLE_FINDME_LOCATOR) +#if (BLE_FINDME_LOCATOR) + case TASK_ID_FINDL: + prf_cbs = findl_prf_itf_get(); + break; +#endif // (BLE_FINDME_LOCATOR) - #if (BLE_FINDME_TARGET) - case TASK_ID_FINDT: - prf_cbs = findt_prf_itf_get(); - break; - #endif // (BLE_FINDME_TARGET) +#if (BLE_FINDME_TARGET) + case TASK_ID_FINDT: + prf_cbs = findt_prf_itf_get(); + break; +#endif // (BLE_FINDME_TARGET) - #if (BLE_PROX_MONITOR) - case TASK_ID_PROXM: - prf_cbs = proxm_prf_itf_get(); - break; - #endif // (BLE_PROX_MONITOR) +#if (BLE_PROX_MONITOR) + case TASK_ID_PROXM: + prf_cbs = proxm_prf_itf_get(); + break; +#endif // (BLE_PROX_MONITOR) - #if (BLE_PROX_REPORTER) - case TASK_ID_PROXR: - prf_cbs = proxr_prf_itf_get(); - break; - #endif // (BLE_PROX_REPORTER) +#if (BLE_PROX_REPORTER) + case TASK_ID_PROXR: + prf_cbs = proxr_prf_itf_get(); + break; +#endif // (BLE_PROX_REPORTER) - #if (BLE_SP_SERVER) - case TASK_ID_SCPPS: - prf_cbs = scpps_prf_itf_get(); - break; - #endif // (BLE_SP_SERVER) +#if (BLE_SP_SERVER) + case TASK_ID_SCPPS: + prf_cbs = scpps_prf_itf_get(); + break; +#endif // (BLE_SP_SERVER) - #if (BLE_SP_CLIENT) - case TASK_ID_SCPPC: - prf_cbs = scppc_prf_itf_get(); - break; - #endif // (BLE_SP_CLIENT) +#if (BLE_SP_CLIENT) + case TASK_ID_SCPPC: + prf_cbs = scppc_prf_itf_get(); + break; +#endif // (BLE_SP_CLIENT) - #if (BLE_BATT_SERVER) - case TASK_ID_BASS: - prf_cbs = bass_prf_itf_get(); - break; - #endif // (BLE_BATT_SERVER) +#if (BLE_BATT_SERVER) + case TASK_ID_BASS: + prf_cbs = bass_prf_itf_get(); + break; +#endif // (BLE_BATT_SERVER) - #if (BLE_BATT_CLIENT) - case TASK_ID_BASC: - prf_cbs = basc_prf_itf_get(); - break; - #endif // (BLE_BATT_CLIENT) +#if (BLE_BATT_CLIENT) + case TASK_ID_BASC: + prf_cbs = basc_prf_itf_get(); + break; +#endif // (BLE_BATT_CLIENT) - #if (BLE_HID_DEVICE) - case TASK_ID_HOGPD: - prf_cbs = hogpd_prf_itf_get(); - break; - #endif // (BLE_HID_DEVICE) +#if (BLE_HID_DEVICE) + case TASK_ID_HOGPD: + prf_cbs = hogpd_prf_itf_get(); + break; +#endif // (BLE_HID_DEVICE) - #if (BLE_HID_BOOT_HOST) - case TASK_ID_HOGPBH: - prf_cbs = hogpbh_prf_itf_get(); - break; - #endif // (BLE_HID_BOOT_HOST) +#if (BLE_HID_BOOT_HOST) + case TASK_ID_HOGPBH: + prf_cbs = hogpbh_prf_itf_get(); + break; +#endif // (BLE_HID_BOOT_HOST) - #if (BLE_HID_REPORT_HOST) - case TASK_ID_HOGPRH: - prf_cbs = hogprh_prf_itf_get(); - break; - #endif // (BLE_HID_REPORT_HOST) +#if (BLE_HID_REPORT_HOST) + case TASK_ID_HOGPRH: + prf_cbs = hogprh_prf_itf_get(); + break; +#endif // (BLE_HID_REPORT_HOST) - #if (BLE_GL_COLLECTOR) - case TASK_ID_GLPC: - prf_cbs = glpc_prf_itf_get(); - break; - #endif // (BLE_GL_COLLECTOR) +#if (BLE_GL_COLLECTOR) + case TASK_ID_GLPC: + prf_cbs = glpc_prf_itf_get(); + break; +#endif // (BLE_GL_COLLECTOR) - #if (BLE_GL_SENSOR) - case TASK_ID_GLPS: - prf_cbs = glps_prf_itf_get(); - break; - #endif // (BLE_GL_SENSOR) +#if (BLE_GL_SENSOR) + case TASK_ID_GLPS: + prf_cbs = glps_prf_itf_get(); + break; +#endif // (BLE_GL_SENSOR) - #if (BLE_RSC_COLLECTOR) - case TASK_ID_RSCPC: - prf_cbs = rscpc_prf_itf_get(); - break; - #endif // (BLE_RSC_COLLECTOR) +#if (BLE_RSC_COLLECTOR) + case TASK_ID_RSCPC: + prf_cbs = rscpc_prf_itf_get(); + break; +#endif // (BLE_RSC_COLLECTOR) - #if (BLE_RSC_SENSOR) - case TASK_ID_RSCPS: - prf_cbs = rscps_prf_itf_get(); - break; - #endif // (BLE_RSC_SENSOR) +#if (BLE_RSC_SENSOR) + case TASK_ID_RSCPS: + prf_cbs = rscps_prf_itf_get(); + break; +#endif // (BLE_RSC_SENSOR) - #if (BLE_CSC_COLLECTOR) - case TASK_ID_CSCPC: - prf_cbs = cscpc_prf_itf_get(); - break; - #endif // (BLE_CSC_COLLECTOR) +#if (BLE_CSC_COLLECTOR) + case TASK_ID_CSCPC: + prf_cbs = cscpc_prf_itf_get(); + break; +#endif // (BLE_CSC_COLLECTOR) - #if (BLE_CSC_SENSOR) - case TASK_ID_CSCPS: - prf_cbs = cscps_prf_itf_get(); - break; - #endif // (BLE_CSC_SENSOR) +#if (BLE_CSC_SENSOR) + case TASK_ID_CSCPS: + prf_cbs = cscps_prf_itf_get(); + break; +#endif // (BLE_CSC_SENSOR) - #if (BLE_CP_COLLECTOR) - case TASK_ID_CPPC: - prf_cbs = cppc_prf_itf_get(); - break; - #endif // (BLE_CP_COLLECTOR) +#if (BLE_CP_COLLECTOR) + case TASK_ID_CPPC: + prf_cbs = cppc_prf_itf_get(); + break; +#endif // (BLE_CP_COLLECTOR) - #if (BLE_CP_SENSOR) - case TASK_ID_CPPS: - prf_cbs = cpps_prf_itf_get(); - break; - #endif // (BLE_CP_SENSOR) +#if (BLE_CP_SENSOR) + case TASK_ID_CPPS: + prf_cbs = cpps_prf_itf_get(); + break; +#endif // (BLE_CP_SENSOR) - #if (BLE_LN_COLLECTOR) - case TASK_ID_LANC: - prf_cbs = lanc_prf_itf_get(); - break; - #endif // (BLE_LN_COLLECTOR) +#if (BLE_LN_COLLECTOR) + case TASK_ID_LANC: + prf_cbs = lanc_prf_itf_get(); + break; +#endif // (BLE_LN_COLLECTOR) - #if (BLE_LN_SENSOR) - case TASK_ID_LANS: - prf_cbs = lans_prf_itf_get(); - break; - #endif // (BLE_LN_SENSOR) +#if (BLE_LN_SENSOR) + case TASK_ID_LANS: + prf_cbs = lans_prf_itf_get(); + break; +#endif // (BLE_LN_SENSOR) - #if (BLE_AN_CLIENT) - case TASK_ID_ANPC: - prf_cbs = anpc_prf_itf_get(); - break; - #endif // (BLE_AN_CLIENT) +#if (BLE_AN_CLIENT) + case TASK_ID_ANPC: + prf_cbs = anpc_prf_itf_get(); + break; +#endif // (BLE_AN_CLIENT) - #if (BLE_AN_SERVER) - case TASK_ID_ANPS: - prf_cbs = anps_prf_itf_get(); - break; - #endif // (BLE_AN_SERVER) +#if (BLE_AN_SERVER) + case TASK_ID_ANPS: + prf_cbs = anps_prf_itf_get(); + break; +#endif // (BLE_AN_SERVER) - #if (BLE_PAS_CLIENT) - case TASK_ID_PASPC: - prf_cbs = paspc_prf_itf_get(); - break; - #endif // (BLE_PAS_CLIENT) +#if (BLE_PAS_CLIENT) + case TASK_ID_PASPC: + prf_cbs = paspc_prf_itf_get(); + break; +#endif // (BLE_PAS_CLIENT) - #if (BLE_PAS_SERVER) - case TASK_ID_PASPS: - prf_cbs = pasps_prf_itf_get(); - break; - #endif // (BLE_PAS_SERVER) +#if (BLE_PAS_SERVER) + case TASK_ID_PASPS: + prf_cbs = pasps_prf_itf_get(); + break; +#endif // (BLE_PAS_SERVER) - #ifdef BLE_AM0_HEARING_AID_SERV - case TASK_ID_AM0_HAS: - prf_cbs = am0_has_prf_itf_get(); - break; - #endif // defined(BLE_AM0_HEARING_AID_SERV) +#ifdef BLE_AM0_HEARING_AID_SERV + case TASK_ID_AM0_HAS: + prf_cbs = am0_has_prf_itf_get(); + break; +#endif // defined(BLE_AM0_HEARING_AID_SERV) - #if (BLE_IPS_SERVER) - case TASK_ID_IPSS: - prf_cbs = ipss_prf_itf_get(); - break; - #endif //(BLE_IPS_SERVER) +#if (BLE_IPS_SERVER) + case TASK_ID_IPSS: + prf_cbs = ipss_prf_itf_get(); + break; +#endif //(BLE_IPS_SERVER) - #if (BLE_IPS_CLIENT) - case TASK_ID_IPSC: - prf_cbs = ipsc_prf_itf_get(); - break; - #endif //(BLE_IPS_CLIENT) +#if (BLE_IPS_CLIENT) + case TASK_ID_IPSC: + prf_cbs = ipsc_prf_itf_get(); + break; +#endif //(BLE_IPS_CLIENT) - #if (BLE_ENV_SERVER) - case TASK_ID_ENVS: - prf_cbs = envs_prf_itf_get(); - break; - #endif //(BLE_ENV_SERVER) +#if (BLE_ENV_SERVER) + case TASK_ID_ENVS: + prf_cbs = envs_prf_itf_get(); + break; +#endif //(BLE_ENV_SERVER) - #if (BLE_ENV_CLIENT) - case TASK_ID_ENVC: - prf_cbs = envc_prf_itf_get(); - break; - #endif //(BLE_ENV_CLIENT +#if (BLE_ENV_CLIENT) + case TASK_ID_ENVC: + prf_cbs = envc_prf_itf_get(); + break; +#endif //(BLE_ENV_CLIENT - #if (BLE_WSC_SERVER) - case TASK_ID_WSCS: - prf_cbs = wscs_prf_itf_get(); - break; - #endif //(BLE_WSC_SERVER) +#if (BLE_WSC_SERVER) + case TASK_ID_WSCS: + prf_cbs = wscs_prf_itf_get(); + break; +#endif //(BLE_WSC_SERVER) - #if (BLE_WSC_CLIENT) - case TASK_ID_WSCC: - prf_cbs = wscc_prf_itf_get(); - break; - #endif //(BLE_WSC_CLIENT +#if (BLE_WSC_CLIENT) + case TASK_ID_WSCC: + prf_cbs = wscc_prf_itf_get(); + break; +#endif //(BLE_WSC_CLIENT - #if (BLE_BCS_SERVER) - case TASK_ID_BCSS: - prf_cbs = bcss_prf_itf_get(); - break; - #endif //(BLE_BCS_SERVER) +#if (BLE_BCS_SERVER) + case TASK_ID_BCSS: + prf_cbs = bcss_prf_itf_get(); + break; +#endif //(BLE_BCS_SERVER) - #if (BLE_BCS_CLIENT) - case TASK_ID_BCSC: - prf_cbs = bcsc_prf_itf_get(); - break; - #endif //(BLE_BCS_CLIENT) +#if (BLE_BCS_CLIENT) + case TASK_ID_BCSC: + prf_cbs = bcsc_prf_itf_get(); + break; +#endif //(BLE_BCS_CLIENT) - #if (BLE_UDS_SERVER) - case TASK_ID_UDSS: - prf_cbs = udss_prf_itf_get(); - break; - #endif //(BLE_UDS_SERVER) +#if (BLE_UDS_SERVER) + case TASK_ID_UDSS: + prf_cbs = udss_prf_itf_get(); + break; +#endif //(BLE_UDS_SERVER) - #if (BLE_UDS_CLIENT) - case TASK_ID_UDSC: - prf_cbs = udsc_prf_itf_get(); - break; - #endif //(BLE_UDS_CLIENT) +#if (BLE_UDS_CLIENT) + case TASK_ID_UDSC: + prf_cbs = udsc_prf_itf_get(); + break; +#endif //(BLE_UDS_CLIENT) - #if (BLE_VOICEPATH) - case TASK_ID_VOICEPATH: - prf_cbs = voicepath_prf_itf_get(); - break; - #endif //(TASK_ID_VOICEPATH) +#if (BLE_VOICEPATH) + case TASK_ID_VOICEPATH: + prf_cbs = voicepath_prf_itf_get(); + break; +#endif //(TASK_ID_VOICEPATH) - #if (BLE_OTA) - case TASK_ID_OTA: - prf_cbs = ota_prf_itf_get(); - break; - #endif //(BLE_OTA) +#if (BLE_OTA) + case TASK_ID_OTA: + prf_cbs = ota_prf_itf_get(); + break; +#endif //(BLE_OTA) - #if (BLE_TOTA) - case TASK_ID_TOTA: - prf_cbs = tota_prf_itf_get(); - break; - #endif //(BLE_TOTA) +#if (BLE_TOTA) + case TASK_ID_TOTA: + prf_cbs = tota_prf_itf_get(); + break; +#endif //(BLE_TOTA) - #if (BLE_BMS) - case TASK_ID_BMS: - prf_cbs = bms_prf_itf_get(); - break; - #endif //(BLE_BMS) +#if (BLE_BMS) + case TASK_ID_BMS: + prf_cbs = bms_prf_itf_get(); + break; +#endif //(BLE_BMS) - #if (BLE_ANC_CLIENT) - case TASK_ID_ANCC: - prf_cbs = ancc_prf_itf_get(); - break; - #endif //(BLE_ANC_CLIENT) +#if (BLE_ANC_CLIENT) + case TASK_ID_ANCC: + prf_cbs = ancc_prf_itf_get(); + break; +#endif //(BLE_ANC_CLIENT) - #if (BLE_AMS_CLIENT) - case TASK_ID_AMSC: - prf_cbs = amsc_prf_itf_get(); - break; - #endif //(BLE_AMS_CLIENT) +#if (BLE_AMS_CLIENT) + case TASK_ID_AMSC: + prf_cbs = amsc_prf_itf_get(); + break; +#endif //(BLE_AMS_CLIENT) - #if (BLE_TILE) - case TASK_ID_TILE: - prf_cbs = tile_prf_itf_get(); - break; - #endif //(TASK_ID_TILE) +#if (BLE_TILE) + case TASK_ID_TILE: + prf_cbs = tile_prf_itf_get(); + break; +#endif //(TASK_ID_TILE) - #if (ANCS_PROXY_ENABLE) - case TASK_ID_ANCSP: - prf_cbs = ancs_proxy_prf_itf_get(); - break; - case TASK_ID_AMSP: - prf_cbs = ams_proxy_prf_itf_get(); - break; - #endif //(ANCS_PROXY_ENABLE) +#if (ANCS_PROXY_ENABLE) + case TASK_ID_ANCSP: + prf_cbs = ancs_proxy_prf_itf_get(); + break; + case TASK_ID_AMSP: + prf_cbs = ams_proxy_prf_itf_get(); + break; +#endif //(ANCS_PROXY_ENABLE) - #if (BLE_GFPS_PROVIDER) - case TASK_ID_GFPSP: - prf_cbs = gfpsp_prf_itf_get(); - break; - #endif //(BLE_GFPS_PROVIDER) - - #if (BLE_AI_VOICE) - case TASK_ID_AI: - prf_cbs = ai_prf_itf_get(); - break; - #endif //(BLE_AMA) +#if (BLE_GFPS_PROVIDER) + case TASK_ID_GFPSP: + prf_cbs = gfpsp_prf_itf_get(); + break; +#endif //(BLE_GFPS_PROVIDER) - #if (BLE_DATAPATH_SERVER) - case TASK_ID_DATAPATHPS: - prf_cbs = datapathps_prf_itf_get(); - break; - #endif //(BLE_DATAPATH_SERVER) +#if (BLE_AI_VOICE) + case TASK_ID_AI: + prf_cbs = ai_prf_itf_get(); + break; +#endif //(BLE_AMA) - default: /* Nothing to do */ - break; - } +#if (BLE_DATAPATH_SERVER) + case TASK_ID_DATAPATHPS: + prf_cbs = datapathps_prf_itf_get(); + break; +#endif //(BLE_DATAPATH_SERVER) - return prf_cbs; + default: /* Nothing to do */ + break; + } + + return prf_cbs; } /* * EXPORTED FUNCTIONS DEFINITIONS **************************************************************************************** */ -void prf_init(bool reset) -{ - uint8_t i; +void prf_init(bool reset) { + uint8_t i; - BLE_FUNC_ENTER(); + BLE_FUNC_ENTER(); - BLE_DBG(">>>>>> prf_create reset %d<<<<<<\n", reset); - if (!reset) - { - // FW boot profile initialization - for(i = 0; i < BLE_NB_PROFILES ; i++) - { - prf_env.prf[i].env = NULL; - prf_env.prf[i].task = TASK_GAPC + i +1; - prf_env.prf[i].id = TASK_ID_INVALID; + BLE_DBG(">>>>>> prf_create reset %d<<<<<<\n", reset); + if (!reset) { + // FW boot profile initialization + for (i = 0; i < BLE_NB_PROFILES; i++) { + prf_env.prf[i].env = NULL; + prf_env.prf[i].task = TASK_GAPC + i + 1; + prf_env.prf[i].id = TASK_ID_INVALID; - // Initialize Task Descriptor - prf_env.prf[i].desc.msg_handler_tab = NULL; - prf_env.prf[i].desc.state = NULL; - prf_env.prf[i].desc.idx_max = 0; - prf_env.prf[i].desc.msg_cnt = 0; + // Initialize Task Descriptor + prf_env.prf[i].desc.msg_handler_tab = NULL; + prf_env.prf[i].desc.state = NULL; + prf_env.prf[i].desc.idx_max = 0; + prf_env.prf[i].desc.msg_cnt = 0; - ke_task_create(prf_env.prf[i].task, &(prf_env.prf[i].desc)); - BLE_DBG("prf_init prf_env.prf[%d].task: %d\n", i, prf_env.prf[i].task); - } + ke_task_create(prf_env.prf[i].task, &(prf_env.prf[i].desc)); + BLE_DBG("prf_init prf_env.prf[%d].task: %d\n", i, prf_env.prf[i].task); } - else - { - // FW boot profile destruction - for(i = 0; i < BLE_NB_PROFILES ; i++) - { - // Get Profile API - const struct prf_task_cbs * cbs = prf_itf_get(prf_env.prf[i].id); - if(cbs != NULL) - { - // request to destroy profile - cbs->destroy(&(prf_env.prf[i])); - } - // unregister profile - prf_env.prf[i].id = TASK_ID_INVALID; - prf_env.prf[i].desc.msg_handler_tab = NULL; - prf_env.prf[i].desc.state = NULL; - prf_env.prf[i].desc.idx_max = 0; - prf_env.prf[i].desc.msg_cnt = 0; + } else { + // FW boot profile destruction + for (i = 0; i < BLE_NB_PROFILES; i++) { + // Get Profile API + const struct prf_task_cbs *cbs = prf_itf_get(prf_env.prf[i].id); + if (cbs != NULL) { + // request to destroy profile + cbs->destroy(&(prf_env.prf[i])); + } + // unregister profile + prf_env.prf[i].id = TASK_ID_INVALID; + prf_env.prf[i].desc.msg_handler_tab = NULL; + prf_env.prf[i].desc.state = NULL; + prf_env.prf[i].desc.idx_max = 0; + prf_env.prf[i].desc.msg_cnt = 0; - // Request kernel to flush task messages - ke_task_msg_flush(KE_TYPE_GET(prf_env.prf[i].task)); - } + // Request kernel to flush task messages + ke_task_msg_flush(KE_TYPE_GET(prf_env.prf[i].task)); } + } - BLE_FUNC_LEAVE(); + BLE_FUNC_LEAVE(); } +uint8_t prf_add_profile(struct gapm_profile_task_add_cmd *params, + ke_task_id_t *prf_task) { + uint8_t i; + uint8_t status = GAP_ERR_NO_ERROR; -uint8_t prf_add_profile(struct gapm_profile_task_add_cmd * params, ke_task_id_t* prf_task) -{ - uint8_t i; - uint8_t status = GAP_ERR_NO_ERROR; + BLE_DBG(">>>>>> prf_add_profile <<<<<<\n"); - BLE_DBG(">>>>>> prf_add_profile <<<<<<\n"); + // retrieve profile callback + const struct prf_task_cbs *cbs = prf_itf_get(params->prf_task_id); + if (cbs == NULL) { + // profile API not available + status = GAP_ERR_INVALID_PARAM; + } - // retrieve profile callback - const struct prf_task_cbs * cbs = prf_itf_get(params->prf_task_id); - if(cbs == NULL) - { - // profile API not available - status = GAP_ERR_INVALID_PARAM; + // check if profile not already present in task list + if (status == GAP_ERR_NO_ERROR) { + for (i = 0; i < BLE_NB_PROFILES; i++) { + if (prf_env.prf[i].id == params->prf_task_id) { + status = GAP_ERR_NOT_SUPPORTED; + break; + } + } + } + + if (status == GAP_ERR_NO_ERROR) { + // find first available task + for (i = 0; i < BLE_NB_PROFILES; i++) { + // available task found + if (prf_env.prf[i].id == TASK_ID_INVALID) { + // initialize profile + status = cbs->init(&(prf_env.prf[i]), &(params->start_hdl), + params->app_task, params->sec_lvl, params->param); + + // initialization succeed + if (status == GAP_ERR_NO_ERROR) { + // register profile + prf_env.prf[i].id = params->prf_task_id; + *prf_task = prf_env.prf[i].task; + } + break; + } } - // check if profile not already present in task list - if(status == GAP_ERR_NO_ERROR) - { - for(i = 0; i < BLE_NB_PROFILES ; i++) - { - if(prf_env.prf[i].id == params->prf_task_id) - { - status = GAP_ERR_NOT_SUPPORTED; - break; - } - } + if (i == BLE_NB_PROFILES) { + status = GAP_ERR_INSUFF_RESOURCES; } + } - if(status == GAP_ERR_NO_ERROR) - { - // find first available task - for(i = 0; i < BLE_NB_PROFILES ; i++) - { - // available task found - if(prf_env.prf[i].id == TASK_ID_INVALID) - { - // initialize profile - status = cbs->init(&(prf_env.prf[i]), &(params->start_hdl), params->app_task, params->sec_lvl, params->param); - - // initialization succeed - if(status == GAP_ERR_NO_ERROR) - { - // register profile - prf_env.prf[i].id = params->prf_task_id; - *prf_task = prf_env.prf[i].task; - } - break; - } - } - - if(i == BLE_NB_PROFILES) - { - status = GAP_ERR_INSUFF_RESOURCES; - } - } - - return (status); + return (status); } +void prf_create(uint8_t conidx) { + uint8_t i; + /* simple connection creation handler, nothing to do. */ - -void prf_create(uint8_t conidx) -{ - uint8_t i; - /* simple connection creation handler, nothing to do. */ - - BLE_DBG(">>>>>> prf_create <<<<<<\n"); - // execute create function of each profiles - for(i = 0; i < BLE_NB_PROFILES ; i++) - { - // Get Profile API - const struct prf_task_cbs * cbs = prf_itf_get(prf_env.prf[i].id); - if(cbs != NULL) - { - // call create callback - cbs->create(&(prf_env.prf[i]), conidx); - } + BLE_DBG(">>>>>> prf_create <<<<<<\n"); + // execute create function of each profiles + for (i = 0; i < BLE_NB_PROFILES; i++) { + // Get Profile API + const struct prf_task_cbs *cbs = prf_itf_get(prf_env.prf[i].id); + if (cbs != NULL) { + // call create callback + cbs->create(&(prf_env.prf[i]), conidx); } + } } +void prf_cleanup(uint8_t conidx, uint8_t reason) { + uint8_t i; + /* simple connection creation handler, nothing to do. */ -void prf_cleanup(uint8_t conidx, uint8_t reason) -{ - uint8_t i; - /* simple connection creation handler, nothing to do. */ - - BLE_DBG(">>>>>> prf_cleanup <<<<<<\n"); - // execute create function of each profiles - for(i = 0; i < BLE_NB_PROFILES ; i++) - { - // Get Profile API - const struct prf_task_cbs * cbs = prf_itf_get(prf_env.prf[i].id); - if(cbs != NULL) - { - // call cleanup callback - cbs->cleanup(&(prf_env.prf[i]), conidx, reason); - } + BLE_DBG(">>>>>> prf_cleanup <<<<<<\n"); + // execute create function of each profiles + for (i = 0; i < BLE_NB_PROFILES; i++) { + // Get Profile API + const struct prf_task_cbs *cbs = prf_itf_get(prf_env.prf[i].id); + if (cbs != NULL) { + // call cleanup callback + cbs->cleanup(&(prf_env.prf[i]), conidx, reason); } + } } - -prf_env_t* prf_env_get(uint16_t prf_id) -{ - prf_env_t* env = NULL; - uint8_t i; - // find if profile present in profile tasks - BLE_DBG("%s prf_id %d", __func__, prf_id); - for(i = 0; i < BLE_NB_PROFILES ; i++) - { - // check if profile identifier is known - if(prf_env.prf[i].id == prf_id) - { - env = prf_env.prf[i].env; - break; - } +prf_env_t *prf_env_get(uint16_t prf_id) { + prf_env_t *env = NULL; + uint8_t i; + // find if profile present in profile tasks + BLE_DBG("%s prf_id %d", __func__, prf_id); + for (i = 0; i < BLE_NB_PROFILES; i++) { + // check if profile identifier is known + if (prf_env.prf[i].id == prf_id) { + env = prf_env.prf[i].env; + break; } + } - return env; + return env; } -ke_task_id_t prf_src_task_get(prf_env_t* env, uint8_t conidx) -{ - ke_task_id_t task = PERM_GET(env->prf_task, PRF_TASK); +ke_task_id_t prf_src_task_get(prf_env_t *env, uint8_t conidx) { + ke_task_id_t task = PERM_GET(env->prf_task, PRF_TASK); - BLE_DBG("%s conidx %d", __func__, conidx); - if(PERM_GET(env->prf_task, PRF_MI)) - { - task = KE_BUILD_ID(task, conidx); - } + BLE_DBG("%s conidx %d", __func__, conidx); + if (PERM_GET(env->prf_task, PRF_MI)) { + task = KE_BUILD_ID(task, conidx); + } - return task; + return task; } -ke_task_id_t prf_dst_task_get(prf_env_t* env, uint8_t conidx) -{ - ke_task_id_t task = PERM_GET(env->app_task, PRF_TASK); +ke_task_id_t prf_dst_task_get(prf_env_t *env, uint8_t conidx) { + ke_task_id_t task = PERM_GET(env->app_task, PRF_TASK); - BLE_DBG("%s app_task %d conidx %d", __func__, env->app_task, conidx); - if(PERM_GET(env->app_task, PRF_MI)) - { - task = KE_BUILD_ID(task, conidx); - } + BLE_DBG("%s app_task %d conidx %d", __func__, env->app_task, conidx); + if (PERM_GET(env->app_task, PRF_MI)) { + task = KE_BUILD_ID(task, conidx); + } - return task; + return task; } +ke_task_id_t prf_get_id_from_task(ke_msg_id_t task) { + ke_task_id_t id = TASK_ID_INVALID; + uint8_t idx = KE_IDX_GET(task); + uint8_t i; + task = KE_TYPE_GET(task); -ke_task_id_t prf_get_id_from_task(ke_msg_id_t task) -{ - ke_task_id_t id = TASK_ID_INVALID; - uint8_t idx = KE_IDX_GET(task); - uint8_t i; - task = KE_TYPE_GET(task); - - BLE_DBG("%s task %d", __func__, task); - // find if profile present in profile tasks - for(i = 0; i < BLE_NB_PROFILES ; i++) - { - // check if profile identifier is known - if(prf_env.prf[i].task == task) - { - id = prf_env.prf[i].id; - break; - } + BLE_DBG("%s task %d", __func__, task); + // find if profile present in profile tasks + for (i = 0; i < BLE_NB_PROFILES; i++) { + // check if profile identifier is known + if (prf_env.prf[i].task == task) { + id = prf_env.prf[i].id; + break; } + } - return KE_BUILD_ID(id, idx); + return KE_BUILD_ID(id, idx); } -ke_task_id_t prf_get_task_from_id(ke_msg_id_t id) -{ - ke_task_id_t task = TASK_NONE; - uint8_t idx = KE_IDX_GET(id); - uint8_t i; - id = KE_TYPE_GET(id); +ke_task_id_t prf_get_task_from_id(ke_msg_id_t id) { + ke_task_id_t task = TASK_NONE; + uint8_t idx = KE_IDX_GET(id); + uint8_t i; + id = KE_TYPE_GET(id); - BLE_DBG("%s id %d", __func__, id); - // find if profile present in profile tasks - for(i = 0; i < BLE_NB_PROFILES ; i++) - { - // check if profile identifier is known - if(prf_env.prf[i].id == id) - { - task = prf_env.prf[i].task; - break; - } + BLE_DBG("%s id %d", __func__, id); + // find if profile present in profile tasks + for (i = 0; i < BLE_NB_PROFILES; i++) { + // check if profile identifier is known + if (prf_env.prf[i].id == id) { + task = prf_env.prf[i].task; + break; } + } - return KE_BUILD_ID(task, idx); + return KE_BUILD_ID(task, idx); } - #endif // (BLE_PROFILES) /// @} PRF diff --git a/services/ble_profiles/prf/prf_utils.c b/services/ble_profiles/prf/prf_utils.c index cfe2a4c..b61ee38 100644 --- a/services/ble_profiles/prf/prf_utils.c +++ b/services/ble_profiles/prf/prf_utils.c @@ -13,18 +13,18 @@ #if (BLE_PROFILES) #if (BLE_SERVER_PRF || BLE_CLIENT_PRF) -#include -#include -#include "ke_task.h" #include "attm.h" -#include "gattc_task.h" -#include "prf_utils.h" #include "gap.h" #include "gapc.h" +#include "gattc_task.h" +#include "ke_task.h" +#include "prf_utils.h" +#include +#include -#include "ke_mem.h" -#include "co_utils.h" #include "co_error.h" +#include "co_utils.h" +#include "ke_mem.h" #endif /* (BLE_SERVER_PRF || BLE_CLIENT_PRF) */ @@ -39,346 +39,318 @@ */ #if (BLE_BATT_SERVER) -void prf_pack_char_pres_fmt(uint8_t *packed_val, const struct prf_char_pres_fmt* char_pres_fmt) -{ - *packed_val = char_pres_fmt->format; - *(packed_val + 1) = char_pres_fmt->exponent; - co_write16p(packed_val + 2, char_pres_fmt->unit); - *(packed_val + 4) = char_pres_fmt->name_space; - co_write16p(packed_val + 5, char_pres_fmt->description); +void prf_pack_char_pres_fmt(uint8_t *packed_val, + const struct prf_char_pres_fmt *char_pres_fmt) { + *packed_val = char_pres_fmt->format; + *(packed_val + 1) = char_pres_fmt->exponent; + co_write16p(packed_val + 2, char_pres_fmt->unit); + *(packed_val + 4) = char_pres_fmt->name_space; + co_write16p(packed_val + 5, char_pres_fmt->description); } #endif // (BLE_BATT_SERVER) #if (BLE_BATT_CLIENT) -void prf_unpack_char_pres_fmt(const uint8_t *packed_val, struct prf_char_pres_fmt* char_pres_fmt) -{ +void prf_unpack_char_pres_fmt(const uint8_t *packed_val, + struct prf_char_pres_fmt *char_pres_fmt) { - char_pres_fmt->format = *packed_val; - char_pres_fmt->exponent = *(packed_val + 1); - char_pres_fmt->unit = co_read16p(packed_val + 2); - char_pres_fmt->name_space = *(packed_val + 4); - char_pres_fmt->description = co_read16p(packed_val + 5); + char_pres_fmt->format = *packed_val; + char_pres_fmt->exponent = *(packed_val + 1); + char_pres_fmt->unit = co_read16p(packed_val + 2); + char_pres_fmt->name_space = *(packed_val + 4); + char_pres_fmt->description = co_read16p(packed_val + 5); } #endif // (BLE_BATT_CLIENT) - #if (BLE_CLIENT_PRF) -void prf_read_char_send(prf_env_t *prf_env, uint8_t conidx, - uint16_t shdl, uint16_t ehdl, uint16_t valhdl) -{ - struct gattc_read_cmd * req = KE_MSG_ALLOC(GATTC_READ_CMD, KE_BUILD_ID(TASK_GATTC, conidx), - prf_src_task_get(prf_env, conidx), gattc_read_cmd); - //request type - req->operation = GATTC_READ; - req->nb = 1; - req->req.simple.offset = 0; - req->req.simple.length = 0; - req->req.simple.handle = valhdl; +void prf_read_char_send(prf_env_t *prf_env, uint8_t conidx, uint16_t shdl, + uint16_t ehdl, uint16_t valhdl) { + struct gattc_read_cmd *req = + KE_MSG_ALLOC(GATTC_READ_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(prf_env, conidx), gattc_read_cmd); + // request type + req->operation = GATTC_READ; + req->nb = 1; + req->req.simple.offset = 0; + req->req.simple.length = 0; + req->req.simple.handle = valhdl; - //send request to GATT - ke_msg_send(req); + // send request to GATT + ke_msg_send(req); } -void prf_register_atthdl2gatt(prf_env_t *prf_env, uint8_t conidx, struct prf_svc *svc) -{ - if(svc->shdl != ATT_INVALID_HANDLE) - { - //register profile task in gatt for indication/notifications - struct gattc_reg_to_peer_evt_cmd * reg = KE_MSG_ALLOC(GATTC_REG_TO_PEER_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(prf_env, conidx), - gattc_reg_to_peer_evt_cmd); +void prf_register_atthdl2gatt(prf_env_t *prf_env, uint8_t conidx, + struct prf_svc *svc) { + if (svc->shdl != ATT_INVALID_HANDLE) { + // register profile task in gatt for indication/notifications + struct gattc_reg_to_peer_evt_cmd *reg = KE_MSG_ALLOC( + GATTC_REG_TO_PEER_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(prf_env, conidx), gattc_reg_to_peer_evt_cmd); - reg->operation = GATTC_REGISTER; - reg->start_hdl = svc->shdl; - reg->end_hdl = svc->ehdl; + reg->operation = GATTC_REGISTER; + reg->start_hdl = svc->shdl; + reg->end_hdl = svc->ehdl; - ke_msg_send(reg); - } + ke_msg_send(reg); + } } -void prf_unregister_atthdl2gatt(prf_env_t *prf_env, uint8_t conidx, struct prf_svc *svc) -{ - if(svc->shdl != ATT_INVALID_HANDLE) - { - //un register profile task in gatt for indication/notifications - struct gattc_reg_to_peer_evt_cmd * reg = KE_MSG_ALLOC(GATTC_REG_TO_PEER_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(prf_env, conidx), - gattc_reg_to_peer_evt_cmd); +void prf_unregister_atthdl2gatt(prf_env_t *prf_env, uint8_t conidx, + struct prf_svc *svc) { + if (svc->shdl != ATT_INVALID_HANDLE) { + // un register profile task in gatt for indication/notifications + struct gattc_reg_to_peer_evt_cmd *reg = KE_MSG_ALLOC( + GATTC_REG_TO_PEER_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(prf_env, conidx), gattc_reg_to_peer_evt_cmd); - reg->operation = GATTC_UNREGISTER; - reg->start_hdl = svc->shdl; - reg->end_hdl = svc->ehdl; + reg->operation = GATTC_UNREGISTER; + reg->start_hdl = svc->shdl; + reg->end_hdl = svc->ehdl; - ke_msg_send(reg); - } + ke_msg_send(reg); + } } +void prf_disc_svc_send(prf_env_t *prf_env, uint8_t conidx, uint16_t uuid) { + // send GATT discover primary services by UUID request + struct gattc_sdp_svc_disc_cmd *svc_req = + KE_MSG_ALLOC_DYN(GATTC_SDP_SVC_DISC_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(prf_env, conidx), + gattc_sdp_svc_disc_cmd, ATT_UUID_16_LEN); -void prf_disc_svc_send(prf_env_t *prf_env, uint8_t conidx, uint16_t uuid) -{ - //send GATT discover primary services by UUID request - struct gattc_sdp_svc_disc_cmd * svc_req = KE_MSG_ALLOC_DYN(GATTC_SDP_SVC_DISC_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(prf_env, conidx), - gattc_sdp_svc_disc_cmd, ATT_UUID_16_LEN); + // gatt request type: by UUID + svc_req->operation = GATTC_SDP_DISC_SVC; + // start handle; + svc_req->start_hdl = ATT_1ST_REQ_START_HDL; + // end handle + svc_req->end_hdl = ATT_1ST_REQ_END_HDL; - //gatt request type: by UUID - svc_req->operation = GATTC_SDP_DISC_SVC; - //start handle; - svc_req->start_hdl = ATT_1ST_REQ_START_HDL; - //end handle - svc_req->end_hdl = ATT_1ST_REQ_END_HDL; + // UUID search + svc_req->uuid_len = ATT_UUID_16_LEN; - // UUID search - svc_req->uuid_len = ATT_UUID_16_LEN; + // set the first two bytes to the value array, LSB to MSB:Health Thermometer + // Service UUID first + co_write16p(&(svc_req->uuid[0]), uuid); - //set the first two bytes to the value array, LSB to MSB:Health Thermometer Service UUID first - co_write16p(&(svc_req->uuid[0]), uuid); - - //send the message to GATT, which will send back the response when it gets it - ke_msg_send(svc_req); + // send the message to GATT, which will send back the response when it gets it + ke_msg_send(svc_req); } +void prf_gatt_write(prf_env_t *prf_env, uint8_t conidx, uint16_t handle, + uint8_t *value, uint16_t length, uint8_t operation) { + if (handle != ATT_INVALID_HANDLE) { + struct gattc_write_cmd *wr_char = KE_MSG_ALLOC_DYN( + GATTC_WRITE_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(prf_env, conidx), gattc_write_cmd, length); + // Offset + wr_char->offset = 0x0000; + // cursor always 0 + wr_char->cursor = 0x0000; + // Write Type + wr_char->operation = operation; + // Characteristic Value attribute handle + wr_char->handle = handle; + // Value Length + wr_char->length = length; + // Auto Execute + wr_char->auto_execute = true; + // Value + memcpy(&wr_char->value[0], value, length); -void prf_gatt_write(prf_env_t *prf_env, uint8_t conidx, - uint16_t handle, uint8_t* value, uint16_t length, uint8_t operation) -{ - if(handle != ATT_INVALID_HANDLE) - { - struct gattc_write_cmd *wr_char = KE_MSG_ALLOC_DYN(GATTC_WRITE_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(prf_env, conidx), - gattc_write_cmd, length); - - // Offset - wr_char->offset = 0x0000; - // cursor always 0 - wr_char->cursor = 0x0000; - // Write Type - wr_char->operation = operation; - // Characteristic Value attribute handle - wr_char->handle = handle; - // Value Length - wr_char->length = length; - // Auto Execute - wr_char->auto_execute = true; - // Value - memcpy(&wr_char->value[0], value, length); - - // Send the message - ke_msg_send(wr_char); - } + // Send the message + ke_msg_send(wr_char); + } } -void prf_gatt_write_ntf_ind(prf_env_t *prf_env, uint8_t conidx, uint16_t handle, uint16_t ntf_ind_cfg) -{ - uint8_t value[2]; +void prf_gatt_write_ntf_ind(prf_env_t *prf_env, uint8_t conidx, uint16_t handle, + uint16_t ntf_ind_cfg) { + uint8_t value[2]; - // put value in air format - co_write16p((&value[0]), ntf_ind_cfg); - // write value over GATT - prf_gatt_write(prf_env, conidx, handle, value, 2, GATTC_WRITE); + // put value in air format + co_write16p((&value[0]), ntf_ind_cfg); + // write value over GATT + prf_gatt_write(prf_env, conidx, handle, value, 2, GATTC_WRITE); } uint8_t prf_check_svc_char_validity(uint8_t nb_chars, - const struct prf_char_inf* chars, - const struct prf_char_def* chars_req) -{ - uint8_t status = GAP_ERR_NO_ERROR; - uint8_t i; + const struct prf_char_inf *chars, + const struct prf_char_def *chars_req) { + uint8_t status = GAP_ERR_NO_ERROR; + uint8_t i; - for(i = 0; ((i < nb_chars) && (status == GAP_ERR_NO_ERROR)); i++) - { - if (chars[i].char_hdl == ATT_INVALID_HANDLE) - { - //If Characteristic is not present, check requirements - if (chars_req[i].req_flag == ATT_MANDATORY) - { - status = PRF_ERR_STOP_DISC_CHAR_MISSING; - } - } - else - { - //If Characteristic is present, check properties - if((chars[i].prop & chars_req[i].prop_mand) != chars_req[i].prop_mand) - { - status = PRF_ERR_STOP_DISC_WRONG_CHAR_PROP; - } - } + for (i = 0; ((i < nb_chars) && (status == GAP_ERR_NO_ERROR)); i++) { + if (chars[i].char_hdl == ATT_INVALID_HANDLE) { + // If Characteristic is not present, check requirements + if (chars_req[i].req_flag == ATT_MANDATORY) { + status = PRF_ERR_STOP_DISC_CHAR_MISSING; + } + } else { + // If Characteristic is present, check properties + if ((chars[i].prop & chars_req[i].prop_mand) != chars_req[i].prop_mand) { + status = PRF_ERR_STOP_DISC_WRONG_CHAR_PROP; + } } + } - return (status); + return (status); } +uint8_t +prf_check_svc_char_desc_validity(uint8_t descs_size, + const struct prf_char_desc_inf *descs, + const struct prf_char_desc_def *descs_req, + const struct prf_char_inf *chars) { + uint8_t status = GAP_ERR_NO_ERROR; + uint8_t i; -uint8_t prf_check_svc_char_desc_validity(uint8_t descs_size, - const struct prf_char_desc_inf* descs, - const struct prf_char_desc_def* descs_req, - const struct prf_char_inf* chars) -{ - uint8_t status = GAP_ERR_NO_ERROR; - uint8_t i; + for (i = 0; ((i < descs_size) && (status == GAP_ERR_NO_ERROR)); i++) { + if (descs[i].desc_hdl == ATT_INVALID_HANDLE) { + // If Descriptor is missing, check if it is mandatory + if (descs_req[i].req_flag == ATT_MANDATORY) { + // Check if Char is present + if (chars[descs_req[i].char_code].char_hdl != ATT_INVALID_HANDLE) { + // Char. is present and descriptor not, error + status = PRF_ERR_STOP_DISC_CHAR_MISSING; + } + } + } + } - for(i = 0; ((i < descs_size) && (status == GAP_ERR_NO_ERROR)) ; i++) - { - if (descs[i].desc_hdl == ATT_INVALID_HANDLE) - { - //If Descriptor is missing, check if it is mandatory - if (descs_req[i].req_flag == ATT_MANDATORY) - { - //Check if Char is present - if (chars[descs_req[i].char_code].char_hdl != ATT_INVALID_HANDLE) - { - //Char. is present and descriptor not, error - status = PRF_ERR_STOP_DISC_CHAR_MISSING; + return (status); +} + +void prf_extract_svc_info(const struct gattc_sdp_svc_ind *param, + uint8_t nb_chars, + const struct prf_char_def *chars_req, + struct prf_char_inf *chars, uint8_t nb_descs, + const struct prf_char_desc_def *descs_req, + struct prf_char_desc_inf *descs) { + // Counters + uint8_t svc_char; + uint8_t svc_desc; + uint8_t fnd_att; + + for (fnd_att = 0; fnd_att < (param->end_hdl - param->start_hdl); fnd_att++) { + if (param->info[fnd_att].att_type == GATTC_SDP_ATT_CHAR) { + uint16_t char_hdl = param->start_hdl + 1 + fnd_att; + uint16_t val_hdl = param->info[fnd_att].att_char.handle; + uint8_t val_prop = param->info[fnd_att].att_char.prop; + uint8_t char_idx = fnd_att; + + // check that value handle is in a valid range + if ((val_hdl <= param->end_hdl) && + (val_hdl > (param->start_hdl + fnd_att))) { + // retrieve value index + uint8_t val_idx = (val_hdl - param->start_hdl - 1); + + // Look over requested characteristics + for (svc_char = 0; svc_char < nb_chars; svc_char++) { + // check if attribute is valid + if ((chars[svc_char].char_hdl == ATT_INVALID_HDL) && + attm_uuid16_comp((uint8_t *)param->info[val_idx].att.uuid, + param->info[val_idx].att.uuid_len, + chars_req[svc_char].uuid)) { + // Save properties and handles + chars[svc_char].char_hdl = char_hdl; + chars[svc_char].val_hdl = val_hdl; + chars[svc_char].prop = val_prop; + + // find end of characteristic handle and discover descriptors + do { + fnd_att++; + + // found a descriptor + if (param->info[fnd_att].att_type == GATTC_SDP_ATT_DESC) { + // Retrieve characteristic descriptor handle using UUID + for (svc_desc = 0; svc_desc < nb_descs; svc_desc++) { + // check if it's expected descriptor + if ((descs[svc_desc].desc_hdl == ATT_INVALID_HANDLE) && + (descs_req[svc_desc].char_code == svc_char) && + (attm_uuid16_comp( + (uint8_t *)param->info[fnd_att].att.uuid, + param->info[fnd_att].att.uuid_len, + descs_req[svc_desc].uuid))) { + descs[svc_desc].desc_hdl = param->start_hdl + 1 + fnd_att; + // search for next descriptor + break; + } } - } + } + } while (((param->start_hdl + 1 + fnd_att) <= param->end_hdl) && + (param->info[fnd_att].att_type != GATTC_SDP_ATT_CHAR) && + (param->info[fnd_att].att_type != GATTC_SDP_INC_SVC)); + + // return to previous valid value + fnd_att--; + // previous handle was end of the characteristic + chars[svc_char].char_ehdl_off = fnd_att - char_idx; + + // search next characteristic + break; + } } + } } - - return (status); + } } -void prf_extract_svc_info(const struct gattc_sdp_svc_ind* param, - uint8_t nb_chars, const struct prf_char_def* chars_req, struct prf_char_inf* chars, - uint8_t nb_descs, const struct prf_char_desc_def* descs_req, struct prf_char_desc_inf* descs) -{ - //Counters - uint8_t svc_char; - uint8_t svc_desc; - uint8_t fnd_att; - - for (fnd_att=0; fnd_att< (param->end_hdl - param->start_hdl); fnd_att++) - { - if(param->info[fnd_att].att_type == GATTC_SDP_ATT_CHAR) - { - uint16_t char_hdl = param->start_hdl+ 1 + fnd_att; - uint16_t val_hdl = param->info[fnd_att].att_char.handle; - uint8_t val_prop = param->info[fnd_att].att_char.prop; - uint8_t char_idx = fnd_att; - - // check that value handle is in a valid range - if((val_hdl <= param->end_hdl) && (val_hdl > (param->start_hdl + fnd_att))) - { - // retrieve value index - uint8_t val_idx = (val_hdl - param->start_hdl - 1); - - //Look over requested characteristics - for (svc_char=0; svc_charinfo[val_idx].att.uuid, - param->info[val_idx].att.uuid_len, chars_req[svc_char].uuid)) - { - //Save properties and handles - chars[svc_char].char_hdl = char_hdl; - chars[svc_char].val_hdl = val_hdl; - chars[svc_char].prop = val_prop; - - // find end of characteristic handle and discover descriptors - do - { - fnd_att++; - - // found a descriptor - if(param->info[fnd_att].att_type == GATTC_SDP_ATT_DESC) - { - //Retrieve characteristic descriptor handle using UUID - for(svc_desc = 0; svc_descinfo[fnd_att].att.uuid, - param->info[fnd_att].att.uuid_len, descs_req[svc_desc].uuid))) - { - descs[svc_desc].desc_hdl = param->start_hdl + 1 + fnd_att; - // search for next descriptor - break; - } - } - } - } while(((param->start_hdl+ 1 + fnd_att) <= param->end_hdl) - && (param->info[fnd_att].att_type != GATTC_SDP_ATT_CHAR) - && (param->info[fnd_att].att_type != GATTC_SDP_INC_SVC)); - - // return to previous valid value - fnd_att--; - // previous handle was end of the characteristic - chars[svc_char].char_ehdl_off = fnd_att - char_idx; - - // search next characteristic - break; - } - } - } - } - } -} - - #endif //(BLE_CLIENT_PRF) #if (BLE_CLIENT_PRF || BLE_TIP_SERVER || BLE_AN_SERVER || BLE_PAS_SERVER) -void prf_client_att_info_rsp(prf_env_t *prf_env, uint8_t conidx, uint16_t msg_id, - uint8_t status, struct gattc_read_ind const* read_ind) -{ - // retrieve value length - uint16_t length = 0; - if(status == GAP_ERR_NO_ERROR) - { - length = read_ind->length; - } +void prf_client_att_info_rsp(prf_env_t *prf_env, uint8_t conidx, + uint16_t msg_id, uint8_t status, + struct gattc_read_ind const *read_ind) { + // retrieve value length + uint16_t length = 0; + if (status == GAP_ERR_NO_ERROR) { + length = read_ind->length; + } - // prepare response - struct prf_att_info *rsp = KE_MSG_ALLOC_DYN(msg_id, - prf_dst_task_get(prf_env, conidx), prf_src_task_get(prf_env, conidx), - prf_att_info, length); + // prepare response + struct prf_att_info *rsp = + KE_MSG_ALLOC_DYN(msg_id, prf_dst_task_get(prf_env, conidx), + prf_src_task_get(prf_env, conidx), prf_att_info, length); - rsp->status = status; - rsp->handle = ATT_INVALID_HDL; - rsp->length = length; + rsp->status = status; + rsp->handle = ATT_INVALID_HDL; + rsp->length = length; - // set value array - if (read_ind != NULL) - { - rsp->handle = read_ind->handle; - memcpy(&(rsp->value[0]), &(read_ind->value[0]), length); - } + // set value array + if (read_ind != NULL) { + rsp->handle = read_ind->handle; + memcpy(&(rsp->value[0]), &(read_ind->value[0]), length); + } - ke_msg_send(rsp); + ke_msg_send(rsp); } #endif //(BLE_CLIENT_PRF || BLE_TIP_SERVER || BLE_AN_SERVER || BLE_PAS_SERVER) - #if ((BLE_SERVER_PRF || BLE_CLIENT_PRF)) -uint8_t prf_pack_date_time(uint8_t *packed_date, const struct prf_date_time* date_time) -{ - co_write16p(packed_date, date_time->year); - *(packed_date + 2) = date_time->month; - *(packed_date + 3) = date_time->day; - *(packed_date + 4) = date_time->hour; - *(packed_date + 5) = date_time->min; - *(packed_date + 6) = date_time->sec; +uint8_t prf_pack_date_time(uint8_t *packed_date, + const struct prf_date_time *date_time) { + co_write16p(packed_date, date_time->year); + *(packed_date + 2) = date_time->month; + *(packed_date + 3) = date_time->day; + *(packed_date + 4) = date_time->hour; + *(packed_date + 5) = date_time->min; + *(packed_date + 6) = date_time->sec; - return 7; + return 7; } -uint8_t prf_unpack_date_time(uint8_t *packed_date, struct prf_date_time* date_time) -{ - date_time->year = co_read16p(&(packed_date[0])); - date_time->month = packed_date[2]; - date_time->day = packed_date[3]; - date_time->hour = packed_date[4]; - date_time->min = packed_date[5]; - date_time->sec = packed_date[6]; +uint8_t prf_unpack_date_time(uint8_t *packed_date, + struct prf_date_time *date_time) { + date_time->year = co_read16p(&(packed_date[0])); + date_time->month = packed_date[2]; + date_time->day = packed_date[3]; + date_time->hour = packed_date[4]; + date_time->min = packed_date[5]; + date_time->sec = packed_date[6]; - return 7; + return 7; } - #endif /* ((BLE_SERVER_PRF || BLE_CLIENT_PRF)) */ #endif // (BLE_PROFILES) /// @} PRF_UTILS - diff --git a/services/ble_profiles/prf/prf_utils_128.c b/services/ble_profiles/prf/prf_utils_128.c index 49efa70..5e0bde4 100644 --- a/services/ble_profiles/prf/prf_utils_128.c +++ b/services/ble_profiles/prf/prf_utils_128.c @@ -12,153 +12,143 @@ #include "rwip_config.h" #if (BLE_CLIENT_PRF) -#include -#include -#include "ke_task.h" -#include "co_error.h" #include "attm.h" -#include "gattc_task.h" -#include "prf_utils_128.h" -#include "ke_mem.h" +#include "co_error.h" #include "gap.h" #include "gapc.h" +#include "gattc_task.h" +#include "ke_mem.h" +#include "ke_task.h" +#include "prf_utils_128.h" +#include +#include #endif //(BLE_CLIENT_PRF) #if (BLE_CLIENT_PRF) -void prf_disc_svc_send_128(prf_env_t *prf_env, uint8_t conidx, uint8_t *uuid_128) -{ - //send GATT discover primary services by UUID request: find by type request - struct gattc_disc_cmd * svc_req = KE_MSG_ALLOC_DYN(GATTC_SDP_SVC_DISC_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(prf_env, conidx), - gattc_disc_cmd, ATT_UUID_128_LEN); +void prf_disc_svc_send_128(prf_env_t *prf_env, uint8_t conidx, + uint8_t *uuid_128) { + // send GATT discover primary services by UUID request: find by type request + struct gattc_disc_cmd *svc_req = KE_MSG_ALLOC_DYN( + GATTC_SDP_SVC_DISC_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(prf_env, conidx), gattc_disc_cmd, ATT_UUID_128_LEN); - //gatt request type: by UUID - svc_req->operation = GATTC_SDP_DISC_SVC; - //start handle; - svc_req->start_hdl = ATT_1ST_REQ_START_HDL; - //end handle - svc_req->end_hdl = ATT_1ST_REQ_END_HDL; + // gatt request type: by UUID + svc_req->operation = GATTC_SDP_DISC_SVC; + // start handle; + svc_req->start_hdl = ATT_1ST_REQ_START_HDL; + // end handle + svc_req->end_hdl = ATT_1ST_REQ_END_HDL; - // UUID search - svc_req->uuid_len = ATT_UUID_128_LEN; + // UUID search + svc_req->uuid_len = ATT_UUID_128_LEN; - // set 128 bit UUID for searching - memcpy(&svc_req->uuid[0], uuid_128, (sizeof(uint8_t) * ATT_UUID_128_LEN)); + // set 128 bit UUID for searching + memcpy(&svc_req->uuid[0], uuid_128, (sizeof(uint8_t) * ATT_UUID_128_LEN)); - //send the message to GATT, which will send back the response when it gets it - ke_msg_send(svc_req); + // send the message to GATT, which will send back the response when it gets it + ke_msg_send(svc_req); } -uint8_t prf_check_svc_char_validity_128(uint8_t nb_chars, - const struct prf_char_inf* chars, - const struct prf_char_def_128* chars_req) -{ - uint8_t status = GAP_ERR_NO_ERROR; - uint8_t i; +uint8_t +prf_check_svc_char_validity_128(uint8_t nb_chars, + const struct prf_char_inf *chars, + const struct prf_char_def_128 *chars_req) { + uint8_t status = GAP_ERR_NO_ERROR; + uint8_t i; - for(i = 0; ((i < nb_chars) && (status == GAP_ERR_NO_ERROR)); i++) - { - if (chars[i].char_hdl == ATT_INVALID_HANDLE) - { - //If Characteristic is not present, check requirements - if (chars_req[i].req_flag == ATT_MANDATORY) - { - status = PRF_ERR_STOP_DISC_CHAR_MISSING; - } - } - else - { - //If Characteristic is present, check properties - if((chars[i].prop & chars_req[i].prop_mand) != chars_req[i].prop_mand) - { - status = PRF_ERR_STOP_DISC_WRONG_CHAR_PROP; - } - } + for (i = 0; ((i < nb_chars) && (status == GAP_ERR_NO_ERROR)); i++) { + if (chars[i].char_hdl == ATT_INVALID_HANDLE) { + // If Characteristic is not present, check requirements + if (chars_req[i].req_flag == ATT_MANDATORY) { + status = PRF_ERR_STOP_DISC_CHAR_MISSING; + } + } else { + // If Characteristic is present, check properties + if ((chars[i].prop & chars_req[i].prop_mand) != chars_req[i].prop_mand) { + status = PRF_ERR_STOP_DISC_WRONG_CHAR_PROP; + } } + } - return status; + return status; } -void prf_extract_svc_info_128(const struct gattc_sdp_svc_ind* param, - uint8_t nb_chars, const struct prf_char_def_128* chars_req, struct prf_char_inf* chars, - uint8_t nb_descs, const struct prf_char_desc_def* descs_req, struct prf_char_desc_inf* descs) -{ - //Counters - uint8_t svc_char; - uint8_t svc_desc; - uint8_t fnd_att; +void prf_extract_svc_info_128(const struct gattc_sdp_svc_ind *param, + uint8_t nb_chars, + const struct prf_char_def_128 *chars_req, + struct prf_char_inf *chars, uint8_t nb_descs, + const struct prf_char_desc_def *descs_req, + struct prf_char_desc_inf *descs) { + // Counters + uint8_t svc_char; + uint8_t svc_desc; + uint8_t fnd_att; - for (fnd_att=0; fnd_att< (param->end_hdl - param->start_hdl); fnd_att++) - { - if(param->info[fnd_att].att_type == GATTC_SDP_ATT_CHAR) - { - uint16_t char_hdl = param->start_hdl+ 1 + fnd_att; - uint16_t val_hdl = param->info[fnd_att].att_char.handle; - uint8_t val_prop = param->info[fnd_att].att_char.prop; - uint8_t char_idx = fnd_att; + for (fnd_att = 0; fnd_att < (param->end_hdl - param->start_hdl); fnd_att++) { + if (param->info[fnd_att].att_type == GATTC_SDP_ATT_CHAR) { + uint16_t char_hdl = param->start_hdl + 1 + fnd_att; + uint16_t val_hdl = param->info[fnd_att].att_char.handle; + uint8_t val_prop = param->info[fnd_att].att_char.prop; + uint8_t char_idx = fnd_att; - // check that value handle is in a valid range - if((val_hdl <= param->end_hdl) && (val_hdl > (param->start_hdl + fnd_att))) - { - // retrieve value index - uint8_t val_idx = (val_hdl - param->start_hdl - 1); + // check that value handle is in a valid range + if ((val_hdl <= param->end_hdl) && + (val_hdl > (param->start_hdl + fnd_att))) { + // retrieve value index + uint8_t val_idx = (val_hdl - param->start_hdl - 1); - //Look over requested characteristics - for (svc_char=0; svc_charinfo[val_idx].att.uuid, ATT_UUID_128_LEN, - (uint8_t*)chars_req[svc_char].uuid, ATT_UUID_128_LEN)) - { - //Save properties and handles - chars[svc_char].char_hdl = char_hdl; - chars[svc_char].val_hdl = val_hdl; - chars[svc_char].prop = val_prop; + // Look over requested characteristics + for (svc_char = 0; svc_char < nb_chars; svc_char++) { + // check if attribute is valid + if ((chars[svc_char].char_hdl == ATT_INVALID_HDL) && + attm_uuid_comp( + (uint8_t *)param->info[val_idx].att.uuid, ATT_UUID_128_LEN, + (uint8_t *)chars_req[svc_char].uuid, ATT_UUID_128_LEN)) { + // Save properties and handles + chars[svc_char].char_hdl = char_hdl; + chars[svc_char].val_hdl = val_hdl; + chars[svc_char].prop = val_prop; - // find end of characteristic handle and discover descriptors - do - { - fnd_att++; + // find end of characteristic handle and discover descriptors + do { + fnd_att++; - // found a descriptor - if(param->info[fnd_att].att_type == GATTC_SDP_ATT_DESC) - { - //Retrieve characteristic descriptor handle using UUID - for(svc_desc = 0; svc_descinfo[fnd_att].att.uuid, - param->info[fnd_att].att.uuid_len, descs_req[svc_desc].uuid))) - { - descs[svc_desc].desc_hdl = param->start_hdl + 1 + fnd_att; - // search for next descriptor - break; - } - } - } - } while(((param->start_hdl+ 1 + fnd_att) <= param->end_hdl) - && (param->info[fnd_att].att_type != GATTC_SDP_ATT_CHAR) - && (param->info[fnd_att].att_type != GATTC_SDP_INC_SVC)); - - // return to previous valid value - fnd_att--; - // previous handle was end of the characteristic - chars[svc_char].char_ehdl_off = fnd_att - char_idx; - - // search next characteristic - break; - } + // found a descriptor + if (param->info[fnd_att].att_type == GATTC_SDP_ATT_DESC) { + // Retrieve characteristic descriptor handle using UUID + for (svc_desc = 0; svc_desc < nb_descs; svc_desc++) { + // check if it's expected descriptor + if ((descs[svc_desc].desc_hdl == ATT_INVALID_HANDLE) && + (descs_req[svc_desc].char_code == svc_char) && + (attm_uuid16_comp( + (uint8_t *)param->info[fnd_att].att.uuid, + param->info[fnd_att].att.uuid_len, + descs_req[svc_desc].uuid))) { + descs[svc_desc].desc_hdl = param->start_hdl + 1 + fnd_att; + // search for next descriptor + break; + } } - } + } + } while (((param->start_hdl + 1 + fnd_att) <= param->end_hdl) && + (param->info[fnd_att].att_type != GATTC_SDP_ATT_CHAR) && + (param->info[fnd_att].att_type != GATTC_SDP_INC_SVC)); + + // return to previous valid value + fnd_att--; + // previous handle was end of the characteristic + chars[svc_char].char_ehdl_off = fnd_att - char_idx; + + // search next characteristic + break; + } } + } } + } } #endif /*(BLE_SAMPLE128_CLIENT) */ /// @} PRF_UTILS - diff --git a/services/ble_profiles/prox/proxm/src/proxm.c b/services/ble_profiles/prox/proxm/src/proxm.c index f55e98f..79e0a0c 100644 --- a/services/ble_profiles/prox/proxm/src/proxm.c +++ b/services/ble_profiles/prox/proxm/src/proxm.c @@ -14,10 +14,10 @@ #if (BLE_PROX_MONITOR) +#include "gap.h" +#include "prf_utils.h" #include "proxm.h" #include "proxm_task.h" -#include "prf_utils.h" -#include "gap.h" #include "ke_mem.h" @@ -26,8 +26,6 @@ **************************************************************************************** */ - - /* * LOCAL FUNCTION DEFINITIONS **************************************************************************************** @@ -44,69 +42,70 @@ * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t proxm_init (struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t idx; - //-------------------- allocate memory required for the profile --------------------- +static uint8_t proxm_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t idx; + //-------------------- allocate memory required for the profile + //--------------------- - struct proxm_env_tag* proxm_env = - (struct proxm_env_tag* ) ke_malloc(sizeof(struct proxm_env_tag), KE_MEM_ATT_DB); + struct proxm_env_tag *proxm_env = (struct proxm_env_tag *)ke_malloc( + sizeof(struct proxm_env_tag), KE_MEM_ATT_DB); - // allocate PROXM required environment variable - env->env = (prf_env_t*) proxm_env; + // allocate PROXM required environment variable + env->env = (prf_env_t *)proxm_env; - proxm_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - proxm_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + proxm_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + proxm_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_PROXM; - proxm_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_PROXM; + proxm_task_init(&(env->desc)); - for(idx = 0; idx < PROXM_IDX_MAX ; idx++) - { - proxm_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), PROXM_FREE); - } + for (idx = 0; idx < PROXM_IDX_MAX; idx++) { + proxm_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), PROXM_FREE); + } - return GAP_ERR_NO_ERROR; + return GAP_ERR_NO_ERROR; } /** **************************************************************************************** * @brief Destruction of the PROXM module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void proxm_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct proxm_env_tag* proxm_env = (struct proxm_env_tag*) env->env; +static void proxm_destroy(struct prf_task_env *env) { + uint8_t idx; + struct proxm_env_tag *proxm_env = (struct proxm_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < PROXM_IDX_MAX ; idx++) - { - if(proxm_env->env[idx] != NULL) - { - ke_free(proxm_env->env[idx]); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < PROXM_IDX_MAX; idx++) { + if (proxm_env->env[idx] != NULL) { + ke_free(proxm_env->env[idx]); } + } - // free profile environment variables - env->env = NULL; - ke_free(proxm_env); + // free profile environment variables + env->env = NULL; + ke_free(proxm_env); } /** @@ -117,10 +116,9 @@ static void proxm_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void proxm_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Put PROX Client in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), PROXM_IDLE); +static void proxm_create(struct prf_task_env *env, uint8_t conidx) { + /* Put PROX Client in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), PROXM_IDLE); } /** @@ -132,32 +130,30 @@ static void proxm_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void proxm_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct proxm_env_tag* proxm_env = (struct proxm_env_tag*) env->env; +static void proxm_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct proxm_env_tag *proxm_env = (struct proxm_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(proxm_env->env[conidx] != NULL) - { - ke_free(proxm_env->env[conidx]); - proxm_env->env[conidx] = NULL; - } + // clean-up environment variable allocated for task instance + if (proxm_env->env[conidx] != NULL) { + ke_free(proxm_env->env[conidx]); + proxm_env->env[conidx] = NULL; + } - /* Put PROX Client in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), PROXM_FREE); + /* Put PROX Client in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), PROXM_FREE); } /* -* GLOBAL VARIABLE DEFINITIONS -**************************************************************************************** -*/ + * GLOBAL VARIABLE DEFINITIONS + **************************************************************************************** + */ /// PROXM Task interface required by profile manager -const struct prf_task_cbs proxm_itf = -{ - (prf_init_fnct) proxm_init, - proxm_destroy, - proxm_create, - proxm_cleanup, +const struct prf_task_cbs proxm_itf = { + (prf_init_fnct)proxm_init, + proxm_destroy, + proxm_create, + proxm_cleanup, }; /* @@ -165,51 +161,44 @@ const struct prf_task_cbs proxm_itf = **************************************************************************************** */ -const struct prf_task_cbs* proxm_prf_itf_get(void) -{ - return &proxm_itf; +const struct prf_task_cbs *proxm_prf_itf_get(void) { return &proxm_itf; } + +void proxm_enable_rsp_send(struct proxm_env_tag *proxm_env, uint8_t conidx, + uint8_t status) { + // format response to app + struct proxm_enable_rsp *cfm = KE_MSG_ALLOC( + PROXM_ENABLE_RSP, prf_dst_task_get(&(proxm_env->prf_env), conidx), + prf_src_task_get(&(proxm_env->prf_env), conidx), proxm_enable_rsp); + + cfm->lls = proxm_env->env[conidx]->prox[PROXM_LK_LOSS_SVC]; + cfm->ias = proxm_env->env[conidx]->prox[PROXM_IAS_SVC]; + cfm->txps = proxm_env->env[conidx]->prox[PROXM_TX_POWER_SVC]; + cfm->status = status; + + if (status == GAP_ERR_NO_ERROR) { + // Go to IDLE state + ke_state_set(prf_src_task_get(&(proxm_env->prf_env), conidx), PROXM_IDLE); + } else { + // clean-up environment variable allocated for task instance + ke_free(proxm_env->env[conidx]); + proxm_env->env[conidx] = NULL; + } + + ke_msg_send(cfm); } -void proxm_enable_rsp_send(struct proxm_env_tag *proxm_env, uint8_t conidx, uint8_t status) -{ - //format response to app - struct proxm_enable_rsp * cfm = KE_MSG_ALLOC(PROXM_ENABLE_RSP, - prf_dst_task_get(&(proxm_env->prf_env), conidx), - prf_src_task_get(&(proxm_env->prf_env), conidx), - proxm_enable_rsp); +uint8_t proxm_validate_request(struct proxm_env_tag *proxm_env, uint8_t conidx, + uint8_t char_code) { + uint8_t status = GAP_ERR_NO_ERROR; + // check if feature val characteristic exists + if (proxm_env->env[conidx]->prox[char_code].characts[0].val_hdl == + ATT_INVALID_HANDLE) { + status = PRF_ERR_INEXISTENT_HDL; + } - cfm->lls = proxm_env->env[conidx]->prox[PROXM_LK_LOSS_SVC]; - cfm->ias = proxm_env->env[conidx]->prox[PROXM_IAS_SVC]; - cfm->txps = proxm_env->env[conidx]->prox[PROXM_TX_POWER_SVC]; - cfm->status = status; - - if (status == GAP_ERR_NO_ERROR) - { - // Go to IDLE state - ke_state_set(prf_src_task_get(&(proxm_env->prf_env), conidx), PROXM_IDLE); - } - else - { - // clean-up environment variable allocated for task instance - ke_free(proxm_env->env[conidx]); - proxm_env->env[conidx] = NULL; - } - - ke_msg_send(cfm); + return (status); } -uint8_t proxm_validate_request(struct proxm_env_tag *proxm_env, uint8_t conidx, uint8_t char_code) -{ - uint8_t status = GAP_ERR_NO_ERROR; - // check if feature val characteristic exists - if(proxm_env->env[conidx]->prox[char_code].characts[0].val_hdl == ATT_INVALID_HANDLE) - { - status = PRF_ERR_INEXISTENT_HDL; - } - - return (status); -} - -#endif //BLE_PROX_MONITOR +#endif // BLE_PROX_MONITOR /// @} PROXM diff --git a/services/ble_profiles/prox/proxm/src/proxm_task.c b/services/ble_profiles/prox/proxm/src/proxm_task.c index 04ed96b..6092b1c 100644 --- a/services/ble_profiles/prox/proxm/src/proxm_task.c +++ b/services/ble_profiles/prox/proxm/src/proxm_task.c @@ -16,29 +16,25 @@ #include "gap.h" #include "gapc.h" -#include "proxm_task.h" -#include "proxm.h" #include "gattc_task.h" #include "prf_types.h" #include "prf_utils.h" +#include "proxm.h" +#include "proxm_task.h" #include "ke_mem.h" ///// State machine used to retrieve services characteristics information -const struct prf_char_def proxm_svc_char[PROXM_SVC_NB][PROXM_SVCS_CHAR_NB] = { - [PROXM_LK_LOSS_SVC] = {{ ATT_CHAR_ALERT_LEVEL, - ATT_MANDATORY, - ATT_CHAR_PROP_RD | ATT_CHAR_PROP_WR}}, +const struct prf_char_def proxm_svc_char[PROXM_SVC_NB][PROXM_SVCS_CHAR_NB] = { + [PROXM_LK_LOSS_SVC] = {{ATT_CHAR_ALERT_LEVEL, ATT_MANDATORY, + ATT_CHAR_PROP_RD | ATT_CHAR_PROP_WR}}, - [PROXM_IAS_SVC] = {{ ATT_CHAR_ALERT_LEVEL, - ATT_MANDATORY, - ATT_CHAR_PROP_WR_NO_RESP}}, + [PROXM_IAS_SVC] = {{ATT_CHAR_ALERT_LEVEL, ATT_MANDATORY, + ATT_CHAR_PROP_WR_NO_RESP}}, - [PROXM_TX_POWER_SVC] = {{ATT_CHAR_TX_POWER_LEVEL, - ATT_MANDATORY, - ATT_CHAR_PROP_RD}} -}; + [PROXM_TX_POWER_SVC] = { + {ATT_CHAR_TX_POWER_LEVEL, ATT_MANDATORY, ATT_CHAR_PROP_RD}}}; /* * FUNCTION DEFINITIONS @@ -56,56 +52,49 @@ const struct prf_char_def proxm_svc_char[PROXM_SVC_NB][PROXM_SVCS_CHAR_NB] = { **************************************************************************************** */ __STATIC int proxm_enable_req_handler(ke_msg_id_t const msgid, - struct proxm_enable_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; + struct proxm_enable_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; - uint8_t state = ke_state_get(dest_id); - uint8_t conidx = KE_IDX_GET(dest_id); - // Proximity Monitor Environment - struct proxm_env_tag *proxm_env = PRF_ENV_GET(PROXM, proxm); + uint8_t state = ke_state_get(dest_id); + uint8_t conidx = KE_IDX_GET(dest_id); + // Proximity Monitor Environment + struct proxm_env_tag *proxm_env = PRF_ENV_GET(PROXM, proxm); - ASSERT_INFO(proxm_env != NULL, dest_id, src_id); - if((state == PROXM_IDLE) && (proxm_env->env[conidx] == NULL)) - { - // allocate environment variable for task instance - proxm_env->env[conidx] = (struct proxm_cnx_env*) ke_malloc(sizeof(struct proxm_cnx_env),KE_MEM_ATT_DB); - memset(proxm_env->env[conidx], 0, sizeof(struct proxm_cnx_env)); + ASSERT_INFO(proxm_env != NULL, dest_id, src_id); + if ((state == PROXM_IDLE) && (proxm_env->env[conidx] == NULL)) { + // allocate environment variable for task instance + proxm_env->env[conidx] = (struct proxm_cnx_env *)ke_malloc( + sizeof(struct proxm_cnx_env), KE_MEM_ATT_DB); + memset(proxm_env->env[conidx], 0, sizeof(struct proxm_cnx_env)); - if(param->con_type == PRF_CON_DISCOVERY) - { - proxm_env->env[conidx]->last_svc_req = PROXM_LK_LOSS_SVC; - prf_disc_svc_send(&(proxm_env->prf_env), conidx, ATT_SVC_LINK_LOSS); + if (param->con_type == PRF_CON_DISCOVERY) { + proxm_env->env[conidx]->last_svc_req = PROXM_LK_LOSS_SVC; + prf_disc_svc_send(&(proxm_env->prf_env), conidx, ATT_SVC_LINK_LOSS); - // Go to DISCOVERING state - ke_state_set(dest_id, PROXM_DISCOVERING); - } - else - { - proxm_env->env[conidx]->prox[PROXM_LK_LOSS_SVC] = param->lls; - proxm_env->env[conidx]->prox[PROXM_IAS_SVC] = param->ias; - proxm_env->env[conidx]->prox[PROXM_TX_POWER_SVC] = param->txps; + // Go to DISCOVERING state + ke_state_set(dest_id, PROXM_DISCOVERING); + } else { + proxm_env->env[conidx]->prox[PROXM_LK_LOSS_SVC] = param->lls; + proxm_env->env[conidx]->prox[PROXM_IAS_SVC] = param->ias; + proxm_env->env[conidx]->prox[PROXM_TX_POWER_SVC] = param->txps; - //send APP confirmation that can start normal connection to TH - proxm_enable_rsp_send(proxm_env, conidx, GAP_ERR_NO_ERROR); - } - - } - else if(state != PROXM_FREE) - { - status = PRF_ERR_REQ_DISALLOWED; + // send APP confirmation that can start normal connection to TH + proxm_enable_rsp_send(proxm_env, conidx, GAP_ERR_NO_ERROR); } - // send an error if request fails - if(status != GAP_ERR_NO_ERROR) - { - proxm_enable_rsp_send(proxm_env, conidx, status); - } + } else if (state != PROXM_FREE) { + status = PRF_ERR_REQ_DISALLOWED; + } - return (KE_MSG_CONSUMED); + // send an error if request fails + if (status != GAP_ERR_NO_ERROR) { + proxm_enable_rsp_send(proxm_env, conidx, status); + } + + return (KE_MSG_CONSUMED); } /** @@ -122,68 +111,61 @@ __STATIC int proxm_enable_req_handler(ke_msg_id_t const msgid, __STATIC int proxm_rd_req_handler(ke_msg_id_t const msgid, struct proxm_rd_req const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - uint8_t status = GAP_ERR_NO_ERROR; - uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t current_svc = PROXM_SVC_NB; + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + uint8_t status = GAP_ERR_NO_ERROR; + uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t current_svc = PROXM_SVC_NB; - if(state == PROXM_IDLE) - { - struct proxm_env_tag *proxm_env = PRF_ENV_GET(PROXM, proxm); + if (state == PROXM_IDLE) { + struct proxm_env_tag *proxm_env = PRF_ENV_GET(PROXM, proxm); - ASSERT_INFO(proxm_env != NULL, dest_id, src_id); + ASSERT_INFO(proxm_env != NULL, dest_id, src_id); - // environment variable not ready - if(proxm_env->env[conidx] == NULL) - { - status = PRF_APP_ERROR; - } - else - { - // Get the request type and handle value for this type of write - switch(param->svc_code) - { - case PROXM_RD_LL_ALERT_LVL: - current_svc = PROXM_LK_LOSS_SVC; - status = proxm_validate_request(proxm_env, conidx, PROXM_LK_LOSS_SVC); - break; - case PROXM_RD_TX_POWER_LVL: - current_svc = PROXM_TX_POWER_SVC; - status = proxm_validate_request(proxm_env, conidx, PROXM_TX_POWER_SVC); - break; - default: - current_svc = PROXM_SVC_NB; - status = PRF_ERR_INVALID_PARAM; - break; - } + // environment variable not ready + if (proxm_env->env[conidx] == NULL) { + status = PRF_APP_ERROR; + } else { + // Get the request type and handle value for this type of write + switch (param->svc_code) { + case PROXM_RD_LL_ALERT_LVL: + current_svc = PROXM_LK_LOSS_SVC; + status = proxm_validate_request(proxm_env, conidx, PROXM_LK_LOSS_SVC); + break; + case PROXM_RD_TX_POWER_LVL: + current_svc = PROXM_TX_POWER_SVC; + status = proxm_validate_request(proxm_env, conidx, PROXM_TX_POWER_SVC); + break; + default: + current_svc = PROXM_SVC_NB; + status = PRF_ERR_INVALID_PARAM; + break; + } - if(status == GAP_ERR_NO_ERROR) - { - prf_read_char_send(&(proxm_env->prf_env), conidx, - proxm_env->env[conidx]->prox[current_svc].characts[0].char_hdl, - proxm_env->env[conidx]->prox[current_svc].characts[0].char_ehdl_off, - proxm_env->env[conidx]->prox[current_svc].characts[0].val_hdl); - // wait for end of read request - proxm_env->env[conidx]->last_svc_req = param->svc_code; + if (status == GAP_ERR_NO_ERROR) { + prf_read_char_send( + &(proxm_env->prf_env), conidx, + proxm_env->env[conidx]->prox[current_svc].characts[0].char_hdl, + proxm_env->env[conidx]->prox[current_svc].characts[0].char_ehdl_off, + proxm_env->env[conidx]->prox[current_svc].characts[0].val_hdl); + // wait for end of read request + proxm_env->env[conidx]->last_svc_req = param->svc_code; - ke_state_set(dest_id, PROXM_BUSY); - } - } - - // request cannot be performed - if(status != GAP_ERR_NO_ERROR) - { - struct proxm_rd_rsp * rsp = KE_MSG_ALLOC(PROXM_RD_RSP, - src_id, dest_id, proxm_rd_rsp); - rsp->svc_code = param->svc_code; - // set error status - rsp->status = status; - ke_msg_send(rsp); - } + ke_state_set(dest_id, PROXM_BUSY); + } } - return (KE_MSG_CONSUMED); + + // request cannot be performed + if (status != GAP_ERR_NO_ERROR) { + struct proxm_rd_rsp *rsp = + KE_MSG_ALLOC(PROXM_RD_RSP, src_id, dest_id, proxm_rd_rsp); + rsp->svc_code = param->svc_code; + // set error status + rsp->status = status; + ke_msg_send(rsp); + } + } + return (KE_MSG_CONSUMED); } /** @@ -197,75 +179,67 @@ __STATIC int proxm_rd_req_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int proxm_wr_alert_lvl_req_handler(ke_msg_id_t const msgid, - struct proxm_wr_alert_lvl_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - uint8_t status = GAP_ERR_NO_ERROR; - uint8_t operation = 0x00; - uint16_t val_hdl = 0x0000; - uint8_t conidx = KE_IDX_GET(dest_id); - struct proxm_env_tag *proxm_env = PRF_ENV_GET(PROXM, proxm); +__STATIC int proxm_wr_alert_lvl_req_handler( + ke_msg_id_t const msgid, struct proxm_wr_alert_lvl_req const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + uint8_t status = GAP_ERR_NO_ERROR; + uint8_t operation = 0x00; + uint16_t val_hdl = 0x0000; + uint8_t conidx = KE_IDX_GET(dest_id); + struct proxm_env_tag *proxm_env = PRF_ENV_GET(PROXM, proxm); - if(state == PROXM_IDLE) - { - ASSERT_INFO(proxm_env != NULL, dest_id, src_id); + if (state == PROXM_IDLE) { + ASSERT_INFO(proxm_env != NULL, dest_id, src_id); - // environment variable not ready - if(proxm_env->env[conidx] == NULL) - { - status = PRF_APP_ERROR; + // environment variable not ready + if (proxm_env->env[conidx] == NULL) { + status = PRF_APP_ERROR; + } else { + // Alert level only has 3 values, other not useful + if (param->lvl <= PROXM_ALERT_HIGH) { + // Get the request type and handle value for this type of write + switch (param->svc_code) { + case PROXM_SET_LK_LOSS_ALERT: + operation = GATTC_WRITE; + val_hdl = proxm_env->env[conidx] + ->prox[PROXM_LK_LOSS_SVC] + .characts[0] + .val_hdl; + break; + case PROXM_SET_IMMDT_ALERT: + operation = GATTC_WRITE_NO_RESPONSE; + val_hdl = + proxm_env->env[conidx]->prox[PROXM_IAS_SVC].characts[0].val_hdl; + break; + default: + status = PRF_ERR_INVALID_PARAM; + break; } - else - { - // Alert level only has 3 values, other not useful - if(param->lvl <= PROXM_ALERT_HIGH) - { - // Get the request type and handle value for this type of write - switch(param->svc_code) - { - case PROXM_SET_LK_LOSS_ALERT: - operation = GATTC_WRITE; - val_hdl = proxm_env->env[conidx]->prox[PROXM_LK_LOSS_SVC].characts[0].val_hdl; - break; - case PROXM_SET_IMMDT_ALERT: - operation = GATTC_WRITE_NO_RESPONSE; - val_hdl = proxm_env->env[conidx]->prox[PROXM_IAS_SVC].characts[0].val_hdl; - break; - default: - status = PRF_ERR_INVALID_PARAM; - break; - } - if(status == GAP_ERR_NO_ERROR) - { - // Send GATT Write Request - prf_gatt_write(&(proxm_env->prf_env), conidx, val_hdl, (uint8_t *)¶m->lvl, - sizeof(uint8_t), operation); - // wait for end of write request - ke_state_set(dest_id, PROXM_BUSY); - } - } - else - { - //wrong level - not one of the possible 3 - status = PRF_ERR_INVALID_PARAM; - } - } - // An error occurs, send the response with error status - if(status != GAP_ERR_NO_ERROR) - { - struct proxm_wr_alert_lvl_rsp * rsp = KE_MSG_ALLOC(PROXM_WR_ALERT_LVL_RSP, - src_id, dest_id, proxm_wr_alert_lvl_rsp); - // set error status - rsp->status = status; - - ke_msg_send(rsp); + if (status == GAP_ERR_NO_ERROR) { + // Send GATT Write Request + prf_gatt_write(&(proxm_env->prf_env), conidx, val_hdl, + (uint8_t *)¶m->lvl, sizeof(uint8_t), operation); + // wait for end of write request + ke_state_set(dest_id, PROXM_BUSY); } + } else { + // wrong level - not one of the possible 3 + status = PRF_ERR_INVALID_PARAM; + } } - return (KE_MSG_CONSUMED); + // An error occurs, send the response with error status + if (status != GAP_ERR_NO_ERROR) { + struct proxm_wr_alert_lvl_rsp *rsp = KE_MSG_ALLOC( + PROXM_WR_ALERT_LVL_RSP, src_id, dest_id, proxm_wr_alert_lvl_rsp); + // set error status + rsp->status = status; + + ke_msg_send(rsp); + } + } + return (KE_MSG_CONSUMED); } /** @@ -280,56 +254,52 @@ __STATIC int proxm_wr_alert_lvl_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, - struct gattc_sdp_svc_ind const *ind, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_sdp_svc_ind const *ind, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == PROXM_DISCOVERING) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == PROXM_DISCOVERING) { + uint8_t conidx = KE_IDX_GET(dest_id); - uint16_t current_svc = PROXM_SVC_NB; - const struct prf_char_def* current_char_def; + uint16_t current_svc = PROXM_SVC_NB; + const struct prf_char_def *current_char_def; - struct proxm_env_tag *proxm_env = PRF_ENV_GET(PROXM, proxm); + struct proxm_env_tag *proxm_env = PRF_ENV_GET(PROXM, proxm); - ASSERT_INFO(proxm_env != NULL, dest_id, src_id); - ASSERT_INFO(proxm_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(proxm_env != NULL, dest_id, src_id); + ASSERT_INFO(proxm_env->env[conidx] != NULL, dest_id, src_id); - // check if a valid service is found - if (attm_uuid16_comp((unsigned char *)ind->uuid, ind->uuid_len, ATT_SVC_LINK_LOSS)) - { - current_svc = PROXM_LK_LOSS_SVC; - current_char_def = &proxm_svc_char[PROXM_LK_LOSS_SVC][PROXM_LK_LOSS_CHAR]; - } - else if(attm_uuid16_comp((unsigned char *)ind->uuid, ind->uuid_len, ATT_SVC_IMMEDIATE_ALERT)) - { - current_svc = PROXM_IAS_SVC; - current_char_def = &proxm_svc_char[PROXM_IAS_SVC][PROXM_IAS_CHAR]; - } - else if(attm_uuid16_comp((unsigned char *)ind->uuid, ind->uuid_len, ATT_SVC_TX_POWER)) - { - current_svc = PROXM_TX_POWER_SVC; - current_char_def = &proxm_svc_char[PROXM_TX_POWER_SVC][PROXM_TX_POWER_CHAR]; - } - - // if a valid service found, put it into environment variable - if(current_svc != PROXM_SVC_NB) - { - prf_extract_svc_info(ind, PROXM_CHAR_NB_MAX, current_char_def, - proxm_env->env[conidx]->prox[current_svc].characts, 0, NULL, NULL); - - proxm_env->env[conidx]->prox[current_svc].svc.shdl = ind->start_hdl; - proxm_env->env[conidx]->prox[current_svc].svc.ehdl = ind->end_hdl; - - proxm_env->env[conidx]->nb_svc++; - } + // check if a valid service is found + if (attm_uuid16_comp((unsigned char *)ind->uuid, ind->uuid_len, + ATT_SVC_LINK_LOSS)) { + current_svc = PROXM_LK_LOSS_SVC; + current_char_def = &proxm_svc_char[PROXM_LK_LOSS_SVC][PROXM_LK_LOSS_CHAR]; + } else if (attm_uuid16_comp((unsigned char *)ind->uuid, ind->uuid_len, + ATT_SVC_IMMEDIATE_ALERT)) { + current_svc = PROXM_IAS_SVC; + current_char_def = &proxm_svc_char[PROXM_IAS_SVC][PROXM_IAS_CHAR]; + } else if (attm_uuid16_comp((unsigned char *)ind->uuid, ind->uuid_len, + ATT_SVC_TX_POWER)) { + current_svc = PROXM_TX_POWER_SVC; + current_char_def = + &proxm_svc_char[PROXM_TX_POWER_SVC][PROXM_TX_POWER_CHAR]; } - return (KE_MSG_CONSUMED); -} + // if a valid service found, put it into environment variable + if (current_svc != PROXM_SVC_NB) { + prf_extract_svc_info(ind, PROXM_CHAR_NB_MAX, current_char_def, + proxm_env->env[conidx]->prox[current_svc].characts, + 0, NULL, NULL); + + proxm_env->env[conidx]->prox[current_svc].svc.shdl = ind->start_hdl; + proxm_env->env[conidx]->prox[current_svc].svc.ehdl = ind->end_hdl; + + proxm_env->env[conidx]->nb_svc++; + } + } + return (KE_MSG_CONSUMED); +} /** **************************************************************************************** @@ -343,103 +313,92 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, - struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - // Get the address of the environment - struct proxm_env_tag *proxm_env = PRF_ENV_GET(PROXM, proxm); - uint8_t conidx = KE_IDX_GET(dest_id); - uint16_t current_att_svc = ATT_INVALID_UUID; - uint8_t status = GAP_ERR_NO_ERROR; + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + // Get the address of the environment + struct proxm_env_tag *proxm_env = PRF_ENV_GET(PROXM, proxm); + uint8_t conidx = KE_IDX_GET(dest_id); + uint16_t current_att_svc = ATT_INVALID_UUID; + uint8_t status = GAP_ERR_NO_ERROR; - if(state == PROXM_DISCOVERING) - { - status = prf_check_svc_char_validity(PROXM_SVCS_CHAR_NB, - proxm_env->env[conidx]->prox[proxm_env->env[conidx]->last_svc_req].characts, - proxm_svc_char[proxm_env->env[conidx]->last_svc_req]); + if (state == PROXM_DISCOVERING) { + status = prf_check_svc_char_validity( + PROXM_SVCS_CHAR_NB, + proxm_env->env[conidx] + ->prox[proxm_env->env[conidx]->last_svc_req] + .characts, + proxm_svc_char[proxm_env->env[conidx]->last_svc_req]); - // Too many services found only one such service should exist - if(proxm_env->env[conidx]->nb_svc > 1) - { - status = PRF_ERR_MULTIPLE_SVC; - } - // if an error append, send confirmation with error status and stop discovering - if(status != GAP_ERR_NO_ERROR) - { - proxm_enable_rsp_send(proxm_env, conidx, status); - } - // if a valid service found, discover and then send confirmation message - else - { - proxm_env->env[conidx]->nb_svc =0; - proxm_env->env[conidx]->last_svc_req += 1; - - if((proxm_env->env[conidx]->last_svc_req) < PROXM_SVC_NB) - { - switch(proxm_env->env[conidx]->last_svc_req) - { - case PROXM_LK_LOSS_SVC: - current_att_svc = ATT_SVC_LINK_LOSS; - break; - case PROXM_IAS_SVC: - current_att_svc = ATT_SVC_IMMEDIATE_ALERT; - break; - case PROXM_TX_POWER_SVC: - current_att_svc = ATT_SVC_TX_POWER; - break; - default : break; - } - - prf_disc_svc_send(&(proxm_env->prf_env), conidx, current_att_svc); - } - else - { - proxm_enable_rsp_send(proxm_env, conidx, GAP_ERR_NO_ERROR); - } - } + // Too many services found only one such service should exist + if (proxm_env->env[conidx]->nb_svc > 1) { + status = PRF_ERR_MULTIPLE_SVC; } - else if (state == PROXM_BUSY) - { - switch(param->operation) - { - case GATTC_WRITE: - case GATTC_WRITE_NO_RESPONSE: - { - struct proxm_wr_alert_lvl_rsp * rsp = KE_MSG_ALLOC(PROXM_WR_ALERT_LVL_RSP, - prf_dst_task_get(&(proxm_env->prf_env), conidx), - prf_src_task_get(&(proxm_env->prf_env), conidx), - proxm_wr_alert_lvl_rsp); - // set error status - rsp->status = param->status; - ke_msg_send(rsp); - - ke_state_set(dest_id, PROXM_IDLE); - } - break; - - case GATTC_READ: - { - if(param->status != GAP_ERR_NO_ERROR) - { - struct proxm_rd_rsp * rsp = KE_MSG_ALLOC(PROXM_RD_RSP, - prf_dst_task_get(&(proxm_env->prf_env), conidx), - prf_src_task_get(&(proxm_env->prf_env), conidx), - proxm_rd_rsp); - // set error status - rsp->status = param->status; - rsp->svc_code = proxm_env->env[conidx]->last_svc_req; - ke_msg_send(rsp); - } - ke_state_set(dest_id, PROXM_IDLE); - } - break; - default: break; - } + // if an error append, send confirmation with error status and stop + // discovering + if (status != GAP_ERR_NO_ERROR) { + proxm_enable_rsp_send(proxm_env, conidx, status); } + // if a valid service found, discover and then send confirmation message + else { + proxm_env->env[conidx]->nb_svc = 0; + proxm_env->env[conidx]->last_svc_req += 1; - return (KE_MSG_CONSUMED); + if ((proxm_env->env[conidx]->last_svc_req) < PROXM_SVC_NB) { + switch (proxm_env->env[conidx]->last_svc_req) { + case PROXM_LK_LOSS_SVC: + current_att_svc = ATT_SVC_LINK_LOSS; + break; + case PROXM_IAS_SVC: + current_att_svc = ATT_SVC_IMMEDIATE_ALERT; + break; + case PROXM_TX_POWER_SVC: + current_att_svc = ATT_SVC_TX_POWER; + break; + default: + break; + } + + prf_disc_svc_send(&(proxm_env->prf_env), conidx, current_att_svc); + } else { + proxm_enable_rsp_send(proxm_env, conidx, GAP_ERR_NO_ERROR); + } + } + } else if (state == PROXM_BUSY) { + switch (param->operation) { + case GATTC_WRITE: + case GATTC_WRITE_NO_RESPONSE: { + struct proxm_wr_alert_lvl_rsp *rsp = + KE_MSG_ALLOC(PROXM_WR_ALERT_LVL_RSP, + prf_dst_task_get(&(proxm_env->prf_env), conidx), + prf_src_task_get(&(proxm_env->prf_env), conidx), + proxm_wr_alert_lvl_rsp); + // set error status + rsp->status = param->status; + ke_msg_send(rsp); + + ke_state_set(dest_id, PROXM_IDLE); + } break; + + case GATTC_READ: { + if (param->status != GAP_ERR_NO_ERROR) { + struct proxm_rd_rsp *rsp = KE_MSG_ALLOC( + PROXM_RD_RSP, prf_dst_task_get(&(proxm_env->prf_env), conidx), + prf_src_task_get(&(proxm_env->prf_env), conidx), proxm_rd_rsp); + // set error status + rsp->status = param->status; + rsp->svc_code = proxm_env->env[conidx]->last_svc_req; + ke_msg_send(rsp); + } + ke_state_set(dest_id, PROXM_IDLE); + } break; + default: + break; + } + } + + return (KE_MSG_CONSUMED); } /** @@ -456,26 +415,23 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, struct gattc_read_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if(ke_state_get(dest_id) == PROXM_BUSY) - { - struct proxm_env_tag *proxm_env = PRF_ENV_GET(PROXM, proxm); - uint8_t conidx = KE_IDX_GET(dest_id); + ke_task_id_t const src_id) { + if (ke_state_get(dest_id) == PROXM_BUSY) { + struct proxm_env_tag *proxm_env = PRF_ENV_GET(PROXM, proxm); + uint8_t conidx = KE_IDX_GET(dest_id); - ASSERT_INFO(proxm_env != NULL, dest_id, src_id); - ASSERT_INFO(proxm_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(proxm_env != NULL, dest_id, src_id); + ASSERT_INFO(proxm_env->env[conidx] != NULL, dest_id, src_id); - struct proxm_rd_rsp * rsp = KE_MSG_ALLOC(PROXM_RD_RSP, - prf_dst_task_get(&(proxm_env->prf_env), conidx), - dest_id, - proxm_rd_rsp); - rsp->status = GAP_ERR_NO_ERROR; - rsp->svc_code = proxm_env->env[conidx]->last_svc_req; - rsp->value = param->value[0]; - ke_msg_send(rsp); - } - return (KE_MSG_CONSUMED); + struct proxm_rd_rsp *rsp = KE_MSG_ALLOC( + PROXM_RD_RSP, prf_dst_task_get(&(proxm_env->prf_env), conidx), dest_id, + proxm_rd_rsp); + rsp->status = GAP_ERR_NO_ERROR; + rsp->svc_code = proxm_env->env[conidx]->last_svc_req; + rsp->value = param->value[0]; + ke_msg_send(rsp); + } + return (KE_MSG_CONSUMED); } /* @@ -484,27 +440,25 @@ __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, */ /// Default State handlers definition -KE_MSG_HANDLER_TAB(proxm) -{ - {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, - {PROXM_ENABLE_REQ, (ke_msg_func_t)proxm_enable_req_handler}, - {PROXM_WR_ALERT_LVL_REQ, (ke_msg_func_t)proxm_wr_alert_lvl_req_handler}, - {PROXM_RD_REQ, (ke_msg_func_t)proxm_rd_req_handler}, - {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, +KE_MSG_HANDLER_TAB(proxm){ + {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, + {PROXM_ENABLE_REQ, (ke_msg_func_t)proxm_enable_req_handler}, + {PROXM_WR_ALERT_LVL_REQ, (ke_msg_func_t)proxm_wr_alert_lvl_req_handler}, + {PROXM_RD_REQ, (ke_msg_func_t)proxm_rd_req_handler}, + {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void proxm_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct proxm_env_tag *proxm_env = PRF_ENV_GET(PROXM, proxm); +void proxm_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct proxm_env_tag *proxm_env = PRF_ENV_GET(PROXM, proxm); - task_desc->msg_handler_tab = proxm_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(proxm_msg_handler_tab); - task_desc->state = proxm_env->state; - task_desc->idx_max = PROXM_IDX_MAX; + task_desc->msg_handler_tab = proxm_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(proxm_msg_handler_tab); + task_desc->state = proxm_env->state; + task_desc->idx_max = PROXM_IDX_MAX; } -#endif //BLE_PROX_MONITOR +#endif // BLE_PROX_MONITOR /// @} PROXMTASK diff --git a/services/ble_profiles/prox/proxr/src/proxr.c b/services/ble_profiles/prox/proxr/src/proxr.c index 9f39793..d25cc8a 100644 --- a/services/ble_profiles/prox/proxr/src/proxr.c +++ b/services/ble_profiles/prox/proxr/src/proxr.c @@ -14,10 +14,10 @@ #if (BLE_PROX_REPORTER) -#include "proxr.h" -#include "proxr_task.h" #include "attm.h" #include "gap.h" +#include "proxr.h" +#include "proxr_task.h" #include "ke_mem.h" @@ -27,115 +27,124 @@ */ /// Full LLS Database Description - Used to add attributes into the database -const struct attm_desc proxr_lls_att_db[LLS_IDX_NB] = -{ +const struct attm_desc proxr_lls_att_db[LLS_IDX_NB] = { // Link Loss Service Declaration - [LLS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [LLS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // Alert Level Characteristic Declaration - [LLS_IDX_ALERT_LVL_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [LLS_IDX_ALERT_LVL_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Alert Level Characteristic Value - [LLS_IDX_ALERT_LVL_VAL] = {ATT_CHAR_ALERT_LEVEL, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), PERM(RI, ENABLE), sizeof(uint8_t)}, + [LLS_IDX_ALERT_LVL_VAL] = {ATT_CHAR_ALERT_LEVEL, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE), sizeof(uint8_t)}, }; /// Full IAS Database Description - Used to add attributes into the database -const struct attm_desc proxr_ias_att_db[IAS_IDX_NB] = -{ +const struct attm_desc proxr_ias_att_db[IAS_IDX_NB] = { // Immediate Alert Service Declaration - [IAS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE),0, 0}, + [IAS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // Alert Level Characteristic Declaration - [IAS_IDX_ALERT_LVL_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [IAS_IDX_ALERT_LVL_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Alert Level Characteristic Value - [IAS_IDX_ALERT_LVL_VAL] = {ATT_CHAR_ALERT_LEVEL, PERM(WRITE_COMMAND, ENABLE), PERM(RI, ENABLE), sizeof(uint8_t)}, + [IAS_IDX_ALERT_LVL_VAL] = {ATT_CHAR_ALERT_LEVEL, + PERM(WRITE_COMMAND, ENABLE), PERM(RI, ENABLE), + sizeof(uint8_t)}, }; /// Full TXPS Database Description - Used to add attributes into the database -const struct attm_desc proxr_txps_att_db[TXPS_IDX_NB] = -{ +const struct attm_desc proxr_txps_att_db[TXPS_IDX_NB] = { // TX Power Service Declaration - [TXPS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [TXPS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // TX Power Level Characteristic Declaration - [TXPS_IDX_TX_POWER_LVL_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [TXPS_IDX_TX_POWER_LVL_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), + 0, 0}, // TX Power Level Characteristic Value - [TXPS_IDX_TX_POWER_LVL_VAL] = {ATT_CHAR_TX_POWER_LEVEL, PERM(RD, ENABLE), PERM(RI, ENABLE), sizeof(uint8_t)}, + [TXPS_IDX_TX_POWER_LVL_VAL] = {ATT_CHAR_TX_POWER_LEVEL, PERM(RD, ENABLE), + PERM(RI, ENABLE), sizeof(uint8_t)}, }; /* * LOCAL FUNCTION DEFINITIONS **************************************************************************************** */ -static uint8_t proxr_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, - uint8_t sec_lvl, struct proxr_db_cfg* params) -{ - // Service content flag - uint32_t cfg_flag = PROXR_LLS_MANDATORY_MASK; - // DB Creation Status - uint8_t status = ATT_ERR_NO_ERROR; +static uint8_t proxr_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, + struct proxr_db_cfg *params) { + // Service content flag + uint32_t cfg_flag = PROXR_LLS_MANDATORY_MASK; + // DB Creation Status + uint8_t status = ATT_ERR_NO_ERROR; - //-------------------- allocate memory required for the profile --------------------- - struct proxr_env_tag* proxr_env = - (struct proxr_env_tag* ) ke_malloc(sizeof(struct proxr_env_tag), KE_MEM_ATT_DB); + //-------------------- allocate memory required for the profile + //--------------------- + struct proxr_env_tag *proxr_env = (struct proxr_env_tag *)ke_malloc( + sizeof(struct proxr_env_tag), KE_MEM_ATT_DB); - // allocate PROXR required environment variable - env->env = (prf_env_t*) proxr_env; + // allocate PROXR required environment variable + env->env = (prf_env_t *)proxr_env; - status = attm_svc_create_db(start_hdl, ATT_SVC_LINK_LOSS, (uint8_t *)&cfg_flag, - LLS_IDX_NB, NULL, env->task, &proxr_lls_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) - | PERM(SVC_MI, DISABLE) ); + status = attm_svc_create_db( + start_hdl, ATT_SVC_LINK_LOSS, (uint8_t *)&cfg_flag, LLS_IDX_NB, NULL, + env->task, &proxr_lls_att_db[0], + (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, DISABLE)); - proxr_env->lls_start_hdl = *start_hdl; - *start_hdl += LLS_IDX_NB; + proxr_env->lls_start_hdl = *start_hdl; + *start_hdl += LLS_IDX_NB; - if( (status == ATT_ERR_NO_ERROR) && (params->features == PROXR_IAS_TXPS_SUP) ) - { - cfg_flag = PROXR_IAS_MANDATORY_MASK; - status = attm_svc_create_db(start_hdl, ATT_SVC_IMMEDIATE_ALERT, (uint8_t *)&cfg_flag, - IAS_IDX_NB, NULL, env->task, &proxr_ias_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) - | PERM(SVC_MI, DISABLE) ); + if ((status == ATT_ERR_NO_ERROR) && + (params->features == PROXR_IAS_TXPS_SUP)) { + cfg_flag = PROXR_IAS_MANDATORY_MASK; + status = attm_svc_create_db( + start_hdl, ATT_SVC_IMMEDIATE_ALERT, (uint8_t *)&cfg_flag, IAS_IDX_NB, + NULL, env->task, &proxr_ias_att_db[0], + (sec_lvl & + (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, DISABLE)); - proxr_env->ias_start_hdl = *start_hdl; - *start_hdl += IAS_IDX_NB; + proxr_env->ias_start_hdl = *start_hdl; + *start_hdl += IAS_IDX_NB; - if( status == ATT_ERR_NO_ERROR ) - { - cfg_flag = PROXR_TXP_MANDATORY_MASK; - status = attm_svc_create_db(start_hdl, ATT_SVC_TX_POWER, (uint8_t *)&cfg_flag, - TXPS_IDX_NB, NULL, env->task, &proxr_txps_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) - | PERM(SVC_MI, DISABLE) ); + if (status == ATT_ERR_NO_ERROR) { + cfg_flag = PROXR_TXP_MANDATORY_MASK; + status = attm_svc_create_db( + start_hdl, ATT_SVC_TX_POWER, (uint8_t *)&cfg_flag, TXPS_IDX_NB, NULL, + env->task, &proxr_txps_att_db[0], + (sec_lvl & + (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, DISABLE)); - proxr_env->txp_start_hdl = *start_hdl; + proxr_env->txp_start_hdl = *start_hdl; - if (status == ATT_ERR_NO_ERROR) - { - // set start handle to first allocated service value - *start_hdl = proxr_env->ias_start_hdl; + if (status == ATT_ERR_NO_ERROR) { + // set start handle to first allocated service value + *start_hdl = proxr_env->ias_start_hdl; - proxr_env->features = params->features; - proxr_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - proxr_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); + proxr_env->features = params->features; + proxr_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + proxr_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); - // initialize environment variable - env->id = TASK_ID_PROXR; - proxr_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_PROXR; + proxr_task_init(&(env->desc)); - // service is ready, go into an Idle state - ke_state_set(env->task, PROXR_IDLE); - } - } + // service is ready, go into an Idle state + ke_state_set(env->task, PROXR_IDLE); + } } - return (status); + } + return (status); } -static void proxr_destroy(struct prf_task_env* env) -{ - struct proxr_env_tag* proxr_env = (struct proxr_env_tag*) env->env; +static void proxr_destroy(struct prf_task_env *env) { + struct proxr_env_tag *proxr_env = (struct proxr_env_tag *)env->env; - // free profile environment variables - env->env = NULL; - ke_free(proxr_env); + // free profile environment variables + env->env = NULL; + ke_free(proxr_env); } /** @@ -146,11 +155,10 @@ static void proxr_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void proxr_create(struct prf_task_env* env, uint8_t conidx) -{ - struct proxr_env_tag* proxr_env = (struct proxr_env_tag*) env->env; +static void proxr_create(struct prf_task_env *env, uint8_t conidx) { + struct proxr_env_tag *proxr_env = (struct proxr_env_tag *)env->env; - proxr_env->lls_alert_lvl[conidx] = PROXR_ALERT_NONE; + proxr_env->lls_alert_lvl[conidx] = PROXR_ALERT_NONE; } /** @@ -162,43 +170,38 @@ static void proxr_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void proxr_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct proxr_env_tag* proxr_env = (struct proxr_env_tag*) env->env; +static void proxr_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct proxr_env_tag *proxr_env = (struct proxr_env_tag *)env->env; - if((proxr_env->features == PROXR_IAS_TXPS_SUP) && (reason != LL_ERR_REMOTE_USER_TERM_CON)) - { - if(proxr_env->lls_alert_lvl[conidx] > PROXR_ALERT_NONE) - { + if ((proxr_env->features == PROXR_IAS_TXPS_SUP) && + (reason != LL_ERR_REMOTE_USER_TERM_CON)) { + if (proxr_env->lls_alert_lvl[conidx] > PROXR_ALERT_NONE) { - // Allocate the alert value change indication - struct proxr_alert_ind *ind = KE_MSG_ALLOC(PROXR_ALERT_IND, - prf_dst_task_get(&(proxr_env->prf_env), conidx), - prf_src_task_get(&(proxr_env->prf_env), conidx), proxr_alert_ind); + // Allocate the alert value change indication + struct proxr_alert_ind *ind = KE_MSG_ALLOC( + PROXR_ALERT_IND, prf_dst_task_get(&(proxr_env->prf_env), conidx), + prf_src_task_get(&(proxr_env->prf_env), conidx), proxr_alert_ind); - // Fill in the parameter structure - ind->alert_lvl = proxr_env->lls_alert_lvl[conidx]; - ind->char_code = PROXR_LLS_CHAR; - ind->conidx = conidx; + // Fill in the parameter structure + ind->alert_lvl = proxr_env->lls_alert_lvl[conidx]; + ind->char_code = PROXR_LLS_CHAR; + ind->conidx = conidx; - // Send the message - ke_msg_send(ind); - } + // Send the message + ke_msg_send(ind); } - + } } - /* * GLOBAL VARIABLE DEFINITIONS **************************************************************************************** */ - /// PROXR Task interface required by profile manager -const struct prf_task_cbs proxr_itf = -{ - (prf_init_fnct) proxr_init, +const struct prf_task_cbs proxr_itf = { + (prf_init_fnct)proxr_init, proxr_destroy, proxr_create, proxr_cleanup, @@ -209,12 +212,8 @@ const struct prf_task_cbs proxr_itf = **************************************************************************************** */ -const struct prf_task_cbs* proxr_prf_itf_get(void) -{ - return &proxr_itf; -} +const struct prf_task_cbs *proxr_prf_itf_get(void) { return &proxr_itf; } - -#endif //BLE_PROX_REPORTER +#endif // BLE_PROX_REPORTER /// @} PROXR diff --git a/services/ble_profiles/prox/proxr/src/proxr_task.c b/services/ble_profiles/prox/proxr/src/proxr_task.c index 7a3a63c..dfedeb1 100644 --- a/services/ble_profiles/prox/proxr/src/proxr_task.c +++ b/services/ble_profiles/prox/proxr/src/proxr_task.c @@ -5,7 +5,6 @@ **************************************************************************************** */ - /* * INCLUDE FILES **************************************************************************************** @@ -16,12 +15,12 @@ #if (BLE_PROX_REPORTER) #include "co_utils.h" +#include "attm.h" #include "gap.h" #include "gattc_task.h" -#include "attm.h" -#include "proxr_task.h" -#include "proxr.h" #include "prf_utils.h" +#include "proxr.h" +#include "proxr_task.h" /* * FUNCTION DEFINITIONS @@ -39,69 +38,59 @@ * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_write_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ +__STATIC int gattc_write_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { - int msg_status = KE_MSG_CONSUMED; + int msg_status = KE_MSG_CONSUMED; - if(ke_state_get(dest_id) == PROXR_IDLE) - { - uint8_t alert_lvl = 0x0000; - uint8_t conidx = KE_IDX_GET(src_id); - // Allocate write confirmation message. - struct gattc_write_cfm *cfm = KE_MSG_ALLOC(GATTC_WRITE_CFM, - src_id, dest_id, gattc_write_cfm); + if (ke_state_get(dest_id) == PROXR_IDLE) { + uint8_t alert_lvl = 0x0000; + uint8_t conidx = KE_IDX_GET(src_id); + // Allocate write confirmation message. + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - // Get the address of the environment - struct proxr_env_tag *proxr_env = PRF_ENV_GET(PROXR, proxr); + // Get the address of the environment + struct proxr_env_tag *proxr_env = PRF_ENV_GET(PROXR, proxr); + // Fill in the parameter structure + cfm->handle = param->handle; + cfm->status = PRF_APP_ERROR; + + if (param->value[0] <= PROXR_ALERT_HIGH) { + alert_lvl = param->value[0]; + // Store alert level on the environment + if (param->handle == (proxr_env->lls_start_hdl + LLS_IDX_ALERT_LVL_VAL)) { + proxr_env->lls_alert_lvl[conidx] = alert_lvl; + cfm->status = GAP_ERR_NO_ERROR; + } else if (param->handle == + (proxr_env->ias_start_hdl + IAS_IDX_ALERT_LVL_VAL)) { + // Allocate the alert value change indication + struct proxr_alert_ind *ind = KE_MSG_ALLOC( + PROXR_ALERT_IND, prf_dst_task_get(&(proxr_env->prf_env), conidx), + dest_id, proxr_alert_ind); // Fill in the parameter structure - cfm->handle = param->handle; - cfm->status = PRF_APP_ERROR; - - if(param->value[0] <= PROXR_ALERT_HIGH) - { - alert_lvl = param->value[0]; - // Store alert level on the environment - if(param->handle == (proxr_env->lls_start_hdl + LLS_IDX_ALERT_LVL_VAL)) - { - proxr_env->lls_alert_lvl[conidx] = alert_lvl; - cfm->status = GAP_ERR_NO_ERROR; - } - else if(param->handle == (proxr_env->ias_start_hdl + IAS_IDX_ALERT_LVL_VAL)) - { - // Allocate the alert value change indication - struct proxr_alert_ind *ind = KE_MSG_ALLOC(PROXR_ALERT_IND, - prf_dst_task_get(&(proxr_env->prf_env), conidx), - dest_id, proxr_alert_ind); - // Fill in the parameter structure - ind->alert_lvl = alert_lvl; - ind->char_code = PROXR_IAS_CHAR; - ind->conidx = conidx; - - // Send the message - ke_msg_send(ind); - - cfm->status = GAP_ERR_NO_ERROR; - } - else - { - cfm->status = ATT_ERR_REQUEST_NOT_SUPPORTED; - } - } + ind->alert_lvl = alert_lvl; + ind->char_code = PROXR_IAS_CHAR; + ind->conidx = conidx; // Send the message - ke_msg_send(cfm); - } - else if(ke_state_get(dest_id) == PROXR_BUSY) - { - msg_status = KE_MSG_SAVED; + ke_msg_send(ind); + + cfm->status = GAP_ERR_NO_ERROR; + } else { + cfm->status = ATT_ERR_REQUEST_NOT_SUPPORTED; + } } - return (msg_status); + // Send the message + ke_msg_send(cfm); + } else if (ke_state_get(dest_id) == PROXR_BUSY) { + msg_status = KE_MSG_SAVED; + } + + return (msg_status); } /** @@ -116,67 +105,58 @@ __STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_read_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - int msg_status = KE_MSG_CONSUMED; + struct gattc_read_req_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + int msg_status = KE_MSG_CONSUMED; - if(ke_state_get(dest_id) == PROXR_IDLE) - { - // Get the address of the environment - struct proxr_env_tag *proxr_env = PRF_ENV_GET(PROXR, proxr); - uint8_t conidx = KE_IDX_GET(src_id); + if (ke_state_get(dest_id) == PROXR_IDLE) { + // Get the address of the environment + struct proxr_env_tag *proxr_env = PRF_ENV_GET(PROXR, proxr); + uint8_t conidx = KE_IDX_GET(src_id); - uint8_t value = PROXR_ALERT_NONE; - uint8_t status = ATT_ERR_NO_ERROR; + uint8_t value = PROXR_ALERT_NONE; + uint8_t status = ATT_ERR_NO_ERROR; - if(param->handle == (proxr_env->lls_start_hdl + LLS_IDX_ALERT_LVL_VAL)) - { - value = proxr_env->lls_alert_lvl[conidx]; - } - else if(param->handle == (proxr_env->txp_start_hdl + TXPS_IDX_TX_POWER_LVL_VAL)) - { - // send a request to read TX power level on GAPM - struct gapm_get_dev_info_cmd* cmd = KE_MSG_ALLOC(GAPM_GET_DEV_INFO_CMD, TASK_GAPM, dest_id, - gapm_get_dev_info_cmd); - cmd->operation = GAPM_GET_DEV_ADV_TX_POWER; - ke_msg_send(cmd); + if (param->handle == (proxr_env->lls_start_hdl + LLS_IDX_ALERT_LVL_VAL)) { + value = proxr_env->lls_alert_lvl[conidx]; + } else if (param->handle == + (proxr_env->txp_start_hdl + TXPS_IDX_TX_POWER_LVL_VAL)) { + // send a request to read TX power level on GAPM + struct gapm_get_dev_info_cmd *cmd = KE_MSG_ALLOC( + GAPM_GET_DEV_INFO_CMD, TASK_GAPM, dest_id, gapm_get_dev_info_cmd); + cmd->operation = GAPM_GET_DEV_ADV_TX_POWER; + ke_msg_send(cmd); - // save the connection index - proxr_env->conidx_saved = conidx; + // save the connection index + proxr_env->conidx_saved = conidx; - // need to wait for GAPM response, go into busy state - ke_state_set(dest_id, PROXR_BUSY); + // need to wait for GAPM response, go into busy state + ke_state_set(dest_id, PROXR_BUSY); - status = PRF_APP_ERROR; - } - else - { - status = ATT_ERR_REQUEST_NOT_SUPPORTED; - } - - // Don't send the confirmation if gap read request has been initiated. - if(status != PRF_APP_ERROR) - { - // Send data to peer device - struct gattc_read_cfm* cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, - gattc_read_cfm, sizeof(uint8_t)); - cfm->length = sizeof(uint8_t); - cfm->value[0] = value; - cfm->handle = param->handle; - cfm->status = status; - - // Send value to peer device. - ke_msg_send(cfm); - } - } - else if(ke_state_get(dest_id) == PROXR_BUSY) - { - msg_status = KE_MSG_SAVED; + status = PRF_APP_ERROR; + } else { + status = ATT_ERR_REQUEST_NOT_SUPPORTED; } - return msg_status; + // Don't send the confirmation if gap read request has been initiated. + if (status != PRF_APP_ERROR) { + // Send data to peer device + struct gattc_read_cfm *cfm = KE_MSG_ALLOC_DYN( + GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(uint8_t)); + cfm->length = sizeof(uint8_t); + cfm->value[0] = value; + cfm->handle = param->handle; + cfm->status = status; + + // Send value to peer device. + ke_msg_send(cfm); + } + } else if (ke_state_get(dest_id) == PROXR_BUSY) { + msg_status = KE_MSG_SAVED; + } + + return msg_status; } /** @@ -190,30 +170,28 @@ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gapm_dev_adv_tx_power_ind_handler(ke_msg_id_t const msgid, - struct gapm_dev_adv_tx_power_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct proxr_env_tag *proxr_env = PRF_ENV_GET(PROXR, proxr); +__STATIC int gapm_dev_adv_tx_power_ind_handler( + ke_msg_id_t const msgid, struct gapm_dev_adv_tx_power_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Get the address of the environment + struct proxr_env_tag *proxr_env = PRF_ENV_GET(PROXR, proxr); - if( ke_state_get(dest_id) == PROXR_BUSY ) - { - // Send data to peer device - struct gattc_read_cfm* cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, KE_BUILD_ID(TASK_GATTC, proxr_env->conidx_saved), dest_id, - gattc_read_cfm, sizeof(uint8_t)); - cfm->length = sizeof(uint8_t); - cfm->value[0] = param->power_lvl; - cfm->handle = proxr_env->txp_start_hdl + TXPS_IDX_TX_POWER_LVL_VAL; - cfm->status = GAP_ERR_NO_ERROR; + if (ke_state_get(dest_id) == PROXR_BUSY) { + // Send data to peer device + struct gattc_read_cfm *cfm = KE_MSG_ALLOC_DYN( + GATTC_READ_CFM, KE_BUILD_ID(TASK_GATTC, proxr_env->conidx_saved), + dest_id, gattc_read_cfm, sizeof(uint8_t)); + cfm->length = sizeof(uint8_t); + cfm->value[0] = param->power_lvl; + cfm->handle = proxr_env->txp_start_hdl + TXPS_IDX_TX_POWER_LVL_VAL; + cfm->status = GAP_ERR_NO_ERROR; - // Send value to peer device. - ke_msg_send(cfm); + // Send value to peer device. + ke_msg_send(cfm); - ke_state_set(dest_id, PROXR_IDLE); - } - return (KE_MSG_CONSUMED); + ke_state_set(dest_id, PROXR_IDLE); + } + return (KE_MSG_CONSUMED); } /** @@ -228,28 +206,28 @@ __STATIC int gapm_dev_adv_tx_power_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gapm_cmp_evt_handler(ke_msg_id_t const msgid, - struct gapm_cmp_evt const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct proxr_env_tag *proxr_env = PRF_ENV_GET(PROXR, proxr); + struct gapm_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct proxr_env_tag *proxr_env = PRF_ENV_GET(PROXR, proxr); - if( (ke_state_get(dest_id) == PROXR_BUSY) && (param->status != GAP_ERR_NO_ERROR)) - { - // Send data to peer device - struct gattc_read_cfm* cfm = KE_MSG_ALLOC(GATTC_READ_CFM, KE_BUILD_ID(TASK_GATTC, - proxr_env->conidx_saved), dest_id, gattc_read_cfm); - cfm->length = sizeof(uint8_t); - cfm->handle = proxr_env->txp_start_hdl + TXPS_IDX_TX_POWER_LVL_VAL; - cfm->status = PRF_APP_ERROR; + if ((ke_state_get(dest_id) == PROXR_BUSY) && + (param->status != GAP_ERR_NO_ERROR)) { + // Send data to peer device + struct gattc_read_cfm *cfm = KE_MSG_ALLOC( + GATTC_READ_CFM, KE_BUILD_ID(TASK_GATTC, proxr_env->conidx_saved), + dest_id, gattc_read_cfm); + cfm->length = sizeof(uint8_t); + cfm->handle = proxr_env->txp_start_hdl + TXPS_IDX_TX_POWER_LVL_VAL; + cfm->status = PRF_APP_ERROR; - // Send value to peer device. - ke_msg_send(cfm); + // Send value to peer device. + ke_msg_send(cfm); - ke_state_set(dest_id, PROXR_IDLE); - } - return (KE_MSG_CONSUMED); + ke_state_set(dest_id, PROXR_IDLE); + } + return (KE_MSG_CONSUMED); } /* @@ -258,25 +236,24 @@ __STATIC int gapm_cmp_evt_handler(ke_msg_id_t const msgid, */ /// Default State handlers definition -KE_MSG_HANDLER_TAB(proxr) -{ - {GATTC_WRITE_REQ_IND, (ke_msg_func_t) gattc_write_req_ind_handler}, - {GATTC_READ_REQ_IND, (ke_msg_func_t) gattc_read_req_ind_handler}, - {GAPM_DEV_ADV_TX_POWER_IND, (ke_msg_func_t) gapm_dev_adv_tx_power_ind_handler}, - {GAPM_CMP_EVT, (ke_msg_func_t) gapm_cmp_evt_handler}, +KE_MSG_HANDLER_TAB(proxr){ + {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, + {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, + {GAPM_DEV_ADV_TX_POWER_IND, + (ke_msg_func_t)gapm_dev_adv_tx_power_ind_handler}, + {GAPM_CMP_EVT, (ke_msg_func_t)gapm_cmp_evt_handler}, }; -void proxr_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct proxr_env_tag *proxr_env = PRF_ENV_GET(PROXR, proxr); +void proxr_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct proxr_env_tag *proxr_env = PRF_ENV_GET(PROXR, proxr); - task_desc->msg_handler_tab = proxr_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(proxr_msg_handler_tab); - task_desc->state = proxr_env->state; - task_desc->idx_max = PROXR_IDX_MAX; + task_desc->msg_handler_tab = proxr_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(proxr_msg_handler_tab); + task_desc->state = proxr_env->state; + task_desc->idx_max = PROXR_IDX_MAX; } -#endif //BLE_PROX_REPORTER +#endif // BLE_PROX_REPORTER /// @} PROXRTASK diff --git a/services/ble_profiles/rscp/rscpc/src/rscpc.c b/services/ble_profiles/rscp/rscpc/src/rscpc.c index dc80922..b59557c 100644 --- a/services/ble_profiles/rscp/rscpc/src/rscpc.c +++ b/services/ble_profiles/rscp/rscpc/src/rscpc.c @@ -15,18 +15,16 @@ #if (BLE_RSC_COLLECTOR) #include "rscp_common.h" - +#include "ke_mem.h" +#include "ke_timer.h" #include "rscpc.h" #include "rscpc_task.h" -#include "ke_timer.h" -#include "ke_mem.h" /* * GLOBAL VARIABLES DECLARATION **************************************************************************************** */ - /* * LOCAL FUNCTIONS DEFINITIONS **************************************************************************************** @@ -44,41 +42,45 @@ * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t rscpc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t idx; - //-------------------- allocate memory required for the profile --------------------- +static uint8_t rscpc_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t idx; + //-------------------- allocate memory required for the profile + //--------------------- - struct rscpc_env_tag* rscpc_env = - (struct rscpc_env_tag* ) ke_malloc(sizeof(struct rscpc_env_tag), KE_MEM_ATT_DB); + struct rscpc_env_tag *rscpc_env = (struct rscpc_env_tag *)ke_malloc( + sizeof(struct rscpc_env_tag), KE_MEM_ATT_DB); - // allocate RSCPC required environment variable - env->env = (prf_env_t*) rscpc_env; + // allocate RSCPC required environment variable + env->env = (prf_env_t *)rscpc_env; - rscpc_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - rscpc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + rscpc_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + rscpc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_RSCPC; - rscpc_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_RSCPC; + rscpc_task_init(&(env->desc)); - for(idx = 0; idx < RSCPC_IDX_MAX ; idx++) - { - rscpc_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), RSCPC_FREE); - } + for (idx = 0; idx < RSCPC_IDX_MAX; idx++) { + rscpc_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), RSCPC_FREE); + } - return GAP_ERR_NO_ERROR; + return GAP_ERR_NO_ERROR; } /** @@ -90,49 +92,46 @@ static uint8_t rscpc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_ * @param[in] reason Detach reason **************************************************************************************** */ -static void rscpc_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct rscpc_env_tag* rscpc_env = (struct rscpc_env_tag*) env->env; +static void rscpc_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct rscpc_env_tag *rscpc_env = (struct rscpc_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(rscpc_env->env[conidx] != NULL) - { - if (rscpc_env->env[conidx]->operation != NULL) - { - ke_free(ke_param2msg(rscpc_env->env[conidx]->operation)); - } - ke_timer_clear(RSCPC_TIMEOUT_TIMER_IND, prf_src_task_get(&rscpc_env->prf_env, conidx)); - ke_free(rscpc_env->env[conidx]); - rscpc_env->env[conidx] = NULL; + // clean-up environment variable allocated for task instance + if (rscpc_env->env[conidx] != NULL) { + if (rscpc_env->env[conidx]->operation != NULL) { + ke_free(ke_param2msg(rscpc_env->env[conidx]->operation)); } + ke_timer_clear(RSCPC_TIMEOUT_TIMER_IND, + prf_src_task_get(&rscpc_env->prf_env, conidx)); + ke_free(rscpc_env->env[conidx]); + rscpc_env->env[conidx] = NULL; + } - /* Put RSCP Client in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), RSCPC_FREE); + /* Put RSCP Client in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), RSCPC_FREE); } /** **************************************************************************************** * @brief Destruction of the RSCPC module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void rscpc_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct rscpc_env_tag* rscpc_env = (struct rscpc_env_tag*) env->env; +static void rscpc_destroy(struct prf_task_env *env) { + uint8_t idx; + struct rscpc_env_tag *rscpc_env = (struct rscpc_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < RSCPC_IDX_MAX ; idx++) - { - rscpc_cleanup(env, idx, 0); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < RSCPC_IDX_MAX; idx++) { + rscpc_cleanup(env, idx, 0); + } - // free profile environment variables - env->env = NULL; - ke_free(rscpc_env); + // free profile environment variables + env->env = NULL; + ke_free(rscpc_env); } /** @@ -143,19 +142,17 @@ static void rscpc_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void rscpc_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Put RSCP Client in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), RSCPC_IDLE); +static void rscpc_create(struct prf_task_env *env, uint8_t conidx) { + /* Put RSCP Client in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), RSCPC_IDLE); } /// RSCPC Task interface required by profile manager -const struct prf_task_cbs rscpc_itf = -{ - rscpc_init, - rscpc_destroy, - rscpc_create, - rscpc_cleanup, +const struct prf_task_cbs rscpc_itf = { + rscpc_init, + rscpc_destroy, + rscpc_create, + rscpc_cleanup, }; /* @@ -163,71 +160,63 @@ const struct prf_task_cbs rscpc_itf = **************************************************************************************** */ -const struct prf_task_cbs* rscpc_prf_itf_get(void) -{ - return &rscpc_itf; +const struct prf_task_cbs *rscpc_prf_itf_get(void) { return &rscpc_itf; } + +void rscpc_enable_rsp_send(struct rscpc_env_tag *rscpc_env, uint8_t conidx, + uint8_t status) { + // Send to APP the details of the discovered attributes on RSCPS + struct rscpc_enable_rsp *rsp = KE_MSG_ALLOC( + RSCPC_ENABLE_RSP, prf_dst_task_get(&(rscpc_env->prf_env), conidx), + prf_src_task_get(&(rscpc_env->prf_env), conidx), rscpc_enable_rsp); + rsp->status = status; + + if (status == GAP_ERR_NO_ERROR) { + rsp->rscs = rscpc_env->env[conidx]->rscs; + // Register RSCPC task in gatt for indication/notifications + prf_register_atthdl2gatt(&(rscpc_env->prf_env), conidx, + &(rscpc_env->env[conidx]->rscs.svc)); + // Go to connected state + ke_state_set(prf_src_task_get(&(rscpc_env->prf_env), conidx), RSCPC_IDLE); + } + + ke_msg_send(rsp); } -void rscpc_enable_rsp_send(struct rscpc_env_tag *rscpc_env, uint8_t conidx, uint8_t status) -{ - // Send to APP the details of the discovered attributes on RSCPS - struct rscpc_enable_rsp * rsp = KE_MSG_ALLOC( - RSCPC_ENABLE_RSP, - prf_dst_task_get(&(rscpc_env->prf_env), conidx), - prf_src_task_get(&(rscpc_env->prf_env), conidx), - rscpc_enable_rsp); - rsp->status = status; +void rscps_send_no_conn_cmp_evt(uint8_t src_id, uint8_t dest_id, + uint8_t operation) { + // Send the message + struct rscpc_cmp_evt *evt = + KE_MSG_ALLOC(RSCPC_CMP_EVT, dest_id, src_id, rscpc_cmp_evt); - if (status == GAP_ERR_NO_ERROR) - { - rsp->rscs = rscpc_env->env[conidx]->rscs; - // Register RSCPC task in gatt for indication/notifications - prf_register_atthdl2gatt(&(rscpc_env->prf_env), conidx, &(rscpc_env->env[conidx]->rscs.svc)); - // Go to connected state - ke_state_set(prf_src_task_get(&(rscpc_env->prf_env), conidx), RSCPC_IDLE); - } + evt->operation = operation; + evt->status = PRF_ERR_REQ_DISALLOWED; - ke_msg_send(rsp); + ke_msg_send(evt); } -void rscps_send_no_conn_cmp_evt(uint8_t src_id, uint8_t dest_id, uint8_t operation) -{ - // Send the message - struct rscpc_cmp_evt *evt = KE_MSG_ALLOC(RSCPC_CMP_EVT, - dest_id, src_id, - rscpc_cmp_evt); +void rscpc_send_cmp_evt(struct rscpc_env_tag *rscpc_env, uint8_t conidx, + uint8_t operation, uint8_t status) { + // Free the stored operation if needed + if (rscpc_env->env[conidx]->operation != NULL) { + ke_msg_free(ke_param2msg(rscpc_env->env[conidx]->operation)); + rscpc_env->env[conidx]->operation = NULL; + } - evt->operation = operation; - evt->status = PRF_ERR_REQ_DISALLOWED; + // Go back to the CONNECTED state if the state is busy + if (ke_state_get(prf_src_task_get(&(rscpc_env->prf_env), conidx)) == + RSCPC_BUSY) { + ke_state_set(prf_src_task_get(&(rscpc_env->prf_env), conidx), RSCPC_IDLE); + } - ke_msg_send(evt); -} + // Send the message + struct rscpc_cmp_evt *evt = KE_MSG_ALLOC( + RSCPC_CMP_EVT, prf_dst_task_get(&(rscpc_env->prf_env), conidx), + prf_src_task_get(&(rscpc_env->prf_env), conidx), rscpc_cmp_evt); -void rscpc_send_cmp_evt(struct rscpc_env_tag *rscpc_env, uint8_t conidx, uint8_t operation, uint8_t status) -{ - // Free the stored operation if needed - if (rscpc_env->env[conidx]->operation != NULL) - { - ke_msg_free(ke_param2msg(rscpc_env->env[conidx]->operation)); - rscpc_env->env[conidx]->operation = NULL; - } + evt->operation = operation; + evt->status = status; - // Go back to the CONNECTED state if the state is busy - if (ke_state_get(prf_src_task_get(&(rscpc_env->prf_env), conidx)) == RSCPC_BUSY) - { - ke_state_set(prf_src_task_get(&(rscpc_env->prf_env), conidx), RSCPC_IDLE); - } - - // Send the message - struct rscpc_cmp_evt *evt = KE_MSG_ALLOC(RSCPC_CMP_EVT, - prf_dst_task_get(&(rscpc_env->prf_env), conidx), - prf_src_task_get(&(rscpc_env->prf_env), conidx), - rscpc_cmp_evt); - - evt->operation = operation; - evt->status = status; - - ke_msg_send(evt); + ke_msg_send(evt); } #endif //(BLE_RSC_COLLECTOR) diff --git a/services/ble_profiles/rscp/rscpc/src/rscpc_task.c b/services/ble_profiles/rscp/rscpc/src/rscpc_task.c index 44734c1..fb26b52 100644 --- a/services/ble_profiles/rscp/rscpc/src/rscpc_task.c +++ b/services/ble_profiles/rscp/rscpc/src/rscpc_task.c @@ -13,56 +13,50 @@ #if (BLE_RSC_COLLECTOR) #include "rscp_common.h" -#include "rscpc_task.h" #include "rscpc.h" +#include "rscpc_task.h" -#include "gap.h" #include "attm.h" -#include "gattc_task.h" -#include "prf_utils.h" #include "compiler.h" +#include "gap.h" +#include "gattc_task.h" #include "ke_timer.h" +#include "prf_utils.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * STRUCTURES **************************************************************************************** */ -/// State machine used to retrieve Running Speed and Cadence service characteristics information -const struct prf_char_def rscpc_rscs_char[RSCP_RSCS_CHAR_MAX] = -{ +/// State machine used to retrieve Running Speed and Cadence service +/// characteristics information +const struct prf_char_def rscpc_rscs_char[RSCP_RSCS_CHAR_MAX] = { /// RSC Measurement - [RSCP_RSCS_RSC_MEAS_CHAR] = {ATT_CHAR_RSC_MEAS, - ATT_MANDATORY, - ATT_CHAR_PROP_NTF}, + [RSCP_RSCS_RSC_MEAS_CHAR] = {ATT_CHAR_RSC_MEAS, ATT_MANDATORY, + ATT_CHAR_PROP_NTF}, /// RSC Feature - [RSCP_RSCS_RSC_FEAT_CHAR] = {ATT_CHAR_RSC_FEAT, - ATT_MANDATORY, - ATT_CHAR_PROP_RD}, + [RSCP_RSCS_RSC_FEAT_CHAR] = {ATT_CHAR_RSC_FEAT, ATT_MANDATORY, + ATT_CHAR_PROP_RD}, /// Sensor Location - [RSCP_RSCS_SENSOR_LOC_CHAR] = {ATT_CHAR_SENSOR_LOC, - ATT_OPTIONAL, - ATT_CHAR_PROP_RD}, + [RSCP_RSCS_SENSOR_LOC_CHAR] = {ATT_CHAR_SENSOR_LOC, ATT_OPTIONAL, + ATT_CHAR_PROP_RD}, /// SC Control Point - [RSCP_RSCS_SC_CTNL_PT_CHAR] = {ATT_CHAR_SC_CNTL_PT, - ATT_OPTIONAL, - ATT_CHAR_PROP_WR | ATT_CHAR_PROP_IND}, + [RSCP_RSCS_SC_CTNL_PT_CHAR] = {ATT_CHAR_SC_CNTL_PT, ATT_OPTIONAL, + ATT_CHAR_PROP_WR | ATT_CHAR_PROP_IND}, }; -/// State machine used to retrieve Running Speed and Cadence service characteristic descriptor information -const struct prf_char_desc_def rscpc_rscs_char_desc[RSCPC_DESC_MAX] = -{ +/// State machine used to retrieve Running Speed and Cadence service +/// characteristic descriptor information +const struct prf_char_desc_def rscpc_rscs_char_desc[RSCPC_DESC_MAX] = { /// RSC Measurement Char. - Client Characteristic Configuration - [RSCPC_DESC_RSC_MEAS_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, - ATT_MANDATORY, - RSCP_RSCS_RSC_MEAS_CHAR}, + [RSCPC_DESC_RSC_MEAS_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, + RSCP_RSCS_RSC_MEAS_CHAR}, /// SC Control Point Char. - Client Characteristic Configuration - [RSCPC_DESC_SC_CTNL_PT_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, - ATT_OPTIONAL, - RSCP_RSCS_SC_CTNL_PT_CHAR}, + [RSCPC_DESC_SC_CTNL_PT_CL_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_OPTIONAL, + RSCP_RSCS_SC_CTNL_PT_CHAR}, }; /* @@ -82,38 +76,36 @@ const struct prf_char_desc_def rscpc_rscs_char_desc[RSCPC_DESC_MAX] = **************************************************************************************** */ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, - struct gattc_sdp_svc_ind const *ind, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_sdp_svc_ind const *ind, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == RSCPC_DISCOVERING) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == RSCPC_DISCOVERING) { + uint8_t conidx = KE_IDX_GET(dest_id); - struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); + struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); - ASSERT_INFO(rscpc_env != NULL, dest_id, src_id); - ASSERT_INFO(rscpc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(rscpc_env != NULL, dest_id, src_id); + ASSERT_INFO(rscpc_env->env[conidx] != NULL, dest_id, src_id); - if(rscpc_env->env[conidx]->nb_svc == 0) - { - // Retrieve RSCS characteristics and descriptors - prf_extract_svc_info(ind, RSCP_RSCS_CHAR_MAX, &rscpc_rscs_char[0], &rscpc_env->env[conidx]->rscs.chars[0], - RSCPC_DESC_MAX, &rscpc_rscs_char_desc[0], &rscpc_env->env[conidx]->rscs.descs[0]); + if (rscpc_env->env[conidx]->nb_svc == 0) { + // Retrieve RSCS characteristics and descriptors + prf_extract_svc_info(ind, RSCP_RSCS_CHAR_MAX, &rscpc_rscs_char[0], + &rscpc_env->env[conidx]->rscs.chars[0], + RSCPC_DESC_MAX, &rscpc_rscs_char_desc[0], + &rscpc_env->env[conidx]->rscs.descs[0]); - //Even if we get multiple responses we only store 1 range - rscpc_env->env[conidx]->rscs.svc.shdl = ind->start_hdl; - rscpc_env->env[conidx]->rscs.svc.ehdl = ind->end_hdl; - } - - rscpc_env->env[conidx]->nb_svc++; + // Even if we get multiple responses we only store 1 range + rscpc_env->env[conidx]->rscs.svc.shdl = ind->start_hdl; + rscpc_env->env[conidx]->rscs.svc.ehdl = ind->end_hdl; } - return (KE_MSG_CONSUMED); -} + rscpc_env->env[conidx]->nb_svc++; + } + return (KE_MSG_CONSUMED); +} /** **************************************************************************************** @@ -126,56 +118,52 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int rscpc_enable_req_handler(ke_msg_id_t const msgid, - struct rscpc_enable_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + struct rscpc_enable_req *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); - // Running Speed and Cadence Profile Collector Role Task Environment - struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); + uint8_t state = ke_state_get(dest_id); + // Running Speed and Cadence Profile Collector Role Task Environment + struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); - ASSERT_INFO(rscpc_env != NULL, dest_id, src_id); - if ((state == RSCPC_IDLE) && (rscpc_env->env[conidx] == NULL)) - { - // allocate environment variable for task instance - rscpc_env->env[conidx] = (struct rscpc_cnx_env*) ke_malloc(sizeof(struct rscpc_cnx_env), KE_MEM_ATT_DB); - memset(rscpc_env->env[conidx], 0, sizeof(struct rscpc_cnx_env)); + ASSERT_INFO(rscpc_env != NULL, dest_id, src_id); + if ((state == RSCPC_IDLE) && (rscpc_env->env[conidx] == NULL)) { + // allocate environment variable for task instance + rscpc_env->env[conidx] = (struct rscpc_cnx_env *)ke_malloc( + sizeof(struct rscpc_cnx_env), KE_MEM_ATT_DB); + memset(rscpc_env->env[conidx], 0, sizeof(struct rscpc_cnx_env)); - // Start discovering - if (param->con_type == PRF_CON_DISCOVERY) - { - prf_disc_svc_send(&(rscpc_env->prf_env), conidx, ATT_SVC_RUNNING_SPEED_CADENCE); + // Start discovering + if (param->con_type == PRF_CON_DISCOVERY) { + prf_disc_svc_send(&(rscpc_env->prf_env), conidx, + ATT_SVC_RUNNING_SPEED_CADENCE); - // Go to DISCOVERING state - ke_state_set(dest_id, RSCPC_DISCOVERING); - } - // Bond information is provided - else - { - rscpc_env->env[conidx]->rscs = param->rscs; - - //send APP confirmation that can start normal connection to TH - rscpc_enable_rsp_send(rscpc_env, conidx, GAP_ERR_NO_ERROR); - } - } - else if (state != RSCPC_FREE) - { - // The message will be forwarded towards the good task instance - status = PRF_ERR_REQ_DISALLOWED; + // Go to DISCOVERING state + ke_state_set(dest_id, RSCPC_DISCOVERING); } + // Bond information is provided + else { + rscpc_env->env[conidx]->rscs = param->rscs; - if(status != GAP_ERR_NO_ERROR) - { - // The request is disallowed (profile already enabled for this connection, or not enough memory, ...) - rscpc_enable_rsp_send(rscpc_env, conidx, status); + // send APP confirmation that can start normal connection to TH + rscpc_enable_rsp_send(rscpc_env, conidx, GAP_ERR_NO_ERROR); } + } else if (state != RSCPC_FREE) { + // The message will be forwarded towards the good task instance + status = PRF_ERR_REQ_DISALLOWED; + } - return (KE_MSG_CONSUMED); + if (status != GAP_ERR_NO_ERROR) { + // The request is disallowed (profile already enabled for this connection, + // or not enough memory, ...) + rscpc_enable_rsp_send(rscpc_env, conidx, status); + } + + return (KE_MSG_CONSUMED); } /** @@ -189,111 +177,99 @@ __STATIC int rscpc_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int rscpc_read_cmd_handler(ke_msg_id_t const msgid, - struct rscpc_read_cmd *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - uint8_t status = PRF_ERR_REQ_DISALLOWED; - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; - // Get the address of the environment - struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + struct rscpc_read_cmd *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + uint8_t status = PRF_ERR_REQ_DISALLOWED; + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; + // Get the address of the environment + struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - if (state == RSCPC_IDLE) + if (state == RSCPC_IDLE) { + // State is Connected or Busy + ASSERT_INFO(rscpc_env != NULL, dest_id, src_id); + + // Check the current state + if (rscpc_env->env[conidx] == NULL) { + status = PRF_APP_ERROR; + } else // State is RSCPC_CONNECTED { - // State is Connected or Busy - ASSERT_INFO(rscpc_env != NULL, dest_id, src_id); + // Attribute Handle + uint16_t handle = ATT_INVALID_SEARCH_HANDLE; - // Check the current state - if (rscpc_env->env[conidx] == NULL) - { - status = PRF_APP_ERROR; - } - else // State is RSCPC_CONNECTED - { - // Attribute Handle - uint16_t handle = ATT_INVALID_SEARCH_HANDLE; + switch (param->read_code) { + // Read RSC Feature + case (RSCPC_RD_RSC_FEAT): { + handle = + rscpc_env->env[conidx]->rscs.chars[RSCP_RSCS_RSC_FEAT_CHAR].val_hdl; + } break; - switch (param->read_code) - { - // Read RSC Feature - case (RSCPC_RD_RSC_FEAT): - { - handle = rscpc_env->env[conidx]->rscs.chars[RSCP_RSCS_RSC_FEAT_CHAR].val_hdl; - } break; + // Read Sensor Location + case (RSCPC_RD_SENSOR_LOC): { + handle = rscpc_env->env[conidx] + ->rscs.chars[RSCP_RSCS_SENSOR_LOC_CHAR] + .val_hdl; + } break; - // Read Sensor Location - case (RSCPC_RD_SENSOR_LOC): - { - handle = rscpc_env->env[conidx]->rscs.chars[RSCP_RSCS_SENSOR_LOC_CHAR].val_hdl; - } break; + // Read RSC Measurement Characteristic Client Char. Cfg. Descriptor Value + case (RSCPC_RD_WR_RSC_MEAS_CFG): { + handle = rscpc_env->env[conidx] + ->rscs.descs[RSCPC_DESC_RSC_MEAS_CL_CFG] + .desc_hdl; + } break; - // Read RSC Measurement Characteristic Client Char. Cfg. Descriptor Value - case (RSCPC_RD_WR_RSC_MEAS_CFG): - { - handle = rscpc_env->env[conidx]->rscs.descs[RSCPC_DESC_RSC_MEAS_CL_CFG].desc_hdl; - } break; + // Read Unread Alert Characteristic Client Char. Cfg. Descriptor Value + case (RSCPC_RD_WR_SC_CTNL_PT_CFG): { + handle = rscpc_env->env[conidx] + ->rscs.descs[RSCPC_DESC_SC_CTNL_PT_CL_CFG] + .desc_hdl; + } break; - // Read Unread Alert Characteristic Client Char. Cfg. Descriptor Value - case (RSCPC_RD_WR_SC_CTNL_PT_CFG): - { - handle = rscpc_env->env[conidx]->rscs.descs[RSCPC_DESC_SC_CTNL_PT_CL_CFG].desc_hdl; - } break; + default: { + status = PRF_ERR_INVALID_PARAM; + } break; + } - default: - { - status = PRF_ERR_INVALID_PARAM; - } break; - } + // Check if handle is viable + if (handle != ATT_INVALID_SEARCH_HANDLE) { + // Force the operation value + param->operation = RSCPC_READ_OP_CODE; - // Check if handle is viable - if (handle != ATT_INVALID_SEARCH_HANDLE) - { - // Force the operation value - param->operation = RSCPC_READ_OP_CODE; + // Store the command structure + rscpc_env->env[conidx]->operation = (void *)param; + msg_status = KE_MSG_NO_FREE; - // Store the command structure - rscpc_env->env[conidx]->operation = (void *)param; - msg_status = KE_MSG_NO_FREE; + // Send the read request + prf_read_char_send(&(rscpc_env->prf_env), conidx, + rscpc_env->env[conidx]->rscs.svc.shdl, + rscpc_env->env[conidx]->rscs.svc.ehdl, handle); - // Send the read request - prf_read_char_send(&(rscpc_env->prf_env), conidx, - rscpc_env->env[conidx]->rscs.svc.shdl, - rscpc_env->env[conidx]->rscs.svc.ehdl, - handle); + // Go to the Busy state + ke_state_set(dest_id, RSCPC_BUSY); - // Go to the Busy state - ke_state_set(dest_id, RSCPC_BUSY); - - status = ATT_ERR_NO_ERROR; - } - else - { - status = PRF_ERR_INEXISTENT_HDL; - } - } - } - else if (state == RSCPC_FREE) - { - status = GAP_ERR_DISCONNECTED; - } - else - { - // Another procedure is pending, keep the command for later - msg_status = KE_MSG_SAVED; - status = GAP_ERR_NO_ERROR; + status = ATT_ERR_NO_ERROR; + } else { + status = PRF_ERR_INEXISTENT_HDL; + } } + } else if (state == RSCPC_FREE) { + status = GAP_ERR_DISCONNECTED; + } else { + // Another procedure is pending, keep the command for later + msg_status = KE_MSG_SAVED; + status = GAP_ERR_NO_ERROR; + } - if (status != GAP_ERR_NO_ERROR) - { - // Send the complete event message to the task id stored in the environment - rscpc_send_cmp_evt(rscpc_env, conidx, RSCPC_READ_OP_CODE, status); - } + if (status != GAP_ERR_NO_ERROR) { + // Send the complete event message to the task id stored in the environment + rscpc_send_cmp_evt(rscpc_env, conidx, RSCPC_READ_OP_CODE, status); + } - return (int)msg_status; + return (int)msg_status; } /** @@ -307,107 +283,95 @@ __STATIC int rscpc_read_cmd_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int rscpc_cfg_ntfind_cmd_handler(ke_msg_id_t const msgid, - struct rscpc_cfg_ntfind_cmd *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; + struct rscpc_cfg_ntfind_cmd *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; - if (rscpc_env != NULL) - { - // Status - uint8_t status = PRF_ERR_REQ_DISALLOWED; - // Handle - uint16_t handle = ATT_INVALID_SEARCH_HANDLE; - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + if (rscpc_env != NULL) { + // Status + uint8_t status = PRF_ERR_REQ_DISALLOWED; + // Handle + uint16_t handle = ATT_INVALID_SEARCH_HANDLE; + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - do - { - if (ke_state_get(dest_id) != RSCPC_IDLE) - { - // Another procedure is pending, keep the command for later - msg_status = KE_MSG_SAVED; - // Status is GAP_ERR_NO_ERROR, no message will be sent to the application - break; - } + do { + if (ke_state_get(dest_id) != RSCPC_IDLE) { + // Another procedure is pending, keep the command for later + msg_status = KE_MSG_SAVED; + // Status is GAP_ERR_NO_ERROR, no message will be sent to the + // application + break; + } - ASSERT_ERR(rscpc_env->env[conidx] != NULL); + ASSERT_ERR(rscpc_env->env[conidx] != NULL); - switch(param->desc_code) - { - // Write RSC Measurement Characteristic Client Char. Cfg. Descriptor Value - case (RSCPC_RD_WR_RSC_MEAS_CFG): - { - if (param->ntfind_cfg <= PRF_CLI_START_NTF) - { - handle = rscpc_env->env[conidx]->rscs.descs[RSCPC_DESC_RSC_MEAS_CL_CFG].desc_hdl; + switch (param->desc_code) { + // Write RSC Measurement Characteristic Client Char. Cfg. Descriptor Value + case (RSCPC_RD_WR_RSC_MEAS_CFG): { + if (param->ntfind_cfg <= PRF_CLI_START_NTF) { + handle = rscpc_env->env[conidx] + ->rscs.descs[RSCPC_DESC_RSC_MEAS_CL_CFG] + .desc_hdl; - status = GAP_ERR_NO_ERROR; - // The characteristic is mandatory and the descriptor is mandatory - ASSERT_ERR(handle != ATT_INVALID_SEARCH_HANDLE); - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } break; - - // Write SC Control Point Characteristic Client Char. Cfg. Descriptor Value - case (RSCPC_RD_WR_SC_CTNL_PT_CFG): - { - if ((param->ntfind_cfg == PRF_CLI_STOP_NTFIND) || - (param->ntfind_cfg == PRF_CLI_START_IND)) - { - handle = rscpc_env->env[conidx]->rscs.descs[RSCPC_DESC_SC_CTNL_PT_CL_CFG].desc_hdl; - - status = GAP_ERR_NO_ERROR; - if (handle == ATT_INVALID_SEARCH_HANDLE) - { - // The descriptor has not been found. - status = PRF_ERR_INEXISTENT_HDL; - } - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } break; - - default: - { - status = PRF_ERR_INVALID_PARAM; - } break; - } - } while (0); - - - if ((status == GAP_ERR_NO_ERROR) && (handle != ATT_INVALID_SEARCH_HANDLE)) - { - // Set the operation code - param->operation = RSCPC_CFG_NTF_IND_OP_CODE; - - // Store the command structure - rscpc_env->env[conidx]->operation = param; - msg_status = KE_MSG_NO_FREE; - - // Go to the Busy state - ke_state_set(dest_id, RSCPC_BUSY); - - // Send GATT Write Request - prf_gatt_write_ntf_ind(&rscpc_env->prf_env, conidx, handle, param->ntfind_cfg); + status = GAP_ERR_NO_ERROR; + // The characteristic is mandatory and the descriptor is mandatory + ASSERT_ERR(handle != ATT_INVALID_SEARCH_HANDLE); + } else { + status = PRF_ERR_INVALID_PARAM; } - } - else - { - // No connection - rscps_send_no_conn_cmp_evt(dest_id, src_id, RSCPC_CFG_NTF_IND_OP_CODE); - } + } break; - return (int)msg_status; + // Write SC Control Point Characteristic Client Char. Cfg. Descriptor + // Value + case (RSCPC_RD_WR_SC_CTNL_PT_CFG): { + if ((param->ntfind_cfg == PRF_CLI_STOP_NTFIND) || + (param->ntfind_cfg == PRF_CLI_START_IND)) { + handle = rscpc_env->env[conidx] + ->rscs.descs[RSCPC_DESC_SC_CTNL_PT_CL_CFG] + .desc_hdl; + + status = GAP_ERR_NO_ERROR; + if (handle == ATT_INVALID_SEARCH_HANDLE) { + // The descriptor has not been found. + status = PRF_ERR_INEXISTENT_HDL; + } + } else { + status = PRF_ERR_INVALID_PARAM; + } + } break; + + default: { + status = PRF_ERR_INVALID_PARAM; + } break; + } + } while (0); + + if ((status == GAP_ERR_NO_ERROR) && (handle != ATT_INVALID_SEARCH_HANDLE)) { + // Set the operation code + param->operation = RSCPC_CFG_NTF_IND_OP_CODE; + + // Store the command structure + rscpc_env->env[conidx]->operation = param; + msg_status = KE_MSG_NO_FREE; + + // Go to the Busy state + ke_state_set(dest_id, RSCPC_BUSY); + + // Send GATT Write Request + prf_gatt_write_ntf_ind(&rscpc_env->prf_env, conidx, handle, + param->ntfind_cfg); + } + } else { + // No connection + rscps_send_no_conn_cmp_evt(dest_id, src_id, RSCPC_CFG_NTF_IND_OP_CODE); + } + + return (int)msg_status; } /** @@ -421,134 +385,124 @@ __STATIC int rscpc_cfg_ntfind_cmd_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int rscpc_ctnl_pt_cfg_req_handler(ke_msg_id_t const msgid, - struct rscpc_ctnl_pt_cfg_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; - // Get the address of the environment - struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + struct rscpc_ctnl_pt_cfg_req *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; + // Get the address of the environment + struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - if (rscpc_env != NULL) - { - // Status - uint8_t status = GAP_ERR_NO_ERROR; + if (rscpc_env != NULL) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; - do - { - // State is Connected or Busy - ASSERT_ERR(ke_state_get(dest_id) > RSCPC_FREE); + do { + // State is Connected or Busy + ASSERT_ERR(ke_state_get(dest_id) > RSCPC_FREE); - // Check the provided connection handle - if (rscpc_env->env[conidx] == NULL) - { - status = PRF_ERR_INVALID_PARAM; - break; - } + // Check the provided connection handle + if (rscpc_env->env[conidx] == NULL) { + status = PRF_ERR_INVALID_PARAM; + break; + } - if (ke_state_get(dest_id) != RSCPC_IDLE) - { - // Another procedure is pending, keep the command for later - msg_status = KE_MSG_SAVED; - // Status is GAP_ERR_NO_ERROR, no message will be sent to the application - break; - } + if (ke_state_get(dest_id) != RSCPC_IDLE) { + // Another procedure is pending, keep the command for later + msg_status = KE_MSG_SAVED; + // Status is GAP_ERR_NO_ERROR, no message will be sent to the + // application + break; + } - // Check if the characteristic has been found - if (rscpc_env->env[conidx]->rscs.descs[RSCPC_DESC_SC_CTNL_PT_CL_CFG].desc_hdl != ATT_INVALID_SEARCH_HANDLE) - { - // Packed request - uint8_t req[RSCP_SC_CNTL_PT_REQ_MAX_LEN]; - // Request Length - uint8_t req_len = RSCP_SC_CNTL_PT_REQ_MIN_LEN; + // Check if the characteristic has been found + if (rscpc_env->env[conidx] + ->rscs.descs[RSCPC_DESC_SC_CTNL_PT_CL_CFG] + .desc_hdl != ATT_INVALID_SEARCH_HANDLE) { + // Packed request + uint8_t req[RSCP_SC_CNTL_PT_REQ_MAX_LEN]; + // Request Length + uint8_t req_len = RSCP_SC_CNTL_PT_REQ_MIN_LEN; - // Set the operation code - req[0] = param->sc_ctnl_pt.op_code; + // Set the operation code + req[0] = param->sc_ctnl_pt.op_code; - // Fulfill the message according to the operation code - switch (param->sc_ctnl_pt.op_code) - { - case (RSCP_CTNL_PT_OP_RESERVED): - { - // Do nothing, used to generate an "Operation Code not supported" error. - } break; + // Fulfill the message according to the operation code + switch (param->sc_ctnl_pt.op_code) { + case (RSCP_CTNL_PT_OP_RESERVED): { + // Do nothing, used to generate an "Operation Code not supported" + // error. + } break; - case (RSCP_CTNL_PT_OP_SET_CUMUL_VAL): - { - // Set the cumulative value - co_write32p(&req[req_len], param->sc_ctnl_pt.value.cumul_val); - // Update length - req_len += 4; - } break; + case (RSCP_CTNL_PT_OP_SET_CUMUL_VAL): { + // Set the cumulative value + co_write32p(&req[req_len], param->sc_ctnl_pt.value.cumul_val); + // Update length + req_len += 4; + } break; - case (RSCP_CTNL_PT_OP_UPD_LOC): - { - // Set the sensor location - req[req_len] = param->sc_ctnl_pt.value.sensor_loc; - // Update length - req_len++; - } break; + case (RSCP_CTNL_PT_OP_UPD_LOC): { + // Set the sensor location + req[req_len] = param->sc_ctnl_pt.value.sensor_loc; + // Update length + req_len++; + } break; - case (RSCP_CTNL_PT_OP_START_CALIB): - case (RSCP_CTNL_PT_OP_REQ_SUPP_LOC): - { - // Nothing more to do - } break; + case (RSCP_CTNL_PT_OP_START_CALIB): + case (RSCP_CTNL_PT_OP_REQ_SUPP_LOC): { + // Nothing more to do + } break; - default: - { - status = PRF_ERR_INVALID_PARAM; - } break; - } - - if (status == GAP_ERR_NO_ERROR) - { - // Set the operation code - param->operation = RSCPC_CTNL_PT_CFG_WR_OP_CODE; - - // Store the command structure - rscpc_env->env[conidx]->operation = param; - // Store the command information - msg_status = KE_MSG_NO_FREE; - - // Go to the Busy state - ke_state_set(dest_id, RSCPC_BUSY); - - // Send the write request - prf_gatt_write(&(rscpc_env->prf_env), conidx, rscpc_env->env[conidx]->rscs.chars[RSCP_RSCS_SC_CTNL_PT_CHAR].val_hdl, - (uint8_t *)&req[0], req_len, GATTC_WRITE); - } - } - else - { - // The SC Control Point Characteristic has not been found - status = PRF_ERR_INEXISTENT_HDL; - } - } while (0); - - if (status != GAP_ERR_NO_ERROR) - { - // Send a complete event status to the application - rscpc_send_cmp_evt(rscpc_env, conidx, RSCPC_CTNL_PT_CFG_WR_OP_CODE, status); + default: { + status = PRF_ERR_INVALID_PARAM; + } break; } - } - else - { - // No connection - rscps_send_no_conn_cmp_evt(dest_id, src_id, RSCPC_CTNL_PT_CFG_WR_OP_CODE); - } - return (int)msg_status; + if (status == GAP_ERR_NO_ERROR) { + // Set the operation code + param->operation = RSCPC_CTNL_PT_CFG_WR_OP_CODE; + + // Store the command structure + rscpc_env->env[conidx]->operation = param; + // Store the command information + msg_status = KE_MSG_NO_FREE; + + // Go to the Busy state + ke_state_set(dest_id, RSCPC_BUSY); + + // Send the write request + prf_gatt_write(&(rscpc_env->prf_env), conidx, + rscpc_env->env[conidx] + ->rscs.chars[RSCP_RSCS_SC_CTNL_PT_CHAR] + .val_hdl, + (uint8_t *)&req[0], req_len, GATTC_WRITE); + } + } else { + // The SC Control Point Characteristic has not been found + status = PRF_ERR_INEXISTENT_HDL; + } + } while (0); + + if (status != GAP_ERR_NO_ERROR) { + // Send a complete event status to the application + rscpc_send_cmp_evt(rscpc_env, conidx, RSCPC_CTNL_PT_CFG_WR_OP_CODE, + status); + } + } else { + // No connection + rscps_send_no_conn_cmp_evt(dest_id, src_id, RSCPC_CTNL_PT_CFG_WR_OP_CODE); + } + + return (int)msg_status; } /** **************************************************************************************** - * @brief Handles reception of the @ref RSCPC_TIMEOUT_TIMER_IND message. This message is - * received when the peer device doesn't send a SC Control Point indication within 30s - * after reception of the write response. + * @brief Handles reception of the @ref RSCPC_TIMEOUT_TIMER_IND message. This + *message is received when the peer device doesn't send a SC Control Point + *indication within 30s after reception of the write response. * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance. @@ -557,26 +511,27 @@ __STATIC int rscpc_ctnl_pt_cfg_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int rscpc_timeout_timer_ind_handler(ke_msg_id_t const msgid, - void const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + void const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - if ((rscpc_env != NULL) && (rscpc_env->env[conidx] != NULL)) - { - ASSERT_ERR(rscpc_env->env[conidx]->operation != NULL); - ASSERT_ERR(((struct rscpc_cmd *)rscpc_env->env[conidx]->operation)->operation == RSCPC_CTNL_PT_CFG_IND_OP_CODE); + if ((rscpc_env != NULL) && (rscpc_env->env[conidx] != NULL)) { + ASSERT_ERR(rscpc_env->env[conidx]->operation != NULL); + ASSERT_ERR( + ((struct rscpc_cmd *)rscpc_env->env[conidx]->operation)->operation == + RSCPC_CTNL_PT_CFG_IND_OP_CODE); - // Send the complete event message - rscpc_send_cmp_evt(rscpc_env, conidx, RSCPC_CTNL_PT_CFG_WR_OP_CODE, PRF_ERR_PROC_TIMEOUT); - } - // else drop the message + // Send the complete event message + rscpc_send_cmp_evt(rscpc_env, conidx, RSCPC_CTNL_PT_CFG_WR_OP_CODE, + PRF_ERR_PROC_TIMEOUT); + } + // else drop the message - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -590,114 +545,97 @@ __STATIC int rscpc_timeout_timer_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, - struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); - // Status - uint8_t status; + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); + // Status + uint8_t status; - if (rscpc_env != NULL) - { - uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t state = ke_state_get(dest_id); + if (rscpc_env != NULL) { + uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t state = ke_state_get(dest_id); - if (state == RSCPC_DISCOVERING) - { - status = param->status; + if (state == RSCPC_DISCOVERING) { + status = param->status; - if ((status == ATT_ERR_ATTRIBUTE_NOT_FOUND) || - (status == ATT_ERR_NO_ERROR)) - { - // Discovery - // check characteristic validity - if(rscpc_env->env[conidx]->nb_svc == 1) - { - status = prf_check_svc_char_validity(RSCP_RSCS_CHAR_MAX, - rscpc_env->env[conidx]->rscs.chars, - rscpc_rscs_char); - } - // too much services - else if (rscpc_env->env[conidx]->nb_svc > 1) - { - status = PRF_ERR_MULTIPLE_SVC; - } - // no services found - else - { - status = PRF_ERR_STOP_DISC_CHAR_MISSING; - } - - // check descriptor validity - if (status == GAP_ERR_NO_ERROR) - { - status = prf_check_svc_char_desc_validity(RSCPC_DESC_MAX, - rscpc_env->env[conidx]->rscs.descs, - rscpc_rscs_char_desc, - rscpc_env->env[conidx]->rscs.chars); - } - } - - rscpc_enable_rsp_send(rscpc_env, conidx, status); + if ((status == ATT_ERR_ATTRIBUTE_NOT_FOUND) || + (status == ATT_ERR_NO_ERROR)) { + // Discovery + // check characteristic validity + if (rscpc_env->env[conidx]->nb_svc == 1) { + status = prf_check_svc_char_validity( + RSCP_RSCS_CHAR_MAX, rscpc_env->env[conidx]->rscs.chars, + rscpc_rscs_char); + } + // too much services + else if (rscpc_env->env[conidx]->nb_svc > 1) { + status = PRF_ERR_MULTIPLE_SVC; + } + // no services found + else { + status = PRF_ERR_STOP_DISC_CHAR_MISSING; } - else if (state == RSCPC_BUSY) - { - switch (param->operation) - { - case GATTC_READ: - { - // Send the complete event status - rscpc_send_cmp_evt(rscpc_env, conidx, RSCPC_READ_OP_CODE, param->status); - } break; - - case GATTC_WRITE: - case GATTC_WRITE_NO_RESPONSE: - { - uint8_t operation = ((struct rscpc_cmd *)rscpc_env->env[conidx]->operation)->operation; - - if (operation == RSCPC_CFG_NTF_IND_OP_CODE) - { - // Send the complete event status - rscpc_send_cmp_evt(rscpc_env, conidx, operation, param->status); - } - - else if (operation == RSCPC_CTNL_PT_CFG_WR_OP_CODE) - { - if (param->status == GAP_ERR_NO_ERROR) - { - // Start Timeout Procedure - ke_timer_set(RSCPC_TIMEOUT_TIMER_IND, dest_id, ATT_TRANS_RTX); - - // Wait for the response indication - ((struct rscpc_cmd *)rscpc_env->env[conidx]->operation)->operation = RSCPC_CTNL_PT_CFG_IND_OP_CODE; - } - else - { - // Send the complete event status - rscpc_send_cmp_evt(rscpc_env, conidx, operation, param->status); - } - } - } break; - - case GATTC_REGISTER: - case GATTC_UNREGISTER: - { - // Do nothing - } break; - - default: - { - ASSERT_ERR(0); - } break; - } + // check descriptor validity + if (status == GAP_ERR_NO_ERROR) { + status = prf_check_svc_char_desc_validity( + RSCPC_DESC_MAX, rscpc_env->env[conidx]->rscs.descs, + rscpc_rscs_char_desc, rscpc_env->env[conidx]->rscs.chars); } + } + + rscpc_enable_rsp_send(rscpc_env, conidx, status); } - // else ignore the message - return (KE_MSG_CONSUMED); + else if (state == RSCPC_BUSY) { + switch (param->operation) { + case GATTC_READ: { + // Send the complete event status + rscpc_send_cmp_evt(rscpc_env, conidx, RSCPC_READ_OP_CODE, + param->status); + } break; + + case GATTC_WRITE: + case GATTC_WRITE_NO_RESPONSE: { + uint8_t operation = + ((struct rscpc_cmd *)rscpc_env->env[conidx]->operation)->operation; + + if (operation == RSCPC_CFG_NTF_IND_OP_CODE) { + // Send the complete event status + rscpc_send_cmp_evt(rscpc_env, conidx, operation, param->status); + } + + else if (operation == RSCPC_CTNL_PT_CFG_WR_OP_CODE) { + if (param->status == GAP_ERR_NO_ERROR) { + // Start Timeout Procedure + ke_timer_set(RSCPC_TIMEOUT_TIMER_IND, dest_id, ATT_TRANS_RTX); + + // Wait for the response indication + ((struct rscpc_cmd *)rscpc_env->env[conidx]->operation)->operation = + RSCPC_CTNL_PT_CFG_IND_OP_CODE; + } else { + // Send the complete event status + rscpc_send_cmp_evt(rscpc_env, conidx, operation, param->status); + } + } + } break; + + case GATTC_REGISTER: + case GATTC_UNREGISTER: { + // Do nothing + } break; + + default: { + ASSERT_ERR(0); + } break; + } + } + } + // else ignore the message + + return (KE_MSG_CONSUMED); } /** @@ -714,62 +652,56 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, struct gattc_read_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); + ke_task_id_t const src_id) { + // Get the address of the environment + struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); - if (ke_state_get(dest_id) == RSCPC_BUSY) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (ke_state_get(dest_id) == RSCPC_BUSY) { + uint8_t conidx = KE_IDX_GET(dest_id); - ASSERT_INFO(rscpc_env != NULL, dest_id, src_id); - ASSERT_INFO(rscpc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(rscpc_env != NULL, dest_id, src_id); + ASSERT_INFO(rscpc_env->env[conidx] != NULL, dest_id, src_id); - // Send the read value to the HL - struct rscpc_value_ind *ind = KE_MSG_ALLOC(RSCPC_VALUE_IND, - prf_dst_task_get(&(rscpc_env->prf_env), conidx), - dest_id, - rscpc_value_ind); + // Send the read value to the HL + struct rscpc_value_ind *ind = KE_MSG_ALLOC( + RSCPC_VALUE_IND, prf_dst_task_get(&(rscpc_env->prf_env), conidx), + dest_id, rscpc_value_ind); - switch (((struct rscpc_read_cmd *)rscpc_env->env[conidx]->operation)->read_code) - { - // Read RSC Feature Characteristic value - case (RSCPC_RD_RSC_FEAT): - { - ind->value.sensor_feat = co_read16p(param->value); + switch (((struct rscpc_read_cmd *)rscpc_env->env[conidx]->operation) + ->read_code) { + // Read RSC Feature Characteristic value + case (RSCPC_RD_RSC_FEAT): { + ind->value.sensor_feat = co_read16p(param->value); - // Mask the unused bits -// ind->value.sensor_feat &= RSCP_FEAT_ALL_SUPP; - } break; + // Mask the unused bits + // ind->value.sensor_feat &= RSCP_FEAT_ALL_SUPP; + } break; - // Read Sensor Location Characteristic value - case (RSCPC_RD_SENSOR_LOC): - { - ind->value.sensor_loc = param->value[0]; - } break; + // Read Sensor Location Characteristic value + case (RSCPC_RD_SENSOR_LOC): { + ind->value.sensor_loc = param->value[0]; + } break; - // Read Client Characteristic Configuration Descriptor value - case (RSCPC_RD_WR_RSC_MEAS_CFG): - case (RSCPC_RD_WR_SC_CTNL_PT_CFG): - { - co_write16p(&ind->value.ntf_cfg, param->value[0]); - } break; + // Read Client Characteristic Configuration Descriptor value + case (RSCPC_RD_WR_RSC_MEAS_CFG): + case (RSCPC_RD_WR_SC_CTNL_PT_CFG): { + co_write16p(&ind->value.ntf_cfg, param->value[0]); + } break; - default: - { - ASSERT_ERR(0); - } break; - } - - ind->att_code = ((struct rscpc_read_cmd *)rscpc_env->env[conidx]->operation)->read_code; - - // Send the message to the application - ke_msg_send(ind); + default: { + ASSERT_ERR(0); + } break; } - // else drop the message - return (KE_MSG_CONSUMED); + ind->att_code = + ((struct rscpc_read_cmd *)rscpc_env->env[conidx]->operation)->read_code; + + // Send the message to the application + ke_msg_send(ind); + } + // else drop the message + + return (KE_MSG_CONSUMED); } /** @@ -783,128 +715,118 @@ __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, - struct gattc_event_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t conidx = KE_IDX_GET(dest_id); - // Get the address of the environment - struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); + struct gattc_event_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); - if (rscpc_env != NULL) - { - switch (param->type) - { - case (GATTC_NOTIFY): - { - // Offset - uint8_t offset = RSCP_RSC_MEAS_MIN_LEN; + if (rscpc_env != NULL) { + switch (param->type) { + case (GATTC_NOTIFY): { + // Offset + uint8_t offset = RSCP_RSC_MEAS_MIN_LEN; - // RSC Measurement value has been received - struct rscpc_value_ind *ind = KE_MSG_ALLOC(RSCPC_VALUE_IND, - prf_dst_task_get(&(rscpc_env->prf_env), conidx), - prf_src_task_get(&(rscpc_env->prf_env), conidx), - rscpc_value_ind); + // RSC Measurement value has been received + struct rscpc_value_ind *ind = KE_MSG_ALLOC( + RSCPC_VALUE_IND, prf_dst_task_get(&(rscpc_env->prf_env), conidx), + prf_src_task_get(&(rscpc_env->prf_env), conidx), rscpc_value_ind); - // Attribute code - ind->att_code = RSCPC_NTF_RSC_MEAS; + // Attribute code + ind->att_code = RSCPC_NTF_RSC_MEAS; - /*---------------------------------------------------- - * Unpack Measurement -------------------------------- - *----------------------------------------------------*/ + /*---------------------------------------------------- + * Unpack Measurement -------------------------------- + *----------------------------------------------------*/ - // Flags - ind->value.rsc_meas.flags = param->value[0]; - // Instantaneous Speed - ind->value.rsc_meas.inst_speed = co_read16p((uint16_t *)¶m->value[1]); - // Instantaneous Cadence - ind->value.rsc_meas.inst_cad = param->value[3]; + // Flags + ind->value.rsc_meas.flags = param->value[0]; + // Instantaneous Speed + ind->value.rsc_meas.inst_speed = co_read16p((uint16_t *)¶m->value[1]); + // Instantaneous Cadence + ind->value.rsc_meas.inst_cad = param->value[3]; - // Instantaneous Stride Length - if (param->value[0] & RSCP_MEAS_INST_STRIDE_LEN_PRESENT) - { - ind->value.rsc_meas.inst_stride_len = co_read16p(¶m->value[offset]); - offset += 2; - } + // Instantaneous Stride Length + if (param->value[0] & RSCP_MEAS_INST_STRIDE_LEN_PRESENT) { + ind->value.rsc_meas.inst_stride_len = co_read16p(¶m->value[offset]); + offset += 2; + } - // Total Distance - if (param->value[0] & RSCP_MEAS_TOTAL_DST_MEAS_PRESENT) - { - ind->value.rsc_meas.total_dist = co_read32p(¶m->value[offset]); - } + // Total Distance + if (param->value[0] & RSCP_MEAS_TOTAL_DST_MEAS_PRESENT) { + ind->value.rsc_meas.total_dist = co_read32p(¶m->value[offset]); + } - ke_msg_send(ind); - } break; + ke_msg_send(ind); + } break; - case (GATTC_INDICATE): - { - // confirm that indication has been correctly received - struct gattc_event_cfm * cfm = KE_MSG_ALLOC(GATTC_EVENT_CFM, src_id, dest_id, gattc_event_cfm); - cfm->handle = param->handle; - ke_msg_send(cfm); + case (GATTC_INDICATE): { + // confirm that indication has been correctly received + struct gattc_event_cfm *cfm = + KE_MSG_ALLOC(GATTC_EVENT_CFM, src_id, dest_id, gattc_event_cfm); + cfm->handle = param->handle; + ke_msg_send(cfm); - // Check if we were waiting for the indication - if (rscpc_env->env[conidx]->operation != NULL) - { - if (((struct rscpc_cmd *)rscpc_env->env[conidx]->operation)->operation == RSCPC_CTNL_PT_CFG_IND_OP_CODE) - { - // Stop the procedure timeout timer - ke_timer_clear(RSCPC_TIMEOUT_TIMER_IND, dest_id); + // Check if we were waiting for the indication + if (rscpc_env->env[conidx]->operation != NULL) { + if (((struct rscpc_cmd *)rscpc_env->env[conidx]->operation) + ->operation == RSCPC_CTNL_PT_CFG_IND_OP_CODE) { + // Stop the procedure timeout timer + ke_timer_clear(RSCPC_TIMEOUT_TIMER_IND, dest_id); - // RSC Measurement value has been received - struct rscpc_ctnl_pt_cfg_rsp *ind = KE_MSG_ALLOC(RSCPC_CTNL_PT_CFG_RSP, - prf_dst_task_get(&(rscpc_env->prf_env), conidx), - prf_src_task_get(&(rscpc_env->prf_env), conidx), - rscpc_ctnl_pt_cfg_rsp); + // RSC Measurement value has been received + struct rscpc_ctnl_pt_cfg_rsp *ind = + KE_MSG_ALLOC(RSCPC_CTNL_PT_CFG_RSP, + prf_dst_task_get(&(rscpc_env->prf_env), conidx), + prf_src_task_get(&(rscpc_env->prf_env), conidx), + rscpc_ctnl_pt_cfg_rsp); - // Requested operation code - ind->ctnl_pt_rsp.req_op_code = param->value[1]; - // Response value - ind->ctnl_pt_rsp.resp_value = param->value[2]; + // Requested operation code + ind->ctnl_pt_rsp.req_op_code = param->value[1]; + // Response value + ind->ctnl_pt_rsp.resp_value = param->value[2]; - // Get the list of supported sensor locations if needed - if ((ind->ctnl_pt_rsp.req_op_code == RSCP_CTNL_PT_OP_REQ_SUPP_LOC) && - (ind->ctnl_pt_rsp.resp_value == RSCP_CTNL_PT_RESP_SUCCESS) && - (param->length > 3)) - { - // Get the number of supported locations that have been received - uint8_t nb_supp_loc = (param->length - 3); - // Counter - uint8_t counter; - // Location - uint8_t loc; + // Get the list of supported sensor locations if needed + if ((ind->ctnl_pt_rsp.req_op_code == RSCP_CTNL_PT_OP_REQ_SUPP_LOC) && + (ind->ctnl_pt_rsp.resp_value == RSCP_CTNL_PT_RESP_SUCCESS) && + (param->length > 3)) { + // Get the number of supported locations that have been received + uint8_t nb_supp_loc = (param->length - 3); + // Counter + uint8_t counter; + // Location + uint8_t loc; - for (counter = 0; counter < nb_supp_loc; counter++) - { - loc = param->value[counter + 3]; + for (counter = 0; counter < nb_supp_loc; counter++) { + loc = param->value[counter + 3]; - // Check if valid - if (loc < RSCP_LOC_MAX) - { - ind->ctnl_pt_rsp.supp_loc |= (1 << loc); - } - } - } + // Check if valid + if (loc < RSCP_LOC_MAX) { + ind->ctnl_pt_rsp.supp_loc |= (1 << loc); + } + } + } - // Send the message - ke_msg_send(ind); + // Send the message + ke_msg_send(ind); - // Send the complete event message - rscpc_send_cmp_evt(rscpc_env, conidx, RSCPC_CTNL_PT_CFG_WR_OP_CODE, GAP_ERR_NO_ERROR); - } - // else drop the message - } - // else drop the message - } break; - - default: - { - ASSERT_ERR(0); - } break; + // Send the complete event message + rscpc_send_cmp_evt(rscpc_env, conidx, RSCPC_CTNL_PT_CFG_WR_OP_CODE, + GAP_ERR_NO_ERROR); } - } + // else drop the message + } + // else drop the message + } break; - return (KE_MSG_CONSUMED); + default: { + ASSERT_ERR(0); + } break; + } + } + + return (KE_MSG_CONSUMED); } /* @@ -913,29 +835,27 @@ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, */ /// Specifies the default message handlers -KE_MSG_HANDLER_TAB(rscpc) -{ - {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, - {RSCPC_ENABLE_REQ, (ke_msg_func_t)rscpc_enable_req_handler}, - {RSCPC_READ_CMD, (ke_msg_func_t)rscpc_read_cmd_handler}, - {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, - {RSCPC_CFG_NTFIND_CMD, (ke_msg_func_t)rscpc_cfg_ntfind_cmd_handler}, - {RSCPC_CTNL_PT_CFG_REQ, (ke_msg_func_t)rscpc_ctnl_pt_cfg_req_handler}, - {RSCPC_TIMEOUT_TIMER_IND, (ke_msg_func_t)rscpc_timeout_timer_ind_handler}, - {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, - {GATTC_EVENT_REQ_IND, (ke_msg_func_t)gattc_event_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, +KE_MSG_HANDLER_TAB(rscpc){ + {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, + {RSCPC_ENABLE_REQ, (ke_msg_func_t)rscpc_enable_req_handler}, + {RSCPC_READ_CMD, (ke_msg_func_t)rscpc_read_cmd_handler}, + {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, + {RSCPC_CFG_NTFIND_CMD, (ke_msg_func_t)rscpc_cfg_ntfind_cmd_handler}, + {RSCPC_CTNL_PT_CFG_REQ, (ke_msg_func_t)rscpc_ctnl_pt_cfg_req_handler}, + {RSCPC_TIMEOUT_TIMER_IND, (ke_msg_func_t)rscpc_timeout_timer_ind_handler}, + {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {GATTC_EVENT_REQ_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void rscpc_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); +void rscpc_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct rscpc_env_tag *rscpc_env = PRF_ENV_GET(RSCPC, rscpc); - task_desc->msg_handler_tab = rscpc_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(rscpc_msg_handler_tab); - task_desc->state = rscpc_env->state; - task_desc->idx_max = RSCPC_IDX_MAX; + task_desc->msg_handler_tab = rscpc_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(rscpc_msg_handler_tab); + task_desc->state = rscpc_env->state; + task_desc->idx_max = RSCPC_IDX_MAX; } #endif //(BLE_RSC_COLLECTOR) diff --git a/services/ble_profiles/rscp/rscps/src/rscps.c b/services/ble_profiles/rscp/rscps/src/rscps.c index d8ee461..1714515 100644 --- a/services/ble_profiles/rscp/rscps/src/rscps.c +++ b/services/ble_profiles/rscp/rscps/src/rscps.c @@ -15,15 +15,15 @@ #if (BLE_RSC_SENSOR) #include "rscp_common.h" +#include "attm.h" #include "gap.h" #include "gattc_task.h" -#include "attm.h" +#include "prf_utils.h" #include "rscps.h" #include "rscps_task.h" -#include "prf_utils.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * GLOBAL VARIABLE DEFINITIONS @@ -31,35 +31,49 @@ */ /// Full RSCPS Database Description - Used to add attributes into the database -static const struct attm_desc rscps_att_db[RSCS_IDX_NB] = -{ +static const struct attm_desc rscps_att_db[RSCS_IDX_NB] = { // Running Speed and Cadence Service Declaration - [RSCS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [RSCS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // RSC Measurement Characteristic Declaration - [RSCS_IDX_RSC_MEAS_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [RSCS_IDX_RSC_MEAS_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // RSC Measurement Characteristic Value - [RSCS_IDX_RSC_MEAS_VAL] = {ATT_CHAR_RSC_MEAS, PERM(NTF, ENABLE), PERM(RI, ENABLE), RSCP_RSC_MEAS_MAX_LEN}, - // RSC Measurement Characteristic - Client Characteristic Configuration Descriptor - [RSCS_IDX_RSC_MEAS_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [RSCS_IDX_RSC_MEAS_VAL] = {ATT_CHAR_RSC_MEAS, PERM(NTF, ENABLE), + PERM(RI, ENABLE), RSCP_RSC_MEAS_MAX_LEN}, + // RSC Measurement Characteristic - Client Characteristic Configuration + // Descriptor + [RSCS_IDX_RSC_MEAS_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + 0, 0}, // RSC Feature Characteristic Declaration - [RSCS_IDX_RSC_FEAT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [RSCS_IDX_RSC_FEAT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // RSC Feature Characteristic Value - [RSCS_IDX_RSC_FEAT_VAL] = {ATT_CHAR_RSC_FEAT, PERM(RD, ENABLE), PERM(RI, ENABLE), sizeof(uint16_t)}, + [RSCS_IDX_RSC_FEAT_VAL] = {ATT_CHAR_RSC_FEAT, PERM(RD, ENABLE), + PERM(RI, ENABLE), sizeof(uint16_t)}, // Sensor Location Characteristic Declaration - [RSCS_IDX_SENSOR_LOC_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [RSCS_IDX_SENSOR_LOC_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Sensor Location Characteristic Value - [RSCS_IDX_SENSOR_LOC_VAL] = {ATT_CHAR_SENSOR_LOC, PERM(RD, ENABLE), PERM(RI, ENABLE), sizeof(uint8_t)}, + [RSCS_IDX_SENSOR_LOC_VAL] = {ATT_CHAR_SENSOR_LOC, PERM(RD, ENABLE), + PERM(RI, ENABLE), sizeof(uint8_t)}, // SC Control Point Characteristic Declaration - [RSCS_IDX_SC_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, - // SC Control Point Characteristic Value - The response has the maximal length - [RSCS_IDX_SC_CTNL_PT_VAL] = {ATT_CHAR_SC_CNTL_PT, PERM(IND, ENABLE) | PERM(WRITE_REQ, ENABLE), - PERM(RI, ENABLE), RSCP_SC_CNTL_PT_RSP_MAX_LEN}, - // SC Control Point Characteristic - Client Characteristic Configuration Descriptor - [RSCS_IDX_SC_CTNL_PT_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [RSCS_IDX_SC_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, + // SC Control Point Characteristic Value - The response has the maximal + // length + [RSCS_IDX_SC_CTNL_PT_VAL] = {ATT_CHAR_SC_CNTL_PT, + PERM(IND, ENABLE) | PERM(WRITE_REQ, ENABLE), + PERM(RI, ENABLE), RSCP_SC_CNTL_PT_RSP_MAX_LEN}, + // SC Control Point Characteristic - Client Characteristic Configuration + // Descriptor + [RSCS_IDX_SC_CTNL_PT_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), + 0, 0}, }; /* @@ -79,110 +93,120 @@ static const struct attm_desc rscps_att_db[RSCS_IDX_NB] = * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t rscps_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, struct rscps_db_cfg* param) -{ - //------------------ create the attribute database for the profile ------------------- - // Service content flag - uint32_t cfg_flag= RSCPS_MANDATORY_MASK; - // DB Creation Status - uint8_t status = ATT_ERR_NO_ERROR; +static uint8_t rscps_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, + struct rscps_db_cfg *param) { + //------------------ create the attribute database for the profile + //------------------- + // Service content flag + uint32_t cfg_flag = RSCPS_MANDATORY_MASK; + // DB Creation Status + uint8_t status = ATT_ERR_NO_ERROR; - /* - * Check if the Sensor Location characteristic shall be added. - * Mandatory if the Multiple Sensor Location feature is supported, otherwise optional. - */ - if ((param->sensor_loc_supp == RSCPS_SENSOR_LOC_SUPP) || - (RSCPS_IS_FEATURE_SUPPORTED(param->rsc_feature, RSCP_FEAT_MULT_SENSOR_LOC_SUPP))) - { - cfg_flag |= RSCPS_SENSOR_LOC_MASK; + /* + * Check if the Sensor Location characteristic shall be added. + * Mandatory if the Multiple Sensor Location feature is supported, otherwise + * optional. + */ + if ((param->sensor_loc_supp == RSCPS_SENSOR_LOC_SUPP) || + (RSCPS_IS_FEATURE_SUPPORTED(param->rsc_feature, + RSCP_FEAT_MULT_SENSOR_LOC_SUPP))) { + cfg_flag |= RSCPS_SENSOR_LOC_MASK; + } + + /* + * Check if the SC Control Point characteristic shall be added + * Mandatory if at least one SC Control Point procedure is supported, + * otherwise excluded. + */ + if (RSCPS_IS_FEATURE_SUPPORTED(param->rsc_feature, + RSCP_FEAT_CALIB_PROC_SUPP) || + RSCPS_IS_FEATURE_SUPPORTED(param->rsc_feature, + RSCP_FEAT_MULT_SENSOR_LOC_SUPP) || + RSCPS_IS_FEATURE_SUPPORTED(param->rsc_feature, + RSCP_FEAT_TOTAL_DST_MEAS_SUPP)) { + cfg_flag |= RSCPS_SC_CTNL_PT_MASK; + } + + // Add service in the database + status = attm_svc_create_db( + start_hdl, ATT_SVC_RUNNING_SPEED_CADENCE, (uint8_t *)&cfg_flag, + RSCS_IDX_NB, NULL, env->task, &rscps_att_db[0], + (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, DISABLE)); + + // Check if an error has occured + if (status == ATT_ERR_NO_ERROR) { + // Allocate RSCPS required environment variable + struct rscps_env_tag *rscps_env = (struct rscps_env_tag *)ke_malloc( + sizeof(struct rscps_env_tag), KE_MEM_ATT_DB); + + // Initialize RSCPS environment + + env->env = (prf_env_t *)rscps_env; + rscps_env->shdl = *start_hdl; + rscps_env->prf_cfg = cfg_flag; + rscps_env->features = param->rsc_feature; + rscps_env->operation = RSCPS_RESERVED_OP_CODE; + + if (RSCPS_IS_FEATURE_SUPPORTED(rscps_env->prf_cfg, RSCPS_SENSOR_LOC_MASK)) { + rscps_env->sensor_loc = (param->sensor_loc >= RSCP_LOC_MAX) + ? RSCP_LOC_OTHER + : param->sensor_loc; } - /* - * Check if the SC Control Point characteristic shall be added - * Mandatory if at least one SC Control Point procedure is supported, otherwise excluded. - */ - if (RSCPS_IS_FEATURE_SUPPORTED(param->rsc_feature, RSCP_FEAT_CALIB_PROC_SUPP) || - RSCPS_IS_FEATURE_SUPPORTED(param->rsc_feature, RSCP_FEAT_MULT_SENSOR_LOC_SUPP) || - RSCPS_IS_FEATURE_SUPPORTED(param->rsc_feature, RSCP_FEAT_TOTAL_DST_MEAS_SUPP)) - { - cfg_flag |= RSCPS_SC_CTNL_PT_MASK; - } + rscps_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + // Mono Instantiated task + rscps_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); - // Add service in the database - status = attm_svc_create_db(start_hdl, ATT_SVC_RUNNING_SPEED_CADENCE, (uint8_t *)&cfg_flag, - RSCS_IDX_NB, NULL, env->task, &rscps_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | PERM(SVC_MI, DISABLE)); + // initialize environment variable + env->id = TASK_ID_RSCPS; + rscps_task_init(&(env->desc)); - // Check if an error has occured - if (status == ATT_ERR_NO_ERROR) - { - // Allocate RSCPS required environment variable - struct rscps_env_tag* rscps_env = - (struct rscps_env_tag* ) ke_malloc(sizeof(struct rscps_env_tag), KE_MEM_ATT_DB); + rscps_env->ntf = NULL; + memset(rscps_env->prfl_ntf_ind_cfg, 0, BLE_CONNECTION_MAX); - // Initialize RSCPS environment + // If we are here, database has been fulfilled with success, go to idle + // state + ke_state_set(env->task, RSCPS_IDLE); + } - env->env = (prf_env_t*) rscps_env; - rscps_env->shdl = *start_hdl; - rscps_env->prf_cfg = cfg_flag; - rscps_env->features = param->rsc_feature; - rscps_env->operation = RSCPS_RESERVED_OP_CODE; - - if (RSCPS_IS_FEATURE_SUPPORTED(rscps_env->prf_cfg, RSCPS_SENSOR_LOC_MASK)) - { - rscps_env->sensor_loc = (param->sensor_loc >= RSCP_LOC_MAX) ? - RSCP_LOC_OTHER : param->sensor_loc; - } - - rscps_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - // Mono Instantiated task - rscps_env->prf_env.prf_task = env->task | PERM(PRF_MI, DISABLE); - - // initialize environment variable - env->id = TASK_ID_RSCPS; - rscps_task_init(&(env->desc)); - - rscps_env->ntf = NULL; - memset(rscps_env->prfl_ntf_ind_cfg, 0, BLE_CONNECTION_MAX); - - // If we are here, database has been fulfilled with success, go to idle state - ke_state_set(env->task, RSCPS_IDLE); - } - - return (status); + return (status); } /** **************************************************************************************** * @brief Destruction of the RSCPS module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void rscps_destroy(struct prf_task_env* env) -{ - struct rscps_env_tag* rscps_env = (struct rscps_env_tag*) env->env; +static void rscps_destroy(struct prf_task_env *env) { + struct rscps_env_tag *rscps_env = (struct rscps_env_tag *)env->env; - // cleanup environment variable for each task instances - if(rscps_env->ntf != NULL) - { - ke_free(rscps_env->ntf); - } + // cleanup environment variable for each task instances + if (rscps_env->ntf != NULL) { + ke_free(rscps_env->ntf); + } - // free profile environment variables - env->env = NULL; - ke_free(rscps_env); + // free profile environment variables + env->env = NULL; + ke_free(rscps_env); } /** @@ -193,11 +217,9 @@ static void rscps_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void rscps_create(struct prf_task_env* env, uint8_t conidx) -{ - struct rscps_env_tag* rscps_env = (struct rscps_env_tag*) env->env; - rscps_env->prfl_ntf_ind_cfg[conidx] = 0; - +static void rscps_create(struct prf_task_env *env, uint8_t conidx) { + struct rscps_env_tag *rscps_env = (struct rscps_env_tag *)env->env; + rscps_env->prfl_ntf_ind_cfg[conidx] = 0; } /** @@ -209,12 +231,12 @@ static void rscps_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void rscps_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct rscps_env_tag* rscps_env = (struct rscps_env_tag*) env->env; +static void rscps_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct rscps_env_tag *rscps_env = (struct rscps_env_tag *)env->env; - // clean-up environment variable allocated for task instance - rscps_env->prfl_ntf_ind_cfg[conidx] = 0; + // clean-up environment variable allocated for task instance + rscps_env->prfl_ntf_ind_cfg[conidx] = 0; } /* @@ -223,12 +245,11 @@ static void rscps_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reas */ /// RSCPS Task interface required by profile manager -const struct prf_task_cbs rscps_itf = -{ - (prf_init_fnct) rscps_init, - rscps_destroy, - rscps_create, - rscps_cleanup, +const struct prf_task_cbs rscps_itf = { + (prf_init_fnct)rscps_init, + rscps_destroy, + rscps_create, + rscps_cleanup, }; /* @@ -236,119 +257,108 @@ const struct prf_task_cbs rscps_itf = **************************************************************************************** */ -const struct prf_task_cbs* rscps_prf_itf_get(void) -{ - return &rscps_itf; +const struct prf_task_cbs *rscps_prf_itf_get(void) { return &rscps_itf; } + +void rscps_send_cmp_evt(uint8_t conidx, uint8_t src_id, uint8_t dest_id, + uint8_t operation, uint8_t status) { + // Get the address of the environment + struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); + + // Go back to the Connected state if the state is busy + if (ke_state_get(src_id) == RSCPS_BUSY) { + ke_state_set(src_id, RSCPS_IDLE); + } + + // Set the operation code + rscps_env->operation = RSCPS_RESERVED_OP_CODE; + + // Send the message + struct rscps_cmp_evt *evt = + KE_MSG_ALLOC(RSCPS_CMP_EVT, dest_id, src_id, rscps_cmp_evt); + + evt->operation = operation; + evt->status = status; + + ke_msg_send(evt); } -void rscps_send_cmp_evt(uint8_t conidx, uint8_t src_id, uint8_t dest_id, uint8_t operation, uint8_t status) -{ - // Get the address of the environment - struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); +void rscps_exe_operation(void) { + struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); - // Go back to the Connected state if the state is busy - if (ke_state_get(src_id) == RSCPS_BUSY) - { - ke_state_set(src_id, RSCPS_IDLE); + ASSERT_ERR(rscps_env->ntf != NULL); + + bool finished = true; + + while (rscps_env->ntf->cursor < BLE_CONNECTION_MAX) { + // Check if notifications are enabled + if (RSCPS_IS_NTFIND_ENABLED(rscps_env->ntf->cursor, + RSCP_PRF_CFG_FLAG_RSC_MEAS_NTF)) { + // Allocate the GATT notification message + struct gattc_send_evt_cmd *meas_val = KE_MSG_ALLOC_DYN( + GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, rscps_env->ntf->cursor), + prf_src_task_get(&(rscps_env->prf_env), 0), gattc_send_evt_cmd, + rscps_env->ntf->length); + + // Fill in the parameter structure + meas_val->operation = GATTC_NOTIFY; + meas_val->handle = RSCPS_HANDLE(RSCS_IDX_RSC_MEAS_VAL); + meas_val->length = rscps_env->ntf->length; + memcpy(meas_val->value, rscps_env->ntf->value, rscps_env->ntf->length); + + // Send the event + ke_msg_send(meas_val); + + finished = false; + rscps_env->ntf->cursor++; + break; } - // Set the operation code + rscps_env->ntf->cursor++; + } + + // check if operation is finished + if (finished) { + // Inform the application that a procedure has been completed + struct rscps_ntf_rsc_meas_rsp *rsp = KE_MSG_ALLOC( + RSCPS_NTF_RSC_MEAS_RSP, prf_dst_task_get(&(rscps_env->prf_env), 0), + prf_src_task_get(&(rscps_env->prf_env), 0), rscps_ntf_rsc_meas_rsp); + + rsp->status = GAP_ERR_NO_ERROR; + ke_msg_send(rsp); + + // free operation + ke_free(rscps_env->ntf); + rscps_env->ntf = NULL; rscps_env->operation = RSCPS_RESERVED_OP_CODE; - // Send the message - struct rscps_cmp_evt *evt = KE_MSG_ALLOC(RSCPS_CMP_EVT, - dest_id, src_id, - rscps_cmp_evt); - - evt->operation = operation; - evt->status = status; - - ke_msg_send(evt); + ke_state_set(prf_src_task_get(&(rscps_env->prf_env), 0), RSCPS_IDLE); + } } +void rscps_send_rsp_ind(uint8_t conidx, uint8_t req_op_code, uint8_t status) { + // Get the address of the environment + struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); -void rscps_exe_operation(void) -{ - struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); + // Allocate the GATT notification message + struct gattc_send_evt_cmd *ctl_pt_rsp = + KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&rscps_env->prf_env, conidx), + gattc_send_evt_cmd, RSCP_SC_CNTL_PT_RSP_MIN_LEN); - ASSERT_ERR(rscps_env->ntf != NULL); + // Fill in the parameter structure + ctl_pt_rsp->operation = GATTC_INDICATE; + ctl_pt_rsp->handle = RSCPS_HANDLE(RSCS_IDX_SC_CTNL_PT_VAL); + // Pack Control Point confirmation + ctl_pt_rsp->length = RSCP_SC_CNTL_PT_RSP_MIN_LEN; + // Response Code + ctl_pt_rsp->value[0] = RSCP_CTNL_PT_RSP_CODE; + // Request Operation Code + ctl_pt_rsp->value[1] = req_op_code; + // Response value + ctl_pt_rsp->value[2] = status; - bool finished = true; - - while(rscps_env->ntf->cursor < BLE_CONNECTION_MAX) - { - // Check if notifications are enabled - if(RSCPS_IS_NTFIND_ENABLED(rscps_env->ntf->cursor, RSCP_PRF_CFG_FLAG_RSC_MEAS_NTF)) - { - // Allocate the GATT notification message - struct gattc_send_evt_cmd *meas_val = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, rscps_env->ntf->cursor), - prf_src_task_get(&(rscps_env->prf_env), 0), - gattc_send_evt_cmd, rscps_env->ntf->length); - - // Fill in the parameter structure - meas_val->operation = GATTC_NOTIFY; - meas_val->handle = RSCPS_HANDLE(RSCS_IDX_RSC_MEAS_VAL); - meas_val->length = rscps_env->ntf->length; - memcpy(meas_val->value, rscps_env->ntf->value, rscps_env->ntf->length); - - // Send the event - ke_msg_send(meas_val); - - finished = false; - rscps_env->ntf->cursor++; - break; - } - - rscps_env->ntf->cursor++; - } - - // check if operation is finished - if(finished) - { - // Inform the application that a procedure has been completed - struct rscps_ntf_rsc_meas_rsp *rsp = KE_MSG_ALLOC(RSCPS_NTF_RSC_MEAS_RSP, - prf_dst_task_get(&(rscps_env->prf_env), 0), - prf_src_task_get(&(rscps_env->prf_env), 0), - rscps_ntf_rsc_meas_rsp); - - rsp->status = GAP_ERR_NO_ERROR; - ke_msg_send(rsp); - - // free operation - ke_free(rscps_env->ntf); - rscps_env->ntf = NULL; - rscps_env->operation = RSCPS_RESERVED_OP_CODE; - - ke_state_set(prf_src_task_get(&(rscps_env->prf_env), 0), RSCPS_IDLE); - } -} - -void rscps_send_rsp_ind(uint8_t conidx, uint8_t req_op_code, uint8_t status) -{ - // Get the address of the environment - struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); - - // Allocate the GATT notification message - struct gattc_send_evt_cmd *ctl_pt_rsp = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), - prf_src_task_get(&rscps_env->prf_env, conidx), - gattc_send_evt_cmd, RSCP_SC_CNTL_PT_RSP_MIN_LEN); - - // Fill in the parameter structure - ctl_pt_rsp->operation = GATTC_INDICATE; - ctl_pt_rsp->handle = RSCPS_HANDLE(RSCS_IDX_SC_CTNL_PT_VAL); - // Pack Control Point confirmation - ctl_pt_rsp->length = RSCP_SC_CNTL_PT_RSP_MIN_LEN; - // Response Code - ctl_pt_rsp->value[0] = RSCP_CTNL_PT_RSP_CODE; - // Request Operation Code - ctl_pt_rsp->value[1] = req_op_code; - // Response value - ctl_pt_rsp->value[2] = status; - - // Send the event - ke_msg_send(ctl_pt_rsp); + // Send the event + ke_msg_send(ctl_pt_rsp); } #endif //(BLE_RSC_SENSOR) diff --git a/services/ble_profiles/rscp/rscps/src/rscps_task.c b/services/ble_profiles/rscp/rscps/src/rscps_task.c index 9e21dfc..6ef5c96 100644 --- a/services/ble_profiles/rscp/rscps/src/rscps_task.c +++ b/services/ble_profiles/rscp/rscps/src/rscps_task.c @@ -15,15 +15,15 @@ #if (BLE_RSC_SENSOR) #include "rscp_common.h" +#include "attm.h" #include "gap.h" #include "gattc_task.h" -#include "attm.h" +#include "prf_utils.h" #include "rscps.h" #include "rscps_task.h" -#include "prf_utils.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * LOCAL FUNCTIONS DEFINITIONS @@ -41,49 +41,46 @@ **************************************************************************************** */ __STATIC int rscps_enable_req_handler(ke_msg_id_t const msgid, - struct rscps_enable_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); - // Status - uint8_t status = PRF_ERR_REQ_DISALLOWED; + struct rscps_enable_req *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); + // Status + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if(ke_state_get(dest_id) == RSCPS_IDLE) - { - status = GAP_ERR_NO_ERROR; + if (ke_state_get(dest_id) == RSCPS_IDLE) { + status = GAP_ERR_NO_ERROR; - if (!RSCPS_IS_PRESENT(rscps_env->prfl_ntf_ind_cfg[param->conidx], RSCP_PRF_CFG_PERFORMED_OK)) - { - // Check the provided value - if (param->rsc_meas_ntf_cfg == PRF_CLI_START_NTF) - { - // Store the status - RSCPS_ENABLE_NTFIND(param->conidx, RSCP_PRF_CFG_FLAG_RSC_MEAS_NTF); - } + if (!RSCPS_IS_PRESENT(rscps_env->prfl_ntf_ind_cfg[param->conidx], + RSCP_PRF_CFG_PERFORMED_OK)) { + // Check the provided value + if (param->rsc_meas_ntf_cfg == PRF_CLI_START_NTF) { + // Store the status + RSCPS_ENABLE_NTFIND(param->conidx, RSCP_PRF_CFG_FLAG_RSC_MEAS_NTF); + } - if (RSCPS_IS_FEATURE_SUPPORTED(rscps_env->prf_cfg, RSCPS_SC_CTNL_PT_MASK)) - { - // Check the provided value - if (param->sc_ctnl_pt_ntf_cfg == PRF_CLI_START_IND) - { - // Store the status - RSCPS_ENABLE_NTFIND(param->conidx, RSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND); - } - } - // Enable Bonded Data - RSCPS_ENABLE_NTFIND(param->conidx, RSCP_PRF_CFG_PERFORMED_OK); + if (RSCPS_IS_FEATURE_SUPPORTED(rscps_env->prf_cfg, + RSCPS_SC_CTNL_PT_MASK)) { + // Check the provided value + if (param->sc_ctnl_pt_ntf_cfg == PRF_CLI_START_IND) { + // Store the status + RSCPS_ENABLE_NTFIND(param->conidx, RSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND); } + } + // Enable Bonded Data + RSCPS_ENABLE_NTFIND(param->conidx, RSCP_PRF_CFG_PERFORMED_OK); } + } - // send completed information to APP task that contains error status - struct rscps_enable_rsp *cmp_evt = KE_MSG_ALLOC(RSCPS_ENABLE_RSP, src_id, dest_id, rscps_enable_rsp); - cmp_evt->status = status; - cmp_evt->conidx = param->conidx; - ke_msg_send(cmp_evt); + // send completed information to APP task that contains error status + struct rscps_enable_rsp *cmp_evt = + KE_MSG_ALLOC(RSCPS_ENABLE_RSP, src_id, dest_id, rscps_enable_rsp); + cmp_evt->status = status; + cmp_evt->conidx = param->conidx; + ke_msg_send(cmp_evt); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -98,74 +95,74 @@ __STATIC int rscps_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_read_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if(ke_state_get(dest_id) == RSCPS_IDLE) - { - // Get the address of the environment - struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); - uint8_t conidx = KE_IDX_GET(src_id); - uint8_t att_idx = RSCPS_IDX(param->handle); + struct gattc_read_req_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + if (ke_state_get(dest_id) == RSCPS_IDLE) { + // Get the address of the environment + struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); + uint8_t conidx = KE_IDX_GET(src_id); + uint8_t att_idx = RSCPS_IDX(param->handle); - // Send data to peer device - struct gattc_read_cfm* cfm = NULL; + // Send data to peer device + struct gattc_read_cfm *cfm = NULL; - uint8_t status = ATT_ERR_NO_ERROR; + uint8_t status = ATT_ERR_NO_ERROR; - switch(att_idx) - { - case RSCS_IDX_RSC_MEAS_NTF_CFG: - { - // Fill data - cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(uint16_t)); - cfm->length = sizeof(uint16_t); - co_write16p(cfm->value, (rscps_env->prfl_ntf_ind_cfg[conidx] & RSCP_PRF_CFG_FLAG_RSC_MEAS_NTF) - ? PRF_CLI_START_NTF : PRF_CLI_STOP_NTFIND); - } break; + switch (att_idx) { + case RSCS_IDX_RSC_MEAS_NTF_CFG: { + // Fill data + cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, + sizeof(uint16_t)); + cfm->length = sizeof(uint16_t); + co_write16p(cfm->value, (rscps_env->prfl_ntf_ind_cfg[conidx] & + RSCP_PRF_CFG_FLAG_RSC_MEAS_NTF) + ? PRF_CLI_START_NTF + : PRF_CLI_STOP_NTFIND); + } break; - case RSCS_IDX_RSC_FEAT_VAL: - { - // Fill data - cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(uint16_t)); - cfm->length = sizeof(uint16_t); - co_write16p(cfm->value, rscps_env->features); - } break; + case RSCS_IDX_RSC_FEAT_VAL: { + // Fill data + cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, + sizeof(uint16_t)); + cfm->length = sizeof(uint16_t); + co_write16p(cfm->value, rscps_env->features); + } break; - case RSCS_IDX_SENSOR_LOC_VAL: - { - // Fill data - cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(uint8_t)); - cfm->length = sizeof(uint8_t); - cfm->value[0] = rscps_env->sensor_loc; - } break; + case RSCS_IDX_SENSOR_LOC_VAL: { + // Fill data + cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, + sizeof(uint8_t)); + cfm->length = sizeof(uint8_t); + cfm->value[0] = rscps_env->sensor_loc; + } break; - case RSCS_IDX_SC_CTNL_PT_NTF_CFG: - { - // Fill data - cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(uint16_t)); - cfm->length = sizeof(uint16_t); - co_write16p(cfm->value, (rscps_env->prfl_ntf_ind_cfg[conidx] & RSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND) - ? PRF_CLI_START_IND : PRF_CLI_STOP_NTFIND); - } break; + case RSCS_IDX_SC_CTNL_PT_NTF_CFG: { + // Fill data + cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, + sizeof(uint16_t)); + cfm->length = sizeof(uint16_t); + co_write16p(cfm->value, (rscps_env->prfl_ntf_ind_cfg[conidx] & + RSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND) + ? PRF_CLI_START_IND + : PRF_CLI_STOP_NTFIND); + } break; - default: - { - cfm = KE_MSG_ALLOC(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm); - cfm->length = 0; - status = ATT_ERR_REQUEST_NOT_SUPPORTED; - } break; - } - - cfm->handle = param->handle; - cfm->status = status; - - // Send value to peer device. - ke_msg_send(cfm); + default: { + cfm = KE_MSG_ALLOC(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm); + cfm->length = 0; + status = ATT_ERR_REQUEST_NOT_SUPPORTED; + } break; } - return (KE_MSG_CONSUMED); + cfm->handle = param->handle; + cfm->status = status; + + // Send value to peer device. + ke_msg_send(cfm); + } + + return (KE_MSG_CONSUMED); } /** @@ -179,46 +176,39 @@ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_att_info_req_ind *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - if(ke_state_get(dest_id) == RSCPS_IDLE) - { - // Get the address of the environment - struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); - uint8_t att_idx = RSCPS_IDX(param->handle); - struct gattc_att_info_cfm * cfm; +__STATIC int gattc_att_info_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_att_info_req_ind *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + if (ke_state_get(dest_id) == RSCPS_IDLE) { + // Get the address of the environment + struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); + uint8_t att_idx = RSCPS_IDX(param->handle); + struct gattc_att_info_cfm *cfm; - //Send write response - cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); - cfm->handle = param->handle; + // Send write response + cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); + cfm->handle = param->handle; - // check if it's a client configuration char - if((att_idx == RSCS_IDX_RSC_MEAS_NTF_CFG) - || (att_idx == RSCS_IDX_SC_CTNL_PT_NTF_CFG)) - { - // CCC attribute length = 2 - cfm->length = 2; - cfm->status = GAP_ERR_NO_ERROR; - } - else if (att_idx == RSCS_IDX_SC_CTNL_PT_VAL) - { - // force length to zero to reject any write starting from something != 0 - cfm->length = 0; - cfm->status = GAP_ERR_NO_ERROR; - } - // not expected request - else - { - cfm->length = 0; - cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; - } - ke_msg_send(cfm); - } + // check if it's a client configuration char + if ((att_idx == RSCS_IDX_RSC_MEAS_NTF_CFG) || + (att_idx == RSCS_IDX_SC_CTNL_PT_NTF_CFG)) { + // CCC attribute length = 2 + cfm->length = 2; + cfm->status = GAP_ERR_NO_ERROR; + } else if (att_idx == RSCS_IDX_SC_CTNL_PT_VAL) { + // force length to zero to reject any write starting from something != 0 + cfm->length = 0; + cfm->status = GAP_ERR_NO_ERROR; + } + // not expected request + else { + cfm->length = 0; + cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; + } + ke_msg_send(cfm); + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -231,79 +221,76 @@ __STATIC int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int rscps_ntf_rsc_meas_req_handler(ke_msg_id_t const msgid, - struct rscps_ntf_rsc_meas_req *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; +__STATIC int rscps_ntf_rsc_meas_req_handler( + ke_msg_id_t const msgid, struct rscps_ntf_rsc_meas_req *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; - // State shall be Connected or Busy - if (ke_state_get(dest_id) == RSCPS_IDLE) - { - // Get the address of the environment - struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); - // allocate and prepare data to notify - rscps_env->ntf = (struct rscps_ntf*) ke_malloc(sizeof(struct rscps_ntf), KE_MEM_KE_MSG); + // State shall be Connected or Busy + if (ke_state_get(dest_id) == RSCPS_IDLE) { + // Get the address of the environment + struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); + // allocate and prepare data to notify + rscps_env->ntf = + (struct rscps_ntf *)ke_malloc(sizeof(struct rscps_ntf), KE_MEM_KE_MSG); - // Fill in the parameter structure - rscps_env->ntf->length = RSCP_RSC_MEAS_MIN_LEN; + // Fill in the parameter structure + rscps_env->ntf->length = RSCP_RSC_MEAS_MIN_LEN; - // Check the provided flags value - if (!RSCPS_IS_FEATURE_SUPPORTED(rscps_env->prf_cfg, RSCP_FEAT_INST_STRIDE_LEN_SUPP) && - RSCPS_IS_PRESENT(param->flags, RSCP_MEAS_INST_STRIDE_LEN_PRESENT)) - { - // Force Measurement Instantaneous Stride Length Present to No (Not supported) - param->flags &= ~RSCP_MEAS_INST_STRIDE_LEN_PRESENT; - } - - if (!RSCPS_IS_FEATURE_SUPPORTED(rscps_env->prf_cfg, RSCP_FEAT_TOTAL_DST_MEAS_SUPP) && - RSCPS_IS_PRESENT(param->flags, RSCP_MEAS_TOTAL_DST_MEAS_PRESENT)) - { - // Force Total Distance Measurement Present to No (Not supported) - param->flags &= ~RSCP_MEAS_TOTAL_DST_MEAS_PRESENT; - } - - // Force the unused bits of the flag value to 0 - rscps_env->ntf->value[0] = param->flags & RSCP_MEAS_ALL_PRESENT; - - // Instantaneous Speed - co_write16p(&rscps_env->ntf->value[1], param->inst_speed); - // Instantaneous Cadence - rscps_env->ntf->value[3] = param->inst_cad; - - // Instantaneous Stride Length - if (RSCPS_IS_PRESENT(param->flags, RSCP_MEAS_INST_STRIDE_LEN_PRESENT)) - { - co_write16p(&rscps_env->ntf->value[rscps_env->ntf->length], param->inst_stride_len); - rscps_env->ntf->length += 2; - } - - // Total Distance - if (RSCPS_IS_PRESENT(param->flags, RSCP_MEAS_TOTAL_DST_MEAS_PRESENT)) - { - co_write32p(&rscps_env->ntf->value[rscps_env->ntf->length], param->total_dist); - rscps_env->ntf->length += 4; - } - - // Configure the environment - rscps_env->operation = RSCPS_SEND_RSC_MEAS_OP_CODE; - rscps_env->ntf->cursor = 0; - - // Go to busy state - ke_state_set(dest_id, RSCPS_BUSY); - - // start operation execution - rscps_exe_operation(); - } - else - { - // Save it for later - msg_status = KE_MSG_SAVED; + // Check the provided flags value + if (!RSCPS_IS_FEATURE_SUPPORTED(rscps_env->prf_cfg, + RSCP_FEAT_INST_STRIDE_LEN_SUPP) && + RSCPS_IS_PRESENT(param->flags, RSCP_MEAS_INST_STRIDE_LEN_PRESENT)) { + // Force Measurement Instantaneous Stride Length Present to No (Not + // supported) + param->flags &= ~RSCP_MEAS_INST_STRIDE_LEN_PRESENT; } - return (int)msg_status; + if (!RSCPS_IS_FEATURE_SUPPORTED(rscps_env->prf_cfg, + RSCP_FEAT_TOTAL_DST_MEAS_SUPP) && + RSCPS_IS_PRESENT(param->flags, RSCP_MEAS_TOTAL_DST_MEAS_PRESENT)) { + // Force Total Distance Measurement Present to No (Not supported) + param->flags &= ~RSCP_MEAS_TOTAL_DST_MEAS_PRESENT; + } + + // Force the unused bits of the flag value to 0 + rscps_env->ntf->value[0] = param->flags & RSCP_MEAS_ALL_PRESENT; + + // Instantaneous Speed + co_write16p(&rscps_env->ntf->value[1], param->inst_speed); + // Instantaneous Cadence + rscps_env->ntf->value[3] = param->inst_cad; + + // Instantaneous Stride Length + if (RSCPS_IS_PRESENT(param->flags, RSCP_MEAS_INST_STRIDE_LEN_PRESENT)) { + co_write16p(&rscps_env->ntf->value[rscps_env->ntf->length], + param->inst_stride_len); + rscps_env->ntf->length += 2; + } + + // Total Distance + if (RSCPS_IS_PRESENT(param->flags, RSCP_MEAS_TOTAL_DST_MEAS_PRESENT)) { + co_write32p(&rscps_env->ntf->value[rscps_env->ntf->length], + param->total_dist); + rscps_env->ntf->length += 4; + } + + // Configure the environment + rscps_env->operation = RSCPS_SEND_RSC_MEAS_OP_CODE; + rscps_env->ntf->cursor = 0; + + // Go to busy state + ke_state_set(dest_id, RSCPS_BUSY); + + // start operation execution + rscps_exe_operation(); + } else { + // Save it for later + msg_status = KE_MSG_SAVED; + } + + return (int)msg_status; } /** @@ -319,136 +306,122 @@ __STATIC int rscps_ntf_rsc_meas_req_handler(ke_msg_id_t const msgid, __STATIC int rscps_sc_ctnl_pt_cfm_handler(ke_msg_id_t const msgid, struct rscps_sc_ctnl_pt_cfm *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); - uint8_t conidx = KE_IDX_GET(src_id); - // Status - uint8_t status = PRF_ERR_REQ_DISALLOWED; + ke_task_id_t const src_id) { + // Get the address of the environment + struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); + uint8_t conidx = KE_IDX_GET(src_id); + // Status + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if (ke_state_get(dest_id) == RSCPS_BUSY) - { - do - { - // check if op code valid - if((param->op_code < RSCPS_CTNL_PT_CUMUL_VAL_OP_CODE) - || (param->op_code > RSCPS_CTNL_ERR_IND_OP_CODE)) - { - //Wrong op code - status = PRF_ERR_INVALID_PARAM; - break; + if (ke_state_get(dest_id) == RSCPS_BUSY) { + do { + // check if op code valid + if ((param->op_code < RSCPS_CTNL_PT_CUMUL_VAL_OP_CODE) || + (param->op_code > RSCPS_CTNL_ERR_IND_OP_CODE)) { + // Wrong op code + status = PRF_ERR_INVALID_PARAM; + break; + } + + // Check the current operation + if ((rscps_env->operation < RSCPS_CTNL_PT_CUMUL_VAL_OP_CODE) || + (param->op_code != rscps_env->operation)) { + // The confirmation has been sent without request indication, ignore + status = PRF_ERR_REQ_DISALLOWED; + break; + } + + // The SC Control Point Characteristic must be supported if we are here + if (RSCPS_IS_FEATURE_SUPPORTED(rscps_env->prf_cfg, + RSCPS_SC_CTNL_PT_MASK)) { + // Allocate the GATT notification message + struct gattc_send_evt_cmd *ctl_pt_rsp = KE_MSG_ALLOC_DYN( + GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, param->conidx), dest_id, + gattc_send_evt_cmd, RSCP_SC_CNTL_PT_RSP_MAX_LEN); + + // Fill in the parameter structure + ctl_pt_rsp->operation = GATTC_INDICATE; + ctl_pt_rsp->handle = RSCPS_HANDLE(RSCS_IDX_SC_CTNL_PT_VAL); + // Pack Control Point confirmation + ctl_pt_rsp->length = RSCP_SC_CNTL_PT_RSP_MIN_LEN; + + // Set the operation code (Response Code) + ctl_pt_rsp->value[0] = RSCP_CTNL_PT_RSP_CODE; + // Set the response value + ctl_pt_rsp->value[2] = (param->status > RSCP_CTNL_PT_RESP_FAILED) + ? RSCP_CTNL_PT_RESP_FAILED + : param->status; + + switch (rscps_env->operation) { + // Set cumulative value + case (RSCPS_CTNL_PT_CUMUL_VAL_OP_CODE): { + // Set the request operation code + ctl_pt_rsp->value[1] = RSCP_CTNL_PT_OP_SET_CUMUL_VAL; + status = GAP_ERR_NO_ERROR; + } break; + + // Start Sensor Calibration + case (RSCPS_CTNL_PT_START_CAL_OP_CODE): { + // Set the request operation code + ctl_pt_rsp->value[1] = RSCP_CTNL_PT_OP_START_CALIB; + status = GAP_ERR_NO_ERROR; + } break; + + // Update Sensor Location + case (RSCPS_CTNL_PT_UPD_LOC_OP_CODE): { + // Set the request operation code + ctl_pt_rsp->value[1] = RSCP_CTNL_PT_OP_UPD_LOC; + + if (param->status == RSCP_CTNL_PT_RESP_SUCCESS) { + // The Sensor Location Characteristic is supported if we are here + if (RSCPS_IS_FEATURE_SUPPORTED(rscps_env->prf_cfg, + RSCPS_SENSOR_LOC_MASK)) { + // If operation is successful, update the value in the database + rscps_env->sensor_loc = param->value.sensor_loc; + status = GAP_ERR_NO_ERROR; } + } + } break; - // Check the current operation - if ((rscps_env->operation < RSCPS_CTNL_PT_CUMUL_VAL_OP_CODE) || - (param->op_code != rscps_env->operation)) - { - // The confirmation has been sent without request indication, ignore - status = PRF_ERR_REQ_DISALLOWED; - break; + case (RSCPS_CTNL_PT_SUPP_LOC_OP_CODE): { + // Set the request operation code + ctl_pt_rsp->value[1] = RSCP_CTNL_PT_OP_REQ_SUPP_LOC; + + if (param->status == RSCP_CTNL_PT_RESP_SUCCESS) { + // Counter + uint8_t counter; + + // Set the list of supported location + for (counter = 0; counter < RSCP_LOC_MAX; counter++) { + if (((param->value.supp_sensor_loc >> counter) & 0x0001) == + 0x0001) { + ctl_pt_rsp->value[ctl_pt_rsp->length] = counter; + ctl_pt_rsp->length++; + } } + status = GAP_ERR_NO_ERROR; + } + } break; - // The SC Control Point Characteristic must be supported if we are here - if (RSCPS_IS_FEATURE_SUPPORTED(rscps_env->prf_cfg, RSCPS_SC_CTNL_PT_MASK)) - { - // Allocate the GATT notification message - struct gattc_send_evt_cmd *ctl_pt_rsp = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, param->conidx), dest_id, - gattc_send_evt_cmd, RSCP_SC_CNTL_PT_RSP_MAX_LEN); - - // Fill in the parameter structure - ctl_pt_rsp->operation = GATTC_INDICATE; - ctl_pt_rsp->handle = RSCPS_HANDLE(RSCS_IDX_SC_CTNL_PT_VAL); - // Pack Control Point confirmation - ctl_pt_rsp->length = RSCP_SC_CNTL_PT_RSP_MIN_LEN; - - // Set the operation code (Response Code) - ctl_pt_rsp->value[0] = RSCP_CTNL_PT_RSP_CODE; - // Set the response value - ctl_pt_rsp->value[2] = (param->status > RSCP_CTNL_PT_RESP_FAILED) ? RSCP_CTNL_PT_RESP_FAILED : param->status; - - switch (rscps_env->operation) - { - // Set cumulative value - case (RSCPS_CTNL_PT_CUMUL_VAL_OP_CODE): - { - // Set the request operation code - ctl_pt_rsp->value[1] = RSCP_CTNL_PT_OP_SET_CUMUL_VAL; - status = GAP_ERR_NO_ERROR; - } break; - - // Start Sensor Calibration - case (RSCPS_CTNL_PT_START_CAL_OP_CODE): - { - // Set the request operation code - ctl_pt_rsp->value[1] = RSCP_CTNL_PT_OP_START_CALIB; - status = GAP_ERR_NO_ERROR; - } break; - - // Update Sensor Location - case (RSCPS_CTNL_PT_UPD_LOC_OP_CODE): - { - // Set the request operation code - ctl_pt_rsp->value[1] = RSCP_CTNL_PT_OP_UPD_LOC; - - if (param->status == RSCP_CTNL_PT_RESP_SUCCESS) - { - // The Sensor Location Characteristic is supported if we are here - if (RSCPS_IS_FEATURE_SUPPORTED(rscps_env->prf_cfg, RSCPS_SENSOR_LOC_MASK)) - { - // If operation is successful, update the value in the database - rscps_env->sensor_loc = param->value.sensor_loc; - status = GAP_ERR_NO_ERROR; - } - } - } break; - - case (RSCPS_CTNL_PT_SUPP_LOC_OP_CODE): - { - // Set the request operation code - ctl_pt_rsp->value[1] = RSCP_CTNL_PT_OP_REQ_SUPP_LOC; - - if (param->status == RSCP_CTNL_PT_RESP_SUCCESS) - { - // Counter - uint8_t counter; - - // Set the list of supported location - for (counter = 0; counter < RSCP_LOC_MAX; counter++) - { - if (((param->value.supp_sensor_loc >> counter) & 0x0001) == 0x0001) - { - ctl_pt_rsp->value[ctl_pt_rsp->length] = counter; - ctl_pt_rsp->length++; - } - } - status = GAP_ERR_NO_ERROR; - } - } break; - - default: - { - ASSERT_ERR(0); - } break; - } - - // Send the event - ke_msg_send(ctl_pt_rsp); - } - } while (0); - - if (status != GAP_ERR_NO_ERROR) - { - // Inform the application that a procedure has been completed - rscps_send_cmp_evt(conidx, - prf_src_task_get(&rscps_env->prf_env, conidx), - prf_dst_task_get(&rscps_env->prf_env, conidx), - rscps_env->operation, param->status); + default: { + ASSERT_ERR(0); + } break; } - } - return (KE_MSG_CONSUMED); + // Send the event + ke_msg_send(ctl_pt_rsp); + } + } while (0); + + if (status != GAP_ERR_NO_ERROR) { + // Inform the application that a procedure has been completed + rscps_send_cmp_evt(conidx, prf_src_task_get(&rscps_env->prf_env, conidx), + prf_dst_task_get(&rscps_env->prf_env, conidx), + rscps_env->operation, param->status); + } + } + + return (KE_MSG_CONSUMED); } /** @@ -461,288 +434,263 @@ __STATIC int rscps_sc_ctnl_pt_cfm_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_write_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); - uint8_t conidx = KE_IDX_GET(src_id); - // Message status - uint8_t msg_status = KE_MSG_CONSUMED; +__STATIC int gattc_write_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Get the address of the environment + struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); + uint8_t conidx = KE_IDX_GET(src_id); + // Message status + uint8_t msg_status = KE_MSG_CONSUMED; - // Check if a connection exists - if (rscps_env != NULL) + // Check if a connection exists + if (rscps_env != NULL) { + // RSC Measurement Characteristic, Client Characteristic Configuration + // Descriptor + if (param->handle == (RSCPS_HANDLE(RSCS_IDX_RSC_MEAS_NTF_CFG))) { + uint16_t ntf_cfg; + // Status + uint8_t status = PRF_ERR_INVALID_PARAM; + + // Get the value + co_write16p(&ntf_cfg, param->value[0]); + + // Check if the value is correct + if (ntf_cfg <= PRF_CLI_START_NTF) { + status = GAP_ERR_NO_ERROR; + + // Save the new configuration in the environment + if (ntf_cfg == PRF_CLI_STOP_NTFIND) { + RSCPS_DISABLE_NTFIND(conidx, RSCP_PRF_CFG_FLAG_RSC_MEAS_NTF); + } else // ntf_cfg == PRF_CLI_START_NTF + { + RSCPS_ENABLE_NTFIND(conidx, RSCP_PRF_CFG_FLAG_RSC_MEAS_NTF); + } + + // Inform the HL about the new configuration + struct rscps_cfg_ntfind_ind *ind = KE_MSG_ALLOC( + RSCPS_CFG_NTFIND_IND, prf_dst_task_get(&rscps_env->prf_env, conidx), + prf_src_task_get(&rscps_env->prf_env, conidx), + rscps_cfg_ntfind_ind); + + ind->char_code = RSCP_RSCS_RSC_MEAS_CHAR; + ind->ntf_cfg = ntf_cfg; + + ke_msg_send(ind); + + // Enable Bonded Data + RSCPS_ENABLE_NTFIND(conidx, RSCP_PRF_CFG_PERFORMED_OK); + } + // else status is RSCP_ERROR_CCC_INVALID_PARAM + + // Send the write response to the peer device + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = status; + ke_msg_send(cfm); + } else // Should be the SC Control Point Characteristic { - // RSC Measurement Characteristic, Client Characteristic Configuration Descriptor - if (param->handle == (RSCPS_HANDLE(RSCS_IDX_RSC_MEAS_NTF_CFG))) - { - uint16_t ntf_cfg; - // Status - uint8_t status = PRF_ERR_INVALID_PARAM; + if (RSCPS_IS_FEATURE_SUPPORTED(rscps_env->prf_cfg, + RSCPS_SC_CTNL_PT_MASK)) { + // SC Control Point, Client Characteristic Configuration Descriptor + if (param->handle == (RSCPS_HANDLE(RSCS_IDX_SC_CTNL_PT_NTF_CFG))) { + uint16_t ntf_cfg; + // Status + uint8_t status = PRF_ERR_INVALID_PARAM; - // Get the value - co_write16p(&ntf_cfg, param->value[0]); + // Get the value + co_write16p(&ntf_cfg, param->value[0]); - // Check if the value is correct - if (ntf_cfg <= PRF_CLI_START_NTF) + // Check if the value is correct + if ((ntf_cfg == PRF_CLI_STOP_NTFIND) || + (ntf_cfg == PRF_CLI_START_IND)) { + status = GAP_ERR_NO_ERROR; + + // Save the new configuration in the environment + if (ntf_cfg == PRF_CLI_STOP_NTFIND) { + RSCPS_DISABLE_NTFIND(conidx, RSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND); + } else // ntf_cfg == PRF_CLI_START_IND { - status = GAP_ERR_NO_ERROR; - - // Save the new configuration in the environment - if (ntf_cfg == PRF_CLI_STOP_NTFIND) - { - RSCPS_DISABLE_NTFIND(conidx, RSCP_PRF_CFG_FLAG_RSC_MEAS_NTF); - } - else // ntf_cfg == PRF_CLI_START_NTF - { - RSCPS_ENABLE_NTFIND(conidx, RSCP_PRF_CFG_FLAG_RSC_MEAS_NTF); - } - - // Inform the HL about the new configuration - struct rscps_cfg_ntfind_ind *ind = KE_MSG_ALLOC(RSCPS_CFG_NTFIND_IND, - prf_dst_task_get(&rscps_env->prf_env, conidx), - prf_src_task_get(&rscps_env->prf_env, conidx), - rscps_cfg_ntfind_ind); - - ind->char_code = RSCP_RSCS_RSC_MEAS_CHAR; - ind->ntf_cfg = ntf_cfg; - - ke_msg_send(ind); - - // Enable Bonded Data - RSCPS_ENABLE_NTFIND(conidx, RSCP_PRF_CFG_PERFORMED_OK); + RSCPS_ENABLE_NTFIND(conidx, RSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND); } - // else status is RSCP_ERROR_CCC_INVALID_PARAM - // Send the write response to the peer device - struct gattc_write_cfm *cfm = KE_MSG_ALLOC( - GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = status; - ke_msg_send(cfm); + // Inform the HL about the new configuration + struct rscps_cfg_ntfind_ind *ind = + KE_MSG_ALLOC(RSCPS_CFG_NTFIND_IND, + prf_dst_task_get(&rscps_env->prf_env, conidx), + prf_src_task_get(&rscps_env->prf_env, conidx), + rscps_cfg_ntfind_ind); + + ind->char_code = RSCP_RSCS_SC_CTNL_PT_CHAR; + ind->ntf_cfg = ntf_cfg; + + ke_msg_send(ind); + + // Enable Bonded Data + RSCPS_ENABLE_NTFIND(conidx, RSCP_PRF_CFG_PERFORMED_OK); + } + // else status is RSCP_ERROR_CCC_INVALID_PARAM + + // Send the write response to the peer device + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = status; + ke_msg_send(cfm); } - else // Should be the SC Control Point Characteristic - { - if (RSCPS_IS_FEATURE_SUPPORTED(rscps_env->prf_cfg, RSCPS_SC_CTNL_PT_MASK)) - { - // SC Control Point, Client Characteristic Configuration Descriptor - if (param->handle == (RSCPS_HANDLE(RSCS_IDX_SC_CTNL_PT_NTF_CFG))) - { - uint16_t ntf_cfg; - // Status - uint8_t status = PRF_ERR_INVALID_PARAM; + // SC Control Point Characteristic + else if (param->handle == (RSCPS_HANDLE(RSCS_IDX_SC_CTNL_PT_VAL))) { + // Write Response Status + uint8_t wr_status = ATT_ERR_NO_ERROR; + // Indication Status + uint8_t ind_status = RSCP_CTNL_PT_RESP_NOT_SUPP; - // Get the value - co_write16p(&ntf_cfg, param->value[0]); - - // Check if the value is correct - if ((ntf_cfg == PRF_CLI_STOP_NTFIND) || (ntf_cfg == PRF_CLI_START_IND)) - { - status = GAP_ERR_NO_ERROR; - - // Save the new configuration in the environment - if (ntf_cfg == PRF_CLI_STOP_NTFIND) - { - RSCPS_DISABLE_NTFIND(conidx, RSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND); - } - else // ntf_cfg == PRF_CLI_START_IND - { - RSCPS_ENABLE_NTFIND(conidx, RSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND); - } - - // Inform the HL about the new configuration - struct rscps_cfg_ntfind_ind *ind = KE_MSG_ALLOC(RSCPS_CFG_NTFIND_IND, - prf_dst_task_get(&rscps_env->prf_env, conidx), - prf_src_task_get(&rscps_env->prf_env, conidx), - rscps_cfg_ntfind_ind); - - ind->char_code = RSCP_RSCS_SC_CTNL_PT_CHAR; - ind->ntf_cfg = ntf_cfg; - - ke_msg_send(ind); - - // Enable Bonded Data - RSCPS_ENABLE_NTFIND(conidx, RSCP_PRF_CFG_PERFORMED_OK); - } - // else status is RSCP_ERROR_CCC_INVALID_PARAM - - // Send the write response to the peer device - struct gattc_write_cfm *cfm = KE_MSG_ALLOC( - GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = status; - ke_msg_send(cfm); - } - // SC Control Point Characteristic - else if (param->handle == (RSCPS_HANDLE(RSCS_IDX_SC_CTNL_PT_VAL))) - { - // Write Response Status - uint8_t wr_status = ATT_ERR_NO_ERROR; - // Indication Status - uint8_t ind_status = RSCP_CTNL_PT_RESP_NOT_SUPP; - - do - { - // Check if sending of indications has been enabled - if (!RSCPS_IS_NTFIND_ENABLED(conidx, RSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND)) - { - // CCC improperly configured - wr_status = RSCP_ERROR_CCC_INVALID_PARAM; - ind_status = RSCP_CTNL_PT_RESP_FAILED; - break; - } - - if ((rscps_env->operation >= RSCPS_CTNL_PT_CUMUL_VAL_OP_CODE) && - (rscps_env->operation <= RSCPS_CTNL_ERR_IND_OP_CODE)) - { - // A procedure is already in progress - wr_status = RSCP_ERROR_PROC_IN_PROGRESS; - ind_status = RSCP_CTNL_PT_RESP_FAILED; - break; - } - - if (rscps_env->operation == RSCPS_SEND_RSC_MEAS_OP_CODE) - { - // Keep the message until the end of the current procedure - msg_status = KE_MSG_SAVED; - break; - } - - // Allocate a request indication message for the application - struct rscps_sc_ctnl_pt_req_ind *req_ind = KE_MSG_ALLOC(RSCPS_SC_CTNL_PT_REQ_IND, - prf_dst_task_get(&rscps_env->prf_env, conidx), - prf_src_task_get(&rscps_env->prf_env, conidx), - rscps_sc_ctnl_pt_req_ind); - - // Operation Code - req_ind->op_code = param->value[0]; - // Connection index - req_ind->conidx = conidx; - - // Operation Code - switch(param->value[0]) - { - // Set Cumulative value - case (RSCP_CTNL_PT_OP_SET_CUMUL_VAL): - { - // Check if the Total Distance Measurement feature is supported - if (RSCPS_IS_FEATURE_SUPPORTED(rscps_env->features, RSCP_FEAT_TOTAL_DST_MEAS_SUPP)) - { - // The request can be handled - ind_status = RSCP_CTNL_PT_RESP_SUCCESS; - rscps_env->operation = RSCPS_CTNL_PT_CUMUL_VAL_OP_CODE; - - // Cumulative value - req_ind->value.cumul_value = co_read32p(¶m->value[1]); - } - } break; - - // Start Sensor calibration - case (RSCP_CTNL_PT_OP_START_CALIB): - { - // Check if the Calibration Procedure feature is supported - if (RSCPS_IS_FEATURE_SUPPORTED(rscps_env->features, RSCP_FEAT_CALIB_PROC_SUPP)) - { - // The request can be handled - ind_status = RSCP_CTNL_PT_RESP_SUCCESS; - - rscps_env->operation = RSCPS_CTNL_PT_START_CAL_OP_CODE; - } - } break; - - // Update sensor location - case (RSCP_CTNL_PT_OP_UPD_LOC): - { - // Check if the Multiple Sensor Location feature is supported - if (RSCPS_IS_FEATURE_SUPPORTED(rscps_env->features, RSCP_FEAT_MULT_SENSOR_LOC_SUPP)) - { - // Check the sensor location value - if (param->value[1] < RSCP_LOC_MAX) - { - // The request can be handled - ind_status = RSCP_CTNL_PT_RESP_SUCCESS; - - rscps_env->operation = RSCPS_CTNL_PT_UPD_LOC_OP_CODE; - - // Sensor Location - req_ind->value.sensor_loc = param->value[1]; - } - else - { - // Provided parameter in not within the defined range - ind_status = RSCP_CTNL_PT_RESP_INV_PARAM; - } - } - } break; - - // Request supported sensor locations - case (RSCP_CTNL_PT_OP_REQ_SUPP_LOC): - { - // Check if the Multiple Sensor Location feature is supported - if (RSCPS_IS_FEATURE_SUPPORTED(rscps_env->features, RSCP_FEAT_MULT_SENSOR_LOC_SUPP)) - { - // The request can be handled - ind_status = RSCP_CTNL_PT_RESP_SUCCESS; - - rscps_env->operation = RSCPS_CTNL_PT_SUPP_LOC_OP_CODE; - } - } break; - - default: - { - // Operation Code is invalid, status is already RSCP_CTNL_PT_RESP_NOT_SUPP - } break; - } - - // If no error raised, inform the application about the request - if (ind_status == RSCP_CTNL_PT_RESP_SUCCESS) - { - // Send the request indication to the application - ke_msg_send(req_ind); - // Go to the Busy status - ke_state_set(dest_id, RSCPS_BUSY); - // Align error code - wr_status = GAP_ERR_NO_ERROR; - } - else - { - // Free the allocated message - ke_msg_free(ke_param2msg(req_ind)); - } - } while (0); - - // Send the write response to the peer device - struct gattc_write_cfm *cfm = KE_MSG_ALLOC( - GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = wr_status; - ke_msg_send(cfm); - - // If error raised in control point, inform the peer - if ((ind_status != RSCP_CTNL_PT_RESP_SUCCESS) && - (param->handle == (RSCPS_HANDLE(RSCS_IDX_SC_CTNL_PT_VAL)))) - { - rscps_send_rsp_ind(conidx, param->value[0], ind_status); - } - } - else - { - ASSERT_ERR(0); - } + do { + // Check if sending of indications has been enabled + if (!RSCPS_IS_NTFIND_ENABLED(conidx, + RSCP_PRF_CFG_FLAG_SC_CTNL_PT_IND)) { + // CCC improperly configured + wr_status = RSCP_ERROR_CCC_INVALID_PARAM; + ind_status = RSCP_CTNL_PT_RESP_FAILED; + break; } + + if ((rscps_env->operation >= RSCPS_CTNL_PT_CUMUL_VAL_OP_CODE) && + (rscps_env->operation <= RSCPS_CTNL_ERR_IND_OP_CODE)) { + // A procedure is already in progress + wr_status = RSCP_ERROR_PROC_IN_PROGRESS; + ind_status = RSCP_CTNL_PT_RESP_FAILED; + break; + } + + if (rscps_env->operation == RSCPS_SEND_RSC_MEAS_OP_CODE) { + // Keep the message until the end of the current procedure + msg_status = KE_MSG_SAVED; + break; + } + + // Allocate a request indication message for the application + struct rscps_sc_ctnl_pt_req_ind *req_ind = + KE_MSG_ALLOC(RSCPS_SC_CTNL_PT_REQ_IND, + prf_dst_task_get(&rscps_env->prf_env, conidx), + prf_src_task_get(&rscps_env->prf_env, conidx), + rscps_sc_ctnl_pt_req_ind); + + // Operation Code + req_ind->op_code = param->value[0]; + // Connection index + req_ind->conidx = conidx; + + // Operation Code + switch (param->value[0]) { + // Set Cumulative value + case (RSCP_CTNL_PT_OP_SET_CUMUL_VAL): { + // Check if the Total Distance Measurement feature is supported + if (RSCPS_IS_FEATURE_SUPPORTED(rscps_env->features, + RSCP_FEAT_TOTAL_DST_MEAS_SUPP)) { + // The request can be handled + ind_status = RSCP_CTNL_PT_RESP_SUCCESS; + rscps_env->operation = RSCPS_CTNL_PT_CUMUL_VAL_OP_CODE; + + // Cumulative value + req_ind->value.cumul_value = co_read32p(¶m->value[1]); + } + } break; + + // Start Sensor calibration + case (RSCP_CTNL_PT_OP_START_CALIB): { + // Check if the Calibration Procedure feature is supported + if (RSCPS_IS_FEATURE_SUPPORTED(rscps_env->features, + RSCP_FEAT_CALIB_PROC_SUPP)) { + // The request can be handled + ind_status = RSCP_CTNL_PT_RESP_SUCCESS; + + rscps_env->operation = RSCPS_CTNL_PT_START_CAL_OP_CODE; + } + } break; + + // Update sensor location + case (RSCP_CTNL_PT_OP_UPD_LOC): { + // Check if the Multiple Sensor Location feature is supported + if (RSCPS_IS_FEATURE_SUPPORTED(rscps_env->features, + RSCP_FEAT_MULT_SENSOR_LOC_SUPP)) { + // Check the sensor location value + if (param->value[1] < RSCP_LOC_MAX) { + // The request can be handled + ind_status = RSCP_CTNL_PT_RESP_SUCCESS; + + rscps_env->operation = RSCPS_CTNL_PT_UPD_LOC_OP_CODE; + + // Sensor Location + req_ind->value.sensor_loc = param->value[1]; + } else { + // Provided parameter in not within the defined range + ind_status = RSCP_CTNL_PT_RESP_INV_PARAM; + } + } + } break; + + // Request supported sensor locations + case (RSCP_CTNL_PT_OP_REQ_SUPP_LOC): { + // Check if the Multiple Sensor Location feature is supported + if (RSCPS_IS_FEATURE_SUPPORTED(rscps_env->features, + RSCP_FEAT_MULT_SENSOR_LOC_SUPP)) { + // The request can be handled + ind_status = RSCP_CTNL_PT_RESP_SUCCESS; + + rscps_env->operation = RSCPS_CTNL_PT_SUPP_LOC_OP_CODE; + } + } break; + + default: { + // Operation Code is invalid, status is already + // RSCP_CTNL_PT_RESP_NOT_SUPP + } break; + } + + // If no error raised, inform the application about the request + if (ind_status == RSCP_CTNL_PT_RESP_SUCCESS) { + // Send the request indication to the application + ke_msg_send(req_ind); + // Go to the Busy status + ke_state_set(dest_id, RSCPS_BUSY); + // Align error code + wr_status = GAP_ERR_NO_ERROR; + } else { + // Free the allocated message + ke_msg_free(ke_param2msg(req_ind)); + } + } while (0); + + // Send the write response to the peer device + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = wr_status; + ke_msg_send(cfm); + + // If error raised in control point, inform the peer + if ((ind_status != RSCP_CTNL_PT_RESP_SUCCESS) && + (param->handle == (RSCPS_HANDLE(RSCS_IDX_SC_CTNL_PT_VAL)))) { + rscps_send_rsp_ind(conidx, param->value[0], ind_status); + } + } else { + ASSERT_ERR(0); } + } } - // else drop the message + } + // else drop the message - return (int)msg_status; + return (int)msg_status; } /** **************************************************************************************** - * @brief Handles @ref GATT_NOTIFY_CMP_EVT message meaning that a notification or an indication - * has been correctly sent to peer device (but not confirmed by peer device). + * @brief Handles @ref GATT_NOTIFY_CMP_EVT message meaning that a notification + *or an indication has been correctly sent to peer device (but not confirmed by + *peer device). * * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. @@ -751,45 +699,40 @@ __STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - uint8_t conidx = KE_IDX_GET(src_id); - // Get the address of the environment - struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); +__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t conidx = KE_IDX_GET(src_id); + // Get the address of the environment + struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); - // Check if a connection exists - if (ke_state_get(dest_id) == RSCPS_BUSY) - { - switch (param->operation) - { - case (GATTC_NOTIFY): - { - ASSERT_ERR(rscps_env->operation == RSCPS_SEND_RSC_MEAS_OP_CODE); - // continuer operation execution - rscps_exe_operation(); - } break; + // Check if a connection exists + if (ke_state_get(dest_id) == RSCPS_BUSY) { + switch (param->operation) { + case (GATTC_NOTIFY): { + ASSERT_ERR(rscps_env->operation == RSCPS_SEND_RSC_MEAS_OP_CODE); + // continuer operation execution + rscps_exe_operation(); + } break; - case (GATTC_INDICATE): - { - ASSERT_ERR((rscps_env->operation >= RSCPS_CTNL_PT_CUMUL_VAL_OP_CODE) || - (rscps_env->operation != RSCPS_CTNL_ERR_IND_OP_CODE)); + case (GATTC_INDICATE): { + ASSERT_ERR((rscps_env->operation >= RSCPS_CTNL_PT_CUMUL_VAL_OP_CODE) || + (rscps_env->operation != RSCPS_CTNL_ERR_IND_OP_CODE)); - // Inform the application that a procedure has been completed - rscps_send_cmp_evt(conidx, - prf_src_task_get(&rscps_env->prf_env, conidx), - prf_dst_task_get(&rscps_env->prf_env, conidx), - rscps_env->operation, param->status); - } break; + // Inform the application that a procedure has been completed + rscps_send_cmp_evt(conidx, prf_src_task_get(&rscps_env->prf_env, conidx), + prf_dst_task_get(&rscps_env->prf_env, conidx), + rscps_env->operation, param->status); + } break; - default: - { - ASSERT_ERR(0); - } break; - } + default: { + ASSERT_ERR(0); + } break; } + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /* @@ -798,26 +741,24 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_ev */ /// Specifies the default message handlers -KE_MSG_HANDLER_TAB(rscps) -{ - {RSCPS_ENABLE_REQ, (ke_msg_func_t) rscps_enable_req_handler}, - {GATTC_READ_REQ_IND, (ke_msg_func_t) gattc_read_req_ind_handler}, - {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t) gattc_att_info_req_ind_handler}, - {RSCPS_NTF_RSC_MEAS_REQ, (ke_msg_func_t) rscps_ntf_rsc_meas_req_handler}, - {RSCPS_SC_CTNL_PT_CFM, (ke_msg_func_t) rscps_sc_ctnl_pt_cfm_handler}, - {GATTC_WRITE_REQ_IND, (ke_msg_func_t) gattc_write_req_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t) gattc_cmp_evt_handler}, +KE_MSG_HANDLER_TAB(rscps){ + {RSCPS_ENABLE_REQ, (ke_msg_func_t)rscps_enable_req_handler}, + {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, + {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t)gattc_att_info_req_ind_handler}, + {RSCPS_NTF_RSC_MEAS_REQ, (ke_msg_func_t)rscps_ntf_rsc_meas_req_handler}, + {RSCPS_SC_CTNL_PT_CFM, (ke_msg_func_t)rscps_sc_ctnl_pt_cfm_handler}, + {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void rscps_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); +void rscps_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct rscps_env_tag *rscps_env = PRF_ENV_GET(RSCPS, rscps); - task_desc->msg_handler_tab = rscps_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(rscps_msg_handler_tab); - task_desc->state = rscps_env->state; - task_desc->idx_max = RSCPS_IDX_MAX; + task_desc->msg_handler_tab = rscps_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(rscps_msg_handler_tab); + task_desc->state = rscps_env->state; + task_desc->idx_max = RSCPS_IDX_MAX; } #endif //(BLE_RSC_SENSOR) diff --git a/services/ble_profiles/tip/tipc/src/tipc.c b/services/ble_profiles/tip/tipc/src/tipc.c index ed8e61f..0315dfc 100644 --- a/services/ble_profiles/tip/tipc/src/tipc.c +++ b/services/ble_profiles/tip/tipc/src/tipc.c @@ -12,10 +12,10 @@ #include "rwip_config.h" #if (BLE_TIP_CLIENT) +#include "gap.h" #include "prf.h" #include "tipc.h" #include "tipc_task.h" -#include "gap.h" #include "ke_mem.h" @@ -31,41 +31,45 @@ * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t tipc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t idx; - //-------------------- allocate memory required for the profile --------------------- +static uint8_t tipc_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t idx; + //-------------------- allocate memory required for the profile + //--------------------- - struct tipc_env_tag* tipc_env = - (struct tipc_env_tag* ) ke_malloc(sizeof(struct tipc_env_tag), KE_MEM_ATT_DB); + struct tipc_env_tag *tipc_env = (struct tipc_env_tag *)ke_malloc( + sizeof(struct tipc_env_tag), KE_MEM_ATT_DB); - // allocate TIPC required environment variable - env->env = (prf_env_t*) tipc_env; + // allocate TIPC required environment variable + env->env = (prf_env_t *)tipc_env; - tipc_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - tipc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + tipc_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + tipc_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - // initialize environment variable - env->id = TASK_ID_TIPC; - tipc_task_init(&(env->desc)); + // initialize environment variable + env->id = TASK_ID_TIPC; + tipc_task_init(&(env->desc)); - for(idx = 0; idx < TIPC_IDX_MAX ; idx++) - { - tipc_env->env[idx] = NULL; - // service is ready, go into an Idle state - ke_state_set(KE_BUILD_ID(env->task, idx), TIPC_FREE); - } + for (idx = 0; idx < TIPC_IDX_MAX; idx++) { + tipc_env->env[idx] = NULL; + // service is ready, go into an Idle state + ke_state_set(KE_BUILD_ID(env->task, idx), TIPC_FREE); + } - return GAP_ERR_NO_ERROR; + return GAP_ERR_NO_ERROR; } /** @@ -77,44 +81,41 @@ static uint8_t tipc_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t * @param[in] reason Detach reason **************************************************************************************** */ -static void tipc_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct tipc_env_tag* tipc_env = (struct tipc_env_tag*) env->env; +static void tipc_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct tipc_env_tag *tipc_env = (struct tipc_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(tipc_env->env[conidx] != NULL) - { - ke_free(tipc_env->env[conidx]); - tipc_env->env[conidx] = NULL; - } + // clean-up environment variable allocated for task instance + if (tipc_env->env[conidx] != NULL) { + ke_free(tipc_env->env[conidx]); + tipc_env->env[conidx] = NULL; + } - /* Put TIP Client in Free state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), TIPC_FREE); + /* Put TIP Client in Free state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), TIPC_FREE); } /** **************************************************************************************** * @brief Destruction of the TIPC module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void tipc_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct tipc_env_tag* tipc_env = (struct tipc_env_tag*) env->env; +static void tipc_destroy(struct prf_task_env *env) { + uint8_t idx; + struct tipc_env_tag *tipc_env = (struct tipc_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < TIPC_IDX_MAX ; idx++) - { - tipc_cleanup(env, idx, 0); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < TIPC_IDX_MAX; idx++) { + tipc_cleanup(env, idx, 0); + } - // free profile environment variables - env->env = NULL; - ke_free(tipc_env); + // free profile environment variables + env->env = NULL; + ke_free(tipc_env); } /** @@ -125,19 +126,17 @@ static void tipc_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void tipc_create(struct prf_task_env* env, uint8_t conidx) -{ - /* Put TIP Client in Idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), TIPC_IDLE); +static void tipc_create(struct prf_task_env *env, uint8_t conidx) { + /* Put TIP Client in Idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), TIPC_IDLE); } /// TIPC Task interface required by profile manager -const struct prf_task_cbs tipc_itf = -{ - tipc_init, - tipc_destroy, - tipc_create, - tipc_cleanup, +const struct prf_task_cbs tipc_itf = { + tipc_init, + tipc_destroy, + tipc_create, + tipc_cleanup, }; /* @@ -145,64 +144,60 @@ const struct prf_task_cbs tipc_itf = **************************************************************************************** */ -const struct prf_task_cbs* tipc_prf_itf_get(void) -{ - return &tipc_itf; -} +const struct prf_task_cbs *tipc_prf_itf_get(void) { return &tipc_itf; } /* * EXPORTED FUNCTIONS DEFINITIONS **************************************************************************************** */ -void tipc_enable_rsp_send(struct tipc_env_tag *tipc_env, uint8_t conidx, uint8_t status) -{ - // Send to APP the details of the discovered attributes on TIPS - struct tipc_enable_rsp * rsp = KE_MSG_ALLOC(TIPC_ENABLE_RSP, - prf_dst_task_get(&(tipc_env->prf_env), conidx), - prf_src_task_get(&(tipc_env->prf_env), conidx), - tipc_enable_rsp); +void tipc_enable_rsp_send(struct tipc_env_tag *tipc_env, uint8_t conidx, + uint8_t status) { + // Send to APP the details of the discovered attributes on TIPS + struct tipc_enable_rsp *rsp = KE_MSG_ALLOC( + TIPC_ENABLE_RSP, prf_dst_task_get(&(tipc_env->prf_env), conidx), + prf_src_task_get(&(tipc_env->prf_env), conidx), tipc_enable_rsp); - rsp->status = status; + rsp->status = status; - if (status == GAP_ERR_NO_ERROR) - { - rsp->cts = tipc_env->env[conidx]->cts; - rsp->ndcs = tipc_env->env[conidx]->ndcs; - rsp->rtus = tipc_env->env[conidx]->rtus; + if (status == GAP_ERR_NO_ERROR) { + rsp->cts = tipc_env->env[conidx]->cts; + rsp->ndcs = tipc_env->env[conidx]->ndcs; + rsp->rtus = tipc_env->env[conidx]->rtus; - //register TIPC task in gatt for indication/notifications - prf_register_atthdl2gatt(&tipc_env->prf_env, conidx, &tipc_env->env[conidx]->cts.svc); + // register TIPC task in gatt for indication/notifications + prf_register_atthdl2gatt(&tipc_env->prf_env, conidx, + &tipc_env->env[conidx]->cts.svc); - // Go to connected state - ke_state_set(prf_src_task_get(&tipc_env->prf_env, conidx), TIPC_IDLE); - } + // Go to connected state + ke_state_set(prf_src_task_get(&tipc_env->prf_env, conidx), TIPC_IDLE); + } - ke_msg_send(rsp); + ke_msg_send(rsp); } -void tipc_unpack_curr_time_value(struct tip_curr_time* p_curr_time_val, uint8_t* packed_ct) -{ - //Date-Time - prf_unpack_date_time(packed_ct, &(p_curr_time_val->date_time)); +void tipc_unpack_curr_time_value(struct tip_curr_time *p_curr_time_val, + uint8_t *packed_ct) { + // Date-Time + prf_unpack_date_time(packed_ct, &(p_curr_time_val->date_time)); - //Day of Week - p_curr_time_val->day_of_week = packed_ct[7]; + // Day of Week + p_curr_time_val->day_of_week = packed_ct[7]; - //Fraction 256 - p_curr_time_val->fraction_256 = packed_ct[8]; + // Fraction 256 + p_curr_time_val->fraction_256 = packed_ct[8]; - //Adjust Reason - p_curr_time_val->adjust_reason = packed_ct[9]; + // Adjust Reason + p_curr_time_val->adjust_reason = packed_ct[9]; } -void tipc_unpack_time_dst_value(struct tip_time_with_dst* p_time_dst_val, uint8_t* packed_tdst) -{ - //Date-Time - prf_unpack_date_time(packed_tdst, &(p_time_dst_val->date_time)); +void tipc_unpack_time_dst_value(struct tip_time_with_dst *p_time_dst_val, + uint8_t *packed_tdst) { + // Date-Time + prf_unpack_date_time(packed_tdst, &(p_time_dst_val->date_time)); - //DST Offset - p_time_dst_val->dst_offset = packed_tdst[7]; + // DST Offset + p_time_dst_val->dst_offset = packed_tdst[7]; } #endif /* (BLE_TIP_CLIENT) */ diff --git a/services/ble_profiles/tip/tipc/src/tipc_task.c b/services/ble_profiles/tip/tipc/src/tipc_task.c index fc44e84..c1ca59e 100644 --- a/services/ble_profiles/tip/tipc/src/tipc_task.c +++ b/services/ble_profiles/tip/tipc/src/tipc_task.c @@ -13,12 +13,12 @@ #include "rwip_config.h" #if (BLE_TIP_CLIENT) -#include "co_utils.h" -#include "tipc_task.h" -#include "tipc.h" -#include "gap.h" #include "attm.h" +#include "co_utils.h" +#include "gap.h" #include "gattc_task.h" +#include "tipc.h" +#include "tipc_task.h" #include "ke_mem.h" /* @@ -26,62 +26,54 @@ **************************************************************************************** */ - - /* * DEFINES **************************************************************************************** */ -/// State machine used to retrieve Current Time service characteristics information -const struct prf_char_def tipc_cts_char[TIPC_CHAR_CTS_MAX] = -{ +/// State machine used to retrieve Current Time service characteristics +/// information +const struct prf_char_def tipc_cts_char[TIPC_CHAR_CTS_MAX] = { /// Current Time - [TIPC_CHAR_CTS_CURR_TIME] = {ATT_CHAR_CT_TIME, - ATT_MANDATORY, - ATT_CHAR_PROP_RD|ATT_CHAR_PROP_NTF}, + [TIPC_CHAR_CTS_CURR_TIME] = {ATT_CHAR_CT_TIME, ATT_MANDATORY, + ATT_CHAR_PROP_RD | ATT_CHAR_PROP_NTF}, /// Local Time Info - [TIPC_CHAR_CTS_LOCAL_TIME_INFO] = {ATT_CHAR_LOCAL_TIME_INFO, - ATT_OPTIONAL, - ATT_CHAR_PROP_RD}, + [TIPC_CHAR_CTS_LOCAL_TIME_INFO] = {ATT_CHAR_LOCAL_TIME_INFO, ATT_OPTIONAL, + ATT_CHAR_PROP_RD}, /// Reference Time Info - [TIPC_CHAR_CTS_REF_TIME_INFO] = {ATT_CHAR_REFERENCE_TIME_INFO, - ATT_OPTIONAL, - ATT_CHAR_PROP_RD}, + [TIPC_CHAR_CTS_REF_TIME_INFO] = {ATT_CHAR_REFERENCE_TIME_INFO, ATT_OPTIONAL, + ATT_CHAR_PROP_RD}, }; -/// State machine used to retrieve Current Time service characteristic description information -const struct prf_char_desc_def tipc_cts_char_desc[TIPC_DESC_CTS_MAX] = -{ +/// State machine used to retrieve Current Time service characteristic +/// description information +const struct prf_char_desc_def tipc_cts_char_desc[TIPC_DESC_CTS_MAX] = { /// Current Time client config [TIPC_DESC_CTS_CURR_TIME_CLI_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, ATT_MANDATORY, TIPC_CHAR_CTS_CURR_TIME}, }; -/// State machine used to retrieve Next DST Change service characteristics information -const struct prf_char_def tipc_ndcs_char[TIPC_CHAR_NDCS_MAX] = -{ +/// State machine used to retrieve Next DST Change service characteristics +/// information +const struct prf_char_def tipc_ndcs_char[TIPC_CHAR_NDCS_MAX] = { /// Current Time - [TIPC_CHAR_NDCS_TIME_WITH_DST] = {ATT_CHAR_TIME_WITH_DST, - ATT_MANDATORY, - ATT_CHAR_PROP_RD}, + [TIPC_CHAR_NDCS_TIME_WITH_DST] = {ATT_CHAR_TIME_WITH_DST, ATT_MANDATORY, + ATT_CHAR_PROP_RD}, }; -/// State machine used to retrieve Reference Time Update service characteristics information -const struct prf_char_def tipc_rtus_char[TIPC_CHAR_RTUS_MAX] = -{ +/// State machine used to retrieve Reference Time Update service characteristics +/// information +const struct prf_char_def tipc_rtus_char[TIPC_CHAR_RTUS_MAX] = { /// Time Update Control Point - [TIPC_CHAR_RTUS_TIME_UPD_CTNL_PT] = {ATT_CHAR_TIME_UPDATE_CNTL_POINT, - ATT_MANDATORY, - ATT_CHAR_PROP_WR_NO_RESP}, + [TIPC_CHAR_RTUS_TIME_UPD_CTNL_PT] = {ATT_CHAR_TIME_UPDATE_CNTL_POINT, + ATT_MANDATORY, + ATT_CHAR_PROP_WR_NO_RESP}, /// Time Update State - [TIPC_CHAR_RTUS_TIME_UPD_STATE] = {ATT_CHAR_TIME_UPDATE_STATE, - ATT_MANDATORY, - ATT_CHAR_PROP_RD}, + [TIPC_CHAR_RTUS_TIME_UPD_STATE] = {ATT_CHAR_TIME_UPDATE_STATE, + ATT_MANDATORY, ATT_CHAR_PROP_RD}, }; - /* * LOCAL FUNCTIONS DEFINITIONS **************************************************************************************** @@ -99,59 +91,61 @@ const struct prf_char_def tipc_rtus_char[TIPC_CHAR_RTUS_MAX] = **************************************************************************************** */ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, - struct gattc_sdp_svc_ind const *ind, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); + struct gattc_sdp_svc_ind const *ind, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); - if(state == TIPC_DISCOVERING) - { - uint8_t conidx = KE_IDX_GET(dest_id); + if (state == TIPC_DISCOVERING) { + uint8_t conidx = KE_IDX_GET(dest_id); - struct tipc_env_tag *tipc_env = PRF_ENV_GET(TIPC, tipc); + struct tipc_env_tag *tipc_env = PRF_ENV_GET(TIPC, tipc); - ASSERT_INFO(tipc_env != NULL, dest_id, src_id); - ASSERT_INFO(tipc_env->env[conidx] != NULL, dest_id, src_id); + ASSERT_INFO(tipc_env != NULL, dest_id, src_id); + ASSERT_INFO(tipc_env->env[conidx] != NULL, dest_id, src_id); - if(attm_uuid16_comp((unsigned char *)ind->uuid, ind->uuid_len, ATT_SVC_CURRENT_TIME)) - { - // Retrieve TIS characteristics and descriptors - prf_extract_svc_info(ind, TIPC_CHAR_CTS_MAX, &tipc_cts_char[0], &tipc_env->env[conidx]->cts.chars[0], - TIPC_DESC_CTS_MAX, &tipc_cts_char_desc[0], &tipc_env->env[conidx]->cts.descs[0]); + if (attm_uuid16_comp((unsigned char *)ind->uuid, ind->uuid_len, + ATT_SVC_CURRENT_TIME)) { + // Retrieve TIS characteristics and descriptors + prf_extract_svc_info(ind, TIPC_CHAR_CTS_MAX, &tipc_cts_char[0], + &tipc_env->env[conidx]->cts.chars[0], + TIPC_DESC_CTS_MAX, &tipc_cts_char_desc[0], + &tipc_env->env[conidx]->cts.descs[0]); - //Even if we get multiple responses we only store 1 range - tipc_env->env[conidx]->cts.svc.shdl = ind->start_hdl; - tipc_env->env[conidx]->cts.svc.ehdl = ind->end_hdl; - } - - if(attm_uuid16_comp((unsigned char *)ind->uuid, ind->uuid_len, ATT_SVC_NEXT_DST_CHANGE)) - { - // Retrieve NDCS characteristics and descriptors - prf_extract_svc_info(ind, TIPC_CHAR_NDCS_MAX, &tipc_ndcs_char[0], &tipc_env->env[conidx]->ndcs.chars[0], - 0, NULL, NULL); - - //Even if we get multiple responses we only store 1 range - tipc_env->env[conidx]->ndcs.svc.shdl = ind->start_hdl; - tipc_env->env[conidx]->ndcs.svc.ehdl = ind->end_hdl; - } - - if(attm_uuid16_comp((unsigned char *)ind->uuid, ind->uuid_len, ATT_SVC_REF_TIME_UPDATE)) - { - // Retrieve RTUS characteristics and descriptors - prf_extract_svc_info(ind, TIPC_CHAR_RTUS_MAX, &tipc_rtus_char[0], &tipc_env->env[conidx]->rtus.chars[0], - 0, NULL, NULL); - - //Even if we get multiple responses we only store 1 range - tipc_env->env[conidx]->rtus.svc.shdl = ind->start_hdl; - tipc_env->env[conidx]->rtus.svc.ehdl = ind->end_hdl; - } - - // Increment number of services - tipc_env->env[conidx]->nb_svc++; + // Even if we get multiple responses we only store 1 range + tipc_env->env[conidx]->cts.svc.shdl = ind->start_hdl; + tipc_env->env[conidx]->cts.svc.ehdl = ind->end_hdl; } - return (KE_MSG_CONSUMED); + if (attm_uuid16_comp((unsigned char *)ind->uuid, ind->uuid_len, + ATT_SVC_NEXT_DST_CHANGE)) { + // Retrieve NDCS characteristics and descriptors + prf_extract_svc_info(ind, TIPC_CHAR_NDCS_MAX, &tipc_ndcs_char[0], + &tipc_env->env[conidx]->ndcs.chars[0], 0, NULL, + NULL); + + // Even if we get multiple responses we only store 1 range + tipc_env->env[conidx]->ndcs.svc.shdl = ind->start_hdl; + tipc_env->env[conidx]->ndcs.svc.ehdl = ind->end_hdl; + } + + if (attm_uuid16_comp((unsigned char *)ind->uuid, ind->uuid_len, + ATT_SVC_REF_TIME_UPDATE)) { + // Retrieve RTUS characteristics and descriptors + prf_extract_svc_info(ind, TIPC_CHAR_RTUS_MAX, &tipc_rtus_char[0], + &tipc_env->env[conidx]->rtus.chars[0], 0, NULL, + NULL); + + // Even if we get multiple responses we only store 1 range + tipc_env->env[conidx]->rtus.svc.shdl = ind->start_hdl; + tipc_env->env[conidx]->rtus.svc.ehdl = ind->end_hdl; + } + + // Increment number of services + tipc_env->env[conidx]->nb_svc++; + } + + return (KE_MSG_CONSUMED); } /** @@ -166,70 +160,65 @@ __STATIC int gattc_sdp_svc_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int tipc_enable_req_handler(ke_msg_id_t const msgid, - struct tipc_enable_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); - // Get state - uint8_t state = ke_state_get(dest_id); + struct tipc_enable_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); + // Get state + uint8_t state = ke_state_get(dest_id); - // Time Service Client Role Task Environment - struct tipc_env_tag *tipc_env = PRF_ENV_GET(TIPC, tipc); + // Time Service Client Role Task Environment + struct tipc_env_tag *tipc_env = PRF_ENV_GET(TIPC, tipc); - ASSERT_INFO(tipc_env != NULL, dest_id, src_id); - if ((state == TIPC_IDLE) && (tipc_env->env[conidx] == NULL)) - { - // allocate environment variable for task instance - tipc_env->env[conidx] = (struct tipc_cnx_env*) ke_malloc(sizeof(struct tipc_cnx_env),KE_MEM_ATT_DB); - memset(tipc_env->env[conidx], 0, sizeof(struct tipc_cnx_env)); + ASSERT_INFO(tipc_env != NULL, dest_id, src_id); + if ((state == TIPC_IDLE) && (tipc_env->env[conidx] == NULL)) { + // allocate environment variable for task instance + tipc_env->env[conidx] = (struct tipc_cnx_env *)ke_malloc( + sizeof(struct tipc_cnx_env), KE_MEM_ATT_DB); + memset(tipc_env->env[conidx], 0, sizeof(struct tipc_cnx_env)); - //config connection, start discovering - if(param->con_type == PRF_CON_DISCOVERY) - { - //start discovering CTS on peer - prf_disc_svc_send(&(tipc_env->prf_env), conidx, ATT_SVC_CURRENT_TIME); + // config connection, start discovering + if (param->con_type == PRF_CON_DISCOVERY) { + // start discovering CTS on peer + prf_disc_svc_send(&(tipc_env->prf_env), conidx, ATT_SVC_CURRENT_TIME); - tipc_env->env[conidx]->last_uuid_req = ATT_SVC_CURRENT_TIME; - tipc_env->env[conidx]->last_svc_req = ATT_SVC_CURRENT_TIME; + tipc_env->env[conidx]->last_uuid_req = ATT_SVC_CURRENT_TIME; + tipc_env->env[conidx]->last_svc_req = ATT_SVC_CURRENT_TIME; - // Go to DISCOVERING state - ke_state_set(dest_id, TIPC_DISCOVERING); - } - //normal connection, get saved att details - else - { - tipc_env->env[conidx]->cts = param->cts; - tipc_env->env[conidx]->ndcs = param->ndcs; - tipc_env->env[conidx]->rtus = param->rtus; - - //send APP confirmation that can start normal connection - tipc_enable_rsp_send(tipc_env, conidx, GAP_ERR_NO_ERROR); - } + // Go to DISCOVERING state + ke_state_set(dest_id, TIPC_DISCOVERING); } + // normal connection, get saved att details + else { + tipc_env->env[conidx]->cts = param->cts; + tipc_env->env[conidx]->ndcs = param->ndcs; + tipc_env->env[conidx]->rtus = param->rtus; - else if(state != TIPC_FREE) - { - status = PRF_ERR_REQ_DISALLOWED; + // send APP confirmation that can start normal connection + tipc_enable_rsp_send(tipc_env, conidx, GAP_ERR_NO_ERROR); } + } - // send an error if request fails - if(status != GAP_ERR_NO_ERROR) - { - tipc_enable_rsp_send(tipc_env, conidx, status); - } + else if (state != TIPC_FREE) { + status = PRF_ERR_REQ_DISALLOWED; + } - return (KE_MSG_CONSUMED); + // send an error if request fails + if (status != GAP_ERR_NO_ERROR) { + tipc_enable_rsp_send(tipc_env, conidx, status); + } + + return (KE_MSG_CONSUMED); } /** **************************************************************************************** * @brief Handles reception of the @ref TIPC_RD_CHAR_REQ message. - * Check if the handle exists in profile(already discovered) and send request, otherwise - * error to APP. + * Check if the handle exists in profile(already discovered) and send request, + *otherwise error to APP. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -238,104 +227,93 @@ __STATIC int tipc_enable_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int tipc_rd_char_req_handler(ke_msg_id_t const msgid, - struct tipc_rd_char_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ + struct tipc_rd_char_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { - uint8_t state = ke_state_get(dest_id); - uint8_t status = GAP_ERR_NO_ERROR; + uint8_t state = ke_state_get(dest_id); + uint8_t status = GAP_ERR_NO_ERROR; - // Get the address of the environment - struct tipc_env_tag *tipc_env = PRF_ENV_GET(TIPC, tipc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); + // Get the address of the environment + struct tipc_env_tag *tipc_env = PRF_ENV_GET(TIPC, tipc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); - if((state == TIPC_IDLE) && (tipc_env->env[conidx] != NULL)) - { - // Service - struct prf_svc *svc = NULL; - // Attribute Handle - uint16_t search_hdl = ATT_INVALID_SEARCH_HANDLE; + if ((state == TIPC_IDLE) && (tipc_env->env[conidx] != NULL)) { + // Service + struct prf_svc *svc = NULL; + // Attribute Handle + uint16_t search_hdl = ATT_INVALID_SEARCH_HANDLE; - //Next DST Change Service Characteristic - if (((param->char_code & TIPC_CHAR_NDCS_MASK) == TIPC_CHAR_NDCS_MASK) && - ((param->char_code & ~TIPC_CHAR_NDCS_MASK) < TIPC_CHAR_NDCS_MAX)) - { - svc = &tipc_env->env[conidx]->ndcs.svc; - search_hdl = tipc_env->env[conidx]->ndcs. - chars[param->char_code & ~TIPC_CHAR_NDCS_MASK].val_hdl; - } - //Reference Time Update Service Characteristic - else if (((param->char_code & TIPC_CHAR_RTUS_MASK) == TIPC_CHAR_RTUS_MASK) && - ((param->char_code & ~TIPC_CHAR_RTUS_MASK) < TIPC_CHAR_RTUS_MAX)) - { - svc = &tipc_env->env[conidx]->rtus.svc; - search_hdl = tipc_env->env[conidx]->rtus. - chars[param->char_code & ~TIPC_CHAR_RTUS_MASK].val_hdl; - } - else - { - svc = &tipc_env->env[conidx]->cts.svc; - - //Current Time Characteristic Descriptor - if (((param->char_code & TIPC_DESC_CTS_MASK) == TIPC_DESC_CTS_MASK) && - ((param->char_code & ~TIPC_DESC_CTS_MASK) < TIPC_DESC_CTS_MAX)) - { - search_hdl = tipc_env->env[conidx]->cts. - descs[param->char_code & ~TIPC_DESC_CTS_MASK].desc_hdl; - } - //Current Time Service Characteristic - else if (param->char_code < TIPC_CHAR_CTS_MAX) - { - search_hdl = tipc_env->env[conidx]->cts. - chars[param->char_code].val_hdl; - } - } - - // Check if handle is viable - if ((search_hdl != ATT_INVALID_SEARCH_HANDLE) && (svc != NULL)) - { - // Save char code - tipc_env->env[conidx]->last_char_code = param->char_code; - // Send read request - prf_read_char_send(&(tipc_env->prf_env), conidx, svc->shdl, svc->ehdl, search_hdl); - } - else - { - status = PRF_ERR_INEXISTENT_HDL; - } + // Next DST Change Service Characteristic + if (((param->char_code & TIPC_CHAR_NDCS_MASK) == TIPC_CHAR_NDCS_MASK) && + ((param->char_code & ~TIPC_CHAR_NDCS_MASK) < TIPC_CHAR_NDCS_MAX)) { + svc = &tipc_env->env[conidx]->ndcs.svc; + search_hdl = tipc_env->env[conidx] + ->ndcs.chars[param->char_code & ~TIPC_CHAR_NDCS_MASK] + .val_hdl; } - else - { - status = PRF_ERR_REQ_DISALLOWED; + // Reference Time Update Service Characteristic + else if (((param->char_code & TIPC_CHAR_RTUS_MASK) == + TIPC_CHAR_RTUS_MASK) && + ((param->char_code & ~TIPC_CHAR_RTUS_MASK) < TIPC_CHAR_RTUS_MAX)) { + svc = &tipc_env->env[conidx]->rtus.svc; + search_hdl = tipc_env->env[conidx] + ->rtus.chars[param->char_code & ~TIPC_CHAR_RTUS_MASK] + .val_hdl; + } else { + svc = &tipc_env->env[conidx]->cts.svc; + + // Current Time Characteristic Descriptor + if (((param->char_code & TIPC_DESC_CTS_MASK) == TIPC_DESC_CTS_MASK) && + ((param->char_code & ~TIPC_DESC_CTS_MASK) < TIPC_DESC_CTS_MAX)) { + search_hdl = tipc_env->env[conidx] + ->cts.descs[param->char_code & ~TIPC_DESC_CTS_MASK] + .desc_hdl; + } + // Current Time Service Characteristic + else if (param->char_code < TIPC_CHAR_CTS_MAX) { + search_hdl = tipc_env->env[conidx]->cts.chars[param->char_code].val_hdl; + } } - if (status != GAP_ERR_NO_ERROR) - { - //send app error indication - struct tipc_rd_char_rsp *ind = KE_MSG_ALLOC( - TIPC_RD_CHAR_RSP, - prf_dst_task_get(&(tipc_env->prf_env), conidx), - prf_src_task_get(&(tipc_env->prf_env), conidx), - tipc_rd_char_rsp); - - // It will be an TIPC status code - ind->status = status; - ind->op_code = param->char_code; - - // send the message - ke_msg_send(ind); + // Check if handle is viable + if ((search_hdl != ATT_INVALID_SEARCH_HANDLE) && (svc != NULL)) { + // Save char code + tipc_env->env[conidx]->last_char_code = param->char_code; + // Send read request + prf_read_char_send(&(tipc_env->prf_env), conidx, svc->shdl, svc->ehdl, + search_hdl); + } else { + status = PRF_ERR_INEXISTENT_HDL; } + } else { + status = PRF_ERR_REQ_DISALLOWED; + } - return (KE_MSG_CONSUMED); + if (status != GAP_ERR_NO_ERROR) { + // send app error indication + struct tipc_rd_char_rsp *ind = KE_MSG_ALLOC( + TIPC_RD_CHAR_RSP, prf_dst_task_get(&(tipc_env->prf_env), conidx), + prf_src_task_get(&(tipc_env->prf_env), conidx), tipc_rd_char_rsp); + + // It will be an TIPC status code + ind->status = status; + ind->op_code = param->char_code; + + // send the message + ke_msg_send(ind); + } + + return (KE_MSG_CONSUMED); } /** **************************************************************************************** * @brief Handles reception of the @ref TIPC_CT_NTF_CFG_REQ message. - * It allows configuration of the peer ind/ntf/stop characteristic for a specified characteristic. - * Will return an error code if that cfg char does not exist. + * It allows configuration of the peer ind/ntf/stop characteristic for a + *specified characteristic. Will return an error code if that cfg char does not + *exist. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -343,66 +321,58 @@ __STATIC int tipc_rd_char_req_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int tipc_ct_ntf_cfg_req_handler(ke_msg_id_t const msgid, - struct tipc_ct_ntf_cfg_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint16_t cfg_hdl = ATT_INVALID_SEARCH_HANDLE; - // Get the address of the environment - struct tipc_env_tag *tipc_env = PRF_ENV_GET(TIPC, tipc); - // Get connection index - uint8_t conidx = KE_IDX_GET(dest_id); - // Status - uint8_t status = PRF_ERR_REQ_DISALLOWED; +__STATIC int tipc_ct_ntf_cfg_req_handler( + ke_msg_id_t const msgid, struct tipc_ct_ntf_cfg_req const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + uint16_t cfg_hdl = ATT_INVALID_SEARCH_HANDLE; + // Get the address of the environment + struct tipc_env_tag *tipc_env = PRF_ENV_GET(TIPC, tipc); + // Get connection index + uint8_t conidx = KE_IDX_GET(dest_id); + // Status + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if((tipc_env->env[conidx] != NULL) && (ke_state_get(dest_id) == TIPC_IDLE)) - { - //Only NTF - if((param->cfg_val == PRF_CLI_STOP_NTFIND)||(param->cfg_val == PRF_CLI_START_NTF)) - { - cfg_hdl = tipc_env->env[conidx]->cts.descs[TIPC_DESC_CTS_CURR_TIME_CLI_CFG].desc_hdl; + if ((tipc_env->env[conidx] != NULL) && (ke_state_get(dest_id) == TIPC_IDLE)) { + // Only NTF + if ((param->cfg_val == PRF_CLI_STOP_NTFIND) || + (param->cfg_val == PRF_CLI_START_NTF)) { + cfg_hdl = tipc_env->env[conidx] + ->cts.descs[TIPC_DESC_CTS_CURR_TIME_CLI_CFG] + .desc_hdl; - //check if the handle value exists - if (cfg_hdl != ATT_INVALID_SEARCH_HANDLE) - { - // Send GATT Write Request - prf_gatt_write_ntf_ind(&tipc_env->prf_env, conidx, cfg_hdl, param->cfg_val); - status = GAP_ERR_NO_ERROR; - } - else - { - status = PRF_ERR_INEXISTENT_HDL; - } - } - else - { - status = PRF_ERR_INVALID_PARAM; - } + // check if the handle value exists + if (cfg_hdl != ATT_INVALID_SEARCH_HANDLE) { + // Send GATT Write Request + prf_gatt_write_ntf_ind(&tipc_env->prf_env, conidx, cfg_hdl, + param->cfg_val); + status = GAP_ERR_NO_ERROR; + } else { + status = PRF_ERR_INEXISTENT_HDL; + } + } else { + status = PRF_ERR_INVALID_PARAM; } + } - if (status != GAP_ERR_NO_ERROR) - { - struct tipc_ct_ntf_cfg_rsp *ind = KE_MSG_ALLOC( - TIPC_CT_NTF_CFG_RSP, - prf_dst_task_get(&(tipc_env->prf_env), conidx), - prf_src_task_get(&(tipc_env->prf_env), conidx), - tipc_ct_ntf_cfg_rsp); + if (status != GAP_ERR_NO_ERROR) { + struct tipc_ct_ntf_cfg_rsp *ind = KE_MSG_ALLOC( + TIPC_CT_NTF_CFG_RSP, prf_dst_task_get(&(tipc_env->prf_env), conidx), + prf_src_task_get(&(tipc_env->prf_env), conidx), tipc_ct_ntf_cfg_rsp); - // It will be an TIPC status code - ind->status = status; - // send the message - ke_msg_send(ind); - } + // It will be an TIPC status code + ind->status = status; + // send the message + ke_msg_send(ind); + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** **************************************************************************************** * @brief Handles reception of the @ref TIPC_WR_TIME_UPD_CTNL_PT_REQ message. - * Check if the handle exists in profile(already discovered) and send request, otherwise - * error to APP. + * Check if the handle exists in profile(already discovered) and send request, + *otherwise error to APP. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -410,59 +380,54 @@ __STATIC int tipc_ct_ntf_cfg_req_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int tipc_wr_time_upd_ctnl_pt_req_handler(ke_msg_id_t const msgid, - struct tipc_wr_time_udp_ctnl_pt_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct tipc_env_tag *tipc_env = PRF_ENV_GET(TIPC, tipc); - uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t status = PRF_ERR_REQ_DISALLOWED; +__STATIC int tipc_wr_time_upd_ctnl_pt_req_handler( + ke_msg_id_t const msgid, struct tipc_wr_time_udp_ctnl_pt_req const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Get the address of the environment + struct tipc_env_tag *tipc_env = PRF_ENV_GET(TIPC, tipc); + uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if((ke_state_get(dest_id) == TIPC_IDLE) && (tipc_env->env[conidx] != NULL)) - { - // Check provided parameters - if ((param->value == TIPS_TIME_UPD_CTNL_PT_GET) || - (param->value == TIPS_TIME_UPD_CTNL_PT_CANCEL)) - { - if (tipc_env->env[conidx]->cts.chars[TIPC_CHAR_RTUS_TIME_UPD_CTNL_PT].char_hdl != ATT_INVALID_SEARCH_HANDLE) - { - // Send GATT Write Request - prf_gatt_write(&tipc_env->prf_env, conidx, - tipc_env->env[conidx]->rtus.chars[TIPC_CHAR_RTUS_TIME_UPD_CTNL_PT].val_hdl, - (uint8_t *)¶m->value, sizeof(uint8_t), GATTC_WRITE_NO_RESPONSE); + if ((ke_state_get(dest_id) == TIPC_IDLE) && (tipc_env->env[conidx] != NULL)) { + // Check provided parameters + if ((param->value == TIPS_TIME_UPD_CTNL_PT_GET) || + (param->value == TIPS_TIME_UPD_CTNL_PT_CANCEL)) { + if (tipc_env->env[conidx] + ->cts.chars[TIPC_CHAR_RTUS_TIME_UPD_CTNL_PT] + .char_hdl != ATT_INVALID_SEARCH_HANDLE) { + // Send GATT Write Request + prf_gatt_write(&tipc_env->prf_env, conidx, + tipc_env->env[conidx] + ->rtus.chars[TIPC_CHAR_RTUS_TIME_UPD_CTNL_PT] + .val_hdl, + (uint8_t *)¶m->value, sizeof(uint8_t), + GATTC_WRITE_NO_RESPONSE); - status = GAP_ERR_NO_ERROR; - } - else - { - status = PRF_ERR_INEXISTENT_HDL; - } - } - else - { - status = PRF_ERR_INVALID_PARAM; - } + status = GAP_ERR_NO_ERROR; + } else { + status = PRF_ERR_INEXISTENT_HDL; + } + } else { + status = PRF_ERR_INVALID_PARAM; } + } - if (status != GAP_ERR_NO_ERROR) - { - //send app error indication - struct tipc_wr_time_upd_ctnl_pt_rsp *ind = KE_MSG_ALLOC( - TIPC_WR_TIME_UPD_CTNL_PT_RSP, - prf_dst_task_get(&(tipc_env->prf_env), conidx), - prf_src_task_get(&(tipc_env->prf_env), conidx), - tipc_wr_time_upd_ctnl_pt_rsp); + if (status != GAP_ERR_NO_ERROR) { + // send app error indication + struct tipc_wr_time_upd_ctnl_pt_rsp *ind = + KE_MSG_ALLOC(TIPC_WR_TIME_UPD_CTNL_PT_RSP, + prf_dst_task_get(&(tipc_env->prf_env), conidx), + prf_src_task_get(&(tipc_env->prf_env), conidx), + tipc_wr_time_upd_ctnl_pt_rsp); - // It will be an TIPC status code - ind->status = status; + // It will be an TIPC status code + ind->status = status; - // send the message - ke_msg_send(ind); - } + // send the message + ke_msg_send(ind); + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -477,173 +442,139 @@ __STATIC int tipc_wr_time_upd_ctnl_pt_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, - struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint8_t state = ke_state_get(dest_id); - uint8_t conidx = KE_IDX_GET(dest_id); - uint8_t status = PRF_ERR_STOP_DISC_CHAR_MISSING; - bool finished = false; + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + uint8_t state = ke_state_get(dest_id); + uint8_t conidx = KE_IDX_GET(dest_id); + uint8_t status = PRF_ERR_STOP_DISC_CHAR_MISSING; + bool finished = false; - // Get the address of the environment - struct tipc_env_tag *tipc_env = PRF_ENV_GET(TIPC, tipc); + // Get the address of the environment + struct tipc_env_tag *tipc_env = PRF_ENV_GET(TIPC, tipc); - if((state == TIPC_DISCOVERING) && (tipc_env->env[conidx] != NULL)) - { - if ((param->status == ATT_ERR_ATTRIBUTE_NOT_FOUND)|| - (param->status == ATT_ERR_NO_ERROR)) - { - // check characteristic validity - if(tipc_env->env[conidx]->nb_svc <= 1) - { - switch(tipc_env->env[conidx]->last_svc_req) - { - case ATT_SVC_CURRENT_TIME: - { - // Check service (mandatory) - status = prf_check_svc_char_validity(TIPC_CHAR_CTS_MAX, - tipc_env->env[conidx]->cts.chars, - tipc_cts_char); + if ((state == TIPC_DISCOVERING) && (tipc_env->env[conidx] != NULL)) { + if ((param->status == ATT_ERR_ATTRIBUTE_NOT_FOUND) || + (param->status == ATT_ERR_NO_ERROR)) { + // check characteristic validity + if (tipc_env->env[conidx]->nb_svc <= 1) { + switch (tipc_env->env[conidx]->last_svc_req) { + case ATT_SVC_CURRENT_TIME: { + // Check service (mandatory) + status = prf_check_svc_char_validity(TIPC_CHAR_CTS_MAX, + tipc_env->env[conidx]->cts.chars, + tipc_cts_char); - // Check Descriptors (mandatory) - if(status == GAP_ERR_NO_ERROR) - { - status = prf_check_svc_char_desc_validity(TIPC_DESC_CTS_MAX, - tipc_env->env[conidx]->cts.descs, - tipc_cts_char_desc, - tipc_env->env[conidx]->cts.chars); - // Prepare to discovery next service - tipc_env->env[conidx]->last_svc_req = ATT_SVC_NEXT_DST_CHANGE; - } - }break; + // Check Descriptors (mandatory) + if (status == GAP_ERR_NO_ERROR) { + status = prf_check_svc_char_desc_validity( + TIPC_DESC_CTS_MAX, tipc_env->env[conidx]->cts.descs, + tipc_cts_char_desc, tipc_env->env[conidx]->cts.chars); + // Prepare to discovery next service + tipc_env->env[conidx]->last_svc_req = ATT_SVC_NEXT_DST_CHANGE; + } + } break; - case ATT_SVC_NEXT_DST_CHANGE: - { - // Check service (if found) - if(tipc_env->env[conidx]->nb_svc) - { - status = prf_check_svc_char_validity(TIPC_CHAR_NDCS_MAX, - tipc_env->env[conidx]->ndcs.chars, - tipc_ndcs_char); - } - else - { - status = GAP_ERR_NO_ERROR; - } - // Prepare to discovery next service - tipc_env->env[conidx]->last_svc_req = ATT_SVC_REF_TIME_UPDATE; - }break; + case ATT_SVC_NEXT_DST_CHANGE: { + // Check service (if found) + if (tipc_env->env[conidx]->nb_svc) { + status = prf_check_svc_char_validity( + TIPC_CHAR_NDCS_MAX, tipc_env->env[conidx]->ndcs.chars, + tipc_ndcs_char); + } else { + status = GAP_ERR_NO_ERROR; + } + // Prepare to discovery next service + tipc_env->env[conidx]->last_svc_req = ATT_SVC_REF_TIME_UPDATE; + } break; - case ATT_SVC_REF_TIME_UPDATE: - { - // Check service (if found) - if(tipc_env->env[conidx]->nb_svc) - { - status = prf_check_svc_char_validity(TIPC_CHAR_RTUS_MAX, - tipc_env->env[conidx]->rtus.chars, - tipc_rtus_char); - } - else - { - status = GAP_ERR_NO_ERROR; - } + case ATT_SVC_REF_TIME_UPDATE: { + // Check service (if found) + if (tipc_env->env[conidx]->nb_svc) { + status = prf_check_svc_char_validity( + TIPC_CHAR_RTUS_MAX, tipc_env->env[conidx]->rtus.chars, + tipc_rtus_char); + } else { + status = GAP_ERR_NO_ERROR; + } - if(status == GAP_ERR_NO_ERROR) - { - // send app the details about the discovered TIPS DB to save - tipc_enable_rsp_send(tipc_env, conidx, GAP_ERR_NO_ERROR); - // Discovery is finished - finished = true; - } - }break; + if (status == GAP_ERR_NO_ERROR) { + // send app the details about the discovered TIPS DB to save + tipc_enable_rsp_send(tipc_env, conidx, GAP_ERR_NO_ERROR); + // Discovery is finished + finished = true; + } + } break; - default: - break; - } - } - // too many services - else - { - status = PRF_ERR_MULTIPLE_SVC; - } - - if(status == GAP_ERR_NO_ERROR) - { - // reset number of services - tipc_env->env[conidx]->nb_svc = 0; - - if (!finished) - { - //start discovering following service on peer - prf_disc_svc_send(&(tipc_env->prf_env), conidx, tipc_env->env[conidx]->last_svc_req); - } - } - else - { - // stop discovery procedure - tipc_enable_rsp_send(tipc_env, conidx, status); - } + default: + break; } - } - else if(state == TIPC_IDLE) - { - switch(param->operation) - { - case GATTC_WRITE: - { - struct tipc_ct_ntf_cfg_rsp *wr_cfm = KE_MSG_ALLOC( - TIPC_CT_NTF_CFG_RSP, - prf_dst_task_get(&(tipc_env->prf_env), conidx), - prf_src_task_get(&(tipc_env->prf_env), conidx), - tipc_ct_ntf_cfg_rsp); + } + // too many services + else { + status = PRF_ERR_MULTIPLE_SVC; + } - //it will be a GATT status code - wr_cfm->status = param->status; - // send the message - ke_msg_send(wr_cfm); - } break; + if (status == GAP_ERR_NO_ERROR) { + // reset number of services + tipc_env->env[conidx]->nb_svc = 0; - case GATTC_WRITE_NO_RESPONSE: - { - struct tipc_wr_time_upd_ctnl_pt_rsp *wr_cfm = KE_MSG_ALLOC( - TIPC_WR_TIME_UPD_CTNL_PT_RSP, - prf_dst_task_get(&(tipc_env->prf_env), conidx), - prf_src_task_get(&(tipc_env->prf_env), conidx), - tipc_wr_time_upd_ctnl_pt_rsp); - - //it will be a GATT status code - wr_cfm->status = param->status; - // send the message - ke_msg_send(wr_cfm); - } - break; - - case GATTC_READ: - { - // an error occurs while reading peer attribute, inform app - if(param->status != GAP_ERR_NO_ERROR) - { - struct tipc_rd_char_rsp *rd_cfm = KE_MSG_ALLOC( - TIPC_RD_CHAR_RSP, - prf_dst_task_get(&(tipc_env->prf_env), conidx), - prf_src_task_get(&(tipc_env->prf_env), conidx), - tipc_rd_char_rsp); - - //it will be a GATT status code - rd_cfm->status = param->status; - rd_cfm->op_code = tipc_env->env[conidx]->last_char_code; - // send the message - ke_msg_send(rd_cfm); - } - } - break; - - default: - break; + if (!finished) { + // start discovering following service on peer + prf_disc_svc_send(&(tipc_env->prf_env), conidx, + tipc_env->env[conidx]->last_svc_req); } + } else { + // stop discovery procedure + tipc_enable_rsp_send(tipc_env, conidx, status); + } } - return (KE_MSG_CONSUMED); + } else if (state == TIPC_IDLE) { + switch (param->operation) { + case GATTC_WRITE: { + struct tipc_ct_ntf_cfg_rsp *wr_cfm = KE_MSG_ALLOC( + TIPC_CT_NTF_CFG_RSP, prf_dst_task_get(&(tipc_env->prf_env), conidx), + prf_src_task_get(&(tipc_env->prf_env), conidx), tipc_ct_ntf_cfg_rsp); + + // it will be a GATT status code + wr_cfm->status = param->status; + // send the message + ke_msg_send(wr_cfm); + } break; + + case GATTC_WRITE_NO_RESPONSE: { + struct tipc_wr_time_upd_ctnl_pt_rsp *wr_cfm = + KE_MSG_ALLOC(TIPC_WR_TIME_UPD_CTNL_PT_RSP, + prf_dst_task_get(&(tipc_env->prf_env), conidx), + prf_src_task_get(&(tipc_env->prf_env), conidx), + tipc_wr_time_upd_ctnl_pt_rsp); + + // it will be a GATT status code + wr_cfm->status = param->status; + // send the message + ke_msg_send(wr_cfm); + } break; + + case GATTC_READ: { + // an error occurs while reading peer attribute, inform app + if (param->status != GAP_ERR_NO_ERROR) { + struct tipc_rd_char_rsp *rd_cfm = KE_MSG_ALLOC( + TIPC_RD_CHAR_RSP, prf_dst_task_get(&(tipc_env->prf_env), conidx), + prf_src_task_get(&(tipc_env->prf_env), conidx), tipc_rd_char_rsp); + + // it will be a GATT status code + rd_cfm->status = param->status; + rd_cfm->op_code = tipc_env->env[conidx]->last_char_code; + // send the message + ke_msg_send(rd_cfm); + } + } break; + + default: + break; + } + } + return (KE_MSG_CONSUMED); } /** @@ -660,73 +591,70 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, struct gattc_read_ind const *param, ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct tipc_env_tag *tipc_env = PRF_ENV_GET(TIPC, tipc); - uint8_t conidx = KE_IDX_GET(dest_id); + ke_task_id_t const src_id) { + // Get the address of the environment + struct tipc_env_tag *tipc_env = PRF_ENV_GET(TIPC, tipc); + uint8_t conidx = KE_IDX_GET(dest_id); - //Build the message - struct tipc_rd_char_rsp * ind = KE_MSG_ALLOC( - TIPC_RD_CHAR_RSP, - prf_dst_task_get(&(tipc_env->prf_env), conidx), - dest_id, - tipc_rd_char_rsp); + // Build the message + struct tipc_rd_char_rsp *ind = KE_MSG_ALLOC( + TIPC_RD_CHAR_RSP, prf_dst_task_get(&(tipc_env->prf_env), conidx), dest_id, + tipc_rd_char_rsp); - //Current Time Characteristic - if (tipc_env->env[conidx]->last_char_code == TIPC_RD_CTS_CURR_TIME) - { - ind->op_code = TIPC_RD_CTS_CURR_TIME; - // Unpack Current Time Value. - tipc_unpack_curr_time_value(&(ind->value.curr_time), (uint8_t *) param->value); - } - //Local Time Information Characteristic - else if (tipc_env->env[conidx]->last_char_code == TIPC_RD_CTS_LOCAL_TIME_INFO) - { - ind->op_code = TIPC_RD_CTS_LOCAL_TIME_INFO; - // Local Time Information Value - ind->value.loc_time_info.time_zone = param->value[0]; - ind->value.loc_time_info.dst_offset = param->value[1]; - } - //Reference Time Information Characteristic - else if (tipc_env->env[conidx]->last_char_code == TIPC_RD_CTS_REF_TIME_INFO) - { - ind->op_code = TIPC_RD_CTS_REF_TIME_INFO; - // Reference Time Information Value - ind->value.ref_time_info.time_source = param->value[0]; - ind->value.ref_time_info.time_accuracy = param->value[1]; - ind->value.ref_time_info.days_update = param->value[2]; - ind->value.ref_time_info.hours_update = param->value[3]; - } - //Time with DST Characteristic - else if (tipc_env->env[conidx]->last_char_code == TIPC_RD_NDCS_TIME_WITH_DST) - { - ind->op_code = TIPC_RD_NDCS_TIME_WITH_DST; - // Time with DST Value - tipc_unpack_time_dst_value(&ind->value.time_with_dst, (uint8_t *) param->value); - } - //Time Update State Characteristic - else if (tipc_env->env[conidx]->last_char_code == TIPC_RD_RTUS_TIME_UPD_STATE) - { - ind->op_code = TIPC_RD_RTUS_TIME_UPD_STATE; - // Reference Time Information Value - ind->value.time_upd_state.current_state = param->value[0]; - ind->value.time_upd_state.result = param->value[1]; - } - //Current Time Characteristic - Client Characteristic Configuration Descriptor - else if (tipc_env->env[conidx]->last_char_code == TIPC_RD_CTS_CURR_TIME_CLI_CFG) - { - ind->op_code = TIPC_RD_CTS_CURR_TIME_CLI_CFG; - // Notification Configuration - memcpy(&ind->value.ntf_cfg, ¶m->value[0], sizeof(uint16_t)); - } + // Current Time Characteristic + if (tipc_env->env[conidx]->last_char_code == TIPC_RD_CTS_CURR_TIME) { + ind->op_code = TIPC_RD_CTS_CURR_TIME; + // Unpack Current Time Value. + tipc_unpack_curr_time_value(&(ind->value.curr_time), + (uint8_t *)param->value); + } + // Local Time Information Characteristic + else if (tipc_env->env[conidx]->last_char_code == + TIPC_RD_CTS_LOCAL_TIME_INFO) { + ind->op_code = TIPC_RD_CTS_LOCAL_TIME_INFO; + // Local Time Information Value + ind->value.loc_time_info.time_zone = param->value[0]; + ind->value.loc_time_info.dst_offset = param->value[1]; + } + // Reference Time Information Characteristic + else if (tipc_env->env[conidx]->last_char_code == TIPC_RD_CTS_REF_TIME_INFO) { + ind->op_code = TIPC_RD_CTS_REF_TIME_INFO; + // Reference Time Information Value + ind->value.ref_time_info.time_source = param->value[0]; + ind->value.ref_time_info.time_accuracy = param->value[1]; + ind->value.ref_time_info.days_update = param->value[2]; + ind->value.ref_time_info.hours_update = param->value[3]; + } + // Time with DST Characteristic + else if (tipc_env->env[conidx]->last_char_code == + TIPC_RD_NDCS_TIME_WITH_DST) { + ind->op_code = TIPC_RD_NDCS_TIME_WITH_DST; + // Time with DST Value + tipc_unpack_time_dst_value(&ind->value.time_with_dst, + (uint8_t *)param->value); + } + // Time Update State Characteristic + else if (tipc_env->env[conidx]->last_char_code == + TIPC_RD_RTUS_TIME_UPD_STATE) { + ind->op_code = TIPC_RD_RTUS_TIME_UPD_STATE; + // Reference Time Information Value + ind->value.time_upd_state.current_state = param->value[0]; + ind->value.time_upd_state.result = param->value[1]; + } + // Current Time Characteristic - Client Characteristic Configuration + // Descriptor + else if (tipc_env->env[conidx]->last_char_code == + TIPC_RD_CTS_CURR_TIME_CLI_CFG) { + ind->op_code = TIPC_RD_CTS_CURR_TIME_CLI_CFG; + // Notification Configuration + memcpy(&ind->value.ntf_cfg, ¶m->value[0], sizeof(uint16_t)); + } - ke_msg_send(ind); + ke_msg_send(ind); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } - /** **************************************************************************************** * @brief Handles reception of the @ref GATTC_EVENT_IND message. @@ -738,32 +666,28 @@ __STATIC int gattc_read_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, - struct gattc_event_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct tipc_env_tag *tipc_env = PRF_ENV_GET(TIPC, tipc); - uint8_t conidx = KE_IDX_GET(dest_id); + struct gattc_event_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct tipc_env_tag *tipc_env = PRF_ENV_GET(TIPC, tipc); + uint8_t conidx = KE_IDX_GET(dest_id); - if(tipc_env->env[conidx] != NULL) - { - if(param->handle == tipc_env->env[conidx]->cts.chars[TIPC_CHAR_CTS_CURR_TIME].val_hdl) - { - //Build a TIPC_CT_IND message - struct tipc_ct_ind * ind = KE_MSG_ALLOC( - TIPC_CT_IND, - prf_dst_task_get(&(tipc_env->prf_env), conidx), - prf_src_task_get(&(tipc_env->prf_env), conidx), - tipc_ct_ind); + if (tipc_env->env[conidx] != NULL) { + if (param->handle == + tipc_env->env[conidx]->cts.chars[TIPC_CHAR_CTS_CURR_TIME].val_hdl) { + // Build a TIPC_CT_IND message + struct tipc_ct_ind *ind = KE_MSG_ALLOC( + TIPC_CT_IND, prf_dst_task_get(&(tipc_env->prf_env), conidx), + prf_src_task_get(&(tipc_env->prf_env), conidx), tipc_ct_ind); - // Unpack Current Time Value. - tipc_unpack_curr_time_value(&(ind->ct_val), (uint8_t*) param->value); + // Unpack Current Time Value. + tipc_unpack_curr_time_value(&(ind->ct_val), (uint8_t *)param->value); - ke_msg_send(ind); - } + ke_msg_send(ind); } - return (KE_MSG_CONSUMED); + } + return (KE_MSG_CONSUMED); } /* @@ -772,27 +696,26 @@ __STATIC int gattc_event_ind_handler(ke_msg_id_t const msgid, */ /// Default State handlers definition -KE_MSG_HANDLER_TAB(tipc) -{ - {TIPC_ENABLE_REQ, (ke_msg_func_t)tipc_enable_req_handler}, - {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, - {TIPC_CT_NTF_CFG_REQ, (ke_msg_func_t)tipc_ct_ntf_cfg_req_handler}, - {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, - {TIPC_RD_CHAR_REQ, (ke_msg_func_t)tipc_rd_char_req_handler}, - {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, - {TIPC_WR_TIME_UPD_CTNL_PT_REQ, (ke_msg_func_t)tipc_wr_time_upd_ctnl_pt_req_handler}, +KE_MSG_HANDLER_TAB(tipc){ + {TIPC_ENABLE_REQ, (ke_msg_func_t)tipc_enable_req_handler}, + {GATTC_SDP_SVC_IND, (ke_msg_func_t)gattc_sdp_svc_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, + {TIPC_CT_NTF_CFG_REQ, (ke_msg_func_t)tipc_ct_ntf_cfg_req_handler}, + {GATTC_EVENT_IND, (ke_msg_func_t)gattc_event_ind_handler}, + {TIPC_RD_CHAR_REQ, (ke_msg_func_t)tipc_rd_char_req_handler}, + {GATTC_READ_IND, (ke_msg_func_t)gattc_read_ind_handler}, + {TIPC_WR_TIME_UPD_CTNL_PT_REQ, + (ke_msg_func_t)tipc_wr_time_upd_ctnl_pt_req_handler}, }; -void tipc_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct tipc_env_tag *tipc_env = PRF_ENV_GET(TIPC, tipc); +void tipc_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct tipc_env_tag *tipc_env = PRF_ENV_GET(TIPC, tipc); - task_desc->msg_handler_tab = tipc_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(tipc_msg_handler_tab); - task_desc->state = tipc_env->state; - task_desc->idx_max = TIPC_IDX_MAX; + task_desc->msg_handler_tab = tipc_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(tipc_msg_handler_tab); + task_desc->state = tipc_env->state; + task_desc->idx_max = TIPC_IDX_MAX; } #endif /* (BLE_TIP_CLIENT) */ diff --git a/services/ble_profiles/tip/tips/src/tips.c b/services/ble_profiles/tip/tips/src/tips.c index 97ccf2b..eb14a08 100644 --- a/services/ble_profiles/tip/tips/src/tips.c +++ b/services/ble_profiles/tip/tips/src/tips.c @@ -13,9 +13,9 @@ #if (BLE_TIP_SERVER) #include "attm.h" +#include "prf_utils.h" #include "tips.h" #include "tips_task.h" -#include "prf_utils.h" #include "ke_mem.h" @@ -24,59 +24,75 @@ **************************************************************************************** */ /// Full CTS Database Description - Used to add attributes into the database -const struct attm_desc cts_att_db[CTS_IDX_NB] = -{ +const struct attm_desc cts_att_db[CTS_IDX_NB] = { // Current Time Service Declaration - [CTS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [CTS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // Current Time Characteristic Declaration - [CTS_IDX_CURRENT_TIME_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [CTS_IDX_CURRENT_TIME_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Current Time Characteristic Value - [CTS_IDX_CURRENT_TIME_VAL] = {ATT_CHAR_CT_TIME, PERM(RD, ENABLE) | PERM(NTF, ENABLE), PERM(RI, ENABLE), CTS_CURRENT_TIME_VAL_LEN}, + [CTS_IDX_CURRENT_TIME_VAL] = {ATT_CHAR_CT_TIME, + PERM(RD, ENABLE) | PERM(NTF, ENABLE), + PERM(RI, ENABLE), CTS_CURRENT_TIME_VAL_LEN}, // Current Time Characteristic - Client Char. Configuration Descriptor - [CTS_IDX_CURRENT_TIME_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [CTS_IDX_CURRENT_TIME_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, + 0}, // Local Time Information Characteristic Declaration - [CTS_IDX_LOCAL_TIME_INFO_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [CTS_IDX_LOCAL_TIME_INFO_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), + 0, 0}, // Local Time Information Characteristic Value - [CTS_IDX_LOCAL_TIME_INFO_VAL] = {ATT_CHAR_LOCAL_TIME_INFO, PERM(RD, ENABLE), PERM(RI, ENABLE), sizeof(struct tip_loc_time_info)}, + [CTS_IDX_LOCAL_TIME_INFO_VAL] = {ATT_CHAR_LOCAL_TIME_INFO, PERM(RD, ENABLE), + PERM(RI, ENABLE), + sizeof(struct tip_loc_time_info)}, // Reference Time Information Characteristic Declaration - [CTS_IDX_REF_TIME_INFO_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [CTS_IDX_REF_TIME_INFO_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), + 0, 0}, // Reference Time Info Characteristic Value - [CTS_IDX_REF_TIME_INFO_VAL] = {ATT_CHAR_REFERENCE_TIME_INFO, PERM(RD, ENABLE), PERM(RI, ENABLE), sizeof(struct tip_ref_time_info)}, + [CTS_IDX_REF_TIME_INFO_VAL] = {ATT_CHAR_REFERENCE_TIME_INFO, + PERM(RD, ENABLE), PERM(RI, ENABLE), + sizeof(struct tip_ref_time_info)}, }; /// Full NDCS Database Description - Used to add attributes into the database -const struct attm_desc ndcs_att_db[NDCS_IDX_NB] = -{ +const struct attm_desc ndcs_att_db[NDCS_IDX_NB] = { // Next DST Change Service Declaration - [NDCS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [NDCS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // Time with DST Characteristic Declaration - [NDCS_IDX_TIME_DST_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [NDCS_IDX_TIME_DST_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, + 0}, // Time With DST Characteristic Value - [NDCS_IDX_TIME_DST_VAL] = {ATT_CHAR_TIME_WITH_DST, PERM(RD, ENABLE), PERM(RI, ENABLE), NDCS_TIME_DST_VAL_LEN}, + [NDCS_IDX_TIME_DST_VAL] = {ATT_CHAR_TIME_WITH_DST, PERM(RD, ENABLE), + PERM(RI, ENABLE), NDCS_TIME_DST_VAL_LEN}, }; /// Full RTUS Database Description - Used to add attributes into the database -const struct attm_desc rtus_att_db[RTUS_IDX_NB] = -{ +const struct attm_desc rtus_att_db[RTUS_IDX_NB] = { // Reference Time Information Service Declaration - [RTUS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, + [RTUS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), 0, 0}, // Time Update Control Point Characteristic Declaration - [RTUS_IDX_TIME_UPD_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [RTUS_IDX_TIME_UPD_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, + PERM(RD, ENABLE), 0, 0}, // Time Update Control Point Characteristic Value - [RTUS_IDX_TIME_UPD_CTNL_PT_VAL] = {ATT_CHAR_TIME_UPDATE_CNTL_POINT, PERM(WRITE_COMMAND, ENABLE), PERM(RI, ENABLE), sizeof(tip_time_upd_contr_pt)}, + [RTUS_IDX_TIME_UPD_CTNL_PT_VAL] = {ATT_CHAR_TIME_UPDATE_CNTL_POINT, + PERM(WRITE_COMMAND, ENABLE), + PERM(RI, ENABLE), + sizeof(tip_time_upd_contr_pt)}, // Time Update State Characteristic Declaration - [RTUS_IDX_TIME_UPD_STATE_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), 0, 0}, + [RTUS_IDX_TIME_UPD_STATE_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), + 0, 0}, // Time Update State Characteristic Value - [RTUS_IDX_TIME_UPD_STATE_VAL] = {ATT_CHAR_TIME_UPDATE_STATE, PERM(RD, ENABLE), PERM(RI, ENABLE), sizeof(struct tip_time_upd_state)}, + [RTUS_IDX_TIME_UPD_STATE_VAL] = {ATT_CHAR_TIME_UPDATE_STATE, + PERM(RD, ENABLE), PERM(RI, ENABLE), + sizeof(struct tip_time_upd_state)}, }; - /** **************************************************************************************** * @brief Initialization of the TIPS module. @@ -89,150 +105,154 @@ const struct attm_desc rtus_att_db[RTUS_IDX_NB] = * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t tips_init(struct prf_task_env* env, uint16_t* start_hdl, uint16_t app_task, uint8_t sec_lvl, struct tips_db_cfg* params) -{ - // Service content flag - uint32_t cfg_flag= TIPS_CTS_CURRENT_TIME_MASK; - // DB Creation Status - uint8_t status = ATT_ERR_NO_ERROR; - // Total number of attributes - uint8_t tot_nb_att = CTS_IDX_NB; +static uint8_t tips_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, + struct tips_db_cfg *params) { + // Service content flag + uint32_t cfg_flag = TIPS_CTS_CURRENT_TIME_MASK; + // DB Creation Status + uint8_t status = ATT_ERR_NO_ERROR; + // Total number of attributes + uint8_t tot_nb_att = CTS_IDX_NB; - // Allocate TIPS required environment variable - struct tips_env_tag* tips_env = - (struct tips_env_tag* ) ke_malloc(sizeof(struct tips_env_tag), KE_MEM_ATT_DB); + // Allocate TIPS required environment variable + struct tips_env_tag *tips_env = (struct tips_env_tag *)ke_malloc( + sizeof(struct tips_env_tag), KE_MEM_ATT_DB); - env->env = (prf_env_t*) tips_env; + env->env = (prf_env_t *)tips_env; - //------------------ create the attribute database for the profile ------------------- + //------------------ create the attribute database for the profile + //------------------- - // Check supported attributes - if (params->features & TIPS_NDCS_SUP) - { - tot_nb_att += NDCS_IDX_NB; + // Check supported attributes + if (params->features & TIPS_NDCS_SUP) { + tot_nb_att += NDCS_IDX_NB; + } + + if (params->features & TIPS_NDCS_SUP) { + tot_nb_att += RTUS_IDX_NB; + } + + // Check that attribute list can be allocated. + status = attm_reserve_handle_range(start_hdl, tot_nb_att); + + if (status == ATT_ERR_NO_ERROR) { + // Set Configuration Flag Value + if (params->features & TIPS_CTS_LOC_TIME_INFO_SUP) { + cfg_flag |= TIPS_CTS_LOC_TIME_INFO_MASK; } - if (params->features & TIPS_NDCS_SUP) - { - tot_nb_att += RTUS_IDX_NB; + if (params->features & TIPS_CTS_REF_TIME_INFO_SUP) { + cfg_flag |= TIPS_CTS_REF_TIME_INFO_MASK; } - // Check that attribute list can be allocated. - status = attm_reserve_handle_range(start_hdl, tot_nb_att); + /*---------------------------------------------------* + * Current Time Service Creation + *---------------------------------------------------*/ + status = attm_svc_create_db( + start_hdl, ATT_SVC_CURRENT_TIME, (uint8_t *)&cfg_flag, CTS_IDX_NB, + &tips_env->cts_att_tbl[0], env->task, &cts_att_db[0], + (sec_lvl & + (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, ENABLE)); - if (status == ATT_ERR_NO_ERROR) - { - //Set Configuration Flag Value - if (params->features & TIPS_CTS_LOC_TIME_INFO_SUP) - { - cfg_flag |= TIPS_CTS_LOC_TIME_INFO_MASK; - } + // Update index + tips_env->cts_shdl = *start_hdl; + *start_hdl += CTS_IDX_NB; - if (params->features & TIPS_CTS_REF_TIME_INFO_SUP) - { - cfg_flag |= TIPS_CTS_REF_TIME_INFO_MASK; - } + // All attributes are mandatory for NDCS and RTUS + cfg_flag = 0xFF; - /*---------------------------------------------------* - * Current Time Service Creation - *---------------------------------------------------*/ - status = attm_svc_create_db(start_hdl, ATT_SVC_CURRENT_TIME, (uint8_t *)&cfg_flag, - CTS_IDX_NB, &tips_env->cts_att_tbl[0], env->task, &cts_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | PERM(SVC_MI, ENABLE)); + if ((status == ATT_ERR_NO_ERROR) && ((params->features & TIPS_NDCS_SUP))) { + /*---------------------------------------------------* + * Next DST Change Service Creation + *---------------------------------------------------*/ + status = attm_svc_create_db( + start_hdl, ATT_SVC_NEXT_DST_CHANGE, (uint8_t *)&cfg_flag, NDCS_IDX_NB, + &tips_env->ndcs_att_tbl[0], env->task, &ndcs_att_db[0], + (sec_lvl & + (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, ENABLE)); - // Update index - tips_env->cts_shdl = *start_hdl; - *start_hdl += CTS_IDX_NB; - - //All attributes are mandatory for NDCS and RTUS - cfg_flag = 0xFF; - - if ((status == ATT_ERR_NO_ERROR) && ((params->features & TIPS_NDCS_SUP))) - { - /*---------------------------------------------------* - * Next DST Change Service Creation - *---------------------------------------------------*/ - status = attm_svc_create_db(start_hdl, ATT_SVC_NEXT_DST_CHANGE, (uint8_t *)&cfg_flag, - NDCS_IDX_NB, &tips_env->ndcs_att_tbl[0], env->task, &ndcs_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | PERM(SVC_MI, ENABLE)); - - // Update index - tips_env->ndcs_shdl = *start_hdl; - *start_hdl += NDCS_IDX_NB; - } - - /*---------------------------------------------------* - * Reference Time Update Service Creation - *---------------------------------------------------*/ - if ((status == ATT_ERR_NO_ERROR) && ((params->features & TIPS_RTUS_SUP))) - { - status = attm_svc_create_db(start_hdl, ATT_SVC_REF_TIME_UPDATE, (uint8_t *)&cfg_flag, - RTUS_IDX_NB, &tips_env->rtus_att_tbl[0], env->task, &rtus_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | PERM(SVC_MI, ENABLE)); - - // Update index - tips_env->rtus_shdl = *start_hdl; - *start_hdl += RTUS_IDX_NB; - } - - // Initialize TIPS environment - tips_env->features = params->features; - - tips_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - // Multi Instantiated task - tips_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); - - // initialize environment variable - env->id = TASK_ID_TIPS; - tips_task_init(&(env->desc)); - - for(uint8_t idx = 0; idx < BLE_CONNECTION_MAX ; idx++) - { - tips_env->env[idx] = NULL; - } - - /* Put TIS in disabled state */ - ke_state_set(env->task, TIPS_IDLE); + // Update index + tips_env->ndcs_shdl = *start_hdl; + *start_hdl += NDCS_IDX_NB; } - return (status); + /*---------------------------------------------------* + * Reference Time Update Service Creation + *---------------------------------------------------*/ + if ((status == ATT_ERR_NO_ERROR) && ((params->features & TIPS_RTUS_SUP))) { + status = attm_svc_create_db( + start_hdl, ATT_SVC_REF_TIME_UPDATE, (uint8_t *)&cfg_flag, RTUS_IDX_NB, + &tips_env->rtus_att_tbl[0], env->task, &rtus_att_db[0], + (sec_lvl & + (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, ENABLE)); + + // Update index + tips_env->rtus_shdl = *start_hdl; + *start_hdl += RTUS_IDX_NB; + } + + // Initialize TIPS environment + tips_env->features = params->features; + + tips_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + // Multi Instantiated task + tips_env->prf_env.prf_task = env->task | PERM(PRF_MI, ENABLE); + + // initialize environment variable + env->id = TASK_ID_TIPS; + tips_task_init(&(env->desc)); + + for (uint8_t idx = 0; idx < BLE_CONNECTION_MAX; idx++) { + tips_env->env[idx] = NULL; + } + + /* Put TIS in disabled state */ + ke_state_set(env->task, TIPS_IDLE); + } + + return (status); } /** **************************************************************************************** * @brief Destruction of the TIPS module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void tips_destroy(struct prf_task_env* env) -{ - uint8_t idx; - struct tips_env_tag* tips_env = (struct tips_env_tag*) env->env; +static void tips_destroy(struct prf_task_env *env) { + uint8_t idx; + struct tips_env_tag *tips_env = (struct tips_env_tag *)env->env; - // cleanup environment variable for each task instances - for(idx = 0; idx < BLE_CONNECTION_MAX ; idx++) - { - if(tips_env->env[idx] != NULL) - { - ke_free(tips_env->env[idx]); - } + // cleanup environment variable for each task instances + for (idx = 0; idx < BLE_CONNECTION_MAX; idx++) { + if (tips_env->env[idx] != NULL) { + ke_free(tips_env->env[idx]); } + } - // free profile environment variables - env->env = NULL; - ke_free(tips_env); + // free profile environment variables + env->env = NULL; + ke_free(tips_env); } /** @@ -243,16 +263,15 @@ static void tips_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void tips_create(struct prf_task_env* env, uint8_t conidx) -{ - struct tips_env_tag* tips_env = (struct tips_env_tag*) env->env; - tips_env->env[conidx] = (struct tips_cnx_env*) - ke_malloc(sizeof(struct tips_cnx_env), KE_MEM_ATT_DB); +static void tips_create(struct prf_task_env *env, uint8_t conidx) { + struct tips_env_tag *tips_env = (struct tips_env_tag *)env->env; + tips_env->env[conidx] = (struct tips_cnx_env *)ke_malloc( + sizeof(struct tips_cnx_env), KE_MEM_ATT_DB); - memset(tips_env->env[conidx], 0, sizeof(struct tips_cnx_env)); + memset(tips_env->env[conidx], 0, sizeof(struct tips_cnx_env)); - /* Put TIS in idle state */ - ke_state_set(KE_BUILD_ID(env->task, conidx), TIPS_IDLE); + /* Put TIS in idle state */ + ke_state_set(KE_BUILD_ID(env->task, conidx), TIPS_IDLE); } /** @@ -264,16 +283,15 @@ static void tips_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void tips_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - struct tips_env_tag* tips_env = (struct tips_env_tag*) env->env; +static void tips_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + struct tips_env_tag *tips_env = (struct tips_env_tag *)env->env; - // clean-up environment variable allocated for task instance - if(tips_env->env[conidx] != NULL) - { - ke_free(tips_env->env[conidx]); - tips_env->env[conidx] = NULL; - } + // clean-up environment variable allocated for task instance + if (tips_env->env[conidx] != NULL) { + ke_free(tips_env->env[conidx]); + tips_env->env[conidx] = NULL; + } } /* @@ -282,12 +300,11 @@ static void tips_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reaso */ /// TIPS Task interface required by profile manager -const struct prf_task_cbs tips_itf = -{ - (prf_init_fnct) tips_init, - tips_destroy, - tips_create, - tips_cleanup, +const struct prf_task_cbs tips_itf = { + (prf_init_fnct)tips_init, + tips_destroy, + tips_create, + tips_cleanup, }; /* @@ -295,39 +312,37 @@ const struct prf_task_cbs tips_itf = **************************************************************************************** */ -const struct prf_task_cbs* tips_prf_itf_get(void) -{ - return &tips_itf; +const struct prf_task_cbs *tips_prf_itf_get(void) { return &tips_itf; } + +uint8_t tips_pack_curr_time_value(uint8_t *p_pckd_time, + const struct tip_curr_time *p_curr_time_val) { + // Date-Time + prf_pack_date_time(p_pckd_time, &(p_curr_time_val->date_time)); + + // Day of Week + *(p_pckd_time + 7) = p_curr_time_val->day_of_week; + + // Fraction 256 + *(p_pckd_time + 8) = p_curr_time_val->fraction_256; + + // Adjust Reason + *(p_pckd_time + 9) = p_curr_time_val->adjust_reason; + + return 10; } -uint8_t tips_pack_curr_time_value(uint8_t *p_pckd_time, const struct tip_curr_time* p_curr_time_val) -{ - // Date-Time - prf_pack_date_time(p_pckd_time, &(p_curr_time_val->date_time)); +uint8_t +tips_pack_time_dst_value(uint8_t *p_pckd_time_dst, + const struct tip_time_with_dst *p_time_dst_val) { + // Date-Time + prf_pack_date_time(p_pckd_time_dst, &(p_time_dst_val->date_time)); - //Day of Week - *(p_pckd_time + 7) = p_curr_time_val->day_of_week; + // DST Offset + *(p_pckd_time_dst + 7) = p_time_dst_val->dst_offset; - //Fraction 256 - *(p_pckd_time + 8) = p_curr_time_val->fraction_256; - - //Adjust Reason - *(p_pckd_time + 9) = p_curr_time_val->adjust_reason; - - return 10; + return 8; } -uint8_t tips_pack_time_dst_value(uint8_t *p_pckd_time_dst, const struct tip_time_with_dst* p_time_dst_val) -{ - // Date-Time - prf_pack_date_time(p_pckd_time_dst, &(p_time_dst_val->date_time)); - - // DST Offset - *(p_pckd_time_dst + 7) = p_time_dst_val->dst_offset; - - return 8; -} - -#endif //BLE_TIP_SERVER +#endif // BLE_TIP_SERVER /// @} TIPS diff --git a/services/ble_profiles/tip/tips/src/tips_task.c b/services/ble_profiles/tip/tips/src/tips_task.c index 7ca6fbe..ca70cfc 100644 --- a/services/ble_profiles/tip/tips/src/tips_task.c +++ b/services/ble_profiles/tip/tips/src/tips_task.c @@ -12,16 +12,15 @@ #include "rwip_config.h" #if (BLE_TIP_SERVER) +#include "attm.h" #include "co_utils.h" #include "gap.h" #include "gattc_task.h" -#include "attm.h" #include "tips.h" #include "tips_task.h" #include "prf_utils.h" - /* * LOCAL FUNCTIONS DEFINITIONS **************************************************************************************** @@ -39,45 +38,35 @@ **************************************************************************************** */ __STATIC int tips_enable_req_handler(ke_msg_id_t const msgid, - struct tips_enable_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct tips_env_tag *tips_env = PRF_ENV_GET(TIPS, tips); - uint8_t conidx = KE_IDX_GET(src_id); + struct tips_enable_req const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct tips_env_tag *tips_env = PRF_ENV_GET(TIPS, tips); + uint8_t conidx = KE_IDX_GET(src_id); - // Status - uint8_t status = GAP_ERR_NO_ERROR; + // Status + uint8_t status = GAP_ERR_NO_ERROR; - if(gapc_get_conhdl(conidx) == GAP_INVALID_CONHDL) - { - status = PRF_ERR_DISCONNECTED; - } - else if(ke_state_get(dest_id) == TIPS_IDLE) - { - if (param->current_time_ntf_en == PRF_CLI_START_NTF) - { - // Enable Bonded Data - tips_env->env[conidx]->ntf_state |= TIPS_CTS_CURRENT_TIME_CFG; - } - } - else - { - status = PRF_ERR_REQ_DISALLOWED; - } + if (gapc_get_conhdl(conidx) == GAP_INVALID_CONHDL) { + status = PRF_ERR_DISCONNECTED; + } else if (ke_state_get(dest_id) == TIPS_IDLE) { + if (param->current_time_ntf_en == PRF_CLI_START_NTF) { + // Enable Bonded Data + tips_env->env[conidx]->ntf_state |= TIPS_CTS_CURRENT_TIME_CFG; + } + } else { + status = PRF_ERR_REQ_DISALLOWED; + } - // Send to APP the details of the discovered attributes on TIPS - struct tips_enable_rsp * rsp = KE_MSG_ALLOC( - TIPS_ENABLE_RSP, - src_id, - dest_id, - tips_enable_rsp); + // Send to APP the details of the discovered attributes on TIPS + struct tips_enable_rsp *rsp = + KE_MSG_ALLOC(TIPS_ENABLE_RSP, src_id, dest_id, tips_enable_rsp); - rsp->status = status; - ke_msg_send(rsp); + rsp->status = status; + ke_msg_send(rsp); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -90,78 +79,67 @@ __STATIC int tips_enable_req_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int tips_upd_curr_time_req_handler(ke_msg_id_t const msgid, - struct tips_upd_curr_time_req const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Status - uint8_t status = GAP_ERR_NO_ERROR; +__STATIC int tips_upd_curr_time_req_handler( + ke_msg_id_t const msgid, struct tips_upd_curr_time_req const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Status + uint8_t status = GAP_ERR_NO_ERROR; - // Get the address of the environment - struct tips_env_tag *tips_env = PRF_ENV_GET(TIPS, tips); - uint8_t conidx = KE_IDX_GET(src_id); + // Get the address of the environment + struct tips_env_tag *tips_env = PRF_ENV_GET(TIPS, tips); + uint8_t conidx = KE_IDX_GET(src_id); - if ((tips_env->env[conidx] != NULL) && (ke_state_get(dest_id) == TIPS_IDLE)) - { + if ((tips_env->env[conidx] != NULL) && (ke_state_get(dest_id) == TIPS_IDLE)) { - //Check if Notifications are enabled - if ((tips_env->env[conidx]->ntf_state & TIPS_CTS_CURRENT_TIME_CFG) == TIPS_CTS_CURRENT_TIME_CFG) - { - //Check if notification can be sent - if ((param->current_time.adjust_reason & TIPS_FLAG_EXT_TIME_UPDATE) == TIPS_FLAG_EXT_TIME_UPDATE) - { - if(param->enable_ntf_send == 0) - { - status = PRF_ERR_REQ_DISALLOWED; - } - } - - if (status == GAP_ERR_NO_ERROR) - { - // Allocate the GATT notification message - struct gattc_send_evt_cmd *meas_val = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), dest_id, - gattc_send_evt_cmd, CTS_CURRENT_TIME_VAL_LEN); - - // Fill in the parameter structure - meas_val->operation = GATTC_NOTIFY; - meas_val->handle = tips_env->cts_shdl + CTS_IDX_CURRENT_TIME_VAL; - // Pack the Current Time value - meas_val->length = tips_pack_curr_time_value(meas_val->value, ¶m->current_time); - - // Go to idle state - ke_state_set(dest_id, TIPS_BUSY); - // Send the event - ke_msg_send(meas_val); - } - } - else - { - status = PRF_ERR_NTF_DISABLED; + // Check if Notifications are enabled + if ((tips_env->env[conidx]->ntf_state & TIPS_CTS_CURRENT_TIME_CFG) == + TIPS_CTS_CURRENT_TIME_CFG) { + // Check if notification can be sent + if ((param->current_time.adjust_reason & TIPS_FLAG_EXT_TIME_UPDATE) == + TIPS_FLAG_EXT_TIME_UPDATE) { + if (param->enable_ntf_send == 0) { + status = PRF_ERR_REQ_DISALLOWED; } + } + + if (status == GAP_ERR_NO_ERROR) { + // Allocate the GATT notification message + struct gattc_send_evt_cmd *meas_val = KE_MSG_ALLOC_DYN( + GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), dest_id, + gattc_send_evt_cmd, CTS_CURRENT_TIME_VAL_LEN); + + // Fill in the parameter structure + meas_val->operation = GATTC_NOTIFY; + meas_val->handle = tips_env->cts_shdl + CTS_IDX_CURRENT_TIME_VAL; + // Pack the Current Time value + meas_val->length = + tips_pack_curr_time_value(meas_val->value, ¶m->current_time); + + // Go to idle state + ke_state_set(dest_id, TIPS_BUSY); + // Send the event + ke_msg_send(meas_val); + } + } else { + status = PRF_ERR_NTF_DISABLED; } - else - { - status = GAP_ERR_INVALID_PARAM; - } + } else { + status = GAP_ERR_INVALID_PARAM; + } - if (status != GAP_ERR_NO_ERROR) - { - // Inform APP - struct tips_upd_curr_time_rsp *ind = KE_MSG_ALLOC( - TIPS_UPD_CURR_TIME_RSP, - prf_dst_task_get(&(tips_env->prf_env), conidx), - prf_src_task_get(&(tips_env->prf_env), conidx), - tips_upd_curr_time_rsp); + if (status != GAP_ERR_NO_ERROR) { + // Inform APP + struct tips_upd_curr_time_rsp *ind = KE_MSG_ALLOC( + TIPS_UPD_CURR_TIME_RSP, prf_dst_task_get(&(tips_env->prf_env), conidx), + prf_src_task_get(&(tips_env->prf_env), conidx), tips_upd_curr_time_rsp); - ind->status = status; + ind->status = status; - // send the message - ke_msg_send(ind); - } + // send the message + ke_msg_send(ind); + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -176,122 +154,104 @@ __STATIC int tips_upd_curr_time_req_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_read_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct tips_env_tag *tips_env = PRF_ENV_GET(TIPS, tips); - uint8_t conidx = KE_IDX_GET(src_id); + struct gattc_read_req_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct tips_env_tag *tips_env = PRF_ENV_GET(TIPS, tips); + uint8_t conidx = KE_IDX_GET(src_id); - uint8_t status = PRF_ERR_REQ_DISALLOWED; + uint8_t status = PRF_ERR_REQ_DISALLOWED; - if((ke_state_get(dest_id) == TIPS_IDLE) && (tips_env->env[conidx] != NULL)) - { - //CTS : Current Time client configuration - if (param->handle == tips_env->cts_shdl + CTS_IDX_CURRENT_TIME_CFG) - { - uint16_t value = (tips_env->env[conidx]->ntf_state & TIPS_CTS_CURRENT_TIME_CFG) - ? PRF_CLI_START_NTF : PRF_CLI_STOP_NTFIND; - status = ATT_ERR_NO_ERROR; + if ((ke_state_get(dest_id) == TIPS_IDLE) && (tips_env->env[conidx] != NULL)) { + // CTS : Current Time client configuration + if (param->handle == tips_env->cts_shdl + CTS_IDX_CURRENT_TIME_CFG) { + uint16_t value = + (tips_env->env[conidx]->ntf_state & TIPS_CTS_CURRENT_TIME_CFG) + ? PRF_CLI_START_NTF + : PRF_CLI_STOP_NTFIND; + status = ATT_ERR_NO_ERROR; - // Send data to peer device - struct gattc_read_cfm* cfm = KE_MSG_ALLOC_DYN( - GATTC_READ_CFM, - src_id, dest_id, - gattc_read_cfm, - sizeof(uint16_t)); + // Send data to peer device + struct gattc_read_cfm *cfm = KE_MSG_ALLOC_DYN( + GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(uint16_t)); - cfm->length = sizeof(uint16_t); - memcpy(cfm->value, &value, sizeof(uint16_t)); - cfm->handle = param->handle; - cfm->status = status; + cfm->length = sizeof(uint16_t); + memcpy(cfm->value, &value, sizeof(uint16_t)); + cfm->handle = param->handle; + cfm->status = status; - // Send value to peer device. - ke_msg_send(cfm); + // Send value to peer device. + ke_msg_send(cfm); + } else { + // Inform APP about read request + struct tips_rd_req_ind *ind = KE_MSG_ALLOC( + TIPS_RD_REQ_IND, prf_dst_task_get(&(tips_env->prf_env), conidx), + prf_src_task_get(&(tips_env->prf_env), conidx), tips_rd_req_ind); + + // Current Time Service + if (param->handle < tips_env->cts_shdl + CTS_IDX_NB) { + // Current Time Char value + if (param->handle == tips_env->cts_shdl + CTS_IDX_CURRENT_TIME_VAL) { + ind->char_code = TIPS_CTS_CURRENT_TIME; + status = ATT_ERR_NO_ERROR; } - else - { - // Inform APP about read request - struct tips_rd_req_ind* ind = KE_MSG_ALLOC( - TIPS_RD_REQ_IND, - prf_dst_task_get(&(tips_env->prf_env), conidx), - prf_src_task_get(&(tips_env->prf_env), conidx), - tips_rd_req_ind); - - // Current Time Service - if (param->handle < tips_env->cts_shdl + CTS_IDX_NB) - { - // Current Time Char value - if(param->handle == tips_env->cts_shdl + CTS_IDX_CURRENT_TIME_VAL) - { - ind->char_code = TIPS_CTS_CURRENT_TIME; - status = ATT_ERR_NO_ERROR; - } - // Local Time Info Char value - else if ((param->handle == tips_env->cts_shdl + CTS_IDX_LOCAL_TIME_INFO_VAL) - && (TIPS_IS_SUPPORTED(TIPS_CTS_LOC_TIME_INFO_SUP))) - { - ind->char_code = TIPS_CTS_LOCAL_TIME_INFO; - status = ATT_ERR_NO_ERROR; - } - // Reference Time Info Char value - else if ((param->handle == tips_env->cts_shdl + CTS_IDX_REF_TIME_INFO_VAL) - && (TIPS_IS_SUPPORTED(TIPS_CTS_REF_TIME_INFO_SUP))) - { - ind->char_code = TIPS_CTS_REF_TIME_INFO; - status = ATT_ERR_NO_ERROR; - } - } - // Time with DST Char value - else if ((param->handle == tips_env->ndcs_shdl + NDCS_IDX_TIME_DST_VAL) - && (TIPS_IS_SUPPORTED(TIPS_NDCS_SUP))) - { - ind->char_code = TIPS_NDCS_TIME_DST; - status = ATT_ERR_NO_ERROR; - } - // Time Update State - else if ((param->handle == tips_env->rtus_shdl + RTUS_IDX_TIME_UPD_STATE_VAL) - && (TIPS_IS_SUPPORTED(TIPS_RTUS_SUP))) - { - ind->char_code = TIPS_RTUS_TIME_UPD_STATE_VAL; - status = ATT_ERR_NO_ERROR; - } - else - { - // Set error code - status = PRF_ERR_INEXISTENT_HDL; - } - - if (status == ATT_ERR_NO_ERROR) - { - // Save handle - tips_env->env[conidx]->handle = param->handle; - // Send message to the APP - ke_msg_send(ind); - // Go to busy state - ke_state_set(dest_id, TIPS_BUSY); - } - else - { - // Free message - ke_msg_free(ke_param2msg(ind)); - // Send data to peer device - struct gattc_read_cfm* cfm = KE_MSG_ALLOC( - GATTC_READ_CFM, - src_id, dest_id, - gattc_read_cfm); - - cfm->handle = param->handle; - cfm->status = status; - - // Send to peer device. - ke_msg_send(cfm); - } + // Local Time Info Char value + else if ((param->handle == + tips_env->cts_shdl + CTS_IDX_LOCAL_TIME_INFO_VAL) && + (TIPS_IS_SUPPORTED(TIPS_CTS_LOC_TIME_INFO_SUP))) { + ind->char_code = TIPS_CTS_LOCAL_TIME_INFO; + status = ATT_ERR_NO_ERROR; } + // Reference Time Info Char value + else if ((param->handle == + tips_env->cts_shdl + CTS_IDX_REF_TIME_INFO_VAL) && + (TIPS_IS_SUPPORTED(TIPS_CTS_REF_TIME_INFO_SUP))) { + ind->char_code = TIPS_CTS_REF_TIME_INFO; + status = ATT_ERR_NO_ERROR; + } + } + // Time with DST Char value + else if ((param->handle == tips_env->ndcs_shdl + NDCS_IDX_TIME_DST_VAL) && + (TIPS_IS_SUPPORTED(TIPS_NDCS_SUP))) { + ind->char_code = TIPS_NDCS_TIME_DST; + status = ATT_ERR_NO_ERROR; + } + // Time Update State + else if ((param->handle == + tips_env->rtus_shdl + RTUS_IDX_TIME_UPD_STATE_VAL) && + (TIPS_IS_SUPPORTED(TIPS_RTUS_SUP))) { + ind->char_code = TIPS_RTUS_TIME_UPD_STATE_VAL; + status = ATT_ERR_NO_ERROR; + } else { + // Set error code + status = PRF_ERR_INEXISTENT_HDL; + } + + if (status == ATT_ERR_NO_ERROR) { + // Save handle + tips_env->env[conidx]->handle = param->handle; + // Send message to the APP + ke_msg_send(ind); + // Go to busy state + ke_state_set(dest_id, TIPS_BUSY); + } else { + // Free message + ke_msg_free(ke_param2msg(ind)); + // Send data to peer device + struct gattc_read_cfm *cfm = + KE_MSG_ALLOC(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm); + + cfm->handle = param->handle; + cfm->status = status; + + // Send to peer device. + ke_msg_send(cfm); + } } + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** @@ -305,87 +265,78 @@ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, **************************************************************************************** */ __STATIC int tips_rd_cfm_handler(ke_msg_id_t const msgid, - struct tips_rd_cfm const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct tips_env_tag *tips_env = PRF_ENV_GET(TIPS, tips); - uint8_t conidx = KE_IDX_GET(src_id); - uint8_t status = GAP_ERR_NO_ERROR; + struct tips_rd_cfm const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct tips_env_tag *tips_env = PRF_ENV_GET(TIPS, tips); + uint8_t conidx = KE_IDX_GET(src_id); + uint8_t status = GAP_ERR_NO_ERROR; - if ((ke_state_get(dest_id) == TIPS_BUSY) && (tips_env->env[conidx] != NULL)) - { - if (tips_env->env[conidx]->handle != ATT_INVALID_HANDLE) - { - // Send data to peer device - struct gattc_read_cfm* cfm = KE_MSG_ALLOC_DYN( - GATTC_READ_CFM, - KE_BUILD_ID(TASK_GATTC, conidx), dest_id, - gattc_read_cfm, - sizeof(struct tips_rd_cfm)); + if ((ke_state_get(dest_id) == TIPS_BUSY) && (tips_env->env[conidx] != NULL)) { + if (tips_env->env[conidx]->handle != ATT_INVALID_HANDLE) { + // Send data to peer device + struct gattc_read_cfm *cfm = + KE_MSG_ALLOC_DYN(GATTC_READ_CFM, KE_BUILD_ID(TASK_GATTC, conidx), + dest_id, gattc_read_cfm, sizeof(struct tips_rd_cfm)); - switch (param->op_code) - { - case TIPS_CTS_CURRENT_TIME: - { - // Pack Current Time - cfm->length = tips_pack_curr_time_value(cfm->value, ¶m->value.curr_time); - } break; + switch (param->op_code) { + case TIPS_CTS_CURRENT_TIME: { + // Pack Current Time + cfm->length = + tips_pack_curr_time_value(cfm->value, ¶m->value.curr_time); + } break; - case TIPS_CTS_LOCAL_TIME_INFO: - { - // Pack Local Time - cfm->length = sizeof(struct tip_loc_time_info); - memcpy(cfm->value, ¶m->value, cfm->length); - } break; + case TIPS_CTS_LOCAL_TIME_INFO: { + // Pack Local Time + cfm->length = sizeof(struct tip_loc_time_info); + memcpy(cfm->value, ¶m->value, cfm->length); + } break; - case TIPS_CTS_REF_TIME_INFO: - { - // Pack Reference Time - cfm->length = sizeof(struct tip_ref_time_info); - memcpy(cfm->value, ¶m->value, cfm->length); - } break; + case TIPS_CTS_REF_TIME_INFO: { + // Pack Reference Time + cfm->length = sizeof(struct tip_ref_time_info); + memcpy(cfm->value, ¶m->value, cfm->length); + } break; - case TIPS_NDCS_TIME_DST: - { - // Pack Time with DST - cfm->length = tips_pack_time_dst_value(cfm->value, ¶m->value.time_with_dst); - } break; + case TIPS_NDCS_TIME_DST: { + // Pack Time with DST + cfm->length = + tips_pack_time_dst_value(cfm->value, ¶m->value.time_with_dst); + } break; - case TIPS_RTUS_TIME_UPD_STATE_VAL: - { - // Pack Time Update State - cfm->length = sizeof(struct tip_time_upd_state); - memcpy(cfm->value, ¶m->value, cfm->length); - } break; - default: - { - // Return Application error to peer - cfm->length = 0; - status = PRF_APP_ERROR; - } break; - } + case TIPS_RTUS_TIME_UPD_STATE_VAL: { + // Pack Time Update State + cfm->length = sizeof(struct tip_time_upd_state); + memcpy(cfm->value, ¶m->value, cfm->length); + } break; + default: { + // Return Application error to peer + cfm->length = 0; + status = PRF_APP_ERROR; + } break; + } - // Set parameters - cfm->handle = tips_env->env[conidx]->handle; - cfm->status = status; - // Send value to peer device. - ke_msg_send(cfm); - // Go to idle state - ke_state_set(dest_id, TIPS_IDLE); - // Reset environment variable - tips_env->env[conidx]->handle = ATT_INVALID_HANDLE; - } + // Set parameters + cfm->handle = tips_env->env[conidx]->handle; + cfm->status = status; + // Send value to peer device. + ke_msg_send(cfm); + // Go to idle state + ke_state_set(dest_id, TIPS_IDLE); + // Reset environment variable + tips_env->env[conidx]->handle = ATT_INVALID_HANDLE; } + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** **************************************************************************************** - * @brief Handles @ref GATTC_CMP_EVT for GATTC_NOTIFY message meaning that Measurement - * notification has been correctly sent to peer device (but not confirmed by peer device). + * @brief Handles @ref GATTC_CMP_EVT for GATTC_NOTIFY message meaning that + *Measurement notification has been correctly sent to peer device (but not + *confirmed by peer device). * * * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. @@ -394,40 +345,40 @@ __STATIC int tips_rd_cfm_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - // Get the address of the environment - struct tips_env_tag *tips_env = PRF_ENV_GET(TIPS, tips); - uint8_t conidx = KE_IDX_GET(src_id); +__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + // Get the address of the environment + struct tips_env_tag *tips_env = PRF_ENV_GET(TIPS, tips); + uint8_t conidx = KE_IDX_GET(src_id); - if (tips_env->env[conidx] != NULL) - { - if (param->operation == GATTC_NOTIFY) - { - // Inform APP - struct tips_upd_curr_time_rsp *ind = KE_MSG_ALLOC( - TIPS_UPD_CURR_TIME_RSP, - prf_dst_task_get(&(tips_env->prf_env), conidx), - prf_src_task_get(&(tips_env->prf_env), conidx), - tips_upd_curr_time_rsp); + if (tips_env->env[conidx] != NULL) { + if (param->operation == GATTC_NOTIFY) { + // Inform APP + struct tips_upd_curr_time_rsp *ind = + KE_MSG_ALLOC(TIPS_UPD_CURR_TIME_RSP, + prf_dst_task_get(&(tips_env->prf_env), conidx), + prf_src_task_get(&(tips_env->prf_env), conidx), + tips_upd_curr_time_rsp); - ind->status = param->status; + ind->status = param->status; - // send the message - ke_msg_send(ind); - // Go to idle state - ke_state_set(dest_id, TIPS_IDLE); - } + // send the message + ke_msg_send(ind); + // Go to idle state + ke_state_set(dest_id, TIPS_IDLE); } + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** **************************************************************************************** * @brief Handles reception of the @ref GL2C_CODE_ATT_WR_CMD_IND message. - * The handler compares the new values with current ones and notifies them if they changed. + * The handler compares the new values with current ones and notifies them if + *they changed. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -435,93 +386,81 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_ev * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_write_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - uint16_t cfg_value = 0x0000; -// uint8_t time_upd_ctnl_pt = 0x00; - uint8_t status = GAP_ERR_NO_ERROR; +__STATIC int gattc_write_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + uint16_t cfg_value = 0x0000; + // uint8_t time_upd_ctnl_pt = 0x00; + uint8_t status = GAP_ERR_NO_ERROR; - // Get the address of the environment - struct tips_env_tag *tips_env = PRF_ENV_GET(TIPS, tips); - uint8_t conidx = KE_IDX_GET(src_id); + // Get the address of the environment + struct tips_env_tag *tips_env = PRF_ENV_GET(TIPS, tips); + uint8_t conidx = KE_IDX_GET(src_id); - //CTS : Current Time Char. - Notification Configuration - if (param->handle == tips_env->cts_shdl + CTS_IDX_CURRENT_TIME_CFG) - { - //Extract value before check - memcpy(&cfg_value, ¶m->value[0], sizeof(uint16_t)); + // CTS : Current Time Char. - Notification Configuration + if (param->handle == tips_env->cts_shdl + CTS_IDX_CURRENT_TIME_CFG) { + // Extract value before check + memcpy(&cfg_value, ¶m->value[0], sizeof(uint16_t)); - //only update configuration if value for stop or notification enable - if ((cfg_value == PRF_CLI_STOP_NTFIND) || (cfg_value == PRF_CLI_START_NTF)) - { - if (cfg_value == PRF_CLI_STOP_NTFIND) - { - tips_env->env[conidx]->ntf_state &= ~TIPS_CTS_CURRENT_TIME_CFG; - } - else //PRF_CLI_START_NTF - { - tips_env->env[conidx]->ntf_state |= TIPS_CTS_CURRENT_TIME_CFG; - } + // only update configuration if value for stop or notification enable + if ((cfg_value == PRF_CLI_STOP_NTFIND) || + (cfg_value == PRF_CLI_START_NTF)) { + if (cfg_value == PRF_CLI_STOP_NTFIND) { + tips_env->env[conidx]->ntf_state &= ~TIPS_CTS_CURRENT_TIME_CFG; + } else // PRF_CLI_START_NTF + { + tips_env->env[conidx]->ntf_state |= TIPS_CTS_CURRENT_TIME_CFG; + } - //Inform APP of configuration change - struct tips_current_time_ccc_ind * msg = KE_MSG_ALLOC( - TIPS_CURRENT_TIME_CCC_IND, - prf_dst_task_get(&tips_env->prf_env, conidx), - prf_src_task_get(&tips_env->prf_env, conidx), - tips_current_time_ccc_ind); + // Inform APP of configuration change + struct tips_current_time_ccc_ind *msg = + KE_MSG_ALLOC(TIPS_CURRENT_TIME_CCC_IND, + prf_dst_task_get(&tips_env->prf_env, conidx), + prf_src_task_get(&tips_env->prf_env, conidx), + tips_current_time_ccc_ind); - msg->cfg_val = cfg_value; + msg->cfg_val = cfg_value; - ke_msg_send(msg); - } - else - { - status = PRF_ERR_INVALID_PARAM; - } + ke_msg_send(msg); + } else { + status = PRF_ERR_INVALID_PARAM; } - //RTUS : Time Update Control Point Char. - Val - else if (param->handle == tips_env->rtus_shdl + RTUS_IDX_TIME_UPD_CTNL_PT_VAL) - { - //Check if value to write is in allowed range - if ((param->value[0] == TIPS_TIME_UPD_CTNL_PT_GET) || - (param->value[0] == TIPS_TIME_UPD_CTNL_PT_CANCEL)) - { - //Update value - tips_env->time_upd_state = param->value[0]; + } + // RTUS : Time Update Control Point Char. - Val + else if (param->handle == + tips_env->rtus_shdl + RTUS_IDX_TIME_UPD_CTNL_PT_VAL) { + // Check if value to write is in allowed range + if ((param->value[0] == TIPS_TIME_UPD_CTNL_PT_GET) || + (param->value[0] == TIPS_TIME_UPD_CTNL_PT_CANCEL)) { + // Update value + tips_env->time_upd_state = param->value[0]; - //Send APP the indication with the new value - struct tips_time_upd_ctnl_pt_ind * msg = KE_MSG_ALLOC( - TIPS_TIME_UPD_CTNL_PT_IND, - prf_dst_task_get(&tips_env->prf_env, conidx), - prf_src_task_get(&tips_env->prf_env, conidx), - tips_time_upd_ctnl_pt_ind); + // Send APP the indication with the new value + struct tips_time_upd_ctnl_pt_ind *msg = + KE_MSG_ALLOC(TIPS_TIME_UPD_CTNL_PT_IND, + prf_dst_task_get(&tips_env->prf_env, conidx), + prf_src_task_get(&tips_env->prf_env, conidx), + tips_time_upd_ctnl_pt_ind); - // Time Update Control Point Characteristic Value - msg->value = tips_env->time_upd_state; - // Send message - ke_msg_send(msg); - } - else - { - status = PRF_ERR_INVALID_PARAM; - } - } - else - { - status = PRF_ERR_NOT_WRITABLE; + // Time Update Control Point Characteristic Value + msg->value = tips_env->time_upd_state; + // Send message + ke_msg_send(msg); + } else { + status = PRF_ERR_INVALID_PARAM; } + } else { + status = PRF_ERR_NOT_WRITABLE; + } - //Send write response - struct gattc_write_cfm *cfm = KE_MSG_ALLOC( - GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = status; - ke_msg_send(cfm); + // Send write response + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = status; + ke_msg_send(cfm); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /* @@ -530,27 +469,25 @@ __STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, */ /// Default State handlers definition -KE_MSG_HANDLER_TAB(tips) -{ - {TIPS_ENABLE_REQ, (ke_msg_func_t)tips_enable_req_handler}, - {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, - {TIPS_UPD_CURR_TIME_REQ, (ke_msg_func_t)tips_upd_curr_time_req_handler}, - {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, - {TIPS_RD_CFM, (ke_msg_func_t)tips_rd_cfm_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, +KE_MSG_HANDLER_TAB(tips){ + {TIPS_ENABLE_REQ, (ke_msg_func_t)tips_enable_req_handler}, + {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, + {TIPS_UPD_CURR_TIME_REQ, (ke_msg_func_t)tips_upd_curr_time_req_handler}, + {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, + {TIPS_RD_CFM, (ke_msg_func_t)tips_rd_cfm_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, }; -void tips_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct tips_env_tag *tips_env = PRF_ENV_GET(TIPS, tips); +void tips_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct tips_env_tag *tips_env = PRF_ENV_GET(TIPS, tips); - task_desc->msg_handler_tab = tips_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(tips_msg_handler_tab); - task_desc->state = tips_env->state; - task_desc->idx_max = TIPS_IDX_MAX; + task_desc->msg_handler_tab = tips_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(tips_msg_handler_tab); + task_desc->state = tips_env->state; + task_desc->idx_max = TIPS_IDX_MAX; } -#endif //BLE_TIP_SERVER +#endif // BLE_TIP_SERVER /// @} TIPSTASK diff --git a/services/ble_profiles/tota/tota_ble.c b/services/ble_profiles/tota/tota_ble.c index ef8b5ab..fbbcb64 100644 --- a/services/ble_profiles/tota/tota_ble.c +++ b/services/ble_profiles/tota/tota_ble.c @@ -14,8 +14,6 @@ * ****************************************************************************/ - - /* * INCLUDE FILES **************************************************************************************** @@ -23,45 +21,59 @@ #include "rwip_config.h" #if (BLE_TOTA) -#include "gap.h" -#include "gattc_task.h" #include "attm.h" +#include "co_utils.h" +#include "gap.h" #include "gapc_task.h" +#include "gattc_task.h" +#include "ke_mem.h" +#include "prf_utils.h" #include "tota_ble.h" #include "tota_task.h" -#include "prf_utils.h" -#include "ke_mem.h" -#include "co_utils.h" - /* * TOTA CMD PROFILE ATTRIBUTES **************************************************************************************** */ -#define tota_service_uuid_128_content {0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86 } -#define tota_val_char_val_uuid_128_content {0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97 } +#define tota_service_uuid_128_content \ + { \ + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, \ + 0x86, 0x86, 0x86, 0x86 \ + } +#define tota_val_char_val_uuid_128_content \ + { \ + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, \ + 0x97, 0x97, 0x97, 0x97 \ + } -#define ATT_DECL_PRIMARY_SERVICE_UUID { 0x00, 0x28 } -#define ATT_DECL_CHARACTERISTIC_UUID { 0x03, 0x28 } -#define ATT_DESC_CLIENT_CHAR_CFG_UUID { 0x02, 0x29 } +#define ATT_DECL_PRIMARY_SERVICE_UUID \ + { 0x00, 0x28 } +#define ATT_DECL_CHARACTERISTIC_UUID \ + { 0x03, 0x28 } +#define ATT_DESC_CLIENT_CHAR_CFG_UUID \ + { 0x02, 0x29 } -static const uint8_t TOTA_SERVICE_UUID_128[ATT_UUID_128_LEN] = tota_service_uuid_128_content; +static const uint8_t TOTA_SERVICE_UUID_128[ATT_UUID_128_LEN] = + tota_service_uuid_128_content; -/// Full OTA SERVER Database Description - Used to add attributes into the database -const struct attm_desc_128 tota_att_db[TOTA_IDX_NB] = -{ +/// Full OTA SERVER Database Description - Used to add attributes into the +/// database +const struct attm_desc_128 tota_att_db[TOTA_IDX_NB] = { // TOTA Service Declaration - [TOTA_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE_UUID, PERM(RD, ENABLE), 0, 0}, - // TOTA Characteristic Declaration - [TOTA_IDX_CHAR] = {ATT_DECL_CHARACTERISTIC_UUID, PERM(RD, ENABLE), 0, 0}, - // TOTA service - [TOTA_IDX_VAL] = {tota_val_char_val_uuid_128_content, PERM(WRITE_REQ, ENABLE) | PERM(NTF, ENABLE), PERM(RI, ENABLE) | PERM_VAL(UUID_LEN, PERM_UUID_128), TOTA_MAX_LEN}, - // TOTA Characteristic - [TOTA_IDX_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG_UUID, PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, + [TOTA_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE_UUID, PERM(RD, ENABLE), 0, 0}, + // TOTA Characteristic Declaration + [TOTA_IDX_CHAR] = {ATT_DECL_CHARACTERISTIC_UUID, PERM(RD, ENABLE), 0, 0}, + // TOTA service + [TOTA_IDX_VAL] = {tota_val_char_val_uuid_128_content, + PERM(WRITE_REQ, ENABLE) | PERM(NTF, ENABLE), + PERM(RI, ENABLE) | PERM_VAL(UUID_LEN, PERM_UUID_128), + TOTA_MAX_LEN}, + // TOTA Characteristic + [TOTA_IDX_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG_UUID, + PERM(RD, ENABLE) | PERM(WRITE_REQ, ENABLE), 0, 0}, }; - /** **************************************************************************************** * @brief Initialization of the TOTA module. @@ -74,71 +86,75 @@ const struct attm_desc_128 tota_att_db[TOTA_IDX_NB] = * - Default task handler * * @param[out] env Collector or Service allocated environment data. - * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), only applies for services. + * @param[in|out] start_hdl Service start handle (0 - dynamically allocated), + *only applies for services. * @param[in] app_task Application task number. - * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum attm_value_perm_mask) - * @param[in] param Configuration parameters of profile collector or service (32 bits aligned) + * @param[in] sec_lvl Security level (AUTH, EKS and MI field of @see enum + *attm_value_perm_mask) + * @param[in] param Configuration parameters of profile collector or + *service (32 bits aligned) * * @return status code to know if profile initialization succeed or not. **************************************************************************************** */ -static uint8_t tota_init(struct prf_task_env* env, uint16_t* start_hdl, - uint16_t app_task, uint8_t sec_lvl, void* params) -{ - uint8_t status; - //Add Service Into Database - status = attm_svc_create_db_128(start_hdl, TOTA_SERVICE_UUID_128, NULL, - TOTA_IDX_NB, NULL, env->task, &tota_att_db[0], - (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS))| PERM(SVC_MI, DISABLE) - | PERM_VAL(SVC_UUID_LEN, PERM_UUID_128)); +static uint8_t tota_init(struct prf_task_env *env, uint16_t *start_hdl, + uint16_t app_task, uint8_t sec_lvl, void *params) { + uint8_t status; + // Add Service Into Database + status = attm_svc_create_db_128( + start_hdl, TOTA_SERVICE_UUID_128, NULL, TOTA_IDX_NB, NULL, env->task, + &tota_att_db[0], + (sec_lvl & (PERM_MASK_SVC_DIS | PERM_MASK_SVC_AUTH | PERM_MASK_SVC_EKS)) | + PERM(SVC_MI, DISABLE) | PERM_VAL(SVC_UUID_LEN, PERM_UUID_128)); + BLE_GATT_DBG("attm_svc_create_db_128 returns %d start handle is %d", status, + *start_hdl); - BLE_GATT_DBG("attm_svc_create_db_128 returns %d start handle is %d", status, *start_hdl); + //-------------------- allocate memory required for the profile + //--------------------- + if (status == ATT_ERR_NO_ERROR) { + // Allocate TOTA required environment variable + struct tota_env_tag *tota_env = (struct tota_env_tag *)ke_malloc( + sizeof(struct tota_env_tag), KE_MEM_ATT_DB); - //-------------------- allocate memory required for the profile --------------------- - if (status == ATT_ERR_NO_ERROR) - { - // Allocate TOTA required environment variable - struct tota_env_tag* tota_env = - (struct tota_env_tag* ) ke_malloc(sizeof(struct tota_env_tag), KE_MEM_ATT_DB); + // Initialize TOTA environment + env->env = (prf_env_t *)tota_env; + tota_env->shdl = *start_hdl; - // Initialize TOTA environment - env->env = (prf_env_t*) tota_env; - tota_env->shdl = *start_hdl; + tota_env->prf_env.app_task = + app_task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); + // Mono Instantiated task + tota_env->prf_env.prf_task = + env->task | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) + : PERM(PRF_MI, DISABLE)); - tota_env->prf_env.app_task = app_task - | (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); - // Mono Instantiated task - tota_env->prf_env.prf_task = env->task | - (PERM_GET(sec_lvl, SVC_MI) ? PERM(PRF_MI, ENABLE) : PERM(PRF_MI, DISABLE)); + // initialize environment variable + env->id = TASK_ID_TOTA; + tota_task_init(&(env->desc)); - // initialize environment variable - env->id = TASK_ID_TOTA; - tota_task_init(&(env->desc)); + /* Put HRS in Idle state */ + ke_state_set(env->task, TOTA_IDLE); + } - /* Put HRS in Idle state */ - ke_state_set(env->task, TOTA_IDLE); - } - - return (status); + return (status); } /** **************************************************************************************** * @brief Destruction of the TOTA module - due to a reset for instance. - * This function clean-up allocated memory (attribute database is destroyed by another - * procedure) + * This function clean-up allocated memory (attribute database is destroyed by + *another procedure) * * @param[in|out] env Collector or Service allocated environment data. **************************************************************************************** */ -static void tota_destroy(struct prf_task_env* env) -{ - struct tota_env_tag* tota_env = (struct tota_env_tag*) env->env; +static void tota_destroy(struct prf_task_env *env) { + struct tota_env_tag *tota_env = (struct tota_env_tag *)env->env; - // free profile environment variables - env->env = NULL; - ke_free(tota_env); + // free profile environment variables + env->env = NULL; + ke_free(tota_env); } /** @@ -149,12 +165,10 @@ static void tota_destroy(struct prf_task_env* env) * @param[in] conidx Connection index **************************************************************************************** */ -static void tota_create(struct prf_task_env* env, uint8_t conidx) -{ - struct tota_env_tag* tota_env = (struct tota_env_tag*) env->env; - struct prf_svc tota_tota_svc = {tota_env->shdl, tota_env->shdl + TOTA_IDX_NB}; - prf_register_atthdl2gatt(env->env, conidx, &tota_tota_svc); - +static void tota_create(struct prf_task_env *env, uint8_t conidx) { + struct tota_env_tag *tota_env = (struct tota_env_tag *)env->env; + struct prf_svc tota_tota_svc = {tota_env->shdl, tota_env->shdl + TOTA_IDX_NB}; + prf_register_atthdl2gatt(env->env, conidx, &tota_tota_svc); } /** @@ -166,9 +180,9 @@ static void tota_create(struct prf_task_env* env, uint8_t conidx) * @param[in] reason Detach reason **************************************************************************************** */ -static void tota_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reason) -{ - /* Nothing to do */ +static void tota_cleanup(struct prf_task_env *env, uint8_t conidx, + uint8_t reason) { + /* Nothing to do */ } /* @@ -177,9 +191,8 @@ static void tota_cleanup(struct prf_task_env* env, uint8_t conidx, uint8_t reaso */ /// TOTA Task interface required by profile manager -const struct prf_task_cbs tota_itf = -{ - (prf_init_fnct) tota_init, +const struct prf_task_cbs tota_itf = { + (prf_init_fnct)tota_init, tota_destroy, tota_create, tota_cleanup, @@ -190,10 +203,6 @@ const struct prf_task_cbs tota_itf = **************************************************************************************** */ -const struct prf_task_cbs* tota_prf_itf_get(void) -{ - return &tota_itf; -} - +const struct prf_task_cbs *tota_prf_itf_get(void) { return &tota_itf; } #endif /* BLE_TOTA */ diff --git a/services/ble_profiles/tota/tota_task.c b/services/ble_profiles/tota/tota_task.c index cb1b013..4df0f72 100644 --- a/services/ble_profiles/tota/tota_task.c +++ b/services/ble_profiles/tota/tota_task.c @@ -14,8 +14,6 @@ * ****************************************************************************/ - - /** **************************************************************************************** * @addtogroup TOTATASK @@ -30,52 +28,50 @@ #include "rwip_config.h" #if (BLE_TOTA) -#include "gap.h" -#include "gattc_task.h" -#include "gapc_task.h" #include "attm.h" +#include "gap.h" +#include "gapc_task.h" +#include "gattc_task.h" #include "tota_ble.h" #include "tota_task.h" #include "prf_utils.h" -#include "ke_mem.h" #include "co_utils.h" +#include "ke_mem.h" /* * LOCAL FUNCTIONS DEFINITIONS **************************************************************************************** */ static int gapc_disconnect_ind_handler(ke_msg_id_t const msgid, - struct gapc_disconnect_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - TOTA_LOG_DBG(1,"[%s]TOTA",__func__); - uint8_t conidx = KE_IDX_GET(src_id); - struct tota_env_tag *tota_env = PRF_ENV_GET(TOTA, tota); - tota_env->isNotificationEnabled[conidx] = false; - return KE_MSG_CONSUMED; + struct gapc_disconnect_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + TOTA_LOG_DBG(1, "[%s]TOTA", __func__); + uint8_t conidx = KE_IDX_GET(src_id); + struct tota_env_tag *tota_env = PRF_ENV_GET(TOTA, tota); + tota_env->isNotificationEnabled[conidx] = false; + return KE_MSG_CONSUMED; } -void app_tota_send_rx_cfm(uint8_t conidx) -{ - TOTA_LOG_DBG(1,"[%s]TOTA",__func__); - struct tota_env_tag *tota_env = PRF_ENV_GET(TOTA, tota); +void app_tota_send_rx_cfm(uint8_t conidx) { + TOTA_LOG_DBG(1, "[%s]TOTA", __func__); + struct tota_env_tag *tota_env = PRF_ENV_GET(TOTA, tota); - struct gattc_write_cfm *cfm = KE_MSG_ALLOC(GATTC_WRITE_CFM, - KE_BUILD_ID(TASK_GATTC, conidx), - prf_src_task_get(&tota_env->prf_env, conidx), - gattc_write_cfm); - cfm->handle = tota_env->shdl + TOTA_IDX_VAL; - cfm->status = ATT_ERR_NO_ERROR; - ke_msg_send(cfm); + struct gattc_write_cfm *cfm = KE_MSG_ALLOC( + GATTC_WRITE_CFM, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&tota_env->prf_env, conidx), gattc_write_cfm); + cfm->handle = tota_env->shdl + TOTA_IDX_VAL; + cfm->status = ATT_ERR_NO_ERROR; + ke_msg_send(cfm); } /** **************************************************************************************** * @brief Handles reception of the @ref GL2C_CODE_ATT_WR_CMD_IND message. - * The handler compares the new values with current ones and notifies them if they changed. + * The handler compares the new values with current ones and notifies them if + *they changed. * @param[in] msgid Id of the message received (probably unused). * @param[in] param Pointer to the parameters of the message. * @param[in] dest_id ID of the receiving task instance (probably unused). @@ -83,91 +79,78 @@ void app_tota_send_rx_cfm(uint8_t conidx) * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_write_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - // Get the address of the environment - struct tota_env_tag *tota_env = PRF_ENV_GET(TOTA, tota); - uint8_t conidx = KE_IDX_GET(src_id); +__STATIC int gattc_write_req_ind_handler( + ke_msg_id_t const msgid, struct gattc_write_req_ind const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + // Get the address of the environment + struct tota_env_tag *tota_env = PRF_ENV_GET(TOTA, tota); + uint8_t conidx = KE_IDX_GET(src_id); - uint8_t status = GAP_ERR_NO_ERROR; + uint8_t status = GAP_ERR_NO_ERROR; - BLE_GATT_DBG("gattc_write_req_ind_handler tota_env 0x%x write handle %d shdl %d", - tota_env, param->handle, tota_env->shdl); + BLE_GATT_DBG( + "gattc_write_req_ind_handler tota_env 0x%x write handle %d shdl %d", + tota_env, param->handle, tota_env->shdl); - //Send write response - struct gattc_write_cfm *cfm = KE_MSG_ALLOC( - GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); - cfm->handle = param->handle; - cfm->status = status; - ke_msg_send(cfm); + // Send write response + struct gattc_write_cfm *cfm = + KE_MSG_ALLOC(GATTC_WRITE_CFM, src_id, dest_id, gattc_write_cfm); + cfm->handle = param->handle; + cfm->status = status; + ke_msg_send(cfm); - if (tota_env != NULL) - { - if (param->handle == (tota_env->shdl + TOTA_IDX_NTF_CFG)) - { - uint16_t value = 0x0000; - - //Extract value before check - memcpy(&value, &(param->value), sizeof(uint16_t)); + if (tota_env != NULL) { + if (param->handle == (tota_env->shdl + TOTA_IDX_NTF_CFG)) { + uint16_t value = 0x0000; - if (value == PRF_CLI_STOP_NTFIND) - { - tota_env->isNotificationEnabled[conidx] = false; - } - else if (value == PRF_CLI_START_NTF) - { - tota_env->isNotificationEnabled[conidx] = true; - } - else - { - status = PRF_APP_ERROR; - } + // Extract value before check + memcpy(&value, &(param->value), sizeof(uint16_t)); - if (status == GAP_ERR_NO_ERROR) - { - //Inform APP of TX ccc change - struct ble_tota_tx_notif_config_t * ind = KE_MSG_ALLOC(TOTA_CCC_CHANGED, - prf_dst_task_get(&tota_env->prf_env, conidx), - prf_src_task_get(&tota_env->prf_env, conidx), - ble_tota_tx_notif_config_t); + if (value == PRF_CLI_STOP_NTFIND) { + tota_env->isNotificationEnabled[conidx] = false; + } else if (value == PRF_CLI_START_NTF) { + tota_env->isNotificationEnabled[conidx] = true; + } else { + status = PRF_APP_ERROR; + } - ind->isNotificationEnabled = tota_env->isNotificationEnabled[conidx]; + if (status == GAP_ERR_NO_ERROR) { + // Inform APP of TX ccc change + struct ble_tota_tx_notif_config_t *ind = KE_MSG_ALLOC( + TOTA_CCC_CHANGED, prf_dst_task_get(&tota_env->prf_env, conidx), + prf_src_task_get(&tota_env->prf_env, conidx), + ble_tota_tx_notif_config_t); - ke_msg_send(ind); - } - } - else if (param->handle == (tota_env->shdl + TOTA_IDX_VAL)) - { - //inform APP of data - struct ble_tota_rx_data_ind_t * ind = KE_MSG_ALLOC_DYN(TOTA_DATA_RECEIVED, - prf_dst_task_get(&tota_env->prf_env, conidx), - prf_src_task_get(&tota_env->prf_env, conidx), - ble_tota_rx_data_ind_t, - sizeof(struct ble_tota_rx_data_ind_t) + param->length); + ind->isNotificationEnabled = tota_env->isNotificationEnabled[conidx]; - ind->length = param->length; - memcpy((uint8_t *)(ind->data), &(param->value), param->length); + ke_msg_send(ind); + } + } else if (param->handle == (tota_env->shdl + TOTA_IDX_VAL)) { + // inform APP of data + struct ble_tota_rx_data_ind_t *ind = KE_MSG_ALLOC_DYN( + TOTA_DATA_RECEIVED, prf_dst_task_get(&tota_env->prf_env, conidx), + prf_src_task_get(&tota_env->prf_env, conidx), ble_tota_rx_data_ind_t, + sizeof(struct ble_tota_rx_data_ind_t) + param->length); - ke_msg_send(ind); + ind->length = param->length; + memcpy((uint8_t *)(ind->data), &(param->value), param->length); - return KE_MSG_CONSUMED; - } - else - { - status = PRF_APP_ERROR; - } + ke_msg_send(ind); + + return KE_MSG_CONSUMED; + } else { + status = PRF_APP_ERROR; } + } - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } /** **************************************************************************************** - * @brief Handles @ref GATTC_CMP_EVT for GATTC_NOTIFY message meaning that Measurement - * notification has been correctly sent to peer device (but not confirmed by peer device). + * @brief Handles @ref GATTC_CMP_EVT for GATTC_NOTIFY message meaning that + *Measurement notification has been correctly sent to peer device (but not + *confirmed by peer device). * * * @param[in] msgid Id of the message received. * @param[in] param Pointer to the parameters of the message. @@ -176,33 +159,32 @@ __STATIC int gattc_write_req_ind_handler(ke_msg_id_t const msgid, * @return If the message was consumed or not. **************************************************************************************** */ -__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt const *param, - ke_task_id_t const dest_id, ke_task_id_t const src_id) -{ - TOTA_LOG_DBG(1,"[%s]TOTA",__func__); - // Get the address of the environment - struct tota_env_tag *tota_env = PRF_ENV_GET(TOTA, tota); +__STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, + struct gattc_cmp_evt const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + TOTA_LOG_DBG(1, "[%s]TOTA", __func__); + // Get the address of the environment + struct tota_env_tag *tota_env = PRF_ENV_GET(TOTA, tota); - uint8_t conidx = KE_IDX_GET(dest_id); - - // notification or write request has been sent out - if ((GATTC_NOTIFY == param->operation) || (GATTC_INDICATE == param->operation)) - { - - struct ble_tota_tx_sent_ind_t * ind = KE_MSG_ALLOC(TOTA_TX_DATA_SENT, - prf_dst_task_get(&tota_env->prf_env, conidx), - prf_src_task_get(&tota_env->prf_env, conidx), - ble_tota_tx_sent_ind_t); + uint8_t conidx = KE_IDX_GET(dest_id); - ind->status = param->status; + // notification or write request has been sent out + if ((GATTC_NOTIFY == param->operation) || + (GATTC_INDICATE == param->operation)) { - ke_msg_send(ind); + struct ble_tota_tx_sent_ind_t *ind = KE_MSG_ALLOC( + TOTA_TX_DATA_SENT, prf_dst_task_get(&tota_env->prf_env, conidx), + prf_src_task_get(&tota_env->prf_env, conidx), ble_tota_tx_sent_ind_t); - } + ind->status = param->status; - ke_state_set(dest_id, TOTA_IDLE); - - return (KE_MSG_CONSUMED); + ke_msg_send(ind); + } + + ke_state_set(dest_id, TOTA_IDLE); + + return (KE_MSG_CONSUMED); } /** @@ -217,134 +199,123 @@ __STATIC int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_ev **************************************************************************************** */ __STATIC int gattc_read_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_read_req_ind const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ + struct gattc_read_req_ind const *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { - TOTA_LOG_DBG(1,"[%s]TOTA",__func__); - // Get the address of the environment - struct tota_env_tag *tota_env = PRF_ENV_GET(TOTA, tota); + TOTA_LOG_DBG(1, "[%s]TOTA", __func__); + // Get the address of the environment + struct tota_env_tag *tota_env = PRF_ENV_GET(TOTA, tota); - struct gattc_read_cfm* cfm; + struct gattc_read_cfm *cfm; - uint8_t status = GAP_ERR_NO_ERROR; - uint8_t conidx = KE_IDX_GET(src_id); + uint8_t status = GAP_ERR_NO_ERROR; + uint8_t conidx = KE_IDX_GET(src_id); - BLE_GATT_DBG("gattc_read_req_ind_handler read handle %d shdl %d", param->handle, tota_env->shdl); + BLE_GATT_DBG("gattc_read_req_ind_handler read handle %d shdl %d", + param->handle, tota_env->shdl); - if (param->handle == (tota_env->shdl + TOTA_IDX_NTF_CFG)) - { - uint16_t notify_ccc; - cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, sizeof(notify_ccc)); - - if (tota_env->isNotificationEnabled[conidx]) - { - notify_ccc = 1; - } - else - { - notify_ccc = 0; - } - cfm->length = sizeof(notify_ccc); - memcpy(cfm->value, (uint8_t *)¬ify_ccc, cfm->length); - } - else - { - cfm = KE_MSG_ALLOC(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm); - cfm->length = 0; - status = ATT_ERR_REQUEST_NOT_SUPPORTED; - } + if (param->handle == (tota_env->shdl + TOTA_IDX_NTF_CFG)) { + uint16_t notify_ccc; + cfm = KE_MSG_ALLOC_DYN(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm, + sizeof(notify_ccc)); - cfm->handle = param->handle; + if (tota_env->isNotificationEnabled[conidx]) { + notify_ccc = 1; + } else { + notify_ccc = 0; + } + cfm->length = sizeof(notify_ccc); + memcpy(cfm->value, (uint8_t *)¬ify_ccc, cfm->length); + } else { + cfm = KE_MSG_ALLOC(GATTC_READ_CFM, src_id, dest_id, gattc_read_cfm); + cfm->length = 0; + status = ATT_ERR_REQUEST_NOT_SUPPORTED; + } - cfm->status = status; + cfm->handle = param->handle; - ke_msg_send(cfm); + cfm->status = status; - ke_state_set(dest_id, TOTA_IDLE); + ke_msg_send(cfm); - return (KE_MSG_CONSUMED); + ke_state_set(dest_id, TOTA_IDLE); + + return (KE_MSG_CONSUMED); } -static void send_notifiction(uint8_t conidx, const uint8_t* ptrData, uint32_t length) -{ - uint16_t handle_offset = 0xFFFF; - struct tota_env_tag *tota_env = PRF_ENV_GET(TOTA, tota); +static void send_notifiction(uint8_t conidx, const uint8_t *ptrData, + uint32_t length) { + uint16_t handle_offset = 0xFFFF; + struct tota_env_tag *tota_env = PRF_ENV_GET(TOTA, tota); - if (tota_env->isNotificationEnabled[conidx]) - { - handle_offset = TOTA_IDX_VAL; - } + if (tota_env->isNotificationEnabled[conidx]) { + handle_offset = TOTA_IDX_VAL; + } - TRACE(1,"Send tota notificationto handle offset %d:", handle_offset); + TRACE(1, "Send tota notificationto handle offset %d:", handle_offset); - if (0xFFFF != handle_offset) - { - // Allocate the GATT notification message - struct gattc_send_evt_cmd *report_ntf = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(&tota_env->prf_env, conidx), - gattc_send_evt_cmd, length); + if (0xFFFF != handle_offset) { + // Allocate the GATT notification message + struct gattc_send_evt_cmd *report_ntf = + KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&tota_env->prf_env, conidx), + gattc_send_evt_cmd, length); - // Fill in the parameter structure - report_ntf->operation = GATTC_NOTIFY; - report_ntf->handle = tota_env->shdl + handle_offset; - // pack measured value in database - report_ntf->length = length; - memcpy(report_ntf->value, ptrData, length); - // send notification to peer device - ke_msg_send(report_ntf); - } + // Fill in the parameter structure + report_ntf->operation = GATTC_NOTIFY; + report_ntf->handle = tota_env->shdl + handle_offset; + // pack measured value in database + report_ntf->length = length; + memcpy(report_ntf->value, ptrData, length); + // send notification to peer device + ke_msg_send(report_ntf); + } } -static void send_indication(uint8_t conidx, const uint8_t* ptrData, uint32_t length) -{ - uint16_t handle_offset = 0xFFFF; - struct tota_env_tag *tota_env = PRF_ENV_GET(TOTA, tota); - if (tota_env->isNotificationEnabled[conidx]) - { - handle_offset = TOTA_IDX_VAL; - } +static void send_indication(uint8_t conidx, const uint8_t *ptrData, + uint32_t length) { + uint16_t handle_offset = 0xFFFF; + struct tota_env_tag *tota_env = PRF_ENV_GET(TOTA, tota); + if (tota_env->isNotificationEnabled[conidx]) { + handle_offset = TOTA_IDX_VAL; + } - TRACE(1,"Send tota indicationto handle offset %d:", handle_offset); + TRACE(1, "Send tota indicationto handle offset %d:", handle_offset); - if (0xFFFF != handle_offset) - { - // Allocate the GATT notification message - struct gattc_send_evt_cmd *report_ntf = KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, - KE_BUILD_ID(TASK_GATTC, conidx), prf_src_task_get(&tota_env->prf_env, conidx), - gattc_send_evt_cmd, length); + if (0xFFFF != handle_offset) { + // Allocate the GATT notification message + struct gattc_send_evt_cmd *report_ntf = + KE_MSG_ALLOC_DYN(GATTC_SEND_EVT_CMD, KE_BUILD_ID(TASK_GATTC, conidx), + prf_src_task_get(&tota_env->prf_env, conidx), + gattc_send_evt_cmd, length); - // Fill in the parameter structure - report_ntf->operation = GATTC_INDICATE; - report_ntf->handle = tota_env->shdl + handle_offset; - // pack measured value in database - report_ntf->length = length; - memcpy(report_ntf->value, ptrData, length); - // send notification to peer device - ke_msg_send(report_ntf); - } + // Fill in the parameter structure + report_ntf->operation = GATTC_INDICATE; + report_ntf->handle = tota_env->shdl + handle_offset; + // pack measured value in database + report_ntf->length = length; + memcpy(report_ntf->value, ptrData, length); + // send notification to peer device + ke_msg_send(report_ntf); + } } -__STATIC int send_notification_handler(ke_msg_id_t const msgid, - struct ble_tota_send_data_req_t const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - send_notifiction(param->connecionIndex, param->value, param->length); - return (KE_MSG_CONSUMED); +__STATIC int send_notification_handler( + ke_msg_id_t const msgid, struct ble_tota_send_data_req_t const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + send_notifiction(param->connecionIndex, param->value, param->length); + return (KE_MSG_CONSUMED); } -__STATIC int send_indication_handler(ke_msg_id_t const msgid, - struct ble_tota_send_data_req_t const *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - send_indication(param->connecionIndex, param->value, param->length); - return (KE_MSG_CONSUMED); +__STATIC int +send_indication_handler(ke_msg_id_t const msgid, + struct ble_tota_send_data_req_t const *param, + ke_task_id_t const dest_id, ke_task_id_t const src_id) { + send_indication(param->connecionIndex, param->value, param->length); + return (KE_MSG_CONSUMED); } - /** **************************************************************************************** * @brief Handles reception of the attribute info request message. @@ -357,70 +328,61 @@ __STATIC int send_indication_handler(ke_msg_id_t const msgid, **************************************************************************************** */ static int gattc_att_info_req_ind_handler(ke_msg_id_t const msgid, - struct gattc_att_info_req_ind *param, - ke_task_id_t const dest_id, - ke_task_id_t const src_id) -{ - TOTA_LOG_DBG(1,"[%s]TOTA",__func__); - // Get the address of the environment - struct gattc_att_info_cfm * cfm; + struct gattc_att_info_req_ind *param, + ke_task_id_t const dest_id, + ke_task_id_t const src_id) { + TOTA_LOG_DBG(1, "[%s]TOTA", __func__); + // Get the address of the environment + struct gattc_att_info_cfm *cfm; - //Send write response - cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); - cfm->handle = param->handle; + // Send write response + cfm = KE_MSG_ALLOC(GATTC_ATT_INFO_CFM, src_id, dest_id, gattc_att_info_cfm); + cfm->handle = param->handle; - struct tota_env_tag *tota_env = PRF_ENV_GET(TOTA, tota); + struct tota_env_tag *tota_env = PRF_ENV_GET(TOTA, tota); - if (param->handle == (tota_env->shdl + TOTA_IDX_NTF_CFG)) - { - // CCC attribute length = 2 - cfm->length = 2; - cfm->status = GAP_ERR_NO_ERROR; - } - else if (param->handle == (tota_env->shdl + TOTA_IDX_VAL)) - { - // force length to zero to reject any write starting from something != 0 - cfm->length = 0; - cfm->status = GAP_ERR_NO_ERROR; - } - else - { - cfm->length = 0; - cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; - } + if (param->handle == (tota_env->shdl + TOTA_IDX_NTF_CFG)) { + // CCC attribute length = 2 + cfm->length = 2; + cfm->status = GAP_ERR_NO_ERROR; + } else if (param->handle == (tota_env->shdl + TOTA_IDX_VAL)) { + // force length to zero to reject any write starting from something != 0 + cfm->length = 0; + cfm->status = GAP_ERR_NO_ERROR; + } else { + cfm->length = 0; + cfm->status = ATT_ERR_WRITE_NOT_PERMITTED; + } - ke_msg_send(cfm); + ke_msg_send(cfm); - return (KE_MSG_CONSUMED); + return (KE_MSG_CONSUMED); } - /* * GLOBAL VARIABLE DEFINITIONS **************************************************************************************** */ /* Default State handlers definition. */ -KE_MSG_HANDLER_TAB(tota) -{ - {GAPC_DISCONNECT_IND, (ke_msg_func_t) gapc_disconnect_ind_handler}, - {GATTC_WRITE_REQ_IND, (ke_msg_func_t) gattc_write_req_ind_handler}, - {GATTC_CMP_EVT, (ke_msg_func_t) gattc_cmp_evt_handler}, - {GATTC_READ_REQ_IND, (ke_msg_func_t) gattc_read_req_ind_handler}, - {TOTA_SEND_NOTIFICATION, (ke_msg_func_t) send_notification_handler}, - {TOTA_SEND_INDICATION, (ke_msg_func_t) send_indication_handler}, - {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t) gattc_att_info_req_ind_handler }, +KE_MSG_HANDLER_TAB(tota){ + {GAPC_DISCONNECT_IND, (ke_msg_func_t)gapc_disconnect_ind_handler}, + {GATTC_WRITE_REQ_IND, (ke_msg_func_t)gattc_write_req_ind_handler}, + {GATTC_CMP_EVT, (ke_msg_func_t)gattc_cmp_evt_handler}, + {GATTC_READ_REQ_IND, (ke_msg_func_t)gattc_read_req_ind_handler}, + {TOTA_SEND_NOTIFICATION, (ke_msg_func_t)send_notification_handler}, + {TOTA_SEND_INDICATION, (ke_msg_func_t)send_indication_handler}, + {GATTC_ATT_INFO_REQ_IND, (ke_msg_func_t)gattc_att_info_req_ind_handler}, }; -void tota_task_init(struct ke_task_desc *task_desc) -{ - // Get the address of the environment - struct tota_env_tag *tota_env = PRF_ENV_GET(TOTA, tota); +void tota_task_init(struct ke_task_desc *task_desc) { + // Get the address of the environment + struct tota_env_tag *tota_env = PRF_ENV_GET(TOTA, tota); - task_desc->msg_handler_tab = tota_msg_handler_tab; - task_desc->msg_cnt = ARRAY_LEN(tota_msg_handler_tab); - task_desc->state = &(tota_env->state); - task_desc->idx_max = BLE_CONNECTION_MAX; + task_desc->msg_handler_tab = tota_msg_handler_tab; + task_desc->msg_cnt = ARRAY_LEN(tota_msg_handler_tab); + task_desc->state = &(tota_env->state); + task_desc->idx_max = BLE_CONNECTION_MAX; } #endif /* #if (BLE_TOTA) */ diff --git a/services/bt_app/a2dp_codecs/aac/a2dp_codec_aac.cpp b/services/bt_app/a2dp_codecs/aac/a2dp_codec_aac.cpp index b18ea18..985a421 100644 --- a/services/bt_app/a2dp_codecs/aac/a2dp_codec_aac.cpp +++ b/services/bt_app/a2dp_codecs/aac/a2dp_codec_aac.cpp @@ -13,24 +13,24 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "cmsis_os.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_trace.h" -#include "hal_cmu.h" +#include "a2dp_api.h" #include "analog.h" #include "app.h" -#include "bt_drv.h" #include "app_audio.h" +#include "audioflinger.h" #include "bluetooth.h" -#include "nvrecord.h" -#include "nvrecord_env.h" -#include "nvrecord_dev.h" +#include "bt_drv.h" +#include "cmsis_os.h" +#include "hal_cmu.h" #include "hal_location.h" -#include "a2dp_api.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "lockcqueue.h" +#include "nvrecord.h" +#include "nvrecord_dev.h" +#include "nvrecord_env.h" +#include #if defined(NEW_NV_RECORD_ENABLED) #include "nvrecord_bt.h" #endif @@ -39,70 +39,71 @@ #include "avrcp_api.h" #include "besbt.h" -#include "cqueue.h" -#include "btapp.h" #include "app_bt.h" -#include "apps.h" -#include "resources.h" #include "app_bt_media_manager.h" -#include "tgt_hardware.h" +#include "apps.h" #include "bt_drv_interface.h" +#include "btapp.h" +#include "cqueue.h" #include "hci_api.h" +#include "resources.h" +#include "tgt_hardware.h" #include "a2dp_codec_aac.h" #include "avdtp_api.h" -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; #if defined(A2DP_AAC_ON) #ifdef __A2DP_AVDTP_CP__ btif_avdtp_content_prot_t a2dp_aac_avdtpCp[BT_DEVICE_NUM]; -U8 a2dp_avdtpCp_aac_securityData[BT_DEVICE_NUM][ BTIF_AVDTP_MAX_CP_VALUE_SIZE] = {}; +U8 a2dp_avdtpCp_aac_securityData[BT_DEVICE_NUM][BTIF_AVDTP_MAX_CP_VALUE_SIZE] = + {}; #endif btif_avdtp_codec_t a2dp_aac_avdtpcodec; const unsigned char a2dp_codec_aac_elements[A2DP_AAC_OCTET_NUMBER] = { - A2DP_AAC_OCTET0_MPEG2_AAC_LC, - A2DP_AAC_OCTET1_SAMPLING_FREQUENCY_44100, - A2DP_AAC_OCTET2_CHANNELS_1 | A2DP_AAC_OCTET2_CHANNELS_2 | A2DP_AAC_OCTET2_SAMPLING_FREQUENCY_48000, + A2DP_AAC_OCTET0_MPEG2_AAC_LC, A2DP_AAC_OCTET1_SAMPLING_FREQUENCY_44100, + A2DP_AAC_OCTET2_CHANNELS_1 | A2DP_AAC_OCTET2_CHANNELS_2 | + A2DP_AAC_OCTET2_SAMPLING_FREQUENCY_48000, A2DP_AAC_OCTET3_VBR_SUPPORTED | ((MAX_AAC_BITRATE >> 16) & 0x7f), /* left bit rate 0 for unkown */ - (MAX_AAC_BITRATE >> 8) & 0xff, - (MAX_AAC_BITRATE) & 0xff -}; + (MAX_AAC_BITRATE >> 8) & 0xff, (MAX_AAC_BITRATE)&0xff}; - -btif_avdtp_codec_t *app_a2dp_codec_get_aac_avdtp_codec() -{ - return (btif_avdtp_codec_t *)&a2dp_aac_avdtpcodec; +btif_avdtp_codec_t *app_a2dp_codec_get_aac_avdtp_codec() { + return (btif_avdtp_codec_t *)&a2dp_aac_avdtpcodec; } -bt_status_t a2dp_codec_aac_init(int index) -{ - bt_status_t st; - struct BT_DEVICE_T *bt_dev = &app_bt_device; +bt_status_t a2dp_codec_aac_init(int index) { + bt_status_t st; + struct BT_DEVICE_T *bt_dev = &app_bt_device; #ifdef __A2DP_AVDTP_CP__ - a2dp_aac_avdtpCp[index].cpType = BTIF_AVDTP_CP_TYPE_SCMS_T; - a2dp_aac_avdtpCp[index].data = (U8 *)&a2dp_avdtpCp_aac_securityData[index][0]; - a2dp_aac_avdtpCp[index].dataLen = 0; + a2dp_aac_avdtpCp[index].cpType = BTIF_AVDTP_CP_TYPE_SCMS_T; + a2dp_aac_avdtpCp[index].data = (U8 *)&a2dp_avdtpCp_aac_securityData[index][0]; + a2dp_aac_avdtpCp[index].dataLen = 0; #endif - a2dp_aac_avdtpcodec.codecType = BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC; - a2dp_aac_avdtpcodec.discoverable = 1; - a2dp_aac_avdtpcodec.elements = (U8 *)&a2dp_codec_aac_elements; - a2dp_aac_avdtpcodec.elemLen = sizeof(a2dp_codec_aac_elements); + a2dp_aac_avdtpcodec.codecType = BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC; + a2dp_aac_avdtpcodec.discoverable = 1; + a2dp_aac_avdtpcodec.elements = (U8 *)&a2dp_codec_aac_elements; + a2dp_aac_avdtpcodec.elemLen = sizeof(a2dp_codec_aac_elements); #ifdef __A2DP_AVDTP_CP__ - st = btif_a2dp_register(bt_dev->a2dp_aac_stream[index]->a2dp_stream, BTIF_A2DP_STREAM_TYPE_SINK, &a2dp_aac_avdtpcodec,&a2dp_aac_avdtpCp[index], 1, index,a2dp_callback); - btif_a2dp_add_content_protection(bt_dev->a2dp_aac_stream[index]->a2dp_stream, &a2dp_aac_avdtpCp[index]); + st = btif_a2dp_register(bt_dev->a2dp_aac_stream[index]->a2dp_stream, + BTIF_A2DP_STREAM_TYPE_SINK, &a2dp_aac_avdtpcodec, + &a2dp_aac_avdtpCp[index], 1, index, a2dp_callback); + btif_a2dp_add_content_protection(bt_dev->a2dp_aac_stream[index]->a2dp_stream, + &a2dp_aac_avdtpCp[index]); #else - st = btif_a2dp_register(bt_dev->a2dp_aac_stream[index]->a2dp_stream, BTIF_A2DP_STREAM_TYPE_SINK, &a2dp_aac_avdtpcodec, NULL, 1,index, a2dp_callback); + st = btif_a2dp_register(bt_dev->a2dp_aac_stream[index]->a2dp_stream, + BTIF_A2DP_STREAM_TYPE_SINK, &a2dp_aac_avdtpcodec, + NULL, 1, index, a2dp_callback); #endif - return st; + return st; } #endif /* A2DP_AAC_ON */ diff --git a/services/bt_app/a2dp_codecs/app_a2dp_codecs.cpp b/services/bt_app/a2dp_codecs/app_a2dp_codecs.cpp index 1e3ee04..34bcce1 100644 --- a/services/bt_app/a2dp_codecs/app_a2dp_codecs.cpp +++ b/services/bt_app/a2dp_codecs/app_a2dp_codecs.cpp @@ -13,24 +13,24 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "cmsis_os.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_trace.h" -#include "hal_cmu.h" +#include "a2dp_api.h" #include "analog.h" #include "app.h" -#include "bt_drv.h" #include "app_audio.h" +#include "audioflinger.h" #include "bluetooth.h" -#include "nvrecord.h" -#include "nvrecord_env.h" -#include "nvrecord_dev.h" +#include "bt_drv.h" +#include "cmsis_os.h" +#include "hal_cmu.h" #include "hal_location.h" -#include "a2dp_api.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "lockcqueue.h" +#include "nvrecord.h" +#include "nvrecord_dev.h" +#include "nvrecord_env.h" +#include #if defined(NEW_NV_RECORD_ENABLED) #include "nvrecord_bt.h" #endif @@ -39,203 +39,197 @@ #include "avrcp_api.h" #include "besbt.h" -#include "cqueue.h" #include "app_bt.h" -#include "apps.h" -#include "resources.h" #include "app_bt_media_manager.h" -#include "tgt_hardware.h" +#include "apps.h" #include "bt_drv_interface.h" +#include "cqueue.h" #include "hci_api.h" +#include "resources.h" +#include "tgt_hardware.h" #define _FILE_TAG_ "A2DP" -#include "color_log.h" #include "app_bt_func.h" +#include "color_log.h" #include "os_api.h" #if (A2DP_DECODER_VER >= 2) #include "a2dp_decoder.h" #endif -#include "btapp.h" -#include "app_a2dp_codecs.h" #include "app_a2dp.h" +#include "app_a2dp_codecs.h" +#include "btapp.h" -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; -int a2dp_codec_source_init(void) -{ - struct BT_DEVICE_T POSSIBLY_UNUSED *bt_dev = &app_bt_device; +int a2dp_codec_source_init(void) { + struct BT_DEVICE_T POSSIBLY_UNUSED *bt_dev = &app_bt_device; -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) - if(bt_dev->src_or_snk == BT_DEVICE_SRC) - { - a2dp_avdtpcodec.codecType = BTIF_AVDTP_CODEC_TYPE_SBC; - a2dp_avdtpcodec.discoverable = 1; - a2dp_avdtpcodec.elements = (U8 *)&a2dp_codec_elements; - a2dp_avdtpcodec.elemLen = 4; - btif_a2dp_register(bt_dev->a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream, BTIF_A2DP_STREAM_TYPE_SOURCE, &a2dp_avdtpcodec, NULL, 0,0, a2dp_callback); - } +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) + if (bt_dev->src_or_snk == BT_DEVICE_SRC) { + a2dp_avdtpcodec.codecType = BTIF_AVDTP_CODEC_TYPE_SBC; + a2dp_avdtpcodec.discoverable = 1; + a2dp_avdtpcodec.elements = (U8 *)&a2dp_codec_elements; + a2dp_avdtpcodec.elemLen = 4; + btif_a2dp_register(bt_dev->a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream, + BTIF_A2DP_STREAM_TYPE_SOURCE, &a2dp_avdtpcodec, NULL, 0, + 0, a2dp_callback); + } #endif - return 0; + return 0; } -int a2dp_codec_sink_init(void) -{ - int i; - struct BT_DEVICE_T POSSIBLY_UNUSED *bt_dev = &app_bt_device; +int a2dp_codec_sink_init(void) { + int i; + struct BT_DEVICE_T POSSIBLY_UNUSED *bt_dev = &app_bt_device; -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) - if(bt_dev->src_or_snk != BT_DEVICE_SRC) +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) + if (bt_dev->src_or_snk != BT_DEVICE_SRC) #endif - { - for(i = 0; i < BT_DEVICE_NUM; i++) - { - a2dp_codec_sbc_init(i); + { + for (i = 0; i < BT_DEVICE_NUM; i++) { + a2dp_codec_sbc_init(i); #if defined(A2DP_AAC_ON) - a2dp_codec_aac_init(i); + a2dp_codec_aac_init(i); #endif #if defined(A2DP_LDAC_ON) - a2dp_codec_ldac_init(i); + a2dp_codec_ldac_init(i); #endif #if defined(A2DP_LHDC_ON) - a2dp_codec_lhdc_init(i); + a2dp_codec_lhdc_init(i); #endif #if defined(MASTER_USE_OPUS) || defined(ALL_USE_OPUS) - a2dp_codec_opus_init(i); + a2dp_codec_opus_init(i); #endif #if defined(A2DP_SCALABLE_ON) - a2dp_codec_scalable_init(i); + a2dp_codec_scalable_init(i); #endif - } } + } - return 0; + return 0; } -uint8_t a2dp_codec_confirm_stream_state(uint8_t index, uint8_t old_state, uint8_t new_state) -{ - btif_a2dp_confirm_stream_state(app_bt_device.a2dp_stream[index]->a2dp_stream, old_state, new_state); +uint8_t a2dp_codec_confirm_stream_state(uint8_t index, uint8_t old_state, + uint8_t new_state) { + btif_a2dp_confirm_stream_state(app_bt_device.a2dp_stream[index]->a2dp_stream, + old_state, new_state); #if defined(A2DP_AAC_ON) - btif_a2dp_confirm_stream_state(app_bt_device.a2dp_aac_stream[index]->a2dp_stream, old_state, new_state); + btif_a2dp_confirm_stream_state( + app_bt_device.a2dp_aac_stream[index]->a2dp_stream, old_state, new_state); #endif #if defined(A2DP_LHDC_ON) - btif_a2dp_confirm_stream_state(app_bt_device.a2dp_lhdc_stream[index]->a2dp_stream, old_state, new_state); + btif_a2dp_confirm_stream_state( + app_bt_device.a2dp_lhdc_stream[index]->a2dp_stream, old_state, new_state); #endif #if defined(A2DP_SCALABLE_ON) - btif_a2dp_confirm_stream_state(app_bt_device.a2dp_scalable_stream[index]->a2dp_stream, old_state, new_state); + btif_a2dp_confirm_stream_state( + app_bt_device.a2dp_scalable_stream[index]->a2dp_stream, old_state, + new_state); #endif #if defined(A2DP_LDAC_ON) - btif_a2dp_confirm_stream_state(app_bt_device.a2dp_ldac_stream[index]->a2dp_stream, old_state, new_state); + btif_a2dp_confirm_stream_state( + app_bt_device.a2dp_ldac_stream[index]->a2dp_stream, old_state, new_state); #endif - return 0; + return 0; } -static void a2dp_set_codec_info(btif_dev_it_e dev_num, const uint8_t *codec) -{ - app_bt_device.codec_type[dev_num] = codec[0]; - app_bt_device.sample_bit[dev_num] = codec[1]; - app_bt_device.sample_rate[dev_num]= codec[2]; +static void a2dp_set_codec_info(btif_dev_it_e dev_num, const uint8_t *codec) { + app_bt_device.codec_type[dev_num] = codec[0]; + app_bt_device.sample_bit[dev_num] = codec[1]; + app_bt_device.sample_rate[dev_num] = codec[2]; #if defined(A2DP_LHDC_ON) - app_bt_device.a2dp_lhdc_llc[dev_num] = codec[3]; + app_bt_device.a2dp_lhdc_llc[dev_num] = codec[3]; #endif #if defined(A2DP_LDAC_ON) - app_ibrt_restore_ldac_info(app_bt_device.sample_rate[dev_num]); + app_ibrt_restore_ldac_info(app_bt_device.sample_rate[dev_num]); #endif - } -static void a2dp_get_codec_info(btif_dev_it_e dev_num, uint8_t *codec) -{ - codec[0] = app_bt_device.codec_type[dev_num]; - codec[1] = app_bt_device.sample_bit[dev_num]; - codec[2] = app_bt_device.sample_rate[dev_num]; +static void a2dp_get_codec_info(btif_dev_it_e dev_num, uint8_t *codec) { + codec[0] = app_bt_device.codec_type[dev_num]; + codec[1] = app_bt_device.sample_bit[dev_num]; + codec[2] = app_bt_device.sample_rate[dev_num]; #if defined(A2DP_LHDC_ON) - codec[3] = app_bt_device.a2dp_lhdc_llc[dev_num]; + codec[3] = app_bt_device.a2dp_lhdc_llc[dev_num]; #endif } -int a2dp_codec_init(void) -{ - a2dp_codec_source_init(); - a2dp_codec_sink_init(); - btif_a2dp_get_codec_info_func(a2dp_get_codec_info); - btif_a2dp_set_codec_info_func(a2dp_set_codec_info); - return 0; +int a2dp_codec_init(void) { + a2dp_codec_source_init(); + a2dp_codec_sink_init(); + btif_a2dp_get_codec_info_func(a2dp_get_codec_info); + btif_a2dp_set_codec_info_func(a2dp_set_codec_info); + return 0; } -btif_avdtp_codec_t * app_a2dp_codec_get_avdtp_codec() -{ - return (btif_avdtp_codec_t *)&a2dp_avdtpcodec; +btif_avdtp_codec_t *app_a2dp_codec_get_avdtp_codec() { + return (btif_avdtp_codec_t *)&a2dp_avdtpcodec; } #if defined(IBRT) enum AUD_SAMPRATE_T bt_parse_sbc_sample_rate(uint8_t sbc_samp_rate); -uint32_t app_a2dp_codec_parse_aac_sample_rate(const a2dp_callback_parms_t *info) -{ - uint32_t ret_sample_rate = AUD_SAMPRATE_44100; - btif_a2dp_callback_parms_t *p_info = (btif_a2dp_callback_parms_t *) info; +uint32_t +app_a2dp_codec_parse_aac_sample_rate(const a2dp_callback_parms_t *info) { + uint32_t ret_sample_rate = AUD_SAMPRATE_44100; + btif_a2dp_callback_parms_t *p_info = (btif_a2dp_callback_parms_t *)info; - if (p_info->p.configReq->codec.elements[1] & A2DP_AAC_OCTET1_SAMPLING_FREQUENCY_44100) - { - ret_sample_rate = AUD_SAMPRATE_44100; - } - else if (p_info->p.configReq->codec.elements[2] & A2DP_AAC_OCTET2_SAMPLING_FREQUENCY_48000) - { - ret_sample_rate = AUD_SAMPRATE_48000; - } - return ret_sample_rate; + if (p_info->p.configReq->codec.elements[1] & + A2DP_AAC_OCTET1_SAMPLING_FREQUENCY_44100) { + ret_sample_rate = AUD_SAMPRATE_44100; + } else if (p_info->p.configReq->codec.elements[2] & + A2DP_AAC_OCTET2_SAMPLING_FREQUENCY_48000) { + ret_sample_rate = AUD_SAMPRATE_48000; + } + return ret_sample_rate; } -uint32_t app_a2dp_codec_parse_aac_lhdc_sample_rate(const a2dp_callback_parms_t * info) -{ - btif_a2dp_callback_parms_t *p_info = (btif_a2dp_callback_parms_t *) info; +uint32_t +app_a2dp_codec_parse_aac_lhdc_sample_rate(const a2dp_callback_parms_t *info) { + btif_a2dp_callback_parms_t *p_info = (btif_a2dp_callback_parms_t *)info; - switch (A2DP_LHDC_SR_DATA(p_info->p.configReq->codec.elements[6])) - { - case A2DP_LHDC_SR_96000: - return AUD_SAMPRATE_96000; - case A2DP_LHDC_SR_48000: - return AUD_SAMPRATE_48000; - case A2DP_LHDC_SR_44100: - return AUD_SAMPRATE_44100; - default: - return AUD_SAMPRATE_44100; - } + switch (A2DP_LHDC_SR_DATA(p_info->p.configReq->codec.elements[6])) { + case A2DP_LHDC_SR_96000: + return AUD_SAMPRATE_96000; + case A2DP_LHDC_SR_48000: + return AUD_SAMPRATE_48000; + case A2DP_LHDC_SR_44100: + return AUD_SAMPRATE_44100; + default: + return AUD_SAMPRATE_44100; + } } -uint32_t app_a2dp_codec_get_sample_rate(const a2dp_callback_parms_t *info) -{ - btif_a2dp_callback_parms_t *p_info = (btif_a2dp_callback_parms_t *) info; - btif_avdtp_codec_type_t codetype = btif_a2dp_get_codec_type((const a2dp_callback_parms_t *)p_info); +uint32_t app_a2dp_codec_get_sample_rate(const a2dp_callback_parms_t *info) { + btif_a2dp_callback_parms_t *p_info = (btif_a2dp_callback_parms_t *)info; + btif_avdtp_codec_type_t codetype = + btif_a2dp_get_codec_type((const a2dp_callback_parms_t *)p_info); - switch(codetype) - { - case BTIF_AVDTP_CODEC_TYPE_SBC: - return bt_parse_sbc_sample_rate(p_info->p.configReq->codec.elements[0]); - case BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC: - return app_a2dp_codec_parse_aac_sample_rate((const a2dp_callback_parms_t *)p_info); - case BTIF_AVDTP_CODEC_TYPE_LHDC: - return app_a2dp_codec_parse_aac_lhdc_sample_rate((const a2dp_callback_parms_t *)p_info); - default: - ASSERT(0,"btif_a2dp_get_sample_rate codetype error!!"); - return 0; - } + switch (codetype) { + case BTIF_AVDTP_CODEC_TYPE_SBC: + return bt_parse_sbc_sample_rate(p_info->p.configReq->codec.elements[0]); + case BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC: + return app_a2dp_codec_parse_aac_sample_rate( + (const a2dp_callback_parms_t *)p_info); + case BTIF_AVDTP_CODEC_TYPE_LHDC: + return app_a2dp_codec_parse_aac_lhdc_sample_rate( + (const a2dp_callback_parms_t *)p_info); + default: + ASSERT(0, "btif_a2dp_get_sample_rate codetype error!!"); + return 0; + } } -uint8_t app_a2dp_codec_get_sample_bit(const a2dp_callback_parms_t *info) -{ - btif_avdtp_codec_type_t codetype = btif_a2dp_get_codec_type(info); - btif_a2dp_callback_parms_t *p_info = (btif_a2dp_callback_parms_t *) info; +uint8_t app_a2dp_codec_get_sample_bit(const a2dp_callback_parms_t *info) { + btif_avdtp_codec_type_t codetype = btif_a2dp_get_codec_type(info); + btif_a2dp_callback_parms_t *p_info = (btif_a2dp_callback_parms_t *)info; - if ((codetype == BTIF_AVDTP_CODEC_TYPE_LHDC) && - A2DP_LHDC_FMT_DATA(p_info->p.configReq->codec.elements[6])) - { - return 24; - } - else - { - //AAC and SBC sample bit eq 16 - return 16; - } + if ((codetype == BTIF_AVDTP_CODEC_TYPE_LHDC) && + A2DP_LHDC_FMT_DATA(p_info->p.configReq->codec.elements[6])) { + return 24; + } else { + // AAC and SBC sample bit eq 16 + return 16; + } } #endif diff --git a/services/bt_app/a2dp_codecs/ldac/a2dp_codec_ldac.cpp b/services/bt_app/a2dp_codecs/ldac/a2dp_codec_ldac.cpp index 3bdd5cc..d298ace 100644 --- a/services/bt_app/a2dp_codecs/ldac/a2dp_codec_ldac.cpp +++ b/services/bt_app/a2dp_codecs/ldac/a2dp_codec_ldac.cpp @@ -13,24 +13,24 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "cmsis_os.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_trace.h" -#include "hal_cmu.h" +#include "a2dp_api.h" #include "analog.h" #include "app.h" -#include "bt_drv.h" #include "app_audio.h" +#include "audioflinger.h" #include "bluetooth.h" -#include "nvrecord.h" -#include "nvrecord_env.h" -#include "nvrecord_dev.h" +#include "bt_drv.h" +#include "cmsis_os.h" +#include "hal_cmu.h" #include "hal_location.h" -#include "a2dp_api.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "lockcqueue.h" +#include "nvrecord.h" +#include "nvrecord_dev.h" +#include "nvrecord_env.h" +#include #if defined(NEW_NV_RECORD_ENABLED) #include "nvrecord_bt.h" #endif @@ -39,51 +39,62 @@ #include "avrcp_api.h" #include "besbt.h" -#include "cqueue.h" -#include "btapp.h" #include "app_bt.h" -#include "apps.h" -#include "resources.h" #include "app_bt_media_manager.h" -#include "tgt_hardware.h" +#include "apps.h" #include "bt_drv_interface.h" +#include "btapp.h" +#include "cqueue.h" #include "hci_api.h" +#include "resources.h" +#include "tgt_hardware.h" #include "a2dp_codec_ldac.h" #include "avdtp_api.h" -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; #if defined(A2DP_LDAC_ON) static btif_avdtp_codec_t a2dp_ldac_avdtpcodec; -const unsigned char a2dp_codec_ldac_elements[A2DP_LDAC_OCTET_NUMBER] = -{ - 0x2d, 0x01, 0x00, 0x00, //Vendor ID - 0xaa, 0x00, //Codec ID - (A2DP_LDAC_SR_96000|A2DP_LDAC_SR_88200|A2DP_LDAC_SR_48000 |A2DP_LDAC_SR_44100), -// (A2DP_LDAC_SR_48000 |A2DP_LDAC_SR_44100), - (A2DP_LDAC_CM_MONO|A2DP_LDAC_CM_DUAL|A2DP_LDAC_CM_STEREO), +const unsigned char a2dp_codec_ldac_elements[A2DP_LDAC_OCTET_NUMBER] = { + 0x2d, + 0x01, + 0x00, + 0x00, // Vendor ID + 0xaa, + 0x00, // Codec ID + (A2DP_LDAC_SR_96000 | A2DP_LDAC_SR_88200 | A2DP_LDAC_SR_48000 | + A2DP_LDAC_SR_44100), + // (A2DP_LDAC_SR_48000 |A2DP_LDAC_SR_44100), + (A2DP_LDAC_CM_MONO | A2DP_LDAC_CM_DUAL | A2DP_LDAC_CM_STEREO), }; -bt_status_t a2dp_codec_ldac_init(int index) -{ - bt_status_t st; +bt_status_t a2dp_codec_ldac_init(int index) { + bt_status_t st; - struct BT_DEVICE_T *bt_dev = &app_bt_device; + struct BT_DEVICE_T *bt_dev = &app_bt_device; - a2dp_ldac_avdtpcodec.codecType = BTIF_AVDTP_CODEC_TYPE_NON_A2DP; - a2dp_ldac_avdtpcodec.discoverable = 1; - a2dp_ldac_avdtpcodec.elements = (U8 *)&a2dp_codec_ldac_elements; - a2dp_ldac_avdtpcodec.elemLen = sizeof(a2dp_codec_ldac_elements); - TRACE(1,"a2dp_ldac_avdtpcodec.elemLen = %d \n", a2dp_ldac_avdtpcodec.elemLen); - TRACE(7,"a2dp_ldac_avdtpcodec.elements->[0]=0x%02x,[1]=0x%02x,[2]=0x%02x,[3]=0x%02x,[4]=0x%02x,[5]=0x%02x,[6]=0x%02x,\n", \ - a2dp_ldac_avdtpcodec.elements[0], a2dp_ldac_avdtpcodec.elements[1], a2dp_ldac_avdtpcodec.elements[2], a2dp_ldac_avdtpcodec.elements[3], - a2dp_ldac_avdtpcodec.elements[4], a2dp_ldac_avdtpcodec.elements[5], a2dp_ldac_avdtpcodec.elements[6]); - TRACE(1,"a2dp_ldac_avdtpcodec.elements->[7]=0x%02x,\n", a2dp_ldac_avdtpcodec.elements[7]); + a2dp_ldac_avdtpcodec.codecType = BTIF_AVDTP_CODEC_TYPE_NON_A2DP; + a2dp_ldac_avdtpcodec.discoverable = 1; + a2dp_ldac_avdtpcodec.elements = (U8 *)&a2dp_codec_ldac_elements; + a2dp_ldac_avdtpcodec.elemLen = sizeof(a2dp_codec_ldac_elements); + TRACE(1, "a2dp_ldac_avdtpcodec.elemLen = %d \n", + a2dp_ldac_avdtpcodec.elemLen); + TRACE(7, + "a2dp_ldac_avdtpcodec.elements->[0]=0x%02x,[1]=0x%02x,[2]=0x%02x,[3]=" + "0x%02x,[4]=0x%02x,[5]=0x%02x,[6]=0x%02x,\n", + a2dp_ldac_avdtpcodec.elements[0], a2dp_ldac_avdtpcodec.elements[1], + a2dp_ldac_avdtpcodec.elements[2], a2dp_ldac_avdtpcodec.elements[3], + a2dp_ldac_avdtpcodec.elements[4], a2dp_ldac_avdtpcodec.elements[5], + a2dp_ldac_avdtpcodec.elements[6]); + TRACE(1, "a2dp_ldac_avdtpcodec.elements->[7]=0x%02x,\n", + a2dp_ldac_avdtpcodec.elements[7]); - st = btif_a2dp_register(bt_dev->a2dp_ldac_stream[index]->a2dp_stream, BTIF_A2DP_STREAM_TYPE_SINK, &a2dp_ldac_avdtpcodec, NULL, 3, index,a2dp_callback); + st = btif_a2dp_register(bt_dev->a2dp_ldac_stream[index]->a2dp_stream, + BTIF_A2DP_STREAM_TYPE_SINK, &a2dp_ldac_avdtpcodec, + NULL, 3, index, a2dp_callback); - return st; + return st; } #endif /* A2DP_LDAC_ON */ \ No newline at end of file diff --git a/services/bt_app/a2dp_codecs/lhdc/a2dp_codec_lhdc.cpp b/services/bt_app/a2dp_codecs/lhdc/a2dp_codec_lhdc.cpp index 6e5402b..021fda9 100644 --- a/services/bt_app/a2dp_codecs/lhdc/a2dp_codec_lhdc.cpp +++ b/services/bt_app/a2dp_codecs/lhdc/a2dp_codec_lhdc.cpp @@ -13,24 +13,24 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "cmsis_os.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_trace.h" -#include "hal_cmu.h" +#include "a2dp_api.h" #include "analog.h" #include "app.h" -#include "bt_drv.h" #include "app_audio.h" +#include "audioflinger.h" #include "bluetooth.h" -#include "nvrecord.h" -#include "nvrecord_env.h" -#include "nvrecord_dev.h" +#include "bt_drv.h" +#include "cmsis_os.h" +#include "hal_cmu.h" #include "hal_location.h" -#include "a2dp_api.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "lockcqueue.h" +#include "nvrecord.h" +#include "nvrecord_dev.h" +#include "nvrecord_env.h" +#include #if defined(NEW_NV_RECORD_ENABLED) #include "nvrecord_bt.h" #endif @@ -39,20 +39,20 @@ #include "avrcp_api.h" #include "besbt.h" -#include "cqueue.h" -#include "btapp.h" #include "app_bt.h" -#include "apps.h" -#include "resources.h" #include "app_bt_media_manager.h" -#include "tgt_hardware.h" +#include "apps.h" #include "bt_drv_interface.h" +#include "btapp.h" +#include "cqueue.h" #include "hci_api.h" +#include "resources.h" +#include "tgt_hardware.h" #include "a2dp_codec_lhdc.h" #include "avdtp_api.h" -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; #if defined(A2DP_LHDC_ON) static btif_avdtp_codec_t a2dp_lhdc_avdtpcodec; @@ -64,55 +64,58 @@ const unsigned char a2dp_codec_lhdc_elements[A2DP_LHDC_OCTET_NUMBER] = { (A2DP_LHDC_SR_96000 | A2DP_LHDC_SR_48000 | A2DP_LHDC_SR_44100) | (A2DP_LHDC_FMT_16 | A2DP_LHDC_FMT_24), }; #else -//V2 +// V2 const unsigned char a2dp_codec_lhdc_elements[A2DP_LHDC_OCTET_NUMBER] = { - 0x3A, 0x05, 0x00, 0x00, //Vendor ID + 0x3A, 0x05, 0x00, 0x00, // Vendor ID #if defined(A2DP_LHDC_V3) - 0x33, 0x4c, //Codec ID + 0x33, 0x4c, // Codec ID #else - 0x32, 0x4c, //Codec ID + 0x32, 0x4c, // Codec ID #endif - //A2DP_LHDC_SR_96000 | // 96K sample rate will audio drop, don't register - (A2DP_LHDC_SR_48000 | A2DP_LHDC_SR_44100) | (A2DP_LHDC_FMT_16 | A2DP_LHDC_FMT_24), + // A2DP_LHDC_SR_96000 | // 96K sample rate will audio drop, don't register + (A2DP_LHDC_SR_48000 | A2DP_LHDC_SR_44100) | + (A2DP_LHDC_FMT_16 | A2DP_LHDC_FMT_24), ( #if defined(IBRT) - A2DP_LHDC_LLC_ENABLE | + A2DP_LHDC_LLC_ENABLE | #endif - A2DP_LHDC_MAX_SR_400 | A2DP_LHDC_VERSION_NUM), - (A2DP_LHDC_COF_CSC_DISABLE) -}; + A2DP_LHDC_MAX_SR_400 | A2DP_LHDC_VERSION_NUM), + (A2DP_LHDC_COF_CSC_DISABLE)}; #endif /* if 0 */ -btif_avdtp_codec_t * app_a2dp_codec_get_lhdc_avdtp_codec() -{ - return (btif_avdtp_codec_t *)&a2dp_lhdc_avdtpcodec; +btif_avdtp_codec_t *app_a2dp_codec_get_lhdc_avdtp_codec() { + return (btif_avdtp_codec_t *)&a2dp_lhdc_avdtpcodec; } -bt_status_t a2dp_codec_lhdc_init(int index) -{ - bt_status_t st; - struct BT_DEVICE_T *bt_dev = &app_bt_device; +bt_status_t a2dp_codec_lhdc_init(int index) { + bt_status_t st; + struct BT_DEVICE_T *bt_dev = &app_bt_device; - a2dp_lhdc_avdtpcodec.codecType = BTIF_AVDTP_CODEC_TYPE_LHDC; - a2dp_lhdc_avdtpcodec.discoverable = 1; - a2dp_lhdc_avdtpcodec.elements = (U8 *)&a2dp_codec_lhdc_elements; - a2dp_lhdc_avdtpcodec.elemLen = sizeof(a2dp_codec_lhdc_elements); - { - btif_avdtp_codec_t *p = &a2dp_lhdc_avdtpcodec; - TRACE(1,"a2dp_lhdc_avdtpcodec.elemLen = %d \n", p->elemLen); + a2dp_lhdc_avdtpcodec.codecType = BTIF_AVDTP_CODEC_TYPE_LHDC; + a2dp_lhdc_avdtpcodec.discoverable = 1; + a2dp_lhdc_avdtpcodec.elements = (U8 *)&a2dp_codec_lhdc_elements; + a2dp_lhdc_avdtpcodec.elemLen = sizeof(a2dp_codec_lhdc_elements); + { + btif_avdtp_codec_t *p = &a2dp_lhdc_avdtpcodec; + TRACE(1, "a2dp_lhdc_avdtpcodec.elemLen = %d \n", p->elemLen); - TRACE(5,"a2dp_lhdc_avdtpcodec.elements->[0]=0x%02x,[1]=0x%02x,[2]=0x%02x,[3]=0x%02x,[4]=0x%02x\n", - p->elements[0], p->elements[1], p->elements[2], - p->elements[3], p->elements[4]); + TRACE(5, + "a2dp_lhdc_avdtpcodec.elements->[0]=0x%02x,[1]=0x%02x,[2]=0x%02x,[3]=" + "0x%02x,[4]=0x%02x\n", + p->elements[0], p->elements[1], p->elements[2], p->elements[3], + p->elements[4]); - TRACE(4,"a2dp_lhdc_avdtpcodec.elements->[5]=0x%02x,[6]=0x%02x,[7]=0x%02x,[8]=0x%02x\n", - p->elements[5], p->elements[6], - p->elements[7], p->elements[8]); - } + TRACE(4, + "a2dp_lhdc_avdtpcodec.elements->[5]=0x%02x,[6]=0x%02x,[7]=0x%02x,[8]=" + "0x%02x\n", + p->elements[5], p->elements[6], p->elements[7], p->elements[8]); + } - st = btif_a2dp_register(bt_dev->a2dp_lhdc_stream[index]->a2dp_stream, BTIF_A2DP_STREAM_TYPE_SINK, &a2dp_lhdc_avdtpcodec, NULL, 2, index, a2dp_callback); + st = btif_a2dp_register(bt_dev->a2dp_lhdc_stream[index]->a2dp_stream, + BTIF_A2DP_STREAM_TYPE_SINK, &a2dp_lhdc_avdtpcodec, + NULL, 2, index, a2dp_callback); - return st; + return st; } #endif /* A2DP_LHDC_ON */ diff --git a/services/bt_app/a2dp_codecs/lhdc/codec_lhdc.cpp b/services/bt_app/a2dp_codecs/lhdc/codec_lhdc.cpp index f5588fe..4ebba08 100644 --- a/services/bt_app/a2dp_codecs/lhdc/codec_lhdc.cpp +++ b/services/bt_app/a2dp_codecs/lhdc/codec_lhdc.cpp @@ -15,130 +15,129 @@ ****************************************************************************/ #ifdef A2DP_LHDC_ON -#include -#include "cmsis_os.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_trace.h" -#include "hal_cmu.h" #include "analog.h" -#include "bt_drv.h" #include "app_audio.h" -#include "bt_drv_interface.h" #include "app_bt_stream.h" +#include "audioflinger.h" +#include "bt_drv.h" +#include "bt_drv_interface.h" +#include "cmsis_os.h" +#include "hal_cmu.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "lockcqueue.h" #include "nvrecord.h" #include "nvrecord_env.h" +#include -#include "spp_api.h" -#include "hal_chipid.h" -#include "bt_drv_reg_op.h" -#include "besbt.h" -#include "cqueue.h" -#include "btapp.h" #include "app_bt.h" -#include "apps.h" -#include "resources.h" #include "app_bt_media_manager.h" +#include "apps.h" +#include "besbt.h" +#include "bt_drv_reg_op.h" +#include "btapp.h" +#include "cqueue.h" +#include "hal_chipid.h" +#include "resources.h" +#include "spp_api.h" #include "tgt_hardware.h" #ifdef __TWS__ -#include "app_tws.h" #include "app_bt.h" +#include "app_tws.h" #include "app_tws_if.h" #endif #include "codec_lhdc.h" -void lhdc_info_parse(uint8_t * elements, lhdc_info_t * info) -{ - info->vendor_id = (uint32_t) elements[0]; - info->vendor_id |= ((uint32_t) elements[1]) << 8; - info->vendor_id |= ((uint32_t) elements[2]) << 16; - info->vendor_id |= ((uint32_t) elements[3]) << 24; +void lhdc_info_parse(uint8_t *elements, lhdc_info_t *info) { + info->vendor_id = (uint32_t)elements[0]; + info->vendor_id |= ((uint32_t)elements[1]) << 8; + info->vendor_id |= ((uint32_t)elements[2]) << 16; + info->vendor_id |= ((uint32_t)elements[3]) << 24; - info->codec_id = (uint16_t) elements[4]; - info->codec_id |= ((uint16_t) elements[5]) << 8; - uint8_t config = elements[6]; + info->codec_id = (uint16_t)elements[4]; + info->codec_id |= ((uint16_t)elements[5]) << 8; + uint8_t config = elements[6]; - if (info->vendor_id == A2DP_LHDC_VENDOR_ID && info->codec_id == A2DP_LHDC_CODEC_ID) { - - TRACE(2,"Vendor ID = 0x%08x, Codec ID = 0x%04x, LHDC Codec\n", info->vendor_id, info->codec_id); - switch (A2DP_LHDC_SR_DATA(config)) { - case A2DP_LHDC_SR_96000: - info->sample_rater = A2D_SBC_IE_SAMP_FREQ_96; - TRACE(1,"%s:CodecCfg sample_rate 96000\n", __func__); - break; - case A2DP_LHDC_SR_48000: - info->sample_rater = A2D_SBC_IE_SAMP_FREQ_48; - TRACE(1,"%s:CodecCfg sample_rate 48000\n", __func__); - break; - case A2DP_LHDC_SR_44100: - info->sample_rater = A2D_SBC_IE_SAMP_FREQ_44; - TRACE(1,"%s:CodecCfg sample_rate 44100\n", __func__); - break; - } - switch (A2DP_LHDC_FMT_DATA(config)) { - case A2DP_LHDC_FMT_16: - info->bits = 16; - TRACE(1,"%s:CodecCfg bits per sampe = 16", __func__); - break; - case A2DP_LHDC_FMT_24: - TRACE(1,"%s:CodecCfg bits per sampe = 24", __func__); - info->bits = 24; - break; - } - - config = elements[7]; - info->version_num = 0x0f & config; - TRACE(2,"%s:lhdc codec version num:%x\n", __func__, info->version_num); - info->max_sample_rate = 0x30 & config; - TRACE(2,"%s:lhdc codec max sample rate:%x\n", __func__, info->sample_rater); - - info->llc_enable = 0x40 & config; - TRACE(2,"%s:lhdc codec llc enable:%x \n", __func__, info->llc_enable); - - config = elements[8]; - switch (A2DP_LHDC_COF_DATA(config)) { - case A2DP_LHDC_COF_CSC_DISABLE: - info->compress_output_format = LHDC_CHANNEL_SPLIT_DISABLE; - TRACE(1,"%s:compress_output_format: LHDC_COF_CSC_DISABLE", __func__); - break; - case A2DP_LHDC_COF_CSC: - TRACE(1,"%s:compress_output_format: LHDC_COF_CSC", __func__); - info->compress_output_format = LHDC_CHANNEL_SPLIT; - break; - case A2DP_LHDC_COF_CSC_PRE: - TRACE(1,"%s:compress_output_format: LHDC_COF_CSC_PRE", __func__); - info->compress_output_format = LHDC_CHANNEL_SPLIT_FROM_ENCODER; - break; - - } + if (info->vendor_id == A2DP_LHDC_VENDOR_ID && + info->codec_id == A2DP_LHDC_CODEC_ID) { + TRACE(2, "Vendor ID = 0x%08x, Codec ID = 0x%04x, LHDC Codec\n", + info->vendor_id, info->codec_id); + switch (A2DP_LHDC_SR_DATA(config)) { + case A2DP_LHDC_SR_96000: + info->sample_rater = A2D_SBC_IE_SAMP_FREQ_96; + TRACE(1, "%s:CodecCfg sample_rate 96000\n", __func__); + break; + case A2DP_LHDC_SR_48000: + info->sample_rater = A2D_SBC_IE_SAMP_FREQ_48; + TRACE(1, "%s:CodecCfg sample_rate 48000\n", __func__); + break; + case A2DP_LHDC_SR_44100: + info->sample_rater = A2D_SBC_IE_SAMP_FREQ_44; + TRACE(1, "%s:CodecCfg sample_rate 44100\n", __func__); + break; } + switch (A2DP_LHDC_FMT_DATA(config)) { + case A2DP_LHDC_FMT_16: + info->bits = 16; + TRACE(1, "%s:CodecCfg bits per sampe = 16", __func__); + break; + case A2DP_LHDC_FMT_24: + TRACE(1, "%s:CodecCfg bits per sampe = 24", __func__); + info->bits = 24; + break; + } + + config = elements[7]; + info->version_num = 0x0f & config; + TRACE(2, "%s:lhdc codec version num:%x\n", __func__, info->version_num); + info->max_sample_rate = 0x30 & config; + TRACE(2, "%s:lhdc codec max sample rate:%x\n", __func__, + info->sample_rater); + + info->llc_enable = 0x40 & config; + TRACE(2, "%s:lhdc codec llc enable:%x \n", __func__, info->llc_enable); + + config = elements[8]; + switch (A2DP_LHDC_COF_DATA(config)) { + case A2DP_LHDC_COF_CSC_DISABLE: + info->compress_output_format = LHDC_CHANNEL_SPLIT_DISABLE; + TRACE(1, "%s:compress_output_format: LHDC_COF_CSC_DISABLE", __func__); + break; + case A2DP_LHDC_COF_CSC: + TRACE(1, "%s:compress_output_format: LHDC_COF_CSC", __func__); + info->compress_output_format = LHDC_CHANNEL_SPLIT; + break; + case A2DP_LHDC_COF_CSC_PRE: + TRACE(1, "%s:compress_output_format: LHDC_COF_CSC_PRE", __func__); + info->compress_output_format = LHDC_CHANNEL_SPLIT_FROM_ENCODER; + break; + } + } } -uint8_t a2dp_lhdc_get_sample_rate(uint8_t * elements) -{ - uint32_t vendor_id = (uint32_t) elements[0]; - vendor_id |= ((uint32_t) elements[1]) << 8; - vendor_id |= ((uint32_t) elements[2]) << 16; - vendor_id |= ((uint32_t) elements[3]) << 24; - uint16_t codec_id = (uint16_t) elements[4]; - codec_id |= ((uint16_t) elements[5]) << 8; +uint8_t a2dp_lhdc_get_sample_rate(uint8_t *elements) { + uint32_t vendor_id = (uint32_t)elements[0]; + vendor_id |= ((uint32_t)elements[1]) << 8; + vendor_id |= ((uint32_t)elements[2]) << 16; + vendor_id |= ((uint32_t)elements[3]) << 24; + uint16_t codec_id = (uint16_t)elements[4]; + codec_id |= ((uint16_t)elements[5]) << 8; - uint8_t config = elements[6]; - if (vendor_id == A2DP_LHDC_VENDOR_ID && codec_id == A2DP_LHDC_CODEC_ID) { - switch (A2DP_LHDC_SR_DATA(config)) { - case A2DP_LHDC_SR_96000: - return A2D_SBC_IE_SAMP_FREQ_96; - case A2DP_LHDC_SR_48000: - return A2D_SBC_IE_SAMP_FREQ_48; - case A2DP_LHDC_SR_44100: - return A2D_SBC_IE_SAMP_FREQ_44; - } + uint8_t config = elements[6]; + if (vendor_id == A2DP_LHDC_VENDOR_ID && codec_id == A2DP_LHDC_CODEC_ID) { + switch (A2DP_LHDC_SR_DATA(config)) { + case A2DP_LHDC_SR_96000: + return A2D_SBC_IE_SAMP_FREQ_96; + case A2DP_LHDC_SR_48000: + return A2D_SBC_IE_SAMP_FREQ_48; + case A2DP_LHDC_SR_44100: + return A2D_SBC_IE_SAMP_FREQ_44; } - return 0; + } + return 0; } #endif diff --git a/services/bt_app/a2dp_codecs/opus/a2dp_codec_opus.cpp b/services/bt_app/a2dp_codecs/opus/a2dp_codec_opus.cpp index 6f0572f..cf33395 100644 --- a/services/bt_app/a2dp_codecs/opus/a2dp_codec_opus.cpp +++ b/services/bt_app/a2dp_codecs/opus/a2dp_codec_opus.cpp @@ -13,24 +13,24 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "cmsis_os.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_trace.h" -#include "hal_cmu.h" +#include "a2dp_api.h" #include "analog.h" #include "app.h" -#include "bt_drv.h" #include "app_audio.h" +#include "audioflinger.h" #include "bluetooth.h" -#include "nvrecord.h" -#include "nvrecord_env.h" -#include "nvrecord_dev.h" +#include "bt_drv.h" +#include "cmsis_os.h" +#include "hal_cmu.h" #include "hal_location.h" -#include "a2dp_api.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "lockcqueue.h" +#include "nvrecord.h" +#include "nvrecord_dev.h" +#include "nvrecord_env.h" +#include #if defined(NEW_NV_RECORD_ENABLED) #include "nvrecord_bt.h" #endif @@ -39,34 +39,33 @@ #include "avrcp_api.h" #include "besbt.h" -#include "cqueue.h" -#include "btapp.h" #include "app_bt.h" -#include "apps.h" -#include "resources.h" #include "app_bt_media_manager.h" -#include "tgt_hardware.h" +#include "apps.h" #include "bt_drv_interface.h" +#include "btapp.h" +#include "cqueue.h" #include "hci_api.h" +#include "resources.h" +#include "tgt_hardware.h" #include "a2dp_codec_opus.h" #include "avdtp_api.h" -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; #if defined(MASTER_USE_OPUS) || defined(ALL_USE_OPUS) static btif_avdtp_codec_t a2dp_opus_avdtpcodec; const unsigned char a2dp_codec_opus_elements[] = { - A2D_SBC_IE_SAMP_FREQ_48 | A2D_SBC_IE_SAMP_FREQ_44 | A2D_SBC_IE_CH_MD_STEREO | A2D_SBC_IE_CH_MD_JOINT, - A2D_SBC_IE_BLOCKS_16 | A2D_SBC_IE_BLOCKS_12 | A2D_SBC_IE_SUBBAND_8 | A2D_SBC_IE_ALLOC_MD_L, - A2D_SBC_IE_MIN_BITPOOL, - BTA_AV_CO_SBC_MAX_BITPOOL -}; + A2D_SBC_IE_SAMP_FREQ_48 | A2D_SBC_IE_SAMP_FREQ_44 | + A2D_SBC_IE_CH_MD_STEREO | A2D_SBC_IE_CH_MD_JOINT, + A2D_SBC_IE_BLOCKS_16 | A2D_SBC_IE_BLOCKS_12 | A2D_SBC_IE_SUBBAND_8 | + A2D_SBC_IE_ALLOC_MD_L, + A2D_SBC_IE_MIN_BITPOOL, BTA_AV_CO_SBC_MAX_BITPOOL}; -bt_status_t a2dp_codec_opus_init(struct BT_DEVICE_T *bt_dev, int index) -{ - return BT_STS_SUCCESS; +bt_status_t a2dp_codec_opus_init(struct BT_DEVICE_T *bt_dev, int index) { + return BT_STS_SUCCESS; } #endif /* MASTER_USE_OPUS || ALL_USE_OPUS */ \ No newline at end of file diff --git a/services/bt_app/a2dp_codecs/sbc/a2dp_codec_sbc.cpp b/services/bt_app/a2dp_codecs/sbc/a2dp_codec_sbc.cpp index fe4a752..c67c7bc 100644 --- a/services/bt_app/a2dp_codecs/sbc/a2dp_codec_sbc.cpp +++ b/services/bt_app/a2dp_codecs/sbc/a2dp_codec_sbc.cpp @@ -13,24 +13,24 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "cmsis_os.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_trace.h" -#include "hal_cmu.h" +#include "a2dp_api.h" #include "analog.h" #include "app.h" -#include "bt_drv.h" #include "app_audio.h" +#include "audioflinger.h" #include "bluetooth.h" -#include "nvrecord.h" -#include "nvrecord_env.h" -#include "nvrecord_dev.h" +#include "bt_drv.h" +#include "cmsis_os.h" +#include "hal_cmu.h" #include "hal_location.h" -#include "a2dp_api.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "lockcqueue.h" +#include "nvrecord.h" +#include "nvrecord_dev.h" +#include "nvrecord_env.h" +#include #if defined(NEW_NV_RECORD_ENABLED) #include "nvrecord_bt.h" #endif @@ -39,20 +39,20 @@ #include "avrcp_api.h" #include "besbt.h" -#include "cqueue.h" -#include "btapp.h" #include "app_bt.h" -#include "apps.h" -#include "resources.h" #include "app_bt_media_manager.h" -#include "tgt_hardware.h" +#include "apps.h" #include "bt_drv_interface.h" +#include "btapp.h" +#include "cqueue.h" #include "hci_api.h" +#include "resources.h" +#include "tgt_hardware.h" #include "a2dp_codec_sbc.h" #include "avdtp_api.h" -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; #ifdef __A2DP_AVDTP_CP__ btif_avdtp_content_prot_t a2dp_avdtpCp[BT_DEVICE_NUM]; @@ -62,34 +62,40 @@ U8 a2dp_avdtpCp_securityData[BT_DEVICE_NUM][BTIF_AVDTP_MAX_CP_VALUE_SIZE] = {}; btif_avdtp_codec_t a2dp_avdtpcodec; const unsigned char a2dp_codec_elements[] = { - A2D_SBC_IE_SAMP_FREQ_48 | A2D_SBC_IE_SAMP_FREQ_44 | A2D_SBC_IE_CH_MD_MONO | A2D_SBC_IE_CH_MD_STEREO | A2D_SBC_IE_CH_MD_JOINT | A2D_SBC_IE_CH_MD_DUAL, - A2D_SBC_IE_BLOCKS_16 | A2D_SBC_IE_BLOCKS_12 | A2D_SBC_IE_BLOCKS_8 |A2D_SBC_IE_BLOCKS_4 | A2D_SBC_IE_SUBBAND_8 | A2D_SBC_IE_ALLOC_MD_L | A2D_SBC_IE_ALLOC_MD_S, - A2D_SBC_IE_MIN_BITPOOL, - BTA_AV_CO_SBC_MAX_BITPOOL -}; + A2D_SBC_IE_SAMP_FREQ_48 | A2D_SBC_IE_SAMP_FREQ_44 | A2D_SBC_IE_CH_MD_MONO | + A2D_SBC_IE_CH_MD_STEREO | A2D_SBC_IE_CH_MD_JOINT | + A2D_SBC_IE_CH_MD_DUAL, + A2D_SBC_IE_BLOCKS_16 | A2D_SBC_IE_BLOCKS_12 | A2D_SBC_IE_BLOCKS_8 | + A2D_SBC_IE_BLOCKS_4 | A2D_SBC_IE_SUBBAND_8 | A2D_SBC_IE_ALLOC_MD_L | + A2D_SBC_IE_ALLOC_MD_S, + A2D_SBC_IE_MIN_BITPOOL, BTA_AV_CO_SBC_MAX_BITPOOL}; -bt_status_t a2dp_codec_sbc_init(int index) -{ - struct BT_DEVICE_T *bt_dev = &app_bt_device; +bt_status_t a2dp_codec_sbc_init(int index) { + struct BT_DEVICE_T *bt_dev = &app_bt_device; - bt_status_t st; + bt_status_t st; #ifdef __A2DP_AVDTP_CP__ - a2dp_avdtpCp[index].cpType = BTIF_AVDTP_CP_TYPE_SCMS_T; - a2dp_avdtpCp[index].data = (U8 *)&a2dp_avdtpCp_securityData[index][0]; - a2dp_avdtpCp[index].dataLen = 0; + a2dp_avdtpCp[index].cpType = BTIF_AVDTP_CP_TYPE_SCMS_T; + a2dp_avdtpCp[index].data = (U8 *)&a2dp_avdtpCp_securityData[index][0]; + a2dp_avdtpCp[index].dataLen = 0; #endif /* __A2DP_AVDTP_CP__ */ - a2dp_avdtpcodec.codecType = BTIF_AVDTP_CODEC_TYPE_SBC; - a2dp_avdtpcodec.discoverable = 1; - a2dp_avdtpcodec.elements = (U8 *)&a2dp_codec_elements; - a2dp_avdtpcodec.elemLen = 4; + a2dp_avdtpcodec.codecType = BTIF_AVDTP_CODEC_TYPE_SBC; + a2dp_avdtpcodec.discoverable = 1; + a2dp_avdtpcodec.elements = (U8 *)&a2dp_codec_elements; + a2dp_avdtpcodec.elemLen = 4; #ifdef __A2DP_AVDTP_CP__ - st = btif_a2dp_register(bt_dev->a2dp_stream[index]->a2dp_stream, BTIF_A2DP_STREAM_TYPE_SINK, &a2dp_avdtpcodec, &a2dp_avdtpCp[index], 0,index,a2dp_callback); - btif_a2dp_add_content_protection(bt_dev->a2dp_stream[index]->a2dp_stream, &a2dp_avdtpCp[index]); + st = btif_a2dp_register(bt_dev->a2dp_stream[index]->a2dp_stream, + BTIF_A2DP_STREAM_TYPE_SINK, &a2dp_avdtpcodec, + &a2dp_avdtpCp[index], 0, index, a2dp_callback); + btif_a2dp_add_content_protection(bt_dev->a2dp_stream[index]->a2dp_stream, + &a2dp_avdtpCp[index]); #else - st = btif_a2dp_register(bt_dev->a2dp_stream[index]->a2dp_stream, BTIF_A2DP_STREAM_TYPE_SINK, &a2dp_avdtpcodec, NULL, 0,index, a2dp_callback); + st = btif_a2dp_register(bt_dev->a2dp_stream[index]->a2dp_stream, + BTIF_A2DP_STREAM_TYPE_SINK, &a2dp_avdtpcodec, NULL, 0, + index, a2dp_callback); #endif /* __A2DP_AVDTP_CP__ */ - return st; + return st; } \ No newline at end of file diff --git a/services/bt_app/a2dp_codecs/scalable/a2dp_codec_scalable.cpp b/services/bt_app/a2dp_codecs/scalable/a2dp_codec_scalable.cpp index eb1b528..f3cb6d9 100644 --- a/services/bt_app/a2dp_codecs/scalable/a2dp_codec_scalable.cpp +++ b/services/bt_app/a2dp_codecs/scalable/a2dp_codec_scalable.cpp @@ -13,24 +13,24 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "cmsis_os.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_trace.h" -#include "hal_cmu.h" +#include "a2dp_api.h" #include "analog.h" #include "app.h" -#include "bt_drv.h" #include "app_audio.h" +#include "audioflinger.h" #include "bluetooth.h" -#include "nvrecord.h" -#include "nvrecord_env.h" -#include "nvrecord_dev.h" +#include "bt_drv.h" +#include "cmsis_os.h" +#include "hal_cmu.h" #include "hal_location.h" -#include "a2dp_api.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "lockcqueue.h" +#include "nvrecord.h" +#include "nvrecord_dev.h" +#include "nvrecord_env.h" +#include #if defined(NEW_NV_RECORD_ENABLED) #include "nvrecord_bt.h" #endif @@ -39,25 +39,25 @@ #include "avrcp_api.h" #include "besbt.h" -#include "cqueue.h" -#include "btapp.h" #include "app_bt.h" -#include "apps.h" -#include "resources.h" #include "app_bt_media_manager.h" -#include "tgt_hardware.h" +#include "apps.h" #include "bt_drv_interface.h" +#include "btapp.h" +#include "cqueue.h" #include "hci_api.h" +#include "resources.h" +#include "tgt_hardware.h" #include "a2dp_codec_scalable.h" #include "avdtp_api.h" -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; #if defined(A2DP_SCALABLE_ON) btif_avdtp_codec_t a2dp_scalable_avdtpcodec; -//Vendor Specific value (8bit) : 0x78 (not support UHQ) 0xF8  (support UHQ) +// Vendor Specific value (8bit) : 0x78 (not support UHQ) 0xF8  (support UHQ) // - bit 7 : 96kHz   sampling frequency supported // - bit 6 : 32kHz   sampling frequency supported // - bit 5 : 44.1kHz sampling frequency supported @@ -67,30 +67,30 @@ btif_avdtp_codec_t a2dp_scalable_avdtpcodec; // - bit 1 : additional information (current 0) // - bit 0 : additional information (current 0) //<1byte Vendor Specific values for Scalable codec>  -const unsigned char a2dp_codec_scalable_elements[A2DP_SCALABLE_OCTET_NUMBER] = -{ - 0x75,0x0,0x0,0x0, // vendor id - 0x03,0x01, // vendor specific codec id +const unsigned char a2dp_codec_scalable_elements[A2DP_SCALABLE_OCTET_NUMBER] = { + 0x75, 0x0, 0x0, 0x0, // vendor id + 0x03, 0x01, // vendor specific codec id #if defined(A2DP_SCALABLE_UHQ_SUPPORT) - 0xf8, // vendor specific value + 0xf8, // vendor specific value #else - 0x78, // vendor specific value + 0x78, // vendor specific value #endif }; -bt_status_t a2dp_codec_scalable_init(int index) -{ - bt_status_t st; +bt_status_t a2dp_codec_scalable_init(int index) { + bt_status_t st; - struct BT_DEVICE_T *bt_dev = &app_bt_device; + struct BT_DEVICE_T *bt_dev = &app_bt_device; - a2dp_scalable_avdtpcodec.codecType = BTIF_AVDTP_CODEC_TYPE_NON_A2DP; - a2dp_scalable_avdtpcodec.discoverable = 1; - a2dp_scalable_avdtpcodec.elements = (U8 *)&a2dp_codec_scalable_elements; - a2dp_scalable_avdtpcodec.elemLen = sizeof(a2dp_codec_scalable_elements); + a2dp_scalable_avdtpcodec.codecType = BTIF_AVDTP_CODEC_TYPE_NON_A2DP; + a2dp_scalable_avdtpcodec.discoverable = 1; + a2dp_scalable_avdtpcodec.elements = (U8 *)&a2dp_codec_scalable_elements; + a2dp_scalable_avdtpcodec.elemLen = sizeof(a2dp_codec_scalable_elements); - st = btif_a2dp_register(bt_dev->a2dp_scalable_stream[index]->a2dp_stream, BTIF_A2DP_STREAM_TYPE_SINK, &a2dp_scalable_avdtpcodec, NULL, 4,index,a2dp_callback); + st = btif_a2dp_register(bt_dev->a2dp_scalable_stream[index]->a2dp_stream, + BTIF_A2DP_STREAM_TYPE_SINK, &a2dp_scalable_avdtpcodec, + NULL, 4, index, a2dp_callback); - return st; + return st; } #endif /* A2DP_SCALABLE_ON */ diff --git a/services/bt_app/app_a2dp.cpp b/services/bt_app/app_a2dp.cpp index 46d82d5..92b38d3 100644 --- a/services/bt_app/app_a2dp.cpp +++ b/services/bt_app/app_a2dp.cpp @@ -13,25 +13,25 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "cmsis_os.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_trace.h" -#include "hal_cmu.h" +#include "app_a2dp.h" +#include "a2dp_api.h" #include "analog.h" #include "app.h" -#include "bt_drv.h" #include "app_audio.h" +#include "audioflinger.h" #include "bluetooth.h" -#include "nvrecord.h" -#include "nvrecord_env.h" -#include "nvrecord_dev.h" +#include "bt_drv.h" +#include "cmsis_os.h" +#include "hal_cmu.h" #include "hal_location.h" -#include "a2dp_api.h" -#include "app_a2dp.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "lockcqueue.h" +#include "nvrecord.h" +#include "nvrecord_dev.h" +#include "nvrecord_env.h" +#include #if defined(NEW_NV_RECORD_ENABLED) #include "nvrecord_bt.h" #endif @@ -41,24 +41,24 @@ #endif #if defined(A2DP_LDAC_ON) -#include"ldacBT.h" +#include "ldacBT.h" #endif #include "a2dp_api.h" #include "avrcp_api.h" #include "besbt.h" -#include "cqueue.h" -#include "btapp.h" #include "app_bt.h" -#include "apps.h" -#include "resources.h" #include "app_bt_media_manager.h" -#include "tgt_hardware.h" +#include "apps.h" #include "bt_drv_interface.h" -#include "hci_api.h" -#include "hal_bootmode.h" #include "bt_drv_reg_op.h" +#include "btapp.h" +#include "cqueue.h" +#include "hal_bootmode.h" +#include "hci_api.h" +#include "resources.h" +#include "tgt_hardware.h" #ifdef BT_USB_AUDIO_DUAL_MODE #include "btusb_audio.h" @@ -68,7 +68,7 @@ #include "app_btmap_sms.h" #endif -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) #include "app_a2dp_source.h" extern enum AUD_SAMPRATE_T bt_parse_sbc_sample_rate(uint8_t sbc_samp_rate); #endif @@ -86,8 +86,8 @@ extern enum AUD_SAMPRATE_T bt_parse_sbc_sample_rate(uint8_t sbc_samp_rate); #endif #define _FILE_TAG_ "A2DP" -#include "color_log.h" #include "app_bt_func.h" +#include "color_log.h" #include "os_api.h" #if (A2DP_DECODER_VER >= 2) @@ -103,12 +103,12 @@ extern enum AUD_SAMPRATE_T bt_parse_sbc_sample_rate(uint8_t sbc_samp_rate); #include "gsound_custom_bt.h" #endif -#define APP_A2DP_STRM_FLAG_QUERY_CODEC 0x08 +#define APP_A2DP_STRM_FLAG_QUERY_CODEC 0x08 #define APP_A2DP__DEBUG -#ifdef APP_A2DP__DEBUG -#define APP_A2DP_TRACE(str, ...) TRACE(str, ##__VA_ARGS__) +#ifdef APP_A2DP__DEBUG +#define APP_A2DP_TRACE(str, ...) TRACE(str, ##__VA_ARGS__) #else #define APP_A2DP_TRACE(str, ...) #endif @@ -117,10 +117,10 @@ uint8_t current_a2dp_non_type = 0; typedef uint8_t tx_done_flag; -#define TX_DONE_FLAG_INIT ((uint8_t)0) -#define TX_DONE_FLAG_SUCCESS ((uint8_t)1) -#define TX_DONE_FLAG_FAIL ((uint8_t)2) -#define TX_DONE_FLAG_TXING ((uint8_t)3) +#define TX_DONE_FLAG_INIT ((uint8_t)0) +#define TX_DONE_FLAG_SUCCESS ((uint8_t)1) +#define TX_DONE_FLAG_FAIL ((uint8_t)2) +#define TX_DONE_FLAG_TXING ((uint8_t)3) tx_done_flag vol_ctrl_done_flag[BT_DEVICE_NUM] = {TX_DONE_FLAG_INIT}; int a2dp_volume_get(enum BT_DEVICE_ID_T id); @@ -130,347 +130,356 @@ extern "C" void app_exit_fastpairing_mode(void); #endif extern int app_bt_stream_volumeset(int8_t vol); -static void app_AVRCP_sendCustomCmdRsp(uint8_t device_id, btif_avrcp_channel_t *chnl, uint8_t isAccept, uint8_t transId); -static void app_AVRCP_CustomCmd_Received(uint8_t* ptrData, uint32_t len); +static void app_AVRCP_sendCustomCmdRsp(uint8_t device_id, + btif_avrcp_channel_t *chnl, + uint8_t isAccept, uint8_t transId); +static void app_AVRCP_CustomCmd_Received(uint8_t *ptrData, uint32_t len); -void get_value1_pos(U8 mask,U8 *start_pos, U8 *end_pos) -{ - U8 num = 0; +void get_value1_pos(U8 mask, U8 *start_pos, U8 *end_pos) { + U8 num = 0; - for(U8 i=0;i<8;i++){ - if((0x01<avrcp_channel_handle) == rem_dev) + break; } + } - for (i = 0; i < BT_DEVICE_NUM; ++i) { - if (btif_avrcp_state_connected(app_bt_device.avrcp_channel[i])) { - if (btif_avrcp_get_remote_device(app_bt_device.avrcp_channel[i]->avrcp_channel_handle) == rem_dev) - break; - } - } + if (i == BT_DEVICE_NUM) { + TRACE(2, "%s:no_proper_avrcp_channel_to_save,rem_dev=%p,error!", __func__, + rem_dev); + return 0; + } - if (i == BT_DEVICE_NUM) { - TRACE(2,"%s:no_proper_avrcp_channel_to_save,rem_dev=%p,error!", __func__, rem_dev); - return 0; - } + buf[offset] = i; + ++offset; - buf[offset] = i; - ++offset; - - return offset; + return offset; } -uint32_t app_avrcp_restore_ctxs(btif_remote_device_t *rem_dev, uint8_t *buf, uint32_t buf_len) -{ - return 0; +uint32_t app_avrcp_restore_ctxs(btif_remote_device_t *rem_dev, uint8_t *buf, + uint32_t buf_len) { + return 0; } #endif /* ENHANCED_STACK */ #endif -bool is_bd_addr_valid(bt_bdaddr_t * addr) -{ - uint8_t addr_empty[6]; - memset(addr_empty, 0, sizeof(addr_empty)); - if (memcmp(addr,addr_empty,6)){ - return TRUE; - }else{ - return FALSE; - } - +bool is_bd_addr_valid(bt_bdaddr_t *addr) { + uint8_t addr_empty[6]; + memset(addr_empty, 0, sizeof(addr_empty)); + if (memcmp(addr, addr_empty, 6)) { + return TRUE; + } else { + return FALSE; + } } -static void app_avrcp_connect_timeout_timer_handler(uint32_t deviceId) -{ - TRACE(2,"app_avrcp_connect_timeout_handler a2dp state=%d,avrcp state=%d", app_bt_device.a2dp_state[deviceId], +static void app_avrcp_connect_timeout_timer_handler(uint32_t deviceId) { + TRACE(2, "app_avrcp_connect_timeout_handler a2dp state=%d,avrcp state=%d", + app_bt_device.a2dp_state[deviceId], btif_get_avrcp_state(app_bt_device.avrcp_channel[deviceId])); - if((!app_is_disconnecting_all_bt_connections()) && - app_bt_device.a2dp_state[deviceId] && - (btif_get_avrcp_state(app_bt_device.avrcp_channel[deviceId]) != BTIF_AVRCP_STATE_CONNECTED)) - { - btif_remote_device_t * rdev = btif_a2dp_get_stream_conn_remDev(app_bt_device.a2dp_connected_stream[deviceId]); - if(rdev){ - bt_bdaddr_t * bd_addr = btif_me_get_remote_device_bdaddr(rdev); - if ( is_bd_addr_valid(bd_addr)){ - btif_avrcp_connect(app_bt_device.avrcp_channel[deviceId], bd_addr); - }else{ - TRACE(1,"%s bd_addr is empty ",__func__); - } - }else{ - TRACE(1,"%s rdev is NULL ", __func__); - } + if ((!app_is_disconnecting_all_bt_connections()) && + app_bt_device.a2dp_state[deviceId] && + (btif_get_avrcp_state(app_bt_device.avrcp_channel[deviceId]) != + BTIF_AVRCP_STATE_CONNECTED)) { + btif_remote_device_t *rdev = btif_a2dp_get_stream_conn_remDev( + app_bt_device.a2dp_connected_stream[deviceId]); + if (rdev) { + bt_bdaddr_t *bd_addr = btif_me_get_remote_device_bdaddr(rdev); + if (is_bd_addr_valid(bd_addr)) { + btif_avrcp_connect(app_bt_device.avrcp_channel[deviceId], bd_addr); + } else { + TRACE(1, "%s bd_addr is empty ", __func__); + } + } else { + TRACE(1, "%s rdev is NULL ", __func__); } + } } -void app_avrcp_connect_timeout_timer_callback(void const *param) -{ - app_bt_start_custom_function_in_bt_thread((uint32_t)param ,0, - (uint32_t)app_avrcp_connect_timeout_timer_handler); +void app_avrcp_connect_timeout_timer_callback(void const *param) { + app_bt_start_custom_function_in_bt_thread( + (uint32_t)param, 0, (uint32_t)app_avrcp_connect_timeout_timer_handler); } -#define MAX_AVRCP_CONNECT_TRY_TIME 3 -osTimerDef (APP_AVRCP_CONNECT0, app_avrcp_connect_timeout_timer_callback); +#define MAX_AVRCP_CONNECT_TRY_TIME 3 +osTimerDef(APP_AVRCP_CONNECT0, app_avrcp_connect_timeout_timer_callback); osTimerId POSSIBLY_UNUSED app_avrcp_connect_timer0 = NULL; -static uint8_t app_avrcp_connect_try_times[BT_DEVICE_NUM]; +static uint8_t app_avrcp_connect_try_times[BT_DEVICE_NUM]; #ifdef __BT_ONE_BRING_TWO__ -osTimerDef (APP_AVRCP_CONNECT1, app_avrcp_connect_timeout_timer_callback); +osTimerDef(APP_AVRCP_CONNECT1, app_avrcp_connect_timeout_timer_callback); osTimerId POSSIBLY_UNUSED app_avrcp_connect_timer1 = NULL; #endif - -#define MAX_GET_CAPABILITIES_RETRY_TIME (3) -#define MAX_GET_CAPABILITIES_RETRY_INTERVAL (500) +#define MAX_GET_CAPABILITIES_RETRY_TIME (3) +#define MAX_GET_CAPABILITIES_RETRY_INTERVAL (500) typedef struct { - btif_avrcp_chnl_handle_t chnl; - osTimerId delay_timer; - int8_t retry_cnt; -}app_avrcp_get_capabilities_ctx_t; + btif_avrcp_chnl_handle_t chnl; + osTimerId delay_timer; + int8_t retry_cnt; +} app_avrcp_get_capabilities_ctx_t; void app_avrcp_get_capabilities_retry_callback(void const *param); -osTimerDef (APP_AVRCP_GET_CAPABILITIES0, app_avrcp_get_capabilities_retry_callback); +osTimerDef(APP_AVRCP_GET_CAPABILITIES0, + app_avrcp_get_capabilities_retry_callback); osTimerId POSSIBLY_UNUSED app_avrcp_get_capabilities_timer0 = NULL; app_avrcp_get_capabilities_ctx_t app_avrcp_get_capabilities_ctx0; #ifdef __BT_ONE_BRING_TWO__ -osTimerDef (APP_AVRCP_GET_CAPABILITIES1, app_avrcp_get_capabilities_retry_callback); +osTimerDef(APP_AVRCP_GET_CAPABILITIES1, + app_avrcp_get_capabilities_retry_callback); osTimerId POSSIBLY_UNUSED app_avrcp_get_capabilities_timer1 = NULL; app_avrcp_get_capabilities_ctx_t app_avrcp_get_capabilities_ctx1; #endif -void app_avrcp_get_capabilities_start(btif_avrcp_chnl_handle_t chnl) -{ +void app_avrcp_get_capabilities_start(btif_avrcp_chnl_handle_t chnl) { #ifdef __BT_ONE_BRING_TWO__ - enum BT_DEVICE_ID_T device_id = (chnl == app_bt_device.avrcp_channel[0]->avrcp_channel_handle) ? BT_DEVICE_ID_1 : BT_DEVICE_ID_2; + enum BT_DEVICE_ID_T device_id = + (chnl == app_bt_device.avrcp_channel[0]->avrcp_channel_handle) + ? BT_DEVICE_ID_1 + : BT_DEVICE_ID_2; #else - enum BT_DEVICE_ID_T device_id = BT_DEVICE_ID_1; + enum BT_DEVICE_ID_T device_id = BT_DEVICE_ID_1; #endif - btif_avrcp_channel_t *channel = btif_get_avrcp_channel(chnl); + btif_avrcp_channel_t *channel = btif_get_avrcp_channel(chnl); - if (btif_get_avrcp_version(channel) == BTIF_AVRCP_VERSION_UNKNOWN) - { - APP_A2DP_TRACE(0,"::AVRCP_GET_CAPABILITY DELAY\n"); - switch (device_id) - { + if (btif_get_avrcp_version(channel) == BTIF_AVRCP_VERSION_UNKNOWN) { + APP_A2DP_TRACE(0, "::AVRCP_GET_CAPABILITY DELAY\n"); + switch (device_id) { #ifdef __BT_ONE_BRING_TWO__ - case BT_DEVICE_ID_2: - app_avrcp_get_capabilities_ctx1.chnl = chnl; - app_avrcp_get_capabilities_ctx1.retry_cnt = MAX_GET_CAPABILITIES_RETRY_TIME; - osTimerStart(app_avrcp_get_capabilities_ctx1.delay_timer, MAX_GET_CAPABILITIES_RETRY_INTERVAL); - break; + case BT_DEVICE_ID_2: + app_avrcp_get_capabilities_ctx1.chnl = chnl; + app_avrcp_get_capabilities_ctx1.retry_cnt = + MAX_GET_CAPABILITIES_RETRY_TIME; + osTimerStart(app_avrcp_get_capabilities_ctx1.delay_timer, + MAX_GET_CAPABILITIES_RETRY_INTERVAL); + break; #endif - case BT_DEVICE_ID_1: - default: - app_avrcp_get_capabilities_ctx0.chnl = chnl; - app_avrcp_get_capabilities_ctx0.retry_cnt = MAX_GET_CAPABILITIES_RETRY_TIME; - osTimerStart(app_avrcp_get_capabilities_ctx0.delay_timer, MAX_GET_CAPABILITIES_RETRY_INTERVAL); - break; - } + case BT_DEVICE_ID_1: + default: + app_avrcp_get_capabilities_ctx0.chnl = chnl; + app_avrcp_get_capabilities_ctx0.retry_cnt = + MAX_GET_CAPABILITIES_RETRY_TIME; + osTimerStart(app_avrcp_get_capabilities_ctx0.delay_timer, + MAX_GET_CAPABILITIES_RETRY_INTERVAL); + break; } - else - { - if(btif_get_avrcp_version(channel) >= BTIF_AVRCP_VERSION_1_3) - { - APP_A2DP_TRACE(0,"::AVRCP_GET_CAPABILITY\n"); - if (app_bt_device.avrcp_cmd1[device_id] == NULL){ - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_cmd1[device_id]); - } - btif_avrcp_ct_get_capabilities(channel, app_bt_device.avrcp_cmd1[device_id],BTIF_AVRCP_CAPABILITY_EVENTS_SUPPORTED); - } + } else { + if (btif_get_avrcp_version(channel) >= BTIF_AVRCP_VERSION_1_3) { + APP_A2DP_TRACE(0, "::AVRCP_GET_CAPABILITY\n"); + if (app_bt_device.avrcp_cmd1[device_id] == NULL) { + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_cmd1[device_id]); + } + btif_avrcp_ct_get_capabilities(channel, + app_bt_device.avrcp_cmd1[device_id], + BTIF_AVRCP_CAPABILITY_EVENTS_SUPPORTED); } - + } } -void app_avrcp_get_capabilities_retry_callback(void const *param) -{ - app_avrcp_get_capabilities_ctx_t *get_capabilities_ctx = (app_avrcp_get_capabilities_ctx_t *)param; - enum BT_DEVICE_ID_T device_id = BT_DEVICE_ID_1; - btif_avrcp_channel_t *channel = NULL; +void app_avrcp_get_capabilities_retry_callback(void const *param) { + app_avrcp_get_capabilities_ctx_t *get_capabilities_ctx = + (app_avrcp_get_capabilities_ctx_t *)param; + enum BT_DEVICE_ID_T device_id = BT_DEVICE_ID_1; + btif_avrcp_channel_t *channel = NULL; #ifdef __BT_ONE_BRING_TWO__ - device_id = (get_capabilities_ctx->chnl == app_bt_device.avrcp_channel[0]->avrcp_channel_handle) ? BT_DEVICE_ID_1 : BT_DEVICE_ID_2; + device_id = (get_capabilities_ctx->chnl == + app_bt_device.avrcp_channel[0]->avrcp_channel_handle) + ? BT_DEVICE_ID_1 + : BT_DEVICE_ID_2; #else - device_id = BT_DEVICE_ID_1; + device_id = BT_DEVICE_ID_1; #endif - channel = btif_get_avrcp_channel(get_capabilities_ctx->chnl); + channel = btif_get_avrcp_channel(get_capabilities_ctx->chnl); - get_capabilities_ctx->retry_cnt--; + get_capabilities_ctx->retry_cnt--; - if (btif_get_avrcp_state(channel) != BTIF_AVRCP_STATE_CONNECTED) - { - APP_A2DP_TRACE(0,"::AVRCP_GET_CAPABILITY CONTINUE disconnect cancel"); - return; - } + if (btif_get_avrcp_state(channel) != BTIF_AVRCP_STATE_CONNECTED) { + APP_A2DP_TRACE(0, "::AVRCP_GET_CAPABILITY CONTINUE disconnect cancel"); + return; + } - if (get_capabilities_ctx->retry_cnt <= 0) - { - APP_A2DP_TRACE(0,"::AVRCP_GET_CAPABILITY CONTINUE limit cancel"); - return; - } + if (get_capabilities_ctx->retry_cnt <= 0) { + APP_A2DP_TRACE(0, "::AVRCP_GET_CAPABILITY CONTINUE limit cancel"); + return; + } - if (app_bt_device.avrcp_cmd1[device_id] == NULL) - { - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_cmd1[device_id]); - } + if (app_bt_device.avrcp_cmd1[device_id] == NULL) { + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_cmd1[device_id]); + } - if (btif_get_avrcp_version(channel) == BTIF_AVRCP_VERSION_UNKNOWN) - { - APP_A2DP_TRACE(1,"::AVRCP_GET_CAPABILITY CONTINUE cnt:%d\n", get_capabilities_ctx->retry_cnt); - switch (device_id) - { + if (btif_get_avrcp_version(channel) == BTIF_AVRCP_VERSION_UNKNOWN) { + APP_A2DP_TRACE(1, "::AVRCP_GET_CAPABILITY CONTINUE cnt:%d\n", + get_capabilities_ctx->retry_cnt); + switch (device_id) { #ifdef __BT_ONE_BRING_TWO__ - case BT_DEVICE_ID_2: - osTimerStart(app_avrcp_get_capabilities_ctx1.delay_timer, MAX_GET_CAPABILITIES_RETRY_INTERVAL); - break; + case BT_DEVICE_ID_2: + osTimerStart(app_avrcp_get_capabilities_ctx1.delay_timer, + MAX_GET_CAPABILITIES_RETRY_INTERVAL); + break; #endif - case BT_DEVICE_ID_1: - default: - osTimerStart(app_avrcp_get_capabilities_ctx0.delay_timer, MAX_GET_CAPABILITIES_RETRY_INTERVAL); - break; - } + case BT_DEVICE_ID_1: + default: + osTimerStart(app_avrcp_get_capabilities_ctx0.delay_timer, + MAX_GET_CAPABILITIES_RETRY_INTERVAL); + break; } - else - { - if(btif_get_avrcp_version(channel) >= BTIF_AVRCP_VERSION_1_3) - { - APP_A2DP_TRACE(0,"::AVRCP_GET_CAPABILITY\n"); - if (app_bt_device.avrcp_cmd1[device_id] == NULL){ - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_cmd1[device_id]); - } - btif_avrcp_ct_get_capabilities(channel, app_bt_device.avrcp_cmd1[device_id],BTIF_AVRCP_CAPABILITY_EVENTS_SUPPORTED); - } + } else { + if (btif_get_avrcp_version(channel) >= BTIF_AVRCP_VERSION_1_3) { + APP_A2DP_TRACE(0, "::AVRCP_GET_CAPABILITY\n"); + if (app_bt_device.avrcp_cmd1[device_id] == NULL) { + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_cmd1[device_id]); + } + btif_avrcp_ct_get_capabilities(channel, + app_bt_device.avrcp_cmd1[device_id], + BTIF_AVRCP_CAPABILITY_EVENTS_SUPPORTED); } + } } - #ifdef BTIF_AVRCP_ADVANCED_CONTROLLER -void a2dp_init(void) -{ - btif_a2dp_init(); - for(int i =0; i< BT_DEVICE_NUM; i++ ){ - app_bt_device.a2dp_stream[i] = btif_a2dp_alloc_stream(); +void a2dp_init(void) { + btif_a2dp_init(); + for (int i = 0; i < BT_DEVICE_NUM; i++) { + app_bt_device.a2dp_stream[i] = btif_a2dp_alloc_stream(); #if defined(A2DP_LHDC_ON) - app_bt_device.a2dp_lhdc_stream[i] = btif_a2dp_alloc_stream(); + app_bt_device.a2dp_lhdc_stream[i] = btif_a2dp_alloc_stream(); #endif #if defined(A2DP_SCALABLE_ON) - app_bt_device.a2dp_scalable_stream[i] = btif_a2dp_alloc_stream(); + app_bt_device.a2dp_scalable_stream[i] = btif_a2dp_alloc_stream(); #endif #if defined(ALL_USE_OPUS) - app_bt_device.a2dp_aac_stream[i] = btif_a2dp_alloc_stream(); + app_bt_device.a2dp_aac_stream[i] = btif_a2dp_alloc_stream(); #endif #if defined(A2DP_AAC_ON) - app_bt_device.a2dp_aac_stream[i] = btif_a2dp_alloc_stream(); + app_bt_device.a2dp_aac_stream[i] = btif_a2dp_alloc_stream(); #endif #if defined(A2DP_LDAC_ON) - app_bt_device.a2dp_ldac_stream[i] = btif_a2dp_alloc_stream(); + app_bt_device.a2dp_ldac_stream[i] = btif_a2dp_alloc_stream(); #endif - } + } -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) - struct nvrecord_env_t *nvrecord_env; - nv_record_env_get(&nvrecord_env); - app_bt_device.src_or_snk=nvrecord_env->src_snk_flag.src_snk_mode; - app_bt_device.src_or_snk=BT_DEVICE_SRC; -// app_bt_device.src_or_snk=BT_DEVICE_SNK; - TRACE(1,"src_or_snk:%d\n",app_bt_device.src_or_snk); - app_bt_device.input_onoff=0; +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) + struct nvrecord_env_t *nvrecord_env; + nv_record_env_get(&nvrecord_env); + app_bt_device.src_or_snk = nvrecord_env->src_snk_flag.src_snk_mode; + app_bt_device.src_or_snk = BT_DEVICE_SRC; + // app_bt_device.src_or_snk=BT_DEVICE_SNK; + TRACE(1, "src_or_snk:%d\n", app_bt_device.src_or_snk); + app_bt_device.input_onoff = 0; #endif - for(uint8_t i=0; iaddress, - bd_addr_2->address, BTIF_BD_ADDR_SIZE) == 0); + return (memcmp(bd_addr_1->address, bd_addr_2->address, BTIF_BD_ADDR_SIZE) == + 0); } -bool a2dp_id_from_bdaddr(bt_bdaddr_t *bd_addr, uint8_t *id) -{ +bool a2dp_id_from_bdaddr(bt_bdaddr_t *bd_addr, uint8_t *id) { bt_bdaddr_t curr_addr = {0}; uint8_t curr_id = BT_DEVICE_NUM; - if (app_bt_is_device_connected(BT_DEVICE_ID_1)) - { - a2dp_bdaddr_from_id(BT_DEVICE_ID_1, &curr_addr); - if(a2dp_bdaddr_cmp(&curr_addr, bd_addr)) { - curr_id = BT_DEVICE_ID_1; - } + if (app_bt_is_device_connected(BT_DEVICE_ID_1)) { + a2dp_bdaddr_from_id(BT_DEVICE_ID_1, &curr_addr); + if (a2dp_bdaddr_cmp(&curr_addr, bd_addr)) { + curr_id = BT_DEVICE_ID_1; + } } #ifdef __BT_ONE_BRING_TWO__ - if (app_bt_is_device_connected(BT_DEVICE_ID_2)) - { + if (app_bt_is_device_connected(BT_DEVICE_ID_2)) { a2dp_bdaddr_from_id(BT_DEVICE_ID_2, &curr_addr); - if(a2dp_bdaddr_cmp(&curr_addr, bd_addr)) { - curr_id = BT_DEVICE_ID_2; + if (a2dp_bdaddr_cmp(&curr_addr, bd_addr)) { + curr_id = BT_DEVICE_ID_2; } } #endif - if(id) { + if (id) { *id = curr_id; } return (curr_id < BT_DEVICE_NUM); } #ifdef __BT_ONE_BRING_TWO__ -#define APP_BT_PAUSE_MEDIA_PLAYER_DELAY 300 -osTimerId app_bt_pause_media_player_delay_timer_id = NULL; +#define APP_BT_PAUSE_MEDIA_PLAYER_DELAY 300 +osTimerId app_bt_pause_media_player_delay_timer_id = NULL; extern uint8_t avrcp_playback_status[BT_DEVICE_NUM]; static uint8_t deviceIdPendingForMediaPlayerPause = 0; static uint8_t deviceIdInMediaPlayHoldState = BT_DEVICE_NUM; static void app_bt_pause_media_player_delay_timer_handler(void const *n); -osTimerDef (APP_BT_PAUSE_MEDIA_PLAYER_DELAY_TIMER, app_bt_pause_media_player_delay_timer_handler); +osTimerDef(APP_BT_PAUSE_MEDIA_PLAYER_DELAY_TIMER, + app_bt_pause_media_player_delay_timer_handler); -static void app_bt_pause_media_player_delay_timer_handler(void const *n) -{ - app_bt_start_custom_function_in_bt_thread(deviceIdPendingForMediaPlayerPause, 0, (uint32_t)app_bt_pause_music_player); +static void app_bt_pause_media_player_delay_timer_handler(void const *n) { + app_bt_start_custom_function_in_bt_thread( + deviceIdPendingForMediaPlayerPause, 0, + (uint32_t)app_bt_pause_music_player); } -void app_bt_pause_media_player_again(uint8_t deviceId) -{ - if (NULL == app_bt_pause_media_player_delay_timer_id) - { - app_bt_pause_media_player_delay_timer_id = osTimerCreate( - osTimer(APP_BT_PAUSE_MEDIA_PLAYER_DELAY_TIMER), osTimerOnce, NULL); - } +void app_bt_pause_media_player_again(uint8_t deviceId) { + if (NULL == app_bt_pause_media_player_delay_timer_id) { + app_bt_pause_media_player_delay_timer_id = osTimerCreate( + osTimer(APP_BT_PAUSE_MEDIA_PLAYER_DELAY_TIMER), osTimerOnce, NULL); + } - TRACE(1,"The media player on device %d is resumed before it's allowed, so pause it again.", + TRACE(1, + "The media player on device %d is resumed before it's allowed, so " + "pause it again.", deviceId); - deviceIdPendingForMediaPlayerPause = deviceId; - osTimerStart(app_bt_pause_media_player_delay_timer_id, - APP_BT_PAUSE_MEDIA_PLAYER_DELAY); + deviceIdPendingForMediaPlayerPause = deviceId; + osTimerStart(app_bt_pause_media_player_delay_timer_id, + APP_BT_PAUSE_MEDIA_PLAYER_DELAY); } -bool app_bt_is_to_resume_music_player(uint8_t deviceId) -{ - return (deviceIdInMediaPlayHoldState == deviceId); +bool app_bt_is_to_resume_music_player(uint8_t deviceId) { + return (deviceIdInMediaPlayHoldState == deviceId); } -void app_bt_reset_music_player_resume_state(void) -{ - deviceIdInMediaPlayHoldState = BT_DEVICE_NUM; +void app_bt_reset_music_player_resume_state(void) { + deviceIdInMediaPlayHoldState = BT_DEVICE_NUM; } -void app_bt_set_music_player_resume_device(uint8_t deviceId) -{ - deviceIdInMediaPlayHoldState = deviceId; +void app_bt_set_music_player_resume_device(uint8_t deviceId) { + deviceIdInMediaPlayHoldState = deviceId; } -bool app_bt_is_music_player_working(uint8_t deviceId) -{ - TRACE(3,"device %d a2dp streaming %d playback state %d", - deviceId, app_bt_is_a2dp_streaming(deviceId), - avrcp_playback_status[deviceId]); - return (app_bt_is_a2dp_streaming(deviceId) && - avrcp_playback_status[deviceId]); +bool app_bt_is_music_player_working(uint8_t deviceId) { + TRACE(3, "device %d a2dp streaming %d playback state %d", deviceId, + app_bt_is_a2dp_streaming(deviceId), avrcp_playback_status[deviceId]); + return (app_bt_is_a2dp_streaming(deviceId) && + avrcp_playback_status[deviceId]); } -void app_bt_suspend_a2dp_streaming(uint8_t deviceId) -{ - if (!app_bt_is_a2dp_streaming(deviceId)) - { - return; - } +void app_bt_suspend_a2dp_streaming(uint8_t deviceId) { + if (!app_bt_is_a2dp_streaming(deviceId)) { + return; + } - TRACE(1,"Suspend a2dp streaming of device %d", deviceId); - btif_a2dp_suspend_stream(app_bt_device.a2dp_connected_stream[deviceId]); + TRACE(1, "Suspend a2dp streaming of device %d", deviceId); + btif_a2dp_suspend_stream(app_bt_device.a2dp_connected_stream[deviceId]); } +bool app_bt_pause_music_player(uint8_t deviceId) { + if (!app_bt_is_music_player_working(deviceId)) { + return false; + } + btif_avrcp_channel_t *avrcp_channel_tmp = + app_bt_device.avrcp_channel[deviceId]; -bool app_bt_pause_music_player(uint8_t deviceId) -{ - if (!app_bt_is_music_player_working(deviceId)) - { - return false; - } + TRACE(1, "Pause music player of device %d", deviceId); + app_bt_suspend_a2dp_streaming(deviceId); - btif_avrcp_channel_t *avrcp_channel_tmp = - app_bt_device.avrcp_channel[deviceId]; + btif_avrcp_set_panel_key(avrcp_channel_tmp, BTIF_AVRCP_POP_PAUSE, TRUE); + btif_avrcp_set_panel_key(avrcp_channel_tmp, BTIF_AVRCP_POP_PAUSE, FALSE); - TRACE(1,"Pause music player of device %d", deviceId); - app_bt_suspend_a2dp_streaming(deviceId); + app_bt_device.a2dp_play_pause_flag = 0; - btif_avrcp_set_panel_key(avrcp_channel_tmp,BTIF_AVRCP_POP_PAUSE,TRUE); - btif_avrcp_set_panel_key(avrcp_channel_tmp,BTIF_AVRCP_POP_PAUSE,FALSE); - - app_bt_device.a2dp_play_pause_flag = 0; - - return true; + return true; } -void app_bt_resume_music_player(uint8_t deviceId) -{ - app_bt_reset_music_player_resume_state(); +void app_bt_resume_music_player(uint8_t deviceId) { + app_bt_reset_music_player_resume_state(); - if (app_bt_is_music_player_working(deviceId)) - { - return; - } + if (app_bt_is_music_player_working(deviceId)) { + return; + } - btif_avrcp_channel_t *avrcp_channel_tmp = - app_bt_device.avrcp_channel[deviceId]; + btif_avrcp_channel_t *avrcp_channel_tmp = + app_bt_device.avrcp_channel[deviceId]; - TRACE(1,"Resume music player of device %d", deviceId); - btif_avrcp_set_panel_key(avrcp_channel_tmp,BTIF_AVRCP_POP_PLAY,TRUE); - btif_avrcp_set_panel_key(avrcp_channel_tmp,BTIF_AVRCP_POP_PLAY,FALSE); - app_bt_device.a2dp_play_pause_flag = 1; + TRACE(1, "Resume music player of device %d", deviceId); + btif_avrcp_set_panel_key(avrcp_channel_tmp, BTIF_AVRCP_POP_PLAY, TRUE); + btif_avrcp_set_panel_key(avrcp_channel_tmp, BTIF_AVRCP_POP_PLAY, FALSE); + app_bt_device.a2dp_play_pause_flag = 1; } #endif -bool app_bt_is_a2dp_streaming(uint8_t deviceId) -{ - return app_bt_device.a2dp_streamming[deviceId]; +bool app_bt_is_a2dp_streaming(uint8_t deviceId) { + return app_bt_device.a2dp_streamming[deviceId]; } -FRAM_TEXT_LOC uint8_t bt_sbc_player_get_codec_type(void) -{ - enum BT_DEVICE_ID_T st_id = app_bt_device.curr_a2dp_stream_id; - if(app_bt_device.a2dp_connected_stream[st_id]) - return btif_a2dp_get_stream_codec(app_bt_device.a2dp_connected_stream[st_id])->codecType; - else - return BTIF_AVDTP_CODEC_TYPE_SBC; +FRAM_TEXT_LOC uint8_t bt_sbc_player_get_codec_type(void) { + enum BT_DEVICE_ID_T st_id = app_bt_device.curr_a2dp_stream_id; + if (app_bt_device.a2dp_connected_stream[st_id]) + return btif_a2dp_get_stream_codec( + app_bt_device.a2dp_connected_stream[st_id]) + ->codecType; + else + return BTIF_AVDTP_CODEC_TYPE_SBC; } FRAM_TEXT_LOC uint8_t bt_sbc_player_get_sample_bit(void) { - enum BT_DEVICE_ID_T st_id = app_bt_device.curr_a2dp_stream_id; + enum BT_DEVICE_ID_T st_id = app_bt_device.curr_a2dp_stream_id; - return app_bt_device.sample_bit[st_id]; + return app_bt_device.sample_bit[st_id]; } - #ifdef __BT_ONE_BRING_TWO__ uint8_t avrcp_playback_status[BT_DEVICE_NUM] = {0}; static struct BT_DEVICE_ID_DIFF avrcp_bond_a2dp_stream; -static uint8_t avrcp_bonding_a2dp_id[BT_DEVICE_NUM] = {BT_DEVICE_NUM,BT_DEVICE_NUM}; -static POSSIBLY_UNUSED uint8_t a2dp_get_cur_stream_id(void) -{ - return (uint8_t)app_bt_device.curr_a2dp_stream_id; +static uint8_t avrcp_bonding_a2dp_id[BT_DEVICE_NUM] = {BT_DEVICE_NUM, + BT_DEVICE_NUM}; +static POSSIBLY_UNUSED uint8_t a2dp_get_cur_stream_id(void) { + return (uint8_t)app_bt_device.curr_a2dp_stream_id; } -static uint8_t avrcp_find_a2dp_stream_id(btif_avrcp_chnl_handle_t chnl) -{ - btif_remote_device_t * p_avrcp_remDev = btif_avrcp_get_remote_device(chnl); - uint8_t i =0; - btif_remote_device_t * p_a2dp_remDev = 0; - TRACE(1,"avrcp_remDev = %p",p_avrcp_remDev); - for(i = 0; iavrcp_channel_handle) - == btif_a2dp_get_remote_device(ptrA2dpStream)) - { - avrcp_bond_a2dp_stream.id = (enum BT_DEVICE_ID_T)a2dpDevIndex; - avrcp_bonding_a2dp_id[avrcpIndex] = a2dpDevIndex; - break; - } +static void a2dp_to_bond_avrcp_with_stream(a2dp_stream_t *ptrA2dpStream, + uint8_t a2dpDevIndex) { + for (uint8_t avrcpIndex = 0; avrcpIndex < BT_DEVICE_NUM; avrcpIndex++) { + if (btif_avrcp_get_remote_device( + app_bt_device.avrcp_channel[avrcpIndex]->avrcp_channel_handle) == + btif_a2dp_get_remote_device(ptrA2dpStream)) { + avrcp_bond_a2dp_stream.id = (enum BT_DEVICE_ID_T)a2dpDevIndex; + avrcp_bonding_a2dp_id[avrcpIndex] = a2dpDevIndex; + break; } + } } #endif @@ -707,85 +700,72 @@ static void a2dp_to_bond_avrcp_with_stream(a2dp_stream_t* ptrA2dpStream, uint8_t void a2dp_update_music_link(void); #endif -static void a2dp_set_cur_stream(enum BT_DEVICE_ID_T id) -{ - TRACE(1,"Set current a2dp stream as %d", id); - app_bt_device.curr_a2dp_stream_id = id; - if(app_bt_device.a2dp_connected_stream[id]) - { - btif_remote_device_t* activeRem = - btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[id]); - if(activeRem) - app_bt_device.current_a2dp_conhdl= btif_me_get_remote_device_hci_handle(activeRem); - else - app_bt_device.current_a2dp_conhdl= 0xffff; - - } +static void a2dp_set_cur_stream(enum BT_DEVICE_ID_T id) { + TRACE(1, "Set current a2dp stream as %d", id); + app_bt_device.curr_a2dp_stream_id = id; + if (app_bt_device.a2dp_connected_stream[id]) { + btif_remote_device_t *activeRem = + btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[id]); + if (activeRem) + app_bt_device.current_a2dp_conhdl = + btif_me_get_remote_device_hci_handle(activeRem); else - { - app_bt_device.current_a2dp_conhdl= 0xffff; - } + app_bt_device.current_a2dp_conhdl = 0xffff; + + } else { + app_bt_device.current_a2dp_conhdl = 0xffff; + } #ifdef __BT_ONE_BRING_TWO__ - a2dp_update_music_link(); + a2dp_update_music_link(); #endif } static uint8_t a2dp_skip_frame_cnt = 0; -enum BT_DEVICE_ID_T a2dp_get_cur_stream(void) -{ - return app_bt_device.curr_a2dp_stream_id; +enum BT_DEVICE_ID_T a2dp_get_cur_stream(void) { + return app_bt_device.curr_a2dp_stream_id; } -uint16_t a2dp_Get_curr_a2dp_conhdl(void) -{ - return app_bt_device.current_a2dp_conhdl; +uint16_t a2dp_Get_curr_a2dp_conhdl(void) { + return app_bt_device.current_a2dp_conhdl; } -void a2dp_get_curStream_remDev(btif_remote_device_t **p_remDev) -{ - enum BT_DEVICE_ID_T id = a2dp_get_cur_stream(); - uint8_t i =0; - if(id != BT_DEVICE_NUM) - i = id; - *p_remDev = btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[i]); - //TRACE(1,"temp_addr = %x",*p_remDev); +void a2dp_get_curStream_remDev(btif_remote_device_t **p_remDev) { + enum BT_DEVICE_ID_T id = a2dp_get_cur_stream(); + uint8_t i = 0; + if (id != BT_DEVICE_NUM) + i = id; + *p_remDev = + btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[i]); + // TRACE(1,"temp_addr = %x",*p_remDev); } -uint8_t app_a2dp_run_skip_frame(void) -{ - if(a2dp_skip_frame_cnt > 0){ - a2dp_skip_frame_cnt--; - return 1; - } - a2dp_skip_frame_cnt = 0; - return 0; +uint8_t app_a2dp_run_skip_frame(void) { + if (a2dp_skip_frame_cnt > 0) { + a2dp_skip_frame_cnt--; + return 1; + } + a2dp_skip_frame_cnt = 0; + return 0; } -void app_a2dp_set_skip_frame(uint8_t frames) -{ - a2dp_skip_frame_cnt = frames; -} -#define SWITCH_MUTE_FRAMES_CNT 65 -void app_a2dp_hold_mute() -{ - TRACE(0,"mute a2dp streaming."); - a2dp_skip_frame_cnt = SWITCH_MUTE_FRAMES_CNT; -} -void app_a2dp_unhold_mute() -{ - a2dp_skip_frame_cnt = 0; +void app_a2dp_set_skip_frame(uint8_t frames) { a2dp_skip_frame_cnt = frames; } +#define SWITCH_MUTE_FRAMES_CNT 65 +void app_a2dp_hold_mute() { + TRACE(0, "mute a2dp streaming."); + a2dp_skip_frame_cnt = SWITCH_MUTE_FRAMES_CNT; } +void app_a2dp_unhold_mute() { a2dp_skip_frame_cnt = 0; } -avrcp_advanced_pdu_t * avrcp_get_play_status_cmd[BT_DEVICE_NUM] = {NULL}; +avrcp_advanced_pdu_t *avrcp_get_play_status_cmd[BT_DEVICE_NUM] = {NULL}; -void avrcp_get_current_media_status(enum BT_DEVICE_ID_T device_id) -{ - if(app_bt_device.avrcp_state[device_id] == 0) - return; - if (NULL == avrcp_get_play_status_cmd[device_id]) - { - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&avrcp_get_play_status_cmd[device_id]); - } - btif_avrcp_ct_get_play_status(app_bt_device.avrcp_channel[device_id], avrcp_get_play_status_cmd[device_id]); +void avrcp_get_current_media_status(enum BT_DEVICE_ID_T device_id) { + if (app_bt_device.avrcp_state[device_id] == 0) + return; + if (NULL == avrcp_get_play_status_cmd[device_id]) { + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &avrcp_get_play_status_cmd[device_id]); + } + btif_avrcp_ct_get_play_status(app_bt_device.avrcp_channel[device_id], + avrcp_get_play_status_cmd[device_id]); } void btapp_a2dp_suspend_music(enum BT_DEVICE_ID_T stream_id); @@ -795,264 +775,294 @@ void avrcp_set_media_status(uint8_t status); #ifdef USER_REBOOT_PLAY_MUSIC_AUTO extern bool a2dp_need_to_play; #endif -extern "C" void avrcp_callback_CT(btif_avrcp_chnl_handle_t chnl, const avrcp_callback_parms_t* parms) -{ - btif_avrcp_channel_t * channel = btif_get_avrcp_channel( chnl); - btif_avctp_event_t event = btif_avrcp_get_callback_event( parms); - APP_A2DP_TRACE(3,"%s : chnl %p, Parms %p\n", __func__,chnl, parms); - APP_A2DP_TRACE(2,"::%s Parms->event %d\n", __func__, btif_avrcp_get_callback_event(parms)); +extern "C" void avrcp_callback_CT(btif_avrcp_chnl_handle_t chnl, + const avrcp_callback_parms_t *parms) { + btif_avrcp_channel_t *channel = btif_get_avrcp_channel(chnl); + btif_avctp_event_t event = btif_avrcp_get_callback_event(parms); + APP_A2DP_TRACE(3, "%s : chnl %p, Parms %p\n", __func__, chnl, parms); + APP_A2DP_TRACE(2, "::%s Parms->event %d\n", __func__, + btif_avrcp_get_callback_event(parms)); #ifdef __BT_ONE_BRING_TWO__ - enum BT_DEVICE_ID_T device_id = (chnl == app_bt_device.avrcp_channel[0]->avrcp_channel_handle) ? BT_DEVICE_ID_1 : BT_DEVICE_ID_2; - enum BT_DEVICE_ID_T device_id_other = (device_id==BT_DEVICE_ID_1)?(BT_DEVICE_ID_2):(BT_DEVICE_ID_1); - APP_A2DP_TRACE(1,"device_id = %d",device_id); + enum BT_DEVICE_ID_T device_id = + (chnl == app_bt_device.avrcp_channel[0]->avrcp_channel_handle) + ? BT_DEVICE_ID_1 + : BT_DEVICE_ID_2; + enum BT_DEVICE_ID_T device_id_other = + (device_id == BT_DEVICE_ID_1) ? (BT_DEVICE_ID_2) : (BT_DEVICE_ID_1); + APP_A2DP_TRACE(1, "device_id = %d", device_id); #else - enum BT_DEVICE_ID_T device_id = BT_DEVICE_ID_1; + enum BT_DEVICE_ID_T device_id = BT_DEVICE_ID_1; #endif - switch(event) - { - case BTIF_AVRCP_EVENT_CONNECT_IND: + switch (event) { + case BTIF_AVRCP_EVENT_CONNECT_IND: #if defined(_AUTO_TEST_) - AUTO_TEST_SEND("Connect ok."); + AUTO_TEST_SEND("Connect ok."); #endif - APP_A2DP_TRACE(1,"::avrcp_callback_CT AVRCP_EVENT_CONNECT_IND %d\n", btif_avrcp_get_callback_event(parms)); - btif_avrcp_connect_rsp (channel, 1); + APP_A2DP_TRACE(1, "::avrcp_callback_CT AVRCP_EVENT_CONNECT_IND %d\n", + btif_avrcp_get_callback_event(parms)); + btif_avrcp_connect_rsp(channel, 1); - break; - case BTIF_AVRCP_EVENT_CONNECT: + break; + case BTIF_AVRCP_EVENT_CONNECT: #if defined(_AUTO_TEST_) - AUTO_TEST_SEND("Connect ok."); + AUTO_TEST_SEND("Connect ok."); #endif - app_bt_device.avrcp_state[device_id] = 1; - app_avrcp_get_capabilities_start(chnl); + app_bt_device.avrcp_state[device_id] = 1; + app_avrcp_get_capabilities_start(chnl); #ifdef AVRCP_TRACK_CHANGED - if (app_bt_device.avrcp_cmd2[device_id] == NULL) - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_cmd2[device_id]); - btif_avrcp_ct_register_notification(channel,app_bt_device.avrcp_cmd2[device_id],BTIF_AVRCP_ENABLE_TRACK_CHANGED,0); + if (app_bt_device.avrcp_cmd2[device_id] == NULL) + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_cmd2[device_id]); + btif_avrcp_ct_register_notification(channel, + app_bt_device.avrcp_cmd2[device_id], + BTIF_AVRCP_ENABLE_TRACK_CHANGED, 0); #endif #ifdef __AVRCP_TRACK_PLAY_STATUS__ - TRACE(0,"::REG AVRCP_EID_MEDIA_STATUS_CHANGED\n"); - if (app_bt_device.avrcp_cmd1[device_id] == NULL) - app_a2dp_avrcpadvancedpdu_mempool_calloc(app_bt_device.avrcp_cmd1[device_id]); - btif_avrcp_ct_register_notification(channel,app_bt_device.avrcp_cmd1[device_id],AVRCP_EID_MEDIA_STATUS_CHANGED,0); + TRACE(0, "::REG AVRCP_EID_MEDIA_STATUS_CHANGED\n"); + if (app_bt_device.avrcp_cmd1[device_id] == NULL) + app_a2dp_avrcpadvancedpdu_mempool_calloc( + app_bt_device.avrcp_cmd1[device_id]); + btif_avrcp_ct_register_notification(channel, + app_bt_device.avrcp_cmd1[device_id], + AVRCP_EID_MEDIA_STATUS_CHANGED, 0); #endif - avrcp_get_current_media_status(device_id); - APP_A2DP_TRACE(2,"::AVRCP_EVENT_CONNECT avrcp_version=0x%x,device_id=%d\n", btif_get_avrcp_version( channel),device_id); + avrcp_get_current_media_status(device_id); + APP_A2DP_TRACE(2, "::AVRCP_EVENT_CONNECT avrcp_version=0x%x,device_id=%d\n", + btif_get_avrcp_version(channel), device_id); #ifdef __BT_ONE_BRING_TWO__ - avrcp_playback_status[device_id] = 0; - avrcp_bonding_a2dp_id[device_id] = BT_DEVICE_NUM; - avrcp_distinguish_bonding_a2dp_stream(chnl,device_id); + avrcp_playback_status[device_id] = 0; + avrcp_bonding_a2dp_id[device_id] = BT_DEVICE_NUM; + avrcp_distinguish_bonding_a2dp_stream(chnl, device_id); #endif #ifdef USER_REBOOT_PLAY_MUSIC_AUTO - if(a2dp_need_to_play == true){ - TRACE(0,"a2dp_need_to_play is true,now play music"); - a2dp_handleKey(AVRCP_KEY_PLAY); - a2dp_need_to_play = false; - } + if (a2dp_need_to_play == true) { + TRACE(0, "a2dp_need_to_play is true,now play music"); + a2dp_handleKey(AVRCP_KEY_PLAY); + a2dp_need_to_play = false; + } #endif - app_avrcp_connect_try_times[device_id] = 0; - break; - case BTIF_AVRCP_EVENT_DISCONNECT: - app_bt_device.avrcp_state[device_id] = 0; - TRACE(0,"::AVRCP_EVENT_DISCONNECT"); - #ifdef __BT_ONE_BRING_TWO__ - if (app_bt_is_to_resume_music_player(device_id)) - { - app_bt_reset_music_player_resume_state(); - } - #endif - if (app_bt_device.avrcp_get_capabilities_rsp[device_id]){ - btif_app_a2dp_avrcpadvancedpdu_mempool_free(app_bt_device.avrcp_get_capabilities_rsp[device_id]); - app_bt_device.avrcp_get_capabilities_rsp[device_id] = NULL; - } - if (app_bt_device.avrcp_control_rsp[device_id]){ - btif_app_a2dp_avrcpadvancedpdu_mempool_free(app_bt_device.avrcp_control_rsp[device_id]); - app_bt_device.avrcp_control_rsp[device_id] = NULL; - } - if (app_bt_device.avrcp_notify_rsp[device_id]){ - btif_app_a2dp_avrcpadvancedpdu_mempool_free(app_bt_device.avrcp_notify_rsp[device_id]); - app_bt_device.avrcp_notify_rsp[device_id] = NULL; - } + app_avrcp_connect_try_times[device_id] = 0; + break; + case BTIF_AVRCP_EVENT_DISCONNECT: + app_bt_device.avrcp_state[device_id] = 0; + TRACE(0, "::AVRCP_EVENT_DISCONNECT"); +#ifdef __BT_ONE_BRING_TWO__ + if (app_bt_is_to_resume_music_player(device_id)) { + app_bt_reset_music_player_resume_state(); + } +#endif + if (app_bt_device.avrcp_get_capabilities_rsp[device_id]) { + btif_app_a2dp_avrcpadvancedpdu_mempool_free( + app_bt_device.avrcp_get_capabilities_rsp[device_id]); + app_bt_device.avrcp_get_capabilities_rsp[device_id] = NULL; + } + if (app_bt_device.avrcp_control_rsp[device_id]) { + btif_app_a2dp_avrcpadvancedpdu_mempool_free( + app_bt_device.avrcp_control_rsp[device_id]); + app_bt_device.avrcp_control_rsp[device_id] = NULL; + } + if (app_bt_device.avrcp_notify_rsp[device_id]) { + btif_app_a2dp_avrcpadvancedpdu_mempool_free( + app_bt_device.avrcp_notify_rsp[device_id]); + app_bt_device.avrcp_notify_rsp[device_id] = NULL; + } - if (app_bt_device.avrcp_cmd1[device_id]){ - btif_app_a2dp_avrcpadvancedpdu_mempool_free(app_bt_device.avrcp_cmd1[device_id]); - app_bt_device.avrcp_cmd1[device_id] = NULL; - } - if (app_bt_device.avrcp_cmd2[device_id]){ - btif_app_a2dp_avrcpadvancedpdu_mempool_free(app_bt_device.avrcp_cmd2[device_id]); - app_bt_device.avrcp_cmd2[device_id] = NULL; - } - app_bt_device.volume_report[device_id] = 0; + if (app_bt_device.avrcp_cmd1[device_id]) { + btif_app_a2dp_avrcpadvancedpdu_mempool_free( + app_bt_device.avrcp_cmd1[device_id]); + app_bt_device.avrcp_cmd1[device_id] = NULL; + } + if (app_bt_device.avrcp_cmd2[device_id]) { + btif_app_a2dp_avrcpadvancedpdu_mempool_free( + app_bt_device.avrcp_cmd2[device_id]); + app_bt_device.avrcp_cmd2[device_id] = NULL; + } + app_bt_device.volume_report[device_id] = 0; #ifdef AVRCP_TRACK_CHANGED - app_bt_device.track_changed[device_id] = 0; + app_bt_device.track_changed[device_id] = 0; #endif #ifdef __BT_ONE_BRING_TWO__ - avrcp_playback_status[device_id ] = 0; - avrcp_bonding_a2dp_id[device_id] = BT_DEVICE_NUM; + avrcp_playback_status[device_id] = 0; + avrcp_bonding_a2dp_id[device_id] = BT_DEVICE_NUM; #endif - if (0 == device_id) - { - osTimerStop(app_avrcp_connect_timer0); - } + if (0 == device_id) { + osTimerStop(app_avrcp_connect_timer0); + } #ifdef __BT_ONE_BRING_TWO__ - else - { - osTimerStop(app_avrcp_connect_timer1); - } + else { + osTimerStop(app_avrcp_connect_timer1); + } #endif #ifndef IBRT - if(!app_is_disconnecting_all_bt_connections()) - { - app_avrcp_connect_try_times[device_id]++; - if (app_avrcp_connect_try_times[device_id] < MAX_AVRCP_CONNECT_TRY_TIME) - { - if (0 == device_id) - { - osTimerStart(app_avrcp_connect_timer0, 3000); - } - #ifdef __BT_ONE_BRING_TWO__ - else - { - osTimerStart(app_avrcp_connect_timer1, 3000); - } - #endif - } - } + if (!app_is_disconnecting_all_bt_connections()) { + app_avrcp_connect_try_times[device_id]++; + if (app_avrcp_connect_try_times[device_id] < MAX_AVRCP_CONNECT_TRY_TIME) { + if (0 == device_id) { + osTimerStart(app_avrcp_connect_timer0, 3000); + } +#ifdef __BT_ONE_BRING_TWO__ + else { + osTimerStart(app_avrcp_connect_timer1, 3000); + } #endif - break; - case BTIF_AVRCP_EVENT_RESPONSE: - APP_A2DP_TRACE(2,"::avrcp_callback_CT AVRCP_EVENT_RESPONSE op=%x,status=%x\n", btif_get_avrcp_cb_channel_advOp(parms), - btif_get_avrcp_cb_channel_state(parms)); + } + } +#endif + break; + case BTIF_AVRCP_EVENT_RESPONSE: + APP_A2DP_TRACE(2, + "::avrcp_callback_CT AVRCP_EVENT_RESPONSE op=%x,status=%x\n", + btif_get_avrcp_cb_channel_advOp(parms), + btif_get_avrcp_cb_channel_state(parms)); + if (btif_get_avrcp_cb_channel_advOp(parms) == + BTIF_AVRCP_OP_GET_PLAY_STATUS) { + avrcp_set_media_status((uint8_t)btif_get_avrcp_cb_channel_state(parms)); + if (btif_get_avrcp_cb_channel_state(parms) == 0x1) { + app_bt_device.a2dp_play_pause_flag = 1; + } else if (btif_get_avrcp_adv_rsp_play_status(parms)->mediaStatus == + 0x0 || + btif_get_avrcp_adv_rsp_play_status(parms)->mediaStatus == + 0x2) { + app_bt_device.a2dp_play_pause_flag = 0; + } + } - if( btif_get_avrcp_cb_channel_advOp(parms) == BTIF_AVRCP_OP_GET_PLAY_STATUS) - { - avrcp_set_media_status((uint8_t)btif_get_avrcp_cb_channel_state(parms)); - if( btif_get_avrcp_cb_channel_state(parms) == 0x1) - { - app_bt_device.a2dp_play_pause_flag = 1; - } - else if(btif_get_avrcp_adv_rsp_play_status(parms)->mediaStatus == 0x0||btif_get_avrcp_adv_rsp_play_status(parms)->mediaStatus == 0x2) - { - app_bt_device.a2dp_play_pause_flag = 0; - } - } + break; +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) + /*For Sony Compability Consideration*/ + case BTIF_AVRCP_EVENT_PANEL_PRESS: + TRACE(3, "::avrcp_callback_TG AVRCP_EVENT_PANEL_PRESS %x,%x,device_id=%d", + btif_get_avrcp_panel_cnf(parms)->operation, + btif_get_avrcp_panel_ind(parms)->operation, device_id); - break; -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) -/*For Sony Compability Consideration*/ - case BTIF_AVRCP_EVENT_PANEL_PRESS: - TRACE(3,"::avrcp_callback_TG AVRCP_EVENT_PANEL_PRESS %x,%x,device_id=%d", - btif_get_avrcp_panel_cnf (parms)->operation, btif_get_avrcp_panel_ind( parms)->operation,device_id); - - switch( btif_get_avrcp_panel_ind( parms)->operation) - { - case BTIF_AVRCP_POP_VOLUME_UP: - TRACE(0,"avrcp_callback_TG avrcp_key = AVRCP_KEY_VOLUME_UP"); - app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_UP, 0); - break; - case BTIF_AVRCP_POP_VOLUME_DOWN: - TRACE(0,"avrcp_callback_TG avrcp_key = AVRCP_KEY_VOLUME_DOWN"); - app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_DOWN, 0); - break; - //SRC:for accept play/pause command from snk - case BTIF_AVRCP_POP_PLAY: - TRACE(0,"::avrcp start stream !"); - app_a2dp_start_stream(); - break; - case BTIF_AVRCP_POP_PAUSE: - TRACE(0,"::acrcp stop stream !"); - app_a2dp_suspend_stream(); - break; - default : - break; - } - break; + switch (btif_get_avrcp_panel_ind(parms)->operation) { + case BTIF_AVRCP_POP_VOLUME_UP: + TRACE(0, "avrcp_callback_TG avrcp_key = AVRCP_KEY_VOLUME_UP"); + app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_UP, 0); + break; + case BTIF_AVRCP_POP_VOLUME_DOWN: + TRACE(0, "avrcp_callback_TG avrcp_key = AVRCP_KEY_VOLUME_DOWN"); + app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_DOWN, 0); + break; + // SRC:for accept play/pause command from snk + case BTIF_AVRCP_POP_PLAY: + TRACE(0, "::avrcp start stream !"); + app_a2dp_start_stream(); + break; + case BTIF_AVRCP_POP_PAUSE: + TRACE(0, "::acrcp stop stream !"); + app_a2dp_suspend_stream(); + break; + default: + break; + } + break; #else - /*For Sony Compability Consideration*/ - case BTIF_AVRCP_EVENT_PANEL_PRESS: - TRACE(3,"::avrcp_callback_TG AVRCP_EVENT_PANEL_PRESS %x,%x,device_id=%d", - btif_get_avrcp_panel_cnf (parms)->operation, btif_get_avrcp_panel_ind( parms)->operation,device_id); - switch(btif_get_avrcp_panel_cnf (parms)->operation) - { - case BTIF_AVRCP_POP_VOLUME_UP: - TRACE(0,"avrcp_callback_TG avrcp_key = AVRCP_KEY_VOLUME_UP"); - app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_UP, 0); - break; - case BTIF_AVRCP_POP_VOLUME_DOWN: - TRACE(0,"avrcp_callback_TG avrcp_key = AVRCP_KEY_VOLUME_DOWN"); - app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_DOWN, 0); - break; - default : - break; - } - break; + /*For Sony Compability Consideration*/ + case BTIF_AVRCP_EVENT_PANEL_PRESS: + TRACE(3, "::avrcp_callback_TG AVRCP_EVENT_PANEL_PRESS %x,%x,device_id=%d", + btif_get_avrcp_panel_cnf(parms)->operation, + btif_get_avrcp_panel_ind(parms)->operation, device_id); + switch (btif_get_avrcp_panel_cnf(parms)->operation) { + case BTIF_AVRCP_POP_VOLUME_UP: + TRACE(0, "avrcp_callback_TG avrcp_key = AVRCP_KEY_VOLUME_UP"); + app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_UP, 0); + break; + case BTIF_AVRCP_POP_VOLUME_DOWN: + TRACE(0, "avrcp_callback_TG avrcp_key = AVRCP_KEY_VOLUME_DOWN"); + app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_DOWN, 0); + break; + default: + break; + } + break; #endif - case BTIF_AVRCP_EVENT_PANEL_HOLD: - TRACE(2,"::avrcp_callback_TG AVRCP_EVENT_PANEL_HOLD %x,%x", - btif_get_avrcp_panel_cnf (parms)->operation, btif_get_avrcp_panel_ind( parms)->operation); - break; - case BTIF_AVRCP_EVENT_PANEL_RELEASE: - TRACE(2,"::avrcp_callback_TG AVRCP_EVENT_PANEL_RELEASE %x,%x", - btif_get_avrcp_panel_cnf (parms)->operation,btif_get_avrcp_panel_ind( parms)->operation); - break; - /*For Sony Compability Consideration End*/ - case BTIF_AVRCP_EVENT_PANEL_CNF: - TRACE(3,"::AVRCP_EVENT_PANEL_CNF %x,%x,%x", - btif_get_avrcp_panel_cnf (parms)->operation, btif_get_avrcp_panel_cnf (parms)->press, btif_get_avrcp_panel_cnf (parms)->response); - break; - case BTIF_AVRCP_EVENT_ADV_TX_DONE://20 - TRACE(3,"::AVRCP_EVENT_ADV_TX_DONE op:%x err_code:%d state:%d\n", btif_get_avrcp_cb_txPdu_Op(parms), - btif_get_avrcp_cb_channel_error_code(parms), - btif_get_avrcp_cb_channel_state(parms)); + case BTIF_AVRCP_EVENT_PANEL_HOLD: + TRACE(2, "::avrcp_callback_TG AVRCP_EVENT_PANEL_HOLD %x,%x", + btif_get_avrcp_panel_cnf(parms)->operation, + btif_get_avrcp_panel_ind(parms)->operation); + break; + case BTIF_AVRCP_EVENT_PANEL_RELEASE: + TRACE(2, "::avrcp_callback_TG AVRCP_EVENT_PANEL_RELEASE %x,%x", + btif_get_avrcp_panel_cnf(parms)->operation, + btif_get_avrcp_panel_ind(parms)->operation); + break; + /*For Sony Compability Consideration End*/ + case BTIF_AVRCP_EVENT_PANEL_CNF: + TRACE(3, "::AVRCP_EVENT_PANEL_CNF %x,%x,%x", + btif_get_avrcp_panel_cnf(parms)->operation, + btif_get_avrcp_panel_cnf(parms)->press, + btif_get_avrcp_panel_cnf(parms)->response); + break; + case BTIF_AVRCP_EVENT_ADV_TX_DONE: // 20 + TRACE(3, "::AVRCP_EVENT_ADV_TX_DONE op:%x err_code:%d state:%d\n", + btif_get_avrcp_cb_txPdu_Op(parms), + btif_get_avrcp_cb_channel_error_code(parms), + btif_get_avrcp_cb_channel_state(parms)); - if (btif_get_avrcp_cb_txPdu_Op(parms) == BTIF_AVRCP_OP_GET_CAPABILITIES){ - if (app_bt_device.avrcp_get_capabilities_rsp[device_id] == btif_get_avrcp_cb_txPdu( parms)){ - app_bt_device.avrcp_get_capabilities_rsp[device_id] = NULL; - btif_app_a2dp_avrcpadvancedpdu_mempool_free(btif_get_avrcp_cb_txPdu( parms)); - } - } - { - void *adv_pdu = app_bt_device.avrcp_notify_rsp[device_id]; + if (btif_get_avrcp_cb_txPdu_Op(parms) == BTIF_AVRCP_OP_GET_CAPABILITIES) { + if (app_bt_device.avrcp_get_capabilities_rsp[device_id] == + btif_get_avrcp_cb_txPdu(parms)) { + app_bt_device.avrcp_get_capabilities_rsp[device_id] = NULL; + btif_app_a2dp_avrcpadvancedpdu_mempool_free( + btif_get_avrcp_cb_txPdu(parms)); + } + } + { + void *adv_pdu = app_bt_device.avrcp_notify_rsp[device_id]; - if(adv_pdu && btif_get_avrcp_pdu_ctype(adv_pdu) == BTIF_AVCTP_RESPONSE_INTERIM) { - vol_ctrl_done_flag[device_id] = TX_DONE_FLAG_SUCCESS; - } - } - break; - case BTIF_AVRCP_EVENT_ADV_RESPONSE://18 - TRACE(2,"::avrcp_callback_CT AVRCP_EVENT_ADV_RESPONSE device_id=%d,role=%x\n",device_id,btif_get_avrcp_channel_role(channel)); - TRACE(2,"::avrcp_callback_CT AVRCP_EVENT_ADV_RESPONSE op=%x,status=%x\n", btif_get_avrcp_cb_channel_advOp(parms) - , btif_get_avrcp_cb_channel_state(parms)); + if (adv_pdu && + btif_get_avrcp_pdu_ctype(adv_pdu) == BTIF_AVCTP_RESPONSE_INTERIM) { + vol_ctrl_done_flag[device_id] = TX_DONE_FLAG_SUCCESS; + } + } + break; + case BTIF_AVRCP_EVENT_ADV_RESPONSE: // 18 + TRACE(2, + "::avrcp_callback_CT AVRCP_EVENT_ADV_RESPONSE device_id=%d,role=%x\n", + device_id, btif_get_avrcp_channel_role(channel)); + TRACE(2, "::avrcp_callback_CT AVRCP_EVENT_ADV_RESPONSE op=%x,status=%x\n", + btif_get_avrcp_cb_channel_advOp(parms), + btif_get_avrcp_cb_channel_state(parms)); - if(btif_get_avrcp_cb_channel_advOp(parms) == BTIF_AVRCP_OP_GET_PLAY_STATUS && btif_get_avrcp_cb_channel_state(parms) == BT_STS_SUCCESS) - { - TRACE(3,"::AVRCP_OP_GET_PLAY_STATUS %d/%d Status:%d", - btif_get_avrcp_adv_rsp_play_status(parms)->position, - btif_get_avrcp_adv_rsp_play_status(parms)->length, - btif_get_avrcp_adv_rsp_play_status(parms)->mediaStatus); - avrcp_set_media_status(btif_get_avrcp_adv_rsp_play_status(parms)->mediaStatus); - } + if (btif_get_avrcp_cb_channel_advOp(parms) == + BTIF_AVRCP_OP_GET_PLAY_STATUS && + btif_get_avrcp_cb_channel_state(parms) == BT_STS_SUCCESS) { + TRACE(3, "::AVRCP_OP_GET_PLAY_STATUS %d/%d Status:%d", + btif_get_avrcp_adv_rsp_play_status(parms)->position, + btif_get_avrcp_adv_rsp_play_status(parms)->length, + btif_get_avrcp_adv_rsp_play_status(parms)->mediaStatus); + avrcp_set_media_status( + btif_get_avrcp_adv_rsp_play_status(parms)->mediaStatus); + } - if(btif_get_avrcp_cb_channel_advOp(parms) == BTIF_AVRCP_OP_GET_CAPABILITIES && btif_get_avrcp_cb_channel_state(parms) == BT_STS_SUCCESS) - { - TRACE(1,"::avrcp_callback_CT AVRCP eventmask=%x\n", btif_get_avrcp_adv_rsp(parms)->capability.info.eventMask); + if (btif_get_avrcp_cb_channel_advOp(parms) == + BTIF_AVRCP_OP_GET_CAPABILITIES && + btif_get_avrcp_cb_channel_state(parms) == BT_STS_SUCCESS) { + TRACE(1, "::avrcp_callback_CT AVRCP eventmask=%x\n", + btif_get_avrcp_adv_rsp(parms)->capability.info.eventMask); - btif_set_avrcp_adv_rem_event_mask(channel, btif_get_avrcp_adv_rsp(parms)->capability.info.eventMask); - if(btif_get_avrcp_adv_rem_event_mask(channel) & BTIF_AVRCP_ENABLE_PLAY_STATUS_CHANGED) - { - TRACE(0,"::avrcp_callback_CT AVRCP send notification PLAY_STATUS_CHANGED\n"); - if (app_bt_device.avrcp_cmd1[device_id] == NULL){ - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_cmd1[device_id]); - } - btif_avrcp_ct_register_notification( channel, app_bt_device.avrcp_cmd1[device_id], BTIF_AVRCP_EID_MEDIA_STATUS_CHANGED,0); - - } - if( btif_get_avrcp_adv_rem_event_mask( channel) & BTIF_AVRCP_ENABLE_PLAY_POS_CHANGED) - { + btif_set_avrcp_adv_rem_event_mask( + channel, btif_get_avrcp_adv_rsp(parms)->capability.info.eventMask); + if (btif_get_avrcp_adv_rem_event_mask(channel) & + BTIF_AVRCP_ENABLE_PLAY_STATUS_CHANGED) { + TRACE(0, "::avrcp_callback_CT AVRCP send notification " + "PLAY_STATUS_CHANGED\n"); + if (app_bt_device.avrcp_cmd1[device_id] == NULL) { + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_cmd1[device_id]); + } + btif_avrcp_ct_register_notification( + channel, app_bt_device.avrcp_cmd1[device_id], + BTIF_AVRCP_EID_MEDIA_STATUS_CHANGED, 0); + } + if (btif_get_avrcp_adv_rem_event_mask(channel) & + BTIF_AVRCP_ENABLE_PLAY_POS_CHANGED) { #if 0 TRACE(0,"::avrcp_callback_CT AVRCP send notification PLAY_POS_CHANGED\n"); if (app_bt_device.avrcp_cmd2[device_id] == NULL){ @@ -1060,398 +1070,527 @@ extern "C" void avrcp_callback_CT(btif_avrcp_chnl_handle_t chnl, const avrcp_cal } btif_avrcp_ct_register_notification(channel,app_bt_device.avrcp_cmd2[device_id],BTIF_AVRCP_EID_PLAY_POS_CHANGED,1); #endif - } - } - else if(btif_get_avrcp_cb_channel_advOp(parms) == BTIF_AVRCP_OP_REGISTER_NOTIFY &&btif_get_avrcp_cb_channel_state(parms) == BT_STS_SUCCESS) - { - btif_avrcp_ct_register_notify_response_check(channel, btif_get_avrcp_adv_notify(parms)->event); - if(btif_get_avrcp_adv_notify(parms)->event == BTIF_AVRCP_EID_MEDIA_STATUS_CHANGED) - { - TRACE(1,"::avrcp_callback_CT ACRCP notify rsp playback states=%x",btif_get_avrcp_adv_notify(parms)->p.mediaStatus); + } + } else if (btif_get_avrcp_cb_channel_advOp(parms) == + BTIF_AVRCP_OP_REGISTER_NOTIFY && + btif_get_avrcp_cb_channel_state(parms) == BT_STS_SUCCESS) { + btif_avrcp_ct_register_notify_response_check( + channel, btif_get_avrcp_adv_notify(parms)->event); + if (btif_get_avrcp_adv_notify(parms)->event == + BTIF_AVRCP_EID_MEDIA_STATUS_CHANGED) { + TRACE(1, "::avrcp_callback_CT ACRCP notify rsp playback states=%x", + btif_get_avrcp_adv_notify(parms)->p.mediaStatus); #if defined(__BT_ONE_BRING_TWO__) - if(btif_get_avrcp_adv_notify(parms)->p.mediaStatus == 0x1){ - avrcp_playback_status[device_id] = 0x01; - if (app_bt_is_to_resume_music_player(device_id) || - (BTIF_HF_AUDIO_CON == app_bt_device.hf_audio_state[device_id_other])) - { - app_bt_pause_media_player_again(device_id); - } - }else if(btif_get_avrcp_adv_notify(parms)->p.mediaStatus == 0x0||btif_get_avrcp_adv_notify(parms)->p.mediaStatus == 0x2){ - avrcp_playback_status[device_id] = 0x00; - app_bt_device.latestPausedDevId = device_id; - } + if (btif_get_avrcp_adv_notify(parms)->p.mediaStatus == 0x1) { + avrcp_playback_status[device_id] = 0x01; + if (app_bt_is_to_resume_music_player(device_id) || + (BTIF_HF_AUDIO_CON == + app_bt_device.hf_audio_state[device_id_other])) { + app_bt_pause_media_player_again(device_id); + } + } else if (btif_get_avrcp_adv_notify(parms)->p.mediaStatus == 0x0 || + btif_get_avrcp_adv_notify(parms)->p.mediaStatus == 0x2) { + avrcp_playback_status[device_id] = 0x00; + app_bt_device.latestPausedDevId = device_id; + } #endif #if defined(__BT_ONE_BRING_TWO__) && defined(__MULTIPOINT_A2DP_PREEMPT__) - uint8_t is_a2dp_streaming = 0; - enum BT_DEVICE_ID_T avrcp_bonding_a2dp_another = BT_DEVICE_NUM; - is_a2dp_streaming = a2dp_get_streaming_id(); - TRACE(1,"is_a2dp_streaming = %d",is_a2dp_streaming); - TRACE(2,"device_id = %d other_id = %d",device_id,device_id_other); - if(avrcp_distinguish_bonding_a2dp_stream(chnl,device_id) == 0x02){ - return; - } - avrcp_bonding_a2dp_another = (avrcp_bond_a2dp_stream.id== BT_DEVICE_ID_1)?(BT_DEVICE_ID_2):(BT_DEVICE_ID_1); - TRACE(5,"avrcp_playback_status_id[%d] = %d , avrcp_playback_status_id_other[%d] = %d cur_a2dp_stream = %d",device_id, - avrcp_playback_status[device_id],device_id_other,avrcp_playback_status[device_id_other],app_bt_device.curr_a2dp_stream_id); - if((avrcp_playback_status[BT_DEVICE_ID_1] == 0) && - (avrcp_playback_status[BT_DEVICE_ID_2] == 0)){ - app_bt_device.a2dp_play_pause_flag = 0; - } - else{ - app_bt_device.a2dp_play_pause_flag = 1; - } - if(is_a2dp_streaming !=0){ - if(avrcp_playback_status[device_id] == 1) /*&& - (avrcp_playback_status[BT_DEVICE_ID_2] == 1))*/ { - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START,BT_STREAM_SBC,avrcp_bond_a2dp_stream.id,MAX_RECORD_NUM); - a2dp_set_cur_stream(avrcp_bond_a2dp_stream.id); + uint8_t is_a2dp_streaming = 0; + enum BT_DEVICE_ID_T avrcp_bonding_a2dp_another = BT_DEVICE_NUM; + is_a2dp_streaming = a2dp_get_streaming_id(); + TRACE(1, "is_a2dp_streaming = %d", is_a2dp_streaming); + TRACE(2, "device_id = %d other_id = %d", device_id, device_id_other); + if (avrcp_distinguish_bonding_a2dp_stream(chnl, device_id) == 0x02) { + return; + } + avrcp_bonding_a2dp_another = + (avrcp_bond_a2dp_stream.id == BT_DEVICE_ID_1) ? (BT_DEVICE_ID_2) + : (BT_DEVICE_ID_1); + TRACE(5, + "avrcp_playback_status_id[%d] = %d , " + "avrcp_playback_status_id_other[%d] = %d cur_a2dp_stream = %d", + device_id, avrcp_playback_status[device_id], device_id_other, + avrcp_playback_status[device_id_other], + app_bt_device.curr_a2dp_stream_id); + if ((avrcp_playback_status[BT_DEVICE_ID_1] == 0) && + (avrcp_playback_status[BT_DEVICE_ID_2] == 0)) { + app_bt_device.a2dp_play_pause_flag = 0; + } else { + app_bt_device.a2dp_play_pause_flag = 1; + } + if (is_a2dp_streaming != 0) { + if (avrcp_playback_status[device_id] == + 1) /*&& + (avrcp_playback_status[BT_DEVICE_ID_2] == 1))*/ + { + app_audio_manager_sendrequest( + APP_BT_STREAM_MANAGER_START, BT_STREAM_SBC, + avrcp_bond_a2dp_stream.id, MAX_RECORD_NUM); + a2dp_set_cur_stream(avrcp_bond_a2dp_stream.id); #if 1 - if(avrcp_playback_status[device_id_other] == 1){ - btapp_a2dp_suspend_music(device_id_other); - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP,BT_STREAM_SBC,avrcp_bonding_a2dp_another,MAX_RECORD_NUM); - /*if(bt_media_is_media_active_by_device(BT_STREAM_SBC,avrcp_bond_a2dp_stream.id_other) != 0)*/ - { - app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_SET, TGT_VOLUME_LEVEL_MUTE); - app_a2dp_hold_mute(); - } - } + if (avrcp_playback_status[device_id_other] == 1) { + btapp_a2dp_suspend_music(device_id_other); + app_audio_manager_sendrequest( + APP_BT_STREAM_MANAGER_STOP, BT_STREAM_SBC, + avrcp_bonding_a2dp_another, MAX_RECORD_NUM); + /*if(bt_media_is_media_active_by_device(BT_STREAM_SBC,avrcp_bond_a2dp_stream.id_other) + * != 0)*/ + { + app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_SET, + TGT_VOLUME_LEVEL_MUTE); + app_a2dp_hold_mute(); + } + } #endif - } - if(is_a2dp_streaming >2){ - if((avrcp_playback_status[device_id] == 1) && - (avrcp_playback_status[device_id_other] == 0)){ - a2dp_set_cur_stream(avrcp_bond_a2dp_stream.id); - } - if(app_bt_device.a2dp_play_pause_flag == 0){ - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP,BT_STREAM_SBC,avrcp_bond_a2dp_stream.id,MAX_RECORD_NUM); - } - } - if(app_bt_device.a2dp_play_pause_flag == 1){ - if(avrcp_playback_status[device_id] == 0){ - a2dp_set_cur_stream(avrcp_bonding_a2dp_another); - app_a2dp_unhold_mute(); - } - } - } - TRACE(1,">stream_id = %d",a2dp_get_cur_stream_id()); + } + if (is_a2dp_streaming > 2) { + if ((avrcp_playback_status[device_id] == 1) && + (avrcp_playback_status[device_id_other] == 0)) { + a2dp_set_cur_stream(avrcp_bond_a2dp_stream.id); + } + if (app_bt_device.a2dp_play_pause_flag == 0) { + app_audio_manager_sendrequest( + APP_BT_STREAM_MANAGER_STOP, BT_STREAM_SBC, + avrcp_bond_a2dp_stream.id, MAX_RECORD_NUM); + } + } + if (app_bt_device.a2dp_play_pause_flag == 1) { + if (avrcp_playback_status[device_id] == 0) { + a2dp_set_cur_stream(avrcp_bonding_a2dp_another); + app_a2dp_unhold_mute(); + } + } + } + TRACE(1, ">stream_id = %d", a2dp_get_cur_stream_id()); #else - avrcp_set_media_status(btif_get_avrcp_adv_notify(parms)->p.mediaStatus); - if(btif_get_avrcp_adv_notify(parms)->p.mediaStatus == 0x1) { - app_bt_device.a2dp_play_pause_flag = 1; - } else if(btif_get_avrcp_adv_notify(parms)->p.mediaStatus == 0x0||btif_get_avrcp_adv_notify(parms)->p.mediaStatus == 0x2){ - app_bt_device.a2dp_play_pause_flag = 0; - } + avrcp_set_media_status(btif_get_avrcp_adv_notify(parms)->p.mediaStatus); + if (btif_get_avrcp_adv_notify(parms)->p.mediaStatus == 0x1) { + app_bt_device.a2dp_play_pause_flag = 1; + } else if (btif_get_avrcp_adv_notify(parms)->p.mediaStatus == 0x0 || + btif_get_avrcp_adv_notify(parms)->p.mediaStatus == 0x2) { + app_bt_device.a2dp_play_pause_flag = 0; + } #endif - } - else if(btif_get_avrcp_adv_notify(parms)->event == BTIF_AVRCP_EID_PLAY_POS_CHANGED) - { - TRACE(1,"::ACRCP notify rsp play pos =%x",btif_get_avrcp_adv_notify(parms)->p.position); - } - else if(btif_get_avrcp_adv_notify(parms)->event == BTIF_AVRCP_EID_VOLUME_CHANGED){ - TRACE(1,"::ACRCP notify rsp volume =%x",btif_get_avrcp_adv_notify(parms)->p.volume); - a2dp_volume_set(device_id, btif_get_avrcp_adv_notify(parms)->p.volume); - } + } else if (btif_get_avrcp_adv_notify(parms)->event == + BTIF_AVRCP_EID_PLAY_POS_CHANGED) { + TRACE(1, "::ACRCP notify rsp play pos =%x", + btif_get_avrcp_adv_notify(parms)->p.position); + } else if (btif_get_avrcp_adv_notify(parms)->event == + BTIF_AVRCP_EID_VOLUME_CHANGED) { + TRACE(1, "::ACRCP notify rsp volume =%x", + btif_get_avrcp_adv_notify(parms)->p.volume); + a2dp_volume_set(device_id, btif_get_avrcp_adv_notify(parms)->p.volume); + } #ifdef AVRCP_TRACK_CHANGED - else if(btif_get_avrcp_adv_notify(parms)->event == BTIF_AVRCP_EID_TRACK_CHANGED){ - // TRACE(1,"::AVRCP_EID_TRACK_CHANGED transId:%d\n", Parms->p.cmdFrame->transId); - if (app_bt_device.avrcp_notify_rsp[device_id] == NULL) - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_notify_rsp[device_id]); + else if (btif_get_avrcp_adv_notify(parms)->event == + BTIF_AVRCP_EID_TRACK_CHANGED) { + // TRACE(1,"::AVRCP_EID_TRACK_CHANGED transId:%d\n", + // Parms->p.cmdFrame->transId); + if (app_bt_device.avrcp_notify_rsp[device_id] == NULL) + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_notify_rsp[device_id]); - btif_set_app_bt_device_avrcp_notify_rsp_ctype(app_bt_device.avrcp_notify_rsp[device_id], BTIF_AVCTP_RESPONSE_INTERIM); + btif_set_app_bt_device_avrcp_notify_rsp_ctype( + app_bt_device.avrcp_notify_rsp[device_id], + BTIF_AVCTP_RESPONSE_INTERIM); - app_bt_device.track_changed[device_id] = BTIF_AVCTP_RESPONSE_INTERIM; - btif_avrcp_ct_get_media_Info(channel,app_bt_device.avrcp_notify_rsp[device_id],0x7f) ; - } + app_bt_device.track_changed[device_id] = BTIF_AVCTP_RESPONSE_INTERIM; + btif_avrcp_ct_get_media_Info( + channel, app_bt_device.avrcp_notify_rsp[device_id], 0x7f); + } #endif - } - else if(btif_get_avrcp_cb_channel_advOp(parms) == BTIF_AVRCP_OP_GET_PLAY_STATUS && btif_get_avrcp_cb_channel_state(parms) == BT_STS_SUCCESS) - { - TRACE(1,"AVRCP get play status returns %d", btif_get_avrcp_adv_rsp_play_status(parms)->mediaStatus); - #if defined(__BT_ONE_BRING_TWO__) - if(btif_get_avrcp_adv_rsp_play_status(parms)->mediaStatus == 0x1){ - avrcp_playback_status[device_id] = 0x01; - }else if(btif_get_avrcp_adv_rsp_play_status(parms)->mediaStatus == 0x0||btif_get_avrcp_adv_rsp_play_status(parms)->mediaStatus == 0x2){ - avrcp_playback_status[device_id] = 0x00; - } - #endif - } -#ifdef AVRCP_TRACK_CHANGED - else if(btif_get_avrcp_cb_channel_advOp(parms) == BTIF_AVRCP_OP_GET_MEDIA_INFO && btif_get_avrcp_cb_channel_state(parms) == BT_STS_SUCCESS){ - TRACE(1,"AVRCP_TRACK_CHANGED numid=%d",btif_get_avrcp_adv_rsp(parms)->element.numIds); - for(uint8_t i=0;i<7;i++) - { - if(btif_get_avrcp_adv_rsp(parms)->element.txt[i].length>0) - { - TRACE(2,"Id=%d,%s\n",i,btif_get_avrcp_adv_rsp(parms)->element.txt[i].string); - } - } - - } + } else if (btif_get_avrcp_cb_channel_advOp(parms) == + BTIF_AVRCP_OP_GET_PLAY_STATUS && + btif_get_avrcp_cb_channel_state(parms) == BT_STS_SUCCESS) { + TRACE(1, "AVRCP get play status returns %d", + btif_get_avrcp_adv_rsp_play_status(parms)->mediaStatus); +#if defined(__BT_ONE_BRING_TWO__) + if (btif_get_avrcp_adv_rsp_play_status(parms)->mediaStatus == 0x1) { + avrcp_playback_status[device_id] = 0x01; + } else if (btif_get_avrcp_adv_rsp_play_status(parms)->mediaStatus == + 0x0 || + btif_get_avrcp_adv_rsp_play_status(parms)->mediaStatus == + 0x2) { + avrcp_playback_status[device_id] = 0x00; + } #endif - break; - case BTIF_AVRCP_EVENT_COMMAND: - TRACE(2,"::avrcp_callback_CT AVRCP_EVENT_COMMAND device_id=%d,role=%x\n",device_id,btif_get_avrcp_channel_role(channel)); - TRACE(2,"::avrcp_callback_CT AVRCP_EVENT_COMMAND ctype=%x,subunitype=%x\n", btif_get_avrcp_cmd_frame(parms)->ctype,btif_get_avrcp_cmd_frame(parms)->subunitType); - TRACE(2,"::avrcp_callback_CT AVRCP_EVENT_COMMAND subunitId=%x,opcode=%x\n", btif_get_avrcp_cmd_frame(parms)->subunitId,btif_get_avrcp_cmd_frame(parms)->opcode); - TRACE(2,"::avrcp_callback_CT AVRCP_EVENT_COMMAND operands=%p,operandLen=%x\n", btif_get_avrcp_cmd_frame(parms)->operands,btif_get_avrcp_cmd_frame(parms)->operandLen); - TRACE(1,"::avrcp_callback_CT AVRCP_EVENT_COMMAND more=%x\n", btif_get_avrcp_cmd_frame(parms)->more); - if( btif_get_avrcp_cmd_frame(parms)->ctype == BTIF_AVRCP_CTYPE_STATUS) - { - uint32_t company_id = *(btif_get_avrcp_cmd_frame(parms)->operands+2) + ((uint32_t)(*(btif_get_avrcp_cmd_frame(parms)->operands+1))<<8) + ((uint32_t)(*(btif_get_avrcp_cmd_frame(parms)->operands))<<16); - TRACE(1,"::avrcp_callback_CT AVRCP_EVENT_COMMAND company_id=%x\n", company_id); - if(company_id == 0x001958) //bt sig - { - avrcp_operation_t op = *(btif_get_avrcp_cmd_frame(parms)->operands+3); - uint8_t oplen = *(btif_get_avrcp_cmd_frame(parms)->operands+6)+ ((uint32_t)(*(btif_get_avrcp_cmd_frame(parms)->operands+5))<<8); - TRACE(2,"::avrcp_callback_CT AVRCP_EVENT_COMMAND op=%x,oplen=%x\n", op,oplen); - switch(op) - { - case BTIF_AVRCP_OP_GET_CAPABILITIES: - { - uint8_t event = *(btif_get_avrcp_cmd_frame(parms)->operands+7); - if(event==BTIF_AVRCP_CAPABILITY_COMPANY_ID) - { - TRACE(0,"::avrcp_callback_CT AVRCP_EVENT_COMMAND send support compay id"); - if (app_bt_device.avrcp_get_capabilities_rsp[device_id] == NULL) - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_get_capabilities_rsp[device_id]); - btif_avrcp_set_capabilities_rsp_cmd(app_bt_device.avrcp_get_capabilities_rsp[device_id], - btif_get_avrcp_cmd_frame(parms)->transId, BTIF_AVCTP_RESPONSE_IMPLEMENTED_STABLE); - btif_avrcp_ct_get_capabilities_company_id_rsp(channel, app_bt_device.avrcp_get_capabilities_rsp[device_id]); - } - else if(event == BTIF_AVRCP_CAPABILITY_EVENTS_SUPPORTED) - { - TRACE(1,"::avrcp_callback_CT AVRCP_EVENT_COMMAND send support event transId:%d", btif_get_avrcp_cmd_frame(parms)->transId); - if(app_bt_device.avrcpVolumeSync) - { - btif_set_avrcp_adv_rem_event_mask(channel, BTIF_AVRCP_ENABLE_VOLUME_CHANGED); - } - else - { - btif_set_avrcp_adv_rem_event_mask(channel, 0); - } - if (app_bt_device.avrcp_get_capabilities_rsp[device_id] == NULL) - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_get_capabilities_rsp[device_id]); - - uint8_t transid = btif_get_avrcp_cmd_frame(parms)->transId; - btif_avrcp_set_capabilities_rsp_cmd(app_bt_device.avrcp_get_capabilities_rsp[device_id], - transid, BTIF_AVCTP_RESPONSE_IMPLEMENTED_STABLE); - TRACE(1,"::avrcp_callback_CT AVRCP_EVENT_COMMAND send support event transId:%d", transid); - btif_avrcp_ct_get_capabilities_rsp(channel, app_bt_device.avrcp_get_capabilities_rsp[device_id], - BTIF_AVRCP_CAPABILITY_EVENTS_SUPPORTED, btif_get_avrcp_adv_rem_event_mask(channel)); - } - else - { - TRACE(0,"::avrcp_callback_CT AVRCP_EVENT_COMMAND send error event value"); - } - } - break; - } - - } - - }else if(btif_get_avrcp_cmd_frame(parms)->ctype == BTIF_AVCTP_CTYPE_CONTROL){ - TRACE(0,"::avrcp_callback_CT AVRCP_EVENT_COMMAND AVCTP_CTYPE_CONTROL\n"); - DUMP8("%02x ", btif_get_avrcp_cmd_frame(parms)->operands, btif_get_avrcp_cmd_frame(parms)->operandLen); - if (btif_get_avrcp_cmd_frame(parms)->operands[3] == BTIF_AVRCP_OP_SET_ABSOLUTE_VOLUME){ - TRACE(1,"::avrcp_callback_CT AVRCP_EID_VOLUME_CHANGED transId:%d\n", btif_get_avrcp_cmd_frame(parms)->transId); - if((btif_get_avrcp_cmd_frame(parms)->operands[7]<127)&&(btif_get_avrcp_cmd_frame(parms)->operands[7]>1)){ - a2dp_volume_set(device_id,btif_get_avrcp_cmd_frame(parms)->operands[7] + 1); - }else{ - a2dp_volume_set(device_id,btif_get_avrcp_cmd_frame(parms)->operands[7]); - } - //a2dp_volume_set(device_id, btif_get_avrcp_cmd_frame(parms)->operands[7]); - if (app_bt_device.avrcp_control_rsp[device_id] == NULL) - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_control_rsp[device_id]); -//#if defined(__BQB_PROFILE_TEST__) - if((btif_get_avrcp_cmd_frame(parms)->operandLen != 8))//it works for BQB - { - btif_avrcp_set_control_rsp_cmd_witherror(app_bt_device.avrcp_control_rsp[device_id],btif_get_avrcp_cmd_frame(parms)->transId, BTIF_AVCTP_RESPONSE_REJECTED, BTIF_AVRCP_ERR_INVALID_PARM); - TRACE(0,"reject invalid volume"); - } - else -//#endif - btif_avrcp_set_control_rsp_cmd(app_bt_device.avrcp_control_rsp[device_id],btif_get_avrcp_cmd_frame(parms)->transId, BTIF_AVCTP_RESPONSE_ACCEPTED); - - DUMP8("%02x ", btif_get_avrcp_cmd_frame(parms)->operands, btif_get_avrcp_cmd_frame(parms)->operandLen); - btif_avrcp_ct_accept_absolute_volume_rsp(channel, app_bt_device.avrcp_control_rsp[device_id], btif_get_avrcp_cmd_frame(parms)->operands[7]); - } else if (BTIF_AVRCP_OP_CUSTOM_CMD == btif_get_avrcp_cmd_frame(parms)->operands[3]) { - app_AVRCP_CustomCmd_Received(&btif_get_avrcp_cmd_frame(parms)->operands[7], btif_get_avrcp_cmd_frame(parms)->operandLen - 7); - app_AVRCP_sendCustomCmdRsp(device_id, channel, true,btif_get_avrcp_cmd_frame(parms)->transId); - } - }else if (btif_get_avrcp_cmd_frame(parms)->ctype == BTIF_AVCTP_CTYPE_NOTIFY){ - bt_status_t status; - TRACE(0,"::avrcp_callback_CT AVRCP_EVENT_COMMAND AVCTP_CTYPE_NOTIFY\n"); - DUMP8("%02x ", btif_get_avrcp_cmd_frame(parms)->operands, btif_get_avrcp_cmd_frame(parms)->operandLen); - if (btif_get_avrcp_cmd_frame(parms)->operands[7] == BTIF_AVRCP_EID_VOLUME_CHANGED){ - TRACE(1,"::avrcp_callback_CT AVRCP_EID_VOLUME_CHANGED transId:%d\n", btif_get_avrcp_cmd_frame(parms)->transId); - if (app_bt_device.avrcp_notify_rsp[device_id] == NULL){ - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_notify_rsp[device_id]); - } - btif_avrcp_set_notify_rsp_cmd(app_bt_device.avrcp_notify_rsp[device_id],btif_get_avrcp_cmd_frame(parms)->transId, BTIF_AVCTP_RESPONSE_INTERIM) ; - app_bt_device.volume_report[device_id] = BTIF_AVCTP_RESPONSE_INTERIM; - status = btif_avrcp_ct_get_absolute_volume_rsp(channel, - app_bt_device.avrcp_notify_rsp[device_id],a2dp_volume_get(device_id)); - TRACE(1,"::avrcp_callback_CT AVRCP_EVENT_COMMAND AVRCP_EID_VOLUME_CHANGED nRet:%x\n",status); - - } -//#if defined(__BQB_PROFILE_TEST__) - else if(btif_get_avrcp_cmd_frame(parms)->operands[7] == 0xff)//it works for BQB - { - TRACE(1,"trances id:%d",btif_get_avrcp_cmd_frame(parms)->transId); - if (app_bt_device.avrcp_notify_rsp[device_id] == NULL){ - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_notify_rsp[device_id]); - } - btif_avrcp_set_notify_rsp_cmd_witherror(app_bt_device.avrcp_notify_rsp[device_id],btif_get_avrcp_cmd_frame(parms)->transId, BTIF_AVCTP_RESPONSE_REJECTED, BTIF_AVRCP_ERR_INVALID_PARM); - - status = btif_avrcp_ct_invalid_volume_rsp(channel, app_bt_device.avrcp_notify_rsp[device_id]); - TRACE(1,"AVRCP_CtInvalidVolume_Rsp,status%d",status); - } -//#endif - } -//#endif - break; - case BTIF_AVRCP_EVENT_ADV_NOTIFY://17 - TRACE(3,"::avrcp_callback_CT AVRCP_EVENT_ADV_NOTIFY adv.notify.event=%x,device_id=%d,chnl->role=%x\n",btif_get_avrcp_adv_notify(parms)->event,device_id, btif_get_avrcp_cb_channel_role( channel)); - if(btif_get_avrcp_adv_notify(parms)->event == BTIF_AVRCP_EID_VOLUME_CHANGED) - { - TRACE(1,"::avrcp_callback_CT ACRCP notify vol =%x",btif_get_avrcp_adv_notify(parms)->p.volume); - // AVRCP_CtRegisterNotification(chnl,app_bt_device.avrcp_notify_rsp[device_id],BTIF_AVRCP_EID_VOLUME_CHANGED,0); - btif_avrcp_ct_register_notification(channel,app_bt_device.avrcp_notify_rsp[device_id],BTIF_AVRCP_EID_VOLUME_CHANGED,0); - } - else if(btif_get_avrcp_adv_notify(parms)->event == BTIF_AVRCP_EID_MEDIA_STATUS_CHANGED) - { - TRACE(1,"::avrcp_callback_CT ACRCP notify playback states=%x",btif_get_avrcp_adv_notify(parms)->p.mediaStatus); - avrcp_set_media_status(btif_get_avrcp_adv_notify(parms)->p.mediaStatus); - if (app_bt_device.avrcp_cmd1[device_id] == NULL){ - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_cmd1[device_id]); - } - btif_avrcp_ct_register_notification(channel,app_bt_device.avrcp_cmd1[device_id],BTIF_AVRCP_EID_MEDIA_STATUS_CHANGED,0); - } - else if(btif_get_avrcp_adv_notify(parms)->event == BTIF_AVRCP_EID_PLAY_POS_CHANGED) - { - TRACE(1,"::avrcp_callback_CT ACRCP notify play pos =%x",btif_get_avrcp_adv_notify(parms)->p.position); - if (app_bt_device.avrcp_cmd2[device_id] == NULL){ - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_cmd2[device_id]); - } - btif_avrcp_ct_register_notification(channel,app_bt_device.avrcp_cmd2[device_id],BTIF_AVRCP_EID_PLAY_POS_CHANGED,1); - } -#ifdef AVRCP_TRACK_CHANGED - else if(btif_get_avrcp_adv_notify(parms)->event == BTIF_AVRCP_EID_TRACK_CHANGED){ - TRACE(2,"::AVRCP notify track msU32=%x, lsU32=%x",btif_get_avrcp_adv_notify(parms)->p.track.msU32,btif_get_avrcp_adv_notify(parms)->p.track.lsU32); - if (app_bt_device.avrcp_cmd2[device_id] == NULL){ - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_cmd2[device_id]); - } - btif_avrcp_ct_register_notification(channel,app_bt_device.avrcp_cmd2[device_id],BTIF_AVRCP_EID_TRACK_CHANGED,0); - } -#endif - break; - case BTIF_AVRCP_EVENT_ADV_CMD_TIMEOUT: - TRACE(2,"::avrcp_callback_CT AVRCP_EVENT_ADV_CMD_TIMEOUT device_id=%d,role=%x\n",device_id,btif_get_avrcp_cb_channel_role(channel)); - break; } +#ifdef AVRCP_TRACK_CHANGED + else if (btif_get_avrcp_cb_channel_advOp(parms) == + BTIF_AVRCP_OP_GET_MEDIA_INFO && + btif_get_avrcp_cb_channel_state(parms) == BT_STS_SUCCESS) { + TRACE(1, "AVRCP_TRACK_CHANGED numid=%d", + btif_get_avrcp_adv_rsp(parms)->element.numIds); + for (uint8_t i = 0; i < 7; i++) { + if (btif_get_avrcp_adv_rsp(parms)->element.txt[i].length > 0) { + TRACE(2, "Id=%d,%s\n", i, + btif_get_avrcp_adv_rsp(parms)->element.txt[i].string); + } + } + } +#endif + break; + case BTIF_AVRCP_EVENT_COMMAND: + TRACE(2, "::avrcp_callback_CT AVRCP_EVENT_COMMAND device_id=%d,role=%x\n", + device_id, btif_get_avrcp_channel_role(channel)); + TRACE(2, "::avrcp_callback_CT AVRCP_EVENT_COMMAND ctype=%x,subunitype=%x\n", + btif_get_avrcp_cmd_frame(parms)->ctype, + btif_get_avrcp_cmd_frame(parms)->subunitType); + TRACE(2, "::avrcp_callback_CT AVRCP_EVENT_COMMAND subunitId=%x,opcode=%x\n", + btif_get_avrcp_cmd_frame(parms)->subunitId, + btif_get_avrcp_cmd_frame(parms)->opcode); + TRACE(2, + "::avrcp_callback_CT AVRCP_EVENT_COMMAND operands=%p,operandLen=%x\n", + btif_get_avrcp_cmd_frame(parms)->operands, + btif_get_avrcp_cmd_frame(parms)->operandLen); + TRACE(1, "::avrcp_callback_CT AVRCP_EVENT_COMMAND more=%x\n", + btif_get_avrcp_cmd_frame(parms)->more); + if (btif_get_avrcp_cmd_frame(parms)->ctype == BTIF_AVRCP_CTYPE_STATUS) { + uint32_t company_id = + *(btif_get_avrcp_cmd_frame(parms)->operands + 2) + + ((uint32_t)(*(btif_get_avrcp_cmd_frame(parms)->operands + 1)) << 8) + + ((uint32_t)(*(btif_get_avrcp_cmd_frame(parms)->operands)) << 16); + TRACE(1, "::avrcp_callback_CT AVRCP_EVENT_COMMAND company_id=%x\n", + company_id); + if (company_id == 0x001958) // bt sig + { + avrcp_operation_t op = *(btif_get_avrcp_cmd_frame(parms)->operands + 3); + uint8_t oplen = + *(btif_get_avrcp_cmd_frame(parms)->operands + 6) + + ((uint32_t)(*(btif_get_avrcp_cmd_frame(parms)->operands + 5)) << 8); + TRACE(2, "::avrcp_callback_CT AVRCP_EVENT_COMMAND op=%x,oplen=%x\n", op, + oplen); + switch (op) { + case BTIF_AVRCP_OP_GET_CAPABILITIES: { + uint8_t event = *(btif_get_avrcp_cmd_frame(parms)->operands + 7); + if (event == BTIF_AVRCP_CAPABILITY_COMPANY_ID) { + TRACE(0, "::avrcp_callback_CT AVRCP_EVENT_COMMAND send support " + "compay id"); + if (app_bt_device.avrcp_get_capabilities_rsp[device_id] == NULL) + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_get_capabilities_rsp[device_id]); + btif_avrcp_set_capabilities_rsp_cmd( + app_bt_device.avrcp_get_capabilities_rsp[device_id], + btif_get_avrcp_cmd_frame(parms)->transId, + BTIF_AVCTP_RESPONSE_IMPLEMENTED_STABLE); + btif_avrcp_ct_get_capabilities_company_id_rsp( + channel, app_bt_device.avrcp_get_capabilities_rsp[device_id]); + } else if (event == BTIF_AVRCP_CAPABILITY_EVENTS_SUPPORTED) { + TRACE(1, + "::avrcp_callback_CT AVRCP_EVENT_COMMAND send support event " + "transId:%d", + btif_get_avrcp_cmd_frame(parms)->transId); + if (app_bt_device.avrcpVolumeSync) { + btif_set_avrcp_adv_rem_event_mask( + channel, BTIF_AVRCP_ENABLE_VOLUME_CHANGED); + } else { + btif_set_avrcp_adv_rem_event_mask(channel, 0); + } + if (app_bt_device.avrcp_get_capabilities_rsp[device_id] == NULL) + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_get_capabilities_rsp[device_id]); + + uint8_t transid = btif_get_avrcp_cmd_frame(parms)->transId; + btif_avrcp_set_capabilities_rsp_cmd( + app_bt_device.avrcp_get_capabilities_rsp[device_id], transid, + BTIF_AVCTP_RESPONSE_IMPLEMENTED_STABLE); + TRACE(1, + "::avrcp_callback_CT AVRCP_EVENT_COMMAND send support event " + "transId:%d", + transid); + btif_avrcp_ct_get_capabilities_rsp( + channel, app_bt_device.avrcp_get_capabilities_rsp[device_id], + BTIF_AVRCP_CAPABILITY_EVENTS_SUPPORTED, + btif_get_avrcp_adv_rem_event_mask(channel)); + } else { + TRACE(0, "::avrcp_callback_CT AVRCP_EVENT_COMMAND send error event " + "value"); + } + } break; + } + } + + } else if (btif_get_avrcp_cmd_frame(parms)->ctype == + BTIF_AVCTP_CTYPE_CONTROL) { + TRACE(0, "::avrcp_callback_CT AVRCP_EVENT_COMMAND AVCTP_CTYPE_CONTROL\n"); + DUMP8("%02x ", btif_get_avrcp_cmd_frame(parms)->operands, + btif_get_avrcp_cmd_frame(parms)->operandLen); + if (btif_get_avrcp_cmd_frame(parms)->operands[3] == + BTIF_AVRCP_OP_SET_ABSOLUTE_VOLUME) { + TRACE(1, "::avrcp_callback_CT AVRCP_EID_VOLUME_CHANGED transId:%d\n", + btif_get_avrcp_cmd_frame(parms)->transId); + if ((btif_get_avrcp_cmd_frame(parms)->operands[7] < 127) && + (btif_get_avrcp_cmd_frame(parms)->operands[7] > 1)) { + a2dp_volume_set(device_id, + btif_get_avrcp_cmd_frame(parms)->operands[7] + 1); + } else { + a2dp_volume_set(device_id, + btif_get_avrcp_cmd_frame(parms)->operands[7]); + } + // a2dp_volume_set(device_id, + // btif_get_avrcp_cmd_frame(parms)->operands[7]); + if (app_bt_device.avrcp_control_rsp[device_id] == NULL) + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_control_rsp[device_id]); + //#if defined(__BQB_PROFILE_TEST__) + if ((btif_get_avrcp_cmd_frame(parms)->operandLen != + 8)) // it works for BQB + { + btif_avrcp_set_control_rsp_cmd_witherror( + app_bt_device.avrcp_control_rsp[device_id], + btif_get_avrcp_cmd_frame(parms)->transId, + BTIF_AVCTP_RESPONSE_REJECTED, BTIF_AVRCP_ERR_INVALID_PARM); + TRACE(0, "reject invalid volume"); + } else + //#endif + btif_avrcp_set_control_rsp_cmd( + app_bt_device.avrcp_control_rsp[device_id], + btif_get_avrcp_cmd_frame(parms)->transId, + BTIF_AVCTP_RESPONSE_ACCEPTED); + + DUMP8("%02x ", btif_get_avrcp_cmd_frame(parms)->operands, + btif_get_avrcp_cmd_frame(parms)->operandLen); + btif_avrcp_ct_accept_absolute_volume_rsp( + channel, app_bt_device.avrcp_control_rsp[device_id], + btif_get_avrcp_cmd_frame(parms)->operands[7]); + } else if (BTIF_AVRCP_OP_CUSTOM_CMD == + btif_get_avrcp_cmd_frame(parms)->operands[3]) { + app_AVRCP_CustomCmd_Received( + &btif_get_avrcp_cmd_frame(parms)->operands[7], + btif_get_avrcp_cmd_frame(parms)->operandLen - 7); + app_AVRCP_sendCustomCmdRsp(device_id, channel, true, + btif_get_avrcp_cmd_frame(parms)->transId); + } + } else if (btif_get_avrcp_cmd_frame(parms)->ctype == + BTIF_AVCTP_CTYPE_NOTIFY) { + bt_status_t status; + TRACE(0, "::avrcp_callback_CT AVRCP_EVENT_COMMAND AVCTP_CTYPE_NOTIFY\n"); + DUMP8("%02x ", btif_get_avrcp_cmd_frame(parms)->operands, + btif_get_avrcp_cmd_frame(parms)->operandLen); + if (btif_get_avrcp_cmd_frame(parms)->operands[7] == + BTIF_AVRCP_EID_VOLUME_CHANGED) { + TRACE(1, "::avrcp_callback_CT AVRCP_EID_VOLUME_CHANGED transId:%d\n", + btif_get_avrcp_cmd_frame(parms)->transId); + if (app_bt_device.avrcp_notify_rsp[device_id] == NULL) { + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_notify_rsp[device_id]); + } + btif_avrcp_set_notify_rsp_cmd(app_bt_device.avrcp_notify_rsp[device_id], + btif_get_avrcp_cmd_frame(parms)->transId, + BTIF_AVCTP_RESPONSE_INTERIM); + app_bt_device.volume_report[device_id] = BTIF_AVCTP_RESPONSE_INTERIM; + status = btif_avrcp_ct_get_absolute_volume_rsp( + channel, app_bt_device.avrcp_notify_rsp[device_id], + a2dp_volume_get(device_id)); + TRACE(1, + "::avrcp_callback_CT AVRCP_EVENT_COMMAND " + "AVRCP_EID_VOLUME_CHANGED nRet:%x\n", + status); + + } + //#if defined(__BQB_PROFILE_TEST__) + else if (btif_get_avrcp_cmd_frame(parms)->operands[7] == + 0xff) // it works for BQB + { + TRACE(1, "trances id:%d", btif_get_avrcp_cmd_frame(parms)->transId); + if (app_bt_device.avrcp_notify_rsp[device_id] == NULL) { + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_notify_rsp[device_id]); + } + btif_avrcp_set_notify_rsp_cmd_witherror( + app_bt_device.avrcp_notify_rsp[device_id], + btif_get_avrcp_cmd_frame(parms)->transId, + BTIF_AVCTP_RESPONSE_REJECTED, BTIF_AVRCP_ERR_INVALID_PARM); + + status = btif_avrcp_ct_invalid_volume_rsp( + channel, app_bt_device.avrcp_notify_rsp[device_id]); + TRACE(1, "AVRCP_CtInvalidVolume_Rsp,status%d", status); + } + //#endif + } + //#endif + break; + case BTIF_AVRCP_EVENT_ADV_NOTIFY: // 17 + TRACE(3, + "::avrcp_callback_CT AVRCP_EVENT_ADV_NOTIFY " + "adv.notify.event=%x,device_id=%d,chnl->role=%x\n", + btif_get_avrcp_adv_notify(parms)->event, device_id, + btif_get_avrcp_cb_channel_role(channel)); + if (btif_get_avrcp_adv_notify(parms)->event == + BTIF_AVRCP_EID_VOLUME_CHANGED) { + TRACE(1, "::avrcp_callback_CT ACRCP notify vol =%x", + btif_get_avrcp_adv_notify(parms)->p.volume); + // AVRCP_CtRegisterNotification(chnl,app_bt_device.avrcp_notify_rsp[device_id],BTIF_AVRCP_EID_VOLUME_CHANGED,0); + btif_avrcp_ct_register_notification( + channel, app_bt_device.avrcp_notify_rsp[device_id], + BTIF_AVRCP_EID_VOLUME_CHANGED, 0); + } else if (btif_get_avrcp_adv_notify(parms)->event == + BTIF_AVRCP_EID_MEDIA_STATUS_CHANGED) { + TRACE(1, "::avrcp_callback_CT ACRCP notify playback states=%x", + btif_get_avrcp_adv_notify(parms)->p.mediaStatus); + avrcp_set_media_status(btif_get_avrcp_adv_notify(parms)->p.mediaStatus); + if (app_bt_device.avrcp_cmd1[device_id] == NULL) { + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_cmd1[device_id]); + } + btif_avrcp_ct_register_notification( + channel, app_bt_device.avrcp_cmd1[device_id], + BTIF_AVRCP_EID_MEDIA_STATUS_CHANGED, 0); + } else if (btif_get_avrcp_adv_notify(parms)->event == + BTIF_AVRCP_EID_PLAY_POS_CHANGED) { + TRACE(1, "::avrcp_callback_CT ACRCP notify play pos =%x", + btif_get_avrcp_adv_notify(parms)->p.position); + if (app_bt_device.avrcp_cmd2[device_id] == NULL) { + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_cmd2[device_id]); + } + btif_avrcp_ct_register_notification(channel, + app_bt_device.avrcp_cmd2[device_id], + BTIF_AVRCP_EID_PLAY_POS_CHANGED, 1); + } +#ifdef AVRCP_TRACK_CHANGED + else if (btif_get_avrcp_adv_notify(parms)->event == + BTIF_AVRCP_EID_TRACK_CHANGED) { + TRACE(2, "::AVRCP notify track msU32=%x, lsU32=%x", + btif_get_avrcp_adv_notify(parms)->p.track.msU32, + btif_get_avrcp_adv_notify(parms)->p.track.lsU32); + if (app_bt_device.avrcp_cmd2[device_id] == NULL) { + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_cmd2[device_id]); + } + btif_avrcp_ct_register_notification(channel, + app_bt_device.avrcp_cmd2[device_id], + BTIF_AVRCP_EID_TRACK_CHANGED, 0); + } +#endif + break; + case BTIF_AVRCP_EVENT_ADV_CMD_TIMEOUT: + TRACE(2, + "::avrcp_callback_CT AVRCP_EVENT_ADV_CMD_TIMEOUT " + "device_id=%d,role=%x\n", + device_id, btif_get_avrcp_cb_channel_role(channel)); + break; + } #if defined(IBRT) - app_tws_ibrt_profile_callback(BTIF_APP_AVRCP_PROFILE_ID,(void *)chnl, (void *)parms); + app_tws_ibrt_profile_callback(BTIF_APP_AVRCP_PROFILE_ID, (void *)chnl, + (void *)parms); #endif - } -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) -extern "C" void avrcp_callback_TG(btif_avrcp_chnl_handle_t chnl, const avrcp_callback_parms_t *parms) -{ - //do nothing +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) +extern "C" void avrcp_callback_TG(btif_avrcp_chnl_handle_t chnl, + const avrcp_callback_parms_t *parms) { + // do nothing } #endif #ifdef __TWS__ typedef uint8_t tx_done_flag; -#define TX_DONE_FLAG_INIT 0 -#define TX_DONE_FLAG_SUCCESS 1 -#define TX_DONE_FLAG_FAIL 2 -#define TX_DONE_FLAG_TXING 3 +#define TX_DONE_FLAG_INIT 0 +#define TX_DONE_FLAG_SUCCESS 1 +#define TX_DONE_FLAG_FAIL 2 +#define TX_DONE_FLAG_TXING 3 tx_done_flag TG_tx_done_flag = TX_DONE_FLAG_INIT; - -void avrcp_callback_TG(btif_avrcp_chnl_handle_t chnl, const avrcp_callback_parms_t *parms) -{ - APP_A2DP_TRACE(2,"avrcp_callback_TG : chnl %p, Parms %p\n", chnl, parms); - APP_A2DP_TRACE(1,"::avrcp_callback_TG Parms->event %d\n", btif_get_avrcp_cb_channel_state(parms)); - btif_avrcp_channel_t* channel = btif_get_avrcp_channel(chnl); - +void avrcp_callback_TG(btif_avrcp_chnl_handle_t chnl, + const avrcp_callback_parms_t *parms) { + APP_A2DP_TRACE(2, "avrcp_callback_TG : chnl %p, Parms %p\n", chnl, parms); + APP_A2DP_TRACE(1, "::avrcp_callback_TG Parms->event %d\n", + btif_get_avrcp_cb_channel_state(parms)); + btif_avrcp_channel_t *channel = btif_get_avrcp_channel(chnl); #ifdef __BT_ONE_BRING_TWO__ - enum BT_DEVICE_ID_T device_id = (chnl == app_bt_device.avrcp_channel[0]->avrcp_channel_handle)?BT_DEVICE_ID_1:BT_DEVICE_ID_2; + enum BT_DEVICE_ID_T device_id = + (chnl == app_bt_device.avrcp_channel[0]->avrcp_channel_handle) + ? BT_DEVICE_ID_1 + : BT_DEVICE_ID_2; #else - enum BT_DEVICE_ID_T device_id = BT_DEVICE_ID_1; + enum BT_DEVICE_ID_T device_id = BT_DEVICE_ID_1; #endif - switch(btif_avrcp_get_callback_event((avrcp_callback_parms_t *)parms)) - { - case BTIF_AVRCP_EVENT_CONNECT: - btif_set_avrcp_state(channel,BTIF_AVRCP_STATE_CONNECTED); - if (app_bt_device.avrcp_custom_cmd[device_id] == NULL) - { - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_custom_cmd[device_id]); - } - APP_A2DP_TRACE(2,"::avrcp_callback_TG AVRCP_EVENT_CONNECT %x,device_id=%d\n", btif_get_avrcp_version( channel),device_id); + switch (btif_avrcp_get_callback_event((avrcp_callback_parms_t *)parms)) { + case BTIF_AVRCP_EVENT_CONNECT: + btif_set_avrcp_state(channel, BTIF_AVRCP_STATE_CONNECTED); + if (app_bt_device.avrcp_custom_cmd[device_id] == NULL) { + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_custom_cmd[device_id]); + } + APP_A2DP_TRACE(2, + "::avrcp_callback_TG AVRCP_EVENT_CONNECT %x,device_id=%d\n", + btif_get_avrcp_version(channel), device_id); - break; - case BTIF_AVRCP_EVENT_DISCONNECT: - APP_A2DP_TRACE(0,"::avrcp_callback_TG AVRCP_EVENT_DISCONNECT"); + break; + case BTIF_AVRCP_EVENT_DISCONNECT: + APP_A2DP_TRACE(0, "::avrcp_callback_TG AVRCP_EVENT_DISCONNECT"); + btif_set_avrcp_state(channel, BTIF_AVRCP_STATE_DISCONNECTED); + if (app_bt_device.avrcp_get_capabilities_rsp[device_id]) { + btif_app_a2dp_avrcpadvancedpdu_mempool_free( + app_bt_device.avrcp_get_capabilities_rsp[device_id]); + app_bt_device.avrcp_get_capabilities_rsp[device_id] = NULL; + } + if (app_bt_device.avrcp_control_rsp[device_id]) { + btif_app_a2dp_avrcpadvancedpdu_mempool_free( + app_bt_device.avrcp_control_rsp[device_id]); + app_bt_device.avrcp_control_rsp[device_id] = NULL; + } + if (app_bt_device.avrcp_notify_rsp[device_id]) { + btif_app_a2dp_avrcpadvancedpdu_mempool_free( + app_bt_device.avrcp_notify_rsp[device_id]); + app_bt_device.avrcp_notify_rsp[device_id] = NULL; + } - btif_set_avrcp_state(channel,BTIF_AVRCP_STATE_DISCONNECTED) ; - if (app_bt_device.avrcp_get_capabilities_rsp[device_id]){ - btif_app_a2dp_avrcpadvancedpdu_mempool_free(app_bt_device.avrcp_get_capabilities_rsp[device_id]); - app_bt_device.avrcp_get_capabilities_rsp[device_id] = NULL; - } - if (app_bt_device.avrcp_control_rsp[device_id]){ - btif_app_a2dp_avrcpadvancedpdu_mempool_free(app_bt_device.avrcp_control_rsp[device_id]); - app_bt_device.avrcp_control_rsp[device_id] = NULL; - } - if (app_bt_device.avrcp_notify_rsp[device_id]){ - btif_app_a2dp_avrcpadvancedpdu_mempool_free(app_bt_device.avrcp_notify_rsp[device_id]); - app_bt_device.avrcp_notify_rsp[device_id] = NULL; - } + if (app_bt_device.avrcp_cmd1[device_id]) { + btif_app_a2dp_avrcpadvancedpdu_mempool_free( + app_bt_device.avrcp_cmd1[device_id]); + app_bt_device.avrcp_cmd1[device_id] = NULL; + } + if (app_bt_device.avrcp_cmd2[device_id]) { + btif_app_a2dp_avrcpadvancedpdu_mempool_free( + app_bt_device.avrcp_cmd2[device_id]); + app_bt_device.avrcp_cmd2[device_id] = NULL; + } - if (app_bt_device.avrcp_cmd1[device_id]){ - btif_app_a2dp_avrcpadvancedpdu_mempool_free(app_bt_device.avrcp_cmd1[device_id]); - app_bt_device.avrcp_cmd1[device_id] = NULL; - } - if (app_bt_device.avrcp_cmd2[device_id]){ - btif_app_a2dp_avrcpadvancedpdu_mempool_free(app_bt_device.avrcp_cmd2[device_id]); - app_bt_device.avrcp_cmd2[device_id] = NULL; - } + if (app_bt_device.avrcp_custom_cmd[device_id]) { + btif_app_a2dp_avrcpadvancedpdu_mempool_free( + app_bt_device.avrcp_custom_cmd[device_id]); + app_bt_device.avrcp_custom_cmd[device_id] = NULL; + } - if (app_bt_device.avrcp_custom_cmd[device_id]){ - btif_app_a2dp_avrcpadvancedpdu_mempool_free(app_bt_device.avrcp_custom_cmd[device_id]); - app_bt_device.avrcp_custom_cmd[device_id] = NULL; - } + app_bt_device.volume_report[device_id] = 0; - app_bt_device.volume_report[device_id] = 0; + break; + case BTIF_AVRCP_EVENT_RESPONSE: + APP_A2DP_TRACE(2, + "::avrcp_callback_TG AVRCP_EVENT_RESPONSE op=%x,status=%x\n", + btif_get_avrcp_cb_channel_advOp(parms), + btif_get_avrcp_cb_channel_state(parms)); - - break; - case BTIF_AVRCP_EVENT_RESPONSE: - APP_A2DP_TRACE(2,"::avrcp_callback_TG AVRCP_EVENT_RESPONSE op=%x,status=%x\n", btif_get_avrcp_cb_channel_advOp(parms), - btif_get_avrcp_cb_channel_state(parms)); - - break; - case BTIF_AVRCP_EVENT_PANEL_CNF: - APP_A2DP_TRACE(3,"::avrcp_callback_TG AVRCP_EVENT_PANEL_CNF %x,%x,%x", - btif_get_avrcp_panel_cnf(parms)->response, btif_get_avrcp_panel_cnf(parms)->operation, - btif_get_avrcp_panel_cnf(parms)->press); - break; - case BTIF_AVRCP_EVENT_ADV_TX_DONE: - APP_A2DP_TRACE(3,"::avrcp_callback_TG AVRCP_EVENT_ADV_TX_DONE device_id=%d,status=%x,errorcode=%x\n",device_id, - btif_get_avrcp_cb_channel_state(parms),btif_get_avrcp_cb_channel_error_code(parms)); - APP_A2DP_TRACE(2,"::avrcp_callback_TG AVRCP_EVENT_ADV_TX_DONE op:%d, transid:%x\n", btif_get_avrcp_cb_txPdu_Op(parms), - btif_get_avrcp_cb_txPdu_transId(parms)); - if (btif_get_avrcp_cb_txPdu_Op(parms) == BTIF_AVRCP_OP_GET_CAPABILITIES){ - if (app_bt_device.avrcp_get_capabilities_rsp[device_id] == btif_get_avrcp_cb_txPdu(parms)){ - app_bt_device.avrcp_get_capabilities_rsp[device_id] = NULL; - btif_app_a2dp_avrcpadvancedpdu_mempool_free(btif_get_avrcp_cb_txPdu(parms)); - } - } - TG_tx_done_flag = TX_DONE_FLAG_SUCCESS; + break; + case BTIF_AVRCP_EVENT_PANEL_CNF: + APP_A2DP_TRACE(3, "::avrcp_callback_TG AVRCP_EVENT_PANEL_CNF %x,%x,%x", + btif_get_avrcp_panel_cnf(parms)->response, + btif_get_avrcp_panel_cnf(parms)->operation, + btif_get_avrcp_panel_cnf(parms)->press); + break; + case BTIF_AVRCP_EVENT_ADV_TX_DONE: + APP_A2DP_TRACE(3, + "::avrcp_callback_TG AVRCP_EVENT_ADV_TX_DONE " + "device_id=%d,status=%x,errorcode=%x\n", + device_id, btif_get_avrcp_cb_channel_state(parms), + btif_get_avrcp_cb_channel_error_code(parms)); + APP_A2DP_TRACE( + 2, "::avrcp_callback_TG AVRCP_EVENT_ADV_TX_DONE op:%d, transid:%x\n", + btif_get_avrcp_cb_txPdu_Op(parms), + btif_get_avrcp_cb_txPdu_transId(parms)); + if (btif_get_avrcp_cb_txPdu_Op(parms) == BTIF_AVRCP_OP_GET_CAPABILITIES) { + if (app_bt_device.avrcp_get_capabilities_rsp[device_id] == + btif_get_avrcp_cb_txPdu(parms)) { + app_bt_device.avrcp_get_capabilities_rsp[device_id] = NULL; + btif_app_a2dp_avrcpadvancedpdu_mempool_free( + btif_get_avrcp_cb_txPdu(parms)); + } + } + TG_tx_done_flag = TX_DONE_FLAG_SUCCESS; #if 0 if (Parms->p.adv.txPdu->op == AVRCP_OP_SET_ABSOLUTE_VOLUME){ if (Parms->p.adv.txPdu->ctype != AVCTP_RESPONSE_INTERIM){ @@ -1471,518 +1610,577 @@ void avrcp_callback_TG(btif_avrcp_chnl_handle_t chnl, const avrcp_callback_parms } #endif - break; - case BTIF_AVRCP_EVENT_COMMAND: - APP_A2DP_TRACE(2,"::avrcp_callback_TG AVRCP_EVENT_COMMAND device_id=%d,role=%x\n",device_id, btif_get_avrcp_channel_role(channel)); - APP_A2DP_TRACE(2,"::avrcp_callback_TG AVRCP_EVENT_COMMAND ctype=%x,subunitype=%x\n", btif_get_avrcp_cmd_frame(parms)->ctype, - btif_get_avrcp_cmd_frame(parms)->subunitType); - APP_A2DP_TRACE(2,"::avrcp_callback_TG AVRCP_EVENT_COMMAND subunitId=%x,opcode=%x\n", btif_get_avrcp_cmd_frame(parms)->subunitId, - btif_get_avrcp_cmd_frame(parms)->opcode); - APP_A2DP_TRACE(2,"::avrcp_callback_TG AVRCP_EVENT_COMMAND operands=%x,operandLen=%x\n", - btif_get_avrcp_cmd_frame(parms)->operands,btif_get_avrcp_cmd_frame(parms)->operandLen); - APP_A2DP_TRACE(1,"::avrcp_callback_TG AVRCP_EVENT_COMMAND more=%x\n", btif_get_avrcp_cmd_frame(parms)->more); - if(btif_get_avrcp_cmd_frame(parms)->ctype == BTIF_AVRCP_CTYPE_STATUS) - { - uint32_t company_id = *(btif_get_avrcp_cmd_frame(parms)->operands+2) + ((uint32_t)(*(btif_get_avrcp_cmd_frame(parms)->operands+1))<<8) + - ((uint32_t)(*(btif_get_avrcp_cmd_frame(parms)->operands))<<16); - TRACE(1,"::avrcp_callback_TG AVRCP_EVENT_COMMAND company_id=%x\n", company_id); - if(company_id == 0x001958) //bt sig - { - avrcp_operation_t op = *(btif_get_avrcp_cmd_frame(parms)->operands+3); - uint8_t oplen = *(btif_get_avrcp_cmd_frame(parms)->operands+6)+ ((uint32_t)(*(btif_get_avrcp_cmd_frame(parms)->operands+5))<<8); - APP_A2DP_TRACE(2,"::avrcp_callback_TG AVRCP_EVENT_COMMAND op=%x,oplen=%x\n", op,oplen); - switch(op) - { - case BTIF_AVRCP_OP_GET_CAPABILITIES: - { - uint8_t event = *(btif_get_avrcp_cmd_frame(parms)->operands+7); - if(event==BTIF_AVRCP_CAPABILITY_COMPANY_ID) - { - APP_A2DP_TRACE(0,"::avrcp_callback_TG AVRCP_EVENT_COMMAND send support compay id"); - } - else if(event == BTIF_AVRCP_CAPABILITY_EVENTS_SUPPORTED) - { - APP_A2DP_TRACE(1,"::avrcp_callback_TG AVRCP_EVENT_COMMAND send support event transId:%d",btif_get_avrcp_cmd_frame(parms)->transId); - if(app_bt_device.avrcpVolumeSync) - { - btif_set_avrcp_adv_rem_event_mask(channel, BTIF_AVRCP_ENABLE_VOLUME_CHANGED); - } - else - { - btif_set_avrcp_adv_rem_event_mask(channel, 0); - } - - if (app_bt_device.avrcp_get_capabilities_rsp[device_id] == NULL) - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_get_capabilities_rsp[device_id]); - - // app_bt_device.avrcp_get_capabilities_rsp[device_id]->transId = btif_get_avrcp_cmd_frame(parms)->transId; - //app_bt_device.avrcp_get_capabilities_rsp[device_id]->ctype = BTIF_AVCTP_RESPONSE_IMPLEMENTED_STABLE; - btif_avrcp_set_capabilities_rsp_cmd( app_bt_device.avrcp_get_capabilities_rsp[device_id],btif_get_avrcp_cmd_frame(parms)->transId, BTIF_AVCTP_RESPONSE_IMPLEMENTED_STABLE); - APP_A2DP_TRACE(1,"::avrcp_callback_TG AVRCP_EVENT_COMMAND send support event transId:%d", btif_get_app_bt_device_avrcp_notify_rsp_transid(app_bt_device.avrcp_get_capabilities_rsp[device_id])); - btif_avrcp_ct_get_capabilities_rsp(channel,app_bt_device.avrcp_get_capabilities_rsp[device_id],BTIF_AVRCP_CAPABILITY_EVENTS_SUPPORTED,btif_get_avrcp_adv_rem_event_mask(channel)); - // AVRCP_CtGetCapabilities_Rsp(chnl,app_bt_device.avrcp_get_capabilities_rsp[device_id],BTIF_AVRCP_CAPABILITY_EVENTS_SUPPORTED,chnl->adv.eventMask); - } - else - { - APP_A2DP_TRACE(0,"::avrcp_callback_TG AVRCP_EVENT_COMMAND send error event value"); - } - } - break; - } - - } - - }else if(btif_get_avrcp_cmd_frame(parms)->ctype == BTIF_AVCTP_CTYPE_CONTROL){ - APP_A2DP_TRACE(0,"::avrcp_callback_TG AVRCP_EVENT_COMMAND AVCTP_CTYPE_CONTROL\n"); - DUMP8("%02x ", btif_get_avrcp_cmd_frame(parms)->operands, btif_get_avrcp_cmd_frame(parms)->operandLen); - if (btif_get_avrcp_cmd_frame(parms)->operands[3] == BTIF_AVRCP_OP_SET_ABSOLUTE_VOLUME){ - APP_A2DP_TRACE(1,"::avrcp_callback_TG AVRCP_EID_VOLUME_CHANGED transId:%d\n", btif_get_avrcp_cmd_frame(parms)->transId); - a2dp_volume_set(device_id, (btif_get_avrcp_cmd_frame(parms)->operands[7])+1); - //a2dp_volume_set(btif_get_avrcp_cmd_frame(parms)->operands[7]); - log_event_2(EVENT_AVRCP_VOLUME_CHANGE_REQ_RECEIVED, (btif_avrcp_get_cmgrhandler_remDev_hciHandle(channel))&0x3, - btif_get_avrcp_cmd_frame(parms)->operands[7]); - - if (app_bt_device.avrcp_control_rsp[device_id] == NULL) - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_control_rsp[device_id]); - - //app_bt_device.avrcp_control_rsp[device_id]->transId = btif_get_avrcp_cmd_frame(parms)->transId; - //app_bt_device.avrcp_control_rsp[device_id]->ctype = BTIF_AVCTP_RESPONSE_ACCEPTED; - btif_avrcp_set_control_rsp_cmd(app_bt_device.avrcp_control_rsp[device_id], - btif_get_avrcp_cmd_frame(parms)->transId, BTIF_AVCTP_RESPONSE_ACCEPTED); - DUMP8("%02x ", btif_get_avrcp_cmd_frame(parms)->operands, btif_get_avrcp_cmd_frame(parms)->operandLen); - - //AVRCP_CtAcceptAbsoluteVolume_Rsp(chnl, app_bt_device.avrcp_control_rsp[device_id], btif_get_avrcp_cmd_frame(parms)->operands[7]); - btif_avrcp_ct_accept_absolute_volume_rsp(channel, app_bt_device.avrcp_control_rsp[device_id], btif_get_avrcp_cmd_frame(parms)->operands[7]); - } - else if (BTIF_AVRCP_OP_CUSTOM_CMD == btif_get_avrcp_cmd_frame(parms)->operands[3]) - { - app_AVRCP_CustomCmd_Received(& btif_get_avrcp_cmd_frame(parms)->operands[7], btif_get_avrcp_cmd_frame(parms)->operandLen - 7); - app_AVRCP_sendCustomCmdRsp(device_id, channel, true, btif_get_avrcp_cmd_frame(parms)->transId); - } - }else if ( btif_get_avrcp_cmd_frame(parms)->ctype == BTIF_AVCTP_CTYPE_NOTIFY){ - bt_status_t status; - APP_A2DP_TRACE(0,"::avrcp_callback_TG AVRCP_EVENT_COMMAND AVCTP_CTYPE_NOTIFY\n"); - DUMP8("%02x ", btif_get_avrcp_cmd_frame(parms)->operands, btif_get_avrcp_cmd_frame(parms)->operandLen); - if ( btif_get_avrcp_cmd_frame(parms)->operands[7] == BTIF_AVRCP_EID_VOLUME_CHANGED){ - APP_A2DP_TRACE(1,"::avrcp_callback_TG AVRCP_EID_VOLUME_CHANGED transId:%d\n", btif_get_avrcp_cmd_frame(parms)->transId); - if (app_bt_device.avrcp_notify_rsp[device_id] == NULL) - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_notify_rsp[device_id]); - - //app_bt_device.avrcp_notify_rsp[device_id]->transId = btif_get_avrcp_cmd_frame(parms)->transId; - //app_bt_device.avrcp_notify_rsp[device_id]->ctype = BTIF_AVCTP_RESPONSE_INTERIM; - btif_avrcp_set_notify_rsp_cmd(app_bt_device.avrcp_notify_rsp[device_id],btif_get_avrcp_cmd_frame(parms)->transId, BTIF_AVCTP_RESPONSE_INTERIM) ; - app_bt_device.volume_report[device_id] = BTIF_AVCTP_RESPONSE_INTERIM; - - //status = AVRCP_CtGetAbsoluteVolume_Rsp(chnl, app_bt_device.avrcp_notify_rsp[device_id], a2dp_volume_get()); - status = btif_avrcp_ct_get_absolute_volume_rsp(channel, app_bt_device.avrcp_notify_rsp[device_id], a2dp_volume_get(device_id)); - APP_A2DP_TRACE(1,"::avrcp_callback_TG AVRCP_EVENT_COMMAND AVRCP_EID_VOLUME_CHANGED nRet:%x\n",status); - } + break; + case BTIF_AVRCP_EVENT_COMMAND: + APP_A2DP_TRACE( + 2, "::avrcp_callback_TG AVRCP_EVENT_COMMAND device_id=%d,role=%x\n", + device_id, btif_get_avrcp_channel_role(channel)); + APP_A2DP_TRACE( + 2, "::avrcp_callback_TG AVRCP_EVENT_COMMAND ctype=%x,subunitype=%x\n", + btif_get_avrcp_cmd_frame(parms)->ctype, + btif_get_avrcp_cmd_frame(parms)->subunitType); + APP_A2DP_TRACE( + 2, "::avrcp_callback_TG AVRCP_EVENT_COMMAND subunitId=%x,opcode=%x\n", + btif_get_avrcp_cmd_frame(parms)->subunitId, + btif_get_avrcp_cmd_frame(parms)->opcode); + APP_A2DP_TRACE( + 2, + "::avrcp_callback_TG AVRCP_EVENT_COMMAND operands=%x,operandLen=%x\n", + btif_get_avrcp_cmd_frame(parms)->operands, + btif_get_avrcp_cmd_frame(parms)->operandLen); + APP_A2DP_TRACE(1, "::avrcp_callback_TG AVRCP_EVENT_COMMAND more=%x\n", + btif_get_avrcp_cmd_frame(parms)->more); + if (btif_get_avrcp_cmd_frame(parms)->ctype == BTIF_AVRCP_CTYPE_STATUS) { + uint32_t company_id = + *(btif_get_avrcp_cmd_frame(parms)->operands + 2) + + ((uint32_t)(*(btif_get_avrcp_cmd_frame(parms)->operands + 1)) << 8) + + ((uint32_t)(*(btif_get_avrcp_cmd_frame(parms)->operands)) << 16); + TRACE(1, "::avrcp_callback_TG AVRCP_EVENT_COMMAND company_id=%x\n", + company_id); + if (company_id == 0x001958) // bt sig + { + avrcp_operation_t op = *(btif_get_avrcp_cmd_frame(parms)->operands + 3); + uint8_t oplen = + *(btif_get_avrcp_cmd_frame(parms)->operands + 6) + + ((uint32_t)(*(btif_get_avrcp_cmd_frame(parms)->operands + 5)) << 8); + APP_A2DP_TRACE( + 2, "::avrcp_callback_TG AVRCP_EVENT_COMMAND op=%x,oplen=%x\n", op, + oplen); + switch (op) { + case BTIF_AVRCP_OP_GET_CAPABILITIES: { + uint8_t event = *(btif_get_avrcp_cmd_frame(parms)->operands + 7); + if (event == BTIF_AVRCP_CAPABILITY_COMPANY_ID) { + APP_A2DP_TRACE(0, "::avrcp_callback_TG AVRCP_EVENT_COMMAND send " + "support compay id"); + } else if (event == BTIF_AVRCP_CAPABILITY_EVENTS_SUPPORTED) { + APP_A2DP_TRACE(1, + "::avrcp_callback_TG AVRCP_EVENT_COMMAND send " + "support event transId:%d", + btif_get_avrcp_cmd_frame(parms)->transId); + if (app_bt_device.avrcpVolumeSync) { + btif_set_avrcp_adv_rem_event_mask( + channel, BTIF_AVRCP_ENABLE_VOLUME_CHANGED); + } else { + btif_set_avrcp_adv_rem_event_mask(channel, 0); } - break; - case BTIF_AVRCP_EVENT_ADV_CMD_TIMEOUT: - APP_A2DP_TRACE(2,"::avrcp_callback_TG AVRCP_EVENT_ADV_CMD_TIMEOUT device_id=%d,role=%x\n",device_id,btif_get_avrcp_channel_role(channel)); - break; + + if (app_bt_device.avrcp_get_capabilities_rsp[device_id] == NULL) + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_get_capabilities_rsp[device_id]); + + // app_bt_device.avrcp_get_capabilities_rsp[device_id]->transId = + // btif_get_avrcp_cmd_frame(parms)->transId; + // app_bt_device.avrcp_get_capabilities_rsp[device_id]->ctype = + // BTIF_AVCTP_RESPONSE_IMPLEMENTED_STABLE; + btif_avrcp_set_capabilities_rsp_cmd( + app_bt_device.avrcp_get_capabilities_rsp[device_id], + btif_get_avrcp_cmd_frame(parms)->transId, + BTIF_AVCTP_RESPONSE_IMPLEMENTED_STABLE); + APP_A2DP_TRACE( + 1, + "::avrcp_callback_TG AVRCP_EVENT_COMMAND send support event " + "transId:%d", + btif_get_app_bt_device_avrcp_notify_rsp_transid( + app_bt_device.avrcp_get_capabilities_rsp[device_id])); + btif_avrcp_ct_get_capabilities_rsp( + channel, app_bt_device.avrcp_get_capabilities_rsp[device_id], + BTIF_AVRCP_CAPABILITY_EVENTS_SUPPORTED, + btif_get_avrcp_adv_rem_event_mask(channel)); + // AVRCP_CtGetCapabilities_Rsp(chnl,app_bt_device.avrcp_get_capabilities_rsp[device_id],BTIF_AVRCP_CAPABILITY_EVENTS_SUPPORTED,chnl->adv.eventMask); + } else { + APP_A2DP_TRACE(0, "::avrcp_callback_TG AVRCP_EVENT_COMMAND send " + "error event value"); + } + } break; + } + } + + } else if (btif_get_avrcp_cmd_frame(parms)->ctype == + BTIF_AVCTP_CTYPE_CONTROL) { + APP_A2DP_TRACE( + 0, "::avrcp_callback_TG AVRCP_EVENT_COMMAND AVCTP_CTYPE_CONTROL\n"); + DUMP8("%02x ", btif_get_avrcp_cmd_frame(parms)->operands, + btif_get_avrcp_cmd_frame(parms)->operandLen); + if (btif_get_avrcp_cmd_frame(parms)->operands[3] == + BTIF_AVRCP_OP_SET_ABSOLUTE_VOLUME) { + APP_A2DP_TRACE( + 1, "::avrcp_callback_TG AVRCP_EID_VOLUME_CHANGED transId:%d\n", + btif_get_avrcp_cmd_frame(parms)->transId); + a2dp_volume_set(device_id, + (btif_get_avrcp_cmd_frame(parms)->operands[7]) + 1); + // a2dp_volume_set(btif_get_avrcp_cmd_frame(parms)->operands[7]); + log_event_2(EVENT_AVRCP_VOLUME_CHANGE_REQ_RECEIVED, + (btif_avrcp_get_cmgrhandler_remDev_hciHandle(channel)) & + 0x3, + btif_get_avrcp_cmd_frame(parms)->operands[7]); + + if (app_bt_device.avrcp_control_rsp[device_id] == NULL) + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_control_rsp[device_id]); + + // app_bt_device.avrcp_control_rsp[device_id]->transId = + // btif_get_avrcp_cmd_frame(parms)->transId; + // app_bt_device.avrcp_control_rsp[device_id]->ctype = + // BTIF_AVCTP_RESPONSE_ACCEPTED; + btif_avrcp_set_control_rsp_cmd( + app_bt_device.avrcp_control_rsp[device_id], + btif_get_avrcp_cmd_frame(parms)->transId, + BTIF_AVCTP_RESPONSE_ACCEPTED); + DUMP8("%02x ", btif_get_avrcp_cmd_frame(parms)->operands, + btif_get_avrcp_cmd_frame(parms)->operandLen); + + // AVRCP_CtAcceptAbsoluteVolume_Rsp(chnl, + // app_bt_device.avrcp_control_rsp[device_id], + // btif_get_avrcp_cmd_frame(parms)->operands[7]); + btif_avrcp_ct_accept_absolute_volume_rsp( + channel, app_bt_device.avrcp_control_rsp[device_id], + btif_get_avrcp_cmd_frame(parms)->operands[7]); + } else if (BTIF_AVRCP_OP_CUSTOM_CMD == + btif_get_avrcp_cmd_frame(parms)->operands[3]) { + app_AVRCP_CustomCmd_Received( + &btif_get_avrcp_cmd_frame(parms)->operands[7], + btif_get_avrcp_cmd_frame(parms)->operandLen - 7); + app_AVRCP_sendCustomCmdRsp(device_id, channel, true, + btif_get_avrcp_cmd_frame(parms)->transId); + } + } else if (btif_get_avrcp_cmd_frame(parms)->ctype == + BTIF_AVCTP_CTYPE_NOTIFY) { + bt_status_t status; + APP_A2DP_TRACE( + 0, "::avrcp_callback_TG AVRCP_EVENT_COMMAND AVCTP_CTYPE_NOTIFY\n"); + DUMP8("%02x ", btif_get_avrcp_cmd_frame(parms)->operands, + btif_get_avrcp_cmd_frame(parms)->operandLen); + if (btif_get_avrcp_cmd_frame(parms)->operands[7] == + BTIF_AVRCP_EID_VOLUME_CHANGED) { + APP_A2DP_TRACE( + 1, "::avrcp_callback_TG AVRCP_EID_VOLUME_CHANGED transId:%d\n", + btif_get_avrcp_cmd_frame(parms)->transId); + if (app_bt_device.avrcp_notify_rsp[device_id] == NULL) + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_notify_rsp[device_id]); + + // app_bt_device.avrcp_notify_rsp[device_id]->transId = + // btif_get_avrcp_cmd_frame(parms)->transId; + // app_bt_device.avrcp_notify_rsp[device_id]->ctype = + // BTIF_AVCTP_RESPONSE_INTERIM; + btif_avrcp_set_notify_rsp_cmd(app_bt_device.avrcp_notify_rsp[device_id], + btif_get_avrcp_cmd_frame(parms)->transId, + BTIF_AVCTP_RESPONSE_INTERIM); + app_bt_device.volume_report[device_id] = BTIF_AVCTP_RESPONSE_INTERIM; + + // status = AVRCP_CtGetAbsoluteVolume_Rsp(chnl, + // app_bt_device.avrcp_notify_rsp[device_id], a2dp_volume_get()); + status = btif_avrcp_ct_get_absolute_volume_rsp( + channel, app_bt_device.avrcp_notify_rsp[device_id], + a2dp_volume_get(device_id)); + APP_A2DP_TRACE(1, + "::avrcp_callback_TG AVRCP_EVENT_COMMAND " + "AVRCP_EID_VOLUME_CHANGED nRet:%x\n", + status); + } } + break; + case BTIF_AVRCP_EVENT_ADV_CMD_TIMEOUT: + APP_A2DP_TRACE(2, + "::avrcp_callback_TG AVRCP_EVENT_ADV_CMD_TIMEOUT " + "device_id=%d,role=%x\n", + device_id, btif_get_avrcp_channel_role(channel)); + break; + } } #endif - -avrcp_media_status_t media_status = 0xff; -uint8_t avrcp_get_media_status(void) -{ - APP_A2DP_TRACE(2,"%s %d",__func__, media_status); - return media_status; +avrcp_media_status_t media_status = 0xff; +uint8_t avrcp_get_media_status(void) { + APP_A2DP_TRACE(2, "%s %d", __func__, media_status); + return media_status; } - uint8_t avrcp_ctrl_music_flag; -void avrcp_set_media_status(uint8_t status) -{ - APP_A2DP_TRACE(2,"%s %d",__func__, status); - if ((status == 1 && avrcp_ctrl_music_flag == 2) || (status == 2 && avrcp_ctrl_music_flag == 1)) - avrcp_ctrl_music_flag = 0; +uint8_t avrcp_ctrl_music_flag; +void avrcp_set_media_status(uint8_t status) { + APP_A2DP_TRACE(2, "%s %d", __func__, status); + if ((status == 1 && avrcp_ctrl_music_flag == 2) || + (status == 2 && avrcp_ctrl_music_flag == 1)) + avrcp_ctrl_music_flag = 0; - - media_status = status; + media_status = status; } - - - - #else -void a2dp_init(void) -{ - for(uint8_t i=0; ievent %d\n", Parms->event); - switch(Parms->event) - { - case AVRCP_EVENT_CONNECT_IND: - TRACE(1,"::AVRCP_EVENT_CONNECT_IND %d\n", Parms->event); - AVRCP_ConnectRsp(chnl, 1); - break; - case AVRCP_EVENT_CONNECT: - TRACE(1,"::AVRCP_EVENT_CONNECT %d\n", Parms->event); - break; - case AVRCP_EVENT_RESPONSE: - TRACE(1,"::AVRCP_EVENT_RESPONSE %d\n", Parms->event); +extern "C" void avrcp_callback(AvrcpChannel *chnl, + const AvrcpCallbackParms *Parms) { + TRACE(2, "avrcp_callback : chnl %p, Parms %p\n", chnl, Parms); + TRACE(1, "::Parms->event %d\n", Parms->event); + switch (Parms->event) { + case AVRCP_EVENT_CONNECT_IND: + TRACE(1, "::AVRCP_EVENT_CONNECT_IND %d\n", Parms->event); + AVRCP_ConnectRsp(chnl, 1); + break; + case AVRCP_EVENT_CONNECT: + TRACE(1, "::AVRCP_EVENT_CONNECT %d\n", Parms->event); + break; + case AVRCP_EVENT_RESPONSE: + TRACE(1, "::AVRCP_EVENT_RESPONSE %d\n", Parms->event); - break; - case AVRCP_EVENT_PANEL_CNF: - TRACE(3,"::AVRCP_EVENT_PANEL_CNF %x,%x,%x", - Parms->p.panelCnf.response,Parms->p.panelCnf.operation,Parms->p.panelCnf.press); + break; + case AVRCP_EVENT_PANEL_CNF: + TRACE(3, "::AVRCP_EVENT_PANEL_CNF %x,%x,%x", Parms->p.panelCnf.response, + Parms->p.panelCnf.operation, Parms->p.panelCnf.press); #if 0 if((Parms->p.panelCnf.response == AVCTP_RESPONSE_ACCEPTED) && (Parms->p.panelCnf.press == TRUE)) { AVRCP_SetPanelKey(chnl,Parms->p.panelCnf.operation,FALSE); } #endif - break; - } + break; + } } #endif -//void avrcp_init(void) +// void avrcp_init(void) //{ // hal_uart_open(HAL_UART_ID_0,NULL); // TRACE(0,"avrcp_init...OK\n"); //} - - - int store_sbc_buffer(unsigned char *buf, unsigned int len); int a2dp_audio_sbc_set_frame_info(int rcv_len, int frame_num); -void btapp_send_pause_key(enum BT_DEVICE_ID_T stream_id) -{ - TRACE(1,"btapp_send_pause_key id = %x",stream_id); - btif_avrcp_set_panel_key(app_bt_device.avrcp_channel[stream_id],BTIF_AVRCP_POP_PAUSE,TRUE); - btif_avrcp_set_panel_key(app_bt_device.avrcp_channel[stream_id],BTIF_AVRCP_POP_PAUSE,FALSE); - // app_bt_device.a2dp_play_pause_flag = 0; +void btapp_send_pause_key(enum BT_DEVICE_ID_T stream_id) { + TRACE(1, "btapp_send_pause_key id = %x", stream_id); + btif_avrcp_set_panel_key(app_bt_device.avrcp_channel[stream_id], + BTIF_AVRCP_POP_PAUSE, TRUE); + btif_avrcp_set_panel_key(app_bt_device.avrcp_channel[stream_id], + BTIF_AVRCP_POP_PAUSE, FALSE); + // app_bt_device.a2dp_play_pause_flag = 0; } +void btapp_a2dp_suspend_music(enum BT_DEVICE_ID_T stream_id) { + TRACE(1, "btapp_a2dp_suspend_music id = %x", stream_id); -void btapp_a2dp_suspend_music(enum BT_DEVICE_ID_T stream_id) -{ - TRACE(1,"btapp_a2dp_suspend_music id = %x",stream_id); - - btapp_send_pause_key(stream_id); + btapp_send_pause_key(stream_id); } extern enum AUD_SAMPRATE_T a2dp_sample_rate; -#define A2DP_TIMESTAMP_TRACE(s,...) -//TRACE(s, ##__VA_ARGS__) +#define A2DP_TIMESTAMP_TRACE(s, ...) +// TRACE(s, ##__VA_ARGS__) #define A2DP_TIMESTAMP_DEBOUNCE_DURATION (1000) #define A2DP_TIMESTAMP_MODE_SAMPLE_THRESHOLD (2000) #define A2DP_TIMESTAMP_SYNC_LIMIT_CNT (100) #define A2DP_TIMESTAMP_SYNC_TIME_THRESHOLD (60) -#define A2DP_TIMESTAMP_SYNC_SAMPLE_THRESHOLD ((int64_t)a2dp_sample_rate*A2DP_TIMESTAMP_SYNC_TIME_THRESHOLD/1000) +#define A2DP_TIMESTAMP_SYNC_SAMPLE_THRESHOLD \ + ((int64_t)a2dp_sample_rate * A2DP_TIMESTAMP_SYNC_TIME_THRESHOLD / 1000) #define RICE_THRESHOLD #define RICE_THRESHOLD -struct A2DP_TIMESTAMP_INFO_T{ - uint16_t rtp_timestamp; - uint32_t loc_timestamp; - uint16_t frame_num; - int32_t rtp_timestamp_diff_sum; +struct A2DP_TIMESTAMP_INFO_T { + uint16_t rtp_timestamp; + uint32_t loc_timestamp; + uint16_t frame_num; + int32_t rtp_timestamp_diff_sum; }; -enum A2DP_TIMESTAMP_MODE_T{ - A2DP_TIMESTAMP_MODE_NONE, - A2DP_TIMESTAMP_MODE_SAMPLE, - A2DP_TIMESTAMP_MODE_TIME, +enum A2DP_TIMESTAMP_MODE_T { + A2DP_TIMESTAMP_MODE_NONE, + A2DP_TIMESTAMP_MODE_SAMPLE, + A2DP_TIMESTAMP_MODE_TIME, }; enum A2DP_TIMESTAMP_MODE_T a2dp_timestamp_mode = A2DP_TIMESTAMP_MODE_NONE; -struct A2DP_TIMESTAMP_INFO_T a2dp_timestamp_pre = {0,0,0}; +struct A2DP_TIMESTAMP_INFO_T a2dp_timestamp_pre = {0, 0, 0}; bool a2dp_timestamp_parser_need_sync = false; -int a2dp_timestamp_parser_init(void) -{ - a2dp_timestamp_mode = A2DP_TIMESTAMP_MODE_NONE; - a2dp_timestamp_pre.rtp_timestamp = 0; - a2dp_timestamp_pre.loc_timestamp = 0; - a2dp_timestamp_pre.frame_num = 0; - a2dp_timestamp_pre.rtp_timestamp_diff_sum = 0; - a2dp_timestamp_parser_need_sync = false; - return 0; +int a2dp_timestamp_parser_init(void) { + a2dp_timestamp_mode = A2DP_TIMESTAMP_MODE_NONE; + a2dp_timestamp_pre.rtp_timestamp = 0; + a2dp_timestamp_pre.loc_timestamp = 0; + a2dp_timestamp_pre.frame_num = 0; + a2dp_timestamp_pre.rtp_timestamp_diff_sum = 0; + a2dp_timestamp_parser_need_sync = false; + return 0; } -int a2dp_timestamp_parser_needsync(void) -{ - a2dp_timestamp_parser_need_sync = true; - return 0; +int a2dp_timestamp_parser_needsync(void) { + a2dp_timestamp_parser_need_sync = true; + return 0; } -int a2dp_timestamp_parser_run(uint16_t timestamp, uint16_t framenum) -{ - static int skip_cnt = 0; - struct A2DP_TIMESTAMP_INFO_T curr_timestamp; - int skipframe = 0; - uint16_t rtpdiff; - int32_t locdiff; - bool needsave_rtp_timestamp = true; - bool needsave_loc_timestamp = true; +int a2dp_timestamp_parser_run(uint16_t timestamp, uint16_t framenum) { + static int skip_cnt = 0; + struct A2DP_TIMESTAMP_INFO_T curr_timestamp; + int skipframe = 0; + uint16_t rtpdiff; + int32_t locdiff; + bool needsave_rtp_timestamp = true; + bool needsave_loc_timestamp = true; - curr_timestamp.rtp_timestamp = timestamp; - curr_timestamp.loc_timestamp = hal_sys_timer_get(); - curr_timestamp.frame_num = framenum; + curr_timestamp.rtp_timestamp = timestamp; + curr_timestamp.loc_timestamp = hal_sys_timer_get(); + curr_timestamp.frame_num = framenum; - switch(a2dp_timestamp_mode) { - case A2DP_TIMESTAMP_MODE_NONE: + switch (a2dp_timestamp_mode) { + case A2DP_TIMESTAMP_MODE_NONE: -// TRACE(5,"parser rtp:%d loc:%d num:%d prertp:%d preloc:%d\n", curr_timestamp.rtp_timestamp, curr_timestamp.loc_timestamp, curr_timestamp.frame_num, -// a2dp_timestamp_pre.rtp_timestamp, a2dp_timestamp_pre.loc_timestamp); - if (a2dp_timestamp_pre.rtp_timestamp){ - locdiff = curr_timestamp.loc_timestamp - a2dp_timestamp_pre.loc_timestamp; - if (TICKS_TO_MS(locdiff) > A2DP_TIMESTAMP_DEBOUNCE_DURATION){ - rtpdiff = curr_timestamp.rtp_timestamp - a2dp_timestamp_pre.rtp_timestamp; - if (ABS((int16_t)TICKS_TO_MS(locdiff)-rtpdiff)>A2DP_TIMESTAMP_MODE_SAMPLE_THRESHOLD){ - a2dp_timestamp_mode = A2DP_TIMESTAMP_MODE_SAMPLE; - TRACE(0,"A2DP_TIMESTAMP_MODE_SAMPLE\n"); - }else{ - a2dp_timestamp_mode = A2DP_TIMESTAMP_MODE_TIME; - TRACE(0,"A2DP_TIMESTAMP_MODE_TIME\n"); - } - }else{ - needsave_rtp_timestamp = false; - needsave_loc_timestamp = false; - } - } - break; - case A2DP_TIMESTAMP_MODE_SAMPLE: - if (a2dp_timestamp_parser_need_sync){ - skip_cnt++; - rtpdiff = curr_timestamp.rtp_timestamp - a2dp_timestamp_pre.rtp_timestamp; - locdiff = curr_timestamp.loc_timestamp - a2dp_timestamp_pre.loc_timestamp; - a2dp_timestamp_pre.rtp_timestamp_diff_sum += rtpdiff; - - A2DP_TIMESTAMP_TRACE(3,"%d-%d=%d", curr_timestamp.rtp_timestamp, a2dp_timestamp_pre.rtp_timestamp, rtpdiff); - - A2DP_TIMESTAMP_TRACE(3,"%d-%d=%d", curr_timestamp.loc_timestamp , a2dp_timestamp_pre.loc_timestamp, locdiff); - - A2DP_TIMESTAMP_TRACE(3,"%d-%d=%d", (int32_t)((int64_t)(TICKS_TO_MS(locdiff))*(uint32_t)a2dp_sample_rate/1000), - a2dp_timestamp_pre.rtp_timestamp_diff_sum, - (int32_t)((TICKS_TO_MS(locdiff)*a2dp_sample_rate/1000) - a2dp_timestamp_pre.rtp_timestamp_diff_sum)); - - - A2DP_TIMESTAMP_TRACE(2,"A2DP_TIMESTAMP_MODE_SAMPLE SYNC diff:%d cnt:%d\n", (int32_t)((int64_t)(TICKS_TO_MS(locdiff)*a2dp_sample_rate/1000) - a2dp_timestamp_pre.rtp_timestamp_diff_sum), skip_cnt); - if (((int64_t)(TICKS_TO_MS(locdiff)*a2dp_sample_rate/1000) - a2dp_timestamp_pre.rtp_timestamp_diff_sum) < (int32_t)A2DP_TIMESTAMP_SYNC_SAMPLE_THRESHOLD){ - TRACE(1,"A2DP_TIMESTAMP_MODE_SAMPLE RESYNC OK cnt:%d\n", skip_cnt); - skip_cnt = 0; - a2dp_timestamp_parser_need_sync = false; - }else if (skip_cnt > A2DP_TIMESTAMP_SYNC_LIMIT_CNT){ - TRACE(0,"A2DP_TIMESTAMP_MODE_SAMPLE RESYNC FORCE END\n"); - skip_cnt = 0; - a2dp_timestamp_parser_need_sync = false; - }else{ - needsave_loc_timestamp = false; - skipframe = 1; - } - }else{ - a2dp_timestamp_pre.rtp_timestamp_diff_sum = 0; - } - break; - case A2DP_TIMESTAMP_MODE_TIME: - if (a2dp_timestamp_parser_need_sync){ - skip_cnt++; - rtpdiff = curr_timestamp.rtp_timestamp - a2dp_timestamp_pre.rtp_timestamp; - locdiff = curr_timestamp.loc_timestamp - a2dp_timestamp_pre.loc_timestamp; - a2dp_timestamp_pre.rtp_timestamp_diff_sum += rtpdiff; - - A2DP_TIMESTAMP_TRACE(5,"%d/%d/ %d/%d %d\n", rtpdiff,a2dp_timestamp_pre.rtp_timestamp_diff_sum, - a2dp_timestamp_pre.loc_timestamp, curr_timestamp.loc_timestamp, - TICKS_TO_MS(locdiff)); - A2DP_TIMESTAMP_TRACE(2,"A2DP_TIMESTAMP_MODE_TIME SYNC diff:%d cnt:%d\n", (int32_t)ABS(TICKS_TO_MS(locdiff) - a2dp_timestamp_pre.rtp_timestamp_diff_sum), skip_cnt); - if (((int64_t)TICKS_TO_MS(locdiff) - a2dp_timestamp_pre.rtp_timestamp_diff_sum) < A2DP_TIMESTAMP_SYNC_TIME_THRESHOLD){ - TRACE(1,"A2DP_TIMESTAMP_MODE_TIME RESYNC OK cnt:%d\n", skip_cnt); - skip_cnt = 0; - needsave_loc_timestamp = false; - a2dp_timestamp_parser_need_sync = false; - }else if (skip_cnt > A2DP_TIMESTAMP_SYNC_LIMIT_CNT){ - TRACE(0,"A2DP_TIMESTAMP_MODE_TIME RESYNC FORCE END\n"); - skip_cnt = 0; - a2dp_timestamp_parser_need_sync = false; - }else{ - needsave_loc_timestamp = false; - skipframe = 1; - } - }else{ - a2dp_timestamp_pre.rtp_timestamp_diff_sum = 0; - } - break; + // TRACE(5,"parser rtp:%d loc:%d num:%d prertp:%d preloc:%d\n", + // curr_timestamp.rtp_timestamp, curr_timestamp.loc_timestamp, + // curr_timestamp.frame_num, + // a2dp_timestamp_pre.rtp_timestamp, + // a2dp_timestamp_pre.loc_timestamp); + if (a2dp_timestamp_pre.rtp_timestamp) { + locdiff = curr_timestamp.loc_timestamp - a2dp_timestamp_pre.loc_timestamp; + if (TICKS_TO_MS(locdiff) > A2DP_TIMESTAMP_DEBOUNCE_DURATION) { + rtpdiff = + curr_timestamp.rtp_timestamp - a2dp_timestamp_pre.rtp_timestamp; + if (ABS((int16_t)TICKS_TO_MS(locdiff) - rtpdiff) > + A2DP_TIMESTAMP_MODE_SAMPLE_THRESHOLD) { + a2dp_timestamp_mode = A2DP_TIMESTAMP_MODE_SAMPLE; + TRACE(0, "A2DP_TIMESTAMP_MODE_SAMPLE\n"); + } else { + a2dp_timestamp_mode = A2DP_TIMESTAMP_MODE_TIME; + TRACE(0, "A2DP_TIMESTAMP_MODE_TIME\n"); + } + } else { + needsave_rtp_timestamp = false; + needsave_loc_timestamp = false; + } } + break; + case A2DP_TIMESTAMP_MODE_SAMPLE: + if (a2dp_timestamp_parser_need_sync) { + skip_cnt++; + rtpdiff = curr_timestamp.rtp_timestamp - a2dp_timestamp_pre.rtp_timestamp; + locdiff = curr_timestamp.loc_timestamp - a2dp_timestamp_pre.loc_timestamp; + a2dp_timestamp_pre.rtp_timestamp_diff_sum += rtpdiff; - if (needsave_rtp_timestamp){ - a2dp_timestamp_pre.rtp_timestamp = curr_timestamp.rtp_timestamp; + A2DP_TIMESTAMP_TRACE(3, "%d-%d=%d", curr_timestamp.rtp_timestamp, + a2dp_timestamp_pre.rtp_timestamp, rtpdiff); + + A2DP_TIMESTAMP_TRACE(3, "%d-%d=%d", curr_timestamp.loc_timestamp, + a2dp_timestamp_pre.loc_timestamp, locdiff); + + A2DP_TIMESTAMP_TRACE( + 3, "%d-%d=%d", + (int32_t)((int64_t)(TICKS_TO_MS(locdiff)) * + (uint32_t)a2dp_sample_rate / 1000), + a2dp_timestamp_pre.rtp_timestamp_diff_sum, + (int32_t)((TICKS_TO_MS(locdiff) * a2dp_sample_rate / 1000) - + a2dp_timestamp_pre.rtp_timestamp_diff_sum)); + + A2DP_TIMESTAMP_TRACE( + 2, "A2DP_TIMESTAMP_MODE_SAMPLE SYNC diff:%d cnt:%d\n", + (int32_t)((int64_t)(TICKS_TO_MS(locdiff) * a2dp_sample_rate / 1000) - + a2dp_timestamp_pre.rtp_timestamp_diff_sum), + skip_cnt); + if (((int64_t)(TICKS_TO_MS(locdiff) * a2dp_sample_rate / 1000) - + a2dp_timestamp_pre.rtp_timestamp_diff_sum) < + (int32_t)A2DP_TIMESTAMP_SYNC_SAMPLE_THRESHOLD) { + TRACE(1, "A2DP_TIMESTAMP_MODE_SAMPLE RESYNC OK cnt:%d\n", skip_cnt); + skip_cnt = 0; + a2dp_timestamp_parser_need_sync = false; + } else if (skip_cnt > A2DP_TIMESTAMP_SYNC_LIMIT_CNT) { + TRACE(0, "A2DP_TIMESTAMP_MODE_SAMPLE RESYNC FORCE END\n"); + skip_cnt = 0; + a2dp_timestamp_parser_need_sync = false; + } else { + needsave_loc_timestamp = false; + skipframe = 1; + } + } else { + a2dp_timestamp_pre.rtp_timestamp_diff_sum = 0; } + break; + case A2DP_TIMESTAMP_MODE_TIME: + if (a2dp_timestamp_parser_need_sync) { + skip_cnt++; + rtpdiff = curr_timestamp.rtp_timestamp - a2dp_timestamp_pre.rtp_timestamp; + locdiff = curr_timestamp.loc_timestamp - a2dp_timestamp_pre.loc_timestamp; + a2dp_timestamp_pre.rtp_timestamp_diff_sum += rtpdiff; - if (needsave_loc_timestamp){ - a2dp_timestamp_pre.loc_timestamp = curr_timestamp.loc_timestamp; + A2DP_TIMESTAMP_TRACE(5, "%d/%d/ %d/%d %d\n", rtpdiff, + a2dp_timestamp_pre.rtp_timestamp_diff_sum, + a2dp_timestamp_pre.loc_timestamp, + curr_timestamp.loc_timestamp, TICKS_TO_MS(locdiff)); + A2DP_TIMESTAMP_TRACE( + 2, "A2DP_TIMESTAMP_MODE_TIME SYNC diff:%d cnt:%d\n", + (int32_t)ABS(TICKS_TO_MS(locdiff) - + a2dp_timestamp_pre.rtp_timestamp_diff_sum), + skip_cnt); + if (((int64_t)TICKS_TO_MS(locdiff) - + a2dp_timestamp_pre.rtp_timestamp_diff_sum) < + A2DP_TIMESTAMP_SYNC_TIME_THRESHOLD) { + TRACE(1, "A2DP_TIMESTAMP_MODE_TIME RESYNC OK cnt:%d\n", skip_cnt); + skip_cnt = 0; + needsave_loc_timestamp = false; + a2dp_timestamp_parser_need_sync = false; + } else if (skip_cnt > A2DP_TIMESTAMP_SYNC_LIMIT_CNT) { + TRACE(0, "A2DP_TIMESTAMP_MODE_TIME RESYNC FORCE END\n"); + skip_cnt = 0; + a2dp_timestamp_parser_need_sync = false; + } else { + needsave_loc_timestamp = false; + skipframe = 1; + } + } else { + a2dp_timestamp_pre.rtp_timestamp_diff_sum = 0; } + break; + } - return skipframe; + if (needsave_rtp_timestamp) { + a2dp_timestamp_pre.rtp_timestamp = curr_timestamp.rtp_timestamp; + } + + if (needsave_loc_timestamp) { + a2dp_timestamp_pre.loc_timestamp = curr_timestamp.loc_timestamp; + } + + return skipframe; } static struct BT_DEVICE_ID_DIFF stream_id_flag; #if defined(A2DP_LHDC_ON) uint8_t bits_depth; -uint8_t bt_sbc_player_get_bitsDepth(void){ - if (app_bt_device.sample_bit[stream_id_flag.id] != bits_depth) { - /* code */ - bits_depth = app_bt_device.sample_bit[stream_id_flag.id]; - } - return bits_depth; +uint8_t bt_sbc_player_get_bitsDepth(void) { + if (app_bt_device.sample_bit[stream_id_flag.id] != bits_depth) { + /* code */ + bits_depth = app_bt_device.sample_bit[stream_id_flag.id]; + } + return bits_depth; } #endif - #ifdef __BT_ONE_BRING_TWO__ - -uint8_t a2dp_stream_id_distinguish(a2dp_stream_t *Stream , uint8_t event_type) -{ - uint8_t found_device_id = BT_DEVICE_NUM; - if(Stream == app_bt_device.a2dp_connected_stream[BT_DEVICE_ID_1]) - { - found_device_id = BT_DEVICE_ID_1; - stream_id_flag.id = BT_DEVICE_ID_1; +uint8_t a2dp_stream_id_distinguish(a2dp_stream_t *Stream, uint8_t event_type) { + uint8_t found_device_id = BT_DEVICE_NUM; + if (Stream == app_bt_device.a2dp_connected_stream[BT_DEVICE_ID_1]) { + found_device_id = BT_DEVICE_ID_1; + stream_id_flag.id = BT_DEVICE_ID_1; + } else if (Stream == app_bt_device.a2dp_connected_stream[BT_DEVICE_ID_2]) { + found_device_id = BT_DEVICE_ID_2; + stream_id_flag.id = BT_DEVICE_ID_2; + } else /* if(event_type == A2DP_EVENT_STREAM_CLOSED)*/ { + btif_remote_device_t *remDev = 0; + btif_remote_device_t *connected_remDev[BT_DEVICE_NUM]; + remDev = btif_a2dp_get_remote_device(Stream); + connected_remDev[0] = btif_a2dp_get_remote_device( + app_bt_device.a2dp_connected_stream[BT_DEVICE_ID_1]); + connected_remDev[1] = btif_a2dp_get_remote_device( + app_bt_device.a2dp_connected_stream[BT_DEVICE_ID_2]); + if ((connected_remDev[0] == remDev) && (remDev != 0)) { + stream_id_flag.id = BT_DEVICE_ID_1; + found_device_id = BT_DEVICE_ID_1; + } else if ((connected_remDev[1] == remDev) && (remDev != 0)) { + stream_id_flag.id = BT_DEVICE_ID_2; + found_device_id = BT_DEVICE_ID_2; } - else if(Stream == app_bt_device.a2dp_connected_stream[BT_DEVICE_ID_2]) - { - found_device_id = BT_DEVICE_ID_2; - stream_id_flag.id = BT_DEVICE_ID_2; - }else/* if(event_type == A2DP_EVENT_STREAM_CLOSED)*/{ - btif_remote_device_t * remDev = 0; - btif_remote_device_t * connected_remDev[BT_DEVICE_NUM]; - remDev = btif_a2dp_get_remote_device(Stream); - connected_remDev[0] = btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[BT_DEVICE_ID_1]); - connected_remDev[1] = btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[BT_DEVICE_ID_2]); - if((connected_remDev[0] == remDev) && (remDev!= 0)){ - stream_id_flag.id = BT_DEVICE_ID_1; - found_device_id = BT_DEVICE_ID_1; - } - else if((connected_remDev[1] == remDev) && (remDev !=0)){ - stream_id_flag.id = BT_DEVICE_ID_2; - found_device_id = BT_DEVICE_ID_2; - } + } + return found_device_id; +} + +uint8_t POSSIBLY_UNUSED a2dp_get_streaming_id(void) { + uint8_t nRet = 0; + if (btif_a2dp_get_stream_state( + app_bt_device.a2dp_connected_stream[BT_DEVICE_ID_1]) == + BTIF_AVDTP_STRM_STATE_STREAMING) + nRet |= 1 << 0; + if (btif_a2dp_get_stream_state( + app_bt_device.a2dp_connected_stream[BT_DEVICE_ID_2]) == + BTIF_AVDTP_STRM_STATE_STREAMING) + nRet |= 1 << 1; + return nRet; +} + +/* profile pass to here 2 states, if no will to change it, call api to confirm + * it */ +uint8_t a2dp_stream_confirm_stream_state(uint8_t index, uint8_t old_state, + uint8_t new_state) { + return a2dp_codec_confirm_stream_state(index, old_state, new_state); +} + +uint8_t a2dp_stream_locate_the_connected_dev_id(a2dp_stream_t *Stream) { + for (uint8_t index = 0; index < BT_DEVICE_NUM; index++) { + if ((app_bt_device.a2dp_stream[index]->a2dp_stream) == Stream) { + TRACE(1, "Get a2dp stream index %d", index); + return index; } - return found_device_id; -} -uint8_t POSSIBLY_UNUSED a2dp_get_streaming_id(void) -{ - uint8_t nRet = 0; - if( btif_a2dp_get_stream_state(app_bt_device.a2dp_connected_stream[BT_DEVICE_ID_1]) == BTIF_AVDTP_STRM_STATE_STREAMING) - nRet |= 1<<0; - if(btif_a2dp_get_stream_state(app_bt_device.a2dp_connected_stream[BT_DEVICE_ID_2]) == BTIF_AVDTP_STRM_STATE_STREAMING) - nRet |= 1<<1; - return nRet; -} - -/* profile pass to here 2 states, if no will to change it, call api to confirm it */ -uint8_t a2dp_stream_confirm_stream_state(uint8_t index, uint8_t old_state, uint8_t new_state) -{ - return a2dp_codec_confirm_stream_state(index, old_state, new_state); -} - -uint8_t a2dp_stream_locate_the_connected_dev_id(a2dp_stream_t *Stream) -{ - for (uint8_t index = 0;index < BT_DEVICE_NUM;index++) - { - if ((app_bt_device.a2dp_stream[index]->a2dp_stream) == Stream) - { - TRACE(1,"Get a2dp stream index %d", index); - return index; - } - - #if defined(A2DP_AAC_ON) - if ((app_bt_device.a2dp_aac_stream[index]->a2dp_stream) == Stream) - { - TRACE(1,"Get a2dp aac stream index %d", index); - return index; - } - #endif +#if defined(A2DP_AAC_ON) + if ((app_bt_device.a2dp_aac_stream[index]->a2dp_stream) == Stream) { + TRACE(1, "Get a2dp aac stream index %d", index); + return index; + } +#endif #if defined(A2DP_LHDC_ON) - if ((app_bt_device.a2dp_lhdc_stream[index]->a2dp_stream) == Stream) - { - TRACE(1,"Get a2dp lhdc stream index %d", index); - return index; - } + if ((app_bt_device.a2dp_lhdc_stream[index]->a2dp_stream) == Stream) { + TRACE(1, "Get a2dp lhdc stream index %d", index); + return index; + } #endif #if defined(A2DP_SCALABLE_ON) - if ((app_bt_device.a2dp_scalable_stream[index]->a2dp_stream) == Stream) - { - TRACE(1,"Get a2dp scalable stream index %d", index); - return index; - } + if ((app_bt_device.a2dp_scalable_stream[index]->a2dp_stream) == Stream) { + TRACE(1, "Get a2dp scalable stream index %d", index); + return index; + } #endif #if defined(A2DP_LDAC_ON) - if ((app_bt_device.a2dp_ldac_stream[index]->a2dp_stream) == Stream) - { - TRACE(1,"Get a2dp ldac stream index %d", index); - return index; - } -#endif - + if ((app_bt_device.a2dp_ldac_stream[index]->a2dp_stream) == Stream) { + TRACE(1, "Get a2dp ldac stream index %d", index); + return index; } +#endif + } - ASSERT(false, "Connected to an non-existing a2dp stream instance."); + ASSERT(false, "Connected to an non-existing a2dp stream instance."); - return 0; + return 0; } -void a2dp_stream_push_connected_stream(a2dp_stream_t *Stream) -{ +void a2dp_stream_push_connected_stream(a2dp_stream_t *Stream) { - uint8_t reserved_device = BT_DEVICE_NUM; - reserved_device = a2dp_stream_locate_the_connected_dev_id(Stream); - app_bt_device.a2dp_connected_stream[reserved_device] = Stream; + uint8_t reserved_device = BT_DEVICE_NUM; + reserved_device = a2dp_stream_locate_the_connected_dev_id(Stream); + app_bt_device.a2dp_connected_stream[reserved_device] = Stream; } -void a2dp_stream_push_configed_stream(a2dp_stream_t *Stream,btif_remote_device_t *rem) -{ - uint8_t reserved_device = BT_DEVICE_NUM; - reserved_device = a2dp_stream_locate_the_connected_dev_id(Stream); - app_bt_device.a2dp_outconfiged_stream[reserved_device] = Stream; - app_bt_device.a2dp_outconfiged_rem[reserved_device] = rem; - +void a2dp_stream_push_configed_stream(a2dp_stream_t *Stream, + btif_remote_device_t *rem) { + uint8_t reserved_device = BT_DEVICE_NUM; + reserved_device = a2dp_stream_locate_the_connected_dev_id(Stream); + app_bt_device.a2dp_outconfiged_stream[reserved_device] = Stream; + app_bt_device.a2dp_outconfiged_rem[reserved_device] = rem; } #ifdef A2DP_AAC_ON -uint8_t is_aac_stream(a2dp_stream_t *Stream) -{ - if((Stream == app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream) - || (Stream == app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_2]->a2dp_stream)) - return TRUE; - else - return FALSE; +uint8_t is_aac_stream(a2dp_stream_t *Stream) { + if ((Stream == app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream) || + (Stream == app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_2]->a2dp_stream)) + return TRUE; + else + return FALSE; } #endif #endif - -#if defined( __BTIF_EARPHONE__) && defined(__BTIF_BT_RECONNECT__) +#if defined(__BTIF_EARPHONE__) && defined(__BTIF_BT_RECONNECT__) #ifdef __BT_ONE_BRING_TWO__ extern btif_device_record_t record2_copy; @@ -1992,2135 +2190,2257 @@ extern uint8_t record2_avalible; #endif #if defined(A2DP_LHDC_ON) -void a2dp_lhdc_config(uint8_t * elements){ - //uint8_t * elements = &(Info->p.configReq->codec.elements[0]); - uint32_t vendor_id = (uint32_t)elements[0]; - vendor_id |= ((uint32_t)elements[1]) << 8; - vendor_id |= ((uint32_t)elements[2]) << 16; - vendor_id |= ((uint32_t)elements[3]) << 24; - uint16_t codec_id = (uint16_t)elements[4]; - codec_id |= ((uint16_t)elements[5]) << 8; - uint8_t config = elements[6]; - TRACE(3,"##codecType: LHDC Codec, config value = 0x%02x, elements[6]=0x%02x elements[7]=0x%02x\n", A2DP_LHDC_SR_DATA(config), elements[6], elements[7]); - if (vendor_id == A2DP_LHDC_VENDOR_ID && codec_id == A2DP_LHDC_CODEC_ID) { - TRACE(2,"Vendor ID = 0x%08x, Codec ID = 0x%04x, LHDC Codec\n", vendor_id, codec_id); - switch (A2DP_LHDC_SR_DATA(config)) { - case A2DP_LHDC_SR_96000: - app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_96; - TRACE(1,"%s:CodecCfg sample_rate 96000\n", __func__); - break; - case A2DP_LHDC_SR_48000: - app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_48; - TRACE(1,"%s:CodecCfg sample_rate 48000\n", __func__); - break; - case A2DP_LHDC_SR_44100: - app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_44; - TRACE(1,"%s:CodecCfg sample_rate 44100\n", __func__); - break; - } - switch (A2DP_LHDC_FMT_DATA(config)) { - case A2DP_LHDC_FMT_16: - app_bt_device.sample_bit[stream_id_flag.id] = 16; - TRACE(1,"%s:CodecCfg bits per sampe = 16", __func__); - break; - case A2DP_LHDC_FMT_24: - TRACE(1,"%s:CodecCfg bits per sampe = 24", __func__); - app_bt_device.sample_bit[stream_id_flag.id] = 24; - break; - } - - if (elements[7]&A2DP_LHDC_LLC_ENABLE){ - app_bt_device.a2dp_lhdc_llc[stream_id_flag.id] = true;; - }else{ - app_bt_device.a2dp_lhdc_llc[stream_id_flag.id] = false;; - } +void a2dp_lhdc_config(uint8_t *elements) { + // uint8_t * elements = &(Info->p.configReq->codec.elements[0]); + uint32_t vendor_id = (uint32_t)elements[0]; + vendor_id |= ((uint32_t)elements[1]) << 8; + vendor_id |= ((uint32_t)elements[2]) << 16; + vendor_id |= ((uint32_t)elements[3]) << 24; + uint16_t codec_id = (uint16_t)elements[4]; + codec_id |= ((uint16_t)elements[5]) << 8; + uint8_t config = elements[6]; + TRACE(3, + "##codecType: LHDC Codec, config value = 0x%02x, elements[6]=0x%02x " + "elements[7]=0x%02x\n", + A2DP_LHDC_SR_DATA(config), elements[6], elements[7]); + if (vendor_id == A2DP_LHDC_VENDOR_ID && codec_id == A2DP_LHDC_CODEC_ID) { + TRACE(2, "Vendor ID = 0x%08x, Codec ID = 0x%04x, LHDC Codec\n", vendor_id, + codec_id); + switch (A2DP_LHDC_SR_DATA(config)) { + case A2DP_LHDC_SR_96000: + app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_96; + TRACE(1, "%s:CodecCfg sample_rate 96000\n", __func__); + break; + case A2DP_LHDC_SR_48000: + app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_48; + TRACE(1, "%s:CodecCfg sample_rate 48000\n", __func__); + break; + case A2DP_LHDC_SR_44100: + app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_44; + TRACE(1, "%s:CodecCfg sample_rate 44100\n", __func__); + break; } + switch (A2DP_LHDC_FMT_DATA(config)) { + case A2DP_LHDC_FMT_16: + app_bt_device.sample_bit[stream_id_flag.id] = 16; + TRACE(1, "%s:CodecCfg bits per sampe = 16", __func__); + break; + case A2DP_LHDC_FMT_24: + TRACE(1, "%s:CodecCfg bits per sampe = 24", __func__); + app_bt_device.sample_bit[stream_id_flag.id] = 24; + break; + } + + if (elements[7] & A2DP_LHDC_LLC_ENABLE) { + app_bt_device.a2dp_lhdc_llc[stream_id_flag.id] = true; + ; + } else { + app_bt_device.a2dp_lhdc_llc[stream_id_flag.id] = false; + ; + } + } } -uint8_t a2dp_lhdc_config_llc_get(void) -{ - return app_bt_device.a2dp_lhdc_llc[stream_id_flag.id]; +uint8_t a2dp_lhdc_config_llc_get(void) { + return app_bt_device.a2dp_lhdc_llc[stream_id_flag.id]; } #endif #if defined(A2DP_SCALABLE_ON) -void a2dp_scalable_config(uint8_t * elements){ - //uint8_t * elements = &(Info->p.configReq->codec.elements[0]); - uint32_t vendor_id = (uint32_t)elements[0]; - vendor_id |= ((uint32_t)elements[1]) << 8; - vendor_id |= ((uint32_t)elements[2]) << 16; - vendor_id |= ((uint32_t)elements[3]) << 24; - uint16_t codec_id = (uint16_t)elements[4]; - codec_id |= ((uint16_t)elements[5]) << 8; - uint8_t config = elements[6]; - TRACE(2,"##codecType: Scalable Codec, config value = 0x%02x, elements[6]=0x%02x\n", A2DP_SCALABLE_SR_DATA(config), elements[6]); - if (vendor_id == A2DP_SCALABLE_VENDOR_ID && codec_id == A2DP_SCALABLE_CODEC_ID) { - TRACE(2,"Vendor ID = 0x%08x, Codec ID = 0x%04x, Scalable Codec\n", vendor_id, codec_id); - switch (A2DP_SCALABLE_SR_DATA(config)) { - case A2DP_SCALABLE_SR_96000: - app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_96; - TRACE(1,"%s:CodecCfg sample_rate 96000\n", __func__); - break; - case A2DP_SCALABLE_SR_48000: - app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_48; - TRACE(1,"%s:CodecCfg sample_rate 48000\n", __func__); - break; - case A2DP_SCALABLE_SR_44100: - app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_44; - TRACE(1,"%s:CodecCfg sample_rate 44100\n", __func__); - break; - case A2DP_SCALABLE_SR_32000: - app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_32; - TRACE(1,"%s:CodecCfg sample_rate 32000\n", __func__); - break; - } - switch (A2DP_SCALABLE_FMT_DATA(config)) { - case A2DP_SCALABLE_FMT_16: - app_bt_device.sample_bit[stream_id_flag.id] = 16; - TRACE(1,"%s:CodecCfg bits per sampe = 16", __func__); - break; - case A2DP_SCALABLE_FMT_24: - app_bt_device.sample_bit[stream_id_flag.id] = 24; - TRACE(1,"%s:CodecCfg bits per sampe = 24", __func__); - if (app_bt_device.sample_rate[stream_id_flag.id] != A2D_SBC_IE_SAMP_FREQ_96) { - app_bt_device.sample_bit[stream_id_flag.id] = 16; - TRACE(1,"%s:CodeCfg reset bit per sample to 16 when samplerate is not 96k", __func__); - } - break; - } +void a2dp_scalable_config(uint8_t *elements) { + // uint8_t * elements = &(Info->p.configReq->codec.elements[0]); + uint32_t vendor_id = (uint32_t)elements[0]; + vendor_id |= ((uint32_t)elements[1]) << 8; + vendor_id |= ((uint32_t)elements[2]) << 16; + vendor_id |= ((uint32_t)elements[3]) << 24; + uint16_t codec_id = (uint16_t)elements[4]; + codec_id |= ((uint16_t)elements[5]) << 8; + uint8_t config = elements[6]; + TRACE(2, + "##codecType: Scalable Codec, config value = 0x%02x, " + "elements[6]=0x%02x\n", + A2DP_SCALABLE_SR_DATA(config), elements[6]); + if (vendor_id == A2DP_SCALABLE_VENDOR_ID && + codec_id == A2DP_SCALABLE_CODEC_ID) { + TRACE(2, "Vendor ID = 0x%08x, Codec ID = 0x%04x, Scalable Codec\n", + vendor_id, codec_id); + switch (A2DP_SCALABLE_SR_DATA(config)) { + case A2DP_SCALABLE_SR_96000: + app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_96; + TRACE(1, "%s:CodecCfg sample_rate 96000\n", __func__); + break; + case A2DP_SCALABLE_SR_48000: + app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_48; + TRACE(1, "%s:CodecCfg sample_rate 48000\n", __func__); + break; + case A2DP_SCALABLE_SR_44100: + app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_44; + TRACE(1, "%s:CodecCfg sample_rate 44100\n", __func__); + break; + case A2DP_SCALABLE_SR_32000: + app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_32; + TRACE(1, "%s:CodecCfg sample_rate 32000\n", __func__); + break; } + switch (A2DP_SCALABLE_FMT_DATA(config)) { + case A2DP_SCALABLE_FMT_16: + app_bt_device.sample_bit[stream_id_flag.id] = 16; + TRACE(1, "%s:CodecCfg bits per sampe = 16", __func__); + break; + case A2DP_SCALABLE_FMT_24: + app_bt_device.sample_bit[stream_id_flag.id] = 24; + TRACE(1, "%s:CodecCfg bits per sampe = 24", __func__); + if (app_bt_device.sample_rate[stream_id_flag.id] != + A2D_SBC_IE_SAMP_FREQ_96) { + app_bt_device.sample_bit[stream_id_flag.id] = 16; + TRACE( + 1, + "%s:CodeCfg reset bit per sample to 16 when samplerate is not 96k", + __func__); + } + break; + } + } } #endif #if defined(A2DP_LDAC_ON) int ldac_decoder_sf = 0; int ldac_decoder_cm = 0; -void a2dp_ldac_config(uint8_t * elements){ - //uint8_t * elements = &(Info->p.configReq->codec.elements[0]); - uint32_t vendor_id = (uint32_t)elements[0]; - vendor_id |= ((uint32_t)elements[1]) << 8; - vendor_id |= ((uint32_t)elements[2]) << 16; - vendor_id |= ((uint32_t)elements[3]) << 24; - uint16_t codec_id = (uint16_t)elements[4]; - codec_id |= ((uint16_t)elements[5]) << 8; - uint8_t sf_config = elements[6]; - uint8_t cm_config = elements[7]; - TRACE(2,"##codecType: LDAC Codec, config value = 0x%02x, elements[6]=0x%02x\n", A2DP_LDAC_SR_DATA(sf_config), elements[6]); - TRACE(2,"##codecType: LDAC Codec, config value = 0x%02x, elements[7]=0x%02x\n", A2DP_LDAC_CM_DATA(cm_config), elements[7]); - TRACE(2,"Vendor ID = 0x%08x, Codec ID = 0x%04x, LDAC Codec\n", vendor_id, codec_id); - if (vendor_id == A2DP_LDAC_VENDOR_ID && codec_id == A2DP_LDAC_CODEC_ID) { - switch (A2DP_LDAC_SR_DATA(sf_config)) { - case A2DP_LDAC_SR_96000: - app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_96; - ldac_decoder_sf = 96000; - TRACE(1,"%s:ldac CodecCfg sample_rate 96000\n", __func__); - break; - case A2DP_LDAC_SR_88200: - app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_88; - ldac_decoder_sf = 88200; - TRACE(1,"%s:ldac CodecCfg sample_rate 88200\n", __func__); - break; - case A2DP_LDAC_SR_48000: - app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_48; - ldac_decoder_sf = 48000; - TRACE(1,"%s:ldac CodecCfg sample_rate 48000\n", __func__); - break; - case A2DP_LDAC_SR_44100: - app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_44; - ldac_decoder_sf = 44100; - TRACE(1,"%sldac :CodecCfg sample_rate 44100\n", __func__); - break; - /*case A2DP_LDAC_SR_88200: - app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_88; - ldac_decoder_sf = 88200; - TRACE(1,"%s:ldac CodecCfg sample_rate 88200\n", __func__); - break;*/ - } - switch (A2DP_LDAC_CM_DATA(cm_config)) { - case A2DP_LDAC_CM_MONO: - app_bt_device.channel_mode = LDACBT_CHANNEL_MODE_MONO; - TRACE(1,"%s:ldac CodecCfg A2DP_LDAC_CM_MONO", __func__); - break; - case A2DP_LDAC_CM_DUAL: - TRACE(1,"%s:ldac CodecCfg A2DP_LDAC_CM_DUAL", __func__); - app_bt_device.channel_mode = LDACBT_CHANNEL_MODE_DUAL_CHANNEL; - break; - case A2DP_LDAC_CM_STEREO: - TRACE(1,"%s:ldac ldac CodecCfg A2DP_LDAC_CM_STEREO", __func__); - app_bt_device.channel_mode = LDACBT_CHANNEL_MODE_STEREO; - break; - } +void a2dp_ldac_config(uint8_t *elements) { + // uint8_t * elements = &(Info->p.configReq->codec.elements[0]); + uint32_t vendor_id = (uint32_t)elements[0]; + vendor_id |= ((uint32_t)elements[1]) << 8; + vendor_id |= ((uint32_t)elements[2]) << 16; + vendor_id |= ((uint32_t)elements[3]) << 24; + uint16_t codec_id = (uint16_t)elements[4]; + codec_id |= ((uint16_t)elements[5]) << 8; + uint8_t sf_config = elements[6]; + uint8_t cm_config = elements[7]; + TRACE(2, + "##codecType: LDAC Codec, config value = 0x%02x, elements[6]=0x%02x\n", + A2DP_LDAC_SR_DATA(sf_config), elements[6]); + TRACE(2, + "##codecType: LDAC Codec, config value = 0x%02x, elements[7]=0x%02x\n", + A2DP_LDAC_CM_DATA(cm_config), elements[7]); + TRACE(2, "Vendor ID = 0x%08x, Codec ID = 0x%04x, LDAC Codec\n", vendor_id, + codec_id); + if (vendor_id == A2DP_LDAC_VENDOR_ID && codec_id == A2DP_LDAC_CODEC_ID) { + switch (A2DP_LDAC_SR_DATA(sf_config)) { + case A2DP_LDAC_SR_96000: + app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_96; + ldac_decoder_sf = 96000; + TRACE(1, "%s:ldac CodecCfg sample_rate 96000\n", __func__); + break; + case A2DP_LDAC_SR_88200: + app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_88; + ldac_decoder_sf = 88200; + TRACE(1, "%s:ldac CodecCfg sample_rate 88200\n", __func__); + break; + case A2DP_LDAC_SR_48000: + app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_48; + ldac_decoder_sf = 48000; + TRACE(1, "%s:ldac CodecCfg sample_rate 48000\n", __func__); + break; + case A2DP_LDAC_SR_44100: + app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_44; + ldac_decoder_sf = 44100; + TRACE(1, "%sldac :CodecCfg sample_rate 44100\n", __func__); + break; + /*case A2DP_LDAC_SR_88200: + app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_88; + ldac_decoder_sf = 88200; + TRACE(1,"%s:ldac CodecCfg sample_rate 88200\n", __func__); + break;*/ } + switch (A2DP_LDAC_CM_DATA(cm_config)) { + case A2DP_LDAC_CM_MONO: + app_bt_device.channel_mode = LDACBT_CHANNEL_MODE_MONO; + TRACE(1, "%s:ldac CodecCfg A2DP_LDAC_CM_MONO", __func__); + break; + case A2DP_LDAC_CM_DUAL: + TRACE(1, "%s:ldac CodecCfg A2DP_LDAC_CM_DUAL", __func__); + app_bt_device.channel_mode = LDACBT_CHANNEL_MODE_DUAL_CHANNEL; + break; + case A2DP_LDAC_CM_STEREO: + TRACE(1, "%s:ldac ldac CodecCfg A2DP_LDAC_CM_STEREO", __func__); + app_bt_device.channel_mode = LDACBT_CHANNEL_MODE_STEREO; + break; + } + } } -void app_ibrt_restore_ldac_info(uint8_t sample_freq) -{ - app_bt_device.channel_mode=LDACBT_CHANNEL_MODE_STEREO; - switch (sample_freq) - { - case A2D_SBC_IE_SAMP_FREQ_96: - ldac_decoder_sf = 96000; - break; - case A2D_SBC_IE_SAMP_FREQ_88: - ldac_decoder_sf = 88200; - break; - case A2D_SBC_IE_SAMP_FREQ_48: - ldac_decoder_sf = 48000; - break; - case A2D_SBC_IE_SAMP_FREQ_44: - ldac_decoder_sf = 44100; - break; - } +void app_ibrt_restore_ldac_info(uint8_t sample_freq) { + app_bt_device.channel_mode = LDACBT_CHANNEL_MODE_STEREO; + switch (sample_freq) { + case A2D_SBC_IE_SAMP_FREQ_96: + ldac_decoder_sf = 96000; + break; + case A2D_SBC_IE_SAMP_FREQ_88: + ldac_decoder_sf = 88200; + break; + case A2D_SBC_IE_SAMP_FREQ_48: + ldac_decoder_sf = 48000; + break; + case A2D_SBC_IE_SAMP_FREQ_44: + ldac_decoder_sf = 44100; + break; + } } - int channel_mode; -int bt_ldac_player_get_channelmode(void){ - if (app_bt_device.channel_mode != channel_mode) { - /* code */ - channel_mode = app_bt_device.channel_mode; - } - return channel_mode; -} -int bt_get_ladc_sample_rate(void){ - - return ldac_decoder_sf; +int bt_ldac_player_get_channelmode(void) { + if (app_bt_device.channel_mode != channel_mode) { + /* code */ + channel_mode = app_bt_device.channel_mode; + } + return channel_mode; } +int bt_get_ladc_sample_rate(void) { return ldac_decoder_sf; } #endif - - -extern void app_bt_profile_connect_manager_a2dp(enum BT_DEVICE_ID_T id, a2dp_stream_t *Stream, const a2dp_callback_parms_t *Info); +extern void +app_bt_profile_connect_manager_a2dp(enum BT_DEVICE_ID_T id, + a2dp_stream_t *Stream, + const a2dp_callback_parms_t *Info); #ifdef __BT_ONE_BRING_TWO__ +void a2dp_dual_slave_setup_during_sco(enum BT_DEVICE_ID_T currentId) { + if (app_bt_device.a2dp_state[BT_DEVICE_ID_1] || + app_bt_device.a2dp_state[BT_DEVICE_ID_2]) { + uint8_t activeDevice = currentId; + uint8_t idleDevice = + (BT_DEVICE_ID_1 == activeDevice) ? BT_DEVICE_ID_2 : BT_DEVICE_ID_1; -void a2dp_dual_slave_setup_during_sco(enum BT_DEVICE_ID_T currentId) -{ - if (app_bt_device.a2dp_state[BT_DEVICE_ID_1] || - app_bt_device.a2dp_state[BT_DEVICE_ID_2]) - { - uint8_t activeDevice = currentId; - uint8_t idleDevice = (BT_DEVICE_ID_1 == activeDevice)?BT_DEVICE_ID_2:BT_DEVICE_ID_1; + btif_remote_device_t *activeRem = btif_a2dp_get_remote_device( + app_bt_device.a2dp_connected_stream[activeDevice]); + btif_remote_device_t *idleRem = btif_a2dp_get_remote_device( + app_bt_device.a2dp_connected_stream[idleDevice]); - btif_remote_device_t* activeRem = - btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[activeDevice]); - btif_remote_device_t* idleRem = - btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[idleDevice]); - - - TRACE(2,"activeRem %p idleRem %p", activeRem, idleRem); - if (idleRem && activeRem) - { - btdrv_enable_dual_slave_configurable_slot_mode(true, - btif_me_get_remote_device_hci_handle(activeRem), - btif_me_get_remote_device_role(activeRem), - btif_me_get_remote_device_hci_handle(idleRem), - btif_me_get_remote_device_role(idleRem)); - } - else - { - btdrv_enable_dual_slave_configurable_slot_mode(false, - 0x80, - BTIF_BCR_SLAVE, - 0x81, - BTIF_BCR_SLAVE); - } - } - else - { - btdrv_enable_dual_slave_configurable_slot_mode(false, - 0x80, - BTIF_BCR_SLAVE, - 0x81, - BTIF_BCR_SLAVE); + TRACE(2, "activeRem %p idleRem %p", activeRem, idleRem); + if (idleRem && activeRem) { + btdrv_enable_dual_slave_configurable_slot_mode( + true, btif_me_get_remote_device_hci_handle(activeRem), + btif_me_get_remote_device_role(activeRem), + btif_me_get_remote_device_hci_handle(idleRem), + btif_me_get_remote_device_role(idleRem)); + } else { + btdrv_enable_dual_slave_configurable_slot_mode( + false, 0x80, BTIF_BCR_SLAVE, 0x81, BTIF_BCR_SLAVE); } + } else { + btdrv_enable_dual_slave_configurable_slot_mode(false, 0x80, BTIF_BCR_SLAVE, + 0x81, BTIF_BCR_SLAVE); + } } +void a2dp_dual_slave_handling_refresh(void) { + if (app_bt_device.a2dp_state[BT_DEVICE_ID_1] || + app_bt_device.a2dp_state[BT_DEVICE_ID_2]) { + TRACE(1, "current a2dp streaming id %d", app_bt_device.curr_a2dp_stream_id); + uint8_t activeDevice = app_bt_device.curr_a2dp_stream_id; + uint8_t idleDevice = + (BT_DEVICE_ID_1 == activeDevice) ? BT_DEVICE_ID_2 : BT_DEVICE_ID_1; -void a2dp_dual_slave_handling_refresh(void) -{ - if (app_bt_device.a2dp_state[BT_DEVICE_ID_1] || - app_bt_device.a2dp_state[BT_DEVICE_ID_2]) - { - TRACE(1,"current a2dp streaming id %d", app_bt_device.curr_a2dp_stream_id); - uint8_t activeDevice = app_bt_device.curr_a2dp_stream_id; - uint8_t idleDevice = (BT_DEVICE_ID_1 == activeDevice)?BT_DEVICE_ID_2:BT_DEVICE_ID_1; - - btif_remote_device_t* activeRem = - btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[activeDevice]); - btif_remote_device_t* idleRem = - btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[idleDevice]); - TRACE(2,"activeRem %p idleRem %p", activeRem, idleRem); - if (idleRem && activeRem) - { - btdrv_enable_dual_slave_configurable_slot_mode(true, - btif_me_get_remote_device_hci_handle(activeRem), - btif_me_get_remote_device_role(activeRem), - btif_me_get_remote_device_hci_handle(idleRem), - btif_me_get_remote_device_role(idleRem)); - } - else - { - btdrv_enable_dual_slave_configurable_slot_mode(false, - 0x80, - BTIF_BCR_SLAVE, - 0x81, - BTIF_BCR_SLAVE); - } - } - else - { - btdrv_enable_dual_slave_configurable_slot_mode(false, - 0x80, - BTIF_BCR_SLAVE, - 0x81, - BTIF_BCR_SLAVE); + btif_remote_device_t *activeRem = btif_a2dp_get_remote_device( + app_bt_device.a2dp_connected_stream[activeDevice]); + btif_remote_device_t *idleRem = btif_a2dp_get_remote_device( + app_bt_device.a2dp_connected_stream[idleDevice]); + TRACE(2, "activeRem %p idleRem %p", activeRem, idleRem); + if (idleRem && activeRem) { + btdrv_enable_dual_slave_configurable_slot_mode( + true, btif_me_get_remote_device_hci_handle(activeRem), + btif_me_get_remote_device_role(activeRem), + btif_me_get_remote_device_hci_handle(idleRem), + btif_me_get_remote_device_role(idleRem)); + } else { + btdrv_enable_dual_slave_configurable_slot_mode( + false, 0x80, BTIF_BCR_SLAVE, 0x81, BTIF_BCR_SLAVE); } + } else { + btdrv_enable_dual_slave_configurable_slot_mode(false, 0x80, BTIF_BCR_SLAVE, + 0x81, BTIF_BCR_SLAVE); + } } -void a2dp_update_music_link(void) -{ - TRACE(1,"current a2dp streaming id %d", app_bt_device.curr_a2dp_stream_id); - uint8_t activeDevice = app_bt_device.curr_a2dp_stream_id; - uint8_t idleDevice = (BT_DEVICE_ID_1 == activeDevice)?BT_DEVICE_ID_2:BT_DEVICE_ID_1; - - btif_remote_device_t* activeRem = - btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[activeDevice]); - btif_remote_device_t* idleRem = - btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[idleDevice]); - TRACE(2,"activeRem %p idleRem %p", activeRem, idleRem); - if (idleRem && activeRem) - { - bt_drv_reg_op_music_link_config( - btif_me_get_remote_device_hci_handle(activeRem), - btif_me_get_remote_device_role(activeRem), - btif_me_get_remote_device_hci_handle(idleRem), - btif_me_get_remote_device_role(idleRem)); - } - else if(activeRem) - { - bt_drv_reg_op_music_link_config( - btif_me_get_remote_device_hci_handle(activeRem), - btif_me_get_remote_device_role(activeRem), - 0xff, - BTIF_BCR_SLAVE); - } +void a2dp_update_music_link(void) { + TRACE(1, "current a2dp streaming id %d", app_bt_device.curr_a2dp_stream_id); + uint8_t activeDevice = app_bt_device.curr_a2dp_stream_id; + uint8_t idleDevice = + (BT_DEVICE_ID_1 == activeDevice) ? BT_DEVICE_ID_2 : BT_DEVICE_ID_1; + btif_remote_device_t *activeRem = btif_a2dp_get_remote_device( + app_bt_device.a2dp_connected_stream[activeDevice]); + btif_remote_device_t *idleRem = btif_a2dp_get_remote_device( + app_bt_device.a2dp_connected_stream[idleDevice]); + TRACE(2, "activeRem %p idleRem %p", activeRem, idleRem); + if (idleRem && activeRem) { + bt_drv_reg_op_music_link_config( + btif_me_get_remote_device_hci_handle(activeRem), + btif_me_get_remote_device_role(activeRem), + btif_me_get_remote_device_hci_handle(idleRem), + btif_me_get_remote_device_role(idleRem)); + } else if (activeRem) { + bt_drv_reg_op_music_link_config( + btif_me_get_remote_device_hci_handle(activeRem), + btif_me_get_remote_device_role(activeRem), 0xff, BTIF_BCR_SLAVE); + } } #endif -uint8_t a2dp_get_latest_paused_device(void) -{ - return app_bt_device.latestPausedDevId; +uint8_t a2dp_get_latest_paused_device(void) { + return app_bt_device.latestPausedDevId; } #ifdef __BT_ONE_BRING_TWO__ #if !defined(__BT_SELECT_PROF_DEVICE_ID__) -static void a2dp_avdtp_stream_state_lock_management(a2dp_stream_t *Stream, const a2dp_callback_parms_t *info) -{ - btif_a2dp_callback_parms_t * Info = (btif_a2dp_callback_parms_t *)info; +static void +a2dp_avdtp_stream_state_lock_management(a2dp_stream_t *Stream, + const a2dp_callback_parms_t *info) { + btif_a2dp_callback_parms_t *Info = (btif_a2dp_callback_parms_t *)info; - static uint8_t last_locked_configedid = 0xff; - if(Info->error!=BTIF_AVDTP_ERR_NO_ERROR) - return; - switch(Info->event) - { + static uint8_t last_locked_configedid = 0xff; + if (Info->error != BTIF_AVDTP_ERR_NO_ERROR) + return; + switch (Info->event) { - case BTIF_A2DP_AVDTP_EVENT_SET_CFG_CNF: //-->set config - LOG_D(0,"outgoing set cfg"); - //record the outgoing configed stream and rem - a2dp_stream_push_configed_stream(Stream,Info->remDev); - break; + case BTIF_A2DP_AVDTP_EVENT_SET_CFG_CNF: //-->set config + LOG_D(0, "outgoing set cfg"); + // record the outgoing configed stream and rem + a2dp_stream_push_configed_stream(Stream, Info->remDev); + break; - case BTIF_A2DP_EVENT_STREAM_RECONFIG_CNF: //reconfig--> - case BTIF_A2DP_EVENT_STREAM_RECONFIG_IND: //rsp reconfig <-- + case BTIF_A2DP_EVENT_STREAM_RECONFIG_CNF: // reconfig--> + case BTIF_A2DP_EVENT_STREAM_RECONFIG_IND: // rsp reconfig <-- + case BTIF_A2DP_EVENT_STREAM_OPEN_IND: // set configed <-- + case BTIF_A2DP_EVENT_STREAM_OPEN: // after avdtp open rsp AVDTP medio + // connected - case BTIF_A2DP_EVENT_STREAM_OPEN_IND: //set configed <-- - case BTIF_A2DP_EVENT_STREAM_OPEN: //after avdtp open rsp AVDTP medio connected + LOG_E(2, "evt %d STREAM %p ", Info->event, Stream); + btif_a2dp_lock_same_deviceid_endpoint(Stream, Info->remDev); + break; + case BTIF_A2DP_EVENT_AVDTP_CLOSE_IND: + case BTIF_A2DP_EVENT_STREAM_CLOSED: // unlock the stream state before the + // connected stream been released - LOG_E(2,"evt %d STREAM %p ",Info->event,Stream); - btif_a2dp_lock_same_deviceid_endpoint(Stream,Info->remDev); - break; - case BTIF_A2DP_EVENT_AVDTP_CLOSE_IND: - case BTIF_A2DP_EVENT_STREAM_CLOSED: //unlock the stream state before the connected stream been released + LOG_E(2, "evt %d STREAM %p ", Info->event, Stream); + btif_a2dp_unlock_same_deviceid_endpoint(Stream, Info->remDev); + break; + case BTIF_A2DP_EVENT_AVDTP_DISCOVER_IND: //<-- discover - LOG_E(2,"evt %d STREAM %p ",Info->event,Stream); - btif_a2dp_unlock_same_deviceid_endpoint(Stream,Info->remDev); - break; - case BTIF_A2DP_EVENT_AVDTP_DISCOVER_IND://<-- discover + LOG_E(0, "DISCOVER_IND"); + btif_a2dp_unlock_the_connected_stream_byRemdev(Info->remDev); - LOG_E(0,"DISCOVER_IND"); - btif_a2dp_unlock_the_connected_stream_byRemdev(Info->remDev); + // lock the other id + last_locked_configedid = + btif_a2dp_trylock_the_other_id_by_configedid(Info->remDev); + break; + case BTIF_A2DP_EVENT_AVDTP_DISCOVER_RSP: + LOG_D(0, "disc rsp"); + btif_a2dp_unlock_deviceid_endpoint(last_locked_configedid); + break; + default: - //lock the other id - last_locked_configedid =btif_a2dp_trylock_the_other_id_by_configedid(Info->remDev); - break; - case BTIF_A2DP_EVENT_AVDTP_DISCOVER_RSP: - LOG_D(0,"disc rsp"); - btif_a2dp_unlock_deviceid_endpoint(last_locked_configedid); - break; - default: - - break; - } + break; + } } #endif #endif #if defined(__BT_SELECT_PROF_DEVICE_ID__) -static void _a2dp_select_stream(a2dp_stream_t *Stream, a2dp_callback_parms_t *info) -{ - uint32_t i = 0, stream_is_on_device_id = 0; - a2dp_stream_t *dst_stream = NULL; - btif_remote_device_t *matching_remdev = NULL, *wanted_remdev = NULL; - // 1. find already connected profile, if any other one profile was conncected, select that device id - // 2. if no other profile connected, select min device id - btif_a2dp_set_dst_stream(info, Stream); - wanted_remdev = btif_a2dp_get_remote_device_from_cbparms(Stream, info); - for(i = 0 ; i < BT_DEVICE_NUM ; i++) { - // Other profile connected - stream_is_on_device_id = app_bt_a2dp_is_stream_on_device_id(Stream, i); - if (app_bt_is_any_profile_connected(i)) { - matching_remdev = app_bt_get_connected_profile_remdev(i); - LOG_D(3,"device_id=%d, a2dp_select_stream : remdev=0x%x:0x%x.", i, wanted_remdev, matching_remdev); - LOG_D(1,"device_id=%d, a2dp_select_stream : other_profile_connected.", i); - if (wanted_remdev == matching_remdev) { - LOG_D(1,"device_id=%d, a2dp_select_stream : same_remdev.", i); - // SWITCH COND 1 : same remdev but cross device id to select stream - if (!stream_is_on_device_id) { - app_bt_a2dp_find_same_unused_stream(Stream, &dst_stream, i); - btif_a2dp_set_dst_stream(info, dst_stream); - LOG_D(3,"device_id=%d, a2dp_select_stream : Switch_cond 1 : 0x%x:0x%x", i, Stream, dst_stream); - } - else { - LOG_D(1,"device_id=%d, a2dp_select_stream : same device id, no_need_to_switch.", i); - } - break; - } - else { - LOG_D(1,"device_id=%d, a2dp_select_stream : different_remdev.", i); - if (stream_is_on_device_id) { - LOG_D(1,"device_id=%d, a2dp_select_stream : error : different_remdev_but_same_device_id, see next device id.", i); - } - else { - LOG_D(1,"device_id=%d, a2dp_select_stream : good : different_remdev_different_device_id, see next device id.", i); - } - } +static void _a2dp_select_stream(a2dp_stream_t *Stream, + a2dp_callback_parms_t *info) { + uint32_t i = 0, stream_is_on_device_id = 0; + a2dp_stream_t *dst_stream = NULL; + btif_remote_device_t *matching_remdev = NULL, *wanted_remdev = NULL; + // 1. find already connected profile, if any other one profile was conncected, + // select that device id + // 2. if no other profile connected, select min device id + btif_a2dp_set_dst_stream(info, Stream); + wanted_remdev = btif_a2dp_get_remote_device_from_cbparms(Stream, info); + for (i = 0; i < BT_DEVICE_NUM; i++) { + // Other profile connected + stream_is_on_device_id = app_bt_a2dp_is_stream_on_device_id(Stream, i); + if (app_bt_is_any_profile_connected(i)) { + matching_remdev = app_bt_get_connected_profile_remdev(i); + LOG_D(3, "device_id=%d, a2dp_select_stream : remdev=0x%x:0x%x.", i, + wanted_remdev, matching_remdev); + LOG_D(1, "device_id=%d, a2dp_select_stream : other_profile_connected.", + i); + if (wanted_remdev == matching_remdev) { + LOG_D(1, "device_id=%d, a2dp_select_stream : same_remdev.", i); + // SWITCH COND 1 : same remdev but cross device id to select stream + if (!stream_is_on_device_id) { + app_bt_a2dp_find_same_unused_stream(Stream, &dst_stream, i); + btif_a2dp_set_dst_stream(info, dst_stream); + LOG_D(3, + "device_id=%d, a2dp_select_stream : Switch_cond 1 : 0x%x:0x%x", + i, Stream, dst_stream); + } else { + LOG_D(1, + "device_id=%d, a2dp_select_stream : same device id, " + "no_need_to_switch.", + i); } - else { - LOG_D(1,"device_id=%d, a2dp_select_stream : other_profile_not_connected.", i); - // first found idle device id is min device id we want - // Assume : other profile will use device id ascending - // TODO to keep other profile use device id ascending - if (!stream_is_on_device_id) { - app_bt_a2dp_find_same_unused_stream(Stream, &dst_stream, i); - btif_a2dp_set_dst_stream(info, dst_stream); - LOG_D(3,"device_id=%d, a2dp_select_stream : Switch_cond 2 : 0x%x:0x%x", i, Stream, dst_stream); - } - else { - LOG_D(1,"device_id=%d, a2dp_select_stream : same device id, no_need_to_switch.", i); - } - break; + break; + } else { + LOG_D(1, "device_id=%d, a2dp_select_stream : different_remdev.", i); + if (stream_is_on_device_id) { + LOG_D(1, + "device_id=%d, a2dp_select_stream : error : " + "different_remdev_but_same_device_id, see next device id.", + i); + } else { + LOG_D(1, + "device_id=%d, a2dp_select_stream : good : " + "different_remdev_different_device_id, see next device id.", + i); } + } + } else { + LOG_D(1, + "device_id=%d, a2dp_select_stream : other_profile_not_connected.", + i); + // first found idle device id is min device id we want + // Assume : other profile will use device id ascending + // TODO to keep other profile use device id ascending + if (!stream_is_on_device_id) { + app_bt_a2dp_find_same_unused_stream(Stream, &dst_stream, i); + btif_a2dp_set_dst_stream(info, dst_stream); + LOG_D(3, "device_id=%d, a2dp_select_stream : Switch_cond 2 : 0x%x:0x%x", + i, Stream, dst_stream); + } else { + LOG_D(1, + "device_id=%d, a2dp_select_stream : same device id, " + "no_need_to_switch.", + i); + } + break; } + } } #endif #if defined(IBRT) -a2dp_stream_t * app_bt_get_mobile_a2dp_stream(uint32_t deviceId); +a2dp_stream_t *app_bt_get_mobile_a2dp_stream(uint32_t deviceId); int app_bt_stream_ibrt_audio_mismatch_stopaudio(void); void app_bt_stream_ibrt_audio_mismatch_resume(void); static uint8_t a2dp_session = 0; -int a2dp_ibrt_session_reset(void) -{ - a2dp_session = 0; - return 0; +int a2dp_ibrt_session_reset(void) { + a2dp_session = 0; + return 0; } -int a2dp_ibrt_session_new(void) -{ - a2dp_session++; - return 0; +int a2dp_ibrt_session_new(void) { + a2dp_session++; + return 0; } -int a2dp_ibrt_session_set(uint8_t session) -{ - a2dp_session = session; - return 0; +int a2dp_ibrt_session_set(uint8_t session) { + a2dp_session = session; + return 0; } -uint32_t a2dp_ibrt_session_get(void) -{ - return a2dp_session; -} +uint32_t a2dp_ibrt_session_get(void) { return a2dp_session; } static int a2dp_ibrt_autotrigger_flag = 0; -int a2dp_ibrt_stream_need_autotrigger_set_flag(void) -{ - a2dp_ibrt_autotrigger_flag = 1; - return 0; +int a2dp_ibrt_stream_need_autotrigger_set_flag(void) { + a2dp_ibrt_autotrigger_flag = 1; + return 0; } -int a2dp_ibrt_stream_need_autotrigger_getandclean_flag(void) -{ - uint32_t flag; +int a2dp_ibrt_stream_need_autotrigger_getandclean_flag(void) { + uint32_t flag; #if defined(IBRT_A2DP_TRIGGER_BY_MYSELF) - flag = a2dp_ibrt_autotrigger_flag; - a2dp_ibrt_autotrigger_flag = 0; + flag = a2dp_ibrt_autotrigger_flag; + a2dp_ibrt_autotrigger_flag = 0; #else - a2dp_ibrt_autotrigger_flag = 0; - flag = 1; + a2dp_ibrt_autotrigger_flag = 0; + flag = 1; #endif - return flag; + return flag; } -int a2dp_ibrt_sync_get_status(ibrt_a2dp_status_t *a2dp_status) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_ibrt_if_get_bt_ctrl_ctx(); - a2dp_status->codec = p_ibrt_ctrl->a2dp_codec; - a2dp_status->volume = a2dp_volume_get(BT_DEVICE_ID_1); - a2dp_status->state = btif_a2dp_get_stream_state(app_bt_device.a2dp_connected_stream[BT_DEVICE_ID_1]); - a2dp_status->latency_factor = a2dp_audio_latency_factor_get(); - a2dp_status->session = a2dp_ibrt_session_get(); - TRACE(4,"%s,sync a2dp stream ac = %p ; stream_status = %d ; codec_type = %d ",__func__,app_bt_device.a2dp_connected_stream[BT_DEVICE_ID_1],a2dp_status->state,a2dp_status->codec.codec_type); - return 0; +int a2dp_ibrt_sync_get_status(ibrt_a2dp_status_t *a2dp_status) { + ibrt_ctrl_t *p_ibrt_ctrl = app_ibrt_if_get_bt_ctrl_ctx(); + a2dp_status->codec = p_ibrt_ctrl->a2dp_codec; + a2dp_status->volume = a2dp_volume_get(BT_DEVICE_ID_1); + a2dp_status->state = btif_a2dp_get_stream_state( + app_bt_device.a2dp_connected_stream[BT_DEVICE_ID_1]); + a2dp_status->latency_factor = a2dp_audio_latency_factor_get(); + a2dp_status->session = a2dp_ibrt_session_get(); + TRACE(4, + "%s,sync a2dp stream ac = %p ; stream_status = %d ; codec_type = %d ", + __func__, app_bt_device.a2dp_connected_stream[BT_DEVICE_ID_1], + a2dp_status->state, a2dp_status->codec.codec_type); + return 0; } +int a2dp_ibrt_sync_set_status(ibrt_a2dp_status_t *a2dp_status) { + ibrt_ctrl_t *p_ibrt_ctrl = app_ibrt_if_get_bt_ctrl_ctx(); + a2dp_stream_t *Stream = app_bt_get_mobile_a2dp_stream(BTIF_DEVICE_ID_1); + btif_avdtp_stream_state_t old_avdtp_stream_state = + btif_a2dp_get_stream_state(Stream); + btif_a2dp_callback_parms_t info; + btif_avdtp_config_request_t avdtp_config_req; -int a2dp_ibrt_sync_set_status(ibrt_a2dp_status_t *a2dp_status) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_ibrt_if_get_bt_ctrl_ctx(); - a2dp_stream_t *Stream = app_bt_get_mobile_a2dp_stream(BTIF_DEVICE_ID_1); - btif_avdtp_stream_state_t old_avdtp_stream_state = btif_a2dp_get_stream_state(Stream); + TRACE(5, "%s,stream_state:[%d]->[%d], codec_type:%d volume:%d", __func__, + old_avdtp_stream_state, a2dp_status->state, + a2dp_status->codec.codec_type, a2dp_status->volume); - btif_a2dp_callback_parms_t info; - btif_avdtp_config_request_t avdtp_config_req; + if ((!(p_ibrt_ctrl->mobile_constate & BTIF_APP_A2DP_PROFILE_ID)) && + (!(p_ibrt_ctrl->ibrt_constate & BTIF_APP_A2DP_PROFILE_ID))) { + TRACE(1, "%s,a2dp profile not connected", __func__); + return 1; + } + btif_a2dp_set_codec_info(BTIF_DEVICE_ID_1, (uint8_t *)&a2dp_status->codec); + info.event = BTIF_A2DP_EVENT_STREAM_OPEN; + app_tws_ibrt_set_a2dp_codec(&info); + app_bt_stream_volume_ptr_update((uint8_t *)btif_me_get_remote_device_bdaddr( + btif_a2dp_get_stream_conn_remDev(Stream))); + a2dp_volume_set(BT_DEVICE_ID_1, a2dp_status->volume); + a2dp_audio_latency_factor_set(a2dp_status->latency_factor); + a2dp_ibrt_session_set(a2dp_status->session); - TRACE(5,"%s,stream_state:[%d]->[%d], codec_type:%d volume:%d", __func__, old_avdtp_stream_state, a2dp_status->state, a2dp_status->codec.codec_type, a2dp_status->volume); - - if ((!(p_ibrt_ctrl->mobile_constate & BTIF_APP_A2DP_PROFILE_ID)) && (!(p_ibrt_ctrl->ibrt_constate & BTIF_APP_A2DP_PROFILE_ID))) - { - TRACE(1,"%s,a2dp profile not connected",__func__); - return 1; - } - - btif_a2dp_set_codec_info(BTIF_DEVICE_ID_1, (uint8_t*)&a2dp_status->codec); - info.event = BTIF_A2DP_EVENT_STREAM_OPEN; - app_tws_ibrt_set_a2dp_codec(&info); - app_bt_stream_volume_ptr_update((uint8_t *) btif_me_get_remote_device_bdaddr(btif_a2dp_get_stream_conn_remDev(Stream))); - a2dp_volume_set(BT_DEVICE_ID_1, a2dp_status->volume); - a2dp_audio_latency_factor_set(a2dp_status->latency_factor); - a2dp_ibrt_session_set(a2dp_status->session); - - if (a2dp_status->state != old_avdtp_stream_state){ - switch(a2dp_status->state) { - case BTIF_AVDTP_STRM_STATE_STREAMING: - app_bt_clear_connecting_profiles_state(BTIF_DEVICE_ID_1); - a2dp_timestamp_parser_init(); - btif_a2dp_set_stream_state(Stream, a2dp_status->state); - info.event = BTIF_A2DP_EVENT_STREAM_STARTED_MOCK; - TRACE(0,"::A2DP_EVENT_STREAM_STARTED mock"); - a2dp_ibrt_stream_need_autotrigger_set_flag(); + if (a2dp_status->state != old_avdtp_stream_state) { + switch (a2dp_status->state) { + case BTIF_AVDTP_STRM_STATE_STREAMING: + app_bt_clear_connecting_profiles_state(BTIF_DEVICE_ID_1); + a2dp_timestamp_parser_init(); + btif_a2dp_set_stream_state(Stream, a2dp_status->state); + info.event = BTIF_A2DP_EVENT_STREAM_STARTED_MOCK; + TRACE(0, "::A2DP_EVENT_STREAM_STARTED mock"); + a2dp_ibrt_stream_need_autotrigger_set_flag(); #if defined(IBRT_FORCE_AUDIO_RETRIGGER) - a2dp_callback(Stream, &info); - app_ibrt_if_force_audio_retrigger(); + a2dp_callback(Stream, &info); + app_ibrt_if_force_audio_retrigger(); #else -// app_bt_stream_ibrt_audio_mismatch_resume(); - a2dp_callback(Stream, &info); + // app_bt_stream_ibrt_audio_mismatch_resume(); + a2dp_callback(Stream, &info); #endif - break; - case BTIF_AVDTP_STRM_STATE_OPEN: - //Ignore START->OPEN transition since itslef can received SUSPEND CMD - if (old_avdtp_stream_state != BTIF_AVDTP_STRM_STATE_STREAMING) - { - TRACE(0,"::A2DP_EVENT_STREAM_OPEN mock"); - btif_a2dp_set_stream_state(Stream, a2dp_status->state); - info.event = BTIF_A2DP_EVENT_STREAM_OPEN; - info.p.configReq = &avdtp_config_req; - info.p.configReq->codec.codecType = a2dp_status->codec.codec_type; - info.p.configReq->codec.elements = (uint8_t*)btif_a2dp_get_stream_codecCfg((a2dp_stream_t *)p_ibrt_ctrl->p_mobile_a2dp_profile)+2; - a2dp_callback(Stream, &info); - } - break; - default: - if (btif_a2dp_get_stream_state(Stream) != BTIF_AVDTP_STRM_STATE_IDLE){ - TRACE(0,"::A2DP_EVENT_STREAM_SUSPENDED mock"); - btif_a2dp_set_stream_state(Stream, a2dp_status->state); - info.event = BTIF_A2DP_EVENT_STREAM_SUSPENDED; - a2dp_callback(Stream, &info); - } - break; - } + break; + case BTIF_AVDTP_STRM_STATE_OPEN: + // Ignore START->OPEN transition since itslef can received SUSPEND CMD + if (old_avdtp_stream_state != BTIF_AVDTP_STRM_STATE_STREAMING) { + TRACE(0, "::A2DP_EVENT_STREAM_OPEN mock"); + btif_a2dp_set_stream_state(Stream, a2dp_status->state); + info.event = BTIF_A2DP_EVENT_STREAM_OPEN; + info.p.configReq = &avdtp_config_req; + info.p.configReq->codec.codecType = a2dp_status->codec.codec_type; + info.p.configReq->codec.elements = + (uint8_t *)btif_a2dp_get_stream_codecCfg( + (a2dp_stream_t *)p_ibrt_ctrl->p_mobile_a2dp_profile) + + 2; + a2dp_callback(Stream, &info); + } + break; + default: + if (btif_a2dp_get_stream_state(Stream) != BTIF_AVDTP_STRM_STATE_IDLE) { + TRACE(0, "::A2DP_EVENT_STREAM_SUSPENDED mock"); + btif_a2dp_set_stream_state(Stream, a2dp_status->state); + info.event = BTIF_A2DP_EVENT_STREAM_SUSPENDED; + a2dp_callback(Stream, &info); + } + break; } - return 0; + } + return 0; } -int a2dp_ibrt_stream_open_mock(void) -{ - a2dp_stream_t *Stream = app_bt_get_mobile_a2dp_stream(BTIF_DEVICE_ID_1); - btif_remote_device_t *remDev = btif_a2dp_get_stream_conn_remDev(Stream); +int a2dp_ibrt_stream_open_mock(void) { + a2dp_stream_t *Stream = app_bt_get_mobile_a2dp_stream(BTIF_DEVICE_ID_1); + btif_remote_device_t *remDev = btif_a2dp_get_stream_conn_remDev(Stream); - TRACE(0,"::A2DP_EVENT_STREAM_OPEN mock"); + TRACE(0, "::A2DP_EVENT_STREAM_OPEN mock"); - app_bt_clear_connecting_profiles_state(BTIF_DEVICE_ID_1); - a2dp_timestamp_parser_init(); - a2dp_set_cur_stream(stream_id_flag.id); + app_bt_clear_connecting_profiles_state(BTIF_DEVICE_ID_1); + a2dp_timestamp_parser_init(); + a2dp_set_cur_stream(stream_id_flag.id); - if (remDev){ - btdevice_profile *btdevice_plf_p = NULL; - btdevice_plf_p = (btdevice_profile *)app_bt_profile_active_store_ptr_get(btif_me_get_remote_device_bdaddr(remDev)->address); - nv_record_btdevicerecord_set_a2dp_profile_active_state(btdevice_plf_p, true); - nv_record_btdevicerecord_set_a2dp_profile_codec(btdevice_plf_p, bt_sbc_player_get_codec_type()); - a2dp_get_current_codec_type(btif_a2dp_get_stream_codec(app_bt_device.a2dp_connected_stream[app_bt_device.curr_a2dp_stream_id])->elements); - app_bt_stream_volume_ptr_update((uint8_t *) btif_me_get_remote_device_bdaddr(remDev)); - TRACE(2,"::A2DP_EVENT_STREAM_OPEN mock codec_type:%d vol:%d", bt_sbc_player_get_codec_type(), app_bt_stream_volume_get_ptr()->a2dp_vol); - }else{ - TRACE(0,"::A2DP_EVENT_STREAM_OPEN mock no find remDev"); - app_bt_stream_volume_ptr_update(NULL); - } + if (remDev) { + btdevice_profile *btdevice_plf_p = NULL; + btdevice_plf_p = (btdevice_profile *)app_bt_profile_active_store_ptr_get( + btif_me_get_remote_device_bdaddr(remDev)->address); + nv_record_btdevicerecord_set_a2dp_profile_active_state(btdevice_plf_p, + true); + nv_record_btdevicerecord_set_a2dp_profile_codec( + btdevice_plf_p, bt_sbc_player_get_codec_type()); + a2dp_get_current_codec_type( + btif_a2dp_get_stream_codec( + app_bt_device + .a2dp_connected_stream[app_bt_device.curr_a2dp_stream_id]) + ->elements); + app_bt_stream_volume_ptr_update( + (uint8_t *)btif_me_get_remote_device_bdaddr(remDev)); + TRACE(2, "::A2DP_EVENT_STREAM_OPEN mock codec_type:%d vol:%d", + bt_sbc_player_get_codec_type(), + app_bt_stream_volume_get_ptr()->a2dp_vol); + } else { + TRACE(0, "::A2DP_EVENT_STREAM_OPEN mock no find remDev"); + app_bt_stream_volume_ptr_update(NULL); + } - return 0; + return 0; } #ifdef __SNIFF_MODE_CHECK__ osTimerId sniff_check_timer = NULL; static void sniff_check_timer_handler(void const *param); -osTimerDef (SNIFF_CHECK_TIMER, (void (*)(void const *))sniff_check_timer_handler); // define timers -uint8_t sniff_timer_state=0; +osTimerDef(SNIFF_CHECK_TIMER, + (void (*)(void const *))sniff_check_timer_handler); // define timers +uint8_t sniff_timer_state = 0; -static void sniff_check_timer_handler(void const *param) -{ - ASSERT(0,"sniff mode error"); +static void sniff_check_timer_handler(void const *param) { + ASSERT(0, "sniff mode error"); } #endif +#define A2DP_IBRT_STREAM_SKIP_TWS_SNIFF_STATUS (1) -#define A2DP_IBRT_STREAM_SKIP_TWS_SNIFF_STATUS (1) - -int a2dp_ibrt_stream_event_stream_data_ind_needskip(a2dp_stream_t *Stream) -{ - int nRet = 0; - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); +int a2dp_ibrt_stream_event_stream_data_ind_needskip(a2dp_stream_t *Stream) { + int nRet = 0; + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); #ifdef __SNIFF_MODE_CHECK__ - if(!sniff_check_timer) - sniff_check_timer = osTimerCreate(osTimer(SNIFF_CHECK_TIMER), osTimerOnce, NULL); + if (!sniff_check_timer) + sniff_check_timer = + osTimerCreate(osTimer(SNIFF_CHECK_TIMER), osTimerOnce, NULL); #endif - if (app_tws_ibrt_mobile_link_connected()){ - if (p_ibrt_ctrl->mobile_mode == IBRT_SNIFF_MODE){ - TRACE(0,"::A2DP_EVENT_STREAM_DATA_IND ibrt_link skip (mobile) skip sniff\n"); - nRet = 1; + if (app_tws_ibrt_mobile_link_connected()) { + if (p_ibrt_ctrl->mobile_mode == IBRT_SNIFF_MODE) { + TRACE( + 0, + "::A2DP_EVENT_STREAM_DATA_IND ibrt_link skip (mobile) skip sniff\n"); + nRet = 1; #ifdef __SNIFF_MODE_CHECK__ - if(sniff_timer_state ==0) - { - sniff_timer_state =1; - osTimerStart(sniff_check_timer,5000); - } -#endif - } -#ifdef __SNIFF_MODE_CHECK__ - else - { - sniff_timer_state= 0; - osTimerStop(sniff_check_timer); - } -#endif - if (app_tws_ibrt_tws_link_connected()){ - if (app_ibrt_ui_is_profile_exchanged() && - p_ibrt_ctrl->tws_mode == IBRT_SNIFF_MODE){ - TRACE(0,"::A2DP_EVENT_STREAM_DATA_IND mobile_link (tws) skip sniff\n"); -#ifndef A2DP_IBRT_STREAM_SKIP_TWS_SNIFF_STATUS - nRet = 1; -#endif -#ifdef __SNIFF_MODE_CHECK__ - if(sniff_timer_state ==0) - { - sniff_timer_state =1; - osTimerStart(sniff_check_timer,5000); - } -#endif - } -#ifdef __SNIFF_MODE_CHECK__ - else - { - sniff_timer_state = 0; - osTimerStop(sniff_check_timer); - } -#endif - } - }else if (app_tws_ibrt_slave_ibrt_link_connected()){ - if (p_ibrt_ctrl->mobile_mode == IBRT_SNIFF_MODE){ - TRACE(0,"::A2DP_EVENT_STREAM_DATA_IND ibrt_link skip (mobile) skip sniff\n"); - nRet = 1; -#ifdef __SNIFF_MODE_CHECK__ - if(sniff_timer_state ==0) - { - sniff_timer_state =1; - osTimerStart(sniff_check_timer,5000); - } -#endif - } -#ifdef __SNIFF_MODE_CHECK__ - else - { - sniff_timer_state = 0; - osTimerStop(sniff_check_timer); - } -#endif - if (p_ibrt_ctrl->tws_mode == IBRT_SNIFF_MODE){ - TRACE(0,"::A2DP_EVENT_STREAM_DATA_IND ibrt_link skip (tws) skip sniff\n"); -#ifndef A2DP_IBRT_STREAM_SKIP_TWS_SNIFF_STATUS - nRet = 1; -#endif -#ifdef __SNIFF_MODE_CHECK__ - if(sniff_timer_state ==0) - { - sniff_timer_state =1; - osTimerStart(sniff_check_timer,5000); - } -#endif - } -#ifdef __SNIFF_MODE_CHECK__ - else - { - sniff_timer_state = 0; - osTimerStop(sniff_check_timer); - } + if (sniff_timer_state == 0) { + sniff_timer_state = 1; + osTimerStart(sniff_check_timer, 5000); + } #endif } - #ifdef __SNIFF_MODE_CHECK__ - if(nRet ==0) - { - sniff_timer_state= 0; + else { + sniff_timer_state = 0; + osTimerStop(sniff_check_timer); + } +#endif + if (app_tws_ibrt_tws_link_connected()) { + if (app_ibrt_ui_is_profile_exchanged() && + p_ibrt_ctrl->tws_mode == IBRT_SNIFF_MODE) { + TRACE(0, "::A2DP_EVENT_STREAM_DATA_IND mobile_link (tws) skip sniff\n"); +#ifndef A2DP_IBRT_STREAM_SKIP_TWS_SNIFF_STATUS + nRet = 1; +#endif +#ifdef __SNIFF_MODE_CHECK__ + if (sniff_timer_state == 0) { + sniff_timer_state = 1; + osTimerStart(sniff_check_timer, 5000); + } +#endif + } +#ifdef __SNIFF_MODE_CHECK__ + else { + sniff_timer_state = 0; osTimerStop(sniff_check_timer); + } +#endif + } + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + if (p_ibrt_ctrl->mobile_mode == IBRT_SNIFF_MODE) { + TRACE( + 0, + "::A2DP_EVENT_STREAM_DATA_IND ibrt_link skip (mobile) skip sniff\n"); + nRet = 1; +#ifdef __SNIFF_MODE_CHECK__ + if (sniff_timer_state == 0) { + sniff_timer_state = 1; + osTimerStart(sniff_check_timer, 5000); + } +#endif + } +#ifdef __SNIFF_MODE_CHECK__ + else { + sniff_timer_state = 0; + osTimerStop(sniff_check_timer); } #endif - return nRet; + if (p_ibrt_ctrl->tws_mode == IBRT_SNIFF_MODE) { + TRACE(0, + "::A2DP_EVENT_STREAM_DATA_IND ibrt_link skip (tws) skip sniff\n"); +#ifndef A2DP_IBRT_STREAM_SKIP_TWS_SNIFF_STATUS + nRet = 1; +#endif +#ifdef __SNIFF_MODE_CHECK__ + if (sniff_timer_state == 0) { + sniff_timer_state = 1; + osTimerStart(sniff_check_timer, 5000); + } +#endif + } +#ifdef __SNIFF_MODE_CHECK__ + else { + sniff_timer_state = 0; + osTimerStop(sniff_check_timer); + } +#endif + } + +#ifdef __SNIFF_MODE_CHECK__ + if (nRet == 0) { + sniff_timer_state = 0; + osTimerStop(sniff_check_timer); + } +#endif + return nRet; } #endif #ifdef __A2DP_AVDTP_CP__ -extern U8 a2dp_avdtpCp_securityData[BT_DEVICE_NUM][BTIF_AVDTP_MAX_CP_VALUE_SIZE]; -extern U8 a2dp_avdtpCp_aac_securityData[BT_DEVICE_NUM][BTIF_AVDTP_MAX_CP_VALUE_SIZE]; +extern U8 a2dp_avdtpCp_securityData[BT_DEVICE_NUM] + [BTIF_AVDTP_MAX_CP_VALUE_SIZE]; +extern U8 a2dp_avdtpCp_aac_securityData[BT_DEVICE_NUM] + [BTIF_AVDTP_MAX_CP_VALUE_SIZE]; #endif /* __A2DP_AVDTP_CP__ */ -uint8_t a2dp_get_current_codec_type(uint8_t *elements) -{ - uint8_t current_codec_type = 0; +uint8_t a2dp_get_current_codec_type(uint8_t *elements) { + uint8_t current_codec_type = 0; - TRACE(4,"INFO element[0]:0x%x, element[1]:0x%x, element[2]:0x%x, element[3]:0x%x", - elements[0], elements[1],elements[2], elements[3]); + TRACE( + 4, + "INFO element[0]:0x%x, element[1]:0x%x, element[2]:0x%x, element[3]:0x%x", + elements[0], elements[1], elements[2], elements[3]); #if defined(A2DP_LHDC_ON) - TRACE(4,"LHDC element[0]:0x%x, element[1]:0x%x, element[2]:0x%x, element[3]:0x%x", - a2dp_codec_lhdc_elements[0], a2dp_codec_lhdc_elements[1], - a2dp_codec_lhdc_elements[2], a2dp_codec_lhdc_elements[3]); - - if (!(strncmp((char*)elements, (char*)&a2dp_codec_lhdc_elements, 4))) - { - TRACE(0,"USE codec type is LHDC"); - current_codec_type = A2DP_NON_CODEC_TYPE_LHDC; - } + TRACE( + 4, + "LHDC element[0]:0x%x, element[1]:0x%x, element[2]:0x%x, element[3]:0x%x", + a2dp_codec_lhdc_elements[0], a2dp_codec_lhdc_elements[1], + a2dp_codec_lhdc_elements[2], a2dp_codec_lhdc_elements[3]); + + if (!(strncmp((char *)elements, (char *)&a2dp_codec_lhdc_elements, 4))) { + TRACE(0, "USE codec type is LHDC"); + current_codec_type = A2DP_NON_CODEC_TYPE_LHDC; + } #endif #if defined(A2DP_LDAC_ON) - TRACE(4,"LDAC element[0]:0x%x, element[1]:0x%x, element[2]:0x%x, element[3]:0x%x", - a2dp_codec_ldac_elements[0], a2dp_codec_ldac_elements[1], - a2dp_codec_ldac_elements[2], a2dp_codec_ldac_elements[3]); - - if (!(strncmp((char*)elements, (char*)&a2dp_codec_ldac_elements, 4))) - { - TRACE(0,"USE codec type is LDAC"); - current_codec_type = A2DP_NON_CODEC_TYPE_LDAC; - } + TRACE( + 4, + "LDAC element[0]:0x%x, element[1]:0x%x, element[2]:0x%x, element[3]:0x%x", + a2dp_codec_ldac_elements[0], a2dp_codec_ldac_elements[1], + a2dp_codec_ldac_elements[2], a2dp_codec_ldac_elements[3]); + + if (!(strncmp((char *)elements, (char *)&a2dp_codec_ldac_elements, 4))) { + TRACE(0, "USE codec type is LDAC"); + current_codec_type = A2DP_NON_CODEC_TYPE_LDAC; + } #endif #if defined(A2DP_SCALABLE_ON) - if (!(strncmp((char*)elements, (char*)&a2dp_codec_scalable_elements, 4))) - { - TRACE(0,"USE codec type is SCALABLE"); - current_codec_type = A2DP_NON_CODEC_TYPE_SCALABLE; - } + if (!(strncmp((char *)elements, (char *)&a2dp_codec_scalable_elements, 4))) { + TRACE(0, "USE codec type is SCALABLE"); + current_codec_type = A2DP_NON_CODEC_TYPE_SCALABLE; + } #endif - current_a2dp_non_type = current_codec_type; + current_a2dp_non_type = current_codec_type; - return current_codec_type; + return current_codec_type; } +extern "C" void a2dp_callback(a2dp_stream_t *Stream, + const a2dp_callback_parms_t *info) { + int header_len = 0; + btif_avdtp_media_header_t header; + uint8_t distinguish_found_id = BT_DEVICE_NUM; + btif_a2dp_callback_parms_t *Info = (btif_a2dp_callback_parms_t *)info; + btif_avdtp_codec_t *codec = NULL; + struct bt_cb_tag *bt_drv_func_cb = bt_drv_get_func_cb_ptr(); -extern "C" void a2dp_callback(a2dp_stream_t *Stream, const a2dp_callback_parms_t *info) -{ - int header_len = 0; - btif_avdtp_media_header_t header; - uint8_t distinguish_found_id = BT_DEVICE_NUM; - btif_a2dp_callback_parms_t * Info = (btif_a2dp_callback_parms_t *)info; - btif_avdtp_codec_t *codec = NULL; - struct bt_cb_tag* bt_drv_func_cb = bt_drv_get_func_cb_ptr(); + static uint8_t detect_first_packet[BT_DEVICE_NUM] = { + 0, + }; - static uint8_t detect_first_packet[BT_DEVICE_NUM] = {0,}; - - uint8_t current_codec_type = 0; + uint8_t current_codec_type = 0; #if defined(__BTIF_BT_RECONNECT__) - static btif_avdtp_codec_t setconfig_codec; - static u8 tmp_element[10]; + static btif_avdtp_codec_t setconfig_codec; + static u8 tmp_element[10]; #endif #ifdef __A2DP_AVDTP_CP__ - static btif_avdtp_content_prot_t setconfig_cp[BT_DEVICE_NUM]; + static btif_avdtp_content_prot_t setconfig_cp[BT_DEVICE_NUM]; #endif #ifdef __BT_ONE_BRING_TWO__ - // !!! not used now - // if (Info->event == BTIF_A2DP_EVENT_STREAM_STATE_CFM) { - // _a2dp_confirm_stream_state(Stream, (a2dp_callback_parms_t *)info); - // return; - // } + // !!! not used now + // if (Info->event == BTIF_A2DP_EVENT_STREAM_STATE_CFM) { + // _a2dp_confirm_stream_state(Stream, (a2dp_callback_parms_t *)info); + // return; + // } - if (Info->event == BTIF_A2DP_EVENT_STREAM_SELECT) { + if (Info->event == BTIF_A2DP_EVENT_STREAM_SELECT) { #if defined(__BT_SELECT_PROF_DEVICE_ID__) - _a2dp_select_stream(Stream, (a2dp_callback_parms_t *)info); + _a2dp_select_stream(Stream, (a2dp_callback_parms_t *)info); #endif - return; - } + return; + } - if(Info->event== BTIF_A2DP_EVENT_STREAM_OPEN){ - // BTIF_A2DP_EVENT_STREAM_OPEN means that the - // AVDTP opened the avdtp media has connected - a2dp_stream_push_connected_stream(Stream); - } + if (Info->event == BTIF_A2DP_EVENT_STREAM_OPEN) { + // BTIF_A2DP_EVENT_STREAM_OPEN means that the + // AVDTP opened the avdtp media has connected + a2dp_stream_push_connected_stream(Stream); + } #if !defined(__BT_SELECT_PROF_DEVICE_ID__) - a2dp_avdtp_stream_state_lock_management(Stream,info); + a2dp_avdtp_stream_state_lock_management(Stream, info); #endif - if (Info->event == BTIF_A2DP_EVENT_STREAM_SELECT) { - return; - } - distinguish_found_id = a2dp_stream_id_distinguish(Stream,Info->event); + if (Info->event == BTIF_A2DP_EVENT_STREAM_SELECT) { + return; + } + distinguish_found_id = a2dp_stream_id_distinguish(Stream, Info->event); #else - stream_id_flag.id = BT_DEVICE_ID_1; - app_bt_device.a2dp_connected_stream[BT_DEVICE_ID_1] = Stream; - distinguish_found_id = BT_DEVICE_ID_1; + stream_id_flag.id = BT_DEVICE_ID_1; + app_bt_device.a2dp_connected_stream[BT_DEVICE_ID_1] = Stream; + distinguish_found_id = BT_DEVICE_ID_1; #endif - codec = btif_a2dp_get_stream_codec( Stream); - if (BTIF_A2DP_EVENT_STREAM_DATA_IND != Info->event) - { - TRACE(1,"Get A2DP event %d", Info->event); - } + codec = btif_a2dp_get_stream_codec(Stream); + if (BTIF_A2DP_EVENT_STREAM_DATA_IND != Info->event) { + TRACE(1, "Get A2DP event %d", Info->event); + } #ifdef __BT_ONE_BRING_TWO__ - enum BT_DEVICE_ID_T anotherDevice = (BT_DEVICE_ID_1 == stream_id_flag.id)?BT_DEVICE_ID_2:BT_DEVICE_ID_1; + enum BT_DEVICE_ID_T anotherDevice = + (BT_DEVICE_ID_1 == stream_id_flag.id) ? BT_DEVICE_ID_2 : BT_DEVICE_ID_1; #endif - switch(Info->event) { - case BTIF_A2DP_EVENT_AVDTP_DISCONNECT: - TRACE(3,"::A2DP_EVENT_AVDTP_DISCONNECT %d st = %p,id %d\n", Info->event, Stream,stream_id_flag.id); - break; - case BTIF_A2DP_EVENT_AVDTP_CONNECT: - TRACE(3,"::A2DP_EVENT_AVDTP_CONNECT %d st = %p id = %d\n", Info->event, Stream,stream_id_flag.id); + switch (Info->event) { + case BTIF_A2DP_EVENT_AVDTP_DISCONNECT: + TRACE(3, "::A2DP_EVENT_AVDTP_DISCONNECT %d st = %p,id %d\n", Info->event, + Stream, stream_id_flag.id); + break; + case BTIF_A2DP_EVENT_AVDTP_CONNECT: + TRACE(3, "::A2DP_EVENT_AVDTP_CONNECT %d st = %p id = %d\n", Info->event, + Stream, stream_id_flag.id); #ifdef BT_USB_AUDIO_DUAL_MODE - if(!btusb_is_bt_mode()) - { - btusb_btaudio_close(false); - } + if (!btusb_is_bt_mode()) { + btusb_btaudio_close(false); + } #endif - break; - case BTIF_A2DP_EVENT_STREAM_OPEN: - TRACE(2,"::A2DP_EVENT_STREAM_OPEN dev_id %x, stream_id:%d, sample_rate codec.elements 0x%x\n", distinguish_found_id,stream_id_flag.id,Info->p.configReq->codec.elements[0]); + break; + case BTIF_A2DP_EVENT_STREAM_OPEN: + TRACE(2, + "::A2DP_EVENT_STREAM_OPEN dev_id %x, stream_id:%d, sample_rate " + "codec.elements 0x%x\n", + distinguish_found_id, stream_id_flag.id, + Info->p.configReq->codec.elements[0]); - //update bt_profile_manager[deviceId].stream - app_bt_set_mobile_a2dp_stream(distinguish_found_id,Stream); + // update bt_profile_manager[deviceId].stream + app_bt_set_mobile_a2dp_stream(distinguish_found_id, Stream); - #ifdef __BT_ONE_BRING_TWO__ - app_bt_device.latestPausedDevId = anotherDevice; - #else - app_bt_device.latestPausedDevId = BT_DEVICE_ID_1; - #endif +#ifdef __BT_ONE_BRING_TWO__ + app_bt_device.latestPausedDevId = anotherDevice; +#else + app_bt_device.latestPausedDevId = BT_DEVICE_ID_1; +#endif - #ifdef GFPS_ENABLED - app_exit_fastpairing_mode(); - #endif +#ifdef GFPS_ENABLED + app_exit_fastpairing_mode(); +#endif - app_bt_clear_connecting_profiles_state(stream_id_flag.id); + app_bt_clear_connecting_profiles_state(stream_id_flag.id); - #ifdef __BT_ONE_BRING_TWO__ - a2dp_to_bond_avrcp_with_stream(Stream, stream_id_flag.id); - #endif +#ifdef __BT_ONE_BRING_TWO__ + a2dp_to_bond_avrcp_with_stream(Stream, stream_id_flag.id); +#endif #if defined(__BTMAP_ENABLE__) #ifdef BTIF_DIP_DEVICE - if ((btif_dip_get_process_status(btif_a2dp_get_stream_conn_remDev(Stream)))&& (app_btmap_check_is_idle(stream_id_flag.id))) + if ((btif_dip_get_process_status( + btif_a2dp_get_stream_conn_remDev(Stream))) && + (app_btmap_check_is_idle(stream_id_flag.id))) #endif - { - app_btmap_sms_open(stream_id_flag.id, btif_me_get_remote_device_bdaddr(btif_a2dp_get_stream_conn_remDev(Stream))); - } + { + app_btmap_sms_open(stream_id_flag.id, + btif_me_get_remote_device_bdaddr( + btif_a2dp_get_stream_conn_remDev(Stream))); + } #endif #ifdef __A2DP_AVDTP_CP__ - //btif_a2dp_security_control_req(Stream,(uint8_t *)&a2dp_avdtpCp_securityData[stream_id_flag.id][0],1); + // btif_a2dp_security_control_req(Stream,(uint8_t + // *)&a2dp_avdtpCp_securityData[stream_id_flag.id][0],1); #endif - a2dp_timestamp_parser_init(); - app_bt_stream_volume_ptr_update((uint8_t *) btif_me_get_remote_device_bdaddr(btif_a2dp_get_stream_conn_remDev(Stream))); -// app_bt_stream_a2dpvolume_reset(); + a2dp_timestamp_parser_init(); + app_bt_stream_volume_ptr_update((uint8_t *)btif_me_get_remote_device_bdaddr( + btif_a2dp_get_stream_conn_remDev(Stream))); + // app_bt_stream_a2dpvolume_reset(); - current_codec_type = a2dp_get_current_codec_type(Info->p.configReq->codec.elements); + current_codec_type = + a2dp_get_current_codec_type(Info->p.configReq->codec.elements); - TRACE(2, "codecType 0x%x, current_codec_type %d \n", Info->p.configReq->codec.codecType, current_codec_type); + TRACE(2, "codecType 0x%x, current_codec_type %d \n", + Info->p.configReq->codec.codecType, current_codec_type); #if defined(A2DP_AAC_ON) - if (Info->p.configReq->codec.codecType == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { - TRACE(2,"::A2DP_EVENT_STREAM_OPEN stream_id:%d, aac sample_rate codec.elements 0x%x\n", stream_id_flag.id,Info->p.configReq->codec.elements[1]); - app_bt_device.codec_type[stream_id_flag.id] = BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC; - app_bt_device.sample_bit[stream_id_flag.id] = 16; - // convert aac sample_rate to sbc sample_rate format - if (Info->p.configReq->codec.elements[1] & A2DP_AAC_OCTET1_SAMPLING_FREQUENCY_44100) { - TRACE(1,"::A2DP_EVENT_STREAM_OPEN stream_id:%d, aac sample_rate 44100\n", stream_id_flag.id); - app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_44; - } - else if (Info->p.configReq->codec.elements[2] & A2DP_AAC_OCTET2_SAMPLING_FREQUENCY_48000) { - TRACE(1,"::A2DP_EVENT_STREAM_OPEN stream_id:%d, aac sample_rate 48000\n", stream_id_flag.id); - app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_48; - } - else { - TRACE(1,"::A2DP_EVENT_STREAM_OPEN stream_id:%d, aac sample_rate not 48000 or 44100, set to 44100\n", stream_id_flag.id); - app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_44; - } + if (Info->p.configReq->codec.codecType == + BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { + TRACE(2, + "::A2DP_EVENT_STREAM_OPEN stream_id:%d, aac sample_rate " + "codec.elements 0x%x\n", + stream_id_flag.id, Info->p.configReq->codec.elements[1]); + app_bt_device.codec_type[stream_id_flag.id] = + BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC; + app_bt_device.sample_bit[stream_id_flag.id] = 16; + // convert aac sample_rate to sbc sample_rate format + if (Info->p.configReq->codec.elements[1] & + A2DP_AAC_OCTET1_SAMPLING_FREQUENCY_44100) { + TRACE(1, + "::A2DP_EVENT_STREAM_OPEN stream_id:%d, aac sample_rate 44100\n", + stream_id_flag.id); + app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_44; + } else if (Info->p.configReq->codec.elements[2] & + A2DP_AAC_OCTET2_SAMPLING_FREQUENCY_48000) { + TRACE(1, + "::A2DP_EVENT_STREAM_OPEN stream_id:%d, aac sample_rate 48000\n", + stream_id_flag.id); + app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_48; + } else { + TRACE(1, + "::A2DP_EVENT_STREAM_OPEN stream_id:%d, aac sample_rate not " + "48000 or 44100, set to 44100\n", + stream_id_flag.id); + app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_44; + } - if (Info->p.configReq->codec.elements[2] & A2DP_AAC_OCTET2_CHANNELS_1){ - a2dp_channel_num[stream_id_flag.id] = 1; - }else{ - a2dp_channel_num[stream_id_flag.id] = 2; - } - }else + if (Info->p.configReq->codec.elements[2] & A2DP_AAC_OCTET2_CHANNELS_1) { + a2dp_channel_num[stream_id_flag.id] = 1; + } else { + a2dp_channel_num[stream_id_flag.id] = 2; + } + } else #endif - if (Info->p.configReq->codec.codecType == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - { + if (Info->p.configReq->codec.codecType == + BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { #if defined(A2DP_LHDC_ON) - if (current_codec_type == A2DP_NON_CODEC_TYPE_LHDC) - { - TRACE(2,"##codecType: LHDC Codec, Element length = %d, AVDTP_MAX_CODEC_ELEM_SIZE = %d\n", Info->p.configReq->codec.elemLen, BTIF_AVDTP_MAX_CODEC_ELEM_SIZE); - app_bt_device.codec_type[stream_id_flag.id] = BTIF_AVDTP_CODEC_TYPE_NON_A2DP; - a2dp_lhdc_config(&(Info->p.configReq->codec.elements[0])); - } + if (current_codec_type == A2DP_NON_CODEC_TYPE_LHDC) { + TRACE(2, + "##codecType: LHDC Codec, Element length = %d, " + "AVDTP_MAX_CODEC_ELEM_SIZE = %d\n", + Info->p.configReq->codec.elemLen, BTIF_AVDTP_MAX_CODEC_ELEM_SIZE); + app_bt_device.codec_type[stream_id_flag.id] = + BTIF_AVDTP_CODEC_TYPE_NON_A2DP; + a2dp_lhdc_config(&(Info->p.configReq->codec.elements[0])); + } #endif #if defined(A2DP_SCALABLE_ON) - if (current_codec_type == A2DP_NON_CODEC_TYPE_SCALABLE) - { - TRACE(0,"##codecType scalable\n"); - a2dp_scalable_config(&(Info->p.configReq->codec.elements[0])); - app_bt_device.codec_type[stream_id_flag.id] = BTIF_AVDTP_CODEC_TYPE_NON_A2DP; - //0x75 0x00 0x00 0x00Vid - //0x03 0x01 Codec id - if(Info->p.codec->elements[0]==0x75&& - Info->p.codec->elements[4]==0x03&& - Info->p.codec->elements[5]==0x01 - ){ - setconfig_codec.elements = a2dp_scalable_avdtpcodec.elements; - } - else{ - if(Info->p.codec->pstreamflags!=NULL) - Info->p.codec->pstreamflags[0] &= ~APP_A2DP_STRM_FLAG_QUERY_CODEC; - else{ - ASSERT(false, "pstreamflags not init .."); - } + if (current_codec_type == A2DP_NON_CODEC_TYPE_SCALABLE) { + TRACE(0, "##codecType scalable\n"); + a2dp_scalable_config(&(Info->p.configReq->codec.elements[0])); + app_bt_device.codec_type[stream_id_flag.id] = + BTIF_AVDTP_CODEC_TYPE_NON_A2DP; + // 0x75 0x00 0x00 0x00Vid + // 0x03 0x01 Codec id + if (Info->p.codec->elements[0] == 0x75 && + Info->p.codec->elements[4] == 0x03 && + Info->p.codec->elements[5] == 0x01) { + setconfig_codec.elements = a2dp_scalable_avdtpcodec.elements; + } else { + if (Info->p.codec->pstreamflags != NULL) + Info->p.codec->pstreamflags[0] &= ~APP_A2DP_STRM_FLAG_QUERY_CODEC; + else { + ASSERT(false, "pstreamflags not init .."); + } - a2dp_channel_num[stream_id_flag.id] = 2; - } - - } + a2dp_channel_num[stream_id_flag.id] = 2; + } + } #endif #if defined(A2DP_LDAC_ON) - if (current_codec_type == A2DP_NON_CODEC_TYPE_LDAC) - { - TRACE(2,"##codecType: LDAC Codec, Element length = %d, AVDTP_MAX_CODEC_ELEM_SIZE = %d\n", Info->p.configReq->codec.elemLen, BTIF_AVDTP_MAX_CODEC_ELEM_SIZE); - app_bt_device.codec_type[stream_id_flag.id] = BTIF_AVDTP_CODEC_TYPE_NON_A2DP; - // - //Codec Info Element: 0x 2d 01 00 00 aa 00 34 07 - // - if(Info->p.codec->elements[0]==0x2d){ - app_bt_device.sample_bit[stream_id_flag.id] = 16; - a2dp_ldac_config(&(Info->p.configReq->codec.elements[0])); + if (current_codec_type == A2DP_NON_CODEC_TYPE_LDAC) { + TRACE(2, + "##codecType: LDAC Codec, Element length = %d, " + "AVDTP_MAX_CODEC_ELEM_SIZE = %d\n", + Info->p.configReq->codec.elemLen, BTIF_AVDTP_MAX_CODEC_ELEM_SIZE); + app_bt_device.codec_type[stream_id_flag.id] = + BTIF_AVDTP_CODEC_TYPE_NON_A2DP; + // + // Codec Info Element: 0x 2d 01 00 00 aa 00 34 07 + // + if (Info->p.codec->elements[0] == 0x2d) { + app_bt_device.sample_bit[stream_id_flag.id] = 16; + a2dp_ldac_config(&(Info->p.configReq->codec.elements[0])); - } - else{ - if(Info->p.codec->pstreamflags!=NULL) - Info->p.codec->pstreamflags[0] &= ~APP_A2DP_STRM_FLAG_QUERY_CODEC; - else{ - ASSERT(false, "pstreamflags not init .."); - } + } else { + if (Info->p.codec->pstreamflags != NULL) + Info->p.codec->pstreamflags[0] &= ~APP_A2DP_STRM_FLAG_QUERY_CODEC; + else { + ASSERT(false, "pstreamflags not init .."); + } - a2dp_channel_num[stream_id_flag.id] = 2; - } - - } + a2dp_channel_num[stream_id_flag.id] = 2; + } + } #endif - } - else - { - TRACE(5,"app_bt_device.sample_rate::elements[0] %d BITPOOL:%d/%d %02x/%02x\n", Info->p.codec->elements[0], - Info->p.codec->elements[2], - Info->p.codec->elements[3], - Info->p.codec->elements[2], - Info->p.codec->elements[3]); + } else { + TRACE( + 5, + "app_bt_device.sample_rate::elements[0] %d BITPOOL:%d/%d %02x/%02x\n", + Info->p.codec->elements[0], Info->p.codec->elements[2], + Info->p.codec->elements[3], Info->p.codec->elements[2], + Info->p.codec->elements[3]); - app_bt_device.codec_type[stream_id_flag.id] = BTIF_AVDTP_CODEC_TYPE_SBC; - app_bt_device.sample_bit[stream_id_flag.id] = 16; - app_bt_device.sample_rate[stream_id_flag.id] = (Info->p.configReq->codec.elements[0] & A2D_SBC_IE_SAMP_FREQ_MSK); + app_bt_device.codec_type[stream_id_flag.id] = BTIF_AVDTP_CODEC_TYPE_SBC; + app_bt_device.sample_bit[stream_id_flag.id] = 16; + app_bt_device.sample_rate[stream_id_flag.id] = + (Info->p.configReq->codec.elements[0] & A2D_SBC_IE_SAMP_FREQ_MSK); - if(Info->p.configReq->codec.elements[0] & A2D_SBC_IE_CH_MD_MONO) - a2dp_channel_num[stream_id_flag.id] = 1; - else - a2dp_channel_num[stream_id_flag.id] = 2; + if (Info->p.configReq->codec.elements[0] & A2D_SBC_IE_CH_MD_MONO) + a2dp_channel_num[stream_id_flag.id] = 1; + else + a2dp_channel_num[stream_id_flag.id] = 2; + } + app_bt_device.a2dp_state[stream_id_flag.id] = 1; - } - app_bt_device.a2dp_state[stream_id_flag.id] = 1; - - if (btif_a2dp_is_stream_device_has_delay_reporting(Stream)) - { - btif_a2dp_set_sink_delay(Stream, 150); - } -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) - if(app_bt_device.src_or_snk==BT_DEVICE_SRC) - { - if((Info->p.configReq->codec.elements[1] & A2D_SBC_IE_SUBBAND_MSK) == A2D_SBC_IE_SUBBAND_4) - TRACE(0,"numSubBands is only support 8!"); - //a2dp_source.sample_rate = bt_parse_sbc_sample_rate(btif_a2dp_get_stream_codec_element(Stream,0)); - a2dp_source.sample_rate = bt_parse_sbc_sample_rate(A2D_SBC_IE_SAMP_FREQ_44); - //TRACE(0,"::AVRCP_Connect\n", __LINE__); - //AVRCP_Connect(&app_bt_device.avrcp_channel[stream_id_flag.id], &Stream->stream.conn.remDev->bdAddr); - } - else - { - // reset connect counter - app_avrcp_connect_try_times[stream_id_flag.id] = 0; - btif_avrcp_connect(app_bt_device.avrcp_channel[stream_id_flag.id], btif_me_get_remote_device_bdaddr(btif_a2dp_get_stream_conn_remDev(Stream))); - } + if (btif_a2dp_is_stream_device_has_delay_reporting(Stream)) { + btif_a2dp_set_sink_delay(Stream, 150); + } +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) + if (app_bt_device.src_or_snk == BT_DEVICE_SRC) { + if ((Info->p.configReq->codec.elements[1] & A2D_SBC_IE_SUBBAND_MSK) == + A2D_SBC_IE_SUBBAND_4) + TRACE(0, "numSubBands is only support 8!"); + // a2dp_source.sample_rate = + // bt_parse_sbc_sample_rate(btif_a2dp_get_stream_codec_element(Stream,0)); + a2dp_source.sample_rate = + bt_parse_sbc_sample_rate(A2D_SBC_IE_SAMP_FREQ_44); + // TRACE(0,"::AVRCP_Connect\n", __LINE__); + // AVRCP_Connect(&app_bt_device.avrcp_channel[stream_id_flag.id], + // &Stream->stream.conn.remDev->bdAddr); + } else { + // reset connect counter + app_avrcp_connect_try_times[stream_id_flag.id] = 0; + btif_avrcp_connect(app_bt_device.avrcp_channel[stream_id_flag.id], + btif_me_get_remote_device_bdaddr( + btif_a2dp_get_stream_conn_remDev(Stream))); + } #else - // reset connect counter - app_avrcp_connect_try_times[stream_id_flag.id] = 0; - btif_avrcp_connect(app_bt_device.avrcp_channel[stream_id_flag.id], btif_me_get_remote_device_bdaddr(btif_a2dp_get_stream_conn_remDev(Stream))); + // reset connect counter + app_avrcp_connect_try_times[stream_id_flag.id] = 0; + btif_avrcp_connect(app_bt_device.avrcp_channel[stream_id_flag.id], + btif_me_get_remote_device_bdaddr( + btif_a2dp_get_stream_conn_remDev(Stream))); #endif - app_bt_profile_connect_manager_a2dp(stream_id_flag.id, Stream, (a2dp_callback_parms_t *)Info); + app_bt_profile_connect_manager_a2dp(stream_id_flag.id, Stream, + (a2dp_callback_parms_t *)Info); #ifdef __BT_ONE_BRING_TWO__ - if(app_bt_device.a2dp_connected_stream[anotherDevice] && - (btif_a2dp_get_stream_state( app_bt_device.a2dp_connected_stream[anotherDevice]) != BTIF_AVDTP_STRM_STATE_STREAMING)) - { - a2dp_set_cur_stream(stream_id_flag.id); - }else if(!app_bt_device.a2dp_connected_stream[anotherDevice]){ - a2dp_set_cur_stream(stream_id_flag.id); - } + if (app_bt_device.a2dp_connected_stream[anotherDevice] && + (btif_a2dp_get_stream_state( + app_bt_device.a2dp_connected_stream[anotherDevice]) != + BTIF_AVDTP_STRM_STATE_STREAMING)) { + a2dp_set_cur_stream(stream_id_flag.id); + } else if (!app_bt_device.a2dp_connected_stream[anotherDevice]) { + a2dp_set_cur_stream(stream_id_flag.id); + } #else - a2dp_set_cur_stream(stream_id_flag.id); + a2dp_set_cur_stream(stream_id_flag.id); #endif #ifdef __BT_ONE_BRING_TWO__ - a2dp_dual_slave_handling_refresh(); + a2dp_dual_slave_handling_refresh(); #endif #if defined(IBRT) - a2dp_ibrt_session_reset(); + a2dp_ibrt_session_reset(); #endif - break; - case BTIF_A2DP_EVENT_STREAM_OPEN_IND: - TRACE(1,"::A2DP_EVENT_STREAM_OPEN_IND %d\n", Info->event); - btif_a2dp_open_stream_rsp(Stream, BTIF_A2DP_ERR_NO_ERROR, BTIF_AVDTP_SRV_CAT_MEDIA_TRANSPORT); + break; + case BTIF_A2DP_EVENT_STREAM_OPEN_IND: + TRACE(1, "::A2DP_EVENT_STREAM_OPEN_IND %d\n", Info->event); + btif_a2dp_open_stream_rsp(Stream, BTIF_A2DP_ERR_NO_ERROR, + BTIF_AVDTP_SRV_CAT_MEDIA_TRANSPORT); #ifdef __A2DP_AVDTP_CP__ - if(Info->p.configReq->cp.cpType==BTIF_AVDTP_CP_TYPE_SCMS_T) - { - app_bt_device.avdtp_cp[stream_id_flag.id] = 1; - } + if (Info->p.configReq->cp.cpType == BTIF_AVDTP_CP_TYPE_SCMS_T) { + app_bt_device.avdtp_cp[stream_id_flag.id] = 1; + } #endif - break; - case BTIF_A2DP_EVENT_STREAM_STARTED: + break; + case BTIF_A2DP_EVENT_STREAM_STARTED: #if defined(IBRT) - a2dp_ibrt_session_new(); - case BTIF_A2DP_EVENT_STREAM_STARTED_MOCK: - app_ibrt_if_sniff_checker_start(APP_IBRT_IF_SNIFF_CHECKER_USER_A2DP); - { - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - bt_drv_reg_op_set_agc_thd(p_ibrt_ctrl->current_role == IBRT_MASTER,false); - } + a2dp_ibrt_session_new(); + case BTIF_A2DP_EVENT_STREAM_STARTED_MOCK: + app_ibrt_if_sniff_checker_start(APP_IBRT_IF_SNIFF_CHECKER_USER_A2DP); + { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + bt_drv_reg_op_set_agc_thd(p_ibrt_ctrl->current_role == IBRT_MASTER, + false); + } #endif - if(bt_drv_func_cb->bt_switch_agc != NULL) - { - bt_drv_func_cb->bt_switch_agc(BT_A2DP_WORK_MODE); - } + if (bt_drv_func_cb->bt_switch_agc != NULL) { + bt_drv_func_cb->bt_switch_agc(BT_A2DP_WORK_MODE); + } #if defined(_AUTO_TEST_) - AUTO_TEST_SEND("Music on ok."); + AUTO_TEST_SEND("Music on ok."); #endif - if (btif_a2dp_is_stream_device_has_delay_reporting(Stream)) - { - btif_a2dp_set_sink_delay(Stream, 150); - } + if (btif_a2dp_is_stream_device_has_delay_reporting(Stream)) { + btif_a2dp_set_sink_delay(Stream, 150); + } #if !defined(IBRT) - app_bt_active_mode_set(ACTIVE_MODE_KEEPER_A2DP_STREAMING, stream_id_flag.id); + app_bt_active_mode_set(ACTIVE_MODE_KEEPER_A2DP_STREAMING, + stream_id_flag.id); #endif - a2dp_timestamp_parser_init(); - app_bt_device.a2dp_streamming[stream_id_flag.id] = 1; - detect_first_packet[stream_id_flag.id] = 1; + a2dp_timestamp_parser_init(); + app_bt_device.a2dp_streamming[stream_id_flag.id] = 1; + detect_first_packet[stream_id_flag.id] = 1; #ifdef __BT_ONE_BRING_TWO__ - if (app_bt_is_device_connected(anotherDevice)) - { - app_bt_active_mode_set(ACTIVE_MODE_KEEPER_A2DP_STREAMING, anotherDevice); - } + if (app_bt_is_device_connected(anotherDevice)) { + app_bt_active_mode_set(ACTIVE_MODE_KEEPER_A2DP_STREAMING, anotherDevice); + } - TRACE(5,"::BTIF_A2DP_EVENT_STREAM_STARTED_MOCK %d stream_id:%d %d %d %d\n", - codec->codecType, - stream_id_flag.id, - app_bt_device.curr_a2dp_stream_id, - app_bt_device.a2dp_streamming[0], - app_bt_device.a2dp_streamming[1]); + TRACE( + 5, "::BTIF_A2DP_EVENT_STREAM_STARTED_MOCK %d stream_id:%d %d %d %d\n", + codec->codecType, stream_id_flag.id, app_bt_device.curr_a2dp_stream_id, + app_bt_device.a2dp_streamming[0], app_bt_device.a2dp_streamming[1]); - TRACE(1,"playback = %d",app_bt_device.a2dp_play_pause_flag); - if(app_bt_device.a2dp_connected_stream[anotherDevice] && - (btif_a2dp_get_stream_state (app_bt_device.a2dp_connected_stream[anotherDevice]) != BTIF_AVDTP_STRM_STATE_STREAMING)){ - a2dp_set_cur_stream(stream_id_flag.id); - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START,BT_STREAM_SBC,stream_id_flag.id,MAX_RECORD_NUM); - app_a2dp_unhold_mute(); - }else if(!app_bt_device.a2dp_connected_stream[anotherDevice]){ - a2dp_set_cur_stream(stream_id_flag.id); - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START,BT_STREAM_SBC,stream_id_flag.id,MAX_RECORD_NUM); - app_a2dp_unhold_mute(); - } + TRACE(1, "playback = %d", app_bt_device.a2dp_play_pause_flag); + if (app_bt_device.a2dp_connected_stream[anotherDevice] && + (btif_a2dp_get_stream_state( + app_bt_device.a2dp_connected_stream[anotherDevice]) != + BTIF_AVDTP_STRM_STATE_STREAMING)) { + a2dp_set_cur_stream(stream_id_flag.id); + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, BT_STREAM_SBC, + stream_id_flag.id, MAX_RECORD_NUM); + app_a2dp_unhold_mute(); + } else if (!app_bt_device.a2dp_connected_stream[anotherDevice]) { + a2dp_set_cur_stream(stream_id_flag.id); + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, BT_STREAM_SBC, + stream_id_flag.id, MAX_RECORD_NUM); + app_a2dp_unhold_mute(); + } #else // #ifndef __BT_ONE_BRING_TWO__ - TRACE(4,"::A2DP_EVENT_STREAM_STARTED %d stream_id:%d %d %d\n", - codec->codecType, - stream_id_flag.id, - app_bt_device.curr_a2dp_stream_id, - app_bt_device.a2dp_streamming[0]); + TRACE(4, "::A2DP_EVENT_STREAM_STARTED %d stream_id:%d %d %d\n", + codec->codecType, stream_id_flag.id, + app_bt_device.curr_a2dp_stream_id, app_bt_device.a2dp_streamming[0]); - a2dp_set_cur_stream(BT_DEVICE_ID_1); + a2dp_set_cur_stream(BT_DEVICE_ID_1); #if (A2DP_DECODER_VER == 2) #if defined(IBRT) - if (Info->event == BTIF_A2DP_EVENT_STREAM_STARTED) - { - a2dp_audio_latency_factor_setlow(); - } + if (Info->event == BTIF_A2DP_EVENT_STREAM_STARTED) { + a2dp_audio_latency_factor_setlow(); + } #else - a2dp_audio_latency_factor_setlow(); + a2dp_audio_latency_factor_setlow(); #endif #endif #if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) - if (app_bt_device.src_or_snk == BT_DEVICE_SNK) - { - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, BT_STREAM_SBC, stream_id_flag.id, MAX_RECORD_NUM); - } - else - { - TRACE(0,"::APP_A2DP_SOURCE START \n"); + if (app_bt_device.src_or_snk == BT_DEVICE_SNK) { + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, BT_STREAM_SBC, + stream_id_flag.id, MAX_RECORD_NUM); + } else { + TRACE(0, "::APP_A2DP_SOURCE START \n"); #if defined(APP_LINEIN_A2DP_SOURCE) - app_audio_sendrequest(APP_A2DP_SOURCE_LINEIN_AUDIO, ( uint8_t )APP_BT_SETTING_OPEN, 0); + app_audio_sendrequest(APP_A2DP_SOURCE_LINEIN_AUDIO, + (uint8_t)APP_BT_SETTING_OPEN, 0); #else - app_audio_sendrequest(APP_A2DP_SOURCE_I2S_AUDIO, ( uint8_t )APP_BT_SETTING_OPEN, 0); + app_audio_sendrequest(APP_A2DP_SOURCE_I2S_AUDIO, + (uint8_t)APP_BT_SETTING_OPEN, 0); #endif - app_bt_device.input_onoff = 1; - } -#else // #if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, BT_STREAM_SBC, stream_id_flag.id, MAX_RECORD_NUM); + app_bt_device.input_onoff = 1; + } +#else // #if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, BT_STREAM_SBC, + stream_id_flag.id, MAX_RECORD_NUM); #endif // #if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) #endif // #ifdef __BT_ONE_BRING_TWO__ #ifdef __BT_ONE_BRING_TWO__ - if (btapp_hfp_is_dev_sco_connected(anotherDevice)) - { - a2dp_dual_slave_setup_during_sco(anotherDevice); - } - else - { - a2dp_dual_slave_handling_refresh(); - } -#endif - -#ifdef __IAG_BLE_INCLUDE__ - app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_A2DP_ON, true); -#endif - break; - case BTIF_A2DP_EVENT_STREAM_START_IND: -#ifdef __BT_ONE_BRING_TWO__ - TRACE(5,"::A2DP_EVENT_STREAM_START_IND %d stream_id:%d %d %d %d\n", codec->codecType, stream_id_flag.id, app_bt_device.curr_a2dp_stream_id, - app_bt_device.a2dp_streamming[0], app_bt_device.a2dp_streamming[1]); -#else - TRACE(4,"::A2DP_EVENT_STREAM_START_IND %d stream_id:%d %d %d\n",codec->codecType, stream_id_flag.id, app_bt_device.curr_a2dp_stream_id, - app_bt_device.a2dp_streamming[0]); -#endif - { -#ifdef BT_USB_AUDIO_DUAL_MODE - if(!btusb_is_bt_mode()) - { - btif_a2dp_start_stream_rsp(Stream, BTIF_A2DP_ERR_INSUFFICIENT_RESOURCE); - } - else -#endif - { - btif_a2dp_start_stream_rsp(Stream, BTIF_A2DP_ERR_NO_ERROR); - app_bt_device.a2dp_play_pause_flag = 1; - } - } - break; - case BTIF_A2DP_EVENT_STREAM_IDLE: - TRACE(0,"BTIF_A2DP_EVENT_STREAM_IDLE"); - case BTIF_A2DP_EVENT_STREAM_SUSPENDED: -#if defined(IBRT) - app_ibrt_if_sniff_checker_stop(APP_IBRT_IF_SNIFF_CHECKER_USER_A2DP); -#endif - if(bt_drv_func_cb->bt_switch_agc != NULL) - { - bt_drv_func_cb->bt_switch_agc(BT_IDLE_MODE); - } - -#ifdef __BT_ONE_BRING_TWO__ - TRACE(5,"::A2DP_EVENT_STREAM_SUSPENDED %d stream_id:%d %d %d %d\n",codec->codecType, stream_id_flag.id, app_bt_device.curr_a2dp_stream_id, - app_bt_device.a2dp_streamming[0], app_bt_device.a2dp_streamming[1]); -#else - TRACE(4,"::A2DP_EVENT_STREAM_SUSPENDED %d stream_id:%d %d %d\n",codec->codecType, stream_id_flag.id, app_bt_device.curr_a2dp_stream_id, - app_bt_device.a2dp_streamming[0]); -#endif - a2dp_timestamp_parser_init(); - app_bt_device.a2dp_streamming[stream_id_flag.id] = 0; -#if defined(_AUTO_TEST_) - AUTO_TEST_SEND("Music suspend ok."); -#endif - app_bt_active_mode_clear(ACTIVE_MODE_KEEPER_A2DP_STREAMING, stream_id_flag.id); - -#ifdef __BT_ONE_BRING_TWO__ - if (app_bt_is_device_connected(anotherDevice) && - (!app_bt_device.a2dp_streamming[anotherDevice]) && - (BTIF_HF_CALL_ACTIVE != app_bt_device.hfchan_call[anotherDevice])) - { - app_bt_active_mode_clear(ACTIVE_MODE_KEEPER_A2DP_STREAMING, anotherDevice); - } - - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP,BT_STREAM_SBC,stream_id_flag.id,0); - if((app_bt_device.a2dp_connected_stream[anotherDevice]) && - (btif_a2dp_get_stream_state(app_bt_device.a2dp_connected_stream[anotherDevice]) == BTIF_AVDTP_STRM_STATE_STREAMING)){ - if(bt_media_is_media_active_by_device(BT_STREAM_SBC,anotherDevice) == 1){ - a2dp_set_cur_stream(anotherDevice); - app_bt_device.a2dp_play_pause_flag = 1; - }else{ - a2dp_set_cur_stream(anotherDevice); - app_bt_device.a2dp_play_pause_flag = 1; - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START,BT_STREAM_SBC,anotherDevice,0); - } - }else{ - app_bt_device.a2dp_play_pause_flag = 0; - app_a2dp_hold_mute(); - } -#else - -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) - if(app_bt_device.src_or_snk==BT_DEVICE_SNK) - { - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP,BT_STREAM_SBC,BT_DEVICE_ID_1,MAX_RECORD_NUM); - } - else - { - TRACE(0,"::APP_A2DP_SOURCE SUSPEND \n"); -#if defined(APP_LINEIN_A2DP_SOURCE) - app_audio_sendrequest(APP_A2DP_SOURCE_LINEIN_AUDIO, (uint8_t)APP_BT_SETTING_CLOSE,0); -#else - app_audio_sendrequest(APP_A2DP_SOURCE_I2S_AUDIO, (uint8_t)APP_BT_SETTING_CLOSE,0); -#endif - app_bt_device.input_onoff=0; - } -#else - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP,BT_STREAM_SBC,BT_DEVICE_ID_1,MAX_RECORD_NUM); -#endif - app_bt_device.a2dp_play_pause_flag = 0; -#endif - -#ifdef __BT_ONE_BRING_TWO__ - if (btapp_hfp_is_dev_sco_connected(anotherDevice)) - { - a2dp_dual_slave_setup_during_sco(anotherDevice); - } - else - { - a2dp_dual_slave_handling_refresh(); - } -#endif - -#ifdef __IAG_BLE_INCLUDE__ - app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_A2DP_ON, false); -#endif - - break; - case BTIF_A2DP_EVENT_STREAM_DATA_IND: -#ifdef __AI_VOICE__ - if(app_ai_is_to_mute_a2dp_during_ai_starting_speech()) { - //TRACE(0,"app_ai_is_to_mute_a2dp_during_ai_starting_speech"); - break; - } -#endif -#if defined(IBRT) - if (a2dp_ibrt_stream_event_stream_data_ind_needskip(Stream)){ - header_len = btif_avdtp_parse_mediaHeader(&header, (btif_a2dp_callback_parms_t *)Info,0); - TRACE(2,"::A2DP_EVENT_STREAM_DATA_IND skip seq:%d timestamp:%d\n", header.sequenceNumber, header.timestamp); - break; - } -#else - if (btif_me_get_current_mode(btif_a2dp_get_remote_device(Stream)) == BTIF_BLM_SNIFF_MODE){ - TRACE(0,"::A2DP_EVENT_STREAM_DATA_IND skip\n"); - break; - } -#endif - if (detect_first_packet[stream_id_flag.id]){ - detect_first_packet[stream_id_flag.id] = 0; - avrcp_get_current_media_status(stream_id_flag.id); - } - -#ifdef __BT_ONE_BRING_TWO__ - ////play music of curr_a2dp_stream_id - if(app_bt_device.curr_a2dp_stream_id == stream_id_flag.id && - app_bt_device.hf_audio_state[stream_id_flag.id]==BTIF_HF_AUDIO_DISCON && - app_bt_device.hf_audio_state[anotherDevice]==BTIF_HF_AUDIO_DISCON && - app_bt_device.hfchan_callSetup[anotherDevice] == BTIF_HF_CALL_SETUP_NONE){ -#ifdef __A2DP_AVDTP_CP__ //zadd bug fixed sony Z5 no sound - header_len = btif_avdtp_parse_mediaHeader(&header, (btif_a2dp_callback_parms_t *)Info,app_bt_device.avdtp_cp[stream_id_flag.id]); -#else - header_len = btif_avdtp_parse_mediaHeader(&header,(btif_a2dp_callback_parms_t *) Info,0); -#endif - if (app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC) && (btif_a2dp_get_stream_state(Stream) == BTIF_AVDTP_STRM_STATE_STREAMING)){ -#ifdef __A2DP_TIMESTAMP_PARSER__ - if (a2dp_timestamp_parser_run(header.timestamp,(*(((unsigned char *)Info->p.data) + header_len)))){ - TRACE(0,"::A2DP_EVENT_STREAM_DATA_IND skip frame\n"); - }else -#endif - { -#if (A2DP_DECODER_VER >= 2) - a2dp_audio_store_packet(&header, ((unsigned char *)Info->p.data) + header_len , Info->len - header_len); -#else - a2dp_audio_sbc_set_frame_info(Info->len - header_len - 1, (*(((unsigned char *)Info->p.data) + header_len))); -#if defined(A2DP_LHDC_ON) - if (app_bt_device.codec_type[stream_id_flag.id] == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { - store_sbc_buffer(((unsigned char *)Info->p.data) + header_len , Info->len - header_len); - } - else -#endif -#if defined(A2DP_AAC_ON) - if (app_bt_device.codec_type[stream_id_flag.id] == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { -#ifdef BT_USB_AUDIO_DUAL_MODE - if(btusb_is_bt_mode()) -#endif - { - store_sbc_buffer(((unsigned char *)Info->p.data) + header_len , Info->len - header_len); - } - } - else -#endif -#if defined(A2DP_SCALABLE_ON) - if (app_bt_device.codec_type[stream_id_flag.id] == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { - store_sbc_buffer(((unsigned char *)Info->p.data) + header_len , Info->len - header_len); - }else -#endif - { - store_sbc_buffer(((unsigned char *)Info->p.data) + header_len + 1 , Info->len - header_len - 1); - } -#endif - } - } - } -#else -#ifdef __A2DP_AVDTP_CP__ //zadd bug fixed sony Z5 no sound - header_len = btif_avdtp_parse_mediaHeader(&header, (btif_a2dp_callback_parms_t *)Info,app_bt_device.avdtp_cp[stream_id_flag.id]); -#else - header_len = btif_avdtp_parse_mediaHeader(&header, (btif_a2dp_callback_parms_t *)Info,0); -#endif - if ( -#if (A2DP_DECODER_VER < 2) - app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC) && -#endif - (btif_a2dp_get_stream_state(Stream) == BTIF_AVDTP_STRM_STATE_STREAMING)){ -#ifdef __A2DP_TIMESTAMP_PARSER__ - if (a2dp_timestamp_parser_run(header.timestamp,(*(((unsigned char *)Info->p.data) + header_len)))){ - TRACE(0,"::A2DP_EVENT_STREAM_DATA_IND skip frame\n"); - }else -#endif - { -#if (A2DP_DECODER_VER >= 2) - a2dp_audio_store_packet(&header, ((unsigned char *)Info->p.data) + header_len , Info->len - header_len); -#else - a2dp_audio_sbc_set_frame_info(Info->len - header_len - 1, (*(((unsigned char *)Info->p.data) + header_len))); - - current_codec_type = a2dp_get_current_codec_type((unsigned char *)Info->p.configReq->codec.elements); -#if defined(A2DP_AAC_ON) - //TRACE(4,"%s:%d pt 0x%x, app_bt_device.codec_type[stream_id_flag.id] %d\n", - // __func__, __LINE__, header.payloadType, app_bt_device.codec_type[stream_id_flag.id]); - if (app_bt_device.codec_type[stream_id_flag.id] == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { - store_sbc_buffer(((unsigned char *)Info->p.data) + header_len , Info->len - header_len); - } - else -#endif -#if defined(A2DP_SCALABLE_ON) - if (app_bt_device.codec_type[stream_id_flag.id] == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { - store_sbc_buffer(((unsigned char *)Info->p.data) + header_len , Info->len - header_len); - }else -#endif -#if defined(A2DP_LHDC_ON) - if (app_bt_device.codec_type[stream_id_flag.id] == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { - store_sbc_buffer(((unsigned char *)Info->p.data) + header_len , Info->len - header_len); - }else -#endif -#if defined(A2DP_LDAC_ON) - if (app_bt_device.codec_type[stream_id_flag.id] == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { - //if((((unsigned char *)Info->p.data) + header_len)) - store_sbc_buffer(((unsigned char *)Info->p.data) + header_len + 1, Info->len - header_len - 1); - } - else -#endif - - store_sbc_buffer(((unsigned char *)Info->p.data) + header_len + 1 , Info->len - header_len - 1); -#endif - } - } - else { - TRACE(2,"::A2DP_EVENT_STREAM_DATA_IND skip app_bt_stream_isrun=%d,stream_state=%d", app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC), btif_a2dp_get_stream_state(Stream)); - } -#endif - break; - case BTIF_A2DP_EVENT_STREAM_CLOSED: - if(bt_drv_func_cb->bt_switch_agc != NULL) - { - bt_drv_func_cb->bt_switch_agc(BT_IDLE_MODE); - } - TRACE(2,"::A2DP_EVENT_STREAM_CLOSED stream_id:%d, reason = %x\n", stream_id_flag.id,Info->discReason); - if (btif_a2dp_is_disconnected(app_bt_device.a2dp_connected_stream[stream_id_flag.id])) { - // disconnect avrcp also when a2dp closed - btif_avrcp_disconnect(app_bt_device.avrcp_channel[stream_id_flag.id]->avrcp_channel_handle); - } -#ifdef __A2DP_AVDTP_CP__ - app_bt_device.avdtp_cp[stream_id_flag.id]=0; -#endif - a2dp_timestamp_parser_init(); - app_bt_device.a2dp_streamming[stream_id_flag.id] = 0; - #ifdef __BT_ONE_BRING_TWO__ - if (app_bt_is_to_resume_music_player(stream_id_flag.id)) - { - app_bt_reset_music_player_resume_state(); - } - #endif - if(distinguish_found_id != BT_DEVICE_NUM){ -#ifdef __BT_ONE_BRING_TWO__ - TRACE(3,"found_id=%d state[0]/[1] = %d %d",distinguish_found_id, - app_bt_device.a2dp_state[BT_DEVICE_ID_1],app_bt_device.a2dp_state[BT_DEVICE_ID_2]); - // app_bt_device.curr_a2dp_stream_id = anotherDevice; - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP,BT_STREAM_SBC,stream_id_flag.id,0); - if((app_bt_device.a2dp_connected_stream[anotherDevice]) && - (btif_a2dp_get_stream_state(app_bt_device.a2dp_connected_stream[anotherDevice]) == BTIF_AVDTP_STRM_STATE_STREAMING)) - { - if(bt_media_is_media_active_by_device(BT_STREAM_SBC,anotherDevice) == 1) - { - a2dp_set_cur_stream(anotherDevice); - app_bt_device.a2dp_play_pause_flag = 1; - }else{ - a2dp_set_cur_stream(anotherDevice); - app_bt_device.a2dp_play_pause_flag = 1; - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START,BT_STREAM_SBC,anotherDevice,0); - } - } - else - { - app_bt_device.a2dp_play_pause_flag = 0; - app_a2dp_hold_mute(); - } -#else - - - -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) - if(app_bt_device.src_or_snk==BT_DEVICE_SRC) - { - if(app_bt_device.input_onoff!=0) - { -#if defined(APP_LINEIN_A2DP_SOURCE) - app_audio_sendrequest(APP_A2DP_SOURCE_LINEIN_AUDIO, (uint8_t)APP_BT_SETTING_CLOSE,0); -#else - app_audio_sendrequest(APP_A2DP_SOURCE_I2S_AUDIO, (uint8_t)APP_BT_SETTING_CLOSE,0); -#endif - app_bt_device.input_onoff=0; - } - app_bt_device.a2dp_streamming[BT_DEVICE_ID_1] = 0; - a2dp_source_notify_send(); - } - else - { - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP,BT_STREAM_SBC,stream_id_flag.id,0); - app_bt_profile_connect_manager_a2dp(stream_id_flag.id, Stream, (a2dp_callback_parms_t *)Info); - } -#else - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP,BT_STREAM_SBC,stream_id_flag.id,0); - app_bt_device.a2dp_play_pause_flag = 0; -#endif - -#endif - - app_bt_device.a2dp_state[stream_id_flag.id] = 0; - app_bt_device.a2dp_connected_stream[stream_id_flag.id] = NULL; -#ifdef __BT_ONE_BRING_TWO__ - ///a2dp disconnect so check the other stream is playing or not - if((app_bt_device.a2dp_connected_stream[anotherDevice]) && - (btif_a2dp_get_stream_state(app_bt_device.a2dp_connected_stream[anotherDevice]) != BTIF_AVDTP_STRM_STATE_STREAMING)) - { - app_bt_device.a2dp_play_pause_flag = 0; - app_a2dp_hold_mute(); - } -#endif - } - -#ifdef __BT_ONE_BRING_TWO__ - a2dp_dual_slave_handling_refresh(); -#endif - app_bt_profile_connect_manager_a2dp(stream_id_flag.id, Stream, info); -#if defined(IBRT) - a2dp_ibrt_session_reset(); -#endif - break; -#if defined(__BTIF_BT_RECONNECT__) - case BTIF_A2DP_EVENT_CODEC_INFO: - TRACE(1,"::A2DP_EVENT_CODEC_INFO %d\n", Info->event); - setconfig_codec.codecType = Info->p.codec->codecType; - setconfig_codec.discoverable = Info->p.codec->discoverable; - setconfig_codec.elemLen = Info->p.codec->elemLen; - setconfig_codec.elements = tmp_element; - memset(tmp_element, 0, sizeof(tmp_element)); - - DUMP8("%02x ", (setconfig_codec.elements), 8); - if(Info->p.codec->codecType == BTIF_AVDTP_CODEC_TYPE_SBC){ - setconfig_codec.elements[0] = (Info->p.codec->elements[0]) & (a2dp_codec_elements[0]); - setconfig_codec.elements[1] = (Info->p.codec->elements[1]) & (a2dp_codec_elements[1]); - - if(Info->p.codec->elements[2] <= a2dp_codec_elements[2]) - setconfig_codec.elements[2] = a2dp_codec_elements[2];////[2]:MIN_BITPOOL - else - setconfig_codec.elements[2] = Info->p.codec->elements[2]; - - if(Info->p.codec->elements[3] >= a2dp_codec_elements[3]) - setconfig_codec.elements[3] = a2dp_codec_elements[3];////[3]:MAX_BITPOOL - else - setconfig_codec.elements[3] = Info->p.codec->elements[3]; - - ///////null set situation: - if(setconfig_codec.elements[3] < a2dp_codec_elements[2]){ - setconfig_codec.elements[2] = a2dp_codec_elements[2]; - setconfig_codec.elements[3] = a2dp_codec_elements[3]; - } - else if(setconfig_codec.elements[2] > a2dp_codec_elements[3]){ - setconfig_codec.elements[2] = a2dp_codec_elements[3]; - setconfig_codec.elements[3] = a2dp_codec_elements[3]; - } - TRACE(2,"!!!setconfig_codec.elements[2]:%d,setconfig_codec.elements[3]:%d\n",setconfig_codec.elements[2],setconfig_codec.elements[3]); - - setconfig_codec.elements[0] = get_valid_bit(setconfig_codec.elements[0],A2D_SBC_IE_SAMP_FREQ_MSK); - setconfig_codec.elements[0] = get_valid_bit(setconfig_codec.elements[0],A2D_SBC_IE_CH_MD_MSK); - setconfig_codec.elements[1] = get_valid_bit(setconfig_codec.elements[1],A2D_SBC_IE_BLOCKS_MSK); - setconfig_codec.elements[1] = get_valid_bit(setconfig_codec.elements[1],A2D_SBC_IE_SUBBAND_MSK); - setconfig_codec.elements[1] = get_valid_bit(setconfig_codec.elements[1],A2D_SBC_IE_ALLOC_MD_MSK); - } -#if defined(A2DP_AAC_ON) - else if(Info->p.codec->codecType == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC){ - setconfig_codec.elements[0] = a2dp_codec_aac_elements[0]; - if(Info->p.codec->elements[1] & A2DP_AAC_OCTET1_SAMPLING_FREQUENCY_44100) - setconfig_codec.elements[1] |= A2DP_AAC_OCTET1_SAMPLING_FREQUENCY_44100; - else if(Info->p.codec->elements[2] & A2DP_AAC_OCTET2_SAMPLING_FREQUENCY_48000) - setconfig_codec.elements[2] |= A2DP_AAC_OCTET2_SAMPLING_FREQUENCY_48000; - - if(Info->p.codec->elements[2] & A2DP_AAC_OCTET2_CHANNELS_2) - setconfig_codec.elements[2] |= A2DP_AAC_OCTET2_CHANNELS_2; - else if(Info->p.codec->elements[2] & A2DP_AAC_OCTET2_CHANNELS_1) - setconfig_codec.elements[2] |= A2DP_AAC_OCTET2_CHANNELS_1; - - setconfig_codec.elements[3] = (Info->p.codec->elements[3]) & A2DP_AAC_OCTET3_VBR_SUPPORTED; - if ( ((Info->p.codec->elements[3]) & A2DP_AAC_OCTET3_VBR_SUPPORTED) && - (((a2dp_codec_aac_elements[3]) & A2DP_AAC_OCTET3_VBR_SUPPORTED) == 0)){ - Info->error = BTIF_A2DP_ERR_NOT_SUPPORTED_VBR; - TRACE(0,"setconfig: VBR UNSUPPORTED!!!!!!"); - } - - uint32_t bit_rate = 0; - bit_rate = ((Info->p.codec->elements[3]) & 0x7f) << 16; - bit_rate |= (Info->p.codec->elements[4]) << 8; - bit_rate |= (Info->p.codec->elements[5]); - TRACE(1,"bit_rate = %d", bit_rate); - if(bit_rate == 0){ - bit_rate = MAX_AAC_BITRATE; - }else if(bit_rate > MAX_AAC_BITRATE){ - bit_rate = MAX_AAC_BITRATE; - } - - setconfig_codec.elements[3] |= (bit_rate >> 16) &0x7f; - setconfig_codec.elements[4] = (bit_rate >> 8) & 0xff; - setconfig_codec.elements[5] = bit_rate & 0xff; - } -#endif - else if(Info->p.codec->codecType == BTIF_AVDTP_CODEC_TYPE_NON_A2DP){ -#if defined(A2DP_SCALABLE_ON) - //0x75 0x00 0x00 0x00Vid - //0x03 0x01 Codec id - if(Info->p.codec->elements[0]==0x75&& - Info->p.codec->elements[1]==0x00&& - Info->p.codec->elements[2]==0x00&& - Info->p.codec->elements[3]==0x00&& - Info->p.codec->elements[4]==0x03&& - Info->p.codec->elements[5]==0x01){ - memcpy(&setconfig_codec.elements[0], &a2dp_codec_scalable_elements[0], 6); - DUMP8("%02x ", (setconfig_codec.elements), 8); - DUMP8("%02x ", &(Info->p.codec->elements[0]), 8); - setconfig_codec.elements[6] = 0x00; - //Audio format setting -#if defined(A2DP_SCALABLE_UHQ_SUPPORT) - if (Info->p.codec->elements[6] & A2DP_SCALABLE_SR_96000) { - setconfig_codec.elements[6] |= A2DP_SCALABLE_SR_96000; - } -#endif - if (Info->p.codec->elements[6] & A2DP_SCALABLE_SR_32000) { - setconfig_codec.elements[6] |= A2DP_SCALABLE_SR_32000; - }else if (Info->p.codec->elements[6] & A2DP_SCALABLE_SR_44100) { - setconfig_codec.elements[6] |= A2DP_SCALABLE_SR_44100; - }else if (Info->p.codec->elements[6] & A2DP_SCALABLE_SR_48000) { - setconfig_codec.elements[6] |= A2DP_SCALABLE_SR_48000; - } - - if (Info->p.codec->elements[6] & A2DP_SCALABLE_HQ) { - setconfig_codec.elements[6] |= A2DP_SCALABLE_HQ; - } - DUMP8("0x%02x ", setconfig_codec.elements, setconfig_codec.elemLen); - } -#endif - -#if defined(A2DP_LHDC_ON) - //0x3A 0x05 0x00 0x00Vid - //0x33 0x4c Codec id V3 - //0x32 0x4c Codec id V2 - if(Info->p.codec->elements[0]==a2dp_codec_lhdc_elements[0]&& - Info->p.codec->elements[1]==a2dp_codec_lhdc_elements[1]&& - Info->p.codec->elements[2]==a2dp_codec_lhdc_elements[2]&& - Info->p.codec->elements[3]==a2dp_codec_lhdc_elements[3]&& - Info->p.codec->elements[4]==a2dp_codec_lhdc_elements[4]&& - Info->p.codec->elements[5]==a2dp_codec_lhdc_elements[5]){ - memcpy(&setconfig_codec.elements[0], &a2dp_codec_lhdc_elements[0], 6); - DUMP8("%02x ", (setconfig_codec.elements), 8); - DUMP8("%02x ", &(Info->p.codec->elements[0]), 8); - - //Audio format setting - //(A2DP_LHDC_SR_96000|A2DP_LHDC_SR_48000 |A2DP_LHDC_SR_44100) | (A2DP_LHDC_FMT_16), - if (Info->p.codec->elements[6] & A2DP_LHDC_SR_96000) { - setconfig_codec.elements[6] |= A2DP_LHDC_SR_96000; - }else if (Info->p.codec->elements[6] & A2DP_LHDC_SR_48000) { - setconfig_codec.elements[6] |= A2DP_LHDC_SR_48000; - }else if (Info->p.codec->elements[6] & A2DP_LHDC_SR_44100) { - setconfig_codec.elements[6] |= A2DP_LHDC_SR_44100; - } - - if (Info->p.codec->elements[6] & A2DP_LHDC_FMT_16) { - setconfig_codec.elements[6] |= A2DP_LHDC_FMT_16; - }else if (Info->p.codec->elements[6] & A2DP_LHDC_FMT_24) { - setconfig_codec.elements[6] |= A2DP_LHDC_FMT_24; - } - } -#endif - -#if defined(A2DP_LDAC_ON) -// 0x2d, 0x01, 0x00, 0x00, //Vendor ID -// 0xaa, 0x00, //Codec ID - if (Info->p.codec->elements[0]==a2dp_codec_ldac_elements[0]&& - Info->p.codec->elements[1]==a2dp_codec_ldac_elements[1]&& - Info->p.codec->elements[2]==a2dp_codec_ldac_elements[2]&& - Info->p.codec->elements[3]==a2dp_codec_ldac_elements[3]&& - Info->p.codec->elements[4]==a2dp_codec_ldac_elements[4]&& - Info->p.codec->elements[5]==a2dp_codec_ldac_elements[5]){ - memcpy(&setconfig_codec.elements[0], &a2dp_codec_ldac_elements[0], 6); - - DUMP8("%02x ", (setconfig_codec.elements), 8); - DUMP8("%02x ", &(Info->p.codec->elements[0]), 8); - //Audio format setting - //3c 03 - //34 07 - if (Info->p.codec->elements[6] & A2DP_LDAC_SR_96000) { - setconfig_codec.elements[6] |= A2DP_LDAC_SR_96000; - }else if (Info->p.codec->elements[6] & A2DP_LDAC_SR_88200) { - setconfig_codec.elements[6] |= A2DP_LDAC_SR_88200; - }else if (Info->p.codec->elements[6] & A2DP_LDAC_SR_48000) { - setconfig_codec.elements[6] |= A2DP_LDAC_SR_48000; - }else if (Info->p.codec->elements[6] & A2DP_LDAC_SR_44100) { - setconfig_codec.elements[6] |= A2DP_LDAC_SR_44100; - } - // }else if (Info->p.codec->elements[6] & A2DP_LDAC_SR_88200) { - // setconfig_codec.elements[6] |= A2DP_LDAC_SR_88200; - // } - - if (Info->p.codec->elements[7] & A2DP_LDAC_CM_MONO) { - setconfig_codec.elements[7] |= A2DP_LDAC_CM_MONO; - }else if (Info->p.codec->elements[7] & A2DP_LDAC_CM_DUAL) { - setconfig_codec.elements[7] |= A2DP_LDAC_CM_DUAL; - }else if (Info->p.codec->elements[7] & A2DP_LDAC_CM_STEREO) { - setconfig_codec.elements[7] |= A2DP_LDAC_CM_STEREO; - } - - TRACE(1,"setconfig_codec.elemLen = %d", setconfig_codec.elemLen); - TRACE(1,"setconfig_codec.elements[7] = 0x%02x", setconfig_codec.elements[7]); - - DUMP8("%02x ", (setconfig_codec.elements), 8); - } -#endif - } - break; - - case BTIF_A2DP_EVENT_GET_CONFIG_IND: - TRACE(1,"::A2DP_EVENT_GET_CONFIG_IND %d\n", Info->event); -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) - //I2S or LineIn for 44.1K - setconfig_codec.elements[0] = (setconfig_codec.elements[0]&0xef) | A2D_SBC_IE_SAMP_FREQ_44; -#endif -#ifdef __A2DP_AVDTP_CP__ - if(Info->p.capability->type & BTIF_AVDTP_SRV_CAT_CONTENT_PROTECTION||Info->p.cp->cpType!=0){ - TRACE(0,"support CONTENT_PROTECTION\n"); - btif_a2dp_set_stream_config(Stream, &setconfig_codec, &setconfig_cp[stream_id_flag.id]); - }else{ - TRACE(0,"no CONTENT_PROTECTION\n"); - btif_a2dp_set_stream_config(Stream, &setconfig_codec, NULL); - } -#else - btif_a2dp_set_stream_config(Stream, &setconfig_codec, NULL); -#endif - break; - case BTIF_A2DP_EVENT_STREAM_RECONFIG_IND: - TRACE(1,"::A2DP_EVENT_STREAM_RECONFIG_IND %d\n", Info->event); -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) - SOURCE_DBLOG("::BTIF_A2DP_EVENT_STREAM_RECONFIG_IND %d\n", Info->event); -#else - - if(Info->p.configReq->codec.codecType == BTIF_AVDTP_CODEC_TYPE_NON_A2DP){ - current_codec_type = a2dp_get_current_codec_type((unsigned char *)Info->p.configReq->codec.elements); -#if defined(A2DP_SCALABLE_ON) - if(current_codec_type == A2DP_NON_CODEC_TYPE_SCALABLE){ - TRACE(0,"::##SCALABLE A2DP_EVENT_STREAM_RECONFIG_IND\n"); - a2dp_scalable_config(&(Info->p.configReq->codec.elements[0])); - } -#endif -#if defined(A2DP_LHDC_ON) - if(current_codec_type == A2DP_NON_CODEC_TYPE_LHDC){ - TRACE(0,"::##LHDC A2DP_EVENT_STREAM_RECONFIG_IND\n"); - a2dp_lhdc_config(&(Info->p.configReq->codec.elements[0])); - } -#endif -#if defined(A2DP_LDAC_ON) - if(current_codec_type == A2DP_NON_CODEC_TYPE_LDAC){ - TRACE(0,"::##LDAC A2DP_EVENT_STREAM_RECONFIG_IND\n"); - a2dp_ldac_config(&(Info->p.configReq->codec.elements[0])); - } -#endif - } - -#if defined(A2DP_AAC_ON) - if(Info->p.configReq->codec.codecType == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC){ - TRACE(0,"::##AAC A2DP_EVENT_STREAM_RECONFIG_IND\n"); - if ( ((Info->p.codec->elements[3]) & A2DP_AAC_OCTET3_VBR_SUPPORTED) && - (((a2dp_codec_aac_elements[3]) & A2DP_AAC_OCTET3_VBR_SUPPORTED) == 0)){ - Info->error = BTIF_A2DP_ERR_NOT_SUPPORTED_VBR; - btif_a2dp_reconfig_stream_rsp(Stream,BTIF_A2DP_ERR_NOT_SUPPORTED_VBR,0); - TRACE(0,"stream reconfig: VBR UNSUPPORTED!!!!!!"); - break; - } - } -#endif - if(Info->p.configReq->codec.codecType == BTIF_AVDTP_CODEC_TYPE_SBC){ - TRACE(0,"::##SBC A2DP_EVENT_STREAM_RECONFIG_IND\n"); - TRACE(5,"app_bt_device.sample_rate::elements[0] %d BITPOOL:%d/%d %02x/%02x\n", Info->p.configReq->codec.elements[0], - Info->p.configReq->codec.elements[2], - Info->p.configReq->codec.elements[3], - Info->p.configReq->codec.elements[2], - Info->p.configReq->codec.elements[3]); - } -#endif - btif_a2dp_reconfig_stream_rsp(Stream,BTIF_A2DP_ERR_NO_ERROR,0); - break; - case BTIF_A2DP_EVENT_STREAM_RECONFIG_CNF: - TRACE(3,"::A2DP_EVENT_STREAM_RECONFIG_CNF %d,sample rate=%x,%x\n", - Info->event,btif_a2dp_get_stream_codecCfg( Stream)->elements[0], Info->p.codec->elements[0]); - -#if defined(A2DP_AAC_ON) - if (Info->p.configReq->codec.codecType == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { -#ifdef __A2DP_AVDTP_CP__ - btif_a2dp_security_control_req(Stream,(U8 *)&a2dp_avdtpCp_aac_securityData[stream_id_flag.id][0],1); -#endif - TRACE(2,"::A2DP_EVENT_STREAM_OPEN stream_id:%d, aac sample_rate codec.elements 0x%x\n", stream_id_flag.id,Info->p.configReq->codec.elements[1]); - app_bt_device.codec_type[stream_id_flag.id] = BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC; - app_bt_device.sample_bit[stream_id_flag.id] = 16; - // convert aac sample_rate to sbc sample_rate format - if (Info->p.configReq->codec.elements[1] & A2DP_AAC_OCTET1_SAMPLING_FREQUENCY_44100) { - TRACE(1,"::A2DP_EVENT_STREAM_OPEN stream_id:%d, aac sample_rate 44100\n", stream_id_flag.id); - app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_44; - } - else if (Info->p.configReq->codec.elements[2] & A2DP_AAC_OCTET2_SAMPLING_FREQUENCY_48000) { - TRACE(1,"::A2DP_EVENT_STREAM_OPEN stream_id:%d, aac sample_rate 48000\n", stream_id_flag.id); - app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_48; - } - else { - TRACE(1,"::A2DP_EVENT_STREAM_OPEN stream_id:%d, aac sample_rate not 48000 or 44100, set to 44100\n", stream_id_flag.id); - app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_44; - } - - if (Info->p.configReq->codec.elements[2] & A2DP_AAC_OCTET2_CHANNELS_1){ - a2dp_channel_num[stream_id_flag.id] = 1; - }else{ - a2dp_channel_num[stream_id_flag.id] = 2; - } - } - else -#endif - if (Info->p.configReq->codec.codecType == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { - current_codec_type = a2dp_get_current_codec_type((unsigned char *)Info->p.configReq->codec.elements); -#if defined(A2DP_SCALABLE_ON) - if (current_codec_type == A2DP_NON_CODEC_TYPE_SCALABLE) { - TRACE(0,"##codecType scalable\n"); - a2dp_scalable_config(&(Info->p.configReq->codec.elements[0])); - app_bt_device.codec_type[stream_id_flag.id] = BTIF_AVDTP_CODEC_TYPE_NON_A2DP; - //0x75 0x00 0x00 0x00Vid - //0x03 0x01 Codec id - if(Info->p.codec->elements[0]==0x75&& - Info->p.codec->elements[4]==0x03&& - Info->p.codec->elements[5]==0x01 - ){ - setconfig_codec.elements = a2dp_scalable_avdtpcodec.elements; - } - else{ - if(Info->p.codec->pstreamflags!=NULL) - Info->p.codec->pstreamflags[0] &= ~APP_A2DP_STRM_FLAG_QUERY_CODEC; - else{ - ASSERT(false, "pstreamflags not init .."); - } - } - - a2dp_channel_num[stream_id_flag.id] = 2; - } -#endif -#if defined(A2DP_LHDC_ON) - if (current_codec_type == A2DP_NON_CODEC_TYPE_LHDC) { - TRACE(2,"##codecType: LHDC Codec, Element length = %d, AVDTP_MAX_CODEC_ELEM_SIZE = %d\n", Info->p.configReq->codec.elemLen, BTIF_AVDTP_MAX_CODEC_ELEM_SIZE); - app_bt_device.codec_type[stream_id_flag.id] = BTIF_AVDTP_CODEC_TYPE_NON_A2DP; - a2dp_channel_num[stream_id_flag.id] = 2; - a2dp_lhdc_config(&(Info->p.configReq->codec.elements[0])); - } -#endif -#if defined(A2DP_LDAC_ON) - if (current_codec_type == A2DP_NON_CODEC_TYPE_LDAC) { - TRACE(2,"##codecType: LDAC Codec, Element length = %d, AVDTP_MAX_CODEC_ELEM_SIZE = %d\n", Info->p.configReq->codec.elemLen, BTIF_AVDTP_MAX_CODEC_ELEM_SIZE); - app_bt_device.codec_type[stream_id_flag.id] = BTIF_AVDTP_CODEC_TYPE_NON_A2DP; - a2dp_channel_num[stream_id_flag.id] = 2; - a2dp_ldac_config(&(Info->p.configReq->codec.elements[0])); - } -#endif - }else - - - { - TRACE(5,"app_bt_device.sample_rate::elements[0] %d BITPOOL:%d/%d %02x/%02x\n", Info->p.codec->elements[0], - Info->p.codec->elements[2], - Info->p.codec->elements[3], - Info->p.codec->elements[2], - Info->p.codec->elements[3]); - - app_bt_device.codec_type[stream_id_flag.id] = BTIF_AVDTP_CODEC_TYPE_SBC; - app_bt_device.sample_bit[stream_id_flag.id] = 16; - app_bt_device.sample_rate[stream_id_flag.id] = (Info->p.configReq->codec.elements[0] & A2D_SBC_IE_SAMP_FREQ_MSK); - - if(Info->p.configReq->codec.elements[0] & A2D_SBC_IE_CH_MD_MONO) - a2dp_channel_num[stream_id_flag.id] = 1; - else - a2dp_channel_num[stream_id_flag.id] = 2; - } -#ifdef __A2DP_AVDTP_CP__ - if(Info->p.configReq->cp.cpType==BTIF_AVDTP_CP_TYPE_SCMS_T) - { - app_bt_device.avdtp_cp[stream_id_flag.id] = 1; - } -#endif -#endif - if (btif_a2dp_is_stream_device_has_delay_reporting(Stream)) - { - btif_a2dp_set_sink_delay(Stream, 150); - } - break; -#ifdef __A2DP_AVDTP_CP__ - case BTIF_A2DP_EVENT_CP_INFO: - TRACE(2,"::A2DP_EVENT_CP_INFO %d cpType: %x\n", Info->event, Info->p.cp->cpType); - setconfig_cp[stream_id_flag.id].cpType = Info->p.cp->cpType; - setconfig_cp[stream_id_flag.id].data = Info->p.cp->data; - setconfig_cp[stream_id_flag.id].dataLen = Info->p.cp->dataLen; - if(Info->p.cp && Info->p.cp->cpType == BTIF_AVDTP_CP_TYPE_SCMS_T) - { - app_bt_device.avdtp_cp[stream_id_flag.id] = 1; - } - else - { - app_bt_device.avdtp_cp[stream_id_flag.id] = 0; - } - btif_a2dp_set_copy_protection_enable(Stream, app_bt_device.avdtp_cp[stream_id_flag.id]); - break; - case BTIF_A2DP_EVENT_STREAM_SECURITY_IND: - TRACE(1,"::A2DP_EVENT_STREAM_SECURITY_IND %d\n", Info->event); - DUMP8("%x ",Info->p.data,Info->len); - btif_a2dp_security_control_rsp(Stream,&Info->p.data[1],Info->len-1,Info->error); - break; - case BTIF_A2DP_EVENT_STREAM_SECURITY_CNF: - app_bt_device.avdtp_cp[stream_id_flag.id]=1; - TRACE(1,"::A2DP_EVENT_STREAM_SECURITY_CNF %d\n", Info->event); - break; -#endif - -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) - case BTIF_A2DP_EVENT_STREAM_SBC_PACKET_SENT: - //TRACE(0,"@sbc be send succ"); - if(app_bt_device.src_or_snk==BT_DEVICE_SRC) - { - a2dp_source_notify_send(); - } - break; -#endif - + if (btapp_hfp_is_dev_sco_connected(anotherDevice)) { + a2dp_dual_slave_setup_during_sco(anotherDevice); + } else { + a2dp_dual_slave_handling_refresh(); } -#if defined(IBRT) - app_tws_ibrt_profile_callback(BTIF_APP_A2DP_PROFILE_ID,(void *)Stream, (void *)info); #endif -} -void a2dp_suspend_music_force(void) -{ - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP,BT_STREAM_SBC,BT_DEVICE_ID_1,0); +#ifdef __IAG_BLE_INCLUDE__ + app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_A2DP_ON, true); +#endif + break; + case BTIF_A2DP_EVENT_STREAM_START_IND: #ifdef __BT_ONE_BRING_TWO__ - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP,BT_STREAM_SBC,BT_DEVICE_ID_2,0); + TRACE(5, "::A2DP_EVENT_STREAM_START_IND %d stream_id:%d %d %d %d\n", + codec->codecType, stream_id_flag.id, + app_bt_device.curr_a2dp_stream_id, app_bt_device.a2dp_streamming[0], + app_bt_device.a2dp_streamming[1]); +#else + TRACE(4, "::A2DP_EVENT_STREAM_START_IND %d stream_id:%d %d %d\n", + codec->codecType, stream_id_flag.id, + app_bt_device.curr_a2dp_stream_id, app_bt_device.a2dp_streamming[0]); #endif -} - -int a2dp_volume_get(enum BT_DEVICE_ID_T id) -{ - int vol = TGT_VOLUME_LEVEL_15; - - btif_remote_device_t *remDev = NULL; - nvrec_btdevicerecord *record = NULL; - - if (id >= BT_DEVICE_NUM) { - TRACE(2,"%s error id %d", __func__, id); +#ifdef BT_USB_AUDIO_DUAL_MODE + if (!btusb_is_bt_mode()) { + btif_a2dp_start_stream_rsp(Stream, BTIF_A2DP_ERR_INSUFFICIENT_RESOURCE); + } else +#endif + { + btif_a2dp_start_stream_rsp(Stream, BTIF_A2DP_ERR_NO_ERROR); + app_bt_device.a2dp_play_pause_flag = 1; + } + } + break; + case BTIF_A2DP_EVENT_STREAM_IDLE: + TRACE(0, "BTIF_A2DP_EVENT_STREAM_IDLE"); + case BTIF_A2DP_EVENT_STREAM_SUSPENDED: +#if defined(IBRT) + app_ibrt_if_sniff_checker_stop(APP_IBRT_IF_SNIFF_CHECKER_USER_A2DP); +#endif + if (bt_drv_func_cb->bt_switch_agc != NULL) { + bt_drv_func_cb->bt_switch_agc(BT_IDLE_MODE); } - remDev = btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[id]); - if (remDev && !nv_record_btdevicerecord_find(btif_me_get_remote_device_bdaddr(remDev),&record)){ - vol = record->device_vol.a2dp_vol; - }else if (app_audio_manager_a2dp_is_active(id)){ - vol = app_bt_stream_a2dpvolume_get(); - }else{ - vol = TGT_VOLUME_LEVEL_15; +#ifdef __BT_ONE_BRING_TWO__ + TRACE(5, "::A2DP_EVENT_STREAM_SUSPENDED %d stream_id:%d %d %d %d\n", + codec->codecType, stream_id_flag.id, + app_bt_device.curr_a2dp_stream_id, app_bt_device.a2dp_streamming[0], + app_bt_device.a2dp_streamming[1]); +#else + TRACE(4, "::A2DP_EVENT_STREAM_SUSPENDED %d stream_id:%d %d %d\n", + codec->codecType, stream_id_flag.id, + app_bt_device.curr_a2dp_stream_id, app_bt_device.a2dp_streamming[0]); +#endif + a2dp_timestamp_parser_init(); + app_bt_device.a2dp_streamming[stream_id_flag.id] = 0; +#if defined(_AUTO_TEST_) + AUTO_TEST_SEND("Music suspend ok."); +#endif + app_bt_active_mode_clear(ACTIVE_MODE_KEEPER_A2DP_STREAMING, + stream_id_flag.id); + +#ifdef __BT_ONE_BRING_TWO__ + if (app_bt_is_device_connected(anotherDevice) && + (!app_bt_device.a2dp_streamming[anotherDevice]) && + (BTIF_HF_CALL_ACTIVE != app_bt_device.hfchan_call[anotherDevice])) { + app_bt_active_mode_clear(ACTIVE_MODE_KEEPER_A2DP_STREAMING, + anotherDevice); } - if (vol == TGT_VOLUME_LEVEL_MUTE){ - vol = 0; - }else{ - if (vol >= TGT_VOLUME_LEVEL_15){ - vol = TGT_VOLUME_LEVEL_15; - }else if (vol <= TGT_VOLUME_LEVEL_0){ - vol = TGT_VOLUME_LEVEL_0; + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_SBC, + stream_id_flag.id, 0); + if ((app_bt_device.a2dp_connected_stream[anotherDevice]) && + (btif_a2dp_get_stream_state( + app_bt_device.a2dp_connected_stream[anotherDevice]) == + BTIF_AVDTP_STRM_STATE_STREAMING)) { + if (bt_media_is_media_active_by_device(BT_STREAM_SBC, anotherDevice) == + 1) { + a2dp_set_cur_stream(anotherDevice); + app_bt_device.a2dp_play_pause_flag = 1; + } else { + a2dp_set_cur_stream(anotherDevice); + app_bt_device.a2dp_play_pause_flag = 1; + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, + BT_STREAM_SBC, anotherDevice, 0); + } + } else { + app_bt_device.a2dp_play_pause_flag = 0; + app_a2dp_hold_mute(); + } +#else + +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) + if (app_bt_device.src_or_snk == BT_DEVICE_SNK) { + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_SBC, + BT_DEVICE_ID_1, MAX_RECORD_NUM); + } else { + TRACE(0, "::APP_A2DP_SOURCE SUSPEND \n"); +#if defined(APP_LINEIN_A2DP_SOURCE) + app_audio_sendrequest(APP_A2DP_SOURCE_LINEIN_AUDIO, + (uint8_t)APP_BT_SETTING_CLOSE, 0); +#else + app_audio_sendrequest(APP_A2DP_SOURCE_I2S_AUDIO, + (uint8_t)APP_BT_SETTING_CLOSE, 0); +#endif + app_bt_device.input_onoff = 0; + } +#else + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_SBC, + BT_DEVICE_ID_1, MAX_RECORD_NUM); +#endif + app_bt_device.a2dp_play_pause_flag = 0; +#endif + +#ifdef __BT_ONE_BRING_TWO__ + if (btapp_hfp_is_dev_sco_connected(anotherDevice)) { + a2dp_dual_slave_setup_during_sco(anotherDevice); + } else { + a2dp_dual_slave_handling_refresh(); + } +#endif + +#ifdef __IAG_BLE_INCLUDE__ + app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_A2DP_ON, false); +#endif + + break; + case BTIF_A2DP_EVENT_STREAM_DATA_IND: +#ifdef __AI_VOICE__ + if (app_ai_is_to_mute_a2dp_during_ai_starting_speech()) { + // TRACE(0,"app_ai_is_to_mute_a2dp_during_ai_starting_speech"); + break; + } +#endif +#if defined(IBRT) + if (a2dp_ibrt_stream_event_stream_data_ind_needskip(Stream)) { + header_len = btif_avdtp_parse_mediaHeader( + &header, (btif_a2dp_callback_parms_t *)Info, 0); + TRACE(2, "::A2DP_EVENT_STREAM_DATA_IND skip seq:%d timestamp:%d\n", + header.sequenceNumber, header.timestamp); + break; + } +#else + if (btif_me_get_current_mode(btif_a2dp_get_remote_device(Stream)) == + BTIF_BLM_SNIFF_MODE) { + TRACE(0, "::A2DP_EVENT_STREAM_DATA_IND skip\n"); + break; + } +#endif + if (detect_first_packet[stream_id_flag.id]) { + detect_first_packet[stream_id_flag.id] = 0; + avrcp_get_current_media_status(stream_id_flag.id); + } + +#ifdef __BT_ONE_BRING_TWO__ + ////play music of curr_a2dp_stream_id + if (app_bt_device.curr_a2dp_stream_id == stream_id_flag.id && + app_bt_device.hf_audio_state[stream_id_flag.id] == + BTIF_HF_AUDIO_DISCON && + app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_DISCON && + app_bt_device.hfchan_callSetup[anotherDevice] == + BTIF_HF_CALL_SETUP_NONE) { +#ifdef __A2DP_AVDTP_CP__ // zadd bug fixed sony Z5 no sound + header_len = btif_avdtp_parse_mediaHeader( + &header, (btif_a2dp_callback_parms_t *)Info, + app_bt_device.avdtp_cp[stream_id_flag.id]); +#else + header_len = btif_avdtp_parse_mediaHeader( + &header, (btif_a2dp_callback_parms_t *)Info, 0); +#endif + if (app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC) && + (btif_a2dp_get_stream_state(Stream) == + BTIF_AVDTP_STRM_STATE_STREAMING)) { +#ifdef __A2DP_TIMESTAMP_PARSER__ + if (a2dp_timestamp_parser_run( + header.timestamp, + (*(((unsigned char *)Info->p.data) + header_len)))) { + TRACE(0, "::A2DP_EVENT_STREAM_DATA_IND skip frame\n"); + } else +#endif + { +#if (A2DP_DECODER_VER >= 2) + a2dp_audio_store_packet(&header, + ((unsigned char *)Info->p.data) + header_len, + Info->len - header_len); +#else + a2dp_audio_sbc_set_frame_info( + Info->len - header_len - 1, + (*(((unsigned char *)Info->p.data) + header_len))); +#if defined(A2DP_LHDC_ON) + if (app_bt_device.codec_type[stream_id_flag.id] == + BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + store_sbc_buffer(((unsigned char *)Info->p.data) + header_len, + Info->len - header_len); + } else +#endif +#if defined(A2DP_AAC_ON) + if (app_bt_device.codec_type[stream_id_flag.id] == + BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { +#ifdef BT_USB_AUDIO_DUAL_MODE + if (btusb_is_bt_mode()) +#endif + { + store_sbc_buffer(((unsigned char *)Info->p.data) + header_len, + Info->len - header_len); + } + } else +#endif +#if defined(A2DP_SCALABLE_ON) + if (app_bt_device.codec_type[stream_id_flag.id] == + BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + store_sbc_buffer(((unsigned char *)Info->p.data) + header_len, + Info->len - header_len); + } else +#endif + { + store_sbc_buffer(((unsigned char *)Info->p.data) + header_len + 1, + Info->len - header_len - 1); + } +#endif } - vol = 8*(vol-1); + } + } +#else +#ifdef __A2DP_AVDTP_CP__ // zadd bug fixed sony Z5 no sound + header_len = btif_avdtp_parse_mediaHeader( + &header, (btif_a2dp_callback_parms_t *)Info, + app_bt_device.avdtp_cp[stream_id_flag.id]); +#else + header_len = btif_avdtp_parse_mediaHeader( + &header, (btif_a2dp_callback_parms_t *)Info, 0); +#endif + if ( +#if (A2DP_DECODER_VER < 2) + app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC) && +#endif + (btif_a2dp_get_stream_state(Stream) == + BTIF_AVDTP_STRM_STATE_STREAMING)) { +#ifdef __A2DP_TIMESTAMP_PARSER__ + if (a2dp_timestamp_parser_run( + header.timestamp, + (*(((unsigned char *)Info->p.data) + header_len)))) { + TRACE(0, "::A2DP_EVENT_STREAM_DATA_IND skip frame\n"); + } else +#endif + { +#if (A2DP_DECODER_VER >= 2) + a2dp_audio_store_packet(&header, + ((unsigned char *)Info->p.data) + header_len, + Info->len - header_len); +#else + a2dp_audio_sbc_set_frame_info( + Info->len - header_len - 1, + (*(((unsigned char *)Info->p.data) + header_len))); + + current_codec_type = a2dp_get_current_codec_type( + (unsigned char *)Info->p.configReq->codec.elements); +#if defined(A2DP_AAC_ON) + // TRACE(4,"%s:%d pt 0x%x, app_bt_device.codec_type[stream_id_flag.id] + // %d\n", + // __func__, __LINE__, header.payloadType, + // app_bt_device.codec_type[stream_id_flag.id]); + if (app_bt_device.codec_type[stream_id_flag.id] == + BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { + store_sbc_buffer(((unsigned char *)Info->p.data) + header_len, + Info->len - header_len); + } else +#endif +#if defined(A2DP_SCALABLE_ON) + if (app_bt_device.codec_type[stream_id_flag.id] == + BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + store_sbc_buffer(((unsigned char *)Info->p.data) + header_len, + Info->len - header_len); + } else +#endif +#if defined(A2DP_LHDC_ON) + if (app_bt_device.codec_type[stream_id_flag.id] == + BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + store_sbc_buffer(((unsigned char *)Info->p.data) + header_len, + Info->len - header_len); + } else +#endif +#if defined(A2DP_LDAC_ON) + if (app_bt_device.codec_type[stream_id_flag.id] == + BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + // if((((unsigned char *)Info->p.data) + header_len)) + store_sbc_buffer(((unsigned char *)Info->p.data) + header_len + 1, + Info->len - header_len - 1); + } else +#endif + + store_sbc_buffer(((unsigned char *)Info->p.data) + header_len + 1, + Info->len - header_len - 1); +#endif + } + } else { + TRACE(2, + "::A2DP_EVENT_STREAM_DATA_IND skip " + "app_bt_stream_isrun=%d,stream_state=%d", + app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC), + btif_a2dp_get_stream_state(Stream)); + } +#endif + break; + case BTIF_A2DP_EVENT_STREAM_CLOSED: + if (bt_drv_func_cb->bt_switch_agc != NULL) { + bt_drv_func_cb->bt_switch_agc(BT_IDLE_MODE); + } + TRACE(2, "::A2DP_EVENT_STREAM_CLOSED stream_id:%d, reason = %x\n", + stream_id_flag.id, Info->discReason); + if (btif_a2dp_is_disconnected( + app_bt_device.a2dp_connected_stream[stream_id_flag.id])) { + // disconnect avrcp also when a2dp closed + btif_avrcp_disconnect( + app_bt_device.avrcp_channel[stream_id_flag.id]->avrcp_channel_handle); + } +#ifdef __A2DP_AVDTP_CP__ + app_bt_device.avdtp_cp[stream_id_flag.id] = 0; +#endif + a2dp_timestamp_parser_init(); + app_bt_device.a2dp_streamming[stream_id_flag.id] = 0; +#ifdef __BT_ONE_BRING_TWO__ + if (app_bt_is_to_resume_music_player(stream_id_flag.id)) { + app_bt_reset_music_player_resume_state(); + } +#endif + if (distinguish_found_id != BT_DEVICE_NUM) { +#ifdef __BT_ONE_BRING_TWO__ + TRACE(3, "found_id=%d state[0]/[1] = %d %d", distinguish_found_id, + app_bt_device.a2dp_state[BT_DEVICE_ID_1], + app_bt_device.a2dp_state[BT_DEVICE_ID_2]); + // app_bt_device.curr_a2dp_stream_id = anotherDevice; + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_SBC, + stream_id_flag.id, 0); + if ((app_bt_device.a2dp_connected_stream[anotherDevice]) && + (btif_a2dp_get_stream_state( + app_bt_device.a2dp_connected_stream[anotherDevice]) == + BTIF_AVDTP_STRM_STATE_STREAMING)) { + if (bt_media_is_media_active_by_device(BT_STREAM_SBC, anotherDevice) == + 1) { + a2dp_set_cur_stream(anotherDevice); + app_bt_device.a2dp_play_pause_flag = 1; + } else { + a2dp_set_cur_stream(anotherDevice); + app_bt_device.a2dp_play_pause_flag = 1; + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, + BT_STREAM_SBC, anotherDevice, 0); + } + } else { + app_bt_device.a2dp_play_pause_flag = 0; + app_a2dp_hold_mute(); + } +#else + +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) + if (app_bt_device.src_or_snk == BT_DEVICE_SRC) { + if (app_bt_device.input_onoff != 0) { +#if defined(APP_LINEIN_A2DP_SOURCE) + app_audio_sendrequest(APP_A2DP_SOURCE_LINEIN_AUDIO, + (uint8_t)APP_BT_SETTING_CLOSE, 0); +#else + app_audio_sendrequest(APP_A2DP_SOURCE_I2S_AUDIO, + (uint8_t)APP_BT_SETTING_CLOSE, 0); +#endif + app_bt_device.input_onoff = 0; + } + app_bt_device.a2dp_streamming[BT_DEVICE_ID_1] = 0; + a2dp_source_notify_send(); + } else { + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_SBC, + stream_id_flag.id, 0); + app_bt_profile_connect_manager_a2dp(stream_id_flag.id, Stream, + (a2dp_callback_parms_t *)Info); + } +#else + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_SBC, + stream_id_flag.id, 0); + app_bt_device.a2dp_play_pause_flag = 0; +#endif + +#endif + + app_bt_device.a2dp_state[stream_id_flag.id] = 0; + app_bt_device.a2dp_connected_stream[stream_id_flag.id] = NULL; +#ifdef __BT_ONE_BRING_TWO__ + /// a2dp disconnect so check the other stream is playing or not + if ((app_bt_device.a2dp_connected_stream[anotherDevice]) && + (btif_a2dp_get_stream_state( + app_bt_device.a2dp_connected_stream[anotherDevice]) != + BTIF_AVDTP_STRM_STATE_STREAMING)) { + app_bt_device.a2dp_play_pause_flag = 0; + app_a2dp_hold_mute(); + } +#endif } - if (vol > 0x7f) - vol = 0x7f; +#ifdef __BT_ONE_BRING_TWO__ + a2dp_dual_slave_handling_refresh(); +#endif + app_bt_profile_connect_manager_a2dp(stream_id_flag.id, Stream, info); +#if defined(IBRT) + a2dp_ibrt_session_reset(); +#endif + break; +#if defined(__BTIF_BT_RECONNECT__) + case BTIF_A2DP_EVENT_CODEC_INFO: + TRACE(1, "::A2DP_EVENT_CODEC_INFO %d\n", Info->event); + setconfig_codec.codecType = Info->p.codec->codecType; + setconfig_codec.discoverable = Info->p.codec->discoverable; + setconfig_codec.elemLen = Info->p.codec->elemLen; + setconfig_codec.elements = tmp_element; + memset(tmp_element, 0, sizeof(tmp_element)); - //TRACE(2,"get vol raw:%d %d/127", app_bt_stream_volume_get_ptr()->a2dp_vol, vol); + DUMP8("%02x ", (setconfig_codec.elements), 8); + if (Info->p.codec->codecType == BTIF_AVDTP_CODEC_TYPE_SBC) { + setconfig_codec.elements[0] = + (Info->p.codec->elements[0]) & (a2dp_codec_elements[0]); + setconfig_codec.elements[1] = + (Info->p.codec->elements[1]) & (a2dp_codec_elements[1]); - return (vol); + if (Info->p.codec->elements[2] <= a2dp_codec_elements[2]) + setconfig_codec.elements[2] = + a2dp_codec_elements[2]; ////[2]:MIN_BITPOOL + else + setconfig_codec.elements[2] = Info->p.codec->elements[2]; + + if (Info->p.codec->elements[3] >= a2dp_codec_elements[3]) + setconfig_codec.elements[3] = + a2dp_codec_elements[3]; ////[3]:MAX_BITPOOL + else + setconfig_codec.elements[3] = Info->p.codec->elements[3]; + + ///////null set situation: + if (setconfig_codec.elements[3] < a2dp_codec_elements[2]) { + setconfig_codec.elements[2] = a2dp_codec_elements[2]; + setconfig_codec.elements[3] = a2dp_codec_elements[3]; + } else if (setconfig_codec.elements[2] > a2dp_codec_elements[3]) { + setconfig_codec.elements[2] = a2dp_codec_elements[3]; + setconfig_codec.elements[3] = a2dp_codec_elements[3]; + } + TRACE( + 2, + "!!!setconfig_codec.elements[2]:%d,setconfig_codec.elements[3]:%d\n", + setconfig_codec.elements[2], setconfig_codec.elements[3]); + + setconfig_codec.elements[0] = + get_valid_bit(setconfig_codec.elements[0], A2D_SBC_IE_SAMP_FREQ_MSK); + setconfig_codec.elements[0] = + get_valid_bit(setconfig_codec.elements[0], A2D_SBC_IE_CH_MD_MSK); + setconfig_codec.elements[1] = + get_valid_bit(setconfig_codec.elements[1], A2D_SBC_IE_BLOCKS_MSK); + setconfig_codec.elements[1] = + get_valid_bit(setconfig_codec.elements[1], A2D_SBC_IE_SUBBAND_MSK); + setconfig_codec.elements[1] = + get_valid_bit(setconfig_codec.elements[1], A2D_SBC_IE_ALLOC_MD_MSK); + } +#if defined(A2DP_AAC_ON) + else if (Info->p.codec->codecType == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { + setconfig_codec.elements[0] = a2dp_codec_aac_elements[0]; + if (Info->p.codec->elements[1] & A2DP_AAC_OCTET1_SAMPLING_FREQUENCY_44100) + setconfig_codec.elements[1] |= A2DP_AAC_OCTET1_SAMPLING_FREQUENCY_44100; + else if (Info->p.codec->elements[2] & + A2DP_AAC_OCTET2_SAMPLING_FREQUENCY_48000) + setconfig_codec.elements[2] |= A2DP_AAC_OCTET2_SAMPLING_FREQUENCY_48000; + + if (Info->p.codec->elements[2] & A2DP_AAC_OCTET2_CHANNELS_2) + setconfig_codec.elements[2] |= A2DP_AAC_OCTET2_CHANNELS_2; + else if (Info->p.codec->elements[2] & A2DP_AAC_OCTET2_CHANNELS_1) + setconfig_codec.elements[2] |= A2DP_AAC_OCTET2_CHANNELS_1; + + setconfig_codec.elements[3] = + (Info->p.codec->elements[3]) & A2DP_AAC_OCTET3_VBR_SUPPORTED; + if (((Info->p.codec->elements[3]) & A2DP_AAC_OCTET3_VBR_SUPPORTED) && + (((a2dp_codec_aac_elements[3]) & A2DP_AAC_OCTET3_VBR_SUPPORTED) == + 0)) { + Info->error = BTIF_A2DP_ERR_NOT_SUPPORTED_VBR; + TRACE(0, "setconfig: VBR UNSUPPORTED!!!!!!"); + } + + uint32_t bit_rate = 0; + bit_rate = ((Info->p.codec->elements[3]) & 0x7f) << 16; + bit_rate |= (Info->p.codec->elements[4]) << 8; + bit_rate |= (Info->p.codec->elements[5]); + TRACE(1, "bit_rate = %d", bit_rate); + if (bit_rate == 0) { + bit_rate = MAX_AAC_BITRATE; + } else if (bit_rate > MAX_AAC_BITRATE) { + bit_rate = MAX_AAC_BITRATE; + } + + setconfig_codec.elements[3] |= (bit_rate >> 16) & 0x7f; + setconfig_codec.elements[4] = (bit_rate >> 8) & 0xff; + setconfig_codec.elements[5] = bit_rate & 0xff; + } +#endif + else if (Info->p.codec->codecType == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { +#if defined(A2DP_SCALABLE_ON) + // 0x75 0x00 0x00 0x00Vid + // 0x03 0x01 Codec id + if (Info->p.codec->elements[0] == 0x75 && + Info->p.codec->elements[1] == 0x00 && + Info->p.codec->elements[2] == 0x00 && + Info->p.codec->elements[3] == 0x00 && + Info->p.codec->elements[4] == 0x03 && + Info->p.codec->elements[5] == 0x01) { + memcpy(&setconfig_codec.elements[0], &a2dp_codec_scalable_elements[0], + 6); + DUMP8("%02x ", (setconfig_codec.elements), 8); + DUMP8("%02x ", &(Info->p.codec->elements[0]), 8); + setconfig_codec.elements[6] = 0x00; + // Audio format setting +#if defined(A2DP_SCALABLE_UHQ_SUPPORT) + if (Info->p.codec->elements[6] & A2DP_SCALABLE_SR_96000) { + setconfig_codec.elements[6] |= A2DP_SCALABLE_SR_96000; + } +#endif + if (Info->p.codec->elements[6] & A2DP_SCALABLE_SR_32000) { + setconfig_codec.elements[6] |= A2DP_SCALABLE_SR_32000; + } else if (Info->p.codec->elements[6] & A2DP_SCALABLE_SR_44100) { + setconfig_codec.elements[6] |= A2DP_SCALABLE_SR_44100; + } else if (Info->p.codec->elements[6] & A2DP_SCALABLE_SR_48000) { + setconfig_codec.elements[6] |= A2DP_SCALABLE_SR_48000; + } + + if (Info->p.codec->elements[6] & A2DP_SCALABLE_HQ) { + setconfig_codec.elements[6] |= A2DP_SCALABLE_HQ; + } + DUMP8("0x%02x ", setconfig_codec.elements, setconfig_codec.elemLen); + } +#endif + +#if defined(A2DP_LHDC_ON) + // 0x3A 0x05 0x00 0x00Vid + // 0x33 0x4c Codec id V3 + // 0x32 0x4c Codec id V2 + if (Info->p.codec->elements[0] == a2dp_codec_lhdc_elements[0] && + Info->p.codec->elements[1] == a2dp_codec_lhdc_elements[1] && + Info->p.codec->elements[2] == a2dp_codec_lhdc_elements[2] && + Info->p.codec->elements[3] == a2dp_codec_lhdc_elements[3] && + Info->p.codec->elements[4] == a2dp_codec_lhdc_elements[4] && + Info->p.codec->elements[5] == a2dp_codec_lhdc_elements[5]) { + memcpy(&setconfig_codec.elements[0], &a2dp_codec_lhdc_elements[0], 6); + DUMP8("%02x ", (setconfig_codec.elements), 8); + DUMP8("%02x ", &(Info->p.codec->elements[0]), 8); + + // Audio format setting + //(A2DP_LHDC_SR_96000|A2DP_LHDC_SR_48000 |A2DP_LHDC_SR_44100) | + //(A2DP_LHDC_FMT_16), + if (Info->p.codec->elements[6] & A2DP_LHDC_SR_96000) { + setconfig_codec.elements[6] |= A2DP_LHDC_SR_96000; + } else if (Info->p.codec->elements[6] & A2DP_LHDC_SR_48000) { + setconfig_codec.elements[6] |= A2DP_LHDC_SR_48000; + } else if (Info->p.codec->elements[6] & A2DP_LHDC_SR_44100) { + setconfig_codec.elements[6] |= A2DP_LHDC_SR_44100; + } + + if (Info->p.codec->elements[6] & A2DP_LHDC_FMT_16) { + setconfig_codec.elements[6] |= A2DP_LHDC_FMT_16; + } else if (Info->p.codec->elements[6] & A2DP_LHDC_FMT_24) { + setconfig_codec.elements[6] |= A2DP_LHDC_FMT_24; + } + } +#endif + +#if defined(A2DP_LDAC_ON) + // 0x2d, 0x01, 0x00, 0x00, //Vendor ID + // 0xaa, 0x00, //Codec ID + if (Info->p.codec->elements[0] == a2dp_codec_ldac_elements[0] && + Info->p.codec->elements[1] == a2dp_codec_ldac_elements[1] && + Info->p.codec->elements[2] == a2dp_codec_ldac_elements[2] && + Info->p.codec->elements[3] == a2dp_codec_ldac_elements[3] && + Info->p.codec->elements[4] == a2dp_codec_ldac_elements[4] && + Info->p.codec->elements[5] == a2dp_codec_ldac_elements[5]) { + memcpy(&setconfig_codec.elements[0], &a2dp_codec_ldac_elements[0], 6); + + DUMP8("%02x ", (setconfig_codec.elements), 8); + DUMP8("%02x ", &(Info->p.codec->elements[0]), 8); + // Audio format setting + // 3c 03 + // 34 07 + if (Info->p.codec->elements[6] & A2DP_LDAC_SR_96000) { + setconfig_codec.elements[6] |= A2DP_LDAC_SR_96000; + } else if (Info->p.codec->elements[6] & A2DP_LDAC_SR_88200) { + setconfig_codec.elements[6] |= A2DP_LDAC_SR_88200; + } else if (Info->p.codec->elements[6] & A2DP_LDAC_SR_48000) { + setconfig_codec.elements[6] |= A2DP_LDAC_SR_48000; + } else if (Info->p.codec->elements[6] & A2DP_LDAC_SR_44100) { + setconfig_codec.elements[6] |= A2DP_LDAC_SR_44100; + } + // }else if (Info->p.codec->elements[6] & + // A2DP_LDAC_SR_88200) { + // setconfig_codec.elements[6] |= A2DP_LDAC_SR_88200; + // } + + if (Info->p.codec->elements[7] & A2DP_LDAC_CM_MONO) { + setconfig_codec.elements[7] |= A2DP_LDAC_CM_MONO; + } else if (Info->p.codec->elements[7] & A2DP_LDAC_CM_DUAL) { + setconfig_codec.elements[7] |= A2DP_LDAC_CM_DUAL; + } else if (Info->p.codec->elements[7] & A2DP_LDAC_CM_STEREO) { + setconfig_codec.elements[7] |= A2DP_LDAC_CM_STEREO; + } + + TRACE(1, "setconfig_codec.elemLen = %d", setconfig_codec.elemLen); + TRACE(1, "setconfig_codec.elements[7] = 0x%02x", + setconfig_codec.elements[7]); + + DUMP8("%02x ", (setconfig_codec.elements), 8); + } +#endif + } + break; + + case BTIF_A2DP_EVENT_GET_CONFIG_IND: + TRACE(1, "::A2DP_EVENT_GET_CONFIG_IND %d\n", Info->event); +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) + // I2S or LineIn for 44.1K + setconfig_codec.elements[0] = + (setconfig_codec.elements[0] & 0xef) | A2D_SBC_IE_SAMP_FREQ_44; +#endif +#ifdef __A2DP_AVDTP_CP__ + if (Info->p.capability->type & BTIF_AVDTP_SRV_CAT_CONTENT_PROTECTION || + Info->p.cp->cpType != 0) { + TRACE(0, "support CONTENT_PROTECTION\n"); + btif_a2dp_set_stream_config(Stream, &setconfig_codec, + &setconfig_cp[stream_id_flag.id]); + } else { + TRACE(0, "no CONTENT_PROTECTION\n"); + btif_a2dp_set_stream_config(Stream, &setconfig_codec, NULL); + } +#else + btif_a2dp_set_stream_config(Stream, &setconfig_codec, NULL); +#endif + break; + case BTIF_A2DP_EVENT_STREAM_RECONFIG_IND: + TRACE(1, "::A2DP_EVENT_STREAM_RECONFIG_IND %d\n", Info->event); +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) + SOURCE_DBLOG("::BTIF_A2DP_EVENT_STREAM_RECONFIG_IND %d\n", Info->event); +#else + + if (Info->p.configReq->codec.codecType == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + current_codec_type = a2dp_get_current_codec_type( + (unsigned char *)Info->p.configReq->codec.elements); +#if defined(A2DP_SCALABLE_ON) + if (current_codec_type == A2DP_NON_CODEC_TYPE_SCALABLE) { + TRACE(0, "::##SCALABLE A2DP_EVENT_STREAM_RECONFIG_IND\n"); + a2dp_scalable_config(&(Info->p.configReq->codec.elements[0])); + } +#endif +#if defined(A2DP_LHDC_ON) + if (current_codec_type == A2DP_NON_CODEC_TYPE_LHDC) { + TRACE(0, "::##LHDC A2DP_EVENT_STREAM_RECONFIG_IND\n"); + a2dp_lhdc_config(&(Info->p.configReq->codec.elements[0])); + } +#endif +#if defined(A2DP_LDAC_ON) + if (current_codec_type == A2DP_NON_CODEC_TYPE_LDAC) { + TRACE(0, "::##LDAC A2DP_EVENT_STREAM_RECONFIG_IND\n"); + a2dp_ldac_config(&(Info->p.configReq->codec.elements[0])); + } +#endif + } + +#if defined(A2DP_AAC_ON) + if (Info->p.configReq->codec.codecType == + BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { + TRACE(0, "::##AAC A2DP_EVENT_STREAM_RECONFIG_IND\n"); + if (((Info->p.codec->elements[3]) & A2DP_AAC_OCTET3_VBR_SUPPORTED) && + (((a2dp_codec_aac_elements[3]) & A2DP_AAC_OCTET3_VBR_SUPPORTED) == + 0)) { + Info->error = BTIF_A2DP_ERR_NOT_SUPPORTED_VBR; + btif_a2dp_reconfig_stream_rsp(Stream, BTIF_A2DP_ERR_NOT_SUPPORTED_VBR, + 0); + TRACE(0, "stream reconfig: VBR UNSUPPORTED!!!!!!"); + break; + } + } +#endif + if (Info->p.configReq->codec.codecType == BTIF_AVDTP_CODEC_TYPE_SBC) { + TRACE(0, "::##SBC A2DP_EVENT_STREAM_RECONFIG_IND\n"); + TRACE( + 5, + "app_bt_device.sample_rate::elements[0] %d BITPOOL:%d/%d %02x/%02x\n", + Info->p.configReq->codec.elements[0], + Info->p.configReq->codec.elements[2], + Info->p.configReq->codec.elements[3], + Info->p.configReq->codec.elements[2], + Info->p.configReq->codec.elements[3]); + } +#endif + btif_a2dp_reconfig_stream_rsp(Stream, BTIF_A2DP_ERR_NO_ERROR, 0); + break; + case BTIF_A2DP_EVENT_STREAM_RECONFIG_CNF: + TRACE(3, "::A2DP_EVENT_STREAM_RECONFIG_CNF %d,sample rate=%x,%x\n", + Info->event, btif_a2dp_get_stream_codecCfg(Stream)->elements[0], + Info->p.codec->elements[0]); + +#if defined(A2DP_AAC_ON) + if (Info->p.configReq->codec.codecType == + BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { +#ifdef __A2DP_AVDTP_CP__ + btif_a2dp_security_control_req( + Stream, (U8 *)&a2dp_avdtpCp_aac_securityData[stream_id_flag.id][0], + 1); +#endif + TRACE(2, + "::A2DP_EVENT_STREAM_OPEN stream_id:%d, aac sample_rate " + "codec.elements 0x%x\n", + stream_id_flag.id, Info->p.configReq->codec.elements[1]); + app_bt_device.codec_type[stream_id_flag.id] = + BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC; + app_bt_device.sample_bit[stream_id_flag.id] = 16; + // convert aac sample_rate to sbc sample_rate format + if (Info->p.configReq->codec.elements[1] & + A2DP_AAC_OCTET1_SAMPLING_FREQUENCY_44100) { + TRACE(1, + "::A2DP_EVENT_STREAM_OPEN stream_id:%d, aac sample_rate 44100\n", + stream_id_flag.id); + app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_44; + } else if (Info->p.configReq->codec.elements[2] & + A2DP_AAC_OCTET2_SAMPLING_FREQUENCY_48000) { + TRACE(1, + "::A2DP_EVENT_STREAM_OPEN stream_id:%d, aac sample_rate 48000\n", + stream_id_flag.id); + app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_48; + } else { + TRACE(1, + "::A2DP_EVENT_STREAM_OPEN stream_id:%d, aac sample_rate not " + "48000 or 44100, set to 44100\n", + stream_id_flag.id); + app_bt_device.sample_rate[stream_id_flag.id] = A2D_SBC_IE_SAMP_FREQ_44; + } + + if (Info->p.configReq->codec.elements[2] & A2DP_AAC_OCTET2_CHANNELS_1) { + a2dp_channel_num[stream_id_flag.id] = 1; + } else { + a2dp_channel_num[stream_id_flag.id] = 2; + } + } else +#endif + if (Info->p.configReq->codec.codecType == + BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + current_codec_type = a2dp_get_current_codec_type( + (unsigned char *)Info->p.configReq->codec.elements); +#if defined(A2DP_SCALABLE_ON) + if (current_codec_type == A2DP_NON_CODEC_TYPE_SCALABLE) { + TRACE(0, "##codecType scalable\n"); + a2dp_scalable_config(&(Info->p.configReq->codec.elements[0])); + app_bt_device.codec_type[stream_id_flag.id] = + BTIF_AVDTP_CODEC_TYPE_NON_A2DP; + // 0x75 0x00 0x00 0x00Vid + // 0x03 0x01 Codec id + if (Info->p.codec->elements[0] == 0x75 && + Info->p.codec->elements[4] == 0x03 && + Info->p.codec->elements[5] == 0x01) { + setconfig_codec.elements = a2dp_scalable_avdtpcodec.elements; + } else { + if (Info->p.codec->pstreamflags != NULL) + Info->p.codec->pstreamflags[0] &= ~APP_A2DP_STRM_FLAG_QUERY_CODEC; + else { + ASSERT(false, "pstreamflags not init .."); + } + } + + a2dp_channel_num[stream_id_flag.id] = 2; + } +#endif +#if defined(A2DP_LHDC_ON) + if (current_codec_type == A2DP_NON_CODEC_TYPE_LHDC) { + TRACE(2, + "##codecType: LHDC Codec, Element length = %d, " + "AVDTP_MAX_CODEC_ELEM_SIZE = %d\n", + Info->p.configReq->codec.elemLen, BTIF_AVDTP_MAX_CODEC_ELEM_SIZE); + app_bt_device.codec_type[stream_id_flag.id] = + BTIF_AVDTP_CODEC_TYPE_NON_A2DP; + a2dp_channel_num[stream_id_flag.id] = 2; + a2dp_lhdc_config(&(Info->p.configReq->codec.elements[0])); + } +#endif +#if defined(A2DP_LDAC_ON) + if (current_codec_type == A2DP_NON_CODEC_TYPE_LDAC) { + TRACE(2, + "##codecType: LDAC Codec, Element length = %d, " + "AVDTP_MAX_CODEC_ELEM_SIZE = %d\n", + Info->p.configReq->codec.elemLen, BTIF_AVDTP_MAX_CODEC_ELEM_SIZE); + app_bt_device.codec_type[stream_id_flag.id] = + BTIF_AVDTP_CODEC_TYPE_NON_A2DP; + a2dp_channel_num[stream_id_flag.id] = 2; + a2dp_ldac_config(&(Info->p.configReq->codec.elements[0])); + } +#endif + } else + + { + TRACE( + 5, + "app_bt_device.sample_rate::elements[0] %d BITPOOL:%d/%d %02x/%02x\n", + Info->p.codec->elements[0], Info->p.codec->elements[2], + Info->p.codec->elements[3], Info->p.codec->elements[2], + Info->p.codec->elements[3]); + + app_bt_device.codec_type[stream_id_flag.id] = BTIF_AVDTP_CODEC_TYPE_SBC; + app_bt_device.sample_bit[stream_id_flag.id] = 16; + app_bt_device.sample_rate[stream_id_flag.id] = + (Info->p.configReq->codec.elements[0] & A2D_SBC_IE_SAMP_FREQ_MSK); + + if (Info->p.configReq->codec.elements[0] & A2D_SBC_IE_CH_MD_MONO) + a2dp_channel_num[stream_id_flag.id] = 1; + else + a2dp_channel_num[stream_id_flag.id] = 2; + } +#ifdef __A2DP_AVDTP_CP__ + if (Info->p.configReq->cp.cpType == BTIF_AVDTP_CP_TYPE_SCMS_T) { + app_bt_device.avdtp_cp[stream_id_flag.id] = 1; + } +#endif +#endif + if (btif_a2dp_is_stream_device_has_delay_reporting(Stream)) { + btif_a2dp_set_sink_delay(Stream, 150); + } + break; +#ifdef __A2DP_AVDTP_CP__ + case BTIF_A2DP_EVENT_CP_INFO: + TRACE(2, "::A2DP_EVENT_CP_INFO %d cpType: %x\n", Info->event, + Info->p.cp->cpType); + setconfig_cp[stream_id_flag.id].cpType = Info->p.cp->cpType; + setconfig_cp[stream_id_flag.id].data = Info->p.cp->data; + setconfig_cp[stream_id_flag.id].dataLen = Info->p.cp->dataLen; + if (Info->p.cp && Info->p.cp->cpType == BTIF_AVDTP_CP_TYPE_SCMS_T) { + app_bt_device.avdtp_cp[stream_id_flag.id] = 1; + } else { + app_bt_device.avdtp_cp[stream_id_flag.id] = 0; + } + btif_a2dp_set_copy_protection_enable( + Stream, app_bt_device.avdtp_cp[stream_id_flag.id]); + break; + case BTIF_A2DP_EVENT_STREAM_SECURITY_IND: + TRACE(1, "::A2DP_EVENT_STREAM_SECURITY_IND %d\n", Info->event); + DUMP8("%x ", Info->p.data, Info->len); + btif_a2dp_security_control_rsp(Stream, &Info->p.data[1], Info->len - 1, + Info->error); + break; + case BTIF_A2DP_EVENT_STREAM_SECURITY_CNF: + app_bt_device.avdtp_cp[stream_id_flag.id] = 1; + TRACE(1, "::A2DP_EVENT_STREAM_SECURITY_CNF %d\n", Info->event); + break; +#endif + +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) + case BTIF_A2DP_EVENT_STREAM_SBC_PACKET_SENT: + // TRACE(0,"@sbc be send succ"); + if (app_bt_device.src_or_snk == BT_DEVICE_SRC) { + a2dp_source_notify_send(); + } + break; +#endif + } +#if defined(IBRT) + app_tws_ibrt_profile_callback(BTIF_APP_A2DP_PROFILE_ID, (void *)Stream, + (void *)info); +#endif } -void a2dp_volume_local_set(enum BT_DEVICE_ID_T id, int8_t vol) -{ - btif_remote_device_t *remDev = NULL; - nvrec_btdevicerecord *record = NULL; - remDev = btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[id]); - if (remDev){ - if (!nv_record_btdevicerecord_find(btif_me_get_remote_device_bdaddr(remDev),&record)){ - nv_record_btdevicerecord_set_a2dp_vol(record, vol); - } - } +void a2dp_suspend_music_force(void) { + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_SBC, + BT_DEVICE_ID_1, 0); +#ifdef __BT_ONE_BRING_TWO__ + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_SBC, + BT_DEVICE_ID_2, 0); +#endif +} - if(app_bt_stream_volume_get_ptr()->a2dp_vol != vol){ +int a2dp_volume_get(enum BT_DEVICE_ID_T id) { + int vol = TGT_VOLUME_LEVEL_15; + + btif_remote_device_t *remDev = NULL; + nvrec_btdevicerecord *record = NULL; + + if (id >= BT_DEVICE_NUM) { + TRACE(2, "%s error id %d", __func__, id); + } + + remDev = btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[id]); + if (remDev && !nv_record_btdevicerecord_find( + btif_me_get_remote_device_bdaddr(remDev), &record)) { + vol = record->device_vol.a2dp_vol; + } else if (app_audio_manager_a2dp_is_active(id)) { + vol = app_bt_stream_a2dpvolume_get(); + } else { + vol = TGT_VOLUME_LEVEL_15; + } + + if (vol == TGT_VOLUME_LEVEL_MUTE) { + vol = 0; + } else { + if (vol >= TGT_VOLUME_LEVEL_15) { + vol = TGT_VOLUME_LEVEL_15; + } else if (vol <= TGT_VOLUME_LEVEL_0) { + vol = TGT_VOLUME_LEVEL_0; + } + vol = 8 * (vol - 1); + } + + if (vol > 0x7f) + vol = 0x7f; + + // TRACE(2,"get vol raw:%d %d/127", app_bt_stream_volume_get_ptr()->a2dp_vol, + // vol); + + return (vol); +} + +void a2dp_volume_local_set(enum BT_DEVICE_ID_T id, int8_t vol) { + btif_remote_device_t *remDev = NULL; + nvrec_btdevicerecord *record = NULL; + remDev = btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[id]); + if (remDev) { + if (!nv_record_btdevicerecord_find(btif_me_get_remote_device_bdaddr(remDev), + &record)) { + nv_record_btdevicerecord_set_a2dp_vol(record, vol); + } + } + + if (app_bt_stream_volume_get_ptr()->a2dp_vol != vol) { #if defined(NEW_NV_RECORD_ENABLED) - nv_record_btdevicevolume_set_a2dp_vol(app_bt_stream_volume_get_ptr(), vol); + nv_record_btdevicevolume_set_a2dp_vol(app_bt_stream_volume_get_ptr(), vol); #endif #ifndef FPGA - nv_record_touch_cause_flush(); + nv_record_touch_cause_flush(); #endif - } + } } -int a2dp_volume_set(enum BT_DEVICE_ID_T id, uint8_t vol) -{ - int dest_vol; +int a2dp_volume_set(enum BT_DEVICE_ID_T id, uint8_t vol) { + int dest_vol; - if (!vol){ - dest_vol = TGT_VOLUME_LEVEL_MUTE; - }else{ - if (0x7f == vol) - { - dest_vol = TGT_VOLUME_LEVEL_15; - } - else - { - dest_vol = (((int)vol&0x7f)<<4)/128 + 1; - } - if (dest_vol > TGT_VOLUME_LEVEL_15){ - dest_vol = TGT_VOLUME_LEVEL_15; - }else if (dest_vol < TGT_VOLUME_LEVEL_0){ - dest_vol = TGT_VOLUME_LEVEL_0; - } + if (!vol) { + dest_vol = TGT_VOLUME_LEVEL_MUTE; + } else { + if (0x7f == vol) { + dest_vol = TGT_VOLUME_LEVEL_15; + } else { + dest_vol = (((int)vol & 0x7f) << 4) / 128 + 1; } - - a2dp_volume_local_set(id, dest_vol); - if (app_audio_manager_a2dp_is_active(id)){ - app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_SET, dest_vol); + if (dest_vol > TGT_VOLUME_LEVEL_15) { + dest_vol = TGT_VOLUME_LEVEL_15; + } else if (dest_vol < TGT_VOLUME_LEVEL_0) { + dest_vol = TGT_VOLUME_LEVEL_0; } + } - TRACE(2,"put vol raw:%d/127 %d", vol, dest_vol); + a2dp_volume_local_set(id, dest_vol); + if (app_audio_manager_a2dp_is_active(id)) { + app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_SET, dest_vol); + } - return (vol); + TRACE(2, "put vol raw:%d/127 %d", vol, dest_vol); + + return (vol); } -bool a2dp_is_music_ongoing(void) -{ +bool a2dp_is_music_ongoing(void) { #ifdef __BT_ONE_BRING_TWO__ - return app_bt_device.a2dp_streamming[BT_DEVICE_ID_1] || - app_bt_device.a2dp_streamming[BT_DEVICE_ID_2]; + return app_bt_device.a2dp_streamming[BT_DEVICE_ID_1] || + app_bt_device.a2dp_streamming[BT_DEVICE_ID_2]; #else - return app_bt_device.a2dp_streamming[BT_DEVICE_ID_1]; + return app_bt_device.a2dp_streamming[BT_DEVICE_ID_1]; #endif - } -void btapp_a2dp_report_speak_gain(void) -{ +void btapp_a2dp_report_speak_gain(void) { #ifdef BTIF_AVRCP_ADVANCED_CONTROLLER - uint8_t i; - int vol; - btif_remote_device_t *remDev = NULL; - btif_link_mode_t mode = BTIF_BLM_SNIFF_MODE; + uint8_t i; + int vol; + btif_remote_device_t *remDev = NULL; + btif_link_mode_t mode = BTIF_BLM_SNIFF_MODE; - for(i=0; itransId, + TRACE(4,"btapp_a2dp_report_speak_gain transId:%d a2dp_state:%d + streamming:%d report:%02x\n", btif_get_avrcp_adv_notify(const + avrcp_callback_parms_t * + parms)(app_bt_device.avrcp_notify_rsp[i])->transId, app_bt_device.a2dp_state[i], app_bt_device.a2dp_streamming[i], app_bt_device.volume_report[i]); */ - osapi_lock_stack(); - if((vol_ctrl_done_flag[i]==TX_DONE_FLAG_INIT)||(vol_ctrl_done_flag[i]==TX_DONE_FLAG_SUCCESS)){ - remDev = btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[i]); - if (remDev){ - mode = btif_me_get_current_mode(remDev); - }else{ - mode = BTIF_BLM_SNIFF_MODE; - } - if ((app_bt_device.a2dp_state[i] == 1) && - (app_bt_device.a2dp_streamming[i] == 1) && - (app_bt_device.volume_report[i] == BTIF_AVCTP_RESPONSE_INTERIM) && - (mode == BTIF_BLM_ACTIVE_MODE)){ - app_bt_device.volume_report[i] = BTIF_AVCTP_RESPONSE_CHANGED; - // TRACE(1,"btapp_a2dp_report_speak_gain transId:%d\n", app_bt_device.avrcp_notify_rsp[i]->transId); - if (app_bt_device.avrcp_notify_rsp[i] != NULL){ + osapi_lock_stack(); + if ((vol_ctrl_done_flag[i] == TX_DONE_FLAG_INIT) || + (vol_ctrl_done_flag[i] == TX_DONE_FLAG_SUCCESS)) { + remDev = + btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[i]); + if (remDev) { + mode = btif_me_get_current_mode(remDev); + } else { + mode = BTIF_BLM_SNIFF_MODE; + } + if ((app_bt_device.a2dp_state[i] == 1) && + (app_bt_device.a2dp_streamming[i] == 1) && + (app_bt_device.volume_report[i] == BTIF_AVCTP_RESPONSE_INTERIM) && + (mode == BTIF_BLM_ACTIVE_MODE)) { + app_bt_device.volume_report[i] = BTIF_AVCTP_RESPONSE_CHANGED; + // TRACE(1,"btapp_a2dp_report_speak_gain transId:%d\n", + // app_bt_device.avrcp_notify_rsp[i]->transId); + if (app_bt_device.avrcp_notify_rsp[i] != NULL) { - btif_set_app_bt_device_avrcp_notify_rsp_ctype(app_bt_device.avrcp_notify_rsp[i], BTIF_AVCTP_RESPONSE_CHANGED); - vol = a2dp_volume_get((enum BT_DEVICE_ID_T)i); - btif_avrcp_ct_get_absolute_volume_rsp(app_bt_device.avrcp_channel[i], app_bt_device.avrcp_notify_rsp[i], vol); - vol_ctrl_done_flag[i] = TX_DONE_FLAG_TXING; - btif_avrcp_recheck_vol_ctrl_flag(vol_ctrl_done_flag+i); - } - } + btif_set_app_bt_device_avrcp_notify_rsp_ctype( + app_bt_device.avrcp_notify_rsp[i], BTIF_AVCTP_RESPONSE_CHANGED); + vol = a2dp_volume_get((enum BT_DEVICE_ID_T)i); + btif_avrcp_ct_get_absolute_volume_rsp( + app_bt_device.avrcp_channel[i], app_bt_device.avrcp_notify_rsp[i], + vol); + vol_ctrl_done_flag[i] = TX_DONE_FLAG_TXING; + btif_avrcp_recheck_vol_ctrl_flag(vol_ctrl_done_flag + i); } - osapi_unlock_stack(); + } } + osapi_unlock_stack(); + } #endif } - - - - -extern "C" bool avdtp_Get_aacEnable_Flag( btif_remote_device_t* remDev, btif_avdtp_stream_t *strm) -{ - TRACE(2,"%s,version=%x", __func__, btif_me_get_remote_device_version(remDev)[1] ); -#if 0//defined(A2DP_AAC_ON) +extern "C" bool avdtp_Get_aacEnable_Flag(btif_remote_device_t *remDev, + btif_avdtp_stream_t *strm) { + TRACE(2, "%s,version=%x", __func__, + btif_me_get_remote_device_version(remDev)[1]); +#if 0 // defined(A2DP_AAC_ON) if(((remDev->remoteVersion[1] == 0x0f) && (remDev->remoteVersion[2] == 0)) || strm->codec->codecType !=AVDTP_CODEC_TYPE_MPEG2_4_AAC){ return TRUE; }else return FALSE; #else - return TRUE; + return TRUE; #endif - - } - - #ifdef __TWS__ -void app_AVRCP_SendCustomCmdToMobile(uint8_t* ptrData, uint32_t len) -{ - if (is_slave_tws_mode()) - { - return; - } +void app_AVRCP_SendCustomCmdToMobile(uint8_t *ptrData, uint32_t len) { + if (is_slave_tws_mode()) { + return; + } - btif_avrcp_send_custom_cmd_generic(app_bt_device.avrcp_channel[BT_DEVICE_ID_1], ptrData, len); + btif_avrcp_send_custom_cmd_generic( + app_bt_device.avrcp_channel[BT_DEVICE_ID_1], ptrData, len); } - -void app_AVRCP_SendCustomCmdToTws(uint8_t* ptrData, uint32_t len) -{ - if (is_slave_tws_mode()) - { - btif_avrcp_send_custom_cmd_generic(app_bt_device.avrcp_channel[BT_DEVICE_ID_1], ptrData, len); - } - else if (is_master_tws_mode()) - { - btif_avrcp_channel_t* chnl = btif_get_avrcp_channel(tws_get_avrcp_channel_hdl()); - btif_avrcp_send_custom_cmd_generic(chnl, ptrData, len); - } +void app_AVRCP_SendCustomCmdToTws(uint8_t *ptrData, uint32_t len) { + if (is_slave_tws_mode()) { + btif_avrcp_send_custom_cmd_generic( + app_bt_device.avrcp_channel[BT_DEVICE_ID_1], ptrData, len); + } else if (is_master_tws_mode()) { + btif_avrcp_channel_t *chnl = + btif_get_avrcp_channel(tws_get_avrcp_channel_hdl()); + btif_avrcp_send_custom_cmd_generic(chnl, ptrData, len); + } } #endif -static void app_AVRCP_sendCustomCmdRsp(uint8_t device_id, btif_avrcp_channel_t *chnl, uint8_t isAccept, uint8_t transId) -{ - if (app_bt_device.avrcp_control_rsp[device_id] == NULL) - { - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_control_rsp[device_id]); - } +static void app_AVRCP_sendCustomCmdRsp(uint8_t device_id, + btif_avrcp_channel_t *chnl, + uint8_t isAccept, uint8_t transId) { + if (app_bt_device.avrcp_control_rsp[device_id] == NULL) { + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_control_rsp[device_id]); + } + btif_avrcp_set_control_rsp_cmd(app_bt_device.avrcp_control_rsp[device_id], + transId, BTIF_AVCTP_RESPONSE_ACCEPTED); - btif_avrcp_set_control_rsp_cmd(app_bt_device.avrcp_control_rsp[device_id],transId, BTIF_AVCTP_RESPONSE_ACCEPTED); - - btif_avrcp_ct_accept_custom_cmd_rsp(chnl, app_bt_device.avrcp_control_rsp[device_id], isAccept); + btif_avrcp_ct_accept_custom_cmd_rsp( + chnl, app_bt_device.avrcp_control_rsp[device_id], isAccept); } -static void app_AVRCP_CustomCmd_Received(uint8_t* ptrData, uint32_t len) -{ - TRACE(1,"AVRCP Custom Command Received %d bytes data:", len); - DUMP8("0x%02x ", ptrData, len); +static void app_AVRCP_CustomCmd_Received(uint8_t *ptrData, uint32_t len) { + TRACE(1, "AVRCP Custom Command Received %d bytes data:", len); + DUMP8("0x%02x ", ptrData, len); } - - - diff --git a/services/bt_app/app_a2dp_source.cpp b/services/bt_app/app_a2dp_source.cpp index 2e00c6c..592db5d 100644 --- a/services/bt_app/app_a2dp_source.cpp +++ b/services/bt_app/app_a2dp_source.cpp @@ -13,34 +13,28 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) #include "app_a2dp_source.h" -#include "app_overlay.h" #include "a2dp_api.h" - - +#include "app_overlay.h" uint8_t *a2dp_linein_buff; -static char a2dp_transmit_buffer[A2DP_TRANS_SIZE]; +static char a2dp_transmit_buffer[A2DP_TRANS_SIZE]; -sbcbank_t sbcbank; +sbcbank_t sbcbank; -A2DP_SOURCE_STRUCT a2dp_source; +A2DP_SOURCE_STRUCT a2dp_source; - -static sbcpack_t *get_sbcPacket(void) -{ - int index = sbcbank.free; - sbcbank.free +=1; - if(sbcbank.free == 1) { - sbcbank.free = 0; - } - return &(sbcbank.sbcpacks[index]); +static sbcpack_t *get_sbcPacket(void) { + int index = sbcbank.free; + sbcbank.free += 1; + if (sbcbank.free == 1) { + sbcbank.free = 0; + } + return &(sbcbank.sbcpacks[index]); } - - #if 0 typedef struct { AvrcpAdvancedPdu pdu; @@ -51,21 +45,26 @@ typedef struct { extern osPoolId app_a2dp_avrcpadvancedpdu_mempool; -#define app_a2dp_avrcpadvancedpdu_mempool_init() do{ \ - if (app_a2dp_avrcpadvancedpdu_mempool == NULL) \ - app_a2dp_avrcpadvancedpdu_mempool = osPoolCreate(osPool(app_a2dp_avrcpadvancedpdu_mempool)); \ - }while(0); +#define app_a2dp_avrcpadvancedpdu_mempool_init() \ + do { \ + if (app_a2dp_avrcpadvancedpdu_mempool == NULL) \ + app_a2dp_avrcpadvancedpdu_mempool = \ + osPoolCreate(osPool(app_a2dp_avrcpadvancedpdu_mempool)); \ + } while (0); -#define app_a2dp_avrcpadvancedpdu_mempool_calloc(buf) do{ \ - APP_A2DP_AVRCPADVANCEDPDU * avrcpadvancedpdu; \ - avrcpadvancedpdu = (APP_A2DP_AVRCPADVANCEDPDU *)osPoolCAlloc(app_a2dp_avrcpadvancedpdu_mempool); \ - buf = &(avrcpadvancedpdu->pdu); \ - buf->parms = avrcpadvancedpdu->para_buf; \ - }while(0); +#define app_a2dp_avrcpadvancedpdu_mempool_calloc(buf) \ + do { \ + APP_A2DP_AVRCPADVANCEDPDU *avrcpadvancedpdu; \ + avrcpadvancedpdu = (APP_A2DP_AVRCPADVANCEDPDU *)osPoolCAlloc( \ + app_a2dp_avrcpadvancedpdu_mempool); \ + buf = &(avrcpadvancedpdu->pdu); \ + buf->parms = avrcpadvancedpdu->para_buf; \ + } while (0); -#define app_a2dp_avrcpadvancedpdu_mempool_free(buf) do{ \ - osPoolFree(app_a2dp_avrcpadvancedpdu_mempool, buf); \ - }while(0); +#define app_a2dp_avrcpadvancedpdu_mempool_free(buf) \ + do { \ + osPoolFree(app_a2dp_avrcpadvancedpdu_mempool, buf); \ + } while (0); void a2dp_source_volume_local_set(int8_t vol) @@ -256,66 +255,54 @@ void avrcp_source_callback_TG(AvrcpChannel *chnl, const AvrcpCallbackParms *Parm osMutexId a2dp_source_mutex_id = NULL; osMutexDef(a2dp_source_mutex); -static void a2dp_source_mutex_lock(void) -{ - osMutexWait(a2dp_source_mutex_id, osWaitForever); +static void a2dp_source_mutex_lock(void) { + osMutexWait(a2dp_source_mutex_id, osWaitForever); } -static void a2dp_source_mutex_unlock(void) -{ - osMutexRelease(a2dp_source_mutex_id); +static void a2dp_source_mutex_unlock(void) { + osMutexRelease(a2dp_source_mutex_id); } -static void a2dp_source_sem_lock(a2dp_source_lock_t * lock) -{ - osSemaphoreWait(lock->_osSemaphoreId, osWaitForever); +static void a2dp_source_sem_lock(a2dp_source_lock_t *lock) { + osSemaphoreWait(lock->_osSemaphoreId, osWaitForever); } -static void a2dp_source_sem_unlock(a2dp_source_lock_t * lock) -{ +static void a2dp_source_sem_unlock(a2dp_source_lock_t *lock) { - osSemaphoreRelease(lock->_osSemaphoreId); + osSemaphoreRelease(lock->_osSemaphoreId); } - - -static void a2dp_source_reset_send_lock(void) -{ - PSCB p_scb =(PSCB)(a2dp_source.sbc_send_lock._osSemaphoreDef.semaphore); - uint32_t lock = int_lock(); - p_scb->tokens = 0; - int_unlock(lock); +static void a2dp_source_reset_send_lock(void) { + PSCB p_scb = (PSCB)(a2dp_source.sbc_send_lock._osSemaphoreDef.semaphore); + uint32_t lock = int_lock(); + p_scb->tokens = 0; + int_unlock(lock); } - -static bool a2dp_source_is_send_wait(void) -{ - bool ret = false; - uint32_t lock = int_lock(); - PSCB p_scb =(PSCB)(a2dp_source.sbc_send_lock._osSemaphoreDef.semaphore); - if(p_scb->p_lnk){ - ret = true; - } - int_unlock(lock); - return ret; +static bool a2dp_source_is_send_wait(void) { + bool ret = false; + uint32_t lock = int_lock(); + PSCB p_scb = (PSCB)(a2dp_source.sbc_send_lock._osSemaphoreDef.semaphore); + if (p_scb->p_lnk) { + ret = true; + } + int_unlock(lock); + return ret; } +static void a2dp_source_wait_pcm_data(void) { -static void a2dp_source_wait_pcm_data(void) -{ - - a2dp_source_lock_t *lock = &(a2dp_source.data_lock); - PSCB p_scb =(PSCB)(lock->_osSemaphoreDef.semaphore); - uint32_t iflag = int_lock(); - p_scb->tokens = 0; - int_unlock(iflag); - a2dp_source_sem_lock(lock); + a2dp_source_lock_t *lock = &(a2dp_source.data_lock); + PSCB p_scb = (PSCB)(lock->_osSemaphoreDef.semaphore); + uint32_t iflag = int_lock(); + p_scb->tokens = 0; + int_unlock(iflag); + a2dp_source_sem_lock(lock); } -static void a2dp_source_put_data(void) -{ - a2dp_source_lock_t *lock = &(a2dp_source.data_lock); - a2dp_source_sem_unlock(lock); +static void a2dp_source_put_data(void) { + a2dp_source_lock_t *lock = &(a2dp_source.data_lock); + a2dp_source_sem_unlock(lock); } #if 0 @@ -331,135 +318,117 @@ static void a2dp_source_unlock_sbcsending(void * channel) } #endif -static int32_t a2dp_source_wait_sent(uint32_t timeout) -{ - int32_t ret = 0; - a2dp_source_lock_t *lock = &(a2dp_source.sbc_send_lock); - a2dp_source_reset_send_lock(); - ret = osSemaphoreWait(lock->_osSemaphoreId, timeout); - return ret; - +static int32_t a2dp_source_wait_sent(uint32_t timeout) { + int32_t ret = 0; + a2dp_source_lock_t *lock = &(a2dp_source.sbc_send_lock); + a2dp_source_reset_send_lock(); + ret = osSemaphoreWait(lock->_osSemaphoreId, timeout); + return ret; } -void a2dp_source_notify_send(void) -{ - if (a2dp_source_is_send_wait()){ //task wait lock - // TWS_DBLOG("\nNOTIFY SEND\n"); - a2dp_source_sem_unlock(&(a2dp_source.sbc_send_lock)); - } - +void a2dp_source_notify_send(void) { + if (a2dp_source_is_send_wait()) { // task wait lock + // TWS_DBLOG("\nNOTIFY SEND\n"); + a2dp_source_sem_unlock(&(a2dp_source.sbc_send_lock)); + } } +// loop write +static int A2dpSourceEnCQueue(CQueue *Q, CQItemType *e, unsigned int len) { + int status = CQ_OK; + if (AvailableOfCQueue(Q) < (int)len) { + Q->write = 0; + Q->len = 0; + Q->read = 0; + status = CQ_ERR; + } else { + status = CQ_OK; + } -//loop write -static int A2dpSourceEnCQueue(CQueue *Q, CQItemType *e, unsigned int len) -{ - int status=CQ_OK; - if (AvailableOfCQueue(Q) < (int)len) { - Q->write=0; - Q->len=0; - Q->read=0; - status=CQ_ERR; - } - else - { - status=CQ_OK; - } + Q->len += len; - Q->len += len; + while (len > 0) { + Q->base[Q->write] = *e; - while(len > 0) { - Q->base[Q->write] = *e; + ++Q->write; + ++e; + --len; - ++Q->write; - ++e; - --len; + if (Q->write >= Q->size) + Q->write = 0; + } - if(Q->write >= Q->size) - Q->write = 0; - } + // TRACE(1,"Q->len:%d ", Q->len); - //TRACE(1,"Q->len:%d ", Q->len); - - return status; + return status; } - - - -static int a2dp_source_pcm_buffer_write(uint8_t * pcm_buf, uint16_t len) -{ - int status; - //TWS_DBLOG("\nenter: %s %d\n",__FUNCTION__,__LINE__); - a2dp_source_mutex_lock(); - status = A2dpSourceEnCQueue(&(a2dp_source.pcm_queue), pcm_buf, len); - a2dp_source_mutex_unlock(); - //TWS_DBLOG("\nexit: %s %d\n",__FUNCTION__,__LINE__); - return status; +static int a2dp_source_pcm_buffer_write(uint8_t *pcm_buf, uint16_t len) { + int status; + // TWS_DBLOG("\nenter: %s %d\n",__FUNCTION__,__LINE__); + a2dp_source_mutex_lock(); + status = A2dpSourceEnCQueue(&(a2dp_source.pcm_queue), pcm_buf, len); + a2dp_source_mutex_unlock(); + // TWS_DBLOG("\nexit: %s %d\n",__FUNCTION__,__LINE__); + return status; } -static int a2dp_source_pcm_buffer_read(uint8_t *buff, uint16_t len) -{ - uint8_t *e1 = NULL, *e2 = NULL; - unsigned int len1 = 0, len2 = 0; - int status; - a2dp_source_mutex_lock(); - status = PeekCQueue(&(a2dp_source.pcm_queue), len, &e1, &len1, &e2, &len2); - if (len==(len1+len2)){ - memcpy(buff,e1,len1); - memcpy(buff+len1,e2,len2); - DeCQueue(&(a2dp_source.pcm_queue), 0, len); - }else{ - //SOURCE_DBLOG("memset buffer"); - memset(buff, 0x00, len); - status = -1; - } - a2dp_source_mutex_unlock(); - return status; +static int a2dp_source_pcm_buffer_read(uint8_t *buff, uint16_t len) { + uint8_t *e1 = NULL, *e2 = NULL; + unsigned int len1 = 0, len2 = 0; + int status; + a2dp_source_mutex_lock(); + status = PeekCQueue(&(a2dp_source.pcm_queue), len, &e1, &len1, &e2, &len2); + if (len == (len1 + len2)) { + memcpy(buff, e1, len1); + memcpy(buff + len1, e2, len2); + DeCQueue(&(a2dp_source.pcm_queue), 0, len); + } else { + // SOURCE_DBLOG("memset buffer"); + memset(buff, 0x00, len); + status = -1; + } + a2dp_source_mutex_unlock(); + return status; } -uint32_t a2dp_source_linein_more_pcm_data(uint8_t * pcm_buf, uint32_t len) -{ +uint32_t a2dp_source_linein_more_pcm_data(uint8_t *pcm_buf, uint32_t len) { #if 1 - int status; - status = a2dp_source_pcm_buffer_write(pcm_buf,len); - //pcm data from adc - //DUMP8("%02x ",pcm_buf, 10); - if(status !=CQ_OK) - { - SOURCE_DBLOG("linin buff overflow!"); - } - a2dp_source_put_data(); - return len; + int status; + status = a2dp_source_pcm_buffer_write(pcm_buf, len); + // pcm data from adc + // DUMP8("%02x ",pcm_buf, 10); + if (status != CQ_OK) { + SOURCE_DBLOG("linin buff overflow!"); + } + a2dp_source_put_data(); + return len; #else -int status; -status = a2dp_source_pcm_buffer_write(pcm_buf,len); -//pcm data from adc -//DUMP8("%02x ",pcm_buf, 10); -if(status !=CQ_OK) -{ - SOURCE_DBLOG("linin buff overflow!"); -} -if(((app_bt_device.input_onoff==1)&&(a2dp_source.pcm_queue.len >10*1024))||(app_bt_device.input_onoff==2)) -{ - a2dp_source_put_data(); - app_bt_device.input_onoff=2; -} + int status; + status = a2dp_source_pcm_buffer_write(pcm_buf, len); + // pcm data from adc + // DUMP8("%02x ",pcm_buf, 10); + if (status != CQ_OK) { + SOURCE_DBLOG("linin buff overflow!"); + } + if (((app_bt_device.input_onoff == 1) && + (a2dp_source.pcm_queue.len > 10 * 1024)) || + (app_bt_device.input_onoff == 2)) { + a2dp_source_put_data(); + app_bt_device.input_onoff = 2; + } -return len; + return len; #endif } - static btif_handler a2dp_source_handler; -static uint8_t app_a2dp_source_find_process=0; +static uint8_t app_a2dp_source_find_process = 0; - -void app_a2dp_source_stop_find(void) -{ - app_a2dp_source_find_process=0; - //ME_UnregisterGlobalHandler(&a2dp_source_handler); +void app_a2dp_source_stop_find(void) { + app_a2dp_source_find_process = 0; + // ME_UnregisterGlobalHandler(&a2dp_source_handler); } #if 0 @@ -514,7 +483,8 @@ static void bt_a2dp_source_call_back(const BtEvent* event) case BTEVENT_LINK_CONNECT_CNF: case BTEVENT_LINK_CONNECT_IND: SOURCE_DBLOG("CONNECT_IND/CNF evt:%d errCode:0x%0x newRole:%d activeCons:%d",event->eType, event->errCode, event->p.remDev->role, MEC(activeCons)); -#if defined(__BTIF_EARPHONE__) && defined(__BTIF_AUTOPOWEROFF__) && !defined(FPGA) +#if defined(__BTIF_EARPHONE__) && defined(__BTIF_AUTOPOWEROFF__) && \ + !defined(FPGA) if (MEC(activeCons) == 0){ app_start_10_second_timer(APP_POWEROFF_TIMER_ID); }else{ @@ -540,137 +510,133 @@ static void bt_a2dp_source_call_back(const BtEvent* event) } #else -uint8_t source_bt_addr[6]={0x88,0xaa,0x33,0x22,0x11,0x11}; -//uint8_t source_bt_addr[6]={0x85,0x7e,0xaa,0x3c,0xd0,0xe8}; +uint8_t source_bt_addr[6] = {0x88, 0xaa, 0x33, 0x22, 0x11, 0x11}; +// uint8_t source_bt_addr[6]={0x85,0x7e,0xaa,0x3c,0xd0,0xe8}; -static void bt_a2dp_source_call_back(const btif_event_t* Event) -{ +static void bt_a2dp_source_call_back(const btif_event_t *Event) { - uint8_t etype = btif_me_get_callback_event_type(Event); - btif_remote_device_t *remDev; + uint8_t etype = btif_me_get_callback_event_type(Event); + btif_remote_device_t *remDev; + switch (etype) { + case BTIF_BTEVENT_HCI_COMMAND_SENT: + case BTIF_BTEVENT_ACL_DATA_NOT_ACTIVE: + return; + case BTIF_BTEVENT_ACL_DATA_ACTIVE: - switch (etype) { - case BTIF_BTEVENT_HCI_COMMAND_SENT: - case BTIF_BTEVENT_ACL_DATA_NOT_ACTIVE: - return; - case BTIF_BTEVENT_ACL_DATA_ACTIVE: + btif_cmgr_handler_t *cmgrHandler; + /* Start the sniff timer */ + cmgrHandler = + btif_cmgr_get_acl_handler(btif_me_get_callback_event_rem_dev(Event)); + if (cmgrHandler) + app_bt_CMGR_SetSniffTimer(cmgrHandler, NULL, BTIF_CMGR_SNIFF_TIMER); + return; + } - btif_cmgr_handler_t *cmgrHandler; - /* Start the sniff timer */ - cmgrHandler = btif_cmgr_get_acl_handler(btif_me_get_callback_event_rem_dev( Event)); - if (cmgrHandler) - app_bt_CMGR_SetSniffTimer(cmgrHandler, NULL, BTIF_CMGR_SNIFF_TIMER); - return; + TRACE(1, "SRC app_bt_golbal_handle evt = %d", etype); + + switch (etype) { + case BTIF_BTEVENT_NAME_RESULT: + SOURCE_DBLOG("\n%s %d BTEVENT_NAME_RESULT\n", __FUNCTION__, __LINE__); + break; + case BTIF_BTEVENT_INQUIRY_RESULT: + remDev = btif_me_get_callback_event_rem_dev(Event); + SOURCE_DBLOG("\n%s %d BTEVENT_INQUIRY_RESULT\n", __FUNCTION__, __LINE__); + DUMP8("%02x ", btif_me_get_callback_event_inq_result_bd_addr_addr(Event), + 6); + SOURCE_DBLOG("inqmode = %x", + btif_me_get_callback_event_inq_result_inq_mode(Event)); + DUMP8("%02x ", btif_me_get_callback_event_inq_result_ext_inq_resp(Event), + 20); + SOURCE_DBLOG("classdevice=%x", + btif_me_get_callback_event_inq_result_classofdevice(Event)); + /// check the class of device to find the handfree device + // if(btif_me_get_callback_event_inq_result_classofdevice(Event) & + // BTIF_COD_MAJOR_AUDIO) + if ((btif_me_get_callback_event_inq_result_classofdevice(Event) & + BTIF_COD_MAJOR_AUDIO) && + (!memcmp(btif_me_get_callback_event_inq_result_bd_addr_addr(Event), + source_bt_addr, 6))) { + memcpy(app_bt_device.inquried_snk_bdAddr.addr, + btif_me_get_callback_event_inq_result_bd_addr_addr(Event), 6); + DUMP8("%02x ", app_bt_device.inquried_snk_bdAddr.addr, 6); + btif_me_cancel_inquiry(); + app_a2dp_source_stop_find(); } - TRACE(1,"SRC app_bt_golbal_handle evt = %d",etype); - - switch(etype){ - case BTIF_BTEVENT_NAME_RESULT: - SOURCE_DBLOG("\n%s %d BTEVENT_NAME_RESULT\n",__FUNCTION__,__LINE__); - break; - case BTIF_BTEVENT_INQUIRY_RESULT: - remDev=btif_me_get_callback_event_rem_dev(Event); - SOURCE_DBLOG("\n%s %d BTEVENT_INQUIRY_RESULT\n",__FUNCTION__,__LINE__); - DUMP8("%02x ", btif_me_get_callback_event_inq_result_bd_addr_addr(Event), 6); - SOURCE_DBLOG("inqmode = %x",btif_me_get_callback_event_inq_result_inq_mode(Event)); - DUMP8("%02x ", btif_me_get_callback_event_inq_result_ext_inq_resp(Event), 20); - SOURCE_DBLOG("classdevice=%x",btif_me_get_callback_event_inq_result_classofdevice(Event)); - ///check the class of device to find the handfree device - //if(btif_me_get_callback_event_inq_result_classofdevice(Event) & BTIF_COD_MAJOR_AUDIO) - if((btif_me_get_callback_event_inq_result_classofdevice(Event) & BTIF_COD_MAJOR_AUDIO) && \ - (!memcmp(btif_me_get_callback_event_inq_result_bd_addr_addr(Event),source_bt_addr,6))) - { - memcpy(app_bt_device.inquried_snk_bdAddr.addr,btif_me_get_callback_event_inq_result_bd_addr_addr(Event),6); - DUMP8("%02x ",app_bt_device.inquried_snk_bdAddr.addr, 6); - btif_me_cancel_inquiry(); - app_a2dp_source_stop_find(); - } - - break; - case BTIF_BTEVENT_INQUIRY_COMPLETE: - SOURCE_DBLOG("\n%s %d BTEVENT_INQUIRY_COMPLETE\n",__FUNCTION__,__LINE__); - app_a2dp_source_stop_find(); - break; - /** The Inquiry process is canceled. */ - case BTIF_BTEVENT_INQUIRY_CANCELED: - SOURCE_DBLOG("\n%s %d BTEVENT_INQUIRY_CANCELED\n",__FUNCTION__,__LINE__); - SOURCE_DBLOG("start to connect peer device"); - btif_a2dp_open_stream(app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream, (bt_bdaddr_t *)&app_bt_device.inquried_snk_bdAddr); - break; - case BTIF_BTEVENT_LINK_CONNECT_CNF: - case BTIF_BTEVENT_LINK_CONNECT_IND: - SOURCE_DBLOG("CONNECT_IND/CNF evt:%d errCode:0x%0x newRole:%d activeCons:%d",etype,btif_me_get_callback_event_err_code(Event),btif_me_get_remote_device_role(btif_me_get_callback_event_rem_dev(Event)),btif_me_get_activeCons()); -#if defined(__BTIF_EARPHONE__) && defined(__BTIF_AUTOPOWEROFF__) && !defined(FPGA) - if (btif_me_get_activeCons() == 0){ - app_start_10_second_timer(APP_POWEROFF_TIMER_ID); - }else{ - app_stop_10_second_timer(APP_POWEROFF_TIMER_ID); - } + break; + case BTIF_BTEVENT_INQUIRY_COMPLETE: + SOURCE_DBLOG("\n%s %d BTEVENT_INQUIRY_COMPLETE\n", __FUNCTION__, __LINE__); + app_a2dp_source_stop_find(); + break; + /** The Inquiry process is canceled. */ + case BTIF_BTEVENT_INQUIRY_CANCELED: + SOURCE_DBLOG("\n%s %d BTEVENT_INQUIRY_CANCELED\n", __FUNCTION__, __LINE__); + SOURCE_DBLOG("start to connect peer device"); + btif_a2dp_open_stream( + app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream, + (bt_bdaddr_t *)&app_bt_device.inquried_snk_bdAddr); + break; + case BTIF_BTEVENT_LINK_CONNECT_CNF: + case BTIF_BTEVENT_LINK_CONNECT_IND: + SOURCE_DBLOG( + "CONNECT_IND/CNF evt:%d errCode:0x%0x newRole:%d activeCons:%d", etype, + btif_me_get_callback_event_err_code(Event), + btif_me_get_remote_device_role( + btif_me_get_callback_event_rem_dev(Event)), + btif_me_get_activeCons()); +#if defined(__BTIF_EARPHONE__) && defined(__BTIF_AUTOPOWEROFF__) && \ + !defined(FPGA) + if (btif_me_get_activeCons() == 0) { + app_start_10_second_timer(APP_POWEROFF_TIMER_ID); + } else { + app_stop_10_second_timer(APP_POWEROFF_TIMER_ID); + } #endif - if (btif_me_get_activeCons() > 1){ - remDev=btif_me_get_callback_event_rem_dev(Event); - app_bt_MeDisconnectLink(remDev); - } - default: - //SOURCE_DBLOG("\n%s %d etype:%d\n",__FUNCTION__,__LINE__,event->eType); - break; - + if (btif_me_get_activeCons() > 1) { + remDev = btif_me_get_callback_event_rem_dev(Event); + app_bt_MeDisconnectLink(remDev); } + default: + // SOURCE_DBLOG("\n%s %d etype:%d\n",__FUNCTION__,__LINE__,event->eType); + break; + } - app_bt_role_manager_process(Event); - app_bt_accessible_manager_process(Event); - app_bt_sniff_manager_process(Event); - - //SOURCE_DBLOG("\nexit: %s %d\n",__FUNCTION__,__LINE__); + app_bt_role_manager_process(Event); + app_bt_accessible_manager_process(Event); + app_bt_sniff_manager_process(Event); + // SOURCE_DBLOG("\nexit: %s %d\n",__FUNCTION__,__LINE__); } - #endif - - - -void app_a2dp_start_stream(void) -{ - btif_a2dp_start_stream(&app_bt_device.a2dp_stream[BT_DEVICE_ID_1]); - +void app_a2dp_start_stream(void) { + btif_a2dp_start_stream(&app_bt_device.a2dp_stream[BT_DEVICE_ID_1]); } - - -void app_a2dp_suspend_stream(void) -{ - btif_a2dp_suspend_stream(&app_bt_device.a2dp_stream[BT_DEVICE_ID_1]); +void app_a2dp_suspend_stream(void) { + btif_a2dp_suspend_stream(&app_bt_device.a2dp_stream[BT_DEVICE_ID_1]); } +static void _find_a2dp_sink_peer_device_start(void) { + SOURCE_DBLOG("\nenter: %s %d\n", __FUNCTION__, __LINE__); + bt_status_t state; + if (app_a2dp_source_find_process == 0 && app_bt_device.a2dp_state[0] == 0) { + app_a2dp_source_find_process = 1; -static void _find_a2dp_sink_peer_device_start(void) -{ - SOURCE_DBLOG("\nenter: %s %d\n",__FUNCTION__,__LINE__); - bt_status_t state; - if(app_a2dp_source_find_process ==0 && app_bt_device.a2dp_state[0]==0) - { - app_a2dp_source_find_process = 1; - - again: - state = btif_me_inquiry(BTIF_BT_IAC_GIAC, 30, 0); - SOURCE_DBLOG("\n%s %d\n",__FUNCTION__,__LINE__); - if (state != BT_STS_PENDING){ - osDelay(500); - goto again; - } - SOURCE_DBLOG("\n%s %d\n",__FUNCTION__,__LINE__); + again: + state = btif_me_inquiry(BTIF_BT_IAC_GIAC, 30, 0); + SOURCE_DBLOG("\n%s %d\n", __FUNCTION__, __LINE__); + if (state != BT_STS_PENDING) { + osDelay(500); + goto again; } + SOURCE_DBLOG("\n%s %d\n", __FUNCTION__, __LINE__); + } } -void app_a2dp_source_find_sink(void) -{ - _find_a2dp_sink_peer_device_start(); -} - +void app_a2dp_source_find_sink(void) { _find_a2dp_sink_peer_device_start(); } static bool need_init_encoder = true; //__PSRAMDATA static SbcStreamInfo StreamInfo = {0}; @@ -678,195 +644,194 @@ static btif_sbc_stream_info_short_t StreamInfo = {0}; static btif_sbc_encoder_t sbc_encoder; - -static uint8_t app_a2dp_source_samplerate_2_sbcenc_type(enum AUD_SAMPRATE_T sample_rate) -{ - uint8_t rate=BTIF_SBC_CHNL_SAMPLE_FREQ_16; - switch(sample_rate) - { - case AUD_SAMPRATE_16000: - rate = BTIF_SBC_CHNL_SAMPLE_FREQ_16; - break; - case AUD_SAMPRATE_32000: - rate = BTIF_SBC_CHNL_SAMPLE_FREQ_32; - break; - case AUD_SAMPRATE_44100: - rate = BTIF_SBC_CHNL_SAMPLE_FREQ_44_1; - break; - case AUD_SAMPRATE_48000: - rate = BTIF_SBC_CHNL_SAMPLE_FREQ_48; - break; - default: - TRACE(0,"error! sbc enc don't support other samplerate"); - break; - } - SOURCE_DBLOG("\n%s %d rate = %x\n",__FUNCTION__,__LINE__,rate); - return rate; - +static uint8_t +app_a2dp_source_samplerate_2_sbcenc_type(enum AUD_SAMPRATE_T sample_rate) { + uint8_t rate = BTIF_SBC_CHNL_SAMPLE_FREQ_16; + switch (sample_rate) { + case AUD_SAMPRATE_16000: + rate = BTIF_SBC_CHNL_SAMPLE_FREQ_16; + break; + case AUD_SAMPRATE_32000: + rate = BTIF_SBC_CHNL_SAMPLE_FREQ_32; + break; + case AUD_SAMPRATE_44100: + rate = BTIF_SBC_CHNL_SAMPLE_FREQ_44_1; + break; + case AUD_SAMPRATE_48000: + rate = BTIF_SBC_CHNL_SAMPLE_FREQ_48; + break; + default: + TRACE(0, "error! sbc enc don't support other samplerate"); + break; + } + SOURCE_DBLOG("\n%s %d rate = %x\n", __FUNCTION__, __LINE__, rate); + return rate; } #if 1 -static void a2dp_source_send_sbc_packet(void) -{ - uint32_t frame_size = 512; - uint32_t frame_num = A2DP_TRANS_SIZE/frame_size; -// a2dp_source.lock_stream(&(tws.tws_source)); - uint16_t byte_encoded = 0; -// uint16_t pcm_frame_size = 512/2; - unsigned short enc_len = 0; - bt_status_t status = BT_STS_FAILED; +static void a2dp_source_send_sbc_packet(void) { + uint32_t frame_size = 512; + uint32_t frame_num = A2DP_TRANS_SIZE / frame_size; + // a2dp_source.lock_stream(&(tws.tws_source)); + uint16_t byte_encoded = 0; + // uint16_t pcm_frame_size = 512/2; + unsigned short enc_len = 0; + bt_status_t status = BT_STS_FAILED; - int lock = int_lock(); - sbcpack_t *sbcpack = get_sbcPacket(); - btif_a2dp_sbc_packet_t *sbcPacket = &(sbcpack->sbcPacket); - sbcPacket->data = (U8 *)sbcpack->buffer; - memcpy(sbcpack->buffer,a2dp_transmit_buffer,A2DP_TRANS_SIZE); + int lock = int_lock(); + sbcpack_t *sbcpack = get_sbcPacket(); + btif_a2dp_sbc_packet_t *sbcPacket = &(sbcpack->sbcPacket); + sbcPacket->data = (U8 *)sbcpack->buffer; + memcpy(sbcpack->buffer, a2dp_transmit_buffer, A2DP_TRANS_SIZE); -// sbcPacket->dataLen = len; -// sbcPacket->frameSize = len/frame_num; + // sbcPacket->dataLen = len; + // sbcPacket->frameSize = len/frame_num; - btif_sbc_pcm_data_t PcmEncData; + btif_sbc_pcm_data_t PcmEncData; - if(need_init_encoder) { - btif_sbc_init_encoder(&sbc_encoder); - sbc_encoder.streamInfo.numChannels = 2; - sbc_encoder.streamInfo.channelMode = BTIF_SBC_CHNL_MODE_JOINT_STEREO; - sbc_encoder.streamInfo.bitPool = A2DP_SBC_BITPOOL; - sbc_encoder.streamInfo.sampleFreq = app_a2dp_source_samplerate_2_sbcenc_type(a2dp_source.sample_rate); - sbc_encoder.streamInfo.allocMethod = BTIF_SBC_ALLOC_METHOD_SNR; - sbc_encoder.streamInfo.numBlocks = 16; - sbc_encoder.streamInfo.numSubBands = 8; - sbc_encoder.streamInfo.mSbcFlag = 0; - need_init_encoder = 0; - } - PcmEncData.data = (uint8_t *)a2dp_transmit_buffer; - PcmEncData.dataLen = A2DP_TRANS_SIZE; - PcmEncData.numChannels = 2; - PcmEncData.sampleFreq = sbc_encoder.streamInfo.sampleFreq; + if (need_init_encoder) { + btif_sbc_init_encoder(&sbc_encoder); + sbc_encoder.streamInfo.numChannels = 2; + sbc_encoder.streamInfo.channelMode = BTIF_SBC_CHNL_MODE_JOINT_STEREO; + sbc_encoder.streamInfo.bitPool = A2DP_SBC_BITPOOL; + sbc_encoder.streamInfo.sampleFreq = + app_a2dp_source_samplerate_2_sbcenc_type(a2dp_source.sample_rate); + sbc_encoder.streamInfo.allocMethod = BTIF_SBC_ALLOC_METHOD_SNR; + sbc_encoder.streamInfo.numBlocks = 16; + sbc_encoder.streamInfo.numSubBands = 8; + sbc_encoder.streamInfo.mSbcFlag = 0; + need_init_encoder = 0; + } + PcmEncData.data = (uint8_t *)a2dp_transmit_buffer; + PcmEncData.dataLen = A2DP_TRANS_SIZE; + PcmEncData.numChannels = 2; + PcmEncData.sampleFreq = sbc_encoder.streamInfo.sampleFreq; - btif_sbc_encode_frames(&sbc_encoder, &PcmEncData, &byte_encoded, - (unsigned char*)sbcpack->buffer, &enc_len, A2DP_TRANS_SIZE) ; - sbcPacket->dataLen = enc_len; - sbcPacket->frameSize = enc_len/frame_num; + btif_sbc_encode_frames(&sbc_encoder, &PcmEncData, &byte_encoded, + (unsigned char *)sbcpack->buffer, &enc_len, + A2DP_TRANS_SIZE); + sbcPacket->dataLen = enc_len; + sbcPacket->frameSize = enc_len / frame_num; - int_unlock(lock); - status = btif_a2dp_stream_send_sbc_packet(app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream,sbcPacket,&StreamInfo); - if(status == BT_STS_PENDING) - a2dp_source_wait_sent(osWaitForever); + int_unlock(lock); + status = btif_a2dp_stream_send_sbc_packet( + app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream, sbcPacket, + &StreamInfo); + if (status == BT_STS_PENDING) + a2dp_source_wait_sent(osWaitForever); } #endif //#define BT_A2DP_SOURCE_LINEIN_BUFF_SIZE (512*5*2*2) -#define BT_A2DP_SOURCE_LINEIN_BUFF_SIZE (A2DP_TRANS_SIZE*2) - +#define BT_A2DP_SOURCE_LINEIN_BUFF_SIZE (A2DP_TRANS_SIZE * 2) #if defined(APP_LINEIN_A2DP_SOURCE) //////////start the audio linein stream for capure the pcm data -int app_a2dp_source_linein_on(bool on) -{ - uint8_t *buff_play = NULL; - struct AF_STREAM_CONFIG_T stream_cfg; - static bool isRun = false; - SOURCE_DBLOG("app_a2dp_source_linein_on work:%d op:%d", isRun, on); +int app_a2dp_source_linein_on(bool on) { + uint8_t *buff_play = NULL; + struct AF_STREAM_CONFIG_T stream_cfg; + static bool isRun = false; + SOURCE_DBLOG("app_a2dp_source_linein_on work:%d op:%d", isRun, on); - if (isRun==on) - return 0; - - if (on){ -#if defined(SLAVE_USE_OPUS) || defined(MASTER_USE_OPUS) || defined(ALL_USE_OPUS) - app_audio_mempool_init(app_audio_get_basebuf_ptr(APP_MEM_LINEIN_AUDIO), app_audio_get_basebuf_size(APP_MEM_LINEIN_AUDIO)); -#else - app_audio_mempool_init(); -#endif - app_sysfreq_req(APP_SYSFREQ_USER_APP_0,APP_SYSFREQ_104M); - app_audio_mempool_get_buff(&buff_play, BT_A2DP_SOURCE_LINEIN_BUFF_SIZE); - - memset(&stream_cfg, 0, sizeof(stream_cfg)); - - stream_cfg.bits = AUD_BITS_16; - stream_cfg.channel_num = AUD_CHANNEL_NUM_2; - stream_cfg.sample_rate = a2dp_source.sample_rate; -#if FPGA==0 - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; -#else - stream_cfg.device = AUD_STREAM_USE_EXT_CODEC; -#endif - stream_cfg.vol = 10; - //stream_cfg.io_path = AUD_INPUT_PATH_HP_MIC; - //stream_cfg.io_path =AUD_INPUT_PATH_MAINMIC; - stream_cfg.io_path =AUD_INPUT_PATH_LINEIN; - stream_cfg.handler = a2dp_source_linein_more_pcm_data; - stream_cfg.data_ptr = buff_play; - stream_cfg.data_size = BT_A2DP_SOURCE_LINEIN_BUFF_SIZE; - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - SOURCE_DBLOG("app_source_linein_on on"); - } else { - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - SOURCE_DBLOG("app_source_linein_on off"); - //clear buffer data - a2dp_source.pcm_queue.write=0; - a2dp_source.pcm_queue.len=0; - a2dp_source.pcm_queue.read=0; - app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_32K); - } - - isRun=on; + if (isRun == on) return 0; + + if (on) { +#if defined(SLAVE_USE_OPUS) || defined(MASTER_USE_OPUS) || defined(ALL_USE_OPUS) + app_audio_mempool_init(app_audio_get_basebuf_ptr(APP_MEM_LINEIN_AUDIO), + app_audio_get_basebuf_size(APP_MEM_LINEIN_AUDIO)); +#else + app_audio_mempool_init(); +#endif + app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_104M); + app_audio_mempool_get_buff(&buff_play, BT_A2DP_SOURCE_LINEIN_BUFF_SIZE); + + memset(&stream_cfg, 0, sizeof(stream_cfg)); + + stream_cfg.bits = AUD_BITS_16; + stream_cfg.channel_num = AUD_CHANNEL_NUM_2; + stream_cfg.sample_rate = a2dp_source.sample_rate; +#if FPGA == 0 + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; +#else + stream_cfg.device = AUD_STREAM_USE_EXT_CODEC; +#endif + stream_cfg.vol = 10; + // stream_cfg.io_path = AUD_INPUT_PATH_HP_MIC; + // stream_cfg.io_path =AUD_INPUT_PATH_MAINMIC; + stream_cfg.io_path = AUD_INPUT_PATH_LINEIN; + stream_cfg.handler = a2dp_source_linein_more_pcm_data; + stream_cfg.data_ptr = buff_play; + stream_cfg.data_size = BT_A2DP_SOURCE_LINEIN_BUFF_SIZE; + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + SOURCE_DBLOG("app_source_linein_on on"); + } else { + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + SOURCE_DBLOG("app_source_linein_on off"); + // clear buffer data + a2dp_source.pcm_queue.write = 0; + a2dp_source.pcm_queue.len = 0; + a2dp_source.pcm_queue.read = 0; + app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_32K); + } + + isRun = on; + return 0; } #endif - -////////////////////////////creat the thread for send sbc data to a2dp sink device /////////////////// +////////////////////////////creat the thread for send sbc data to a2dp sink +/// device /////////////////// static void send_thread(const void *arg); - -osThreadDef(send_thread, osPriorityHigh, 1, 1024*2, "a2dp_send"); +osThreadDef(send_thread, osPriorityHigh, 1, 1024 * 2, "a2dp_send"); #if 1 -static void send_thread(const void *arg) -{ - while(1){ - a2dp_source_wait_pcm_data(); - while(a2dp_source_pcm_buffer_read((uint8_t *)a2dp_transmit_buffer,A2DP_TRANS_SIZE)==0) - { - a2dp_source_send_sbc_packet(); - } +static void send_thread(const void *arg) { + while (1) { + a2dp_source_wait_pcm_data(); + while (a2dp_source_pcm_buffer_read((uint8_t *)a2dp_transmit_buffer, + A2DP_TRANS_SIZE) == 0) { + a2dp_source_send_sbc_packet(); } + } } #endif -void app_source_init(void) -{ - //register the bt global handler - a2dp_source_handler.callback = bt_a2dp_source_call_back; - btif_me_register_global_handler(&a2dp_source_handler); - btif_me_set_event_mask(&a2dp_source_handler, BTIF_BEM_LINK_DISCONNECT|BTIF_BEM_ROLE_CHANGE|BTIF_BEM_INQUIRY_RESULT| - BTIF_BEM_INQUIRY_COMPLETE|BTIF_BEM_INQUIRY_CANCELED|BTIF_BEM_LINK_CONNECT_CNF|BTIF_BEM_LINK_CONNECT_IND); +void app_source_init(void) { + // register the bt global handler + a2dp_source_handler.callback = bt_a2dp_source_call_back; + btif_me_register_global_handler(&a2dp_source_handler); + btif_me_set_event_mask( + &a2dp_source_handler, + BTIF_BEM_LINK_DISCONNECT | BTIF_BEM_ROLE_CHANGE | + BTIF_BEM_INQUIRY_RESULT | BTIF_BEM_INQUIRY_COMPLETE | + BTIF_BEM_INQUIRY_CANCELED | BTIF_BEM_LINK_CONNECT_CNF | + BTIF_BEM_LINK_CONNECT_IND); } ///////init the a2dp source feature -void app_a2dp_source_init(void) -{ - a2dp_source_lock_t *lock; - //get heap from app_audio_buffer - app_audio_mempool_get_buff(&a2dp_linein_buff, A2DP_LINEIN_SIZE); - InitCQueue(&a2dp_source.pcm_queue, A2DP_LINEIN_SIZE, ( CQItemType *)a2dp_linein_buff); - if(a2dp_source_mutex_id == NULL) - { - a2dp_source_mutex_id = osMutexCreate((osMutex(a2dp_source_mutex))); - } +void app_a2dp_source_init(void) { + a2dp_source_lock_t *lock; + // get heap from app_audio_buffer + app_audio_mempool_get_buff(&a2dp_linein_buff, A2DP_LINEIN_SIZE); + InitCQueue(&a2dp_source.pcm_queue, A2DP_LINEIN_SIZE, + (CQItemType *)a2dp_linein_buff); + if (a2dp_source_mutex_id == NULL) { + a2dp_source_mutex_id = osMutexCreate((osMutex(a2dp_source_mutex))); + } - lock = &(a2dp_source.data_lock); - memset(lock,0,sizeof(a2dp_source_lock_t)); - lock->_osSemaphoreDef.semaphore = lock->_semaphore_data; - lock->_osSemaphoreId = osSemaphoreCreate(&(lock->_osSemaphoreDef), 0); + lock = &(a2dp_source.data_lock); + memset(lock, 0, sizeof(a2dp_source_lock_t)); + lock->_osSemaphoreDef.semaphore = lock->_semaphore_data; + lock->_osSemaphoreId = osSemaphoreCreate(&(lock->_osSemaphoreDef), 0); - lock = &(a2dp_source.sbc_send_lock); - memset(lock,0,sizeof(a2dp_source_lock_t)); - lock->_osSemaphoreDef.semaphore = lock->_semaphore_data; - lock->_osSemaphoreId = osSemaphoreCreate(&(lock->_osSemaphoreDef), 0); - a2dp_source.sbc_send_id = osThreadCreate(osThread(send_thread), NULL); - a2dp_source.sample_rate = AUD_SAMPRATE_44100; + lock = &(a2dp_source.sbc_send_lock); + memset(lock, 0, sizeof(a2dp_source_lock_t)); + lock->_osSemaphoreDef.semaphore = lock->_semaphore_data; + lock->_osSemaphoreId = osSemaphoreCreate(&(lock->_osSemaphoreDef), 0); + a2dp_source.sbc_send_id = osThreadCreate(osThread(send_thread), NULL); + a2dp_source.sample_rate = AUD_SAMPRATE_44100; } #endif diff --git a/services/bt_app/app_bqb.cpp b/services/bt_app/app_bqb.cpp index d8a6334..a03f251 100644 --- a/services/bt_app/app_bqb.cpp +++ b/services/bt_app/app_bqb.cpp @@ -15,98 +15,95 @@ ****************************************************************************/ #if defined(__BQB_PROFILE_TEST__) && !defined(ENHANCED_STACK) -#include "hal_uart.h" -#include "hal_timer.h" -#include "hal_cmu.h" #include "analog.h" #include "bt_drv.h" +#include "hal_cmu.h" +#include "hal_timer.h" +#include "hal_uart.h" #include "nvrecord.h" -#include "nvrecord_env.h" #include "nvrecord_dev.h" +#include "nvrecord_env.h" - -#include "cqueue.h" #include "apps.h" +#include "cqueue.h" #include "tgt_hardware.h" -#include "stdio.h" #include "cmsis_os.h" +#include "stdio.h" #include "string.h" +#include "hal_bootmode.h" #include "hal_timer.h" #include "hal_trace.h" -#include "hal_bootmode.h" -#include "audioflinger.h" -#include "apps.h" -#include "app_thread.h" -#include "app_key.h" #include "app_audio.h" +#include "app_key.h" #include "app_overlay.h" -#include "app_utils.h" #include "app_status_ind.h" +#include "app_thread.h" +#include "app_utils.h" +#include "apps.h" +#include "audioflinger.h" #ifdef __FACTORY_MODE_SUPPORT__ #include "app_factory.h" #include "app_factory_bt.h" #endif -#include "bt_drv_interface.h" #include "besbt.h" +#include "bt_drv_interface.h" #include "nvrecord.h" #include "nvrecord_dev.h" #include "nvrecord_env.h" - -#include "me_api.h" #include "a2dp_api.h" -#include "avdtp_api.h" +#include "app_bt.h" #include "avctp_api.h" +#include "avdtp_api.h" #include "avrcp_api.h" #include "btapp.h" -#include "app_bt.h" +#include "me_api.h" #ifdef MEDIA_PLAYER_SUPPORT -#include "resources.h" #include "app_media_player.h" +#include "resources.h" #endif #include "app_bt_media_manager.h" #include "hal_sleep.h" - -extern struct BT_DEVICE_T app_bt_device; -void A2dp_pts_Set_Sink_Delay(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!A2dp_pts_Set_Sink_Delay\n"); - btif_a2dp_set_sink_delay(app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream,10); +extern struct BT_DEVICE_T app_bt_device; +void A2dp_pts_Set_Sink_Delay(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!A2dp_pts_Set_Sink_Delay\n"); + btif_a2dp_set_sink_delay( + app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream, 10); } -void A2dp_pts_Create_Avdtp_Signal_Channel(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!A2dp_pts_Create_Avdtp_Signal_Channel\n"); - bt_bdaddr_t bdAddr; +void A2dp_pts_Create_Avdtp_Signal_Channel(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!A2dp_pts_Create_Avdtp_Signal_Channel\n"); + bt_bdaddr_t bdAddr; - //PTS addr:13 71 da 7d 1a 0 - bdAddr.address[0] = 0x13; - bdAddr.address[1] = 0x71; - bdAddr.address[2] = 0xda; - bdAddr.address[3] = 0x7d; - bdAddr.address[4] = 0x1a; - bdAddr.address[5] = 0x00; - btif_a2dp_open_stream(app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream, &bdAddr); + // PTS addr:13 71 da 7d 1a 0 + bdAddr.address[0] = 0x13; + bdAddr.address[1] = 0x71; + bdAddr.address[2] = 0xda; + bdAddr.address[3] = 0x7d; + bdAddr.address[4] = 0x1a; + bdAddr.address[5] = 0x00; + btif_a2dp_open_stream(app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream, + &bdAddr); } -void Hfp_pts_create_service_level_channel(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!Hfp_pts_create_service_level_channel\n"); - bt_bdaddr_t bdAddr; +void Hfp_pts_create_service_level_channel(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!Hfp_pts_create_service_level_channel\n"); + bt_bdaddr_t bdAddr; - //PTS addr:13 71 da 7d 1a 0 - bdAddr.address[0] = 0x13; - bdAddr.address[1] = 0x71; - bdAddr.address[2] = 0xda; - bdAddr.address[3] = 0x7d; - bdAddr.address[4] = 0x1a; - bdAddr.address[5] = 0x00; - btif_hf_create_service_link(app_bt_device.hf_channel[BT_DEVICE_ID_1],&bdAddr); + // PTS addr:13 71 da 7d 1a 0 + bdAddr.address[0] = 0x13; + bdAddr.address[1] = 0x71; + bdAddr.address[2] = 0xda; + bdAddr.address[3] = 0x7d; + bdAddr.address[4] = 0x1a; + bdAddr.address[5] = 0x00; + btif_hf_create_service_link(app_bt_device.hf_channel[BT_DEVICE_ID_1], + &bdAddr); } #if 0 @@ -115,25 +112,29 @@ typedef struct { uint8_t para_buf[10]; }APP_A2DP_AVRCPADVANCEDPDU; extern osPoolId app_a2dp_avrcpadvancedpdu_mempool; -#define app_a2dp_avrcpadvancedpdu_mempool_calloc(buf) do{ \ - APP_A2DP_AVRCPADVANCEDPDU * avrcpadvancedpdu; \ - avrcpadvancedpdu = (APP_A2DP_AVRCPADVANCEDPDU *)osPoolCAlloc(app_a2dp_avrcpadvancedpdu_mempool); \ - buf = &(avrcpadvancedpdu->pdu); \ - buf->parms = avrcpadvancedpdu->para_buf; \ - }while(0); - +#define app_a2dp_avrcpadvancedpdu_mempool_calloc(buf) \ + do { \ + APP_A2DP_AVRCPADVANCEDPDU *avrcpadvancedpdu; \ + avrcpadvancedpdu = (APP_A2DP_AVRCPADVANCEDPDU *)osPoolCAlloc( \ + app_a2dp_avrcpadvancedpdu_mempool); \ + buf = &(avrcpadvancedpdu->pdu); \ + buf->parms = avrcpadvancedpdu->para_buf; \ + } while (0); #endif -void Avrcp_pts_volume_change_notify(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!Avrcp_pts_volume_change_notify\n"); - if (app_bt_device.avrcp_notify_rsp[BT_DEVICE_ID_1] == NULL) - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_notify_rsp[BT_DEVICE_ID_1]); - btif_avrcp_ct_register_notification(app_bt_device.avrcp_channel[BT_DEVICE_ID_1],app_bt_device.avrcp_notify_rsp[BT_DEVICE_ID_1], BTIF_AVRCP_EID_VOLUME_CHANGED,0); +void Avrcp_pts_volume_change_notify(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!Avrcp_pts_volume_change_notify\n"); + if (app_bt_device.avrcp_notify_rsp[BT_DEVICE_ID_1] == NULL) + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_notify_rsp[BT_DEVICE_ID_1]); + btif_avrcp_ct_register_notification( + app_bt_device.avrcp_channel[BT_DEVICE_ID_1], + app_bt_device.avrcp_notify_rsp[BT_DEVICE_ID_1], + BTIF_AVRCP_EID_VOLUME_CHANGED, 0); } -//extern int a2dp_volume_get(void); +// extern int a2dp_volume_get(void); #if 0 void Avrcp_pts_set_absolute_volume(APP_KEY_STATUS *status, void *param) { diff --git a/services/bt_app/app_bqb_new_profile.cpp b/services/bt_app/app_bqb_new_profile.cpp index 75942bd..cd47305 100644 --- a/services/bt_app/app_bqb_new_profile.cpp +++ b/services/bt_app/app_bqb_new_profile.cpp @@ -15,10 +15,10 @@ ****************************************************************************/ #if defined(__BQB_PROFILE_TEST__) && defined(ENHANCED_STACK) -#include "hal_trace.h" #include "app_key.h" -#include "conmgr_api.h" #include "bt_if.h" +#include "conmgr_api.h" +#include "hal_trace.h" static bt_bdaddr_t pts_bt_addr = {{ #if 1 @@ -28,250 +28,211 @@ static bt_bdaddr_t pts_bt_addr = {{ #endif }}; -void A2dp_pts_Create_Avdtp_Signal_Channel(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!A2dp_pts_Create_Avdtp_Signal_Channel\n"); - btif_pts_av_create_channel(&pts_bt_addr); +void A2dp_pts_Create_Avdtp_Signal_Channel(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!A2dp_pts_Create_Avdtp_Signal_Channel\n"); + btif_pts_av_create_channel(&pts_bt_addr); } -void A2dp_pts_set_sink_delay(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!A2dp_pts_set_sink_delay\n"); - btif_pts_av_set_sink_delay(); +void A2dp_pts_set_sink_delay(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!A2dp_pts_set_sink_delay\n"); + btif_pts_av_set_sink_delay(); } -void Avctp_pts_avrcp_connect(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!Avctp_pts_avrcp_connect\n"); - btif_pts_ar_connect(&pts_bt_addr); +void Avctp_pts_avrcp_connect(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!Avctp_pts_avrcp_connect\n"); + btif_pts_ar_connect(&pts_bt_addr); } -void Avrcp_pts_volume_change_notify(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!Avrcp_pts_volume_change_notify\n"); - btif_pts_ar_volume_notify(); +void Avrcp_pts_volume_change_notify(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!Avrcp_pts_volume_change_notify\n"); + btif_pts_ar_volume_notify(); } -void Avrcp_pts_set_absolute_volume(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"app_avrcp_set_absolute_volume\n"); - btif_pts_ar_set_absolute_volume(); +void Avrcp_pts_set_absolute_volume(APP_KEY_STATUS *status, void *param) { + TRACE(0, "app_avrcp_set_absolute_volume\n"); + btif_pts_ar_set_absolute_volume(); } -void Hfp_pts_create_service_level_channel(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!Hfp_pts_create_service_level_channel\n"); - btif_pts_hf_create_service_link(&pts_bt_addr); +void Hfp_pts_create_service_level_channel(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!Hfp_pts_create_service_level_channel\n"); + btif_pts_hf_create_service_link(&pts_bt_addr); } -void Hfp_pts_disconnect_service_link(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!Hfp_pts_disconnect_service_link\n"); - btif_pts_hf_disc_service_link(); +void Hfp_pts_disconnect_service_link(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!Hfp_pts_disconnect_service_link\n"); + btif_pts_hf_disc_service_link(); } -void Hfp_pts_create_audio_link(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!Hfp_pts_create_audio_link\n"); - btif_pts_hf_create_audio_link(); +void Hfp_pts_create_audio_link(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!Hfp_pts_create_audio_link\n"); + btif_pts_hf_create_audio_link(); } -void Hfp_pts_enable_voice_recognition(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!Hfp_pts_enable_voice_recognition\n"); - btif_pts_hf_vr_enable(); +void Hfp_pts_enable_voice_recognition(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!Hfp_pts_enable_voice_recognition\n"); + btif_pts_hf_vr_enable(); } -void Hfp_pts_disable_voice_recognition(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!Hfp_pts_disable_voice_recognition\n"); - btif_pts_hf_vr_disable(); +void Hfp_pts_disable_voice_recognition(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!Hfp_pts_disable_voice_recognition\n"); + btif_pts_hf_vr_disable(); } -void Hfp_pts_list_current_calls(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!Hfp_pts_list_current_calls\n"); - btif_pts_hf_list_current_calls(); +void Hfp_pts_list_current_calls(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!Hfp_pts_list_current_calls\n"); + btif_pts_hf_list_current_calls(); } -void Hfp_pts_release_active_call_index2(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!Hfp_pts_release_active_call_index2\n"); - btif_pts_hf_release_active_call_2(); +void Hfp_pts_release_active_call_index2(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!Hfp_pts_release_active_call_index2\n"); + btif_pts_hf_release_active_call_2(); } -void Hfp_pts_hold_active_call_index2(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!Hfp_pts_hold_active_call_index2\n"); - btif_pts_hf_hold_active_call_2(); +void Hfp_pts_hold_active_call_index2(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!Hfp_pts_hold_active_call_index2\n"); + btif_pts_hf_hold_active_call_2(); } -void Hfp_pts_release_active_call(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!Hfp_pts_release_active_call\n"); - btif_pts_hf_release_active_call(); +void Hfp_pts_release_active_call(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!Hfp_pts_release_active_call\n"); + btif_pts_hf_release_active_call(); } -void Hfp_pts_hf_indicators_1(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!Hfp_pts_hf_indicators_1\n"); - btif_pts_hf_send_ind_1(); +void Hfp_pts_hf_indicators_1(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!Hfp_pts_hf_indicators_1\n"); + btif_pts_hf_send_ind_1(); } -void Hfp_pts_hf_indicators_2(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!Hfp_pts_hf_indicators_2\n"); - btif_pts_hf_send_ind_2(); +void Hfp_pts_hf_indicators_2(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!Hfp_pts_hf_indicators_2\n"); + btif_pts_hf_send_ind_2(); } -void Hfp_pts_hf_indicators_3(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!Hfp_pts_hf_indicators_3\n"); - btif_pts_hf_send_ind_3(); +void Hfp_pts_hf_indicators_3(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!Hfp_pts_hf_indicators_3\n"); + btif_pts_hf_send_ind_3(); } -void Hfp_pts_update_indicators_value(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!Hfp_pts_update_indicators_value\n"); - btif_pts_hf_update_ind_value(); +void Hfp_pts_update_indicators_value(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!Hfp_pts_update_indicators_value\n"); + btif_pts_hf_update_ind_value(); } -void rfcomm_pts_register_channel(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"rfcomm_pts_register_channel\n"); - btif_pts_rfc_register_channel(); +void rfcomm_pts_register_channel(APP_KEY_STATUS *status, void *param) { + TRACE(0, "rfcomm_pts_register_channel\n"); + btif_pts_rfc_register_channel(); } -void rfcomm_pts_rfcomm_close(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"rfcomm_pts_rfcomm_close\n"); - btif_pts_rfc_close(); +void rfcomm_pts_rfcomm_close(APP_KEY_STATUS *status, void *param) { + TRACE(0, "rfcomm_pts_rfcomm_close\n"); + btif_pts_rfc_close(); } -void rfcomm_pts_rfcomm_close_dlci0(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"rfcomm_pts_rfcomm_close_dlci0\n"); - btif_pts_rfc_close_dlci_0(); +void rfcomm_pts_rfcomm_close_dlci0(APP_KEY_STATUS *status, void *param) { + TRACE(0, "rfcomm_pts_rfcomm_close_dlci0\n"); + btif_pts_rfc_close_dlci_0(); } -void rfcomm_pts_rfcomm_send_data(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"rfcomm_pts_rfcomm_send_data\n"); - btif_pts_rfc_send_data(); +void rfcomm_pts_rfcomm_send_data(APP_KEY_STATUS *status, void *param) { + TRACE(0, "rfcomm_pts_rfcomm_send_data\n"); + btif_pts_rfc_send_data(); } -void Avdtp_pts_send_discover_cmd(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"Avdtp_pts_send_discover_cmd\n"); - btif_pts_av_send_discover(); +void Avdtp_pts_send_discover_cmd(APP_KEY_STATUS *status, void *param) { + TRACE(0, "Avdtp_pts_send_discover_cmd\n"); + btif_pts_av_send_discover(); } -void Avdtp_pts_send_get_capability_cmd(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"Avdtp_pts_send_get_capability_cmd\n"); - btif_pts_av_send_getcap(); +void Avdtp_pts_send_get_capability_cmd(APP_KEY_STATUS *status, void *param) { + TRACE(0, "Avdtp_pts_send_get_capability_cmd\n"); + btif_pts_av_send_getcap(); } -void Avdtp_pts_send_set_configuration_cmd(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"Avdtp_pts_send_set_configuration_cmd\n"); - btif_pts_av_send_setconf(); +void Avdtp_pts_send_set_configuration_cmd(APP_KEY_STATUS *status, void *param) { + TRACE(0, "Avdtp_pts_send_set_configuration_cmd\n"); + btif_pts_av_send_setconf(); } -void Avdtp_pts_send_get_configuration_cmd(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"Avdtp_pts_send_get_configuration_cmd\n"); - btif_pts_av_send_getconf(); +void Avdtp_pts_send_get_configuration_cmd(APP_KEY_STATUS *status, void *param) { + TRACE(0, "Avdtp_pts_send_get_configuration_cmd\n"); + btif_pts_av_send_getconf(); } -void Avdtp_pts_send_reconfigure_cmd(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"Avdtp_pts_send_reconfigure_cmd\n"); - btif_pts_av_send_reconf(); +void Avdtp_pts_send_reconfigure_cmd(APP_KEY_STATUS *status, void *param) { + TRACE(0, "Avdtp_pts_send_reconfigure_cmd\n"); + btif_pts_av_send_reconf(); } -void Avdtp_pts_send_open_cmd(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"Avdtp_pts_send_open_cmd\n"); - btif_pts_av_send_open(); +void Avdtp_pts_send_open_cmd(APP_KEY_STATUS *status, void *param) { + TRACE(0, "Avdtp_pts_send_open_cmd\n"); + btif_pts_av_send_open(); } -void Avdtp_pts_send_close_cmd(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"Avdtp_pts_send_close_cmd\n"); - btif_pts_av_send_close(); +void Avdtp_pts_send_close_cmd(APP_KEY_STATUS *status, void *param) { + TRACE(0, "Avdtp_pts_send_close_cmd\n"); + btif_pts_av_send_close(); } -void Avdtp_pts_send_abort_cmd(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"Avdtp_pts_send_abort_cmd\n"); - btif_pts_av_send_abort(); +void Avdtp_pts_send_abort_cmd(APP_KEY_STATUS *status, void *param) { + TRACE(0, "Avdtp_pts_send_abort_cmd\n"); + btif_pts_av_send_abort(); } -void Avdtp_pts_send_get_all_capability_cmd(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"Avdtp_pts_send_get_all_capability_cmd\n"); - btif_pts_av_send_getallcap(); +void Avdtp_pts_send_get_all_capability_cmd(APP_KEY_STATUS *status, + void *param) { + TRACE(0, "Avdtp_pts_send_get_all_capability_cmd\n"); + btif_pts_av_send_getallcap(); } -void Avdtp_pts_send_suspend_cmd(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"Avdtp_pts_send_suspend_cmd\n"); - btif_pts_av_send_suspend(); +void Avdtp_pts_send_suspend_cmd(APP_KEY_STATUS *status, void *param) { + TRACE(0, "Avdtp_pts_send_suspend_cmd\n"); + btif_pts_av_send_suspend(); } -void Avdtp_pts_send_start_cmd(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"Avdtp_pts_send_start_cmd\n"); - btif_pts_av_send_start(); +void Avdtp_pts_send_start_cmd(APP_KEY_STATUS *status, void *param) { + TRACE(0, "Avdtp_pts_send_start_cmd\n"); + btif_pts_av_send_start(); } -void Avdtp_pts_create_media_channel(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"Avdtp_pts_create_media_channel\n"); - btif_pts_av_create_media_channel(); +void Avdtp_pts_create_media_channel(APP_KEY_STATUS *status, void *param) { + TRACE(0, "Avdtp_pts_create_media_channel\n"); + btif_pts_av_create_media_channel(); } -void l2cap_pts_disconnect_channel(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!l2cap_pts_disconnect_channel\n"); - btif_pts_l2c_disc_channel(); +void l2cap_pts_disconnect_channel(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!l2cap_pts_disconnect_channel\n"); + btif_pts_l2c_disc_channel(); } -void l2cap_pts_send_data(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"!!!l2cap_pts_send_data\n"); - btif_pts_l2c_send_data(); +void l2cap_pts_send_data(APP_KEY_STATUS *status, void *param) { + TRACE(0, "!!!l2cap_pts_send_data\n"); + btif_pts_l2c_send_data(); } void pts_spp_client_init(void); -btif_cmgr_handler_t* pts_cmgr_handler; +btif_cmgr_handler_t *pts_cmgr_handler; bt_status_t btif_cmgr_create_data_link(btif_cmgr_handler_t *cmgr_handler, - bt_bdaddr_t *bd_addr); + bt_bdaddr_t *bd_addr); bt_status_t btif_cmgr_register_handler(btif_cmgr_handler_t *cmgr_handler, - btif_cmgr_callback callback); -void pts_cmgr_callback(btif_cmgr_handler_t *cHandler, - cmgr_event_t Event, - bt_status_t Status); -void spp_pts_client_open(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"spp_pts_client_open\n"); - - pts_cmgr_handler = btif_cmgr_handler_create(); - btif_cmgr_register_handler(pts_cmgr_handler,pts_cmgr_callback); - pts_spp_client_init(); - btif_cmgr_create_data_link(pts_cmgr_handler,&pts_bt_addr); + btif_cmgr_callback callback); +void pts_cmgr_callback(btif_cmgr_handler_t *cHandler, cmgr_event_t Event, + bt_status_t Status); +void spp_pts_client_open(APP_KEY_STATUS *status, void *param) { + TRACE(0, "spp_pts_client_open\n"); + pts_cmgr_handler = btif_cmgr_handler_create(); + btif_cmgr_register_handler(pts_cmgr_handler, pts_cmgr_callback); + pts_spp_client_init(); + btif_cmgr_create_data_link(pts_cmgr_handler, &pts_bt_addr); } extern struct gap_bdaddr BLE_BdAddr; extern "C" void pts_ble_addr_init(void); -extern "C" void appm_start_connecting(struct gap_bdaddr* ptBdAddr); -void ble_pts_appm_start_connecting(APP_KEY_STATUS *status, void *param) -{ - TRACE(0,"ble_pts_appm_start_connecting\n"); - pts_ble_addr_init(); - appm_start_connecting(&BLE_BdAddr); +extern "C" void appm_start_connecting(struct gap_bdaddr *ptBdAddr); +void ble_pts_appm_start_connecting(APP_KEY_STATUS *status, void *param) { + TRACE(0, "ble_pts_appm_start_connecting\n"); + pts_ble_addr_init(); + appm_start_connecting(&BLE_BdAddr); } #endif diff --git a/services/bt_app/app_bt.cpp b/services/bt_app/app_bt.cpp index e8afb9e..6f08323 100644 --- a/services/bt_app/app_bt.cpp +++ b/services/bt_app/app_bt.cpp @@ -14,40 +14,40 @@ * ****************************************************************************/ +#include "app_bt.h" +#include "a2dp_api.h" +#include "app_a2dp.h" +#include "app_ai_manager_api.h" +#include "app_bt.h" +#include "app_bt_func.h" +#include "app_dip.h" +#include "app_hfp.h" +#include "app_status_ind.h" +#include "app_thread.h" +#include "apps.h" +#include "besbt.h" +#include "besbt_cfg.h" +#include "bluetooth.h" +#include "bt_drv_interface.h" +#include "bt_drv_reg_op.h" +#include "btapp.h" +#include "dip_api.h" #include "hal_aud.h" #include "hal_chipid.h" #include "hal_trace.h" -#include "apps.h" -#include "app_thread.h" -#include "app_status_ind.h" -#include "bluetooth.h" -#include "nvrecord.h" -#include "besbt.h" -#include "besbt_cfg.h" +#include "hci_api.h" +#include "hfp_api.h" +#include "l2cap_api.h" #include "me_api.h" #include "mei_api.h" -#include "a2dp_api.h" -#include "hci_api.h" -#include "l2cap_api.h" -#include "hfp_api.h" -#include "dip_api.h" -#include "btapp.h" -#include "app_bt.h" -#include "app_hfp.h" -#include "app_bt_func.h" -#include "bt_drv_interface.h" +#include "nvrecord.h" #include "os_api.h" -#include "bt_drv_reg_op.h" -#include "app_a2dp.h" -#include "app_dip.h" -#include "app_ai_manager_api.h" -#include "app_bt.h" #if defined(IBRT) -#include "app_tws_ibrt.h" -#include "app_ibrt_ui.h" -#include "app_ibrt_if.h" #include "app_ibrt_a2dp.h" +#include "app_ibrt_if.h" +#include "app_ibrt_ui.h" +#include "app_tws_ibrt.h" #endif #ifdef __THIRDPARTY @@ -61,18 +61,18 @@ #endif #ifdef __AI_VOICE__ +#include "ai_manager.h" #include "ai_spp.h" #include "ai_thread.h" -#include "ai_manager.h" #endif #ifdef __INTERCONNECTION__ #include "app_interconnection.h" #include "app_interconnection_ble.h" -#include "spp_api.h" #include "app_interconnection_ccmp.h" -#include "app_spp.h" #include "app_interconnection_spp.h" +#include "app_spp.h" +#include "spp_api.h" #endif #ifdef __INTERACTION__ @@ -92,24 +92,24 @@ #endif #ifdef TILE_DATAPATH -#include "tile_target_ble.h" #include "rwip_config.h" +#include "tile_target_ble.h" #endif #if (A2DP_DECODER_VER >= 2) #include "a2dp_decoder.h" #endif -extern "C" -{ +extern "C" { #include "ddbif.h" } -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; extern "C" bool app_anc_work_status(void); extern uint8_t avrcp_get_media_status(void); void avrcp_set_media_status(uint8_t status); #ifdef GFPS_ENABLED -extern "C" void app_gfps_handling_on_mobile_link_disconnection(btif_remote_device_t* pRemDev); +extern "C" void +app_gfps_handling_on_mobile_link_disconnection(btif_remote_device_t *pRemDev); #endif static btif_remote_device_t *connectedMobile = NULL; @@ -122,46 +122,43 @@ btif_device_record_t record2_copy; uint8_t record2_avalible; #endif -enum bt_profile_reconnect_mode -{ - bt_profile_reconnect_null, - bt_profile_reconnect_openreconnecting, - bt_profile_reconnect_reconnecting, - bt_profile_reconnect_reconnect_pending, +enum bt_profile_reconnect_mode { + bt_profile_reconnect_null, + bt_profile_reconnect_openreconnecting, + bt_profile_reconnect_reconnecting, + bt_profile_reconnect_reconnect_pending, }; -enum bt_profile_connect_status -{ - bt_profile_connect_status_unknow, - bt_profile_connect_status_success, - bt_profile_connect_status_failure, +enum bt_profile_connect_status { + bt_profile_connect_status_unknow, + bt_profile_connect_status_success, + bt_profile_connect_status_failure, }; -struct app_bt_profile_manager -{ - bool has_connected; - enum bt_profile_connect_status hfp_connect; - enum bt_profile_connect_status hsp_connect; - enum bt_profile_connect_status a2dp_connect; - bt_bdaddr_t rmt_addr; - bt_profile_reconnect_mode reconnect_mode; - bt_profile_reconnect_mode saved_reconnect_mode; - a2dp_stream_t *stream; - //HfChannel *chan; - hf_chan_handle_t chan; -#if defined (__HSP_ENABLE__) - HsChannel * hs_chan; +struct app_bt_profile_manager { + bool has_connected; + enum bt_profile_connect_status hfp_connect; + enum bt_profile_connect_status hsp_connect; + enum bt_profile_connect_status a2dp_connect; + bt_bdaddr_t rmt_addr; + bt_profile_reconnect_mode reconnect_mode; + bt_profile_reconnect_mode saved_reconnect_mode; + a2dp_stream_t *stream; + // HfChannel *chan; + hf_chan_handle_t chan; +#if defined(__HSP_ENABLE__) + HsChannel *hs_chan; #endif - uint16_t reconnect_cnt; - osTimerId connect_timer; - void (* connect_timer_cb)(void const *); + uint16_t reconnect_cnt; + osTimerId connect_timer; + void (*connect_timer_cb)(void const *); - APP_BT_CONNECTING_STATE_E connectingState; + APP_BT_CONNECTING_STATE_E connectingState; }; -//reconnect = (INTERVAL+PAGETO)*CNT = (3000ms+5000ms)*15 = 120s +// reconnect = (INTERVAL+PAGETO)*CNT = (3000ms+5000ms)*15 = 120s #define APP_BT_PROFILE_RECONNECT_RETRY_INTERVAL_MS (3000) -#define APP_BT_PROFILE_OPENNING_RECONNECT_RETRY_LIMIT_CNT (2) +#define APP_BT_PROFILE_OPENNING_RECONNECT_RETRY_LIMIT_CNT (2) #define APP_BT_PROFILE_RECONNECT_RETRY_LIMIT_CNT (15) #define APP_BT_PROFILE_CONNECT_RETRY_MS (10000) @@ -176,17 +173,22 @@ btif_accessible_mode_t g_bt_access_mode = BTIF_BAM_NOT_ACCESSIBLE; #define APP_BT_PROFILE_PAGE_SCAN_MS (4000) osTimerId app_bt_accessmode_timer = NULL; -btif_accessible_mode_t app_bt_accessmode_timer_argument = BTIF_BAM_NOT_ACCESSIBLE; +btif_accessible_mode_t app_bt_accessmode_timer_argument = + BTIF_BAM_NOT_ACCESSIBLE; static int app_bt_accessmode_timehandler(void const *param); -osTimerDef (APP_BT_ACCESSMODE_TIMER, (void (*)(void const *))app_bt_accessmode_timehandler); // define timers +osTimerDef(APP_BT_ACCESSMODE_TIMER, + (void (*)(void const *)) + app_bt_accessmode_timehandler); // define timers -#define A2DP_CONN_CLOSED 10 +#define A2DP_CONN_CLOSED 10 #ifdef __IAG_BLE_INCLUDE__ #define APP_FAST_BLE_ADV_TIMEOUT_IN_MS 30000 osTimerId app_fast_ble_adv_timeout_timer = NULL; static int app_fast_ble_adv_timeout_timehandler(void const *param); -osTimerDef(APP_FAST_BLE_ADV_TIMEOUT_TIMER, ( void (*)(void const *) )app_fast_ble_adv_timeout_timehandler); // define timers +osTimerDef(APP_FAST_BLE_ADV_TIMEOUT_TIMER, + (void (*)(void const *)) + app_fast_ble_adv_timeout_timehandler); // define timers /*--------------------------------------------------------------------------- * app_start_fast_connectable_ble_adv @@ -204,3032 +206,2959 @@ osTimerDef(APP_FAST_BLE_ADV_TIMEOUT_TIMER, ( void (*)(void const *) )app_fast_bl static void app_start_fast_connectable_ble_adv(uint16_t advInterval); #endif - #if defined(__INTERCONNECTION__) -btif_accessible_mode_t app_bt_get_current_access_mode(void) -{ - return g_bt_access_mode; +btif_accessible_mode_t app_bt_get_current_access_mode(void) { + return g_bt_access_mode; } -bool app_bt_is_connected() -{ - uint8_t i=0; - bool connceted_value=false; - for(i=0; i= (int8_t)nameLen) - { - // Check if data can be added to the adv Data - adv_data[adv_data_len++] = nameLen + 1; - // Fill Device Name Flag - adv_data[adv_data_len++] = '\x09'; - // Copy device name - memcpy(&adv_data[adv_data_len], ble_name_in_nv, nameLen); - // Update adv Data Length - adv_data_len += nameLen; - btif_me_ble_set_adv_data(adv_data_len, adv_data); + // Get default Device Name (No name if not enough space) + const char *ble_name_in_nv = BLE_DEFAULT_NAME; + uint32_t nameLen = strlen(ble_name_in_nv); + // Get remaining space in the Advertising Data - 2 bytes are used for name + // length/flag + int8_t avail_space = 31 - adv_data_len; + if (avail_space - 2 >= (int8_t)nameLen) { + // Check if data can be added to the adv Data + adv_data[adv_data_len++] = nameLen + 1; + // Fill Device Name Flag + adv_data[adv_data_len++] = '\x09'; + // Copy device name + memcpy(&adv_data[adv_data_len], ble_name_in_nv, nameLen); + // Update adv Data Length + adv_data_len += nameLen; + btif_me_ble_set_adv_data(adv_data_len, adv_data); - btif_adv_para_struct_t adv_para; - adv_para.interval_min = 32; - adv_para.interval_max = 32; - adv_para.adv_type = 0; - adv_para.own_addr_type = 0; - adv_para.peer_addr_type = 0; - adv_para.adv_chanmap = 0x07; - adv_para.adv_filter_policy = 0; - btif_me_ble_set_adv_parameters(&adv_para); - btif_me_set_ble_bd_address(ble_addr); - btif_me_ble_set_adv_en(1); - } - else - { - nameLen = avail_space - 2; - // Check if data can be added to the adv Data - adv_data[adv_data_len++] = nameLen + 1; - // Fill Device Name Flag - adv_data[adv_data_len++] = '\x08'; - // Copy device name - memcpy(&adv_data[adv_data_len], ble_name_in_nv, nameLen); - // Update adv Data Length - adv_data_len += nameLen; - btif_me_ble_set_adv_data(adv_data_len, adv_data); + btif_adv_para_struct_t adv_para; + adv_para.interval_min = 32; + adv_para.interval_max = 32; + adv_para.adv_type = 0; + adv_para.own_addr_type = 0; + adv_para.peer_addr_type = 0; + adv_para.adv_chanmap = 0x07; + adv_para.adv_filter_policy = 0; + btif_me_ble_set_adv_parameters(&adv_para); + btif_me_set_ble_bd_address(ble_addr); + btif_me_ble_set_adv_en(1); + } else { + nameLen = avail_space - 2; + // Check if data can be added to the adv Data + adv_data[adv_data_len++] = nameLen + 1; + // Fill Device Name Flag + adv_data[adv_data_len++] = '\x08'; + // Copy device name + memcpy(&adv_data[adv_data_len], ble_name_in_nv, nameLen); + // Update adv Data Length + adv_data_len += nameLen; + btif_me_ble_set_adv_data(adv_data_len, adv_data); - btif_adv_para_struct_t adv_para; - adv_para.interval_min = 256; - adv_para.interval_max = 256; - adv_para.adv_type = 0; - adv_para.own_addr_type = 0; - adv_para.peer_addr_type = 0; - adv_para.adv_chanmap = 0x07; - adv_para.adv_filter_policy = 0; - btif_me_ble_set_adv_parameters(&adv_para); - btif_me_set_ble_bd_address(ble_addr); + btif_adv_para_struct_t adv_para; + adv_para.interval_min = 256; + adv_para.interval_max = 256; + adv_para.adv_type = 0; + adv_para.own_addr_type = 0; + adv_para.peer_addr_type = 0; + adv_para.adv_chanmap = 0x07; + adv_para.adv_filter_policy = 0; + btif_me_ble_set_adv_parameters(&adv_para); + btif_me_set_ble_bd_address(ble_addr); - avail_space = 31; - nameLen = strlen(ble_name_in_nv); - if(avail_space - 2 < (int8_t)nameLen) - nameLen = avail_space - 2; + avail_space = 31; + nameLen = strlen(ble_name_in_nv); + if (avail_space - 2 < (int8_t)nameLen) + nameLen = avail_space - 2; - scan_rsp_data[scan_rsp_data_len++] = nameLen + 1; - // Fill Device Name Flag - scan_rsp_data[scan_rsp_data_len++] = '\x09'; - // Copy device name - memcpy(&scan_rsp_data[scan_rsp_data_len], ble_name_in_nv, nameLen); - // Update Scan response Data Length - scan_rsp_data_len += nameLen; - btif_me_ble_set_scan_rsp_data(scan_rsp_data_len, scan_rsp_data); - btif_me_ble_set_adv_en(1); - } + scan_rsp_data[scan_rsp_data_len++] = nameLen + 1; + // Fill Device Name Flag + scan_rsp_data[scan_rsp_data_len++] = '\x09'; + // Copy device name + memcpy(&scan_rsp_data[scan_rsp_data_len], ble_name_in_nv, nameLen); + // Update Scan response Data Length + scan_rsp_data_len += nameLen; + btif_me_ble_set_scan_rsp_data(scan_rsp_data_len, scan_rsp_data); + btif_me_ble_set_adv_en(1); + } } -void app_bt_write_controller_memory_for_test(uint32_t addr,uint32_t val,uint8_t type) -{ - TRACE(2,"%s addr=0x%x val=0x%x type=%d",__func__, addr,val,type); - app_bt_ME_Write_Controller_Memory_Fortest(addr,val,type); +void app_bt_write_controller_memory_for_test(uint32_t addr, uint32_t val, + uint8_t type) { + TRACE(2, "%s addr=0x%x val=0x%x type=%d", __func__, addr, val, type); + app_bt_ME_Write_Controller_Memory_Fortest(addr, val, type); } -void app_bt_read_controller_memory_for_test(uint32_t addr,uint32_t len,uint8_t type) -{ - TRACE(2,"%s addr=0x%x len=%x type=%d",__func__, addr,len,type); - app_bt_ME_Read_Controller_Memory_Fortest(addr,len,type); +void app_bt_read_controller_memory_for_test(uint32_t addr, uint32_t len, + uint8_t type) { + TRACE(2, "%s addr=0x%x len=%x type=%d", __func__, addr, len, type); + app_bt_ME_Read_Controller_Memory_Fortest(addr, len, type); } #endif -extern "C" uint8_t app_bt_get_act_cons(void) -{ - int activeCons; +extern "C" uint8_t app_bt_get_act_cons(void) { + int activeCons; - osapi_lock_stack(); - activeCons = btif_me_get_activeCons(); - osapi_unlock_stack(); - TRACE(2,"%s %d",__func__,activeCons); - return activeCons; + osapi_lock_stack(); + activeCons = btif_me_get_activeCons(); + osapi_unlock_stack(); + TRACE(2, "%s %d", __func__, activeCons); + return activeCons; } -enum -{ - INITIATE_PAIRING_NONE = 0, - INITIATE_PAIRING_RUN = 1, +enum { + INITIATE_PAIRING_NONE = 0, + INITIATE_PAIRING_RUN = 1, }; static uint8_t initiate_pairing = INITIATE_PAIRING_NONE; -void app_bt_connectable_state_set(uint8_t set) -{ - initiate_pairing = set; -} -bool is_app_bt_pairing_running(void) -{ - return (initiate_pairing == INITIATE_PAIRING_RUN)?(true):(false); +void app_bt_connectable_state_set(uint8_t set) { initiate_pairing = set; } +bool is_app_bt_pairing_running(void) { + return (initiate_pairing == INITIATE_PAIRING_RUN) ? (true) : (false); } #define APP_DISABLE_PAGE_SCAN_AFTER_CONN #ifdef APP_DISABLE_PAGE_SCAN_AFTER_CONN osTimerId disable_page_scan_check_timer = NULL; static void disable_page_scan_check_timer_handler(void const *param); -osTimerDef (DISABLE_PAGE_SCAN_CHECK_TIMER, (void (*)(void const *))disable_page_scan_check_timer_handler); // define timers -static void disable_page_scan_check_timer_handler(void const *param) -{ +osTimerDef(DISABLE_PAGE_SCAN_CHECK_TIMER, + (void (*)(void const *)) + disable_page_scan_check_timer_handler); // define timers +static void disable_page_scan_check_timer_handler(void const *param) { #ifdef __BT_ONE_BRING_TWO__ - if((btif_me_get_activeCons() > 1) && (initiate_pairing == INITIATE_PAIRING_NONE)) - { + if ((btif_me_get_activeCons() > 1) && + (initiate_pairing == INITIATE_PAIRING_NONE)) { #else - if((btif_me_get_activeCons() > 0) && (initiate_pairing == INITIATE_PAIRING_NONE)) - { + if ((btif_me_get_activeCons() > 0) && + (initiate_pairing == INITIATE_PAIRING_NONE)) { #endif - app_bt_accessmode_set_req(BTIF_BAM_NOT_ACCESSIBLE); - } + app_bt_accessmode_set_req(BTIF_BAM_NOT_ACCESSIBLE); + } } -static void disable_page_scan_check_timer_start(void) -{ - if(disable_page_scan_check_timer == NULL) - { - disable_page_scan_check_timer = osTimerCreate(osTimer(DISABLE_PAGE_SCAN_CHECK_TIMER), osTimerOnce, NULL); - } - osTimerStart(disable_page_scan_check_timer, 4000); +static void disable_page_scan_check_timer_start(void) { + if (disable_page_scan_check_timer == NULL) { + disable_page_scan_check_timer = osTimerCreate( + osTimer(DISABLE_PAGE_SCAN_CHECK_TIMER), osTimerOnce, NULL); + } + osTimerStart(disable_page_scan_check_timer, 4000); } #endif -void PairingTransferToConnectable(void) -{ - int activeCons; - osapi_lock_stack(); - activeCons = btif_me_get_activeCons(); - osapi_unlock_stack(); - TRACE(1,"%s",__func__); +void PairingTransferToConnectable(void) { + int activeCons; + osapi_lock_stack(); + activeCons = btif_me_get_activeCons(); + osapi_unlock_stack(); + TRACE(1, "%s", __func__); - app_bt_connectable_state_set(INITIATE_PAIRING_NONE); - if(activeCons == 0) - { - TRACE(0,"!!!PairingTransferToConnectable BAM_CONNECTABLE_ONLY\n"); - app_bt_accessmode_set_req(BTIF_BAM_CONNECTABLE_ONLY); - } + app_bt_connectable_state_set(INITIATE_PAIRING_NONE); + if (activeCons == 0) { + TRACE(0, "!!!PairingTransferToConnectable BAM_CONNECTABLE_ONLY\n"); + app_bt_accessmode_set_req(BTIF_BAM_CONNECTABLE_ONLY); + } } -int app_bt_get_audio_up_id(void) -{ - uint8_t i; - btif_remote_device_t *remDev = NULL; - btif_cmgr_handler_t *cmgrHandler; - for (i=0; imaxInterval); +int app_bt_ibrt_profile_checker(const char *str, btif_remote_device_t *remDev, + btif_cmgr_handler_t *cmgrHandler, + a2dp_stream_t *a2dp_stream, + hf_chan_handle_t hf_channel) { + if (remDev && cmgrHandler) { + TRACE(6, "checker: %s remDev state:%d mode:%d role:%d sniffInterval:%d/%d", + str, btif_me_get_remote_device_state(remDev), + btif_me_get_remote_device_mode(remDev), + btif_me_get_remote_device_role(remDev), + btif_cmgr_get_cmgrhandler_sniff_Interval(cmgrHandler), + btif_cmgr_get_cmgrhandler_sniff_info(cmgrHandler)->maxInterval); - TRACE(2,"checker: %s remDev:%p remote_dev_address:", str,remDev); - DUMP8("0x%02x ", btif_me_get_remote_device_bdaddr(remDev)->address, BTIF_BD_ADDR_SIZE); - } - else - { - TRACE(3,"checker: %s remDev:%p cmgrHandler:%p", str, remDev, cmgrHandler); - } + TRACE(2, "checker: %s remDev:%p remote_dev_address:", str, remDev); + DUMP8("0x%02x ", btif_me_get_remote_device_bdaddr(remDev)->address, + BTIF_BD_ADDR_SIZE); + } else { + TRACE(3, "checker: %s remDev:%p cmgrHandler:%p", str, remDev, cmgrHandler); + } - if (a2dp_stream) - { - TRACE(1,"a2dp State:%d", btif_a2dp_get_stream_state(a2dp_stream)); - if (btif_a2dp_get_stream_state(a2dp_stream) > BTIF_AVDTP_STRM_STATE_IDLE) - { - TRACE(1,"a2dp cmgrHandler remDev:%p", btif_a2dp_get_stream_devic_cmgrHandler_remdev(a2dp_stream)); - } + if (a2dp_stream) { + TRACE(1, "a2dp State:%d", btif_a2dp_get_stream_state(a2dp_stream)); + if (btif_a2dp_get_stream_state(a2dp_stream) > BTIF_AVDTP_STRM_STATE_IDLE) { + TRACE(1, "a2dp cmgrHandler remDev:%p", + btif_a2dp_get_stream_devic_cmgrHandler_remdev(a2dp_stream)); } - else - { - TRACE(1,"%s a2dp stream NULL", str); - } - if (hf_channel) - { - TRACE(4,"hf_channel Connected:%d IsAudioUp:%d/%d remDev:%p", btif_hf_is_acl_connected(hf_channel), - app_bt_device.hf_audio_state[0], - btif_hf_check_AudioConnect_status(hf_channel), - btif_hf_cmgr_get_remote_device(hf_channel)); - } - else - { - TRACE(1,"%s hf_channel NULL", str); - } - return 0; + } else { + TRACE(1, "%s a2dp stream NULL", str); + } + if (hf_channel) { + TRACE(4, "hf_channel Connected:%d IsAudioUp:%d/%d remDev:%p", + btif_hf_is_acl_connected(hf_channel), app_bt_device.hf_audio_state[0], + btif_hf_check_AudioConnect_status(hf_channel), + btif_hf_cmgr_get_remote_device(hf_channel)); + } else { + TRACE(1, "%s hf_channel NULL", str); + } + return 0; } #endif -int app_bt_state_checker(void) -{ - btif_remote_device_t *remDev = NULL; - btif_cmgr_handler_t *cmgrHandler; +int app_bt_state_checker(void) { + btif_remote_device_t *remDev = NULL; + btif_cmgr_handler_t *cmgrHandler; - osapi_lock_stack(); + osapi_lock_stack(); #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (app_tws_ibrt_mobile_link_connected()) - { - TRACE(1,"checker: IBRT_MASTER activeCons:%d", btif_me_get_activeCons()); - remDev = p_ibrt_ctrl->p_tws_remote_dev; - if (remDev != NULL) - { - cmgrHandler = btif_cmgr_get_acl_handler(remDev); - if (cmgrHandler) - { - app_bt_ibrt_profile_checker("tws peers", remDev, cmgrHandler, NULL, NULL); - } - else - { - TRACE(0,"checker: cmgrhandler not handle p_tws_remote_dev!"); - } - } - else - { - TRACE(0,"checker: tws_remote_dev is NULL!"); - } + if (app_tws_ibrt_mobile_link_connected()) { + TRACE(1, "checker: IBRT_MASTER activeCons:%d", btif_me_get_activeCons()); + remDev = p_ibrt_ctrl->p_tws_remote_dev; + if (remDev != NULL) { + cmgrHandler = btif_cmgr_get_acl_handler(remDev); + if (cmgrHandler) { + app_bt_ibrt_profile_checker("tws peers", remDev, cmgrHandler, NULL, + NULL); + } else { + TRACE(0, "checker: cmgrhandler not handle p_tws_remote_dev!"); + } + } else { + TRACE(0, "checker: tws_remote_dev is NULL!"); + } - remDev = p_ibrt_ctrl->p_mobile_remote_dev; - if (remDev != NULL) - { - cmgrHandler = btif_cmgr_get_acl_handler(remDev); - if (cmgrHandler) - { - app_bt_ibrt_profile_checker("master mobile", remDev, cmgrHandler, app_bt_device.a2dp_connected_stream[0], - app_bt_device.hf_conn_flag[0] ? app_bt_device.hf_channel[0] : NULL); - } - else - { - TRACE(0,"checker: cmgrhandler not handle mobile_remote_dev"); - } - } - else - { - TRACE(0,"checker: mobile_remote_dev is NULL!"); - } + remDev = p_ibrt_ctrl->p_mobile_remote_dev; + if (remDev != NULL) { + cmgrHandler = btif_cmgr_get_acl_handler(remDev); + if (cmgrHandler) { + app_bt_ibrt_profile_checker( + "master mobile", remDev, cmgrHandler, + app_bt_device.a2dp_connected_stream[0], + app_bt_device.hf_conn_flag[0] ? app_bt_device.hf_channel[0] : NULL); + } else { + TRACE(0, "checker: cmgrhandler not handle mobile_remote_dev"); + } + } else { + TRACE(0, "checker: mobile_remote_dev is NULL!"); } - else if (app_tws_ibrt_slave_ibrt_link_connected()) - { - TRACE(1,"checker: IBRT_SLAVE activeCons:%d", btif_me_get_activeCons()); - remDev = p_ibrt_ctrl->p_tws_remote_dev; - if (remDev != NULL) - { - cmgrHandler = btif_cmgr_get_acl_handler(remDev); - if (cmgrHandler) - { - app_bt_ibrt_profile_checker("tws peers", remDev, cmgrHandler, NULL, NULL); - } - else - { - TRACE(0,"checker: cmgrhandler not handle p_tws_remote_dev!"); - } - } - else - { - TRACE(0,"checker: tws_remote_dev is NULL!"); - } - if (app_ibrt_ui_is_profile_exchanged()) - { - app_bt_ibrt_profile_checker("ibrt mobile", NULL, NULL, app_bt_device.a2dp_connected_stream[0], - app_bt_device.hf_conn_flag[0] ? app_bt_device.hf_channel[0] : NULL); - } + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + TRACE(1, "checker: IBRT_SLAVE activeCons:%d", btif_me_get_activeCons()); + remDev = p_ibrt_ctrl->p_tws_remote_dev; + if (remDev != NULL) { + cmgrHandler = btif_cmgr_get_acl_handler(remDev); + if (cmgrHandler) { + app_bt_ibrt_profile_checker("tws peers", remDev, cmgrHandler, NULL, + NULL); + } else { + TRACE(0, "checker: cmgrhandler not handle p_tws_remote_dev!"); + } + } else { + TRACE(0, "checker: tws_remote_dev is NULL!"); } - else - { - TRACE(1,"checker: IBRT_UNKNOW activeCons:%d", btif_me_get_activeCons()); + if (app_ibrt_ui_is_profile_exchanged()) { + app_bt_ibrt_profile_checker( + "ibrt mobile", NULL, NULL, app_bt_device.a2dp_connected_stream[0], + app_bt_device.hf_conn_flag[0] ? app_bt_device.hf_channel[0] : NULL); } - app_ibrt_if_ctx_checker(); + } else { + TRACE(1, "checker: IBRT_UNKNOW activeCons:%d", btif_me_get_activeCons()); + } + app_ibrt_if_ctx_checker(); #if defined(ENHANCED_STACK) - btif_me_cobuf_state_dump(); - btif_me_hcibuff_state_dump(); + btif_me_cobuf_state_dump(); + btif_me_hcibuff_state_dump(); #endif - //BT controller state checker - ASSERT(bt_drv_reg_op_check_bt_controller_state(), "BT controller dead!"); + // BT controller state checker + ASSERT(bt_drv_reg_op_check_bt_controller_state(), "BT controller dead!"); #else - for (uint8_t i=0; imaxInterval, - app_bt_device.hf_audio_state[i]); - DUMP8("0x%02x ", btif_me_get_remote_device_bdaddr(remDev)->address, BTIF_BD_ADDR_SIZE); - TRACE(4,"remDev:%p a2dp State:%d hf_channel Connected:%d remDev:%p ", - remDev, - app_bt_device.a2dp_connected_stream[i] ? btif_a2dp_get_stream_state(app_bt_device.a2dp_connected_stream[i]):BTIF_A2DP_STREAM_STATE_CLOSED, - app_bt_device.hf_conn_flag[i], - app_bt_device.hf_conn_flag[i] ? (btif_remote_device_t *)btif_hf_cmgr_get_remote_device(app_bt_device.hf_channel[i]):NULL); - } - } - else - { - TRACE(1,"checker: id:%d remDev is NULL!", i); - } + for (uint8_t i = 0; i < BT_DEVICE_NUM; i++) { + remDev = btif_me_enumerate_remote_devices(i); + if (remDev != NULL) { + cmgrHandler = btif_cmgr_get_acl_handler(remDev); + if (cmgrHandler) { + TRACE(8, + "checker: id:%d state:%d mode:%d role:%d cmghdl:%p " + "sniffInterva:%d/%d IsAudioUp:%d", + i, btif_me_get_remote_device_state(remDev), + btif_me_get_remote_device_mode(remDev), + btif_me_get_remote_device_role(remDev), cmgrHandler, + btif_cmgr_get_cmgrhandler_sniff_Interval(cmgrHandler), + btif_cmgr_get_cmgrhandler_sniff_info(cmgrHandler)->maxInterval, + app_bt_device.hf_audio_state[i]); + DUMP8("0x%02x ", btif_me_get_remote_device_bdaddr(remDev)->address, + BTIF_BD_ADDR_SIZE); + TRACE(4, "remDev:%p a2dp State:%d hf_channel Connected:%d remDev:%p ", + remDev, + app_bt_device.a2dp_connected_stream[i] + ? btif_a2dp_get_stream_state( + app_bt_device.a2dp_connected_stream[i]) + : BTIF_A2DP_STREAM_STATE_CLOSED, + app_bt_device.hf_conn_flag[i], + app_bt_device.hf_conn_flag[i] + ? (btif_remote_device_t *)btif_hf_cmgr_get_remote_device( + app_bt_device.hf_channel[i]) + : NULL); + } + } else { + TRACE(1, "checker: id:%d remDev is NULL!", i); + } #ifdef __AI_VOICE__ - TRACE(1,"ai_setup_complete %d", app_ai_is_setup_complete()); + TRACE(1, "ai_setup_complete %d", app_ai_is_setup_complete()); #endif #ifdef IS_MULTI_AI_ENABLED - TRACE(1,"current_spec %d", app_ai_manager_get_current_spec()); + TRACE(1, "current_spec %d", app_ai_manager_get_current_spec()); #endif -#if defined (__HSP_ENABLE__) - TRACE(2,"hs_channel Connected:%d remDev:%p ", - app_bt_device.hs_conn_flag[i], - app_bt_device.hs_channel[i].cmgrHandler.remDev); +#if defined(__HSP_ENABLE__) + TRACE(2, "hs_channel Connected:%d remDev:%p ", + app_bt_device.hs_conn_flag[i], + app_bt_device.hs_channel[i].cmgrHandler.remDev); #endif - TRACE(2,"%s btif_me_get_activeCons = %d",__func__,btif_me_get_activeCons()); + TRACE(2, "%s btif_me_get_activeCons = %d", __func__, + btif_me_get_activeCons()); #ifdef HFP_DEBUG - hfp_call_state_checker(); + hfp_call_state_checker(); #endif - } + } #if defined(ENHANCED_STACK) - btif_me_cobuf_state_dump(); - btif_me_hcibuff_state_dump(); + btif_me_cobuf_state_dump(); + btif_me_hcibuff_state_dump(); #endif #endif - osapi_unlock_stack(); + osapi_unlock_stack(); - return 0; + return 0; } -static uint8_t app_bt_get_devId_from_RemDev( btif_remote_device_t* remDev) -{ - uint8_t connectedDevId = 0; - for (uint8_t devId = 0; devId < BT_DEVICE_NUM; devId++) - { - if ( btif_me_enumerate_remote_devices(devId) == remDev) - { - TRACE(2, "%s %d", __func__, devId); - connectedDevId = devId; - break; - } +static uint8_t app_bt_get_devId_from_RemDev(btif_remote_device_t *remDev) { + uint8_t connectedDevId = 0; + for (uint8_t devId = 0; devId < BT_DEVICE_NUM; devId++) { + if (btif_me_enumerate_remote_devices(devId) == remDev) { + TRACE(2, "%s %d", __func__, devId); + connectedDevId = devId; + break; } + } - return connectedDevId; + return connectedDevId; } -void app_bt_accessible_manager_process(const btif_event_t *Event) -{ +void app_bt_accessible_manager_process(const btif_event_t *Event) { #if defined(IBRT) - //IBRT device's access mode will be controlled by UI - return; + // IBRT device's access mode will be controlled by UI + return; #else - btif_event_type_t etype = btif_me_get_callback_event_type(Event); + btif_event_type_t etype = btif_me_get_callback_event_type(Event); #ifdef __BT_ONE_BRING_TWO__ - static uint8_t opening_reconnect_cnf_cnt = 0; - //uint8_t disconnectedDevId = app_bt_get_devId_from_RemDev(btif_me_get_callback_event_rem_dev( Event)); + static uint8_t opening_reconnect_cnf_cnt = 0; + // uint8_t disconnectedDevId = + // app_bt_get_devId_from_RemDev(btif_me_get_callback_event_rem_dev( Event)); - if (app_bt_profile_connect_openreconnecting(NULL)) - { - if (etype == BTIF_BTEVENT_LINK_CONNECT_CNF) - { - opening_reconnect_cnf_cnt++; - } - if (record2_avalible) - { - if (opening_reconnect_cnf_cnt<2) - { - return; - } - } + if (app_bt_profile_connect_openreconnecting(NULL)) { + if (etype == BTIF_BTEVENT_LINK_CONNECT_CNF) { + opening_reconnect_cnf_cnt++; + } + if (record2_avalible) { + if (opening_reconnect_cnf_cnt < 2) { + return; + } + } + } +#endif + switch (etype) { + case BTIF_BTEVENT_LINK_CONNECT_CNF: + case BTIF_BTEVENT_LINK_CONNECT_IND: + TRACE(1, "BTEVENT_LINK_CONNECT_IND/CNF activeCons:%d", + btif_me_get_activeCons()); +#if defined(__BTIF_EARPHONE__) && !defined(FPGA) + app_stop_10_second_timer(APP_PAIR_TIMER_ID); +#endif +#ifdef __BT_ONE_BRING_TWO__ + if (btif_me_get_activeCons() == 0) { +#ifdef __EARPHONE_STAY_BOTH_SCAN__ + app_bt_accessmode_set_req(BTIF_BT_DEFAULT_ACCESS_MODE_PAIR); +#else + app_bt_accessmode_set_req(BTIF_BAM_CONNECTABLE_ONLY); +#endif + } else if (btif_me_get_activeCons() == 1) { + app_bt_accessmode_set_req(BTIF_BAM_CONNECTABLE_ONLY); + } else if (btif_me_get_activeCons() >= 2) { + app_bt_accessmode_set_req(BTIF_BAM_NOT_ACCESSIBLE); + } +#else + if (btif_me_get_activeCons() == 0) { +#ifdef __EARPHONE_STAY_BOTH_SCAN__ + app_bt_accessmode_set_req(BTIF_BT_DEFAULT_ACCESS_MODE_PAIR); +#else + app_bt_accessmode_set_req(BTIF_BAM_CONNECTABLE_ONLY); +#endif + } else if (btif_me_get_activeCons() >= 1) { + app_bt_accessmode_set_req(BTIF_BAM_NOT_ACCESSIBLE); } #endif - switch (etype) - { - case BTIF_BTEVENT_LINK_CONNECT_CNF: - case BTIF_BTEVENT_LINK_CONNECT_IND: - TRACE(1,"BTEVENT_LINK_CONNECT_IND/CNF activeCons:%d",btif_me_get_activeCons()); -#if defined(__BTIF_EARPHONE__) && !defined(FPGA) - app_stop_10_second_timer(APP_PAIR_TIMER_ID); -#endif -#ifdef __BT_ONE_BRING_TWO__ - if(btif_me_get_activeCons() == 0) - { -#ifdef __EARPHONE_STAY_BOTH_SCAN__ - app_bt_accessmode_set_req(BTIF_BT_DEFAULT_ACCESS_MODE_PAIR); -#else - app_bt_accessmode_set_req(BTIF_BAM_CONNECTABLE_ONLY); -#endif - } - else if(btif_me_get_activeCons() == 1) - { - app_bt_accessmode_set_req(BTIF_BAM_CONNECTABLE_ONLY); - } - else if(btif_me_get_activeCons() >= 2) - { - app_bt_accessmode_set_req(BTIF_BAM_NOT_ACCESSIBLE); - } -#else - if(btif_me_get_activeCons() == 0) - { -#ifdef __EARPHONE_STAY_BOTH_SCAN__ - app_bt_accessmode_set_req(BTIF_BT_DEFAULT_ACCESS_MODE_PAIR); -#else - app_bt_accessmode_set_req(BTIF_BAM_CONNECTABLE_ONLY); -#endif - } - else if(btif_me_get_activeCons() >= 1) - { - app_bt_accessmode_set_req(BTIF_BAM_NOT_ACCESSIBLE); - } -#endif - break; - case BTIF_BTEVENT_LINK_DISCONNECT: - TRACE(1,"DISCONNECT activeCons:%d",btif_me_get_activeCons()); + break; + case BTIF_BTEVENT_LINK_DISCONNECT: + TRACE(1, "DISCONNECT activeCons:%d", btif_me_get_activeCons()); #ifdef __EARPHONE_STAY_BOTH_SCAN__ #ifdef __BT_ONE_BRING_TWO__ - if(btif_me_get_activeCons() == 0) - { - app_bt_accessmode_set_req(BTIF_BT_DEFAULT_ACCESS_MODE_PAIR); - } - else if(btif_me_get_activeCons() == 1) - { - app_bt_accessmode_set_req(BTIF_BAM_CONNECTABLE_ONLY); - } - else if(btif_me_get_activeCons() >= 2) - { - app_bt_accessmode_set_req(BTIF_BAM_NOT_ACCESSIBLE); - } -#else - app_bt_accessmode_set_req(BTIF_BT_DEFAULT_ACCESS_MODE_PAIR); -#endif -#else - app_bt_accessmode_set_req(BTIF_BAM_CONNECTABLE_ONLY); -#endif - break; -#ifdef __BT_ONE_BRING_TWO__ - case BTIF_BTEVENT_SCO_CONNECT_IND: - case BTIF_BTEVENT_SCO_CONNECT_CNF: - if(btif_me_get_activeCons() == 1) - { - app_bt_accessmode_set_req(BTIF_BAM_NOT_ACCESSIBLE); - } - break; - case BTIF_BTEVENT_SCO_DISCONNECT: - if(btif_me_get_activeCons() == 1) - { - app_bt_accessmode_set_req(BTIF_BAM_CONNECTABLE_ONLY); - } - break; -#endif - default: - break; + if (btif_me_get_activeCons() == 0) { + app_bt_accessmode_set_req(BTIF_BT_DEFAULT_ACCESS_MODE_PAIR); + } else if (btif_me_get_activeCons() == 1) { + app_bt_accessmode_set_req(BTIF_BAM_CONNECTABLE_ONLY); + } else if (btif_me_get_activeCons() >= 2) { + app_bt_accessmode_set_req(BTIF_BAM_NOT_ACCESSIBLE); } +#else + app_bt_accessmode_set_req(BTIF_BT_DEFAULT_ACCESS_MODE_PAIR); +#endif +#else + app_bt_accessmode_set_req(BTIF_BAM_CONNECTABLE_ONLY); +#endif + break; +#ifdef __BT_ONE_BRING_TWO__ + case BTIF_BTEVENT_SCO_CONNECT_IND: + case BTIF_BTEVENT_SCO_CONNECT_CNF: + if (btif_me_get_activeCons() == 1) { + app_bt_accessmode_set_req(BTIF_BAM_NOT_ACCESSIBLE); + } + break; + case BTIF_BTEVENT_SCO_DISCONNECT: + if (btif_me_get_activeCons() == 1) { + app_bt_accessmode_set_req(BTIF_BAM_CONNECTABLE_ONLY); + } + break; +#endif + default: + break; + } #endif } #define APP_BT_SWITCHROLE_LIMIT (2) //#define __SET_OUR_AS_MASTER__ -void app_bt_role_manager_process(const btif_event_t *Event) -{ -#if defined(IBRT) || defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) || defined(__APP_A2DP_SOURCE__) - return; +void app_bt_role_manager_process(const btif_event_t *Event) { +#if defined(IBRT) || defined(APP_LINEIN_A2DP_SOURCE) || \ + defined(APP_I2S_A2DP_SOURCE) || defined(__APP_A2DP_SOURCE__) + return; #else - static btif_remote_device_t *opRemDev = NULL; - static uint8_t switchrole_cnt = 0; - btif_remote_device_t *remDev = NULL; - btif_event_type_t etype = btif_me_get_callback_event_type(Event); - //on phone connecting - switch (etype) - { - case BTIF_BTEVENT_LINK_CONNECT_IND: - if( btif_me_get_callback_event_err_code(Event) == BTIF_BEC_NO_ERROR) - { - if (btif_me_get_activeCons() == 1) - { - switch ( btif_me_get_callback_event_rem_dev_role (Event)) - { + static btif_remote_device_t *opRemDev = NULL; + static uint8_t switchrole_cnt = 0; + btif_remote_device_t *remDev = NULL; + btif_event_type_t etype = btif_me_get_callback_event_type(Event); + // on phone connecting + switch (etype) { + case BTIF_BTEVENT_LINK_CONNECT_IND: + if (btif_me_get_callback_event_err_code(Event) == BTIF_BEC_NO_ERROR) { + if (btif_me_get_activeCons() == 1) { + switch (btif_me_get_callback_event_rem_dev_role(Event)) { #if defined(__SET_OUR_AS_MASTER__) - case BTIF_BCR_SLAVE: - case BTIF_BCR_PSLAVE: + case BTIF_BCR_SLAVE: + case BTIF_BCR_PSLAVE: #else - case BTIF_BCR_MASTER: - case BTIF_BCR_PMASTER: + case BTIF_BCR_MASTER: + case BTIF_BCR_PMASTER: #endif - TRACE(1,"CONNECT_IND try to role %p\n", btif_me_get_callback_event_rem_dev( Event)); - //curr connectrot try to role - opRemDev =btif_me_get_callback_event_rem_dev( Event); - switchrole_cnt = 0; - app_bt_Me_SetLinkPolicy(btif_me_get_callback_event_rem_dev( Event), BTIF_BLP_MASTER_SLAVE_SWITCH|BTIF_BLP_SNIFF_MODE); - break; + TRACE(1, "CONNECT_IND try to role %p\n", + btif_me_get_callback_event_rem_dev(Event)); + // curr connectrot try to role + opRemDev = btif_me_get_callback_event_rem_dev(Event); + switchrole_cnt = 0; + app_bt_Me_SetLinkPolicy(btif_me_get_callback_event_rem_dev(Event), + BTIF_BLP_MASTER_SLAVE_SWITCH | + BTIF_BLP_SNIFF_MODE); + break; #if defined(__SET_OUR_AS_MASTER__) - case BTIF_BCR_MASTER: - case BTIF_BCR_PMASTER: + case BTIF_BCR_MASTER: + case BTIF_BCR_PMASTER: #else - case BTIF_BCR_SLAVE: - case BTIF_BCR_PSLAVE: + case BTIF_BCR_SLAVE: + case BTIF_BCR_PSLAVE: #endif - case BTIF_BCR_ANY: - case BTIF_BCR_UNKNOWN: - default: - TRACE(1,"CONNECT_IND disable role %p\n",btif_me_get_callback_event_rem_dev( Event)); - //disable roleswitch when 1 connect - app_bt_Me_SetLinkPolicy ( btif_me_get_callback_event_rem_dev( Event), BTIF_BLP_SNIFF_MODE); - break; - } - //set next connector to master - app_bt_ME_SetConnectionRole(BTIF_BCR_MASTER); - } - else if (btif_me_get_activeCons() > 1) - { - switch (btif_me_get_callback_event_rem_dev_role (Event)) - { - case BTIF_BCR_MASTER: - case BTIF_BCR_PMASTER: - TRACE(1,"CONNECT_IND disable role %p\n",btif_me_get_callback_event_rem_dev( Event)); - //disable roleswitch - app_bt_Me_SetLinkPolicy(btif_me_get_callback_event_rem_dev( Event), BTIF_BLP_SNIFF_MODE); - break; - case BTIF_BCR_SLAVE: - case BTIF_BCR_PSLAVE: - case BTIF_BCR_ANY: - case BTIF_BCR_UNKNOWN: - default: - //disconnect slave - TRACE(1,"CONNECT_IND disconnect slave %p\n",btif_me_get_callback_event_rem_dev( Event)); - app_bt_MeDisconnectLink(btif_me_get_callback_event_rem_dev( Event)); - break; - } - //set next connector to master - app_bt_ME_SetConnectionRole(BTIF_BCR_MASTER); - } - } - break; - case BTIF_BTEVENT_LINK_CONNECT_CNF: - if (btif_me_get_activeCons() == 1) - { - switch (btif_me_get_callback_event_rem_dev_role (Event)) - { -#if defined(__SET_OUR_AS_MASTER__) - case BTIF_BCR_SLAVE: - case BTIF_BCR_PSLAVE: -#else - case BTIF_BCR_MASTER: - case BTIF_BCR_PMASTER: -#endif - TRACE(1,"CONNECT_CNF try to role %p\n",btif_me_get_callback_event_rem_dev( Event)); - //curr connectrot try to role - opRemDev =btif_me_get_callback_event_rem_dev( Event); - switchrole_cnt = 0; - app_bt_Me_SetLinkPolicy(btif_me_get_callback_event_rem_dev( Event), BTIF_BLP_MASTER_SLAVE_SWITCH|BTIF_BLP_SNIFF_MODE); - app_bt_ME_SwitchRole(btif_me_get_callback_event_rem_dev( Event)); - break; -#if defined(__SET_OUR_AS_MASTER__) - case BTIF_BCR_MASTER: - case BTIF_BCR_PMASTER: -#else - case BTIF_BCR_SLAVE: - case BTIF_BCR_PSLAVE: -#endif - case BTIF_BCR_ANY: - case BTIF_BCR_UNKNOWN: - default: - TRACE(1,"CONNECT_CNF disable role %p\n",btif_me_get_callback_event_rem_dev( Event)); - //disable roleswitch - app_bt_Me_SetLinkPolicy(btif_me_get_callback_event_rem_dev( Event), BTIF_BLP_SNIFF_MODE); - break; - } - //set next connector to master - app_bt_ME_SetConnectionRole(BTIF_BCR_MASTER); - } - else if (btif_me_get_activeCons() > 1) - { - switch (btif_me_get_callback_event_rem_dev_role (Event)) - { - case BTIF_BCR_MASTER: - case BTIF_BCR_PMASTER : - TRACE(1,"CONNECT_CNF disable role %p\n",btif_me_get_callback_event_rem_dev( Event)); - //disable roleswitch - app_bt_Me_SetLinkPolicy(btif_me_get_callback_event_rem_dev( Event), BTIF_BLP_SNIFF_MODE); - break; - case BTIF_BCR_SLAVE: - case BTIF_BCR_ANY: - case BTIF_BCR_UNKNOWN: - default: - //disconnect slave - TRACE(1,"CONNECT_CNF disconnect slave %p\n",btif_me_get_callback_event_rem_dev( Event)); - app_bt_MeDisconnectLink(btif_me_get_callback_event_rem_dev( Event)); - break; - } - //set next connector to master - app_bt_ME_SetConnectionRole(BTIF_BCR_MASTER); - } - break; - case BTIF_BTEVENT_LINK_DISCONNECT: - if (opRemDev ==btif_me_get_callback_event_rem_dev( Event)) - { - opRemDev = NULL; - switchrole_cnt = 0; - } - if (btif_me_get_activeCons() == 0) - { - for (uint8_t i=0; i 1) - { - uint8_t slave_cnt = 0; - for (uint8_t i=0; i1) - { - TRACE(1,"ROLE_CHANGE disconnect slave %p\n",btif_me_get_callback_event_rem_dev( Event)); - app_bt_MeDisconnectLink(btif_me_get_callback_event_rem_dev( Event)); - } - } - break; + case BTIF_BCR_ANY: + case BTIF_BCR_UNKNOWN: default: - break; + TRACE(1, "CONNECT_IND disable role %p\n", + btif_me_get_callback_event_rem_dev(Event)); + // disable roleswitch when 1 connect + app_bt_Me_SetLinkPolicy(btif_me_get_callback_event_rem_dev(Event), + BTIF_BLP_SNIFF_MODE); + break; + } + // set next connector to master + app_bt_ME_SetConnectionRole(BTIF_BCR_MASTER); + } else if (btif_me_get_activeCons() > 1) { + switch (btif_me_get_callback_event_rem_dev_role(Event)) { + case BTIF_BCR_MASTER: + case BTIF_BCR_PMASTER: + TRACE(1, "CONNECT_IND disable role %p\n", + btif_me_get_callback_event_rem_dev(Event)); + // disable roleswitch + app_bt_Me_SetLinkPolicy(btif_me_get_callback_event_rem_dev(Event), + BTIF_BLP_SNIFF_MODE); + break; + case BTIF_BCR_SLAVE: + case BTIF_BCR_PSLAVE: + case BTIF_BCR_ANY: + case BTIF_BCR_UNKNOWN: + default: + // disconnect slave + TRACE(1, "CONNECT_IND disconnect slave %p\n", + btif_me_get_callback_event_rem_dev(Event)); + app_bt_MeDisconnectLink(btif_me_get_callback_event_rem_dev(Event)); + break; + } + // set next connector to master + app_bt_ME_SetConnectionRole(BTIF_BCR_MASTER); + } } -#endif -} - -void app_bt_role_manager_process_dual_slave(const btif_event_t *Event) -{ -#if defined(IBRT) || defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) || defined(__APP_A2DP_SOURCE__) - return; -#else - static btif_remote_device_t *opRemDev = NULL; - static uint8_t switchrole_cnt = 0; - //btif_remote_device_t *remDev = NULL; - //on phone connecting - switch ( btif_me_get_callback_event_type(Event)) - { - case BTIF_BTEVENT_LINK_CONNECT_IND: - case BTIF_BTEVENT_LINK_CONNECT_CNF: - if(btif_me_get_callback_event_err_code(Event) == BTIF_BEC_NO_ERROR) - { - switch (btif_me_get_callback_event_rem_dev_role (Event)) - { + break; + case BTIF_BTEVENT_LINK_CONNECT_CNF: + if (btif_me_get_activeCons() == 1) { + switch (btif_me_get_callback_event_rem_dev_role(Event)) { #if defined(__SET_OUR_AS_MASTER__) - case BTIF_BCR_SLAVE: - case BTIF_BCR_PSLAVE: + case BTIF_BCR_SLAVE: + case BTIF_BCR_PSLAVE: #else - case BTIF_BCR_MASTER: - case BTIF_BCR_PMASTER: + case BTIF_BCR_MASTER: + case BTIF_BCR_PMASTER: #endif - TRACE(1,"CONNECT_IND/CNF try to role %p\n",btif_me_get_callback_event_rem_dev( Event)); - opRemDev =btif_me_get_callback_event_rem_dev( Event); - switchrole_cnt = 0; - app_bt_Me_SetLinkPolicy(btif_me_get_callback_event_rem_dev( Event), BTIF_BLP_MASTER_SLAVE_SWITCH|BTIF_BLP_SNIFF_MODE); - app_bt_ME_SwitchRole(btif_me_get_callback_event_rem_dev( Event)); - break; + TRACE(1, "CONNECT_CNF try to role %p\n", + btif_me_get_callback_event_rem_dev(Event)); + // curr connectrot try to role + opRemDev = btif_me_get_callback_event_rem_dev(Event); + switchrole_cnt = 0; + app_bt_Me_SetLinkPolicy(btif_me_get_callback_event_rem_dev(Event), + BTIF_BLP_MASTER_SLAVE_SWITCH | + BTIF_BLP_SNIFF_MODE); + app_bt_ME_SwitchRole(btif_me_get_callback_event_rem_dev(Event)); + break; #if defined(__SET_OUR_AS_MASTER__) - case BTIF_BCR_MASTER: - case BTIF_BCR_PMASTER: + case BTIF_BCR_MASTER: + case BTIF_BCR_PMASTER: #else - case BTIF_BCR_SLAVE: - case BTIF_BCR_PSLAVE: + case BTIF_BCR_SLAVE: + case BTIF_BCR_PSLAVE: #endif - case BTIF_BCR_ANY: - case BTIF_BCR_UNKNOWN: - default: - TRACE(1,"CONNECT_IND disable role %p\n",btif_me_get_callback_event_rem_dev( Event)); - app_bt_Me_SetLinkPolicy(btif_me_get_callback_event_rem_dev( Event), BTIF_BLP_SNIFF_MODE); - break; - } - app_bt_ME_SetConnectionRole(BTIF_BCR_SLAVE); - } - break; - case BTIF_BTEVENT_LINK_DISCONNECT: - if (opRemDev ==btif_me_get_callback_event_rem_dev( Event)) - { - opRemDev = NULL; - switchrole_cnt = 0; - } - if ( btif_me_get_activeCons() == 0) - { - for (uint8_t i=0; i 1) { + switch (btif_me_get_callback_event_rem_dev_role(Event)) { + case BTIF_BCR_MASTER: + case BTIF_BCR_PMASTER: + TRACE(1, "CONNECT_CNF disable role %p\n", + btif_me_get_callback_event_rem_dev(Event)); + // disable roleswitch + app_bt_Me_SetLinkPolicy(btif_me_get_callback_event_rem_dev(Event), + BTIF_BLP_SNIFF_MODE); + break; + case BTIF_BCR_SLAVE: + case BTIF_BCR_ANY: + case BTIF_BCR_UNKNOWN: + default: + // disconnect slave + TRACE(1, "CONNECT_CNF disconnect slave %p\n", + btif_me_get_callback_event_rem_dev(Event)); + app_bt_MeDisconnectLink(btif_me_get_callback_event_rem_dev(Event)); + break; + } + // set next connector to master + app_bt_ME_SetConnectionRole(BTIF_BCR_MASTER); } + break; + case BTIF_BTEVENT_LINK_DISCONNECT: + if (opRemDev == btif_me_get_callback_event_rem_dev(Event)) { + opRemDev = NULL; + switchrole_cnt = 0; + } + if (btif_me_get_activeCons() == 0) { + for (uint8_t i = 0; i < BT_DEVICE_NUM; i++) { + if (app_bt_device.a2dp_connected_stream[i]) + app_bt_A2DP_SetMasterRole(app_bt_device.a2dp_connected_stream[i], + FALSE); + app_bt_HF_SetMasterRole(app_bt_device.hf_channel[i], FALSE); + } + app_bt_ME_SetConnectionRole(BTIF_BCR_ANY); + } else if (btif_me_get_activeCons() == 1) { + // set next connector to master + app_bt_ME_SetConnectionRole(BTIF_BCR_MASTER); + } + break; + case BTIF_BTEVENT_ROLE_CHANGE: + if (opRemDev == btif_me_get_callback_event_rem_dev(Event)) { + switch (btif_me_get_callback_event_role_change_new_role(Event)) { +#if defined(__SET_OUR_AS_MASTER__) + case BTIF_BCR_SLAVE: +#else + case BTIF_BCR_MASTER: #endif -} + if (++switchrole_cnt <= APP_BT_SWITCHROLE_LIMIT) { + app_bt_ME_SwitchRole(btif_me_get_callback_event_rem_dev(Event)); + } else { +#if defined(__SET_OUR_AS_MASTER__) + TRACE(2, "ROLE TO MASTER FAILED remDev %p cnt:%d\n", + btif_me_get_callback_event_rem_dev(Event), switchrole_cnt); +#else + TRACE(2, "ROLE TO SLAVE FAILED remDev %p cnt:%d\n", + btif_me_get_callback_event_rem_dev(Event), switchrole_cnt); +#endif + opRemDev = NULL; + switchrole_cnt = 0; + } + break; +#if defined(__SET_OUR_AS_MASTER__) + case BTIF_BCR_MASTER: + TRACE(2, "ROLE TO MASTER SUCCESS remDev %p cnt:%d\n", + btif_me_get_callback_event_rem_dev(Event), switchrole_cnt); +#else + case BTIF_BCR_SLAVE: + TRACE(2, "ROLE TO SLAVE SUCCESS remDev %p cnt:%d\n", + btif_me_get_callback_event_rem_dev(Event), switchrole_cnt); +#endif + opRemDev = NULL; + switchrole_cnt = 0; + app_bt_Me_SetLinkPolicy(btif_me_get_callback_event_rem_dev(Event), + BTIF_BLP_SNIFF_MODE); + break; + case BTIF_BCR_ANY: + break; + case BTIF_BCR_UNKNOWN: + break; + default: + break; + } + } -static int app_bt_sniff_manager_init(void) -{ - btif_sniff_info_t sniffInfo; - btif_remote_device_t *remDev = NULL; - - for (uint8_t i=0; i 1) { + uint8_t slave_cnt = 0; + for (uint8_t i = 0; i < BT_DEVICE_NUM; i++) { remDev = btif_me_enumerate_remote_devices(i); - sniffInfo.maxInterval = BTIF_CMGR_SNIFF_MAX_INTERVAL; - sniffInfo.minInterval = BTIF_CMGR_SNIFF_MIN_INTERVAL; - sniffInfo.attempt = BTIF_CMGR_SNIFF_ATTEMPT; - sniffInfo.timeout =BTIF_CMGR_SNIFF_TIMEOUT; - app_bt_CMGR_SetSniffInfoToAllHandlerByRemDev(&sniffInfo, remDev); - app_bt_HF_EnableSniffMode(app_bt_device.hf_channel[i], FALSE); -#if defined (__HSP_ENABLE__) - app_bt_HS_EnableSniffMode(&app_bt_device.hs_channel[i], FALSE); -#endif + if (btif_me_get_current_role(remDev) == BTIF_BCR_SLAVE) { + slave_cnt++; + } + } + if (slave_cnt > 1) { + TRACE(1, "ROLE_CHANGE disconnect slave %p\n", + btif_me_get_callback_event_rem_dev(Event)); + app_bt_MeDisconnectLink(btif_me_get_callback_event_rem_dev(Event)); + } } - - return 0; + break; + default: + break; + } +#endif } -void app_bt_sniff_config(btif_remote_device_t *remDev) -{ - btif_sniff_info_t sniffInfo; +void app_bt_role_manager_process_dual_slave(const btif_event_t *Event) { +#if defined(IBRT) || defined(APP_LINEIN_A2DP_SOURCE) || \ + defined(APP_I2S_A2DP_SOURCE) || defined(__APP_A2DP_SOURCE__) + return; +#else + static btif_remote_device_t *opRemDev = NULL; + static uint8_t switchrole_cnt = 0; + // btif_remote_device_t *remDev = NULL; + // on phone connecting + switch (btif_me_get_callback_event_type(Event)) { + case BTIF_BTEVENT_LINK_CONNECT_IND: + case BTIF_BTEVENT_LINK_CONNECT_CNF: + if (btif_me_get_callback_event_err_code(Event) == BTIF_BEC_NO_ERROR) { + switch (btif_me_get_callback_event_rem_dev_role(Event)) { +#if defined(__SET_OUR_AS_MASTER__) + case BTIF_BCR_SLAVE: + case BTIF_BCR_PSLAVE: +#else + case BTIF_BCR_MASTER: + case BTIF_BCR_PMASTER: +#endif + TRACE(1, "CONNECT_IND/CNF try to role %p\n", + btif_me_get_callback_event_rem_dev(Event)); + opRemDev = btif_me_get_callback_event_rem_dev(Event); + switchrole_cnt = 0; + app_bt_Me_SetLinkPolicy(btif_me_get_callback_event_rem_dev(Event), + BTIF_BLP_MASTER_SLAVE_SWITCH | + BTIF_BLP_SNIFF_MODE); + app_bt_ME_SwitchRole(btif_me_get_callback_event_rem_dev(Event)); + break; +#if defined(__SET_OUR_AS_MASTER__) + case BTIF_BCR_MASTER: + case BTIF_BCR_PMASTER: +#else + case BTIF_BCR_SLAVE: + case BTIF_BCR_PSLAVE: +#endif + case BTIF_BCR_ANY: + case BTIF_BCR_UNKNOWN: + default: + TRACE(1, "CONNECT_IND disable role %p\n", + btif_me_get_callback_event_rem_dev(Event)); + app_bt_Me_SetLinkPolicy(btif_me_get_callback_event_rem_dev(Event), + BTIF_BLP_SNIFF_MODE); + break; + } + app_bt_ME_SetConnectionRole(BTIF_BCR_SLAVE); + } + break; + case BTIF_BTEVENT_LINK_DISCONNECT: + if (opRemDev == btif_me_get_callback_event_rem_dev(Event)) { + opRemDev = NULL; + switchrole_cnt = 0; + } + if (btif_me_get_activeCons() == 0) { + for (uint8_t i = 0; i < BT_DEVICE_NUM; i++) { + if (app_bt_device.a2dp_connected_stream[i]) + app_bt_A2DP_SetMasterRole(app_bt_device.a2dp_connected_stream[i], + FALSE); + app_bt_HF_SetMasterRole(app_bt_device.hf_channel[i], FALSE); + } + app_bt_ME_SetConnectionRole(BTIF_BCR_ANY); + } else if (btif_me_get_activeCons() == 1) { + app_bt_ME_SetConnectionRole(BTIF_BCR_SLAVE); + } + break; + case BTIF_BTEVENT_ROLE_CHANGE: + if (opRemDev == btif_me_get_callback_event_rem_dev(Event)) { + switch (btif_me_get_callback_event_role_change_new_role(Event)) { +#if defined(__SET_OUR_AS_MASTER__) + case BTIF_BCR_SLAVE: +#else + case BTIF_BCR_MASTER: +#endif + if (++switchrole_cnt <= APP_BT_SWITCHROLE_LIMIT) { + TRACE(1, "ROLE_CHANGE try to role again: %d", switchrole_cnt); + app_bt_Me_SetLinkPolicy(btif_me_get_callback_event_rem_dev(Event), + BTIF_BLP_MASTER_SLAVE_SWITCH | + BTIF_BLP_SNIFF_MODE); + app_bt_ME_SwitchRole(btif_me_get_callback_event_rem_dev(Event)); + } else { +#if defined(__SET_OUR_AS_MASTER__) + TRACE(2, "ROLE TO MASTER FAILED remDev %p cnt:%d\n", + btif_me_get_callback_event_rem_dev(Event), switchrole_cnt); +#else + TRACE(2, "ROLE TO SLAVE FAILED remDev %p cnt:%d\n", + btif_me_get_callback_event_rem_dev(Event), switchrole_cnt); +#endif + opRemDev = NULL; + switchrole_cnt = 0; + } + break; +#if defined(__SET_OUR_AS_MASTER__) + case BTIF_BCR_MASTER: + TRACE(2, "ROLE TO MASTER SUCCESS remDev %p cnt:%d\n", + btif_me_get_callback_event_rem_dev(Event), switchrole_cnt); +#else + case BTIF_BCR_SLAVE: + TRACE(2, "ROLE TO SLAVE SUCCESS remDev %p cnt:%d\n", + btif_me_get_callback_event_rem_dev(Event), switchrole_cnt); +#endif + opRemDev = NULL; + switchrole_cnt = 0; + // workaround for power reset opening reconnect sometime unsuccessfully + // in sniff mode, only after authentication completes, enable sniff + // mode. + opRemDev = btif_me_get_callback_event_rem_dev(Event); + if (btif_me_get_remote_device_auth_state(opRemDev) == + BTIF_BAS_AUTHENTICATED) { + app_bt_Me_SetLinkPolicy(opRemDev, BTIF_BLP_SNIFF_MODE); + } else { + app_bt_Me_SetLinkPolicy(opRemDev, BTIF_BLP_DISABLE_ALL); + } + break; + case BTIF_BCR_ANY: + break; + case BTIF_BCR_UNKNOWN: + break; + default: + break; + } + } + break; + } +#endif +} + +static int app_bt_sniff_manager_init(void) { + btif_sniff_info_t sniffInfo; + btif_remote_device_t *remDev = NULL; + + for (uint8_t i = 0; i < BT_DEVICE_NUM; i++) { + remDev = btif_me_enumerate_remote_devices(i); sniffInfo.maxInterval = BTIF_CMGR_SNIFF_MAX_INTERVAL; sniffInfo.minInterval = BTIF_CMGR_SNIFF_MIN_INTERVAL; sniffInfo.attempt = BTIF_CMGR_SNIFF_ATTEMPT; sniffInfo.timeout = BTIF_CMGR_SNIFF_TIMEOUT; app_bt_CMGR_SetSniffInfoToAllHandlerByRemDev(&sniffInfo, remDev); + app_bt_HF_EnableSniffMode(app_bt_device.hf_channel[i], FALSE); +#if defined(__HSP_ENABLE__) + app_bt_HS_EnableSniffMode(&app_bt_device.hs_channel[i], FALSE); +#endif + } + + return 0; +} + +void app_bt_sniff_config(btif_remote_device_t *remDev) { + btif_sniff_info_t sniffInfo; + sniffInfo.maxInterval = BTIF_CMGR_SNIFF_MAX_INTERVAL; + sniffInfo.minInterval = BTIF_CMGR_SNIFF_MIN_INTERVAL; + sniffInfo.attempt = BTIF_CMGR_SNIFF_ATTEMPT; + sniffInfo.timeout = BTIF_CMGR_SNIFF_TIMEOUT; + app_bt_CMGR_SetSniffInfoToAllHandlerByRemDev(&sniffInfo, remDev); #if !defined(IBRT) - if (btif_me_get_activeCons() > 1) - { - btif_remote_device_t* tmpRemDev = NULL; - btif_cmgr_handler_t *currbtif_cmgr_handler_t = NULL; - btif_cmgr_handler_t *otherbtif_cmgr_handler_t = NULL; - currbtif_cmgr_handler_t = btif_cmgr_get_conn_ind_handler(remDev); - for (uint8_t i=0; imaxInterval == btif_cmgr_get_cmgrhandler_sniff_info(currbtif_cmgr_handler_t)->maxInterval) - { - sniffInfo.maxInterval = btif_cmgr_get_cmgrhandler_sniff_info(otherbtif_cmgr_handler_t)->maxInterval -20; - sniffInfo.minInterval = btif_cmgr_get_cmgrhandler_sniff_info(otherbtif_cmgr_handler_t)->minInterval - 20; - sniffInfo.attempt = BTIF_CMGR_SNIFF_ATTEMPT; - sniffInfo.timeout = BTIF_CMGR_SNIFF_TIMEOUT; - app_bt_CMGR_SetSniffInfoToAllHandlerByRemDev(&sniffInfo, remDev); - } - } - break; - } - else - { - TRACE(3,"%s:enumerate i:%d remDev is NULL, param remDev:%p, this may cause error!", __func__, i, remDev); - } + if (btif_me_get_activeCons() > 1) { + btif_remote_device_t *tmpRemDev = NULL; + btif_cmgr_handler_t *currbtif_cmgr_handler_t = NULL; + btif_cmgr_handler_t *otherbtif_cmgr_handler_t = NULL; + currbtif_cmgr_handler_t = btif_cmgr_get_conn_ind_handler(remDev); + for (uint8_t i = 0; i < BT_DEVICE_NUM; i++) { + tmpRemDev = btif_me_enumerate_remote_devices(i); + if (remDev != tmpRemDev && tmpRemDev != NULL) { + otherbtif_cmgr_handler_t = btif_cmgr_get_acl_handler(tmpRemDev); + if (otherbtif_cmgr_handler_t && currbtif_cmgr_handler_t) { + if (btif_cmgr_get_cmgrhandler_sniff_info(otherbtif_cmgr_handler_t) + ->maxInterval == + btif_cmgr_get_cmgrhandler_sniff_info(currbtif_cmgr_handler_t) + ->maxInterval) { + sniffInfo.maxInterval = + btif_cmgr_get_cmgrhandler_sniff_info(otherbtif_cmgr_handler_t) + ->maxInterval - + 20; + sniffInfo.minInterval = + btif_cmgr_get_cmgrhandler_sniff_info(otherbtif_cmgr_handler_t) + ->minInterval - + 20; + sniffInfo.attempt = BTIF_CMGR_SNIFF_ATTEMPT; + sniffInfo.timeout = BTIF_CMGR_SNIFF_TIMEOUT; + app_bt_CMGR_SetSniffInfoToAllHandlerByRemDev(&sniffInfo, remDev); + } } + break; + } else { + TRACE(3, + "%s:enumerate i:%d remDev is NULL, param remDev:%p, this may " + "cause error!", + __func__, i, remDev); + } } + } #endif } -void app_bt_sniff_manager_process(const btif_event_t *Event) -{ - static btif_remote_device_t *opRemDev = NULL; - btif_remote_device_t *remDev = NULL; - btif_cmgr_handler_t *currbtif_cmgr_handler_t = NULL; - btif_cmgr_handler_t *otherbtif_cmgr_handler_t = NULL; +void app_bt_sniff_manager_process(const btif_event_t *Event) { + static btif_remote_device_t *opRemDev = NULL; + btif_remote_device_t *remDev = NULL; + btif_cmgr_handler_t *currbtif_cmgr_handler_t = NULL; + btif_cmgr_handler_t *otherbtif_cmgr_handler_t = NULL; - btif_sniff_info_t sniffInfo; + btif_sniff_info_t sniffInfo; - if (!besbt_cfg.sniff) - return; + if (!besbt_cfg.sniff) + return; - switch (btif_me_get_callback_event_type(Event)) - { - case BTIF_BTEVENT_LINK_CONNECT_IND: - break; - case BTIF_BTEVENT_LINK_CONNECT_CNF: - break; - case BTIF_BTEVENT_LINK_DISCONNECT: - if (opRemDev ==btif_me_get_callback_event_rem_dev( Event)) - { - opRemDev = NULL; + switch (btif_me_get_callback_event_type(Event)) { + case BTIF_BTEVENT_LINK_CONNECT_IND: + break; + case BTIF_BTEVENT_LINK_CONNECT_CNF: + break; + case BTIF_BTEVENT_LINK_DISCONNECT: + if (opRemDev == btif_me_get_callback_event_rem_dev(Event)) { + opRemDev = NULL; + } + sniffInfo.maxInterval = BTIF_CMGR_SNIFF_MAX_INTERVAL; + sniffInfo.minInterval = BTIF_CMGR_SNIFF_MIN_INTERVAL; + sniffInfo.attempt = BTIF_CMGR_SNIFF_ATTEMPT; + sniffInfo.timeout = BTIF_CMGR_SNIFF_TIMEOUT; + app_bt_CMGR_SetSniffInfoToAllHandlerByRemDev( + &sniffInfo, btif_me_get_callback_event_rem_dev(Event)); + break; + case BTIF_BTEVENT_MODE_CHANGE: + + /* + if(Event->p.modeChange.curMode == BLM_SNIFF_MODE){ + currbtif_cmgr_handler_t = + btif_cmgr_get_acl_handler(btif_me_get_callback_event_rem_dev( Event)); if + (Event->p.modeChange.interval > CMGR_SNIFF_MAX_INTERVAL){ if (!opRemDev){ + opRemDev = currbtif_cmgr_handler_t->remDev; + } + currbtif_cmgr_handler_t->sniffInfo.maxInterval = + CMGR_SNIFF_MAX_INTERVAL; currbtif_cmgr_handler_t->sniffInfo.minInterval = + CMGR_SNIFF_MIN_INTERVAL; currbtif_cmgr_handler_t->sniffInfo.attempt = + CMGR_SNIFF_ATTEMPT; currbtif_cmgr_handler_t->sniffInfo.timeout = + CMGR_SNIFF_TIMEOUT; + app_bt_CMGR_SetSniffInfoToAllHandlerByRemDev(&currbtif_cmgr_handler_t->sniffInfo,btif_me_get_callback_event_rem_dev( + Event)); app_bt_ME_StopSniff(currbtif_cmgr_handler_t->remDev); }else{ if + (currbtif_cmgr_handler_t){ currbtif_cmgr_handler_t->sniffInfo.maxInterval = + Event->p.modeChange.interval; currbtif_cmgr_handler_t->sniffInfo.minInterval + = Event->p.modeChange.interval; currbtif_cmgr_handler_t->sniffInfo.attempt = + CMGR_SNIFF_ATTEMPT; currbtif_cmgr_handler_t->sniffInfo.timeout = + CMGR_SNIFF_TIMEOUT; + app_bt_CMGR_SetSniffInfoToAllHandlerByRemDev(&currbtif_cmgr_handler_t->sniffInfo,btif_me_get_callback_event_rem_dev( + Event)); } - sniffInfo.maxInterval = BTIF_CMGR_SNIFF_MAX_INTERVAL; - sniffInfo.minInterval = BTIF_CMGR_SNIFF_MIN_INTERVAL; - sniffInfo.attempt = BTIF_CMGR_SNIFF_ATTEMPT; - sniffInfo.timeout = BTIF_CMGR_SNIFF_TIMEOUT; - app_bt_CMGR_SetSniffInfoToAllHandlerByRemDev(&sniffInfo,btif_me_get_callback_event_rem_dev( Event)); - break; - case BTIF_BTEVENT_MODE_CHANGE: - - /* - if(Event->p.modeChange.curMode == BLM_SNIFF_MODE){ - currbtif_cmgr_handler_t = btif_cmgr_get_acl_handler(btif_me_get_callback_event_rem_dev( Event)); - if (Event->p.modeChange.interval > CMGR_SNIFF_MAX_INTERVAL){ - if (!opRemDev){ - opRemDev = currbtif_cmgr_handler_t->remDev; - } - currbtif_cmgr_handler_t->sniffInfo.maxInterval = CMGR_SNIFF_MAX_INTERVAL; - currbtif_cmgr_handler_t->sniffInfo.minInterval = CMGR_SNIFF_MIN_INTERVAL; - currbtif_cmgr_handler_t->sniffInfo.attempt = CMGR_SNIFF_ATTEMPT; - currbtif_cmgr_handler_t->sniffInfo.timeout = CMGR_SNIFF_TIMEOUT; - app_bt_CMGR_SetSniffInfoToAllHandlerByRemDev(&currbtif_cmgr_handler_t->sniffInfo,btif_me_get_callback_event_rem_dev( Event)); - app_bt_ME_StopSniff(currbtif_cmgr_handler_t->remDev); - }else{ - if (currbtif_cmgr_handler_t){ - currbtif_cmgr_handler_t->sniffInfo.maxInterval = Event->p.modeChange.interval; - currbtif_cmgr_handler_t->sniffInfo.minInterval = Event->p.modeChange.interval; - currbtif_cmgr_handler_t->sniffInfo.attempt = CMGR_SNIFF_ATTEMPT; - currbtif_cmgr_handler_t->sniffInfo.timeout = CMGR_SNIFF_TIMEOUT; - app_bt_CMGR_SetSniffInfoToAllHandlerByRemDev(&currbtif_cmgr_handler_t->sniffInfo,btif_me_get_callback_event_rem_dev( Event)); - } - if (btif_me_get_activeCons() > 1){ - for (uint8_t i=0; isniffInfo.maxInterval == currbtif_cmgr_handler_t->sniffInfo.maxInterval){ - if (btif_me_get_current_mode(remDev) == BLM_ACTIVE_MODE){ - otherbtif_cmgr_handler_t->sniffInfo.maxInterval -= 20; - otherbtif_cmgr_handler_t->sniffInfo.minInterval -= 20; - otherbtif_cmgr_handler_t->sniffInfo.attempt = CMGR_SNIFF_ATTEMPT; - otherbtif_cmgr_handler_t->sniffInfo.timeout = CMGR_SNIFF_TIMEOUT; - app_bt_CMGR_SetSniffInfoToAllHandlerByRemDev(&otherbtif_cmgr_handler_t->sniffInfo, remDev); - TRACE(1,"reconfig sniff other RemDev:%x\n", remDev); - }else if (btif_me_get_current_mode(remDev) == BLM_SNIFF_MODE){ - need_reconfig = true; - } - } + if (btif_me_get_activeCons() > 1){ + for (uint8_t i=0; isniffInfo.maxInterval == + currbtif_cmgr_handler_t->sniffInfo.maxInterval){ if + (btif_me_get_current_mode(remDev) == BLM_ACTIVE_MODE){ + otherbtif_cmgr_handler_t->sniffInfo.maxInterval + -= 20; otherbtif_cmgr_handler_t->sniffInfo.minInterval -= 20; + otherbtif_cmgr_handler_t->sniffInfo.attempt + = CMGR_SNIFF_ATTEMPT; otherbtif_cmgr_handler_t->sniffInfo.timeout = + CMGR_SNIFF_TIMEOUT; + app_bt_CMGR_SetSniffInfoToAllHandlerByRemDev(&otherbtif_cmgr_handler_t->sniffInfo, + remDev); TRACE(1,"reconfig sniff other RemDev:%x\n", remDev); }else if + (btif_me_get_current_mode(remDev) == BLM_SNIFF_MODE){ need_reconfig = true; } - break; } } - } - if (need_reconfig){ - opRemDev = remDev; - if (currbtif_cmgr_handler_t){ - currbtif_cmgr_handler_t->sniffInfo.maxInterval -= 20; - currbtif_cmgr_handler_t->sniffInfo.minInterval -= 20; - currbtif_cmgr_handler_t->sniffInfo.attempt = CMGR_SNIFF_ATTEMPT; - currbtif_cmgr_handler_t->sniffInfo.timeout = CMGR_SNIFF_TIMEOUT; - app_bt_CMGR_SetSniffInfoToAllHandlerByRemDev(&currbtif_cmgr_handler_t->sniffInfo, currbtif_cmgr_handler_t->remDev); - } - app_bt_ME_StopSniff(currbtif_cmgr_handler_t->remDev); - TRACE(1,"reconfig sniff setup op opRemDev:%x\n", opRemDev); - } - } - } - if (Event->p.modeChange.curMode == BLM_ACTIVE_MODE){ - if (opRemDev ==btif_me_get_callback_event_rem_dev( Event)){ - TRACE(1,"reconfig sniff op opRemDev:%x\n", opRemDev); - opRemDev = NULL; - currbtif_cmgr_handler_t = btif_cmgr_get_acl_handler(btif_me_get_callback_event_rem_dev( Event)); - if (currbtif_cmgr_handler_t){ - app_bt_CMGR_SetSniffTimer(currbtif_cmgr_handler_t, NULL, CMGR_SNIFF_TIMER); - } - } - } - */ - break; - case BTIF_BTEVENT_ACL_DATA_ACTIVE: - btif_cmgr_handler_t *cmgrHandler; - /* Start the sniff timer */ - cmgrHandler = btif_cmgr_get_acl_handler(btif_me_get_callback_event_rem_dev( Event)); - if (cmgrHandler) - app_bt_CMGR_SetSniffTimer(cmgrHandler, NULL, BTIF_CMGR_SNIFF_TIMER); - break; - case BTIF_BTEVENT_SCO_CONNECT_IND: - case BTIF_BTEVENT_SCO_CONNECT_CNF: - TRACE(1,"BTEVENT_SCO_CONNECT_IND/CNF cur_remDev = %p",btif_me_get_callback_event_rem_dev( Event)); - currbtif_cmgr_handler_t = btif_cmgr_get_conn_ind_handler(btif_me_get_callback_event_rem_dev( Event)); - app_bt_Me_SetLinkPolicy( btif_me_get_callback_event_sco_connect_rem_dev(Event), BTIF_BLP_DISABLE_ALL); - if (btif_me_get_activeCons() > 1) - { - for (uint8_t i=0; isniffInfo.maxInterval -= 20; + currbtif_cmgr_handler_t->sniffInfo.minInterval -= 20; + currbtif_cmgr_handler_t->sniffInfo.attempt = + CMGR_SNIFF_ATTEMPT; currbtif_cmgr_handler_t->sniffInfo.timeout = + CMGR_SNIFF_TIMEOUT; + app_bt_CMGR_SetSniffInfoToAllHandlerByRemDev(&currbtif_cmgr_handler_t->sniffInfo, + currbtif_cmgr_handler_t->remDev); + } + app_bt_ME_StopSniff(currbtif_cmgr_handler_t->remDev); + TRACE(1,"reconfig sniff setup op opRemDev:%x\n", opRemDev); + } + } } -} - -APP_BT_GOLBAL_HANDLE_HOOK_HANDLER app_bt_global_handle_hook_handler[APP_BT_GOLBAL_HANDLE_HOOK_USER_QTY] = {0}; -void app_bt_global_handle_hook(const btif_event_t *Event) -{ - uint8_t i; - for (i=0; ip.modeChange.curMode == BLM_ACTIVE_MODE){ + if (opRemDev ==btif_me_get_callback_event_rem_dev( Event)){ + TRACE(1,"reconfig sniff op opRemDev:%x\n", opRemDev); + opRemDev = NULL; + currbtif_cmgr_handler_t = + btif_cmgr_get_acl_handler(btif_me_get_callback_event_rem_dev( Event)); if + (currbtif_cmgr_handler_t){ + app_bt_CMGR_SetSniffTimer(currbtif_cmgr_handler_t, NULL, + CMGR_SNIFF_TIMER); + } + } } + */ + break; + case BTIF_BTEVENT_ACL_DATA_ACTIVE: + btif_cmgr_handler_t *cmgrHandler; + /* Start the sniff timer */ + cmgrHandler = + btif_cmgr_get_acl_handler(btif_me_get_callback_event_rem_dev(Event)); + if (cmgrHandler) + app_bt_CMGR_SetSniffTimer(cmgrHandler, NULL, BTIF_CMGR_SNIFF_TIMER); + break; + case BTIF_BTEVENT_SCO_CONNECT_IND: + case BTIF_BTEVENT_SCO_CONNECT_CNF: + TRACE(1, "BTEVENT_SCO_CONNECT_IND/CNF cur_remDev = %p", + btif_me_get_callback_event_rem_dev(Event)); + currbtif_cmgr_handler_t = btif_cmgr_get_conn_ind_handler( + btif_me_get_callback_event_rem_dev(Event)); + app_bt_Me_SetLinkPolicy( + btif_me_get_callback_event_sco_connect_rem_dev(Event), + BTIF_BLP_DISABLE_ALL); + if (btif_me_get_activeCons() > 1) { + for (uint8_t i = 0; i < BT_DEVICE_NUM; i++) { + remDev = btif_me_enumerate_remote_devices(i); + TRACE(1, "other_remDev = %p", remDev); + if (btif_me_get_callback_event_rem_dev(Event) == remDev) { + continue; + } + + otherbtif_cmgr_handler_t = btif_cmgr_get_conn_ind_handler(remDev); + if (otherbtif_cmgr_handler_t) { + if (btif_cmgr_is_link_up(otherbtif_cmgr_handler_t)) { + if (btif_me_get_current_mode(remDev) == BTIF_BLM_ACTIVE_MODE) { + TRACE(0, "other dev disable sniff"); + app_bt_Me_SetLinkPolicy(remDev, BTIF_BLP_DISABLE_ALL); + } else if (btif_me_get_current_mode(remDev) == + BTIF_BLM_SNIFF_MODE) { + TRACE(0, " ohter dev exit & disable sniff"); + app_bt_ME_StopSniff(remDev); + app_bt_Me_SetLinkPolicy(remDev, BTIF_BLP_DISABLE_ALL); + } + } + } + +#if defined(HFP_NO_PRERMPT) + TRACE(2, "cur_audio = %d other_audio = %d", + btif_cmgr_is_audio_up(currbtif_cmgr_handler_t), + btif_cmgr_is_audio_up(otherbtif_cmgr_handler_t)); + if ((btif_cmgr_is_audio_up(otherbtif_cmgr_handler_t) == true) && + (btif_cmgr_is_audio_up(currbtif_cmgr_handler_t) == true) + /*(btapp_hfp_get_call_active()!=0)*/) { + btif_cmgr_remove_audio_link(currbtif_cmgr_handler_t); + app_bt_Me_switch_sco(btif_cmgr_get_sco_connect_sco_Hcihandler( + otherbtif_cmgr_handler_t)); + } +#endif + } + } + break; + case BTIF_BTEVENT_SCO_DISCONNECT: + app_bt_profile_reconnect_pending_process(); + if (a2dp_is_music_ongoing()) { + break; + } + if (btif_me_get_activeCons() == 1) { + app_bt_Me_SetLinkPolicy( + btif_me_get_callback_event_sco_connect_rem_dev(Event), + BTIF_BLP_SNIFF_MODE); + } else { + uint8_t i; + for (i = 0; i < BT_DEVICE_NUM; i++) { + remDev = btif_me_enumerate_remote_devices(i); + if (btif_me_get_callback_event_rem_dev(Event) == remDev) { + break; + } + } + /* + if(i==0) + remDev = btif_me_enumerate_remote_devices(1); + else if(i==1) + remDev = btif_me_enumerate_remote_devices(0); + else + ASSERT(0,"error other remotedevice!!!"); */ + otherbtif_cmgr_handler_t = btif_cmgr_get_conn_ind_handler(remDev); + currbtif_cmgr_handler_t = btif_cmgr_get_conn_ind_handler( + btif_me_get_callback_event_rem_dev(Event)); + + TRACE(4, "SCO_DISCONNECT:%d/%d %p/%p\n", + btif_cmgr_is_audio_up(currbtif_cmgr_handler_t), + btif_cmgr_is_audio_up(otherbtif_cmgr_handler_t), + btif_cmgr_get_cmgrhandler_remdev(currbtif_cmgr_handler_t), + btif_me_get_callback_event_rem_dev(Event)); + if (otherbtif_cmgr_handler_t) { + if (!btif_cmgr_is_audio_up(otherbtif_cmgr_handler_t)) { + TRACE(0, "enable sniff to all\n"); + app_bt_Me_SetLinkPolicy( + btif_me_get_callback_event_sco_connect_rem_dev(Event), + BTIF_BLP_SNIFF_MODE); + app_bt_Me_SetLinkPolicy( + btif_cmgr_get_cmgrhandler_remdev(otherbtif_cmgr_handler_t), + BTIF_BLP_SNIFF_MODE); + } + } else { + app_bt_Me_SetLinkPolicy( + btif_me_get_callback_event_sco_connect_rem_dev(Event), + BTIF_BLP_SNIFF_MODE); + } + } + break; + default: + break; + } } -int app_bt_global_handle_hook_set(enum APP_BT_GOLBAL_HANDLE_HOOK_USER_T user, APP_BT_GOLBAL_HANDLE_HOOK_HANDLER handler) -{ - app_bt_global_handle_hook_handler[user] = handler; - return 0; +APP_BT_GOLBAL_HANDLE_HOOK_HANDLER +app_bt_global_handle_hook_handler[APP_BT_GOLBAL_HANDLE_HOOK_USER_QTY] = {0}; +void app_bt_global_handle_hook(const btif_event_t *Event) { + uint8_t i; + for (i = 0; i < APP_BT_GOLBAL_HANDLE_HOOK_USER_QTY; i++) { + if (app_bt_global_handle_hook_handler[i]) + app_bt_global_handle_hook_handler[i](Event); + } } -APP_BT_GOLBAL_HANDLE_HOOK_HANDLER app_bt_global_handle_hook_get(enum APP_BT_GOLBAL_HANDLE_HOOK_USER_T user) -{ - return app_bt_global_handle_hook_handler[user]; +int app_bt_global_handle_hook_set(enum APP_BT_GOLBAL_HANDLE_HOOK_USER_T user, + APP_BT_GOLBAL_HANDLE_HOOK_HANDLER handler) { + app_bt_global_handle_hook_handler[user] = handler; + return 0; +} + +APP_BT_GOLBAL_HANDLE_HOOK_HANDLER +app_bt_global_handle_hook_get(enum APP_BT_GOLBAL_HANDLE_HOOK_USER_T user) { + return app_bt_global_handle_hook_handler[user]; } extern uint8_t once_event_case; extern bool IsMobileLinkLossing; -extern void startonce_event(int ms,uint8_t once_event_pram); +extern void startonce_event(int ms, uint8_t once_event_pram); extern void a2dp_update_music_link(void); -/////There is a device connected, so stop PAIR_TIMER and POWEROFF_TIMER of earphone. +/////There is a device connected, so stop PAIR_TIMER and POWEROFF_TIMER of +/// earphone. btif_handler app_bt_handler; -void app_bt_global_handle(const btif_event_t *Event) -{ - switch (btif_me_get_callback_event_type(Event)) - { - case BTIF_BTEVENT_HCI_INITIALIZED: - break; +void app_bt_global_handle(const btif_event_t *Event) { + switch (btif_me_get_callback_event_type(Event)) { + case BTIF_BTEVENT_HCI_INITIALIZED: + break; #if defined(IBRT) - case BTIF_BTEVENT_HCI_COMMAND_SENT: - return; + case BTIF_BTEVENT_HCI_COMMAND_SENT: + return; #else - case BTIF_BTEVENT_HCI_COMMAND_SENT: - case BTIF_BTEVENT_ACL_DATA_NOT_ACTIVE: - return; - case BTIF_BTEVENT_ACL_DATA_ACTIVE: - btif_cmgr_handler_t *cmgrHandler; - /* Start the sniff timer */ - cmgrHandler = btif_cmgr_get_acl_handler(btif_me_get_callback_event_rem_dev( Event)); - if (cmgrHandler) - app_bt_CMGR_SetSniffTimer(cmgrHandler, NULL, BTIF_CMGR_SNIFF_TIMER); - return; + case BTIF_BTEVENT_HCI_COMMAND_SENT: + case BTIF_BTEVENT_ACL_DATA_NOT_ACTIVE: + return; + case BTIF_BTEVENT_ACL_DATA_ACTIVE: + btif_cmgr_handler_t *cmgrHandler; + /* Start the sniff timer */ + cmgrHandler = + btif_cmgr_get_acl_handler(btif_me_get_callback_event_rem_dev(Event)); + if (cmgrHandler) + app_bt_CMGR_SetSniffTimer(cmgrHandler, NULL, BTIF_CMGR_SNIFF_TIMER); + return; #endif - case BTIF_BTEVENT_AUTHENTICATED: - TRACE(1,"[BTEVENT] HANDER AUTH error=%x", btif_me_get_callback_event_err_code(Event)); - //after authentication completes, re-enable sniff mode. - if(btif_me_get_callback_event_err_code(Event) == BTIF_BEC_NO_ERROR) - { - app_bt_Me_SetLinkPolicy(btif_me_get_callback_event_rem_dev( Event),BTIF_BLP_SNIFF_MODE); - } - else if (btif_me_get_callback_event_err_code(Event) == BTIF_BEC_AUTHENTICATE_FAILURE) - { - //auth failed should clear nv record link key - bt_bdaddr_t *bd_ddr = btif_me_get_callback_event_rem_dev_bd_addr(Event); - btif_device_record_t record; + case BTIF_BTEVENT_AUTHENTICATED: + TRACE(1, "[BTEVENT] HANDER AUTH error=%x", + btif_me_get_callback_event_err_code(Event)); + // after authentication completes, re-enable sniff mode. + if (btif_me_get_callback_event_err_code(Event) == BTIF_BEC_NO_ERROR) { + app_bt_Me_SetLinkPolicy(btif_me_get_callback_event_rem_dev(Event), + BTIF_BLP_SNIFF_MODE); + } else if (btif_me_get_callback_event_err_code(Event) == + BTIF_BEC_AUTHENTICATE_FAILURE) { + // auth failed should clear nv record link key + bt_bdaddr_t *bd_ddr = btif_me_get_callback_event_rem_dev_bd_addr(Event); + btif_device_record_t record; - if (ddbif_find_record(bd_ddr, &record) == BT_STS_SUCCESS) - { - ddbif_delete_record(&record.bdAddr); + if (ddbif_find_record(bd_ddr, &record) == BT_STS_SUCCESS) { + ddbif_delete_record(&record.bdAddr); #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (!p_ibrt_ctrl->mobile_pair_canceled) + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (!p_ibrt_ctrl->mobile_pair_canceled) #endif - { - memset(&record, 0, sizeof(record)); - record.bdAddr = *bd_ddr; - ddbif_add_record(&record); - } - nv_record_flash_flush(); - } - } - break; - } - // trace filter - switch (btif_me_get_callback_event_type(Event)) - { - case BTIF_BTEVENT_HCI_COMMAND_SENT: - case BTIF_BTEVENT_ACL_DATA_NOT_ACTIVE: - case BTIF_BTEVENT_ACL_DATA_ACTIVE: - break; - default: - TRACE(1,"[BTEVENT] evt = %d", btif_me_get_callback_event_type(Event)); - break; + { + memset(&record, 0, sizeof(record)); + record.bdAddr = *bd_ddr; + ddbif_add_record(&record); + } + nv_record_flash_flush(); + } } + break; + } + // trace filter + switch (btif_me_get_callback_event_type(Event)) { + case BTIF_BTEVENT_HCI_COMMAND_SENT: + case BTIF_BTEVENT_ACL_DATA_NOT_ACTIVE: + case BTIF_BTEVENT_ACL_DATA_ACTIVE: + break; + default: + TRACE(1, "[BTEVENT] evt = %d", btif_me_get_callback_event_type(Event)); + break; + } - switch (btif_me_get_callback_event_type(Event)) - { - case BTIF_BTEVENT_LINK_CONNECT_IND: - hfp_reconnecting_timer_stop_callback(Event); - case BTIF_BTEVENT_LINK_CONNECT_CNF: + switch (btif_me_get_callback_event_type(Event)) { + case BTIF_BTEVENT_LINK_CONNECT_IND: + hfp_reconnecting_timer_stop_callback(Event); + case BTIF_BTEVENT_LINK_CONNECT_CNF: #ifdef __BT_ONE_BRING_TWO__ - if(bt_drv_reg_op_get_reconnecting_flag()) - { - bt_drv_reg_op_clear_reconnecting_flag(); - if(a2dp_is_music_ongoing()) - a2dp_update_music_link(); - } + if (bt_drv_reg_op_get_reconnecting_flag()) { + bt_drv_reg_op_clear_reconnecting_flag(); + if (a2dp_is_music_ongoing()) + a2dp_update_music_link(); + } #endif - if (BTIF_BEC_NO_ERROR == btif_me_get_callback_event_err_code(Event)) - { - connectedMobile = btif_me_get_callback_event_rem_dev( Event); - uint8_t connectedDevId = app_bt_get_devId_from_RemDev(connectedMobile); - app_bt_set_connecting_profiles_state(connectedDevId); - TRACE(1,"MEC(pendCons) is %d", btif_me_get_pendCons()); + if (BTIF_BEC_NO_ERROR == btif_me_get_callback_event_err_code(Event)) { + connectedMobile = btif_me_get_callback_event_rem_dev(Event); + uint8_t connectedDevId = app_bt_get_devId_from_RemDev(connectedMobile); + app_bt_set_connecting_profiles_state(connectedDevId); + TRACE(1, "MEC(pendCons) is %d", btif_me_get_pendCons()); - app_bt_stay_active_rem_dev(btif_me_get_callback_event_rem_dev( Event)); + app_bt_stay_active_rem_dev(btif_me_get_callback_event_rem_dev(Event)); #ifdef __BT_ONE_BRING_TWO__ - btif_remote_device_t *remote_dev = btif_me_get_callback_event_rem_dev(Event); - uint16_t conn_handle = btif_me_get_remote_device_hci_handle(remote_dev); - btif_me_qos_set_up(conn_handle); + btif_remote_device_t *remote_dev = + btif_me_get_callback_event_rem_dev(Event); + uint16_t conn_handle = btif_me_get_remote_device_hci_handle(remote_dev); + btif_me_qos_set_up(conn_handle); #endif #if (defined(__AI_VOICE__) || defined(BISTO_ENABLED)) - app_ai_if_mobile_connect_handle(btif_me_get_callback_event_rem_dev_bd_addr(Event)); + app_ai_if_mobile_connect_handle( + btif_me_get_callback_event_rem_dev_bd_addr(Event)); #endif - } + } - TRACE(4,"[BTEVENT] CONNECT_IND/CNF evt:%d errCode:0x%0x newRole:%d activeCons:%d",btif_me_get_callback_event_type(Event), - btif_me_get_callback_event_err_code(Event),btif_me_get_callback_event_rem_dev_role (Event), btif_me_get_activeCons()); - DUMP8("%02x ", btif_me_get_callback_event_rem_dev_bd_addr(Event), BTIF_BD_ADDR_SIZE); + TRACE(4, + "[BTEVENT] CONNECT_IND/CNF evt:%d errCode:0x%0x newRole:%d " + "activeCons:%d", + btif_me_get_callback_event_type(Event), + btif_me_get_callback_event_err_code(Event), + btif_me_get_callback_event_rem_dev_role(Event), + btif_me_get_activeCons()); + DUMP8("%02x ", btif_me_get_callback_event_rem_dev_bd_addr(Event), + BTIF_BD_ADDR_SIZE); -#if defined(__BTIF_EARPHONE__) && defined(__BTIF_AUTOPOWEROFF__) && !defined(FPGA) - if (btif_me_get_activeCons() == 0) - { - app_start_10_second_timer(APP_POWEROFF_TIMER_ID); - } - else - { - app_stop_10_second_timer(APP_POWEROFF_TIMER_ID); - } +#if defined(__BTIF_EARPHONE__) && defined(__BTIF_AUTOPOWEROFF__) && \ + !defined(FPGA) + if (btif_me_get_activeCons() == 0) { + app_start_10_second_timer(APP_POWEROFF_TIMER_ID); + } else { + app_stop_10_second_timer(APP_POWEROFF_TIMER_ID); + } #endif -#if defined(__BT_ONE_BRING_TWO__)||defined(IBRT) - if (btif_me_get_activeCons() > 2) - { - TRACE(1,"CONNECT_IND/CNF activeCons:%d so disconnect it", btif_me_get_activeCons()); - app_bt_MeDisconnectLink(btif_me_get_callback_event_rem_dev( Event)); - } +#if defined(__BT_ONE_BRING_TWO__) || defined(IBRT) + if (btif_me_get_activeCons() > 2) { + TRACE(1, "CONNECT_IND/CNF activeCons:%d so disconnect it", + btif_me_get_activeCons()); + app_bt_MeDisconnectLink(btif_me_get_callback_event_rem_dev(Event)); + } #else - if (btif_me_get_activeCons() > 1) - { - TRACE(1,"CONNECT_IND/CNF activeCons:%d so disconnect it", btif_me_get_activeCons()); - app_bt_MeDisconnectLink(btif_me_get_callback_event_rem_dev( Event)); - } + if (btif_me_get_activeCons() > 1) { + TRACE(1, "CONNECT_IND/CNF activeCons:%d so disconnect it", + btif_me_get_activeCons()); + app_bt_MeDisconnectLink(btif_me_get_callback_event_rem_dev(Event)); + } #endif - break; - case BTIF_BTEVENT_LINK_DISCONNECT: - { - connectedMobile = btif_me_get_callback_event_rem_dev( Event); - uint8_t disconnectedDevId = app_bt_get_devId_from_RemDev(connectedMobile); - connectedMobile = NULL; - app_bt_clear_connecting_profiles_state(disconnectedDevId); + break; + case BTIF_BTEVENT_LINK_DISCONNECT: { + connectedMobile = btif_me_get_callback_event_rem_dev(Event); + uint8_t disconnectedDevId = app_bt_get_devId_from_RemDev(connectedMobile); + connectedMobile = NULL; + app_bt_clear_connecting_profiles_state(disconnectedDevId); - btif_remote_device_t *remote_dev = btif_me_get_callback_event_disconnect_rem_dev(Event); - if(remote_dev) - { - uint16_t conhdl = btif_me_get_remote_device_hci_handle(remote_dev); - bt_drv_reg_op_acl_tx_silence_clear(conhdl); - bt_drv_hwspi_select(conhdl-0x80, 0); - } + btif_remote_device_t *remote_dev = + btif_me_get_callback_event_disconnect_rem_dev(Event); + if (remote_dev) { + uint16_t conhdl = btif_me_get_remote_device_hci_handle(remote_dev); + bt_drv_reg_op_acl_tx_silence_clear(conhdl); + bt_drv_hwspi_select(conhdl - 0x80, 0); + } - TRACE(5,"[BTEVENT] DISCONNECT evt = %d encryptState:%d reason:0x%02x/0x%02x activeCons:%d", - btif_me_get_callback_event_type(Event), - btif_me_get_remote_sevice_encrypt_state(btif_me_get_callback_event_rem_dev( Event)), - btif_me_get_remote_device_disc_reason_saved(btif_me_get_callback_event_rem_dev( Event)), - btif_me_get_remote_device_disc_reason(btif_me_get_callback_event_rem_dev( Event)), - btif_me_get_activeCons()); - DUMP8("%02x ", btif_me_get_callback_event_rem_dev_bd_addr(Event), BTIF_BD_ADDR_SIZE); + TRACE(5, + "[BTEVENT] DISCONNECT evt = %d encryptState:%d reason:0x%02x/0x%02x " + "activeCons:%d", + btif_me_get_callback_event_type(Event), + btif_me_get_remote_sevice_encrypt_state( + btif_me_get_callback_event_rem_dev(Event)), + btif_me_get_remote_device_disc_reason_saved( + btif_me_get_callback_event_rem_dev(Event)), + btif_me_get_remote_device_disc_reason( + btif_me_get_callback_event_rem_dev(Event)), + btif_me_get_activeCons()); + DUMP8("%02x ", btif_me_get_callback_event_rem_dev_bd_addr(Event), + BTIF_BD_ADDR_SIZE); #ifdef CHIP_BEST2000 - bt_drv_patch_force_disconnect_ack(); + bt_drv_patch_force_disconnect_ack(); #endif - //disconnect from reconnect connection, and the HF don't connect successful once - //(whitch will release the saved_reconnect_mode ). so we are reconnect fail with remote link key loss. - // goto pairing. - //reason 07 maybe from the controller's error . - //05 auth error - //16 io cap reject. + // disconnect from reconnect connection, and the HF don't connect successful + // once (whitch will release the saved_reconnect_mode ). so we are reconnect + // fail with remote link key loss. + // goto pairing. + // reason 07 maybe from the controller's error . + // 05 auth error + // 16 io cap reject. -#if defined(__BTIF_EARPHONE__) && defined(__BTIF_AUTOPOWEROFF__) && !defined(FPGA) - if (btif_me_get_activeCons() == 0) - { - app_start_10_second_timer(APP_POWEROFF_TIMER_ID); - } +#if defined(__BTIF_EARPHONE__) && defined(__BTIF_AUTOPOWEROFF__) && \ + !defined(FPGA) + if (btif_me_get_activeCons() == 0) { + app_start_10_second_timer(APP_POWEROFF_TIMER_ID); + } #endif #if defined(BISTO_ENABLED) - gsound_custom_bt_link_disconnected_handler(btif_me_get_callback_event_rem_dev_bd_addr(Event)->address); + gsound_custom_bt_link_disconnected_handler( + btif_me_get_callback_event_rem_dev_bd_addr(Event)->address); #endif #if defined(__AI_VOICE__) - app_ai_mobile_disconnect_handle(btif_me_get_callback_event_rem_dev_bd_addr(Event)); + app_ai_mobile_disconnect_handle( + btif_me_get_callback_event_rem_dev_bd_addr(Event)); #endif -#ifdef __IAG_BLE_INCLUDE__ - // start BLE adv - app_ble_force_switch_adv(BLE_SWITCH_USER_BT_CONNECT, true); +#ifdef __IAG_BLE_INCLUDE__ + // start BLE adv + app_ble_force_switch_adv(BLE_SWITCH_USER_BT_CONNECT, true); #endif #ifdef BTIF_DIP_DEVICE - btif_dip_clear(remote_dev); + btif_dip_clear(remote_dev); #endif - app_bt_active_mode_reset(disconnectedDevId); + app_bt_active_mode_reset(disconnectedDevId); #ifdef GFPS_ENABLED - app_gfps_handling_on_mobile_link_disconnection( - btif_me_get_callback_event_rem_dev(Event)); + app_gfps_handling_on_mobile_link_disconnection( + btif_me_get_callback_event_rem_dev(Event)); #endif -#if !defined(IBRT) && defined( BT_XTAL_SYNC_NO_RESET) - bt_term_xtal_sync_default(); +#if !defined(IBRT) && defined(BT_XTAL_SYNC_NO_RESET) + bt_term_xtal_sync_default(); #endif - break; - } - case BTIF_BTEVENT_ROLE_CHANGE: - TRACE(3,"[BTEVENT] ROLE_CHANGE eType:0x%x errCode:0x%x newRole:%d activeCons:%d", btif_me_get_callback_event_type(Event), - btif_me_get_callback_event_err_code(Event), btif_me_get_callback_event_role_change_new_role(Event), btif_me_get_activeCons()); - break; - case BTIF_BTEVENT_MODE_CHANGE: - TRACE(4,"[BTEVENT] MODE_CHANGE evt:%d errCode:0x%0x curMode=0x%0x, interval=%d ",btif_me_get_callback_event_type(Event), - btif_me_get_callback_event_err_code(Event), btif_me_get_callback_event_mode_change_curMode(Event), - btif_me_get_callback_event_mode_change_interval(Event)); - DUMP8("%02x ", btif_me_get_callback_event_rem_dev_bd_addr(Event), BTIF_BD_ADDR_SIZE); - break; - case BTIF_BTEVENT_ACCESSIBLE_CHANGE: - TRACE(3,"[BTEVENT] ACCESSIBLE_CHANGE evt:%d errCode:0x%0x aMode=0x%0x", btif_me_get_callback_event_type(Event), - btif_me_get_callback_event_err_code(Event), - btif_me_get_callback_event_a_mode(Event)); + break; + } + case BTIF_BTEVENT_ROLE_CHANGE: + TRACE(3, + "[BTEVENT] ROLE_CHANGE eType:0x%x errCode:0x%x newRole:%d " + "activeCons:%d", + btif_me_get_callback_event_type(Event), + btif_me_get_callback_event_err_code(Event), + btif_me_get_callback_event_role_change_new_role(Event), + btif_me_get_activeCons()); + break; + case BTIF_BTEVENT_MODE_CHANGE: + TRACE(4, + "[BTEVENT] MODE_CHANGE evt:%d errCode:0x%0x curMode=0x%0x, " + "interval=%d ", + btif_me_get_callback_event_type(Event), + btif_me_get_callback_event_err_code(Event), + btif_me_get_callback_event_mode_change_curMode(Event), + btif_me_get_callback_event_mode_change_interval(Event)); + DUMP8("%02x ", btif_me_get_callback_event_rem_dev_bd_addr(Event), + BTIF_BD_ADDR_SIZE); + break; + case BTIF_BTEVENT_ACCESSIBLE_CHANGE: + TRACE(3, "[BTEVENT] ACCESSIBLE_CHANGE evt:%d errCode:0x%0x aMode=0x%0x", + btif_me_get_callback_event_type(Event), + btif_me_get_callback_event_err_code(Event), + btif_me_get_callback_event_a_mode(Event)); #if !defined(IBRT) - if (app_is_access_mode_set_pending()) - { - app_set_pending_access_mode(); - } - else - { - if (BTIF_BEC_NO_ERROR != btif_me_get_callback_event_err_code(Event)) - { - app_retry_setting_access_mode(); - } - } -#endif - break; - case BTIF_BTEVENT_LINK_POLICY_CHANGED: - { - BT_SET_LINKPOLICY_REQ_T* pReq = app_bt_pop_pending_set_linkpolicy(); - if (NULL != pReq) - { - app_bt_Me_SetLinkPolicy(pReq->remDev, pReq->policy); - } - break; - } - case BTIF_BTEVENT_DEFAULT_LINK_POLICY_CHANGED: - { - TRACE(0,"[BTEVENT] DEFAULT_LINK_POLICY_CHANGED-->BT_STACK_INITIALIZED"); - app_notify_stack_ready(STACK_READY_BT); - break; - } - case BTIF_BTEVENT_NAME_RESULT: - { - uint8_t* ptrName; - uint8_t nameLen; - nameLen = btif_me_get_callback_event_remote_dev_name(Event, &ptrName); - TRACE(1,"[BTEVENT] NAME_RESULT name len %d", nameLen); - if (nameLen > 0) - { - TRACE(1,"remote dev name: %s", ptrName); - } - //return; - } - default: - break; + if (app_is_access_mode_set_pending()) { + app_set_pending_access_mode(); + } else { + if (BTIF_BEC_NO_ERROR != btif_me_get_callback_event_err_code(Event)) { + app_retry_setting_access_mode(); + } } +#endif + break; + case BTIF_BTEVENT_LINK_POLICY_CHANGED: { + BT_SET_LINKPOLICY_REQ_T *pReq = app_bt_pop_pending_set_linkpolicy(); + if (NULL != pReq) { + app_bt_Me_SetLinkPolicy(pReq->remDev, pReq->policy); + } + break; + } + case BTIF_BTEVENT_DEFAULT_LINK_POLICY_CHANGED: { + TRACE(0, "[BTEVENT] DEFAULT_LINK_POLICY_CHANGED-->BT_STACK_INITIALIZED"); + app_notify_stack_ready(STACK_READY_BT); + break; + } + case BTIF_BTEVENT_NAME_RESULT: { + uint8_t *ptrName; + uint8_t nameLen; + nameLen = btif_me_get_callback_event_remote_dev_name(Event, &ptrName); + TRACE(1, "[BTEVENT] NAME_RESULT name len %d", nameLen); + if (nameLen > 0) { + TRACE(1, "remote dev name: %s", ptrName); + } + // return; + } + default: + break; + } #ifdef MULTIPOINT_DUAL_SLAVE - app_bt_role_manager_process_dual_slave(Event); + app_bt_role_manager_process_dual_slave(Event); #else - app_bt_role_manager_process(Event); + app_bt_role_manager_process(Event); #endif - app_bt_accessible_manager_process(Event); + app_bt_accessible_manager_process(Event); #if !defined(IBRT) - app_bt_sniff_manager_process(Event); + app_bt_sniff_manager_process(Event); #endif - app_bt_global_handle_hook(Event); + app_bt_global_handle_hook(Event); #if defined(IBRT) - app_tws_ibrt_global_callback(Event); + app_tws_ibrt_global_callback(Event); #endif } #include "app_bt_media_manager.h" osTimerId bt_sco_recov_timer = NULL; static void bt_sco_recov_timer_handler(void const *param); -osTimerDef (BT_SCO_RECOV_TIMER, (void (*)(void const *))bt_sco_recov_timer_handler); // define timers +osTimerDef(BT_SCO_RECOV_TIMER, + (void (*)(void const *))bt_sco_recov_timer_handler); // define timers void hfp_reconnect_sco(uint8_t flag); -static void bt_sco_recov_timer_handler(void const *param) -{ - TRACE(1,"%s",__func__); - hfp_reconnect_sco(0); +static void bt_sco_recov_timer_handler(void const *param) { + TRACE(1, "%s", __func__); + hfp_reconnect_sco(0); } -static void bt_sco_recov_timer_start() -{ - osTimerStop(bt_sco_recov_timer); - osTimerStart(bt_sco_recov_timer, 2500); +static void bt_sco_recov_timer_start() { + osTimerStop(bt_sco_recov_timer); + osTimerStart(bt_sco_recov_timer, 2500); } - -enum -{ - SCO_DISCONNECT_RECONN_START, - SCO_DISCONNECT_RECONN_RUN, - SCO_DISCONNECT_RECONN_NONE, +enum { + SCO_DISCONNECT_RECONN_START, + SCO_DISCONNECT_RECONN_RUN, + SCO_DISCONNECT_RECONN_NONE, }; -static uint8_t sco_reconnect_status = SCO_DISCONNECT_RECONN_NONE; +static uint8_t sco_reconnect_status = SCO_DISCONNECT_RECONN_NONE; -void hfp_reconnect_sco(uint8_t set) -{ - TRACE(3,"%s cur_chl_id=%d reconnect_status =%d",__func__,app_bt_device.curr_hf_channel_id, - sco_reconnect_status); - if(set == 1) - { - sco_reconnect_status = SCO_DISCONNECT_RECONN_START; - } - if(sco_reconnect_status == SCO_DISCONNECT_RECONN_START) - { - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP,BT_STREAM_VOICE, app_bt_device.curr_hf_channel_id,MAX_RECORD_NUM); - app_bt_HF_DisconnectAudioLink(app_bt_device.hf_channel[app_bt_device.curr_hf_channel_id]); - sco_reconnect_status = SCO_DISCONNECT_RECONN_RUN; - bt_sco_recov_timer_start(); - } - else if(sco_reconnect_status == SCO_DISCONNECT_RECONN_RUN) - { - app_bt_HF_CreateAudioLink(app_bt_device.hf_channel[app_bt_device.curr_hf_channel_id]); - sco_reconnect_status = SCO_DISCONNECT_RECONN_NONE; - } +void hfp_reconnect_sco(uint8_t set) { + TRACE(3, "%s cur_chl_id=%d reconnect_status =%d", __func__, + app_bt_device.curr_hf_channel_id, sco_reconnect_status); + if (set == 1) { + sco_reconnect_status = SCO_DISCONNECT_RECONN_START; + } + if (sco_reconnect_status == SCO_DISCONNECT_RECONN_START) { + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_VOICE, + app_bt_device.curr_hf_channel_id, + MAX_RECORD_NUM); + app_bt_HF_DisconnectAudioLink( + app_bt_device.hf_channel[app_bt_device.curr_hf_channel_id]); + sco_reconnect_status = SCO_DISCONNECT_RECONN_RUN; + bt_sco_recov_timer_start(); + } else if (sco_reconnect_status == SCO_DISCONNECT_RECONN_RUN) { + app_bt_HF_CreateAudioLink( + app_bt_device.hf_channel[app_bt_device.curr_hf_channel_id]); + sco_reconnect_status = SCO_DISCONNECT_RECONN_NONE; + } } - -void app_bt_global_handle_init(void) -{ - btif_event_mask_t mask = BTIF_BEM_NO_EVENTS; - btif_me_init_handler(&app_bt_handler); - app_bt_handler.callback = app_bt_global_handle; - btif_me_register_global_handler(&app_bt_handler); +void app_bt_global_handle_init(void) { + btif_event_mask_t mask = BTIF_BEM_NO_EVENTS; + btif_me_init_handler(&app_bt_handler); + app_bt_handler.callback = app_bt_global_handle; + btif_me_register_global_handler(&app_bt_handler); #if defined(IBRT) - btif_me_register_accept_handler(&app_bt_handler); + btif_me_register_accept_handler(&app_bt_handler); #endif #ifdef IBRT_SEARCH_UI - app_bt_global_handle_hook_set(APP_BT_GOLBAL_HANDLE_HOOK_USER_0,app_bt_manager_ibrt_role_process); + app_bt_global_handle_hook_set(APP_BT_GOLBAL_HANDLE_HOOK_USER_0, + app_bt_manager_ibrt_role_process); #endif - mask |= BTIF_BEM_ROLE_CHANGE | BTIF_BEM_SCO_CONNECT_CNF | BTIF_BEM_SCO_DISCONNECT | BTIF_BEM_SCO_CONNECT_IND; - mask |= BTIF_BEM_AUTHENTICATED; - mask |= BTIF_BEM_LINK_CONNECT_IND; - mask |= BTIF_BEM_LINK_DISCONNECT; - mask |= BTIF_BEM_LINK_CONNECT_CNF; - mask |= BTIF_BEM_ACCESSIBLE_CHANGE; - mask |= BTIF_BEM_ENCRYPTION_CHANGE; - mask |= BTIF_BEM_SIMPLE_PAIRING_COMPLETE; -#if (defined(__BT_ONE_BRING_TWO__)||defined(IBRT)) - mask |= BTIF_BEM_MODE_CHANGE; + mask |= BTIF_BEM_ROLE_CHANGE | BTIF_BEM_SCO_CONNECT_CNF | + BTIF_BEM_SCO_DISCONNECT | BTIF_BEM_SCO_CONNECT_IND; + mask |= BTIF_BEM_AUTHENTICATED; + mask |= BTIF_BEM_LINK_CONNECT_IND; + mask |= BTIF_BEM_LINK_DISCONNECT; + mask |= BTIF_BEM_LINK_CONNECT_CNF; + mask |= BTIF_BEM_ACCESSIBLE_CHANGE; + mask |= BTIF_BEM_ENCRYPTION_CHANGE; + mask |= BTIF_BEM_SIMPLE_PAIRING_COMPLETE; +#if (defined(__BT_ONE_BRING_TWO__) || defined(IBRT)) + mask |= BTIF_BEM_MODE_CHANGE; #endif - mask |= BTIF_BEM_LINK_POLICY_CHANGED; + mask |= BTIF_BEM_LINK_POLICY_CHANGED; - app_bt_ME_SetConnectionRole(BTIF_BCR_ANY); - for (uint8_t i=0; ia2dp_stream, FALSE); + app_bt_ME_SetConnectionRole(BTIF_BCR_ANY); + for (uint8_t i = 0; i < BT_DEVICE_NUM; i++) { + app_bt_A2DP_SetMasterRole(app_bt_device.a2dp_stream[i]->a2dp_stream, FALSE); #if defined(A2DP_LHDC_ON) - app_bt_A2DP_SetMasterRole(app_bt_device.a2dp_lhdc_stream[i]->a2dp_stream, FALSE); + app_bt_A2DP_SetMasterRole(app_bt_device.a2dp_lhdc_stream[i]->a2dp_stream, + FALSE); #endif #if defined(A2DP_AAC_ON) - app_bt_A2DP_SetMasterRole(app_bt_device.a2dp_aac_stream[i]->a2dp_stream, FALSE); + app_bt_A2DP_SetMasterRole(app_bt_device.a2dp_aac_stream[i]->a2dp_stream, + FALSE); #endif #if defined(A2DP_SCALABLE_ON) - app_bt_A2DP_SetMasterRole(app_bt_device.a2dp_scalable_stream[i]->a2dp_stream, FALSE); + app_bt_A2DP_SetMasterRole( + app_bt_device.a2dp_scalable_stream[i]->a2dp_stream, FALSE); #endif #if defined(A2DP_LDAC_ON) - app_bt_A2DP_SetMasterRole(app_bt_device.a2dp_ldac_stream[i]->a2dp_stream, FALSE); + app_bt_A2DP_SetMasterRole(app_bt_device.a2dp_ldac_stream[i]->a2dp_stream, + FALSE); #endif - app_bt_HF_SetMasterRole(app_bt_device.hf_channel[i], FALSE); -#if defined (__HSP_ENABLE__) - HS_SetMasterRole(&app_bt_device.hs_channel[i], FALSE); + app_bt_HF_SetMasterRole(app_bt_device.hf_channel[i], FALSE); +#if defined(__HSP_ENABLE__) + HS_SetMasterRole(&app_bt_device.hs_channel[i], FALSE); #endif - } - btif_me_set_event_mask(&app_bt_handler, mask); - app_bt_sniff_manager_init(); - app_bt_accessmode_timer = osTimerCreate (osTimer(APP_BT_ACCESSMODE_TIMER), osTimerOnce, &app_bt_accessmode_timer_argument); - bt_sco_recov_timer = osTimerCreate (osTimer(BT_SCO_RECOV_TIMER), osTimerOnce, NULL); + } + btif_me_set_event_mask(&app_bt_handler, mask); + app_bt_sniff_manager_init(); + app_bt_accessmode_timer = + osTimerCreate(osTimer(APP_BT_ACCESSMODE_TIMER), osTimerOnce, + &app_bt_accessmode_timer_argument); + bt_sco_recov_timer = + osTimerCreate(osTimer(BT_SCO_RECOV_TIMER), osTimerOnce, NULL); } -void app_bt_send_request(uint32_t message_id, uint32_t param0, uint32_t param1, uint32_t ptr) -{ - APP_MESSAGE_BLOCK msg; +void app_bt_send_request(uint32_t message_id, uint32_t param0, uint32_t param1, + uint32_t ptr) { + APP_MESSAGE_BLOCK msg; - msg.mod_id = APP_MODUAL_BT; - msg.msg_body.message_id = message_id; - msg.msg_body.message_Param0 = param0; - msg.msg_body.message_Param1 = param1; - msg.msg_body.message_ptr = ptr; - app_mailbox_put(&msg); + msg.mod_id = APP_MODUAL_BT; + msg.msg_body.message_id = message_id; + msg.msg_body.message_Param0 = param0; + msg.msg_body.message_Param1 = param1; + msg.msg_body.message_ptr = ptr; + app_mailbox_put(&msg); } extern void app_start_10_second_timer(uint8_t timer_id); -static int app_bt_handle_process(APP_MESSAGE_BODY *msg_body) -{ - btif_accessible_mode_t old_access_mode; +static int app_bt_handle_process(APP_MESSAGE_BODY *msg_body) { + btif_accessible_mode_t old_access_mode; - switch (msg_body->message_id) - { - case APP_BT_REQ_ACCESS_MODE_SET: - old_access_mode = g_bt_access_mode; - app_bt_accessmode_set(msg_body->message_Param0); - if (msg_body->message_Param0 == BTIF_BAM_GENERAL_ACCESSIBLE && - old_access_mode != BTIF_BAM_GENERAL_ACCESSIBLE) - { + switch (msg_body->message_id) { + case APP_BT_REQ_ACCESS_MODE_SET: + old_access_mode = g_bt_access_mode; + app_bt_accessmode_set(msg_body->message_Param0); + if (msg_body->message_Param0 == BTIF_BAM_GENERAL_ACCESSIBLE && + old_access_mode != BTIF_BAM_GENERAL_ACCESSIBLE) { #ifndef FPGA - //app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); + // app_status_indication_set(APP_STATUS_INDICATION_BOTHSCAN); #ifdef MEDIA_PLAYER_SUPPORT - app_voice_report(APP_STATUS_INDICATION_BOTHSCAN, 0); + app_voice_report(APP_STATUS_INDICATION_BOTHSCAN, 0); #endif - app_start_10_second_timer(APP_PAIR_TIMER_ID); + app_start_10_second_timer(APP_PAIR_TIMER_ID); #endif - } - else - { + } else { #ifndef FPGA - //app_status_indication_set(APP_STATUS_INDICATION_PAGESCAN); + // app_status_indication_set(APP_STATUS_INDICATION_PAGESCAN); #endif - } - break; - default: - break; } + break; + default: + break; + } - return 0; + return 0; } -void *app_bt_profile_active_store_ptr_get(uint8_t *bdAddr) -{ - static btdevice_profile device_profile = {true, false, true,0}; - btdevice_profile *ptr; +void *app_bt_profile_active_store_ptr_get(uint8_t *bdAddr) { + static btdevice_profile device_profile = {true, false, true, 0}; + btdevice_profile *ptr; #ifndef FPGA - nvrec_btdevicerecord *record = NULL; - if (!nv_record_btdevicerecord_find((bt_bdaddr_t *)bdAddr,&record)) - { - uint32_t lock = nv_record_pre_write_operation(); - ptr = &(record->device_plf); - DUMP8("0x%02x ", bdAddr, BTIF_BD_ADDR_SIZE); - TRACE(5,"%s hfp_act:%d hsp_act:%d a2dp_act:0x%x codec_type=%x", __func__, ptr->hfp_act, ptr->hsp_act, ptr->a2dp_act,ptr->a2dp_codectype); - /* always need connect a2dp and hfp */ - ptr->hfp_act = true; - ptr->a2dp_act = true; - nv_record_post_write_operation(lock); - } - else + nvrec_btdevicerecord *record = NULL; + if (!nv_record_btdevicerecord_find((bt_bdaddr_t *)bdAddr, &record)) { + uint32_t lock = nv_record_pre_write_operation(); + ptr = &(record->device_plf); + DUMP8("0x%02x ", bdAddr, BTIF_BD_ADDR_SIZE); + TRACE(5, "%s hfp_act:%d hsp_act:%d a2dp_act:0x%x codec_type=%x", __func__, + ptr->hfp_act, ptr->hsp_act, ptr->a2dp_act, ptr->a2dp_codectype); + /* always need connect a2dp and hfp */ + ptr->hfp_act = true; + ptr->a2dp_act = true; + nv_record_post_write_operation(lock); + } else #endif - { - ptr = &device_profile; - TRACE(1,"%s default", __func__); - } - return (void *)ptr; + { + ptr = &device_profile; + TRACE(1, "%s default", __func__); + } + return (void *)ptr; } static void app_bt_profile_reconnect_timehandler(void const *param); extern void startonce_delay_event_Timer_(int ms); -osTimerDef (BT_PROFILE_CONNECT_TIMER0, app_bt_profile_reconnect_timehandler); // define timers +osTimerDef(BT_PROFILE_CONNECT_TIMER0, + app_bt_profile_reconnect_timehandler); // define timers #ifdef __BT_ONE_BRING_TWO__ -osTimerDef (BT_PROFILE_CONNECT_TIMER1, app_bt_profile_reconnect_timehandler); +osTimerDef(BT_PROFILE_CONNECT_TIMER1, app_bt_profile_reconnect_timehandler); #endif #ifdef __AUTO_CONNECT_OTHER_PROFILE__ -static void app_bt_profile_connect_hf_retry_handler(void) -{ - struct app_bt_profile_manager *bt_profile_manager_p = (struct app_bt_profile_manager *)param; - if (MEC(pendCons) > 0) - { - TRACE(1,"Former link is not down yet, reset the timer %s.", __FUNCTION__); - osTimerStart(bt_profile_manager_p->connect_timer, APP_BT_PROFILE_RECONNECT_RETRY_INTERVAL_MS); - } - else - { - app_bt_precheck_before_starting_connecting(bt_profile_manager_p->has_connected); - if (bt_profile_manager_p->hfp_connect != bt_profile_connect_status_success) - { - app_bt_HF_CreateServiceLink(bt_profile_manager_p->chan, &bt_profile_manager_p->rmt_addr); - } +static void app_bt_profile_connect_hf_retry_handler(void) { + struct app_bt_profile_manager *bt_profile_manager_p = + (struct app_bt_profile_manager *)param; + if (MEC(pendCons) > 0) { + TRACE(1, "Former link is not down yet, reset the timer %s.", __FUNCTION__); + osTimerStart(bt_profile_manager_p->connect_timer, + APP_BT_PROFILE_RECONNECT_RETRY_INTERVAL_MS); + } else { + app_bt_precheck_before_starting_connecting( + bt_profile_manager_p->has_connected); + if (bt_profile_manager_p->hfp_connect != + bt_profile_connect_status_success) { + app_bt_HF_CreateServiceLink(bt_profile_manager_p->chan, + &bt_profile_manager_p->rmt_addr); } + } } -static void app_bt_profile_connect_hf_retry_timehandler(void const *param) -{ - app_bt_start_custom_function_in_bt_thread(0, 0, - (uint32_t)app_bt_profile_connect_hf_retry_handler); +static void app_bt_profile_connect_hf_retry_timehandler(void const *param) { + app_bt_start_custom_function_in_bt_thread( + 0, 0, (uint32_t)app_bt_profile_connect_hf_retry_handler); } -#if defined (__HSP_ENABLE__) -static void app_bt_profile_connect_hs_retry_timehandler(void const *param) -{ - struct app_bt_profile_manager *bt_profile_manager_p = (struct app_bt_profile_manager *)param; - if (MEC(pendCons) > 0) - { - if (bt_profile_manager_p->reconnect_cnt < APP_BT_PROFILE_OPENNING_RECONNECT_RETRY_LIMIT_CNT) - { - bt_profile_manager_p->reconnect_cnt++; - } - TRACE(1,"Former link is not down yet, reset the timer %s.", __FUNCTION__); - osTimerStart(bt_profile_manager_p->connect_timer, - BTIF_BT_DEFAULT_PAGE_TIMEOUT_IN_MS+APP_BT_PROFILE_RECONNECT_RETRY_INTERVAL_MS); +#if defined(__HSP_ENABLE__) +static void app_bt_profile_connect_hs_retry_timehandler(void const *param) { + struct app_bt_profile_manager *bt_profile_manager_p = + (struct app_bt_profile_manager *)param; + if (MEC(pendCons) > 0) { + if (bt_profile_manager_p->reconnect_cnt < + APP_BT_PROFILE_OPENNING_RECONNECT_RETRY_LIMIT_CNT) { + bt_profile_manager_p->reconnect_cnt++; } - else - { - if (bt_profile_manager_p->hsp_connect != bt_profile_connect_status_success) - { - app_bt_HS_CreateServiceLink(bt_profile_manager_p->hs_chan, &bt_profile_manager_p->rmt_addr); - } + TRACE(1, "Former link is not down yet, reset the timer %s.", __FUNCTION__); + osTimerStart(bt_profile_manager_p->connect_timer, + BTIF_BT_DEFAULT_PAGE_TIMEOUT_IN_MS + + APP_BT_PROFILE_RECONNECT_RETRY_INTERVAL_MS); + } else { + if (bt_profile_manager_p->hsp_connect != + bt_profile_connect_status_success) { + app_bt_HS_CreateServiceLink(bt_profile_manager_p->hs_chan, + &bt_profile_manager_p->rmt_addr); } + } } #endif -static bool app_bt_profile_manager_connect_a2dp_filter_connected_a2dp_stream(BT_BD_ADDR bd_addr) -{ - uint8_t i =0; - BtRemoteDevice *StrmRemDev; - A2dpStream * connected_stream; +static bool app_bt_profile_manager_connect_a2dp_filter_connected_a2dp_stream( + BT_BD_ADDR bd_addr) { + uint8_t i = 0; + BtRemoteDevice *StrmRemDev; + A2dpStream *connected_stream; - for(i =0; ibdAddr.addr,bd_addr.addr,BD_ADDR_SIZE) == 0) - { - return true; - } - } + for (i = 0; i < BT_DEVICE_NUM; i++) { + if ((app_bt_device.a2dp_stream[i].stream.state == + AVDTP_STRM_STATE_STREAMING || + app_bt_device.a2dp_stream[i].stream.state == AVDTP_STRM_STATE_OPEN)) { + connected_stream = &app_bt_device.a2dp_stream[i]; + StrmRemDev = A2DP_GetRemoteDevice(connected_stream); + if (memcmp(StrmRemDev->bdAddr.addr, bd_addr.addr, BD_ADDR_SIZE) == 0) { + return true; + } } - return false; + } + return false; } -static void app_bt_profile_connect_a2dp_retry_handler(void) -{ - struct app_bt_profile_manager *bt_profile_manager_p = (struct app_bt_profile_manager *)param; - TRACE(1,"%s reconnect_cnt = %d",__func__,bt_profile_manager_p->reconnect_cnt); +static void app_bt_profile_connect_a2dp_retry_handler(void) { + struct app_bt_profile_manager *bt_profile_manager_p = + (struct app_bt_profile_manager *)param; + TRACE(1, "%s reconnect_cnt = %d", __func__, + bt_profile_manager_p->reconnect_cnt); - if (MEC(pendCons) > 0) - { - if (bt_profile_manager_p->reconnect_cnt < APP_BT_PROFILE_OPENNING_RECONNECT_RETRY_LIMIT_CNT) - { - bt_profile_manager_p->reconnect_cnt++; - } - TRACE(1,"Former link is not down yet, reset the timer %s.", __FUNCTION__); - osTimerStart(bt_profile_manager_p->connect_timer, - BTIF_BT_DEFAULT_PAGE_TIMEOUT_IN_MS+APP_BT_PROFILE_RECONNECT_RETRY_INTERVAL_MS); + if (MEC(pendCons) > 0) { + if (bt_profile_manager_p->reconnect_cnt < + APP_BT_PROFILE_OPENNING_RECONNECT_RETRY_LIMIT_CNT) { + bt_profile_manager_p->reconnect_cnt++; } - else - { - if(app_bt_profile_manager_connect_a2dp_filter_connected_a2dp_stream(bt_profile_manager_p->rmt_addr) == true) - { - TRACE(0,"has been connected , no need to init connect again"); - return ; - } - app_bt_precheck_before_starting_connecting(bt_profile_manager_p->has_connected); - if (bt_profile_manager_p->a2dp_connect != bt_profile_connect_status_success) - { - app_bt_A2DP_OpenStream(bt_profile_manager_p->stream, &bt_profile_manager_p->rmt_addr); - } + TRACE(1, "Former link is not down yet, reset the timer %s.", __FUNCTION__); + osTimerStart(bt_profile_manager_p->connect_timer, + BTIF_BT_DEFAULT_PAGE_TIMEOUT_IN_MS + + APP_BT_PROFILE_RECONNECT_RETRY_INTERVAL_MS); + } else { + if (app_bt_profile_manager_connect_a2dp_filter_connected_a2dp_stream( + bt_profile_manager_p->rmt_addr) == true) { + TRACE(0, "has been connected , no need to init connect again"); + return; } + app_bt_precheck_before_starting_connecting( + bt_profile_manager_p->has_connected); + if (bt_profile_manager_p->a2dp_connect != + bt_profile_connect_status_success) { + app_bt_A2DP_OpenStream(bt_profile_manager_p->stream, + &bt_profile_manager_p->rmt_addr); + } + } } -static void app_bt_profile_connect_a2dp_retry_timehandler(void const *param) -{ - app_bt_start_custom_function_in_bt_thread(0, 0, - (uint32_t)app_bt_profile_connect_a2dp_retry_handler); +static void app_bt_profile_connect_a2dp_retry_timehandler(void const *param) { + app_bt_start_custom_function_in_bt_thread( + 0, 0, (uint32_t)app_bt_profile_connect_a2dp_retry_handler); } #endif -void app_bt_reset_reconnect_timer(bt_bdaddr_t *pBdAddr) -{ - uint8_t devId = 0; - for (uint8_t i = 0; i < BT_DEVICE_NUM; i++) - { - if (pBdAddr == &(bt_profile_manager[i].rmt_addr)) - { - devId = i; - break; - } +void app_bt_reset_reconnect_timer(bt_bdaddr_t *pBdAddr) { + uint8_t devId = 0; + for (uint8_t i = 0; i < BT_DEVICE_NUM; i++) { + if (pBdAddr == &(bt_profile_manager[i].rmt_addr)) { + devId = i; + break; } + } - TRACE(1,"Resart the reconnecting timer of dev %d", devId); - osTimerStart(bt_profile_manager[devId].connect_timer, - BTIF_BT_DEFAULT_PAGE_TIMEOUT_IN_MS+APP_BT_PROFILE_RECONNECT_RETRY_INTERVAL_MS); + TRACE(1, "Resart the reconnecting timer of dev %d", devId); + osTimerStart(bt_profile_manager[devId].connect_timer, + BTIF_BT_DEFAULT_PAGE_TIMEOUT_IN_MS + + APP_BT_PROFILE_RECONNECT_RETRY_INTERVAL_MS); } -static void app_bt_profile_reconnect_handler(void const *param) -{ +static void app_bt_profile_reconnect_handler(void const *param) { #if !defined(IBRT) - struct app_bt_profile_manager *bt_profile_manager_p = (struct app_bt_profile_manager *)param; - TRACE(1,"%s reconnect_cnt = %d",__FUNCTION__,bt_profile_manager_p->reconnect_cnt); + struct app_bt_profile_manager *bt_profile_manager_p = + (struct app_bt_profile_manager *)param; + TRACE(1, "%s reconnect_cnt = %d", __FUNCTION__, + bt_profile_manager_p->reconnect_cnt); - if ( btif_me_get_pendCons() > 0) - { - if (bt_profile_manager_p->reconnect_cnt < APP_BT_PROFILE_OPENNING_RECONNECT_RETRY_LIMIT_CNT) - { - bt_profile_manager_p->reconnect_cnt++; - } - TRACE(1,"Former link is not down yet, reset the timer %s.", __FUNCTION__); - osTimerStart(bt_profile_manager_p->connect_timer, - BTIF_BT_DEFAULT_PAGE_TIMEOUT_IN_MS+APP_BT_PROFILE_RECONNECT_RETRY_INTERVAL_MS); + if (btif_me_get_pendCons() > 0) { + if (bt_profile_manager_p->reconnect_cnt < + APP_BT_PROFILE_OPENNING_RECONNECT_RETRY_LIMIT_CNT) { + bt_profile_manager_p->reconnect_cnt++; } - else - { - btdevice_profile *btdevice_plf_p = (btdevice_profile *)app_bt_profile_active_store_ptr_get(bt_profile_manager_p->rmt_addr.address); + TRACE(1, "Former link is not down yet, reset the timer %s.", __FUNCTION__); + osTimerStart(bt_profile_manager_p->connect_timer, + BTIF_BT_DEFAULT_PAGE_TIMEOUT_IN_MS + + APP_BT_PROFILE_RECONNECT_RETRY_INTERVAL_MS); + } else { + btdevice_profile *btdevice_plf_p = + (btdevice_profile *)app_bt_profile_active_store_ptr_get( + bt_profile_manager_p->rmt_addr.address); #ifdef __BT_ONE_BRING_TWO__ - if(a2dp_is_music_ongoing()&&(bt_profile_manager_p->has_connected == false)) - { - bt_drv_reg_op_set_reconnecting_flag(); - a2dp_update_music_link(); - } + if (a2dp_is_music_ongoing() && + (bt_profile_manager_p->has_connected == false)) { + bt_drv_reg_op_set_reconnecting_flag(); + a2dp_update_music_link(); + } #endif - if (bt_profile_manager_p->connect_timer_cb) - { - bt_profile_manager_p->connect_timer_cb(param); - bt_profile_manager_p->connect_timer_cb = NULL; - } - else - { - if ((btdevice_plf_p->hfp_act) - &&(bt_profile_manager_p->hfp_connect != bt_profile_connect_status_success)) - { - TRACE(0,"try connect hf"); - app_bt_precheck_before_starting_connecting(bt_profile_manager_p->has_connected); - app_bt_HF_CreateServiceLink(bt_profile_manager_p->chan, (bt_bdaddr_t *)&bt_profile_manager_p->rmt_addr); - } -#if defined (__HSP_ENABLE__) - else if(btdevice_plf_p->hsp_act) + if (bt_profile_manager_p->connect_timer_cb) { + bt_profile_manager_p->connect_timer_cb(param); + bt_profile_manager_p->connect_timer_cb = NULL; + } else { + if ((btdevice_plf_p->hfp_act) && (bt_profile_manager_p->hfp_connect != + bt_profile_connect_status_success)) { + TRACE(0, "try connect hf"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager_p->has_connected); + app_bt_HF_CreateServiceLink( + bt_profile_manager_p->chan, + (bt_bdaddr_t *)&bt_profile_manager_p->rmt_addr); + } +#if defined(__HSP_ENABLE__) + else if (btdevice_plf_p->hsp_act) &&(bt_profile_manager_p->hsp_connect != bt_profile_connect_status_success)) { - TRACE(0,"try connect hs"); - app_bt_precheck_before_starting_connecting(bt_profile_manager_p->has_connected); - app_bt_HS_CreateServiceLink(bt_profile_manager_p->hs_chan, &bt_profile_manager_p->rmt_addr); - } + TRACE(0, "try connect hs"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager_p->has_connected); + app_bt_HS_CreateServiceLink(bt_profile_manager_p->hs_chan, + &bt_profile_manager_p->rmt_addr); + } #endif - else if((btdevice_plf_p->a2dp_act) - &&(bt_profile_manager_p->a2dp_connect != bt_profile_connect_status_success)) - { - TRACE(0,"try connect a2dp"); - app_bt_precheck_before_starting_connecting(bt_profile_manager_p->has_connected); - app_bt_A2DP_OpenStream(bt_profile_manager_p->stream, &bt_profile_manager_p->rmt_addr); - } - } + else if ((btdevice_plf_p->a2dp_act) && + (bt_profile_manager_p->a2dp_connect != + bt_profile_connect_status_success)) { + TRACE(0, "try connect a2dp"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager_p->has_connected); + app_bt_A2DP_OpenStream(bt_profile_manager_p->stream, + &bt_profile_manager_p->rmt_addr); + } } + } #else - TRACE(0,"ibrt_ui_log:app_bt_profile_reconnect_timehandler called"); + TRACE(0, "ibrt_ui_log:app_bt_profile_reconnect_timehandler called"); #endif } -static void app_bt_profile_reconnect_timehandler(void const *param) -{ - app_bt_start_custom_function_in_bt_thread((uint32_t)param, 0, - (uint32_t)app_bt_profile_reconnect_handler); +static void app_bt_profile_reconnect_timehandler(void const *param) { + app_bt_start_custom_function_in_bt_thread( + (uint32_t)param, 0, (uint32_t)app_bt_profile_reconnect_handler); } -bool app_bt_is_in_connecting_profiles_state(void) -{ - for (uint8_t devId = 0; devId < BT_DEVICE_NUM; devId++) - { - if (APP_BT_IN_CONNECTING_PROFILES_STATE == bt_profile_manager[devId].connectingState) - { - return true; - } +bool app_bt_is_in_connecting_profiles_state(void) { + for (uint8_t devId = 0; devId < BT_DEVICE_NUM; devId++) { + if (APP_BT_IN_CONNECTING_PROFILES_STATE == + bt_profile_manager[devId].connectingState) { + return true; } + } - return false; + return false; } -void app_bt_clear_connecting_profiles_state(uint8_t devId) -{ - TRACE(1,"Dev %d exists connecting profiles state", devId); +void app_bt_clear_connecting_profiles_state(uint8_t devId) { + TRACE(1, "Dev %d exists connecting profiles state", devId); - bt_profile_manager[devId].connectingState = APP_BT_IDLE_STATE; - if (!app_bt_is_in_connecting_profiles_state()) - { -#ifdef __IAG_BLE_INCLUDE__ - app_start_fast_connectable_ble_adv(BLE_FAST_ADVERTISING_INTERVAL); -#endif - } -} - -void app_bt_set_connecting_profiles_state(uint8_t devId) -{ - TRACE(1,"Dev %d enters connecting profiles state", devId); - - bt_profile_manager[devId].connectingState = APP_BT_IN_CONNECTING_PROFILES_STATE; -} - -void app_bt_profile_connect_manager_open(void) -{ - uint8_t i=0; - for (i=0; ihfp_act)&&!(btdevice_plf_p->a2dp_act)) - { - nv_record_ddbrec_delete((bt_bdaddr_t *)&record1.bdAddr); - find_invalid_record_cnt++; - } - } - else if(ret == 2) - { - btdevice_plf_p = (btdevice_profile *)app_bt_profile_active_store_ptr_get(record1.bdAddr.address); - if (!(btdevice_plf_p->hfp_act)&&!(btdevice_plf_p->a2dp_act)) - { - nv_record_ddbrec_delete((bt_bdaddr_t *)&record1.bdAddr); - find_invalid_record_cnt++; - } - btdevice_plf_p = (btdevice_profile *)app_bt_profile_active_store_ptr_get(record2.bdAddr.address); - if (!(btdevice_plf_p->hfp_act)&&!(btdevice_plf_p->a2dp_act)) - { - nv_record_ddbrec_delete((bt_bdaddr_t *)&record2.bdAddr); - find_invalid_record_cnt++; - } - } - } - while(find_invalid_record_cnt); - - TRACE(0,"!!!app_bt_opening_reconnect:\n"); - DUMP8("%02x ", &record1.bdAddr, 6); - DUMP8("%02x ", &record2.bdAddr, 6); - - - if(ret > 0) - { - TRACE(0,"!!!start reconnect first device\n"); - - if( btif_me_get_pendCons() == 0) - { - bt_profile_manager[BT_DEVICE_ID_1].reconnect_mode = bt_profile_reconnect_openreconnecting; - bt_profile_manager[BT_DEVICE_ID_1].reconnect_cnt = 0; - memcpy(bt_profile_manager[BT_DEVICE_ID_1].rmt_addr.address, record1.bdAddr.address, BTIF_BD_ADDR_SIZE); - btdevice_plf_p = (btdevice_profile *)app_bt_profile_active_store_ptr_get(bt_profile_manager[BT_DEVICE_ID_1].rmt_addr.address); - -#if defined(A2DP_LHDC_ON) - if(btdevice_plf_p->a2dp_codectype == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_1]->a2dp_stream; - else -#endif -#if defined(A2DP_AAC_ON) - if(btdevice_plf_p->a2dp_codectype == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream; - else -#endif -#if defined(A2DP_LDAC_ON) //workaround for mate10 no a2dp issue when link back - if(btdevice_plf_p->a2dp_codectype == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - { - //bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream; - //btdevice_plf_p->a2dp_codectype = BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC; - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_ldac_stream[BT_DEVICE_ID_1]->a2dp_stream; - btdevice_plf_p->a2dp_codectype = BTIF_AVDTP_CODEC_TYPE_NON_A2DP; - } - else -#endif - -#if defined(A2DP_SCALABLE_ON) - if(btdevice_plf_p->a2dp_codectype == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_1]->a2dp_stream; - else -#endif - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream; - } - - btif_a2dp_reset_stream_state(bt_profile_manager[BT_DEVICE_ID_1].stream); - - bt_profile_manager[BT_DEVICE_ID_1].chan = app_bt_device.hf_channel[BT_DEVICE_ID_1]; -#if defined (__HSP_ENABLE__) - bt_profile_manager[BT_DEVICE_ID_1].hs_chan = &app_bt_device.hs_channel[BT_DEVICE_ID_1]; -#endif - if (btdevice_plf_p->hfp_act) - { - TRACE(0,"try connect hf"); - app_bt_precheck_before_starting_connecting(bt_profile_manager[BT_DEVICE_ID_1].has_connected); - app_bt_HF_CreateServiceLink(bt_profile_manager[BT_DEVICE_ID_1].chan, (bt_bdaddr_t *)&bt_profile_manager[BT_DEVICE_ID_1].rmt_addr); - } - else if(btdevice_plf_p->a2dp_act) - { - TRACE(0,"try connect a2dp"); - app_bt_precheck_before_starting_connecting(bt_profile_manager[BT_DEVICE_ID_1].has_connected); - app_bt_A2DP_OpenStream(bt_profile_manager[BT_DEVICE_ID_1].stream, &bt_profile_manager[BT_DEVICE_ID_1].rmt_addr); - } - -#if defined (__HSP_ENABLE__) - else if (btdevice_plf_p->hsp_act) - { - TRACE(0,"try connect hs"); - app_bt_precheck_before_starting_connecting(bt_profile_manager[BT_DEVICE_ID_1].has_connected); - app_bt_HS_CreateServiceLink(bt_profile_manager[BT_DEVICE_ID_1].hs_chan, &bt_profile_manager[BT_DEVICE_ID_1].rmt_addr); - } -#endif - - } -#ifdef __BT_ONE_BRING_TWO__ - if(ret > 1) - { - TRACE(0,"!!!need reconnect second device\n"); - bt_profile_manager[BT_DEVICE_ID_2].reconnect_mode = bt_profile_reconnect_openreconnecting; - bt_profile_manager[BT_DEVICE_ID_2].reconnect_cnt = 0; - memcpy(bt_profile_manager[BT_DEVICE_ID_2].rmt_addr.address, record2.bdAddr.address, BTIF_BD_ADDR_SIZE); - btdevice_plf_p = (btdevice_profile *)app_bt_profile_active_store_ptr_get(bt_profile_manager[BT_DEVICE_ID_2].rmt_addr.address); - -#if defined(A2DP_LHDC_ON) - if(btdevice_plf_p->a2dp_codectype == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - bt_profile_manager[BT_DEVICE_ID_2].stream = app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_2]->a2dp_stream; - else -#endif -#if defined(A2DP_AAC_ON) - if(btdevice_plf_p->a2dp_codectype == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) - bt_profile_manager[BT_DEVICE_ID_2].stream = app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_2]->a2dp_stream; - else -#endif -#if defined(A2DP_SCALABLE_ON) - if(btdevice_plf_p->a2dp_codectype == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - bt_profile_manager[BT_DEVICE_ID_2].stream = app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_2]->a2dp_stream; - else -#endif - { - bt_profile_manager[BT_DEVICE_ID_2].stream = app_bt_device.a2dp_stream[BT_DEVICE_ID_2]->a2dp_stream; - } - - btif_a2dp_reset_stream_state(bt_profile_manager[BT_DEVICE_ID_2].stream); - - bt_profile_manager[BT_DEVICE_ID_2].chan = app_bt_device.hf_channel[BT_DEVICE_ID_2]; -#if defined (__HSP_ENABLE__) - bt_profile_manager[BT_DEVICE_ID_2].hs_chan = &app_bt_device.hs_channel[BT_DEVICE_ID_2]; -#endif - } -#endif - } - - else - { - TRACE(0,"!!!go to pairing\n"); -#ifdef __EARPHONE_STAY_BOTH_SCAN__ - app_bt_accessmode_set_req(BTIF_BT_DEFAULT_ACCESS_MODE_PAIR); -#else - app_bt_accessmode_set_req(BTIF_BAM_CONNECTABLE_ONLY); -#endif - - } - osapi_unlock_stack(); -} - - -void app_bt_resume_sniff_mode(uint8_t deviceId) -{ - if (bt_profile_connect_status_success == bt_profile_manager[deviceId].a2dp_connect|| - bt_profile_connect_status_success == bt_profile_manager[deviceId].hfp_connect|| - bt_profile_connect_status_success == bt_profile_manager[deviceId].hsp_connect) - { - app_bt_allow_sniff(deviceId); - btif_remote_device_t* currentRemDev = app_bt_get_remoteDev(deviceId); - app_bt_sniff_config(currentRemDev); - } -} -#if !defined(IBRT) -static int8_t app_bt_profile_reconnect_pending(enum BT_DEVICE_ID_T id) -{ - if(btapp_hfp_is_dev_call_active(id) == true) - { - bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_reconnect_pending; - return 0; - } - return -1; -} -#endif -static int8_t app_bt_profile_reconnect_pending_process(void) -{ - uint8_t i =BT_DEVICE_NUM; - - btif_remote_device_t *remDev = NULL; - btif_cmgr_handler_t *cmgrHandler; - - - for (i=0; ihfp_act) && !(btdevice_plf_p->a2dp_act)) { + nv_record_ddbrec_delete((bt_bdaddr_t *)&record1.bdAddr); + find_invalid_record_cnt++; + } + } else if (ret == 2) { + btdevice_plf_p = (btdevice_profile *)app_bt_profile_active_store_ptr_get( + record1.bdAddr.address); + if (!(btdevice_plf_p->hfp_act) && !(btdevice_plf_p->a2dp_act)) { + nv_record_ddbrec_delete((bt_bdaddr_t *)&record1.bdAddr); + find_invalid_record_cnt++; + } + btdevice_plf_p = (btdevice_profile *)app_bt_profile_active_store_ptr_get( + record2.bdAddr.address); + if (!(btdevice_plf_p->hfp_act) && !(btdevice_plf_p->a2dp_act)) { + nv_record_ddbrec_delete((bt_bdaddr_t *)&record2.bdAddr); + find_invalid_record_cnt++; + } + } + } while (find_invalid_record_cnt); + + TRACE(0, "!!!app_bt_opening_reconnect:\n"); + DUMP8("%02x ", &record1.bdAddr, 6); + DUMP8("%02x ", &record2.bdAddr, 6); + + if (ret > 0) { + TRACE(0, "!!!start reconnect first device\n"); + + if (btif_me_get_pendCons() == 0) { + bt_profile_manager[BT_DEVICE_ID_1].reconnect_mode = + bt_profile_reconnect_openreconnecting; + bt_profile_manager[BT_DEVICE_ID_1].reconnect_cnt = 0; + memcpy(bt_profile_manager[BT_DEVICE_ID_1].rmt_addr.address, + record1.bdAddr.address, BTIF_BD_ADDR_SIZE); + btdevice_plf_p = (btdevice_profile *)app_bt_profile_active_store_ptr_get( + bt_profile_manager[BT_DEVICE_ID_1].rmt_addr.address); + +#if defined(A2DP_LHDC_ON) + if (btdevice_plf_p->a2dp_codectype == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_1]->a2dp_stream; + else +#endif +#if defined(A2DP_AAC_ON) + if (btdevice_plf_p->a2dp_codectype == + BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream; + else +#endif +#if defined(A2DP_LDAC_ON) // workaround for mate10 no a2dp issue when link back + if (btdevice_plf_p->a2dp_codectype == + BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + // bt_profile_manager[BT_DEVICE_ID_1].stream = + // app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream; + // btdevice_plf_p->a2dp_codectype = BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC; + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_ldac_stream[BT_DEVICE_ID_1]->a2dp_stream; + btdevice_plf_p->a2dp_codectype = BTIF_AVDTP_CODEC_TYPE_NON_A2DP; + } else +#endif + +#if defined(A2DP_SCALABLE_ON) + if (btdevice_plf_p->a2dp_codectype == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_1]->a2dp_stream; + else +#endif + { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream; + } + + btif_a2dp_reset_stream_state(bt_profile_manager[BT_DEVICE_ID_1].stream); + + bt_profile_manager[BT_DEVICE_ID_1].chan = + app_bt_device.hf_channel[BT_DEVICE_ID_1]; +#if defined(__HSP_ENABLE__) + bt_profile_manager[BT_DEVICE_ID_1].hs_chan = + &app_bt_device.hs_channel[BT_DEVICE_ID_1]; +#endif + if (btdevice_plf_p->hfp_act) { + TRACE(0, "try connect hf"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[BT_DEVICE_ID_1].has_connected); + app_bt_HF_CreateServiceLink( + bt_profile_manager[BT_DEVICE_ID_1].chan, + (bt_bdaddr_t *)&bt_profile_manager[BT_DEVICE_ID_1].rmt_addr); + } else if (btdevice_plf_p->a2dp_act) { + TRACE(0, "try connect a2dp"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[BT_DEVICE_ID_1].has_connected); + app_bt_A2DP_OpenStream(bt_profile_manager[BT_DEVICE_ID_1].stream, + &bt_profile_manager[BT_DEVICE_ID_1].rmt_addr); + } + +#if defined(__HSP_ENABLE__) + else if (btdevice_plf_p->hsp_act) { + TRACE(0, "try connect hs"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[BT_DEVICE_ID_1].has_connected); + app_bt_HS_CreateServiceLink( + bt_profile_manager[BT_DEVICE_ID_1].hs_chan, + &bt_profile_manager[BT_DEVICE_ID_1].rmt_addr); + } +#endif + } +#ifdef __BT_ONE_BRING_TWO__ + if (ret > 1) { + TRACE(0, "!!!need reconnect second device\n"); + bt_profile_manager[BT_DEVICE_ID_2].reconnect_mode = + bt_profile_reconnect_openreconnecting; + bt_profile_manager[BT_DEVICE_ID_2].reconnect_cnt = 0; + memcpy(bt_profile_manager[BT_DEVICE_ID_2].rmt_addr.address, + record2.bdAddr.address, BTIF_BD_ADDR_SIZE); + btdevice_plf_p = (btdevice_profile *)app_bt_profile_active_store_ptr_get( + bt_profile_manager[BT_DEVICE_ID_2].rmt_addr.address); + +#if defined(A2DP_LHDC_ON) + if (btdevice_plf_p->a2dp_codectype == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) + bt_profile_manager[BT_DEVICE_ID_2].stream = + app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_2]->a2dp_stream; + else +#endif +#if defined(A2DP_AAC_ON) + if (btdevice_plf_p->a2dp_codectype == + BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) + bt_profile_manager[BT_DEVICE_ID_2].stream = + app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_2]->a2dp_stream; + else +#endif +#if defined(A2DP_SCALABLE_ON) + if (btdevice_plf_p->a2dp_codectype == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) + bt_profile_manager[BT_DEVICE_ID_2].stream = + app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_2]->a2dp_stream; + else +#endif + { + bt_profile_manager[BT_DEVICE_ID_2].stream = + app_bt_device.a2dp_stream[BT_DEVICE_ID_2]->a2dp_stream; + } + + btif_a2dp_reset_stream_state(bt_profile_manager[BT_DEVICE_ID_2].stream); + + bt_profile_manager[BT_DEVICE_ID_2].chan = + app_bt_device.hf_channel[BT_DEVICE_ID_2]; +#if defined(__HSP_ENABLE__) + bt_profile_manager[BT_DEVICE_ID_2].hs_chan = + &app_bt_device.hs_channel[BT_DEVICE_ID_2]; +#endif + } +#endif + } + + else { + TRACE(0, "!!!go to pairing\n"); +#ifdef __EARPHONE_STAY_BOTH_SCAN__ + app_bt_accessmode_set_req(BTIF_BT_DEFAULT_ACCESS_MODE_PAIR); +#else + app_bt_accessmode_set_req(BTIF_BAM_CONNECTABLE_ONLY); +#endif + } + osapi_unlock_stack(); +} + +void app_bt_resume_sniff_mode(uint8_t deviceId) { + if (bt_profile_connect_status_success == + bt_profile_manager[deviceId].a2dp_connect || + bt_profile_connect_status_success == + bt_profile_manager[deviceId].hfp_connect || + bt_profile_connect_status_success == + bt_profile_manager[deviceId].hsp_connect) { + app_bt_allow_sniff(deviceId); + btif_remote_device_t *currentRemDev = app_bt_get_remoteDev(deviceId); + app_bt_sniff_config(currentRemDev); + } +} +#if !defined(IBRT) +static int8_t app_bt_profile_reconnect_pending(enum BT_DEVICE_ID_T id) { + if (btapp_hfp_is_dev_call_active(id) == true) { + bt_profile_manager[id].reconnect_mode = + bt_profile_reconnect_reconnect_pending; + return 0; + } + return -1; +} +#endif +static int8_t app_bt_profile_reconnect_pending_process(void) { + uint8_t i = BT_DEVICE_NUM; + + btif_remote_device_t *remDev = NULL; + btif_cmgr_handler_t *cmgrHandler; + + for (i = 0; i < BT_DEVICE_NUM; i++) { + remDev = btif_me_enumerate_remote_devices(i); + if (remDev != NULL) { + cmgrHandler = btif_cmgr_get_acl_handler(remDev); + if (btif_cmgr_is_audio_up(cmgrHandler) == 1) + return -1; + } + } + for (i = 0; i < BT_DEVICE_NUM; i++) { + if (bt_profile_manager[i].reconnect_mode == + bt_profile_reconnect_reconnect_pending) + break; + } + + if (i == BT_DEVICE_NUM) + return -1; + + bt_profile_manager[i].reconnect_mode = bt_profile_reconnect_reconnecting; +#ifdef __IAG_BLE_INCLUDE__ + app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); +#endif + osTimerStart(bt_profile_manager[i].connect_timer, + APP_BT_PROFILE_RECONNECT_RETRY_INTERVAL_MS); + return 0; +} + +uint8_t app_bt_get_num_of_connected_dev(void) { + uint8_t num_of_connected_dev = 0; + uint8_t deviceId; + + for (deviceId = 0; deviceId < BT_DEVICE_NUM; deviceId++) { + if (bt_profile_manager[deviceId].has_connected) { + num_of_connected_dev++; + } + } + + return num_of_connected_dev; +} + +static uint8_t recorded_latest_connected_service_device_id = BT_DEVICE_ID_1; +void app_bt_record_latest_connected_service_device_id(uint8_t device_id) { + recorded_latest_connected_service_device_id = device_id; +} + +uint8_t app_bt_get_recorded_latest_connected_service_device_id(void) { + return recorded_latest_connected_service_device_id; +} + +static void app_bt_precheck_before_starting_connecting(uint8_t isBtConnected) { +#ifdef __IAG_BLE_INCLUDE__ + if (!isBtConnected) { + app_ble_force_switch_adv(BLE_SWITCH_USER_BT_CONNECT, false); + } +#endif +} + +static void app_bt_restore_reconnecting_idle_mode(uint8_t deviceId) { + bt_profile_manager[deviceId].reconnect_mode = bt_profile_reconnect_null; +#ifdef __IAG_BLE_INCLUDE__ + app_start_fast_connectable_ble_adv(BLE_FAST_ADVERTISING_INTERVAL); #endif } #ifdef __BT_ONE_BRING_TWO__ -static void app_bt_update_connectable_mode_after_connection_management(void) -{ - uint8_t deviceId; - bool isEnterConnetableOnlyState = true; - for (deviceId = 0; deviceId < BT_DEVICE_NUM; deviceId++) - { - // assure none of the device is in reconnecting mode - if (bt_profile_manager[deviceId].reconnect_mode != bt_profile_reconnect_null) - { - isEnterConnetableOnlyState = false; - break; - } +static void app_bt_update_connectable_mode_after_connection_management(void) { + uint8_t deviceId; + bool isEnterConnetableOnlyState = true; + for (deviceId = 0; deviceId < BT_DEVICE_NUM; deviceId++) { + // assure none of the device is in reconnecting mode + if (bt_profile_manager[deviceId].reconnect_mode != + bt_profile_reconnect_null) { + isEnterConnetableOnlyState = false; + break; } + } - if (isEnterConnetableOnlyState) - { - for (deviceId = 0; deviceId < BT_DEVICE_NUM; deviceId++) - { - if (!bt_profile_manager[deviceId].has_connected) - { - app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); - return; - } - } + if (isEnterConnetableOnlyState) { + for (deviceId = 0; deviceId < BT_DEVICE_NUM; deviceId++) { + if (!bt_profile_manager[deviceId].has_connected) { + app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); + return; + } } + } } #endif -static void app_bt_connectable_mode_stop_reconnecting_handler(void) -{ - uint8_t deviceId; - btif_remote_device_t*remDev; - btif_cmgr_handler_t * cmgrHandler; - for (deviceId = 0; deviceId < BT_DEVICE_NUM; deviceId++) - { - if (bt_profile_manager[deviceId].reconnect_mode != bt_profile_reconnect_null) - { - bt_profile_manager[deviceId].hfp_connect = bt_profile_connect_status_failure; - bt_profile_manager[deviceId].reconnect_mode = bt_profile_reconnect_null; - bt_profile_manager[deviceId].saved_reconnect_mode = bt_profile_reconnect_null; - bt_profile_manager[deviceId].reconnect_cnt = 0; - if(bt_profile_manager[deviceId].connect_timer !=NULL) - osTimerStop(bt_profile_manager[deviceId].connect_timer); - remDev = btif_me_enumerate_remote_devices(deviceId); - if (remDev != NULL) - { - cmgrHandler = btif_cmgr_get_acl_handler(remDev); - btif_me_cancel_create_link( btif_cmgr_get_cmgrhandler_remdev_bthandle(cmgrHandler),remDev); - } - } +static void app_bt_connectable_mode_stop_reconnecting_handler(void) { + uint8_t deviceId; + btif_remote_device_t *remDev; + btif_cmgr_handler_t *cmgrHandler; + for (deviceId = 0; deviceId < BT_DEVICE_NUM; deviceId++) { + if (bt_profile_manager[deviceId].reconnect_mode != + bt_profile_reconnect_null) { + bt_profile_manager[deviceId].hfp_connect = + bt_profile_connect_status_failure; + bt_profile_manager[deviceId].reconnect_mode = bt_profile_reconnect_null; + bt_profile_manager[deviceId].saved_reconnect_mode = + bt_profile_reconnect_null; + bt_profile_manager[deviceId].reconnect_cnt = 0; + if (bt_profile_manager[deviceId].connect_timer != NULL) + osTimerStop(bt_profile_manager[deviceId].connect_timer); + remDev = btif_me_enumerate_remote_devices(deviceId); + if (remDev != NULL) { + cmgrHandler = btif_cmgr_get_acl_handler(remDev); + btif_me_cancel_create_link( + btif_cmgr_get_cmgrhandler_remdev_bthandle(cmgrHandler), remDev); + } } + } } -void app_bt_connectable_mode_stop_reconnecting(void) -{ - app_bt_start_custom_function_in_bt_thread(0, 0, - (uint32_t)app_bt_connectable_mode_stop_reconnecting_handler); +void app_bt_connectable_mode_stop_reconnecting(void) { + app_bt_start_custom_function_in_bt_thread( + 0, 0, (uint32_t)app_bt_connectable_mode_stop_reconnecting_handler); } -#if defined (__HSP_ENABLE__) -void app_bt_profile_connect_manager_hs(enum BT_DEVICE_ID_T id, HsChannel *Chan, HsCallbackParms *Info) -{ - btdevice_profile *btdevice_plf_p = (btdevice_profile *)app_bt_profile_active_store_ptr_get((uint8_t *)Info->p.remDev->bdAddr.address); +#if defined(__HSP_ENABLE__) +void app_bt_profile_connect_manager_hs(enum BT_DEVICE_ID_T id, HsChannel *Chan, + HsCallbackParms *Info) { + btdevice_profile *btdevice_plf_p = + (btdevice_profile *)app_bt_profile_active_store_ptr_get( + (uint8_t *)Info->p.remDev->bdAddr.address); - osTimerStop(bt_profile_manager[id].connect_timer); - bt_profile_manager[id].connect_timer_cb = NULL; - bool profile_reconnect_enable = false; + osTimerStop(bt_profile_manager[id].connect_timer); + bt_profile_manager[id].connect_timer_cb = NULL; + bool profile_reconnect_enable = false; - if (Chan&&Info) - { - switch(Info->event) - { - case HF_EVENT_SERVICE_CONNECTED: - TRACE(1,"%s HS_EVENT_SERVICE_CONNECTED",__func__); - nv_record_btdevicerecord_set_hsp_profile_active_state(btdevice_plf_p, true); + if (Chan && Info) { + switch (Info->event) { + case HF_EVENT_SERVICE_CONNECTED: + TRACE(1, "%s HS_EVENT_SERVICE_CONNECTED", __func__); + nv_record_btdevicerecord_set_hsp_profile_active_state(btdevice_plf_p, + true); #ifndef FPGA - nv_record_touch_cause_flush(); + nv_record_touch_cause_flush(); #endif - bt_profile_manager[id].hsp_connect = bt_profile_connect_status_success; - bt_profile_manager[id].reconnect_cnt = 0; - bt_profile_manager[id].hs_chan = &app_bt_device.hs_channel[id]; - memcpy(bt_profile_manager[id].rmt_addr.address, Info->p.remDev->bdAddr.address, BTIF_BD_ADDR_SIZE); - if (false == bt_profile_manager[id].has_connected) - { - app_bt_resume_sniff_mode(id); - } - if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_openreconnecting) - { - //do nothing - } - else if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_reconnecting) - { - if (btdevice_plf_p->a2dp_act && bt_profile_manager[id].a2dp_connect != bt_profile_connect_status_success) - { - TRACE(0,"!!!continue connect a2dp\n"); - app_bt_precheck_before_starting_connecting(bt_profile_manager[id].has_connected); - app_bt_A2DP_OpenStream(bt_profile_manager[id].stream, &bt_profile_manager[id].rmt_address); - } - } + bt_profile_manager[id].hsp_connect = bt_profile_connect_status_success; + bt_profile_manager[id].reconnect_cnt = 0; + bt_profile_manager[id].hs_chan = &app_bt_device.hs_channel[id]; + memcpy(bt_profile_manager[id].rmt_addr.address, + Info->p.remDev->bdAddr.address, BTIF_BD_ADDR_SIZE); + if (false == bt_profile_manager[id].has_connected) { + app_bt_resume_sniff_mode(id); + } + if (bt_profile_manager[id].reconnect_mode == + bt_profile_reconnect_openreconnecting) { + // do nothing + } else if (bt_profile_manager[id].reconnect_mode == + bt_profile_reconnect_reconnecting) { + if (btdevice_plf_p->a2dp_act && bt_profile_manager[id].a2dp_connect != + bt_profile_connect_status_success) { + TRACE(0, "!!!continue connect a2dp\n"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[id].has_connected); + app_bt_A2DP_OpenStream(bt_profile_manager[id].stream, + &bt_profile_manager[id].rmt_address); + } + } #ifdef __AUTO_CONNECT_OTHER_PROFILE__ - else - { - if (btdevice_plf_p->a2dp_act && bt_profile_manager[id].a2dp_connect != bt_profile_connect_status_success) - { - bt_profile_manager[id].connect_timer_cb = app_bt_profile_connect_a2dp_retry_timehandler; - app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); - osTimerStart(bt_profile_manager[id].connect_timer, APP_BT_PROFILE_CONNECT_RETRY_MS); - } - } + else { + if (btdevice_plf_p->a2dp_act && bt_profile_manager[id].a2dp_connect != + bt_profile_connect_status_success) { + bt_profile_manager[id].connect_timer_cb = + app_bt_profile_connect_a2dp_retry_timehandler; + app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); + osTimerStart(bt_profile_manager[id].connect_timer, + APP_BT_PROFILE_CONNECT_RETRY_MS); + } + } #endif - break; - case HF_EVENT_SERVICE_DISCONNECTED: - TRACE(2,"%s HS_EVENT_SERVICE_DISCONNECTED discReason:%d",__func__, Info->p.remDev->discReason); - bt_profile_manager[id].hsp_connect = bt_profile_connect_status_failure; - if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_openreconnecting) - { - if (++bt_profile_manager[id].reconnect_cnt < APP_BT_PROFILE_OPENNING_RECONNECT_RETRY_LIMIT_CNT) - { - app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); - profile_reconnect_enable = true; - bt_profile_manager[id].hfp_connect = bt_profile_connect_status_unknow; - } - } - else if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_reconnecting) - { - if (++bt_profile_manager[id].reconnect_cnt < APP_BT_PROFILE_RECONNECT_RETRY_LIMIT_CNT) - { - app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); - profile_reconnect_enable = true - } - else - { - app_bt_restore_reconnecting_idle_mode(id); - //bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_null; - } - TRACE(2,"%s try to reconnect cnt:%d",__func__, bt_profile_manager[id].reconnect_cnt); + break; + case HF_EVENT_SERVICE_DISCONNECTED: + TRACE(2, "%s HS_EVENT_SERVICE_DISCONNECTED discReason:%d", __func__, + Info->p.remDev->discReason); + bt_profile_manager[id].hsp_connect = bt_profile_connect_status_failure; + if (bt_profile_manager[id].reconnect_mode == + bt_profile_reconnect_openreconnecting) { + if (++bt_profile_manager[id].reconnect_cnt < + APP_BT_PROFILE_OPENNING_RECONNECT_RETRY_LIMIT_CNT) { + app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); + profile_reconnect_enable = true; + bt_profile_manager[id].hfp_connect = bt_profile_connect_status_unknow; + } + } else if (bt_profile_manager[id].reconnect_mode == + bt_profile_reconnect_reconnecting) { + if (++bt_profile_manager[id].reconnect_cnt < + APP_BT_PROFILE_RECONNECT_RETRY_LIMIT_CNT) { + app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); + profile_reconnect_enable = true + } else { + app_bt_restore_reconnecting_idle_mode(id); + // bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_null; + } + TRACE(2, "%s try to reconnect cnt:%d", __func__, + bt_profile_manager[id].reconnect_cnt); #if !defined(IBRT) - } - else if(Info->p.remDev->discReason == 0x8) - { - bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_reconnecting; - app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); - TRACE(1,"%s try to reconnect",__func__); - if(app_bt_profile_reconnect_pending(id) != 0) - { - profile_reconnect_enable = true; - } + } else if (Info->p.remDev->discReason == 0x8) { + bt_profile_manager[id].reconnect_mode = + bt_profile_reconnect_reconnecting; + app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); + TRACE(1, "%s try to reconnect", __func__); + if (app_bt_profile_reconnect_pending(id) != 0) { + profile_reconnect_enable = true; + } #endif - } - else - { - bt_profile_manager[id].hsp_connect = bt_profile_connect_status_unknow; - } + } else { + bt_profile_manager[id].hsp_connect = bt_profile_connect_status_unknow; + } - if (profile_reconnect_enable) - { + if (profile_reconnect_enable) { #ifdef __IAG_BLE_INCLUDE__ - app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); + app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); #endif - osTimerStart(bt_profile_manager[id].connect_timer, APP_BT_PROFILE_RECONNECT_RETRY_INTERVAL_MS); - } - break; - default: - break; - } + osTimerStart(bt_profile_manager[id].connect_timer, + APP_BT_PROFILE_RECONNECT_RETRY_INTERVAL_MS); + } + break; + default: + break; + } + } + + if (bt_profile_manager[id].reconnect_mode == + bt_profile_reconnect_reconnecting) { + bool reconnect_hsp_proc_final = true; + bool reconnect_a2dp_proc_final = true; + if (bt_profile_manager[id].hsp_connect == + bt_profile_connect_status_failure) { + reconnect_hsp_proc_final = false; + } + if (bt_profile_manager[id].a2dp_connect == + bt_profile_connect_status_failure) { + reconnect_a2dp_proc_final = false; + } + if (reconnect_hsp_proc_final && reconnect_a2dp_proc_final) { + TRACE(3, "!!!reconnect success %d/%d/%d\n", + bt_profile_manager[id].hfp_connect, + bt_profile_manager[id].hsp_connect, + bt_profile_manager[id].a2dp_connect); + app_bt_restore_reconnecting_idle_mode(id); + // bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_null; + } + } else if (bt_profile_manager[id].reconnect_mode == + bt_profile_reconnect_openreconnecting) { + bool opening_hsp_proc_final = false; + bool opening_a2dp_proc_final = false; + + if (btdevice_plf_p->hsp_act && bt_profile_manager[id].hsp_connect == + bt_profile_connect_status_unknow) { + opening_hsp_proc_final = false; + } else { + opening_hsp_proc_final = true; } - if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_reconnecting) - { - bool reconnect_hsp_proc_final = true; - bool reconnect_a2dp_proc_final = true; - if (bt_profile_manager[id].hsp_connect == bt_profile_connect_status_failure) - { - reconnect_hsp_proc_final = false; - } - if (bt_profile_manager[id].a2dp_connect == bt_profile_connect_status_failure) - { - reconnect_a2dp_proc_final = false; - } - if (reconnect_hsp_proc_final && reconnect_a2dp_proc_final) - { - TRACE(3,"!!!reconnect success %d/%d/%d\n", bt_profile_manager[id].hfp_connect, bt_profile_manager[id].hsp_connect, bt_profile_manager[id].a2dp_connect); - app_bt_restore_reconnecting_idle_mode(id); - // bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_null; - } - } - else if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_openreconnecting) - { - bool opening_hsp_proc_final = false; - bool opening_a2dp_proc_final = false; - - if (btdevice_plf_p->hsp_act && bt_profile_manager[id].hsp_connect == bt_profile_connect_status_unknow) - { - opening_hsp_proc_final = false; - } - else - { - opening_hsp_proc_final = true; - } - - if (btdevice_plf_p->a2dp_act && bt_profile_manager[id].a2dp_connect == bt_profile_connect_status_unknow) - { - opening_a2dp_proc_final = false; - } - else - { - opening_a2dp_proc_final = true; - } - - if ((opening_hsp_proc_final && opening_a2dp_proc_final) || - (bt_profile_manager[id].hsp_connect == bt_profile_connect_status_failure)) - { - TRACE(3,"!!!reconnect success %d/%d/%d\n", bt_profile_manager[id].hfp_connect, bt_profile_manager[id].hsp_connect, bt_profile_manager[id].a2dp_connect); - app_bt_restore_reconnecting_idle_mode(id); - // bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_null; - } - - if (btdevice_plf_p->hsp_act && bt_profile_manager[id].hsp_connect == bt_profile_connect_status_success) - { - if (btdevice_plf_p->a2dp_act && !opening_a2dp_proc_final) - { - TRACE(0,"!!!continue connect a2dp\n"); - app_bt_precheck_before_starting_connecting(bt_profile_manager[id].has_connected); - app_bt_A2DP_OpenStream(bt_profile_manager[id].stream, &bt_profile_manager[id].rmt_addr); - } - } - - if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_null) - { - for (uint8_t i=0; istart reconnect second device\n"); - if ((btdevice_plf_p->hfp_act)&&(!bt_profile_manager[i].hfp_connect)) - { - TRACE(0,"try connect hf"); - app_bt_precheck_before_starting_connecting(bt_profile_manager[i].has_connected); - app_bt_HF_CreateServiceLink(bt_profile_manager[i].chan, &bt_profile_manager[i].rmt_addr); - } - else if ((btdevice_plf_p->hsp_act)&&(!bt_profile_manager[i].hsp_connect)) - { - TRACE(0,"try connect hs"); - app_bt_precheck_before_starting_connecting(bt_profile_manager[i].has_connected); - app_bt_HS_CreateServiceLink(bt_profile_manager[i].hs_chan, &bt_profile_manager[i].rmt_addr); - - } - else if((btdevice_plf_p->a2dp_act)&&(!bt_profile_manager[i].a2dp_connect)) - { - TRACE(0,"try connect a2dp"); - app_bt_precheck_before_starting_connecting(bt_profile_manager[i].has_connected); - app_bt_A2DP_OpenStream(bt_profile_manager[i].stream, &bt_profile_manager[i].rmt_addr); - } - break; - } - } - } + if (btdevice_plf_p->a2dp_act && bt_profile_manager[id].a2dp_connect == + bt_profile_connect_status_unknow) { + opening_a2dp_proc_final = false; + } else { + opening_a2dp_proc_final = true; } -#ifdef __IAG_BLE_INCLUDE__ - if (bt_profile_manager[id].hfp_connect == bt_profile_connect_status_success && - bt_profile_manager[id].hsp_connect == bt_profile_connect_status_success&& - bt_profile_manager[id].a2dp_connect == bt_profile_connect_status_success) - { - app_ble_force_switch_adv(BLE_SWITCH_USER_BT_CONNECT, true); + if ((opening_hsp_proc_final && opening_a2dp_proc_final) || + (bt_profile_manager[id].hsp_connect == + bt_profile_connect_status_failure)) { + TRACE(3, "!!!reconnect success %d/%d/%d\n", + bt_profile_manager[id].hfp_connect, + bt_profile_manager[id].hsp_connect, + bt_profile_manager[id].a2dp_connect); + app_bt_restore_reconnecting_idle_mode(id); + // bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_null; } + + if (btdevice_plf_p->hsp_act && bt_profile_manager[id].hsp_connect == + bt_profile_connect_status_success) { + if (btdevice_plf_p->a2dp_act && !opening_a2dp_proc_final) { + TRACE(0, "!!!continue connect a2dp\n"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[id].has_connected); + app_bt_A2DP_OpenStream(bt_profile_manager[id].stream, + &bt_profile_manager[id].rmt_addr); + } + } + + if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_null) { + for (uint8_t i = 0; i < BT_DEVICE_NUM; i++) { + if (bt_profile_manager[i].reconnect_mode == + bt_profile_reconnect_openreconnecting) { + TRACE(0, "!!!hs->start reconnect second device\n"); + if ((btdevice_plf_p->hfp_act) && + (!bt_profile_manager[i].hfp_connect)) { + TRACE(0, "try connect hf"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[i].has_connected); + app_bt_HF_CreateServiceLink(bt_profile_manager[i].chan, + &bt_profile_manager[i].rmt_addr); + } else if ((btdevice_plf_p->hsp_act) && + (!bt_profile_manager[i].hsp_connect)) { + TRACE(0, "try connect hs"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[i].has_connected); + app_bt_HS_CreateServiceLink(bt_profile_manager[i].hs_chan, + &bt_profile_manager[i].rmt_addr); + + } else if ((btdevice_plf_p->a2dp_act) && + (!bt_profile_manager[i].a2dp_connect)) { + TRACE(0, "try connect a2dp"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[i].has_connected); + app_bt_A2DP_OpenStream(bt_profile_manager[i].stream, + &bt_profile_manager[i].rmt_addr); + } + break; + } + } + } + } + +#ifdef __IAG_BLE_INCLUDE__ + if (bt_profile_manager[id].hfp_connect == bt_profile_connect_status_success && + bt_profile_manager[id].hsp_connect == bt_profile_connect_status_success && + bt_profile_manager[id].a2dp_connect == + bt_profile_connect_status_success) { + app_ble_force_switch_adv(BLE_SWITCH_USER_BT_CONNECT, true); + } #endif - if (!bt_profile_manager[id].has_connected && - (bt_profile_manager[id].hfp_connect == bt_profile_connect_status_success || - bt_profile_manager[id].hsp_connect == bt_profile_connect_status_success|| - bt_profile_manager[id].a2dp_connect == bt_profile_connect_status_success)) - { + if (!bt_profile_manager[id].has_connected && + (bt_profile_manager[id].hfp_connect == + bt_profile_connect_status_success || + bt_profile_manager[id].hsp_connect == + bt_profile_connect_status_success || + bt_profile_manager[id].a2dp_connect == + bt_profile_connect_status_success)) { - bt_profile_manager[id].has_connected = true; - TRACE(0,"BT connected!!!"); + bt_profile_manager[id].has_connected = true; + TRACE(0, "BT connected!!!"); #ifndef IBRT - btif_me_get_remote_device_name(&(ctx->remote_dev_bdaddr), app_bt_global_handle); + btif_me_get_remote_device_name(&(ctx->remote_dev_bdaddr), + app_bt_global_handle); #endif -#if defined(MEDIA_PLAYER_SUPPORT)&& !defined(IBRT) - app_voice_report(APP_STATUS_INDICATION_CONNECTED, id); +#if defined(MEDIA_PLAYER_SUPPORT) && !defined(IBRT) + app_voice_report(APP_STATUS_INDICATION_CONNECTED, id); #endif #ifdef __INTERCONNECTION__ - app_interconnection_start_disappear_adv(INTERCONNECTION_BLE_ADVERTISING_INTERVAL, - APP_INTERCONNECTION_DISAPPEAR_ADV_IN_MS); + app_interconnection_start_disappear_adv( + INTERCONNECTION_BLE_ADVERTISING_INTERVAL, + APP_INTERCONNECTION_DISAPPEAR_ADV_IN_MS); - if (btif_me_get_activeCons() <= 2) - { - app_interconnection_spp_open(btif_me_enumerate_remote_devices(id)); - } + if (btif_me_get_activeCons() <= 2) { + app_interconnection_spp_open(btif_me_enumerate_remote_devices(id)); + } #endif #ifdef __INTERACTION__ - // app_interaction_spp_open(); + // app_interaction_spp_open(); #endif - } + } - if (bt_profile_manager[id].has_connected && - (bt_profile_manager[id].hfp_connect != bt_profile_connect_status_success && - bt_profile_manager[id].hsp_connect != bt_profile_connect_status_success && - bt_profile_manager[id].a2dp_connect != bt_profile_connect_status_success)) - { + if (bt_profile_manager[id].has_connected && + (bt_profile_manager[id].hfp_connect != + bt_profile_connect_status_success && + bt_profile_manager[id].hsp_connect != + bt_profile_connect_status_success && + bt_profile_manager[id].a2dp_connect != + bt_profile_connect_status_success)) { - bt_profile_manager[id].has_connected = false; - TRACE(0,"BT disconnected!!!"); + bt_profile_manager[id].has_connected = false; + TRACE(0, "BT disconnected!!!"); #ifdef GFPS_ENABLED - if (app_gfps_is_last_response_pending()) - { - app_gfps_enter_connectable_mode_req_handler(app_gfps_get_last_response()); - } + if (app_gfps_is_last_response_pending()) { + app_gfps_enter_connectable_mode_req_handler(app_gfps_get_last_response()); + } #endif -#if defined(MEDIA_PLAYER_SUPPORT)&& !defined(IBRT) - app_voice_report(APP_STATUS_INDICATION_DISCONNECTED, id); +#if defined(MEDIA_PLAYER_SUPPORT) && !defined(IBRT) + app_voice_report(APP_STATUS_INDICATION_DISCONNECTED, id); #endif #ifdef __INTERCONNECTION__ - app_interconnection_disconnected_callback(); + app_interconnection_disconnected_callback(); #endif - app_set_disconnecting_all_bt_connections(false); - } + app_set_disconnecting_all_bt_connections(false); + } #ifdef __BT_ONE_BRING_TWO__ - app_bt_update_connectable_mode_after_connection_management(); + app_bt_update_connectable_mode_after_connection_management(); #endif } #endif -void hfp_reconnecting_timer_stop_callback(const btif_event_t *event) -{ - uint8_t i =0; - uint8_t id =BT_DEVICE_NUM; - bt_bdaddr_t *remote = NULL; - bt_bdaddr_t *hfp_remote = NULL; - remote = btif_me_get_callback_event_rem_dev_bd_addr(event); - if(remote != NULL){ - for(i = 0; ip.remDev->bdAddr.address); - btdevice_profile *btdevice_plf_p = (btdevice_profile *)app_bt_profile_active_store_ptr_get((uint8_t *)ctx->remote_dev_bdaddr.address); - bool profile_reconnect_enable = false; +// void app_bt_profile_connect_manager_hf(enum BT_DEVICE_ID_T id, HfChannel +// *Chan, HfCallbackParms *Info) +void app_bt_profile_connect_manager_hf(enum BT_DEVICE_ID_T id, + hf_chan_handle_t Chan, + struct hfp_context *ctx) { + static ibrt_ctrl_t *p_ibrt_ctrl = app_ibrt_if_get_bt_ctrl_ctx(); + // btdevice_profile *btdevice_plf_p = (btdevice_profile + // *)app_bt_profile_active_store_ptr_get((uint8_t + // *)Info->p.remDev->bdAddr.address); + btdevice_profile *btdevice_plf_p = + (btdevice_profile *)app_bt_profile_active_store_ptr_get( + (uint8_t *)ctx->remote_dev_bdaddr.address); + bool profile_reconnect_enable = false; - osTimerStop(bt_profile_manager[id].connect_timer); - bt_profile_manager[id].connect_timer_cb = NULL; - //if (Chan&&Info){ - if (Chan) - { - switch(ctx->event) - { - case BTIF_HF_EVENT_SERVICE_CONNECTED: - TRACE(1,"%s HF_EVENT_SERVICE_CONNECTED",__func__); - nv_record_btdevicerecord_set_hfp_profile_active_state(btdevice_plf_p, true); + osTimerStop(bt_profile_manager[id].connect_timer); + bt_profile_manager[id].connect_timer_cb = NULL; + // if (Chan&&Info){ + if (Chan) { + switch (ctx->event) { + case BTIF_HF_EVENT_SERVICE_CONNECTED: + TRACE(1, "%s HF_EVENT_SERVICE_CONNECTED", __func__); + nv_record_btdevicerecord_set_hfp_profile_active_state(btdevice_plf_p, + true); #ifndef FPGA - nv_record_touch_cause_flush(); + nv_record_touch_cause_flush(); #endif - bt_profile_manager[id].hfp_connect = bt_profile_connect_status_success; - bt_profile_manager[id].saved_reconnect_mode =bt_profile_reconnect_null; - bt_profile_manager[id].reconnect_cnt = 0; - bt_profile_manager[id].chan = app_bt_device.hf_channel[id]; - memcpy(bt_profile_manager[id].rmt_addr.address, ctx->remote_dev_bdaddr.address, BTIF_BD_ADDR_SIZE); - if (false == bt_profile_manager[id].has_connected) - { - app_bt_resume_sniff_mode(id); - } + bt_profile_manager[id].hfp_connect = bt_profile_connect_status_success; + bt_profile_manager[id].saved_reconnect_mode = bt_profile_reconnect_null; + bt_profile_manager[id].reconnect_cnt = 0; + bt_profile_manager[id].chan = app_bt_device.hf_channel[id]; + memcpy(bt_profile_manager[id].rmt_addr.address, + ctx->remote_dev_bdaddr.address, BTIF_BD_ADDR_SIZE); + if (false == bt_profile_manager[id].has_connected) { + app_bt_resume_sniff_mode(id); + } #ifdef BTIF_DIP_DEVICE - btif_dip_get_remote_info(app_bt_get_remoteDev(id)); + btif_dip_get_remote_info(app_bt_get_remoteDev(id)); #endif - if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_openreconnecting) - { - //do nothing - } + if (bt_profile_manager[id].reconnect_mode == + bt_profile_reconnect_openreconnecting) { + // do nothing + } #if defined(IBRT) - else if (app_bt_ibrt_reconnect_mobile_profile_flag_get()) - { - app_bt_ibrt_reconnect_mobile_profile_flag_clear(); + else if (app_bt_ibrt_reconnect_mobile_profile_flag_get()) { + app_bt_ibrt_reconnect_mobile_profile_flag_clear(); #else - else if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_reconnecting) - { + else if (bt_profile_manager[id].reconnect_mode == + bt_profile_reconnect_reconnecting) { #endif - TRACE(2,"app_bt: a2dp_act in NV =%d,a2dp_connect=%d",btdevice_plf_p->a2dp_act,bt_profile_manager[id].a2dp_connect); - if (btdevice_plf_p->a2dp_act && bt_profile_manager[id].a2dp_connect != bt_profile_connect_status_success) - { - TRACE(0,"!!!continue connect a2dp\n"); - app_bt_precheck_before_starting_connecting(bt_profile_manager[id].has_connected); - app_bt_A2DP_OpenStream(bt_profile_manager[id].stream, &bt_profile_manager[id].rmt_addr); - } - } + TRACE(2, "app_bt: a2dp_act in NV =%d,a2dp_connect=%d", + btdevice_plf_p->a2dp_act, bt_profile_manager[id].a2dp_connect); + if (btdevice_plf_p->a2dp_act && bt_profile_manager[id].a2dp_connect != + bt_profile_connect_status_success) { + TRACE(0, "!!!continue connect a2dp\n"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[id].has_connected); + app_bt_A2DP_OpenStream(bt_profile_manager[id].stream, + &bt_profile_manager[id].rmt_addr); + } + } #ifdef __AUTO_CONNECT_OTHER_PROFILE__ - else - { - //befor auto connect a2dp profile, check whether a2dp is supported - if (btdevice_plf_p->a2dp_act && bt_profile_manager[id].a2dp_connect != bt_profile_connect_status_success) - { - bt_profile_manager[id].connect_timer_cb = app_bt_profile_connect_a2dp_retry_timehandler; - app_bt_accessmode_set(BAM_CONNECTABLE_ONLY); - osTimerStart(bt_profile_manager[id].connect_timer, APP_BT_PROFILE_CONNECT_RETRY_MS); - } - } + else { + // befor auto connect a2dp profile, check whether a2dp is supported + if (btdevice_plf_p->a2dp_act && bt_profile_manager[id].a2dp_connect != + bt_profile_connect_status_success) { + bt_profile_manager[id].connect_timer_cb = + app_bt_profile_connect_a2dp_retry_timehandler; + app_bt_accessmode_set(BAM_CONNECTABLE_ONLY); + osTimerStart(bt_profile_manager[id].connect_timer, + APP_BT_PROFILE_CONNECT_RETRY_MS); + } + } #endif - break; - case BTIF_HF_EVENT_SERVICE_DISCONNECTED: - if(((ctx->disc_reason == 0)||(ctx->disc_reason == 19))&&(p_ibrt_ctrl->current_role != IBRT_SLAVE)) - { - once_event_case = 2; - startonce_delay_event_Timer_(1000); - } - //TRACE(3,"%s HF_EVENT_SERVICE_DISCONNECTED discReason:%d/%d",__func__, Info->p.remDev->discReason, Info->p.remDev->discReason_saved); - TRACE(3,"%s HF_EVENT_SERVICE_DISCONNECTED discReason:%d/%d",__func__, ctx->disc_reason, ctx->disc_reason_saved); - bt_profile_manager[id].hfp_connect = bt_profile_connect_status_failure; - if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_openreconnecting) - { - if (++bt_profile_manager[id].reconnect_cnt < APP_BT_PROFILE_OPENNING_RECONNECT_RETRY_LIMIT_CNT) - { - app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); - profile_reconnect_enable = true; - bt_profile_manager[id].hfp_connect = bt_profile_connect_status_unknow; - } - } - else if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_reconnecting) - { - if (++bt_profile_manager[id].reconnect_cnt < APP_BT_PROFILE_RECONNECT_RETRY_LIMIT_CNT) - { - app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); - profile_reconnect_enable = true; - } - else - { - app_bt_restore_reconnecting_idle_mode(id); - // bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_null; - } - TRACE(2,"%s try to reconnect cnt:%d",__func__, bt_profile_manager[id].reconnect_cnt); - /* - }else if ((Info->p.remDev->discReason == 0x8)|| - (Info->p.remDev->discReason_saved == 0x8)){ - */ - } + break; + case BTIF_HF_EVENT_SERVICE_DISCONNECTED: + if (((ctx->disc_reason == 0) || (ctx->disc_reason == 19)) && + (p_ibrt_ctrl->current_role != IBRT_SLAVE)) { + once_event_case = 2; + startonce_delay_event_Timer_(1000); + } + // TRACE(3,"%s HF_EVENT_SERVICE_DISCONNECTED discReason:%d/%d",__func__, + // Info->p.remDev->discReason, Info->p.remDev->discReason_saved); + TRACE(3, "%s HF_EVENT_SERVICE_DISCONNECTED discReason:%d/%d", __func__, + ctx->disc_reason, ctx->disc_reason_saved); + bt_profile_manager[id].hfp_connect = bt_profile_connect_status_failure; + if (bt_profile_manager[id].reconnect_mode == + bt_profile_reconnect_openreconnecting) { + if (++bt_profile_manager[id].reconnect_cnt < + APP_BT_PROFILE_OPENNING_RECONNECT_RETRY_LIMIT_CNT) { + app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); + profile_reconnect_enable = true; + bt_profile_manager[id].hfp_connect = bt_profile_connect_status_unknow; + } + } else if (bt_profile_manager[id].reconnect_mode == + bt_profile_reconnect_reconnecting) { + if (++bt_profile_manager[id].reconnect_cnt < + APP_BT_PROFILE_RECONNECT_RETRY_LIMIT_CNT) { + app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); + profile_reconnect_enable = true; + } else { + app_bt_restore_reconnecting_idle_mode(id); + // bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_null; + } + TRACE(2, "%s try to reconnect cnt:%d", __func__, + bt_profile_manager[id].reconnect_cnt); + /* + }else if ((Info->p.remDev->discReason == 0x8)|| + (Info->p.remDev->discReason_saved == 0x8)){ + */ + } #if !defined(IBRT) #if defined(ENHANCED_STACK) - else if ((ctx->disc_reason == 0x8)|| - (ctx->disc_reason_saved == 0x8) || - (ctx->disc_reason == 0x4)|| - (ctx->disc_reason_saved == 0x4)) + else if ((ctx->disc_reason == 0x8) || (ctx->disc_reason_saved == 0x8) || + (ctx->disc_reason == 0x4) || (ctx->disc_reason_saved == 0x4)) #else - else if ((ctx->disc_reason == 0x8)|| - (ctx->disc_reason_saved == 0x8) || - (ctx->disc_reason == 0x0)|| - (ctx->disc_reason_saved == 0x0)) + else if ((ctx->disc_reason == 0x8) || (ctx->disc_reason_saved == 0x8) || + (ctx->disc_reason == 0x0) || (ctx->disc_reason_saved == 0x0)) #endif - { - bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_reconnecting; - app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); - TRACE(2,"%s try to reconnect reason =%d",__func__,ctx->disc_reason); - if(app_bt_profile_reconnect_pending(id) != 0) - { - profile_reconnect_enable = true; - } - } -#endif - else - { - bt_profile_manager[id].hfp_connect = bt_profile_connect_status_unknow; - } - - if (profile_reconnect_enable) - { -#ifdef __IAG_BLE_INCLUDE__ - app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); -#endif - osTimerStart(bt_profile_manager[id].connect_timer, APP_BT_PROFILE_RECONNECT_RETRY_INTERVAL_MS); - } - break; - default: - break; + { + bt_profile_manager[id].reconnect_mode = + bt_profile_reconnect_reconnecting; + app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); + TRACE(2, "%s try to reconnect reason =%d", __func__, ctx->disc_reason); + if (app_bt_profile_reconnect_pending(id) != 0) { + profile_reconnect_enable = true; } + } +#endif + else { + bt_profile_manager[id].hfp_connect = bt_profile_connect_status_unknow; + } + + if (profile_reconnect_enable) { +#ifdef __IAG_BLE_INCLUDE__ + app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); +#endif + osTimerStart(bt_profile_manager[id].connect_timer, + APP_BT_PROFILE_RECONNECT_RETRY_INTERVAL_MS); + } + break; + default: + break; } - DUMP8("%02x ", &bt_profile_manager[id].rmt_addr.address, 6); - btdevice_profile *btdevice_plf_p1 = (btdevice_profile *)app_bt_profile_active_store_ptr_get((uint8_t *)&bt_profile_manager[id].rmt_addr.address); + } + DUMP8("%02x ", &bt_profile_manager[id].rmt_addr.address, 6); + btdevice_profile *btdevice_plf_p1 = + (btdevice_profile *)app_bt_profile_active_store_ptr_get( + (uint8_t *)&bt_profile_manager[id].rmt_addr.address); - if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_reconnecting) - { - bool reconnect_hfp_proc_final = false; - bool reconnect_a2dp_proc_final = false; + if (bt_profile_manager[id].reconnect_mode == + bt_profile_reconnect_reconnecting) { + bool reconnect_hfp_proc_final = false; + bool reconnect_a2dp_proc_final = false; - if (bt_profile_manager[id].hfp_connect != bt_profile_connect_status_success) - { - reconnect_hfp_proc_final = false; - } - else - { - reconnect_hfp_proc_final = true; - } - if (bt_profile_manager[id].a2dp_connect != bt_profile_connect_status_success) - { - if(btdevice_plf_p1->hfp_act && btdevice_plf_p1->a2dp_act) - { - reconnect_a2dp_proc_final = false; - } - else - { - reconnect_a2dp_proc_final = true; - } - } - if (reconnect_hfp_proc_final && reconnect_a2dp_proc_final) - { - TRACE(3,"!!!reconnect success %d/%d/%d\n", bt_profile_manager[id].hfp_connect, bt_profile_manager[id].hsp_connect, bt_profile_manager[id].a2dp_connect); - app_bt_restore_reconnecting_idle_mode(id); - // bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_null; - } + if (bt_profile_manager[id].hfp_connect != + bt_profile_connect_status_success) { + reconnect_hfp_proc_final = false; + } else { + reconnect_hfp_proc_final = true; } - else if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_openreconnecting) - { - bool opening_hfp_proc_final = false; - bool opening_a2dp_proc_final = false; + if (bt_profile_manager[id].a2dp_connect != + bt_profile_connect_status_success) { + if (btdevice_plf_p1->hfp_act && btdevice_plf_p1->a2dp_act) { + reconnect_a2dp_proc_final = false; + } else { + reconnect_a2dp_proc_final = true; + } + } + if (reconnect_hfp_proc_final && reconnect_a2dp_proc_final) { + TRACE(3, "!!!reconnect success %d/%d/%d\n", + bt_profile_manager[id].hfp_connect, + bt_profile_manager[id].hsp_connect, + bt_profile_manager[id].a2dp_connect); + app_bt_restore_reconnecting_idle_mode(id); + // bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_null; + } + } else if (bt_profile_manager[id].reconnect_mode == + bt_profile_reconnect_openreconnecting) { + bool opening_hfp_proc_final = false; + bool opening_a2dp_proc_final = false; - if (btdevice_plf_p1->hfp_act && bt_profile_manager[id].hfp_connect == bt_profile_connect_status_unknow) - { - opening_hfp_proc_final = false; - } - else - { - opening_hfp_proc_final = true; - } + if (btdevice_plf_p1->hfp_act && bt_profile_manager[id].hfp_connect == + bt_profile_connect_status_unknow) { + opening_hfp_proc_final = false; + } else { + opening_hfp_proc_final = true; + } - if (btdevice_plf_p1->a2dp_act && bt_profile_manager[id].a2dp_connect == bt_profile_connect_status_unknow) - { - opening_a2dp_proc_final = false; - } - else - { - opening_a2dp_proc_final = true; - } + if (btdevice_plf_p1->a2dp_act && bt_profile_manager[id].a2dp_connect == + bt_profile_connect_status_unknow) { + opening_a2dp_proc_final = false; + } else { + opening_a2dp_proc_final = true; + } - if(opening_hfp_proc_final && opening_a2dp_proc_final) - { - TRACE(3,"!!!reconnect success %d/%d/%d\n", bt_profile_manager[id].hfp_connect, bt_profile_manager[id].hsp_connect, bt_profile_manager[id].a2dp_connect); - bt_profile_manager[id].saved_reconnect_mode = bt_profile_reconnect_openreconnecting; - app_bt_restore_reconnecting_idle_mode(id); - } - else if(bt_profile_manager[id].hfp_connect == bt_profile_connect_status_failure) - { - TRACE(3,"reconnect_mode888:%d",bt_profile_manager[0].reconnect_mode); - TRACE(3,"!!!reconnect success %d/%d/%d\n", bt_profile_manager[id].hfp_connect, bt_profile_manager[id].hsp_connect, bt_profile_manager[id].a2dp_connect); - bt_profile_manager[id].saved_reconnect_mode = bt_profile_reconnect_openreconnecting; - if ((bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_openreconnecting) - &&(bt_profile_manager[id].reconnect_cnt >= APP_BT_PROFILE_OPENNING_RECONNECT_RETRY_LIMIT_CNT)) - { - app_bt_restore_reconnecting_idle_mode(id); - } - } + if (opening_hfp_proc_final && opening_a2dp_proc_final) { + TRACE(3, "!!!reconnect success %d/%d/%d\n", + bt_profile_manager[id].hfp_connect, + bt_profile_manager[id].hsp_connect, + bt_profile_manager[id].a2dp_connect); + bt_profile_manager[id].saved_reconnect_mode = + bt_profile_reconnect_openreconnecting; + app_bt_restore_reconnecting_idle_mode(id); + } else if (bt_profile_manager[id].hfp_connect == + bt_profile_connect_status_failure) { + TRACE(3, "reconnect_mode888:%d", bt_profile_manager[0].reconnect_mode); + TRACE(3, "!!!reconnect success %d/%d/%d\n", + bt_profile_manager[id].hfp_connect, + bt_profile_manager[id].hsp_connect, + bt_profile_manager[id].a2dp_connect); + bt_profile_manager[id].saved_reconnect_mode = + bt_profile_reconnect_openreconnecting; + if ((bt_profile_manager[id].reconnect_mode == + bt_profile_reconnect_openreconnecting) && + (bt_profile_manager[id].reconnect_cnt >= + APP_BT_PROFILE_OPENNING_RECONNECT_RETRY_LIMIT_CNT)) { + app_bt_restore_reconnecting_idle_mode(id); + } + } - if (btdevice_plf_p1->hfp_act && bt_profile_manager[id].hfp_connect == bt_profile_connect_status_success) - { - if (btdevice_plf_p1->a2dp_act && !opening_a2dp_proc_final) - { - TRACE(1,"!!!continue connect a2dp %p\n", bt_profile_manager[id].stream); - app_bt_precheck_before_starting_connecting(bt_profile_manager[id].has_connected); - app_bt_A2DP_OpenStream(bt_profile_manager[id].stream, &bt_profile_manager[id].rmt_addr); - } - } + if (btdevice_plf_p1->hfp_act && bt_profile_manager[id].hfp_connect == + bt_profile_connect_status_success) { + if (btdevice_plf_p1->a2dp_act && !opening_a2dp_proc_final) { + TRACE(1, "!!!continue connect a2dp %p\n", + bt_profile_manager[id].stream); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[id].has_connected); + app_bt_A2DP_OpenStream(bt_profile_manager[id].stream, + &bt_profile_manager[id].rmt_addr); + } + } - if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_null) - { - for (uint8_t i=0; istart reconnect second device\n"); - if ((btdevice_plf_p_temp->hfp_act)&&(!bt_profile_manager[i].hfp_connect)) - { - TRACE(0,"try connect hf"); - app_bt_precheck_before_starting_connecting(bt_profile_manager[id].has_connected); - app_bt_HF_CreateServiceLink(bt_profile_manager[i].chan, (bt_bdaddr_t *)&bt_profile_manager[i].rmt_addr); - } -#if defined (__HSP_ENABLE__) - else if((btdevice_plf_p_temp->hsp_act)&&(!bt_profile_manager[i].hsp_connect)) - { - TRACE(0,"try connect hs"); - app_bt_precheck_before_starting_connecting(bt_profile_manager[id].has_connected); - app_bt_HS_CreateServiceLink(bt_profile_manager[i].hs_chan, &bt_profile_manager[i].rmt_addr); - } + if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_null) { + for (uint8_t i = 0; i < BT_DEVICE_NUM; i++) { + btdevice_profile *btdevice_plf_p_temp = + (btdevice_profile *)app_bt_profile_active_store_ptr_get( + (uint8_t *)bt_profile_manager[i].rmt_addr.address); + TRACE(3, "reconnect_mode:%d", bt_profile_manager[i].reconnect_mode); + if (bt_profile_manager[i].reconnect_mode == + bt_profile_reconnect_openreconnecting) { + TRACE(0, "!!!hf->start reconnect second device\n"); + if ((btdevice_plf_p_temp->hfp_act) && + (!bt_profile_manager[i].hfp_connect)) { + TRACE(0, "try connect hf"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[id].has_connected); + app_bt_HF_CreateServiceLink( + bt_profile_manager[i].chan, + (bt_bdaddr_t *)&bt_profile_manager[i].rmt_addr); + } +#if defined(__HSP_ENABLE__) + else if ((btdevice_plf_p_temp->hsp_act) && + (!bt_profile_manager[i].hsp_connect)) { + TRACE(0, "try connect hs"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[id].has_connected); + app_bt_HS_CreateServiceLink(bt_profile_manager[i].hs_chan, + &bt_profile_manager[i].rmt_addr); + } #endif - else if((btdevice_plf_p_temp->a2dp_act)&&(!bt_profile_manager[i].a2dp_connect)) - { - TRACE(0,"try connect a2dp"); - app_bt_precheck_before_starting_connecting(bt_profile_manager[id].has_connected); - app_bt_A2DP_OpenStream(bt_profile_manager[i].stream, &bt_profile_manager[i].rmt_addr); - } - break; - } - } + else if ((btdevice_plf_p_temp->a2dp_act) && + (!bt_profile_manager[i].a2dp_connect)) { + TRACE(0, "try connect a2dp"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[id].has_connected); + app_bt_A2DP_OpenStream(bt_profile_manager[i].stream, + &bt_profile_manager[i].rmt_addr); + } + break; } + } } + } #ifdef __INTERCONNECTION__ - if (bt_profile_manager[id].hfp_connect == bt_profile_connect_status_success && - bt_profile_manager[id].a2dp_connect == bt_profile_connect_status_success) - { - app_interconnection_start_disappear_adv(INTERCONNECTION_BLE_ADVERTISING_INTERVAL, - APP_INTERCONNECTION_DISAPPEAR_ADV_IN_MS); + if (bt_profile_manager[id].hfp_connect == bt_profile_connect_status_success && + bt_profile_manager[id].a2dp_connect == + bt_profile_connect_status_success) { + app_interconnection_start_disappear_adv( + INTERCONNECTION_BLE_ADVERTISING_INTERVAL, + APP_INTERCONNECTION_DISAPPEAR_ADV_IN_MS); - if (btif_me_get_activeCons() <= 2) - { - app_interconnection_spp_open(btif_me_enumerate_remote_devices(id)); - } + if (btif_me_get_activeCons() <= 2) { + app_interconnection_spp_open(btif_me_enumerate_remote_devices(id)); } + } #endif -#ifdef __IAG_BLE_INCLUDE__ - TRACE(3, "%s hfp %d a2dp %d", __func__, bt_profile_manager[id].hfp_connect, bt_profile_manager[id].a2dp_connect); - if (bt_profile_manager[id].hfp_connect == bt_profile_connect_status_success && +#ifdef __IAG_BLE_INCLUDE__ + TRACE(3, "%s hfp %d a2dp %d", __func__, bt_profile_manager[id].hfp_connect, + bt_profile_manager[id].a2dp_connect); + if (bt_profile_manager[id].hfp_connect == bt_profile_connect_status_success && #ifdef __HSP_ENABLE__ - bt_profile_manager[id].hsp_connect == bt_profile_connect_status_success&& + bt_profile_manager[id].hsp_connect == bt_profile_connect_status_success && #endif - bt_profile_manager[id].a2dp_connect == bt_profile_connect_status_success) - { - app_ble_force_switch_adv(BLE_SWITCH_USER_BT_CONNECT, true); + bt_profile_manager[id].a2dp_connect == + bt_profile_connect_status_success) { + app_ble_force_switch_adv(BLE_SWITCH_USER_BT_CONNECT, true); + } +#endif + + if (!bt_profile_manager[id].has_connected && + (bt_profile_manager[id].hfp_connect == + bt_profile_connect_status_success || +#ifdef __HSP_ENABLE__ + bt_profile_manager[id].hsp_connect == + bt_profile_connect_status_success || +#endif + bt_profile_manager[id].a2dp_connect == + bt_profile_connect_status_success)) { + + bt_profile_manager[id].has_connected = true; + TRACE(0, "BT connected!!!"); + once_event_case = 1; + /*if(IsMobileLinkLossing){ + startonce_delay_event_Timer_(3000); } -#endif - - if (!bt_profile_manager[id].has_connected && - (bt_profile_manager[id].hfp_connect == bt_profile_connect_status_success || -#ifdef __HSP_ENABLE__ - bt_profile_manager[id].hsp_connect == bt_profile_connect_status_success|| -#endif - bt_profile_manager[id].a2dp_connect == bt_profile_connect_status_success)) - { - - bt_profile_manager[id].has_connected = true; - TRACE(0,"BT connected!!!"); - once_event_case = 1; - /*if(IsMobileLinkLossing){ - startonce_delay_event_Timer_(3000); - } - else{ - startonce_delay_event_Timer_(1500); - }*/ - app_voice_report(APP_STATUS_INDICATION_CONNECTED,0); - IsMobileLinkLossing = FALSE; + else{ + startonce_delay_event_Timer_(1500); + }*/ + app_voice_report(APP_STATUS_INDICATION_CONNECTED, 0); + IsMobileLinkLossing = FALSE; #ifndef IBRT - btif_me_get_remote_device_name(&(ctx->remote_dev_bdaddr), app_bt_global_handle); + btif_me_get_remote_device_name(&(ctx->remote_dev_bdaddr), + app_bt_global_handle); #endif -#if defined(MEDIA_PLAYER_SUPPORT)&& !defined(IBRT) - app_voice_report(APP_STATUS_INDICATION_CONNECTED, id); +#if defined(MEDIA_PLAYER_SUPPORT) && !defined(IBRT) + app_voice_report(APP_STATUS_INDICATION_CONNECTED, id); #endif #if 0 // #ifdef __INTERCONNECTION__ @@ -3238,404 +3167,423 @@ static ibrt_ctrl_t *p_ibrt_ctrl = app_ibrt_if_get_bt_ctrl_ctx(); #endif #ifdef __INTERACTION__ - // app_interaction_spp_open(); + // app_interaction_spp_open(); #endif - } + } - if (bt_profile_manager[id].has_connected && - (bt_profile_manager[id].hfp_connect != bt_profile_connect_status_success && + if (bt_profile_manager[id].has_connected && + (bt_profile_manager[id].hfp_connect != + bt_profile_connect_status_success && #ifdef __HSP_ENABLE__ - bt_profile_manager[id].hsp_connect != bt_profile_connect_status_success && + bt_profile_manager[id].hsp_connect != + bt_profile_connect_status_success && #endif - bt_profile_manager[id].a2dp_connect != bt_profile_connect_status_success)) - { + bt_profile_manager[id].a2dp_connect != + bt_profile_connect_status_success)) { - bt_profile_manager[id].has_connected = false; - TRACE(0,"BT disconnected!!!"); + bt_profile_manager[id].has_connected = false; + TRACE(0, "BT disconnected!!!"); #ifdef GFPS_ENABLED - if (app_gfps_is_last_response_pending()) - { - app_gfps_enter_connectable_mode_req_handler(app_gfps_get_last_response()); - } + if (app_gfps_is_last_response_pending()) { + app_gfps_enter_connectable_mode_req_handler(app_gfps_get_last_response()); + } #endif -#if defined(MEDIA_PLAYER_SUPPORT)&& !defined(IBRT) - app_voice_report(APP_STATUS_INDICATION_DISCONNECTED, id); +#if defined(MEDIA_PLAYER_SUPPORT) && !defined(IBRT) + app_voice_report(APP_STATUS_INDICATION_DISCONNECTED, id); #endif #ifdef __INTERCONNECTION__ - app_interconnection_disconnected_callback(); + app_interconnection_disconnected_callback(); #endif - app_set_disconnecting_all_bt_connections(false); - } + app_set_disconnecting_all_bt_connections(false); + } #ifdef __BT_ONE_BRING_TWO__ - app_bt_update_connectable_mode_after_connection_management(); + app_bt_update_connectable_mode_after_connection_management(); #endif } -void app_bt_profile_connect_manager_a2dp(enum BT_DEVICE_ID_T id, a2dp_stream_t *Stream, const a2dp_callback_parms_t *info) -{ - btdevice_profile *btdevice_plf_p = NULL; - btif_remote_device_t *remDev = NULL; - btif_a2dp_callback_parms_t* Info = (btif_a2dp_callback_parms_t*)info; - osTimerStop(bt_profile_manager[id].connect_timer); - bt_profile_manager[id].connect_timer_cb = NULL; - bool profile_reconnect_enable = false; +void app_bt_profile_connect_manager_a2dp(enum BT_DEVICE_ID_T id, + a2dp_stream_t *Stream, + const a2dp_callback_parms_t *info) { + btdevice_profile *btdevice_plf_p = NULL; + btif_remote_device_t *remDev = NULL; + btif_a2dp_callback_parms_t *Info = (btif_a2dp_callback_parms_t *)info; + osTimerStop(bt_profile_manager[id].connect_timer); + bt_profile_manager[id].connect_timer_cb = NULL; + bool profile_reconnect_enable = false; - remDev = btif_a2dp_get_stream_conn_remDev(Stream); - if (remDev) - { - btdevice_plf_p = (btdevice_profile *)app_bt_profile_active_store_ptr_get(btif_me_get_remote_device_bdaddr(remDev)->address); - } - else - { - btdevice_plf_p = (btdevice_profile *)app_bt_profile_active_store_ptr_get(NULL); - } + remDev = btif_a2dp_get_stream_conn_remDev(Stream); + if (remDev) { + btdevice_plf_p = (btdevice_profile *)app_bt_profile_active_store_ptr_get( + btif_me_get_remote_device_bdaddr(remDev)->address); + } else { + btdevice_plf_p = + (btdevice_profile *)app_bt_profile_active_store_ptr_get(NULL); + } - if (Stream&&Info) - { + if (Stream && Info) { - switch(Info->event) - { - case BTIF_A2DP_EVENT_STREAM_OPEN: - TRACE(4,"%s A2DP_EVENT_STREAM_OPEN,codec type=%x a2dp:%d mode:%d", - __func__, Info->p.configReq->codec.codecType, - bt_profile_manager[id].a2dp_connect, - bt_profile_manager[id].reconnect_mode); + switch (Info->event) { + case BTIF_A2DP_EVENT_STREAM_OPEN: + TRACE(4, "%s A2DP_EVENT_STREAM_OPEN,codec type=%x a2dp:%d mode:%d", + __func__, Info->p.configReq->codec.codecType, + bt_profile_manager[id].a2dp_connect, + bt_profile_manager[id].reconnect_mode); - nv_record_btdevicerecord_set_a2dp_profile_active_state(btdevice_plf_p, true); - nv_record_btdevicerecord_set_a2dp_profile_codec(btdevice_plf_p, Info->p.configReq->codec.codecType); + nv_record_btdevicerecord_set_a2dp_profile_active_state(btdevice_plf_p, + true); + nv_record_btdevicerecord_set_a2dp_profile_codec( + btdevice_plf_p, Info->p.configReq->codec.codecType); #ifndef FPGA - nv_record_touch_cause_flush(); + nv_record_touch_cause_flush(); #endif - if(bt_profile_manager[id].a2dp_connect == bt_profile_connect_status_success) - { - TRACE(0,"!!!a2dp has opened force return "); - return; - } - bt_profile_manager[id].a2dp_connect = bt_profile_connect_status_success; - bt_profile_manager[id].reconnect_cnt = 0; - bt_profile_manager[id].stream = app_bt_device.a2dp_connected_stream[id]; - memcpy(bt_profile_manager[id].rmt_addr.address, btif_me_get_remote_device_bdaddr(btif_a2dp_get_stream_conn_remDev(Stream))->address, BTIF_BD_ADDR_SIZE); - app_bt_record_latest_connected_service_device_id(id); - if (false == bt_profile_manager[id].has_connected) - { - app_bt_resume_sniff_mode(id); - } + if (bt_profile_manager[id].a2dp_connect == + bt_profile_connect_status_success) { + TRACE(0, "!!!a2dp has opened force return "); + return; + } + bt_profile_manager[id].a2dp_connect = bt_profile_connect_status_success; + bt_profile_manager[id].reconnect_cnt = 0; + bt_profile_manager[id].stream = app_bt_device.a2dp_connected_stream[id]; + memcpy(bt_profile_manager[id].rmt_addr.address, + btif_me_get_remote_device_bdaddr( + btif_a2dp_get_stream_conn_remDev(Stream)) + ->address, + BTIF_BD_ADDR_SIZE); + app_bt_record_latest_connected_service_device_id(id); + if (false == bt_profile_manager[id].has_connected) { + app_bt_resume_sniff_mode(id); + } #ifdef BTIF_DIP_DEVICE - btif_dip_get_remote_info(remDev); + btif_dip_get_remote_info(remDev); #endif - if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_openreconnecting) - { - //do nothing - } + if (bt_profile_manager[id].reconnect_mode == + bt_profile_reconnect_openreconnecting) { + // do nothing + } #if defined(IBRT) - else if (app_bt_ibrt_reconnect_mobile_profile_flag_get()) - { - app_bt_ibrt_reconnect_mobile_profile_flag_clear(); + else if (app_bt_ibrt_reconnect_mobile_profile_flag_get()) { + app_bt_ibrt_reconnect_mobile_profile_flag_clear(); #else - else if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_reconnecting) - { + else if (bt_profile_manager[id].reconnect_mode == + bt_profile_reconnect_reconnecting) { #endif - TRACE(2,"app_bt: hfp_act in NV =%d,a2dp_connect=%d",btdevice_plf_p->hfp_act,bt_profile_manager[id].hfp_connect); - if (btdevice_plf_p->hfp_act&& bt_profile_manager[id].hfp_connect != bt_profile_connect_status_success) - { - if (btif_hf_check_rfcomm_l2cap_channel_is_creating(&bt_profile_manager[id].rmt_addr)) - { - TRACE(0,"!!!remote is creating hfp after a2dp connected\n"); - } - else - { - TRACE(0,"!!!continue connect hfp\n"); - app_bt_precheck_before_starting_connecting(bt_profile_manager[id].has_connected); - app_bt_HF_CreateServiceLink(bt_profile_manager[id].chan, (bt_bdaddr_t *)&bt_profile_manager[id].rmt_addr); - } - } -#if defined (__HSP_ENABLE__) - else if(btdevice_plf_p->hsp_act&& bt_profile_manager[id].hsp_connect != bt_profile_connect_status_success) - { - TRACE(0,"!!!continue connect hsp\n"); - app_bt_precheck_before_starting_connecting(bt_profile_manager[id].has_connected); - app_bt_HS_CreateServiceLink(bt_profile_manager[id].hs_chan, &bt_profile_manager[id].rmt_addr); - } + TRACE(2, "app_bt: hfp_act in NV =%d,a2dp_connect=%d", + btdevice_plf_p->hfp_act, bt_profile_manager[id].hfp_connect); + if (btdevice_plf_p->hfp_act && bt_profile_manager[id].hfp_connect != + bt_profile_connect_status_success) { + if (btif_hf_check_rfcomm_l2cap_channel_is_creating( + &bt_profile_manager[id].rmt_addr)) { + TRACE(0, "!!!remote is creating hfp after a2dp connected\n"); + } else { + TRACE(0, "!!!continue connect hfp\n"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[id].has_connected); + app_bt_HF_CreateServiceLink( + bt_profile_manager[id].chan, + (bt_bdaddr_t *)&bt_profile_manager[id].rmt_addr); + } + } +#if defined(__HSP_ENABLE__) + else if (btdevice_plf_p->hsp_act && + bt_profile_manager[id].hsp_connect != + bt_profile_connect_status_success) { + TRACE(0, "!!!continue connect hsp\n"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[id].has_connected); + app_bt_HS_CreateServiceLink(bt_profile_manager[id].hs_chan, + &bt_profile_manager[id].rmt_addr); + } #endif - } + } #ifdef __AUTO_CONNECT_OTHER_PROFILE__ - else - { - if(btdevice_plf_p->hfp_act && bt_profile_manager[id].hfp_connect != bt_profile_connect_status_success) - { - bt_profile_manager[id].connect_timer_cb = app_bt_profile_connect_hf_retry_timehandler; - app_bt_accessmode_set(BAM_CONNECTABLE_ONLY); - osTimerStart(bt_profile_manager[id].connect_timer, APP_BT_PROFILE_CONNECT_RETRY_MS); - } -#if defined (__HSP_ENABLE__) - else if(btdevice_plf_p->hsp_act && bt_profile_manager[id].hsp_connect != bt_profile_connect_status_success) - { - bt_profile_manager[id].connect_timer_cb = app_bt_profile_connect_hs_retry_timehandler; - app_bt_accessmode_set(BAM_CONNECTABLE_ONLY); - osTimerStart(bt_profile_manager[id].connect_timer, APP_BT_PROFILE_CONNECT_RETRY_MS); - } + else { + if (btdevice_plf_p->hfp_act && bt_profile_manager[id].hfp_connect != + bt_profile_connect_status_success) { + bt_profile_manager[id].connect_timer_cb = + app_bt_profile_connect_hf_retry_timehandler; + app_bt_accessmode_set(BAM_CONNECTABLE_ONLY); + osTimerStart(bt_profile_manager[id].connect_timer, + APP_BT_PROFILE_CONNECT_RETRY_MS); + } +#if defined(__HSP_ENABLE__) + else if (btdevice_plf_p->hsp_act && + bt_profile_manager[id].hsp_connect != + bt_profile_connect_status_success) { + bt_profile_manager[id].connect_timer_cb = + app_bt_profile_connect_hs_retry_timehandler; + app_bt_accessmode_set(BAM_CONNECTABLE_ONLY); + osTimerStart(bt_profile_manager[id].connect_timer, + APP_BT_PROFILE_CONNECT_RETRY_MS); + } #endif - } + } #endif #ifdef APP_DISABLE_PAGE_SCAN_AFTER_CONN - disable_page_scan_check_timer_start(); + disable_page_scan_check_timer_start(); #endif - break; - case BTIF_A2DP_EVENT_STREAM_CLOSED: + break; + case BTIF_A2DP_EVENT_STREAM_CLOSED: - TRACE(2,"%s A2DP_EVENT_STREAM_CLOSED discReason1:%d",__func__, Info->discReason); + TRACE(2, "%s A2DP_EVENT_STREAM_CLOSED discReason1:%d", __func__, + Info->discReason); - if(Info->subevt != A2DP_CONN_CLOSED) - { - TRACE(0,"do not need set access mode"); - return ; - } + if (Info->subevt != A2DP_CONN_CLOSED) { + TRACE(0, "do not need set access mode"); + return; + } - if(Stream!=NULL) - { - if(btif_a2dp_get_remote_device(Stream)!=NULL) - TRACE(2,"%s A2DP_EVENT_STREAM_CLOSED discReason2:%d",__func__,btif_me_get_remote_device_disc_reason_saved(btif_a2dp_get_remote_device(Stream))); - } + if (Stream != NULL) { + if (btif_a2dp_get_remote_device(Stream) != NULL) + TRACE(2, "%s A2DP_EVENT_STREAM_CLOSED discReason2:%d", __func__, + btif_me_get_remote_device_disc_reason_saved( + btif_a2dp_get_remote_device(Stream))); + } #if defined(IBRT) - if (app_bt_ibrt_reconnect_mobile_profile_flag_get()) - { - app_bt_HF_CreateServiceLink(bt_profile_manager[id].chan, (bt_bdaddr_t *)&bt_profile_manager[id].rmt_addr); - } + if (app_bt_ibrt_reconnect_mobile_profile_flag_get()) { + app_bt_HF_CreateServiceLink( + bt_profile_manager[id].chan, + (bt_bdaddr_t *)&bt_profile_manager[id].rmt_addr); + } #endif - bt_profile_manager[id].a2dp_connect = bt_profile_connect_status_failure; + bt_profile_manager[id].a2dp_connect = bt_profile_connect_status_failure; - if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_openreconnecting) - { - if (++bt_profile_manager[id].reconnect_cnt < APP_BT_PROFILE_OPENNING_RECONNECT_RETRY_LIMIT_CNT) - { - app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); - profile_reconnect_enable = true; - bt_profile_manager[id].a2dp_connect = bt_profile_connect_status_unknow; - } - } - else if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_reconnecting) - { - if (++bt_profile_manager[id].reconnect_cnt < APP_BT_PROFILE_RECONNECT_RETRY_LIMIT_CNT) - { - app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); - profile_reconnect_enable = true; - } - else - { - app_bt_restore_reconnecting_idle_mode(id); - // bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_null; - } - TRACE(2,"%s try to reconnect cnt:%d",__func__, bt_profile_manager[id].reconnect_cnt); - } + if (bt_profile_manager[id].reconnect_mode == + bt_profile_reconnect_openreconnecting) { + if (++bt_profile_manager[id].reconnect_cnt < + APP_BT_PROFILE_OPENNING_RECONNECT_RETRY_LIMIT_CNT) { + app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); + profile_reconnect_enable = true; + bt_profile_manager[id].a2dp_connect = + bt_profile_connect_status_unknow; + } + } else if (bt_profile_manager[id].reconnect_mode == + bt_profile_reconnect_reconnecting) { + if (++bt_profile_manager[id].reconnect_cnt < + APP_BT_PROFILE_RECONNECT_RETRY_LIMIT_CNT) { + app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); + profile_reconnect_enable = true; + } else { + app_bt_restore_reconnecting_idle_mode(id); + // bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_null; + } + TRACE(2, "%s try to reconnect cnt:%d", __func__, + bt_profile_manager[id].reconnect_cnt); + } #if !defined(IBRT) #if defined(ENHANCED_STACK) - else if(((Info->discReason == 0x08)|| - (Info->discReason == 0x04)) && + else if (((Info->discReason == 0x08) || (Info->discReason == 0x04)) && #else - else if(((Info->discReason == 0x8)|| - (Info->discReason_saved == 0x8)|| - (Info->discReason_saved == 0x0)) && + else if (((Info->discReason == 0x8) || (Info->discReason_saved == 0x8) || + (Info->discReason_saved == 0x0)) && #endif - (btdevice_plf_p->a2dp_act)&& - (!btdevice_plf_p->hfp_act) && - (!btdevice_plf_p->hsp_act)) - { - bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_reconnecting; - TRACE(2,"%s try to reconnect cnt:%d",__func__, bt_profile_manager[id].reconnect_cnt); - app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); - if(app_bt_profile_reconnect_pending(id) != 0) - { - profile_reconnect_enable = true; - } - } + (btdevice_plf_p->a2dp_act) && (!btdevice_plf_p->hfp_act) && + (!btdevice_plf_p->hsp_act)) { + bt_profile_manager[id].reconnect_mode = + bt_profile_reconnect_reconnecting; + TRACE(2, "%s try to reconnect cnt:%d", __func__, + bt_profile_manager[id].reconnect_cnt); + app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); + if (app_bt_profile_reconnect_pending(id) != 0) { + profile_reconnect_enable = true; + } + } #endif - else - { - bt_profile_manager[id].a2dp_connect = bt_profile_connect_status_unknow; - } + else { + bt_profile_manager[id].a2dp_connect = bt_profile_connect_status_unknow; + } - if (profile_reconnect_enable) - { + if (profile_reconnect_enable) { #ifdef __IAG_BLE_INCLUDE__ - app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); + app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); #endif - osTimerStart(bt_profile_manager[id].connect_timer, APP_BT_PROFILE_RECONNECT_RETRY_INTERVAL_MS); - } - break; - default: - break; - } + osTimerStart(bt_profile_manager[id].connect_timer, + APP_BT_PROFILE_RECONNECT_RETRY_INTERVAL_MS); + } + break; + default: + break; } + } - if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_reconnecting) + if (bt_profile_manager[id].reconnect_mode == + bt_profile_reconnect_reconnecting) { + bool reconnect_hfp_proc_final = true; + bool reconnect_a2dp_proc_final = true; + if (bt_profile_manager[id].hfp_connect == + bt_profile_connect_status_failure) { + reconnect_hfp_proc_final = false; + } +#if defined(__HSP_ENABLE__) + if (btdevice_plf_p->hsp_act != 0) // has HSP { - bool reconnect_hfp_proc_final = true; - bool reconnect_a2dp_proc_final = true; - if (bt_profile_manager[id].hfp_connect == bt_profile_connect_status_failure) - { - reconnect_hfp_proc_final = false; - } -#if defined (__HSP_ENABLE__) - if(btdevice_plf_p->hsp_act !=0) //has HSP - { - reconnect_hfp_proc_final = true; - if (bt_profile_manager[id].hsp_connect == bt_profile_connect_status_failure) - { - reconnect_hfp_proc_final = false; - } - } -#endif - if (bt_profile_manager[id].a2dp_connect == bt_profile_connect_status_failure) - { - reconnect_a2dp_proc_final = false; - } - if (reconnect_hfp_proc_final && reconnect_a2dp_proc_final) - { - TRACE(3,"!!!reconnect success %d/%d/%d\n", bt_profile_manager[id].hfp_connect, bt_profile_manager[id].hsp_connect, bt_profile_manager[id].a2dp_connect); - app_bt_restore_reconnecting_idle_mode(id); - // bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_null; - } + reconnect_hfp_proc_final = true; + if (bt_profile_manager[id].hsp_connect == + bt_profile_connect_status_failure) { + reconnect_hfp_proc_final = false; + } } - else if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_openreconnecting) - { - bool opening_hfp_proc_final = false; - bool opening_a2dp_proc_final = false; - - if (btdevice_plf_p->hfp_act && bt_profile_manager[id].hfp_connect == bt_profile_connect_status_unknow) - { - opening_hfp_proc_final = false; - } - else - { - opening_hfp_proc_final = true; - } - - if (btdevice_plf_p->a2dp_act && bt_profile_manager[id].a2dp_connect == bt_profile_connect_status_unknow) - { - opening_a2dp_proc_final = false; - } - else - { - opening_a2dp_proc_final = true; - } - - if ((opening_hfp_proc_final && opening_a2dp_proc_final) || - (bt_profile_manager[id].a2dp_connect == bt_profile_connect_status_failure)) - { - TRACE(3,"!!!reconnect success %d/%d/%d\n", bt_profile_manager[id].hfp_connect, bt_profile_manager[id].hsp_connect, bt_profile_manager[id].a2dp_connect); - app_bt_restore_reconnecting_idle_mode(id); - // bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_null; - } - - if (btdevice_plf_p->a2dp_act && bt_profile_manager[id].a2dp_connect== bt_profile_connect_status_success) - { - if (btdevice_plf_p->hfp_act && !opening_hfp_proc_final) - { - if (btif_hf_check_rfcomm_l2cap_channel_is_creating(&bt_profile_manager[id].rmt_addr)) - { - TRACE(0,"!!!remote is creating hf after a2dp connected\n"); - } - else - { - TRACE(0,"!!!continue connect hf\n"); - app_bt_precheck_before_starting_connecting(bt_profile_manager[id].has_connected); - app_bt_HF_CreateServiceLink(bt_profile_manager[id].chan, (bt_bdaddr_t *)&bt_profile_manager[id].rmt_addr); - } - } -#if defined (__HSP_ENABLE) - else if(btdevice_plf_p->hsp_act && !opening_hfp_hsp_proc_final) - { - TRACE(0,"!!!continue connect hs\n"); - app_bt_precheck_before_starting_connecting(bt_profile_manager[id].has_connected); - app_bt_HS_CreateServiceLink(bt_profile_manager[id].hs_chan, &bt_profile_manager[id].rmt_addr); - } #endif - } - - if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_null) - { - for (uint8_t i=0; istart reconnect device %d\n", i); - if ((btdevice_plf_p->hfp_act)&&(!bt_profile_manager[i].hfp_connect)) - { - TRACE(0,"try connect hf"); - app_bt_precheck_before_starting_connecting(bt_profile_manager[i].has_connected); - app_bt_HF_CreateServiceLink(bt_profile_manager[i].chan, (bt_bdaddr_t *)&bt_profile_manager[i].rmt_addr); - } -#if defined (__HSP_ENABLE__) - else if((btdevice_plf_p->hsp_act)&&(!bt_profile_manager[i].hsp_connect)) - { - TRACE(0,"try connect hs"); - app_bt_precheck_before_starting_connecting(bt_profile_manager[i].has_connected); - app_bt_HS_CreateServiceLink(bt_profile_manager[i].hs_chan, &bt_profile_manager[i].rmt_addr); - } -#endif - else if((btdevice_plf_p->a2dp_act)&&(!bt_profile_manager[i].a2dp_connect)) - { - TRACE(0,"try connect a2dp"); - app_bt_precheck_before_starting_connecting(bt_profile_manager[i].has_connected); - app_bt_A2DP_OpenStream(bt_profile_manager[i].stream, &bt_profile_manager[i].rmt_addr); - } - break; - } - } - } + if (bt_profile_manager[id].a2dp_connect == + bt_profile_connect_status_failure) { + reconnect_a2dp_proc_final = false; } + if (reconnect_hfp_proc_final && reconnect_a2dp_proc_final) { + TRACE(3, "!!!reconnect success %d/%d/%d\n", + bt_profile_manager[id].hfp_connect, + bt_profile_manager[id].hsp_connect, + bt_profile_manager[id].a2dp_connect); + app_bt_restore_reconnecting_idle_mode(id); + // bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_null; + } + } else if (bt_profile_manager[id].reconnect_mode == + bt_profile_reconnect_openreconnecting) { + bool opening_hfp_proc_final = false; + bool opening_a2dp_proc_final = false; + + if (btdevice_plf_p->hfp_act && bt_profile_manager[id].hfp_connect == + bt_profile_connect_status_unknow) { + opening_hfp_proc_final = false; + } else { + opening_hfp_proc_final = true; + } + + if (btdevice_plf_p->a2dp_act && bt_profile_manager[id].a2dp_connect == + bt_profile_connect_status_unknow) { + opening_a2dp_proc_final = false; + } else { + opening_a2dp_proc_final = true; + } + + if ((opening_hfp_proc_final && opening_a2dp_proc_final) || + (bt_profile_manager[id].a2dp_connect == + bt_profile_connect_status_failure)) { + TRACE(3, "!!!reconnect success %d/%d/%d\n", + bt_profile_manager[id].hfp_connect, + bt_profile_manager[id].hsp_connect, + bt_profile_manager[id].a2dp_connect); + app_bt_restore_reconnecting_idle_mode(id); + // bt_profile_manager[id].reconnect_mode = bt_profile_reconnect_null; + } + + if (btdevice_plf_p->a2dp_act && bt_profile_manager[id].a2dp_connect == + bt_profile_connect_status_success) { + if (btdevice_plf_p->hfp_act && !opening_hfp_proc_final) { + if (btif_hf_check_rfcomm_l2cap_channel_is_creating( + &bt_profile_manager[id].rmt_addr)) { + TRACE(0, "!!!remote is creating hf after a2dp connected\n"); + } else { + TRACE(0, "!!!continue connect hf\n"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[id].has_connected); + app_bt_HF_CreateServiceLink( + bt_profile_manager[id].chan, + (bt_bdaddr_t *)&bt_profile_manager[id].rmt_addr); + } + } +#if defined(__HSP_ENABLE) + else if (btdevice_plf_p->hsp_act && !opening_hfp_hsp_proc_final) { + TRACE(0, "!!!continue connect hs\n"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[id].has_connected); + app_bt_HS_CreateServiceLink(bt_profile_manager[id].hs_chan, + &bt_profile_manager[id].rmt_addr); + } +#endif + } + + if (bt_profile_manager[id].reconnect_mode == bt_profile_reconnect_null) { + for (uint8_t i = 0; i < BT_DEVICE_NUM; i++) { + if (bt_profile_manager[i].reconnect_mode == + bt_profile_reconnect_openreconnecting) { + TRACE(1, "!!!a2dp->start reconnect device %d\n", i); + if ((btdevice_plf_p->hfp_act) && + (!bt_profile_manager[i].hfp_connect)) { + TRACE(0, "try connect hf"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[i].has_connected); + app_bt_HF_CreateServiceLink( + bt_profile_manager[i].chan, + (bt_bdaddr_t *)&bt_profile_manager[i].rmt_addr); + } +#if defined(__HSP_ENABLE__) + else if ((btdevice_plf_p->hsp_act) && + (!bt_profile_manager[i].hsp_connect)) { + TRACE(0, "try connect hs"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[i].has_connected); + app_bt_HS_CreateServiceLink(bt_profile_manager[i].hs_chan, + &bt_profile_manager[i].rmt_addr); + } +#endif + else if ((btdevice_plf_p->a2dp_act) && + (!bt_profile_manager[i].a2dp_connect)) { + TRACE(0, "try connect a2dp"); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[i].has_connected); + app_bt_A2DP_OpenStream(bt_profile_manager[i].stream, + &bt_profile_manager[i].rmt_addr); + } + break; + } + } + } + } #ifdef __INTERCONNECTION__ - if (bt_profile_manager[id].hfp_connect == bt_profile_connect_status_success && - bt_profile_manager[id].a2dp_connect == bt_profile_connect_status_success) - { - app_interconnection_start_disappear_adv(INTERCONNECTION_BLE_ADVERTISING_INTERVAL, - APP_INTERCONNECTION_DISAPPEAR_ADV_IN_MS); + if (bt_profile_manager[id].hfp_connect == bt_profile_connect_status_success && + bt_profile_manager[id].a2dp_connect == + bt_profile_connect_status_success) { + app_interconnection_start_disappear_adv( + INTERCONNECTION_BLE_ADVERTISING_INTERVAL, + APP_INTERCONNECTION_DISAPPEAR_ADV_IN_MS); - if (btif_me_get_activeCons() <= 2) - { - app_interconnection_spp_open(remDev); - } + if (btif_me_get_activeCons() <= 2) { + app_interconnection_spp_open(remDev); } + } #endif -#ifdef __IAG_BLE_INCLUDE__ - TRACE(3, "%s hfp %d a2dp %d", __func__, bt_profile_manager[id].hfp_connect, bt_profile_manager[id].a2dp_connect); - if (bt_profile_manager[id].hfp_connect == bt_profile_connect_status_success && +#ifdef __IAG_BLE_INCLUDE__ + TRACE(3, "%s hfp %d a2dp %d", __func__, bt_profile_manager[id].hfp_connect, + bt_profile_manager[id].a2dp_connect); + if (bt_profile_manager[id].hfp_connect == bt_profile_connect_status_success && #ifdef __HSP_ENABLE__ - bt_profile_manager[id].hsp_connect == bt_profile_connect_status_success && + bt_profile_manager[id].hsp_connect == bt_profile_connect_status_success && #endif - bt_profile_manager[id].a2dp_connect == bt_profile_connect_status_success) - { - app_ble_force_switch_adv(BLE_SWITCH_USER_BT_CONNECT, true); - } + bt_profile_manager[id].a2dp_connect == + bt_profile_connect_status_success) { + app_ble_force_switch_adv(BLE_SWITCH_USER_BT_CONNECT, true); + } #endif - if (!bt_profile_manager[id].has_connected && - (bt_profile_manager[id].hfp_connect == bt_profile_connect_status_success || + if (!bt_profile_manager[id].has_connected && + (bt_profile_manager[id].hfp_connect == + bt_profile_connect_status_success || #ifdef __HSP_ENABLE__ - bt_profile_manager[id].hsp_connect == bt_profile_connect_status_success|| + bt_profile_manager[id].hsp_connect == + bt_profile_connect_status_success || #endif - bt_profile_manager[id].a2dp_connect == bt_profile_connect_status_success)) - { + bt_profile_manager[id].a2dp_connect == + bt_profile_connect_status_success)) { - bt_profile_manager[id].has_connected = true; - TRACE(0,"BT connected!!!"); - IsMobileLinkLossing = FALSE; + bt_profile_manager[id].has_connected = true; + TRACE(0, "BT connected!!!"); + IsMobileLinkLossing = FALSE; #ifndef IBRT - btif_me_get_remote_device_name(&(bt_profile_manager[id].rmt_addr), app_bt_global_handle); + btif_me_get_remote_device_name(&(bt_profile_manager[id].rmt_addr), + app_bt_global_handle); #endif -#if defined(MEDIA_PLAYER_SUPPORT)//&& !defined(IBRT) - app_voice_report(APP_STATUS_INDICATION_CONNECTED, id); +#if defined(MEDIA_PLAYER_SUPPORT) //&& !defined(IBRT) + app_voice_report(APP_STATUS_INDICATION_CONNECTED, id); #endif #if 0 // #ifdef __INTERCONNECTION__ @@ -3644,40 +3592,41 @@ void app_bt_profile_connect_manager_a2dp(enum BT_DEVICE_ID_T id, a2dp_stream_t * #endif #ifdef __INTERACTION__ - // app_interaction_spp_open(); + // app_interaction_spp_open(); #endif - } + } - if (bt_profile_manager[id].has_connected && - (bt_profile_manager[id].hfp_connect != bt_profile_connect_status_success && + if (bt_profile_manager[id].has_connected && + (bt_profile_manager[id].hfp_connect != + bt_profile_connect_status_success && #ifdef __HSP_ENABLE__ - bt_profile_manager[id].hsp_connect != bt_profile_connect_status_success && + bt_profile_manager[id].hsp_connect != + bt_profile_connect_status_success && #endif - bt_profile_manager[id].a2dp_connect != bt_profile_connect_status_success)) - { + bt_profile_manager[id].a2dp_connect != + bt_profile_connect_status_success)) { - bt_profile_manager[id].has_connected = false; - TRACE(0,"BT disconnected!!!"); + bt_profile_manager[id].has_connected = false; + TRACE(0, "BT disconnected!!!"); #ifdef GFPS_ENABLED - if (app_gfps_is_last_response_pending()) - { - app_gfps_enter_connectable_mode_req_handler(app_gfps_get_last_response()); - } + if (app_gfps_is_last_response_pending()) { + app_gfps_enter_connectable_mode_req_handler(app_gfps_get_last_response()); + } #endif -#if defined(MEDIA_PLAYER_SUPPORT)&& !defined(IBRT) - app_voice_report(APP_STATUS_INDICATION_DISCONNECTED, id); +#if defined(MEDIA_PLAYER_SUPPORT) && !defined(IBRT) + app_voice_report(APP_STATUS_INDICATION_DISCONNECTED, id); #endif #ifdef __INTERCONNECTION__ - app_interconnection_disconnected_callback(); + app_interconnection_disconnected_callback(); #endif - app_set_disconnecting_all_bt_connections(false); - } + app_set_disconnecting_all_bt_connections(false); + } #ifdef __BT_ONE_BRING_TWO__ - app_bt_update_connectable_mode_after_connection_management(); + app_bt_update_connectable_mode_after_connection_management(); #endif } @@ -3687,254 +3636,286 @@ void hid_exit_shutter_mode(void); static bool isDisconnectAllBtConnections = false; -bool app_is_disconnecting_all_bt_connections(void) -{ - return isDisconnectAllBtConnections; +bool app_is_disconnecting_all_bt_connections(void) { + return isDisconnectAllBtConnections; } -void app_set_disconnecting_all_bt_connections(bool isEnable) -{ - isDisconnectAllBtConnections = isEnable; +void app_set_disconnecting_all_bt_connections(bool isEnable) { + isDisconnectAllBtConnections = isEnable; } -bt_status_t LinkDisconnectDirectly(bool PowerOffFlag) -{ - app_set_disconnecting_all_bt_connections(true); - //TRACE(1,"osapi_lock_is_exist:%d",osapi_lock_is_exist()); - if(osapi_lock_is_exist()) - osapi_lock_stack(); +bt_status_t LinkDisconnectDirectly(bool PowerOffFlag) { + app_set_disconnecting_all_bt_connections(true); + // TRACE(1,"osapi_lock_is_exist:%d",osapi_lock_is_exist()); + if (osapi_lock_is_exist()) + osapi_lock_stack(); #ifdef __IAG_BLE_INCLUDE__ - TRACE(1,"ble_connected_state:%d", app_ble_is_any_connection_exist()); + TRACE(1, "ble_connected_state:%d", app_ble_is_any_connection_exist()); #endif #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if(true==PowerOffFlag) - p_ibrt_ctrl->ibrt_in_poweroff= true; + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (true == PowerOffFlag) + p_ibrt_ctrl->ibrt_in_poweroff = true; - if (p_ibrt_ctrl->init_done) - { - if(IBRT_MASTER==p_ibrt_ctrl->current_role) - { - if(app_tws_ibrt_mobile_link_connected()) - { - //should check return status - app_tws_ibrt_disconnect_connection(btif_me_get_remote_device_by_handle(p_ibrt_ctrl->mobile_conhandle)); - } - } - if (app_tws_ibrt_tws_link_connected()) - { - app_tws_ibrt_disconnect_connection(btif_me_get_remote_device_by_handle(p_ibrt_ctrl->tws_conhandle)); - } + if (p_ibrt_ctrl->init_done) { + if (IBRT_MASTER == p_ibrt_ctrl->current_role) { + if (app_tws_ibrt_mobile_link_connected()) { + // should check return status + app_tws_ibrt_disconnect_connection( + btif_me_get_remote_device_by_handle(p_ibrt_ctrl->mobile_conhandle)); + } } + if (app_tws_ibrt_tws_link_connected()) { + app_tws_ibrt_disconnect_connection( + btif_me_get_remote_device_by_handle(p_ibrt_ctrl->tws_conhandle)); + } + } - if(osapi_lock_is_exist()) - osapi_unlock_stack(); + if (osapi_lock_is_exist()) + osapi_unlock_stack(); - osDelay(500); + osDelay(500); - return BT_STS_SUCCESS; + return BT_STS_SUCCESS; #endif - TRACE(1,"activeCons:%d", btif_me_get_activeCons()); + TRACE(1, "activeCons:%d", btif_me_get_activeCons()); - uint8_t Tmp_activeCons = btif_me_get_activeCons(); + uint8_t Tmp_activeCons = btif_me_get_activeCons(); - if(Tmp_activeCons) - { - //TRACE(3,"%s id1 hf:%d a2dp:%d",__func__, app_bt_device.hf_channel[BT_DEVICE_ID_1].state, btif_a2dp_get_stream_state(app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream)); - TRACE(3,"%s id1 hf:%d a2dp:%d",__func__, btif_get_hf_chan_state(app_bt_device.hf_channel[BT_DEVICE_ID_1]), btif_a2dp_get_stream_state(app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream)); + if (Tmp_activeCons) { + // TRACE(3,"%s id1 hf:%d a2dp:%d",__func__, + // app_bt_device.hf_channel[BT_DEVICE_ID_1].state, + // btif_a2dp_get_stream_state(app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream)); + TRACE(3, "%s id1 hf:%d a2dp:%d", __func__, + btif_get_hf_chan_state(app_bt_device.hf_channel[BT_DEVICE_ID_1]), + btif_a2dp_get_stream_state( + app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream)); #ifdef BTIF_HID_DEVICE - hid_exit_shutter_mode(); + hid_exit_shutter_mode(); #endif - if (btif_get_hf_chan_state(app_bt_device.hf_channel[BT_DEVICE_ID_1]) == BTIF_HF_STATE_OPEN) - { - app_bt_HF_DisconnectServiceLink(app_bt_device.hf_channel[BT_DEVICE_ID_1]); - } -#if defined (__HSP_ENABLE__) - if(app_bt_device.hs_channel[BT_DEVICE_ID_1].state == HS_STATE_OPEN) - { - app_bt_HS_DisconnectServiceLink(&app_bt_device.hs_channel[BT_DEVICE_ID_1]); - } -#endif //btif_a2dp_get_stream_state(app_bt_device.a2dp_stream[device_id]->a2dp_stream) - if(btif_a2dp_get_stream_state(app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream) == BTIF_AVDTP_STRM_STATE_STREAMING || - btif_a2dp_get_stream_state(app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream) == BTIF_AVDTP_STRM_STATE_OPEN) - { - app_bt_A2DP_CloseStream(app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream); - } + if (btif_get_hf_chan_state(app_bt_device.hf_channel[BT_DEVICE_ID_1]) == + BTIF_HF_STATE_OPEN) { + app_bt_HF_DisconnectServiceLink(app_bt_device.hf_channel[BT_DEVICE_ID_1]); + } +#if defined(__HSP_ENABLE__) + if (app_bt_device.hs_channel[BT_DEVICE_ID_1].state == HS_STATE_OPEN) { + app_bt_HS_DisconnectServiceLink( + &app_bt_device.hs_channel[BT_DEVICE_ID_1]); + } +#endif // btif_a2dp_get_stream_state(app_bt_device.a2dp_stream[device_id]->a2dp_stream) + if (btif_a2dp_get_stream_state( + app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_STREAMING || + btif_a2dp_get_stream_state( + app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_OPEN) { + app_bt_A2DP_CloseStream( + app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream); + } #if defined(A2DP_LHDC_ON) - if(btif_a2dp_get_stream_state(app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_1]->a2dp_stream) == BTIF_AVDTP_STRM_STATE_STREAMING || - btif_a2dp_get_stream_state(app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_1]->a2dp_stream) == BTIF_AVDTP_STRM_STATE_OPEN) - { - app_bt_A2DP_CloseStream(app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_1]->a2dp_stream); - } + if (btif_a2dp_get_stream_state( + app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_1]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_STREAMING || + btif_a2dp_get_stream_state( + app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_1]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_OPEN) { + app_bt_A2DP_CloseStream( + app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_1]->a2dp_stream); + } #endif #if defined(A2DP_LDAC_ON) - if(btif_a2dp_get_stream_state(app_bt_device.a2dp_ldac_stream[BT_DEVICE_ID_1]->a2dp_stream) == BTIF_AVDTP_STRM_STATE_STREAMING || - btif_a2dp_get_stream_state(app_bt_device.a2dp_ldac_stream[BT_DEVICE_ID_1]->a2dp_stream) == BTIF_AVDTP_STRM_STATE_OPEN) - { - app_bt_A2DP_CloseStream(app_bt_device.a2dp_ldac_stream[BT_DEVICE_ID_1]->a2dp_stream); - } + if (btif_a2dp_get_stream_state( + app_bt_device.a2dp_ldac_stream[BT_DEVICE_ID_1]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_STREAMING || + btif_a2dp_get_stream_state( + app_bt_device.a2dp_ldac_stream[BT_DEVICE_ID_1]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_OPEN) { + app_bt_A2DP_CloseStream( + app_bt_device.a2dp_ldac_stream[BT_DEVICE_ID_1]->a2dp_stream); + } #endif #if defined(A2DP_AAC_ON) - if(btif_a2dp_get_stream_state( app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream) == BTIF_AVDTP_STRM_STATE_STREAMING || - btif_a2dp_get_stream_state( app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream) == BTIF_AVDTP_STRM_STATE_OPEN) - { - app_bt_A2DP_CloseStream(app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream); - } + if (btif_a2dp_get_stream_state( + app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_STREAMING || + btif_a2dp_get_stream_state( + app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_OPEN) { + app_bt_A2DP_CloseStream( + app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream); + } #endif #if defined(A2DP_SCALABLE_ON) - if(btif_a2dp_get_stream_state( app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_1]->a2dp_stream) == BTIF_AVDTP_STRM_STATE_STREAMING || - btif_a2dp_get_stream_state(app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_1]->a2dp_stream) == BTIF_AVDTP_STRM_STATE_OPEN) - { - app_bt_A2DP_CloseStream(app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_1]->a2dp_stream); - } + if (btif_a2dp_get_stream_state( + app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_1]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_STREAMING || + btif_a2dp_get_stream_state( + app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_1]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_OPEN) { + app_bt_A2DP_CloseStream( + app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_1]->a2dp_stream); + } #endif - if( btif_avrcp_get_remote_device(app_bt_device.avrcp_channel[BT_DEVICE_ID_1]->avrcp_channel_handle)) - { - btif_avrcp_disconnect(app_bt_device.avrcp_channel[BT_DEVICE_ID_1]->avrcp_channel_handle); - } + if (btif_avrcp_get_remote_device( + app_bt_device.avrcp_channel[BT_DEVICE_ID_1] + ->avrcp_channel_handle)) { + btif_avrcp_disconnect( + app_bt_device.avrcp_channel[BT_DEVICE_ID_1]->avrcp_channel_handle); + } #ifdef __BT_ONE_BRING_TWO__ - TRACE(3,"%s id2 hf:%d a2dp:%d",__func__, btif_get_hf_chan_state(app_bt_device.hf_channel[BT_DEVICE_ID_2]), btif_a2dp_get_stream_state(app_bt_device.a2dp_stream[BT_DEVICE_ID_2]->a2dp_stream)); - //if(app_bt_device.hf_channel[BT_DEVICE_ID_2].state == HF_STATE_OPEN){ - if(btif_get_hf_chan_state(app_bt_device.hf_channel[BT_DEVICE_ID_2]) == BTIF_HF_STATE_OPEN) - { - app_bt_HF_DisconnectServiceLink(app_bt_device.hf_channel[BT_DEVICE_ID_2]); - } + TRACE(3, "%s id2 hf:%d a2dp:%d", __func__, + btif_get_hf_chan_state(app_bt_device.hf_channel[BT_DEVICE_ID_2]), + btif_a2dp_get_stream_state( + app_bt_device.a2dp_stream[BT_DEVICE_ID_2]->a2dp_stream)); + // if(app_bt_device.hf_channel[BT_DEVICE_ID_2].state == HF_STATE_OPEN){ + if (btif_get_hf_chan_state(app_bt_device.hf_channel[BT_DEVICE_ID_2]) == + BTIF_HF_STATE_OPEN) { + app_bt_HF_DisconnectServiceLink(app_bt_device.hf_channel[BT_DEVICE_ID_2]); + } -#if defined (__HSP_ENABLE__) - if(app_bt_device.hs_channel[BT_DEVICE_ID_2].state == HS_STATE_OPEN) - { - app_bt_HS_DisconnectServiceLink(&app_bt_device.hs_channel[BT_DEVICE_ID_2]); - } +#if defined(__HSP_ENABLE__) + if (app_bt_device.hs_channel[BT_DEVICE_ID_2].state == HS_STATE_OPEN) { + app_bt_HS_DisconnectServiceLink( + &app_bt_device.hs_channel[BT_DEVICE_ID_2]); + } #endif // __HSP_ENABLE__ - if( btif_a2dp_get_stream_state(app_bt_device.a2dp_stream[BT_DEVICE_ID_2]->a2dp_stream) == BTIF_AVDTP_STRM_STATE_STREAMING || - btif_a2dp_get_stream_state(app_bt_device.a2dp_stream[BT_DEVICE_ID_2]->a2dp_stream) == BTIF_AVDTP_STRM_STATE_OPEN) - { - app_bt_A2DP_CloseStream(app_bt_device.a2dp_stream[BT_DEVICE_ID_2]->a2dp_stream); - } + if (btif_a2dp_get_stream_state( + app_bt_device.a2dp_stream[BT_DEVICE_ID_2]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_STREAMING || + btif_a2dp_get_stream_state( + app_bt_device.a2dp_stream[BT_DEVICE_ID_2]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_OPEN) { + app_bt_A2DP_CloseStream( + app_bt_device.a2dp_stream[BT_DEVICE_ID_2]->a2dp_stream); + } #if defined(A2DP_LHDC_ON) - if(btif_a2dp_get_stream_state(app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_2]->a2dp_stream) == BTIF_AVDTP_STRM_STATE_STREAMING || - btif_a2dp_get_stream_state(app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_2]->a2dp_stream) == BTIF_AVDTP_STRM_STATE_OPEN) - { - app_bt_A2DP_CloseStream(app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_2]->a2dp_stream); - } + if (btif_a2dp_get_stream_state( + app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_2]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_STREAMING || + btif_a2dp_get_stream_state( + app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_2]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_OPEN) { + app_bt_A2DP_CloseStream( + app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_2]->a2dp_stream); + } #endif // A2DP_LHDC_ON #if defined(A2DP_AAC_ON) - if(btif_a2dp_get_stream_state(app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_2]->a2dp_stream) == BTIF_AVDTP_STRM_STATE_STREAMING || - btif_a2dp_get_stream_state(app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_2]->a2dp_stream)== BTIF_AVDTP_STRM_STATE_OPEN) - { - app_bt_A2DP_CloseStream(app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_2]->a2dp_stream); - } + if (btif_a2dp_get_stream_state( + app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_2]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_STREAMING || + btif_a2dp_get_stream_state( + app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_2]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_OPEN) { + app_bt_A2DP_CloseStream( + app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_2]->a2dp_stream); + } #endif // A2DP_AAC_ON #if defined(A2DP_SCALABLE_ON) - if(btif_a2dp_get_stream_state(app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_2]->a2dp_stream)== BTIF_AVDTP_STRM_STATE_STREAMING || - btif_a2dp_get_stream_state(app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_2]->a2dp_stream) == BTIF_AVDTP_STRM_STATE_OPEN) - { - app_bt_A2DP_CloseStream(app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_2]->a2dp_stream); - } + if (btif_a2dp_get_stream_state( + app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_2]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_STREAMING || + btif_a2dp_get_stream_state( + app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_2]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_OPEN) { + app_bt_A2DP_CloseStream( + app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_2]->a2dp_stream); + } #endif // A2DP_SCALABLE_ON - if( btif_avrcp_get_remote_device(app_bt_device.avrcp_channel[BT_DEVICE_ID_2]->avrcp_channel_handle)) - { - btif_avrcp_disconnect(app_bt_device.avrcp_channel[BT_DEVICE_ID_2]->avrcp_channel_handle); - } + if (btif_avrcp_get_remote_device( + app_bt_device.avrcp_channel[BT_DEVICE_ID_2] + ->avrcp_channel_handle)) { + btif_avrcp_disconnect( + app_bt_device.avrcp_channel[BT_DEVICE_ID_2]->avrcp_channel_handle); + } #endif //__BT_ONE_BRING_TWO__ #ifdef BISTO_ENABLED - gsound_custom_bt_disconnect_all_channel(); + gsound_custom_bt_disconnect_all_channel(); #endif - } + } #ifdef __IAG_BLE_INCLUDE__ - if(app_ble_is_any_connection_exist()) - { + if (app_ble_is_any_connection_exist()) { #ifdef GFPS_ENABLED - if (!app_gfps_is_last_response_pending()) + if (!app_gfps_is_last_response_pending()) #endif - app_ble_disconnect_all(); - } + app_ble_disconnect_all(); + } #endif - if(osapi_lock_is_exist()) - osapi_unlock_stack(); - - osDelay(500); - - if(Tmp_activeCons) - { - btif_remote_device_t* remDev = app_bt_get_remoteDev(BT_DEVICE_ID_1); - if (NULL != remDev) - { - app_bt_MeDisconnectLink(remDev); - } - -#ifdef __BT_ONE_BRING_TWO__ - remDev = app_bt_get_remoteDev(BT_DEVICE_ID_2); - if (NULL != remDev) - { - osDelay(200); - app_bt_MeDisconnectLink(remDev); - } -#endif - } - return BT_STS_SUCCESS; -} - -void app_disconnect_all_bt_connections(void) -{ - LinkDisconnectDirectly(false); -} - -static int app_custom_function_process(APP_MESSAGE_BODY *msg_body) -{ - APP_APPTHREAD_REQ_CUSTOMER_CALL_FN_T customer_call = (APP_APPTHREAD_REQ_CUSTOMER_CALL_FN_T)(msg_body->message_ptr); - TRACE(4, "func:0x%08x,param0:0x%08x, param1:0x%08x", - msg_body->message_ptr, - msg_body->message_Param0, - msg_body->message_Param1); - if (customer_call){ - customer_call((void *)msg_body->message_Param0, (void *)msg_body->message_Param1); - } - return 0; -} - -int app_bt_start_custom_function_in_app_thread( - uint32_t param0, uint32_t param1, uint32_t funcPtr) -{ - APP_MESSAGE_BLOCK msg; - - msg.mod_id = APP_MODUAL_CUSTOM_FUNCTION; - msg.msg_body.message_id = 0; - msg.msg_body.message_ptr = funcPtr; - msg.msg_body.message_Param0 = param0; - msg.msg_body.message_Param1 = param1; - - app_mailbox_put(&msg); - return 0; -} - -void app_bt_init(void) -{ - app_bt_mail_init(); - app_set_threadhandle(APP_MODUAL_BT, app_bt_handle_process); - btif_me_sec_set_io_cap_rsp_reject_ext(app_bt_profile_connect_openreconnecting); - app_bt_active_mode_manager_init(); - app_set_threadhandle(APP_MODUAL_CUSTOM_FUNCTION, app_custom_function_process); -} - -extern "C" bool app_bt_has_connectivitys(void) -{ - int activeCons; - osapi_lock_stack(); - activeCons = btif_me_get_activeCons(); + if (osapi_lock_is_exist()) osapi_unlock_stack(); - if(activeCons > 0) - return true; + osDelay(500); - return false; + if (Tmp_activeCons) { + btif_remote_device_t *remDev = app_bt_get_remoteDev(BT_DEVICE_ID_1); + if (NULL != remDev) { + app_bt_MeDisconnectLink(remDev); + } + +#ifdef __BT_ONE_BRING_TWO__ + remDev = app_bt_get_remoteDev(BT_DEVICE_ID_2); + if (NULL != remDev) { + osDelay(200); + app_bt_MeDisconnectLink(remDev); + } +#endif + } + return BT_STS_SUCCESS; +} + +void app_disconnect_all_bt_connections(void) { LinkDisconnectDirectly(false); } + +static int app_custom_function_process(APP_MESSAGE_BODY *msg_body) { + APP_APPTHREAD_REQ_CUSTOMER_CALL_FN_T customer_call = + (APP_APPTHREAD_REQ_CUSTOMER_CALL_FN_T)(msg_body->message_ptr); + TRACE(4, "func:0x%08x,param0:0x%08x, param1:0x%08x", msg_body->message_ptr, + msg_body->message_Param0, msg_body->message_Param1); + if (customer_call) { + customer_call((void *)msg_body->message_Param0, + (void *)msg_body->message_Param1); + } + return 0; +} + +int app_bt_start_custom_function_in_app_thread(uint32_t param0, uint32_t param1, + uint32_t funcPtr) { + APP_MESSAGE_BLOCK msg; + + msg.mod_id = APP_MODUAL_CUSTOM_FUNCTION; + msg.msg_body.message_id = 0; + msg.msg_body.message_ptr = funcPtr; + msg.msg_body.message_Param0 = param0; + msg.msg_body.message_Param1 = param1; + + app_mailbox_put(&msg); + return 0; +} + +void app_bt_init(void) { + app_bt_mail_init(); + app_set_threadhandle(APP_MODUAL_BT, app_bt_handle_process); + btif_me_sec_set_io_cap_rsp_reject_ext( + app_bt_profile_connect_openreconnecting); + app_bt_active_mode_manager_init(); + app_set_threadhandle(APP_MODUAL_CUSTOM_FUNCTION, app_custom_function_process); +} + +extern "C" bool app_bt_has_connectivitys(void) { + int activeCons; + osapi_lock_stack(); + activeCons = btif_me_get_activeCons(); + osapi_unlock_stack(); + + if (activeCons > 0) + return true; + + return false; #if 0 if(app_bt_device.hf_channel[BT_DEVICE_ID_1].cmgrHandler.remDev) return true; @@ -3950,1339 +3931,1277 @@ extern "C" bool app_bt_has_connectivitys(void) #endif } - #ifdef __TWS_CHARGER_BOX__ extern "C" { - bt_status_t ME_Ble_Clear_Whitelist(void); - bt_status_t ME_Ble_Set_Private_Address(BT_BD_ADDR *addr); - bt_status_t ME_Ble_Add_Dev_To_Whitelist(U8 addr_type,BT_BD_ADDR *addr); - bt_status_t ME_Ble_SetAdv_data(U8 len, U8 *data); - bt_status_t ME_Ble_SetScanRsp_data(U8 len, U8 *data); - bt_status_t ME_Ble_SetAdv_parameters(adv_para_struct *para); - bt_status_t ME_Ble_SetAdv_en(U8 en); - bt_status_t ME_Ble_Setscan_parameter(scan_para_struct *para); - bt_status_t ME_Ble_Setscan_en(U8 scan_en, U8 filter_duplicate); +bt_status_t ME_Ble_Clear_Whitelist(void); +bt_status_t ME_Ble_Set_Private_Address(BT_BD_ADDR *addr); +bt_status_t ME_Ble_Add_Dev_To_Whitelist(U8 addr_type, BT_BD_ADDR *addr); +bt_status_t ME_Ble_SetAdv_data(U8 len, U8 *data); +bt_status_t ME_Ble_SetScanRsp_data(U8 len, U8 *data); +bt_status_t ME_Ble_SetAdv_parameters(adv_para_struct *para); +bt_status_t ME_Ble_SetAdv_en(U8 en); +bt_status_t ME_Ble_Setscan_parameter(scan_para_struct *para); +bt_status_t ME_Ble_Setscan_en(U8 scan_en, U8 filter_duplicate); } - -int8_t power_level=0; +int8_t power_level = 0; #define TWS_BOX_OPEN 1 #define TWS_BOX_CLOSE 0 -void app_tws_box_set_slave_adv_data(uint8_t power_level,uint8_t box_status) -{ - uint8_t adv_data[] = - { - 0x02,0xfe, 0x00, - 0x02, 0xfd, 0x00 // manufacturer data - }; +void app_tws_box_set_slave_adv_data(uint8_t power_level, uint8_t box_status) { + uint8_t adv_data[] = { + 0x02, 0xfe, 0x00, 0x02, 0xfd, 0x00 // manufacturer data + }; - adv_data[2] = power_level; - - adv_data[5] = box_status; - ME_Ble_SetAdv_data(sizeof(adv_data), adv_data); + adv_data[2] = power_level; + adv_data[5] = box_status; + ME_Ble_SetAdv_data(sizeof(adv_data), adv_data); } +void app_tws_box_set_slave_adv_para(void) { + uint8_t peer_addr[BTIF_BD_ADDR_SIZE] = {0}; + adv_para_struct para; -void app_tws_box_set_slave_adv_para(void) -{ - uint8_t peer_addr[BTIF_BD_ADDR_SIZE] = {0}; - adv_para_struct para; - - - para.interval_min = 0x0040; // 20ms - para.interval_max = 0x0040; // 20ms - para.adv_type = 0x03; - para.own_addr_type = 0x01; - para.peer_addr_type = 0x01; - para.adv_chanmap = 0x07; - para.adv_filter_policy = 0x00; - memcpy(para.bd_addr.addr, peer_addr, BTIF_BD_ADDR_SIZE); - - ME_Ble_SetAdv_parameters(¶); + para.interval_min = 0x0040; // 20ms + para.interval_max = 0x0040; // 20ms + para.adv_type = 0x03; + para.own_addr_type = 0x01; + para.peer_addr_type = 0x01; + para.adv_chanmap = 0x07; + para.adv_filter_policy = 0x00; + memcpy(para.bd_addr.addr, peer_addr, BTIF_BD_ADDR_SIZE); + ME_Ble_SetAdv_parameters(¶); } - extern uint8_t bt_addr[6]; -void app_tws_start_chargerbox_adv(void) -{ - app_tws_box_set_slave_adv_data(power_level,TWS_BOX_OPEN); - ME_Ble_Set_Private_Address((BT_BD_ADDR *)bt_addr); - app_tws_box_set_slave_adv_para(); - ME_Ble_SetAdv_en(1); - +void app_tws_start_chargerbox_adv(void) { + app_tws_box_set_slave_adv_data(power_level, TWS_BOX_OPEN); + ME_Ble_Set_Private_Address((BT_BD_ADDR *)bt_addr); + app_tws_box_set_slave_adv_para(); + ME_Ble_SetAdv_en(1); } - - #endif -bool app_is_hfp_service_connected(void) -{ - return (bt_profile_manager[BT_DEVICE_ID_1].hfp_connect == bt_profile_connect_status_success); +bool app_is_hfp_service_connected(void) { + return (bt_profile_manager[BT_DEVICE_ID_1].hfp_connect == + bt_profile_connect_status_success); } +btif_remote_device_t *app_bt_get_remoteDev(uint8_t deviceId) { + btif_remote_device_t *currentRemDev = NULL; -btif_remote_device_t* app_bt_get_remoteDev(uint8_t deviceId) -{ - btif_remote_device_t* currentRemDev = NULL; + if (btif_a2dp_get_stream_state( + app_bt_device.a2dp_stream[deviceId]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_STREAMING || + btif_a2dp_get_stream_state( + app_bt_device.a2dp_stream[deviceId]->a2dp_stream) == + BTIF_AVDTP_STRM_STATE_OPEN) { + currentRemDev = btif_a2dp_get_stream_conn_remDev( + app_bt_device.a2dp_stream[deviceId]->a2dp_stream); + } else if (btif_get_hf_chan_state(app_bt_device.hf_channel[deviceId]) == + BTIF_HF_STATE_OPEN) { + currentRemDev = (btif_remote_device_t *)btif_hf_cmgr_get_remote_device( + app_bt_device.hf_channel[deviceId]); + } - if(btif_a2dp_get_stream_state( app_bt_device.a2dp_stream[deviceId]->a2dp_stream) - == BTIF_AVDTP_STRM_STATE_STREAMING || - btif_a2dp_get_stream_state( app_bt_device.a2dp_stream[deviceId]->a2dp_stream) - == BTIF_AVDTP_STRM_STATE_OPEN) - { - currentRemDev = btif_a2dp_get_stream_conn_remDev(app_bt_device.a2dp_stream[deviceId]->a2dp_stream); - } - else if (btif_get_hf_chan_state(app_bt_device.hf_channel[deviceId]) == BTIF_HF_STATE_OPEN) - { - currentRemDev = (btif_remote_device_t *)btif_hf_cmgr_get_remote_device(app_bt_device.hf_channel[deviceId]); - } + TRACE(2, "%s get current Remdev %p", __FUNCTION__, currentRemDev); - TRACE(2,"%s get current Remdev %p", __FUNCTION__, currentRemDev); - - return currentRemDev; + return currentRemDev; } -void app_bt_stay_active_rem_dev(btif_remote_device_t* pRemDev) -{ - if (pRemDev) - { - btif_cmgr_handler_t *cmgrHandler; - /* Clear the sniff timer */ - cmgrHandler = btif_cmgr_get_acl_handler(pRemDev); - btif_cmgr_clear_sniff_timer(cmgrHandler); - btif_cmgr_disable_sniff_timer(cmgrHandler); - app_bt_Me_SetLinkPolicy(pRemDev, BTIF_BLP_MASTER_SLAVE_SWITCH); - } +void app_bt_stay_active_rem_dev(btif_remote_device_t *pRemDev) { + if (pRemDev) { + btif_cmgr_handler_t *cmgrHandler; + /* Clear the sniff timer */ + cmgrHandler = btif_cmgr_get_acl_handler(pRemDev); + btif_cmgr_clear_sniff_timer(cmgrHandler); + btif_cmgr_disable_sniff_timer(cmgrHandler); + app_bt_Me_SetLinkPolicy(pRemDev, BTIF_BLP_MASTER_SLAVE_SWITCH); + } } -void app_bt_stay_active(uint8_t deviceId) -{ - btif_remote_device_t* currentRemDev = app_bt_get_remoteDev(deviceId); - app_bt_stay_active_rem_dev(currentRemDev); +void app_bt_stay_active(uint8_t deviceId) { + btif_remote_device_t *currentRemDev = app_bt_get_remoteDev(deviceId); + app_bt_stay_active_rem_dev(currentRemDev); } -void app_bt_allow_sniff_rem_dev(btif_remote_device_t* pRemDev) -{ - if (pRemDev && (BTIF_BDS_CONNECTED == btif_me_get_remote_device_state(pRemDev))) - { - btif_cmgr_handler_t *cmgrHandler; - /* Enable the sniff timer */ - cmgrHandler = btif_cmgr_get_acl_handler(pRemDev); +void app_bt_allow_sniff_rem_dev(btif_remote_device_t *pRemDev) { + if (pRemDev && + (BTIF_BDS_CONNECTED == btif_me_get_remote_device_state(pRemDev))) { + btif_cmgr_handler_t *cmgrHandler; + /* Enable the sniff timer */ + cmgrHandler = btif_cmgr_get_acl_handler(pRemDev); - /* Start the sniff timer */ - btif_sniff_info_t sniffInfo; - sniffInfo.minInterval = BTIF_CMGR_SNIFF_MIN_INTERVAL; - sniffInfo.maxInterval = BTIF_CMGR_SNIFF_MAX_INTERVAL; - sniffInfo.attempt = BTIF_CMGR_SNIFF_ATTEMPT; - sniffInfo.timeout = BTIF_CMGR_SNIFF_TIMEOUT; - if (cmgrHandler) - { - btif_cmgr_set_sniff_timer(cmgrHandler, &sniffInfo, BTIF_CMGR_SNIFF_TIMER); - } - app_bt_Me_SetLinkPolicy(pRemDev, BTIF_BLP_MASTER_SLAVE_SWITCH | BTIF_BLP_SNIFF_MODE); + /* Start the sniff timer */ + btif_sniff_info_t sniffInfo; + sniffInfo.minInterval = BTIF_CMGR_SNIFF_MIN_INTERVAL; + sniffInfo.maxInterval = BTIF_CMGR_SNIFF_MAX_INTERVAL; + sniffInfo.attempt = BTIF_CMGR_SNIFF_ATTEMPT; + sniffInfo.timeout = BTIF_CMGR_SNIFF_TIMEOUT; + if (cmgrHandler) { + btif_cmgr_set_sniff_timer(cmgrHandler, &sniffInfo, BTIF_CMGR_SNIFF_TIMER); } + app_bt_Me_SetLinkPolicy(pRemDev, + BTIF_BLP_MASTER_SLAVE_SWITCH | BTIF_BLP_SNIFF_MODE); + } } -extern "C" uint8_t is_sco_mode (void); -void app_bt_allow_sniff(uint8_t deviceId) -{ - if (a2dp_is_music_ongoing() || is_sco_mode()) - { - return; - } - btif_remote_device_t* currentRemDev = app_bt_get_remoteDev(deviceId); - app_bt_allow_sniff_rem_dev(currentRemDev); +extern "C" uint8_t is_sco_mode(void); +void app_bt_allow_sniff(uint8_t deviceId) { + if (a2dp_is_music_ongoing() || is_sco_mode()) { + return; + } + btif_remote_device_t *currentRemDev = app_bt_get_remoteDev(deviceId); + app_bt_allow_sniff_rem_dev(currentRemDev); } -void app_bt_stop_sniff(uint8_t deviceId) -{ - btif_remote_device_t* currentRemDev = app_bt_get_remoteDev(deviceId); +void app_bt_stop_sniff(uint8_t deviceId) { + btif_remote_device_t *currentRemDev = app_bt_get_remoteDev(deviceId); - if (currentRemDev && (btif_me_get_remote_device_state(currentRemDev) == BTIF_BDS_CONNECTED)) - { - if (btif_me_get_current_mode(currentRemDev) == BTIF_BLM_SNIFF_MODE) - { - TRACE(1,"!!! stop sniff currmode:%d\n", btif_me_get_current_mode(currentRemDev)); - app_bt_ME_StopSniff(currentRemDev); - } + if (currentRemDev && + (btif_me_get_remote_device_state(currentRemDev) == BTIF_BDS_CONNECTED)) { + if (btif_me_get_current_mode(currentRemDev) == BTIF_BLM_SNIFF_MODE) { + TRACE(1, "!!! stop sniff currmode:%d\n", + btif_me_get_current_mode(currentRemDev)); + app_bt_ME_StopSniff(currentRemDev); } + } } -bool app_bt_is_device_connected(uint8_t deviceId) -{ - if (deviceId < BT_DEVICE_NUM) - { - return bt_profile_manager[deviceId].has_connected; - } - else - { - // Indicate no connection is user passes invalid deviceId - return false; - } +bool app_bt_is_device_connected(uint8_t deviceId) { + if (deviceId < BT_DEVICE_NUM) { + return bt_profile_manager[deviceId].has_connected; + } else { + // Indicate no connection is user passes invalid deviceId + return false; + } } #if defined(__BT_SELECT_PROF_DEVICE_ID__) -int8_t app_bt_a2dp_is_same_stream(a2dp_stream_t *src_Stream, a2dp_stream_t *dst_Stream) -{ - return btif_a2dp_is_register_codec_same(src_Stream, dst_Stream); +int8_t app_bt_a2dp_is_same_stream(a2dp_stream_t *src_Stream, + a2dp_stream_t *dst_Stream) { + return btif_a2dp_is_register_codec_same(src_Stream, dst_Stream); } -void app_bt_a2dp_find_same_unused_stream(a2dp_stream_t *in_Stream, a2dp_stream_t **out_Stream, uint32_t device_id) -{ - *out_Stream = NULL; - if (app_bt_a2dp_is_same_stream(app_bt_device.a2dp_stream[device_id]->a2dp_stream, in_Stream)) - *out_Stream = app_bt_device.a2dp_stream[device_id]->a2dp_stream; +void app_bt_a2dp_find_same_unused_stream(a2dp_stream_t *in_Stream, + a2dp_stream_t **out_Stream, + uint32_t device_id) { + *out_Stream = NULL; + if (app_bt_a2dp_is_same_stream( + app_bt_device.a2dp_stream[device_id]->a2dp_stream, in_Stream)) + *out_Stream = app_bt_device.a2dp_stream[device_id]->a2dp_stream; #if defined(A2DP_LHDC_ON) - else if (app_bt_a2dp_is_same_stream(app_bt_device.a2dp_lhdc_stream[device_id]->a2dp_stream, in_Stream)) - *out_Stream = app_bt_device.a2dp_lhdc_stream[device_id]->a2dp_stream; + else if (app_bt_a2dp_is_same_stream( + app_bt_device.a2dp_lhdc_stream[device_id]->a2dp_stream, + in_Stream)) + *out_Stream = app_bt_device.a2dp_lhdc_stream[device_id]->a2dp_stream; #endif #if defined(A2DP_LDAC_ON) - else if (app_bt_a2dp_is_same_stream(app_bt_device.a2dp_ldac_stream[device_id]->a2dp_stream, in_Stream)) - *out_Stream = app_bt_device.a2dp_ldac_stream[device_id]->a2dp_stream; + else if (app_bt_a2dp_is_same_stream( + app_bt_device.a2dp_ldac_stream[device_id]->a2dp_stream, + in_Stream)) + *out_Stream = app_bt_device.a2dp_ldac_stream[device_id]->a2dp_stream; #endif #if defined(A2DP_AAC_ON) - else if (app_bt_a2dp_is_same_stream(app_bt_device.a2dp_aac_stream[device_id]->a2dp_stream, in_Stream)) - *out_Stream = app_bt_device.a2dp_aac_stream[device_id]->a2dp_stream; + else if (app_bt_a2dp_is_same_stream( + app_bt_device.a2dp_aac_stream[device_id]->a2dp_stream, + in_Stream)) + *out_Stream = app_bt_device.a2dp_aac_stream[device_id]->a2dp_stream; #endif #if defined(A2DP_SCALABLE_ON) - else if (app_bt_a2dp_is_same_stream(app_bt_device.a2dp_scalable_stream[device_id]->a2dp_stream, in_Stream)) - *out_Stream = app_bt_device.a2dp_scalable_stream[device_id]->a2dp_stream; + else if (app_bt_a2dp_is_same_stream( + app_bt_device.a2dp_scalable_stream[device_id]->a2dp_stream, + in_Stream)) + *out_Stream = app_bt_device.a2dp_scalable_stream[device_id]->a2dp_stream; #endif } -int8_t app_bt_a2dp_is_stream_on_device_id(a2dp_stream_t *in_Stream, uint32_t device_id) -{ - if (app_bt_device.a2dp_stream[device_id]->a2dp_stream == in_Stream) - return 1; +int8_t app_bt_a2dp_is_stream_on_device_id(a2dp_stream_t *in_Stream, + uint32_t device_id) { + if (app_bt_device.a2dp_stream[device_id]->a2dp_stream == in_Stream) + return 1; #if defined(A2DP_LHDC_ON) - else if (app_bt_device.a2dp_lhdc_stream[device_id]->a2dp_stream == in_Stream) - return 1; + else if (app_bt_device.a2dp_lhdc_stream[device_id]->a2dp_stream == in_Stream) + return 1; #endif #if defined(A2DP_LDAC_ON) - else if (app_bt_device.a2dp_ldac_stream[device_id]->a2dp_stream == in_Stream) - return 1; + else if (app_bt_device.a2dp_ldac_stream[device_id]->a2dp_stream == in_Stream) + return 1; #endif #if defined(A2DP_AAC_ON) - else if (app_bt_device.a2dp_aac_stream[device_id]->a2dp_stream == in_Stream) - return 1; + else if (app_bt_device.a2dp_aac_stream[device_id]->a2dp_stream == in_Stream) + return 1; #endif #if defined(A2DP_SCALABLE_ON) - else if (app_bt_device.a2dp_scalable_stream[device_id]->a2dp_stream == in_Stream) - return 1; + else if (app_bt_device.a2dp_scalable_stream[device_id]->a2dp_stream == + in_Stream) + return 1; #endif - return 0; + return 0; } -int8_t app_bt_hfp_is_chan_on_device_id(hf_chan_handle_t chan, uint32_t device_id) -{ - if (app_bt_device.hf_channel[device_id] == chan) - return 1; - return 0; +int8_t app_bt_hfp_is_chan_on_device_id(hf_chan_handle_t chan, + uint32_t device_id) { + if (app_bt_device.hf_channel[device_id] == chan) + return 1; + return 0; } -int8_t app_bt_is_any_profile_connected(uint32_t device_id) -{ - // TODO avrcp?spp?hid?bisto?ama?dma?rfcomm? - if ((bt_profile_manager[device_id].hfp_connect == bt_profile_connect_status_success) - || (bt_profile_manager[device_id].hsp_connect == bt_profile_connect_status_success) - || (bt_profile_manager[device_id].a2dp_connect == bt_profile_connect_status_success)) - { - return 1; - } +int8_t app_bt_is_any_profile_connected(uint32_t device_id) { + // TODO avrcp?spp?hid?bisto?ama?dma?rfcomm? + if ((bt_profile_manager[device_id].hfp_connect == + bt_profile_connect_status_success) || + (bt_profile_manager[device_id].hsp_connect == + bt_profile_connect_status_success) || + (bt_profile_manager[device_id].a2dp_connect == + bt_profile_connect_status_success)) { + return 1; + } - return 0; + return 0; } -int8_t app_bt_is_a2dp_connected(uint32_t device_id) -{ - if (bt_profile_manager[device_id].a2dp_connect == bt_profile_connect_status_success) - { - return 1; - } +int8_t app_bt_is_a2dp_connected(uint32_t device_id) { + if (bt_profile_manager[device_id].a2dp_connect == + bt_profile_connect_status_success) { + return 1; + } - return 0; + return 0; } -btif_remote_device_t *app_bt_get_connected_profile_remdev(uint32_t device_id) -{ - if (bt_profile_manager[device_id].a2dp_connect == bt_profile_connect_status_success) - { - return (btif_remote_device_t *)btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[device_id]); - } - else if (bt_profile_manager[device_id].hfp_connect == bt_profile_connect_status_success) - { - return (btif_remote_device_t *)btif_hf_cmgr_get_remote_device(app_bt_device.hf_channel[device_id]); - } -#if defined (__HSP_ENABLE__) - else if (bt_profile_manager[device_id].hsp_connect == bt_profile_connect_status_success) - { - // TODO hsp support - //return (btif_remote_device_t *)btif_hs_cmgr_get_remote_device(app_bt_device.hs_channel[i]); - } +btif_remote_device_t *app_bt_get_connected_profile_remdev(uint32_t device_id) { + if (bt_profile_manager[device_id].a2dp_connect == + bt_profile_connect_status_success) { + return (btif_remote_device_t *)btif_a2dp_get_remote_device( + app_bt_device.a2dp_connected_stream[device_id]); + } else if (bt_profile_manager[device_id].hfp_connect == + bt_profile_connect_status_success) { + return (btif_remote_device_t *)btif_hf_cmgr_get_remote_device( + app_bt_device.hf_channel[device_id]); + } +#if defined(__HSP_ENABLE__) + else if (bt_profile_manager[device_id].hsp_connect == + bt_profile_connect_status_success) { + // TODO hsp support + // return (btif_remote_device_t + // *)btif_hs_cmgr_get_remote_device(app_bt_device.hs_channel[i]); + } #endif - return NULL; + return NULL; } #endif -bool app_bt_get_device_bdaddr(uint8_t deviceId, uint8_t* btAddr) -{ - bool ret = false; +bool app_bt_get_device_bdaddr(uint8_t deviceId, uint8_t *btAddr) { + bool ret = false; - if (app_bt_is_device_connected(deviceId)) - { - btif_remote_device_t* currentRemDev = app_bt_get_remoteDev(deviceId); + if (app_bt_is_device_connected(deviceId)) { + btif_remote_device_t *currentRemDev = app_bt_get_remoteDev(deviceId); - if (currentRemDev) - { - memcpy(btAddr, btif_me_get_remote_device_bdaddr(currentRemDev)->address, BTIF_BD_ADDR_SIZE); - ret = true; - } + if (currentRemDev) { + memcpy(btAddr, btif_me_get_remote_device_bdaddr(currentRemDev)->address, + BTIF_BD_ADDR_SIZE); + ret = true; } + } - return ret; + return ret; } -void fast_pair_enter_pairing_mode_handler(void) -{ +void fast_pair_enter_pairing_mode_handler(void) { #if defined(IBRT) - app_ibrt_ui_judge_scan_type(IBRT_FASTPAIR_TRIGGER, MOBILE_LINK, 0); + app_ibrt_ui_judge_scan_type(IBRT_FASTPAIR_TRIGGER, MOBILE_LINK, 0); #else - app_bt_accessmode_set(BTIF_BAM_GENERAL_ACCESSIBLE); + app_bt_accessmode_set(BTIF_BAM_GENERAL_ACCESSIBLE); #endif #ifdef __INTERCONNECTION__ - clear_discoverable_adv_timeout_flag(); - app_interceonnection_start_discoverable_adv(INTERCONNECTION_BLE_FAST_ADVERTISING_INTERVAL, - APP_INTERCONNECTION_FAST_ADV_TIMEOUT_IN_MS); + clear_discoverable_adv_timeout_flag(); + app_interceonnection_start_discoverable_adv( + INTERCONNECTION_BLE_FAST_ADVERTISING_INTERVAL, + APP_INTERCONNECTION_FAST_ADV_TIMEOUT_IN_MS); #endif } -bool app_bt_is_hfp_audio_on(void) -{ - bool hfp_audio_is_on = false; - for (uint8_t i=0; iaddress[0], addr->address[1], addr->address[2], addr->address[3], - addr->address[4], addr->address[5], name); +static bool app_bt_search_device_match(const bt_bdaddr_t *addr, + const char *name) { + TRACE(7, + "app_bt_search_callback found device %02x:%02x:%02x:%02x:%02x:%02x " + "'%s'\n", + addr->address[0], addr->address[1], addr->address[2], addr->address[3], + addr->address[4], addr->address[5], name); #if defined(HFP_MOBILE_AG_ROLE) - bt_bdaddr_t test_device1 = {{0xd2, 0x53, 0x86, 0x42, 0x71, 0x31}}; - bt_bdaddr_t test_device2 = {{0xd3, 0x53, 0x86, 0x42, 0x71, 0x31}}; - return (memcmp(addr, test_device1.address, sizeof(bt_bdaddr_t)) == 0 || - memcmp(addr, test_device2.address, sizeof(bt_bdaddr_t)) == 0); + bt_bdaddr_t test_device1 = {{0xd2, 0x53, 0x86, 0x42, 0x71, 0x31}}; + bt_bdaddr_t test_device2 = {{0xd3, 0x53, 0x86, 0x42, 0x71, 0x31}}; + return (memcmp(addr, test_device1.address, sizeof(bt_bdaddr_t)) == 0 || + memcmp(addr, test_device2.address, sizeof(bt_bdaddr_t)) == 0); #else - return false; + return false; #endif } static struct app_bt_search_t g_bt_search; -static void app_bt_search_callback(const btif_event_t* event) -{ - TRACE(2,"%s event %d\n", __func__, btif_me_get_callback_event_type(event)); +static void app_bt_search_callback(const btif_event_t *event) { + TRACE(2, "%s event %d\n", __func__, btif_me_get_callback_event_type(event)); - switch(btif_me_get_callback_event_type(event)) - { - case BTIF_BTEVENT_INQUIRY_RESULT: - { - bt_bdaddr_t *addr = btif_me_get_callback_event_inq_result_bd_addr(event); - uint8_t mode = btif_me_get_callback_event_inq_result_inq_mode(event); - const int NAME_MAX_LEN = 255; - char device_name[NAME_MAX_LEN+1] = {0}; - int device_name_len = 0; - uint8_t *eir = NULL; + switch (btif_me_get_callback_event_type(event)) { + case BTIF_BTEVENT_INQUIRY_RESULT: { + bt_bdaddr_t *addr = btif_me_get_callback_event_inq_result_bd_addr(event); + uint8_t mode = btif_me_get_callback_event_inq_result_inq_mode(event); + const int NAME_MAX_LEN = 255; + char device_name[NAME_MAX_LEN + 1] = {0}; + int device_name_len = 0; + uint8_t *eir = NULL; - if ((mode == BTIF_INQ_MODE_EXTENDED) && - (eir = btif_me_get_callback_event_inq_result_ext_inq_resp(event))) - { - device_name_len = btif_me_get_ext_inq_data(eir, 0x09, (uint8_t *)device_name, NAME_MAX_LEN); - } + if ((mode == BTIF_INQ_MODE_EXTENDED) && + (eir = btif_me_get_callback_event_inq_result_ext_inq_resp(event))) { + device_name_len = btif_me_get_ext_inq_data( + eir, 0x09, (uint8_t *)device_name, NAME_MAX_LEN); + } - if (app_bt_search_device_match(addr, device_name_len > 0 ? device_name : "")) - { - g_bt_search.address = *addr; - g_bt_search.device_searched = true; - btif_me_cancel_inquiry(); - } - } - break; - case BTIF_BTEVENT_INQUIRY_COMPLETE: - case BTIF_BTEVENT_INQUIRY_CANCELED: - btif_me_unregister_globa_handler((btif_handler *)btif_me_get_bt_handler()); - g_bt_search.search_start = false; - g_bt_search.inquiry_pending = false; - if (g_bt_search.device_searched) - { + if (app_bt_search_device_match(addr, + device_name_len > 0 ? device_name : "")) { + g_bt_search.address = *addr; + g_bt_search.device_searched = true; + btif_me_cancel_inquiry(); + } + } break; + case BTIF_BTEVENT_INQUIRY_COMPLETE: + case BTIF_BTEVENT_INQUIRY_CANCELED: + btif_me_unregister_globa_handler((btif_handler *)btif_me_get_bt_handler()); + g_bt_search.search_start = false; + g_bt_search.inquiry_pending = false; + if (g_bt_search.device_searched) { #if defined(HFP_MOBILE_AG_ROLE) - bt_profile_manager[BT_DEVICE_ID_1].reconnect_mode = bt_profile_reconnect_null; - bt_profile_manager[BT_DEVICE_ID_1].rmt_addr = g_bt_search.address; - bt_profile_manager[BT_DEVICE_ID_1].chan = app_bt_device.hf_channel[BT_DEVICE_ID_1]; - app_bt_precheck_before_starting_connecting(bt_profile_manager[BT_DEVICE_ID_1].has_connected); - app_bt_HF_CreateServiceLink(bt_profile_manager[BT_DEVICE_ID_1].chan, &bt_profile_manager[BT_DEVICE_ID_1].rmt_addr); + bt_profile_manager[BT_DEVICE_ID_1].reconnect_mode = + bt_profile_reconnect_null; + bt_profile_manager[BT_DEVICE_ID_1].rmt_addr = g_bt_search.address; + bt_profile_manager[BT_DEVICE_ID_1].chan = + app_bt_device.hf_channel[BT_DEVICE_ID_1]; + app_bt_precheck_before_starting_connecting( + bt_profile_manager[BT_DEVICE_ID_1].has_connected); + app_bt_HF_CreateServiceLink(bt_profile_manager[BT_DEVICE_ID_1].chan, + &bt_profile_manager[BT_DEVICE_ID_1].rmt_addr); #endif - } - else - { - TRACE(1,"%s no device matched\n", __func__); + } else { + TRACE(1, "%s no device matched\n", __func__); #if 0 /* continue to search ??? */ app_bt_start_search(); #endif - } - break; - default: - break; } + break; + default: + break; + } } -void app_bt_start_search(void) -{ - uint8_t max_search_time = 10; /* 12.8s */ +void app_bt_start_search(void) { + uint8_t max_search_time = 10; /* 12.8s */ - if (g_bt_search.search_start) - { - TRACE(1,"%s already started\n", __func__); - return; - } + if (g_bt_search.search_start) { + TRACE(1, "%s already started\n", __func__); + return; + } - btif_me_set_handler(btif_me_get_bt_handler(), app_bt_search_callback); + btif_me_set_handler(btif_me_get_bt_handler(), app_bt_search_callback); - btif_me_set_event_mask(btif_me_get_bt_handler(), - BTIF_BEM_INQUIRY_RESULT | BTIF_BEM_INQUIRY_COMPLETE | BTIF_BEM_INQUIRY_CANCELED | - BTIF_BEM_LINK_CONNECT_IND | BTIF_BEM_LINK_CONNECT_CNF | BTIF_BEM_LINK_DISCONNECT | - BTIF_BEM_ROLE_CHANGE | BTIF_BEM_MODE_CHANGE); + btif_me_set_event_mask( + btif_me_get_bt_handler(), + BTIF_BEM_INQUIRY_RESULT | BTIF_BEM_INQUIRY_COMPLETE | + BTIF_BEM_INQUIRY_CANCELED | BTIF_BEM_LINK_CONNECT_IND | + BTIF_BEM_LINK_CONNECT_CNF | BTIF_BEM_LINK_DISCONNECT | + BTIF_BEM_ROLE_CHANGE | BTIF_BEM_MODE_CHANGE); - btif_me_register_global_handler(btif_me_get_bt_handler()); + btif_me_register_global_handler(btif_me_get_bt_handler()); - g_bt_search.search_start = true; - g_bt_search.device_searched = false; - g_bt_search.inquiry_pending = false; + g_bt_search.search_start = true; + g_bt_search.device_searched = false; + g_bt_search.inquiry_pending = false; - if (BT_STS_PENDING != btif_me_inquiry(BTIF_BT_IAC_GIAC, max_search_time, 0)) - { - TRACE(1,"%s start inquiry failed\n", __func__); - g_bt_search.inquiry_pending = true; - } + if (BT_STS_PENDING != btif_me_inquiry(BTIF_BT_IAC_GIAC, max_search_time, 0)) { + TRACE(1, "%s start inquiry failed\n", __func__); + g_bt_search.inquiry_pending = true; + } } -uint8_t app_bt_avrcp_get_notify_trans_id(void) -{ - return btif_a2dp_get_avrcpadvancedpdu_trans_id(app_bt_device.avrcp_notify_rsp[BT_DEVICE_ID_1]); +uint8_t app_bt_avrcp_get_notify_trans_id(void) { + return btif_a2dp_get_avrcpadvancedpdu_trans_id( + app_bt_device.avrcp_notify_rsp[BT_DEVICE_ID_1]); } -void app_bt_avrcp_set_notify_trans_id(uint8_t trans_id) -{ - TRACE(3,"%s %d %p\n", __func__, trans_id, app_bt_device.avrcp_notify_rsp[BT_DEVICE_ID_1]); - btif_a2dp_set_avrcpadvancedpdu_trans_id(app_bt_device.avrcp_notify_rsp[BT_DEVICE_ID_1], trans_id); +void app_bt_avrcp_set_notify_trans_id(uint8_t trans_id) { + TRACE(3, "%s %d %p\n", __func__, trans_id, + app_bt_device.avrcp_notify_rsp[BT_DEVICE_ID_1]); + btif_a2dp_set_avrcpadvancedpdu_trans_id( + app_bt_device.avrcp_notify_rsp[BT_DEVICE_ID_1], trans_id); } -uint8_t app_bt_avrcp_get_ctl_trans_id(void) -{ - return btif_avrcp_get_ctl_trans_id(app_bt_device.avrcp_channel[BT_DEVICE_ID_1]); +uint8_t app_bt_avrcp_get_ctl_trans_id(void) { + return btif_avrcp_get_ctl_trans_id( + app_bt_device.avrcp_channel[BT_DEVICE_ID_1]); } -void app_bt_avrcp_set_ctl_trans_id(uint8_t trans_id) -{ - TRACE(3,"%s %d %p\n", __func__, trans_id, app_bt_device.avrcp_channel[BT_DEVICE_ID_1]); - btif_avrcp_set_ctl_trans_id(app_bt_device.avrcp_channel[BT_DEVICE_ID_1], trans_id); +void app_bt_avrcp_set_ctl_trans_id(uint8_t trans_id) { + TRACE(3, "%s %d %p\n", __func__, trans_id, + app_bt_device.avrcp_channel[BT_DEVICE_ID_1]); + btif_avrcp_set_ctl_trans_id(app_bt_device.avrcp_channel[BT_DEVICE_ID_1], + trans_id); } -void app_bt_set_mobile_a2dp_stream(uint32_t deviceId,a2dp_stream_t *stream) -{ - bt_profile_manager[deviceId].stream = stream; +void app_bt_set_mobile_a2dp_stream(uint32_t deviceId, a2dp_stream_t *stream) { + bt_profile_manager[deviceId].stream = stream; } #if defined(IBRT) #if defined(ENHANCED_STACK) -uint32_t app_bt_save_spp_app_ctx(uint32_t app_id,btif_remote_device_t *rem_dev, uint8_t *buf, uint32_t buf_len) -{ - bt_bdaddr_t *remote = NULL; - uint32_t offset = 0; - struct spp_device *device = (struct spp_device *)btif_spp_get_device(app_id); - ASSERT(device, "%s NULL spp device app_id=0x%x",__func__, app_id); +uint32_t app_bt_save_spp_app_ctx(uint32_t app_id, btif_remote_device_t *rem_dev, + uint8_t *buf, uint32_t buf_len) { + bt_bdaddr_t *remote = NULL; + uint32_t offset = 0; + struct spp_device *device = (struct spp_device *)btif_spp_get_device(app_id); + ASSERT(device, "%s NULL spp device app_id=0x%x", __func__, app_id); - // save app_id - buf[offset++] = app_id & 0xFF; - buf[offset++] = (app_id >> 8) & 0xFF; - buf[offset++] = (app_id >> 16) & 0xFF; - buf[offset++] = (app_id >> 24) & 0xFF; + // save app_id + buf[offset++] = app_id & 0xFF; + buf[offset++] = (app_id >> 8) & 0xFF; + buf[offset++] = (app_id >> 16) & 0xFF; + buf[offset++] = (app_id >> 24) & 0xFF; - // save port type - buf[offset++] = device->portType; + // save port type + buf[offset++] = device->portType; - //save remote address - remote = btif_me_get_remote_device_bdaddr(rem_dev); - memcpy(buf+offset, remote, sizeof(bt_bdaddr_t)); - offset += sizeof(bt_bdaddr_t); + // save remote address + remote = btif_me_get_remote_device_bdaddr(rem_dev); + memcpy(buf + offset, remote, sizeof(bt_bdaddr_t)); + offset += sizeof(bt_bdaddr_t); - //TRACE(7,"%s:%02x:%02x:%02x:%02x:%02x:%02x\r\n", - // __func__, remote->addr[5], remote->addr[4], remote->addr[3], - // remote->addr[2], remote->addr[1], remote->addr[0]); + // TRACE(7,"%s:%02x:%02x:%02x:%02x:%02x:%02x\r\n", + // __func__, remote->addr[5], remote->addr[4], remote->addr[3], + // remote->addr[2], remote->addr[1], remote->addr[0]); - //spp device - buf[offset++] = device->spp_connected_flag; + // spp device + buf[offset++] = device->spp_connected_flag; - return offset; + return offset; } -uint32_t app_bt_restore_spp_app_ctx(uint8_t *buf, uint32_t buf_len, uint32_t app_id) -{ - bt_bdaddr_t remote; - uint32_t offset = 0; - struct spp_device *device = NULL; - uint8_t i = 0; - uint8_t port_type = 0; - uint32_t app_id_restore = 0; +uint32_t app_bt_restore_spp_app_ctx(uint8_t *buf, uint32_t buf_len, + uint32_t app_id) { + bt_bdaddr_t remote; + uint32_t offset = 0; + struct spp_device *device = NULL; + uint8_t i = 0; + uint8_t port_type = 0; + uint32_t app_id_restore = 0; - // restore app_id - for (i=0; i<4; i++) - { - app_id_restore += (buf[offset+i]<<(8*i)); - } - offset += 4; + // restore app_id + for (i = 0; i < 4; i++) { + app_id_restore += (buf[offset + i] << (8 * i)); + } + offset += 4; - port_type = buf[offset++]; + port_type = buf[offset++]; - ASSERT(app_id_restore == app_id,"%s,spp app id mismatch=%x,%x",__func__,app_id_restore,app_id); + ASSERT(app_id_restore == app_id, "%s,spp app id mismatch=%x,%x", __func__, + app_id_restore, app_id); - // restore remote address - memcpy(&remote, buf+offset, sizeof(remote)); - offset += sizeof(remote); + // restore remote address + memcpy(&remote, buf + offset, sizeof(remote)); + offset += sizeof(remote); - device = (struct spp_device *)btif_spp_get_device(app_id); + device = (struct spp_device *)btif_spp_get_device(app_id); #ifdef __INTERCONNECTION__ - TRACE(1,"%s,%x,%x,%x", __func__,app_id,BTIF_APP_SPP_CLIENT_CCMP_ID,BTIF_APP_SPP_CLIENT_RED_ID); + TRACE(1, "%s,%x,%x,%x", __func__, app_id, BTIF_APP_SPP_CLIENT_CCMP_ID, + BTIF_APP_SPP_CLIENT_RED_ID); #endif - if (device == NULL) - { - /* - * SPP client device may not be created in bt host initialized stage,so IBRT SLAVE will restore it - */ - if (port_type == BTIF_SPP_CLIENT_PORT) - { - TRACE(1,"%s,spp client device null", __func__); - switch (app_id) - { + if (device == NULL) { + /* + * SPP client device may not be created in bt host initialized stage,so IBRT + * SLAVE will restore it + */ + if (port_type == BTIF_SPP_CLIENT_PORT) { + TRACE(1, "%s,spp client device null", __func__); + switch (app_id) { #ifdef __INTERCONNECTION__ - case BTIF_APP_SPP_CLIENT_CCMP_ID: - app_ccmp_client_open((uint8_t *)SppServiceSearchReq, app_interconnection_get_length(), 0, 1); - device = (struct spp_device *)btif_spp_get_device(BTIF_APP_SPP_CLIENT_CCMP_ID); - device->spp_callback = ccmp_callback; - //device->_channel = chnl; //restore in btif_spp_profile_restore_ctx - device->sppUsedFlag = 1; - break; + case BTIF_APP_SPP_CLIENT_CCMP_ID: + app_ccmp_client_open((uint8_t *)SppServiceSearchReq, + app_interconnection_get_length(), 0, 1); + device = (struct spp_device *)btif_spp_get_device( + BTIF_APP_SPP_CLIENT_CCMP_ID); + device->spp_callback = ccmp_callback; + // device->_channel = chnl; //restore in btif_spp_profile_restore_ctx + device->sppUsedFlag = 1; + break; - case BTIF_APP_SPP_CLIENT_RED_ID: - app_spp_client_open((uint8_t*)SppServiceSearchReq, app_interconnection_get_length(),1); - device = (struct spp_device *)btif_spp_get_device(BTIF_APP_SPP_CLIENT_RED_ID); - device->spp_callback = spp_client_callback; - //device->_channel = chnl; //restore in btif_spp_profile_restore_ctx - device->sppUsedFlag = 1; - break; + case BTIF_APP_SPP_CLIENT_RED_ID: + app_spp_client_open((uint8_t *)SppServiceSearchReq, + app_interconnection_get_length(), 1); + device = (struct spp_device *)btif_spp_get_device( + BTIF_APP_SPP_CLIENT_RED_ID); + device->spp_callback = spp_client_callback; + // device->_channel = chnl; //restore in btif_spp_profile_restore_ctx + device->sppUsedFlag = 1; + break; #endif - default: - ASSERT(device, "%s NULL spp client device app_id=0x%x", __func__, app_id); - break; - } - } - else - { - ASSERT(device, "%s NULL spp server device app_id=0x%x", __func__, app_id); - } + default: + ASSERT(device, "%s NULL spp client device app_id=0x%x", __func__, + app_id); + break; + } + } else { + ASSERT(device, "%s NULL spp server device app_id=0x%x", __func__, app_id); } + } #ifdef __INTERCONNECTION__ - if (app_id == BTIF_APP_SPP_CLIENT_RED_ID) - { - //btm_conn will NULL if only SPP profile since btm_conn restore later - app_bt_set_spp_device_ptr((btif_remote_device_t *)btif_me_get_remote_device_by_bdaddr(&remote)); - } + if (app_id == BTIF_APP_SPP_CLIENT_RED_ID) { + // btm_conn will NULL if only SPP profile since btm_conn restore later + app_bt_set_spp_device_ptr( + (btif_remote_device_t *)btif_me_get_remote_device_by_bdaddr(&remote)); + } #endif - //restore spp device - device->portType = port_type; - device->spp_connected_flag = buf[offset++]; - - return offset; + // restore spp device + device->portType = port_type; + device->spp_connected_flag = buf[offset++]; + return offset; } -uint32_t app_bt_save_hfp_app_ctx(btif_remote_device_t *rem_dev, uint8_t *buf, uint32_t buf_len) -{ - BTIF_CTX_INIT(buf); +uint32_t app_bt_save_hfp_app_ctx(btif_remote_device_t *rem_dev, uint8_t *buf, + uint32_t buf_len) { + BTIF_CTX_INIT(buf); - BTIF_CTX_STR_BUF(btif_me_get_remote_device_bdaddr(rem_dev), BTIF_BD_ADDR_SIZE); + BTIF_CTX_STR_BUF(btif_me_get_remote_device_bdaddr(rem_dev), + BTIF_BD_ADDR_SIZE); - BTIF_CTX_STR_VAL8(app_bt_device.hfchan_call[BT_DEVICE_ID_1]); - BTIF_CTX_STR_VAL8(app_bt_device.hfchan_callSetup[BT_DEVICE_ID_1]); - BTIF_CTX_STR_VAL8(app_bt_device.hf_callheld[BT_DEVICE_ID_1]); + BTIF_CTX_STR_VAL8(app_bt_device.hfchan_call[BT_DEVICE_ID_1]); + BTIF_CTX_STR_VAL8(app_bt_device.hfchan_callSetup[BT_DEVICE_ID_1]); + BTIF_CTX_STR_VAL8(app_bt_device.hf_callheld[BT_DEVICE_ID_1]); - BTIF_CTX_SAVE_UPDATE_DATA_LEN(); - return BTIF_CTX_GET_TOTAL_LEN(); + BTIF_CTX_SAVE_UPDATE_DATA_LEN(); + return BTIF_CTX_GET_TOTAL_LEN(); } -uint32_t app_bt_restore_hfp_app_ctx(uint8_t *buf, uint32_t buf_len) -{ - bt_bdaddr_t remote; - uint8_t call, callsetup, callheld; - BTIF_CTX_INIT(buf); +uint32_t app_bt_restore_hfp_app_ctx(uint8_t *buf, uint32_t buf_len) { + bt_bdaddr_t remote; + uint8_t call, callsetup, callheld; + BTIF_CTX_INIT(buf); - BTIF_CTX_LDR_BUF(&remote, BTIF_BD_ADDR_SIZE); + BTIF_CTX_LDR_BUF(&remote, BTIF_BD_ADDR_SIZE); - BTIF_CTX_LDR_VAL8(call); - BTIF_CTX_LDR_VAL8(callsetup); - BTIF_CTX_LDR_VAL8(callheld); + BTIF_CTX_LDR_VAL8(call); + BTIF_CTX_LDR_VAL8(callsetup); + BTIF_CTX_LDR_VAL8(callheld); - app_bt_device.hfchan_call[BT_DEVICE_ID_1] = call; - app_bt_device.hfchan_callSetup[BT_DEVICE_ID_1] = callsetup; - app_bt_device.hf_callheld[BT_DEVICE_ID_1] = callheld; + app_bt_device.hfchan_call[BT_DEVICE_ID_1] = call; + app_bt_device.hfchan_callSetup[BT_DEVICE_ID_1] = callsetup; + app_bt_device.hf_callheld[BT_DEVICE_ID_1] = callheld; - TRACE(4,"%s call %d callsetup %d callheld %d", __func__, call, callsetup, callheld); + TRACE(4, "%s call %d callsetup %d callheld %d", __func__, call, callsetup, + callheld); - return BTIF_CTX_GET_TOTAL_LEN(); + return BTIF_CTX_GET_TOTAL_LEN(); } -uint32_t app_bt_save_a2dp_app_ctx(btif_remote_device_t *rem_dev, uint8_t *buf, uint32_t buf_len) -{ - uint32_t offset = 0; - unsigned char stream_enc = 0; - uint32_t factor = 0; +uint32_t app_bt_save_a2dp_app_ctx(btif_remote_device_t *rem_dev, uint8_t *buf, + uint32_t buf_len) { + uint32_t offset = 0; + unsigned char stream_enc = 0; + uint32_t factor = 0; - // TODO - // more codecs, BT_DEVICE_ID_2 - if (bt_profile_manager[BT_DEVICE_ID_1].stream == app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream) - { - stream_enc = 0; - } + // TODO + // more codecs, BT_DEVICE_ID_2 + if (bt_profile_manager[BT_DEVICE_ID_1].stream == + app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream) { + stream_enc = 0; + } #if defined(A2DP_AAC_ON) - else if (bt_profile_manager[BT_DEVICE_ID_1].stream == app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream) - { - stream_enc = 1; - } + else if (bt_profile_manager[BT_DEVICE_ID_1].stream == + app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream) { + stream_enc = 1; + } #endif #if defined(A2DP_LHDC_ON) - else if (bt_profile_manager[BT_DEVICE_ID_1].stream == app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_1]->a2dp_stream) - { - stream_enc = 2; - } + else if (bt_profile_manager[BT_DEVICE_ID_1].stream == + app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_1]->a2dp_stream) { + stream_enc = 2; + } #endif #if defined(A2DP_LDAC_ON) - else if (bt_profile_manager[BT_DEVICE_ID_1].stream == app_bt_device.a2dp_ldac_stream[BT_DEVICE_ID_1]->a2dp_stream) - { - stream_enc = 2; - } + else if (bt_profile_manager[BT_DEVICE_ID_1].stream == + app_bt_device.a2dp_ldac_stream[BT_DEVICE_ID_1]->a2dp_stream) { + stream_enc = 2; + } #endif + buf[offset++] = stream_enc; + memcpy(buf + offset, btif_me_get_remote_device_bdaddr(rem_dev), + BTIF_BD_ADDR_SIZE); + offset += BTIF_BD_ADDR_SIZE; - buf[offset++] = stream_enc; - memcpy(buf+offset,btif_me_get_remote_device_bdaddr(rem_dev),BTIF_BD_ADDR_SIZE); - offset += BTIF_BD_ADDR_SIZE; + buf[offset++] = app_bt_device.a2dp_state[BT_DEVICE_ID_1]; + buf[offset++] = app_bt_device.a2dp_play_pause_flag; + buf[offset++] = avrcp_get_media_status(); - buf[offset++] = app_bt_device.a2dp_state[BT_DEVICE_ID_1]; - buf[offset++] = app_bt_device.a2dp_play_pause_flag; - buf[offset++] = avrcp_get_media_status(); - - //codec - buf[offset++] = app_bt_device.codec_type[BT_DEVICE_ID_1]; - buf[offset++] = app_bt_device.sample_rate[BT_DEVICE_ID_1]; - buf[offset++] = app_bt_device.sample_bit[BT_DEVICE_ID_1]; + // codec + buf[offset++] = app_bt_device.codec_type[BT_DEVICE_ID_1]; + buf[offset++] = app_bt_device.sample_rate[BT_DEVICE_ID_1]; + buf[offset++] = app_bt_device.sample_bit[BT_DEVICE_ID_1]; #if defined(A2DP_LHDC_ON) - buf[offset++] = app_bt_device.a2dp_lhdc_llc[BT_DEVICE_ID_1]; + buf[offset++] = app_bt_device.a2dp_lhdc_llc[BT_DEVICE_ID_1]; #endif #if defined(__A2DP_AVDTP_CP__) - buf[offset++] = app_bt_device.avdtp_cp[BT_DEVICE_ID_1]; + buf[offset++] = app_bt_device.avdtp_cp[BT_DEVICE_ID_1]; #endif - //volume - buf[offset++] = (uint8_t)a2dp_volume_get(BT_DEVICE_ID_1); + // volume + buf[offset++] = (uint8_t)a2dp_volume_get(BT_DEVICE_ID_1); - //latency factor - factor = (uint32_t)a2dp_audio_latency_factor_get(); - buf[offset++] = factor & 0xFF; - buf[offset++] = (factor >> 8) & 0xFF; - buf[offset++] = (factor >> 16) & 0xFF; - buf[offset++] = (factor >> 24) & 0xFF; + // latency factor + factor = (uint32_t)a2dp_audio_latency_factor_get(); + buf[offset++] = factor & 0xFF; + buf[offset++] = (factor >> 8) & 0xFF; + buf[offset++] = (factor >> 16) & 0xFF; + buf[offset++] = (factor >> 24) & 0xFF; - //a2dp session - buf[offset++] = a2dp_ibrt_session_get() & 0xFF; - buf[offset++] = (a2dp_ibrt_session_get() >> 8) & 0xFF; - buf[offset++] = (a2dp_ibrt_session_get() >> 16) & 0xFF; - buf[offset++] = (a2dp_ibrt_session_get() >> 24) & 0xFF; + // a2dp session + buf[offset++] = a2dp_ibrt_session_get() & 0xFF; + buf[offset++] = (a2dp_ibrt_session_get() >> 8) & 0xFF; + buf[offset++] = (a2dp_ibrt_session_get() >> 16) & 0xFF; + buf[offset++] = (a2dp_ibrt_session_get() >> 24) & 0xFF; - return offset; + return offset; } -uint32_t app_bt_restore_a2dp_app_ctx(uint8_t *buf, uint32_t buf_len) -{ - uint32_t offset = 0; - bt_bdaddr_t remote; - unsigned char stream_enc = 0; +uint32_t app_bt_restore_a2dp_app_ctx(uint8_t *buf, uint32_t buf_len) { + uint32_t offset = 0; + bt_bdaddr_t remote; + unsigned char stream_enc = 0; - stream_enc = buf[offset++]; + stream_enc = buf[offset++]; - memcpy(&remote,buf+offset,BTIF_BD_ADDR_SIZE); - offset += BTIF_BD_ADDR_SIZE; + memcpy(&remote, buf + offset, BTIF_BD_ADDR_SIZE); + offset += BTIF_BD_ADDR_SIZE; + app_bt_device.a2dp_state[BT_DEVICE_ID_1] = buf[offset++]; + app_bt_device.a2dp_play_pause_flag = buf[offset++]; + avrcp_set_media_status(buf[offset++]); - app_bt_device.a2dp_state[BT_DEVICE_ID_1] = buf[offset++]; - app_bt_device.a2dp_play_pause_flag = buf[offset++]; - avrcp_set_media_status(buf[offset++]); - - //codec info - app_bt_device.codec_type[BT_DEVICE_ID_1] = buf[offset++]; - app_bt_device.sample_rate[BT_DEVICE_ID_1] = buf[offset++]; - app_bt_device.sample_bit[BT_DEVICE_ID_1] = buf[offset++]; + // codec info + app_bt_device.codec_type[BT_DEVICE_ID_1] = buf[offset++]; + app_bt_device.sample_rate[BT_DEVICE_ID_1] = buf[offset++]; + app_bt_device.sample_bit[BT_DEVICE_ID_1] = buf[offset++]; #if defined(A2DP_LHDC_ON) - app_bt_device.a2dp_lhdc_llc[BT_DEVICE_ID_1] = buf[offset++]; + app_bt_device.a2dp_lhdc_llc[BT_DEVICE_ID_1] = buf[offset++]; #endif #if defined(__A2DP_AVDTP_CP__) - app_bt_device.avdtp_cp[BT_DEVICE_ID_1] = buf[offset++]; + app_bt_device.avdtp_cp[BT_DEVICE_ID_1] = buf[offset++]; #endif - //volume - a2dp_volume_set(BT_DEVICE_ID_1, buf[offset++]); + // volume + a2dp_volume_set(BT_DEVICE_ID_1, buf[offset++]); - //latency factor - a2dp_audio_latency_factor_set((float)(buf[offset] + (buf[offset+1] << 8) + (buf[offset+2] << 16) + (buf[offset+3] << 24))); - offset += 4; + // latency factor + a2dp_audio_latency_factor_set((float)(buf[offset] + (buf[offset + 1] << 8) + + (buf[offset + 2] << 16) + + (buf[offset + 3] << 24))); + offset += 4; - //a2dp session - a2dp_ibrt_session_set((buf[offset] + (buf[offset+1] << 8) + (buf[offset+2] << 16) + (buf[offset+3] << 24))); - offset += 4; + // a2dp session + a2dp_ibrt_session_set((buf[offset] + (buf[offset + 1] << 8) + + (buf[offset + 2] << 16) + (buf[offset + 3] << 24))); + offset += 4; - // TODO - // more codecs, BT_DEVICE_ID_2 - if (stream_enc == 0) - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream; - } + // TODO + // more codecs, BT_DEVICE_ID_2 + if (stream_enc == 0) { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream; + } #if defined(A2DP_AAC_ON) - else if (stream_enc == 1) - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream; - } + else if (stream_enc == 1) { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream; + } #endif #if defined(A2DP_LHDC_ON) - else if (stream_enc == 2) - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_1]->a2dp_stream; - } + else if (stream_enc == 2) { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_1]->a2dp_stream; + } #endif #if defined(A2DP_LDAC_ON) - else if (stream_enc == 2) - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_ldac_stream[BT_DEVICE_ID_1]->a2dp_stream; - } + else if (stream_enc == 2) { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_ldac_stream[BT_DEVICE_ID_1]->a2dp_stream; + } #endif - memcpy(bt_profile_manager[BT_DEVICE_ID_1].rmt_addr.address, &remote, BTIF_BD_ADDR_SIZE); - bt_profile_manager[BT_DEVICE_ID_1].a2dp_connect = bt_profile_connect_status_success; - bt_profile_manager[BT_DEVICE_ID_1].hfp_connect = bt_profile_connect_status_success; - bt_profile_manager[BT_DEVICE_ID_1].has_connected = true; + memcpy(bt_profile_manager[BT_DEVICE_ID_1].rmt_addr.address, &remote, + BTIF_BD_ADDR_SIZE); + bt_profile_manager[BT_DEVICE_ID_1].a2dp_connect = + bt_profile_connect_status_success; + bt_profile_manager[BT_DEVICE_ID_1].hfp_connect = + bt_profile_connect_status_success; + bt_profile_manager[BT_DEVICE_ID_1].has_connected = true; - return offset; + return offset; } -uint32_t app_bt_save_avrcp_app_ctx(btif_remote_device_t *rem_dev, uint8_t *buf, uint32_t buf_len) -{ - uint32_t offset = 0; +uint32_t app_bt_save_avrcp_app_ctx(btif_remote_device_t *rem_dev, uint8_t *buf, + uint32_t buf_len) { + uint32_t offset = 0; - buf[offset++] = app_bt_device.avrcp_state[BT_DEVICE_ID_1]; - buf[offset++] = app_bt_device.volume_report[BT_DEVICE_ID_1]; + buf[offset++] = app_bt_device.avrcp_state[BT_DEVICE_ID_1]; + buf[offset++] = app_bt_device.volume_report[BT_DEVICE_ID_1]; - if (app_bt_device.avrcp_notify_rsp[BT_DEVICE_ID_1]) - { - buf[offset++] = true; - buf[offset++] = app_bt_avrcp_get_notify_trans_id(); - } - else - { - buf[offset++] = false; - buf[offset++] = 0; - } + if (app_bt_device.avrcp_notify_rsp[BT_DEVICE_ID_1]) { + buf[offset++] = true; + buf[offset++] = app_bt_avrcp_get_notify_trans_id(); + } else { + buf[offset++] = false; + buf[offset++] = 0; + } - return offset; + return offset; } -uint32_t app_bt_restore_avrcp_app_ctx(uint8_t *buf, uint32_t buf_len) -{ - uint32_t offset = 0; - uint8_t notify_rsp_exist = 0; - uint8_t trans_id = 0; +uint32_t app_bt_restore_avrcp_app_ctx(uint8_t *buf, uint32_t buf_len) { + uint32_t offset = 0; + uint8_t notify_rsp_exist = 0; + uint8_t trans_id = 0; - app_bt_device.avrcp_state[BT_DEVICE_ID_1] = buf[offset++]; - app_bt_device.volume_report[BT_DEVICE_ID_1] = buf[offset++]; - notify_rsp_exist = buf[offset++]; - trans_id = buf[offset++]; + app_bt_device.avrcp_state[BT_DEVICE_ID_1] = buf[offset++]; + app_bt_device.volume_report[BT_DEVICE_ID_1] = buf[offset++]; + notify_rsp_exist = buf[offset++]; + trans_id = buf[offset++]; - TRACE(4,"app_bt_restore_avrcp_app_ctx state %d report %d notify %d %d\n", - app_bt_device.avrcp_state[BT_DEVICE_ID_1], app_bt_device.volume_report[BT_DEVICE_ID_1], notify_rsp_exist, trans_id); + TRACE(4, "app_bt_restore_avrcp_app_ctx state %d report %d notify %d %d\n", + app_bt_device.avrcp_state[BT_DEVICE_ID_1], + app_bt_device.volume_report[BT_DEVICE_ID_1], notify_rsp_exist, + trans_id); - if (notify_rsp_exist && app_bt_device.avrcp_notify_rsp[BT_DEVICE_ID_1] == NULL) - { - btif_app_a2dp_avrcpadvancedpdu_mempool_calloc(&app_bt_device.avrcp_notify_rsp[BT_DEVICE_ID_1]); - } + if (notify_rsp_exist && + app_bt_device.avrcp_notify_rsp[BT_DEVICE_ID_1] == NULL) { + btif_app_a2dp_avrcpadvancedpdu_mempool_calloc( + &app_bt_device.avrcp_notify_rsp[BT_DEVICE_ID_1]); + } - app_bt_avrcp_set_notify_trans_id(trans_id); + app_bt_avrcp_set_notify_trans_id(trans_id); - return offset; + return offset; } #ifdef __BTMAP_ENABLE__ -uint32_t app_bt_save_map_app_ctx(btif_remote_device_t *rem_dev, uint8_t *buf, uint32_t buf_len) -{ - //struct bdaddr_t *remote = NULL; - uint32_t offset = 0; +uint32_t app_bt_save_map_app_ctx(btif_remote_device_t *rem_dev, uint8_t *buf, + uint32_t buf_len) { + // struct bdaddr_t *remote = NULL; + uint32_t offset = 0; - memcpy((void *)buf, (void *)app_bt_device.map_session_handle, sizeof(app_bt_device.map_session_handle)); - offset += sizeof(app_bt_device.map_session_handle); + memcpy((void *)buf, (void *)app_bt_device.map_session_handle, + sizeof(app_bt_device.map_session_handle)); + offset += sizeof(app_bt_device.map_session_handle); - return offset; + return offset; } -uint32_t app_bt_restore_map_app_ctx(uint8_t *buf, uint32_t buf_len) -{ - uint32_t offset = 0; +uint32_t app_bt_restore_map_app_ctx(uint8_t *buf, uint32_t buf_len) { + uint32_t offset = 0; - memcpy((void *)app_bt_device.map_session_handle, (void *)buf, sizeof(btif_map_session_handle_t)); - offset += sizeof(btif_map_session_handle_t); + memcpy((void *)app_bt_device.map_session_handle, (void *)buf, + sizeof(btif_map_session_handle_t)); + offset += sizeof(btif_map_session_handle_t); - return offset; + return offset; } #endif #if BTIF_HID_DEVICE -uint32_t app_bt_save_hid_app_ctx(uint8_t *buf) -{ - uint32_t offset = 0; - - if(app_bt_device.hid_channel == NULL) - { - TRACE(0, "app_bt_save_hid_app_ctx app_bt_device.hid_channel is NULL"); - return offset; - } - - memcpy((void *)buf, (void *)app_bt_device.hid_channel, sizeof(app_bt_device.hid_channel)); - offset += sizeof(app_bt_device.hid_channel); +uint32_t app_bt_save_hid_app_ctx(uint8_t *buf) { + uint32_t offset = 0; + if (app_bt_device.hid_channel == NULL) { + TRACE(0, "app_bt_save_hid_app_ctx app_bt_device.hid_channel is NULL"); return offset; + } + + memcpy((void *)buf, (void *)app_bt_device.hid_channel, + sizeof(app_bt_device.hid_channel)); + offset += sizeof(app_bt_device.hid_channel); + + return offset; } -uint32_t app_bt_restore_hid_app_ctx(uint8_t *buf) -{ - uint32_t offset = 0; +uint32_t app_bt_restore_hid_app_ctx(uint8_t *buf) { + uint32_t offset = 0; - memcpy((void *)app_bt_device.hid_channel, (void *)buf, sizeof(hid_channel_t)); - offset += sizeof(hid_channel_t); + memcpy((void *)app_bt_device.hid_channel, (void *)buf, sizeof(hid_channel_t)); + offset += sizeof(hid_channel_t); - return offset; + return offset; +} +#else +uint32_t app_bt_restore_hid_app_ctx(uint8_t *buf) { return 4; } +uint32_t app_bt_save_hid_app_ctx(uint8_t *buf) { + buf[0] = 0; + buf[1] = 0; + buf[2] = 0; + buf[3] = 0; + return 4; } -#else -uint32_t app_bt_restore_hid_app_ctx(uint8_t *buf) -{return 4;} -uint32_t app_bt_save_hid_app_ctx(uint8_t *buf) -{ - buf[0]=0; - buf[1]=0; - buf[2]=0; - buf[3]=0; - return 4;} #endif #endif /* ENHANCED_STACK */ -a2dp_stream_t * app_bt_get_mobile_a2dp_stream(uint32_t deviceId) -{ - return bt_profile_manager[deviceId].stream; +a2dp_stream_t *app_bt_get_mobile_a2dp_stream(uint32_t deviceId) { + return bt_profile_manager[deviceId].stream; } -void app_bt_update_bt_profile_manager(void) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); +void app_bt_update_bt_profile_manager(void) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - memcpy(bt_profile_manager[BT_DEVICE_ID_1].rmt_addr.address, p_ibrt_ctrl->mobile_addr.address, BTIF_BD_ADDR_SIZE); + memcpy(bt_profile_manager[BT_DEVICE_ID_1].rmt_addr.address, + p_ibrt_ctrl->mobile_addr.address, BTIF_BD_ADDR_SIZE); #if defined(A2DP_AAC_ON) - if(p_ibrt_ctrl->a2dp_codec.codec_type == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream; + if (p_ibrt_ctrl->a2dp_codec.codec_type == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream; - } - else + } else #endif #if defined(A2DP_SCALABLE_ON) - if (p_ibrt_ctrl->a2dp_codec.codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_1]->a2dp_stream; - } - else + if (p_ibrt_ctrl->a2dp_codec.codec_type == + BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_1]->a2dp_stream; + } else #endif #if defined(A2DP_LHDC_ON) - if (p_ibrt_ctrl->a2dp_codec.codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_1]->a2dp_stream; - } - else + if (p_ibrt_ctrl->a2dp_codec.codec_type == + BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_1]->a2dp_stream; + } else #endif #if defined(A2DP_LDAC_ON) - if (p_ibrt_ctrl->a2dp_codec.codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_ldac_stream[BT_DEVICE_ID_1]->a2dp_stream; - } - else + if (p_ibrt_ctrl->a2dp_codec.codec_type == + BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_ldac_stream[BT_DEVICE_ID_1]->a2dp_stream; + } else #endif - if (p_ibrt_ctrl->a2dp_codec.codec_type == BTIF_AVDTP_CODEC_TYPE_SBC) - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream; - } - else - { - ASSERT(0, "%s err codec_type:%d ", __func__, p_ibrt_ctrl->a2dp_codec.codec_type); - } + if (p_ibrt_ctrl->a2dp_codec.codec_type == BTIF_AVDTP_CODEC_TYPE_SBC) { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream; + } else { + ASSERT(0, "%s err codec_type:%d ", __func__, + p_ibrt_ctrl->a2dp_codec.codec_type); + } - bt_profile_manager[BT_DEVICE_ID_1].a2dp_connect = bt_profile_connect_status_success; - bt_profile_manager[BT_DEVICE_ID_1].hfp_connect = bt_profile_connect_status_success; - bt_profile_manager[BT_DEVICE_ID_1].has_connected = true; + bt_profile_manager[BT_DEVICE_ID_1].a2dp_connect = + bt_profile_connect_status_success; + bt_profile_manager[BT_DEVICE_ID_1].hfp_connect = + bt_profile_connect_status_success; + bt_profile_manager[BT_DEVICE_ID_1].has_connected = true; - TRACE(3,"%s codec_type:%x if_a2dp_stream:%p", __func__, p_ibrt_ctrl->a2dp_codec.codec_type, bt_profile_manager[BT_DEVICE_ID_1].stream); - DUMP8("%02x ", bt_profile_manager[BT_DEVICE_ID_1].rmt_addr.address, BTIF_BD_ADDR_SIZE); + TRACE(3, "%s codec_type:%x if_a2dp_stream:%p", __func__, + p_ibrt_ctrl->a2dp_codec.codec_type, + bt_profile_manager[BT_DEVICE_ID_1].stream); + DUMP8("%02x ", bt_profile_manager[BT_DEVICE_ID_1].rmt_addr.address, + BTIF_BD_ADDR_SIZE); } -void app_bt_update_bt_profile_manager_codec_type(uint8_t codec_type) -{ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); +void app_bt_update_bt_profile_manager_codec_type(uint8_t codec_type) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - p_ibrt_ctrl->a2dp_codec.codec_type = codec_type; + p_ibrt_ctrl->a2dp_codec.codec_type = codec_type; #if defined(A2DP_AAC_ON) - if(p_ibrt_ctrl->a2dp_codec.codec_type == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream; + if (p_ibrt_ctrl->a2dp_codec.codec_type == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream; - } - else + } else #endif #if defined(A2DP_SCALABLE_ON) - if (p_ibrt_ctrl->a2dp_codec.codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_1]->a2dp_stream; - } - else + if (p_ibrt_ctrl->a2dp_codec.codec_type == + BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_1]->a2dp_stream; + } else #endif #if defined(A2DP_LHDC_ON) - if (p_ibrt_ctrl->a2dp_codec.codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_1]->a2dp_stream; - } - else + if (p_ibrt_ctrl->a2dp_codec.codec_type == + BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_1]->a2dp_stream; + } else #endif #if defined(A2DP_LDAC_ON) - if (p_ibrt_ctrl->a2dp_codec.codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_ldac_stream[BT_DEVICE_ID_1]->a2dp_stream; - } - else + if (p_ibrt_ctrl->a2dp_codec.codec_type == + BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_ldac_stream[BT_DEVICE_ID_1]->a2dp_stream; + } else #endif - if (p_ibrt_ctrl->a2dp_codec.codec_type == BTIF_AVDTP_CODEC_TYPE_SBC) - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream; - } - else - { - ASSERT(0, "%s err codec_type:%d ", __func__, p_ibrt_ctrl->a2dp_codec.codec_type); - } + if (p_ibrt_ctrl->a2dp_codec.codec_type == BTIF_AVDTP_CODEC_TYPE_SBC) { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream; + } else { + ASSERT(0, "%s err codec_type:%d ", __func__, + p_ibrt_ctrl->a2dp_codec.codec_type); + } - bt_profile_manager[BT_DEVICE_ID_1].a2dp_connect = bt_profile_connect_status_success; - bt_profile_manager[BT_DEVICE_ID_1].hfp_connect = bt_profile_connect_status_success; - bt_profile_manager[BT_DEVICE_ID_1].has_connected = true; + bt_profile_manager[BT_DEVICE_ID_1].a2dp_connect = + bt_profile_connect_status_success; + bt_profile_manager[BT_DEVICE_ID_1].hfp_connect = + bt_profile_connect_status_success; + bt_profile_manager[BT_DEVICE_ID_1].has_connected = true; - TRACE(3,"%s codec_type:%x if_a2dp_stream:%p", __func__, p_ibrt_ctrl->a2dp_codec.codec_type, bt_profile_manager[BT_DEVICE_ID_1].stream); + TRACE(3, "%s codec_type:%x if_a2dp_stream:%p", __func__, + p_ibrt_ctrl->a2dp_codec.codec_type, + bt_profile_manager[BT_DEVICE_ID_1].stream); } static bool ibrt_reconnect_mobile_profile_flag = false; -void app_bt_ibrt_reconnect_mobile_profile_flag_set(void) -{ - ibrt_reconnect_mobile_profile_flag = true; +void app_bt_ibrt_reconnect_mobile_profile_flag_set(void) { + ibrt_reconnect_mobile_profile_flag = true; } -void app_bt_ibrt_reconnect_mobile_profile_flag_clear(void) -{ - ibrt_reconnect_mobile_profile_flag = false; +void app_bt_ibrt_reconnect_mobile_profile_flag_clear(void) { + ibrt_reconnect_mobile_profile_flag = false; } -bool app_bt_ibrt_reconnect_mobile_profile_flag_get(void) -{ - return ibrt_reconnect_mobile_profile_flag; +bool app_bt_ibrt_reconnect_mobile_profile_flag_get(void) { + return ibrt_reconnect_mobile_profile_flag; } -void app_bt_ibrt_reconnect_mobile_profile(bt_bdaddr_t mobile_addr) -{ - nvrec_btdevicerecord *mobile_record = NULL; +void app_bt_ibrt_reconnect_mobile_profile(bt_bdaddr_t mobile_addr) { + nvrec_btdevicerecord *mobile_record = NULL; - bt_profile_manager[BT_DEVICE_ID_1].reconnect_mode = bt_profile_reconnect_null; - bt_profile_manager[BT_DEVICE_ID_1].rmt_addr = mobile_addr; - bt_profile_manager[BT_DEVICE_ID_1].chan = app_bt_device.hf_channel[BT_DEVICE_ID_1]; + bt_profile_manager[BT_DEVICE_ID_1].reconnect_mode = bt_profile_reconnect_null; + bt_profile_manager[BT_DEVICE_ID_1].rmt_addr = mobile_addr; + bt_profile_manager[BT_DEVICE_ID_1].chan = + app_bt_device.hf_channel[BT_DEVICE_ID_1]; - if (!nv_record_btdevicerecord_find(&mobile_addr, &mobile_record)) - { + if (!nv_record_btdevicerecord_find(&mobile_addr, &mobile_record)) { #if defined(A2DP_AAC_ON) - if(mobile_record->device_plf.a2dp_codectype == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream; - } - else + if (mobile_record->device_plf.a2dp_codectype == + BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_aac_stream[BT_DEVICE_ID_1]->a2dp_stream; + } else #endif #if defined(A2DP_SCALABLE_ON) - if(mobile_record->device_plf.a2dp_codectype == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_1]->a2dp_stream; - } - else + if (mobile_record->device_plf.a2dp_codectype == + BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_scalable_stream[BT_DEVICE_ID_1]->a2dp_stream; + } else #endif #if defined(A2DP_LHDC_ON) - if(mobile_record->device_plf.a2dp_codectype == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_1]->a2dp_stream; - } - else + if (mobile_record->device_plf.a2dp_codectype == + BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_lhdc_stream[BT_DEVICE_ID_1]->a2dp_stream; + } else #endif #if defined(A2DP_LDAC_ON) - if(mobile_record->device_plf.a2dp_codectype == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_ldac_stream[BT_DEVICE_ID_1]->a2dp_stream; - } - else + if (mobile_record->device_plf.a2dp_codectype == + BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_ldac_stream[BT_DEVICE_ID_1]->a2dp_stream; + } else #endif - { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream; - } - } - else { - bt_profile_manager[BT_DEVICE_ID_1].stream = app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream;//default using SBC + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream; } + } else { + bt_profile_manager[BT_DEVICE_ID_1].stream = + app_bt_device.a2dp_stream[BT_DEVICE_ID_1] + ->a2dp_stream; // default using SBC + } - btif_a2dp_reset_stream_state(bt_profile_manager[BT_DEVICE_ID_1].stream); + btif_a2dp_reset_stream_state(bt_profile_manager[BT_DEVICE_ID_1].stream); - TRACE(0,"ibrt_ui_log:start reconnect mobile, addr below:"); - DUMP8("0x%02x ",&(mobile_addr.address[0]),BTIF_BD_ADDR_SIZE); - app_bt_ibrt_reconnect_mobile_profile_flag_set(); - app_bt_precheck_before_starting_connecting(bt_profile_manager[BT_DEVICE_ID_1].has_connected); + TRACE(0, "ibrt_ui_log:start reconnect mobile, addr below:"); + DUMP8("0x%02x ", &(mobile_addr.address[0]), BTIF_BD_ADDR_SIZE); + app_bt_ibrt_reconnect_mobile_profile_flag_set(); + app_bt_precheck_before_starting_connecting( + bt_profile_manager[BT_DEVICE_ID_1].has_connected); - app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); - if (p_ibrt_ui->config.profile_concurrency_supported) - { - app_bt_A2DP_OpenStream(bt_profile_manager[BT_DEVICE_ID_1].stream, &(bt_profile_manager[BT_DEVICE_ID_1].rmt_addr)); - app_bt_HF_CreateServiceLink(bt_profile_manager[BT_DEVICE_ID_1].chan, &(bt_profile_manager[BT_DEVICE_ID_1].rmt_addr)); - } - else - { - app_bt_A2DP_OpenStream(bt_profile_manager[BT_DEVICE_ID_1].stream, &(bt_profile_manager[BT_DEVICE_ID_1].rmt_addr)); - //app_bt_HF_CreateServiceLink(bt_profile_manager[BT_DEVICE_ID_1].chan, &(bt_profile_manager[BT_DEVICE_ID_1].rmt_addr)); - } - //osTimerStart(bt_profile_manager[BT_DEVICE_ID_1].connect_timer, APP_IBRT_RECONNECT_TIMEOUT_MS); + app_ibrt_ui_t *p_ibrt_ui = app_ibrt_ui_get_ctx(); + if (p_ibrt_ui->config.profile_concurrency_supported) { + app_bt_A2DP_OpenStream(bt_profile_manager[BT_DEVICE_ID_1].stream, + &(bt_profile_manager[BT_DEVICE_ID_1].rmt_addr)); + app_bt_HF_CreateServiceLink(bt_profile_manager[BT_DEVICE_ID_1].chan, + &(bt_profile_manager[BT_DEVICE_ID_1].rmt_addr)); + } else { + app_bt_A2DP_OpenStream(bt_profile_manager[BT_DEVICE_ID_1].stream, + &(bt_profile_manager[BT_DEVICE_ID_1].rmt_addr)); + // app_bt_HF_CreateServiceLink(bt_profile_manager[BT_DEVICE_ID_1].chan, + // &(bt_profile_manager[BT_DEVICE_ID_1].rmt_addr)); + } + // osTimerStart(bt_profile_manager[BT_DEVICE_ID_1].connect_timer, + // APP_IBRT_RECONNECT_TIMEOUT_MS); } #endif #ifdef __IAG_BLE_INCLUDE__ -static void app_start_fast_connectable_ble_adv(uint16_t advInterval) -{ - bool ret = FALSE; +static void app_start_fast_connectable_ble_adv(uint16_t advInterval) { + bool ret = FALSE; - if (NULL == app_fast_ble_adv_timeout_timer) - { - app_fast_ble_adv_timeout_timer = - osTimerCreate(osTimer(APP_FAST_BLE_ADV_TIMEOUT_TIMER), - osTimerOnce, - NULL); - } + if (NULL == app_fast_ble_adv_timeout_timer) { + app_fast_ble_adv_timeout_timer = osTimerCreate( + osTimer(APP_FAST_BLE_ADV_TIMEOUT_TIMER), osTimerOnce, NULL); + } - osTimerStart(app_fast_ble_adv_timeout_timer, APP_FAST_BLE_ADV_TIMEOUT_IN_MS); + osTimerStart(app_fast_ble_adv_timeout_timer, APP_FAST_BLE_ADV_TIMEOUT_IN_MS); #ifdef IBRT - ret = app_ibrt_ui_get_snoop_via_ble_enable(); + ret = app_ibrt_ui_get_snoop_via_ble_enable(); #endif - if (FALSE == ret) - { - app_ble_start_connectable_adv(advInterval); - } + if (FALSE == ret) { + app_ble_start_connectable_adv(advInterval); + } } -static int app_fast_ble_adv_timeout_timehandler(void const *param) -{ - bool ret = FALSE; +static int app_fast_ble_adv_timeout_timehandler(void const *param) { + bool ret = FALSE; #ifdef IBRT - ret = app_ibrt_ui_get_snoop_via_ble_enable(); + ret = app_ibrt_ui_get_snoop_via_ble_enable(); #endif - if (FALSE == ret) - { - app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); - } + if (FALSE == ret) { + app_ble_refresh_adv_state(BLE_ADVERTISING_INTERVAL); + } - return 0; + return 0; } -void app_stop_fast_connectable_ble_adv_timer(void) -{ - if (NULL != app_fast_ble_adv_timeout_timer) - { - osTimerStop(app_fast_ble_adv_timeout_timer); - } +void app_stop_fast_connectable_ble_adv_timer(void) { + if (NULL != app_fast_ble_adv_timeout_timer) { + osTimerStop(app_fast_ble_adv_timeout_timer); + } } #endif - static uint32_t bt_link_active_mode_bits[MAX_ACTIVE_MODE_MANAGED_LINKS]; -void app_bt_active_mode_manager_init(void) -{ - memset(bt_link_active_mode_bits, 0, sizeof(bt_link_active_mode_bits)); +void app_bt_active_mode_manager_init(void) { + memset(bt_link_active_mode_bits, 0, sizeof(bt_link_active_mode_bits)); } -void app_bt_active_mode_reset(uint32_t linkIndex) -{ - bt_link_active_mode_bits[linkIndex] = 0; +void app_bt_active_mode_reset(uint32_t linkIndex) { + bt_link_active_mode_bits[linkIndex] = 0; } -void app_bt_active_mode_set(BT_LINK_ACTIVE_MODE_KEEPER_USER_E user, uint32_t linkIndex) -{ +void app_bt_active_mode_set(BT_LINK_ACTIVE_MODE_KEEPER_USER_E user, + uint32_t linkIndex) { #if defined(IBRT) - return; + return; #endif - bool isAlreadyInActiveMode = false; - if (linkIndex < MAX_ACTIVE_MODE_MANAGED_LINKS) - { - uint32_t lock = int_lock_global(); - if (bt_link_active_mode_bits[linkIndex] > 0) - { - isAlreadyInActiveMode = true; - } - else - { - isAlreadyInActiveMode = false; - } - bt_link_active_mode_bits[linkIndex] |= (1 << user); - int_unlock_global(lock); - - if (!isAlreadyInActiveMode) - { - app_bt_stop_sniff(linkIndex); - app_bt_stay_active(linkIndex); - } - + bool isAlreadyInActiveMode = false; + if (linkIndex < MAX_ACTIVE_MODE_MANAGED_LINKS) { + uint32_t lock = int_lock_global(); + if (bt_link_active_mode_bits[linkIndex] > 0) { + isAlreadyInActiveMode = true; + } else { + isAlreadyInActiveMode = false; } - else if (MAX_ACTIVE_MODE_MANAGED_LINKS == linkIndex) - { - for (uint8_t devId = 0; devId < BT_DEVICE_NUM; devId++) - { - uint32_t lock = int_lock_global(); - if (bt_link_active_mode_bits[devId] > 0) - { - isAlreadyInActiveMode = true; - } - else - { - isAlreadyInActiveMode = false; - } - bt_link_active_mode_bits[devId] |= (1 << user); - int_unlock_global(lock); + bt_link_active_mode_bits[linkIndex] |= (1 << user); + int_unlock_global(lock); - if (!isAlreadyInActiveMode) - { - app_bt_stop_sniff(devId); - app_bt_stay_active(devId); - } - } + if (!isAlreadyInActiveMode) { + app_bt_stop_sniff(linkIndex); + app_bt_stay_active(linkIndex); } - TRACE(2,"set active mode for user %d, link %d, now state:", user, linkIndex); - DUMP32("%08x", bt_link_active_mode_bits, MAX_ACTIVE_MODE_MANAGED_LINKS); + } else if (MAX_ACTIVE_MODE_MANAGED_LINKS == linkIndex) { + for (uint8_t devId = 0; devId < BT_DEVICE_NUM; devId++) { + uint32_t lock = int_lock_global(); + if (bt_link_active_mode_bits[devId] > 0) { + isAlreadyInActiveMode = true; + } else { + isAlreadyInActiveMode = false; + } + bt_link_active_mode_bits[devId] |= (1 << user); + int_unlock_global(lock); + + if (!isAlreadyInActiveMode) { + app_bt_stop_sniff(devId); + app_bt_stay_active(devId); + } + } + } + + TRACE(2, "set active mode for user %d, link %d, now state:", user, linkIndex); + DUMP32("%08x", bt_link_active_mode_bits, MAX_ACTIVE_MODE_MANAGED_LINKS); } -void app_bt_active_mode_clear(BT_LINK_ACTIVE_MODE_KEEPER_USER_E user, uint32_t linkIndex) -{ +void app_bt_active_mode_clear(BT_LINK_ACTIVE_MODE_KEEPER_USER_E user, + uint32_t linkIndex) { #if defined(IBRT) - return; + return; #endif - bool isAlreadyAllowSniff = false; - if (linkIndex < MAX_ACTIVE_MODE_MANAGED_LINKS) - { - uint32_t lock = int_lock_global(); + bool isAlreadyAllowSniff = false; + if (linkIndex < MAX_ACTIVE_MODE_MANAGED_LINKS) { + uint32_t lock = int_lock_global(); - if (0 == bt_link_active_mode_bits[linkIndex]) - { - isAlreadyAllowSniff = true; - } - else - { - isAlreadyAllowSniff = false; - } - - bt_link_active_mode_bits[linkIndex] &= (~(1 << user)); - - int_unlock_global(lock); - - if (!isAlreadyAllowSniff) - { - app_bt_allow_sniff(linkIndex); - } - } - else if (MAX_ACTIVE_MODE_MANAGED_LINKS == linkIndex) - { - for (uint8_t devId = 0; devId < BT_DEVICE_NUM; devId++) - { - uint32_t lock = int_lock_global(); - if (0 == bt_link_active_mode_bits[devId]) - { - isAlreadyAllowSniff = true; - } - else - { - isAlreadyAllowSniff = false; - } - bt_link_active_mode_bits[devId] &= (~(1 << user)); - int_unlock_global(lock); - - if (!isAlreadyAllowSniff) - { - app_bt_allow_sniff(devId); - } - } + if (0 == bt_link_active_mode_bits[linkIndex]) { + isAlreadyAllowSniff = true; + } else { + isAlreadyAllowSniff = false; } - TRACE(2,"clear active mode for user %d, link %d, now state:", user, linkIndex); - DUMP32("%08x ", bt_link_active_mode_bits, MAX_ACTIVE_MODE_MANAGED_LINKS); + bt_link_active_mode_bits[linkIndex] &= (~(1 << user)); + + int_unlock_global(lock); + + if (!isAlreadyAllowSniff) { + app_bt_allow_sniff(linkIndex); + } + } else if (MAX_ACTIVE_MODE_MANAGED_LINKS == linkIndex) { + for (uint8_t devId = 0; devId < BT_DEVICE_NUM; devId++) { + uint32_t lock = int_lock_global(); + if (0 == bt_link_active_mode_bits[devId]) { + isAlreadyAllowSniff = true; + } else { + isAlreadyAllowSniff = false; + } + bt_link_active_mode_bits[devId] &= (~(1 << user)); + int_unlock_global(lock); + + if (!isAlreadyAllowSniff) { + app_bt_allow_sniff(devId); + } + } + } + + TRACE(2, "clear active mode for user %d, link %d, now state:", user, + linkIndex); + DUMP32("%08x ", bt_link_active_mode_bits, MAX_ACTIVE_MODE_MANAGED_LINKS); } -int8_t app_bt_get_rssi(void) -{ - int8_t rssi=127; - uint8_t i; - btif_remote_device_t *remDev = NULL; - rx_agc_t tws_agc = {0}; +int8_t app_bt_get_rssi(void) { + int8_t rssi = 127; + uint8_t i; + btif_remote_device_t *remDev = NULL; + rx_agc_t tws_agc = {0}; - for (i=0; iconfig.disable_tws_switch = true;//disable role switch +void app_bt_prepare_for_ota(void) { + app_ibrt_ui_t *p_ui_ctrl = app_ibrt_ui_get_ctx(); - app_key_close(); + p_ui_ctrl->config.disable_tws_switch = true; // disable role switch - if(IBRT_MASTER == app_tws_ibrt_role_get_callback(NULL)){ - btif_hf_disconnect_service_link(app_bt_device.hf_channel[BT_DEVICE_ID_1]); - btif_a2dp_suspend_stream(app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream); - } - TRACE(0,"app_bt_prepare_for_ota"); + app_key_close(); + + if (IBRT_MASTER == app_tws_ibrt_role_get_callback(NULL)) { + btif_hf_disconnect_service_link(app_bt_device.hf_channel[BT_DEVICE_ID_1]); + btif_a2dp_suspend_stream( + app_bt_device.a2dp_stream[BT_DEVICE_ID_1]->a2dp_stream); + } + TRACE(0, "app_bt_prepare_for_ota"); } #endif diff --git a/services/bt_app/app_bt_func.cpp b/services/bt_app/app_bt_func.cpp index c0f82b7..7e203a9 100644 --- a/services/bt_app/app_bt_func.cpp +++ b/services/bt_app/app_bt_func.cpp @@ -14,20 +14,19 @@ * ****************************************************************************/ #include "cmsis_os.h" -#include "string.h" #include "hal_trace.h" +#include "string.h" -#include "bluetooth.h" -#include "besbt.h" -#include "app_bt_func.h" -#include "hfp_api.h" -#include "app_bt.h" -#include "os_api.h" #include "app_ble_mode_switch.h" +#include "app_bt.h" +#include "app_bt_func.h" +#include "besbt.h" +#include "bluetooth.h" +#include "hfp_api.h" +#include "os_api.h" extern "C" void OS_NotifyEvm(void); -static const char * const app_bt_func_table_str[] = -{ +static const char *const app_bt_func_table_str[] = { "Me_switch_sco", "ME_SwitchRole", "ME_SetConnectionRole", @@ -64,850 +63,806 @@ static const char * const app_bt_func_table_str[] = }; #define APP_BT_MAILBOX_MAX (40) -osMailQDef (app_bt_mailbox, APP_BT_MAILBOX_MAX, APP_BT_MAIL); +osMailQDef(app_bt_mailbox, APP_BT_MAILBOX_MAX, APP_BT_MAIL); static osMailQId app_bt_mailbox = NULL; static btif_accessible_mode_t gBT_DEFAULT_ACCESS_MODE = BTIF_BAM_NOT_ACCESSIBLE; static uint8_t bt_access_mode_set_pending = 0; -void app_set_accessmode(btif_accessible_mode_t mode) -{ +void app_set_accessmode(btif_accessible_mode_t mode) { #if !defined(IBRT) - const btif_access_mode_info_t info = { BTIF_BT_DEFAULT_INQ_SCAN_INTERVAL, - BTIF_BT_DEFAULT_INQ_SCAN_WINDOW, - BTIF_BT_DEFAULT_PAGE_SCAN_INTERVAL, - BTIF_BT_DEFAULT_PAGE_SCAN_WINDOW }; - bt_status_t status; - osapi_lock_stack(); - gBT_DEFAULT_ACCESS_MODE = mode; + const btif_access_mode_info_t info = { + BTIF_BT_DEFAULT_INQ_SCAN_INTERVAL, BTIF_BT_DEFAULT_INQ_SCAN_WINDOW, + BTIF_BT_DEFAULT_PAGE_SCAN_INTERVAL, BTIF_BT_DEFAULT_PAGE_SCAN_WINDOW}; + bt_status_t status; + osapi_lock_stack(); + gBT_DEFAULT_ACCESS_MODE = mode; - status = btif_me_set_accessible_mode(mode, &info); - TRACE(1,"app_set_accessmode status=0x%x",status); + status = btif_me_set_accessible_mode(mode, &info); + TRACE(1, "app_set_accessmode status=0x%x", status); - if(status == BT_STS_IN_PROGRESS) - bt_access_mode_set_pending = 1; - else - bt_access_mode_set_pending = 0; - osapi_unlock_stack(); + if (status == BT_STS_IN_PROGRESS) + bt_access_mode_set_pending = 1; + else + bt_access_mode_set_pending = 0; + osapi_unlock_stack(); #endif } -bool app_is_access_mode_set_pending(void) -{ - return bt_access_mode_set_pending; -} +bool app_is_access_mode_set_pending(void) { return bt_access_mode_set_pending; } extern "C" void app_bt_accessmode_set(btif_accessible_mode_t mode); -void app_set_pending_access_mode(void) -{ - if (bt_access_mode_set_pending) - { - TRACE(1,"Pending for change access mode to %d", gBT_DEFAULT_ACCESS_MODE); - bt_access_mode_set_pending = 0; - app_bt_accessmode_set(gBT_DEFAULT_ACCESS_MODE); - } -} - -void app_retry_setting_access_mode(void) -{ - TRACE(0,"Former setting access mode failed, retry it."); +void app_set_pending_access_mode(void) { + if (bt_access_mode_set_pending) { + TRACE(1, "Pending for change access mode to %d", gBT_DEFAULT_ACCESS_MODE); + bt_access_mode_set_pending = 0; app_bt_accessmode_set(gBT_DEFAULT_ACCESS_MODE); + } } -#define PENDING_SET_LINKPOLICY_REQ_BUF_CNT 5 -static BT_SET_LINKPOLICY_REQ_T pending_set_linkpolicy_req[PENDING_SET_LINKPOLICY_REQ_BUF_CNT]; +void app_retry_setting_access_mode(void) { + TRACE(0, "Former setting access mode failed, retry it."); + app_bt_accessmode_set(gBT_DEFAULT_ACCESS_MODE); +} + +#define PENDING_SET_LINKPOLICY_REQ_BUF_CNT 5 +static BT_SET_LINKPOLICY_REQ_T + pending_set_linkpolicy_req[PENDING_SET_LINKPOLICY_REQ_BUF_CNT]; static uint8_t pending_set_linkpolicy_in_cursor = 0; static uint8_t pending_set_linkpolicy_out_cursor = 0; -static void app_bt_print_pending_set_linkpolicy_req(void) -{ - TRACE(0,"Pending set link policy requests:"); - uint8_t index = pending_set_linkpolicy_out_cursor; - while (index != pending_set_linkpolicy_in_cursor) - { - TRACE(3,"index %d RemDev %p LinkPolicy %d", index, - pending_set_linkpolicy_req[index].remDev, - pending_set_linkpolicy_req[index].policy); - index++; - if (PENDING_SET_LINKPOLICY_REQ_BUF_CNT == index) - { - index = 0; - } +static void app_bt_print_pending_set_linkpolicy_req(void) { + TRACE(0, "Pending set link policy requests:"); + uint8_t index = pending_set_linkpolicy_out_cursor; + while (index != pending_set_linkpolicy_in_cursor) { + TRACE(3, "index %d RemDev %p LinkPolicy %d", index, + pending_set_linkpolicy_req[index].remDev, + pending_set_linkpolicy_req[index].policy); + index++; + if (PENDING_SET_LINKPOLICY_REQ_BUF_CNT == index) { + index = 0; } + } } -static void app_bt_push_pending_set_linkpolicy(btif_remote_device_t *remDev, btif_link_policy_t policy) -{ - // go through the existing pending list to see if the remDev is already in - uint8_t index = pending_set_linkpolicy_out_cursor; - while (index != pending_set_linkpolicy_in_cursor) - { - if (remDev == pending_set_linkpolicy_req[index].remDev) - { - pending_set_linkpolicy_req[index].policy = policy; - return; - } - index++; - if (PENDING_SET_LINKPOLICY_REQ_BUF_CNT == index) - { - index = 0; - } +static void app_bt_push_pending_set_linkpolicy(btif_remote_device_t *remDev, + btif_link_policy_t policy) { + // go through the existing pending list to see if the remDev is already in + uint8_t index = pending_set_linkpolicy_out_cursor; + while (index != pending_set_linkpolicy_in_cursor) { + if (remDev == pending_set_linkpolicy_req[index].remDev) { + pending_set_linkpolicy_req[index].policy = policy; + return; } - - pending_set_linkpolicy_req[pending_set_linkpolicy_in_cursor].remDev = remDev; - pending_set_linkpolicy_req[pending_set_linkpolicy_in_cursor].policy = policy; - pending_set_linkpolicy_in_cursor++; - if (PENDING_SET_LINKPOLICY_REQ_BUF_CNT == pending_set_linkpolicy_in_cursor) - { - pending_set_linkpolicy_in_cursor = 0; + index++; + if (PENDING_SET_LINKPOLICY_REQ_BUF_CNT == index) { + index = 0; } + } - app_bt_print_pending_set_linkpolicy_req(); + pending_set_linkpolicy_req[pending_set_linkpolicy_in_cursor].remDev = remDev; + pending_set_linkpolicy_req[pending_set_linkpolicy_in_cursor].policy = policy; + pending_set_linkpolicy_in_cursor++; + if (PENDING_SET_LINKPOLICY_REQ_BUF_CNT == pending_set_linkpolicy_in_cursor) { + pending_set_linkpolicy_in_cursor = 0; + } + + app_bt_print_pending_set_linkpolicy_req(); } -BT_SET_LINKPOLICY_REQ_T* app_bt_pop_pending_set_linkpolicy(void) -{ - if (pending_set_linkpolicy_out_cursor == pending_set_linkpolicy_in_cursor) - { - return NULL; - } +BT_SET_LINKPOLICY_REQ_T *app_bt_pop_pending_set_linkpolicy(void) { + if (pending_set_linkpolicy_out_cursor == pending_set_linkpolicy_in_cursor) { + return NULL; + } - BT_SET_LINKPOLICY_REQ_T* ptReq = &pending_set_linkpolicy_req[pending_set_linkpolicy_out_cursor]; - pending_set_linkpolicy_out_cursor++; - if (PENDING_SET_LINKPOLICY_REQ_BUF_CNT == pending_set_linkpolicy_out_cursor) - { - pending_set_linkpolicy_out_cursor = 0; - } + BT_SET_LINKPOLICY_REQ_T *ptReq = + &pending_set_linkpolicy_req[pending_set_linkpolicy_out_cursor]; + pending_set_linkpolicy_out_cursor++; + if (PENDING_SET_LINKPOLICY_REQ_BUF_CNT == pending_set_linkpolicy_out_cursor) { + pending_set_linkpolicy_out_cursor = 0; + } - app_bt_print_pending_set_linkpolicy_req(); - return ptReq; + app_bt_print_pending_set_linkpolicy_req(); + return ptReq; } -void app_bt_set_linkpolicy(btif_remote_device_t *remDev, btif_link_policy_t policy) -{ - if (btif_me_get_remote_device_state(remDev) == BTIF_BDS_CONNECTED) - { - bt_status_t ret = btif_me_set_link_policy(remDev, policy); - TRACE(3,"%s policy %d returns %d", __FUNCTION__, policy, ret); +void app_bt_set_linkpolicy(btif_remote_device_t *remDev, + btif_link_policy_t policy) { + if (btif_me_get_remote_device_state(remDev) == BTIF_BDS_CONNECTED) { + bt_status_t ret = btif_me_set_link_policy(remDev, policy); + TRACE(3, "%s policy %d returns %d", __FUNCTION__, policy, ret); - osapi_lock_stack(); - if (BT_STS_IN_PROGRESS == ret) - { - app_bt_push_pending_set_linkpolicy(remDev, policy); - } - osapi_unlock_stack(); + osapi_lock_stack(); + if (BT_STS_IN_PROGRESS == ret) { + app_bt_push_pending_set_linkpolicy(remDev, policy); } + osapi_unlock_stack(); + } } -#define COUNT_OF_PENDING_REMOTE_DEV_TO_EXIT_SNIFF_MODE 8 -static btif_remote_device_t* pendingRemoteDevToExitSniffMode[COUNT_OF_PENDING_REMOTE_DEV_TO_EXIT_SNIFF_MODE]; -static uint8_t maskOfRemoteDevPendingForExitingSniffMode = 0; -void app_check_pending_stop_sniff_op(void) -{ - if (maskOfRemoteDevPendingForExitingSniffMode > 0) - { - for (uint8_t index = 0;index < COUNT_OF_PENDING_REMOTE_DEV_TO_EXIT_SNIFF_MODE;index++) - { - if (maskOfRemoteDevPendingForExitingSniffMode & (1 << index)) - { - btif_remote_device_t* remDev = pendingRemoteDevToExitSniffMode[index]; - if (!btif_me_is_op_in_progress(remDev)) - { - if (btif_me_get_remote_device_state(remDev) == BTIF_BDS_CONNECTED){ - if (btif_me_get_current_mode(remDev) == BTIF_BLM_SNIFF_MODE){ - TRACE(1,"!!! stop sniff currmode:%d\n", btif_me_get_current_mode(remDev)); - bt_status_t ret = btif_me_stop_sniff(remDev); - TRACE(1,"Return status %d", ret); - if (BT_STS_IN_PROGRESS != ret) - { - maskOfRemoteDevPendingForExitingSniffMode &= (~(1< 0) { + for (uint8_t index = 0; + index < COUNT_OF_PENDING_REMOTE_DEV_TO_EXIT_SNIFF_MODE; index++) { + if (maskOfRemoteDevPendingForExitingSniffMode & (1 << index)) { + btif_remote_device_t *remDev = pendingRemoteDevToExitSniffMode[index]; + if (!btif_me_is_op_in_progress(remDev)) { + if (btif_me_get_remote_device_state(remDev) == BTIF_BDS_CONNECTED) { + if (btif_me_get_current_mode(remDev) == BTIF_BLM_SNIFF_MODE) { + TRACE(1, "!!! stop sniff currmode:%d\n", + btif_me_get_current_mode(remDev)); + bt_status_t ret = btif_me_stop_sniff(remDev); + TRACE(1, "Return status %d", ret); + if (BT_STS_IN_PROGRESS != ret) { + maskOfRemoteDevPendingForExitingSniffMode &= (~(1 << index)); + break; + } } + } } - - if (maskOfRemoteDevPendingForExitingSniffMode > 0) - { - osapi_notify_evm(); - } + } } + + if (maskOfRemoteDevPendingForExitingSniffMode > 0) { + osapi_notify_evm(); + } + } } -static void app_add_pending_stop_sniff_op(btif_remote_device_t* remDev) -{ - for (uint8_t index = 0;index < COUNT_OF_PENDING_REMOTE_DEV_TO_EXIT_SNIFF_MODE;index++) - { - if (maskOfRemoteDevPendingForExitingSniffMode & (1 << index)) - { - if (pendingRemoteDevToExitSniffMode[index] == remDev) - { - return; - } - } +static void app_add_pending_stop_sniff_op(btif_remote_device_t *remDev) { + for (uint8_t index = 0; + index < COUNT_OF_PENDING_REMOTE_DEV_TO_EXIT_SNIFF_MODE; index++) { + if (maskOfRemoteDevPendingForExitingSniffMode & (1 << index)) { + if (pendingRemoteDevToExitSniffMode[index] == remDev) { + return; + } } + } - for (uint8_t index = 0;index < COUNT_OF_PENDING_REMOTE_DEV_TO_EXIT_SNIFF_MODE;index++) - { - if (0 == (maskOfRemoteDevPendingForExitingSniffMode & (1 << index))) - { - pendingRemoteDevToExitSniffMode[index] = remDev; - maskOfRemoteDevPendingForExitingSniffMode |= (1 << index); - } + for (uint8_t index = 0; + index < COUNT_OF_PENDING_REMOTE_DEV_TO_EXIT_SNIFF_MODE; index++) { + if (0 == (maskOfRemoteDevPendingForExitingSniffMode & (1 << index))) { + pendingRemoteDevToExitSniffMode[index] = remDev; + maskOfRemoteDevPendingForExitingSniffMode |= (1 << index); } + } } #ifdef FPGA -extern "C" bt_status_t app_tws_ibrt_set_access_mode(btif_accessible_mode_t mode); +extern "C" bt_status_t +app_tws_ibrt_set_access_mode(btif_accessible_mode_t mode); void app_start_ble_adv_for_test(void); #endif -static inline int app_bt_mail_process(APP_BT_MAIL* mail_p) -{ - bt_status_t status = BT_STS_LAST_CODE; - if (mail_p->request_id != CMGR_SetSniffTimer_req){ - TRACE(3,"[BT_FUNC] src_thread:0x%08x call request_id=%x->:%s", mail_p->src_thread, mail_p->request_id,app_bt_func_table_str[mail_p->request_id]); +static inline int app_bt_mail_process(APP_BT_MAIL *mail_p) { + bt_status_t status = BT_STS_LAST_CODE; + if (mail_p->request_id != CMGR_SetSniffTimer_req) { + TRACE(3, "[BT_FUNC] src_thread:0x%08x call request_id=%x->:%s", + mail_p->src_thread, mail_p->request_id, + app_bt_func_table_str[mail_p->request_id]); + } + switch (mail_p->request_id) { + case Me_switch_sco_req: + status = btif_me_switch_sco(mail_p->param.Me_switch_sco_param.scohandle); + break; + case ME_SwitchRole_req: + status = btif_me_switch_role(mail_p->param.ME_SwitchRole_param.remDev); + break; + case ME_SetConnectionRole_req: + status = + btif_me_set_connection_role(mail_p->param.BtConnectionRole_param.role); + break; + case MeDisconnectLink_req: + status = btif_me_force_disconnect_link_with_reason( + NULL, mail_p->param.MeDisconnectLink_param.remDev, + BTIF_BEC_USER_TERMINATED, TRUE); + break; + case ME_StopSniff_req: { + if (btif_me_get_remote_device_state( + mail_p->param.ME_StopSniff_param.remDev) == BTIF_BDS_CONNECTED) { + status = btif_me_stop_sniff(mail_p->param.ME_StopSniff_param.remDev); + if (BT_STS_IN_PROGRESS == status) { + app_add_pending_stop_sniff_op(mail_p->param.ME_StopSniff_param.remDev); + } } - switch (mail_p->request_id) { - case Me_switch_sco_req: - status = btif_me_switch_sco(mail_p->param.Me_switch_sco_param.scohandle); - break; - case ME_SwitchRole_req: - status = btif_me_switch_role(mail_p->param.ME_SwitchRole_param.remDev); - break; - case ME_SetConnectionRole_req: - status = btif_me_set_connection_role(mail_p->param.BtConnectionRole_param.role); - break; - case MeDisconnectLink_req: - status = btif_me_force_disconnect_link_with_reason(NULL, mail_p->param.MeDisconnectLink_param.remDev, BTIF_BEC_USER_TERMINATED, TRUE); - break; - case ME_StopSniff_req: - { - if (btif_me_get_remote_device_state(mail_p->param.ME_StopSniff_param.remDev) == BTIF_BDS_CONNECTED) - { - status = btif_me_stop_sniff(mail_p->param.ME_StopSniff_param.remDev); - if (BT_STS_IN_PROGRESS == status) - { - app_add_pending_stop_sniff_op(mail_p->param.ME_StopSniff_param.remDev); - } - } - break; - } - case ME_StartSniff_req: - { - if (btif_me_get_remote_device_state(mail_p->param.ME_StartSniff_param.remDev) == BTIF_BDS_CONNECTED) - { - status = btif_me_start_sniff (mail_p->param.ME_StartSniff_param.remDev, - &(mail_p->param.ME_StartSniff_param.sniffInfo)); - } - break; - } - case BT_Control_SleepMode_req: - { - btif_me_write_bt_sleep_enable(mail_p->param.ME_BtControlSleepMode_param.isEnable); - break; - } - case ME_SetAccessibleMode_req: - app_set_accessmode(mail_p->param.ME_SetAccessibleMode_param.mode); - break; - case Me_SetLinkPolicy_req: - app_bt_set_linkpolicy(mail_p->param.Me_SetLinkPolicy_param.remDev, - mail_p->param.Me_SetLinkPolicy_param.policy); - break; - case CMGR_SetSniffTimer_req: - if (mail_p->param.CMGR_SetSniffTimer_param.SniffInfo.maxInterval == 0){ - status = btif_cmgr_set_sniff_timer(mail_p->param.CMGR_SetSniffTimer_param.Handler, - NULL, - mail_p->param.CMGR_SetSniffTimer_param.Time); - }else{ - status = btif_cmgr_set_sniff_timer(mail_p->param.CMGR_SetSniffTimer_param.Handler, - &mail_p->param.CMGR_SetSniffTimer_param.SniffInfo, - mail_p->param.CMGR_SetSniffTimer_param.Time); - } - break; - case CMGR_SetSniffInofToAllHandlerByRemDev_req: - status = btif_cmgr_set_sniff_info_to_all_handler_by_remdev(&mail_p->param.CMGR_SetSniffInofToAllHandlerByRemDev_param.SniffInfo, - mail_p->param.CMGR_SetSniffInofToAllHandlerByRemDev_param.RemDev); - break; - case A2DP_OpenStream_req: - status = btif_a2dp_open_stream(mail_p->param.A2DP_OpenStream_param.Stream, - mail_p->param.A2DP_OpenStream_param.Addr); - if ((BT_STS_NO_RESOURCES == status) || (BT_STS_IN_PROGRESS == status)) - { - app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); - app_bt_reset_reconnect_timer(mail_p->param.A2DP_OpenStream_param.Addr); - } - else - { - app_bt_accessmode_set(BTIF_BAM_NOT_ACCESSIBLE); - } - break; - case A2DP_CloseStream_req: - status = btif_a2dp_close_stream(mail_p->param.A2DP_CloseStream_param.Stream); - break; - case A2DP_SetMasterRole_req: - status = btif_a2dp_set_master_role(mail_p->param.A2DP_SetMasterRole_param.Stream, - mail_p->param.A2DP_SetMasterRole_param.Flag); - break; - case HF_CreateServiceLink_req: - status = btif_hf_create_service_link(mail_p->param.HF_CreateServiceLink_param.Chan, - mail_p->param.HF_CreateServiceLink_param.Addr); - if ((BT_STS_NO_RESOURCES == status) || (BT_STS_IN_PROGRESS == status)) - { - app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); - app_bt_reset_reconnect_timer(mail_p->param.HF_CreateServiceLink_param.Addr); - } - else - { - app_bt_accessmode_set(BTIF_BAM_NOT_ACCESSIBLE); - } - break; - case HF_DisconnectServiceLink_req: - status = btif_hf_disconnect_service_link(mail_p->param.HF_DisconnectServiceLink_param.Chan); - break; - case HF_CreateAudioLink_req: - status = btif_hf_create_audio_link(mail_p->param.HF_CreateAudioLink_param.Chan); - break; - case HF_DisconnectAudioLink_req: - status = btif_hf_disc_audio_link(mail_p->param.HF_DisconnectAudioLink_param.Chan); - break; - case HF_EnableSniffMode_req: - status = btif_hf_enable_sniff_mode(mail_p->param.HF_EnableSniffMode_param.Chan, - mail_p->param.HF_EnableSniffMode_param.Enable); - break; - case HF_SetMasterRole_req: - status = btif_hf_set_master_role(mail_p->param.HF_SetMasterRole_param.Chan, - mail_p->param.HF_SetMasterRole_param.Flag); - break; + break; + } + case ME_StartSniff_req: { + if (btif_me_get_remote_device_state( + mail_p->param.ME_StartSniff_param.remDev) == BTIF_BDS_CONNECTED) { + status = + btif_me_start_sniff(mail_p->param.ME_StartSniff_param.remDev, + &(mail_p->param.ME_StartSniff_param.sniffInfo)); + } + break; + } + case BT_Control_SleepMode_req: { + btif_me_write_bt_sleep_enable( + mail_p->param.ME_BtControlSleepMode_param.isEnable); + break; + } + case ME_SetAccessibleMode_req: + app_set_accessmode(mail_p->param.ME_SetAccessibleMode_param.mode); + break; + case Me_SetLinkPolicy_req: + app_bt_set_linkpolicy(mail_p->param.Me_SetLinkPolicy_param.remDev, + mail_p->param.Me_SetLinkPolicy_param.policy); + break; + case CMGR_SetSniffTimer_req: + if (mail_p->param.CMGR_SetSniffTimer_param.SniffInfo.maxInterval == 0) { + status = btif_cmgr_set_sniff_timer( + mail_p->param.CMGR_SetSniffTimer_param.Handler, NULL, + mail_p->param.CMGR_SetSniffTimer_param.Time); + } else { + status = btif_cmgr_set_sniff_timer( + mail_p->param.CMGR_SetSniffTimer_param.Handler, + &mail_p->param.CMGR_SetSniffTimer_param.SniffInfo, + mail_p->param.CMGR_SetSniffTimer_param.Time); + } + break; + case CMGR_SetSniffInofToAllHandlerByRemDev_req: + status = btif_cmgr_set_sniff_info_to_all_handler_by_remdev( + &mail_p->param.CMGR_SetSniffInofToAllHandlerByRemDev_param.SniffInfo, + mail_p->param.CMGR_SetSniffInofToAllHandlerByRemDev_param.RemDev); + break; + case A2DP_OpenStream_req: + status = btif_a2dp_open_stream(mail_p->param.A2DP_OpenStream_param.Stream, + mail_p->param.A2DP_OpenStream_param.Addr); + if ((BT_STS_NO_RESOURCES == status) || (BT_STS_IN_PROGRESS == status)) { + app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); + app_bt_reset_reconnect_timer(mail_p->param.A2DP_OpenStream_param.Addr); + } else { + app_bt_accessmode_set(BTIF_BAM_NOT_ACCESSIBLE); + } + break; + case A2DP_CloseStream_req: + status = + btif_a2dp_close_stream(mail_p->param.A2DP_CloseStream_param.Stream); + break; + case A2DP_SetMasterRole_req: + status = + btif_a2dp_set_master_role(mail_p->param.A2DP_SetMasterRole_param.Stream, + mail_p->param.A2DP_SetMasterRole_param.Flag); + break; + case HF_CreateServiceLink_req: + status = btif_hf_create_service_link( + mail_p->param.HF_CreateServiceLink_param.Chan, + mail_p->param.HF_CreateServiceLink_param.Addr); + if ((BT_STS_NO_RESOURCES == status) || (BT_STS_IN_PROGRESS == status)) { + app_bt_accessmode_set(BTIF_BAM_CONNECTABLE_ONLY); + app_bt_reset_reconnect_timer( + mail_p->param.HF_CreateServiceLink_param.Addr); + } else { + app_bt_accessmode_set(BTIF_BAM_NOT_ACCESSIBLE); + } + break; + case HF_DisconnectServiceLink_req: + status = btif_hf_disconnect_service_link( + mail_p->param.HF_DisconnectServiceLink_param.Chan); + break; + case HF_CreateAudioLink_req: + status = + btif_hf_create_audio_link(mail_p->param.HF_CreateAudioLink_param.Chan); + break; + case HF_DisconnectAudioLink_req: + status = btif_hf_disc_audio_link( + mail_p->param.HF_DisconnectAudioLink_param.Chan); + break; + case HF_EnableSniffMode_req: + status = btif_hf_enable_sniff_mode( + mail_p->param.HF_EnableSniffMode_param.Chan, + mail_p->param.HF_EnableSniffMode_param.Enable); + break; + case HF_SetMasterRole_req: + status = btif_hf_set_master_role(mail_p->param.HF_SetMasterRole_param.Chan, + mail_p->param.HF_SetMasterRole_param.Flag); + break; #ifdef BTIF_DIP_DEVICE - case DIP_QuryService_req: - status = btif_dip_query_for_service(mail_p->param.DIP_QuryService_param.dip_client, - mail_p->param.DIP_QuryService_param.remDev); - break; + case DIP_QuryService_req: + status = btif_dip_query_for_service( + mail_p->param.DIP_QuryService_param.dip_client, + mail_p->param.DIP_QuryService_param.remDev); + break; #endif -#if defined (__HSP_ENABLE__) - case HS_CreateServiceLink_req: - app_bt_accessmode_set(BTIF_BAM_NOT_ACCESSIBLE); - status = HS_CreateServiceLink(mail_p->param.HS_CreateServiceLink_param.Chan, - mail_p->param.HS_CreateServiceLink_param.Addr); - break; - case HS_CreateAudioLink_req: - status = HS_CreateAudioLink(mail_p->param.HS_CreateAudioLink_param.Chan); - break; - case HS_DisconnectAudioLink_req: - status = HS_DisconnectAudioLink(mail_p->param.HS_DisconnectAudioLink_param.Chan); - break; - case HS_DisconnectServiceLink_req: - status = HS_DisconnectServiceLink(mail_p->param.HS_DisconnectServiceLink_param.Chan); - break; - case HS_EnableSniffMode_req: - status = HS_EnableSniffMode(mail_p->param.HS_EnableSniffMode_param.Chan, - mail_p->param.HS_EnableSniffMode_param.Enable); - break; +#if defined(__HSP_ENABLE__) + case HS_CreateServiceLink_req: + app_bt_accessmode_set(BTIF_BAM_NOT_ACCESSIBLE); + status = + HS_CreateServiceLink(mail_p->param.HS_CreateServiceLink_param.Chan, + mail_p->param.HS_CreateServiceLink_param.Addr); + break; + case HS_CreateAudioLink_req: + status = HS_CreateAudioLink(mail_p->param.HS_CreateAudioLink_param.Chan); + break; + case HS_DisconnectAudioLink_req: + status = + HS_DisconnectAudioLink(mail_p->param.HS_DisconnectAudioLink_param.Chan); + break; + case HS_DisconnectServiceLink_req: + status = HS_DisconnectServiceLink( + mail_p->param.HS_DisconnectServiceLink_param.Chan); + break; + case HS_EnableSniffMode_req: + status = HS_EnableSniffMode(mail_p->param.HS_EnableSniffMode_param.Chan, + mail_p->param.HS_EnableSniffMode_param.Enable); + break; #endif #ifdef FPGA - case BT_Set_Access_Mode_Test: + case BT_Set_Access_Mode_Test: #if defined(IBRT) - app_tws_ibrt_set_access_mode(mail_p->param.ME_SetAccessibleMode_param.mode); + app_tws_ibrt_set_access_mode(mail_p->param.ME_SetAccessibleMode_param.mode); #else - app_set_accessmode(mail_p->param.ME_SetAccessibleMode_param.mode); + app_set_accessmode(mail_p->param.ME_SetAccessibleMode_param.mode); #endif - break; - case BT_Set_Adv_Mode_Test: + break; + case BT_Set_Adv_Mode_Test: #if defined(IBRT) - app_start_ble_adv_for_test(); -#endif - break; - case Write_Controller_Memory_Test: - { - status = btif_me_write_controller_memory(mail_p->param.Me_writecontrollermem_param.addr, - mail_p->param.Me_writecontrollermem_param.memval, - mail_p->param.Me_writecontrollermem_param.type); - break; - } - case Read_Controller_Memory_Test: - { - status = btif_me_read_controller_memory(mail_p->param.Me_readcontrollermem_param.addr, - mail_p->param.Me_readcontrollermem_param.len, - mail_p->param.Me_readcontrollermem_param.type); - break; - } -#endif - case BT_Custom_Func_req: - if (mail_p->param.CustomFunc_param.func_ptr){ - TRACE(3,"func:0x%08x,param0:0x%08x, param1:0x%08x", - mail_p->param.CustomFunc_param.func_ptr, - mail_p->param.CustomFunc_param.param0, - mail_p->param.CustomFunc_param.param1); - ((APP_BTTHREAD_REQ_CUSTOMER_CALL_CB_T)(mail_p->param.CustomFunc_param.func_ptr))( - (void *)mail_p->param.CustomFunc_param.param0, - (void *)mail_p->param.CustomFunc_param.param1); - } - break; + app_start_ble_adv_for_test(); +#endif + break; + case Write_Controller_Memory_Test: { + status = btif_me_write_controller_memory( + mail_p->param.Me_writecontrollermem_param.addr, + mail_p->param.Me_writecontrollermem_param.memval, + mail_p->param.Me_writecontrollermem_param.type); + break; + } + case Read_Controller_Memory_Test: { + status = btif_me_read_controller_memory( + mail_p->param.Me_readcontrollermem_param.addr, + mail_p->param.Me_readcontrollermem_param.len, + mail_p->param.Me_readcontrollermem_param.type); + break; + } +#endif + case BT_Custom_Func_req: + if (mail_p->param.CustomFunc_param.func_ptr) { + TRACE(3, "func:0x%08x,param0:0x%08x, param1:0x%08x", + mail_p->param.CustomFunc_param.func_ptr, + mail_p->param.CustomFunc_param.param0, + mail_p->param.CustomFunc_param.param1); + ((APP_BTTHREAD_REQ_CUSTOMER_CALL_CB_T)( + mail_p->param.CustomFunc_param.func_ptr))( + (void *)mail_p->param.CustomFunc_param.param0, + (void *)mail_p->param.CustomFunc_param.param1); } + break; + } - if (mail_p->request_id != CMGR_SetSniffTimer_req){ - TRACE(2,"[BT_FUNC] exit request_id:%d :status:%d", mail_p->request_id, status); - } + if (mail_p->request_id != CMGR_SetSniffTimer_req) { + TRACE(2, "[BT_FUNC] exit request_id:%d :status:%d", mail_p->request_id, + status); + } + return 0; +} + +static inline int app_bt_mail_alloc(APP_BT_MAIL **mail) { + *mail = (APP_BT_MAIL *)osMailAlloc(app_bt_mailbox, 0); + ASSERT(*mail, "app_bt_mail_alloc error"); + return 0; +} + +static inline int app_bt_mail_send(APP_BT_MAIL *mail) { + osStatus status; + + ASSERT(mail, "osMailAlloc NULL"); + status = osMailPut(app_bt_mailbox, mail); + ASSERT(osOK == status, "osMailAlloc Put failed"); + + OS_NotifyEvm(); + + return (int)status; +} + +static inline int app_bt_mail_free(APP_BT_MAIL *mail_p) { + osStatus status; + + status = osMailFree(app_bt_mailbox, mail_p); + ASSERT(osOK == status, "osMailAlloc Put failed"); + + return (int)status; +} + +static inline int app_bt_mail_get(APP_BT_MAIL **mail_p) { + osEvent evt; + evt = osMailGet(app_bt_mailbox, 0); + if (evt.status == osEventMail) { + *mail_p = (APP_BT_MAIL *)evt.value.p; return 0; + } + return -1; } -static inline int app_bt_mail_alloc(APP_BT_MAIL** mail) -{ - *mail = (APP_BT_MAIL*)osMailAlloc(app_bt_mailbox, 0); - ASSERT(*mail, "app_bt_mail_alloc error"); - return 0; +static void app_bt_mail_poll(void) { + APP_BT_MAIL *mail_p = NULL; + if (!app_bt_mail_get(&mail_p)) { + app_bt_mail_process(mail_p); + app_bt_mail_free(mail_p); + osapi_notify_evm(); + } } -static inline int app_bt_mail_send(APP_BT_MAIL* mail) -{ - osStatus status; - - ASSERT(mail, "osMailAlloc NULL"); - status = osMailPut(app_bt_mailbox, mail); - ASSERT(osOK == status, "osMailAlloc Put failed"); - - OS_NotifyEvm(); - - return (int)status; -} - -static inline int app_bt_mail_free(APP_BT_MAIL* mail_p) -{ - osStatus status; - - status = osMailFree(app_bt_mailbox, mail_p); - ASSERT(osOK == status, "osMailAlloc Put failed"); - - return (int)status; -} - -static inline int app_bt_mail_get(APP_BT_MAIL** mail_p) -{ - osEvent evt; - evt = osMailGet(app_bt_mailbox, 0); - if (evt.status == osEventMail) { - *mail_p = (APP_BT_MAIL *)evt.value.p; - return 0; - } +int app_bt_mail_init(void) { + app_bt_mailbox = osMailCreate(osMailQ(app_bt_mailbox), NULL); + if (app_bt_mailbox == NULL) { + TRACE(0, "Failed to Create app_mailbox\n"); return -1; + } + Besbt_hook_handler_set(BESBT_HOOK_USER_1, app_bt_mail_poll); + + return 0; } -static void app_bt_mail_poll(void) -{ - APP_BT_MAIL *mail_p = NULL; - if (!app_bt_mail_get(&mail_p)){ - app_bt_mail_process(mail_p); - app_bt_mail_free(mail_p); - osapi_notify_evm(); - } +int app_bt_Me_switch_sco(uint16_t scohandle) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = Me_switch_sco_req; + mail->param.Me_switch_sco_param.scohandle = scohandle; + app_bt_mail_send(mail); + return 0; } -int app_bt_mail_init(void) -{ - app_bt_mailbox = osMailCreate(osMailQ(app_bt_mailbox), NULL); - if (app_bt_mailbox == NULL) { - TRACE(0,"Failed to Create app_mailbox\n"); - return -1; - } - Besbt_hook_handler_set(BESBT_HOOK_USER_1, app_bt_mail_poll); - - return 0; -} - -int app_bt_Me_switch_sco(uint16_t scohandle) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = Me_switch_sco_req; - mail->param.Me_switch_sco_param.scohandle = scohandle; - app_bt_mail_send(mail); - return 0; -} - -int app_bt_ME_SwitchRole(btif_remote_device_t* remDev) -{ +int app_bt_ME_SwitchRole(btif_remote_device_t *remDev) { #if !defined(IBRT) - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = ME_SwitchRole_req; - mail->param.ME_SwitchRole_param.remDev = remDev; - app_bt_mail_send(mail); + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = ME_SwitchRole_req; + mail->param.ME_SwitchRole_param.remDev = remDev; + app_bt_mail_send(mail); #endif - return 0; + return 0; } -int app_bt_ME_SetConnectionRole(btif_connection_role_t role) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = ME_SetConnectionRole_req; - mail->param.BtConnectionRole_param.role = role; - app_bt_mail_send(mail); - return 0; +int app_bt_ME_SetConnectionRole(btif_connection_role_t role) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = ME_SetConnectionRole_req; + mail->param.BtConnectionRole_param.role = role; + app_bt_mail_send(mail); + return 0; } -int app_bt_MeDisconnectLink(btif_remote_device_t* remDev) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = MeDisconnectLink_req; - mail->param.MeDisconnectLink_param.remDev = remDev; - app_bt_mail_send(mail); - return 0; +int app_bt_MeDisconnectLink(btif_remote_device_t *remDev) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = MeDisconnectLink_req; + mail->param.MeDisconnectLink_param.remDev = remDev; + app_bt_mail_send(mail); + return 0; } -int app_bt_ME_StopSniff(btif_remote_device_t *remDev) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = ME_StopSniff_req; - mail->param.ME_StopSniff_param.remDev = remDev; - app_bt_mail_send(mail); - return 0; +int app_bt_ME_StopSniff(btif_remote_device_t *remDev) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = ME_StopSniff_req; + mail->param.ME_StopSniff_param.remDev = remDev; + app_bt_mail_send(mail); + return 0; } -int app_bt_ME_StartSniff(btif_remote_device_t *remDev, btif_sniff_info_t* sniffInfo) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = ME_StartSniff_req; - mail->param.ME_StartSniff_param.remDev = remDev; - mail->param.ME_StartSniff_param.sniffInfo = *sniffInfo; - app_bt_mail_send(mail); - return 0; +int app_bt_ME_StartSniff(btif_remote_device_t *remDev, + btif_sniff_info_t *sniffInfo) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = ME_StartSniff_req; + mail->param.ME_StartSniff_param.remDev = remDev; + mail->param.ME_StartSniff_param.sniffInfo = *sniffInfo; + app_bt_mail_send(mail); + return 0; } -int app_bt_ME_ControlSleepMode(bool isEnabled) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = BT_Control_SleepMode_req; - mail->param.ME_BtControlSleepMode_param.isEnable = isEnabled; - app_bt_mail_send(mail); - return 0; +int app_bt_ME_ControlSleepMode(bool isEnabled) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = BT_Control_SleepMode_req; + mail->param.ME_BtControlSleepMode_param.isEnable = isEnabled; + app_bt_mail_send(mail); + return 0; } -int app_bt_ME_SetAccessibleMode(btif_accessible_mode_t mode, const btif_access_mode_info_t *info) -{ +int app_bt_ME_SetAccessibleMode(btif_accessible_mode_t mode, + const btif_access_mode_info_t *info) { #if defined(BLE_ONLY_ENABLED) - return 0; + return 0; #endif - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = ME_SetAccessibleMode_req; - mail->param.ME_SetAccessibleMode_param.mode = mode; - memcpy(&mail->param.ME_SetAccessibleMode_param.info, info, sizeof(btif_access_mode_info_t)); - app_bt_mail_send(mail); - return 0; + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = ME_SetAccessibleMode_req; + mail->param.ME_SetAccessibleMode_param.mode = mode; + memcpy(&mail->param.ME_SetAccessibleMode_param.info, info, + sizeof(btif_access_mode_info_t)); + app_bt_mail_send(mail); + return 0; } #ifdef FPGA -int app_bt_ME_SetAccessibleMode_Fortest(btif_accessible_mode_t mode, const btif_access_mode_info_t *info) -{ +int app_bt_ME_SetAccessibleMode_Fortest(btif_accessible_mode_t mode, + const btif_access_mode_info_t *info) { #if defined(BLE_ONLY_ENABLED) - return 0; + return 0; #endif - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = BT_Set_Access_Mode_Test; - mail->param.ME_SetAccessibleMode_param.mode = mode; - memcpy(&mail->param.ME_SetAccessibleMode_param.info, info, sizeof(btif_access_mode_info_t)); - app_bt_mail_send(mail); - return 0; + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = BT_Set_Access_Mode_Test; + mail->param.ME_SetAccessibleMode_param.mode = mode; + memcpy(&mail->param.ME_SetAccessibleMode_param.info, info, + sizeof(btif_access_mode_info_t)); + app_bt_mail_send(mail); + return 0; } -int app_bt_ME_Set_Advmode_Fortest(uint8_t en) -{ +int app_bt_ME_Set_Advmode_Fortest(uint8_t en) { - - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = BT_Set_Adv_Mode_Test; - mail->param.ME_BtSetAdvMode_param.isEnable = en; - app_bt_mail_send(mail); - return 0; + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = BT_Set_Adv_Mode_Test; + mail->param.ME_BtSetAdvMode_param.isEnable = en; + app_bt_mail_send(mail); + return 0; } -int app_bt_ME_Write_Controller_Memory_Fortest(uint32_t addr,uint32_t val,uint8_t type) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = Write_Controller_Memory_Test; - mail->param.Me_writecontrollermem_param.addr = addr; - mail->param.Me_writecontrollermem_param.memval = val; - mail->param.Me_writecontrollermem_param.type = type; - app_bt_mail_send(mail); - return 0; +int app_bt_ME_Write_Controller_Memory_Fortest(uint32_t addr, uint32_t val, + uint8_t type) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = Write_Controller_Memory_Test; + mail->param.Me_writecontrollermem_param.addr = addr; + mail->param.Me_writecontrollermem_param.memval = val; + mail->param.Me_writecontrollermem_param.type = type; + app_bt_mail_send(mail); + return 0; } -int app_bt_ME_Read_Controller_Memory_Fortest(uint32_t addr,uint32_t len,uint8_t type) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = Read_Controller_Memory_Test; - mail->param.Me_readcontrollermem_param.addr = addr; - mail->param.Me_readcontrollermem_param.len = len; - mail->param.Me_readcontrollermem_param.type = type; - app_bt_mail_send(mail); - return 0; +int app_bt_ME_Read_Controller_Memory_Fortest(uint32_t addr, uint32_t len, + uint8_t type) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = Read_Controller_Memory_Test; + mail->param.Me_readcontrollermem_param.addr = addr; + mail->param.Me_readcontrollermem_param.len = len; + mail->param.Me_readcontrollermem_param.type = type; + app_bt_mail_send(mail); + return 0; } #endif -int app_bt_Me_SetLinkPolicy(btif_remote_device_t *remDev, btif_link_policy_t policy) -{ +int app_bt_Me_SetLinkPolicy(btif_remote_device_t *remDev, + btif_link_policy_t policy) { #if !defined(IBRT) - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = Me_SetLinkPolicy_req; - mail->param.Me_SetLinkPolicy_param.remDev = remDev; - mail->param.Me_SetLinkPolicy_param.policy = policy; - app_bt_mail_send(mail); + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = Me_SetLinkPolicy_req; + mail->param.Me_SetLinkPolicy_param.remDev = remDev; + mail->param.Me_SetLinkPolicy_param.policy = policy; + app_bt_mail_send(mail); #endif - return 0; + return 0; } -int app_bt_CMGR_SetSniffTimer( btif_cmgr_handler_t *Handler, - btif_sniff_info_t* SniffInfo, - TimeT Time) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = CMGR_SetSniffTimer_req; - mail->param.CMGR_SetSniffTimer_param.Handler = Handler; - if (SniffInfo){ - memcpy(&mail->param.CMGR_SetSniffTimer_param.SniffInfo, SniffInfo, sizeof(btif_sniff_info_t)); - }else{ - memset(&mail->param.CMGR_SetSniffTimer_param.SniffInfo, 0, sizeof(btif_sniff_info_t)); - } - mail->param.CMGR_SetSniffTimer_param.Time = Time; - app_bt_mail_send(mail); - return 0; +int app_bt_CMGR_SetSniffTimer(btif_cmgr_handler_t *Handler, + btif_sniff_info_t *SniffInfo, TimeT Time) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = CMGR_SetSniffTimer_req; + mail->param.CMGR_SetSniffTimer_param.Handler = Handler; + if (SniffInfo) { + memcpy(&mail->param.CMGR_SetSniffTimer_param.SniffInfo, SniffInfo, + sizeof(btif_sniff_info_t)); + } else { + memset(&mail->param.CMGR_SetSniffTimer_param.SniffInfo, 0, + sizeof(btif_sniff_info_t)); + } + mail->param.CMGR_SetSniffTimer_param.Time = Time; + app_bt_mail_send(mail); + return 0; } -int app_bt_CMGR_SetSniffInfoToAllHandlerByRemDev(btif_sniff_info_t* SniffInfo, - btif_remote_device_t *RemDev) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = CMGR_SetSniffInofToAllHandlerByRemDev_req; - memcpy(&mail->param.CMGR_SetSniffInofToAllHandlerByRemDev_param.SniffInfo, SniffInfo, sizeof(btif_sniff_info_t)); - mail->param.CMGR_SetSniffInofToAllHandlerByRemDev_param.RemDev = RemDev; - app_bt_mail_send(mail); - return 0; +int app_bt_CMGR_SetSniffInfoToAllHandlerByRemDev(btif_sniff_info_t *SniffInfo, + btif_remote_device_t *RemDev) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = CMGR_SetSniffInofToAllHandlerByRemDev_req; + memcpy(&mail->param.CMGR_SetSniffInofToAllHandlerByRemDev_param.SniffInfo, + SniffInfo, sizeof(btif_sniff_info_t)); + mail->param.CMGR_SetSniffInofToAllHandlerByRemDev_param.RemDev = RemDev; + app_bt_mail_send(mail); + return 0; } -int app_bt_A2DP_OpenStream(a2dp_stream_t *Stream, bt_bdaddr_t *Addr) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = A2DP_OpenStream_req; - mail->param.A2DP_OpenStream_param.Stream = Stream; - mail->param.A2DP_OpenStream_param.Addr = Addr; - app_bt_mail_send(mail); - return 0; +int app_bt_A2DP_OpenStream(a2dp_stream_t *Stream, bt_bdaddr_t *Addr) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = A2DP_OpenStream_req; + mail->param.A2DP_OpenStream_param.Stream = Stream; + mail->param.A2DP_OpenStream_param.Addr = Addr; + app_bt_mail_send(mail); + return 0; } -int app_bt_A2DP_CloseStream(a2dp_stream_t *Stream) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = A2DP_CloseStream_req; - mail->param.A2DP_CloseStream_param.Stream = Stream; - app_bt_mail_send(mail); - return 0; +int app_bt_A2DP_CloseStream(a2dp_stream_t *Stream) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = A2DP_CloseStream_req; + mail->param.A2DP_CloseStream_param.Stream = Stream; + app_bt_mail_send(mail); + return 0; } -int app_bt_A2DP_SetMasterRole(a2dp_stream_t *Stream, BOOL Flag) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = A2DP_SetMasterRole_req; - mail->param.A2DP_SetMasterRole_param.Stream = Stream; - mail->param.A2DP_SetMasterRole_param.Flag = Flag; - app_bt_mail_send(mail); - return 0; +int app_bt_A2DP_SetMasterRole(a2dp_stream_t *Stream, BOOL Flag) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = A2DP_SetMasterRole_req; + mail->param.A2DP_SetMasterRole_param.Stream = Stream; + mail->param.A2DP_SetMasterRole_param.Flag = Flag; + app_bt_mail_send(mail); + return 0; } -int app_bt_HF_CreateServiceLink(hf_chan_handle_t Chan, bt_bdaddr_t *Addr) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = HF_CreateServiceLink_req; - mail->param.HF_CreateServiceLink_param.Chan = Chan; - mail->param.HF_CreateServiceLink_param.Addr = Addr; - app_bt_mail_send(mail); - return 0; +int app_bt_HF_CreateServiceLink(hf_chan_handle_t Chan, bt_bdaddr_t *Addr) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = HF_CreateServiceLink_req; + mail->param.HF_CreateServiceLink_param.Chan = Chan; + mail->param.HF_CreateServiceLink_param.Addr = Addr; + app_bt_mail_send(mail); + return 0; } -int app_bt_HF_DisconnectServiceLink(hf_chan_handle_t Chan) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = HF_DisconnectServiceLink_req; - mail->param.HF_DisconnectServiceLink_param.Chan = Chan; - app_bt_mail_send(mail); - return 0; +int app_bt_HF_DisconnectServiceLink(hf_chan_handle_t Chan) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = HF_DisconnectServiceLink_req; + mail->param.HF_DisconnectServiceLink_param.Chan = Chan; + app_bt_mail_send(mail); + return 0; } -int app_bt_HF_CreateAudioLink(hf_chan_handle_t Chan) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = HF_CreateAudioLink_req; - mail->param.HF_CreateAudioLink_param.Chan = Chan; - app_bt_mail_send(mail); - return 0; +int app_bt_HF_CreateAudioLink(hf_chan_handle_t Chan) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = HF_CreateAudioLink_req; + mail->param.HF_CreateAudioLink_param.Chan = Chan; + app_bt_mail_send(mail); + return 0; } -int app_bt_HF_DisconnectAudioLink(hf_chan_handle_t Chan) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = HF_DisconnectAudioLink_req; - mail->param.HF_DisconnectAudioLink_param.Chan = Chan; - app_bt_mail_send(mail); - return 0; +int app_bt_HF_DisconnectAudioLink(hf_chan_handle_t Chan) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = HF_DisconnectAudioLink_req; + mail->param.HF_DisconnectAudioLink_param.Chan = Chan; + app_bt_mail_send(mail); + return 0; } -int app_bt_HF_EnableSniffMode(hf_chan_handle_t Chan, BOOL Enable) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = HF_EnableSniffMode_req; - mail->param.HF_EnableSniffMode_param.Chan = Chan; - mail->param.HF_EnableSniffMode_param.Enable = Enable; - app_bt_mail_send(mail); - return 0; +int app_bt_HF_EnableSniffMode(hf_chan_handle_t Chan, BOOL Enable) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = HF_EnableSniffMode_req; + mail->param.HF_EnableSniffMode_param.Chan = Chan; + mail->param.HF_EnableSniffMode_param.Enable = Enable; + app_bt_mail_send(mail); + return 0; } -int app_bt_HF_SetMasterRole(hf_chan_handle_t Chan, BOOL Flag) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = HF_SetMasterRole_req; - mail->param.HF_SetMasterRole_param.Chan = Chan; - mail->param.HF_SetMasterRole_param.Flag = Flag; - app_bt_mail_send(mail); - return 0; +int app_bt_HF_SetMasterRole(hf_chan_handle_t Chan, BOOL Flag) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = HF_SetMasterRole_req; + mail->param.HF_SetMasterRole_param.Chan = Chan; + mail->param.HF_SetMasterRole_param.Flag = Flag; + app_bt_mail_send(mail); + return 0; } #ifdef BTIF_DIP_DEVICE -int app_bt_dip_QuryService(btif_dip_client_t *client, btif_remote_device_t* rem) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = DIP_QuryService_req; - mail->param.DIP_QuryService_param.remDev = rem; - mail->param.DIP_QuryService_param.dip_client = client; - app_bt_mail_send(mail); - return 0; +int app_bt_dip_QuryService(btif_dip_client_t *client, + btif_remote_device_t *rem) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = DIP_QuryService_req; + mail->param.DIP_QuryService_param.remDev = rem; + mail->param.DIP_QuryService_param.dip_client = client; + app_bt_mail_send(mail); + return 0; } #endif -#if defined (__HSP_ENABLE__) -int app_bt_HS_CreateServiceLink(HsChannel *Chan, bt_bdaddr_t *Addr) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = HS_CreateServiceLink_req; - mail->param.HS_CreateServiceLink_param.Chan = Chan; - mail->param.HS_CreateServiceLink_param.Addr = Addr; - app_bt_mail_send(mail); - return 0; +#if defined(__HSP_ENABLE__) +int app_bt_HS_CreateServiceLink(HsChannel *Chan, bt_bdaddr_t *Addr) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = HS_CreateServiceLink_req; + mail->param.HS_CreateServiceLink_param.Chan = Chan; + mail->param.HS_CreateServiceLink_param.Addr = Addr; + app_bt_mail_send(mail); + return 0; } -int app_bt_HS_CreateAudioLink(HsChannel *Chan) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = HS_CreateAudioLink_req; - mail->param.HS_CreateAudioLink_param.Chan = Chan; - app_bt_mail_send(mail); - return 0; +int app_bt_HS_CreateAudioLink(HsChannel *Chan) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = HS_CreateAudioLink_req; + mail->param.HS_CreateAudioLink_param.Chan = Chan; + app_bt_mail_send(mail); + return 0; } - -int app_bt_HS_DisconnectAudioLink(HsChannel *Chan) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = HS_DisconnectAudioLink_req; - mail->param.HS_DisconnectAudioLink_param.Chan = Chan; - app_bt_mail_send(mail); - return 0; +int app_bt_HS_DisconnectAudioLink(HsChannel *Chan) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = HS_DisconnectAudioLink_req; + mail->param.HS_DisconnectAudioLink_param.Chan = Chan; + app_bt_mail_send(mail); + return 0; } -int app_bt_HS_DisconnectServiceLink(HsChannel *Chan) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = HS_DisconnectServiceLink_req; - mail->param.HS_DisconnectServiceLink_param.Chan = Chan; - app_bt_mail_send(mail); - return 0; +int app_bt_HS_DisconnectServiceLink(HsChannel *Chan) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = HS_DisconnectServiceLink_req; + mail->param.HS_DisconnectServiceLink_param.Chan = Chan; + app_bt_mail_send(mail); + return 0; } - -int app_bt_HS_EnableSniffMode(HsChannel *Chan, BOOL Enable) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = HS_EnableSniffMode_req; - mail->param.HS_EnableSniffMode_param.Chan = Chan; - mail->param.HS_EnableSniffMode_param.Enable = Enable; - app_bt_mail_send(mail); - return 0; +int app_bt_HS_EnableSniffMode(HsChannel *Chan, BOOL Enable) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = HS_EnableSniffMode_req; + mail->param.HS_EnableSniffMode_param.Chan = Chan; + mail->param.HS_EnableSniffMode_param.Enable = Enable; + app_bt_mail_send(mail); + return 0; } #endif -int app_bt_start_custom_function_in_bt_thread( - uint32_t param0, uint32_t param1, uint32_t funcPtr) -{ - APP_BT_MAIL* mail; - app_bt_mail_alloc(&mail); - mail->src_thread = (uint32_t)osThreadGetId(); - mail->request_id = BT_Custom_Func_req; - mail->param.CustomFunc_param.func_ptr = funcPtr; - mail->param.CustomFunc_param.param0 = param0; - mail->param.CustomFunc_param.param1 = param1; - app_bt_mail_send(mail); - return 0; +int app_bt_start_custom_function_in_bt_thread(uint32_t param0, uint32_t param1, + uint32_t funcPtr) { + APP_BT_MAIL *mail; + app_bt_mail_alloc(&mail); + mail->src_thread = (uint32_t)osThreadGetId(); + mail->request_id = BT_Custom_Func_req; + mail->param.CustomFunc_param.func_ptr = funcPtr; + mail->param.CustomFunc_param.param0 = param0; + mail->param.CustomFunc_param.param1 = param1; + app_bt_mail_send(mail); + return 0; } - - diff --git a/services/bt_app/app_bt_hid.cpp b/services/bt_app/app_bt_hid.cpp index 25dce5d..d25ff4e 100644 --- a/services/bt_app/app_bt_hid.cpp +++ b/services/bt_app/app_bt_hid.cpp @@ -14,43 +14,42 @@ * ****************************************************************************/ #ifdef BTIF_HID_DEVICE -#include -#include "cmsis_os.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "lockcqueue.h" -#include "hal_trace.h" -#include "hal_cmu.h" -#include "hal_chipid.h" #include "analog.h" #include "app_audio.h" #include "app_battery.h" -#include "hal_trace.h" #include "app_status_ind.h" #include "bluetooth.h" +#include "cmsis_os.h" +#include "hal_chipid.h" +#include "hal_cmu.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "lockcqueue.h" #include "nvrecord.h" -#include "nvrecord_env.h" #include "nvrecord_dev.h" +#include "nvrecord_env.h" +#include #if defined(NEW_NV_RECORD_ENABLED) #include "nvrecord_bt.h" #endif -#include "besbt.h" -#include "cqueue.h" -#include "btapp.h" -#include "app_bt.h" -#include "apps.h" -#include "resources.h" -#include "bt_if.h" -#include "os_api.h" -#include "app_bt_func.h" -#include "bt_drv_interface.h" #include "app.h" -#include "bt_drv_reg_op.h" -#include "besbt_cfg.h" -#include "me_api.h" -#include "app_tws_ibrt.h" +#include "app_bt.h" +#include "app_bt_func.h" #include "app_bt_hid.h" +#include "app_tws_ibrt.h" +#include "apps.h" +#include "besbt.h" +#include "besbt_cfg.h" +#include "bt_drv_interface.h" +#include "bt_drv_reg_op.h" +#include "bt_if.h" +#include "btapp.h" +#include "cqueue.h" #include "hid_api.h" +#include "me_api.h" +#include "os_api.h" +#include "resources.h" static bool shutter_mode = false; static bool send_capture_pending = false; @@ -58,189 +57,171 @@ static bool send_capture_pending = false; #define APP_BT_HID_DELAY_SEND_CAPTURE_MS 500 osTimerId app_bt_hid_delay_send_timer_id = 0; static void app_bt_hid_delay_send_timer_handler(void const *param); -osTimerDef (APP_BT_HID_DELAY_SEND_CAPTURE_TIMER, app_bt_hid_delay_send_timer_handler); +osTimerDef(APP_BT_HID_DELAY_SEND_CAPTURE_TIMER, + app_bt_hid_delay_send_timer_handler); -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; -static void app_bt_hid_delay_send_timer_handler(void const *param) -{ - hid_channel_t chan = (hid_channel_t)param; - app_bt_start_custom_function_in_bt_thread((uint32_t)&chan, (uint32_t)NULL, (uint32_t)app_bt_hid_send_capture); +static void app_bt_hid_delay_send_timer_handler(void const *param) { + hid_channel_t chan = (hid_channel_t)param; + app_bt_start_custom_function_in_bt_thread((uint32_t)&chan, (uint32_t)NULL, + (uint32_t)app_bt_hid_send_capture); } -static void app_bt_hid_delay_send_capture(hid_channel_t chan) -{ - if (app_bt_hid_delay_send_timer_id) - { - osTimerStop(app_bt_hid_delay_send_timer_id); - osTimerDelete(app_bt_hid_delay_send_timer_id); - app_bt_hid_delay_send_timer_id = 0; - } +static void app_bt_hid_delay_send_capture(hid_channel_t chan) { + if (app_bt_hid_delay_send_timer_id) { + osTimerStop(app_bt_hid_delay_send_timer_id); + osTimerDelete(app_bt_hid_delay_send_timer_id); + app_bt_hid_delay_send_timer_id = 0; + } - app_bt_hid_delay_send_timer_id = osTimerCreate(osTimer(APP_BT_HID_DELAY_SEND_CAPTURE_TIMER), osTimerOnce, chan); + app_bt_hid_delay_send_timer_id = osTimerCreate( + osTimer(APP_BT_HID_DELAY_SEND_CAPTURE_TIMER), osTimerOnce, chan); - if (!app_bt_hid_delay_send_timer_id) - { - TRACE(1, "%s create timer failed", __func__); - return; - } + if (!app_bt_hid_delay_send_timer_id) { + TRACE(1, "%s create timer failed", __func__); + return; + } - TRACE(2, "%s channel %p", __func__, chan); + TRACE(2, "%s channel %p", __func__, chan); - osTimerStart(app_bt_hid_delay_send_timer_id, APP_BT_HID_DELAY_SEND_CAPTURE_MS); + osTimerStart(app_bt_hid_delay_send_timer_id, + APP_BT_HID_DELAY_SEND_CAPTURE_MS); } -static void app_bt_hid_callback(hid_channel_t chan, const hid_callback_parms_t *param) -{ - btif_hid_callback_param_t *info = (btif_hid_callback_param_t *)param; +static void app_bt_hid_callback(hid_channel_t chan, + const hid_callback_parms_t *param) { + btif_hid_callback_param_t *info = (btif_hid_callback_param_t *)param; - TRACE(9, "%s channel %p event %d errno %02x %02x:%02x:%02x:%02x:%02x:%02x", - __func__, chan, info->event, info->error_code, - info->remote.address[0], info->remote.address[1], info->remote.address[2], - info->remote.address[3], info->remote.address[4], info->remote.address[5]); + TRACE(9, "%s channel %p event %d errno %02x %02x:%02x:%02x:%02x:%02x:%02x", + __func__, chan, info->event, info->error_code, info->remote.address[0], + info->remote.address[1], info->remote.address[2], + info->remote.address[3], info->remote.address[4], + info->remote.address[5]); - switch (info->event) - { - case BTIF_HID_EVENT_CONN_OPENED: - shutter_mode = true; - if (send_capture_pending) - { - app_bt_hid_delay_send_capture(chan); - send_capture_pending = false; - } - break; - case BTIF_HID_EVENT_CONN_CLOSED: - shutter_mode = false; - break; - default: - break; + switch (info->event) { + case BTIF_HID_EVENT_CONN_OPENED: + shutter_mode = true; + if (send_capture_pending) { + app_bt_hid_delay_send_capture(chan); + send_capture_pending = false; } - app_tws_ibrt_profile_callback(BTIF_APP_HID_PROFILE_ID, (void *)chan, (void *)param); + break; + case BTIF_HID_EVENT_CONN_CLOSED: + shutter_mode = false; + break; + default: + break; + } + app_tws_ibrt_profile_callback(BTIF_APP_HID_PROFILE_ID, (void *)chan, + (void *)param); } -void app_bt_hid_init(void) -{ - //TRACE(2, "%s sink_enable %d", __func__, besbt_cfg.sink_enable); - //if (besbt_cfg.sink_enable) - { - btif_hid_init(app_bt_hid_callback, HID_DEVICE_ROLE); +void app_bt_hid_init(void) { + // TRACE(2, "%s sink_enable %d", __func__, besbt_cfg.sink_enable); + // if (besbt_cfg.sink_enable) + { + btif_hid_init(app_bt_hid_callback, HID_DEVICE_ROLE); - for (int i = 0; i < BT_DEVICE_NUM; ++i) - { - app_bt_device.hid_channel[i] = btif_hid_channel_alloc(); - TRACE(2, "app_bt_hid_init device: %d hid_channle: %p", i, app_bt_device.hid_channel[i]); - } + for (int i = 0; i < BT_DEVICE_NUM; ++i) { + app_bt_device.hid_channel[i] = btif_hid_channel_alloc(); + TRACE(2, "app_bt_hid_init device: %d hid_channle: %p", i, + app_bt_device.hid_channel[i]); } + } } -void app_bt_hid_profile_connect(bt_bdaddr_t *bdaddr) -{ - static bt_bdaddr_t remote; +void app_bt_hid_profile_connect(bt_bdaddr_t *bdaddr) { + static bt_bdaddr_t remote; - remote = *bdaddr; + remote = *bdaddr; - TRACE(7, "%s address %02x:%02x:%02x:%02x:%02x:%02x", __func__, + TRACE(7, "%s address %02x:%02x:%02x:%02x:%02x:%02x", __func__, remote.address[0], remote.address[1], remote.address[2], remote.address[3], remote.address[4], remote.address[5]); - app_bt_start_custom_function_in_bt_thread((uint32_t)&remote, (uint32_t)NULL, (uint32_t)btif_hid_connect); + app_bt_start_custom_function_in_bt_thread((uint32_t)&remote, (uint32_t)NULL, + (uint32_t)btif_hid_connect); } -void app_bt_hid_profile_disconnect(hid_channel_t chnl) -{ - TRACE(1, "%s channel %p", __func__, chnl); +void app_bt_hid_profile_disconnect(hid_channel_t chnl) { + TRACE(1, "%s channel %p", __func__, chnl); - app_bt_start_custom_function_in_bt_thread((uint32_t)chnl, (uint32_t)NULL, (uint32_t)btif_hid_disconnect); + app_bt_start_custom_function_in_bt_thread((uint32_t)chnl, (uint32_t)NULL, + (uint32_t)btif_hid_disconnect); } -int app_bt_nvrecord_get_latest_device_addr(bt_bdaddr_t *addr) -{ - btif_device_record_t record; - int found_addr_count = 0; - int paired_dev_count = nv_record_get_paired_dev_count(); +int app_bt_nvrecord_get_latest_device_addr(bt_bdaddr_t *addr) { + btif_device_record_t record; + int found_addr_count = 0; + int paired_dev_count = nv_record_get_paired_dev_count(); - if (paired_dev_count > 0 && BT_STS_SUCCESS == nv_record_enum_dev_records(0, &record)) - { - *addr = record.bdAddr; - found_addr_count = 1; - } + if (paired_dev_count > 0 && + BT_STS_SUCCESS == nv_record_enum_dev_records(0, &record)) { + *addr = record.bdAddr; + found_addr_count = 1; + } - return found_addr_count; + return found_addr_count; } -void app_bt_hid_enter_shutter_mode(void) -{ - bt_bdaddr_t remote; +void app_bt_hid_enter_shutter_mode(void) { + bt_bdaddr_t remote; - TRACE(1, "%s", __func__); + TRACE(1, "%s", __func__); - if (!app_bt_nvrecord_get_latest_device_addr(&remote)) - { - TRACE(1, "%s latest device not found", __func__); - return; - } + if (!app_bt_nvrecord_get_latest_device_addr(&remote)) { + TRACE(1, "%s latest device not found", __func__); + return; + } - if (!shutter_mode) - { - app_bt_hid_profile_connect(&remote); - shutter_mode = true; - } - else - { - TRACE(1, "%s already in shutter mode", __func__); - } + if (!shutter_mode) { + app_bt_hid_profile_connect(&remote); + shutter_mode = true; + } else { + TRACE(1, "%s already in shutter mode", __func__); + } } -void app_bt_hid_exit_shutter_mode(void) -{ - hid_channel_t chnl = NULL; - int i = 0; +void app_bt_hid_exit_shutter_mode(void) { + hid_channel_t chnl = NULL; + int i = 0; - TRACE(0, "%s", __func__); + TRACE(0, "%s", __func__); - for (; i < BT_DEVICE_NUM; ++i) - { - chnl = app_bt_device.hid_channel[i]; - if (btif_hid_is_connected(chnl)) - { - app_bt_hid_profile_disconnect(chnl); - } + for (; i < BT_DEVICE_NUM; ++i) { + chnl = app_bt_device.hid_channel[i]; + if (btif_hid_is_connected(chnl)) { + app_bt_hid_profile_disconnect(chnl); } + } - shutter_mode = false; + shutter_mode = false; } -void app_bt_hid_send_capture(hid_channel_t chnl) -{ - for (int i = 0; i < BT_DEVICE_NUM; ++i) - { - if (btif_hid_is_connected(app_bt_device.hid_channel[i])) - { - chnl = app_bt_device.hid_channel[i]; - break; - } +void app_bt_hid_send_capture(hid_channel_t chnl) { + for (int i = 0; i < BT_DEVICE_NUM; ++i) { + if (btif_hid_is_connected(app_bt_device.hid_channel[i])) { + chnl = app_bt_device.hid_channel[i]; + break; } + } - TRACE(3, "%s channel %p state %d", __func__, chnl, btif_hid_get_state(chnl)); + TRACE(3, "%s channel %p state %d", __func__, chnl, btif_hid_get_state(chnl)); - if (btif_hid_is_connected(chnl)) - { - send_capture_pending = false; + if (btif_hid_is_connected(chnl)) { + send_capture_pending = false; - btif_hid_keyboard_input_report(chnl, HID_MOD_KEY_NULL, HID_KEY_CODE_ENTER); - btif_hid_keyboard_input_report(chnl, HID_MOD_KEY_NULL, HID_KEY_CODE_NULL); + btif_hid_keyboard_input_report(chnl, HID_MOD_KEY_NULL, HID_KEY_CODE_ENTER); + btif_hid_keyboard_input_report(chnl, HID_MOD_KEY_NULL, HID_KEY_CODE_NULL); - btif_hid_keyboard_send_ctrl_key(chnl, HID_CTRL_KEY_VOLUME_INC); - btif_hid_keyboard_send_ctrl_key(chnl, HID_CTRL_KEY_NULL); - } - else - { - send_capture_pending = true; - - app_bt_hid_enter_shutter_mode(); - } + btif_hid_keyboard_send_ctrl_key(chnl, HID_CTRL_KEY_VOLUME_INC); + btif_hid_keyboard_send_ctrl_key(chnl, HID_CTRL_KEY_NULL); + } else { + send_capture_pending = true; + app_bt_hid_enter_shutter_mode(); + } } #endif /* BTIF_HID_DEVICE */ - diff --git a/services/bt_app/app_bt_media_manager.cpp b/services/bt_app/app_bt_media_manager.cpp index 1394e03..5070945 100644 --- a/services/bt_app/app_bt_media_manager.cpp +++ b/services/bt_app/app_bt_media_manager.cpp @@ -13,24 +13,24 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include #include +#include -#include "cmsis_os.h" -#include "cmsis.h" -#include "app_bt_trace.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "hal_chipid.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_trace.h" -#include "hal_cmu.h" #include "analog.h" -#include "app_bt_stream.h" -#include "app_overlay.h" #include "app_audio.h" +#include "app_bt_stream.h" +#include "app_bt_trace.h" +#include "app_overlay.h" #include "app_utils.h" +#include "audioflinger.h" +#include "cmsis.h" +#include "cmsis_os.h" +#include "hal_chipid.h" +#include "hal_cmu.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "lockcqueue.h" #include "nvrecord.h" #if defined(IBRT) #include "app_ibrt_if.h" @@ -43,1141 +43,1053 @@ #include "app_media_player.h" #endif -#include "bt_drv.h" -#include "apps.h" #include "app_bt_func.h" +#include "apps.h" +#include "bt_drv.h" #include "besbt.h" -#include "cqueue.h" -#include "btapp.h" #include "app_hfp.h" +#include "btapp.h" +#include "cqueue.h" #include "app_bt_media_manager.h" #include "app_thread.h" -#include "app_ring_merge.h" -#include "bt_if.h" -#include "audio_prompt_sbc.h" #include "app_ai_if.h" - +#include "app_ring_merge.h" +#include "audio_prompt_sbc.h" +#include "bt_if.h" int bt_sco_player_forcemute(bool mic_mute, bool spk_mute); int bt_sco_player_get_codetype(void); -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; extern enum AUD_SAMPRATE_T a2dp_sample_rate; -struct bt_media_manager -{ - uint16_t media_active[BT_DEVICE_NUM]; - uint8_t media_current_call_state[BT_DEVICE_NUM]; - uint8_t media_curr_sbc; - uint8_t media_curr_sco; - uint16_t curr_active_media; // low 8 bits are out direciton, while high 8 bits are in direction +struct bt_media_manager { + uint16_t media_active[BT_DEVICE_NUM]; + uint8_t media_current_call_state[BT_DEVICE_NUM]; + uint8_t media_curr_sbc; + uint8_t media_curr_sco; + uint16_t curr_active_media; // low 8 bits are out direciton, while high 8 bits + // are in direction }; static char _strm_type_str[168]; -static char *_catstr(char *dst, const char *src) -{ - while(*dst) dst++; - while((*dst++ = *src++)); - return --dst; +static char *_catstr(char *dst, const char *src) { + while (*dst) + dst++; + while ((*dst++ = *src++)) + ; + return --dst; } -static const char *strmtype2str(uint16_t stream_type) -{ - const char *s = NULL; - char _cat = 0, first = 1, *d = NULL; - _strm_type_str[0] = '\0'; - d = _strm_type_str; - d = _catstr(d, "["); - if (stream_type != 0) - { - for (int i = 15 ; i >= 0; i--) - { - _cat = 1; - //TRACE_AUD_MGR_I("i=%d,stream_type=0x%d,stream_type&(1<= 0; i--) { + _cat = 1; + // TRACE_AUD_MGR_I("i=%d,stream_type=0x%d,stream_type&(1<%d", bt_meida.media_curr_sbc, id); + bt_meida.media_curr_sbc = id; } -void bt_media_current_sbc_set(uint8_t id) -{ - TRACE_AUD_MGR_I("current sbc %d->%d", bt_meida.media_curr_sbc, id); - bt_meida.media_curr_sbc = id; +static void bt_media_set_current_media(uint16_t media_type) { + // out direction + if (media_type < 0x100) { + bt_meida.curr_active_media &= (~0xFF); + bt_meida.curr_active_media |= media_type; + } else { + // bt_meida.curr_active_media &= (~0xFF00); + bt_meida.curr_active_media |= media_type; + } + + TRACE_AUD_MGR_I("curr_active_media is set to 0x%x->:%s", + bt_meida.curr_active_media, + strmtype2str(bt_meida.curr_active_media)); } -static void bt_media_set_current_media(uint16_t media_type) -{ - // out direction - if (media_type < 0x100) - { - bt_meida.curr_active_media &= (~0xFF); - bt_meida.curr_active_media |= media_type; - } - else - { - //bt_meida.curr_active_media &= (~0xFF00); - bt_meida.curr_active_media |= media_type; - } - - TRACE_AUD_MGR_I("curr_active_media is set to 0x%x->:%s", bt_meida.curr_active_media, strmtype2str(bt_meida.curr_active_media)); -} - -static void bt_media_clear_current_media(uint16_t media_type) -{ - if (media_type < 0x100) - { - bt_meida.curr_active_media &= (~0xFF); - } - else - { - bt_meida.curr_active_media &= (~media_type); - } - TRACE_AUD_MGR_I("clear media 0x%x curr media 0x%x", media_type, bt_meida.curr_active_media); +static void bt_media_clear_current_media(uint16_t media_type) { + if (media_type < 0x100) { + bt_meida.curr_active_media &= (~0xFF); + } else { + bt_meida.curr_active_media &= (~media_type); + } + TRACE_AUD_MGR_I("clear media 0x%x curr media 0x%x", media_type, + bt_meida.curr_active_media); } #ifdef VOICE_DATAPATH #if !ISOLATED_AUDIO_STREAM_ENABLED -static void bt_media_clear_all_media_type(void) -{ - uint8_t i; - for(i=0; i:%s,device id = 0x%x,media_id = 0x%x", - stream_type, - strmtype2str(stream_type), - device_id, - media_id); + TRACE_AUD_MGR_I( + "[HANDLE_START] type= 0x%x->:%s,device id = 0x%x,media_id = 0x%x", + stream_type, strmtype2str(stream_type), device_id, media_id); #ifdef __BT_ONE_BRING_TWO__ - TRACE_AUD_MGR_I( - "[HANDLE_START] media_active[0] = 0x%x->:%s", - bt_meida.media_active[0], - strmtype2str(bt_meida.media_active[0])); - TRACE_AUD_MGR_I( - "[HANDLE_START] media_active[1] = 0x%x->:%s", - bt_meida.media_active[1], - strmtype2str(bt_meida.media_active[1])); - TRACE_AUD_MGR_I( - "[HANDLE_START] curr_active_media = 0x%x->:%s", - bt_meida.curr_active_media, - strmtype2str(bt_meida.curr_active_media)); + TRACE_AUD_MGR_I("[HANDLE_START] media_active[0] = 0x%x->:%s", + bt_meida.media_active[0], + strmtype2str(bt_meida.media_active[0])); + TRACE_AUD_MGR_I("[HANDLE_START] media_active[1] = 0x%x->:%s", + bt_meida.media_active[1], + strmtype2str(bt_meida.media_active[1])); + TRACE_AUD_MGR_I("[HANDLE_START] curr_active_media = 0x%x->:%s", + bt_meida.curr_active_media, + strmtype2str(bt_meida.curr_active_media)); #else - TRACE_AUD_MGR_I( - "[HANDLE_START] media_active = 0x%x->:%s", - bt_meida.media_active[0], - strmtype2str(bt_meida.media_active[0])); - TRACE_AUD_MGR_I( - "[HANDLE_START] curr_active_media = 0x%x->:%s", - bt_meida.curr_active_media, - strmtype2str(bt_meida.curr_active_media)); + TRACE_AUD_MGR_I("[HANDLE_START] media_active = 0x%x->:%s", + bt_meida.media_active[0], + strmtype2str(bt_meida.media_active[0])); + TRACE_AUD_MGR_I("[HANDLE_START] curr_active_media = 0x%x->:%s", + bt_meida.curr_active_media, + strmtype2str(bt_meida.curr_active_media)); #endif - switch(stream_type) - { + switch (stream_type) { #ifdef RB_CODEC - case BT_STREAM_RBCODEC: - if(!bt_media_rbcodec_start_process(stream_type,device_id, (AUD_ID_ENUM)media_id, NULL, NULL)) - goto exit; - break; + case BT_STREAM_RBCODEC: + if (!bt_media_rbcodec_start_process(stream_type, device_id, + (AUD_ID_ENUM)media_id, NULL, NULL)) + goto exit; + break; #endif #ifdef VOICE_DATAPATH - case BT_STREAM_CAPTURE: - if (bt_media_get_current_media() & BT_STREAM_CAPTURE) - { - TRACE_AUD_MGR_I("[HANDLE_START] capture stream exist ,do nothing"); - return; - } + case BT_STREAM_CAPTURE: + if (bt_media_get_current_media() & BT_STREAM_CAPTURE) { + TRACE_AUD_MGR_I("[HANDLE_START] capture stream exist ,do nothing"); + return; + } - if (bt_media_is_media_active_by_type(BT_STREAM_VOICE)) - { - goto exit; - } + if (bt_media_is_media_active_by_type(BT_STREAM_VOICE)) { + goto exit; + } #ifdef MEDIA_PLAYER_SUPPORT #if !ISOLATED_AUDIO_STREAM_ENABLED - if(bt_media_is_media_active_by_type(BT_STREAM_MEDIA)) - { - return; - } + if (bt_media_is_media_active_by_type(BT_STREAM_MEDIA)) { + return; + } #endif #endif - if (!bt_media_voicepath_start_process(BT_STREAM_CAPTURE, device_id, ( AUD_ID_ENUM )media_id, ( uint32_t )NULL, ( uint32_t )NULL)) - goto exit; - break; + if (!bt_media_voicepath_start_process(BT_STREAM_CAPTURE, device_id, + (AUD_ID_ENUM)media_id, (uint32_t)NULL, + (uint32_t)NULL)) + goto exit; + break; #endif #ifdef __AI_VOICE__ - case BT_STREAM_AI_VOICE: - if (bt_media_get_current_media() & BT_STREAM_AI_VOICE) - { - TRACE_AUD_MGR_I("[HANDLE_START] ai voice stream exist ,do nothing"); - return; - } + case BT_STREAM_AI_VOICE: + if (bt_media_get_current_media() & BT_STREAM_AI_VOICE) { + TRACE_AUD_MGR_I("[HANDLE_START] ai voice stream exist ,do nothing"); + return; + } - if (bt_media_is_media_active_by_type(BT_STREAM_VOICE)) - { - TRACE_AUD_MGR_I("[HANDLE_START] SCO stream exist ,do nothing"); - goto exit; - } + if (bt_media_is_media_active_by_type(BT_STREAM_VOICE)) { + TRACE_AUD_MGR_I("[HANDLE_START] SCO stream exist ,do nothing"); + goto exit; + } - if(bt_media_is_media_active_by_type(BT_STREAM_SBC)) - { - if(bt_media_get_current_media() & BT_STREAM_SBC) - { - TRACE_AUD_MGR_I("[HANDLE_START] CLOSE SBC."); - app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_CLOSE, 0); - bt_media_clear_current_media(BT_STREAM_SBC); - } - } + if (bt_media_is_media_active_by_type(BT_STREAM_SBC)) { + if (bt_media_get_current_media() & BT_STREAM_SBC) { + TRACE_AUD_MGR_I("[HANDLE_START] CLOSE SBC."); + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + bt_media_clear_current_media(BT_STREAM_SBC); + } + } - if (!bt_media_ai_voice_start_process(BT_STREAM_AI_VOICE, device_id, ( AUD_ID_ENUM )media_id, ( uint32_t )NULL, ( uint32_t )NULL)) - goto exit; - break; + if (!bt_media_ai_voice_start_process(BT_STREAM_AI_VOICE, device_id, + (AUD_ID_ENUM)media_id, (uint32_t)NULL, + (uint32_t)NULL)) + goto exit; + break; #endif #ifdef __THIRDPARTY - case BT_STREAM_THIRDPARTY_VOICE: - if (bt_media_get_current_media() & BT_STREAM_THIRDPARTY_VOICE) - { - TRACE_AUD_MGR_I("[HANDLE_START]there is a thirdparty voice stream exist ,do nothing"); - return; - } - - if (bt_media_is_media_active_by_type(BT_STREAM_VOICE)) - { - TRACE_AUD_MGR_I("[HANDLE_START]there is a SCO stream exist ,do nothing"); - goto exit; - } - - if (!bt_media_thirdparty_voice_start_process(BT_STREAM_THIRDPARTY_VOICE, device_id, ( AUD_ID_ENUM )media_id, ( uint32_t )NULL, ( uint32_t )NULL)) - goto exit; - break; + case BT_STREAM_THIRDPARTY_VOICE: + if (bt_media_get_current_media() & BT_STREAM_THIRDPARTY_VOICE) { + TRACE_AUD_MGR_I( + "[HANDLE_START]there is a thirdparty voice stream exist ,do nothing"); + return; + } + + if (bt_media_is_media_active_by_type(BT_STREAM_VOICE)) { + TRACE_AUD_MGR_I("[HANDLE_START]there is a SCO stream exist ,do nothing"); + goto exit; + } + + if (!bt_media_thirdparty_voice_start_process( + BT_STREAM_THIRDPARTY_VOICE, device_id, (AUD_ID_ENUM)media_id, + (uint32_t)NULL, (uint32_t)NULL)) + goto exit; + break; #endif - case BT_STREAM_SBC: - { - uint8_t media_pre_sbc = bt_meida.media_curr_sbc; - ////because voice is the highest priority and media report will stop soon - //// so just store the sbc type - if (bt_meida.media_curr_sbc == BT_DEVICE_NUM) - bt_meida.media_curr_sbc = device_id; - TRACE_AUD_MGR_I("[HANDLE_START] pre/cur_sbc = %d/%d", media_pre_sbc, bt_meida.media_curr_sbc); + case BT_STREAM_SBC: { + uint8_t media_pre_sbc = bt_meida.media_curr_sbc; + ////because voice is the highest priority and media report will stop soon + //// so just store the sbc type + if (bt_meida.media_curr_sbc == BT_DEVICE_NUM) + bt_meida.media_curr_sbc = device_id; + TRACE_AUD_MGR_I("[HANDLE_START] pre/cur_sbc = %d/%d", media_pre_sbc, + bt_meida.media_curr_sbc); #ifdef MEDIA_PLAYER_SUPPORT #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - /// clear the pending stop flag if it is set - audio_prompt_clear_pending_stream(PENDING_TO_STOP_A2DP_STREAMING); + /// clear the pending stop flag if it is set + audio_prompt_clear_pending_stream(PENDING_TO_STOP_A2DP_STREAMING); #endif - if (bt_media_is_media_active_by_type(BT_STREAM_MEDIA)) - { - goto exit; - } + if (bt_media_is_media_active_by_type(BT_STREAM_MEDIA)) { + goto exit; + } #endif #ifdef RB_CODEC - if (bt_media_is_media_active_by_type(BT_STREAM_RBCODEC)) - { - goto exit; - } + if (bt_media_is_media_active_by_type(BT_STREAM_RBCODEC)) { + goto exit; + } #endif #ifdef VOICE_DATAPATH #if !ISOLATED_AUDIO_STREAM_ENABLED - if (bt_media_is_media_active_by_type(BT_STREAM_CAPTURE)) - { - goto exit; - } + if (bt_media_is_media_active_by_type(BT_STREAM_CAPTURE)) { + goto exit; + } #endif #endif #ifdef __AI_VOICE__ - if (bt_media_is_media_active_by_type(BT_STREAM_AI_VOICE) || ai_if_is_ai_stream_mic_open()) - { - TRACE_AUD_MGR_I("[HANDLE_START] ai voice stream exist"); - goto exit; - } + if (bt_media_is_media_active_by_type(BT_STREAM_AI_VOICE) || + ai_if_is_ai_stream_mic_open()) { + TRACE_AUD_MGR_I("[HANDLE_START] ai voice stream exist"); + goto exit; + } #endif #ifdef AUDIO_LINEIN - if(bt_media_is_media_active_by_type(BT_STREAM_LINEIN)) - { - if(bt_media_get_current_media() & BT_STREAM_LINEIN) - { - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, (uint8_t)BT_STREAM_LINEIN, 0,0); - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, BT_STREAM_SBC, device_id, 0); - return; - } - } + if (bt_media_is_media_active_by_type(BT_STREAM_LINEIN)) { + if (bt_media_get_current_media() & BT_STREAM_LINEIN) { + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, + (uint8_t)BT_STREAM_LINEIN, 0, 0); + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, + BT_STREAM_SBC, device_id, 0); + return; + } + } #endif - if(bt_media_is_media_active_by_type(BT_STREAM_VOICE)) - { - ////sbc and voice is all on so set sys freq to 104m - app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_104M); - return; - } + if (bt_media_is_media_active_by_type(BT_STREAM_VOICE)) { + ////sbc and voice is all on so set sys freq to 104m + app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_104M); + return; + } #ifdef __BT_ONE_BRING_TWO__ - else if (btapp_hfp_is_call_active()) - { - //do nothing - TRACE_AUD_MGR_I("[HANDLE_START] skip sbc start, because HF_CALL_ACTIVE"); - } - else if(bt_media_is_media_active_by_device(BT_STREAM_SBC,other_device_id)) - { + else if (btapp_hfp_is_call_active()) { + // do nothing + TRACE_AUD_MGR_I("[HANDLE_START] skip sbc start, because HF_CALL_ACTIVE"); + } else if (bt_media_is_media_active_by_device(BT_STREAM_SBC, + other_device_id)) { #if !defined(__MULTIPOINT_A2DP_PREEMPT__) - //if another device is the active stream do nothing - if(bt_meida.media_curr_sbc == other_device_id) - { + // if another device is the active stream do nothing + if (bt_meida.media_curr_sbc == other_device_id) { - ///2 device is play sbc,so set sys freq to 104m - app_audio_manager_switch_a2dp((enum BT_DEVICE_ID_T)bt_meida.media_curr_sbc); - app_audio_sendrequest_param((uint8_t)APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_RESTART, 0, APP_SYSFREQ_104M); - return; - } + /// 2 device is play sbc,so set sys freq to 104m + app_audio_manager_switch_a2dp( + (enum BT_DEVICE_ID_T)bt_meida.media_curr_sbc); + app_audio_sendrequest_param((uint8_t)APP_BT_STREAM_A2DP_SBC, + (uint8_t)APP_BT_SETTING_RESTART, 0, + APP_SYSFREQ_104M); + return; + } #else - if (bt_meida.media_curr_sbc == other_device_id) - { - app_audio_manager_switch_a2dp(device_id); - app_audio_sendrequest( APP_BT_STREAM_A2DP_SBC, - (uint8_t)(APP_BT_SETTING_SETUP), - (uint32_t)(app_bt_device.sample_rate[device_id] & A2D_STREAM_SAMP_FREQ_MSK)); - app_audio_sendrequest_param(APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_RESTART, 0, APP_SYSFREQ_104M); - return; - } + if (bt_meida.media_curr_sbc == other_device_id) { + app_audio_manager_switch_a2dp(device_id); + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)(APP_BT_SETTING_SETUP), + (uint32_t)(app_bt_device.sample_rate[device_id] & + A2D_STREAM_SAMP_FREQ_MSK)); + app_audio_sendrequest_param(APP_BT_STREAM_A2DP_SBC, + (uint8_t)APP_BT_SETTING_RESTART, 0, + APP_SYSFREQ_104M); + return; + } #endif - ////if curr active media is not sbc,wrong~~ - if(0 == (bt_media_get_current_media() & BT_STREAM_SBC)) - { - ASSERT(0,"curr_active_media is wrong!"); - } - ///stop the old audio sbc and start the new audio sbc - app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_CLOSE, 0); - } + ////if curr active media is not sbc,wrong~~ + if (0 == (bt_media_get_current_media() & BT_STREAM_SBC)) { + ASSERT(0, "curr_active_media is wrong!"); + } + /// stop the old audio sbc and start the new audio sbc + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + } #endif - else - { - //start audio sbc stream - if (media_pre_sbc != bt_meida.media_curr_sbc) - { - app_audio_manager_switch_a2dp(device_id); - bt_media_set_current_media(BT_STREAM_SBC); - app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, - (uint8_t)(APP_BT_SETTING_SETUP), - (uint32_t)(app_bt_device.sample_rate[device_id] & A2D_STREAM_SAMP_FREQ_MSK)); - app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, ( uint8_t )APP_BT_SETTING_OPEN, 0); - } - } - } - break; + else { + // start audio sbc stream + if (media_pre_sbc != bt_meida.media_curr_sbc) { + app_audio_manager_switch_a2dp(device_id); + bt_media_set_current_media(BT_STREAM_SBC); + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)(APP_BT_SETTING_SETUP), + (uint32_t)(app_bt_device.sample_rate[device_id] & + A2D_STREAM_SAMP_FREQ_MSK)); + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)APP_BT_SETTING_OPEN, 0); + } + } + } break; #ifdef MEDIA_PLAYER_SUPPORT - case BT_STREAM_MEDIA: - #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - isMergingPrompt = IS_PROMPT_NEED_MERGING(media_id); - #endif - - if( + case BT_STREAM_MEDIA: #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - audio_prompt_is_playing_ongoing() || + isMergingPrompt = IS_PROMPT_NEED_MERGING(media_id); #endif - app_audio_list_playback_exist()) - { - if (!bt_media_cur_is_bt_stream_media()) - { - bt_media_clear_media_type(BT_STREAM_MEDIA,device_id); - } - media_id = PROMPT_ID_FROM_ID_VALUE(media_id); - APP_AUDIO_STATUS aud_status; - aud_status.id = APP_PLAY_BACK_AUDIO; - aud_status.aud_id = media_id; - app_audio_list_append(&aud_status); - break; - } + if ( +#ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED + audio_prompt_is_playing_ongoing() || +#endif + app_audio_list_playback_exist()) { + if (!bt_media_cur_is_bt_stream_media()) { + bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); + } + media_id = PROMPT_ID_FROM_ID_VALUE(media_id); + APP_AUDIO_STATUS aud_status; + aud_status.id = APP_PLAY_BACK_AUDIO; + aud_status.aud_id = media_id; + + app_audio_list_append(&aud_status); + break; + } #ifdef AUDIO_LINEIN - if(bt_media_is_media_active_by_type(BT_STREAM_LINEIN)) - { - if(bt_media_get_current_media() & BT_STREAM_LINEIN) - { - APP_AUDIO_STATUS aud_status; - aud_status.id = media_id; - app_play_audio_lineinmode_start(&aud_status); - bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); - } - }else + if (bt_media_is_media_active_by_type(BT_STREAM_LINEIN)) { + if (bt_media_get_current_media() & BT_STREAM_LINEIN) { + APP_AUDIO_STATUS aud_status; + aud_status.id = media_id; + app_play_audio_lineinmode_start(&aud_status); + bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); + } + } else #endif - //first,if the voice is active so mix "dudu" to the stream - if(bt_media_is_media_active_by_type(BT_STREAM_VOICE)) - { - if(bt_media_get_current_media() & BT_STREAM_VOICE) - { + // first,if the voice is active so mix "dudu" to the stream + if (bt_media_is_media_active_by_type(BT_STREAM_VOICE)) { + if (bt_media_get_current_media() & BT_STREAM_VOICE) { #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - // if the playback is not triggered yet, we just use the stand-alone prompt playing - if (!bt_is_playback_triggered()) - { - isMergingPrompt = false; - } + // if the playback is not triggered yet, we just use the stand-alone + // prompt playing + if (!bt_is_playback_triggered()) { + isMergingPrompt = false; + } #endif - //if call is not active so do media report - if((btapp_hfp_is_call_active() && !btapp_hfp_incoming_calls()) || - (app_bt_stream_isrun(APP_BT_STREAM_HFP_PCM))) - { + // if call is not active so do media report + if ((btapp_hfp_is_call_active() && !btapp_hfp_incoming_calls()) || + (app_bt_stream_isrun(APP_BT_STREAM_HFP_PCM))) { #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); - if (isMergingPrompt) - { - audio_prompt_start_playing(media_id, sco_sample_rate); - goto exit; - } - else - { - app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, (uint8_t)APP_BT_SETTING_CLOSE, 0); - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, media_id); - bt_media_set_current_media(BT_STREAM_MEDIA); - } + bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); + if (isMergingPrompt) { + audio_prompt_start_playing(media_id, sco_sample_rate); + goto exit; + } else { + app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, + (uint8_t)APP_BT_SETTING_OPEN, media_id); + bt_media_set_current_media(BT_STREAM_MEDIA); + } #else - //in three way call merge "dudu" - TRACE_AUD_MGR_I("[HANDLE_START] BT_STREAM_VOICE-->app_ring_merge_start\n"); - app_ring_merge_start(); - //meida is done here - bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); + // in three way call merge "dudu" + TRACE_AUD_MGR_I( + "[HANDLE_START] BT_STREAM_VOICE-->app_ring_merge_start\n"); + app_ring_merge_start(); + // meida is done here + bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); #endif - } - else - { + } else { #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); - if (isMergingPrompt) - { - audio_prompt_start_playing(media_id, sco_sample_rate); - goto exit; - } - else - { - app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, (uint8_t)APP_BT_SETTING_CLOSE, 0); - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, media_id); - bt_media_set_current_media(BT_STREAM_MEDIA); - } + bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); + if (isMergingPrompt) { + audio_prompt_start_playing(media_id, sco_sample_rate); + goto exit; + } else { + app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, + (uint8_t)APP_BT_SETTING_OPEN, media_id); + bt_media_set_current_media(BT_STREAM_MEDIA); + } #else - TRACE_AUD_MGR_I("[HANDLE_START] stop sco and do media report\n"); - bt_media_set_current_media(BT_STREAM_MEDIA); - app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, (uint8_t)APP_BT_SETTING_CLOSE, 0); - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, media_id); + TRACE_AUD_MGR_I("[HANDLE_START] stop sco and do media report\n"); + bt_media_set_current_media(BT_STREAM_MEDIA); + app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, + (uint8_t)APP_BT_SETTING_OPEN, media_id); #endif - } - } - else if(bt_media_get_current_media() & BT_STREAM_MEDIA) - { - bt_media_set_current_media(BT_STREAM_MEDIA); - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, media_id); - } - else - { - ///if voice is active but current is not voice something is unkown - bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); + } + } else if (bt_media_get_current_media() & BT_STREAM_MEDIA) { + bt_media_set_current_media(BT_STREAM_MEDIA); + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, + media_id); + } else { + /// if voice is active but current is not voice something is unkown + bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); #ifdef __BT_ONE_BRING_TWO__ - TRACE_AUD_MGR_I("[HANDLE_START] voice_act media_act = %x,%x,curr_media = %x", - bt_meida.media_active[0],bt_meida.media_active[1], bt_meida.curr_active_media); + TRACE_AUD_MGR_I( + "[HANDLE_START] voice_act media_act = %x,%x,curr_media = %x", + bt_meida.media_active[0], bt_meida.media_active[1], + bt_meida.curr_active_media); #else - TRACE_AUD_MGR_I("[HANDLE_START] voice_act media_act = %x,curr_media = %x", - bt_meida.media_active[0], bt_meida.curr_active_media); + TRACE_AUD_MGR_I( + "[HANDLE_START] voice_act media_act = %x,curr_media = %x", + bt_meida.media_active[0], bt_meida.curr_active_media); #endif - } - } - else if (btapp_hfp_is_call_active()) - { - bt_media_set_current_media(BT_STREAM_MEDIA); - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, media_id); - } + } + } else if (btapp_hfp_is_call_active()) { + bt_media_set_current_media(BT_STREAM_MEDIA); + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, + media_id); + } #ifdef VOICE_DATAPATH #if !ISOLATED_AUDIO_STREAM_ENABLED - else if( bt_media_is_media_active_by_type(BT_STREAM_CAPTURE) ) - { - if(bt_media_get_current_media() & BT_STREAM_MEDIA) - { - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, media_id); - } - else - { - goto exit; - } - } + else if (bt_media_is_media_active_by_type(BT_STREAM_CAPTURE)) { + if (bt_media_get_current_media() & BT_STREAM_MEDIA) { + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, + media_id); + } else { + goto exit; + } + } #endif #endif - ////if sbc active so - else if(bt_media_is_media_active_by_type(BT_STREAM_SBC)) - { - if(bt_media_get_current_media() & BT_STREAM_SBC) - { + ////if sbc active so + else if (bt_media_is_media_active_by_type(BT_STREAM_SBC)) { + if (bt_media_get_current_media() & BT_STREAM_SBC) { #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - // if the playback is not triggered yet, we just use the stand-alone prompt playing - if (!bt_is_playback_triggered()) - { - isMergingPrompt = false; - } + // if the playback is not triggered yet, we just use the stand-alone + // prompt playing + if (!bt_is_playback_triggered()) { + isMergingPrompt = false; + } - bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); - if (isMergingPrompt) - { - audio_prompt_start_playing(media_id,a2dp_sample_rate); - goto exit; - } - else - { - TRACE_AUD_MGR_I("[HANDLE_START] START prompt."); - app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_CLOSE, 0); - bt_media_set_current_media(BT_STREAM_MEDIA); - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, media_id); - } + bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); + if (isMergingPrompt) { + audio_prompt_start_playing(media_id, a2dp_sample_rate); + goto exit; + } else { + TRACE_AUD_MGR_I("[HANDLE_START] START prompt."); + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + bt_media_set_current_media(BT_STREAM_MEDIA); + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, + (uint8_t)APP_BT_SETTING_OPEN, media_id); + } #else #ifdef __BT_WARNING_TONE_MERGE_INTO_STREAM_SBC__ - if (PROMPT_ID_FROM_ID_VALUE(media_id) == AUD_ID_BT_WARNING) - { - TRACE_AUD_MGR_I("[HANDLE_START] BT_STREAM_SBC-->app_ring_merge_start\n"); - app_ring_merge_start(); - //meida is done here - bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); - } - else + if (PROMPT_ID_FROM_ID_VALUE(media_id) == AUD_ID_BT_WARNING) { + TRACE_AUD_MGR_I( + "[HANDLE_START] BT_STREAM_SBC-->app_ring_merge_start\n"); + app_ring_merge_start(); + // meida is done here + bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); + } else #endif - { - app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_CLOSE, 0); - bt_media_set_current_media(BT_STREAM_MEDIA); - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, media_id); - } + { + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + bt_media_set_current_media(BT_STREAM_MEDIA); + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, + (uint8_t)APP_BT_SETTING_OPEN, media_id); + } #endif // #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - } - else if(bt_media_get_current_media() & BT_STREAM_MEDIA) - { - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, media_id); - } - else if ((bt_media_get_current_media()&0xFF) == 0) - { - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, media_id); - } - else - { - ASSERT(0,"media in sbc current wrong"); - } - } - /// just play the media - else - { - bt_media_set_current_media(BT_STREAM_MEDIA); - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, media_id); - } - break; + } else if (bt_media_get_current_media() & BT_STREAM_MEDIA) { + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, + media_id); + } else if ((bt_media_get_current_media() & 0xFF) == 0) { + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, + media_id); + } else { + ASSERT(0, "media in sbc current wrong"); + } + } + /// just play the media + else { + bt_media_set_current_media(BT_STREAM_MEDIA); + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, + media_id); + } + break; #endif - case BT_STREAM_VOICE: + case BT_STREAM_VOICE: #ifdef HFP_NO_PRERMPT - if(app_audio_manager_get_active_sco_num() != BT_DEVICE_NUM) - return; + if (app_audio_manager_get_active_sco_num() != BT_DEVICE_NUM) + return; #endif - app_audio_manager_set_active_sco_num(device_id); + app_audio_manager_set_active_sco_num(device_id); #ifdef VOICE_DATAPATH - if(bt_media_is_media_active_by_type(BT_STREAM_CAPTURE)) - { - if(bt_media_get_current_media() & BT_STREAM_CAPTURE) - { - app_audio_sendrequest(APP_BT_STREAM_VOICEPATH, (uint8_t)APP_BT_SETTING_CLOSE, 0); - bt_media_clear_current_media(BT_STREAM_CAPTURE); - } - } + if (bt_media_is_media_active_by_type(BT_STREAM_CAPTURE)) { + if (bt_media_get_current_media() & BT_STREAM_CAPTURE) { + app_audio_sendrequest(APP_BT_STREAM_VOICEPATH, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + bt_media_clear_current_media(BT_STREAM_CAPTURE); + } + } #endif #ifdef __AI_VOICE__ - if(bt_media_is_media_active_by_type(BT_STREAM_AI_VOICE)) - { - if(bt_media_get_current_media() & BT_STREAM_AI_VOICE) - { - app_audio_sendrequest(APP_BT_STREAM_AI_VOICE, (uint8_t)APP_BT_SETTING_CLOSE, 0); - bt_media_clear_current_media(BT_STREAM_AI_VOICE); - } - } + if (bt_media_is_media_active_by_type(BT_STREAM_AI_VOICE)) { + if (bt_media_get_current_media() & BT_STREAM_AI_VOICE) { + app_audio_sendrequest(APP_BT_STREAM_AI_VOICE, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + bt_media_clear_current_media(BT_STREAM_AI_VOICE); + } + } #endif #ifdef __THIRDPARTY - if(bt_media_is_media_active_by_type(BT_STREAM_THIRDPARTY_VOICE)) { - if(bt_media_get_current_media() & BT_STREAM_THIRDPARTY_VOICE) { - app_audio_sendrequest(APP_BT_STREAM_THIRDPARTY_VOICE, (uint8_t)APP_BT_SETTING_CLOSE, 0); - bt_media_clear_current_media(BT_STREAM_THIRDPARTY_VOICE); - } - } + if (bt_media_is_media_active_by_type(BT_STREAM_THIRDPARTY_VOICE)) { + if (bt_media_get_current_media() & BT_STREAM_THIRDPARTY_VOICE) { + app_audio_sendrequest(APP_BT_STREAM_THIRDPARTY_VOICE, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + bt_media_clear_current_media(BT_STREAM_THIRDPARTY_VOICE); + } + } #endif #ifdef MEDIA_PLAYER_SUPPORT #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - /// clear the pending stop flag if it is set - audio_prompt_clear_pending_stream(PENDING_TO_STOP_A2DP_STREAMING); + /// clear the pending stop flag if it is set + audio_prompt_clear_pending_stream(PENDING_TO_STOP_A2DP_STREAMING); #endif - if(bt_media_is_media_active_by_type(BT_STREAM_MEDIA)) - { - //if call is active ,so disable media report - if(bt_media_is_media_active_by_type(BT_STREAM_VOICE)) - { - if(bt_media_get_current_media() & BT_STREAM_MEDIA) - { - if (app_play_audio_get_aud_id() == AUD_ID_BT_CALL_INCOMING_NUMBER) - { - //if meida is open ,close media clear all media type - TRACE_AUD_MGR_I("[HANDLE_START] call active so start sco and stop media report\n"); + if (bt_media_is_media_active_by_type(BT_STREAM_MEDIA)) { + // if call is active ,so disable media report + if (bt_media_is_media_active_by_type(BT_STREAM_VOICE)) { + if (bt_media_get_current_media() & BT_STREAM_MEDIA) { + if (app_play_audio_get_aud_id() == AUD_ID_BT_CALL_INCOMING_NUMBER) { + // if meida is open ,close media clear all media type + TRACE_AUD_MGR_I("[HANDLE_START] call active so start sco and stop " + "media report\n"); #ifdef __AUDIO_QUEUE_SUPPORT__ - app_audio_list_clear(); + app_audio_list_clear(); #endif - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_CLOSE, 0); - bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); - bt_media_set_current_media(BT_STREAM_VOICE); - app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, (uint8_t)APP_BT_SETTING_OPEN, 0); - } - } - } - else - { - ////call is not active so media report continue - } - } - else + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); + bt_media_set_current_media(BT_STREAM_VOICE); + app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, + (uint8_t)APP_BT_SETTING_OPEN, 0); + } + } + } else { + ////call is not active so media report continue + } + } else #endif - if(bt_media_is_media_active_by_type(BT_STREAM_SBC)) - { - ///if sbc is open stop sbc - if(bt_media_get_current_media() & BT_STREAM_SBC) - { - app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_CLOSE, 0); - } - ////start voice stream - bt_media_set_current_media(BT_STREAM_VOICE); - app_audio_sendrequest_param(APP_BT_STREAM_HFP_PCM, (uint8_t)APP_BT_SETTING_OPEN, 0, APP_SYSFREQ_104M); - } - else - { - //voice is open already so do nothing - if(bt_media_get_current_media() & BT_STREAM_VOICE) - { + if (bt_media_is_media_active_by_type(BT_STREAM_SBC)) { + /// if sbc is open stop sbc + if (bt_media_get_current_media() & BT_STREAM_SBC) { + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + } + ////start voice stream + bt_media_set_current_media(BT_STREAM_VOICE); + app_audio_sendrequest_param(APP_BT_STREAM_HFP_PCM, + (uint8_t)APP_BT_SETTING_OPEN, 0, + APP_SYSFREQ_104M); + } else { + // voice is open already so do nothing + if (bt_media_get_current_media() & BT_STREAM_VOICE) { #if defined(__BT_ONE_BRING_TWO__) - if(bt_get_sco_number()>1 + if (bt_get_sco_number() > 1 #ifdef CHIP_BEST1000 - && hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_2 + && hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_2 #endif - ) - { - app_audio_manager_swap_sco(device_id); + ) { + app_audio_manager_swap_sco(device_id); #if defined(__HF_KEEP_ONE_ALIVE__) - if (btif_hf_check_AudioConnect_status(app_bt_device.hf_channel[other_device_id])) - { - TRACE_AUD_MGR_I("[MEDIA_START] Disconnect another AudioLink"); - btif_hf_disc_audio_link(app_bt_device.hf_channel[other_device_id]); - } + if (btif_hf_check_AudioConnect_status( + app_bt_device.hf_channel[other_device_id])) { + TRACE_AUD_MGR_I("[MEDIA_START] Disconnect another AudioLink"); + btif_hf_disc_audio_link(app_bt_device.hf_channel[other_device_id]); + } #endif - } + } #endif - } - else - { - bt_media_set_current_media(BT_STREAM_VOICE); - app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, (uint8_t)APP_BT_SETTING_OPEN, 0); - } - } - - break; -#ifdef AUDIO_LINEIN - case BT_STREAM_LINEIN: - if(!bt_media_is_media_active_by_type(BT_STREAM_SBC | BT_STREAM_MEDIA | BT_STREAM_VOICE)) - { - app_audio_sendrequest(APP_PLAY_LINEIN_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, 0); - bt_media_set_current_media(BT_STREAM_LINEIN); - } - break; -#endif - - default: - ASSERT(0,"bt_media_open ERROR TYPE"); - break; - + } else { + bt_media_set_current_media(BT_STREAM_VOICE); + app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, + (uint8_t)APP_BT_SETTING_OPEN, 0); + } } -#if defined(RB_CODEC) || defined(VOICE_DATAPATH) || defined(MEDIA_PLAYER_SUPPORT) || defined(__AI_VOICE__) + break; +#ifdef AUDIO_LINEIN + case BT_STREAM_LINEIN: + if (!bt_media_is_media_active_by_type(BT_STREAM_SBC | BT_STREAM_MEDIA | + BT_STREAM_VOICE)) { + app_audio_sendrequest(APP_PLAY_LINEIN_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, + 0); + bt_media_set_current_media(BT_STREAM_LINEIN); + } + break; +#endif + + default: + ASSERT(0, "bt_media_open ERROR TYPE"); + break; + } + +#if defined(RB_CODEC) || defined(VOICE_DATAPATH) || \ + defined(MEDIA_PLAYER_SUPPORT) || defined(__AI_VOICE__) exit: - return; + return; #endif } #ifdef RB_CODEC -static bool bt_media_rbcodec_stop_process(uint16_t stream_type,enum BT_DEVICE_ID_T device_id, uint32_t ptr) -{ - int ret_SendReq2AudioThread = -1; - bt_media_clear_media_type(stream_type,device_id); - //if current stream is the stop one ,so stop it - if(bt_media_get_current_media() & BT_STREAM_RBCODEC ) - { - ret_SendReq2AudioThread = app_audio_sendrequest(APP_BT_STREAM_RBCODEC, (uint8_t)APP_BT_SETTING_CLOSE, ptr); - bt_media_clear_current_media(BT_STREAM_RBCODEC); - TRACE_AUD_MGR_I("[RBCODEC][STOPED]"); - } +static bool bt_media_rbcodec_stop_process(uint16_t stream_type, + enum BT_DEVICE_ID_T device_id, + uint32_t ptr) { + int ret_SendReq2AudioThread = -1; + bt_media_clear_media_type(stream_type, device_id); + // if current stream is the stop one ,so stop it + if (bt_media_get_current_media() & BT_STREAM_RBCODEC) { + ret_SendReq2AudioThread = app_audio_sendrequest( + APP_BT_STREAM_RBCODEC, (uint8_t)APP_BT_SETTING_CLOSE, ptr); + bt_media_clear_current_media(BT_STREAM_RBCODEC); + TRACE_AUD_MGR_I("[RBCODEC][STOPED]"); + } - if(bt_media_is_media_active_by_type(BT_STREAM_SBC)) - { - enum BT_DEVICE_ID_T sbc_id = bt_media_get_active_device_by_type(BT_STREAM_SBC); - TRACE_AUD_MGR_I("[RBCODEC][STOPED] sbc_id %d",sbc_id); - if(sbc_id < BT_DEVICE_NUM) - { - bt_meida.media_curr_sbc = sbc_id; - } - } - else - { - bt_meida.media_curr_sbc = BT_DEVICE_NUM; + if (bt_media_is_media_active_by_type(BT_STREAM_SBC)) { + enum BT_DEVICE_ID_T sbc_id = + bt_media_get_active_device_by_type(BT_STREAM_SBC); + TRACE_AUD_MGR_I("[RBCODEC][STOPED] sbc_id %d", sbc_id); + if (sbc_id < BT_DEVICE_NUM) { + bt_meida.media_curr_sbc = sbc_id; } + } else { + bt_meida.media_curr_sbc = BT_DEVICE_NUM; + } - TRACE_AUD_MGR_I("[RBCODEC][STOPED] bt_meida.media_curr_sbc %d",bt_meida.media_curr_sbc); + TRACE_AUD_MGR_I("[RBCODEC][STOPED] bt_meida.media_curr_sbc %d", + bt_meida.media_curr_sbc); - if(bt_media_is_media_active_by_type(BT_STREAM_VOICE)) - { - } - else if(bt_media_is_media_active_by_type(BT_STREAM_SBC)) - { - enum BT_DEVICE_ID_T sbc_id = bt_media_get_active_device_by_type(BT_STREAM_SBC); - if(sbc_id < BT_DEVICE_NUM) - { + if (bt_media_is_media_active_by_type(BT_STREAM_VOICE)) { + } else if (bt_media_is_media_active_by_type(BT_STREAM_SBC)) { + enum BT_DEVICE_ID_T sbc_id = + bt_media_get_active_device_by_type(BT_STREAM_SBC); + if (sbc_id < BT_DEVICE_NUM) { #ifdef __TWS__ - bt_media_clear_media_type(BT_STREAM_SBC,sbc_id); - bt_media_clear_current_media(BT_STREAM_SBC); - notify_tws_player_status(APP_BT_SETTING_OPEN); + bt_media_clear_media_type(BT_STREAM_SBC, sbc_id); + bt_media_clear_current_media(BT_STREAM_SBC); + notify_tws_player_status(APP_BT_SETTING_OPEN); #else - bt_parse_store_sbc_sample_rate(app_bt_device.sample_rate[sbc_id]); - ret_SendReq2AudioThread = app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_OPEN, 0); - bt_media_set_current_media(BT_STREAM_SBC); + bt_parse_store_sbc_sample_rate(app_bt_device.sample_rate[sbc_id]); + ret_SendReq2AudioThread = app_audio_sendrequest( + APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_OPEN, 0); + bt_media_set_current_media(BT_STREAM_SBC); #endif - } - } - else if(bt_media_is_media_active_by_type(BT_STREAM_MEDIA)) - { - //do nothing } + } else if (bt_media_is_media_active_by_type(BT_STREAM_MEDIA)) { + // do nothing + } } #endif #ifdef VOICE_DATAPATH -bool bt_media_voicepath_stop_process(uint16_t stream_type,enum BT_DEVICE_ID_T device_id) -{ - int ret_SendReq2AudioThread __attribute__((unused)); - ret_SendReq2AudioThread= -1; - bt_media_clear_media_type(stream_type,device_id); - //if current stream is the stop one ,so stop it - if(bt_media_get_current_media() & BT_STREAM_CAPTURE) - { - ret_SendReq2AudioThread = app_audio_sendrequest(APP_BT_STREAM_VOICEPATH, (uint8_t)APP_BT_SETTING_CLOSE, 0); - bt_media_clear_current_media(BT_STREAM_CAPTURE); - TRACE_AUD_MGR_I("[VOICEPATH][STOPED] Voice Path STOPED! "); - } +bool bt_media_voicepath_stop_process(uint16_t stream_type, + enum BT_DEVICE_ID_T device_id) { + int ret_SendReq2AudioThread __attribute__((unused)); + ret_SendReq2AudioThread = -1; + bt_media_clear_media_type(stream_type, device_id); + // if current stream is the stop one ,so stop it + if (bt_media_get_current_media() & BT_STREAM_CAPTURE) { + ret_SendReq2AudioThread = app_audio_sendrequest( + APP_BT_STREAM_VOICEPATH, (uint8_t)APP_BT_SETTING_CLOSE, 0); + bt_media_clear_current_media(BT_STREAM_CAPTURE); + TRACE_AUD_MGR_I("[VOICEPATH][STOPED] Voice Path STOPED! "); + } - if(bt_media_is_media_active_by_type(BT_STREAM_SBC)) - { - enum BT_DEVICE_ID_T sbc_id = bt_media_get_active_device_by_type(BT_STREAM_SBC); - TRACE_AUD_MGR_I("[VOICEPATH][STOPED] sbc_id %d",sbc_id); - if(sbc_id < BT_DEVICE_NUM) - { - bt_meida.media_curr_sbc = sbc_id; - } - } - else - { - bt_meida.media_curr_sbc = BT_DEVICE_NUM; + if (bt_media_is_media_active_by_type(BT_STREAM_SBC)) { + enum BT_DEVICE_ID_T sbc_id = + bt_media_get_active_device_by_type(BT_STREAM_SBC); + TRACE_AUD_MGR_I("[VOICEPATH][STOPED] sbc_id %d", sbc_id); + if (sbc_id < BT_DEVICE_NUM) { + bt_meida.media_curr_sbc = sbc_id; } + } else { + bt_meida.media_curr_sbc = BT_DEVICE_NUM; + } - TRACE_AUD_MGR_I("[VOICEPATH][STOPED] bt_meida.media_curr_sbc %d",bt_meida.media_curr_sbc); + TRACE_AUD_MGR_I("[VOICEPATH][STOPED] bt_meida.media_curr_sbc %d", + bt_meida.media_curr_sbc); - if(bt_media_is_media_active_by_type(BT_STREAM_VOICE)) - { - } + if (bt_media_is_media_active_by_type(BT_STREAM_VOICE)) { + } #if !ISOLATED_AUDIO_STREAM_ENABLED - else if(bt_media_is_media_active_by_type(BT_STREAM_MEDIA)) - { - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, 0); - bt_media_set_current_media(BT_STREAM_MEDIA); - } - else if(bt_media_is_media_active_by_type(BT_STREAM_SBC)) - { - enum BT_DEVICE_ID_T sbc_id = bt_media_get_active_device_by_type(BT_STREAM_SBC); - if(sbc_id < BT_DEVICE_NUM) - { + else if (bt_media_is_media_active_by_type(BT_STREAM_MEDIA)) { + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_OPEN, 0); + bt_media_set_current_media(BT_STREAM_MEDIA); + } else if (bt_media_is_media_active_by_type(BT_STREAM_SBC)) { + enum BT_DEVICE_ID_T sbc_id = + bt_media_get_active_device_by_type(BT_STREAM_SBC); + if (sbc_id < BT_DEVICE_NUM) { #ifdef __TWS__ - bt_media_clear_media_type(BT_STREAM_SBC,sbc_id); - bt_media_clear_current_media(BT_STREAM_SBC); - notify_tws_player_status(APP_BT_SETTING_OPEN); + bt_media_clear_media_type(BT_STREAM_SBC, sbc_id); + bt_media_clear_current_media(BT_STREAM_SBC); + notify_tws_player_status(APP_BT_SETTING_OPEN); #else - //bt_parse_store_sbc_sample_rate(app_bt_device.sample_rate[sbc_id]); - ret_SendReq2AudioThread = app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_OPEN, 0); - bt_media_set_current_media(BT_STREAM_SBC); + // bt_parse_store_sbc_sample_rate(app_bt_device.sample_rate[sbc_id]); + ret_SendReq2AudioThread = app_audio_sendrequest( + APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_OPEN, 0); + bt_media_set_current_media(BT_STREAM_SBC); #endif - } } + } #endif - return true; + return true; } #endif #ifdef __AI_VOICE__ -bool bt_media_ai_voice_stop_process(uint16_t stream_type, enum BT_DEVICE_ID_T device_id) -{ - bt_media_clear_media_type(BT_STREAM_AI_VOICE, device_id); - //if current stream is the stop one ,stop it - if(bt_media_get_current_media() & BT_STREAM_AI_VOICE) - { - app_audio_sendrequest(APP_BT_STREAM_AI_VOICE, (uint8_t)APP_BT_SETTING_CLOSE, 0); - bt_media_clear_current_media(BT_STREAM_AI_VOICE); - TRACE_AUD_MGR_I("[AI_VOICE][STOPED]"); +bool bt_media_ai_voice_stop_process(uint16_t stream_type, + enum BT_DEVICE_ID_T device_id) { + bt_media_clear_media_type(BT_STREAM_AI_VOICE, device_id); + // if current stream is the stop one ,stop it + if (bt_media_get_current_media() & BT_STREAM_AI_VOICE) { + app_audio_sendrequest(APP_BT_STREAM_AI_VOICE, (uint8_t)APP_BT_SETTING_CLOSE, + 0); + bt_media_clear_current_media(BT_STREAM_AI_VOICE); + TRACE_AUD_MGR_I("[AI_VOICE][STOPED]"); #ifdef IBRT - if(!bt_media_is_media_active_by_type(BT_STREAM_VOICE)) - { - app_ibrt_if_force_audio_retrigger(); - } -#endif + if (!bt_media_is_media_active_by_type(BT_STREAM_VOICE)) { + app_ibrt_if_force_audio_retrigger(); } +#endif + } #ifndef IBRT - enum BT_DEVICE_ID_T sbc_id = BT_DEVICE_NUM; - sbc_id = bt_media_get_active_device_by_type(BT_STREAM_SBC); - TRACE_AUD_MGR_I("[AI_VOICE][STOPED] sbc_id %d",sbc_id); - bt_meida.media_curr_sbc = sbc_id; + enum BT_DEVICE_ID_T sbc_id = BT_DEVICE_NUM; + sbc_id = bt_media_get_active_device_by_type(BT_STREAM_SBC); + TRACE_AUD_MGR_I("[AI_VOICE][STOPED] sbc_id %d", sbc_id); + bt_meida.media_curr_sbc = sbc_id; - TRACE_AUD_MGR_I("[AI_VOICE][STOPED] bt_meida.media_curr_sbc %d",bt_meida.media_curr_sbc); + TRACE_AUD_MGR_I("[AI_VOICE][STOPED] bt_meida.media_curr_sbc %d", + bt_meida.media_curr_sbc); - if(bt_media_is_media_active_by_type(BT_STREAM_VOICE)) - { - } - else if(sbc_id < BT_DEVICE_NUM) - { - if(!(bt_media_get_current_media() & BT_STREAM_SBC)) - { - //bt_parse_store_sbc_sample_rate(app_bt_device.sample_rate[sbc_id]); - app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, - (uint8_t)(APP_BT_SETTING_SETUP), - (uint32_t)(app_bt_device.sample_rate[sbc_id] & A2D_STREAM_SAMP_FREQ_MSK)); - app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_OPEN, 0); - bt_media_set_current_media(BT_STREAM_SBC); - } + if (bt_media_is_media_active_by_type(BT_STREAM_VOICE)) { + } else if (sbc_id < BT_DEVICE_NUM) { + if (!(bt_media_get_current_media() & BT_STREAM_SBC)) { + // bt_parse_store_sbc_sample_rate(app_bt_device.sample_rate[sbc_id]); + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)(APP_BT_SETTING_SETUP), + (uint32_t)(app_bt_device.sample_rate[sbc_id] & + A2D_STREAM_SAMP_FREQ_MSK)); + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)APP_BT_SETTING_OPEN, 0); + bt_media_set_current_media(BT_STREAM_SBC); } + } #endif - return true; + return true; } #endif #ifdef __THIRDPARTY -bool bt_media_thirdparty_voice_stop_process(uint16_t stream_type, enum BT_DEVICE_ID_T device_id) -{ - bt_media_clear_media_type(BT_STREAM_THIRDPARTY_VOICE, device_id); - //if current stream is the stop one ,stop it - if(bt_media_get_current_media() & BT_STREAM_THIRDPARTY_VOICE) - { - app_audio_sendrequest(APP_BT_STREAM_THIRDPARTY_VOICE, (uint8_t)APP_BT_SETTING_CLOSE, 0); - bt_media_clear_current_media(BT_STREAM_THIRDPARTY_VOICE); - TRACE_AUD_MGR_I("THIRDPARTY VOICE STOPED! "); - } - return true; +bool bt_media_thirdparty_voice_stop_process(uint16_t stream_type, + enum BT_DEVICE_ID_T device_id) { + bt_media_clear_media_type(BT_STREAM_THIRDPARTY_VOICE, device_id); + // if current stream is the stop one ,stop it + if (bt_media_get_current_media() & BT_STREAM_THIRDPARTY_VOICE) { + app_audio_sendrequest(APP_BT_STREAM_THIRDPARTY_VOICE, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + bt_media_clear_current_media(BT_STREAM_THIRDPARTY_VOICE); + TRACE_AUD_MGR_I("THIRDPARTY VOICE STOPED! "); + } + return true; } #endif @@ -1188,1168 +1100,1132 @@ bool bt_media_thirdparty_voice_stop_process(uint16_t stream_type, enum BT_DEVICE media is stop by media player finished call back */ -void bt_media_stop(uint16_t stream_type,enum BT_DEVICE_ID_T device_id) -{ - TRACE_AUD_MGR_I("[HANDLE_STOP] type= 0x%x->:%s, device id = 0x%x",stream_type,strmtype2str(stream_type),device_id); +void bt_media_stop(uint16_t stream_type, enum BT_DEVICE_ID_T device_id) { + TRACE_AUD_MGR_I("[HANDLE_STOP] type= 0x%x->:%s, device id = 0x%x", + stream_type, strmtype2str(stream_type), device_id); #ifdef __BT_ONE_BRING_TWO__ - TRACE_AUD_MGR_I("[HANDLE_STOP] media_active[0] = 0x%x->:%s", - bt_meida.media_active[0], strmtype2str(bt_meida.media_active[0])); - TRACE_AUD_MGR_I("[HANDLE_STOP] media_active[1] = 0x%x->:%s", - bt_meida.media_active[1], strmtype2str(bt_meida.media_active[1])); - TRACE_AUD_MGR_I("[HANDLE_STOP] curr_active_media = 0x%x->:%s", - bt_meida.curr_active_media, strmtype2str(bt_meida.curr_active_media)); + TRACE_AUD_MGR_I("[HANDLE_STOP] media_active[0] = 0x%x->:%s", + bt_meida.media_active[0], + strmtype2str(bt_meida.media_active[0])); + TRACE_AUD_MGR_I("[HANDLE_STOP] media_active[1] = 0x%x->:%s", + bt_meida.media_active[1], + strmtype2str(bt_meida.media_active[1])); + TRACE_AUD_MGR_I("[HANDLE_STOP] curr_active_media = 0x%x->:%s", + bt_meida.curr_active_media, + strmtype2str(bt_meida.curr_active_media)); #else - TRACE_AUD_MGR_I("[HANDLE_STOP] media_active = 0x%x->:%s", - bt_meida.media_active[0], strmtype2str(bt_meida.media_active[0])); - TRACE_AUD_MGR_I("[HANDLE_STOP] curr_active_media = 0x%x->:%s", - bt_meida.curr_active_media, strmtype2str(bt_meida.curr_active_media)); + TRACE_AUD_MGR_I("[HANDLE_STOP] media_active = 0x%x->:%s", + bt_meida.media_active[0], + strmtype2str(bt_meida.media_active[0])); + TRACE_AUD_MGR_I("[HANDLE_STOP] curr_active_media = 0x%x->:%s", + bt_meida.curr_active_media, + strmtype2str(bt_meida.curr_active_media)); #endif - if (!bt_media_is_media_active_by_device(stream_type, device_id)&& - !(bt_media_get_current_media()&stream_type)) - { - return; - } + if (!bt_media_is_media_active_by_device(stream_type, device_id) && + !(bt_media_get_current_media() & stream_type)) { + return; + } - switch(stream_type) - { + switch (stream_type) { #ifdef VOICE_DATAPATH - case BT_STREAM_CAPTURE: - bt_media_voicepath_stop_process(stream_type,device_id); - break; + case BT_STREAM_CAPTURE: + bt_media_voicepath_stop_process(stream_type, device_id); + break; #endif #ifdef __AI_VOICE__ - case BT_STREAM_AI_VOICE: - bt_media_ai_voice_stop_process(stream_type, device_id); - break; + case BT_STREAM_AI_VOICE: + bt_media_ai_voice_stop_process(stream_type, device_id); + break; #endif #ifdef __THIRDPARTY - case BT_STREAM_THIRDPARTY_VOICE: - bt_media_thirdparty_voice_stop_process(stream_type, device_id); - break; + case BT_STREAM_THIRDPARTY_VOICE: + bt_media_thirdparty_voice_stop_process(stream_type, device_id); + break; #endif - case BT_STREAM_SBC: - { + case BT_STREAM_SBC: { #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - if (!audio_prompt_check_on_stopping_stream( - PENDING_TO_STOP_A2DP_STREAMING, device_id)) - { - TRACE_AUD_MGR_I("[HANDLE_STOP] Pending stop BT_STREAM_SBC"); - return; - } + if (!audio_prompt_check_on_stopping_stream(PENDING_TO_STOP_A2DP_STREAMING, + device_id)) { + TRACE_AUD_MGR_I("[HANDLE_STOP] Pending stop BT_STREAM_SBC"); + return; + } #else - if (app_ring_merge_isrun()) - { - TRACE_AUD_MGR_I("[HANDLE_STOP] pending BT_STREAM_SBC"); - app_ring_merge_save_pending_start_stream_op(PENDING_TO_STOP_A2DP_STREAMING, device_id); - return; - } + if (app_ring_merge_isrun()) { + TRACE_AUD_MGR_I("[HANDLE_STOP] pending BT_STREAM_SBC"); + app_ring_merge_save_pending_start_stream_op( + PENDING_TO_STOP_A2DP_STREAMING, device_id); + return; + } #endif - uint8_t media_pre_sbc = bt_meida.media_curr_sbc; - TRACE_AUD_MGR_I("[HANDLE_STOP] SBC STOPPING id:%d/%d", bt_meida.media_curr_sbc, device_id); + uint8_t media_pre_sbc = bt_meida.media_curr_sbc; + TRACE_AUD_MGR_I("[HANDLE_STOP] SBC STOPPING id:%d/%d", + bt_meida.media_curr_sbc, device_id); - ////if current media is sbc ,stop the sbc streaming - bt_media_clear_media_type(stream_type,device_id); + ////if current media is sbc ,stop the sbc streaming + bt_media_clear_media_type(stream_type, device_id); - //if current stream is the stop one ,so stop it - if ((bt_media_get_current_media() & BT_STREAM_SBC) + // if current stream is the stop one ,so stop it + if ((bt_media_get_current_media() & BT_STREAM_SBC) #if !defined(IBRT) - && bt_meida.media_curr_sbc == device_id + && bt_meida.media_curr_sbc == device_id #endif - ) - { - app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_CLOSE, 0); - bt_media_clear_current_media(BT_STREAM_SBC); - TRACE_AUD_MGR_I("[HANDLE_STOP] SBC STOPED!"); - } + ) { + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + bt_media_clear_current_media(BT_STREAM_SBC); + TRACE_AUD_MGR_I("[HANDLE_STOP] SBC STOPED!"); + } - if(bt_media_is_media_active_by_type(BT_STREAM_SBC)) - { - enum BT_DEVICE_ID_T sbc_id = bt_media_get_active_device_by_type(BT_STREAM_SBC); - if(sbc_id < BT_DEVICE_NUM) - { - bt_meida.media_curr_sbc = sbc_id; - } - } - else - { - bt_meida.media_curr_sbc = BT_DEVICE_NUM; - } + if (bt_media_is_media_active_by_type(BT_STREAM_SBC)) { + enum BT_DEVICE_ID_T sbc_id = + bt_media_get_active_device_by_type(BT_STREAM_SBC); + if (sbc_id < BT_DEVICE_NUM) { + bt_meida.media_curr_sbc = sbc_id; + } + } else { + bt_meida.media_curr_sbc = BT_DEVICE_NUM; + } - if(bt_media_is_media_active_by_type(BT_STREAM_VOICE)) - { + if (bt_media_is_media_active_by_type(BT_STREAM_VOICE)) { - } - else if(bt_media_is_media_active_by_type(BT_STREAM_MEDIA)) - { - //do nothing - } + } else if (bt_media_is_media_active_by_type(BT_STREAM_MEDIA)) { + // do nothing + } #ifdef VOICE_DATAPATH #if !ISOLATED_AUDIO_STREAM_ENABLED - else if(bt_media_is_media_active_by_type(BT_STREAM_CAPTURE)) - { - //do nothing - } + else if (bt_media_is_media_active_by_type(BT_STREAM_CAPTURE)) { + // do nothing + } #endif #endif - else if(bt_media_is_media_active_by_type(BT_STREAM_SBC)) - { - enum BT_DEVICE_ID_T sbc_id = bt_media_get_active_device_by_type(BT_STREAM_SBC); - if (sbc_id < BT_DEVICE_NUM && - (media_pre_sbc != bt_meida.media_curr_sbc)) - { - app_audio_manager_switch_a2dp(sbc_id); - bt_media_set_current_media(BT_STREAM_SBC); - app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, - (uint8_t)(APP_BT_SETTING_SETUP), - (uint32_t)(app_bt_device.sample_rate[sbc_id] & A2D_STREAM_SAMP_FREQ_MSK)); - app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_OPEN, 0); - } - } - } - break; + else if (bt_media_is_media_active_by_type(BT_STREAM_SBC)) { + enum BT_DEVICE_ID_T sbc_id = + bt_media_get_active_device_by_type(BT_STREAM_SBC); + if (sbc_id < BT_DEVICE_NUM && + (media_pre_sbc != bt_meida.media_curr_sbc)) { + app_audio_manager_switch_a2dp(sbc_id); + bt_media_set_current_media(BT_STREAM_SBC); + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)(APP_BT_SETTING_SETUP), + (uint32_t)(app_bt_device.sample_rate[sbc_id] & + A2D_STREAM_SAMP_FREQ_MSK)); + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)APP_BT_SETTING_OPEN, 0); + } + } + } break; #ifdef MEDIA_PLAYER_SUPPORT - case BT_STREAM_MEDIA: - bt_media_clear_media_type(BT_STREAM_MEDIA,device_id); + case BT_STREAM_MEDIA: + bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); - if(bt_media_is_media_active_by_type(BT_STREAM_MEDIA)) - { - //also have media report so do nothing - } - else if(bt_media_is_media_active_by_type(BT_STREAM_VOICE)) - { - if(bt_media_get_current_media() & BT_STREAM_VOICE) - { - //do nothing - } - else if(bt_media_get_current_media() & BT_STREAM_MEDIA) - { - ///media report is end ,so goto voice - uint8_t curr_sco_id; - curr_sco_id = app_audio_manager_get_active_sco_num(); - if (curr_sco_id!=BT_DEVICE_NUM) - { - bt_media_set_media_type(BT_STREAM_VOICE, (enum BT_DEVICE_ID_T)curr_sco_id); - bt_media_set_current_media(BT_STREAM_VOICE); + if (bt_media_is_media_active_by_type(BT_STREAM_MEDIA)) { + // also have media report so do nothing + } else if (bt_media_is_media_active_by_type(BT_STREAM_VOICE)) { + if (bt_media_get_current_media() & BT_STREAM_VOICE) { + // do nothing + } else if (bt_media_get_current_media() & BT_STREAM_MEDIA) { + /// media report is end ,so goto voice + uint8_t curr_sco_id; + curr_sco_id = app_audio_manager_get_active_sco_num(); + if (curr_sco_id != BT_DEVICE_NUM) { + bt_media_set_media_type(BT_STREAM_VOICE, + (enum BT_DEVICE_ID_T)curr_sco_id); + bt_media_set_current_media(BT_STREAM_VOICE); #ifdef __BT_ONE_BRING_TWO__ - app_audio_manager_swap_sco((enum BT_DEVICE_ID_T)curr_sco_id); + app_audio_manager_swap_sco((enum BT_DEVICE_ID_T)curr_sco_id); #endif - app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, (uint8_t)APP_BT_SETTING_OPEN, 0); - } - } + app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, + (uint8_t)APP_BT_SETTING_OPEN, 0); + } + } - } - else if (btapp_hfp_is_call_active()) - { - //do nothing - } + } else if (btapp_hfp_is_call_active()) { + // do nothing + } #ifdef VOICE_DATAPATH #if !ISOLATED_AUDIO_STREAM_ENABLED - else if(bt_media_is_media_active_by_type(BT_STREAM_CAPTURE)) - { - app_audio_sendrequest(APP_BT_STREAM_VOICEPATH, (uint8_t)APP_BT_SETTING_OPEN, 0); - bt_media_set_current_media(BT_STREAM_CAPTURE); - } + else if (bt_media_is_media_active_by_type(BT_STREAM_CAPTURE)) { + app_audio_sendrequest(APP_BT_STREAM_VOICEPATH, + (uint8_t)APP_BT_SETTING_OPEN, 0); + bt_media_set_current_media(BT_STREAM_CAPTURE); + } #endif #endif #ifdef __AI_VOICE__ - else if(bt_media_is_media_active_by_type(BT_STREAM_AI_VOICE) || ai_if_is_ai_stream_mic_open()) - { - bt_media_clear_current_media(BT_STREAM_MEDIA); - if (bt_media_is_media_active_by_type(BT_STREAM_AI_VOICE) && !(bt_media_get_current_media() & BT_STREAM_AI_VOICE)) - { - app_audio_sendrequest(APP_BT_STREAM_AI_VOICE, (uint8_t)APP_BT_SETTING_OPEN, 0); - bt_media_set_current_media(BT_STREAM_AI_VOICE); - } - } + else if (bt_media_is_media_active_by_type(BT_STREAM_AI_VOICE) || + ai_if_is_ai_stream_mic_open()) { + bt_media_clear_current_media(BT_STREAM_MEDIA); + if (bt_media_is_media_active_by_type(BT_STREAM_AI_VOICE) && + !(bt_media_get_current_media() & BT_STREAM_AI_VOICE)) { + app_audio_sendrequest(APP_BT_STREAM_AI_VOICE, + (uint8_t)APP_BT_SETTING_OPEN, 0); + bt_media_set_current_media(BT_STREAM_AI_VOICE); + } + } #endif - else if(bt_media_is_media_active_by_type(BT_STREAM_SBC)) - { - ///if another device is also in sbc mode - enum BT_DEVICE_ID_T sbc_id = bt_media_get_active_sbc_device(); - bt_media_set_media_type(BT_STREAM_SBC, sbc_id); - app_audio_manager_switch_a2dp(sbc_id); - bt_media_set_current_media(BT_STREAM_SBC); + else if (bt_media_is_media_active_by_type(BT_STREAM_SBC)) { + /// if another device is also in sbc mode + enum BT_DEVICE_ID_T sbc_id = bt_media_get_active_sbc_device(); + bt_media_set_media_type(BT_STREAM_SBC, sbc_id); + app_audio_manager_switch_a2dp(sbc_id); + bt_media_set_current_media(BT_STREAM_SBC); - app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, - (uint8_t)(APP_BT_SETTING_SETUP), - (uint32_t)(app_bt_device.sample_rate[sbc_id] & A2D_STREAM_SAMP_FREQ_MSK)); + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)(APP_BT_SETTING_SETUP), + (uint32_t)(app_bt_device.sample_rate[sbc_id] & + A2D_STREAM_SAMP_FREQ_MSK)); - app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_OPEN, 0); - } - else - { - //have no meida task,so goto idle - bt_media_set_current_media(0); - } - break; + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)APP_BT_SETTING_OPEN, 0); + } else { + // have no meida task,so goto idle + bt_media_set_current_media(0); + } + break; #endif - case BT_STREAM_VOICE: + case BT_STREAM_VOICE: - if(!bt_media_is_media_active_by_device(BT_STREAM_VOICE,device_id)||!(bt_media_get_current_media() & BT_STREAM_VOICE)) - { - TRACE_AUD_MGR_I("[HANDLE_STOP] bt_media_stop already stop"); - bt_media_clear_media_type(stream_type, device_id); - return ; - } + if (!bt_media_is_media_active_by_device(BT_STREAM_VOICE, device_id) || + !(bt_media_get_current_media() & BT_STREAM_VOICE)) { + TRACE_AUD_MGR_I("[HANDLE_STOP] bt_media_stop already stop"); + bt_media_clear_media_type(stream_type, device_id); + return; + } #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - if (!audio_prompt_check_on_stopping_stream( - PENDING_TO_STOP_SCO_STREAMING, device_id)) - { - return; - } + if (!audio_prompt_check_on_stopping_stream(PENDING_TO_STOP_SCO_STREAMING, + device_id)) { + return; + } #else - if (app_ring_merge_isrun()) - { - TRACE_AUD_MGR_I("[HANDLE_STOP] bt_media_stop pending BT_STREAM_VOICE"); - app_ring_merge_save_pending_start_stream_op(PENDING_TO_STOP_SCO_STREAMING, device_id); - return; - } + if (app_ring_merge_isrun()) { + TRACE_AUD_MGR_I("[HANDLE_STOP] bt_media_stop pending BT_STREAM_VOICE"); + app_ring_merge_save_pending_start_stream_op(PENDING_TO_STOP_SCO_STREAMING, + device_id); + return; + } #endif - app_audio_manager_set_active_sco_num(BT_DEVICE_NUM); - bt_media_clear_media_type(stream_type, device_id); + app_audio_manager_set_active_sco_num(BT_DEVICE_NUM); + bt_media_clear_media_type(stream_type, device_id); #ifdef MEDIA_PLAYER_SUPPORT - if(bt_media_is_media_active_by_type(BT_STREAM_MEDIA)) - { - if(bt_media_get_current_media() & BT_STREAM_MEDIA) - { - //do nothing - } + if (bt_media_is_media_active_by_type(BT_STREAM_MEDIA)) { + if (bt_media_get_current_media() & BT_STREAM_MEDIA) { + // do nothing + } #ifdef VOICE_DATAPATH #if !ISOLATED_AUDIO_STREAM_ENABLED - else if(bt_media_is_media_active_by_type(BT_STREAM_CAPTURE)) - { - bt_media_clear_all_media_type(); - app_audio_sendrequest(APP_BT_STREAM_VOICEPATH, (uint8_t)APP_BT_SETTING_OPEN, 0); - bt_media_set_current_media(BT_STREAM_CAPTURE); - } + else if (bt_media_is_media_active_by_type(BT_STREAM_CAPTURE)) { + bt_media_clear_all_media_type(); + app_audio_sendrequest(APP_BT_STREAM_VOICEPATH, + (uint8_t)APP_BT_SETTING_OPEN, 0); + bt_media_set_current_media(BT_STREAM_CAPTURE); + } #endif #endif - else if (bt_media_get_current_media() & BT_STREAM_VOICE) - { - TRACE_AUD_MGR_W("[HANDLE_STOP] voice and media is all on,media should be the current media"); - if(!bt_media_is_media_active_by_type(BT_STREAM_VOICE)) - { - app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, (uint8_t)APP_BT_SETTING_CLOSE, 0); - } - } - else if (bt_media_get_current_media() & BT_STREAM_SBC) - { - TRACE_AUD_MGR_W("[HANDLE_STOP] voice and media is all on,media should be the current media"); - if(!bt_media_is_media_active_by_type(BT_STREAM_SBC)) - { - app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_CLOSE, 0); - } - } - } - else + else if (bt_media_get_current_media() & BT_STREAM_VOICE) { + TRACE_AUD_MGR_W("[HANDLE_STOP] voice and media is all on,media should " + "be the current media"); + if (!bt_media_is_media_active_by_type(BT_STREAM_VOICE)) { + app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + } + } else if (bt_media_get_current_media() & BT_STREAM_SBC) { + TRACE_AUD_MGR_W("[HANDLE_STOP] voice and media is all on,media should " + "be the current media"); + if (!bt_media_is_media_active_by_type(BT_STREAM_SBC)) { + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + } + } + } else #endif - if(bt_media_is_media_active_by_type(BT_STREAM_VOICE)) - { + if (bt_media_is_media_active_by_type(BT_STREAM_VOICE)) { #ifdef __BT_ONE_BRING_TWO__ - if(bt_get_sco_number()>1 + if (bt_get_sco_number() > 1 #ifdef CHIP_BEST1000 - && hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_2 + && hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_2 #endif - ) - { - TRACE_AUD_MGR_W("[HANDLE_STOP] bt_media_stop, but another soc need connect"); - enum BT_DEVICE_ID_T voice_dev_id = bt_media_get_active_device_by_type(BT_STREAM_VOICE); + ) { + TRACE_AUD_MGR_W( + "[HANDLE_STOP] bt_media_stop, but another soc need connect"); + enum BT_DEVICE_ID_T voice_dev_id = + bt_media_get_active_device_by_type(BT_STREAM_VOICE); #ifdef HFP_NO_PRERMPT - app_audio_manager_set_active_sco_num(voice_dev_id); + app_audio_manager_set_active_sco_num(voice_dev_id); #else - app_audio_manager_swap_sco(voice_dev_id); + app_audio_manager_swap_sco(voice_dev_id); #ifdef __HF_KEEP_ONE_ALIVE__ - enum BT_DEVICE_ID_T other_voice_dev_id = (voice_dev_id == BT_DEVICE_ID_1) ? BT_DEVICE_ID_2 : BT_DEVICE_ID_1;; - if (btif_hf_check_AudioConnect_status(app_bt_device.hf_channel[other_voice_dev_id])) - { - TRACE_AUD_MGR_I("[HANDLE_STOP] Disconnect another AudioLink"); - app_bt_HF_DisconnectAudioLink(app_bt_device.hf_channel[other_voice_dev_id]); - } + enum BT_DEVICE_ID_T other_voice_dev_id = + (voice_dev_id == BT_DEVICE_ID_1) ? BT_DEVICE_ID_2 : BT_DEVICE_ID_1; + ; + if (btif_hf_check_AudioConnect_status( + app_bt_device.hf_channel[other_voice_dev_id])) { + TRACE_AUD_MGR_I("[HANDLE_STOP] Disconnect another AudioLink"); + app_bt_HF_DisconnectAudioLink( + app_bt_device.hf_channel[other_voice_dev_id]); + } #endif #endif - } - bt_media_set_current_media(BT_STREAM_VOICE); + } + bt_media_set_current_media(BT_STREAM_VOICE); #endif - } - else if (btapp_hfp_is_call_active()) - { - TRACE_AUD_MGR_I("[HANDLE_STOP] stop in HF_CALL_ACTIVE and no sco need"); - bt_media_set_current_media(0); - app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, (uint8_t)APP_BT_SETTING_CLOSE, 0); - bt_media_clear_media_type(BT_STREAM_VOICE, device_id); - { - enum BT_DEVICE_ID_T sbc_id = bt_media_get_active_sbc_device(); - if(sbc_id < BT_DEVICE_NUM ) - { - app_audio_manager_switch_a2dp(sbc_id); - bt_media_set_current_media(BT_STREAM_SBC); - app_audio_sendrequest( APP_BT_STREAM_A2DP_SBC, - (uint8_t)(APP_BT_SETTING_SETUP), - (uint32_t)(app_bt_device.sample_rate[sbc_id] & A2D_STREAM_SAMP_FREQ_MSK)); - app_audio_sendrequest( APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_OPEN, 0); - } - } - } + } else if (btapp_hfp_is_call_active()) { + TRACE_AUD_MGR_I("[HANDLE_STOP] stop in HF_CALL_ACTIVE and no sco need"); + bt_media_set_current_media(0); + app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + bt_media_clear_media_type(BT_STREAM_VOICE, device_id); + { + enum BT_DEVICE_ID_T sbc_id = bt_media_get_active_sbc_device(); + if (sbc_id < BT_DEVICE_NUM) { + app_audio_manager_switch_a2dp(sbc_id); + bt_media_set_current_media(BT_STREAM_SBC); + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)(APP_BT_SETTING_SETUP), + (uint32_t)(app_bt_device.sample_rate[sbc_id] & + A2D_STREAM_SAMP_FREQ_MSK)); + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)APP_BT_SETTING_OPEN, 0); + } + } + } #ifdef VOICE_DATAPATH #if !ISOLATED_AUDIO_STREAM_ENABLED - else if(bt_media_is_media_active_by_type(BT_STREAM_CAPTURE)) - { - app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, (uint8_t)APP_BT_SETTING_CLOSE, 0); - app_audio_sendrequest(APP_BT_STREAM_VOICEPATH, (uint8_t)APP_BT_SETTING_OPEN, 0); - bt_media_set_current_media(BT_STREAM_CAPTURE); - } + else if (bt_media_is_media_active_by_type(BT_STREAM_CAPTURE)) { + app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + app_audio_sendrequest(APP_BT_STREAM_VOICEPATH, + (uint8_t)APP_BT_SETTING_OPEN, 0); + bt_media_set_current_media(BT_STREAM_CAPTURE); + } #endif #endif - else if(bt_media_is_media_active_by_type(BT_STREAM_SBC)) - { - ///if another device is also in sbc mode - enum BT_DEVICE_ID_T sbc_id = bt_media_get_active_sbc_device(); - if( sbc_id < BT_DEVICE_NUM /*&& device_id == sbc_id*/ ) - { - app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, (uint8_t)APP_BT_SETTING_CLOSE, 0); - app_audio_manager_switch_a2dp(sbc_id); - bt_media_set_current_media(BT_STREAM_SBC); - app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, - (uint8_t)(APP_BT_SETTING_SETUP), - (uint32_t)(app_bt_device.sample_rate[sbc_id] & A2D_STREAM_SAMP_FREQ_MSK)); - app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_OPEN, 0); - } - } - else - { - bt_media_set_current_media(0); - app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, (uint8_t)APP_BT_SETTING_CLOSE, 0); - } + else if (bt_media_is_media_active_by_type(BT_STREAM_SBC)) { + /// if another device is also in sbc mode + enum BT_DEVICE_ID_T sbc_id = bt_media_get_active_sbc_device(); + if (sbc_id < BT_DEVICE_NUM /*&& device_id == sbc_id*/) { + app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + app_audio_manager_switch_a2dp(sbc_id); + bt_media_set_current_media(BT_STREAM_SBC); + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)(APP_BT_SETTING_SETUP), + (uint32_t)(app_bt_device.sample_rate[sbc_id] & + A2D_STREAM_SAMP_FREQ_MSK)); + app_audio_sendrequest(APP_BT_STREAM_A2DP_SBC, + (uint8_t)APP_BT_SETTING_OPEN, 0); + } + } else { + bt_media_set_current_media(0); + app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + } #if ISOLATED_AUDIO_STREAM_ENABLED #ifdef VOICE_DATAPATH - if(bt_media_is_media_active_by_type(BT_STREAM_CAPTURE)) - { - app_audio_sendrequest(APP_BT_STREAM_VOICEPATH, (uint8_t)APP_BT_SETTING_OPEN, 0); - bt_media_set_current_media(BT_STREAM_CAPTURE); - } + if (bt_media_is_media_active_by_type(BT_STREAM_CAPTURE)) { + app_audio_sendrequest(APP_BT_STREAM_VOICEPATH, + (uint8_t)APP_BT_SETTING_OPEN, 0); + bt_media_set_current_media(BT_STREAM_CAPTURE); + } #endif #endif #ifdef __THIRDPARTY - if(bt_media_is_media_active_by_type(BT_STREAM_THIRDPARTY_VOICE)) { - app_audio_sendrequest(APP_BT_STREAM_THIRDPARTY_VOICE, (uint8_t)APP_BT_SETTING_OPEN, 0); - bt_media_set_current_media(BT_STREAM_THIRDPARTY_VOICE); - } + if (bt_media_is_media_active_by_type(BT_STREAM_THIRDPARTY_VOICE)) { + app_audio_sendrequest(APP_BT_STREAM_THIRDPARTY_VOICE, + (uint8_t)APP_BT_SETTING_OPEN, 0); + bt_media_set_current_media(BT_STREAM_THIRDPARTY_VOICE); + } #endif - break; + break; #ifdef RB_CODEC - case BT_STREAM_RBCODEC: - bt_media_rbcodec_stop_process(stream_type, device_id, 0); - break; + case BT_STREAM_RBCODEC: + bt_media_rbcodec_stop_process(stream_type, device_id, 0); + break; #endif #ifdef AUDIO_LINEIN - case BT_STREAM_LINEIN: - if(bt_media_is_media_active_by_type(BT_STREAM_LINEIN)) - { - app_audio_sendrequest(APP_PLAY_LINEIN_AUDIO, (uint8_t)APP_BT_SETTING_CLOSE, 0); - if(bt_media_get_current_media() & BT_STREAM_LINEIN) - bt_media_set_current_media(0); + case BT_STREAM_LINEIN: + if (bt_media_is_media_active_by_type(BT_STREAM_LINEIN)) { + app_audio_sendrequest(APP_PLAY_LINEIN_AUDIO, + (uint8_t)APP_BT_SETTING_CLOSE, 0); + if (bt_media_get_current_media() & BT_STREAM_LINEIN) + bt_media_set_current_media(0); - bt_media_clear_media_type(stream_type,device_id); - } - break; -#endif - default: - ASSERT(0,"[HANDLE_STOP] ERROR TYPE: %x", stream_type); - break; + bt_media_clear_media_type(stream_type, device_id); } + break; +#endif + default: + ASSERT(0, "[HANDLE_STOP] ERROR TYPE: %x", stream_type); + break; + } #ifdef __BT_ONE_BRING_TWO__ - TRACE_AUD_MGR_I("[HANDLE_STOP] end media_active = %x,%x,curr_active_media = %x", - bt_meida.media_active[0],bt_meida.media_active[1], bt_meida.curr_active_media); + TRACE_AUD_MGR_I( + "[HANDLE_STOP] end media_active = %x,%x,curr_active_media = %x", + bt_meida.media_active[0], bt_meida.media_active[1], + bt_meida.curr_active_media); #else - TRACE_AUD_MGR_I("[HANDLE_STOP] end media_active = %x%s", - bt_meida.media_active[0], strmtype2str(bt_meida.media_active[0])); - TRACE_AUD_MGR_I("[HANDLE_STOP] end curr_active_media = %x%s", - bt_meida.curr_active_media, strmtype2str(bt_meida.curr_active_media)); + TRACE_AUD_MGR_I("[HANDLE_STOP] end media_active = %x%s", + bt_meida.media_active[0], + strmtype2str(bt_meida.media_active[0])); + TRACE_AUD_MGR_I("[HANDLE_STOP] end curr_active_media = %x%s", + bt_meida.curr_active_media, + strmtype2str(bt_meida.curr_active_media)); #endif } -void app_media_stop_media(uint16_t stream_type,enum BT_DEVICE_ID_T device_id) -{ +void app_media_stop_media(uint16_t stream_type, enum BT_DEVICE_ID_T device_id) { #ifdef MEDIA_PLAYER_SUPPORT #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - audio_prompt_stop_playing(); + audio_prompt_stop_playing(); #endif - if(bt_media_is_media_active_by_type(BT_STREAM_MEDIA) || app_audio_list_playback_exist()) - { + if (bt_media_is_media_active_by_type(BT_STREAM_MEDIA) || + app_audio_list_playback_exist()) { #ifdef __AUDIO_QUEUE_SUPPORT__ - ////should have no sbc - app_audio_list_clear(); + ////should have no sbc + app_audio_list_clear(); #endif - if(bt_media_get_current_media() & BT_STREAM_MEDIA) - { - TRACE_AUD_MGR_I("[STOP_MEDIA]"); - //bt_media_set_current_media(0); - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_CLOSE, 0); + if (bt_media_get_current_media() & BT_STREAM_MEDIA) { + TRACE_AUD_MGR_I("[STOP_MEDIA]"); + // bt_media_set_current_media(0); + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_CLOSE, + 0); + } + bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); + if (bt_media_is_media_active_by_type(BT_STREAM_VOICE)) { + enum BT_DEVICE_ID_T currScoId = BT_DEVICE_NUM; + currScoId = (enum BT_DEVICE_ID_T)app_audio_manager_get_active_sco_num(); + + if (currScoId == BT_DEVICE_NUM) { + for (uint8_t i = 0; i < BT_DEVICE_NUM; i++) { + if (bt_media_is_media_active_by_device(BT_STREAM_VOICE, + (enum BT_DEVICE_ID_T)i)) { + currScoId = device_id; + break; + } } - bt_media_clear_media_type(BT_STREAM_MEDIA, device_id); - if(bt_media_is_media_active_by_type(BT_STREAM_VOICE)) - { - enum BT_DEVICE_ID_T currScoId = BT_DEVICE_NUM; - currScoId = (enum BT_DEVICE_ID_T)app_audio_manager_get_active_sco_num(); + } - if (currScoId == BT_DEVICE_NUM) - { - for (uint8_t i=0; ibdAddr.addr, 6); - btif_hf_get_remote_bdaddr(app_bt_device.hf_channel[bt_meida.media_curr_sco], &bdaddr); - DUMP8("%02x ", bdaddr.address, 6); -#if defined(HFP_1_6_ENABLE) - uint32_t code_type; - uint32_t code_type_reg; - code_type = app_audio_manager_get_scocodecid(); - code_type_reg = BTDIGITAL_REG(0xD0222000); - if (code_type == BTIF_HF_SCO_CODEC_MSBC) - { - BTDIGITAL_REG(0xD0222000) = (code_type_reg & (~(7<<1))) | (3<<1); - TRACE_AUD_MGR_I("[SCO_CHK] MSBC REG:0xD0222000=0x%08x B:%d", BTDIGITAL_REG(0xD0222000), (BTDIGITAL_REG(0xD0222000)>>15)&1); - - } - else - { - BTDIGITAL_REG(0xD0222000) = (code_type_reg & (~(7<<1))) | (2<<1); - TRACE_AUD_MGR_I("[SCO_CHK] CVSD REG:0xD0222000=0x%08x B:%d", BTDIGITAL_REG(0xD0222000), (BTDIGITAL_REG(0xD0222000)>>15)&1); - } -#else - uint32_t code_type_reg; - code_type_reg = BTDIGITAL_REG(0xD0222000); - BTDIGITAL_REG(0xD0222000) = (code_type_reg & (~(7<<1))) | (2<<1); - TRACE_AUD_MGR_I("[SCO_CHK] CVSD REG:0xD0222000=0x%08x B:%d", BTDIGITAL_REG(0xD0222000), (BTDIGITAL_REG(0xD0222000)>>15)&1); -#endif + } } + TRACE_AUD_MGR_I( + "[SCO_CHK] curr:%d type:%d Intv:%d Intv_reg:%d", + bt_meida.media_curr_sco, + btif_cmgr_get_sco_connect_sco_link_type(cmgrHandler), + btif_cmgr_get_sco_connect_sco_rx_parms_sco_transmission_interval( + cmgrHandler), + scoTransmissionInterval_reg); + + // DUMP8("%02x ", + // app_bt_device.hf_channel[bt_meida.media_curr_sco].cmgrHandler.remDev->bdAddr.addr, + // 6); + btif_hf_get_remote_bdaddr(app_bt_device.hf_channel[bt_meida.media_curr_sco], + &bdaddr); + DUMP8("%02x ", bdaddr.address, 6); +#if defined(HFP_1_6_ENABLE) + uint32_t code_type; + uint32_t code_type_reg; + code_type = app_audio_manager_get_scocodecid(); + code_type_reg = BTDIGITAL_REG(0xD0222000); + if (code_type == BTIF_HF_SCO_CODEC_MSBC) { + BTDIGITAL_REG(0xD0222000) = (code_type_reg & (~(7 << 1))) | (3 << 1); + TRACE_AUD_MGR_I("[SCO_CHK] MSBC REG:0xD0222000=0x%08x B:%d", + BTDIGITAL_REG(0xD0222000), + (BTDIGITAL_REG(0xD0222000) >> 15) & 1); + + } else { + BTDIGITAL_REG(0xD0222000) = (code_type_reg & (~(7 << 1))) | (2 << 1); + TRACE_AUD_MGR_I("[SCO_CHK] CVSD REG:0xD0222000=0x%08x B:%d", + BTDIGITAL_REG(0xD0222000), + (BTDIGITAL_REG(0xD0222000) >> 15) & 1); + } +#else + uint32_t code_type_reg; + code_type_reg = BTDIGITAL_REG(0xD0222000); + BTDIGITAL_REG(0xD0222000) = (code_type_reg & (~(7 << 1))) | (2 << 1); + TRACE_AUD_MGR_I("[SCO_CHK] CVSD REG:0xD0222000=0x%08x B:%d", + BTDIGITAL_REG(0xD0222000), + (BTDIGITAL_REG(0xD0222000) >> 15) & 1); +#endif + } #else #if defined(DEBUG) #if defined(IBRT) - if (app_tws_ibrt_mobile_link_connected()) + if (app_tws_ibrt_mobile_link_connected()) #endif - { - hf_chan_handle_t hf_chan = app_bt_device.hf_channel[bt_meida.media_curr_sco]; - if (hf_chan && (cmgrHandler = btif_hf_get_chan_manager_handler(hf_chan))) - { - TRACE_AUD_MGR_I("[SCO_CHK] curSco:%d type:%d Interval:%d", - bt_meida.media_curr_sco, - btif_cmgr_get_sco_connect_sco_link_type(cmgrHandler), - btif_cmgr_get_sco_connect_sco_rx_parms_sco_transmission_interval(cmgrHandler)); - } + { + hf_chan_handle_t hf_chan = + app_bt_device.hf_channel[bt_meida.media_curr_sco]; + if (hf_chan && (cmgrHandler = btif_hf_get_chan_manager_handler(hf_chan))) { + TRACE_AUD_MGR_I( + "[SCO_CHK] curSco:%d type:%d Interval:%d", bt_meida.media_curr_sco, + btif_cmgr_get_sco_connect_sco_link_type(cmgrHandler), + btif_cmgr_get_sco_connect_sco_rx_parms_sco_transmission_interval( + cmgrHandler)); } + } #endif #endif - TRACE_AUD_MGR_I("[SCO_CHK] exit"); - return 0; + TRACE_AUD_MGR_I("[SCO_CHK] exit"); + return 0; } -int app_audio_manager_swap_sco(enum BT_DEVICE_ID_T id) -{ - if(bt_get_sco_number()<=1) - return 0; +int app_audio_manager_swap_sco(enum BT_DEVICE_ID_T id) { + if (bt_get_sco_number() <= 1) + return 0; #if defined(HFP_1_6_ENABLE) - uint8_t curr_sco_id; - curr_sco_id = app_audio_manager_get_active_sco_num(); + uint8_t curr_sco_id; + curr_sco_id = app_audio_manager_get_active_sco_num(); #endif - bt_bdaddr_t bdAdd; - uint16_t scohandle; - //if (HF_GetRemoteBDAddr(&app_bt_device.hf_channel[id], &bdAdd)){ - if ( btif_hf_get_remote_bdaddr(app_bt_device.hf_channel[id], &bdAdd)) - { - //TRACE_AUD_MGR_I("[SCO SWAP]switch_sco to id:%d sco:%x", id, app_bt_device.hf_channel[id].cmgrHandler.scoConnect); + bt_bdaddr_t bdAdd; + uint16_t scohandle; + // if (HF_GetRemoteBDAddr(&app_bt_device.hf_channel[id], &bdAdd)){ + if (btif_hf_get_remote_bdaddr(app_bt_device.hf_channel[id], &bdAdd)) { + // TRACE_AUD_MGR_I("[SCO SWAP]switch_sco to id:%d sco:%x", id, + // app_bt_device.hf_channel[id].cmgrHandler.scoConnect); - //DUMP8("%02x ", app_bt_device.hf_channel[id].cmgrHandler.remDev->bdAddr.addr, 6); - //DUMP8("%02x ", bdAdd.address, 6); + // DUMP8("%02x ", + // app_bt_device.hf_channel[id].cmgrHandler.remDev->bdAddr.addr, 6); + // DUMP8("%02x ", bdAdd.address, 6); - /* - TRACE_AUD_MGR_I("[SCO_SWAP] state:%d type:%d hdl:%x ", app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scostate, - app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoLinkType, - app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoHciHandle); - TRACE_AUD_MGR_I("[SCO_SWAP] tx[bw:%d rbw:%d ml:%d vs:%d rt:%d pktyp:%d]", app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoTxParms.transmitBandwidth, - app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoTxParms.receiveBandwidth, - app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoTxParms.maxLatency, - app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoTxParms.voiceSetting, - app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoTxParms.retransmissionEffort, - app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoTxParms.eScoPktType); + /* + TRACE_AUD_MGR_I("[SCO_SWAP] state:%d type:%d hdl:%x ", + app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scostate, + app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoLinkType, + app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoHciHandle); + TRACE_AUD_MGR_I("[SCO_SWAP] tx[bw:%d rbw:%d ml:%d vs:%d rt:%d pktyp:%d]", + app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoTxParms.transmitBandwidth, + app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoTxParms.receiveBandwidth, + app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoTxParms.maxLatency, + app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoTxParms.voiceSetting, + app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoTxParms.retransmissionEffort, + app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoTxParms.eScoPktType); - TRACE_AUD_MGR_I("[SCO_SWAP] rx[itv:%d ret:%d rxl:%d txl:%d]", app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoRxParms.scoTransmissionInterval, - app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoRxParms.scoRetransmissionWindow, - app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoRxParms.scoRxPacketLen, - app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoRxParms.scoTxPacketLen); - */ + TRACE_AUD_MGR_I("[SCO_SWAP] rx[itv:%d ret:%d rxl:%d txl:%d]", + app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoRxParms.scoTransmissionInterval, + app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoRxParms.scoRetransmissionWindow, + app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoRxParms.scoRxPacketLen, + app_bt_device.hf_channel[id].cmgrHandler.scoConnect->scoRxParms.scoTxPacketLen); + */ - app_audio_manager_set_active_sco_num(id); - scohandle = btif_hf_get_sco_hcihandle(app_bt_device.hf_channel[id]); - if (scohandle != BTIF_HCI_INVALID_HANDLE) - { - app_bt_Me_switch_sco(scohandle); - } - app_bt_stream_volume_ptr_update(bdAdd.address); - app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_SET, app_bt_stream_volume_get_ptr()->hfp_vol); + app_audio_manager_set_active_sco_num(id); + scohandle = btif_hf_get_sco_hcihandle(app_bt_device.hf_channel[id]); + if (scohandle != BTIF_HCI_INVALID_HANDLE) { + app_bt_Me_switch_sco(scohandle); + } + app_bt_stream_volume_ptr_update(bdAdd.address); + app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_SET, + app_bt_stream_volume_get_ptr()->hfp_vol); #if defined(HFP_1_6_ENABLE) - if(curr_sco_id != id) - { - TRACE_AUD_MGR_I("[SCO_SWAP] try restart"); - bt_sco_player_forcemute(true,true); - app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, (uint8_t)APP_BT_SETTING_RESTART, 0); - } + if (curr_sco_id != id) { + TRACE_AUD_MGR_I("[SCO_SWAP] try restart"); + bt_sco_player_forcemute(true, true); + app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, + (uint8_t)APP_BT_SETTING_RESTART, 0); + } #endif - app_audio_manager_sco_status_checker(); - } - return 0; + app_audio_manager_sco_status_checker(); + } + return 0; } -int app_audio_manager_ctrl_volume_handle(APP_MESSAGE_BODY *msg_body) -{ - enum APP_AUDIO_MANAGER_VOLUME_CTRL_T volume_ctrl; - uint16_t volume_level = 0; +int app_audio_manager_ctrl_volume_handle(APP_MESSAGE_BODY *msg_body) { + enum APP_AUDIO_MANAGER_VOLUME_CTRL_T volume_ctrl; + uint16_t volume_level = 0; - volume_ctrl = (enum APP_AUDIO_MANAGER_VOLUME_CTRL_T)msg_body->message_ptr; - volume_level = (uint16_t)msg_body->message_Param0; + volume_ctrl = (enum APP_AUDIO_MANAGER_VOLUME_CTRL_T)msg_body->message_ptr; + volume_level = (uint16_t)msg_body->message_Param0; - switch (volume_ctrl) - { - case APP_AUDIO_MANAGER_VOLUME_CTRL_SET: - app_bt_stream_volumeset(volume_level); - break; - case APP_AUDIO_MANAGER_VOLUME_CTRL_UP: - app_bt_stream_volumeup(); - btapp_hfp_report_speak_gain(); - btapp_a2dp_report_speak_gain(); - break; - case APP_AUDIO_MANAGER_VOLUME_CTRL_DOWN: - app_bt_stream_volumedown(); - btapp_hfp_report_speak_gain(); - btapp_a2dp_report_speak_gain(); - break; - default: - break; - } + switch (volume_ctrl) { + case APP_AUDIO_MANAGER_VOLUME_CTRL_SET: + app_bt_stream_volumeset(volume_level); + break; + case APP_AUDIO_MANAGER_VOLUME_CTRL_UP: + app_bt_stream_volumeup(); + btapp_hfp_report_speak_gain(); + btapp_a2dp_report_speak_gain(); + break; + case APP_AUDIO_MANAGER_VOLUME_CTRL_DOWN: + app_bt_stream_volumedown(); + btapp_hfp_report_speak_gain(); + btapp_a2dp_report_speak_gain(); + break; + default: + break; + } - return 0; + return 0; } -int app_audio_manager_tune_samplerate_ratio_handle(APP_MESSAGE_BODY *msg_body) -{ - enum AUD_STREAM_T stream = AUD_STREAM_NUM; - float ratio = 1.0f; +int app_audio_manager_tune_samplerate_ratio_handle(APP_MESSAGE_BODY *msg_body) { + enum AUD_STREAM_T stream = AUD_STREAM_NUM; + float ratio = 1.0f; - stream = (enum AUD_STREAM_T)msg_body->message_ptr; - ratio = *(float *)&msg_body->message_Param0; + stream = (enum AUD_STREAM_T)msg_body->message_ptr; + ratio = *(float *)&msg_body->message_Param0; - TRACE_AUD_MGR_I("[TUNE] %d", (int32_t)(ratio * 10000000)); - af_codec_tune(stream, ratio); + TRACE_AUD_MGR_I("[TUNE] %d", (int32_t)(ratio * 10000000)); + af_codec_tune(stream, ratio); - return 0; + return 0; } static bool app_audio_manager_init = false; +int app_audio_manager_sendrequest(uint8_t massage_id, uint16_t stream_type, + uint8_t device_id, uint16_t aud_id) { + uint32_t audevt; + uint32_t msg0; + APP_MESSAGE_BLOCK msg; -int app_audio_manager_sendrequest(uint8_t massage_id, uint16_t stream_type, uint8_t device_id, uint16_t aud_id) -{ - uint32_t audevt; - uint32_t msg0; - APP_MESSAGE_BLOCK msg; + if (app_audio_manager_init == false) + return -1; - if(app_audio_manager_init == false) - return -1; - - // only allow prompt playing if powering-off is on-going - if (app_is_power_off_in_progress()) - { - if ((APP_BT_STREAM_MANAGER_START == massage_id) && - (BT_STREAM_MEDIA != stream_type)) - { - return -1; - } + // only allow prompt playing if powering-off is on-going + if (app_is_power_off_in_progress()) { + if ((APP_BT_STREAM_MANAGER_START == massage_id) && + (BT_STREAM_MEDIA != stream_type)) { + return -1; } + } - msg.mod_id = APP_MODUAL_AUDIO_MANAGE; - APP_AUDIO_MANAGER_SET_MESSAGE(audevt, massage_id, stream_type); - APP_AUDIO_MANAGER_SET_MESSAGE0(msg0,device_id,aud_id); - msg.msg_body.message_id = audevt; - msg.msg_body.message_ptr = msg0; - msg.msg_body.message_Param0 = msg0; - msg.msg_body.message_Param1 = 0; - msg.msg_body.message_Param2 = 0; + msg.mod_id = APP_MODUAL_AUDIO_MANAGE; + APP_AUDIO_MANAGER_SET_MESSAGE(audevt, massage_id, stream_type); + APP_AUDIO_MANAGER_SET_MESSAGE0(msg0, device_id, aud_id); + msg.msg_body.message_id = audevt; + msg.msg_body.message_ptr = msg0; + msg.msg_body.message_Param0 = msg0; + msg.msg_body.message_Param1 = 0; + msg.msg_body.message_Param2 = 0; + app_mailbox_put(&msg); + + return 0; +} + +int app_audio_manager_sendrequest_need_callback(uint8_t massage_id, + uint16_t stream_type, + uint8_t device_id, + uint16_t aud_id, uint32_t cb, + uint32_t cb_param) { + uint32_t audevt; + uint32_t msg0; + APP_MESSAGE_BLOCK msg; + + if (app_audio_manager_init == false) + return -1; + + msg.mod_id = APP_MODUAL_AUDIO_MANAGE; + APP_AUDIO_MANAGER_SET_MESSAGE(audevt, massage_id, stream_type); + APP_AUDIO_MANAGER_SET_MESSAGE0(msg0, device_id, aud_id); + msg.msg_body.message_id = audevt; + msg.msg_body.message_ptr = msg0; + msg.msg_body.message_Param0 = msg0; + msg.msg_body.message_Param1 = cb; + msg.msg_body.message_Param2 = cb_param; + app_mailbox_put(&msg); + + return 0; +} + +int app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_T volume_ctrl, + uint16_t volume_level) { + uint32_t audevt; + APP_MESSAGE_BLOCK msg; + osThreadId currThreadId; + + if (app_audio_manager_init == false) + return -1; + + msg.mod_id = APP_MODUAL_AUDIO_MANAGE; + APP_AUDIO_MANAGER_SET_MESSAGE(audevt, APP_BT_STREAM_MANAGER_CTRL_VOLUME, 0); + msg.msg_body.message_id = audevt; + msg.msg_body.message_ptr = (uint32_t)volume_ctrl; + msg.msg_body.message_Param0 = (uint32_t)volume_level; + msg.msg_body.message_Param1 = 0; + msg.msg_body.message_Param2 = 0; + currThreadId = osThreadGetId(); + if (currThreadId == af_thread_tid_get() || currThreadId == app_os_tid_get()) { + app_audio_manager_ctrl_volume_handle(&msg.msg_body); + } else { app_mailbox_put(&msg); - - return 0; + } + return 0; } -int app_audio_manager_sendrequest_need_callback( - uint8_t massage_id, uint16_t stream_type, uint8_t device_id, uint16_t aud_id, uint32_t cb, uint32_t cb_param) -{ - uint32_t audevt; - uint32_t msg0; - APP_MESSAGE_BLOCK msg; +int app_audio_manager_tune_samplerate_ratio(enum AUD_STREAM_T stream, + float ratio) { + uint32_t audevt; + APP_MESSAGE_BLOCK msg; + osThreadId currThreadId; - if(app_audio_manager_init == false) - return -1; + if (app_audio_manager_init == false) + return -1; - msg.mod_id = APP_MODUAL_AUDIO_MANAGE; - APP_AUDIO_MANAGER_SET_MESSAGE(audevt, massage_id, stream_type); - APP_AUDIO_MANAGER_SET_MESSAGE0(msg0,device_id,aud_id); - msg.msg_body.message_id = audevt; - msg.msg_body.message_ptr = msg0; - msg.msg_body.message_Param0 = msg0; - msg.msg_body.message_Param1 = cb; - msg.msg_body.message_Param2 = cb_param; + msg.mod_id = APP_MODUAL_AUDIO_MANAGE; + APP_AUDIO_MANAGER_SET_MESSAGE(audevt, + APP_BT_STREAM_MANAGER_TUNE_SAMPLERATE_RATIO, 0); + msg.msg_body.message_id = audevt; + msg.msg_body.message_ptr = (uint32_t)stream; + msg.msg_body.message_Param0 = *(uint32_t *)∶ + msg.msg_body.message_Param1 = 0; + msg.msg_body.message_Param2 = 0; + + currThreadId = osThreadGetId(); + if (currThreadId == af_thread_tid_get() || currThreadId == app_os_tid_get()) { + app_audio_manager_tune_samplerate_ratio_handle(&msg.msg_body); + } else { app_mailbox_put(&msg); + } - return 0; + return 0; } -int app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_T volume_ctrl, uint16_t volume_level) -{ - uint32_t audevt; - APP_MESSAGE_BLOCK msg; - osThreadId currThreadId; - - if(app_audio_manager_init == false) - return -1; - - msg.mod_id = APP_MODUAL_AUDIO_MANAGE; - APP_AUDIO_MANAGER_SET_MESSAGE(audevt, APP_BT_STREAM_MANAGER_CTRL_VOLUME, 0); - msg.msg_body.message_id = audevt; - msg.msg_body.message_ptr = (uint32_t)volume_ctrl; - msg.msg_body.message_Param0 = (uint32_t)volume_level; - msg.msg_body.message_Param1 = 0; - msg.msg_body.message_Param2 = 0; - currThreadId = osThreadGetId(); - if (currThreadId == af_thread_tid_get() || - currThreadId == app_os_tid_get()) - { - app_audio_manager_ctrl_volume_handle(&msg.msg_body); - } - else - { - app_mailbox_put(&msg); - } - return 0; -} - -int app_audio_manager_tune_samplerate_ratio(enum AUD_STREAM_T stream, float ratio) -{ - uint32_t audevt; - APP_MESSAGE_BLOCK msg; - osThreadId currThreadId; - - if(app_audio_manager_init == false) - return -1; - - msg.mod_id = APP_MODUAL_AUDIO_MANAGE; - APP_AUDIO_MANAGER_SET_MESSAGE(audevt, APP_BT_STREAM_MANAGER_TUNE_SAMPLERATE_RATIO, 0); - msg.msg_body.message_id = audevt; - msg.msg_body.message_ptr = (uint32_t)stream; - msg.msg_body.message_Param0 = *(uint32_t *)∶ - msg.msg_body.message_Param1 = 0; - msg.msg_body.message_Param2 = 0; - - currThreadId = osThreadGetId(); - if (currThreadId == af_thread_tid_get() || - currThreadId == app_os_tid_get()) - { - app_audio_manager_tune_samplerate_ratio_handle(&msg.msg_body); - } - else - { - app_mailbox_put(&msg); - } - - return 0; -} - - #if defined(VOICE_DATAPATH) && defined(MIX_MIC_DURING_MUSIC) -static bool app_audio_handle_pre_processing(APP_MESSAGE_BODY *msg_body) -{ - uint16_t stream_type; - APP_AUDIO_MANAGER_GET_STREAM_TYPE(msg_body->message_id, stream_type); +static bool app_audio_handle_pre_processing(APP_MESSAGE_BODY *msg_body) { + uint16_t stream_type; + APP_AUDIO_MANAGER_GET_STREAM_TYPE(msg_body->message_id, stream_type); - bool isToResetCaptureStream = false; - if ((BT_STREAM_SBC == stream_type) || (BT_STREAM_MEDIA == stream_type)) - { - if (app_audio_manager_capture_is_active()) - { - isToResetCaptureStream = true; - } + bool isToResetCaptureStream = false; + if ((BT_STREAM_SBC == stream_type) || (BT_STREAM_MEDIA == stream_type)) { + if (app_audio_manager_capture_is_active()) { + isToResetCaptureStream = true; } + } - if (isToResetCaptureStream) - { - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, - BT_STREAM_CAPTURE, 0, 0); + if (isToResetCaptureStream) { + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_CAPTURE, + 0, 0); - APP_MESSAGE_BLOCK msg; - msg.msg_body = *msg_body; - msg.mod_id = APP_MODUAL_AUDIO_MANAGE; + APP_MESSAGE_BLOCK msg; + msg.msg_body = *msg_body; + msg.mod_id = APP_MODUAL_AUDIO_MANAGE; - app_mailbox_put(&msg); - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, - BT_STREAM_CAPTURE, 0, 0); + app_mailbox_put(&msg); + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, + BT_STREAM_CAPTURE, 0, 0); - return false; - } - else - { - return true; - } + return false; + } else { + return true; + } } #endif -static int app_audio_manager_handle_process(APP_MESSAGE_BODY *msg_body) -{ - int nRet = 0; +static int app_audio_manager_handle_process(APP_MESSAGE_BODY *msg_body) { + int nRet = 0; - APP_AUDIO_MANAGER_MSG_STRUCT aud_manager_msg; - APP_AUDIO_MANAGER_CALLBACK_T callback_fn = NULL; - uint32_t callback_param = 0; + APP_AUDIO_MANAGER_MSG_STRUCT aud_manager_msg; + APP_AUDIO_MANAGER_CALLBACK_T callback_fn = NULL; + uint32_t callback_param = 0; - if(app_audio_manager_init == false) - return -1; + if (app_audio_manager_init == false) + return -1; #if defined(VOICE_DATAPATH) && defined(MIX_MIC_DURING_MUSIC) - bool isContinue = app_audio_handle_pre_processing(msg_body); - if (!isContinue) - { - return -1; - } + bool isContinue = app_audio_handle_pre_processing(msg_body); + if (!isContinue) { + return -1; + } #endif - APP_AUDIO_MANAGER_GET_ID(msg_body->message_id, aud_manager_msg.id); - APP_AUDIO_MANAGER_GET_STREAM_TYPE(msg_body->message_id, aud_manager_msg.stream_type); - APP_AUDIO_MANAGER_GET_DEVICE_ID(msg_body->message_Param0, aud_manager_msg.device_id); - APP_AUDIO_MANAGER_GET_AUD_ID(msg_body->message_Param0, aud_manager_msg.aud_id); - APP_AUDIO_MANAGER_GET_CALLBACK((uintptr_t)msg_body->message_Param1, callback_fn); - APP_AUDIO_MANAGER_GET_CALLBACK_PARAM(msg_body->message_Param2, callback_param); + APP_AUDIO_MANAGER_GET_ID(msg_body->message_id, aud_manager_msg.id); + APP_AUDIO_MANAGER_GET_STREAM_TYPE(msg_body->message_id, + aud_manager_msg.stream_type); + APP_AUDIO_MANAGER_GET_DEVICE_ID(msg_body->message_Param0, + aud_manager_msg.device_id); + APP_AUDIO_MANAGER_GET_AUD_ID(msg_body->message_Param0, + aud_manager_msg.aud_id); + APP_AUDIO_MANAGER_GET_CALLBACK((uintptr_t)msg_body->message_Param1, + callback_fn); + APP_AUDIO_MANAGER_GET_CALLBACK_PARAM(msg_body->message_Param2, + callback_param); - TRACE_AUD_MGR_I( - "[handle_process] id %d %s type 0x%x %s", - aud_manager_msg.id, - handleId2str(aud_manager_msg.id), - aud_manager_msg.stream_type, - strmtype2str(aud_manager_msg.stream_type)); + TRACE_AUD_MGR_I("[handle_process] id %d %s type 0x%x %s", aud_manager_msg.id, + handleId2str(aud_manager_msg.id), aud_manager_msg.stream_type, + strmtype2str(aud_manager_msg.stream_type)); - switch (aud_manager_msg.id) - { - case APP_BT_STREAM_MANAGER_START: - bt_media_start(aud_manager_msg.stream_type,(enum BT_DEVICE_ID_T) aud_manager_msg.device_id, aud_manager_msg.aud_id); - break; - case APP_BT_STREAM_MANAGER_STOP: - bt_media_stop(aud_manager_msg.stream_type, (enum BT_DEVICE_ID_T)aud_manager_msg.device_id); - break; - case APP_BT_STREAM_MANAGER_SWITCHTO_SCO: - bt_media_switch_to_voice(aud_manager_msg.stream_type, (enum BT_DEVICE_ID_T)aud_manager_msg.device_id); - break; - case APP_BT_STREAM_MANAGER_STOP_MEDIA: - app_media_stop_media(aud_manager_msg.stream_type, (enum BT_DEVICE_ID_T)aud_manager_msg.device_id); - break; - case APP_BT_STREAM_MANAGER_UPDATE_MEDIA: - app_media_update_media(aud_manager_msg.stream_type, (enum BT_DEVICE_ID_T)aud_manager_msg.device_id); - break; - case APP_BT_STREAM_MANAGER_SWAP_SCO: - app_audio_manager_swap_sco((enum BT_DEVICE_ID_T)aud_manager_msg.device_id); - break; - case APP_BT_STREAM_MANAGER_CTRL_VOLUME: - app_audio_manager_ctrl_volume_handle(msg_body); - break; - case APP_BT_STREAM_MANAGER_TUNE_SAMPLERATE_RATIO: - app_audio_manager_tune_samplerate_ratio_handle(msg_body); - break; - default: - break; - } - if (callback_fn) - { - callback_fn(aud_manager_msg.id, callback_param); - } - return nRet; + switch (aud_manager_msg.id) { + case APP_BT_STREAM_MANAGER_START: + bt_media_start(aud_manager_msg.stream_type, + (enum BT_DEVICE_ID_T)aud_manager_msg.device_id, + aud_manager_msg.aud_id); + break; + case APP_BT_STREAM_MANAGER_STOP: + bt_media_stop(aud_manager_msg.stream_type, + (enum BT_DEVICE_ID_T)aud_manager_msg.device_id); + break; + case APP_BT_STREAM_MANAGER_SWITCHTO_SCO: + bt_media_switch_to_voice(aud_manager_msg.stream_type, + (enum BT_DEVICE_ID_T)aud_manager_msg.device_id); + break; + case APP_BT_STREAM_MANAGER_STOP_MEDIA: + app_media_stop_media(aud_manager_msg.stream_type, + (enum BT_DEVICE_ID_T)aud_manager_msg.device_id); + break; + case APP_BT_STREAM_MANAGER_UPDATE_MEDIA: + app_media_update_media(aud_manager_msg.stream_type, + (enum BT_DEVICE_ID_T)aud_manager_msg.device_id); + break; + case APP_BT_STREAM_MANAGER_SWAP_SCO: + app_audio_manager_swap_sco((enum BT_DEVICE_ID_T)aud_manager_msg.device_id); + break; + case APP_BT_STREAM_MANAGER_CTRL_VOLUME: + app_audio_manager_ctrl_volume_handle(msg_body); + break; + case APP_BT_STREAM_MANAGER_TUNE_SAMPLERATE_RATIO: + app_audio_manager_tune_samplerate_ratio_handle(msg_body); + break; + default: + break; + } + if (callback_fn) { + callback_fn(aud_manager_msg.id, callback_param); + } + return nRet; } -void bt_media_volume_ptr_update_by_mediatype(uint16_t stream_type) -{ - bt_bdaddr_t *bdAdd =NULL; - bt_bdaddr_t temp; - btif_remote_device_t *remDev = NULL; - uint8_t id; +void bt_media_volume_ptr_update_by_mediatype(uint16_t stream_type) { + bt_bdaddr_t *bdAdd = NULL; + bt_bdaddr_t temp; + btif_remote_device_t *remDev = NULL; + uint8_t id; - TRACE_AUD_MGR_I("[VOLUME_PTR] enter"); - if (stream_type & bt_media_get_current_media()) - { - switch (stream_type) - { - case BT_STREAM_SBC: - id = bt_meida.media_curr_sbc; - ASSERT(idaddress); - } - break; - case BT_STREAM_VOICE: - id = app_audio_manager_get_active_sco_num(); - ASSERT(idaddress); - } - break; - case BT_STREAM_MEDIA: - default: - break; - } + TRACE_AUD_MGR_I("[VOLUME_PTR] enter"); + if (stream_type & bt_media_get_current_media()) { + switch (stream_type) { + case BT_STREAM_SBC: + id = bt_meida.media_curr_sbc; + ASSERT(id < BT_DEVICE_NUM, "INVALID_BT_DEVICE_NUM"); + remDev = + btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[id]); + if (remDev) { + bdAdd = btif_me_get_remote_device_bdaddr(remDev); + app_bt_stream_volume_ptr_update(bdAdd->address); + } + break; + case BT_STREAM_VOICE: + id = app_audio_manager_get_active_sco_num(); + ASSERT(id < BT_DEVICE_NUM, "INVALID_BT_DEVICE_NUM"); + // if (HF_GetRemoteBDAddr(&app_bt_device.hf_channel[id], &bdAdd)){ + bdAdd = &temp; + if (btif_hf_get_remote_bdaddr(app_bt_device.hf_channel[id], bdAdd)) { + app_bt_stream_volume_ptr_update(bdAdd->address); + } + break; + case BT_STREAM_MEDIA: + default: + break; } - TRACE_AUD_MGR_I("[VOLUME_PTR] exit"); + } + TRACE_AUD_MGR_I("[VOLUME_PTR] exit"); } -int app_audio_manager_set_active_sco_num(enum BT_DEVICE_ID_T id) -{ - bt_meida.media_curr_sco = id; - return 0; +int app_audio_manager_set_active_sco_num(enum BT_DEVICE_ID_T id) { + bt_meida.media_curr_sco = id; + return 0; } -int app_audio_manager_get_active_sco_num(void) -{ - return bt_meida.media_curr_sco; +int app_audio_manager_get_active_sco_num(void) { + return bt_meida.media_curr_sco; } -hf_chan_handle_t* app_audio_manager_get_active_sco_chnl(void) -{ - int curr_sco; +hf_chan_handle_t *app_audio_manager_get_active_sco_chnl(void) { + int curr_sco; - curr_sco = app_audio_manager_get_active_sco_num(); - if (curr_sco != BT_DEVICE_NUM) - { - return &app_bt_device.hf_channel[curr_sco]; - } - return NULL; + curr_sco = app_audio_manager_get_active_sco_num(); + if (curr_sco != BT_DEVICE_NUM) { + return &app_bt_device.hf_channel[curr_sco]; + } + return NULL; } #if defined(HFP_1_6_ENABLE) #ifdef __BT_ONE_BRING_TWO__ -static uint16_t app_audio_manage_scocodecid[BT_DEVICE_NUM] = {BTIF_HF_SCO_CODEC_CVSD, BTIF_HF_SCO_CODEC_CVSD}; +static uint16_t app_audio_manage_scocodecid[BT_DEVICE_NUM] = { + BTIF_HF_SCO_CODEC_CVSD, BTIF_HF_SCO_CODEC_CVSD}; #else -static uint16_t app_audio_manage_scocodecid[BT_DEVICE_NUM] = {BTIF_HF_SCO_CODEC_CVSD}; +static uint16_t app_audio_manage_scocodecid[BT_DEVICE_NUM] = { + BTIF_HF_SCO_CODEC_CVSD}; #endif -int app_audio_manager_set_scocodecid(enum BT_DEVICE_ID_T dev_id, uint16_t codec_id) -{ - app_audio_manage_scocodecid[dev_id] = codec_id; - return 0; +int app_audio_manager_set_scocodecid(enum BT_DEVICE_ID_T dev_id, + uint16_t codec_id) { + app_audio_manage_scocodecid[dev_id] = codec_id; + return 0; } -int app_audio_manager_get_scocodecid(void) -{ - int scocodecid = BTIF_HF_SCO_CODEC_NONE; - if (bt_meida.media_curr_sco != BT_DEVICE_NUM) - { - scocodecid = app_audio_manage_scocodecid[bt_meida.media_curr_sco]; - } - return scocodecid; +int app_audio_manager_get_scocodecid(void) { + int scocodecid = BTIF_HF_SCO_CODEC_NONE; + if (bt_meida.media_curr_sco != BT_DEVICE_NUM) { + scocodecid = app_audio_manage_scocodecid[bt_meida.media_curr_sco]; + } + return scocodecid; } #endif - -int app_audio_manager_switch_a2dp(enum BT_DEVICE_ID_T id) -{ - bt_bdaddr_t* bdAdd =NULL; - btif_remote_device_t *remDev = NULL; +int app_audio_manager_switch_a2dp(enum BT_DEVICE_ID_T id) { + bt_bdaddr_t *bdAdd = NULL; + btif_remote_device_t *remDev = NULL; #ifndef __MULTIPOINT_A2DP_PREEMPT__ - if(bt_meida.media_curr_sbc == id) - { - TRACE_AUD_MGR_I("[A2DP_SWITCH]the disconnected dev not working"); - return 0; - } -#endif - - remDev = btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[id]); - if (remDev) - { - TRACE_AUD_MGR_I("[A2DP_SWITCH] switch_a2dp to id:%d", id); - bdAdd = btif_me_get_remote_device_bdaddr(remDev); - app_bt_stream_volume_ptr_update(bdAdd->address); - bt_meida.media_curr_sbc = id; - } + if (bt_meida.media_curr_sbc == id) { + TRACE_AUD_MGR_I("[A2DP_SWITCH]the disconnected dev not working"); return 0; + } +#endif + + remDev = btif_a2dp_get_remote_device(app_bt_device.a2dp_connected_stream[id]); + if (remDev) { + TRACE_AUD_MGR_I("[A2DP_SWITCH] switch_a2dp to id:%d", id); + bdAdd = btif_me_get_remote_device_bdaddr(remDev); + app_bt_stream_volume_ptr_update(bdAdd->address); + bt_meida.media_curr_sbc = id; + } + return 0; } -bool app_audio_manager_a2dp_is_active(enum BT_DEVICE_ID_T id) -{ - uint16_t media_type; - bool nRet = false; +bool app_audio_manager_a2dp_is_active(enum BT_DEVICE_ID_T id) { + uint16_t media_type; + bool nRet = false; - media_type = bt_media_get_current_media(); - if (media_type & BT_STREAM_SBC) - { - if (bt_meida.media_curr_sbc == id) - { - nRet = true; - } + media_type = bt_media_get_current_media(); + if (media_type & BT_STREAM_SBC) { + if (bt_meida.media_curr_sbc == id) { + nRet = true; } + } #ifndef BES_AUTOMATE_TEST - TRACE_AUD_MGR_I("[A2DP_ACTIVE] nRet:%d type:%d %d/%d", nRet, media_type, id, bt_meida.media_curr_sbc); + TRACE_AUD_MGR_I("[A2DP_ACTIVE] nRet:%d type:%d %d/%d", nRet, media_type, id, + bt_meida.media_curr_sbc); #endif - return nRet; + return nRet; } -bool app_audio_manager_hfp_is_active(enum BT_DEVICE_ID_T id) -{ - uint16_t media_type; - bool nRet = false; +bool app_audio_manager_hfp_is_active(enum BT_DEVICE_ID_T id) { + uint16_t media_type; + bool nRet = false; - media_type = bt_media_get_current_media(); - if (media_type & BT_STREAM_VOICE) - { - if (bt_meida.media_curr_sco == id) - { - nRet = true; - } + media_type = bt_media_get_current_media(); + if (media_type & BT_STREAM_VOICE) { + if (bt_meida.media_curr_sco == id) { + nRet = true; } + } #ifndef BES_AUTOMATE_TEST - TRACE_AUD_MGR_I("[SCO_ACTIVE] nRet:%d type:%d %d/%d", nRet, media_type, id, bt_meida.media_curr_sco); + TRACE_AUD_MGR_I("[SCO_ACTIVE] nRet:%d type:%d %d/%d", nRet, media_type, id, + bt_meida.media_curr_sco); #endif - return nRet; + return nRet; } #ifdef VOICE_DATAPATH -bool app_audio_manager_capture_is_active(void) -{ - uint16_t media_type; - bool nRet = false; +bool app_audio_manager_capture_is_active(void) { + uint16_t media_type; + bool nRet = false; - media_type = bt_media_get_current_media(); - if (media_type & BT_STREAM_CAPTURE) - { - nRet = true; - } + media_type = bt_media_get_current_media(); + if (media_type & BT_STREAM_CAPTURE) { + nRet = true; + } - return nRet; + return nRet; } #endif -bool app_audio_manager_media_is_active(void) -{ - uint16_t media_type; - bool nRet = false; +bool app_audio_manager_media_is_active(void) { + uint16_t media_type; + bool nRet = false; - media_type = bt_media_get_current_media(); - if (media_type & BT_STREAM_MEDIA) - { - nRet = true; - } + media_type = bt_media_get_current_media(); + if (media_type & BT_STREAM_MEDIA) { + nRet = true; + } - return nRet; + return nRet; } -void app_audio_manager_open(void) -{ - if(app_audio_manager_init) - { - return; - } - bt_meida.media_curr_sbc = BT_DEVICE_NUM; - bt_meida.media_curr_sco = BT_DEVICE_NUM; - bt_meida.curr_active_media = 0; - app_set_threadhandle(APP_MODUAL_AUDIO_MANAGE, app_audio_manager_handle_process); - app_audio_manager_init = true; +void app_audio_manager_open(void) { + if (app_audio_manager_init) { + return; + } + bt_meida.media_curr_sbc = BT_DEVICE_NUM; + bt_meida.media_curr_sco = BT_DEVICE_NUM; + bt_meida.curr_active_media = 0; + app_set_threadhandle(APP_MODUAL_AUDIO_MANAGE, + app_audio_manager_handle_process); + app_audio_manager_init = true; #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - audio_prompt_init_handler(); + audio_prompt_init_handler(); #endif } -void app_audio_manager_close(void) -{ - app_set_threadhandle(APP_MODUAL_AUDIO_MANAGE, NULL); - app_audio_manager_init = false; +void app_audio_manager_close(void) { + app_set_threadhandle(APP_MODUAL_AUDIO_MANAGE, NULL); + app_audio_manager_init = false; } #ifdef RB_CODEC @@ -2358,77 +2234,63 @@ static bool app_rbcodec_play_status = false; static bool app_rbplay_player_mode = false; -bool app_rbplay_is_localplayer_mode(void) -{ - return app_rbplay_player_mode; +bool app_rbplay_is_localplayer_mode(void) { return app_rbplay_player_mode; } + +bool app_rbplay_mode_switch(void) { + return (app_rbplay_player_mode = !app_rbplay_player_mode); } -bool app_rbplay_mode_switch(void) -{ - return (app_rbplay_player_mode = !app_rbplay_player_mode); +void app_rbplay_set_player_mode(bool isInPlayerMode) { + app_rbplay_player_mode = isInPlayerMode; } -void app_rbplay_set_player_mode(bool isInPlayerMode) -{ - app_rbplay_player_mode = isInPlayerMode; +void app_rbcodec_ctr_play_onoff(bool on) { + TRACE_AUD_MGR_I("[RBCODEC] onoff %d ,turnon:%d ", app_rbcodec_play_status, + on); + + if (app_rbcodec_play_status == on) + return; + app_rbcodec_play_status = on; + if (on) + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, + BT_STREAM_RBCODEC, 0, 0); + else + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_RBCODEC, + 0, 0); } -void app_rbcodec_ctr_play_onoff(bool on ) -{ - TRACE_AUD_MGR_I("[RBCODEC] onoff %d ,turnon:%d ", app_rbcodec_play_status,on); - - if(app_rbcodec_play_status == on) - return; - app_rbcodec_play_status = on; - if(on) - app_audio_manager_sendrequest( APP_BT_STREAM_MANAGER_START, BT_STREAM_RBCODEC, 0, 0); - else - app_audio_manager_sendrequest( APP_BT_STREAM_MANAGER_STOP, BT_STREAM_RBCODEC, 0, 0); +void app_rbcodec_ctl_set_play_status(bool st) { + app_rbcodec_play_status = st; + TRACE_AUD_MGR_I("[RBCODEC] curr_status%d", app_rbcodec_play_status); } -void app_rbcodec_ctl_set_play_status(bool st) -{ - app_rbcodec_play_status = st; - TRACE_AUD_MGR_I("[RBCODEC] curr_status%d", app_rbcodec_play_status); +bool app_rbcodec_get_play_status(void) { + TRACE_AUD_MGR_I("[RBCODEC] play_status:%d", app_rbcodec_play_status); + return app_rbcodec_play_status; } -bool app_rbcodec_get_play_status(void) -{ - TRACE_AUD_MGR_I("[RBCODEC] play_status:%d", app_rbcodec_play_status); - return app_rbcodec_play_status; +void app_rbcodec_toggle_play_stop(void) { + if (app_rbcodec_get_play_status()) { + app_rbcodec_ctr_play_onoff(false); + } else { + app_rbcodec_ctr_play_onoff(true); + } } -void app_rbcodec_toggle_play_stop(void) -{ - if(app_rbcodec_get_play_status()) - { - app_rbcodec_ctr_play_onoff(false); - } - else - { - app_rbcodec_ctr_play_onoff(true); - } -} - -bool app_rbcodec_check_hfp_active(void ) -{ - return (bool)bt_media_is_media_active_by_type(BT_STREAM_VOICE); +bool app_rbcodec_check_hfp_active(void) { + return (bool)bt_media_is_media_active_by_type(BT_STREAM_VOICE); } #endif -void app_ibrt_sync_mix_prompt_req_handler(uint8_t* ptrParam, uint16_t paramLen) -{ +void app_ibrt_sync_mix_prompt_req_handler(uint8_t *ptrParam, + uint16_t paramLen) { #ifdef TWS_PROMPT_SYNC - app_tws_cmd_sync_mix_prompt_req_handler(ptrParam, paramLen); + app_tws_cmd_sync_mix_prompt_req_handler(ptrParam, paramLen); #endif } -void app_audio_decode_err_force_trigger(void) -{ +void app_audio_decode_err_force_trigger(void) { #ifndef IBRT - trigger_media_play((AUD_ID_ENUM)AUDIO_ID_BT_MUTE, 0, false); + trigger_media_play((AUD_ID_ENUM)AUDIO_ID_BT_MUTE, 0, false); #endif } - - - diff --git a/services/bt_app/app_bt_stream.cpp b/services/bt_app/app_bt_stream.cpp index 3620689..e30a4ca 100644 --- a/services/bt_app/app_bt_stream.cpp +++ b/services/bt_app/app_bt_stream.cpp @@ -14,39 +14,39 @@ * ****************************************************************************/ //#include "mbed.h" -#include #include +#include -#include "cmsis_os.h" +#include "analog.h" +#include "app_audio.h" +#include "app_bt_stream.h" #include "app_bt_trace.h" -#include "tgt_hardware.h" -#include "hal_uart.h" -#include "hal_timer.h" +#include "app_overlay.h" +#include "app_utils.h" #include "audioflinger.h" -#include "lockcqueue.h" +#include "avdtp_i.h" +#include "cmsis_os.h" #include "hal_cmu.h" #include "hal_overlay.h" -#include "analog.h" -#include "avdtp_i.h" -#include "app_bt_stream.h" -#include "app_overlay.h" -#include "app_audio.h" -#include "app_utils.h" +#include "hal_timer.h" +#include "hal_uart.h" +#include "lockcqueue.h" +#include "tgt_hardware.h" #ifdef ANC_APP #include "app_anc.h" #endif #include "anc_wnr.h" #include "bluetooth.h" -#include "nvrecord.h" -#include "nvrecord_env.h" -#include "nvrecord_dev.h" -#include "resample_coef.h" +#include "hal_bootmode.h" #include "hal_codec.h" #include "hal_i2s.h" -#include "hal_bootmode.h" +#include "nvrecord.h" +#include "nvrecord_dev.h" +#include "nvrecord_env.h" +#include "resample_coef.h" #ifdef MEDIA_PLAYER_SUPPORT -#include "resources.h" #include "app_media_player.h" +#include "resources.h" #endif #ifdef __FACTORY_MODE_SUPPORT__ #include "app_factory_audio.h" @@ -55,7 +55,7 @@ #include "hal_chipid.h" #endif -#ifdef __IAG_BLE_INCLUDE__ +#ifdef __IAG_BLE_INCLUDE__ #include "app_ble_mode_switch.h" #endif @@ -63,30 +63,30 @@ #include "app_voicepath.h" #endif -#if defined(__AI_VOICE__)||defined(BISTO_ENABLED) -#include "app_ai_voice.h" +#if defined(__AI_VOICE__) || defined(BISTO_ENABLED) #include "app_ai_if.h" +#include "app_ai_voice.h" #endif #ifdef AI_AEC_CP_ACCEL #include "app_ai_algorithm.h" #endif -#include "app_ring_merge.h" -#include "bt_drv.h" -#include "bt_xtal_sync.h" -#include "bt_drv_reg_op.h" -#include "besbt.h" -#include "hal_chipid.h" -#include "cqueue.h" -#include "btapp.h" -#include "app_hfp.h" -#include "app_bt.h" -#include "os_api.h" -#include "audio_process.h" #include "app_a2dp.h" +#include "app_bt.h" +#include "app_hfp.h" +#include "app_ring_merge.h" #include "audio_dump.h" +#include "audio_process.h" +#include "besbt.h" +#include "bt_drv.h" +#include "bt_drv_reg_op.h" +#include "bt_xtal_sync.h" +#include "btapp.h" +#include "cqueue.h" +#include "hal_chipid.h" #include "math.h" +#include "os_api.h" #ifdef WL_DET #include "app_mic_alg.h" @@ -100,8 +100,8 @@ #endif #if defined(BONE_SENSOR_TDM) -#include "speech_utils.h" #include "lis25ba.h" +#include "speech_utils.h" #include "tdm_stream.h" #endif @@ -111,12 +111,12 @@ #endif #if defined(IBRT) +#include "app_ibrt_a2dp.h" #include "app_ibrt_if.h" +#include "app_ibrt_rssi.h" #include "app_tws_ctrl_thread.h" #include "app_tws_ibrt_audio_analysis.h" #include "app_tws_ibrt_audio_sync.h" -#include "app_ibrt_a2dp.h" -#include "app_ibrt_rssi.h" #undef MUSIC_DELAY_CONTROL #endif @@ -125,95 +125,101 @@ #include "fftfilt2.h" #endif - // NOTE: Modify parameters for your project. // #define A2DP_STREAM_AUDIO_DUMP #if defined(__SW_IIR_EQ_PROCESS__) static uint8_t audio_eq_sw_iir_index = 0; -extern const IIR_CFG_T * const audio_eq_sw_iir_cfg_list[]; +extern const IIR_CFG_T *const audio_eq_sw_iir_cfg_list[]; #endif #if defined(__HW_FIR_EQ_PROCESS__) static uint8_t audio_eq_hw_fir_index = 0; -extern const FIR_CFG_T * const audio_eq_hw_fir_cfg_list[]; +extern const FIR_CFG_T *const audio_eq_hw_fir_cfg_list[]; #endif #if defined(__HW_DAC_IIR_EQ_PROCESS__) static uint8_t audio_eq_hw_dac_iir_index = 0; -extern const IIR_CFG_T * const audio_eq_hw_dac_iir_cfg_list[]; +extern const IIR_CFG_T *const audio_eq_hw_dac_iir_cfg_list[]; #endif #include "audio_prompt_sbc.h" #if defined(__HW_IIR_EQ_PROCESS__) static uint8_t audio_eq_hw_iir_index = 0; -extern const IIR_CFG_T * const audio_eq_hw_iir_cfg_list[]; +extern const IIR_CFG_T *const audio_eq_hw_iir_cfg_list[]; #endif #if defined(HW_DC_FILTER_WITH_IIR) -#include "hw_filter_codec_iir.h" #include "hw_codec_iir_process.h" +#include "hw_filter_codec_iir.h" -hw_filter_codec_iir_cfg POSSIBLY_UNUSED adc_iir_cfg = { - .bypass = 0, - .iir_device = HW_CODEC_IIR_ADC, +hw_filter_codec_iir_cfg + POSSIBLY_UNUSED + adc_iir_cfg = {.bypass = 0, + .iir_device = HW_CODEC_IIR_ADC, #if 1 - .iir_cfg = { - .iir_filtes_l = { - .iir_bypass_flag = 0, - .iir_counter = 2, - .iir_coef = { - {{0.994406, -1.988812, 0.994406}, {1.000000, -1.988781, 0.988843}}, // iir_designer('highpass', 0, 20, 0.7, 16000); - {{4.0, 0.0, 0.0}, {1.0, 0.0, 0.0}}, - } - }, - .iir_filtes_r = { - .iir_bypass_flag = 0, - .iir_counter = 2, - .iir_coef = { - {{0.994406, -1.988812, 0.994406}, {1.000000, -1.988781, 0.988843}}, - {{4.0, 0.0, 0.0}, {1.0, 0.0, 0.0}}, - } - } - } + .iir_cfg = + {.iir_filtes_l = {.iir_bypass_flag = 0, + .iir_counter = 2, + .iir_coef = + { + {{0.994406, -1.988812, + 0.994406}, + {1.000000, + -1.988781, 0.988843}}, // iir_designer('highpass', + // 0, 20, 0.7, + // 16000); + {{4.0, 0.0, 0.0}, {1.0, 0.0, 0.0}}, + }}, + .iir_filtes_r = + { + .iir_bypass_flag = 0, + .iir_counter = 2, + .iir_coef = + { + {{0.994406, -1.988812, 0.994406}, + {1.000000, -1.988781, 0.988843}}, + {{4.0, 0.0, 0.0}, {1.0, 0.0, 0.0}}, + }}} #else - .iir_cfg = { - .gain0 = 0, - .gain1 = 0, - .num = 1, - .param = { - {IIR_TYPE_HIGH_PASS, 0, 20.0, 0.7}, - } - } + .iir_cfg = {.gain0 = 0, + .gain1 = 0, + .num = 1, + .param = + { + {IIR_TYPE_HIGH_PASS, 0, 20.0, 0.7}, + }} #endif }; hw_filter_codec_iir_state *hw_filter_codec_iir_st; #endif -#if defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST3003)|| \ - defined(CHIP_BEST1400) || defined(CHIP_BEST1402) || defined(CHIP_BEST1000) || \ - defined(CHIP_BEST2000) || defined(CHIP_BEST3001) || defined(CHIP_BEST2001) \ +#if defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || \ + defined(CHIP_BEST3003) || defined(CHIP_BEST1400) || \ + defined(CHIP_BEST1402) || defined(CHIP_BEST1000) || \ + defined(CHIP_BEST2000) || defined(CHIP_BEST3001) || defined(CHIP_BEST2001) #undef AUDIO_RESAMPLE_ANTI_DITHER #else -#define AUDIO_RESAMPLE_ANTI_DITHER +#define AUDIO_RESAMPLE_ANTI_DITHER #endif #include "audio_cfg.h" //#define SCO_DMA_SNAPSHOT_DEBUG -extern uint8_t bt_audio_get_eq_index(AUDIO_EQ_TYPE_T audio_eq_type,uint8_t anc_status); -extern uint32_t bt_audio_set_eq(AUDIO_EQ_TYPE_T audio_eq_type,uint8_t index); +extern uint8_t bt_audio_get_eq_index(AUDIO_EQ_TYPE_T audio_eq_type, + uint8_t anc_status); +extern uint32_t bt_audio_set_eq(AUDIO_EQ_TYPE_T audio_eq_type, uint8_t index); extern uint8_t bt_audio_updata_eq_for_anc(uint8_t anc_status); #include "app_bt_media_manager.h" -#include "string.h" #include "hal_location.h" +#include "string.h" #include "bt_drv_interface.h" @@ -225,21 +231,22 @@ extern uint8_t bt_audio_updata_eq_for_anc(uint8_t anc_status); #define BT_INIT_XTAL_SYNC_FCAP_RANGE (0xFF) #endif #define BT_INIT_XTAL_SYNC_MIN (20) -#define BT_INIT_XTAL_SYNC_MAX (BT_INIT_XTAL_SYNC_FCAP_RANGE - BT_INIT_XTAL_SYNC_MIN) +#define BT_INIT_XTAL_SYNC_MAX \ + (BT_INIT_XTAL_SYNC_FCAP_RANGE - BT_INIT_XTAL_SYNC_MIN) #ifdef __THIRDPARTY #include "app_thirdparty.h" #endif #if defined(AUDIO_ANC_FB_MC) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) -#include"anc_process.h" +#include "anc_process.h" #ifdef ANC_FB_MC_96KHZ -#define DELAY_SAMPLE_MC (29*2) // 2:ch -#define SAMPLERATE_RATIO_THRESHOLD (4) //384 = 96*4 +#define DELAY_SAMPLE_MC (29 * 2) // 2:ch +#define SAMPLERATE_RATIO_THRESHOLD (4) // 384 = 96*4 #else -#define DELAY_SAMPLE_MC (31*2) // 2:ch -#define SAMPLERATE_RATIO_THRESHOLD (8) //384 = 48*8 +#define DELAY_SAMPLE_MC (31 * 2) // 2:ch +#define SAMPLERATE_RATIO_THRESHOLD (8) // 384 = 48*8 #endif static int32_t delay_buf_bt[DELAY_SAMPLE_MC]; @@ -258,16 +265,19 @@ static uint8_t anc_status_record = 0xff; #else #define MASTER_MOBILE_BTCLK_OFFSET (4) #endif -#define MASTER_MOBILE_BTCNT_OFFSET (MASTER_MOBILE_BTCLK_OFFSET*625) +#define MASTER_MOBILE_BTCNT_OFFSET (MASTER_MOBILE_BTCLK_OFFSET * 625) -#if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) || defined(CHIP_BEST2001) +#if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) || \ + defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) || \ + defined(CHIP_BEST2001) #define MUTE_PATTERN (0x55) #else #define MUTE_PATTERN (0x00) #endif -extern void app_tws_ibrt_audio_mobile_clkcnt_get(uint32_t btclk, uint16_t btcnt, - uint32_t *mobile_master_clk, uint16_t *mobile_master_cnt); +extern void app_tws_ibrt_audio_mobile_clkcnt_get(uint32_t btclk, uint16_t btcnt, + uint32_t *mobile_master_clk, + uint16_t *mobile_master_cnt); static uint8_t *playback_buf_codecpcm; static uint32_t playback_size_codecpcm; @@ -280,26 +290,25 @@ static uint8_t *capture_buf_btpcm; static uint32_t capture_size_btpcm; #ifdef TX_RX_PCM_MASK -static uint8_t *playback_buf_btpcm_copy=NULL; -static uint32_t playback_size_btpcm_copy=0; -static uint8_t *capture_buf_btpcm_copy=NULL; -static uint32_t capture_size_btpcm_copy=0; +static uint8_t *playback_buf_btpcm_copy = NULL; +static uint32_t playback_size_btpcm_copy = 0; +static uint8_t *capture_buf_btpcm_copy = NULL; +static uint32_t capture_size_btpcm_copy = 0; #endif -volatile int sco_btpcm_mute_flag=0; -volatile int sco_disconnect_mute_flag=0; +volatile int sco_btpcm_mute_flag = 0; +volatile int sco_disconnect_mute_flag = 0; -static uint8_t *playback_buf_btpcm_cache=NULL; +static uint8_t *playback_buf_btpcm_cache = NULL; static enum AUD_SAMPRATE_T playback_samplerate_codecpcm; static int32_t mobile_master_clk_offset_init; #endif -enum PLAYER_OPER_T -{ - PLAYER_OPER_START, - PLAYER_OPER_STOP, - PLAYER_OPER_RESTART, +enum PLAYER_OPER_T { + PLAYER_OPER_START, + PLAYER_OPER_STOP, + PLAYER_OPER_RESTART, }; #if defined(AF_ADC_I2S_SYNC) @@ -325,7 +334,9 @@ struct btdevice_volume current_btdevice_volume; uint8_t bt_sco_samplerate_ratio = 0; static uint8_t *bt_anc_sco_dec_buf; extern void us_fir_init(void); -extern uint32_t voicebtpcm_pcm_resample (short* src_samp_buf, uint32_t src_smpl_cnt, short* dst_samp_buf); +extern uint32_t voicebtpcm_pcm_resample(short *src_samp_buf, + uint32_t src_smpl_cnt, + short *dst_samp_buf); #endif #if defined(AUDIO_ANC_FB_MC) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) @@ -339,50 +350,55 @@ static int32_t playback_samplerate_ratio_bt; static uint8_t *playback_buf_mc; static uint32_t playback_size_mc; -static enum AUD_CHANNEL_NUM_T playback_ch_num_bt; +static enum AUD_CHANNEL_NUM_T playback_ch_num_bt; #ifdef AUDIO_ANC_FB_ADJ_MC uint32_t adj_mc_capture_sample_rate; #endif #endif -#if defined(MUSIC_DELAY_CONTROL) && (defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A)|| defined(CHIP_BEST1400)|| defined(CHIP_BEST1402)) +#if defined(MUSIC_DELAY_CONTROL) && \ + (defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || \ + defined(CHIP_BEST2300A) || defined(CHIP_BEST1400) || \ + defined(CHIP_BEST1402)) static enum AUD_BITS_T lowdelay_sample_size_play_bt; static enum AUD_SAMPRATE_T lowdelay_sample_rate_play_bt; static uint32_t lowdelay_data_size_play_bt; -static enum AUD_CHANNEL_NUM_T lowdelay_playback_ch_num_bt; +static enum AUD_CHANNEL_NUM_T lowdelay_playback_ch_num_bt; #endif extern uint8_t current_a2dp_non_type; +extern void bt_media_clear_media_type(uint16_t media_type, + enum BT_DEVICE_ID_T device_id); -extern void bt_media_clear_media_type(uint16_t media_type,enum BT_DEVICE_ID_T device_id); - -extern "C" uint8_t is_sbc_mode (void); +extern "C" uint8_t is_sbc_mode(void); uint8_t bt_sbc_mode; -extern "C" uint8_t __attribute__((section(".fast_text_sram"))) is_sbc_mode(void) -{ - return bt_sbc_mode; +extern "C" uint8_t __attribute__((section(".fast_text_sram"))) +is_sbc_mode(void) { + return bt_sbc_mode; } -extern "C" uint8_t is_sco_mode (void); +extern "C" uint8_t is_sco_mode(void); uint8_t bt_sco_mode; -extern "C" uint8_t __attribute__((section(".fast_text_sram"))) is_sco_mode(void) -{ - return bt_sco_mode; +extern "C" uint8_t __attribute__((section(".fast_text_sram"))) +is_sco_mode(void) { + return bt_sco_mode; } #define APP_BT_STREAM_TRIGGER_TIMEROUT (2000) -#define TRIGGER_CHECKER_A2DP_PLAYERBLACK (1<<0) -#define TRIGGER_CHECKER_A2DP_DONE (TRIGGER_CHECKER_A2DP_PLAYERBLACK) - -#define TRIGGER_CHECKER_HFP_BTPCM_PLAYERBLACK (1<<1) -#define TRIGGER_CHECKER_HFP_BTPCM_CAPTURE (1<<2) -#define TRIGGER_CHECKER_HFP_AUDPCM_PLAYERBLACK (1<<3) -#define TRIGGER_CHECKER_HFP_AUDPCM_CAPTURE (1<<4) -#define TRIGGER_CHECKER_HFP_DONE (TRIGGER_CHECKER_HFP_BTPCM_PLAYERBLACK|TRIGGER_CHECKER_HFP_BTPCM_CAPTURE|TRIGGER_CHECKER_HFP_AUDPCM_PLAYERBLACK|TRIGGER_CHECKER_HFP_AUDPCM_CAPTURE) +#define TRIGGER_CHECKER_A2DP_PLAYERBLACK (1 << 0) +#define TRIGGER_CHECKER_A2DP_DONE (TRIGGER_CHECKER_A2DP_PLAYERBLACK) +#define TRIGGER_CHECKER_HFP_BTPCM_PLAYERBLACK (1 << 1) +#define TRIGGER_CHECKER_HFP_BTPCM_CAPTURE (1 << 2) +#define TRIGGER_CHECKER_HFP_AUDPCM_PLAYERBLACK (1 << 3) +#define TRIGGER_CHECKER_HFP_AUDPCM_CAPTURE (1 << 4) +#define TRIGGER_CHECKER_HFP_DONE \ + (TRIGGER_CHECKER_HFP_BTPCM_PLAYERBLACK | TRIGGER_CHECKER_HFP_BTPCM_CAPTURE | \ + TRIGGER_CHECKER_HFP_AUDPCM_PLAYERBLACK | \ + TRIGGER_CHECKER_HFP_AUDPCM_CAPTURE) static bool app_bt_stream_trigger_enable = 0; static uint32_t app_bt_stream_trigger_checker = 0; @@ -390,84 +406,82 @@ static void app_bt_stream_trigger_timeout_cb(void const *n); osTimerDef(APP_BT_STREAM_TRIGGER_TIMEOUT, app_bt_stream_trigger_timeout_cb); osTimerId app_bt_stream_trigger_timeout_id = NULL; -static void app_bt_stream_trigger_timeout_cb(void const *n) -{ - TRACE_AUD_STREAM_I("[STRM_TRIG][CHK]timeout_cb\n"); - if (app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC)){ - TRACE_AUD_STREAM_I("[STRM_TRIG][CHK]-->A2DP_SBC\n"); +static void app_bt_stream_trigger_timeout_cb(void const *n) { + TRACE_AUD_STREAM_I("[STRM_TRIG][CHK]timeout_cb\n"); + if (app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC)) { + TRACE_AUD_STREAM_I("[STRM_TRIG][CHK]-->A2DP_SBC\n"); #if defined(IBRT) - app_ibrt_if_force_audio_retrigger(); + app_ibrt_if_force_audio_retrigger(); #else - app_audio_sendrequest_param(APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_RESTART, 0, 0); + app_audio_sendrequest_param(APP_BT_STREAM_A2DP_SBC, + (uint8_t)APP_BT_SETTING_RESTART, 0, 0); #endif - }else if (app_bt_stream_isrun(APP_BT_STREAM_HFP_PCM)){ - TRACE_AUD_STREAM_I("[STRM_TRIG][CHK]-->HFP_PCM\n"); - app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, (uint8_t)APP_BT_SETTING_RESTART, 0); - } - + } else if (app_bt_stream_isrun(APP_BT_STREAM_HFP_PCM)) { + TRACE_AUD_STREAM_I("[STRM_TRIG][CHK]-->HFP_PCM\n"); + app_audio_sendrequest(APP_BT_STREAM_HFP_PCM, + (uint8_t)APP_BT_SETTING_RESTART, 0); + } } -static int app_bt_stream_trigger_checker_init(void) -{ - if (app_bt_stream_trigger_timeout_id == NULL){ - app_bt_stream_trigger_enable = false; - app_bt_stream_trigger_checker = 0; - app_bt_stream_trigger_timeout_id = osTimerCreate(osTimer(APP_BT_STREAM_TRIGGER_TIMEOUT), osTimerOnce, NULL); - } - - return 0; -} - -static int app_bt_stream_trigger_checker_start(void) -{ - app_bt_stream_trigger_checker = 0; - app_bt_stream_trigger_enable = true; - osTimerStart(app_bt_stream_trigger_timeout_id, APP_BT_STREAM_TRIGGER_TIMEROUT); - return 0; -} - -static int app_bt_stream_trigger_checker_stop(void) -{ +static int app_bt_stream_trigger_checker_init(void) { + if (app_bt_stream_trigger_timeout_id == NULL) { app_bt_stream_trigger_enable = false; app_bt_stream_trigger_checker = 0; - osTimerStop(app_bt_stream_trigger_timeout_id); - return 0; + app_bt_stream_trigger_timeout_id = osTimerCreate( + osTimer(APP_BT_STREAM_TRIGGER_TIMEOUT), osTimerOnce, NULL); + } + + return 0; } -int app_bt_stream_trigger_checker_handler(uint32_t trigger_checker) -{ - bool trigger_ok = false; +static int app_bt_stream_trigger_checker_start(void) { + app_bt_stream_trigger_checker = 0; + app_bt_stream_trigger_enable = true; + osTimerStart(app_bt_stream_trigger_timeout_id, + APP_BT_STREAM_TRIGGER_TIMEROUT); + return 0; +} - if (app_bt_stream_trigger_enable){ - app_bt_stream_trigger_checker |= trigger_checker; - if (app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC)){ - if (app_bt_stream_trigger_checker == TRIGGER_CHECKER_A2DP_DONE){ - trigger_ok = true; - } - }else if (app_bt_stream_isrun(APP_BT_STREAM_HFP_PCM)){ - if (app_bt_stream_trigger_checker == TRIGGER_CHECKER_HFP_DONE){ - trigger_ok = true; - } - } - if (trigger_ok){ - TRACE_AUD_STREAM_I("[STRM_TRIG][CHK] ok\n"); - app_bt_stream_trigger_checker_stop(); - } +static int app_bt_stream_trigger_checker_stop(void) { + app_bt_stream_trigger_enable = false; + app_bt_stream_trigger_checker = 0; + osTimerStop(app_bt_stream_trigger_timeout_id); + return 0; +} + +int app_bt_stream_trigger_checker_handler(uint32_t trigger_checker) { + bool trigger_ok = false; + + if (app_bt_stream_trigger_enable) { + app_bt_stream_trigger_checker |= trigger_checker; + if (app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC)) { + if (app_bt_stream_trigger_checker == TRIGGER_CHECKER_A2DP_DONE) { + trigger_ok = true; + } + } else if (app_bt_stream_isrun(APP_BT_STREAM_HFP_PCM)) { + if (app_bt_stream_trigger_checker == TRIGGER_CHECKER_HFP_DONE) { + trigger_ok = true; + } } - return 0; + if (trigger_ok) { + TRACE_AUD_STREAM_I("[STRM_TRIG][CHK] ok\n"); + app_bt_stream_trigger_checker_stop(); + } + } + return 0; } #ifdef A2DP_LHDC_ON -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; #if defined(A2DP_LHDC_V3) -#define LHDC_AUDIO_96K_BUFF_SIZE (256*2*4*8) +#define LHDC_AUDIO_96K_BUFF_SIZE (256 * 2 * 4 * 8) //#define LHDC_AUDIO_96K_16BITS_BUFF_SIZE (256*2*2*8) -#define LHDC_AUDIO_BUFF_SIZE (256*2*4*4) +#define LHDC_AUDIO_BUFF_SIZE (256 * 2 * 4 * 4) //#define LHDC_AUDIO_16BITS_BUFF_SIZE (256*2*2*4) -#define LHDC_LLC_AUDIO_BUFF_SIZE (256*2*2*2) +#define LHDC_LLC_AUDIO_BUFF_SIZE (256 * 2 * 2 * 2) #else -#define LHDC_AUDIO_BUFF_SIZE (512*2*4) +#define LHDC_AUDIO_BUFF_SIZE (512 * 2 * 4) //#define LHDC_AUDIO_16BITS_BUFF_SIZE (512*2*2) #endif #endif @@ -482,14 +496,14 @@ uint32_t a2dp_data_buf_size; extern int app_rbplay_audio_onoff(bool onoff, uint16_t aud_id); #endif -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) int app_a2dp_source_linein_on(bool on); #endif #if defined(APP_I2S_A2DP_SOURCE) -#include "app_status_ind.h" #include "app_a2dp_source.h" -//player channel should <= capture channel number -//player must be 2 channel +#include "app_status_ind.h" +// player channel should <= capture channel number +// player must be 2 channel #define LINEIN_PLAYER_CHANNEL (2) #ifdef __AUDIO_INPUT_MONO_MODE__ #define LINEIN_CAPTURE_CHANNEL (1) @@ -498,104 +512,106 @@ int app_a2dp_source_linein_on(bool on); #endif #if (LINEIN_CAPTURE_CHANNEL == 1) -#define LINEIN_PLAYER_BUFFER_SIZE (1024*LINEIN_PLAYER_CHANNEL) -#define LINEIN_CAPTURE_BUFFER_SIZE (LINEIN_PLAYER_BUFFER_SIZE/2) +#define LINEIN_PLAYER_BUFFER_SIZE (1024 * LINEIN_PLAYER_CHANNEL) +#define LINEIN_CAPTURE_BUFFER_SIZE (LINEIN_PLAYER_BUFFER_SIZE / 2) #elif (LINEIN_CAPTURE_CHANNEL == 2) -#define LINEIN_PLAYER_BUFFER_SIZE (1024*LINEIN_PLAYER_CHANNEL) +#define LINEIN_PLAYER_BUFFER_SIZE (1024 * LINEIN_PLAYER_CHANNEL) //#define LINEIN_CAPTURE_BUFFER_SIZE (LINEIN_PLAYER_BUFFER_SIZE) -#define LINEIN_CAPTURE_BUFFER_SIZE (1024*10) +#define LINEIN_CAPTURE_BUFFER_SIZE (1024 * 10) #endif static int16_t *app_linein_play_cache = NULL; -int8_t app_linein_buffer_is_empty(void) -{ - if (app_audio_pcmbuff_length()) - { - return 0; - } - else - { - return 1; - } +int8_t app_linein_buffer_is_empty(void) { + if (app_audio_pcmbuff_length()) { + return 0; + } else { + return 1; + } } -uint32_t app_linein_pcm_come(uint8_t * pcm_buf, uint32_t len) -{ - //DUMP16("%d ", pcm_buf, 10); - DUMP8("0x%02x ", pcm_buf, 10); - TRACE_AUD_STREAM_I("app_linein_pcm_come"); - app_audio_pcmbuff_put(pcm_buf, len); +uint32_t app_linein_pcm_come(uint8_t *pcm_buf, uint32_t len) { + // DUMP16("%d ", pcm_buf, 10); + DUMP8("0x%02x ", pcm_buf, 10); + TRACE_AUD_STREAM_I("app_linein_pcm_come"); + app_audio_pcmbuff_put(pcm_buf, len); - return len; + return len; } -uint32_t app_linein_need_pcm_data(uint8_t* pcm_buf, uint32_t len) -{ +uint32_t app_linein_need_pcm_data(uint8_t *pcm_buf, uint32_t len) { #if (LINEIN_CAPTURE_CHANNEL == 1) - app_audio_pcmbuff_get((uint8_t *)app_linein_play_cache, len/2); - //app_play_audio_lineinmode_more_data((uint8_t *)app_linein_play_cache,len/2); - app_bt_stream_copy_track_one_to_two_16bits((int16_t *)pcm_buf, app_linein_play_cache, len/2/2); + app_audio_pcmbuff_get((uint8_t *)app_linein_play_cache, len / 2); + // app_play_audio_lineinmode_more_data((uint8_t + // *)app_linein_play_cache,len/2); + app_bt_stream_copy_track_one_to_two_16bits( + (int16_t *)pcm_buf, app_linein_play_cache, len / 2 / 2); #elif (LINEIN_CAPTURE_CHANNEL == 2) - app_audio_pcmbuff_get((uint8_t *)pcm_buf, len); - //app_play_audio_lineinmode_more_data((uint8_t *)pcm_buf, len); + app_audio_pcmbuff_get((uint8_t *)pcm_buf, len); + // app_play_audio_lineinmode_more_data((uint8_t *)pcm_buf, len); #endif #if defined(__AUDIO_OUTPUT_MONO_MODE__) - merge_stereo_to_mono_16bits((int16_t *)buf, (int16_t *)pcm_buf, len/2); + merge_stereo_to_mono_16bits((int16_t *)buf, (int16_t *)pcm_buf, len / 2); #endif #ifdef ANC_APP - bt_audio_updata_eq_for_anc(app_anc_work_status()); + bt_audio_updata_eq_for_anc(app_anc_work_status()); #endif - audio_process_run(pcm_buf, len); + audio_process_run(pcm_buf, len); - return len; + return len; } extern "C" void pmu_linein_onoff(unsigned char en); extern "C" int hal_analogif_reg_read(unsigned short reg, unsigned short *val); -int app_a2dp_source_I2S_onoff(bool onoff) -{ - static bool isRun = false; - uint8_t *linein_audio_cap_buff = 0; - uint8_t *linein_audio_play_buff = 0; - uint8_t *linein_audio_loop_buf = NULL; - struct AF_STREAM_CONFIG_T stream_cfg; +int app_a2dp_source_I2S_onoff(bool onoff) { + static bool isRun = false; + uint8_t *linein_audio_cap_buff = 0; + uint8_t *linein_audio_play_buff = 0; + uint8_t *linein_audio_loop_buf = NULL; + struct AF_STREAM_CONFIG_T stream_cfg; - TRACE_AUD_STREAM_I("app_a2dp_source_I2S_onoff work:%d op:%d", isRun, onoff); + TRACE_AUD_STREAM_I("app_a2dp_source_I2S_onoff work:%d op:%d", isRun, onoff); - if (isRun == onoff) - return 0; + if (isRun == onoff) + return 0; - if (onoff) - { - app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_104M); - app_overlay_select(APP_OVERLAY_A2DP); - app_audio_mempool_init(); - app_audio_mempool_get_buff(&linein_audio_cap_buff, LINEIN_CAPTURE_BUFFER_SIZE); -// app_audio_mempool_get_buff(&linein_audio_play_buff, LINEIN_PLAYER_BUFFER_SIZE); -// app_audio_mempool_get_buff(&linein_audio_loop_buf, LINEIN_PLAYER_BUFFER_SIZE<<2); -// app_audio_pcmbuff_init(linein_audio_loop_buf, LINEIN_PLAYER_BUFFER_SIZE<<2); + if (onoff) { + app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_104M); + app_overlay_select(APP_OVERLAY_A2DP); + app_audio_mempool_init(); + app_audio_mempool_get_buff(&linein_audio_cap_buff, + LINEIN_CAPTURE_BUFFER_SIZE); + // app_audio_mempool_get_buff(&linein_audio_play_buff, + // LINEIN_PLAYER_BUFFER_SIZE); + // app_audio_mempool_get_buff(&linein_audio_loop_buf, + // LINEIN_PLAYER_BUFFER_SIZE<<2); + // app_audio_pcmbuff_init(linein_audio_loop_buf, + // LINEIN_PLAYER_BUFFER_SIZE<<2); #if (LINEIN_CAPTURE_CHANNEL == 1) - app_audio_mempool_get_buff((uint8_t **)&app_linein_play_cache, LINEIN_PLAYER_BUFFER_SIZE/2/2); - //app_play_audio_lineinmode_init(LINEIN_CAPTURE_CHANNEL, LINEIN_PLAYER_BUFFER_SIZE/2/2); + app_audio_mempool_get_buff((uint8_t **)&app_linein_play_cache, + LINEIN_PLAYER_BUFFER_SIZE / 2 / 2); + // app_play_audio_lineinmode_init(LINEIN_CAPTURE_CHANNEL, + // LINEIN_PLAYER_BUFFER_SIZE/2/2); #elif (LINEIN_CAPTURE_CHANNEL == 2) - //app_play_audio_lineinmode_init(LINEIN_CAPTURE_CHANNEL, LINEIN_PLAYER_BUFFER_SIZE/2); + // app_play_audio_lineinmode_init(LINEIN_CAPTURE_CHANNEL, + // LINEIN_PLAYER_BUFFER_SIZE/2); #endif - sRet = memset_s(&stream_cfg, sizeof(stream_cfg), 0, sizeof(stream_cfg)); - if (sRet){ - TRACE_AUD_STREAM_W("func-s line:%d sRet:%d %s ", __LINE__, sRet, __func__); - } - stream_cfg.bits = AUD_BITS_16; - stream_cfg.channel_num = (enum AUD_CHANNEL_NUM_T)LINEIN_PLAYER_CHANNEL; - stream_cfg.sample_rate = AUD_SAMPRATE_44100; + sRet = memset_s(&stream_cfg, sizeof(stream_cfg), 0, sizeof(stream_cfg)); + if (sRet) { + TRACE_AUD_STREAM_W("func-s line:%d sRet:%d %s ", __LINE__, sRet, + __func__); + } + stream_cfg.bits = AUD_BITS_16; + stream_cfg.channel_num = (enum AUD_CHANNEL_NUM_T)LINEIN_PLAYER_CHANNEL; + stream_cfg.sample_rate = AUD_SAMPRATE_44100; #if 0 -#if FPGA==0 +#if FPGA == 0 stream_cfg.device = AUD_STREAM_USE_INT_CODEC; #else stream_cfg.device = AUD_STREAM_USE_EXT_CODEC; @@ -612,268 +628,301 @@ int app_a2dp_source_I2S_onoff(bool onoff) #endif #if 1 - stream_cfg.device = AUD_STREAM_USE_I2S0_SLAVE; -// stream_cfg.io_path = AUD_INPUT_PATH_LINEIN; -// stream_cfg.handler = app_linein_pcm_come; - stream_cfg.handler = a2dp_source_linein_more_pcm_data; -// stream_cfg.handler = app_linein_pcm_come; - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(linein_audio_cap_buff); - stream_cfg.data_size = LINEIN_CAPTURE_BUFFER_SIZE;//2k + stream_cfg.device = AUD_STREAM_USE_I2S0_SLAVE; + // stream_cfg.io_path = AUD_INPUT_PATH_LINEIN; + // stream_cfg.handler = app_linein_pcm_come; + stream_cfg.handler = a2dp_source_linein_more_pcm_data; + // stream_cfg.handler = app_linein_pcm_come; + stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(linein_audio_cap_buff); + stream_cfg.data_size = LINEIN_CAPTURE_BUFFER_SIZE; // 2k -// pmu_linein_onoff(1); - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); + // pmu_linein_onoff(1); + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); - audio_process_open(stream_cfg.sample_rate, stream_cfg.bits, stream_cfg.channel_num, NULL, 0); + audio_process_open(stream_cfg.sample_rate, stream_cfg.bits, + stream_cfg.channel_num, NULL, 0); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); #endif - //app_status_indication_set(APP_STATUS_INDICATION_LINEIN_ON); - } - else - { -// clear buffer data - a2dp_source.pcm_queue.write=0; - a2dp_source.pcm_queue.len=0; - a2dp_source.pcm_queue.read=0; -// pmu_linein_onoff(0); - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + // app_status_indication_set(APP_STATUS_INDICATION_LINEIN_ON); + } else { + // clear buffer data + a2dp_source.pcm_queue.write = 0; + a2dp_source.pcm_queue.len = 0; + a2dp_source.pcm_queue.read = 0; + // pmu_linein_onoff(0); + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - //app_status_indication_set(APP_STATUS_INDICATION_LINEIN_OFF); - app_overlay_unloadall(); - app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_32K); - } + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + // app_status_indication_set(APP_STATUS_INDICATION_LINEIN_OFF); + app_overlay_unloadall(); + app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_32K); + } - isRun = onoff; - TRACE_AUD_STREAM_I("%s end!\n", __func__); + isRun = onoff; + TRACE_AUD_STREAM_I("%s end!\n", __func__); + return 0; +} +#endif + +enum AUD_SAMPRATE_T bt_parse_sbc_sample_rate(uint8_t sbc_samp_rate) { + enum AUD_SAMPRATE_T sample_rate; + sbc_samp_rate = sbc_samp_rate & A2D_STREAM_SAMP_FREQ_MSK; + + switch (sbc_samp_rate) { + case A2D_SBC_IE_SAMP_FREQ_16: + // sample_rate = AUD_SAMPRATE_16000; + // break; + case A2D_SBC_IE_SAMP_FREQ_32: + // sample_rate = AUD_SAMPRATE_32000; + // break; + case A2D_SBC_IE_SAMP_FREQ_48: + sample_rate = AUD_SAMPRATE_48000; + break; + case A2D_SBC_IE_SAMP_FREQ_44: + sample_rate = AUD_SAMPRATE_44100; + break; +#if defined(A2DP_LHDC_ON) || defined(A2DP_LDAC_ON) || defined(A2DP_SCALABLE_ON) + case A2D_SBC_IE_SAMP_FREQ_96: + sample_rate = AUD_SAMPRATE_96000; + break; +#endif + + default: + ASSERT(0, "[%s] 0x%x is invalid", __func__, sbc_samp_rate); + break; + } + return sample_rate; +} + +void bt_store_sbc_sample_rate(enum AUD_SAMPRATE_T sample_rate) { + a2dp_sample_rate = sample_rate; +} + +enum AUD_SAMPRATE_T bt_get_sbc_sample_rate(void) { return a2dp_sample_rate; } + +enum AUD_SAMPRATE_T bt_parse_store_sbc_sample_rate(uint8_t sbc_samp_rate) { + enum AUD_SAMPRATE_T sample_rate; + + sample_rate = bt_parse_sbc_sample_rate(sbc_samp_rate); + bt_store_sbc_sample_rate(sample_rate); + + return sample_rate; +} + +int bt_sbc_player_setup(uint8_t freq) { + struct AF_STREAM_CONFIG_T *stream_cfg = NULL; + static uint8_t sbc_samp_rate = 0xff; + uint32_t ret; + + if (sbc_samp_rate == freq) return 0; -} -#endif -enum AUD_SAMPRATE_T bt_parse_sbc_sample_rate(uint8_t sbc_samp_rate) -{ - enum AUD_SAMPRATE_T sample_rate; - sbc_samp_rate = sbc_samp_rate & A2D_STREAM_SAMP_FREQ_MSK; - - switch (sbc_samp_rate) - { - case A2D_SBC_IE_SAMP_FREQ_16: -// sample_rate = AUD_SAMPRATE_16000; -// break; - case A2D_SBC_IE_SAMP_FREQ_32: -// sample_rate = AUD_SAMPRATE_32000; -// break; - case A2D_SBC_IE_SAMP_FREQ_48: - sample_rate = AUD_SAMPRATE_48000; - break; - case A2D_SBC_IE_SAMP_FREQ_44: - sample_rate = AUD_SAMPRATE_44100; - break; + switch (freq) { + case A2D_SBC_IE_SAMP_FREQ_16: + case A2D_SBC_IE_SAMP_FREQ_32: + case A2D_SBC_IE_SAMP_FREQ_48: + a2dp_sample_rate = AUD_SAMPRATE_48000; + break; #if defined(A2DP_LHDC_ON) || defined(A2DP_LDAC_ON) || defined(A2DP_SCALABLE_ON) - case A2D_SBC_IE_SAMP_FREQ_96: - sample_rate = AUD_SAMPRATE_96000; - break; -#endif - - default: - ASSERT(0, "[%s] 0x%x is invalid", __func__, sbc_samp_rate); - break; - } - return sample_rate; -} - -void bt_store_sbc_sample_rate(enum AUD_SAMPRATE_T sample_rate) -{ - a2dp_sample_rate = sample_rate; -} - -enum AUD_SAMPRATE_T bt_get_sbc_sample_rate(void) -{ - return a2dp_sample_rate; -} - -enum AUD_SAMPRATE_T bt_parse_store_sbc_sample_rate(uint8_t sbc_samp_rate) -{ - enum AUD_SAMPRATE_T sample_rate; - - sample_rate = bt_parse_sbc_sample_rate(sbc_samp_rate); - bt_store_sbc_sample_rate(sample_rate); - - return sample_rate; -} - -int bt_sbc_player_setup(uint8_t freq) -{ - struct AF_STREAM_CONFIG_T *stream_cfg = NULL; - static uint8_t sbc_samp_rate = 0xff; - uint32_t ret; - - if (sbc_samp_rate == freq) - return 0; - - switch (freq) - { - case A2D_SBC_IE_SAMP_FREQ_16: - case A2D_SBC_IE_SAMP_FREQ_32: - case A2D_SBC_IE_SAMP_FREQ_48: - a2dp_sample_rate = AUD_SAMPRATE_48000; - break; -#if defined(A2DP_LHDC_ON) || defined(A2DP_LDAC_ON) || defined(A2DP_SCALABLE_ON) - case A2D_SBC_IE_SAMP_FREQ_96: - a2dp_sample_rate = AUD_SAMPRATE_96000; - break; + case A2D_SBC_IE_SAMP_FREQ_96: + a2dp_sample_rate = AUD_SAMPRATE_96000; + break; #if defined(A2DP_LDAC_ON) - case A2D_SBC_IE_SAMP_FREQ_88: - a2dp_sample_rate = AUD_SAMPRATE_88200; - break; + case A2D_SBC_IE_SAMP_FREQ_88: + a2dp_sample_rate = AUD_SAMPRATE_88200; + break; #endif #endif - case A2D_SBC_IE_SAMP_FREQ_44: - a2dp_sample_rate = AUD_SAMPRATE_44100; - break; - default: - break; - } - TRACE_AUD_STREAM_I("%s:Sample rate :%d", __func__, a2dp_sample_rate); + case A2D_SBC_IE_SAMP_FREQ_44: + a2dp_sample_rate = AUD_SAMPRATE_44100; + break; + default: + break; + } + TRACE_AUD_STREAM_I("%s:Sample rate :%d", __func__, a2dp_sample_rate); - ret = af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg, true); - if (ret == 0) { - stream_cfg->sample_rate = a2dp_sample_rate; - af_stream_setup(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, stream_cfg); - } + ret = af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg, + true); + if (ret == 0) { + stream_cfg->sample_rate = a2dp_sample_rate; + af_stream_setup(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, stream_cfg); + } #if defined(AUDIO_ANC_FB_MC) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - ret = af_stream_get_cfg(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &stream_cfg, true); - if (ret == 0) { - stream_cfg->sample_rate = a2dp_sample_rate; - sample_rate_play_bt=stream_cfg->sample_rate; - af_stream_setup(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, stream_cfg); - anc_mc_run_setup(hal_codec_anc_convert_rate(sample_rate_play_bt)); - } + ret = af_stream_get_cfg(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &stream_cfg, + true); + if (ret == 0) { + stream_cfg->sample_rate = a2dp_sample_rate; + sample_rate_play_bt = stream_cfg->sample_rate; + af_stream_setup(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, stream_cfg); + anc_mc_run_setup(hal_codec_anc_convert_rate(sample_rate_play_bt)); + } #endif - sbc_samp_rate = freq; + sbc_samp_rate = freq; #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - if (audio_prompt_is_playing_ongoing()) - { - audio_prompt_forcefully_stop(); - } + if (audio_prompt_is_playing_ongoing()) { + audio_prompt_forcefully_stop(); + } #endif - return 0; + return 0; } -void merge_stereo_to_mono_16bits(int16_t *src_buf, int16_t *dst_buf, uint32_t src_len) -{ - uint32_t i = 0; - for (i = 0; i < src_len; i+=2) - { - dst_buf[i] = (src_buf[i]>>1) + (src_buf[i+1]>>1); - dst_buf[i+1] = dst_buf[i]; - } +void merge_stereo_to_mono_16bits(int16_t *src_buf, int16_t *dst_buf, + uint32_t src_len) { + uint32_t i = 0; + for (i = 0; i < src_len; i += 2) { + dst_buf[i] = (src_buf[i] >> 1) + (src_buf[i + 1] >> 1); + dst_buf[i + 1] = dst_buf[i]; + } } -void merge_stereo_to_mono_24bits(int32_t *src_buf, int32_t *dst_buf, uint32_t src_len) -{ - uint32_t i = 0; - for (i = 0; i < src_len; i+=2) - { - dst_buf[i] = (src_buf[i]>>1) + (src_buf[i+1]>>1); - dst_buf[i+1] = dst_buf[i]; - } +void merge_stereo_to_mono_24bits(int32_t *src_buf, int32_t *dst_buf, + uint32_t src_len) { + uint32_t i = 0; + for (i = 0; i < src_len; i += 2) { + dst_buf[i] = (src_buf[i] >> 1) + (src_buf[i + 1] >> 1); + dst_buf[i + 1] = dst_buf[i]; + } } static char _player_type_str[168]; static char *_catstr(char *dst, const char *src) { - while(*dst) dst++; - while((*dst++ = *src++)); - return --dst; + while (*dst) + dst++; + while ((*dst++ = *src++)) + ; + return --dst; } const char *player2str(uint16_t player_type) { - const char *s = NULL; - char _cat = 0, first = 1, *d = NULL; - _player_type_str[0] = '\0'; - d = _player_type_str; - d = _catstr(d, "["); - if (player_type != 0) { - for (int i = 15 ; i >= 0; i--) { - _cat = 1; - //TRACE_AUD_STREAM_I("i=%d,player_type=0x%d,player_type&(1<= 0; i--) { + _cat = 1; + // TRACE_AUD_STREAM_I("i=%d,player_type=0x%d,player_type&(1<= 0x80 && + a2dp_Get_curr_a2dp_conhdl() <= 0x82) { + btofs = btdrv_rf_bitoffset_get(a2dp_Get_curr_a2dp_conhdl() - 0x80); - // a2dp_get_curStream_remDev(&p_a2dp_remDev); - if(a2dp_Get_curr_a2dp_conhdl() >=0x80 && a2dp_Get_curr_a2dp_conhdl()<=0x82) - { - btofs = btdrv_rf_bitoffset_get( a2dp_Get_curr_a2dp_conhdl() -0x80); + if (calib_reset == 1) { + calib_reset = 0; - if(calib_reset==1) - { - calib_reset=0; + bt_clock_total_mutius = 0; - bt_clock_total_mutius=0; + bt_old_clock_us = btcnt; + bt_old_clock_mutius = btclk; - bt_old_clock_us=btcnt; - bt_old_clock_mutius=btclk; + bt_total_offset_us = 0; - bt_total_offset_us=0; + local_total_samples = 0; + local_total_frames = 0; + local_clock_ms = 0; + bt_local_clock_s = 0; + bt_clock_us = 0; + bt_clock_ms = 0; - local_total_samples=0; - local_total_frames=0; - local_clock_ms = 0; + bt_old_offset_us = btofs; - bt_local_clock_s=0; - bt_clock_us = 0; - bt_clock_ms = 0; + calib_factor_offset = 0.0f; + calib_factor_flag = 0; + calib_total_delay = 0; + calib_flag = 0; + } else { + btoffset = btofs - bt_old_offset_us; - bt_old_offset_us=btofs; + if (btoffset < -BT_USPERCLK / 3) { + btoffset = btoffset + BT_USPERCLK; + } else if (btoffset > BT_USPERCLK / 3) { + btoffset = btoffset - BT_USPERCLK; + } - calib_factor_offset=0.0f; - calib_factor_flag=0; - calib_total_delay=0; - calib_flag=0; - } - else - { - btoffset=btofs-bt_old_offset_us; - - if(btoffset<-BT_USPERCLK/3) - { - btoffset=btoffset+BT_USPERCLK; - } - else if(btoffset>BT_USPERCLK/3) - { - btoffset=btoffset-BT_USPERCLK; - } - - bt_total_offset_us=bt_total_offset_us+btoffset; - bt_old_offset_us=btofs; - - local_total_frames++; - if(lowdelay_sample_size_play_bt==AUD_BITS_16) - { - smplcnt=len/(2*lowdelay_playback_ch_num_bt); - } - else - { - smplcnt=len/(4*lowdelay_playback_ch_num_bt); - } - - local_total_samples=local_total_samples+smplcnt; - - bt_clock_us=btcnt-bt_old_clock_us-bt_total_offset_us; - - btoffset=btclk-bt_old_clock_mutius; - if(btoffset<0) - { - btoffset=0; - } - bt_clock_total_mutius=bt_clock_total_mutius+btoffset; - - bt_old_clock_us=btcnt; - bt_old_clock_mutius=btclk; - - if((bt_clock_total_mutius>BT_MUTIUSPERSECOND)&&(local_total_samples>lowdelay_sample_rate_play_bt)) - { - bt_local_clock_s++; - bt_clock_total_mutius=bt_clock_total_mutius-BT_MUTIUSPERSECOND; - local_total_samples=local_total_samples-lowdelay_sample_rate_play_bt; - } - - bt_clock_ms=(bt_clock_total_mutius*BT_USPERCLK/1000)+bt_clock_us/625; - local_clock_ms=(local_total_samples*1000)/lowdelay_sample_rate_play_bt; - - local_clock_ms=local_clock_ms+calib_total_delay; - - //TRACE_AUD_STREAM_I("A2DP bt_clock_ms:%8d,local_clock_ms:%8d,bt_total_offset_us:%8d\n",bt_clock_ms, local_clock_ms,bt_total_offset_us); - - if(bt_clock_ms>(local_clock_ms+CALIB_DEVIATION_MS)) - { -#if defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE) - app_resample_tune(a2dp_resample, CALIB_FACTOR_DELAY); -#else - af_codec_tune(AUD_STREAM_PLAYBACK, CALIB_FACTOR_DELAY); -#endif - calib_factor_flag=1; - //TRACE_AUD_STREAM_I("*************1***************"); - } - else if(bt_clock_ms<(local_clock_ms-CALIB_DEVIATION_MS)) - { -#if defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE) - app_resample_tune(a2dp_resample, -CALIB_FACTOR_DELAY); -#else - af_codec_tune(AUD_STREAM_PLAYBACK, -CALIB_FACTOR_DELAY); -#endif - calib_factor_flag=-1; - //TRACE_AUD_STREAM_I("*************-1***************"); - } - else - { - if((calib_factor_flag==1||calib_factor_flag==-1)&&(bt_clock_ms==local_clock_ms)) - { - if(calib_factor_offset BT_MUTIUSPERSECOND) && + (local_total_samples > lowdelay_sample_rate_play_bt)) { + bt_local_clock_s++; + bt_clock_total_mutius = bt_clock_total_mutius - BT_MUTIUSPERSECOND; + local_total_samples = + local_total_samples - lowdelay_sample_rate_play_bt; + } + + bt_clock_ms = + (bt_clock_total_mutius * BT_USPERCLK / 1000) + bt_clock_us / 625; + local_clock_ms = + (local_total_samples * 1000) / lowdelay_sample_rate_play_bt; + + local_clock_ms = local_clock_ms + calib_total_delay; + + // TRACE_AUD_STREAM_I("A2DP + // bt_clock_ms:%8d,local_clock_ms:%8d,bt_total_offset_us:%8d\n",bt_clock_ms, + // local_clock_ms,bt_total_offset_us); + + if (bt_clock_ms > (local_clock_ms + CALIB_DEVIATION_MS)) { +#if defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE) + app_resample_tune(a2dp_resample, CALIB_FACTOR_DELAY); +#else + af_codec_tune(AUD_STREAM_PLAYBACK, CALIB_FACTOR_DELAY); +#endif + calib_factor_flag = 1; + // TRACE_AUD_STREAM_I("*************1***************"); + } else if (bt_clock_ms < (local_clock_ms - CALIB_DEVIATION_MS)) { +#if defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE) + app_resample_tune(a2dp_resample, -CALIB_FACTOR_DELAY); +#else + af_codec_tune(AUD_STREAM_PLAYBACK, -CALIB_FACTOR_DELAY); +#endif + calib_factor_flag = -1; + // TRACE_AUD_STREAM_I("*************-1***************"); + } else { + if ((calib_factor_flag == 1 || calib_factor_flag == -1) && + (bt_clock_ms == local_clock_ms)) { + if (calib_factor_offset < CALIB_FACTOR_MAX_THRESHOLD && + calib_flag == 0) { + if (calib_factor_flag == 1) { + calib_factor_offset = + calib_factor_offset + CALIB_BT_CLOCK_FACTOR_STEP; + } else { + calib_factor_offset = + calib_factor_offset - CALIB_BT_CLOCK_FACTOR_STEP; + } + } +#if defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE) + app_resample_tune(a2dp_resample, calib_factor_offset); +#else + af_codec_tune(AUD_STREAM_PLAYBACK, calib_factor_offset); +#endif + calib_factor_flag = 0; + calib_flag = 0; + // TRACE_AUD_STREAM_I("*************0***************"); } + } + // TRACE_AUD_STREAM_I("factoroffset:%d\n",(int32_t)((factoroffset)*(float)10000000.0f)); } + } - return; + return; } #endif -bool app_if_need_fix_target_rxbit(void) -{ - return (!bt_drv_is_enhanced_ibrt_rom()); +bool app_if_need_fix_target_rxbit(void) { + return (!bt_drv_is_enhanced_ibrt_rom()); } static uint8_t isBtPlaybackTriggered = false; -bool bt_is_playback_triggered(void) -{ - return isBtPlaybackTriggered; +bool bt_is_playback_triggered(void) { return isBtPlaybackTriggered; } + +static void bt_set_playback_triggered(bool isEnable) { + isBtPlaybackTriggered = isEnable; } -static void bt_set_playback_triggered(bool isEnable) -{ - isBtPlaybackTriggered = isEnable; -} - -FRAM_TEXT_LOC uint32_t bt_sbc_player_more_data(uint8_t *buf, uint32_t len) -{ - app_bt_stream_trigger_checker_handler(TRIGGER_CHECKER_A2DP_PLAYERBLACK); +FRAM_TEXT_LOC uint32_t bt_sbc_player_more_data(uint8_t *buf, uint32_t len) { + app_bt_stream_trigger_checker_handler(TRIGGER_CHECKER_A2DP_PLAYERBLACK); #ifdef A2DP_STREAM_AUDIO_DUMP - audio_dump_clear_up(); - audio_dump_add_channel_data_from_multi_channels(0, buf, len / sizeof(int) / 2, 2, 0); - audio_dump_run(); + audio_dump_clear_up(); + audio_dump_add_channel_data_from_multi_channels(0, buf, len / sizeof(int) / 2, + 2, 0); + audio_dump_run(); #endif - bt_set_playback_triggered(true); + bt_set_playback_triggered(true); -#if defined(MUSIC_DELAY_CONTROL) && (defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A)|| defined(CHIP_BEST1400)|| defined(CHIP_BEST1402)) - a2dp_clock_calib_process(len); +#if defined(MUSIC_DELAY_CONTROL) && \ + (defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || \ + defined(CHIP_BEST2300A) || defined(CHIP_BEST1400) || \ + defined(CHIP_BEST1402)) + a2dp_clock_calib_process(len); #endif #if defined(IBRT) && defined(RSSI_GATHERING_ENABLED) - app_ibrt_ui_rssi_process(); + app_ibrt_ui_rssi_process(); #endif #ifdef VOICE_DATAPATH - //if (AI_SPEC_GSOUND == ai_manager_get_current_spec()) - { - if (app_voicepath_get_stream_pending_state(VOICEPATH_STREAMING)) - { - #ifdef __DUAL_MIC_RECORDING__ - app_ibrt_voice_capture_trigger_init(); - #endif - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - #ifdef MIX_MIC_DURING_MUSIC - app_voicepath_enable_hw_sidetone(0, HW_SIDE_TONE_MAX_ATTENUATION_COEF); - #endif - app_voicepath_set_stream_state(VOICEPATH_STREAMING, true); - app_voicepath_set_pending_started_stream(VOICEPATH_STREAMING, false); - } + // if (AI_SPEC_GSOUND == ai_manager_get_current_spec()) + { + if (app_voicepath_get_stream_pending_state(VOICEPATH_STREAMING)) { +#ifdef __DUAL_MIC_RECORDING__ + app_ibrt_voice_capture_trigger_init(); +#endif + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); +#ifdef MIX_MIC_DURING_MUSIC + app_voicepath_enable_hw_sidetone(0, HW_SIDE_TONE_MAX_ATTENUATION_COEF); +#endif + app_voicepath_set_stream_state(VOICEPATH_STREAMING, true); + app_voicepath_set_pending_started_stream(VOICEPATH_STREAMING, false); } + } #endif #ifdef BT_XTAL_SYNC #ifdef BT_XTAL_SYNC_NEW_METHOD - if(a2dp_Get_curr_a2dp_conhdl() >=0x80 && a2dp_Get_curr_a2dp_conhdl()<=0x82) - { - uint32_t bitoffset = btdrv_rf_bitoffset_get( a2dp_Get_curr_a2dp_conhdl() -0x80); - if(app_if_need_fix_target_rxbit() == false) - { - if(bitoffsetSLOT_SIZE-XTAL_OFFSET) - bitoffset = SLOT_SIZE-XTAL_OFFSET; - } -#ifdef BT_XTAL_SYNC_SLOW - bt_xtal_sync_new(bitoffset,app_if_need_fix_target_rxbit(),BT_XTAL_SYNC_MODE_WITH_MOBILE); -#else - bt_xtal_sync_new_new(bitoffset,app_if_need_fix_target_rxbit(),BT_XTAL_SYNC_MODE_WITH_MOBILE); -#endif + if (a2dp_Get_curr_a2dp_conhdl() >= 0x80 && + a2dp_Get_curr_a2dp_conhdl() <= 0x82) { + uint32_t bitoffset = + btdrv_rf_bitoffset_get(a2dp_Get_curr_a2dp_conhdl() - 0x80); + if (app_if_need_fix_target_rxbit() == false) { + if (bitoffset < XTAL_OFFSET) + bitoffset = XTAL_OFFSET; + else if (bitoffset > SLOT_SIZE - XTAL_OFFSET) + bitoffset = SLOT_SIZE - XTAL_OFFSET; } +#ifdef BT_XTAL_SYNC_SLOW + bt_xtal_sync_new(bitoffset, app_if_need_fix_target_rxbit(), + BT_XTAL_SYNC_MODE_WITH_MOBILE); +#else + bt_xtal_sync_new_new(bitoffset, app_if_need_fix_target_rxbit(), + BT_XTAL_SYNC_MODE_WITH_MOBILE); +#endif + } #else - bt_xtal_sync(BT_XTAL_SYNC_MODE_MUSIC); + bt_xtal_sync(BT_XTAL_SYNC_MODE_MUSIC); #endif #endif #ifndef FPGA - uint8_t codec_type = bt_sbc_player_get_codec_type(); - uint32_t overlay_id = 0; - if(codec_type == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) - { - overlay_id = APP_OVERLAY_A2DP_AAC; - } - else if(codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - { + uint8_t codec_type = bt_sbc_player_get_codec_type(); + uint32_t overlay_id = 0; + if (codec_type == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { + overlay_id = APP_OVERLAY_A2DP_AAC; + } else if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { #if defined(A2DP_LHDC_ON) - if(current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LHDC) - { - overlay_id = APP_OVERLAY_A2DP_LHDC; - } + if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LHDC) { + overlay_id = APP_OVERLAY_A2DP_LHDC; + } #endif #if defined(A2DP_LDAC_ON) - if(current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LDAC) - { - overlay_id = APP_OVERLAY_A2DP_LDAC; - } + if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LDAC) { + overlay_id = APP_OVERLAY_A2DP_LDAC; + } #endif #if defined(A2DP_SCALABLE_ON) - if(current_a2dp_non_type == A2DP_NON_CODEC_TYPE_SCALABLE) - { - overlay_id = APP_OVERLAY_A2DP_SCALABLE; - } + if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_SCALABLE) { + overlay_id = APP_OVERLAY_A2DP_SCALABLE; + } #endif - } - else - { - overlay_id = APP_OVERLAY_A2DP; - } + } else { + overlay_id = APP_OVERLAY_A2DP; + } - memset(buf, 0, len); + memset(buf, 0, len); - if(app_get_current_overlay() != overlay_id) - { - return len; - } + if (app_get_current_overlay() != overlay_id) { + return len; + } #endif #ifdef PLAYBACK_FORCE_48K - app_playback_resample_run(force48k_resample, buf, len); + app_playback_resample_run(force48k_resample, buf, len); #else #if (A2DP_DECODER_VER == 2) - a2dp_audio_playback_handler(buf, len); + a2dp_audio_playback_handler(buf, len); #else #ifndef FPGA - a2dp_audio_more_data(overlay_id, buf, len); + a2dp_audio_more_data(overlay_id, buf, len); #endif #endif #endif #ifdef __AUDIO_SPECTRUM__ - audio_spectrum_run(buf, len); + audio_spectrum_run(buf, len); #endif - #ifdef __KWS_AUDIO_PROCESS__ - short* pdata = (short*)buf; - short pdata_mono = 0; - for(unsigned int i = 0;i=EQ_SW_IIR_LIST_NUM) - return -1; + if (index >= EQ_SW_IIR_LIST_NUM) + return -1; #endif #ifdef __HW_FIR_EQ_PROCESS__ - if (index >=EQ_HW_FIR_LIST_NUM) - return -1; + if (index >= EQ_HW_FIR_LIST_NUM) + return -1; #endif #ifdef __HW_DAC_IIR_EQ_PROCESS__ - if (index >=EQ_HW_DAC_IIR_LIST_NUM) - return -1; + if (index >= EQ_HW_DAC_IIR_LIST_NUM) + return -1; #endif #ifdef __HW_IIR_EQ_PROCESS__ - if (index >=EQ_HW_IIR_LIST_NUM) - return -1; + if (index >= EQ_HW_IIR_LIST_NUM) + return -1; #endif - g_current_eq_index = index; - return index; + g_current_eq_index = index; + return index; } -void bt_audio_updata_eq(uint8_t index) -{ - TRACE_AUD_STREAM_I("[EQ] update idx = %d", index); -#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__)|| defined(__HW_DAC_IIR_EQ_PROCESS__)|| defined(__HW_IIR_EQ_PROCESS__) - AUDIO_EQ_TYPE_T audio_eq_type; +void bt_audio_updata_eq(uint8_t index) { + TRACE_AUD_STREAM_I("[EQ] update idx = %d", index); +#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__) || \ + defined(__HW_DAC_IIR_EQ_PROCESS__) || defined(__HW_IIR_EQ_PROCESS__) + AUDIO_EQ_TYPE_T audio_eq_type; #ifdef __SW_IIR_EQ_PROCESS__ - audio_eq_type = AUDIO_EQ_TYPE_SW_IIR; + audio_eq_type = AUDIO_EQ_TYPE_SW_IIR; #endif #ifdef __HW_FIR_EQ_PROCESS__ - audio_eq_type = AUDIO_EQ_TYPE_HW_FIR; + audio_eq_type = AUDIO_EQ_TYPE_HW_FIR; #endif #ifdef __HW_DAC_IIR_EQ_PROCESS__ - audio_eq_type = AUDIO_EQ_TYPE_HW_DAC_IIR; + audio_eq_type = AUDIO_EQ_TYPE_HW_DAC_IIR; #endif #ifdef __HW_IIR_EQ_PROCESS__ - audio_eq_type = AUDIO_EQ_TYPE_HW_IIR; + audio_eq_type = AUDIO_EQ_TYPE_HW_IIR; #endif - bt_audio_set_eq(audio_eq_type,index); + bt_audio_set_eq(audio_eq_type, index); #endif } - #ifdef ANC_APP -uint8_t bt_audio_updata_eq_for_anc(uint8_t anc_status) -{ - anc_status = app_anc_work_status(); - if(anc_status_record != anc_status) - { - anc_status_record = anc_status; - TRACE_AUD_STREAM_I("[EQ] update anc_status = %d", anc_status); +uint8_t bt_audio_updata_eq_for_anc(uint8_t anc_status) { + anc_status = app_anc_work_status(); + if (anc_status_record != anc_status) { + anc_status_record = anc_status; + TRACE_AUD_STREAM_I("[EQ] update anc_status = %d", anc_status); #ifdef __SW_IIR_EQ_PROCESS__ - bt_audio_set_eq(AUDIO_EQ_TYPE_SW_IIR,bt_audio_get_eq_index(AUDIO_EQ_TYPE_SW_IIR,anc_status)); + bt_audio_set_eq(AUDIO_EQ_TYPE_SW_IIR, + bt_audio_get_eq_index(AUDIO_EQ_TYPE_SW_IIR, anc_status)); #endif #ifdef __HW_FIR_EQ_PROCESS__ - bt_audio_set_eq(AUDIO_EQ_TYPE_HW_FIR,bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_FIR,anc_status)); + bt_audio_set_eq(AUDIO_EQ_TYPE_HW_FIR, + bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_FIR, anc_status)); #endif #ifdef __HW_DAC_IIR_EQ_PROCESS__ - bt_audio_set_eq(AUDIO_EQ_TYPE_HW_DAC_IIR,bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_DAC_IIR,anc_status)); + bt_audio_set_eq( + AUDIO_EQ_TYPE_HW_DAC_IIR, + bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_DAC_IIR, anc_status)); #endif #ifdef __HW_IIR_EQ_PROCESS__ - bt_audio_set_eq(AUDIO_EQ_TYPE_HW_IIR,bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_IIR,anc_status)); + bt_audio_set_eq(AUDIO_EQ_TYPE_HW_IIR, + bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_IIR, anc_status)); #endif - } - return 0; + } + return 0; } #endif -uint8_t bt_audio_get_eq_index(AUDIO_EQ_TYPE_T audio_eq_type,uint8_t anc_status) -{ - uint8_t index_eq=0; +uint8_t bt_audio_get_eq_index(AUDIO_EQ_TYPE_T audio_eq_type, + uint8_t anc_status) { + uint8_t index_eq = 0; -#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__)|| defined(__HW_DAC_IIR_EQ_PROCESS__)|| defined(__HW_IIR_EQ_PROCESS__) - switch (audio_eq_type) - { +#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__) || \ + defined(__HW_DAC_IIR_EQ_PROCESS__) || defined(__HW_IIR_EQ_PROCESS__) + switch (audio_eq_type) { #if defined(__SW_IIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_SW_IIR: - { - if(anc_status) - { - index_eq=audio_eq_sw_iir_index+1; - } - else - { - index_eq=audio_eq_sw_iir_index; - } + case AUDIO_EQ_TYPE_SW_IIR: { + if (anc_status) { + index_eq = audio_eq_sw_iir_index + 1; + } else { + index_eq = audio_eq_sw_iir_index; + } - } - break; + } break; #endif #if defined(__HW_FIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_HW_FIR: - { - if(a2dp_sample_rate == AUD_SAMPRATE_44100) { - index_eq = 0; - } else if(a2dp_sample_rate == AUD_SAMPRATE_48000) { - index_eq = 1; - } else if(a2dp_sample_rate == AUD_SAMPRATE_96000) { - index_eq = 2; - } else { - ASSERT(0, "[%s] sample_rate_recv(%d) is not supported", __func__, a2dp_sample_rate); - } - audio_eq_hw_fir_index=index_eq; + case AUDIO_EQ_TYPE_HW_FIR: { + if (a2dp_sample_rate == AUD_SAMPRATE_44100) { + index_eq = 0; + } else if (a2dp_sample_rate == AUD_SAMPRATE_48000) { + index_eq = 1; + } else if (a2dp_sample_rate == AUD_SAMPRATE_96000) { + index_eq = 2; + } else { + ASSERT(0, "[%s] sample_rate_recv(%d) is not supported", __func__, + a2dp_sample_rate); + } + audio_eq_hw_fir_index = index_eq; - if(anc_status) - { - index_eq=index_eq+3; - } - } - break; + if (anc_status) { + index_eq = index_eq + 3; + } + } break; #endif #if defined(__HW_DAC_IIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_HW_DAC_IIR: - { - if(anc_status) - { - index_eq=audio_eq_hw_dac_iir_index+1; - } - else - { - index_eq=audio_eq_hw_dac_iir_index; - } - } - break; + case AUDIO_EQ_TYPE_HW_DAC_IIR: { + if (anc_status) { + index_eq = audio_eq_hw_dac_iir_index + 1; + } else { + index_eq = audio_eq_hw_dac_iir_index; + } + } break; #endif #if defined(__HW_IIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_HW_IIR: - { - if(anc_status) - { - index_eq=audio_eq_hw_iir_index+1; - } - else - { - index_eq=audio_eq_hw_iir_index; - } - } - break; -#endif - default: - { - ASSERT(false,"[%s]Error eq type!",__func__); - } + case AUDIO_EQ_TYPE_HW_IIR: { + if (anc_status) { + index_eq = audio_eq_hw_iir_index + 1; + } else { + index_eq = audio_eq_hw_iir_index; } + } break; #endif - return index_eq; + default: { + ASSERT(false, "[%s]Error eq type!", __func__); + } + } +#endif + return index_eq; } +uint32_t bt_audio_set_eq(AUDIO_EQ_TYPE_T audio_eq_type, uint8_t index) { + const FIR_CFG_T *fir_cfg = NULL; + const IIR_CFG_T *iir_cfg = NULL; -uint32_t bt_audio_set_eq(AUDIO_EQ_TYPE_T audio_eq_type, uint8_t index) -{ - const FIR_CFG_T *fir_cfg=NULL; - const IIR_CFG_T *iir_cfg=NULL; + TRACE_AUD_STREAM_I("[EQ] set type=%d,index=%d", audio_eq_type, index); - TRACE_AUD_STREAM_I("[EQ] set type=%d,index=%d", audio_eq_type,index); - -#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__)|| defined(__HW_DAC_IIR_EQ_PROCESS__)|| defined(__HW_IIR_EQ_PROCESS__) - switch (audio_eq_type) - { +#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__) || \ + defined(__HW_DAC_IIR_EQ_PROCESS__) || defined(__HW_IIR_EQ_PROCESS__) + switch (audio_eq_type) { #if defined(__SW_IIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_SW_IIR: - { - if(index >= EQ_SW_IIR_LIST_NUM) - { - TRACE_AUD_STREAM_W("[EQ] SET index %u > EQ_SW_IIR_LIST_NUM", index); - return 1; - } + case AUDIO_EQ_TYPE_SW_IIR: { + if (index >= EQ_SW_IIR_LIST_NUM) { + TRACE_AUD_STREAM_W("[EQ] SET index %u > EQ_SW_IIR_LIST_NUM", index); + return 1; + } - iir_cfg=audio_eq_sw_iir_cfg_list[index]; - } - break; + iir_cfg = audio_eq_sw_iir_cfg_list[index]; + } break; #endif #if defined(__HW_FIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_HW_FIR: - { - if(index >= EQ_HW_FIR_LIST_NUM) - { - TRACE_AUD_STREAM_W("[EQ] SET index %u > EQ_HW_FIR_LIST_NUM", index); - return 1; - } + case AUDIO_EQ_TYPE_HW_FIR: { + if (index >= EQ_HW_FIR_LIST_NUM) { + TRACE_AUD_STREAM_W("[EQ] SET index %u > EQ_HW_FIR_LIST_NUM", index); + return 1; + } - fir_cfg=audio_eq_hw_fir_cfg_list[index]; - } - break; + fir_cfg = audio_eq_hw_fir_cfg_list[index]; + } break; #endif #if defined(__HW_DAC_IIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_HW_DAC_IIR: - { - if(index >= EQ_HW_DAC_IIR_LIST_NUM) - { - TRACE_AUD_STREAM_W("[EQ] SET index %u > EQ_HW_DAC_IIR_LIST_NUM", index); - return 1; - } + case AUDIO_EQ_TYPE_HW_DAC_IIR: { + if (index >= EQ_HW_DAC_IIR_LIST_NUM) { + TRACE_AUD_STREAM_W("[EQ] SET index %u > EQ_HW_DAC_IIR_LIST_NUM", index); + return 1; + } - iir_cfg=audio_eq_hw_dac_iir_cfg_list[index]; - } - break; + iir_cfg = audio_eq_hw_dac_iir_cfg_list[index]; + } break; #endif #if defined(__HW_IIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_HW_IIR: - { - if(index >= EQ_HW_IIR_LIST_NUM) - { - TRACE_AUD_STREAM_W("[EQ] SET index %u > EQ_HW_IIR_LIST_NUM", index); - return 1; - } - - iir_cfg=audio_eq_hw_iir_cfg_list[index]; - } - break; -#endif - default: - { - ASSERT(false,"[%s]Error eq type!",__func__); - } + case AUDIO_EQ_TYPE_HW_IIR: { + if (index >= EQ_HW_IIR_LIST_NUM) { + TRACE_AUD_STREAM_W("[EQ] SET index %u > EQ_HW_IIR_LIST_NUM", index); + return 1; } + + iir_cfg = audio_eq_hw_iir_cfg_list[index]; + } break; +#endif + default: { + ASSERT(false, "[%s]Error eq type!", __func__); + } + } #endif #ifdef AUDIO_SECTION_ENABLE - const IIR_CFG_T *iir_cfg_from_audio_section = (const IIR_CFG_T *)load_audio_cfg_from_audio_section(AUDIO_PROCESS_TYPE_IIR_EQ); - if (iir_cfg_from_audio_section) - { - iir_cfg = iir_cfg_from_audio_section; - } + const IIR_CFG_T *iir_cfg_from_audio_section = + (const IIR_CFG_T *)load_audio_cfg_from_audio_section( + AUDIO_PROCESS_TYPE_IIR_EQ); + if (iir_cfg_from_audio_section) { + iir_cfg = iir_cfg_from_audio_section; + } #endif - return audio_eq_set_cfg(fir_cfg,iir_cfg,audio_eq_type); + return audio_eq_set_cfg(fir_cfg, iir_cfg, audio_eq_type); } -#define A2DP_PLAYER_PLAYBACK_WATER_LINE ((uint32_t)(3.f * a2dp_audio_latency_factor_get() + 0.5f)) +#define A2DP_PLAYER_PLAYBACK_WATER_LINE \ + ((uint32_t)(3.f * a2dp_audio_latency_factor_get() + 0.5f)) #define A2DP_PLAYER_PLAYBACK_WATER_LINE_UPPER (25) /******************************** AUD_BITS_16 - dma_buffer_delay_us = stream_cfg->data_size/stream_cfg->channel_num/2*1000000LL/stream_cfg->sample_rate; + dma_buffer_delay_us = + stream_cfg->data_size/stream_cfg->channel_num/2*1000000LL/stream_cfg->sample_rate; AUD_BITS_24 - dma_buffer_delay_us = stream_cfg->data_size/stream_cfg->channel_num/4*1000000LL/stream_cfg->sample_rate; + dma_buffer_delay_us = + stream_cfg->data_size/stream_cfg->channel_num/4*1000000LL/stream_cfg->sample_rate; dma_buffer_delay_us scalable delay = 864/sample*1000*n ms @@ -1915,17 +1879,23 @@ uint32_t bt_audio_set_eq(AUDIO_EQ_TYPE_T audio_eq_type, uint8_t index) #define A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_HIRES_MTU (13) #define A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_HIRES_BASE (9000) -#define A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_HIRES_US (A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_HIRES_BASE*A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_HIRES_MTU) +#define A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_HIRES_US \ + (A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_HIRES_BASE * \ + A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_HIRES_MTU) -#define A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_BASERES_MTU (6) +#define A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_BASERES_MTU (6) #define A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_BASERES_BASE (19500) -#define A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_BASERES_US (A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_BASERES_BASE*A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_BASERES_MTU) +#define A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_BASERES_US \ + (A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_BASERES_BASE * \ + A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_BASERES_MTU) /******************************** AUD_BITS_16 - dma_buffer_delay_us = stream_cfg->data_size/stream_cfg->channel_num/2*1000000LL/stream_cfg->sample_rate; + dma_buffer_delay_us = + stream_cfg->data_size/stream_cfg->channel_num/2*1000000LL/stream_cfg->sample_rate; AUD_BITS_24 - dma_buffer_delay_us = stream_cfg->data_size/stream_cfg->channel_num/4*1000000LL/stream_cfg->sample_rate; + dma_buffer_delay_us = + stream_cfg->data_size/stream_cfg->channel_num/4*1000000LL/stream_cfg->sample_rate; dma_buffer_delay_us aac delay = 1024/sample*1000*n ms @@ -1942,13 +1912,16 @@ uint32_t bt_audio_set_eq(AUDIO_EQ_TYPE_T audio_eq_type, uint8_t index) #endif #endif #define A2DP_PLAYER_PLAYBACK_DELAY_AAC_BASE (23000) -#define A2DP_PLAYER_PLAYBACK_DELAY_AAC_US (A2DP_PLAYER_PLAYBACK_DELAY_AAC_BASE*A2DP_PLAYER_PLAYBACK_DELAY_AAC_MTU) +#define A2DP_PLAYER_PLAYBACK_DELAY_AAC_US \ + (A2DP_PLAYER_PLAYBACK_DELAY_AAC_BASE * A2DP_PLAYER_PLAYBACK_DELAY_AAC_MTU) /******************************** AUD_BITS_16 - dma_buffer_delay_us = stream_cfg->data_size/stream_cfg->channel_num/2*1000000LL/stream_cfg->sample_rate; + dma_buffer_delay_us = +stream_cfg->data_size/stream_cfg->channel_num/2*1000000LL/stream_cfg->sample_rate; AUD_BITS_24 - dma_buffer_delay_us = stream_cfg->data_size/stream_cfg->channel_num/4*1000000LL/stream_cfg->sample_rate; + dma_buffer_delay_us = +stream_cfg->data_size/stream_cfg->channel_num/4*1000000LL/stream_cfg->sample_rate; sbc delay = 128/sample*n ms sbc delay = 128/44100*45 = 130ms @@ -1966,14 +1939,17 @@ uint32_t bt_audio_set_eq(AUDIO_EQ_TYPE_T audio_eq_type, uint8_t index) #endif #endif #define A2DP_PLAYER_PLAYBACK_DELAY_SBC_BASE (2800) -#define A2DP_PLAYER_PLAYBACK_DELAY_SBC_US (A2DP_PLAYER_PLAYBACK_DELAY_SBC_BASE*A2DP_PLAYER_PLAYBACK_DELAY_SBC_MTU) +#define A2DP_PLAYER_PLAYBACK_DELAY_SBC_US \ + (A2DP_PLAYER_PLAYBACK_DELAY_SBC_BASE * A2DP_PLAYER_PLAYBACK_DELAY_SBC_MTU) #if defined(A2DP_LHDC_ON) /******************************** AUD_BITS_16 - dma_buffer_delay_us = stream_cfg->data_size/stream_cfg->channel_num/2*1000000LL/stream_cfg->sample_rate; + dma_buffer_delay_us = +stream_cfg->data_size/stream_cfg->channel_num/2*1000000LL/stream_cfg->sample_rate; AUD_BITS_24 - dma_buffer_delay_us = stream_cfg->data_size/stream_cfg->channel_num/4*1000000LL/stream_cfg->sample_rate; + dma_buffer_delay_us = +stream_cfg->data_size/stream_cfg->channel_num/4*1000000LL/stream_cfg->sample_rate; lhdc delay = 512/sample*1000*n ms lhdc delay = *28 = 149ms @@ -1998,13 +1974,17 @@ uint32_t bt_audio_set_eq(AUDIO_EQ_TYPE_T audio_eq_type, uint8_t index) #else #define A2DP_PLAYER_PLAYBACK_DELAY_LHDC_HIRES_BASE (5333) #endif -#define A2DP_PLAYER_PLAYBACK_DELAY_LHDC_HIRES_US (A2DP_PLAYER_PLAYBACK_DELAY_LHDC_HIRES_MTU*A2DP_PLAYER_PLAYBACK_DELAY_LHDC_HIRES_BASE) +#define A2DP_PLAYER_PLAYBACK_DELAY_LHDC_HIRES_US \ + (A2DP_PLAYER_PLAYBACK_DELAY_LHDC_HIRES_MTU * \ + A2DP_PLAYER_PLAYBACK_DELAY_LHDC_HIRES_BASE) /******************************** AUD_BITS_16 - dma_buffer_delay_us = stream_cfg->data_size/stream_cfg->channel_num/2*1000000LL/stream_cfg->sample_rate; + dma_buffer_delay_us = +stream_cfg->data_size/stream_cfg->channel_num/2*1000000LL/stream_cfg->sample_rate; AUD_BITS_24 - dma_buffer_delay_us = stream_cfg->data_size/stream_cfg->channel_num/4*1000000LL/stream_cfg->sample_rate; + dma_buffer_delay_us = +stream_cfg->data_size/stream_cfg->channel_num/4*1000000LL/stream_cfg->sample_rate; lhdc delay = 512/sample*1000*n ms lhdc_v2 delay = 512/48000*1000*14 = 149ms @@ -2022,13 +2002,17 @@ uint32_t bt_audio_set_eq(AUDIO_EQ_TYPE_T audio_eq_type, uint8_t index) #else #define A2DP_PLAYER_PLAYBACK_DELAY_LHDC_BASERES_BASE (10666) #endif -#define A2DP_PLAYER_PLAYBACK_DELAY_LHDC_BASERES_US (A2DP_PLAYER_PLAYBACK_DELAY_LHDC_BASERES_MTU*A2DP_PLAYER_PLAYBACK_DELAY_LHDC_BASERES_BASE) +#define A2DP_PLAYER_PLAYBACK_DELAY_LHDC_BASERES_US \ + (A2DP_PLAYER_PLAYBACK_DELAY_LHDC_BASERES_MTU * \ + A2DP_PLAYER_PLAYBACK_DELAY_LHDC_BASERES_BASE) /******************************** AUD_BITS_16 - dma_buffer_delay_us = stream_cfg->data_size/stream_cfg->channel_num/2*1000000LL/stream_cfg->sample_rate; + dma_buffer_delay_us = +stream_cfg->data_size/stream_cfg->channel_num/2*1000000LL/stream_cfg->sample_rate; AUD_BITS_24 - dma_buffer_delay_us = stream_cfg->data_size/stream_cfg->channel_num/4*1000000LL/stream_cfg->sample_rate; + dma_buffer_delay_us = +stream_cfg->data_size/stream_cfg->channel_num/4*1000000LL/stream_cfg->sample_rate; lhdc delay = 512/sample*1000*n ms lhdc_v2 delay = 512/48000*1000*9 = 96ms @@ -2050,318 +2034,362 @@ uint32_t bt_audio_set_eq(AUDIO_EQ_TYPE_T audio_eq_type, uint8_t index) #else #define A2DP_PLAYER_PLAYBACK_DELAY_LHDC_LLC_BASE (10666) #endif -#define A2DP_PLAYER_PLAYBACK_DELAY_LHDC_LLC_US (A2DP_PLAYER_PLAYBACK_DELAY_LHDC_LLC_MTU*A2DP_PLAYER_PLAYBACK_DELAY_LHDC_LLC_BASE) +#define A2DP_PLAYER_PLAYBACK_DELAY_LHDC_LLC_US \ + (A2DP_PLAYER_PLAYBACK_DELAY_LHDC_LLC_MTU * \ + A2DP_PLAYER_PLAYBACK_DELAY_LHDC_LLC_BASE) #endif #if defined(A2DP_LDAC_ON) /******************************** AUD_BITS_16 - dma_buffer_delay_us = stream_cfg->data_size/stream_cfg->channel_num/2*1000000LL/stream_cfg->sample_rate; + dma_buffer_delay_us = +stream_cfg->data_size/stream_cfg->channel_num/2*1000000LL/stream_cfg->sample_rate; AUD_BITS_24 - dma_buffer_delay_us = stream_cfg->data_size/stream_cfg->channel_num/4*1000000LL/stream_cfg->sample_rate; + dma_buffer_delay_us = +stream_cfg->data_size/stream_cfg->channel_num/4*1000000LL/stream_cfg->sample_rate; ldac delay = 256/sample*1000*n ms ldac delay = 256/96000*1000*56 = 149ms audio_delay = ldac delay *********************************/ #define A2DP_PLAYER_PLAYBACK_DELAY_LDAC_FRAME_MTU (5) -#define A2DP_PLAYER_PLAYBACK_DELAY_LDAC_MTU (60) +#define A2DP_PLAYER_PLAYBACK_DELAY_LDAC_MTU (60) #define A2DP_PLAYER_PLAYBACK_DELAY_LDAC_BASE (2667) -#define A2DP_PLAYER_PLAYBACK_DELAY_LDAC_US (A2DP_PLAYER_PLAYBACK_DELAY_LDAC_BASE*A2DP_PLAYER_PLAYBACK_DELAY_LDAC_MTU) +#define A2DP_PLAYER_PLAYBACK_DELAY_LDAC_US \ + (A2DP_PLAYER_PLAYBACK_DELAY_LDAC_BASE * A2DP_PLAYER_PLAYBACK_DELAY_LDAC_MTU) #endif enum BT_STREAM_TRIGGER_STATUS_T { - BT_STREAM_TRIGGER_STATUS_NULL = 0, - BT_STREAM_TRIGGER_STATUS_INIT, - BT_STREAM_TRIGGER_STATUS_WAIT, - BT_STREAM_TRIGGER_STATUS_OK, + BT_STREAM_TRIGGER_STATUS_NULL = 0, + BT_STREAM_TRIGGER_STATUS_INIT, + BT_STREAM_TRIGGER_STATUS_WAIT, + BT_STREAM_TRIGGER_STATUS_OK, }; static uint32_t tg_acl_trigger_time = 0; static uint32_t tg_acl_trigger_start_time = 0; static uint32_t tg_acl_trigger_init_time = 0; -static enum BT_STREAM_TRIGGER_STATUS_T bt_stream_trigger_status = BT_STREAM_TRIGGER_STATUS_NULL; +static enum BT_STREAM_TRIGGER_STATUS_T bt_stream_trigger_status = + BT_STREAM_TRIGGER_STATUS_NULL; -void app_bt_stream_playback_irq_notification(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream); +void app_bt_stream_playback_irq_notification(enum AUD_STREAM_ID_T id, + enum AUD_STREAM_T stream); -inline void app_bt_stream_trigger_stauts_set(enum BT_STREAM_TRIGGER_STATUS_T stauts) -{ - TRACE_AUD_STREAM_I("[STRM_TRIG] stauts_set %d->%d", bt_stream_trigger_status,stauts); - bt_stream_trigger_status = stauts; +inline void +app_bt_stream_trigger_stauts_set(enum BT_STREAM_TRIGGER_STATUS_T stauts) { + TRACE_AUD_STREAM_I("[STRM_TRIG] stauts_set %d->%d", bt_stream_trigger_status, + stauts); + bt_stream_trigger_status = stauts; } -inline enum BT_STREAM_TRIGGER_STATUS_T app_bt_stream_trigger_stauts_get(void) -{ - TRACE_AUD_STREAM_I("[STRM_TRIG] stauts_get:%d", bt_stream_trigger_status); - return bt_stream_trigger_status; +inline enum BT_STREAM_TRIGGER_STATUS_T app_bt_stream_trigger_stauts_get(void) { + TRACE_AUD_STREAM_I("[STRM_TRIG] stauts_get:%d", bt_stream_trigger_status); + return bt_stream_trigger_status; } -uint32_t app_bt_stream_get_dma_buffer_delay_us(void) -{ - uint32_t dma_buffer_delay_us = 0; - struct AF_STREAM_CONFIG_T *stream_cfg = NULL; - if (!af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg, false)){ - if (stream_cfg->bits <= AUD_BITS_16){ - dma_buffer_delay_us = stream_cfg->data_size/stream_cfg->channel_num/2*1000000LL/stream_cfg->sample_rate; - }else{ - dma_buffer_delay_us = stream_cfg->data_size/stream_cfg->channel_num/4*1000000LL/stream_cfg->sample_rate; - } +uint32_t app_bt_stream_get_dma_buffer_delay_us(void) { + uint32_t dma_buffer_delay_us = 0; + struct AF_STREAM_CONFIG_T *stream_cfg = NULL; + if (!af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg, + false)) { + if (stream_cfg->bits <= AUD_BITS_16) { + dma_buffer_delay_us = stream_cfg->data_size / stream_cfg->channel_num / + 2 * 1000000LL / stream_cfg->sample_rate; + } else { + dma_buffer_delay_us = stream_cfg->data_size / stream_cfg->channel_num / + 4 * 1000000LL / stream_cfg->sample_rate; } - return dma_buffer_delay_us; + } + return dma_buffer_delay_us; } -uint32_t app_bt_stream_get_dma_buffer_samples(void) -{ - uint32_t dma_buffer_delay_samples = 0; - struct AF_STREAM_CONFIG_T *stream_cfg = NULL; - if (!af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg, false)){ - if (stream_cfg->bits <= AUD_BITS_16){ - dma_buffer_delay_samples = stream_cfg->data_size/stream_cfg->channel_num/2; - }else{ - dma_buffer_delay_samples = stream_cfg->data_size/stream_cfg->channel_num/4; - } +uint32_t app_bt_stream_get_dma_buffer_samples(void) { + uint32_t dma_buffer_delay_samples = 0; + struct AF_STREAM_CONFIG_T *stream_cfg = NULL; + if (!af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg, + false)) { + if (stream_cfg->bits <= AUD_BITS_16) { + dma_buffer_delay_samples = + stream_cfg->data_size / stream_cfg->channel_num / 2; + } else { + dma_buffer_delay_samples = + stream_cfg->data_size / stream_cfg->channel_num / 4; } - return dma_buffer_delay_samples; + } + return dma_buffer_delay_samples; } #if defined(IBRT) typedef enum { - APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_IDLE, - APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_ONPROCESS, - APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_SYNCOK, -}APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_TYPE; + APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_IDLE, + APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_ONPROCESS, + APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_SYNCOK, +} APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_TYPE; #define APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_CNT_LIMIT (100) -void app_bt_stream_ibrt_set_trigger_time(APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger); -void app_bt_stream_ibrt_auto_synchronize_initsync_start(APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger); -static APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T app_bt_stream_ibrt_auto_synchronize_trigger; +void app_bt_stream_ibrt_set_trigger_time( + APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger); +void app_bt_stream_ibrt_auto_synchronize_initsync_start( + APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger); +static APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T + app_bt_stream_ibrt_auto_synchronize_trigger; static uint32_t app_bt_stream_ibrt_auto_synchronize_cnt = 0; int app_bt_stream_ibrt_audio_mismatch_stopaudio(void); void app_bt_stream_ibrt_auto_synchronize_hungup(void); void app_bt_stream_ibrt_auto_synchronize_stop(void); -static APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_TYPE ibrt_auto_synchronize_status = APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_IDLE; +static APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_TYPE ibrt_auto_synchronize_status = + APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_IDLE; -int app_bt_stream_ibrt_auto_synchronize_status_set(APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_TYPE status) -{ - TRACE_AUD_STREAM_I("[AUTO_SYNC] status:%d", status); - ibrt_auto_synchronize_status = status; - return 0; +int app_bt_stream_ibrt_auto_synchronize_status_set( + APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_TYPE status) { + TRACE_AUD_STREAM_I("[AUTO_SYNC] status:%d", status); + ibrt_auto_synchronize_status = status; + return 0; } -APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_TYPE app_bt_stream_ibrt_auto_synchronize_status_get(void) -{ - TRACE_AUD_STREAM_I("[AUTO_SYNC] status:%d", ibrt_auto_synchronize_status); - return ibrt_auto_synchronize_status; +APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_TYPE +app_bt_stream_ibrt_auto_synchronize_status_get(void) { + TRACE_AUD_STREAM_I("[AUTO_SYNC] status:%d", ibrt_auto_synchronize_status); + return ibrt_auto_synchronize_status; } -int app_bt_stream_ibrt_auto_synchronize_trigger_start(btif_media_header_t * header, unsigned char *buf, unsigned int len) -{ - APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger = &app_bt_stream_ibrt_auto_synchronize_trigger; +int app_bt_stream_ibrt_auto_synchronize_trigger_start( + btif_media_header_t *header, unsigned char *buf, unsigned int len) { + APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger = + &app_bt_stream_ibrt_auto_synchronize_trigger; + app_bt_stream_ibrt_auto_synchronize_stop(); + TRACE_AUD_STREAM_I( + "[AUTO_SYNC] trigger:%d Seq:%d timestamp:%d SubSeq:%d/%d currSeq:%d", + sync_trigger->trigger_time, sync_trigger->audio_info.sequenceNumber, + sync_trigger->audio_info.timestamp, + sync_trigger->audio_info.curSubSequenceNumber, + sync_trigger->audio_info.totalSubSequenceNumber, header->sequenceNumber); + + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + + if (app_tws_ibrt_slave_ibrt_link_connected()) { + if (sync_trigger->trigger_time >= + bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle)) { + app_bt_stream_ibrt_set_trigger_time(sync_trigger); + } else { + TRACE_AUD_STREAM_W("[AUTO_SYNC]failed trigger(%d)-->tg(%d) need resume", + bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle), + sync_trigger->trigger_time); + app_ibrt_if_force_audio_retrigger(); + // app_tws_ibrt_audio_sync_mismatch_resume_notify(); + } + } else { + TRACE_AUD_STREAM_I("[AUTO_SYNC] ok but currRole:%d mismatch\n", + p_ibrt_ctrl->current_role); + app_ibrt_if_force_audio_retrigger(); + } + + return 0; +} + +int app_bt_stream_ibrt_auto_synchronize_dataind_cb(btif_media_header_t *header, + unsigned char *buf, + unsigned int len) { + APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger = + &app_bt_stream_ibrt_auto_synchronize_trigger; + bool synchronize_ok = false; + int32_t timestamp_diff = 0; + int32_t dma_buffer_samples = 0; + int32_t frame_totle_samples = 0; + + frame_totle_samples = sync_trigger->audio_info.totalSubSequenceNumber * + sync_trigger->audio_info.frame_samples; + timestamp_diff = sync_trigger->audio_info.timestamp - header->timestamp; + + TRACE_AUD_STREAM_I("[AUTO_SYNC][DATAIND] seq:%d/%d timestamp:%d/%d cnt:%d", + header->sequenceNumber, + sync_trigger->audio_info.sequenceNumber, header->timestamp, + sync_trigger->audio_info.timestamp, + app_bt_stream_ibrt_auto_synchronize_cnt); + + if (++app_bt_stream_ibrt_auto_synchronize_cnt > + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_CNT_LIMIT) { app_bt_stream_ibrt_auto_synchronize_stop(); - TRACE_AUD_STREAM_I("[AUTO_SYNC] trigger:%d Seq:%d timestamp:%d SubSeq:%d/%d currSeq:%d", - sync_trigger->trigger_time, - sync_trigger->audio_info.sequenceNumber, - sync_trigger->audio_info.timestamp, - sync_trigger->audio_info.curSubSequenceNumber, - sync_trigger->audio_info.totalSubSequenceNumber, - header->sequenceNumber - ); - - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - - if (app_tws_ibrt_slave_ibrt_link_connected()){ - if (sync_trigger->trigger_time >= bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle)){ - app_bt_stream_ibrt_set_trigger_time(sync_trigger); - }else{ - TRACE_AUD_STREAM_W("[AUTO_SYNC]failed trigger(%d)-->tg(%d) need resume", bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle), - sync_trigger->trigger_time); - app_ibrt_if_force_audio_retrigger(); - //app_tws_ibrt_audio_sync_mismatch_resume_notify(); - } - }else{ - TRACE_AUD_STREAM_I("[AUTO_SYNC] ok but currRole:%d mismatch\n", p_ibrt_ctrl->current_role); - app_ibrt_if_force_audio_retrigger(); + TRACE_AUD_STREAM_W( + "[AUTO_SYNC][DATAIND] SYNCHRONIZE_CNT_LIMIT, we need force retrigger"); + app_ibrt_if_force_audio_retrigger(); + } else if (app_tws_ibrt_mobile_link_connected()) { + app_bt_stream_ibrt_auto_synchronize_stop(); + TRACE_AUD_STREAM_W( + "[AUTO_SYNC][DATAIND] find role to master, we need force retrigger"); + app_ibrt_if_force_audio_retrigger(); + } else if (sync_trigger->audio_info.sequenceNumber < header->sequenceNumber) { + app_bt_stream_ibrt_auto_synchronize_stop(); + TRACE_AUD_STREAM_W( + "[AUTO_SYNC][DATAIND] seq timestamp:%d/%d mismatch need resume", + header->timestamp, sync_trigger->audio_info.timestamp); + app_ibrt_if_force_audio_retrigger(); + } else { + if (header->sequenceNumber >= sync_trigger->audio_info.sequenceNumber && + !sync_trigger->audio_info.totalSubSequenceNumber) { + synchronize_ok = true; + } else if (header->timestamp == sync_trigger->audio_info.timestamp) { + synchronize_ok = true; } - return 0; -} + dma_buffer_samples = app_bt_stream_get_dma_buffer_samples() / 2; -int app_bt_stream_ibrt_auto_synchronize_dataind_cb(btif_media_header_t * header, unsigned char *buf, unsigned int len) -{ - APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger = &app_bt_stream_ibrt_auto_synchronize_trigger; - bool synchronize_ok = false; - int32_t timestamp_diff = 0; - int32_t dma_buffer_samples = 0; - int32_t frame_totle_samples = 0; - - frame_totle_samples = sync_trigger->audio_info.totalSubSequenceNumber * sync_trigger->audio_info.frame_samples; - timestamp_diff = sync_trigger->audio_info.timestamp - header->timestamp; - - TRACE_AUD_STREAM_I("[AUTO_SYNC][DATAIND] seq:%d/%d timestamp:%d/%d cnt:%d", header->sequenceNumber, - sync_trigger->audio_info.sequenceNumber, - header->timestamp, - sync_trigger->audio_info.timestamp, - app_bt_stream_ibrt_auto_synchronize_cnt); - - if (++app_bt_stream_ibrt_auto_synchronize_cnt > APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_CNT_LIMIT){ - app_bt_stream_ibrt_auto_synchronize_stop(); - TRACE_AUD_STREAM_W("[AUTO_SYNC][DATAIND] SYNCHRONIZE_CNT_LIMIT, we need force retrigger"); - app_ibrt_if_force_audio_retrigger(); - }else if (app_tws_ibrt_mobile_link_connected()){ - app_bt_stream_ibrt_auto_synchronize_stop(); - TRACE_AUD_STREAM_W("[AUTO_SYNC][DATAIND] find role to master, we need force retrigger"); - app_ibrt_if_force_audio_retrigger(); - }else if (sync_trigger->audio_info.sequenceNumber < header->sequenceNumber){ - app_bt_stream_ibrt_auto_synchronize_stop(); - TRACE_AUD_STREAM_W("[AUTO_SYNC][DATAIND] seq timestamp:%d/%d mismatch need resume", header->timestamp, - sync_trigger->audio_info.timestamp); - app_ibrt_if_force_audio_retrigger(); - }else{ - if (header->sequenceNumber >= sync_trigger->audio_info.sequenceNumber && - !sync_trigger->audio_info.totalSubSequenceNumber){ - synchronize_ok = true; - }else if (header->timestamp == sync_trigger->audio_info.timestamp){ - synchronize_ok = true; - } - - dma_buffer_samples = app_bt_stream_get_dma_buffer_samples()/2; - - if (sync_trigger->audio_info.timestamp >= header->timestamp && sync_trigger->audio_info.totalSubSequenceNumber){ - if (timestamp_diff < dma_buffer_samples){ - TRACE_AUD_STREAM_I("[AUTO_SYNC][DATAIND] timestamp_diff < dma_buffer_samples synchronize ok"); - synchronize_ok = true; - }else if (timestamp_diff < frame_totle_samples){ - TRACE_AUD_STREAM_I("[AUTO_SYNC][DATAIND] timestamp_diff < frame_totle_samples synchronize ok"); - synchronize_ok = true; - } - } - - if (!synchronize_ok && header->sequenceNumber >= sync_trigger->audio_info.sequenceNumber){ - - TRACE_AUD_STREAM_I("[AUTO_SYNC][DATAIND] timestamp %d vs %d", sync_trigger->audio_info.timestamp - header->timestamp, - frame_totle_samples); - if ((sync_trigger->audio_info.timestamp - header->timestamp) <= (uint32_t)(frame_totle_samples*3)){ - sync_trigger->audio_info.sequenceNumber++; - TRACE_AUD_STREAM_I("[AUTO_SYNC][DATAIND] timestamp try sequenceNumber:%d", header->sequenceNumber); - } - } - - //flush all - a2dp_audio_synchronize_dest_packet_mut(0); - - if (synchronize_ok){ - A2DP_AUDIO_LASTFRAME_INFO_T lastframe_info; - if (a2dp_audio_lastframe_info_get(&lastframe_info) < 0){ - TRACE_AUD_STREAM_I("[AUTO_SYNC][DATAIND]synchronize ok but lastframe error"); - goto exit; - } - - TRACE_AUD_STREAM_I("[AUTO_SYNC][DATAIND]synchronize ok timestamp_diff:%d frame_samples:%d", timestamp_diff, - lastframe_info.frame_samples); - sync_trigger->trigger_type = APP_TWS_IBRT_AUDIO_TRIGGER_TYPE_LOCAL; - sync_trigger->audio_info.sequenceNumber = header->sequenceNumber; - sync_trigger->audio_info.timestamp = header->timestamp; - if (sync_trigger->audio_info.totalSubSequenceNumber){ - sync_trigger->audio_info.curSubSequenceNumber = timestamp_diff/lastframe_info.frame_samples; - TRACE_AUD_STREAM_I("[AUTO_SYNC][DATAIND]synchronize ok tstmp_diff:%d/%d SubSeq:%d", timestamp_diff, sync_trigger->audio_info.frame_samples, - sync_trigger->audio_info.curSubSequenceNumber); - }else{ - sync_trigger->audio_info.curSubSequenceNumber = 0; - } - sync_trigger->audio_info.totalSubSequenceNumber = lastframe_info.totalSubSequenceNumber; - sync_trigger->audio_info.frame_samples = lastframe_info.frame_samples; - if (sync_trigger->audio_info.totalSubSequenceNumber && - sync_trigger->audio_info.curSubSequenceNumber >= sync_trigger->audio_info.totalSubSequenceNumber){ - TRACE_AUD_STREAM_W("[AUTO_SYNC][DATAIND]synchronize ok but sbc & timestamp is ms so force trigger"); - app_bt_stream_ibrt_auto_synchronize_stop(); - app_ibrt_if_force_audio_retrigger(); - }else{ - a2dp_audio_detect_store_packet_callback_register(app_bt_stream_ibrt_auto_synchronize_trigger_start); - } - }else{ - a2dp_audio_detect_first_packet(); - } + if (sync_trigger->audio_info.timestamp >= header->timestamp && + sync_trigger->audio_info.totalSubSequenceNumber) { + if (timestamp_diff < dma_buffer_samples) { + TRACE_AUD_STREAM_I("[AUTO_SYNC][DATAIND] timestamp_diff < " + "dma_buffer_samples synchronize ok"); + synchronize_ok = true; + } else if (timestamp_diff < frame_totle_samples) { + TRACE_AUD_STREAM_I("[AUTO_SYNC][DATAIND] timestamp_diff < " + "frame_totle_samples synchronize ok"); + synchronize_ok = true; + } } + + if (!synchronize_ok && + header->sequenceNumber >= sync_trigger->audio_info.sequenceNumber) { + + TRACE_AUD_STREAM_I("[AUTO_SYNC][DATAIND] timestamp %d vs %d", + sync_trigger->audio_info.timestamp - header->timestamp, + frame_totle_samples); + if ((sync_trigger->audio_info.timestamp - header->timestamp) <= + (uint32_t)(frame_totle_samples * 3)) { + sync_trigger->audio_info.sequenceNumber++; + TRACE_AUD_STREAM_I( + "[AUTO_SYNC][DATAIND] timestamp try sequenceNumber:%d", + header->sequenceNumber); + } + } + + // flush all + a2dp_audio_synchronize_dest_packet_mut(0); + + if (synchronize_ok) { + A2DP_AUDIO_LASTFRAME_INFO_T lastframe_info; + if (a2dp_audio_lastframe_info_get(&lastframe_info) < 0) { + TRACE_AUD_STREAM_I( + "[AUTO_SYNC][DATAIND]synchronize ok but lastframe error"); + goto exit; + } + + TRACE_AUD_STREAM_I("[AUTO_SYNC][DATAIND]synchronize ok timestamp_diff:%d " + "frame_samples:%d", + timestamp_diff, lastframe_info.frame_samples); + sync_trigger->trigger_type = APP_TWS_IBRT_AUDIO_TRIGGER_TYPE_LOCAL; + sync_trigger->audio_info.sequenceNumber = header->sequenceNumber; + sync_trigger->audio_info.timestamp = header->timestamp; + if (sync_trigger->audio_info.totalSubSequenceNumber) { + sync_trigger->audio_info.curSubSequenceNumber = + timestamp_diff / lastframe_info.frame_samples; + TRACE_AUD_STREAM_I( + "[AUTO_SYNC][DATAIND]synchronize ok tstmp_diff:%d/%d SubSeq:%d", + timestamp_diff, sync_trigger->audio_info.frame_samples, + sync_trigger->audio_info.curSubSequenceNumber); + } else { + sync_trigger->audio_info.curSubSequenceNumber = 0; + } + sync_trigger->audio_info.totalSubSequenceNumber = + lastframe_info.totalSubSequenceNumber; + sync_trigger->audio_info.frame_samples = lastframe_info.frame_samples; + if (sync_trigger->audio_info.totalSubSequenceNumber && + sync_trigger->audio_info.curSubSequenceNumber >= + sync_trigger->audio_info.totalSubSequenceNumber) { + TRACE_AUD_STREAM_W("[AUTO_SYNC][DATAIND]synchronize ok but sbc & " + "timestamp is ms so force trigger"); + app_bt_stream_ibrt_auto_synchronize_stop(); + app_ibrt_if_force_audio_retrigger(); + } else { + a2dp_audio_detect_store_packet_callback_register( + app_bt_stream_ibrt_auto_synchronize_trigger_start); + } + } else { + a2dp_audio_detect_first_packet(); + } + } exit: - return 0; + return 0; } -void app_bt_stream_ibrt_auto_synchronize_start(APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger) -{ - TRACE_AUD_STREAM_I("[AUTO_SYNC][DATAIND] trigger_time:%d seq:%d timestamp:%d SubSeq:%d/%d", sync_trigger->trigger_time, - sync_trigger->audio_info.sequenceNumber, - sync_trigger->audio_info.timestamp, - sync_trigger->audio_info.curSubSequenceNumber, - sync_trigger->audio_info.totalSubSequenceNumber - ); - app_bt_stream_ibrt_auto_synchronize_status_set(APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_ONPROCESS); - app_bt_stream_ibrt_auto_synchronize_cnt = 0; - app_bt_stream_ibrt_auto_synchronize_trigger = *sync_trigger; - a2dp_audio_detect_next_packet_callback_register(app_bt_stream_ibrt_auto_synchronize_dataind_cb); - a2dp_audio_detect_first_packet(); +void app_bt_stream_ibrt_auto_synchronize_start( + APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger) { + TRACE_AUD_STREAM_I( + "[AUTO_SYNC][DATAIND] trigger_time:%d seq:%d timestamp:%d SubSeq:%d/%d", + sync_trigger->trigger_time, sync_trigger->audio_info.sequenceNumber, + sync_trigger->audio_info.timestamp, + sync_trigger->audio_info.curSubSequenceNumber, + sync_trigger->audio_info.totalSubSequenceNumber); + app_bt_stream_ibrt_auto_synchronize_status_set( + APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_ONPROCESS); + app_bt_stream_ibrt_auto_synchronize_cnt = 0; + app_bt_stream_ibrt_auto_synchronize_trigger = *sync_trigger; + a2dp_audio_detect_next_packet_callback_register( + app_bt_stream_ibrt_auto_synchronize_dataind_cb); + a2dp_audio_detect_first_packet(); } - -void app_bt_stream_ibrt_auto_synchronize_hungup(void) -{ - a2dp_audio_detect_next_packet_callback_register(NULL); - a2dp_audio_detect_store_packet_callback_register(NULL); +void app_bt_stream_ibrt_auto_synchronize_hungup(void) { + a2dp_audio_detect_next_packet_callback_register(NULL); + a2dp_audio_detect_store_packet_callback_register(NULL); } -void app_bt_stream_ibrt_auto_synchronize_stop(void) -{ - app_bt_stream_ibrt_auto_synchronize_hungup(); - app_bt_stream_ibrt_auto_synchronize_cnt = 0; - app_bt_stream_ibrt_auto_synchronize_status_set(APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_IDLE); +void app_bt_stream_ibrt_auto_synchronize_stop(void) { + app_bt_stream_ibrt_auto_synchronize_hungup(); + app_bt_stream_ibrt_auto_synchronize_cnt = 0; + app_bt_stream_ibrt_auto_synchronize_status_set( + APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_IDLE); } -bool app_bt_stream_ibrt_auto_synchronize_on_porcess(void) -{ - bool nRet = true; - APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_TYPE synchronize_status = app_bt_stream_ibrt_auto_synchronize_status_get(); - if (synchronize_status == APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_IDLE){ - nRet = false; - } - return nRet; +bool app_bt_stream_ibrt_auto_synchronize_on_porcess(void) { + bool nRet = true; + APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_TYPE synchronize_status = + app_bt_stream_ibrt_auto_synchronize_status_get(); + if (synchronize_status == APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_IDLE) { + nRet = false; + } + return nRet; } -void app_bt_stream_ibrt_start_sbc_player_callback(uint32_t status, uint32_t param) -{ - if (app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC)){ - TRACE_AUD_STREAM_I("start_sbc_player_cb trigger(%d)-->tg(%d)", param, ((APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *)(uintptr_t)param)->trigger_time); - app_bt_stream_ibrt_set_trigger_time((APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *)(uintptr_t)param); - }else{ - TRACE_AUD_STREAM_I("start_sbc_player_cb try again"); - app_audio_manager_sendrequest_need_callback( - APP_BT_STREAM_MANAGER_START,BT_STREAM_SBC, - BT_DEVICE_ID_1, - MAX_RECORD_NUM, - (uint32_t)(uintptr_t)app_bt_stream_ibrt_start_sbc_player_callback, - (uint32_t)param); - } -} - -int app_bt_stream_ibrt_start_sbc_player(APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger) -{ - TRACE_AUD_STREAM_I("start_sbc_player tg(%d)", sync_trigger->trigger_time); +void app_bt_stream_ibrt_start_sbc_player_callback(uint32_t status, + uint32_t param) { + if (app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC)) { + TRACE_AUD_STREAM_I( + "start_sbc_player_cb trigger(%d)-->tg(%d)", param, + ((APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *)(uintptr_t)param)->trigger_time); + app_bt_stream_ibrt_set_trigger_time( + (APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *)(uintptr_t)param); + } else { + TRACE_AUD_STREAM_I("start_sbc_player_cb try again"); app_audio_manager_sendrequest_need_callback( - APP_BT_STREAM_MANAGER_START,BT_STREAM_SBC, - BT_DEVICE_ID_1, - MAX_RECORD_NUM, - (uint32_t)(uintptr_t)app_bt_stream_ibrt_start_sbc_player_callback, - (uint32_t)(uintptr_t)sync_trigger); - return 0; + APP_BT_STREAM_MANAGER_START, BT_STREAM_SBC, BT_DEVICE_ID_1, + MAX_RECORD_NUM, + (uint32_t)(uintptr_t)app_bt_stream_ibrt_start_sbc_player_callback, + (uint32_t)param); + } } -uint16_t app_bt_stream_ibrt_trigger_seq_diff_calc(int32_t dma_samples, int32_t frame_samples, int32_t total_subseq, int32_t interval) -{ - float seq_factor = 1.0f; - if (total_subseq){ - seq_factor = (float)(dma_samples/frame_samples)/(float)total_subseq; - }else{ - seq_factor = (float)(dma_samples/frame_samples); - } - return (uint16_t)(seq_factor * (float)interval); +int app_bt_stream_ibrt_start_sbc_player( + APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger) { + TRACE_AUD_STREAM_I("start_sbc_player tg(%d)", sync_trigger->trigger_time); + app_audio_manager_sendrequest_need_callback( + APP_BT_STREAM_MANAGER_START, BT_STREAM_SBC, BT_DEVICE_ID_1, + MAX_RECORD_NUM, + (uint32_t)(uintptr_t)app_bt_stream_ibrt_start_sbc_player_callback, + (uint32_t)(uintptr_t)sync_trigger); + return 0; +} + +uint16_t app_bt_stream_ibrt_trigger_seq_diff_calc(int32_t dma_samples, + int32_t frame_samples, + int32_t total_subseq, + int32_t interval) { + float seq_factor = 1.0f; + if (total_subseq) { + seq_factor = (float)(dma_samples / frame_samples) / (float)total_subseq; + } else { + seq_factor = (float)(dma_samples / frame_samples); + } + return (uint16_t)(seq_factor * (float)interval); } #define MOBILE_LINK_PLAYBACK_INFO_TRIG_DUMMY_DMA_CNT (5) @@ -2370,631 +2398,713 @@ uint16_t app_bt_stream_ibrt_trigger_seq_diff_calc(int32_t dma_samples, int32_t f static int synchronize_need_discards_dma_cnt = 0; static int synchronize_dataind_cnt = 0; -int app_bt_stream_ibrt_auto_synchronize_initsync_dataind_cb_v2(btif_media_header_t * header, unsigned char *buf, unsigned int len) -{ - bool synchronize_ok = false; - bool discards_samples_finished = false; - int dest_discards_samples = 0; - uint32_t list_samples = 0; - uint32_t curr_ticks = 0; - A2DP_AUDIO_HEADFRAME_INFO_T headframe_info; - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger = &app_bt_stream_ibrt_auto_synchronize_trigger; - - synchronize_dataind_cnt++; - if (app_tws_ibrt_mobile_link_connected()){ - TRACE_AUD_STREAM_W("[AUTO_SYNCV2] mobile_link is connect retrigger because role switch"); - app_ibrt_if_force_audio_retrigger(); - return 0; - } - - if (synchronize_dataind_cnt >= SYNCHRONIZE_DATAIND_CNT_LIMIT){ - TRACE_AUD_STREAM_W("[AUTO_SYNCV2] mobile_link is connect retrigger because CNT_LIMIT"); - app_ibrt_if_force_audio_retrigger(); - return 0; - } - - dest_discards_samples = app_bt_stream_get_dma_buffer_samples()/2*synchronize_need_discards_dma_cnt; - a2dp_audio_convert_list_to_samples(&list_samples); - if ((int)list_samples > dest_discards_samples){ - discards_samples_finished = true; - a2dp_audio_discards_samples(dest_discards_samples); - } - a2dp_audio_decoder_headframe_info_get(&headframe_info); - TRACE_AUD_STREAM_I("[AUTO_SYNCV2] sample:%d->%d seq:%d sub_seq:%d/%d", - list_samples,dest_discards_samples, - headframe_info.sequenceNumber, - headframe_info.curSubSequenceNumber, - headframe_info.totalSubSequenceNumber); - - curr_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle); - TRACE_AUD_STREAM_I("[AUTO_SYNCV2] trig:%x/%x", curr_ticks, sync_trigger->trigger_time); - - if (discards_samples_finished){ - if (sync_trigger->trigger_time > curr_ticks){ - synchronize_ok = true; - }else{ - TRACE_AUD_STREAM_I("[AUTO_SYNCV2] synchronize_failed"); - app_ibrt_if_force_audio_retrigger(); - return 0; - } - } - if (synchronize_ok){ - TRACE_AUD_STREAM_I("[AUTO_SYNCV2] synchronize_ok"); - tg_acl_trigger_time = sync_trigger->trigger_time; - btdrv_syn_trigger_codec_en(1); - btdrv_syn_clr_trigger(); - btdrv_enable_playback_triggler(ACL_TRIGGLE_MODE); - bt_syn_set_tg_ticks(sync_trigger->trigger_time, p_ibrt_ctrl->ibrt_conhandle, BT_TRIG_SLAVE_ROLE); - app_tws_ibrt_audio_analysis_start(sync_trigger->handler_cnt, AUDIO_ANALYSIS_CHECKER_INTERVEL_INVALID); - app_tws_ibrt_audio_sync_start(); - app_tws_ibrt_audio_sync_new_reference(sync_trigger->factor_reference); - TRACE_AUD_STREAM_I("[AUTO_SYNCV2] trigger curr(%d)-->tg(%d)", - bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle), - sync_trigger->trigger_time); - synchronize_need_discards_dma_cnt = 0; - synchronize_dataind_cnt = 0; - a2dp_audio_detect_first_packet_clear(); - a2dp_audio_detect_next_packet_callback_register(NULL); - a2dp_audio_detect_store_packet_callback_register(NULL); - }else{ - a2dp_audio_detect_first_packet(); - } +int app_bt_stream_ibrt_auto_synchronize_initsync_dataind_cb_v2( + btif_media_header_t *header, unsigned char *buf, unsigned int len) { + bool synchronize_ok = false; + bool discards_samples_finished = false; + int dest_discards_samples = 0; + uint32_t list_samples = 0; + uint32_t curr_ticks = 0; + A2DP_AUDIO_HEADFRAME_INFO_T headframe_info; + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger = + &app_bt_stream_ibrt_auto_synchronize_trigger; + synchronize_dataind_cnt++; + if (app_tws_ibrt_mobile_link_connected()) { + TRACE_AUD_STREAM_W( + "[AUTO_SYNCV2] mobile_link is connect retrigger because role switch"); + app_ibrt_if_force_audio_retrigger(); return 0; -} + } -void app_bt_stream_ibrt_mobile_link_playback_info_receive(APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger) -{ - uint32_t tg_tick = 0; - uint32_t next_dma_cnt = 0; - A2DP_AUDIO_LASTFRAME_INFO_T lastframe_info; - A2DP_AUDIO_SYNCFRAME_INFO_T sync_info; - A2DP_AUDIO_HEADFRAME_INFO_T headframe_info; - APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger_loc = &app_bt_stream_ibrt_auto_synchronize_trigger; - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (synchronize_dataind_cnt >= SYNCHRONIZE_DATAIND_CNT_LIMIT) { + TRACE_AUD_STREAM_W( + "[AUTO_SYNCV2] mobile_link is connect retrigger because CNT_LIMIT"); + app_ibrt_if_force_audio_retrigger(); + return 0; + } - TRACE_AUD_STREAM_I("[AUTO_SYNCV2][INFO_RECV] session:%d hdl:%d clk:%d cnt:%d seq:%d/%d/%d", sync_trigger->a2dp_session, - sync_trigger->handler_cnt, - sync_trigger->trigger_bt_clk, - sync_trigger->trigger_bt_cnt, - sync_trigger->audio_info.sequenceNumber, - sync_trigger->audio_info.curSubSequenceNumber, - sync_trigger->audio_info.totalSubSequenceNumber); + dest_discards_samples = app_bt_stream_get_dma_buffer_samples() / 2 * + synchronize_need_discards_dma_cnt; + a2dp_audio_convert_list_to_samples(&list_samples); + if ((int)list_samples > dest_discards_samples) { + discards_samples_finished = true; + a2dp_audio_discards_samples(dest_discards_samples); + } + a2dp_audio_decoder_headframe_info_get(&headframe_info); + TRACE_AUD_STREAM_I("[AUTO_SYNCV2] sample:%d->%d seq:%d sub_seq:%d/%d", + list_samples, dest_discards_samples, + headframe_info.sequenceNumber, + headframe_info.curSubSequenceNumber, + headframe_info.totalSubSequenceNumber); - if (app_bt_stream_ibrt_auto_synchronize_on_porcess()){ - TRACE_AUD_STREAM_W("[AUTO_SYNCV2][INFO_RECV] auto_synchronize_on_porcess skip it"); - return; + curr_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle); + TRACE_AUD_STREAM_I("[AUTO_SYNCV2] trig:%x/%x", curr_ticks, + sync_trigger->trigger_time); + + if (discards_samples_finished) { + if (sync_trigger->trigger_time > curr_ticks) { + synchronize_ok = true; + } else { + TRACE_AUD_STREAM_I("[AUTO_SYNCV2] synchronize_failed"); + app_ibrt_if_force_audio_retrigger(); + return 0; } - - if (!app_bt_is_a2dp_streaming(BTIF_DEVICE_ID_1)){ - TRACE_AUD_STREAM_W("[AUTO_SYNCV2][INFO_RECV] streaming not ready skip it"); - app_bt_stream_ibrt_audio_mismatch_stopaudio(); - return; - } - - if (a2dp_ibrt_session_get() != sync_trigger->a2dp_session){ - TRACE_AUD_STREAM_W("[AUTO_SYNCV2][INFO_RECV] session mismatch skip it loc:%d rmt:%d", a2dp_ibrt_session_get(), sync_trigger->a2dp_session); - TRACE_AUD_STREAM_W("[AUTO_SYNCV2][INFO_RECV] session froce resume and try retrigger"); - a2dp_ibrt_session_set(sync_trigger->a2dp_session); - app_bt_stream_ibrt_audio_mismatch_stopaudio(); - return; - } - - if (a2dp_audio_lastframe_info_get(&lastframe_info) < 0){ - TRACE_AUD_STREAM_W("[AUTO_SYNCV2][INFO_RECV] lastframe not ready mismatch_stopaudio"); - app_bt_stream_ibrt_audio_mismatch_stopaudio(); - return; - } - - *sync_trigger_loc = *sync_trigger; - - sync_info.sequenceNumber = sync_trigger->audio_info.sequenceNumber; - sync_info.timestamp = sync_trigger->audio_info.timestamp; - sync_info.curSubSequenceNumber = sync_trigger->audio_info.curSubSequenceNumber; - sync_info.totalSubSequenceNumber = sync_trigger->audio_info.totalSubSequenceNumber; - sync_info.frame_samples = sync_trigger->audio_info.frame_samples; - if (a2dp_audio_synchronize_packet(&sync_info, A2DP_AUDIO_SYNCFRAME_MASK_ALL)){ - TRACE_AUD_STREAM_W("[AUTO_SYNCV2][INFO_RECV] synchronize_packe mismatch"); - app_ibrt_if_force_audio_retrigger(); - return; - } - - a2dp_audio_decoder_headframe_info_get(&headframe_info); - TRACE_AUD_STREAM_I("[AUTO_SYNCV2][INFO_RECV] sync with master packet step1 seq:%d sub_seq:%d/%d", - headframe_info.sequenceNumber, - headframe_info.curSubSequenceNumber, - headframe_info.totalSubSequenceNumber); - a2dp_audio_discards_samples(lastframe_info.list_samples); - a2dp_audio_decoder_headframe_info_get(&headframe_info); - TRACE_AUD_STREAM_I("[AUTO_SYNCV2][INFO_RECV] sync with master packet step2 seq:%d sub_seq:%d/%d", - headframe_info.sequenceNumber, - headframe_info.curSubSequenceNumber, - headframe_info.totalSubSequenceNumber); - - uint32_t btclk; - uint16_t btcnt; - uint32_t mobile_master_clk = 0; - uint16_t mobile_master_cnt = 0; - int64_t mobile_master_us = 0; - btclk = btdrv_syn_get_curr_ticks()/2; - btcnt = 0; - app_tws_ibrt_audio_mobile_clkcnt_get(btclk, btcnt, - &mobile_master_clk, &mobile_master_cnt); - mobile_master_us = (int64_t)mobile_master_clk * (int64_t)SLOT_SIZE + (int64_t)mobile_master_cnt; - - uint32_t rmt_mobile_master_clk = sync_trigger->trigger_bt_clk; - uint16_t rmt_mobile_master_cnt = sync_trigger->trigger_bt_cnt; - int64_t rmt_mobile_master_us = 0; - int64_t tmp_mobile_master_us = 0; - rmt_mobile_master_us = (int64_t)rmt_mobile_master_clk * (int64_t)SLOT_SIZE + (int64_t)rmt_mobile_master_cnt; - - uint32_t dma_buffer_us = 0; - dma_buffer_us = app_bt_stream_get_dma_buffer_delay_us()/2; - - tmp_mobile_master_us = rmt_mobile_master_us; - do{ - if (tmp_mobile_master_us - mobile_master_us >= 0){ - break; - } - tmp_mobile_master_us += dma_buffer_us; - next_dma_cnt++; - }while(1); - next_dma_cnt += MOBILE_LINK_PLAYBACK_INFO_TRIG_DUMMY_DMA_CNT ; - tmp_mobile_master_us += dma_buffer_us * (MOBILE_LINK_PLAYBACK_INFO_TRIG_DUMMY_DMA_CNT-1); - synchronize_need_discards_dma_cnt = next_dma_cnt + a2dp_audio_frame_delay_get() - 1; + } + if (synchronize_ok) { + TRACE_AUD_STREAM_I("[AUTO_SYNCV2] synchronize_ok"); + tg_acl_trigger_time = sync_trigger->trigger_time; + btdrv_syn_trigger_codec_en(1); + btdrv_syn_clr_trigger(); + btdrv_enable_playback_triggler(ACL_TRIGGLE_MODE); + bt_syn_set_tg_ticks(sync_trigger->trigger_time, p_ibrt_ctrl->ibrt_conhandle, + BT_TRIG_SLAVE_ROLE); + app_tws_ibrt_audio_analysis_start(sync_trigger->handler_cnt, + AUDIO_ANALYSIS_CHECKER_INTERVEL_INVALID); + app_tws_ibrt_audio_sync_start(); + app_tws_ibrt_audio_sync_new_reference(sync_trigger->factor_reference); + TRACE_AUD_STREAM_I("[AUTO_SYNCV2] trigger curr(%d)-->tg(%d)", + bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle), + sync_trigger->trigger_time); + synchronize_need_discards_dma_cnt = 0; synchronize_dataind_cnt = 0; - TRACE_AUD_STREAM_I("[AUTO_SYNCV2][INFO_RECV] loc:%08x%08x rmt:%08x%08x tg:%08x%08x", (uint32_t)((uint64_t)mobile_master_us>>32U), (uint32_t)((uint64_t)mobile_master_us&0xffffffff), - (uint32_t)((uint64_t)rmt_mobile_master_us>>32U), (uint32_t)((uint64_t)rmt_mobile_master_us&0xffffffff), - (uint32_t)((uint64_t)tmp_mobile_master_us>>32U), (uint32_t)((uint64_t)tmp_mobile_master_us&0xffffffff)); - - tmp_mobile_master_us = tmp_mobile_master_us/SLOT_SIZE; - - tg_tick = tmp_mobile_master_us * 2; - tg_tick &= 0x0fffffff; - - sync_trigger_loc->trigger_type = APP_TWS_IBRT_AUDIO_TRIGGER_TYPE_LOCAL; - sync_trigger_loc->trigger_time = tg_tick; - sync_trigger_loc->handler_cnt += next_dma_cnt; - a2dp_audio_detect_next_packet_callback_register(app_bt_stream_ibrt_auto_synchronize_initsync_dataind_cb_v2); - a2dp_audio_detect_first_packet(); - - - TRACE_AUD_STREAM_I("[AUTO_SYNCV2][INFO_RECV] mobile clk:%x/%x tg:%x", bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle)/2, - mobile_master_clk, - tg_tick/2); - - TRACE_AUD_STREAM_I("[AUTO_SYNCV2][INFO_RECV] master_us:%x/%x/%x dma_cnt:%d/%d", (int32_t)mobile_master_us, (int32_t)rmt_mobile_master_us, (int32_t)tmp_mobile_master_us, - next_dma_cnt, sync_trigger_loc->handler_cnt); -} - - -void app_bt_stream_ibrt_set_trigger_time(APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger) -{ - uint32_t curr_ticks = 0; - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - uint32_t tg_tick = sync_trigger->trigger_time; - A2DP_AUDIO_SYNCFRAME_INFO_T sync_info; - int synchronize_ret; - A2DP_AUDIO_LASTFRAME_INFO_T lastframe_info; - A2DP_AUDIO_HEADFRAME_INFO_T headframe_info; - - if (app_bt_stream_ibrt_auto_synchronize_on_porcess()){ - TRACE_AUD_STREAM_W("[STRM_TRIG][A2DP][IBRT] auto_synchronize_on_porcess skip it"); - return; - } - - if (!app_bt_is_a2dp_streaming(BTIF_DEVICE_ID_1)){ - TRACE_AUD_STREAM_W("[STRM_TRIG][A2DP][IBRT] streaming not ready skip it"); - app_bt_stream_ibrt_audio_mismatch_stopaudio(); - return; - } - - if (a2dp_ibrt_session_get() != sync_trigger->a2dp_session){ - TRACE_AUD_STREAM_W("[STRM_TRIG][A2DP][IBRT] session mismatch skip it loc:%d rmt:%d", a2dp_ibrt_session_get(), sync_trigger->a2dp_session); - TRACE_AUD_STREAM_W("[STRM_TRIG][A2DP][IBRT] session froce resume and try retrigger"); - a2dp_ibrt_session_set(sync_trigger->a2dp_session); - app_bt_stream_ibrt_audio_mismatch_stopaudio(); - return; - } - - if (a2dp_audio_lastframe_info_get(&lastframe_info) < 0){ - TRACE_AUD_STREAM_W("[STRM_TRIG][A2DP][IBRT] lastframe not ready mismatch_stopaudio"); - app_bt_stream_ibrt_audio_mismatch_stopaudio(); - return; - } - - if (a2dp_audio_decoder_headframe_info_get(&headframe_info) < 0){ - TRACE_AUD_STREAM_W("[STRM_TRIG][A2DP][IBRT] lastframe not ready mismatch_stopaudio"); - app_bt_stream_ibrt_audio_mismatch_stopaudio(); - goto exit; - } - TRACE_AUD_STREAM_W("[STRM_TRIG][A2DP][IBRT] info base_seq:%d/%d", headframe_info.sequenceNumber, sync_trigger->sequenceNumberStart); - + a2dp_audio_detect_first_packet_clear(); a2dp_audio_detect_next_packet_callback_register(NULL); a2dp_audio_detect_store_packet_callback_register(NULL); + } else { + a2dp_audio_detect_first_packet(); + } - sync_info.sequenceNumber = sync_trigger->sequenceNumberStart; - synchronize_ret = a2dp_audio_synchronize_packet(&sync_info, A2DP_AUDIO_SYNCFRAME_MASK_SEQ); - if (synchronize_ret){ - TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][IBRT] synchronize_packet failed"); - app_bt_stream_ibrt_audio_mismatch_stopaudio(); - goto exit; - } + return 0; +} - curr_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle); - if (tg_tick < curr_ticks){ - TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][IBRT] synchronize tick failed:%x->%x", curr_ticks, tg_tick); - app_bt_stream_ibrt_audio_mismatch_stopaudio(); - goto exit; - } - sync_info.sequenceNumber = sync_trigger->audio_info.sequenceNumber; - sync_info.timestamp = sync_trigger->audio_info.timestamp; - sync_info.curSubSequenceNumber = sync_trigger->audio_info.curSubSequenceNumber; - sync_info.totalSubSequenceNumber = sync_trigger->audio_info.totalSubSequenceNumber; - sync_info.frame_samples = sync_trigger->audio_info.frame_samples; +void app_bt_stream_ibrt_mobile_link_playback_info_receive( + APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger) { + uint32_t tg_tick = 0; + uint32_t next_dma_cnt = 0; + A2DP_AUDIO_LASTFRAME_INFO_T lastframe_info; + A2DP_AUDIO_SYNCFRAME_INFO_T sync_info; + A2DP_AUDIO_HEADFRAME_INFO_T headframe_info; + APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger_loc = + &app_bt_stream_ibrt_auto_synchronize_trigger; + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (app_tws_ibrt_slave_ibrt_link_connected()){ - if (app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC)){ - if (sync_trigger->trigger_type == APP_TWS_IBRT_AUDIO_TRIGGER_TYPE_INIT_SYNC){ - TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][IBRT] TRIGGER_TYPE_INIT_SYNC needskip:%d", sync_trigger->trigger_skip_frame); - //limter to water line upper - uint32_t list_samples = 0; - uint32_t limter_water_line_samples = 0; - limter_water_line_samples = (a2dp_audio_dest_packet_mut_get() * lastframe_info.list_samples); - a2dp_audio_convert_list_to_samples(&list_samples); - TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][IBRT] synchronize:%d/%d", list_samples, limter_water_line_samples); - if (list_samples > limter_water_line_samples){ - TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][IBRT] skip discards:%d", list_samples - limter_water_line_samples); - a2dp_audio_discards_samples(list_samples - limter_water_line_samples); - } - app_bt_stream_ibrt_auto_synchronize_initsync_start(sync_trigger); - app_bt_stream_ibrt_auto_synchronize_status_set(APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_SYNCOK); - } - }else if (!app_bt_stream_isrun(APP_BT_STREAM_HFP_PCM)){ - TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][IBRT] sbc player not active, so try to start it"); - app_bt_stream_ibrt_auto_synchronize_trigger = *sync_trigger; - app_bt_stream_ibrt_audio_mismatch_stopaudio(); - } - }else{ - TRACE_AUD_STREAM_W("[STRM_TRIG][A2DP][IBRT] Not Connected"); - } -exit: + TRACE_AUD_STREAM_I( + "[AUTO_SYNCV2][INFO_RECV] session:%d hdl:%d clk:%d cnt:%d seq:%d/%d/%d", + sync_trigger->a2dp_session, sync_trigger->handler_cnt, + sync_trigger->trigger_bt_clk, sync_trigger->trigger_bt_cnt, + sync_trigger->audio_info.sequenceNumber, + sync_trigger->audio_info.curSubSequenceNumber, + sync_trigger->audio_info.totalSubSequenceNumber); + + if (app_bt_stream_ibrt_auto_synchronize_on_porcess()) { + TRACE_AUD_STREAM_W( + "[AUTO_SYNCV2][INFO_RECV] auto_synchronize_on_porcess skip it"); return; + } + + if (!app_bt_is_a2dp_streaming(BTIF_DEVICE_ID_1)) { + TRACE_AUD_STREAM_W("[AUTO_SYNCV2][INFO_RECV] streaming not ready skip it"); + app_bt_stream_ibrt_audio_mismatch_stopaudio(); + return; + } + + if (a2dp_ibrt_session_get() != sync_trigger->a2dp_session) { + TRACE_AUD_STREAM_W( + "[AUTO_SYNCV2][INFO_RECV] session mismatch skip it loc:%d rmt:%d", + a2dp_ibrt_session_get(), sync_trigger->a2dp_session); + TRACE_AUD_STREAM_W( + "[AUTO_SYNCV2][INFO_RECV] session froce resume and try retrigger"); + a2dp_ibrt_session_set(sync_trigger->a2dp_session); + app_bt_stream_ibrt_audio_mismatch_stopaudio(); + return; + } + + if (a2dp_audio_lastframe_info_get(&lastframe_info) < 0) { + TRACE_AUD_STREAM_W( + "[AUTO_SYNCV2][INFO_RECV] lastframe not ready mismatch_stopaudio"); + app_bt_stream_ibrt_audio_mismatch_stopaudio(); + return; + } + + *sync_trigger_loc = *sync_trigger; + + sync_info.sequenceNumber = sync_trigger->audio_info.sequenceNumber; + sync_info.timestamp = sync_trigger->audio_info.timestamp; + sync_info.curSubSequenceNumber = + sync_trigger->audio_info.curSubSequenceNumber; + sync_info.totalSubSequenceNumber = + sync_trigger->audio_info.totalSubSequenceNumber; + sync_info.frame_samples = sync_trigger->audio_info.frame_samples; + if (a2dp_audio_synchronize_packet(&sync_info, + A2DP_AUDIO_SYNCFRAME_MASK_ALL)) { + TRACE_AUD_STREAM_W("[AUTO_SYNCV2][INFO_RECV] synchronize_packe mismatch"); + app_ibrt_if_force_audio_retrigger(); + return; + } + + a2dp_audio_decoder_headframe_info_get(&headframe_info); + TRACE_AUD_STREAM_I("[AUTO_SYNCV2][INFO_RECV] sync with master packet step1 " + "seq:%d sub_seq:%d/%d", + headframe_info.sequenceNumber, + headframe_info.curSubSequenceNumber, + headframe_info.totalSubSequenceNumber); + a2dp_audio_discards_samples(lastframe_info.list_samples); + a2dp_audio_decoder_headframe_info_get(&headframe_info); + TRACE_AUD_STREAM_I("[AUTO_SYNCV2][INFO_RECV] sync with master packet step2 " + "seq:%d sub_seq:%d/%d", + headframe_info.sequenceNumber, + headframe_info.curSubSequenceNumber, + headframe_info.totalSubSequenceNumber); + + uint32_t btclk; + uint16_t btcnt; + uint32_t mobile_master_clk = 0; + uint16_t mobile_master_cnt = 0; + int64_t mobile_master_us = 0; + btclk = btdrv_syn_get_curr_ticks() / 2; + btcnt = 0; + app_tws_ibrt_audio_mobile_clkcnt_get(btclk, btcnt, &mobile_master_clk, + &mobile_master_cnt); + mobile_master_us = (int64_t)mobile_master_clk * (int64_t)SLOT_SIZE + + (int64_t)mobile_master_cnt; + + uint32_t rmt_mobile_master_clk = sync_trigger->trigger_bt_clk; + uint16_t rmt_mobile_master_cnt = sync_trigger->trigger_bt_cnt; + int64_t rmt_mobile_master_us = 0; + int64_t tmp_mobile_master_us = 0; + rmt_mobile_master_us = (int64_t)rmt_mobile_master_clk * (int64_t)SLOT_SIZE + + (int64_t)rmt_mobile_master_cnt; + + uint32_t dma_buffer_us = 0; + dma_buffer_us = app_bt_stream_get_dma_buffer_delay_us() / 2; + + tmp_mobile_master_us = rmt_mobile_master_us; + do { + if (tmp_mobile_master_us - mobile_master_us >= 0) { + break; + } + tmp_mobile_master_us += dma_buffer_us; + next_dma_cnt++; + } while (1); + next_dma_cnt += MOBILE_LINK_PLAYBACK_INFO_TRIG_DUMMY_DMA_CNT; + tmp_mobile_master_us += + dma_buffer_us * (MOBILE_LINK_PLAYBACK_INFO_TRIG_DUMMY_DMA_CNT - 1); + synchronize_need_discards_dma_cnt = + next_dma_cnt + a2dp_audio_frame_delay_get() - 1; + synchronize_dataind_cnt = 0; + TRACE_AUD_STREAM_I( + "[AUTO_SYNCV2][INFO_RECV] loc:%08x%08x rmt:%08x%08x tg:%08x%08x", + (uint32_t)((uint64_t)mobile_master_us >> 32U), + (uint32_t)((uint64_t)mobile_master_us & 0xffffffff), + (uint32_t)((uint64_t)rmt_mobile_master_us >> 32U), + (uint32_t)((uint64_t)rmt_mobile_master_us & 0xffffffff), + (uint32_t)((uint64_t)tmp_mobile_master_us >> 32U), + (uint32_t)((uint64_t)tmp_mobile_master_us & 0xffffffff)); + + tmp_mobile_master_us = tmp_mobile_master_us / SLOT_SIZE; + + tg_tick = tmp_mobile_master_us * 2; + tg_tick &= 0x0fffffff; + + sync_trigger_loc->trigger_type = APP_TWS_IBRT_AUDIO_TRIGGER_TYPE_LOCAL; + sync_trigger_loc->trigger_time = tg_tick; + sync_trigger_loc->handler_cnt += next_dma_cnt; + a2dp_audio_detect_next_packet_callback_register( + app_bt_stream_ibrt_auto_synchronize_initsync_dataind_cb_v2); + a2dp_audio_detect_first_packet(); + + TRACE_AUD_STREAM_I("[AUTO_SYNCV2][INFO_RECV] mobile clk:%x/%x tg:%x", + bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle) / 2, + mobile_master_clk, tg_tick / 2); + + TRACE_AUD_STREAM_I( + "[AUTO_SYNCV2][INFO_RECV] master_us:%x/%x/%x dma_cnt:%d/%d", + (int32_t)mobile_master_us, (int32_t)rmt_mobile_master_us, + (int32_t)tmp_mobile_master_us, next_dma_cnt, + sync_trigger_loc->handler_cnt); } -void app_bt_stream_ibrt_audio_mismatch_resume(void) -{ - ibrt_a2dp_status_t a2dp_status; +void app_bt_stream_ibrt_set_trigger_time( + APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger) { + uint32_t curr_ticks = 0; + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + uint32_t tg_tick = sync_trigger->trigger_time; + A2DP_AUDIO_SYNCFRAME_INFO_T sync_info; + int synchronize_ret; + A2DP_AUDIO_LASTFRAME_INFO_T lastframe_info; + A2DP_AUDIO_HEADFRAME_INFO_T headframe_info; - a2dp_ibrt_sync_get_status(&a2dp_status); + if (app_bt_stream_ibrt_auto_synchronize_on_porcess()) { + TRACE_AUD_STREAM_W( + "[STRM_TRIG][A2DP][IBRT] auto_synchronize_on_porcess skip it"); + return; + } - TRACE_AUD_STREAM_I("[MISMATCH] resume state:%d", a2dp_status.state); + if (!app_bt_is_a2dp_streaming(BTIF_DEVICE_ID_1)) { + TRACE_AUD_STREAM_W("[STRM_TRIG][A2DP][IBRT] streaming not ready skip it"); + app_bt_stream_ibrt_audio_mismatch_stopaudio(); + return; + } - if (a2dp_status.state == BTIF_AVDTP_STRM_STATE_STREAMING){ - if (app_tws_ibrt_mobile_link_connected()){ - TRACE_AUD_STREAM_I("[MISMATCH] resume find role switch so force retrigger"); - app_ibrt_if_force_audio_retrigger(); - }else{ - app_tws_ibrt_audio_sync_mismatch_resume_notify(); + if (a2dp_ibrt_session_get() != sync_trigger->a2dp_session) { + TRACE_AUD_STREAM_W( + "[STRM_TRIG][A2DP][IBRT] session mismatch skip it loc:%d rmt:%d", + a2dp_ibrt_session_get(), sync_trigger->a2dp_session); + TRACE_AUD_STREAM_W( + "[STRM_TRIG][A2DP][IBRT] session froce resume and try retrigger"); + a2dp_ibrt_session_set(sync_trigger->a2dp_session); + app_bt_stream_ibrt_audio_mismatch_stopaudio(); + return; + } + + if (a2dp_audio_lastframe_info_get(&lastframe_info) < 0) { + TRACE_AUD_STREAM_W( + "[STRM_TRIG][A2DP][IBRT] lastframe not ready mismatch_stopaudio"); + app_bt_stream_ibrt_audio_mismatch_stopaudio(); + return; + } + + if (a2dp_audio_decoder_headframe_info_get(&headframe_info) < 0) { + TRACE_AUD_STREAM_W( + "[STRM_TRIG][A2DP][IBRT] lastframe not ready mismatch_stopaudio"); + app_bt_stream_ibrt_audio_mismatch_stopaudio(); + goto exit; + } + TRACE_AUD_STREAM_W("[STRM_TRIG][A2DP][IBRT] info base_seq:%d/%d", + headframe_info.sequenceNumber, + sync_trigger->sequenceNumberStart); + + a2dp_audio_detect_next_packet_callback_register(NULL); + a2dp_audio_detect_store_packet_callback_register(NULL); + + sync_info.sequenceNumber = sync_trigger->sequenceNumberStart; + synchronize_ret = + a2dp_audio_synchronize_packet(&sync_info, A2DP_AUDIO_SYNCFRAME_MASK_SEQ); + if (synchronize_ret) { + TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][IBRT] synchronize_packet failed"); + app_bt_stream_ibrt_audio_mismatch_stopaudio(); + goto exit; + } + + curr_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle); + if (tg_tick < curr_ticks) { + TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][IBRT] synchronize tick failed:%x->%x", + curr_ticks, tg_tick); + app_bt_stream_ibrt_audio_mismatch_stopaudio(); + goto exit; + } + sync_info.sequenceNumber = sync_trigger->audio_info.sequenceNumber; + sync_info.timestamp = sync_trigger->audio_info.timestamp; + sync_info.curSubSequenceNumber = + sync_trigger->audio_info.curSubSequenceNumber; + sync_info.totalSubSequenceNumber = + sync_trigger->audio_info.totalSubSequenceNumber; + sync_info.frame_samples = sync_trigger->audio_info.frame_samples; + + if (app_tws_ibrt_slave_ibrt_link_connected()) { + if (app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC)) { + if (sync_trigger->trigger_type == + APP_TWS_IBRT_AUDIO_TRIGGER_TYPE_INIT_SYNC) { + TRACE_AUD_STREAM_I( + "[STRM_TRIG][A2DP][IBRT] TRIGGER_TYPE_INIT_SYNC needskip:%d", + sync_trigger->trigger_skip_frame); + // limter to water line upper + uint32_t list_samples = 0; + uint32_t limter_water_line_samples = 0; + limter_water_line_samples = + (a2dp_audio_dest_packet_mut_get() * lastframe_info.list_samples); + a2dp_audio_convert_list_to_samples(&list_samples); + TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][IBRT] synchronize:%d/%d", + list_samples, limter_water_line_samples); + if (list_samples > limter_water_line_samples) { + TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][IBRT] skip discards:%d", + list_samples - limter_water_line_samples); + a2dp_audio_discards_samples(list_samples - limter_water_line_samples); } + app_bt_stream_ibrt_auto_synchronize_initsync_start(sync_trigger); + app_bt_stream_ibrt_auto_synchronize_status_set( + APP_TWS_IBRT_AUDIO_SYNCHRONIZE_STATUS_SYNCOK); + } + } else if (!app_bt_stream_isrun(APP_BT_STREAM_HFP_PCM)) { + TRACE_AUD_STREAM_I( + "[STRM_TRIG][A2DP][IBRT] sbc player not active, so try to start it"); + app_bt_stream_ibrt_auto_synchronize_trigger = *sync_trigger; + app_bt_stream_ibrt_audio_mismatch_stopaudio(); } + } else { + TRACE_AUD_STREAM_W("[STRM_TRIG][A2DP][IBRT] Not Connected"); + } +exit: + return; } -void app_bt_stream_ibrt_audio_mismatch_stopaudio_cb(uint32_t status, uint32_t param) -{ - TRACE_AUD_STREAM_I("[MISMATCH] stopaudio_cb"); +void app_bt_stream_ibrt_audio_mismatch_resume(void) { + ibrt_a2dp_status_t a2dp_status; - if (app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC)){ - TRACE_AUD_STREAM_I("[MISMATCH] stopaudio_cb try again"); - app_audio_manager_sendrequest_need_callback( - APP_BT_STREAM_MANAGER_STOP,BT_STREAM_SBC, - BT_DEVICE_ID_1, - MAX_RECORD_NUM, - (uintptr_t)app_bt_stream_ibrt_audio_mismatch_stopaudio_cb, - (uint32_t)NULL); - }else{ - app_bt_stream_ibrt_audio_mismatch_resume(); + a2dp_ibrt_sync_get_status(&a2dp_status); + + TRACE_AUD_STREAM_I("[MISMATCH] resume state:%d", a2dp_status.state); + + if (a2dp_status.state == BTIF_AVDTP_STRM_STATE_STREAMING) { + if (app_tws_ibrt_mobile_link_connected()) { + TRACE_AUD_STREAM_I( + "[MISMATCH] resume find role switch so force retrigger"); + app_ibrt_if_force_audio_retrigger(); + } else { + app_tws_ibrt_audio_sync_mismatch_resume_notify(); } + } } -int app_bt_stream_ibrt_audio_mismatch_stopaudio(void) -{ - ibrt_a2dp_status_t a2dp_status; +void app_bt_stream_ibrt_audio_mismatch_stopaudio_cb(uint32_t status, + uint32_t param) { + TRACE_AUD_STREAM_I("[MISMATCH] stopaudio_cb"); - a2dp_ibrt_sync_get_status(&a2dp_status); + if (app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC)) { + TRACE_AUD_STREAM_I("[MISMATCH] stopaudio_cb try again"); + app_audio_manager_sendrequest_need_callback( + APP_BT_STREAM_MANAGER_STOP, BT_STREAM_SBC, BT_DEVICE_ID_1, + MAX_RECORD_NUM, + (uintptr_t)app_bt_stream_ibrt_audio_mismatch_stopaudio_cb, + (uint32_t)NULL); + } else { + app_bt_stream_ibrt_audio_mismatch_resume(); + } +} - TRACE_AUD_STREAM_I("[MISMATCH] stopaudio state:%d sco:%d sbc:%d media:%d", a2dp_status.state, - app_audio_manager_hfp_is_active(BT_DEVICE_ID_1), - app_audio_manager_a2dp_is_active(BT_DEVICE_ID_1), - app_bt_stream_isrun(APP_PLAY_BACK_AUDIO)); +int app_bt_stream_ibrt_audio_mismatch_stopaudio(void) { + ibrt_a2dp_status_t a2dp_status; - if (a2dp_status.state == BTIF_AVDTP_STRM_STATE_STREAMING){ - if (app_audio_manager_a2dp_is_active(BT_DEVICE_ID_1)){ - TRACE_AUD_STREAM_I("[MISMATCH] stopaudio"); - app_audio_sendrequest_param(APP_BT_STREAM_A2DP_SBC, (uint8_t)APP_BT_SETTING_RESTART, 0, APP_SYSFREQ_52M); - app_bt_stream_ibrt_audio_mismatch_resume(); - }else{ - if (app_ibrt_ui_is_profile_exchanged()){ - if (!bt_media_is_sbc_media_active()){ - TRACE_AUD_STREAM_I("[MISMATCH] stopaudio not active resume it & force retrigger"); - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START,BT_STREAM_SBC, BT_DEVICE_ID_1,MAX_RECORD_NUM); - app_ibrt_if_force_audio_retrigger(); - }else{ - if (app_bt_stream_isrun(APP_PLAY_BACK_AUDIO) + a2dp_ibrt_sync_get_status(&a2dp_status); + + TRACE_AUD_STREAM_I("[MISMATCH] stopaudio state:%d sco:%d sbc:%d media:%d", + a2dp_status.state, + app_audio_manager_hfp_is_active(BT_DEVICE_ID_1), + app_audio_manager_a2dp_is_active(BT_DEVICE_ID_1), + app_bt_stream_isrun(APP_PLAY_BACK_AUDIO)); + + if (a2dp_status.state == BTIF_AVDTP_STRM_STATE_STREAMING) { + if (app_audio_manager_a2dp_is_active(BT_DEVICE_ID_1)) { + TRACE_AUD_STREAM_I("[MISMATCH] stopaudio"); + app_audio_sendrequest_param(APP_BT_STREAM_A2DP_SBC, + (uint8_t)APP_BT_SETTING_RESTART, 0, + APP_SYSFREQ_52M); + app_bt_stream_ibrt_audio_mismatch_resume(); + } else { + if (app_ibrt_ui_is_profile_exchanged()) { + if (!bt_media_is_sbc_media_active()) { + TRACE_AUD_STREAM_I( + "[MISMATCH] stopaudio not active resume it & force retrigger"); + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, + BT_STREAM_SBC, BT_DEVICE_ID_1, + MAX_RECORD_NUM); + app_ibrt_if_force_audio_retrigger(); + } else { + if (app_bt_stream_isrun(APP_PLAY_BACK_AUDIO) #ifdef MEDIA_PLAYER_SUPPORT - &&app_play_audio_get_aud_id() == AUDIO_ID_BT_MUTE + && app_play_audio_get_aud_id() == AUDIO_ID_BT_MUTE #endif - ){ - TRACE_AUD_STREAM_I("[MISMATCH] stopaudio resum on process skip it"); - }else{ - TRACE_AUD_STREAM_I("[MISMATCH] stopaudio cancel_media and force retrigger"); - app_ibrt_if_force_audio_retrigger(); - } - } - }else{ - TRACE_AUD_STREAM_I("[MISMATCH] stopaudio profile not exchanged skip it"); - } + ) { + TRACE_AUD_STREAM_I("[MISMATCH] stopaudio resum on process skip it"); + } else { + TRACE_AUD_STREAM_I( + "[MISMATCH] stopaudio cancel_media and force retrigger"); + app_ibrt_if_force_audio_retrigger(); + } } + } else { + TRACE_AUD_STREAM_I( + "[MISMATCH] stopaudio profile not exchanged skip it"); + } } + } - return 0; + return 0; } #endif -void app_bt_stream_set_trigger_time(uint32_t trigger_time_us) -{ - struct AF_STREAM_CONFIG_T *stream_cfg = NULL; - uint32_t curr_ticks = 0; - uint32_t dma_buffer_delay_us = 0; - uint32_t tg_acl_trigger_offset_time = 0; +void app_bt_stream_set_trigger_time(uint32_t trigger_time_us) { + struct AF_STREAM_CONFIG_T *stream_cfg = NULL; + uint32_t curr_ticks = 0; + uint32_t dma_buffer_delay_us = 0; + uint32_t tg_acl_trigger_offset_time = 0; - - if (trigger_time_us){ + if (trigger_time_us) { #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - uint16_t conhandle = INVALID_HANDLE; - if (app_tws_ibrt_mobile_link_connected()){ - conhandle = p_ibrt_ctrl->mobile_conhandle; - curr_ticks = bt_syn_get_curr_ticks(conhandle); - }else if (app_tws_ibrt_slave_ibrt_link_connected()){ - conhandle = p_ibrt_ctrl->ibrt_conhandle; - curr_ticks = bt_syn_get_curr_ticks(conhandle); - }else{ - return; - } -#else - curr_ticks = btdrv_syn_get_curr_ticks(); -#endif - af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg, false); - btdrv_syn_trigger_codec_en(0); - btdrv_syn_clr_trigger(); - - btdrv_enable_playback_triggler(ACL_TRIGGLE_MODE); - - dma_buffer_delay_us = app_bt_stream_get_dma_buffer_delay_us(); - dma_buffer_delay_us /= 2; - TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][SETTIME] %d-%d-%d dma_sz:%d dly:%d", stream_cfg->sample_rate, stream_cfg->channel_num, stream_cfg->bits, - stream_cfg->data_size, dma_buffer_delay_us); - - tg_acl_trigger_offset_time = US_TO_BTCLKS(trigger_time_us-dma_buffer_delay_us); - tg_acl_trigger_time = curr_ticks + tg_acl_trigger_offset_time; - tg_acl_trigger_start_time = curr_ticks; -#if defined(IBRT) - bt_syn_set_tg_ticks(tg_acl_trigger_time, conhandle, BT_TRIG_SLAVE_ROLE); - TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][SETTIME] %d->%d trig_dly:%d aud_dly:%dus", - curr_ticks, tg_acl_trigger_time, trigger_time_us-dma_buffer_delay_us, trigger_time_us+dma_buffer_delay_us); -#else - bt_syn_set_tg_ticks(tg_acl_trigger_time, 0, BT_TRIG_NONE_ROLE); - TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][SETTIME] %d->%d trig_dly:%d aud_dly:%dus", - curr_ticks, tg_acl_trigger_time, trigger_time_us-dma_buffer_delay_us, trigger_time_us+dma_buffer_delay_us); -#endif - - btdrv_syn_trigger_codec_en(1); - app_bt_stream_trigger_stauts_set(BT_STREAM_TRIGGER_STATUS_WAIT); - }else{ - tg_acl_trigger_time = 0; - tg_acl_trigger_start_time = 0; - btdrv_syn_trigger_codec_en(0); - btdrv_syn_clr_trigger(); - app_bt_stream_trigger_stauts_set(BT_STREAM_TRIGGER_STATUS_NULL); - TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][SETTIME] trigger clear"); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + uint16_t conhandle = INVALID_HANDLE; + if (app_tws_ibrt_mobile_link_connected()) { + conhandle = p_ibrt_ctrl->mobile_conhandle; + curr_ticks = bt_syn_get_curr_ticks(conhandle); + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + conhandle = p_ibrt_ctrl->ibrt_conhandle; + curr_ticks = bt_syn_get_curr_ticks(conhandle); + } else { + return; } +#else + curr_ticks = btdrv_syn_get_curr_ticks(); +#endif + af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg, false); + btdrv_syn_trigger_codec_en(0); + btdrv_syn_clr_trigger(); + + btdrv_enable_playback_triggler(ACL_TRIGGLE_MODE); + + dma_buffer_delay_us = app_bt_stream_get_dma_buffer_delay_us(); + dma_buffer_delay_us /= 2; + TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][SETTIME] %d-%d-%d dma_sz:%d dly:%d", + stream_cfg->sample_rate, stream_cfg->channel_num, + stream_cfg->bits, stream_cfg->data_size, + dma_buffer_delay_us); + + tg_acl_trigger_offset_time = + US_TO_BTCLKS(trigger_time_us - dma_buffer_delay_us); + tg_acl_trigger_time = curr_ticks + tg_acl_trigger_offset_time; + tg_acl_trigger_start_time = curr_ticks; +#if defined(IBRT) + bt_syn_set_tg_ticks(tg_acl_trigger_time, conhandle, BT_TRIG_SLAVE_ROLE); + TRACE_AUD_STREAM_I( + "[STRM_TRIG][A2DP][SETTIME] %d->%d trig_dly:%d aud_dly:%dus", + curr_ticks, tg_acl_trigger_time, trigger_time_us - dma_buffer_delay_us, + trigger_time_us + dma_buffer_delay_us); +#else + bt_syn_set_tg_ticks(tg_acl_trigger_time, 0, BT_TRIG_NONE_ROLE); + TRACE_AUD_STREAM_I( + "[STRM_TRIG][A2DP][SETTIME] %d->%d trig_dly:%d aud_dly:%dus", + curr_ticks, tg_acl_trigger_time, trigger_time_us - dma_buffer_delay_us, + trigger_time_us + dma_buffer_delay_us); +#endif + + btdrv_syn_trigger_codec_en(1); + app_bt_stream_trigger_stauts_set(BT_STREAM_TRIGGER_STATUS_WAIT); + } else { + tg_acl_trigger_time = 0; + tg_acl_trigger_start_time = 0; + btdrv_syn_trigger_codec_en(0); + btdrv_syn_clr_trigger(); + app_bt_stream_trigger_stauts_set(BT_STREAM_TRIGGER_STATUS_NULL); + TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][SETTIME] trigger clear"); + } } -void app_bt_stream_trigger_result(void) -{ - uint32_t curr_ticks = 0; +void app_bt_stream_trigger_result(void) { + uint32_t curr_ticks = 0; - if(tg_acl_trigger_time){ + if (tg_acl_trigger_time) { #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (app_tws_ibrt_mobile_link_connected()){ - curr_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->mobile_conhandle); - bt_syn_trig_checker(p_ibrt_ctrl->mobile_conhandle); - }else if (app_tws_ibrt_slave_ibrt_link_connected()){ - curr_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle); - bt_syn_trig_checker(p_ibrt_ctrl->ibrt_conhandle); - }else{ - TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][RESULT] mobile_link:%d %04x ibrt_link:%d %04x", app_tws_ibrt_mobile_link_connected(), p_ibrt_ctrl->mobile_conhandle, - app_tws_ibrt_slave_ibrt_link_connected(), p_ibrt_ctrl->ibrt_conhandle); - } -#else - curr_ticks = btdrv_syn_get_curr_ticks(); -#endif - TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][RESULT] trig:%d curr:%d tg:%d start:%d", (curr_ticks - (uint32_t)US_TO_BTCLKS(app_bt_stream_get_dma_buffer_delay_us()/2)), - curr_ticks, tg_acl_trigger_time, tg_acl_trigger_start_time); - TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][RESULT] tg_trig_diff:%d trig_diff:%d", (uint32_t)BTCLKS_TO_US(curr_ticks-tg_acl_trigger_time), - (uint32_t)BTCLKS_TO_US(curr_ticks-tg_acl_trigger_start_time)); - app_bt_stream_set_trigger_time(0); - app_bt_stream_trigger_stauts_set(BT_STREAM_TRIGGER_STATUS_OK); - A2DP_AUDIO_HEADFRAME_INFO_T headframe_info; - a2dp_audio_decoder_headframe_info_get(&headframe_info); - TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][RESULT] synchronize_ok :%d", headframe_info.sequenceNumber); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (app_tws_ibrt_mobile_link_connected()) { + curr_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->mobile_conhandle); + bt_syn_trig_checker(p_ibrt_ctrl->mobile_conhandle); + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + curr_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle); + bt_syn_trig_checker(p_ibrt_ctrl->ibrt_conhandle); + } else { + TRACE_AUD_STREAM_I( + "[STRM_TRIG][A2DP][RESULT] mobile_link:%d %04x ibrt_link:%d %04x", + app_tws_ibrt_mobile_link_connected(), p_ibrt_ctrl->mobile_conhandle, + app_tws_ibrt_slave_ibrt_link_connected(), + p_ibrt_ctrl->ibrt_conhandle); } +#else + curr_ticks = btdrv_syn_get_curr_ticks(); +#endif + TRACE_AUD_STREAM_I( + "[STRM_TRIG][A2DP][RESULT] trig:%d curr:%d tg:%d start:%d", + (curr_ticks - + (uint32_t)US_TO_BTCLKS(app_bt_stream_get_dma_buffer_delay_us() / 2)), + curr_ticks, tg_acl_trigger_time, tg_acl_trigger_start_time); + TRACE_AUD_STREAM_I( + "[STRM_TRIG][A2DP][RESULT] tg_trig_diff:%d trig_diff:%d", + (uint32_t)BTCLKS_TO_US(curr_ticks - tg_acl_trigger_time), + (uint32_t)BTCLKS_TO_US(curr_ticks - tg_acl_trigger_start_time)); + app_bt_stream_set_trigger_time(0); + app_bt_stream_trigger_stauts_set(BT_STREAM_TRIGGER_STATUS_OK); + A2DP_AUDIO_HEADFRAME_INFO_T headframe_info; + a2dp_audio_decoder_headframe_info_get(&headframe_info); + TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][RESULT] synchronize_ok :%d", + headframe_info.sequenceNumber); + } } -void app_bt_stream_playback_irq_notification(enum AUD_STREAM_ID_T id, enum AUD_STREAM_T stream) -{ - if (id != AUD_STREAM_ID_0 || stream != AUD_STREAM_PLAYBACK) { - return; - } - app_bt_stream_trigger_result(); +void app_bt_stream_playback_irq_notification(enum AUD_STREAM_ID_T id, + enum AUD_STREAM_T stream) { + if (id != AUD_STREAM_ID_0 || stream != AUD_STREAM_PLAYBACK) { + return; + } + app_bt_stream_trigger_result(); #if defined(IBRT) - app_tws_ibrt_audio_analysis_interrupt_tick(); + app_tws_ibrt_audio_analysis_interrupt_tick(); #endif } extern void a2dp_audio_set_mtu_limit(uint8_t mut); extern float a2dp_audio_latency_factor_get(void); extern uint8_t a2dp_lhdc_config_llc_get(void); -void app_bt_stream_trigger_init(void) -{ +void app_bt_stream_trigger_init(void) { #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (app_tws_ibrt_mobile_link_connected()){ - tg_acl_trigger_init_time = bt_syn_get_curr_ticks(p_ibrt_ctrl->mobile_conhandle); - }else if (app_tws_ibrt_slave_ibrt_link_connected()){ - tg_acl_trigger_init_time = bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle); - }else{ - TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][INIT] mobile_link:%d %04x ibrt_link:%d %04x", app_tws_ibrt_mobile_link_connected(), p_ibrt_ctrl->mobile_conhandle, - app_tws_ibrt_slave_ibrt_link_connected(), p_ibrt_ctrl->ibrt_conhandle); - } + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (app_tws_ibrt_mobile_link_connected()) { + tg_acl_trigger_init_time = + bt_syn_get_curr_ticks(p_ibrt_ctrl->mobile_conhandle); + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + tg_acl_trigger_init_time = + bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle); + } else { + TRACE_AUD_STREAM_I( + "[STRM_TRIG][A2DP][INIT] mobile_link:%d %04x ibrt_link:%d %04x", + app_tws_ibrt_mobile_link_connected(), p_ibrt_ctrl->mobile_conhandle, + app_tws_ibrt_slave_ibrt_link_connected(), p_ibrt_ctrl->ibrt_conhandle); + } #else - tg_acl_trigger_init_time = btdrv_syn_get_curr_ticks(); + tg_acl_trigger_init_time = btdrv_syn_get_curr_ticks(); #endif - app_bt_stream_set_trigger_time(0); + app_bt_stream_set_trigger_time(0); #ifdef PLAYBACK_USE_I2S - af_i2s_sync_config(AUD_STREAM_PLAYBACK, AF_I2S_SYNC_TYPE_BT, false); - af_i2s_sync_config(AUD_STREAM_PLAYBACK, AF_I2S_SYNC_TYPE_BT, true); + af_i2s_sync_config(AUD_STREAM_PLAYBACK, AF_I2S_SYNC_TYPE_BT, false); + af_i2s_sync_config(AUD_STREAM_PLAYBACK, AF_I2S_SYNC_TYPE_BT, true); #else - af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, false); - af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, true); + af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, false); + af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, true); #endif - app_bt_stream_trigger_stauts_set(BT_STREAM_TRIGGER_STATUS_INIT); + app_bt_stream_trigger_stauts_set(BT_STREAM_TRIGGER_STATUS_INIT); } -void app_bt_stream_trigger_deinit(void) -{ - app_bt_stream_set_trigger_time(0); -} +void app_bt_stream_trigger_deinit(void) { app_bt_stream_set_trigger_time(0); } -void app_bt_stream_trigger_start(uint8_t offset) -{ - float tg_trigger_time = 0; - uint32_t curr_ticks; - struct AF_STREAM_CONFIG_T *stream_cfg = NULL; - af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg, false); +void app_bt_stream_trigger_start(uint8_t offset) { + float tg_trigger_time = 0; + uint32_t curr_ticks; + struct AF_STREAM_CONFIG_T *stream_cfg = NULL; + af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg, false); #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (app_tws_ibrt_mobile_link_connected()){ - curr_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->mobile_conhandle); - }else if (app_tws_ibrt_slave_ibrt_link_connected()){ - curr_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle); - }else{ - return; - } + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (app_tws_ibrt_mobile_link_connected()) { + curr_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->mobile_conhandle); + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + curr_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle); + } else { + return; + } #else - curr_ticks = btdrv_syn_get_curr_ticks(); + curr_ticks = btdrv_syn_get_curr_ticks(); #endif - TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][START] init(%d)-->set_trig(%d) %dus", tg_acl_trigger_init_time, curr_ticks, (uint32_t)BTCLKS_TO_US(curr_ticks-tg_acl_trigger_init_time)); + TRACE_AUD_STREAM_I( + "[STRM_TRIG][A2DP][START] init(%d)-->set_trig(%d) %dus", + tg_acl_trigger_init_time, curr_ticks, + (uint32_t)BTCLKS_TO_US(curr_ticks - tg_acl_trigger_init_time)); #if defined(A2DP_AAC_ON) - if(bt_sbc_player_get_codec_type() == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC){ - tg_trigger_time = A2DP_PLAYER_PLAYBACK_DELAY_AAC_US * a2dp_audio_latency_factor_get(); - tg_trigger_time += offset*A2DP_PLAYER_PLAYBACK_DELAY_AAC_BASE; + if (bt_sbc_player_get_codec_type() == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { + tg_trigger_time = + A2DP_PLAYER_PLAYBACK_DELAY_AAC_US * a2dp_audio_latency_factor_get(); + tg_trigger_time += offset * A2DP_PLAYER_PLAYBACK_DELAY_AAC_BASE; #if (A2DP_DECODER_VER < 2) - a2dp_audio_set_mtu_limit(A2DP_PLAYER_PLAYBACK_DELAY_AAC_MTU); + a2dp_audio_set_mtu_limit(A2DP_PLAYER_PLAYBACK_DELAY_AAC_MTU); #endif - }else + } else #endif - if(bt_sbc_player_get_codec_type() == BTIF_AVDTP_CODEC_TYPE_NON_A2DP){ + if (bt_sbc_player_get_codec_type() == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { #if defined(A2DP_SCALABLE_ON) - if(current_a2dp_non_type == A2DP_NON_CODEC_TYPE_SCALABLE){ - if(stream_cfg->sample_rate > AUD_SAMPRATE_48000){ - tg_trigger_time = A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_HIRES_US * a2dp_audio_latency_factor_get(); + if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_SCALABLE) { + if (stream_cfg->sample_rate > AUD_SAMPRATE_48000) { + tg_trigger_time = A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_HIRES_US * + a2dp_audio_latency_factor_get(); - tg_trigger_time += offset*A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_HIRES_BASE; + tg_trigger_time += + offset * A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_HIRES_BASE; #if (A2DP_DECODER_VER < 2) - a2dp_audio_set_mtu_limit(A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_HIRES_MTU); + a2dp_audio_set_mtu_limit(A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_HIRES_MTU); #endif - }else{ - tg_trigger_time = A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_BASERES_US * a2dp_audio_latency_factor_get(); - tg_trigger_time += offset*A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_BASERES_BASE; + } else { + tg_trigger_time = A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_BASERES_US * + a2dp_audio_latency_factor_get(); + tg_trigger_time += + offset * A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_BASERES_BASE; #if (A2DP_DECODER_VER < 2) - a2dp_audio_set_mtu_limit(A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_BASERES_MTU); + a2dp_audio_set_mtu_limit( + A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_BASERES_MTU); #endif - } - } + } + } #endif #if defined(A2DP_LHDC_ON) - if(current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LHDC){ - if (a2dp_lhdc_config_llc_get()){ - tg_trigger_time = A2DP_PLAYER_PLAYBACK_DELAY_LHDC_LLC_US * a2dp_audio_latency_factor_get(); - tg_trigger_time += offset*A2DP_PLAYER_PLAYBACK_DELAY_LHDC_LLC_BASE; + if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LHDC) { + if (a2dp_lhdc_config_llc_get()) { + tg_trigger_time = A2DP_PLAYER_PLAYBACK_DELAY_LHDC_LLC_US * + a2dp_audio_latency_factor_get(); + tg_trigger_time += offset * A2DP_PLAYER_PLAYBACK_DELAY_LHDC_LLC_BASE; #if (A2DP_DECODER_VER < 2) - a2dp_audio_set_mtu_limit(A2DP_PLAYER_PLAYBACK_DELAY_LHDC_LLC_MTU); + a2dp_audio_set_mtu_limit(A2DP_PLAYER_PLAYBACK_DELAY_LHDC_LLC_MTU); #endif - }else if(stream_cfg->sample_rate > AUD_SAMPRATE_48000){ - tg_trigger_time = A2DP_PLAYER_PLAYBACK_DELAY_LHDC_HIRES_US * a2dp_audio_latency_factor_get(); - tg_trigger_time += offset*A2DP_PLAYER_PLAYBACK_DELAY_LHDC_HIRES_BASE; + } else if (stream_cfg->sample_rate > AUD_SAMPRATE_48000) { + tg_trigger_time = A2DP_PLAYER_PLAYBACK_DELAY_LHDC_HIRES_US * + a2dp_audio_latency_factor_get(); + tg_trigger_time += offset * A2DP_PLAYER_PLAYBACK_DELAY_LHDC_HIRES_BASE; #if (A2DP_DECODER_VER < 2) - a2dp_audio_set_mtu_limit(A2DP_PLAYER_PLAYBACK_DELAY_LHDC_HIRES_MTU); + a2dp_audio_set_mtu_limit(A2DP_PLAYER_PLAYBACK_DELAY_LHDC_HIRES_MTU); #endif - }else{ - tg_trigger_time = A2DP_PLAYER_PLAYBACK_DELAY_LHDC_BASERES_US * a2dp_audio_latency_factor_get(); - tg_trigger_time += offset*A2DP_PLAYER_PLAYBACK_DELAY_LHDC_BASERES_BASE; + } else { + tg_trigger_time = A2DP_PLAYER_PLAYBACK_DELAY_LHDC_BASERES_US * + a2dp_audio_latency_factor_get(); + tg_trigger_time += + offset * A2DP_PLAYER_PLAYBACK_DELAY_LHDC_BASERES_BASE; #if (A2DP_DECODER_VER < 2) - a2dp_audio_set_mtu_limit(A2DP_PLAYER_PLAYBACK_DELAY_LHDC_BASERES_MTU); + a2dp_audio_set_mtu_limit(A2DP_PLAYER_PLAYBACK_DELAY_LHDC_BASERES_MTU); #endif - } - } + } + } #endif #if defined(A2DP_LDAC_ON) - if(current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LDAC){ - uint32_t frame_mtu = A2DP_PLAYER_PLAYBACK_DELAY_LDAC_FRAME_MTU; + if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LDAC) { + uint32_t frame_mtu = A2DP_PLAYER_PLAYBACK_DELAY_LDAC_FRAME_MTU; #if (A2DP_DECODER_VER == 2) - A2DP_AUDIO_LASTFRAME_INFO_T lastframe_info; - if (!a2dp_audio_lastframe_info_get(&lastframe_info)){ - frame_mtu = lastframe_info.totalSubSequenceNumber; - } + A2DP_AUDIO_LASTFRAME_INFO_T lastframe_info; + if (!a2dp_audio_lastframe_info_get(&lastframe_info)) { + frame_mtu = lastframe_info.totalSubSequenceNumber; + } #endif - tg_trigger_time = A2DP_PLAYER_PLAYBACK_DELAY_LDAC_US * a2dp_audio_latency_factor_get(); - tg_trigger_time += offset*A2DP_PLAYER_PLAYBACK_DELAY_LDAC_BASE*frame_mtu; + tg_trigger_time = + A2DP_PLAYER_PLAYBACK_DELAY_LDAC_US * a2dp_audio_latency_factor_get(); + tg_trigger_time += + offset * A2DP_PLAYER_PLAYBACK_DELAY_LDAC_BASE * frame_mtu; #if (A2DP_DECODER_VER < 2) - a2dp_audio_set_mtu_limit(A2DP_PLAYER_PLAYBACK_DELAY_LDAC_MTU); -#endif - TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][START] [%d,%d,%d]", A2DP_PLAYER_PLAYBACK_DELAY_LDAC_MTU,A2DP_PLAYER_PLAYBACK_DELAY_LDAC_BASE,A2DP_PLAYER_PLAYBACK_DELAY_LDAC_US); - - } -#endif - }else - { - uint32_t frame_mtu = A2DP_PLAYER_PLAYBACK_DELAY_SBC_FRAME_MTU; -#if (A2DP_DECODER_VER == 2) - A2DP_AUDIO_LASTFRAME_INFO_T lastframe_info; - if (!a2dp_audio_lastframe_info_get(&lastframe_info)){ - frame_mtu = lastframe_info.totalSubSequenceNumber; - } -#endif - tg_trigger_time = A2DP_PLAYER_PLAYBACK_DELAY_SBC_US; - tg_trigger_time += offset*A2DP_PLAYER_PLAYBACK_DELAY_SBC_BASE*frame_mtu; -#if (A2DP_DECODER_VER < 2) - a2dp_audio_set_mtu_limit(A2DP_PLAYER_PLAYBACK_DELAY_SBC_MTU); + a2dp_audio_set_mtu_limit(A2DP_PLAYER_PLAYBACK_DELAY_LDAC_MTU); #endif + TRACE_AUD_STREAM_I("[STRM_TRIG][A2DP][START] [%d,%d,%d]", + A2DP_PLAYER_PLAYBACK_DELAY_LDAC_MTU, + A2DP_PLAYER_PLAYBACK_DELAY_LDAC_BASE, + A2DP_PLAYER_PLAYBACK_DELAY_LDAC_US); } - app_bt_stream_set_trigger_time((uint32_t)tg_trigger_time); +#endif + } else { + uint32_t frame_mtu = A2DP_PLAYER_PLAYBACK_DELAY_SBC_FRAME_MTU; +#if (A2DP_DECODER_VER == 2) + A2DP_AUDIO_LASTFRAME_INFO_T lastframe_info; + if (!a2dp_audio_lastframe_info_get(&lastframe_info)) { + frame_mtu = lastframe_info.totalSubSequenceNumber; + } +#endif + tg_trigger_time = A2DP_PLAYER_PLAYBACK_DELAY_SBC_US; + tg_trigger_time += offset * A2DP_PLAYER_PLAYBACK_DELAY_SBC_BASE * frame_mtu; +#if (A2DP_DECODER_VER < 2) + a2dp_audio_set_mtu_limit(A2DP_PLAYER_PLAYBACK_DELAY_SBC_MTU); +#endif + } + app_bt_stream_set_trigger_time((uint32_t)tg_trigger_time); } -bool app_bt_stream_trigger_onprocess(void) -{ - if (app_bt_stream_trigger_stauts_get() == BT_STREAM_TRIGGER_STATUS_INIT){ - return true; - }else{ - return false; - } +bool app_bt_stream_trigger_onprocess(void) { + if (app_bt_stream_trigger_stauts_get() == BT_STREAM_TRIGGER_STATUS_INIT) { + return true; + } else { + return false; + } } #if defined(IBRT) @@ -3006,861 +3116,927 @@ bool app_bt_stream_trigger_onprocess(void) #define APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME (4) #endif -APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T app_bt_stream_ibrt_auto_synchronize_initsync_trigger; +APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T +app_bt_stream_ibrt_auto_synchronize_initsync_trigger; -int app_bt_stream_ibrt_auto_synchronize_initsync_dataind_cb(btif_media_header_t * header, unsigned char *buf, unsigned int len) -{ - APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger = &app_bt_stream_ibrt_auto_synchronize_initsync_trigger; - bool synchronize_ok = false; - A2DP_AUDIO_LASTFRAME_INFO_T lastframe_info; +int app_bt_stream_ibrt_auto_synchronize_initsync_dataind_cb( + btif_media_header_t *header, unsigned char *buf, unsigned int len) { + APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger = + &app_bt_stream_ibrt_auto_synchronize_initsync_trigger; + bool synchronize_ok = false; + A2DP_AUDIO_LASTFRAME_INFO_T lastframe_info; - TRACE_AUD_STREAM_I("[AUTO_SYNC][INITSYNC][DATAIND] dataind_seq:%d/%d timestamp:%d/%d", header->sequenceNumber, - sync_trigger->audio_info.sequenceNumber, - header->timestamp, - sync_trigger->audio_info.timestamp); + TRACE_AUD_STREAM_I( + "[AUTO_SYNC][INITSYNC][DATAIND] dataind_seq:%d/%d timestamp:%d/%d", + header->sequenceNumber, sync_trigger->audio_info.sequenceNumber, + header->timestamp, sync_trigger->audio_info.timestamp); - if (a2dp_audio_lastframe_info_get(&lastframe_info)<0){ - TRACE_AUD_STREAM_W("[AUTO_SYNC][INITSYNC][DATAIND] force retrigger"); - app_ibrt_if_force_audio_retrigger(); - return 0; + if (a2dp_audio_lastframe_info_get(&lastframe_info) < 0) { + TRACE_AUD_STREAM_W("[AUTO_SYNC][INITSYNC][DATAIND] force retrigger"); + app_ibrt_if_force_audio_retrigger(); + return 0; + } + + if (app_bt_stream_trigger_stauts_get() != BT_STREAM_TRIGGER_STATUS_WAIT) { + TRACE_AUD_STREAM_W("[AUTO_SYNC][INITSYNC][DATAIND] already end"); + a2dp_audio_detect_next_packet_callback_register(NULL); + a2dp_audio_detect_store_packet_callback_register(NULL); + return 0; + } + + if (sync_trigger->audio_info.sequenceNumber < header->sequenceNumber) { + TRACE_AUD_STREAM_W("[AUTO_SYNC][INITSYNC][DATAIND] force retrigger"); + app_ibrt_if_force_audio_retrigger(); + } else { + if (header->sequenceNumber >= sync_trigger->audio_info.sequenceNumber) { + synchronize_ok = true; } - if (app_bt_stream_trigger_stauts_get() != BT_STREAM_TRIGGER_STATUS_WAIT){ - TRACE_AUD_STREAM_W("[AUTO_SYNC][INITSYNC][DATAIND] already end"); - a2dp_audio_detect_next_packet_callback_register(NULL); - a2dp_audio_detect_store_packet_callback_register(NULL); - return 0; + if (synchronize_ok && + app_bt_stream_trigger_stauts_get() != BT_STREAM_TRIGGER_STATUS_WAIT) { + TRACE_AUD_STREAM_W("[AUTO_SYNC][INITSYNC][DATAIND] synchronize_failed"); + app_ibrt_if_force_audio_retrigger(); + return 0; } - - if (sync_trigger->audio_info.sequenceNumber < header->sequenceNumber){ - TRACE_AUD_STREAM_W("[AUTO_SYNC][INITSYNC][DATAIND] force retrigger"); - app_ibrt_if_force_audio_retrigger(); - }else{ - if (header->sequenceNumber >= sync_trigger->audio_info.sequenceNumber){ - synchronize_ok = true; - } - - if (synchronize_ok && app_bt_stream_trigger_stauts_get() != BT_STREAM_TRIGGER_STATUS_WAIT){ - TRACE_AUD_STREAM_W("[AUTO_SYNC][INITSYNC][DATAIND] synchronize_failed"); - app_ibrt_if_force_audio_retrigger(); - return 0; - } #ifdef A2DP_PLAYER_PLAYBACK_WATER_LINE - //limter to water line upper - uint32_t list_samples = 0; - uint32_t limter_water_line_samples = 0; - limter_water_line_samples = (a2dp_audio_dest_packet_mut_get() * lastframe_info.list_samples); - a2dp_audio_convert_list_to_samples(&list_samples); - TRACE_AUD_STREAM_W("[AUTO_SYNC][INITSYNC][DATAIND] synchronize:%d/%d", list_samples, limter_water_line_samples); - if (list_samples > limter_water_line_samples){ - TRACE_AUD_STREAM_W("[AUTO_SYNC][INITSYNC][DATAIND] skip discards:%d", list_samples - limter_water_line_samples); - a2dp_audio_discards_samples(list_samples - limter_water_line_samples); - } + // limter to water line upper + uint32_t list_samples = 0; + uint32_t limter_water_line_samples = 0; + limter_water_line_samples = + (a2dp_audio_dest_packet_mut_get() * lastframe_info.list_samples); + a2dp_audio_convert_list_to_samples(&list_samples); + TRACE_AUD_STREAM_W("[AUTO_SYNC][INITSYNC][DATAIND] synchronize:%d/%d", + list_samples, limter_water_line_samples); + if (list_samples > limter_water_line_samples) { + TRACE_AUD_STREAM_W("[AUTO_SYNC][INITSYNC][DATAIND] skip discards:%d", + list_samples - limter_water_line_samples); + a2dp_audio_discards_samples(list_samples - limter_water_line_samples); + } #else - //flush all + // flush all + a2dp_audio_synchronize_dest_packet_mut(0); +#endif + if (synchronize_ok) { + A2DP_AUDIO_HEADFRAME_INFO_T headframe_info; + a2dp_audio_decoder_headframe_info_get(&headframe_info); + TRACE_AUD_STREAM_W("[AUTO_SYNC][INITSYNC][DATAIND] synchronize_ok :%d", + headframe_info.sequenceNumber); + a2dp_audio_detect_next_packet_callback_register(NULL); + a2dp_audio_detect_store_packet_callback_register(NULL); + } else { + a2dp_audio_detect_first_packet(); + } + } + return 0; +} + +void app_bt_stream_ibrt_auto_synchronize_initsync_start( + APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger) { + TRACE_AUD_STREAM_I("[AUTO_SYNC][INITSYNC] start trigger_time:%d seq:%d " + "timestamp:%d SubSeq:%d/%d", + sync_trigger->trigger_time, + sync_trigger->audio_info.sequenceNumber, + sync_trigger->audio_info.timestamp, + sync_trigger->audio_info.curSubSequenceNumber, + sync_trigger->audio_info.totalSubSequenceNumber); + app_bt_stream_ibrt_auto_synchronize_initsync_trigger = *sync_trigger; + a2dp_audio_detect_next_packet_callback_register( + app_bt_stream_ibrt_auto_synchronize_initsync_dataind_cb); + a2dp_audio_detect_first_packet(); + if (app_tws_ibrt_slave_ibrt_link_connected()) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (sync_trigger->trigger_time > + bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle)) { + uint32_t tg_tick = sync_trigger->trigger_time; + btdrv_syn_trigger_codec_en(1); + btdrv_syn_clr_trigger(); + btdrv_enable_playback_triggler(ACL_TRIGGLE_MODE); + bt_syn_set_tg_ticks(tg_tick, p_ibrt_ctrl->ibrt_conhandle, + BT_TRIG_SLAVE_ROLE); + tg_acl_trigger_time = tg_tick; + app_bt_stream_trigger_stauts_set(BT_STREAM_TRIGGER_STATUS_WAIT); + TRACE_AUD_STREAM_I( + "[AUTO_SYNC][INITSYNC] start slave trigger curr(%d)-->tg(%d)", + bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle), tg_tick); + app_tws_ibrt_audio_analysis_start( + sync_trigger->handler_cnt, AUDIO_ANALYSIS_CHECKER_INTERVEL_INVALID); + app_tws_ibrt_audio_sync_start(); + app_tws_ibrt_audio_sync_new_reference(sync_trigger->factor_reference); + } else { + TRACE_AUD_STREAM_I("[AUTO_SYNC][INITSYNC] start slave failed " + "trigger(%d)-->tg(%d) need resume", + bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle), + sync_trigger->trigger_time); + app_tws_ibrt_audio_sync_mismatch_resume_notify(); + } + } +} + +int app_bt_stream_ibrt_audio_master_detect_next_packet_cb( + btif_media_header_t *header, unsigned char *buf, unsigned int len) { +#ifdef A2DP_PLAYER_PLAYBACK_WATER_LINE + A2DP_AUDIO_SYNCFRAME_INFO_T sync_info; + A2DP_AUDIO_HEADFRAME_INFO_T headframe_info; +#endif + + if (app_bt_stream_trigger_stauts_get() == BT_STREAM_TRIGGER_STATUS_INIT) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + int32_t dma_buffer_samples = app_bt_stream_get_dma_buffer_samples() / 2; + + if (app_tws_ibrt_slave_ibrt_link_connected()) { + TRACE_AUD_STREAM_W( + "[AUTO_SYNC][MASTER] cache ok but currRole:%d mismatch\n", + p_ibrt_ctrl->current_role); + app_ibrt_if_force_audio_retrigger(); + } else if (!app_ibrt_ui_is_profile_exchanged() && + !app_ibrt_if_start_ibrt_onporcess() && + !app_ibrt_sync_a2dp_status_onporcess()) { + if (p_ibrt_ctrl->mobile_mode == IBRT_SNIFF_MODE) { + // flush all a2dp_audio_synchronize_dest_packet_mut(0); -#endif - if (synchronize_ok){ - A2DP_AUDIO_HEADFRAME_INFO_T headframe_info; - a2dp_audio_decoder_headframe_info_get(&headframe_info); - TRACE_AUD_STREAM_W("[AUTO_SYNC][INITSYNC][DATAIND] synchronize_ok :%d", headframe_info.sequenceNumber); - a2dp_audio_detect_next_packet_callback_register(NULL); - a2dp_audio_detect_store_packet_callback_register(NULL); - }else{ - a2dp_audio_detect_first_packet(); - } - } - return 0; -} - -void app_bt_stream_ibrt_auto_synchronize_initsync_start(APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T *sync_trigger) -{ - TRACE_AUD_STREAM_I("[AUTO_SYNC][INITSYNC] start trigger_time:%d seq:%d timestamp:%d SubSeq:%d/%d", sync_trigger->trigger_time, - sync_trigger->audio_info.sequenceNumber, - sync_trigger->audio_info.timestamp, - sync_trigger->audio_info.curSubSequenceNumber, - sync_trigger->audio_info.totalSubSequenceNumber - ); - app_bt_stream_ibrt_auto_synchronize_initsync_trigger = *sync_trigger; - a2dp_audio_detect_next_packet_callback_register(app_bt_stream_ibrt_auto_synchronize_initsync_dataind_cb); - a2dp_audio_detect_first_packet(); - if (app_tws_ibrt_slave_ibrt_link_connected()){ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (sync_trigger->trigger_time > bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle)){ - uint32_t tg_tick = sync_trigger->trigger_time; - btdrv_syn_trigger_codec_en(1); - btdrv_syn_clr_trigger(); - btdrv_enable_playback_triggler(ACL_TRIGGLE_MODE); - bt_syn_set_tg_ticks(tg_tick, p_ibrt_ctrl->ibrt_conhandle, BT_TRIG_SLAVE_ROLE); - tg_acl_trigger_time = tg_tick; - app_bt_stream_trigger_stauts_set(BT_STREAM_TRIGGER_STATUS_WAIT); - TRACE_AUD_STREAM_I("[AUTO_SYNC][INITSYNC] start slave trigger curr(%d)-->tg(%d)", bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle), tg_tick); - app_tws_ibrt_audio_analysis_start(sync_trigger->handler_cnt, AUDIO_ANALYSIS_CHECKER_INTERVEL_INVALID); - app_tws_ibrt_audio_sync_start(); - app_tws_ibrt_audio_sync_new_reference(sync_trigger->factor_reference); - }else{ - TRACE_AUD_STREAM_I("[AUTO_SYNC][INITSYNC] start slave failed trigger(%d)-->tg(%d) need resume", - bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle), - sync_trigger->trigger_time); - app_tws_ibrt_audio_sync_mismatch_resume_notify(); - } - } -} - -int app_bt_stream_ibrt_audio_master_detect_next_packet_cb(btif_media_header_t * header, unsigned char *buf, unsigned int len) -{ + a2dp_audio_detect_first_packet(); + TRACE_AUD_STREAM_I( + "[AUTO_SYNC][MASTER] cache skip delay dma trigger1\n"); + return 0; + } + TRACE_AUD_STREAM_I("[AUTO_SYNC][MASTER] cache ok use dma trigger1\n"); + a2dp_audio_detect_next_packet_callback_register(NULL); + a2dp_audio_detect_store_packet_callback_register(NULL); #ifdef A2DP_PLAYER_PLAYBACK_WATER_LINE - A2DP_AUDIO_SYNCFRAME_INFO_T sync_info; - A2DP_AUDIO_HEADFRAME_INFO_T headframe_info; -#endif - - if(app_bt_stream_trigger_stauts_get() == BT_STREAM_TRIGGER_STATUS_INIT){ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - int32_t dma_buffer_samples = app_bt_stream_get_dma_buffer_samples()/2; - - if (app_tws_ibrt_slave_ibrt_link_connected()){ - TRACE_AUD_STREAM_W("[AUTO_SYNC][MASTER] cache ok but currRole:%d mismatch\n", p_ibrt_ctrl->current_role); - app_ibrt_if_force_audio_retrigger(); - }else if (!app_ibrt_ui_is_profile_exchanged() && - !app_ibrt_if_start_ibrt_onporcess() && - !app_ibrt_sync_a2dp_status_onporcess()){ - if (p_ibrt_ctrl->mobile_mode == IBRT_SNIFF_MODE){ - //flush all - a2dp_audio_synchronize_dest_packet_mut(0); - a2dp_audio_detect_first_packet(); - TRACE_AUD_STREAM_I("[AUTO_SYNC][MASTER] cache skip delay dma trigger1\n"); - return 0; - } - TRACE_AUD_STREAM_I("[AUTO_SYNC][MASTER] cache ok use dma trigger1\n"); - a2dp_audio_detect_next_packet_callback_register(NULL); - a2dp_audio_detect_store_packet_callback_register(NULL); -#ifdef A2DP_PLAYER_PLAYBACK_WATER_LINE - app_bt_stream_trigger_start(A2DP_PLAYER_PLAYBACK_WATER_LINE); + app_bt_stream_trigger_start(A2DP_PLAYER_PLAYBACK_WATER_LINE); #else - app_bt_stream_trigger_start(0); + app_bt_stream_trigger_start(0); #endif - }else if (app_ibrt_if_start_ibrt_onporcess() || - app_ibrt_sync_a2dp_status_onporcess() || - app_ibrt_waiting_cmd_rsp()){ - //flush all - a2dp_audio_synchronize_dest_packet_mut(0); - a2dp_audio_detect_first_packet(); - TRACE_AUD_STREAM_I("[AUTO_SYNC][MASTER] cache skip profile_exchanged sync_a2dp_status_onporcess\n"); - return 0; - }else{ - if (p_ibrt_ctrl->tws_mode == IBRT_SNIFF_MODE || - p_ibrt_ctrl->mobile_mode == IBRT_SNIFF_MODE){ - //flush all - a2dp_audio_synchronize_dest_packet_mut(0); - a2dp_audio_detect_first_packet(); - TRACE_AUD_STREAM_I("[AUTO_SYNC][MASTER] cache skip delay dma trigger2\n"); - return 0; - } - uint8_t codec_type = bt_sbc_player_get_codec_type(); + } else if (app_ibrt_if_start_ibrt_onporcess() || + app_ibrt_sync_a2dp_status_onporcess() || + app_ibrt_waiting_cmd_rsp()) { + // flush all + a2dp_audio_synchronize_dest_packet_mut(0); + a2dp_audio_detect_first_packet(); + TRACE_AUD_STREAM_I("[AUTO_SYNC][MASTER] cache skip profile_exchanged " + "sync_a2dp_status_onporcess\n"); + return 0; + } else { + if (p_ibrt_ctrl->tws_mode == IBRT_SNIFF_MODE || + p_ibrt_ctrl->mobile_mode == IBRT_SNIFF_MODE) { + // flush all + a2dp_audio_synchronize_dest_packet_mut(0); + a2dp_audio_detect_first_packet(); + TRACE_AUD_STREAM_I( + "[AUTO_SYNC][MASTER] cache skip delay dma trigger2\n"); + return 0; + } + uint8_t codec_type = bt_sbc_player_get_codec_type(); #ifdef A2DP_PLAYER_PLAYBACK_WATER_LINE - uint32_t dest_waterline_samples = 0; - uint32_t list_samples = 0; - dest_waterline_samples = app_bt_stream_get_dma_buffer_samples()/2*A2DP_PLAYER_PLAYBACK_WATER_LINE; - a2dp_audio_convert_list_to_samples(&list_samples); - if (list_samples < dest_waterline_samples){ - a2dp_audio_detect_first_packet(); - TRACE_AUD_STREAM_I("[AUTO_SYNC][MASTER] cache skip fill data sample:%d\n", list_samples); - return 0; - } - a2dp_audio_decoder_headframe_info_get(&headframe_info); - if(codec_type == BTIF_AVDTP_CODEC_TYPE_LHDC) - { - sync_info.sequenceNumber = headframe_info.sequenceNumber; - } - else - { - sync_info.sequenceNumber = headframe_info.sequenceNumber + 1; - } - a2dp_audio_synchronize_packet(&sync_info, A2DP_AUDIO_SYNCFRAME_MASK_SEQ); + uint32_t dest_waterline_samples = 0; + uint32_t list_samples = 0; + dest_waterline_samples = app_bt_stream_get_dma_buffer_samples() / 2 * + A2DP_PLAYER_PLAYBACK_WATER_LINE; + a2dp_audio_convert_list_to_samples(&list_samples); + if (list_samples < dest_waterline_samples) { + a2dp_audio_detect_first_packet(); + TRACE_AUD_STREAM_I( + "[AUTO_SYNC][MASTER] cache skip fill data sample:%d\n", + list_samples); + return 0; + } + a2dp_audio_decoder_headframe_info_get(&headframe_info); + if (codec_type == BTIF_AVDTP_CODEC_TYPE_LHDC) { + sync_info.sequenceNumber = headframe_info.sequenceNumber; + } else { + sync_info.sequenceNumber = headframe_info.sequenceNumber + 1; + } + a2dp_audio_synchronize_packet(&sync_info, A2DP_AUDIO_SYNCFRAME_MASK_SEQ); #else - a2dp_audio_synchronize_dest_packet_mut(0); + a2dp_audio_synchronize_dest_packet_mut(0); #endif - TRACE_AUD_STREAM_I("[AUTO_SYNC][MASTER] cache ok use dma trigger2\n"); - //uint8_t codec_type = bt_sbc_player_get_codec_type(); + TRACE_AUD_STREAM_I("[AUTO_SYNC][MASTER] cache ok use dma trigger2\n"); + // uint8_t codec_type = bt_sbc_player_get_codec_type(); #ifdef A2DP_CP_ACCEL - if(codec_type == BTIF_AVDTP_CODEC_TYPE_LHDC) - { - app_bt_stream_trigger_start(APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME_LHDC - a2dp_audio_frame_delay_get()); - } - else - { - app_bt_stream_trigger_start(APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME - a2dp_audio_frame_delay_get()); - } + if (codec_type == BTIF_AVDTP_CODEC_TYPE_LHDC) { + app_bt_stream_trigger_start( + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME_LHDC - + a2dp_audio_frame_delay_get()); + } else { + app_bt_stream_trigger_start( + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME - + a2dp_audio_frame_delay_get()); + } #else - app_bt_stream_trigger_start(APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME); + app_bt_stream_trigger_start( + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME); #endif - APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T sync_trigger; - A2DP_AUDIO_HEADFRAME_INFO_T headframe_info; - A2DP_AUDIO_LASTFRAME_INFO_T lastframe_info; - sync_trigger.trigger_time = tg_acl_trigger_time; - if(codec_type == BTIF_AVDTP_CODEC_TYPE_LHDC) - { - sync_trigger.trigger_skip_frame = APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME_LHDC - a2dp_audio_frame_delay_get(); - } - else - { - sync_trigger.trigger_skip_frame = APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME - a2dp_audio_frame_delay_get(); - } - sync_trigger.trigger_type = APP_TWS_IBRT_AUDIO_TRIGGER_TYPE_INIT_SYNC; - if (a2dp_audio_lastframe_info_get(&lastframe_info)<0){ - goto exit; - } + APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T sync_trigger; + A2DP_AUDIO_HEADFRAME_INFO_T headframe_info; + A2DP_AUDIO_LASTFRAME_INFO_T lastframe_info; + sync_trigger.trigger_time = tg_acl_trigger_time; + if (codec_type == BTIF_AVDTP_CODEC_TYPE_LHDC) { + sync_trigger.trigger_skip_frame = + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME_LHDC - + a2dp_audio_frame_delay_get(); + } else { + sync_trigger.trigger_skip_frame = + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME - + a2dp_audio_frame_delay_get(); + } + sync_trigger.trigger_type = APP_TWS_IBRT_AUDIO_TRIGGER_TYPE_INIT_SYNC; + if (a2dp_audio_lastframe_info_get(&lastframe_info) < 0) { + goto exit; + } - a2dp_audio_decoder_headframe_info_get(&headframe_info); - sync_trigger.sequenceNumberStart = headframe_info.sequenceNumber; - if(codec_type == BTIF_AVDTP_CODEC_TYPE_LHDC) - { - sync_trigger.audio_info.sequenceNumber = lastframe_info.sequenceNumber + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME_LHDC; - if (lastframe_info.totalSubSequenceNumber){ - sync_trigger.audio_info.timestamp = lastframe_info.timestamp + - (lastframe_info.totalSubSequenceNumber * lastframe_info.frame_samples) * - APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME_LHDC; - }else{ - sync_trigger.audio_info.timestamp = lastframe_info.timestamp + dma_buffer_samples * APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME_LHDC; - } - } - else - { - sync_trigger.audio_info.sequenceNumber = lastframe_info.sequenceNumber + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME; - if (lastframe_info.totalSubSequenceNumber){ - sync_trigger.audio_info.timestamp = lastframe_info.timestamp + - (lastframe_info.totalSubSequenceNumber * lastframe_info.frame_samples) * - APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME; - }else{ - sync_trigger.audio_info.timestamp = lastframe_info.timestamp + dma_buffer_samples * APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME; - } - } - sync_trigger.audio_info.curSubSequenceNumber = lastframe_info.curSubSequenceNumber; - sync_trigger.audio_info.totalSubSequenceNumber = lastframe_info.totalSubSequenceNumber; - sync_trigger.audio_info.frame_samples = lastframe_info.frame_samples; - sync_trigger.factor_reference = a2dp_audio_get_output_config()->factor_reference; - sync_trigger.a2dp_session = a2dp_ibrt_session_get(); - sync_trigger.handler_cnt = 0; - - app_bt_stream_ibrt_auto_synchronize_initsync_start(&sync_trigger); - - if (app_tws_ibrt_mobile_link_connected() && - app_ibrt_ui_is_profile_exchanged()){ - tws_ctrl_send_cmd_high_priority(APP_TWS_CMD_SET_TRIGGER_TIME, (uint8_t*)&sync_trigger, sizeof(APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T)); - } + a2dp_audio_decoder_headframe_info_get(&headframe_info); + sync_trigger.sequenceNumberStart = headframe_info.sequenceNumber; + if (codec_type == BTIF_AVDTP_CODEC_TYPE_LHDC) { + sync_trigger.audio_info.sequenceNumber = + lastframe_info.sequenceNumber + + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME_LHDC; + if (lastframe_info.totalSubSequenceNumber) { + sync_trigger.audio_info.timestamp = + lastframe_info.timestamp + + (lastframe_info.totalSubSequenceNumber * + lastframe_info.frame_samples) * + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME_LHDC; + } else { + sync_trigger.audio_info.timestamp = + lastframe_info.timestamp + + dma_buffer_samples * + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME_LHDC; } - }else{ - if(app_bt_stream_trigger_stauts_get() == BT_STREAM_TRIGGER_STATUS_NULL){ - TRACE_AUD_STREAM_W("[AUTO_SYNC][MASTER] audio not ready skip it"); - }else{ - TRACE_AUD_STREAM_I("[AUTO_SYNC][MASTER] unhandle status:%d", app_bt_stream_trigger_stauts_get()); - app_ibrt_if_force_audio_retrigger(); + } else { + sync_trigger.audio_info.sequenceNumber = + lastframe_info.sequenceNumber + + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME; + if (lastframe_info.totalSubSequenceNumber) { + sync_trigger.audio_info.timestamp = + lastframe_info.timestamp + + (lastframe_info.totalSubSequenceNumber * + lastframe_info.frame_samples) * + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME; + } else { + sync_trigger.audio_info.timestamp = + lastframe_info.timestamp + + dma_buffer_samples * + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME; } + } + sync_trigger.audio_info.curSubSequenceNumber = + lastframe_info.curSubSequenceNumber; + sync_trigger.audio_info.totalSubSequenceNumber = + lastframe_info.totalSubSequenceNumber; + sync_trigger.audio_info.frame_samples = lastframe_info.frame_samples; + sync_trigger.factor_reference = + a2dp_audio_get_output_config()->factor_reference; + sync_trigger.a2dp_session = a2dp_ibrt_session_get(); + sync_trigger.handler_cnt = 0; + + app_bt_stream_ibrt_auto_synchronize_initsync_start(&sync_trigger); + + if (app_tws_ibrt_mobile_link_connected() && + app_ibrt_ui_is_profile_exchanged()) { + tws_ctrl_send_cmd_high_priority( + APP_TWS_CMD_SET_TRIGGER_TIME, (uint8_t *)&sync_trigger, + sizeof(APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T)); + } } + } else { + if (app_bt_stream_trigger_stauts_get() == BT_STREAM_TRIGGER_STATUS_NULL) { + TRACE_AUD_STREAM_W("[AUTO_SYNC][MASTER] audio not ready skip it"); + } else { + TRACE_AUD_STREAM_I("[AUTO_SYNC][MASTER] unhandle status:%d", + app_bt_stream_trigger_stauts_get()); + app_ibrt_if_force_audio_retrigger(); + } + } exit: - return 0; + return 0; } -int app_bt_stream_ibrt_audio_master_detect_next_packet_start(void) -{ - TRACE_AUD_STREAM_I("[AUTO_SYNC][MASTER] start"); +int app_bt_stream_ibrt_audio_master_detect_next_packet_start(void) { + TRACE_AUD_STREAM_I("[AUTO_SYNC][MASTER] start"); - a2dp_audio_detect_next_packet_callback_register(app_bt_stream_ibrt_audio_master_detect_next_packet_cb); - return 0; + a2dp_audio_detect_next_packet_callback_register( + app_bt_stream_ibrt_audio_master_detect_next_packet_cb); + return 0; } #define SLAVE_DETECT_NEXT_PACKET_TO_RETRIGGER_THRESHOLD (120) static uint32_t slave_detect_next_packet_cnt = 0; -int app_bt_stream_ibrt_audio_slave_detect_next_packet_waitforever_cb(btif_media_header_t * header, unsigned char *buf, unsigned int len) -{ - if (app_tws_ibrt_mobile_link_connected() || ++slave_detect_next_packet_cnt > SLAVE_DETECT_NEXT_PACKET_TO_RETRIGGER_THRESHOLD){ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - TRACE_AUD_STREAM_W("[AUTO_SYNC][SLAVE] detect_next_packet ok but currRole:%d mismatch packet_cnt:%d\n", p_ibrt_ctrl->current_role, - slave_detect_next_packet_cnt); - slave_detect_next_packet_cnt = 0; - app_ibrt_if_force_audio_retrigger(); - }else{ - TRACE_AUD_STREAM_I("[AUTO_SYNC][SLAVE] detect_next_packet cnt:%d\n", slave_detect_next_packet_cnt); - a2dp_audio_detect_first_packet(); - } - return 0; -} - -int app_bt_stream_ibrt_audio_slave_detect_next_packet_cb(btif_media_header_t * header, unsigned char *buf, unsigned int len) -{ - if(app_bt_stream_trigger_onprocess()){ - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - int32_t dma_buffer_samples = app_bt_stream_get_dma_buffer_samples()/2; - - if (app_tws_ibrt_mobile_link_connected()){ - TRACE_AUD_STREAM_W("[AUTO_SYNC][SLAVE]cache ok but currRole:%d mismatch\n", p_ibrt_ctrl->current_role); - app_ibrt_if_force_audio_retrigger(); - }else{ - if (app_tws_ibrt_slave_ibrt_link_connected() && - (p_ibrt_ctrl->tws_mode == IBRT_SNIFF_MODE || - p_ibrt_ctrl->mobile_mode == IBRT_SNIFF_MODE || - !app_ibrt_ui_is_profile_exchanged())){ - //flush all - a2dp_audio_synchronize_dest_packet_mut(0); - a2dp_audio_detect_first_packet(); - TRACE_AUD_STREAM_W("[AUTO_SYNC][SLAVE]cache skip delay dma trigger2\n"); - return 0; - } - TRACE_AUD_STREAM_I("[AUTO_SYNC][SLAVE]cache ok use dma trigger2\n"); - //flush all - a2dp_audio_synchronize_dest_packet_mut(0); - uint8_t codec_type = bt_sbc_player_get_codec_type(); -#ifdef A2DP_CP_ACCEL - if(codec_type == BTIF_AVDTP_CODEC_TYPE_LHDC) - { - app_bt_stream_trigger_start(APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME_LHDC - a2dp_audio_frame_delay_get()); - } - else - { - app_bt_stream_trigger_start(APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME - a2dp_audio_frame_delay_get()); - } -#else - app_bt_stream_trigger_start(APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME); -#endif - APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T sync_trigger = {0,}; - A2DP_AUDIO_LASTFRAME_INFO_T lastframe_info = {0,}; - sync_trigger.trigger_time = tg_acl_trigger_time; - if(codec_type == BTIF_AVDTP_CODEC_TYPE_LHDC) - { - sync_trigger.trigger_skip_frame = APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME_LHDC - a2dp_audio_frame_delay_get(); - } - else - { - sync_trigger.trigger_skip_frame = APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME - a2dp_audio_frame_delay_get(); - } - sync_trigger.trigger_type = APP_TWS_IBRT_AUDIO_TRIGGER_TYPE_INIT_SYNC; - if (a2dp_audio_lastframe_info_get(&lastframe_info)<0){ - goto exit; - } - if(codec_type == BTIF_AVDTP_CODEC_TYPE_LHDC) - { - sync_trigger.audio_info.sequenceNumber = lastframe_info.sequenceNumber + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME_LHDC; - sync_trigger.audio_info.timestamp = lastframe_info.timestamp + dma_buffer_samples * APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME_LHDC; - } - else - { - sync_trigger.audio_info.sequenceNumber = lastframe_info.sequenceNumber + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME; - sync_trigger.audio_info.timestamp = lastframe_info.timestamp + dma_buffer_samples * APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME; - } - sync_trigger.audio_info.curSubSequenceNumber = lastframe_info.curSubSequenceNumber; - sync_trigger.audio_info.totalSubSequenceNumber = lastframe_info.totalSubSequenceNumber; - sync_trigger.audio_info.frame_samples = lastframe_info.frame_samples; - sync_trigger.factor_reference = a2dp_audio_get_output_config() ? a2dp_audio_get_output_config()->factor_reference : 1.0f; - sync_trigger.a2dp_session = a2dp_ibrt_session_get(); - sync_trigger.handler_cnt = 0; - - app_bt_stream_ibrt_auto_synchronize_initsync_start(&sync_trigger); - } - } -exit: - return 0; -} - -int app_bt_stream_ibrt_audio_slave_detect_next_packet_start(int need_autotrigger) -{ - TRACE_AUD_STREAM_I("[AUTO_SYNC][SLAVE] start"); +int app_bt_stream_ibrt_audio_slave_detect_next_packet_waitforever_cb( + btif_media_header_t *header, unsigned char *buf, unsigned int len) { + if (app_tws_ibrt_mobile_link_connected() || + ++slave_detect_next_packet_cnt > + SLAVE_DETECT_NEXT_PACKET_TO_RETRIGGER_THRESHOLD) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + TRACE_AUD_STREAM_W("[AUTO_SYNC][SLAVE] detect_next_packet ok but " + "currRole:%d mismatch packet_cnt:%d\n", + p_ibrt_ctrl->current_role, slave_detect_next_packet_cnt); slave_detect_next_packet_cnt = 0; - if (need_autotrigger){ - a2dp_audio_detect_next_packet_callback_register(app_bt_stream_ibrt_audio_slave_detect_next_packet_waitforever_cb); - }else{ - app_tws_ibrt_audio_analysis_start(0, AUDIO_ANALYSIS_CHECKER_INTERVEL_INVALID); - app_tws_ibrt_audio_sync_start(); - a2dp_audio_detect_next_packet_callback_register(app_bt_stream_ibrt_audio_slave_detect_next_packet_cb); + app_ibrt_if_force_audio_retrigger(); + } else { + TRACE_AUD_STREAM_I("[AUTO_SYNC][SLAVE] detect_next_packet cnt:%d\n", + slave_detect_next_packet_cnt); + a2dp_audio_detect_first_packet(); + } + return 0; +} + +int app_bt_stream_ibrt_audio_slave_detect_next_packet_cb( + btif_media_header_t *header, unsigned char *buf, unsigned int len) { + if (app_bt_stream_trigger_onprocess()) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + int32_t dma_buffer_samples = app_bt_stream_get_dma_buffer_samples() / 2; + + if (app_tws_ibrt_mobile_link_connected()) { + TRACE_AUD_STREAM_W( + "[AUTO_SYNC][SLAVE]cache ok but currRole:%d mismatch\n", + p_ibrt_ctrl->current_role); + app_ibrt_if_force_audio_retrigger(); + } else { + if (app_tws_ibrt_slave_ibrt_link_connected() && + (p_ibrt_ctrl->tws_mode == IBRT_SNIFF_MODE || + p_ibrt_ctrl->mobile_mode == IBRT_SNIFF_MODE || + !app_ibrt_ui_is_profile_exchanged())) { + // flush all + a2dp_audio_synchronize_dest_packet_mut(0); + a2dp_audio_detect_first_packet(); + TRACE_AUD_STREAM_W("[AUTO_SYNC][SLAVE]cache skip delay dma trigger2\n"); + return 0; + } + TRACE_AUD_STREAM_I("[AUTO_SYNC][SLAVE]cache ok use dma trigger2\n"); + // flush all + a2dp_audio_synchronize_dest_packet_mut(0); + uint8_t codec_type = bt_sbc_player_get_codec_type(); +#ifdef A2DP_CP_ACCEL + if (codec_type == BTIF_AVDTP_CODEC_TYPE_LHDC) { + app_bt_stream_trigger_start( + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME_LHDC - + a2dp_audio_frame_delay_get()); + } else { + app_bt_stream_trigger_start( + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME - + a2dp_audio_frame_delay_get()); + } +#else + app_bt_stream_trigger_start( + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME); +#endif + APP_TWS_IBRT_AUDIO_SYNC_TRIGGER_T sync_trigger = { + 0, + }; + A2DP_AUDIO_LASTFRAME_INFO_T lastframe_info = { + 0, + }; + sync_trigger.trigger_time = tg_acl_trigger_time; + if (codec_type == BTIF_AVDTP_CODEC_TYPE_LHDC) { + sync_trigger.trigger_skip_frame = + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME_LHDC - + a2dp_audio_frame_delay_get(); + } else { + sync_trigger.trigger_skip_frame = + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME - + a2dp_audio_frame_delay_get(); + } + sync_trigger.trigger_type = APP_TWS_IBRT_AUDIO_TRIGGER_TYPE_INIT_SYNC; + if (a2dp_audio_lastframe_info_get(&lastframe_info) < 0) { + goto exit; + } + if (codec_type == BTIF_AVDTP_CODEC_TYPE_LHDC) { + sync_trigger.audio_info.sequenceNumber = + lastframe_info.sequenceNumber + + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME_LHDC; + sync_trigger.audio_info.timestamp = + lastframe_info.timestamp + + dma_buffer_samples * + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME_LHDC; + } else { + sync_trigger.audio_info.sequenceNumber = + lastframe_info.sequenceNumber + + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME; + sync_trigger.audio_info.timestamp = + lastframe_info.timestamp + + dma_buffer_samples * + APP_BT_STREAM_IBRT_AUTO_SYNCHRONIZE_INITSYNC_SKIP_FRAME; + } + sync_trigger.audio_info.curSubSequenceNumber = + lastframe_info.curSubSequenceNumber; + sync_trigger.audio_info.totalSubSequenceNumber = + lastframe_info.totalSubSequenceNumber; + sync_trigger.audio_info.frame_samples = lastframe_info.frame_samples; + sync_trigger.factor_reference = + a2dp_audio_get_output_config() + ? a2dp_audio_get_output_config()->factor_reference + : 1.0f; + sync_trigger.a2dp_session = a2dp_ibrt_session_get(); + sync_trigger.handler_cnt = 0; + + app_bt_stream_ibrt_auto_synchronize_initsync_start(&sync_trigger); } - return 0; + } +exit: + return 0; +} + +int app_bt_stream_ibrt_audio_slave_detect_next_packet_start( + int need_autotrigger) { + TRACE_AUD_STREAM_I("[AUTO_SYNC][SLAVE] start"); + slave_detect_next_packet_cnt = 0; + if (need_autotrigger) { + a2dp_audio_detect_next_packet_callback_register( + app_bt_stream_ibrt_audio_slave_detect_next_packet_waitforever_cb); + } else { + app_tws_ibrt_audio_analysis_start(0, + AUDIO_ANALYSIS_CHECKER_INTERVEL_INVALID); + app_tws_ibrt_audio_sync_start(); + a2dp_audio_detect_next_packet_callback_register( + app_bt_stream_ibrt_audio_slave_detect_next_packet_cb); + } + return 0; } #else -int app_bt_stream_detect_next_packet_cb(btif_media_header_t * header, unsigned char *buf, unsigned int len) -{ - if(app_bt_stream_trigger_onprocess()){ - TRACE_AUD_STREAM_I("[AUTO_SYNC] start"); - app_bt_stream_trigger_start(0); - } +int app_bt_stream_detect_next_packet_cb(btif_media_header_t *header, + unsigned char *buf, unsigned int len) { + if (app_bt_stream_trigger_onprocess()) { + TRACE_AUD_STREAM_I("[AUTO_SYNC] start"); + app_bt_stream_trigger_start(0); + } + return 0; +} +#endif + +void app_audio_buffer_check(void) { + bool buffer_check = (APP_AUDIO_BUFFER_SIZE + APP_CAPTURE_AUDIO_BUFFER_SIZE) <= + syspool_original_size(); + + TRACE_AUD_STREAM_I( + "audio buf size[%d] capture buf size[%d] total available space[%d]", + APP_AUDIO_BUFFER_SIZE, APP_CAPTURE_AUDIO_BUFFER_SIZE, + syspool_original_size()); + + ASSERT( + buffer_check, + "Audio buffer[%d]+Capture buffer[%d] exceeds the maximum ram sapce[%d]", + APP_AUDIO_BUFFER_SIZE, APP_CAPTURE_AUDIO_BUFFER_SIZE, + syspool_original_size()); +} + +static bool isRun = false; + +int bt_sbc_player(enum PLAYER_OPER_T on, enum APP_SYSFREQ_FREQ_T freq) { + struct AF_STREAM_CONFIG_T stream_cfg; + enum AUD_SAMPRATE_T sample_rate; + const char *g_log_player_oper_str[] = { + "PLAYER_OPER_START", + "PLAYER_OPER_STOP", + "PLAYER_OPER_RESTART", + }; + + uint8_t *bt_audio_buff = NULL; + + uint8_t POSSIBLY_UNUSED *bt_eq_buff = NULL; + uint32_t POSSIBLY_UNUSED eq_buff_size = 0; + uint8_t POSSIBLY_UNUSED play_samp_size; + TRACE_AUD_STREAM_I("[A2DP_PLAYER] work:%d op:%s freq:%d :sample:%d \n", isRun, + g_log_player_oper_str[on], freq, a2dp_sample_rate); + + bt_set_playback_triggered(false); + + if ((isRun && on == PLAYER_OPER_START) || + (!isRun && on == PLAYER_OPER_STOP)) { + TRACE_AUD_STREAM_W("[A2DP_PLAYER],fail,isRun=%x,on=%x", isRun, on); return 0; -} -#endif + } -void app_audio_buffer_check(void) -{ - bool buffer_check = (APP_AUDIO_BUFFER_SIZE + APP_CAPTURE_AUDIO_BUFFER_SIZE) <= syspool_original_size(); + uint8_t codec_type = bt_sbc_player_get_codec_type(); - TRACE_AUD_STREAM_I("audio buf size[%d] capture buf size[%d] total available space[%d]", - APP_AUDIO_BUFFER_SIZE, APP_CAPTURE_AUDIO_BUFFER_SIZE, syspool_original_size()); - - ASSERT(buffer_check, - "Audio buffer[%d]+Capture buffer[%d] exceeds the maximum ram sapce[%d]", - APP_AUDIO_BUFFER_SIZE, APP_CAPTURE_AUDIO_BUFFER_SIZE, syspool_original_size()); -} - -static bool isRun = false; - -int bt_sbc_player(enum PLAYER_OPER_T on, enum APP_SYSFREQ_FREQ_T freq) -{ - struct AF_STREAM_CONFIG_T stream_cfg; - enum AUD_SAMPRATE_T sample_rate; - const char *g_log_player_oper_str[] = - { - "PLAYER_OPER_START", - "PLAYER_OPER_STOP", - "PLAYER_OPER_RESTART", - }; - - uint8_t* bt_audio_buff = NULL; - - uint8_t POSSIBLY_UNUSED *bt_eq_buff = NULL; - uint32_t POSSIBLY_UNUSED eq_buff_size = 0; - uint8_t POSSIBLY_UNUSED play_samp_size; - TRACE_AUD_STREAM_I("[A2DP_PLAYER] work:%d op:%s freq:%d :sample:%d \n", isRun, g_log_player_oper_str[on], freq,a2dp_sample_rate); - - bt_set_playback_triggered(false); - - if ((isRun && on == PLAYER_OPER_START) || (!isRun && on == PLAYER_OPER_STOP)) - { - TRACE_AUD_STREAM_W("[A2DP_PLAYER],fail,isRun=%x,on=%x",isRun,on); - return 0; - } - - uint8_t codec_type = bt_sbc_player_get_codec_type(); - - if (on == PLAYER_OPER_STOP || on == PLAYER_OPER_RESTART) - { + if (on == PLAYER_OPER_STOP || on == PLAYER_OPER_RESTART) { #ifdef __THIRDPARTY - start_by_sbc = false; + start_by_sbc = false; #endif - #ifdef WL_DET - app_mic_alg_audioloop(false,APP_SYSFREQ_78M); + app_mic_alg_audioloop(false, APP_SYSFREQ_78M); #endif #ifdef PLAYBACK_USE_I2S - hal_cmu_audio_resample_enable(); + hal_cmu_audio_resample_enable(); #endif #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - bool isToClearActiveMedia = audio_prompt_clear_pending_stream(PENDING_TO_STOP_A2DP_STREAMING); - if (isToClearActiveMedia) - { - // clear active media mark - bt_media_clear_media_type(BT_STREAM_SBC, BT_DEVICE_ID_1); - bt_media_current_sbc_set(BT_DEVICE_NUM); - } + bool isToClearActiveMedia = + audio_prompt_clear_pending_stream(PENDING_TO_STOP_A2DP_STREAMING); + if (isToClearActiveMedia) { + // clear active media mark + bt_media_clear_media_type(BT_STREAM_SBC, BT_DEVICE_ID_1); + bt_media_current_sbc_set(BT_DEVICE_NUM); + } #endif #if defined(IBRT) - app_bt_stream_ibrt_auto_synchronize_stop(); - app_tws_ibrt_audio_analysis_stop(); - app_tws_ibrt_audio_sync_stop(); + app_bt_stream_ibrt_auto_synchronize_stop(); + app_tws_ibrt_audio_analysis_stop(); + app_tws_ibrt_audio_sync_stop(); #endif #if (A2DP_DECODER_VER == 2) - a2dp_audio_stop(); + a2dp_audio_stop(); #endif - af_codec_set_playback_post_handler(NULL); - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_codec_set_playback_post_handler(NULL); + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); #if defined(AUDIO_ANC_FB_MC) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) #ifdef AUDIO_ANC_FB_ADJ_MC - af_stream_stop(ADJ_MC_STREAM_ID, AUD_STREAM_CAPTURE); + af_stream_stop(ADJ_MC_STREAM_ID, AUD_STREAM_CAPTURE); #endif - af_stream_stop(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); + af_stream_stop(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); #endif -#if defined(MUSIC_DELAY_CONTROL) && (defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A)|| defined(CHIP_BEST1400)|| defined(CHIP_BEST1402)) - calib_reset = 1; - af_stream_dma_tc_irq_disable(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); +#if defined(MUSIC_DELAY_CONTROL) && \ + (defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || \ + defined(CHIP_BEST2300A) || defined(CHIP_BEST1400) || \ + defined(CHIP_BEST1402)) + calib_reset = 1; + af_stream_dma_tc_irq_disable(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); #endif - af_stream_dma_tc_irq_disable(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_dma_tc_irq_disable(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); #if defined(__AUDIO_SPECTRUM__) - audio_spectrum_close(); + audio_spectrum_close(); #endif - audio_process_close(); + audio_process_close(); - TRACE_AUD_STREAM_I("[A2DP_PLAYER] syspool free size: %d/%d", syspool_free_size(), syspool_total_size()); + TRACE_AUD_STREAM_I("[A2DP_PLAYER] syspool free size: %d/%d", + syspool_free_size(), syspool_total_size()); #if !(defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE)) - af_codec_tune(AUD_STREAM_PLAYBACK, 0); + af_codec_tune(AUD_STREAM_PLAYBACK, 0); #endif - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); #if defined(AUDIO_ANC_FB_MC) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) #ifdef AUDIO_ANC_FB_ADJ_MC - af_stream_close(ADJ_MC_STREAM_ID, AUD_STREAM_CAPTURE); + af_stream_close(ADJ_MC_STREAM_ID, AUD_STREAM_CAPTURE); #endif - af_stream_close(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); + af_stream_close(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); #endif - bt_sbc_mode = 0; + bt_sbc_mode = 0; #ifdef VOICE_DATAPATH - app_voicepath_set_stream_state(AUDIO_OUTPUT_STREAMING, false); - app_voicepath_set_pending_started_stream(AUDIO_OUTPUT_STREAMING, false); + app_voicepath_set_stream_state(AUDIO_OUTPUT_STREAMING, false); + app_voicepath_set_pending_started_stream(AUDIO_OUTPUT_STREAMING, false); #endif #ifdef AI_AEC_CP_ACCEL - cp_aec_deinit(); + cp_aec_deinit(); #endif - af_set_irq_notification(NULL); - if (on == PLAYER_OPER_STOP) - { + af_set_irq_notification(NULL); + if (on == PLAYER_OPER_STOP) { - osThreadId ctrl_thread_id = NULL; - osPriority ctrl_thread_priority; - ctrl_thread_id = osThreadGetId(); - ctrl_thread_priority = osThreadGetPriority(ctrl_thread_id); - osThreadSetPriority(ctrl_thread_id, osPriorityLow); - app_bt_stream_trigger_checker_stop(); + osThreadId ctrl_thread_id = NULL; + osPriority ctrl_thread_priority; + ctrl_thread_id = osThreadGetId(); + ctrl_thread_priority = osThreadGetPriority(ctrl_thread_id); + osThreadSetPriority(ctrl_thread_id, osPriorityLow); + app_bt_stream_trigger_checker_stop(); #ifdef USER_REBOOT_PLAY_MUSIC_AUTO - TRACE_AUD_STREAM_I("[A2DP_PLAYER] hal_sw_bootmode_clear HAL_SW_BOOTMODE_LOCAL_PLAYER!!!!!!"); - hal_sw_bootmode_clear(HAL_SW_BOOTMODE_LOCAL_PLAYER); + TRACE_AUD_STREAM_I("[A2DP_PLAYER] hal_sw_bootmode_clear " + "HAL_SW_BOOTMODE_LOCAL_PLAYER!!!!!!"); + hal_sw_bootmode_clear(HAL_SW_BOOTMODE_LOCAL_PLAYER); #endif #ifdef __A2DP_PLAYER_USE_BT_TRIGGER__ - app_bt_stream_trigger_deinit(); + app_bt_stream_trigger_deinit(); #endif #ifndef FPGA #ifdef BT_XTAL_SYNC - bt_term_xtal_sync(false); + bt_term_xtal_sync(false); #ifndef BT_XTAL_SYNC_NO_RESET - bt_term_xtal_sync_default(); + bt_term_xtal_sync_default(); #endif #endif #endif - a2dp_audio_deinit(); -#if defined(AUDIO_ANC_FB_MC) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__)&&defined(AUDIO_ANC_FB_ADJ_MC) - adj_mc_deinit(); + a2dp_audio_deinit(); +#if defined(AUDIO_ANC_FB_MC) && defined(ANC_APP) && \ + !defined(__AUDIO_RESAMPLE__) && defined(AUDIO_ANC_FB_ADJ_MC) + adj_mc_deinit(); #endif - app_overlay_unloadall(); + app_overlay_unloadall(); #ifdef __THIRDPARTY - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1,THIRDPARTY_STOP2MIC); - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1,THIRDPARTY_START); + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1, + THIRDPARTY_STOP2MIC); + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1, + THIRDPARTY_START); #endif - app_sysfreq_req(APP_SYSFREQ_USER_BT_A2DP, APP_SYSFREQ_32K); - osThreadSetPriority(ctrl_thread_id, ctrl_thread_priority); - af_set_priority(AF_USER_SBC, osPriorityAboveNormal); + app_sysfreq_req(APP_SYSFREQ_USER_BT_A2DP, APP_SYSFREQ_32K); + osThreadSetPriority(ctrl_thread_id, ctrl_thread_priority); + af_set_priority(AF_USER_SBC, osPriorityAboveNormal); -#if defined(__AI_VOICE__)||defined(BISTO_ENABLED) - app_ai_if_inform_music_or_prompt_status(false, 0); +#if defined(__AI_VOICE__) || defined(BISTO_ENABLED) + app_ai_if_inform_music_or_prompt_status(false, 0); #endif #if defined(IBRT) - app_ibrt_if_exec_sleep_hook_blocker_clr(APP_IBRT_IF_SLEEP_HOOK_BLOCKER_A2DP_STREAMING); + app_ibrt_if_exec_sleep_hook_blocker_clr( + APP_IBRT_IF_SLEEP_HOOK_BLOCKER_A2DP_STREAMING); #endif - } } + } - if (on == PLAYER_OPER_START || on == PLAYER_OPER_RESTART) - { + if (on == PLAYER_OPER_START || on == PLAYER_OPER_RESTART) { #if USER_REBOOT_PLAY_MUSIC_AUTO - TRACE_AUD_STREAM_I("[A2DP_PLAYER] hal_sw_bootmode_set HAL_SW_BOOTMODE_LOCAL_PLAYER!!!!!!"); - hal_sw_bootmode_set(HAL_SW_BOOTMODE_LOCAL_PLAYER); + TRACE_AUD_STREAM_I( + "[A2DP_PLAYER] hal_sw_bootmode_set HAL_SW_BOOTMODE_LOCAL_PLAYER!!!!!!"); + hal_sw_bootmode_set(HAL_SW_BOOTMODE_LOCAL_PLAYER); #endif -#if defined(__AI_VOICE__)||defined(BISTO_ENABLED) - app_ai_if_inform_music_or_prompt_status(true, a2dp_sample_rate); - app_ai_if_pre_music_or_prompt_check(); +#if defined(__AI_VOICE__) || defined(BISTO_ENABLED) + app_ai_if_inform_music_or_prompt_status(true, a2dp_sample_rate); + app_ai_if_pre_music_or_prompt_check(); #endif #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - audio_prompt_stop_playing(); + audio_prompt_stop_playing(); #endif #if defined(IBRT) - app_ibrt_if_exec_sleep_hook_blocker_set(APP_IBRT_IF_SLEEP_HOOK_BLOCKER_A2DP_STREAMING); + app_ibrt_if_exec_sleep_hook_blocker_set( + APP_IBRT_IF_SLEEP_HOOK_BLOCKER_A2DP_STREAMING); #endif #ifdef __THIRDPARTY - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1,THIRDPARTY_STOP); + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1, + THIRDPARTY_STOP); #endif - af_set_priority(AF_USER_SBC, osPriorityHigh); - bt_media_volume_ptr_update_by_mediatype(BT_STREAM_SBC); - stream_local_volume = btdevice_volume_p->a2dp_vol; - app_audio_mempool_init_with_specific_size(APP_AUDIO_BUFFER_SIZE); + af_set_priority(AF_USER_SBC, osPriorityHigh); + bt_media_volume_ptr_update_by_mediatype(BT_STREAM_SBC); + stream_local_volume = btdevice_volume_p->a2dp_vol; + app_audio_mempool_init_with_specific_size(APP_AUDIO_BUFFER_SIZE); #ifdef __BT_ONE_BRING_TWO__ - if (btif_me_get_activeCons()>1) - { - if (freq < APP_SYSFREQ_104M) { - freq = APP_SYSFREQ_104M; - } - } + if (btif_me_get_activeCons() > 1) { + if (freq < APP_SYSFREQ_104M) { + freq = APP_SYSFREQ_104M; + } + } #endif #ifdef __PC_CMD_UART__ - if (freq < APP_SYSFREQ_104M) { - freq = APP_SYSFREQ_104M; - } + if (freq < APP_SYSFREQ_104M) { + freq = APP_SYSFREQ_104M; + } #endif -#if defined(__SW_IIR_EQ_PROCESS__)&&defined(__HW_FIR_EQ_PROCESS__)&&defined(CHIP_BEST1000) - if (audio_eq_hw_fir_cfg_list[bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_FIR,0)]->len>128) - { - if (freq < APP_SYSFREQ_104M) - { - freq = APP_SYSFREQ_104M; - } - } +#if defined(__SW_IIR_EQ_PROCESS__) && defined(__HW_FIR_EQ_PROCESS__) && \ + defined(CHIP_BEST1000) + if (audio_eq_hw_fir_cfg_list[bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_FIR, 0)] + ->len > 128) { + if (freq < APP_SYSFREQ_104M) { + freq = APP_SYSFREQ_104M; + } + } #endif -#if defined(APP_MUSIC_26M) && !defined(__SW_IIR_EQ_PROCESS__)&& !defined(__HW_IIR_EQ_PROCESS__)&& !defined(__HW_FIR_EQ_PROCESS__) - if (freq < APP_SYSFREQ_26M) { - freq = APP_SYSFREQ_26M; - } +#if defined(APP_MUSIC_26M) && !defined(__SW_IIR_EQ_PROCESS__) && \ + !defined(__HW_IIR_EQ_PROCESS__) && !defined(__HW_FIR_EQ_PROCESS__) + if (freq < APP_SYSFREQ_26M) { + freq = APP_SYSFREQ_26M; + } #else - if (freq < APP_SYSFREQ_52M) { - freq = APP_SYSFREQ_52M; - } + if (freq < APP_SYSFREQ_52M) { + freq = APP_SYSFREQ_52M; + } #endif #if defined(AUDIO_ANC_FB_MC) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - if (freq < APP_SYSFREQ_104M) { - freq = APP_SYSFREQ_104M; - } + if (freq < APP_SYSFREQ_104M) { + freq = APP_SYSFREQ_104M; + } #endif - TRACE_AUD_STREAM_I("[A2DP_PLAYER] codec_type:%d", codec_type); + TRACE_AUD_STREAM_I("[A2DP_PLAYER] codec_type:%d", codec_type); #if defined(A2DP_AAC_ON) - if (codec_type == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { - if(freq < APP_SYSFREQ_52M) { - freq = APP_SYSFREQ_52M; - } - } + if (codec_type == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { + if (freq < APP_SYSFREQ_52M) { + freq = APP_SYSFREQ_52M; + } + } #endif #if defined(A2DP_SCALABLE_ON) - if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - { - if(a2dp_sample_rate==44100) - { - if(freq < APP_SYSFREQ_78M) { - freq = APP_SYSFREQ_78M; - } - } - else if(a2dp_sample_rate==96000) - { - if (freq < APP_SYSFREQ_208M) { - freq = APP_SYSFREQ_208M; - } - } + if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + if (a2dp_sample_rate == 44100) { + if (freq < APP_SYSFREQ_78M) { + freq = APP_SYSFREQ_78M; } - TRACE_AUD_STREAM_I("[A2DP_PLAYER] a2dp_sample_rate=%d",a2dp_sample_rate); + } else if (a2dp_sample_rate == 96000) { + if (freq < APP_SYSFREQ_208M) { + freq = APP_SYSFREQ_208M; + } + } + } + TRACE_AUD_STREAM_I("[A2DP_PLAYER] a2dp_sample_rate=%d", a2dp_sample_rate); #endif #if defined(__AUDIO_DRC__) || defined(__AUDIO_DRC2__) - freq = (freq < APP_SYSFREQ_208M)?APP_SYSFREQ_208M:freq; + freq = (freq < APP_SYSFREQ_208M) ? APP_SYSFREQ_208M : freq; #endif #ifdef AUDIO_OUTPUT_SW_GAIN - freq = (freq < APP_SYSFREQ_104M)?APP_SYSFREQ_104M:freq; + freq = (freq < APP_SYSFREQ_104M) ? APP_SYSFREQ_104M : freq; #endif #ifdef PLAYBACK_FORCE_48K - freq = (freq < APP_SYSFREQ_104M)?APP_SYSFREQ_104M:freq; + freq = (freq < APP_SYSFREQ_104M) ? APP_SYSFREQ_104M : freq; #endif #ifdef A2DP_CP_ACCEL - // Default freq for SBC - freq = APP_SYSFREQ_26M; + // Default freq for SBC + freq = APP_SYSFREQ_26M; #if defined(A2DP_AAC_ON) - if (codec_type == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { - freq = APP_SYSFREQ_26M; - } + if (codec_type == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { + freq = APP_SYSFREQ_26M; + } #endif #if defined(A2DP_LHDC_ON) || defined(A2DP_SCALABLE_ON) || defined(A2DP_LDAC_ON) - if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP){ - freq = APP_SYSFREQ_52M; - } - - if (a2dp_sample_rate==AUD_SAMPRATE_96000) - { - freq = APP_SYSFREQ_104M; - } + if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + freq = APP_SYSFREQ_52M; + } + + if (a2dp_sample_rate == AUD_SAMPRATE_96000) { + freq = APP_SYSFREQ_104M; + } #endif #if defined(AUDIO_ANC_FB_MC) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - if (freq < APP_SYSFREQ_52M) { - freq = APP_SYSFREQ_52M; - } + if (freq < APP_SYSFREQ_52M) { + freq = APP_SYSFREQ_52M; + } #endif #if defined(A2DP_LDAC_ON) - if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP){ - if (a2dp_sample_rate==AUD_SAMPRATE_96000 || a2dp_sample_rate==AUD_SAMPRATE_88200) - { - freq = APP_SYSFREQ_104M; - }else - { - freq = APP_SYSFREQ_52M; - } - } + if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + if (a2dp_sample_rate == AUD_SAMPRATE_96000 || + a2dp_sample_rate == AUD_SAMPRATE_88200) { + freq = APP_SYSFREQ_104M; + } else { + freq = APP_SYSFREQ_52M; + } + } #endif #endif - freq = APP_SYSFREQ_52M; - app_sysfreq_req(APP_SYSFREQ_USER_BT_A2DP, freq); - TRACE_AUD_STREAM_I("[A2DP_PLAYER] sysfreq %d", freq); - TRACE_AUD_STREAM_I("[A2DP_PLAYER] sysfreq calc : %d\n", hal_sys_timer_calc_cpu_freq(5, 0)); + freq = APP_SYSFREQ_52M; + app_sysfreq_req(APP_SYSFREQ_USER_BT_A2DP, freq); + TRACE_AUD_STREAM_I("[A2DP_PLAYER] sysfreq %d", freq); + TRACE_AUD_STREAM_I("[A2DP_PLAYER] sysfreq calc : %d\n", + hal_sys_timer_calc_cpu_freq(5, 0)); - if (on == PLAYER_OPER_START) - { - af_set_irq_notification(app_bt_stream_playback_irq_notification); - ASSERT(!app_ring_merge_isrun(), "Ring playback will be abnormal, please check."); - if (0) - { - } + if (on == PLAYER_OPER_START) { + af_set_irq_notification(app_bt_stream_playback_irq_notification); + ASSERT(!app_ring_merge_isrun(), + "Ring playback will be abnormal, please check."); + if (0) { + } #if defined(A2DP_AAC_ON) - else if (codec_type == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) - { - app_overlay_select(APP_OVERLAY_A2DP_AAC); - } + else if (codec_type == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { + app_overlay_select(APP_OVERLAY_A2DP_AAC); + } #endif - else if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - { - TRACE(1,"current_a2dp_non_type %d", current_a2dp_non_type); + else if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + TRACE(1, "current_a2dp_non_type %d", current_a2dp_non_type); #if defined(A2DP_LHDC_ON) - if(current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LHDC) - { - app_overlay_select(APP_OVERLAY_A2DP_LHDC); - } + if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LHDC) { + app_overlay_select(APP_OVERLAY_A2DP_LHDC); + } #endif #if defined(A2DP_SCALABLE_ON) - else if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_SCALABLE) - { - app_overlay_select(APP_OVERLAY_A2DP_SCALABLE); - } + else if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_SCALABLE) { + app_overlay_select(APP_OVERLAY_A2DP_SCALABLE); + } #endif #if defined(A2DP_LDAC_ON) - else if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LDAC) - { - TRACE_AUD_STREAM_I("[A2DP_PLAYER] ldac overlay select \n"); //toto - app_overlay_select(APP_OVERLAY_A2DP_LDAC); - } + else if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LDAC) { + TRACE_AUD_STREAM_I("[A2DP_PLAYER] ldac overlay select \n"); // toto + app_overlay_select(APP_OVERLAY_A2DP_LDAC); + } #endif - } - else - { - app_overlay_select(APP_OVERLAY_A2DP); - } + } else { + app_overlay_select(APP_OVERLAY_A2DP); + } #ifdef BT_XTAL_SYNC #ifdef __TWS__ - if(app_tws_mode_is_only_mobile()) - { - btdrv_rf_bit_offset_track_enable(false); - } - else + if (app_tws_mode_is_only_mobile()) { + btdrv_rf_bit_offset_track_enable(false); + } else #endif - { - btdrv_rf_bit_offset_track_enable(true); - } - bt_init_xtal_sync(BT_XTAL_SYNC_MODE_MUSIC, BT_INIT_XTAL_SYNC_MIN, BT_INIT_XTAL_SYNC_MAX, BT_INIT_XTAL_SYNC_FCAP_RANGE); + { + btdrv_rf_bit_offset_track_enable(true); + } + bt_init_xtal_sync(BT_XTAL_SYNC_MODE_MUSIC, BT_INIT_XTAL_SYNC_MIN, + BT_INIT_XTAL_SYNC_MAX, BT_INIT_XTAL_SYNC_FCAP_RANGE); #endif // BT_XTAL_SYNC #ifdef __THIRDPARTY - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1,THIRDPARTY_START2MIC); + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1, + THIRDPARTY_START2MIC); #endif - bt_sbc_mode = 1; - } + bt_sbc_mode = 1; + } #ifdef __THIRDPARTY - //app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1,THIRDPARTY_STOP); - start_by_sbc = true; - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1,THIRDPARTY_START); + // app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1,THIRDPARTY_STOP); + start_by_sbc = true; + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1, + THIRDPARTY_START); #endif #if defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE) - sample_rate = AUD_SAMPRATE_50781; + sample_rate = AUD_SAMPRATE_50781; #else - sample_rate = a2dp_sample_rate; + sample_rate = a2dp_sample_rate; #endif #ifdef PLAYBACK_USE_I2S - hal_cmu_audio_resample_disable(); + hal_cmu_audio_resample_disable(); #endif - memset(&stream_cfg, 0, sizeof(stream_cfg)); + memset(&stream_cfg, 0, sizeof(stream_cfg)); - stream_cfg.channel_num = AUD_CHANNEL_NUM_2; + stream_cfg.channel_num = AUD_CHANNEL_NUM_2; #ifdef PLAYBACK_FORCE_48K - stream_cfg.sample_rate = AUD_SAMPRATE_48000; + stream_cfg.sample_rate = AUD_SAMPRATE_48000; #else - stream_cfg.sample_rate = sample_rate; + stream_cfg.sample_rate = sample_rate; #endif #ifdef FPGA - stream_cfg.device = AUD_STREAM_USE_EXT_CODEC; + stream_cfg.device = AUD_STREAM_USE_EXT_CODEC; #else #ifdef PLAYBACK_USE_I2S - stream_cfg.device = AUD_STREAM_USE_I2S0_MASTER; + stream_cfg.device = AUD_STREAM_USE_I2S0_MASTER; #else - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; #endif #endif #ifdef PLAYBACK_USE_I2S - stream_cfg.io_path = AUD_IO_PATH_NULL; + stream_cfg.io_path = AUD_IO_PATH_NULL; #else - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; #endif - stream_cfg.vol = stream_local_volume; - stream_cfg.handler = bt_sbc_player_more_data; + stream_cfg.vol = stream_local_volume; + stream_cfg.handler = bt_sbc_player_more_data; - - if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP){ + if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { #if defined(A2DP_SCALABLE_ON) - if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_SCALABLE){ - stream_cfg.data_size = SCALABLE_FRAME_SIZE*8; - } + if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_SCALABLE) { + stream_cfg.data_size = SCALABLE_FRAME_SIZE * 8; + } #endif #if defined(A2DP_LHDC_ON) - if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LHDC){ + if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LHDC) { #if defined(A2DP_LHDC_V3) - if (bt_get_sbc_sample_rate() == AUD_SAMPRATE_96000) { - stream_cfg.data_size = LHDC_AUDIO_96K_BUFF_SIZE; - } else { - stream_cfg.data_size = LHDC_AUDIO_BUFF_SIZE; - } - if (a2dp_lhdc_config_llc_get()){ - TRACE_AUD_STREAM_I("[A2DP_PLAYER] USE LHDC_LLC"); - stream_cfg.data_size = LHDC_LLC_AUDIO_BUFF_SIZE; - } + if (bt_get_sbc_sample_rate() == AUD_SAMPRATE_96000) { + stream_cfg.data_size = LHDC_AUDIO_96K_BUFF_SIZE; + } else { + stream_cfg.data_size = LHDC_AUDIO_BUFF_SIZE; + } + if (a2dp_lhdc_config_llc_get()) { + TRACE_AUD_STREAM_I("[A2DP_PLAYER] USE LHDC_LLC"); + stream_cfg.data_size = LHDC_LLC_AUDIO_BUFF_SIZE; + } #else - stream_cfg.data_size = LHDC_AUDIO_BUFF_SIZE; + stream_cfg.data_size = LHDC_AUDIO_BUFF_SIZE; #endif - } + } #endif #if defined(A2DP_LDAC_ON) - if(current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LDAC) - { - stream_cfg.data_size = BT_AUDIO_BUFF_SIZE_LDAC; - } + if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LDAC) { + stream_cfg.data_size = BT_AUDIO_BUFF_SIZE_LDAC; + } #endif - }else + } else #if defined(A2DP_AAC_ON) - if (codec_type == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC){ - stream_cfg.data_size = BT_AUDIO_BUFF_AAC_SIZE; - }else + if (codec_type == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { + stream_cfg.data_size = BT_AUDIO_BUFF_AAC_SIZE; + } else #endif - { - if (stream_cfg.sample_rate == AUD_SAMPRATE_44100){ - stream_cfg.data_size = BT_AUDIO_BUFF_SBC_44P1K_SIZE; - }else{ - stream_cfg.data_size = BT_AUDIO_BUFF_SBC_48K_SIZE; - } - } + { + if (stream_cfg.sample_rate == AUD_SAMPRATE_44100) { + stream_cfg.data_size = BT_AUDIO_BUFF_SBC_44P1K_SIZE; + } else { + stream_cfg.data_size = BT_AUDIO_BUFF_SBC_48K_SIZE; + } + } - stream_cfg.bits = AUD_BITS_16; + stream_cfg.bits = AUD_BITS_16; #ifdef A2DP_EQ_24BIT - stream_cfg.data_size *= 2; - stream_cfg.bits = AUD_BITS_24; -#elif defined(A2DP_SCALABLE_ON) || defined(A2DP_LHDC_ON) || defined(A2DP_LDAC_ON) - if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { - stream_cfg.data_size *= 2; - stream_cfg.bits = AUD_BITS_24; - } + stream_cfg.data_size *= 2; + stream_cfg.bits = AUD_BITS_24; +#elif defined(A2DP_SCALABLE_ON) || defined(A2DP_LHDC_ON) || \ + defined(A2DP_LDAC_ON) + if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + stream_cfg.data_size *= 2; + stream_cfg.bits = AUD_BITS_24; + } #endif -#if 0//defined(A2DP_LHDC_ON) +#if 0 // defined(A2DP_LHDC_ON) if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { if(bt_sbc_player_get_sample_bit() == AUD_BITS_16) @@ -3870,731 +4046,749 @@ int bt_sbc_player(enum PLAYER_OPER_T on, enum APP_SYSFREQ_FREQ_T freq) } #endif - a2dp_data_buf_size = stream_cfg.data_size; + a2dp_data_buf_size = stream_cfg.data_size; - app_audio_mempool_get_buff(&bt_audio_buff, stream_cfg.data_size); - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); -#if defined(MUSIC_DELAY_CONTROL) && (defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A)|| defined(CHIP_BEST1400)|| defined(CHIP_BEST1402)) - lowdelay_sample_size_play_bt=stream_cfg.bits; - lowdelay_sample_rate_play_bt=stream_cfg.sample_rate; - lowdelay_data_size_play_bt=stream_cfg.data_size; - lowdelay_playback_ch_num_bt=stream_cfg.channel_num; + app_audio_mempool_get_buff(&bt_audio_buff, stream_cfg.data_size); + stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); +#if defined(MUSIC_DELAY_CONTROL) && \ + (defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || \ + defined(CHIP_BEST2300A) || defined(CHIP_BEST1400) || \ + defined(CHIP_BEST1402)) + lowdelay_sample_size_play_bt = stream_cfg.bits; + lowdelay_sample_rate_play_bt = stream_cfg.sample_rate; + lowdelay_data_size_play_bt = stream_cfg.data_size; + lowdelay_playback_ch_num_bt = stream_cfg.channel_num; #endif - #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - uint8_t* promptTmpSourcePcmDataBuf; - uint8_t* promptTmpTargetPcmDataBuf; - uint8_t* promptPcmDataBuf; - uint8_t* promptResamplerBuf; + uint8_t *promptTmpSourcePcmDataBuf; + uint8_t *promptTmpTargetPcmDataBuf; + uint8_t *promptPcmDataBuf; + uint8_t *promptResamplerBuf; - app_audio_mempool_get_buff(&promptTmpSourcePcmDataBuf, AUDIO_PROMPT_SOURCE_PCM_BUFFER_SIZE); - app_audio_mempool_get_buff(&promptTmpTargetPcmDataBuf, AUDIO_PROMPT_TARGET_PCM_BUFFER_SIZE); - app_audio_mempool_get_buff(&promptPcmDataBuf, AUDIO_PROMPT_PCM_BUFFER_SIZE); - app_audio_mempool_get_buff(&promptResamplerBuf, AUDIO_PROMPT_BUF_SIZE_FOR_RESAMPLER); + app_audio_mempool_get_buff(&promptTmpSourcePcmDataBuf, + AUDIO_PROMPT_SOURCE_PCM_BUFFER_SIZE); + app_audio_mempool_get_buff(&promptTmpTargetPcmDataBuf, + AUDIO_PROMPT_TARGET_PCM_BUFFER_SIZE); + app_audio_mempool_get_buff(&promptPcmDataBuf, AUDIO_PROMPT_PCM_BUFFER_SIZE); + app_audio_mempool_get_buff(&promptResamplerBuf, + AUDIO_PROMPT_BUF_SIZE_FOR_RESAMPLER); - audio_prompt_buffer_config(MIX_WITH_A2DP_STREAMING, - stream_cfg.channel_num, - stream_cfg.bits, - promptTmpSourcePcmDataBuf, - promptTmpTargetPcmDataBuf, - promptPcmDataBuf, - AUDIO_PROMPT_PCM_BUFFER_SIZE, - promptResamplerBuf, - AUDIO_PROMPT_BUF_SIZE_FOR_RESAMPLER); + audio_prompt_buffer_config(MIX_WITH_A2DP_STREAMING, stream_cfg.channel_num, + stream_cfg.bits, promptTmpSourcePcmDataBuf, + promptTmpTargetPcmDataBuf, promptPcmDataBuf, + AUDIO_PROMPT_PCM_BUFFER_SIZE, promptResamplerBuf, + AUDIO_PROMPT_BUF_SIZE_FOR_RESAMPLER); #endif #if defined(AUDIO_ANC_FB_MC) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - sample_size_play_bt=stream_cfg.bits; - sample_rate_play_bt=stream_cfg.sample_rate; - data_size_play_bt=stream_cfg.data_size; - playback_buf_bt=stream_cfg.data_ptr; - playback_size_bt=stream_cfg.data_size; - if(sample_rate_play_bt==AUD_SAMPRATE_96000) - { - playback_samplerate_ratio_bt=4; - } - else - { - playback_samplerate_ratio_bt=8; - } - playback_ch_num_bt=stream_cfg.channel_num; - mid_p_8_old_l=0; - mid_p_8_old_r=0; + sample_size_play_bt = stream_cfg.bits; + sample_rate_play_bt = stream_cfg.sample_rate; + data_size_play_bt = stream_cfg.data_size; + playback_buf_bt = stream_cfg.data_ptr; + playback_size_bt = stream_cfg.data_size; + if (sample_rate_play_bt == AUD_SAMPRATE_96000) { + playback_samplerate_ratio_bt = 4; + } else { + playback_samplerate_ratio_bt = 8; + } + playback_ch_num_bt = stream_cfg.channel_num; + mid_p_8_old_l = 0; + mid_p_8_old_r = 0; #endif #ifdef PLAYBACK_FORCE_48K - force48k_resample= app_force48k_resample_any_open( stream_cfg.channel_num, - app_force48k_resample_iter, stream_cfg.data_size / stream_cfg.channel_num, - (float)sample_rate / AUD_SAMPRATE_48000); + force48k_resample = app_force48k_resample_any_open( + stream_cfg.channel_num, app_force48k_resample_iter, + stream_cfg.data_size / stream_cfg.channel_num, + (float)sample_rate / AUD_SAMPRATE_48000); #endif - TRACE(4, "A2DP Playback: sample rate: %d, bits = %d, channel number = %d, data size:%d", - stream_cfg.sample_rate, - stream_cfg.bits, - stream_cfg.channel_num, - stream_cfg.data_size); + TRACE(4, + "A2DP Playback: sample rate: %d, bits = %d, channel number = %d, " + "data size:%d", + stream_cfg.sample_rate, stream_cfg.bits, stream_cfg.channel_num, + stream_cfg.data_size); - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); #if defined(AUDIO_ANC_FB_MC) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - stream_cfg.bits = sample_size_play_bt; - stream_cfg.channel_num = playback_ch_num_bt; - stream_cfg.sample_rate = sample_rate_play_bt; - stream_cfg.device = AUD_STREAM_USE_MC; - stream_cfg.vol = 0; + stream_cfg.bits = sample_size_play_bt; + stream_cfg.channel_num = playback_ch_num_bt; + stream_cfg.sample_rate = sample_rate_play_bt; + stream_cfg.device = AUD_STREAM_USE_MC; + stream_cfg.vol = 0; #ifdef AUDIO_ANC_FB_ADJ_MC - stream_cfg.handler = audio_adj_mc_data_playback_a2dp; + stream_cfg.handler = audio_adj_mc_data_playback_a2dp; #else - stream_cfg.handler = audio_mc_data_playback_a2dp; + stream_cfg.handler = audio_mc_data_playback_a2dp; #endif - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; - app_audio_mempool_get_buff(&bt_audio_buff, data_size_play_bt*playback_samplerate_ratio_bt); - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); - stream_cfg.data_size = data_size_play_bt*playback_samplerate_ratio_bt; + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; + app_audio_mempool_get_buff( + &bt_audio_buff, data_size_play_bt * playback_samplerate_ratio_bt); + stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); + stream_cfg.data_size = data_size_play_bt * playback_samplerate_ratio_bt; - playback_buf_mc=stream_cfg.data_ptr; - playback_size_mc=stream_cfg.data_size; + playback_buf_mc = stream_cfg.data_ptr; + playback_size_mc = stream_cfg.data_size; - anc_mc_run_init(hal_codec_anc_convert_rate(sample_rate_play_bt)); + anc_mc_run_init(hal_codec_anc_convert_rate(sample_rate_play_bt)); - memset(delay_buf_bt,0,sizeof(delay_buf_bt)); + memset(delay_buf_bt, 0, sizeof(delay_buf_bt)); - af_stream_open(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &stream_cfg); - //ASSERT(ret == 0, "af_stream_open playback failed: %d", ret); + af_stream_open(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &stream_cfg); + // ASSERT(ret == 0, "af_stream_open playback failed: %d", ret); #ifdef AUDIO_ANC_FB_ADJ_MC - adj_mc_capture_sample_rate = sample_rate_play_bt / 3; - adj_mc_init(ADJ_MC_FRAME_LEN); - memset(&stream_cfg, 0, sizeof(stream_cfg)); - stream_cfg.channel_num = (enum AUD_CHANNEL_NUM_T)ADJ_MC_CHANNEL_NUM; - stream_cfg.data_size = ADJ_MC_BUF_SIZE; - stream_cfg.sample_rate = (enum AUD_SAMPRATE_T)adj_mc_capture_sample_rate; - stream_cfg.bits = AUD_BITS_16; - stream_cfg.vol = 12; - stream_cfg.chan_sep_buf = true; - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; - stream_cfg.io_path = AUD_INPUT_PATH_ASRMIC; - stream_cfg.handler = adj_mc_filter_estimate; - stream_cfg.data_ptr = adj_mc_buf; - TRACE(2,"[A2DP_PLAYER] capture sample_rate:%d, data_size:%d",stream_cfg.sample_rate,stream_cfg.data_size); - af_stream_open(ADJ_MC_STREAM_ID, AUD_STREAM_CAPTURE, &stream_cfg); + adj_mc_capture_sample_rate = sample_rate_play_bt / 3; + adj_mc_init(ADJ_MC_FRAME_LEN); + memset(&stream_cfg, 0, sizeof(stream_cfg)); + stream_cfg.channel_num = (enum AUD_CHANNEL_NUM_T)ADJ_MC_CHANNEL_NUM; + stream_cfg.data_size = ADJ_MC_BUF_SIZE; + stream_cfg.sample_rate = (enum AUD_SAMPRATE_T)adj_mc_capture_sample_rate; + stream_cfg.bits = AUD_BITS_16; + stream_cfg.vol = 12; + stream_cfg.chan_sep_buf = true; + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; + stream_cfg.io_path = AUD_INPUT_PATH_ASRMIC; + stream_cfg.handler = adj_mc_filter_estimate; + stream_cfg.data_ptr = adj_mc_buf; + TRACE(2, "[A2DP_PLAYER] capture sample_rate:%d, data_size:%d", + stream_cfg.sample_rate, stream_cfg.data_size); + af_stream_open(ADJ_MC_STREAM_ID, AUD_STREAM_CAPTURE, &stream_cfg); #endif #endif #ifdef A2DP_STREAM_AUDIO_DUMP - audio_dump_init(1024, sizeof(int), 1); + audio_dump_init(1024, sizeof(int), 1); #endif #ifdef __HEAR_THRU_PEAK_DET__ - PEAK_DETECTOR_CFG_T peak_detector_cfg; - peak_detector_cfg.fs = stream_cfg.sample_rate; - peak_detector_cfg.bits = stream_cfg.bits; - peak_detector_cfg.factor_up = 0.6; - peak_detector_cfg.factor_down = 2.0; - peak_detector_cfg.reduce_dB = -30; - peak_detector_init(); - peak_detector_setup(&peak_detector_cfg); + PEAK_DETECTOR_CFG_T peak_detector_cfg; + peak_detector_cfg.fs = stream_cfg.sample_rate; + peak_detector_cfg.bits = stream_cfg.bits; + peak_detector_cfg.factor_up = 0.6; + peak_detector_cfg.factor_down = 2.0; + peak_detector_cfg.reduce_dB = -30; + peak_detector_init(); + peak_detector_setup(&peak_detector_cfg); #endif #if defined(__AUDIO_SPECTRUM__) - audio_spectrum_open(stream_cfg.sample_rate, stream_cfg.bits); + audio_spectrum_open(stream_cfg.sample_rate, stream_cfg.bits); #endif #if defined(__HW_FIR_EQ_PROCESS__) && defined(__HW_IIR_EQ_PROCESS__) - eq_buff_size = stream_cfg.data_size*2; + eq_buff_size = stream_cfg.data_size * 2; #elif defined(__HW_FIR_EQ_PROCESS__) && !defined(__HW_IIR_EQ_PROCESS__) - play_samp_size = (stream_cfg.bits <= AUD_BITS_16) ? 2 : 4; + play_samp_size = (stream_cfg.bits <= AUD_BITS_16) ? 2 : 4; #if defined(CHIP_BEST2000) - eq_buff_size = stream_cfg.data_size * sizeof(int32_t) / play_samp_size; + eq_buff_size = stream_cfg.data_size * sizeof(int32_t) / play_samp_size; #elif defined(CHIP_BEST1000) - eq_buff_size = stream_cfg.data_size * sizeof(int16_t) / play_samp_size; -#elif defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) - eq_buff_size = stream_cfg.data_size; + eq_buff_size = stream_cfg.data_size * sizeof(int16_t) / play_samp_size; +#elif defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || \ + defined(CHIP_BEST2300A) + eq_buff_size = stream_cfg.data_size; #endif #elif !defined(__HW_FIR_EQ_PROCESS__) && defined(__HW_IIR_EQ_PROCESS__) - eq_buff_size = stream_cfg.data_size; + eq_buff_size = stream_cfg.data_size; #else - eq_buff_size = 0; - bt_eq_buff = NULL; + eq_buff_size = 0; + bt_eq_buff = NULL; #endif - if(eq_buff_size > 0) - { - app_audio_mempool_get_buff(&bt_eq_buff, eq_buff_size); - } + if (eq_buff_size > 0) { + app_audio_mempool_get_buff(&bt_eq_buff, eq_buff_size); + } #if defined(IBRT) - enum AUD_CHANNEL_NUM_T sw_ch_num = AUD_CHANNEL_NUM_1; + enum AUD_CHANNEL_NUM_T sw_ch_num = AUD_CHANNEL_NUM_1; #else - enum AUD_CHANNEL_NUM_T sw_ch_num = stream_cfg.channel_num; + enum AUD_CHANNEL_NUM_T sw_ch_num = stream_cfg.channel_num; #endif - audio_process_open(stream_cfg.sample_rate, stream_cfg.bits, sw_ch_num, stream_cfg.channel_num, stream_cfg.data_size/stream_cfg.channel_num/(stream_cfg.bits <= AUD_BITS_16 ? 2 : 4)/2, bt_eq_buff, eq_buff_size); + audio_process_open(stream_cfg.sample_rate, stream_cfg.bits, sw_ch_num, + stream_cfg.channel_num, + stream_cfg.data_size / stream_cfg.channel_num / + (stream_cfg.bits <= AUD_BITS_16 ? 2 : 4) / 2, + bt_eq_buff, eq_buff_size); // disable audio eq config on a2dp start for audio tuning tools #ifndef __PC_CMD_UART__ #ifdef __SW_IIR_EQ_PROCESS__ - bt_audio_set_eq(AUDIO_EQ_TYPE_SW_IIR,bt_audio_get_eq_index(AUDIO_EQ_TYPE_SW_IIR,0)); + bt_audio_set_eq(AUDIO_EQ_TYPE_SW_IIR, + bt_audio_get_eq_index(AUDIO_EQ_TYPE_SW_IIR, 0)); #endif #ifdef __HW_FIR_EQ_PROCESS__ - bt_audio_set_eq(AUDIO_EQ_TYPE_HW_FIR,bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_FIR,0)); + bt_audio_set_eq(AUDIO_EQ_TYPE_HW_FIR, + bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_FIR, 0)); #endif #ifdef __HW_DAC_IIR_EQ_PROCESS__ - bt_audio_set_eq(AUDIO_EQ_TYPE_HW_DAC_IIR,bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_DAC_IIR,0)); + bt_audio_set_eq(AUDIO_EQ_TYPE_HW_DAC_IIR, + bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_DAC_IIR, 0)); #endif #ifdef __HW_IIR_EQ_PROCESS__ - bt_audio_set_eq(AUDIO_EQ_TYPE_HW_IIR,bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_IIR,0)); + bt_audio_set_eq(AUDIO_EQ_TYPE_HW_IIR, + bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_IIR, 0)); #endif #endif #ifdef ANC_APP - anc_status_record = 0xff; + anc_status_record = 0xff; #endif #if defined(IBRT) - APP_TWS_IBRT_AUDIO_SYNC_CFG_T sync_config; - sync_config.factor_reference = TWS_IBRT_AUDIO_SYNC_FACTOR_REFERENCE; - sync_config.factor_fast_limit = TWS_IBRT_AUDIO_SYNC_FACTOR_FAST_LIMIT; - sync_config.factor_slow_limit = TWS_IBRT_AUDIO_SYNC_FACTOR_SLOW_LIMIT;; - sync_config.dead_zone_us = TWS_IBRT_AUDIO_SYNC_DEAD_ZONE_US; - app_tws_ibrt_audio_sync_reconfig(&sync_config); + APP_TWS_IBRT_AUDIO_SYNC_CFG_T sync_config; + sync_config.factor_reference = TWS_IBRT_AUDIO_SYNC_FACTOR_REFERENCE; + sync_config.factor_fast_limit = TWS_IBRT_AUDIO_SYNC_FACTOR_FAST_LIMIT; + sync_config.factor_slow_limit = TWS_IBRT_AUDIO_SYNC_FACTOR_SLOW_LIMIT; + ; + sync_config.dead_zone_us = TWS_IBRT_AUDIO_SYNC_DEAD_ZONE_US; + app_tws_ibrt_audio_sync_reconfig(&sync_config); #else #if !(defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE)) - af_codec_tune(AUD_STREAM_PLAYBACK, 0); + af_codec_tune(AUD_STREAM_PLAYBACK, 0); #endif #endif - if (on == PLAYER_OPER_START) - { - // This might use all of the rest buffer in the mempool, - // so it must be the last configuration before starting stream. + if (on == PLAYER_OPER_START) { + // This might use all of the rest buffer in the mempool, + // so it must be the last configuration before starting stream. #if (A2DP_DECODER_VER == 2) - A2DP_AUDIO_OUTPUT_CONFIG_T output_config; - A2DP_AUDIO_CODEC_TYPE a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_SBC; - output_config.sample_rate = sample_rate; - output_config.num_channels = 2; - #ifdef A2DP_EQ_24BIT - output_config.bits_depth = 24; - #else - output_config.bits_depth = 16; - #endif - output_config.frame_samples = app_bt_stream_get_dma_buffer_samples()/2; - output_config.factor_reference = 1.0f; + A2DP_AUDIO_OUTPUT_CONFIG_T output_config; + A2DP_AUDIO_CODEC_TYPE a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_SBC; + output_config.sample_rate = sample_rate; + output_config.num_channels = 2; +#ifdef A2DP_EQ_24BIT + output_config.bits_depth = 24; +#else + output_config.bits_depth = 16; +#endif + output_config.frame_samples = app_bt_stream_get_dma_buffer_samples() / 2; + output_config.factor_reference = 1.0f; #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - uint8_t codec_type = bt_sbc_player_get_codec_type(); - float dest_packet_mut = 0; - int need_autotrigger = a2dp_ibrt_stream_need_autotrigger_getandclean_flag(); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + uint8_t codec_type = bt_sbc_player_get_codec_type(); + float dest_packet_mut = 0; + int need_autotrigger = + a2dp_ibrt_stream_need_autotrigger_getandclean_flag(); - uint32_t offset_mut = 0; - switch (codec_type) - { - case BTIF_AVDTP_CODEC_TYPE_SBC: - a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_SBC; - dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_SBC_MTU; - #ifdef A2DP_PLAYER_PLAYBACK_WATER_LINE - offset_mut = A2DP_PLAYER_PLAYBACK_DELAY_SBC_FRAME_MTU * A2DP_PLAYER_PLAYBACK_WATER_LINE; - #endif - break; - case BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC: - a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_MPEG2_4_AAC; - dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_AAC_MTU; - #ifdef A2DP_PLAYER_PLAYBACK_WATER_LINE - offset_mut = A2DP_PLAYER_PLAYBACK_WATER_LINE; - #endif - break; - case BTIF_AVDTP_CODEC_TYPE_NON_A2DP: + uint32_t offset_mut = 0; + switch (codec_type) { + case BTIF_AVDTP_CODEC_TYPE_SBC: + a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_SBC; + dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_SBC_MTU; +#ifdef A2DP_PLAYER_PLAYBACK_WATER_LINE + offset_mut = A2DP_PLAYER_PLAYBACK_DELAY_SBC_FRAME_MTU * + A2DP_PLAYER_PLAYBACK_WATER_LINE; +#endif + break; + case BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC: + a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_MPEG2_4_AAC; + dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_AAC_MTU; +#ifdef A2DP_PLAYER_PLAYBACK_WATER_LINE + offset_mut = A2DP_PLAYER_PLAYBACK_WATER_LINE; +#endif + break; + case BTIF_AVDTP_CODEC_TYPE_NON_A2DP: #if defined(A2DP_LHDC_ON) - if(current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LHDC) - { - a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_LHDC; - if (a2dp_lhdc_config_llc_get()){ - dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_LHDC_LLC_MTU; - }else if (sample_rate > AUD_SAMPRATE_48000){ - dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_LHDC_HIRES_MTU; - }else{ - dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_LHDC_BASERES_MTU; - } - } + if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LHDC) { + a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_LHDC; + if (a2dp_lhdc_config_llc_get()) { + dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_LHDC_LLC_MTU; + } else if (sample_rate > AUD_SAMPRATE_48000) { + dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_LHDC_HIRES_MTU; + } else { + dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_LHDC_BASERES_MTU; + } + } #endif #if defined(A2DP_LDAC_ON) - if(current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LDAC) - { - a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_LDAC; - dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_LDAC_MTU; - } + if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LDAC) { + a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_LDAC; + dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_LDAC_MTU; + } #endif - #if defined(A2DP_SCALABLE_ON) - if(current_a2dp_non_type == A2DP_NON_CODEC_TYPE_SCALABLE) - { - a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_SCALABL; - if (sample_rate > AUD_SAMPRATE_48000){ - dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_HIRES_MTU; - }else{ - dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_BASERES_MTU; - } - } + if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_SCALABLE) { + a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_SCALABL; + if (sample_rate > AUD_SAMPRATE_48000) { + dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_HIRES_MTU; + } else { + dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_BASERES_MTU; + } + } #endif - break; - default: - break; - } - output_config.factor_reference = TWS_IBRT_AUDIO_SYNC_FACTOR_REFERENCE; + break; + default: + break; + } + output_config.factor_reference = TWS_IBRT_AUDIO_SYNC_FACTOR_REFERENCE; #if defined(A2DP_LHDC_ON) || defined(A2DP_SCALABLE_ON) || defined(A2DP_LDAC_ON) - if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - { - if(bt_sbc_player_get_sample_bit() == AUD_BITS_16) - { - output_config.curr_bits = AUD_BITS_16; - } - else - { - output_config.curr_bits = AUD_BITS_24; - } - } + if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + if (bt_sbc_player_get_sample_bit() == AUD_BITS_16) { + output_config.curr_bits = AUD_BITS_16; + } else { + output_config.curr_bits = AUD_BITS_24; + } + } #endif - dest_packet_mut *= a2dp_audio_latency_factor_get(); - A2DP_AUDIO_CHANNEL_SELECT_E a2dp_audio_channel_sel = A2DP_AUDIO_CHANNEL_SELECT_STEREO; - switch ((AUDIO_CHANNEL_SELECT_E)p_ibrt_ctrl->audio_chnl_sel) - { - case AUDIO_CHANNEL_SELECT_STEREO: - a2dp_audio_channel_sel = A2DP_AUDIO_CHANNEL_SELECT_STEREO; - break; - case AUDIO_CHANNEL_SELECT_LRMERGE: - a2dp_audio_channel_sel = A2DP_AUDIO_CHANNEL_SELECT_LRMERGE; - break; - case AUDIO_CHANNEL_SELECT_LCHNL: - a2dp_audio_channel_sel = A2DP_AUDIO_CHANNEL_SELECT_LCHNL; - break; - case AUDIO_CHANNEL_SELECT_RCHNL: - a2dp_audio_channel_sel = A2DP_AUDIO_CHANNEL_SELECT_RCHNL; - break; - default: - break; - } - dest_packet_mut += offset_mut; - a2dp_audio_init(freq, a2dp_audio_codec_type, &output_config, a2dp_audio_channel_sel, (uint16_t)dest_packet_mut); + dest_packet_mut *= a2dp_audio_latency_factor_get(); + A2DP_AUDIO_CHANNEL_SELECT_E a2dp_audio_channel_sel = + A2DP_AUDIO_CHANNEL_SELECT_STEREO; + switch ((AUDIO_CHANNEL_SELECT_E)p_ibrt_ctrl->audio_chnl_sel) { + case AUDIO_CHANNEL_SELECT_STEREO: + a2dp_audio_channel_sel = A2DP_AUDIO_CHANNEL_SELECT_STEREO; + break; + case AUDIO_CHANNEL_SELECT_LRMERGE: + a2dp_audio_channel_sel = A2DP_AUDIO_CHANNEL_SELECT_LRMERGE; + break; + case AUDIO_CHANNEL_SELECT_LCHNL: + a2dp_audio_channel_sel = A2DP_AUDIO_CHANNEL_SELECT_LCHNL; + break; + case AUDIO_CHANNEL_SELECT_RCHNL: + a2dp_audio_channel_sel = A2DP_AUDIO_CHANNEL_SELECT_RCHNL; + break; + default: + break; + } + dest_packet_mut += offset_mut; + a2dp_audio_init(freq, a2dp_audio_codec_type, &output_config, + a2dp_audio_channel_sel, (uint16_t)dest_packet_mut); - app_tws_ibrt_audio_analysis_interval_set(sample_rate > AUD_SAMPRATE_48000 ? AUDIO_ANALYSIS_INTERVAL*2 : AUDIO_ANALYSIS_INTERVAL); - if (app_tws_ibrt_mobile_link_connected()){ - app_tws_ibrt_audio_analysis_start(0, AUDIO_ANALYSIS_CHECKER_INTERVEL_INVALID); - app_tws_ibrt_audio_sync_start(); - app_bt_stream_ibrt_audio_master_detect_next_packet_start(); - }else if (app_tws_ibrt_slave_ibrt_link_connected()){ - app_bt_stream_ibrt_audio_slave_detect_next_packet_start(need_autotrigger); - }else{ - TRACE_AUD_STREAM_E("[A2DP_PLAYER] mobile_link:%d %04x ibrt_link:%d %04x", app_tws_ibrt_mobile_link_connected(), p_ibrt_ctrl->mobile_conhandle, - app_tws_ibrt_slave_ibrt_link_connected(), p_ibrt_ctrl->ibrt_conhandle); - } + app_tws_ibrt_audio_analysis_interval_set(sample_rate > AUD_SAMPRATE_48000 + ? AUDIO_ANALYSIS_INTERVAL * 2 + : AUDIO_ANALYSIS_INTERVAL); + if (app_tws_ibrt_mobile_link_connected()) { + app_tws_ibrt_audio_analysis_start( + 0, AUDIO_ANALYSIS_CHECKER_INTERVEL_INVALID); + app_tws_ibrt_audio_sync_start(); + app_bt_stream_ibrt_audio_master_detect_next_packet_start(); + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + app_bt_stream_ibrt_audio_slave_detect_next_packet_start( + need_autotrigger); + } else { + TRACE_AUD_STREAM_E( + "[A2DP_PLAYER] mobile_link:%d %04x ibrt_link:%d %04x", + app_tws_ibrt_mobile_link_connected(), p_ibrt_ctrl->mobile_conhandle, + app_tws_ibrt_slave_ibrt_link_connected(), + p_ibrt_ctrl->ibrt_conhandle); + } #else - uint8_t codec_type = bt_sbc_player_get_codec_type(); - uint16_t dest_packet_mut = 0; + uint8_t codec_type = bt_sbc_player_get_codec_type(); + uint16_t dest_packet_mut = 0; - switch (codec_type) - { - case BTIF_AVDTP_CODEC_TYPE_SBC: - a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_SBC; - dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_SBC_MTU; - break; - case BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC: - a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_MPEG2_4_AAC; - dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_AAC_MTU; - break; - case BTIF_AVDTP_CODEC_TYPE_NON_A2DP: + switch (codec_type) { + case BTIF_AVDTP_CODEC_TYPE_SBC: + a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_SBC; + dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_SBC_MTU; + break; + case BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC: + a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_MPEG2_4_AAC; + dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_AAC_MTU; + break; + case BTIF_AVDTP_CODEC_TYPE_NON_A2DP: #if defined(A2DP_LHDC_ON) - if(current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LHDC) - { - a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_LHDC; - if (a2dp_lhdc_config_llc_get()){ - dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_LHDC_LLC_MTU; - }else if (sample_rate > AUD_SAMPRATE_48000){ - dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_LHDC_HIRES_MTU; - }else{ - dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_LHDC_BASERES_MTU; - } - } + if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LHDC) { + a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_LHDC; + if (a2dp_lhdc_config_llc_get()) { + dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_LHDC_LLC_MTU; + } else if (sample_rate > AUD_SAMPRATE_48000) { + dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_LHDC_HIRES_MTU; + } else { + dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_LHDC_BASERES_MTU; + } + } #endif #if defined(A2DP_LDAC_ON) - if(current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LDAC) - { - a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_LDAC; - dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_LDAC_MTU; - } + if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_LDAC) { + a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_LDAC; + dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_LDAC_MTU; + } #endif #if defined(A2DP_SCALABLE_ON) - if(current_a2dp_non_type == A2DP_NON_CODEC_TYPE_SCALABLE) - { - a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_SCALABL; - if (sample_rate > AUD_SAMPRATE_48000){ - dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_HIRES_MTU; - }else{ - dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_BASERES_MTU; - } - } + if (current_a2dp_non_type == A2DP_NON_CODEC_TYPE_SCALABLE) { + a2dp_audio_codec_type = A2DP_AUDIO_CODEC_TYPE_SCALABL; + if (sample_rate > AUD_SAMPRATE_48000) { + dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_HIRES_MTU; + } else { + dest_packet_mut = A2DP_PLAYER_PLAYBACK_DELAY_SCALABLE_BASERES_MTU; + } + } #endif - if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - { - if(bt_sbc_player_get_sample_bit() == AUD_BITS_16) - { - output_config.curr_bits = AUD_BITS_16; - } - else - { - output_config.curr_bits = AUD_BITS_24; - } - } - - break; - default: - break; - } -#if defined(A2DP_LHDC_ON) - if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) - { - if(bt_sbc_player_get_sample_bit() == AUD_BITS_16) - { - output_config.curr_bits = AUD_BITS_16; - } - else - { - output_config.curr_bits = AUD_BITS_24; - } - } -#endif - a2dp_audio_init(freq,a2dp_audio_codec_type, &output_config, A2DP_AUDIO_CHANNEL_SELECT_STEREO, dest_packet_mut); - a2dp_audio_detect_next_packet_callback_register(app_bt_stream_detect_next_packet_cb); -#endif - a2dp_audio_start(); -#else - a2dp_audio_init(); -#endif + if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + if (bt_sbc_player_get_sample_bit() == AUD_BITS_16) { + output_config.curr_bits = AUD_BITS_16; + } else { + output_config.curr_bits = AUD_BITS_24; + } } - -#if defined(MUSIC_DELAY_CONTROL) && (defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A)|| defined(CHIP_BEST1400)|| defined(CHIP_BEST1402)) - calib_reset = 1; + break; + default: + break; + } +#if defined(A2DP_LHDC_ON) + if (codec_type == BTIF_AVDTP_CODEC_TYPE_NON_A2DP) { + if (bt_sbc_player_get_sample_bit() == AUD_BITS_16) { + output_config.curr_bits = AUD_BITS_16; + } else { + output_config.curr_bits = AUD_BITS_24; + } + } #endif - af_stream_dma_tc_irq_enable(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_codec_set_playback_post_handler(bt_sbc_player_playback_post_handler); + a2dp_audio_init(freq, a2dp_audio_codec_type, &output_config, + A2DP_AUDIO_CHANNEL_SELECT_STEREO, dest_packet_mut); + a2dp_audio_detect_next_packet_callback_register( + app_bt_stream_detect_next_packet_cb); +#endif + a2dp_audio_start(); +#else + a2dp_audio_init(); +#endif + } + +#if defined(MUSIC_DELAY_CONTROL) && \ + (defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || \ + defined(CHIP_BEST2300A) || defined(CHIP_BEST1400) || \ + defined(CHIP_BEST1402)) + calib_reset = 1; +#endif + af_stream_dma_tc_irq_enable(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_codec_set_playback_post_handler(bt_sbc_player_playback_post_handler); #ifdef __A2DP_PLAYER_USE_BT_TRIGGER__ - app_bt_stream_trigger_init(); + app_bt_stream_trigger_init(); #endif #ifdef VOICE_DATAPATH - if (app_voicepath_get_stream_state(VOICEPATH_STREAMING)) - { - app_voicepath_set_pending_started_stream(AUDIO_OUTPUT_STREAMING, true); - } - else - { - app_voicepath_set_stream_state(AUDIO_OUTPUT_STREAMING, true); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - } + if (app_voicepath_get_stream_state(VOICEPATH_STREAMING)) { + app_voicepath_set_pending_started_stream(AUDIO_OUTPUT_STREAMING, true); + } else { + app_voicepath_set_stream_state(AUDIO_OUTPUT_STREAMING, true); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + } #else - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); #endif #ifdef AI_AEC_CP_ACCEL cp_aec_init(); #endif #if defined(AUDIO_ANC_FB_MC) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - af_stream_start(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); - #ifdef AUDIO_ANC_FB_ADJ_MC - af_stream_start(ADJ_MC_STREAM_ID, AUD_STREAM_CAPTURE); - #endif + af_stream_start(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); +#ifdef AUDIO_ANC_FB_ADJ_MC + af_stream_start(ADJ_MC_STREAM_ID, AUD_STREAM_CAPTURE); +#endif #endif #ifdef WL_DET - app_mic_alg_audioloop(true,APP_SYSFREQ_78M); + app_mic_alg_audioloop(true, APP_SYSFREQ_78M); #endif #ifdef __THIRDPARTY - //app_thirdparty_specific_lib_event_handle(THIRDPARTY_ID_NO1,THIRDPARTY_OTHER_EVENT); + // app_thirdparty_specific_lib_event_handle(THIRDPARTY_ID_NO1,THIRDPARTY_OTHER_EVENT); #endif - app_bt_stream_trigger_checker_start(); - } + app_bt_stream_trigger_checker_start(); + } - isRun = (on != PLAYER_OPER_STOP); - return 0; + isRun = (on != PLAYER_OPER_STOP); + return 0; } #if defined(SCO_DMA_SNAPSHOT) static uint32_t sco_trigger_wait_codecpcm = 0; static uint32_t sco_trigger_wait_btpcm = 0; -void app_bt_stream_sco_trigger_set_codecpcm_triggle(uint8_t triggle_en) -{ - sco_trigger_wait_codecpcm = triggle_en; +void app_bt_stream_sco_trigger_set_codecpcm_triggle(uint8_t triggle_en) { + sco_trigger_wait_codecpcm = triggle_en; } -uint32_t app_bt_stream_sco_trigger_wait_codecpcm_triggle(void) -{ - return sco_trigger_wait_codecpcm; +uint32_t app_bt_stream_sco_trigger_wait_codecpcm_triggle(void) { + return sco_trigger_wait_codecpcm; } -void app_bt_stream_sco_trigger_set_btpcm_triggle(uint32_t triggle_en) -{ - sco_trigger_wait_btpcm = triggle_en; +void app_bt_stream_sco_trigger_set_btpcm_triggle(uint32_t triggle_en) { + sco_trigger_wait_btpcm = triggle_en; } -uint32_t app_bt_stream_sco_trigger_wait_btpcm_triggle(void) -{ - return sco_trigger_wait_btpcm; +uint32_t app_bt_stream_sco_trigger_wait_btpcm_triggle(void) { + return sco_trigger_wait_btpcm; } -int app_bt_stream_sco_trigger_codecpcm_tick(void) -{ - if(app_bt_stream_sco_trigger_wait_codecpcm_triggle()){ - app_bt_stream_sco_trigger_set_codecpcm_triggle(0); +int app_bt_stream_sco_trigger_codecpcm_tick(void) { + if (app_bt_stream_sco_trigger_wait_codecpcm_triggle()) { + app_bt_stream_sco_trigger_set_codecpcm_triggle(0); #if defined(IBRT) ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (app_tws_ibrt_mobile_link_connected()){ - TRACE_AUD_STREAM_I("[SCO_PLAYER] codecpcm_tick:%x/%x", btdrv_syn_get_curr_ticks(), bt_syn_get_curr_ticks(p_ibrt_ctrl->mobile_conhandle)); - }else if (app_tws_ibrt_slave_ibrt_link_connected()){ - TRACE_AUD_STREAM_I("[SCO_PLAYER] codecpcm_tick:%x/%x", btdrv_syn_get_curr_ticks(), bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle)); - }else{ - TRACE_AUD_STREAM_E("[SCO_PLAYER] codecpcm_tick mobile_link:%d %04x ibrt_link:%d %04x", app_tws_ibrt_mobile_link_connected(), p_ibrt_ctrl->mobile_conhandle, - app_tws_ibrt_slave_ibrt_link_connected(), p_ibrt_ctrl->ibrt_conhandle); + if (app_tws_ibrt_mobile_link_connected()) { + TRACE_AUD_STREAM_I("[SCO_PLAYER] codecpcm_tick:%x/%x", + btdrv_syn_get_curr_ticks(), + bt_syn_get_curr_ticks(p_ibrt_ctrl->mobile_conhandle)); + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + TRACE_AUD_STREAM_I("[SCO_PLAYER] codecpcm_tick:%x/%x", + btdrv_syn_get_curr_ticks(), + bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle)); + } else { + TRACE_AUD_STREAM_E( + "[SCO_PLAYER] codecpcm_tick mobile_link:%d %04x ibrt_link:%d %04x", + app_tws_ibrt_mobile_link_connected(), p_ibrt_ctrl->mobile_conhandle, + app_tws_ibrt_slave_ibrt_link_connected(), + p_ibrt_ctrl->ibrt_conhandle); } #else uint16_t conhdl = 0xFFFF; int curr_sco; curr_sco = app_audio_manager_get_active_sco_num(); - if (curr_sco != BT_DEVICE_NUM) - { - conhdl = btif_hf_get_remote_hci_handle(*app_audio_manager_get_active_sco_chnl()); + if (curr_sco != BT_DEVICE_NUM) { + conhdl = btif_hf_get_remote_hci_handle( + *app_audio_manager_get_active_sco_chnl()); } - if (conhdl != 0xFFFF){ - TRACE_AUD_STREAM_I("[SCO_PLAYER] codecpcm_tick:%x", bt_syn_get_curr_ticks(conhdl)); + if (conhdl != 0xFFFF) { + TRACE_AUD_STREAM_I("[SCO_PLAYER] codecpcm_tick:%x", + bt_syn_get_curr_ticks(conhdl)); } #endif - btdrv_syn_clr_trigger(); - return 1; - } - return 0; + btdrv_syn_clr_trigger(); + return 1; + } + return 0; } -int app_bt_stream_sco_trigger_btpcm_tick(void) -{ - if(app_bt_stream_sco_trigger_wait_btpcm_triggle()){ - app_bt_stream_sco_trigger_set_btpcm_triggle(0); - btdrv_set_bt_pcm_triggler_en(0); -#if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (app_tws_ibrt_mobile_link_connected()){ - TRACE_AUD_STREAM_I("[SCO_PLAYER] btpcm_tick:%x/%x", btdrv_syn_get_curr_ticks(), bt_syn_get_curr_ticks(p_ibrt_ctrl->mobile_conhandle)); - }else if (app_tws_ibrt_slave_ibrt_link_connected()){ - TRACE_AUD_STREAM_I("[SCO_PLAYER] btpcm_tick:tick:%x/%x", btdrv_syn_get_curr_ticks(), bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle)); - }else{ - TRACE_AUD_STREAM_I("[SCO_PLAYER] btpcm_tick: mobile_link:%d %04x ibrt_link:%d %04x", app_tws_ibrt_mobile_link_connected(), p_ibrt_ctrl->mobile_conhandle, - app_tws_ibrt_slave_ibrt_link_connected(), p_ibrt_ctrl->ibrt_conhandle); - } -#else - uint16_t conhdl = 0xFFFF; - int curr_sco; - - curr_sco = app_audio_manager_get_active_sco_num(); - if (curr_sco != BT_DEVICE_NUM) - { - conhdl = btif_hf_get_remote_hci_handle(*app_audio_manager_get_active_sco_chnl()); - } - TRACE_AUD_STREAM_I("[SCO_PLAYER] btpcm_tick:%x", bt_syn_get_curr_ticks(conhdl)); -#endif - btdrv_syn_clr_trigger(); - return 1; - } - return 0; -} - - -void app_bt_stream_sco_trigger_btpcm_start(void ) -{ - uint32_t curr_ticks = 0; - uint32_t tg_acl_trigger_offset_time = 0; - uint16_t conhdl = 0xFFFF; - - uint32_t lock; - -#if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (app_tws_ibrt_mobile_link_connected()){ - conhdl = p_ibrt_ctrl->mobile_conhandle; -#ifdef __SW_TRIG__ - btdrv_sync_sw_trig_store_conhdl(p_ibrt_ctrl->mobile_conhandle); -#endif - }else if (app_tws_ibrt_slave_ibrt_link_connected()){ - conhdl = p_ibrt_ctrl->ibrt_conhandle; -#ifdef __SW_TRIG__ - btdrv_sync_sw_trig_store_conhdl(p_ibrt_ctrl->ibrt_conhandle); -#endif - }else{ - TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] btpcm_startr mobile:%d %04x ibrt:%d %04x", app_tws_ibrt_mobile_link_connected(), p_ibrt_ctrl->mobile_conhandle, - app_tws_ibrt_slave_ibrt_link_connected(), p_ibrt_ctrl->ibrt_conhandle); - } -#else - int curr_sco; - curr_sco = app_audio_manager_get_active_sco_num(); - if (curr_sco != BT_DEVICE_NUM) - { - conhdl = btif_hf_get_remote_hci_handle(*app_audio_manager_get_active_sco_chnl()); - } -#endif - - lock = int_lock(); - curr_ticks = bt_syn_get_curr_ticks(conhdl); - - tg_acl_trigger_offset_time = (curr_ticks+0x180) - ((curr_ticks+0x180)%192); - +int app_bt_stream_sco_trigger_btpcm_tick(void) { + if (app_bt_stream_sco_trigger_wait_btpcm_triggle()) { + app_bt_stream_sco_trigger_set_btpcm_triggle(0); btdrv_set_bt_pcm_triggler_en(0); - btdrv_set_bt_pcm_en(0); - btdrv_syn_clr_trigger(); - btdrv_enable_playback_triggler(SCO_TRIGGLE_MODE); - -#if defined(IBRT) - if (app_tws_ibrt_mobile_link_connected()){ - bt_syn_set_tg_ticks(tg_acl_trigger_offset_time, p_ibrt_ctrl->mobile_conhandle, BT_TRIG_SLAVE_ROLE); - TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] btpcm_startr set ticks:%d,",tg_acl_trigger_offset_time); - }else if (app_tws_ibrt_slave_ibrt_link_connected()){ - bt_syn_set_tg_ticks(tg_acl_trigger_offset_time, p_ibrt_ctrl->ibrt_conhandle, BT_TRIG_SLAVE_ROLE); - TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] btpcm_startr set ticks:%d,",tg_acl_trigger_offset_time); - }else{ - TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] btpcm_startr mobile:%d %04x ibrt:%d %04x", app_tws_ibrt_mobile_link_connected(), p_ibrt_ctrl->mobile_conhandle, - app_tws_ibrt_slave_ibrt_link_connected(), p_ibrt_ctrl->ibrt_conhandle); - } - TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] btpcm_startr get ticks:%d,",curr_ticks); - -#else - bt_syn_set_tg_ticks(tg_acl_trigger_offset_time, conhdl, BT_TRIG_SLAVE_ROLE); -#endif - btdrv_set_bt_pcm_triggler_en(1); - btdrv_set_bt_pcm_en(1); - app_bt_stream_sco_trigger_set_btpcm_triggle(1); - TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] btpcm_startr curr:%x, trig:%x, curr:%x", - btdrv_syn_get_curr_ticks(), - tg_acl_trigger_offset_time, - bt_syn_get_curr_ticks(conhdl)); - int_unlock(lock); -} - -void app_bt_stream_sco_trigger_btpcm_stop(void) -{ - return; -} - - -#define TIRG_DELAY_THRESHOLD_325US (15) //total:TIRG_DELAY_THRESHOLD_325US*325us -#define TIRG_DELAY_MAX (20) //total:20*TIRG_DELAY_325US*325us - -#define TIRG_DELAY_325US (96) //total:TIRG_DELAY_325US*325us It' up to the codec and bt pcm pingpang buffer. - -void app_bt_stream_sco_trigger_codecpcm_start(uint32_t btclk, uint16_t btcnt ) -{ - uint32_t curr_ticks = 0; - uint32_t tg_acl_trigger_offset_time = 0; - uint32_t lock; - uint16_t conhdl = 0xFFFF; - //must lock the interrupts when set trig ticks. - #if defined(IBRT) ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (app_tws_ibrt_mobile_link_connected()){ - conhdl = p_ibrt_ctrl->mobile_conhandle; - }else if (app_tws_ibrt_slave_ibrt_link_connected()){ - conhdl = p_ibrt_ctrl->ibrt_conhandle; - }else{ - TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] codecpcm_start mobile_link:%d %04x ibrt_link:%d %04x", app_tws_ibrt_mobile_link_connected(), p_ibrt_ctrl->mobile_conhandle, - app_tws_ibrt_slave_ibrt_link_connected(), p_ibrt_ctrl->ibrt_conhandle); + if (app_tws_ibrt_mobile_link_connected()) { + TRACE_AUD_STREAM_I("[SCO_PLAYER] btpcm_tick:%x/%x", + btdrv_syn_get_curr_ticks(), + bt_syn_get_curr_ticks(p_ibrt_ctrl->mobile_conhandle)); + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + TRACE_AUD_STREAM_I("[SCO_PLAYER] btpcm_tick:tick:%x/%x", + btdrv_syn_get_curr_ticks(), + bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle)); + } else { + TRACE_AUD_STREAM_I( + "[SCO_PLAYER] btpcm_tick: mobile_link:%d %04x ibrt_link:%d %04x", + app_tws_ibrt_mobile_link_connected(), p_ibrt_ctrl->mobile_conhandle, + app_tws_ibrt_slave_ibrt_link_connected(), + p_ibrt_ctrl->ibrt_conhandle); } #else + uint16_t conhdl = 0xFFFF; int curr_sco; + curr_sco = app_audio_manager_get_active_sco_num(); - if (curr_sco != BT_DEVICE_NUM) - { - conhdl = btif_hf_get_remote_hci_handle(*app_audio_manager_get_active_sco_chnl()); + if (curr_sco != BT_DEVICE_NUM) { + conhdl = btif_hf_get_remote_hci_handle( + *app_audio_manager_get_active_sco_chnl()); } + TRACE_AUD_STREAM_I("[SCO_PLAYER] btpcm_tick:%x", + bt_syn_get_curr_ticks(conhdl)); #endif - - lock = int_lock(); - curr_ticks = bt_syn_get_curr_ticks(conhdl); - TRACE_AUD_STREAM_I("[[STRM_TRIG][SCO] codecpcm_start 1 curr:%d clk:%dcnt:%d", curr_ticks,btclk,btcnt); -#ifdef LOW_DELAY_SCO - tg_acl_trigger_offset_time=btclk+12+MASTER_MOBILE_BTCLK_OFFSET; -#else - tg_acl_trigger_offset_time=btclk+24+MASTER_MOBILE_BTCLK_OFFSET; -#endif - - tg_acl_trigger_offset_time = tg_acl_trigger_offset_time * 2; - if(tg_acl_trigger_offset_timeTIRG_DELAY_MAX) - { - tirg_delay=TIRG_DELAY_MAX; - TRACE_AUD_STREAM_W("[STRM_TRIG][SCO] codecpcm_start bt clk convolution!"); - } - tg_acl_trigger_offset_time=tg_acl_trigger_offset_time+tirg_delay*TIRG_DELAY_325US; - TRACE_AUD_STREAM_W("[STRM_TRIG][SCO] codecpcm_start need more tirg_delay:%d offset:%d curr:%d,",tirg_delay,tg_acl_trigger_offset_time,curr_ticks); - } - tg_acl_trigger_offset_time &= 0x0fffffff; - - btdrv_syn_trigger_codec_en(0); -// af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, false); -// af_codec_sync_config(AUD_STREAM_CAPTURE, AF_CODEC_SYNC_TYPE_BT, false); btdrv_syn_clr_trigger(); - - -#if defined(IBRT) - if (app_tws_ibrt_mobile_link_connected()){ - bt_syn_set_tg_ticks(tg_acl_trigger_offset_time, p_ibrt_ctrl->mobile_conhandle, BT_TRIG_SLAVE_ROLE); - TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] codecpcm_start set 2 offset:%d",tg_acl_trigger_offset_time); - }else if (app_tws_ibrt_slave_ibrt_link_connected()){ - bt_syn_set_tg_ticks(tg_acl_trigger_offset_time, p_ibrt_ctrl->ibrt_conhandle, BT_TRIG_SLAVE_ROLE); - TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] codecpcm_start set 2 offset:%d",tg_acl_trigger_offset_time); - }else{ - TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] codecpcm_start mobile_link:%d %04x ibrt_link:%d %04x", app_tws_ibrt_mobile_link_connected(), p_ibrt_ctrl->mobile_conhandle, - app_tws_ibrt_slave_ibrt_link_connected(), p_ibrt_ctrl->ibrt_conhandle); - } -#else - bt_syn_set_tg_ticks(tg_acl_trigger_offset_time, conhdl, BT_TRIG_SLAVE_ROLE); -#endif - btdrv_syn_trigger_codec_en(1); - app_bt_stream_sco_trigger_set_codecpcm_triggle(1); - - btdrv_enable_playback_triggler(ACL_TRIGGLE_MODE); - - int_unlock(lock); - - TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] codecpcm_start enable curr:%x trig:%x curr:%x", - btdrv_syn_get_curr_ticks(), - tg_acl_trigger_offset_time, - curr_ticks); - - - -// af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, true); -// af_codec_sync_config(AUD_STREAM_CAPTURE, AF_CODEC_SYNC_TYPE_BT, true); - - + return 1; + } + return 0; } -void app_bt_stream_sco_trigger_codecpcm_stop(void) -{ -#ifdef PLAYBACK_USE_I2S - af_i2s_sync_config(AUD_STREAM_PLAYBACK, AF_I2S_SYNC_TYPE_BT, false); -#else - af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, false); +void app_bt_stream_sco_trigger_btpcm_start(void) { + uint32_t curr_ticks = 0; + uint32_t tg_acl_trigger_offset_time = 0; + uint16_t conhdl = 0xFFFF; + + uint32_t lock; + +#if defined(IBRT) + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (app_tws_ibrt_mobile_link_connected()) { + conhdl = p_ibrt_ctrl->mobile_conhandle; +#ifdef __SW_TRIG__ + btdrv_sync_sw_trig_store_conhdl(p_ibrt_ctrl->mobile_conhandle); #endif - af_codec_sync_config(AUD_STREAM_CAPTURE, AF_CODEC_SYNC_TYPE_BT, false); + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + conhdl = p_ibrt_ctrl->ibrt_conhandle; +#ifdef __SW_TRIG__ + btdrv_sync_sw_trig_store_conhdl(p_ibrt_ctrl->ibrt_conhandle); +#endif + } else { + TRACE_AUD_STREAM_I( + "[STRM_TRIG][SCO] btpcm_startr mobile:%d %04x ibrt:%d %04x", + app_tws_ibrt_mobile_link_connected(), p_ibrt_ctrl->mobile_conhandle, + app_tws_ibrt_slave_ibrt_link_connected(), p_ibrt_ctrl->ibrt_conhandle); + } +#else + int curr_sco; + curr_sco = app_audio_manager_get_active_sco_num(); + if (curr_sco != BT_DEVICE_NUM) { + conhdl = + btif_hf_get_remote_hci_handle(*app_audio_manager_get_active_sco_chnl()); + } +#endif + + lock = int_lock(); + curr_ticks = bt_syn_get_curr_ticks(conhdl); + + tg_acl_trigger_offset_time = + (curr_ticks + 0x180) - ((curr_ticks + 0x180) % 192); + + btdrv_set_bt_pcm_triggler_en(0); + btdrv_set_bt_pcm_en(0); + btdrv_syn_clr_trigger(); + btdrv_enable_playback_triggler(SCO_TRIGGLE_MODE); + +#if defined(IBRT) + if (app_tws_ibrt_mobile_link_connected()) { + bt_syn_set_tg_ticks(tg_acl_trigger_offset_time, + p_ibrt_ctrl->mobile_conhandle, BT_TRIG_SLAVE_ROLE); + TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] btpcm_startr set ticks:%d,", + tg_acl_trigger_offset_time); + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + bt_syn_set_tg_ticks(tg_acl_trigger_offset_time, p_ibrt_ctrl->ibrt_conhandle, + BT_TRIG_SLAVE_ROLE); + TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] btpcm_startr set ticks:%d,", + tg_acl_trigger_offset_time); + } else { + TRACE_AUD_STREAM_I( + "[STRM_TRIG][SCO] btpcm_startr mobile:%d %04x ibrt:%d %04x", + app_tws_ibrt_mobile_link_connected(), p_ibrt_ctrl->mobile_conhandle, + app_tws_ibrt_slave_ibrt_link_connected(), p_ibrt_ctrl->ibrt_conhandle); + } + TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] btpcm_startr get ticks:%d,", curr_ticks); + +#else + bt_syn_set_tg_ticks(tg_acl_trigger_offset_time, conhdl, BT_TRIG_SLAVE_ROLE); +#endif + btdrv_set_bt_pcm_triggler_en(1); + btdrv_set_bt_pcm_en(1); + app_bt_stream_sco_trigger_set_btpcm_triggle(1); + TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] btpcm_startr curr:%x, trig:%x, curr:%x", + btdrv_syn_get_curr_ticks(), tg_acl_trigger_offset_time, + bt_syn_get_curr_ticks(conhdl)); + int_unlock(lock); +} + +void app_bt_stream_sco_trigger_btpcm_stop(void) { return; } + +#define TIRG_DELAY_THRESHOLD_325US \ + (15) // total:TIRG_DELAY_THRESHOLD_325US*325us +#define TIRG_DELAY_MAX (20) // total:20*TIRG_DELAY_325US*325us + +#define TIRG_DELAY_325US \ + (96) // total:TIRG_DELAY_325US*325us It' up to the codec and bt pcm pingpang + // buffer. + +void app_bt_stream_sco_trigger_codecpcm_start(uint32_t btclk, uint16_t btcnt) { + uint32_t curr_ticks = 0; + uint32_t tg_acl_trigger_offset_time = 0; + uint32_t lock; + uint16_t conhdl = 0xFFFF; + // must lock the interrupts when set trig ticks. + +#if defined(IBRT) + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (app_tws_ibrt_mobile_link_connected()) { + conhdl = p_ibrt_ctrl->mobile_conhandle; + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + conhdl = p_ibrt_ctrl->ibrt_conhandle; + } else { + TRACE_AUD_STREAM_I( + "[STRM_TRIG][SCO] codecpcm_start mobile_link:%d %04x ibrt_link:%d %04x", + app_tws_ibrt_mobile_link_connected(), p_ibrt_ctrl->mobile_conhandle, + app_tws_ibrt_slave_ibrt_link_connected(), p_ibrt_ctrl->ibrt_conhandle); + } +#else + int curr_sco; + curr_sco = app_audio_manager_get_active_sco_num(); + if (curr_sco != BT_DEVICE_NUM) { + conhdl = + btif_hf_get_remote_hci_handle(*app_audio_manager_get_active_sco_chnl()); + } +#endif + + lock = int_lock(); + curr_ticks = bt_syn_get_curr_ticks(conhdl); + TRACE_AUD_STREAM_I("[[STRM_TRIG][SCO] codecpcm_start 1 curr:%d clk:%dcnt:%d", + curr_ticks, btclk, btcnt); +#ifdef LOW_DELAY_SCO + tg_acl_trigger_offset_time = btclk + 12 + MASTER_MOBILE_BTCLK_OFFSET; +#else + tg_acl_trigger_offset_time = btclk + 24 + MASTER_MOBILE_BTCLK_OFFSET; +#endif + + tg_acl_trigger_offset_time = tg_acl_trigger_offset_time * 2; + if (tg_acl_trigger_offset_time < curr_ticks + TIRG_DELAY_THRESHOLD_325US) { + int tirg_delay = 0; + tirg_delay = ((curr_ticks + TIRG_DELAY_THRESHOLD_325US) - + tg_acl_trigger_offset_time) / + TIRG_DELAY_325US; + tirg_delay = tirg_delay + 1; + if (tirg_delay > TIRG_DELAY_MAX) { + tirg_delay = TIRG_DELAY_MAX; + TRACE_AUD_STREAM_W("[STRM_TRIG][SCO] codecpcm_start bt clk convolution!"); + } + tg_acl_trigger_offset_time = + tg_acl_trigger_offset_time + tirg_delay * TIRG_DELAY_325US; + TRACE_AUD_STREAM_W("[STRM_TRIG][SCO] codecpcm_start need more " + "tirg_delay:%d offset:%d curr:%d,", + tirg_delay, tg_acl_trigger_offset_time, curr_ticks); + } + tg_acl_trigger_offset_time &= 0x0fffffff; + + btdrv_syn_trigger_codec_en(0); + // af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, false); + // af_codec_sync_config(AUD_STREAM_CAPTURE, AF_CODEC_SYNC_TYPE_BT, false); + btdrv_syn_clr_trigger(); + +#if defined(IBRT) + if (app_tws_ibrt_mobile_link_connected()) { + bt_syn_set_tg_ticks(tg_acl_trigger_offset_time, + p_ibrt_ctrl->mobile_conhandle, BT_TRIG_SLAVE_ROLE); + TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] codecpcm_start set 2 offset:%d", + tg_acl_trigger_offset_time); + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + bt_syn_set_tg_ticks(tg_acl_trigger_offset_time, p_ibrt_ctrl->ibrt_conhandle, + BT_TRIG_SLAVE_ROLE); + TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] codecpcm_start set 2 offset:%d", + tg_acl_trigger_offset_time); + } else { + TRACE_AUD_STREAM_I( + "[STRM_TRIG][SCO] codecpcm_start mobile_link:%d %04x ibrt_link:%d %04x", + app_tws_ibrt_mobile_link_connected(), p_ibrt_ctrl->mobile_conhandle, + app_tws_ibrt_slave_ibrt_link_connected(), p_ibrt_ctrl->ibrt_conhandle); + } +#else + bt_syn_set_tg_ticks(tg_acl_trigger_offset_time, conhdl, BT_TRIG_SLAVE_ROLE); +#endif + btdrv_syn_trigger_codec_en(1); + app_bt_stream_sco_trigger_set_codecpcm_triggle(1); + + btdrv_enable_playback_triggler(ACL_TRIGGLE_MODE); + + int_unlock(lock); + + TRACE_AUD_STREAM_I( + "[STRM_TRIG][SCO] codecpcm_start enable curr:%x trig:%x curr:%x", + btdrv_syn_get_curr_ticks(), tg_acl_trigger_offset_time, curr_ticks); + + // af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, true); + // af_codec_sync_config(AUD_STREAM_CAPTURE, AF_CODEC_SYNC_TYPE_BT, true); +} + +void app_bt_stream_sco_trigger_codecpcm_stop(void) { +#ifdef PLAYBACK_USE_I2S + af_i2s_sync_config(AUD_STREAM_PLAYBACK, AF_I2S_SYNC_TYPE_BT, false); +#else + af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, false); +#endif + af_codec_sync_config(AUD_STREAM_CAPTURE, AF_CODEC_SYNC_TYPE_BT, false); } #endif @@ -4615,54 +4809,54 @@ static uint32_t bt_sco_player_code_type = 0; static enum AUD_CHANNEL_NUM_T sco_play_chan_num; static enum AUD_CHANNEL_NUM_T sco_cap_chan_num; -bool bt_sco_codec_is_msbc(void) -{ - bool en = false; +bool bt_sco_codec_is_msbc(void) { + bool en = false; #ifdef HFP_1_6_ENABLE - if (app_audio_manager_get_scocodecid() == BTIF_HF_SCO_CODEC_MSBC) - { - en = true; - } - else + if (app_audio_manager_get_scocodecid() == BTIF_HF_SCO_CODEC_MSBC) { + en = true; + } else #endif - { - en = false; - } + { + en = false; + } - return en; + return en; } void bt_sco_mobile_clkcnt_get(uint32_t btclk, uint16_t btcnt, - uint32_t *mobile_master_clk, uint16_t *mobile_master_cnt) -{ + uint32_t *mobile_master_clk, + uint16_t *mobile_master_cnt) { #if defined(IBRT) - app_tws_ibrt_audio_mobile_clkcnt_get(btclk, btcnt, mobile_master_clk, mobile_master_cnt); + app_tws_ibrt_audio_mobile_clkcnt_get(btclk, btcnt, mobile_master_clk, + mobile_master_cnt); #else - uint16_t conhdl = 0xFFFF; - int32_t clock_offset; - uint16_t bit_offset; - int curr_sco; + uint16_t conhdl = 0xFFFF; + int32_t clock_offset; + uint16_t bit_offset; + int curr_sco; - curr_sco = app_audio_manager_get_active_sco_num(); - if (curr_sco != BT_DEVICE_NUM){ - conhdl = btif_hf_get_remote_hci_handle(*app_audio_manager_get_active_sco_chnl()); - } + curr_sco = app_audio_manager_get_active_sco_num(); + if (curr_sco != BT_DEVICE_NUM) { + conhdl = + btif_hf_get_remote_hci_handle(*app_audio_manager_get_active_sco_chnl()); + } - if (conhdl != 0xFFFF){ - bt_drv_reg_op_piconet_clk_offset_get(conhdl, &clock_offset, &bit_offset); - //TRACE_AUD_STREAM_I("mobile piconet clk:%d bit:%d loc clk:%d cnt:%d", clock_offset, bit_offset, btclk, btcnt); - btdrv_slave2master_clkcnt_convert(btclk, btcnt, - clock_offset, bit_offset, - mobile_master_clk, mobile_master_cnt); - }else{ - TRACE_AUD_STREAM_W("[STRM_TRIG][SCO] mobile_clkcnt_get warning conhdl NULL conhdl:%x", conhdl); - *mobile_master_clk = 0; - *mobile_master_cnt = 0; - } + if (conhdl != 0xFFFF) { + bt_drv_reg_op_piconet_clk_offset_get(conhdl, &clock_offset, &bit_offset); + // TRACE_AUD_STREAM_I("mobile piconet clk:%d bit:%d loc clk:%d cnt:%d", + // clock_offset, bit_offset, btclk, btcnt); + btdrv_slave2master_clkcnt_convert(btclk, btcnt, clock_offset, bit_offset, + mobile_master_clk, mobile_master_cnt); + } else { + TRACE_AUD_STREAM_W( + "[STRM_TRIG][SCO] mobile_clkcnt_get warning conhdl NULL conhdl:%x", + conhdl); + *mobile_master_clk = 0; + *mobile_master_cnt = 0; + } #endif } - #if defined(__AUDIO_RESAMPLE__) && defined(SW_SCO_RESAMPLE) #ifdef CHIP_BEST1000 @@ -4672,280 +4866,278 @@ void bt_sco_mobile_clkcnt_get(uint32_t btclk, uint16_t btcnt, #error "Conflicted config: NO_SCO_RESAMPLE and SW_SCO_RESAMPLE" #endif -// The decoded playback data in the first irq is output to DAC after the second irq (PING-PONG buffer) -#define SCO_PLAY_RESAMPLE_ALIGN_CNT 2 +// The decoded playback data in the first irq is output to DAC after the second +// irq (PING-PONG buffer) +#define SCO_PLAY_RESAMPLE_ALIGN_CNT 2 static uint8_t sco_play_irq_cnt; static bool sco_dma_buf_err; static struct APP_RESAMPLE_T *sco_capture_resample; static struct APP_RESAMPLE_T *sco_playback_resample; -static int bt_sco_capture_resample_iter(uint8_t *buf, uint32_t len) -{ - voicebtpcm_pcm_audio_data_come(buf, len); - return 0; +static int bt_sco_capture_resample_iter(uint8_t *buf, uint32_t len) { + voicebtpcm_pcm_audio_data_come(buf, len); + return 0; } -static int bt_sco_playback_resample_iter(uint8_t *buf, uint32_t len) -{ - voicebtpcm_pcm_audio_more_data(buf, len); - return 0; +static int bt_sco_playback_resample_iter(uint8_t *buf, uint32_t len) { + voicebtpcm_pcm_audio_more_data(buf, len); + return 0; } #endif #if defined(SCO_DMA_SNAPSHOT) -extern int process_downlink_bt_voice_frames(uint8_t *in_buf, uint32_t in_len, uint8_t *out_buf,uint32_t out_len,int32_t codec_type); -extern int process_uplink_bt_voice_frames(uint8_t *in_buf, uint32_t in_len, uint8_t *ref_buf, uint32_t ref_len, uint8_t *out_buf,uint32_t out_len,int32_t codec_type); +extern int process_downlink_bt_voice_frames(uint8_t *in_buf, uint32_t in_len, + uint8_t *out_buf, uint32_t out_len, + int32_t codec_type); +extern int process_uplink_bt_voice_frames(uint8_t *in_buf, uint32_t in_len, + uint8_t *ref_buf, uint32_t ref_len, + uint8_t *out_buf, uint32_t out_len, + int32_t codec_type); #define MSBC_FRAME_LEN (60) #define PCM_LEN_PER_FRAME (240) #define CAL_FRAME_NUM (22) -static void bt_sco_codec_tuning(void) -{ - uint32_t btclk; - uint16_t btcnt; +static void bt_sco_codec_tuning(void) { + uint32_t btclk; + uint16_t btcnt; - uint32_t mobile_master_clk; - uint16_t mobile_master_cnt; + uint32_t mobile_master_clk; + uint16_t mobile_master_cnt; - uint32_t mobile_master_clk_offset; - int32_t mobile_master_cnt_offset; + uint32_t mobile_master_clk_offset; + int32_t mobile_master_cnt_offset; - static float fre_offset=0.0f; - static int32_t mobile_master_cnt_offset_init; - static int32_t mobile_master_cnt_offset_old; - static uint32_t first_proc_flag=0; -#if defined( __AUDIO_RESAMPLE__) && !defined(AUDIO_RESAMPLE_ANTI_DITHER) - static uint32_t frame_counter=0; - static int32_t mobile_master_cnt_offset_max=0; - static int32_t mobile_master_cnt_offset_min=0; - static int32_t mobile_master_cnt_offset_resample=0; + static float fre_offset = 0.0f; + static int32_t mobile_master_cnt_offset_init; + static int32_t mobile_master_cnt_offset_old; + static uint32_t first_proc_flag = 0; +#if defined(__AUDIO_RESAMPLE__) && !defined(AUDIO_RESAMPLE_ANTI_DITHER) + static uint32_t frame_counter = 0; + static int32_t mobile_master_cnt_offset_max = 0; + static int32_t mobile_master_cnt_offset_min = 0; + static int32_t mobile_master_cnt_offset_resample = 0; - int32_t offset_max=0; - int32_t offset_min=0; + int32_t offset_max = 0; + int32_t offset_min = 0; #endif - bt_drv_reg_op_dma_tc_clkcnt_get(&btclk, &btcnt); - bt_sco_mobile_clkcnt_get(btclk, btcnt, - &mobile_master_clk, &mobile_master_cnt); + bt_drv_reg_op_dma_tc_clkcnt_get(&btclk, &btcnt); + bt_sco_mobile_clkcnt_get(btclk, btcnt, &mobile_master_clk, + &mobile_master_cnt); #if defined(SCO_DMA_SNAPSHOT_DEBUG) - TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] tune btclk:%d,btcnt:%d,",mobile_master_clk,mobile_master_cnt); + TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] tune btclk:%d,btcnt:%d,", + mobile_master_clk, mobile_master_cnt); #endif - mobile_master_clk_offset=(mobile_master_clk-mobile_master_clk_offset_init)%12; - mobile_master_cnt_offset=mobile_master_clk_offset*625+(625-mobile_master_cnt); - mobile_master_cnt_offset=mobile_master_cnt_offset-(MASTER_MOBILE_BTCNT_OFFSET+mobile_master_cnt_offset_init); + mobile_master_clk_offset = + (mobile_master_clk - mobile_master_clk_offset_init) % 12; + mobile_master_cnt_offset = + mobile_master_clk_offset * 625 + (625 - mobile_master_cnt); + mobile_master_cnt_offset = + mobile_master_cnt_offset - + (MASTER_MOBILE_BTCNT_OFFSET + mobile_master_cnt_offset_init); - if(app_bt_stream_sco_trigger_codecpcm_tick()) - { - fre_offset=0.0f; - if(mobile_master_clk_offsetmobile_master_cnt_offset_max) - { - mobile_master_cnt_offset_max=mobile_master_cnt_offset; - } - - if(mobile_master_cnt_offset=CAL_FRAME_NUM) - { - if(mobile_master_cnt_offset_minoffset_max) - { - mobile_master_cnt_offset_resample=mobile_master_cnt_offset_max-offset_max; - } - else - { - mobile_master_cnt_offset_resample=0; - } - TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] tune mobile_master_cnt_offset:%d/%d",mobile_master_cnt_offset_min,mobile_master_cnt_offset_max); - mobile_master_cnt_offset=mobile_master_cnt_offset_resample; - - if(first_proc_flag==0) - { - fre_offset=((int32_t)(mobile_master_cnt_offset*0.5f))*0.0000001f - +(mobile_master_cnt_offset-mobile_master_cnt_offset_old)*0.0000001f; - first_proc_flag=1; - } - else - { - fre_offset=fre_offset+((int32_t)(mobile_master_cnt_offset*0.5f))*0.0000001f - +(mobile_master_cnt_offset-mobile_master_cnt_offset_old)*0.0000001f; - first_proc_flag=1; - } - - mobile_master_cnt_offset_old=mobile_master_cnt_offset; -#if defined(SCO_DMA_SNAPSHOT_DEBUG) - TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] tune mobile_master_cnt_offset:%d", mobile_master_cnt_offset); -#endif - mobile_master_cnt_offset_max=0; - mobile_master_cnt_offset_min=0; - frame_counter=0; - } - } - else -#endif - { - fre_offset=fre_offset+((int32_t)(mobile_master_cnt_offset*0.5f))*0.00000001f - +(mobile_master_cnt_offset-mobile_master_cnt_offset_old)*0.00000001f; - - mobile_master_cnt_offset_old=mobile_master_cnt_offset; - //TRACE_AUD_STREAM_I("mobile_master_cnt_offset:%d",mobile_master_cnt_offset); - first_proc_flag=1; - - } - -#if defined(SCO_DMA_SNAPSHOT_DEBUG) - TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] tune fre_offset:%d",(int)(fre_offset*10000000.0f)); -#endif - if(first_proc_flag==1) - { - if(fre_offset>0.0001f)fre_offset=0.0001f; - if(fre_offset<-0.0001f)fre_offset=-0.0001f; - } -#if defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE) - app_resample_tune(playback_samplerate_codecpcm, fre_offset); + if (playback_samplerate_codecpcm == AUD_SAMPRATE_16000) { +#ifdef ANC_APP + mobile_master_cnt_offset_init = -232; #else - af_codec_tune(AUD_STREAM_NUM, fre_offset); +#if defined(__AUDIO_RESAMPLE__) + if (hal_cmu_get_audio_resample_status()) { +#if defined(AUDIO_RESAMPLE_ANTI_DITHER) + mobile_master_cnt_offset_init = 171; +#else + mobile_master_cnt_offset_init = 146; +#endif + } else +#endif + { + mobile_master_cnt_offset_init = 113; + } +#endif + } else if (playback_samplerate_codecpcm == AUD_SAMPRATE_8000) { +#ifdef ANC_APP + mobile_master_cnt_offset_init = -512; +#else +#if defined(__AUDIO_RESAMPLE__) + if (hal_cmu_get_audio_resample_status()) { +#if defined(AUDIO_RESAMPLE_ANTI_DITHER) + mobile_master_cnt_offset_init = -270; +#else + mobile_master_cnt_offset_init = -327; +#endif + } else +#endif + { + mobile_master_cnt_offset_init = -386; + } +#endif + } + +#if defined(__AUDIO_RESAMPLE__) && !defined(AUDIO_RESAMPLE_ANTI_DITHER) + mobile_master_cnt_offset = + mobile_master_clk_offset * 625 + (625 - mobile_master_cnt); + mobile_master_cnt_offset = + mobile_master_cnt_offset - + (MASTER_MOBILE_BTCNT_OFFSET + mobile_master_cnt_offset_init); + TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] tune mobile_master_cnt_offset:%d,", + mobile_master_cnt_offset); +#ifdef LOW_DELAY_SCO + fre_offset = + (float)mobile_master_cnt_offset / (CAL_FRAME_NUM * 7.5f * 1000.0f); +#else + fre_offset = + (float)mobile_master_cnt_offset / (CAL_FRAME_NUM * 15.0f * 1000.0f); +#endif + first_proc_flag = 0; #endif - return; +#if defined(__AUDIO_RESAMPLE__) && !defined(AUDIO_RESAMPLE_ANTI_DITHER) + if (hal_cmu_get_audio_resample_status()) { + frame_counter = 0; + mobile_master_cnt_offset_max = 0; + mobile_master_cnt_offset_min = 0; + mobile_master_cnt_offset_resample = 0; + } +#endif + mobile_master_cnt_offset = 0; + mobile_master_cnt_offset_old = 0; + } + +#if defined(__AUDIO_RESAMPLE__) && !defined(SW_PLAYBACK_RESAMPLE) && \ + !defined(AUDIO_RESAMPLE_ANTI_DITHER) + if (hal_cmu_get_audio_resample_status()) { + if (playback_samplerate_codecpcm == AUD_SAMPRATE_16000) { + offset_max = 28; + offset_min = -33; + } else if (playback_samplerate_codecpcm == AUD_SAMPRATE_8000) { + offset_max = 12; + offset_min = -112; + } + + if (mobile_master_cnt_offset > mobile_master_cnt_offset_max) { + mobile_master_cnt_offset_max = mobile_master_cnt_offset; + } + + if (mobile_master_cnt_offset < mobile_master_cnt_offset_min) { + mobile_master_cnt_offset_min = mobile_master_cnt_offset; + } + + frame_counter++; + + if (frame_counter >= CAL_FRAME_NUM) { + if (mobile_master_cnt_offset_min < offset_min) { + mobile_master_cnt_offset_resample = + mobile_master_cnt_offset_min - offset_min; + } else if (mobile_master_cnt_offset_max > offset_max) { + mobile_master_cnt_offset_resample = + mobile_master_cnt_offset_max - offset_max; + } else { + mobile_master_cnt_offset_resample = 0; + } + TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] tune mobile_master_cnt_offset:%d/%d", + mobile_master_cnt_offset_min, + mobile_master_cnt_offset_max); + mobile_master_cnt_offset = mobile_master_cnt_offset_resample; + + if (first_proc_flag == 0) { + fre_offset = ((int32_t)(mobile_master_cnt_offset * 0.5f)) * 0.0000001f + + (mobile_master_cnt_offset - mobile_master_cnt_offset_old) * + 0.0000001f; + first_proc_flag = 1; + } else { + fre_offset = fre_offset + + ((int32_t)(mobile_master_cnt_offset * 0.5f)) * 0.0000001f + + (mobile_master_cnt_offset - mobile_master_cnt_offset_old) * + 0.0000001f; + first_proc_flag = 1; + } + + mobile_master_cnt_offset_old = mobile_master_cnt_offset; +#if defined(SCO_DMA_SNAPSHOT_DEBUG) + TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] tune mobile_master_cnt_offset:%d", + mobile_master_cnt_offset); +#endif + mobile_master_cnt_offset_max = 0; + mobile_master_cnt_offset_min = 0; + frame_counter = 0; + } + } else +#endif + { + fre_offset = + fre_offset + + ((int32_t)(mobile_master_cnt_offset * 0.5f)) * 0.00000001f + + (mobile_master_cnt_offset - mobile_master_cnt_offset_old) * 0.00000001f; + + mobile_master_cnt_offset_old = mobile_master_cnt_offset; + // TRACE_AUD_STREAM_I("mobile_master_cnt_offset:%d",mobile_master_cnt_offset); + first_proc_flag = 1; + } + +#if defined(SCO_DMA_SNAPSHOT_DEBUG) + TRACE_AUD_STREAM_I("[STRM_TRIG][SCO] tune fre_offset:%d", + (int)(fre_offset * 10000000.0f)); +#endif + if (first_proc_flag == 1) { + if (fre_offset > 0.0001f) + fre_offset = 0.0001f; + if (fre_offset < -0.0001f) + fre_offset = -0.0001f; + } +#if defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE) + app_resample_tune(playback_samplerate_codecpcm, fre_offset); +#else + af_codec_tune(AUD_STREAM_NUM, fre_offset); +#endif + + return; } #endif -extern CQueue* get_tx_esco_queue_ptr(); +extern CQueue *get_tx_esco_queue_ptr(); #if defined(BONE_SENSOR_TDM) -#define MIC_TDM_FRAME_MS (15) -#define MIC_TDM_MAX_CH (3) +#define MIC_TDM_FRAME_MS (15) +#define MIC_TDM_MAX_CH (3) static int16_t mic_tdm_buf[SPEECH_FRAME_MS_TO_LEN(16000, MIC_TDM_FRAME_MS)]; // forward static uint32_t bt_sco_codec_capture_data(uint8_t *buf, uint32_t len); -uint32_t tdm_callback_func(uint8_t *buf_ptr, uint32_t frame_len) -{ - int16_t *pcm_buf = (int16_t *)buf_ptr; +uint32_t tdm_callback_func(uint8_t *buf_ptr, uint32_t frame_len) { + int16_t *pcm_buf = (int16_t *)buf_ptr; - // TODO: Check frame_len, depend on sample rate + // TODO: Check frame_len, depend on sample rate - for (uint32_t i = 0; i < frame_len; i++) - { - mic_tdm_buf[i] = pcm_buf[i]; - } + for (uint32_t i = 0; i < frame_len; i++) { + mic_tdm_buf[i] = pcm_buf[i]; + } #if defined(__AUDIO_RESAMPLE__) && defined(SW_SCO_RESAMPLE) - ASSERT(0, "[%s] Do not support defined(__AUDIO_RESAMPLE__) && defined(SW_SCO_RESAMPLE)", __func__); + ASSERT(0, + "[%s] Do not support defined(__AUDIO_RESAMPLE__) && " + "defined(SW_SCO_RESAMPLE)", + __func__); #endif - return 0; + return 0; } -void bt_sco_get_tdm_buffer(uint8_t **buf, uint32_t *len) -{ - *buf = (uint8_t *)&mic_tdm_buf[0]; - *len = sizeof(mic_tdm_buf); +void bt_sco_get_tdm_buffer(uint8_t **buf, uint32_t *len) { + *buf = (uint8_t *)&mic_tdm_buf[0]; + *len = sizeof(mic_tdm_buf); } #endif @@ -4953,1028 +5145,963 @@ void bt_sco_get_tdm_buffer(uint8_t **buf, uint32_t *len) static int16_t *anc_buf = NULL; #endif - #if defined(ANC_WNR_ENABLED) #if defined(SPEECH_TX_24BIT) -static int32_t wnr_buf[256*2]; +static int32_t wnr_buf[256 * 2]; #else -static short wnr_buf[256*2]; +static short wnr_buf[256 * 2]; #endif #endif //#define BT_SCO_HANDLER_PROFILE //( codec:mic-->btpcm:tx // codec:mic -static uint32_t bt_sco_codec_capture_data(uint8_t *buf, uint32_t len) -{ - app_bt_stream_trigger_checker_handler(TRIGGER_CHECKER_HFP_AUDPCM_CAPTURE); +static uint32_t bt_sco_codec_capture_data(uint8_t *buf, uint32_t len) { + app_bt_stream_trigger_checker_handler(TRIGGER_CHECKER_HFP_AUDPCM_CAPTURE); #if defined(ANC_NOISE_TRACKER) - int16_t *pcm_buf = (int16_t *)buf; - uint32_t pcm_len = len / sizeof(short); - uint32_t ch_num = SPEECH_CODEC_CAPTURE_CHANNEL_NUM + ANC_NOISE_TRACKER_CHANNEL_NUM; - uint32_t remain_ch_num = SPEECH_CODEC_CAPTURE_CHANNEL_NUM; - + int16_t *pcm_buf = (int16_t *)buf; + uint32_t pcm_len = len / sizeof(short); + uint32_t ch_num = + SPEECH_CODEC_CAPTURE_CHANNEL_NUM + ANC_NOISE_TRACKER_CHANNEL_NUM; + uint32_t remain_ch_num = SPEECH_CODEC_CAPTURE_CHANNEL_NUM; #if defined(SPEECH_TX_AEC_CODEC_REF) - ch_num += 1; - remain_ch_num += 1; + ch_num += 1; + remain_ch_num += 1; #endif - ASSERT(pcm_len % ch_num == 0, "[%s] input data length error", __FUNCTION__); + ASSERT(pcm_len % ch_num == 0, "[%s] input data length error", __FUNCTION__); - // assume anc mic in ch0 - for (uint32_t i = 0, j = 0; i < pcm_len; i += ch_num, j += ANC_NOISE_TRACKER_CHANNEL_NUM) - { - for (uint32_t ch = 0; ch < ANC_NOISE_TRACKER_CHANNEL_NUM; ch++) - anc_buf[j + ch] = pcm_buf[i + ch]; - } + // assume anc mic in ch0 + for (uint32_t i = 0, j = 0; i < pcm_len; + i += ch_num, j += ANC_NOISE_TRACKER_CHANNEL_NUM) { + for (uint32_t ch = 0; ch < ANC_NOISE_TRACKER_CHANNEL_NUM; ch++) + anc_buf[j + ch] = pcm_buf[i + ch]; + } - noise_tracker_process(anc_buf, pcm_len / ch_num * ANC_NOISE_TRACKER_CHANNEL_NUM); + noise_tracker_process(anc_buf, + pcm_len / ch_num * ANC_NOISE_TRACKER_CHANNEL_NUM); - for (uint32_t i = 0, j = 0; i < pcm_len; i += ch_num, j += remain_ch_num) - { - for (uint32_t chi = ANC_NOISE_TRACKER_CHANNEL_NUM, cho = 0; chi < ch_num; chi++, cho++) - pcm_buf[j + cho] = pcm_buf[i + chi]; - } + for (uint32_t i = 0, j = 0; i < pcm_len; i += ch_num, j += remain_ch_num) { + for (uint32_t chi = ANC_NOISE_TRACKER_CHANNEL_NUM, cho = 0; chi < ch_num; + chi++, cho++) + pcm_buf[j + cho] = pcm_buf[i + chi]; + } - len = len / ch_num * remain_ch_num; + len = len / ch_num * remain_ch_num; #endif #if defined(AF_ADC_I2S_SYNC) - //TRACE_AUD_STREAM_I("[SCO][MIC] cnt = %d", codec_capture_cnt++); + // TRACE_AUD_STREAM_I("[SCO][MIC] cnt = %d", codec_capture_cnt++); #endif #if defined(ANC_WNR_ENABLED) #if defined(SPEECH_TX_24BIT) - int32_t *pcm_buf = (int32_t *)buf; - uint32_t pcm_len = len / sizeof(int32_t); + int32_t *pcm_buf = (int32_t *)buf; + uint32_t pcm_len = len / sizeof(int32_t); #else - int16_t *pcm_buf = (int16_t *)buf; - uint32_t pcm_len = len / sizeof(short); + int16_t *pcm_buf = (int16_t *)buf; + uint32_t pcm_len = len / sizeof(short); #endif - for(uint32_t i=0;i>8); + uint16_t *playback_src = + (uint16_t *)(playback_buf_btpcm + (pingpang)*playback_size_btpcm / 2); + for (i = 0; i < playback_size_btpcm_copy; i++) { + playback_buf_btpcm_copy[i] = (uint8_t)(playback_src[i] >> 8); } int_unlock(lock); - } + } #endif + // TRACE_AUD_STREAM_I("pcm length:%d",len); - //TRACE_AUD_STREAM_I("pcm length:%d",len); + // processing clock + bt_sco_codec_tuning(); - //processing clock - bt_sco_codec_tuning(); - - - //processing mic - uint8_t *capture_pcm_frame_p=capture_buf_codecpcm+pingpang*(capture_size_codecpcm)/2; - //uint8_t *dst=(uint8_t *)(playback_buf_btpcm+(pingpang)*playback_size_btpcm/2); - uint8_t *dst=playback_buf_btpcm_cache; - uint8_t *ref_pcm_frame_p=playback_buf_codecpcm+(pingpang^1)*(playback_size_codecpcm)/2; + // processing mic + uint8_t *capture_pcm_frame_p = + capture_buf_codecpcm + pingpang * (capture_size_codecpcm) / 2; + // uint8_t *dst=(uint8_t + // *)(playback_buf_btpcm+(pingpang)*playback_size_btpcm/2); + uint8_t *dst = playback_buf_btpcm_cache; + uint8_t *ref_pcm_frame_p = + playback_buf_codecpcm + (pingpang ^ 1) * (playback_size_codecpcm) / 2; #if defined(HFP_1_6_ENABLE) - process_uplink_bt_voice_frames(capture_pcm_frame_p,len, - ref_pcm_frame_p,(playback_size_codecpcm)/2, - dst,len,app_audio_manager_get_scocodecid()); + process_uplink_bt_voice_frames(capture_pcm_frame_p, len, ref_pcm_frame_p, + (playback_size_codecpcm) / 2, dst, len, + app_audio_manager_get_scocodecid()); #else - process_uplink_bt_voice_frames(capture_pcm_frame_p,len, - ref_pcm_frame_p,(playback_size_codecpcm)/2, - dst,len,BTIF_HF_SCO_CODEC_CVSD); + process_uplink_bt_voice_frames(capture_pcm_frame_p, len, ref_pcm_frame_p, + (playback_size_codecpcm) / 2, dst, len, + BTIF_HF_SCO_CODEC_CVSD); #endif #if defined(BT_SCO_HANDLER_PROFILE) - uint32_t end_ticks = hal_fast_sys_timer_get(); - TRACE_AUD_STREAM_I("[SCO][MIC] takes %d us", - FAST_TICKS_TO_US(end_ticks - start_ticks)); + uint32_t end_ticks = hal_fast_sys_timer_get(); + TRACE_AUD_STREAM_I("[SCO][MIC] takes %d us", + FAST_TICKS_TO_US(end_ticks - start_ticks)); #endif - return len; + return len; #else #if defined(BT_SCO_HANDLER_PROFILE) - uint32_t start_ticks = hal_fast_sys_timer_get(); + uint32_t start_ticks = hal_fast_sys_timer_get(); #endif #if defined(BONE_SENSOR_TDM) - int16_t *pcm_buf = (int16_t *)buf; - uint32_t frame_len = len / sizeof(short) / SPEECH_CODEC_CAPTURE_CHANNEL_NUM; - uint32_t ch_num = SPEECH_CODEC_CAPTURE_CHANNEL_NUM + 1; + int16_t *pcm_buf = (int16_t *)buf; + uint32_t frame_len = len / sizeof(short) / SPEECH_CODEC_CAPTURE_CHANNEL_NUM; + uint32_t ch_num = SPEECH_CODEC_CAPTURE_CHANNEL_NUM + 1; - ASSERT(SPEECH_CODEC_CAPTURE_CHANNEL_NUM < MIC_TDM_MAX_CH, "[%s] SPEECH_CODEC_CAPTURE_CHANNEL_NUM(%d) is invalid", __func__, SPEECH_CODEC_CAPTURE_CHANNEL_NUM); - // TODO: Check len, depend on sample rate + ASSERT(SPEECH_CODEC_CAPTURE_CHANNEL_NUM < MIC_TDM_MAX_CH, + "[%s] SPEECH_CODEC_CAPTURE_CHANNEL_NUM(%d) is invalid", __func__, + SPEECH_CODEC_CAPTURE_CHANNEL_NUM); + // TODO: Check len, depend on sample rate - for (uint32_t ch = 0; ch < SPEECH_CODEC_CAPTURE_CHANNEL_NUM; ch++) - { - for (uint32_t i = 0; i < frame_len; i++) - { - mic_tdm_buf[ch_num * i + ch] = pcm_buf[SPEECH_CODEC_CAPTURE_CHANNEL_NUM * i + ch]; - } + for (uint32_t ch = 0; ch < SPEECH_CODEC_CAPTURE_CHANNEL_NUM; ch++) { + for (uint32_t i = 0; i < frame_len; i++) { + mic_tdm_buf[ch_num * i + ch] = + pcm_buf[SPEECH_CODEC_CAPTURE_CHANNEL_NUM * i + ch]; } + } - return len; + return len; #endif #if defined(__AUDIO_RESAMPLE__) && defined(SW_SCO_RESAMPLE) - if(hal_cmu_get_audio_resample_status()) - { - if (af_stream_buffer_error(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE)) { - sco_dma_buf_err = true; - } - // The decoded playback data in the first irq is output to DAC after the second irq (PING-PONG buffer), - // so it is aligned with the capture data after 2 playback irqs. - if (sco_play_irq_cnt < SCO_PLAY_RESAMPLE_ALIGN_CNT) { - // Skip processing - return len; - } - app_capture_resample_run(sco_capture_resample, buf, len); + if (hal_cmu_get_audio_resample_status()) { + if (af_stream_buffer_error(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE)) { + sco_dma_buf_err = true; } - else + // The decoded playback data in the first irq is output to DAC after the + // second irq (PING-PONG buffer), so it is aligned with the capture data + // after 2 playback irqs. + if (sco_play_irq_cnt < SCO_PLAY_RESAMPLE_ALIGN_CNT) { + // Skip processing + return len; + } + app_capture_resample_run(sco_capture_resample, buf, len); + } else #endif - { - voicebtpcm_pcm_audio_data_come(buf, len); - } + { + voicebtpcm_pcm_audio_data_come(buf, len); + } #if defined(BT_SCO_HANDLER_PROFILE) - uint32_t end_ticks = hal_fast_sys_timer_get(); - TRACE_AUD_STREAM_I("[SCO][MIC] takes %d us", - FAST_TICKS_TO_US(end_ticks - start_ticks)); + uint32_t end_ticks = hal_fast_sys_timer_get(); + TRACE_AUD_STREAM_I("[SCO][MIC] takes %d us", + FAST_TICKS_TO_US(end_ticks - start_ticks)); #endif - return len; + return len; #endif } #ifdef _SCO_BTPCM_CHANNEL_ // btpcm:tx -static uint32_t bt_sco_btpcm_playback_data(uint8_t *buf, uint32_t len) -{ - app_bt_stream_trigger_checker_handler(TRIGGER_CHECKER_HFP_BTPCM_PLAYERBLACK); +static uint32_t bt_sco_btpcm_playback_data(uint8_t *buf, uint32_t len) { + app_bt_stream_trigger_checker_handler(TRIGGER_CHECKER_HFP_BTPCM_PLAYERBLACK); #if defined(SCO_DMA_SNAPSHOT) - return len; + return len; #else #if defined(BT_SCO_HANDLER_PROFILE) - uint32_t start_ticks = hal_fast_sys_timer_get(); + uint32_t start_ticks = hal_fast_sys_timer_get(); #endif - get_voicebtpcm_p2m_frame(buf, len); + get_voicebtpcm_p2m_frame(buf, len); #if defined(BT_SCO_HANDLER_PROFILE) - uint32_t end_ticks = hal_fast_sys_timer_get(); - TRACE_AUD_STREAM_I("[SCO][SPK] takes %d us", - FAST_TICKS_TO_US(end_ticks - start_ticks)); + uint32_t end_ticks = hal_fast_sys_timer_get(); + TRACE_AUD_STREAM_I("[SCO][SPK] takes %d us", + FAST_TICKS_TO_US(end_ticks - start_ticks)); #endif - return len; + return len; #endif } //) #if defined(AF_ADC_I2S_SYNC) -void codec_capture_i2s_enable(void) -{ - uint32_t lock; +void codec_capture_i2s_enable(void) { + uint32_t lock; - TRACE_AUD_STREAM_I("[SCO][IIS] Start...", __func__); - - lock = int_lock(); - hal_codec_capture_enable(); - hal_i2s_enable(HAL_I2S_ID_0); - int_unlock(lock); + TRACE_AUD_STREAM_I("[SCO][IIS] Start...", __func__); + lock = int_lock(); + hal_codec_capture_enable(); + hal_i2s_enable(HAL_I2S_ID_0); + int_unlock(lock); } #endif -extern CQueue* get_rx_esco_queue_ptr(); +extern CQueue *get_rx_esco_queue_ptr(); static volatile bool is_codec_stream_started = false; #ifdef PCM_PRIVATE_DATA_FLAG -void bt_sco_btpcm_get_pcm_priv_data(struct PCM_DATA_FLAG_T *pcm_data, uint8_t *buf, uint32_t len) -{ - uint8_t frame_num = len/120; - for(uint8_t i=0; i>5)&3; - pcm_data[i].btclk = buf[head_pos+6]|(buf[head_pos+8]<<8)|(buf[head_pos+10]<<16)|(buf[head_pos+12]<<24); - pcm_data[i].reserved = buf[head_pos+14]|(buf[head_pos+16]<<8)|(buf[head_pos+18]<<16)|(buf[head_pos+20]<<24); - //clear private msg in buffer - for(uint8_t j=0; j> 5) & 3; + pcm_data[i].btclk = buf[head_pos + 6] | (buf[head_pos + 8] << 8) | + (buf[head_pos + 10] << 16) | (buf[head_pos + 12] << 24); + pcm_data[i].reserved = buf[head_pos + 14] | (buf[head_pos + 16] << 8) | + (buf[head_pos + 18] << 16) | + (buf[head_pos + 20] << 24); + // clear private msg in buffer + for (uint8_t j = 0; j < PCM_PRIVATE_DATA_LENGTH; j++) + buf[head_pos + 2 * j] = 0; + } } #endif //( btpcm:rx-->codec:spk // btpcm:rx extern void bt_drv_reg_op_set_music_ongong_flag(); extern void bt_drv_reg_op_clear_music_ongong_flag(); -static uint32_t bt_sco_btpcm_capture_data(uint8_t *buf, uint32_t len) -{ - int POSSIBLY_UNUSED sRet = 0; +static uint32_t bt_sco_btpcm_capture_data(uint8_t *buf, uint32_t len) { + int POSSIBLY_UNUSED sRet = 0; - app_bt_stream_trigger_checker_handler(TRIGGER_CHECKER_HFP_BTPCM_CAPTURE); + app_bt_stream_trigger_checker_handler(TRIGGER_CHECKER_HFP_BTPCM_CAPTURE); #ifdef __BT_ONE_BRING_TWO__ - if(a2dp_is_music_ongoing()) - bt_drv_reg_op_set_music_ongong_flag(); - else - bt_drv_reg_op_clear_music_ongong_flag(); + if (a2dp_is_music_ongoing()) + bt_drv_reg_op_set_music_ongong_flag(); + else + bt_drv_reg_op_clear_music_ongong_flag(); #endif #if defined(PCM_PRIVATE_DATA_FLAG) && defined(PCM_FAST_MODE) - bt_sco_btpcm_get_pcm_priv_data(pcm_data_param, buf, len); + bt_sco_btpcm_get_pcm_priv_data(pcm_data_param, buf, len); #endif #if defined(SCO_DMA_SNAPSHOT) - uint32_t btclk; - uint16_t btcnt; + uint32_t btclk; + uint16_t btcnt; - uint32_t mobile_master_clk; - uint16_t mobile_master_cnt; + uint32_t mobile_master_clk; + uint16_t mobile_master_cnt; - bool codec_stream_trig = false; + bool codec_stream_trig = false; #if defined(BT_SCO_HANDLER_PROFILE) - uint32_t start_ticks = hal_fast_sys_timer_get(); + uint32_t start_ticks = hal_fast_sys_timer_get(); #endif - if((is_codec_stream_started == false)&&(buf==capture_buf_btpcm)) - { - if(!af_stream_buffer_error(AUD_STREAM_ID_1, AUD_STREAM_CAPTURE)) - { - bt_drv_reg_op_dma_tc_clkcnt_get(&btclk, &btcnt); - bt_sco_mobile_clkcnt_get(btclk, btcnt,&mobile_master_clk, &mobile_master_cnt); - hal_sys_timer_delay_us(1); - if(!af_stream_buffer_error(AUD_STREAM_ID_1, AUD_STREAM_CAPTURE)) - { - codec_stream_trig = true; - } - } + if ((is_codec_stream_started == false) && (buf == capture_buf_btpcm)) { + if (!af_stream_buffer_error(AUD_STREAM_ID_1, AUD_STREAM_CAPTURE)) { + bt_drv_reg_op_dma_tc_clkcnt_get(&btclk, &btcnt); + bt_sco_mobile_clkcnt_get(btclk, btcnt, &mobile_master_clk, + &mobile_master_cnt); + hal_sys_timer_delay_us(1); + if (!af_stream_buffer_error(AUD_STREAM_ID_1, AUD_STREAM_CAPTURE)) { + codec_stream_trig = true; + } } -/* - uint32_t curr_ticks; + } + /* + uint32_t curr_ticks; - ibbt_ctrl_t *p_ibbt_ctrl = app_tws_ibbt_get_bt_ctrl_ctx(); - if (app_tws_ibbt_tws_link_connected()){ - curr_ticks = bt_syn_get_curr_ticks(IBBT_MASTER == p_ibbt_ctrl->current_role ? p_ibbt_ctrl->mobile_conhandle : p_ibbt_ctrl->ibbt_conhandle); - TRACE_AUD_STREAM_I("bt_sco_btpcm_capture_data +++++++++++++++++++++++++++++++++curr_ticks:%d,",curr_ticks); - }else{ - curr_ticks = btdrv_syn_get_curr_ticks(); - TRACE_AUD_STREAM_I("--------------------------------------"); - } -*/ - sco_btpcm_mute_flag=0; + ibbt_ctrl_t *p_ibbt_ctrl = app_tws_ibbt_get_bt_ctrl_ctx(); + if (app_tws_ibbt_tws_link_connected()){ + curr_ticks = bt_syn_get_curr_ticks(IBBT_MASTER == + p_ibbt_ctrl->current_role ? p_ibbt_ctrl->mobile_conhandle : + p_ibbt_ctrl->ibbt_conhandle); TRACE_AUD_STREAM_I("bt_sco_btpcm_capture_data + +++++++++++++++++++++++++++++++++curr_ticks:%d,",curr_ticks); }else{ + curr_ticks = btdrv_syn_get_curr_ticks(); + TRACE_AUD_STREAM_I("--------------------------------------"); + } + */ + sco_btpcm_mute_flag = 0; - if (codec_stream_trig) { - if (app_bt_stream_sco_trigger_btpcm_tick()) { - af_stream_dma_tc_irq_enable(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_stream_dma_tc_irq_disable(AUD_STREAM_ID_1, AUD_STREAM_CAPTURE); + if (codec_stream_trig) { + if (app_bt_stream_sco_trigger_btpcm_tick()) { + af_stream_dma_tc_irq_enable(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_dma_tc_irq_disable(AUD_STREAM_ID_1, AUD_STREAM_CAPTURE); #if defined(SCO_DMA_SNAPSHOT_DEBUG) - af_stream_dma_tc_irq_enable(AUD_STREAM_ID_1, AUD_STREAM_CAPTURE); + af_stream_dma_tc_irq_enable(AUD_STREAM_ID_1, AUD_STREAM_CAPTURE); #endif - TRACE_AUD_STREAM_I("[SCO][BTPCMRX] buf:%p,capture_buf_btpcm:%p",buf,capture_buf_btpcm); + TRACE_AUD_STREAM_I("[SCO][BTPCMRX] buf:%p,capture_buf_btpcm:%p", buf, + capture_buf_btpcm); - // uint16_t *source=(uint16_t *)buf; - // DUMP16("%02x,", source, MSBC_FRAME_LEN); + // uint16_t *source=(uint16_t *)buf; + // DUMP16("%02x,", source, MSBC_FRAME_LEN); #if defined(BONE_SENSOR_TDM) #if defined(AF_ADC_I2S_SYNC) - hal_i2s_enable_delay(HAL_I2S_ID_0); - // hal_codec_capture_enable_delay(); + hal_i2s_enable_delay(HAL_I2S_ID_0); + // hal_codec_capture_enable_delay(); #endif - tdm_stream_start(); + tdm_stream_start(); #endif - mobile_master_clk_offset_init=mobile_master_clk%12; - app_bt_stream_sco_trigger_codecpcm_start(mobile_master_clk,mobile_master_cnt); - is_codec_stream_started = true; + mobile_master_clk_offset_init = mobile_master_clk % 12; + app_bt_stream_sco_trigger_codecpcm_start(mobile_master_clk, + mobile_master_cnt); + is_codec_stream_started = true; #if defined(SCO_DMA_SNAPSHOT_DEBUG) - TRACE_AUD_STREAM_I("[SCO][BTPCMRX] btclk:%d,btcnt:%d,",mobile_master_clk,mobile_master_cnt); -#endif - } - } else { -#if defined(SCO_DMA_SNAPSHOT_DEBUG) - bt_drv_reg_op_dma_tc_clkcnt_get(&btclk, &btcnt); - bt_sco_mobile_clkcnt_get(btclk, btcnt,&mobile_master_clk, &mobile_master_cnt); - TRACE_AUD_STREAM_I("[SCO][BTPCMRX]:btclk:%d,btcnt:%d,",mobile_master_clk,mobile_master_cnt); + TRACE_AUD_STREAM_I("[SCO][BTPCMRX] btclk:%d,btcnt:%d,", mobile_master_clk, + mobile_master_cnt); #endif } + } else { +#if defined(SCO_DMA_SNAPSHOT_DEBUG) + bt_drv_reg_op_dma_tc_clkcnt_get(&btclk, &btcnt); + bt_sco_mobile_clkcnt_get(btclk, btcnt, &mobile_master_clk, + &mobile_master_cnt); + TRACE_AUD_STREAM_I("[SCO][BTPCMRX]:btclk:%d,btcnt:%d,", mobile_master_clk, + mobile_master_cnt); +#endif + } #if defined(BT_SCO_HANDLER_PROFILE) - uint32_t end_ticks = hal_fast_sys_timer_get(); - TRACE_AUD_STREAM_I("[SCO][BTPCMRX] takes %d us", - FAST_TICKS_TO_US(end_ticks - start_ticks)); + uint32_t end_ticks = hal_fast_sys_timer_get(); + TRACE_AUD_STREAM_I("[SCO][BTPCMRX] takes %d us", + FAST_TICKS_TO_US(end_ticks - start_ticks)); #endif - return len; + return len; #else #if defined(BT_SCO_HANDLER_PROFILE) - uint32_t start_ticks = hal_fast_sys_timer_get(); + uint32_t start_ticks = hal_fast_sys_timer_get(); #endif - if(!is_sco_mode()){ - TRACE_AUD_STREAM_E("[SCO][BTPCMRX] player exit!"); - memset(buf,0x0,len); - return len; - } + if (!is_sco_mode()) { + TRACE_AUD_STREAM_E("[SCO][BTPCMRX] player exit!"); + memset(buf, 0x0, len); + return len; + } #if defined(TX_RX_PCM_MASK) - TRACE_AUD_STREAM_I("[SCO][BTPCMRX] TX_RX_PCM_MASK"); - CQueue* Rx_esco_queue_temp = NULL; - Rx_esco_queue_temp = get_rx_esco_queue_ptr(); - if(bt_sco_codec_is_msbc() && btdrv_is_pcm_mask_enable() ==1 ) - { - memset(buf,0,len); - int status = 0; - len /= 2; - uint8_t rx_data[len]; - status = DeCQueue(Rx_esco_queue_temp,rx_data,len); - for(uint32_t i = 0; imobile_conhandle -0x80); - } - else if (app_tws_ibrt_slave_ibrt_link_connected()) - { - valid = true; - bitoffset = btdrv_rf_bitoffset_get(p_ibrt_ctrl->ibrt_conhandle -0x80); - } + if (app_tws_ibrt_mobile_link_connected()) { + valid = true; + bitoffset = btdrv_rf_bitoffset_get(p_ibrt_ctrl->mobile_conhandle - 0x80); + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + valid = true; + bitoffset = btdrv_rf_bitoffset_get(p_ibrt_ctrl->ibrt_conhandle - 0x80); + } - if(valid) - { - if(app_if_need_fix_target_rxbit() == false) - { - if(bitoffsetSLOT_SIZE-XTAL_OFFSET) - bitoffset = SLOT_SIZE-XTAL_OFFSET; - } + if (valid) { + if (app_if_need_fix_target_rxbit() == false) { + if (bitoffset < XTAL_OFFSET) + bitoffset = XTAL_OFFSET; + else if (bitoffset > SLOT_SIZE - XTAL_OFFSET) + bitoffset = SLOT_SIZE - XTAL_OFFSET; + } #ifdef BT_XTAL_SYNC_SLOW - bt_xtal_sync_new_new(bitoffset,app_if_need_fix_target_rxbit(),BT_XTAL_SYNC_MODE_WITH_MOBILE); + bt_xtal_sync_new_new(bitoffset, app_if_need_fix_target_rxbit(), + BT_XTAL_SYNC_MODE_WITH_MOBILE); #else - bt_xtal_sync_new(bitoffset,app_if_need_fix_target_rxbit(),BT_XTAL_SYNC_MODE_WITH_MOBILE); + bt_xtal_sync_new(bitoffset, app_if_need_fix_target_rxbit(), + BT_XTAL_SYNC_MODE_WITH_MOBILE); #endif - } + } #endif #else - bt_xtal_sync(BT_XTAL_SYNC_MODE_VOICE); + bt_xtal_sync(BT_XTAL_SYNC_MODE_VOICE); #endif #endif #if defined(AF_ADC_I2S_SYNC) - //TRACE_AUD_STREAM_I("[%s] cnt = %d", __func__, codec_playback_cnt++); + // TRACE_AUD_STREAM_I("[%s] cnt = %d", __func__, codec_playback_cnt++); #endif #if defined(SCO_DMA_SNAPSHOT) - //processing ping pang flag - int pingpang; + // processing ping pang flag + int pingpang; - if(buf==playback_buf_codecpcm) - { - pingpang=0; - } - else - { - pingpang=1; - } + if (buf == playback_buf_codecpcm) { + pingpang = 0; + } else { + pingpang = 1; + } #ifdef TX_RX_PCM_MASK - //processing btpcm.(It must be from CPU's copy ) - if(btdrv_is_pcm_mask_enable()==1&&bt_sco_codec_is_msbc()) - { + // processing btpcm.(It must be from CPU's copy ) + if (btdrv_is_pcm_mask_enable() == 1 && bt_sco_codec_is_msbc()) { uint32_t lock; uint32_t i; - //must lock the interrupts when exchanging data. + // must lock the interrupts when exchanging data. lock = int_lock(); - uint16_t *capture_dst=(uint16_t *)(capture_buf_btpcm + pingpang * capture_size_btpcm / 2); + uint16_t *capture_dst = + (uint16_t *)(capture_buf_btpcm + pingpang * capture_size_btpcm / 2); - for( i =0; i> 8); - } - source_len >>= 1; + uint32_t source_len = playback_size_btpcm / 2; + if (app_audio_manager_get_scocodecid() == BTIF_HF_SCO_CODEC_MSBC) { + uint16_t *source_u16 = (uint16_t *)source; + for (uint32_t i = 0; i < source_len / 2; i++) { + source[i] = (source_u16[i] >> 8); } - process_downlink_bt_voice_frames(source,source_len, - playbakce_pcm_frame_p,(playback_size_codecpcm)/sco_play_chan_num/2,app_audio_manager_get_scocodecid()); + source_len >>= 1; + } + process_downlink_bt_voice_frames(source, source_len, playbakce_pcm_frame_p, + (playback_size_codecpcm) / + sco_play_chan_num / 2, + app_audio_manager_get_scocodecid()); #else - process_downlink_bt_voice_frames(source,(playback_size_btpcm)/2, - playbakce_pcm_frame_p,(playback_size_codecpcm)/sco_play_chan_num/2,BTIF_HF_SCO_CODEC_CVSD); + process_downlink_bt_voice_frames( + source, (playback_size_btpcm) / 2, playbakce_pcm_frame_p, + (playback_size_codecpcm) / sco_play_chan_num / 2, BTIF_HF_SCO_CODEC_CVSD); #endif - if (sco_play_chan_num == AUD_CHANNEL_NUM_2) { - // Convert mono data to stereo data + if (sco_play_chan_num == AUD_CHANNEL_NUM_2) { + // Convert mono data to stereo data #if defined(SPEECH_RX_24BIT) - app_bt_stream_copy_track_one_to_two_24bits((int32_t *)playbakce_pcm_frame_p, (int32_t *)playbakce_pcm_frame_p, playback_size_codecpcm / 2 / sco_play_chan_num / sizeof(int32_t)); + app_bt_stream_copy_track_one_to_two_24bits( + (int32_t *)playbakce_pcm_frame_p, (int32_t *)playbakce_pcm_frame_p, + playback_size_codecpcm / 2 / sco_play_chan_num / sizeof(int32_t)); #else - app_bt_stream_copy_track_one_to_two_16bits((int16_t *)playbakce_pcm_frame_p, (int16_t *)playbakce_pcm_frame_p, playback_size_codecpcm / 2 / sco_play_chan_num / sizeof(int16_t)); + app_bt_stream_copy_track_one_to_two_16bits( + (int16_t *)playbakce_pcm_frame_p, (int16_t *)playbakce_pcm_frame_p, + playback_size_codecpcm / 2 / sco_play_chan_num / sizeof(int16_t)); #endif - } - return len; + } + return len; #else #if defined(BT_SCO_HANDLER_PROFILE) - uint32_t start_ticks = hal_fast_sys_timer_get(); + uint32_t start_ticks = hal_fast_sys_timer_get(); #endif - uint8_t *dec_buf; - uint32_t mono_len; + uint8_t *dec_buf; + uint32_t mono_len; #if defined(SPEECH_RX_24BIT) - len /= 2; + len /= 2; #endif #ifdef __BT_ANC__ - mono_len = len / sco_play_chan_num / bt_sco_samplerate_ratio; - dec_buf = bt_anc_sco_dec_buf; + mono_len = len / sco_play_chan_num / bt_sco_samplerate_ratio; + dec_buf = bt_anc_sco_dec_buf; #else - mono_len = len / sco_play_chan_num; - dec_buf = buf; + mono_len = len / sco_play_chan_num; + dec_buf = buf; #endif #if defined(__AUDIO_RESAMPLE__) && defined(SW_SCO_RESAMPLE) - if(hal_cmu_get_audio_resample_status()) - { - if (sco_play_irq_cnt < SCO_PLAY_RESAMPLE_ALIGN_CNT) { - sco_play_irq_cnt++; - } - if (sco_dma_buf_err || af_stream_buffer_error(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK)) { - sco_dma_buf_err = false; - sco_play_irq_cnt = 0; - app_resample_reset(sco_playback_resample); - app_resample_reset(sco_capture_resample); - voicebtpcm_pcm_echo_buf_queue_reset(); - TRACE_AUD_STREAM_I("[SCO][SPK]: DMA buffer error: reset resample"); - } - app_playback_resample_run(sco_playback_resample, dec_buf, mono_len); + if (hal_cmu_get_audio_resample_status()) { + if (sco_play_irq_cnt < SCO_PLAY_RESAMPLE_ALIGN_CNT) { + sco_play_irq_cnt++; } - else + if (sco_dma_buf_err || + af_stream_buffer_error(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK)) { + sco_dma_buf_err = false; + sco_play_irq_cnt = 0; + app_resample_reset(sco_playback_resample); + app_resample_reset(sco_capture_resample); + voicebtpcm_pcm_echo_buf_queue_reset(); + TRACE_AUD_STREAM_I("[SCO][SPK]: DMA buffer error: reset resample"); + } + app_playback_resample_run(sco_playback_resample, dec_buf, mono_len); + } else #endif - { + { #ifdef __BT_ANC__ - bt_anc_sco_down_sample_16bits((int16_t *)dec_buf, (int16_t *)buf, mono_len / 2); + bt_anc_sco_down_sample_16bits((int16_t *)dec_buf, (int16_t *)buf, + mono_len / 2); #else - if (sco_play_chan_num == AUD_CHANNEL_NUM_2) { - // Convert stereo data to mono data (to save into echo_buf) - app_bt_stream_copy_track_two_to_one_16bits((int16_t *)dec_buf, (int16_t *)buf, mono_len / 2); - } -#endif - voicebtpcm_pcm_audio_more_data(dec_buf, mono_len); - } - -#ifdef __BT_ANC__ - voicebtpcm_pcm_resample((int16_t *)dec_buf, mono_len / 2, (int16_t *)buf); -#endif - -#if defined(SPEECH_RX_24BIT) - len <<= 1; -#endif - if (sco_play_chan_num == AUD_CHANNEL_NUM_2) { - // Convert mono data to stereo data -#if defined(SPEECH_RX_24BIT) - app_bt_stream_copy_track_one_to_two_24bits((int32_t *)buf, (int32_t *)buf, len / 2 / sizeof(int32_t)); -#else - app_bt_stream_copy_track_one_to_two_16bits((int16_t *)buf, (int16_t *)buf, len / 2 / sizeof(int16_t)); + // Convert stereo data to mono data (to save into echo_buf) + app_bt_stream_copy_track_two_to_one_16bits((int16_t *)dec_buf, + (int16_t *)buf, mono_len / 2); + } #endif - } + voicebtpcm_pcm_audio_more_data(dec_buf, mono_len); + } - if (spk_force_mute) - { - memset(buf, 0, len); - } +#ifdef __BT_ANC__ + voicebtpcm_pcm_resample((int16_t *)dec_buf, mono_len / 2, (int16_t *)buf); +#endif + +#if defined(SPEECH_RX_24BIT) + len <<= 1; +#endif + + if (sco_play_chan_num == AUD_CHANNEL_NUM_2) { + // Convert mono data to stereo data +#if defined(SPEECH_RX_24BIT) + app_bt_stream_copy_track_one_to_two_24bits((int32_t *)buf, (int32_t *)buf, + len / 2 / sizeof(int32_t)); +#else + app_bt_stream_copy_track_one_to_two_16bits((int16_t *)buf, (int16_t *)buf, + len / 2 / sizeof(int16_t)); +#endif + } + + if (spk_force_mute) { + memset(buf, 0, len); + } #if defined(BT_SCO_HANDLER_PROFILE) - uint32_t end_ticks = hal_fast_sys_timer_get(); - TRACE_AUD_STREAM_I("[SCO][SPK] takes %d us", - FAST_TICKS_TO_US(end_ticks - start_ticks)); + uint32_t end_ticks = hal_fast_sys_timer_get(); + TRACE_AUD_STREAM_I("[SCO][SPK] takes %d us", + FAST_TICKS_TO_US(end_ticks - start_ticks)); #endif - return len; + return len; #endif } -int bt_sco_player_forcemute(bool mic_mute, bool spk_mute) -{ - mic_force_mute = mic_mute; - spk_force_mute = spk_mute; +int bt_sco_player_forcemute(bool mic_mute, bool spk_mute) { + mic_force_mute = mic_mute; + spk_force_mute = spk_mute; + return 0; +} + +int bt_sco_player_get_codetype(void) { + if (gStreamplayer & APP_BT_STREAM_HFP_PCM) { + return bt_sco_player_code_type; + } else { return 0; + } } -int bt_sco_player_get_codetype(void) -{ - if (gStreamplayer & APP_BT_STREAM_HFP_PCM) - { - return bt_sco_player_code_type; - } - else - { - return 0; - } -} - -#if defined(AUDIO_ANC_FB_MC_SCO) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) -static uint32_t audio_mc_data_playback_sco(uint8_t *buf, uint32_t mc_len_bytes) -{ +#if defined(AUDIO_ANC_FB_MC_SCO) && defined(ANC_APP) && \ + !defined(__AUDIO_RESAMPLE__) +static uint32_t audio_mc_data_playback_sco(uint8_t *buf, + uint32_t mc_len_bytes) { // uint32_t begin_time; - //uint32_t end_time; + // uint32_t end_time; // begin_time = hal_sys_timer_get(); // TRACE_AUD_STREAM_I("phone cancel: %d",begin_time); - float left_gain; - float right_gain; - int32_t playback_len_bytes,mc_len_bytes_8; - int32_t i,j,k; - int delay_sample; + float left_gain; + float right_gain; + int32_t playback_len_bytes, mc_len_bytes_8; + int32_t i, j, k; + int delay_sample; - mc_len_bytes_8=mc_len_bytes/8; + mc_len_bytes_8 = mc_len_bytes / 8; - hal_codec_get_dac_gain(&left_gain,&right_gain); + hal_codec_get_dac_gain(&left_gain, &right_gain); - TRACE_AUD_STREAM_I("[SCO][SPK][MC] playback_samplerate_ratio: %d,ch:%d,sample_size:%d.",playback_samplerate_ratio_bt,playback_ch_num_bt,sample_size_play_bt); - TRACE_AUD_STREAM_I("[SCO][SPK][MC] len: %d",mc_len_bytes); + TRACE_AUD_STREAM_I( + "[SCO][SPK][MC] playback_samplerate_ratio: %d,ch:%d,sample_size:%d.", + playback_samplerate_ratio_bt, playback_ch_num_bt, sample_size_play_bt); + TRACE_AUD_STREAM_I("[SCO][SPK][MC] len: %d", mc_len_bytes); // TRACE_AUD_STREAM_I("left_gain: %d",(int)(left_gain*(1<<12))); // TRACE_AUD_STREAM_I("right_gain: %d",(int)(right_gain*(1<<12))); - playback_len_bytes=mc_len_bytes/playback_samplerate_ratio_bt; + playback_len_bytes = mc_len_bytes / playback_samplerate_ratio_bt; - if (sample_size_play_bt == AUD_BITS_16) - { - int16_t *sour_p=(int16_t *)(playback_buf_bt+playback_size_bt/2); - int16_t *mid_p=(int16_t *)(buf); - int16_t *mid_p_8=(int16_t *)(buf+mc_len_bytes-mc_len_bytes_8); - int16_t *dest_p=(int16_t *)buf; - - if(buf == playback_buf_mc) - { - sour_p=(int16_t *)playback_buf_bt; - } - - if(playback_ch_num_bt==AUD_CHANNEL_NUM_2) - { - delay_sample=DELAY_SAMPLE_MC; - - for(i=0,j=0;ihfp_vol; - app_audio_manager_sco_status_checker(); + // bt_syncerr set to max(0x0a) + // BTDIGITAL_REG_SET_FIELD(REG_BTCORE_BASE_ADDR, 0x0f, 0, 0x0f); + // af_set_priority(AF_USER_SCO, osPriorityRealtime); + af_set_priority(AF_USER_SCO, osPriorityHigh); + bt_media_volume_ptr_update_by_mediatype(BT_STREAM_VOICE); + stream_local_volume = btdevice_volume_p->hfp_vol; + app_audio_manager_sco_status_checker(); #if defined(HFP_1_6_ENABLE) - bt_sco_player_code_type = app_audio_manager_get_scocodecid(); + bt_sco_player_code_type = app_audio_manager_get_scocodecid(); #endif - if (freq < APP_SYSFREQ_104M) - { - freq = APP_SYSFREQ_104M; - } + if (freq < APP_SYSFREQ_104M) { + freq = APP_SYSFREQ_104M; + } -#if defined(AUDIO_ANC_FB_MC_SCO) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - if (freq < APP_SYSFREQ_208M) { - freq = APP_SYSFREQ_208M; - } +#if defined(AUDIO_ANC_FB_MC_SCO) && defined(ANC_APP) && \ + !defined(__AUDIO_RESAMPLE__) + if (freq < APP_SYSFREQ_208M) { + freq = APP_SYSFREQ_208M; + } #endif #if defined(SCO_CP_ACCEL) - freq = APP_SYSFREQ_52M; + freq = APP_SYSFREQ_52M; #endif - app_sysfreq_req(APP_SYSFREQ_USER_BT_SCO, freq); - TRACE_AUD_STREAM_I("[SCO_PLAYER] sysfreq:%d", freq); - TRACE_AUD_STREAM_I("[SCO_PLAYER] sysfreq calc : %d\n", hal_sys_timer_calc_cpu_freq(5, 0)); + app_sysfreq_req(APP_SYSFREQ_USER_BT_SCO, freq); + TRACE_AUD_STREAM_I("[SCO_PLAYER] sysfreq:%d", freq); + TRACE_AUD_STREAM_I("[SCO_PLAYER] sysfreq calc : %d\n", + hal_sys_timer_calc_cpu_freq(5, 0)); #ifndef FPGA - app_overlay_select(APP_OVERLAY_HFP); + app_overlay_select(APP_OVERLAY_HFP); #ifdef BT_XTAL_SYNC - bt_init_xtal_sync(BT_XTAL_SYNC_MODE_VOICE, BT_INIT_XTAL_SYNC_MIN, BT_INIT_XTAL_SYNC_MAX, BT_INIT_XTAL_SYNC_FCAP_RANGE); + bt_init_xtal_sync(BT_XTAL_SYNC_MODE_VOICE, BT_INIT_XTAL_SYNC_MIN, + BT_INIT_XTAL_SYNC_MAX, BT_INIT_XTAL_SYNC_FCAP_RANGE); #endif #endif - btdrv_rf_bit_offset_track_enable(true); + btdrv_rf_bit_offset_track_enable(true); #if !defined(SCO_DMA_SNAPSHOT) - int aec_frame_len = speech_get_frame_size(speech_codec_get_sample_rate(), 1, SPEECH_SCO_FRAME_MS); - speech_tx_aec_set_frame_len(aec_frame_len); + int aec_frame_len = speech_get_frame_size(speech_codec_get_sample_rate(), 1, + SPEECH_SCO_FRAME_MS); + speech_tx_aec_set_frame_len(aec_frame_len); #endif - bt_sco_player_forcemute(false, false); + bt_sco_player_forcemute(false, false); - bt_sco_mode = 1; + bt_sco_mode = 1; - app_audio_mempool_init(); + app_audio_mempool_init(); #ifndef _SCO_BTPCM_CHANNEL_ - memset(&hf_sendbuff_ctrl, 0, sizeof(hf_sendbuff_ctrl)); + memset(&hf_sendbuff_ctrl, 0, sizeof(hf_sendbuff_ctrl)); #endif - sample_rate = speech_codec_get_sample_rate(); + sample_rate = speech_codec_get_sample_rate(); - sco_cap_chan_num = (enum AUD_CHANNEL_NUM_T)SPEECH_CODEC_CAPTURE_CHANNEL_NUM; + sco_cap_chan_num = (enum AUD_CHANNEL_NUM_T)SPEECH_CODEC_CAPTURE_CHANNEL_NUM; #if defined(FPGA) - sco_cap_chan_num = AUD_CHANNEL_NUM_2; + sco_cap_chan_num = AUD_CHANNEL_NUM_2; #endif #if defined(SPEECH_TX_AEC_CODEC_REF) - sco_cap_chan_num = (enum AUD_CHANNEL_NUM_T)(sco_cap_chan_num + 1); + sco_cap_chan_num = (enum AUD_CHANNEL_NUM_T)(sco_cap_chan_num + 1); #endif #if defined(ANC_NOISE_TRACKER) - sco_cap_chan_num = (enum AUD_CHANNEL_NUM_T)(sco_cap_chan_num + ANC_NOISE_TRACKER_CHANNEL_NUM); + sco_cap_chan_num = (enum AUD_CHANNEL_NUM_T)(sco_cap_chan_num + + ANC_NOISE_TRACKER_CHANNEL_NUM); #endif #ifdef PLAYBACK_USE_I2S - hal_cmu_audio_resample_disable(); + hal_cmu_audio_resample_disable(); #endif - memset(&stream_cfg, 0, sizeof(stream_cfg)); + memset(&stream_cfg, 0, sizeof(stream_cfg)); - // codec:mic - stream_cfg.channel_num = sco_cap_chan_num; - stream_cfg.data_size = speech_get_af_buffer_size(sample_rate, sco_cap_chan_num, SPEECH_SCO_FRAME_MS); + // codec:mic + stream_cfg.channel_num = sco_cap_chan_num; + stream_cfg.data_size = speech_get_af_buffer_size( + sample_rate, sco_cap_chan_num, SPEECH_SCO_FRAME_MS); #if defined(__AUDIO_RESAMPLE__) && defined(NO_SCO_RESAMPLE) - // When __AUDIO_RESAMPLE__ is defined, - // resample is off by default on best1000, and on by default on other platforms + // When __AUDIO_RESAMPLE__ is defined, + // resample is off by default on best1000, and on by default on other + // platforms #ifndef CHIP_BEST1000 - hal_cmu_audio_resample_disable(); + hal_cmu_audio_resample_disable(); #endif #endif #if defined(__AUDIO_RESAMPLE__) && defined(SW_SCO_RESAMPLE) - if (sample_rate == AUD_SAMPRATE_8000) - { - stream_cfg.sample_rate = AUD_SAMPRATE_8463; - } - else if (sample_rate == AUD_SAMPRATE_16000) - { - stream_cfg.sample_rate = AUD_SAMPRATE_16927; - } + if (sample_rate == AUD_SAMPRATE_8000) { + stream_cfg.sample_rate = AUD_SAMPRATE_8463; + } else if (sample_rate == AUD_SAMPRATE_16000) { + stream_cfg.sample_rate = AUD_SAMPRATE_16927; + } #ifdef RESAMPLE_ANY_SAMPLE_RATE - sco_capture_resample = app_capture_resample_any_open( stream_cfg.channel_num, - bt_sco_capture_resample_iter, stream_cfg.data_size / 2, - (float)CODEC_FREQ_26M / CODEC_FREQ_24P576M); + sco_capture_resample = app_capture_resample_any_open( + stream_cfg.channel_num, bt_sco_capture_resample_iter, + stream_cfg.data_size / 2, (float)CODEC_FREQ_26M / CODEC_FREQ_24P576M); #else - sco_capture_resample = app_capture_resample_open(sample_rate, stream_cfg.channel_num, - bt_sco_capture_resample_iter, stream_cfg.data_size / 2); + sco_capture_resample = app_capture_resample_open( + sample_rate, stream_cfg.channel_num, bt_sco_capture_resample_iter, + stream_cfg.data_size / 2); #endif - uint32_t mono_cap_samp_cnt = stream_cfg.data_size / 2 / 2 / stream_cfg.channel_num; - uint32_t cap_irq_cnt_per_frm = ((mono_cap_samp_cnt * stream_cfg.sample_rate + (sample_rate - 1)) / sample_rate + - (aec_frame_len - 1)) / aec_frame_len; - if (cap_irq_cnt_per_frm == 0) { - cap_irq_cnt_per_frm = 1; - } + uint32_t mono_cap_samp_cnt = + stream_cfg.data_size / 2 / 2 / stream_cfg.channel_num; + uint32_t cap_irq_cnt_per_frm = + ((mono_cap_samp_cnt * stream_cfg.sample_rate + (sample_rate - 1)) / + sample_rate + + (aec_frame_len - 1)) / + aec_frame_len; + if (cap_irq_cnt_per_frm == 0) { + cap_irq_cnt_per_frm = 1; + } #else - stream_cfg.sample_rate = sample_rate; + stream_cfg.sample_rate = sample_rate; #endif #if defined(SPEECH_TX_24BIT) - stream_cfg.bits = AUD_BITS_24; - stream_cfg.data_size *= 2; + stream_cfg.bits = AUD_BITS_24; + stream_cfg.data_size *= 2; #else - stream_cfg.bits = AUD_BITS_16; + stream_cfg.bits = AUD_BITS_16; #endif - stream_cfg.vol = stream_local_volume; + stream_cfg.vol = stream_local_volume; #ifdef FPGA - stream_cfg.device = AUD_STREAM_USE_EXT_CODEC; + stream_cfg.device = AUD_STREAM_USE_EXT_CODEC; #else - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; #endif - stream_cfg.io_path = AUD_INPUT_PATH_MAINMIC; - stream_cfg.handler = bt_sco_codec_capture_data; - app_audio_mempool_get_buff(&bt_audio_buff, stream_cfg.data_size); - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); + stream_cfg.io_path = AUD_INPUT_PATH_MAINMIC; + stream_cfg.handler = bt_sco_codec_capture_data; + app_audio_mempool_get_buff(&bt_audio_buff, stream_cfg.data_size); + stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); #if defined(SCO_DMA_SNAPSHOT) - capture_buf_codecpcm=stream_cfg.data_ptr; - capture_size_codecpcm=stream_cfg.data_size; + capture_buf_codecpcm = stream_cfg.data_ptr; + capture_size_codecpcm = stream_cfg.data_size; #endif - TRACE_AUD_STREAM_I("[SCO_PLAYER] capture sample_rate:%d, data_size:%d",stream_cfg.sample_rate,stream_cfg.data_size); + TRACE_AUD_STREAM_I("[SCO_PLAYER] capture sample_rate:%d, data_size:%d", + stream_cfg.sample_rate, stream_cfg.data_size); #if defined(ANC_WNR_ENABLED) - if(app_anc_work_status()) - { - anc_wnr_close(); - anc_wnr_ctrl(stream_cfg.sample_rate, speech_get_frame_size(stream_cfg.sample_rate, 1, SPEECH_SCO_FRAME_MS)); - anc_release_gain(); - anc_wnr_open(ANC_WNR_OPEN_MODE_CONFIGURE); - } - else - { - anc_wnr_ctrl(stream_cfg.sample_rate, speech_get_frame_size(stream_cfg.sample_rate, 1, SPEECH_SCO_FRAME_MS)); - } + if (app_anc_work_status()) { + anc_wnr_close(); + anc_wnr_ctrl(stream_cfg.sample_rate, + speech_get_frame_size(stream_cfg.sample_rate, 1, + SPEECH_SCO_FRAME_MS)); + anc_release_gain(); + anc_wnr_open(ANC_WNR_OPEN_MODE_CONFIGURE); + } else { + anc_wnr_ctrl(stream_cfg.sample_rate, + speech_get_frame_size(stream_cfg.sample_rate, 1, + SPEECH_SCO_FRAME_MS)); + } #endif - - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); #if defined(HW_DC_FILTER_WITH_IIR) - hw_filter_codec_iir_st = hw_filter_codec_iir_create(stream_cfg.sample_rate, stream_cfg.channel_num, stream_cfg.bits, &adc_iir_cfg); + hw_filter_codec_iir_st = hw_filter_codec_iir_create( + stream_cfg.sample_rate, stream_cfg.channel_num, stream_cfg.bits, + &adc_iir_cfg); #endif #if defined(CHIP_BEST2300) - btdrv_set_bt_pcm_triggler_delay(60); + btdrv_set_bt_pcm_triggler_delay(60); #elif defined(CHIP_BEST1400) || defined(CHIP_BEST1402) || defined(CHIP_BEST2001) #if defined(SCO_DMA_SNAPSHOT) - btdrv_set_bt_pcm_triggler_delay(2); + btdrv_set_bt_pcm_triggler_delay(2); #else - btdrv_set_bt_pcm_triggler_delay(60); + btdrv_set_bt_pcm_triggler_delay(60); #endif #elif defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) #if defined(SCO_DMA_SNAPSHOT) - btdrv_set_bt_pcm_triggler_delay(2); + btdrv_set_bt_pcm_triggler_delay(2); #else - btdrv_set_bt_pcm_triggler_delay(59); + btdrv_set_bt_pcm_triggler_delay(59); #endif #else - btdrv_set_bt_pcm_triggler_delay(55); + btdrv_set_bt_pcm_triggler_delay(55); #endif - // codec:spk - sample_rate = speech_codec_get_sample_rate(); + // codec:spk + sample_rate = speech_codec_get_sample_rate(); #if defined(CHIP_BEST1000) sco_play_chan_num = AUD_CHANNEL_NUM_2; #else @@ -6243,477 +6381,504 @@ int bt_sco_player(bool on, enum APP_SYSFREQ_FREQ_T freq) #if defined(BONE_SENSOR_TDM) #if defined(AF_ADC_I2S_SYNC) - codec_capture_cnt = 0; - codec_playback_cnt = 0; + codec_capture_cnt = 0; + codec_playback_cnt = 0; #endif - lis25ba_init(); - tdm_stream_register(tdm_callback_func); + lis25ba_init(); + tdm_stream_register(tdm_callback_func); #endif - stream_cfg.channel_num = sco_play_chan_num; - // stream_cfg.data_size = BT_AUDIO_SCO_BUFF_SIZE * stream_cfg.channel_num; - stream_cfg.data_size = speech_get_af_buffer_size(sample_rate, sco_play_chan_num, SPEECH_SCO_FRAME_MS); + stream_cfg.channel_num = sco_play_chan_num; + // stream_cfg.data_size = BT_AUDIO_SCO_BUFF_SIZE * stream_cfg.channel_num; + stream_cfg.data_size = speech_get_af_buffer_size( + sample_rate, sco_play_chan_num, SPEECH_SCO_FRAME_MS); #if defined(__AUDIO_RESAMPLE__) && defined(SW_SCO_RESAMPLE) - if (sample_rate == AUD_SAMPRATE_8000) - { - stream_cfg.sample_rate = AUD_SAMPRATE_8463; - } - else if (sample_rate == AUD_SAMPRATE_16000) - { - stream_cfg.sample_rate = AUD_SAMPRATE_16927; - } + if (sample_rate == AUD_SAMPRATE_8000) { + stream_cfg.sample_rate = AUD_SAMPRATE_8463; + } else if (sample_rate == AUD_SAMPRATE_16000) { + stream_cfg.sample_rate = AUD_SAMPRATE_16927; + } #ifdef RESAMPLE_ANY_SAMPLE_RATE - sco_playback_resample = app_playback_resample_any_open( AUD_CHANNEL_NUM_1, - bt_sco_playback_resample_iter, stream_cfg.data_size / stream_cfg.channel_num / 2, - (float)CODEC_FREQ_24P576M / CODEC_FREQ_26M); + sco_playback_resample = app_playback_resample_any_open( + AUD_CHANNEL_NUM_1, bt_sco_playback_resample_iter, + stream_cfg.data_size / stream_cfg.channel_num / 2, + (float)CODEC_FREQ_24P576M / CODEC_FREQ_26M); #else - sco_playback_resample = app_playback_resample_open(sample_rate, AUD_CHANNEL_NUM_1, - bt_sco_playback_resample_iter, stream_cfg.data_size / stream_cfg.channel_num / 2); + sco_playback_resample = app_playback_resample_open( + sample_rate, AUD_CHANNEL_NUM_1, bt_sco_playback_resample_iter, + stream_cfg.data_size / stream_cfg.channel_num / 2); #endif - sco_play_irq_cnt = 0; - sco_dma_buf_err = false; + sco_play_irq_cnt = 0; + sco_dma_buf_err = false; - uint32_t mono_play_samp_cnt = stream_cfg.data_size / 2 / 2 / stream_cfg.channel_num; - uint32_t play_irq_cnt_per_frm = ((mono_play_samp_cnt * stream_cfg.sample_rate + (sample_rate - 1)) / sample_rate + - (aec_frame_len - 1)) / aec_frame_len; - if (play_irq_cnt_per_frm == 0) { - play_irq_cnt_per_frm = 1; - } - uint32_t play_samp_cnt_per_frm = mono_play_samp_cnt * play_irq_cnt_per_frm; - uint32_t cap_samp_cnt_per_frm = mono_cap_samp_cnt * cap_irq_cnt_per_frm; - uint32_t max_samp_cnt_per_frm = (play_samp_cnt_per_frm >= cap_samp_cnt_per_frm) ? play_samp_cnt_per_frm : cap_samp_cnt_per_frm; - uint32_t echo_q_samp_cnt = (((max_samp_cnt_per_frm + mono_play_samp_cnt * SCO_PLAY_RESAMPLE_ALIGN_CNT) * - // convert to 8K/16K sample cnt - sample_rate +(stream_cfg.sample_rate - 1)) / stream_cfg.sample_rate + - // aligned with aec_frame_len - (aec_frame_len - 1)) / aec_frame_len * aec_frame_len; - if (echo_q_samp_cnt == 0) { - echo_q_samp_cnt = aec_frame_len; - } - voicebtpcm_pcm_echo_buf_queue_init(echo_q_samp_cnt * 2); + uint32_t mono_play_samp_cnt = + stream_cfg.data_size / 2 / 2 / stream_cfg.channel_num; + uint32_t play_irq_cnt_per_frm = + ((mono_play_samp_cnt * stream_cfg.sample_rate + (sample_rate - 1)) / + sample_rate + + (aec_frame_len - 1)) / + aec_frame_len; + if (play_irq_cnt_per_frm == 0) { + play_irq_cnt_per_frm = 1; + } + uint32_t play_samp_cnt_per_frm = mono_play_samp_cnt * play_irq_cnt_per_frm; + uint32_t cap_samp_cnt_per_frm = mono_cap_samp_cnt * cap_irq_cnt_per_frm; + uint32_t max_samp_cnt_per_frm = + (play_samp_cnt_per_frm >= cap_samp_cnt_per_frm) ? play_samp_cnt_per_frm + : cap_samp_cnt_per_frm; + uint32_t echo_q_samp_cnt = + (((max_samp_cnt_per_frm + + mono_play_samp_cnt * SCO_PLAY_RESAMPLE_ALIGN_CNT) * + // convert to 8K/16K sample cnt + sample_rate + + (stream_cfg.sample_rate - 1)) / + stream_cfg.sample_rate + + // aligned with aec_frame_len + (aec_frame_len - 1)) / + aec_frame_len * aec_frame_len; + if (echo_q_samp_cnt == 0) { + echo_q_samp_cnt = aec_frame_len; + } + voicebtpcm_pcm_echo_buf_queue_init(echo_q_samp_cnt * 2); #else - stream_cfg.sample_rate = sample_rate; + stream_cfg.sample_rate = sample_rate; #endif #ifdef __BT_ANC__ - // Mono channel decoder buffer (8K or 16K sample rate) - app_audio_mempool_get_buff(&bt_anc_sco_dec_buf, stream_cfg.data_size / 2 / sco_play_chan_num); - // The playback size for the actual sample rate - bt_sco_samplerate_ratio = 6/(sample_rate/AUD_SAMPRATE_8000); - stream_cfg.data_size *= bt_sco_samplerate_ratio; + // Mono channel decoder buffer (8K or 16K sample rate) + app_audio_mempool_get_buff(&bt_anc_sco_dec_buf, + stream_cfg.data_size / 2 / sco_play_chan_num); + // The playback size for the actual sample rate + bt_sco_samplerate_ratio = 6 / (sample_rate / AUD_SAMPRATE_8000); + stream_cfg.data_size *= bt_sco_samplerate_ratio; #if defined(__AUDIO_RESAMPLE__) && defined(SW_SCO_RESAMPLE) - stream_cfg.sample_rate = AUD_SAMPRATE_50781; + stream_cfg.sample_rate = AUD_SAMPRATE_50781; #else - stream_cfg.sample_rate = AUD_SAMPRATE_48000; + stream_cfg.sample_rate = AUD_SAMPRATE_48000; #endif - //damic_init(); - //init_amic_dc_bt(); - //ds_fir_init(); - us_fir_init(); + // damic_init(); + // init_amic_dc_bt(); + // ds_fir_init(); + us_fir_init(); #endif - stream_cfg.bits = AUD_BITS_16; + stream_cfg.bits = AUD_BITS_16; #ifdef PLAYBACK_USE_I2S - stream_cfg.device = AUD_STREAM_USE_I2S0_MASTER; - stream_cfg.io_path = AUD_IO_PATH_NULL; + stream_cfg.device = AUD_STREAM_USE_I2S0_MASTER; + stream_cfg.io_path = AUD_IO_PATH_NULL; #else - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; #endif - stream_cfg.handler = bt_sco_codec_playback_data; + stream_cfg.handler = bt_sco_codec_playback_data; #if defined(SPEECH_RX_24BIT) - stream_cfg.bits = AUD_BITS_24; - stream_cfg.data_size *= 2; + stream_cfg.bits = AUD_BITS_24; + stream_cfg.data_size *= 2; #endif #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - uint8_t* promptTmpSourcePcmDataBuf; - uint8_t* promptTmpTargetPcmDataBuf; - uint8_t* promptPcmDataBuf; - uint8_t* promptResamplerBuf; + uint8_t *promptTmpSourcePcmDataBuf; + uint8_t *promptTmpTargetPcmDataBuf; + uint8_t *promptPcmDataBuf; + uint8_t *promptResamplerBuf; - sco_sample_rate = stream_cfg.sample_rate; - app_audio_mempool_get_buff(&promptTmpSourcePcmDataBuf, AUDIO_PROMPT_SOURCE_PCM_BUFFER_SIZE); - app_audio_mempool_get_buff(&promptTmpTargetPcmDataBuf, AUDIO_PROMPT_TARGET_PCM_BUFFER_SIZE); - app_audio_mempool_get_buff(&promptPcmDataBuf, AUDIO_PROMPT_PCM_BUFFER_SIZE); - app_audio_mempool_get_buff(&promptResamplerBuf, AUDIO_PROMPT_BUF_SIZE_FOR_RESAMPLER); + sco_sample_rate = stream_cfg.sample_rate; + app_audio_mempool_get_buff(&promptTmpSourcePcmDataBuf, + AUDIO_PROMPT_SOURCE_PCM_BUFFER_SIZE); + app_audio_mempool_get_buff(&promptTmpTargetPcmDataBuf, + AUDIO_PROMPT_TARGET_PCM_BUFFER_SIZE); + app_audio_mempool_get_buff(&promptPcmDataBuf, AUDIO_PROMPT_PCM_BUFFER_SIZE); + app_audio_mempool_get_buff(&promptResamplerBuf, + AUDIO_PROMPT_BUF_SIZE_FOR_RESAMPLER); - audio_prompt_buffer_config(MIX_WITH_SCO_STREAMING, - stream_cfg.channel_num, - stream_cfg.bits, - promptTmpSourcePcmDataBuf, - promptTmpTargetPcmDataBuf, - promptPcmDataBuf, - AUDIO_PROMPT_PCM_BUFFER_SIZE, - promptResamplerBuf, - AUDIO_PROMPT_BUF_SIZE_FOR_RESAMPLER); + audio_prompt_buffer_config(MIX_WITH_SCO_STREAMING, stream_cfg.channel_num, + stream_cfg.bits, promptTmpSourcePcmDataBuf, + promptTmpTargetPcmDataBuf, promptPcmDataBuf, + AUDIO_PROMPT_PCM_BUFFER_SIZE, promptResamplerBuf, + AUDIO_PROMPT_BUF_SIZE_FOR_RESAMPLER); #endif - app_audio_mempool_get_buff(&bt_audio_buff, stream_cfg.data_size); - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); + app_audio_mempool_get_buff(&bt_audio_buff, stream_cfg.data_size); + stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); - TRACE_AUD_STREAM_I("[SCO_PLAYER] playback sample_rate:%d, data_size:%d",stream_cfg.sample_rate,stream_cfg.data_size); + TRACE_AUD_STREAM_I("[SCO_PLAYER] playback sample_rate:%d, data_size:%d", + stream_cfg.sample_rate, stream_cfg.data_size); -#if defined(AUDIO_ANC_FB_MC_SCO) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - sample_size_play_bt=stream_cfg.bits; - sample_rate_play_bt=stream_cfg.sample_rate; - data_size_play_bt=stream_cfg.data_size; - playback_buf_bt=stream_cfg.data_ptr; - playback_size_bt=stream_cfg.data_size; +#if defined(AUDIO_ANC_FB_MC_SCO) && defined(ANC_APP) && \ + !defined(__AUDIO_RESAMPLE__) + sample_size_play_bt = stream_cfg.bits; + sample_rate_play_bt = stream_cfg.sample_rate; + data_size_play_bt = stream_cfg.data_size; + playback_buf_bt = stream_cfg.data_ptr; + playback_size_bt = stream_cfg.data_size; #ifdef __BT_ANC__ - playback_samplerate_ratio_bt=8; + playback_samplerate_ratio_bt = 8; #else - if (sample_rate_play_bt == AUD_SAMPRATE_8000) - { - playback_samplerate_ratio_bt=8*3*2; - } - else if (sample_rate_play_bt == AUD_SAMPRATE_16000) - { - playback_samplerate_ratio_bt=8*3; - } + if (sample_rate_play_bt == AUD_SAMPRATE_8000) { + playback_samplerate_ratio_bt = 8 * 3 * 2; + } else if (sample_rate_play_bt == AUD_SAMPRATE_16000) { + playback_samplerate_ratio_bt = 8 * 3; + } #endif - playback_ch_num_bt=stream_cfg.channel_num; + playback_ch_num_bt = stream_cfg.channel_num; #endif #if defined(SCO_DMA_SNAPSHOT) - playback_buf_codecpcm=stream_cfg.data_ptr; - playback_size_codecpcm=stream_cfg.data_size; - playback_samplerate_codecpcm=stream_cfg.sample_rate; + playback_buf_codecpcm = stream_cfg.data_ptr; + playback_size_codecpcm = stream_cfg.data_size; + playback_samplerate_codecpcm = stream_cfg.sample_rate; #endif - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); - af_stream_dma_tc_irq_enable(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_dma_tc_irq_enable(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_codec_set_playback_post_handler(bt_sco_codec_playback_data_post_handler); + af_codec_set_playback_post_handler(bt_sco_codec_playback_data_post_handler); -#if defined(AUDIO_ANC_FB_MC_SCO) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - stream_cfg.bits = sample_size_play_bt; - stream_cfg.channel_num = playback_ch_num_bt; - stream_cfg.sample_rate = sample_rate_play_bt; - stream_cfg.device = AUD_STREAM_USE_MC; - stream_cfg.vol = 0; - stream_cfg.handler = audio_mc_data_playback_sco; - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; +#if defined(AUDIO_ANC_FB_MC_SCO) && defined(ANC_APP) && \ + !defined(__AUDIO_RESAMPLE__) + stream_cfg.bits = sample_size_play_bt; + stream_cfg.channel_num = playback_ch_num_bt; + stream_cfg.sample_rate = sample_rate_play_bt; + stream_cfg.device = AUD_STREAM_USE_MC; + stream_cfg.vol = 0; + stream_cfg.handler = audio_mc_data_playback_sco; + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; - app_audio_mempool_get_buff(&bt_audio_buff, data_size_play_bt*playback_samplerate_ratio_bt); - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); - stream_cfg.data_size = data_size_play_bt*playback_samplerate_ratio_bt; + app_audio_mempool_get_buff( + &bt_audio_buff, data_size_play_bt * playback_samplerate_ratio_bt); + stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); + stream_cfg.data_size = data_size_play_bt * playback_samplerate_ratio_bt; - playback_buf_mc=stream_cfg.data_ptr; - playback_size_mc=stream_cfg.data_size; + playback_buf_mc = stream_cfg.data_ptr; + playback_size_mc = stream_cfg.data_size; - anc_mc_run_init(hal_codec_anc_convert_rate(sample_rate_play_bt)); + anc_mc_run_init(hal_codec_anc_convert_rate(sample_rate_play_bt)); - memset(delay_buf_bt,0,sizeof(delay_buf_bt)); + memset(delay_buf_bt, 0, sizeof(delay_buf_bt)); - af_stream_open(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &stream_cfg); + af_stream_open(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &stream_cfg); #endif #if defined(BONE_SENSOR_TDM) - tdm_stream_open(); + tdm_stream_open(); #if defined(AF_ADC_I2S_SYNC) - af_codec_bt_trigger_config(true, bt_sco_bt_trigger_callback); + af_codec_bt_trigger_config(true, bt_sco_bt_trigger_callback); #endif #endif #if defined(ANC_NOISE_TRACKER) - app_audio_mempool_get_buff( - (uint8_t **)&anc_buf, - speech_get_frame_size( - speech_codec_get_sample_rate(), - ANC_NOISE_TRACKER_CHANNEL_NUM, - SPEECH_SCO_FRAME_MS) * sizeof(int16_t)); - noise_tracker_init(nt_demo_words_cb, ANC_NOISE_TRACKER_CHANNEL_NUM, -20); + app_audio_mempool_get_buff( + (uint8_t **)&anc_buf, + speech_get_frame_size(speech_codec_get_sample_rate(), + ANC_NOISE_TRACKER_CHANNEL_NUM, + SPEECH_SCO_FRAME_MS) * + sizeof(int16_t)); + noise_tracker_init(nt_demo_words_cb, ANC_NOISE_TRACKER_CHANNEL_NUM, -20); #endif - // Must call this function before af_stream_start - // Get all free app audio buffer except SCO_BTPCM used(2k) - voicebtpcm_pcm_audio_init(speech_sco_get_sample_rate(), speech_codec_get_sample_rate()); + // Must call this function before af_stream_start + // Get all free app audio buffer except SCO_BTPCM used(2k) + voicebtpcm_pcm_audio_init(speech_sco_get_sample_rate(), + speech_codec_get_sample_rate()); - /* - TRACE_AUD_STREAM_I("[SCO_PLAYER] start codec %d", FAST_TICKS_TO_US(hal_fast_sys_timer_get())); -#if defined(AUDIO_ANC_FB_MC) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - af_stream_start(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); + /* + TRACE_AUD_STREAM_I("[SCO_PLAYER] start codec %d", +FAST_TICKS_TO_US(hal_fast_sys_timer_get())); #if defined(AUDIO_ANC_FB_MC) && +defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) + af_stream_start(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); #endif - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - */ + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + */ #ifdef SPEECH_SIDETONE - hal_codec_sidetone_enable(); + hal_codec_sidetone_enable(); #endif #ifdef _SCO_BTPCM_CHANNEL_ - stream_cfg.bits = AUD_BITS_16; - stream_cfg.sample_rate = speech_sco_get_sample_rate(); - stream_cfg.channel_num = AUD_CHANNEL_NUM_1; - // stream_cfg.data_size = BT_AUDIO_SCO_BUFF_SIZE * stream_cfg.channel_num; + stream_cfg.bits = AUD_BITS_16; + stream_cfg.sample_rate = speech_sco_get_sample_rate(); + stream_cfg.channel_num = AUD_CHANNEL_NUM_1; + // stream_cfg.data_size = BT_AUDIO_SCO_BUFF_SIZE * stream_cfg.channel_num; - if (bt_sco_codec_is_msbc()) - { - stream_cfg.data_size = speech_get_af_buffer_size(stream_cfg.sample_rate, stream_cfg.channel_num, SPEECH_SCO_FRAME_MS)/2; - } - else - { - stream_cfg.data_size = speech_get_af_buffer_size(stream_cfg.sample_rate, stream_cfg.channel_num, SPEECH_SCO_FRAME_MS); - } + if (bt_sco_codec_is_msbc()) { + stream_cfg.data_size = speech_get_af_buffer_size(stream_cfg.sample_rate, + stream_cfg.channel_num, + SPEECH_SCO_FRAME_MS) / + 2; + } else { + stream_cfg.data_size = speech_get_af_buffer_size( + stream_cfg.sample_rate, stream_cfg.channel_num, SPEECH_SCO_FRAME_MS); + } - // btpcm:rx - stream_cfg.device = AUD_STREAM_USE_BT_PCM; - stream_cfg.handler = bt_sco_btpcm_capture_data; - app_audio_mempool_get_buff(&bt_audio_buff, stream_cfg.data_size); - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); + // btpcm:rx + stream_cfg.device = AUD_STREAM_USE_BT_PCM; + stream_cfg.handler = bt_sco_btpcm_capture_data; + app_audio_mempool_get_buff(&bt_audio_buff, stream_cfg.data_size); + stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); - TRACE_AUD_STREAM_I("[SCO_PLAYER] sco btpcm sample_rate:%d, data_size:%d",stream_cfg.sample_rate,stream_cfg.data_size); + TRACE_AUD_STREAM_I("[SCO_PLAYER] sco btpcm sample_rate:%d, data_size:%d", + stream_cfg.sample_rate, stream_cfg.data_size); #if defined(SCO_DMA_SNAPSHOT) - sco_btpcm_mute_flag=0; - sco_disconnect_mute_flag=0; + sco_btpcm_mute_flag = 0; + sco_disconnect_mute_flag = 0; - capture_buf_btpcm=stream_cfg.data_ptr; - capture_size_btpcm=stream_cfg.data_size; + capture_buf_btpcm = stream_cfg.data_ptr; + capture_size_btpcm = stream_cfg.data_size; #ifdef TX_RX_PCM_MASK - capture_size_btpcm_copy=stream_cfg.data_size/4;//only need ping or pang; - app_audio_mempool_get_buff(&capture_buf_btpcm_copy, capture_size_btpcm_copy); + capture_size_btpcm_copy = + stream_cfg.data_size / 4; // only need ping or pang; + app_audio_mempool_get_buff(&capture_buf_btpcm_copy, + capture_size_btpcm_copy); #endif #endif - af_stream_open(AUD_STREAM_ID_1, AUD_STREAM_CAPTURE, &stream_cfg); + af_stream_open(AUD_STREAM_ID_1, AUD_STREAM_CAPTURE, &stream_cfg); - // btpcm:tx - stream_cfg.device = AUD_STREAM_USE_BT_PCM; - stream_cfg.handler = bt_sco_btpcm_playback_data; - app_audio_mempool_get_buff(&bt_audio_buff, stream_cfg.data_size); - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); + // btpcm:tx + stream_cfg.device = AUD_STREAM_USE_BT_PCM; + stream_cfg.handler = bt_sco_btpcm_playback_data; + app_audio_mempool_get_buff(&bt_audio_buff, stream_cfg.data_size); + stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); #if defined(SCO_DMA_SNAPSHOT) - playback_buf_btpcm=stream_cfg.data_ptr; - playback_size_btpcm=stream_cfg.data_size; + playback_buf_btpcm = stream_cfg.data_ptr; + playback_size_btpcm = stream_cfg.data_size; #ifdef TX_RX_PCM_MASK - playback_size_btpcm_copy=stream_cfg.data_size/4; //only need ping or pang; - app_audio_mempool_get_buff(&playback_buf_btpcm_copy, playback_size_btpcm_copy); + playback_size_btpcm_copy = + stream_cfg.data_size / 4; // only need ping or pang; + app_audio_mempool_get_buff(&playback_buf_btpcm_copy, + playback_size_btpcm_copy); #endif - //only need ping or pang; - app_audio_mempool_get_buff(&playback_buf_btpcm_cache, stream_cfg.data_size/2); + // only need ping or pang; + app_audio_mempool_get_buff(&playback_buf_btpcm_cache, + stream_cfg.data_size / 2); #endif - af_stream_open(AUD_STREAM_ID_1, AUD_STREAM_PLAYBACK, &stream_cfg); + af_stream_open(AUD_STREAM_ID_1, AUD_STREAM_PLAYBACK, &stream_cfg); #if !(defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE)) - af_codec_tune(AUD_STREAM_NUM, 0); + af_codec_tune(AUD_STREAM_NUM, 0); #endif - TRACE_AUD_STREAM_I("[SCO_PLAYER] start btpcm %d", FAST_TICKS_TO_US(hal_fast_sys_timer_get())); - af_stream_start(AUD_STREAM_ID_1, AUD_STREAM_PLAYBACK); - af_stream_start(AUD_STREAM_ID_1, AUD_STREAM_CAPTURE); + TRACE_AUD_STREAM_I("[SCO_PLAYER] start btpcm %d", + FAST_TICKS_TO_US(hal_fast_sys_timer_get())); + af_stream_start(AUD_STREAM_ID_1, AUD_STREAM_PLAYBACK); + af_stream_start(AUD_STREAM_ID_1, AUD_STREAM_CAPTURE); #if defined(SCO_DMA_SNAPSHOT) - af_stream_dma_tc_irq_enable(AUD_STREAM_ID_1, AUD_STREAM_CAPTURE); + af_stream_dma_tc_irq_enable(AUD_STREAM_ID_1, AUD_STREAM_CAPTURE); #ifdef PLAYBACK_USE_I2S - af_i2s_sync_config(AUD_STREAM_PLAYBACK, AF_I2S_SYNC_TYPE_BT, true); + af_i2s_sync_config(AUD_STREAM_PLAYBACK, AF_I2S_SYNC_TYPE_BT, true); #else - af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, true); + af_codec_sync_config(AUD_STREAM_PLAYBACK, AF_CODEC_SYNC_TYPE_BT, true); #endif - af_codec_sync_config(AUD_STREAM_CAPTURE, AF_CODEC_SYNC_TYPE_BT, true); + af_codec_sync_config(AUD_STREAM_CAPTURE, AF_CODEC_SYNC_TYPE_BT, true); - btdrv_disable_playback_triggler(); - app_bt_stream_sco_trigger_btpcm_start(); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + btdrv_disable_playback_triggler(); + app_bt_stream_sco_trigger_btpcm_start(); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); #endif - is_codec_stream_started = false; + is_codec_stream_started = false; -#if defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) || defined(CHIP_BEST1400) || defined(CHIP_BEST1402) || defined(CHIP_BEST2001) +#if defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || \ + defined(CHIP_BEST2300A) || defined(CHIP_BEST1400) || \ + defined(CHIP_BEST1402) || defined(CHIP_BEST2001) #if defined(CVSD_BYPASS) - btdrv_cvsd_bypass_enable(bt_sco_codec_is_msbc()); + btdrv_cvsd_bypass_enable(bt_sco_codec_is_msbc()); #endif #if !defined(SCO_DMA_SNAPSHOT) - btdrv_pcm_enable(); + btdrv_pcm_enable(); #endif #endif #endif #ifdef FPGA - app_bt_stream_volumeset(stream_local_volume); - //btdrv_set_bt_pcm_en(1); + app_bt_stream_volumeset(stream_local_volume); + // btdrv_set_bt_pcm_en(1); #endif - app_bt_stream_trigger_checker_start(); - TRACE_AUD_STREAM_I("[SCO_PLAYER] on"); - } - else - { + app_bt_stream_trigger_checker_start(); + TRACE_AUD_STREAM_I("[SCO_PLAYER] on"); + } else { #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - bool isToClearActiveMedia= audio_prompt_clear_pending_stream(PENDING_TO_STOP_SCO_STREAMING); - if (isToClearActiveMedia) - { - bt_media_clear_media_type(BT_STREAM_VOICE, BT_DEVICE_ID_1); - } + bool isToClearActiveMedia = + audio_prompt_clear_pending_stream(PENDING_TO_STOP_SCO_STREAMING); + if (isToClearActiveMedia) { + bt_media_clear_media_type(BT_STREAM_VOICE, BT_DEVICE_ID_1); + } #endif - app_bt_stream_trigger_checker_stop(); + app_bt_stream_trigger_checker_stop(); #if defined(SCO_DMA_SNAPSHOT) #ifdef TX_RX_PCM_MASK - playback_buf_btpcm_copy=NULL; - capture_buf_btpcm_copy=NULL; - playback_size_btpcm_copy=0; - capture_size_btpcm_copy=0; + playback_buf_btpcm_copy = NULL; + capture_buf_btpcm_copy = NULL; + playback_size_btpcm_copy = 0; + capture_size_btpcm_copy = 0; #endif #endif #ifdef __THIRDPARTY - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO2,THIRDPARTY_MIC_CLOSE); + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO2, + THIRDPARTY_MIC_CLOSE); #endif #if defined(SCO_DMA_SNAPSHOT) - app_bt_stream_sco_trigger_codecpcm_stop(); + app_bt_stream_sco_trigger_codecpcm_stop(); #endif - af_stream_dma_tc_irq_disable(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_codec_set_playback_post_handler(NULL); + af_stream_dma_tc_irq_disable(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_codec_set_playback_post_handler(NULL); - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); -#if defined(AUDIO_ANC_FB_MC_SCO) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - af_stream_stop(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); +#if defined(AUDIO_ANC_FB_MC_SCO) && defined(ANC_APP) && \ + !defined(__AUDIO_RESAMPLE__) + af_stream_stop(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); #endif - is_codec_stream_started = false; + is_codec_stream_started = false; #if defined(BONE_SENSOR_TDM) - tdm_stream_stop(); + tdm_stream_stop(); #endif #if !(defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE)) - af_codec_tune(AUD_STREAM_NUM, 0); + af_codec_tune(AUD_STREAM_NUM, 0); #endif #ifdef _SCO_BTPCM_CHANNEL_ - af_stream_stop(AUD_STREAM_ID_1, AUD_STREAM_CAPTURE); - af_stream_stop(AUD_STREAM_ID_1, AUD_STREAM_PLAYBACK); + af_stream_stop(AUD_STREAM_ID_1, AUD_STREAM_CAPTURE); + af_stream_stop(AUD_STREAM_ID_1, AUD_STREAM_PLAYBACK); - af_stream_close(AUD_STREAM_ID_1, AUD_STREAM_CAPTURE); - af_stream_close(AUD_STREAM_ID_1, AUD_STREAM_PLAYBACK); + af_stream_close(AUD_STREAM_ID_1, AUD_STREAM_CAPTURE); + af_stream_close(AUD_STREAM_ID_1, AUD_STREAM_PLAYBACK); #endif #ifdef TX_RX_PCM_MASK - if (btdrv_is_pcm_mask_enable()==1 && bt_drv_reg_op_pcm_get()) - { - bt_drv_reg_op_pcm_set(0); - TRACE_AUD_STREAM_I("[SCO_PLAYER] PCM UNMASK"); - } + if (btdrv_is_pcm_mask_enable() == 1 && bt_drv_reg_op_pcm_get()) { + bt_drv_reg_op_pcm_set(0); + TRACE_AUD_STREAM_I("[SCO_PLAYER] PCM UNMASK"); + } #endif #if defined(PCM_FAST_MODE) - btdrv_open_pcm_fast_mode_disable(); + btdrv_open_pcm_fast_mode_disable(); #endif #if defined(HW_DC_FILTER_WITH_IIR) - hw_filter_codec_iir_destroy(hw_filter_codec_iir_st); + hw_filter_codec_iir_destroy(hw_filter_codec_iir_st); #endif - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); -#if defined(AUDIO_ANC_FB_MC_SCO) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - af_stream_close(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); +#if defined(AUDIO_ANC_FB_MC_SCO) && defined(ANC_APP) && \ + !defined(__AUDIO_RESAMPLE__) + af_stream_close(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); #endif #if defined(BONE_SENSOR_TDM) - tdm_stream_close(); + tdm_stream_close(); #endif #ifdef SPEECH_SIDETONE - hal_codec_sidetone_disable(); + hal_codec_sidetone_disable(); #endif #if defined(__AUDIO_RESAMPLE__) && defined(SW_SCO_RESAMPLE) - app_capture_resample_close(sco_capture_resample); - sco_capture_resample = NULL; - app_capture_resample_close(sco_playback_resample); - sco_playback_resample = NULL; + app_capture_resample_close(sco_capture_resample); + sco_capture_resample = NULL; + app_capture_resample_close(sco_playback_resample); + sco_playback_resample = NULL; #endif #if defined(__AUDIO_RESAMPLE__) && defined(NO_SCO_RESAMPLE) #ifndef CHIP_BEST1000 - // When __AUDIO_RESAMPLE__ is defined, - // resample is off by default on best1000, and on by default on other platforms - hal_cmu_audio_resample_enable(); + // When __AUDIO_RESAMPLE__ is defined, + // resample is off by default on best1000, and on by default on other + // platforms + hal_cmu_audio_resample_enable(); #endif #endif #ifdef PLAYBACK_USE_I2S - hal_cmu_audio_resample_enable(); + hal_cmu_audio_resample_enable(); #endif - bt_sco_mode = 0; + bt_sco_mode = 0; #ifdef __BT_ANC__ - bt_anc_sco_dec_buf = NULL; - //damic_deinit(); - //app_cap_thread_stop(); + bt_anc_sco_dec_buf = NULL; + // damic_deinit(); + // app_cap_thread_stop(); #endif - voicebtpcm_pcm_audio_deinit(); + voicebtpcm_pcm_audio_deinit(); #if defined(BONE_SENSOR_TDM) - lis25ba_deinit(); + lis25ba_deinit(); #endif #ifndef FPGA #ifdef BT_XTAL_SYNC - bt_term_xtal_sync(false); + bt_term_xtal_sync(false); #ifndef BT_XTAL_SYNC_NO_RESET - bt_term_xtal_sync_default(); + bt_term_xtal_sync_default(); #endif #endif #endif #if defined(HFP_1_6_ENABLE) - TRACE(1,"clear sco tx fifo codec:%d",bt_sco_player_code_type); - bt_drv_reg_op_sco_txfifo_reset(bt_sco_player_code_type); - bt_sco_player_code_type = BTIF_HF_SCO_CODEC_NONE; + TRACE(1, "clear sco tx fifo codec:%d", bt_sco_player_code_type); + bt_drv_reg_op_sco_txfifo_reset(bt_sco_player_code_type); + bt_sco_player_code_type = BTIF_HF_SCO_CODEC_NONE; #else - bt_drv_reg_op_sco_txfifo_reset(1); + bt_drv_reg_op_sco_txfifo_reset(1); #endif #if defined(ANC_WNR_ENABLED) - if (app_anc_work_status()) { - anc_wnr_close(); - anc_release_gain(); - anc_wnr_open(ANC_WNR_OPEN_MODE_STANDALONE); - } + if (app_anc_work_status()) { + anc_wnr_close(); + anc_release_gain(); + anc_wnr_open(ANC_WNR_OPEN_MODE_STANDALONE); + } #endif #ifdef __IAG_BLE_INCLUDE__ - app_ble_force_switch_adv(BLE_SWITCH_USER_SCO, true); + app_ble_force_switch_adv(BLE_SWITCH_USER_SCO, true); #endif - TRACE_AUD_STREAM_I("[SCO_PLAYER] off"); - app_overlay_unloadall(); - app_sysfreq_req(APP_SYSFREQ_USER_BT_SCO, APP_SYSFREQ_32K); - af_set_priority(AF_USER_SCO, osPriorityAboveNormal); + TRACE_AUD_STREAM_I("[SCO_PLAYER] off"); + app_overlay_unloadall(); + app_sysfreq_req(APP_SYSFREQ_USER_BT_SCO, APP_SYSFREQ_32K); + af_set_priority(AF_USER_SCO, osPriorityAboveNormal); - //bt_syncerr set to default(0x07) + // bt_syncerr set to default(0x07) // BTDIGITAL_REG_SET_FIELD(REG_BTCORE_BASE_ADDR, 0x0f, 0, 0x07); #ifdef __THIRDPARTY - //app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1,THIRDPARTY_START); - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO3,THIRDPARTY_START); - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_KWS,THIRDPARTY_CALL_STOP); + // app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1,THIRDPARTY_START); + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO3, + THIRDPARTY_START); + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_KWS, + THIRDPARTY_CALL_STOP); #endif #if defined(IBRT) - app_ibrt_if_exec_sleep_hook_blocker_clr(APP_IBRT_IF_SLEEP_HOOK_BLOCKER_HFP_SCO); - app_ibrt_ui_rssi_reset(); + app_ibrt_if_exec_sleep_hook_blocker_clr( + APP_IBRT_IF_SLEEP_HOOK_BLOCKER_HFP_SCO); + app_ibrt_ui_rssi_reset(); #endif #ifdef WL_DET - app_mic_alg_audioloop(true,APP_SYSFREQ_78M); + app_mic_alg_audioloop(true, APP_SYSFREQ_78M); #endif + } - } - - isRun=on; - return 0; + isRun = on; + return 0; } #ifdef AUDIO_LINEIN #include "app_status_ind.h" -//player channel should <= capture channel number -//player must be 2 channel +// player channel should <= capture channel number +// player must be 2 channel #define LINEIN_PLAYER_CHANNEL (2) #ifdef __AUDIO_OUTPUT_MONO_MODE__ #define LINEIN_CAPTURE_CHANNEL (1) @@ -6722,922 +6887,904 @@ int bt_sco_player(bool on, enum APP_SYSFREQ_FREQ_T freq) #endif #if (LINEIN_CAPTURE_CHANNEL == 1) -#define LINEIN_PLAYER_BUFFER_SIZE (1024*LINEIN_PLAYER_CHANNEL) -#define LINEIN_CAPTURE_BUFFER_SIZE (LINEIN_PLAYER_BUFFER_SIZE/2) +#define LINEIN_PLAYER_BUFFER_SIZE (1024 * LINEIN_PLAYER_CHANNEL) +#define LINEIN_CAPTURE_BUFFER_SIZE (LINEIN_PLAYER_BUFFER_SIZE / 2) #elif (LINEIN_CAPTURE_CHANNEL == 2) -#define LINEIN_PLAYER_BUFFER_SIZE (1024*LINEIN_PLAYER_CHANNEL) +#define LINEIN_PLAYER_BUFFER_SIZE (1024 * LINEIN_PLAYER_CHANNEL) #define LINEIN_CAPTURE_BUFFER_SIZE (LINEIN_PLAYER_BUFFER_SIZE) #endif -int8_t app_linein_buffer_is_empty(void) -{ - if (app_audio_pcmbuff_length()){ - return 0; - }else{ - return 1; - } +int8_t app_linein_buffer_is_empty(void) { + if (app_audio_pcmbuff_length()) { + return 0; + } else { + return 1; + } } -uint32_t app_linein_pcm_come(uint8_t * pcm_buf, uint32_t len) -{ - app_audio_pcmbuff_put(pcm_buf, len); +uint32_t app_linein_pcm_come(uint8_t *pcm_buf, uint32_t len) { + app_audio_pcmbuff_put(pcm_buf, len); - return len; + return len; } -uint32_t app_linein_need_pcm_data(uint8_t* pcm_buf, uint32_t len) -{ +uint32_t app_linein_need_pcm_data(uint8_t *pcm_buf, uint32_t len) { #if (LINEIN_CAPTURE_CHANNEL == 1) - app_audio_pcmbuff_get((uint8_t *)app_linein_play_cache, len/2); - app_play_audio_lineinmode_more_data((uint8_t *)app_linein_play_cache,len/2); - app_bt_stream_copy_track_one_to_two_16bits((int16_t *)pcm_buf, app_linein_play_cache, len/2/2); + app_audio_pcmbuff_get((uint8_t *)app_linein_play_cache, len / 2); + app_play_audio_lineinmode_more_data((uint8_t *)app_linein_play_cache, + len / 2); + app_bt_stream_copy_track_one_to_two_16bits( + (int16_t *)pcm_buf, app_linein_play_cache, len / 2 / 2); #elif (LINEIN_CAPTURE_CHANNEL == 2) - app_audio_pcmbuff_get((uint8_t *)pcm_buf, len); - app_play_audio_lineinmode_more_data((uint8_t *)pcm_buf, len); + app_audio_pcmbuff_get((uint8_t *)pcm_buf, len); + app_play_audio_lineinmode_more_data((uint8_t *)pcm_buf, len); #endif #if defined(__AUDIO_OUTPUT_MONO_MODE__) - merge_stereo_to_mono_16bits((int16_t *)buf, (int16_t *)pcm_buf, len/2); + merge_stereo_to_mono_16bits((int16_t *)buf, (int16_t *)pcm_buf, len / 2); #endif #ifdef ANC_APP - bt_audio_updata_eq_for_anc(app_anc_work_status()); + bt_audio_updata_eq_for_anc(app_anc_work_status()); #else - bt_audio_updata_eq(app_audio_get_eq()); + bt_audio_updata_eq(app_audio_get_eq()); #endif - audio_process_run(pcm_buf, len); + audio_process_run(pcm_buf, len); - return len; + return len; } -int app_play_linein_onoff(bool onoff) -{ - static bool isRun = false; - uint8_t *linein_audio_cap_buff = 0; - uint8_t *linein_audio_play_buff = 0; - uint8_t *linein_audio_loop_buf = NULL; - struct AF_STREAM_CONFIG_T stream_cfg; +int app_play_linein_onoff(bool onoff) { + static bool isRun = false; + uint8_t *linein_audio_cap_buff = 0; + uint8_t *linein_audio_play_buff = 0; + uint8_t *linein_audio_loop_buf = NULL; + struct AF_STREAM_CONFIG_T stream_cfg; - uint8_t POSSIBLY_UNUSED *bt_eq_buff = NULL; - uint32_t POSSIBLY_UNUSED eq_buff_size; - uint8_t POSSIBLY_UNUSED play_samp_size; + uint8_t POSSIBLY_UNUSED *bt_eq_buff = NULL; + uint32_t POSSIBLY_UNUSED eq_buff_size; + uint8_t POSSIBLY_UNUSED play_samp_size; - TRACE_AUD_STREAM_I("[LINEIN_PLAYER] work:%d op:%d", isRun, onoff); + TRACE_AUD_STREAM_I("[LINEIN_PLAYER] work:%d op:%d", isRun, onoff); - if (isRun == onoff) - return 0; + if (isRun == onoff) + return 0; - if (onoff){ - app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_104M); - app_overlay_select(APP_OVERLAY_A2DP); - app_audio_mempool_init(); - app_audio_mempool_get_buff(&linein_audio_cap_buff, LINEIN_CAPTURE_BUFFER_SIZE); - app_audio_mempool_get_buff(&linein_audio_play_buff, LINEIN_PLAYER_BUFFER_SIZE); - app_audio_mempool_get_buff(&linein_audio_loop_buf, LINEIN_PLAYER_BUFFER_SIZE<<2); - app_audio_pcmbuff_init(linein_audio_loop_buf, LINEIN_PLAYER_BUFFER_SIZE<<2); + if (onoff) { + app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_104M); + app_overlay_select(APP_OVERLAY_A2DP); + app_audio_mempool_init(); + app_audio_mempool_get_buff(&linein_audio_cap_buff, + LINEIN_CAPTURE_BUFFER_SIZE); + app_audio_mempool_get_buff(&linein_audio_play_buff, + LINEIN_PLAYER_BUFFER_SIZE); + app_audio_mempool_get_buff(&linein_audio_loop_buf, + LINEIN_PLAYER_BUFFER_SIZE << 2); + app_audio_pcmbuff_init(linein_audio_loop_buf, + LINEIN_PLAYER_BUFFER_SIZE << 2); #if (LINEIN_CAPTURE_CHANNEL == 1) - app_audio_mempool_get_buff((uint8_t **)&app_linein_play_cache, LINEIN_PLAYER_BUFFER_SIZE/2/2); - app_play_audio_lineinmode_init(LINEIN_CAPTURE_CHANNEL, LINEIN_PLAYER_BUFFER_SIZE/2/2); + app_audio_mempool_get_buff((uint8_t **)&app_linein_play_cache, + LINEIN_PLAYER_BUFFER_SIZE / 2 / 2); + app_play_audio_lineinmode_init(LINEIN_CAPTURE_CHANNEL, + LINEIN_PLAYER_BUFFER_SIZE / 2 / 2); #elif (LINEIN_CAPTURE_CHANNEL == 2) - app_play_audio_lineinmode_init(LINEIN_CAPTURE_CHANNEL, LINEIN_PLAYER_BUFFER_SIZE/2); + app_play_audio_lineinmode_init(LINEIN_CAPTURE_CHANNEL, + LINEIN_PLAYER_BUFFER_SIZE / 2); #endif - memset(&stream_cfg, 0, sizeof(stream_cfg)); + memset(&stream_cfg, 0, sizeof(stream_cfg)); - stream_cfg.bits = AUD_BITS_16; - stream_cfg.channel_num = (enum AUD_CHANNEL_NUM_T)LINEIN_PLAYER_CHANNEL; + stream_cfg.bits = AUD_BITS_16; + stream_cfg.channel_num = (enum AUD_CHANNEL_NUM_T)LINEIN_PLAYER_CHANNEL; #if defined(__AUDIO_RESAMPLE__) - stream_cfg.sample_rate = AUD_SAMPRATE_50781; + stream_cfg.sample_rate = AUD_SAMPRATE_50781; #else - stream_cfg.sample_rate = AUD_SAMPRATE_44100; + stream_cfg.sample_rate = AUD_SAMPRATE_44100; #endif -#if FPGA==0 - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; +#if FPGA == 0 + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; #else - stream_cfg.device = AUD_STREAM_USE_EXT_CODEC; + stream_cfg.device = AUD_STREAM_USE_EXT_CODEC; #endif - stream_cfg.vol = stream_linein_volume; - TRACE_AUD_STREAM_I("[LINEIN_PLAYER] vol = %d",stream_linein_volume); - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; - stream_cfg.handler = app_linein_need_pcm_data; - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(linein_audio_play_buff); - stream_cfg.data_size = LINEIN_PLAYER_BUFFER_SIZE; + stream_cfg.vol = stream_linein_volume; + TRACE_AUD_STREAM_I("[LINEIN_PLAYER] vol = %d", stream_linein_volume); + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; + stream_cfg.handler = app_linein_need_pcm_data; + stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(linein_audio_play_buff); + stream_cfg.data_size = LINEIN_PLAYER_BUFFER_SIZE; #if defined(AUDIO_ANC_FB_MC) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - sample_size_play_bt=stream_cfg.bits; - sample_rate_play_bt=stream_cfg.sample_rate; - data_size_play_bt=stream_cfg.data_size; - playback_buf_bt=stream_cfg.data_ptr; - playback_size_bt=stream_cfg.data_size; - if(sample_rate_play_bt==AUD_SAMPRATE_96000) - { - playback_samplerate_ratio_bt=4; - } - else - { - playback_samplerate_ratio_bt=8; - } - playback_ch_num_bt=stream_cfg.channel_num; - mid_p_8_old_l=0; - mid_p_8_old_r=0; + sample_size_play_bt = stream_cfg.bits; + sample_rate_play_bt = stream_cfg.sample_rate; + data_size_play_bt = stream_cfg.data_size; + playback_buf_bt = stream_cfg.data_ptr; + playback_size_bt = stream_cfg.data_size; + if (sample_rate_play_bt == AUD_SAMPRATE_96000) { + playback_samplerate_ratio_bt = 4; + } else { + playback_samplerate_ratio_bt = 8; + } + playback_ch_num_bt = stream_cfg.channel_num; + mid_p_8_old_l = 0; + mid_p_8_old_r = 0; #endif - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); #if defined(__HW_FIR_EQ_PROCESS__) && defined(__HW_IIR_EQ_PROCESS__) - eq_buff_size = stream_cfg.data_size*2; + eq_buff_size = stream_cfg.data_size * 2; #elif defined(__HW_FIR_EQ_PROCESS__) && !defined(__HW_IIR_EQ_PROCESS__) - play_samp_size = (stream_cfg.bits <= AUD_BITS_16) ? 2 : 4; + play_samp_size = (stream_cfg.bits <= AUD_BITS_16) ? 2 : 4; #if defined(CHIP_BEST2000) - eq_buff_size = stream_cfg.data_size * sizeof(int32_t) / play_samp_size; -#elif defined(CHIP_BEST1000) - eq_buff_size = stream_cfg.data_size * sizeof(int16_t) / play_samp_size; -#elif defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) - eq_buff_size = stream_cfg.data_size; + eq_buff_size = stream_cfg.data_size * sizeof(int32_t) / play_samp_size; +#elif defined(CHIP_BEST1000) + eq_buff_size = stream_cfg.data_size * sizeof(int16_t) / play_samp_size; +#elif defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || \ + defined(CHIP_BEST2300A) + eq_buff_size = stream_cfg.data_size; #endif #elif !defined(__HW_FIR_EQ_PROCESS__) && defined(__HW_IIR_EQ_PROCESS__) - eq_buff_size = stream_cfg.data_size; + eq_buff_size = stream_cfg.data_size; #else - eq_buff_size = 0; - bt_eq_buff = NULL; + eq_buff_size = 0; + bt_eq_buff = NULL; #endif - if(eq_buff_size>0) - { - app_audio_mempool_get_buff(&bt_eq_buff, eq_buff_size); - } + if (eq_buff_size > 0) { + app_audio_mempool_get_buff(&bt_eq_buff, eq_buff_size); + } #if defined(IBRT) - enum AUD_CHANNEL_NUM_T sw_ch_num = AUD_CHANNEL_NUM_1; + enum AUD_CHANNEL_NUM_T sw_ch_num = AUD_CHANNEL_NUM_1; #else - enum AUD_CHANNEL_NUM_T sw_ch_num = stream_cfg.channel_num; + enum AUD_CHANNEL_NUM_T sw_ch_num = stream_cfg.channel_num; #endif - audio_process_open(stream_cfg.sample_rate, stream_cfg.bits, sw_ch_num, stream_cfg.channel_num, stream_cfg.data_size/stream_cfg.channel_num/(stream_cfg.bits <= AUD_BITS_16 ? 2 : 4)/2, bt_eq_buff, eq_buff_size); + audio_process_open(stream_cfg.sample_rate, stream_cfg.bits, sw_ch_num, + stream_cfg.channel_num, + stream_cfg.data_size / stream_cfg.channel_num / + (stream_cfg.bits <= AUD_BITS_16 ? 2 : 4) / 2, + bt_eq_buff, eq_buff_size); #ifdef __SW_IIR_EQ_PROCESS__ - bt_audio_set_eq(AUDIO_EQ_TYPE_SW_IIR,bt_audio_get_eq_index(AUDIO_EQ_TYPE_SW_IIR,0)); + bt_audio_set_eq(AUDIO_EQ_TYPE_SW_IIR, + bt_audio_get_eq_index(AUDIO_EQ_TYPE_SW_IIR, 0)); #endif #ifdef __HW_FIR_EQ_PROCESS__ - bt_audio_set_eq(AUDIO_EQ_TYPE_HW_FIR,bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_FIR,0)); + bt_audio_set_eq(AUDIO_EQ_TYPE_HW_FIR, + bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_FIR, 0)); #endif #ifdef __HW_DAC_IIR_EQ_PROCESS__ - bt_audio_set_eq(AUDIO_EQ_TYPE_HW_DAC_IIR,bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_DAC_IIR,0)); + bt_audio_set_eq(AUDIO_EQ_TYPE_HW_DAC_IIR, + bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_DAC_IIR, 0)); #endif #ifdef __HW_IIR_EQ_PROCESS__ - bt_audio_set_eq(AUDIO_EQ_TYPE_HW_IIR,bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_IIR,0)); + bt_audio_set_eq(AUDIO_EQ_TYPE_HW_IIR, + bt_audio_get_eq_index(AUDIO_EQ_TYPE_HW_IIR, 0)); #endif #ifdef ANC_APP - anc_status_record = 0xff; + anc_status_record = 0xff; #endif #if defined(AUDIO_ANC_FB_MC) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - uint8_t *bt_audio_buff = NULL; - stream_cfg.bits = sample_size_play_bt; - stream_cfg.channel_num = playback_ch_num_bt; - stream_cfg.sample_rate = sample_rate_play_bt; - stream_cfg.device = AUD_STREAM_USE_MC; - stream_cfg.vol = 0; - stream_cfg.handler = audio_mc_data_playback_a2dp; - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; + uint8_t *bt_audio_buff = NULL; + stream_cfg.bits = sample_size_play_bt; + stream_cfg.channel_num = playback_ch_num_bt; + stream_cfg.sample_rate = sample_rate_play_bt; + stream_cfg.device = AUD_STREAM_USE_MC; + stream_cfg.vol = 0; + stream_cfg.handler = audio_mc_data_playback_a2dp; + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; - app_audio_mempool_get_buff(&bt_audio_buff, data_size_play_bt*playback_samplerate_ratio_bt); - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); - stream_cfg.data_size = data_size_play_bt*playback_samplerate_ratio_bt; + app_audio_mempool_get_buff( + &bt_audio_buff, data_size_play_bt * playback_samplerate_ratio_bt); + stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); + stream_cfg.data_size = data_size_play_bt * playback_samplerate_ratio_bt; - playback_buf_mc=stream_cfg.data_ptr; - playback_size_mc=stream_cfg.data_size; + playback_buf_mc = stream_cfg.data_ptr; + playback_size_mc = stream_cfg.data_size; - anc_mc_run_init(hal_codec_anc_convert_rate(sample_rate_play_bt)); + anc_mc_run_init(hal_codec_anc_convert_rate(sample_rate_play_bt)); - memset(delay_buf_bt,0,sizeof(delay_buf_bt)); + memset(delay_buf_bt, 0, sizeof(delay_buf_bt)); - af_stream_open(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &stream_cfg); - //ASSERT(ret == 0, "af_stream_open playback failed: %d", ret); + af_stream_open(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &stream_cfg); + // ASSERT(ret == 0, "af_stream_open playback failed: %d", ret); #endif - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); #if defined(AUDIO_ANC_FB_MC) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - af_stream_start(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); + af_stream_start(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); #endif - memset(&stream_cfg, 0, sizeof(stream_cfg)); + memset(&stream_cfg, 0, sizeof(stream_cfg)); - stream_cfg.bits = AUD_BITS_16; + stream_cfg.bits = AUD_BITS_16; #if defined(__AUDIO_RESAMPLE__) - stream_cfg.sample_rate = AUD_SAMPRATE_50781; + stream_cfg.sample_rate = AUD_SAMPRATE_50781; #else - stream_cfg.sample_rate = AUD_SAMPRATE_44100; + stream_cfg.sample_rate = AUD_SAMPRATE_44100; #endif -#if FPGA==0 - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; +#if FPGA == 0 + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; #else - stream_cfg.device = AUD_STREAM_USE_EXT_CODEC; + stream_cfg.device = AUD_STREAM_USE_EXT_CODEC; #endif - stream_cfg.io_path = AUD_INPUT_PATH_LINEIN; - stream_cfg.channel_num = (enum AUD_CHANNEL_NUM_T)LINEIN_CAPTURE_CHANNEL; - stream_cfg.channel_map = (enum AUD_CHANNEL_MAP_T)hal_codec_get_input_path_cfg(stream_cfg.io_path); - stream_cfg.handler = app_linein_pcm_come; - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(linein_audio_cap_buff); - stream_cfg.data_size = LINEIN_CAPTURE_BUFFER_SIZE; + stream_cfg.io_path = AUD_INPUT_PATH_LINEIN; + stream_cfg.channel_num = (enum AUD_CHANNEL_NUM_T)LINEIN_CAPTURE_CHANNEL; + stream_cfg.channel_map = + (enum AUD_CHANNEL_MAP_T)hal_codec_get_input_path_cfg( + stream_cfg.io_path); + stream_cfg.handler = app_linein_pcm_come; + stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(linein_audio_cap_buff); + stream_cfg.data_size = LINEIN_CAPTURE_BUFFER_SIZE; - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - }else { - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + } else { + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - audio_process_close(); + audio_process_close(); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - app_overlay_unloadall(); - app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_32K); - } + app_overlay_unloadall(); + app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_32K); + } - isRun = onoff; - TRACE_AUD_STREAM_I("[LINEIN_PLAYER] end!\n"); - return 0; + isRun = onoff; + TRACE_AUD_STREAM_I("[LINEIN_PLAYER] end!\n"); + return 0; } #endif -int app_bt_stream_open(APP_AUDIO_STATUS* status) -{ - int nRet = -1; - uint16_t player = status->id; - APP_AUDIO_STATUS next_status; - enum APP_SYSFREQ_FREQ_T freq = (enum APP_SYSFREQ_FREQ_T)status->freq; +int app_bt_stream_open(APP_AUDIO_STATUS *status) { + int nRet = -1; + uint16_t player = status->id; + APP_AUDIO_STATUS next_status; + enum APP_SYSFREQ_FREQ_T freq = (enum APP_SYSFREQ_FREQ_T)status->freq; - TRACE_AUD_STREAM_I("[STRM_PLAYER][OPEN] prev:0x%x%s freq:%d", gStreamplayer, player2str(gStreamplayer), freq); - TRACE_AUD_STREAM_I("[STRM_PLAYER][OPEN] cur:0x%x%s freq:%d", player, player2str(player), freq); + TRACE_AUD_STREAM_I("[STRM_PLAYER][OPEN] prev:0x%x%s freq:%d", gStreamplayer, + player2str(gStreamplayer), freq); + TRACE_AUD_STREAM_I("[STRM_PLAYER][OPEN] cur:0x%x%s freq:%d", player, + player2str(player), freq); - APP_AUDIO_STATUS streamToClose; + APP_AUDIO_STATUS streamToClose; - if (gStreamplayer != APP_BT_STREAM_INVALID) - { + if (gStreamplayer != APP_BT_STREAM_INVALID) { #if !ISOLATED_AUDIO_STREAM_ENABLED - TRACE_AUD_STREAM_I("[STRM_PLAYER][OPEN] close 0x%x%s prev opening", gStreamplayer, player2str(gStreamplayer)); - nRet = app_bt_stream_close(gStreamplayer); - if (nRet) - { - return -1; - } - else - { - streamToClose.id = gStreamplayer; - app_audio_list_rmv_callback(&streamToClose, &next_status, APP_BT_SETTING_Q_POS_TAIL, false); - } + TRACE_AUD_STREAM_I("[STRM_PLAYER][OPEN] close 0x%x%s prev opening", + gStreamplayer, player2str(gStreamplayer)); + nRet = app_bt_stream_close(gStreamplayer); + if (nRet) { + return -1; + } else { + streamToClose.id = gStreamplayer; + app_audio_list_rmv_callback(&streamToClose, &next_status, + APP_BT_SETTING_Q_POS_TAIL, false); + } #else - if (gStreamplayer & player) - { - TRACE_AUD_STREAM_I("[STRM_PLAYER][OPEN] 0x%x%s has opened", player, player2str(player)); - return -1; - } - - if (player >= APP_BT_STREAM_BORDER_INDEX) - { - if (APP_BT_INPUT_STREAM_INDEX(gStreamplayer) > 0) - { - TRACE_AUD_STREAM_I("[STRM_PLAYER][OPEN] close 0x%x%s prev opening", gStreamplayer, player2str(gStreamplayer)); - } - } - else - { - if (APP_BT_OUTPUT_STREAM_INDEX(gStreamplayer) > 0) - { - TRACE_AUD_STREAM_I("[STRM_PLAYER][OPEN] close 0x%x%s prev opening", gStreamplayer, player2str(gStreamplayer)); - uint16_t player2close = APP_BT_OUTPUT_STREAM_INDEX(gStreamplayer); - nRet = app_bt_stream_close(player2close); - if (nRet) - { - return -1; - } - else - { - streamToClose.id = player2close; - app_audio_list_rmv_callback(&streamToClose, &next_status, APP_BT_SETTING_Q_POS_TAIL, false); - } - } - } -#endif + if (gStreamplayer & player) { + TRACE_AUD_STREAM_I("[STRM_PLAYER][OPEN] 0x%x%s has opened", player, + player2str(player)); + return -1; } - switch (player) - { - case APP_BT_STREAM_HFP_PCM: - case APP_BT_STREAM_HFP_CVSD: - case APP_BT_STREAM_HFP_VENDOR: - nRet = bt_sco_player(true, freq); - break; - case APP_BT_STREAM_A2DP_SBC: - case APP_BT_STREAM_A2DP_AAC: - case APP_BT_STREAM_A2DP_VENDOR: - nRet = bt_sbc_player(PLAYER_OPER_START, freq); - break; + if (player >= APP_BT_STREAM_BORDER_INDEX) { + if (APP_BT_INPUT_STREAM_INDEX(gStreamplayer) > 0) { + TRACE_AUD_STREAM_I("[STRM_PLAYER][OPEN] close 0x%x%s prev opening", + gStreamplayer, player2str(gStreamplayer)); + } + } else { + if (APP_BT_OUTPUT_STREAM_INDEX(gStreamplayer) > 0) { + TRACE_AUD_STREAM_I("[STRM_PLAYER][OPEN] close 0x%x%s prev opening", + gStreamplayer, player2str(gStreamplayer)); + uint16_t player2close = APP_BT_OUTPUT_STREAM_INDEX(gStreamplayer); + nRet = app_bt_stream_close(player2close); + if (nRet) { + return -1; + } else { + streamToClose.id = player2close; + app_audio_list_rmv_callback(&streamToClose, &next_status, + APP_BT_SETTING_Q_POS_TAIL, false); + } + } + } +#endif + } + + switch (player) { + case APP_BT_STREAM_HFP_PCM: + case APP_BT_STREAM_HFP_CVSD: + case APP_BT_STREAM_HFP_VENDOR: + nRet = bt_sco_player(true, freq); + break; + case APP_BT_STREAM_A2DP_SBC: + case APP_BT_STREAM_A2DP_AAC: + case APP_BT_STREAM_A2DP_VENDOR: + nRet = bt_sbc_player(PLAYER_OPER_START, freq); + break; #ifdef __FACTORY_MODE_SUPPORT__ - case APP_FACTORYMODE_AUDIO_LOOP: - nRet = app_factorymode_audioloop(true, freq); - break; + case APP_FACTORYMODE_AUDIO_LOOP: + nRet = app_factorymode_audioloop(true, freq); + break; #endif #ifdef MEDIA_PLAYER_SUPPORT - case APP_PLAY_BACK_AUDIO: - nRet = app_play_audio_onoff(true, status); - break; + case APP_PLAY_BACK_AUDIO: + nRet = app_play_audio_onoff(true, status); + break; #endif #ifdef RB_CODEC - case APP_BT_STREAM_RBCODEC: - nRet = app_rbplay_audio_onoff(true, 0); - break; + case APP_BT_STREAM_RBCODEC: + nRet = app_rbplay_audio_onoff(true, 0); + break; #endif #ifdef AUDIO_LINEIN - case APP_PLAY_LINEIN_AUDIO: - nRet = app_play_linein_onoff(true); - break; + case APP_PLAY_LINEIN_AUDIO: + nRet = app_play_linein_onoff(true); + break; #endif #if defined(APP_LINEIN_A2DP_SOURCE) - case APP_A2DP_SOURCE_LINEIN_AUDIO: - nRet = app_a2dp_source_linein_on(true); - break; + case APP_A2DP_SOURCE_LINEIN_AUDIO: + nRet = app_a2dp_source_linein_on(true); + break; #endif #if defined(APP_I2S_A2DP_SOURCE) - case APP_A2DP_SOURCE_I2S_AUDIO: - nRet = app_a2dp_source_I2S_onoff(true); - break; + case APP_A2DP_SOURCE_I2S_AUDIO: + nRet = app_a2dp_source_I2S_onoff(true); + break; #endif #ifdef VOICE_DATAPATH - case APP_BT_STREAM_VOICEPATH: - nRet = app_voicepath_start_audio_stream(); - break; + case APP_BT_STREAM_VOICEPATH: + nRet = app_voicepath_start_audio_stream(); + break; #endif #ifdef __AI_VOICE__ - case APP_BT_STREAM_AI_VOICE: - nRet = app_ai_voice_start_mic_stream(); - break; + case APP_BT_STREAM_AI_VOICE: + nRet = app_ai_voice_start_mic_stream(); + break; #endif #ifdef __THIRDPARTY - case APP_BT_STREAM_THIRDPARTY_VOICE: - nRet = app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_KWS, THIRDPARTY_MIC_OPEN); - break; + case APP_BT_STREAM_THIRDPARTY_VOICE: + nRet = app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_KWS, + THIRDPARTY_MIC_OPEN); + break; #endif - default: - nRet = -1; - break; - } + default: + nRet = -1; + break; + } - if (!nRet) - { - gStreamplayer |= player; - TRACE_AUD_STREAM_I("[STRM_PLAYER][OPEN] updated to 0x%x%s", gStreamplayer, player2str(gStreamplayer)); - } - return nRet; + if (!nRet) { + gStreamplayer |= player; + TRACE_AUD_STREAM_I("[STRM_PLAYER][OPEN] updated to 0x%x%s", gStreamplayer, + player2str(gStreamplayer)); + } + return nRet; } -int app_bt_stream_close(uint16_t player) -{ - int nRet = -1; - TRACE_AUD_STREAM_I("[STRM_PLAYER][CLOSE] gStreamplayer: 0x%x%s", gStreamplayer, player2str(gStreamplayer)); - TRACE_AUD_STREAM_I("[STRM_PLAYER][CLOSE] player:0x%x%s", gStreamplayer, player2str(gStreamplayer)); +int app_bt_stream_close(uint16_t player) { + int nRet = -1; + TRACE_AUD_STREAM_I("[STRM_PLAYER][CLOSE] gStreamplayer: 0x%x%s", + gStreamplayer, player2str(gStreamplayer)); + TRACE_AUD_STREAM_I("[STRM_PLAYER][CLOSE] player:0x%x%s", gStreamplayer, + player2str(gStreamplayer)); - if ((gStreamplayer & player) != player) - { - return -1; - } + if ((gStreamplayer & player) != player) { + return -1; + } - switch (player) - { - case APP_BT_STREAM_HFP_PCM: - case APP_BT_STREAM_HFP_CVSD: - case APP_BT_STREAM_HFP_VENDOR: - nRet = bt_sco_player(false, APP_SYSFREQ_32K); - break; - case APP_BT_STREAM_A2DP_SBC: - case APP_BT_STREAM_A2DP_AAC: - case APP_BT_STREAM_A2DP_VENDOR: - nRet = bt_sbc_player(PLAYER_OPER_STOP, APP_SYSFREQ_32K); - break; + switch (player) { + case APP_BT_STREAM_HFP_PCM: + case APP_BT_STREAM_HFP_CVSD: + case APP_BT_STREAM_HFP_VENDOR: + nRet = bt_sco_player(false, APP_SYSFREQ_32K); + break; + case APP_BT_STREAM_A2DP_SBC: + case APP_BT_STREAM_A2DP_AAC: + case APP_BT_STREAM_A2DP_VENDOR: + nRet = bt_sbc_player(PLAYER_OPER_STOP, APP_SYSFREQ_32K); + break; #ifdef __FACTORY_MODE_SUPPORT__ - case APP_FACTORYMODE_AUDIO_LOOP: - nRet = app_factorymode_audioloop(false, APP_SYSFREQ_32K); - break; + case APP_FACTORYMODE_AUDIO_LOOP: + nRet = app_factorymode_audioloop(false, APP_SYSFREQ_32K); + break; #endif #ifdef MEDIA_PLAYER_SUPPORT - case APP_PLAY_BACK_AUDIO: - nRet = app_play_audio_onoff(false, NULL); - break; + case APP_PLAY_BACK_AUDIO: + nRet = app_play_audio_onoff(false, NULL); + break; #endif #ifdef RB_CODEC - case APP_BT_STREAM_RBCODEC: - nRet = app_rbplay_audio_onoff(false, 0); - break; + case APP_BT_STREAM_RBCODEC: + nRet = app_rbplay_audio_onoff(false, 0); + break; #endif #ifdef AUDIO_LINEIN - case APP_PLAY_LINEIN_AUDIO: - nRet = app_play_linein_onoff(false); - break; + case APP_PLAY_LINEIN_AUDIO: + nRet = app_play_linein_onoff(false); + break; #endif #if defined(APP_LINEIN_A2DP_SOURCE) - case APP_A2DP_SOURCE_LINEIN_AUDIO: - nRet = app_a2dp_source_linein_on(false); - break; + case APP_A2DP_SOURCE_LINEIN_AUDIO: + nRet = app_a2dp_source_linein_on(false); + break; #endif #if defined(APP_I2S_A2DP_SOURCE) - case APP_A2DP_SOURCE_I2S_AUDIO: - nRet = app_a2dp_source_I2S_onoff(false); - break; + case APP_A2DP_SOURCE_I2S_AUDIO: + nRet = app_a2dp_source_I2S_onoff(false); + break; #endif #ifdef VOICE_DATAPATH - case APP_BT_STREAM_VOICEPATH: - nRet = app_voicepath_stop_audio_stream(); - break; + case APP_BT_STREAM_VOICEPATH: + nRet = app_voicepath_stop_audio_stream(); + break; #endif #ifdef __AI_VOICE__ - case APP_BT_STREAM_AI_VOICE: - nRet = app_ai_voice_stop_mic_stream(); - break; + case APP_BT_STREAM_AI_VOICE: + nRet = app_ai_voice_stop_mic_stream(); + break; #endif #ifdef __THIRDPARTY - case APP_BT_STREAM_THIRDPARTY_VOICE: - nRet = app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_KWS, THIRDPARTY_MIC_CLOSE); - break; + case APP_BT_STREAM_THIRDPARTY_VOICE: + nRet = app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_KWS, + THIRDPARTY_MIC_CLOSE); + break; #endif - default: - nRet = -1; - break; - } - if (!nRet) - { - gStreamplayer &= (~player); - TRACE_AUD_STREAM_I("[STRM_PLAYER][CLOSE] updated to 0x%x%s", gStreamplayer, player2str(gStreamplayer)); - } - return nRet; + default: + nRet = -1; + break; + } + if (!nRet) { + gStreamplayer &= (~player); + TRACE_AUD_STREAM_I("[STRM_PLAYER][CLOSE] updated to 0x%x%s", gStreamplayer, + player2str(gStreamplayer)); + } + return nRet; } -int app_bt_stream_setup(uint16_t player, uint8_t status) -{ - int nRet = -1; +int app_bt_stream_setup(uint16_t player, uint8_t status) { + int nRet = -1; - TRACE_AUD_STREAM_I("[STRM_PLAYER][SETUP] prev:%d%s sample:%d", gStreamplayer, player2str(gStreamplayer), status); - TRACE_AUD_STREAM_I("[STRM_PLAYER][SETUP] cur:%d%s sample:%d", player, player2str(player), status); + TRACE_AUD_STREAM_I("[STRM_PLAYER][SETUP] prev:%d%s sample:%d", gStreamplayer, + player2str(gStreamplayer), status); + TRACE_AUD_STREAM_I("[STRM_PLAYER][SETUP] cur:%d%s sample:%d", player, + player2str(player), status); - switch (player) - { - case APP_BT_STREAM_HFP_PCM: - case APP_BT_STREAM_HFP_CVSD: - case APP_BT_STREAM_HFP_VENDOR: - break; - case APP_BT_STREAM_A2DP_SBC: - case APP_BT_STREAM_A2DP_AAC: - case APP_BT_STREAM_A2DP_VENDOR: - bt_sbc_player_setup(status); - break; - default: - nRet = -1; - break; - } + switch (player) { + case APP_BT_STREAM_HFP_PCM: + case APP_BT_STREAM_HFP_CVSD: + case APP_BT_STREAM_HFP_VENDOR: + break; + case APP_BT_STREAM_A2DP_SBC: + case APP_BT_STREAM_A2DP_AAC: + case APP_BT_STREAM_A2DP_VENDOR: + bt_sbc_player_setup(status); + break; + default: + nRet = -1; + break; + } - return nRet; + return nRet; } -int app_bt_stream_restart(APP_AUDIO_STATUS* status) -{ - int nRet = -1; - uint16_t player = status->id; - enum APP_SYSFREQ_FREQ_T freq = (enum APP_SYSFREQ_FREQ_T)status->freq; +int app_bt_stream_restart(APP_AUDIO_STATUS *status) { + int nRet = -1; + uint16_t player = status->id; + enum APP_SYSFREQ_FREQ_T freq = (enum APP_SYSFREQ_FREQ_T)status->freq; - TRACE_AUD_STREAM_I("[STRM_PLAYER][RESTART] prev:%d%s freq:%d", gStreamplayer, player2str(gStreamplayer), freq); - TRACE_AUD_STREAM_I("[STRM_PLAYER][RESTART] cur:%d%s freq:%d", player, player2str(player), freq); + TRACE_AUD_STREAM_I("[STRM_PLAYER][RESTART] prev:%d%s freq:%d", gStreamplayer, + player2str(gStreamplayer), freq); + TRACE_AUD_STREAM_I("[STRM_PLAYER][RESTART] cur:%d%s freq:%d", player, + player2str(player), freq); - if ((gStreamplayer & player) != player) - { - return -1; - } + if ((gStreamplayer & player) != player) { + return -1; + } - switch (player) - { - case APP_BT_STREAM_HFP_PCM: - case APP_BT_STREAM_HFP_CVSD: - case APP_BT_STREAM_HFP_VENDOR: - nRet = bt_sco_player(false, freq); - nRet = bt_sco_player(true, freq); - break; - case APP_BT_STREAM_A2DP_SBC: - case APP_BT_STREAM_A2DP_AAC: - case APP_BT_STREAM_A2DP_VENDOR: + switch (player) { + case APP_BT_STREAM_HFP_PCM: + case APP_BT_STREAM_HFP_CVSD: + case APP_BT_STREAM_HFP_VENDOR: + nRet = bt_sco_player(false, freq); + nRet = bt_sco_player(true, freq); + break; + case APP_BT_STREAM_A2DP_SBC: + case APP_BT_STREAM_A2DP_AAC: + case APP_BT_STREAM_A2DP_VENDOR: #if defined(IBRT) - ibrt_a2dp_status_t a2dp_status; - a2dp_ibrt_sync_get_status(&a2dp_status); - TRACE_AUD_STREAM_I("[STRM_PLAYER][RESTART] state:%d", a2dp_status.state); - if (a2dp_status.state == BTIF_AVDTP_STRM_STATE_STREAMING){ - if (app_audio_manager_a2dp_is_active(BT_DEVICE_ID_1)){ - TRACE_AUD_STREAM_I("[STRM_PLAYER][RESTART] resume"); - nRet = bt_sbc_player(PLAYER_OPER_STOP, freq); - nRet = bt_sbc_player(PLAYER_OPER_START, freq); - }else{ - if (app_ibrt_ui_is_profile_exchanged()){ - TRACE_AUD_STREAM_I("[STRM_PLAYER][RESTART] force_audio_retrigger"); - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START,BT_STREAM_SBC, BT_DEVICE_ID_1,MAX_RECORD_NUM); - app_ibrt_if_force_audio_retrigger(); - } - } - } + ibrt_a2dp_status_t a2dp_status; + a2dp_ibrt_sync_get_status(&a2dp_status); + TRACE_AUD_STREAM_I("[STRM_PLAYER][RESTART] state:%d", a2dp_status.state); + if (a2dp_status.state == BTIF_AVDTP_STRM_STATE_STREAMING) { + if (app_audio_manager_a2dp_is_active(BT_DEVICE_ID_1)) { + TRACE_AUD_STREAM_I("[STRM_PLAYER][RESTART] resume"); + nRet = bt_sbc_player(PLAYER_OPER_STOP, freq); + nRet = bt_sbc_player(PLAYER_OPER_START, freq); + } else { + if (app_ibrt_ui_is_profile_exchanged()) { + TRACE_AUD_STREAM_I("[STRM_PLAYER][RESTART] force_audio_retrigger"); + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, + BT_STREAM_SBC, BT_DEVICE_ID_1, + MAX_RECORD_NUM); + app_ibrt_if_force_audio_retrigger(); + } + } + } #elif defined(__BT_ONE_BRING_TWO__) - if (btif_me_get_activeCons()>1) - { - enum APP_SYSFREQ_FREQ_T sysfreq; + if (btif_me_get_activeCons() > 1) { + enum APP_SYSFREQ_FREQ_T sysfreq; #ifdef A2DP_CP_ACCEL - sysfreq = APP_SYSFREQ_26M; + sysfreq = APP_SYSFREQ_26M; #else - sysfreq = APP_SYSFREQ_104M; + sysfreq = APP_SYSFREQ_104M; #endif - app_sysfreq_req(APP_SYSFREQ_USER_BT_A2DP, sysfreq); - bt_media_volume_ptr_update_by_mediatype(BT_STREAM_SBC); - app_bt_stream_volumeset(btdevice_volume_p->a2dp_vol); - } + app_sysfreq_req(APP_SYSFREQ_USER_BT_A2DP, sysfreq); + bt_media_volume_ptr_update_by_mediatype(BT_STREAM_SBC); + app_bt_stream_volumeset(btdevice_volume_p->a2dp_vol); + } #endif - break; + break; #ifdef __FACTORY_MODE_SUPPORT__ - case APP_FACTORYMODE_AUDIO_LOOP: - break; + case APP_FACTORYMODE_AUDIO_LOOP: + break; #endif #ifdef MEDIA_PLAYER_SUPPORT - case APP_PLAY_BACK_AUDIO: - break; + case APP_PLAY_BACK_AUDIO: + break; #endif - default: - nRet = -1; - break; - } + default: + nRet = -1; + break; + } - return nRet; + return nRet; } -void app_bt_stream_volumeup(void) -{ +void app_bt_stream_volumeup(void) { #if defined AUDIO_LINEIN - if(app_bt_stream_isrun(APP_PLAY_LINEIN_AUDIO)) - { - stream_linein_volume ++; - if (stream_linein_volume > TGT_VOLUME_LEVEL_15) - stream_linein_volume = TGT_VOLUME_LEVEL_15; - app_bt_stream_volumeset(stream_linein_volume); - TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][UP] set linein volume %d\n", stream_linein_volume); - }else + if (app_bt_stream_isrun(APP_PLAY_LINEIN_AUDIO)) { + stream_linein_volume++; + if (stream_linein_volume > TGT_VOLUME_LEVEL_15) + stream_linein_volume = TGT_VOLUME_LEVEL_15; + app_bt_stream_volumeset(stream_linein_volume); + TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][UP] set linein volume %d\n", + stream_linein_volume); + } else #endif - { - if (app_bt_stream_isrun(APP_BT_STREAM_HFP_PCM)) - { - TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][UP] hfp volume"); + { + if (app_bt_stream_isrun(APP_BT_STREAM_HFP_PCM)) { + TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][UP] hfp volume"); - int8_t updatedVol = btdevice_volume_p->hfp_vol; - updatedVol++; - if (updatedVol > TGT_VOLUME_LEVEL_15) - { - updatedVol = TGT_VOLUME_LEVEL_15; - } - uint32_t lock = nv_record_pre_write_operation(); - btdevice_volume_p->hfp_vol = updatedVol; - nv_record_post_write_operation(lock); - current_btdevice_volume.hfp_vol=updatedVol; - if (updatedVol < TGT_VOLUME_LEVEL_15) - { - app_bt_stream_volumeset(updatedVol); - } - if (btdevice_volume_p->hfp_vol == TGT_VOLUME_LEVEL_15) - { + int8_t updatedVol = btdevice_volume_p->hfp_vol; + updatedVol++; + if (updatedVol > TGT_VOLUME_LEVEL_15) { + updatedVol = TGT_VOLUME_LEVEL_15; + } + uint32_t lock = nv_record_pre_write_operation(); + btdevice_volume_p->hfp_vol = updatedVol; + nv_record_post_write_operation(lock); + current_btdevice_volume.hfp_vol = updatedVol; + if (updatedVol < TGT_VOLUME_LEVEL_15) { + app_bt_stream_volumeset(updatedVol); + } + if (btdevice_volume_p->hfp_vol == TGT_VOLUME_LEVEL_15) { #ifdef MEDIA_PLAYER_SUPPORT - media_PlayAudio(AUD_ID_BT_WARNING,0); + media_PlayAudio(AUD_ID_BT_WARNING, 0); #endif - } + } - } - else if ((app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC)) || - (app_bt_stream_isrun(APP_BT_STREAM_INVALID))) - { - TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][UP] a2dp volume"); - int8_t updatedVol = btdevice_volume_p->a2dp_vol; - updatedVol++; - if (updatedVol > TGT_VOLUME_LEVEL_15) - { - updatedVol = TGT_VOLUME_LEVEL_15; - } - uint32_t lock = nv_record_pre_write_operation(); - btdevice_volume_p->a2dp_vol = updatedVol; - nv_record_post_write_operation(lock); - current_btdevice_volume.a2dp_vol=updatedVol; - if (updatedVol < TGT_VOLUME_LEVEL_15) - { - app_bt_stream_volumeset(updatedVol); - } - if (btdevice_volume_p->a2dp_vol == TGT_VOLUME_LEVEL_15) - { + } else if ((app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC)) || + (app_bt_stream_isrun(APP_BT_STREAM_INVALID))) { + TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][UP] a2dp volume"); + int8_t updatedVol = btdevice_volume_p->a2dp_vol; + updatedVol++; + if (updatedVol > TGT_VOLUME_LEVEL_15) { + updatedVol = TGT_VOLUME_LEVEL_15; + } + uint32_t lock = nv_record_pre_write_operation(); + btdevice_volume_p->a2dp_vol = updatedVol; + nv_record_post_write_operation(lock); + current_btdevice_volume.a2dp_vol = updatedVol; + if (updatedVol < TGT_VOLUME_LEVEL_15) { + app_bt_stream_volumeset(updatedVol); + } + if (btdevice_volume_p->a2dp_vol == TGT_VOLUME_LEVEL_15) { #ifdef MEDIA_PLAYER_SUPPORT - media_PlayAudio(AUD_ID_BT_WARNING,0); + media_PlayAudio(AUD_ID_BT_WARNING, 0); #endif - } - } - - TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][UP] a2dp: %d", btdevice_volume_p->a2dp_vol); - TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][UP] hfp: %d", btdevice_volume_p->hfp_vol); + } } + + TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][UP] a2dp: %d", + btdevice_volume_p->a2dp_vol); + TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][UP] hfp: %d", + btdevice_volume_p->hfp_vol); + } #ifndef FPGA - nv_record_touch_cause_flush(); + nv_record_touch_cause_flush(); #endif } -void app_bt_set_volume(uint16_t type,uint8_t level) -{ - if ((type&APP_BT_STREAM_HFP_PCM) && app_bt_stream_isrun(APP_BT_STREAM_HFP_PCM)) { - TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL] set hfp volume"); - if (level >= TGT_VOLUME_LEVEL_MUTE && level <= TGT_VOLUME_LEVEL_15) - { - uint32_t lock = nv_record_pre_write_operation(); - btdevice_volume_p->hfp_vol = level; - nv_record_post_write_operation(lock); - app_bt_stream_volumeset(btdevice_volume_p->hfp_vol); - } - if (btdevice_volume_p->hfp_vol == TGT_VOLUME_LEVEL_0) - { -#ifdef MEDIA_PLAYER_SUPPORT - media_PlayAudio(AUD_ID_BT_WARNING,0); -#endif - } +void app_bt_set_volume(uint16_t type, uint8_t level) { + if ((type & APP_BT_STREAM_HFP_PCM) && + app_bt_stream_isrun(APP_BT_STREAM_HFP_PCM)) { + TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL] set hfp volume"); + if (level >= TGT_VOLUME_LEVEL_MUTE && level <= TGT_VOLUME_LEVEL_15) { + uint32_t lock = nv_record_pre_write_operation(); + btdevice_volume_p->hfp_vol = level; + nv_record_post_write_operation(lock); + app_bt_stream_volumeset(btdevice_volume_p->hfp_vol); } - if ((type&APP_BT_STREAM_A2DP_SBC) && ((app_bt_stream_isrun(APP_BT_STREAM_INVALID)) || - (app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC)))) { - TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL] set a2dp volume"); - if (level >= TGT_VOLUME_LEVEL_MUTE && level <= TGT_VOLUME_LEVEL_15) - { - uint32_t lock = nv_record_pre_write_operation(); - btdevice_volume_p->a2dp_vol = level; - nv_record_post_write_operation(lock); - app_bt_stream_volumeset(btdevice_volume_p->a2dp_vol); - } - if (btdevice_volume_p->a2dp_vol == TGT_VOLUME_LEVEL_MUTE) - { + if (btdevice_volume_p->hfp_vol == TGT_VOLUME_LEVEL_0) { #ifdef MEDIA_PLAYER_SUPPORT - media_PlayAudio(AUD_ID_BT_WARNING,0); + media_PlayAudio(AUD_ID_BT_WARNING, 0); #endif - } } + } + if ((type & APP_BT_STREAM_A2DP_SBC) && + ((app_bt_stream_isrun(APP_BT_STREAM_INVALID)) || + (app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC)))) { + TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL] set a2dp volume"); + if (level >= TGT_VOLUME_LEVEL_MUTE && level <= TGT_VOLUME_LEVEL_15) { + uint32_t lock = nv_record_pre_write_operation(); + btdevice_volume_p->a2dp_vol = level; + nv_record_post_write_operation(lock); + app_bt_stream_volumeset(btdevice_volume_p->a2dp_vol); + } + if (btdevice_volume_p->a2dp_vol == TGT_VOLUME_LEVEL_MUTE) { +#ifdef MEDIA_PLAYER_SUPPORT + media_PlayAudio(AUD_ID_BT_WARNING, 0); +#endif + } + } - TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL] a2dp: %d", btdevice_volume_p->a2dp_vol); - TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL] hfp: %d", btdevice_volume_p->hfp_vol); + TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL] a2dp: %d", + btdevice_volume_p->a2dp_vol); + TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL] hfp: %d", btdevice_volume_p->hfp_vol); #ifndef FPGA - nv_record_touch_cause_flush(); + nv_record_touch_cause_flush(); #endif } -void app_bt_stream_volumedown(void) -{ +void app_bt_stream_volumedown(void) { #if defined AUDIO_LINEIN - if(app_bt_stream_isrun(APP_PLAY_LINEIN_AUDIO)) - { - stream_linein_volume --; - if (stream_linein_volume < TGT_VOLUME_LEVEL_MUTE) - stream_linein_volume = TGT_VOLUME_LEVEL_MUTE; - app_bt_stream_volumeset(stream_linein_volume); - TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][DONW] set linein volume %d\n", stream_linein_volume); - }else + if (app_bt_stream_isrun(APP_PLAY_LINEIN_AUDIO)) { + stream_linein_volume--; + if (stream_linein_volume < TGT_VOLUME_LEVEL_MUTE) + stream_linein_volume = TGT_VOLUME_LEVEL_MUTE; + app_bt_stream_volumeset(stream_linein_volume); + TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][DONW] set linein volume %d\n", + stream_linein_volume); + } else #endif - { - if (app_bt_stream_isrun(APP_BT_STREAM_HFP_PCM)) { - TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][DONW] set hfp volume"); + { + if (app_bt_stream_isrun(APP_BT_STREAM_HFP_PCM)) { + TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][DONW] set hfp volume"); - int8_t updatedVol = btdevice_volume_p->hfp_vol; - updatedVol--; - if (updatedVol < TGT_VOLUME_LEVEL_0) - { - updatedVol = TGT_VOLUME_LEVEL_0; - } + int8_t updatedVol = btdevice_volume_p->hfp_vol; + updatedVol--; + if (updatedVol < TGT_VOLUME_LEVEL_0) { + updatedVol = TGT_VOLUME_LEVEL_0; + } - uint32_t lock = nv_record_pre_write_operation(); - btdevice_volume_p->hfp_vol = updatedVol; - nv_record_post_write_operation(lock); - current_btdevice_volume.hfp_vol=updatedVol; - app_bt_stream_volumeset(updatedVol); - if (btdevice_volume_p->hfp_vol == TGT_VOLUME_LEVEL_0) - { + uint32_t lock = nv_record_pre_write_operation(); + btdevice_volume_p->hfp_vol = updatedVol; + nv_record_post_write_operation(lock); + current_btdevice_volume.hfp_vol = updatedVol; + app_bt_stream_volumeset(updatedVol); + if (btdevice_volume_p->hfp_vol == TGT_VOLUME_LEVEL_0) { #ifdef MEDIA_PLAYER_SUPPORT - media_PlayAudio(AUD_ID_BT_WARNING,0); + media_PlayAudio(AUD_ID_BT_WARNING, 0); #endif - } - } else if ((app_bt_stream_isrun(APP_BT_STREAM_INVALID)) || - (app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC))) { - TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][DONW] set a2dp volume"); - int8_t updatedVol = btdevice_volume_p->a2dp_vol; - updatedVol--; - if (updatedVol < TGT_VOLUME_LEVEL_MUTE) - { - updatedVol = TGT_VOLUME_LEVEL_MUTE; - } + } + } else if ((app_bt_stream_isrun(APP_BT_STREAM_INVALID)) || + (app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC))) { + TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][DONW] set a2dp volume"); + int8_t updatedVol = btdevice_volume_p->a2dp_vol; + updatedVol--; + if (updatedVol < TGT_VOLUME_LEVEL_MUTE) { + updatedVol = TGT_VOLUME_LEVEL_MUTE; + } - uint32_t lock = nv_record_pre_write_operation(); - btdevice_volume_p->a2dp_vol = updatedVol; - nv_record_post_write_operation(lock); - current_btdevice_volume.a2dp_vol=updatedVol; - app_bt_stream_volumeset(updatedVol); - if (btdevice_volume_p->a2dp_vol == TGT_VOLUME_LEVEL_MUTE) - { + uint32_t lock = nv_record_pre_write_operation(); + btdevice_volume_p->a2dp_vol = updatedVol; + nv_record_post_write_operation(lock); + current_btdevice_volume.a2dp_vol = updatedVol; + app_bt_stream_volumeset(updatedVol); + if (btdevice_volume_p->a2dp_vol == TGT_VOLUME_LEVEL_MUTE) { #ifdef MEDIA_PLAYER_SUPPORT - media_PlayAudio(AUD_ID_BT_WARNING,0); + media_PlayAudio(AUD_ID_BT_WARNING, 0); #endif - } - } - - TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][DONW] a2dp: %d", btdevice_volume_p->a2dp_vol); - TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][DONW] hfp: %d", btdevice_volume_p->hfp_vol); + } } + + TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][DONW] a2dp: %d", + btdevice_volume_p->a2dp_vol); + TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][DONW] hfp: %d", + btdevice_volume_p->hfp_vol); + } #ifndef FPGA - nv_record_touch_cause_flush(); + nv_record_touch_cause_flush(); #endif } -void app_bt_stream_volumeset_handler(int8_t vol) -{ - uint32_t ret; - struct AF_STREAM_CONFIG_T *stream_cfg = NULL; - ret = af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg, false); - if (ret == 0) { - stream_cfg->vol = vol; - af_stream_setup(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, stream_cfg); - } -#if (defined(AUDIO_ANC_FB_MC)||defined(AUDIO_ANC_FB_MC_SCO)) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - ret = af_stream_get_cfg(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &stream_cfg, false); - if (ret == 0) { - stream_cfg->vol = vol; - af_stream_setup(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, stream_cfg); - } +void app_bt_stream_volumeset_handler(int8_t vol) { + uint32_t ret; + struct AF_STREAM_CONFIG_T *stream_cfg = NULL; + ret = af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg, + false); + if (ret == 0) { + stream_cfg->vol = vol; + af_stream_setup(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, stream_cfg); + } +#if (defined(AUDIO_ANC_FB_MC) || defined(AUDIO_ANC_FB_MC_SCO)) && \ + defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) + ret = af_stream_get_cfg(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &stream_cfg, + false); + if (ret == 0) { + stream_cfg->vol = vol; + af_stream_setup(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, stream_cfg); + } #endif } -int app_bt_stream_volumeset(int8_t vol) -{ - TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][SET] vol=%d", vol); +int app_bt_stream_volumeset(int8_t vol) { + TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][SET] vol=%d", vol); - if (vol > TGT_VOLUME_LEVEL_15) - vol = TGT_VOLUME_LEVEL_15; - if (vol < TGT_VOLUME_LEVEL_MUTE) - vol = TGT_VOLUME_LEVEL_MUTE; + if (vol > TGT_VOLUME_LEVEL_15) + vol = TGT_VOLUME_LEVEL_15; + if (vol < TGT_VOLUME_LEVEL_MUTE) + vol = TGT_VOLUME_LEVEL_MUTE; - stream_local_volume = vol; + stream_local_volume = vol; #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - if ((!app_bt_stream_isrun(APP_PLAY_BACK_AUDIO)) && - (audio_prompt_is_allow_update_volume())) + if ((!app_bt_stream_isrun(APP_PLAY_BACK_AUDIO)) && + (audio_prompt_is_allow_update_volume())) #else - if (!app_bt_stream_isrun(APP_PLAY_BACK_AUDIO)) + if (!app_bt_stream_isrun(APP_PLAY_BACK_AUDIO)) #endif - { - app_bt_stream_volumeset_handler(vol); - } - return 0; + { + app_bt_stream_volumeset_handler(vol); + } + return 0; } -int app_bt_stream_local_volume_get(void) -{ - return stream_local_volume; +int app_bt_stream_local_volume_get(void) { return stream_local_volume; } + +uint8_t app_bt_stream_a2dpvolume_get(void) { + // return btdevice_volume_p->a2dp_vol; + return current_btdevice_volume.a2dp_vol; } -uint8_t app_bt_stream_a2dpvolume_get(void) -{ - // return btdevice_volume_p->a2dp_vol; - return current_btdevice_volume.a2dp_vol; +uint8_t app_bt_stream_hfpvolume_get(void) { + // return btdevice_volume_p->hfp_vol; + return current_btdevice_volume.hfp_vol; } -uint8_t app_bt_stream_hfpvolume_get(void) -{ - //return btdevice_volume_p->hfp_vol; - return current_btdevice_volume.hfp_vol; - +void app_bt_stream_a2dpvolume_reset(void) { + btdevice_volume_p->a2dp_vol = NVRAM_ENV_STREAM_VOLUME_A2DP_VOL_DEFAULT; + current_btdevice_volume.a2dp_vol = NVRAM_ENV_STREAM_VOLUME_A2DP_VOL_DEFAULT; } -void app_bt_stream_a2dpvolume_reset(void) -{ - btdevice_volume_p->a2dp_vol = NVRAM_ENV_STREAM_VOLUME_A2DP_VOL_DEFAULT ; - current_btdevice_volume.a2dp_vol=NVRAM_ENV_STREAM_VOLUME_A2DP_VOL_DEFAULT; +void app_bt_stream_hfpvolume_reset(void) { + btdevice_volume_p->hfp_vol = NVRAM_ENV_STREAM_VOLUME_HFP_VOL_DEFAULT; + current_btdevice_volume.hfp_vol = NVRAM_ENV_STREAM_VOLUME_HFP_VOL_DEFAULT; } -void app_bt_stream_hfpvolume_reset(void) -{ - btdevice_volume_p->hfp_vol = NVRAM_ENV_STREAM_VOLUME_HFP_VOL_DEFAULT; - current_btdevice_volume.hfp_vol=NVRAM_ENV_STREAM_VOLUME_HFP_VOL_DEFAULT; -} - -void app_bt_stream_volume_ptr_update(uint8_t *bdAddr) -{ - static struct btdevice_volume stream_volume = {NVRAM_ENV_STREAM_VOLUME_A2DP_VOL_DEFAULT,NVRAM_ENV_STREAM_VOLUME_HFP_VOL_DEFAULT}; +void app_bt_stream_volume_ptr_update(uint8_t *bdAddr) { + static struct btdevice_volume stream_volume = { + NVRAM_ENV_STREAM_VOLUME_A2DP_VOL_DEFAULT, + NVRAM_ENV_STREAM_VOLUME_HFP_VOL_DEFAULT}; #ifndef FPGA - nvrec_btdevicerecord *record = NULL; + nvrec_btdevicerecord *record = NULL; - memset(¤t_btdevice_volume, 0, sizeof(btdevice_volume)); + memset(¤t_btdevice_volume, 0, sizeof(btdevice_volume)); - if (bdAddr && !nv_record_btdevicerecord_find((bt_bdaddr_t*)bdAddr,&record)) - { - btdevice_volume_p = &(record->device_vol); - DUMP8("0x%02x ", bdAddr, BTIF_BD_ADDR_SIZE); - TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][UPDATE] a2dp_vol:%d hfp_vol:%d ptr:%p", btdevice_volume_p->a2dp_vol, btdevice_volume_p->hfp_vol,btdevice_volume_p); - } - else + if (bdAddr && + !nv_record_btdevicerecord_find((bt_bdaddr_t *)bdAddr, &record)) { + btdevice_volume_p = &(record->device_vol); + DUMP8("0x%02x ", bdAddr, BTIF_BD_ADDR_SIZE); + TRACE_AUD_STREAM_I( + "[STRM_PLAYER][VOL][UPDATE] a2dp_vol:%d hfp_vol:%d ptr:%p", + btdevice_volume_p->a2dp_vol, btdevice_volume_p->hfp_vol, + btdevice_volume_p); + } else #endif - { - btdevice_volume_p = &stream_volume; - TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][UPDATE] default"); - if (bdAddr){ - DUMP8("0x%02x ", bdAddr, BTIF_BD_ADDR_SIZE); - } + { + btdevice_volume_p = &stream_volume; + TRACE_AUD_STREAM_I("[STRM_PLAYER][VOL][UPDATE] default"); + if (bdAddr) { + DUMP8("0x%02x ", bdAddr, BTIF_BD_ADDR_SIZE); } - current_btdevice_volume.a2dp_vol=btdevice_volume_p->a2dp_vol; - current_btdevice_volume.hfp_vol=btdevice_volume_p->hfp_vol; - + } + current_btdevice_volume.a2dp_vol = btdevice_volume_p->a2dp_vol; + current_btdevice_volume.hfp_vol = btdevice_volume_p->hfp_vol; } -struct btdevice_volume * app_bt_stream_volume_get_ptr(void) -{ - return btdevice_volume_p; +struct btdevice_volume *app_bt_stream_volume_get_ptr(void) { + return btdevice_volume_p; } -bool app_bt_stream_isrun(uint16_t player) -{ - if ((gStreamplayer & player) == player) - { - return true; - } - else - { - return false; - } +bool app_bt_stream_isrun(uint16_t player) { + if ((gStreamplayer & player) == player) { + return true; + } else { + return false; + } } -int app_bt_stream_closeall() -{ - TRACE_AUD_STREAM_I("[STRM_PLAYER][CLOSEALL]"); +int app_bt_stream_closeall() { + TRACE_AUD_STREAM_I("[STRM_PLAYER][CLOSEALL]"); - bt_sco_player(false, APP_SYSFREQ_32K); - bt_sbc_player(PLAYER_OPER_STOP, APP_SYSFREQ_32K); + bt_sco_player(false, APP_SYSFREQ_32K); + bt_sbc_player(PLAYER_OPER_STOP, APP_SYSFREQ_32K); #ifdef MEDIA_PLAYER_SUPPORT - app_play_audio_onoff(false, 0); + app_play_audio_onoff(false, 0); #endif #ifdef RB_CODEC - app_rbplay_audio_onoff(false, 0); + app_rbplay_audio_onoff(false, 0); #endif #ifdef VOICE_DATAPATH - app_voicepath_stop_audio_stream(); + app_voicepath_stop_audio_stream(); #endif - gStreamplayer = APP_BT_STREAM_INVALID; + gStreamplayer = APP_BT_STREAM_INVALID; - return 0; + return 0; } -void app_bt_stream_copy_track_one_to_two_24bits(int32_t *dst_buf, int32_t *src_buf, uint32_t src_len) -{ - // Copy from tail so that it works even if dst_buf == src_buf - for (int i = (int)(src_len - 1); i >= 0; i--) - { - dst_buf[i*2 + 0] = dst_buf[i*2 + 1] = src_buf[i]; - } +void app_bt_stream_copy_track_one_to_two_24bits(int32_t *dst_buf, + int32_t *src_buf, + uint32_t src_len) { + // Copy from tail so that it works even if dst_buf == src_buf + for (int i = (int)(src_len - 1); i >= 0; i--) { + dst_buf[i * 2 + 0] = dst_buf[i * 2 + 1] = src_buf[i]; + } } -void app_bt_stream_copy_track_one_to_two_16bits(int16_t *dst_buf, int16_t *src_buf, uint32_t src_len) -{ - // Copy from tail so that it works even if dst_buf == src_buf - for (int i = (int)(src_len - 1); i >= 0; i--) - { - dst_buf[i*2 + 0] = dst_buf[i*2 + 1] = src_buf[i]; - } +void app_bt_stream_copy_track_one_to_two_16bits(int16_t *dst_buf, + int16_t *src_buf, + uint32_t src_len) { + // Copy from tail so that it works even if dst_buf == src_buf + for (int i = (int)(src_len - 1); i >= 0; i--) { + dst_buf[i * 2 + 0] = dst_buf[i * 2 + 1] = src_buf[i]; + } } -void app_bt_stream_copy_track_two_to_one_16bits(int16_t *dst_buf, int16_t *src_buf, uint32_t dst_len) -{ - for (uint32_t i = 0; i < dst_len; i++) - { - dst_buf[i] = src_buf[i*2]; - } +void app_bt_stream_copy_track_two_to_one_16bits(int16_t *dst_buf, + int16_t *src_buf, + uint32_t dst_len) { + for (uint32_t i = 0; i < dst_len; i++) { + dst_buf[i] = src_buf[i * 2]; + } } -void app_bt_stream_adaptive_frequency_adjusting(void) -{ -#if 0//(A2DP_DECODER_VER == 2) +void app_bt_stream_adaptive_frequency_adjusting(void) { +#if 0 //(A2DP_DECODER_VER == 2) if (app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC)){ if (!a2dp_audio_sysfreq_boost_running()){ a2dp_audio_sysfreq_boost_start(1); @@ -7647,31 +7794,30 @@ void app_bt_stream_adaptive_frequency_adjusting(void) } #ifdef PLAYBACK_FORCE_48K -static int app_force48k_resample_iter(uint8_t *buf, uint32_t len) -{ - uint8_t codec_type = bt_sbc_player_get_codec_type(); - uint32_t overlay_id = 0; - if(0){ +static int app_force48k_resample_iter(uint8_t *buf, uint32_t len) { + uint8_t codec_type = bt_sbc_player_get_codec_type(); + uint32_t overlay_id = 0; + if (0) { #if defined(A2DP_LHDC_ON) - }else if(codec_type == BTIF_AVDTP_CODEC_TYPE_LHDC){ - overlay_id = APP_OVERLAY_A2DP_LHDC; + } else if (codec_type == BTIF_AVDTP_CODEC_TYPE_LHDC) { + overlay_id = APP_OVERLAY_A2DP_LHDC; #endif #if defined(A2DP_AAC_ON) - }else if(codec_type == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC){ - overlay_id = APP_OVERLAY_A2DP_AAC; + } else if (codec_type == BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC) { + overlay_id = APP_OVERLAY_A2DP_AAC; #endif - }else if(codec_type == BTIF_AVDTP_CODEC_TYPE_SBC){ - overlay_id = APP_OVERLAY_A2DP; - } - a2dp_audio_more_data(overlay_id, buf, len); - return 0; + } else if (codec_type == BTIF_AVDTP_CODEC_TYPE_SBC) { + overlay_id = APP_OVERLAY_A2DP; + } + a2dp_audio_more_data(overlay_id, buf, len); + return 0; } -struct APP_RESAMPLE_T *app_force48k_resample_any_open(enum AUD_CHANNEL_NUM_T chans, - APP_RESAMPLE_ITER_CALLBACK cb, uint32_t iter_len, - float ratio_step) -{ - return app_playback_resample_any_open(chans, cb, iter_len, ratio_step); +struct APP_RESAMPLE_T * +app_force48k_resample_any_open(enum AUD_CHANNEL_NUM_T chans, + APP_RESAMPLE_ITER_CALLBACK cb, uint32_t iter_len, + float ratio_step) { + return app_playback_resample_any_open(chans, cb, iter_len, ratio_step); } #endif @@ -7683,528 +7829,500 @@ struct APP_RESAMPLE_T *app_force48k_resample_any_open(enum AUD_CHANNEL_NUM_T cha #include "resample_coef.h" #endif -static APP_RESAMPLE_BUF_ALLOC_CALLBACK resamp_buf_alloc = app_audio_mempool_get_buff; +static APP_RESAMPLE_BUF_ALLOC_CALLBACK resamp_buf_alloc = + app_audio_mempool_get_buff; -static void memzero_int16(void *dst, uint32_t len) -{ - if (dst) - { - int16_t *dst16 = (int16_t *)dst; - int16_t *dst16_end = dst16 + len / 2; +static void memzero_int16(void *dst, uint32_t len) { + if (dst) { + int16_t *dst16 = (int16_t *)dst; + int16_t *dst16_end = dst16 + len / 2; - while (dst16 < dst16_end) - { - *dst16++ = 0; - } - } - else - { - TRACE_AUD_STREAM_I("WRN: receive null pointer"); + while (dst16 < dst16_end) { + *dst16++ = 0; } + } else { + TRACE_AUD_STREAM_I("WRN: receive null pointer"); + } } -struct APP_RESAMPLE_T *app_resample_open_with_preallocated_buf(enum AUD_STREAM_T stream, const struct RESAMPLE_COEF_T *coef, enum AUD_CHANNEL_NUM_T chans, - APP_RESAMPLE_ITER_CALLBACK cb, uint32_t iter_len, - float ratio_step, uint8_t* buf, uint32_t bufSize) -{ - TRACE_AUD_STREAM_I("[STRM_PLAYER][PROMPT_MIXER][OPEN]"); - struct APP_RESAMPLE_T *resamp; - struct RESAMPLE_CFG_T cfg; - enum RESAMPLE_STATUS_T status; - uint32_t size, resamp_size; +struct APP_RESAMPLE_T *app_resample_open_with_preallocated_buf( + enum AUD_STREAM_T stream, const struct RESAMPLE_COEF_T *coef, + enum AUD_CHANNEL_NUM_T chans, APP_RESAMPLE_ITER_CALLBACK cb, + uint32_t iter_len, float ratio_step, uint8_t *buf, uint32_t bufSize) { + TRACE_AUD_STREAM_I("[STRM_PLAYER][PROMPT_MIXER][OPEN]"); + struct APP_RESAMPLE_T *resamp; + struct RESAMPLE_CFG_T cfg; + enum RESAMPLE_STATUS_T status; + uint32_t size, resamp_size; - resamp_size = audio_resample_ex_get_buffer_size(chans, AUD_BITS_16, coef->phase_coef_num); + resamp_size = audio_resample_ex_get_buffer_size(chans, AUD_BITS_16, + coef->phase_coef_num); - size = sizeof(struct APP_RESAMPLE_T); - size += ALIGN(iter_len, 4); - size += resamp_size; + size = sizeof(struct APP_RESAMPLE_T); + size += ALIGN(iter_len, 4); + size += resamp_size; - ASSERT(size < bufSize, "Pre-allocated buffer size %d is smaller than the needed size %d", - bufSize, size); + ASSERT(size < bufSize, + "Pre-allocated buffer size %d is smaller than the needed size %d", + bufSize, size); - resamp = (struct APP_RESAMPLE_T *)buf; - buf += sizeof(*resamp); - resamp->stream = stream; - resamp->cb = cb; - resamp->iter_buf = buf; - buf += ALIGN(iter_len, 4); - resamp->iter_len = iter_len; - resamp->offset = iter_len; - resamp->ratio_step = ratio_step; + resamp = (struct APP_RESAMPLE_T *)buf; + buf += sizeof(*resamp); + resamp->stream = stream; + resamp->cb = cb; + resamp->iter_buf = buf; + buf += ALIGN(iter_len, 4); + resamp->iter_len = iter_len; + resamp->offset = iter_len; + resamp->ratio_step = ratio_step; - memset(&cfg, 0, sizeof(cfg)); - cfg.chans = chans; - cfg.bits = AUD_BITS_16; - cfg.ratio_step = ratio_step; - cfg.coef = coef; - cfg.buf = buf; - cfg.size = resamp_size; + memset(&cfg, 0, sizeof(cfg)); + cfg.chans = chans; + cfg.bits = AUD_BITS_16; + cfg.ratio_step = ratio_step; + cfg.coef = coef; + cfg.buf = buf; + cfg.size = resamp_size; - status = audio_resample_ex_open(&cfg, (RESAMPLE_ID *)&resamp->id); - ASSERT(status == RESAMPLE_STATUS_OK, "%s: Failed to open resample: %d", __func__, status); + status = audio_resample_ex_open(&cfg, (RESAMPLE_ID *)&resamp->id); + ASSERT(status == RESAMPLE_STATUS_OK, "%s: Failed to open resample: %d", + __func__, status); #ifdef CHIP_BEST1000 - hal_cmu_audio_resample_enable(); + hal_cmu_audio_resample_enable(); #endif - return resamp; + return resamp; } +static struct APP_RESAMPLE_T * +app_resample_open(enum AUD_STREAM_T stream, const struct RESAMPLE_COEF_T *coef, + enum AUD_CHANNEL_NUM_T chans, APP_RESAMPLE_ITER_CALLBACK cb, + uint32_t iter_len, float ratio_step) { + TRACE_AUD_STREAM_I("[STRM_PLAYER][RESAMPLE][OPEN] ratio: %d/1000", + uint32_t(ratio_step * 1000)); + struct APP_RESAMPLE_T *resamp; + struct RESAMPLE_CFG_T cfg; + enum RESAMPLE_STATUS_T status; + uint32_t size, resamp_size; + uint8_t *buf; -static struct APP_RESAMPLE_T *app_resample_open(enum AUD_STREAM_T stream, const struct RESAMPLE_COEF_T *coef, enum AUD_CHANNEL_NUM_T chans, - APP_RESAMPLE_ITER_CALLBACK cb, uint32_t iter_len, - float ratio_step) -{ - TRACE_AUD_STREAM_I("[STRM_PLAYER][RESAMPLE][OPEN] ratio: %d/1000", uint32_t(ratio_step * 1000)); - struct APP_RESAMPLE_T *resamp; - struct RESAMPLE_CFG_T cfg; - enum RESAMPLE_STATUS_T status; - uint32_t size, resamp_size; - uint8_t *buf; + resamp_size = audio_resample_ex_get_buffer_size(chans, AUD_BITS_16, + coef->phase_coef_num); - resamp_size = audio_resample_ex_get_buffer_size(chans, AUD_BITS_16, coef->phase_coef_num); + size = sizeof(struct APP_RESAMPLE_T); + size += ALIGN(iter_len, 4); + size += resamp_size; - size = sizeof(struct APP_RESAMPLE_T); - size += ALIGN(iter_len, 4); - size += resamp_size; + resamp_buf_alloc(&buf, size); - resamp_buf_alloc(&buf, size); + resamp = (struct APP_RESAMPLE_T *)buf; + buf += sizeof(*resamp); + resamp->stream = stream; + resamp->cb = cb; + resamp->iter_buf = buf; + buf += ALIGN(iter_len, 4); + resamp->iter_len = iter_len; + resamp->offset = iter_len; + resamp->ratio_step = ratio_step; - resamp = (struct APP_RESAMPLE_T *)buf; - buf += sizeof(*resamp); - resamp->stream = stream; - resamp->cb = cb; - resamp->iter_buf = buf; - buf += ALIGN(iter_len, 4); - resamp->iter_len = iter_len; - resamp->offset = iter_len; - resamp->ratio_step = ratio_step; + memset(&cfg, 0, sizeof(cfg)); + cfg.chans = chans; + cfg.bits = AUD_BITS_16; + cfg.ratio_step = ratio_step; + cfg.coef = coef; + cfg.buf = buf; + cfg.size = resamp_size; - memset(&cfg, 0, sizeof(cfg)); - cfg.chans = chans; - cfg.bits = AUD_BITS_16; - cfg.ratio_step = ratio_step; - cfg.coef = coef; - cfg.buf = buf; - cfg.size = resamp_size; - - status = audio_resample_ex_open(&cfg, (RESAMPLE_ID *)&resamp->id); - ASSERT(status == RESAMPLE_STATUS_OK, "%s: Failed to open resample: %d", __func__, status); + status = audio_resample_ex_open(&cfg, (RESAMPLE_ID *)&resamp->id); + ASSERT(status == RESAMPLE_STATUS_OK, "%s: Failed to open resample: %d", + __func__, status); #ifdef CHIP_BEST1000 - hal_cmu_audio_resample_enable(); + hal_cmu_audio_resample_enable(); #endif - return resamp; + return resamp; } -static int app_resample_close(struct APP_RESAMPLE_T *resamp) -{ +static int app_resample_close(struct APP_RESAMPLE_T *resamp) { #ifdef CHIP_BEST1000 - hal_cmu_audio_resample_disable(); + hal_cmu_audio_resample_disable(); #endif - if (resamp) - { - audio_resample_ex_close((RESAMPLE_ID *)resamp->id); - } + if (resamp) { + audio_resample_ex_close((RESAMPLE_ID *)resamp->id); + } - return 0; + return 0; } -struct APP_RESAMPLE_T *app_playback_resample_open(enum AUD_SAMPRATE_T sample_rate, enum AUD_CHANNEL_NUM_T chans, - APP_RESAMPLE_ITER_CALLBACK cb, uint32_t iter_len) -{ - const struct RESAMPLE_COEF_T *coef = NULL; +struct APP_RESAMPLE_T * +app_playback_resample_open(enum AUD_SAMPRATE_T sample_rate, + enum AUD_CHANNEL_NUM_T chans, + APP_RESAMPLE_ITER_CALLBACK cb, uint32_t iter_len) { + const struct RESAMPLE_COEF_T *coef = NULL; - if (sample_rate == AUD_SAMPRATE_8000) - { - coef = &resample_coef_8k_to_8p4k; - } - else if (sample_rate == AUD_SAMPRATE_16000) - { - coef = &resample_coef_8k_to_8p4k; - } - else if (sample_rate == AUD_SAMPRATE_32000) - { - coef = &resample_coef_32k_to_50p7k; - } - else if (sample_rate == AUD_SAMPRATE_44100) - { - coef = &resample_coef_44p1k_to_50p7k; - } - else if (sample_rate == AUD_SAMPRATE_48000) - { - coef = &resample_coef_48k_to_50p7k; - } - else - { - ASSERT(false, "%s: Bad sample rate: %u", __func__, sample_rate); - } + if (sample_rate == AUD_SAMPRATE_8000) { + coef = &resample_coef_8k_to_8p4k; + } else if (sample_rate == AUD_SAMPRATE_16000) { + coef = &resample_coef_8k_to_8p4k; + } else if (sample_rate == AUD_SAMPRATE_32000) { + coef = &resample_coef_32k_to_50p7k; + } else if (sample_rate == AUD_SAMPRATE_44100) { + coef = &resample_coef_44p1k_to_50p7k; + } else if (sample_rate == AUD_SAMPRATE_48000) { + coef = &resample_coef_48k_to_50p7k; + } else { + ASSERT(false, "%s: Bad sample rate: %u", __func__, sample_rate); + } - return app_resample_open(AUD_STREAM_PLAYBACK, coef, chans, cb, iter_len, 0); + return app_resample_open(AUD_STREAM_PLAYBACK, coef, chans, cb, iter_len, 0); } #ifdef RESAMPLE_ANY_SAMPLE_RATE -struct APP_RESAMPLE_T *app_playback_resample_any_open(enum AUD_CHANNEL_NUM_T chans, - APP_RESAMPLE_ITER_CALLBACK cb, uint32_t iter_len, - float ratio_step) -{ - const struct RESAMPLE_COEF_T *coef = &resample_coef_any_up256; +struct APP_RESAMPLE_T * +app_playback_resample_any_open(enum AUD_CHANNEL_NUM_T chans, + APP_RESAMPLE_ITER_CALLBACK cb, uint32_t iter_len, + float ratio_step) { + const struct RESAMPLE_COEF_T *coef = &resample_coef_any_up256; - return app_resample_open(AUD_STREAM_PLAYBACK, coef, chans, cb, iter_len, ratio_step); + return app_resample_open(AUD_STREAM_PLAYBACK, coef, chans, cb, iter_len, + ratio_step); } -struct APP_RESAMPLE_T *app_playback_resample_any_open_with_pre_allocated_buffer(enum AUD_CHANNEL_NUM_T chans, - APP_RESAMPLE_ITER_CALLBACK cb, uint32_t iter_len, - float ratio_step, uint8_t* ptrBuf, uint32_t bufSize) -{ - const struct RESAMPLE_COEF_T *coef = &resample_coef_any_up256; +struct APP_RESAMPLE_T *app_playback_resample_any_open_with_pre_allocated_buffer( + enum AUD_CHANNEL_NUM_T chans, APP_RESAMPLE_ITER_CALLBACK cb, + uint32_t iter_len, float ratio_step, uint8_t *ptrBuf, uint32_t bufSize) { + const struct RESAMPLE_COEF_T *coef = &resample_coef_any_up256; - return app_resample_open_with_preallocated_buf( - AUD_STREAM_PLAYBACK, coef, chans, cb, iter_len, ratio_step, ptrBuf, bufSize); + return app_resample_open_with_preallocated_buf(AUD_STREAM_PLAYBACK, coef, + chans, cb, iter_len, + ratio_step, ptrBuf, bufSize); } -struct APP_RESAMPLE_T *app_capture_resample_14k7_to_16k(enum AUD_CHANNEL_NUM_T chans, - APP_RESAMPLE_ITER_CALLBACK cb, uint32_t iter_len, - float ratio_step, uint8_t* ptrBuf, uint32_t bufSize) -{ - const struct RESAMPLE_COEF_T *coef = &resample_coef_44p1k_to_48k; +struct APP_RESAMPLE_T *app_capture_resample_14k7_to_16k( + enum AUD_CHANNEL_NUM_T chans, APP_RESAMPLE_ITER_CALLBACK cb, + uint32_t iter_len, float ratio_step, uint8_t *ptrBuf, uint32_t bufSize) { + const struct RESAMPLE_COEF_T *coef = &resample_coef_44p1k_to_48k; - return app_resample_open_with_preallocated_buf( - AUD_STREAM_PLAYBACK, coef, chans, cb, iter_len, ratio_step, ptrBuf, bufSize); + return app_resample_open_with_preallocated_buf(AUD_STREAM_PLAYBACK, coef, + chans, cb, iter_len, + ratio_step, ptrBuf, bufSize); } #endif -int app_playback_resample_close(struct APP_RESAMPLE_T *resamp) -{ - return app_resample_close(resamp); +int app_playback_resample_close(struct APP_RESAMPLE_T *resamp) { + return app_resample_close(resamp); } -int app_playback_resample_run(struct APP_RESAMPLE_T *resamp, uint8_t *buf, uint32_t len) -{ - uint32_t in_size, out_size; - struct RESAMPLE_IO_BUF_T io; - enum RESAMPLE_STATUS_T status; - int ret; - //uint32_t lock; +int app_playback_resample_run(struct APP_RESAMPLE_T *resamp, uint8_t *buf, + uint32_t len) { + uint32_t in_size, out_size; + struct RESAMPLE_IO_BUF_T io; + enum RESAMPLE_STATUS_T status; + int ret; + // uint32_t lock; - if (resamp == NULL) - { - goto _err_exit; + if (resamp == NULL) { + goto _err_exit; + } + + io.out_cyclic_start = NULL; + io.out_cyclic_end = NULL; + + if (resamp->offset < resamp->iter_len) { + io.in = resamp->iter_buf + resamp->offset; + io.in_size = resamp->iter_len - resamp->offset; + io.out = buf; + io.out_size = len; + + // lock = int_lock(); + status = audio_resample_ex_run((RESAMPLE_ID *)resamp->id, &io, &in_size, + &out_size); + // int_unlock(lock); + if (status != RESAMPLE_STATUS_OUT_FULL && + status != RESAMPLE_STATUS_IN_EMPTY && status != RESAMPLE_STATUS_DONE) { + goto _err_exit; } - io.out_cyclic_start = NULL; - io.out_cyclic_end = NULL; + buf += out_size; + len -= out_size; + resamp->offset += in_size; - if (resamp->offset < resamp->iter_len) - { - io.in = resamp->iter_buf + resamp->offset; - io.in_size = resamp->iter_len - resamp->offset; - io.out = buf; - io.out_size = len; + ASSERT(len == 0 || resamp->offset == resamp->iter_len, + "%s: Bad resample offset: len=%d offset=%u iter_len=%u", __func__, + len, resamp->offset, resamp->iter_len); + } - //lock = int_lock(); - status = audio_resample_ex_run((RESAMPLE_ID *)resamp->id, &io, &in_size, &out_size); - //int_unlock(lock); - if (status != RESAMPLE_STATUS_OUT_FULL && status != RESAMPLE_STATUS_IN_EMPTY && - status != RESAMPLE_STATUS_DONE) - { - goto _err_exit; - } - - buf += out_size; - len -= out_size; - resamp->offset += in_size; - - ASSERT(len == 0 || resamp->offset == resamp->iter_len, - "%s: Bad resample offset: len=%d offset=%u iter_len=%u", - __func__, len, resamp->offset, resamp->iter_len); + while (len) { + ret = resamp->cb(resamp->iter_buf, resamp->iter_len); + if (ret) { + goto _err_exit; } - while (len) - { - ret = resamp->cb(resamp->iter_buf, resamp->iter_len); - if (ret) - { - goto _err_exit; - } + io.in = resamp->iter_buf; + io.in_size = resamp->iter_len; + io.out = buf; + io.out_size = len; - io.in = resamp->iter_buf; - io.in_size = resamp->iter_len; - io.out = buf; - io.out_size = len; - - //lock = int_lock(); - status = audio_resample_ex_run((RESAMPLE_ID *)resamp->id, &io, &in_size, &out_size); - //int_unlock(lock); - if (status != RESAMPLE_STATUS_OUT_FULL && status != RESAMPLE_STATUS_IN_EMPTY && - status != RESAMPLE_STATUS_DONE) - { - goto _err_exit; - } - - ASSERT(out_size <= len, "%s: Bad resample out_size: out_size=%u len=%d", __func__, out_size, len); - ASSERT(in_size <= resamp->iter_len, "%s: Bad resample in_size: in_size=%u iter_len=%u", __func__, in_size, resamp->iter_len); - - buf += out_size; - len -= out_size; - if (in_size != resamp->iter_len) - { - resamp->offset = in_size; - - ASSERT(len == 0, "%s: Bad resample len: len=%d out_size=%u", __func__, len, out_size); - } + // lock = int_lock(); + status = audio_resample_ex_run((RESAMPLE_ID *)resamp->id, &io, &in_size, + &out_size); + // int_unlock(lock); + if (status != RESAMPLE_STATUS_OUT_FULL && + status != RESAMPLE_STATUS_IN_EMPTY && status != RESAMPLE_STATUS_DONE) { + goto _err_exit; } - return 0; + ASSERT(out_size <= len, "%s: Bad resample out_size: out_size=%u len=%d", + __func__, out_size, len); + ASSERT(in_size <= resamp->iter_len, + "%s: Bad resample in_size: in_size=%u iter_len=%u", __func__, + in_size, resamp->iter_len); + + buf += out_size; + len -= out_size; + if (in_size != resamp->iter_len) { + resamp->offset = in_size; + + ASSERT(len == 0, "%s: Bad resample len: len=%d out_size=%u", __func__, + len, out_size); + } + } + + return 0; _err_exit: - if (resamp) - { - app_resample_reset(resamp); - } + if (resamp) { + app_resample_reset(resamp); + } - memzero_int16(buf, len); + memzero_int16(buf, len); - return 1; + return 1; } -struct APP_RESAMPLE_T *app_capture_resample_open(enum AUD_SAMPRATE_T sample_rate, enum AUD_CHANNEL_NUM_T chans, - APP_RESAMPLE_ITER_CALLBACK cb, uint32_t iter_len) -{ - const struct RESAMPLE_COEF_T *coef = NULL; +struct APP_RESAMPLE_T * +app_capture_resample_open(enum AUD_SAMPRATE_T sample_rate, + enum AUD_CHANNEL_NUM_T chans, + APP_RESAMPLE_ITER_CALLBACK cb, uint32_t iter_len) { + const struct RESAMPLE_COEF_T *coef = NULL; - if (sample_rate == AUD_SAMPRATE_8000) - { - coef = &resample_coef_8p4k_to_8k; - } - else if (sample_rate == AUD_SAMPRATE_16000) - { - // Same coef as 8K sample rate - coef = &resample_coef_8p4k_to_8k; - } - else - { - ASSERT(false, "%s: Bad sample rate: %u", __func__, sample_rate); - } - - return app_resample_open(AUD_STREAM_CAPTURE, coef, chans, cb, iter_len, 0); + if (sample_rate == AUD_SAMPRATE_8000) { + coef = &resample_coef_8p4k_to_8k; + } else if (sample_rate == AUD_SAMPRATE_16000) { + // Same coef as 8K sample rate + coef = &resample_coef_8p4k_to_8k; + } else { + ASSERT(false, "%s: Bad sample rate: %u", __func__, sample_rate); + } + return app_resample_open(AUD_STREAM_CAPTURE, coef, chans, cb, iter_len, 0); } #ifdef RESAMPLE_ANY_SAMPLE_RATE -struct APP_RESAMPLE_T *app_capture_resample_any_open(enum AUD_CHANNEL_NUM_T chans, - APP_RESAMPLE_ITER_CALLBACK cb, uint32_t iter_len, - float ratio_step) -{ - const struct RESAMPLE_COEF_T *coef = &resample_coef_any_up256; - return app_resample_open(AUD_STREAM_CAPTURE, coef, chans, cb, iter_len, ratio_step); +struct APP_RESAMPLE_T * +app_capture_resample_any_open(enum AUD_CHANNEL_NUM_T chans, + APP_RESAMPLE_ITER_CALLBACK cb, uint32_t iter_len, + float ratio_step) { + const struct RESAMPLE_COEF_T *coef = &resample_coef_any_up256; + return app_resample_open(AUD_STREAM_CAPTURE, coef, chans, cb, iter_len, + ratio_step); } #endif -int app_capture_resample_close(struct APP_RESAMPLE_T *resamp) -{ - return app_resample_close(resamp); +int app_capture_resample_close(struct APP_RESAMPLE_T *resamp) { + return app_resample_close(resamp); } -int app_capture_resample_run(struct APP_RESAMPLE_T *resamp, uint8_t *buf, uint32_t len) -{ - uint32_t in_size, out_size; - struct RESAMPLE_IO_BUF_T io; - enum RESAMPLE_STATUS_T status; - int ret; +int app_capture_resample_run(struct APP_RESAMPLE_T *resamp, uint8_t *buf, + uint32_t len) { + uint32_t in_size, out_size; + struct RESAMPLE_IO_BUF_T io; + enum RESAMPLE_STATUS_T status; + int ret; - if (resamp == NULL) - { + if (resamp == NULL) { + goto _err_exit; + } + + io.out_cyclic_start = NULL; + io.out_cyclic_end = NULL; + + if (resamp->offset < resamp->iter_len) { + io.in = buf; + io.in_size = len; + io.out = resamp->iter_buf + resamp->offset; + io.out_size = resamp->iter_len - resamp->offset; + + status = audio_resample_ex_run((RESAMPLE_ID *)resamp->id, &io, &in_size, + &out_size); + if (status != RESAMPLE_STATUS_OUT_FULL && + status != RESAMPLE_STATUS_IN_EMPTY && status != RESAMPLE_STATUS_DONE) { + goto _err_exit; + } + + buf += in_size; + len -= in_size; + resamp->offset += out_size; + + ASSERT(len == 0 || resamp->offset == resamp->iter_len, + "%s: Bad resample offset: len=%d offset=%u iter_len=%u", __func__, + len, resamp->offset, resamp->iter_len); + + if (resamp->offset == resamp->iter_len) { + ret = resamp->cb(resamp->iter_buf, resamp->iter_len); + if (ret) { goto _err_exit; + } + } + } + + while (len) { + io.in = buf; + io.in_size = len; + io.out = resamp->iter_buf; + io.out_size = resamp->iter_len; + + status = audio_resample_ex_run((RESAMPLE_ID *)resamp->id, &io, &in_size, + &out_size); + if (status != RESAMPLE_STATUS_OUT_FULL && + status != RESAMPLE_STATUS_IN_EMPTY && status != RESAMPLE_STATUS_DONE) { + goto _err_exit; } - io.out_cyclic_start = NULL; - io.out_cyclic_end = NULL; + ASSERT(in_size <= len, "%s: Bad resample in_size: in_size=%u len=%u", + __func__, in_size, len); + ASSERT(out_size <= resamp->iter_len, + "%s: Bad resample out_size: out_size=%u iter_len=%u", __func__, + out_size, resamp->iter_len); - if (resamp->offset < resamp->iter_len) - { - io.in = buf; - io.in_size = len; - io.out = resamp->iter_buf + resamp->offset; - io.out_size = resamp->iter_len - resamp->offset; - - status = audio_resample_ex_run((RESAMPLE_ID *)resamp->id, &io, &in_size, &out_size); - if (status != RESAMPLE_STATUS_OUT_FULL && status != RESAMPLE_STATUS_IN_EMPTY && - status != RESAMPLE_STATUS_DONE) - { - goto _err_exit; - } - - buf += in_size; - len -= in_size; - resamp->offset += out_size; - - ASSERT(len == 0 || resamp->offset == resamp->iter_len, - "%s: Bad resample offset: len=%d offset=%u iter_len=%u", - __func__, len, resamp->offset, resamp->iter_len); - - if (resamp->offset == resamp->iter_len) - { - ret = resamp->cb(resamp->iter_buf, resamp->iter_len); - if (ret) - { - goto _err_exit; - } - } - } - - while (len) - { - io.in = buf; - io.in_size = len; - io.out = resamp->iter_buf; - io.out_size = resamp->iter_len; - - status = audio_resample_ex_run((RESAMPLE_ID *)resamp->id, &io, &in_size, &out_size); - if (status != RESAMPLE_STATUS_OUT_FULL && status != RESAMPLE_STATUS_IN_EMPTY && - status != RESAMPLE_STATUS_DONE) - { - goto _err_exit; - } - - ASSERT(in_size <= len, "%s: Bad resample in_size: in_size=%u len=%u", __func__, in_size, len); - ASSERT(out_size <= resamp->iter_len, "%s: Bad resample out_size: out_size=%u iter_len=%u", __func__, out_size, resamp->iter_len); - - buf += in_size; - len -= in_size; - if (out_size == resamp->iter_len) - { - ret = resamp->cb(resamp->iter_buf, resamp->iter_len); - if (ret) - { - goto _err_exit; - } - } - else - { - resamp->offset = out_size; - - ASSERT(len == 0, "%s: Bad resample len: len=%u in_size=%u", __func__, len, in_size); - } - } - - return 0; - -_err_exit: - if (resamp) - { - app_resample_reset(resamp); - } - - memzero_int16(buf, len); - - return 1; -} - -void app_resample_reset(struct APP_RESAMPLE_T *resamp) -{ - audio_resample_ex_flush((RESAMPLE_ID *)resamp->id); - resamp->offset = resamp->iter_len; -} - -void app_resample_tune(struct APP_RESAMPLE_T *resamp, float ratio) -{ - float new_step; - - if (resamp == NULL) - { - return; - } - - TRACE_AUD_STREAM_I("%s: stream=%d ratio=%d", __FUNCTION__, resamp->stream, FLOAT_TO_PPB_INT(ratio)); - - if (resamp->stream == AUD_STREAM_PLAYBACK) { - new_step = resamp->ratio_step + resamp->ratio_step * ratio; + buf += in_size; + len -= in_size; + if (out_size == resamp->iter_len) { + ret = resamp->cb(resamp->iter_buf, resamp->iter_len); + if (ret) { + goto _err_exit; + } } else { - new_step = resamp->ratio_step - resamp->ratio_step * ratio; + resamp->offset = out_size; + + ASSERT(len == 0, "%s: Bad resample len: len=%u in_size=%u", __func__, len, + in_size); } - audio_resample_ex_set_ratio_step(resamp->id, new_step); + } + + return 0; + +_err_exit: + if (resamp) { + app_resample_reset(resamp); + } + + memzero_int16(buf, len); + + return 1; } -APP_RESAMPLE_BUF_ALLOC_CALLBACK app_resample_set_buf_alloc_callback(APP_RESAMPLE_BUF_ALLOC_CALLBACK cb) -{ - APP_RESAMPLE_BUF_ALLOC_CALLBACK old_cb; +void app_resample_reset(struct APP_RESAMPLE_T *resamp) { + audio_resample_ex_flush((RESAMPLE_ID *)resamp->id); + resamp->offset = resamp->iter_len; +} - old_cb = resamp_buf_alloc; - resamp_buf_alloc = cb; +void app_resample_tune(struct APP_RESAMPLE_T *resamp, float ratio) { + float new_step; - return old_cb; + if (resamp == NULL) { + return; + } + + TRACE_AUD_STREAM_I("%s: stream=%d ratio=%d", __FUNCTION__, resamp->stream, + FLOAT_TO_PPB_INT(ratio)); + + if (resamp->stream == AUD_STREAM_PLAYBACK) { + new_step = resamp->ratio_step + resamp->ratio_step * ratio; + } else { + new_step = resamp->ratio_step - resamp->ratio_step * ratio; + } + audio_resample_ex_set_ratio_step(resamp->id, new_step); +} + +APP_RESAMPLE_BUF_ALLOC_CALLBACK +app_resample_set_buf_alloc_callback(APP_RESAMPLE_BUF_ALLOC_CALLBACK cb) { + APP_RESAMPLE_BUF_ALLOC_CALLBACK old_cb; + + old_cb = resamp_buf_alloc; + resamp_buf_alloc = cb; + + return old_cb; } #ifdef TX_RX_PCM_MASK #ifdef SCO_DMA_SNAPSHOT -#define MSBC_LEN 60 +#define MSBC_LEN 60 -void store_encode_frame2buff() -{ - if(bt_sco_codec_is_msbc()) - { +void store_encode_frame2buff() { + if (bt_sco_codec_is_msbc()) { uint32_t len; - //processing uplink msbc data. - if(playback_buf_btpcm_copy!=NULL) - { - len=playback_size_btpcm_copy-MSBC_LEN; - memcpy((uint8_t *)(*(volatile uint32_t *)(MIC_BUFF_ADRR_REG)),playback_buf_btpcm_copy,MSBC_LEN); - memcpy(playback_buf_btpcm_copy,playback_buf_btpcm_copy+MSBC_LEN,len); - } - //processing downlink msbc data. - if(capture_buf_btpcm_copy!=NULL) - { - len=capture_size_btpcm_copy-MSBC_LEN; - memcpy(capture_buf_btpcm_copy,capture_buf_btpcm_copy+MSBC_LEN,len); - memcpy(capture_buf_btpcm_copy+len,(uint8_t *)(*(volatile uint32_t *)(RX_BUFF_ADRR)),MSBC_LEN); - } -#if defined(CHIP_BEST2300A) - uint8_t sco_toggle = *(volatile uint8_t *)(RX_BUFF_ADRR+8); - pcm_data_param[sco_toggle].curr_time = *(volatile uint32_t *)(RX_BUFF_ADRR+4); - pcm_data_param[sco_toggle].toggle = sco_toggle; - pcm_data_param[sco_toggle].flag = *(volatile uint8_t *)(RX_BUFF_ADRR+9); - pcm_data_param[sco_toggle].counter = *(volatile uint16_t *)(RX_BUFF_ADRR+10); -#endif + // processing uplink msbc data. + if (playback_buf_btpcm_copy != NULL) { + len = playback_size_btpcm_copy - MSBC_LEN; + memcpy((uint8_t *)(*(volatile uint32_t *)(MIC_BUFF_ADRR_REG)), + playback_buf_btpcm_copy, MSBC_LEN); + memcpy(playback_buf_btpcm_copy, playback_buf_btpcm_copy + MSBC_LEN, len); } - return; + // processing downlink msbc data. + if (capture_buf_btpcm_copy != NULL) { + len = capture_size_btpcm_copy - MSBC_LEN; + memcpy(capture_buf_btpcm_copy, capture_buf_btpcm_copy + MSBC_LEN, len); + memcpy(capture_buf_btpcm_copy + len, + (uint8_t *)(*(volatile uint32_t *)(RX_BUFF_ADRR)), MSBC_LEN); + } +#if defined(CHIP_BEST2300A) + uint8_t sco_toggle = *(volatile uint8_t *)(RX_BUFF_ADRR + 8); + pcm_data_param[sco_toggle].curr_time = + *(volatile uint32_t *)(RX_BUFF_ADRR + 4); + pcm_data_param[sco_toggle].toggle = sco_toggle; + pcm_data_param[sco_toggle].flag = *(volatile uint8_t *)(RX_BUFF_ADRR + 9); + pcm_data_param[sco_toggle].counter = + *(volatile uint16_t *)(RX_BUFF_ADRR + 10); +#endif + } + return; } #else -extern CQueue* get_tx_esco_queue_ptr(); -extern CQueue* get_rx_esco_queue_ptr(); -void store_encode_frame2buff() -{ - CQueue* Tx_esco_queue_temp = NULL; - CQueue* Rx_esco_queue_temp = NULL; - Tx_esco_queue_temp = get_tx_esco_queue_ptr(); - Rx_esco_queue_temp = get_rx_esco_queue_ptr(); - unsigned int len; - len= 60; - int status = 0; - if(bt_sco_codec_is_msbc()) - { - status = DeCQueue(Tx_esco_queue_temp,(uint8_t *)(*(volatile uint32_t *)(MIC_BUFF_ADRR_REG)),len); - if(status){ - //TRACE_AUD_STREAM_I("TX DeC Fail"); - } - status =EnCQueue(Rx_esco_queue_temp, (uint8_t *)(*(volatile uint32_t *)(RX_BUFF_ADRR)), len); - if(status){ - //TRACE_AUD_STREAM_I("RX EnC Fail"); - } +extern CQueue *get_tx_esco_queue_ptr(); +extern CQueue *get_rx_esco_queue_ptr(); +void store_encode_frame2buff() { + CQueue *Tx_esco_queue_temp = NULL; + CQueue *Rx_esco_queue_temp = NULL; + Tx_esco_queue_temp = get_tx_esco_queue_ptr(); + Rx_esco_queue_temp = get_rx_esco_queue_ptr(); + unsigned int len; + len = 60; + int status = 0; + if (bt_sco_codec_is_msbc()) { + status = + DeCQueue(Tx_esco_queue_temp, + (uint8_t *)(*(volatile uint32_t *)(MIC_BUFF_ADRR_REG)), len); + if (status) { + // TRACE_AUD_STREAM_I("TX DeC Fail"); } - + status = EnCQueue(Rx_esco_queue_temp, + (uint8_t *)(*(volatile uint32_t *)(RX_BUFF_ADRR)), len); + if (status) { + // TRACE_AUD_STREAM_I("RX EnC Fail"); + } + } } #endif #endif -int app_bt_stream_init(void) -{ - app_bt_stream_trigger_checker_init(); - return 0; +int app_bt_stream_init(void) { + app_bt_stream_trigger_checker_init(); + return 0; } - diff --git a/services/bt_app/app_btgatt.cpp b/services/bt_app/app_btgatt.cpp index c00e7a1..5da76f6 100644 --- a/services/bt_app/app_btgatt.cpp +++ b/services/bt_app/app_btgatt.cpp @@ -14,22 +14,20 @@ * ****************************************************************************/ #ifdef __GATT_OVER_BR_EDR__ -#include "hal_trace.h" -#include "plat_types.h" #include "app_btgatt.h" #include "btgatt_api.h" +#include "hal_trace.h" +#include "plat_types.h" -void app_btgatt_addsdp(uint16_t pServiceUUID, uint16_t startHandle, uint16_t endHandle) -{ - TRACE(1, "%s", __func__); - btif_btgatt_addsdp(pServiceUUID, startHandle, endHandle); +void app_btgatt_addsdp(uint16_t pServiceUUID, uint16_t startHandle, + uint16_t endHandle) { + TRACE(1, "%s", __func__); + btif_btgatt_addsdp(pServiceUUID, startHandle, endHandle); } -void app_btgatt_init(void) -{ - TRACE(1, "%s", __func__); - btif_btgatt_init(); +void app_btgatt_init(void) { + TRACE(1, "%s", __func__); + btif_btgatt_init(); } #endif - diff --git a/services/bt_app/app_btmap_sms.cpp b/services/bt_app/app_btmap_sms.cpp index 8a669ae..51f3574 100644 --- a/services/bt_app/app_btmap_sms.cpp +++ b/services/bt_app/app_btmap_sms.cpp @@ -13,39 +13,39 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "cmsis_os.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_trace.h" -#include "hal_cmu.h" -#include "hal_chipid.h" #include "analog.h" #include "app_audio.h" #include "app_battery.h" #include "app_status_ind.h" +#include "audioflinger.h" #include "bluetooth.h" +#include "cmsis_os.h" +#include "hal_chipid.h" +#include "hal_cmu.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "lockcqueue.h" #include "nvrecord.h" -#include "nvrecord_env.h" #include "nvrecord_dev.h" +#include "nvrecord_env.h" +#include #if defined(NEW_NV_RECORD_ENABLED) #include "nvrecord_bt.h" #endif -#include "hfp_api.h" -#include "besbt.h" -#include "cqueue.h" -#include "btapp.h" #include "app_bt.h" -#include "apps.h" -#include "resources.h" -#include "app_bt_media_manager.h" -#include "bt_if.h" -#include "app_hfp.h" -#include "app_fp_rfcomm.h" -#include "os_api.h" #include "app_bt_func.h" +#include "app_bt_media_manager.h" +#include "app_fp_rfcomm.h" +#include "app_hfp.h" +#include "apps.h" +#include "besbt.h" +#include "bt_if.h" +#include "btapp.h" +#include "cqueue.h" +#include "hfp_api.h" +#include "os_api.h" +#include "resources.h" #ifdef BT_USB_AUDIO_DUAL_MODE #include "btusb_audio.h" #endif @@ -64,179 +64,167 @@ #endif #if defined(IBRT) -#include "app_ibrt_if.h" -#include "app_tws_ibrt_cmd_sync_hfp_status.h" #include "app_ibrt_hf.h" +#include "app_ibrt_if.h" #include "app_tws_ibrt.h" +#include "app_tws_ibrt_cmd_sync_hfp_status.h" #endif #if defined(__BTMAP_ENABLE__) -#include "obex_api.h" -#include "map_api.h" #include "app_btmap_sms.h" +#include "map_api.h" +#include "obex_api.h" extern struct BT_DEVICE_T app_bt_device; struct SMS_MSG_T app_sms_msg; -#define CHACK_BTMAP_STATE_STAYING_MS 2000 +#define CHACK_BTMAP_STATE_STAYING_MS 2000 osTimerId app_btmap_state_check_handling_timer_id = NULL; static int app_btmap_state_check_handling_handler(void const *param); -osTimerDef (APP_BTMAP_STATE_CHECK_HANDLING_TIMER, (void (*)(void const *))app_btmap_state_check_handling_handler); - +osTimerDef(APP_BTMAP_STATE_CHECK_HANDLING_TIMER, + (void (*)(void const *))app_btmap_state_check_handling_handler); static int btmap_sms_session_event_handler(btif_map_session_handle_t handle, - btif_map_session_event_t event, btif_map_session_cb_param_t *param) -{ - TRACE(1,"%s", __func__); - btif_map_session_function_param_t func_param; - switch (event) { - case BTIF_MAP_SESSION_EVENT_OPEN: - func_param.p.SetFolder.folder[0] = "root"; - func_param.p.SetFolder.folder[1] = "telecom"; - func_param.p.SetFolder.folder[2] = "msg"; - func_param.p.SetFolder.folder[3] = NULL; - func_param.p.SetFolder.up_level = 0; - btif_map_set_folder(handle, &func_param); - break; - case BTIF_MAP_SESSION_EVENT_CLOSE: - break; - default: - break; - } - return 0; + btif_map_session_event_t event, + btif_map_session_cb_param_t *param) { + TRACE(1, "%s", __func__); + btif_map_session_function_param_t func_param; + switch (event) { + case BTIF_MAP_SESSION_EVENT_OPEN: + func_param.p.SetFolder.folder[0] = "root"; + func_param.p.SetFolder.folder[1] = "telecom"; + func_param.p.SetFolder.folder[2] = "msg"; + func_param.p.SetFolder.folder[3] = NULL; + func_param.p.SetFolder.up_level = 0; + btif_map_set_folder(handle, &func_param); + break; + case BTIF_MAP_SESSION_EVENT_CLOSE: + break; + default: + break; + } + return 0; } -void app_btmap_connected_callback(void* param, void* map_session) -{ - TRACE(1,"%s", __func__); +void app_btmap_connected_callback(void *param, void *map_session) { + TRACE(1, "%s", __func__); #if defined(IBRT) - app_tws_ibrt_profile_callback(BTIF_APP_MAP_PROFILE_ID,(void *)param,(void *)map_session); + app_tws_ibrt_profile_callback(BTIF_APP_MAP_PROFILE_ID, (void *)param, + (void *)map_session); #endif } -void app_btmap_sms_init(void) -{ - TRACE(1,"%s", __func__); - int i = 0; - btif_map_initialize(); - btif_map_callback_register(app_btmap_connected_callback); - // only map mas client supported now - for (i = 0; i < BT_DEVICE_NUM; ++i) { - app_bt_device.map_session_handle[i] = btif_map_create_session(); - } +void app_btmap_sms_init(void) { + TRACE(1, "%s", __func__); + int i = 0; + btif_map_initialize(); + btif_map_callback_register(app_btmap_connected_callback); + // only map mas client supported now + for (i = 0; i < BT_DEVICE_NUM; ++i) { + app_bt_device.map_session_handle[i] = btif_map_create_session(); + } } -void app_btmap_sms_open(BT_DEVICE_ID_T id, bt_bdaddr_t *remote) -{ - TRACE(1,"%s", __func__); - btif_map_session_config_t config; - btif_map_session_handle_t handle = NULL; - handle = app_bt_device.map_session_handle[id]; +void app_btmap_sms_open(BT_DEVICE_ID_T id, bt_bdaddr_t *remote) { + TRACE(1, "%s", __func__); + btif_map_session_config_t config; + btif_map_session_handle_t handle = NULL; + handle = app_bt_device.map_session_handle[id]; - if (handle == NULL) { - TRACE(2,"%s:handle is NULL, id=%d", __func__, id); - return; - } + if (handle == NULL) { + TRACE(2, "%s:handle is NULL, id=%d", __func__, id); + return; + } - TRACE(2,"btmap_sms_open:id=%d,remote=0x%p", id, remote); - DUMP8("0x%02x-", remote, 6); + TRACE(2, "btmap_sms_open:id=%d,remote=0x%p", id, remote); + DUMP8("0x%02x-", remote, 6); - config.type = BTIF_MAP_SESSION_TYPE_MAS; - config.obex_role = BTIF_OBEX_SESSION_ROLE_CLIENT; - btif_map_session_open(handle, remote, &config, btmap_sms_session_event_handler); + config.type = BTIF_MAP_SESSION_TYPE_MAS; + config.obex_role = BTIF_OBEX_SESSION_ROLE_CLIENT; + btif_map_session_open(handle, remote, &config, + btmap_sms_session_event_handler); } -void app_btmap_sms_close(BT_DEVICE_ID_T id) -{ - TRACE(1,"%s", __func__); - btif_map_session_handle_t handle = NULL; - handle = app_bt_device.map_session_handle[id]; +void app_btmap_sms_close(BT_DEVICE_ID_T id) { + TRACE(1, "%s", __func__); + btif_map_session_handle_t handle = NULL; + handle = app_bt_device.map_session_handle[id]; - if (handle == NULL) { - TRACE(2,"%s:handle is NULL, id=%d", __func__, id); - return; - } + if (handle == NULL) { + TRACE(2, "%s:handle is NULL, id=%d", __func__, id); + return; + } - btif_map_session_close(handle); + btif_map_session_close(handle); } -void app_btmap_sms_send(BT_DEVICE_ID_T id, char* telNum, char* msg) -{ - btif_map_session_handle_t handle = NULL; - handle = app_bt_device.map_session_handle[id]; +void app_btmap_sms_send(BT_DEVICE_ID_T id, char *telNum, char *msg) { + btif_map_session_handle_t handle = NULL; + handle = app_bt_device.map_session_handle[id]; - if (handle == NULL) { - TRACE(2,"%s:handle is NULL, id=%d", __func__, id); - return; - } + if (handle == NULL) { + TRACE(2, "%s:handle is NULL, id=%d", __func__, id); + return; + } - btif_map_send_sms(handle, telNum, msg); + btif_map_send_sms(handle, telNum, msg); } -bool app_btmap_check_is_connected(BT_DEVICE_ID_T id) -{ - TRACE(1,"%s", __func__); - btif_map_session_handle_t handle = NULL; - handle = app_bt_device.map_session_handle[id]; +bool app_btmap_check_is_connected(BT_DEVICE_ID_T id) { + TRACE(1, "%s", __func__); + btif_map_session_handle_t handle = NULL; + handle = app_bt_device.map_session_handle[id]; - return btif_map_check_is_connected(handle); + return btif_map_check_is_connected(handle); } -bool app_btmap_check_is_idle(BT_DEVICE_ID_T id) -{ - TRACE(1,"%s", __func__); - btif_map_session_handle_t handle = NULL; - handle = app_bt_device.map_session_handle[id]; +bool app_btmap_check_is_idle(BT_DEVICE_ID_T id) { + TRACE(1, "%s", __func__); + btif_map_session_handle_t handle = NULL; + handle = app_bt_device.map_session_handle[id]; - return btif_map_check_is_idle(handle); + return btif_map_check_is_idle(handle); } +void app_btmap_sms_save(BT_DEVICE_ID_T id, char *telNum, char *msg) { + TRACE(1, "%s", __func__); + app_sms_msg.telNum = telNum; + app_sms_msg.msg = msg; + app_sms_msg.telNumLen = strlen(telNum); + app_sms_msg.msgLen = strlen(msg); -void app_btmap_sms_save(BT_DEVICE_ID_T id, char* telNum, char* msg) -{ - TRACE(1,"%s", __func__); - app_sms_msg.telNum = telNum; - app_sms_msg.msg = msg; - app_sms_msg.telNumLen = strlen(telNum); - app_sms_msg.msgLen = strlen(msg); - - if (NULL == app_btmap_state_check_handling_timer_id) - { - app_btmap_state_check_handling_timer_id = - osTimerCreate(osTimer(APP_BTMAP_STATE_CHECK_HANDLING_TIMER), osTimerOnce, NULL); - } + if (NULL == app_btmap_state_check_handling_timer_id) { + app_btmap_state_check_handling_timer_id = osTimerCreate( + osTimer(APP_BTMAP_STATE_CHECK_HANDLING_TIMER), osTimerOnce, NULL); + } - osTimerStart(app_btmap_state_check_handling_timer_id, CHACK_BTMAP_STATE_STAYING_MS); + osTimerStart(app_btmap_state_check_handling_timer_id, + CHACK_BTMAP_STATE_STAYING_MS); } -void app_btmap_sms_resend(void) -{ - TRACE(1,"%s", __func__); +void app_btmap_sms_resend(void) { + TRACE(1, "%s", __func__); - app_btmap_sms_send(BT_DEVICE_ID_1, app_sms_msg.telNum, app_sms_msg.msg); - memset((void *)app_sms_msg.telNum, 0, app_sms_msg.telNumLen); - memset((void *)app_sms_msg.msg, 0, app_sms_msg.msgLen); + app_btmap_sms_send(BT_DEVICE_ID_1, app_sms_msg.telNum, app_sms_msg.msg); + memset((void *)app_sms_msg.telNum, 0, app_sms_msg.telNumLen); + memset((void *)app_sms_msg.msg, 0, app_sms_msg.msgLen); } static uint8_t resendTime = 0; -static int app_btmap_state_check_handling_handler(void const *param) -{ - TRACE(1,"%s", __func__); - resendTime++; - if(resendTime >= 6) - { - resendTime = 0; - return -1; - } +static int app_btmap_state_check_handling_handler(void const *param) { + TRACE(1, "%s", __func__); + resendTime++; + if (resendTime >= 6) { + resendTime = 0; + return -1; + } - if(true == app_btmap_check_is_connected(BT_DEVICE_ID_1)) - { - app_btmap_sms_resend(); - } - else - { - osTimerStart(app_btmap_state_check_handling_timer_id, CHACK_BTMAP_STATE_STAYING_MS); - } - return 0; + if (true == app_btmap_check_is_connected(BT_DEVICE_ID_1)) { + app_btmap_sms_resend(); + } else { + osTimerStart(app_btmap_state_check_handling_timer_id, + CHACK_BTMAP_STATE_STAYING_MS); + } + return 0; } #endif /* __BTMAP_ENABLE__ */ diff --git a/services/bt_app/app_dip.cpp b/services/bt_app/app_dip.cpp index 7340f1d..034b042 100644 --- a/services/bt_app/app_dip.cpp +++ b/services/bt_app/app_dip.cpp @@ -17,25 +17,25 @@ #ifdef BTIF_DIP_DEVICE -#include -#include "cmsis_os.h" -#include "hal_trace.h" -#include "dip_api.h" -#include "plat_types.h" #include "app_bt.h" #include "app_dip.h" +#include "cmsis_os.h" +#include "dip_api.h" +#include "hal_trace.h" #include "nvrecord_bt.h" +#include "plat_types.h" +#include #if defined(ENHANCED_STACK) -#include "sdp_api.h" #include "me_api.h" +#include "sdp_api.h" #endif #if defined(IBRT) -#include "app_tws_ibrt_cmd_handler.h" -#include "app_tws_ctrl_thread.h" -#include "app_ibrt_peripheral_manager.h" #include "app_ibrt_if.h" +#include "app_ibrt_peripheral_manager.h" +#include "app_tws_ctrl_thread.h" +#include "app_tws_ibrt_cmd_handler.h" #include "app_tws_if.h" #endif @@ -49,94 +49,85 @@ void app_dip_sync_dip_info(void); -static void app_dip_callback(bt_bdaddr_t *_addr, bool ios_flag) -{ - btif_remote_device_t *p_remote_dev = btif_me_get_remote_device_by_bdaddr(_addr); +static void app_dip_callback(bt_bdaddr_t *_addr, bool ios_flag) { + btif_remote_device_t *p_remote_dev = + btif_me_get_remote_device_by_bdaddr(_addr); - TRACE(2,"%s dev %p addr :", __func__, p_remote_dev); - DUMP8("%x ", _addr->address, 6); + TRACE(2, "%s dev %p addr :", __func__, p_remote_dev); + DUMP8("%x ", _addr->address, 6); #if defined(IBRT) - if (TWS_LINK == app_tws_ibrt_get_remote_link_type(p_remote_dev)) - { - TRACE(1,"%s connect type is TWS", __func__); - return; - } + if (TWS_LINK == app_tws_ibrt_get_remote_link_type(p_remote_dev)) { + TRACE(1, "%s connect type is TWS", __func__); + return; + } - app_dip_sync_dip_info(); + app_dip_sync_dip_info(); #endif #if defined(__AI_VOICE__) || defined(BISTO_ENABLED) - app_ai_if_mobile_connect_handle(_addr); + app_ai_if_mobile_connect_handle(_addr); #endif } #if defined(IBRT) -void app_dip_sync_info_prepare_handler(uint8_t *buf, uint16_t *length) -{ - uint32_t offset = 0; - ibrt_ctrl_t *p_g_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - bt_bdaddr_t *mobile_addr = &p_g_ibrt_ctrl->mobile_addr; - uint16_t vend_id = 0; - uint16_t vend_id_source = 0; +void app_dip_sync_info_prepare_handler(uint8_t *buf, uint16_t *length) { + uint32_t offset = 0; + ibrt_ctrl_t *p_g_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + bt_bdaddr_t *mobile_addr = &p_g_ibrt_ctrl->mobile_addr; + uint16_t vend_id = 0; + uint16_t vend_id_source = 0; - btif_dip_get_record_vend_id_and_source(mobile_addr, &vend_id, &vend_id_source); - memcpy(buf, mobile_addr->address, 6); - offset += 6; - memcpy(buf+offset, (uint8_t *)&vend_id, 2); - offset += 2; - memcpy(buf+offset, (uint8_t *)&vend_id_source, 2); - offset += 2; + btif_dip_get_record_vend_id_and_source(mobile_addr, &vend_id, + &vend_id_source); + memcpy(buf, mobile_addr->address, 6); + offset += 6; + memcpy(buf + offset, (uint8_t *)&vend_id, 2); + offset += 2; + memcpy(buf + offset, (uint8_t *)&vend_id_source, 2); + offset += 2; - *length = offset; + *length = offset; } -void app_dip_sync_info_received_handler(uint8_t *buf, uint16_t length) -{ - bt_bdaddr_t mobile_addr; - uint16_t vend_id = 0; - uint16_t vend_id_source = 0; - uint32_t offset = 0; - nvrec_btdevicerecord *record = NULL; +void app_dip_sync_info_received_handler(uint8_t *buf, uint16_t length) { + bt_bdaddr_t mobile_addr; + uint16_t vend_id = 0; + uint16_t vend_id_source = 0; + uint32_t offset = 0; + nvrec_btdevicerecord *record = NULL; - memcpy(mobile_addr.address, buf, 6); - offset += 6; - memcpy((uint8_t *)&vend_id, buf+offset, 2); - offset += 2; - memcpy((uint8_t *)&vend_id_source, buf+offset, 2); - offset += 2; - TRACE(2, "%s vend_id 0x%x vend_id_source 0x%x addr:", __func__, vend_id, vend_id_source); - DUMP8("0x%x ", mobile_addr.address, 6); + memcpy(mobile_addr.address, buf, 6); + offset += 6; + memcpy((uint8_t *)&vend_id, buf + offset, 2); + offset += 2; + memcpy((uint8_t *)&vend_id_source, buf + offset, 2); + offset += 2; + TRACE(2, "%s vend_id 0x%x vend_id_source 0x%x addr:", __func__, vend_id, + vend_id_source); + DUMP8("0x%x ", mobile_addr.address, 6); - if (vend_id && !nv_record_btdevicerecord_find(&mobile_addr, &record)) - { - nv_record_btdevicerecord_set_vend_id_and_source(record, vend_id, vend_id_source); - } + if (vend_id && !nv_record_btdevicerecord_find(&mobile_addr, &record)) { + nv_record_btdevicerecord_set_vend_id_and_source(record, vend_id, + vend_id_source); + } } -void app_dip_sync_init(void) -{ - TWS_SYNC_USER_T user_app_dip_t = { - app_dip_sync_info_prepare_handler, - app_dip_sync_info_received_handler, - NULL, - NULL, - NULL, - }; +void app_dip_sync_init(void) { + TWS_SYNC_USER_T user_app_dip_t = { + app_dip_sync_info_prepare_handler, + app_dip_sync_info_received_handler, + NULL, + NULL, + NULL, + }; - app_tws_if_register_sync_user(TWS_SYNC_USER_DIP, &user_app_dip_t); + app_tws_if_register_sync_user(TWS_SYNC_USER_DIP, &user_app_dip_t); } -void app_dip_sync_dip_info(void) -{ - app_tws_if_sync_info(TWS_SYNC_USER_DIP); -} +void app_dip_sync_dip_info(void) { app_tws_if_sync_info(TWS_SYNC_USER_DIP); } #endif -void app_dip_init(void) -{ - btif_dip_init(app_dip_callback); -} +void app_dip_init(void) { btif_dip_init(app_dip_callback); } #endif - diff --git a/services/bt_app/app_fp_rfcomm.cpp b/services/bt_app/app_fp_rfcomm.cpp index 63b20e0..7dc1124 100644 --- a/services/bt_app/app_fp_rfcomm.cpp +++ b/services/bt_app/app_fp_rfcomm.cpp @@ -1,18 +1,18 @@ -#include -#include -#include +#include "app_fp_rfcomm.h" +#include "app_bt.h" +#include "app_bt_func.h" +#include "app_rfcomm_mgr.h" +#include "app_spp.h" +#include "bt_if.h" #include "cmsis.h" #include "cmsis_os.h" #include "hal_trace.h" #include "os_api.h" -#include "bt_if.h" -#include "app_bt.h" -#include "app_spp.h" -#include "spp_api.h" #include "sdp_api.h" -#include "app_bt_func.h" -#include "app_rfcomm_mgr.h" -#include "app_fp_rfcomm.h" +#include "spp_api.h" +#include +#include +#include #ifdef IBRT #include "app_tws_ibrt.h" #include "app_tws_if.h" @@ -21,111 +21,107 @@ osMutexDef(fp_rfcomm_mutex); osMutexDef(fp_rfcomm_credit_mutex); - #define FP_RFCOMM_TX_PKT_CNT 6 /* 128 bit UUID in Big Endian df21fe2c-2515-4fdb-8886-f12c4d67927c */ static const uint8_t FP_RFCOMM_UUID_128[16] = { - 0x7C, 0x92, 0x67, 0x4D, 0x2C, 0xF1, 0x86, 0x88, 0xDB, 0x4F, 0x15, 0x25, 0x2C, 0xFE, 0x21, 0xDF}; + 0x7C, 0x92, 0x67, 0x4D, 0x2C, 0xF1, 0x86, 0x88, + 0xDB, 0x4F, 0x15, 0x25, 0x2C, 0xFE, 0x21, 0xDF}; -typedef struct -{ - uint8_t isConnected; - int8_t serviceIndex; - uint8_t isRfcommInitialized; +typedef struct { + uint8_t isConnected; + int8_t serviceIndex; + uint8_t isRfcommInitialized; } FpRFcommServiceEnv_t; -typedef union -{ - struct - { - uint8_t isCompanionAppInstalled : 1; - uint8_t isSilentModeSupported : 1; - uint8_t reserve : 6; - } env; - uint8_t content; +typedef union { + struct { + uint8_t isCompanionAppInstalled : 1; + uint8_t isSilentModeSupported : 1; + uint8_t reserve : 6; + } env; + uint8_t content; } FpCapabilitiesEnv_t; -typedef struct -{ - uint8_t isRightRinging : 1; - uint8_t isLeftRinging : 1; - uint8_t reserve : 6; +typedef struct { + uint8_t isRightRinging : 1; + uint8_t isLeftRinging : 1; + uint8_t reserve : 6; } FpRingStatus_t; static FpRFcommServiceEnv_t fp_rfcomm_service = {false, -1, false}; static FpCapabilitiesEnv_t fp_capabilities = {false, false, 0}; -static __attribute__((unused)) FpRingStatus_t fp_ring_status = {false, false, 0}; +static __attribute__((unused)) +FpRingStatus_t fp_ring_status = {false, false, 0}; -btif_sdp_record_t* fpSppSdpRecord; +btif_sdp_record_t *fpSppSdpRecord; -extern "C" void app_gfps_get_battery_levels(uint8_t *pCount, uint8_t *pBatteryLevel); +extern "C" void app_gfps_get_battery_levels(uint8_t *pCount, + uint8_t *pBatteryLevel); extern "C" uint8_t *appm_get_current_ble_addr(void); -static int fp_rfcomm_data_received(void *pDev, uint8_t process, uint8_t *pData, uint16_t dataLen); +static int fp_rfcomm_data_received(void *pDev, uint8_t process, uint8_t *pData, + uint16_t dataLen); static void app_fp_msg_send_active_components_rsp(void); static void app_fp_msg_send_message_ack(uint8_t msgGroup, uint8_t msgCode); -static void app_fp_msg_send_message_nak(uint8_t reason, uint8_t msgGroup, uint8_t msgCode); -static void fp_rfcomm_data_handler(uint8_t* ptr, uint16_t len); -// update this value if the maximum possible tx data size is bigger than current value +static void app_fp_msg_send_message_nak(uint8_t reason, uint8_t msgGroup, + uint8_t msgCode); +static void fp_rfcomm_data_handler(uint8_t *ptr, uint16_t len); +// update this value if the maximum possible tx data size is bigger than current +// value #define FP_RFCOMM_TX_BUF_CHUNK_SIZE 64 #define FP_RFCOMM_TX_BUF_CHUNK_CNT FP_RFCOMM_TX_PKT_CNT -#define FP_RFCOMM_TX_BUF_SIZE (FP_RFCOMM_TX_BUF_CHUNK_CNT * FP_RFCOMM_TX_BUF_CHUNK_SIZE) +#define FP_RFCOMM_TX_BUF_SIZE \ + (FP_RFCOMM_TX_BUF_CHUNK_CNT * FP_RFCOMM_TX_BUF_CHUNK_SIZE) static uint32_t fp_rfcomm_tx_buf_next_allocated_chunk = 0; -static uint32_t fp_rfcomm_tx_buf_allocated_chunk_cnt = 0; -static uint8_t fp_rfcomm_tx_buf[FP_RFCOMM_TX_BUF_CHUNK_CNT][FP_RFCOMM_TX_BUF_CHUNK_SIZE]; +static uint32_t fp_rfcomm_tx_buf_allocated_chunk_cnt = 0; +static uint8_t fp_rfcomm_tx_buf[FP_RFCOMM_TX_BUF_CHUNK_CNT] + [FP_RFCOMM_TX_BUF_CHUNK_SIZE]; -static uint8_t *fp_rfcomm_tx_buf_addr(uint32_t chunk) -{ - return fp_rfcomm_tx_buf[chunk]; +static uint8_t *fp_rfcomm_tx_buf_addr(uint32_t chunk) { + return fp_rfcomm_tx_buf[chunk]; } -static int32_t fp_rfcomm_alloc_tx_chunk(void) -{ - uint32_t lock = int_lock_global(); - - if (fp_rfcomm_tx_buf_allocated_chunk_cnt >= FP_RFCOMM_TX_BUF_CHUNK_CNT) - { - int_unlock_global(lock); - return -1; - } - - uint32_t returnedChunk = fp_rfcomm_tx_buf_next_allocated_chunk; - - fp_rfcomm_tx_buf_allocated_chunk_cnt++; - fp_rfcomm_tx_buf_next_allocated_chunk++; - if (FP_RFCOMM_TX_BUF_CHUNK_CNT == fp_rfcomm_tx_buf_next_allocated_chunk) - { - fp_rfcomm_tx_buf_next_allocated_chunk = 0; - } +static int32_t fp_rfcomm_alloc_tx_chunk(void) { + uint32_t lock = int_lock_global(); + if (fp_rfcomm_tx_buf_allocated_chunk_cnt >= FP_RFCOMM_TX_BUF_CHUNK_CNT) { int_unlock_global(lock); - return returnedChunk; -} + return -1; + } -static bool fp_rfcomm_free_tx_chunk(void) -{ - uint32_t lock = int_lock_global(); - if (0 == fp_rfcomm_tx_buf_allocated_chunk_cnt) - { - int_unlock_global(lock); - return false; - } + uint32_t returnedChunk = fp_rfcomm_tx_buf_next_allocated_chunk; - fp_rfcomm_tx_buf_allocated_chunk_cnt--; - int_unlock_global(lock); - return true; -} - -static void fp_rfcomm_reset_tx_buf(void) -{ - uint32_t lock = int_lock_global(); - fp_rfcomm_tx_buf_allocated_chunk_cnt = 0; + fp_rfcomm_tx_buf_allocated_chunk_cnt++; + fp_rfcomm_tx_buf_next_allocated_chunk++; + if (FP_RFCOMM_TX_BUF_CHUNK_CNT == fp_rfcomm_tx_buf_next_allocated_chunk) { fp_rfcomm_tx_buf_next_allocated_chunk = 0; + } + + int_unlock_global(lock); + return returnedChunk; +} + +static bool fp_rfcomm_free_tx_chunk(void) { + uint32_t lock = int_lock_global(); + if (0 == fp_rfcomm_tx_buf_allocated_chunk_cnt) { int_unlock_global(lock); + return false; + } + + fp_rfcomm_tx_buf_allocated_chunk_cnt--; + int_unlock_global(lock); + return true; +} + +static void fp_rfcomm_reset_tx_buf(void) { + uint32_t lock = int_lock_global(); + fp_rfcomm_tx_buf_allocated_chunk_cnt = 0; + fp_rfcomm_tx_buf_next_allocated_chunk = 0; + int_unlock_global(lock); } #define GFPS_FIND_MY_BUDS_CMD_STOP 0x0 @@ -143,148 +139,133 @@ uint8_t find_buds_flag = 0; #include "app_status_ind.h" #include "apps.h" -void app_set_find_my_buds(uint8_t mode) -{ +void app_set_find_my_buds(uint8_t mode) { #ifdef IBRT - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - TRACE(2,"%s, mode = %d,role = %d", __func__, mode,p_ibrt_ctrl->current_role); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + TRACE(2, "%s, mode = %d,role = %d", __func__, mode, + p_ibrt_ctrl->current_role); - switch (mode) - { - case FIND_MY_BUDS_CMD_STOP_MASTER: - if(find_buds_flag & FIND_MY_BUDS_STATUS_MASTER_MASK) - { - /* stop beeping master */ - if (IBRT_SLAVE != p_ibrt_ctrl->current_role) - { - //app_set_find_my_buds_status(false); - app_voice_stop(APP_STATUS_INDICATION_FIND_MY_BUDS, 0); - find_buds_flag &= ~(FIND_MY_BUDS_STATUS_MASTER_MASK); - } - } - break; - case FIND_MY_BUDS_CMD_STOP_SLAVE: - if(find_buds_flag & FIND_MY_BUDS_STATUS_SLAVE_MASK) - { - /* stop beeping slave */ - if (IBRT_SLAVE == p_ibrt_ctrl->current_role) - { - app_voice_stop(APP_STATUS_INDICATION_FIND_MY_BUDS, 0); - find_buds_flag &= ~(FIND_MY_BUDS_STATUS_SLAVE_MASK); - } - } - break; - case FIND_MY_BUDS_CMD_START_MASTER: - if(!(find_buds_flag & FIND_MY_BUDS_STATUS_MASTER_MASK)) - { - /* start beep master */ - if (IBRT_SLAVE != p_ibrt_ctrl->current_role) - { - app_voice_report(APP_STATUS_INDICATION_FIND_MY_BUDS, 0); - - find_buds_flag |= FIND_MY_BUDS_STATUS_MASTER_MASK; - } - } - break; - case FIND_MY_BUDS_CMD_START_SLAVE: - if(!(find_buds_flag & FIND_MY_BUDS_STATUS_SLAVE_MASK)) - { - /* start beep slave */ - if (IBRT_SLAVE == p_ibrt_ctrl->current_role) - { - app_voice_report(APP_STATUS_INDICATION_FIND_MY_BUDS, 0); - - find_buds_flag |= FIND_MY_BUDS_STATUS_SLAVE_MASK; - } - } - break; - default: - break; + switch (mode) { + case FIND_MY_BUDS_CMD_STOP_MASTER: + if (find_buds_flag & FIND_MY_BUDS_STATUS_MASTER_MASK) { + /* stop beeping master */ + if (IBRT_SLAVE != p_ibrt_ctrl->current_role) { + // app_set_find_my_buds_status(false); + app_voice_stop(APP_STATUS_INDICATION_FIND_MY_BUDS, 0); + find_buds_flag &= ~(FIND_MY_BUDS_STATUS_MASTER_MASK); + } } + break; + case FIND_MY_BUDS_CMD_STOP_SLAVE: + if (find_buds_flag & FIND_MY_BUDS_STATUS_SLAVE_MASK) { + /* stop beeping slave */ + if (IBRT_SLAVE == p_ibrt_ctrl->current_role) { + app_voice_stop(APP_STATUS_INDICATION_FIND_MY_BUDS, 0); + find_buds_flag &= ~(FIND_MY_BUDS_STATUS_SLAVE_MASK); + } + } + break; + case FIND_MY_BUDS_CMD_START_MASTER: + if (!(find_buds_flag & FIND_MY_BUDS_STATUS_MASTER_MASK)) { + /* start beep master */ + if (IBRT_SLAVE != p_ibrt_ctrl->current_role) { + app_voice_report(APP_STATUS_INDICATION_FIND_MY_BUDS, 0); + + find_buds_flag |= FIND_MY_BUDS_STATUS_MASTER_MASK; + } + } + break; + case FIND_MY_BUDS_CMD_START_SLAVE: + if (!(find_buds_flag & FIND_MY_BUDS_STATUS_SLAVE_MASK)) { + /* start beep slave */ + if (IBRT_SLAVE == p_ibrt_ctrl->current_role) { + app_voice_report(APP_STATUS_INDICATION_FIND_MY_BUDS, 0); + + find_buds_flag |= FIND_MY_BUDS_STATUS_SLAVE_MASK; + } + } + break; + default: + break; + } #else - switch (mode) - { - case GFPS_FIND_MY_BUDS_CMD_START: - app_voice_report(APP_STATUS_INDICATION_FIND_MY_BUDS, 0); - break; - case GFPS_FIND_MY_BUDS_CMD_STOP: - app_voice_stop(APP_STATUS_INDICATION_FIND_MY_BUDS, 0); - default: - break; - } + switch (mode) { + case GFPS_FIND_MY_BUDS_CMD_START: + app_voice_report(APP_STATUS_INDICATION_FIND_MY_BUDS, 0); + break; + case GFPS_FIND_MY_BUDS_CMD_STOP: + app_voice_stop(APP_STATUS_INDICATION_FIND_MY_BUDS, 0); + default: + break; + } #endif } osTimerId ring_timeout_timer_id = NULL; static void gfps_find_devices_ring_timeout_handler(void const *param); -osTimerDef (GFPS_FIND_DEVICES_RING_TIMEOUT, gfps_find_devices_ring_timeout_handler); +osTimerDef(GFPS_FIND_DEVICES_RING_TIMEOUT, + gfps_find_devices_ring_timeout_handler); #define GFPS_FIND_MY_BUDS_CMD_STOP_DUAL 0x0 #define GFPS_FIND_MY_BUDS_CMD_START_MASTER_ONLY 0x1 #define GFPS_FIND_MY_BUDS_CMD_START_SLAVE_ONLY 0x2 #define GFPS_FIND_MY_BUDS_CMD_START_DUAL 0x3 -static void gfps_set_find_my_buds(uint8_t cmd) -{ - TRACE(2,"%s, cmd = %d", __func__, cmd); +static void gfps_set_find_my_buds(uint8_t cmd) { + TRACE(2, "%s, cmd = %d", __func__, cmd); #ifdef IBRT - if(GFPS_FIND_MY_BUDS_CMD_STOP_DUAL == cmd) - { - app_set_find_my_buds(FIND_MY_BUDS_CMD_STOP_MASTER); - app_set_find_my_buds(FIND_MY_BUDS_CMD_STOP_SLAVE); - } - else if(GFPS_FIND_MY_BUDS_CMD_START_MASTER_ONLY == cmd) //right ring, stop left - { - app_set_find_my_buds(FIND_MY_BUDS_CMD_STOP_SLAVE); - app_set_find_my_buds(FIND_MY_BUDS_CMD_START_MASTER); - } - else if(GFPS_FIND_MY_BUDS_CMD_START_SLAVE_ONLY == cmd) //left ring, stop right - { - app_set_find_my_buds(FIND_MY_BUDS_CMD_STOP_MASTER); - app_set_find_my_buds(FIND_MY_BUDS_CMD_START_SLAVE); - } - else if(GFPS_FIND_MY_BUDS_CMD_START_DUAL == cmd) //both ring - { - app_set_find_my_buds(FIND_MY_BUDS_CMD_START_MASTER); - app_set_find_my_buds(FIND_MY_BUDS_CMD_START_SLAVE); - } + if (GFPS_FIND_MY_BUDS_CMD_STOP_DUAL == cmd) { + app_set_find_my_buds(FIND_MY_BUDS_CMD_STOP_MASTER); + app_set_find_my_buds(FIND_MY_BUDS_CMD_STOP_SLAVE); + } else if (GFPS_FIND_MY_BUDS_CMD_START_MASTER_ONLY == + cmd) // right ring, stop left + { + app_set_find_my_buds(FIND_MY_BUDS_CMD_STOP_SLAVE); + app_set_find_my_buds(FIND_MY_BUDS_CMD_START_MASTER); + } else if (GFPS_FIND_MY_BUDS_CMD_START_SLAVE_ONLY == + cmd) // left ring, stop right + { + app_set_find_my_buds(FIND_MY_BUDS_CMD_STOP_MASTER); + app_set_find_my_buds(FIND_MY_BUDS_CMD_START_SLAVE); + } else if (GFPS_FIND_MY_BUDS_CMD_START_DUAL == cmd) // both ring + { + app_set_find_my_buds(FIND_MY_BUDS_CMD_START_MASTER); + app_set_find_my_buds(FIND_MY_BUDS_CMD_START_SLAVE); + } #else - app_set_find_my_buds(cmd); + app_set_find_my_buds(cmd); #endif } -static void gfps_find_devices_ring_timeout_handler(void const *param) -{ - TRACE(0,"gfps_find_devices_ring_timeout_handler"); - app_bt_start_custom_function_in_bt_thread(GFPS_FIND_MY_BUDS_CMD_STOP_DUAL, 0, \ - (uint32_t)gfps_set_find_my_buds); +static void gfps_find_devices_ring_timeout_handler(void const *param) { + TRACE(0, "gfps_find_devices_ring_timeout_handler"); + app_bt_start_custom_function_in_bt_thread(GFPS_FIND_MY_BUDS_CMD_STOP_DUAL, 0, + (uint32_t)gfps_set_find_my_buds); } -void fp_rfcomm_ring_timer_set(uint8_t period) -{ - TRACE(2,"%s, period = %d", __func__, period); - if (ring_timeout_timer_id == NULL) - { - ring_timeout_timer_id = osTimerCreate(osTimer(GFPS_FIND_DEVICES_RING_TIMEOUT), osTimerOnce, NULL); - } - - osTimerStop(ring_timeout_timer_id); - if(period) - { - osTimerStart(ring_timeout_timer_id, period*1000); - } +void fp_rfcomm_ring_timer_set(uint8_t period) { + TRACE(2, "%s, period = %d", __func__, period); + if (ring_timeout_timer_id == NULL) { + ring_timeout_timer_id = osTimerCreate( + osTimer(GFPS_FIND_DEVICES_RING_TIMEOUT), osTimerOnce, NULL); + } + + osTimerStop(ring_timeout_timer_id); + if (period) { + osTimerStart(ring_timeout_timer_id, period * 1000); + } } -static void fp_rfcomm_ring_request_handling(uint8_t* requestdata, uint16_t datalen) -{ - TRACE(1,"%s,[RFCOMM][FMD] request",__func__); - DUMP8("%02x ", requestdata, datalen); - app_fp_msg_send_message_ack(FP_MSG_GROUP_DEVICE_ACTION, FP_MSG_DEVICE_ACTION_RING); - if (datalen > 1) - { - fp_rfcomm_ring_timer_set(requestdata[1]); - } +static void fp_rfcomm_ring_request_handling(uint8_t *requestdata, + uint16_t datalen) { + TRACE(1, "%s,[RFCOMM][FMD] request", __func__); + DUMP8("%02x ", requestdata, datalen); + app_fp_msg_send_message_ack(FP_MSG_GROUP_DEVICE_ACTION, + FP_MSG_DEVICE_ACTION_RING); + if (datalen > 1) { + fp_rfcomm_ring_timer_set(requestdata[1]); + } - gfps_set_find_my_buds(requestdata[0]); - - // TODO: implement the continuous audio prompt playing state machine + gfps_set_find_my_buds(requestdata[0]); + + // TODO: implement the continuous audio prompt playing state machine #if 0 uint8_t isAllowed = false; uint8_t isChangePeerDevStatus = false; @@ -462,398 +443,335 @@ static void fp_rfcomm_ring_request_handling(uint8_t* requestdata, uint16_t datal #endif } -#define FP_ACCUMULATED_DATA_BUF_SIZE 128 +#define FP_ACCUMULATED_DATA_BUF_SIZE 128 static uint8_t fp_accumulated_data_buf[FP_ACCUMULATED_DATA_BUF_SIZE]; static uint16_t fp_accumulated_data_size = 0; -static void fp_rfcomm_reset_data_accumulator(void) -{ - fp_accumulated_data_size = 0; - memset(fp_accumulated_data_buf, 0, sizeof(fp_accumulated_data_buf)); +static void fp_rfcomm_reset_data_accumulator(void) { + fp_accumulated_data_size = 0; + memset(fp_accumulated_data_buf, 0, sizeof(fp_accumulated_data_buf)); } -static void fp_rfcomm_data_accumulator(uint8_t* ptr, uint16_t len) -{ - ASSERT((fp_accumulated_data_size + len) < sizeof(fp_accumulated_data_buf), - "fp accumulcate buffer is overflow!"); +static void fp_rfcomm_data_accumulator(uint8_t *ptr, uint16_t len) { + ASSERT((fp_accumulated_data_size + len) < sizeof(fp_accumulated_data_buf), + "fp accumulcate buffer is overflow!"); - memcpy(&fp_accumulated_data_buf[fp_accumulated_data_size], ptr, len); - fp_accumulated_data_size += len; + memcpy(&fp_accumulated_data_buf[fp_accumulated_data_size], ptr, len); + fp_accumulated_data_size += len; - uint16_t msgTotalLen; - FP_MESSAGE_STREAM_T* msgStream; - - while (fp_accumulated_data_size >= FP_MESSAGE_RESERVED_LEN) - { - msgStream = (FP_MESSAGE_STREAM_T *)fp_accumulated_data_buf; - msgTotalLen = ((msgStream->dataLenHighByte << 8)|msgStream->dataLenLowByte) + - FP_MESSAGE_RESERVED_LEN; - ASSERT(msgTotalLen < sizeof(fp_accumulated_data_buf), - "Wrong fp msg len %d received!", msgTotalLen); - if (fp_accumulated_data_size >= msgTotalLen) - { - fp_rfcomm_data_handler(fp_accumulated_data_buf, msgTotalLen); - fp_accumulated_data_size -= msgTotalLen; - memmove(fp_accumulated_data_buf, &fp_accumulated_data_buf[msgTotalLen], - fp_accumulated_data_size); - } - else - { - break; - } + uint16_t msgTotalLen; + FP_MESSAGE_STREAM_T *msgStream; + + while (fp_accumulated_data_size >= FP_MESSAGE_RESERVED_LEN) { + msgStream = (FP_MESSAGE_STREAM_T *)fp_accumulated_data_buf; + msgTotalLen = + ((msgStream->dataLenHighByte << 8) | msgStream->dataLenLowByte) + + FP_MESSAGE_RESERVED_LEN; + ASSERT(msgTotalLen < sizeof(fp_accumulated_data_buf), + "Wrong fp msg len %d received!", msgTotalLen); + if (fp_accumulated_data_size >= msgTotalLen) { + fp_rfcomm_data_handler(fp_accumulated_data_buf, msgTotalLen); + fp_accumulated_data_size -= msgTotalLen; + memmove(fp_accumulated_data_buf, &fp_accumulated_data_buf[msgTotalLen], + fp_accumulated_data_size); + } else { + break; } + } } -static void fp_rfcomm_data_handler(uint8_t* ptr, uint16_t len) -{ - FP_MESSAGE_STREAM_T* pMsg = (FP_MESSAGE_STREAM_T *)ptr; - uint16_t datalen = 0; - TRACE(2,"fp rfcomm receives msg group %d code %d", - pMsg->messageGroup, pMsg->messageCode); +static void fp_rfcomm_data_handler(uint8_t *ptr, uint16_t len) { + FP_MESSAGE_STREAM_T *pMsg = (FP_MESSAGE_STREAM_T *)ptr; + uint16_t datalen = 0; + TRACE(2, "fp rfcomm receives msg group %d code %d", pMsg->messageGroup, + pMsg->messageCode); - switch (pMsg->messageGroup) - { - case FP_MSG_GROUP_DEVICE_INFO: - { - switch (pMsg->messageCode) - { - case FP_MSG_DEVICE_INFO_ACTIVE_COMPONENTS_REQ: - app_fp_msg_send_active_components_rsp(); - break; - case FP_MSG_DEVICE_INFO_TELL_CAPABILITIES: - fp_capabilities.content = pMsg->data[0]; - TRACE(3,"cap 0x%x isCompanionAppInstalled %d isSilentModeSupported %d", - fp_capabilities.content, fp_capabilities.env.isCompanionAppInstalled, - fp_capabilities.env.isSilentModeSupported); - break; - default: - break; - } - } - case FP_MSG_GROUP_DEVICE_ACTION: - { - switch (pMsg->messageCode) - { - case FP_MSG_DEVICE_ACTION_RING: - datalen = (pMsg->dataLenHighByte<<8)+pMsg->dataLenLowByte; - fp_rfcomm_ring_request_handling(pMsg->data, datalen); - break; - default: - break; - } - break; - } - default: - break; + switch (pMsg->messageGroup) { + case FP_MSG_GROUP_DEVICE_INFO: { + switch (pMsg->messageCode) { + case FP_MSG_DEVICE_INFO_ACTIVE_COMPONENTS_REQ: + app_fp_msg_send_active_components_rsp(); + break; + case FP_MSG_DEVICE_INFO_TELL_CAPABILITIES: + fp_capabilities.content = pMsg->data[0]; + TRACE(3, "cap 0x%x isCompanionAppInstalled %d isSilentModeSupported %d", + fp_capabilities.content, + fp_capabilities.env.isCompanionAppInstalled, + fp_capabilities.env.isSilentModeSupported); + break; + default: + break; } -} - -static int fp_rfcomm_data_received(void *pDev, uint8_t process, uint8_t *pData, uint16_t dataLen) -{ - TRACE(1,"%s",__func__); - //DUMP8("0x%02x ",pData, dataLen); - fp_rfcomm_data_accumulator(pData, dataLen); - return 0; -} - -static void fp_rfcomm_connected_handler(void) -{ - if (!fp_rfcomm_service.isConnected) - { - fp_rfcomm_service.isConnected = true; - - fp_rfcomm_reset_data_accumulator(); - app_fp_msg_send_model_id(); - app_fp_msg_send_updated_ble_addr(); - app_fp_msg_send_battery_levels(); + } + case FP_MSG_GROUP_DEVICE_ACTION: { + switch (pMsg->messageCode) { + case FP_MSG_DEVICE_ACTION_RING: + datalen = (pMsg->dataLenHighByte << 8) + pMsg->dataLenLowByte; + fp_rfcomm_ring_request_handling(pMsg->data, datalen); + break; + default: + break; } + break; + } + default: + break; + } } -static bool fp_rfcomm_callback(RFCOMM_EVENT_E event, - uint8_t instanceIndex, uint16_t connHandle, - uint8_t* pBtAddr, uint8_t* pSentDataBuf, uint16_t sentDataLen) -{ - TRACE(2,"%s,event is %d",__func__,event); - switch (event) - { - case RFCOMM_INCOMING_CONN_REQ: - { - TRACE(0,"Connected Indication RFComm device info:"); - TRACE(2,"hci handle is 0x%x service index %d", - connHandle, instanceIndex); - if (pBtAddr) - { - TRACE(0,"Bd addr is:"); - DUMP8("%02x ", pBtAddr, 6); - } +static int fp_rfcomm_data_received(void *pDev, uint8_t process, uint8_t *pData, + uint16_t dataLen) { + TRACE(1, "%s", __func__); + // DUMP8("0x%02x ",pData, dataLen); + fp_rfcomm_data_accumulator(pData, dataLen); + return 0; +} - fp_rfcomm_connected_handler(); - break; - } - case RFCOMM_CONNECTED: - { - if (pBtAddr) - { - TRACE(0,"Bd addr is:"); - DUMP8("%02x ", pBtAddr, 6); - } - - fp_rfcomm_connected_handler(); - break; - } - case RFCOMM_DISCONNECTED: - { - TRACE(0,"Disconnected Rfcomm device info:"); - TRACE(0,"Bd addr is:"); - DUMP8("%02x ", pBtAddr, 6); - TRACE(1,"hci handle is 0x%x", connHandle); +static void fp_rfcomm_connected_handler(void) { + if (!fp_rfcomm_service.isConnected) { + fp_rfcomm_service.isConnected = true; - TRACE(1,"::RFCOMM_DISCONNECTED %d", event); - - fp_rfcomm_service.isConnected = false; - fp_rfcomm_reset_tx_buf(); - break; - } - case RFCOMM_TX_DONE: - { - TRACE(1,"Rfcomm dataLen %d sent out", sentDataLen); - fp_rfcomm_free_tx_chunk(); - break; - } - default: - { - TRACE(1,"Unkown rfcomm event %d", event); - break; - } + fp_rfcomm_reset_data_accumulator(); + app_fp_msg_send_model_id(); + app_fp_msg_send_updated_ble_addr(); + app_fp_msg_send_battery_levels(); + } +} + +static bool fp_rfcomm_callback(RFCOMM_EVENT_E event, uint8_t instanceIndex, + uint16_t connHandle, uint8_t *pBtAddr, + uint8_t *pSentDataBuf, uint16_t sentDataLen) { + TRACE(2, "%s,event is %d", __func__, event); + switch (event) { + case RFCOMM_INCOMING_CONN_REQ: { + TRACE(0, "Connected Indication RFComm device info:"); + TRACE(2, "hci handle is 0x%x service index %d", connHandle, instanceIndex); + if (pBtAddr) { + TRACE(0, "Bd addr is:"); + DUMP8("%02x ", pBtAddr, 6); } - return true; -} - -static void app_fp_disconnect_rfcomm_handler(void) -{ - if (fp_rfcomm_service.isConnected) - { - app_rfcomm_close(fp_rfcomm_service.serviceIndex); - } -} - -void app_fp_disconnect_rfcomm(void) -{ - app_bt_start_custom_function_in_bt_thread(0, - 0, - ( uint32_t )app_fp_disconnect_rfcomm_handler); -} - -static void app_fp_rfcomm_send_handler(uint8_t *ptrData, uint32_t length) -{ - int8_t ret = app_rfcomm_write(fp_rfcomm_service.serviceIndex, ptrData, length); - if (0 != ret) - { - fp_rfcomm_free_tx_chunk(); - } -} - -void app_fp_rfcomm_send(uint8_t *ptrData, uint32_t length) -{ - if (!fp_rfcomm_service.isConnected) - { - return; + fp_rfcomm_connected_handler(); + break; + } + case RFCOMM_CONNECTED: { + if (pBtAddr) { + TRACE(0, "Bd addr is:"); + DUMP8("%02x ", pBtAddr, 6); } - int32_t chunk = fp_rfcomm_alloc_tx_chunk(); - if (-1 == chunk) - { - TRACE(0,"Fast pair rfcomm tx buffer used out!"); - return; - } + fp_rfcomm_connected_handler(); + break; + } + case RFCOMM_DISCONNECTED: { + TRACE(0, "Disconnected Rfcomm device info:"); + TRACE(0, "Bd addr is:"); + DUMP8("%02x ", pBtAddr, 6); + TRACE(1, "hci handle is 0x%x", connHandle); - ASSERT(length < FP_RFCOMM_TX_BUF_CHUNK_SIZE, - "FP_RFCOMM_TX_BUF_CHUNK_SIZE is %d which is smaller than %d, need to increase!", - FP_RFCOMM_TX_BUF_CHUNK_SIZE, - length); + TRACE(1, "::RFCOMM_DISCONNECTED %d", event); - uint8_t *txBufAddr = fp_rfcomm_tx_buf_addr(chunk); - memcpy(txBufAddr, ptrData, length); - app_bt_start_custom_function_in_bt_thread(( uint32_t )txBufAddr, - ( uint32_t )length, - ( uint32_t )app_fp_rfcomm_send_handler); + fp_rfcomm_service.isConnected = false; + fp_rfcomm_reset_tx_buf(); + break; + } + case RFCOMM_TX_DONE: { + TRACE(1, "Rfcomm dataLen %d sent out", sentDataLen); + fp_rfcomm_free_tx_chunk(); + break; + } + default: { + TRACE(1, "Unkown rfcomm event %d", event); + break; + } + } + + return true; } -bt_status_t app_fp_rfcomm_init(void) -{ - TRACE(1,"%s",__func__); - bt_status_t stat = BT_STS_SUCCESS; - - if (!fp_rfcomm_service.isRfcommInitialized) - { - osMutexId mid; - mid = osMutexCreate(osMutex(fp_rfcomm_mutex)); - if (!mid) { - ASSERT(0, "cannot create mutex"); - } - - fp_rfcomm_service.isRfcommInitialized = true; - - RFCOMM_CONFIG_T tConfig; - tConfig.callback = fp_rfcomm_callback; - tConfig.tx_pkt_cnt = FP_RFCOMM_TX_PKT_CNT; - tConfig.rfcomm_128bit_uuid = FP_RFCOMM_UUID_128; - tConfig.rfcomm_ch = RFCOMM_CHANNEL_FP; - tConfig.app_id = BTIF_APP_SPP_SERVER_FP_RFCOMM_ID; - tConfig.spp_handle_data_event_func = fp_rfcomm_data_received; - tConfig.mutexId = mid; - tConfig.creditMutexId = osMutexCreate(osMutex(fp_rfcomm_credit_mutex)); - int8_t index = app_rfcomm_open(&tConfig); - - if (-1 == index) - { - TRACE(0,"fast pair rfcomm open failed"); - return BT_STS_FAILED; - } - - fp_rfcomm_service.isConnected = false; - fp_rfcomm_service.serviceIndex = index; - } - else - { - TRACE(0,"already initialized."); - } - - return stat; +static void app_fp_disconnect_rfcomm_handler(void) { + if (fp_rfcomm_service.isConnected) { + app_rfcomm_close(fp_rfcomm_service.serviceIndex); + } } -bool app_is_fp_rfcomm_connected(void) -{ - return fp_rfcomm_service.isConnected; +void app_fp_disconnect_rfcomm(void) { + app_bt_start_custom_function_in_bt_thread( + 0, 0, (uint32_t)app_fp_disconnect_rfcomm_handler); } +static void app_fp_rfcomm_send_handler(uint8_t *ptrData, uint32_t length) { + int8_t ret = + app_rfcomm_write(fp_rfcomm_service.serviceIndex, ptrData, length); + if (0 != ret) { + fp_rfcomm_free_tx_chunk(); + } +} + +void app_fp_rfcomm_send(uint8_t *ptrData, uint32_t length) { + if (!fp_rfcomm_service.isConnected) { + return; + } + + int32_t chunk = fp_rfcomm_alloc_tx_chunk(); + if (-1 == chunk) { + TRACE(0, "Fast pair rfcomm tx buffer used out!"); + return; + } + + ASSERT(length < FP_RFCOMM_TX_BUF_CHUNK_SIZE, + "FP_RFCOMM_TX_BUF_CHUNK_SIZE is %d which is smaller than %d, need to " + "increase!", + FP_RFCOMM_TX_BUF_CHUNK_SIZE, length); + + uint8_t *txBufAddr = fp_rfcomm_tx_buf_addr(chunk); + memcpy(txBufAddr, ptrData, length); + app_bt_start_custom_function_in_bt_thread( + (uint32_t)txBufAddr, (uint32_t)length, + (uint32_t)app_fp_rfcomm_send_handler); +} + +bt_status_t app_fp_rfcomm_init(void) { + TRACE(1, "%s", __func__); + bt_status_t stat = BT_STS_SUCCESS; + + if (!fp_rfcomm_service.isRfcommInitialized) { + osMutexId mid; + mid = osMutexCreate(osMutex(fp_rfcomm_mutex)); + if (!mid) { + ASSERT(0, "cannot create mutex"); + } + + fp_rfcomm_service.isRfcommInitialized = true; + + RFCOMM_CONFIG_T tConfig; + tConfig.callback = fp_rfcomm_callback; + tConfig.tx_pkt_cnt = FP_RFCOMM_TX_PKT_CNT; + tConfig.rfcomm_128bit_uuid = FP_RFCOMM_UUID_128; + tConfig.rfcomm_ch = RFCOMM_CHANNEL_FP; + tConfig.app_id = BTIF_APP_SPP_SERVER_FP_RFCOMM_ID; + tConfig.spp_handle_data_event_func = fp_rfcomm_data_received; + tConfig.mutexId = mid; + tConfig.creditMutexId = osMutexCreate(osMutex(fp_rfcomm_credit_mutex)); + int8_t index = app_rfcomm_open(&tConfig); + + if (-1 == index) { + TRACE(0, "fast pair rfcomm open failed"); + return BT_STS_FAILED; + } + + fp_rfcomm_service.isConnected = false; + fp_rfcomm_service.serviceIndex = index; + } else { + TRACE(0, "already initialized."); + } + + return stat; +} + +bool app_is_fp_rfcomm_connected(void) { return fp_rfcomm_service.isConnected; } + // use cases for fp message stream -void app_fp_msg_enable_bt_silence_mode(bool isEnable) -{ - if (fp_capabilities.env.isSilentModeSupported) - { - FP_MESSAGE_STREAM_T req = {FP_MSG_GROUP_BLUETOOTH_EVENT, 0, 0, 0}; - if (isEnable) - { - req.messageCode = FP_MSG_BT_EVENT_ENABLE_SILENCE_MODE; - } - else - { - req.messageCode = FP_MSG_BT_EVENT_DISABLE_SILENCE_MODE; - } +void app_fp_msg_enable_bt_silence_mode(bool isEnable) { + if (fp_capabilities.env.isSilentModeSupported) { + FP_MESSAGE_STREAM_T req = {FP_MSG_GROUP_BLUETOOTH_EVENT, 0, 0, 0}; + if (isEnable) { + req.messageCode = FP_MSG_BT_EVENT_ENABLE_SILENCE_MODE; + } else { + req.messageCode = FP_MSG_BT_EVENT_DISABLE_SILENCE_MODE; + } - app_fp_rfcomm_send((uint8_t *)&req, FP_MESSAGE_RESERVED_LEN); - } - else - { - TRACE(0,"fp silence mode is not supported."); - } + app_fp_rfcomm_send((uint8_t *)&req, FP_MESSAGE_RESERVED_LEN); + } else { + TRACE(0, "fp silence mode is not supported."); + } } -void app_fp_msg_send_model_id(void) -{ - TRACE(1,"%s",__func__); +void app_fp_msg_send_model_id(void) { + TRACE(1, "%s", __func__); #ifndef IS_USE_CUSTOM_FP_INFO - uint32_t model_id = 0x2B677D; + uint32_t model_id = 0x2B677D; #else - uint32_t model_id = app_bt_get_model_id(); + uint32_t model_id = app_bt_get_model_id(); #endif - uint8_t modelID[3]; - modelID[0] = (model_id >> 16) & 0xFF; - modelID[1] = (model_id >> 8) & 0xFF; - modelID[2] = ( model_id )&0xFF; + uint8_t modelID[3]; + modelID[0] = (model_id >> 16) & 0xFF; + modelID[1] = (model_id >> 8) & 0xFF; + modelID[2] = (model_id)&0xFF; - uint16_t rawDataLen = sizeof(modelID); + uint16_t rawDataLen = sizeof(modelID); - FP_MESSAGE_STREAM_T req = - {FP_MSG_GROUP_DEVICE_INFO, - FP_MSG_DEVICE_INFO_MODEL_ID, - (uint8_t)(rawDataLen >> 8), - (uint8_t)(rawDataLen & 0xFF)}; - memcpy(req.data, modelID, sizeof(modelID)); + FP_MESSAGE_STREAM_T req = { + FP_MSG_GROUP_DEVICE_INFO, FP_MSG_DEVICE_INFO_MODEL_ID, + (uint8_t)(rawDataLen >> 8), (uint8_t)(rawDataLen & 0xFF)}; + memcpy(req.data, modelID, sizeof(modelID)); - app_fp_rfcomm_send(( uint8_t * )&req, FP_MESSAGE_RESERVED_LEN + rawDataLen); + app_fp_rfcomm_send((uint8_t *)&req, FP_MESSAGE_RESERVED_LEN + rawDataLen); } -void app_fp_msg_send_updated_ble_addr(void) -{ - FP_MESSAGE_STREAM_T req = - {FP_MSG_GROUP_DEVICE_INFO, - FP_MSG_DEVICE_INFO_BLE_ADD_UPDATED, - 0, - 6}; +void app_fp_msg_send_updated_ble_addr(void) { + FP_MESSAGE_STREAM_T req = {FP_MSG_GROUP_DEVICE_INFO, + FP_MSG_DEVICE_INFO_BLE_ADD_UPDATED, 0, 6}; - uint8_t *ptr = appm_get_current_ble_addr(); + uint8_t *ptr = appm_get_current_ble_addr(); - for (uint8_t index = 0; index < 6; index++) - { - req.data[index] = ptr[5 - index]; - } + for (uint8_t index = 0; index < 6; index++) { + req.data[index] = ptr[5 - index]; + } - app_fp_rfcomm_send(( uint8_t * )&req, FP_MESSAGE_RESERVED_LEN + 6); + app_fp_rfcomm_send((uint8_t *)&req, FP_MESSAGE_RESERVED_LEN + 6); } -void app_fp_msg_send_battery_levels(void) -{ - TRACE(1,"%s",__func__); - FP_MESSAGE_STREAM_T req = - {FP_MSG_GROUP_DEVICE_INFO, - FP_MSG_DEVICE_INFO_BATTERY_UPDATED, - 0, - 3}; +void app_fp_msg_send_battery_levels(void) { + TRACE(1, "%s", __func__); + FP_MESSAGE_STREAM_T req = {FP_MSG_GROUP_DEVICE_INFO, + FP_MSG_DEVICE_INFO_BATTERY_UPDATED, 0, 3}; - uint8_t batteryLevelCount = 0; - app_gfps_get_battery_levels(&batteryLevelCount, req.data); + uint8_t batteryLevelCount = 0; + app_gfps_get_battery_levels(&batteryLevelCount, req.data); - app_fp_rfcomm_send(( uint8_t * )&req, FP_MESSAGE_RESERVED_LEN + 3); + app_fp_rfcomm_send((uint8_t *)&req, FP_MESSAGE_RESERVED_LEN + 3); } -static __attribute__((unused)) void app_fp_msg_send_active_components_rsp(void) -{ - FP_MESSAGE_STREAM_T req = {FP_MSG_GROUP_DEVICE_INFO, FP_MSG_DEVICE_INFO_ACTIVE_COMPONENTS_RSP, 0, 1}; +static __attribute__((unused)) void +app_fp_msg_send_active_components_rsp(void) { + FP_MESSAGE_STREAM_T req = {FP_MSG_GROUP_DEVICE_INFO, + FP_MSG_DEVICE_INFO_ACTIVE_COMPONENTS_RSP, 0, 1}; #if defined(IBRT) - if (app_tws_ibrt_tws_link_connected()) - { - req.data[0] = FP_MSG_BOTH_BUDS_ACTIVE; - } - else - { - if (app_tws_is_left_side()) - { - req.data[0] = FP_MSG_LEFT_BUD_ACTIVE; - } - else - { - req.data[0] = FP_MSG_RIGHT_BUD_ACTIVE; - } - } -#else + if (app_tws_ibrt_tws_link_connected()) { req.data[0] = FP_MSG_BOTH_BUDS_ACTIVE; + } else { + if (app_tws_is_left_side()) { + req.data[0] = FP_MSG_LEFT_BUD_ACTIVE; + } else { + req.data[0] = FP_MSG_RIGHT_BUD_ACTIVE; + } + } +#else + req.data[0] = FP_MSG_BOTH_BUDS_ACTIVE; #endif - app_fp_rfcomm_send((uint8_t *)&req, FP_MESSAGE_RESERVED_LEN+1); + app_fp_rfcomm_send((uint8_t *)&req, FP_MESSAGE_RESERVED_LEN + 1); } -static __attribute__((unused)) void app_fp_msg_send_message_ack(uint8_t msgGroup, uint8_t msgCode) -{ - FP_MESSAGE_STREAM_T req = {FP_MSG_GROUP_ACKNOWLEDGEMENT, FP_MSG_ACK, 0, 2}; +static __attribute__((unused)) void +app_fp_msg_send_message_ack(uint8_t msgGroup, uint8_t msgCode) { + FP_MESSAGE_STREAM_T req = {FP_MSG_GROUP_ACKNOWLEDGEMENT, FP_MSG_ACK, 0, 2}; - req.data[0] = msgGroup; - req.data[1] = msgCode; + req.data[0] = msgGroup; + req.data[1] = msgCode; - app_fp_rfcomm_send((uint8_t *)&req, FP_MESSAGE_RESERVED_LEN+2); + app_fp_rfcomm_send((uint8_t *)&req, FP_MESSAGE_RESERVED_LEN + 2); } -static __attribute__((unused)) void app_fp_msg_send_message_nak(uint8_t reason, uint8_t msgGroup, uint8_t msgCode) -{ - FP_MESSAGE_STREAM_T req = {FP_MSG_GROUP_ACKNOWLEDGEMENT, FP_MSG_NAK, 0, 3}; +static __attribute__((unused)) void +app_fp_msg_send_message_nak(uint8_t reason, uint8_t msgGroup, uint8_t msgCode) { + FP_MESSAGE_STREAM_T req = {FP_MSG_GROUP_ACKNOWLEDGEMENT, FP_MSG_NAK, 0, 3}; - req.data[0] = reason; - req.data[1] = msgGroup; - req.data[2] = msgCode; + req.data[0] = reason; + req.data[1] = msgGroup; + req.data[2] = msgCode; - app_fp_rfcomm_send((uint8_t *)&req, FP_MESSAGE_RESERVED_LEN+3); + app_fp_rfcomm_send((uint8_t *)&req, FP_MESSAGE_RESERVED_LEN + 3); } - diff --git a/services/bt_app/app_fp_rfcomm.h b/services/bt_app/app_fp_rfcomm.h index 604d7e8..f75dbaa 100644 --- a/services/bt_app/app_fp_rfcomm.h +++ b/services/bt_app/app_fp_rfcomm.h @@ -1,51 +1,52 @@ #ifndef __APP_FP_RFCOMM_H__ #define __APP_FP_RFCOMM_H__ - -#define FP_MESSAGE_RESERVED_LEN 4 // at least 4 bytes +#include "bluetooth.h" +#include +#include +#define FP_MESSAGE_RESERVED_LEN 4 // at least 4 bytes // TODO: increase this value if needed -#define FP_MESSAGE_STREAM_MAX_ADDITIONAL_DATA_LEN 16 -typedef struct -{ - uint8_t messageGroup; - uint8_t messageCode; - uint8_t dataLenHighByte; - uint8_t dataLenLowByte; - uint8_t data[FP_MESSAGE_STREAM_MAX_ADDITIONAL_DATA_LEN]; -} __attribute__((packed)) FP_MESSAGE_STREAM_T; +#define FP_MESSAGE_STREAM_MAX_ADDITIONAL_DATA_LEN 16 +typedef struct { + uint8_t messageGroup; + uint8_t messageCode; + uint8_t dataLenHighByte; + uint8_t dataLenLowByte; + uint8_t data[FP_MESSAGE_STREAM_MAX_ADDITIONAL_DATA_LEN]; +} __attribute__((packed)) FP_MESSAGE_STREAM_T; // The values is posted at FP spec 8/27/19 revision -#define FP_MSG_GROUP_BLUETOOTH_EVENT 0x01 -#define FP_MSG_BT_EVENT_ENABLE_SILENCE_MODE 0x01 -#define FP_MSG_BT_EVENT_DISABLE_SILENCE_MODE 0x02 +#define FP_MSG_GROUP_BLUETOOTH_EVENT 0x01 +#define FP_MSG_BT_EVENT_ENABLE_SILENCE_MODE 0x01 +#define FP_MSG_BT_EVENT_DISABLE_SILENCE_MODE 0x02 -#define FP_MSG_GROUP_COMPANION_APP_EVENT 0x02 -#define FP_MSG_COMPANION_APP_LOG_BUF_FULL 0x01 +#define FP_MSG_GROUP_COMPANION_APP_EVENT 0x02 +#define FP_MSG_COMPANION_APP_LOG_BUF_FULL 0x01 -#define FP_MSG_GROUP_DEVICE_INFO 0x03 -#define FP_MSG_DEVICE_INFO_MODEL_ID 0x01 -#define FP_MSG_DEVICE_INFO_BLE_ADD_UPDATED 0x02 -#define FP_MSG_DEVICE_INFO_BATTERY_UPDATED 0x03 -#define FP_MSG_DEVICE_INFO_REMAINING_BATTERY_TIME 0x04 -#define FP_MSG_DEVICE_INFO_ACTIVE_COMPONENTS_REQ 0x05 -#define FP_MSG_DEVICE_INFO_ACTIVE_COMPONENTS_RSP 0x06 -#define FP_MSG_DEVICE_INFO_TELL_CAPABILITIES 0x07 -#define FP_MSG_DEVICE_INFO_PLATFORM_TYPE 0x08 +#define FP_MSG_GROUP_DEVICE_INFO 0x03 +#define FP_MSG_DEVICE_INFO_MODEL_ID 0x01 +#define FP_MSG_DEVICE_INFO_BLE_ADD_UPDATED 0x02 +#define FP_MSG_DEVICE_INFO_BATTERY_UPDATED 0x03 +#define FP_MSG_DEVICE_INFO_REMAINING_BATTERY_TIME 0x04 +#define FP_MSG_DEVICE_INFO_ACTIVE_COMPONENTS_REQ 0x05 +#define FP_MSG_DEVICE_INFO_ACTIVE_COMPONENTS_RSP 0x06 +#define FP_MSG_DEVICE_INFO_TELL_CAPABILITIES 0x07 +#define FP_MSG_DEVICE_INFO_PLATFORM_TYPE 0x08 -#define FP_MSG_GROUP_DEVICE_ACTION 0x04 -#define FP_MSG_DEVICE_ACTION_RING 0x01 +#define FP_MSG_GROUP_DEVICE_ACTION 0x04 +#define FP_MSG_DEVICE_ACTION_RING 0x01 -#define FP_MSG_NEITHER_BUD_ACTIVE 0x00 -#define FP_MSG_RIGHT_BUD_ACTIVE 0x01 -#define FP_MSG_LEFT_BUD_ACTIVE 0x02 -#define FP_MSG_BOTH_BUDS_ACTIVE 0x03 +#define FP_MSG_NEITHER_BUD_ACTIVE 0x00 +#define FP_MSG_RIGHT_BUD_ACTIVE 0x01 +#define FP_MSG_LEFT_BUD_ACTIVE 0x02 +#define FP_MSG_BOTH_BUDS_ACTIVE 0x03 -#define FP_MSG_GROUP_ACKNOWLEDGEMENT 0xFF -#define FP_MSG_ACK 0x01 -#define FP_MSG_NAK 0x02 +#define FP_MSG_GROUP_ACKNOWLEDGEMENT 0xFF +#define FP_MSG_ACK 0x01 +#define FP_MSG_NAK 0x02 -#define FP_MSG_NAK_REASON_NOT_SUPPORTED 0x00 -#define FP_MSG_NAK_REASON_DEVICE_BUSY 0x01 -#define FP_MSG_NAK_REASON_NOT_ALLOWED 0x02 +#define FP_MSG_NAK_REASON_NOT_SUPPORTED 0x00 +#define FP_MSG_NAK_REASON_DEVICE_BUSY 0x01 +#define FP_MSG_NAK_REASON_NOT_ALLOWED 0x02 #ifdef __cplusplus extern "C" { @@ -65,4 +66,4 @@ void app_fp_msg_send_battery_levels(void); } #endif -#endif // __APP_FP_RFCOMM_H__ +#endif // __APP_FP_RFCOMM_H__ diff --git a/services/bt_app/app_hfp.cpp b/services/bt_app/app_hfp.cpp index ca540be..c032c72 100644 --- a/services/bt_app/app_hfp.cpp +++ b/services/bt_app/app_hfp.cpp @@ -13,40 +13,40 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -//#include "mbed.h" -#include -#include "cmsis_os.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_trace.h" -#include "hal_cmu.h" -#include "hal_chipid.h" + #include "analog.h" #include "app_audio.h" #include "app_battery.h" #include "app_status_ind.h" +#include "audioflinger.h" #include "bluetooth.h" +#include "cmsis_os.h" +#include "hal_chipid.h" +#include "hal_cmu.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "lockcqueue.h" #include "nvrecord.h" -#include "nvrecord_env.h" #include "nvrecord_dev.h" +#include "nvrecord_env.h" +#include #if defined(NEW_NV_RECORD_ENABLED) #include "nvrecord_bt.h" #endif -#include "hfp_api.h" -#include "besbt.h" -#include "cqueue.h" -#include "btapp.h" #include "app_bt.h" -#include "apps.h" -#include "resources.h" -#include "app_bt_media_manager.h" -#include "bt_if.h" -#include "app_hfp.h" -#include "app_fp_rfcomm.h" -#include "os_api.h" #include "app_bt_func.h" +#include "app_bt_media_manager.h" +#include "app_fp_rfcomm.h" +#include "app_hfp.h" +#include "apps.h" +#include "besbt.h" +#include "bt_if.h" +#include "btapp.h" +#include "cqueue.h" +#include "hfp_api.h" +#include "os_api.h" +#include "resources.h" #ifdef BT_USB_AUDIO_DUAL_MODE #include "btusb_audio.h" #endif @@ -69,9 +69,9 @@ #endif #if defined(IBRT) +#include "app_ibrt_hf.h" #include "app_ibrt_if.h" #include "app_tws_ibrt_cmd_sync_hfp_status.h" -#include "app_ibrt_hf.h" #include "besaud_api.h" #endif @@ -85,15 +85,14 @@ #include "app_btmap_sms.h" #endif - #ifdef __INTERCONNECTION__ -#define HF_COMMAND_HUAWEI_BATTERY_HEAD "AT+HUAWEIBATTERY=" -#define BATTERY_REPORT_NUM 2 -#define BATTERY_REPORT_TYPE_BATTERY_LEVEL 1 -#define BATTERY_REPORT_KEY_LEFT_BATTERY_LEVEL 2 -#define BATTERY_REPORT_KEY_LEFT_CHARGE_STATE 3 +#define HF_COMMAND_HUAWEI_BATTERY_HEAD "AT+HUAWEIBATTERY=" +#define BATTERY_REPORT_NUM 2 +#define BATTERY_REPORT_TYPE_BATTERY_LEVEL 1 +#define BATTERY_REPORT_KEY_LEFT_BATTERY_LEVEL 2 +#define BATTERY_REPORT_KEY_LEFT_CHARGE_STATE 3 char ATCommand[42]; -const char* huawei_self_defined_command_response = "+HUAWEIBATTERY=OK"; +const char *huawei_self_defined_command_response = "+HUAWEIBATTERY=OK"; #endif /* hfp */ @@ -114,346 +113,338 @@ extern bool app_audio_list_playback_exist(void); extern "C" void app_exit_fastpairing_mode(void); #endif -extern void app_bt_profile_connect_manager_hf(enum BT_DEVICE_ID_T id, hf_chan_handle_t Chan, struct hfp_context *ctx); +extern void app_bt_profile_connect_manager_hf(enum BT_DEVICE_ID_T id, + hf_chan_handle_t Chan, + struct hfp_context *ctx); #ifdef __BT_ONE_BRING_TWO__ extern void hfcall_next_sta_handler(hf_event_t event); #endif #ifndef _SCO_BTPCM_CHANNEL_ -struct hf_sendbuff_control hf_sendbuff_ctrl; +struct hf_sendbuff_control hf_sendbuff_ctrl; #endif #ifdef __INTERACTION__ -const char* oppo_self_defined_command_response = "+VDSF:7"; +const char *oppo_self_defined_command_response = "+VDSF:7"; #endif #if defined(SCO_LOOP) #define HF_LOOP_CNT (20) #define HF_LOOP_SIZE (360) -static uint8_t hf_loop_buffer[HF_LOOP_CNT*HF_LOOP_SIZE]; +static uint8_t hf_loop_buffer[HF_LOOP_CNT * HF_LOOP_SIZE]; static uint32_t hf_loop_buffer_len[HF_LOOP_CNT]; static uint32_t hf_loop_buffer_valid = 1; static uint32_t hf_loop_buffer_size = 0; static char hf_loop_buffer_w_idx = 0; #endif -static void app_hfp_set_starting_media_pending_flag(bool isEnabled, uint8_t devId); +static void app_hfp_set_starting_media_pending_flag(bool isEnabled, + uint8_t devId); void app_hfp_resume_pending_voice_media(void); -static void app_hfp_mediaplay_delay_resume_timer_cb(void const *n) -{ - app_hfp_resume_pending_voice_media(); +static void app_hfp_mediaplay_delay_resume_timer_cb(void const *n) { + app_hfp_resume_pending_voice_media(); } -#define HFP_MEDIAPLAY_DELAY_RESUME_IN_MS 3000//This time must be greater than SOUND_CONNECTED play time. +#define HFP_MEDIAPLAY_DELAY_RESUME_IN_MS \ + 3000 // This time must be greater than SOUND_CONNECTED play time. static void app_hfp_mediaplay_delay_resume_timer_cb(void const *n); -osTimerDef (APP_HFP_MEDIAPLAY_DELAY_RESUME_TIMER, app_hfp_mediaplay_delay_resume_timer_cb); -osTimerId app_hfp_mediaplay_delay_resume_timer_id = NULL; +osTimerDef(APP_HFP_MEDIAPLAY_DELAY_RESUME_TIMER, + app_hfp_mediaplay_delay_resume_timer_cb); +osTimerId app_hfp_mediaplay_delay_resume_timer_id = NULL; #ifdef __IAG_BLE_INCLUDE__ static void app_hfp_resume_ble_adv(void); #endif -#define HFP_AUDIO_CLOSED_DELAY_RESUME_ADV_IN_MS 1500 +#define HFP_AUDIO_CLOSED_DELAY_RESUME_ADV_IN_MS 1500 static void app_hfp_audio_closed_delay_resume_ble_adv_timer_cb(void const *n); -osTimerDef (APP_HFP_AUDIO_CLOSED_DELAY_RESUME_BLE_ADV_TIMER, - app_hfp_audio_closed_delay_resume_ble_adv_timer_cb); -osTimerId app_hfp_audio_closed_delay_resume_ble_adv_timer_id = NULL; +osTimerDef(APP_HFP_AUDIO_CLOSED_DELAY_RESUME_BLE_ADV_TIMER, + app_hfp_audio_closed_delay_resume_ble_adv_timer_cb); +osTimerId app_hfp_audio_closed_delay_resume_ble_adv_timer_id = NULL; -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; #if defined(SUPPORT_BATTERY_REPORT) || defined(SUPPORT_HF_INDICATORS) #ifdef __BT_ONE_BRING_TWO__ - static uint8_t battery_level[BT_DEVICE_NUM] = {0xff, 0xff}; +static uint8_t battery_level[BT_DEVICE_NUM] = {0xff, 0xff}; #else - static uint8_t battery_level[BT_DEVICE_NUM] = {0xff}; +static uint8_t battery_level[BT_DEVICE_NUM] = {0xff}; #endif static uint8_t report_battery_level = 0xff; -void app_hfp_set_battery_level(uint8_t level) -{ - osapi_lock_stack(); - if (report_battery_level == 0xff) { - report_battery_level = level; - osapi_notify_evm(); - } - osapi_unlock_stack(); +void app_hfp_set_battery_level(uint8_t level) { + osapi_lock_stack(); + if (report_battery_level == 0xff) { + report_battery_level = level; + osapi_notify_evm(); + } + osapi_unlock_stack(); } -int app_hfp_battery_report_reset(uint8_t bt_device_id) -{ - ASSERT(bt_device_id < BT_DEVICE_NUM, "bt_device_id error"); - battery_level[bt_device_id] = 0xff; - return 0; +int app_hfp_battery_report_reset(uint8_t bt_device_id) { + ASSERT(bt_device_id < BT_DEVICE_NUM, "bt_device_id error"); + battery_level[bt_device_id] = 0xff; + return 0; } - #ifdef __INTERACTION_CUSTOMER_AT_COMMAND__ -#define HF_COMMAND_BATTERY_HEAD "AT+VDBTY=" -#define HF_COMMAND_VERSION_HEAD "AT+VDRV=" -#define HF_COMMAND_FEATURE_HEAD "AT+VDSF=" -#define REPORT_NUM 3 -#define LEFT_UNIT_REPORT 1 -#define RIGHT_UNIT_REPORT 2 -#define BOX_REPORT 3 +#define HF_COMMAND_BATTERY_HEAD "AT+VDBTY=" +#define HF_COMMAND_VERSION_HEAD "AT+VDRV=" +#define HF_COMMAND_FEATURE_HEAD "AT+VDSF=" +#define REPORT_NUM 3 +#define LEFT_UNIT_REPORT 1 +#define RIGHT_UNIT_REPORT 2 +#define BOX_REPORT 3 char ATCommand[42]; -bt_status_t Send_customer_battery_report_AT_command(hf_chan_handle_t chan_h, uint8_t level) -{ - TRACE(0,"Send battery report at commnad."); - /// head and keyNumber - sprintf(ATCommand, "%s%d", HF_COMMAND_BATTERY_HEAD,REPORT_NUM); - /// keys and corresponding values - sprintf(ATCommand, "%s,%d,%d,%d,%d,%d,%d\r", ATCommand, LEFT_UNIT_REPORT, level, RIGHT_UNIT_REPORT, level, BOX_REPORT, 9); - /// send AT command - return btif_hf_send_at_cmd(chan_h, ATCommand); +bt_status_t Send_customer_battery_report_AT_command(hf_chan_handle_t chan_h, + uint8_t level) { + TRACE(0, "Send battery report at commnad."); + /// head and keyNumber + sprintf(ATCommand, "%s%d", HF_COMMAND_BATTERY_HEAD, REPORT_NUM); + /// keys and corresponding values + sprintf(ATCommand, "%s,%d,%d,%d,%d,%d,%d\r", ATCommand, LEFT_UNIT_REPORT, + level, RIGHT_UNIT_REPORT, level, BOX_REPORT, 9); + /// send AT command + return btif_hf_send_at_cmd(chan_h, ATCommand); } -bt_status_t Send_customer_phone_feature_support_AT_command(hf_chan_handle_t chan_h, uint8_t val) -{ - TRACE(0,"Send_customer_phone_feature_support_AT_command."); - /// keys and corresponding values - sprintf(ATCommand, "%s%d\r", HF_COMMAND_FEATURE_HEAD,val); - /// send AT command - return btif_hf_send_at_cmd(chan_h, ATCommand); +bt_status_t +Send_customer_phone_feature_support_AT_command(hf_chan_handle_t chan_h, + uint8_t val) { + TRACE(0, "Send_customer_phone_feature_support_AT_command."); + /// keys and corresponding values + sprintf(ATCommand, "%s%d\r", HF_COMMAND_FEATURE_HEAD, val); + /// send AT command + return btif_hf_send_at_cmd(chan_h, ATCommand); } -bt_status_t Send_customer_version_report_AT_command(hf_chan_handle_t chan_h) -{ - TRACE(0,"Send version report at commnad."); - /// head and keyNumber - sprintf(ATCommand, "%s%d", HF_COMMAND_VERSION_HEAD,REPORT_NUM); - /// keys and corresponding values - sprintf(ATCommand, "%s,%d,%d,%d,%d,%d,%d\r", ATCommand, LEFT_UNIT_REPORT, 0x1111, RIGHT_UNIT_REPORT, 0x2222, BOX_REPORT,0x3333); - /// send AT command - return btif_hf_send_at_cmd(chan_h, ATCommand); +bt_status_t Send_customer_version_report_AT_command(hf_chan_handle_t chan_h) { + TRACE(0, "Send version report at commnad."); + /// head and keyNumber + sprintf(ATCommand, "%s%d", HF_COMMAND_VERSION_HEAD, REPORT_NUM); + /// keys and corresponding values + sprintf(ATCommand, "%s,%d,%d,%d,%d,%d,%d\r", ATCommand, LEFT_UNIT_REPORT, + 0x1111, RIGHT_UNIT_REPORT, 0x2222, BOX_REPORT, 0x3333); + /// send AT command + return btif_hf_send_at_cmd(chan_h, ATCommand); } #endif #ifdef __INTERCONNECTION__ -uint8_t ask_is_selfdefined_battery_report_AT_command_support(void) -{ - TRACE(0,"ask if mobile support self-defined at commnad."); - uint8_t *pSelfDefinedCommandSupport = app_battery_get_mobile_support_self_defined_command_p(); - *pSelfDefinedCommandSupport = 0; +uint8_t ask_is_selfdefined_battery_report_AT_command_support(void) { + TRACE(0, "ask if mobile support self-defined at commnad."); + uint8_t *pSelfDefinedCommandSupport = + app_battery_get_mobile_support_self_defined_command_p(); + *pSelfDefinedCommandSupport = 0; - sprintf(ATCommand, "%s?", HF_COMMAND_HUAWEI_BATTERY_HEAD); - btif_hf_send_at_cmd((hf_chan_handle_t)app_bt_device.hf_channel[BT_DEVICE_ID_1], ATCommand); + sprintf(ATCommand, "%s?", HF_COMMAND_HUAWEI_BATTERY_HEAD); + btif_hf_send_at_cmd( + (hf_chan_handle_t)app_bt_device.hf_channel[BT_DEVICE_ID_1], ATCommand); - return 0; + return 0; } +uint8_t send_selfdefined_battery_report_AT_command(void) { + uint8_t *pSelfDefinedCommandSupport = + app_battery_get_mobile_support_self_defined_command_p(); + uint8_t batteryInfo = 0; -uint8_t send_selfdefined_battery_report_AT_command(void) -{ - uint8_t *pSelfDefinedCommandSupport = app_battery_get_mobile_support_self_defined_command_p(); - uint8_t batteryInfo = 0; + if (*pSelfDefinedCommandSupport) { + app_battery_get_info(NULL, &batteryInfo, NULL); - if(*pSelfDefinedCommandSupport) - { - app_battery_get_info(NULL, &batteryInfo, NULL); + /// head and keyNumber + sprintf(ATCommand, "%s%d", HF_COMMAND_HUAWEI_BATTERY_HEAD, + BATTERY_REPORT_NUM); - /// head and keyNumber - sprintf(ATCommand, "%s%d", HF_COMMAND_HUAWEI_BATTERY_HEAD, BATTERY_REPORT_NUM); + /// keys and corresponding values + sprintf(ATCommand, "%s,%d,%d,%d,%d", ATCommand, + BATTERY_REPORT_KEY_LEFT_BATTERY_LEVEL, batteryInfo & 0x7f, + BATTERY_REPORT_KEY_LEFT_CHARGE_STATE, (batteryInfo & 0x80) ? 1 : 0); - /// keys and corresponding values - sprintf(ATCommand, "%s,%d,%d,%d,%d", ATCommand, BATTERY_REPORT_KEY_LEFT_BATTERY_LEVEL, batteryInfo&0x7f, BATTERY_REPORT_KEY_LEFT_CHARGE_STATE, (batteryInfo&0x80)?1:0); - - /// send AT command - btif_hf_send_at_cmd((hf_chan_handle_t)app_bt_device.hf_channel[BT_DEVICE_ID_1], ATCommand); - } - return 0; + /// send AT command + btif_hf_send_at_cmd( + (hf_chan_handle_t)app_bt_device.hf_channel[BT_DEVICE_ID_1], ATCommand); + } + return 0; } #endif -int app_hfp_battery_report(uint8_t level) -{ - // Care: BT_DEVICE_NUM<-->{0xff, 0xff, ...} - bt_status_t status = BT_STS_LAST_CODE; - hf_chan_handle_t chan; +int app_hfp_battery_report(uint8_t level) { + // Care: BT_DEVICE_NUM<-->{0xff, 0xff, ...} + bt_status_t status = BT_STS_LAST_CODE; + hf_chan_handle_t chan; - uint8_t i; - int nRet = 0; + uint8_t i; + int nRet = 0; - if (level>9) - return -1; + if (level > 9) + return -1; - for(i=0; iclose"); + hf_id = BT_DEVICE_ID_1; + en = false; + hf_siri_chnl = app_bt_device.hf_channel[BT_DEVICE_ID_1]; } - if(open_siri_flag == 0){ - if(btif_hf_is_voice_rec_active(app_bt_device.hf_channel[BT_DEVICE_ID_1]) == true){ - TRACE(0,"1 ->close"); - hf_id = BT_DEVICE_ID_1; - en = false; - hf_siri_chnl = app_bt_device.hf_channel[BT_DEVICE_ID_1]; - } #ifdef __BT_ONE_BRING_TWO__ - else if(btif_hf_is_voice_rec_active(app_bt_device.hf_channel[BT_DEVICE_ID_2]) == true){ - TRACE(0,"2->close"); - hf_id = BT_DEVICE_ID_2; - en = false; - hf_siri_chnl = app_bt_device.hf_channel[BT_DEVICE_ID_2]; - } + else if (btif_hf_is_voice_rec_active( + app_bt_device.hf_channel[BT_DEVICE_ID_2]) == true) { + TRACE(0, "2->close"); + hf_id = BT_DEVICE_ID_2; + en = false; + hf_siri_chnl = app_bt_device.hf_channel[BT_DEVICE_ID_2]; + } #endif - else{ - open_siri_flag =1; - en = true; + else { + open_siri_flag = 1; + en = true; #ifdef __BT_ONE_BRING_TWO__ - hf_id = (enum BT_DEVICE_ID_T)app_hfp_get_chnl_via_remDev(&hf_siri_chnl); + hf_id = (enum BT_DEVICE_ID_T)app_hfp_get_chnl_via_remDev(&hf_siri_chnl); #else - hf_id = BT_DEVICE_ID_1; + hf_id = BT_DEVICE_ID_1; #endif - TRACE(1,"a2dp id = %d",hf_id); - } + TRACE(1, "a2dp id = %d", hf_id); } - TRACE(4,"[%s]id =%d/%d/%d",__func__,hf_id,open_siri_flag,en); - if(hf_id == BT_DEVICE_NUM) - hf_id = BT_DEVICE_ID_1; + } + TRACE(4, "[%s]id =%d/%d/%d", __func__, hf_id, open_siri_flag, en); + if (hf_id == BT_DEVICE_NUM) + hf_id = BT_DEVICE_ID_1; - if((btif_get_hf_chan_state(app_bt_device.hf_channel[hf_id]) == BTIF_HF_STATE_OPEN)) { - res = btif_hf_enable_voice_recognition(app_bt_device.hf_channel[hf_id], en); - } + if ((btif_get_hf_chan_state(app_bt_device.hf_channel[hf_id]) == + BTIF_HF_STATE_OPEN)) { + res = btif_hf_enable_voice_recognition(app_bt_device.hf_channel[hf_id], en); + } - TRACE(3,"[%s] Line =%d, res = %d", __func__, __LINE__, res); + TRACE(3, "[%s] Line =%d, res = %d", __func__, __LINE__, res); - return 0; + return 0; } #endif @@ -463,1078 +454,1117 @@ static enum BT_DEVICE_ID_T hfp_cur_call_chnl = BT_DEVICE_NUM; static int8_t cur_chnl_call_on_active[BT_DEVICE_NUM] = {0}; int app_bt_get_audio_up_id(void); -void app_hfp_3_way_call_counter_set(enum BT_DEVICE_ID_T id,uint8_t set) -{ - if (set > 0) { - cur_chnl_call_on_active[id]++; - if (cur_chnl_call_on_active[id] > BT_DEVICE_NUM) - cur_chnl_call_on_active[id] = 2; - } else { - cur_chnl_call_on_active[id]--; - if (cur_chnl_call_on_active[id] < 0) - cur_chnl_call_on_active[id] = 0; - if (app_bt_device.hfchan_call[id] == 1) - cur_chnl_call_on_active[id] = 1; - } - TRACE(1,"call_on_active = %d",cur_chnl_call_on_active[id]); +void app_hfp_3_way_call_counter_set(enum BT_DEVICE_ID_T id, uint8_t set) { + if (set > 0) { + cur_chnl_call_on_active[id]++; + if (cur_chnl_call_on_active[id] > BT_DEVICE_NUM) + cur_chnl_call_on_active[id] = 2; + } else { + cur_chnl_call_on_active[id]--; + if (cur_chnl_call_on_active[id] < 0) + cur_chnl_call_on_active[id] = 0; + if (app_bt_device.hfchan_call[id] == 1) + cur_chnl_call_on_active[id] = 1; + } + TRACE(1, "call_on_active = %d", cur_chnl_call_on_active[id]); } -void app_hfp_set_cur_chnl_id(uint8_t id) -{ - if (hfp_cur_call_chnl == BT_DEVICE_NUM) { - hfp_cur_call_chnl = (enum BT_DEVICE_ID_T)id; - cur_chnl_call_on_active[id] = 1; - } - TRACE(3,"%s hfp_cur_call_chnl = %d id=%d",__func__,hfp_cur_call_chnl,id); +void app_hfp_set_cur_chnl_id(uint8_t id) { + if (hfp_cur_call_chnl == BT_DEVICE_NUM) { + hfp_cur_call_chnl = (enum BT_DEVICE_ID_T)id; + cur_chnl_call_on_active[id] = 1; + } + TRACE(3, "%s hfp_cur_call_chnl = %d id=%d", __func__, hfp_cur_call_chnl, + id); } -uint8_t app_hfp_get_cur_call_chnl(void ** chnl) -{ - TRACE(2,"%s hfp_cur_call_chnl = %d",__func__,hfp_cur_call_chnl); - if(hfp_cur_call_chnl != BT_DEVICE_NUM){ - return hfp_cur_call_chnl; - } - return BT_DEVICE_NUM; +uint8_t app_hfp_get_cur_call_chnl(void **chnl) { + TRACE(2, "%s hfp_cur_call_chnl = %d", __func__, hfp_cur_call_chnl); + if (hfp_cur_call_chnl != BT_DEVICE_NUM) { + return hfp_cur_call_chnl; + } + return BT_DEVICE_NUM; } -void app_hfp_clear_cur_call_chnl(enum BT_DEVICE_ID_T id) -{ +void app_hfp_clear_cur_call_chnl(enum BT_DEVICE_ID_T id) { + hfp_cur_call_chnl = BT_DEVICE_NUM; + cur_chnl_call_on_active[id] = 0; + TRACE(2, "%s id= %d", __func__, id); +} + +void app_hfp_cur_call_chnl_reset(enum BT_DEVICE_ID_T id) { + if (id == hfp_cur_call_chnl) hfp_cur_call_chnl = BT_DEVICE_NUM; - cur_chnl_call_on_active[id] = 0; - TRACE(2,"%s id= %d",__func__,id); + TRACE(3, "%s hfp_cur_call_chnl = %d id=%d", __func__, hfp_cur_call_chnl, + id); } -void app_hfp_cur_call_chnl_reset(enum BT_DEVICE_ID_T id) -{ - if(id == hfp_cur_call_chnl) - hfp_cur_call_chnl = BT_DEVICE_NUM; - TRACE(3,"%s hfp_cur_call_chnl = %d id=%d",__func__,hfp_cur_call_chnl,id); -} - -bool app_hfp_cur_chnl_is_on_3_way_calling(void) -{ - uint8_t i = 0; - TRACE(1,"hfp_cur_call_chnl = %d",hfp_cur_call_chnl); +bool app_hfp_cur_chnl_is_on_3_way_calling(void) { + uint8_t i = 0; + TRACE(1, "hfp_cur_call_chnl = %d", hfp_cur_call_chnl); #ifdef __BT_ONE_BRING_TWO__ - TRACE(2,"cur_chnl_call_on_active[0] = %d [1] = %d",cur_chnl_call_on_active[0], - cur_chnl_call_on_active[1]); + TRACE(2, "cur_chnl_call_on_active[0] = %d [1] = %d", + cur_chnl_call_on_active[0], cur_chnl_call_on_active[1]); #else - TRACE(1,"cur_chnl_call_on_active[0] = %d",cur_chnl_call_on_active[0]); + TRACE(1, "cur_chnl_call_on_active[0] = %d", cur_chnl_call_on_active[0]); #endif - if(hfp_cur_call_chnl == BT_DEVICE_NUM) - return false; - for(i=0;i1){ - break; - } + if (hfp_cur_call_chnl == BT_DEVICE_NUM) + return false; + for (i = 0; i < BT_DEVICE_NUM; i++) { + if (cur_chnl_call_on_active[i] > 1) { + break; } - if(i == BT_DEVICE_NUM) - return false; - return true; + } + if (i == BT_DEVICE_NUM) + return false; + return true; } #endif #if !defined(FPGA) && defined(__BTIF_EARPHONE__) -static void hfp_app_status_indication(enum BT_DEVICE_ID_T chan_id, struct hfp_context *ctx) -{ +static void hfp_app_status_indication(enum BT_DEVICE_ID_T chan_id, + struct hfp_context *ctx) { #ifdef __BT_ONE_BRING_TWO__ - enum BT_DEVICE_ID_T chan_id_other = (chan_id==BT_DEVICE_ID_1)?(BT_DEVICE_ID_2):(BT_DEVICE_ID_1); + enum BT_DEVICE_ID_T chan_id_other = + (chan_id == BT_DEVICE_ID_1) ? (BT_DEVICE_ID_2) : (BT_DEVICE_ID_1); #else - enum BT_DEVICE_ID_T chan_id_other =BT_DEVICE_ID_1; + enum BT_DEVICE_ID_T chan_id_other = BT_DEVICE_ID_1; #endif - switch(ctx->event) - { - /* - case HF_EVENT_SERVICE_CONNECTED: - break; - case HF_EVENT_SERVICE_DISCONNECTED: - break; - */ - case BTIF_HF_EVENT_CURRENT_CALL_STATE: - TRACE(2,"!!!HF_EVENT_CURRENT_CALL_STATE chan_id:%d, call_number:%s\n", chan_id, ctx->call_number); - if(app_bt_device.hfchan_callSetup[chan_id] == BTIF_HF_CALL_SETUP_IN){ - //////report incoming call number - //app_status_set_num(ctx->call_number); + switch (ctx->event) { + /* + case HF_EVENT_SERVICE_CONNECTED: + break; + case HF_EVENT_SERVICE_DISCONNECTED: + break; + */ + case BTIF_HF_EVENT_CURRENT_CALL_STATE: + TRACE(2, "!!!HF_EVENT_CURRENT_CALL_STATE chan_id:%d, call_number:%s\n", + chan_id, ctx->call_number); + if (app_bt_device.hfchan_callSetup[chan_id] == BTIF_HF_CALL_SETUP_IN) { + //////report incoming call number + // app_status_set_num(ctx->call_number); #ifdef __BT_WARNING_TONE_MERGE_INTO_STREAM_SBC__ - app_voice_report(APP_STATUS_RING_WARNING,chan_id); + app_voice_report(APP_STATUS_RING_WARNING, chan_id); #endif - } - break; - case BTIF_HF_EVENT_CALL_IND: - if(ctx->call == BTIF_HF_CALL_NONE && app_bt_device.hfchan_call[chan_id] == BTIF_HF_CALL_ACTIVE){ - //////report call hangup voice - TRACE(1,"!!!HF_EVENT_CALL_IND APP_STATUS_INDICATION_HANGUPCALL chan_id:%d\n",chan_id); - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP_MEDIA,BT_STREAM_VOICE,chan_id,0); - ///disable media prompt - if(app_bt_device.hf_endcall_dis[chan_id] == false) - { - TRACE(0,"HANGUPCALL PROMPT"); - //app_voice_report(APP_STATUS_INDICATION_HANGUPCALL,chan_id); - } + } + break; + case BTIF_HF_EVENT_CALL_IND: + if (ctx->call == BTIF_HF_CALL_NONE && + app_bt_device.hfchan_call[chan_id] == BTIF_HF_CALL_ACTIVE) { + //////report call hangup voice + TRACE(1, + "!!!HF_EVENT_CALL_IND APP_STATUS_INDICATION_HANGUPCALL " + "chan_id:%d\n", + chan_id); + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP_MEDIA, + BT_STREAM_VOICE, chan_id, 0); + /// disable media prompt + if (app_bt_device.hf_endcall_dis[chan_id] == false) { + TRACE(0, "HANGUPCALL PROMPT"); + // app_voice_report(APP_STATUS_INDICATION_HANGUPCALL,chan_id); + } #if defined(_THREE_WAY_ONE_CALL_COUNT__) - if(app_hfp_get_cur_call_chnl(NULL) == chan_id){ - app_hfp_clear_cur_call_chnl(chan_id); - } + if (app_hfp_get_cur_call_chnl(NULL) == chan_id) { + app_hfp_clear_cur_call_chnl(chan_id); + } #endif - } + } #if defined(_THREE_WAY_ONE_CALL_COUNT__) - else if((ctx->call == BTIF_HF_CALL_ACTIVE) && - (app_bt_get_audio_up_id() == chan_id)) - { - app_hfp_set_cur_chnl_id(chan_id); - } + else if ((ctx->call == BTIF_HF_CALL_ACTIVE) && + (app_bt_get_audio_up_id() == chan_id)) { + app_hfp_set_cur_chnl_id(chan_id); + } #endif - break; - case BTIF_HF_EVENT_CALLSETUP_IND: - if(ctx->call_setup == BTIF_HF_CALL_SETUP_NONE && - (app_bt_device.hfchan_call[chan_id] != BTIF_HF_CALL_ACTIVE) && - (app_bt_device.hfchan_callSetup[chan_id] != BTIF_HF_CALL_SETUP_NONE)) { - ////check the call refuse and stop media of (ring and call number) - TRACE(1,"!!!HF_EVENT_CALLSETUP_IND APP_STATUS_INDICATION_REFUSECALL chan_id:%d\n",chan_id); - #if 0//def __BT_ONE_BRING_TWO__ + break; + case BTIF_HF_EVENT_CALLSETUP_IND: + if (ctx->call_setup == BTIF_HF_CALL_SETUP_NONE && + (app_bt_device.hfchan_call[chan_id] != BTIF_HF_CALL_ACTIVE) && + (app_bt_device.hfchan_callSetup[chan_id] != BTIF_HF_CALL_SETUP_NONE)) { + ////check the call refuse and stop media of (ring and call number) + TRACE(1, + "!!!HF_EVENT_CALLSETUP_IND APP_STATUS_INDICATION_REFUSECALL " + "chan_id:%d\n", + chan_id); +#if 0 // def __BT_ONE_BRING_TWO__ if (app_bt_device.hf_audio_state[chan_id_other] == BTIF_HF_AUDIO_DISCON){ app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP_MEDIA,BT_STREAM_VOICE,chan_id,0); app_voice_report(APP_STATUS_INDICATION_REFUSECALL,chan_id); } - #else - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP_MEDIA,BT_STREAM_VOICE,chan_id,0); +#else + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP_MEDIA, + BT_STREAM_VOICE, chan_id, 0); #if !defined(IBRT) && defined(MEDIA_PLAYER_SUPPORT) - app_voice_report(APP_STATUS_INDICATION_REFUSECALL,chan_id);/////////////du���� + app_voice_report(APP_STATUS_INDICATION_REFUSECALL, + chan_id); /////////////du���� #endif - #endif - if((app_bt_device.hfchan_call[chan_id_other] == BTIF_HF_CALL_ACTIVE) && - (app_bt_device.hf_audio_state[chan_id_other] == BTIF_HF_AUDIO_CON)){ - app_bt_device.curr_hf_channel_id = chan_id_other; - } - }else if(ctx->call_setup == BTIF_HF_CALL_SETUP_NONE && - (app_bt_device.hfchan_callSetup[chan_id] != BTIF_HF_CALL_SETUP_NONE) && - (app_bt_device.hfchan_call[chan_id] == BTIF_HF_CALL_ACTIVE)){ - TRACE(1,"!!!HF_EVENT_CALLSETUP_IND APP_STATUS_INDICATION_ANSWERCALL but noneed sco chan_id:%d\n",chan_id); +#endif + if ((app_bt_device.hfchan_call[chan_id_other] == BTIF_HF_CALL_ACTIVE) && + (app_bt_device.hf_audio_state[chan_id_other] == BTIF_HF_AUDIO_CON)) { + app_bt_device.curr_hf_channel_id = chan_id_other; + } + } else if (ctx->call_setup == BTIF_HF_CALL_SETUP_NONE && + (app_bt_device.hfchan_callSetup[chan_id] != + BTIF_HF_CALL_SETUP_NONE) && + (app_bt_device.hfchan_call[chan_id] == BTIF_HF_CALL_ACTIVE)) { + TRACE(1, + "!!!HF_EVENT_CALLSETUP_IND APP_STATUS_INDICATION_ANSWERCALL but " + "noneed sco chan_id:%d\n", + chan_id); #ifdef _THREE_WAY_ONE_CALL_COUNT__ - if(app_bt_device.hf_callheld[chan_id] == BTIF_HF_CALL_HELD_NONE) { - if(app_hfp_get_cur_call_chnl(NULL) == chan_id) { - app_hfp_3_way_call_counter_set(chan_id,0); - } - } + if (app_bt_device.hf_callheld[chan_id] == BTIF_HF_CALL_HELD_NONE) { + if (app_hfp_get_cur_call_chnl(NULL) == chan_id) { + app_hfp_3_way_call_counter_set(chan_id, 0); + } + } #endif /* _THREE_WAY_ONE_CALL_COUNT__ */ #ifdef MEDIA_PLAYER_SUPPORT - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP_MEDIA, BT_STREAM_MEDIA ,chan_id, 0); + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP_MEDIA, + BT_STREAM_MEDIA, chan_id, 0); #endif - } -#if defined(_THREE_WAY_ONE_CALL_COUNT__) - else if((ctx->call_setup != BTIF_HF_CALL_SETUP_NONE) && - (app_bt_device.hfchan_call[chan_id] == BTIF_HF_CALL_ACTIVE)){ - if(app_hfp_get_cur_call_chnl(NULL) == chan_id){ - app_hfp_3_way_call_counter_set(chan_id,1); - } - } -#endif - break; - /* - case HF_EVENT_AUDIO_CONNECTED: - TRACE(1,"!!!HF_EVENT_AUDIO_CONNECTED APP_STATUS_INDICATION_ANSWERCALL chan_id:%d\n",chan_id); - // app_voice_report(APP_STATUS_INDICATION_ANSWERCALL,chan_id);//////////////duһ�� - break; - */ - case BTIF_HF_EVENT_RING_IND: -#ifdef MEDIA_PLAYER_SUPPORT - app_voice_report(APP_STATUS_INDICATION_INCOMINGCALL,chan_id); -#endif - break; - default: - break; } +#if defined(_THREE_WAY_ONE_CALL_COUNT__) + else if ((ctx->call_setup != BTIF_HF_CALL_SETUP_NONE) && + (app_bt_device.hfchan_call[chan_id] == BTIF_HF_CALL_ACTIVE)) { + if (app_hfp_get_cur_call_chnl(NULL) == chan_id) { + app_hfp_3_way_call_counter_set(chan_id, 1); + } + } +#endif + break; + /* +case HF_EVENT_AUDIO_CONNECTED: + TRACE(1,"!!!HF_EVENT_AUDIO_CONNECTED APP_STATUS_INDICATION_ANSWERCALL +chan_id:%d\n",chan_id); + // +app_voice_report(APP_STATUS_INDICATION_ANSWERCALL,chan_id);//////////////duһ�� + break; + */ + case BTIF_HF_EVENT_RING_IND: +#ifdef MEDIA_PLAYER_SUPPORT + app_voice_report(APP_STATUS_INDICATION_INCOMINGCALL, chan_id); +#endif + break; + default: + break; + } } #endif - struct BT_DEVICE_ID_DIFF chan_id_flag; #ifdef __BT_ONE_BRING_TWO__ -void hfp_chan_id_distinguish(hf_chan_handle_t chan) -{ - if(chan == app_bt_device.hf_channel[BT_DEVICE_ID_1]){ - chan_id_flag.id = BT_DEVICE_ID_1; - }else if(chan == app_bt_device.hf_channel[BT_DEVICE_ID_2]){ - chan_id_flag.id = BT_DEVICE_ID_2; - } +void hfp_chan_id_distinguish(hf_chan_handle_t chan) { + if (chan == app_bt_device.hf_channel[BT_DEVICE_ID_1]) { + chan_id_flag.id = BT_DEVICE_ID_1; + } else if (chan == app_bt_device.hf_channel[BT_DEVICE_ID_2]) { + chan_id_flag.id = BT_DEVICE_ID_2; + } } #endif -int hfp_volume_get(enum BT_DEVICE_ID_T id) -{ - int vol = TGT_VOLUME_LEVEL_15; +int hfp_volume_get(enum BT_DEVICE_ID_T id) { + int vol = TGT_VOLUME_LEVEL_15; - nvrec_btdevicerecord *record = NULL; - bt_bdaddr_t bdAdd; - if (btif_hf_get_remote_bdaddr(app_bt_device.hf_channel[id], &bdAdd) && !nv_record_btdevicerecord_find(&bdAdd,&record)){ - vol = record->device_vol.hfp_vol - 2; - }else if (app_audio_manager_hfp_is_active(id)){ - vol = app_bt_stream_hfpvolume_get() - 2; - }else{ - vol = TGT_VOLUME_LEVEL_15; - } + nvrec_btdevicerecord *record = NULL; + bt_bdaddr_t bdAdd; + if (btif_hf_get_remote_bdaddr(app_bt_device.hf_channel[id], &bdAdd) && + !nv_record_btdevicerecord_find(&bdAdd, &record)) { + vol = record->device_vol.hfp_vol - 2; + } else if (app_audio_manager_hfp_is_active(id)) { + vol = app_bt_stream_hfpvolume_get() - 2; + } else { + vol = TGT_VOLUME_LEVEL_15; + } - if (vol > 15) - vol = 15; - if (vol < 0) - vol = 0; + if (vol > 15) + vol = 15; + if (vol < 0) + vol = 0; #ifndef BES_AUTOMATE_TEST - TRACE(2,"hfp get vol raw:%d loc:%d", vol, vol+2); + TRACE(2, "hfp get vol raw:%d loc:%d", vol, vol + 2); #endif - return (vol); + return (vol); } -void hfp_volume_local_set(enum BT_DEVICE_ID_T id, int8_t vol) -{ - nvrec_btdevicerecord *record = NULL; - bt_bdaddr_t bdAdd; - if (btif_hf_get_remote_bdaddr(app_bt_device.hf_channel[id], &bdAdd)){ - if (!nv_record_btdevicerecord_find(&bdAdd,&record)){ - nv_record_btdevicerecord_set_hfp_vol(record, vol); - } +void hfp_volume_local_set(enum BT_DEVICE_ID_T id, int8_t vol) { + nvrec_btdevicerecord *record = NULL; + bt_bdaddr_t bdAdd; + if (btif_hf_get_remote_bdaddr(app_bt_device.hf_channel[id], &bdAdd)) { + if (!nv_record_btdevicerecord_find(&bdAdd, &record)) { + nv_record_btdevicerecord_set_hfp_vol(record, vol); } + } - if(app_bt_stream_volume_get_ptr()->hfp_vol != vol){ + if (app_bt_stream_volume_get_ptr()->hfp_vol != vol) { #if defined(NEW_NV_RECORD_ENABLED) - nv_record_btdevicevolume_set_hfp_vol(app_bt_stream_volume_get_ptr(), vol); + nv_record_btdevicevolume_set_hfp_vol(app_bt_stream_volume_get_ptr(), vol); #endif #ifndef FPGA - nv_record_touch_cause_flush(); + nv_record_touch_cause_flush(); #endif - } + } } -int hfp_volume_set(enum BT_DEVICE_ID_T id, int vol) -{ - if (vol > 15) - vol = 15; - if (vol < 0) - vol = 0; +int hfp_volume_set(enum BT_DEVICE_ID_T id, int vol) { + if (vol > 15) + vol = 15; + if (vol < 0) + vol = 0; - hfp_volume_local_set(id, vol+2); - if (app_audio_manager_hfp_is_active(id)){ - app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_SET, vol+2); - } + hfp_volume_local_set(id, vol + 2); + if (app_audio_manager_hfp_is_active(id)) { + app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_SET, vol + 2); + } - TRACE(2,"hfp put vol raw:%d loc:%d", vol, vol+2); - return 0; + TRACE(2, "hfp put vol raw:%d loc:%d", vol, vol + 2); + return 0; } static uint8_t call_setup_running_on = 0; -void hfp_call_setup_running_on_set(uint8_t set) -{ - call_setup_running_on = set; +void hfp_call_setup_running_on_set(uint8_t set) { call_setup_running_on = set; } + +void hfp_call_setup_running_on_clr(void) { call_setup_running_on = 0; } + +uint8_t hfp_get_call_setup_running_on_state(void) { + TRACE(2, "%s state = %d", __func__, call_setup_running_on); + return call_setup_running_on; } -void hfp_call_setup_running_on_clr(void) -{ - call_setup_running_on = 0; -} - -uint8_t hfp_get_call_setup_running_on_state(void) -{ - TRACE(2,"%s state = %d",__func__,call_setup_running_on); - return call_setup_running_on; -} - -static void hfp_connected_ind_handler(hf_chan_handle_t chan, struct hfp_context *ctx) -{ +static void hfp_connected_ind_handler(hf_chan_handle_t chan, + struct hfp_context *ctx) { #ifdef __BT_ONE_BRING_TWO__ - enum BT_DEVICE_ID_T anotherDevice = (BT_DEVICE_ID_1 == chan_id_flag.id)?BT_DEVICE_ID_2:BT_DEVICE_ID_1; + enum BT_DEVICE_ID_T anotherDevice = + (BT_DEVICE_ID_1 == chan_id_flag.id) ? BT_DEVICE_ID_2 : BT_DEVICE_ID_1; #endif #ifdef GFPS_ENABLED - app_exit_fastpairing_mode(); + app_exit_fastpairing_mode(); #endif - app_bt_clear_connecting_profiles_state(chan_id_flag.id); + app_bt_clear_connecting_profiles_state(chan_id_flag.id); - TRACE(1,"::HF_EVENT_SERVICE_CONNECTED Chan_id:%d\n", chan_id_flag.id); - app_bt_device.phone_earphone_mark = 1; + TRACE(1, "::HF_EVENT_SERVICE_CONNECTED Chan_id:%d\n", chan_id_flag.id); + app_bt_device.phone_earphone_mark = 1; #if !defined(FPGA) && defined(__BTIF_EARPHONE__) - if (ctx->state == BTIF_HF_STATE_OPEN) { - ////report connected voice - app_bt_device.hf_conn_flag[chan_id_flag.id] = 1; - } + if (ctx->state == BTIF_HF_STATE_OPEN) { + ////report connected voice + app_bt_device.hf_conn_flag[chan_id_flag.id] = 1; + } #endif #if defined(SUPPORT_BATTERY_REPORT) || defined(SUPPORT_HF_INDICATORS) - uint8_t battery_level; - app_hfp_battery_report_reset(chan_id_flag.id); - app_battery_get_info(NULL, &battery_level, NULL); - app_hfp_set_battery_level(battery_level); + uint8_t battery_level; + app_hfp_battery_report_reset(chan_id_flag.id); + app_battery_get_info(NULL, &battery_level, NULL); + app_hfp_set_battery_level(battery_level); #endif - // app_bt_stream_hfpvolume_reset(); - btif_hf_report_speaker_volume(chan, hfp_volume_get(chan_id_flag.id)); + // app_bt_stream_hfpvolume_reset(); + btif_hf_report_speaker_volume(chan, hfp_volume_get(chan_id_flag.id)); #if defined(HFP_DISABLE_NREC) - btif_hf_disable_nrec(chan); + btif_hf_disable_nrec(chan); #endif #ifdef __BT_ONE_BRING_TWO__ - ////if a call is active and start bt open reconnect procedure, process the curr_hf_channel_id - if((app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_CON) - ||(app_bt_device.hfchan_callSetup[anotherDevice] == BTIF_HF_CALL_SETUP_IN)){ - app_bt_device.curr_hf_channel_id = anotherDevice; - }else{ - app_bt_device.curr_hf_channel_id = chan_id_flag.id; - } + ////if a call is active and start bt open reconnect procedure, process the + /// curr_hf_channel_id + if ((app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_CON) || + (app_bt_device.hfchan_callSetup[anotherDevice] == + BTIF_HF_CALL_SETUP_IN)) { + app_bt_device.curr_hf_channel_id = anotherDevice; + } else { + app_bt_device.curr_hf_channel_id = chan_id_flag.id; + } #endif #if defined(__BTMAP_ENABLE__) && defined(BTIF_DIP_DEVICE) - if ((btif_dip_get_process_status(app_bt_get_remoteDev(chan_id_flag.id)))&& (app_btmap_check_is_idle(chan_id_flag.id))) - { - app_btmap_sms_open(chan_id_flag.id, &ctx->remote_dev_bdaddr); - } + if ((btif_dip_get_process_status(app_bt_get_remoteDev(chan_id_flag.id))) && + (app_btmap_check_is_idle(chan_id_flag.id))) { + app_btmap_sms_open(chan_id_flag.id, &ctx->remote_dev_bdaddr); + } #endif - app_bt_profile_connect_manager_hf(chan_id_flag.id, chan, ctx); + app_bt_profile_connect_manager_hf(chan_id_flag.id, chan, ctx); #ifdef __INTERCONNECTION__ - ask_is_selfdefined_battery_report_AT_command_support(); + ask_is_selfdefined_battery_report_AT_command_support(); #endif #ifdef __INTERACTION_CUSTOMER_AT_COMMAND__ - Send_customer_phone_feature_support_AT_command(chan,7); - Send_customer_battery_report_AT_command(chan, battery_level); + Send_customer_phone_feature_support_AT_command(chan, 7); + Send_customer_battery_report_AT_command(chan, battery_level); #endif } -static void hfp_disconnected_ind_handler(hf_chan_handle_t chan, struct hfp_context *ctx) -{ - TRACE(2,"::HF_EVENT_SERVICE_DISCONNECTED Chan_id:%d, reason=%x\n", chan_id_flag.id, ctx->disc_reason); +static void hfp_disconnected_ind_handler(hf_chan_handle_t chan, + struct hfp_context *ctx) { + TRACE(2, "::HF_EVENT_SERVICE_DISCONNECTED Chan_id:%d, reason=%x\n", + chan_id_flag.id, ctx->disc_reason); #if defined(HFP_1_6_ENABLE) - btif_hf_set_negotiated_codec(chan, BTIF_HF_SCO_CODEC_CVSD); + btif_hf_set_negotiated_codec(chan, BTIF_HF_SCO_CODEC_CVSD); #endif #if !defined(FPGA) && defined(__BTIF_EARPHONE__) - if(app_bt_device.hf_conn_flag[chan_id_flag.id] ){ - ////report device disconnected voice - app_bt_device.hf_conn_flag[chan_id_flag.id] = 0; - } + if (app_bt_device.hf_conn_flag[chan_id_flag.id]) { + ////report device disconnected voice + app_bt_device.hf_conn_flag[chan_id_flag.id] = 0; + } #endif - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP,BT_STREAM_VOICE,chan_id_flag.id,MAX_RECORD_NUM); - for (uint8_t i=0; iaudio_data, ctx->audio_data_len); + uint32_t idx = 0; + if (app_bt_stream_isrun(APP_BT_STREAM_HFP_PCM)) { + store_voicebtpcm_m2p_buffer(ctx->audio_data, ctx->audio_data_len); - idx = hf_sendbuff_ctrl.index % HF_SENDBUFF_MEMPOOL_NUM; - get_voicebtpcm_p2m_frame(&(hf_sendbuff_ctrl.mempool[idx].buffer[0]), ctx->audio_data_len); - hf_sendbuff_ctrl.mempool[idx].packet.data = &(hf_sendbuff_ctrl.mempool[idx].buffer[0]); - hf_sendbuff_ctrl.mempool[idx].packet.dataLen = ctx->audio_data_len; - hf_sendbuff_ctrl.mempool[idx].packet.flags = BTIF_BTP_FLAG_NONE; - if(!app_bt_device.hf_mute_flag){ - btif_hf_send_audio_data(chan, &hf_sendbuff_ctrl.mempool[idx].packet); - } - hf_sendbuff_ctrl.index++; - } + idx = hf_sendbuff_ctrl.index % HF_SENDBUFF_MEMPOOL_NUM; + get_voicebtpcm_p2m_frame(&(hf_sendbuff_ctrl.mempool[idx].buffer[0]), + ctx->audio_data_len); + hf_sendbuff_ctrl.mempool[idx].packet.data = + &(hf_sendbuff_ctrl.mempool[idx].buffer[0]); + hf_sendbuff_ctrl.mempool[idx].packet.dataLen = ctx->audio_data_len; + hf_sendbuff_ctrl.mempool[idx].packet.flags = BTIF_BTP_FLAG_NONE; + if (!app_bt_device.hf_mute_flag) { + btif_hf_send_audio_data(chan, &hf_sendbuff_ctrl.mempool[idx].packet); + } + hf_sendbuff_ctrl.index++; + } #endif #ifdef __BT_ONE_BRING_TWO__ - } + } #endif #if defined(SCO_LOOP) - memcpy(hf_loop_buffer + hf_loop_buffer_w_idx*HF_LOOP_SIZE, Info->p.audioData->data, Info->p.audioData->len); - hf_loop_buffer_len[hf_loop_buffer_w_idx] = Info->p.audioData->len; - hf_loop_buffer_w_idx = (hf_loop_buffer_w_idx+1)%HF_LOOP_CNT; - ++hf_loop_buffer_size; + memcpy(hf_loop_buffer + hf_loop_buffer_w_idx * HF_LOOP_SIZE, + Info->p.audioData->data, Info->p.audioData->len); + hf_loop_buffer_len[hf_loop_buffer_w_idx] = Info->p.audioData->len; + hf_loop_buffer_w_idx = (hf_loop_buffer_w_idx + 1) % HF_LOOP_CNT; + ++hf_loop_buffer_size; - if (hf_loop_buffer_size >= 18 && hf_loop_buffer_valid == 1) { - hf_loop_buffer_valid = 0; - idx = hf_loop_buffer_w_idx-17<0?(HF_LOOP_CNT-(17-hf_loop_buffer_w_idx)):hf_loop_buffer_w_idx-17; - pkt.flags = BTP_FLAG_NONE; - pkt.dataLen = hf_loop_buffer_len[idx]; - pkt.data = hf_loop_buffer + idx*HF_LOOP_SIZE; - HF_SendAudioData(Chan, &pkt); - } + if (hf_loop_buffer_size >= 18 && hf_loop_buffer_valid == 1) { + hf_loop_buffer_valid = 0; + idx = hf_loop_buffer_w_idx - 17 < 0 + ? (HF_LOOP_CNT - (17 - hf_loop_buffer_w_idx)) + : hf_loop_buffer_w_idx - 17; + pkt.flags = BTP_FLAG_NONE; + pkt.dataLen = hf_loop_buffer_len[idx]; + pkt.data = hf_loop_buffer + idx * HF_LOOP_SIZE; + HF_SendAudioData(Chan, &pkt); + } #endif } -static void hfp_call_ind_handler(hf_chan_handle_t chan, struct hfp_context *ctx) -{ +static void hfp_call_ind_handler(hf_chan_handle_t chan, + struct hfp_context *ctx) { #ifdef __BT_ONE_BRING_TWO__ - enum BT_DEVICE_ID_T anotherDevice = (BT_DEVICE_ID_1 == chan_id_flag.id)?BT_DEVICE_ID_2:BT_DEVICE_ID_1; + enum BT_DEVICE_ID_T anotherDevice = + (BT_DEVICE_ID_1 == chan_id_flag.id) ? BT_DEVICE_ID_2 : BT_DEVICE_ID_1; #endif #ifdef __BT_ONE_BRING_TWO__ - TRACE(8,"::HF_EVENT_CALL_IND %d chan_id %dx call %d %d held %d %d audio_state %d %d\n", - ctx->call, chan_id_flag.id, - app_bt_device.hfchan_call[BT_DEVICE_ID_1], app_bt_device.hfchan_call[BT_DEVICE_ID_2], - app_bt_device.hf_callheld[BT_DEVICE_ID_1], app_bt_device.hf_callheld[BT_DEVICE_ID_2], - app_bt_device.hf_audio_state[BT_DEVICE_ID_1], app_bt_device.hf_audio_state[BT_DEVICE_ID_2]); + TRACE(8, + "::HF_EVENT_CALL_IND %d chan_id %dx call %d %d held %d %d audio_state " + "%d %d\n", + ctx->call, chan_id_flag.id, app_bt_device.hfchan_call[BT_DEVICE_ID_1], + app_bt_device.hfchan_call[BT_DEVICE_ID_2], + app_bt_device.hf_callheld[BT_DEVICE_ID_1], + app_bt_device.hf_callheld[BT_DEVICE_ID_2], + app_bt_device.hf_audio_state[BT_DEVICE_ID_1], + app_bt_device.hf_audio_state[BT_DEVICE_ID_2]); #else - TRACE(2,"::HF_EVENT_CALL_IND chan_id:%d, call:%d\n",chan_id_flag.id, ctx->call); + TRACE(2, "::HF_EVENT_CALL_IND chan_id:%d, call:%d\n", chan_id_flag.id, + ctx->call); #endif - if(ctx->call == BTIF_HF_CALL_NONE) - { - hfp_call_setup_running_on_clr(); + if (ctx->call == BTIF_HF_CALL_NONE) { + hfp_call_setup_running_on_clr(); #if defined(_AUTO_TEST_) - AUTO_TEST_SEND("Call hangup ok."); + AUTO_TEST_SEND("Call hangup ok."); #endif - app_bt_device.hf_callheld[chan_id_flag.id] = BTIF_HF_CALL_HELD_NONE; - } - else if(ctx->call == BTIF_HF_CALL_ACTIVE) - { + app_bt_device.hf_callheld[chan_id_flag.id] = BTIF_HF_CALL_HELD_NONE; + } else if (ctx->call == BTIF_HF_CALL_ACTIVE) { #if defined(_AUTO_TEST_) - AUTO_TEST_SEND("Call setup ok."); + AUTO_TEST_SEND("Call setup ok."); #endif - ///call is active so check if it's a outgoing call - if(app_bt_device.hfchan_callSetup[chan_id_flag.id] == BTIF_HF_CALL_SETUP_ALERT) - { - TRACE(1,"HF CALLACTIVE TIME=%d",hal_sys_timer_get()); - if(TICKS_TO_MS(hal_sys_timer_get()-app_bt_device.hf_callsetup_time[chan_id_flag.id])<1000) - { - TRACE(0,"DISABLE HANGUPCALL PROMPT"); - app_bt_device.hf_endcall_dis[chan_id_flag.id] = true; - } - } - /////stop media of (ring and call number) and switch to sco -#if defined (HFP_NO_PRERMPT) - if(app_bt_device.hfchan_call[anotherDevice] == BTIF_HF_CALL_ACTIVE){ - }else + /// call is active so check if it's a outgoing call + if (app_bt_device.hfchan_callSetup[chan_id_flag.id] == + BTIF_HF_CALL_SETUP_ALERT) { + TRACE(1, "HF CALLACTIVE TIME=%d", hal_sys_timer_get()); + if (TICKS_TO_MS(hal_sys_timer_get() - + app_bt_device.hf_callsetup_time[chan_id_flag.id]) < + 1000) { + TRACE(0, "DISABLE HANGUPCALL PROMPT"); + app_bt_device.hf_endcall_dis[chan_id_flag.id] = true; + } + } + /////stop media of (ring and call number) and switch to sco +#if defined(HFP_NO_PRERMPT) + if (app_bt_device.hfchan_call[anotherDevice] == BTIF_HF_CALL_ACTIVE) { + } else #endif - { + { #ifdef __BT_ONE_BRING_TWO__ - TRACE(1,"%s another %d,hf_callheld %d",__func__,anotherDevice,app_bt_device.hf_callheld[anotherDevice]); - if((btapp_hfp_get_call_state()) - &&(app_bt_device.hf_callheld[anotherDevice] == BTIF_HF_CALL_HELD_NONE)) + TRACE(1, "%s another %d,hf_callheld %d", __func__, anotherDevice, + app_bt_device.hf_callheld[anotherDevice]); + if ((btapp_hfp_get_call_state()) && + (app_bt_device.hf_callheld[anotherDevice] == BTIF_HF_CALL_HELD_NONE)) #else - if(btapp_hfp_get_call_state()) + if (btapp_hfp_get_call_state()) #endif - { - TRACE(0,"DON'T SIWTCH_TO_SCO"); - app_bt_device.hfchan_call[chan_id_flag.id] = ctx->call; - return; - } - else - { + { + TRACE(0, "DON'T SIWTCH_TO_SCO"); + app_bt_device.hfchan_call[chan_id_flag.id] = ctx->call; + return; + } else { #ifndef ENABLE_HFP_AUDIO_PENDING_FOR_MEDIA - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_SWITCHTO_SCO,BT_STREAM_VOICE,chan_id_flag.id,0); + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_SWITCHTO_SCO, + BT_STREAM_VOICE, chan_id_flag.id, 0); #endif - } - } - } - else - { + } + } + } else { #if defined(_AUTO_TEST_) - AUTO_TEST_SEND("Call hangup ok."); + AUTO_TEST_SEND("Call hangup ok."); #endif - } - + } #if !defined(FPGA) && defined(__BTIF_EARPHONE__) - hfp_app_status_indication(chan_id_flag.id, ctx); + hfp_app_status_indication(chan_id_flag.id, ctx); #endif - - if(ctx->call == BTIF_HF_CALL_ACTIVE){ -#if defined (HFP_NO_PRERMPT) + if (ctx->call == BTIF_HF_CALL_ACTIVE) { +#if defined(HFP_NO_PRERMPT) #else - app_bt_device.curr_hf_channel_id = chan_id_flag.id; + app_bt_device.curr_hf_channel_id = chan_id_flag.id; #endif - } + } #ifdef __BT_ONE_BRING_TWO__ - else if((ctx->call == BTIF_HF_CALL_NONE)&& - ((app_bt_device.hfchan_call[anotherDevice] == BTIF_HF_CALL_ACTIVE)|| - (app_bt_device.hfchan_callSetup[anotherDevice] == BTIF_HF_CALL_SETUP_IN)|| - (app_bt_device.hfchan_callSetup[anotherDevice] == BTIF_HF_CALL_SETUP_OUT) || - (app_bt_device.hfchan_callSetup[anotherDevice] == BTIF_HF_CALL_SETUP_ALERT))){ - app_bt_device.curr_hf_channel_id = anotherDevice; - } + else if ((ctx->call == BTIF_HF_CALL_NONE) && + ((app_bt_device.hfchan_call[anotherDevice] == BTIF_HF_CALL_ACTIVE) || + (app_bt_device.hfchan_callSetup[anotherDevice] == + BTIF_HF_CALL_SETUP_IN) || + (app_bt_device.hfchan_callSetup[anotherDevice] == + BTIF_HF_CALL_SETUP_OUT) || + (app_bt_device.hfchan_callSetup[anotherDevice] == + BTIF_HF_CALL_SETUP_ALERT))) { + app_bt_device.curr_hf_channel_id = anotherDevice; + } #endif - TRACE(1,"!!!HF_EVENT_CALL_IND curr_hf_channel_id:%d\n",app_bt_device.curr_hf_channel_id); - app_bt_device.hfchan_call[chan_id_flag.id] = ctx->call; - if(ctx->call == BTIF_HF_CALL_NONE) - { - app_bt_device.hf_endcall_dis[chan_id_flag.id] = false; - } -#if defined( __BT_ONE_BRING_TWO__) - if(bt_get_sco_number() > 1 + TRACE(1, "!!!HF_EVENT_CALL_IND curr_hf_channel_id:%d\n", + app_bt_device.curr_hf_channel_id); + app_bt_device.hfchan_call[chan_id_flag.id] = ctx->call; + if (ctx->call == BTIF_HF_CALL_NONE) { + app_bt_device.hf_endcall_dis[chan_id_flag.id] = false; + } +#if defined(__BT_ONE_BRING_TWO__) + if (bt_get_sco_number() > 1 #ifdef CHIP_BEST1000 - && hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_2 + && hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_2 #endif - ){ - ////a call is active: - if(app_bt_device.hfchan_call[chan_id_flag.id] == BTIF_HF_CALL_ACTIVE){ + ) { + ////a call is active: + if (app_bt_device.hfchan_call[chan_id_flag.id] == BTIF_HF_CALL_ACTIVE) { #if !defined(HFP_NO_PRERMPT) - if(app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_CON){ - app_bt_device.curr_hf_channel_id = chan_id_flag.id; + if (app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_CON) { + app_bt_device.curr_hf_channel_id = chan_id_flag.id; #ifdef __HF_KEEP_ONE_ALIVE__ #ifdef ENABLE_HFP_AUDIO_PENDING_FOR_MEDIA - if (bt_media_cur_is_bt_stream_media()) - { - app_hfp_set_starting_media_pending_flag(true, chan_id_flag.id); - } - else + if (bt_media_cur_is_bt_stream_media()) { + app_hfp_set_starting_media_pending_flag(true, chan_id_flag.id); + } else #endif - { - app_hfp_start_voice_media(chan_id_flag.id); - } -#else - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_SWAP_SCO,BT_STREAM_SBC, chan_id_flag.id, 0); -#endif - } - app_bt_device.hf_voice_en[chan_id_flag.id] = HF_VOICE_ENABLE; - app_bt_device.hf_voice_en[anotherDevice] = HF_VOICE_DISABLE; -#endif - }else{ - ////a call is hung up: - ///if one device setup a sco connect so get the other device's sco state, if both connect mute the earlier one - if(app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_CON){ - app_bt_device.hf_voice_en[anotherDevice] = HF_VOICE_ENABLE; - app_bt_device.hf_voice_en[chan_id_flag.id] = HF_VOICE_DISABLE; - } + { + app_hfp_start_voice_media(chan_id_flag.id); } - } +#else + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_SWAP_SCO, + BT_STREAM_SBC, chan_id_flag.id, 0); #endif - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_UPDATE_MEDIA,BT_STREAM_VOICE,chan_id_flag.id,MAX_RECORD_NUM); + } + app_bt_device.hf_voice_en[chan_id_flag.id] = HF_VOICE_ENABLE; + app_bt_device.hf_voice_en[anotherDevice] = HF_VOICE_DISABLE; +#endif + } else { + ////a call is hung up: + /// if one device setup a sco connect so get the other device's sco + /// state, if both connect mute the earlier one + if (app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_CON) { + app_bt_device.hf_voice_en[anotherDevice] = HF_VOICE_ENABLE; + app_bt_device.hf_voice_en[chan_id_flag.id] = HF_VOICE_DISABLE; + } + } + } +#endif + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_UPDATE_MEDIA, + BT_STREAM_VOICE, chan_id_flag.id, + MAX_RECORD_NUM); } extern uint8_t once_event_case; extern void startonce_delay_event_Timer_(int ms); extern void bt_drv_clear_skip_flag(); -static void hfp_callsetup_ind_handler(hf_chan_handle_t chan, struct hfp_context *ctx) -{ +static void hfp_callsetup_ind_handler(hf_chan_handle_t chan, + struct hfp_context *ctx) { #ifdef __BT_ONE_BRING_TWO__ - //clear flag_skip_resv and flag_skip_retx - bt_drv_clear_skip_flag(); - enum BT_DEVICE_ID_T anotherDevice = (BT_DEVICE_ID_1 == chan_id_flag.id)?BT_DEVICE_ID_2:BT_DEVICE_ID_1; + // clear flag_skip_resv and flag_skip_retx + bt_drv_clear_skip_flag(); + enum BT_DEVICE_ID_T anotherDevice = + (BT_DEVICE_ID_1 == chan_id_flag.id) ? BT_DEVICE_ID_2 : BT_DEVICE_ID_1; #endif - TRACE(2,"::HF_EVENT_CALLSETUP_IND chan_id:%d, callSetup =%d\n", chan_id_flag.id, ctx->call_setup); - if(ctx->call_setup == 0x03) - { - once_event_case = 8; - startonce_delay_event_Timer_(1000); - } - if((ctx->call_setup & 0x03) != 0){ - hfp_call_setup_running_on_set(1); - } + TRACE(2, "::HF_EVENT_CALLSETUP_IND chan_id:%d, callSetup =%d\n", + chan_id_flag.id, ctx->call_setup); + if (ctx->call_setup == 0x03) { + once_event_case = 8; + startonce_delay_event_Timer_(1000); + } + if ((ctx->call_setup & 0x03) != 0) { + hfp_call_setup_running_on_set(1); + } #if !defined(FPGA) && defined(__BTIF_EARPHONE__) - hfp_app_status_indication(chan_id_flag.id, ctx); + hfp_app_status_indication(chan_id_flag.id, ctx); #endif - if (BTIF_HF_CALL_SETUP_NONE != ctx->call_setup) - { - // exit sniff mode and stay active - app_bt_active_mode_set(ACTIVE_MODE_KEEPEER_SCO_STREAMING, - UPDATE_ACTIVE_MODE_FOR_ALL_LINKS); - } - else - { - // resume sniff mode - app_bt_active_mode_clear(ACTIVE_MODE_KEEPEER_SCO_STREAMING, - UPDATE_ACTIVE_MODE_FOR_ALL_LINKS); - } + if (BTIF_HF_CALL_SETUP_NONE != ctx->call_setup) { + // exit sniff mode and stay active + app_bt_active_mode_set(ACTIVE_MODE_KEEPEER_SCO_STREAMING, + UPDATE_ACTIVE_MODE_FOR_ALL_LINKS); + } else { + // resume sniff mode + app_bt_active_mode_clear(ACTIVE_MODE_KEEPEER_SCO_STREAMING, + UPDATE_ACTIVE_MODE_FOR_ALL_LINKS); + } #ifdef __BT_ONE_BRING_TWO__ - TRACE(2,"call [0]/[1] =%d / %d",app_bt_device.hfchan_call[BT_DEVICE_ID_1],app_bt_device.hfchan_call[BT_DEVICE_ID_2]); - TRACE(2,"audio [0]/[1] =%d / %d",app_bt_device.hf_audio_state[BT_DEVICE_ID_1],app_bt_device.hf_audio_state[BT_DEVICE_ID_2]); + TRACE(2, "call [0]/[1] =%d / %d", app_bt_device.hfchan_call[BT_DEVICE_ID_1], + app_bt_device.hfchan_call[BT_DEVICE_ID_2]); + TRACE(2, "audio [0]/[1] =%d / %d", + app_bt_device.hf_audio_state[BT_DEVICE_ID_1], + app_bt_device.hf_audio_state[BT_DEVICE_ID_2]); - app_bt_device.callSetupBitRec |= (1 << ctx->call_setup); - if(ctx->call_setup == 0){ - //do nothing - }else{ + app_bt_device.callSetupBitRec |= (1 << ctx->call_setup); + if (ctx->call_setup == 0) { + // do nothing + } else { #ifdef BT_USB_AUDIO_DUAL_MODE - if(!btusb_is_bt_mode()) - { - TRACE(0,"btusb_usbaudio_close doing."); - btusb_usbaudio_close(); - } + if (!btusb_is_bt_mode()) { + TRACE(0, "btusb_usbaudio_close doing."); + btusb_usbaudio_close(); + } #endif -#if defined (HFP_NO_PRERMPT) - if(((app_bt_device.hfchan_call[anotherDevice] == BTIF_HF_CALL_ACTIVE)&& - (app_bt_device.hfchan_call[chan_id_flag.id] == BTIF_HF_CALL_NONE))|| - ((app_bt_device.hfchan_callSetup[anotherDevice] == BTIF_HF_CALL_SETUP_IN)&& - (app_bt_device.hfchan_call[chan_id_flag.id] == BTIF_HF_CALL_NONE))){ - app_bt_device.curr_hf_channel_id = anotherDevice; - } - else if((app_bt_device.hfchan_call[chan_id_flag.id] == BTIF_HF_CALL_ACTIVE)&& - (app_bt_device.hfchan_call[anotherDevice] == BTIF_HF_CALL_ACTIVE)){ - }else{ - app_bt_device.curr_hf_channel_id = chan_id_flag.id; - } +#if defined(HFP_NO_PRERMPT) + if (((app_bt_device.hfchan_call[anotherDevice] == BTIF_HF_CALL_ACTIVE) && + (app_bt_device.hfchan_call[chan_id_flag.id] == BTIF_HF_CALL_NONE)) || + ((app_bt_device.hfchan_callSetup[anotherDevice] == + BTIF_HF_CALL_SETUP_IN) && + (app_bt_device.hfchan_call[chan_id_flag.id] == BTIF_HF_CALL_NONE))) { + app_bt_device.curr_hf_channel_id = anotherDevice; + } else if ((app_bt_device.hfchan_call[chan_id_flag.id] == + BTIF_HF_CALL_ACTIVE) && + (app_bt_device.hfchan_call[anotherDevice] == + BTIF_HF_CALL_ACTIVE)) { + } else { + app_bt_device.curr_hf_channel_id = chan_id_flag.id; + } #else - if((app_bt_device.hfchan_call[anotherDevice] == BTIF_HF_CALL_ACTIVE)||((app_bt_device.hfchan_callSetup[anotherDevice] == BTIF_HF_CALL_SETUP_IN)&&(app_bt_device.hfchan_call[chan_id_flag.id] != BTIF_HF_CALL_ACTIVE))){ - app_bt_device.curr_hf_channel_id = anotherDevice; - }else{ - app_bt_device.curr_hf_channel_id = chan_id_flag.id; - } + if ((app_bt_device.hfchan_call[anotherDevice] == BTIF_HF_CALL_ACTIVE) || + ((app_bt_device.hfchan_callSetup[anotherDevice] == + BTIF_HF_CALL_SETUP_IN) && + (app_bt_device.hfchan_call[chan_id_flag.id] != BTIF_HF_CALL_ACTIVE))) { + app_bt_device.curr_hf_channel_id = anotherDevice; + } else { + app_bt_device.curr_hf_channel_id = chan_id_flag.id; + } #endif - } - TRACE(1,"!!!HF_EVENT_CALLSETUP_IND curr_hf_channel_id:%d\n",app_bt_device.curr_hf_channel_id); + } + TRACE(1, "!!!HF_EVENT_CALLSETUP_IND curr_hf_channel_id:%d\n", + app_bt_device.curr_hf_channel_id); #endif - app_bt_device.hfchan_callSetup[chan_id_flag.id] = ctx->call_setup; - /////call is alert so remember this time - if(app_bt_device.hfchan_callSetup[chan_id_flag.id] == BTIF_HF_CALL_SETUP_ALERT ) - { - TRACE(1,"HF CALLSETUP TIME=%d",hal_sys_timer_get()); - app_bt_device.hf_callsetup_time[chan_id_flag.id] = hal_sys_timer_get(); - } - if(app_bt_device.hfchan_callSetup[chan_id_flag.id]== BTIF_HF_CALL_SETUP_IN){ - btif_hf_list_current_calls(chan); - } + app_bt_device.hfchan_callSetup[chan_id_flag.id] = ctx->call_setup; + /////call is alert so remember this time + if (app_bt_device.hfchan_callSetup[chan_id_flag.id] == + BTIF_HF_CALL_SETUP_ALERT) { + TRACE(1, "HF CALLSETUP TIME=%d", hal_sys_timer_get()); + app_bt_device.hf_callsetup_time[chan_id_flag.id] = hal_sys_timer_get(); + } + if (app_bt_device.hfchan_callSetup[chan_id_flag.id] == + BTIF_HF_CALL_SETUP_IN) { + btif_hf_list_current_calls(chan); + } - if((app_bt_device.hfchan_callSetup[chan_id_flag.id] == 0) && - (app_bt_device.hfchan_call[chan_id_flag.id]==0)){ - hfp_call_setup_running_on_clr(); - } + if ((app_bt_device.hfchan_callSetup[chan_id_flag.id] == 0) && + (app_bt_device.hfchan_call[chan_id_flag.id] == 0)) { + hfp_call_setup_running_on_clr(); + } } -static void hfp_current_call_state_handler(hf_chan_handle_t chan, struct hfp_context *ctx) -{ - TRACE(1,"::HF_EVENT_CURRENT_CALL_STATE chan_id:%d\n", chan_id_flag.id); +static void hfp_current_call_state_handler(hf_chan_handle_t chan, + struct hfp_context *ctx) { + TRACE(1, "::HF_EVENT_CURRENT_CALL_STATE chan_id:%d\n", chan_id_flag.id); #if !defined(FPGA) && defined(__BTIF_EARPHONE__) - hfp_app_status_indication(chan_id_flag.id,ctx); + hfp_app_status_indication(chan_id_flag.id, ctx); #endif } void app_hfp_mute_upstream(uint8_t devId, bool isMute); -static void hfp_audio_connected_handler(hf_chan_handle_t chan, struct hfp_context *ctx) -{ +static void hfp_audio_connected_handler(hf_chan_handle_t chan, + struct hfp_context *ctx) { #ifdef __BT_ONE_BRING_TWO__ - enum BT_DEVICE_ID_T anotherDevice = (BT_DEVICE_ID_1 == chan_id_flag.id)?BT_DEVICE_ID_2:BT_DEVICE_ID_1; + enum BT_DEVICE_ID_T anotherDevice = + (BT_DEVICE_ID_1 == chan_id_flag.id) ? BT_DEVICE_ID_2 : BT_DEVICE_ID_1; #endif #if defined(HFP_1_6_ENABLE) - hf_chan_handle_t chan_tmp; + hf_chan_handle_t chan_tmp; #endif #ifdef __AI_VOICE__ - ai_function_handle(CALLBACK_STOP_SPEECH, NULL, 0); - ai_function_handle(CALLBACK_AI_APP_KEEPALIVE_POST_HANDLER, NULL, 0); // check + ai_function_handle(CALLBACK_STOP_SPEECH, NULL, 0); + ai_function_handle(CALLBACK_AI_APP_KEEPALIVE_POST_HANDLER, NULL, 0); // check #endif - if(ctx->status != BT_STS_SUCCESS) - return; + if (ctx->status != BT_STS_SUCCESS) + return; #if defined(IBRT) - app_ibrt_if_sniff_checker_start(APP_IBRT_IF_SNIFF_CHECKER_USER_HFP); + app_ibrt_if_sniff_checker_start(APP_IBRT_IF_SNIFF_CHECKER_USER_HFP); #endif - btdrv_set_powerctrl_rssi_low(0xffff); - btapp_hfp_mic_need_skip_frame_set(2); + btdrv_set_powerctrl_rssi_low(0xffff); + btapp_hfp_mic_need_skip_frame_set(2); #ifdef __BT_ONE_BRING_TWO__ #ifdef SUSPEND_ANOTHER_DEV_A2DP_STREAMING_WHEN_CALL_IS_COMING - if(app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_CON){ - TRACE(0,"::HF_EVENT_AUDIO_CONNECTED no need to update state"); - return; - } - hfp_suspend_another_device_a2dp(); + if (app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_CON) { + TRACE(0, "::HF_EVENT_AUDIO_CONNECTED no need to update state"); + return; + } + hfp_suspend_another_device_a2dp(); #endif #endif #ifdef __BT_ONE_BRING_TWO__ - a2dp_dual_slave_setup_during_sco(chan_id_flag.id); + a2dp_dual_slave_setup_during_sco(chan_id_flag.id); #endif #if defined(HFP_1_6_ENABLE) - chan_tmp = app_bt_device.hf_channel[chan_id_flag.id]; - uint16_t codec_id; + chan_tmp = app_bt_device.hf_channel[chan_id_flag.id]; + uint16_t codec_id; #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if(p_ibrt_ctrl->current_role==IBRT_SLAVE) - { - codec_id= p_ibrt_ctrl->ibrt_sco_codec; - } - else + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (p_ibrt_ctrl->current_role == IBRT_SLAVE) { + codec_id = p_ibrt_ctrl->ibrt_sco_codec; + } else #endif - { - codec_id = btif_hf_get_negotiated_codec(chan_tmp); - } - TRACE(2,"::HF_EVENT_AUDIO_CONNECTED chan_id:%d, codec_id:%d\n", chan_id_flag.id, codec_id); - app_audio_manager_set_scocodecid(chan_id_flag.id, codec_id); + { + codec_id = btif_hf_get_negotiated_codec(chan_tmp); + } + TRACE(2, "::HF_EVENT_AUDIO_CONNECTED chan_id:%d, codec_id:%d\n", + chan_id_flag.id, codec_id); + app_audio_manager_set_scocodecid(chan_id_flag.id, codec_id); - - // bt_drv_reg_op_sco_txfifo_reset(codec_id); + // bt_drv_reg_op_sco_txfifo_reset(codec_id); #else - TRACE(1,"::HF_EVENT_AUDIO_CONNECTED chan_id:%d\n", chan_id_flag.id); - // bt_drv_reg_op_sco_txfifo_reset(1); + TRACE(1, "::HF_EVENT_AUDIO_CONNECTED chan_id:%d\n", chan_id_flag.id); + // bt_drv_reg_op_sco_txfifo_reset(1); #endif -#if defined (HFP_NO_PRERMPT) - if(((app_bt_device.hfchan_call[anotherDevice] == BTIF_HF_CALL_ACTIVE)&& - (app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_DISCON))&& - ((app_bt_device.hf_audio_state[chan_id_flag.id] == BTIF_HF_AUDIO_DISCON)&& - (app_bt_device.hfchan_call[chan_id_flag.id] == BTIF_HF_CALL_ACTIVE))){ - app_bt_device.phone_earphone_mark = 0; - app_bt_device.hf_mute_flag = 0; - }else if((app_bt_device.hf_audio_state[chan_id_flag.id] == BTIF_HF_AUDIO_CON)|| - (app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_CON)){ - }else +#if defined(HFP_NO_PRERMPT) + if (((app_bt_device.hfchan_call[anotherDevice] == BTIF_HF_CALL_ACTIVE) && + (app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_DISCON)) && + ((app_bt_device.hf_audio_state[chan_id_flag.id] == + BTIF_HF_AUDIO_DISCON) && + (app_bt_device.hfchan_call[chan_id_flag.id] == BTIF_HF_CALL_ACTIVE))) { + app_bt_device.phone_earphone_mark = 0; + app_bt_device.hf_mute_flag = 0; + } else if ((app_bt_device.hf_audio_state[chan_id_flag.id] == + BTIF_HF_AUDIO_CON) || + (app_bt_device.hf_audio_state[anotherDevice] == + BTIF_HF_AUDIO_CON)) { + } else #endif - { - app_bt_device.phone_earphone_mark = 0; - app_bt_device.hf_mute_flag = 0; - } - app_bt_device.hf_audio_state[chan_id_flag.id] = BTIF_HF_AUDIO_CON; + { + app_bt_device.phone_earphone_mark = 0; + app_bt_device.hf_mute_flag = 0; + } + app_bt_device.hf_audio_state[chan_id_flag.id] = BTIF_HF_AUDIO_CON; #if defined(__FORCE_REPORTVOLUME_SOCON__) - btif_hf_report_speaker_volume(chan, hfp_volume_get(chan_id_flag.id)); + btif_hf_report_speaker_volume(chan, hfp_volume_get(chan_id_flag.id)); #endif #ifdef __BT_ONE_BRING_TWO__ - if( bt_get_sco_number()>1 + if (bt_get_sco_number() > 1 #ifdef CHIP_BEST1000 - && hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_2 + && hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_2 #endif - ){ - if(app_bt_device.hfchan_call[chan_id_flag.id] == BTIF_HF_CALL_ACTIVE){ -#if !defined (HFP_NO_PRERMPT) + ) { + if (app_bt_device.hfchan_call[chan_id_flag.id] == BTIF_HF_CALL_ACTIVE) { +#if !defined(HFP_NO_PRERMPT) #ifndef __HF_KEEP_ONE_ALIVE__ - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_SWAP_SCO,BT_STREAM_SBC, chan_id_flag.id, 0); + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_SWAP_SCO, + BT_STREAM_SBC, chan_id_flag.id, 0); #endif - app_bt_device.hf_voice_en[chan_id_flag.id] = HF_VOICE_ENABLE; - app_bt_device.hf_voice_en[anotherDevice] = HF_VOICE_DISABLE; + app_bt_device.hf_voice_en[chan_id_flag.id] = HF_VOICE_ENABLE; + app_bt_device.hf_voice_en[anotherDevice] = HF_VOICE_DISABLE; #else - if((app_bt_device.hfchan_call[anotherDevice] == BTIF_HF_CALL_NONE)&& - (app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_DISCON)) - app_bt_device.curr_hf_channel_id = chan_id_flag.id; + if ((app_bt_device.hfchan_call[anotherDevice] == BTIF_HF_CALL_NONE) && + (app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_DISCON)) + app_bt_device.curr_hf_channel_id = chan_id_flag.id; #ifdef _THREE_WAY_ONE_CALL_COUNT__ - app_hfp_set_cur_chnl_id(chan_id_flag.id); - TRACE(4,"%s :%d : app_bt_device.hf_callheld[%d]: %d\n", __func__, __LINE__, chan_id_flag.id, app_bt_device.hf_callheld[chan_id_flag.id]); - if(app_bt_device.hf_callheld[chan_id_flag.id] == BTIF_HF_CALL_HELD_ACTIVE){ - if(app_hfp_get_cur_call_chnl(NULL) == chan_id_flag.id) - app_hfp_3_way_call_counter_set(chan_id_flag.id,1); - }else if((app_bt_device.hf_callheld[chan_id_flag.id] == BTIF_HF_CALL_HELD_NONE) || - (app_bt_device.hf_callheld[chan_id_flag.id] == BTIF_HF_CALL_HELD_NO_ACTIVE)){ - if(app_hfp_get_cur_call_chnl(NULL) == chan_id_flag.id) - app_hfp_3_way_call_counter_set(chan_id_flag.id,0); - } + app_hfp_set_cur_chnl_id(chan_id_flag.id); + TRACE(4, "%s :%d : app_bt_device.hf_callheld[%d]: %d\n", __func__, + __LINE__, chan_id_flag.id, + app_bt_device.hf_callheld[chan_id_flag.id]); + if (app_bt_device.hf_callheld[chan_id_flag.id] == + BTIF_HF_CALL_HELD_ACTIVE) { + if (app_hfp_get_cur_call_chnl(NULL) == chan_id_flag.id) + app_hfp_3_way_call_counter_set(chan_id_flag.id, 1); + } else if ((app_bt_device.hf_callheld[chan_id_flag.id] == + BTIF_HF_CALL_HELD_NONE) || + (app_bt_device.hf_callheld[chan_id_flag.id] == + BTIF_HF_CALL_HELD_NO_ACTIVE)) { + if (app_hfp_get_cur_call_chnl(NULL) == chan_id_flag.id) + app_hfp_3_way_call_counter_set(chan_id_flag.id, 0); + } #endif #endif - }else if(app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_CON){ - app_bt_device.hf_voice_en[chan_id_flag.id] = HF_VOICE_DISABLE; - app_bt_device.hf_voice_en[anotherDevice] = HF_VOICE_ENABLE; - } - }else{ - ///if one device setup a sco connect so get the other device's sco state, if both connect mute the earlier one - if(app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_CON){ - app_bt_device.hf_voice_en[anotherDevice] = HF_VOICE_DISABLE; - } - app_bt_device.hf_voice_en[chan_id_flag.id] = HF_VOICE_ENABLE; - } + } else if (app_bt_device.hf_audio_state[anotherDevice] == + BTIF_HF_AUDIO_CON) { + app_bt_device.hf_voice_en[chan_id_flag.id] = HF_VOICE_DISABLE; + app_bt_device.hf_voice_en[anotherDevice] = HF_VOICE_ENABLE; + } + } else { + /// if one device setup a sco connect so get the other device's sco state, + /// if both connect mute the earlier one + if (app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_CON) { + app_bt_device.hf_voice_en[anotherDevice] = HF_VOICE_DISABLE; + } + app_bt_device.hf_voice_en[chan_id_flag.id] = HF_VOICE_ENABLE; + } #ifndef __HF_KEEP_ONE_ALIVE__ - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START,BT_STREAM_VOICE,chan_id_flag.id,MAX_RECORD_NUM); + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, BT_STREAM_VOICE, + chan_id_flag.id, MAX_RECORD_NUM); #endif -#if defined (HFP_NO_PRERMPT) - TRACE(2,"call[id_other] =%d audio[id_other] = %d",app_bt_device.hfchan_call[anotherDevice], - app_bt_device.hf_audio_state[anotherDevice]); - if(/*(app_bt_device.hfchan_call[anotherDevice] == HF_CALL_ACTIVE)&&*/ - (app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_CON)){ - }else +#if defined(HFP_NO_PRERMPT) + TRACE(2, "call[id_other] =%d audio[id_other] = %d", + app_bt_device.hfchan_call[anotherDevice], + app_bt_device.hf_audio_state[anotherDevice]); + if (/*(app_bt_device.hfchan_call[anotherDevice] == HF_CALL_ACTIVE)&&*/ + (app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_CON)) { + } else #endif - { - if (bt_media_cur_is_bt_stream_media()) - { - app_hfp_start_voice_media(chan_id_flag.id); - app_bt_device.curr_hf_channel_id = chan_id_flag.id; - } - else - { + { + if (bt_media_cur_is_bt_stream_media()) { + app_hfp_start_voice_media(chan_id_flag.id); + app_bt_device.curr_hf_channel_id = chan_id_flag.id; + } else { #ifdef __BT_ONE_BRING_TWO__ - TRACE(1,"%s another[%d] hf_audio_state %d,",__func__,anotherDevice,app_bt_device.hf_audio_state[anotherDevice]); + TRACE(1, "%s another[%d] hf_audio_state %d,", __func__, anotherDevice, + app_bt_device.hf_audio_state[anotherDevice]); - if(BTIF_HF_AUDIO_CON == app_bt_device.hf_audio_state[anotherDevice]) - { - TRACE(1,"disconnect current audio link and don't swith to current sco"); - btif_hf_disc_audio_link(app_bt_device.hf_channel[chan_id_flag.id]); - app_bt_device.curr_hf_channel_id = anotherDevice; - } + if (BTIF_HF_AUDIO_CON == app_bt_device.hf_audio_state[anotherDevice]) { + TRACE(1, + "disconnect current audio link and don't swith to current sco"); + btif_hf_disc_audio_link(app_bt_device.hf_channel[chan_id_flag.id]); + app_bt_device.curr_hf_channel_id = anotherDevice; + } #else - if(bt_is_sco_media_open()) - { - TRACE(0,"disconnect current audio link and don't swith to current sco"); - app_bt_HF_DisconnectAudioLink(app_bt_device.hf_channel[chan_id_flag.id]); - } + if (bt_is_sco_media_open()) { + TRACE(0, + "disconnect current audio link and don't swith to current sco"); + app_bt_HF_DisconnectAudioLink( + app_bt_device.hf_channel[chan_id_flag.id]); + } #endif - else - { - app_hfp_start_voice_media(chan_id_flag.id); - app_bt_device.curr_hf_channel_id = chan_id_flag.id; - } - } - } + else { + app_hfp_start_voice_media(chan_id_flag.id); + app_bt_device.curr_hf_channel_id = chan_id_flag.id; + } + } + } #else #ifdef _THREE_WAY_ONE_CALL_COUNT__ - app_hfp_set_cur_chnl_id(chan_id_flag.id); + app_hfp_set_cur_chnl_id(chan_id_flag.id); #endif #ifdef ENABLE_HFP_AUDIO_PENDING_FOR_MEDIA - if (bt_media_cur_is_bt_stream_media()) - { - app_hfp_set_starting_media_pending_flag(true, BT_DEVICE_ID_1); - } - else + if (bt_media_cur_is_bt_stream_media()) { + app_hfp_set_starting_media_pending_flag(true, BT_DEVICE_ID_1); + } else #endif - { - app_hfp_start_voice_media(BT_DEVICE_ID_1); - } + { + app_hfp_start_voice_media(BT_DEVICE_ID_1); + } #endif #ifdef __IAG_BLE_INCLUDE__ - app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_HFP_ON, true); + app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_HFP_ON, true); #endif } -static void hfp_audio_disconnected_handler(hf_chan_handle_t chan, struct hfp_context *ctx) -{ +static void hfp_audio_disconnected_handler(hf_chan_handle_t chan, + struct hfp_context *ctx) { #ifdef __BT_ONE_BRING_TWO__ - //clear flag_skip_resv and flag_skip_retx - bt_drv_clear_skip_flag(); - enum BT_DEVICE_ID_T anotherDevice = (BT_DEVICE_ID_1 == chan_id_flag.id)?BT_DEVICE_ID_2:BT_DEVICE_ID_1; + // clear flag_skip_resv and flag_skip_retx + bt_drv_clear_skip_flag(); + enum BT_DEVICE_ID_T anotherDevice = + (BT_DEVICE_ID_1 == chan_id_flag.id) ? BT_DEVICE_ID_2 : BT_DEVICE_ID_1; #endif #ifdef BT_USB_AUDIO_DUAL_MODE - if(!btusb_is_bt_mode()) - { - TRACE(0,"btusb_usbaudio_open doing."); - btusb_usbaudio_open(); - } + if (!btusb_is_bt_mode()) { + TRACE(0, "btusb_usbaudio_open doing."); + btusb_usbaudio_open(); + } #endif - app_hfp_set_starting_media_pending_flag(false, 0); + app_hfp_set_starting_media_pending_flag(false, 0); #if defined(IBRT) - app_ibrt_if_sniff_checker_stop(APP_IBRT_IF_SNIFF_CHECKER_USER_HFP); + app_ibrt_if_sniff_checker_stop(APP_IBRT_IF_SNIFF_CHECKER_USER_HFP); #endif #ifdef __BT_ONE_BRING_TWO__ #ifdef SUSPEND_ANOTHER_DEV_A2DP_STREAMING_WHEN_CALL_IS_COMING - if (app_bt_is_to_resume_music_player(anotherDevice)) - { - app_bt_resume_music_player(anotherDevice); - } + if (app_bt_is_to_resume_music_player(anotherDevice)) { + app_bt_resume_music_player(anotherDevice); + } #endif #endif #ifdef __BT_ONE_BRING_TWO__ - a2dp_dual_slave_handling_refresh(); + a2dp_dual_slave_handling_refresh(); #endif - TRACE(1,"::HF_EVENT_AUDIO_DISCONNECTED chan_id:%d\n", chan_id_flag.id); - if(app_bt_device.hfchan_call[chan_id_flag.id] == BTIF_HF_CALL_ACTIVE){ - app_bt_device.phone_earphone_mark = 1; - } + TRACE(1, "::HF_EVENT_AUDIO_DISCONNECTED chan_id:%d\n", chan_id_flag.id); + if (app_bt_device.hfchan_call[chan_id_flag.id] == BTIF_HF_CALL_ACTIVE) { + app_bt_device.phone_earphone_mark = 1; + } - app_bt_device.hf_audio_state[chan_id_flag.id] = BTIF_HF_AUDIO_DISCON; + app_bt_device.hf_audio_state[chan_id_flag.id] = BTIF_HF_AUDIO_DISCON; - /* Dont clear callsetup status when audio disc: press iphone volume button - will disc audio link, but the iphone incoming call is still exist. The - callsetup status will be reported after call rejected or answered. */ - //app_bt_device.hfchan_callSetup[chan_id_flag.id] = BTIF_HF_CALL_SETUP_NONE; + /* Dont clear callsetup status when audio disc: press iphone volume button + will disc audio link, but the iphone incoming call is still exist. The + callsetup status will be reported after call rejected or answered. */ + // app_bt_device.hfchan_callSetup[chan_id_flag.id] = BTIF_HF_CALL_SETUP_NONE; #ifdef __IAG_BLE_INCLUDE__ - if (!app_bt_is_in_reconnecting()) - { - app_hfp_resume_ble_adv(); - } + if (!app_bt_is_in_reconnecting()) { + app_hfp_resume_ble_adv(); + } - app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_HFP_ON, false); + app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_HFP_ON, false); #endif -#if defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) || defined(CHIP_BEST1400) || defined(CHIP_BEST1402) - bt_drv_reg_op_clean_flags_of_ble_and_sco(); +#if defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) || \ + defined(CHIP_BEST1400) || defined(CHIP_BEST1402) + bt_drv_reg_op_clean_flags_of_ble_and_sco(); #endif #ifdef __BT_ONE_BRING_TWO__ - if (btif_get_hf_chan_state(app_bt_device.hf_channel[anotherDevice]) != BTIF_HF_STATE_OPEN){ - TRACE(2,"!!!HF_EVENT_AUDIO_DISCONNECTED hfchan_call[%d]:%d\n",anotherDevice, - app_bt_device.hfchan_call[anotherDevice]); - } - if ((app_bt_device.hfchan_call[anotherDevice] == BTIF_HF_CALL_ACTIVE) || - (app_bt_device.hfchan_callSetup[anotherDevice] == BTIF_HF_CALL_SETUP_IN)){ - // app_bt_device.curr_hf_channel_id = chan_id_flag.id_other; - TRACE(1,"!!!HF_EVENT_AUDIO_DISCONNECTED app_bt_device.curr_hf_channel_id:%d\n", - app_bt_device.curr_hf_channel_id); - } else { - app_bt_device.curr_hf_channel_id = chan_id_flag.id; - } + if (btif_get_hf_chan_state(app_bt_device.hf_channel[anotherDevice]) != + BTIF_HF_STATE_OPEN) { + TRACE(2, "!!!HF_EVENT_AUDIO_DISCONNECTED hfchan_call[%d]:%d\n", + anotherDevice, app_bt_device.hfchan_call[anotherDevice]); + } + if ((app_bt_device.hfchan_call[anotherDevice] == BTIF_HF_CALL_ACTIVE) || + (app_bt_device.hfchan_callSetup[anotherDevice] == + BTIF_HF_CALL_SETUP_IN)) { + // app_bt_device.curr_hf_channel_id = chan_id_flag.id_other; + TRACE( + 1, + "!!!HF_EVENT_AUDIO_DISCONNECTED app_bt_device.curr_hf_channel_id:%d\n", + app_bt_device.curr_hf_channel_id); + } else { + app_bt_device.curr_hf_channel_id = chan_id_flag.id; + } #if defined(_THREE_WAY_ONE_CALL_COUNT__) - if (chan_id_flag.id == app_hfp_get_cur_call_chnl(NULL)) { - app_hfp_cur_call_chnl_reset(chan_id_flag.id); - } + if (chan_id_flag.id == app_hfp_get_cur_call_chnl(NULL)) { + app_hfp_cur_call_chnl_reset(chan_id_flag.id); + } #endif - app_bt_device.hf_voice_en[chan_id_flag.id] = HF_VOICE_DISABLE; - if(app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_CON){ - app_bt_device.hf_voice_en[anotherDevice] = HF_VOICE_ENABLE; - TRACE(1,"chan_id:%d AUDIO_DISCONNECTED, then enable id_other voice",chan_id_flag.id); - } - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_VOICE, - chan_id_flag.id, MAX_RECORD_NUM); + app_bt_device.hf_voice_en[chan_id_flag.id] = HF_VOICE_DISABLE; + if (app_bt_device.hf_audio_state[anotherDevice] == BTIF_HF_AUDIO_CON) { + app_bt_device.hf_voice_en[anotherDevice] = HF_VOICE_ENABLE; + TRACE(1, "chan_id:%d AUDIO_DISCONNECTED, then enable id_other voice", + chan_id_flag.id); + } + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_VOICE, + chan_id_flag.id, MAX_RECORD_NUM); #else - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_VOICE, - BT_DEVICE_ID_1, MAX_RECORD_NUM); + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_VOICE, + BT_DEVICE_ID_1, MAX_RECORD_NUM); #endif - app_bt_device.callSetupBitRec = 0; - //app_hfp_mute_upstream(chan_id_flag.id, true); + app_bt_device.callSetupBitRec = 0; + // app_hfp_mute_upstream(chan_id_flag.id, true); #if defined(HFP_1_6_ENABLE) - uint16_t codec_id = btif_hf_get_negotiated_codec(app_bt_device.hf_channel[chan_id_flag.id]); - bt_drv_reg_op_sco_txfifo_reset(codec_id); + uint16_t codec_id = + btif_hf_get_negotiated_codec(app_bt_device.hf_channel[chan_id_flag.id]); + bt_drv_reg_op_sco_txfifo_reset(codec_id); #else - bt_drv_reg_op_sco_txfifo_reset(1); + bt_drv_reg_op_sco_txfifo_reset(1); #endif - app_bt_active_mode_clear(ACTIVE_MODE_KEEPEER_SCO_STREAMING, - UPDATE_ACTIVE_MODE_FOR_ALL_LINKS); + app_bt_active_mode_clear(ACTIVE_MODE_KEEPEER_SCO_STREAMING, + UPDATE_ACTIVE_MODE_FOR_ALL_LINKS); } -static void hfp_ring_ind_handler(hf_chan_handle_t chan, struct hfp_context *ctx) -{ -#if !defined(FPGA) && defined(__BTIF_EARPHONE__) && defined(MEDIA_PLAYER_SUPPORT) +static void hfp_ring_ind_handler(hf_chan_handle_t chan, + struct hfp_context *ctx) { +#if !defined(FPGA) && defined(__BTIF_EARPHONE__) && \ + defined(MEDIA_PLAYER_SUPPORT) #ifdef __BT_ONE_BRING_TWO__ - enum BT_DEVICE_ID_T anotherDevice = (BT_DEVICE_ID_1 == chan_id_flag.id)?BT_DEVICE_ID_2:BT_DEVICE_ID_1; + enum BT_DEVICE_ID_T anotherDevice = + (BT_DEVICE_ID_1 == chan_id_flag.id) ? BT_DEVICE_ID_2 : BT_DEVICE_ID_1; #endif - TRACE(1,"::HF_EVENT_RING_IND chan_id:%d\n", chan_id_flag.id); - TRACE(1,"btif_hf_is_inbandring_enabled:%d",btif_hf_is_inbandring_enabled(chan)); + TRACE(1, "::HF_EVENT_RING_IND chan_id:%d\n", chan_id_flag.id); + TRACE(1, "btif_hf_is_inbandring_enabled:%d", + btif_hf_is_inbandring_enabled(chan)); #if defined(__BT_ONE_BRING_TWO__) - if((app_bt_device.hf_audio_state[chan_id_flag.id] != BTIF_HF_AUDIO_CON) && - (app_bt_device.hf_audio_state[anotherDevice] != BTIF_HF_AUDIO_CON)) - app_voice_report(APP_STATUS_INDICATION_INCOMINGCALL,chan_id_flag.id); + if ((app_bt_device.hf_audio_state[chan_id_flag.id] != BTIF_HF_AUDIO_CON) && + (app_bt_device.hf_audio_state[anotherDevice] != BTIF_HF_AUDIO_CON)) + app_voice_report(APP_STATUS_INDICATION_INCOMINGCALL, chan_id_flag.id); #else #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if(p_ibrt_ctrl->current_role == IBRT_SLAVE) - return; + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (p_ibrt_ctrl->current_role == IBRT_SLAVE) + return; #endif - if(app_bt_device.hf_audio_state[chan_id_flag.id] != BTIF_HF_AUDIO_CON) - app_voice_report(APP_STATUS_INDICATION_INCOMINGCALL,chan_id_flag.id); + if (app_bt_device.hf_audio_state[chan_id_flag.id] != BTIF_HF_AUDIO_CON) + app_voice_report(APP_STATUS_INDICATION_INCOMINGCALL, chan_id_flag.id); #endif #endif } -static void hfp_speak_volume_handler(hf_chan_handle_t chan, struct hfp_context *ctx) -{ - TRACE(2,"::HF_EVENT_SPEAKER_VOLUME chan_id:%d,speaker gain = %d\n", - chan_id_flag.id, ctx->speaker_volume); - hfp_volume_set(chan_id_flag.id, (int)ctx->speaker_volume); +static void hfp_speak_volume_handler(hf_chan_handle_t chan, + struct hfp_context *ctx) { + TRACE(2, "::HF_EVENT_SPEAKER_VOLUME chan_id:%d,speaker gain = %d\n", + chan_id_flag.id, ctx->speaker_volume); + hfp_volume_set(chan_id_flag.id, (int)ctx->speaker_volume); } -static void hfp_voice_rec_state_ind_handler(hf_chan_handle_t chan, struct hfp_context *ctx) -{ - TRACE(2,"::HF_EVENT_VOICE_REC_STATE chan_id:%d,voice_rec_state = %d\n", - chan_id_flag.id, ctx->voice_rec_state); +static void hfp_voice_rec_state_ind_handler(hf_chan_handle_t chan, + struct hfp_context *ctx) { + TRACE(2, "::HF_EVENT_VOICE_REC_STATE chan_id:%d,voice_rec_state = %d\n", + chan_id_flag.id, ctx->voice_rec_state); } -static void hfp_bes_test_handler(hf_chan_handle_t chan, struct hfp_context *ctx) -{ - //TRACE(0,"HF_EVENT_BES_TEST content =d", Info->p.ptr); +static void hfp_bes_test_handler(hf_chan_handle_t chan, + struct hfp_context *ctx) { + // TRACE(0,"HF_EVENT_BES_TEST content =d", Info->p.ptr); } -static void hfp_read_ag_ind_status_handler(hf_chan_handle_t chan, struct hfp_context *ctx) -{ - TRACE(1,"HF_EVENT_READ_AG_INDICATORS_STATUS %s\n", __func__); +static void hfp_read_ag_ind_status_handler(hf_chan_handle_t chan, + struct hfp_context *ctx) { + TRACE(1, "HF_EVENT_READ_AG_INDICATORS_STATUS %s\n", __func__); } -static void hfp_call_held_ind_handler(hf_chan_handle_t chan, struct hfp_context *ctx) -{ -#if defined( __BT_ONE_BRING_TWO__) - TRACE(8,"::HF_EVENT_CALLHELD_IND %d chan_id %d call %d %d held %d %d audio_state %d %d\n", +static void hfp_call_held_ind_handler(hf_chan_handle_t chan, + struct hfp_context *ctx) { +#if defined(__BT_ONE_BRING_TWO__) + TRACE(8, + "::HF_EVENT_CALLHELD_IND %d chan_id %d call %d %d held %d %d " + "audio_state %d %d\n", ctx->call_held, chan_id_flag.id, - app_bt_device.hfchan_call[BT_DEVICE_ID_1], app_bt_device.hfchan_call[BT_DEVICE_ID_2], - app_bt_device.hf_callheld[BT_DEVICE_ID_1], app_bt_device.hf_callheld[BT_DEVICE_ID_2], - app_bt_device.hf_audio_state[BT_DEVICE_ID_1], app_bt_device.hf_audio_state[BT_DEVICE_ID_2]); + app_bt_device.hfchan_call[BT_DEVICE_ID_1], + app_bt_device.hfchan_call[BT_DEVICE_ID_2], + app_bt_device.hf_callheld[BT_DEVICE_ID_1], + app_bt_device.hf_callheld[BT_DEVICE_ID_2], + app_bt_device.hf_audio_state[BT_DEVICE_ID_1], + app_bt_device.hf_audio_state[BT_DEVICE_ID_2]); #else - TRACE(2,"::HF_EVENT_CALLHELD_IND chan_id:%d HELD_STATUS = %d \n",chan_id_flag.id, ctx->call_held); + TRACE(2, "::HF_EVENT_CALLHELD_IND chan_id:%d HELD_STATUS = %d \n", + chan_id_flag.id, ctx->call_held); #endif #if defined(_THREE_WAY_ONE_CALL_COUNT__) -#if defined( __BT_ONE_BRING_TWO__) - if (app_bt_device.hf_audio_state[chan_id_flag.id] == BTIF_HF_AUDIO_CON && (ctx->call_held == BTIF_HF_CALL_HELD_NONE || ctx->call_held == BTIF_HF_CALL_HELD_ACTIVE)) { - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_SWITCHTO_SCO, BT_STREAM_VOICE, chan_id_flag.id, 0); - } +#if defined(__BT_ONE_BRING_TWO__) + if (app_bt_device.hf_audio_state[chan_id_flag.id] == BTIF_HF_AUDIO_CON && + (ctx->call_held == BTIF_HF_CALL_HELD_NONE || + ctx->call_held == BTIF_HF_CALL_HELD_ACTIVE)) { + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_SWITCHTO_SCO, + BT_STREAM_VOICE, chan_id_flag.id, 0); + } #endif - app_bt_device.hf_callheld[chan_id_flag.id] = ctx->call_held; - if(ctx->call_held == BTIF_HF_CALL_HELD_ACTIVE){ - if(app_hfp_get_cur_call_chnl(NULL) == chan_id_flag.id) - app_hfp_3_way_call_counter_set(chan_id_flag.id,1); - }else if((ctx->call_held == BTIF_HF_CALL_HELD_NONE) || - (ctx->call_held == BTIF_HF_CALL_HELD_NO_ACTIVE)){ - if(app_hfp_get_cur_call_chnl(NULL) == chan_id_flag.id) - app_hfp_3_way_call_counter_set(chan_id_flag.id,0); - }else{ - TRACE(0,"UNKNOWN CMD.IGNORE"); - } + app_bt_device.hf_callheld[chan_id_flag.id] = ctx->call_held; + if (ctx->call_held == BTIF_HF_CALL_HELD_ACTIVE) { + if (app_hfp_get_cur_call_chnl(NULL) == chan_id_flag.id) + app_hfp_3_way_call_counter_set(chan_id_flag.id, 1); + } else if ((ctx->call_held == BTIF_HF_CALL_HELD_NONE) || + (ctx->call_held == BTIF_HF_CALL_HELD_NO_ACTIVE)) { + if (app_hfp_get_cur_call_chnl(NULL) == chan_id_flag.id) + app_hfp_3_way_call_counter_set(chan_id_flag.id, 0); + } else { + TRACE(0, "UNKNOWN CMD.IGNORE"); + } #endif } static uint8_t skip_frame_cnt = 0; -void app_hfp_set_skip_frame(uint8_t frames) -{ - skip_frame_cnt = frames; +void app_hfp_set_skip_frame(uint8_t frames) { skip_frame_cnt = frames; } +uint8_t app_hfp_run_skip_frame(void) { + if (skip_frame_cnt > 0) { + skip_frame_cnt--; + return 1; + } + return 0; } -uint8_t app_hfp_run_skip_frame(void) -{ - if(skip_frame_cnt >0){ - skip_frame_cnt--; - return 1; - } +uint8_t hfp_is_service_connected(uint8_t device_id) { + if (device_id >= BT_DEVICE_NUM) return 0; -} -uint8_t hfp_is_service_connected(uint8_t device_id) -{ - if(device_id >= BT_DEVICE_NUM) - return 0; - return app_bt_device.hf_conn_flag[device_id]; + return app_bt_device.hf_conn_flag[device_id]; } #if HF_VERSION_1_6 == XA_ENABLED -//HfCommand hf_codec_sel_command; +// HfCommand hf_codec_sel_command; #endif static uint8_t app_hfp_is_starting_media_pending_flag = false; static uint8_t app_hfp_pending_dev_id; -bool app_hfp_is_starting_media_pending(void) -{ - return app_hfp_is_starting_media_pending_flag; +bool app_hfp_is_starting_media_pending(void) { + return app_hfp_is_starting_media_pending_flag; } static uint8_t upstreamMute = 0xff; -void app_hfp_mute_upstream(uint8_t devId, bool isMute) -{ - if (upstreamMute != isMute){ - TRACE(3,"%s devId %d isMute %d",__func__,devId,isMute); - upstreamMute = isMute; - if (isMute){ - btdrv_set_bt_pcm_en(0); - }else{ - btdrv_set_bt_pcm_en(1); - } +void app_hfp_mute_upstream(uint8_t devId, bool isMute) { + if (upstreamMute != isMute) { + TRACE(3, "%s devId %d isMute %d", __func__, devId, isMute); + upstreamMute = isMute; + if (isMute) { + btdrv_set_bt_pcm_en(0); + } else { + btdrv_set_bt_pcm_en(1); } + } } -static void app_hfp_set_starting_media_pending_flag(bool isEnabled, uint8_t devId) -{ - TRACE(1,"%s %d.Current state %d toEnable %d",__func__,__LINE__, +static void app_hfp_set_starting_media_pending_flag(bool isEnabled, + uint8_t devId) { + TRACE(1, "%s %d.Current state %d toEnable %d", __func__, __LINE__, app_hfp_is_starting_media_pending_flag, isEnabled); - if ((app_hfp_is_starting_media_pending_flag && isEnabled) || - (!app_hfp_is_starting_media_pending_flag && !isEnabled)) - { - return; - } + if ((app_hfp_is_starting_media_pending_flag && isEnabled) || + (!app_hfp_is_starting_media_pending_flag && !isEnabled)) { + return; + } - app_hfp_is_starting_media_pending_flag = isEnabled; + app_hfp_is_starting_media_pending_flag = isEnabled; - app_hfp_pending_dev_id = devId; + app_hfp_pending_dev_id = devId; #if 0 if (isEnabled) { @@ -1549,422 +1579,417 @@ static void app_hfp_set_starting_media_pending_flag(bool isEnabled, uint8_t devI #endif } -void app_hfp_start_voice_media(uint8_t devId) -{ - app_hfp_set_starting_media_pending_flag(false, 0); - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, - BT_STREAM_VOICE, devId, MAX_RECORD_NUM); +void app_hfp_start_voice_media(uint8_t devId) { + app_hfp_set_starting_media_pending_flag(false, 0); + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, BT_STREAM_VOICE, + devId, MAX_RECORD_NUM); } -void app_hfp_resume_pending_voice_media(void) -{ - if (btapp_hfp_is_dev_sco_connected(app_hfp_pending_dev_id)) - { - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, - BT_STREAM_VOICE, app_hfp_pending_dev_id, MAX_RECORD_NUM); - app_hfp_set_starting_media_pending_flag(false, 0); - } +void app_hfp_resume_pending_voice_media(void) { + if (btapp_hfp_is_dev_sco_connected(app_hfp_pending_dev_id)) { + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, BT_STREAM_VOICE, + app_hfp_pending_dev_id, MAX_RECORD_NUM); + app_hfp_set_starting_media_pending_flag(false, 0); + } } #include "app_bt_func.h" -void hfp_multipoint_audio_manage_a2dp_callback() -{ +void hfp_multipoint_audio_manage_a2dp_callback() { #ifdef SUSPEND_ANOTHER_DEV_A2DP_STREAMING_WHEN_CALL_IS_COMING - int i = 0; - int j = 0; - TRACE(1,"%s",__func__); + int i = 0; + int j = 0; + TRACE(1, "%s", __func__); - for(i =0;ichan_sel_remDev; - // default channel is NULL - *(ctx->chan_sel_channel) = NULL; - for(i = 0 ; i < BT_DEVICE_NUM ; i++) { - // Other profile connected - curr_channel = app_bt_device.hf_channel[i]; - if (app_bt_is_any_profile_connected(i)) { - matching_remdev = app_bt_get_connected_profile_remdev(i); - TRACE(3,"device_id=%d, hfp_select_channel : remdev=0x%x:0x%x.", i, wanted_remdev, matching_remdev); - TRACE(1,"device_id=%d, hfp_select_channel : other_profile_connected.", i); - if (wanted_remdev == matching_remdev) { - TRACE(2,"device_id=%d, hfp_select_channel : found_same_remdev : 0x%x", i, &(app_bt_device.hf_channel[i])); - if (btif_get_hf_chan_state(curr_channel) == BTIF_HF_STATE_CLOSED) { - TRACE(1,"device_id=%d, hfp_select_channel : current_channel_is_closed, good.", i); - *(ctx->chan_sel_channel) = (uint32_t *)curr_channel; - } - else { - TRACE(2,"device_id=%d, hfp_select_channel : other_profile_connected: current_channel_is_not_closed %d, ohno.", i, btif_get_hf_chan_state(curr_channel)); - TRACE(1,"device_id=%d, hfp_select_channel : other_profile_connected: missed right channel, found nothing, return", i); - } - return; - } - else { - TRACE(1,"device_id=%d, hfp_select_channel : different_remdev, see next device id", i); - } - } - else { - TRACE(1,"device_id=%d, hfp_select_channel : other_profile_not_connected.", i); - // first found idle device id is min device id we want - // Assume : other profile will use device id ascending - // TODO to keep other profile use device id ascending - if (btif_get_hf_chan_state(curr_channel) == BTIF_HF_STATE_CLOSED) { - TRACE(1,"device_id=%d, hfp_select_channel : current_channel_is_closed, choose this idle channel.", i); - *(ctx->chan_sel_channel) = (uint32_t *)curr_channel; - } - else { - TRACE(2,"device_id=%d, hfp_select_channel : no_other_profile_connected : current_channel_is_not_closed %d, ohno.", i, btif_get_hf_chan_state(curr_channel)); - TRACE(1,"device_id=%d, hfp_select_channel : no_other_profile_connected : missed right channel, found nothing, return", i); - } - return; + wanted_remdev = ctx->chan_sel_remDev; + // default channel is NULL + *(ctx->chan_sel_channel) = NULL; + for (i = 0; i < BT_DEVICE_NUM; i++) { + // Other profile connected + curr_channel = app_bt_device.hf_channel[i]; + if (app_bt_is_any_profile_connected(i)) { + matching_remdev = app_bt_get_connected_profile_remdev(i); + TRACE(3, "device_id=%d, hfp_select_channel : remdev=0x%x:0x%x.", i, + wanted_remdev, matching_remdev); + TRACE(1, "device_id=%d, hfp_select_channel : other_profile_connected.", + i); + if (wanted_remdev == matching_remdev) { + TRACE(2, "device_id=%d, hfp_select_channel : found_same_remdev : 0x%x", + i, &(app_bt_device.hf_channel[i])); + if (btif_get_hf_chan_state(curr_channel) == BTIF_HF_STATE_CLOSED) { + TRACE(1, + "device_id=%d, hfp_select_channel : current_channel_is_closed, " + "good.", + i); + *(ctx->chan_sel_channel) = (uint32_t *)curr_channel; + } else { + TRACE(2, + "device_id=%d, hfp_select_channel : other_profile_connected: " + "current_channel_is_not_closed %d, ohno.", + i, btif_get_hf_chan_state(curr_channel)); + TRACE(1, + "device_id=%d, hfp_select_channel : other_profile_connected: " + "missed right channel, found nothing, return", + i); } + return; + } else { + TRACE(1, + "device_id=%d, hfp_select_channel : different_remdev, see next " + "device id", + i); + } + } else { + TRACE(1, + "device_id=%d, hfp_select_channel : other_profile_not_connected.", + i); + // first found idle device id is min device id we want + // Assume : other profile will use device id ascending + // TODO to keep other profile use device id ascending + if (btif_get_hf_chan_state(curr_channel) == BTIF_HF_STATE_CLOSED) { + TRACE(1, + "device_id=%d, hfp_select_channel : current_channel_is_closed, " + "choose this idle channel.", + i); + *(ctx->chan_sel_channel) = (uint32_t *)curr_channel; + } else { + TRACE(2, + "device_id=%d, hfp_select_channel : no_other_profile_connected : " + "current_channel_is_not_closed %d, ohno.", + i, btif_get_hf_chan_state(curr_channel)); + TRACE(1, + "device_id=%d, hfp_select_channel : no_other_profile_connected : " + "missed right channel, found nothing, return", + i); + } + return; } + } } #endif #endif -void app_hfp_event_callback(hf_chan_handle_t chan, struct hfp_context *ctx) -{ - struct bt_cb_tag* bt_drv_func_cb = bt_drv_get_func_cb_ptr(); +void app_hfp_event_callback(hf_chan_handle_t chan, struct hfp_context *ctx) { + struct bt_cb_tag *bt_drv_func_cb = bt_drv_get_func_cb_ptr(); #ifdef __BT_ONE_BRING_TWO__ - if (ctx->event == BTIF_HF_EVENT_SELECT_CHANNEL) { + if (ctx->event == BTIF_HF_EVENT_SELECT_CHANNEL) { #if defined(__BT_SELECT_PROF_DEVICE_ID__) - _app_hfp_select_channel(chan, ctx); + _app_hfp_select_channel(chan, ctx); #endif - return; - } - hfp_chan_id_distinguish(chan); + return; + } + hfp_chan_id_distinguish(chan); #else - if (ctx->event == BTIF_HF_EVENT_SELECT_CHANNEL) { - return; + if (ctx->event == BTIF_HF_EVENT_SELECT_CHANNEL) { + return; + } + chan_id_flag.id = BT_DEVICE_ID_1; +#endif + switch (ctx->event) { + case BTIF_HF_EVENT_SERVICE_CONNECTED: + hfp_connected_ind_handler(chan, ctx); + break; + case BTIF_HF_EVENT_AUDIO_DATA_SENT: + hfp_audio_data_sent_handler(chan, ctx); + break; + case BTIF_HF_EVENT_AUDIO_DATA: + hfp_audio_data_handler(chan, ctx); + break; + case BTIF_HF_EVENT_SERVICE_DISCONNECTED: + hfp_disconnected_ind_handler(chan, ctx); + break; + case BTIF_HF_EVENT_CALL_IND: + hfp_call_ind_handler(chan, ctx); + break; + case BTIF_HF_EVENT_CALLSETUP_IND: + hfp_callsetup_ind_handler(chan, ctx); + break; + case BTIF_HF_EVENT_CURRENT_CALL_STATE: + hfp_current_call_state_handler(chan, ctx); + break; + case BTIF_HF_EVENT_AUDIO_CONNECTED: +#ifdef IBRT + { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + bt_drv_reg_op_set_agc_thd(p_ibrt_ctrl->current_role == IBRT_MASTER, true); + + if (!btif_besaud_is_connected()) { + bt_drv_reg_op_hack_max_slot(p_ibrt_ctrl->mobile_conhandle - 0x80, 1); } - chan_id_flag.id = BT_DEVICE_ID_1; + } #endif - switch(ctx->event) { - case BTIF_HF_EVENT_SERVICE_CONNECTED: - hfp_connected_ind_handler(chan, ctx); - break; - case BTIF_HF_EVENT_AUDIO_DATA_SENT: - hfp_audio_data_sent_handler(chan, ctx); - break; - case BTIF_HF_EVENT_AUDIO_DATA: - hfp_audio_data_handler(chan, ctx); - break; - case BTIF_HF_EVENT_SERVICE_DISCONNECTED: - hfp_disconnected_ind_handler(chan, ctx); - break; - case BTIF_HF_EVENT_CALL_IND: - hfp_call_ind_handler(chan, ctx); - break; - case BTIF_HF_EVENT_CALLSETUP_IND: - hfp_callsetup_ind_handler(chan, ctx); - break; - case BTIF_HF_EVENT_CURRENT_CALL_STATE: - hfp_current_call_state_handler(chan, ctx); - break; - case BTIF_HF_EVENT_AUDIO_CONNECTED: - #ifdef IBRT - { - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - bt_drv_reg_op_set_agc_thd(p_ibrt_ctrl->current_role == IBRT_MASTER,true); - if(!btif_besaud_is_connected()) - { - bt_drv_reg_op_hack_max_slot(p_ibrt_ctrl->mobile_conhandle-0x80,1); - } - } - #endif + if (bt_drv_func_cb->bt_switch_agc != NULL) { + bt_drv_func_cb->bt_switch_agc(BT_HFP_WORK_MODE); + } - if(bt_drv_func_cb->bt_switch_agc != NULL) - { - bt_drv_func_cb->bt_switch_agc(BT_HFP_WORK_MODE); - } + hfp_audio_connected_handler(chan, ctx); + break; + case BTIF_HF_EVENT_AUDIO_DISCONNECTED: - hfp_audio_connected_handler(chan, ctx); - break; - case BTIF_HF_EVENT_AUDIO_DISCONNECTED: + if (bt_drv_func_cb->bt_switch_agc != NULL) { + bt_drv_func_cb->bt_switch_agc(BT_IDLE_MODE); + } - if(bt_drv_func_cb->bt_switch_agc != NULL) - { - bt_drv_func_cb->bt_switch_agc(BT_IDLE_MODE); - } - - hfp_audio_disconnected_handler(chan, ctx); - break; - case BTIF_HF_EVENT_RING_IND: - hfp_ring_ind_handler(chan, ctx); - break; - case BTIF_HF_EVENT_SPEAKER_VOLUME: - hfp_speak_volume_handler(chan, ctx); - break; + hfp_audio_disconnected_handler(chan, ctx); + break; + case BTIF_HF_EVENT_RING_IND: + hfp_ring_ind_handler(chan, ctx); + break; + case BTIF_HF_EVENT_SPEAKER_VOLUME: + hfp_speak_volume_handler(chan, ctx); + break; #ifdef SUPPORT_SIRI - case BTIF_HF_EVENT_SIRI_STATUS: - break; + case BTIF_HF_EVENT_SIRI_STATUS: + break; #endif - case BTIF_HF_EVENT_BES_TEST: - hfp_bes_test_handler(chan, ctx); - break; - case BTIF_HF_EVENT_READ_AG_INDICATORS_STATUS: - hfp_read_ag_ind_status_handler(chan, ctx); - break; - case BTIF_HF_EVENT_CALLHELD_IND: - hfp_call_held_ind_handler(chan, ctx); - break; - case BTIF_HF_EVENT_COMMAND_COMPLETE: - break; - case BTIF_HF_EVENT_AT_RESULT_DATA: - TRACE(1,"received AT command: %s", ctx->ptr); + case BTIF_HF_EVENT_BES_TEST: + hfp_bes_test_handler(chan, ctx); + break; + case BTIF_HF_EVENT_READ_AG_INDICATORS_STATUS: + hfp_read_ag_ind_status_handler(chan, ctx); + break; + case BTIF_HF_EVENT_CALLHELD_IND: + hfp_call_held_ind_handler(chan, ctx); + break; + case BTIF_HF_EVENT_COMMAND_COMPLETE: + break; + case BTIF_HF_EVENT_AT_RESULT_DATA: + TRACE(1, "received AT command: %s", ctx->ptr); #ifdef __INTERACTION__ - if(!memcmp(oppo_self_defined_command_response, ctx->ptr, strlen(oppo_self_defined_command_response))) + if (!memcmp(oppo_self_defined_command_response, ctx->ptr, + strlen(oppo_self_defined_command_response))) { + for (int i = 0; i < BT_DEVICE_NUM; i++) { + chan = app_bt_device.hf_channel[i]; { - for(int i=0; iptr, strlen(huawei_self_defined_command_response)+1)) - { - uint8_t *pSelfDefinedCommandSupport = app_battery_get_mobile_support_self_defined_command_p(); - *pSelfDefinedCommandSupport = 1; + if (!memcmp(huawei_self_defined_command_response, ctx->ptr, + strlen(huawei_self_defined_command_response) + 1)) { + uint8_t *pSelfDefinedCommandSupport = + app_battery_get_mobile_support_self_defined_command_p(); + *pSelfDefinedCommandSupport = 1; - TRACE(0,"send self defined AT command to mobile."); - send_selfdefined_battery_report_AT_command(); - } -#endif - break; - - case BTIF_HF_EVENT_VOICE_REC_STATE: - hfp_voice_rec_state_ind_handler(chan, ctx); - break; - - default: - break; + TRACE(0, "send self defined AT command to mobile."); + send_selfdefined_battery_report_AT_command(); } +#endif + break; + + case BTIF_HF_EVENT_VOICE_REC_STATE: + hfp_voice_rec_state_ind_handler(chan, ctx); + break; + + default: + break; + } #ifdef __BT_ONE_BRING_TWO__ - hfcall_next_sta_handler(ctx->event); + hfcall_next_sta_handler(ctx->event); #endif #if defined(IBRT) - app_tws_ibrt_profile_callback(BTIF_APP_HFP_PROFILE_ID,(void *)chan, (void *)ctx); + app_tws_ibrt_profile_callback(BTIF_APP_HFP_PROFILE_ID, (void *)chan, + (void *)ctx); #endif } -uint8_t btapp_hfp_get_call_state(void) -{ - uint8_t i; - for (i = 0; i < BT_DEVICE_NUM; i++) { - if (app_bt_device.hfchan_call[i] == BTIF_HF_CALL_ACTIVE) { - return 1; - } +uint8_t btapp_hfp_get_call_state(void) { + uint8_t i; + for (i = 0; i < BT_DEVICE_NUM; i++) { + if (app_bt_device.hfchan_call[i] == BTIF_HF_CALL_ACTIVE) { + return 1; } - return 0; + } + return 0; } -uint8_t btapp_hfp_get_call_setup(void) -{ - uint8_t i; - for (i = 0; i < BT_DEVICE_NUM; i++){ - if ((app_bt_device.hfchan_callSetup[i] != BTIF_HF_CALL_SETUP_NONE)){ - return (app_bt_device.hfchan_callSetup[i]); - } +uint8_t btapp_hfp_get_call_setup(void) { + uint8_t i; + for (i = 0; i < BT_DEVICE_NUM; i++) { + if ((app_bt_device.hfchan_callSetup[i] != BTIF_HF_CALL_SETUP_NONE)) { + return (app_bt_device.hfchan_callSetup[i]); } - return 0; + } + return 0; } -uint8_t btapp_hfp_incoming_calls(void) -{ - uint8_t i; - for (i = 0; i < BT_DEVICE_NUM; i++) { - if (app_bt_device.hfchan_callSetup[i] == BTIF_HF_CALL_SETUP_IN) { - return 1; - } +uint8_t btapp_hfp_incoming_calls(void) { + uint8_t i; + for (i = 0; i < BT_DEVICE_NUM; i++) { + if (app_bt_device.hfchan_callSetup[i] == BTIF_HF_CALL_SETUP_IN) { + return 1; } - return 0; + } + return 0; } -bool btapp_hfp_is_call_active(void) -{ - uint8_t i; - for (i = 0; i < BT_DEVICE_NUM; i++){ - if ((app_bt_device.hfchan_call[i] == BTIF_HF_CALL_ACTIVE) && - (app_bt_device.hf_audio_state[i] == BTIF_HF_AUDIO_CON)) { - return true; - } +bool btapp_hfp_is_call_active(void) { + uint8_t i; + for (i = 0; i < BT_DEVICE_NUM; i++) { + if ((app_bt_device.hfchan_call[i] == BTIF_HF_CALL_ACTIVE) && + (app_bt_device.hf_audio_state[i] == BTIF_HF_AUDIO_CON)) { + return true; } - return false; + } + return false; } -bool btapp_hfp_is_sco_active(void) -{ - uint8_t i; - for (i = 0; i < BT_DEVICE_NUM; i++) { - if (app_bt_device.hf_audio_state[i] == BTIF_HF_AUDIO_CON) { - return true; - } +bool btapp_hfp_is_sco_active(void) { + uint8_t i; + for (i = 0; i < BT_DEVICE_NUM; i++) { + if (app_bt_device.hf_audio_state[i] == BTIF_HF_AUDIO_CON) { + return true; } - return false; + } + return false; } -bool btapp_hfp_is_dev_call_active(uint8_t devId) -{ - return ((app_bt_device.hfchan_call[devId] == BTIF_HF_CALL_ACTIVE) && - (app_bt_device.hf_audio_state[devId] == BTIF_HF_AUDIO_CON)); +bool btapp_hfp_is_dev_call_active(uint8_t devId) { + return ((app_bt_device.hfchan_call[devId] == BTIF_HF_CALL_ACTIVE) && + (app_bt_device.hf_audio_state[devId] == BTIF_HF_AUDIO_CON)); } -bool btapp_hfp_is_dev_sco_connected(uint8_t devId) -{ - return (app_bt_device.hf_audio_state[devId] == BTIF_HF_AUDIO_CON); +bool btapp_hfp_is_dev_sco_connected(uint8_t devId) { + return (app_bt_device.hf_audio_state[devId] == BTIF_HF_AUDIO_CON); } -uint8_t btapp_hfp_get_call_active(void) -{ - uint8_t i; - for (i = 0; i < BT_DEVICE_NUM; i++) { - if ((app_bt_device.hfchan_call[i] == BTIF_HF_CALL_ACTIVE) || - (app_bt_device.hfchan_callSetup[i] == BTIF_HF_CALL_SETUP_ALERT)){ +uint8_t btapp_hfp_get_call_active(void) { + uint8_t i; + for (i = 0; i < BT_DEVICE_NUM; i++) { + if ((app_bt_device.hfchan_call[i] == BTIF_HF_CALL_ACTIVE) || + (app_bt_device.hfchan_callSetup[i] == BTIF_HF_CALL_SETUP_ALERT)) { - return 1; - } + return 1; } - return 0; + } + return 0; } -void btapp_hfp_report_speak_gain(void) -{ - uint8_t i; - btif_remote_device_t *remDev = NULL; - btif_link_mode_t mode = BTIF_BLM_SNIFF_MODE; - hf_chan_handle_t chan; +void btapp_hfp_report_speak_gain(void) { + uint8_t i; + btif_remote_device_t *remDev = NULL; + btif_link_mode_t mode = BTIF_BLM_SNIFF_MODE; + hf_chan_handle_t chan; - - for(i = 0; i < BT_DEVICE_NUM; i++) { - osapi_lock_stack(); - remDev = (btif_remote_device_t *)btif_hf_cmgr_get_remote_device(app_bt_device.hf_channel[i]); - if (remDev){ - mode = btif_me_get_current_mode(remDev); - } else { - mode = BTIF_BLM_SNIFF_MODE; - } - chan = app_bt_device.hf_channel[i]; - if ((btif_get_hf_chan_state(chan) == BTIF_HF_STATE_OPEN) && - (mode == BTIF_BLM_ACTIVE_MODE)) { - btif_hf_report_speaker_volume(chan, hfp_volume_get((enum BT_DEVICE_ID_T)i)); - } - osapi_unlock_stack(); + for (i = 0; i < BT_DEVICE_NUM; i++) { + osapi_lock_stack(); + remDev = (btif_remote_device_t *)btif_hf_cmgr_get_remote_device( + app_bt_device.hf_channel[i]); + if (remDev) { + mode = btif_me_get_current_mode(remDev); + } else { + mode = BTIF_BLM_SNIFF_MODE; } - - + chan = app_bt_device.hf_channel[i]; + if ((btif_get_hf_chan_state(chan) == BTIF_HF_STATE_OPEN) && + (mode == BTIF_BLM_ACTIVE_MODE)) { + btif_hf_report_speaker_volume(chan, + hfp_volume_get((enum BT_DEVICE_ID_T)i)); + } + osapi_unlock_stack(); + } } -uint8_t btapp_hfp_need_mute(void) -{ - return app_bt_device.hf_mute_flag; -} +uint8_t btapp_hfp_need_mute(void) { return app_bt_device.hf_mute_flag; } int32_t hfp_mic_need_skip_frame_cnt = 0; -bool btapp_hfp_mic_need_skip_frame(void) -{ - bool nRet; +bool btapp_hfp_mic_need_skip_frame(void) { + bool nRet; - if (hfp_mic_need_skip_frame_cnt > 0) { - hfp_mic_need_skip_frame_cnt--; - nRet = true; - } else { - app_hfp_mute_upstream(0, false); - nRet = false; - } - return nRet; + if (hfp_mic_need_skip_frame_cnt > 0) { + hfp_mic_need_skip_frame_cnt--; + nRet = true; + } else { + app_hfp_mute_upstream(0, false); + nRet = false; + } + return nRet; } -void btapp_hfp_mic_need_skip_frame_set(int32_t skip_frame) -{ - hfp_mic_need_skip_frame_cnt = skip_frame; +void btapp_hfp_mic_need_skip_frame_set(int32_t skip_frame) { + hfp_mic_need_skip_frame_cnt = skip_frame; } #if defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) @@ -1972,183 +1997,175 @@ typedef void (*btapp_set_sco_switch_cmd_callback)(void); btapp_set_sco_switch_cmd_callback set_sco_switch_cmd_callback; -void btapp_sco_switch_set_pcm(void) -{ - TRACE(0,"btapp_sco_switch_set_pcm\n"); - TRACE(1,"0xd02201b0 = 0x%x before\n",*(volatile uint32_t *)(0xd02201b0)); - osDelay(20); - btdrv_pcm_enable(); - TRACE(1,"0xd02201b0 = 0x%x after\n",*(volatile uint32_t *)(0xd02201b0)); +void btapp_sco_switch_set_pcm(void) { + TRACE(0, "btapp_sco_switch_set_pcm\n"); + TRACE(1, "0xd02201b0 = 0x%x before\n", *(volatile uint32_t *)(0xd02201b0)); + osDelay(20); + btdrv_pcm_enable(); + TRACE(1, "0xd02201b0 = 0x%x after\n", *(volatile uint32_t *)(0xd02201b0)); } #endif -void app_hfp_init(void) -{ - hfp_hfcommand_mempool_init(); +void app_hfp_init(void) { + hfp_hfcommand_mempool_init(); #if defined(ENHANCED_STACK) - btif_hfp_initialize(); + btif_hfp_initialize(); #endif /* ENHANCED_STACK */ - app_bt_device.curr_hf_channel_id = BT_DEVICE_ID_1; - app_bt_device.hf_mute_flag = 0; + app_bt_device.curr_hf_channel_id = BT_DEVICE_ID_1; + app_bt_device.hf_mute_flag = 0; - for (uint8_t i = 0; i < BT_DEVICE_NUM; i++) { - app_bt_device.hf_channel[i] = btif_hf_create_channel(); - if (!app_bt_device.hf_channel[i]) { - ASSERT(0, "Serious error: cannot create hf channel\n"); - } - btif_hf_init_channel(app_bt_device.hf_channel[i]); - app_bt_device.hfchan_call[i] = 0; - app_bt_device.hfchan_callSetup[i] = 0; - app_bt_device.hf_audio_state[i] = BTIF_HF_AUDIO_DISCON, - app_bt_device.hf_conn_flag[i] = false; - app_bt_device.hf_voice_en[i] = 0; + for (uint8_t i = 0; i < BT_DEVICE_NUM; i++) { + app_bt_device.hf_channel[i] = btif_hf_create_channel(); + if (!app_bt_device.hf_channel[i]) { + ASSERT(0, "Serious error: cannot create hf channel\n"); } - btif_hf_register_callback(app_hfp_event_callback); + btif_hf_init_channel(app_bt_device.hf_channel[i]); + app_bt_device.hfchan_call[i] = 0; + app_bt_device.hfchan_callSetup[i] = 0; + app_bt_device.hf_audio_state[i] = BTIF_HF_AUDIO_DISCON, + app_bt_device.hf_conn_flag[i] = false; + app_bt_device.hf_voice_en[i] = 0; + } + btif_hf_register_callback(app_hfp_event_callback); #if defined(SUPPORT_BATTERY_REPORT) || defined(SUPPORT_HF_INDICATORS) - Besbt_hook_handler_set(BESBT_HOOK_USER_3, app_hfp_battery_report_proc); + Besbt_hook_handler_set(BESBT_HOOK_USER_3, app_hfp_battery_report_proc); #endif #if defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) - set_sco_switch_cmd_callback = btapp_sco_switch_set_pcm; + set_sco_switch_cmd_callback = btapp_sco_switch_set_pcm; #endif - app_hfp_mute_upstream(chan_id_flag.id, true); + app_hfp_mute_upstream(chan_id_flag.id, true); } -void app_hfp_enable_audio_link(bool isEnable) -{ - return; -} +void app_hfp_enable_audio_link(bool isEnable) { return; } #if defined(IBRT) -int hfp_ibrt_service_connected_mock(void) -{ - if (btif_get_hf_chan_state(app_bt_device.hf_channel[BT_DEVICE_ID_1]) == BTIF_HF_STATE_OPEN){ - TRACE(0,"::HF_EVENT_SERVICE_CONNECTED mock"); - app_bt_device.hf_conn_flag[chan_id_flag.id] = 1; - }else{ - TRACE(1,"::HF_EVENT_SERVICE_CONNECTED mock need check chan_state:%d", btif_get_hf_chan_state(app_bt_device.hf_channel[BT_DEVICE_ID_1])); - } +int hfp_ibrt_service_connected_mock(void) { + if (btif_get_hf_chan_state(app_bt_device.hf_channel[BT_DEVICE_ID_1]) == + BTIF_HF_STATE_OPEN) { + TRACE(0, "::HF_EVENT_SERVICE_CONNECTED mock"); + app_bt_device.hf_conn_flag[chan_id_flag.id] = 1; + } else { + TRACE(1, "::HF_EVENT_SERVICE_CONNECTED mock need check chan_state:%d", + btif_get_hf_chan_state(app_bt_device.hf_channel[BT_DEVICE_ID_1])); + } - return 0; + return 0; } -int hfp_ibrt_sync_get_status(ibrt_hfp_status_t *hfp_status) -{ - hfp_status->audio_state = (uint8_t)app_bt_device.hf_audio_state[BT_DEVICE_ID_1]; - hfp_status->volume = hfp_volume_get(BT_DEVICE_ID_1); - hfp_status->lmp_sco_hdl = 0; +int hfp_ibrt_sync_get_status(ibrt_hfp_status_t *hfp_status) { + hfp_status->audio_state = + (uint8_t)app_bt_device.hf_audio_state[BT_DEVICE_ID_1]; + hfp_status->volume = hfp_volume_get(BT_DEVICE_ID_1); + hfp_status->lmp_sco_hdl = 0; - if (hfp_status->audio_state == BTIF_HF_AUDIO_CON && - app_tws_ibrt_mobile_link_connected()) - { - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - uint16_t sco_connhdl = btif_me_get_scohdl_by_connhdl(p_ibrt_ctrl->mobile_conhandle); - hfp_status->lmp_sco_hdl = bt_drv_reg_op_lmp_sco_hdl_get(sco_connhdl); - TRACE(2,"ibrt_ui_log:get sco lmp hdl %04x %02x\n", sco_connhdl, hfp_status->lmp_sco_hdl); - } - - return 0; -} - -int hfp_ibrt_sync_set_status(ibrt_hfp_status_t *hfp_status) -{ + if (hfp_status->audio_state == BTIF_HF_AUDIO_CON && + app_tws_ibrt_mobile_link_connected()) { ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - btif_remote_device_t *remDev = NULL; + uint16_t sco_connhdl = + btif_me_get_scohdl_by_connhdl(p_ibrt_ctrl->mobile_conhandle); + hfp_status->lmp_sco_hdl = bt_drv_reg_op_lmp_sco_hdl_get(sco_connhdl); + TRACE(2, "ibrt_ui_log:get sco lmp hdl %04x %02x\n", sco_connhdl, + hfp_status->lmp_sco_hdl); + } - TRACE(4,"%s audio_state:%d volume:%d lmp_scohdl:%02x", __func__, hfp_status->audio_state, - hfp_status->volume, hfp_status->lmp_sco_hdl); - - app_bt_device.hf_audio_state[BT_DEVICE_ID_1] = (btif_audio_state_t)hfp_status->audio_state; - - if (app_tws_ibrt_mobile_link_connected()){ - remDev = btif_me_get_remote_device_by_handle(p_ibrt_ctrl->mobile_conhandle); - }else if (app_tws_ibrt_slave_ibrt_link_connected()){ - remDev = btif_me_get_remote_device_by_handle(p_ibrt_ctrl->ibrt_conhandle); - } - - if (remDev){ - app_bt_stream_volume_ptr_update((uint8_t *) btif_me_get_remote_device_bdaddr(remDev)); - }else{ - app_bt_stream_volume_ptr_update(NULL); - } - - hfp_volume_set(BT_DEVICE_ID_1, hfp_status->volume); - - p_ibrt_ctrl->ibrt_sco_lmphdl = 0; - - if (hfp_status->audio_state == BTIF_HF_AUDIO_CON && - hfp_status->lmp_sco_hdl != 0 && - app_tws_ibrt_slave_ibrt_link_connected()) - { - uint16_t sco_connhdl = 0x0100; //SYNC_HFP_STATUS arrive before mock sniffer_sco, so use 0x0100 directly - if (bt_drv_reg_op_lmp_sco_hdl_set(sco_connhdl, hfp_status->lmp_sco_hdl)) - { - TRACE(2,"ibrt_ui_log:set sco %04x lmp hdl %02x\n", sco_connhdl, hfp_status->lmp_sco_hdl); - } - else - { - // SYNC_HFP_STATUS may so much faster lead bt_drv_reg_op_lmp_sco_hdl_set fail, backup the value - p_ibrt_ctrl->ibrt_sco_lmphdl = hfp_status->lmp_sco_hdl; - } - } - - return 0; + return 0; } -int hfp_ibrt_sco_audio_connected(hfp_sco_codec_t codec, uint16_t sco_connhdl) -{ - int ret = BT_STS_SUCCESS; - ibrt_ctrl_t *p_ibrt_ctrl = NULL; +int hfp_ibrt_sync_set_status(ibrt_hfp_status_t *hfp_status) { + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + btif_remote_device_t *remDev = NULL; - TRACE(0,"::HF_EVENT_AUDIO_CONNECTED mock"); + TRACE(4, "%s audio_state:%d volume:%d lmp_scohdl:%02x", __func__, + hfp_status->audio_state, hfp_status->volume, hfp_status->lmp_sco_hdl); - app_bt_device.hf_audio_state[BT_DEVICE_ID_1] = BTIF_HF_AUDIO_CON; - btif_hf_set_negotiated_codec(app_bt_device.hf_channel[BT_DEVICE_ID_1] ,codec); - app_audio_manager_set_scocodecid(BT_DEVICE_ID_1,codec); + app_bt_device.hf_audio_state[BT_DEVICE_ID_1] = + (btif_audio_state_t)hfp_status->audio_state; + + if (app_tws_ibrt_mobile_link_connected()) { + remDev = btif_me_get_remote_device_by_handle(p_ibrt_ctrl->mobile_conhandle); + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + remDev = btif_me_get_remote_device_by_handle(p_ibrt_ctrl->ibrt_conhandle); + } + + if (remDev) { + app_bt_stream_volume_ptr_update( + (uint8_t *)btif_me_get_remote_device_bdaddr(remDev)); + } else { + app_bt_stream_volume_ptr_update(NULL); + } + + hfp_volume_set(BT_DEVICE_ID_1, hfp_status->volume); + + p_ibrt_ctrl->ibrt_sco_lmphdl = 0; + + if (hfp_status->audio_state == BTIF_HF_AUDIO_CON && + hfp_status->lmp_sco_hdl != 0 && + app_tws_ibrt_slave_ibrt_link_connected()) { + uint16_t sco_connhdl = 0x0100; // SYNC_HFP_STATUS arrive before mock + // sniffer_sco, so use 0x0100 directly + if (bt_drv_reg_op_lmp_sco_hdl_set(sco_connhdl, hfp_status->lmp_sco_hdl)) { + TRACE(2, "ibrt_ui_log:set sco %04x lmp hdl %02x\n", sco_connhdl, + hfp_status->lmp_sco_hdl); + } else { + // SYNC_HFP_STATUS may so much faster lead bt_drv_reg_op_lmp_sco_hdl_set + // fail, backup the value + p_ibrt_ctrl->ibrt_sco_lmphdl = hfp_status->lmp_sco_hdl; + } + } + + return 0; +} + +int hfp_ibrt_sco_audio_connected(hfp_sco_codec_t codec, uint16_t sco_connhdl) { + int ret = BT_STS_SUCCESS; + ibrt_ctrl_t *p_ibrt_ctrl = NULL; + + TRACE(0, "::HF_EVENT_AUDIO_CONNECTED mock"); + + app_bt_device.hf_audio_state[BT_DEVICE_ID_1] = BTIF_HF_AUDIO_CON; + btif_hf_set_negotiated_codec(app_bt_device.hf_channel[BT_DEVICE_ID_1], codec); + app_audio_manager_set_scocodecid(BT_DEVICE_ID_1, codec); #ifdef ENABLE_HFP_AUDIO_PENDING_FOR_MEDIA - if (bt_media_cur_is_bt_stream_media()) - { - app_hfp_set_starting_media_pending_flag(true, BT_DEVICE_ID_1); - } - else + if (bt_media_cur_is_bt_stream_media()) { + app_hfp_set_starting_media_pending_flag(true, BT_DEVICE_ID_1); + } else #endif - { - app_hfp_start_voice_media(BT_DEVICE_ID_1); - } - app_ibrt_if_sniff_checker_start(APP_IBRT_IF_SNIFF_CHECKER_USER_HFP); + { + app_hfp_start_voice_media(BT_DEVICE_ID_1); + } + app_ibrt_if_sniff_checker_start(APP_IBRT_IF_SNIFF_CHECKER_USER_HFP); - struct bt_cb_tag* bt_drv_func_cb = bt_drv_get_func_cb_ptr(); - if(bt_drv_func_cb->bt_switch_agc != NULL) - { - bt_drv_func_cb->bt_switch_agc(BT_HFP_WORK_MODE); - } + struct bt_cb_tag *bt_drv_func_cb = bt_drv_get_func_cb_ptr(); + if (bt_drv_func_cb->bt_switch_agc != NULL) { + bt_drv_func_cb->bt_switch_agc(BT_HFP_WORK_MODE); + } - p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - if (p_ibrt_ctrl->ibrt_sco_lmphdl != 0) - { - // set backuped lmphdl if it is failed in hfp_ibrt_sync_set_status - TRACE(2,"ibrt_ui_log:set sco %04x lmp hdl %02x\n", sco_connhdl, p_ibrt_ctrl->ibrt_sco_lmphdl); - bt_drv_reg_op_lmp_sco_hdl_set(sco_connhdl, p_ibrt_ctrl->ibrt_sco_lmphdl); - p_ibrt_ctrl->ibrt_sco_lmphdl = 0; - } + p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + if (p_ibrt_ctrl->ibrt_sco_lmphdl != 0) { + // set backuped lmphdl if it is failed in hfp_ibrt_sync_set_status + TRACE(2, "ibrt_ui_log:set sco %04x lmp hdl %02x\n", sco_connhdl, + p_ibrt_ctrl->ibrt_sco_lmphdl); + bt_drv_reg_op_lmp_sco_hdl_set(sco_connhdl, p_ibrt_ctrl->ibrt_sco_lmphdl); + p_ibrt_ctrl->ibrt_sco_lmphdl = 0; + } - return ret; + return ret; } -int hfp_ibrt_sco_audio_disconnected(void) -{ - int ret = BT_STS_SUCCESS; - TRACE(0,"::HF_EVENT_AUDIO_DISCONNECTED mock"); - app_bt_device.hf_audio_state[BT_DEVICE_ID_1] = BTIF_HF_AUDIO_DISCON; - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP,BT_STREAM_VOICE,BT_DEVICE_ID_1,0); - app_ibrt_if_sniff_checker_stop(APP_IBRT_IF_SNIFF_CHECKER_USER_HFP); +int hfp_ibrt_sco_audio_disconnected(void) { + int ret = BT_STS_SUCCESS; + TRACE(0, "::HF_EVENT_AUDIO_DISCONNECTED mock"); + app_bt_device.hf_audio_state[BT_DEVICE_ID_1] = BTIF_HF_AUDIO_DISCON; + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_VOICE, + BT_DEVICE_ID_1, 0); + app_ibrt_if_sniff_checker_stop(APP_IBRT_IF_SNIFF_CHECKER_USER_HFP); - struct bt_cb_tag* bt_drv_func_cb = bt_drv_get_func_cb_ptr(); - if(bt_drv_func_cb->bt_switch_agc != NULL) - { - bt_drv_func_cb->bt_switch_agc(BT_IDLE_MODE); - } - return ret; + struct bt_cb_tag *bt_drv_func_cb = bt_drv_get_func_cb_ptr(); + if (bt_drv_func_cb->bt_switch_agc != NULL) { + bt_drv_func_cb->bt_switch_agc(BT_IDLE_MODE); + } + return ret; } #endif diff --git a/services/bt_app/app_hsp.cpp b/services/bt_app/app_hsp.cpp index bd94e1e..6d10da3 100644 --- a/services/bt_app/app_hsp.cpp +++ b/services/bt_app/app_hsp.cpp @@ -13,30 +13,28 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "cmsis_os.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_trace.h" -#include "hal_cmu.h" -#include "hal_chipid.h" #include "analog.h" #include "app_audio.h" #include "app_status_ind.h" +#include "audioflinger.h" #include "bluetooth.h" +#include "cmsis_os.h" +#include "hal_chipid.h" +#include "hal_cmu.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "lockcqueue.h" #include "nvrecord.h" -#include "nvrecord_env.h" #include "nvrecord_dev.h" - - +#include "nvrecord_env.h" +#include #include "besbt.h" -#include "cqueue.h" -#include "btapp.h" #include "app_bt.h" +#include "btapp.h" +#include "cqueue.h" #include "nvrecord.h" @@ -49,35 +47,31 @@ #error can not defined at the same time. #endif -#if defined (__HSP_ENABLE__) - -#define MODIFY_HS_CALL_SETUP_IN HF_CALL_SETUP_IN -#define MODIFY_HS_CALL_ACTIVE HF_CALL_ACTIVE -#define MODIFY_HS_CALL_NONE HF_CALL_NONE +#if defined(__HSP_ENABLE__) +#define MODIFY_HS_CALL_SETUP_IN HF_CALL_SETUP_IN +#define MODIFY_HS_CALL_ACTIVE HF_CALL_ACTIVE +#define MODIFY_HS_CALL_NONE HF_CALL_NONE extern struct BT_DEVICE_ID_DIFF chan_id_flag; -extern struct BT_DEVICE_T app_bt_device; +extern struct BT_DEVICE_T app_bt_device; #if defined(SCO_LOOP) #define HF_LOOP_CNT (20) #define HF_LOOP_SIZE (360) - -extern uint8_t hf_loop_buffer[HF_LOOP_CNT*HF_LOOP_SIZE]; +extern uint8_t hf_loop_buffer[HF_LOOP_CNT * HF_LOOP_SIZE]; extern uint32_t hf_loop_buffer_len[HF_LOOP_CNT]; -extern uint32_t hf_loop_buffer_valid ; -extern uint32_t hf_loop_buffer_size ; -extern char hf_loop_buffer_w_idx ; +extern uint32_t hf_loop_buffer_valid; +extern uint32_t hf_loop_buffer_size; +extern char hf_loop_buffer_w_idx; #endif #ifndef _SCO_BTPCM_CHANNEL_ -extern struct hf_sendbuff_control hf_sendbuff_ctrl; +extern struct hf_sendbuff_control hf_sendbuff_ctrl; #endif - - #ifdef __BT_ONE_BRING_TWO__ extern void hfp_chan_id_distinguish(HfChannel *Chan); #endif @@ -89,274 +83,264 @@ extern int store_voicemsbc_buffer(unsigned char *buf, unsigned int len); extern int hfp_volume_get(enum BT_DEVICE_ID_T id); extern void hfp_volume_local_set(int8_t vol); extern int hfp_volume_set(enum BT_DEVICE_ID_T id, int vol); -extern void app_bt_profile_connect_manager_hs(enum BT_DEVICE_ID_T id, HsChannel *Chan, HsCallbackParms *Info);; +extern void app_bt_profile_connect_manager_hs(enum BT_DEVICE_ID_T id, + HsChannel *Chan, + HsCallbackParms *Info); +; #ifdef __BT_ONE_BRING_TWO__ -void hsp_chan_id_distinguish(HsChannel *Chan) -{ - if(Chan == &app_bt_device.hs_channel[BT_DEVICE_ID_1]){ - chan_id_flag.id = BT_DEVICE_ID_1; - chan_id_flag.id_other = BT_DEVICE_ID_2; - }else if(Chan == &app_bt_device.hsf_channel[BT_DEVICE_ID_2]){ - chan_id_flag.id = BT_DEVICE_ID_2; - chan_id_flag.id_other = BT_DEVICE_ID_1; - } +void hsp_chan_id_distinguish(HsChannel *Chan) { + if (Chan == &app_bt_device.hs_channel[BT_DEVICE_ID_1]) { + chan_id_flag.id = BT_DEVICE_ID_1; + chan_id_flag.id_other = BT_DEVICE_ID_2; + } else if (Chan == &app_bt_device.hsf_channel[BT_DEVICE_ID_2]) { + chan_id_flag.id = BT_DEVICE_ID_2; + chan_id_flag.id_other = BT_DEVICE_ID_1; + } } #endif -int app_hsp_hscommand_mempool_init(void) -{ - app_hfp_hfcommand_mempool_init(); - return 0; +int app_hsp_hscommand_mempool_init(void) { + app_hfp_hfcommand_mempool_init(); + return 0; } -int app_hsp_hscommand_mempool_calloc(HsCommand **hs_cmd_p) -{ - app_hfp_hfcommand_mempool_calloc(hs_cmd_p); - return 0; +int app_hsp_hscommand_mempool_calloc(HsCommand **hs_cmd_p) { + app_hfp_hfcommand_mempool_calloc(hs_cmd_p); + return 0; } -int app_hsp_hscommand_mempool_free(HsCommand *hs_cmd_p) -{ - app_hfp_hfcommand_mempool_free(hs_cmd_p); - return 0; +int app_hsp_hscommand_mempool_free(HsCommand *hs_cmd_p) { + app_hfp_hfcommand_mempool_free(hs_cmd_p); + return 0; } #if 0 -#define app_hsp_hscommand_mempool app_hfp_hfcommand_mempool -#define app_hsp_hscommand_mempool_init app_hfp_hfcommand_mempool_init -#define app_hsp_hscommand_mempool_calloc app_hfp_hfcommand_mempool_calloc -#define app_hsp_hscommand_mempool_free app_hfp_hfcommand_mempool_free +#define app_hsp_hscommand_mempool app_hfp_hfcommand_mempool +#define app_hsp_hscommand_mempool_init app_hfp_hfcommand_mempool_init +#define app_hsp_hscommand_mempool_calloc app_hfp_hfcommand_mempool_calloc +#define app_hsp_hscommand_mempool_free app_hfp_hfcommand_mempool_free #endif - -XaStatus app_hs_handle_cmd(HsChannel *Chan,uint8_t cmd_type) -{ - HsCommand *hs_cmd_p; - int8_t ret = 0; - switch(cmd_type){ - case APP_REPORT_SPEAKER_VOL_CMD: - app_hsp_hscommand_mempool_calloc(&hs_cmd_p); - if (hs_cmd_p){ - if(HS_ReportSpeakerVolume(Chan,hfp_volume_get(chan_id_flag.id), hs_cmd_p) != BT_STATUS_PENDING) - { - app_hsp_hscommand_mempool_free(hs_cmd_p); - ret = -1; - } - } - break; - case APP_CPKD_CMD: - app_hsp_hscommand_mempool_calloc(&hs_cmd_p); - if (hs_cmd_p){ - if(HS_CKPD_CONTROL(Chan,hs_cmd_p) != BT_STATUS_PENDING) - { - app_hsp_hscommand_mempool_free(hs_cmd_p); - ret = -1; - } - } - break; - default: - break; - } - - return ret ; - -} - - - -// because hfp and hsp can not exist simultaneously , so we do not need to alloc 2 cmd pool! -void app_hsp_init(void) -{ - - - app_hsp_hscommand_mempool_init(); - - app_bt_device.curr_hs_channel_id = BT_DEVICE_ID_1; - app_bt_device.hs_mute_flag = 0; - - for(uint8_t i=0; ievent); + TRACE(2, "[%s] event = %d", __func__, Info->event); - switch(Info->event) - { - case HS_EVENT_SERVICE_CONNECTED: - TRACE(1,"::HS_EVENT_SERVICE_CONNECTED Chan_id:%d\n", chan_id_flag.id); - app_bt_profile_connect_manager_hs(chan_id_flag.id, Chan, Info); + switch (Info->event) { + case HS_EVENT_SERVICE_CONNECTED: + TRACE(1, "::HS_EVENT_SERVICE_CONNECTED Chan_id:%d\n", chan_id_flag.id); + app_bt_profile_connect_manager_hs(chan_id_flag.id, Chan, Info); #if !defined(FPGA) && defined(__BTIF_EARPHONE__) - if(Chan->state == HF_STATE_OPEN){ - ////report connected voice - app_bt_device.hs_conn_flag[chan_id_flag.id] = 1; - - } + if (Chan->state == HF_STATE_OPEN) { + ////report connected voice + app_bt_device.hs_conn_flag[chan_id_flag.id] = 1; + } #endif - app_bt_stream_volume_ptr_update((uint8_t *)Info->p.remDev->bdAddr.addr); - if(app_hs_handle_cmd(Chan,APP_REPORT_SPEAKER_VOL_CMD) !=0) - TRACE(0,"app_hs_handle_cmd err"); + app_bt_stream_volume_ptr_update((uint8_t *)Info->p.remDev->bdAddr.addr); + if (app_hs_handle_cmd(Chan, APP_REPORT_SPEAKER_VOL_CMD) != 0) + TRACE(0, "app_hs_handle_cmd err"); - break; - case HS_EVENT_AUDIO_DATA_SENT: - TRACE(1,"::HF_EVENT_AUDIO_DATA_SENT %d\n", Info->event); + break; + case HS_EVENT_AUDIO_DATA_SENT: + TRACE(1, "::HF_EVENT_AUDIO_DATA_SENT %d\n", Info->event); #if defined(SCO_LOOP) - hf_loop_buffer_valid = 1; + hf_loop_buffer_valid = 1; #endif - break; - case HS_EVENT_AUDIO_DATA: - TRACE(0,"HF_EVENT_AUDIO_DATA"); + break; + case HS_EVENT_AUDIO_DATA: + TRACE(0, "HF_EVENT_AUDIO_DATA"); { #ifndef _SCO_BTPCM_CHANNEL_ - uint32_t idx = 0; - if (app_bt_stream_isrun(APP_BT_STREAM_HFP_PCM)){ - store_voicebtpcm_m2p_buffer(Info->p.audioData->data, Info->p.audioData->len); + uint32_t idx = 0; + if (app_bt_stream_isrun(APP_BT_STREAM_HFP_PCM)) { + store_voicebtpcm_m2p_buffer(Info->p.audioData->data, + Info->p.audioData->len); - idx = hf_sendbuff_ctrl.index%HF_SENDBUFF_MEMPOOL_NUM; - get_voicebtpcm_p2m_frame(&(hf_sendbuff_ctrl.mempool[idx].buffer[0]), Info->p.audioData->len); - hf_sendbuff_ctrl.mempool[idx].packet.data = &(hf_sendbuff_ctrl.mempool[idx].buffer[0]); - hf_sendbuff_ctrl.mempool[idx].packet.dataLen = Info->p.audioData->len; - hf_sendbuff_ctrl.mempool[idx].packet.flags = BTP_FLAG_NONE; - if(!app_bt_device.hf_mute_flag){ - HF_SendAudioData(Chan, &hf_sendbuff_ctrl.mempool[idx].packet); - } - hf_sendbuff_ctrl.index++; + idx = hf_sendbuff_ctrl.index % HF_SENDBUFF_MEMPOOL_NUM; + get_voicebtpcm_p2m_frame(&(hf_sendbuff_ctrl.mempool[idx].buffer[0]), + Info->p.audioData->len); + hf_sendbuff_ctrl.mempool[idx].packet.data = + &(hf_sendbuff_ctrl.mempool[idx].buffer[0]); + hf_sendbuff_ctrl.mempool[idx].packet.dataLen = Info->p.audioData->len; + hf_sendbuff_ctrl.mempool[idx].packet.flags = BTP_FLAG_NONE; + if (!app_bt_device.hf_mute_flag) { + HF_SendAudioData(Chan, &hf_sendbuff_ctrl.mempool[idx].packet); } + hf_sendbuff_ctrl.index++; + } #endif - } #if defined(SCO_LOOP) - memcpy(hf_loop_buffer + hf_loop_buffer_w_idx*HF_LOOP_SIZE, Info->p.audioData->data, Info->p.audioData->len); + memcpy(hf_loop_buffer + hf_loop_buffer_w_idx * HF_LOOP_SIZE, + Info->p.audioData->data, Info->p.audioData->len); hf_loop_buffer_len[hf_loop_buffer_w_idx] = Info->p.audioData->len; - hf_loop_buffer_w_idx = (hf_loop_buffer_w_idx+1)%HF_LOOP_CNT; + hf_loop_buffer_w_idx = (hf_loop_buffer_w_idx + 1) % HF_LOOP_CNT; ++hf_loop_buffer_size; if (hf_loop_buffer_size >= 18 && hf_loop_buffer_valid == 1) { - hf_loop_buffer_valid = 0; - idx = hf_loop_buffer_w_idx-17<0?(HF_LOOP_CNT-(17-hf_loop_buffer_w_idx)):hf_loop_buffer_w_idx-17; - pkt.flags = BTP_FLAG_NONE; - pkt.dataLen = hf_loop_buffer_len[idx]; - pkt.data = hf_loop_buffer + idx*HF_LOOP_SIZE; - HF_SendAudioData(Chan, &pkt); + hf_loop_buffer_valid = 0; + idx = hf_loop_buffer_w_idx - 17 < 0 + ? (HF_LOOP_CNT - (17 - hf_loop_buffer_w_idx)) + : hf_loop_buffer_w_idx - 17; + pkt.flags = BTP_FLAG_NONE; + pkt.dataLen = hf_loop_buffer_len[idx]; + pkt.data = hf_loop_buffer + idx * HF_LOOP_SIZE; + HF_SendAudioData(Chan, &pkt); } #endif - break; - case HS_EVENT_SERVICE_DISCONNECTED: - TRACE(2,"::HS_EVENT_SERVICE_DISCONNECTED Chan_id:%d, reason=%x\n", chan_id_flag.id,Info->p.remDev->discReason); - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP,BT_STREAM_VOICE,chan_id_flag.id,MAX_RECORD_NUM); + break; + case HS_EVENT_SERVICE_DISCONNECTED: + TRACE(2, "::HS_EVENT_SERVICE_DISCONNECTED Chan_id:%d, reason=%x\n", + chan_id_flag.id, Info->p.remDev->discReason); + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_VOICE, + chan_id_flag.id, MAX_RECORD_NUM); #if !defined(FPGA) && defined(__BTIF_EARPHONE__) - if(app_bt_device.hs_conn_flag[chan_id_flag.id] ){ - ////report device disconnected voice - app_bt_device.hs_conn_flag[chan_id_flag.id] = 0; - - } + if (app_bt_device.hs_conn_flag[chan_id_flag.id]) { + ////report device disconnected voice + app_bt_device.hs_conn_flag[chan_id_flag.id] = 0; + } #endif - app_bt_stream_volume_ptr_update(NULL); + app_bt_stream_volume_ptr_update(NULL); - app_bt_profile_connect_manager_hs(chan_id_flag.id, Chan, Info); - for (uint8_t i=0; istatus == BT_STATUS_SUCCESS){ - TRACE(1,"::HS_EVENT_AUDIO_CONNECTED chan_id:%d\n", chan_id_flag.id); - if((Chan->state == HF_STATE_OPEN) && (app_bt_device.hs_conn_flag[chan_id_flag.id] == 1)){ - app_bt_device.hschan_call[BT_DEVICE_ID_1] = MODIFY_HS_CALL_ACTIVE; - } + if (Info->status == BT_STATUS_SUCCESS) { + TRACE(1, "::HS_EVENT_AUDIO_CONNECTED chan_id:%d\n", chan_id_flag.id); + if ((Chan->state == HF_STATE_OPEN) && + (app_bt_device.hs_conn_flag[chan_id_flag.id] == 1)) { + app_bt_device.hschan_call[BT_DEVICE_ID_1] = MODIFY_HS_CALL_ACTIVE; + } - app_bt_device.curr_hs_channel_id = chan_id_flag.id; + app_bt_device.curr_hs_channel_id = chan_id_flag.id; - app_bt_device.phone_earphone_mark = 0; - app_bt_device.hs_mute_flag = 0; + app_bt_device.phone_earphone_mark = 0; + app_bt_device.hs_mute_flag = 0; - app_bt_device.hs_audio_state[chan_id_flag.id] = HF_AUDIO_CON; + app_bt_device.hs_audio_state[chan_id_flag.id] = HF_AUDIO_CON; #if defined(__FORCE_REPORTVOLUME_SOCON__) - app_hs_handle_cmd(Chan,APP_REPORT_SPEAKER_VOL_CMD); + app_hs_handle_cmd(Chan, APP_REPORT_SPEAKER_VOL_CMD); #endif - if (bt_media_cur_is_bt_stream_media()) - { - app_hfp_set_starting_media_pending_flag(true, BT_DEVICE_ID_1); - } - else - { - app_hfp_start_voice_media(BT_DEVICE_ID_1); - } - - } - break; - case HS_EVENT_AUDIO_DISCONNECTED: - TRACE(1,"::HS_EVENT_AUDIO_DISCONNECTED chan_id:%d\n", chan_id_flag.id); - - if(app_bt_device.hschan_call[chan_id_flag.id] == HF_CALL_ACTIVE){ - app_bt_device.phone_earphone_mark = 1; - } - - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP,BT_STREAM_VOICE,BT_DEVICE_ID_1,MAX_RECORD_NUM); - - break; - - case HS_EVENT_RING_IND: - TRACE(1,"::HS_EVENT_RING_IND chan_id:%d\n", chan_id_flag.id); -#if !defined(FPGA) && defined(__BTIF_EARPHONE__) -// if(app_bt_device.hs_audio_state[chan_id_flag.id] != HF_AUDIO_CON) - app_voice_report(APP_STATUS_INDICATION_INCOMINGCALL,chan_id_flag.id); -#endif - - break; - case HS_EVENT_SPEAKER_VOLUME: - TRACE(2,"::HS_EVENT_SPEAKER_VOLUME chan_id:%d,speaker gain = %x\n", chan_id_flag.id,Info->p.ptr); - hfp_volume_set(chan_id_flag.id, (int)(uint32_t)Info->p.ptr); - break; - - case HS_EVENT_COMMAND_COMPLETE: - TRACE(2,"::EVENT_HS_COMMAND_COMPLETE chan_id:%d %x\n", chan_id_flag.id, (HsCommand *)Info->p.ptr); - if (Info->p.ptr) - app_hsp_hscommand_mempool_free((HsCommand *)Info->p.ptr); - break; - default: - break; - + if (bt_media_cur_is_bt_stream_media()) { + app_hfp_set_starting_media_pending_flag(true, BT_DEVICE_ID_1); + } else { + app_hfp_start_voice_media(BT_DEVICE_ID_1); + } } + break; + case HS_EVENT_AUDIO_DISCONNECTED: + TRACE(1, "::HS_EVENT_AUDIO_DISCONNECTED chan_id:%d\n", chan_id_flag.id); + + if (app_bt_device.hschan_call[chan_id_flag.id] == HF_CALL_ACTIVE) { + app_bt_device.phone_earphone_mark = 1; + } + + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_STOP, BT_STREAM_VOICE, + BT_DEVICE_ID_1, MAX_RECORD_NUM); + + break; + + case HS_EVENT_RING_IND: + TRACE(1, "::HS_EVENT_RING_IND chan_id:%d\n", chan_id_flag.id); +#if !defined(FPGA) && defined(__BTIF_EARPHONE__) + // if(app_bt_device.hs_audio_state[chan_id_flag.id] != HF_AUDIO_CON) + app_voice_report(APP_STATUS_INDICATION_INCOMINGCALL, chan_id_flag.id); +#endif + + break; + case HS_EVENT_SPEAKER_VOLUME: + TRACE(2, "::HS_EVENT_SPEAKER_VOLUME chan_id:%d,speaker gain = %x\n", + chan_id_flag.id, Info->p.ptr); + hfp_volume_set(chan_id_flag.id, (int)(uint32_t)Info->p.ptr); + break; + + case HS_EVENT_COMMAND_COMPLETE: + TRACE(2, "::EVENT_HS_COMMAND_COMPLETE chan_id:%d %x\n", chan_id_flag.id, + (HsCommand *)Info->p.ptr); + if (Info->p.ptr) + app_hsp_hscommand_mempool_free((HsCommand *)Info->p.ptr); + break; + default: + break; + } } - #endif diff --git a/services/bt_app/app_keyhandle.cpp b/services/bt_app/app_keyhandle.cpp index 85e221c..9a4116f 100644 --- a/services/bt_app/app_keyhandle.cpp +++ b/services/bt_app/app_keyhandle.cpp @@ -14,47 +14,47 @@ * ****************************************************************************/ //#include "mbed.h" -#include +#include "analog.h" +#include "audioflinger.h" #include "cmsis.h" #include "cmsis_os.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_trace.h" #include "hal_cmu.h" -#include "analog.h" - +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "lockcqueue.h" +#include +#include "a2dp_api.h" +#include "avctp_api.h" +#include "avdtp_api.h" +#include "avrcp_api.h" #include "hfp_api.h" #include "me_api.h" -#include "a2dp_api.h" -#include "avdtp_api.h" -#include "avctp_api.h" -#include "avrcp_api.h" #include "besbt.h" -#include "cqueue.h" -#include "btapp.h" -#include "app_key.h" #include "app_audio.h" +#include "app_key.h" +#include "btapp.h" +#include "cqueue.h" -#include "apps.h" -#include "app_bt_stream.h" -#include "app_bt_media_manager.h" #include "app_bt.h" #include "app_bt_func.h" +#include "app_bt_media_manager.h" +#include "app_bt_stream.h" #include "app_hfp.h" +#include "apps.h" #include "bt_if.h" -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) #include "nvrecord_env.h" #endif #include "os_api.h" -extern struct BT_DEVICE_T app_bt_device; -//BT_DEVICE_ID_T g_current_device_id=BT_DEVICE_NUM; //used to change sco by one-bring-two -//BT_DEVICE_ID_T g_another_device_id=BT_DEVICE_NUM; //used to change sco by one-bring-two +extern struct BT_DEVICE_T app_bt_device; +// BT_DEVICE_ID_T g_current_device_id=BT_DEVICE_NUM; //used to change sco by +// one-bring-two BT_DEVICE_ID_T g_another_device_id=BT_DEVICE_NUM; //used to +// change sco by one-bring-two #ifdef BTIF_HID_DEVICE #include "app_bt_hid.h" @@ -64,289 +64,291 @@ extern struct BT_DEVICE_T app_bt_device; extern int app_hfp_siri_report(); extern int app_hfp_siri_voice(bool en); int open_siri_flag = 0; -void bt_key_handle_siri_key(enum APP_KEY_EVENT_T event) -{ - switch(event) - { - case APP_KEY_EVENT_NONE: - if(open_siri_flag == 1){ - TRACE(0,"open siri"); - app_hfp_siri_voice(true); - open_siri_flag = 0; - } /*else { - TRACE(0,"evnet none close siri"); - app_hfp_siri_voice(false); - }*/ - break; - case APP_KEY_EVENT_LONGLONGPRESS: - case APP_KEY_EVENT_UP: - //TRACE(0,"long long/up/click event close siri"); - //app_hfp_siri_voice(false); - break; - default: - TRACE(1,"unregister down key event=%x",event); - break; - } +void bt_key_handle_siri_key(enum APP_KEY_EVENT_T event) { + switch (event) { + case APP_KEY_EVENT_NONE: + if (open_siri_flag == 1) { + TRACE(0, "open siri"); + app_hfp_siri_voice(true); + open_siri_flag = 0; + } /*else { + TRACE(0,"evnet none close siri"); + app_hfp_siri_voice(false); + }*/ + break; + case APP_KEY_EVENT_LONGLONGPRESS: + case APP_KEY_EVENT_UP: + // TRACE(0,"long long/up/click event close siri"); + // app_hfp_siri_voice(false); + break; + default: + TRACE(1, "unregister down key event=%x", event); + break; + } } #endif -//bool hf_mute_flag = 0; +// bool hf_mute_flag = 0; -#if defined (__HSP_ENABLE__) +#if defined(__HSP_ENABLE__) -extern XaStatus app_hs_handle_cmd(HsChannel *Chan,uint8_t cmd_type); +extern XaStatus app_hs_handle_cmd(HsChannel *Chan, uint8_t cmd_type); -void hsp_handle_key(uint8_t hsp_key) -{ - HsCommand *hs_cmd_p; - HsChannel *hs_channel_tmp = NULL; - uint8_t ret= 0; +void hsp_handle_key(uint8_t hsp_key) { + HsCommand *hs_cmd_p; + HsChannel *hs_channel_tmp = NULL; + uint8_t ret = 0; #ifdef __BT_ONE_BRING_TWO__ - enum BT_DEVICE_ID_T another_device_id = (app_bt_device.curr_hs_channel_id == BT_DEVICE_ID_1) ? BT_DEVICE_ID_2 : BT_DEVICE_ID_1; - TRACE(1,"!!!hsp_handle_key curr_hf_channel=%d\n",app_bt_device.curr_hs_channel_id); - hs_channel_tmp = (app_bt_device.curr_hs_channel_id == BT_DEVICE_ID_1) ? &(app_bt_device.hs_channel[BT_DEVICE_ID_1]) : &(app_bt_device.hs_channel[BT_DEVICE_ID_2]); + enum BT_DEVICE_ID_T another_device_id = + (app_bt_device.curr_hs_channel_id == BT_DEVICE_ID_1) ? BT_DEVICE_ID_2 + : BT_DEVICE_ID_1; + TRACE(1, "!!!hsp_handle_key curr_hf_channel=%d\n", + app_bt_device.curr_hs_channel_id); + hs_channel_tmp = (app_bt_device.curr_hs_channel_id == BT_DEVICE_ID_1) + ? &(app_bt_device.hs_channel[BT_DEVICE_ID_1]) + : &(app_bt_device.hs_channel[BT_DEVICE_ID_2]); #else - hs_channel_tmp = &(app_bt_device.hs_channel[BT_DEVICE_ID_1]); + hs_channel_tmp = &(app_bt_device.hs_channel[BT_DEVICE_ID_1]); #endif - if(hsp_key == HSP_KEY_CKPD_CONTROL) - { - TRACE(0,"hsp_key = HSP_KEY_CKPD_CONTROL"); - if(app_hs_handle_cmd(hs_channel_tmp,APP_CPKD_CMD) !=0) - TRACE(0,"app_hs_handle_cmd err"); - - } - else if(hsp_key == HSP_KEY_CHANGE_TO_PHONE) - { - TRACE(0,"hsp_key = HSP_KEY_CHANGE_TO_PHONE"); - HS_DisconnectAudioLink(hs_channel_tmp); - } - else if(hsp_key == HSP_KEY_ADD_TO_EARPHONE) - { - TRACE(0,"hsp_key = HSP_KEY_ADD_TO_EARPHONE"); - HS_CreateAudioLink(hs_channel_tmp); - } - + if (hsp_key == HSP_KEY_CKPD_CONTROL) { + TRACE(0, "hsp_key = HSP_KEY_CKPD_CONTROL"); + if (app_hs_handle_cmd(hs_channel_tmp, APP_CPKD_CMD) != 0) + TRACE(0, "app_hs_handle_cmd err"); + } else if (hsp_key == HSP_KEY_CHANGE_TO_PHONE) { + TRACE(0, "hsp_key = HSP_KEY_CHANGE_TO_PHONE"); + HS_DisconnectAudioLink(hs_channel_tmp); + } else if (hsp_key == HSP_KEY_ADD_TO_EARPHONE) { + TRACE(0, "hsp_key = HSP_KEY_ADD_TO_EARPHONE"); + HS_CreateAudioLink(hs_channel_tmp); + } } #endif #ifdef __BT_ONE_BRING_TWO__ uint8_t gHfcallNextSta = HFCALL_NEXT_STA_NULL; -void hfcall_next_sta_handler(hf_event_t event) -{ - TRACE(0,"!!!hfcall_next_sta_handler curr_hf_channel=%d,gHfcallNextSta %d\n",app_bt_device.curr_hf_channel_id,gHfcallNextSta); - //hf_chan_handle_t hf_channel_curr = app_bt_device.hf_channel[app_bt_device.curr_hf_channel_id]; - enum BT_DEVICE_ID_T another_device_id = (app_bt_device.curr_hf_channel_id == BT_DEVICE_ID_1) ? BT_DEVICE_ID_2 : BT_DEVICE_ID_1; - hf_chan_handle_t hf_channel_another = app_bt_device.hf_channel[another_device_id]; +void hfcall_next_sta_handler(hf_event_t event) { + TRACE(0, "!!!hfcall_next_sta_handler curr_hf_channel=%d,gHfcallNextSta %d\n", + app_bt_device.curr_hf_channel_id, gHfcallNextSta); + // hf_chan_handle_t hf_channel_curr = + // app_bt_device.hf_channel[app_bt_device.curr_hf_channel_id]; + enum BT_DEVICE_ID_T another_device_id = + (app_bt_device.curr_hf_channel_id == BT_DEVICE_ID_1) ? BT_DEVICE_ID_2 + : BT_DEVICE_ID_1; + hf_chan_handle_t hf_channel_another = + app_bt_device.hf_channel[another_device_id]; - switch(gHfcallNextSta){ - case HFCALL_NEXT_STA_NULL: - break; - case HFCALL_NEXT_STA_ANOTHER_ANSWER: - if(event == BTIF_HF_EVENT_AUDIO_DISCONNECTED) - { - TRACE(0,"NEXT_ACTION = HFP_ANSWER_ANOTHER_CALL\n"); - btif_hf_answer_call(hf_channel_another); - gHfcallNextSta = HFCALL_NEXT_STA_NULL; - } - case HFCALL_NEXT_STA_ANOTHER_ADDTOEARPHONE: - if(event == BTIF_HF_EVENT_AUDIO_DISCONNECTED) - { - TRACE(0,"NEXT_ACTION = HFP_ANOTHER_ADDTOEARPHONE\n"); - btif_hf_create_audio_link(hf_channel_another); - gHfcallNextSta = HFCALL_NEXT_STA_NULL; - } - break; + switch (gHfcallNextSta) { + case HFCALL_NEXT_STA_NULL: + break; + case HFCALL_NEXT_STA_ANOTHER_ANSWER: + if (event == BTIF_HF_EVENT_AUDIO_DISCONNECTED) { + TRACE(0, "NEXT_ACTION = HFP_ANSWER_ANOTHER_CALL\n"); + btif_hf_answer_call(hf_channel_another); + gHfcallNextSta = HFCALL_NEXT_STA_NULL; } + case HFCALL_NEXT_STA_ANOTHER_ADDTOEARPHONE: + if (event == BTIF_HF_EVENT_AUDIO_DISCONNECTED) { + TRACE(0, "NEXT_ACTION = HFP_ANOTHER_ADDTOEARPHONE\n"); + btif_hf_create_audio_link(hf_channel_another); + gHfcallNextSta = HFCALL_NEXT_STA_NULL; + } + break; + } } #endif -void hfp_handle_key(uint8_t hfp_key) -{ - hf_chan_handle_t hf_channel_curr = app_bt_device.hf_channel[app_bt_device.curr_hf_channel_id]; +void hfp_handle_key(uint8_t hfp_key) { + hf_chan_handle_t hf_channel_curr = + app_bt_device.hf_channel[app_bt_device.curr_hf_channel_id]; #ifdef __BT_ONE_BRING_TWO__ - enum BT_DEVICE_ID_T another_device_id = (app_bt_device.curr_hf_channel_id == BT_DEVICE_ID_1) ? BT_DEVICE_ID_2 : BT_DEVICE_ID_1; - hf_chan_handle_t hf_channel_another = app_bt_device.hf_channel[another_device_id]; + enum BT_DEVICE_ID_T another_device_id = + (app_bt_device.curr_hf_channel_id == BT_DEVICE_ID_1) ? BT_DEVICE_ID_2 + : BT_DEVICE_ID_1; + hf_chan_handle_t hf_channel_another = + app_bt_device.hf_channel[another_device_id]; #endif - switch(hfp_key) - { - case HFP_KEY_ANSWER_CALL: - ///answer a incomming call - TRACE(0,"avrcp_key = HFP_KEY_ANSWER_CALL\n"); - btif_hf_answer_call(hf_channel_curr); - break; - case HFP_KEY_HANGUP_CALL: - TRACE(0,"avrcp_key = HFP_KEY_HANGUP_CALL\n"); - btif_hf_hang_up_call(hf_channel_curr); - break; - case HFP_KEY_REDIAL_LAST_CALL: - ///redail the last call - TRACE(0,"avrcp_key = HFP_KEY_REDIAL_LAST_CALL\n"); - btif_hf_redial_call(hf_channel_curr); - break; - case HFP_KEY_CHANGE_TO_PHONE: - ///remove sco and voice change to phone - if(app_bt_is_hfp_audio_on()) - { - TRACE(0,"avrcp_key = HFP_KEY_CHANGE_TO_PHONE\n"); - btif_hf_disc_audio_link(hf_channel_curr); - } - break; - case HFP_KEY_ADD_TO_EARPHONE: - ///add a sco and voice change to earphone - if(!app_bt_is_hfp_audio_on()) - { - TRACE(0,"avrcp_key = HFP_KEY_ADD_TO_EARPHONE ver:%x\n", btif_hf_get_version(hf_channel_curr)); + switch (hfp_key) { + case HFP_KEY_ANSWER_CALL: + /// answer a incomming call + TRACE(0, "avrcp_key = HFP_KEY_ANSWER_CALL\n"); + btif_hf_answer_call(hf_channel_curr); + break; + case HFP_KEY_HANGUP_CALL: + TRACE(0, "avrcp_key = HFP_KEY_HANGUP_CALL\n"); + btif_hf_hang_up_call(hf_channel_curr); + break; + case HFP_KEY_REDIAL_LAST_CALL: + /// redail the last call + TRACE(0, "avrcp_key = HFP_KEY_REDIAL_LAST_CALL\n"); + btif_hf_redial_call(hf_channel_curr); + break; + case HFP_KEY_CHANGE_TO_PHONE: + /// remove sco and voice change to phone + if (app_bt_is_hfp_audio_on()) { + TRACE(0, "avrcp_key = HFP_KEY_CHANGE_TO_PHONE\n"); + btif_hf_disc_audio_link(hf_channel_curr); + } + break; + case HFP_KEY_ADD_TO_EARPHONE: + /// add a sco and voice change to earphone + if (!app_bt_is_hfp_audio_on()) { + TRACE(0, "avrcp_key = HFP_KEY_ADD_TO_EARPHONE ver:%x\n", + btif_hf_get_version(hf_channel_curr)); #if defined(HFP_1_6_ENABLE) - //if (hf_channel_tmp->negotiated_codec == HF_SCO_CODEC_MSBC){ - if (btif_hf_get_negotiated_codec(hf_channel_curr) == BTIF_HF_SCO_CODEC_MSBC) { - TRACE(0,"at+bcc"); + // if (hf_channel_tmp->negotiated_codec == HF_SCO_CODEC_MSBC){ + if (btif_hf_get_negotiated_codec(hf_channel_curr) == + BTIF_HF_SCO_CODEC_MSBC) { + TRACE(0, "at+bcc"); #ifdef __HFP_OK__ - hfp_handle_add_to_earphone_1_6(hf_channel_curr); + hfp_handle_add_to_earphone_1_6(hf_channel_curr); #endif - TRACE(0,"CreateAudioLink"); - btif_hf_create_audio_link(hf_channel_curr); - } else + TRACE(0, "CreateAudioLink"); + btif_hf_create_audio_link(hf_channel_curr); + } else #endif - { - TRACE(0,"CreateAudioLink"); - btif_hf_create_audio_link(hf_channel_curr); - } - } - break; - case HFP_KEY_MUTE: - TRACE(0,"avrcp_key = HFP_KEY_MUTE\n"); - app_bt_device.hf_mute_flag = 1; - break; - case HFP_KEY_CLEAR_MUTE: - TRACE(0,"avrcp_key = HFP_KEY_CLEAR_MUTE\n"); - app_bt_device.hf_mute_flag = 0; - break; - case HFP_KEY_THREEWAY_HOLD_AND_ANSWER: - TRACE(0,"avrcp_key = HFP_KEY_THREEWAY_HOLD_AND_ANSWER\n"); - btif_hf_call_hold(hf_channel_curr, BTIF_HF_HOLD_HOLD_ACTIVE_CALLS, 0); - break; - case HFP_KEY_THREEWAY_HANGUP_AND_ANSWER: - TRACE(0,"avrcp_key = HFP_KEY_THREEWAY_HOLD_SWAP_ANSWER\n"); - btif_hf_call_hold(hf_channel_curr, BTIF_HF_HOLD_RELEASE_ACTIVE_CALLS, 0); - break; - case HFP_KEY_THREEWAY_HOLD_REL_INCOMING: - TRACE(0,"avrcp_key = HFP_KEY_THREEWAY_HOLD_REL_INCOMING\n"); - btif_hf_call_hold(hf_channel_curr, BTIF_HF_HOLD_RELEASE_HELD_CALLS, 0); - break; + { + TRACE(0, "CreateAudioLink"); + btif_hf_create_audio_link(hf_channel_curr); + } + } + break; + case HFP_KEY_MUTE: + TRACE(0, "avrcp_key = HFP_KEY_MUTE\n"); + app_bt_device.hf_mute_flag = 1; + break; + case HFP_KEY_CLEAR_MUTE: + TRACE(0, "avrcp_key = HFP_KEY_CLEAR_MUTE\n"); + app_bt_device.hf_mute_flag = 0; + break; + case HFP_KEY_THREEWAY_HOLD_AND_ANSWER: + TRACE(0, "avrcp_key = HFP_KEY_THREEWAY_HOLD_AND_ANSWER\n"); + btif_hf_call_hold(hf_channel_curr, BTIF_HF_HOLD_HOLD_ACTIVE_CALLS, 0); + break; + case HFP_KEY_THREEWAY_HANGUP_AND_ANSWER: + TRACE(0, "avrcp_key = HFP_KEY_THREEWAY_HOLD_SWAP_ANSWER\n"); + btif_hf_call_hold(hf_channel_curr, BTIF_HF_HOLD_RELEASE_ACTIVE_CALLS, 0); + break; + case HFP_KEY_THREEWAY_HOLD_REL_INCOMING: + TRACE(0, "avrcp_key = HFP_KEY_THREEWAY_HOLD_REL_INCOMING\n"); + btif_hf_call_hold(hf_channel_curr, BTIF_HF_HOLD_RELEASE_HELD_CALLS, 0); + break; #ifdef __BT_ONE_BRING_TWO__ - case HFP_KEY_DUAL_HF_HANGUP_ANOTHER: - TRACE(0,"avrcp_key = HFP_KEY_DUAL_HF_HANGUP_ANOTHER\n"); - btif_hf_hang_up_call(hf_channel_another); - break; - case HFP_KEY_DUAL_HF_HANGUP_CURR_ANSWER_ANOTHER: - TRACE(0,"avrcp_key = HFP_KEY_DUAL_HF_HANGUP_CURR_ANSWER_ANOTHER\n"); - btif_hf_hang_up_call(hf_channel_curr); - gHfcallNextSta = HFCALL_NEXT_STA_ANOTHER_ANSWER; - break; - case HFP_KEY_DUAL_HF_HOLD_CURR_ANSWER_ANOTHER: - TRACE(0,"avrcp_key = HFP_KEY_DUAL_HF_HOLD_CURR_ANSWER_ANOTHER\n"); + case HFP_KEY_DUAL_HF_HANGUP_ANOTHER: + TRACE(0, "avrcp_key = HFP_KEY_DUAL_HF_HANGUP_ANOTHER\n"); + btif_hf_hang_up_call(hf_channel_another); + break; + case HFP_KEY_DUAL_HF_HANGUP_CURR_ANSWER_ANOTHER: + TRACE(0, "avrcp_key = HFP_KEY_DUAL_HF_HANGUP_CURR_ANSWER_ANOTHER\n"); + btif_hf_hang_up_call(hf_channel_curr); + gHfcallNextSta = HFCALL_NEXT_STA_ANOTHER_ANSWER; + break; + case HFP_KEY_DUAL_HF_HOLD_CURR_ANSWER_ANOTHER: + TRACE(0, "avrcp_key = HFP_KEY_DUAL_HF_HOLD_CURR_ANSWER_ANOTHER\n"); #ifdef __HFP_OK__ - hf_answer_call(hf_channel_another); + hf_answer_call(hf_channel_another); #endif - break; - case HFP_KEY_DUAL_HF_CHANGETOPHONE_ANSWER_ANOTHER: - TRACE(0,"avrcp_key = HFP_KEY_DUAL_HF_CHANGETOPHONE_ANSWER_ANOTHER\n"); - btif_hf_disc_audio_link(hf_channel_curr); - gHfcallNextSta = HFCALL_NEXT_STA_ANOTHER_ANSWER; - break; - case HFP_KEY_DUAL_HF_CHANGETOPHONE_ANOTHER_ADDTOEARPHONE: - TRACE(0,"avrcp_key = HFP_KEY_DUAL_HF_CHANGETOPHONE_ANOTHER_ADDTOEARPHONE\n"); - btif_hf_disc_audio_link(hf_channel_curr); - gHfcallNextSta = HFCALL_NEXT_STA_ANOTHER_ADDTOEARPHONE; - break; - case HFP_KEY_DUAL_HF_HANGUP_ANOTHER_ADDTOEARPHONE: - TRACE(0,"avrcp_key = HFP_KEY_DUAL_HF_HANGUP_ANOTHER_ADDTOEARPHONE\n"); - btif_hf_hang_up_call(hf_channel_curr); - gHfcallNextSta = HFCALL_NEXT_STA_ANOTHER_ADDTOEARPHONE; - break; + break; + case HFP_KEY_DUAL_HF_CHANGETOPHONE_ANSWER_ANOTHER: + TRACE(0, "avrcp_key = HFP_KEY_DUAL_HF_CHANGETOPHONE_ANSWER_ANOTHER\n"); + btif_hf_disc_audio_link(hf_channel_curr); + gHfcallNextSta = HFCALL_NEXT_STA_ANOTHER_ANSWER; + break; + case HFP_KEY_DUAL_HF_CHANGETOPHONE_ANOTHER_ADDTOEARPHONE: + TRACE(0, + "avrcp_key = HFP_KEY_DUAL_HF_CHANGETOPHONE_ANOTHER_ADDTOEARPHONE\n"); + btif_hf_disc_audio_link(hf_channel_curr); + gHfcallNextSta = HFCALL_NEXT_STA_ANOTHER_ADDTOEARPHONE; + break; + case HFP_KEY_DUAL_HF_HANGUP_ANOTHER_ADDTOEARPHONE: + TRACE(0, "avrcp_key = HFP_KEY_DUAL_HF_HANGUP_ANOTHER_ADDTOEARPHONE\n"); + btif_hf_hang_up_call(hf_channel_curr); + gHfcallNextSta = HFCALL_NEXT_STA_ANOTHER_ADDTOEARPHONE; + break; #endif - default : - break; - } + default: + break; + } } -//bool a2dp_play_pause_flag = 0; +// bool a2dp_play_pause_flag = 0; uint8_t get_avrcp_via_a2dp_id(uint8_t a2dp_id); -extern void a2dp_handleKey(uint8_t a2dp_key) -{ - btif_avrcp_channel_t* avrcp_channel_tmp = NULL; - enum BT_DEVICE_ID_T avrcp_id = BT_DEVICE_NUM; - if(app_bt_device.a2dp_state[app_bt_device.curr_a2dp_stream_id] == 0) - return; +extern void a2dp_handleKey(uint8_t a2dp_key) { + btif_avrcp_channel_t *avrcp_channel_tmp = NULL; + enum BT_DEVICE_ID_T avrcp_id = BT_DEVICE_NUM; + if (app_bt_device.a2dp_state[app_bt_device.curr_a2dp_stream_id] == 0) + return; #ifdef __BT_ONE_BRING_TWO__ - TRACE(1,"!!!a2dp_handleKey curr_a2dp_stream_id=%d\n",app_bt_device.curr_a2dp_stream_id); - avrcp_id = (enum BT_DEVICE_ID_T )get_avrcp_via_a2dp_id(app_bt_device.curr_a2dp_stream_id); - if(avrcp_id == BT_DEVICE_NUM) - avrcp_id = BT_DEVICE_ID_1; - avrcp_channel_tmp = app_bt_device.avrcp_channel[avrcp_id]; -#else + TRACE(1, "!!!a2dp_handleKey curr_a2dp_stream_id=%d\n", + app_bt_device.curr_a2dp_stream_id); + avrcp_id = (enum BT_DEVICE_ID_T)get_avrcp_via_a2dp_id( + app_bt_device.curr_a2dp_stream_id); + if (avrcp_id == BT_DEVICE_NUM) avrcp_id = BT_DEVICE_ID_1; - avrcp_channel_tmp = app_bt_device.avrcp_channel[avrcp_id]; + avrcp_channel_tmp = app_bt_device.avrcp_channel[avrcp_id]; +#else + avrcp_id = BT_DEVICE_ID_1; + avrcp_channel_tmp = app_bt_device.avrcp_channel[avrcp_id]; #endif - if (!btif_avrcp_is_control_channel_connected(avrcp_channel_tmp)) - { - TRACE(1, "avrcp_key %d the channel is not connected", a2dp_key); - return; - } + if (!btif_avrcp_is_control_channel_connected(avrcp_channel_tmp)) { + TRACE(1, "avrcp_key %d the channel is not connected", a2dp_key); + return; + } - switch(a2dp_key) - { - case AVRCP_KEY_STOP: - TRACE(0,"avrcp_key = AVRCP_KEY_STOP"); - btif_avrcp_set_panel_key(avrcp_channel_tmp,BTIF_AVRCP_POP_STOP,TRUE); - btif_avrcp_set_panel_key(avrcp_channel_tmp,BTIF_AVRCP_POP_STOP,FALSE); - app_bt_device.a2dp_play_pause_flag = 0; - break; - case AVRCP_KEY_PLAY: - TRACE(0,"avrcp_key = AVRCP_KEY_PLAY"); - btif_avrcp_set_panel_key(avrcp_channel_tmp,BTIF_AVRCP_POP_PLAY,TRUE); - btif_avrcp_set_panel_key(avrcp_channel_tmp,BTIF_AVRCP_POP_PLAY,FALSE); - app_bt_device.a2dp_play_pause_flag = 1; - break; - case AVRCP_KEY_PAUSE: - TRACE(0,"avrcp_key = AVRCP_KEY_PAUSE"); - btif_avrcp_set_panel_key(avrcp_channel_tmp,BTIF_AVRCP_POP_PAUSE,TRUE); - btif_avrcp_set_panel_key(avrcp_channel_tmp,BTIF_AVRCP_POP_PAUSE,FALSE); - app_bt_device.a2dp_play_pause_flag = 0; - break; - case AVRCP_KEY_FORWARD: - TRACE(0,"avrcp_key = AVRCP_KEY_FORWARD"); - btif_avrcp_set_panel_key(avrcp_channel_tmp,BTIF_AVRCP_POP_FORWARD,TRUE); - btif_avrcp_set_panel_key(avrcp_channel_tmp,BTIF_AVRCP_POP_FORWARD,FALSE); - app_bt_device.a2dp_play_pause_flag = 1; - break; - case AVRCP_KEY_BACKWARD: - TRACE(0,"avrcp_key = AVRCP_KEY_BACKWARD"); - btif_avrcp_set_panel_key(avrcp_channel_tmp,BTIF_AVRCP_POP_BACKWARD,TRUE); - btif_avrcp_set_panel_key(avrcp_channel_tmp,BTIF_AVRCP_POP_BACKWARD,FALSE); - app_bt_device.a2dp_play_pause_flag = 1; - break; - case AVRCP_KEY_VOLUME_UP: - TRACE(0,"avrcp_key = AVRCP_KEY_VOLUME_UP"); - btif_avrcp_set_panel_key(avrcp_channel_tmp,BTIF_AVRCP_POP_VOLUME_UP,TRUE); - btif_avrcp_set_panel_key(avrcp_channel_tmp,BTIF_AVRCP_POP_VOLUME_UP,FALSE); - break; - case AVRCP_KEY_VOLUME_DOWN: - TRACE(0,"avrcp_key = AVRCP_KEY_VOLUME_DOWN"); - btif_avrcp_set_panel_key(avrcp_channel_tmp,BTIF_AVRCP_POP_VOLUME_DOWN,TRUE); - btif_avrcp_set_panel_key(avrcp_channel_tmp,BTIF_AVRCP_POP_VOLUME_DOWN,FALSE); - break; - default : - break; - } + switch (a2dp_key) { + case AVRCP_KEY_STOP: + TRACE(0, "avrcp_key = AVRCP_KEY_STOP"); + btif_avrcp_set_panel_key(avrcp_channel_tmp, BTIF_AVRCP_POP_STOP, TRUE); + btif_avrcp_set_panel_key(avrcp_channel_tmp, BTIF_AVRCP_POP_STOP, FALSE); + app_bt_device.a2dp_play_pause_flag = 0; + break; + case AVRCP_KEY_PLAY: + TRACE(0, "avrcp_key = AVRCP_KEY_PLAY"); + btif_avrcp_set_panel_key(avrcp_channel_tmp, BTIF_AVRCP_POP_PLAY, TRUE); + btif_avrcp_set_panel_key(avrcp_channel_tmp, BTIF_AVRCP_POP_PLAY, FALSE); + app_bt_device.a2dp_play_pause_flag = 1; + break; + case AVRCP_KEY_PAUSE: + TRACE(0, "avrcp_key = AVRCP_KEY_PAUSE"); + btif_avrcp_set_panel_key(avrcp_channel_tmp, BTIF_AVRCP_POP_PAUSE, TRUE); + btif_avrcp_set_panel_key(avrcp_channel_tmp, BTIF_AVRCP_POP_PAUSE, FALSE); + app_bt_device.a2dp_play_pause_flag = 0; + break; + case AVRCP_KEY_FORWARD: + TRACE(0, "avrcp_key = AVRCP_KEY_FORWARD"); + btif_avrcp_set_panel_key(avrcp_channel_tmp, BTIF_AVRCP_POP_FORWARD, TRUE); + btif_avrcp_set_panel_key(avrcp_channel_tmp, BTIF_AVRCP_POP_FORWARD, FALSE); + app_bt_device.a2dp_play_pause_flag = 1; + break; + case AVRCP_KEY_BACKWARD: + TRACE(0, "avrcp_key = AVRCP_KEY_BACKWARD"); + btif_avrcp_set_panel_key(avrcp_channel_tmp, BTIF_AVRCP_POP_BACKWARD, TRUE); + btif_avrcp_set_panel_key(avrcp_channel_tmp, BTIF_AVRCP_POP_BACKWARD, FALSE); + app_bt_device.a2dp_play_pause_flag = 1; + break; + case AVRCP_KEY_VOLUME_UP: + TRACE(0, "avrcp_key = AVRCP_KEY_VOLUME_UP"); + btif_avrcp_set_panel_key(avrcp_channel_tmp, BTIF_AVRCP_POP_VOLUME_UP, TRUE); + btif_avrcp_set_panel_key(avrcp_channel_tmp, BTIF_AVRCP_POP_VOLUME_UP, + FALSE); + break; + case AVRCP_KEY_VOLUME_DOWN: + TRACE(0, "avrcp_key = AVRCP_KEY_VOLUME_DOWN"); + btif_avrcp_set_panel_key(avrcp_channel_tmp, BTIF_AVRCP_POP_VOLUME_DOWN, + TRUE); + btif_avrcp_set_panel_key(avrcp_channel_tmp, BTIF_AVRCP_POP_VOLUME_DOWN, + FALSE); + break; + default: + break; + } } -//uint8_t phone_earphone_mark = 0; -#if 0//def __BT_ONE_BRING_TWO__ +// uint8_t phone_earphone_mark = 0; +#if 0 // def __BT_ONE_BRING_TWO__ #define HF_CHANNEL_SWITCH_HOOK_USER APP_BT_GOLBAL_HANDLE_HOOK_USER_0 enum HF_CHANNEL_SWITCH_STATUS{ @@ -464,515 +466,507 @@ static void bt_key_hf_channel_switch_hook(const btif_event_t*Event) } #endif -void hfp_call_state_checker(void) -{ - BT_DEVICE_ID_T current_device_id = app_bt_device.curr_hf_channel_id; +void hfp_call_state_checker(void) { + BT_DEVICE_ID_T current_device_id = app_bt_device.curr_hf_channel_id; - TRACE(0,"current_device_id:%d,phone_earphone_mark=%d",app_bt_device.curr_hf_channel_id,app_bt_device.phone_earphone_mark); - TRACE(0,"hf_channel current[%d]: conn-%d-audio-%d-call-%d-callsetup-%d-callheld-%d-voice-%d",current_device_id, - app_bt_device.hf_conn_flag[current_device_id], - app_bt_device.hf_audio_state[current_device_id], - app_bt_device.hfchan_call[current_device_id], - app_bt_device.hfchan_callSetup[current_device_id], - app_bt_device.hf_callheld[current_device_id], - app_bt_device.hf_voice_en[current_device_id]); + TRACE(0, "current_device_id:%d,phone_earphone_mark=%d", + app_bt_device.curr_hf_channel_id, app_bt_device.phone_earphone_mark); + TRACE(0, + "hf_channel current[%d]: " + "conn-%d-audio-%d-call-%d-callsetup-%d-callheld-%d-voice-%d", + current_device_id, app_bt_device.hf_conn_flag[current_device_id], + app_bt_device.hf_audio_state[current_device_id], + app_bt_device.hfchan_call[current_device_id], + app_bt_device.hfchan_callSetup[current_device_id], + app_bt_device.hf_callheld[current_device_id], + app_bt_device.hf_voice_en[current_device_id]); #ifdef __BT_ONE_BRING_TWO__ - BT_DEVICE_ID_T another_device_id = (current_device_id == BT_DEVICE_ID_1) ? BT_DEVICE_ID_2 : BT_DEVICE_ID_1; - TRACE(0,"hf_channel another[%d]: conn-%d-audio-%d-call-%d-callsetup-%d-callheld-%d-voice-%d",another_device_id, - app_bt_device.hf_conn_flag[another_device_id], - app_bt_device.hf_audio_state[another_device_id], - app_bt_device.hfchan_call[another_device_id], - app_bt_device.hfchan_callSetup[another_device_id], - app_bt_device.hf_callheld[another_device_id], - app_bt_device.hf_voice_en[another_device_id]); + BT_DEVICE_ID_T another_device_id = + (current_device_id == BT_DEVICE_ID_1) ? BT_DEVICE_ID_2 : BT_DEVICE_ID_1; + TRACE(0, + "hf_channel another[%d]: " + "conn-%d-audio-%d-call-%d-callsetup-%d-callheld-%d-voice-%d", + another_device_id, app_bt_device.hf_conn_flag[another_device_id], + app_bt_device.hf_audio_state[another_device_id], + app_bt_device.hfchan_call[another_device_id], + app_bt_device.hfchan_callSetup[another_device_id], + app_bt_device.hf_callheld[another_device_id], + app_bt_device.hf_voice_en[another_device_id]); #endif } -HFCALL_MACHINE_ENUM app_get_hfcall_machine(void) -{ - HFCALL_MACHINE_ENUM status = HFCALL_MACHINE_NUM; - BT_DEVICE_ID_T current_device_id = app_bt_device.curr_hf_channel_id; - btif_hf_call_setup_t current_callSetup = app_bt_device.hfchan_callSetup[current_device_id]; - btif_hf_call_active_t current_call = app_bt_device.hfchan_call[current_device_id]; - btif_hf_call_held_state current_callheld = app_bt_device.hf_callheld[current_device_id]; - btif_audio_state_t current_audioState = app_bt_device.hf_audio_state[current_device_id]; +HFCALL_MACHINE_ENUM app_get_hfcall_machine(void) { + HFCALL_MACHINE_ENUM status = HFCALL_MACHINE_NUM; + BT_DEVICE_ID_T current_device_id = app_bt_device.curr_hf_channel_id; + btif_hf_call_setup_t current_callSetup = + app_bt_device.hfchan_callSetup[current_device_id]; + btif_hf_call_active_t current_call = + app_bt_device.hfchan_call[current_device_id]; + btif_hf_call_held_state current_callheld = + app_bt_device.hf_callheld[current_device_id]; + btif_audio_state_t current_audioState = + app_bt_device.hf_audio_state[current_device_id]; #ifdef __BT_ONE_BRING_TWO__ - BT_DEVICE_ID_T another_device_id = (current_device_id == BT_DEVICE_ID_1) ? BT_DEVICE_ID_2 : BT_DEVICE_ID_1; - btif_hf_call_setup_t another_callSetup = app_bt_device.hfchan_callSetup[another_device_id]; - btif_hf_call_active_t another_call = app_bt_device.hfchan_call[another_device_id]; - btif_hf_call_held_state another_callheld = app_bt_device.hf_callheld[another_device_id]; - btif_audio_state_t another_audioState = app_bt_device.hf_audio_state[another_device_id]; + BT_DEVICE_ID_T another_device_id = + (current_device_id == BT_DEVICE_ID_1) ? BT_DEVICE_ID_2 : BT_DEVICE_ID_1; + btif_hf_call_setup_t another_callSetup = + app_bt_device.hfchan_callSetup[another_device_id]; + btif_hf_call_active_t another_call = + app_bt_device.hfchan_call[another_device_id]; + btif_hf_call_held_state another_callheld = + app_bt_device.hf_callheld[another_device_id]; + btif_audio_state_t another_audioState = + app_bt_device.hf_audio_state[another_device_id]; #endif - hfp_call_state_checker(); + hfp_call_state_checker(); #ifndef __BT_ONE_BRING_TWO__ - // current AG is idle. - if( current_callSetup ==BTIF_HF_CALL_SETUP_NONE && - current_call == BTIF_HF_CALL_NONE && - current_audioState == BTIF_HF_AUDIO_DISCON ) - { - TRACE(0,"current hfcall machine status is HFCALL_MACHINE_CURRENT_IDLE!!!!"); - status = HFCALL_MACHINE_CURRENT_IDLE; - } - // current AG is incomming. - else if( current_callSetup == BTIF_HF_CALL_SETUP_IN && - current_call == BTIF_HF_CALL_NONE ) - { - TRACE(0,"current hfcall machine status is HFCALL_MACHINE_CURRENT_INCOMMING!!!!"); - status = HFCALL_MACHINE_CURRENT_INCOMMING; - } - // current AG is outgoing. - else if( (current_callSetup >= BTIF_HF_CALL_SETUP_OUT) && - current_call == BTIF_HF_CALL_NONE) - { - TRACE(0,"current hfcall machine status is HFCALL_MACHINE_CURRENT_OUTGOING!!!!"); - status = HFCALL_MACHINE_CURRENT_OUTGOING; - } - // current AG is calling. - else if( (current_callSetup ==BTIF_HF_CALL_SETUP_NONE) && - current_call == BTIF_HF_CALL_ACTIVE && - current_callheld != BTIF_HF_CALL_HELD_ACTIVE) - { - TRACE(0,"current hfcall machine status is HFCALL_MACHINE_CURRENT_CALLING!!!!"); - status = HFCALL_MACHINE_CURRENT_CALLING; - } - // current AG is 3way incomming. - else if( current_callSetup ==BTIF_HF_CALL_SETUP_IN && - current_call == BTIF_HF_CALL_ACTIVE && - current_callheld == BTIF_HF_CALL_HELD_NONE) - { - TRACE(0,"current hfcall machine status is HFCALL_MACHINE_CURRENT_3WAY_INCOMMING!!!!"); - status = HFCALL_MACHINE_CURRENT_3WAY_INCOMMING; - } - // current AG is 3way hold calling. - else if( current_callSetup ==BTIF_HF_CALL_SETUP_NONE && - current_call == BTIF_HF_CALL_ACTIVE && - current_callheld == BTIF_HF_CALL_HELD_ACTIVE) - { - TRACE(0,"current hfcall machine status is HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING!!!!"); - status = HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING; - } - else - { - TRACE(0,"current hfcall machine status is not found!!!!!!"); - } + // current AG is idle. + if (current_callSetup == BTIF_HF_CALL_SETUP_NONE && + current_call == BTIF_HF_CALL_NONE && + current_audioState == BTIF_HF_AUDIO_DISCON) { + TRACE(0, + "current hfcall machine status is HFCALL_MACHINE_CURRENT_IDLE!!!!"); + status = HFCALL_MACHINE_CURRENT_IDLE; + } + // current AG is incomming. + else if (current_callSetup == BTIF_HF_CALL_SETUP_IN && + current_call == BTIF_HF_CALL_NONE) { + TRACE(0, "current hfcall machine status is " + "HFCALL_MACHINE_CURRENT_INCOMMING!!!!"); + status = HFCALL_MACHINE_CURRENT_INCOMMING; + } + // current AG is outgoing. + else if ((current_callSetup >= BTIF_HF_CALL_SETUP_OUT) && + current_call == BTIF_HF_CALL_NONE) { + TRACE( + 0, + "current hfcall machine status is HFCALL_MACHINE_CURRENT_OUTGOING!!!!"); + status = HFCALL_MACHINE_CURRENT_OUTGOING; + } + // current AG is calling. + else if ((current_callSetup == BTIF_HF_CALL_SETUP_NONE) && + current_call == BTIF_HF_CALL_ACTIVE && + current_callheld != BTIF_HF_CALL_HELD_ACTIVE) { + TRACE( + 0, + "current hfcall machine status is HFCALL_MACHINE_CURRENT_CALLING!!!!"); + status = HFCALL_MACHINE_CURRENT_CALLING; + } + // current AG is 3way incomming. + else if (current_callSetup == BTIF_HF_CALL_SETUP_IN && + current_call == BTIF_HF_CALL_ACTIVE && + current_callheld == BTIF_HF_CALL_HELD_NONE) { + TRACE(0, "current hfcall machine status is " + "HFCALL_MACHINE_CURRENT_3WAY_INCOMMING!!!!"); + status = HFCALL_MACHINE_CURRENT_3WAY_INCOMMING; + } + // current AG is 3way hold calling. + else if (current_callSetup == BTIF_HF_CALL_SETUP_NONE && + current_call == BTIF_HF_CALL_ACTIVE && + current_callheld == BTIF_HF_CALL_HELD_ACTIVE) { + TRACE(0, "current hfcall machine status is " + "HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING!!!!"); + status = HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING; + } else { + TRACE(0, "current hfcall machine status is not found!!!!!!"); + } #else - // current AG is idle , another AG is idle. - if( current_callSetup ==BTIF_HF_CALL_SETUP_NONE && - current_call == BTIF_HF_CALL_NONE && - current_audioState == BTIF_HF_AUDIO_DISCON && - another_callSetup==BTIF_HF_CALL_SETUP_NONE && - another_call == BTIF_HF_CALL_NONE && - another_audioState == BTIF_HF_AUDIO_DISCON ) - { - TRACE(0,"current hfcall machine status is HFCALL_MACHINE_CURRENT_IDLE_ANOTHER_IDLE!!!!"); - status = HFCALL_MACHINE_CURRENT_IDLE_ANOTHER_IDLE; - } - // current AG is on incomming , another AG is idle. - else if( current_callSetup == BTIF_HF_CALL_SETUP_IN && - current_call == BTIF_HF_CALL_NONE && - another_callSetup==BTIF_HF_CALL_SETUP_NONE && - another_call == BTIF_HF_CALL_NONE && - another_audioState == BTIF_HF_AUDIO_DISCON ) - { - TRACE(0,"current hfcall machine status is HFCALL_MACHINE_CURRENT_INCOMMING_ANOTHER_IDLE!!!!"); - status = HFCALL_MACHINE_CURRENT_INCOMMING_ANOTHER_IDLE; - } - // current AG is on outgoing , another AG is idle. - else if( current_callSetup >= BTIF_HF_CALL_SETUP_OUT && - current_call == BTIF_HF_CALL_NONE && - another_callSetup == BTIF_HF_CALL_SETUP_NONE && - another_call == BTIF_HF_CALL_NONE && - another_audioState == BTIF_HF_AUDIO_DISCON ) - { - TRACE(0,"current hfcall machine status is HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_IDLE!!!!"); - status = HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_IDLE; - } - // current AG is on calling , another AG is idle. - else if( current_callSetup == BTIF_HF_CALL_SETUP_NONE && - current_call == BTIF_HF_CALL_ACTIVE && - current_callheld != BTIF_HF_CALL_HELD_ACTIVE&& - another_callSetup == BTIF_HF_CALL_SETUP_NONE && - another_call == BTIF_HF_CALL_NONE && - another_audioState == BTIF_HF_AUDIO_DISCON ) - { - TRACE(0,"current hfcall machine status is HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_IDLE!!!!"); - status = HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_IDLE; - } - // current AG is 3way incomming , another AG is idle. - else if( current_callSetup ==BTIF_HF_CALL_SETUP_IN && - current_call == BTIF_HF_CALL_ACTIVE && - current_callheld == BTIF_HF_CALL_HELD_NONE&& - another_callSetup == BTIF_HF_CALL_SETUP_NONE && - another_call == BTIF_HF_CALL_NONE && - another_audioState == BTIF_HF_AUDIO_DISCON ) - { - TRACE(0,"current hfcall machine status is HFCALL_MACHINE_CURRENT_3WAY_INCOMMING_ANOTHER_IDLE!!!!"); - status = HFCALL_MACHINE_CURRENT_3WAY_INCOMMING_ANOTHER_IDLE; - } - // current AG is 3way hold calling , another AG is without connecting. - else if( current_callSetup ==BTIF_HF_CALL_SETUP_NONE && - current_call == BTIF_HF_CALL_ACTIVE && - current_callheld == BTIF_HF_CALL_HELD_ACTIVE&& - another_callSetup == BTIF_HF_CALL_SETUP_NONE && - another_call == BTIF_HF_CALL_NONE && - another_audioState == BTIF_HF_AUDIO_DISCON ) - { - TRACE(0,"current hfcall machine status is HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING_ANOTHER_IDLE!!!!"); - status = HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING_ANOTHER_IDLE; - } - // current AG is incomming , another AG is incomming too. - else if( current_callSetup == BTIF_HF_CALL_SETUP_IN && - current_call == BTIF_HF_CALL_NONE && - current_callheld == BTIF_HF_CALL_HELD_NONE&& - another_callSetup == BTIF_HF_CALL_SETUP_IN && - another_call == BTIF_HF_CALL_NONE && - another_callheld == BTIF_HF_CALL_HELD_NONE) - { - TRACE(0,"current hfcall machine status is HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_INCOMMING!!!!"); - status = HFCALL_MACHINE_CURRENT_INCOMMING_ANOTHER_INCOMMING; - } - // current AG is outgoing , another AG is incomming too. - else if( current_callSetup == BTIF_HF_CALL_SETUP_OUT && - current_call == BTIF_HF_CALL_NONE && - current_callheld == BTIF_HF_CALL_HELD_NONE&& - another_callSetup == BTIF_HF_CALL_SETUP_IN && - another_call == BTIF_HF_CALL_NONE && - another_callheld == BTIF_HF_CALL_HELD_NONE) - { - TRACE(0,"current hfcall machine status is HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_INCOMMING!!!!"); - status = HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_INCOMMING; - } - // current AG is calling , another AG is incomming. - else if( current_callSetup == BTIF_HF_CALL_SETUP_NONE && - current_call == BTIF_HF_CALL_ACTIVE && - current_callheld == BTIF_HF_CALL_HELD_NONE&& - another_callSetup == BTIF_HF_CALL_SETUP_IN && - another_call == BTIF_HF_CALL_NONE && - another_callheld == BTIF_HF_CALL_HELD_NONE) - { - TRACE(0,"current hfcall machine status is HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_INCOMMING!!!!"); - status = HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_INCOMMING; - } - // current AG is on calling , another AG calling changed to phone. - else if( current_callSetup == BTIF_HF_CALL_SETUP_NONE && - current_call == BTIF_HF_CALL_ACTIVE && - current_callheld == BTIF_HF_CALL_HELD_NONE&& - another_callSetup == BTIF_HF_CALL_SETUP_NONE && - another_call == BTIF_HF_CALL_ACTIVE && - another_callheld == BTIF_HF_CALL_HELD_NONE&& - another_audioState == BTIF_HF_AUDIO_DISCON) - { - TRACE(0,"current hfcall machine status is HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_CHANGETOPHONE!!!!"); - status = HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_CHANGETOPHONE; - } - // current AG is on calling , another AG calling is hold. - else if( current_callSetup == BTIF_HF_CALL_SETUP_NONE && - current_call == BTIF_HF_CALL_ACTIVE && - current_callheld == BTIF_HF_CALL_HELD_NONE&& - another_callSetup == BTIF_HF_CALL_SETUP_NONE && - another_call == BTIF_HF_CALL_ACTIVE && - another_callheld == BTIF_HF_CALL_HELD_ACTIVE) - { - TRACE(0,"current hfcall machine status is HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_HOLD!!!!"); - status = HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_HOLD; - } - else - { - TRACE(0,"current hfcall machine status is not found!!!!!!"); - } + // current AG is idle , another AG is idle. + if (current_callSetup == BTIF_HF_CALL_SETUP_NONE && + current_call == BTIF_HF_CALL_NONE && + current_audioState == BTIF_HF_AUDIO_DISCON && + another_callSetup == BTIF_HF_CALL_SETUP_NONE && + another_call == BTIF_HF_CALL_NONE && + another_audioState == BTIF_HF_AUDIO_DISCON) { + TRACE(0, "current hfcall machine status is " + "HFCALL_MACHINE_CURRENT_IDLE_ANOTHER_IDLE!!!!"); + status = HFCALL_MACHINE_CURRENT_IDLE_ANOTHER_IDLE; + } + // current AG is on incomming , another AG is idle. + else if (current_callSetup == BTIF_HF_CALL_SETUP_IN && + current_call == BTIF_HF_CALL_NONE && + another_callSetup == BTIF_HF_CALL_SETUP_NONE && + another_call == BTIF_HF_CALL_NONE && + another_audioState == BTIF_HF_AUDIO_DISCON) { + TRACE(0, "current hfcall machine status is " + "HFCALL_MACHINE_CURRENT_INCOMMING_ANOTHER_IDLE!!!!"); + status = HFCALL_MACHINE_CURRENT_INCOMMING_ANOTHER_IDLE; + } + // current AG is on outgoing , another AG is idle. + else if (current_callSetup >= BTIF_HF_CALL_SETUP_OUT && + current_call == BTIF_HF_CALL_NONE && + another_callSetup == BTIF_HF_CALL_SETUP_NONE && + another_call == BTIF_HF_CALL_NONE && + another_audioState == BTIF_HF_AUDIO_DISCON) { + TRACE(0, "current hfcall machine status is " + "HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_IDLE!!!!"); + status = HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_IDLE; + } + // current AG is on calling , another AG is idle. + else if (current_callSetup == BTIF_HF_CALL_SETUP_NONE && + current_call == BTIF_HF_CALL_ACTIVE && + current_callheld != BTIF_HF_CALL_HELD_ACTIVE && + another_callSetup == BTIF_HF_CALL_SETUP_NONE && + another_call == BTIF_HF_CALL_NONE && + another_audioState == BTIF_HF_AUDIO_DISCON) { + TRACE(0, "current hfcall machine status is " + "HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_IDLE!!!!"); + status = HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_IDLE; + } + // current AG is 3way incomming , another AG is idle. + else if (current_callSetup == BTIF_HF_CALL_SETUP_IN && + current_call == BTIF_HF_CALL_ACTIVE && + current_callheld == BTIF_HF_CALL_HELD_NONE && + another_callSetup == BTIF_HF_CALL_SETUP_NONE && + another_call == BTIF_HF_CALL_NONE && + another_audioState == BTIF_HF_AUDIO_DISCON) { + TRACE(0, "current hfcall machine status is " + "HFCALL_MACHINE_CURRENT_3WAY_INCOMMING_ANOTHER_IDLE!!!!"); + status = HFCALL_MACHINE_CURRENT_3WAY_INCOMMING_ANOTHER_IDLE; + } + // current AG is 3way hold calling , another AG is without connecting. + else if (current_callSetup == BTIF_HF_CALL_SETUP_NONE && + current_call == BTIF_HF_CALL_ACTIVE && + current_callheld == BTIF_HF_CALL_HELD_ACTIVE && + another_callSetup == BTIF_HF_CALL_SETUP_NONE && + another_call == BTIF_HF_CALL_NONE && + another_audioState == BTIF_HF_AUDIO_DISCON) { + TRACE(0, "current hfcall machine status is " + "HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING_ANOTHER_IDLE!!!!"); + status = HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING_ANOTHER_IDLE; + } + // current AG is incomming , another AG is incomming too. + else if (current_callSetup == BTIF_HF_CALL_SETUP_IN && + current_call == BTIF_HF_CALL_NONE && + current_callheld == BTIF_HF_CALL_HELD_NONE && + another_callSetup == BTIF_HF_CALL_SETUP_IN && + another_call == BTIF_HF_CALL_NONE && + another_callheld == BTIF_HF_CALL_HELD_NONE) { + TRACE(0, "current hfcall machine status is " + "HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_INCOMMING!!!!"); + status = HFCALL_MACHINE_CURRENT_INCOMMING_ANOTHER_INCOMMING; + } + // current AG is outgoing , another AG is incomming too. + else if (current_callSetup == BTIF_HF_CALL_SETUP_OUT && + current_call == BTIF_HF_CALL_NONE && + current_callheld == BTIF_HF_CALL_HELD_NONE && + another_callSetup == BTIF_HF_CALL_SETUP_IN && + another_call == BTIF_HF_CALL_NONE && + another_callheld == BTIF_HF_CALL_HELD_NONE) { + TRACE(0, "current hfcall machine status is " + "HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_INCOMMING!!!!"); + status = HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_INCOMMING; + } + // current AG is calling , another AG is incomming. + else if (current_callSetup == BTIF_HF_CALL_SETUP_NONE && + current_call == BTIF_HF_CALL_ACTIVE && + current_callheld == BTIF_HF_CALL_HELD_NONE && + another_callSetup == BTIF_HF_CALL_SETUP_IN && + another_call == BTIF_HF_CALL_NONE && + another_callheld == BTIF_HF_CALL_HELD_NONE) { + TRACE(0, "current hfcall machine status is " + "HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_INCOMMING!!!!"); + status = HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_INCOMMING; + } + // current AG is on calling , another AG calling changed to phone. + else if (current_callSetup == BTIF_HF_CALL_SETUP_NONE && + current_call == BTIF_HF_CALL_ACTIVE && + current_callheld == BTIF_HF_CALL_HELD_NONE && + another_callSetup == BTIF_HF_CALL_SETUP_NONE && + another_call == BTIF_HF_CALL_ACTIVE && + another_callheld == BTIF_HF_CALL_HELD_NONE && + another_audioState == BTIF_HF_AUDIO_DISCON) { + TRACE(0, "current hfcall machine status is " + "HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_CHANGETOPHONE!!!!"); + status = HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_CHANGETOPHONE; + } + // current AG is on calling , another AG calling is hold. + else if (current_callSetup == BTIF_HF_CALL_SETUP_NONE && + current_call == BTIF_HF_CALL_ACTIVE && + current_callheld == BTIF_HF_CALL_HELD_NONE && + another_callSetup == BTIF_HF_CALL_SETUP_NONE && + another_call == BTIF_HF_CALL_ACTIVE && + another_callheld == BTIF_HF_CALL_HELD_ACTIVE) { + TRACE(0, "current hfcall machine status is " + "HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_HOLD!!!!"); + status = HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_HOLD; + } else { + TRACE(0, "current hfcall machine status is not found!!!!!!"); + } #endif -// TRACE(0,"%s status is %d",__func__,status); - return status; + // TRACE(0,"%s status is %d",__func__,status); + return status; } -void bt_key_handle_func_click(void) -{ - TRACE(0,"%s enter",__func__); +void bt_key_handle_func_click(void) { + TRACE(0, "%s enter", __func__); - HFCALL_MACHINE_ENUM hfcall_machine = app_get_hfcall_machine(); - switch(hfcall_machine) - { - case HFCALL_MACHINE_CURRENT_IDLE: - { - if(app_bt_device.a2dp_play_pause_flag == 0){ - a2dp_handleKey(AVRCP_KEY_PLAY); - }else{ - a2dp_handleKey(AVRCP_KEY_PAUSE); - } - } - break; - case HFCALL_MACHINE_CURRENT_INCOMMING: - hfp_handle_key(HFP_KEY_ANSWER_CALL); - break; - case HFCALL_MACHINE_CURRENT_OUTGOING: - hfp_handle_key(HFP_KEY_HANGUP_CALL); - break; - case HFCALL_MACHINE_CURRENT_CALLING: - hfp_handle_key(HFP_KEY_HANGUP_CALL); - break; - case HFCALL_MACHINE_CURRENT_3WAY_INCOMMING: - hfp_handle_key(HFP_KEY_THREEWAY_HANGUP_AND_ANSWER); - break; - case HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING: - hfp_handle_key(HFP_KEY_THREEWAY_HOLD_AND_ANSWER); - break; -#ifdef __BT_ONE_BRING_TWO__ - case HFCALL_MACHINE_CURRENT_IDLE_ANOTHER_IDLE: - { - if(app_bt_device.a2dp_play_pause_flag == 0){ - a2dp_handleKey(AVRCP_KEY_PLAY); - }else{ - a2dp_handleKey(AVRCP_KEY_PAUSE); - } - } - break; - case HFCALL_MACHINE_CURRENT_INCOMMING_ANOTHER_IDLE: - hfp_handle_key(HFP_KEY_ANSWER_CALL); - break; - case HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_IDLE: - hfp_handle_key(HFP_KEY_HANGUP_CALL); - break; - case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_IDLE: - hfp_handle_key(HFP_KEY_HANGUP_CALL); - break; - case HFCALL_MACHINE_CURRENT_3WAY_INCOMMING_ANOTHER_IDLE: - hfp_handle_key(HFP_KEY_THREEWAY_HANGUP_AND_ANSWER); - break; - case HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING_ANOTHER_IDLE: - hfp_handle_key(HFP_KEY_THREEWAY_HOLD_AND_ANSWER); - break; - case HFCALL_MACHINE_CURRENT_INCOMMING_ANOTHER_INCOMMING: - break; - case HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_INCOMMING: - break; - case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_INCOMMING: - hfp_handle_key(HFP_KEY_DUAL_HF_HANGUP_CURR_ANSWER_ANOTHER); - break; - case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_CHANGETOPHONE: - hfp_handle_key(HFP_KEY_DUAL_HF_HANGUP_ANOTHER_ADDTOEARPHONE); - break; - case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_HOLD: - hfp_handle_key(HFP_KEY_DUAL_HF_HANGUP_CURR_ANSWER_ANOTHER); - break; -#endif - default: - break; + HFCALL_MACHINE_ENUM hfcall_machine = app_get_hfcall_machine(); + switch (hfcall_machine) { + case HFCALL_MACHINE_CURRENT_IDLE: { + if (app_bt_device.a2dp_play_pause_flag == 0) { + a2dp_handleKey(AVRCP_KEY_PLAY); + } else { + a2dp_handleKey(AVRCP_KEY_PAUSE); } -#if defined (__HSP_ENABLE__) - //now we know it is HSP active ! - if(app_bt_device.hs_conn_flag[app_bt_device.curr_hs_channel_id] == 1){ - hsp_handle_key(HSP_KEY_CKPD_CONTROL); - } -#endif -#if HF_CUSTOM_FEATURE_SUPPORT & HF_CUSTOM_FEATURE_SIRI_REPORT - open_siri_flag = 0; -#endif - return; -} -void bt_key_handle_func_doubleclick(void) -{ - TRACE(0,"%s enter",__func__); - - HFCALL_MACHINE_ENUM hfcall_machine = app_get_hfcall_machine(); - -#ifdef SUPPORT_SIRI - open_siri_flag=0; -#endif - - switch(hfcall_machine) - { - case HFCALL_MACHINE_CURRENT_IDLE: -#ifdef BTIF_HID_DEVICE - app_bt_hid_send_capture(app_bt_device.hid_channel[BT_DEVICE_ID_1]); -#else - hfp_handle_key(HFP_KEY_REDIAL_LAST_CALL); -#endif - break; - case HFCALL_MACHINE_CURRENT_INCOMMING: - break; - case HFCALL_MACHINE_CURRENT_OUTGOING: - break; - case HFCALL_MACHINE_CURRENT_CALLING: - if(app_bt_device.hf_mute_flag == 0){ - hfp_handle_key(HFP_KEY_MUTE); - app_bt_device.hf_mute_flag = 1; - }else{ - hfp_handle_key(HFP_KEY_CLEAR_MUTE); - app_bt_device.hf_mute_flag = 0; - } - break; - case HFCALL_MACHINE_CURRENT_3WAY_INCOMMING: - hfp_handle_key(HFP_KEY_THREEWAY_HOLD_REL_INCOMING); - break; - case HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING: - break; -#ifdef __BT_ONE_BRING_TWO__ - case HFCALL_MACHINE_CURRENT_IDLE_ANOTHER_IDLE: -#ifdef BTIF_HID_DEVICE - app_bt_hid_send_capture(app_bt_device.hid_channel[BT_DEVICE_ID_1]); -#else - hfp_handle_key(HFP_KEY_REDIAL_LAST_CALL); -#endif - break; - case HFCALL_MACHINE_CURRENT_INCOMMING_ANOTHER_IDLE: - break; - case HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_IDLE: - break; - case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_IDLE: - if(app_bt_device.hf_mute_flag == 0){ - hfp_handle_key(HFP_KEY_MUTE); - }else{ - hfp_handle_key(HFP_KEY_CLEAR_MUTE); - } - break; - case HFCALL_MACHINE_CURRENT_3WAY_INCOMMING_ANOTHER_IDLE: - hfp_handle_key(HFP_KEY_THREEWAY_HOLD_REL_INCOMING); - break; - case HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING_ANOTHER_IDLE: - break; - case HFCALL_MACHINE_CURRENT_INCOMMING_ANOTHER_INCOMMING: - break; - case HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_INCOMMING: - break; - case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_INCOMMING: - hfp_handle_key(HFP_KEY_DUAL_HF_HANGUP_ANOTHER); - break; - case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_CHANGETOPHONE: - break; - case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_HOLD: - break; -#endif - default: - break; - } -} -void bt_key_handle_func_longpress(void) -{ - TRACE(0,"%s enter",__func__); - HFCALL_MACHINE_ENUM hfcall_machine = app_get_hfcall_machine(); -#ifdef SUPPORT_SIRI - open_siri_flag=0; -#endif - app_voice_report(APP_STATUS_INDICATION_WARNING, 0); - - switch(hfcall_machine) - { - case HFCALL_MACHINE_CURRENT_IDLE: - { -#if HF_CUSTOM_FEATURE_SUPPORT & HF_CUSTOM_FEATURE_SIRI_REPORT - if(open_siri_flag == 0 ) - { - app_voice_report(APP_STATUS_INDICATION_WARNING, 0); - open_siri_flag = 1; - } -#endif - } - break; - case HFCALL_MACHINE_CURRENT_INCOMMING: - hfp_handle_key(HFP_KEY_HANGUP_CALL); - break; - case HFCALL_MACHINE_CURRENT_OUTGOING: - break; - case HFCALL_MACHINE_CURRENT_CALLING: - { - if(app_bt_device.phone_earphone_mark == 0){ - //call is active, switch from earphone to phone - hfp_handle_key(HFP_KEY_CHANGE_TO_PHONE); - }else if(app_bt_device.phone_earphone_mark == 1){ - //call is active, switch from phone to earphone - hfp_handle_key(HFP_KEY_ADD_TO_EARPHONE); - } - } - break; - case HFCALL_MACHINE_CURRENT_3WAY_INCOMMING: - { - app_voice_report(APP_STATUS_INDICATION_WARNING, 0); - hfp_handle_key(HFP_KEY_THREEWAY_HOLD_AND_ANSWER); - } - break; - case HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING: - hfp_handle_key(HFP_KEY_THREEWAY_HANGUP_AND_ANSWER); - break; + } break; + case HFCALL_MACHINE_CURRENT_INCOMMING: + hfp_handle_key(HFP_KEY_ANSWER_CALL); + break; + case HFCALL_MACHINE_CURRENT_OUTGOING: + hfp_handle_key(HFP_KEY_HANGUP_CALL); + break; + case HFCALL_MACHINE_CURRENT_CALLING: + hfp_handle_key(HFP_KEY_HANGUP_CALL); + break; + case HFCALL_MACHINE_CURRENT_3WAY_INCOMMING: + hfp_handle_key(HFP_KEY_THREEWAY_HANGUP_AND_ANSWER); + break; + case HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING: + hfp_handle_key(HFP_KEY_THREEWAY_HOLD_AND_ANSWER); + break; #ifdef __BT_ONE_BRING_TWO__ - case HFCALL_MACHINE_CURRENT_IDLE_ANOTHER_IDLE: + case HFCALL_MACHINE_CURRENT_IDLE_ANOTHER_IDLE: { + if (app_bt_device.a2dp_play_pause_flag == 0) { + a2dp_handleKey(AVRCP_KEY_PLAY); + } else { + a2dp_handleKey(AVRCP_KEY_PAUSE); + } + } break; + case HFCALL_MACHINE_CURRENT_INCOMMING_ANOTHER_IDLE: + hfp_handle_key(HFP_KEY_ANSWER_CALL); + break; + case HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_IDLE: + hfp_handle_key(HFP_KEY_HANGUP_CALL); + break; + case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_IDLE: + hfp_handle_key(HFP_KEY_HANGUP_CALL); + break; + case HFCALL_MACHINE_CURRENT_3WAY_INCOMMING_ANOTHER_IDLE: + hfp_handle_key(HFP_KEY_THREEWAY_HANGUP_AND_ANSWER); + break; + case HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING_ANOTHER_IDLE: + hfp_handle_key(HFP_KEY_THREEWAY_HOLD_AND_ANSWER); + break; + case HFCALL_MACHINE_CURRENT_INCOMMING_ANOTHER_INCOMMING: + break; + case HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_INCOMMING: + break; + case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_INCOMMING: + hfp_handle_key(HFP_KEY_DUAL_HF_HANGUP_CURR_ANSWER_ANOTHER); + break; + case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_CHANGETOPHONE: + hfp_handle_key(HFP_KEY_DUAL_HF_HANGUP_ANOTHER_ADDTOEARPHONE); + break; + case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_HOLD: + hfp_handle_key(HFP_KEY_DUAL_HF_HANGUP_CURR_ANSWER_ANOTHER); + break; +#endif + default: + break; + } +#if defined(__HSP_ENABLE__) + // now we know it is HSP active ! + if (app_bt_device.hs_conn_flag[app_bt_device.curr_hs_channel_id] == 1) { + hsp_handle_key(HSP_KEY_CKPD_CONTROL); + } +#endif +#if HF_CUSTOM_FEATURE_SUPPORT & HF_CUSTOM_FEATURE_SIRI_REPORT + open_siri_flag = 0; +#endif + return; +} +void bt_key_handle_func_doubleclick(void) { + TRACE(0, "%s enter", __func__); + + HFCALL_MACHINE_ENUM hfcall_machine = app_get_hfcall_machine(); + +#ifdef SUPPORT_SIRI + open_siri_flag = 0; +#endif + + switch (hfcall_machine) { + case HFCALL_MACHINE_CURRENT_IDLE: #ifdef BTIF_HID_DEVICE - Hid_Send_capture(&app_bt_device.hid_channel[BT_DEVICE_ID_1]); + app_bt_hid_send_capture(app_bt_device.hid_channel[BT_DEVICE_ID_1]); +#else + hfp_handle_key(HFP_KEY_REDIAL_LAST_CALL); #endif - break; - case HFCALL_MACHINE_CURRENT_INCOMMING_ANOTHER_IDLE: - hfp_handle_key(HFP_KEY_HANGUP_CALL); - break; - case HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_IDLE: - break; - case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_IDLE: - { - if(app_bt_device.phone_earphone_mark == 0){ - //call is active, switch from earphone to phone - hfp_handle_key(HFP_KEY_CHANGE_TO_PHONE); - }else if(app_bt_device.phone_earphone_mark == 1){ - //call is active, switch from phone to earphone - hfp_handle_key(HFP_KEY_ADD_TO_EARPHONE); - } - } - break; - case HFCALL_MACHINE_CURRENT_3WAY_INCOMMING_ANOTHER_IDLE: - hfp_handle_key(HFP_KEY_THREEWAY_HOLD_AND_ANSWER); - break; - case HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING_ANOTHER_IDLE: - hfp_handle_key(HFP_KEY_THREEWAY_HANGUP_AND_ANSWER); - break; - case HFCALL_MACHINE_CURRENT_INCOMMING_ANOTHER_INCOMMING: - break; - case HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_INCOMMING: - break; - case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_INCOMMING: - hfp_handle_key(HFP_KEY_DUAL_HF_CHANGETOPHONE_ANSWER_ANOTHER); - //hfp_handle_key(HFP_KEY_DUAL_HF_HOLD_CURR_ANSWER_ANOTHER); - break; - case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_CHANGETOPHONE: - hfp_handle_key(HFP_KEY_DUAL_HF_CHANGETOPHONE_ANOTHER_ADDTOEARPHONE); - break; - case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_HOLD: - hfp_handle_key(HFP_KEY_DUAL_HF_HANGUP_CURR_ANSWER_ANOTHER); - break; + break; + case HFCALL_MACHINE_CURRENT_INCOMMING: + break; + case HFCALL_MACHINE_CURRENT_OUTGOING: + break; + case HFCALL_MACHINE_CURRENT_CALLING: + if (app_bt_device.hf_mute_flag == 0) { + hfp_handle_key(HFP_KEY_MUTE); + app_bt_device.hf_mute_flag = 1; + } else { + hfp_handle_key(HFP_KEY_CLEAR_MUTE); + app_bt_device.hf_mute_flag = 0; + } + break; + case HFCALL_MACHINE_CURRENT_3WAY_INCOMMING: + hfp_handle_key(HFP_KEY_THREEWAY_HOLD_REL_INCOMING); + break; + case HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING: + break; +#ifdef __BT_ONE_BRING_TWO__ + case HFCALL_MACHINE_CURRENT_IDLE_ANOTHER_IDLE: +#ifdef BTIF_HID_DEVICE + app_bt_hid_send_capture(app_bt_device.hid_channel[BT_DEVICE_ID_1]); +#else + hfp_handle_key(HFP_KEY_REDIAL_LAST_CALL); #endif - default: - break; + break; + case HFCALL_MACHINE_CURRENT_INCOMMING_ANOTHER_IDLE: + break; + case HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_IDLE: + break; + case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_IDLE: + if (app_bt_device.hf_mute_flag == 0) { + hfp_handle_key(HFP_KEY_MUTE); + } else { + hfp_handle_key(HFP_KEY_CLEAR_MUTE); } -#if defined (__HSP_ENABLE__) - if(hfcall_machine == HFCALL_MACHINE_NUM){ - if(app_bt_device.hs_conn_flag[app_bt_device.curr_hs_channel_id] == 1){ //now we know it is HSP active ! - if(app_bt_device.phone_earphone_mark == 0){ - //call is active, switch from earphone to phone - hsp_handle_key(HSP_KEY_CHANGE_TO_PHONE); - }else if(app_bt_device.phone_earphone_mark == 1){ - //call is active, switch from phone to earphone - hsp_handle_key(HSP_KEY_ADD_TO_EARPHONE); - } - } + break; + case HFCALL_MACHINE_CURRENT_3WAY_INCOMMING_ANOTHER_IDLE: + hfp_handle_key(HFP_KEY_THREEWAY_HOLD_REL_INCOMING); + break; + case HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING_ANOTHER_IDLE: + break; + case HFCALL_MACHINE_CURRENT_INCOMMING_ANOTHER_INCOMMING: + break; + case HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_INCOMMING: + break; + case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_INCOMMING: + hfp_handle_key(HFP_KEY_DUAL_HF_HANGUP_ANOTHER); + break; + case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_CHANGETOPHONE: + break; + case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_HOLD: + break; +#endif + default: + break; + } +} +void bt_key_handle_func_longpress(void) { + TRACE(0, "%s enter", __func__); + HFCALL_MACHINE_ENUM hfcall_machine = app_get_hfcall_machine(); +#ifdef SUPPORT_SIRI + open_siri_flag = 0; +#endif + app_voice_report(APP_STATUS_INDICATION_WARNING, 0); + + switch (hfcall_machine) { + case HFCALL_MACHINE_CURRENT_IDLE: { +#if HF_CUSTOM_FEATURE_SUPPORT & HF_CUSTOM_FEATURE_SIRI_REPORT + if (open_siri_flag == 0) { + app_voice_report(APP_STATUS_INDICATION_WARNING, 0); + open_siri_flag = 1; } +#endif + } break; + case HFCALL_MACHINE_CURRENT_INCOMMING: + hfp_handle_key(HFP_KEY_HANGUP_CALL); + break; + case HFCALL_MACHINE_CURRENT_OUTGOING: + break; + case HFCALL_MACHINE_CURRENT_CALLING: { + if (app_bt_device.phone_earphone_mark == 0) { + // call is active, switch from earphone to phone + hfp_handle_key(HFP_KEY_CHANGE_TO_PHONE); + } else if (app_bt_device.phone_earphone_mark == 1) { + // call is active, switch from phone to earphone + hfp_handle_key(HFP_KEY_ADD_TO_EARPHONE); + } + } break; + case HFCALL_MACHINE_CURRENT_3WAY_INCOMMING: { + app_voice_report(APP_STATUS_INDICATION_WARNING, 0); + hfp_handle_key(HFP_KEY_THREEWAY_HOLD_AND_ANSWER); + } break; + case HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING: + hfp_handle_key(HFP_KEY_THREEWAY_HANGUP_AND_ANSWER); + break; +#ifdef __BT_ONE_BRING_TWO__ + case HFCALL_MACHINE_CURRENT_IDLE_ANOTHER_IDLE: +#ifdef BTIF_HID_DEVICE + Hid_Send_capture(&app_bt_device.hid_channel[BT_DEVICE_ID_1]); +#endif + break; + case HFCALL_MACHINE_CURRENT_INCOMMING_ANOTHER_IDLE: + hfp_handle_key(HFP_KEY_HANGUP_CALL); + break; + case HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_IDLE: + break; + case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_IDLE: { + if (app_bt_device.phone_earphone_mark == 0) { + // call is active, switch from earphone to phone + hfp_handle_key(HFP_KEY_CHANGE_TO_PHONE); + } else if (app_bt_device.phone_earphone_mark == 1) { + // call is active, switch from phone to earphone + hfp_handle_key(HFP_KEY_ADD_TO_EARPHONE); + } + } break; + case HFCALL_MACHINE_CURRENT_3WAY_INCOMMING_ANOTHER_IDLE: + hfp_handle_key(HFP_KEY_THREEWAY_HOLD_AND_ANSWER); + break; + case HFCALL_MACHINE_CURRENT_3WAY_HOLD_CALLING_ANOTHER_IDLE: + hfp_handle_key(HFP_KEY_THREEWAY_HANGUP_AND_ANSWER); + break; + case HFCALL_MACHINE_CURRENT_INCOMMING_ANOTHER_INCOMMING: + break; + case HFCALL_MACHINE_CURRENT_OUTGOING_ANOTHER_INCOMMING: + break; + case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_INCOMMING: + hfp_handle_key(HFP_KEY_DUAL_HF_CHANGETOPHONE_ANSWER_ANOTHER); + // hfp_handle_key(HFP_KEY_DUAL_HF_HOLD_CURR_ANSWER_ANOTHER); + break; + case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_CHANGETOPHONE: + hfp_handle_key(HFP_KEY_DUAL_HF_CHANGETOPHONE_ANOTHER_ADDTOEARPHONE); + break; + case HFCALL_MACHINE_CURRENT_CALLING_ANOTHER_HOLD: + hfp_handle_key(HFP_KEY_DUAL_HF_HANGUP_CURR_ANSWER_ANOTHER); + break; +#endif + default: + break; + } +#if defined(__HSP_ENABLE__) + if (hfcall_machine == HFCALL_MACHINE_NUM) { + if (app_bt_device.hs_conn_flag[app_bt_device.curr_hs_channel_id] == + 1) { // now we know it is HSP active ! + if (app_bt_device.phone_earphone_mark == 0) { + // call is active, switch from earphone to phone + hsp_handle_key(HSP_KEY_CHANGE_TO_PHONE); + } else if (app_bt_device.phone_earphone_mark == 1) { + // call is active, switch from phone to earphone + hsp_handle_key(HSP_KEY_ADD_TO_EARPHONE); + } + } + } #endif } -void bt_key_handle_func_key(enum APP_KEY_EVENT_T event) -{ - switch (event) { - case APP_KEY_EVENT_UP: - case APP_KEY_EVENT_CLICK: - bt_key_handle_func_click(); - break; - case APP_KEY_EVENT_DOUBLECLICK: - bt_key_handle_func_doubleclick(); - break; - case APP_KEY_EVENT_LONGPRESS: - bt_key_handle_func_longpress(); - break; - default: - TRACE(0,"unregister func key event=%x", event); - break; - } +void bt_key_handle_func_key(enum APP_KEY_EVENT_T event) { + switch (event) { + case APP_KEY_EVENT_UP: + case APP_KEY_EVENT_CLICK: + bt_key_handle_func_click(); + break; + case APP_KEY_EVENT_DOUBLECLICK: + bt_key_handle_func_doubleclick(); + break; + case APP_KEY_EVENT_LONGPRESS: + bt_key_handle_func_longpress(); + break; + default: + TRACE(0, "unregister func key event=%x", event); + break; + } } #if 0 @@ -988,7 +982,7 @@ void bt_key_handle_func_key(enum APP_KEY_EVENT_T event) #endif switch(event) - { + { #ifndef __BT_ONE_BRING_TWO__ case APP_KEY_EVENT_UP: case APP_KEY_EVENT_CLICK: @@ -1296,9 +1290,7 @@ void bt_key_handle_func_key(enum APP_KEY_EVENT_T event) } #endif - - - #if 0 +#if 0 if((app_bt_device.hfchan_call[BT_DEVICE_ID_1] == BTIF_HF_CALL_ACTIVE)&&(app_bt_device.hfchan_callSetup[BT_DEVICE_ID_2] == BTIF_HF_CALL_SETUP_IN)){ hfp_handle_key(HFP_KEY_DUAL_HF_HOLD_CURR_ANSWER_ANOTHER); }else if((app_bt_device.hfchan_call[BT_DEVICE_ID_2] == BTIF_HF_CALL_ACTIVE)&&(app_bt_device.hfchan_callSetup[BT_DEVICE_ID_1] == BTIF_HF_CALL_SETUP_IN)){ @@ -1306,229 +1298,195 @@ void bt_key_handle_func_key(enum APP_KEY_EVENT_T event) } #endif break; -#endif/* __BT_ONE_BRING_TWO__ */ +#endif /* __BT_ONE_BRING_TWO__ */ default: TRACE(1,"unregister func key event=%x",event); break; } } #endif -void app_bt_volumeup() -{ - app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_UP, 0); +void app_bt_volumeup() { + app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_UP, 0); } - -void app_bt_volumedown() -{ - app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_DOWN, 0); +void app_bt_volumedown() { + app_audio_manager_ctrl_volume(APP_AUDIO_MANAGER_VOLUME_CTRL_DOWN, 0); } #if defined(__APP_KEY_FN_STYLE_A__) -void bt_key_handle_up_key(enum APP_KEY_EVENT_T event) -{ -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) - struct nvrecord_env_t *nvrecord_env=NULL; +void bt_key_handle_up_key(enum APP_KEY_EVENT_T event) { +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) + struct nvrecord_env_t *nvrecord_env = NULL; #endif - switch(event) - { - case APP_KEY_EVENT_UP: - case APP_KEY_EVENT_CLICK: - app_bt_volumeup(); - break; - case APP_KEY_EVENT_LONGPRESS: - a2dp_handleKey(AVRCP_KEY_FORWARD); - break; -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) - case APP_KEY_EVENT_DOUBLECLICK: - //debug switch src mode - nv_record_env_get(&nvrecord_env); - if(app_bt_device.src_or_snk==BT_DEVICE_SRC) - { - nvrecord_env->src_snk_flag.src_snk_mode =BT_DEVICE_SNK; - } - else - { - nvrecord_env->src_snk_flag.src_snk_mode =BT_DEVICE_SRC; - } - nv_record_env_set(nvrecord_env); - app_reset(); - break; -#endif - default: - TRACE(1,"unregister up key event=%x",event); - break; + switch (event) { + case APP_KEY_EVENT_UP: + case APP_KEY_EVENT_CLICK: + app_bt_volumeup(); + break; + case APP_KEY_EVENT_LONGPRESS: + a2dp_handleKey(AVRCP_KEY_FORWARD); + break; +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) + case APP_KEY_EVENT_DOUBLECLICK: + // debug switch src mode + nv_record_env_get(&nvrecord_env); + if (app_bt_device.src_or_snk == BT_DEVICE_SRC) { + nvrecord_env->src_snk_flag.src_snk_mode = BT_DEVICE_SNK; + } else { + nvrecord_env->src_snk_flag.src_snk_mode = BT_DEVICE_SRC; } + nv_record_env_set(nvrecord_env); + app_reset(); + break; +#endif + default: + TRACE(1, "unregister up key event=%x", event); + break; + } } +void bt_key_handle_down_key(enum APP_KEY_EVENT_T event) { + switch (event) { + case APP_KEY_EVENT_UP: + case APP_KEY_EVENT_CLICK: + app_bt_volumedown(); + break; + case APP_KEY_EVENT_LONGPRESS: + a2dp_handleKey(AVRCP_KEY_BACKWARD); -void bt_key_handle_down_key(enum APP_KEY_EVENT_T event) -{ - switch(event) - { - case APP_KEY_EVENT_UP: - case APP_KEY_EVENT_CLICK: - app_bt_volumedown(); - break; - case APP_KEY_EVENT_LONGPRESS: - a2dp_handleKey(AVRCP_KEY_BACKWARD); - - break; - default: - TRACE(1,"unregister down key event=%x",event); - break; - } + break; + default: + TRACE(1, "unregister down key event=%x", event); + break; + } } #else //#elif defined(__APP_KEY_FN_STYLE_B__) -void bt_key_handle_up_key(enum APP_KEY_EVENT_T event) -{ - TRACE(1,"%s",__func__); - switch(event) - { - case APP_KEY_EVENT_REPEAT: - app_bt_volumeup(); - break; - case APP_KEY_EVENT_UP: - case APP_KEY_EVENT_CLICK: - a2dp_handleKey(AVRCP_KEY_FORWARD); - break; - default: - TRACE(1,"unregister up key event=%x",event); - break; - } +void bt_key_handle_up_key(enum APP_KEY_EVENT_T event) { + TRACE(1, "%s", __func__); + switch (event) { + case APP_KEY_EVENT_REPEAT: + app_bt_volumeup(); + break; + case APP_KEY_EVENT_UP: + case APP_KEY_EVENT_CLICK: + a2dp_handleKey(AVRCP_KEY_FORWARD); + break; + default: + TRACE(1, "unregister up key event=%x", event); + break; + } } - -void bt_key_handle_down_key(enum APP_KEY_EVENT_T event) -{ - switch(event) - { - case APP_KEY_EVENT_REPEAT: - app_bt_volumedown(); - break; - case APP_KEY_EVENT_UP: - case APP_KEY_EVENT_CLICK: - a2dp_handleKey(AVRCP_KEY_BACKWARD); - break; - default: - TRACE(1,"unregister down key event=%x",event); - break; - } +void bt_key_handle_down_key(enum APP_KEY_EVENT_T event) { + switch (event) { + case APP_KEY_EVENT_REPEAT: + app_bt_volumedown(); + break; + case APP_KEY_EVENT_UP: + case APP_KEY_EVENT_CLICK: + a2dp_handleKey(AVRCP_KEY_BACKWARD); + break; + default: + TRACE(1, "unregister down key event=%x", event); + break; + } } #endif -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) -void bt_key_handle_source_func_key(enum APP_KEY_EVENT_T event) -{ - TRACE(2,"%s,%d",__FUNCTION__,event); - static bool onaudioloop = false; - switch(event) - { - case APP_KEY_EVENT_UP: - case APP_KEY_EVENT_CLICK: - app_a2dp_source_find_sink(); - break; - case APP_KEY_EVENT_DOUBLECLICK: - if(app_bt_device.a2dp_state[0]==1) - { - onaudioloop = onaudioloop?false:true; - if (onaudioloop) - { - app_a2dp_start_stream(); +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) +void bt_key_handle_source_func_key(enum APP_KEY_EVENT_T event) { + TRACE(2, "%s,%d", __FUNCTION__, event); + static bool onaudioloop = false; + switch (event) { + case APP_KEY_EVENT_UP: + case APP_KEY_EVENT_CLICK: + app_a2dp_source_find_sink(); + break; + case APP_KEY_EVENT_DOUBLECLICK: + if (app_bt_device.a2dp_state[0] == 1) { + onaudioloop = onaudioloop ? false : true; + if (onaudioloop) { + app_a2dp_start_stream(); - } - else - { - app_a2dp_suspend_stream(); - } - } - break; - case APP_KEY_EVENT_TRIPLECLICK: - app_a2dp_start_stream(); - break; - default: - TRACE(1,"unregister down key event=%x",event); - break; + } else { + app_a2dp_suspend_stream(); + } } + break; + case APP_KEY_EVENT_TRIPLECLICK: + app_a2dp_start_stream(); + break; + default: + TRACE(1, "unregister down key event=%x", event); + break; + } } #endif APP_KEY_STATUS bt_key; -static void bt_update_key_event(uint32_t code, uint8_t event) -{ - TRACE(3,"%s code:%d evt:%d",__func__, code, event); +static void bt_update_key_event(uint32_t code, uint8_t event) { + TRACE(3, "%s code:%d evt:%d", __func__, code, event); - bt_key.code = code; - bt_key.event = event; - osapi_notify_evm(); + bt_key.code = code; + bt_key.event = event; + osapi_notify_evm(); } -void bt_key_send(APP_KEY_STATUS *status) -{ - uint32_t lock = int_lock(); - bool isKeyBusy = false; - if (0xff != bt_key.code) - { - isKeyBusy = true; - } - int_unlock(lock); +void bt_key_send(APP_KEY_STATUS *status) { + uint32_t lock = int_lock(); + bool isKeyBusy = false; + if (0xff != bt_key.code) { + isKeyBusy = true; + } + int_unlock(lock); - if (!isKeyBusy) - { - app_bt_start_custom_function_in_bt_thread( - (uint32_t)status->code, - (uint32_t)status->event, - (uint32_t)bt_update_key_event); - } + if (!isKeyBusy) { + app_bt_start_custom_function_in_bt_thread((uint32_t)status->code, + (uint32_t)status->event, + (uint32_t)bt_update_key_event); + } } -void bt_key_handle(void) -{ - osapi_lock_stack(); - if(bt_key.code != 0xff) - { - TRACE(3,"%s code:%d evt:%d",__func__, bt_key.code, bt_key.event); - switch(bt_key.code) - { - case BTAPP_FUNC_KEY: -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) - if(app_bt_device.src_or_snk==BT_DEVICE_SRC) - { - bt_key_handle_source_func_key((enum APP_KEY_EVENT_T)bt_key.event); - } - else +void bt_key_handle(void) { + osapi_lock_stack(); + if (bt_key.code != 0xff) { + TRACE(3, "%s code:%d evt:%d", __func__, bt_key.code, bt_key.event); + switch (bt_key.code) { + case BTAPP_FUNC_KEY: +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) + if (app_bt_device.src_or_snk == BT_DEVICE_SRC) { + bt_key_handle_source_func_key((enum APP_KEY_EVENT_T)bt_key.event); + } else #endif - { - bt_key_handle_func_key((enum APP_KEY_EVENT_T)bt_key.event); - } - break; - case BTAPP_VOLUME_UP_KEY: - bt_key_handle_up_key((enum APP_KEY_EVENT_T)bt_key.event); - break; - case BTAPP_VOLUME_DOWN_KEY: - bt_key_handle_down_key((enum APP_KEY_EVENT_T)bt_key.event); - break; + { + bt_key_handle_func_key((enum APP_KEY_EVENT_T)bt_key.event); + } + break; + case BTAPP_VOLUME_UP_KEY: + bt_key_handle_up_key((enum APP_KEY_EVENT_T)bt_key.event); + break; + case BTAPP_VOLUME_DOWN_KEY: + bt_key_handle_down_key((enum APP_KEY_EVENT_T)bt_key.event); + break; #ifdef SUPPORT_SIRI - case BTAPP_RELEASE_KEY: - bt_key_handle_siri_key((enum APP_KEY_EVENT_T)bt_key.event); - break; + case BTAPP_RELEASE_KEY: + bt_key_handle_siri_key((enum APP_KEY_EVENT_T)bt_key.event); + break; #endif - default: - TRACE(0,"bt_key_handle undefined key"); - break; - } - bt_key.code = 0xff; + default: + TRACE(0, "bt_key_handle undefined key"); + break; } - osapi_unlock_stack(); -} - -void bt_key_init(void) -{ - Besbt_hook_handler_set(BESBT_HOOK_USER_2, bt_key_handle); -#ifdef __BT_ONE_BRING_TWO__ - //bt_key_hf_channel_switch_init(); -#endif bt_key.code = 0xff; - bt_key.event = 0xff; + } + osapi_unlock_stack(); } +void bt_key_init(void) { + Besbt_hook_handler_set(BESBT_HOOK_USER_2, bt_key_handle); +#ifdef __BT_ONE_BRING_TWO__ + // bt_key_hf_channel_switch_init(); +#endif + bt_key.code = 0xff; + bt_key.event = 0xff; +} diff --git a/services/bt_app/app_media_player.cpp b/services/bt_app/app_media_player.cpp index 59bcb45..762ffad 100644 --- a/services/bt_app/app_media_player.cpp +++ b/services/bt_app/app_media_player.cpp @@ -13,13 +13,13 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include -#include +#include "app_bt_trace.h" #include "cmsis.h" #include "cmsis_os.h" -#include "app_bt_trace.h" #include "tgt_hardware.h" +#include +#include +#include #ifdef WL_DET #include "app_mic_alg.h" @@ -27,36 +27,37 @@ #ifdef MEDIA_PLAYER_SUPPORT -#include "hal_uart.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_cmu.h" #include "analog.h" +#include "app_audio.h" #include "app_bt_stream.h" #include "app_overlay.h" -#include "app_audio.h" #include "app_utils.h" +#include "audioflinger.h" +#include "hal_cmu.h" +#include "hal_timer.h" +#include "hal_uart.h" +#include "lockcqueue.h" +#include "app_bt.h" +#include "app_media_player.h" +#include "audio_prompt_sbc.h" +#include "besbt.h" #include "res_audio_data.h" #include "res_audio_data_cn.h" -#include "resources.h" -#include "app_media_player.h" #include "res_audio_ring.h" -#include "audio_prompt_sbc.h" -#include "app_bt.h" -#include "besbt.h" +#include "resources.h" -#include "cqueue.h" -#include "btapp.h" #include "app_bt_media_manager.h" +#include "btapp.h" +#include "cqueue.h" #ifdef VOICE_DATAPATH -#include "app_voicepath.h" #include "app_ai_if.h" +#include "app_voicepath.h" #endif -#if defined(AUDIO_ANC_FB_MC_MEDIA) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) -#include"anc_process.h" +#if defined(AUDIO_ANC_FB_MC_MEDIA) && defined(ANC_APP) && \ + !defined(__AUDIO_RESAMPLE__) +#include "anc_process.h" #include "hal_codec.h" #endif @@ -64,9 +65,9 @@ #include "app_thirdparty.h" #endif #if defined(IBRT) -#include "app_tws_ibrt.h" #include "app_ibrt_if.h" #include "app_ibrt_voice_report.h" +#include "app_tws_ibrt.h" #endif #ifdef __INTERACTION__ uint8_t g_findme_fadein_vol = TGT_VOLUME_LEVEL_0; @@ -75,18 +76,19 @@ static char need_init_decoder = 1; static btif_sbc_decoder_t *media_sbc_decoder = NULL; #define SBC_TEMP_BUFFER_SIZE 64 -#define SBC_QUEUE_SIZE (SBC_TEMP_BUFFER_SIZE*16) +#define SBC_QUEUE_SIZE (SBC_TEMP_BUFFER_SIZE * 16) CQueue media_sbc_queue; -static float * media_sbc_eq_band_gain = NULL; +static float *media_sbc_eq_band_gain = NULL; #ifdef __BT_ANC__ -#define APP_AUDIO_PLAYBACK_BUFF_SIZE (1024*3) +#define APP_AUDIO_PLAYBACK_BUFF_SIZE (1024 * 3) #else -#define APP_AUDIO_PLAYBACK_BUFF_SIZE (1024*4) +#define APP_AUDIO_PLAYBACK_BUFF_SIZE (1024 * 4) #endif -#if defined(AUDIO_ANC_FB_MC_MEDIA) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) +#if defined(AUDIO_ANC_FB_MC_MEDIA) && defined(ANC_APP) && \ + !defined(__AUDIO_RESAMPLE__) static enum AUD_BITS_T sample_size_play_bt; static enum AUD_SAMPRATE_T sample_rate_play_bt; static uint32_t data_size_play_bt; @@ -97,13 +99,11 @@ static int32_t playback_samplerate_ratio_bt; static uint8_t *playback_buf_mc; static uint32_t playback_size_mc; -static enum AUD_CHANNEL_NUM_T playback_ch_num_bt; +static enum AUD_CHANNEL_NUM_T playback_ch_num_bt; #endif - - -#define SBC_FRAME_LEN 64 //0x5c /* pcm 512 bytes*/ -static U8* g_app_audio_data = NULL; +#define SBC_FRAME_LEN 64 // 0x5c /* pcm 512 bytes*/ +static U8 *g_app_audio_data = NULL; static uint32_t g_app_audio_length = 0; static uint32_t g_app_audio_read = 0; @@ -113,45 +113,42 @@ static uint8_t app_play_sbc_stop_proc_cnt = 0; static uint16_t g_prompt_chnlsel = PROMOT_ID_BIT_MASK_CHNLSEl_ALL; -//for continue play +// for continue play #define MAX_SOUND_NUMBER 10 -typedef struct tMediaSoundMap -{ - U8* data; //total files - uint32_t fsize; //file index +typedef struct tMediaSoundMap { + U8 *data; // total files + uint32_t fsize; // file index -}_tMediaSoundMap; +} _tMediaSoundMap; -const tMediaSoundMap* media_sound_map; +const tMediaSoundMap *media_sound_map; -const tMediaSoundMap media_sound_map_cn[MAX_SOUND_NUMBER] = -{ - {(U8*)CN_SOUND_ZERO, sizeof(CN_SOUND_ZERO) }, - {(U8*)CN_SOUND_ONE, sizeof(CN_SOUND_ONE) }, - {(U8*)CN_SOUND_TWO, sizeof(CN_SOUND_TWO) }, - {(U8*)CN_SOUND_THREE, sizeof(CN_SOUND_THREE) }, - {(U8*)CN_SOUND_FOUR, sizeof(CN_SOUND_FOUR) }, - {(U8*)CN_SOUND_FIVE, sizeof(CN_SOUND_FIVE) }, - {(U8*)CN_SOUND_SIX, sizeof(CN_SOUND_SIX) }, - {(U8*)CN_SOUND_SEVEN, sizeof(CN_SOUND_SEVEN) }, - {(U8*)CN_SOUND_EIGHT, sizeof(CN_SOUND_EIGHT) }, - {(U8*)CN_SOUND_NINE, sizeof(CN_SOUND_NINE) }, +const tMediaSoundMap media_sound_map_cn[MAX_SOUND_NUMBER] = { + {(U8 *)CN_SOUND_ZERO, sizeof(CN_SOUND_ZERO)}, + {(U8 *)CN_SOUND_ONE, sizeof(CN_SOUND_ONE)}, + {(U8 *)CN_SOUND_TWO, sizeof(CN_SOUND_TWO)}, + {(U8 *)CN_SOUND_THREE, sizeof(CN_SOUND_THREE)}, + {(U8 *)CN_SOUND_FOUR, sizeof(CN_SOUND_FOUR)}, + {(U8 *)CN_SOUND_FIVE, sizeof(CN_SOUND_FIVE)}, + {(U8 *)CN_SOUND_SIX, sizeof(CN_SOUND_SIX)}, + {(U8 *)CN_SOUND_SEVEN, sizeof(CN_SOUND_SEVEN)}, + {(U8 *)CN_SOUND_EIGHT, sizeof(CN_SOUND_EIGHT)}, + {(U8 *)CN_SOUND_NINE, sizeof(CN_SOUND_NINE)}, }; -const tMediaSoundMap media_sound_map_en[MAX_SOUND_NUMBER] = -{ - {(U8*)EN_SOUND_ZERO, EN_SOUND_ZERO_len }, - {(U8*)EN_SOUND_ONE, EN_SOUND_ONE_len }, - {(U8*)EN_SOUND_TWO, EN_SOUND_TWO_len }, - {(U8*)EN_SOUND_THREE, EN_SOUND_THREE_len }, - {(U8*)EN_SOUND_FOUR, EN_SOUND_FOUR_len }, - {(U8*)EN_SOUND_FIVE, EN_SOUND_FIVE_len }, - {(U8*)EN_SOUND_SIX, EN_SOUND_SIX_len }, - {(U8*)EN_SOUND_SEVEN, EN_SOUND_SEVEN_len }, - {(U8*)EN_SOUND_EIGHT, EN_SOUND_EIGHT_len }, - {(U8*)EN_SOUND_NINE, EN_SOUND_NINE_len }, +const tMediaSoundMap media_sound_map_en[MAX_SOUND_NUMBER] = { + {(U8 *)EN_SOUND_ZERO, EN_SOUND_ZERO_len}, + {(U8 *)EN_SOUND_ONE, EN_SOUND_ONE_len}, + {(U8 *)EN_SOUND_TWO, EN_SOUND_TWO_len}, + {(U8 *)EN_SOUND_THREE, EN_SOUND_THREE_len}, + {(U8 *)EN_SOUND_FOUR, EN_SOUND_FOUR_len}, + {(U8 *)EN_SOUND_FIVE, EN_SOUND_FIVE_len}, + {(U8 *)EN_SOUND_SIX, EN_SOUND_SIX_len}, + {(U8 *)EN_SOUND_SEVEN, EN_SOUND_SEVEN_len}, + {(U8 *)EN_SOUND_EIGHT, EN_SOUND_EIGHT_len}, + {(U8 *)EN_SOUND_NINE, EN_SOUND_NINE_len}, }; const uint8_t BT_MUTE[] = { @@ -160,316 +157,300 @@ const uint8_t BT_MUTE[] = { char Media_player_number[MAX_PHB_NUMBER]; -typedef struct tPlayContContext -{ - uint32_t g_play_continue_total; //total files - uint32_t g_play_continue_n; //file index +typedef struct tPlayContContext { + uint32_t g_play_continue_total; // total files + uint32_t g_play_continue_n; // file index - uint32_t g_play_continue_fread; //per file have readed + uint32_t g_play_continue_fread; // per file have readed - U8 g_play_continue_array[MAX_PHB_NUMBER]; + U8 g_play_continue_array[MAX_PHB_NUMBER]; -}_tPlayContContext; +} _tPlayContContext; tPlayContContext pCont_context; APP_AUDIO_STATUS MSG_PLAYBACK_STATUS; -APP_AUDIO_STATUS* ptr_msg_playback = &MSG_PLAYBACK_STATUS; +APP_AUDIO_STATUS *ptr_msg_playback = &MSG_PLAYBACK_STATUS; static int g_language = MEDIA_DEFAULT_LANGUAGE; #ifdef AUDIO_LINEIN static enum AUD_SAMPRATE_T app_play_audio_sample_rate = AUD_SAMPRATE_16000; #endif -#define PREFIX_AUDIO(name) ((g_language==MEDIA_DEFAULT_LANGUAGE) ? EN_##name : CN_##name) +#define PREFIX_AUDIO(name) \ + ((g_language == MEDIA_DEFAULT_LANGUAGE) ? EN_##name : CN_##name) -#define PROMPT_MIX_PROPERTY_PTR_FROM_ENTRY_INDEX(index) \ - ((PROMPT_MIX_PROPERTY_T *)((uintptr_t)__mixprompt_property_table_start + \ - (index)*sizeof(PROMPT_MIX_PROPERTY_T))) +#define PROMPT_MIX_PROPERTY_PTR_FROM_ENTRY_INDEX(index) \ + ((PROMPT_MIX_PROPERTY_T *)((uintptr_t)__mixprompt_property_table_start + \ + (index) * sizeof(PROMPT_MIX_PROPERTY_T))) -int media_audio_init(void) -{ - const float EQLevel[25] = { - 0.0630957, 0.0794328, 0.1, 0.1258925, 0.1584893, - 0.1995262, 0.2511886, 0.3162278, 0.398107 , 0.5011872, - 0.6309573, 0.794328 , 1, 1.258925 , 1.584893 , - 1.995262 , 2.5118864, 3.1622776, 3.9810717, 5.011872 , - 6.309573 , 7.943282 , 10 , 12.589254, 15.848932 - };//-12~12 - uint8_t *buff = NULL; - uint8_t i; +int media_audio_init(void) { + const float EQLevel[25] = { + 0.0630957, 0.0794328, 0.1, 0.1258925, 0.1584893, + 0.1995262, 0.2511886, 0.3162278, 0.398107, 0.5011872, + 0.6309573, 0.794328, 1, 1.258925, 1.584893, + 1.995262, 2.5118864, 3.1622776, 3.9810717, 5.011872, + 6.309573, 7.943282, 10, 12.589254, 15.848932}; //-12~12 + uint8_t *buff = NULL; + uint8_t i; - app_audio_mempool_get_buff((uint8_t **)&media_sbc_eq_band_gain, CFG_HW_AUD_EQ_NUM_BANDS*sizeof(float)); + app_audio_mempool_get_buff((uint8_t **)&media_sbc_eq_band_gain, + CFG_HW_AUD_EQ_NUM_BANDS * sizeof(float)); - for (i=0; itws_mode) - { - return; - } + if (IBRT_ACTIVE_MODE != app_ibrt_if_get_bt_ctrl_ctx()->tws_mode) { + return; + } - bool isPlayPendingPrompt = false; - uint16_t promptIdToPlay = 0; + bool isPlayPendingPrompt = false; + uint16_t promptIdToPlay = 0; - uint32_t lock = int_lock_global(); - if (pending_sync_prompt_cnt > 0) - { - isPlayPendingPrompt = true; - promptIdToPlay = pendingSyncPromptId[pending_sync_prompt_out_index]; - pending_sync_prompt_out_index++; - if (PENDING_SYNC_PROMPT_BUFFER_CNT == pending_sync_prompt_out_index) - { - pending_sync_prompt_out_index = 0; - } - pending_sync_prompt_cnt--; + uint32_t lock = int_lock_global(); + if (pending_sync_prompt_cnt > 0) { + isPlayPendingPrompt = true; + promptIdToPlay = pendingSyncPromptId[pending_sync_prompt_out_index]; + pending_sync_prompt_out_index++; + if (PENDING_SYNC_PROMPT_BUFFER_CNT == pending_sync_prompt_out_index) { + pending_sync_prompt_out_index = 0; } - int_unlock_global(lock); + pending_sync_prompt_cnt--; + } + int_unlock_global(lock); - if (isPlayPendingPrompt) - { - TRACE_MEDIA_PLAYESTREAM_I("[POP_PENDING_PROMPT] 0x%x to play", promptIdToPlay); - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, - BT_STREAM_MEDIA, 0, promptIdToPlay); - } + if (isPlayPendingPrompt) { + TRACE_MEDIA_PLAYESTREAM_I("[POP_PENDING_PROMPT] 0x%x to play", + promptIdToPlay); + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, BT_STREAM_MEDIA, + 0, promptIdToPlay); + } } #endif -void trigger_media_play(AUD_ID_ENUM id, uint8_t device_id, uint16_t aud_pram) -{ - uint16_t convertedId = (uint8_t)id; - convertedId |= aud_pram; - app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START,BT_STREAM_MEDIA,device_id,convertedId); +void trigger_media_play(AUD_ID_ENUM id, uint8_t device_id, uint16_t aud_pram) { + uint16_t convertedId = (uint8_t)id; + convertedId |= aud_pram; + app_audio_manager_sendrequest(APP_BT_STREAM_MANAGER_START, BT_STREAM_MEDIA, + device_id, convertedId); } -void trigger_media_stop(AUD_ID_ENUM id, uint8_t device_id) -{ - /* Only the stop loop mode is supported */ - if (id == AUDIO_ID_FIND_MY_BUDS) - app_play_sbc_stop_proc_cnt = 1; +void trigger_media_stop(AUD_ID_ENUM id, uint8_t device_id) { + /* Only the stop loop mode is supported */ + if (id == AUDIO_ID_FIND_MY_BUDS) + app_play_sbc_stop_proc_cnt = 1; } -uint32_t media_playAudioSideSelect(AUD_ID_ENUM id,uint8_t device_id, uint16_t side_select) -{ - trigger_media_play(id, device_id, PROMOT_ID_BIT_MASK_MERGING|side_select); - return 0; +uint32_t media_playAudioSideSelect(AUD_ID_ENUM id, uint8_t device_id, + uint16_t side_select) { + trigger_media_play(id, device_id, PROMOT_ID_BIT_MASK_MERGING | side_select); + return 0; } - -uint32_t media_PlayAudio(AUD_ID_ENUM id,uint8_t device_id) -{ - trigger_media_play(id, device_id, PROMOT_ID_BIT_MASK_MERGING|PROMOT_ID_BIT_MASK_CHNLSEl_ALL); - return 0; +uint32_t media_PlayAudio(AUD_ID_ENUM id, uint8_t device_id) { + trigger_media_play(id, device_id, + PROMOT_ID_BIT_MASK_MERGING | + PROMOT_ID_BIT_MASK_CHNLSEl_ALL); + return 0; } -void media_PlayAudio_standalone(AUD_ID_ENUM id, uint8_t device_id) -{ - trigger_media_play(id, device_id, false); +void media_PlayAudio_standalone(AUD_ID_ENUM id, uint8_t device_id) { + trigger_media_play(id, device_id, false); } -void media_PlayAudio_locally(AUD_ID_ENUM id, uint8_t device_id) -{ - trigger_media_play(id, device_id, PROMOT_ID_BIT_MASK_MERGING|PROMOT_ID_BIT_MASK_CHNLSEl_ALL); +void media_PlayAudio_locally(AUD_ID_ENUM id, uint8_t device_id) { + trigger_media_play(id, device_id, + PROMOT_ID_BIT_MASK_MERGING | + PROMOT_ID_BIT_MASK_CHNLSEl_ALL); } -void media_PlayAudio_standalone_locally(AUD_ID_ENUM id, uint8_t device_id) -{ - trigger_media_play(id, device_id, PROMOT_ID_BIT_MASK_CHNLSEl_ALL); +void media_PlayAudio_standalone_locally(AUD_ID_ENUM id, uint8_t device_id) { + trigger_media_play(id, device_id, PROMOT_ID_BIT_MASK_CHNLSEl_ALL); } -void media_PlayAudio_remotely(AUD_ID_ENUM id, uint8_t device_id) -{ - trigger_media_play(id, device_id, PROMOT_ID_BIT_MASK_MERGING|PROMOT_ID_BIT_MASK_CHNLSEl_ALL); +void media_PlayAudio_remotely(AUD_ID_ENUM id, uint8_t device_id) { + trigger_media_play(id, device_id, + PROMOT_ID_BIT_MASK_MERGING | + PROMOT_ID_BIT_MASK_CHNLSEl_ALL); } -void media_PlayAudio_standalone_remotely(AUD_ID_ENUM id, uint8_t device_id) -{ - trigger_media_play(id, device_id, PROMOT_ID_BIT_MASK_CHNLSEl_ALL); +void media_PlayAudio_standalone_remotely(AUD_ID_ENUM id, uint8_t device_id) { + trigger_media_play(id, device_id, PROMOT_ID_BIT_MASK_CHNLSEl_ALL); } -AUD_ID_ENUM media_GetCurrentPrompt(uint8_t device_id) -{ - AUD_ID_ENUM currentPromptId = AUD_ID_INVALID; - if (app_bt_stream_isrun(APP_PLAY_BACK_AUDIO)) - { - currentPromptId = app_get_current_standalone_promptId(); - } +AUD_ID_ENUM media_GetCurrentPrompt(uint8_t device_id) { + AUD_ID_ENUM currentPromptId = AUD_ID_INVALID; + if (app_bt_stream_isrun(APP_PLAY_BACK_AUDIO)) { + currentPromptId = app_get_current_standalone_promptId(); + } #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - else if (audio_prompt_is_playing_ongoing()) - { - currentPromptId = (AUD_ID_ENUM)audio_prompt_get_prompt_id(); - } + else if (audio_prompt_is_playing_ongoing()) { + currentPromptId = (AUD_ID_ENUM)audio_prompt_get_prompt_id(); + } #endif - return currentPromptId; + return currentPromptId; } -#define IsDigit(c) (((c)>='0')&&((c)<='9')) -void media_Set_IncomingNumber(const char* pNumber) -{ - char *p_num = Media_player_number; - uint8_t cnt = 0; - for(uint8_t idx = 0; idx < MAX_PHB_NUMBER; idx++) { - if(*(pNumber + idx) == 0) - break; +#define IsDigit(c) (((c) >= '0') && ((c) <= '9')) +void media_Set_IncomingNumber(const char *pNumber) { + char *p_num = Media_player_number; + uint8_t cnt = 0; + for (uint8_t idx = 0; idx < MAX_PHB_NUMBER; idx++) { + if (*(pNumber + idx) == 0) + break; - if(IsDigit(*(pNumber + idx))) { - *(p_num + cnt) = *(pNumber + idx); - TRACE_MEDIA_PLAYESTREAM_I("[INCOMINGNUMBER] cnt %d ,p_num %d", cnt, *(p_num + cnt)); - cnt ++; - } + if (IsDigit(*(pNumber + idx))) { + *(p_num + cnt) = *(pNumber + idx); + TRACE_MEDIA_PLAYESTREAM_I("[INCOMINGNUMBER] cnt %d ,p_num %d", cnt, + *(p_num + cnt)); + cnt++; } + } } -PROMPT_MIX_PROPERTY_T* get_prompt_mix_property(uint16_t promptId) -{ - for (uint32_t index = 0; - index < ((uint32_t)(uintptr_t)__mixprompt_property_table_end - - (uint32_t)(uintptr_t)__mixprompt_property_table_start) / sizeof(PROMPT_MIX_PROPERTY_T); - index++) - { - if (PROMPT_MIX_PROPERTY_PTR_FROM_ENTRY_INDEX(index)->promptId == promptId) - { - return PROMPT_MIX_PROPERTY_PTR_FROM_ENTRY_INDEX(index); - } +PROMPT_MIX_PROPERTY_T *get_prompt_mix_property(uint16_t promptId) { + for (uint32_t index = 0; + index < ((uint32_t)(uintptr_t)__mixprompt_property_table_end - + (uint32_t)(uintptr_t)__mixprompt_property_table_start) / + sizeof(PROMPT_MIX_PROPERTY_T); + index++) { + if (PROMPT_MIX_PROPERTY_PTR_FROM_ENTRY_INDEX(index)->promptId == promptId) { + return PROMPT_MIX_PROPERTY_PTR_FROM_ENTRY_INDEX(index); } + } - return NULL; + return NULL; } /* Reference information for how to pass @@ -483,1034 +464,1131 @@ coeff_for_mix_music_for_music, coeff_for_mix_prompt_for_call, coeff_for_mix_call_for_call) */ -void media_runtime_audio_prompt_update(uint16_t id, uint8_t** ptr, uint32_t* len) -{ - switch (id) - { - case AUD_ID_POWER_ON: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)? (U8*)EN_SOUND_POWER_ON: (U8*)CN_POWER_ON; //aud_get_reouce((AUD_ID_ENUM)id, &g_app_audio_length, &type); - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)? EN_SOUND_POWER_ON_len: sizeof(CN_POWER_ON); - break; - case AUD_ID_POWER_OFF: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_POWER_OFF: (U8*)CN_POWER_OFF; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_POWER_OFF_len: sizeof(CN_POWER_OFF); - break; - case AUD_ID_BT_PAIR_ENABLE: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_PAIR_ENABLE: (U8*)CN_BT_PAIR_ENABLE; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_PAIR_ENABLE_len: sizeof(CN_BT_PAIR_ENABLE); - break; - case AUD_ID_BT_PAIRING: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)? (U8*)EN_SOUND_PAIRING: (U8*)CN_BT_PAIRING; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_PAIRING_len: sizeof(CN_BT_PAIRING); - break; - case AUD_ID_BT_PAIRING_SUC: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_PAIRING_SUCCESS: (U8*)CN_BT_PAIRING_SUCCESS; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_PAIRING_SUCCESS_len: sizeof(CN_BT_PAIRING_SUCCESS); - break; - case AUD_ID_BT_PAIRING_FAIL: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_PAIRING_FAIL: (U8*)CN_BT_PAIRING_FAIL; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_PAIRING_FAIL_len: sizeof(CN_BT_PAIRING_FAIL); - break; - case AUD_ID_BT_CALL_REFUSE: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_REFUSE: (U8*)CN_BT_REFUSE; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_REFUSE_len: sizeof(CN_BT_REFUSE); - break; - case AUD_ID_BT_CALL_OVER: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_OVER: (U8*)CN_BT_OVER; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_OVER_len: sizeof(CN_BT_OVER); - break; - case AUD_ID_BT_CALL_ANSWER: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_ANSWER: (U8*)CN_BT_ANSWER; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_ANSWER_len: sizeof(CN_BT_ANSWER); - break; - case AUD_ID_BT_CALL_HUNG_UP: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_HUNG_UP: (U8*)CN_BT_HUNG_UP; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_HUNG_UP_len: sizeof(CN_BT_HUNG_UP); - break; - case AUD_ID_BT_CALL_INCOMING_CALL: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_INCOMING_CALL: (U8*)CN_BT_INCOMING_CALL; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_INCOMING_CALL_len: sizeof(CN_BT_INCOMING_CALL); - break; - case AUD_ID_BT_CHARGE_PLEASE: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_CHARGE_PLEASE: (U8*)CN_CHARGE_PLEASE; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_CHARGE_PLEASE_len: sizeof(CN_CHARGE_PLEASE); - break; - case AUD_ID_BT_CHARGE_FINISH: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_CHARGE_FINISH: (U8*)CN_CHARGE_FINISH; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_CHARGE_FINISH_len: sizeof(CN_CHARGE_FINISH); - break; - case AUD_ID_BT_CONNECTED: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_CONNECTED: (U8*)CN_BT_CONNECTED; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_CONNECTED_len: sizeof(CN_BT_CONNECTED); - break; - case AUD_ID_BT_DIS_CONNECT: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_DIS_CONNECT: (U8*)CN_BT_DIS_CONNECT; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_DIS_CONNECT_len: sizeof(CN_BT_DIS_CONNECT); - break; - case AUD_ID_BT_WARNING: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_WARNING: (U8*)CN_BT_WARNING; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_WARNING_len: sizeof(CN_BT_WARNING); - break; - case AUDIO_ID_BT_ALEXA_START: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_ALEXA_START: (U8*)CN_BT_ALEXA_START; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_ALEXA_START_len: sizeof(CN_BT_ALEXA_START); - break; - case AUDIO_ID_BT_ALEXA_STOP: - case AUDIO_ID_FIND_MY_BUDS: - case AUDIO_ID_FIND_TILE: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_ALEXA_STOP: (U8*)CN_BT_ALEXA_STOP; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_ALEXA_STOP_len: sizeof(CN_BT_ALEXA_STOP); - break; - case AUDIO_ID_BT_GSOUND_MIC_OPEN: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_GSOUND_MIC_OPEN: (U8*)CN_BT_GSOUND_MIC_OPEN; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_GSOUND_MIC_OPEN_len: sizeof(CN_BT_GSOUND_MIC_OPEN); - break; - case AUDIO_ID_BT_GSOUND_MIC_CLOSE: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_GSOUND_MIC_CLOSE: (U8*)CN_BT_GSOUND_MIC_CLOSE; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_GSOUND_MIC_CLOSE_len: sizeof(CN_BT_GSOUND_MIC_CLOSE); - break; - case AUDIO_ID_BT_GSOUND_NC: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_GSOUND_NC: (U8*)CN_BT_GSOUND_NC; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_GSOUND_NC_len: sizeof(CN_BT_GSOUND_NC); - break; - case AUD_ID_LANGUAGE_SWITCH: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_LANGUAGE_SWITCH: (U8*)CN_LANGUAGE_SWITCH; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_LANGUAGE_SWITCH_len: sizeof(CN_LANGUAGE_SWITCH); - break; - case AUDIO_ID_BT_MUTE: - g_app_audio_data = (U8*)BT_MUTE; - g_app_audio_length = sizeof(BT_MUTE); - break; - case AUD_ID_NUM_0: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)? (U8*)EN_SOUND_ZERO: (U8*)CN_SOUND_ZERO; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)? EN_SOUND_ZERO_len: sizeof(CN_SOUND_ZERO); - break; - case AUD_ID_NUM_1: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)? (U8*)EN_SOUND_ONE: (U8*)CN_SOUND_ONE; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)? EN_SOUND_ONE_len: sizeof(CN_SOUND_ONE); - break; - case AUD_ID_NUM_2: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)? (U8*)EN_SOUND_TWO: (U8*)CN_SOUND_TWO; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)? EN_SOUND_TWO_len: sizeof(CN_SOUND_TWO); - break; - case AUD_ID_NUM_3: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)? (U8*)EN_SOUND_THREE: (U8*)CN_SOUND_THREE; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)? EN_SOUND_THREE_len: sizeof(CN_SOUND_THREE); - break; - case AUD_ID_NUM_4: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)? (U8*)EN_SOUND_FOUR: (U8*)CN_SOUND_FOUR; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)? EN_SOUND_FOUR_len: sizeof(CN_SOUND_FOUR); - break; - case AUD_ID_NUM_5: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)? (U8*)EN_SOUND_FIVE: (U8*)CN_SOUND_FIVE; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)? EN_SOUND_FIVE_len: sizeof(CN_SOUND_FIVE); - break; - case AUD_ID_NUM_6: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)? (U8*)EN_SOUND_SIX: (U8*)CN_SOUND_SIX; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)? EN_SOUND_SIX_len: sizeof(CN_SOUND_SIX); - break; - case AUD_ID_NUM_7: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)? (U8*)EN_SOUND_SEVEN: (U8*)CN_SOUND_SEVEN; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)? EN_SOUND_SEVEN_len: sizeof(CN_SOUND_SEVEN); - break; - case AUD_ID_NUM_8: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)? (U8*)EN_SOUND_EIGHT: (U8*)CN_SOUND_EIGHT; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)? EN_SOUND_EIGHT_len: sizeof(CN_SOUND_EIGHT); - break; - case AUD_ID_NUM_9: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)? (U8*)EN_SOUND_NINE: (U8*)CN_SOUND_NINE; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)? EN_SOUND_NINE_len: sizeof(CN_SOUND_NINE); - break; +void media_runtime_audio_prompt_update(uint16_t id, uint8_t **ptr, + uint32_t *len) { + switch (id) { + case AUD_ID_POWER_ON: + g_app_audio_data = + (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_POWER_ON + : (U8 *)CN_POWER_ON; // aud_get_reouce((AUD_ID_ENUM)id, + // &g_app_audio_length, &type); + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_POWER_ON_len + : sizeof(CN_POWER_ON); + break; + case AUD_ID_POWER_OFF: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_POWER_OFF + : (U8 *)CN_POWER_OFF; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_POWER_OFF_len + : sizeof(CN_POWER_OFF); + break; + case AUD_ID_BT_PAIR_ENABLE: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_PAIR_ENABLE + : (U8 *)CN_BT_PAIR_ENABLE; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_PAIR_ENABLE_len + : sizeof(CN_BT_PAIR_ENABLE); + break; + case AUD_ID_BT_PAIRING: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_PAIRING + : (U8 *)CN_BT_PAIRING; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_PAIRING_len + : sizeof(CN_BT_PAIRING); + break; + case AUD_ID_BT_PAIRING_SUC: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_PAIRING_SUCCESS + : (U8 *)CN_BT_PAIRING_SUCCESS; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_PAIRING_SUCCESS_len + : sizeof(CN_BT_PAIRING_SUCCESS); + break; + case AUD_ID_BT_PAIRING_FAIL: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_PAIRING_FAIL + : (U8 *)CN_BT_PAIRING_FAIL; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_PAIRING_FAIL_len + : sizeof(CN_BT_PAIRING_FAIL); + break; + case AUD_ID_BT_CALL_REFUSE: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_REFUSE + : (U8 *)CN_BT_REFUSE; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_REFUSE_len + : sizeof(CN_BT_REFUSE); + break; + case AUD_ID_BT_CALL_OVER: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_OVER + : (U8 *)CN_BT_OVER; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_OVER_len + : sizeof(CN_BT_OVER); + break; + case AUD_ID_BT_CALL_ANSWER: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_ANSWER + : (U8 *)CN_BT_ANSWER; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_ANSWER_len + : sizeof(CN_BT_ANSWER); + break; + case AUD_ID_BT_CALL_HUNG_UP: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_HUNG_UP + : (U8 *)CN_BT_HUNG_UP; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_HUNG_UP_len + : sizeof(CN_BT_HUNG_UP); + break; + case AUD_ID_BT_CALL_INCOMING_CALL: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_INCOMING_CALL + : (U8 *)CN_BT_INCOMING_CALL; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_INCOMING_CALL_len + : sizeof(CN_BT_INCOMING_CALL); + break; + case AUD_ID_BT_CHARGE_PLEASE: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_CHARGE_PLEASE + : (U8 *)CN_CHARGE_PLEASE; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_CHARGE_PLEASE_len + : sizeof(CN_CHARGE_PLEASE); + break; + case AUD_ID_BT_CHARGE_FINISH: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_CHARGE_FINISH + : (U8 *)CN_CHARGE_FINISH; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_CHARGE_FINISH_len + : sizeof(CN_CHARGE_FINISH); + break; + case AUD_ID_BT_CONNECTED: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_CONNECTED + : (U8 *)CN_BT_CONNECTED; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_CONNECTED_len + : sizeof(CN_BT_CONNECTED); + break; + case AUD_ID_BT_DIS_CONNECT: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_DIS_CONNECT + : (U8 *)CN_BT_DIS_CONNECT; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_DIS_CONNECT_len + : sizeof(CN_BT_DIS_CONNECT); + break; + case AUD_ID_BT_WARNING: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_WARNING + : (U8 *)CN_BT_WARNING; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_WARNING_len + : sizeof(CN_BT_WARNING); + break; + case AUDIO_ID_BT_ALEXA_START: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_ALEXA_START + : (U8 *)CN_BT_ALEXA_START; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_ALEXA_START_len + : sizeof(CN_BT_ALEXA_START); + break; + case AUDIO_ID_BT_ALEXA_STOP: + case AUDIO_ID_FIND_MY_BUDS: + case AUDIO_ID_FIND_TILE: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_ALEXA_STOP + : (U8 *)CN_BT_ALEXA_STOP; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_ALEXA_STOP_len + : sizeof(CN_BT_ALEXA_STOP); + break; + case AUDIO_ID_BT_GSOUND_MIC_OPEN: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_GSOUND_MIC_OPEN + : (U8 *)CN_BT_GSOUND_MIC_OPEN; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_GSOUND_MIC_OPEN_len + : sizeof(CN_BT_GSOUND_MIC_OPEN); + break; + case AUDIO_ID_BT_GSOUND_MIC_CLOSE: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_GSOUND_MIC_CLOSE + : (U8 *)CN_BT_GSOUND_MIC_CLOSE; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_GSOUND_MIC_CLOSE_len + : sizeof(CN_BT_GSOUND_MIC_CLOSE); + break; + case AUDIO_ID_BT_GSOUND_NC: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_GSOUND_NC + : (U8 *)CN_BT_GSOUND_NC; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_GSOUND_NC_len + : sizeof(CN_BT_GSOUND_NC); + break; + case AUD_ID_LANGUAGE_SWITCH: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_LANGUAGE_SWITCH + : (U8 *)CN_LANGUAGE_SWITCH; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_LANGUAGE_SWITCH_len + : sizeof(CN_LANGUAGE_SWITCH); + break; + case AUDIO_ID_BT_MUTE: + g_app_audio_data = (U8 *)BT_MUTE; + g_app_audio_length = sizeof(BT_MUTE); + break; + case AUD_ID_NUM_0: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_ZERO + : (U8 *)CN_SOUND_ZERO; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_ZERO_len + : sizeof(CN_SOUND_ZERO); + break; + case AUD_ID_NUM_1: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_ONE + : (U8 *)CN_SOUND_ONE; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_ONE_len + : sizeof(CN_SOUND_ONE); + break; + case AUD_ID_NUM_2: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_TWO + : (U8 *)CN_SOUND_TWO; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_TWO_len + : sizeof(CN_SOUND_TWO); + break; + case AUD_ID_NUM_3: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_THREE + : (U8 *)CN_SOUND_THREE; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_THREE_len + : sizeof(CN_SOUND_THREE); + break; + case AUD_ID_NUM_4: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_FOUR + : (U8 *)CN_SOUND_FOUR; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_FOUR_len + : sizeof(CN_SOUND_FOUR); + break; + case AUD_ID_NUM_5: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_FIVE + : (U8 *)CN_SOUND_FIVE; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_FIVE_len + : sizeof(CN_SOUND_FIVE); + break; + case AUD_ID_NUM_6: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_SIX + : (U8 *)CN_SOUND_SIX; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_SIX_len + : sizeof(CN_SOUND_SIX); + break; + case AUD_ID_NUM_7: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_SEVEN + : (U8 *)CN_SOUND_SEVEN; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_SEVEN_len + : sizeof(CN_SOUND_SEVEN); + break; + case AUD_ID_NUM_8: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_EIGHT + : (U8 *)CN_SOUND_EIGHT; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_EIGHT_len + : sizeof(CN_SOUND_EIGHT); + break; + case AUD_ID_NUM_9: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_NINE + : (U8 *)CN_SOUND_NINE; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_NINE_len + : sizeof(CN_SOUND_NINE); + break; #ifdef __BT_WARNING_TONE_MERGE_INTO_STREAM_SBC__ - case AUD_ID_RING_WARNING: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)? (U8*)RES_AUD_RING_SAMPRATE_16000: (U8*)RES_AUD_RING_SAMPRATE_16000; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)? sizeof(RES_AUD_RING_SAMPRATE_16000): sizeof(RES_AUD_RING_SAMPRATE_16000); - break; + case AUD_ID_RING_WARNING: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)RES_AUD_RING_SAMPRATE_16000 + : (U8 *)RES_AUD_RING_SAMPRATE_16000; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? sizeof(RES_AUD_RING_SAMPRATE_16000) + : sizeof(RES_AUD_RING_SAMPRATE_16000); + break; #endif #ifdef __INTERACTION__ - case AUD_ID_BT_FINDME: - g_app_audio_data = (g_language==MEDIA_DEFAULT_LANGUAGE)?(U8*)EN_SOUND_FINDME: (U8*)CN_BT_FINDME; - g_app_audio_length = (g_language==MEDIA_DEFAULT_LANGUAGE)?EN_SOUND_FINDME_len: sizeof(CN_BT_FINDME); - break; + case AUD_ID_BT_FINDME: + g_app_audio_data = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? (U8 *)EN_SOUND_FINDME + : (U8 *)CN_BT_FINDME; + g_app_audio_length = (g_language == MEDIA_DEFAULT_LANGUAGE) + ? EN_SOUND_FINDME_len + : sizeof(CN_BT_FINDME); + break; #endif - case AUDIO_ID_BT_DUDU: - g_app_audio_data = (U8*)EN_DUDU; - g_app_audio_length = EN_DUDU_len; - break; - case AUDIO_ID_BT_DU: - g_app_audio_data = (U8*)EN_DUDU; - g_app_audio_length = EN_DUDU_len; - break; - default: - g_app_audio_length = 0; - break; - } + case AUDIO_ID_BT_DUDU: + g_app_audio_data = (U8 *)EN_DUDU; + g_app_audio_length = EN_DUDU_len; + break; + case AUDIO_ID_BT_DU: + g_app_audio_data = (U8 *)EN_DUDU; + g_app_audio_length = EN_DUDU_len; + break; + default: + g_app_audio_length = 0; + break; + } - *ptr = g_app_audio_data; - *len = g_app_audio_length; + *ptr = g_app_audio_data; + *len = g_app_audio_length; } -void media_Play_init_audio(uint16_t aud_id) -{ +void media_Play_init_audio(uint16_t aud_id) { - if (aud_id == AUD_ID_BT_CALL_INCOMING_NUMBER) - { - g_play_continue_mark = 1; + if (aud_id == AUD_ID_BT_CALL_INCOMING_NUMBER) { + g_play_continue_mark = 1; - if (g_language == MEDIA_DEFAULT_LANGUAGE) - media_sound_map = media_sound_map_en; - else - media_sound_map = media_sound_map_cn; + if (g_language == MEDIA_DEFAULT_LANGUAGE) + media_sound_map = media_sound_map_en; + else + media_sound_map = media_sound_map_cn; - memset(&pCont_context, 0x0, sizeof(pCont_context)); - - pCont_context.g_play_continue_total = strlen((const char*)Media_player_number); + memset(&pCont_context, 0x0, sizeof(pCont_context)); - for (uint32_t i=0;( i 0; i--){ - *(buf+j) = *(buf+j)*i/len; - j++; + TRACE_MEDIA_PLAYESTREAM_I("[INIT_AUDIO] array[%d] = %d, total =%d", i, + pCont_context.g_play_continue_array[i], + pCont_context.g_play_continue_total); } + } else { + g_app_audio_read = 0; + g_play_continue_mark = 0; - return len; + media_runtime_audio_prompt_update(aud_id, &g_app_audio_data, + &g_app_audio_length); + } +} +uint32_t app_play_sbc_more_data_fadeout(int16_t *buf, uint32_t len) { + uint32_t i; + uint32_t j = 0; + + for (i = len; i > 0; i--) { + *(buf + j) = *(buf + j) * i / len; + j++; + } + + return len; } static uint32_t need_fadein_len = 0; static uint32_t need_fadein_len_processed = 0; -int app_play_sbc_more_data_fadein_config(uint32_t len) -{ - TRACE_MEDIA_PLAYESTREAM_I("[FADEIN] config l:%d", len); - need_fadein_len = len; - need_fadein_len_processed = 0; - return 0; +int app_play_sbc_more_data_fadein_config(uint32_t len) { + TRACE_MEDIA_PLAYESTREAM_I("[FADEIN] config l:%d", len); + need_fadein_len = len; + need_fadein_len_processed = 0; + return 0; } -uint32_t app_play_sbc_more_data_fadein(int16_t *buf, uint32_t len) -{ - uint32_t i; - uint32_t j = 0; - uint32_t base; - uint32_t dest; +uint32_t app_play_sbc_more_data_fadein(int16_t *buf, uint32_t len) { + uint32_t i; + uint32_t j = 0; + uint32_t base; + uint32_t dest; - base = need_fadein_len_processed; - dest = need_fadein_len_processed + len < need_fadein_len ? - need_fadein_len_processed + len : - need_fadein_len_processed; + base = need_fadein_len_processed; + dest = need_fadein_len_processed + len < need_fadein_len + ? need_fadein_len_processed + len + : need_fadein_len_processed; - if (base >= dest){ -// TRACE_MEDIA_PLAYESTREAM_I("skip fadein"); - return len; - } -// TRACE_MEDIA_PLAYESTREAM_I("fadein l:%d base:%d dest:%d", len, base, dest); -// DUMP16("%5d ", buf, 20); -// DUMP16("%5d ", buf+len-19, 20); - - for (i = base; i < dest; i++){ - *(buf+j) = *(buf+j)*i/need_fadein_len; - j++; - } - - need_fadein_len_processed += j; -// DUMP16("%05d ", buf, 20); -// DUMP16("%5d ", buf+len-19, 20); + if (base >= dest) { + // TRACE_MEDIA_PLAYESTREAM_I("skip fadein"); return len; + } + // TRACE_MEDIA_PLAYESTREAM_I("fadein l:%d base:%d dest:%d", len, base, + // dest); DUMP16("%5d ", buf, 20); DUMP16("%5d ", buf+len-19, 20); + + for (i = base; i < dest; i++) { + *(buf + j) = *(buf + j) * i / need_fadein_len; + j++; + } + + need_fadein_len_processed += j; + // DUMP16("%05d ", buf, 20); + // DUMP16("%5d ", buf+len-19, 20); + return len; } -uint32_t app_play_single_sbc_more_data(uint8_t *buf, uint32_t len) -{ - //int32_t stime, etime; - //U16 byte_decode; - uint32_t l = 0; +uint32_t app_play_single_sbc_more_data(uint8_t *buf, uint32_t len) { + // int32_t stime, etime; + // U16 byte_decode; + uint32_t l = 0; - //TRACE_MEDIA_PLAYESTREAM_I("app_play_sbc_more_data : %d, %d", g_app_audio_read, g_app_audio_length); + // TRACE_MEDIA_PLAYESTREAM_I("app_play_sbc_more_data : %d, %d", + // g_app_audio_read, g_app_audio_length); - if (g_app_audio_read < g_app_audio_length){ - unsigned int available_len = 0; - unsigned int store_len = 0; - - available_len = AvailableOfCQueue(&media_sbc_queue); - store_len = (g_app_audio_length - g_app_audio_read) > available_len ? available_len :(g_app_audio_length - g_app_audio_read); - store_sbc_buffer((unsigned char *)(g_app_audio_data + g_app_audio_read), store_len); - g_app_audio_read += store_len; - } - - - l = decode_sbc_frame(buf, len); - - if (l != len) - { - g_app_audio_read = g_app_audio_length; - //af_stream_stop(AUD_STREAM_PLAYBACK); - //af_stream_close(AUD_STREAM_PLAYBACK); - TRACE_MEDIA_PLAYESTREAM_I("[SINGLE_SBC_MORE_DATA][END] length:%d len:%d l:%d", g_app_audio_length, len, l); - } - - return l; -} - - -/* play continue sound */ -uint32_t app_play_continue_sbc_more_data(uint8_t *buf, uint32_t len) -{ - - uint32_t l, n, fsize = 0; - - U8* pdata =NULL; - -// store data + if (g_app_audio_read < g_app_audio_length) { unsigned int available_len = 0; unsigned int store_len = 0; - if (pCont_context.g_play_continue_n < pCont_context.g_play_continue_total){ - do { - n = pCont_context.g_play_continue_n; - pdata = media_sound_map[pCont_context.g_play_continue_array[n]].data; - fsize = media_sound_map[pCont_context.g_play_continue_array[n]].fsize; + available_len = AvailableOfCQueue(&media_sbc_queue); + store_len = (g_app_audio_length - g_app_audio_read) > available_len + ? available_len + : (g_app_audio_length - g_app_audio_read); + store_sbc_buffer((unsigned char *)(g_app_audio_data + g_app_audio_read), + store_len); + g_app_audio_read += store_len; + } - available_len = AvailableOfCQueue(&media_sbc_queue); - if (!available_len) - break; + l = decode_sbc_frame(buf, len); - store_len = (fsize - pCont_context.g_play_continue_fread) > available_len ? available_len :(fsize - pCont_context.g_play_continue_fread); - store_sbc_buffer((unsigned char *)(pdata + pCont_context.g_play_continue_fread), store_len); - pCont_context.g_play_continue_fread += store_len; - if (pCont_context.g_play_continue_fread == fsize){ - pCont_context.g_play_continue_n++; - pCont_context.g_play_continue_fread = 0; - } - }while(pCont_context.g_play_continue_n < pCont_context.g_play_continue_total); - } + if (l != len) { + g_app_audio_read = g_app_audio_length; + // af_stream_stop(AUD_STREAM_PLAYBACK); + // af_stream_close(AUD_STREAM_PLAYBACK); + TRACE_MEDIA_PLAYESTREAM_I( + "[SINGLE_SBC_MORE_DATA][END] length:%d len:%d l:%d", g_app_audio_length, + len, l); + } - l = decode_sbc_frame(buf, len); - - if (l !=len){ - TRACE_MEDIA_PLAYESTREAM_I("[CONTINUE_SBC_MORE_DATA][END]"); - } - - return l; + return l; } -uint32_t app_play_sbc_channel_select(int16_t *dst_buf, int16_t *src_buf, uint32_t src_len) -{ +/* play continue sound */ +uint32_t app_play_continue_sbc_more_data(uint8_t *buf, uint32_t len) { + + uint32_t l, n, fsize = 0; + + U8 *pdata = NULL; + + // store data + unsigned int available_len = 0; + unsigned int store_len = 0; + + if (pCont_context.g_play_continue_n < pCont_context.g_play_continue_total) { + do { + n = pCont_context.g_play_continue_n; + pdata = media_sound_map[pCont_context.g_play_continue_array[n]].data; + fsize = media_sound_map[pCont_context.g_play_continue_array[n]].fsize; + + available_len = AvailableOfCQueue(&media_sbc_queue); + if (!available_len) + break; + + store_len = (fsize - pCont_context.g_play_continue_fread) > available_len + ? available_len + : (fsize - pCont_context.g_play_continue_fread); + store_sbc_buffer( + (unsigned char *)(pdata + pCont_context.g_play_continue_fread), + store_len); + pCont_context.g_play_continue_fread += store_len; + if (pCont_context.g_play_continue_fread == fsize) { + pCont_context.g_play_continue_n++; + pCont_context.g_play_continue_fread = 0; + } + } while (pCont_context.g_play_continue_n < + pCont_context.g_play_continue_total); + } + + l = decode_sbc_frame(buf, len); + + if (l != len) { + TRACE_MEDIA_PLAYESTREAM_I("[CONTINUE_SBC_MORE_DATA][END]"); + } + + return l; +} + +uint32_t app_play_sbc_channel_select(int16_t *dst_buf, int16_t *src_buf, + uint32_t src_len) { #if defined(IBRT) - if (IS_PROMPT_CHNLSEl_ALL(g_prompt_chnlsel) || app_ibrt_voice_report_is_me(PROMPT_CHNLSEl_FROM_ID_VALUE(g_prompt_chnlsel))) - { - // Copy from tail so that it works even if dst_buf == src_buf - for (int i = (int)(src_len - 1); i >= 0; i--) - { - dst_buf[i*2 + 0] = dst_buf[i*2 + 1] = src_buf[i]; - } + if (IS_PROMPT_CHNLSEl_ALL(g_prompt_chnlsel) || + app_ibrt_voice_report_is_me( + PROMPT_CHNLSEl_FROM_ID_VALUE(g_prompt_chnlsel))) { + // Copy from tail so that it works even if dst_buf == src_buf + for (int i = (int)(src_len - 1); i >= 0; i--) { + dst_buf[i * 2 + 0] = dst_buf[i * 2 + 1] = src_buf[i]; } - else - { - // Copy from tail so that it works even if dst_buf == src_buf - for (int i = (int)(src_len - 1); i >= 0; i--) - { - dst_buf[i*2 + 0] = dst_buf[i*2 + 1] = 0; - } + } else { + // Copy from tail so that it works even if dst_buf == src_buf + for (int i = (int)(src_len - 1); i >= 0; i--) { + dst_buf[i * 2 + 0] = dst_buf[i * 2 + 1] = 0; } + } #else - if (IS_PROMPT_CHNLSEl_ALL(g_prompt_chnlsel)) - { - // Copy from tail so that it works even if dst_buf == src_buf - for (int i = (int)(src_len - 1); i >= 0; i--) - { - dst_buf[i*2 + 0] = dst_buf[i*2 + 1] = src_buf[i]; - } + if (IS_PROMPT_CHNLSEl_ALL(g_prompt_chnlsel)) { + // Copy from tail so that it works even if dst_buf == src_buf + for (int i = (int)(src_len - 1); i >= 0; i--) { + dst_buf[i * 2 + 0] = dst_buf[i * 2 + 1] = src_buf[i]; } - else if (IS_PROMPT_CHNLSEl_LCHNL(g_prompt_chnlsel)) - { - // Copy from tail so that it works even if dst_buf == src_buf - for (int i = (int)(src_len - 1); i >= 0; i--) - { - dst_buf[i*2 + 0] = src_buf[i]; - dst_buf[i*2 + 1] = 0; - } + } else if (IS_PROMPT_CHNLSEl_LCHNL(g_prompt_chnlsel)) { + // Copy from tail so that it works even if dst_buf == src_buf + for (int i = (int)(src_len - 1); i >= 0; i--) { + dst_buf[i * 2 + 0] = src_buf[i]; + dst_buf[i * 2 + 1] = 0; } - else if (IS_PROMPT_CHNLSEl_RCHNL(g_prompt_chnlsel)) - { - // Copy from tail so that it works even if dst_buf == src_buf - for (int i = (int)(src_len - 1); i >= 0; i--) - { - dst_buf[i*2 + 0] = 0; - dst_buf[i*2 + 1] = src_buf[i]; - } + } else if (IS_PROMPT_CHNLSEl_RCHNL(g_prompt_chnlsel)) { + // Copy from tail so that it works even if dst_buf == src_buf + for (int i = (int)(src_len - 1); i >= 0; i--) { + dst_buf[i * 2 + 0] = 0; + dst_buf[i * 2 + 1] = src_buf[i]; } - else - { - // Copy from tail so that it works even if dst_buf == src_buf - for (int i = (int)(src_len - 1); i >= 0; i--) - { - dst_buf[i*2 + 0] = dst_buf[i*2 + 1] = 0; - } + } else { + // Copy from tail so that it works even if dst_buf == src_buf + for (int i = (int)(src_len - 1); i >= 0; i--) { + dst_buf[i * 2 + 0] = dst_buf[i * 2 + 1] = 0; } + } #endif - return 0; + return 0; } #ifdef __BT_ANC__ -extern uint8_t bt_sco_samplerate_ratio ; -extern void us_fir_init (void); -extern U32 us_fir_run (short* src_buf, short* dst_buf, U32 in_samp_num); +extern uint8_t bt_sco_samplerate_ratio; +extern void us_fir_init(void); +extern U32 us_fir_run(short *src_buf, short *dst_buf, U32 in_samp_num); #endif uint32_t g_cache_buff_sz = 0; static int16_t *app_play_sbc_cache = NULL; -uint32_t app_play_sbc_more_data(uint8_t *buf, uint32_t len) -{ +uint32_t app_play_sbc_more_data(uint8_t *buf, uint32_t len) { #if defined(IBRT) - app_ibrt_voice_report_trigger_checker(); + app_ibrt_voice_report_trigger_checker(); #endif #ifdef VOICE_DATAPATH - if (app_voicepath_get_stream_pending_state(VOICEPATH_STREAMING)) - { - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - #ifdef MIX_MIC_DURING_MUSIC - app_voicepath_enable_hw_sidetone(0, HW_SIDE_TONE_MAX_ATTENUATION_COEF); - #endif - app_voicepath_set_stream_state(VOICEPATH_STREAMING, true); - app_voicepath_set_pending_started_stream(VOICEPATH_STREAMING, false); - } + if (app_voicepath_get_stream_pending_state(VOICEPATH_STREAMING)) { + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); +#ifdef MIX_MIC_DURING_MUSIC + app_voicepath_enable_hw_sidetone(0, HW_SIDE_TONE_MAX_ATTENUATION_COEF); #endif - uint32_t l = 0; + app_voicepath_set_stream_state(VOICEPATH_STREAMING, true); + app_voicepath_set_pending_started_stream(VOICEPATH_STREAMING, false); + } +#endif + uint32_t l = 0; - memset(buf, 0, len); + memset(buf, 0, len); #if defined(MEDIA_PLAY_24BIT) - len /= 2; + len /= 2; #endif #ifdef __BT_ANC__ - uint32_t dec_len = len/bt_sco_samplerate_ratio; + uint32_t dec_len = len / bt_sco_samplerate_ratio; #endif - if(app_play_sbc_cache) - memset(app_play_sbc_cache, 0, g_cache_buff_sz); + if (app_play_sbc_cache) + memset(app_play_sbc_cache, 0, g_cache_buff_sz); - if (app_play_sbc_stop_proc_cnt) { - if (app_play_sbc_stop_proc_cnt == 1) { - app_play_sbc_stop_proc_cnt = 2; - } else if (app_play_sbc_stop_proc_cnt == 2) { - app_play_sbc_stop_proc_cnt = 3; + if (app_play_sbc_stop_proc_cnt) { + if (app_play_sbc_stop_proc_cnt == 1) { + app_play_sbc_stop_proc_cnt = 2; + } else if (app_play_sbc_stop_proc_cnt == 2) { + app_play_sbc_stop_proc_cnt = 3; - // For 8K sample rate data, it takes about 4ms (or 12ms if h/w resample in use) from codec to DAC PA. - // The playback stream should be stopped after the last data arrives at DAC PA, otherwise there - // might be some pop sound. - app_play_audio_stop(); - } - } else { - if (app_play_sbc_cache) { + // For 8K sample rate data, it takes about 4ms (or 12ms if h/w resample in + // use) from codec to DAC PA. The playback stream should be stopped after + // the last data arrives at DAC PA, otherwise there might be some pop + // sound. + app_play_audio_stop(); + } + } else { + if (app_play_sbc_cache) { #ifdef __BT_ANC__ - len = dec_len; + len = dec_len; #endif - if (g_play_continue_mark) { - l = app_play_continue_sbc_more_data((uint8_t *)app_play_sbc_cache, len/2); - } else { - l = app_play_single_sbc_more_data((uint8_t *)app_play_sbc_cache, len/2); - } - if (l != len / 2) { + if (g_play_continue_mark) { + l = app_play_continue_sbc_more_data((uint8_t *)app_play_sbc_cache, + len / 2); + } else { + l = app_play_single_sbc_more_data((uint8_t *)app_play_sbc_cache, + len / 2); + } + if (l != len / 2) { #ifdef __BT_ANC__ - len = dec_len*3; + len = dec_len * 3; #endif - memset(app_play_sbc_cache+l, 0, len/2-l); - app_play_sbc_stop_proc_cnt = 1; - } + memset(app_play_sbc_cache + l, 0, len / 2 - l); + app_play_sbc_stop_proc_cnt = 1; + } #ifdef __BT_ANC__ - len = dec_len*3; - l = l*3; - us_fir_run((short*)app_play_sbc_cache, (short*)buf, dec_len/2/2); - app_play_sbc_channel_select((int16_t*)buf, (int16_t*)buf, len/2/2); + len = dec_len * 3; + l = l * 3; + us_fir_run((short *)app_play_sbc_cache, (short *)buf, dec_len / 2 / 2); + app_play_sbc_channel_select((int16_t *)buf, (int16_t *)buf, len / 2 / 2); #else - app_play_sbc_channel_select((int16_t *)buf, app_play_sbc_cache, len/2/2); + app_play_sbc_channel_select((int16_t *)buf, app_play_sbc_cache, + len / 2 / 2); #endif #if defined(MEDIA_PLAY_24BIT) - int32_t *buf32 = (int32_t *)buf; - int16_t *buf16 = (int16_t *)buf; + int32_t *buf32 = (int32_t *)buf; + int16_t *buf16 = (int16_t *)buf; - for (int16_t i = len/2 - 1; i >= 0; i--) { - buf32[i] = ((int32_t)buf16[i] << 8); - } - len *= 2; + for (int16_t i = len / 2 - 1; i >= 0; i--) { + buf32[i] = ((int32_t)buf16[i] << 8); + } + len *= 2; #endif - } else { + } else { #if defined(MEDIA_PLAY_24BIT) - len *= 2; + len *= 2; #endif - memset(buf, 0, len); - } + memset(buf, 0, len); } + } - return l; + return l; } #ifdef AUDIO_LINEIN static uint8_t app_play_lineinmode_merge = 0; static uint8_t app_play_lineinmode_mode = 0; -inline static void app_play_audio_lineinmode_mono_merge(int16_t *aud_buf_mono, int16_t *ring_buf_mono, uint32_t aud_buf_len) -{ - uint32_t i = 0; - for (i = 0; i < aud_buf_len; i++) { - aud_buf_mono[i] = (aud_buf_mono[i]>>1) + (ring_buf_mono[i]>>1); +inline static void app_play_audio_lineinmode_mono_merge(int16_t *aud_buf_mono, + int16_t *ring_buf_mono, + uint32_t aud_buf_len) { + uint32_t i = 0; + for (i = 0; i < aud_buf_len; i++) { + aud_buf_mono[i] = (aud_buf_mono[i] >> 1) + (ring_buf_mono[i] >> 1); + } +} + +inline static void app_play_audio_lineinmode_stereo_merge( + int16_t *aud_buf_stereo, int16_t *ring_buf_mono, uint32_t aud_buf_len) { + uint32_t aud_buf_stereo_offset = 0; + uint32_t ring_buf_mono_offset = 0; + for (aud_buf_stereo_offset = 0; aud_buf_stereo_offset < aud_buf_len;) { + aud_buf_stereo[aud_buf_stereo_offset] = + aud_buf_stereo[aud_buf_stereo_offset] + + (ring_buf_mono[ring_buf_mono_offset] >> 1); + aud_buf_stereo_offset++; + aud_buf_stereo[aud_buf_stereo_offset] = + aud_buf_stereo[aud_buf_stereo_offset] + + (ring_buf_mono[ring_buf_mono_offset] >> 1); + aud_buf_stereo_offset++; + ring_buf_mono_offset++; + } +} + +uint32_t app_play_audio_lineinmode_more_data(uint8_t *buf, uint32_t len) { + uint32_t l = 0; + if (app_play_lineinmode_merge && app_play_sbc_cache) { + TRACE(1, "line in mode:%d ", len); + if (app_play_lineinmode_mode == 1) { + if (g_play_continue_mark) { + l = app_play_continue_sbc_more_data((uint8_t *)app_play_sbc_cache, len); + } else { + l = app_play_single_sbc_more_data((uint8_t *)app_play_sbc_cache, len); + } + if (l != len) { + memset(app_play_sbc_cache + l, 0, len - l); + app_play_lineinmode_merge = 0; + } + app_play_audio_lineinmode_mono_merge( + (int16_t *)buf, (int16_t *)app_play_sbc_cache, len / 2); + } else if (app_play_lineinmode_mode == 2) { + if (g_play_continue_mark) { + l = app_play_continue_sbc_more_data((uint8_t *)app_play_sbc_cache, + len / 2); + } else { + l = app_play_single_sbc_more_data((uint8_t *)app_play_sbc_cache, + len / 2); + } + if (l != len / 2) { + memset(app_play_sbc_cache + l, 0, len / 2 - l); + app_play_lineinmode_merge = 0; + } + app_play_audio_lineinmode_stereo_merge( + (int16_t *)buf, (int16_t *)app_play_sbc_cache, len / 2); } + } + + return l; } -inline static void app_play_audio_lineinmode_stereo_merge(int16_t *aud_buf_stereo, int16_t *ring_buf_mono, uint32_t aud_buf_len) -{ - uint32_t aud_buf_stereo_offset = 0; - uint32_t ring_buf_mono_offset = 0; - for (aud_buf_stereo_offset = 0; aud_buf_stereo_offset < aud_buf_len; ) { - aud_buf_stereo[aud_buf_stereo_offset] = aud_buf_stereo[aud_buf_stereo_offset] + (ring_buf_mono[ring_buf_mono_offset]>>1); - aud_buf_stereo_offset++; - aud_buf_stereo[aud_buf_stereo_offset] = aud_buf_stereo[aud_buf_stereo_offset] + (ring_buf_mono[ring_buf_mono_offset]>>1); - aud_buf_stereo_offset++; - ring_buf_mono_offset++; - } +int app_play_audio_lineinmode_init(uint8_t mode, uint32_t buff_len) { + TRACE(1, "lapp_play_audio_lineinmode_init:%d ", buff_len); + app_play_lineinmode_mode = mode; + app_audio_mempool_get_buff((uint8_t **)&app_play_sbc_cache, buff_len); + media_audio_init(); + return 0; } -uint32_t app_play_audio_lineinmode_more_data(uint8_t *buf, uint32_t len) -{ - uint32_t l = 0; - if (app_play_lineinmode_merge && app_play_sbc_cache){ - TRACE(1,"line in mode:%d ", len); - if (app_play_lineinmode_mode == 1){ - if (g_play_continue_mark){ - l = app_play_continue_sbc_more_data((uint8_t *)app_play_sbc_cache, len); - }else{ - l = app_play_single_sbc_more_data((uint8_t *)app_play_sbc_cache, len); - } - if (l != len){ - memset(app_play_sbc_cache+l, 0, len-l); - app_play_lineinmode_merge = 0; - } - app_play_audio_lineinmode_mono_merge((int16_t *)buf, (int16_t *)app_play_sbc_cache, len/2); - }else if (app_play_lineinmode_mode == 2){ - if (g_play_continue_mark){ - l = app_play_continue_sbc_more_data((uint8_t *)app_play_sbc_cache, len/2); - }else{ - l = app_play_single_sbc_more_data((uint8_t *)app_play_sbc_cache, len/2); - } - if (l != len/2){ - memset(app_play_sbc_cache+l, 0, len/2-l); - app_play_lineinmode_merge = 0; - } - app_play_audio_lineinmode_stereo_merge((int16_t *)buf, (int16_t *)app_play_sbc_cache, len/2); - } - } - - return l; +int app_play_audio_lineinmode_start(APP_AUDIO_STATUS *status) { + if (app_play_audio_sample_rate == AUD_SAMPRATE_44100) { + LOCK_APP_AUDIO_QUEUE(); + APP_AUDIO_DeCQueue(&media_sbc_queue, 0, + APP_AUDIO_LengthOfCQueue(&media_sbc_queue)); + UNLOCK_APP_AUDIO_QUEUE(); + app_play_lineinmode_merge = 1; + need_init_decoder = 1; + media_Play_init_audio(status->aud_id); + } + return 0; } -int app_play_audio_lineinmode_init(uint8_t mode, uint32_t buff_len) -{ - TRACE(1,"lapp_play_audio_lineinmode_init:%d ", buff_len); - app_play_lineinmode_mode = mode; - app_audio_mempool_get_buff((uint8_t **)&app_play_sbc_cache, buff_len); - media_audio_init(); - return 0; -} - -int app_play_audio_lineinmode_start(APP_AUDIO_STATUS* status) -{ - if (app_play_audio_sample_rate == AUD_SAMPRATE_44100){ - LOCK_APP_AUDIO_QUEUE(); - APP_AUDIO_DeCQueue(&media_sbc_queue, 0, APP_AUDIO_LengthOfCQueue(&media_sbc_queue)); - UNLOCK_APP_AUDIO_QUEUE(); - app_play_lineinmode_merge = 1; - need_init_decoder = 1; - media_Play_init_audio(status->aud_id); - } - return 0; -} - -int app_play_audio_lineinmode_stop(APP_AUDIO_STATUS* status) -{ - app_play_lineinmode_merge = 0; - return 0; +int app_play_audio_lineinmode_stop(APP_AUDIO_STATUS *status) { + app_play_lineinmode_merge = 0; + return 0; } #endif - -#if defined(AUDIO_ANC_FB_MC_MEDIA) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) -#define DELAY_SAMPLE_MC (33*2) // 2:ch +#if defined(AUDIO_ANC_FB_MC_MEDIA) && defined(ANC_APP) && \ + !defined(__AUDIO_RESAMPLE__) +#define DELAY_SAMPLE_MC (33 * 2) // 2:ch static int32_t delay_buf_media[DELAY_SAMPLE_MC]; -static uint32_t audio_mc_data_playback_media(uint8_t *buf, uint32_t mc_len_bytes) -{ - uint32_t begin_time; - //uint32_t end_time; - begin_time = hal_sys_timer_get(); - TRACE_MEDIA_PLAYESTREAM_I("[PLAYBACK_MEDIA][MC] %d",begin_time); +static uint32_t audio_mc_data_playback_media(uint8_t *buf, + uint32_t mc_len_bytes) { + uint32_t begin_time; + // uint32_t end_time; + begin_time = hal_sys_timer_get(); + TRACE_MEDIA_PLAYESTREAM_I("[PLAYBACK_MEDIA][MC] %d", begin_time); - float left_gain; - float right_gain; - int32_t playback_len_bytes,mc_len_bytes_8; - int32_t i,j,k; - int delay_sample; + float left_gain; + float right_gain; + int32_t playback_len_bytes, mc_len_bytes_8; + int32_t i, j, k; + int delay_sample; - mc_len_bytes_8=mc_len_bytes/8; + mc_len_bytes_8 = mc_len_bytes / 8; - hal_codec_get_dac_gain(&left_gain,&right_gain); + hal_codec_get_dac_gain(&left_gain, &right_gain); - //TRACE_MEDIA_PLAYESTREAM_I("playback_samplerate_ratio: %d",playback_samplerate_ratio); + // TRACE_MEDIA_PLAYESTREAM_I("playback_samplerate_ratio: + // %d",playback_samplerate_ratio); // TRACE_MEDIA_PLAYESTREAM_I("left_gain: %d",(int)(left_gain*(1<<12))); // TRACE_MEDIA_PLAYESTREAM_I("right_gain: %d",(int)(right_gain*(1<<12))); - playback_len_bytes=mc_len_bytes/playback_samplerate_ratio_bt; - - if (sample_size_play_bt == AUD_BITS_16) - { - int16_t *sour_p=(int16_t *)(playback_buf_bt+playback_size_bt/2); - int16_t *mid_p=(int16_t *)(buf); - int16_t *mid_p_8=(int16_t *)(buf+mc_len_bytes-mc_len_bytes_8); - int16_t *dest_p=(int16_t *)buf; - - if(buf == playback_buf_mc) - { - sour_p=(int16_t *)playback_buf_bt; - } - - delay_sample=DELAY_SAMPLE_MC; - - for(i=0,j=0;iaud_id); - aud_pram = PROMPT_PRAM_FROM_ID_VALUE(status->aud_id); - g_prompt_chnlsel = PROMPT_CHNLSEl_FROM_ID_VALUE(aud_pram); - TRACE_MEDIA_PLAYESTREAM_I("[MEDIA_ONOFF] aud_id:%04x %s aud_pram:%04x chnlsel:%d", status->aud_id, aud_id2str(aud_id), aud_pram, g_prompt_chnlsel); + aud_id = PROMPT_ID_FROM_ID_VALUE(status->aud_id); + aud_pram = PROMPT_PRAM_FROM_ID_VALUE(status->aud_id); + g_prompt_chnlsel = PROMPT_CHNLSEl_FROM_ID_VALUE(aud_pram); + TRACE_MEDIA_PLAYESTREAM_I( + "[MEDIA_ONOFF] aud_id:%04x %s aud_pram:%04x chnlsel:%d", status->aud_id, + aud_id2str(aud_id), aud_pram, g_prompt_chnlsel); - media_Play_init_audio(aud_id); - app_play_audio_set_aud_id(aud_id); - if (!g_app_audio_length){ - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_CLOSE, 0); - return 0; - } + media_Play_init_audio(aud_id); + app_play_audio_set_aud_id(aud_id); + if (!g_app_audio_length) { + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, (uint8_t)APP_BT_SETTING_CLOSE, + 0); + return 0; + } -#if defined(AUDIO_ANC_FB_MC_MEDIA) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_104M); +#if defined(AUDIO_ANC_FB_MC_MEDIA) && defined(ANC_APP) && \ + !defined(__AUDIO_RESAMPLE__) + app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_104M); #else - app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_52M); + app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_52M); #endif - af_set_priority(AF_USER_AUDIO, osPriorityHigh); - app_audio_mempool_init_with_specific_size(APP_AUDIO_BUFFER_SIZE); - media_audio_init(); + af_set_priority(AF_USER_AUDIO, osPriorityHigh); + app_audio_mempool_init_with_specific_size(APP_AUDIO_BUFFER_SIZE); + media_audio_init(); -#if (defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE))&&defined(ENHANCED_STACK) - if(app_bt_device.src_or_snk == BT_DEVICE_SRC) - { - app_a2dp_source_init(); - } +#if (defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE)) && \ + defined(ENHANCED_STACK) + if (app_bt_device.src_or_snk == BT_DEVICE_SRC) { + app_a2dp_source_init(); + } #endif - btif_sbc_init_decoder(media_sbc_decoder); - btif_sbc_decode_frames(media_sbc_decoder, - g_app_audio_data, g_app_audio_length, - &bytes_parsed, - NULL, 0, - NULL); - switch (media_sbc_decoder->streamInfo.sampleFreq) - { - case BTIF_SBC_CHNL_SAMPLE_FREQ_16: - sample_rate = AUD_SAMPRATE_16000; - break; - case BTIF_SBC_CHNL_SAMPLE_FREQ_32: - sample_rate = AUD_SAMPRATE_32000; - break; - case BTIF_SBC_CHNL_SAMPLE_FREQ_44_1: - sample_rate = AUD_SAMPRATE_44100; - break; - case BTIF_SBC_CHNL_SAMPLE_FREQ_48: - sample_rate = AUD_SAMPRATE_48000; - break; - default: - sample_rate = AUD_SAMPRATE_16000; - break; - } + btif_sbc_init_decoder(media_sbc_decoder); + btif_sbc_decode_frames(media_sbc_decoder, g_app_audio_data, + g_app_audio_length, &bytes_parsed, NULL, 0, NULL); + switch (media_sbc_decoder->streamInfo.sampleFreq) { + case BTIF_SBC_CHNL_SAMPLE_FREQ_16: + sample_rate = AUD_SAMPRATE_16000; + break; + case BTIF_SBC_CHNL_SAMPLE_FREQ_32: + sample_rate = AUD_SAMPRATE_32000; + break; + case BTIF_SBC_CHNL_SAMPLE_FREQ_44_1: + sample_rate = AUD_SAMPRATE_44100; + break; + case BTIF_SBC_CHNL_SAMPLE_FREQ_48: + sample_rate = AUD_SAMPRATE_48000; + break; + default: + sample_rate = AUD_SAMPRATE_16000; + break; + } #ifdef PLAYBACK_USE_I2S - hal_cmu_audio_resample_disable(); + hal_cmu_audio_resample_disable(); #endif - memset(&stream_cfg, 0, sizeof(stream_cfg)); + memset(&stream_cfg, 0, sizeof(stream_cfg)); #if defined(MEDIA_PLAY_24BIT) - stream_cfg.bits = AUD_BITS_24; + stream_cfg.bits = AUD_BITS_24; #else - stream_cfg.bits = AUD_BITS_16; + stream_cfg.bits = AUD_BITS_16; #endif - stream_cfg.channel_num = AUD_CHANNEL_NUM_2; + stream_cfg.channel_num = AUD_CHANNEL_NUM_2; #ifdef __BT_ANC__ - stream_cfg.sample_rate = AUD_SAMPRATE_48000 ; + stream_cfg.sample_rate = AUD_SAMPRATE_48000; #else - stream_cfg.sample_rate = AUD_SAMPRATE_16000; + stream_cfg.sample_rate = AUD_SAMPRATE_16000; #endif #ifdef PLAYBACK_USE_I2S - stream_cfg.device = AUD_STREAM_USE_I2S0_MASTER; - stream_cfg.io_path = AUD_IO_PATH_NULL; + stream_cfg.device = AUD_STREAM_USE_I2S0_MASTER; + stream_cfg.io_path = AUD_IO_PATH_NULL; #else - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; #endif #ifdef __INTERACTION__ - if(aud_id == AUD_ID_BT_FINDME) - { - stream_cfg.vol = g_findme_fadein_vol; - } - else + if (aud_id == AUD_ID_BT_FINDME) { + stream_cfg.vol = g_findme_fadein_vol; + } else #endif - { - stream_cfg.vol = TGT_VOLUME_LEVEL_WARNINGTONE; - } - stream_cfg.handler = app_play_sbc_more_data; + { + stream_cfg.vol = TGT_VOLUME_LEVEL_WARNINGTONE; + } + stream_cfg.handler = app_play_sbc_more_data; - stream_cfg.data_size = APP_AUDIO_PLAYBACK_BUFF_SIZE; + stream_cfg.data_size = APP_AUDIO_PLAYBACK_BUFF_SIZE; #if defined(MEDIA_PLAY_24BIT) - stream_cfg.data_size *= 2; + stream_cfg.data_size *= 2; #endif - g_cache_buff_sz = stream_cfg.data_size/2/2 ; + g_cache_buff_sz = stream_cfg.data_size / 2 / 2; - app_audio_mempool_get_buff((uint8_t **)&app_play_sbc_cache, g_cache_buff_sz); - app_audio_mempool_get_buff(&bt_audio_buff, stream_cfg.data_size); - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); + app_audio_mempool_get_buff((uint8_t **)&app_play_sbc_cache, + g_cache_buff_sz); + app_audio_mempool_get_buff(&bt_audio_buff, stream_cfg.data_size); + stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); #ifdef __BT_ANC__ - bt_sco_samplerate_ratio = 3; - us_fir_init(); + bt_sco_samplerate_ratio = 3; + us_fir_init(); #endif -#if defined(AUDIO_ANC_FB_MC_MEDIA) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - sample_size_play_bt=stream_cfg.bits; - sample_rate_play_bt=stream_cfg.sample_rate; - data_size_play_bt=stream_cfg.data_size; - playback_buf_bt=stream_cfg.data_ptr; - playback_size_bt=stream_cfg.data_size; +#if defined(AUDIO_ANC_FB_MC_MEDIA) && defined(ANC_APP) && \ + !defined(__AUDIO_RESAMPLE__) + sample_size_play_bt = stream_cfg.bits; + sample_rate_play_bt = stream_cfg.sample_rate; + data_size_play_bt = stream_cfg.data_size; + playback_buf_bt = stream_cfg.data_ptr; + playback_size_bt = stream_cfg.data_size; #ifdef __BT_ANC__ - playback_samplerate_ratio_bt=8; + playback_samplerate_ratio_bt = 8; #else - playback_samplerate_ratio_bt=8*3; + playback_samplerate_ratio_bt = 8 * 3; #endif - playback_ch_num_bt=stream_cfg.channel_num; + playback_ch_num_bt = stream_cfg.channel_num; #endif - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); -#if defined(AUDIO_ANC_FB_MC_MEDIA) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - stream_cfg.bits = sample_size_play_bt; - stream_cfg.channel_num = playback_ch_num_bt; - stream_cfg.sample_rate = sample_rate_play_bt; - stream_cfg.device = AUD_STREAM_USE_MC; - stream_cfg.vol = 0; - stream_cfg.handler = audio_mc_data_playback_media; - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; +#if defined(AUDIO_ANC_FB_MC_MEDIA) && defined(ANC_APP) && \ + !defined(__AUDIO_RESAMPLE__) + stream_cfg.bits = sample_size_play_bt; + stream_cfg.channel_num = playback_ch_num_bt; + stream_cfg.sample_rate = sample_rate_play_bt; + stream_cfg.device = AUD_STREAM_USE_MC; + stream_cfg.vol = 0; + stream_cfg.handler = audio_mc_data_playback_media; + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; - app_audio_mempool_get_buff(&bt_audio_buff, data_size_play_bt*playback_samplerate_ratio_bt); - stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); - stream_cfg.data_size = data_size_play_bt*playback_samplerate_ratio_bt; + app_audio_mempool_get_buff( + &bt_audio_buff, data_size_play_bt * playback_samplerate_ratio_bt); + stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(bt_audio_buff); + stream_cfg.data_size = data_size_play_bt * playback_samplerate_ratio_bt; - playback_buf_mc=stream_cfg.data_ptr; - playback_size_mc=stream_cfg.data_size; + playback_buf_mc = stream_cfg.data_ptr; + playback_size_mc = stream_cfg.data_size; - anc_mc_run_init(hal_codec_anc_convert_rate(sample_rate_play_bt)); - af_stream_open(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &stream_cfg); + anc_mc_run_init(hal_codec_anc_convert_rate(sample_rate_play_bt)); + af_stream_open(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &stream_cfg); #endif #if !(defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE)) - af_codec_tune(AUD_STREAM_NUM, 0); + af_codec_tune(AUD_STREAM_NUM, 0); #endif #if defined(IBRT) - app_ibrt_voice_report_trigger_init(aud_id, aud_pram); + app_ibrt_voice_report_trigger_init(aud_id, aud_pram); #endif - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); -#if defined(AUDIO_ANC_FB_MC_MEDIA) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - af_stream_start(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); +#if defined(AUDIO_ANC_FB_MC_MEDIA) && defined(ANC_APP) && \ + !defined(__AUDIO_RESAMPLE__) + af_stream_start(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); #endif - - } else { + } else { #ifdef VOICE_DATAPATH - app_voicepath_set_stream_state(AUDIO_OUTPUT_STREAMING, false); - app_voicepath_set_pending_started_stream(AUDIO_OUTPUT_STREAMING, false); + app_voicepath_set_stream_state(AUDIO_OUTPUT_STREAMING, false); + app_voicepath_set_pending_started_stream(AUDIO_OUTPUT_STREAMING, false); #endif #if !(defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE)) - af_codec_tune(AUD_STREAM_PLAYBACK, 0); + af_codec_tune(AUD_STREAM_PLAYBACK, 0); #endif - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); -#if defined(AUDIO_ANC_FB_MC_MEDIA) && defined(ANC_APP) && !defined(__AUDIO_RESAMPLE__) - af_stream_stop(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); - af_stream_close(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); +#if defined(AUDIO_ANC_FB_MC_MEDIA) && defined(ANC_APP) && \ + !defined(__AUDIO_RESAMPLE__) + af_stream_stop(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); + af_stream_close(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK); #endif #if defined(IBRT) - app_ibrt_voice_report_trigger_deinit(); -#ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED - audio_prompt_stop_playing(); -#endif -#endif -#ifdef PLAYBACK_USE_I2S - hal_cmu_audio_resample_enable(); -#endif - - app_play_sbc_cache = NULL; - g_cache_buff_sz = 0; - g_prompt_chnlsel = PROMOT_ID_BIT_MASK_CHNLSEl_ALL; - app_play_audio_set_aud_id(MAX_RECORD_NUM); - af_set_priority(AF_USER_AUDIO, osPriorityAboveNormal); - app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_32K); - - app_audio_playback_done(); -#if defined(__THIRDPARTY) - app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1,THIRDPARTY_START); -#endif - -#ifdef WL_DET - app_mic_alg_audioloop(true,APP_SYSFREQ_78M); -#endif - } - isRun = onoff; - - return 0; -} - -static void app_stop_local_prompt_playing(void) -{ - app_audio_sendrequest(APP_PLAY_BACK_AUDIO, APP_BT_SETTING_CLOSE, 0); + app_ibrt_voice_report_trigger_deinit(); #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED audio_prompt_stop_playing(); #endif -} - -void app_stop_both_prompt_playing(void) -{ - app_stop_local_prompt_playing(); - app_tws_stop_peer_prompt(); -} - -void app_tws_cmd_stop_prompt_handler(uint8_t* ptrParam, uint16_t paramLen) -{ - TRACE_MEDIA_PLAYESTREAM_I("[STOP_PROMPT_HANDLER]"); - app_stop_local_prompt_playing(); -} +#endif +#ifdef PLAYBACK_USE_I2S + hal_cmu_audio_resample_enable(); #endif + app_play_sbc_cache = NULL; + g_cache_buff_sz = 0; + g_prompt_chnlsel = PROMOT_ID_BIT_MASK_CHNLSEl_ALL; + app_play_audio_set_aud_id(MAX_RECORD_NUM); + af_set_priority(AF_USER_AUDIO, osPriorityAboveNormal); + app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_32K); + + app_audio_playback_done(); +#if defined(__THIRDPARTY) + app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1, + THIRDPARTY_START); +#endif + +#ifdef WL_DET + app_mic_alg_audioloop(true, APP_SYSFREQ_78M); +#endif + } + isRun = onoff; + + return 0; +} + +static void app_stop_local_prompt_playing(void) { + app_audio_sendrequest(APP_PLAY_BACK_AUDIO, APP_BT_SETTING_CLOSE, 0); +#ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED + audio_prompt_stop_playing(); +#endif +} + +void app_stop_both_prompt_playing(void) { + app_stop_local_prompt_playing(); + app_tws_stop_peer_prompt(); +} + +void app_tws_cmd_stop_prompt_handler(uint8_t *ptrParam, uint16_t paramLen) { + TRACE_MEDIA_PLAYESTREAM_I("[STOP_PROMPT_HANDLER]"); + app_stop_local_prompt_playing(); +} +#endif diff --git a/services/bt_app/app_rfcomm_mgr.cpp b/services/bt_app/app_rfcomm_mgr.cpp index 3dca0cb..f40966f 100644 --- a/services/bt_app/app_rfcomm_mgr.cpp +++ b/services/bt_app/app_rfcomm_mgr.cpp @@ -1,36 +1,36 @@ -#include "string.h" #include "app_rfcomm_mgr.h" +#include "string.h" extern "C" { -#include "hal_trace.h" +#include "app_bt.h" +#include "bt_if.h" #include "cmsis_os.h" #include "cqueue.h" -#include "spp_api.h" +#include "hal_trace.h" #include "os_api.h" -#include "bt_if.h" -#include "app_bt.h" +#include "spp_api.h" } -typedef struct -{ - uint8_t instanceIndex; +typedef struct { + uint8_t instanceIndex; - struct spp_device *sppDev; + struct spp_device *sppDev; #if SPP_SERVER == XA_ENABLED - struct spp_service *sppService; - btif_sdp_record_t *sppSdpRecord; + struct spp_service *sppService; + btif_sdp_record_t *sppSdpRecord; #endif - rfcomm_callback_func callback; - osMutexId service_mutex_id; + rfcomm_callback_func callback; + osMutexId service_mutex_id; } RfcommService_t; -#define RFCOMM_SERVER_MAX_CHANNEL_CNT 4 +#define RFCOMM_SERVER_MAX_CHANNEL_CNT 4 static RfcommService_t RfcommServiceInstance[RFCOMM_SERVER_MAX_CHANNEL_CNT]; static uint8_t rfcomm_service_used_instance_cnt = 0; #define RFCOMM_RECV_BUFFER_SIZE 2048 -#define RFCOMM_RECV_BUFFER_POOL_SIZE (RFCOMM_SERVER_MAX_CHANNEL_CNT * RFCOMM_RECV_BUFFER_SIZE) +#define RFCOMM_RECV_BUFFER_POOL_SIZE \ + (RFCOMM_SERVER_MAX_CHANNEL_CNT * RFCOMM_RECV_BUFFER_SIZE) static uint8_t rfcomm_rx_buf[RFCOMM_RECV_BUFFER_POOL_SIZE]; static uint32_t rfcomm_rx_buf_allocated_offset = 0; @@ -43,32 +43,32 @@ static const uint8_t RFCOMM_NULL_UUID_128[16] = { }; static const U8 rfcommClassId[] = { - SDP_ATTRIB_HEADER_8BIT(17), /* Data Element Sequence, 17 bytes */ - SDP_UUID_128BIT(RFCOMM_NULL_UUID_128), /* 128 bit UUID in Big Endian */ + SDP_ATTRIB_HEADER_8BIT(17), /* Data Element Sequence, 17 bytes */ + SDP_UUID_128BIT(RFCOMM_NULL_UUID_128), /* 128 bit UUID in Big Endian */ }; -static uint8_t rfcommClassIdArray[RFCOMM_SERVER_MAX_CHANNEL_CNT*sizeof(rfcommClassId)] = -{ +static uint8_t rfcommClassIdArray[RFCOMM_SERVER_MAX_CHANNEL_CNT * + sizeof(rfcommClassId)] = { }; static const U8 RfcommProtoDescList[] = { - SDP_ATTRIB_HEADER_8BIT(12), /* Data element sequence, 12 bytes */ + SDP_ATTRIB_HEADER_8BIT(12), /* Data element sequence, 12 bytes */ /* Each element of the list is a Protocol descriptor which is a - * data element sequence. The first element is L2CAP which only - * has a UUID element. - */ - SDP_ATTRIB_HEADER_8BIT(3), /* Data element sequence for L2CAP, 3 + * data element sequence. The first element is L2CAP which only + * has a UUID element. + */ + SDP_ATTRIB_HEADER_8BIT(3), /* Data element sequence for L2CAP, 3 * bytes */ - SDP_UUID_16BIT(PROT_L2CAP), /* Uuid16 L2CAP */ + SDP_UUID_16BIT(PROT_L2CAP), /* Uuid16 L2CAP */ /* Next protocol descriptor in the list is RFCOMM. It contains two - * elements which are the UUID and the channel. Ultimately this - * channel will need to filled in with value returned by RFCOMM. - */ + * elements which are the UUID and the channel. Ultimately this + * channel will need to filled in with value returned by RFCOMM. + */ /* Data element sequence for RFCOMM, 5 bytes */ SDP_ATTRIB_HEADER_8BIT(5), @@ -76,11 +76,10 @@ static const U8 RfcommProtoDescList[] = { SDP_UUID_16BIT(PROT_RFCOMM), /* Uuid16 RFCOMM */ /* Uint8 RFCOMM channel number - value can vary */ - SDP_UINT_8BIT(0) -}; + SDP_UINT_8BIT(0)}; -static uint8_t RfcommProtoDescListArray[RFCOMM_SERVER_MAX_CHANNEL_CNT*sizeof(RfcommProtoDescList)] = -{ +static uint8_t RfcommProtoDescListArray[RFCOMM_SERVER_MAX_CHANNEL_CNT * + sizeof(RfcommProtoDescList)] = { }; @@ -88,13 +87,13 @@ static uint8_t RfcommProtoDescListArray[RFCOMM_SERVER_MAX_CHANNEL_CNT*sizeof(Rfc * BluetoothProfileDescriptorList */ static const U8 ProfileDescList[] = { - SDP_ATTRIB_HEADER_8BIT(8), /* Data element sequence, 8 bytes */ + SDP_ATTRIB_HEADER_8BIT(8), /* Data element sequence, 8 bytes */ - /* Data element sequence for ProfileDescriptor, 6 bytes */ - SDP_ATTRIB_HEADER_8BIT(6), + /* Data element sequence for ProfileDescriptor, 6 bytes */ + SDP_ATTRIB_HEADER_8BIT(6), - SDP_UUID_16BIT(SC_SERIAL_PORT), /* Uuid16 SPP */ - SDP_UINT_16BIT(0x0102) /* As per errata 2239 */ + SDP_UUID_16BIT(SC_SERIAL_PORT), /* Uuid16 SPP */ + SDP_UINT_16BIT(0x0102) /* As per errata 2239 */ }; /* SPP attributes. @@ -107,276 +106,237 @@ static sdp_attribute_t rfcommAttributes[] = { SDP_ATTRIBUTE(AID_PROTOCOL_DESC_LIST, RfcommProtoDescList), - SDP_ATTRIBUTE(AID_BT_PROFILE_DESC_LIST, ProfileDescList), + SDP_ATTRIBUTE(AID_BT_PROFILE_DESC_LIST, ProfileDescList), }; -static sdp_attribute_t rfcommAttributesArray[RFCOMM_SERVER_MAX_CHANNEL_CNT][ARRAY_SIZE(rfcommAttributes)] = -{ +static sdp_attribute_t rfcommAttributesArray[RFCOMM_SERVER_MAX_CHANNEL_CNT] + [ARRAY_SIZE(rfcommAttributes)] = { }; -osThreadId app_rfcomm_get_rx_thread_id(uint8_t serviceIndex) -{ - if (serviceIndex < rfcomm_service_used_instance_cnt) - { - return RfcommServiceInstance[serviceIndex].sppDev->reader_thread_id; - } - else - { - ASSERT(false, "Wrong rfcomm service index %d", serviceIndex); - } +osThreadId app_rfcomm_get_rx_thread_id(uint8_t serviceIndex) { + if (serviceIndex < rfcomm_service_used_instance_cnt) { + return RfcommServiceInstance[serviceIndex].sppDev->reader_thread_id; + } else { + ASSERT(false, "Wrong rfcomm service index %d", serviceIndex); + } } -uint8_t app_rfcomm_get_instance_index(void* dev) -{ - for (uint8_t index = 0;index < rfcomm_service_used_instance_cnt;index++) - { - if ((struct spp_device *)dev == (RfcommServiceInstance[index].sppDev)) - { - return index; - } +uint8_t app_rfcomm_get_instance_index(void *dev) { + for (uint8_t index = 0; index < rfcomm_service_used_instance_cnt; index++) { + if ((struct spp_device *)dev == (RfcommServiceInstance[index].sppDev)) { + return index; } + } - ASSERT(false, "invalid rfcomm callback triggered!"); + ASSERT(false, "invalid rfcomm callback triggered!"); + return 0; +} + +static void app_rfcomm_org_callback(struct spp_device *locDev, + struct spp_callback_parms *info) { + uint8_t index = app_rfcomm_get_instance_index(locDev); + RfcommService_t *pService = &(RfcommServiceInstance[index]); + RFCOMM_EVENT_E event; + uint16_t sentDataLen = 0; + uint8_t *sentDataBuf = NULL; + + if (BTIF_SPP_EVENT_REMDEV_CONNECTED_IND == info->event) { + event = RFCOMM_INCOMING_CONN_REQ; + } else if (BTIF_SPP_EVENT_REMDEV_CONNECTED == info->event) { + event = RFCOMM_CONNECTED; + } else if (BTIF_SPP_EVENT_REMDEV_DISCONNECTED == info->event) { + event = RFCOMM_DISCONNECTED; + } else if (BTIF_SPP_EVENT_DATA_SENT == info->event) { + struct spp_tx_done *pTxDone = (struct spp_tx_done *)(info->p.other); + sentDataBuf = pTxDone->tx_buf; + sentDataLen = pTxDone->tx_data_length; + event = RFCOMM_TX_DONE; + } else { + event = RFCOMM_UNKNOWN_EVENT; + } + + uint8_t *pBtAddr = NULL; + if (info->p.remDev) { + pBtAddr = btif_me_get_remote_device_bdaddr(info->p.remDev)->address; + + if (pService->callback) { + bool ret = pService->callback( + event, index, btif_me_get_remote_device_hci_handle(info->p.remDev), + pBtAddr, sentDataBuf, sentDataLen); + + if (!ret) { + if (RFCOMM_INCOMING_CONN_REQ == event) { + // reject the incoming connection request + info->status = BT_STS_CANCELLED; + } + } + } + } +} + +osMutexId app_rfcomm_service_get_mutex(uint8_t instanceIndex) { + return RfcommServiceInstance[instanceIndex].service_mutex_id; +} + +static bt_status_t app_rfcomm_service_init( + RfcommService_t *service, sdp_attribute_t *sdpAttributes, + int attributeCount, int serviceId, uint32_t app_id, + spp_handle_data_event_func_t dataRecCallback, int txPacketCount, + osMutexId mutexId, osMutexId creditMutexId) { + service->sppService = btif_create_spp_service(); + service->sppDev = btif_create_spp_device(); + + service->sppDev->portType = BTIF_SPP_SERVER_PORT; + uint8_t *ptrRxBuf = &rfcomm_rx_buf[rfcomm_rx_buf_allocated_offset]; + uint32_t rxBufSize = RFCOMM_RECV_BUFFER_SIZE; + + rfcomm_rx_buf_allocated_offset += rxBufSize; + + ASSERT(rfcomm_rx_buf_allocated_offset <= RFCOMM_RECV_BUFFER_POOL_SIZE, + "RFComm rx buffer overflow! Need %d actual %d", + rfcomm_rx_buf_allocated_offset, RFCOMM_RECV_BUFFER_POOL_SIZE); + + btif_spp_init_rx_buf(service->sppDev, ptrRxBuf, rxBufSize); + + service->sppSdpRecord = btif_sdp_create_record(); + + btif_sdp_record_param_t param; + param.attrs = sdpAttributes, param.attr_count = attributeCount; + param.COD = BTIF_COD_MAJOR_PERIPHERAL; + btif_sdp_record_setup(service->sppSdpRecord, ¶m); + + service->sppService->rf_service.serviceId = serviceId; + service->sppService->numPorts = 0; + service->sppDev->app_id = app_id; + service->sppDev->spp_handle_data_event_func = dataRecCallback; + // TODO: add more in other files + service->sppDev->creditMutex = creditMutexId; + + btif_spp_service_setup(service->sppDev, service->sppService, + service->sppSdpRecord); + btif_spp_init_device(service->sppDev, txPacketCount, mutexId); + + return btif_spp_open(service->sppDev, NULL, app_rfcomm_org_callback); +} + +void app_rfcomm_read(uint8_t instanceIndex, uint8_t *pBuf, uint16_t *ptrLen) { + if (instanceIndex >= rfcomm_service_used_instance_cnt) { + return; + } + + uint16_t lenToRead = *ptrLen; + + btif_spp_read(RfcommServiceInstance[instanceIndex].sppDev, (char *)pBuf, + &lenToRead); + *ptrLen = lenToRead; +} + +int8_t app_rfcomm_write(uint8_t instanceIndex, const uint8_t *pBuf, + uint16_t length) { + if (instanceIndex >= rfcomm_service_used_instance_cnt) { + return -1; + } + + uint16_t len = (uint16_t)length; + if (BT_STS_SUCCESS != + btif_spp_write(RfcommServiceInstance[instanceIndex].sppDev, (char *)pBuf, + &len)) { + return -1; + } else { return 0; + } } -static void app_rfcomm_org_callback(struct spp_device *locDev, struct spp_callback_parms *info) -{ - uint8_t index = app_rfcomm_get_instance_index(locDev); - RfcommService_t* pService = &(RfcommServiceInstance[index]); - RFCOMM_EVENT_E event; - uint16_t sentDataLen = 0; - uint8_t* sentDataBuf = NULL; - - if (BTIF_SPP_EVENT_REMDEV_CONNECTED_IND == info->event) - { - event = RFCOMM_INCOMING_CONN_REQ; - } - else if (BTIF_SPP_EVENT_REMDEV_CONNECTED == info->event) - { - event = RFCOMM_CONNECTED; - } - else if (BTIF_SPP_EVENT_REMDEV_DISCONNECTED == info->event) - { - event = RFCOMM_DISCONNECTED; - } - else if (BTIF_SPP_EVENT_DATA_SENT == info->event) - { - struct spp_tx_done* pTxDone = (struct spp_tx_done *)(info->p.other); - sentDataBuf = pTxDone->tx_buf; - sentDataLen = pTxDone->tx_data_length; - event = RFCOMM_TX_DONE; - } - else - { - event = RFCOMM_UNKNOWN_EVENT; - } +bool app_rfcomm_removesdpservice(uint8_t instanceIndex) { + if (instanceIndex >= rfcomm_service_used_instance_cnt) { + return false; + } - uint8_t* pBtAddr = NULL; - if (info->p.remDev) - { - pBtAddr = btif_me_get_remote_device_bdaddr(info->p.remDev)->address; - - if (pService->callback) - { - bool ret = pService->callback(event, - index, - btif_me_get_remote_device_hci_handle(info->p.remDev), - pBtAddr, - sentDataBuf, - sentDataLen); - - if (!ret) - { - if (RFCOMM_INCOMING_CONN_REQ == event) - { - // reject the incoming connection request - info->status = BT_STS_CANCELLED; - } - } - } - } + return (BT_STS_SUCCESS == + btif_sdp_remove_record( + &(RfcommServiceInstance[instanceIndex].sppSdpRecord))); } -osMutexId app_rfcomm_service_get_mutex(uint8_t instanceIndex) -{ - return RfcommServiceInstance[instanceIndex].service_mutex_id; +bool app_rfcomm_addsdpservice(uint8_t instanceIndex) { + if (instanceIndex >= rfcomm_service_used_instance_cnt) { + return false; + } + + return (BT_STS_SUCCESS == + btif_sdp_add_record( + &(RfcommServiceInstance[instanceIndex].sppSdpRecord))); } -static bt_status_t app_rfcomm_service_init(RfcommService_t *service, - sdp_attribute_t *sdpAttributes, - int attributeCount, int serviceId, uint32_t app_id, - spp_handle_data_event_func_t dataRecCallback, - int txPacketCount, - osMutexId mutexId, - osMutexId creditMutexId) { - service->sppService = btif_create_spp_service(); - service->sppDev = btif_create_spp_device(); - - service->sppDev->portType = BTIF_SPP_SERVER_PORT; - uint8_t* ptrRxBuf = &rfcomm_rx_buf[rfcomm_rx_buf_allocated_offset]; - uint32_t rxBufSize = RFCOMM_RECV_BUFFER_SIZE; - - rfcomm_rx_buf_allocated_offset += rxBufSize; - - ASSERT(rfcomm_rx_buf_allocated_offset <= RFCOMM_RECV_BUFFER_POOL_SIZE, - "RFComm rx buffer overflow! Need %d actual %d", - rfcomm_rx_buf_allocated_offset, RFCOMM_RECV_BUFFER_POOL_SIZE); - - btif_spp_init_rx_buf(service->sppDev, ptrRxBuf, - rxBufSize); - - service->sppSdpRecord = btif_sdp_create_record(); - - btif_sdp_record_param_t param; - param.attrs = sdpAttributes, - param.attr_count = attributeCount; - param.COD = BTIF_COD_MAJOR_PERIPHERAL; - btif_sdp_record_setup(service->sppSdpRecord, ¶m); - - service->sppService->rf_service.serviceId = serviceId; - service->sppService->numPorts = 0; - service->sppDev->app_id = app_id; - service->sppDev->spp_handle_data_event_func = dataRecCallback; - // TODO: add more in other files - service->sppDev->creditMutex = creditMutexId; - - btif_spp_service_setup(service->sppDev, service->sppService, service->sppSdpRecord); - btif_spp_init_device(service->sppDev, txPacketCount, mutexId); - - return btif_spp_open(service->sppDev, NULL, app_rfcomm_org_callback); +void app_rfcomm_close(uint8_t instanceIndex) { + if (instanceIndex >= rfcomm_service_used_instance_cnt) { + return; + } + btif_spp_close(RfcommServiceInstance[instanceIndex].sppDev); } -void app_rfcomm_read(uint8_t instanceIndex, uint8_t* pBuf, uint16_t* ptrLen) -{ - if (instanceIndex >= rfcomm_service_used_instance_cnt) - { - return; - } +int8_t app_rfcomm_open(RFCOMM_CONFIG_T *ptConfig) { + if (rfcomm_service_used_instance_cnt >= RFCOMM_SERVER_MAX_CHANNEL_CNT) { + return -1; + } - uint16_t lenToRead = *ptrLen; + RfcommService_t *sppServiceInstance = + &RfcommServiceInstance[rfcomm_service_used_instance_cnt]; - btif_spp_read(RfcommServiceInstance[instanceIndex].sppDev, - (char *)pBuf, &lenToRead); - *ptrLen = lenToRead; + sppServiceInstance->callback = ptConfig->callback; + + memcpy(&rfcommClassIdArray[rfcomm_service_used_instance_cnt * + sizeof(rfcommClassId)], + rfcommClassId, sizeof(rfcommClassId)); + for (int32_t index = 0; index < 16; index++) { + rfcommClassIdArray[rfcomm_service_used_instance_cnt * + sizeof(rfcommClassId) + + 3 + index] = ptConfig->rfcomm_128bit_uuid[15 - index]; + } + + memcpy(&RfcommProtoDescListArray[rfcomm_service_used_instance_cnt * + sizeof(RfcommProtoDescList)], + RfcommProtoDescList, sizeof(RfcommProtoDescList)); + memcpy(&RfcommProtoDescListArray[rfcomm_service_used_instance_cnt * + sizeof(RfcommProtoDescList) + + 13], + &(ptConfig->rfcomm_ch), 1); + + memcpy(&rfcommAttributesArray[rfcomm_service_used_instance_cnt], + rfcommAttributes, sizeof(rfcommAttributes)); + + rfcommAttributesArray[rfcomm_service_used_instance_cnt][0].value = + &rfcommClassIdArray[rfcomm_service_used_instance_cnt * + sizeof(rfcommClassId)]; + rfcommAttributesArray[rfcomm_service_used_instance_cnt][1].value = + &RfcommProtoDescListArray[rfcomm_service_used_instance_cnt * + sizeof(RfcommProtoDescList)]; + + sppServiceInstance->instanceIndex = rfcomm_service_used_instance_cnt; + + bt_status_t status = app_rfcomm_service_init( + sppServiceInstance, + rfcommAttributesArray[rfcomm_service_used_instance_cnt], + ARRAY_SIZE(rfcommAttributes), ptConfig->rfcomm_ch, ptConfig->app_id, + ptConfig->spp_handle_data_event_func, ptConfig->tx_pkt_cnt, + ptConfig->mutexId, ptConfig->creditMutexId); + + if (status != BT_STS_SUCCESS) { + return -1; + } else { + return rfcomm_service_used_instance_cnt++; + } } -int8_t app_rfcomm_write(uint8_t instanceIndex, const uint8_t* pBuf, uint16_t length) -{ - if (instanceIndex >= rfcomm_service_used_instance_cnt) - { - return -1; - } - - uint16_t len = (uint16_t)length; - if (BT_STS_SUCCESS != btif_spp_write(RfcommServiceInstance[instanceIndex].sppDev, - (char *)pBuf, &len)) - { - return -1; - } - else - { - return 0; - } -} - -bool app_rfcomm_removesdpservice(uint8_t instanceIndex) -{ - if (instanceIndex >= rfcomm_service_used_instance_cnt) - { - return false; - } - - return (BT_STS_SUCCESS == btif_sdp_remove_record(&(RfcommServiceInstance[instanceIndex].sppSdpRecord))); -} - -bool app_rfcomm_addsdpservice(uint8_t instanceIndex) -{ - if (instanceIndex >= rfcomm_service_used_instance_cnt) - { - return false; - } - - return (BT_STS_SUCCESS == btif_sdp_add_record(&(RfcommServiceInstance[instanceIndex].sppSdpRecord))); -} - -void app_rfcomm_close(uint8_t instanceIndex) -{ - if (instanceIndex >= rfcomm_service_used_instance_cnt) - { - return; - } - btif_spp_close(RfcommServiceInstance[instanceIndex].sppDev); -} - -int8_t app_rfcomm_open(RFCOMM_CONFIG_T* ptConfig) -{ - if (rfcomm_service_used_instance_cnt >= RFCOMM_SERVER_MAX_CHANNEL_CNT) - { - return -1; - } - - RfcommService_t* sppServiceInstance = - &RfcommServiceInstance[rfcomm_service_used_instance_cnt]; - - sppServiceInstance->callback = ptConfig->callback; - - memcpy(&rfcommClassIdArray[rfcomm_service_used_instance_cnt*sizeof(rfcommClassId)], - rfcommClassId, sizeof(rfcommClassId)); - for (int32_t index = 0;index < 16;index++) - { - rfcommClassIdArray[rfcomm_service_used_instance_cnt*sizeof(rfcommClassId) + 3 + index] - = ptConfig->rfcomm_128bit_uuid[15-index]; - } - - memcpy(&RfcommProtoDescListArray[rfcomm_service_used_instance_cnt*sizeof(RfcommProtoDescList)], - RfcommProtoDescList, sizeof(RfcommProtoDescList)); - memcpy(&RfcommProtoDescListArray[rfcomm_service_used_instance_cnt*sizeof(RfcommProtoDescList) + 13], - &(ptConfig->rfcomm_ch), 1); - - memcpy(&rfcommAttributesArray[rfcomm_service_used_instance_cnt], - rfcommAttributes, sizeof(rfcommAttributes)); - - rfcommAttributesArray[rfcomm_service_used_instance_cnt][0].value = &rfcommClassIdArray[rfcomm_service_used_instance_cnt*sizeof(rfcommClassId)]; - rfcommAttributesArray[rfcomm_service_used_instance_cnt][1].value = &RfcommProtoDescListArray[rfcomm_service_used_instance_cnt*sizeof(RfcommProtoDescList)]; - - sppServiceInstance->instanceIndex = rfcomm_service_used_instance_cnt; - - bt_status_t status = app_rfcomm_service_init( - sppServiceInstance, rfcommAttributesArray[rfcomm_service_used_instance_cnt], - ARRAY_SIZE(rfcommAttributes), - ptConfig->rfcomm_ch, ptConfig->app_id, - ptConfig->spp_handle_data_event_func, - ptConfig->tx_pkt_cnt, - ptConfig->mutexId, - ptConfig->creditMutexId); - - if (status != BT_STS_SUCCESS) - { - return -1; - } - else - { - return rfcomm_service_used_instance_cnt++; - } -} - -void app_rfcomm_mgr_init(void) -{ - memset(&RfcommServiceInstance, 0, sizeof(RfcommServiceInstance)); - rfcomm_service_used_instance_cnt = 0; +void app_rfcomm_mgr_init(void) { + memset(&RfcommServiceInstance, 0, sizeof(RfcommServiceInstance)); + rfcomm_service_used_instance_cnt = 0; } // Add services to sdp database, currently invoked on connection // -void app_rfcomm_services_add_sdp(void) { - -} +void app_rfcomm_services_add_sdp(void) {} // Remove services from sdp database, currently invoked on disconnection // -void app_rfcomm_services_remove_sdp(void) { - -} - +void app_rfcomm_services_remove_sdp(void) {} diff --git a/services/bt_app/app_ring_merge.cpp b/services/bt_app/app_ring_merge.cpp index 35e5fd7..cd02652 100644 --- a/services/bt_app/app_ring_merge.cpp +++ b/services/bt_app/app_ring_merge.cpp @@ -13,10 +13,10 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "app_ring_merge.h" +#include "audioflinger.h" #include "cmsis_os.h" #include "hal_trace.h" -#include "audioflinger.h" -#include "app_ring_merge.h" #include "res_audio_ring.h" // control queue access @@ -29,375 +29,352 @@ extern "C" void app_stop_sco_media_stream(uint8_t devId); static void app_ring_merge_finished_callback(void); enum APP_RING_MERGE_STATUS { - APP_RING_MERGE_STATUS_STOP, - APP_RING_MERGE_STATUS_START, - APP_RING_MERGE_STATUS_RUNNING + APP_RING_MERGE_STATUS_STOP, + APP_RING_MERGE_STATUS_START, + APP_RING_MERGE_STATUS_RUNNING }; struct APP_RING_MERGE_CONFIG_T { - APP_RING_MERGE_STATUS status; - int16_t * pbuf; - uint32_t len; - uint32_t next; - AUD_BITS_T bits; - enum APP_RING_MERGE_PLAY_T play; - AF_STREAM_HANDLER_T handler; + APP_RING_MERGE_STATUS status; + int16_t *pbuf; + uint32_t len; + uint32_t next; + AUD_BITS_T bits; + enum APP_RING_MERGE_PLAY_T play; + AF_STREAM_HANDLER_T handler; - uint8_t pendingStopOp; - int8_t savedStoppedStreamId; + uint8_t pendingStopOp; + int8_t savedStoppedStreamId; }; struct APP_RING_MERGE_CONFIG_T app_ring_merge_config = { .status = APP_RING_MERGE_STATUS_STOP, - .pbuf = NULL, - .len = 0, - .next = 0, - .bits = AUD_BITS_16, - .play = APP_RING_MERGE_PLAY_QTY, + .pbuf = NULL, + .len = 0, + .next = 0, + .bits = AUD_BITS_16, + .play = APP_RING_MERGE_PLAY_QTY, .handler = NULL}; -template -static DataType convertTo(int16_t x) -{ - return (x); +template static DataType convertTo(int16_t x) { + return (x); } -template <> -int32_t convertTo(int16_t x) -{ - return (x << 8); -} +template <> int32_t convertTo(int16_t x) { return (x << 8); } template -static void app_ring_merge_track_2_in_1(DataType *src_buf0, int16_t *src_buf1, DataType *dst_buf, uint32_t src_len) -{ - uint32_t i = 0; - for (i = 0; i < src_len; i++) - { - dst_buf[i] = (src_buf0[i] >> 1) + ((convertTo(src_buf1[i])) >> 1); - } +static void app_ring_merge_track_2_in_1(DataType *src_buf0, int16_t *src_buf1, + DataType *dst_buf, uint32_t src_len) { + uint32_t i = 0; + for (i = 0; i < src_len; i++) { + dst_buf[i] = (src_buf0[i] >> 1) + ((convertTo(src_buf1[i])) >> 1); + } } /* -static void app_ring_merge_track_2_in_1_16bits(int16_t *src_buf0, int16_t *src_buf1, int16_t *dst_buf, uint32_t src_len) +static void app_ring_merge_track_2_in_1_16bits(int16_t *src_buf0, int16_t +*src_buf1, int16_t *dst_buf, uint32_t src_len) { app_ring_merge_track_2_in_1(src_buf0, src_buf1, dst_buf, src_len); } -static void app_ring_merge_track_2_in_1_24bits(int32_t *src_buf0, int16_t *src_buf1, int32_t *dst_buf, uint32_t src_len) +static void app_ring_merge_track_2_in_1_24bits(int32_t *src_buf0, int16_t +*src_buf1, int32_t *dst_buf, uint32_t src_len) { app_ring_merge_track_2_in_1(src_buf0, src_buf1, dst_buf, src_len); } */ template -static uint32_t app_ring_merge_oneshot_more_data_impl(uint8_t *buf, uint32_t len) -{ - uint32_t need_len = len / sizeof(DataType); - DataType *pBuf = ( DataType * )buf; +static uint32_t app_ring_merge_oneshot_more_data_impl(uint8_t *buf, + uint32_t len) { + uint32_t need_len = len / sizeof(DataType); + DataType *pBuf = (DataType *)buf; - uint32_t curr_size = 0; + uint32_t curr_size = 0; - if (app_ring_merge_config.next == app_ring_merge_config.len) - { - return len; - } - - if (need_len > app_ring_merge_config.len) - { - app_ring_merge_track_2_in_1(pBuf, app_ring_merge_config.pbuf, pBuf, app_ring_merge_config.len); - app_ring_merge_config.next = app_ring_merge_config.len; - app_ring_merge_finished_callback(); - } - else - { - if ((app_ring_merge_config.len - app_ring_merge_config.next) >= need_len) - { - app_ring_merge_track_2_in_1(pBuf, app_ring_merge_config.pbuf + app_ring_merge_config.next, pBuf, need_len); - app_ring_merge_config.next += need_len; - } - else - { - curr_size = app_ring_merge_config.len - app_ring_merge_config.next; - app_ring_merge_track_2_in_1(pBuf, app_ring_merge_config.pbuf + app_ring_merge_config.next, pBuf, curr_size); - app_ring_merge_config.next = app_ring_merge_config.len; - app_ring_merge_finished_callback(); - } - } + if (app_ring_merge_config.next == app_ring_merge_config.len) { return len; + } + + if (need_len > app_ring_merge_config.len) { + app_ring_merge_track_2_in_1(pBuf, app_ring_merge_config.pbuf, pBuf, + app_ring_merge_config.len); + app_ring_merge_config.next = app_ring_merge_config.len; + app_ring_merge_finished_callback(); + } else { + if ((app_ring_merge_config.len - app_ring_merge_config.next) >= need_len) { + app_ring_merge_track_2_in_1( + pBuf, app_ring_merge_config.pbuf + app_ring_merge_config.next, pBuf, + need_len); + app_ring_merge_config.next += need_len; + } else { + curr_size = app_ring_merge_config.len - app_ring_merge_config.next; + app_ring_merge_track_2_in_1( + pBuf, app_ring_merge_config.pbuf + app_ring_merge_config.next, pBuf, + curr_size); + app_ring_merge_config.next = app_ring_merge_config.len; + app_ring_merge_finished_callback(); + } + } + return len; } -static uint32_t app_ring_merge_oneshot_more_data(uint8_t *buf, uint32_t len) -{ - uint32_t ret = 0; +static uint32_t app_ring_merge_oneshot_more_data(uint8_t *buf, uint32_t len) { + uint32_t ret = 0; - if (app_ring_merge_config.bits == AUD_BITS_16) - ret = app_ring_merge_oneshot_more_data_impl(buf, len); - else if (app_ring_merge_config.bits == AUD_BITS_24) - ret = app_ring_merge_oneshot_more_data_impl(buf, len); - else - TRACE(1,"[%s] warning not suitable callback available", __func__); + if (app_ring_merge_config.bits == AUD_BITS_16) + ret = app_ring_merge_oneshot_more_data_impl(buf, len); + else if (app_ring_merge_config.bits == AUD_BITS_24) + ret = app_ring_merge_oneshot_more_data_impl(buf, len); + else + TRACE(1, "[%s] warning not suitable callback available", __func__); - return ret; + return ret; } template -static uint32_t app_ring_merge_periodic_more_data_impl(uint8_t *buf, uint32_t len) -{ - uint32_t need_len = len / sizeof(DataType); - uint32_t remain_size = len / sizeof(DataType); - uint32_t curr_size = 0; - DataType *pBuf = ( DataType * )buf; - if (need_len > app_ring_merge_config.len) - { - do - { - if (app_ring_merge_config.next) - { - curr_size = app_ring_merge_config.len - app_ring_merge_config.next; - app_ring_merge_track_2_in_1(pBuf, app_ring_merge_config.pbuf + app_ring_merge_config.next, pBuf, curr_size); - remain_size -= curr_size; - app_ring_merge_config.next = 0; - } - else if (remain_size > app_ring_merge_config.len) - { - app_ring_merge_track_2_in_1(pBuf + curr_size, app_ring_merge_config.pbuf, pBuf + curr_size, app_ring_merge_config.len); - curr_size += app_ring_merge_config.len; - remain_size -= app_ring_merge_config.len; - } - else - { - app_ring_merge_track_2_in_1(pBuf + curr_size, app_ring_merge_config.pbuf, pBuf + curr_size, remain_size); - app_ring_merge_config.next = remain_size; - remain_size = 0; - } - } while (remain_size); +static uint32_t app_ring_merge_periodic_more_data_impl(uint8_t *buf, + uint32_t len) { + uint32_t need_len = len / sizeof(DataType); + uint32_t remain_size = len / sizeof(DataType); + uint32_t curr_size = 0; + DataType *pBuf = (DataType *)buf; + if (need_len > app_ring_merge_config.len) { + do { + if (app_ring_merge_config.next) { + curr_size = app_ring_merge_config.len - app_ring_merge_config.next; + app_ring_merge_track_2_in_1( + pBuf, app_ring_merge_config.pbuf + app_ring_merge_config.next, pBuf, + curr_size); + remain_size -= curr_size; + app_ring_merge_config.next = 0; + } else if (remain_size > app_ring_merge_config.len) { + app_ring_merge_track_2_in_1( + pBuf + curr_size, app_ring_merge_config.pbuf, pBuf + curr_size, + app_ring_merge_config.len); + curr_size += app_ring_merge_config.len; + remain_size -= app_ring_merge_config.len; + } else { + app_ring_merge_track_2_in_1(pBuf + curr_size, + app_ring_merge_config.pbuf, + pBuf + curr_size, remain_size); + app_ring_merge_config.next = remain_size; + remain_size = 0; + } + } while (remain_size); + } else { + if ((app_ring_merge_config.len - app_ring_merge_config.next) >= need_len) { + app_ring_merge_track_2_in_1( + pBuf, app_ring_merge_config.pbuf + app_ring_merge_config.next, pBuf, + need_len); + app_ring_merge_config.next += need_len; + } else { + curr_size = app_ring_merge_config.len - app_ring_merge_config.next; + app_ring_merge_track_2_in_1( + pBuf, app_ring_merge_config.pbuf + app_ring_merge_config.next, pBuf, + curr_size); + app_ring_merge_config.next = need_len - curr_size; + app_ring_merge_track_2_in_1(pBuf + curr_size, app_ring_merge_config.pbuf, + pBuf + curr_size, app_ring_merge_config.next); } - else - { - if ((app_ring_merge_config.len - app_ring_merge_config.next) >= need_len) - { - app_ring_merge_track_2_in_1(pBuf, app_ring_merge_config.pbuf + app_ring_merge_config.next, pBuf, need_len); - app_ring_merge_config.next += need_len; - } - else - { - curr_size = app_ring_merge_config.len - app_ring_merge_config.next; - app_ring_merge_track_2_in_1(pBuf, app_ring_merge_config.pbuf + app_ring_merge_config.next, pBuf, curr_size); - app_ring_merge_config.next = need_len - curr_size; - app_ring_merge_track_2_in_1(pBuf + curr_size, app_ring_merge_config.pbuf, pBuf + curr_size, app_ring_merge_config.next); - } - } - return len; + } + return len; } -static uint32_t app_ring_merge_periodic_more_data(uint8_t *buf, uint32_t len) -{ - uint32_t ret = 0; +static uint32_t app_ring_merge_periodic_more_data(uint8_t *buf, uint32_t len) { + uint32_t ret = 0; - if (app_ring_merge_config.bits == AUD_BITS_16) - ret = app_ring_merge_periodic_more_data_impl(buf, len); - else if (app_ring_merge_config.bits == AUD_BITS_24) - ret = app_ring_merge_periodic_more_data_impl(buf, len); - else - TRACE(1,"[%s] warning not suitable callback available", __func__); + if (app_ring_merge_config.bits == AUD_BITS_16) + ret = app_ring_merge_periodic_more_data_impl(buf, len); + else if (app_ring_merge_config.bits == AUD_BITS_24) + ret = app_ring_merge_periodic_more_data_impl(buf, len); + else + TRACE(1, "[%s] warning not suitable callback available", __func__); - return ret; + return ret; } +uint32_t app_ring_merge_more_data(uint8_t *buf, uint32_t len) { + uint32_t nRet = len; -uint32_t app_ring_merge_more_data(uint8_t *buf, uint32_t len) -{ - uint32_t nRet = len; - - osMutexWait(app_ring_merge_mutex_id, osWaitForever); - if (app_ring_merge_config.handler && - app_ring_merge_config.status != APP_RING_MERGE_STATUS_STOP) - { - if (app_ring_merge_config.status == APP_RING_MERGE_STATUS_START) - { - app_ring_merge_config.status = APP_RING_MERGE_STATUS_RUNNING; - } - nRet = app_ring_merge_config.handler(buf, len); + osMutexWait(app_ring_merge_mutex_id, osWaitForever); + if (app_ring_merge_config.handler && + app_ring_merge_config.status != APP_RING_MERGE_STATUS_STOP) { + if (app_ring_merge_config.status == APP_RING_MERGE_STATUS_START) { + app_ring_merge_config.status = APP_RING_MERGE_STATUS_RUNNING; } - osMutexRelease(app_ring_merge_mutex_id); + nRet = app_ring_merge_config.handler(buf, len); + } + osMutexRelease(app_ring_merge_mutex_id); - return nRet; + return nRet; } -int app_ring_merge_setup(int16_t *buf, uint32_t len, enum APP_RING_MERGE_PLAY_T play) -{ - TRACE(3,"%s mode:%d len:%d", __func__, play, len); +int app_ring_merge_setup(int16_t *buf, uint32_t len, + enum APP_RING_MERGE_PLAY_T play) { + TRACE(3, "%s mode:%d len:%d", __func__, play, len); - osMutexWait(app_ring_merge_mutex_id, osWaitForever); + osMutexWait(app_ring_merge_mutex_id, osWaitForever); - app_ring_merge_config.status = APP_RING_MERGE_STATUS_STOP; - app_ring_merge_config.pbuf = ( int16_t * )buf; - app_ring_merge_config.len = len; - app_ring_merge_config.next = 0; + app_ring_merge_config.status = APP_RING_MERGE_STATUS_STOP; + app_ring_merge_config.pbuf = (int16_t *)buf; + app_ring_merge_config.len = len; + app_ring_merge_config.next = 0; - app_ring_merge_config.play = play; + app_ring_merge_config.play = play; - if (play == APP_RING_MERGE_PLAY_ONESHOT) - { - app_ring_merge_config.handler = app_ring_merge_oneshot_more_data; - } - else if (play == APP_RING_MERGE_PLAY_PERIODIC) - { - app_ring_merge_config.handler = app_ring_merge_periodic_more_data; - } + if (play == APP_RING_MERGE_PLAY_ONESHOT) { + app_ring_merge_config.handler = app_ring_merge_oneshot_more_data; + } else if (play == APP_RING_MERGE_PLAY_PERIODIC) { + app_ring_merge_config.handler = app_ring_merge_periodic_more_data; + } - osMutexRelease(app_ring_merge_mutex_id); + osMutexRelease(app_ring_merge_mutex_id); + return 0; +} + +int app_ring_merge_init(void) { + if (app_ring_merge_mutex_id == NULL) { + app_ring_merge_mutex_id = osMutexCreate((osMutex(app_ring_merge_mutex))); + } + + app_ring_merge_config.savedStoppedStreamId = -1; + return 0; +} + +int app_ring_merge_deinit(void) { + osMutexWait(app_ring_merge_mutex_id, osWaitForever); + + app_ring_merge_config.status = APP_RING_MERGE_STATUS_STOP; + app_ring_merge_config.pbuf = NULL; + app_ring_merge_config.len = 0; + app_ring_merge_config.next = 0; + app_ring_merge_config.bits = AUD_BITS_16; + app_ring_merge_config.play = APP_RING_MERGE_PLAY_QTY; + app_ring_merge_config.handler = NULL; + + app_ring_merge_config.savedStoppedStreamId = -1; + + osMutexRelease(app_ring_merge_mutex_id); + + return 0; +} + +int app_ring_merge_start(void) { + uint32_t ret; + struct AF_STREAM_CONFIG_T *stream_cfg = NULL; + + ret = af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg, + true); + if (ret != 0) { + TRACE(0, "Failed to get stream cfg"); return 0; -} + } + TRACE(4, "%s: sample_rate: %d, bits: %d, channel: %d\n", __func__, + stream_cfg->sample_rate, stream_cfg->bits, stream_cfg->channel_num); -int app_ring_merge_init(void) -{ - if (app_ring_merge_mutex_id == NULL) - { - app_ring_merge_mutex_id = osMutexCreate((osMutex(app_ring_merge_mutex))); - } - - app_ring_merge_config.savedStoppedStreamId = -1; - return 0; -} - -int app_ring_merge_deinit(void) -{ - osMutexWait(app_ring_merge_mutex_id, osWaitForever); - - app_ring_merge_config.status = APP_RING_MERGE_STATUS_STOP; - app_ring_merge_config.pbuf = NULL; - app_ring_merge_config.len = 0; - app_ring_merge_config.next = 0; - app_ring_merge_config.bits = AUD_BITS_16; - app_ring_merge_config.play = APP_RING_MERGE_PLAY_QTY; - app_ring_merge_config.handler = NULL; - - app_ring_merge_config.savedStoppedStreamId = -1; - - osMutexRelease(app_ring_merge_mutex_id); - - return 0; -} - -int app_ring_merge_start(void) -{ - uint32_t ret; - struct AF_STREAM_CONFIG_T *stream_cfg = NULL; - - ret = af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg, true); - if(ret != 0){ - TRACE(0,"Failed to get stream cfg"); - return 0; - } - TRACE(4,"%s: sample_rate: %d, bits: %d, channel: %d\n", - __func__, - stream_cfg->sample_rate, - stream_cfg->bits, - stream_cfg->channel_num); - - osMutexWait(app_ring_merge_mutex_id, osWaitForever); + osMutexWait(app_ring_merge_mutex_id, osWaitForever); #ifdef __BT_WARNING_TONE_MERGE_INTO_STREAM_SBC__ - switch (stream_cfg->sample_rate) - { - case AUD_SAMPRATE_8000: - app_ring_merge_setup(( int16_t * )RES_AUD_RING_SAMPRATE_8000, sizeof(RES_AUD_RING_SAMPRATE_8000) / sizeof(int16_t), APP_RING_MERGE_PLAY_ONESHOT); - app_ring_merge_config.next = 0; - app_ring_merge_config.status = APP_RING_MERGE_STATUS_START; - break; - case AUD_SAMPRATE_16000: - TRACE(0,"sample rate 16000 merge"); - app_ring_merge_setup(( int16_t * )RES_AUD_RING_SAMPRATE_16000, sizeof(RES_AUD_RING_SAMPRATE_16000) / sizeof(int16_t), APP_RING_MERGE_PLAY_ONESHOT); - app_ring_merge_config.next = 0; - app_ring_merge_config.status = APP_RING_MERGE_STATUS_START; - break; - case AUD_SAMPRATE_44100: - app_ring_merge_setup(( int16_t * )RES_AUD_RING_SAMPRATE_44100, sizeof(RES_AUD_RING_SAMPRATE_44100) / sizeof(int16_t), APP_RING_MERGE_PLAY_ONESHOT); - app_ring_merge_config.next = 0; - app_ring_merge_config.status = APP_RING_MERGE_STATUS_START; - break; - - case AUD_SAMPRATE_48000: - app_ring_merge_setup(( int16_t * )RES_AUD_RING_SAMPRATE_48000, sizeof(RES_AUD_RING_SAMPRATE_48000) / sizeof(int16_t), APP_RING_MERGE_PLAY_ONESHOT); - app_ring_merge_config.next = 0; - app_ring_merge_config.status = APP_RING_MERGE_STATUS_START; - break; - case AUD_SAMPRATE_22050: - case AUD_SAMPRATE_24000: - case AUD_SAMPRATE_96000: - case AUD_SAMPRATE_192000: - case AUD_SAMPRATE_NULL: - default: - app_ring_merge_config.next = 0; - app_ring_merge_config.status = APP_RING_MERGE_STATUS_START; - break; - } -#else - app_ring_merge_setup(( int16_t * )RES_AUD_RING_SAMPRATE_8000, + switch (stream_cfg->sample_rate) { + case AUD_SAMPRATE_8000: + app_ring_merge_setup((int16_t *)RES_AUD_RING_SAMPRATE_8000, sizeof(RES_AUD_RING_SAMPRATE_8000) / sizeof(int16_t), APP_RING_MERGE_PLAY_ONESHOT); - - app_ring_merge_config.next = 0; + app_ring_merge_config.next = 0; app_ring_merge_config.status = APP_RING_MERGE_STATUS_START; + break; + case AUD_SAMPRATE_16000: + TRACE(0, "sample rate 16000 merge"); + app_ring_merge_setup((int16_t *)RES_AUD_RING_SAMPRATE_16000, + sizeof(RES_AUD_RING_SAMPRATE_16000) / sizeof(int16_t), + APP_RING_MERGE_PLAY_ONESHOT); + app_ring_merge_config.next = 0; + app_ring_merge_config.status = APP_RING_MERGE_STATUS_START; + break; + case AUD_SAMPRATE_44100: + app_ring_merge_setup((int16_t *)RES_AUD_RING_SAMPRATE_44100, + sizeof(RES_AUD_RING_SAMPRATE_44100) / sizeof(int16_t), + APP_RING_MERGE_PLAY_ONESHOT); + app_ring_merge_config.next = 0; + app_ring_merge_config.status = APP_RING_MERGE_STATUS_START; + break; + + case AUD_SAMPRATE_48000: + app_ring_merge_setup((int16_t *)RES_AUD_RING_SAMPRATE_48000, + sizeof(RES_AUD_RING_SAMPRATE_48000) / sizeof(int16_t), + APP_RING_MERGE_PLAY_ONESHOT); + app_ring_merge_config.next = 0; + app_ring_merge_config.status = APP_RING_MERGE_STATUS_START; + break; + case AUD_SAMPRATE_22050: + case AUD_SAMPRATE_24000: + case AUD_SAMPRATE_96000: + case AUD_SAMPRATE_192000: + case AUD_SAMPRATE_NULL: + default: + app_ring_merge_config.next = 0; + app_ring_merge_config.status = APP_RING_MERGE_STATUS_START; + break; + } +#else + app_ring_merge_setup((int16_t *)RES_AUD_RING_SAMPRATE_8000, + sizeof(RES_AUD_RING_SAMPRATE_8000) / sizeof(int16_t), + APP_RING_MERGE_PLAY_ONESHOT); + + app_ring_merge_config.next = 0; + app_ring_merge_config.status = APP_RING_MERGE_STATUS_START; #endif - app_ring_merge_config.bits = stream_cfg->bits; + app_ring_merge_config.bits = stream_cfg->bits; - app_ring_merge_config.savedStoppedStreamId = -1; + app_ring_merge_config.savedStoppedStreamId = -1; - osMutexRelease(app_ring_merge_mutex_id); + osMutexRelease(app_ring_merge_mutex_id); - return 0; + return 0; } -int app_ring_merge_stop(void) -{ - osMutexWait(app_ring_merge_mutex_id, osWaitForever); - app_ring_merge_config.status = APP_RING_MERGE_STATUS_STOP; - app_ring_merge_config.next = 0; - osMutexRelease(app_ring_merge_mutex_id); +int app_ring_merge_stop(void) { + osMutexWait(app_ring_merge_mutex_id, osWaitForever); + app_ring_merge_config.status = APP_RING_MERGE_STATUS_STOP; + app_ring_merge_config.next = 0; + osMutexRelease(app_ring_merge_mutex_id); - app_ring_merge_finished_callback(); + app_ring_merge_finished_callback(); - return 0; + return 0; } -bool app_ring_merge_isrun(void) -{ - bool running = false; - osMutexWait(app_ring_merge_mutex_id, osWaitForever); - if (app_ring_merge_config.status == APP_RING_MERGE_STATUS_RUNNING) - { - running = true; +bool app_ring_merge_isrun(void) { + bool running = false; + osMutexWait(app_ring_merge_mutex_id, osWaitForever); + if (app_ring_merge_config.status == APP_RING_MERGE_STATUS_RUNNING) { + running = true; + } + osMutexRelease(app_ring_merge_mutex_id); + return running; +} + +void app_ring_merge_save_pending_start_stream_op(uint8_t pendingStopOp, + uint8_t deviceId) { + app_ring_merge_config.pendingStopOp = pendingStopOp; + app_ring_merge_config.savedStoppedStreamId = deviceId; +} + +static void app_ring_merge_finished_callback(void) { + TRACE(1, "%s", __func__); + app_ring_merge_config.status = APP_RING_MERGE_STATUS_STOP; + + if (app_ring_merge_config.savedStoppedStreamId >= 0) { + if (PENDING_TO_STOP_A2DP_STREAMING == app_ring_merge_config.pendingStopOp) { + TRACE(0, "Stop the pending stopped a2dp media stream."); + app_stop_a2dp_media_stream(app_ring_merge_config.savedStoppedStreamId); + } else if (PENDING_TO_STOP_SCO_STREAMING == + app_ring_merge_config.pendingStopOp) { + TRACE(0, "Stop the pending stopped sco media stream."); + app_stop_sco_media_stream(app_ring_merge_config.savedStoppedStreamId); } - osMutexRelease(app_ring_merge_mutex_id); - return running; -} - -void app_ring_merge_save_pending_start_stream_op(uint8_t pendingStopOp, uint8_t deviceId) -{ - app_ring_merge_config.pendingStopOp = pendingStopOp; - app_ring_merge_config.savedStoppedStreamId = deviceId; -} - -static void app_ring_merge_finished_callback(void) -{ - TRACE(1,"%s", __func__); - app_ring_merge_config.status = APP_RING_MERGE_STATUS_STOP; - - if (app_ring_merge_config.savedStoppedStreamId >= 0) - { - if (PENDING_TO_STOP_A2DP_STREAMING == app_ring_merge_config.pendingStopOp) - { - TRACE(0,"Stop the pending stopped a2dp media stream."); - app_stop_a2dp_media_stream(app_ring_merge_config.savedStoppedStreamId); - } - else if (PENDING_TO_STOP_SCO_STREAMING == app_ring_merge_config.pendingStopOp) - { - TRACE(0,"Stop the pending stopped sco media stream."); - app_stop_sco_media_stream(app_ring_merge_config.savedStoppedStreamId); - } - } - app_ring_merge_config.savedStoppedStreamId = -1; + } + app_ring_merge_config.savedStoppedStreamId = -1; } diff --git a/services/bt_app/app_ring_merge.h b/services/bt_app/app_ring_merge.h index 0fc647f..89dddab 100644 --- a/services/bt_app/app_ring_merge.h +++ b/services/bt_app/app_ring_merge.h @@ -16,19 +16,22 @@ #ifndef __APP_RING_MERGE_H__ #define __APP_RING_MERGE_H__ -enum APP_RING_MERGE_PLAY_T { - APP_RING_MERGE_PLAY_ONESHOT = 0, - APP_RING_MERGE_PLAY_PERIODIC, +#include - APP_RING_MERGE_PLAY_QTY = 0xff +enum APP_RING_MERGE_PLAY_T { + APP_RING_MERGE_PLAY_ONESHOT = 0, + APP_RING_MERGE_PLAY_PERIODIC, + + APP_RING_MERGE_PLAY_QTY = 0xff }; -#define PENDING_TO_STOP_A2DP_STREAMING 0 -#define PENDING_TO_STOP_SCO_STREAMING 1 +#define PENDING_TO_STOP_A2DP_STREAMING 0 +#define PENDING_TO_STOP_SCO_STREAMING 1 uint32_t app_ring_merge_more_data(uint8_t *buf, uint32_t len); -int app_ring_merge_setup(int16_t *buf, uint32_t len, enum APP_RING_MERGE_PLAY_T play); +int app_ring_merge_setup(int16_t *buf, uint32_t len, + enum APP_RING_MERGE_PLAY_T play); int app_ring_merge_init(void); @@ -40,8 +43,7 @@ int app_ring_merge_stop(void); bool app_ring_merge_isrun(void); -void app_ring_merge_save_pending_start_stream_op(uint8_t pendingStopOp, uint8_t deviceId); - +void app_ring_merge_save_pending_start_stream_op(uint8_t pendingStopOp, + uint8_t deviceId); #endif - diff --git a/services/bt_app/app_sec.cpp b/services/bt_app/app_sec.cpp index 0c8c003..48ab8db 100644 --- a/services/bt_app/app_sec.cpp +++ b/services/bt_app/app_sec.cpp @@ -14,54 +14,52 @@ * ****************************************************************************/ #include "apps.h" +#include "bt_if.h" #include "hal_trace.h" #include "me_api.h" -#include "bt_if.h" #include "nvrecord.h" #if defined(IBRT) #include "app_ibrt_if.h" #endif -void pair_handler_func(enum pair_event evt, const btif_event_t *event) -{ - switch(evt) { - case PAIR_EVENT_NUMERIC_REQ: - break; - case PAIR_EVENT_COMPLETE: +void pair_handler_func(enum pair_event evt, const btif_event_t *event) { + switch (evt) { + case PAIR_EVENT_NUMERIC_REQ: + break; + case PAIR_EVENT_COMPLETE: #if defined(_AUTO_TEST_) - AUTO_TEST_SEND("Pairing ok."); + AUTO_TEST_SEND("Pairing ok."); #endif #ifndef FPGA #ifdef MEDIA_PLAYER_SUPPORT - if (btif_me_get_callback_event_err_code(event) == BTIF_BEC_NO_ERROR) { + if (btif_me_get_callback_event_err_code(event) == BTIF_BEC_NO_ERROR) { #if defined(IBRT) - app_voice_report(APP_STATUS_INDICATION_PAIRSUCCEED,0); + app_voice_report(APP_STATUS_INDICATION_PAIRSUCCEED, 0); #endif - } else { - app_voice_report(APP_STATUS_INDICATION_PAIRFAIL,0); - } + } else { + app_voice_report(APP_STATUS_INDICATION_PAIRFAIL, 0); + } #endif #endif #if defined(IBRT) - if (app_ibrt_if_is_audio_active()){ - TRACE(0,"!!!!!!!!!! flash_touch"); - nv_record_execute_async_flush(); - }else{ - TRACE(0,"!!!!!!!!!! flash_flush"); - nv_record_flash_flush(); + if (app_ibrt_if_is_audio_active()) { + TRACE(0, "!!!!!!!!!! flash_touch"); + nv_record_execute_async_flush(); + } else { + TRACE(0, "!!!!!!!!!! flash_flush"); + nv_record_flash_flush(); } #elif !defined(__BT_ONE_BRING_TWO__) - nv_record_flash_flush(); + nv_record_flash_flush(); #endif - break; - default: - break; - } + break; + default: + break; + } } -void auth_handler_func(void) -{ - /*currently do nothing*/ - return; +void auth_handler_func(void) { + /*currently do nothing*/ + return; } diff --git a/services/bt_app/app_spp.cpp b/services/bt_app/app_spp.cpp index ab9f007..8e4f463 100644 --- a/services/bt_app/app_spp.cpp +++ b/services/bt_app/app_spp.cpp @@ -13,97 +13,90 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "cmsis_os.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_trace.h" -#include "hal_cmu.h" -#include "hal_chipid.h" #include "analog.h" #include "app_audio.h" -#include "app_status_ind.h" #include "app_bt_stream.h" +#include "app_status_ind.h" +#include "audioflinger.h" +#include "cmsis_os.h" +#include "hal_chipid.h" +#include "hal_cmu.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "lockcqueue.h" #include "nvrecord.h" -#include "nvrecord_env.h" #include "nvrecord_dev.h" +#include "nvrecord_env.h" #include "umm_malloc.h" +#include +#include "app_spp.h" #include "cqueue.h" -#include "resources.h" -#include "app_spp.h" -#include "spp_api.h" -#include "sdp_api.h" -#include "app_spp.h" #include "plat_types.h" +#include "resources.h" +#include "sdp_api.h" +#include "spp_api.h" -#define SPP_MAX_PACKET_NUM 10 +#define SPP_MAX_PACKET_NUM 10 -struct spp_device *app_create_spp_device(void) -{ - return btif_create_spp_device(); +struct spp_device *app_create_spp_device(void) { + return btif_create_spp_device(); } -bt_status_t app_spp_send_data(struct spp_device *osDev_t, uint8_t* ptrData, uint16_t *length) -{ - bt_status_t status = BT_STS_FAILED; - uint8_t *ptrBuf = NULL; - uint16_t len = *length; - - if(!osDev_t->spp_connected_flag) { - TRACE(1,"%s spp don't connect\n", __func__); - return status; - } - - TRACE(2,"%s length %d", __func__, len); - //DUMP8("0x%02x ",ptrData,length); - - ptrBuf = (uint8_t *)umm_malloc(len); - if(NULL == ptrBuf) { - TRACE(1,"%s failed to malloc for tx buffer", __func__); - return status; - } - memcpy(ptrBuf, ptrData, len); - - status = btif_spp_write(osDev_t, (char *)ptrBuf, length); - if(status != BT_STS_SUCCESS) { - TRACE(2,"%s spp send error status %d", __func__, status); - umm_free(( void * )ptrBuf); - } +bt_status_t app_spp_send_data(struct spp_device *osDev_t, uint8_t *ptrData, + uint16_t *length) { + bt_status_t status = BT_STS_FAILED; + uint8_t *ptrBuf = NULL; + uint16_t len = *length; + if (!osDev_t->spp_connected_flag) { + TRACE(1, "%s spp don't connect\n", __func__); return status; + } + + TRACE(2, "%s length %d", __func__, len); + // DUMP8("0x%02x ",ptrData,length); + + ptrBuf = (uint8_t *)umm_malloc(len); + if (NULL == ptrBuf) { + TRACE(1, "%s failed to malloc for tx buffer", __func__); + return status; + } + memcpy(ptrBuf, ptrData, len); + + status = btif_spp_write(osDev_t, (char *)ptrBuf, length); + if (status != BT_STS_SUCCESS) { + TRACE(2, "%s spp send error status %d", __func__, status); + umm_free((void *)ptrBuf); + } + + return status; } -void app_spp_open(struct spp_device *osDev_t, - btif_remote_device_t *btDevice, - btif_sdp_record_param_t *param, - osMutexId mid, - uint8_t service_id, - spp_callback_t callback) -{ - btif_sdp_record_t *spp_sdp_record = NULL; +void app_spp_open(struct spp_device *osDev_t, btif_remote_device_t *btDevice, + btif_sdp_record_param_t *param, osMutexId mid, + uint8_t service_id, spp_callback_t callback) { + btif_sdp_record_t *spp_sdp_record = NULL; #if SPP_SERVER == XA_ENABLED - struct spp_service *spp_service_t; + struct spp_service *spp_service_t; - if(osDev_t->portType == BTIF_SPP_SERVER_PORT) { - spp_service_t = btif_create_spp_service(); - spp_service_t->rf_service.serviceId = service_id; - spp_service_t->numPorts = 0; + if (osDev_t->portType == BTIF_SPP_SERVER_PORT) { + spp_service_t = btif_create_spp_service(); + spp_service_t->rf_service.serviceId = service_id; + spp_service_t->numPorts = 0; - spp_sdp_record = btif_sdp_create_record(); - btif_sdp_record_setup(spp_sdp_record, param); - btif_spp_service_setup(osDev_t, spp_service_t, spp_sdp_record); - } + spp_sdp_record = btif_sdp_create_record(); + btif_sdp_record_setup(spp_sdp_record, param); + btif_spp_service_setup(osDev_t, spp_service_t, spp_sdp_record); + } #endif - btif_spp_init_device(osDev_t, SPP_MAX_PACKET_NUM, mid); - btif_spp_open(osDev_t, btDevice, callback); + btif_spp_init_device(osDev_t, SPP_MAX_PACKET_NUM, mid); + btif_spp_open(osDev_t, btDevice, callback); } - #if defined(__BQB_PROFILE_TEST__) #if 1 @@ -113,49 +106,44 @@ static uint8_t spp_test_rx_buf[SPP_RECV_BUFFER_SIZE]; #define TEST_PORT_SPP 0x1101 static const uint8_t SppTestSearchReq[] = { /* First parameter is the search pattern in data element format. It - * is a list of 3 UUIDs. - */ + * is a list of 3 UUIDs. + */ /* Data Element Sequence, 9 bytes */ - SDP_ATTRIB_HEADER_8BIT(9), - SDP_UUID_16BIT(TEST_PORT_SPP), + SDP_ATTRIB_HEADER_8BIT(9), SDP_UUID_16BIT(TEST_PORT_SPP), SDP_UUID_16BIT(PROT_L2CAP), /* L2CAP UUID in Big Endian */ SDP_UUID_16BIT(PROT_RFCOMM), /* UUID for RFCOMM in Big Endian */ /* The second parameter is the maximum number of bytes that can be - * be received for the attribute list. - */ - 0x00, - 0x64, /* Max number of bytes for attribute is 100 */ - SDP_ATTRIB_HEADER_8BIT(9), - SDP_UINT_16BIT(AID_PROTOCOL_DESC_LIST), + * be received for the attribute list. + */ + 0x00, 0x64, /* Max number of bytes for attribute is 100 */ + SDP_ATTRIB_HEADER_8BIT(9), SDP_UINT_16BIT(AID_PROTOCOL_DESC_LIST), SDP_UINT_16BIT(AID_BT_PROFILE_DESC_LIST), - SDP_UINT_16BIT(AID_ADDITIONAL_PROT_DESC_LISTS) -}; -int spp_test_handle_data_event_func(void *pDev, uint8_t process, uint8_t *pData, uint16_t dataLen) -{ - TRACE(1,"%s", __func__); - return 0; + SDP_UINT_16BIT(AID_ADDITIONAL_PROT_DESC_LISTS)}; +int spp_test_handle_data_event_func(void *pDev, uint8_t process, uint8_t *pData, + uint16_t dataLen) { + TRACE(1, "%s", __func__); + return 0; } -static void spp_test_client_callback(struct spp_device *locDev, struct spp_callback_parms *Info) -{ - TRACE(2,"%s event %d", __func__, Info->event); - switch (Info->event) - { - case BTIF_SPP_EVENT_REMDEV_CONNECTED: - TRACE(1,"::SPP_EVENT_REMDEV_CONNECTED %d\n", Info->event); - break; +static void spp_test_client_callback(struct spp_device *locDev, + struct spp_callback_parms *Info) { + TRACE(2, "%s event %d", __func__, Info->event); + switch (Info->event) { + case BTIF_SPP_EVENT_REMDEV_CONNECTED: + TRACE(1, "::SPP_EVENT_REMDEV_CONNECTED %d\n", Info->event); + break; - case BTIF_SPP_EVENT_REMDEV_DISCONNECTED: - TRACE(1,"::SPP_EVENT_REMDEV_DISCONNECTED %d\n", Info->event); - break; + case BTIF_SPP_EVENT_REMDEV_DISCONNECTED: + TRACE(1, "::SPP_EVENT_REMDEV_DISCONNECTED %d\n", Info->event); + break; - case BTIF_SPP_EVENT_DATA_SENT: - TRACE(1,"::SPP_EVENT_DATA_SENT %d\n", Info->event); - break; - - default: - TRACE(1,"::unknown event %d\n", Info->event); - break; - } + case BTIF_SPP_EVENT_DATA_SENT: + TRACE(1, "::SPP_EVENT_DATA_SENT %d\n", Info->event); + break; + + default: + TRACE(1, "::unknown event %d\n", Info->event); + break; + } } #endif @@ -191,67 +179,57 @@ void app_spp_test_client_open(btif_remote_device_t *remote_device) } #endif -void pts_spp_client_init(void) -{ - TRACE(1,"[%s]", __func__); - //bt_status_t status; - osMutexId mid; +void pts_spp_client_init(void) { + TRACE(1, "[%s]", __func__); + // bt_status_t status; + osMutexId mid; - if(spp_test_dev == NULL) - spp_test_dev = app_create_spp_device(); - //app_spp_init_tx_buf(NULL); - btif_spp_init_rx_buf(spp_test_dev, spp_test_rx_buf, SPP_RECV_BUFFER_SIZE); + if (spp_test_dev == NULL) + spp_test_dev = app_create_spp_device(); + // app_spp_init_tx_buf(NULL); + btif_spp_init_rx_buf(spp_test_dev, spp_test_rx_buf, SPP_RECV_BUFFER_SIZE); - mid = osMutexCreate(osMutex(client_spp_test_mutex)); - if (!mid) - { - ASSERT(0, "cannot create mutex"); - } - spp_test_dev->portType = BTIF_SPP_CLIENT_PORT; - spp_test_dev->app_id = 0x8000; - spp_test_dev->spp_handle_data_event_func = spp_test_handle_data_event_func; + mid = osMutexCreate(osMutex(client_spp_test_mutex)); + if (!mid) { + ASSERT(0, "cannot create mutex"); + } + spp_test_dev->portType = BTIF_SPP_CLIENT_PORT; + spp_test_dev->app_id = 0x8000; + spp_test_dev->spp_handle_data_event_func = spp_test_handle_data_event_func; - btif_spp_init_device(spp_test_dev, SPP_MAX_PACKET_NUM, mid); + btif_spp_init_device(spp_test_dev, SPP_MAX_PACKET_NUM, mid); - spp_test_dev->sppDev.type.client.rfcommServiceSearchRequestPtr = (uint8_t*)SppTestSearchReq; - spp_test_dev->sppDev.type.client.rfcommServiceSearchRequestLen = sizeof(SppTestSearchReq); + spp_test_dev->sppDev.type.client.rfcommServiceSearchRequestPtr = + (uint8_t *)SppTestSearchReq; + spp_test_dev->sppDev.type.client.rfcommServiceSearchRequestLen = + sizeof(SppTestSearchReq); } #include "conmgr_api.h" -btif_remote_device_t *btif_cmgr_pts_get_remDev(btif_cmgr_handler_t *cmgr_handler); -extern btif_cmgr_handler_t* pts_cmgr_handler; -void pts_cmgr_callback(btif_cmgr_handler_t *cHandler, - cmgr_event_t Event, - bt_status_t Status) -{ - btif_remote_device_t *remDev = btif_cmgr_pts_get_remDev(pts_cmgr_handler); +btif_remote_device_t * +btif_cmgr_pts_get_remDev(btif_cmgr_handler_t *cmgr_handler); +extern btif_cmgr_handler_t *pts_cmgr_handler; +void pts_cmgr_callback(btif_cmgr_handler_t *cHandler, cmgr_event_t Event, + bt_status_t Status) { + btif_remote_device_t *remDev = btif_cmgr_pts_get_remDev(pts_cmgr_handler); - TRACE(2,"%s Event %d", __func__, Event); - if (Event == BTIF_BTEVENT_LINK_CONNECT_IND || - Event == BTIF_BTEVENT_LINK_CONNECT_CNF) - { - if (Status == BT_STS_SUCCESS) - { - TRACE(2,"connect ok cHandler %p remDev=%x",cHandler, remDev); - btif_spp_open(spp_test_dev, remDev, spp_test_client_callback); - } - else - { - TRACE(0,"connect failed"); - } + TRACE(2, "%s Event %d", __func__, Event); + if (Event == BTIF_BTEVENT_LINK_CONNECT_IND || + Event == BTIF_BTEVENT_LINK_CONNECT_CNF) { + if (Status == BT_STS_SUCCESS) { + TRACE(2, "connect ok cHandler %p remDev=%x", cHandler, remDev); + btif_spp_open(spp_test_dev, remDev, spp_test_client_callback); + } else { + TRACE(0, "connect failed"); } + } - if (Event == BTIF_BTEVENT_LINK_DISCONNECT) - { - if (Status == BT_STS_SUCCESS) - { - TRACE(0,"disconnect ok"); - } - else - { - TRACE(0,"disconnect failed"); - } + if (Event == BTIF_BTEVENT_LINK_DISCONNECT) { + if (Status == BT_STS_SUCCESS) { + TRACE(0, "disconnect ok"); + } else { + TRACE(0, "disconnect failed"); } + } } #endif - diff --git a/services/bt_app/audio_prompt_sbc.cpp b/services/bt_app/audio_prompt_sbc.cpp index ba87c83..fbe16ab 100644 --- a/services/bt_app/audio_prompt_sbc.cpp +++ b/services/bt_app/audio_prompt_sbc.cpp @@ -1,26 +1,25 @@ #include "audio_prompt_sbc.h" -#include "hal_trace.h" -#include "string.h" -#include "app_bt_stream.h" #include "app_bt_media_manager.h" +#include "app_bt_stream.h" #include "app_utils.h" #include "cmsis.h" +#include "hal_trace.h" +#include "string.h" - -#include "bt_drv_interface.h" -#include "audioflinger.h" #include "app_media_player.h" +#include "audioflinger.h" +#include "bt_drv_interface.h" #if defined(IBRT) +#include "app_ibrt_if.h" +#include "app_tws_ctrl_thread.h" #include "app_tws_ibrt.h" #include "app_tws_ibrt_cmd_handler.h" -#include "app_tws_ctrl_thread.h" -#include "app_ibrt_if.h" #endif #include "app_audio.h" #include "apps.h" #ifdef MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED -#define AUDIO_PROMPT_RESAMPLE_ITER_NUM 256 +#define AUDIO_PROMPT_RESAMPLE_ITER_NUM 256 #ifdef TWS_PROMPT_SYNC extern void tws_sync_mix_prompt_start_handling(void); @@ -28,1047 +27,996 @@ extern void tws_reset_mix_prompt_trigger_ticks(void); extern void tws_enable_mix_prompt(bool isEnable); #endif - extern void app_stop_a2dp_media_stream(uint8_t devId); extern void app_stop_sco_media_stream(uint8_t devId); -extern void app_bt_stream_copy_track_one_to_two_16bits(int16_t *dst_buf, int16_t *src_buf, uint32_t src_len); +extern void app_bt_stream_copy_track_one_to_two_16bits(int16_t *dst_buf, + int16_t *src_buf, + uint32_t src_len); -static uint32_t audio_prompt_sbc_decode(uint8_t* pcm_buffer, uint32_t expectedOutputSize, uint8_t isReset); +static uint32_t audio_prompt_sbc_decode(uint8_t *pcm_buffer, + uint32_t expectedOutputSize, + uint8_t isReset); static btif_sbc_decoder_t audio_prompt_sbc_decoder; static float audio_prompt_sbc_eq_band_gain[8] = {1, 1, 1, 1, 1, 1, 1, 1}; // keep the current volume -#define KEEP_CURRENT_VOLUME_FOR_MIX_PROMPT -1 +#define KEEP_CURRENT_VOLUME_FOR_MIX_PROMPT -1 // from TGT_VOLUME_LEVEL_T or KEEP_CURRENT_VOLUME_FOR_MIX_PROMPT -#define DEFAULT_VOLUME_FOR_MIX_PROMPT KEEP_CURRENT_VOLUME_FOR_MIX_PROMPT +#define DEFAULT_VOLUME_FOR_MIX_PROMPT KEEP_CURRENT_VOLUME_FOR_MIX_PROMPT -#define DEFAULT_COEFF_FOR_MIX_PROMPT_FOR_MUSIC 1.0 -#define DEFAULT_COEFF_FOR_MIX_MUSIC_FOR_MUSIC 0.4 -#define DEFAULT_COEFF_FOR_MIX_PROMPT_FOR_CALL 1.0 -#define DEFAULT_COEFF_FOR_MIX_CALL_FOR_CALL 0.4 +#define DEFAULT_COEFF_FOR_MIX_PROMPT_FOR_MUSIC 1.0 +#define DEFAULT_COEFF_FOR_MIX_MUSIC_FOR_MUSIC 0.4 +#define DEFAULT_COEFF_FOR_MIX_PROMPT_FOR_CALL 1.0 +#define DEFAULT_COEFF_FOR_MIX_CALL_FOR_CALL 0.4 #define DEFAULT_OVERLAP_LENGTH 128 -static int audio_prompt_sbc_init_decoder(void) -{ - btif_sbc_init_decoder(&audio_prompt_sbc_decoder); - return 0; +static int audio_prompt_sbc_init_decoder(void) { + btif_sbc_init_decoder(&audio_prompt_sbc_decoder); + return 0; } -typedef struct -{ - uint32_t wholeEncodedDataLen; - uint32_t leftEncodedDataLen; - uint8_t* promptDataBuf; - uint16_t tmpSourcePcmDataLen; - uint16_t tmpSourcePcmDataOutIndex; - uint8_t* tmpSourcePcmDataBuf; - uint8_t* tmpTargetPcmDataBuf; - CQueue pcmDataQueue; - uint8_t isResetDecoder; - uint8_t isAudioPromptDecodingDone; - uint8_t targetBytesCntPerSample; - uint32_t targetSampleRate; - struct APP_RESAMPLE_T * resampler; - uint32_t targetPcmChunkSize; - float resampleRatio; - uint8_t* bufForResampler; - uint32_t resampleBufLen; - uint8_t pendingStopOp; - int8_t savedStoppedStreamId; - uint8_t targetChannelCnt; - uint8_t mixType; - uint16_t promptId; - int16_t volume_level_override; - uint16_t promptPram; - float coeff_for_mix_prompt_for_music; - float coeff_for_mix_music_for_music; - float coeff_for_mix_prompt_for_call; - float coeff_for_mix_call_for_call; - uint8_t isMixPromptOn; - int16_t currentVol; - uint16_t mergeInOverlapLength; - uint16_t mergeOutOverlapLength; - float mergeInWeight; - float mergeOutWeight; - float mergeStep; +typedef struct { + uint32_t wholeEncodedDataLen; + uint32_t leftEncodedDataLen; + uint8_t *promptDataBuf; + uint16_t tmpSourcePcmDataLen; + uint16_t tmpSourcePcmDataOutIndex; + uint8_t *tmpSourcePcmDataBuf; + uint8_t *tmpTargetPcmDataBuf; + CQueue pcmDataQueue; + uint8_t isResetDecoder; + uint8_t isAudioPromptDecodingDone; + uint8_t targetBytesCntPerSample; + uint32_t targetSampleRate; + struct APP_RESAMPLE_T *resampler; + uint32_t targetPcmChunkSize; + float resampleRatio; + uint8_t *bufForResampler; + uint32_t resampleBufLen; + uint8_t pendingStopOp; + int8_t savedStoppedStreamId; + uint8_t targetChannelCnt; + uint8_t mixType; + uint16_t promptId; + int16_t volume_level_override; + uint16_t promptPram; + float coeff_for_mix_prompt_for_music; + float coeff_for_mix_music_for_music; + float coeff_for_mix_prompt_for_call; + float coeff_for_mix_call_for_call; + uint8_t isMixPromptOn; + int16_t currentVol; + uint16_t mergeInOverlapLength; + uint16_t mergeOutOverlapLength; + float mergeInWeight; + float mergeOutWeight; + float mergeStep; } AUDIO_PROMPT_ENV_T; static AUDIO_PROMPT_ENV_T audio_prompt_env; -static void audio_prompt_set_pending_stop_op(uint8_t op) -{ - audio_prompt_env.pendingStopOp = op; - TRACE(1,"pendingStopOp is set to %d", op); +static void audio_prompt_set_pending_stop_op(uint8_t op) { + audio_prompt_env.pendingStopOp = op; + TRACE(1, "pendingStopOp is set to %d", op); } -static uint8_t audio_prompt_get_pending_stop_op(void) -{ - return audio_prompt_env.pendingStopOp; +static uint8_t audio_prompt_get_pending_stop_op(void) { + return audio_prompt_env.pendingStopOp; } -static void audio_prompt_set_saved_stopped_stream_id(int8_t id) -{ - audio_prompt_env.savedStoppedStreamId = id; - TRACE(1,"savedStoppedStreamId is set to %d", id); +static void audio_prompt_set_saved_stopped_stream_id(int8_t id) { + audio_prompt_env.savedStoppedStreamId = id; + TRACE(1, "savedStoppedStreamId is set to %d", id); } -static int8_t audio_prompt_get_saved_stopped_stream_id(void) -{ - return audio_prompt_env.savedStoppedStreamId; +static int8_t audio_prompt_get_saved_stopped_stream_id(void) { + return audio_prompt_env.savedStoppedStreamId; } -void audio_prompt_init_handler(void) -{ - memset((uint8_t *)&audio_prompt_env, 0, sizeof(audio_prompt_env)); - audio_prompt_set_saved_stopped_stream_id(-1); +void audio_prompt_init_handler(void) { + memset((uint8_t *)&audio_prompt_env, 0, sizeof(audio_prompt_env)); + audio_prompt_set_saved_stopped_stream_id(-1); } -bool audio_prompt_is_allow_update_volume(void) -{ - bool isAllow = true; +bool audio_prompt_is_allow_update_volume(void) { + bool isAllow = true; - uint32_t lock = int_lock_global(); + uint32_t lock = int_lock_global(); - isAllow= (!(audio_prompt_env.isMixPromptOn))|| - (KEEP_CURRENT_VOLUME_FOR_MIX_PROMPT == - audio_prompt_env.volume_level_override); + isAllow = (!(audio_prompt_env.isMixPromptOn)) || + (KEEP_CURRENT_VOLUME_FOR_MIX_PROMPT == + audio_prompt_env.volume_level_override); - int_unlock_global(lock); + int_unlock_global(lock); - return isAllow; + return isAllow; } -bool audio_prompt_is_playing_ongoing(void) -{ - bool isPlayingOnGoing = false; - uint32_t lock = int_lock_global(); - if (audio_prompt_env.isMixPromptOn) - { - isPlayingOnGoing = true; - } - int_unlock_global(lock); - return isPlayingOnGoing; +bool audio_prompt_is_playing_ongoing(void) { + bool isPlayingOnGoing = false; + uint32_t lock = int_lock_global(); + if (audio_prompt_env.isMixPromptOn) { + isPlayingOnGoing = true; + } + int_unlock_global(lock); + return isPlayingOnGoing; } #ifdef TWS_PROMPT_SYNC -#define MEDIA_SHORT_TRIGGER_DELAY 8 -#define MEDIA_LONG_TRIGGER_DELAY 12 +#define MEDIA_SHORT_TRIGGER_DELAY 8 +#define MEDIA_LONG_TRIGGER_DELAY 12 -#define PROMPT_TICKS_OFFSET_TO_TRIGGER_MIX 10 // 3.25 ms +#define PROMPT_TICKS_OFFSET_TO_TRIGGER_MIX 10 // 3.25 ms static uint32_t mix_prompt_trigger_ticks = 0; static uint32_t playback_interval_in_ticks = 0; static uint32_t playback_last_irq_ticks = 0; static uint8_t isStartMixPrompt = false; -static uint32_t get_prompt_trigger_delay(uint16_t promptId) -{ - switch (promptId) - { - case AUDIO_ID_BT_GSOUND_MIC_OPEN: - case AUDIO_ID_BT_GSOUND_MIC_CLOSE: - // TODO: add more case for specific prompts here if you wanna it played sooner - return MEDIA_SHORT_TRIGGER_DELAY; - default: - return MEDIA_LONG_TRIGGER_DELAY; - } +static uint32_t get_prompt_trigger_delay(uint16_t promptId) { + switch (promptId) { + case AUDIO_ID_BT_GSOUND_MIC_OPEN: + case AUDIO_ID_BT_GSOUND_MIC_CLOSE: + // TODO: add more case for specific prompts here if you wanna it played + // sooner + return MEDIA_SHORT_TRIGGER_DELAY; + default: + return MEDIA_LONG_TRIGGER_DELAY; + } } -bool tws_calculate_mix_prompt_trigger_ticks(uint16_t promptId) -{ - if (0 == mix_prompt_trigger_ticks) - { - if ((playback_interval_in_ticks > 0)&&(playback_last_irq_ticks > 0)) - { - mix_prompt_trigger_ticks = playback_last_irq_ticks+ - get_prompt_trigger_delay(promptId)*playback_interval_in_ticks; - //TRACE(1,"playback_last_irq_ticks %d",playback_last_irq_ticks); - //TRACE(2,"playback_interval_in_ticks %d mix_prompt_trigger_ticks %d",playback_interval_in_ticks, mix_prompt_trigger_ticks); - return true; - } +bool tws_calculate_mix_prompt_trigger_ticks(uint16_t promptId) { + if (0 == mix_prompt_trigger_ticks) { + if ((playback_interval_in_ticks > 0) && (playback_last_irq_ticks > 0)) { + mix_prompt_trigger_ticks = + playback_last_irq_ticks + + get_prompt_trigger_delay(promptId) * playback_interval_in_ticks; + // TRACE(1,"playback_last_irq_ticks %d",playback_last_irq_ticks); + // TRACE(2,"playback_interval_in_ticks %d mix_prompt_trigger_ticks + // %d",playback_interval_in_ticks, mix_prompt_trigger_ticks); + return true; } + } + return false; +} + +void tws_enable_mix_prompt(bool isEnable) { + TRACE(1, "isStartMixPrompt to %d.", isEnable); + isStartMixPrompt = isEnable; +} + +void tws_set_mix_prompt_trigger_ticks(uint32_t ticks) { + mix_prompt_trigger_ticks = ticks; +} + +void tws_sync_mix_prompt_start_handling(void) { + if (!app_tws_ibrt_tws_link_connected()) { + tws_enable_mix_prompt(true); + } else { + tws_enable_mix_prompt(false); + } +} + +bool tws_is_mix_prompt_allowed_to_start(void) { return isStartMixPrompt; } + +void app_ibrt_send_mix_prompt_req(void) { + if (app_tws_ibrt_tws_link_connected()) { + APP_TWS_CMD_MIX_PROMPT_SYNC_T req; + req.promptId = audio_prompt_get_prompt_id(); + req.promptPram = audio_prompt_env.promptPram; + req.trigger_time = mix_prompt_trigger_ticks; + req.sampleRate = audio_prompt_get_sample_rate(); + tws_ctrl_send_cmd(APP_TWS_CMD_SYNC_MIX_PROMPT_REQ, (uint8_t *)&req, + sizeof(APP_TWS_CMD_MIX_PROMPT_SYNC_T)); + } +} + +bool tws_sync_mix_prompt_handling(void) { + if (!tws_is_mix_prompt_allowed_to_start()) { + if (tws_calculate_mix_prompt_trigger_ticks(audio_prompt_get_prompt_id())) { + // get the trigger ticks, send request to slave + app_ibrt_send_mix_prompt_req(); + } return false; + } else { + return true; + } } -void tws_enable_mix_prompt(bool isEnable) -{ - TRACE(1,"isStartMixPrompt to %d.", isEnable); - isStartMixPrompt = isEnable; +uint32_t tws_get_mix_prompt_trigger_ticks(void) { + return mix_prompt_trigger_ticks; } -void tws_set_mix_prompt_trigger_ticks(uint32_t ticks) -{ - mix_prompt_trigger_ticks = ticks; +void tws_reset_mix_prompt_trigger_ticks(void) { + mix_prompt_trigger_ticks = 0; + playback_interval_in_ticks = 0; + playback_last_irq_ticks = 0; + isStartMixPrompt = false; } -void tws_sync_mix_prompt_start_handling(void) -{ - if (!app_tws_ibrt_tws_link_connected()) - { - tws_enable_mix_prompt(true); - } - else - { - tws_enable_mix_prompt(false); - } +void app_tws_stop_peer_prompt(void) { + uint8_t stub_param = 0; + + tws_ctrl_send_cmd(APP_TWS_CMD_STOP_PEER_PROMPT_REQ, &stub_param, + sizeof(stub_param)); } -bool tws_is_mix_prompt_allowed_to_start(void) -{ - return isStartMixPrompt; +void tws_playback_ticks_check_for_mix_prompt(void) { + if ((!audio_prompt_is_playing_ongoing()) || + tws_is_mix_prompt_allowed_to_start()) { + // TRACE(0,"check for mix prompt<1>"); + return; + } + + uint32_t curr_ticks = 0; + uint16_t conhandle = INVALID_HANDLE; + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + + uint32_t btclk; + uint16_t btcnt; + int32_t offset; + + if (app_tws_ibrt_mobile_link_connected()) { + conhandle = p_ibrt_ctrl->mobile_conhandle; + } else if (app_tws_ibrt_slave_ibrt_link_connected()) { + conhandle = p_ibrt_ctrl->ibrt_conhandle; + } else { + TRACE(0, "check for mix prompt<2>"); + tws_enable_mix_prompt(true); + return; + } + + bt_drv_reg_op_dma_tc_clkcnt_get(&btclk, &btcnt); + if (conhandle >= 0x80) { + offset = bt_syn_get_offset_ticks(conhandle); + } else { + offset = 0; + } + curr_ticks = (2 * btclk + offset) & 0x0fffffff; + + if (mix_prompt_trigger_ticks > 0) { + if (curr_ticks >= mix_prompt_trigger_ticks) { + TRACE(2, "ticks<1> %d - trigger ticks %d", curr_ticks, + mix_prompt_trigger_ticks); + tws_enable_mix_prompt(true); + } else if ((curr_ticks < mix_prompt_trigger_ticks) && + ((mix_prompt_trigger_ticks - curr_ticks) < + PROMPT_TICKS_OFFSET_TO_TRIGGER_MIX)) { + TRACE(2, "ticks<2> %d - trigger ticks %d", curr_ticks, + mix_prompt_trigger_ticks); + tws_enable_mix_prompt(true); + } + } + + if (0 != playback_last_irq_ticks) { + playback_interval_in_ticks = curr_ticks - playback_last_irq_ticks; + } + + playback_last_irq_ticks = curr_ticks; } -void app_ibrt_send_mix_prompt_req(void) -{ - if (app_tws_ibrt_tws_link_connected()) - { - APP_TWS_CMD_MIX_PROMPT_SYNC_T req; - req.promptId = audio_prompt_get_prompt_id(); - req.promptPram = audio_prompt_env.promptPram; - req.trigger_time = mix_prompt_trigger_ticks; - req.sampleRate = audio_prompt_get_sample_rate(); - tws_ctrl_send_cmd(APP_TWS_CMD_SYNC_MIX_PROMPT_REQ,(uint8_t*)&req,sizeof(APP_TWS_CMD_MIX_PROMPT_SYNC_T)); - } -} +void app_tws_cmd_sync_mix_prompt_req_handler(uint8_t *ptrParam, + uint16_t paramLen) { + uint16_t promptPram = 0xFFFF; + uint32_t curr_ticks = 0xFFFFFFFF; + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); -bool tws_sync_mix_prompt_handling(void) -{ - if (!tws_is_mix_prompt_allowed_to_start()) - { - if (tws_calculate_mix_prompt_trigger_ticks(audio_prompt_get_prompt_id())) - { - // get the trigger ticks, send request to slave - app_ibrt_send_mix_prompt_req(); - } - return false; - } - else - { - return true; - } -} + APP_TWS_CMD_MIX_PROMPT_SYNC_T *pReq = + (APP_TWS_CMD_MIX_PROMPT_SYNC_T *)ptrParam; + TRACE(2, "promptId, trigger_time:0x%x, %d", pReq->promptId, + pReq->trigger_time); -uint32_t tws_get_mix_prompt_trigger_ticks(void) -{ - return mix_prompt_trigger_ticks; -} + audio_prompt_stop_playing(); -void tws_reset_mix_prompt_trigger_ticks(void) -{ - mix_prompt_trigger_ticks = 0; - playback_interval_in_ticks = 0; - playback_last_irq_ticks = 0; - isStartMixPrompt = false; -} + if (app_tws_ibrt_slave_ibrt_link_connected()) { + curr_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle); + } -void app_tws_stop_peer_prompt(void) -{ - uint8_t stub_param = 0; + if ((!app_tws_ibrt_slave_ibrt_link_connected()) || + ((curr_ticks > pReq->trigger_time) && + ((curr_ticks - pReq->trigger_time) > + PROMPT_TICKS_OFFSET_TO_TRIGGER_MIX))) { + TRACE(0, "return directly."); + return; + } - tws_ctrl_send_cmd(APP_TWS_CMD_STOP_PEER_PROMPT_REQ, &stub_param, sizeof(stub_param)); -} - -void tws_playback_ticks_check_for_mix_prompt(void) -{ - if ((!audio_prompt_is_playing_ongoing()) || tws_is_mix_prompt_allowed_to_start()) - { - //TRACE(0,"check for mix prompt<1>"); - return; - } - - uint32_t curr_ticks = 0; - uint16_t conhandle = INVALID_HANDLE; - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - - uint32_t btclk; - uint16_t btcnt; - int32_t offset; - - if (app_tws_ibrt_mobile_link_connected()){ - conhandle = p_ibrt_ctrl->mobile_conhandle; - }else if (app_tws_ibrt_slave_ibrt_link_connected()){ - conhandle = p_ibrt_ctrl->ibrt_conhandle; - }else{ - TRACE(0,"check for mix prompt<2>"); - tws_enable_mix_prompt(true); - return; - } - - bt_drv_reg_op_dma_tc_clkcnt_get(&btclk, &btcnt); - if(conhandle>=0x80){ - offset = bt_syn_get_offset_ticks(conhandle); - }else{ - offset = 0; - } - curr_ticks = (2*btclk + offset) & 0x0fffffff; - - if (mix_prompt_trigger_ticks > 0) - { - if (curr_ticks >= mix_prompt_trigger_ticks) - { - TRACE(2,"ticks<1> %d - trigger ticks %d", curr_ticks,mix_prompt_trigger_ticks); - tws_enable_mix_prompt(true); - } - else if ((curr_ticks < mix_prompt_trigger_ticks) && - ((mix_prompt_trigger_ticks - curr_ticks) < PROMPT_TICKS_OFFSET_TO_TRIGGER_MIX)) - { - TRACE(2,"ticks<2> %d - trigger ticks %d", curr_ticks,mix_prompt_trigger_ticks); - tws_enable_mix_prompt(true); - } - } - - if (0 != playback_last_irq_ticks) - { - playback_interval_in_ticks = curr_ticks-playback_last_irq_ticks; - } - - playback_last_irq_ticks = curr_ticks; -} - -void app_tws_cmd_sync_mix_prompt_req_handler(uint8_t* ptrParam, uint16_t paramLen) -{ - uint16_t promptPram = 0xFFFF; - uint32_t curr_ticks = 0xFFFFFFFF; - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - - APP_TWS_CMD_MIX_PROMPT_SYNC_T* pReq = (APP_TWS_CMD_MIX_PROMPT_SYNC_T *)ptrParam; - TRACE(2,"promptId, trigger_time:0x%x, %d", - pReq->promptId, pReq->trigger_time); - - audio_prompt_stop_playing(); - - if (app_tws_ibrt_slave_ibrt_link_connected()) - { - curr_ticks = bt_syn_get_curr_ticks(p_ibrt_ctrl->ibrt_conhandle); - } - - if ((!app_tws_ibrt_slave_ibrt_link_connected()) || - ((curr_ticks > pReq->trigger_time) && - ((curr_ticks - pReq->trigger_time) > PROMPT_TICKS_OFFSET_TO_TRIGGER_MIX))) - { - TRACE(0,"return directly."); - return; - } - - tws_set_mix_prompt_trigger_ticks(pReq->trigger_time); - promptPram = pReq->promptId | pReq->promptPram; - audio_prompt_start_playing(promptPram, pReq->sampleRate); - if (curr_ticks >= pReq->trigger_time) - { - TRACE(1,"Instant passed %d",curr_ticks); - tws_enable_mix_prompt(true); - } - else if ((curr_ticks < pReq->trigger_time) && - ((pReq->trigger_time - curr_ticks) < PROMPT_TICKS_OFFSET_TO_TRIGGER_MIX)){ - TRACE(1,"Instant near %d",curr_ticks); - tws_enable_mix_prompt(true); - } + tws_set_mix_prompt_trigger_ticks(pReq->trigger_time); + promptPram = pReq->promptId | pReq->promptPram; + audio_prompt_start_playing(promptPram, pReq->sampleRate); + if (curr_ticks >= pReq->trigger_time) { + TRACE(1, "Instant passed %d", curr_ticks); + tws_enable_mix_prompt(true); + } else if ((curr_ticks < pReq->trigger_time) && + ((pReq->trigger_time - curr_ticks) < + PROMPT_TICKS_OFFSET_TO_TRIGGER_MIX)) { + TRACE(1, "Instant near %d", curr_ticks); + tws_enable_mix_prompt(true); + } } #endif -static int audio_prompt_resample_iter(uint8_t *buf, uint32_t len) -{ - if (!buf) - { - TRACE(0, "NULL pointer received in %s", __func__); - return -1; - } +static int audio_prompt_resample_iter(uint8_t *buf, uint32_t len) { + if (!buf) { + TRACE(0, "NULL pointer received in %s", __func__); + return -1; + } - uint32_t leftLen = audio_prompt_env.tmpSourcePcmDataLen - audio_prompt_env.tmpSourcePcmDataOutIndex; - uint32_t lenToFetch; + uint32_t leftLen = audio_prompt_env.tmpSourcePcmDataLen - + audio_prompt_env.tmpSourcePcmDataOutIndex; + uint32_t lenToFetch; - if (leftLen >= len) - { - lenToFetch = len; - } - else - { - lenToFetch = leftLen; - } + if (leftLen >= len) { + lenToFetch = len; + } else { + lenToFetch = leftLen; + } - memcpy(buf, audio_prompt_env.tmpSourcePcmDataBuf + audio_prompt_env.tmpSourcePcmDataOutIndex, - lenToFetch); - audio_prompt_env.tmpSourcePcmDataOutIndex += lenToFetch; + memcpy(buf, + audio_prompt_env.tmpSourcePcmDataBuf + + audio_prompt_env.tmpSourcePcmDataOutIndex, + lenToFetch); + audio_prompt_env.tmpSourcePcmDataOutIndex += lenToFetch; - memset(buf + lenToFetch, 0, len - lenToFetch); + memset(buf + lenToFetch, 0, len - lenToFetch); - return 0; + return 0; } -void audio_prompt_buffer_config(uint8_t mixType, - uint8_t channel_cnt, +void audio_prompt_buffer_config(uint8_t mixType, uint8_t channel_cnt, uint8_t bitNumPerSample, uint8_t *tmpSourcePcmDataBuf, uint8_t *tmpTargetPcmDataBuf, - uint8_t *pcmDataBuf, - uint32_t pcmBufLen, + uint8_t *pcmDataBuf, uint32_t pcmBufLen, uint8_t *bufForResampler, - uint32_t resampleBufLen) -{ - af_lock_thread(); - audio_prompt_env.mixType = mixType; - audio_prompt_env.targetChannelCnt = channel_cnt; - if (24 == bitNumPerSample) - { - audio_prompt_env.targetBytesCntPerSample = 4; - } - else if (16 == bitNumPerSample) - { - audio_prompt_env.targetBytesCntPerSample = 2; - } - else - { - ASSERT(false, "bitNumPerSample %d is not supported by prompt mixer yet!", bitNumPerSample); - } + uint32_t resampleBufLen) { + af_lock_thread(); + audio_prompt_env.mixType = mixType; + audio_prompt_env.targetChannelCnt = channel_cnt; + if (24 == bitNumPerSample) { + audio_prompt_env.targetBytesCntPerSample = 4; + } else if (16 == bitNumPerSample) { + audio_prompt_env.targetBytesCntPerSample = 2; + } else { + ASSERT(false, "bitNumPerSample %d is not supported by prompt mixer yet!", + bitNumPerSample); + } - audio_prompt_env.tmpSourcePcmDataBuf = tmpSourcePcmDataBuf; - audio_prompt_env.tmpTargetPcmDataBuf = tmpTargetPcmDataBuf; - audio_prompt_env.bufForResampler = bufForResampler; - audio_prompt_env.resampleBufLen = resampleBufLen; + audio_prompt_env.tmpSourcePcmDataBuf = tmpSourcePcmDataBuf; + audio_prompt_env.tmpTargetPcmDataBuf = tmpTargetPcmDataBuf; + audio_prompt_env.bufForResampler = bufForResampler; + audio_prompt_env.resampleBufLen = resampleBufLen; - InitCQueue(&(audio_prompt_env.pcmDataQueue), pcmBufLen, (CQItemType *)(pcmDataBuf)); - af_unlock_thread(); + InitCQueue(&(audio_prompt_env.pcmDataQueue), pcmBufLen, + (CQItemType *)(pcmDataBuf)); + af_unlock_thread(); } +uint16_t audio_prompt_get_prompt_id(void) { return audio_prompt_env.promptId; } -uint16_t audio_prompt_get_prompt_id(void) -{ - return audio_prompt_env.promptId; +uint32_t audio_prompt_get_sample_rate(void) { + return audio_prompt_env.targetSampleRate; } -uint32_t audio_prompt_get_sample_rate(void) -{ - return audio_prompt_env.targetSampleRate; -} +bool audio_prompt_start_playing(uint16_t promptPram, + uint32_t targetSampleRate) { + uint16_t promptId = PROMPT_ID_FROM_ID_VALUE(promptPram); -bool audio_prompt_start_playing(uint16_t promptPram, uint32_t targetSampleRate) -{ - uint16_t promptId = PROMPT_ID_FROM_ID_VALUE(promptPram); + if (audio_prompt_is_playing_ongoing()) { + return false; + } - if (audio_prompt_is_playing_ongoing()) - { - return false; - } - - TRACE(0, "[%s]", __func__); + TRACE(0, "[%s]", __func__); #ifdef TWS_PROMPT_SYNC - bool isPlayingLocally = false; - if (app_tws_ibrt_tws_link_connected()) - { - isPlayingLocally = false; - } - else - { - isPlayingLocally = true; - } + bool isPlayingLocally = false; + if (app_tws_ibrt_tws_link_connected()) { + isPlayingLocally = false; + } else { + isPlayingLocally = true; + } #endif - promptId = PROMPT_ID_FROM_ID_VALUE(promptId); + promptId = PROMPT_ID_FROM_ID_VALUE(promptId); - uint32_t lock = int_lock_global(); - audio_prompt_env.isMixPromptOn = true; + uint32_t lock = int_lock_global(); + audio_prompt_env.isMixPromptOn = true; - uint8_t* promptDataPtr = NULL; - uint32_t promptDataLen = 0; - PROMPT_MIX_PROPERTY_T* pPromptProperty = NULL; + uint8_t *promptDataPtr = NULL; + uint32_t promptDataLen = 0; + PROMPT_MIX_PROPERTY_T *pPromptProperty = NULL; #ifdef MEDIA_PLAYER_SUPPORT - media_runtime_audio_prompt_update(promptId, &promptDataPtr, &promptDataLen); - pPromptProperty = get_prompt_mix_property(promptId); + media_runtime_audio_prompt_update(promptId, &promptDataPtr, &promptDataLen); + pPromptProperty = get_prompt_mix_property(promptId); #endif - if (NULL == pPromptProperty) - { - TRACE(0,"use default mix property"); + if (NULL == pPromptProperty) { + TRACE(0, "use default mix property"); - // use default property - audio_prompt_env.volume_level_override = DEFAULT_VOLUME_FOR_MIX_PROMPT; + // use default property + audio_prompt_env.volume_level_override = DEFAULT_VOLUME_FOR_MIX_PROMPT; - audio_prompt_env.coeff_for_mix_prompt_for_call = DEFAULT_COEFF_FOR_MIX_PROMPT_FOR_CALL; - audio_prompt_env.coeff_for_mix_call_for_call = DEFAULT_COEFF_FOR_MIX_CALL_FOR_CALL; - audio_prompt_env.coeff_for_mix_prompt_for_music = DEFAULT_COEFF_FOR_MIX_PROMPT_FOR_MUSIC; - audio_prompt_env.coeff_for_mix_music_for_music = DEFAULT_COEFF_FOR_MIX_MUSIC_FOR_MUSIC; + audio_prompt_env.coeff_for_mix_prompt_for_call = + DEFAULT_COEFF_FOR_MIX_PROMPT_FOR_CALL; + audio_prompt_env.coeff_for_mix_call_for_call = + DEFAULT_COEFF_FOR_MIX_CALL_FOR_CALL; + audio_prompt_env.coeff_for_mix_prompt_for_music = + DEFAULT_COEFF_FOR_MIX_PROMPT_FOR_MUSIC; + audio_prompt_env.coeff_for_mix_music_for_music = + DEFAULT_COEFF_FOR_MIX_MUSIC_FOR_MUSIC; + } else { + audio_prompt_env.volume_level_override = + pPromptProperty->volume_level_override; + + audio_prompt_env.coeff_for_mix_prompt_for_call = + pPromptProperty->coeff_for_mix_prompt_for_call; + audio_prompt_env.coeff_for_mix_call_for_call = + pPromptProperty->coeff_for_mix_call_for_call; + audio_prompt_env.coeff_for_mix_prompt_for_music = + pPromptProperty->coeff_for_mix_prompt_for_music; + audio_prompt_env.coeff_for_mix_music_for_music = + pPromptProperty->coeff_for_mix_music_for_music; + } + + if (KEEP_CURRENT_VOLUME_FOR_MIX_PROMPT != + audio_prompt_env.volume_level_override) { + // if the prompt's volume is smaller than the current volume, don't change + // it + if (audio_prompt_env.volume_level_override <= + app_bt_stream_local_volume_get()) { + audio_prompt_env.volume_level_override = + KEEP_CURRENT_VOLUME_FOR_MIX_PROMPT; } - else - { - audio_prompt_env.volume_level_override = - pPromptProperty->volume_level_override; + } - audio_prompt_env.coeff_for_mix_prompt_for_call = - pPromptProperty->coeff_for_mix_prompt_for_call; - audio_prompt_env.coeff_for_mix_call_for_call = - pPromptProperty->coeff_for_mix_call_for_call; - audio_prompt_env.coeff_for_mix_prompt_for_music = - pPromptProperty->coeff_for_mix_prompt_for_music; - audio_prompt_env.coeff_for_mix_music_for_music = - pPromptProperty->coeff_for_mix_music_for_music; - } + audio_prompt_env.promptId = promptId; + audio_prompt_env.promptPram = PROMPT_PRAM_FROM_ID_VALUE(promptPram); + audio_prompt_env.promptDataBuf = promptDataPtr; + audio_prompt_env.isResetDecoder = true; + audio_prompt_env.isAudioPromptDecodingDone = false; + audio_prompt_env.wholeEncodedDataLen = promptDataLen; + audio_prompt_env.leftEncodedDataLen = audio_prompt_env.wholeEncodedDataLen; + audio_prompt_env.targetSampleRate = targetSampleRate; - if (KEEP_CURRENT_VOLUME_FOR_MIX_PROMPT != audio_prompt_env.volume_level_override) - { - // if the prompt's volume is smaller than the current volume, don't change it - if (audio_prompt_env.volume_level_override <= app_bt_stream_local_volume_get()) - { - audio_prompt_env.volume_level_override = KEEP_CURRENT_VOLUME_FOR_MIX_PROMPT; - } - } + audio_prompt_env.resampleRatio = ((float)AUDIO_PROMPT_SBC_SAMPLE_RATE_VALUE) / + audio_prompt_env.targetSampleRate; + audio_prompt_env.targetPcmChunkSize = + (uint32_t)(AUDIO_PROMPT_SBC_PCM_DATA_SIZE_PER_FRAME / + audio_prompt_env.resampleRatio); - audio_prompt_env.promptId = promptId; - audio_prompt_env.promptPram = PROMPT_PRAM_FROM_ID_VALUE(promptPram); - audio_prompt_env.promptDataBuf = promptDataPtr; - audio_prompt_env.isResetDecoder = true; - audio_prompt_env.isAudioPromptDecodingDone = false; - audio_prompt_env.wholeEncodedDataLen = promptDataLen; - audio_prompt_env.leftEncodedDataLen = audio_prompt_env.wholeEncodedDataLen; - audio_prompt_env.targetSampleRate = targetSampleRate; + audio_prompt_env.resampler = + app_playback_resample_any_open_with_pre_allocated_buffer( + (enum AUD_CHANNEL_NUM_T)AUDIO_PROMPT_SBC_CHANNEL_COUNT, + audio_prompt_resample_iter, AUDIO_PROMPT_RESAMPLE_ITER_NUM, + audio_prompt_env.resampleRatio, audio_prompt_env.bufForResampler, + audio_prompt_env.resampleBufLen); - audio_prompt_env.resampleRatio = ((float)AUDIO_PROMPT_SBC_SAMPLE_RATE_VALUE) / audio_prompt_env.targetSampleRate; - audio_prompt_env.targetPcmChunkSize = (uint32_t)(AUDIO_PROMPT_SBC_PCM_DATA_SIZE_PER_FRAME/audio_prompt_env.resampleRatio); + // audio resample out size should be even + uint16_t targetOverlapLength = + ((uint16_t)(DEFAULT_OVERLAP_LENGTH / audio_prompt_env.resampleRatio) / 2 * + 2); + audio_prompt_env.mergeInOverlapLength = + targetOverlapLength * audio_prompt_env.targetChannelCnt; + audio_prompt_env.mergeOutOverlapLength = + targetOverlapLength * audio_prompt_env.targetChannelCnt; + audio_prompt_env.mergeInWeight = 0.f; + audio_prompt_env.mergeOutWeight = 1.f; + audio_prompt_env.mergeStep = 1.f / (targetOverlapLength - 1); - audio_prompt_env.resampler = app_playback_resample_any_open_with_pre_allocated_buffer(( enum AUD_CHANNEL_NUM_T )AUDIO_PROMPT_SBC_CHANNEL_COUNT, - audio_prompt_resample_iter, - AUDIO_PROMPT_RESAMPLE_ITER_NUM, - audio_prompt_env.resampleRatio, - audio_prompt_env.bufForResampler, - audio_prompt_env.resampleBufLen); + audio_prompt_set_saved_stopped_stream_id(-1); - // audio resample out size should be even - uint16_t targetOverlapLength = ((uint16_t)(DEFAULT_OVERLAP_LENGTH / audio_prompt_env.resampleRatio) / 2 * 2); - audio_prompt_env.mergeInOverlapLength = targetOverlapLength * audio_prompt_env.targetChannelCnt; - audio_prompt_env.mergeOutOverlapLength = targetOverlapLength * audio_prompt_env.targetChannelCnt; - audio_prompt_env.mergeInWeight = 0.f; - audio_prompt_env.mergeOutWeight = 1.f; - audio_prompt_env.mergeStep = 1.f / (targetOverlapLength - 1); + int_unlock_global(lock); - audio_prompt_set_saved_stopped_stream_id(-1); + TRACE(1, "start audio prompt. target sample rate %d", targetSampleRate); - int_unlock_global(lock); - - TRACE(1,"start audio prompt. target sample rate %d", targetSampleRate); - - app_sysfreq_req(APP_SYSFREQ_USER_PROMPT_MIXER, APP_SYSFREQ_104M); + app_sysfreq_req(APP_SYSFREQ_USER_PROMPT_MIXER, APP_SYSFREQ_104M); #ifdef TWS_PROMPT_SYNC - if (!isPlayingLocally) - { - tws_sync_mix_prompt_start_handling(); - } - else - { - tws_enable_mix_prompt(true); - } + if (!isPlayingLocally) { + tws_sync_mix_prompt_start_handling(); + } else { + tws_enable_mix_prompt(true); + } #endif - - return true; + return true; } -void audio_prompt_forcefully_stop(void) -{ - app_playback_resample_close(audio_prompt_env.resampler); - audio_prompt_set_saved_stopped_stream_id(-1); - audio_prompt_env.isAudioPromptDecodingDone = true; - audio_prompt_env.leftEncodedDataLen = 0; - app_sysfreq_req(APP_SYSFREQ_USER_PROMPT_MIXER, APP_SYSFREQ_32K); +void audio_prompt_forcefully_stop(void) { + app_playback_resample_close(audio_prompt_env.resampler); + audio_prompt_set_saved_stopped_stream_id(-1); + audio_prompt_env.isAudioPromptDecodingDone = true; + audio_prompt_env.leftEncodedDataLen = 0; + app_sysfreq_req(APP_SYSFREQ_USER_PROMPT_MIXER, APP_SYSFREQ_32K); #if defined(IBRT) && defined(MEDIA_PLAYER_SUPPORT) - app_tws_sync_prompt_check(); + app_tws_sync_prompt_check(); #endif } -bool audio_prompt_check_on_stopping_stream(uint8_t pendingStopOp, uint8_t deviceId) -{ - uint32_t lock = int_lock_global(); - if (audio_prompt_env.isMixPromptOn) - { - if (bt_is_playback_triggered()) - { - TRACE(1,"Prompt mixing ongoing, pending op:%d", pendingStopOp); - audio_prompt_env.pendingStopOp = pendingStopOp; - audio_prompt_set_saved_stopped_stream_id(deviceId); - int_unlock_global(lock); - return false; - } - else - { - int_unlock_global(lock); - audio_prompt_stop_playing(); - return true; - } +bool audio_prompt_check_on_stopping_stream(uint8_t pendingStopOp, + uint8_t deviceId) { + uint32_t lock = int_lock_global(); + if (audio_prompt_env.isMixPromptOn) { + if (bt_is_playback_triggered()) { + TRACE(1, "Prompt mixing ongoing, pending op:%d", pendingStopOp); + audio_prompt_env.pendingStopOp = pendingStopOp; + audio_prompt_set_saved_stopped_stream_id(deviceId); + int_unlock_global(lock); + return false; + } else { + int_unlock_global(lock); + audio_prompt_stop_playing(); + return true; } + } + int_unlock_global(lock); + return true; +} + +bool audio_prompt_clear_pending_stream(uint8_t op) { + bool isToClearActiveMedia = false; + + TRACE(4, "%s stop_id %d pendingStopOp %d op %d", __func__, + audio_prompt_get_saved_stopped_stream_id(), + audio_prompt_env.pendingStopOp, op); + + if (-1 != audio_prompt_get_saved_stopped_stream_id()) { + uint32_t lock = int_lock_global(); + if ((PENDING_TO_STOP_A2DP_STREAMING == op) && + (PENDING_TO_STOP_A2DP_STREAMING == + audio_prompt_get_pending_stop_op())) { + audio_prompt_set_saved_stopped_stream_id(-1); + audio_prompt_set_pending_stop_op(PENDING_TO_STOP_STREAM_INVALID); + isToClearActiveMedia = true; + } else if ((PENDING_TO_STOP_SCO_STREAMING == op) && + (PENDING_TO_STOP_SCO_STREAMING == + audio_prompt_get_pending_stop_op())) { + audio_prompt_set_saved_stopped_stream_id(-1); + audio_prompt_set_pending_stop_op(PENDING_TO_STOP_STREAM_INVALID); + isToClearActiveMedia = true; + } int_unlock_global(lock); - return true; + } + + return isToClearActiveMedia; } -bool audio_prompt_clear_pending_stream(uint8_t op) -{ - bool isToClearActiveMedia = false; +void audio_prompt_stop_playing(void) { + if (!audio_prompt_env.isMixPromptOn) { + return; + } - TRACE(4, - "%s stop_id %d pendingStopOp %d op %d", - __func__, - audio_prompt_get_saved_stopped_stream_id(), - audio_prompt_env.pendingStopOp, - op); + TRACE(0, "Stop audio prompt."); - if (-1 != audio_prompt_get_saved_stopped_stream_id()) - { - uint32_t lock = int_lock_global(); - if ((PENDING_TO_STOP_A2DP_STREAMING == op) && - (PENDING_TO_STOP_A2DP_STREAMING == audio_prompt_get_pending_stop_op())) - { - audio_prompt_set_saved_stopped_stream_id(-1); - audio_prompt_set_pending_stop_op(PENDING_TO_STOP_STREAM_INVALID); - isToClearActiveMedia = true; - } - else if ((PENDING_TO_STOP_SCO_STREAMING == op) && - (PENDING_TO_STOP_SCO_STREAMING == audio_prompt_get_pending_stop_op())) - { - audio_prompt_set_saved_stopped_stream_id(-1); - audio_prompt_set_pending_stop_op(PENDING_TO_STOP_STREAM_INVALID); - isToClearActiveMedia = true; - } - int_unlock_global(lock); - } + app_playback_resample_close(audio_prompt_env.resampler); - return isToClearActiveMedia; -} + uint32_t lock = int_lock_global(); -void audio_prompt_stop_playing(void) -{ - if (!audio_prompt_env.isMixPromptOn) - { - return; - } - - TRACE(0,"Stop audio prompt."); - - app_playback_resample_close(audio_prompt_env.resampler); - - uint32_t lock = int_lock_global(); - - audio_prompt_env.leftEncodedDataLen = 0; - audio_prompt_env.isMixPromptOn = false; + audio_prompt_env.leftEncodedDataLen = 0; + audio_prompt_env.isMixPromptOn = false; #ifdef TWS_PROMPT_SYNC - tws_reset_mix_prompt_trigger_ticks(); + tws_reset_mix_prompt_trigger_ticks(); #endif - int_unlock_global(lock); + int_unlock_global(lock); - if (KEEP_CURRENT_VOLUME_FOR_MIX_PROMPT != audio_prompt_env.volume_level_override) - { - // restore the volume - app_bt_stream_volumeset_handler(app_bt_stream_local_volume_get()); + if (KEEP_CURRENT_VOLUME_FOR_MIX_PROMPT != + audio_prompt_env.volume_level_override) { + // restore the volume + app_bt_stream_volumeset_handler(app_bt_stream_local_volume_get()); + } + + lock = int_lock_global(); + + uint8_t pendingStopOp; + int8_t savedStoppedStreamId; + + pendingStopOp = audio_prompt_env.pendingStopOp; + savedStoppedStreamId = audio_prompt_get_saved_stopped_stream_id(); + + audio_prompt_set_saved_stopped_stream_id(-1); + + int_unlock_global(lock); + + if (savedStoppedStreamId >= 0) { + if (PENDING_TO_STOP_A2DP_STREAMING == pendingStopOp) { + TRACE(0, "Stop the pending stopped a2dp media stream."); + app_stop_a2dp_media_stream(savedStoppedStreamId); + } else if (PENDING_TO_STOP_SCO_STREAMING == pendingStopOp) { + TRACE(0, "Stop the pending stopped sco media stream."); + app_stop_sco_media_stream(savedStoppedStreamId); } + } - lock = int_lock_global(); - - uint8_t pendingStopOp; - int8_t savedStoppedStreamId; - - pendingStopOp = audio_prompt_env.pendingStopOp; - savedStoppedStreamId = audio_prompt_get_saved_stopped_stream_id(); - - audio_prompt_set_saved_stopped_stream_id(-1); - - int_unlock_global(lock); - - if (savedStoppedStreamId >= 0) - { - if (PENDING_TO_STOP_A2DP_STREAMING == pendingStopOp) - { - TRACE(0,"Stop the pending stopped a2dp media stream."); - app_stop_a2dp_media_stream(savedStoppedStreamId); - } - else if (PENDING_TO_STOP_SCO_STREAMING == pendingStopOp) - { - TRACE(0,"Stop the pending stopped sco media stream."); - app_stop_sco_media_stream(savedStoppedStreamId); - } - } - - app_sysfreq_req(APP_SYSFREQ_USER_PROMPT_MIXER, APP_SYSFREQ_32K); + app_sysfreq_req(APP_SYSFREQ_USER_PROMPT_MIXER, APP_SYSFREQ_32K); #if defined(IBRT) && defined(MEDIA_PLAYER_SUPPORT) - app_tws_sync_prompt_check(); + app_tws_sync_prompt_check(); #endif - //check if there is any pending prompt need to play - APP_AUDIO_STATUS status_next; - APP_AUDIO_STATUS aud_status; - aud_status.id = APP_PLAY_BACK_AUDIO; - if (app_audio_list_rmv_callback(&aud_status, &status_next,APP_BT_SETTING_Q_POS_HEAD, true)) - { - TRACE(4,"%s next id: 0x%x%s, aud_id %d", __func__, status_next.id, player2str(status_next.id), status_next.aud_id); + // check if there is any pending prompt need to play + APP_AUDIO_STATUS status_next; + APP_AUDIO_STATUS aud_status; + aud_status.id = APP_PLAY_BACK_AUDIO; + if (app_audio_list_rmv_callback(&aud_status, &status_next, + APP_BT_SETTING_Q_POS_HEAD, true)) { + TRACE(4, "%s next id: 0x%x%s, aud_id %d", __func__, status_next.id, + player2str(status_next.id), status_next.aud_id); #if defined(IBRT) - app_ibrt_if_voice_report_handler(status_next.aud_id, true); + app_ibrt_if_voice_report_handler(status_next.aud_id, true); #endif - } - + } } -template -static inline DstType prompt_data_ssat(int32_t in) -{ - DstType out; +template static inline DstType prompt_data_ssat(int32_t in) { + DstType out; - if (sizeof(DstType) == 2) { - out = __SSAT(in, 16); - } else { - out = __SSAT(in, 24); - } + if (sizeof(DstType) == 2) { + out = __SSAT(in, 16); + } else { + out = __SSAT(in, 24); + } - return out; + return out; } -template -static inline DstType prompt_data_extend(int16_t in) -{ - DstType out; +template +static inline DstType prompt_data_extend(int16_t in) { + DstType out; - if (sizeof(DstType) == 2) { - out = in; - } else { - out = (in << 8); - } + if (sizeof(DstType) == 2) { + out = in; + } else { + out = (in << 8); + } - return out; + return out; } -template -static void audio_prompt_crossfade(DstType *dst_buf, DstType *src_buf1, int16_t *src_buf0, - float coeff_for_source, float coeff_for_prompt, - uint32_t merge_in_end, uint32_t merge_out_start, uint32_t src_len) -{ - uint32_t i = 0; - if (audio_prompt_env.targetChannelCnt == 2) { - float weight = audio_prompt_env.mergeInWeight; - for (; i < merge_in_end; i += 2) { - /* TODO: increase coeff by step instead of calcualted every step */ - float coeff0 = 1 - weight + weight * coeff_for_source; - float coeff1 = weight * coeff_for_prompt; +template +static void audio_prompt_crossfade(DstType *dst_buf, DstType *src_buf1, + int16_t *src_buf0, float coeff_for_source, + float coeff_for_prompt, + uint32_t merge_in_end, + uint32_t merge_out_start, uint32_t src_len) { + uint32_t i = 0; + if (audio_prompt_env.targetChannelCnt == 2) { + float weight = audio_prompt_env.mergeInWeight; + for (; i < merge_in_end; i += 2) { + /* TODO: increase coeff by step instead of calcualted every step */ + float coeff0 = 1 - weight + weight * coeff_for_source; + float coeff1 = weight * coeff_for_prompt; - float tmp0 = coeff0 * src_buf1[i] + coeff1 * prompt_data_extend(src_buf0[i]); - float tmp1 = coeff0 * src_buf1[i + 1] + coeff1 * prompt_data_extend(src_buf0[i + 1]); - dst_buf[i] = prompt_data_ssat((int32_t)tmp0); - dst_buf[i + 1] = prompt_data_ssat((int32_t)tmp1); + float tmp0 = coeff0 * src_buf1[i] + + coeff1 * prompt_data_extend(src_buf0[i]); + float tmp1 = coeff0 * src_buf1[i + 1] + + coeff1 * prompt_data_extend(src_buf0[i + 1]); + dst_buf[i] = prompt_data_ssat((int32_t)tmp0); + dst_buf[i + 1] = prompt_data_ssat((int32_t)tmp1); - weight += audio_prompt_env.mergeStep; - } - audio_prompt_env.mergeInOverlapLength -= merge_in_end; - audio_prompt_env.mergeInWeight = weight; - } else if (audio_prompt_env.targetChannelCnt == 1) { - float weight = audio_prompt_env.mergeInWeight; - for (; i < merge_in_end; i++) { - float coeff0 = 1 - weight + weight * coeff_for_source; - float coeff1 = weight * coeff_for_prompt; - - float tmp0 = coeff0 * src_buf1[i] + coeff1 * prompt_data_extend(src_buf0[i]); - dst_buf[i] = prompt_data_ssat((int32_t)tmp0); - - weight += audio_prompt_env.mergeStep; - } - audio_prompt_env.mergeInOverlapLength -= merge_in_end; - audio_prompt_env.mergeInWeight = weight; - } else { - ASSERT(0, "[%s] channel number %d not supported", __FUNCTION__, audio_prompt_env.targetChannelCnt); + weight += audio_prompt_env.mergeStep; } - for (; i < merge_out_start; i++) { - float mix_value = coeff_for_prompt * prompt_data_extend(src_buf0[i]) + - coeff_for_source * src_buf1[i]; - dst_buf[i] = prompt_data_ssat((int32_t)mix_value); + audio_prompt_env.mergeInOverlapLength -= merge_in_end; + audio_prompt_env.mergeInWeight = weight; + } else if (audio_prompt_env.targetChannelCnt == 1) { + float weight = audio_prompt_env.mergeInWeight; + for (; i < merge_in_end; i++) { + float coeff0 = 1 - weight + weight * coeff_for_source; + float coeff1 = weight * coeff_for_prompt; + + float tmp0 = coeff0 * src_buf1[i] + + coeff1 * prompt_data_extend(src_buf0[i]); + dst_buf[i] = prompt_data_ssat((int32_t)tmp0); + + weight += audio_prompt_env.mergeStep; } - if (audio_prompt_env.targetChannelCnt == 2) { - float weight = audio_prompt_env.mergeOutWeight; - for (; i < src_len; i += 2) { - float coeff0 = (1 - weight + weight * coeff_for_source); - float coeff1 = weight * coeff_for_prompt; + audio_prompt_env.mergeInOverlapLength -= merge_in_end; + audio_prompt_env.mergeInWeight = weight; + } else { + ASSERT(0, "[%s] channel number %d not supported", __FUNCTION__, + audio_prompt_env.targetChannelCnt); + } + for (; i < merge_out_start; i++) { + float mix_value = + coeff_for_prompt * prompt_data_extend(src_buf0[i]) + + coeff_for_source * src_buf1[i]; + dst_buf[i] = prompt_data_ssat((int32_t)mix_value); + } + if (audio_prompt_env.targetChannelCnt == 2) { + float weight = audio_prompt_env.mergeOutWeight; + for (; i < src_len; i += 2) { + float coeff0 = (1 - weight + weight * coeff_for_source); + float coeff1 = weight * coeff_for_prompt; - float tmp0 = coeff0 * src_buf1[i] + coeff1 * prompt_data_extend(src_buf0[i]); - float tmp1 = coeff0 * src_buf1[i + 1] + coeff1 * prompt_data_extend(src_buf0[i + 1]); - dst_buf[i] = prompt_data_ssat((int32_t)tmp0); - dst_buf[i + 1] = prompt_data_ssat((int32_t)tmp1); + float tmp0 = coeff0 * src_buf1[i] + + coeff1 * prompt_data_extend(src_buf0[i]); + float tmp1 = coeff0 * src_buf1[i + 1] + + coeff1 * prompt_data_extend(src_buf0[i + 1]); + dst_buf[i] = prompt_data_ssat((int32_t)tmp0); + dst_buf[i + 1] = prompt_data_ssat((int32_t)tmp1); - weight -= audio_prompt_env.mergeStep; - } - audio_prompt_env.mergeOutOverlapLength -= src_len - merge_out_start; - audio_prompt_env.mergeOutWeight = weight; - } else if (audio_prompt_env.targetChannelCnt == 1) { - float weight = audio_prompt_env.mergeOutWeight; - for (; i < src_len; i++) { - float coeff0 = (1 - weight + weight * coeff_for_source); - float coeff1 = weight * coeff_for_prompt; - - float tmp0 = coeff0 * src_buf1[i] + coeff1 * prompt_data_extend(src_buf0[i]); - dst_buf[i] = prompt_data_ssat((int32_t)tmp0); - - weight -= audio_prompt_env.mergeStep; - } - audio_prompt_env.mergeOutOverlapLength -= src_len - merge_out_start; - audio_prompt_env.mergeOutWeight = weight; - } else { - ASSERT(0, "[%s] channel number %d not supported", __FUNCTION__, audio_prompt_env.targetChannelCnt); + weight -= audio_prompt_env.mergeStep; } + audio_prompt_env.mergeOutOverlapLength -= src_len - merge_out_start; + audio_prompt_env.mergeOutWeight = weight; + } else if (audio_prompt_env.targetChannelCnt == 1) { + float weight = audio_prompt_env.mergeOutWeight; + for (; i < src_len; i++) { + float coeff0 = (1 - weight + weight * coeff_for_source); + float coeff1 = weight * coeff_for_prompt; + + float tmp0 = coeff0 * src_buf1[i] + + coeff1 * prompt_data_extend(src_buf0[i]); + dst_buf[i] = prompt_data_ssat((int32_t)tmp0); + + weight -= audio_prompt_env.mergeStep; + } + audio_prompt_env.mergeOutOverlapLength -= src_len - merge_out_start; + audio_prompt_env.mergeOutWeight = weight; + } else { + ASSERT(0, "[%s] channel number %d not supported", __FUNCTION__, + audio_prompt_env.targetChannelCnt); + } } -static void audio_prompt_processing_handler_func(uint32_t acquiredPcmDataLen, uint8_t* pcmDataToMerge) -{ +static void audio_prompt_processing_handler_func(uint32_t acquiredPcmDataLen, + uint8_t *pcmDataToMerge) { #ifdef TWS_PROMPT_SYNC - uint16_t prompt_chnlsel = PROMPT_CHNLSEl_FROM_ID_VALUE(audio_prompt_env.promptPram); + uint16_t prompt_chnlsel = + PROMPT_CHNLSEl_FROM_ID_VALUE(audio_prompt_env.promptPram); #endif - uint32_t pcmDataToGetFromPrompt = acquiredPcmDataLen/(audio_prompt_env.targetChannelCnt*audio_prompt_env.targetBytesCntPerSample/2); + uint32_t pcmDataToGetFromPrompt = + acquiredPcmDataLen / (audio_prompt_env.targetChannelCnt * + audio_prompt_env.targetBytesCntPerSample / 2); - while ((uint32_t)LengthOfCQueue(&(audio_prompt_env.pcmDataQueue)) < pcmDataToGetFromPrompt) - { - if (audio_prompt_env.isAudioPromptDecodingDone) - { - break; - } - - // decode the audio prompt - uint32_t returnedPcmDataLen = audio_prompt_sbc_decode(audio_prompt_env.tmpSourcePcmDataBuf, - AUDIO_PROMPT_SBC_PCM_DATA_SIZE_PER_FRAME, - audio_prompt_env.isResetDecoder); - - if (returnedPcmDataLen < AUDIO_PROMPT_SBC_PCM_DATA_SIZE_PER_FRAME) - { - audio_prompt_env.isAudioPromptDecodingDone = true; - } - - audio_prompt_env.isResetDecoder = false; - audio_prompt_env.tmpSourcePcmDataLen = returnedPcmDataLen; - audio_prompt_env.tmpSourcePcmDataOutIndex = 0; - - // do resmpling - if (audio_prompt_env.targetSampleRate != AUDIO_PROMPT_SBC_SAMPLE_RATE_VALUE) - { - uint32_t targetPcmSize = returnedPcmDataLen; - if (AUDIO_PROMPT_SBC_PCM_DATA_SIZE_PER_FRAME == returnedPcmDataLen) - { - targetPcmSize = audio_prompt_env.targetPcmChunkSize; - } - else - { - targetPcmSize = (uint32_t)(returnedPcmDataLen/audio_prompt_env.resampleRatio); - } - - targetPcmSize = (targetPcmSize/4)*4; - - app_playback_resample_run(audio_prompt_env.resampler, - audio_prompt_env.tmpTargetPcmDataBuf, - targetPcmSize); - - // fill into pcm data queue - EnCQueue(&(audio_prompt_env.pcmDataQueue), audio_prompt_env.tmpTargetPcmDataBuf, targetPcmSize); - } - else - { - EnCQueue(&(audio_prompt_env.pcmDataQueue), audio_prompt_env.tmpSourcePcmDataBuf, returnedPcmDataLen); - } + while ((uint32_t)LengthOfCQueue(&(audio_prompt_env.pcmDataQueue)) < + pcmDataToGetFromPrompt) { + if (audio_prompt_env.isAudioPromptDecodingDone) { + break; } - uint32_t pcmDataLenToMerge = pcmDataToGetFromPrompt; - if ((uint32_t)LengthOfCQueue(&(audio_prompt_env.pcmDataQueue)) < pcmDataToGetFromPrompt) - { - pcmDataLenToMerge = LengthOfCQueue(&(audio_prompt_env.pcmDataQueue)); + // decode the audio prompt + uint32_t returnedPcmDataLen = + audio_prompt_sbc_decode(audio_prompt_env.tmpSourcePcmDataBuf, + AUDIO_PROMPT_SBC_PCM_DATA_SIZE_PER_FRAME, + audio_prompt_env.isResetDecoder); + + if (returnedPcmDataLen < AUDIO_PROMPT_SBC_PCM_DATA_SIZE_PER_FRAME) { + audio_prompt_env.isAudioPromptDecodingDone = true; } - if (pcmDataLenToMerge == 0) - goto exit; + audio_prompt_env.isResetDecoder = false; + audio_prompt_env.tmpSourcePcmDataLen = returnedPcmDataLen; + audio_prompt_env.tmpSourcePcmDataOutIndex = 0; - // copy to multiple channel if needed - if (audio_prompt_env.targetChannelCnt > 1) - { - // get the data - DeCQueue(&(audio_prompt_env.pcmDataQueue), audio_prompt_env.tmpSourcePcmDataBuf, pcmDataLenToMerge); - app_bt_stream_copy_track_one_to_two_16bits(( int16_t * )audio_prompt_env.tmpTargetPcmDataBuf, - ( int16_t * )audio_prompt_env.tmpSourcePcmDataBuf, - pcmDataLenToMerge / sizeof(uint16_t)); - } - else - { - DeCQueue(&(audio_prompt_env.pcmDataQueue), audio_prompt_env.tmpTargetPcmDataBuf, pcmDataLenToMerge); + // do resmpling + if (audio_prompt_env.targetSampleRate != + AUDIO_PROMPT_SBC_SAMPLE_RATE_VALUE) { + uint32_t targetPcmSize = returnedPcmDataLen; + if (AUDIO_PROMPT_SBC_PCM_DATA_SIZE_PER_FRAME == returnedPcmDataLen) { + targetPcmSize = audio_prompt_env.targetPcmChunkSize; + } else { + targetPcmSize = + (uint32_t)(returnedPcmDataLen / audio_prompt_env.resampleRatio); + } + + targetPcmSize = (targetPcmSize / 4) * 4; + + app_playback_resample_run(audio_prompt_env.resampler, + audio_prompt_env.tmpTargetPcmDataBuf, + targetPcmSize); + + // fill into pcm data queue + EnCQueue(&(audio_prompt_env.pcmDataQueue), + audio_prompt_env.tmpTargetPcmDataBuf, targetPcmSize); + } else { + EnCQueue(&(audio_prompt_env.pcmDataQueue), + audio_prompt_env.tmpSourcePcmDataBuf, returnedPcmDataLen); } + } + + uint32_t pcmDataLenToMerge = pcmDataToGetFromPrompt; + if ((uint32_t)LengthOfCQueue(&(audio_prompt_env.pcmDataQueue)) < + pcmDataToGetFromPrompt) { + pcmDataLenToMerge = LengthOfCQueue(&(audio_prompt_env.pcmDataQueue)); + } + + if (pcmDataLenToMerge == 0) + goto exit; + + // copy to multiple channel if needed + if (audio_prompt_env.targetChannelCnt > 1) { + // get the data + DeCQueue(&(audio_prompt_env.pcmDataQueue), + audio_prompt_env.tmpSourcePcmDataBuf, pcmDataLenToMerge); + app_bt_stream_copy_track_one_to_two_16bits( + (int16_t *)audio_prompt_env.tmpTargetPcmDataBuf, + (int16_t *)audio_prompt_env.tmpSourcePcmDataBuf, + pcmDataLenToMerge / sizeof(uint16_t)); + } else { + DeCQueue(&(audio_prompt_env.pcmDataQueue), + audio_prompt_env.tmpTargetPcmDataBuf, pcmDataLenToMerge); + } #ifdef TWS_PROMPT_SYNC - if (IS_PROMPT_CHNLSEl_ALL(prompt_chnlsel) || app_ibrt_voice_report_is_me(prompt_chnlsel)) + if (IS_PROMPT_CHNLSEl_ALL(prompt_chnlsel) || + app_ibrt_voice_report_is_me(prompt_chnlsel)) #endif - { - // merge the data - int16_t *src_buf0 = (int16_t *)audio_prompt_env.tmpTargetPcmDataBuf; - uint32_t src_len = pcmDataLenToMerge*audio_prompt_env.targetChannelCnt/sizeof(uint16_t); + { + // merge the data + int16_t *src_buf0 = (int16_t *)audio_prompt_env.tmpTargetPcmDataBuf; + uint32_t src_len = pcmDataLenToMerge * audio_prompt_env.targetChannelCnt / + sizeof(uint16_t); - float coeff_for_prompt; - float coeff_for_source; + float coeff_for_prompt; + float coeff_for_source; - if (MIX_WITH_A2DP_STREAMING == audio_prompt_env.mixType) { - coeff_for_prompt = audio_prompt_env.coeff_for_mix_prompt_for_music; - coeff_for_source = audio_prompt_env.coeff_for_mix_music_for_music; - } else { - coeff_for_prompt = audio_prompt_env.coeff_for_mix_prompt_for_call; - coeff_for_source = audio_prompt_env.coeff_for_mix_call_for_call; - } - - /* - * 0 --------------- merge_in_end --- merge_out_start --- src_len - * |---- merge in ---------|---- merge ------|----- merge out ---| - * Split data into three segments, merge in stands for merge begin crossfade, merge out for merge end crossfade. - * In merge begin crossfade stage, old data is music/sco pcm data, new data is merged data. - * In merge end crossfade stage, old data is merged data, new data is music/sco data. - * Assume music/soc is a, ring is b, then merged data is x = m * a + p * b, - * merge begin final data y = (1 - w) * a + w * x = (1 - w + w * m) * a + w * p * b for w = 0:step:1, - * merge end final data y = (1 - w) * a + w * x = (1 - w + w * m) * a + w * p * b for w = 1:-step:0. - */ - uint32_t merge_in_end = 0; - if (audio_prompt_env.mergeInOverlapLength > 0) { - TRACE(3, "[%s] bytes_per_sample %d, channel_num %d", __FUNCTION__, - audio_prompt_env.targetBytesCntPerSample, audio_prompt_env.targetChannelCnt); - TRACE(2, "[%s] merge start, remain %d", __FUNCTION__, audio_prompt_env.mergeInOverlapLength); - merge_in_end = MIN(audio_prompt_env.mergeInOverlapLength, src_len); - } - - uint32_t merge_out_start = src_len; - /* TODO: calc remain decoded pcm samples for DEFAULT_OVERLAP_LENGTH > 128 */ - if (audio_prompt_env.leftEncodedDataLen == 0) { - if (LengthOfCQueue(&(audio_prompt_env.pcmDataQueue)) < audio_prompt_env.mergeOutOverlapLength / audio_prompt_env.targetChannelCnt * (int32_t)sizeof(uint16_t)) { - TRACE(2, "[%s] merge end, remain %d", __FUNCTION__, audio_prompt_env.mergeOutOverlapLength); - merge_out_start = src_len - (audio_prompt_env.mergeOutOverlapLength - LengthOfCQueue(&(audio_prompt_env.pcmDataQueue)) / sizeof(uint16_t) * audio_prompt_env.targetChannelCnt); - } - } - - //TRACE(3, "[%s] merge_in_end = %d, merge_out_start = %d", __FUNCTION__, merge_in_end, merge_out_start); - //TRACE(3, "[%s] pcm queue size = %d, src_len = %d", __FUNCTION__, LengthOfCQueue(&(audio_prompt_env.pcmDataQueue)), src_len); - - if (2 == audio_prompt_env.targetBytesCntPerSample) - { - int16_t *src_buf1 = (int16_t *)pcmDataToMerge; - int16_t *dst_buf = (int16_t *)pcmDataToMerge; - - audio_prompt_crossfade(dst_buf, src_buf1, src_buf0, - coeff_for_source, coeff_for_prompt, - merge_in_end, merge_out_start, src_len); - } - else if (4 == audio_prompt_env.targetBytesCntPerSample) - { - int32_t *src_buf1 = (int32_t *)pcmDataToMerge; - int32_t *dst_buf = (int32_t *)pcmDataToMerge; - - audio_prompt_crossfade(dst_buf, src_buf1, src_buf0, - coeff_for_source, coeff_for_prompt, - merge_in_end, merge_out_start, src_len); - } + if (MIX_WITH_A2DP_STREAMING == audio_prompt_env.mixType) { + coeff_for_prompt = audio_prompt_env.coeff_for_mix_prompt_for_music; + coeff_for_source = audio_prompt_env.coeff_for_mix_music_for_music; + } else { + coeff_for_prompt = audio_prompt_env.coeff_for_mix_prompt_for_call; + coeff_for_source = audio_prompt_env.coeff_for_mix_call_for_call; } + /* + * 0 --------------- merge_in_end --- merge_out_start --- src_len + * |---- merge in ---------|---- merge ------|----- merge out ---| + * Split data into three segments, merge in stands for merge begin + * crossfade, merge out for merge end crossfade. In merge begin crossfade + * stage, old data is music/sco pcm data, new data is merged data. In merge + * end crossfade stage, old data is merged data, new data is music/sco data. + * Assume music/soc is a, ring is b, then merged data is x = m * a + p * b, + * merge begin final data y = (1 - w) * a + w * x = (1 - w + w * m) * a + w + * * p * b for w = 0:step:1, merge end final data y = (1 - w) * a + w * x = + * (1 - w + w * m) * a + w * p * b for w = 1:-step:0. + */ + uint32_t merge_in_end = 0; + if (audio_prompt_env.mergeInOverlapLength > 0) { + TRACE(3, "[%s] bytes_per_sample %d, channel_num %d", __FUNCTION__, + audio_prompt_env.targetBytesCntPerSample, + audio_prompt_env.targetChannelCnt); + TRACE(2, "[%s] merge start, remain %d", __FUNCTION__, + audio_prompt_env.mergeInOverlapLength); + merge_in_end = MIN(audio_prompt_env.mergeInOverlapLength, src_len); + } + + uint32_t merge_out_start = src_len; + /* TODO: calc remain decoded pcm samples for DEFAULT_OVERLAP_LENGTH > 128 */ + if (audio_prompt_env.leftEncodedDataLen == 0) { + if (LengthOfCQueue(&(audio_prompt_env.pcmDataQueue)) < + audio_prompt_env.mergeOutOverlapLength / + audio_prompt_env.targetChannelCnt * (int32_t)sizeof(uint16_t)) { + TRACE(2, "[%s] merge end, remain %d", __FUNCTION__, + audio_prompt_env.mergeOutOverlapLength); + merge_out_start = + src_len - + (audio_prompt_env.mergeOutOverlapLength - + LengthOfCQueue(&(audio_prompt_env.pcmDataQueue)) / + sizeof(uint16_t) * audio_prompt_env.targetChannelCnt); + } + } + + // TRACE(3, "[%s] merge_in_end = %d, merge_out_start = %d", __FUNCTION__, + // merge_in_end, merge_out_start); TRACE(3, "[%s] pcm queue size = %d, + // src_len = %d", __FUNCTION__, + // LengthOfCQueue(&(audio_prompt_env.pcmDataQueue)), src_len); + + if (2 == audio_prompt_env.targetBytesCntPerSample) { + int16_t *src_buf1 = (int16_t *)pcmDataToMerge; + int16_t *dst_buf = (int16_t *)pcmDataToMerge; + + audio_prompt_crossfade(dst_buf, src_buf1, src_buf0, + coeff_for_source, coeff_for_prompt, + merge_in_end, merge_out_start, src_len); + } else if (4 == audio_prompt_env.targetBytesCntPerSample) { + int32_t *src_buf1 = (int32_t *)pcmDataToMerge; + int32_t *dst_buf = (int32_t *)pcmDataToMerge; + + audio_prompt_crossfade(dst_buf, src_buf1, src_buf0, + coeff_for_source, coeff_for_prompt, + merge_in_end, merge_out_start, src_len); + } + } + exit: - if (audio_prompt_env.mergeOutOverlapLength == 0) - { - // prompt playing is completed - audio_prompt_stop_playing(); - app_sysfreq_req(APP_SYSFREQ_USER_PROMPT_MIXER, APP_SYSFREQ_32K); - } - + if (audio_prompt_env.mergeOutOverlapLength == 0) { + // prompt playing is completed + audio_prompt_stop_playing(); + app_sysfreq_req(APP_SYSFREQ_USER_PROMPT_MIXER, APP_SYSFREQ_32K); + } } -void audio_prompt_processing_handler(uint32_t acquiredPcmDataLen, uint8_t* pcmDataToMerge) -{ +void audio_prompt_processing_handler(uint32_t acquiredPcmDataLen, + uint8_t *pcmDataToMerge) { #ifdef TWS_PROMPT_SYNC - if (!tws_sync_mix_prompt_handling()) - { - return; - } + if (!tws_sync_mix_prompt_handling()) { + return; + } #endif - af_lock_thread(); + af_lock_thread(); - if (audio_prompt_env.leftEncodedDataLen == - audio_prompt_env.wholeEncodedDataLen) - { - if (KEEP_CURRENT_VOLUME_FOR_MIX_PROMPT != audio_prompt_env.volume_level_override) - { - // first entering, coordinate the volume here - app_bt_stream_volumeset_handler(audio_prompt_env.volume_level_override); - } + if (audio_prompt_env.leftEncodedDataLen == + audio_prompt_env.wholeEncodedDataLen) { + if (KEEP_CURRENT_VOLUME_FOR_MIX_PROMPT != + audio_prompt_env.volume_level_override) { + // first entering, coordinate the volume here + app_bt_stream_volumeset_handler(audio_prompt_env.volume_level_override); + } + } + + uint32_t gotDataLen = 0; + while (gotDataLen < acquiredPcmDataLen) { + uint32_t lenToGet; + if ((acquiredPcmDataLen - gotDataLen) > AUDIO_PROMPT_PCM_FILL_UNIT_SIZE) { + lenToGet = AUDIO_PROMPT_PCM_FILL_UNIT_SIZE; + } else { + lenToGet = acquiredPcmDataLen - gotDataLen; } - uint32_t gotDataLen = 0; - while (gotDataLen < acquiredPcmDataLen) - { - uint32_t lenToGet; - if ((acquiredPcmDataLen - gotDataLen) > AUDIO_PROMPT_PCM_FILL_UNIT_SIZE) - { - lenToGet = AUDIO_PROMPT_PCM_FILL_UNIT_SIZE; - } - else - { - lenToGet = acquiredPcmDataLen - gotDataLen; - } - - audio_prompt_processing_handler_func(lenToGet, pcmDataToMerge+gotDataLen); - gotDataLen += lenToGet; - } - af_unlock_thread(); + audio_prompt_processing_handler_func(lenToGet, pcmDataToMerge + gotDataLen); + gotDataLen += lenToGet; + } + af_unlock_thread(); } -static uint32_t audio_prompt_sbc_decode(uint8_t* pcm_buffer, uint32_t expectedOutputSize, uint8_t isReset) -{ - if (isReset) - { - audio_prompt_sbc_init_decoder(); - } +static uint32_t audio_prompt_sbc_decode(uint8_t *pcm_buffer, + uint32_t expectedOutputSize, + uint8_t isReset) { + if (isReset) { + audio_prompt_sbc_init_decoder(); + } - uint32_t sbcDataBytesToDecode; - unsigned int pcm_offset = 0; - uint16_t byte_decode; - int8_t ret; - btif_sbc_pcm_data_t audio_prompt_PcmDecData; + uint32_t sbcDataBytesToDecode; + unsigned int pcm_offset = 0; + uint16_t byte_decode; + int8_t ret; + btif_sbc_pcm_data_t audio_prompt_PcmDecData; get_again: - audio_prompt_PcmDecData.data = pcm_buffer+pcm_offset; - audio_prompt_PcmDecData.dataLen = 0; + audio_prompt_PcmDecData.data = pcm_buffer + pcm_offset; + audio_prompt_PcmDecData.dataLen = 0; - if (audio_prompt_env.leftEncodedDataLen > AUDIO_PROMPT_SBC_ENCODED_DATA_SIZE_PER_FRAME) - { - sbcDataBytesToDecode = AUDIO_PROMPT_SBC_ENCODED_DATA_SIZE_PER_FRAME; - } - else - { - sbcDataBytesToDecode = audio_prompt_env.leftEncodedDataLen; - } + if (audio_prompt_env.leftEncodedDataLen > + AUDIO_PROMPT_SBC_ENCODED_DATA_SIZE_PER_FRAME) { + sbcDataBytesToDecode = AUDIO_PROMPT_SBC_ENCODED_DATA_SIZE_PER_FRAME; + } else { + sbcDataBytesToDecode = audio_prompt_env.leftEncodedDataLen; + } - ret = btif_sbc_decode_frames(&audio_prompt_sbc_decoder, - audio_prompt_env.promptDataBuf+audio_prompt_env.wholeEncodedDataLen-audio_prompt_env.leftEncodedDataLen, - sbcDataBytesToDecode, &byte_decode, - &audio_prompt_PcmDecData, expectedOutputSize-pcm_offset, - audio_prompt_sbc_eq_band_gain); + ret = btif_sbc_decode_frames( + &audio_prompt_sbc_decoder, + audio_prompt_env.promptDataBuf + audio_prompt_env.wholeEncodedDataLen - + audio_prompt_env.leftEncodedDataLen, + sbcDataBytesToDecode, &byte_decode, &audio_prompt_PcmDecData, + expectedOutputSize - pcm_offset, audio_prompt_sbc_eq_band_gain); + audio_prompt_env.leftEncodedDataLen -= byte_decode; - audio_prompt_env.leftEncodedDataLen -= byte_decode; + pcm_offset += audio_prompt_PcmDecData.dataLen; - pcm_offset += audio_prompt_PcmDecData.dataLen; + if (0 == audio_prompt_env.leftEncodedDataLen) { + goto exit; + } - if (0 == audio_prompt_env.leftEncodedDataLen) - { - goto exit; - } + if (expectedOutputSize == pcm_offset) { + goto exit; + } - if (expectedOutputSize == pcm_offset) - { - goto exit; - } - - if ((ret == BT_STS_CONTINUE) || (ret == BT_STS_SUCCESS)) { - goto get_again; - } + if ((ret == BT_STS_CONTINUE) || (ret == BT_STS_SUCCESS)) { + goto get_again; + } exit: - return pcm_offset; + return pcm_offset; } #endif // MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED diff --git a/services/bt_app/besmain.cpp b/services/bt_app/besmain.cpp index b57a713..fe452fe 100644 --- a/services/bt_app/besmain.cpp +++ b/services/bt_app/besmain.cpp @@ -14,31 +14,31 @@ * ****************************************************************************/ //#include "mbed.h" -#include -#include -#include "string.h" -#include "cmsis_os.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_trace.h" -#include "hal_cmu.h" -#include "hal_chipid.h" #include "analog.h" -#include "apps.h" +#include "app_bt_func.h" +#include "app_bt_stream.h" #include "app_status_ind.h" #include "app_utils.h" -#include "app_bt_stream.h" -#include "nvrecord_dev.h" -#include "tgt_hardware.h" +#include "apps.h" +#include "audioflinger.h" #include "besbt_cfg.h" -#include "hfp_api.h" -#include "app_bt_func.h" -#include "rwapp_config.h" #include "bt_if.h" -#include "os_api.h" +#include "cmsis_os.h" #include "dip_api.h" +#include "hal_chipid.h" +#include "hal_cmu.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "hfp_api.h" +#include "lockcqueue.h" +#include "nvrecord_dev.h" +#include "os_api.h" +#include "rwapp_config.h" +#include "string.h" +#include "tgt_hardware.h" +#include +#include #if defined(ENHANCED_STACK) #include "sdp_api.h" #endif @@ -54,9 +54,9 @@ extern "C" { #include "besble.h" #endif #ifdef TX_RX_PCM_MASK -#include "hal_intersys.h" #include "app_audio.h" #include "app_bt_stream.h" +#include "hal_intersys.h" #endif #include "bt_drv_interface.h" @@ -85,18 +85,18 @@ void BESHCI_UNLockBuffer(void); } #include "besbt.h" -#include "cqueue.h" #include "app_bt.h" #include "btapp.h" +#include "cqueue.h" #if defined(__BTMAP_ENABLE__) #include "app_btmap_sms.h" #endif #if defined(IBRT) -#include "app_tws_ibrt_cmd_handler.h" -#include "app_tws_ctrl_thread.h" -#include "app_ibrt_peripheral_manager.h" #include "app_ibrt_if.h" +#include "app_ibrt_peripheral_manager.h" +#include "app_tws_ctrl_thread.h" +#include "app_tws_ibrt_cmd_handler.h" #endif #ifdef __AI_VOICE__ @@ -126,7 +126,7 @@ struct besbt_cfg_t besbt_cfg = { #else .avdtp_cp_enable = false, #endif -#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) +#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) .source_enable = true, #else .source_enable = false, @@ -139,7 +139,7 @@ struct besbt_cfg_t besbt_cfg = { }; osMessageQDef(evm_queue, 128, uint32_t); -osMessageQId evm_queue_id; +osMessageQId evm_queue_id; /* besbt thread */ #ifndef BESBT_STACK_SIZE @@ -162,73 +162,56 @@ osMessageQId evm_queue_id; #endif #endif -osThreadDef(BesbtThread, (osPriorityAboveNormal), 1, (BESBT_STACK_SIZE), "bes_bt_main"); - +osThreadDef(BesbtThread, (osPriorityAboveNormal), 1, (BESBT_STACK_SIZE), + "bes_bt_main"); static BESBT_HOOK_HANDLER bt_hook_handler[BESBT_HOOK_USER_QTY] = {0}; -int Besbt_hook_handler_set(enum BESBT_HOOK_USER_T user, BESBT_HOOK_HANDLER handler) -{ - bt_hook_handler[user]= handler; - return 0; +int Besbt_hook_handler_set(enum BESBT_HOOK_USER_T user, + BESBT_HOOK_HANDLER handler) { + bt_hook_handler[user] = handler; + return 0; } -static void Besbt_hook_proc(void) -{ - uint8_t i; - for (i=0; i= addr_size / 2) { - j = 0; - } + j = 0; + for (i = 0; i < hlen; i++) { + bt_addr[j++] ^= host[i]; + if (j >= addr_size / 2) { + j = 0; } + } - j = addr_size / 2; - for (i = 0; i < ulen; i++) { - bt_addr[j++] ^= user[i]; - if (j >= addr_size) { - j = addr_size / 2; - } + j = addr_size / 2; + for (i = 0; i < ulen; i++) { + bt_addr[j++] ^= user[i]; + if (j >= addr_size) { + j = addr_size / 2; } + } - TRACE(0,"Modified debug BT addr is:"); - DUMP8("%02x ", bt_addr, BTIF_BD_ADDR_SIZE); + TRACE(0, "Modified debug BT addr is:"); + DUMP8("%02x ", bt_addr, BTIF_BD_ADDR_SIZE); } #if !defined(ENHANCED_STACK) -static void __set_local_dev_name(void) -{ - dev_addr_name devinfo; +static void __set_local_dev_name(void) { + dev_addr_name devinfo; - devinfo.btd_addr = bt_get_local_address(); - devinfo.ble_addr = bt_get_ble_local_address(); - devinfo.localname = bt_get_local_name(); - devinfo.ble_name = bt_get_ble_local_name(); + devinfo.btd_addr = bt_get_local_address(); + devinfo.ble_addr = bt_get_ble_local_address(); + devinfo.localname = bt_get_local_name(); + devinfo.ble_name = bt_get_ble_local_name(); #ifndef FPGA - nvrec_dev_localname_addr_init(&devinfo); + nvrec_dev_localname_addr_init(&devinfo); #endif - bt_set_local_dev_name((const unsigned char*)devinfo.localname, strlen(devinfo.localname) + 1); + bt_set_local_dev_name((const unsigned char *)devinfo.localname, + strlen(devinfo.localname) + 1); } #endif -static void add_randomness(void) -{ - uint32_t generatedSeed = hal_sys_timer_get(); +static void add_randomness(void) { + uint32_t generatedSeed = hal_sys_timer_get(); - //avoid bt address collision low probability - for (uint8_t index = 0; index < sizeof(bt_addr); index++) { - generatedSeed ^= (((uint32_t)(bt_addr[index])) << (hal_sys_timer_get()&0xF)); - } - srand(generatedSeed); + // avoid bt address collision low probability + for (uint8_t index = 0; index < sizeof(bt_addr); index++) { + generatedSeed ^= + (((uint32_t)(bt_addr[index])) << (hal_sys_timer_get() & 0xF)); + } + srand(generatedSeed); } -static void __set_bt_sco_num(void) -{ - uint8_t sco_num; +static void __set_bt_sco_num(void) { + uint8_t sco_num; #ifdef CHIP_BEST1000 - if(hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_2) + if (hal_get_chip_metal_id() >= HAL_CHIP_METAL_ID_2) #endif - { - sco_num = 2; - } + { + sco_num = 2; + } #ifdef CHIP_BEST1000 - else - { - sco_num = 1; - } -#endif -#if defined(__BT_ONE_BRING_TWO__)//&&defined(HFP_NO_PRERMPT) + else { sco_num = 1; + } #endif - bt_set_sco_number(sco_num); +#if defined(__BT_ONE_BRING_TWO__) //&&defined(HFP_NO_PRERMPT) + sco_num = 1; +#endif + bt_set_sco_number(sco_num); } #if defined(ENHANCED_STACK) void app_notify_stack_ready(uint8_t ready_flag); -static void stack_ready_callback(int status) -{ - dev_addr_name devinfo; +static void stack_ready_callback(int status) { + dev_addr_name devinfo; - devinfo.btd_addr = bt_get_local_address(); - devinfo.ble_addr = bt_get_ble_local_address(); - devinfo.localname = bt_get_local_name(); - devinfo.ble_name = bt_get_ble_local_name(); + devinfo.btd_addr = bt_get_local_address(); + devinfo.ble_addr = bt_get_ble_local_address(); + devinfo.localname = bt_get_local_name(); + devinfo.ble_name = bt_get_ble_local_name(); #ifndef FPGA - nvrec_dev_localname_addr_init(&devinfo); + nvrec_dev_localname_addr_init(&devinfo); #endif - bt_set_local_dev_name((const unsigned char*)devinfo.localname, strlen(devinfo.localname) + 1); + bt_set_local_dev_name((const unsigned char *)devinfo.localname, + strlen(devinfo.localname) + 1); - bt_stack_config((const unsigned char*)devinfo.localname, strlen(devinfo.localname) + 1); + bt_stack_config((const unsigned char *)devinfo.localname, + strlen(devinfo.localname) + 1); - app_notify_stack_ready(STACK_READY_BT); + app_notify_stack_ready(STACK_READY_BT); } #endif /* ENHANCED_STACK */ -int besmain(void) -{ - enum APP_SYSFREQ_FREQ_T sysfreq; +int besmain(void) { + enum APP_SYSFREQ_FREQ_T sysfreq; #if !defined(BLE_ONLY_ENABLED) #ifdef A2DP_CP_ACCEL - sysfreq = APP_SYSFREQ_26M; + sysfreq = APP_SYSFREQ_26M; #else - sysfreq = APP_SYSFREQ_52M; + sysfreq = APP_SYSFREQ_52M; #endif #else - sysfreq = APP_SYSFREQ_26M; + sysfreq = APP_SYSFREQ_26M; #endif - BESHCI_Open(); -#if defined( TX_RX_PCM_MASK) - if(btdrv_is_pcm_mask_enable()==1) - hal_intersys_mic_open(HAL_INTERSYS_ID_1,store_encode_frame2buff); + BESHCI_Open(); +#if defined(TX_RX_PCM_MASK) + if (btdrv_is_pcm_mask_enable() == 1) + hal_intersys_mic_open(HAL_INTERSYS_ID_1, store_encode_frame2buff); #endif - __set_bt_sco_num(); - add_randomness(); + __set_bt_sco_num(); + add_randomness(); #ifdef __IAG_BLE_INCLUDE__ - bes_ble_init(); + bes_ble_init(); #endif - btif_set_btstack_chip_config(bt_drv_get_btstack_chip_config()); + btif_set_btstack_chip_config(bt_drv_get_btstack_chip_config()); - /* bes stack init */ - bt_stack_initilize(); + /* bes stack init */ + bt_stack_initilize(); #if defined(ENHANCED_STACK) - bt_stack_register_ready_callback(stack_ready_callback); - btif_sdp_init(); + bt_stack_register_ready_callback(stack_ready_callback); + btif_sdp_init(); #endif #if defined(ENHANCED_STACK) - btif_cmgr_handler_init(); + btif_cmgr_handler_init(); #endif - a2dp_init(); - btif_avrcp_init(&app_bt_device); + a2dp_init(); + btif_avrcp_init(&app_bt_device); #ifdef __AI_VOICE__ - app_ai_voice_init(); + app_ai_voice_init(); #endif #if defined(VOICE_DATAPATH) - app_voicepath_init(); + app_voicepath_init(); #endif #ifdef GFPS_ENABLED - app_fp_rfcomm_init(); + app_fp_rfcomm_init(); #endif - app_hfp_init(); + app_hfp_init(); #if defined(__HSP_ENABLE_) - app_hsp_init(); + app_hsp_init(); #endif #if defined(__BTMAP_ENABLE__) - app_btmap_sms_init(); + app_btmap_sms_init(); #endif #if defined(__GATT_OVER_BR_EDR__) - app_btgatt_init(); + app_btgatt_init(); #endif - /* pair callback init */ - bt_pairing_init(pair_handler_func); - bt_authing_init(auth_handler_func); + /* pair callback init */ + bt_pairing_init(pair_handler_func); + bt_authing_init(auth_handler_func); - a2dp_hid_init(); - a2dp_codec_init(); + a2dp_hid_init(); + a2dp_codec_init(); #ifdef BTIF_HID_DEVICE - app_bt_hid_init(); + app_bt_hid_init(); #endif #ifdef BTIF_DIP_DEVICE - app_dip_init(); + app_dip_init(); #endif #if defined(ENHANCED_STACK) - //register_hci_delete_con_send_complete_cmd_callback(HciSendCompletePacketCommandRightNow); + // register_hci_delete_con_send_complete_cmd_callback(HciSendCompletePacketCommandRightNow); - /* bt local name */ - /* - nvrec_dev_localname_addr_init(&devinfo); - */ + /* bt local name */ + /* + nvrec_dev_localname_addr_init(&devinfo); + */ #else - register_hci_delete_con_send_complete_cmd_callback(HciSendCompletePacketCommandRightNow); + register_hci_delete_con_send_complete_cmd_callback( + HciSendCompletePacketCommandRightNow); - __set_local_dev_name(); + __set_local_dev_name(); #endif #if defined(IBRT) - app_ibrt_set_cmdhandle(TWS_CMD_IBRT, app_ibrt_cmd_table_get); - app_ibrt_set_cmdhandle(TWS_CMD_CUSTOMER, app_ibrt_customif_cmd_table_get); + app_ibrt_set_cmdhandle(TWS_CMD_IBRT, app_ibrt_cmd_table_get); + app_ibrt_set_cmdhandle(TWS_CMD_CUSTOMER, app_ibrt_customif_cmd_table_get); #if defined(IBRT_OTA) || defined(__GMA_OTA_TWS__) || defined(BISTO_ENABLED) - app_ibrt_set_cmdhandle(TWS_CMD_IBRT_OTA, app_ibrt_ota_tws_cmd_table_get); + app_ibrt_set_cmdhandle(TWS_CMD_IBRT_OTA, app_ibrt_ota_tws_cmd_table_get); #endif #ifdef __INTERACTION__ - app_ibrt_set_cmdhandle(TWS_CMD_OTA, app_ibrt_ota_cmd_table_get); + app_ibrt_set_cmdhandle(TWS_CMD_OTA, app_ibrt_ota_cmd_table_get); #endif - tws_ctrl_thread_init(); - app_ibrt_peripheral_thread_init(); + tws_ctrl_thread_init(); + app_ibrt_peripheral_thread_init(); #endif #if defined(APP_LINEIN_A2DP_SOURCE) - app_source_init(); + app_source_init(); #endif #if defined(ENHANCED_STACK) - /* - __set_local_dev_name(); - bt_stack_config(); - */ + /* + __set_local_dev_name(); + bt_stack_config(); + */ #else - bt_stack_config(); + bt_stack_config(); #endif - //init bt key - bt_key_init(); + // init bt key + bt_key_init(); #ifdef TEST_OVER_THE_AIR_ENANBLED - app_tota_init(); + app_tota_init(); #endif - osapi_notify_evm(); - while(1) { - app_sysfreq_req(APP_SYSFREQ_USER_BT_MAIN, APP_SYSFREQ_32K); - osMessageGet(evm_queue_id, osWaitForever); - app_sysfreq_req(APP_SYSFREQ_USER_BT_MAIN, sysfreq); - // BESHCI_LockBuffer(); + osapi_notify_evm(); + while (1) { + app_sysfreq_req(APP_SYSFREQ_USER_BT_MAIN, APP_SYSFREQ_32K); + osMessageGet(evm_queue_id, osWaitForever); + app_sysfreq_req(APP_SYSFREQ_USER_BT_MAIN, sysfreq); + // BESHCI_LockBuffer(); #ifdef __LOCK_AUDIO_THREAD__ - bool stream_a2dp_sbc_isrun = app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC); - if (stream_a2dp_sbc_isrun) { - af_lock_thread(); - } + bool stream_a2dp_sbc_isrun = app_bt_stream_isrun(APP_BT_STREAM_A2DP_SBC); + if (stream_a2dp_sbc_isrun) { + af_lock_thread(); + } #endif - bt_process_stack_events(); + bt_process_stack_events(); #ifdef __IAG_BLE_INCLUDE__ - bes_ble_schedule(); + bes_ble_schedule(); #endif - Besbt_hook_proc(); + Besbt_hook_proc(); #ifdef __LOCK_AUDIO_THREAD__ - if (stream_a2dp_sbc_isrun) { - af_unlock_thread(); - } + if (stream_a2dp_sbc_isrun) { + af_unlock_thread(); + } #endif - // BESHCI_UNLockBuffer(); - BESHCI_Poll(); + // BESHCI_UNLockBuffer(); + BESHCI_Poll(); #if defined(IBRT) - app_ibrt_data_send_handler(); - app_ibrt_data_receive_handler(); - app_ibrt_ui_controller_dbg_state_checker(); - app_ibrt_ui_stop_ibrt_condition_checker(); + app_ibrt_data_send_handler(); + app_ibrt_data_receive_handler(); + app_ibrt_ui_controller_dbg_state_checker(); + app_ibrt_ui_stop_ibrt_condition_checker(); #endif - app_check_pending_stop_sniff_op(); + app_check_pending_stop_sniff_op(); + } - } - - return 0; + return 0; } -void BesbtThread(void const *argument) -{ - besmain(); -} +void BesbtThread(void const *argument) { besmain(); } osThreadId besbt_tid; -void BesbtInit(void) -{ +void BesbtInit(void) { - evm_queue_id = osMessageCreate(osMessageQ(evm_queue), NULL); - /* bt */ - besbt_tid = osThreadCreate(osThread(BesbtThread), NULL); - TRACE(1,"BesbtThread: %p\n", besbt_tid); + evm_queue_id = osMessageCreate(osMessageQ(evm_queue), NULL); + /* bt */ + besbt_tid = osThreadCreate(osThread(BesbtThread), NULL); + TRACE(1, "BesbtThread: %p\n", besbt_tid); } diff --git a/services/bt_if_enhanced/inc/me_api.h b/services/bt_if_enhanced/inc/me_api.h index 7e9cd5c..b8db470 100644 --- a/services/bt_if_enhanced/inc/me_api.h +++ b/services/bt_if_enhanced/inc/me_api.h @@ -18,71 +18,73 @@ #define __ME_API__H__ #include "bluetooth.h" +#include +#include typedef uint8_t btif_event_type_t; -#if defined(BTIF_HCI_HOST_FLOW_CONTROL) && defined (__IAG_BLE_INCLUDE__) -#define BTIF_BTEVENT_CONNECT_CPMPLETE 1 +#if defined(BTIF_HCI_HOST_FLOW_CONTROL) && defined(__IAG_BLE_INCLUDE__) +#define BTIF_BTEVENT_CONNECT_CPMPLETE 1 #endif /* */ -#define BTIF_BTEVENT_INQUIRY_RESULT 1 +#define BTIF_BTEVENT_INQUIRY_RESULT 1 -#define BTIF_BTEVENT_INQUIRY_COMPLETE 2 +#define BTIF_BTEVENT_INQUIRY_COMPLETE 2 -#define BTIF_BTEVENT_INQUIRY_CANCELED 3 +#define BTIF_BTEVENT_INQUIRY_CANCELED 3 -#define BTIF_BTEVENT_LINK_CONNECT_IND 4 +#define BTIF_BTEVENT_LINK_CONNECT_IND 4 -#define BTIF_BTEVENT_SCO_CONNECT_IND 5 +#define BTIF_BTEVENT_SCO_CONNECT_IND 5 -#define BTIF_BTEVENT_LINK_DISCONNECT 6 +#define BTIF_BTEVENT_LINK_DISCONNECT 6 -#define BTIF_BTEVENT_LINK_CONNECT_CNF 7 +#define BTIF_BTEVENT_LINK_CONNECT_CNF 7 -#define BTIF_BTEVENT_LINK_CON_RESTRICT 8 +#define BTIF_BTEVENT_LINK_CON_RESTRICT 8 -#define BTIF_BTEVENT_MODE_CHANGE 9 +#define BTIF_BTEVENT_MODE_CHANGE 9 -#define BTIF_BTEVENT_ACCESSIBLE_CHANGE 10 +#define BTIF_BTEVENT_ACCESSIBLE_CHANGE 10 -#define BTIF_BTEVENT_AUTHENTICATED 11 +#define BTIF_BTEVENT_AUTHENTICATED 11 -#define BTIF_BTEVENT_ENCRYPTION_CHANGE 12 +#define BTIF_BTEVENT_ENCRYPTION_CHANGE 12 -#define BTIF_BTEVENT_SECURITY_CHANGE 13 +#define BTIF_BTEVENT_SECURITY_CHANGE 13 -#define BTIF_BTEVENT_ROLE_CHANGE 14 +#define BTIF_BTEVENT_ROLE_CHANGE 14 -#define BTIF_BTEVENT_SCO_DISCONNECT 15 +#define BTIF_BTEVENT_SCO_DISCONNECT 15 -#define BTIF_BTEVENT_SCO_CONNECT_CNF 16 +#define BTIF_BTEVENT_SCO_CONNECT_CNF 16 -#define BTIF_BTEVENT_SIMPLE_PAIRING_COMPLETE 17 +#define BTIF_BTEVENT_SIMPLE_PAIRING_COMPLETE 17 -#define BTIF_BTEVENT_REMOTE_FEATURES 18 +#define BTIF_BTEVENT_REMOTE_FEATURES 18 -#define BTIF_BTEVENT_REM_HOST_FEATURES 19 +#define BTIF_BTEVENT_REM_HOST_FEATURES 19 -#define BTIF_BTEVENT_LINK_SUPERV_TIMEOUT_CHANGED 20 +#define BTIF_BTEVENT_LINK_SUPERV_TIMEOUT_CHANGED 20 #define BTIF_BTEVENT_SET_SNIFF_SUBRATING_PARMS_CNF 21 -#define BTIF_BTEVENT_SNIFF_SUBRATE_INFO 22 +#define BTIF_BTEVENT_SNIFF_SUBRATE_INFO 22 -#define BTIF_BTEVENT_SET_INQUIRY_MODE_CNF 23 +#define BTIF_BTEVENT_SET_INQUIRY_MODE_CNF 23 -#define BTIF_BTEVENT_SET_INQ_TX_PWR_LVL_CNF 24 +#define BTIF_BTEVENT_SET_INQ_TX_PWR_LVL_CNF 24 -#define BTIF_BTEVENT_SET_EXT_INQUIRY_RESP_CNF 25 +#define BTIF_BTEVENT_SET_EXT_INQUIRY_RESP_CNF 25 -#define BTIF_BTEVENT_SET_ERR_DATA_REPORTING_CNF 26 +#define BTIF_BTEVENT_SET_ERR_DATA_REPORTING_CNF 26 -#define BTIF_BTEVENT_KEY_PRESSED 27 +#define BTIF_BTEVENT_KEY_PRESSED 27 -#define BTIF_BTEVENT_QOS_SETUP_COMPLETE 28 +#define BTIF_BTEVENT_QOS_SETUP_COMPLETE 28 #ifdef __TWS_RECONNECT_USE_BLE__ -#define BTIF_BTEVENT_TWS_BLE_ADV_REPORT_EVENT 29 +#define BTIF_BTEVENT_TWS_BLE_ADV_REPORT_EVENT 29 #endif /* */ /** an ACL connection has received an internal data transmit @@ -100,417 +102,427 @@ while it is in active mode. Then, keep resetting the sniff timer. #define BTIF_BTEVENT_ACL_DATA_ACTIVE 98 /** Indicates that the HCI failed to initialize. */ -#define BTIF_BTEVENT_HCI_INIT_ERROR 100 +#define BTIF_BTEVENT_HCI_INIT_ERROR 100 -#define BTIF_BTEVENT_HCI_INITIALIZED 101 +#define BTIF_BTEVENT_HCI_INITIALIZED 101 /** Indicates that a fatal error has occurred in the radio or the HCI transport. */ -#define BTIF_BTEVENT_HCI_FATAL_ERROR 102 +#define BTIF_BTEVENT_HCI_FATAL_ERROR 102 /** Indicates that the HCI has been deinitialized. */ -#define BTIF_BTEVENT_HCI_DEINITIALIZED 103 +#define BTIF_BTEVENT_HCI_DEINITIALIZED 103 /** Indicates that the HCI cannot be initialized. */ -#define BTIF_BTEVENT_HCI_FAILED 104 +#define BTIF_BTEVENT_HCI_FAILED 104 -#define BTIF_BTEVENT_HCI_COMMAND_SENT 105 +#define BTIF_BTEVENT_HCI_COMMAND_SENT 105 /** Indicates the name of a remote device or cancellation of a name request. */ -#define BTIF_BTEVENT_NAME_RESULT 30 +#define BTIF_BTEVENT_NAME_RESULT 30 -#define BTIF_BTEVENT_SCO_DATA_IND 31 +#define BTIF_BTEVENT_SCO_DATA_IND 31 /** Outgoing SCO data has been sent and the packet is free for re-use by * the application. */ -#define BTIF_BTEVENT_SCO_DATA_CNF 32 +#define BTIF_BTEVENT_SCO_DATA_CNF 32 -#define BTIF_BTEVENT_LINK_CONNECT_REQ 33 +#define BTIF_BTEVENT_LINK_CONNECT_REQ 33 /** Incoming link accept complete. */ -#define BTIF_BTEVENT_LINK_ACCEPT_RSP 34 +#define BTIF_BTEVENT_LINK_ACCEPT_RSP 34 /** Incoming link reject complete. . */ -#define BTEVENT_LINK_REJECT_RSP 35 +#define BTEVENT_LINK_REJECT_RSP 35 -#define BTIF_BTEVENT_COMMAND_COMPLETE 36 +#define BTIF_BTEVENT_COMMAND_COMPLETE 36 -#define BTIF_BTEVENT_SCO_CONNECT_REQ 37 +#define BTIF_BTEVENT_SCO_CONNECT_REQ 37 /** Set Audio/Voice settings complete. */ -#define BTIF_BTEVENT_SCO_VSET_COMPLETE 38 +#define BTIF_BTEVENT_SCO_VSET_COMPLETE 38 /** SCO link connection process started. */ -#define BTIF_BTEVENT_SCO_STARTED 39 +#define BTIF_BTEVENT_SCO_STARTED 39 /** Select Device operation complete, "p.select" is valid. */ -#define BTIF_BTEVENT_DEVICE_SELECTED 40 +#define BTIF_BTEVENT_DEVICE_SELECTED 40 /** The eSCO connection has changed. "p.scoConnect" is valid. */ -#define BTIF_BTEVENT_SCO_CONN_CHNG 41 +#define BTIF_BTEVENT_SCO_CONN_CHNG 41 /* Group: Security-related events. */ /** Indicates access request is successful. "p.secToken" is valid. */ -#define BTIF_BTEVENT_ACCESS_APPROVED 50 +#define BTIF_BTEVENT_ACCESS_APPROVED 50 /** Indicates access request failed. "p.secToken" is valid. */ -#define BTIF_BTEVENT_ACCESS_DENIED 51 +#define BTIF_BTEVENT_ACCESS_DENIED 51 /** Request authorization when "errCode" is BEC_NO_ERROR. * "p.remDev" is valid. */ -#define BTIF_BTEVENT_AUTHORIZATION_REQ 52 +#define BTIF_BTEVENT_AUTHORIZATION_REQ 52 /** Request a Pin for pairing when "errCode" is BEC_NO_ERROR. * "p.pinReq" is valid. If p.pinReq.pinLen is > 0 then SEC_SetPin() * must be called in response to this event with a pin length >= * p.pinReq.pinLen. */ -#define BTIF_BTEVENT_PIN_REQ 53 +#define BTIF_BTEVENT_PIN_REQ 53 /** Pairing operation is complete. */ -#define BTIF_BTEVENT_PAIRING_COMPLETE 54 +#define BTIF_BTEVENT_PAIRING_COMPLETE 54 /** Authentication operation complete. "p.remDev" is valid. */ -#define BTIF_BTEVENT_AUTHENTICATE_CNF 55 +#define BTIF_BTEVENT_AUTHENTICATE_CNF 55 /** Encryption operation complete. "p.remDev" is valid. */ -#define BTIF_BTEVENT_ENCRYPT_COMPLETE 56 +#define BTIF_BTEVENT_ENCRYPT_COMPLETE 56 /** Security mode 3 operation complete. "p.secMode" is valid. */ -#define BTIF_BTIF_BTEVENT_SECURITY3_COMPLETE 57 +#define BTIF_BTIF_BTEVENT_SECURITY3_COMPLETE 57 /** A link key is returned. "p.bdLinkKey" is valid. */ -#define BTIF_BTEVENT_RETURN_LINK_KEYS 58 +#define BTIF_BTEVENT_RETURN_LINK_KEYS 58 /** Out of Band data has been received from the host controller. */ -#define BTIF_BTEVENT_LOCAL_OOB_DATA 59 +#define BTIF_BTEVENT_LOCAL_OOB_DATA 59 /** Request a Pass Key for simple pairing when "errCode" is BEC_NO_ERROR. The * application should call SEC_SetPassKey() to provide the passkey or reject * the request, and optionally save the link key. */ -#define BTIF_BTEVENT_PASS_KEY_REQ 60 +#define BTIF_BTEVENT_PASS_KEY_REQ 60 /** Request a User Confirmation for simple pairing when "errCode" is * BEC_NO_ERROR. */ -#define BTIF_BTEVENT_CONFIRM_NUMERIC_REQ 61 +#define BTIF_BTEVENT_CONFIRM_NUMERIC_REQ 61 -#define BTIF_BTEVENT_DISPLAY_NUMERIC_IND 62 +#define BTIF_BTEVENT_DISPLAY_NUMERIC_IND 62 -#define BTIF_BTEVENT_CONN_PACKET_TYPE_CHNG 63 +#define BTIF_BTEVENT_CONN_PACKET_TYPE_CHNG 63 -#define BTIF_SDEVENT_QUERY_RSP 70 +#define BTIF_SDEVENT_QUERY_RSP 70 -#define BTIF_SDEVENT_QUERY_ERR 71 +#define BTIF_SDEVENT_QUERY_ERR 71 -#define BTIF_SDEVENT_QUERY_FAILED 72 +#define BTIF_SDEVENT_QUERY_FAILED 72 -#define BTIF_BTEVENT_SELECT_DEVICE_REQ 80 +#define BTIF_BTEVENT_SELECT_DEVICE_REQ 80 -#define BTIF_BTEVENT_DEVICE_ADDED 81 +#define BTIF_BTEVENT_DEVICE_ADDED 81 -#define BTIF_BTEVENT_DEVICE_DELETED 82 +#define BTIF_BTEVENT_DEVICE_DELETED 82 -#define BTIF_BTEVENT_MAX_SLOT_CHANGED 83 +#define BTIF_BTEVENT_MAX_SLOT_CHANGED 83 -#define BTIF_BTEVENT_SNIFFER_CONTROL_DONE 84 +#define BTIF_BTEVENT_SNIFFER_CONTROL_DONE 84 -#define BTIF_BTEVENT_LINK_POLICY_CHANGED 85 +#define BTIF_BTEVENT_LINK_POLICY_CHANGED 85 -#define BTIF_BTEVENT_DEFAULT_LINK_POLICY_CHANGED 86 +#define BTIF_BTEVENT_DEFAULT_LINK_POLICY_CHANGED 86 -#define BTIF_BTEVENT_BES_AUD_CONNECTED 200 +#define BTIF_BTEVENT_BES_AUD_CONNECTED 200 -#define BTIF_BTEVENT_BES_AUD_DISCONNECTED 201 +#define BTIF_BTEVENT_BES_AUD_DISCONNECTED 201 -#define BTIF_STACK_LINK_DISCONNECT_COMPLETE 220 +#define BTIF_STACK_LINK_DISCONNECT_COMPLETE 220 typedef uint32_t btif_event_mask_t; -#define BTIF_BEM_NO_EVENTS 0x00000000 -#define BTIF_BEM_INQUIRY_RESULT 0x00000001 -#define BTIF_BEM_INQUIRY_COMPLETE 0x00000002 -#define BTIF_BEM_INQUIRY_CANCELED 0x00000004 -#define BTIF_BEM_LINK_CONNECT_IND 0x00000008 -#define BTIF_BEM_SCO_CONNECT_IND 0x00000010 -#define BTIF_BEM_LINK_DISCONNECT 0x00000020 -#define BTIF_BEM_LINK_CONNECT_CNF 0x00000040 -#define BTIF_BEM_LINK_CON_RESTRICT 0x00000080 -#define BTIF_BEM_MODE_CHANGE 0x00000100 -#define BTIF_BEM_ACCESSIBLE_CHANGE 0x00000200 -#define BTIF_BEM_AUTHENTICATED 0x00000400 -#define BTIF_BEM_ENCRYPTION_CHANGE 0x00000800 -#define BTIF_BEM_SECURITY_CHANGE 0x00001000 -#define BTIF_BEM_ROLE_CHANGE 0x00002000 -#define BTIF_BEM_SCO_DISCONNECT 0x00004000 -#define BTIF_BEM_SCO_CONNECT_CNF 0x00008000 -#define BTIF_BEM_SIMPLE_PAIRING_COMPLETE 0x00010000 -#define BTIF_BEM_REMOTE_FEATURES 0x00020000 -#define BTIF_BEM_REM_HOST_FEATURES 0x00040000 -#define BTIF_BEM_LINK_SUPERV_TIMEOUT_CHANGED 0x00080000 -#define BTIF_BEM_SET_SNIFF_SUBR_PARMS 0x00100000 -#define BTIF_BEM_SNIFF_SUBRATE_INFO 0x00200000 -#define BTIF_BEM_SET_INQ_MODE 0x00400000 -#define BTIF_BEM_SET_INQ_RSP_TX_PWR 0x00800000 -#define BTIF_BEM_SET_EXT_INQ_RESP 0x01000000 -#define BTIF_BEM_SET_ERR_DATA_REP 0x02000000 -#define BTIF_BEM_KEY_PRESSED 0x04000000 -#define BTIF_BEM_CONN_PACKET_TYPE_CHNG 0x08000000 -#define BTIF_BEM_QOS_SETUP_COMPLETE 0x10000000 -#define BTIF_BEM_MAX_SLOT_CHANGED 0x20000000 -#define BTIF_BEM_SNIFFER_CONTROL_DONE 0x40000000 -#define BTIF_BEM_LINK_POLICY_CHANGED 0x80000000 -#define BTIF_BEM_ALL_EVENTS 0xffffffff +#define BTIF_BEM_NO_EVENTS 0x00000000 +#define BTIF_BEM_INQUIRY_RESULT 0x00000001 +#define BTIF_BEM_INQUIRY_COMPLETE 0x00000002 +#define BTIF_BEM_INQUIRY_CANCELED 0x00000004 +#define BTIF_BEM_LINK_CONNECT_IND 0x00000008 +#define BTIF_BEM_SCO_CONNECT_IND 0x00000010 +#define BTIF_BEM_LINK_DISCONNECT 0x00000020 +#define BTIF_BEM_LINK_CONNECT_CNF 0x00000040 +#define BTIF_BEM_LINK_CON_RESTRICT 0x00000080 +#define BTIF_BEM_MODE_CHANGE 0x00000100 +#define BTIF_BEM_ACCESSIBLE_CHANGE 0x00000200 +#define BTIF_BEM_AUTHENTICATED 0x00000400 +#define BTIF_BEM_ENCRYPTION_CHANGE 0x00000800 +#define BTIF_BEM_SECURITY_CHANGE 0x00001000 +#define BTIF_BEM_ROLE_CHANGE 0x00002000 +#define BTIF_BEM_SCO_DISCONNECT 0x00004000 +#define BTIF_BEM_SCO_CONNECT_CNF 0x00008000 +#define BTIF_BEM_SIMPLE_PAIRING_COMPLETE 0x00010000 +#define BTIF_BEM_REMOTE_FEATURES 0x00020000 +#define BTIF_BEM_REM_HOST_FEATURES 0x00040000 +#define BTIF_BEM_LINK_SUPERV_TIMEOUT_CHANGED 0x00080000 +#define BTIF_BEM_SET_SNIFF_SUBR_PARMS 0x00100000 +#define BTIF_BEM_SNIFF_SUBRATE_INFO 0x00200000 +#define BTIF_BEM_SET_INQ_MODE 0x00400000 +#define BTIF_BEM_SET_INQ_RSP_TX_PWR 0x00800000 +#define BTIF_BEM_SET_EXT_INQ_RESP 0x01000000 +#define BTIF_BEM_SET_ERR_DATA_REP 0x02000000 +#define BTIF_BEM_KEY_PRESSED 0x04000000 +#define BTIF_BEM_CONN_PACKET_TYPE_CHNG 0x08000000 +#define BTIF_BEM_QOS_SETUP_COMPLETE 0x10000000 +#define BTIF_BEM_MAX_SLOT_CHANGED 0x20000000 +#define BTIF_BEM_SNIFFER_CONTROL_DONE 0x40000000 +#define BTIF_BEM_LINK_POLICY_CHANGED 0x80000000 +#define BTIF_BEM_ALL_EVENTS 0xffffffff typedef uint8_t btif_error_code_t; -#define BTIF_BEC_NO_ERROR 0x00 -#define BTIF_BEC_UNKNOWN_HCI_CMD 0x01 -#define BTIF_BEC_NO_CONNECTION 0x02 -#define BTIF_BEC_HARDWARE_FAILURE 0x03 -#define BTIF_BEC_PAGE_TIMEOUT 0x04 -#define BTIF_BEC_AUTHENTICATE_FAILURE 0x05 -#define BTIF_BEC_MISSING_KEY 0x06 -#define BTIF_BEC_MEMORY_FULL 0x07 -#define BTIF_BEC_CONNECTION_TIMEOUT 0x08 -#define BTIF_BEC_MAX_CONNECTIONS 0x09 -#define BTIF_BEC_MAX_SCO_CONNECTIONS 0x0a -#define BTIF_BEC_ACL_ALREADY_EXISTS 0x0b -#define BTIF_BEC_COMMAND_DISALLOWED 0x0c -#define BTIF_BEC_LIMITED_RESOURCE 0x0d -#define BTIF_BEC_SECURITY_ERROR 0x0e -#define BTIF_BEC_PERSONAL_DEVICE 0x0f -#define BTIF_BEC_HOST_TIMEOUT 0x10 -#define BTIF_BEC_UNSUPPORTED_FEATURE 0x11 -#define BTIF_BEC_INVALID_HCI_PARM 0x12 -#define BTIF_BEC_USER_TERMINATED 0x13 -#define BTIF_BEC_LOW_RESOURCES 0x14 -#define BTIF_BEC_POWER_OFF 0x15 -#define BTIF_BEC_LOCAL_TERMINATED 0x16 -#define BTIF_BEC_REPEATED_ATTEMPTS 0x17 -#define BTIF_BEC_PAIRING_NOT_ALLOWED 0x18 -#define BTIF_BEC_UNKNOWN_LMP_PDU 0x19 -#define BTIF_BEC_UNSUPPORTED_REMOTE 0x1a -#define BTIF_BEC_SCO_OFFSET_REJECT 0x1b -#define BTIF_BEC_SCO_INTERVAL_REJECT 0x1c -#define BTIF_BEC_SCO_AIR_MODE_REJECT 0x1d -#define BTIF_BEC_INVALID_LMP_PARM 0x1e -#define BTIF_BEC_UNSPECIFIED_ERR 0x1f +#define BTIF_BEC_NO_ERROR 0x00 +#define BTIF_BEC_UNKNOWN_HCI_CMD 0x01 +#define BTIF_BEC_NO_CONNECTION 0x02 +#define BTIF_BEC_HARDWARE_FAILURE 0x03 +#define BTIF_BEC_PAGE_TIMEOUT 0x04 +#define BTIF_BEC_AUTHENTICATE_FAILURE 0x05 +#define BTIF_BEC_MISSING_KEY 0x06 +#define BTIF_BEC_MEMORY_FULL 0x07 +#define BTIF_BEC_CONNECTION_TIMEOUT 0x08 +#define BTIF_BEC_MAX_CONNECTIONS 0x09 +#define BTIF_BEC_MAX_SCO_CONNECTIONS 0x0a +#define BTIF_BEC_ACL_ALREADY_EXISTS 0x0b +#define BTIF_BEC_COMMAND_DISALLOWED 0x0c +#define BTIF_BEC_LIMITED_RESOURCE 0x0d +#define BTIF_BEC_SECURITY_ERROR 0x0e +#define BTIF_BEC_PERSONAL_DEVICE 0x0f +#define BTIF_BEC_HOST_TIMEOUT 0x10 +#define BTIF_BEC_UNSUPPORTED_FEATURE 0x11 +#define BTIF_BEC_INVALID_HCI_PARM 0x12 +#define BTIF_BEC_USER_TERMINATED 0x13 +#define BTIF_BEC_LOW_RESOURCES 0x14 +#define BTIF_BEC_POWER_OFF 0x15 +#define BTIF_BEC_LOCAL_TERMINATED 0x16 +#define BTIF_BEC_REPEATED_ATTEMPTS 0x17 +#define BTIF_BEC_PAIRING_NOT_ALLOWED 0x18 +#define BTIF_BEC_UNKNOWN_LMP_PDU 0x19 +#define BTIF_BEC_UNSUPPORTED_REMOTE 0x1a +#define BTIF_BEC_SCO_OFFSET_REJECT 0x1b +#define BTIF_BEC_SCO_INTERVAL_REJECT 0x1c +#define BTIF_BEC_SCO_AIR_MODE_REJECT 0x1d +#define BTIF_BEC_INVALID_LMP_PARM 0x1e +#define BTIF_BEC_UNSPECIFIED_ERR 0x1f #define BTIF_BEC_UNSUPPORTED_LMP_PARM 0x20 #define BTIF_BEC_ROLE_CHG_NOT_ALLOWED 0x21 #define BTIF_BEC_LMP_RESPONSE_TIMEOUT 0x22 -#define BTIF_BEC_LMP_TRANS_COLLISION 0x23 -#define BTIF_BEC_LMP_PDU_NOT_ALLOWED 0x24 -#define BTIF_BEC_ENCRYP_MODE_NOT_ACC 0x25 -#define BTIF_BEC_UNIT_KEY_USED 0x26 -#define BTIF_BEC_QOS_NOT_SUPPORTED 0x27 -#define BTIF_BEC_INSTANT_PASSED 0x28 +#define BTIF_BEC_LMP_TRANS_COLLISION 0x23 +#define BTIF_BEC_LMP_PDU_NOT_ALLOWED 0x24 +#define BTIF_BEC_ENCRYP_MODE_NOT_ACC 0x25 +#define BTIF_BEC_UNIT_KEY_USED 0x26 +#define BTIF_BEC_QOS_NOT_SUPPORTED 0x27 +#define BTIF_BEC_INSTANT_PASSED 0x28 #define BTIF_BEC_PAIR_UNITKEY_NO_SUPP 0x29 -#define BTIF_BEC_NOT_FOUND 0xf1 -#define BTIF_BEC_REQUEST_CANCELLED 0xf2 +#define BTIF_BEC_NOT_FOUND 0xf1 +#define BTIF_BEC_REQUEST_CANCELLED 0xf2 -#define BTIF_BEC_INVALID_SDP_PDU 0xd1 -#define BTIF_BEC_SDP_DISCONNECT 0xd2 -#define BTIF_BEC_SDP_NO_RESOURCES 0xd3 -#define BTIF_BEC_SDP_INTERNAL_ERR 0xd4 +#define BTIF_BEC_INVALID_SDP_PDU 0xd1 +#define BTIF_BEC_SDP_DISCONNECT 0xd2 +#define BTIF_BEC_SDP_NO_RESOURCES 0xd3 +#define BTIF_BEC_SDP_INTERNAL_ERR 0xd4 -#define BTIF_BEC_STORE_LINK_KEY_ERR 0xe0 +#define BTIF_BEC_STORE_LINK_KEY_ERR 0xe0 typedef uint32_t btif_iac_t; -#define BTIF_BT_IAC_GIAC 0x9E8B33 /* General/Unlimited Inquiry Access Code */ -#define BTIF_BT_IAC_LIAC 0x9E8B00 /* Limited Dedicated Inquiry Access Code */ +#define BTIF_BT_IAC_GIAC 0x9E8B33 /* General/Unlimited Inquiry Access Code */ +#define BTIF_BT_IAC_LIAC 0x9E8B00 /* Limited Dedicated Inquiry Access Code */ typedef uint8_t btif_link_type_t; -#define BTIF_BLT_SCO 0x00 -#define BTIF_BLT_ACL 0x01 -#define BTIF_BLT_ESCO 0x02 +#define BTIF_BLT_SCO 0x00 +#define BTIF_BLT_ACL 0x01 +#define BTIF_BLT_ESCO 0x02 typedef U16 btif_acl_packet; -#define BTIF_BAPT_NO_2_DH1 0x0002 -#define BTIF_BAPT_NO_3_DH1 0x0004 -#define BTIF_BAPT_DM1 0x0008 -#define BTIF_BAPT_DH1 0x0010 -#define BTIF_BAPT_NO_2_DH3 0x0100 -#define BTIF_BAPT_NO_3_DH3 0x0200 -#define BTIF_BAPT_DM3 0x0400 -#define BTIF_BAPT_DH3 0x0800 -#define BTIF_BAPT_NO_2_DH5 0x1000 -#define BTIF_BAPT_NO_3_DH5 0x2000 -#define BTIF_BAPT_DM5 0x4000 -#define BTIF_BAPT_DH5 0x8000 +#define BTIF_BAPT_NO_2_DH1 0x0002 +#define BTIF_BAPT_NO_3_DH1 0x0004 +#define BTIF_BAPT_DM1 0x0008 +#define BTIF_BAPT_DH1 0x0010 +#define BTIF_BAPT_NO_2_DH3 0x0100 +#define BTIF_BAPT_NO_3_DH3 0x0200 +#define BTIF_BAPT_DM3 0x0400 +#define BTIF_BAPT_DH3 0x0800 +#define BTIF_BAPT_NO_2_DH5 0x1000 +#define BTIF_BAPT_NO_3_DH5 0x2000 +#define BTIF_BAPT_DM5 0x4000 +#define BTIF_BAPT_DH5 0x8000 -#define BTIF_2M_PACKET (BTIF_BAPT_DM1|BTIF_BAPT_DH1|BTIF_BAPT_NO_3_DH1|BTIF_BAPT_NO_3_DH3|BTIF_BAPT_DM3|BTIF_BAPT_DH3|BTIF_BAPT_NO_3_DH5) -#define BTIF_3M_PACKET (BTIF_BAPT_DM1|BTIF_BAPT_DH1|BTIF_BAPT_DM3|BTIF_BAPT_DH3|BTIF_BAPT_DM5|BTIF_BAPT_DH5) -#define BTIF_1_SLOT_PACKET (BTIF_BAPT_DM1|BTIF_BAPT_DH1|BTIF_BAPT_NO_3_DH1|BTIF_BAPT_NO_2_DH3|BTIF_BAPT_NO_3_DH3|BTIF_BAPT_NO_2_DH5|BTIF_BAPT_NO_3_DH5) -#define BTIF_3_SLOT_PACKET (BTIF_BAPT_DM1|BTIF_BAPT_NO_3_DH3|BTIF_BAPT_NO_2_DH5|BTIF_BAPT_NO_3_DH5) +#define BTIF_2M_PACKET \ + (BTIF_BAPT_DM1 | BTIF_BAPT_DH1 | BTIF_BAPT_NO_3_DH1 | BTIF_BAPT_NO_3_DH3 | \ + BTIF_BAPT_DM3 | BTIF_BAPT_DH3 | BTIF_BAPT_NO_3_DH5) +#define BTIF_3M_PACKET \ + (BTIF_BAPT_DM1 | BTIF_BAPT_DH1 | BTIF_BAPT_DM3 | BTIF_BAPT_DH3 | \ + BTIF_BAPT_DM5 | BTIF_BAPT_DH5) +#define BTIF_1_SLOT_PACKET \ + (BTIF_BAPT_DM1 | BTIF_BAPT_DH1 | BTIF_BAPT_NO_3_DH1 | BTIF_BAPT_NO_2_DH3 | \ + BTIF_BAPT_NO_3_DH3 | BTIF_BAPT_NO_2_DH5 | BTIF_BAPT_NO_3_DH5) +#define BTIF_3_SLOT_PACKET \ + (BTIF_BAPT_DM1 | BTIF_BAPT_NO_3_DH3 | BTIF_BAPT_NO_2_DH5 | BTIF_BAPT_NO_3_DH5) typedef uint16_t btif_link_policy_t; -#define BTIF_BLP_DISABLE_ALL 0x0000 +#define BTIF_BLP_DISABLE_ALL 0x0000 #define BTIF_BLP_MASTER_SLAVE_SWITCH 0x0001 -#define BTIF_BLP_HOLD_MODE 0x0002 -#define BTIF_BLP_SNIFF_MODE 0x0004 -#define BTIF_BLP_PARK_MODE 0x0008 -#define BTIF_BLP_SCATTER_MODE 0x0010 +#define BTIF_BLP_HOLD_MODE 0x0002 +#define BTIF_BLP_SNIFF_MODE 0x0004 +#define BTIF_BLP_PARK_MODE 0x0008 +#define BTIF_BLP_SCATTER_MODE 0x0010 /* Mask must be updated if new policy values are added */ -#define BLP_MASK 0xfff0 /* Disables ScatterNet bit */ -#define BLP_SCATTER_MASK 0xffe0 /* Enables ScatterNet bit */ +#define BLP_MASK 0xfff0 /* Disables ScatterNet bit */ +#define BLP_SCATTER_MASK 0xffe0 /* Enables ScatterNet bit */ typedef uint8_t btif_accessible_mode_t; -#define BTIF_BAM_NOT_ACCESSIBLE 0x00 /* Non-discoverable or connectable */ -#define BTIF_BAM_GENERAL_ACCESSIBLE 0x03 /* General discoverable and connectable */ -#define BTIF_BAM_LIMITED_ACCESSIBLE 0x13 /* Limited discoverable and connectable */ -#define BTIF_BAM_CONNECTABLE_ONLY 0x02 /* Connectable but not discoverable */ -#define BTIF_BAM_DISCOVERABLE_ONLY 0x01 /* Discoverable but not connectable */ -#define BTIF_BT_DEFAULT_ACCESS_MODE_PAIR BTIF_BAM_GENERAL_ACCESSIBLE -#define BTIF_BAM_INVALID_ACCESS_MODE 0xFF +#define BTIF_BAM_NOT_ACCESSIBLE 0x00 /* Non-discoverable or connectable */ +#define BTIF_BAM_GENERAL_ACCESSIBLE \ + 0x03 /* General discoverable and connectable */ +#define BTIF_BAM_LIMITED_ACCESSIBLE \ + 0x13 /* Limited discoverable and connectable */ +#define BTIF_BAM_CONNECTABLE_ONLY 0x02 /* Connectable but not discoverable */ +#define BTIF_BAM_DISCOVERABLE_ONLY 0x01 /* Discoverable but not connectable */ +#define BTIF_BT_DEFAULT_ACCESS_MODE_PAIR BTIF_BAM_GENERAL_ACCESSIBLE +#define BTIF_BAM_INVALID_ACCESS_MODE 0xFF /* End of BtAccessibleMode */ typedef uint8_t btif_oob_data_present_t; -#define BTIF_OOB_DATA_NOT_PRESENT 0 /* No Out of Band Data is present */ -#define BTIF_OOB_DATA_PRESENT 1 /* Out of Band Data is present */ +#define BTIF_OOB_DATA_NOT_PRESENT 0 /* No Out of Band Data is present */ +#define BTIF_OOB_DATA_PRESENT 1 /* Out of Band Data is present */ typedef uint8_t btif_auth_requirements_t; -#define BTIF_MITM_PROTECT_NOT_REQUIRED 0x00 /* No Man in the Middle protection */ -#define BTIF_MITM_PROTECT_REQUIRED 0x01 /* Man in the Middle protection req */ +#define BTIF_MITM_PROTECT_NOT_REQUIRED \ + 0x00 /* No Man in the Middle protection */ +#define BTIF_MITM_PROTECT_REQUIRED 0x01 /* Man in the Middle protection req */ typedef uint8_t btif_link_mode_t; -#define BTIF_BLM_ACTIVE_MODE 0x00 -#define BTIF_BLM_HOLD_MODE 0x01 -#define BTIF_BLM_SNIFF_MODE 0x02 -#define BTIF_BLM_PARK_MODE 0x03 -#define BTIF_BLM_SCATTER_MODE 0x04 +#define BTIF_BLM_ACTIVE_MODE 0x00 +#define BTIF_BLM_HOLD_MODE 0x01 +#define BTIF_BLM_SNIFF_MODE 0x02 +#define BTIF_BLM_PARK_MODE 0x03 +#define BTIF_BLM_SCATTER_MODE 0x04 typedef uint8_t btif_link_key_type_t; -#define BTIF_COMBINATION_KEY 0x00 -#define BTIF_LOCAL_UNIT_KEY 0x01 -#define BTIF_REMOTE_UNIT_KEY 0x02 -#define BTIF_DEBUG_COMBINATION_KEY 0x03 -#define BTIF_UNAUTH_COMBINATION_KEY 0x04 -#define BTIF_AUTH_COMBINATION_KEY 0x05 -#define BTIF_CHANGED_COMBINATION_KEY 0x06 -#define BTIF_IBRT_STORE_ADDR_ONLY 0x07 +#define BTIF_COMBINATION_KEY 0x00 +#define BTIF_LOCAL_UNIT_KEY 0x01 +#define BTIF_REMOTE_UNIT_KEY 0x02 +#define BTIF_DEBUG_COMBINATION_KEY 0x03 +#define BTIF_UNAUTH_COMBINATION_KEY 0x04 +#define BTIF_AUTH_COMBINATION_KEY 0x05 +#define BTIF_CHANGED_COMBINATION_KEY 0x06 +#define BTIF_IBRT_STORE_ADDR_ONLY 0x07 typedef uint8_t btif_connection_role_t; -#define BTIF_BCR_MASTER 0x00 -#define BTIF_BCR_SLAVE 0x01 -#define BTIF_BCR_ANY 0x02 -#define BTIF_BCR_UNKNOWN 0x03 -#define BTIF_BCR_PSLAVE 0x04 -#define BTIF_BCR_PMASTER 0x05 +#define BTIF_BCR_MASTER 0x00 +#define BTIF_BCR_SLAVE 0x01 +#define BTIF_BCR_ANY 0x02 +#define BTIF_BCR_UNKNOWN 0x03 +#define BTIF_BCR_PSLAVE 0x04 +#define BTIF_BCR_PMASTER 0x05 typedef uint8_t btif_stack_state_t; typedef enum { - HCI_CMD_COMPLETE_USER_IBRT_CMD = 0, - HCI_CMD_COMPLETE_USER_BLE = 1, - HCI_CMD_COMPLETE_USER_RESEVER_1 = 2, - HCI_CMD_COMPLETE_USER_RESEVER_2 = 3, - HCI_CMD_COMPLETE_USER_RESEVER_3 = 4, - HCI_CMD_COMPLETE_USER_RESEVER_4 = 5, + HCI_CMD_COMPLETE_USER_IBRT_CMD = 0, + HCI_CMD_COMPLETE_USER_BLE = 1, + HCI_CMD_COMPLETE_USER_RESEVER_1 = 2, + HCI_CMD_COMPLETE_USER_RESEVER_2 = 3, + HCI_CMD_COMPLETE_USER_RESEVER_3 = 4, + HCI_CMD_COMPLETE_USER_RESEVER_4 = 5, - HCI_CMD_COMPLETE_USER_NUM, -}HCI_CMD_COMPLETE_USER_E; + HCI_CMD_COMPLETE_USER_NUM, +} HCI_CMD_COMPLETE_USER_E; /* The stack has completed initialization of the radio hardware. */ #define BTIF_BTSS_NOT_INITIALIZED 0 /* The stack is initialized. */ -#define BTIF_BTSS_INITIALIZED 1 +#define BTIF_BTSS_INITIALIZED 1 /* The stack has encountered an error while initializing the radio hardware. */ -#define BTIF_BTSS_INITIALIZE_ERR 2 +#define BTIF_BTSS_INITIALIZE_ERR 2 /* The stack is deinitializing. */ -#define BTIF_BTSS_DEINITIALIZE 3 +#define BTIF_BTSS_DEINITIALIZE 3 /* End of BtStackState */ typedef void btif_remote_device_t; - typedef void btif_BtDeviceContext; - /* Forward declaration of the callback parameters */ typedef void btif_event_t; -typedef void (*btif_callback) (const void *); +typedef void (*btif_callback)(const void *); typedef void (*ibrt_cmd_status_callback)(const uint8_t *para); typedef void (*ibrt_cmd_complete_callback)(const uint8_t *para); -typedef uint8_t (*btif_callback_ext) (const void *); -typedef uint8_t (*btif_callback_ext2) (void); -typedef void (*btif_callback_ext3) (void); +typedef uint8_t (*btif_callback_ext)(const void *); +typedef uint8_t (*btif_callback_ext2)(void); +typedef void (*btif_callback_ext3)(void); typedef uint8_t btif_inquiry_mode_t; -#define BTIF_INQ_MODE_NORMAL 0 /* Normal Inquiry Response format */ -#define BTIF_INQ_MODE_RSSI 1 /* RSSI Inquiry Response format */ -#define BTIF_INQ_INVALID_RSSI 127 /* RSSI Inquiry Response format */ -#define BTIF_INQ_MODE_EXTENDED 2 /* Extended or RSSI Inquiry Response format */ +#define BTIF_INQ_MODE_NORMAL 0 /* Normal Inquiry Response format */ +#define BTIF_INQ_MODE_RSSI 1 /* RSSI Inquiry Response format */ +#define BTIF_INQ_INVALID_RSSI 127 /* RSSI Inquiry Response format */ +#define BTIF_INQ_MODE_EXTENDED 2 /* Extended or RSSI Inquiry Response format \ + */ typedef uint8_t btif_rem_dev_state_t; -#define BTIF_BDS_DISCONNECTED 0x00 -#define BTIF_BDS_OUT_CON 0x01 /* Starting an out going connection */ -#define BTIF_BDS_IN_CON 0x02 /* In process of incoming connection */ -#define BTIF_BDS_CONNECTED 0x03 /* Connected */ -#define BTIF_BDS_OUT_DISC 0x04 /* Starting an out going disconnect */ -#define BTIF_BDS_OUT_DISC2 0x05 /* Disconnect status received */ -#define BTIF_BDS_OUT_CON2 0x06 /* In SCO, used when connection request has - been sent */ +#define BTIF_BDS_DISCONNECTED 0x00 +#define BTIF_BDS_OUT_CON 0x01 /* Starting an out going connection */ +#define BTIF_BDS_IN_CON 0x02 /* In process of incoming connection */ +#define BTIF_BDS_CONNECTED 0x03 /* Connected */ +#define BTIF_BDS_OUT_DISC 0x04 /* Starting an out going disconnect */ +#define BTIF_BDS_OUT_DISC2 0x05 /* Disconnect status received */ +#define BTIF_BDS_OUT_CON2 \ + 0x06 /* In SCO, used when connection request has \ + been sent */ typedef uint8_t btif_eir_data_type_t; -#define BTIF_EIR_FLAGS 0x01 -#define BTIF_EIR_SRV_CLASS_16_PART 0x02 -#define BTIF_EIR_SRV_CLASS_16_WHOLE 0x03 -#define BTIF_EIR_SRV_CLASS_32_PART 0x04 -#define BTIF_EIR_SRV_CLASS_32_WHOLE 0x05 -#define BTIF_EIR_SRV_CLASS_128_PART 0x06 -#define BTIF_EIR_SRV_CLASS_128_WHOLE 0x07 -#define BTIF_EIR_REM_NAME_PART 0x08 -#define BTIF_EIR_REM_NAME_WHOLE 0x09 -#define BTIF_EIR_TX_POWER 0x0A -#define BTIF_EIR_MAN_SPECIFIC 0xFF +#define BTIF_EIR_FLAGS 0x01 +#define BTIF_EIR_SRV_CLASS_16_PART 0x02 +#define BTIF_EIR_SRV_CLASS_16_WHOLE 0x03 +#define BTIF_EIR_SRV_CLASS_32_PART 0x04 +#define BTIF_EIR_SRV_CLASS_32_WHOLE 0x05 +#define BTIF_EIR_SRV_CLASS_128_PART 0x06 +#define BTIF_EIR_SRV_CLASS_128_WHOLE 0x07 +#define BTIF_EIR_REM_NAME_PART 0x08 +#define BTIF_EIR_REM_NAME_WHOLE 0x09 +#define BTIF_EIR_TX_POWER 0x0A +#define BTIF_EIR_MAN_SPECIFIC 0xFF -#define BTIF_BR_USE_FEC (0<<0) -#define BTIF_BR_NOT_USE_FEC (1<<0) -#define BTIF_BR_NO_PKT_PRFER_AVALB (0<<1) -#define BTIF_BR_USE_1_SLOT_PKT (1<<1) -#define BTIF_BR_USE_3_SLOT_PKT (2<<1) -#define BTIF_BR_USE_5_SLOT_PKT (3<<1) -#define BTIF_EDR_USE_DM1_PKT (0<<3) -#define BTIF_EDR_USE_2MB_PKT (1<<3) -#define BTIF_EDR_USE_3MB_PKT (2<<3) -#define BTIF_EDR_NO_PKT_PRFER_AVALB (0<<5) -#define BTIF_EDR_USE_1_SLOT_PTK (1<<5) -#define BTIF_EDR_USE_3_SLOT_PTK (2<<5) -#define BTIF_EDR_USE_5_SLOT_PTK (3<<5) +#define BTIF_BR_USE_FEC (0 << 0) +#define BTIF_BR_NOT_USE_FEC (1 << 0) +#define BTIF_BR_NO_PKT_PRFER_AVALB (0 << 1) +#define BTIF_BR_USE_1_SLOT_PKT (1 << 1) +#define BTIF_BR_USE_3_SLOT_PKT (2 << 1) +#define BTIF_BR_USE_5_SLOT_PKT (3 << 1) +#define BTIF_EDR_USE_DM1_PKT (0 << 3) +#define BTIF_EDR_USE_2MB_PKT (1 << 3) +#define BTIF_EDR_USE_3MB_PKT (2 << 3) +#define BTIF_EDR_NO_PKT_PRFER_AVALB (0 << 5) +#define BTIF_EDR_USE_1_SLOT_PTK (1 << 5) +#define BTIF_EDR_USE_3_SLOT_PTK (2 << 5) +#define BTIF_EDR_USE_5_SLOT_PTK (3 << 5) -#define CONN_AUTO_ACCEPT_DISABLE 0x01 +#define CONN_AUTO_ACCEPT_DISABLE 0x01 -#define CONN_AUTO_ACCEPT_ENABLE_WITH_MSS_DISABLE 0x02 +#define CONN_AUTO_ACCEPT_ENABLE_WITH_MSS_DISABLE 0x02 -#define CONN_AUTO_ACCEPT_ENABLE_WITH_MSS_ENABLE 0x03 +#define CONN_AUTO_ACCEPT_ENABLE_WITH_MSS_ENABLE 0x03 /*--------------------------------------------------------------------------- * btif_class_of_device_t type * @@ -527,182 +539,180 @@ typedef uint32_t btif_class_of_device_t; /* Group: Major Service Classes. Can be ORed together */ #define BTIF_COD_LIMITED_DISCOVERABLE_MODE 0x00002000 -#define BTIF_COD_POSITIONING 0x00010000 -#define BTIF_COD_NETWORKING 0x00020000 -#define BTIF_COD_RENDERING 0x00040000 -#define BTIF_COD_CAPTURING 0x00080000 -#define BTIF_COD_OBJECT_TRANSFER 0x00100000 -#define BTIF_COD_AUDIO 0x00200000 -#define BTIF_COD_TELEPHONY 0x00400000 -#define BTIF_COD_INFORMATION 0x00800000 +#define BTIF_COD_POSITIONING 0x00010000 +#define BTIF_COD_NETWORKING 0x00020000 +#define BTIF_COD_RENDERING 0x00040000 +#define BTIF_COD_CAPTURING 0x00080000 +#define BTIF_COD_OBJECT_TRANSFER 0x00100000 +#define BTIF_COD_AUDIO 0x00200000 +#define BTIF_COD_TELEPHONY 0x00400000 +#define BTIF_COD_INFORMATION 0x00800000 /* Group: Major Device Classes (Select one) */ -#define BTIF_COD_MAJOR_MISCELLANEOUS 0x00000000 -#define BTIF_COD_MAJOR_COMPUTER 0x00000100 -#define BTIF_COD_MAJOR_PHONE 0x00000200 -#define BTIF_COD_MAJOR_LAN_ACCESS_POINT 0x00000300 -#define BTIF_COD_MAJOR_AUDIO 0x00000400 -#define BTIF_COD_MAJOR_PERIPHERAL 0x00000500 -#define BTIF_COD_MAJOR_IMAGING 0x00000600 -#define BTIF_COD_MAJOR_UNCLASSIFIED 0x00001F00 +#define BTIF_COD_MAJOR_MISCELLANEOUS 0x00000000 +#define BTIF_COD_MAJOR_COMPUTER 0x00000100 +#define BTIF_COD_MAJOR_PHONE 0x00000200 +#define BTIF_COD_MAJOR_LAN_ACCESS_POINT 0x00000300 +#define BTIF_COD_MAJOR_AUDIO 0x00000400 +#define BTIF_COD_MAJOR_PERIPHERAL 0x00000500 +#define BTIF_COD_MAJOR_IMAGING 0x00000600 +#define BTIF_COD_MAJOR_UNCLASSIFIED 0x00001F00 /* Group: Minor Device Class - Computer Major class */ -#define BTIF_COD_MINOR_COMP_UNCLASSIFIED 0x00000000 -#define BTIF_COD_MINOR_COMP_DESKTOP 0x00000004 -#define BTIF_COD_MINOR_COMP_SERVER 0x00000008 -#define BTIF_COD_MINOR_COMP_LAPTOP 0x0000000C -#define BTIF_COD_MINOR_COMP_HANDHELD 0x00000010 -#define BTIF_COD_MINOR_COMP_PALM 0x00000014 -#define BTIF_COD_MINOR_COMP_WEARABLE 0x00000018 +#define BTIF_COD_MINOR_COMP_UNCLASSIFIED 0x00000000 +#define BTIF_COD_MINOR_COMP_DESKTOP 0x00000004 +#define BTIF_COD_MINOR_COMP_SERVER 0x00000008 +#define BTIF_COD_MINOR_COMP_LAPTOP 0x0000000C +#define BTIF_COD_MINOR_COMP_HANDHELD 0x00000010 +#define BTIF_COD_MINOR_COMP_PALM 0x00000014 +#define BTIF_COD_MINOR_COMP_WEARABLE 0x00000018 /* Group: Minor Device Class - Phone Major class */ -#define BTIF_COD_MINOR_PHONE_UNCLASSIFIED 0x00000000 -#define BTIF_COD_MINOR_PHONE_CELLULAR 0x00000004 -#define BTIF_COD_MINOR_PHONE_CORDLESS 0x00000008 -#define BTIF_COD_MINOR_PHONE_SMART 0x0000000C -#define BTIF_COD_MINOR_PHONE_MODEM 0x00000010 -#define BTIF_COD_MINOR_PHONE_ISDN 0x00000014 +#define BTIF_COD_MINOR_PHONE_UNCLASSIFIED 0x00000000 +#define BTIF_COD_MINOR_PHONE_CELLULAR 0x00000004 +#define BTIF_COD_MINOR_PHONE_CORDLESS 0x00000008 +#define BTIF_COD_MINOR_PHONE_SMART 0x0000000C +#define BTIF_COD_MINOR_PHONE_MODEM 0x00000010 +#define BTIF_COD_MINOR_PHONE_ISDN 0x00000014 /* Group: Minor Device Class - LAN Access Point Major class */ -#define BTIF_COD_MINOR_LAN_0 0x00000000 /* fully available */ -#define BTIF_COD_MINOR_LAN_17 0x00000020 /* 1-17% utilized */ -#define BTIF_COD_MINOR_LAN_33 0x00000040 /* 17-33% utilized */ -#define BTIF_COD_MINOR_LAN_50 0x00000060 /* 33-50% utilized */ -#define BTIF_COD_MINOR_LAN_67 0x00000080 /* 50-67% utilized */ -#define BTIF_COD_MINOR_LAN_83 0x000000A0 /* 67-83% utilized */ -#define BTIF_COD_MINOR_LAN_99 0x000000C0 /* 83-99% utilized */ -#define BTIF_COD_MINOR_LAN_NO_SERVICE 0x000000E0 /* 100% utilized */ +#define BTIF_COD_MINOR_LAN_0 0x00000000 /* fully available */ +#define BTIF_COD_MINOR_LAN_17 0x00000020 /* 1-17% utilized */ +#define BTIF_COD_MINOR_LAN_33 0x00000040 /* 17-33% utilized */ +#define BTIF_COD_MINOR_LAN_50 0x00000060 /* 33-50% utilized */ +#define BTIF_COD_MINOR_LAN_67 0x00000080 /* 50-67% utilized */ +#define BTIF_COD_MINOR_LAN_83 0x000000A0 /* 67-83% utilized */ +#define BTIF_COD_MINOR_LAN_99 0x000000C0 /* 83-99% utilized */ +#define BTIF_COD_MINOR_LAN_NO_SERVICE 0x000000E0 /* 100% utilized */ /* Group: Minor Device Class - Audio Major class */ -#define BTIF_COD_MINOR_AUDIO_UNCLASSIFIED 0x00000000 -#define BTIF_COD_MINOR_AUDIO_HEADSET 0x00000004 -#define BTIF_COD_MINOR_AUDIO_HANDSFREE 0x00000008 -#define BTIF_COD_MINOR_AUDIO_MICROPHONE 0x00000010 -#define BTIF_COD_MINOR_AUDIO_LOUDSPEAKER 0x00000014 -#define BTIF_COD_MINOR_AUDIO_HEADPHONES 0x00000018 +#define BTIF_COD_MINOR_AUDIO_UNCLASSIFIED 0x00000000 +#define BTIF_COD_MINOR_AUDIO_HEADSET 0x00000004 +#define BTIF_COD_MINOR_AUDIO_HANDSFREE 0x00000008 +#define BTIF_COD_MINOR_AUDIO_MICROPHONE 0x00000010 +#define BTIF_COD_MINOR_AUDIO_LOUDSPEAKER 0x00000014 +#define BTIF_COD_MINOR_AUDIO_HEADPHONES 0x00000018 #define BTIF_COD_MINOR_AUDIO_PORTABLEAUDIO 0x0000001C -#define BTIF_COD_MINOR_AUDIO_CARAUDIO 0x00000020 -#define BTIF_COD_MINOR_AUDIO_SETTOPBOX 0x00000024 -#define BTIF_COD_MINOR_AUDIO_HIFIAUDIO 0x00000028 -#define BTIF_COD_MINOR_AUDIO_VCR 0x0000002C -#define BTIF_COD_MINOR_AUDIO_VIDEOCAMERA 0x00000030 -#define BTIF_COD_MINOR_AUDIO_CAMCORDER 0x00000034 -#define BTIF_COD_MINOR_AUDIO_VIDEOMONITOR 0x00000038 -#define BTIF_COD_MINOR_AUDIO_VIDEOSPEAKER 0x0000003C -#define BTIF_COD_MINOR_AUDIO_CONFERENCING 0x00000040 -#define BTIF_COD_MINOR_AUDIO_GAMING 0x00000048 +#define BTIF_COD_MINOR_AUDIO_CARAUDIO 0x00000020 +#define BTIF_COD_MINOR_AUDIO_SETTOPBOX 0x00000024 +#define BTIF_COD_MINOR_AUDIO_HIFIAUDIO 0x00000028 +#define BTIF_COD_MINOR_AUDIO_VCR 0x0000002C +#define BTIF_COD_MINOR_AUDIO_VIDEOCAMERA 0x00000030 +#define BTIF_COD_MINOR_AUDIO_CAMCORDER 0x00000034 +#define BTIF_COD_MINOR_AUDIO_VIDEOMONITOR 0x00000038 +#define BTIF_COD_MINOR_AUDIO_VIDEOSPEAKER 0x0000003C +#define BTIF_COD_MINOR_AUDIO_CONFERENCING 0x00000040 +#define BTIF_COD_MINOR_AUDIO_GAMING 0x00000048 /* Group: Minor Device Class - Peripheral Major class */ -#define BTIF_COD_MINOR_PERIPH_KEYBOARD 0x00000040 -#define BTIF_COD_MINOR_PERIPH_POINTING 0x00000080 -#define BTIF_COD_MINOR_PERIPH_COMBOKEY 0x000000C0 +#define BTIF_COD_MINOR_PERIPH_KEYBOARD 0x00000040 +#define BTIF_COD_MINOR_PERIPH_POINTING 0x00000080 +#define BTIF_COD_MINOR_PERIPH_COMBOKEY 0x000000C0 /* Group: Minor Device Class - ORed with Peripheral Minor Device class */ #define BTIF_COD_MINOR_PERIPH_UNCLASSIFIED 0x00000000 -#define BTIF_COD_MINOR_PERIPH_JOYSTICK 0x00000004 -#define BTIF_COD_MINOR_PERIPH_GAMEPAD 0x00000008 -#define BTIF_COD_MINOR_PERIPH_REMOTECTRL 0x0000000C -#define BTIF_COD_MINOR_PERIPH_SENSING 0x00000010 -#define BTIF_COD_MINOR_PERIPH_DIGITIZER 0x00000014 -#define BTIF_COD_MINOR_PERIPH_CARD_RDR 0x00000018 +#define BTIF_COD_MINOR_PERIPH_JOYSTICK 0x00000004 +#define BTIF_COD_MINOR_PERIPH_GAMEPAD 0x00000008 +#define BTIF_COD_MINOR_PERIPH_REMOTECTRL 0x0000000C +#define BTIF_COD_MINOR_PERIPH_SENSING 0x00000010 +#define BTIF_COD_MINOR_PERIPH_DIGITIZER 0x00000014 +#define BTIF_COD_MINOR_PERIPH_CARD_RDR 0x00000018 /* Group: Minor Device Class - Imaging Major class */ -#define BTIF_COD_MINOR_IMAGE_UNCLASSIFIED 0x00000000 -#define BTIF_COD_MINOR_IMAGE_DISPLAY 0x00000010 -#define BTIF_COD_MINOR_IMAGE_CAMERA 0x00000020 -#define BTIF_COD_MINOR_IMAGE_SCANNER 0x00000040 -#define BTIF_COD_MINOR_IMAGE_PRINTER 0x00000080 +#define BTIF_COD_MINOR_IMAGE_UNCLASSIFIED 0x00000000 +#define BTIF_COD_MINOR_IMAGE_DISPLAY 0x00000010 +#define BTIF_COD_MINOR_IMAGE_CAMERA 0x00000020 +#define BTIF_COD_MINOR_IMAGE_SCANNER 0x00000040 +#define BTIF_COD_MINOR_IMAGE_PRINTER 0x00000080 /* Group: Masks used to isolate the class of device components */ -#define BTIF_COD_SERVICE_MASK 0x00ffC000 /* Less LIAC bit */ -#define BTIF_COD_MAJOR_MASK 0x00001F00 -#define BTIF_COD_MINOR_MASK 0x000000FC -#define BTIF_COD_LIMITED_DISC_MASK 0x00002000 /* LIAC bit */ +#define BTIF_COD_SERVICE_MASK 0x00ffC000 /* Less LIAC bit */ +#define BTIF_COD_MAJOR_MASK 0x00001F00 +#define BTIF_COD_MINOR_MASK 0x000000FC +#define BTIF_COD_LIMITED_DISC_MASK 0x00002000 /* LIAC bit */ /* End of btif_class_of_device_t */ -//when report_format=0,data_format will set the interval(unit:slot) -//when report_format=1,data_format will set the packet total num -//when report_format=2,data_format has no meaning -#define FLAG_RESET_DATA 2 -#define FLAG_START_DATA 1 -#define FLAG_GET_DATA 0 +// when report_format=0,data_format will set the interval(unit:slot) +// when report_format=1,data_format will set the packet total num +// when report_format=2,data_format has no meaning +#define FLAG_RESET_DATA 2 +#define FLAG_START_DATA 1 +#define FLAG_GET_DATA 0 -#define REP_FORMAT_TIME 0 -#define REP_FORMAT_PACKET 1 -#define REP_FORMAT_STOP_GET 2 - - -//Vendor defined error code -#define BTIF_EVT_ERROR_SCO_UNKNOWN (0xE8) -#define BTIF_EVT_ERROR_ACL_UNKNOWN (0xE9) +#define REP_FORMAT_TIME 0 +#define REP_FORMAT_PACKET 1 +#define REP_FORMAT_STOP_GET 2 +// Vendor defined error code +#define BTIF_EVT_ERROR_SCO_UNKNOWN (0xE8) +#define BTIF_EVT_ERROR_ACL_UNKNOWN (0xE9) typedef struct { - list_entry_t node; - uint8_t opType; + list_entry_t node; + uint8_t opType; } btif_operation_t; typedef struct { - /* the mandatory sniff interval range for controllers is between 0x0006 and 0x0540. - * The value is expressed in 0.625 ms increments (0x0006 = 3.75 ms). - * - * The actual interval selected by the radio will be returned in - * a BTEVENT_MODE_CHANGE event. - */ + /* the mandatory sniff interval range for controllers is between 0x0006 and + * 0x0540. The value is expressed in 0.625 ms increments (0x0006 = 3.75 ms). + * + * The actual interval selected by the radio will be returned in + * a BTEVENT_MODE_CHANGE event. + */ - uint16_t maxInterval; + uint16_t maxInterval; - /* Minimum acceptable interval between each consecutive sniff period. - * Must be an even number between 0x0002 and 0xFFFE, and be less than - * "maxInterval". Like maxInterval this value is expressed in - * 0.625 ms increments. - */ - uint16_t minInterval; + /* Minimum acceptable interval between each consecutive sniff period. + * Must be an even number between 0x0002 and 0xFFFE, and be less than + * "maxInterval". Like maxInterval this value is expressed in + * 0.625 ms increments. + */ + uint16_t minInterval; - /* The number of master-to-slave transmission slots during which - * a device should listen for traffic (sniff attempt). - * Expressed in 0.625 ms increments. May be between 0x0001 and 0x7FFF. - */ - uint16_t attempt; + /* The number of master-to-slave transmission slots during which + * a device should listen for traffic (sniff attempt). + * Expressed in 0.625 ms increments. May be between 0x0001 and 0x7FFF. + */ + uint16_t attempt; - /* The amount of time before a sniff timeout occurs. Expressed in - * 1.25 ms increments. May be between 0x0000 and 0x7FFF, but the mandatory - * range for controllers is 0x0000 to 0x0028. - */ - uint16_t timeout; + /* The amount of time before a sniff timeout occurs. Expressed in + * 1.25 ms increments. May be between 0x0000 and 0x7FFF, but the mandatory + * range for controllers is 0x0000 to 0x0028. + */ + uint16_t timeout; } btif_sniff_info_t; typedef struct { - /* May be any number between 0x0000 and 0xFFFE. The value is expressed in 0.625 ms - * increments. - */ - uint16_t maxLatency; + /* May be any number between 0x0000 and 0xFFFE. The value is expressed in + * 0.625 ms increments. + */ + uint16_t maxLatency; - /* any number between 0x0000 and 0xFFFE. The value is expressed in - * 0.625 ms increments. - */ - uint16_t minRemoteTimeout; + /* any number between 0x0000 and 0xFFFE. The value is expressed in + * 0.625 ms increments. + */ + uint16_t minRemoteTimeout; - /* Minimum base sniff subrate timeout that the local device may use. - * May be any number between 0x0000 and 0xFFFE. The value is expressed in - * 0.625 ms increments. - */ - uint16_t minLocalTimeout; + /* Minimum base sniff subrate timeout that the local device may use. + * May be any number between 0x0000 and 0xFFFE. The value is expressed in + * 0.625 ms increments. + */ + uint16_t minLocalTimeout; } btif_sniff_subrate_parms_t; typedef struct { - uint16_t inqInterval; /* Inquiry scan interval */ - uint16_t inqWindow; /* Inquiry scan Window */ - uint16_t pageInterval; /* Page scan interval */ - uint16_t pageWindow; /* Page scan window */ + uint16_t inqInterval; /* Inquiry scan interval */ + uint16_t inqWindow; /* Inquiry scan Window */ + uint16_t pageInterval; /* Page scan interval */ + uint16_t pageWindow; /* Page scan window */ } btif_access_mode_info_t; typedef struct { - list_entry_t node; /* For internal stack use only. */ - btif_callback callback; /* Pointer to callback function */ - btif_event_mask_t emask; /* For internal stack use only. */ + list_entry_t node; /* For internal stack use only. */ + btif_callback callback; /* Pointer to callback function */ + btif_event_mask_t emask; /* For internal stack use only. */ } btif_handler; /* Internal types required for BtRemoteDevice structure */ @@ -720,655 +730,678 @@ typedef uint8_t btif_op_type_t; typedef struct { - /* Reserved */ - uint8_t flags; + /* Reserved */ + uint8_t flags; - /* Service Type: 0 = No Traffic, 1 = Best Effort, 2 Guaranteed */ - uint8_t serviceType; + /* Service Type: 0 = No Traffic, 1 = Best Effort, 2 Guaranteed */ + uint8_t serviceType; - /* Token Rate in octets per second */ - uint32_t tokenRate; + /* Token Rate in octets per second */ + uint32_t tokenRate; - /* Peak Bandwidth in octets per second */ - uint32_t peakBandwidth; + /* Peak Bandwidth in octets per second */ + uint32_t peakBandwidth; - /* Latency in microseconds */ - uint32_t latency; + /* Latency in microseconds */ + uint32_t latency; - /* Delay Variation in microseconds */ - uint32_t delayVariation; + /* Delay Variation in microseconds */ + uint32_t delayVariation; } btif_qos_info_t; typedef struct { - bt_bdaddr_t bdAddr; - BOOL trusted; - uint8_t linkKey[16]; - btif_link_key_type_t keyType; + bt_bdaddr_t bdAddr; + BOOL trusted; + uint8_t linkKey[16]; + btif_link_key_type_t keyType; - uint8_t pinLen; + uint8_t pinLen; } btif_device_record_t; typedef struct { - btif_operation_t op; - uint8_t len; - uint8_t data[31]; + btif_operation_t op; + uint8_t len; + uint8_t data[31]; } btif_write_adv_data_op_t; typedef struct { - uint16_t interval_min; - uint16_t interval_max; - uint8_t adv_type; - uint8_t own_addr_type; - uint8_t peer_addr_type; - bt_bdaddr_t bd_addr; - uint8_t adv_chanmap; - uint8_t adv_filter_policy; + uint16_t interval_min; + uint16_t interval_max; + uint8_t adv_type; + uint8_t own_addr_type; + uint8_t peer_addr_type; + bt_bdaddr_t bd_addr; + uint8_t adv_chanmap; + uint8_t adv_filter_policy; } btif_adv_para_struct_t; typedef struct { - btif_operation_t op; - btif_adv_para_struct_t adv_para; + btif_operation_t op; + btif_adv_para_struct_t adv_para; } btif_write_adv_para_op_t; typedef struct { - btif_operation_t op; - uint8_t en; + btif_operation_t op; + uint8_t en; } btif_write_adv_en_op_t; #define BLE_ADV_REPORT_MAX_LEN 31 typedef struct { - uint8_t type; - uint8_t addr_type; - bt_bdaddr_t addr; - uint8_t data_len; - uint8_t data[BLE_ADV_REPORT_MAX_LEN]; - int8_t rssi; + uint8_t type; + uint8_t addr_type; + bt_bdaddr_t addr; + uint8_t data_len; + uint8_t data[BLE_ADV_REPORT_MAX_LEN]; + int8_t rssi; } btif_ble_adv_report; typedef struct { - uint8_t scan_type; - uint16_t scan_interval; - uint16_t scan_window; - uint8_t own_addr_type; - uint8_t scan_filter_policy; + uint8_t scan_type; + uint16_t scan_interval; + uint16_t scan_window; + uint8_t own_addr_type; + uint8_t scan_filter_policy; } btif_scan_para_struct_t; typedef struct { - btif_operation_t op; - btif_scan_para_struct_t scan_para; + btif_operation_t op; + btif_scan_para_struct_t scan_para; } btif_write_scan_para_op_t; typedef struct { - btif_operation_t op; - uint8_t scan_en; - uint32_t filter_duplicat; + btif_operation_t op; + uint8_t scan_en; + uint32_t filter_duplicat; } btif_write_scan_en_op_t; -typedef struct -{ - bt_bdaddr_t bdAddr; /* Device Address */ - uint8_t linkKey[16]; +typedef struct { + bt_bdaddr_t bdAddr; /* Device Address */ + uint8_t linkKey[16]; } btif_dev_linkkey; -typedef struct -{ - U8 psRepMode; - U8 psMode; - U16 clockOffset; +typedef struct { + U8 psRepMode; + U8 psMode; + U16 clockOffset; } bt_page_scanInfo_t; -typedef struct -{ - bt_bdaddr_t bdAddr; /* Device Address */ - bt_page_scanInfo_t psi; /* Page scan info used for connecting */ - U8 psPeriodMode; - U32 classOfDevice; +typedef struct { + bt_bdaddr_t bdAddr; /* Device Address */ + bt_page_scanInfo_t psi; /* Page scan info used for connecting */ + U8 psPeriodMode; + U32 classOfDevice; - /* RSSI in dBm (-127 to +20). Only valid when controller reports RSSI with - * in inquiry results (also see ME_SetInquiryMode). Otherwise it will be - * set to BT_INVALID_RSSI. - */ - S8 rssi; + /* RSSI in dBm (-127 to +20). Only valid when controller reports RSSI with + * in inquiry results (also see ME_SetInquiryMode). Otherwise it will be + * set to BT_INVALID_RSSI. + */ + S8 rssi; - /* Extended Inquiry response. Only valid when controller reports an - * extended inquiry (also see ME_SetInquiryMode). Otherwise it will be - * set to all 0's. - */ - U8 extInqResp[240]; + /* Extended Inquiry response. Only valid when controller reports an + * extended inquiry (also see ME_SetInquiryMode). Otherwise it will be + * set to all 0's. + */ + U8 extInqResp[240]; - /* Describes the format of the current inquiry result */ - U8 inqMode; + /* Describes the format of the current inquiry result */ + U8 inqMode; } bt_Inquiry_result_t; -typedef struct -{ - /* Event causing callback. Always valid.*/ - uint8_t eType; +typedef struct { + /* Event causing callback. Always valid.*/ + uint8_t eType; - /* Error code. See BtEventType for guidance on whether errCode is valid. */ - uint8_t errCode; + /* Error code. See BtEventType for guidance on whether errCode is valid. */ + uint8_t errCode; - /* Pointer to handler. Only valid for events directed to BtHandlers. */ - btif_handler *handler; + /* Pointer to handler. Only valid for events directed to BtHandlers. */ + btif_handler *handler; - /* Parameters */ - union - { - btif_accessible_mode_t aMode; /* New access mode */ - void *remDev; /* Pointer to remote device */ - bt_bdaddr_t bdAddr; /* Device Address */ - void *meToken; /* Me command token */ - U8 pMode; /* Simple Pairing Mode */ + /* Parameters */ + union { + btif_accessible_mode_t aMode; /* New access mode */ + void *remDev; /* Pointer to remote device */ + bt_bdaddr_t bdAddr; /* Device Address */ + void *meToken; /* Me command token */ + U8 pMode; /* Simple Pairing Mode */ #ifdef __TWS_RECONNECT_USE_BLE__ - struct - { - U8 *data; - U16 len; - } twsBleReport; + struct { + U8 *data; + U16 len; + } twsBleReport; #endif - bt_Inquiry_result_t inqResult; + bt_Inquiry_result_t inqResult; - void *secToken; /* Security Token */ - void *token; + void *secToken; /* Security Token */ + void *token; - /* Information for BTEVENT_PAIRING_COMPLETE */ - struct - { - void *remDev; - btif_link_key_type_t keyType; - } pairingInfo; + /* Information for BTEVENT_PAIRING_COMPLETE */ + struct { + void *remDev; + btif_link_key_type_t keyType; + } pairingInfo; - /* Information for BTEVENT_PIN_REQ */ - struct - { - void *remDev; + /* Information for BTEVENT_PIN_REQ */ + struct { + void *remDev; - /* If > 0 then the pin length returned in SEC_SetPin must be >= pinLen */ - U8 pinLen; - } pinReq; + /* If > 0 then the pin length returned in SEC_SetPin must be >= pinLen */ + U8 pinLen; + } pinReq; - /* Information for BTEVENT_SET_INQUIRY_MODE_CNF */ - btif_inquiry_mode_t inqMode; + /* Information for BTEVENT_SET_INQUIRY_MODE_CNF */ + btif_inquiry_mode_t inqMode; - /* Information for BTEVENT_SET_INQ_TX_PWR_LVL_CNF */ - S8 inqTxPwr; + /* Information for BTEVENT_SET_INQ_TX_PWR_LVL_CNF */ + S8 inqTxPwr; - /* Information for BTEVENT_REMOTE_FEATURES */ - struct - { - bt_bdaddr_t bdAddr; - U8 features[8]; - } remoteFeatures; + /* Information for BTEVENT_REMOTE_FEATURES */ + struct { + bt_bdaddr_t bdAddr; + U8 features[8]; + } remoteFeatures; - /* Information for BTEVENT_REM_HOST_FEATURES */ - struct - { - bt_bdaddr_t bdAddr; - U8 features[8]; - } remHostFeatures; + /* Information for BTEVENT_REM_HOST_FEATURES */ + struct { + bt_bdaddr_t bdAddr; + U8 features[8]; + } remHostFeatures; - /* Information for BTEVENT_LINK_SUPERV_TIMEOUT_CHANGED */ - struct - { - void *remDev; - U16 timeout; - } linkSupervision; + /* Information for BTEVENT_LINK_SUPERV_TIMEOUT_CHANGED */ + struct { + void *remDev; + U16 timeout; + } linkSupervision; - /* Information for BTEVENT_MAX_SLOT_CHANGED */ - struct - { - U16 connHandle; - U8 maxSlot; - } maxSlotChanged; + /* Information for BTEVENT_MAX_SLOT_CHANGED */ + struct { + U16 connHandle; + U8 maxSlot; + } maxSlotChanged; - /* Information for BTEVENT_QOS_SETUP_COMPLETE */ - struct - { + /* Information for BTEVENT_QOS_SETUP_COMPLETE */ + struct { - /* Reserved */ - U8 flags; + /* Reserved */ + U8 flags; - /* Service Type: 0 = No Traffic, 1 = Best Effort, 2 Guaranteed */ - U8 serviceType; + /* Service Type: 0 = No Traffic, 1 = Best Effort, 2 Guaranteed */ + U8 serviceType; - /* Token Rate in octets per second */ - U32 tokenRate; + /* Token Rate in octets per second */ + U32 tokenRate; - /* Peak Bandwidth in octets per second */ - U32 peakBandwidth; + /* Peak Bandwidth in octets per second */ + U32 peakBandwidth; - /* Latency in microseconds */ - U32 latency; + /* Latency in microseconds */ + U32 latency; - /* Delay Variation in microseconds */ - U32 delayVariation; - } qos; + /* Delay Variation in microseconds */ + U32 delayVariation; + } qos; - /* Result for BTEVENT_SET_SNIFF_SUBRATING_PARMS_CNF */ - btif_sniff_subrate_parms_t *sniffSubrateParms; + /* Result for BTEVENT_SET_SNIFF_SUBRATING_PARMS_CNF */ + btif_sniff_subrate_parms_t *sniffSubrateParms; - /* Information for BTEVENT_SNIFF_SUBRATE_INFO */ - struct - { - /* Pointer to the remote device */ - void *remDev; + /* Information for BTEVENT_SNIFF_SUBRATE_INFO */ + struct { + /* Pointer to the remote device */ + void *remDev; - /* Maximum latency for data being transmitted from the local - * device to the remote device. - */ - U16 maxTxLatency; + /* Maximum latency for data being transmitted from the local + * device to the remote device. + */ + U16 maxTxLatency; - /* Maximum latency for data being received by the local - * device from the remote device. - */ - U16 maxRxLatency; + /* Maximum latency for data being received by the local + * device from the remote device. + */ + U16 maxRxLatency; - /* The base sniff subrate timeout in baseband slots that the - * remote device shall use. - */ - U16 minRemoteTimeout; + /* The base sniff subrate timeout in baseband slots that the + * remote device shall use. + */ + U16 minRemoteTimeout; - /* The base sniff subrate timeout in baseband slots that the - * local device will use. - */ - U16 minLocalTimeout; - } sniffSubrateInfo; + /* The base sniff subrate timeout in baseband slots that the + * local device will use. + */ + U16 minLocalTimeout; + } sniffSubrateInfo; - /* Result for BTEVENT_LOCAL_OOB_DATA */ - struct - { - /* Simple Pairing Hash C from the local device */ - U8 hashC[16]; + /* Result for BTEVENT_LOCAL_OOB_DATA */ + struct { + /* Simple Pairing Hash C from the local device */ + U8 hashC[16]; - /* Simple Pairing Randomizer R the local device */ - U8 randR[16]; - } oobData; + /* Simple Pairing Randomizer R the local device */ + U8 randR[16]; + } oobData; - /* Information for BTEVENT_CONFIRM_NUMERIC_REQ, BTEVENT_PASS_KEY_REQ, - * and BTEVENT_DISPLAY_NUMERIC_IND - */ - struct - { - void *remDev; /* Pointer to the remote device */ - U32 numeric; /* Numeric value received from Secure - * Simple Pairing (not valid for - * BTEVENT_PASS_KEY_REQ - */ + /* Information for BTEVENT_CONFIRM_NUMERIC_REQ, BTEVENT_PASS_KEY_REQ, + * and BTEVENT_DISPLAY_NUMERIC_IND + */ + struct { + void *remDev; /* Pointer to the remote device */ + U32 numeric; /* Numeric value received from Secure + * Simple Pairing (not valid for + * BTEVENT_PASS_KEY_REQ + */ - U8 bondingMode; /* Bonding has been requested */ - } userIoReq; + U8 bondingMode; /* Bonding has been requested */ + } userIoReq; - /* Result for BTEVENT_ENCRYPTION_CHANGE event. */ - struct - { - void *remDev; - U8 mode; /* New encryption mode (uses the - * BtEncryptMode type) */ - } encrypt; + /* Result for BTEVENT_ENCRYPTION_CHANGE event. */ + struct { + void *remDev; + U8 mode; /* New encryption mode (uses the + * BtEncryptMode type) */ + } encrypt; - /* Result for BTEVENT_KEY_PRESSED */ - struct - { - bt_bdaddr_t bdAddr; /* Address of the device sending the keypress */ - U8 parm; /* The value of the keypress parameter */ - } keyPress; + /* Result for BTEVENT_KEY_PRESSED */ + struct { + bt_bdaddr_t bdAddr; /* Address of the device sending the keypress */ + U8 parm; /* The value of the keypress parameter */ + } keyPress; - struct - { - void *remDev; + struct { + void *remDev; - /* If disconnection was successful, contains BEC_NO_ERROR. - * errCode will contain the disconnect reason. - * - * Unsuccessful disconnections will contain an error code - * as generated by the radio. In this case, errCode can be - * ignored. - */ - btif_error_code_t status; - } disconnect; + /* If disconnection was successful, contains BEC_NO_ERROR. + * errCode will contain the disconnect reason. + * + * Unsuccessful disconnections will contain an error code + * as generated by the radio. In this case, errCode can be + * ignored. + */ + btif_error_code_t status; + } disconnect; - /* Result for the BTEVENT_SCO_DATA_CNF event */ - struct - { - void *remDev; /* Pointer to remote device */ - void *scoCon; /* SCO connection */ - void *scoPacket; /* SCO Packet Handled */ - } scoPacketHandled; + /* Result for the BTEVENT_SCO_DATA_CNF event */ + struct { + void *remDev; /* Pointer to remote device */ + void *scoCon; /* SCO connection */ + void *scoPacket; /* SCO Packet Handled */ + } scoPacketHandled; - /* Result for the BTEVENT_SCO_CONNECT_CNF && BTEVENT_SCO_CONNECT_IND - events. - */ - struct - { - void *remDev; /* Pointer to remote device */ - U16 scoHandle; /* SCO Connection handle for HCI */ - void *scoCon; /* SCO connection */ - U8 scoLinkType;/* SCO link type */ - void *scoTxParms; /* Pointer to eSCO TX parameters */ - void *scoRxParms; /* Pointer to eSCO RX parameters */ - } scoConnect; + /* Result for the BTEVENT_SCO_CONNECT_CNF && BTEVENT_SCO_CONNECT_IND + events. + */ + struct { + void *remDev; /* Pointer to remote device */ + U16 scoHandle; /* SCO Connection handle for HCI */ + void *scoCon; /* SCO connection */ + U8 scoLinkType; /* SCO link type */ + void *scoTxParms; /* Pointer to eSCO TX parameters */ + void *scoRxParms; /* Pointer to eSCO RX parameters */ + } scoConnect; - /* Result for the BTEVENT_SCO_DATA_IND event */ - struct - { - void *remDev; /* Pointer to remote device */ - U16 scoHandle; /* SCO Connection handle for HCI */ - void *scoCon; /* SCO connection. */ - U8 len; /* SCO data len */ - U8 *ptr; /* SCO data ptr */ - U8 errFlags; /* Erroneous Data Reporting */ - } scoDataInd; + /* Result for the BTEVENT_SCO_DATA_IND event */ + struct { + void *remDev; /* Pointer to remote device */ + U16 scoHandle; /* SCO Connection handle for HCI */ + void *scoCon; /* SCO connection. */ + U8 len; /* SCO data len */ + U8 *ptr; /* SCO data ptr */ + U8 errFlags; /* Erroneous Data Reporting */ + } scoDataInd; - /* Result for the BTEVENT_SECURITY_CHANGE and - * BTEVENT_SECURITY3_COMPLETE events - */ - struct - { - U8 mode; /* New security mode (uses the BtSecurityMode - * type). */ - BOOL encrypt; /* Indicate if encryption set or not */ - } secMode; + /* Result for the BTEVENT_SECURITY_CHANGE and + * BTEVENT_SECURITY3_COMPLETE events + */ + struct { + U8 mode; /* New security mode (uses the BtSecurityMode + * type). */ + BOOL encrypt; /* Indicate if encryption set or not */ + } secMode; - /* Results for the BTEVENT_MODE_CHANGE event */ - struct - { - void *remDev; - uint8_t curMode; - U16 interval; - } modeChange; + /* Results for the BTEVENT_MODE_CHANGE event */ + struct { + void *remDev; + uint8_t curMode; + U16 interval; + } modeChange; - /* Results for BTEVENT_ROLE_CHANGE */ - struct - { - void *remDev; - uint8_t newRole; /* New role */ - } roleChange; + /* Results for BTEVENT_ROLE_CHANGE */ + struct { + void *remDev; + uint8_t newRole; /* New role */ + } roleChange; - /* Results for BTEVENT_ACL_DATA_ACTIVE */ - struct - { - void *remDev; - uint16_t dataLen; /* ACL data length */ - } aclDataActive; + /* Results for BTEVENT_ACL_DATA_ACTIVE */ + struct { + void *remDev; + uint16_t dataLen; /* ACL data length */ + } aclDataActive; - /* Results for BTEVENT_ACL_DATA_NOT_ACTIVE */ - struct - { - void *remDev; - uint16_t dataLen; /* ACL data length */ - } aclDataNotActive; - struct - { - uint8_t status; - bt_bdaddr_t bdAddr; /* Address of the device sending the keypress */ - }name_rsp; - struct - { - btif_remote_device_t *conn; - }conn_req; - } edata; + /* Results for BTEVENT_ACL_DATA_NOT_ACTIVE */ + struct { + void *remDev; + uint16_t dataLen; /* ACL data length */ + } aclDataNotActive; + struct { + uint8_t status; + bt_bdaddr_t bdAddr; /* Address of the device sending the keypress */ + } name_rsp; + struct { + btif_remote_device_t *conn; + } conn_req; + } edata; } event_t; -typedef struct -{ - event_t *evt; - btif_event_mask_t mask; +typedef struct { + event_t *evt; + btif_event_mask_t mask; } me_event_t; typedef bool (*ibrt_io_capbility_callback)(void *bdaddr); typedef void (*ibrt_disconnect_callback)(const void *event); -typedef void (*btif_cmgr_callback) (void *handler, uint8_t event, bt_status_t status); +typedef void (*btif_cmgr_callback)(void *handler, uint8_t event, + bt_status_t status); typedef void (*btif_global_handle)(const btif_event_t *Event); #ifdef __cplusplus extern "C" { -#endif /* */ - bt_status_t btif_me_get_tws_slave_mobile_rssi(uint16_t ConnHandle); +#endif /* */ +bt_status_t btif_me_get_tws_slave_mobile_rssi(uint16_t ConnHandle); - void btif_me_set_sniffer_env(uint8_t sniffer_acitve, uint8_t sniffer_role, - uint8_t * monitored_addr, uint8_t * sniffer_addr); - BOOL btif_me_get_remote_device_initiator(btif_remote_device_t * rdev); - uint16_t btif_me_get_remote_device_hci_handle(btif_remote_device_t * rdev); - btif_remote_device_t* btif_me_get_remote_device_by_handle(uint16_t hci_handle); - uint16_t btif_me_get_hci_handle_by_remote_dev(btif_remote_device_t *p_remote_dev); - btif_remote_device_t* btif_me_get_remote_device_by_bdaddr(bt_bdaddr_t *bdaddr); - uint8_t btif_me_get_remote_device_op_optype(btif_remote_device_t * rdev); - btif_connection_role_t btif_me_get_remote_device_role(btif_remote_device_t * rdev); - void btif_me_set_remote_device_role(btif_remote_device_t * rdev, uint8_t role); - BOOL *btif_me_get_remote_device_new_link_key(btif_remote_device_t * rdev); - void *btif_me_get_remote_device_parms(btif_remote_device_t * rdev); - bt_status_t btif_me_exchange_bt_addr(uint16_t connHandle); - bool btif_me_role_switch_pending(uint16_t handle); - bool btif_me_is_tws_role_switch_pending(); - bool btif_me_is_exechange_bt_addr_pending(); - bool is_btif_me_current_role_bcr_master(btif_remote_device_t * device); - bt_status_t btif_me_inquiry(uint32_t lap, uint8_t len, uint8_t maxResp); - bt_status_t btif_me_ble_add_dev_to_whitelist(uint8_t addr_type, bt_bdaddr_t * addr); - bt_status_t btif_me_ble_clear_whitelist(void); - bt_status_t btif_me_ble_set_private_address(bt_bdaddr_t * addr); - bt_status_t btif_me_ble_set_adv_data(uint8_t len, uint8_t * data); - bt_status_t btif_me_ble_set_scan_rsp_data(U8 len, U8 * data); - bt_status_t btif_me_ble_set_adv_parameters(btif_adv_para_struct_t * para); - bt_status_t btif_me_ble_set_adv_en(uint8_t en); - bt_status_t btif_me_ble_set_scan_parameter(btif_scan_para_struct_t * para); - bt_status_t btif_me_ble_set_scan_en(uint8_t scan_en, uint8_t filter_duplicate); - bt_status_t btif_me_ble_receive_adv_report(void (*cb)(const btif_ble_adv_report* report)); - bt_status_t btif_sec_find_device_record(const bt_bdaddr_t * bdAddr, - btif_device_record_t * record); +void btif_me_set_sniffer_env(uint8_t sniffer_acitve, uint8_t sniffer_role, + uint8_t *monitored_addr, uint8_t *sniffer_addr); +BOOL btif_me_get_remote_device_initiator(btif_remote_device_t *rdev); +uint16_t btif_me_get_remote_device_hci_handle(btif_remote_device_t *rdev); +btif_remote_device_t *btif_me_get_remote_device_by_handle(uint16_t hci_handle); +uint16_t +btif_me_get_hci_handle_by_remote_dev(btif_remote_device_t *p_remote_dev); +btif_remote_device_t *btif_me_get_remote_device_by_bdaddr(bt_bdaddr_t *bdaddr); +uint8_t btif_me_get_remote_device_op_optype(btif_remote_device_t *rdev); +btif_connection_role_t +btif_me_get_remote_device_role(btif_remote_device_t *rdev); +void btif_me_set_remote_device_role(btif_remote_device_t *rdev, uint8_t role); +BOOL *btif_me_get_remote_device_new_link_key(btif_remote_device_t *rdev); +void *btif_me_get_remote_device_parms(btif_remote_device_t *rdev); +bt_status_t btif_me_exchange_bt_addr(uint16_t connHandle); +bool btif_me_role_switch_pending(uint16_t handle); +bool btif_me_is_tws_role_switch_pending(); +bool btif_me_is_exechange_bt_addr_pending(); +bool is_btif_me_current_role_bcr_master(btif_remote_device_t *device); +bt_status_t btif_me_inquiry(uint32_t lap, uint8_t len, uint8_t maxResp); +bt_status_t btif_me_ble_add_dev_to_whitelist(uint8_t addr_type, + bt_bdaddr_t *addr); +bt_status_t btif_me_ble_clear_whitelist(void); +bt_status_t btif_me_ble_set_private_address(bt_bdaddr_t *addr); +bt_status_t btif_me_ble_set_adv_data(uint8_t len, uint8_t *data); +bt_status_t btif_me_ble_set_scan_rsp_data(U8 len, U8 *data); +bt_status_t btif_me_ble_set_adv_parameters(btif_adv_para_struct_t *para); +bt_status_t btif_me_ble_set_adv_en(uint8_t en); +bt_status_t btif_me_ble_set_scan_parameter(btif_scan_para_struct_t *para); +bt_status_t btif_me_ble_set_scan_en(uint8_t scan_en, uint8_t filter_duplicate); +bt_status_t +btif_me_ble_receive_adv_report(void (*cb)(const btif_ble_adv_report *report)); +bt_status_t btif_sec_find_device_record(const bt_bdaddr_t *bdAddr, + btif_device_record_t *record); - uint8_t btif_sec_set_io_capabilities(uint8_t ioCap); - uint8_t btif_sec_set_authrequirements(uint8_t authRequirements); - uint8_t btif_me_get_callback_event_type(const btif_event_t * event); - uint8_t btif_me_get_callback_event_rem_dev_role(const btif_event_t * event); - bt_bdaddr_t *btif_me_get_callback_event_rem_dev_bd_addr(const btif_event_t * event); - bt_bdaddr_t *btif_me_get_callback_event_disconnect_rem_dev_bd_addr(const btif_event_t * - event); - btif_remote_device_t *btif_me_get_callback_event_disconnect_rem_dev(const btif_event_t * - event); - btif_remote_device_t *btif_me_get_callback_event_role_change_rem_dev(const btif_event_t *event); - uint8_t btif_me_get_callback_event_disconnect_rem_dev_disc_reason_saved(const btif_event_t * - event); - uint8_t btif_me_get_callback_event_disconnect_rem_dev_disc_reason(const btif_event_t * - event); +uint8_t btif_sec_set_io_capabilities(uint8_t ioCap); +uint8_t btif_sec_set_authrequirements(uint8_t authRequirements); +uint8_t btif_me_get_callback_event_type(const btif_event_t *event); +uint8_t btif_me_get_callback_event_rem_dev_role(const btif_event_t *event); +bt_bdaddr_t * +btif_me_get_callback_event_rem_dev_bd_addr(const btif_event_t *event); +bt_bdaddr_t *btif_me_get_callback_event_disconnect_rem_dev_bd_addr( + const btif_event_t *event); +btif_remote_device_t * +btif_me_get_callback_event_disconnect_rem_dev(const btif_event_t *event); +btif_remote_device_t * +btif_me_get_callback_event_role_change_rem_dev(const btif_event_t *event); +uint8_t btif_me_get_callback_event_disconnect_rem_dev_disc_reason_saved( + const btif_event_t *event); +uint8_t btif_me_get_callback_event_disconnect_rem_dev_disc_reason( + const btif_event_t *event); - uint8_t btif_me_get_pendCons(void); +uint8_t btif_me_get_pendCons(void); - uint8_t btif_me_get_activeCons(void); +uint8_t btif_me_get_activeCons(void); - void btif_me_set_pendCons(uint8_t pendCons); +void btif_me_set_pendCons(uint8_t pendCons); - void btif_me_set_activeCons(uint8_t activeCons ); +void btif_me_set_activeCons(uint8_t activeCons); - btif_remote_device_t *btif_me_get_callback_event_rem_dev(const btif_event_t * event); +btif_remote_device_t * +btif_me_get_callback_event_rem_dev(const btif_event_t *event); - btif_BtDeviceContext* btif_me_get_bt_device_context(const btif_event_t * event); +btif_BtDeviceContext *btif_me_get_bt_device_context(const btif_event_t *event); - uint16_t btif_me_get_scohdl_by_connhdl(uint16_t conn_handle); - btif_remote_device_t *btif_me_get_callback_event_sco_connect_rem_dev(const btif_event_t * - event); - uint8_t btif_me_get_callback_event_role_change_new_role(const btif_event_t * event); - bt_bdaddr_t *btif_me_get_callback_event_inq_result_bd_addr(const btif_event_t * event); - uint8_t *btif_me_get_callback_event_inq_result_bd_addr_addr(const btif_event_t * event); - uint8_t btif_me_get_callback_event_inq_result_inq_mode(const btif_event_t * event); - uint8_t btif_me_get_callback_event_rssi(const btif_event_t *event); - uint8_t *btif_me_get_callback_event_inq_result_ext_inq_resp(const btif_event_t * event); - uint32_t btif_me_get_callback_event_inq_result_classofdevice(const btif_event_t *event); - uint8_t btif_me_get_callback_event_err_code(const btif_event_t * event); - uint8_t btif_me_get_callback_event_a_mode(const btif_event_t * event); - uint16_t btif_me_get_callback_event_max_slot_changed_connHandle(const btif_event_t * event); - uint8_t btif_me_get_callback_event_max_slot_changed_max_slot(const btif_event_t * event); - uint8_t btif_me_get_callback_event_mode_change_curMode(const btif_event_t * event); - uint16_t btif_me_get_callback_event_mode_change_interval(const btif_event_t * event); +uint16_t btif_me_get_scohdl_by_connhdl(uint16_t conn_handle); +btif_remote_device_t * +btif_me_get_callback_event_sco_connect_rem_dev(const btif_event_t *event); +uint8_t +btif_me_get_callback_event_role_change_new_role(const btif_event_t *event); +bt_bdaddr_t * +btif_me_get_callback_event_inq_result_bd_addr(const btif_event_t *event); +uint8_t * +btif_me_get_callback_event_inq_result_bd_addr_addr(const btif_event_t *event); +uint8_t +btif_me_get_callback_event_inq_result_inq_mode(const btif_event_t *event); +uint8_t btif_me_get_callback_event_rssi(const btif_event_t *event); +uint8_t * +btif_me_get_callback_event_inq_result_ext_inq_resp(const btif_event_t *event); +uint32_t +btif_me_get_callback_event_inq_result_classofdevice(const btif_event_t *event); +uint8_t btif_me_get_callback_event_err_code(const btif_event_t *event); +uint8_t btif_me_get_callback_event_a_mode(const btif_event_t *event); +uint16_t btif_me_get_callback_event_max_slot_changed_connHandle( + const btif_event_t *event); +uint8_t +btif_me_get_callback_event_max_slot_changed_max_slot(const btif_event_t *event); +uint8_t +btif_me_get_callback_event_mode_change_curMode(const btif_event_t *event); +uint16_t +btif_me_get_callback_event_mode_change_interval(const btif_event_t *event); - uint16_t btif_me_get_callback_event_remote_dev_name(const btif_event_t * event, uint8_t** ppName); +uint16_t btif_me_get_callback_event_remote_dev_name(const btif_event_t *event, + uint8_t **ppName); - bt_status_t btif_me_get_remote_device_name(const bt_bdaddr_t * bdAddr, btif_global_handle handler); +bt_status_t btif_me_get_remote_device_name(const bt_bdaddr_t *bdAddr, + btif_global_handle handler); - uint8_t btif_me_get_ext_inq_data(uint8_t * eir, btif_eir_data_type_t type, - uint8_t * outBuffer, uint8_t Length); - bt_status_t btif_me_cancel_inquiry(void); - bt_status_t btif_sec_delete_device_record(const bt_bdaddr_t * bdAddr); - bt_status_t btif_me_cancel_create_link(btif_handler * handler, - btif_remote_device_t * rdev); - void btif_me_set_handler(void *handler, btif_callback cb); - uint8_t btif_me_set_connection_role(uint8_t role); - bt_status_t btif_me_disconnect_link(btif_handler * handler, - btif_remote_device_t * rdev); - bt_status_t btif_me_set_link_policy(btif_remote_device_t * rdev, - btif_link_policy_t policy); - bt_status_t btif_me_set_link_lowlayer_monitor(btif_remote_device_t * rdev, uint8_t control_flag,uint8_t report_format, - uint32_t data_format,uint8_t report_unit); - bt_status_t btif_me_set_connection_qos_info(btif_remote_device_t * rdev, - btif_qos_info_t * qosInfo); - void btif_me_fake_tws_disconnect(uint16_t hci_handle, uint8_t reason); - void btif_me_fake_mobile_disconnect(uint16_t hci_handle, uint8_t reason); - void btif_me_fake_tws_connect(uint8_t status, uint16_t hci_handle, bt_bdaddr_t * bdAddr); - void btif_me_reset_bt_controller(void); - void btif_me_fake_mobile_connect(uint8_t status, uint16_t hci_handle, bt_bdaddr_t *bdAddr); +uint8_t btif_me_get_ext_inq_data(uint8_t *eir, btif_eir_data_type_t type, + uint8_t *outBuffer, uint8_t Length); +bt_status_t btif_me_cancel_inquiry(void); +bt_status_t btif_sec_delete_device_record(const bt_bdaddr_t *bdAddr); +bt_status_t btif_me_cancel_create_link(btif_handler *handler, + btif_remote_device_t *rdev); +void btif_me_set_handler(void *handler, btif_callback cb); +uint8_t btif_me_set_connection_role(uint8_t role); +bt_status_t btif_me_disconnect_link(btif_handler *handler, + btif_remote_device_t *rdev); +bt_status_t btif_me_set_link_policy(btif_remote_device_t *rdev, + btif_link_policy_t policy); +bt_status_t btif_me_set_link_lowlayer_monitor(btif_remote_device_t *rdev, + uint8_t control_flag, + uint8_t report_format, + uint32_t data_format, + uint8_t report_unit); +bt_status_t btif_me_set_connection_qos_info(btif_remote_device_t *rdev, + btif_qos_info_t *qosInfo); +void btif_me_fake_tws_disconnect(uint16_t hci_handle, uint8_t reason); +void btif_me_fake_mobile_disconnect(uint16_t hci_handle, uint8_t reason); +void btif_me_fake_tws_connect(uint8_t status, uint16_t hci_handle, + bt_bdaddr_t *bdAddr); +void btif_me_reset_bt_controller(void); +void btif_me_fake_mobile_connect(uint8_t status, uint16_t hci_handle, + bt_bdaddr_t *bdAddr); - bt_status_t btif_me_set_lbrt_enable(uint16_t connHandle, uint8_t enable); - bt_status_t btif_me_set_accessible_mode(btif_accessible_mode_t mode, - const btif_access_mode_info_t * info); - bt_status_t btif_me_write_page_timeout(uint16_t timeout); - bool btif_me_is_op_in_progress(btif_remote_device_t * rdev); - bt_status_t btif_me_switch_role(btif_remote_device_t * rdev); - bt_status_t btif_me_register_global_handler(void *handler); - void *btif_me_register_accept_handler(void *handler); - bt_status_t btif_me_set_event_mask(void *handler, btif_event_mask_t mask); - void *btif_me_get_bt_handler(void); - bt_status_t btif_me_set_bt_address(uint8_t * btAddr); - bt_status_t btif_me_set_local_device_name(const U8 *name, U8 length); - bt_status_t btif_me_set_ble_bd_address(uint8_t * btAddr); - bt_status_t btif_sec_add_device_record(btif_device_record_t * record); - bt_status_t btif_enum_device_record(U16 dev_id, btif_device_record_t *record); - bt_bdaddr_t *btif_me_get_remote_device_bdaddr(btif_remote_device_t * rdev); - btif_rem_dev_state_t btif_me_get_remote_device_state(btif_remote_device_t * rdev); - btif_link_mode_t btif_me_get_remote_device_mode(btif_remote_device_t * rdev); - btif_authorize_state_t btif_me_get_remote_device_auth_state(btif_remote_device_t * rdev); - bt_status_t btif_me_write_link_superv_timeout(uint16_t handle, uint16_t slots); - btif_link_mode_t btif_me_get_current_mode(btif_remote_device_t * rdev); - btif_connection_role_t btif_me_get_current_role(btif_remote_device_t * rdev); +bt_status_t btif_me_set_lbrt_enable(uint16_t connHandle, uint8_t enable); +bt_status_t btif_me_set_accessible_mode(btif_accessible_mode_t mode, + const btif_access_mode_info_t *info); +bt_status_t btif_me_write_page_timeout(uint16_t timeout); +bool btif_me_is_op_in_progress(btif_remote_device_t *rdev); +bt_status_t btif_me_switch_role(btif_remote_device_t *rdev); +bt_status_t btif_me_register_global_handler(void *handler); +void *btif_me_register_accept_handler(void *handler); +bt_status_t btif_me_set_event_mask(void *handler, btif_event_mask_t mask); +void *btif_me_get_bt_handler(void); +bt_status_t btif_me_set_bt_address(uint8_t *btAddr); +bt_status_t btif_me_set_local_device_name(const U8 *name, U8 length); +bt_status_t btif_me_set_ble_bd_address(uint8_t *btAddr); +bt_status_t btif_sec_add_device_record(btif_device_record_t *record); +bt_status_t btif_enum_device_record(U16 dev_id, btif_device_record_t *record); +bt_bdaddr_t *btif_me_get_remote_device_bdaddr(btif_remote_device_t *rdev); +btif_rem_dev_state_t +btif_me_get_remote_device_state(btif_remote_device_t *rdev); +btif_link_mode_t btif_me_get_remote_device_mode(btif_remote_device_t *rdev); +btif_authorize_state_t +btif_me_get_remote_device_auth_state(btif_remote_device_t *rdev); +bt_status_t btif_me_write_link_superv_timeout(uint16_t handle, uint16_t slots); +btif_link_mode_t btif_me_get_current_mode(btif_remote_device_t *rdev); +btif_connection_role_t btif_me_get_current_role(btif_remote_device_t *rdev); - bt_status_t btif_me_start_sniff(btif_remote_device_t * rdev, btif_sniff_info_t* info); +bt_status_t btif_me_start_sniff(btif_remote_device_t *rdev, + btif_sniff_info_t *info); - bt_status_t btif_me_stop_sniff(btif_remote_device_t * rdev); +bt_status_t btif_me_stop_sniff(btif_remote_device_t *rdev); - bt_status_t btif_me_accept_incoming_link(const btif_event_t *event,btif_remote_device_t * rdev, btif_connection_role_t role); +bt_status_t btif_me_accept_incoming_link(const btif_event_t *event, + btif_remote_device_t *rdev, + btif_connection_role_t role); - bt_status_t btif_me_reject_incoming_link(btif_remote_device_t * rdev, btif_error_code_t reason); +bt_status_t btif_me_reject_incoming_link(btif_remote_device_t *rdev, + btif_error_code_t reason); - bt_status_t btif_me_start_tws_role_switch(uint16_t slaveConnHandle, uint16_t mobileConnHandle); - bt_status_t btif_me_set_sco_tx_silence(uint16_t connHandle, uint8_t silence_on); - void btif_me_increase_active_counts(void); - bool btif_me_is_sending_data_to_peer_dev_pending(void); - btif_handler *btif_me_get_me_handler(void); - bt_status_t btif_me_force_disconnect_link_with_reason(btif_handler * handler, - btif_remote_device_t * rdev, - uint8_t reason, BOOL forceDisconnect); +bt_status_t btif_me_start_tws_role_switch(uint16_t slaveConnHandle, + uint16_t mobileConnHandle); +bt_status_t btif_me_set_sco_tx_silence(uint16_t connHandle, uint8_t silence_on); +void btif_me_increase_active_counts(void); +bool btif_me_is_sending_data_to_peer_dev_pending(void); +btif_handler *btif_me_get_me_handler(void); +bt_status_t +btif_me_force_disconnect_link_with_reason(btif_handler *handler, + btif_remote_device_t *rdev, + uint8_t reason, BOOL forceDisconnect); - void btif_me_sec_set_io_cap_rsp_reject_ext(BOOL(*ext_fn) (void *)); - void btif_me_write_bt_sleep_enable(uint8_t sleep_en); - void btif_me_write_bt_page_scan_type(uint8_t scan_type); - void btif_me_write_bt_inquiry_scan_type(uint8_t scan_type); +void btif_me_sec_set_io_cap_rsp_reject_ext(BOOL (*ext_fn)(void *)); +void btif_me_write_bt_sleep_enable(uint8_t sleep_en); +void btif_me_write_bt_page_scan_type(uint8_t scan_type); +void btif_me_write_bt_inquiry_scan_type(uint8_t scan_type); #if IS_USE_INTERNAL_ACL_DATA_PATH - bt_status_t btif_me_send_data_to_peer_dev(uint16_t connHandle, uint8_t dataLen, uint8_t * data); -#endif /* */ - void btif_bt_call_back(const btif_event_t * event); - void btif_me_init_handler(btif_handler * handler); - bt_status_t btif_me_dbg_sniffer_interface(uint16_t connHandle, uint8_t subCode); - bt_status_t btif_me_switch_sco(uint16_t scohandle); - uint8_t *btif_me_get_remote_device_version(btif_remote_device_t * rdev); - void *btif_me_get_cmgr_handler(); - bt_status_t btif_bind_cmgr_handler(void *cmgr_handler, bt_bdaddr_t * bdAddr,btif_cmgr_callback Callback); - bt_status_t btif_create_acl_to_slave(void *cmgr_handler, bt_bdaddr_t * bdAddr,btif_cmgr_callback Callback); - bt_status_t btif_register_cmgr_handle(void *cmgr_handler,btif_cmgr_callback Callback); - void btif_me_update_cmgr_info(void *cmgr_handler,btif_BtDeviceContext* bt_device_context,btif_remote_device_t * rdev); - void btif_me_unregister_globa_handler(btif_handler * handler); - void btif_me_set_inquiry_mode(uint8_t mode); - void btif_me_inquiry_result_setup(uint8_t *inquiry_buff, bool rssi, - bool extended_mode); - btif_remote_device_t *btif_me_enumerate_remote_devices(uint32_t devid); +bt_status_t btif_me_send_data_to_peer_dev(uint16_t connHandle, uint8_t dataLen, + uint8_t *data); +#endif /* */ +void btif_bt_call_back(const btif_event_t *event); +void btif_me_init_handler(btif_handler *handler); +bt_status_t btif_me_dbg_sniffer_interface(uint16_t connHandle, uint8_t subCode); +bt_status_t btif_me_switch_sco(uint16_t scohandle); +uint8_t *btif_me_get_remote_device_version(btif_remote_device_t *rdev); +void *btif_me_get_cmgr_handler(); +bt_status_t btif_bind_cmgr_handler(void *cmgr_handler, bt_bdaddr_t *bdAddr, + btif_cmgr_callback Callback); +bt_status_t btif_create_acl_to_slave(void *cmgr_handler, bt_bdaddr_t *bdAddr, + btif_cmgr_callback Callback); +bt_status_t btif_register_cmgr_handle(void *cmgr_handler, + btif_cmgr_callback Callback); +void btif_me_update_cmgr_info(void *cmgr_handler, + btif_BtDeviceContext *bt_device_context, + btif_remote_device_t *rdev); +void btif_me_unregister_globa_handler(btif_handler *handler); +void btif_me_set_inquiry_mode(uint8_t mode); +void btif_me_inquiry_result_setup(uint8_t *inquiry_buff, bool rssi, + bool extended_mode); +btif_remote_device_t *btif_me_enumerate_remote_devices(uint32_t devid); - uint8_t btif_me_get_remote_sevice_encrypt_state(btif_remote_device_t* rdev); +uint8_t btif_me_get_remote_sevice_encrypt_state(btif_remote_device_t *rdev); - uint8_t btif_me_get_remote_device_disc_reason_saved(btif_remote_device_t * device); +uint8_t +btif_me_get_remote_device_disc_reason_saved(btif_remote_device_t *device); +uint8_t btif_me_get_remote_device_disc_reason(btif_remote_device_t *device); - uint8_t btif_me_get_remote_device_disc_reason(btif_remote_device_t * device); - - void btif_me_event_report(me_event_t *event); - void btif_me_init_peer_headset_addr(uint8_t *p_remote_addr); - bt_bdaddr_t * btif_me_get_peer_headset_addr(void); - uint8_t btif_me_get_remote_device_link_mode(btif_remote_device_t* rdev); - uint8_t btif_me_get_remote_device_bt_role(btif_remote_device_t* rdev); - bt_status_t btif_me_change_packet_type(btif_remote_device_t *rdev, btif_acl_packet packetTypes); - void btif_me_cobuf_state_dump(void); - void btif_me_hcibuff_state_dump(void); - bt_status_t btif_me_read_controller_memory(uint32_t addr, uint32_t len,uint8_t type); - bt_status_t btif_me_write_controller_memory(uint32_t addr,uint32_t val,uint8_t type); - bt_status_t btif_me_qos_set_up(uint16_t conn_handle); - void btif_set_sco_max_number(uint8_t num); - uint8_t btif_get_sco_max_number(); +void btif_me_event_report(me_event_t *event); +void btif_me_init_peer_headset_addr(uint8_t *p_remote_addr); +bt_bdaddr_t *btif_me_get_peer_headset_addr(void); +uint8_t btif_me_get_remote_device_link_mode(btif_remote_device_t *rdev); +uint8_t btif_me_get_remote_device_bt_role(btif_remote_device_t *rdev); +bt_status_t btif_me_change_packet_type(btif_remote_device_t *rdev, + btif_acl_packet packetTypes); +void btif_me_cobuf_state_dump(void); +void btif_me_hcibuff_state_dump(void); +bt_status_t btif_me_read_controller_memory(uint32_t addr, uint32_t len, + uint8_t type); +bt_status_t btif_me_write_controller_memory(uint32_t addr, uint32_t val, + uint8_t type); +bt_status_t btif_me_qos_set_up(uint16_t conn_handle); +void btif_set_sco_max_number(uint8_t num); +uint8_t btif_get_sco_max_number(); #if defined(IBRT) - // ibrt fast ack toggle - #define IBRT_FAST_ACK_OFF (0) - #define IBRT_FAST_ACK_ON (1) - // ibrt fast direction - #define IBRT_FAST_ACK_TX 0 - #define IBRT_FAST_ACK_RX 1 - // ibrt slave flow control - #define IBRT_SLAVE_FLOW_CTRL_ON IBRT_FAST_ACK_OFF - #define IBRT_SLAVE_FLOW_CTRL_OFF IBRT_FAST_ACK_ON +// ibrt fast ack toggle +#define IBRT_FAST_ACK_OFF (0) +#define IBRT_FAST_ACK_ON (1) +// ibrt fast direction +#define IBRT_FAST_ACK_TX 0 +#define IBRT_FAST_ACK_RX 1 +// ibrt slave flow control +#define IBRT_SLAVE_FLOW_CTRL_ON IBRT_FAST_ACK_OFF +#define IBRT_SLAVE_FLOW_CTRL_OFF IBRT_FAST_ACK_ON - bt_status_t btif_me_enable_fastack(uint16_t conhdl, uint8_t direction, uint8_t enable); - bt_status_t btif_me_start_ibrt(U16 slaveConnHandle, U16 mobileConnHandle); - bt_status_t btif_me_stop_ibrt(uint8_t enable,uint8_t reason); - bt_status_t btif_me_suspend_ibrt(void); - bt_status_t btif_me_ibrt_mode_init(bool enable); - bt_status_t btif_me_ibrt_role_switch(uint8_t switch_op); +bt_status_t btif_me_enable_fastack(uint16_t conhdl, uint8_t direction, + uint8_t enable); +bt_status_t btif_me_start_ibrt(U16 slaveConnHandle, U16 mobileConnHandle); +bt_status_t btif_me_stop_ibrt(uint8_t enable, uint8_t reason); +bt_status_t btif_me_suspend_ibrt(void); +bt_status_t btif_me_ibrt_mode_init(bool enable); +bt_status_t btif_me_ibrt_role_switch(uint8_t switch_op); - void btif_me_set_ibrt_mobile_hci_handle(uint16_t hci_handle); - uint16_t btif_me_get_ibrt_mobile_hci_handle(void); +void btif_me_set_ibrt_mobile_hci_handle(uint16_t hci_handle); +uint16_t btif_me_get_ibrt_mobile_hci_handle(void); - void btif_me_set_devctx_state(uint8_t ctx_idx, uint16_t state); - void btif_me_set_devctx_link(uint8_t ctx_idx, btif_remote_device_t * rm_dev); - bt_bdaddr_t* btif_me_get_devctx_btaddr(uint8_t ctx_idx); - btif_remote_device_t* btif_me_get_remote_device(uint8_t dev_index); - void btif_me_free_tws_outgoing_dev(uint8_t *peer_tws_addr); - btif_remote_device_t* btif_me_get_devctx_remote_device(uint8_t ctx_idx); - btif_remote_device_t * btif_me_avdev_ctx_get_conn_remote_device(uint8_t dev_idx); +void btif_me_set_devctx_state(uint8_t ctx_idx, uint16_t state); +void btif_me_set_devctx_link(uint8_t ctx_idx, btif_remote_device_t *rm_dev); +bt_bdaddr_t *btif_me_get_devctx_btaddr(uint8_t ctx_idx); +btif_remote_device_t *btif_me_get_remote_device(uint8_t dev_index); +void btif_me_free_tws_outgoing_dev(uint8_t *peer_tws_addr); +btif_remote_device_t *btif_me_get_devctx_remote_device(uint8_t ctx_idx); +btif_remote_device_t *btif_me_avdev_ctx_get_conn_remote_device(uint8_t dev_idx); - uint32_t btif_me_save_record_ctx(uint8_t *ctx_buffer, uint8_t *addr); - uint32_t btif_me_set_record_ctx(uint8_t *ctx_buffer, uint8_t *addr); - uint32_t btif_me_save_me_ctx(uint8_t *ctx_buffer, uint16_t dev_id); - uint32_t btif_me_set_me_ctx(uint8_t *ctx_buffer, uint16_t dev_id); - uint8_t btif_me_get_mobile_avdev_index(uint16_t mobile_handle); - uint8_t btif_me_get_free_avdev_index(void); - uint32_t btif_me_save_avdev_ctx(uint8_t* ctx_buffer, uint16_t dev_id); - uint32_t btif_me_set_avdev_ctx(uint8_t *ctx_buffer, uint16_t dev_id, uint8_t rm_devtbl_idx); - void btif_me_conn_auto_accept_enable(uint8_t *condition); - uint8_t btif_me_get_callback_event_encty_mode(const btif_event_t * event); - btif_dev_linkkey *btif_me_get_callback_link_key(const btif_event_t *event); - void btif_me_register_ibrt_disconnect_callback(btif_callback cb); - bt_status_t btif_me_set_tws_poll_interval(uint16_t conn_handle, uint16_t poll_interval); - bt_status_t btif_me_resume_ibrt(uint8_t enable); - void btif_me_write_scan_activity_specific(uint16_t opcode, uint16_t scan_interval, uint16_t scan_window); - void btif_me_write_dbg_sniffer(const uint8_t subcode, const uint16_t connhandle); - void btif_me_ibrt_simu_hci_event_disallow(uint8_t opcode1, uint8_t opcode2); - void btif_me_register_conn_req_pre_treatment_callback(btif_callback cb); - void btif_me_register_cmd_status_callback(btif_callback cb); - void btif_me_register_cmd_complete_callback(HCI_CMD_COMPLETE_USER_E index,btif_callback cb); - bt_status_t btif_me_ibrt_conn_connected(bt_bdaddr_t *bt_addr, uint16_t conhdl); - bt_status_t btif_me_ibrt_conn_disconnected(bt_bdaddr_t *bt_addr, uint16_t conhdl, uint8_t status, uint8_t reason); - void btif_me_register_ibrt_io_capbility_callback(ibrt_io_capbility_callback cb); - bt_status_t btif_me_auth_req(uint16_t conn_handle); - void btif_me_set_ecc_ibrt_data_test(uint8_t ecc_data_test_en, uint8_t ecc_data_len, uint16_t ecc_count, uint32_t data_pattern); - void btif_me_send_prefer_rate(uint16_t connhdl, uint8_t rate); +uint32_t btif_me_save_record_ctx(uint8_t *ctx_buffer, uint8_t *addr); +uint32_t btif_me_set_record_ctx(uint8_t *ctx_buffer, uint8_t *addr); +uint32_t btif_me_save_me_ctx(uint8_t *ctx_buffer, uint16_t dev_id); +uint32_t btif_me_set_me_ctx(uint8_t *ctx_buffer, uint16_t dev_id); +uint8_t btif_me_get_mobile_avdev_index(uint16_t mobile_handle); +uint8_t btif_me_get_free_avdev_index(void); +uint32_t btif_me_save_avdev_ctx(uint8_t *ctx_buffer, uint16_t dev_id); +uint32_t btif_me_set_avdev_ctx(uint8_t *ctx_buffer, uint16_t dev_id, + uint8_t rm_devtbl_idx); +void btif_me_conn_auto_accept_enable(uint8_t *condition); +uint8_t btif_me_get_callback_event_encty_mode(const btif_event_t *event); +btif_dev_linkkey *btif_me_get_callback_link_key(const btif_event_t *event); +void btif_me_register_ibrt_disconnect_callback(btif_callback cb); +bt_status_t btif_me_set_tws_poll_interval(uint16_t conn_handle, + uint16_t poll_interval); +bt_status_t btif_me_resume_ibrt(uint8_t enable); +void btif_me_write_scan_activity_specific(uint16_t opcode, + uint16_t scan_interval, + uint16_t scan_window); +void btif_me_write_dbg_sniffer(const uint8_t subcode, + const uint16_t connhandle); +void btif_me_ibrt_simu_hci_event_disallow(uint8_t opcode1, uint8_t opcode2); +void btif_me_register_conn_req_pre_treatment_callback(btif_callback cb); +void btif_me_register_cmd_status_callback(btif_callback cb); +void btif_me_register_cmd_complete_callback(HCI_CMD_COMPLETE_USER_E index, + btif_callback cb); +bt_status_t btif_me_ibrt_conn_connected(bt_bdaddr_t *bt_addr, uint16_t conhdl); +bt_status_t btif_me_ibrt_conn_disconnected(bt_bdaddr_t *bt_addr, + uint16_t conhdl, uint8_t status, + uint8_t reason); +void btif_me_register_ibrt_io_capbility_callback(ibrt_io_capbility_callback cb); +bt_status_t btif_me_auth_req(uint16_t conn_handle); +void btif_me_set_ecc_ibrt_data_test(uint8_t ecc_data_test_en, + uint8_t ecc_data_len, uint16_t ecc_count, + uint32_t data_pattern); +void btif_me_send_prefer_rate(uint16_t connhdl, uint8_t rate); #endif #ifdef __cplusplus } -#endif /* */ -#endif /* __ME_H */ +#endif /* */ +#endif /* __ME_H */ diff --git a/services/communication/comminication_knowles/communication_cmd_handle.cpp b/services/communication/comminication_knowles/communication_cmd_handle.cpp index 96f63c3..a0e07fb 100644 --- a/services/communication/comminication_knowles/communication_cmd_handle.cpp +++ b/services/communication/comminication_knowles/communication_cmd_handle.cpp @@ -1,78 +1,69 @@ -#include "stdint.h" -#include "stdbool.h" -#include "plat_types.h" -#include "hal_chipid.h" -#include "hal_trace.h" -#include "string.h" -#include "hal_dma.h" #include "communication_cmd_handle.h" +#include "hal_chipid.h" +#include "hal_dma.h" +#include "hal_trace.h" +#include "plat_types.h" +#include "stdbool.h" +#include "stdint.h" +#include "string.h" static bool communication_cmd_inited = false; static int (*send_reply_cb)(const unsigned char *, unsigned int); extern "C" int extend_cmd_pmu_open(void); -int communication_cmd_init(int (* cb)(const unsigned char *, unsigned int)) -{ - if (!communication_cmd_inited){ - send_reply_cb = cb; - communication_cmd_inited = true; - } - return 0; +int communication_cmd_init(int (*cb)(const unsigned char *, unsigned int)) { + if (!communication_cmd_inited) { + send_reply_cb = cb; + communication_cmd_inited = true; + } + return 0; } - -int communication_cmd_send_reply(const unsigned char *payload, unsigned int len) -{ - return send_reply_cb(payload, len); +int communication_cmd_send_reply(const unsigned char *payload, + unsigned int len) { + return send_reply_cb(payload, len); } -enum ERR_CODE communication_cmd_check_msg_hdr(struct message_t *msg) -{ - return ERR_NONE; +enum ERR_CODE communication_cmd_check_msg_hdr(struct message_t *msg) { + return ERR_NONE; } -void FloatToByte(float floatNum,unsigned char* byteArry) -{ - char* pchar=(char*)&floatNum; - for(u32 i=0;i 1024) - { - //TRACE(0,"More than 1024 bytes availble hence sending next chunk command \n"); - send_data(get_next_chunk_cmd, 4); - osTimerStop(app_uart_flow_control_timeout_timer_id); - osTimerStart(app_uart_flow_control_timeout_timer_id, APP_UART_FLOW_CONTROL_TIMEOUT_INTERVEL); - } - else - { - //TRACE(0,"no buffer available hence triggering timer for 10ms\n"); - osTimerStop(app_uart_flow_control_timeout_timer_id); - osTimerStart(app_uart_flow_control_timeout_timer_id, APP_UART_FLOW_CONTROL_TIMEOUT_INTERVEL); - } + TRACE(1, "UART_FLOW_CONTROL: Available UART Buffer %d\n", available_buffer); + if (available_buffer > 1024) { + // TRACE(0,"More than 1024 bytes availble hence sending next chunk command + // \n"); + send_data(get_next_chunk_cmd, 4); + osTimerStop(app_uart_flow_control_timeout_timer_id); + osTimerStart(app_uart_flow_control_timeout_timer_id, + APP_UART_FLOW_CONTROL_TIMEOUT_INTERVEL); + } else { + // TRACE(0,"no buffer available hence triggering timer for 10ms\n"); + osTimerStop(app_uart_flow_control_timeout_timer_id); + osTimerStart(app_uart_flow_control_timeout_timer_id, + APP_UART_FLOW_CONTROL_TIMEOUT_INTERVEL); + } } -void ama_uart_stream_fifo_init() -{ - if (uart_audio_pcmbuff_mutex_id == NULL) - { - uart_audio_pcmbuff_mutex_id = osMutexCreate((osMutex(uart_audio_pcmbuff_mutex))); - } +void ama_uart_stream_fifo_init() { + if (uart_audio_pcmbuff_mutex_id == NULL) { + uart_audio_pcmbuff_mutex_id = + osMutexCreate((osMutex(uart_audio_pcmbuff_mutex))); + } - pp_index=PP_PING; + pp_index = PP_PING; - if (knowles_uart_audio_tid) - { - osSignalClear(knowles_uart_audio_tid, UART_OUT_SIGNAL_ID); - } + if (knowles_uart_audio_tid) { + osSignalClear(knowles_uart_audio_tid, UART_OUT_SIGNAL_ID); + } - memset(audio_data_receive_buf,0,sizeof(audio_data_receive_buf)); - InitCQueue(&ama_uart_queue, AMA_STREAM_UART_FIFO_SIZE, - (CQItemType *)ama_uart_buff); + memset(audio_data_receive_buf, 0, sizeof(audio_data_receive_buf)); + InitCQueue(&ama_uart_queue, AMA_STREAM_UART_FIFO_SIZE, + (CQItemType *)ama_uart_buff); } -uint32_t ama_uart_get_fifo_data(uint8_t *buf) -{ - uint32_t avail = 0; +uint32_t ama_uart_get_fifo_data(uint8_t *buf) { + uint32_t avail = 0; - avail = LengthOfCQueue(&ama_uart_queue); - if (avail > 0) { - if (avail < knowles_uart_packet_len) { - TRACE(2,"%s: Invalid UART STREAM SIZE: %d", __FUNCTION__, avail); - return 0; - } else { - //TRACE(1,"UART_GET_len %d",knowles_uart_packet_len); - if(!DeCQueue(&ama_uart_queue, buf, knowles_uart_packet_len)) - return knowles_uart_packet_len; - TRACE(2,"%s: queue get data error len %d", __func__, knowles_uart_packet_len); - return 0; - } + avail = LengthOfCQueue(&ama_uart_queue); + if (avail > 0) { + if (avail < knowles_uart_packet_len) { + TRACE(2, "%s: Invalid UART STREAM SIZE: %d", __FUNCTION__, avail); + return 0; } else { - TRACE(0,"uart no stream to get"); - return 0; + // TRACE(1,"UART_GET_len %d",knowles_uart_packet_len); + if (!DeCQueue(&ama_uart_queue, buf, knowles_uart_packet_len)) + return knowles_uart_packet_len; + TRACE(2, "%s: queue get data error len %d", __func__, + knowles_uart_packet_len); + return 0; } + } else { + TRACE(0, "uart no stream to get"); + return 0; + } } -uint32_t avil_len_of_the_fifo() -{ - return LengthOfCQueue(&ama_uart_queue); -} +uint32_t avil_len_of_the_fifo() { return LengthOfCQueue(&ama_uart_queue); } extern "C" void OS_NotifyEvm(void); -void send_message() -{ - OS_NotifyEvm(); -} +void send_message() { OS_NotifyEvm(); } #endif #endif -static void uart_break_handler(void) -{ - TRACE(0,"****** Handle break ******"); +static void uart_break_handler(void) { + TRACE(0, "****** Handle break ******"); - cancel_xfer = true; - hal_uart_stop_dma_recv(comm_uart); - hal_uart_stop_dma_send(comm_uart); - uart_dma_rx_state = UART_DMA_ERROR; + cancel_xfer = true; + hal_uart_stop_dma_recv(comm_uart); + hal_uart_stop_dma_send(comm_uart); + uart_dma_rx_state = UART_DMA_ERROR; } extern "C" uint8_t app_ai_is_stream_running(void); -static void uart_rx_dma_handler(uint32_t xfer_size, int dma_error, union HAL_UART_IRQ_T status) -{ - if (status.BE) { - uart_break_handler(); - return; - } +static void uart_rx_dma_handler(uint32_t xfer_size, int dma_error, + union HAL_UART_IRQ_T status) { + if (status.BE) { + uart_break_handler(); + return; + } - // The DMA transfer has been cancelled + // The DMA transfer has been cancelled #ifndef KNOWLES_UART_DATA - if (uart_dma_rx_state != UART_DMA_START) { - return; - } + if (uart_dma_rx_state != UART_DMA_START) { + return; + } #endif - uart_dma_rx_size = xfer_size; - if (dma_error || status.FE || status.OE || status.PE || status.BE) { - TRACE(2,"UART-RX Error: dma_error=%d, status=0x%08x", dma_error, status.reg); - uart_dma_rx_state = UART_DMA_ERROR; - } else { - //TRACE(1,"UART-RX OK: rx_size=%d", uart_dma_rx_size); - uart_dma_rx_state = UART_DMA_DONE; - int ret = 0; - //TRACE(1,"UART DMA INTERUPT TIME=%d",hal_sys_timer_get()-uart_dma_interval); - uart_dma_interval=hal_sys_timer_get(); - if(app_ai_is_stream_running()) - { - if(!EnCQueue(&ama_uart_queue, (uint8_t *)&audio_data_receive_buf[pp_index*knowles_uart_packet_len], FRAME_SIZE)) - ret = FRAME_SIZE; - if (ret < FRAME_SIZE) { - TRACE(2,"%s:WARNING !!! UART STREAM OVERFLOW Dropping %d Bytes", __FUNCTION__, (FRAME_SIZE - ret)); - } + uart_dma_rx_size = xfer_size; + if (dma_error || status.FE || status.OE || status.PE || status.BE) { + TRACE(2, "UART-RX Error: dma_error=%d, status=0x%08x", dma_error, + status.reg); + uart_dma_rx_state = UART_DMA_ERROR; + } else { + // TRACE(1,"UART-RX OK: rx_size=%d", uart_dma_rx_size); + uart_dma_rx_state = UART_DMA_DONE; + int ret = 0; + // TRACE(1,"UART DMA INTERUPT + // TIME=%d",hal_sys_timer_get()-uart_dma_interval); + uart_dma_interval = hal_sys_timer_get(); + if (app_ai_is_stream_running()) { + if (!EnCQueue(&ama_uart_queue, + (uint8_t *)&audio_data_receive_buf[pp_index * + knowles_uart_packet_len], + FRAME_SIZE)) + ret = FRAME_SIZE; + if (ret < FRAME_SIZE) { + TRACE(2, "%s:WARNING !!! UART STREAM OVERFLOW Dropping %d Bytes", + __FUNCTION__, (FRAME_SIZE - ret)); + } - osSignalSet(knowles_uart_audio_tid, UART_OUT_SIGNAL_ID); - } - pp_index=PP_PINGPANG(pp_index); + osSignalSet(knowles_uart_audio_tid, UART_OUT_SIGNAL_ID); } + pp_index = PP_PINGPANG(pp_index); + } } -void recv_data_state_get(enum UART_DMA_STATE *state) -{ - *state = uart_dma_rx_state; +void recv_data_state_get(enum UART_DMA_STATE *state) { + *state = uart_dma_rx_state; } -void recv_data_reset(void) -{ - union HAL_UART_IRQ_T mask; - mask.reg = 0; - mask.BE = 1; - hal_uart_irq_set_mask(comm_uart, mask); - uart_dma_rx_state = UART_DMA_IDLE; +void recv_data_reset(void) { + union HAL_UART_IRQ_T mask; + mask.reg = 0; + mask.BE = 1; + hal_uart_irq_set_mask(comm_uart, mask); + uart_dma_rx_state = UART_DMA_IDLE; } -void init_transport(void) -{ - union HAL_UART_IRQ_T mask; - struct HAL_UART_CFG_T comm_uart_cfg; +void init_transport(void) { + union HAL_UART_IRQ_T mask; + struct HAL_UART_CFG_T comm_uart_cfg; #ifdef KNOWLES_UART_DATA - //audio_dump_init(320, 1); - ama_uart_stream_fifo_init(); + // audio_dump_init(320, 1); + ama_uart_stream_fifo_init(); #endif - if (!uart_opened) { + if (!uart_opened) { #ifdef __PC_CMD_UART__ - hal_iomux_set_uart0(); + hal_iomux_set_uart0(); #else #ifdef CHIP_BEST2300P - hal_iomux_init(cfg_pinmux_uart, ARRAY_SIZE(cfg_pinmux_uart)); + hal_iomux_init(cfg_pinmux_uart, ARRAY_SIZE(cfg_pinmux_uart)); #else - hal_iomux_set_uart1(); + hal_iomux_set_uart1(); #endif #endif - memcpy(&comm_uart_cfg, &uart_cfg, sizeof(comm_uart_cfg)); - hal_uart_open(comm_uart, &comm_uart_cfg); - mask.reg = 0; - mask.BE = 1; - mask.FE = 1; - mask.OE = 1; - mask.PE = 1; - - hal_uart_irq_set_dma_handler(comm_uart, uart_rx_dma_handler, NULL); - hal_uart_irq_set_mask(comm_uart, mask); - uart_opened = true; - } - - cancel_xfer = false; - - hal_uart_flush(comm_uart,0); -#ifdef KNOWLES_UART_DATA - if(recv_data(&audio_data_receive_buf[0], knowles_uart_packet_len*2) < 0) - TRACE(1,"%s error", __func__); - smart_mic_stream_header_parser_init(FRAME_SIZE); -#endif - - app_uart_flow_control_timeout_timer_id = osTimerCreate(osTimer(APP_UART_FLOW_CONTROL_TIMEOUT), osTimerOnce, NULL); - -} - - -void deinit_transport(void) -{ - union HAL_UART_IRQ_T mask; - - mask.reg = 0; - - //audio_dump_clear_up(); //added by punith - - hal_uart_stop_dma_recv(comm_uart);//punith - uart_dma_rx_state = UART_DMA_IDLE; - hal_uart_irq_set_mask(comm_uart, mask); - hal_uart_irq_set_dma_handler(comm_uart, NULL, NULL); - hal_uart_close(comm_uart); - - - hal_uart_flush(comm_uart,0); - uart_opened = false; - cancel_xfer = true; - - osTimerStop(app_uart_flow_control_timeout_timer_id); - if (osTimerDelete(app_uart_flow_control_timeout_timer_id) != osOK) - { - TRACE(0,"app_uart_flow_control_timeout_timer_id Failed !!!!"); - } - -} - - - - -void reinit_transport(void) -{ - union HAL_UART_IRQ_T mask; - struct HAL_UART_CFG_T comm_uart_cfg; - - uart_opened = false; memcpy(&comm_uart_cfg, &uart_cfg, sizeof(comm_uart_cfg)); hal_uart_open(comm_uart, &comm_uart_cfg); mask.reg = 0; @@ -344,223 +267,248 @@ void reinit_transport(void) mask.FE = 1; mask.OE = 1; mask.PE = 1; + hal_uart_irq_set_dma_handler(comm_uart, uart_rx_dma_handler, NULL); hal_uart_irq_set_mask(comm_uart, mask); uart_opened = true; + } - cancel_xfer = false; + cancel_xfer = false; - hal_uart_flush(comm_uart,0); + hal_uart_flush(comm_uart, 0); +#ifdef KNOWLES_UART_DATA + if (recv_data(&audio_data_receive_buf[0], knowles_uart_packet_len * 2) < 0) + TRACE(1, "%s error", __func__); + smart_mic_stream_header_parser_init(FRAME_SIZE); +#endif + + app_uart_flow_control_timeout_timer_id = + osTimerCreate(osTimer(APP_UART_FLOW_CONTROL_TIMEOUT), osTimerOnce, NULL); } -void set_send_timeout(uint32_t timeout) -{ - send_timeout = MS_TO_TICKS(timeout); +void deinit_transport(void) { + union HAL_UART_IRQ_T mask; + + mask.reg = 0; + + // audio_dump_clear_up(); //added by punith + + hal_uart_stop_dma_recv(comm_uart); // punith + uart_dma_rx_state = UART_DMA_IDLE; + hal_uart_irq_set_mask(comm_uart, mask); + hal_uart_irq_set_dma_handler(comm_uart, NULL, NULL); + hal_uart_close(comm_uart); + + hal_uart_flush(comm_uart, 0); + uart_opened = false; + cancel_xfer = true; + + osTimerStop(app_uart_flow_control_timeout_timer_id); + if (osTimerDelete(app_uart_flow_control_timeout_timer_id) != osOK) { + TRACE(0, "app_uart_flow_control_timeout_timer_id Failed !!!!"); + } } -int debug_read_enabled(void) -{ - return !!(hal_sw_bootmode_get() & HAL_SW_BOOTMODE_READ_ENABLED); +void reinit_transport(void) { + union HAL_UART_IRQ_T mask; + struct HAL_UART_CFG_T comm_uart_cfg; + + uart_opened = false; + memcpy(&comm_uart_cfg, &uart_cfg, sizeof(comm_uart_cfg)); + hal_uart_open(comm_uart, &comm_uart_cfg); + mask.reg = 0; + mask.BE = 1; + mask.FE = 1; + mask.OE = 1; + mask.PE = 1; + hal_uart_irq_set_dma_handler(comm_uart, uart_rx_dma_handler, NULL); + hal_uart_irq_set_mask(comm_uart, mask); + uart_opened = true; + + cancel_xfer = false; + + hal_uart_flush(comm_uart, 0); } -int debug_write_enabled(void) -{ - return !!(hal_sw_bootmode_get() & HAL_SW_BOOTMODE_WRITE_ENABLED); +void set_send_timeout(uint32_t timeout) { send_timeout = MS_TO_TICKS(timeout); } + +int debug_read_enabled(void) { + return !!(hal_sw_bootmode_get() & HAL_SW_BOOTMODE_READ_ENABLED); } -static int uart_send_data(const unsigned char *buf, unsigned int len) -{ - uint32_t start; - uint32_t sent = 0; - - start = hal_sys_timer_get(); - while (sent < len) { - while (!cancel_xfer && !hal_uart_writable(comm_uart) && - hal_sys_timer_get() - start < send_timeout); - if (cancel_xfer) { - break; - } - if (hal_uart_writable(comm_uart)) { - hal_uart_putc(comm_uart, buf[sent++]); - } else { - break; - } - } - - if (sent != len) { - return 1; - } - - return 0; +int debug_write_enabled(void) { + return !!(hal_sw_bootmode_get() & HAL_SW_BOOTMODE_WRITE_ENABLED); } -int send_data(const unsigned char *buf, unsigned int len) -{ +static int uart_send_data(const unsigned char *buf, unsigned int len) { + uint32_t start; + uint32_t sent = 0; + + start = hal_sys_timer_get(); + while (sent < len) { + while (!cancel_xfer && !hal_uart_writable(comm_uart) && + hal_sys_timer_get() - start < send_timeout) + ; if (cancel_xfer) { - return -1; + break; } + if (hal_uart_writable(comm_uart)) { + hal_uart_putc(comm_uart, buf[sent++]); + } else { + break; + } + } - return uart_send_data(buf, len); + if (sent != len) { + return 1; + } + + return 0; } +int send_data(const unsigned char *buf, unsigned int len) { + if (cancel_xfer) { + return -1; + } + + return uart_send_data(buf, len); +} static struct HAL_DMA_DESC_T dma_desc[17] = {0}; -static int uart_recv_data_dma(unsigned char *buf, unsigned int len, unsigned int expect) -{ - int ret; - union HAL_UART_IRQ_T mask; +static int uart_recv_data_dma(unsigned char *buf, unsigned int len, + unsigned int expect) { + int ret; + union HAL_UART_IRQ_T mask; - uint32_t desc_cnt = ARRAY_SIZE(dma_desc); + uint32_t desc_cnt = ARRAY_SIZE(dma_desc); - if (uart_dma_rx_state != UART_DMA_IDLE) { - ret = -3; - goto _no_state_exit; - } + if (uart_dma_rx_state != UART_DMA_IDLE) { + ret = -3; + goto _no_state_exit; + } - uart_dma_rx_state = UART_DMA_START; - uart_dma_rx_size = 0; + uart_dma_rx_state = UART_DMA_START; + uart_dma_rx_size = 0; #ifdef KNOWLES_UART_DATA - ret = hal_uart_dma_recv_pingpang(comm_uart, buf, expect, &dma_desc[0], &desc_cnt); + ret = hal_uart_dma_recv_pingpang(comm_uart, buf, expect, &dma_desc[0], + &desc_cnt); #else - ret = hal_uart_dma_recv(comm_uart, buf, expect, &dma_desc[0], &desc_cnt); + ret = hal_uart_dma_recv(comm_uart, buf, expect, &dma_desc[0], &desc_cnt); #endif - if (ret) { - uart_dma_rx_state = UART_DMA_ERROR; - goto err_exit; - } + if (ret) { + uart_dma_rx_state = UART_DMA_ERROR; + goto err_exit; + } - mask.reg = 0; - mask.BE = 1; - mask.FE = 1; - mask.OE = 1; - mask.PE = 1; - //mask.RT = 1; - hal_uart_irq_set_mask(comm_uart, mask); + mask.reg = 0; + mask.BE = 1; + mask.FE = 1; + mask.OE = 1; + mask.PE = 1; + // mask.RT = 1; + hal_uart_irq_set_mask(comm_uart, mask); _no_state_exit: - TRACE(2,"%s ret %d", __func__, ret); - return ret; + TRACE(2, "%s ret %d", __func__, ret); + return ret; err_exit: - TRACE(2,"%s err_exit ret %d", __func__, ret); + TRACE(2, "%s err_exit ret %d", __func__, ret); + return -1; +} + +int recv_data(unsigned char *buf, unsigned int len) { + TRACE(3, "%s %d %d", __func__, cancel_xfer, len); + if (cancel_xfer) { return -1; + } + return uart_recv_data_dma(buf, len, len); } -int recv_data(unsigned char *buf, unsigned int len) -{ - TRACE(3,"%s %d %d",__func__, cancel_xfer, len); - if (cancel_xfer) { - return -1; - } - return uart_recv_data_dma(buf, len, len); +int recv_data_dma(unsigned char *buf, unsigned int len, unsigned int expect) { + if (cancel_xfer) { + return -1; + } + + return uart_recv_data_dma(buf, len, expect); } -int recv_data_dma(unsigned char *buf, unsigned int len, unsigned int expect) -{ - if (cancel_xfer) { - return -1; - } +static int uart_handle_error(void) { + TRACE(0, "****** Send break ******"); - return uart_recv_data_dma(buf, len, expect); + // Send break signal, to tell the peer to reset the connection + hal_uart_break_set(comm_uart); + osDelay(100); + hal_uart_break_clear(comm_uart); + + return 0; } -static int uart_handle_error(void) -{ - TRACE(0,"****** Send break ******"); +int handle_error(void) { + int ret = 0; + uint32_t err_time; - // Send break signal, to tell the peer to reset the connection - hal_uart_break_set(comm_uart); - osDelay(100); - hal_uart_break_clear(comm_uart); + osDelay(200); - return 0; + if (!cancel_xfer) { + ret = uart_handle_error(); + } + + xfer_err_cnt++; + err_time = hal_sys_timer_get(); + if (err_time - xfer_err_time > MS_TO_TICKS(5000)) { + xfer_err_cnt = 0; + } + xfer_err_time = err_time; + if (xfer_err_cnt < 2) { + osDelay(500); + } else if (xfer_err_cnt < 5) { + osDelay(1000); + } else { + osDelay(2000); + } + + return ret; } -int handle_error(void) -{ - int ret = 0; - uint32_t err_time; - - osDelay(200); - - if (!cancel_xfer) { - ret = uart_handle_error(); - } - - xfer_err_cnt++; - err_time = hal_sys_timer_get(); - if (err_time - xfer_err_time > MS_TO_TICKS(5000)) { - xfer_err_cnt = 0; - } - xfer_err_time = err_time; - if (xfer_err_cnt < 2) { - osDelay(500); - } else if (xfer_err_cnt < 5) { - osDelay(1000); - } else { - osDelay(2000); - } - - return ret; +static int uart_cancel_input(void) { + hal_uart_flush(comm_uart, 0); + return 0; } -static int uart_cancel_input(void) -{ - hal_uart_flush(comm_uart,0); - return 0; +int cancel_input(void) { return uart_cancel_input(); } + +void system_reboot(void) { hal_cmu_sys_reboot(); } + +void system_shutdown(void) { pmu_shutdown(); } + +void system_set_bootmode(unsigned int bootmode) { + bootmode &= ~(HAL_SW_BOOTMODE_READ_ENABLED | HAL_SW_BOOTMODE_WRITE_ENABLED); + hal_sw_bootmode_set(bootmode); } -int cancel_input(void) -{ - return uart_cancel_input(); +void system_clear_bootmode(unsigned int bootmode) { + bootmode &= ~(HAL_SW_BOOTMODE_READ_ENABLED | HAL_SW_BOOTMODE_WRITE_ENABLED); + hal_sw_bootmode_clear(bootmode); } -void system_reboot(void) -{ - hal_cmu_sys_reboot(); +unsigned int system_get_bootmode(void) { return hal_sw_bootmode_get(); } + +void wait_trace_finished(void) { + uint32_t time; + int idle_cnt = 0; + + time = hal_sys_timer_get(); + + while (idle_cnt < 2 && hal_sys_timer_get() - time < WAIT_TRACE_TIMEOUT) { + osDelay(10); + idle_cnt = hal_trace_busy() ? 0 : (idle_cnt + 1); + } } -void system_shutdown(void) -{ - pmu_shutdown(); -} - -void system_set_bootmode(unsigned int bootmode) -{ - bootmode &= ~(HAL_SW_BOOTMODE_READ_ENABLED | HAL_SW_BOOTMODE_WRITE_ENABLED); - hal_sw_bootmode_set(bootmode); -} - -void system_clear_bootmode(unsigned int bootmode) -{ - bootmode &= ~(HAL_SW_BOOTMODE_READ_ENABLED | HAL_SW_BOOTMODE_WRITE_ENABLED); - hal_sw_bootmode_clear(bootmode); -} - -unsigned int system_get_bootmode(void) -{ - return hal_sw_bootmode_get(); -} - -void wait_trace_finished(void) -{ - uint32_t time; - int idle_cnt = 0; - - time = hal_sys_timer_get(); - - while (idle_cnt < 2 && hal_sys_timer_get() - time < WAIT_TRACE_TIMEOUT) { - osDelay(10); - idle_cnt = hal_trace_busy() ? 0 : (idle_cnt + 1); - } -} - -unsigned int get_current_time(void) -{ - return hal_sys_timer_get(); -} +unsigned int get_current_time(void) { return hal_sys_timer_get(); } #ifdef KNOWLES_UART_DATA uint8_t *uart_stream_buf; @@ -568,79 +516,80 @@ bool send_start_speech = false; extern bool is_markers_read_done; #endif #ifdef KNOWLES_UART_DATA -osThreadId knowles_uart_audio_tid = NULL; +osThreadId knowles_uart_audio_tid = NULL; static void uart_data_process_thread(const void *arg); -osThreadDef(uart_data_process_thread, (osPriorityAboveNormal), 1, (1024*12), "UART_DATA"); +osThreadDef(uart_data_process_thread, (osPriorityAboveNormal), 1, (1024 * 12), + "UART_DATA"); -int app_ai_voice_uart_audio_init() -{ - ama_uart_stream_fifo_init(); - if(knowles_uart_audio_tid==NULL) - knowles_uart_audio_tid = osThreadCreate(osThread(uart_data_process_thread), NULL); - if (knowles_uart_audio_tid == NULL) { - TRACE(0,"[UART AUDIO]Create thread error\n"); - return -1; - } +int app_ai_voice_uart_audio_init() { + ama_uart_stream_fifo_init(); + if (knowles_uart_audio_tid == NULL) + knowles_uart_audio_tid = + osThreadCreate(osThread(uart_data_process_thread), NULL); + if (knowles_uart_audio_tid == NULL) { + TRACE(0, "[UART AUDIO]Create thread error\n"); + return -1; + } - return 0; + return 0; } -void uart_data_process_thread(const void *arg) -{ - uint32_t ret = 0; - uint32_t frame_len=0; - //uint32_t stime,etime; - //stime=hal_sys_timer_get(); - - while(1) - { - //TRACE(0,"---in uart_process_thread\n"); - osEvent evt; - - if(avil_len_of_the_fifo()<=640){ - evt = osSignalWait(0x0, osWaitForever); - } +void uart_data_process_thread(const void *arg) { + uint32_t ret = 0; + uint32_t frame_len = 0; + // uint32_t stime,etime; + // stime=hal_sys_timer_get(); - //TRACE(1,"#####Available len of fifo %d####",avil_len_of_the_fifo()); - //get role from signal value - if(evt.status == osEventSignal) - { - if(evt.value.signals & UART_OUT_SIGNAL_ID) - { - if(app_ai_is_stream_running()) { - frame_len = ama_uart_get_fifo_data(uart_stream_buf); - } else { - frame_len = 0; - } + while (1) { + // TRACE(0,"---in uart_process_thread\n"); + osEvent evt; - if(frame_len != 0) { - TRACE(1,"--data start encode %d", frame_len); - //DUMP8("%02x ",uart_stream_buf,10); - - //stime=hal_sys_timer_get(); - - ret=voice_compression_handle(app_ai_get_encode_type(), uart_stream_buf, VOB_PCM_SIZE_TO_SAMPLE_CNT(640), app_ai_is_algorithm_engine_reset()); - app_ai_set_algorithm_engine_reset(false); - - ai_function_handle(API_DATA_SEND, NULL, 0); - - //etime=hal_sys_timer_get(); - //TRACE(1,"OPUS COST TIME %d", TICKS_TO_MS(etime-stime)); - //TRACE(2,"%s ====>sys freq calc : %d\n", __func__, hal_sys_timer_calc_cpu_freq(50, 0)); - audio_dump_add_channel_data(0, (short *)uart_stream_buf, frame_len/2); - audio_dump_run(); - send_message(); - if(ret < 0) { - goto __EXCEPTION; - } - } - } - } - - continue; - - __EXCEPTION: - app_ai_voice_stop_stream(); + if (avil_len_of_the_fifo() <= 640) { + evt = osSignalWait(0x0, osWaitForever); } + + // TRACE(1,"#####Available len of fifo %d####",avil_len_of_the_fifo()); + // get role from signal value + if (evt.status == osEventSignal) { + if (evt.value.signals & UART_OUT_SIGNAL_ID) { + if (app_ai_is_stream_running()) { + frame_len = ama_uart_get_fifo_data(uart_stream_buf); + } else { + frame_len = 0; + } + + if (frame_len != 0) { + TRACE(1, "--data start encode %d", frame_len); + // DUMP8("%02x ",uart_stream_buf,10); + + // stime=hal_sys_timer_get(); + + ret = voice_compression_handle(app_ai_get_encode_type(), + uart_stream_buf, + VOB_PCM_SIZE_TO_SAMPLE_CNT(640), + app_ai_is_algorithm_engine_reset()); + app_ai_set_algorithm_engine_reset(false); + + ai_function_handle(API_DATA_SEND, NULL, 0); + + // etime=hal_sys_timer_get(); + // TRACE(1,"OPUS COST TIME %d", TICKS_TO_MS(etime-stime)); + // TRACE(2,"%s ====>sys freq calc : %d\n", __func__, + // hal_sys_timer_calc_cpu_freq(50, 0)); + audio_dump_add_channel_data(0, (short *)uart_stream_buf, + frame_len / 2); + audio_dump_run(); + send_message(); + if (ret < 0) { + goto __EXCEPTION; + } + } + } + } + + continue; + + __EXCEPTION: + app_ai_voice_stop_stream(); + } } #endif - diff --git a/services/communication/communication_svr.cpp b/services/communication/communication_svr.cpp index 56176fc..f252245 100644 --- a/services/communication/communication_svr.cpp +++ b/services/communication/communication_svr.cpp @@ -1,84 +1,77 @@ -#include "stdint.h" -#include "stdbool.h" -#include "plat_types.h" -#include "cmsis_os.h" -#include "cmsis_nvic.h" -#include "string.h" -#include "stdio.h" -#include "crc32.h" -#include "hal_trace.h" -#include "hal_iomux.h" -#include "hal_gpio.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "hal_iomux.h" -#include "app_ai_if_config.h" #include "communication_svr.h" +#include "app_ai_if_config.h" +#include "cmsis_nvic.h" +#include "cmsis_os.h" #include "communication_sysapi.h" - +#include "crc32.h" +#include "hal_gpio.h" +#include "hal_iomux.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "plat_types.h" +#include "stdbool.h" +#include "stdint.h" +#include "stdio.h" +#include "string.h" //====================================================================================================== enum COMMUNICATION_MSG { - COMMUNICATION_MSG_TX_REQ = 0, - COMMUNICATION_MSG_TX_DONE = 1, - COMMUNICATION_MSG_RX_REQ = 2, - COMMUNICATION_MSG_RX_DONE = 3, - COMMUNICATION_MSG_INIT = 4, - COMMUNICATION_MSG_REINIT = 5, - COMMUNICATION_MSG_RESET = 6, - COMMUNICATION_MSG_BREAK = 7, + COMMUNICATION_MSG_TX_REQ = 0, + COMMUNICATION_MSG_TX_DONE = 1, + COMMUNICATION_MSG_RX_REQ = 2, + COMMUNICATION_MSG_RX_DONE = 3, + COMMUNICATION_MSG_INIT = 4, + COMMUNICATION_MSG_REINIT = 5, + COMMUNICATION_MSG_RESET = 6, + COMMUNICATION_MSG_BREAK = 7, }; const static uint8_t communication_process_log[8][26] = { - "COMMUNICATION_MSG_TX_REQ", - "COMMUNICATION_MSG_TX_DONE", - "COMMUNICATION_MSG_RX_REQ", - "COMMUNICATION_MSG_RX_DONE", - "COMMUNICATION_MSG_INIT", - "COMMUNICATION_MSG_REINIT", - "COMMUNICATION_MSG_RESET", - "COMMUNICATION_MSG_BREAK", + "COMMUNICATION_MSG_TX_REQ", "COMMUNICATION_MSG_TX_DONE", + "COMMUNICATION_MSG_RX_REQ", "COMMUNICATION_MSG_RX_DONE", + "COMMUNICATION_MSG_INIT", "COMMUNICATION_MSG_REINIT", + "COMMUNICATION_MSG_RESET", "COMMUNICATION_MSG_BREAK", }; enum COMMUNICATION_MODE { - COMMUNICATION_MODE_NULL, - COMMUNICATION_MODE_TX, - COMMUNICATION_MODE_RX, - COMMUNICATION_MODE_ENABLE_IRQ, - COMMUNICATION_MODE_DISABLE_IRQ, + COMMUNICATION_MODE_NULL, + COMMUNICATION_MODE_TX, + COMMUNICATION_MODE_RX, + COMMUNICATION_MODE_ENABLE_IRQ, + COMMUNICATION_MODE_DISABLE_IRQ, }; - #define COMMAND_BLOCK_MAX (5) #define COMMAND_LEN_MAX (128) -#define COMMAND_TRANSMITTED_SIGNAL (1<<0) +#define COMMAND_TRANSMITTED_SIGNAL (1 << 0) typedef struct { - uint8_t cmd_buf[COMMAND_LEN_MAX]; - uint8_t cmd_len; + uint8_t cmd_buf[COMMAND_LEN_MAX]; + uint8_t cmd_len; } COMMAND_BLOCK; -osPoolDef (command_mempool, COMMAND_BLOCK_MAX, COMMAND_BLOCK); -osPoolId command_mempool = NULL; - +osPoolDef(command_mempool, COMMAND_BLOCK_MAX, COMMAND_BLOCK); +osPoolId command_mempool = NULL; #define COMMUNICATION_MAILBOX_MAX (10) typedef struct { - uint32_t src_thread; - uint32_t system_time; - uint32_t message; - uint32_t parms1; - uint32_t parms2; + uint32_t src_thread; + uint32_t system_time; + uint32_t message; + uint32_t parms1; + uint32_t parms2; } COMMUNICATION_MAIL; -osMailQDef (communication_mailbox, COMMUNICATION_MAILBOX_MAX, COMMUNICATION_MAIL); +osMailQDef(communication_mailbox, COMMUNICATION_MAILBOX_MAX, + COMMUNICATION_MAIL); static osMailQId communication_mailbox = NULL; static uint8_t communication_mailbox_cnt = 0; - static osThreadId communication_tid = NULL; static void communication_thread(void const *argument); -osThreadDef(communication_thread, osPriorityHigh, 1, 2048, "communication_server"); +osThreadDef(communication_thread, osPriorityHigh, 1, 2048, + "communication_server"); static bool uart_opened = false; static int uart_error_detected = 0; @@ -115,486 +108,462 @@ static void uart_rx_idle_handler(void const *param); osTimerDef(uart_rx_idle_timer, uart_rx_idle_handler); static osTimerId uart_rx_idle_timer_id = NULL; - static communication_receive_func_typedef communication_receive_cb = NULL; - const static struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_led2 = { - HAL_IOMUX_PIN_LED2, HAL_IOMUX_FUNC_GPIO, HAL_IOMUX_PIN_VOLTAGE_VBAT, HAL_IOMUX_PIN_PULLUP_ENABLE, + HAL_IOMUX_PIN_LED2, + HAL_IOMUX_FUNC_GPIO, + HAL_IOMUX_PIN_VOLTAGE_VBAT, + HAL_IOMUX_PIN_PULLUP_ENABLE, }; - -inline int communication_mailbox_put(COMMUNICATION_MAIL* msg_src); -static void communication_process(COMMUNICATION_MAIL* mail_p); +inline int communication_mailbox_put(COMMUNICATION_MAIL *msg_src); +static void communication_process(COMMUNICATION_MAIL *mail_p); int communication_io_mode_switch(enum COMMUNICATION_MODE mode); +static void uart_rx_dma_stop(void) { + union HAL_UART_IRQ_T mask; -static void uart_rx_dma_stop(void) -{ - union HAL_UART_IRQ_T mask; - - uint32_t lock = int_lock(); -// TRACE(1,"uart_rx_dma_stop:%d", uart_rx_dma_is_running); - if (uart_rx_dma_is_running){ - mask.reg = 0; - hal_uart_irq_set_mask(comm_uart, mask); - hal_uart_stop_dma_recv(comm_uart); - uart_rx_dma_is_running = false; - } - - int_unlock(lock); -} - -static void uart_rx_dma_start(void) -{ - union HAL_UART_IRQ_T mask; - - uint32_t lock = int_lock(); - -// TRACE(1,"uart_rx_dma_start:%d", uart_rx_dma_is_running); - - hal_uart_flush(comm_uart, 0); - //hal_uart_dma_recv(comm_uart, rx_command_block_p->cmd_buf, COMMAND_LEN_MAX, NULL, NULL); - mask.reg = 0; - mask.RT = 1; - //hal_uart_irq_set_mask(comm_uart, mask); - hal_uart_dma_recv_mask(comm_uart, rx_command_block_p->cmd_buf, COMMAND_LEN_MAX, NULL, NULL,&mask); - - uart_rx_dma_is_running = true; - - int_unlock(lock); -} - -static void uart_break_handler(void) -{ - union HAL_UART_IRQ_T mask; - COMMUNICATION_MAIL msg; - memset(&msg, 0, sizeof(msg)); - - TRACE(0,"UART-BREAK"); + uint32_t lock = int_lock(); + // TRACE(1,"uart_rx_dma_stop:%d", uart_rx_dma_is_running); + if (uart_rx_dma_is_running) { mask.reg = 0; hal_uart_irq_set_mask(comm_uart, mask); - hal_uart_flush(comm_uart, 0); + hal_uart_stop_dma_recv(comm_uart); + uart_rx_dma_is_running = false; + } + + int_unlock(lock); +} + +static void uart_rx_dma_start(void) { + union HAL_UART_IRQ_T mask; + + uint32_t lock = int_lock(); + + // TRACE(1,"uart_rx_dma_start:%d", uart_rx_dma_is_running); + + hal_uart_flush(comm_uart, 0); + // hal_uart_dma_recv(comm_uart, rx_command_block_p->cmd_buf, COMMAND_LEN_MAX, + // NULL, NULL); + mask.reg = 0; + mask.RT = 1; + // hal_uart_irq_set_mask(comm_uart, mask); + hal_uart_dma_recv_mask(comm_uart, rx_command_block_p->cmd_buf, + COMMAND_LEN_MAX, NULL, NULL, &mask); + + uart_rx_dma_is_running = true; + + int_unlock(lock); +} + +static void uart_break_handler(void) { + union HAL_UART_IRQ_T mask; + COMMUNICATION_MAIL msg; + memset(&msg, 0, sizeof(msg)); + + TRACE(0, "UART-BREAK"); + mask.reg = 0; + hal_uart_irq_set_mask(comm_uart, mask); + hal_uart_flush(comm_uart, 0); + uart_error_detected = 1; + msg.message = COMMUNICATION_MSG_BREAK; + communication_mailbox_put(&msg); +} + +static void uart_rx_dma_handler(uint32_t xfer_size, int dma_error, + union HAL_UART_IRQ_T status) { + COMMUNICATION_MAIL msg; + + // TRACE(8,"UART-RX size:%d dma_error=%d, status=0x%08x rt:%d fe:%d pe:%d + // be:%d oe:%d", xfer_size, dma_error, status, status.RT, status.FE, + // status.PE, status.BE, status.OE); + + if (status.BE) { + uart_break_handler(); + return; + } + + memset(&msg, 0, sizeof(COMMUNICATION_MAIL)); + msg.message = COMMUNICATION_MSG_RX_DONE; + + if (dma_error || status.FE || status.PE || status.BE || status.OE) { uart_error_detected = 1; - msg.message = COMMUNICATION_MSG_BREAK; + uart_rx_dma_stop(); + msg.parms1 = false; + msg.message = COMMUNICATION_MSG_RESET; communication_mailbox_put(&msg); + } else { + if (xfer_size) { + msg.parms1 = true; + msg.parms2 = xfer_size; + communication_mailbox_put(&msg); + } else { + uart_rx_dma_stop(); + msg.message = COMMUNICATION_MSG_RESET; + communication_mailbox_put(&msg); + } + } } -static void uart_rx_dma_handler(uint32_t xfer_size, int dma_error, union HAL_UART_IRQ_T status) -{ - COMMUNICATION_MAIL msg; +static void uart_tx_dma_handler(uint32_t xfer_size, int dma_error) { + COMMUNICATION_MAIL msg; - //TRACE(8,"UART-RX size:%d dma_error=%d, status=0x%08x rt:%d fe:%d pe:%d be:%d oe:%d", xfer_size, dma_error, status, status.RT, status.FE, status.PE, status.BE, status.OE); + memset(&msg, 0, sizeof(COMMUNICATION_MAIL)); - if (status.BE) { - uart_break_handler(); - return; - } + // TRACE(2,"UART-TX size:%d dma_error=%d", xfer_size, dma_error); - memset(&msg, 0, sizeof(COMMUNICATION_MAIL)); - msg.message = COMMUNICATION_MSG_RX_DONE; + osSignalSet(communication_tid, COMMAND_TRANSMITTED_SIGNAL); - if (dma_error || status.FE|| status.PE || status.BE || status.OE ) { - uart_error_detected = 1; - uart_rx_dma_stop(); - msg.parms1 = false; - msg.message = COMMUNICATION_MSG_RESET; - communication_mailbox_put(&msg); - }else{ - if (xfer_size){ - msg.parms1 = true; - msg.parms2 = xfer_size; - communication_mailbox_put(&msg); - }else{ - uart_rx_dma_stop(); - msg.message = COMMUNICATION_MSG_RESET; - communication_mailbox_put(&msg); - } - } + msg.message = COMMUNICATION_MSG_TX_DONE; + + communication_mailbox_put(&msg); } -static void uart_tx_dma_handler(uint32_t xfer_size, int dma_error) -{ - COMMUNICATION_MAIL msg; +static void uart_init(void) { + struct HAL_UART_CFG_T comm_uart_cfg; - memset(&msg, 0, sizeof(COMMUNICATION_MAIL)); + if (!uart_opened) { + memcpy(&comm_uart_cfg, &uart_cfg, sizeof(comm_uart_cfg)); + hal_uart_open(comm_uart, &comm_uart_cfg); + hal_uart_irq_set_dma_handler(comm_uart, uart_rx_dma_handler, + uart_tx_dma_handler); + uart_opened = true; + } -// TRACE(2,"UART-TX size:%d dma_error=%d", xfer_size, dma_error); - - osSignalSet(communication_tid, COMMAND_TRANSMITTED_SIGNAL); - - msg.message = COMMUNICATION_MSG_TX_DONE; - - communication_mailbox_put(&msg); + hal_uart_flush(comm_uart, 0); } -static void uart_init(void) -{ - struct HAL_UART_CFG_T comm_uart_cfg; - - if (!uart_opened) { - memcpy(&comm_uart_cfg, &uart_cfg, sizeof(comm_uart_cfg)); - hal_uart_open(comm_uart, &comm_uart_cfg); - hal_uart_irq_set_dma_handler(comm_uart, uart_rx_dma_handler, uart_tx_dma_handler); - uart_opened = true; - } - - hal_uart_flush(comm_uart, 0); +static void uart_deinit(void) { + if (uart_opened) { + hal_uart_close(comm_uart); + uart_opened = false; + } } -static void uart_deinit(void) -{ - if (uart_opened) { - hal_uart_close(comm_uart); - uart_opened = false; - } -} +static void uart_rx_idle_timer_start(void) { + uart_rx_idle_counter = 0; + TRACE(1, "[%s] enter...", __func__); -static void uart_rx_idle_timer_start(void) -{ - uart_rx_idle_counter = 0; - TRACE(1,"[%s] enter...", __func__); - - if (uart_rx_idle_timer_id != NULL) { - osTimerStop(uart_rx_idle_timer_id); - osTimerStart(uart_rx_idle_timer_id, 100); - } + if (uart_rx_idle_timer_id != NULL) { + osTimerStop(uart_rx_idle_timer_id); + osTimerStart(uart_rx_idle_timer_id, 100); + } } #if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) -static void uart_rx_edge_detect_handler(enum HAL_GPIO_PIN_T pin) -{ - COMMUNICATION_MAIL msg = {0}; +static void uart_rx_edge_detect_handler(enum HAL_GPIO_PIN_T pin) { + COMMUNICATION_MAIL msg = {0}; - //disable led2 pin external interrupt mode... - communication_io_mode_switch(COMMUNICATION_MODE_DISABLE_IRQ); + // disable led2 pin external interrupt mode... + communication_io_mode_switch(COMMUNICATION_MODE_DISABLE_IRQ); - //post uart rx request... - msg.message = COMMUNICATION_MSG_RX_REQ; - communication_mailbox_put(&msg); + // post uart rx request... + msg.message = COMMUNICATION_MSG_RX_REQ; + communication_mailbox_put(&msg); } #endif -static void uart_rx_idle_handler(void const *param) -{ - const uint8_t rx_idle_indicate[2] = {0x10,0x24}; +static void uart_rx_idle_handler(void const *param) { + const uint8_t rx_idle_indicate[2] = {0x10, 0x24}; - if(uart_rx_idle_counter++ >= 150)//150 * 100 = 15s - { - TRACE(1,"[%s] enter...", __func__); + if (uart_rx_idle_counter++ >= 150) // 150 * 100 = 15s + { + TRACE(1, "[%s] enter...", __func__); - uart_rx_idle_counter = 0; + uart_rx_idle_counter = 0; - //stop virtual timer... - osTimerStop(uart_rx_idle_timer_id); + // stop virtual timer... + osTimerStop(uart_rx_idle_timer_id); - //stop uart rx dma... - uart_rx_dma_stop(); + // stop uart rx dma... + uart_rx_dma_stop(); - //notify charge box uart rx dma has closed... - communication_io_mode_switch(COMMUNICATION_MODE_TX); - hal_uart_dma_send(comm_uart, rx_idle_indicate, 2, NULL, NULL); - osDelay(10); + // notify charge box uart rx dma has closed... + communication_io_mode_switch(COMMUNICATION_MODE_TX); + hal_uart_dma_send(comm_uart, rx_idle_indicate, 2, NULL, NULL); + osDelay(10); - //config led2 pin as external interrupt mode... - communication_io_mode_switch(COMMUNICATION_MODE_ENABLE_IRQ); - } + // config led2 pin as external interrupt mode... + communication_io_mode_switch(COMMUNICATION_MODE_ENABLE_IRQ); + } } - -int communication_io_mode_switch(enum COMMUNICATION_MODE mode) -{ - //best1400 and best1402 platform - switch (mode) - { - case COMMUNICATION_MODE_TX: { - #if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) - hal_iomux_single_wire_uart1_tx(); - #endif - } - break; - case COMMUNICATION_MODE_RX: { - #if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) - hal_iomux_single_wire_uart1_rx(); - #endif - } - break; - case COMMUNICATION_MODE_ENABLE_IRQ: { - #if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) - hal_iomux_single_wire_uart1_enable_irq(uart_rx_edge_detect_handler); - #endif - } - break; - case COMMUNICATION_MODE_DISABLE_IRQ: { - #if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) - hal_iomux_single_wire_uart1_disable_irq(); - #endif - } - break; - default:break; - } - return 0; +int communication_io_mode_switch(enum COMMUNICATION_MODE mode) { + // best1400 and best1402 platform + switch (mode) { + case COMMUNICATION_MODE_TX: { +#if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) + hal_iomux_single_wire_uart1_tx(); +#endif + } break; + case COMMUNICATION_MODE_RX: { +#if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) + hal_iomux_single_wire_uart1_rx(); +#endif + } break; + case COMMUNICATION_MODE_ENABLE_IRQ: { +#if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) + hal_iomux_single_wire_uart1_enable_irq(uart_rx_edge_detect_handler); +#endif + } break; + case COMMUNICATION_MODE_DISABLE_IRQ: { +#if defined(CHIP_BEST1400) || defined(CHIP_BEST1402) + hal_iomux_single_wire_uart1_disable_irq(); +#endif + } break; + default: + break; + } + return 0; } -int communication_io_mode_init(void) -{ - communication_io_mode_switch(COMMUNICATION_MODE_RX); +int communication_io_mode_init(void) { + communication_io_mode_switch(COMMUNICATION_MODE_RX); - return 0; + return 0; } -inline int communication_mailbox_put(COMMUNICATION_MAIL* msg_src) -{ - osStatus status; +inline int communication_mailbox_put(COMMUNICATION_MAIL *msg_src) { + osStatus status; - COMMUNICATION_MAIL *mail_p = NULL; + COMMUNICATION_MAIL *mail_p = NULL; - if (msg_src == NULL) - { - return -1; - } - - mail_p = (COMMUNICATION_MAIL*)osMailAlloc(communication_mailbox, 0); - if (!mail_p){ - osEvent evt; - TRACE(0,"communication_mailbox"); - for (uint8_t i=0; imessage, - ((COMMUNICATION_MAIL *)(evt.value.p))->parms1, - ((COMMUNICATION_MAIL *)(evt.value.p))->parms2); - }else{ - break; - } - } - ASSERT(mail_p, "communication_mailbox error"); - } - mail_p->src_thread = (uint32_t)osThreadGetId(); - mail_p->system_time = hal_sys_timer_get(); - mail_p->message = msg_src->message; - mail_p->parms1 = msg_src->parms1; - mail_p->parms2 = msg_src->parms2; - status = osMailPut(communication_mailbox, mail_p); - if (osOK == status){ - communication_mailbox_cnt++; - } - - return (int)status; -} - -inline int communication_mailbox_free(COMMUNICATION_MAIL* mail_p) -{ - osStatus status; - - status = osMailFree(communication_mailbox, mail_p); - if (osOK == status){ - communication_mailbox_cnt--; - } - return (int)status; -} - -inline int communication_mailbox_get(COMMUNICATION_MAIL** mail_p) -{ - osEvent evt; - evt = osMailGet(communication_mailbox, osWaitForever); - if (evt.status == osEventMail) { - *mail_p = (COMMUNICATION_MAIL *)evt.value.p; - return 0; - } + if (msg_src == NULL) { return -1; -} + } -static void communication_thread(void const *argument) -{ - while(1){ - COMMUNICATION_MAIL *mail_p = NULL; - if (!communication_mailbox_get(&mail_p)){ - communication_process(mail_p); - communication_mailbox_free(mail_p); - } - } -} - -int communication_command_block_alloc(COMMAND_BLOCK **cmd_blk) -{ - *cmd_blk = (COMMAND_BLOCK *)osPoolCAlloc (command_mempool); - ASSERT(*cmd_blk, "%s error", __func__); - return 0; -} - -void communication_command_block_free(COMMAND_BLOCK *cmd_blk) -{ - osPoolFree(command_mempool, cmd_blk); -} - -void communication_send_command(COMMAND_BLOCK *cmd_blk) -{ - COMMUNICATION_MAIL mail; - memset(&mail, 0, sizeof(mail)); - ASSERT(cmd_blk->cmd_len <=COMMAND_LEN_MAX, "%s len error", __func__); - mail.message = COMMUNICATION_MSG_TX_REQ; - mail.parms2 = (uint32_t)cmd_blk; - communication_mailbox_put(&mail); -} - -static void communication_process(COMMUNICATION_MAIL* mail_p) -{ + mail_p = (COMMUNICATION_MAIL *)osMailAlloc(communication_mailbox, 0); + if (!mail_p) { osEvent evt; - COMMAND_BLOCK *command_block_p; - COMMUNICATION_MAIL msg; - uint32_t lock; - - TRACE(2,"[%s]: %s", __func__, communication_process_log[mail_p->message]); - - memset(&msg, 0, sizeof(COMMUNICATION_MAIL)); - switch (mail_p->message) { - case COMMUNICATION_MSG_TX_REQ: - command_block_p = (COMMAND_BLOCK *)mail_p->parms2; - TRACE(1,"UART TX:%d", command_block_p->cmd_len); - DUMP8("%02x ", command_block_p->cmd_buf, command_block_p->cmd_len); - uart_rx_dma_stop(); - communication_io_mode_switch(COMMUNICATION_MODE_TX); - osSignalClear(communication_tid, COMMAND_TRANSMITTED_SIGNAL); - hal_uart_dma_send(comm_uart, command_block_p->cmd_buf, command_block_p->cmd_len, NULL, NULL); - evt = osSignalWait(COMMAND_TRANSMITTED_SIGNAL, 1000); - if (evt.status== osEventTimeout){ - ASSERT(0, "%s osEventTimeout", __func__); - } - communication_command_block_free(command_block_p); - while (!hal_uart_get_flag(comm_uart).TXFE || hal_uart_get_flag(comm_uart).BUSY){ - osThreadYield(); - } - communication_io_mode_switch(COMMUNICATION_MODE_RX); - if (!uart_error_detected){ - uart_rx_dma_start(); - uart_rx_idle_timer_start(); - } - break; - case COMMUNICATION_MSG_TX_DONE: - break; - case COMMUNICATION_MSG_RX_REQ: - communication_io_mode_init(); - uart_init(); - uart_rx_dma_start(); - uart_rx_idle_timer_start(); - break; - case COMMUNICATION_MSG_RX_DONE: - TRACE(2,"UART RX status:%d len:%d", mail_p->parms1, mail_p->parms2); - DUMP8("%02x ", rx_command_block_p->cmd_buf, mail_p->parms2); - TRACE(1,"%s", rx_command_block_p->cmd_buf); - - if(communication_receive_cb != NULL) - (*communication_receive_cb)(rx_command_block_p->cmd_buf, mail_p->parms2); - - memset(rx_command_block_p->cmd_buf, 0, mail_p->parms2); - - if (!uart_error_detected){ - uart_rx_dma_start(); - uart_rx_idle_timer_start(); - } - break; - case COMMUNICATION_MSG_REINIT: - uart_deinit(); - case COMMUNICATION_MSG_INIT: - uart_error_detected = 0; - communication_io_mode_init(); - uart_init(); - uart_rx_dma_start(); - uart_rx_idle_timer_id = osTimerCreate(osTimer(uart_rx_idle_timer), osTimerPeriodic, NULL); - uart_rx_idle_timer_start(); - break; - case COMMUNICATION_MSG_RESET: - case COMMUNICATION_MSG_BREAK: - lock = int_lock(); - uart_rx_dma_stop(); - communication_io_mode_switch(COMMUNICATION_MODE_RX); - hal_uart_flush(comm_uart, 0); - uart_rx_dma_start(); - uart_error_detected = 0; - int_unlock(lock); - uart_rx_idle_timer_start(); - break; - - default: - break; + TRACE(0, "communication_mailbox"); + for (uint8_t i = 0; i < COMMUNICATION_MAILBOX_MAX; i++) { + evt = osMailGet(communication_mailbox, 0); + if (evt.status == osEventMail) { + TRACE(4, "msg cnt:%d msg:%d parms:%08x/%08x", i, + ((COMMUNICATION_MAIL *)(evt.value.p))->message, + ((COMMUNICATION_MAIL *)(evt.value.p))->parms1, + ((COMMUNICATION_MAIL *)(evt.value.p))->parms2); + } else { + break; + } } + ASSERT(mail_p, "communication_mailbox error"); + } + mail_p->src_thread = (uint32_t)osThreadGetId(); + mail_p->system_time = hal_sys_timer_get(); + mail_p->message = msg_src->message; + mail_p->parms1 = msg_src->parms1; + mail_p->parms2 = msg_src->parms2; + status = osMailPut(communication_mailbox, mail_p); + if (osOK == status) { + communication_mailbox_cnt++; + } + return (int)status; } -void communication_init(void) -{ - COMMUNICATION_MAIL msg; - COMMAND_BLOCK *cmd_blk; +inline int communication_mailbox_free(COMMUNICATION_MAIL *mail_p) { + osStatus status; - memset(&msg, 0, sizeof(COMMUNICATION_MAIL)); - TRACE(1,"%s", __func__); - - if (command_mempool == NULL){ - command_mempool = osPoolCreate(osPool(command_mempool)); - } - - if (communication_mailbox == NULL){ - communication_mailbox = osMailCreate(osMailQ(communication_mailbox), NULL); - } - - if (communication_tid == NULL){ - communication_tid = osThreadCreate(osThread(communication_thread), NULL); - } - - if (rx_command_block_p == NULL){ - communication_command_block_alloc(&rx_command_block_p); - memset(rx_command_block_p->cmd_buf, 0, COMMAND_LEN_MAX); - rx_command_block_p->cmd_len = 0; - } - - msg.message = COMMUNICATION_MSG_INIT; - communication_mailbox_put(&msg); - - communication_command_block_alloc(&cmd_blk); - cmd_blk->cmd_buf[0] = 0xff; - cmd_blk->cmd_len = 1; - communication_send_command(cmd_blk); + status = osMailFree(communication_mailbox, mail_p); + if (osOK == status) { + communication_mailbox_cnt--; + } + return (int)status; } -int communication_receive_register_callback(communication_receive_func_typedef p) -{ - if(p == NULL) - return -1; - - communication_receive_cb = p; - - TRACE(1,"[%s] register receive callback success\n", __func__); - +inline int communication_mailbox_get(COMMUNICATION_MAIL **mail_p) { + osEvent evt; + evt = osMailGet(communication_mailbox, osWaitForever); + if (evt.status == osEventMail) { + *mail_p = (COMMUNICATION_MAIL *)evt.value.p; return 0; + } + return -1; } -int communication_send_buf(uint8_t * buf, uint8_t len) -{ - COMMAND_BLOCK *cmd_blk; +static void communication_thread(void const *argument) { + while (1) { + COMMUNICATION_MAIL *mail_p = NULL; + if (!communication_mailbox_get(&mail_p)) { + communication_process(mail_p); + communication_mailbox_free(mail_p); + } + } +} - communication_command_block_alloc(&cmd_blk); - memcpy(cmd_blk->cmd_buf, buf, len); - cmd_blk->cmd_len = len; - communication_send_command(cmd_blk); - return 0; +int communication_command_block_alloc(COMMAND_BLOCK **cmd_blk) { + *cmd_blk = (COMMAND_BLOCK *)osPoolCAlloc(command_mempool); + ASSERT(*cmd_blk, "%s error", __func__); + return 0; +} + +void communication_command_block_free(COMMAND_BLOCK *cmd_blk) { + osPoolFree(command_mempool, cmd_blk); +} + +void communication_send_command(COMMAND_BLOCK *cmd_blk) { + COMMUNICATION_MAIL mail; + memset(&mail, 0, sizeof(mail)); + ASSERT(cmd_blk->cmd_len <= COMMAND_LEN_MAX, "%s len error", __func__); + mail.message = COMMUNICATION_MSG_TX_REQ; + mail.parms2 = (uint32_t)cmd_blk; + communication_mailbox_put(&mail); +} + +static void communication_process(COMMUNICATION_MAIL *mail_p) { + osEvent evt; + COMMAND_BLOCK *command_block_p; + COMMUNICATION_MAIL msg; + uint32_t lock; + + TRACE(2, "[%s]: %s", __func__, communication_process_log[mail_p->message]); + + memset(&msg, 0, sizeof(COMMUNICATION_MAIL)); + switch (mail_p->message) { + case COMMUNICATION_MSG_TX_REQ: + command_block_p = (COMMAND_BLOCK *)mail_p->parms2; + TRACE(1, "UART TX:%d", command_block_p->cmd_len); + DUMP8("%02x ", command_block_p->cmd_buf, command_block_p->cmd_len); + uart_rx_dma_stop(); + communication_io_mode_switch(COMMUNICATION_MODE_TX); + osSignalClear(communication_tid, COMMAND_TRANSMITTED_SIGNAL); + hal_uart_dma_send(comm_uart, command_block_p->cmd_buf, + command_block_p->cmd_len, NULL, NULL); + evt = osSignalWait(COMMAND_TRANSMITTED_SIGNAL, 1000); + if (evt.status == osEventTimeout) { + ASSERT(0, "%s osEventTimeout", __func__); + } + communication_command_block_free(command_block_p); + while (!hal_uart_get_flag(comm_uart).TXFE || + hal_uart_get_flag(comm_uart).BUSY) { + osThreadYield(); + } + communication_io_mode_switch(COMMUNICATION_MODE_RX); + if (!uart_error_detected) { + uart_rx_dma_start(); + uart_rx_idle_timer_start(); + } + break; + case COMMUNICATION_MSG_TX_DONE: + break; + case COMMUNICATION_MSG_RX_REQ: + communication_io_mode_init(); + uart_init(); + uart_rx_dma_start(); + uart_rx_idle_timer_start(); + break; + case COMMUNICATION_MSG_RX_DONE: + TRACE(2, "UART RX status:%d len:%d", mail_p->parms1, mail_p->parms2); + DUMP8("%02x ", rx_command_block_p->cmd_buf, mail_p->parms2); + TRACE(1, "%s", rx_command_block_p->cmd_buf); + + if (communication_receive_cb != NULL) + (*communication_receive_cb)(rx_command_block_p->cmd_buf, mail_p->parms2); + + memset(rx_command_block_p->cmd_buf, 0, mail_p->parms2); + + if (!uart_error_detected) { + uart_rx_dma_start(); + uart_rx_idle_timer_start(); + } + break; + case COMMUNICATION_MSG_REINIT: + uart_deinit(); + case COMMUNICATION_MSG_INIT: + uart_error_detected = 0; + communication_io_mode_init(); + uart_init(); + uart_rx_dma_start(); + uart_rx_idle_timer_id = + osTimerCreate(osTimer(uart_rx_idle_timer), osTimerPeriodic, NULL); + uart_rx_idle_timer_start(); + break; + case COMMUNICATION_MSG_RESET: + case COMMUNICATION_MSG_BREAK: + lock = int_lock(); + uart_rx_dma_stop(); + communication_io_mode_switch(COMMUNICATION_MODE_RX); + hal_uart_flush(comm_uart, 0); + uart_rx_dma_start(); + uart_error_detected = 0; + int_unlock(lock); + uart_rx_idle_timer_start(); + break; + + default: + break; + } +} + +void communication_init(void) { + COMMUNICATION_MAIL msg; + COMMAND_BLOCK *cmd_blk; + + memset(&msg, 0, sizeof(COMMUNICATION_MAIL)); + TRACE(1, "%s", __func__); + + if (command_mempool == NULL) { + command_mempool = osPoolCreate(osPool(command_mempool)); + } + + if (communication_mailbox == NULL) { + communication_mailbox = osMailCreate(osMailQ(communication_mailbox), NULL); + } + + if (communication_tid == NULL) { + communication_tid = osThreadCreate(osThread(communication_thread), NULL); + } + + if (rx_command_block_p == NULL) { + communication_command_block_alloc(&rx_command_block_p); + memset(rx_command_block_p->cmd_buf, 0, COMMAND_LEN_MAX); + rx_command_block_p->cmd_len = 0; + } + + msg.message = COMMUNICATION_MSG_INIT; + communication_mailbox_put(&msg); + + communication_command_block_alloc(&cmd_blk); + cmd_blk->cmd_buf[0] = 0xff; + cmd_blk->cmd_len = 1; + communication_send_command(cmd_blk); +} + +int communication_receive_register_callback( + communication_receive_func_typedef p) { + if (p == NULL) + return -1; + + communication_receive_cb = p; + + TRACE(1, "[%s] register receive callback success\n", __func__); + + return 0; +} + +int communication_send_buf(uint8_t *buf, uint8_t len) { + COMMAND_BLOCK *cmd_blk; + + communication_command_block_alloc(&cmd_blk); + memcpy(cmd_blk->cmd_buf, buf, len); + cmd_blk->cmd_len = len; + communication_send_command(cmd_blk); + return 0; } #ifdef KNOWLES_UART_DATA #include "knowles_uart.h" -void uart_audio_init() -{ - TRACE(1,"%s run!!!", __func__); - init_transport(); +void uart_audio_init() { + TRACE(1, "%s run!!!", __func__); + init_transport(); } -void uart_audio_deinit() -{ - deinit_transport(); - reopen_uart(); +void uart_audio_deinit() { + deinit_transport(); + reopen_uart(); } #endif - diff --git a/services/communication/communication_svr.h b/services/communication/communication_svr.h index 759ce78..074422c 100644 --- a/services/communication/communication_svr.h +++ b/services/communication/communication_svr.h @@ -4,24 +4,22 @@ #ifdef __cplusplus extern "C" { #endif - +#include typedef void (*communication_receive_func_typedef)(uint8_t *buf, uint8_t len); void communication_init(void); -int communication_receive_register_callback(communication_receive_func_typedef p); -int communication_send_buf(uint8_t * buf, uint8_t len); - +int communication_receive_register_callback( + communication_receive_func_typedef p); +int communication_send_buf(uint8_t *buf, uint8_t len); #ifdef KNOWLES_UART_DATA void uart_audio_init(); void uart_audio_deinit(); #endif - #ifdef __cplusplus } #endif #endif - diff --git a/services/cp_accel/cp_accel.c b/services/cp_accel/cp_accel.c index 0c07f9c..b80c7c0 100644 --- a/services/cp_accel/cp_accel.c +++ b/services/cp_accel/cp_accel.c @@ -16,39 +16,39 @@ #ifdef CHIP_HAS_CP #include "cp_accel.h" +#include "app_utils.h" #include "cmsis.h" #include "cmsis_os.h" #include "hal_cmu.h" #include "hal_location.h" #include "hal_mcu2cp.h" +#include "hal_memsc.h" #include "hal_timer.h" #include "hal_trace.h" #include "mpu.h" #include "stdarg.h" -#include "system_cp.h" -#include "hal_memsc.h" #include "string.h" -#include "app_utils.h" +#include "system_cp.h" #ifdef CP_ACCEL_DEBUG -#define CP_ACCEL_TRACE(s, ...) TRACE(s, ##__VA_ARGS__) +#define CP_ACCEL_TRACE(s, ...) TRACE(s, ##__VA_ARGS__) #else #define CP_ACCEL_TRACE(s, ...) #endif #define CP_NO_FLASH_ACCESS -#define CP_CRASH_START_TIMEOUT MS_TO_TICKS(100) -#define CP_TRACE_FLUSH_TIMEOUT MS_TO_TICKS(200) -#define CP_CRASH_DUMP_TIMEOUT MS_TO_TICKS(500) -#define CP_TRACE_BUF_FULL_INTVL MS_TO_TICKS(50) +#define CP_CRASH_START_TIMEOUT MS_TO_TICKS(100) +#define CP_TRACE_FLUSH_TIMEOUT MS_TO_TICKS(200) +#define CP_CRASH_DUMP_TIMEOUT MS_TO_TICKS(500) +#define CP_TRACE_BUF_FULL_INTVL MS_TO_TICKS(50) enum CP_SYS_EVENT_T { - CP_SYS_EVENT_NONE = 0, - CP_SYS_EVENT_CRASH_START, - CP_SYS_EVENT_CRASH_END, - CP_SYS_EVENT_TRACE_FLUSH, - CP_SYS_EVENT_TRACE_BUF_FULL, + CP_SYS_EVENT_NONE = 0, + CP_SYS_EVENT_CRASH_START, + CP_SYS_EVENT_CRASH_END, + CP_SYS_EVENT_TRACE_FLUSH, + CP_SYS_EVENT_TRACE_BUF_FULL, }; static bool ram_inited; @@ -62,129 +62,134 @@ static CP_BSS_LOC volatile uint8_t cp_in_sleep; static CP_BSS_LOC uint32_t cp_buf_full_time; static CP_BSS_LOC uint8_t req_event = 0, pending_event = 0; -static CP_TEXT_SRAM_LOC int send_sys_ctrl_cp2mcu(uint32_t event) -{ - return hal_mcu2cp_send_cp(HAL_MCU2CP_ID_1, HAL_MCU2CP_MSG_TYPE_0, (unsigned char *)event, 0); +static CP_TEXT_SRAM_LOC int send_sys_ctrl_cp2mcu(uint32_t event) { + return hal_mcu2cp_send_cp(HAL_MCU2CP_ID_1, HAL_MCU2CP_MSG_TYPE_0, + (unsigned char *)event, 0); } -static CP_TEXT_SRAM_LOC void cp_trace_crash_notify(enum HAL_TRACE_STATE_T state) -{ - uint32_t time; +static CP_TEXT_SRAM_LOC void +cp_trace_crash_notify(enum HAL_TRACE_STATE_T state) { + uint32_t time; - if (state == HAL_TRACE_STATE_CRASH_ASSERT_START || state == HAL_TRACE_STATE_CRASH_FAULT_START) { - cp_in_crash = true; - cp_sys_evt = CP_SYS_EVENT_CRASH_START; - mpu_close(); - send_sys_ctrl_cp2mcu(0); - - time = hal_sys_timer_get(); - while (cp_sys_evt == CP_SYS_EVENT_CRASH_START && - hal_sys_timer_get() - time < CP_CRASH_START_TIMEOUT); - } else { - cp_sys_evt = CP_SYS_EVENT_CRASH_END; - } -} - -static CP_TEXT_SRAM_LOC void cp_trace_buffer_ctrl(enum HAL_TRACE_BUF_STATE_T buf_state) -{ - uint32_t time; - - if (cp_sys_evt != CP_SYS_EVENT_NONE) { - return; - } + if (state == HAL_TRACE_STATE_CRASH_ASSERT_START || + state == HAL_TRACE_STATE_CRASH_FAULT_START) { + cp_in_crash = true; + cp_sys_evt = CP_SYS_EVENT_CRASH_START; + mpu_close(); + send_sys_ctrl_cp2mcu(0); time = hal_sys_timer_get(); - - if (buf_state == HAL_TRACE_BUF_STATE_FLUSH) { - cp_sys_evt = CP_SYS_EVENT_TRACE_FLUSH; - if (!cp_in_crash) { - send_sys_ctrl_cp2mcu(0); - } - - while (cp_sys_evt == CP_SYS_EVENT_TRACE_FLUSH && - hal_sys_timer_get() - time < CP_TRACE_FLUSH_TIMEOUT); - } else if (buf_state == HAL_TRACE_BUF_STATE_FULL || buf_state == HAL_TRACE_BUF_STATE_NEAR_FULL) { - if (time - cp_buf_full_time >= CP_TRACE_BUF_FULL_INTVL) { - cp_buf_full_time = time; - if (!cp_in_crash) { - cp_sys_evt = CP_SYS_EVENT_TRACE_BUF_FULL; - send_sys_ctrl_cp2mcu(0); - } - } - } + while (cp_sys_evt == CP_SYS_EVENT_CRASH_START && + hal_sys_timer_get() - time < CP_CRASH_START_TIMEOUT) + ; + } else { + cp_sys_evt = CP_SYS_EVENT_CRASH_END; + } } -static SRAM_TEXT_LOC unsigned int cp2mcu_sys_arrived(const unsigned char *data, unsigned int len) -{ - uint32_t time; - uint8_t task_id = 0; +static CP_TEXT_SRAM_LOC void +cp_trace_buffer_ctrl(enum HAL_TRACE_BUF_STATE_T buf_state) { + uint32_t time; - if (cp_sys_evt == CP_SYS_EVENT_TRACE_FLUSH) { + if (cp_sys_evt != CP_SYS_EVENT_NONE) { + return; + } + + time = hal_sys_timer_get(); + + if (buf_state == HAL_TRACE_BUF_STATE_FLUSH) { + cp_sys_evt = CP_SYS_EVENT_TRACE_FLUSH; + if (!cp_in_crash) { + send_sys_ctrl_cp2mcu(0); + } + + while (cp_sys_evt == CP_SYS_EVENT_TRACE_FLUSH && + hal_sys_timer_get() - time < CP_TRACE_FLUSH_TIMEOUT) + ; + } else if (buf_state == HAL_TRACE_BUF_STATE_FULL || + buf_state == HAL_TRACE_BUF_STATE_NEAR_FULL) { + if (time - cp_buf_full_time >= CP_TRACE_BUF_FULL_INTVL) { + cp_buf_full_time = time; + if (!cp_in_crash) { + cp_sys_evt = CP_SYS_EVENT_TRACE_BUF_FULL; + send_sys_ctrl_cp2mcu(0); + } + } + } +} + +static SRAM_TEXT_LOC unsigned int cp2mcu_sys_arrived(const unsigned char *data, + unsigned int len) { + uint32_t time; + uint8_t task_id = 0; + + if (cp_sys_evt == CP_SYS_EVENT_TRACE_FLUSH) { + TRACE_FLUSH(); + cp_sys_evt = CP_SYS_EVENT_NONE; + } else if (cp_sys_evt == CP_SYS_EVENT_TRACE_BUF_FULL) { + TRACE(0, " "); + cp_sys_evt = CP_SYS_EVENT_NONE; + } else if (cp_sys_evt == CP_SYS_EVENT_CRASH_START) { + cp_sys_evt = CP_SYS_EVENT_NONE; + + TRACE(0, " "); + TRACE(0, "CP Crash starts ..."); + UNLOCK_CP_PROCESS(); // Forced release lock + + // Wait CP crash dump finishes in interrupt context + time = hal_sys_timer_get(); + while (cp_sys_evt != CP_SYS_EVENT_CRASH_END && + hal_sys_timer_get() - time < CP_CRASH_DUMP_TIMEOUT) { + if (cp_sys_evt == CP_SYS_EVENT_TRACE_FLUSH) { TRACE_FLUSH(); cp_sys_evt = CP_SYS_EVENT_NONE; - } else if (cp_sys_evt == CP_SYS_EVENT_TRACE_BUF_FULL) { - TRACE(0," "); - cp_sys_evt = CP_SYS_EVENT_NONE; - } else if (cp_sys_evt == CP_SYS_EVENT_CRASH_START) { - cp_sys_evt = CP_SYS_EVENT_NONE; - - TRACE(0," "); - TRACE(0,"CP Crash starts ..."); - UNLOCK_CP_PROCESS(); //Forced release lock - - // Wait CP crash dump finishes in interrupt context - time = hal_sys_timer_get(); - while (cp_sys_evt != CP_SYS_EVENT_CRASH_END && - hal_sys_timer_get() - time < CP_CRASH_DUMP_TIMEOUT) { - if (cp_sys_evt == CP_SYS_EVENT_TRACE_FLUSH) { - TRACE_FLUSH(); - cp_sys_evt = CP_SYS_EVENT_NONE; - } - } - - for (task_id=0; task_id 1) { - cp_env.mcu2cp_tx_count--; - pending_event = cp_env.mcu2cp_tx_pending[0]; - hal_mcu2cp_send_mcu(HAL_MCU2CP_ID_0, HAL_MCU2CP_MSG_TYPE_0, &pending_event, 1); + if (cp_env.mcu2cp_tx_count > 1) { + cp_env.mcu2cp_tx_count--; + pending_event = cp_env.mcu2cp_tx_pending[0]; + hal_mcu2cp_send_mcu(HAL_MCU2CP_ID_0, HAL_MCU2CP_MSG_TYPE_0, &pending_event, + 1); - for (uint8_t index = 0;index < cp_env.mcu2cp_tx_count-1;index++) { - cp_env.mcu2cp_tx_pending[index] = cp_env.mcu2cp_tx_pending[index+1]; - } - } else { - cp_env.mcu2cp_tx_count = 0; + for (uint8_t index = 0; index < cp_env.mcu2cp_tx_count - 1; index++) { + cp_env.mcu2cp_tx_pending[index] = cp_env.mcu2cp_tx_pending[index + 1]; } + } else { + cp_env.mcu2cp_tx_count = 0; + } } #if defined(__ARM_ARCH_8M_MAIN__) @@ -192,227 +197,222 @@ static CP_TEXT_SRAM_LOC void mcu2cp_msg_sent(const unsigned char *data, unsigned #define CP_CODE_MAP_BASE (ROM_BASE + 0x800) #define CP_CODE_MAP_SIZE (RAMX_BASE + RAM_TOTAL_SIZE - CP_CODE_MAP_BASE) -static CP_DATA_LOC const mpu_regions_t mpu_table_cp[] = { - {CP_CODE_MAP_BASE, CP_CODE_MAP_SIZE, MPU_ATTR_EXEC, MAIR_ATTR_INT_SRAM}, - {RAM_BASE, RAM_TOTAL_SIZE, MPU_ATTR_READ_WRITE, MAIR_ATTR_INT_SRAM}, - {CMU_BASE, 0x01000000, MPU_ATTR_READ_WRITE, MAIR_ATTR_DEVICE}, +static CP_DATA_LOC const mpu_regions_t mpu_table_cp[] = { + {CP_CODE_MAP_BASE, CP_CODE_MAP_SIZE, MPU_ATTR_EXEC, MAIR_ATTR_INT_SRAM}, + {RAM_BASE, RAM_TOTAL_SIZE, MPU_ATTR_READ_WRITE, MAIR_ATTR_INT_SRAM}, + {CMU_BASE, 0x01000000, MPU_ATTR_READ_WRITE, MAIR_ATTR_DEVICE}, }; #else -static CP_DATA_LOC const mpu_regions_t mpu_table_cp[] = { - {0, 0x800, MPU_ATTR_NO_ACCESS}, - {FLASHX_BASE, 0x4000000, MPU_ATTR_NO_ACCESS}, - {FLASH_BASE, 0x4000000, MPU_ATTR_NO_ACCESS}, - {FLASH_NC_BASE, 0x4000000, MPU_ATTR_NO_ACCESS}, +static CP_DATA_LOC const mpu_regions_t mpu_table_cp[] = { + {0, 0x800, MPU_ATTR_NO_ACCESS}, + {FLASHX_BASE, 0x4000000, MPU_ATTR_NO_ACCESS}, + {FLASH_BASE, 0x4000000, MPU_ATTR_NO_ACCESS}, + {FLASH_NC_BASE, 0x4000000, MPU_ATTR_NO_ACCESS}, }; #endif -static CP_TEXT_SRAM_LOC NOINLINE void accel_loop(void) -{ - uint32_t lock; - uint8_t task_index = 0, event_index = 0; - bool msg_flag = false; - uint8_t msg[CP_TASK_MAX][CP_EVENT_MAX]; +static CP_TEXT_SRAM_LOC NOINLINE void accel_loop(void) { + uint32_t lock; + uint8_t task_index = 0, event_index = 0; + bool msg_flag = false; + uint8_t msg[CP_TASK_MAX][CP_EVENT_MAX]; - mpu_setup_cp(mpu_table_cp, ARRAY_SIZE(mpu_table_cp)); + mpu_setup_cp(mpu_table_cp, ARRAY_SIZE(mpu_table_cp)); - while (1) { - lock = int_lock_global(); - msg_flag = cp_env.cp_msg_recv; - cp_env.cp_msg_recv = false; - memcpy(msg, (uint8_t *)cp_env.cp_msg, sizeof(cp_env.cp_msg)); - memset((uint8_t *)cp_env.cp_msg, 0, sizeof(cp_env.cp_msg)); - if (false == msg_flag) { - cp_in_sleep = true; - __WFI(); - cp_in_sleep = false; - } - int_unlock_global(lock); - - if (msg_flag) { - for (task_index = 0;task_index < CP_TASK_MAX;task_index++) { - for (event_index = 0;event_index < CP_EVENT_MAX;event_index++) { - LOCK_CP_PROCESS(); - if ((msg[task_index][event_index]) && (cp_task_env.p_desc[task_index].cp_work_main)) { - cp_task_env.p_desc[task_index].cp_work_main(event_index); - } - UNLOCK_CP_PROCESS(); - } - } + while (1) { + lock = int_lock_global(); + msg_flag = cp_env.cp_msg_recv; + cp_env.cp_msg_recv = false; + memcpy(msg, (uint8_t *)cp_env.cp_msg, sizeof(cp_env.cp_msg)); + memset((uint8_t *)cp_env.cp_msg, 0, sizeof(cp_env.cp_msg)); + if (false == msg_flag) { + cp_in_sleep = true; + __WFI(); + cp_in_sleep = false; + } + int_unlock_global(lock); + + if (msg_flag) { + for (task_index = 0; task_index < CP_TASK_MAX; task_index++) { + for (event_index = 0; event_index < CP_EVENT_MAX; event_index++) { + LOCK_CP_PROCESS(); + if ((msg[task_index][event_index]) && + (cp_task_env.p_desc[task_index].cp_work_main)) { + cp_task_env.p_desc[task_index].cp_work_main(event_index); + } + UNLOCK_CP_PROCESS(); } + } } + } } -static void accel_main(void) -{ - system_cp_init(!ram_inited); - TRACE(1, "%s", __func__); +static void accel_main(void) { + system_cp_init(!ram_inited); + TRACE(1, "%s", __func__); - ram_inited = true; + ram_inited = true; - memset((uint8_t *)&cp_env, 0, sizeof(cp_env)); + memset((uint8_t *)&cp_env, 0, sizeof(cp_env)); - hal_trace_open_cp(); + hal_trace_open_cp(); - hal_mcu2cp_open_cp(HAL_MCU2CP_ID_0, HAL_MCU2CP_MSG_TYPE_0, mcu2cp_msg_arrived, NULL, false); - hal_mcu2cp_open_cp(HAL_MCU2CP_ID_1, HAL_MCU2CP_MSG_TYPE_0, NULL, NULL, false); + hal_mcu2cp_open_cp(HAL_MCU2CP_ID_0, HAL_MCU2CP_MSG_TYPE_0, mcu2cp_msg_arrived, + NULL, false); + hal_mcu2cp_open_cp(HAL_MCU2CP_ID_1, HAL_MCU2CP_MSG_TYPE_0, NULL, NULL, false); - hal_mcu2cp_start_recv_cp(HAL_MCU2CP_ID_0); - //hal_mcu2cp_start_recv_cp(HAL_MCU2CP_ID_1); + hal_mcu2cp_start_recv_cp(HAL_MCU2CP_ID_0); + // hal_mcu2cp_start_recv_cp(HAL_MCU2CP_ID_1); - cp_accel_inited = true; + cp_accel_inited = true; - accel_loop(); + accel_loop(); } -static SRAM_TEXT_LOC unsigned int cp2mcu_msg_arrived(const unsigned char *data, unsigned int len) -{ - uint8_t task_id = CP_TASK_ID_GET((uint32_t)data); - // TRACE(2, "%s, task_id = %d", __func__, task_id); +static SRAM_TEXT_LOC unsigned int cp2mcu_msg_arrived(const unsigned char *data, + unsigned int len) { + uint8_t task_id = CP_TASK_ID_GET((uint32_t)data); + // TRACE(2, "%s, task_id = %d", __func__, task_id); - if (task_id >= CP_TASK_MAX) { - return -1; - } + if (task_id >= CP_TASK_MAX) { + return -1; + } - if (cp_task_env.p_desc[task_id].mcu_evt_hdlr) { - cp_task_env.p_desc[task_id].mcu_evt_hdlr((uint32_t)data); - } + if (cp_task_env.p_desc[task_id].mcu_evt_hdlr) { + cp_task_env.p_desc[task_id].mcu_evt_hdlr((uint32_t)data); + } - return len; + return len; } -int cp_accel_open(enum CP_TASK_TYPE task_id, struct cp_task_desc const * p_task_desc) -{ - TRACE(4, "%s, task id = %d, cp_state = %d init %d", __func__, task_id, cp_task_env.p_desc[task_id].cp_accel_state, cp_accel_inited); +int cp_accel_open(enum CP_TASK_TYPE task_id, + struct cp_task_desc const *p_task_desc) { + TRACE(4, "%s, task id = %d, cp_state = %d init %d", __func__, task_id, + cp_task_env.p_desc[task_id].cp_accel_state, cp_accel_inited); - if ((task_id >= CP_TASK_MAX) || (p_task_desc == NULL)) { - TRACE(1, "%s task id error", __func__); - return -1; - } + if ((task_id >= CP_TASK_MAX) || (p_task_desc == NULL)) { + TRACE(1, "%s task id error", __func__); + return -1; + } - if (cp_task_env.p_desc[task_id].cp_accel_state != CP_ACCEL_STATE_CLOSED) { - TRACE(1, "%s cp_accel_state error", __func__); - return -1; - } + if (cp_task_env.p_desc[task_id].cp_accel_state != CP_ACCEL_STATE_CLOSED) { + TRACE(1, "%s cp_accel_state error", __func__); + return -1; + } - cp_task_env.p_desc[task_id].cp_accel_state = CP_ACCEL_STATE_OPENING; - cp_task_env.p_desc[task_id].cp_work_main = p_task_desc->cp_work_main; - cp_task_env.p_desc[task_id].cp_evt_hdlr = p_task_desc->cp_evt_hdlr; - cp_task_env.p_desc[task_id].mcu_evt_hdlr = p_task_desc->mcu_evt_hdlr; - cp_task_env.p_desc[task_id].mcu_sys_ctrl_hdlr = p_task_desc->mcu_sys_ctrl_hdlr; + cp_task_env.p_desc[task_id].cp_accel_state = CP_ACCEL_STATE_OPENING; + cp_task_env.p_desc[task_id].cp_work_main = p_task_desc->cp_work_main; + cp_task_env.p_desc[task_id].cp_evt_hdlr = p_task_desc->cp_evt_hdlr; + cp_task_env.p_desc[task_id].mcu_evt_hdlr = p_task_desc->mcu_evt_hdlr; + cp_task_env.p_desc[task_id].mcu_sys_ctrl_hdlr = + p_task_desc->mcu_sys_ctrl_hdlr; - if (false == cp_accel_inited) { - hal_trace_cp_register(cp_trace_crash_notify, cp_trace_buffer_ctrl); + if (false == cp_accel_inited) { + hal_trace_cp_register(cp_trace_crash_notify, cp_trace_buffer_ctrl); - hal_cmu_cp_enable(RAMCP_BASE + RAMCP_SIZE, (uint32_t)accel_main); + hal_cmu_cp_enable(RAMCP_BASE + RAMCP_SIZE, (uint32_t)accel_main); - hal_mcu2cp_open_mcu(HAL_MCU2CP_ID_0, HAL_MCU2CP_MSG_TYPE_0, cp2mcu_msg_arrived, mcu2cp_msg_sent, false); - hal_mcu2cp_open_mcu(HAL_MCU2CP_ID_1, HAL_MCU2CP_MSG_TYPE_0, cp2mcu_sys_arrived, NULL, false); + hal_mcu2cp_open_mcu(HAL_MCU2CP_ID_0, HAL_MCU2CP_MSG_TYPE_0, + cp2mcu_msg_arrived, mcu2cp_msg_sent, false); + hal_mcu2cp_open_mcu(HAL_MCU2CP_ID_1, HAL_MCU2CP_MSG_TYPE_0, + cp2mcu_sys_arrived, NULL, false); - hal_mcu2cp_start_recv_mcu(HAL_MCU2CP_ID_0); - hal_mcu2cp_start_recv_mcu(HAL_MCU2CP_ID_1); - } - cp_task_env.p_desc[task_id].cp_accel_state = CP_ACCEL_STATE_OPENED; + hal_mcu2cp_start_recv_mcu(HAL_MCU2CP_ID_0); + hal_mcu2cp_start_recv_mcu(HAL_MCU2CP_ID_1); + } + cp_task_env.p_desc[task_id].cp_accel_state = CP_ACCEL_STATE_OPENED; - return 0; + return 0; } -int cp_accel_close(enum CP_TASK_TYPE task_id) -{ - uint8_t i = 0; +int cp_accel_close(enum CP_TASK_TYPE task_id) { + uint8_t i = 0; - TRACE(4, "%s, task id = %d, cp_state = %d init %d", __func__, - task_id, cp_task_env.p_desc[task_id].cp_accel_state, cp_accel_inited); - LOCK_CP_PROCESS(); // avoid hangup + TRACE(4, "%s, task id = %d, cp_state = %d init %d", __func__, task_id, + cp_task_env.p_desc[task_id].cp_accel_state, cp_accel_inited); + LOCK_CP_PROCESS(); // avoid hangup - if (cp_task_env.p_desc[task_id].cp_accel_state == CP_ACCEL_STATE_CLOSED) { - goto accel_close_end; + if (cp_task_env.p_desc[task_id].cp_accel_state == CP_ACCEL_STATE_CLOSED) { + goto accel_close_end; + } + + cp_task_env.p_desc[task_id].cp_accel_state = CP_ACCEL_STATE_CLOSING; + cp_task_env.p_desc[task_id].cp_work_main = NULL; + cp_task_env.p_desc[task_id].cp_evt_hdlr = NULL; + cp_task_env.p_desc[task_id].mcu_evt_hdlr = NULL; + + for (i = 0; i < CP_TASK_MAX; i++) { + if (cp_task_env.p_desc[i].cp_accel_state == CP_ACCEL_STATE_OPENED || + cp_task_env.p_desc[i].cp_accel_state == CP_ACCEL_STATE_OPENING) { + goto accel_close_end; } + } - cp_task_env.p_desc[task_id].cp_accel_state = CP_ACCEL_STATE_CLOSING; - cp_task_env.p_desc[task_id].cp_work_main = NULL; - cp_task_env.p_desc[task_id].cp_evt_hdlr = NULL; - cp_task_env.p_desc[task_id].mcu_evt_hdlr = NULL; + if (cp_accel_inited) { + cp_accel_inited = false; - for (i=0; i MAX_CP_MSG_NUM)) { - TRACE(2, - "send_evt error, cp_accel_inited = %d, event pending count = %d", - cp_accel_inited, - cp_env.mcu2cp_tx_count); +int cp_accel_send_event_mcu2cp(uint8_t event) { + if ((false == cp_accel_inited) || (cp_env.mcu2cp_tx_count > MAX_CP_MSG_NUM)) { + TRACE(2, "send_evt error, cp_accel_inited = %d, event pending count = %d", + cp_accel_inited, cp_env.mcu2cp_tx_count); - TRACE(2, - "send evt task_id = %d, event = %d", - CP_TASK_ID_GET(event), - CP_EVENT_GET(event)); - return -1; + TRACE(2, "send evt task_id = %d, event = %d", CP_TASK_ID_GET(event), + CP_EVENT_GET(event)); + return -1; + } + + // TRACE(1, "current CP tx count:%d", cp_env.mcu2cp_tx_count); + if (cp_env.mcu2cp_tx_count > 0) { + cp_env.mcu2cp_tx_pending[cp_env.mcu2cp_tx_count - 1] = event; + cp_env.mcu2cp_tx_count++; + } else { + req_event = event; + cp_env.mcu2cp_tx_count = 1; + hal_mcu2cp_send_mcu(HAL_MCU2CP_ID_0, HAL_MCU2CP_MSG_TYPE_0, &req_event, 1); + } + + return 0; +} + +int CP_TEXT_SRAM_LOC cp_accel_send_event_cp2mcu(uint8_t event) { + return hal_mcu2cp_send_cp(HAL_MCU2CP_ID_0, HAL_MCU2CP_MSG_TYPE_0, + (unsigned char *)(uint32_t)event, 0); +} + +int SRAM_TEXT_LOC cp_accel_busy(enum CP_TASK_TYPE task_id) { + if (cp_task_env.p_desc[task_id].cp_accel_state != CP_ACCEL_STATE_CLOSED) { + if (cp_task_env.p_desc[task_id].cp_accel_state == CP_ACCEL_STATE_OPENED && + cp_in_sleep && !hal_mcu2cp_local_irq_pending_cp(HAL_MCU2CP_ID_0)) { + return false; } + return true; + } - // TRACE(1, "current CP tx count:%d", cp_env.mcu2cp_tx_count); - if (cp_env.mcu2cp_tx_count > 0) { - cp_env.mcu2cp_tx_pending[cp_env.mcu2cp_tx_count - 1] = event; - cp_env.mcu2cp_tx_count++; - } else { - req_event = event; - cp_env.mcu2cp_tx_count = 1; - hal_mcu2cp_send_mcu(HAL_MCU2CP_ID_0, HAL_MCU2CP_MSG_TYPE_0, &req_event, 1); - } - - return 0; -} - -int CP_TEXT_SRAM_LOC cp_accel_send_event_cp2mcu(uint8_t event) -{ - return hal_mcu2cp_send_cp(HAL_MCU2CP_ID_0, HAL_MCU2CP_MSG_TYPE_0, (unsigned char *)(uint32_t)event, 0); -} - -int SRAM_TEXT_LOC cp_accel_busy(enum CP_TASK_TYPE task_id) -{ - if (cp_task_env.p_desc[task_id].cp_accel_state != CP_ACCEL_STATE_CLOSED) { - if (cp_task_env.p_desc[task_id].cp_accel_state == CP_ACCEL_STATE_OPENED && cp_in_sleep && - !hal_mcu2cp_local_irq_pending_cp(HAL_MCU2CP_ID_0)) { - return false; - } - return true; - } - - return false; + return false; } #endif - diff --git a/services/cp_accel/cp_queue.c b/services/cp_accel/cp_queue.c index fab3260..4e9badd 100644 --- a/services/cp_accel/cp_queue.c +++ b/services/cp_accel/cp_queue.c @@ -15,123 +15,106 @@ * ****************************************************************************/ /*** -* cqueue.c - c circle queue c file -*/ + * cqueue.c - c circle queue c file + */ #include "cp_queue.h" -#include #include "cmsis.h" #include "hal_uart.h" +#include #include -int InitCpQueue(CQueue *Q, unsigned int size, CQItemType *buf) -{ - Q->size = size; - Q->base = buf; - Q->len = 0; - if (!Q->base) - return CQ_ERR; +int InitCpQueue(CQueue *Q, unsigned int size, CQItemType *buf) { + Q->size = size; + Q->base = buf; + Q->len = 0; + if (!Q->base) + return CQ_ERR; - Q->read = Q->write = 0; + Q->read = Q->write = 0; + return CQ_OK; +} + +int IsEmptyCpQueue(CQueue *Q) { + if (Q->len == 0) return CQ_OK; -} - -int IsEmptyCpQueue(CQueue *Q) -{ - if (Q->len == 0) - return CQ_OK; - else - return CQ_ERR; -} - -int LengthOfCpQueue(CQueue *Q) -{ - return Q->len; -} - -int AvailableOfCpQueue(CQueue *Q) -{ - return (Q->size - Q->len); -} - -int EnCpQueue(CQueue *Q, CQItemType *e, unsigned int len) -{ - if (AvailableOfCQueue(Q) < len) { - return CQ_ERR; - } - - Q->len += len; - - uint32_t bytesToTheEnd = Q->size - Q->write; - if (bytesToTheEnd > len) - { - memcpy((uint8_t *)&Q->base[Q->write], (uint8_t *)e, len); - Q->write += len; - } - else - { - memcpy((uint8_t *)&Q->base[Q->write], (uint8_t *)e, bytesToTheEnd); - memcpy((uint8_t *)&Q->base[0], (((uint8_t *)e)+bytesToTheEnd), len-bytesToTheEnd); - Q->write = len-bytesToTheEnd; - } - - return CQ_OK; -} - -int DeCpQueue(CQueue *Q, CQItemType *e, unsigned int len) -{ - if(LengthOfCQueue(Q) < len) - return CQ_ERR; - - Q->len -= len; - - if(e != NULL) { - - uint32_t bytesToTheEnd = Q->size - Q->read; - if (bytesToTheEnd > len) - { - memcpy((uint8_t *)e, (uint8_t *)&Q->base[Q->read], len); - Q->read += len; - } - else - { - memcpy((uint8_t *)e, (uint8_t *)&Q->base[Q->read], bytesToTheEnd); - memcpy((((uint8_t *)e)+bytesToTheEnd), (uint8_t *)&Q->base[0], len-bytesToTheEnd); - Q->read = len-bytesToTheEnd; - } - } - else { - Q->read = (Q->read+len)%Q->size; - } - - return CQ_OK; -} - -int PeekCpQueue(CQueue *Q, unsigned int len_want, CQItemType **e1, unsigned int *len1, CQItemType **e2, unsigned int *len2) -{ - if(LengthOfCQueue(Q) < len_want) { - return CQ_ERR; - } - - *e1 = &(Q->base[Q->read]); - if((Q->write > Q->read) || (Q->size - Q->read >= len_want)) { - *len1 = len_want; - *e2 = NULL; - *len2 = 0; - return CQ_OK; - } - else { - *len1 = Q->size - Q->read; - *e2 = &(Q->base[0]); - *len2 = len_want - *len1; - return CQ_OK; - } - + else return CQ_ERR; } -void ResetCpQueue(CQueue *Q) -{ - Q->len = 0; - Q->read = Q->write = 0; +int LengthOfCpQueue(CQueue *Q) { return Q->len; } + +int AvailableOfCpQueue(CQueue *Q) { return (Q->size - Q->len); } + +int EnCpQueue(CQueue *Q, CQItemType *e, unsigned int len) { + if (AvailableOfCQueue(Q) < len) { + return CQ_ERR; + } + + Q->len += len; + + uint32_t bytesToTheEnd = Q->size - Q->write; + if (bytesToTheEnd > len) { + memcpy((uint8_t *)&Q->base[Q->write], (uint8_t *)e, len); + Q->write += len; + } else { + memcpy((uint8_t *)&Q->base[Q->write], (uint8_t *)e, bytesToTheEnd); + memcpy((uint8_t *)&Q->base[0], (((uint8_t *)e) + bytesToTheEnd), + len - bytesToTheEnd); + Q->write = len - bytesToTheEnd; + } + + return CQ_OK; +} + +int DeCpQueue(CQueue *Q, CQItemType *e, unsigned int len) { + if (LengthOfCQueue(Q) < len) + return CQ_ERR; + + Q->len -= len; + + if (e != NULL) { + + uint32_t bytesToTheEnd = Q->size - Q->read; + if (bytesToTheEnd > len) { + memcpy((uint8_t *)e, (uint8_t *)&Q->base[Q->read], len); + Q->read += len; + } else { + memcpy((uint8_t *)e, (uint8_t *)&Q->base[Q->read], bytesToTheEnd); + memcpy((((uint8_t *)e) + bytesToTheEnd), (uint8_t *)&Q->base[0], + len - bytesToTheEnd); + Q->read = len - bytesToTheEnd; + } + } else { + Q->read = (Q->read + len) % Q->size; + } + + return CQ_OK; +} + +int PeekCpQueue(CQueue *Q, unsigned int len_want, CQItemType **e1, + unsigned int *len1, CQItemType **e2, unsigned int *len2) { + if (LengthOfCQueue(Q) < len_want) { + return CQ_ERR; + } + + *e1 = &(Q->base[Q->read]); + if ((Q->write > Q->read) || (Q->size - Q->read >= len_want)) { + *len1 = len_want; + *e2 = NULL; + *len2 = 0; + return CQ_OK; + } else { + *len1 = Q->size - Q->read; + *e2 = &(Q->base[0]); + *len2 = len_want - *len1; + return CQ_OK; + } + + return CQ_ERR; +} + +void ResetCpQueue(CQueue *Q) { + Q->len = 0; + Q->read = Q->write = 0; } \ No newline at end of file diff --git a/services/hw_dsp/src/hw_filter_codec_iir.c b/services/hw_dsp/src/hw_filter_codec_iir.c index a86154a..41988d0 100644 --- a/services/hw_dsp/src/hw_filter_codec_iir.c +++ b/services/hw_dsp/src/hw_filter_codec_iir.c @@ -6,120 +6,119 @@ ** modify: 2016.12.26 ** todo: 1. *******************************************************************************/ +#include "hw_filter_codec_iir.h" +#include "hal_cmu.h" +#include "hal_location.h" #include "hal_timer.h" #include "hal_trace.h" -#include "hal_cmu.h" -#include "string.h" -#include "hw_filter_codec_iir.h" -#include "stdbool.h" -#include "hal_location.h" #include "hw_codec_iir_process.h" +#include "stdbool.h" +#include "string.h" #include "tgt_hardware.h" #ifndef CODEC_OUTPUT_DEV -#define CODEC_OUTPUT_DEV CFG_HW_AUD_OUTPUT_PATH_SPEAKER_DEV +#define CODEC_OUTPUT_DEV CFG_HW_AUD_OUTPUT_PATH_SPEAKER_DEV #endif -struct hw_filter_codec_iir_state_ -{ - // public - /* Basic info */ - int32_t sample_rate; - // int32_t frame_size; - int32_t channel_num; - int32_t bits; +struct hw_filter_codec_iir_state_ { + // public + /* Basic info */ + int32_t sample_rate; + // int32_t frame_size; + int32_t channel_num; + int32_t bits; - /* configure info */ - int32_t bypass; - int32_t need_value; - HW_CODEC_IIR_TYPE_T iir_device; + /* configure info */ + int32_t bypass; + int32_t need_value; + HW_CODEC_IIR_TYPE_T iir_device; - // private - /* Parameters */ - int32_t iir_device_opened; + // private + /* Parameters */ + int32_t iir_device_opened; - /* DSP-related arrays */ - - /* Misc */ - // input and output buffer + /* DSP-related arrays */ + /* Misc */ + // input and output buffer }; // just support 1 st hw_filter_codec_iir_state iir_st; -hw_filter_codec_iir_state *hw_filter_codec_iir_create(int32_t sample_rate, int32_t channel_num, int32_t bits, hw_filter_codec_iir_cfg *cfg) -{ - hw_filter_codec_iir_state *st = &iir_st; +hw_filter_codec_iir_state * +hw_filter_codec_iir_create(int32_t sample_rate, int32_t channel_num, + int32_t bits, hw_filter_codec_iir_cfg *cfg) { + hw_filter_codec_iir_state *st = &iir_st; - TRACE(4,"[%s] sample_rate = %d, channel_num = %d, bits = %d", __func__, sample_rate, channel_num, bits); + TRACE(4, "[%s] sample_rate = %d, channel_num = %d, bits = %d", __func__, + sample_rate, channel_num, bits); - // Set parameters - st->sample_rate = sample_rate; - st->channel_num = channel_num; - st->bits = bits; + // Set parameters + st->sample_rate = sample_rate; + st->channel_num = channel_num; + st->bits = bits; - // Initialize internal variables - st->iir_device_opened = 0; - - // Malloc dynamic memory - - // Initialize dynamic memory + // Initialize internal variables + st->iir_device_opened = 0; - hw_filter_codec_iir_set_config(st, cfg); + // Malloc dynamic memory - return st; + // Initialize dynamic memory + + hw_filter_codec_iir_set_config(st, cfg); + + return st; } -int32_t hw_filter_codec_iir_destroy(hw_filter_codec_iir_state *st) -{ - if (st->iir_device_opened) - { - hw_codec_iir_close(st->iir_device); - } +int32_t hw_filter_codec_iir_destroy(hw_filter_codec_iir_state *st) { + if (st->iir_device_opened) { + hw_codec_iir_close(st->iir_device); + } - st->bypass = 0; - st->iir_device = HW_CODEC_IIR_NOTYPE; - st->iir_device_opened = 0; + st->bypass = 0; + st->iir_device = HW_CODEC_IIR_NOTYPE; + st->iir_device_opened = 0; - return 0; + return 0; } -int32_t hw_filter_codec_iir_set_config(hw_filter_codec_iir_state *st, hw_filter_codec_iir_cfg *cfg) -{ - st->bypass = cfg->bypass; - st->iir_device = cfg->iir_device; +int32_t hw_filter_codec_iir_set_config(hw_filter_codec_iir_state *st, + hw_filter_codec_iir_cfg *cfg) { + st->bypass = cfg->bypass; + st->iir_device = cfg->iir_device; - TRACE(2,"[%s] iir device = %d", __func__, st->iir_device); + TRACE(2, "[%s] iir device = %d", __func__, st->iir_device); - if (!st->iir_device_opened) - { - hw_codec_iir_open((enum AUD_SAMPRATE_T)st->sample_rate, st->iir_device,CODEC_OUTPUT_DEV); - } + if (!st->iir_device_opened) { + hw_codec_iir_open((enum AUD_SAMPRATE_T)st->sample_rate, st->iir_device, + CODEC_OUTPUT_DEV); + } #if 1 - hw_codec_iir_set_coefs(&cfg->iir_cfg, st->iir_device); + hw_codec_iir_set_coefs(&cfg->iir_cfg, st->iir_device); #else - HW_CODEC_IIR_CFG_T *hw_iir_cfg=NULL; + HW_CODEC_IIR_CFG_T *hw_iir_cfg = NULL; - hw_iir_cfg = hw_codec_iir_get_cfg((enum AUD_SAMPRATE_T)st->sample_rate, &cfg->iir_cfg); - ASSERT(hw_iir_cfg != NULL, "[%s] codec IIR parameter error!", __func__); - hal_codec_iir_dump(hw_iir_cfg); - hw_codec_iir_set_cfg(hw_iir_cfg, (enum AUD_SAMPRATE_T)st->sample_rate, st->iir_device); + hw_iir_cfg = + hw_codec_iir_get_cfg((enum AUD_SAMPRATE_T)st->sample_rate, &cfg->iir_cfg); + ASSERT(hw_iir_cfg != NULL, "[%s] codec IIR parameter error!", __func__); + hal_codec_iir_dump(hw_iir_cfg); + hw_codec_iir_set_cfg(hw_iir_cfg, (enum AUD_SAMPRATE_T)st->sample_rate, + st->iir_device); #endif - - - return 0; + return 0; } -// int32_t hw_filter_codec_iir_ctl(hw_filter_codec_iir_state *st, int32_t ctl, void *ptr) +// int32_t hw_filter_codec_iir_ctl(hw_filter_codec_iir_state *st, int32_t ctl, +// void *ptr) // { // switch(ctl) // { // case HW_FILTER_CODEC_IIR_SET_AAA: // st->aaa = (*(int32_t*)ptr); -// break; +// break; // case HW_FILTER_CODEC_IIR_GET_AAA: // (*(int32_t*)ptr) = (int32_t)st->aaa; @@ -130,16 +129,15 @@ int32_t hw_filter_codec_iir_set_config(hw_filter_codec_iir_state *st, hw_filter_ // return -1; // } -// return 0; +// return 0; // } -int32_t hw_filter_codec_iir_dump(hw_filter_codec_iir_state *st) -{ - TRACE(1,"[%s]: ", __func__); +int32_t hw_filter_codec_iir_dump(hw_filter_codec_iir_state *st) { + TRACE(1, "[%s]: ", __func__); - // Add dump info + // Add dump info - // End - - return 0; + // End + + return 0; } \ No newline at end of file diff --git a/services/ibrt_core/inc/app_tws_ibrt_cmd_sync_a2dp_status.h b/services/ibrt_core/inc/app_tws_ibrt_cmd_sync_a2dp_status.h index a8ed734..2f59334 100644 --- a/services/ibrt_core/inc/app_tws_ibrt_cmd_sync_a2dp_status.h +++ b/services/ibrt_core/inc/app_tws_ibrt_cmd_sync_a2dp_status.h @@ -15,14 +15,15 @@ ****************************************************************************/ #ifndef __APP_TWS_IBRT_CMD_SYNC_A2DP_STATUS_H__ #define __APP_TWS_IBRT_CMD_SYNC_A2DP_STATUS_H__ +#include "app_tws_ibrt.h" +#include -typedef struct -{ - ibrt_codec_t codec; - uint8_t volume; - btif_avdtp_stream_state_t state; - float latency_factor; - uint32_t session; +typedef struct { + ibrt_codec_t codec; + uint8_t volume; + btif_avdtp_stream_state_t state; + float latency_factor; + uint32_t session; } __attribute__((packed)) ibrt_a2dp_status_t; bool app_ibrt_sync_a2dp_status_onporcess(void); @@ -30,9 +31,13 @@ void app_ibrt_sync_a2dp_status_set(bool status); void app_ibrt_sync_a2dp_status(void); void app_ibrt_sync_a2dp_send_status(uint8_t *p_buff, uint16_t length); -void app_ibrt_sync_a2dp_send_status_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -void app_ibrt_sync_a2dp_send_status_rsp_timeout_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); -void app_ibrt_sync_a2dp_send_status_rsp_handler(uint16_t rsp_seq, uint8_t *p_buff, uint16_t length); - +void app_ibrt_sync_a2dp_send_status_handler(uint16_t rsp_seq, uint8_t *p_buff, + uint16_t length); +void app_ibrt_sync_a2dp_send_status_rsp_timeout_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); +void app_ibrt_sync_a2dp_send_status_rsp_handler(uint16_t rsp_seq, + uint8_t *p_buff, + uint16_t length); #endif diff --git a/services/interconnection/umm_malloc/umm_malloc.c b/services/interconnection/umm_malloc/umm_malloc.c index a11504a..46b191b 100644 --- a/services/interconnection/umm_malloc/umm_malloc.c +++ b/services/interconnection/umm_malloc/umm_malloc.c @@ -1,9 +1,9 @@ -#include -#include -#include "stdint.h" +#include "umm_malloc.h" #include "cmsis_os.h" #include "dbglog.h" -#include "umm_malloc.h" +#include "stdint.h" +#include +#include /* Use the default DBGLOG_LEVEL and DBGLOG_FUNCTION */ @@ -11,23 +11,22 @@ unsigned char umm_heap_array[UMM_MALLOC_CFG_HEAP_SIZE]; /* ------------------------------------------------------------------------- */ UMM_H_ATTPACKPRE typedef struct umm_ptr_t { - unsigned short int next; - unsigned short int prev; + unsigned short int next; + unsigned short int prev; } UMM_H_ATTPACKSUF umm_ptr; - UMM_H_ATTPACKPRE typedef struct umm_block_t { - union { - umm_ptr used; - } header; - union { - umm_ptr free; + union { + umm_ptr used; + } header; + union { + umm_ptr free; unsigned char data[4]; - } body; + } body; } UMM_H_ATTPACKSUF umm_block; #define UMM_FREELIST_MASK (0x8000) -#define UMM_BLOCKNO_MASK (0x7FFF) +#define UMM_BLOCKNO_MASK (0x7FFF) /* ------------------------------------------------------------------------- */ @@ -38,73 +37,71 @@ unsigned short int umm_numblocks = 0; /* ------------------------------------------------------------------------ */ -#define UMM_BLOCK(b) (umm_heap[b]) +#define UMM_BLOCK(b) (umm_heap[b]) #define UMM_NBLOCK(b) (UMM_BLOCK(b).header.used.next) #define UMM_PBLOCK(b) (UMM_BLOCK(b).header.used.prev) -#define UMM_NFREE(b) (UMM_BLOCK(b).body.free.next) -#define UMM_PFREE(b) (UMM_BLOCK(b).body.free.prev) -#define UMM_DATA(b) (UMM_BLOCK(b).body.data) +#define UMM_NFREE(b) (UMM_BLOCK(b).body.free.next) +#define UMM_PFREE(b) (UMM_BLOCK(b).body.free.prev) +#define UMM_DATA(b) (UMM_BLOCK(b).body.data) static osMutexId umm_clock_mutex_id = NULL; osMutexDef(umm_clock_mutex); /* ------------------------------------------------------------------------ */ -void LOCK_UMM_CLOCK(void) -{ - if(osMutexWait(umm_clock_mutex_id, osWaitForever) != osOK) - DBGLOG_INFO(1,"%s Error", __func__); +void LOCK_UMM_CLOCK(void) { + if (osMutexWait(umm_clock_mutex_id, osWaitForever) != osOK) + DBGLOG_INFO(1, "%s Error", __func__); } -void UNLOCK_UMM_CLOCK(void) -{ - if(osMutexRelease(umm_clock_mutex_id) != osOK) - DBGLOG_INFO(1,"%s Error", __func__); +void UNLOCK_UMM_CLOCK(void) { + if (osMutexRelease(umm_clock_mutex_id) != osOK) + DBGLOG_INFO(1, "%s Error", __func__); } /* ------------------------------------------------------------------------ */ -static void trace_umm_blocks_info( void ) { - unsigned short int blockSize = 0; - unsigned short int cf = 0; +static void trace_umm_blocks_info(void) { + unsigned short int blockSize = 0; + unsigned short int cf = 0; - cf = UMM_NFREE(0); - blockSize = blockSize; - DBGLOG_INFO(1, "fisrt free block %d", cf); + cf = UMM_NFREE(0); + blockSize = blockSize; + DBGLOG_INFO(1, "fisrt free block %d", cf); - while( cf ) { - blockSize = (UMM_NBLOCK(cf) & UMM_BLOCKNO_MASK) - cf; + while (cf) { + blockSize = (UMM_NBLOCK(cf) & UMM_BLOCKNO_MASK) - cf; - DBGLOG_INFO(2, "Looking at block %6i size %6i\n", cf, blockSize ); + DBGLOG_INFO(2, "Looking at block %6i size %6i\n", cf, blockSize); - cf = UMM_NFREE(cf); - } + cf = UMM_NFREE(cf); + } } /* ------------------------------------------------------------------------ */ -static unsigned short int umm_blocks( size_t size ) { +static unsigned short int umm_blocks(size_t size) { - /* - * The calculation of the block size is not too difficult, but there are - * a few little things that we need to be mindful of. - * - * When a block removed from the free list, the space used by the free - * pointers is available for data. That's what the first calculation - * of size is doing. - */ + /* + * The calculation of the block size is not too difficult, but there are + * a few little things that we need to be mindful of. + * + * When a block removed from the free list, the space used by the free + * pointers is available for data. That's what the first calculation + * of size is doing. + */ - if( size <= (sizeof(((umm_block *)0)->body)) ) - return( 1 ); + if (size <= (sizeof(((umm_block *)0)->body))) + return (1); - /* - * If it's for more than that, then we need to figure out the number of - * additional whole blocks the size of an umm_block are required. - */ + /* + * If it's for more than that, then we need to figure out the number of + * additional whole blocks the size of an umm_block are required. + */ - size -= ( 1 + (sizeof(((umm_block *)0)->body)) ); + size -= (1 + (sizeof(((umm_block *)0)->body))); - return( 2 + size/(sizeof(umm_block)) ); + return (2 + size / (sizeof(umm_block))); } /* ------------------------------------------------------------------------ */ @@ -116,28 +113,27 @@ static unsigned short int umm_blocks( size_t size ) { * * Note that free pointers are NOT modified by this function. */ -static void umm_split_block( unsigned short int c, - unsigned short int blocks, - unsigned short int new_freemask ) { +static void umm_split_block(unsigned short int c, unsigned short int blocks, + unsigned short int new_freemask) { - UMM_NBLOCK(c+blocks) = (UMM_NBLOCK(c) & UMM_BLOCKNO_MASK) | new_freemask; - UMM_PBLOCK(c+blocks) = c; + UMM_NBLOCK(c + blocks) = (UMM_NBLOCK(c) & UMM_BLOCKNO_MASK) | new_freemask; + UMM_PBLOCK(c + blocks) = c; - UMM_PBLOCK(UMM_NBLOCK(c) & UMM_BLOCKNO_MASK) = (c+blocks); - UMM_NBLOCK(c) = (c+blocks); + UMM_PBLOCK(UMM_NBLOCK(c) & UMM_BLOCKNO_MASK) = (c + blocks); + UMM_NBLOCK(c) = (c + blocks); } /* ------------------------------------------------------------------------ */ -static void umm_disconnect_from_free_list( unsigned short int c ) { - /* Disconnect this block from the FREE list */ +static void umm_disconnect_from_free_list(unsigned short int c) { + /* Disconnect this block from the FREE list */ - UMM_NFREE(UMM_PFREE(c)) = UMM_NFREE(c); - UMM_PFREE(UMM_NFREE(c)) = UMM_PFREE(c); + UMM_NFREE(UMM_PFREE(c)) = UMM_NFREE(c); + UMM_PFREE(UMM_NFREE(c)) = UMM_PFREE(c); - /* And clear the free block indicator */ + /* And clear the free block indicator */ - UMM_NBLOCK(c) &= (~UMM_FREELIST_MASK); + UMM_NBLOCK(c) &= (~UMM_FREELIST_MASK); } /* ------------------------------------------------------------------------ @@ -145,25 +141,26 @@ static void umm_disconnect_from_free_list( unsigned short int c ) { * have the UMM_FREELIST_MASK bit set! */ -static void umm_assimilate_up( unsigned short int c ) { +static void umm_assimilate_up(unsigned short int c) { - if( UMM_NBLOCK(UMM_NBLOCK(c)) & UMM_FREELIST_MASK ) { + if (UMM_NBLOCK(UMM_NBLOCK(c)) & UMM_FREELIST_MASK) { /* - * The next block is a free block, so assimilate up and remove it from - * the free list - */ + * The next block is a free block, so assimilate up and remove it from + * the free list + */ - DBGLOG_DEBUG(2, "%d Assimilate up to next block %d, which is FREE\n", c, UMM_NBLOCK(c)); + DBGLOG_DEBUG(2, "%d Assimilate up to next block %d, which is FREE\n", c, + UMM_NBLOCK(c)); - /* Disconnect the next block from the FREE list */ + /* Disconnect the next block from the FREE list */ - umm_disconnect_from_free_list( UMM_NBLOCK(c) ); + umm_disconnect_from_free_list(UMM_NBLOCK(c)); - /* Assimilate the next block with this one */ + /* Assimilate the next block with this one */ - UMM_PBLOCK(UMM_NBLOCK(UMM_NBLOCK(c)) & UMM_BLOCKNO_MASK) = c; - UMM_NBLOCK(c) = UMM_NBLOCK(UMM_NBLOCK(c)) & UMM_BLOCKNO_MASK; - } + UMM_PBLOCK(UMM_NBLOCK(UMM_NBLOCK(c)) & UMM_BLOCKNO_MASK) = c; + UMM_NBLOCK(c) = UMM_NBLOCK(UMM_NBLOCK(c)) & UMM_BLOCKNO_MASK; + } } /* ------------------------------------------------------------------------ @@ -171,289 +168,293 @@ static void umm_assimilate_up( unsigned short int c ) { * have the UMM_FREELIST_MASK bit set! */ -static unsigned short int umm_assimilate_down( unsigned short int c, unsigned short int freemask ) { +static unsigned short int umm_assimilate_down(unsigned short int c, + unsigned short int freemask) { - UMM_NBLOCK(UMM_PBLOCK(c)) = UMM_NBLOCK(c) | freemask; - UMM_PBLOCK(UMM_NBLOCK(c)) = UMM_PBLOCK(c); + UMM_NBLOCK(UMM_PBLOCK(c)) = UMM_NBLOCK(c) | freemask; + UMM_PBLOCK(UMM_NBLOCK(c)) = UMM_PBLOCK(c); - return( UMM_PBLOCK(c) ); + return (UMM_PBLOCK(c)); } /* ------------------------------------------------------------------------- */ -void umm_init( void ) { - /* init heap pointer and size, and memset it to 0 */ - umm_heap = (umm_block *)UMM_MALLOC_CFG_HEAP_ADDR; - umm_numblocks = (UMM_MALLOC_CFG_HEAP_SIZE / sizeof(umm_block)); - DBGLOG_DEBUG(3, "%s umm_heap %p blocks number %d", __func__, umm_heap, umm_numblocks); +void umm_init(void) { + /* init heap pointer and size, and memset it to 0 */ + umm_heap = (umm_block *)UMM_MALLOC_CFG_HEAP_ADDR; + umm_numblocks = (UMM_MALLOC_CFG_HEAP_SIZE / sizeof(umm_block)); + DBGLOG_DEBUG(3, "%s umm_heap %p blocks number %d", __func__, umm_heap, + umm_numblocks); - if (umm_clock_mutex_id == NULL) - { - umm_clock_mutex_id = osMutexCreate((osMutex(umm_clock_mutex))); - } + if (umm_clock_mutex_id == NULL) { + umm_clock_mutex_id = osMutexCreate((osMutex(umm_clock_mutex))); + } - memset(umm_heap, 0x00, UMM_MALLOC_CFG_HEAP_SIZE); + memset(umm_heap, 0x00, UMM_MALLOC_CFG_HEAP_SIZE); - /* setup initial blank heap structure */ - { - /* index of the 0th `umm_block` */ - const unsigned short int block_0th = 0; - /* index of the 1st `umm_block` */ - const unsigned short int block_1th = 1; - /* index of the latest `umm_block` */ - const unsigned short int block_last = UMM_NUMBLOCKS - 1; + /* setup initial blank heap structure */ + { + /* index of the 0th `umm_block` */ + const unsigned short int block_0th = 0; + /* index of the 1st `umm_block` */ + const unsigned short int block_1th = 1; + /* index of the latest `umm_block` */ + const unsigned short int block_last = UMM_NUMBLOCKS - 1; - /* setup the 0th `umm_block`, which just points to the 1st */ - UMM_NBLOCK(block_0th) = block_1th; - UMM_NFREE(block_0th) = block_1th; - UMM_PFREE(block_0th) = block_1th; + /* setup the 0th `umm_block`, which just points to the 1st */ + UMM_NBLOCK(block_0th) = block_1th; + UMM_NFREE(block_0th) = block_1th; + UMM_PFREE(block_0th) = block_1th; - /* - * Now, we need to set the whole heap space as a huge free block. We should - * not touch the 0th `umm_block`, since it's special: the 0th `umm_block` - * is the head of the free block list. It's a part of the heap invariant. - * - * See the detailed explanation at the beginning of the file. - */ + /* + * Now, we need to set the whole heap space as a huge free block. We should + * not touch the 0th `umm_block`, since it's special: the 0th `umm_block` + * is the head of the free block list. It's a part of the heap invariant. + * + * See the detailed explanation at the beginning of the file. + */ - /* - * 1th `umm_block` has pointers: - * - * - next `umm_block`: the latest one - * - prev `umm_block`: the 0th - * - * Plus, it's a free `umm_block`, so we need to apply `UMM_FREELIST_MASK` - * - * And it's the last free block, so the next free block is 0. - */ - UMM_NBLOCK(block_1th) = block_last | UMM_FREELIST_MASK; - UMM_NFREE(block_1th) = 0; - UMM_PBLOCK(block_1th) = block_0th; - UMM_PFREE(block_1th) = block_0th; + /* + * 1th `umm_block` has pointers: + * + * - next `umm_block`: the latest one + * - prev `umm_block`: the 0th + * + * Plus, it's a free `umm_block`, so we need to apply `UMM_FREELIST_MASK` + * + * And it's the last free block, so the next free block is 0. + */ + UMM_NBLOCK(block_1th) = block_last | UMM_FREELIST_MASK; + UMM_NFREE(block_1th) = 0; + UMM_PBLOCK(block_1th) = block_0th; + UMM_PFREE(block_1th) = block_0th; - /* - * latest `umm_block` has pointers: - * - * - next `umm_block`: 0 (meaning, there are no more `umm_blocks`) - * - prev `umm_block`: the 1st - * - * It's not a free block, so we don't touch NFREE / PFREE at all. - */ - UMM_NBLOCK(block_last) = 0; - UMM_PBLOCK(block_last) = block_1th; - } + /* + * latest `umm_block` has pointers: + * + * - next `umm_block`: 0 (meaning, there are no more `umm_blocks`) + * - prev `umm_block`: the 1st + * + * It's not a free block, so we don't touch NFREE / PFREE at all. + */ + UMM_NBLOCK(block_last) = 0; + UMM_PBLOCK(block_last) = block_1th; + } } /* ------------------------------------------------------------------------ */ -void umm_free( void *ptr ) { +void umm_free(void *ptr) { - unsigned short int c; + unsigned short int c; - /* If we're being asked to free a NULL pointer, well that's just silly! */ + /* If we're being asked to free a NULL pointer, well that's just silly! */ - if( (void *)0 == ptr ) { - DBGLOG_DEBUG(0, "free a null pointer -> do nothing\n" ); + if ((void *)0 == ptr) { + DBGLOG_DEBUG(0, "free a null pointer -> do nothing\n"); - return; - } + return; + } + /* + * FIXME: At some point it might be a good idea to add a check to make sure + * that the pointer we're being asked to free up is actually within + * the umm_heap! + * + * NOTE: See the new umm_info() function that you can use to see if a ptr is + * on the free list! + */ + + /* Protect the critical section... */ + UMM_CRITICAL_ENTRY(); + + /* Figure out which block we're in. Note the use of truncated division... */ + + c = (((char *)ptr) - (char *)(&(umm_heap[0]))) / sizeof(umm_block); + + DBGLOG_DEBUG(2, "Freeing block %6i %p\n", c, ptr); + + /* Now let's assimilate this block with the next one if possible. */ + + umm_assimilate_up(c); + + /* Then assimilate with the previous block if possible */ + + if (UMM_NBLOCK(UMM_PBLOCK(c)) & UMM_FREELIST_MASK) { + + DBGLOG_DEBUG(1, "Assimilate down to next block %d, which is FREE\n", + UMM_PBLOCK(c)); + + c = umm_assimilate_down(c, UMM_FREELIST_MASK); + } else { /* - * FIXME: At some point it might be a good idea to add a check to make sure - * that the pointer we're being asked to free up is actually within - * the umm_heap! - * - * NOTE: See the new umm_info() function that you can use to see if a ptr is - * on the free list! - */ + * The previous block is not a free block, so add this one to the head + * of the free list + */ - /* Protect the critical section... */ - UMM_CRITICAL_ENTRY(); + DBGLOG_DEBUG(0, "Just add to head of free list\n"); - /* Figure out which block we're in. Note the use of truncated division... */ + UMM_PFREE(UMM_NFREE(0)) = c; + UMM_NFREE(c) = UMM_NFREE(0); + UMM_PFREE(c) = 0; + UMM_NFREE(0) = c; - c = (((char *)ptr)-(char *)(&(umm_heap[0])))/sizeof(umm_block); + UMM_NBLOCK(c) |= UMM_FREELIST_MASK; + } - DBGLOG_DEBUG(2, "Freeing block %6i %p\n", c, ptr); - - /* Now let's assimilate this block with the next one if possible. */ - - umm_assimilate_up( c ); - - /* Then assimilate with the previous block if possible */ - - if( UMM_NBLOCK(UMM_PBLOCK(c)) & UMM_FREELIST_MASK ) { - - DBGLOG_DEBUG(1, "Assimilate down to next block %d, which is FREE\n", UMM_PBLOCK(c)); - - c = umm_assimilate_down(c, UMM_FREELIST_MASK); - } else { - /* - * The previous block is not a free block, so add this one to the head - * of the free list - */ - - DBGLOG_DEBUG(0, "Just add to head of free list\n" ); - - UMM_PFREE(UMM_NFREE(0)) = c; - UMM_NFREE(c) = UMM_NFREE(0); - UMM_PFREE(c) = 0; - UMM_NFREE(0) = c; - - UMM_NBLOCK(c) |= UMM_FREELIST_MASK; - } - - /* Release the critical section... */ - UMM_CRITICAL_EXIT(); + /* Release the critical section... */ + UMM_CRITICAL_EXIT(); } /* ------------------------------------------------------------------------ */ -void *umm_malloc( size_t size ) { - unsigned short int blocks; - unsigned short int blockSize = 0; +void *umm_malloc(size_t size) { + unsigned short int blocks; + unsigned short int blockSize = 0; - unsigned short int bestSize; - unsigned short int bestBlock; + unsigned short int bestSize; + unsigned short int bestBlock; - unsigned short int cf; + unsigned short int cf; - if (umm_heap == NULL) { - umm_init(); - } + if (umm_heap == NULL) { + umm_init(); + } - /* - * the very first thing we do is figure out if we're being asked to allocate - * a size of 0 - and if we are we'll simply return a null pointer. if not - * then reduce the size by 1 byte so that the subsequent calculations on - * the number of blocks to allocate are easier... - */ + /* + * the very first thing we do is figure out if we're being asked to allocate + * a size of 0 - and if we are we'll simply return a null pointer. if not + * then reduce the size by 1 byte so that the subsequent calculations on + * the number of blocks to allocate are easier... + */ - if( 0 == size ) { - DBGLOG_DEBUG(0, "malloc a block of 0 bytes -> do nothing\n" ); + if (0 == size) { + DBGLOG_DEBUG(0, "malloc a block of 0 bytes -> do nothing\n"); - return( (void *)NULL ); - } + return ((void *)NULL); + } - /* Protect the critical section... */ - UMM_CRITICAL_ENTRY(); + /* Protect the critical section... */ + UMM_CRITICAL_ENTRY(); - blocks = umm_blocks( size ); + blocks = umm_blocks(size); - /* - * Now we can scan through the free list until we find a space that's big - * enough to hold the number of blocks we need. - * - * This part may be customized to be a best-fit, worst-fit, or first-fit - * algorithm - */ + /* + * Now we can scan through the free list until we find a space that's big + * enough to hold the number of blocks we need. + * + * This part may be customized to be a best-fit, worst-fit, or first-fit + * algorithm + */ - cf = UMM_NFREE(0); + cf = UMM_NFREE(0); - bestBlock = UMM_NFREE(0); - bestSize = 0x7FFF; + bestBlock = UMM_NFREE(0); + bestSize = 0x7FFF; - while( cf ) { - blockSize = (UMM_NBLOCK(cf) & UMM_BLOCKNO_MASK) - cf; + while (cf) { + blockSize = (UMM_NBLOCK(cf) & UMM_BLOCKNO_MASK) - cf; - DBGLOG_DEBUG(2, "Looking at block %6i size %6i\n", cf, blockSize ); + DBGLOG_DEBUG(2, "Looking at block %6i size %6i\n", cf, blockSize); #if defined UMM_BEST_FIT - if( (blockSize >= blocks) && (blockSize < bestSize) ) { - bestBlock = cf; - bestSize = blockSize; - } + if ((blockSize >= blocks) && (blockSize < bestSize)) { + bestBlock = cf; + bestSize = blockSize; + } #elif defined UMM_FIRST_FIT - /* This is the first block that fits! */ - if( (blockSize >= blocks) ) - break; + /* This is the first block that fits! */ + if ((blockSize >= blocks)) + break; #else -# error "No UMM_*_FIT is defined - check umm_malloc_cfg.h" +#error "No UMM_*_FIT is defined - check umm_malloc_cfg.h" #endif - cf = UMM_NFREE(cf); - } + cf = UMM_NFREE(cf); + } - if( 0x7FFF != bestSize ) { - cf = bestBlock; - blockSize = bestSize; - } + if (0x7FFF != bestSize) { + cf = bestBlock; + blockSize = bestSize; + } - if( UMM_NBLOCK(cf) & UMM_BLOCKNO_MASK && blockSize >= blocks ) { - /* - * This is an existing block in the memory heap, we just need to split off - * what we need, unlink it from the free list and mark it as in use, and - * link the rest of the block back into the freelist as if it was a new - * block on the free list... - */ + if (UMM_NBLOCK(cf) & UMM_BLOCKNO_MASK && blockSize >= blocks) { + /* + * This is an existing block in the memory heap, we just need to split off + * what we need, unlink it from the free list and mark it as in use, and + * link the rest of the block back into the freelist as if it was a new + * block on the free list... + */ - if( blockSize == blocks ) { - /* It's an exact fit and we don't neet to split off a block. */ - DBGLOG_DEBUG(2, "Allocating %6i blocks starting at %6i - exact\n", blocks, cf ); + if (blockSize == blocks) { + /* It's an exact fit and we don't neet to split off a block. */ + DBGLOG_DEBUG(2, "Allocating %6i blocks starting at %6i - exact\n", blocks, + cf); - /* Disconnect this block from the FREE list */ + /* Disconnect this block from the FREE list */ - umm_disconnect_from_free_list( cf ); + umm_disconnect_from_free_list(cf); - } else { - /* It's not an exact fit and we need to split off a block. */ - DBGLOG_DEBUG(2, "Allocating %6i blocks starting at %6i - existing\n", blocks, cf ); - - /* - * split current free block `cf` into two blocks. The first one will be - * returned to user, so it's not free, and the second one will be free. - */ - umm_split_block( cf, blocks, UMM_FREELIST_MASK /*new block is free*/ ); - - /* - * `umm_split_block()` does not update the free pointers (it affects - * only free flags), but effectively we've just moved beginning of the - * free block from `cf` to `cf + blocks`. So we have to adjust pointers - * to and from adjacent free blocks. - */ - - /* previous free block */ - UMM_NFREE( UMM_PFREE(cf) ) = cf + blocks; - UMM_PFREE( cf + blocks ) = UMM_PFREE(cf); - - /* next free block */ - UMM_PFREE( UMM_NFREE(cf) ) = cf + blocks; - UMM_NFREE( cf + blocks ) = UMM_NFREE(cf); - } } else { - /* Out of memory */ + /* It's not an exact fit and we need to split off a block. */ + DBGLOG_DEBUG(2, "Allocating %6i blocks starting at %6i - existing\n", + blocks, cf); - DBGLOG_DEBUG(1, "Can't allocate %5i blocks\n", blocks ); - trace_umm_blocks_info(); + /* + * split current free block `cf` into two blocks. The first one will be + * returned to user, so it's not free, and the second one will be free. + */ + umm_split_block(cf, blocks, UMM_FREELIST_MASK /*new block is free*/); - /* Release the critical section... */ - UMM_CRITICAL_EXIT(); + /* + * `umm_split_block()` does not update the free pointers (it affects + * only free flags), but effectively we've just moved beginning of the + * free block from `cf` to `cf + blocks`. So we have to adjust pointers + * to and from adjacent free blocks. + */ - return( (void *)NULL ); + /* previous free block */ + UMM_NFREE(UMM_PFREE(cf)) = cf + blocks; + UMM_PFREE(cf + blocks) = UMM_PFREE(cf); + + /* next free block */ + UMM_PFREE(UMM_NFREE(cf)) = cf + blocks; + UMM_NFREE(cf + blocks) = UMM_NFREE(cf); } + } else { + /* Out of memory */ + + DBGLOG_DEBUG(1, "Can't allocate %5i blocks\n", blocks); + trace_umm_blocks_info(); /* Release the critical section... */ UMM_CRITICAL_EXIT(); - return( (void *)&UMM_DATA(cf) ); + return ((void *)NULL); + } + + /* Release the critical section... */ + UMM_CRITICAL_EXIT(); + + return ((void *)&UMM_DATA(cf)); } /* ------------------------------------------------------------------------ */ -void *umm_realloc( void *ptr, size_t size ) { +void *umm_realloc(void *ptr, size_t size) { - unsigned short int blocks; - unsigned short int blockSize; - unsigned short int prevBlockSize = 0; - unsigned short int nextBlockSize = 0; + unsigned short int blocks; + unsigned short int blockSize; + unsigned short int prevBlockSize = 0; + unsigned short int nextBlockSize = 0; - unsigned short int c; + unsigned short int c; - size_t curSize; + size_t curSize; - if (umm_heap == NULL) { - umm_init(); - } + if (umm_heap == NULL) { + umm_init(); + } /* * This code looks after the case of a NULL value for ptr. The ANSI C @@ -463,157 +464,167 @@ void *umm_realloc( void *ptr, size_t size ) { * standard is concerned. */ - if( ((void *)NULL == ptr) ) { - DBGLOG_DEBUG(0, "realloc the NULL pointer - call malloc()\n" ); + if (((void *)NULL == ptr)) { + DBGLOG_DEBUG(0, "realloc the NULL pointer - call malloc()\n"); - return( umm_malloc(size) ); - } + return (umm_malloc(size)); + } - /* - * Now we're sure that we have a non_NULL ptr, but we're not sure what - * we should do with it. If the size is 0, then the ANSI C standard says that - * we should operate the same as free. - */ + /* + * Now we're sure that we have a non_NULL ptr, but we're not sure what + * we should do with it. If the size is 0, then the ANSI C standard says that + * we should operate the same as free. + */ - if( 0 == size ) { - DBGLOG_DEBUG(0, "realloc to 0 size, just free the block\n" ); + if (0 == size) { + DBGLOG_DEBUG(0, "realloc to 0 size, just free the block\n"); - umm_free( ptr ); + umm_free(ptr); - return( (void *)NULL ); - } + return ((void *)NULL); + } - /* - * Otherwise we need to actually do a reallocation. A naiive approach - * would be to malloc() a new block of the correct size, copy the old data - * to the new block, and then free the old block. - * - * While this will work, we end up doing a lot of possibly unnecessary - * copying. So first, let's figure out how many blocks we'll need. - */ + /* + * Otherwise we need to actually do a reallocation. A naiive approach + * would be to malloc() a new block of the correct size, copy the old data + * to the new block, and then free the old block. + * + * While this will work, we end up doing a lot of possibly unnecessary + * copying. So first, let's figure out how many blocks we'll need. + */ - blocks = umm_blocks( size ); + blocks = umm_blocks(size); - /* Figure out which block we're in. Note the use of truncated division... */ + /* Figure out which block we're in. Note the use of truncated division... */ - c = (((char *)ptr)-(char *)(&(umm_heap[0])))/sizeof(umm_block); + c = (((char *)ptr) - (char *)(&(umm_heap[0]))) / sizeof(umm_block); - /* Figure out how big this block is ... the free bit is not set :-) */ + /* Figure out how big this block is ... the free bit is not set :-) */ - blockSize = (UMM_NBLOCK(c) - c); + blockSize = (UMM_NBLOCK(c) - c); - /* Figure out how many bytes are in this block */ + /* Figure out how many bytes are in this block */ - curSize = (blockSize*sizeof(umm_block))-(sizeof(((umm_block *)0)->header)); + curSize = + (blockSize * sizeof(umm_block)) - (sizeof(((umm_block *)0)->header)); - /* Protect the critical section... */ - UMM_CRITICAL_ENTRY(); + /* Protect the critical section... */ + UMM_CRITICAL_ENTRY(); - /* Now figure out if the previous and/or next blocks are free as well as - * their sizes - this will help us to minimize special code later when we - * decide if it's possible to use the adjacent blocks. - * - * We set prevBlockSize and nextBlockSize to non-zero values ONLY if they - * are free! - */ + /* Now figure out if the previous and/or next blocks are free as well as + * their sizes - this will help us to minimize special code later when we + * decide if it's possible to use the adjacent blocks. + * + * We set prevBlockSize and nextBlockSize to non-zero values ONLY if they + * are free! + */ - if ((UMM_NBLOCK(UMM_NBLOCK(c)) & UMM_FREELIST_MASK)) { - nextBlockSize = (UMM_NBLOCK(UMM_NBLOCK(c)) & UMM_BLOCKNO_MASK) - UMM_NBLOCK(c); - } + if ((UMM_NBLOCK(UMM_NBLOCK(c)) & UMM_FREELIST_MASK)) { + nextBlockSize = + (UMM_NBLOCK(UMM_NBLOCK(c)) & UMM_BLOCKNO_MASK) - UMM_NBLOCK(c); + } - if ((UMM_NBLOCK(UMM_PBLOCK(c)) & UMM_FREELIST_MASK)) { - prevBlockSize = (c - UMM_PBLOCK(c)); - } + if ((UMM_NBLOCK(UMM_PBLOCK(c)) & UMM_FREELIST_MASK)) { + prevBlockSize = (c - UMM_PBLOCK(c)); + } - DBGLOG_DEBUG(4, "realloc blocks %i blockSize %i nextBlockSize %i prevBlockSize %i\n", blocks, blockSize, nextBlockSize, prevBlockSize ); + DBGLOG_DEBUG( + 4, "realloc blocks %i blockSize %i nextBlockSize %i prevBlockSize %i\n", + blocks, blockSize, nextBlockSize, prevBlockSize); - /* - * Ok, now that we're here we know how many blocks we want and the current - * blockSize. The prevBlockSize and nextBlockSize are set and we can figure - * out the best strategy for the new allocation as follows: - * - * 1. If the new block is the same size or smaller than the current block do - * nothing. - * 2. If the next block is free and adding it to the current block gives us - * enough memory, assimilate the next block. - * 3. If the prev block is free and adding it to the current block gives us - * enough memory, remove the previous block from the free list, assimilate - * it, copy to the new block. - * 4. If the prev and next blocks are free and adding them to the current - * block gives us enough memory, assimilate the next block, remove the - * previous block from the free list, assimilate it, copy to the new block. - * 5. Otherwise try to allocate an entirely new block of memory. If the - * allocation works free the old block and return the new pointer. If - * the allocation fails, return NULL and leave the old block intact. - * - * All that's left to do is decide if the fit was exact or not. If the fit - * was not exact, then split the memory block so that we use only the requested - * number of blocks and add what's left to the free list. - */ + /* + * Ok, now that we're here we know how many blocks we want and the current + * blockSize. The prevBlockSize and nextBlockSize are set and we can figure + * out the best strategy for the new allocation as follows: + * + * 1. If the new block is the same size or smaller than the current block do + * nothing. + * 2. If the next block is free and adding it to the current block gives us + * enough memory, assimilate the next block. + * 3. If the prev block is free and adding it to the current block gives us + * enough memory, remove the previous block from the free list, assimilate + * it, copy to the new block. + * 4. If the prev and next blocks are free and adding them to the current + * block gives us enough memory, assimilate the next block, remove the + * previous block from the free list, assimilate it, copy to the new block. + * 5. Otherwise try to allocate an entirely new block of memory. If the + * allocation works free the old block and return the new pointer. If + * the allocation fails, return NULL and leave the old block intact. + * + * All that's left to do is decide if the fit was exact or not. If the fit + * was not exact, then split the memory block so that we use only the + * requested number of blocks and add what's left to the free list. + */ - if (blockSize >= blocks) { - DBGLOG_DEBUG(1, "realloc the same or smaller size block - %i, do nothing\n", blocks ); - /* This space intentionally left blank */ - } else if ((blockSize + nextBlockSize) >= blocks) { - DBGLOG_DEBUG(1, "realloc using next block - %i\n", blocks ); - umm_assimilate_up( c ); - blockSize += nextBlockSize; - } else if ((prevBlockSize + blockSize) >= blocks) { - DBGLOG_DEBUG(1, "realloc using prev block - %i\n", blocks ); - umm_disconnect_from_free_list( UMM_PBLOCK(c) ); - c = umm_assimilate_down(c, 0); - memmove( (void *)&UMM_DATA(c), ptr, curSize ); - ptr = (void *)&UMM_DATA(c); - blockSize += prevBlockSize; - } else if ((prevBlockSize + blockSize + nextBlockSize) >= blocks) { - DBGLOG_DEBUG(1, "realloc using prev and next block - %i\n", blocks ); - umm_assimilate_up( c ); - umm_disconnect_from_free_list( UMM_PBLOCK(c) ); - c = umm_assimilate_down(c, 0); - memmove( (void *)&UMM_DATA(c), ptr, curSize ); - ptr = (void *)&UMM_DATA(c); - blockSize += (prevBlockSize + nextBlockSize); + if (blockSize >= blocks) { + DBGLOG_DEBUG(1, "realloc the same or smaller size block - %i, do nothing\n", + blocks); + /* This space intentionally left blank */ + } else if ((blockSize + nextBlockSize) >= blocks) { + DBGLOG_DEBUG(1, "realloc using next block - %i\n", blocks); + umm_assimilate_up(c); + blockSize += nextBlockSize; + } else if ((prevBlockSize + blockSize) >= blocks) { + DBGLOG_DEBUG(1, "realloc using prev block - %i\n", blocks); + umm_disconnect_from_free_list(UMM_PBLOCK(c)); + c = umm_assimilate_down(c, 0); + memmove((void *)&UMM_DATA(c), ptr, curSize); + ptr = (void *)&UMM_DATA(c); + blockSize += prevBlockSize; + } else if ((prevBlockSize + blockSize + nextBlockSize) >= blocks) { + DBGLOG_DEBUG(1, "realloc using prev and next block - %i\n", blocks); + umm_assimilate_up(c); + umm_disconnect_from_free_list(UMM_PBLOCK(c)); + c = umm_assimilate_down(c, 0); + memmove((void *)&UMM_DATA(c), ptr, curSize); + ptr = (void *)&UMM_DATA(c); + blockSize += (prevBlockSize + nextBlockSize); + } else { + DBGLOG_DEBUG(1, "realloc a completely new block %i\n", blocks); + void *oldptr = ptr; + if ((ptr = umm_malloc(size))) { + DBGLOG_DEBUG(2, + "realloc %i to a bigger block %i, copy, and free the old\n", + blockSize, blocks); + memcpy(ptr, oldptr, curSize); + umm_free(oldptr); } else { - DBGLOG_DEBUG(1, "realloc a completely new block %i\n", blocks ); - void *oldptr = ptr; - if( (ptr = umm_malloc( size )) ) { - DBGLOG_DEBUG(2, "realloc %i to a bigger block %i, copy, and free the old\n", blockSize, blocks ); - memcpy( ptr, oldptr, curSize ); - umm_free( oldptr ); - } else { - DBGLOG_DEBUG(2, "realloc %i to a bigger block %i failed - return NULL and leave the old block!\n", blockSize, blocks ); - /* This space intentionally left blnk */ - } - blockSize = blocks; + DBGLOG_DEBUG(2, + "realloc %i to a bigger block %i failed - return NULL and " + "leave the old block!\n", + blockSize, blocks); + /* This space intentionally left blnk */ } + blockSize = blocks; + } - /* Now all we need to do is figure out if the block fit exactly or if we - * need to split and free ... - */ + /* Now all we need to do is figure out if the block fit exactly or if we + * need to split and free ... + */ - if (blockSize > blocks ) { - DBGLOG_DEBUG(2, "split and free %i blocks from %i\n", blocks, blockSize ); - umm_split_block( c, blocks, 0 ); - umm_free( (void *)&UMM_DATA(c+blocks) ); - } + if (blockSize > blocks) { + DBGLOG_DEBUG(2, "split and free %i blocks from %i\n", blocks, blockSize); + umm_split_block(c, blocks, 0); + umm_free((void *)&UMM_DATA(c + blocks)); + } - /* Release the critical section... */ - UMM_CRITICAL_EXIT(); + /* Release the critical section... */ + UMM_CRITICAL_EXIT(); - return( ptr ); + return (ptr); } /* ------------------------------------------------------------------------ */ -void *umm_calloc( size_t num, size_t item_size ) { - void *ret; +void *umm_calloc(size_t num, size_t item_size) { + void *ret; - ret = umm_malloc((size_t)(item_size * num)); + ret = umm_malloc((size_t)(item_size * num)); - if (ret) - memset(ret, 0x00, (size_t)(item_size * num)); + if (ret) + memset(ret, 0x00, (size_t)(item_size * num)); - return ret; - } + return ret; +} /* ------------------------------------------------------------------------ */ diff --git a/services/multimedia/audio/process/anc/cfg/anc_cfg.c b/services/multimedia/audio/process/anc/cfg/anc_cfg.c index 8f359bc..e457d99 100644 --- a/services/multimedia/audio/process/anc/cfg/anc_cfg.c +++ b/services/multimedia/audio/process/anc/cfg/anc_cfg.c @@ -13,32 +13,31 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" +#include "anc_process.h" #include "aud_section.h" #include "aud_section_inc.h" -#include "tgt_hardware.h" -#include "hal_trace.h" -#include "anc_process.h" #include "hal_location.h" -#include "hal_trace.h" #include "hal_sysfreq.h" +#include "hal_trace.h" +#include "plat_types.h" +#include "tgt_hardware.h" #ifdef USB_ANC_MC_EQ_TUNING -#include "string.h" -#include "hal_timer.h" +#include "analog.h" +#include "audioflinger.h" +#include "crc32.h" #include "hal_aud.h" #include "hal_cmu.h" +#include "hal_codec.h" #include "hal_dma.h" #include "hal_iomux.h" -#include "hal_codec.h" -#include "audioflinger.h" -#include "pmu.h" -#include "analog.h" #include "hal_norflash.h" -#include "stdint.h" -#include "crc32.h" -#include "hw_iir_process.h" +#include "hal_timer.h" #include "hw_codec_iir_process.h" +#include "hw_iir_process.h" +#include "pmu.h" +#include "stdint.h" +#include "string.h" #endif #ifdef AUDIO_ANC_FB_MC @@ -50,29 +49,28 @@ #error "Invalid ANC_COEF_LIST_NUM configuration" #endif #else -#define ANC_COEF_LIST_NUM (1) +#define ANC_COEF_LIST_NUM (1) #endif -extern const struct_anc_cfg * anc_coef_list_50p7k[ANC_COEF_LIST_NUM]; -extern const struct_anc_cfg * anc_coef_list_48k[ANC_COEF_LIST_NUM]; -extern const struct_anc_cfg * anc_coef_list_44p1k[ANC_COEF_LIST_NUM]; +extern const struct_anc_cfg *anc_coef_list_50p7k[ANC_COEF_LIST_NUM]; +extern const struct_anc_cfg *anc_coef_list_48k[ANC_COEF_LIST_NUM]; +extern const struct_anc_cfg *anc_coef_list_44p1k[ANC_COEF_LIST_NUM]; -const struct_anc_cfg * WEAK anc_coef_list_50p7k[ANC_COEF_LIST_NUM] = { }; -const struct_anc_cfg * WEAK anc_coef_list_48k[ANC_COEF_LIST_NUM] = { }; -const struct_anc_cfg * WEAK anc_coef_list_44p1k[ANC_COEF_LIST_NUM] = { }; +const struct_anc_cfg *WEAK anc_coef_list_50p7k[ANC_COEF_LIST_NUM] = {}; +const struct_anc_cfg *WEAK anc_coef_list_48k[ANC_COEF_LIST_NUM] = {}; +const struct_anc_cfg *WEAK anc_coef_list_44p1k[ANC_COEF_LIST_NUM] = {}; -static enum ANC_INDEX cur_coef_idx=ANC_INDEX_0; +static enum ANC_INDEX cur_coef_idx = ANC_INDEX_0; static enum AUD_SAMPRATE_T cur_coef_samprate; - #ifdef AUDIO_ANC_FB_MC -#define AUD_IIR_NUM (8) +#define AUD_IIR_NUM (8) typedef struct { - aud_item anc_cfg_mc_l; - aud_item anc_cfg_mc_r; - float mc_history_l[AUD_IIR_NUM][4]; - float mc_history_r[AUD_IIR_NUM][4]; + aud_item anc_cfg_mc_l; + aud_item anc_cfg_mc_r; + float mc_history_l[AUD_IIR_NUM][4]; + float mc_history_r[AUD_IIR_NUM][4]; } IIR_MC_CFG_T; static IIR_MC_CFG_T mc_iir_cfg; @@ -80,1089 +78,1065 @@ static IIR_MC_CFG_T mc_iir_cfg; #endif #ifndef CODEC_OUTPUT_DEV -#define CODEC_OUTPUT_DEV CFG_HW_AUD_OUTPUT_PATH_SPEAKER_DEV +#define CODEC_OUTPUT_DEV CFG_HW_AUD_OUTPUT_PATH_SPEAKER_DEV #endif -int anc_load_cfg(void) -{ - int res = 0; - const struct_anc_cfg **list; +int anc_load_cfg(void) { + int res = 0; + const struct_anc_cfg **list; - anc_set_ch_map(CODEC_OUTPUT_DEV); + anc_set_ch_map(CODEC_OUTPUT_DEV); #ifdef __AUDIO_RESAMPLE__ - res = anccfg_loadfrom_audsec(anc_coef_list_50p7k, anc_coef_list_48k, ANC_COEF_LIST_NUM); - list = anc_coef_list_50p7k; - TRACE(0,"50.7k!!!!"); + res = anccfg_loadfrom_audsec(anc_coef_list_50p7k, anc_coef_list_48k, + ANC_COEF_LIST_NUM); + list = anc_coef_list_50p7k; + TRACE(0, "50.7k!!!!"); - if(res) { - TRACE(2,"[%s] WARNING(%d): Can not load anc coefficient from audio section!!!", __func__, res); - } else { - TRACE(1,"[%s] Load anc coefficient from audio section.", __func__); + if (res) { + TRACE( + 2, + "[%s] WARNING(%d): Can not load anc coefficient from audio section!!!", + __func__, res); + } else { + TRACE(1, "[%s] Load anc coefficient from audio section.", __func__); #if (AUD_SECTION_STRUCT_VERSION == 1) - TRACE(5,"[%s] L: gain = %d, len = %d, dac = %d, adc = %d", __func__, list[0]->anc_cfg_ff_l.total_gain, list[0]->anc_cfg_ff_l.fir_len, list[0]->anc_cfg_ff_l.dac_gain_offset, list[0]->anc_cfg_ff_l.adc_gain_offset); - TRACE(5,"[%s] R: gain = %d, len = %d, dac = %d, adc = %d", __func__, list[0]->anc_cfg_ff_r.total_gain, list[0]->anc_cfg_ff_r.fir_len, list[0]->anc_cfg_ff_r.dac_gain_offset, list[0]->anc_cfg_ff_r.adc_gain_offset); -#elif (AUD_SECTION_STRUCT_VERSION == 2) - for(int i = 0; i < ANC_COEF_LIST_NUM; i++) { - TRACE(3,"appmode%d,FEEDFORWARD,L:gain %d,R:gain %d",i, list[i]->anc_cfg_ff_l.total_gain, list[i]->anc_cfg_ff_r.total_gain); - for(int j = 0; j anc_cfg_ff_l.iir_coef[j].coef_b[0], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[1], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[2], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[0], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[1], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[2]); - } + TRACE(5, "[%s] L: gain = %d, len = %d, dac = %d, adc = %d", __func__, + list[0]->anc_cfg_ff_l.total_gain, list[0]->anc_cfg_ff_l.fir_len, + list[0]->anc_cfg_ff_l.dac_gain_offset, + list[0]->anc_cfg_ff_l.adc_gain_offset); + TRACE(5, "[%s] R: gain = %d, len = %d, dac = %d, adc = %d", __func__, + list[0]->anc_cfg_ff_r.total_gain, list[0]->anc_cfg_ff_r.fir_len, + list[0]->anc_cfg_ff_r.dac_gain_offset, + list[0]->anc_cfg_ff_r.adc_gain_offset); +#elif (AUD_SECTION_STRUCT_VERSION == 2) + for (int i = 0; i < ANC_COEF_LIST_NUM; i++) { + TRACE(3, "appmode%d,FEEDFORWARD,L:gain %d,R:gain %d", i, + list[i]->anc_cfg_ff_l.total_gain, list[i]->anc_cfg_ff_r.total_gain); + for (int j = 0; j < AUD_IIR_NUM; j++) { + TRACE(7, + "appmode%d,iir coef ff 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, " + "0x%08x", + i, list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[0], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[1], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[2], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[0], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[1], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[2]); + } - TRACE(3,"appmode%d,FEEDBACK,L:gain %d,R:gain %d",i, list[i]->anc_cfg_fb_l.total_gain, list[i]->anc_cfg_fb_r.total_gain); - for(int j = 0; j anc_cfg_fb_l.iir_coef[j].coef_b[0], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[1], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[2], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[0], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[1], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[2]); - } - } -#elif (AUD_SECTION_STRUCT_VERSION == 3) - for(int i = 0; i < ANC_COEF_LIST_NUM; i++) { - TRACE(2,"appmode%d,FEEDFORWARD,L:gain %d",i, list[i]->anc_cfg_ff_l.total_gain); - for(int j = 0; j anc_cfg_ff_l.iir_coef[j].coef_b[0], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[1], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[2], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[0], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[1], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[2]); - } + TRACE(3, "appmode%d,FEEDBACK,L:gain %d,R:gain %d", i, + list[i]->anc_cfg_fb_l.total_gain, list[i]->anc_cfg_fb_r.total_gain); + for (int j = 0; j < AUD_IIR_NUM; j++) { + TRACE(7, + "appmode%d,iir coef fb 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, " + "0x%08x", + i, list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[0], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[1], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[2], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[0], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[1], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[2]); + } + } +#elif (AUD_SECTION_STRUCT_VERSION == 3) + for (int i = 0; i < ANC_COEF_LIST_NUM; i++) { + TRACE(2, "appmode%d,FEEDFORWARD,L:gain %d", i, + list[i]->anc_cfg_ff_l.total_gain); + for (int j = 0; j < AUD_IIR_NUM; j++) { + TRACE(7, + "appmode%d,iir coef ff 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, " + "0x%08x", + i, list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[0], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[1], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[2], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[0], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[1], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[2]); + } - TRACE(2,"appmode%d,FEEDBACK,L:gain %d",i, list[i]->anc_cfg_fb_l.total_gain); - for(int j = 0; j anc_cfg_fb_l.iir_coef[j].coef_b[0], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[1], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[2], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[0], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[1], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[2]); - } - } + TRACE(2, "appmode%d,FEEDBACK,L:gain %d", i, + list[i]->anc_cfg_fb_l.total_gain); + for (int j = 0; j < AUD_IIR_NUM; j++) { + TRACE(7, + "appmode%d,iir coef fb 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, " + "0x%08x", + i, list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[0], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[1], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[2], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[0], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[1], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[2]); + } + } #endif - } + } #else - res = anccfg_loadfrom_audsec(anc_coef_list_48k, anc_coef_list_44p1k, ANC_COEF_LIST_NUM); - list = anc_coef_list_44p1k; - TRACE(0,"44.1k!!!!"); + res = anccfg_loadfrom_audsec(anc_coef_list_48k, anc_coef_list_44p1k, + ANC_COEF_LIST_NUM); + list = anc_coef_list_44p1k; + TRACE(0, "44.1k!!!!"); - if(res) { - TRACE(2,"[%s] WARNING(%d): Can not load anc coefficient from audio section!!!", __func__, res); - } else { - TRACE(1,"[%s] Load anc coefficient from audio section.", __func__); + if (res) { + TRACE( + 2, + "[%s] WARNING(%d): Can not load anc coefficient from audio section!!!", + __func__, res); + } else { + TRACE(1, "[%s] Load anc coefficient from audio section.", __func__); #if (AUD_SECTION_STRUCT_VERSION == 1) - TRACE(5,"[%s] L: gain = %d, len = %d, dac = %d, adc = %d", __func__, list[0]->anc_cfg_ff_l.total_gain, list[0]->anc_cfg_ff_l.fir_len, list[0]->anc_cfg_ff_l.dac_gain_offset, list[0]->anc_cfg_ff_l.adc_gain_offset); - TRACE(5,"[%s] R: gain = %d, len = %d, dac = %d, adc = %d", __func__, list[0]->anc_cfg_ff_r.total_gain, list[0]->anc_cfg_ff_r.fir_len, list[0]->anc_cfg_ff_r.dac_gain_offset, list[0]->anc_cfg_ff_r.adc_gain_offset); -#elif (AUD_SECTION_STRUCT_VERSION == 2) - for(int i = 0; i < ANC_COEF_LIST_NUM; i++) { - TRACE(3,"appmode%d,FEEDFORWARD,L:gain %d,R:gain %d",i, list[i]->anc_cfg_ff_l.total_gain, list[i]->anc_cfg_ff_r.total_gain); - for(int j = 0; j anc_cfg_ff_l.iir_coef[j].coef_b[0], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[1], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[2], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[0], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[1], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[2]); - } + TRACE(5, "[%s] L: gain = %d, len = %d, dac = %d, adc = %d", __func__, + list[0]->anc_cfg_ff_l.total_gain, list[0]->anc_cfg_ff_l.fir_len, + list[0]->anc_cfg_ff_l.dac_gain_offset, + list[0]->anc_cfg_ff_l.adc_gain_offset); + TRACE(5, "[%s] R: gain = %d, len = %d, dac = %d, adc = %d", __func__, + list[0]->anc_cfg_ff_r.total_gain, list[0]->anc_cfg_ff_r.fir_len, + list[0]->anc_cfg_ff_r.dac_gain_offset, + list[0]->anc_cfg_ff_r.adc_gain_offset); +#elif (AUD_SECTION_STRUCT_VERSION == 2) + for (int i = 0; i < ANC_COEF_LIST_NUM; i++) { + TRACE(3, "appmode%d,FEEDFORWARD,L:gain %d,R:gain %d", i, + list[i]->anc_cfg_ff_l.total_gain, list[i]->anc_cfg_ff_r.total_gain); + for (int j = 0; j < AUD_IIR_NUM; j++) { + TRACE(7, + "appmode%d,iir coef ff 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, " + "0x%08x", + i, list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[0], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[1], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[2], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[0], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[1], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[2]); + } - TRACE(3,"appmode%d,FEEDBACK,L:gain %d,R:gain %d",i, list[i]->anc_cfg_fb_l.total_gain, list[i]->anc_cfg_fb_r.total_gain); - for(int j = 0; j anc_cfg_fb_l.iir_coef[j].coef_b[0], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[1], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[2], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[0], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[1], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[2]); - } - } -#elif (AUD_SECTION_STRUCT_VERSION == 3) - for(int i = 0; i < ANC_COEF_LIST_NUM; i++) { - TRACE(2,"appmode%d,FEEDFORWARD,L:gain %d",i, list[i]->anc_cfg_ff_l.total_gain); - for(int j = 0; j anc_cfg_ff_l.iir_coef[j].coef_b[0], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[1], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[2], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[0], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[1], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[2]); - } + TRACE(3, "appmode%d,FEEDBACK,L:gain %d,R:gain %d", i, + list[i]->anc_cfg_fb_l.total_gain, list[i]->anc_cfg_fb_r.total_gain); + for (int j = 0; j < AUD_IIR_NUM; j++) { + TRACE(7, + "appmode%d,iir coef fb 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, " + "0x%08x", + i, list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[0], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[1], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[2], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[0], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[1], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[2]); + } + } +#elif (AUD_SECTION_STRUCT_VERSION == 3) + for (int i = 0; i < ANC_COEF_LIST_NUM; i++) { + TRACE(2, "appmode%d,FEEDFORWARD,L:gain %d", i, + list[i]->anc_cfg_ff_l.total_gain); + for (int j = 0; j < AUD_IIR_NUM; j++) { + TRACE(7, + "appmode%d,iir coef ff 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, " + "0x%08x", + i, list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[0], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[1], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[2], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[0], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[1], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[2]); + } - TRACE(2,"appmode%d,FEEDBACK,L:gain %d",i, list[i]->anc_cfg_fb_l.total_gain); - for(int j = 0; j anc_cfg_fb_l.iir_coef[j].coef_b[0], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[1], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[2], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[0], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[1], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[2]); - } - } + TRACE(2, "appmode%d,FEEDBACK,L:gain %d", i, + list[i]->anc_cfg_fb_l.total_gain); + for (int j = 0; j < AUD_IIR_NUM; j++) { + TRACE(7, + "appmode%d,iir coef fb 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, " + "0x%08x", + i, list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[0], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[1], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[2], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[0], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[1], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[2]); + } + } #endif - } + } - res = anccfg_loadfrom_audsec(anc_coef_list_48k, anc_coef_list_44p1k, ANC_COEF_LIST_NUM); - list = anc_coef_list_48k; - TRACE(0,"48k!!!!"); + res = anccfg_loadfrom_audsec(anc_coef_list_48k, anc_coef_list_44p1k, + ANC_COEF_LIST_NUM); + list = anc_coef_list_48k; + TRACE(0, "48k!!!!"); - if(res) { - TRACE(2,"[%s] WARNING(%d): Can not load anc coefficient from audio section!!!", __func__, res); - } else { - TRACE(1,"[%s] Load anc coefficient from audio section.", __func__); + if (res) { + TRACE( + 2, + "[%s] WARNING(%d): Can not load anc coefficient from audio section!!!", + __func__, res); + } else { + TRACE(1, "[%s] Load anc coefficient from audio section.", __func__); #if (AUD_SECTION_STRUCT_VERSION == 1) - TRACE(5,"[%s] L: gain = %d, len = %d, dac = %d, adc = %d", __func__, list[0]->anc_cfg_ff_l.total_gain, list[0]->anc_cfg_ff_l.fir_len, list[0]->anc_cfg_ff_l.dac_gain_offset, list[0]->anc_cfg_ff_l.adc_gain_offset); - TRACE(5,"[%s] R: gain = %d, len = %d, dac = %d, adc = %d", __func__, list[0]->anc_cfg_ff_r.total_gain, list[0]->anc_cfg_ff_r.fir_len, list[0]->anc_cfg_ff_r.dac_gain_offset, list[0]->anc_cfg_ff_r.adc_gain_offset); -#elif (AUD_SECTION_STRUCT_VERSION == 2) - for(int i = 0; i < ANC_COEF_LIST_NUM; i++) { - TRACE(3,"appmode%d,FEEDFORWARD,L:gain %d,R:gain %d",i, list[i]->anc_cfg_ff_l.total_gain, list[i]->anc_cfg_ff_r.total_gain); - for(int j = 0; j anc_cfg_ff_l.iir_coef[j].coef_b[0], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[1], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[2], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[0], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[1], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[2]); - } + TRACE(5, "[%s] L: gain = %d, len = %d, dac = %d, adc = %d", __func__, + list[0]->anc_cfg_ff_l.total_gain, list[0]->anc_cfg_ff_l.fir_len, + list[0]->anc_cfg_ff_l.dac_gain_offset, + list[0]->anc_cfg_ff_l.adc_gain_offset); + TRACE(5, "[%s] R: gain = %d, len = %d, dac = %d, adc = %d", __func__, + list[0]->anc_cfg_ff_r.total_gain, list[0]->anc_cfg_ff_r.fir_len, + list[0]->anc_cfg_ff_r.dac_gain_offset, + list[0]->anc_cfg_ff_r.adc_gain_offset); +#elif (AUD_SECTION_STRUCT_VERSION == 2) + for (int i = 0; i < ANC_COEF_LIST_NUM; i++) { + TRACE(3, "appmode%d,FEEDFORWARD,L:gain %d,R:gain %d", i, + list[i]->anc_cfg_ff_l.total_gain, list[i]->anc_cfg_ff_r.total_gain); + for (int j = 0; j < AUD_IIR_NUM; j++) { + TRACE(7, + "appmode%d,iir coef ff 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, " + "0x%08x", + i, list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[0], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[1], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[2], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[0], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[1], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[2]); + } - TRACE(3,"appmode%d,FEEDBACK,L:gain %d,R:gain %d",i, list[i]->anc_cfg_fb_l.total_gain, list[i]->anc_cfg_fb_r.total_gain); - for(int j = 0; j anc_cfg_fb_l.iir_coef[j].coef_b[0], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[1], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[2], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[0], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[1], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[2]); - } - } -#elif (AUD_SECTION_STRUCT_VERSION == 3) - for(int i = 0; i < ANC_COEF_LIST_NUM; i++) { - TRACE(2,"appmode%d,FEEDFORWARD,L:gain %d",i, list[i]->anc_cfg_ff_l.total_gain); - for(int j = 0; j anc_cfg_ff_l.iir_coef[j].coef_b[0], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[1], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[2], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[0], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[1], \ - list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[2]); - } + TRACE(3, "appmode%d,FEEDBACK,L:gain %d,R:gain %d", i, + list[i]->anc_cfg_fb_l.total_gain, list[i]->anc_cfg_fb_r.total_gain); + for (int j = 0; j < AUD_IIR_NUM; j++) { + TRACE(7, + "appmode%d,iir coef fb 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, " + "0x%08x", + i, list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[0], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[1], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[2], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[0], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[1], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[2]); + } + } +#elif (AUD_SECTION_STRUCT_VERSION == 3) + for (int i = 0; i < ANC_COEF_LIST_NUM; i++) { + TRACE(2, "appmode%d,FEEDFORWARD,L:gain %d", i, + list[i]->anc_cfg_ff_l.total_gain); + for (int j = 0; j < AUD_IIR_NUM; j++) { + TRACE(7, + "appmode%d,iir coef ff 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, " + "0x%08x", + i, list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[0], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[1], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_b[2], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[0], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[1], + list[i]->anc_cfg_ff_l.iir_coef[j].coef_a[2]); + } - TRACE(2,"appmode%d,FEEDBACK,L:gain %d",i, list[i]->anc_cfg_fb_l.total_gain); - for(int j = 0; j anc_cfg_fb_l.iir_coef[j].coef_b[0], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[1], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[2], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[0], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[1], \ - list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[2]); - } - } + TRACE(2, "appmode%d,FEEDBACK,L:gain %d", i, + list[i]->anc_cfg_fb_l.total_gain); + for (int j = 0; j < AUD_IIR_NUM; j++) { + TRACE(7, + "appmode%d,iir coef fb 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x, " + "0x%08x", + i, list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[0], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[1], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_b[2], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[0], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[1], + list[i]->anc_cfg_fb_l.iir_coef[j].coef_a[2]); + } + } #endif - } + } #endif - return res; + return res; } +int anc_select_coef(enum AUD_SAMPRATE_T rate, enum ANC_INDEX index, + enum ANC_TYPE_T anc_type, ANC_GAIN_TIME anc_gain_delay) { + const struct_anc_cfg **list = NULL; - -int anc_select_coef(enum AUD_SAMPRATE_T rate,enum ANC_INDEX index,enum ANC_TYPE_T anc_type,ANC_GAIN_TIME anc_gain_delay) -{ - const struct_anc_cfg **list=NULL; - - if (index >= ANC_COEF_LIST_NUM) { - return 1; - } + if (index >= ANC_COEF_LIST_NUM) { + return 1; + } #ifdef CHIP_BEST1000 - switch(rate) - { - case AUD_SAMPRATE_96000: - list=anc_coef_list_48k; - break; + switch (rate) { + case AUD_SAMPRATE_96000: + list = anc_coef_list_48k; + break; - case AUD_SAMPRATE_88200: - list=anc_coef_list_44p1k; - break; + case AUD_SAMPRATE_88200: + list = anc_coef_list_44p1k; + break; - default: - break; - } + default: + break; + } #else - switch(rate) - { - case AUD_SAMPRATE_48000: - list=anc_coef_list_48k; - break; + switch (rate) { + case AUD_SAMPRATE_48000: + list = anc_coef_list_48k; + break; - case AUD_SAMPRATE_44100: - list=anc_coef_list_44p1k; - break; + case AUD_SAMPRATE_44100: + list = anc_coef_list_44p1k; + break; #ifdef __AUDIO_RESAMPLE__ - case AUD_SAMPRATE_50781: - list=anc_coef_list_50p7k; - break; + case AUD_SAMPRATE_50781: + list = anc_coef_list_50p7k; + break; #endif - default: - break; - } + default: + break; + } #endif - ASSERT(list!=NULL&&list[index]!=NULL,"The coefs of Samprate %d is NULL", rate); + ASSERT(list != NULL && list[index] != NULL, + "The coefs of Samprate %d is NULL", rate); - if(anc_opened(anc_type)) - { - hal_sysfreq_req(HAL_SYSFREQ_USER_ANC,HAL_CMU_FREQ_52M); - anc_set_cfg(list[index],anc_type,anc_gain_delay); - hal_sysfreq_req(HAL_SYSFREQ_USER_ANC,HAL_CMU_FREQ_32K); + if (anc_opened(anc_type)) { + hal_sysfreq_req(HAL_SYSFREQ_USER_ANC, HAL_CMU_FREQ_52M); + anc_set_cfg(list[index], anc_type, anc_gain_delay); + hal_sysfreq_req(HAL_SYSFREQ_USER_ANC, HAL_CMU_FREQ_32K); #ifdef AUDIO_ANC_FB_MC - mc_iir_cfg.anc_cfg_mc_l=(*list[index]).anc_cfg_mc_l; - mc_iir_cfg.anc_cfg_mc_r=(*list[index]).anc_cfg_mc_r; + mc_iir_cfg.anc_cfg_mc_l = (*list[index]).anc_cfg_mc_l; + mc_iir_cfg.anc_cfg_mc_r = (*list[index]).anc_cfg_mc_r; #endif - } + } - cur_coef_idx = index; - cur_coef_samprate=rate; + cur_coef_idx = index; + cur_coef_samprate = rate; - return 0; + return 0; } -enum ANC_INDEX anc_get_current_coef_index(void) -{ - return cur_coef_idx; -} +enum ANC_INDEX anc_get_current_coef_index(void) { return cur_coef_idx; } -enum AUD_SAMPRATE_T anc_get_current_coef_samplerate(void) -{ - return cur_coef_samprate; +enum AUD_SAMPRATE_T anc_get_current_coef_samplerate(void) { + return cur_coef_samprate; } #ifdef AUDIO_ANC_FB_MC -void anc_mc_run_init(enum AUD_SAMPRATE_T rate) -{ - const struct_anc_cfg **list=NULL; +void anc_mc_run_init(enum AUD_SAMPRATE_T rate) { + const struct_anc_cfg **list = NULL; - switch(rate) - { - case AUD_SAMPRATE_48000: - list=anc_coef_list_48k; - break; + switch (rate) { + case AUD_SAMPRATE_48000: + list = anc_coef_list_48k; + break; - case AUD_SAMPRATE_44100: - list=anc_coef_list_44p1k; - break; + case AUD_SAMPRATE_44100: + list = anc_coef_list_44p1k; + break; #ifdef __AUDIO_RESAMPLE__ - case AUD_SAMPRATE_50781: - list=anc_coef_list_50p7k; - break; + case AUD_SAMPRATE_50781: + list = anc_coef_list_50p7k; + break; #endif - default: - break; + default: + break; + } + + ASSERT(list != NULL && list[cur_coef_idx] != NULL, + "The coefs of Samprate %d is NULL", rate); + + mc_iir_cfg.anc_cfg_mc_l = (*list[cur_coef_idx]).anc_cfg_mc_l; + mc_iir_cfg.anc_cfg_mc_r = (*list[cur_coef_idx]).anc_cfg_mc_r; + + for (int j = 0; j < AUD_IIR_NUM; j++) { + for (int i = 0; i < 4; i++) { + mc_iir_cfg.mc_history_l[j][i] = 0.0f; + mc_iir_cfg.mc_history_r[j][i] = 0.0f; } - - ASSERT(list!=NULL&&list[cur_coef_idx]!=NULL,"The coefs of Samprate %d is NULL", rate); - - mc_iir_cfg.anc_cfg_mc_l=(*list[cur_coef_idx]).anc_cfg_mc_l; - mc_iir_cfg.anc_cfg_mc_r=(*list[cur_coef_idx]).anc_cfg_mc_r; - - for(int j=0;j>2; + len_mono = len >> 2; - gain_l = (mc_iir_cfg.anc_cfg_mc_l.total_gain/512.0f)*left_gain; + gain_l = (mc_iir_cfg.anc_cfg_mc_l.total_gain / 512.0f) * left_gain; - if(mc_iir_cfg.anc_cfg_mc_l.iir_counter==0||mc_iir_cfg.anc_cfg_mc_l.iir_bypass_flag) - { - iir_buf = (int16_t *)buf; + if (mc_iir_cfg.anc_cfg_mc_l.iir_counter == 0 || + mc_iir_cfg.anc_cfg_mc_l.iir_bypass_flag) { + iir_buf = (int16_t *)buf; - for(int j=0; j>3; - - gain_l = (mc_iir_cfg.anc_cfg_mc_l.total_gain/512.0f)*left_gain; - - if(mc_iir_cfg.anc_cfg_mc_l.iir_counter==0||mc_iir_cfg.anc_cfg_mc_l.iir_bypass_flag) - { - iir_buf = (int32_t *)buf; - for(int j=0; j> 3; + + gain_l = (mc_iir_cfg.anc_cfg_mc_l.total_gain / 512.0f) * left_gain; + + if (mc_iir_cfg.anc_cfg_mc_l.iir_counter == 0 || + mc_iir_cfg.anc_cfg_mc_l.iir_bypass_flag) { + iir_buf = (int32_t *)buf; + for (int j = 0; j < len_mono; j++) { + x0 = *iir_buf * gain_l; + *iir_buf++ = iir_ssat_24bits(x0); + iir_buf++; + } + } else { + for (int i = 0; i < mc_iir_cfg.anc_cfg_mc_l.iir_counter; i++) { + // Coef + coefs = mc_iir_cfg.anc_cfg_mc_l.iir_coef[i].coef_a; + a0 = *coefs++; + a1 = *coefs++; + a2 = *coefs; + coefs = mc_iir_cfg.anc_cfg_mc_l.iir_coef[i].coef_b; + b0 = *coefs++; + b1 = *coefs++; + b2 = *coefs; + + a1 = a1 / a0; + a2 = a2 / a0; + b0 = b0 / a0; + b1 = b1 / a0; + b2 = b2 / a0; + + // TRACE(7,"[%d] %f, %f, %f, %f, %f, %f", i, a0, a1, a2, b0, b1, b2); + + // Left + history = mc_iir_cfg.mc_history_l[i]; + x1 = *history++; + x2 = *history++; + y1 = *history++; + y2 = *history; + + iir_buf = (int32_t *)buf; + if (i == 0) { + for (int j = 0; j < len_mono; j++) { + // Left channel + x0 = *iir_buf * gain_l; + y0 = x0 * b0 + x1 * b1 + x2 * b2 - y1 * a1 - y2 * a2; + y2 = y1; + y1 = y0; + x2 = x1; + x1 = x0; + *iir_buf++ = iir_ssat_24bits(y0); + iir_buf++; + } + } else { + for (int j = 0; j < len_mono; j++) { + // Left channel + x0 = *iir_buf; + y0 = x0 * b0 + x1 * b1 + x2 * b2 - y1 * a1 - y2 * a2; + y2 = y1; + y1 = y0; + x2 = x1; + x1 = x0; + *iir_buf++ = iir_ssat_24bits(y0); + iir_buf++; + } + } + // Left + history = mc_iir_cfg.mc_history_l[i]; + *history++ = x1; + *history++ = x2; + *history++ = y1; + *history = y2; + } + } + + gain_r = (mc_iir_cfg.anc_cfg_mc_r.total_gain / 512.0f) * right_gain; + if (mc_iir_cfg.anc_cfg_mc_r.iir_counter == 0 || + mc_iir_cfg.anc_cfg_mc_r.iir_bypass_flag) { + iir_buf = (int32_t *)buf; + iir_buf++; + for (int j = 0; j < len_mono; j++) { + x0 = *iir_buf * gain_r; + *iir_buf++ = iir_ssat_24bits(x0); + iir_buf++; + } + + } else { + for (int i = 0; i < mc_iir_cfg.anc_cfg_mc_r.iir_counter; i++) { + // Coef + coefs = mc_iir_cfg.anc_cfg_mc_r.iir_coef[i].coef_a; + a0 = *coefs++; + a1 = *coefs++; + a2 = *coefs; + coefs = mc_iir_cfg.anc_cfg_mc_r.iir_coef[i].coef_b; + b0 = *coefs++; + b1 = *coefs++; + b2 = *coefs; + + a1 = a1 / a0; + a2 = a2 / a0; + b0 = b0 / a0; + b1 = b1 / a0; + b2 = b2 / a0; + + // TRACE(7,"[%d] %f, %f, %f, %f, %f, %f", i, a0, a1, a2, b0, b1, b2); + + // right + history = mc_iir_cfg.mc_history_r[i]; + x1 = *history++; + x2 = *history++; + y1 = *history++; + y2 = *history; + + iir_buf = (int32_t *)buf; + iir_buf++; + if (i == 0) { + for (int j = 0; j < len_mono; j++) { + // right channel + x0 = *iir_buf * gain_r; + y0 = x0 * b0 + x1 * b1 + x2 * b2 - y1 * a1 - y2 * a2; + y2 = y1; + y1 = y0; + x2 = x1; + x1 = x0; + *iir_buf++ = iir_ssat_24bits(y0); + iir_buf++; + } + } else { + for (int j = 0; j < len_mono; j++) { + // right channel + x0 = *iir_buf; + y0 = x0 * b0 + x1 * b1 + x2 * b2 - y1 * a1 - y2 * a2; + y2 = y1; + y1 = y0; + x2 = x1; + x1 = x0; + *iir_buf++ = iir_ssat_24bits(y0); + iir_buf++; + } + } + // right + history = mc_iir_cfg.mc_history_r[i]; + *history++ = x1; + *history++ = x2; + *history++ = y1; + *history = y2; + } + } + + } else { + ASSERT(false, "Can't support sample bit mode:%d", sample_bit); + } + + return 0; } -SRAM_TEXT_LOC int anc_mc_run_mono(uint8_t *buf, int len,float left_gain,enum AUD_BITS_T sample_bit) -{ - int len_mono; - int num; - float gain_l = 0; - int32_t *coefs = NULL; - float *history = NULL; +SRAM_TEXT_LOC int anc_mc_run_mono(uint8_t *buf, int len, float left_gain, + enum AUD_BITS_T sample_bit) { + int len_mono; + int num; + float gain_l = 0; + int32_t *coefs = NULL; + float *history = NULL; - // Left - float x0, x1, x2; - float y0, y1, y2; + // Left + float x0, x1, x2; + float y0, y1, y2; - // Coefs - float POSSIBLY_UNUSED a0, a1, a2; - float b0, b1, b2; + // Coefs + float POSSIBLY_UNUSED a0, a1, a2; + float b0, b1, b2; - if(sample_bit==AUD_BITS_16) - { - int16_t *iir_buf; + if (sample_bit == AUD_BITS_16) { + int16_t *iir_buf; - len_mono = len>>1; + len_mono = len >> 1; - gain_l = (mc_iir_cfg.anc_cfg_mc_l.total_gain/512.0f)*left_gain; - num = mc_iir_cfg.anc_cfg_mc_l.iir_counter; + gain_l = (mc_iir_cfg.anc_cfg_mc_l.total_gain / 512.0f) * left_gain; + num = mc_iir_cfg.anc_cfg_mc_l.iir_counter; - if(num==0||mc_iir_cfg.anc_cfg_mc_l.iir_bypass_flag) - { - iir_buf = (int16_t *)buf; + if (num == 0 || mc_iir_cfg.anc_cfg_mc_l.iir_bypass_flag) { + iir_buf = (int16_t *)buf; - for(int j=0; j>2; - - gain_l = (mc_iir_cfg.anc_cfg_mc_l.total_gain/512.0f)*left_gain; - num = mc_iir_cfg.anc_cfg_mc_l.iir_counter; - - if(num==0) - { - iir_buf = (int32_t *)buf; - - for(int j=0; j> 2; + + gain_l = (mc_iir_cfg.anc_cfg_mc_l.total_gain / 512.0f) * left_gain; + num = mc_iir_cfg.anc_cfg_mc_l.iir_counter; + + if (num == 0) { + iir_buf = (int32_t *)buf; + + for (int j = 0; j < len_mono; j++) { + x0 = *iir_buf * gain_l; + *iir_buf++ = iir_ssat_24bits(x0); + } + + return 0; + } + + for (int i = 0; i < num; i++) { + // Coef + coefs = mc_iir_cfg.anc_cfg_mc_l.iir_coef[i].coef_a; + a0 = *coefs++; + a1 = *coefs++; + a2 = *coefs; + coefs = mc_iir_cfg.anc_cfg_mc_l.iir_coef[i].coef_b; + b0 = *coefs++; + b1 = *coefs++; + b2 = *coefs; + + a1 = a1 / a0; + a2 = a2 / a0; + b0 = b0 / a0; + b1 = b1 / a0; + b2 = b2 / a0; + + // TRACE(7,"[%d] %f, %f, %f, %f, %f, %f", i, a0, a1, a2, b0, b1, + // b2); + + // Left + history = mc_iir_cfg.mc_history_l[i]; + x1 = *history++; + x2 = *history++; + y1 = *history++; + y2 = *history; + + iir_buf = (int32_t *)buf; + if (i == 0) { + for (int j = 0; j < len_mono; j++) { + // Left channel + x0 = *iir_buf * gain_l; + y0 = x0 * b0 + x1 * b1 + x2 * b2 - y1 * a1 - y2 * a2; + y2 = y1; + y1 = y0; + x2 = x1; + x1 = x0; + *iir_buf++ = iir_ssat_24bits(y0); + } + } else { + for (int j = 0; j < len_mono; j++) { + // Left channel + x0 = *iir_buf; + y0 = x0 * b0 + x1 * b1 + x2 * b2 - y1 * a1 - y2 * a2; + y2 = y1; + y1 = y0; + x2 = x1; + x1 = x0; + *iir_buf++ = iir_ssat_24bits(y0); + } + } + // Left + history = mc_iir_cfg.mc_history_l[i]; + *history++ = x1; + *history++ = x2; + *history++ = y1; + *history = y2; + } + + } else { + ASSERT(false, "Can't support sample bit mode:%d", sample_bit); + } + + return 0; } #endif #ifdef USB_ANC_MC_EQ_TUNING struct message_t { - struct msg_hdr_t { - unsigned char prefix; - unsigned char type; - unsigned char seq; - unsigned char len; - } hdr; - unsigned char data[255]; + struct msg_hdr_t { + unsigned char prefix; + unsigned char type; + unsigned char seq; + unsigned char len; + } hdr; + unsigned char data[255]; }; -#define PREFIX_CHAR 0xBE +#define PREFIX_CHAR 0xBE enum MSG_TYPE { - TYPE_SYS = 0x00, - TYPE_READ = 0x01, - TYPE_WRITE = 0x02, - TYPE_BULK_READ = 0x03, - TYPE_SYNC = 0x50, - TYPE_SIG_INFO = 0x51, - TYPE_SIG = 0x52, - TYPE_CODE_INFO = 0x53, - TYPE_CODE = 0x54, - TYPE_RUN = 0x55, - TYPE_SECTOR_SIZE = 0x60, - TYPE_ERASE_BURN_START = 0x61, - TYPE_ERASE_BURN_DATA = 0x62, - TYPE_OBSOLETED_63 = 0x63, - TYPE_OBSOLETED_64 = 0x64, - TYPE_FLASH_CMD = 0x65, - TYPE_GET_SECTOR_INFO = 0x66, - TYPE_SEC_REG_ERASE_BURN_START = 0x67, - TYPE_SEC_REG_ERASE_BURN_DATA = 0x68, + TYPE_SYS = 0x00, + TYPE_READ = 0x01, + TYPE_WRITE = 0x02, + TYPE_BULK_READ = 0x03, + TYPE_SYNC = 0x50, + TYPE_SIG_INFO = 0x51, + TYPE_SIG = 0x52, + TYPE_CODE_INFO = 0x53, + TYPE_CODE = 0x54, + TYPE_RUN = 0x55, + TYPE_SECTOR_SIZE = 0x60, + TYPE_ERASE_BURN_START = 0x61, + TYPE_ERASE_BURN_DATA = 0x62, + TYPE_OBSOLETED_63 = 0x63, + TYPE_OBSOLETED_64 = 0x64, + TYPE_FLASH_CMD = 0x65, + TYPE_GET_SECTOR_INFO = 0x66, + TYPE_SEC_REG_ERASE_BURN_START = 0x67, + TYPE_SEC_REG_ERASE_BURN_DATA = 0x68, - // Extended types - TYPE_PROD_TEST = 0x81, - TYPE_RUNTIME_CMD = 0x82, - TYPE_BT_CALIB_CMD = 0x83, - TYPE_PROTO_EL = 0xA0, + // Extended types + TYPE_PROD_TEST = 0x81, + TYPE_RUNTIME_CMD = 0x82, + TYPE_BT_CALIB_CMD = 0x83, + TYPE_PROTO_EL = 0xA0, - TYPE_INVALID = 0xFF, + TYPE_INVALID = 0xFF, }; enum ERR_CODE { - ERR_NONE = 0x00, - ERR_LEN = 0x01, - ERR_CHECKSUM = 0x02, - ERR_NOT_SYNC = 0x03, - ERR_NOT_SEC = 0x04, - ERR_SYNC_WORD = 0x05, - ERR_SYS_CMD = 0x06, - ERR_DATA_ADDR = 0x07, - ERR_DATA_LEN = 0x08, - ERR_ACCESS_RIGHT = 0x09, + ERR_NONE = 0x00, + ERR_LEN = 0x01, + ERR_CHECKSUM = 0x02, + ERR_NOT_SYNC = 0x03, + ERR_NOT_SEC = 0x04, + ERR_SYNC_WORD = 0x05, + ERR_SYS_CMD = 0x06, + ERR_DATA_ADDR = 0x07, + ERR_DATA_LEN = 0x08, + ERR_ACCESS_RIGHT = 0x09, - ERR_TYPE_INVALID = 0x0F, + ERR_TYPE_INVALID = 0x0F, - //ERR_BOOT_OK = 0x10, - ERR_BOOT_MAGIC = 0x11, - ERR_BOOT_SEC = 0x12, - ERR_BOOT_HASH_TYPE = 0x13, - ERR_BOOT_KEY_TYPE = 0x14, - ERR_BOOT_KEY_LEN = 0x15, - ERR_BOOT_SIG_LEN = 0x16, - ERR_BOOT_SIG = 0x17, - ERR_BOOT_CRC = 0x18, - ERR_BOOT_LEN = 0x19, - ERR_SIG_CODE_SIZE = 0x1A, - ERR_SIG_SIG_LEN = 0x1B, - ERR_SIG_INFO_MISSING = 0x1C, - ERR_BOOT_KEY_ID = 0x1D, - ERR_BOOT_HASH = 0x1E, + // ERR_BOOT_OK = 0x10, + ERR_BOOT_MAGIC = 0x11, + ERR_BOOT_SEC = 0x12, + ERR_BOOT_HASH_TYPE = 0x13, + ERR_BOOT_KEY_TYPE = 0x14, + ERR_BOOT_KEY_LEN = 0x15, + ERR_BOOT_SIG_LEN = 0x16, + ERR_BOOT_SIG = 0x17, + ERR_BOOT_CRC = 0x18, + ERR_BOOT_LEN = 0x19, + ERR_SIG_CODE_SIZE = 0x1A, + ERR_SIG_SIG_LEN = 0x1B, + ERR_SIG_INFO_MISSING = 0x1C, + ERR_BOOT_KEY_ID = 0x1D, + ERR_BOOT_HASH = 0x1E, - ERR_CODE_OK = 0x20, - ERR_BOOT_MISSING = 0x21, - ERR_CODE_SIZE_SIG = 0x22, - ERR_CODE_ADDR_SIZE = 0x23, - ERR_CODE_INFO_MISSING = 0x24, - ERR_CODE_CRC = 0x25, - ERR_CODE_SIG = 0x26, + ERR_CODE_OK = 0x20, + ERR_BOOT_MISSING = 0x21, + ERR_CODE_SIZE_SIG = 0x22, + ERR_CODE_ADDR_SIZE = 0x23, + ERR_CODE_INFO_MISSING = 0x24, + ERR_CODE_CRC = 0x25, + ERR_CODE_SIG = 0x26, - ERR_CODE_MISSING = 0x31, - ERR_VERSION = 0x32, + ERR_CODE_MISSING = 0x31, + ERR_VERSION = 0x32, - ERR_BURN_OK = 0x60, - ERR_SECTOR_SIZE = 0x61, - ERR_SECTOR_SEQ_OVERFLOW = 0x62, - ERR_BURN_INFO_MISSING = 0x63, - ERR_SECTOR_DATA_LEN = 0x64, - ERR_SECTOR_DATA_CRC = 0x65, - ERR_SECTOR_SEQ = 0x66, - ERR_ERASE_FLSH = 0x67, - ERR_BURN_FLSH = 0x68, - ERR_VERIFY_FLSH = 0x69, - ERR_FLASH_CMD = 0x6A, + ERR_BURN_OK = 0x60, + ERR_SECTOR_SIZE = 0x61, + ERR_SECTOR_SEQ_OVERFLOW = 0x62, + ERR_BURN_INFO_MISSING = 0x63, + ERR_SECTOR_DATA_LEN = 0x64, + ERR_SECTOR_DATA_CRC = 0x65, + ERR_SECTOR_SEQ = 0x66, + ERR_ERASE_FLSH = 0x67, + ERR_BURN_FLSH = 0x68, + ERR_VERIFY_FLSH = 0x69, + ERR_FLASH_CMD = 0x6A, - ERR_TYPE_MISMATCHED = 0xE1, - ERR_SEQ_MISMATCHED = 0xE2, - ERR_BUF_TOO_SMALL = 0xE3, + ERR_TYPE_MISMATCHED = 0xE1, + ERR_SEQ_MISMATCHED = 0xE2, + ERR_BUF_TOO_SMALL = 0xE3, - ERR_INTERNAL = 0xFF, + ERR_INTERNAL = 0xFF, }; - //#define PROGRAMMER_ANC_DEBUG enum ANC_CMD_T { - ANC_CMD_CLOSE = 0, - ANC_CMD_OPEN = 1, - ANC_CMD_GET_CFG = 2, - ANC_CMD_APPLY_CFG = 3, - ANC_CMD_CFG_SETUP = 4, - ANC_CMD_CHANNEL_SETUP = 5, - ANC_CMD_SET_SAMP_RATE = 6, + ANC_CMD_CLOSE = 0, + ANC_CMD_OPEN = 1, + ANC_CMD_GET_CFG = 2, + ANC_CMD_APPLY_CFG = 3, + ANC_CMD_CFG_SETUP = 4, + ANC_CMD_CHANNEL_SETUP = 5, + ANC_CMD_SET_SAMP_RATE = 6, }; enum FLASH_CMD_TYPE { - FLASH_CMD_ERASE_SECTOR = 0x21, - FLASH_CMD_BURN_DATA = 0x22, - FLASH_CMD_ERASE_CHIP = 0x31, - FLASH_CMD_SEC_REG_ERASE = 0x41, - FLASH_CMD_SEC_REG_BURN = 0x42, - FLASH_CMD_SEC_REG_LOCK = 0x43, - FLASH_CMD_SEC_REG_READ = 0x44, - FLASH_CMD_ENABLE_REMAP = 0x51, - FLASH_CMD_DISABLE_REMAP = 0x52, + FLASH_CMD_ERASE_SECTOR = 0x21, + FLASH_CMD_BURN_DATA = 0x22, + FLASH_CMD_ERASE_CHIP = 0x31, + FLASH_CMD_SEC_REG_ERASE = 0x41, + FLASH_CMD_SEC_REG_BURN = 0x42, + FLASH_CMD_SEC_REG_LOCK = 0x43, + FLASH_CMD_SEC_REG_READ = 0x44, + FLASH_CMD_ENABLE_REMAP = 0x51, + FLASH_CMD_DISABLE_REMAP = 0x52, }; enum PROD_TEST_CMD_T { - PROD_TEST_CMD_ANC = 0x00000001, + PROD_TEST_CMD_ANC = 0x00000001, }; static struct_anc_cfg g_anc_config; @@ -1170,17 +1144,18 @@ static struct_anc_cfg g_anc_config; #define MAX_READ_DATA_LEN 255 #define MAX_WRITE_DATA_LEN 255 - static struct message_t recv_msg; -static struct message_t send_msg = { { PREFIX_CHAR, }, }; +static struct message_t send_msg = { + { + PREFIX_CHAR, + }, +}; - -#define MAX_SNED_MSG_QUEUE (10) +#define MAX_SNED_MSG_QUEUE (10) static unsigned int send_msg_push_seq = 0; static unsigned int send_msg_pop_seq = 0; static struct message_t send_msg_queue[MAX_SNED_MSG_QUEUE]; - static uint8_t pcsuppt_anc_type = ANC_NOTYPE; static enum AUD_SAMPRATE_T anc_sample_rate; @@ -1192,227 +1167,207 @@ static unsigned int last_sector_len; static unsigned int cur_sector_seq; static unsigned int burn_len; -void anc_set_gpio(enum HAL_GPIO_PIN_T io_pin, bool set_flag) -{ -// #define ANC_SET_GPIO_PIN HAL_IOMUX_PIN_P2_4 - struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_anc_set_gpio[1] = { - {io_pin, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_NOPULL}, - }; +void anc_set_gpio(enum HAL_GPIO_PIN_T io_pin, bool set_flag) { + // #define ANC_SET_GPIO_PIN HAL_IOMUX_PIN_P2_4 + struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_anc_set_gpio[1] = { + {io_pin, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_NOPULL}, + }; - hal_iomux_init(pinmux_anc_set_gpio, ARRAY_SIZE(pinmux_anc_set_gpio)); - hal_gpio_pin_set_dir(io_pin, HAL_GPIO_DIR_OUT, 0); - if(set_flag) - hal_gpio_pin_set(io_pin); - else - hal_gpio_pin_clr(io_pin); + hal_iomux_init(pinmux_anc_set_gpio, ARRAY_SIZE(pinmux_anc_set_gpio)); + hal_gpio_pin_set_dir(io_pin, HAL_GPIO_DIR_OUT, 0); + if (set_flag) + hal_gpio_pin_set(io_pin); + else + hal_gpio_pin_clr(io_pin); } -#define MSG_TOTAL_LEN(msg) (sizeof((msg)->hdr) + (msg)->hdr.len + 1) +#define MSG_TOTAL_LEN(msg) (sizeof((msg)->hdr) + (msg)->hdr.len + 1) -#define TRACE_TIME(num,str, ...) TRACE(1+num,"[%05u] " str, TICKS_TO_MS(hal_sys_timer_get()), ##__VA_ARGS__) +#define TRACE_TIME(num, str, ...) \ + TRACE(1 + num, "[%05u] " str, TICKS_TO_MS(hal_sys_timer_get()), ##__VA_ARGS__) +static unsigned char check_sum(const unsigned char *buf, unsigned char len) { + int i; + unsigned char sum = 0; -static unsigned char check_sum(const unsigned char *buf, unsigned char len) -{ - int i; - unsigned char sum = 0; + for (i = 0; i < len; i++) { + sum += buf[i]; + } - for (i = 0; i < len; i++) { - sum += buf[i]; - } - - return sum; + return sum; } -static void trace_stage_info(const char *name) -{ - TRACE_TIME(1,"------ %s ------", name); +static void trace_stage_info(const char *name) { + TRACE_TIME(1, "------ %s ------", name); } -static void trace_rw_len_err(const char *name, unsigned int len) -{ - TRACE(2,"[%s] Length error: %u", name, len); +static void trace_rw_len_err(const char *name, unsigned int len) { + TRACE(2, "[%s] Length error: %u", name, len); } -static void trace_rw_info(const char *name, unsigned int addr, unsigned int len) -{ - // TRACE(3,"[%s] addr=0x%08X len=%u", name, addr, len); +static void trace_rw_info(const char *name, unsigned int addr, + unsigned int len) { + // TRACE(3,"[%s] addr=0x%08X len=%u", name, addr, len); } -static void trace_flash_cmd_info(const char *name) -{ - TRACE_TIME(1,"- %s -", name); +static void trace_flash_cmd_info(const char *name) { + TRACE_TIME(1, "- %s -", name); } -static void trace_flash_cmd_len_err(const char *name, unsigned int len) -{ - TRACE(2,"Invalid %s cmd param len: %u", name, len); +static void trace_flash_cmd_len_err(const char *name, unsigned int len) { + TRACE(2, "Invalid %s cmd param len: %u", name, len); } -static void trace_flash_cmd_err(const char *name) -{ - TRACE_TIME(1,"%s failed", name); +static void trace_flash_cmd_err(const char *name) { + TRACE_TIME(1, "%s failed", name); } -static void trace_flash_cmd_done(const char *name) -{ - TRACE_TIME(1,"%s done", name); +static void trace_flash_cmd_done(const char *name) { + TRACE_TIME(1, "%s done", name); } -int send_reply(const unsigned char *payload, unsigned int len) -{ - int ret = 0; +int send_reply(const unsigned char *payload, unsigned int len) { + int ret = 0; - if (len + 1 > sizeof(send_msg.data)) { - TRACE(1,"Packet length too long: %u", len); - return -1; - } + if (len + 1 > sizeof(send_msg.data)) { + TRACE(1, "Packet length too long: %u", len); + return -1; + } - send_msg.hdr.type = recv_msg.hdr.type; - send_msg.hdr.seq = recv_msg.hdr.seq; - send_msg.hdr.len = len; - memcpy(&send_msg.data[0], payload, len); - send_msg.data[len] = ~check_sum((unsigned char *)&send_msg, MSG_TOTAL_LEN(&send_msg) - 1); + send_msg.hdr.type = recv_msg.hdr.type; + send_msg.hdr.seq = recv_msg.hdr.seq; + send_msg.hdr.len = len; + memcpy(&send_msg.data[0], payload, len); + send_msg.data[len] = + ~check_sum((unsigned char *)&send_msg, MSG_TOTAL_LEN(&send_msg) - 1); - send_msg_push_seq=send_msg_push_seq%MAX_SNED_MSG_QUEUE; - send_msg_queue[send_msg_push_seq]=send_msg; - send_msg_push_seq++; + send_msg_push_seq = send_msg_push_seq % MAX_SNED_MSG_QUEUE; + send_msg_queue[send_msg_push_seq] = send_msg; + send_msg_push_seq++; - return ret; + return ret; } -static enum ERR_CODE handle_read_cmd(unsigned int type, unsigned int addr, unsigned int len) -{ - union { - unsigned int data[1 + (MAX_READ_DATA_LEN + 3) / 4]; - unsigned char buf[(1 + (MAX_READ_DATA_LEN + 3) / 4) * 4]; - } d; - int i; +static enum ERR_CODE handle_read_cmd(unsigned int type, unsigned int addr, + unsigned int len) { + union { + unsigned int data[1 + (MAX_READ_DATA_LEN + 3) / 4]; + unsigned char buf[(1 + (MAX_READ_DATA_LEN + 3) / 4) * 4]; + } d; + int i; - int cnt; - unsigned int *p32; - unsigned short *p16; + int cnt; + unsigned int *p32; + unsigned short *p16; - const char *name = NULL; + const char *name = NULL; - if (type == TYPE_READ) { - name = "READ"; - } else { - return ERR_INTERNAL; - } + if (type == TYPE_READ) { + name = "READ"; + } else { + return ERR_INTERNAL; + } + if (len > MAX_READ_DATA_LEN) { + trace_rw_len_err(name, len); + return ERR_DATA_LEN; + } - if (len > MAX_READ_DATA_LEN) { - trace_rw_len_err(name, len); - return ERR_DATA_LEN; - } - - - if (type == TYPE_READ) { - // Handle half-word and word register reading - if ((len & 0x03) == 0 && (addr & 0x03) == 0) { - cnt = len / 4; - p32 = (unsigned int *)&d.data[1]; - for (i = 0; i < cnt; i++) { - p32[i] = *((unsigned int *)addr + i); - } - } else if ((len & 0x01) == 0 && (addr & 0x01) == 0) { - cnt = len / 2; - p16 = (unsigned short *)&d.data[1]; - for (i = 0; i < cnt; i++) { - p16[i] = *((unsigned short *)addr + i); - } - } else { - memcpy(&d.data[1], (unsigned char *)addr, len); - } - } - - d.buf[3] = ERR_NONE; - send_reply((unsigned char *)&d.buf[3], 1 + len); - - return ERR_NONE; -} -static enum ERR_CODE handle_write_cmd(unsigned int addr, unsigned int len, unsigned char *wdata) -{ - unsigned int data; - int i; - int cnt; - const char *name = "WRITE"; - - trace_rw_info(name, addr, len); - - if (len > MAX_WRITE_DATA_LEN) { - trace_rw_len_err(name, len); - return ERR_DATA_LEN; - } - // Handle half-word and word register writing + if (type == TYPE_READ) { + // Handle half-word and word register reading if ((len & 0x03) == 0 && (addr & 0x03) == 0) { - cnt = len / 4; - for (i = 0; i < cnt; i++) { - data = wdata[4 * i] | (wdata[4 * i + 1] << 8) | (wdata[4 * i + 2] << 16) | (wdata[4 * i + 3] << 24); - *((unsigned int *)addr + i) = data; - } + cnt = len / 4; + p32 = (unsigned int *)&d.data[1]; + for (i = 0; i < cnt; i++) { + p32[i] = *((unsigned int *)addr + i); + } } else if ((len & 0x01) == 0 && (addr & 0x01) == 0) { - cnt = len / 2; - for (i = 0; i < cnt; i++) { - data = wdata[2 * i] | (wdata[2 * i + 1] << 8); - *((unsigned short *)addr + i) = (unsigned short)data; - } + cnt = len / 2; + p16 = (unsigned short *)&d.data[1]; + for (i = 0; i < cnt; i++) { + p16[i] = *((unsigned short *)addr + i); + } } else { - memcpy((unsigned char *)addr, wdata, len); + memcpy(&d.data[1], (unsigned char *)addr, len); } + } - data = ERR_NONE; - send_reply((unsigned char *)&data, 1); + d.buf[3] = ERR_NONE; + send_reply((unsigned char *)&d.buf[3], 1 + len); - return ERR_NONE; -} -static struct_anc_cfg *get_anc_config(void) -{ - return &g_anc_config; + return ERR_NONE; } +static enum ERR_CODE handle_write_cmd(unsigned int addr, unsigned int len, + unsigned char *wdata) { + unsigned int data; + int i; + int cnt; + const char *name = "WRITE"; + trace_rw_info(name, addr, len); -static void tool_anc_close(void) -{ - if(pcsuppt_anc_type & ANC_FEEDFORWARD) - { - anc_close(ANC_FEEDFORWARD); - af_anc_close(ANC_FEEDFORWARD); + if (len > MAX_WRITE_DATA_LEN) { + trace_rw_len_err(name, len); + return ERR_DATA_LEN; + } + // Handle half-word and word register writing + if ((len & 0x03) == 0 && (addr & 0x03) == 0) { + cnt = len / 4; + for (i = 0; i < cnt; i++) { + data = wdata[4 * i] | (wdata[4 * i + 1] << 8) | (wdata[4 * i + 2] << 16) | + (wdata[4 * i + 3] << 24); + *((unsigned int *)addr + i) = data; } - - if(pcsuppt_anc_type & ANC_FEEDBACK) - { - anc_close(ANC_FEEDBACK); - af_anc_close(ANC_FEEDBACK); + } else if ((len & 0x01) == 0 && (addr & 0x01) == 0) { + cnt = len / 2; + for (i = 0; i < cnt; i++) { + data = wdata[2 * i] | (wdata[2 * i + 1] << 8); + *((unsigned short *)addr + i) = (unsigned short)data; } -} -static void tool_anc_open(void) -{ - if(pcsuppt_anc_type & ANC_FEEDFORWARD) - { - af_anc_open(ANC_FEEDFORWARD, anc_sample_rate, anc_sample_rate, NULL); - anc_open(ANC_FEEDFORWARD); - anc_set_gain(512,512,ANC_FEEDFORWARD); + } else { + memcpy((unsigned char *)addr, wdata, len); + } -#ifdef AUDIO_ANC_TT_HW - af_anc_open(ANC_TALKTHRU, anc_sample_rate, anc_sample_rate, NULL); - anc_open(ANC_TALKTHRU); - anc_set_gain(512,512,ANC_TALKTHRU); + data = ERR_NONE; + send_reply((unsigned char *)&data, 1); + + return ERR_NONE; +} +static struct_anc_cfg *get_anc_config(void) { return &g_anc_config; } + +static void tool_anc_close(void) { + if (pcsuppt_anc_type & ANC_FEEDFORWARD) { + anc_close(ANC_FEEDFORWARD); + af_anc_close(ANC_FEEDFORWARD); + } + + if (pcsuppt_anc_type & ANC_FEEDBACK) { + anc_close(ANC_FEEDBACK); + af_anc_close(ANC_FEEDBACK); + } +} +static void tool_anc_open(void) { + if (pcsuppt_anc_type & ANC_FEEDFORWARD) { + af_anc_open(ANC_FEEDFORWARD, anc_sample_rate, anc_sample_rate, NULL); + anc_open(ANC_FEEDFORWARD); + anc_set_gain(512, 512, ANC_FEEDFORWARD); + +#ifdef AUDIO_ANC_TT_HW + af_anc_open(ANC_TALKTHRU, anc_sample_rate, anc_sample_rate, NULL); + anc_open(ANC_TALKTHRU); + anc_set_gain(512, 512, ANC_TALKTHRU); #endif + } - } + if (pcsuppt_anc_type & ANC_FEEDBACK) { + af_anc_open(ANC_FEEDBACK, anc_sample_rate, anc_sample_rate, NULL); + anc_open(ANC_FEEDBACK); + anc_set_gain(512, 512, ANC_FEEDBACK); - if(pcsuppt_anc_type & ANC_FEEDBACK) - { - af_anc_open(ANC_FEEDBACK, anc_sample_rate, anc_sample_rate, NULL); - anc_open(ANC_FEEDBACK); - anc_set_gain(512,512,ANC_FEEDBACK); - -#ifdef AUDIO_ANC_FB_MC_HW - anc_open(ANC_MUSICCANCLE); - anc_set_gain(512,512,ANC_MUSICCANCLE); +#ifdef AUDIO_ANC_FB_MC_HW + anc_open(ANC_MUSICCANCLE); + anc_set_gain(512, 512, ANC_MUSICCANCLE); #endif - - } + } } -#if !defined( AUDIO_ANC_TT_HW) +#if !defined(AUDIO_ANC_TT_HW) #if defined(__HW_IIR_EQ_PROCESS__) static HW_IIR_CFG_T hw_iir_cfg; #endif @@ -1422,153 +1377,144 @@ static HW_CODEC_IIR_CFG_T hw_codec_iir_cfg; #endif #endif -static int handle_anc_cmd(enum ANC_CMD_T cmd, const uint8_t *data, uint32_t len) -{ +static int handle_anc_cmd(enum ANC_CMD_T cmd, const uint8_t *data, + uint32_t len) { - unsigned char cret = ERR_NONE; + unsigned char cret = ERR_NONE; - switch (cmd) { - case ANC_CMD_CLOSE: - { - TRACE(0,"ANC_CMD_CLOSE ------"); - if (len != 0) - { - return ERR_LEN; - } - anc_disable(); - tool_anc_close(); - send_reply(&cret, 1); - break; - } - case ANC_CMD_OPEN: - { - TRACE(0,"ANC_CMD_OPEN ------"); - if (len != 0) { - return ERR_LEN; - } - hal_sysfreq_req(HAL_SYSFREQ_USER_ANC, HAL_CMU_FREQ_52M); - tool_anc_open(); - anc_enable(); - send_reply(&cret, 1); - break; - } - case ANC_CMD_GET_CFG: - { - TRACE(0,"ANC_CMD_GET_CFG ------"); + switch (cmd) { + case ANC_CMD_CLOSE: { + TRACE(0, "ANC_CMD_CLOSE ------"); + if (len != 0) { + return ERR_LEN; + } + anc_disable(); + tool_anc_close(); + send_reply(&cret, 1); + break; + } + case ANC_CMD_OPEN: { + TRACE(0, "ANC_CMD_OPEN ------"); + if (len != 0) { + return ERR_LEN; + } + hal_sysfreq_req(HAL_SYSFREQ_USER_ANC, HAL_CMU_FREQ_52M); + tool_anc_open(); + anc_enable(); + send_reply(&cret, 1); + break; + } + case ANC_CMD_GET_CFG: { + TRACE(0, "ANC_CMD_GET_CFG ------"); - struct_anc_cfg *anccfg_addr = get_anc_config(); - uint32_t addr = (uint32_t)anccfg_addr; + struct_anc_cfg *anccfg_addr = get_anc_config(); + uint32_t addr = (uint32_t)anccfg_addr; - if (len != 0) { - return ERR_LEN; - } + if (len != 0) { + return ERR_LEN; + } - TRACE(1,"send anccfg address 0x%x ------",addr); - send_reply((unsigned char *)&addr, sizeof(addr)); - break; - } - case ANC_CMD_APPLY_CFG: - { - TRACE(0,"ANC_CMD_APPLY_CFG ------"); + TRACE(1, "send anccfg address 0x%x ------", addr); + send_reply((unsigned char *)&addr, sizeof(addr)); + break; + } + case ANC_CMD_APPLY_CFG: { + TRACE(0, "ANC_CMD_APPLY_CFG ------"); - if (len != 0) { - return ERR_LEN; - } - TRACE(0,"apply anccfg ------"); - // best2000_prod_test_anccfg_apply(); - struct_anc_cfg *anccfg = get_anc_config(); + if (len != 0) { + return ERR_LEN; + } + TRACE(0, "apply anccfg ------"); + // best2000_prod_test_anccfg_apply(); + struct_anc_cfg *anccfg = get_anc_config(); - - //process ANC - if(pcsuppt_anc_type & ANC_FEEDFORWARD) - { - anc_set_cfg(anccfg,ANC_FEEDFORWARD,ANC_GAIN_NO_DELAY); -#ifdef AUDIO_ANC_TT_HW - //anc_set_cfg(anccfg,ANC_TALKTHRU,ANC_GAIN_NO_DELAY); + // process ANC + if (pcsuppt_anc_type & ANC_FEEDFORWARD) { + anc_set_cfg(anccfg, ANC_FEEDFORWARD, ANC_GAIN_NO_DELAY); +#ifdef AUDIO_ANC_TT_HW + // anc_set_cfg(anccfg,ANC_TALKTHRU,ANC_GAIN_NO_DELAY); #endif - } + } - if(pcsuppt_anc_type & ANC_FEEDBACK) - { - anc_set_cfg(anccfg,ANC_FEEDBACK,ANC_GAIN_NO_DELAY); -#ifdef AUDIO_ANC_FB_MC_HW - anc_set_cfg(anccfg,ANC_MUSICCANCLE,ANC_GAIN_NO_DELAY); + if (pcsuppt_anc_type & ANC_FEEDBACK) { + anc_set_cfg(anccfg, ANC_FEEDBACK, ANC_GAIN_NO_DELAY); +#ifdef AUDIO_ANC_FB_MC_HW + anc_set_cfg(anccfg, ANC_MUSICCANCLE, ANC_GAIN_NO_DELAY); #endif - } + } #ifdef AUDIO_ANC_FB_MC - //process MC - mc_iir_cfg.anc_cfg_mc_l=anccfg->anc_cfg_mc_l; - mc_iir_cfg.anc_cfg_mc_r=anccfg->anc_cfg_mc_r; + // process MC + mc_iir_cfg.anc_cfg_mc_l = anccfg->anc_cfg_mc_l; + mc_iir_cfg.anc_cfg_mc_r = anccfg->anc_cfg_mc_r; #endif - if(anccfg->anc_cfg_mc_l.adc_gain_offset==0) - { - hal_codec_anc_adc_enable(ANC_FEEDFORWARD); - analog_aud_codec_anc_enable(ANC_FEEDFORWARD, true); - hal_codec_anc_adc_enable(ANC_FEEDBACK); - analog_aud_codec_anc_enable(ANC_FEEDBACK, true); - TRACE(0,"ADC UNMUTE........"); - } - else - { - hal_codec_anc_adc_disable(ANC_FEEDFORWARD); - analog_aud_codec_anc_enable(ANC_FEEDFORWARD, false); - hal_codec_anc_adc_disable(ANC_FEEDBACK); - analog_aud_codec_anc_enable(ANC_FEEDBACK, false); - TRACE(0,"ADC MUTE........"); - } + if (anccfg->anc_cfg_mc_l.adc_gain_offset == 0) { + hal_codec_anc_adc_enable(ANC_FEEDFORWARD); + analog_aud_codec_anc_enable(ANC_FEEDFORWARD, true); + hal_codec_anc_adc_enable(ANC_FEEDBACK); + analog_aud_codec_anc_enable(ANC_FEEDBACK, true); + TRACE(0, "ADC UNMUTE........"); + } else { + hal_codec_anc_adc_disable(ANC_FEEDFORWARD); + analog_aud_codec_anc_enable(ANC_FEEDFORWARD, false); + hal_codec_anc_adc_disable(ANC_FEEDBACK); + analog_aud_codec_anc_enable(ANC_FEEDBACK, false); + TRACE(0, "ADC MUTE........"); + } - if(anccfg->anc_cfg_mc_l.dac_gain_offset==0) - { - analog_aud_codec_nomute(); - TRACE(0,"DAC UNMUTE........"); - } - else - { - analog_aud_codec_mute(); - TRACE(0,"DAC MUTE........"); - } + if (anccfg->anc_cfg_mc_l.dac_gain_offset == 0) { + analog_aud_codec_nomute(); + TRACE(0, "DAC UNMUTE........"); + } else { + analog_aud_codec_mute(); + TRACE(0, "DAC MUTE........"); + } -#if !defined( AUDIO_ANC_TT_HW) +#if !defined(AUDIO_ANC_TT_HW) #if defined(__HW_IIR_EQ_PROCESS__) - //process EQ - if(anccfg->anc_cfg_tt_l.total_gain ==0) - { - hw_iir_cfg.iir_filtes_l.iir_counter=0; - } - else - { - hw_iir_cfg.iir_filtes_l.iir_counter=anccfg->anc_cfg_tt_l.iir_counter; - } + // process EQ + if (anccfg->anc_cfg_tt_l.total_gain == 0) { + hw_iir_cfg.iir_filtes_l.iir_counter = 0; + } else { + hw_iir_cfg.iir_filtes_l.iir_counter = anccfg->anc_cfg_tt_l.iir_counter; + } - if(anccfg->anc_cfg_tt_r.total_gain ==0) - { - hw_iir_cfg.iir_filtes_r.iir_counter=0; - } - else - { - hw_iir_cfg.iir_filtes_r.iir_counter=anccfg->anc_cfg_tt_r.iir_counter; - } + if (anccfg->anc_cfg_tt_r.total_gain == 0) { + hw_iir_cfg.iir_filtes_r.iir_counter = 0; + } else { + hw_iir_cfg.iir_filtes_r.iir_counter = anccfg->anc_cfg_tt_r.iir_counter; + } - for(int i=0;ianc_cfg_tt_l.iir_coef[i].coef_b[0]); - hw_iir_cfg.iir_filtes_l.iir_coef[i].coef_b[1]=(anccfg->anc_cfg_tt_l.iir_coef[i].coef_b[1]); - hw_iir_cfg.iir_filtes_l.iir_coef[i].coef_b[2]=(anccfg->anc_cfg_tt_l.iir_coef[i].coef_b[2]); - hw_iir_cfg.iir_filtes_l.iir_coef[i].coef_a[0]=(anccfg->anc_cfg_tt_l.iir_coef[i].coef_a[0]); - hw_iir_cfg.iir_filtes_l.iir_coef[i].coef_a[1]=(anccfg->anc_cfg_tt_l.iir_coef[i].coef_a[1]); - hw_iir_cfg.iir_filtes_l.iir_coef[i].coef_a[2]=(anccfg->anc_cfg_tt_l.iir_coef[i].coef_a[2]); + for (int i = 0; i < AUD_IIR_NUM_EQ; i++) { + hw_iir_cfg.iir_filtes_l.iir_coef[i].coef_b[0] = + (anccfg->anc_cfg_tt_l.iir_coef[i].coef_b[0]); + hw_iir_cfg.iir_filtes_l.iir_coef[i].coef_b[1] = + (anccfg->anc_cfg_tt_l.iir_coef[i].coef_b[1]); + hw_iir_cfg.iir_filtes_l.iir_coef[i].coef_b[2] = + (anccfg->anc_cfg_tt_l.iir_coef[i].coef_b[2]); + hw_iir_cfg.iir_filtes_l.iir_coef[i].coef_a[0] = + (anccfg->anc_cfg_tt_l.iir_coef[i].coef_a[0]); + hw_iir_cfg.iir_filtes_l.iir_coef[i].coef_a[1] = + (anccfg->anc_cfg_tt_l.iir_coef[i].coef_a[1]); + hw_iir_cfg.iir_filtes_l.iir_coef[i].coef_a[2] = + (anccfg->anc_cfg_tt_l.iir_coef[i].coef_a[2]); - hw_iir_cfg.iir_filtes_r.iir_coef[i].coef_b[0]=(anccfg->anc_cfg_tt_r.iir_coef[i].coef_b[0]); - hw_iir_cfg.iir_filtes_r.iir_coef[i].coef_b[1]=(anccfg->anc_cfg_tt_r.iir_coef[i].coef_b[1]); - hw_iir_cfg.iir_filtes_r.iir_coef[i].coef_b[2]=(anccfg->anc_cfg_tt_r.iir_coef[i].coef_b[2]); - hw_iir_cfg.iir_filtes_r.iir_coef[i].coef_a[0]=(anccfg->anc_cfg_tt_r.iir_coef[i].coef_a[0]); - hw_iir_cfg.iir_filtes_r.iir_coef[i].coef_a[1]=(anccfg->anc_cfg_tt_r.iir_coef[i].coef_a[1]); - hw_iir_cfg.iir_filtes_r.iir_coef[i].coef_a[2]=(anccfg->anc_cfg_tt_r.iir_coef[i].coef_a[2]); - } + hw_iir_cfg.iir_filtes_r.iir_coef[i].coef_b[0] = + (anccfg->anc_cfg_tt_r.iir_coef[i].coef_b[0]); + hw_iir_cfg.iir_filtes_r.iir_coef[i].coef_b[1] = + (anccfg->anc_cfg_tt_r.iir_coef[i].coef_b[1]); + hw_iir_cfg.iir_filtes_r.iir_coef[i].coef_b[2] = + (anccfg->anc_cfg_tt_r.iir_coef[i].coef_b[2]); + hw_iir_cfg.iir_filtes_r.iir_coef[i].coef_a[0] = + (anccfg->anc_cfg_tt_r.iir_coef[i].coef_a[0]); + hw_iir_cfg.iir_filtes_r.iir_coef[i].coef_a[1] = + (anccfg->anc_cfg_tt_r.iir_coef[i].coef_a[1]); + hw_iir_cfg.iir_filtes_r.iir_coef[i].coef_a[2] = + (anccfg->anc_cfg_tt_r.iir_coef[i].coef_a[2]); + } - hw_iir_set_cfg(&hw_iir_cfg); + hw_iir_set_cfg(&hw_iir_cfg); #endif #if defined(__HW_DAC_IIR_EQ_PROCESS__) @@ -1592,363 +1538,350 @@ static int handle_anc_cmd(enum ANC_CMD_T cmd, const uint8_t *data, uint32_t len) } #endif - //process EQ - if(anccfg->anc_cfg_tt_l.total_gain ==0) - { - hw_codec_iir_cfg.iir_filtes_l.iir_counter=0; - } - else - { - hw_codec_iir_cfg.iir_filtes_l.iir_counter=anccfg->anc_cfg_tt_l.iir_counter; - } + // process EQ + if (anccfg->anc_cfg_tt_l.total_gain == 0) { + hw_codec_iir_cfg.iir_filtes_l.iir_counter = 0; + } else { + hw_codec_iir_cfg.iir_filtes_l.iir_counter = + anccfg->anc_cfg_tt_l.iir_counter; + } - if(anccfg->anc_cfg_tt_r.total_gain ==0) - { - hw_codec_iir_cfg.iir_filtes_r.iir_counter=0; - } - else - { - hw_codec_iir_cfg.iir_filtes_r.iir_counter=anccfg->anc_cfg_tt_r.iir_counter; - } + if (anccfg->anc_cfg_tt_r.total_gain == 0) { + hw_codec_iir_cfg.iir_filtes_r.iir_counter = 0; + } else { + hw_codec_iir_cfg.iir_filtes_r.iir_counter = + anccfg->anc_cfg_tt_r.iir_counter; + } - for(int i=0;ianc_cfg_tt_l.iir_coef[i].coef_b[0]); - hw_codec_iir_cfg.iir_filtes_l.iir_coef[i].coef_b[1]=(anccfg->anc_cfg_tt_l.iir_coef[i].coef_b[1]); - hw_codec_iir_cfg.iir_filtes_l.iir_coef[i].coef_b[2]=(anccfg->anc_cfg_tt_l.iir_coef[i].coef_b[2]); - hw_codec_iir_cfg.iir_filtes_l.iir_coef[i].coef_a[0]=(anccfg->anc_cfg_tt_l.iir_coef[i].coef_a[0]); - hw_codec_iir_cfg.iir_filtes_l.iir_coef[i].coef_a[1]=(anccfg->anc_cfg_tt_l.iir_coef[i].coef_a[1]); - hw_codec_iir_cfg.iir_filtes_l.iir_coef[i].coef_a[2]=(anccfg->anc_cfg_tt_l.iir_coef[i].coef_a[2]); + for (int i = 0; i < AUD_IIR_NUM_EQ; i++) { + hw_codec_iir_cfg.iir_filtes_l.iir_coef[i].coef_b[0] = + (anccfg->anc_cfg_tt_l.iir_coef[i].coef_b[0]); + hw_codec_iir_cfg.iir_filtes_l.iir_coef[i].coef_b[1] = + (anccfg->anc_cfg_tt_l.iir_coef[i].coef_b[1]); + hw_codec_iir_cfg.iir_filtes_l.iir_coef[i].coef_b[2] = + (anccfg->anc_cfg_tt_l.iir_coef[i].coef_b[2]); + hw_codec_iir_cfg.iir_filtes_l.iir_coef[i].coef_a[0] = + (anccfg->anc_cfg_tt_l.iir_coef[i].coef_a[0]); + hw_codec_iir_cfg.iir_filtes_l.iir_coef[i].coef_a[1] = + (anccfg->anc_cfg_tt_l.iir_coef[i].coef_a[1]); + hw_codec_iir_cfg.iir_filtes_l.iir_coef[i].coef_a[2] = + (anccfg->anc_cfg_tt_l.iir_coef[i].coef_a[2]); - hw_codec_iir_cfg.iir_filtes_r.iir_coef[i].coef_b[0]=(anccfg->anc_cfg_tt_r.iir_coef[i].coef_b[0]); - hw_codec_iir_cfg.iir_filtes_r.iir_coef[i].coef_b[1]=(anccfg->anc_cfg_tt_r.iir_coef[i].coef_b[1]); - hw_codec_iir_cfg.iir_filtes_r.iir_coef[i].coef_b[2]=(anccfg->anc_cfg_tt_r.iir_coef[i].coef_b[2]); - hw_codec_iir_cfg.iir_filtes_r.iir_coef[i].coef_a[0]=(anccfg->anc_cfg_tt_r.iir_coef[i].coef_a[0]); - hw_codec_iir_cfg.iir_filtes_r.iir_coef[i].coef_a[1]=(anccfg->anc_cfg_tt_r.iir_coef[i].coef_a[1]); - hw_codec_iir_cfg.iir_filtes_r.iir_coef[i].coef_a[2]=(anccfg->anc_cfg_tt_r.iir_coef[i].coef_a[2]); - } + hw_codec_iir_cfg.iir_filtes_r.iir_coef[i].coef_b[0] = + (anccfg->anc_cfg_tt_r.iir_coef[i].coef_b[0]); + hw_codec_iir_cfg.iir_filtes_r.iir_coef[i].coef_b[1] = + (anccfg->anc_cfg_tt_r.iir_coef[i].coef_b[1]); + hw_codec_iir_cfg.iir_filtes_r.iir_coef[i].coef_b[2] = + (anccfg->anc_cfg_tt_r.iir_coef[i].coef_b[2]); + hw_codec_iir_cfg.iir_filtes_r.iir_coef[i].coef_a[0] = + (anccfg->anc_cfg_tt_r.iir_coef[i].coef_a[0]); + hw_codec_iir_cfg.iir_filtes_r.iir_coef[i].coef_a[1] = + (anccfg->anc_cfg_tt_r.iir_coef[i].coef_a[1]); + hw_codec_iir_cfg.iir_filtes_r.iir_coef[i].coef_a[2] = + (anccfg->anc_cfg_tt_r.iir_coef[i].coef_a[2]); + } - if (anc_sample_rate == AUD_SAMPRATE_50781) - { - hw_codec_iir_set_cfg(&hw_codec_iir_cfg, AUD_SAMPRATE_50781, HW_CODEC_IIR_DAC); - } - else - { - hw_codec_iir_set_cfg(&hw_codec_iir_cfg, AUD_SAMPRATE_48000, HW_CODEC_IIR_DAC); - } + if (anc_sample_rate == AUD_SAMPRATE_50781) { + hw_codec_iir_set_cfg(&hw_codec_iir_cfg, AUD_SAMPRATE_50781, + HW_CODEC_IIR_DAC); + } else { + hw_codec_iir_set_cfg(&hw_codec_iir_cfg, AUD_SAMPRATE_48000, + HW_CODEC_IIR_DAC); + } #endif #endif - send_reply(&cret, 1); - break; - } - case ANC_CMD_CFG_SETUP: - { - TRACE(0,"ANC_CMD_CFG_SETUP ------"); + send_reply(&cret, 1); + break; + } + case ANC_CMD_CFG_SETUP: { + TRACE(0, "ANC_CMD_CFG_SETUP ------"); - int ret = 0; - bool diff; - bool high_performance_adc; - bool vcrystal_on; - uint16_t vcodec; - pctool_iocfg *iocfg1, *iocfg2; - - if(data[0]==1) - { - pcsuppt_anc_type = ANC_FEEDFORWARD; - } - else if(data[0]==2) - { - pcsuppt_anc_type = ANC_FEEDBACK; - } - else if(data[0]==3) - { - pcsuppt_anc_type = ANC_FEEDFORWARD|ANC_FEEDBACK; - } - - vcodec = (data[1] | (data[2] << 8)); - diff = (bool)data[3]; - high_performance_adc = false; //(bool)data[4]; // default 0 - anc_sample_rate = (data[5] | (data[6] << 8) | (data[7] << 16) | (data[8] << 24)); - vcrystal_on = data[9]; //(bool)data[?]; // default 0 - TRACE(4,"vcodec:%d,diff:%d,anc_sample_rate:%d,vcrystal_on:%d.", vcodec,diff,anc_sample_rate,vcrystal_on); - ret |= pmu_debug_config_vcrystal(vcrystal_on); - ret |= analog_debug_config_audio_output(diff); - ret |= analog_debug_config_codec(vcodec); - ret |= analog_debug_config_low_power_adc(!high_performance_adc); - if (anc_sample_rate == AUD_SAMPRATE_50781) { - hal_cmu_audio_resample_enable(); - } else { - hal_cmu_audio_resample_disable(); - } - iocfg1 = (pctool_iocfg *)(&data[10]); - iocfg2 = (pctool_iocfg *)(&data[12]); - TRACE(4,"io cfg:%d %d %d %d",iocfg1->io_pin,iocfg1->set_flag,iocfg2->io_pin,iocfg2->set_flag); - if(iocfg1->io_pin>=0) - anc_set_gpio(iocfg1->io_pin,iocfg1->set_flag); - if(iocfg2->io_pin>=0) - anc_set_gpio(iocfg2->io_pin,iocfg2->set_flag); - cret = ret ? ERR_INTERNAL : ERR_NONE; - - send_reply((unsigned char *)&cret, 1); - break; - } - case ANC_CMD_CHANNEL_SETUP: - { - - const enum AUD_CHANNEL_MAP_T channel_map_arr[16] = { - AUD_CHANNEL_MAP_CH0, - AUD_CHANNEL_MAP_CH1, - AUD_CHANNEL_MAP_CH2, - AUD_CHANNEL_MAP_CH3, - AUD_CHANNEL_MAP_CH4, - AUD_CHANNEL_MAP_CH5, - AUD_CHANNEL_MAP_CH6, - AUD_CHANNEL_MAP_CH7, - AUD_CHANNEL_MAP_DIGMIC_CH0, - AUD_CHANNEL_MAP_DIGMIC_CH1, - AUD_CHANNEL_MAP_DIGMIC_CH2, - AUD_CHANNEL_MAP_DIGMIC_CH3, - AUD_CHANNEL_MAP_DIGMIC_CH4, - AUD_CHANNEL_MAP_DIGMIC_CH5, - AUD_CHANNEL_MAP_DIGMIC_CH6, - AUD_CHANNEL_MAP_DIGMIC_CH7, - }; - anc_ff_mic_ch_l = channel_map_arr[data[0]]; - anc_ff_mic_ch_r = channel_map_arr[data[1]]; - anc_fb_mic_ch_l = channel_map_arr[data[2]]; - anc_fb_mic_ch_r = channel_map_arr[data[3]]; - TRACE(4,"anc_ff_mic_ch_l 0x%x,anc_ff_mic_ch_r 0x%x,anc_fb_mic_ch_l 0x%x,anc_fb_mic_ch_r 0x%x", - anc_ff_mic_ch_l, anc_ff_mic_ch_r, anc_fb_mic_ch_l, anc_fb_mic_ch_r); - - hal_iomux_set_dig_mic_clock_pin(data[4]); - hal_iomux_set_dig_mic_data0_pin(data[5]); - hal_iomux_set_dig_mic_data1_pin(data[6]); - hal_iomux_set_dig_mic_data2_pin(data[7]); - uint8_t phase = data[8]; -#if defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) - analog_debug_config_vad_mic(!!(phase & (1 << 7))); - phase &= ~(1 << 7); -#endif - hal_codec_config_digmic_phase(phase); - - send_reply((unsigned char *)&cret, 1); - break; - } - case ANC_CMD_SET_SAMP_RATE: - { - bool opened; - - opened = (anc_opened(ANC_FEEDFORWARD) || anc_opened(ANC_FEEDBACK)); - if (opened) - { - anc_disable(); - tool_anc_close(); - } - anc_sample_rate = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); - if (anc_sample_rate == AUD_SAMPRATE_50781) { - hal_cmu_audio_resample_enable(); - } else { - hal_cmu_audio_resample_disable(); - } - if (opened) - { - tool_anc_open(); - anc_enable(); - } - send_reply((unsigned char *)&cret, 1); - break; - } - } - - return ERR_NONE; - } -static int get_sector_info(unsigned int addr, unsigned int *sector_addr, unsigned int *sector_len) -{ - int ret; - - ret = hal_norflash_get_boundary(HAL_NORFLASH_ID_0, addr, NULL, (uint32_t *)sector_addr); - if (ret) { - return ret; - } - - ret = hal_norflash_get_size(HAL_NORFLASH_ID_0, NULL, NULL, (uint32_t *)sector_len, NULL); - - return ret; -} -static int erase_sector(unsigned int sector_addr, unsigned int sector_len) -{ - return hal_norflash_erase(HAL_NORFLASH_ID_0, sector_addr, sector_len); -} - -static int erase_chip(void) -{ - return hal_norflash_erase_chip(HAL_NORFLASH_ID_0); -} - -static int burn_data(unsigned int addr, const unsigned char *data, unsigned int len) -{ - int ret; - - ret = hal_norflash_write(HAL_NORFLASH_ID_0, addr, data, len); - return ret; -} - -static int verify_flash_data(unsigned int addr, const unsigned char *data, unsigned int len) -{ - const unsigned char *fdata; - const unsigned char *mdata; - int i; - - fdata = (unsigned char *)addr; - mdata = data; - for (i = 0; i < len; i++) { - if (*fdata++ != *mdata++) { - --fdata; - --mdata; - TRACE(4,"*** Verify flash data failed: 0x%02X @ %p != 0x%02X @ %p", *fdata, fdata, *mdata, mdata); - return *fdata - *mdata; - } - } - return 0; -} -static enum ERR_CODE handle_sector_info_cmd(unsigned int addr) -{ - unsigned int sector_addr; - unsigned int sector_len; - unsigned char buf[9]; - int ret; - - ret = get_sector_info(addr, §or_addr, §or_len); - if (ret) { - return ERR_DATA_ADDR; - } - - TRACE(3,"addr=0x%08X sector_addr=0x%08X sector_len=%u", addr, sector_addr, sector_len); - - buf[0] = ERR_NONE; - memcpy(&buf[1], §or_addr, 4); - memcpy(&buf[5], §or_len, 4); - - send_reply(buf, 9); - - return ERR_NONE; -} -static enum ERR_CODE handle_flash_cmd(enum FLASH_CMD_TYPE cmd, unsigned char *param, unsigned int len) -{ int ret = 0; - unsigned char cret = ERR_NONE; - const char *name = NULL; + bool diff; + bool high_performance_adc; + bool vcrystal_on; + uint16_t vcodec; + pctool_iocfg *iocfg1, *iocfg2; - switch (cmd) { - case FLASH_CMD_ERASE_SECTOR: - { - unsigned int addr; - unsigned int size; - - if (cmd == FLASH_CMD_ERASE_SECTOR) - { - name = "ERASE_SECTOR"; - } - - trace_flash_cmd_info(name); - - if (len != 8) - { - trace_flash_cmd_len_err(name, len); - return ERR_LEN; - } - - addr = param[0] | (param[1] << 8) | (param[2] << 16) | (param[3] << 24); - size = param[4] | (param[5] << 8) | (param[6] << 16) | (param[7] << 24); - TRACE(2,"addr=0x%08X size=%u", addr, size); - - if (cmd == FLASH_CMD_ERASE_SECTOR) - { - ret = erase_sector(addr, size); - } - - if (ret) { - trace_flash_cmd_err(name); - return ERR_ERASE_FLSH; - } - - trace_flash_cmd_done(name); - - send_reply(&cret, 1); - break; - } - case FLASH_CMD_BURN_DATA: - { - unsigned int addr; - - if (cmd == FLASH_CMD_BURN_DATA) - { - name = "BURN_DATA"; - } - - trace_flash_cmd_info(name); - - if (len <= 4 || len > 20) { - trace_flash_cmd_len_err(name, len); - return ERR_LEN; - } - - addr = param[0] | (param[1] << 8) | (param[2] << 16) | (param[3] << 24); - TRACE(2,"addr=0x%08X len=%u", addr, len - 4); - - if (cmd == FLASH_CMD_BURN_DATA) - { - ret = burn_data(addr, ¶m[4], len - 4); - } - - if (ret) { - trace_flash_cmd_err(name); - return ERR_BURN_FLSH; - } - - TRACE_TIME(1,"%s verifying", name); - - if (cmd == FLASH_CMD_BURN_DATA) - { - ret = verify_flash_data(addr, ¶m[4], len - 4); - } - if (ret) { - TRACE(1,"%s verify failed", name); - return ERR_VERIFY_FLSH; - } - - trace_flash_cmd_done(name); - - send_reply(&cret, 1); - break; - } - case FLASH_CMD_ERASE_CHIP: { - name = "CMD_ERASE_CHIP"; - - trace_flash_cmd_info(name); - - if (len != 0) { - trace_flash_cmd_len_err(name, len); - return ERR_LEN; - } - - ret = erase_chip(); - if (ret) { - trace_flash_cmd_err(name); - return ERR_ERASE_FLSH; - } - - trace_flash_cmd_done(name); - - send_reply(&cret, 1); - break; - } - default: - TRACE(1,"Unsupported flash cmd: 0x%x", cmd); - return ERR_FLASH_CMD; + if (data[0] == 1) { + pcsuppt_anc_type = ANC_FEEDFORWARD; + } else if (data[0] == 2) { + pcsuppt_anc_type = ANC_FEEDBACK; + } else if (data[0] == 3) { + pcsuppt_anc_type = ANC_FEEDFORWARD | ANC_FEEDBACK; } - return ERR_NONE; + vcodec = (data[1] | (data[2] << 8)); + diff = (bool)data[3]; + high_performance_adc = false; //(bool)data[4]; // default 0 + anc_sample_rate = + (data[5] | (data[6] << 8) | (data[7] << 16) | (data[8] << 24)); + vcrystal_on = data[9]; //(bool)data[?]; // default 0 + TRACE(4, "vcodec:%d,diff:%d,anc_sample_rate:%d,vcrystal_on:%d.", vcodec, + diff, anc_sample_rate, vcrystal_on); + ret |= pmu_debug_config_vcrystal(vcrystal_on); + ret |= analog_debug_config_audio_output(diff); + ret |= analog_debug_config_codec(vcodec); + ret |= analog_debug_config_low_power_adc(!high_performance_adc); + if (anc_sample_rate == AUD_SAMPRATE_50781) { + hal_cmu_audio_resample_enable(); + } else { + hal_cmu_audio_resample_disable(); + } + iocfg1 = (pctool_iocfg *)(&data[10]); + iocfg2 = (pctool_iocfg *)(&data[12]); + TRACE(4, "io cfg:%d %d %d %d", iocfg1->io_pin, iocfg1->set_flag, + iocfg2->io_pin, iocfg2->set_flag); + if (iocfg1->io_pin >= 0) + anc_set_gpio(iocfg1->io_pin, iocfg1->set_flag); + if (iocfg2->io_pin >= 0) + anc_set_gpio(iocfg2->io_pin, iocfg2->set_flag); + cret = ret ? ERR_INTERNAL : ERR_NONE; + + send_reply((unsigned char *)&cret, 1); + break; + } + case ANC_CMD_CHANNEL_SETUP: { + + const enum AUD_CHANNEL_MAP_T channel_map_arr[16] = { + AUD_CHANNEL_MAP_CH0, AUD_CHANNEL_MAP_CH1, + AUD_CHANNEL_MAP_CH2, AUD_CHANNEL_MAP_CH3, + AUD_CHANNEL_MAP_CH4, AUD_CHANNEL_MAP_CH5, + AUD_CHANNEL_MAP_CH6, AUD_CHANNEL_MAP_CH7, + AUD_CHANNEL_MAP_DIGMIC_CH0, AUD_CHANNEL_MAP_DIGMIC_CH1, + AUD_CHANNEL_MAP_DIGMIC_CH2, AUD_CHANNEL_MAP_DIGMIC_CH3, + AUD_CHANNEL_MAP_DIGMIC_CH4, AUD_CHANNEL_MAP_DIGMIC_CH5, + AUD_CHANNEL_MAP_DIGMIC_CH6, AUD_CHANNEL_MAP_DIGMIC_CH7, + }; + anc_ff_mic_ch_l = channel_map_arr[data[0]]; + anc_ff_mic_ch_r = channel_map_arr[data[1]]; + anc_fb_mic_ch_l = channel_map_arr[data[2]]; + anc_fb_mic_ch_r = channel_map_arr[data[3]]; + TRACE(4, + "anc_ff_mic_ch_l 0x%x,anc_ff_mic_ch_r 0x%x,anc_fb_mic_ch_l " + "0x%x,anc_fb_mic_ch_r 0x%x", + anc_ff_mic_ch_l, anc_ff_mic_ch_r, anc_fb_mic_ch_l, anc_fb_mic_ch_r); + + hal_iomux_set_dig_mic_clock_pin(data[4]); + hal_iomux_set_dig_mic_data0_pin(data[5]); + hal_iomux_set_dig_mic_data1_pin(data[6]); + hal_iomux_set_dig_mic_data2_pin(data[7]); + uint8_t phase = data[8]; +#if defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) || defined(CHIP_BEST2300A) + analog_debug_config_vad_mic(!!(phase & (1 << 7))); + phase &= ~(1 << 7); +#endif + hal_codec_config_digmic_phase(phase); + + send_reply((unsigned char *)&cret, 1); + break; + } + case ANC_CMD_SET_SAMP_RATE: { + bool opened; + + opened = (anc_opened(ANC_FEEDFORWARD) || anc_opened(ANC_FEEDBACK)); + if (opened) { + anc_disable(); + tool_anc_close(); + } + anc_sample_rate = + data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); + if (anc_sample_rate == AUD_SAMPRATE_50781) { + hal_cmu_audio_resample_enable(); + } else { + hal_cmu_audio_resample_disable(); + } + if (opened) { + tool_anc_open(); + anc_enable(); + } + send_reply((unsigned char *)&cret, 1); + break; + } + } + + return ERR_NONE; +} +static int get_sector_info(unsigned int addr, unsigned int *sector_addr, + unsigned int *sector_len) { + int ret; + + ret = hal_norflash_get_boundary(HAL_NORFLASH_ID_0, addr, NULL, + (uint32_t *)sector_addr); + if (ret) { + return ret; + } + + ret = hal_norflash_get_size(HAL_NORFLASH_ID_0, NULL, NULL, + (uint32_t *)sector_len, NULL); + + return ret; +} +static int erase_sector(unsigned int sector_addr, unsigned int sector_len) { + return hal_norflash_erase(HAL_NORFLASH_ID_0, sector_addr, sector_len); +} + +static int erase_chip(void) { + return hal_norflash_erase_chip(HAL_NORFLASH_ID_0); +} + +static int burn_data(unsigned int addr, const unsigned char *data, + unsigned int len) { + int ret; + + ret = hal_norflash_write(HAL_NORFLASH_ID_0, addr, data, len); + return ret; +} + +static int verify_flash_data(unsigned int addr, const unsigned char *data, + unsigned int len) { + const unsigned char *fdata; + const unsigned char *mdata; + int i; + + fdata = (unsigned char *)addr; + mdata = data; + for (i = 0; i < len; i++) { + if (*fdata++ != *mdata++) { + --fdata; + --mdata; + TRACE(4, "*** Verify flash data failed: 0x%02X @ %p != 0x%02X @ %p", + *fdata, fdata, *mdata, mdata); + return *fdata - *mdata; + } + } + return 0; +} +static enum ERR_CODE handle_sector_info_cmd(unsigned int addr) { + unsigned int sector_addr; + unsigned int sector_len; + unsigned char buf[9]; + int ret; + + ret = get_sector_info(addr, §or_addr, §or_len); + if (ret) { + return ERR_DATA_ADDR; + } + + TRACE(3, "addr=0x%08X sector_addr=0x%08X sector_len=%u", addr, sector_addr, + sector_len); + + buf[0] = ERR_NONE; + memcpy(&buf[1], §or_addr, 4); + memcpy(&buf[5], §or_len, 4); + + send_reply(buf, 9); + + return ERR_NONE; +} +static enum ERR_CODE handle_flash_cmd(enum FLASH_CMD_TYPE cmd, + unsigned char *param, unsigned int len) { + int ret = 0; + unsigned char cret = ERR_NONE; + const char *name = NULL; + + switch (cmd) { + case FLASH_CMD_ERASE_SECTOR: { + unsigned int addr; + unsigned int size; + + if (cmd == FLASH_CMD_ERASE_SECTOR) { + name = "ERASE_SECTOR"; + } + + trace_flash_cmd_info(name); + + if (len != 8) { + trace_flash_cmd_len_err(name, len); + return ERR_LEN; + } + + addr = param[0] | (param[1] << 8) | (param[2] << 16) | (param[3] << 24); + size = param[4] | (param[5] << 8) | (param[6] << 16) | (param[7] << 24); + TRACE(2, "addr=0x%08X size=%u", addr, size); + + if (cmd == FLASH_CMD_ERASE_SECTOR) { + ret = erase_sector(addr, size); + } + + if (ret) { + trace_flash_cmd_err(name); + return ERR_ERASE_FLSH; + } + + trace_flash_cmd_done(name); + + send_reply(&cret, 1); + break; + } + case FLASH_CMD_BURN_DATA: { + unsigned int addr; + + if (cmd == FLASH_CMD_BURN_DATA) { + name = "BURN_DATA"; + } + + trace_flash_cmd_info(name); + + if (len <= 4 || len > 20) { + trace_flash_cmd_len_err(name, len); + return ERR_LEN; + } + + addr = param[0] | (param[1] << 8) | (param[2] << 16) | (param[3] << 24); + TRACE(2, "addr=0x%08X len=%u", addr, len - 4); + + if (cmd == FLASH_CMD_BURN_DATA) { + ret = burn_data(addr, ¶m[4], len - 4); + } + + if (ret) { + trace_flash_cmd_err(name); + return ERR_BURN_FLSH; + } + + TRACE_TIME(1, "%s verifying", name); + + if (cmd == FLASH_CMD_BURN_DATA) { + ret = verify_flash_data(addr, ¶m[4], len - 4); + } + if (ret) { + TRACE(1, "%s verify failed", name); + return ERR_VERIFY_FLSH; + } + + trace_flash_cmd_done(name); + + send_reply(&cret, 1); + break; + } + case FLASH_CMD_ERASE_CHIP: { + name = "CMD_ERASE_CHIP"; + + trace_flash_cmd_info(name); + + if (len != 0) { + trace_flash_cmd_len_err(name, len); + return ERR_LEN; + } + + ret = erase_chip(); + if (ret) { + trace_flash_cmd_err(name); + return ERR_ERASE_FLSH; + } + + trace_flash_cmd_done(name); + + send_reply(&cret, 1); + break; + } + default: + TRACE(1, "Unsupported flash cmd: 0x%x", cmd); + return ERR_FLASH_CMD; + } + + return ERR_NONE; } /* #define SECTOR_SIZE_64K (1 << 16) @@ -1956,21 +1889,20 @@ static enum ERR_CODE handle_flash_cmd(enum FLASH_CMD_TYPE cmd, unsigned char *pa #define SECTOR_SIZE_16K (1 << 14) #define SECTOR_SIZE_4K (1 << 12) */ -#define BURN_DATA_MSG_OVERHEAD 16 +#define BURN_DATA_MSG_OVERHEAD 16 -//static const unsigned int size_mask = SECTOR_SIZE_32K | SECTOR_SIZE_4K; +// static const unsigned int size_mask = SECTOR_SIZE_32K | SECTOR_SIZE_4K; enum PROGRAMMER_STATE { - PROGRAMMER_NONE, - PROGRAMMER_ERASE_BURN_START, - PROGRAMMER_SEC_REG_ERASE_BURN_START, + PROGRAMMER_NONE, + PROGRAMMER_ERASE_BURN_START, + PROGRAMMER_SEC_REG_ERASE_BURN_START, }; +#define BURN_BUFFER_LOC __attribute__((section(".burn_buffer"))) -#define BURN_BUFFER_LOC __attribute__((section(".burn_buffer"))) - -static unsigned char BURN_BUFFER_LOC data_buf[65536+2048]; -static enum PROGRAMMER_STATE programmer_state=PROGRAMMER_NONE; +static unsigned char BURN_BUFFER_LOC data_buf[65536 + 2048]; +static enum PROGRAMMER_STATE programmer_state = PROGRAMMER_NONE; /* static unsigned int count_set_bits(unsigned int i) @@ -1981,315 +1913,288 @@ static unsigned int count_set_bits(unsigned int i) } */ -static int send_burn_data_reply(enum ERR_CODE code, unsigned short sec_seq, unsigned char seq) -{ - int ret = 0; - enum MSG_TYPE type = TYPE_INVALID; +static int send_burn_data_reply(enum ERR_CODE code, unsigned short sec_seq, + unsigned char seq) { + int ret = 0; + enum MSG_TYPE type = TYPE_INVALID; + + if (programmer_state == PROGRAMMER_ERASE_BURN_START) { + type = TYPE_ERASE_BURN_DATA; + } + + send_msg.hdr.type = type; + send_msg.hdr.seq = recv_msg.hdr.seq; + send_msg.hdr.len = 3; + send_msg.data[0] = code; + send_msg.data[1] = sec_seq & 0xFF; + send_msg.data[2] = (sec_seq >> 8) & 0xFF; + send_msg.data[3] = + ~check_sum((unsigned char *)&send_msg, MSG_TOTAL_LEN(&send_msg) - 1); + + send_msg_push_seq = send_msg_push_seq % MAX_SNED_MSG_QUEUE; + send_msg_queue[send_msg_push_seq] = send_msg; + send_msg_push_seq++; + + // ret = send_data((unsigned char *)&send_msg, MSG_TOTAL_LEN(&send_msg)); + return ret; +} + +int anc_cmd_receve_process(uint8_t *buf, uint32_t len) { + enum MSG_TYPE type; + enum ERR_CODE errcode = ERR_NONE; + unsigned char cret = ERR_NONE; + + if (len > sizeof(recv_msg)) { + memcpy(&recv_msg, buf, sizeof(recv_msg)); + } else { + memcpy(&recv_msg, buf, len); + } + // Checksum + if (check_sum((unsigned char *)&recv_msg, MSG_TOTAL_LEN(&recv_msg)) != 0xFF) { + trace_stage_info("Checksum error"); + return ERR_CHECKSUM; + } + type = recv_msg.hdr.type; + + // TRACE(1,"COMMAND:0x%x",type); + + switch (type) { + case TYPE_SYS: { + TRACE(0, "SYS CMD"); + break; + } + case TYPE_READ: { + unsigned int addr; + unsigned int len; + + trace_stage_info("READ CMD"); + + addr = recv_msg.data[0] | (recv_msg.data[1] << 8) | + (recv_msg.data[2] << 16) | (recv_msg.data[3] << 24); + len = recv_msg.data[4]; + + TRACE(2, "addr:0x%x,len:%d", addr, len); + + errcode = handle_read_cmd(type, addr, len); + if (errcode != ERR_NONE) { + return errcode; + } + break; + } + case TYPE_WRITE: { + unsigned int addr; + unsigned int len; + unsigned char *wdata; + + // trace_stage_info("WRITE CMD"); + + addr = recv_msg.data[0] | (recv_msg.data[1] << 8) | + (recv_msg.data[2] << 16) | (recv_msg.data[3] << 24); + len = recv_msg.hdr.len - 4; + wdata = &recv_msg.data[4]; + + errcode = handle_write_cmd(addr, len, wdata); + if (errcode != ERR_NONE) { + return errcode; + } + break; + } + case TYPE_ERASE_BURN_START: { + TRACE(0, "TYPE_ERASE_BURN_START CMD"); + + if (programmer_state == PROGRAMMER_NONE) { + trace_stage_info("ERASE_BURN_START"); + + burn_addr = recv_msg.data[0] | (recv_msg.data[1] << 8) | + (recv_msg.data[2] << 16) | (recv_msg.data[3] << 24); + burn_total_len = recv_msg.data[4] | (recv_msg.data[5] << 8) | + (recv_msg.data[6] << 16) | (recv_msg.data[7] << 24); + sector_size = recv_msg.data[8] | (recv_msg.data[9] << 8) | + (recv_msg.data[10] << 16) | (recv_msg.data[11] << 24); + + TRACE(3, "burn_addr=0x%08X burn_total_len=%u sector_size=%u", burn_addr, + burn_total_len, sector_size); + + /*if ((size_mask & sector_size) == 0 || count_set_bits(sector_size) != 1) + { + TRACE(2,"Unsupported sector_size=0x%08X mask=0x%08X", sector_size, + size_mask); return ERR_SECTOR_SIZE; + }*/ + + sector_cnt = burn_total_len / sector_size; + last_sector_len = burn_total_len % sector_size; + + if (last_sector_len) { + sector_cnt++; + } else { + last_sector_len = sector_size; + } + + if (sector_cnt > 0xFFFF) { + TRACE(1, "Sector seq overflow: %u", sector_cnt); + return ERR_SECTOR_SEQ_OVERFLOW; + } + + send_reply(&cret, 1); + + if (burn_total_len == 0) { + TRACE(0, "Burn length = 0"); + break; + } + + programmer_state = PROGRAMMER_ERASE_BURN_START; + + burn_len = 0; + + trace_stage_info("ERASE_BURN_START end"); + } else { + TRACE(1, "ERROR programmer_state status:%d", programmer_state); + } + break; + } + case TYPE_ERASE_BURN_DATA: { if (programmer_state == PROGRAMMER_ERASE_BURN_START) { - type = TYPE_ERASE_BURN_DATA; + unsigned int dlen; + unsigned int mcrc; + unsigned int crc; + + dlen = recv_msg.data[0] | (recv_msg.data[1] << 8) | + (recv_msg.data[2] << 16) | (recv_msg.data[3] << 24); + mcrc = recv_msg.data[4] | (recv_msg.data[5] << 8) | + (recv_msg.data[6] << 16) | (recv_msg.data[7] << 24); + + cur_sector_seq = recv_msg.data[8] | (recv_msg.data[9] << 8); + + TRACE(2, " sec_seq=%u dlen=%u", cur_sector_seq, dlen); + + if (cur_sector_seq >= sector_cnt) { + TRACE(2, "Bad sector seq: sec_seq=%u sector_cnt=%u", cur_sector_seq, + sector_cnt); + send_burn_data_reply(ERR_SECTOR_SEQ, cur_sector_seq, recv_msg.hdr.seq); + return ERR_NONE; + } + + if (((cur_sector_seq + 1) == sector_cnt && dlen != last_sector_len) || + ((cur_sector_seq + 1) != sector_cnt && dlen != sector_size)) { + TRACE(2, " Bad data len: sec_seq=%u dlen=%u", cur_sector_seq, dlen); + send_burn_data_reply(ERR_SECTOR_DATA_LEN, cur_sector_seq, + recv_msg.hdr.seq); + return ERR_NONE; + } + + crc = crc32(0, (unsigned char *)&buf[BURN_DATA_MSG_OVERHEAD], dlen); + if (crc != mcrc) { + TRACE(0, "Bad CRC"); + send_burn_data_reply(ERR_SECTOR_DATA_CRC, cur_sector_seq, + recv_msg.hdr.seq); + return ERR_NONE; + } + + if (burn_len + dlen <= burn_total_len) { + memcpy(&data_buf[burn_len], + (unsigned char *)&buf[BURN_DATA_MSG_OVERHEAD], dlen); + burn_len = burn_len + dlen; + } else { + TRACE(2, "Error burn_len=%d,burn_total_len=%d", burn_len, + burn_total_len); + } + + if (burn_len == burn_total_len) { + TRACE(2, "BURN_DATA addr=0x%08X len=%u .........................", + burn_addr, burn_total_len); + int ret = burn_data(burn_addr, data_buf, burn_total_len); + if (ret) { + TRACE(2, "### FLASH_TASK: BURN_DATA failed: addr=0x%08X len=%u ###", + burn_addr, burn_total_len); + return 0; + } else { + TRACE(0, "burn sucessful"); + } + ret = verify_flash_data(burn_addr, data_buf, burn_total_len); + if (ret) { + TRACE(0, "verify failed"); + return ERR_VERIFY_FLSH; + } else { + TRACE(0, "verify sucessful"); + } + } + + send_burn_data_reply(ERR_BURN_OK, cur_sector_seq, recv_msg.hdr.seq); + + } else { + TRACE(1, "ERROR programmer_state status:%d", programmer_state); + } + break; + } + case TYPE_FLASH_CMD: { + trace_stage_info("FLASH CMD"); + + errcode = handle_flash_cmd((enum FLASH_CMD_TYPE)recv_msg.data[0], + &recv_msg.data[1], recv_msg.hdr.len - 1); + + TRACE_TIME(1, "FLASH CMD ret=%d", errcode); + + if (errcode != ERR_NONE) { + return errcode; + } + break; + } + case TYPE_GET_SECTOR_INFO: { + unsigned int addr; + + trace_stage_info("GET SECTOR INFO"); + + addr = recv_msg.data[0] | (recv_msg.data[1] << 8) | + (recv_msg.data[2] << 16) | (recv_msg.data[3] << 24); + + errcode = handle_sector_info_cmd(addr); + if (errcode != ERR_NONE) { + return errcode; + } + break; + } + case TYPE_PROD_TEST: { + uint32_t cmd; + + trace_stage_info("ANC CMD"); + + cmd = recv_msg.data[0] | (recv_msg.data[1] << 8) | + (recv_msg.data[2] << 16) | (recv_msg.data[3] << 24); + if (cmd != PROD_TEST_CMD_ANC) { + return ERR_TYPE_INVALID; } - send_msg.hdr.type = type; - send_msg.hdr.seq = recv_msg.hdr.seq; - send_msg.hdr.len = 3; - send_msg.data[0] = code; - send_msg.data[1] = sec_seq & 0xFF; - send_msg.data[2] = (sec_seq >> 8) & 0xFF; - send_msg.data[3] = ~check_sum((unsigned char *)&send_msg, MSG_TOTAL_LEN(&send_msg) - 1); + if (recv_msg.hdr.len < 5) { + TRACE(1, "PROD_TEST/ANC msg length error: %d", recv_msg.hdr.len); + return ERR_LEN; + } - send_msg_push_seq=send_msg_push_seq%MAX_SNED_MSG_QUEUE; - send_msg_queue[send_msg_push_seq]=send_msg; - send_msg_push_seq++; + errcode = handle_anc_cmd(recv_msg.data[4], &recv_msg.data[5], + recv_msg.hdr.len - 5); + if (errcode != ERR_NONE) { + return errcode; + } - //ret = send_data((unsigned char *)&send_msg, MSG_TOTAL_LEN(&send_msg)); - return ret; + break; + } + default: + TRACE(1, "COMMAND:0x%x", type); + + cret = ERR_TYPE_INVALID; + send_reply((unsigned char *)&cret, 1); + break; + } + + return 0; } +int anc_cmd_send_process(uint8_t **pbuf, uint16_t *len) { -int anc_cmd_receve_process(uint8_t *buf,uint32_t len) -{ - enum MSG_TYPE type; - enum ERR_CODE errcode=ERR_NONE; - unsigned char cret = ERR_NONE; + send_msg_pop_seq = send_msg_pop_seq % MAX_SNED_MSG_QUEUE; + *pbuf = (uint8_t *)&send_msg_queue[send_msg_pop_seq]; + *len = MSG_TOTAL_LEN(&send_msg); + send_msg_pop_seq++; - if(len>sizeof(recv_msg)) - { - memcpy(&recv_msg,buf,sizeof(recv_msg)); - } - else - { - memcpy(&recv_msg,buf,len); - } - // Checksum - if (check_sum((unsigned char *)&recv_msg, MSG_TOTAL_LEN(&recv_msg)) != 0xFF) { - trace_stage_info("Checksum error"); - return ERR_CHECKSUM; - } - type = recv_msg.hdr.type; - - //TRACE(1,"COMMAND:0x%x",type); - - switch (type) { - case TYPE_SYS: - { - TRACE(0,"SYS CMD"); - break; - } - case TYPE_READ: - { - unsigned int addr; - unsigned int len; - - trace_stage_info("READ CMD"); - - addr = recv_msg.data[0] | (recv_msg.data[1] << 8) | (recv_msg.data[2] << 16) | (recv_msg.data[3] << 24); - len = recv_msg.data[4]; - - TRACE(2,"addr:0x%x,len:%d",addr,len); - - errcode = handle_read_cmd(type, addr, len); - if (errcode != ERR_NONE) { - return errcode; - } - break; - } - case TYPE_WRITE: - { - unsigned int addr; - unsigned int len; - unsigned char *wdata; - - // trace_stage_info("WRITE CMD"); - - addr = recv_msg.data[0] | (recv_msg.data[1] << 8) | (recv_msg.data[2] << 16) | (recv_msg.data[3] << 24); - len = recv_msg.hdr.len - 4; - wdata = &recv_msg.data[4]; - - errcode = handle_write_cmd(addr, len, wdata); - if (errcode != ERR_NONE) { - return errcode; - } - break; - } - case TYPE_ERASE_BURN_START: - { - TRACE(0,"TYPE_ERASE_BURN_START CMD"); - - if(programmer_state == PROGRAMMER_NONE) - { - trace_stage_info("ERASE_BURN_START"); - - burn_addr = recv_msg.data[0] | (recv_msg.data[1] << 8) | (recv_msg.data[2] << 16) | (recv_msg.data[3] << 24); - burn_total_len = recv_msg.data[4] | (recv_msg.data[5] << 8) | (recv_msg.data[6] << 16) | (recv_msg.data[7] << 24); - sector_size = recv_msg.data[8] | (recv_msg.data[9] << 8) | (recv_msg.data[10] << 16) | (recv_msg.data[11] << 24); - - TRACE(3,"burn_addr=0x%08X burn_total_len=%u sector_size=%u", burn_addr, burn_total_len, sector_size); - - /*if ((size_mask & sector_size) == 0 || count_set_bits(sector_size) != 1) - { - TRACE(2,"Unsupported sector_size=0x%08X mask=0x%08X", sector_size, size_mask); - return ERR_SECTOR_SIZE; - }*/ - - sector_cnt = burn_total_len / sector_size; - last_sector_len = burn_total_len % sector_size; - - if (last_sector_len) - { - sector_cnt++; - } - else - { - last_sector_len = sector_size; - } - - if (sector_cnt > 0xFFFF) - { - TRACE(1,"Sector seq overflow: %u", sector_cnt); - return ERR_SECTOR_SEQ_OVERFLOW; - } - - send_reply(&cret, 1); - - if (burn_total_len == 0) { - TRACE(0,"Burn length = 0"); - break; - } - - programmer_state = PROGRAMMER_ERASE_BURN_START; - - burn_len=0; - - - trace_stage_info("ERASE_BURN_START end"); - } - else - { - TRACE(1,"ERROR programmer_state status:%d",programmer_state); - } - break; - } - case TYPE_ERASE_BURN_DATA: - { - - if(programmer_state == PROGRAMMER_ERASE_BURN_START) - { - unsigned int dlen; - unsigned int mcrc; - unsigned int crc; - - dlen = recv_msg.data[0] | (recv_msg.data[1] << 8) | (recv_msg.data[2] << 16) | (recv_msg.data[3] << 24); - mcrc = recv_msg.data[4] | (recv_msg.data[5] << 8) | (recv_msg.data[6] << 16) | (recv_msg.data[7] << 24); - - cur_sector_seq = recv_msg.data[8] | (recv_msg.data[9] << 8); - - TRACE(2," sec_seq=%u dlen=%u", cur_sector_seq, dlen); - - if (cur_sector_seq >= sector_cnt) { - TRACE(2,"Bad sector seq: sec_seq=%u sector_cnt=%u", cur_sector_seq, sector_cnt); - send_burn_data_reply(ERR_SECTOR_SEQ, cur_sector_seq, recv_msg.hdr.seq); - return ERR_NONE; - } - - if (((cur_sector_seq + 1) == sector_cnt && dlen != last_sector_len) || - ((cur_sector_seq + 1) != sector_cnt && dlen != sector_size)) { - TRACE(2," Bad data len: sec_seq=%u dlen=%u", cur_sector_seq, dlen); - send_burn_data_reply(ERR_SECTOR_DATA_LEN, cur_sector_seq, recv_msg.hdr.seq); - return ERR_NONE; - } - - crc = crc32(0, (unsigned char *)&buf[BURN_DATA_MSG_OVERHEAD], dlen); - if (crc != mcrc) - { - TRACE(0,"Bad CRC"); - send_burn_data_reply(ERR_SECTOR_DATA_CRC, cur_sector_seq, recv_msg.hdr.seq); - return ERR_NONE; - } - - if(burn_len+dlen<=burn_total_len) - { - memcpy(&data_buf[burn_len],(unsigned char *)&buf[BURN_DATA_MSG_OVERHEAD], dlen); - burn_len=burn_len+dlen; - } - else - { - TRACE(2,"Error burn_len=%d,burn_total_len=%d", burn_len, burn_total_len); - } - - if(burn_len==burn_total_len) - { - TRACE(2,"BURN_DATA addr=0x%08X len=%u .........................", burn_addr, burn_total_len); - int ret=burn_data(burn_addr,data_buf,burn_total_len); - if (ret) - { - TRACE(2,"### FLASH_TASK: BURN_DATA failed: addr=0x%08X len=%u ###", burn_addr, burn_total_len); - return 0; - } - else - { - TRACE(0,"burn sucessful"); - } - ret = verify_flash_data(burn_addr,data_buf,burn_total_len); - if (ret) - { - TRACE(0,"verify failed"); - return ERR_VERIFY_FLSH; - } - else - { - TRACE(0,"verify sucessful"); - } - - } - - send_burn_data_reply(ERR_BURN_OK,cur_sector_seq,recv_msg.hdr.seq); - - } - else - { - TRACE(1,"ERROR programmer_state status:%d",programmer_state); - } - break; - } - case TYPE_FLASH_CMD: - { - trace_stage_info("FLASH CMD"); - - errcode = handle_flash_cmd((enum FLASH_CMD_TYPE)recv_msg.data[0], &recv_msg.data[1], recv_msg.hdr.len - 1); - - TRACE_TIME(1,"FLASH CMD ret=%d", errcode); - - if (errcode != ERR_NONE) { - return errcode; - } - break; - } - case TYPE_GET_SECTOR_INFO: - { - unsigned int addr; - - trace_stage_info("GET SECTOR INFO"); - - addr = recv_msg.data[0] | (recv_msg.data[1] << 8) | (recv_msg.data[2] << 16) | (recv_msg.data[3] << 24); - - errcode = handle_sector_info_cmd(addr); - if (errcode != ERR_NONE) { - return errcode; - } - break; - } - case TYPE_PROD_TEST: { - uint32_t cmd; - - trace_stage_info("ANC CMD"); - - cmd = recv_msg.data[0] | (recv_msg.data[1] << 8) | (recv_msg.data[2] << 16) | (recv_msg.data[3] << 24); - if (cmd != PROD_TEST_CMD_ANC) { - return ERR_TYPE_INVALID; - } - - if (recv_msg.hdr.len < 5) { - TRACE(1,"PROD_TEST/ANC msg length error: %d", recv_msg.hdr.len); - return ERR_LEN; - } - - errcode = handle_anc_cmd(recv_msg.data[4], &recv_msg.data[5], recv_msg.hdr.len - 5); - if (errcode != ERR_NONE) { - return errcode; - } - - break; - } - default: - TRACE(1,"COMMAND:0x%x",type); - - cret = ERR_TYPE_INVALID; - send_reply((unsigned char *)&cret, 1); - break; - - } - - - return 0; -} -int anc_cmd_send_process(uint8_t **pbuf,uint16_t *len) -{ - - - send_msg_pop_seq=send_msg_pop_seq%MAX_SNED_MSG_QUEUE; - *pbuf = (uint8_t *)&send_msg_queue[send_msg_pop_seq]; - *len = MSG_TOTAL_LEN(&send_msg); - send_msg_pop_seq++; - - return 0; + return 0; } #endif - - - - - - - - - diff --git a/services/multimedia/audio/process/filters/cfg/eq_cfg.c b/services/multimedia/audio/process/filters/cfg/eq_cfg.c index d07ffba..b690566 100644 --- a/services/multimedia/audio/process/filters/cfg/eq_cfg.c +++ b/services/multimedia/audio/process/filters/cfg/eq_cfg.c @@ -13,409 +13,419 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" -#include "tgt_hardware.h" -#include "filter_debug_trace.h" -#include "iir_process.h" #include "eq_cfg.h" +#include "filter_debug_trace.h" #include "hw_codec_iir_process.h" #include "hw_iir_process.h" +#include "iir_process.h" #include "math.h" +#include "plat_types.h" +#include "tgt_hardware.h" -#define IIR_FIXED_Q (1<<27) +#define IIR_FIXED_Q (1 << 27) -#define PI (3.14159265358979) +#define PI (3.14159265358979) -static HW_CODEC_IIR_CFG_T hw_codec_iir_eq; -static HW_IIR_CFG_T hw_iir_eq; +static HW_CODEC_IIR_CFG_T hw_codec_iir_eq; +static HW_IIR_CFG_T hw_iir_eq; -void iir_lowshelf_coefs_generate(float gain, float fn, float Q, float *coefs) -{ - float A = (float)sqrtf(powf(10, gain / 20)); - float w0 = 2 * PI*fn; - float alpha = (float)sinf(w0)/(2*Q); +void iir_lowshelf_coefs_generate(float gain, float fn, float Q, float *coefs) { + float A = (float)sqrtf(powf(10, gain / 20)); + float w0 = 2 * PI * fn; + float alpha = (float)sinf(w0) / (2 * Q); - float a0 = (A + 1) + (A - 1)*(float)cosf(w0) + 2 * (float)sqrtf(A)*alpha; - float a1 = (-2 * ((A - 1) + (A + 1)*(float)cosf(w0))); - float a2 = ((A + 1) + (A - 1)*(float)cosf(w0) - 2 * (float)sqrtf(A)*alpha); - float b0 = (A*((A + 1) - (A - 1)*(float)cosf(w0) + 2 *(float)sqrtf(A)*alpha)); - float b1 = (2 * A*((A - 1) - (A + 1)*(float)cosf(w0))); - float b2 = (A*((A + 1) - (A - 1)*(float)cosf(w0) - 2 * (float)sqrtf(A)*alpha)); + float a0 = (A + 1) + (A - 1) * (float)cosf(w0) + 2 * (float)sqrtf(A) * alpha; + float a1 = (-2 * ((A - 1) + (A + 1) * (float)cosf(w0))); + float a2 = + ((A + 1) + (A - 1) * (float)cosf(w0) - 2 * (float)sqrtf(A) * alpha); + float b0 = + (A * ((A + 1) - (A - 1) * (float)cosf(w0) + 2 * (float)sqrtf(A) * alpha)); + float b1 = (2 * A * ((A - 1) - (A + 1) * (float)cosf(w0))); + float b2 = + (A * ((A + 1) - (A - 1) * (float)cosf(w0) - 2 * (float)sqrtf(A) * alpha)); - coefs[0] = 1; - coefs[1] = a1 / a0; - coefs[2] = a2 / a0; - coefs[3] = b0 / a0; - coefs[4] = b1 / a0; - coefs[5] = b2 / a0; + coefs[0] = 1; + coefs[1] = a1 / a0; + coefs[2] = a2 / a0; + coefs[3] = b0 / a0; + coefs[4] = b1 / a0; + coefs[5] = b2 / a0; -// IIR_TRACE(6,"fn = %f, gain = %f, Q = %f, A = %f, w0 = %f, alpha = %f", fn, gain, Q, A, w0, alpha); -// FILTER_DEBUG_TRACE(7,"[%s] %f, %f, %f, %f, %f, %f", __func__, (double)coefs[0], (double)coefs[1], (double)coefs[2], (double)coefs[3], (double)coefs[4], (double)coefs[5]); + // IIR_TRACE(6,"fn = %f, gain = %f, Q = %f, A = %f, w0 = %f, alpha = %f", + // fn, gain, Q, A, w0, alpha); FILTER_DEBUG_TRACE(7,"[%s] %f, %f, %f, %f, + // %f, %f", __func__, (double)coefs[0], (double)coefs[1], (double)coefs[2], + // (double)coefs[3], (double)coefs[4], (double)coefs[5]); } -void iir_highshelf_coefs_generate(float gain, float fn, float Q, float *coefs) -{ - float A = (float)sqrtf(powf(10, gain / 20)); - float w0 = 2 * PI*fn; - float alpha = (float)sinf(w0) / (2 * Q); +void iir_highshelf_coefs_generate(float gain, float fn, float Q, float *coefs) { + float A = (float)sqrtf(powf(10, gain / 20)); + float w0 = 2 * PI * fn; + float alpha = (float)sinf(w0) / (2 * Q); - float a0 = (A + 1) - (A - 1)*(float)cosf(w0) + 2 * (float)sqrtf(A)*alpha; // a0 - float a1 = (2 * ((A - 1) - (A + 1)*(float)cosf(w0))); // a1 - float a2 = ((A + 1) - (A - 1)*(float)cosf(w0) - 2 * (float)sqrtf(A)*alpha); //a2 - float b0 = (A*((A + 1) + (A - 1)*(float)cosf(w0) + 2 * (float)sqrtf(A)*alpha)); //b0 - float b1 = (-2 * A*((A - 1) + (A + 1)*(float)cosf(w0))); // b1 - float b2 = (A*((A + 1) + (A - 1)*(float)cosf(w0) - 2 * (float)sqrtf(A)*alpha)); // b2 + float a0 = + (A + 1) - (A - 1) * (float)cosf(w0) + 2 * (float)sqrtf(A) * alpha; // a0 + float a1 = (2 * ((A - 1) - (A + 1) * (float)cosf(w0))); // a1 + float a2 = + ((A + 1) - (A - 1) * (float)cosf(w0) - 2 * (float)sqrtf(A) * alpha); // a2 + float b0 = (A * ((A + 1) + (A - 1) * (float)cosf(w0) + + 2 * (float)sqrtf(A) * alpha)); // b0 + float b1 = (-2 * A * ((A - 1) + (A + 1) * (float)cosf(w0))); // b1 + float b2 = (A * ((A + 1) + (A - 1) * (float)cosf(w0) - + 2 * (float)sqrtf(A) * alpha)); // b2 - coefs[0] = 1; - coefs[1] = a1 / a0; - coefs[2] = a2 / a0; - coefs[3] = b0 / a0; - coefs[4] = b1 / a0; - coefs[5] = b2 / a0; + coefs[0] = 1; + coefs[1] = a1 / a0; + coefs[2] = a2 / a0; + coefs[3] = b0 / a0; + coefs[4] = b1 / a0; + coefs[5] = b2 / a0; -// IIR_TRACE(6,"fn = %f, gain = %f, Q = %f, A = %f, w0 = %f, alpha = %f", fn, gain, Q, A, w0, alpha); - // FILTER_DEBUG_TRACE(7,"[%s] %f, %f, %f, %f, %f, %f", __func__, (double)coefs[0], (double)coefs[1], (double)coefs[2], (double)coefs[3], (double)coefs[4], (double)coefs[5]); + // IIR_TRACE(6,"fn = %f, gain = %f, Q = %f, A = %f, w0 = %f, alpha = %f", + // fn, gain, Q, A, w0, alpha); + // FILTER_DEBUG_TRACE(7,"[%s] %f, %f, %f, %f, %f, %f", __func__, + // (double)coefs[0], (double)coefs[1], (double)coefs[2], (double)coefs[3], + // (double)coefs[4], (double)coefs[5]); } // fn: Normalized frequency -void iir_peak_notch_coefs_generate(float gain, float fn, float Q, float *coefs) -{ -// float Fs = 1000.0 / 48000.0; -// float gain = -5.0; -// float fo = 1000.0; -// float Q = 0.7; - float A = (float)sqrtf(powf(10, gain/20)); - float w0 = 2*PI*fn; - float alpha = (float)sinf(w0)/(2*Q); +void iir_peak_notch_coefs_generate(float gain, float fn, float Q, + float *coefs) { + // float Fs = 1000.0 / 48000.0; + // float gain = -5.0; + // float fo = 1000.0; + // float Q = 0.7; + float A = (float)sqrtf(powf(10, gain / 20)); + float w0 = 2 * PI * fn; + float alpha = (float)sinf(w0) / (2 * Q); - float a0 = 1 + alpha/A; - float a1 = -2*(float)cosf(w0); - float a2 = 1 - alpha/A; - float b0 = 1 + alpha*A; - float b1 = -2*(float)cosf(w0); - float b2 = 1 - alpha*A; + float a0 = 1 + alpha / A; + float a1 = -2 * (float)cosf(w0); + float a2 = 1 - alpha / A; + float b0 = 1 + alpha * A; + float b1 = -2 * (float)cosf(w0); + float b2 = 1 - alpha * A; + coefs[0] = 1; + coefs[1] = a1 / a0; + coefs[2] = a2 / a0; + coefs[3] = b0 / a0; + coefs[4] = b1 / a0; + coefs[5] = b2 / a0; + + // IIR_TRACE(6,"fn = %f, gain = %f, Q = %f, A = %f, w0 = %f, alpha = %f", + // fn, gain, Q, A, w0, alpha); + // FILTER_DEBUG_TRACE(7,"[%s] %f, %f, %f, %f, %f, %f", __func__, + // (double)coefs[0], (double)coefs[1], (double)coefs[2], (double)coefs[3], + // (double)coefs[4], (double)coefs[5]); +} + +void iir_highpass_coefs_generate(float gain, float fn, float Q, float *coefs) { + float w0 = 2 * PI * fn; + float alpha = (float)sinf(w0) / (2 * Q); + + float a0 = 1 + alpha; + float a1 = -2 * (float)cosf(w0); + float a2 = 1 - alpha; + float b0 = (1 + (float)cosf(w0)) / 2; + float b1 = -(1 + (float)cosf(w0)); + float b2 = (1 + (float)cosf(w0)) / 2; + + coefs[0] = 1; + coefs[1] = a1 / a0; + coefs[2] = a2 / a0; + coefs[3] = b0 / a0; + coefs[4] = b1 / a0; + coefs[5] = b2 / a0; +} + +void iir_lowspass_coefs_generate(float gain, float fn, float Q, float *coefs) { + float w0 = 2 * PI * fn; + float alpha = (float)sinf(w0) / (2 * Q); + + float a0 = 1 + alpha; + float a1 = -2 * (float)cosf(w0); + float a2 = 1 - alpha; + float b0 = (1 - (float)cosf(w0)) / 2; + float b1 = 1 - (float)cosf(w0); + float b2 = (1 - (float)cosf(w0)) / 2; + + coefs[0] = 1; + coefs[1] = a1 / a0; + coefs[2] = a2 / a0; + coefs[3] = b0 / a0; + coefs[4] = b1 / a0; + coefs[5] = b2 / a0; +} + +float iir_convert_db_to_multiple(float db) { return (float)powf(10, db / 20); } + +void iir_coefs_generate(IIR_TYPE_T type, float gain, float fn, float Q, + float *coefs) { + // As it is meaningless to set an eq at or above fs/2, just skip it when we + // receive such request. + if (fn >= 0.5f) { coefs[0] = 1; - coefs[1] = a1 / a0; - coefs[2] = a2 / a0; - coefs[3] = b0 / a0; - coefs[4] = b1 / a0; - coefs[5] = b2 / a0; + coefs[1] = 0; + coefs[2] = 0; + coefs[3] = 1; + coefs[4] = 0; + coefs[5] = 0; -// IIR_TRACE(6,"fn = %f, gain = %f, Q = %f, A = %f, w0 = %f, alpha = %f", fn, gain, Q, A, w0, alpha); - // FILTER_DEBUG_TRACE(7,"[%s] %f, %f, %f, %f, %f, %f", __func__, (double)coefs[0], (double)coefs[1], (double)coefs[2], (double)coefs[3], (double)coefs[4], (double)coefs[5]); + FILTER_DEBUG_TRACE( + 1, "[%s] center frequency is above nyquist frequency, skip this band", + __FUNCTION__); + return; + } + + if (type == IIR_TYPE_LOW_SHELF) { + iir_lowshelf_coefs_generate(gain, fn, Q, coefs); + } else if (type == IIR_TYPE_PEAK) { + iir_peak_notch_coefs_generate(gain, fn, Q, coefs); + } else if (type == IIR_TYPE_HIGH_SHELF) { + iir_highshelf_coefs_generate(gain, fn, Q, coefs); + } else if (type == IIR_TYPE_LOW_PASS) { + iir_lowspass_coefs_generate(gain, fn, Q, coefs); + } else if (type == IIR_TYPE_HIGH_PASS) { + iir_highpass_coefs_generate(gain, fn, Q, coefs); + } else { + ASSERT(false, "[%s] %d is not supported", __func__, type); + } } -void iir_highpass_coefs_generate(float gain, float fn, float Q, float *coefs) -{ - float w0 = 2 * PI*fn; - float alpha = (float)sinf(w0) / (2 * Q); +HW_CODEC_IIR_CFG_T *hw_codec_iir_get_cfg(enum AUD_SAMPRATE_T sample_rate, + const IIR_CFG_T *ext_cfg) { + const IIR_CFG_T *cfg; + float coefs_l[6], coefs_r[6]; + float gain0, gain1; + int sample_rate_iir = sample_rate; - float a0 = 1 + alpha; - float a1 = -2 * (float)cosf(w0); - float a2 = 1 - alpha; - float b0 = (1 + (float)cosf(w0))/2; - float b1 = -(1 + (float)cosf(w0)); - float b2 = (1 + (float)cosf(w0))/2; - - coefs[0] = 1; - coefs[1] = a1/a0; - coefs[2] = a2/a0; - coefs[3] = b0/a0; - coefs[4] = b1/a0; - coefs[5] = b2/a0; -} - -void iir_lowspass_coefs_generate(float gain, float fn, float Q, float *coefs) -{ - float w0 = 2 * PI*fn; - float alpha = (float)sinf(w0) / (2 * Q); - - float a0 = 1 + alpha; - float a1 = -2 * (float)cosf(w0); - float a2 = 1 - alpha; - float b0 = (1 - (float)cosf(w0))/2; - float b1 = 1 - (float)cosf(w0); - float b2 = (1 - (float)cosf(w0))/2; - - coefs[0] = 1; - coefs[1] = a1/a0; - coefs[2] = a2/a0; - coefs[3] = b0/a0; - coefs[4] = b1/a0; - coefs[5] = b2/a0; -} - -float iir_convert_db_to_multiple(float db) -{ - return (float)powf(10, db/20); -} - -void iir_coefs_generate(IIR_TYPE_T type, float gain, float fn, float Q, float *coefs) -{ - // As it is meaningless to set an eq at or above fs/2, just skip it when we receive - // such request. - if (fn >= 0.5f) - { - coefs[0] = 1; - coefs[1] = 0; - coefs[2] = 0; - coefs[3] = 1; - coefs[4] = 0; - coefs[5] = 0; - - FILTER_DEBUG_TRACE(1,"[%s] center frequency is above nyquist frequency, skip this band", __FUNCTION__); - return; - } - - if (type == IIR_TYPE_LOW_SHELF) - { - iir_lowshelf_coefs_generate(gain, fn, Q, coefs); - } - else if (type == IIR_TYPE_PEAK) - { - iir_peak_notch_coefs_generate(gain, fn, Q, coefs); - } - else if (type == IIR_TYPE_HIGH_SHELF) - { - iir_highshelf_coefs_generate(gain, fn, Q, coefs); - } - else if (type == IIR_TYPE_LOW_PASS) - { - iir_lowspass_coefs_generate(gain, fn, Q, coefs); - } - else if (type == IIR_TYPE_HIGH_PASS) - { - iir_highpass_coefs_generate(gain, fn, Q, coefs); - } - else - { - ASSERT(false, "[%s] %d is not supported", __func__, type); - } -} - -HW_CODEC_IIR_CFG_T *hw_codec_iir_get_cfg(enum AUD_SAMPRATE_T sample_rate, const IIR_CFG_T *ext_cfg) -{ - const IIR_CFG_T *cfg; - float coefs_l[6],coefs_r[6]; - float gain0,gain1; - int sample_rate_iir=sample_rate; - #if defined(CHIP_BEST2001) #ifdef __AUDIO_RESAMPLE__ - sample_rate_iir=50781.25f*8; + sample_rate_iir = 50781.25f * 8; #else - switch(sample_rate) - { - case AUD_SAMPRATE_22050: - case AUD_SAMPRATE_44100: - case AUD_SAMPRATE_88200: - case AUD_SAMPRATE_176400: - case AUD_SAMPRATE_352800: - case AUD_SAMPRATE_705600: - sample_rate_iir=44100*8; - break; + switch (sample_rate) { + case AUD_SAMPRATE_22050: + case AUD_SAMPRATE_44100: + case AUD_SAMPRATE_88200: + case AUD_SAMPRATE_176400: + case AUD_SAMPRATE_352800: + case AUD_SAMPRATE_705600: + sample_rate_iir = 44100 * 8; + break; - default: - sample_rate_iir=48000*8 ; - break; - }; + default: + sample_rate_iir = 48000 * 8; + break; + }; #endif #endif - FILTER_DEBUG_TRACE(2,"%s,sample_rate:%d\n", __func__,sample_rate_iir); + FILTER_DEBUG_TRACE(2, "%s,sample_rate:%d\n", __func__, sample_rate_iir); - hw_codec_iir_eq.iir_filtes_l.iir_bypass_flag=1; - hw_codec_iir_eq.iir_filtes_r.iir_bypass_flag=1; + hw_codec_iir_eq.iir_filtes_l.iir_bypass_flag = 1; + hw_codec_iir_eq.iir_filtes_r.iir_bypass_flag = 1; - if (ext_cfg) - { - cfg = ext_cfg; - } - else - { - FILTER_DEBUG_TRACE(0,"Error HW IIR CODEC cfg!"); - return NULL; + if (ext_cfg) { + cfg = ext_cfg; + } else { + FILTER_DEBUG_TRACE(0, "Error HW IIR CODEC cfg!"); + return NULL; + } + + // Check parameter + ASSERT(cfg->num <= AUD_DAC_IIR_NUM_EQ, "[%s] num(%d) is too large", __func__, + cfg->num); + + gain0 = iir_convert_db_to_multiple(cfg->gain0); + gain1 = iir_convert_db_to_multiple(cfg->gain1); + + // FILTER_DEBUG_TRACE(3,"[%s] gain0 = %f, gain1 = %f", __func__, + // (double)gain0, (double)gain1); + FILTER_DEBUG_TRACE(2, "[%s] len = %d", __func__, cfg->num); + + for (int i = 0; i < cfg->num; i++) { + if (cfg->param[i].fc < sample_rate_iir / 2) { + iir_coefs_generate(cfg->param[i].type, cfg->param[i].gain, + cfg->param[i].fc / sample_rate_iir, cfg->param[i].Q, + coefs_l); + } else { + FILTER_DEBUG_TRACE(2, "[%s]Error iir parameters i = %d", __func__, i); + coefs_l[0] = 1.0f; + coefs_l[1] = 0.0f; + coefs_l[2] = 0.0f; + coefs_l[3] = 1.0f; + coefs_l[4] = 0.0f; + coefs_l[5] = 0.0f; } - // Check parameter - ASSERT(cfg->num <= AUD_DAC_IIR_NUM_EQ, "[%s] num(%d) is too large", __func__, cfg->num); + coefs_r[0] = coefs_l[0]; + coefs_r[1] = coefs_l[1]; + coefs_r[2] = coefs_l[2]; + coefs_r[3] = coefs_l[3]; + coefs_r[4] = coefs_l[4]; + coefs_r[5] = coefs_l[5]; - gain0 = iir_convert_db_to_multiple(cfg->gain0); - gain1 = iir_convert_db_to_multiple(cfg->gain1); - - // FILTER_DEBUG_TRACE(3,"[%s] gain0 = %f, gain1 = %f", __func__, (double)gain0, (double)gain1); - FILTER_DEBUG_TRACE(2,"[%s] len = %d", __func__, cfg->num); - - for(int i=0; inum; i++) - { - if (cfg->param[i].fcparam[i].type, - cfg->param[i].gain, - cfg->param[i].fc / sample_rate_iir, - cfg->param[i].Q, - coefs_l); - } - else - { - FILTER_DEBUG_TRACE(2,"[%s]Error iir parameters i = %d", __func__, i); - coefs_l[0]=1.0f; - coefs_l[1]=0.0f; - coefs_l[2]=0.0f; - coefs_l[3]=1.0f; - coefs_l[4]=0.0f; - coefs_l[5]=0.0f; - } - - coefs_r[0]=coefs_l[0]; - coefs_r[1]=coefs_l[1]; - coefs_r[2]=coefs_l[2]; - coefs_r[3]=coefs_l[3]; - coefs_r[4]=coefs_l[4]; - coefs_r[5]=coefs_l[5]; - - if(i==0) - { - coefs_l[3] = coefs_l[3]*gain0; - coefs_l[4] = coefs_l[4]*gain0; - coefs_l[5] = coefs_l[5]*gain0; - - coefs_r[3] = coefs_r[3]*gain1; - coefs_r[4] = coefs_r[4]*gain1; - coefs_r[5] = coefs_r[5]*gain1; - } - - hw_codec_iir_eq.iir_filtes_l.iir_coef[i].coef_a[0]=(int32_t)((double)coefs_l[0]*(int32_t)IIR_FIXED_Q); - hw_codec_iir_eq.iir_filtes_l.iir_coef[i].coef_a[1]=(int32_t)((double)coefs_l[1]*(int32_t)IIR_FIXED_Q); - hw_codec_iir_eq.iir_filtes_l.iir_coef[i].coef_a[2]=(int32_t)((double)coefs_l[2]*(int32_t)IIR_FIXED_Q); - hw_codec_iir_eq.iir_filtes_l.iir_coef[i].coef_b[0]=(int32_t)((double)coefs_l[3]*(int32_t)IIR_FIXED_Q); - hw_codec_iir_eq.iir_filtes_l.iir_coef[i].coef_b[1]=(int32_t)((double)coefs_l[4]*(int32_t)IIR_FIXED_Q); - hw_codec_iir_eq.iir_filtes_l.iir_coef[i].coef_b[2]=(int32_t)((double)coefs_l[5]*(int32_t)IIR_FIXED_Q); - - hw_codec_iir_eq.iir_filtes_r.iir_coef[i].coef_a[0]=(int32_t)((double)coefs_r[0]*(int32_t)IIR_FIXED_Q); - hw_codec_iir_eq.iir_filtes_r.iir_coef[i].coef_a[1]=(int32_t)((double)coefs_r[1]*(int32_t)IIR_FIXED_Q); - hw_codec_iir_eq.iir_filtes_r.iir_coef[i].coef_a[2]=(int32_t)((double)coefs_r[2]*(int32_t)IIR_FIXED_Q); - hw_codec_iir_eq.iir_filtes_r.iir_coef[i].coef_b[0]=(int32_t)((double)coefs_r[3]*(int32_t)IIR_FIXED_Q); - hw_codec_iir_eq.iir_filtes_r.iir_coef[i].coef_b[1]=(int32_t)((double)coefs_r[4]*(int32_t)IIR_FIXED_Q); - hw_codec_iir_eq.iir_filtes_r.iir_coef[i].coef_b[2]=(int32_t)((double)coefs_r[5]*(int32_t)IIR_FIXED_Q); + if (i == 0) { + coefs_l[3] = coefs_l[3] * gain0; + coefs_l[4] = coefs_l[4] * gain0; + coefs_l[5] = coefs_l[5] * gain0; + coefs_r[3] = coefs_r[3] * gain1; + coefs_r[4] = coefs_r[4] * gain1; + coefs_r[5] = coefs_r[5] * gain1; } - /* - FILTER_DEBUG_TRACE(2,"\n[%s] coef_a = %d\n", __func__, hw_codec_iir_eq.iir_filtes_l.iir_coef[0].coef_a[0]); - FILTER_DEBUG_TRACE(2,"[%s] coef_a = %d\n", __func__, hw_codec_iir_eq.iir_filtes_l.iir_coef[0].coef_a[1]); - FILTER_DEBUG_TRACE(2,"[%s] coef_a = %d\n", __func__, hw_codec_iir_eq.iir_filtes_l.iir_coef[0].coef_a[2]); - FILTER_DEBUG_TRACE(2,"[%s] coef_a = %d\n", __func__, hw_codec_iir_eq.iir_filtes_l.iir_coef[0].coef_b[0]); - FILTER_DEBUG_TRACE(2,"[%s] coef_a = %d\n", __func__, hw_codec_iir_eq.iir_filtes_l.iir_coef[0].coef_b[1]); - FILTER_DEBUG_TRACE(2,"[%s] coef_a = %d\n", __func__, hw_codec_iir_eq.iir_filtes_l.iir_coef[0].coef_b[2]); - */ - if(cfg->num>=0) - { - hw_codec_iir_eq.iir_filtes_l.iir_bypass_flag=0; - hw_codec_iir_eq.iir_filtes_r.iir_bypass_flag=0; + hw_codec_iir_eq.iir_filtes_l.iir_coef[i].coef_a[0] = + (int32_t)((double)coefs_l[0] * (int32_t)IIR_FIXED_Q); + hw_codec_iir_eq.iir_filtes_l.iir_coef[i].coef_a[1] = + (int32_t)((double)coefs_l[1] * (int32_t)IIR_FIXED_Q); + hw_codec_iir_eq.iir_filtes_l.iir_coef[i].coef_a[2] = + (int32_t)((double)coefs_l[2] * (int32_t)IIR_FIXED_Q); + hw_codec_iir_eq.iir_filtes_l.iir_coef[i].coef_b[0] = + (int32_t)((double)coefs_l[3] * (int32_t)IIR_FIXED_Q); + hw_codec_iir_eq.iir_filtes_l.iir_coef[i].coef_b[1] = + (int32_t)((double)coefs_l[4] * (int32_t)IIR_FIXED_Q); + hw_codec_iir_eq.iir_filtes_l.iir_coef[i].coef_b[2] = + (int32_t)((double)coefs_l[5] * (int32_t)IIR_FIXED_Q); - hw_codec_iir_eq.iir_filtes_l.iir_counter=cfg->num; - hw_codec_iir_eq.iir_filtes_r.iir_counter=cfg->num; - } + hw_codec_iir_eq.iir_filtes_r.iir_coef[i].coef_a[0] = + (int32_t)((double)coefs_r[0] * (int32_t)IIR_FIXED_Q); + hw_codec_iir_eq.iir_filtes_r.iir_coef[i].coef_a[1] = + (int32_t)((double)coefs_r[1] * (int32_t)IIR_FIXED_Q); + hw_codec_iir_eq.iir_filtes_r.iir_coef[i].coef_a[2] = + (int32_t)((double)coefs_r[2] * (int32_t)IIR_FIXED_Q); + hw_codec_iir_eq.iir_filtes_r.iir_coef[i].coef_b[0] = + (int32_t)((double)coefs_r[3] * (int32_t)IIR_FIXED_Q); + hw_codec_iir_eq.iir_filtes_r.iir_coef[i].coef_b[1] = + (int32_t)((double)coefs_r[4] * (int32_t)IIR_FIXED_Q); + hw_codec_iir_eq.iir_filtes_r.iir_coef[i].coef_b[2] = + (int32_t)((double)coefs_r[5] * (int32_t)IIR_FIXED_Q); + } - return &hw_codec_iir_eq; + /* + FILTER_DEBUG_TRACE(2,"\n[%s] coef_a = %d\n", __func__, + hw_codec_iir_eq.iir_filtes_l.iir_coef[0].coef_a[0]); + FILTER_DEBUG_TRACE(2,"[%s] coef_a = %d\n", __func__, + hw_codec_iir_eq.iir_filtes_l.iir_coef[0].coef_a[1]); + FILTER_DEBUG_TRACE(2,"[%s] coef_a = %d\n", __func__, + hw_codec_iir_eq.iir_filtes_l.iir_coef[0].coef_a[2]); + FILTER_DEBUG_TRACE(2,"[%s] coef_a = %d\n", __func__, + hw_codec_iir_eq.iir_filtes_l.iir_coef[0].coef_b[0]); + FILTER_DEBUG_TRACE(2,"[%s] coef_a = %d\n", __func__, + hw_codec_iir_eq.iir_filtes_l.iir_coef[0].coef_b[1]); + FILTER_DEBUG_TRACE(2,"[%s] coef_a = %d\n", __func__, + hw_codec_iir_eq.iir_filtes_l.iir_coef[0].coef_b[2]); + */ + if (cfg->num >= 0) { + hw_codec_iir_eq.iir_filtes_l.iir_bypass_flag = 0; + hw_codec_iir_eq.iir_filtes_r.iir_bypass_flag = 0; + + hw_codec_iir_eq.iir_filtes_l.iir_counter = cfg->num; + hw_codec_iir_eq.iir_filtes_r.iir_counter = cfg->num; + } + + return &hw_codec_iir_eq; } -HW_IIR_CFG_T *hw_iir_get_cfg(enum AUD_SAMPRATE_T sample_rate, const IIR_CFG_T* ext_cfg) -{ - const IIR_CFG_T *cfg; - float coefs_l[6],coefs_r[6]; - float gain0,gain1; +HW_IIR_CFG_T *hw_iir_get_cfg(enum AUD_SAMPRATE_T sample_rate, + const IIR_CFG_T *ext_cfg) { + const IIR_CFG_T *cfg; + float coefs_l[6], coefs_r[6]; + float gain0, gain1; - if (ext_cfg) - { - cfg = ext_cfg; - } - else - { - FILTER_DEBUG_TRACE(0,"Error HW IIR cfg!"); - return NULL; + if (ext_cfg) { + cfg = ext_cfg; + } else { + FILTER_DEBUG_TRACE(0, "Error HW IIR cfg!"); + return NULL; + } + + FILTER_DEBUG_TRACE(3, "[%s]sample_rate:%d,iir num:%d.", __func__, sample_rate, + cfg->num); + + // Check parameter + ASSERT(cfg->num <= AUD_IIR_NUM_EQ, "[%s] num(%d) is too large", __func__, + cfg->num); + + gain0 = iir_convert_db_to_multiple(cfg->gain0); + gain1 = iir_convert_db_to_multiple(cfg->gain1); + + // FILTER_DEBUG_TRACE(3,"[%s] gain0 = %f, gain1 = %f", __func__, + // (double)gain0, (double)gain1); + + for (int i = 0; i < cfg->num; i++) { + if (cfg->param[i].fc < sample_rate / 2) { + iir_coefs_generate(cfg->param[i].type, cfg->param[i].gain, + cfg->param[i].fc / sample_rate, cfg->param[i].Q, + coefs_l); + } else { + FILTER_DEBUG_TRACE(2, "[%s]Error iir parameters i = %d", __func__, i); + coefs_l[0] = 1.0f; + coefs_l[1] = 0.0f; + coefs_l[2] = 0.0f; + coefs_l[3] = 1.0f; + coefs_l[4] = 0.0f; + coefs_l[5] = 0.0f; } - FILTER_DEBUG_TRACE(3,"[%s]sample_rate:%d,iir num:%d.", __func__,sample_rate,cfg->num); + coefs_r[0] = coefs_l[0]; + coefs_r[1] = coefs_l[1]; + coefs_r[2] = coefs_l[2]; + coefs_r[3] = coefs_l[3]; + coefs_r[4] = coefs_l[4]; + coefs_r[5] = coefs_l[5]; - // Check parameter - ASSERT(cfg->num <= AUD_IIR_NUM_EQ, "[%s] num(%d) is too large", __func__, cfg->num); - - gain0 = iir_convert_db_to_multiple(cfg->gain0); - gain1 = iir_convert_db_to_multiple(cfg->gain1); - - // FILTER_DEBUG_TRACE(3,"[%s] gain0 = %f, gain1 = %f", __func__, (double)gain0, (double)gain1); - - for(int i=0; inum; i++) - { - if (cfg->param[i].fcparam[i].type, - cfg->param[i].gain, - cfg->param[i].fc / sample_rate, - cfg->param[i].Q, - coefs_l); - } - else - { - FILTER_DEBUG_TRACE(2,"[%s]Error iir parameters i = %d", __func__, i); - coefs_l[0]=1.0f; - coefs_l[1]=0.0f; - coefs_l[2]=0.0f; - coefs_l[3]=1.0f; - coefs_l[4]=0.0f; - coefs_l[5]=0.0f; - } - - coefs_r[0]=coefs_l[0]; - coefs_r[1]=coefs_l[1]; - coefs_r[2]=coefs_l[2]; - coefs_r[3]=coefs_l[3]; - coefs_r[4]=coefs_l[4]; - coefs_r[5]=coefs_l[5]; - - if(i==0) - { - coefs_l[3] = coefs_l[3]*gain0; - coefs_l[4] = coefs_l[4]*gain0; - coefs_l[5] = coefs_l[5]*gain0; - - coefs_r[3] = coefs_r[3]*gain1; - coefs_r[4] = coefs_r[4]*gain1; - coefs_r[5] = coefs_r[5]*gain1; - } - - hw_iir_eq.iir_filtes_l.iir_coef[i].coef_a[0]=(int32_t)((double)coefs_l[0]*(int32_t)IIR_FIXED_Q); - hw_iir_eq.iir_filtes_l.iir_coef[i].coef_a[1]=(int32_t)((double)coefs_l[1]*(int32_t)IIR_FIXED_Q); - hw_iir_eq.iir_filtes_l.iir_coef[i].coef_a[2]=(int32_t)((double)coefs_l[2]*(int32_t)IIR_FIXED_Q); - hw_iir_eq.iir_filtes_l.iir_coef[i].coef_b[0]=(int32_t)((double)coefs_l[3]*(int32_t)IIR_FIXED_Q); - hw_iir_eq.iir_filtes_l.iir_coef[i].coef_b[1]=(int32_t)((double)coefs_l[4]*(int32_t)IIR_FIXED_Q); - hw_iir_eq.iir_filtes_l.iir_coef[i].coef_b[2]=(int32_t)((double)coefs_l[5]*(int32_t)IIR_FIXED_Q); - - hw_iir_eq.iir_filtes_r.iir_coef[i].coef_a[0]=(int32_t)((double)coefs_r[0]*(int32_t)IIR_FIXED_Q); - hw_iir_eq.iir_filtes_r.iir_coef[i].coef_a[1]=(int32_t)((double)coefs_r[1]*(int32_t)IIR_FIXED_Q); - hw_iir_eq.iir_filtes_r.iir_coef[i].coef_a[2]=(int32_t)((double)coefs_r[2]*(int32_t)IIR_FIXED_Q); - hw_iir_eq.iir_filtes_r.iir_coef[i].coef_b[0]=(int32_t)((double)coefs_r[3]*(int32_t)IIR_FIXED_Q); - hw_iir_eq.iir_filtes_r.iir_coef[i].coef_b[1]=(int32_t)((double)coefs_r[4]*(int32_t)IIR_FIXED_Q); - hw_iir_eq.iir_filtes_r.iir_coef[i].coef_b[2]=(int32_t)((double)coefs_r[5]*(int32_t)IIR_FIXED_Q); + if (i == 0) { + coefs_l[3] = coefs_l[3] * gain0; + coefs_l[4] = coefs_l[4] * gain0; + coefs_l[5] = coefs_l[5] * gain0; + coefs_r[3] = coefs_r[3] * gain1; + coefs_r[4] = coefs_r[4] * gain1; + coefs_r[5] = coefs_r[5] * gain1; } -/* - FILTER_DEBUG_TRACE(2,"\n[%s] coef_a0 = %d\n", __func__, hw_iir_eq.iir_filtes_l.iir_coef[0].coef_a[0]); - FILTER_DEBUG_TRACE(2,"[%s] coef_a1 = %d\n", __func__, hw_iir_eq.iir_filtes_l.iir_coef[0].coef_a[1]); - FILTER_DEBUG_TRACE(2,"[%s] coef_a2 = %d\n", __func__, hw_iir_eq.iir_filtes_l.iir_coef[0].coef_a[2]); - FILTER_DEBUG_TRACE(2,"[%s] coef_b0 = %d\n", __func__, hw_iir_eq.iir_filtes_l.iir_coef[0].coef_b[0]); - FILTER_DEBUG_TRACE(2,"[%s] coef_b1 = %d\n", __func__, hw_iir_eq.iir_filtes_l.iir_coef[0].coef_b[1]); - FILTER_DEBUG_TRACE(2,"[%s] coef_b2 = %d\n", __func__, hw_iir_eq.iir_filtes_l.iir_coef[0].coef_b[2]); -*/ - if(cfg->num>=0) - { - hw_iir_eq.iir_filtes_l.iir_counter=cfg->num; - hw_iir_eq.iir_filtes_r.iir_counter=cfg->num; - } + hw_iir_eq.iir_filtes_l.iir_coef[i].coef_a[0] = + (int32_t)((double)coefs_l[0] * (int32_t)IIR_FIXED_Q); + hw_iir_eq.iir_filtes_l.iir_coef[i].coef_a[1] = + (int32_t)((double)coefs_l[1] * (int32_t)IIR_FIXED_Q); + hw_iir_eq.iir_filtes_l.iir_coef[i].coef_a[2] = + (int32_t)((double)coefs_l[2] * (int32_t)IIR_FIXED_Q); + hw_iir_eq.iir_filtes_l.iir_coef[i].coef_b[0] = + (int32_t)((double)coefs_l[3] * (int32_t)IIR_FIXED_Q); + hw_iir_eq.iir_filtes_l.iir_coef[i].coef_b[1] = + (int32_t)((double)coefs_l[4] * (int32_t)IIR_FIXED_Q); + hw_iir_eq.iir_filtes_l.iir_coef[i].coef_b[2] = + (int32_t)((double)coefs_l[5] * (int32_t)IIR_FIXED_Q); - return &hw_iir_eq; + hw_iir_eq.iir_filtes_r.iir_coef[i].coef_a[0] = + (int32_t)((double)coefs_r[0] * (int32_t)IIR_FIXED_Q); + hw_iir_eq.iir_filtes_r.iir_coef[i].coef_a[1] = + (int32_t)((double)coefs_r[1] * (int32_t)IIR_FIXED_Q); + hw_iir_eq.iir_filtes_r.iir_coef[i].coef_a[2] = + (int32_t)((double)coefs_r[2] * (int32_t)IIR_FIXED_Q); + hw_iir_eq.iir_filtes_r.iir_coef[i].coef_b[0] = + (int32_t)((double)coefs_r[3] * (int32_t)IIR_FIXED_Q); + hw_iir_eq.iir_filtes_r.iir_coef[i].coef_b[1] = + (int32_t)((double)coefs_r[4] * (int32_t)IIR_FIXED_Q); + hw_iir_eq.iir_filtes_r.iir_coef[i].coef_b[2] = + (int32_t)((double)coefs_r[5] * (int32_t)IIR_FIXED_Q); + } + + /* + FILTER_DEBUG_TRACE(2,"\n[%s] coef_a0 = %d\n", __func__, + hw_iir_eq.iir_filtes_l.iir_coef[0].coef_a[0]); FILTER_DEBUG_TRACE(2,"[%s] + coef_a1 = %d\n", __func__, hw_iir_eq.iir_filtes_l.iir_coef[0].coef_a[1]); + FILTER_DEBUG_TRACE(2,"[%s] coef_a2 = %d\n", __func__, + hw_iir_eq.iir_filtes_l.iir_coef[0].coef_a[2]); FILTER_DEBUG_TRACE(2,"[%s] + coef_b0 = %d\n", __func__, hw_iir_eq.iir_filtes_l.iir_coef[0].coef_b[0]); + FILTER_DEBUG_TRACE(2,"[%s] coef_b1 = %d\n", __func__, + hw_iir_eq.iir_filtes_l.iir_coef[0].coef_b[1]); FILTER_DEBUG_TRACE(2,"[%s] + coef_b2 = %d\n", __func__, hw_iir_eq.iir_filtes_l.iir_coef[0].coef_b[2]); + */ + if (cfg->num >= 0) { + hw_iir_eq.iir_filtes_l.iir_counter = cfg->num; + hw_iir_eq.iir_filtes_r.iir_counter = cfg->num; + } + + return &hw_iir_eq; } - diff --git a/services/multimedia/audio/process/filters/cfg/eq_cfg.h b/services/multimedia/audio/process/filters/cfg/eq_cfg.h index 3cd87f8..c288bdb 100644 --- a/services/multimedia/audio/process/filters/cfg/eq_cfg.h +++ b/services/multimedia/audio/process/filters/cfg/eq_cfg.h @@ -15,7 +15,7 @@ ****************************************************************************/ #ifndef __FIR_PROCESS_H__ #define __FIR_PROCESS_H__ - +#include "iir_process.h" #ifdef __cplusplus extern "C" { #endif @@ -32,7 +32,8 @@ void iir_lowspass_coefs_generate(float gain, float fn, float Q, float *coefs); float iir_convert_db_to_multiple(float db); -void iir_coefs_generate(IIR_TYPE_T type, float gain, float fn, float Q, float *coefs); +void iir_coefs_generate(IIR_TYPE_T type, float gain, float fn, float Q, + float *coefs); #ifdef __cplusplus } diff --git a/services/multimedia/audio/process/resample/coef/resample_coef.c b/services/multimedia/audio/process/resample/coef/resample_coef.c index 5429aee..984dfb6 100644 --- a/services/multimedia/audio/process/resample/coef/resample_coef.c +++ b/services/multimedia/audio/process/resample/coef/resample_coef.c @@ -13,14 +13,14 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" -#include "hal_location.h" #include "resample_coef.h" +#include "hal_location.h" +#include "plat_types.h" -#define COEF_DEF(n) FLASH_RODATA_DEF(n) +#define COEF_DEF(n) FLASH_RODATA_DEF(n) static const int16_t COEF_DEF(filter_50p7k_to_48k)[] = { - #include "resample_50p7k_to_48k_filter.txt" +#include "resample_50p7k_to_48k_filter.txt" }; const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_50p7k_to_48k) = { .upsample_factor = 69, @@ -31,7 +31,7 @@ const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_50p7k_to_48k) = { }; static const int16_t COEF_DEF(filter_50p7k_to_44p1k)[] = { - #include "resample_50p7k_to_44p1k_filter.txt" +#include "resample_50p7k_to_44p1k_filter.txt" }; const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_50p7k_to_44p1k) = { .upsample_factor = 33, @@ -42,7 +42,7 @@ const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_50p7k_to_44p1k) = { }; static const int16_t COEF_DEF(filter_44p1k_to_48k)[] = { - #include "resample_44p1k_to_48k_filter.txt" +#include "resample_44p1k_to_48k_filter.txt" }; const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_44p1k_to_48k) = { .upsample_factor = 160, @@ -53,7 +53,7 @@ const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_44p1k_to_48k) = { }; static const int16_t COEF_DEF(filter_48k_to_44p1k)[] = { - #include "resample_48k_to_44p1k_filter.txt" +#include "resample_48k_to_44p1k_filter.txt" }; const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_48k_to_44p1k) = { .upsample_factor = 147, @@ -64,7 +64,7 @@ const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_48k_to_44p1k) = { }; static const int16_t COEF_DEF(filter_32k_to_50p7k)[] = { - #include "resample_32k_to_50p7k_filter.txt" +#include "resample_32k_to_50p7k_filter.txt" }; const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_32k_to_50p7k) = { .upsample_factor = 73, @@ -75,7 +75,7 @@ const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_32k_to_50p7k) = { }; static const int16_t COEF_DEF(filter_44p1k_to_50p7k)[] = { - #include "resample_44p1k_to_50p7k_filter.txt" +#include "resample_44p1k_to_50p7k_filter.txt" }; const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_44p1k_to_50p7k) = { .upsample_factor = 38, @@ -86,7 +86,7 @@ const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_44p1k_to_50p7k) = { }; static const int16_t COEF_DEF(filter_48k_to_50p7k)[] = { - #include "resample_48k_to_50p7k_filter.txt" +#include "resample_48k_to_50p7k_filter.txt" }; const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_48k_to_50p7k) = { .upsample_factor = 73, @@ -97,7 +97,7 @@ const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_48k_to_50p7k) = { }; static const int16_t COEF_DEF(filter_8k_to_8p4k)[] = { - #include "resample_8k_to_8p4k_filter.txt" +#include "resample_8k_to_8p4k_filter.txt" }; const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_8k_to_8p4k) = { .upsample_factor = 73, @@ -108,7 +108,7 @@ const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_8k_to_8p4k) = { }; static const int16_t COEF_DEF(filter_8p4k_to_8k)[] = { - #include "resample_8p4k_to_8k_filter.txt" +#include "resample_8p4k_to_8k_filter.txt" }; const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_8p4k_to_8k) = { .upsample_factor = 69, @@ -119,7 +119,7 @@ const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_8p4k_to_8k) = { }; static const int16_t COEF_DEF(filter_16k_to_48k)[] = { - #include "resample_16k_to_48k_filter.txt" +#include "resample_16k_to_48k_filter.txt" }; const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_16k_to_48k) = { .upsample_factor = 3, @@ -131,7 +131,7 @@ const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_16k_to_48k) = { #ifdef RESAMPLE_ANY_SAMPLE_RATE static const int16_t COEF_DEF(filter_any_up64)[] = { - #include "resample_any_up64_filter.txt" +#include "resample_any_up64_filter.txt" }; const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_any_up64) = { .upsample_factor = 64, @@ -142,7 +142,7 @@ const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_any_up64) = { }; static const int16_t COEF_DEF(filter_any_up256)[] = { - #include "resample_any_up256_filter.txt" +#include "resample_any_up256_filter.txt" }; const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_any_up256) = { .upsample_factor = 256, @@ -153,7 +153,7 @@ const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_any_up256) = { }; static const int16_t COEF_DEF(filter_any_up512_32)[] = { - #include "resample_any_up512_32_filter.txt" +#include "resample_any_up512_32_filter.txt" }; const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_any_up512_32) = { .upsample_factor = 512, @@ -164,7 +164,7 @@ const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_any_up512_32) = { }; static const int16_t COEF_DEF(filter_any_up512_36)[] = { - #include "resample_any_up512_36_filter.txt" +#include "resample_any_up512_36_filter.txt" }; const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_any_up512_36) = { .upsample_factor = 512, @@ -174,4 +174,3 @@ const struct RESAMPLE_COEF_T COEF_DEF(resample_coef_any_up512_36) = { .coef_group = filter_any_up512_36, }; #endif - diff --git a/services/norflash_api/norflash_api.cpp b/services/norflash_api/norflash_api.cpp index 1dd28f6..a04ca81 100644 --- a/services/norflash_api/norflash_api.cpp +++ b/services/norflash_api/norflash_api.cpp @@ -1,350 +1,304 @@ +#include "cmsis.h" #include "stdio.h" #include "string.h" -#include "cmsis.h" #ifdef RTOS #include "cmsis_os.h" #else #include "hal_timer.h" #endif -#include "pmu.h" +#include "hal_norflash.h" #include "hal_sleep.h" #include "hal_trace.h" -#include "hal_norflash.h" #include "norflash_api.h" +#include "pmu.h" #if 0 -#define NORFLASH_API_TRACE(str,...) TRACE(str, ##__VA_ARGS__) +#define NORFLASH_API_TRACE(str, ...) TRACE(str, ##__VA_ARGS__) #else -#define NORFLASH_API_TRACE(str,...) +#define NORFLASH_API_TRACE(str, ...) #endif -#define API_IS_ALIGN(v,size) (((v/size)*size) == v) +#define API_IS_ALIGN(v, size) (((v / size) * size) == v) -static NORFLASH_API_INFO norflash_api_info = {false,}; +static NORFLASH_API_INFO norflash_api_info = { + false, +}; static OPERA_INFO_LIST opera_info_list[NORFLASH_API_OPRA_LIST_LEN]; -static DATA_LIST data_list[NORFLASH_API_WRITE_BUFF_LEN]; +static DATA_LIST data_list[NORFLASH_API_WRITE_BUFF_LEN]; static int suspend_number = 0; -static void* _norflash_api_malloc(uint32_t size) -{ - uint32_t i; +static void *_norflash_api_malloc(uint32_t size) { + uint32_t i; - if(size == sizeof(OPRA_INFO)) - { - for(i = 0; i < NORFLASH_API_OPRA_LIST_LEN; i++) - { - if(opera_info_list[i].is_used == false) - { - opera_info_list[i].is_used = true; - return (void*)&opera_info_list[i].opera_info; - } - } - return NULL; - } - else if(size == NORFLASH_API_SECTOR_SIZE) - { - for(i = 0; i < NORFLASH_API_WRITE_BUFF_LEN; i++) - { - if(data_list[i].is_used == false) - { - data_list[i].is_used = true; - return (void*)data_list[i].buffer; - } - } - return NULL; - } - else - { - ASSERT(0,"%s: size(0x%x) error!", __func__, size); - } -} - -static void _norflash_api_free(void *p) -{ - uint32_t i; - - for(i = 0; i < NORFLASH_API_OPRA_LIST_LEN; i++) - { - if((uint8_t*)&opera_info_list[i].opera_info == p) - { - opera_info_list[i].is_used = false; - return; - } - } - - for(i = 0; i < NORFLASH_API_WRITE_BUFF_LEN; i++) - { - if(data_list[i].buffer == p) - { - data_list[i].is_used = false; - return; - } - } - - ASSERT(0,"%s: p(%p) error!", __func__, p); -} - -static MODULE_INFO* _get_module_info(enum NORFLASH_API_MODULE_ID_T mod_id) -{ - return &norflash_api_info.mod_info[mod_id]; -} - -static OPRA_INFO* _get_tail(MODULE_INFO *mod_info,bool is_remove) -{ - OPRA_INFO *opera_node = NULL; - OPRA_INFO *pre_node = NULL; - OPRA_INFO *tmp; - - pre_node = mod_info->opera_info; - tmp = mod_info->opera_info; - while(tmp) - { - opera_node = tmp; - tmp = opera_node->next; - if(tmp) - { - pre_node = opera_node; - } - } - if(is_remove) - { - if(pre_node) - { - pre_node->next = NULL; - } - } - if(opera_node) - { - opera_node->lock = true; - } - return opera_node; -} - -static void _opera_del(MODULE_INFO *mod_info,OPRA_INFO *node) -{ - OPRA_INFO *opera_node = NULL; - OPRA_INFO *pre_node = NULL; - OPRA_INFO *tmp; - - pre_node = mod_info->opera_info; - tmp = mod_info->opera_info; - while(tmp) - { - opera_node = tmp; - if(opera_node == node) - { - if(mod_info->opera_info == opera_node) - { - mod_info->opera_info = NULL; - } - else - { - pre_node->next = NULL; - } - if(node->buff) - { - _norflash_api_free(node->buff); - } - _norflash_api_free(node); - break; - } - tmp = opera_node->next; - if(tmp) - { - pre_node = opera_node; - } - } -} - -static uint32_t _get_ew_count(MODULE_INFO *mod_info) -{ - OPRA_INFO *opera_node = NULL; - OPRA_INFO *tmp; - uint32_t count = 0; - - tmp = mod_info->opera_info; - while(tmp) - { - opera_node = tmp; - count ++; - tmp = opera_node->next; - } - return count; -} - -static uint32_t _get_w_count(MODULE_INFO *mod_info) -{ - OPRA_INFO *opera_node = NULL; - OPRA_INFO *tmp; - uint32_t count = 0; - - tmp = mod_info->opera_info; - while(tmp) - { - opera_node = tmp; - if(opera_node->type == NORFLASH_API_WRITTING) - { - count ++; - } - tmp = opera_node->next; - } - return count; -} - -static uint32_t _get_e_count(MODULE_INFO *mod_info) -{ - OPRA_INFO *opera_node = NULL; - OPRA_INFO *tmp; - uint32_t count = 0; - - tmp = mod_info->opera_info; - while(tmp) - { - opera_node = tmp; - if(opera_node->type == NORFLASH_API_ERASING) - { - count ++; - } - tmp = opera_node->next; - } - return count; -} - -static MODULE_INFO* _get_cur_mod(void) -{ - uint32_t i; - MODULE_INFO *mod_info = NULL; - uint32_t tmp_mod_id = NORFLASH_API_MODULE_ID_COUNT; - - if(norflash_api_info.cur_mod) - { - return norflash_api_info.cur_mod; - } - - tmp_mod_id = norflash_api_info.cur_mod_id; - for(i = 0; i < NORFLASH_API_MODULE_ID_COUNT; i++) - { - tmp_mod_id = tmp_mod_id + 1 >= NORFLASH_API_MODULE_ID_COUNT ? 0 : tmp_mod_id + 1; - mod_info = _get_module_info((enum NORFLASH_API_MODULE_ID_T)tmp_mod_id); - if(mod_info->is_inited) - { - if(_get_ew_count(mod_info) > 0) - { - return mod_info; - } - } + if (size == sizeof(OPRA_INFO)) { + for (i = 0; i < NORFLASH_API_OPRA_LIST_LEN; i++) { + if (opera_info_list[i].is_used == false) { + opera_info_list[i].is_used = true; + return (void *)&opera_info_list[i].opera_info; + } } return NULL; + } else if (size == NORFLASH_API_SECTOR_SIZE) { + for (i = 0; i < NORFLASH_API_WRITE_BUFF_LEN; i++) { + if (data_list[i].is_used == false) { + data_list[i].is_used = true; + return (void *)data_list[i].buffer; + } + } + return NULL; + } else { + ASSERT(0, "%s: size(0x%x) error!", __func__, size); + } } -static enum NORFLASH_API_MODULE_ID_T _get_mod_id(MODULE_INFO *mod_info) -{ - uint32_t i; - enum NORFLASH_API_MODULE_ID_T mod_id = NORFLASH_API_MODULE_ID_COUNT; - MODULE_INFO *tmp_mod_info = NULL; +static void _norflash_api_free(void *p) { + uint32_t i; - for(i = 0; i < NORFLASH_API_MODULE_ID_COUNT; i++) - { - tmp_mod_info = _get_module_info((enum NORFLASH_API_MODULE_ID_T)i); - if(tmp_mod_info == mod_info) - { - mod_id = (enum NORFLASH_API_MODULE_ID_T)i; - break; - } + for (i = 0; i < NORFLASH_API_OPRA_LIST_LEN; i++) { + if ((uint8_t *)&opera_info_list[i].opera_info == p) { + opera_info_list[i].is_used = false; + return; } - return mod_id; + } + + for (i = 0; i < NORFLASH_API_WRITE_BUFF_LEN; i++) { + if (data_list[i].buffer == p) { + data_list[i].is_used = false; + return; + } + } + + ASSERT(0, "%s: p(%p) error!", __func__, p); +} + +static MODULE_INFO *_get_module_info(enum NORFLASH_API_MODULE_ID_T mod_id) { + return &norflash_api_info.mod_info[mod_id]; +} + +static OPRA_INFO *_get_tail(MODULE_INFO *mod_info, bool is_remove) { + OPRA_INFO *opera_node = NULL; + OPRA_INFO *pre_node = NULL; + OPRA_INFO *tmp; + + pre_node = mod_info->opera_info; + tmp = mod_info->opera_info; + while (tmp) { + opera_node = tmp; + tmp = opera_node->next; + if (tmp) { + pre_node = opera_node; + } + } + if (is_remove) { + if (pre_node) { + pre_node->next = NULL; + } + } + if (opera_node) { + opera_node->lock = true; + } + return opera_node; +} + +static void _opera_del(MODULE_INFO *mod_info, OPRA_INFO *node) { + OPRA_INFO *opera_node = NULL; + OPRA_INFO *pre_node = NULL; + OPRA_INFO *tmp; + + pre_node = mod_info->opera_info; + tmp = mod_info->opera_info; + while (tmp) { + opera_node = tmp; + if (opera_node == node) { + if (mod_info->opera_info == opera_node) { + mod_info->opera_info = NULL; + } else { + pre_node->next = NULL; + } + if (node->buff) { + _norflash_api_free(node->buff); + } + _norflash_api_free(node); + break; + } + tmp = opera_node->next; + if (tmp) { + pre_node = opera_node; + } + } +} + +static uint32_t _get_ew_count(MODULE_INFO *mod_info) { + OPRA_INFO *opera_node = NULL; + OPRA_INFO *tmp; + uint32_t count = 0; + + tmp = mod_info->opera_info; + while (tmp) { + opera_node = tmp; + count++; + tmp = opera_node->next; + } + return count; +} + +static uint32_t _get_w_count(MODULE_INFO *mod_info) { + OPRA_INFO *opera_node = NULL; + OPRA_INFO *tmp; + uint32_t count = 0; + + tmp = mod_info->opera_info; + while (tmp) { + opera_node = tmp; + if (opera_node->type == NORFLASH_API_WRITTING) { + count++; + } + tmp = opera_node->next; + } + return count; +} + +static uint32_t _get_e_count(MODULE_INFO *mod_info) { + OPRA_INFO *opera_node = NULL; + OPRA_INFO *tmp; + uint32_t count = 0; + + tmp = mod_info->opera_info; + while (tmp) { + opera_node = tmp; + if (opera_node->type == NORFLASH_API_ERASING) { + count++; + } + tmp = opera_node->next; + } + return count; +} + +static MODULE_INFO *_get_cur_mod(void) { + uint32_t i; + MODULE_INFO *mod_info = NULL; + uint32_t tmp_mod_id = NORFLASH_API_MODULE_ID_COUNT; + + if (norflash_api_info.cur_mod) { + return norflash_api_info.cur_mod; + } + + tmp_mod_id = norflash_api_info.cur_mod_id; + for (i = 0; i < NORFLASH_API_MODULE_ID_COUNT; i++) { + tmp_mod_id = + tmp_mod_id + 1 >= NORFLASH_API_MODULE_ID_COUNT ? 0 : tmp_mod_id + 1; + mod_info = _get_module_info((enum NORFLASH_API_MODULE_ID_T)tmp_mod_id); + if (mod_info->is_inited) { + if (_get_ew_count(mod_info) > 0) { + return mod_info; + } + } + } + return NULL; +} + +static enum NORFLASH_API_MODULE_ID_T _get_mod_id(MODULE_INFO *mod_info) { + uint32_t i; + enum NORFLASH_API_MODULE_ID_T mod_id = NORFLASH_API_MODULE_ID_COUNT; + MODULE_INFO *tmp_mod_info = NULL; + + for (i = 0; i < NORFLASH_API_MODULE_ID_COUNT; i++) { + tmp_mod_info = _get_module_info((enum NORFLASH_API_MODULE_ID_T)i); + if (tmp_mod_info == mod_info) { + mod_id = (enum NORFLASH_API_MODULE_ID_T)i; + break; + } + } + return mod_id; } #ifdef FLASH_REMAP -static void _flash_remap_start(enum HAL_NORFLASH_ID_T id,uint32_t addr, uint32_t len) -{ - uint32_t remap_addr; - uint32_t remap_len; - uint32_t remap_offset; - enum HAL_NORFLASH_RET_T ret; +static void _flash_remap_start(enum HAL_NORFLASH_ID_T id, uint32_t addr, + uint32_t len) { + uint32_t remap_addr; + uint32_t remap_len; + uint32_t remap_offset; + enum HAL_NORFLASH_RET_T ret; - remap_addr = OTA_CODE_OFFSET; - remap_len = OTA_REMAP_OFFSET - OTA_CODE_OFFSET; - remap_offset = OTA_REMAP_OFFSET; + remap_addr = OTA_CODE_OFFSET; + remap_len = OTA_REMAP_OFFSET - OTA_CODE_OFFSET; + remap_offset = OTA_REMAP_OFFSET; - // NORFLASH_API_TRACE(3,"%s: id = %d,addr = 0x%x,len = 0x%x.", __func__,id,addr,len); - if((addr & 0x3ffffff) + len <= (remap_addr & 0x3ffffff) || - (addr & 0x3ffffff) >= (remap_addr & 0x3ffffff) + remap_len) - { - // NORFLASH_API_TRACE(3,"%s: Not in the remap area.",__func__); - return; - } + // NORFLASH_API_TRACE(3,"%s: id = %d,addr = 0x%x,len = 0x%x.", + // __func__,id,addr,len); + if ((addr & 0x3ffffff) + len <= (remap_addr & 0x3ffffff) || + (addr & 0x3ffffff) >= (remap_addr & 0x3ffffff) + remap_len) { + // NORFLASH_API_TRACE(3,"%s: Not in the remap area.",__func__); + return; + } - if(((addr & 0x3ffffff) < (remap_addr & 0x3ffffff) && + if (((addr & 0x3ffffff) < (remap_addr & 0x3ffffff) && (addr & 0x3ffffff) + len > (remap_addr & 0x3ffffff)) || - ((addr & 0x3ffffff) < (remap_addr & 0x3ffffff) + remap_len && - (addr & 0x3ffffff) + len > (remap_addr & 0x3ffffff) + remap_len)) - { - ASSERT(0,"%s: Address ranges bad!addr = 0x%x, len=0x%x,remap_addr=0x%x,remap_len=0x%x", - __func__, addr, len, remap_addr, remap_len); - } + ((addr & 0x3ffffff) < (remap_addr & 0x3ffffff) + remap_len && + (addr & 0x3ffffff) + len > (remap_addr & 0x3ffffff) + remap_len)) { + ASSERT(0, + "%s: Address ranges bad!addr = 0x%x, " + "len=0x%x,remap_addr=0x%x,remap_len=0x%x", + __func__, addr, len, remap_addr, remap_len); + } - if(!hal_norflash_get_remap_status(id)) - { - // NORFLASH_API_TRACE(3,"%s: Unremap to enable remap.",__func__); - ret = hal_norflash_enable_remap(id, remap_addr, remap_len, remap_offset); - ASSERT(ret == HAL_NORFLASH_OK, "%s: Failed to enable remap(0x%x,0x%x,0x%x), ret = %d", - __func__, remap_addr, remap_len, remap_offset, ret); - } - else - { - // NORFLASH_API_TRACE(3,"%s: Remaped to disable remap.",__func__); - ret = hal_norflash_disable_remap(id); - ASSERT(ret == HAL_NORFLASH_OK, "%s: Failed to disable remap, ret = %d", - __func__, ret); - } + if (!hal_norflash_get_remap_status(id)) { + // NORFLASH_API_TRACE(3,"%s: Unremap to enable remap.",__func__); + ret = hal_norflash_enable_remap(id, remap_addr, remap_len, remap_offset); + ASSERT(ret == HAL_NORFLASH_OK, + "%s: Failed to enable remap(0x%x,0x%x,0x%x), ret = %d", __func__, + remap_addr, remap_len, remap_offset, ret); + } else { + // NORFLASH_API_TRACE(3,"%s: Remaped to disable remap.",__func__); + ret = hal_norflash_disable_remap(id); + ASSERT(ret == HAL_NORFLASH_OK, "%s: Failed to disable remap, ret = %d", + __func__, ret); + } } -static void _flash_remap_done(enum HAL_NORFLASH_ID_T id,uint32_t addr, uint32_t len) -{ - uint32_t remap_addr; - uint32_t remap_len; - uint32_t remap_offset; - enum HAL_NORFLASH_RET_T ret; +static void _flash_remap_done(enum HAL_NORFLASH_ID_T id, uint32_t addr, + uint32_t len) { + uint32_t remap_addr; + uint32_t remap_len; + uint32_t remap_offset; + enum HAL_NORFLASH_RET_T ret; - remap_addr = OTA_CODE_OFFSET; - remap_len = OTA_REMAP_OFFSET - OTA_CODE_OFFSET; - remap_offset = OTA_REMAP_OFFSET; + remap_addr = OTA_CODE_OFFSET; + remap_len = OTA_REMAP_OFFSET - OTA_CODE_OFFSET; + remap_offset = OTA_REMAP_OFFSET; - // NORFLASH_API_TRACE(3, "%s: id = %d,addr = 0x%x,len = 0x%x.", __func__,id,addr,len); - if((addr & 0x3ffffff) + len <= (remap_addr & 0x3ffffff) || - (addr & 0x3ffffff) >= (remap_addr & 0x3ffffff) + remap_len) - { - // NORFLASH_API_TRACE(3,"%s: Not in the remap area.",__func__); - return; - } + // NORFLASH_API_TRACE(3, "%s: id = %d,addr = 0x%x,len = 0x%x.", + // __func__,id,addr,len); + if ((addr & 0x3ffffff) + len <= (remap_addr & 0x3ffffff) || + (addr & 0x3ffffff) >= (remap_addr & 0x3ffffff) + remap_len) { + // NORFLASH_API_TRACE(3,"%s: Not in the remap area.",__func__); + return; + } - if(((addr & 0x3ffffff) < (remap_addr & 0x3ffffff) && + if (((addr & 0x3ffffff) < (remap_addr & 0x3ffffff) && (addr & 0x3ffffff) + len > (remap_addr & 0x3ffffff)) || - ((addr & 0x3ffffff) < (remap_addr & 0x3ffffff) + remap_len && - (addr & 0x3ffffff) + len > (remap_addr & 0x3ffffff) + remap_len)) - { - ASSERT(0,"%s: Address ranges bad!addr = 0x%x, len=0x%x,remap_addr=0x%x,remap_len=0x%x", - __func__, addr, len, remap_addr, remap_len); - } + ((addr & 0x3ffffff) < (remap_addr & 0x3ffffff) + remap_len && + (addr & 0x3ffffff) + len > (remap_addr & 0x3ffffff) + remap_len)) { + ASSERT(0, + "%s: Address ranges bad!addr = 0x%x, " + "len=0x%x,remap_addr=0x%x,remap_len=0x%x", + __func__, addr, len, remap_addr, remap_len); + } - if(!hal_norflash_get_remap_status(id)) - { - // NORFLASH_API_TRACE(3, "%s: Unremap to enable remap.",__func__); - ret = hal_norflash_enable_remap(id, remap_addr, remap_len, remap_offset); - ASSERT(ret == HAL_NORFLASH_OK, "%s: Failed to enable remap(0x%x,0x%x,0x%x), ret = %d", - __func__, remap_addr, remap_len, remap_offset, ret); - } - else - { - // NORFLASH_API_TRACE(3, "%s: Remaped to disable remap.",__func__); - ret = hal_norflash_disable_remap(id); - ASSERT(ret == HAL_NORFLASH_OK, "%s: Failed to disable remap, ret = %d", - __func__, ret); - } + if (!hal_norflash_get_remap_status(id)) { + // NORFLASH_API_TRACE(3, "%s: Unremap to enable remap.",__func__); + ret = hal_norflash_enable_remap(id, remap_addr, remap_len, remap_offset); + ASSERT(ret == HAL_NORFLASH_OK, + "%s: Failed to enable remap(0x%x,0x%x,0x%x), ret = %d", __func__, + remap_addr, remap_len, remap_offset, ret); + } else { + // NORFLASH_API_TRACE(3, "%s: Remaped to disable remap.",__func__); + ret = hal_norflash_disable_remap(id); + ASSERT(ret == HAL_NORFLASH_OK, "%s: Failed to disable remap, ret = %d", + __func__, ret); + } } - #define FLASH_REMAP_START _flash_remap_start #define FLASH_REMAP_DONE _flash_remap_done #else @@ -352,1314 +306,1086 @@ static void _flash_remap_done(enum HAL_NORFLASH_ID_T id,uint32_t addr, uint32_t #define FLASH_REMAP_DONE(...) #endif -static int32_t _opera_read(MODULE_INFO *mod_info, - uint32_t addr, - uint8_t *buff, - uint32_t len) -{ - OPRA_INFO *opera_node = NULL; - OPRA_INFO *e_node = NULL; - OPRA_INFO *w_node = NULL; - OPRA_INFO *tmp; - uint32_t r_offs; - uint32_t sec_start; - uint32_t sec_len; +static int32_t _opera_read(MODULE_INFO *mod_info, uint32_t addr, uint8_t *buff, + uint32_t len) { + OPRA_INFO *opera_node = NULL; + OPRA_INFO *e_node = NULL; + OPRA_INFO *w_node = NULL; + OPRA_INFO *tmp; + uint32_t r_offs; + uint32_t sec_start; + uint32_t sec_len; - sec_len = mod_info->mod_sector_len; - sec_start = (addr/sec_len)*sec_len; - tmp = mod_info->opera_info; - while(tmp) - { - opera_node = tmp; - tmp = opera_node->next; - if(opera_node->addr == sec_start) - { - if(opera_node->type == NORFLASH_API_WRITTING) - { - w_node = opera_node; - break; - } - else - { - e_node = opera_node; - break; - } - } + sec_len = mod_info->mod_sector_len; + sec_start = (addr / sec_len) * sec_len; + tmp = mod_info->opera_info; + while (tmp) { + opera_node = tmp; + tmp = opera_node->next; + if (opera_node->addr == sec_start) { + if (opera_node->type == NORFLASH_API_WRITTING) { + w_node = opera_node; + break; + } else { + e_node = opera_node; + break; + } } + } - if(w_node) - { - r_offs = addr - sec_start; - memcpy(buff,w_node->buff + r_offs,len); + if (w_node) { + r_offs = addr - sec_start; + memcpy(buff, w_node->buff + r_offs, len); + } else { + if (e_node) { + memset(buff, 0xff, len); + } else { + FLASH_REMAP_START(mod_info->dev_id, addr, len); + memcpy(buff, (uint8_t *)addr, len); + FLASH_REMAP_DONE(mod_info->dev_id, addr, len); + /* + HAL_NORFLASH_RET_T result; + result = hal_norflash_read(mod_info->dev_id,addr,buff,len); + if(result != HAL_NORFLASH_OK) + { + NORFLASH_API_TRACE(2,"%s: hal_norflash_read failed,result = %d.", + __func__,result); + return result; + } + */ } - else - { - if(e_node) - { - memset(buff,0xff,len); - } - else - { - FLASH_REMAP_START(mod_info->dev_id,addr,len); - memcpy(buff,(uint8_t*)addr,len); - FLASH_REMAP_DONE(mod_info->dev_id,addr,len); - /* - HAL_NORFLASH_RET_T result; - result = hal_norflash_read(mod_info->dev_id,addr,buff,len); - if(result != HAL_NORFLASH_OK) - { - NORFLASH_API_TRACE(2,"%s: hal_norflash_read failed,result = %d.", - __func__,result); - return result; - } - */ - } - } - return 0; + } + return 0; } -static int32_t _e_opera_add(MODULE_INFO *mod_info, - uint32_t addr, - uint32_t len - ) -{ - OPRA_INFO *opera_node = NULL; - OPRA_INFO *pre_node = NULL; - OPRA_INFO *tmp; - int32_t ret = 0; +static int32_t _e_opera_add(MODULE_INFO *mod_info, uint32_t addr, + uint32_t len) { + OPRA_INFO *opera_node = NULL; + OPRA_INFO *pre_node = NULL; + OPRA_INFO *tmp; + int32_t ret = 0; - // delete opera nodes with the same address when add the erase opera node. - pre_node = mod_info->opera_info; - tmp = mod_info->opera_info; - while(tmp) - { - opera_node = tmp; - tmp = opera_node->next; + // delete opera nodes with the same address when add the erase opera node. + pre_node = mod_info->opera_info; + tmp = mod_info->opera_info; + while (tmp) { + opera_node = tmp; + tmp = opera_node->next; - if(opera_node->addr == addr) - { - if(opera_node->lock == false) - { - if(opera_node == mod_info->opera_info) - { - mod_info->opera_info = tmp; - } - else - { - pre_node->next = tmp; - } - if(opera_node->type == NORFLASH_API_WRITTING) - { - if(opera_node->buff) - { - _norflash_api_free(opera_node->buff); - } - } - _norflash_api_free(opera_node); - } - else - { - if(opera_node->type == NORFLASH_API_ERASING) - { - NORFLASH_API_TRACE(3,"%s: erase is merged! addr = 0x%x,len = 0x%x.", - __func__, - opera_node->addr, - opera_node->len); - ret = 0; - goto _func_end; - } - } + if (opera_node->addr == addr) { + if (opera_node->lock == false) { + if (opera_node == mod_info->opera_info) { + mod_info->opera_info = tmp; + } else { + pre_node->next = tmp; } - - if(tmp) - { - pre_node = opera_node; + if (opera_node->type == NORFLASH_API_WRITTING) { + if (opera_node->buff) { + _norflash_api_free(opera_node->buff); + } } + _norflash_api_free(opera_node); + } else { + if (opera_node->type == NORFLASH_API_ERASING) { + NORFLASH_API_TRACE(3, "%s: erase is merged! addr = 0x%x,len = 0x%x.", + __func__, opera_node->addr, opera_node->len); + ret = 0; + goto _func_end; + } + } } - // add new node to header. - opera_node = (OPRA_INFO*)_norflash_api_malloc(sizeof(OPRA_INFO)); - if(opera_node == NULL) - { - NORFLASH_API_TRACE(3,"%s:%d,_norflash_api_malloc failed! size = %d.", - __func__,__LINE__,sizeof(OPRA_INFO)); - ret = 1; - goto _func_end; + if (tmp) { + pre_node = opera_node; } - opera_node->type = NORFLASH_API_ERASING; - opera_node->addr = addr; - opera_node->len = len; - opera_node->w_offs = 0; - opera_node->w_len = 0; - opera_node->buff = NULL; + } + + // add new node to header. + opera_node = (OPRA_INFO *)_norflash_api_malloc(sizeof(OPRA_INFO)); + if (opera_node == NULL) { + NORFLASH_API_TRACE(3, "%s:%d,_norflash_api_malloc failed! size = %d.", + __func__, __LINE__, sizeof(OPRA_INFO)); + ret = 1; + goto _func_end; + } + opera_node->type = NORFLASH_API_ERASING; + opera_node->addr = addr; + opera_node->len = len; + opera_node->w_offs = 0; + opera_node->w_len = 0; + opera_node->buff = NULL; + opera_node->lock = false; + opera_node->next = mod_info->opera_info; + mod_info->opera_info = opera_node; + ret = 0; +_func_end: + + return ret; +} + +static int32_t _w_opera_add(MODULE_INFO *mod_info, uint32_t addr, uint32_t len, + uint8_t *buff) { + OPRA_INFO *opera_node = NULL; + OPRA_INFO *e_node = NULL; + OPRA_INFO *w_node = NULL; + OPRA_INFO *tmp; + uint32_t w_offs; + uint32_t w_len; + uint32_t sec_start; + uint32_t sec_len; + uint32_t w_end1; + uint32_t w_end2; + uint32_t w_start; + uint32_t w_end; + uint32_t w_len_new; + int32_t ret = 0; + + sec_len = mod_info->mod_sector_len; + sec_start = (addr / sec_len) * sec_len; + w_offs = addr - sec_start; + w_len = len; + tmp = mod_info->opera_info; + while (tmp) { + opera_node = tmp; + tmp = opera_node->next; + + if (opera_node->addr == sec_start) { + if (opera_node->type == NORFLASH_API_WRITTING) { + if (!opera_node->lock) { + // select the first w_node in the list. + w_node = opera_node; + break; + } + } else { + e_node = opera_node; + break; + } + } + } + + if (w_node) { + memcpy(w_node->buff + w_offs, buff, w_len); + w_start = w_node->w_offs <= w_offs ? w_node->w_offs : w_offs; + w_end1 = w_node->w_offs + w_node->w_len; + w_end2 = w_offs + w_len; + w_end = w_end1 >= w_end2 ? w_end1 : w_end2; + w_len_new = w_end - w_start; + w_node->w_offs = w_start; + w_node->w_len = w_len_new; + opera_node = w_node; + ret = 0; + } else { + opera_node = (OPRA_INFO *)_norflash_api_malloc(sizeof(OPRA_INFO)); + if (opera_node == NULL) { + NORFLASH_API_TRACE(3, "%s:%d,_norflash_api_malloc failed! size = %d.", + __func__, __LINE__, sizeof(OPRA_INFO)); + ret = 1; + goto _func_end; + } + opera_node->type = NORFLASH_API_WRITTING; + opera_node->addr = sec_start; + opera_node->len = sec_len; + opera_node->w_offs = w_offs; + opera_node->w_len = w_len; + opera_node->buff = (uint8_t *)_norflash_api_malloc(opera_node->len); + if (opera_node->buff == NULL) { + _norflash_api_free(opera_node); + NORFLASH_API_TRACE(3, "%s:%d,_norflash_api_malloc failed! size = %d.", + __func__, __LINE__, opera_node->len); + ret = 1; + goto _func_end; + } + if (e_node) { + memset(opera_node->buff, 0xff, opera_node->len); + } else { + memcpy(opera_node->buff, (uint8_t *)opera_node->addr, opera_node->len); + } + memcpy(opera_node->buff + w_offs, buff, w_len); opera_node->lock = false; opera_node->next = mod_info->opera_info; mod_info->opera_info = opera_node; ret = 0; -_func_end: - - return ret; -} - -static int32_t _w_opera_add(MODULE_INFO *mod_info, - uint32_t addr, - uint32_t len, - uint8_t *buff) -{ - OPRA_INFO *opera_node = NULL; - OPRA_INFO *e_node = NULL; - OPRA_INFO *w_node = NULL; - OPRA_INFO *tmp; - uint32_t w_offs; - uint32_t w_len; - uint32_t sec_start; - uint32_t sec_len; - uint32_t w_end1; - uint32_t w_end2; - uint32_t w_start; - uint32_t w_end; - uint32_t w_len_new; - int32_t ret = 0; - - sec_len = mod_info->mod_sector_len; - sec_start = (addr/sec_len)*sec_len; - w_offs = addr - sec_start; - w_len = len; - tmp = mod_info->opera_info; - while(tmp) - { - opera_node = tmp; - tmp = opera_node->next; - - if(opera_node->addr == sec_start) - { - if(opera_node->type == NORFLASH_API_WRITTING) - { - if(!opera_node->lock) - { - // select the first w_node in the list. - w_node = opera_node; - break; - } - } - else - { - e_node = opera_node; - break; - } - } - } - - if(w_node) - { - memcpy(w_node->buff + w_offs,buff,w_len); - w_start = w_node->w_offs <= w_offs ? w_node->w_offs:w_offs; - w_end1 = w_node->w_offs + w_node->w_len; - w_end2 = w_offs + w_len; - w_end = w_end1 >= w_end2 ? w_end1 : w_end2; - w_len_new = w_end - w_start; - w_node->w_offs = w_start; - w_node->w_len = w_len_new; - opera_node = w_node; - ret = 0; - } - else - { - opera_node = (OPRA_INFO*)_norflash_api_malloc(sizeof(OPRA_INFO)); - if(opera_node == NULL) - { - NORFLASH_API_TRACE(3,"%s:%d,_norflash_api_malloc failed! size = %d.", - __func__,__LINE__,sizeof(OPRA_INFO)); - ret = 1; - goto _func_end; - } - opera_node->type = NORFLASH_API_WRITTING; - opera_node->addr = sec_start; - opera_node->len = sec_len; - opera_node->w_offs = w_offs; - opera_node->w_len = w_len; - opera_node->buff = (uint8_t*)_norflash_api_malloc(opera_node->len); - if(opera_node->buff == NULL) - { - _norflash_api_free(opera_node); - NORFLASH_API_TRACE(3,"%s:%d,_norflash_api_malloc failed! size = %d.", - __func__,__LINE__,opera_node->len); - ret = 1; - goto _func_end; - } - if(e_node) - { - memset(opera_node->buff,0xff,opera_node->len); - } - else - { - memcpy(opera_node->buff,(uint8_t*)opera_node->addr,opera_node->len); - } - memcpy(opera_node->buff + w_offs,buff,w_len); - opera_node->lock = false; - opera_node->next = mod_info->opera_info; - mod_info->opera_info = opera_node; - ret = 0; - } + } _func_end: - return ret; + return ret; } -bool _opera_flush(MODULE_INFO *mod_info,bool nosuspend) -{ - OPRA_INFO *cur_opera_info = NULL; - enum HAL_NORFLASH_RET_T result; - bool opera_is_completed = false; - NORFLASH_API_OPERA_RESULT opera_result; - bool ret = false; - bool suspend; +bool _opera_flush(MODULE_INFO *mod_info, bool nosuspend) { + OPRA_INFO *cur_opera_info = NULL; + enum HAL_NORFLASH_RET_T result; + bool opera_is_completed = false; + NORFLASH_API_OPERA_RESULT opera_result; + bool ret = false; + bool suspend; #if defined(FLASH_SUSPEND) - suspend = true; + suspend = true; #else - suspend = false; + suspend = false; #endif - suspend = nosuspend == true ? false: suspend; + suspend = nosuspend == true ? false : suspend; - if(!mod_info->cur_opera_info) - { - mod_info->cur_opera_info = _get_tail(mod_info, false); + if (!mod_info->cur_opera_info) { + mod_info->cur_opera_info = _get_tail(mod_info, false); + } + + if (!mod_info->cur_opera_info) { + return false; + } + + ret = true; + cur_opera_info = mod_info->cur_opera_info; + if (cur_opera_info->type == NORFLASH_API_WRITTING) { + if (mod_info->state == NORFLASH_API_STATE_IDLE) { + suspend_number = 0; + if (cur_opera_info->w_len > 0) { + NORFLASH_API_TRACE(5, + "%s: %d,hal_norflash_write_suspend,addr = 0x%x,len " + "= 0x%x,suspend = %d.", + __func__, __LINE__, + cur_opera_info->addr + cur_opera_info->w_offs, + cur_opera_info->w_len, suspend); + + FLASH_REMAP_START(mod_info->dev_id, + cur_opera_info->addr + cur_opera_info->w_offs, + cur_opera_info->w_len); + pmu_flash_write_config(); + result = hal_norflash_write_suspend( + mod_info->dev_id, cur_opera_info->addr + cur_opera_info->w_offs, + cur_opera_info->buff + cur_opera_info->w_offs, + cur_opera_info->w_len, suspend); + pmu_flash_read_config(); + FLASH_REMAP_DONE(mod_info->dev_id, + cur_opera_info->addr + cur_opera_info->w_offs, + cur_opera_info->w_len); + } else { + result = HAL_NORFLASH_OK; + } + + if (result == HAL_NORFLASH_OK) { + opera_is_completed = true; + goto __opera_is_completed; + } else if (result == HAL_NORFLASH_SUSPENDED) { + mod_info->state = NORFLASH_API_STATE_WRITTING_SUSPEND; + } else { + ASSERT(0, "%s: %d, hal_norflash_write_suspend failed,result = %d", + __func__, __LINE__, result); + } + } else if (mod_info->state == NORFLASH_API_STATE_WRITTING_SUSPEND) { + suspend_number++; + FLASH_REMAP_START(mod_info->dev_id, + cur_opera_info->addr + cur_opera_info->w_offs, + cur_opera_info->w_len); + pmu_flash_write_config(); + result = hal_norflash_write_resume(mod_info->dev_id, suspend); + pmu_flash_read_config(); + FLASH_REMAP_DONE(mod_info->dev_id, + cur_opera_info->addr + cur_opera_info->w_offs, + cur_opera_info->w_len); + if (result == HAL_NORFLASH_OK) { + opera_is_completed = true; + goto __opera_is_completed; + } else if (result == HAL_NORFLASH_SUSPENDED) { + mod_info->state = NORFLASH_API_STATE_WRITTING_SUSPEND; + } else { + ASSERT(0, "%s: %d, hal_norflash_write_resume failed,result = %d", + __func__, __LINE__, result); + } + } else { + ASSERT(0, "%s: %d, mod_info->state error,state = %d", __func__, __LINE__, + mod_info->state); } - - if(!mod_info->cur_opera_info) - { - return false; - } - - ret = true; - cur_opera_info = mod_info->cur_opera_info; - if(cur_opera_info->type == NORFLASH_API_WRITTING) - { - if(mod_info->state == NORFLASH_API_STATE_IDLE) - { - suspend_number = 0; - if(cur_opera_info->w_len > 0) - { - NORFLASH_API_TRACE(5,"%s: %d,hal_norflash_write_suspend,addr = 0x%x,len = 0x%x,suspend = %d.", - __func__,__LINE__, - cur_opera_info->addr + cur_opera_info->w_offs, - cur_opera_info->w_len, - suspend); - - FLASH_REMAP_START(mod_info->dev_id,cur_opera_info->addr + cur_opera_info->w_offs,cur_opera_info->w_len); - pmu_flash_write_config(); - result = hal_norflash_write_suspend(mod_info->dev_id, - cur_opera_info->addr + cur_opera_info->w_offs, - cur_opera_info->buff + cur_opera_info->w_offs, - cur_opera_info->w_len, - suspend); - pmu_flash_read_config(); - FLASH_REMAP_DONE(mod_info->dev_id,cur_opera_info->addr + cur_opera_info->w_offs,cur_opera_info->w_len); - } - else - { - result = HAL_NORFLASH_OK; - } - - if(result == HAL_NORFLASH_OK) - { - opera_is_completed = true; - goto __opera_is_completed; - } - else if(result == HAL_NORFLASH_SUSPENDED) - { - mod_info->state = NORFLASH_API_STATE_WRITTING_SUSPEND; - } - else - { - ASSERT(0, "%s: %d, hal_norflash_write_suspend failed,result = %d",__func__,__LINE__,result); - } - } - else if(mod_info->state == NORFLASH_API_STATE_WRITTING_SUSPEND) - { - suspend_number ++; - FLASH_REMAP_START(mod_info->dev_id,cur_opera_info->addr + cur_opera_info->w_offs,cur_opera_info->w_len); - pmu_flash_write_config(); - result = hal_norflash_write_resume(mod_info->dev_id, - suspend); - pmu_flash_read_config(); - FLASH_REMAP_DONE(mod_info->dev_id,cur_opera_info->addr + cur_opera_info->w_offs,cur_opera_info->w_len); - if(result == HAL_NORFLASH_OK) - { - opera_is_completed = true; - goto __opera_is_completed; - } - else if(result == HAL_NORFLASH_SUSPENDED) - { - mod_info->state = NORFLASH_API_STATE_WRITTING_SUSPEND; - } - else - { - ASSERT(0, "%s: %d, hal_norflash_write_resume failed,result = %d",__func__,__LINE__,result); - } - } - else - { - ASSERT(0, "%s: %d, mod_info->state error,state = %d",__func__,__LINE__,mod_info->state); - } - } - else - { - if(mod_info->state == NORFLASH_API_STATE_IDLE) - { - suspend_number = 0; - NORFLASH_API_TRACE(5,"%s: %d,hal_norflash_erase_suspend,addr = 0x%x,len = 0x%x,suspend = %d.", - __func__,__LINE__, - cur_opera_info->addr, - cur_opera_info->len, - suspend); - FLASH_REMAP_START(mod_info->dev_id, cur_opera_info->addr, cur_opera_info->len); - pmu_flash_write_config(); - result = hal_norflash_erase_suspend(mod_info->dev_id, - cur_opera_info->addr, - cur_opera_info->len, - suspend); - pmu_flash_read_config(); - FLASH_REMAP_DONE(mod_info->dev_id, cur_opera_info->addr, cur_opera_info->len); - if(result == HAL_NORFLASH_OK) - { - opera_is_completed = true; - goto __opera_is_completed; - } - else if(result == HAL_NORFLASH_SUSPENDED) - { - mod_info->state = NORFLASH_API_STATE_ERASE_SUSPEND; - } - else - { - ASSERT(0, "%s: %d, hal_norflash_erase_suspend failed,result = %d",__func__,__LINE__,result); - } - } - else if(mod_info->state == NORFLASH_API_STATE_ERASE_SUSPEND) - { - suspend_number ++; - FLASH_REMAP_START(mod_info->dev_id, cur_opera_info->addr, cur_opera_info->len); - pmu_flash_write_config(); - result = hal_norflash_erase_resume(mod_info->dev_id, - suspend); - pmu_flash_read_config(); - FLASH_REMAP_DONE(mod_info->dev_id, cur_opera_info->addr, cur_opera_info->len); - if(result == HAL_NORFLASH_OK) - { - opera_is_completed = true; - goto __opera_is_completed; - } - else if(result == HAL_NORFLASH_SUSPENDED) - { - mod_info->state = NORFLASH_API_STATE_ERASE_SUSPEND; - } - else - { - ASSERT(0, "%s: %d, hal_norflash_write_resume failed,result = %d", - __func__,__LINE__,result); - } - } - else - { - ASSERT(0, "%s: %d, mod_info->state error,state = %d", - __func__,__LINE__,mod_info->state); - } + } else { + if (mod_info->state == NORFLASH_API_STATE_IDLE) { + suspend_number = 0; + NORFLASH_API_TRACE(5, + "%s: %d,hal_norflash_erase_suspend,addr = 0x%x,len = " + "0x%x,suspend = %d.", + __func__, __LINE__, cur_opera_info->addr, + cur_opera_info->len, suspend); + FLASH_REMAP_START(mod_info->dev_id, cur_opera_info->addr, + cur_opera_info->len); + pmu_flash_write_config(); + result = hal_norflash_erase_suspend( + mod_info->dev_id, cur_opera_info->addr, cur_opera_info->len, suspend); + pmu_flash_read_config(); + FLASH_REMAP_DONE(mod_info->dev_id, cur_opera_info->addr, + cur_opera_info->len); + if (result == HAL_NORFLASH_OK) { + opera_is_completed = true; + goto __opera_is_completed; + } else if (result == HAL_NORFLASH_SUSPENDED) { + mod_info->state = NORFLASH_API_STATE_ERASE_SUSPEND; + } else { + ASSERT(0, "%s: %d, hal_norflash_erase_suspend failed,result = %d", + __func__, __LINE__, result); + } + } else if (mod_info->state == NORFLASH_API_STATE_ERASE_SUSPEND) { + suspend_number++; + FLASH_REMAP_START(mod_info->dev_id, cur_opera_info->addr, + cur_opera_info->len); + pmu_flash_write_config(); + result = hal_norflash_erase_resume(mod_info->dev_id, suspend); + pmu_flash_read_config(); + FLASH_REMAP_DONE(mod_info->dev_id, cur_opera_info->addr, + cur_opera_info->len); + if (result == HAL_NORFLASH_OK) { + opera_is_completed = true; + goto __opera_is_completed; + } else if (result == HAL_NORFLASH_SUSPENDED) { + mod_info->state = NORFLASH_API_STATE_ERASE_SUSPEND; + } else { + ASSERT(0, "%s: %d, hal_norflash_write_resume failed,result = %d", + __func__, __LINE__, result); + } + } else { + ASSERT(0, "%s: %d, mod_info->state error,state = %d", __func__, __LINE__, + mod_info->state); } + } __opera_is_completed: - if(opera_is_completed) - { - mod_info->state = NORFLASH_API_STATE_IDLE; - if(!nosuspend - && mod_info->cb_func - && ((cur_opera_info->w_len > 0 && cur_opera_info->type == NORFLASH_API_WRITTING) - || (cur_opera_info->len > 0 && cur_opera_info->type == NORFLASH_API_ERASING)) - ) - { - NORFLASH_API_TRACE(6,"%s: w/e done.type = %d,addr = 0x%x,w_len = 0x%x,len = 0x%x,suspend_num = %d.", - __func__, - cur_opera_info->type, - cur_opera_info->addr + cur_opera_info->w_offs, - cur_opera_info->w_len, - cur_opera_info->len, - suspend_number); - if(cur_opera_info->type == NORFLASH_API_WRITTING) - { - opera_result.addr = cur_opera_info->addr + cur_opera_info->w_offs; - opera_result.len = cur_opera_info->w_len; - } - else - { - opera_result.addr = cur_opera_info->addr; - opera_result.len = cur_opera_info->len; - } - opera_result.type = cur_opera_info->type; - opera_result.result = NORFLASH_API_OK; - opera_result.remain_num = _get_ew_count(mod_info) - 1; - mod_info->cb_func(&opera_result); - } - _opera_del(mod_info,cur_opera_info); - mod_info->cur_opera_info = NULL; + if (opera_is_completed) { + mod_info->state = NORFLASH_API_STATE_IDLE; + if (!nosuspend && mod_info->cb_func && + ((cur_opera_info->w_len > 0 && + cur_opera_info->type == NORFLASH_API_WRITTING) || + (cur_opera_info->len > 0 && + cur_opera_info->type == NORFLASH_API_ERASING))) { + NORFLASH_API_TRACE(6, + "%s: w/e done.type = %d,addr = 0x%x,w_len = 0x%x,len " + "= 0x%x,suspend_num = %d.", + __func__, cur_opera_info->type, + cur_opera_info->addr + cur_opera_info->w_offs, + cur_opera_info->w_len, cur_opera_info->len, + suspend_number); + if (cur_opera_info->type == NORFLASH_API_WRITTING) { + opera_result.addr = cur_opera_info->addr + cur_opera_info->w_offs; + opera_result.len = cur_opera_info->w_len; + } else { + opera_result.addr = cur_opera_info->addr; + opera_result.len = cur_opera_info->len; + } + opera_result.type = cur_opera_info->type; + opera_result.result = NORFLASH_API_OK; + opera_result.remain_num = _get_ew_count(mod_info) - 1; + mod_info->cb_func(&opera_result); } + _opera_del(mod_info, cur_opera_info); + mod_info->cur_opera_info = NULL; + } - return ret; + return ret; } -void _flush_disable(enum NORFLASH_API_USER user_id,uint32_t cb) -{ - norflash_api_info.allowed_cb[user_id] = (NOFLASH_API_FLUSH_ALLOWED_CB)cb; +void _flush_disable(enum NORFLASH_API_USER user_id, uint32_t cb) { + norflash_api_info.allowed_cb[user_id] = (NOFLASH_API_FLUSH_ALLOWED_CB)cb; } -void _flush_enable(enum NORFLASH_API_USER user_id) -{ - norflash_api_info.allowed_cb[user_id] = NULL; +void _flush_enable(enum NORFLASH_API_USER user_id) { + norflash_api_info.allowed_cb[user_id] = NULL; } -bool _flush_is_allowed(void) -{ - bool ret = true; - uint32_t user_id; +bool _flush_is_allowed(void) { + bool ret = true; + uint32_t user_id; - for(user_id = NORFLASH_API_USER_CP; user_id < NORFLASH_API_USER_COUNTS; user_id ++) - { - if(norflash_api_info.allowed_cb[user_id]) - { - if(!norflash_api_info.allowed_cb[user_id]()) - { - ret = false; - } - else - { - norflash_api_info.allowed_cb[user_id] = NULL; - } - } + for (user_id = NORFLASH_API_USER_CP; user_id < NORFLASH_API_USER_COUNTS; + user_id++) { + if (norflash_api_info.allowed_cb[user_id]) { + if (!norflash_api_info.allowed_cb[user_id]()) { + ret = false; + } else { + norflash_api_info.allowed_cb[user_id] = NULL; + } } - return ret; + } + return ret; } //------------------------------------------------------------------- // APIS Function. //------------------------------------------------------------------- -enum NORFLASH_API_RET_T norflash_api_init(void) -{ - uint32_t i; +enum NORFLASH_API_RET_T norflash_api_init(void) { + uint32_t i; - memset((void*)&norflash_api_info,0,sizeof(NORFLASH_API_INFO)); - norflash_api_info.cur_mod_id = NORFLASH_API_MODULE_ID_COUNT; - norflash_api_info.is_inited = true; - norflash_api_info.cur_mod = NULL; - for(i = 0; i < NORFLASH_API_MODULE_ID_COUNT; i++) - { - norflash_api_info.mod_info[i].state = NORFLASH_API_STATE_UNINITED; - } + memset((void *)&norflash_api_info, 0, sizeof(NORFLASH_API_INFO)); + norflash_api_info.cur_mod_id = NORFLASH_API_MODULE_ID_COUNT; + norflash_api_info.is_inited = true; + norflash_api_info.cur_mod = NULL; + for (i = 0; i < NORFLASH_API_MODULE_ID_COUNT; i++) { + norflash_api_info.mod_info[i].state = NORFLASH_API_STATE_UNINITED; + } #if !defined(FLASH_API_SIMPLE) #if defined(FLASH_SUSPEND) - hal_sleep_set_sleep_hook(HAL_SLEEP_HOOK_NORFLASH_API, norflash_api_flush); + hal_sleep_set_sleep_hook(HAL_SLEEP_HOOK_NORFLASH_API, norflash_api_flush); #else - hal_sleep_set_deep_sleep_hook(HAL_DEEP_SLEEP_HOOK_NORFLASH_API, norflash_api_flush); + hal_sleep_set_deep_sleep_hook(HAL_DEEP_SLEEP_HOOK_NORFLASH_API, + norflash_api_flush); #endif #endif - return NORFLASH_API_OK; + return NORFLASH_API_OK; } -enum NORFLASH_API_RET_T norflash_api_register( - enum NORFLASH_API_MODULE_ID_T mod_id, - enum HAL_NORFLASH_ID_T dev_id, - uint32_t mod_base_addr, - uint32_t mod_len, - uint32_t mod_block_len, - uint32_t mod_sector_len, - uint32_t mod_page_len, - uint32_t buffer_len, - NORFLASH_API_OPERA_CB cb_func - ) -{ - MODULE_INFO *mod_info = NULL; +enum NORFLASH_API_RET_T +norflash_api_register(enum NORFLASH_API_MODULE_ID_T mod_id, + enum HAL_NORFLASH_ID_T dev_id, uint32_t mod_base_addr, + uint32_t mod_len, uint32_t mod_block_len, + uint32_t mod_sector_len, uint32_t mod_page_len, + uint32_t buffer_len, NORFLASH_API_OPERA_CB cb_func) { + MODULE_INFO *mod_info = NULL; - NORFLASH_API_TRACE(5,"%s: mod_id = %d,dev_id = %d,mod_base_addr = 0x%x,mod_len = 0x%x,", - __func__,mod_id,dev_id,mod_base_addr,mod_len); - NORFLASH_API_TRACE(4,"mod_block_len = 0x%x,mod_sector_len = 0x%x,mod_page_len = 0x%x,buffer_len = 0x%x.", - mod_block_len,mod_sector_len,mod_page_len,buffer_len); - if(!norflash_api_info.is_inited) - { - NORFLASH_API_TRACE(2,"%s: %d, norflash_api uninit!",__func__,__LINE__); - return NORFLASH_API_ERR_UNINIT; - } + NORFLASH_API_TRACE( + 5, "%s: mod_id = %d,dev_id = %d,mod_base_addr = 0x%x,mod_len = 0x%x,", + __func__, mod_id, dev_id, mod_base_addr, mod_len); + NORFLASH_API_TRACE(4, + "mod_block_len = 0x%x,mod_sector_len = 0x%x,mod_page_len " + "= 0x%x,buffer_len = 0x%x.", + mod_block_len, mod_sector_len, mod_page_len, buffer_len); + if (!norflash_api_info.is_inited) { + NORFLASH_API_TRACE(2, "%s: %d, norflash_api uninit!", __func__, __LINE__); + return NORFLASH_API_ERR_UNINIT; + } - if(mod_id >= NORFLASH_API_MODULE_ID_COUNT) - { - NORFLASH_API_TRACE(2,"%s : mod_id error! mod_id = %d.",__func__, mod_id); - return NORFLASH_API_BAD_MOD_ID; - } + if (mod_id >= NORFLASH_API_MODULE_ID_COUNT) { + NORFLASH_API_TRACE(2, "%s : mod_id error! mod_id = %d.", __func__, mod_id); + return NORFLASH_API_BAD_MOD_ID; + } - if(dev_id >= HAL_NORFLASH_ID_NUM) - { - NORFLASH_API_TRACE(2,"%s : dev_id error! mod_id = %d.",__func__,dev_id); - return NORFLASH_API_BAD_DEV_ID; - } + if (dev_id >= HAL_NORFLASH_ID_NUM) { + NORFLASH_API_TRACE(2, "%s : dev_id error! mod_id = %d.", __func__, dev_id); + return NORFLASH_API_BAD_DEV_ID; + } - if(buffer_len < mod_sector_len || !API_IS_ALIGN(buffer_len,mod_sector_len)) - { - NORFLASH_API_TRACE(2,"%s : buffer_len error buffer_len = %d.",__func__, buffer_len); - return NORFLASH_API_BAD_BUFF_LEN; - } - mod_info = _get_module_info(mod_id); - if(mod_info->is_inited) - { - // NORFLASH_API_TRACE(3,"%s: %d, norflash_async[%d] has registered!",__func__,__LINE__,mod_id); - return NORFLASH_API_OK; //NORFLASH_API_ERR_HASINIT; - } - mod_info->dev_id = dev_id; - mod_info->mod_id = mod_id; - mod_info->mod_base_addr = mod_base_addr; - mod_info->mod_len = mod_len; - mod_info->mod_block_len = mod_block_len; - mod_info->mod_sector_len = mod_sector_len; - mod_info->mod_page_len = mod_page_len; - mod_info->buff_len = buffer_len; - mod_info->cb_func = cb_func; - mod_info->opera_info = NULL; - mod_info->cur_opera_info = NULL; - mod_info->state = NORFLASH_API_STATE_IDLE; - mod_info->is_inited = true; - return NORFLASH_API_OK; + if (buffer_len < mod_sector_len || + !API_IS_ALIGN(buffer_len, mod_sector_len)) { + NORFLASH_API_TRACE(2, "%s : buffer_len error buffer_len = %d.", __func__, + buffer_len); + return NORFLASH_API_BAD_BUFF_LEN; + } + mod_info = _get_module_info(mod_id); + if (mod_info->is_inited) { + // NORFLASH_API_TRACE(3,"%s: %d, norflash_async[%d] has + // registered!",__func__,__LINE__,mod_id); + return NORFLASH_API_OK; // NORFLASH_API_ERR_HASINIT; + } + mod_info->dev_id = dev_id; + mod_info->mod_id = mod_id; + mod_info->mod_base_addr = mod_base_addr; + mod_info->mod_len = mod_len; + mod_info->mod_block_len = mod_block_len; + mod_info->mod_sector_len = mod_sector_len; + mod_info->mod_page_len = mod_page_len; + mod_info->buff_len = buffer_len; + mod_info->cb_func = cb_func; + mod_info->opera_info = NULL; + mod_info->cur_opera_info = NULL; + mod_info->state = NORFLASH_API_STATE_IDLE; + mod_info->is_inited = true; + return NORFLASH_API_OK; } -enum NORFLASH_API_RET_T norflash_api_read( - enum NORFLASH_API_MODULE_ID_T mod_id, - uint32_t start_addr, - uint8_t *buffer, - uint32_t len - ) -{ - MODULE_INFO *mod_info = NULL; - int32_t result; - enum NORFLASH_API_RET_T ret; - uint32_t lock; +enum NORFLASH_API_RET_T norflash_api_read(enum NORFLASH_API_MODULE_ID_T mod_id, + uint32_t start_addr, uint8_t *buffer, + uint32_t len) { + MODULE_INFO *mod_info = NULL; + int32_t result; + enum NORFLASH_API_RET_T ret; + uint32_t lock; - NORFLASH_API_TRACE(4,"%s:mod_id = %d,start_addr = 0x%x,len = 0x%x", - __func__,mod_id, start_addr, len); - ASSERT(buffer,"%s:buffer is null! ", - __func__); - if(!norflash_api_info.is_inited) - { - NORFLASH_API_TRACE(1,"%s: norflash_api uninit!",__func__); - return NORFLASH_API_ERR_UNINIT; - } - if(mod_id >= NORFLASH_API_MODULE_ID_COUNT) - { - NORFLASH_API_TRACE(2,"%s : mod_id error! mod_id = %d.",__func__, mod_id); - return NORFLASH_API_BAD_MOD_ID; - } + NORFLASH_API_TRACE(4, "%s:mod_id = %d,start_addr = 0x%x,len = 0x%x", __func__, + mod_id, start_addr, len); + ASSERT(buffer, "%s:buffer is null! ", __func__); + if (!norflash_api_info.is_inited) { + NORFLASH_API_TRACE(1, "%s: norflash_api uninit!", __func__); + return NORFLASH_API_ERR_UNINIT; + } + if (mod_id >= NORFLASH_API_MODULE_ID_COUNT) { + NORFLASH_API_TRACE(2, "%s : mod_id error! mod_id = %d.", __func__, mod_id); + return NORFLASH_API_BAD_MOD_ID; + } - mod_info = _get_module_info(mod_id); - if(!mod_info->is_inited) - { - NORFLASH_API_TRACE(2,"%s : module unregistered! mod_id = %d.",__func__, mod_id); - return NORFLASH_API_ERR_UNINIT; - } + mod_info = _get_module_info(mod_id); + if (!mod_info->is_inited) { + NORFLASH_API_TRACE(2, "%s : module unregistered! mod_id = %d.", __func__, + mod_id); + return NORFLASH_API_ERR_UNINIT; + } - if(start_addr < mod_info->mod_base_addr - || start_addr + len > mod_info->mod_base_addr + mod_info->mod_len) - { - NORFLASH_API_TRACE(3,"%s : reading out of range! start_address = 0x%x,len = 0x%x.", - __func__, start_addr, len); - return NORFLASH_API_BAD_ADDR; - } + if (start_addr < mod_info->mod_base_addr || + start_addr + len > mod_info->mod_base_addr + mod_info->mod_len) { + NORFLASH_API_TRACE( + 3, "%s : reading out of range! start_address = 0x%x,len = 0x%x.", + __func__, start_addr, len); + return NORFLASH_API_BAD_ADDR; + } - if(len == 0) - { - NORFLASH_API_TRACE(2,"%s : len error! len = %d.", - __func__, len); - return NORFLASH_API_BAD_LEN; - } - lock = int_lock_global(); - result = _opera_read(mod_info,start_addr,(uint8_t*)buffer,len); + if (len == 0) { + NORFLASH_API_TRACE(2, "%s : len error! len = %d.", __func__, len); + return NORFLASH_API_BAD_LEN; + } + lock = int_lock_global(); + result = _opera_read(mod_info, start_addr, (uint8_t *)buffer, len); - if(result) - { - ret = NORFLASH_API_ERR; - } - else - { - ret = NORFLASH_API_OK; - } - int_unlock_global(lock); - NORFLASH_API_TRACE(2,"%s: done. ret = %d.",__func__,ret); - return ret; + if (result) { + ret = NORFLASH_API_ERR; + } else { + ret = NORFLASH_API_OK; + } + int_unlock_global(lock); + NORFLASH_API_TRACE(2, "%s: done. ret = %d.", __func__, ret); + return ret; } -enum NORFLASH_API_RET_T norflash_sync_read( - enum NORFLASH_API_MODULE_ID_T mod_id, - uint32_t start_addr, - uint8_t *buffer, - uint32_t len - ) -{ - MODULE_INFO *mod_info = NULL; - uint32_t lock; +enum NORFLASH_API_RET_T norflash_sync_read(enum NORFLASH_API_MODULE_ID_T mod_id, + uint32_t start_addr, uint8_t *buffer, + uint32_t len) { + MODULE_INFO *mod_info = NULL; + uint32_t lock; - NORFLASH_API_TRACE(4,"%s:mod_id = %d,start_addr = 0x%x,len = 0x%x", - __func__,mod_id,start_addr,len); - ASSERT(buffer,"%s:%d,buffer is null! ", - __func__,__LINE__); - if(!norflash_api_info.is_inited) - { - NORFLASH_API_TRACE(1,"%s: norflash_api uninit!", __func__); - return NORFLASH_API_ERR_UNINIT; - } - if(mod_id >= NORFLASH_API_MODULE_ID_COUNT) - { - NORFLASH_API_TRACE(2,"%s : mod_id error! mod_id = %d.", __func__, mod_id); - return NORFLASH_API_BAD_MOD_ID; - } + NORFLASH_API_TRACE(4, "%s:mod_id = %d,start_addr = 0x%x,len = 0x%x", __func__, + mod_id, start_addr, len); + ASSERT(buffer, "%s:%d,buffer is null! ", __func__, __LINE__); + if (!norflash_api_info.is_inited) { + NORFLASH_API_TRACE(1, "%s: norflash_api uninit!", __func__); + return NORFLASH_API_ERR_UNINIT; + } + if (mod_id >= NORFLASH_API_MODULE_ID_COUNT) { + NORFLASH_API_TRACE(2, "%s : mod_id error! mod_id = %d.", __func__, mod_id); + return NORFLASH_API_BAD_MOD_ID; + } - mod_info = _get_module_info(mod_id); - if(!mod_info->is_inited) - { - NORFLASH_API_TRACE(2,"%s : module unregistered! mod_id = %d.",__func__, mod_id); - return NORFLASH_API_ERR_UNINIT; - } + mod_info = _get_module_info(mod_id); + if (!mod_info->is_inited) { + NORFLASH_API_TRACE(2, "%s : module unregistered! mod_id = %d.", __func__, + mod_id); + return NORFLASH_API_ERR_UNINIT; + } - if(start_addr < mod_info->mod_base_addr - || start_addr + len > mod_info->mod_base_addr + mod_info->mod_len) - { - NORFLASH_API_TRACE(3,"%s : reading out of range! start_address = 0x%x,len = 0x%x.", - __func__, start_addr, len); - return NORFLASH_API_BAD_ADDR; - } + if (start_addr < mod_info->mod_base_addr || + start_addr + len > mod_info->mod_base_addr + mod_info->mod_len) { + NORFLASH_API_TRACE( + 3, "%s : reading out of range! start_address = 0x%x,len = 0x%x.", + __func__, start_addr, len); + return NORFLASH_API_BAD_ADDR; + } - if(len == 0) - { - NORFLASH_API_TRACE(2,"%s : len error! len = %d.", - __func__, len); - return NORFLASH_API_BAD_LEN; - } + if (len == 0) { + NORFLASH_API_TRACE(2, "%s : len error! len = %d.", __func__, len); + return NORFLASH_API_BAD_LEN; + } - lock = int_lock_global(); - FLASH_REMAP_START(mod_info->dev_id,start_addr, len); - memcpy(buffer,(uint8_t*)start_addr,len); - FLASH_REMAP_DONE(mod_info->dev_id,start_addr, len); - NORFLASH_API_TRACE(1,"%s: done.",__func__); - int_unlock_global(lock); + lock = int_lock_global(); + FLASH_REMAP_START(mod_info->dev_id, start_addr, len); + memcpy(buffer, (uint8_t *)start_addr, len); + FLASH_REMAP_DONE(mod_info->dev_id, start_addr, len); + NORFLASH_API_TRACE(1, "%s: done.", __func__); + int_unlock_global(lock); - return NORFLASH_API_OK; + return NORFLASH_API_OK; } -enum NORFLASH_API_RET_T norflash_api_erase( - enum NORFLASH_API_MODULE_ID_T mod_id, - uint32_t start_addr, - uint32_t len, - bool async - ) -{ - MODULE_INFO *mod_info = NULL; - MODULE_INFO *cur_mod_info = NULL; - uint32_t lock; - int32_t result; - bool bresult = false; - enum NORFLASH_API_RET_T ret; +enum NORFLASH_API_RET_T norflash_api_erase(enum NORFLASH_API_MODULE_ID_T mod_id, + uint32_t start_addr, uint32_t len, + bool async) { + MODULE_INFO *mod_info = NULL; + MODULE_INFO *cur_mod_info = NULL; + uint32_t lock; + int32_t result; + bool bresult = false; + enum NORFLASH_API_RET_T ret; - NORFLASH_API_TRACE(5,"%s: mod_id = %d,start_addr = 0x%x,len = 0x%x,async = %d.", - __func__,mod_id,start_addr,len,async); - if(!norflash_api_info.is_inited) - { - NORFLASH_API_TRACE(1,"%s: norflash_api uninit!",__func__); - return NORFLASH_API_ERR_UNINIT; - } - if(mod_id >= NORFLASH_API_MODULE_ID_COUNT) - { - NORFLASH_API_TRACE(2,"%s : invalid mod_id! mod_id = %d.",__func__, mod_id); - return NORFLASH_API_BAD_MOD_ID; - } + NORFLASH_API_TRACE(5, + "%s: mod_id = %d,start_addr = 0x%x,len = 0x%x,async = %d.", + __func__, mod_id, start_addr, len, async); + if (!norflash_api_info.is_inited) { + NORFLASH_API_TRACE(1, "%s: norflash_api uninit!", __func__); + return NORFLASH_API_ERR_UNINIT; + } + if (mod_id >= NORFLASH_API_MODULE_ID_COUNT) { + NORFLASH_API_TRACE(2, "%s : invalid mod_id! mod_id = %d.", __func__, + mod_id); + return NORFLASH_API_BAD_MOD_ID; + } - mod_info = _get_module_info(mod_id); - if(!mod_info->is_inited) - { - NORFLASH_API_TRACE(2,"%s : module unregistered! mod_id = %d.",__func__, mod_id); - return NORFLASH_API_ERR_UNINIT; - } + mod_info = _get_module_info(mod_id); + if (!mod_info->is_inited) { + NORFLASH_API_TRACE(2, "%s : module unregistered! mod_id = %d.", __func__, + mod_id); + return NORFLASH_API_ERR_UNINIT; + } - if(start_addr < mod_info->mod_base_addr - || start_addr + len > mod_info->mod_base_addr + mod_info->mod_len) - { - NORFLASH_API_TRACE(3,"%s : erase out of range! start_address = 0x%x,len = 0x%x.", - __func__,start_addr,len); - return NORFLASH_API_BAD_ADDR; - } + if (start_addr < mod_info->mod_base_addr || + start_addr + len > mod_info->mod_base_addr + mod_info->mod_len) { + NORFLASH_API_TRACE( + 3, "%s : erase out of range! start_address = 0x%x,len = 0x%x.", + __func__, start_addr, len); + return NORFLASH_API_BAD_ADDR; + } - if(!API_IS_ALIGN(start_addr,mod_info->mod_sector_len)) - { - NORFLASH_API_TRACE(2,"%s : start_address no alignment! start_address = %d.", - __func__, start_addr); - return NORFLASH_API_BAD_ADDR; - } + if (!API_IS_ALIGN(start_addr, mod_info->mod_sector_len)) { + NORFLASH_API_TRACE(2, + "%s : start_address no alignment! start_address = %d.", + __func__, start_addr); + return NORFLASH_API_BAD_ADDR; + } - if( + if ( #ifdef PUYA_FLASH_ERASE_PAGE_ENABLE - len != mod_info->mod_page_len && + len != mod_info->mod_page_len && #endif - len != mod_info->mod_sector_len && - len != mod_info->mod_block_len) - { - NORFLASH_API_TRACE(2,"%s : len error. len = %d!", - __func__, len); - return NORFLASH_API_BAD_LEN; - } + len != mod_info->mod_sector_len && len != mod_info->mod_block_len) { + NORFLASH_API_TRACE(2, "%s : len error. len = %d!", __func__, len); + return NORFLASH_API_BAD_LEN; + } #if defined(FLASH_API_SIMPLE) - async = false; + async = false; #endif - if(async) - { - lock = int_lock_global(); - - // add to opera_info chain header. - result = _e_opera_add(mod_info,start_addr,len); - if(result == 0) - { - ret = NORFLASH_API_OK; - } - else - { - ret = NORFLASH_API_BUFFER_FULL; - } - int_unlock_global(lock); - NORFLASH_API_TRACE(4,"%s: _e_opera_add done. start_addr = 0x%x,len = 0x%x,ret = %d.", - __func__,start_addr,len,ret); - } - else - { - lock = int_lock_global(); - // Handle the suspend operation. - if(norflash_api_info.cur_mod != NULL - && mod_info != norflash_api_info.cur_mod) - { - cur_mod_info = norflash_api_info.cur_mod; - while(cur_mod_info->state != NORFLASH_API_STATE_IDLE) - { - if(!_flush_is_allowed()) - { - continue; - } - bresult = _opera_flush(cur_mod_info,true); - if(!bresult) - { - norflash_api_info.cur_mod = NULL; - } - } - } - - // flush all of cur module opera. - // norflash_api_info.cur_mod_id = mod_id; - do{ - if(!_flush_is_allowed()) - { - continue; - } - bresult = _opera_flush(mod_info,true); - }while(bresult); - FLASH_REMAP_START(mod_info->dev_id,start_addr,len); - pmu_flash_write_config(); - result = hal_norflash_erase(mod_info->dev_id,start_addr, len); - pmu_flash_read_config(); - FLASH_REMAP_DONE(mod_info->dev_id,start_addr,len); - if(result == HAL_NORFLASH_OK) - { - ret = NORFLASH_API_OK; - } - else if(result == HAL_NORFLASH_BAD_ADDR) - { - ret = NORFLASH_API_BAD_ADDR; - } - else if(result == HAL_NORFLASH_BAD_LEN) - { - ret = NORFLASH_API_BAD_LEN; - } - else - { - ret = NORFLASH_API_ERR; - } - int_unlock_global(lock); - NORFLASH_API_TRACE(4,"%s: hal_norflash_erase done. start_addr = 0x%x,len = 0x%x,ret = %d.", - __func__,start_addr,len,ret); - } - //NORFLASH_API_TRACE(2,"%s: done.ret = %d.",__func__, ret); - return ret; -} - -enum NORFLASH_API_RET_T norflash_api_write( - enum NORFLASH_API_MODULE_ID_T mod_id, - uint32_t start_addr, - const uint8_t *buffer, - uint32_t len, - bool async - ) -{ - MODULE_INFO *mod_info = NULL; - MODULE_INFO *cur_mod_info = NULL; - uint32_t lock; - int32_t result; - bool bresult = false; - enum NORFLASH_API_RET_T ret; - - NORFLASH_API_TRACE(4,"%s: mod_id = %d,start_addr = 0x%x,len = 0x%x.", - __func__,mod_id,start_addr,len); - - if(!norflash_api_info.is_inited) - { - NORFLASH_API_TRACE(1,"%s: norflash_api uninit!",__func__); - return NORFLASH_API_ERR_UNINIT; - } - - if(mod_id > NORFLASH_API_MODULE_ID_COUNT) - { - NORFLASH_API_TRACE(2,"%s : mod_id error! mod_id = %d.",__func__, mod_id); - return NORFLASH_API_BAD_MOD_ID; - } - - mod_info = _get_module_info(mod_id); - if(!mod_info->is_inited) - { - NORFLASH_API_TRACE(2,"%s :module unregistered! mod_id = %d.",__func__, mod_id); - return NORFLASH_API_ERR_UNINIT; - } - - - if(start_addr < mod_info->mod_base_addr - || start_addr + len > mod_info->mod_base_addr + mod_info->mod_len) - { - NORFLASH_API_TRACE(3,"%s : writting out of range! start_address = 0x%x,len = 0x%x.", - __func__,mod_info->mod_base_addr,mod_info->mod_len); - return NORFLASH_API_BAD_ADDR; - } - - if(len == 0) - { - NORFLASH_API_TRACE(2,"%s : len error! len = %d.", - __func__,len); - return NORFLASH_API_BAD_LEN; - } -#if defined(FLASH_API_SIMPLE) - async = false; -#endif - if(async) - { - // add to opera_info chain header. - lock = int_lock_global(); - result = _w_opera_add(mod_info,start_addr,len,(uint8_t*)buffer); - if(result == 0) - { - ret = NORFLASH_API_OK; - } - else - { - ret = NORFLASH_API_BUFFER_FULL; - } - int_unlock_global(lock); - NORFLASH_API_TRACE(4,"%s: _w_opera_add done. start_addr = 0x%x,len = 0x%x,ret = %d.", - __func__,start_addr,len,ret); - } - else - { - lock = int_lock_global(); - - // flush the opera of currently being processed. - if(norflash_api_info.cur_mod != NULL - && mod_info != norflash_api_info.cur_mod) - { - cur_mod_info = norflash_api_info.cur_mod; - while(cur_mod_info->state != NORFLASH_API_STATE_IDLE) - { - if(!_flush_is_allowed()) - { - continue; - } - bresult = _opera_flush(cur_mod_info,true); - if(!bresult) - { - norflash_api_info.cur_mod = NULL; - } - } - } - - // flush all of cur module opera. - do{ - if(!_flush_is_allowed()) - { - continue; - } - bresult = _opera_flush(mod_info,true); - }while(bresult); - FLASH_REMAP_START(mod_info->dev_id,start_addr,len); - pmu_flash_write_config(); - result = hal_norflash_write(mod_info->dev_id,start_addr, buffer, len); - pmu_flash_read_config(); - FLASH_REMAP_DONE(mod_info->dev_id,start_addr,len); - if(result == HAL_NORFLASH_OK) - { - ret = NORFLASH_API_OK; - } - else if(result == HAL_NORFLASH_BAD_ADDR) - { - ret = NORFLASH_API_BAD_ADDR; - } - else if(result == HAL_NORFLASH_BAD_LEN) - { - ret = NORFLASH_API_BAD_LEN; - } - else - { - ret = NORFLASH_API_ERR; - } - int_unlock_global(lock); - NORFLASH_API_TRACE(4,"%s: hal_norflash_write done. start_addr = 0x%x,len = 0x%x,ret = %d.", - __func__,start_addr,len,ret); - } - return ret; -} - -// -1: error, 0:all pending flash op flushed, 1:still pending flash op to be flushed -int norflash_api_flush(void) -{ - enum NORFLASH_API_MODULE_ID_T mod_id = NORFLASH_API_MODULE_ID_COUNT; - MODULE_INFO *mod_info = NULL; - uint32_t lock; - bool bret = false; - + if (async) { lock = int_lock_global(); - if(!norflash_api_info.is_inited) - { - NORFLASH_API_TRACE(1,"%s: norflash_api uninit!",__func__); - int_unlock_global(lock); - return -1; + + // add to opera_info chain header. + result = _e_opera_add(mod_info, start_addr, len); + if (result == 0) { + ret = NORFLASH_API_OK; + } else { + ret = NORFLASH_API_BUFFER_FULL; } + int_unlock_global(lock); + NORFLASH_API_TRACE( + 4, "%s: _e_opera_add done. start_addr = 0x%x,len = 0x%x,ret = %d.", + __func__, start_addr, len, ret); + } else { + lock = int_lock_global(); + // Handle the suspend operation. + if (norflash_api_info.cur_mod != NULL && + mod_info != norflash_api_info.cur_mod) { + cur_mod_info = norflash_api_info.cur_mod; + while (cur_mod_info->state != NORFLASH_API_STATE_IDLE) { + if (!_flush_is_allowed()) { + continue; + } + bresult = _opera_flush(cur_mod_info, true); + if (!bresult) { + norflash_api_info.cur_mod = NULL; + } + } + } + + // flush all of cur module opera. + // norflash_api_info.cur_mod_id = mod_id; + do { + if (!_flush_is_allowed()) { + continue; + } + bresult = _opera_flush(mod_info, true); + } while (bresult); + FLASH_REMAP_START(mod_info->dev_id, start_addr, len); + pmu_flash_write_config(); + result = hal_norflash_erase(mod_info->dev_id, start_addr, len); + pmu_flash_read_config(); + FLASH_REMAP_DONE(mod_info->dev_id, start_addr, len); + if (result == HAL_NORFLASH_OK) { + ret = NORFLASH_API_OK; + } else if (result == HAL_NORFLASH_BAD_ADDR) { + ret = NORFLASH_API_BAD_ADDR; + } else if (result == HAL_NORFLASH_BAD_LEN) { + ret = NORFLASH_API_BAD_LEN; + } else { + ret = NORFLASH_API_ERR; + } + int_unlock_global(lock); + NORFLASH_API_TRACE( + 4, + "%s: hal_norflash_erase done. start_addr = 0x%x,len = 0x%x,ret = %d.", + __func__, start_addr, len, ret); + } + // NORFLASH_API_TRACE(2,"%s: done.ret = %d.",__func__, ret); + return ret; +} + +enum NORFLASH_API_RET_T norflash_api_write(enum NORFLASH_API_MODULE_ID_T mod_id, + uint32_t start_addr, + const uint8_t *buffer, uint32_t len, + bool async) { + MODULE_INFO *mod_info = NULL; + MODULE_INFO *cur_mod_info = NULL; + uint32_t lock; + int32_t result; + bool bresult = false; + enum NORFLASH_API_RET_T ret; + + NORFLASH_API_TRACE(4, "%s: mod_id = %d,start_addr = 0x%x,len = 0x%x.", + __func__, mod_id, start_addr, len); + + if (!norflash_api_info.is_inited) { + NORFLASH_API_TRACE(1, "%s: norflash_api uninit!", __func__); + return NORFLASH_API_ERR_UNINIT; + } + + if (mod_id > NORFLASH_API_MODULE_ID_COUNT) { + NORFLASH_API_TRACE(2, "%s : mod_id error! mod_id = %d.", __func__, mod_id); + return NORFLASH_API_BAD_MOD_ID; + } + + mod_info = _get_module_info(mod_id); + if (!mod_info->is_inited) { + NORFLASH_API_TRACE(2, "%s :module unregistered! mod_id = %d.", __func__, + mod_id); + return NORFLASH_API_ERR_UNINIT; + } + + if (start_addr < mod_info->mod_base_addr || + start_addr + len > mod_info->mod_base_addr + mod_info->mod_len) { + NORFLASH_API_TRACE( + 3, "%s : writting out of range! start_address = 0x%x,len = 0x%x.", + __func__, mod_info->mod_base_addr, mod_info->mod_len); + return NORFLASH_API_BAD_ADDR; + } + + if (len == 0) { + NORFLASH_API_TRACE(2, "%s : len error! len = %d.", __func__, len); + return NORFLASH_API_BAD_LEN; + } #if defined(FLASH_API_SIMPLE) + async = false; +#endif + if (async) { + // add to opera_info chain header. + lock = int_lock_global(); + result = _w_opera_add(mod_info, start_addr, len, (uint8_t *)buffer); + if (result == 0) { + ret = NORFLASH_API_OK; + } else { + ret = NORFLASH_API_BUFFER_FULL; + } + int_unlock_global(lock); + NORFLASH_API_TRACE( + 4, "%s: _w_opera_add done. start_addr = 0x%x,len = 0x%x,ret = %d.", + __func__, start_addr, len, ret); + } else { + lock = int_lock_global(); + + // flush the opera of currently being processed. + if (norflash_api_info.cur_mod != NULL && + mod_info != norflash_api_info.cur_mod) { + cur_mod_info = norflash_api_info.cur_mod; + while (cur_mod_info->state != NORFLASH_API_STATE_IDLE) { + if (!_flush_is_allowed()) { + continue; + } + bresult = _opera_flush(cur_mod_info, true); + if (!bresult) { + norflash_api_info.cur_mod = NULL; + } + } + } + + // flush all of cur module opera. + do { + if (!_flush_is_allowed()) { + continue; + } + bresult = _opera_flush(mod_info, true); + } while (bresult); + FLASH_REMAP_START(mod_info->dev_id, start_addr, len); + pmu_flash_write_config(); + result = hal_norflash_write(mod_info->dev_id, start_addr, buffer, len); + pmu_flash_read_config(); + FLASH_REMAP_DONE(mod_info->dev_id, start_addr, len); + if (result == HAL_NORFLASH_OK) { + ret = NORFLASH_API_OK; + } else if (result == HAL_NORFLASH_BAD_ADDR) { + ret = NORFLASH_API_BAD_ADDR; + } else if (result == HAL_NORFLASH_BAD_LEN) { + ret = NORFLASH_API_BAD_LEN; + } else { + ret = NORFLASH_API_ERR; + } + int_unlock_global(lock); + NORFLASH_API_TRACE( + 4, + "%s: hal_norflash_write done. start_addr = 0x%x,len = 0x%x,ret = %d.", + __func__, start_addr, len, ret); + } + return ret; +} + +// -1: error, 0:all pending flash op flushed, 1:still pending flash op to be +// flushed +int norflash_api_flush(void) { + enum NORFLASH_API_MODULE_ID_T mod_id = NORFLASH_API_MODULE_ID_COUNT; + MODULE_INFO *mod_info = NULL; + uint32_t lock; + bool bret = false; + + lock = int_lock_global(); + if (!norflash_api_info.is_inited) { + NORFLASH_API_TRACE(1, "%s: norflash_api uninit!", __func__); + int_unlock_global(lock); + return -1; + } +#if defined(FLASH_API_SIMPLE) + int_unlock_global(lock); + return 0; +#endif + + if (!_flush_is_allowed()) { int_unlock_global(lock); return 0; -#endif + } - if(!_flush_is_allowed()) - { - int_unlock_global(lock); - return 0; - } - - mod_info = _get_cur_mod(); - if(!mod_info) - { - int_unlock_global(lock); - return 0; - } - mod_id = _get_mod_id(mod_info); - - norflash_api_info.cur_mod_id = mod_id; - norflash_api_info.cur_mod = mod_info; - bret = _opera_flush(mod_info,false); - if(!bret) - { - norflash_api_info.cur_mod = NULL; - } + mod_info = _get_cur_mod(); + if (!mod_info) { int_unlock_global(lock); + return 0; + } + mod_id = _get_mod_id(mod_info); - return 1; + norflash_api_info.cur_mod_id = mod_id; + norflash_api_info.cur_mod = mod_info; + bret = _opera_flush(mod_info, false); + if (!bret) { + norflash_api_info.cur_mod = NULL; + } + int_unlock_global(lock); + + return 1; } -bool norflash_api_buffer_is_free( - enum NORFLASH_API_MODULE_ID_T mod_id) -{ - MODULE_INFO *mod_info = NULL; - uint32_t count; +bool norflash_api_buffer_is_free(enum NORFLASH_API_MODULE_ID_T mod_id) { + MODULE_INFO *mod_info = NULL; + uint32_t count; - if(mod_id >= NORFLASH_API_MODULE_ID_COUNT) - { - ASSERT(0,"%s : mod_id error! mod_id = %d.",__func__, mod_id); - } + if (mod_id >= NORFLASH_API_MODULE_ID_COUNT) { + ASSERT(0, "%s : mod_id error! mod_id = %d.", __func__, mod_id); + } - mod_info = _get_module_info(mod_id); - if(!mod_info->is_inited) - { - ASSERT(0,"%s : mod_id error! mod_id = %d.",__func__, mod_id); - } + mod_info = _get_module_info(mod_id); + if (!mod_info->is_inited) { + ASSERT(0, "%s : mod_id error! mod_id = %d.", __func__, mod_id); + } - count = _get_ew_count(mod_info); - if(count > 0) - { - return false; - } - else - { - return true; - } + count = _get_ew_count(mod_info); + if (count > 0) { + return false; + } else { + return true; + } } -uint32_t norflash_api_get_used_buffer_count( - enum NORFLASH_API_MODULE_ID_T mod_id, - enum NORFLASH_API_OPRATION_TYPE type - ) -{ - MODULE_INFO *mod_info = NULL; - uint32_t count = 0; +uint32_t +norflash_api_get_used_buffer_count(enum NORFLASH_API_MODULE_ID_T mod_id, + enum NORFLASH_API_OPRATION_TYPE type) { + MODULE_INFO *mod_info = NULL; + uint32_t count = 0; - if(mod_id >= NORFLASH_API_MODULE_ID_COUNT) - { - ASSERT(0,"%s : mod_id error! mod_id = %d.",__func__, mod_id); - } + if (mod_id >= NORFLASH_API_MODULE_ID_COUNT) { + ASSERT(0, "%s : mod_id error! mod_id = %d.", __func__, mod_id); + } - mod_info = _get_module_info(mod_id); - if(!mod_info->is_inited) - { - ASSERT(0,"%s : mod_id error! mod_id = %d.",__func__, mod_id); - } - if(type & NORFLASH_API_WRITTING) - { - count = _get_w_count(mod_info); - } + mod_info = _get_module_info(mod_id); + if (!mod_info->is_inited) { + ASSERT(0, "%s : mod_id error! mod_id = %d.", __func__, mod_id); + } + if (type & NORFLASH_API_WRITTING) { + count = _get_w_count(mod_info); + } - if(type & NORFLASH_API_ERASING) - { - count += _get_e_count(mod_info); - } - return count; + if (type & NORFLASH_API_ERASING) { + count += _get_e_count(mod_info); + } + return count; } -uint32_t norflash_api_get_free_buffer_count( - enum NORFLASH_API_OPRATION_TYPE type - ) -{ - MODULE_INFO *mod_info = NULL; - uint32_t i; - uint32_t used_count = 0; - uint32_t free_count = 0; +uint32_t +norflash_api_get_free_buffer_count(enum NORFLASH_API_OPRATION_TYPE type) { + MODULE_INFO *mod_info = NULL; + uint32_t i; + uint32_t used_count = 0; + uint32_t free_count = 0; - if(type & NORFLASH_API_WRITTING) - { - for(i = NORFLASH_API_MODULE_ID_LOG_DUMP; i < NORFLASH_API_MODULE_ID_COUNT; i ++) - { - mod_info = _get_module_info((enum NORFLASH_API_MODULE_ID_T)i); - if(mod_info->is_inited) - { - used_count += _get_w_count(mod_info); - } - } - ASSERT(used_count <= NORFLASH_API_OPRA_LIST_LEN,"writting opra count error!"); - free_count += (NORFLASH_API_OPRA_LIST_LEN - used_count); + if (type & NORFLASH_API_WRITTING) { + for (i = NORFLASH_API_MODULE_ID_LOG_DUMP; i < NORFLASH_API_MODULE_ID_COUNT; + i++) { + mod_info = _get_module_info((enum NORFLASH_API_MODULE_ID_T)i); + if (mod_info->is_inited) { + used_count += _get_w_count(mod_info); + } } + ASSERT(used_count <= NORFLASH_API_OPRA_LIST_LEN, + "writting opra count error!"); + free_count += (NORFLASH_API_OPRA_LIST_LEN - used_count); + } - if(type & NORFLASH_API_ERASING) - { - for(i = NORFLASH_API_MODULE_ID_LOG_DUMP; i < NORFLASH_API_MODULE_ID_COUNT; i ++) - { - mod_info = _get_module_info((enum NORFLASH_API_MODULE_ID_T)i); - if(mod_info->is_inited) - { - used_count += _get_e_count(mod_info); - } - } - ASSERT(used_count <= NORFLASH_API_OPRA_LIST_LEN,"erase opra count error!"); - free_count += (NORFLASH_API_OPRA_LIST_LEN - used_count); + if (type & NORFLASH_API_ERASING) { + for (i = NORFLASH_API_MODULE_ID_LOG_DUMP; i < NORFLASH_API_MODULE_ID_COUNT; + i++) { + mod_info = _get_module_info((enum NORFLASH_API_MODULE_ID_T)i); + if (mod_info->is_inited) { + used_count += _get_e_count(mod_info); + } } - return free_count; + ASSERT(used_count <= NORFLASH_API_OPRA_LIST_LEN, "erase opra count error!"); + free_count += (NORFLASH_API_OPRA_LIST_LEN - used_count); + } + return free_count; } +void norflash_api_flush_all(void) { + int ret; + int cnt = 0; -void norflash_api_flush_all(void) -{ - int ret; - int cnt = 0; - - norflash_api_flush_enable_all(); - do - { - ret = norflash_api_flush(); - if(ret == 1) - { - cnt ++; - } - } while (1 == ret); - - NORFLASH_API_TRACE(2,"%s: done. cnt = %d.",__func__,cnt); -} - -void norflash_api_flush_disable(enum NORFLASH_API_USER user_id,uint32_t cb) -{ - if(!norflash_api_info.is_inited) - { - return; + norflash_api_flush_enable_all(); + do { + ret = norflash_api_flush(); + if (ret == 1) { + cnt++; } - ASSERT(user_id < NORFLASH_API_USER_COUNTS, "%s: user_id(%d) error!", __func__, user_id); - _flush_disable(user_id,cb); + } while (1 == ret); + + NORFLASH_API_TRACE(2, "%s: done. cnt = %d.", __func__, cnt); } -void norflash_api_flush_enable(enum NORFLASH_API_USER user_id) -{ - if(!norflash_api_info.is_inited) - { - return; - } - ASSERT(user_id < NORFLASH_API_USER_COUNTS, "%s: user_id(%d) too large!", __func__, user_id); - _flush_enable(user_id); +void norflash_api_flush_disable(enum NORFLASH_API_USER user_id, uint32_t cb) { + if (!norflash_api_info.is_inited) { + return; + } + ASSERT(user_id < NORFLASH_API_USER_COUNTS, "%s: user_id(%d) error!", __func__, + user_id); + _flush_disable(user_id, cb); } -void norflash_api_flush_enable_all(void) -{ - uint32_t user_id; - - if(!norflash_api_info.is_inited) - { - return; - } - for(user_id = NORFLASH_API_USER_CP; user_id < NORFLASH_API_USER_COUNTS; user_id ++) - { - _flush_enable((enum NORFLASH_API_USER)user_id); - } +void norflash_api_flush_enable(enum NORFLASH_API_USER user_id) { + if (!norflash_api_info.is_inited) { + return; + } + ASSERT(user_id < NORFLASH_API_USER_COUNTS, "%s: user_id(%d) too large!", + __func__, user_id); + _flush_enable(user_id); } +void norflash_api_flush_enable_all(void) { + uint32_t user_id; -enum NORFLASH_API_STATE norflash_api_get_state(enum NORFLASH_API_MODULE_ID_T mod_id) -{ - ASSERT(mod_id < NORFLASH_API_MODULE_ID_COUNT,"%s : mod_id error! mod_id = %d.",__func__, mod_id); - return norflash_api_info.mod_info[mod_id].state; + if (!norflash_api_info.is_inited) { + return; + } + for (user_id = NORFLASH_API_USER_CP; user_id < NORFLASH_API_USER_COUNTS; + user_id++) { + _flush_enable((enum NORFLASH_API_USER)user_id); + } } -void norflash_flush_all_pending_op(void) -{ - norflash_api_flush_all(); +enum NORFLASH_API_STATE +norflash_api_get_state(enum NORFLASH_API_MODULE_ID_T mod_id) { + ASSERT(mod_id < NORFLASH_API_MODULE_ID_COUNT, + "%s : mod_id error! mod_id = %d.", __func__, mod_id); + return norflash_api_info.mod_info[mod_id].state; } +void norflash_flush_all_pending_op(void) { norflash_api_flush_all(); } + void app_flush_pending_flash_op(enum NORFLASH_API_MODULE_ID_T module, - enum NORFLASH_API_OPRATION_TYPE type) -{ - hal_trace_pause(); - do - { - norflash_api_flush(); - if (NORFLASH_API_ALL != type) - { - if (0 == norflash_api_get_used_buffer_count(module, type)) - { - break; - } - } - else - { - if (norflash_api_buffer_is_free(module)) - { - break; - } - } - osDelay(10); - } while (1); + enum NORFLASH_API_OPRATION_TYPE type) { + hal_trace_pause(); + do { + norflash_api_flush(); + if (NORFLASH_API_ALL != type) { + if (0 == norflash_api_get_used_buffer_count(module, type)) { + break; + } + } else { + if (norflash_api_buffer_is_free(module)) { + break; + } + } + osDelay(10); + } while (1); - hal_trace_continue(); + hal_trace_continue(); } -void app_flash_page_erase(enum NORFLASH_API_MODULE_ID_T module, uint32_t flashOffset) -{ - // check whether the flash has been erased - bool isEmptyPage = true; - uint32_t *ptrStartFlashAddr = ( uint32_t * )(FLASH_NC_BASE + flashOffset); - for (uint32_t index = 0; index < FLASH_SECTOR_SIZE / sizeof(uint32_t); index++) - { - if (0xFFFFFFFF != ptrStartFlashAddr[index]) - { - isEmptyPage = false; - break; - } +void app_flash_page_erase(enum NORFLASH_API_MODULE_ID_T module, + uint32_t flashOffset) { + // check whether the flash has been erased + bool isEmptyPage = true; + uint32_t *ptrStartFlashAddr = (uint32_t *)(FLASH_NC_BASE + flashOffset); + for (uint32_t index = 0; index < FLASH_SECTOR_SIZE / sizeof(uint32_t); + index++) { + if (0xFFFFFFFF != ptrStartFlashAddr[index]) { + isEmptyPage = false; + break; } + } - if (isEmptyPage) - { - return; + if (isEmptyPage) { + return; + } + + uint32_t lock; + enum NORFLASH_API_RET_T ret; + + flashOffset &= 0xFFFFFF; + do { + lock = int_lock_global(); + hal_trace_pause(); + ret = norflash_api_erase(module, (FLASH_NC_BASE + flashOffset), + FLASH_SECTOR_SIZE, true); + hal_trace_continue(); + int_unlock_global(lock); + + if (NORFLASH_API_OK == ret) { + TRACE(1, "%s: norflash_api_erase ok!", __func__); + break; + } else if (NORFLASH_API_BUFFER_FULL == ret) { + TRACE(0, "Flash async cache overflow! To flush it."); + app_flush_pending_flash_op(module, NORFLASH_API_ERASING); + } else { + ASSERT(0, "%s: norflash_api_erase failed. ret = %d", __FUNCTION__, ret); } - - uint32_t lock; - enum NORFLASH_API_RET_T ret; - - flashOffset &= 0xFFFFFF; - do - { - lock = int_lock_global(); - hal_trace_pause(); - ret = norflash_api_erase(module, - (FLASH_NC_BASE + flashOffset), - FLASH_SECTOR_SIZE, - true); - hal_trace_continue(); - int_unlock_global(lock); - - if (NORFLASH_API_OK == ret) - { - TRACE(1,"%s: norflash_api_erase ok!", __func__); - break; - } - else if (NORFLASH_API_BUFFER_FULL == ret) - { - TRACE(0,"Flash async cache overflow! To flush it."); - app_flush_pending_flash_op(module, NORFLASH_API_ERASING); - } - else - { - ASSERT(0, "%s: norflash_api_erase failed. ret = %d", __FUNCTION__, ret); - } - } while (1); + } while (1); } void app_flash_page_program(enum NORFLASH_API_MODULE_ID_T module, - uint32_t flashOffset, - uint8_t *ptr, - uint32_t len, - bool synWrite) -{ - uint32_t lock; - enum NORFLASH_API_RET_T ret; - bool is_async = false; + uint32_t flashOffset, uint8_t *ptr, uint32_t len, + bool synWrite) { + uint32_t lock; + enum NORFLASH_API_RET_T ret; + bool is_async = false; - flashOffset &= 0xFFFFFF; + flashOffset &= 0xFFFFFF; - if (synWrite) - { - is_async = false; + if (synWrite) { + is_async = false; + } else { + is_async = true; + } + + do { + lock = int_lock_global(); + hal_trace_pause(); + + ret = norflash_api_write(module, (FLASH_NC_BASE + flashOffset), ptr, len, + is_async); + + hal_trace_continue(); + + int_unlock_global(lock); + + if (NORFLASH_API_OK == ret) { + TRACE(1, "%s: norflash_api_write ok!", __func__); + break; + } else if (NORFLASH_API_BUFFER_FULL == ret) { + TRACE(0, "Flash async cache overflow! To flush it."); + app_flush_pending_flash_op(module, NORFLASH_API_WRITTING); + } else { + ASSERT(0, "%s: norflash_api_write failed. ret = %d", __FUNCTION__, ret); } - else - { - is_async = true; - } - - do - { - lock = int_lock_global(); - hal_trace_pause(); - - ret = norflash_api_write(module, - (FLASH_NC_BASE + flashOffset), - ptr, - len, - is_async); - - hal_trace_continue(); - - int_unlock_global(lock); - - if (NORFLASH_API_OK == ret) - { - TRACE(1,"%s: norflash_api_write ok!", __func__); - break; - } - else if (NORFLASH_API_BUFFER_FULL == ret) - { - TRACE(0,"Flash async cache overflow! To flush it."); - app_flush_pending_flash_op(module, NORFLASH_API_WRITTING); - } - else - { - ASSERT(0, "%s: norflash_api_write failed. ret = %d", __FUNCTION__, ret); - } - } while (1); + } while (1); } - - diff --git a/services/nv_section/aud_section/aud_section.c b/services/nv_section/aud_section/aud_section.c index b5d0f90..17875b7 100644 --- a/services/nv_section/aud_section/aud_section.c +++ b/services/nv_section/aud_section/aud_section.c @@ -13,14 +13,14 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "hal_trace.h" #include "aud_section.h" -#include "crc32.h" -#include "tgt_hardware.h" -#include "string.h" -#include "hal_norflash.h" #include "cmsis.h" +#include "crc32.h" +#include "hal_norflash.h" +#include "hal_trace.h" +#include "string.h" +#include "tgt_hardware.h" +#include #ifdef __ARMCC_VERSION #include "link_sym_armclang.h" #endif @@ -28,11 +28,11 @@ extern uint32_t __aud_start[]; #ifndef ANC_COEF_LIST_NUM -#define ANC_COEF_LIST_NUM 0 +#define ANC_COEF_LIST_NUM 0 #endif -#define MAGIC_NUMBER 0xBE57 -#define USERDATA_VERSION 0x0001 +#define MAGIC_NUMBER 0xBE57 +#define USERDATA_VERSION 0x0001 static uint32_t section_device_length[AUDIO_SECTION_DEVICE_NUM] = { AUDIO_SECTION_LENGTH_ANC, @@ -40,176 +40,181 @@ static uint32_t section_device_length[AUDIO_SECTION_DEVICE_NUM] = { AUDIO_SECTION_LENGTH_SPEECH, }; -static uint32_t audio_section_get_device_addr_offset(uint32_t device) -{ - ASSERT(device < AUDIO_SECTION_DEVICE_NUM, "[%s] device(%d) >= AUDIO_SECTION_DEVICE_NUM", __func__, device); +static uint32_t audio_section_get_device_addr_offset(uint32_t device) { + ASSERT(device < AUDIO_SECTION_DEVICE_NUM, + "[%s] device(%d) >= AUDIO_SECTION_DEVICE_NUM", __func__, device); - uint32_t addr_offset = 0; + uint32_t addr_offset = 0; - for (uint32_t i=0; ihead.magic = MAGIC_NUMBER; - section_ptr->head.version = USERDATA_VERSION; - section_ptr->device = device; - section_ptr->cfg_len = len; + section_ptr->head.magic = MAGIC_NUMBER; + section_ptr->head.version = USERDATA_VERSION; + section_ptr->device = device; + section_ptr->cfg_len = len; - // calculate crc - crc = crc32(0, (unsigned char *)section_ptr + AUDIO_SECTION_CFG_RESERVED_LEN, len - AUDIO_SECTION_CFG_RESERVED_LEN); - section_ptr->head.crc = crc; + // calculate crc + crc = crc32(0, (unsigned char *)section_ptr + AUDIO_SECTION_CFG_RESERVED_LEN, + len - AUDIO_SECTION_CFG_RESERVED_LEN); + section_ptr->head.crc = crc; - addr_start = (uint32_t)__aud_start + audio_section_get_device_addr_offset(device); + addr_start = + (uint32_t)__aud_start + audio_section_get_device_addr_offset(device); #ifdef AUDIO_SECTION_DEBUG - TRACE(2,"[%s] len = %d", __func__, len); - TRACE(2,"[%s] addr_start = 0x%x", __func__, addr_start); - TRACE(2,"[%s] block length = 0x%x", __func__, section_device_length[device]); + TRACE(2, "[%s] len = %d", __func__, len); + TRACE(2, "[%s] addr_start = 0x%x", __func__, addr_start); + TRACE(2, "[%s] block length = 0x%x", __func__, section_device_length[device]); #endif - // FIXME: CHECK return value - enum HAL_NORFLASH_RET_T flash_opt_res; - uint32_t flag = int_lock(); - flash_opt_res = hal_norflash_erase(HAL_NORFLASH_ID_0, addr_start, section_device_length[device]); - int_unlock(flag); + // FIXME: CHECK return value + enum HAL_NORFLASH_RET_T flash_opt_res; + uint32_t flag = int_lock(); + flash_opt_res = hal_norflash_erase(HAL_NORFLASH_ID_0, addr_start, + section_device_length[device]); + int_unlock(flag); - if (flash_opt_res) - { - TRACE(2,"[%s] ERROR: erase flash res = %d", __func__, flash_opt_res); - return flash_opt_res; - } + if (flash_opt_res) { + TRACE(2, "[%s] ERROR: erase flash res = %d", __func__, flash_opt_res); + return flash_opt_res; + } - flag = int_lock(); - flash_opt_res = hal_norflash_write(HAL_NORFLASH_ID_0, addr_start, (uint8_t *)section_ptr, len); - int_unlock(flag); - - if (flash_opt_res) - { - TRACE(2,"[%s] ERROR: write flash res = %d", __func__, flash_opt_res); - return flash_opt_res; - } + flag = int_lock(); + flash_opt_res = hal_norflash_write(HAL_NORFLASH_ID_0, addr_start, + (uint8_t *)section_ptr, len); + int_unlock(flag); + if (flash_opt_res) { + TRACE(2, "[%s] ERROR: write flash res = %d", __func__, flash_opt_res); + return flash_opt_res; + } #ifdef AUDIO_SECTION_DEBUG - TRACE(1,"********************[%s]********************", __func__); - TRACE(1,"magic: 0x%x", section_ptr->head.magic); - TRACE(1,"version: 0x%x", section_ptr->head.version); - TRACE(1,"crc: 0x%x", section_ptr->head.crc); - TRACE(1,"device: %d", section_ptr->device); - TRACE(1,"cfg_len: %d", section_ptr->cfg_len); - TRACE(0,"********************END********************"); + TRACE(1, "********************[%s]********************", __func__); + TRACE(1, "magic: 0x%x", section_ptr->head.magic); + TRACE(1, "version: 0x%x", section_ptr->head.version); + TRACE(1, "crc: 0x%x", section_ptr->head.crc); + TRACE(1, "device: %d", section_ptr->device); + TRACE(1, "cfg_len: %d", section_ptr->cfg_len); + TRACE(0, "********************END********************"); #endif - // audio_section_t *section_read_ptr = audio_section_get_device_ptr(device); - // check + // audio_section_t *section_read_ptr = audio_section_get_device_ptr(device); + // check - return 0; + return 0; } -int audio_section_load_cfg(uint32_t device, uint8_t *cfg, uint32_t len) -{ - audio_section_t *section_ptr = audio_section_get_device_ptr(device); - uint32_t crc = 0; +int audio_section_load_cfg(uint32_t device, uint8_t *cfg, uint32_t len) { + audio_section_t *section_ptr = audio_section_get_device_ptr(device); + uint32_t crc = 0; #ifdef AUDIO_SECTION_DEBUG - TRACE(1,"********************[%s]********************", __func__); - TRACE(1,"magic: 0x%x", section_ptr->head.magic); - TRACE(1,"version: 0x%x", section_ptr->head.version); - TRACE(1,"crc: 0x%x", section_ptr->head.crc); - TRACE(1,"device: %d", section_ptr->device); - TRACE(1,"cfg_len: %d", section_ptr->cfg_len); - TRACE(0,"********************END********************"); + TRACE(1, "********************[%s]********************", __func__); + TRACE(1, "magic: 0x%x", section_ptr->head.magic); + TRACE(1, "version: 0x%x", section_ptr->head.version); + TRACE(1, "crc: 0x%x", section_ptr->head.crc); + TRACE(1, "device: %d", section_ptr->device); + TRACE(1, "cfg_len: %d", section_ptr->cfg_len); + TRACE(0, "********************END********************"); #endif - if(section_ptr->head.magic != MAGIC_NUMBER) - { - TRACE(3,"[%s] WARNING: Different magic number (%x != %x)", __func__, section_ptr->head.magic, MAGIC_NUMBER); - return -1; - } + if (section_ptr->head.magic != MAGIC_NUMBER) { + TRACE(3, "[%s] WARNING: Different magic number (%x != %x)", __func__, + section_ptr->head.magic, MAGIC_NUMBER); + return -1; + } - // Calculate crc and check crc value - crc = crc32(0, (unsigned char *)section_ptr + AUDIO_SECTION_CFG_RESERVED_LEN, len - AUDIO_SECTION_CFG_RESERVED_LEN); + // Calculate crc and check crc value + crc = crc32(0, (unsigned char *)section_ptr + AUDIO_SECTION_CFG_RESERVED_LEN, + len - AUDIO_SECTION_CFG_RESERVED_LEN); - if(section_ptr->head.crc != crc) - { - TRACE(3,"[%s] WARNING: Different crc (%x != %x)", __func__, section_ptr->head.crc, crc); - return -2; - } + if (section_ptr->head.crc != crc) { + TRACE(3, "[%s] WARNING: Different crc (%x != %x)", __func__, + section_ptr->head.crc, crc); + return -2; + } - if(section_ptr->device != device) - { - TRACE(3,"[%s] WARNING: Different device (%d != %d)", __func__, section_ptr->device, device); - return -3; - } + if (section_ptr->device != device) { + TRACE(3, "[%s] WARNING: Different device (%d != %d)", __func__, + section_ptr->device, device); + return -3; + } - if(section_ptr->cfg_len != len) - { - TRACE(3,"[%s] WARNING: Different length (%d != %d)", __func__, section_ptr->cfg_len, len); - return -4; - } + if (section_ptr->cfg_len != len) { + TRACE(3, "[%s] WARNING: Different length (%d != %d)", __func__, + section_ptr->cfg_len, len); + return -4; + } - memcpy(cfg, section_ptr, len); + memcpy(cfg, section_ptr, len); - return 0; + return 0; } -int anccfg_loadfrom_audsec(const struct_anc_cfg *list[], const struct_anc_cfg *list_44p1k[], uint32_t count) -{ +int anccfg_loadfrom_audsec(const struct_anc_cfg *list[], + const struct_anc_cfg *list_44p1k[], uint32_t count) { #ifdef PROGRAMMER - return 1; + return 1; #else // !PROGRAMMER #ifdef CHIP_BEST1000 - ASSERT(0, "[%s] Can not support anc load in this branch!!!", __func__); + ASSERT(0, "[%s] Can not support anc load in this branch!!!", __func__); #else - unsigned int re_calc_crc,i; - const pctool_aud_section *audsec_ptr; + unsigned int re_calc_crc, i; + const pctool_aud_section *audsec_ptr; - audsec_ptr = (pctool_aud_section *)__aud_start; - TRACE(3,"0x%x,0x%x,0x%x",audsec_ptr->sec_head.magic,audsec_ptr->sec_head.version,audsec_ptr->sec_head.crc); - if (audsec_ptr->sec_head.magic != aud_section_magic) { - TRACE(0,"Invalid aud section - magic"); - return 1; - } - re_calc_crc = crc32(0,(unsigned char *)&(audsec_ptr->sec_body),sizeof(audsec_body)-4); - if (re_calc_crc != audsec_ptr->sec_head.crc){ - TRACE(0,"crc verify failure, invalid aud section."); - return 1; - } - TRACE(0,"Valid aud section."); - for(i=0;isec_body.anc_config.anc_config_arr[i].anc_cfg[PCTOOL_SAMPLERATE_48X8K]); + audsec_ptr = (pctool_aud_section *)__aud_start; + TRACE(3, "0x%x,0x%x,0x%x", audsec_ptr->sec_head.magic, + audsec_ptr->sec_head.version, audsec_ptr->sec_head.crc); + if (audsec_ptr->sec_head.magic != aud_section_magic) { + TRACE(0, "Invalid aud section - magic"); + return 1; + } + re_calc_crc = crc32(0, (unsigned char *)&(audsec_ptr->sec_body), + sizeof(audsec_body) - 4); + if (re_calc_crc != audsec_ptr->sec_head.crc) { + TRACE(0, "crc verify failure, invalid aud section."); + return 1; + } + TRACE(0, "Valid aud section."); + for (i = 0; i < ANC_COEF_LIST_NUM; i++) + list[i] = + (struct_anc_cfg *)&(audsec_ptr->sec_body.anc_config.anc_config_arr[i] + .anc_cfg[PCTOOL_SAMPLERATE_48X8K]); #if (AUD_SECTION_STRUCT_VERSION == 3) - for(i=0;isec_body.anc_config.anc_config_arr[i].anc_cfg[PCTOOL_SAMPLERATE_48X8K]); + for (i = 0; i < ANC_COEF_LIST_NUM; i++) + list_44p1k[i] = + (struct_anc_cfg *)&(audsec_ptr->sec_body.anc_config.anc_config_arr[i] + .anc_cfg[PCTOOL_SAMPLERATE_48X8K]); #else - for(i=0;isec_body.anc_config.anc_config_arr[i].anc_cfg[PCTOOL_SAMPLERATE_44_1X8K]); + for (i = 0; i < ANC_COEF_LIST_NUM; i++) + list_44p1k[i] = + (struct_anc_cfg *)&(audsec_ptr->sec_body.anc_config.anc_config_arr[i] + .anc_cfg[PCTOOL_SAMPLERATE_44_1X8K]); #endif #endif - return 0; + return 0; #endif // !PROGRAMMER } - diff --git a/services/nv_section/customparam_section/customparam_section.c b/services/nv_section/customparam_section/customparam_section.c index b6c780f..882ad3d 100644 --- a/services/nv_section/customparam_section/customparam_section.c +++ b/services/nv_section/customparam_section/customparam_section.c @@ -13,102 +13,96 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "hal_trace.h" #include "customparam_section.h" +#include "hal_trace.h" +#include #include extern uint32_t __custom_parameter_start[]; static uint8_t isCustomParamSectionValid = false; -void nv_custom_parameter_section_init(void) -{ - isCustomParamSectionValid = false; - - if (CUSTOMPARAM_MAGIC_CODE == - ((CUSTOM_PARAM_SECTION_HEADER_T *)__custom_parameter_start)->magic_code) - { - // check whether the length is correct - uint8_t* startLogicAddr = (uint8_t *)__custom_parameter_start; - - CUSTOM_PARAM_SECTION_HEADER_T* pSectoinHeader = - (CUSTOM_PARAM_SECTION_HEADER_T *)startLogicAddr; +void nv_custom_parameter_section_init(void) { + isCustomParamSectionValid = false; - uint32_t totalDataLen = OFFSETOF(CUSTOM_PARAM_SECTION_HEADER_T, entryCount) + - pSectoinHeader->length; + if (CUSTOMPARAM_MAGIC_CODE == + ((CUSTOM_PARAM_SECTION_HEADER_T *)__custom_parameter_start)->magic_code) { + // check whether the length is correct + uint8_t *startLogicAddr = (uint8_t *)__custom_parameter_start; - if (totalDataLen > CUSTOMPARAM_SECTION_SIZE) - { - return; - } - - uint32_t offset = sizeof(CUSTOM_PARAM_SECTION_HEADER_T); - for (uint32_t entry = 0;entry < pSectoinHeader->entryCount;entry++) - { - CUSTOM_PARAM_ENTRY_HEADER_T* pEntryHeader = - (CUSTOM_PARAM_ENTRY_HEADER_T *)((uint8_t *)__custom_parameter_start + offset); - offset += (sizeof(CUSTOM_PARAM_ENTRY_HEADER_T) + pEntryHeader->paramLen); - if (offset > CUSTOMPARAM_SECTION_SIZE) - { - return; - } - } - - isCustomParamSectionValid = true; + CUSTOM_PARAM_SECTION_HEADER_T *pSectoinHeader = + (CUSTOM_PARAM_SECTION_HEADER_T *)startLogicAddr; - uint8_t serialNumber[CUSTOM_PARAM_SERIAL_NUM_LEN]; - uint32_t serialNumParamLen = 0; - bool isSuccessfullyLoaded = nv_custom_parameter_section_get_entry(CUSTOM_PARAM_SERIAL_NUM_INDEX, serialNumber, - &serialNumParamLen); - if (isSuccessfullyLoaded) - { - TRACE(0,"Serial number is:"); - DUMP8("%02x ", serialNumber, sizeof(serialNumber)); - } - } -} + uint32_t totalDataLen = + OFFSETOF(CUSTOM_PARAM_SECTION_HEADER_T, entryCount) + + pSectoinHeader->length; -bool nv_custom_parameter_section_get_entry(uint16_t paramIndex, uint8_t* pParamVal, uint32_t* pParamLen) -{ - if (isCustomParamSectionValid) - { - uint8_t* startLogicAddr = (uint8_t *)__custom_parameter_start; - - CUSTOM_PARAM_SECTION_HEADER_T* pSectoinHeader = - (CUSTOM_PARAM_SECTION_HEADER_T *)startLogicAddr; - - uint32_t offset = sizeof(CUSTOM_PARAM_SECTION_HEADER_T); - for (uint32_t entry = 0;entry < pSectoinHeader->entryCount;entry++) - { - CUSTOM_PARAM_ENTRY_HEADER_T* pEntryHeader = - (CUSTOM_PARAM_ENTRY_HEADER_T *)((uint8_t *)__custom_parameter_start + offset); - if (paramIndex == pEntryHeader->paramIndex) - { - memcpy(pParamVal, ((uint8_t *)pEntryHeader)+sizeof(CUSTOM_PARAM_ENTRY_HEADER_T), - pEntryHeader->paramLen); - *pParamLen = pEntryHeader->paramLen; - return true; - } - offset += (sizeof(CUSTOM_PARAM_ENTRY_HEADER_T) + pEntryHeader->paramLen); - } - } - - return false; -} - -#if defined(BISTO_ENABLED)||defined(GFPS_ENABLED) -uint32_t Get_ModelId(void) -{ - uint8_t Model_ID[CUSTOM_PARAM_Model_ID_LEN]; - uint32_t ModelIdValue, Model_ID_ParamLen = 0; - if(nv_custom_parameter_section_get_entry( CUSTOM_PARAM_Mode_ID_INDEX, - Model_ID, &Model_ID_ParamLen)) - { - ModelIdValue = (Model_ID[0]<<16) | (Model_ID[1]<<8) | Model_ID[2]; - TRACE(1,"Model id is :0x%08x\n",ModelIdValue); - return ModelIdValue; + if (totalDataLen > CUSTOMPARAM_SECTION_SIZE) { + return; } - return 0; + + uint32_t offset = sizeof(CUSTOM_PARAM_SECTION_HEADER_T); + for (uint32_t entry = 0; entry < pSectoinHeader->entryCount; entry++) { + CUSTOM_PARAM_ENTRY_HEADER_T *pEntryHeader = + (CUSTOM_PARAM_ENTRY_HEADER_T *)((uint8_t *)__custom_parameter_start + + offset); + offset += (sizeof(CUSTOM_PARAM_ENTRY_HEADER_T) + pEntryHeader->paramLen); + if (offset > CUSTOMPARAM_SECTION_SIZE) { + return; + } + } + + isCustomParamSectionValid = true; + + uint8_t serialNumber[CUSTOM_PARAM_SERIAL_NUM_LEN]; + uint32_t serialNumParamLen = 0; + bool isSuccessfullyLoaded = nv_custom_parameter_section_get_entry( + CUSTOM_PARAM_SERIAL_NUM_INDEX, serialNumber, &serialNumParamLen); + if (isSuccessfullyLoaded) { + TRACE(0, "Serial number is:"); + DUMP8("%02x ", serialNumber, sizeof(serialNumber)); + } + } +} + +bool nv_custom_parameter_section_get_entry(uint16_t paramIndex, + uint8_t *pParamVal, + uint32_t *pParamLen) { + if (isCustomParamSectionValid) { + uint8_t *startLogicAddr = (uint8_t *)__custom_parameter_start; + + CUSTOM_PARAM_SECTION_HEADER_T *pSectoinHeader = + (CUSTOM_PARAM_SECTION_HEADER_T *)startLogicAddr; + + uint32_t offset = sizeof(CUSTOM_PARAM_SECTION_HEADER_T); + for (uint32_t entry = 0; entry < pSectoinHeader->entryCount; entry++) { + CUSTOM_PARAM_ENTRY_HEADER_T *pEntryHeader = + (CUSTOM_PARAM_ENTRY_HEADER_T *)((uint8_t *)__custom_parameter_start + + offset); + if (paramIndex == pEntryHeader->paramIndex) { + memcpy(pParamVal, + ((uint8_t *)pEntryHeader) + sizeof(CUSTOM_PARAM_ENTRY_HEADER_T), + pEntryHeader->paramLen); + *pParamLen = pEntryHeader->paramLen; + return true; + } + offset += (sizeof(CUSTOM_PARAM_ENTRY_HEADER_T) + pEntryHeader->paramLen); + } + } + + return false; +} + +#if defined(BISTO_ENABLED) || defined(GFPS_ENABLED) +uint32_t Get_ModelId(void) { + uint8_t Model_ID[CUSTOM_PARAM_Model_ID_LEN]; + uint32_t ModelIdValue, Model_ID_ParamLen = 0; + if (nv_custom_parameter_section_get_entry(CUSTOM_PARAM_Mode_ID_INDEX, + Model_ID, &Model_ID_ParamLen)) { + ModelIdValue = (Model_ID[0] << 16) | (Model_ID[1] << 8) | Model_ID[2]; + TRACE(1, "Model id is :0x%08x\n", ModelIdValue); + return ModelIdValue; + } + return 0; } #endif diff --git a/services/nv_section/customparam_section/customparam_section.h b/services/nv_section/customparam_section/customparam_section.h index 60da94c..e674d86 100644 --- a/services/nv_section/customparam_section/customparam_section.h +++ b/services/nv_section/customparam_section/customparam_section.h @@ -15,55 +15,53 @@ ****************************************************************************/ #ifndef __CUSTOMPARAM_SECTION_H__ #define __CUSTOMPARAM_SECTION_H__ +#include +#include #ifdef __cplusplus extern "C" { #endif // Could be customized -#define CUSTOMPARAM_MAGIC_CODE 0x54534542 -#define CUSTOMPARAM_VERSION 1 +#define CUSTOMPARAM_MAGIC_CODE 0x54534542 +#define CUSTOMPARAM_VERSION 1 -#define CUSTOMPARAM_SECTION_SIZE 4096 // one flash page +#define CUSTOMPARAM_SECTION_SIZE 4096 // one flash page + +typedef struct { + uint32_t magic_code; // fixed value as CUSTOMPARAM_MAGIC_CODE + uint16_t version; + uint16_t length; // length in bytes of the following data in the section + uint16_t entryCount; + // following are parameter entries -typedef struct -{ - uint32_t magic_code; // fixed value as CUSTOMPARAM_MAGIC_CODE - uint16_t version; - uint16_t length; // length in bytes of the following data in the section - uint16_t entryCount; - // following are parameter entries - } __attribute__((packed)) CUSTOM_PARAM_SECTION_HEADER_T; -typedef struct -{ - uint16_t paramIndex; - uint16_t paramLen; - // following are the parameter content with length paramLen +typedef struct { + uint16_t paramIndex; + uint16_t paramLen; + // following are the parameter content with length paramLen } __attribute__((packed)) CUSTOM_PARAM_ENTRY_HEADER_T; -#define CUSTOM_PARAM_Mode_ID_INDEX 0 -#define CUSTOM_PARAM_Model_ID_LEN 3 +#define CUSTOM_PARAM_Mode_ID_INDEX 0 +#define CUSTOM_PARAM_Model_ID_LEN 3 -#define CUSTOM_PARAM_SERIAL_NUM_INDEX 0 -#define CUSTOM_PARAM_SERIAL_NUM_LEN 16 -typedef struct -{ - uint8_t sn[CUSTOM_PARAM_SERIAL_NUM_LEN]; +#define CUSTOM_PARAM_SERIAL_NUM_INDEX 0 +#define CUSTOM_PARAM_SERIAL_NUM_LEN 16 +typedef struct { + uint8_t sn[CUSTOM_PARAM_SERIAL_NUM_LEN]; } CUSTOM_PARAM_SERIAL_NUM_T; // TODO: // Add your own custom parameters here - void nv_custom_parameter_section_init(void); -bool nv_custom_parameter_section_get_entry( - uint16_t paramIndex, uint8_t* pParamVal, uint32_t* pParamLen); +bool nv_custom_parameter_section_get_entry(uint16_t paramIndex, + uint8_t *pParamVal, + uint32_t *pParamLen); uint32_t Get_ModelId(void); #ifdef __cplusplus } #endif #endif - diff --git a/services/nv_section/factory_section/factory_section.c b/services/nv_section/factory_section/factory_section.c index 5c3203c..4cc69f3 100644 --- a/services/nv_section/factory_section/factory_section.c +++ b/services/nv_section/factory_section/factory_section.c @@ -13,17 +13,17 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "cmsis.h" -#include "plat_types.h" -#include "tgt_hardware.h" -#include "string.h" -#include "crc32.h" #include "factory_section.h" -#include "pmu.h" -#include "hal_trace.h" +#include "cmsis.h" +#include "crc32.h" #include "hal_norflash.h" -#include "norflash_api.h" +#include "hal_trace.h" #include "heap_api.h" +#include "norflash_api.h" +#include "plat_types.h" +#include "pmu.h" +#include "string.h" +#include "tgt_hardware.h" extern uint32_t __factory_start[]; extern uint32_t __factory_end[]; @@ -34,240 +34,198 @@ static uint8_t nv_record_dev_rev = nvrec_current_version; #ifndef BTIF_BD_ADDR_SIZE #define BTIF_BD_ADDR_SIZE 6 #endif -static void factory_callback(void* param) -{ - NORFLASH_API_OPERA_RESULT *opera_result; +static void factory_callback(void *param) { + NORFLASH_API_OPERA_RESULT *opera_result; - opera_result = (NORFLASH_API_OPERA_RESULT*)param; + opera_result = (NORFLASH_API_OPERA_RESULT *)param; - TRACE(5,"%s:type = %d, addr = 0x%x,len = 0x%x,result = %d.", - __func__, - opera_result->type, - opera_result->addr, - opera_result->len, - opera_result->result); + TRACE(5, "%s:type = %d, addr = 0x%x,len = 0x%x,result = %d.", __func__, + opera_result->type, opera_result->addr, opera_result->len, + opera_result->result); } -void factory_section_init(void) -{ - enum NORFLASH_API_RET_T result; - uint32_t sector_size = 0; - uint32_t block_size = 0; - uint32_t page_size = 0; +void factory_section_init(void) { + enum NORFLASH_API_RET_T result; + uint32_t sector_size = 0; + uint32_t block_size = 0; + uint32_t page_size = 0; - hal_norflash_get_size(HAL_NORFLASH_ID_0, - NULL, - &block_size, - §or_size, - &page_size); - result = norflash_api_register(NORFLASH_API_MODULE_ID_FACTORY, - HAL_NORFLASH_ID_0, - ((uint32_t)__factory_start)&0x00FFFFFF, - (uint32_t)__factory_end - (uint32_t)__factory_start, - block_size, - sector_size, - page_size, - FACTORY_SECTOR_SIZE, - factory_callback - ); - ASSERT(result == NORFLASH_API_OK,"nv_record_init: module register failed! result = %d.",result); + hal_norflash_get_size(HAL_NORFLASH_ID_0, NULL, &block_size, §or_size, + &page_size); + result = norflash_api_register( + NORFLASH_API_MODULE_ID_FACTORY, HAL_NORFLASH_ID_0, + ((uint32_t)__factory_start) & 0x00FFFFFF, + (uint32_t)__factory_end - (uint32_t)__factory_start, block_size, + sector_size, page_size, FACTORY_SECTOR_SIZE, factory_callback); + ASSERT(result == NORFLASH_API_OK, + "nv_record_init: module register failed! result = %d.", result); } -int factory_section_open(void) -{ - factory_section_p = (factory_section_t *)__factory_start; +int factory_section_open(void) { + factory_section_p = (factory_section_t *)__factory_start; - if (factory_section_p->head.magic != nvrec_dev_magic){ - factory_section_p = NULL; - return -1; - } - if ((factory_section_p->head.version < nvrec_mini_version) || - (factory_section_p->head.version > nvrec_current_version)) - { - factory_section_p = NULL; - return -1; + if (factory_section_p->head.magic != nvrec_dev_magic) { + factory_section_p = NULL; + return -1; + } + if ((factory_section_p->head.version < nvrec_mini_version) || + (factory_section_p->head.version > nvrec_current_version)) { + factory_section_p = NULL; + return -1; + } + + nv_record_dev_rev = factory_section_p->head.version; + + if (1 == nv_record_dev_rev) { + if (factory_section_p->head.crc != + crc32(0, (unsigned char *)(&(factory_section_p->head.reserved0)), + sizeof(factory_section_t) - 2 - 2 - 4 - + (5 + 63 + 2 + 2 + 2 + 1 + 8) * sizeof(int))) { + factory_section_p = NULL; + return -1; } - nv_record_dev_rev = factory_section_p->head.version; - - if (1 == nv_record_dev_rev) - { - if (factory_section_p->head.crc != - crc32(0,(unsigned char *)(&(factory_section_p->head.reserved0)), - sizeof(factory_section_t)-2-2-4-(5+63+2+2+2+1+8)*sizeof(int))){ - factory_section_p = NULL; - return -1; - } - - memcpy(bt_addr, factory_section_p->data.bt_address, BTIF_BD_ADDR_SIZE); - memcpy(ble_addr, factory_section_p->data.ble_address, BTIF_BD_ADDR_SIZE); - TRACE(2,"%s sucess btname:%s", __func__, factory_section_p->data.device_name); + memcpy(bt_addr, factory_section_p->data.bt_address, BTIF_BD_ADDR_SIZE); + memcpy(ble_addr, factory_section_p->data.ble_address, BTIF_BD_ADDR_SIZE); + TRACE(2, "%s sucess btname:%s", __func__, + factory_section_p->data.device_name); + } else { + // check the data length + if (((uint32_t)(&((factory_section_t *)0)->data.rev2_reserved0) + + factory_section_p->data.rev2_data_len) > 4096) { + TRACE(1, "nv rec dev data len %d has exceeds the facory sector size!.", + factory_section_p->data.rev2_data_len); + return -1; } - else - { - // check the data length - if (((uint32_t)(&((factory_section_t *)0)->data.rev2_reserved0)+ - factory_section_p->data.rev2_data_len) > 4096) - { - TRACE(1,"nv rec dev data len %d has exceeds the facory sector size!.", - factory_section_p->data.rev2_data_len); - return -1; - } - if (factory_section_p->data.rev2_crc != - crc32(0,(unsigned char *)(&(factory_section_p->data.rev2_reserved0)), - factory_section_p->data.rev2_data_len)){ - factory_section_p = NULL; - return -1; - } + if (factory_section_p->data.rev2_crc != + crc32(0, (unsigned char *)(&(factory_section_p->data.rev2_reserved0)), + factory_section_p->data.rev2_data_len)) { + factory_section_p = NULL; + return -1; + } + memcpy(bt_addr, factory_section_p->data.rev2_bt_addr, BTIF_BD_ADDR_SIZE); + memcpy(ble_addr, factory_section_p->data.rev2_ble_addr, BTIF_BD_ADDR_SIZE); + TRACE(2, "%s sucess btname:%s", __func__, + (char *)factory_section_p->data.rev2_bt_name); + } - memcpy(bt_addr, factory_section_p->data.rev2_bt_addr, BTIF_BD_ADDR_SIZE); - memcpy(ble_addr, factory_section_p->data.rev2_ble_addr, BTIF_BD_ADDR_SIZE); - TRACE(2,"%s sucess btname:%s", __func__, (char *)factory_section_p->data.rev2_bt_name); - } + DUMP8("%02x ", bt_addr, 6); + DUMP8("%02x ", ble_addr, 6); + return 0; +} - DUMP8("%02x ", bt_addr, 6); - DUMP8("%02x ", ble_addr, 6); +uint8_t *factory_section_get_bt_address(void) { + if (factory_section_p) { + if (1 == nv_record_dev_rev) { + return (uint8_t *)&(factory_section_p->data.bt_address); + } else { + return (uint8_t *)&(factory_section_p->data.rev2_bt_addr); + } + } else { + return NULL; + } +} + +uint8_t *factory_section_get_bt_name(void) { + if (factory_section_p) { + if (1 == nv_record_dev_rev) { + return (uint8_t *)&(factory_section_p->data.device_name); + } else { + return (uint8_t *)&(factory_section_p->data.rev2_bt_name); + } + } else { + return (uint8_t *)BT_LOCAL_NAME; + } +} + +uint8_t *factory_section_get_ble_name(void) { + if (factory_section_p) { + if (1 == nv_record_dev_rev) { + return (uint8_t *)BLE_DEFAULT_NAME; + } else { + return (uint8_t *)&(factory_section_p->data.rev2_ble_name); + } + } else { + return (uint8_t *)BLE_DEFAULT_NAME; + } +} + +uint32_t factory_section_get_version(void) { + if (factory_section_p) { + return nv_record_dev_rev; + } + + return 0; +} + +int factory_section_xtal_fcap_get(unsigned int *xtal_fcap) { + if (factory_section_p) { + if (1 == nv_record_dev_rev) { + *xtal_fcap = factory_section_p->data.xtal_fcap; + } else { + *xtal_fcap = factory_section_p->data.rev2_xtal_fcap; + } return 0; + } else { + return -1; + } } -uint8_t* factory_section_get_bt_address(void) -{ - if (factory_section_p) - { - if (1 == nv_record_dev_rev) - { - return (uint8_t *)&(factory_section_p->data.bt_address); - } - else - { - return (uint8_t *)&(factory_section_p->data.rev2_bt_addr); - } - } - else - { - return NULL; - } -} +int factory_section_xtal_fcap_set(unsigned int xtal_fcap) { + uint8_t *mempool = NULL; + uint32_t lock; + enum NORFLASH_API_RET_T ret; -uint8_t* factory_section_get_bt_name(void) -{ - if (factory_section_p) - { - if (1 == nv_record_dev_rev) - { - return (uint8_t *)&(factory_section_p->data.device_name); - } - else - { - return (uint8_t *)&(factory_section_p->data.rev2_bt_name); - } - } - else - { - return (uint8_t *)BT_LOCAL_NAME; - } -} - -uint8_t* factory_section_get_ble_name(void) -{ - if (factory_section_p) - { - if (1 == nv_record_dev_rev) - { - return (uint8_t *)BLE_DEFAULT_NAME; - } - else - { - return (uint8_t *)&(factory_section_p->data.rev2_ble_name); - } - } - else - { - return (uint8_t *)BLE_DEFAULT_NAME; - } -} - -uint32_t factory_section_get_version(void) -{ - if (factory_section_p) - { - return nv_record_dev_rev; - } - - return 0; -} - -int factory_section_xtal_fcap_get(unsigned int *xtal_fcap) -{ - if (factory_section_p){ - if (1 == nv_record_dev_rev) - { - *xtal_fcap = factory_section_p->data.xtal_fcap; - } - else - { - *xtal_fcap = factory_section_p->data.rev2_xtal_fcap; - } - return 0; - }else{ - return -1; + if (factory_section_p) { + TRACE(1, "factory_section_xtal_fcap_set:%d", xtal_fcap); + syspool_init(); + syspool_get_buff((uint8_t **)&mempool, 0x1000); + memcpy(mempool, factory_section_p, 0x1000); + if (1 == nv_record_dev_rev) { + ((factory_section_t *)mempool)->data.xtal_fcap = xtal_fcap; + ((factory_section_t *)mempool)->head.crc = crc32( + 0, + (unsigned char *)(&(((factory_section_t *)mempool)->head.reserved0)), + sizeof(factory_section_t) - 2 - 2 - 4); + } else { + ((factory_section_t *)mempool)->data.rev2_xtal_fcap = xtal_fcap; + ((factory_section_t *)mempool)->data.rev2_crc = + crc32(0, (unsigned char *)(&(factory_section_p->data.rev2_reserved0)), + factory_section_p->data.rev2_data_len); } + lock = int_lock_global(); + + ret = norflash_api_erase(NORFLASH_API_MODULE_ID_FACTORY, + (uint32_t)(__factory_start)&0x00FFFFFF, 0x1000, + false); + ASSERT(ret == NORFLASH_API_OK, + "factory_section_xtal_fcap_set: erase failed! ret = %d.", ret); + ret = norflash_api_write(NORFLASH_API_MODULE_ID_FACTORY, + (uint32_t)(__factory_start)&0x00FFFFFF, + (uint8_t *)mempool, 0x1000, false); + ASSERT(ret == NORFLASH_API_OK, + "factory_section_xtal_fcap_set: write failed! ret = %d.", ret); + + int_unlock_global(lock); + + return 0; + } else { + return -1; + } } -int factory_section_xtal_fcap_set(unsigned int xtal_fcap) -{ - uint8_t *mempool = NULL; - uint32_t lock; - enum NORFLASH_API_RET_T ret; - - if (factory_section_p){ - TRACE(1,"factory_section_xtal_fcap_set:%d", xtal_fcap); - syspool_init(); - syspool_get_buff((uint8_t **)&mempool, 0x1000); - memcpy(mempool, factory_section_p, 0x1000); - if (1 == nv_record_dev_rev) - { - ((factory_section_t *)mempool)->data.xtal_fcap = xtal_fcap; - ((factory_section_t *)mempool)->head.crc = crc32(0,(unsigned char *)(&(((factory_section_t *)mempool)->head.reserved0)),sizeof(factory_section_t)-2-2-4); - } - else - { - ((factory_section_t *)mempool)->data.rev2_xtal_fcap = xtal_fcap; - ((factory_section_t *)mempool)->data.rev2_crc = - crc32(0,(unsigned char *)(&(factory_section_p->data.rev2_reserved0)), - factory_section_p->data.rev2_data_len); - } - lock = int_lock_global(); - - ret = norflash_api_erase(NORFLASH_API_MODULE_ID_FACTORY,(uint32_t)(__factory_start)&0x00FFFFFF,0x1000,false); - ASSERT(ret == NORFLASH_API_OK,"factory_section_xtal_fcap_set: erase failed! ret = %d.",ret); - ret = norflash_api_write(NORFLASH_API_MODULE_ID_FACTORY,(uint32_t)(__factory_start)&0x00FFFFFF,(uint8_t *)mempool,0x1000,false); - ASSERT(ret == NORFLASH_API_OK,"factory_section_xtal_fcap_set: write failed! ret = %d.",ret); - - int_unlock_global(lock); - - return 0; - }else{ - return -1; - } -} - -void factory_section_original_btaddr_get(uint8_t *btAddr) -{ - if(factory_section_p){ - TRACE(0,"get factory_section_p"); - if (1 == nv_record_dev_rev) - { - memcpy(btAddr, factory_section_p->data.bt_address, BTIF_BD_ADDR_SIZE); - } - else - { - memcpy(btAddr, factory_section_p->data.rev2_bt_addr, BTIF_BD_ADDR_SIZE); - } - }else{ - TRACE(0,"get bt_addr"); - memcpy(btAddr, bt_addr, BTIF_BD_ADDR_SIZE); +void factory_section_original_btaddr_get(uint8_t *btAddr) { + if (factory_section_p) { + TRACE(0, "get factory_section_p"); + if (1 == nv_record_dev_rev) { + memcpy(btAddr, factory_section_p->data.bt_address, BTIF_BD_ADDR_SIZE); + } else { + memcpy(btAddr, factory_section_p->data.rev2_bt_addr, BTIF_BD_ADDR_SIZE); } + } else { + TRACE(0, "get bt_addr"); + memcpy(btAddr, bt_addr, BTIF_BD_ADDR_SIZE); + } } diff --git a/services/nv_section/factory_section/factory_section.h b/services/nv_section/factory_section/factory_section.h index 6dea1d3..f7f8422 100644 --- a/services/nv_section/factory_section/factory_section.h +++ b/services/nv_section/factory_section/factory_section.h @@ -15,44 +15,46 @@ ****************************************************************************/ #ifndef __FACTORY_SECTIONS_H__ #define __FACTORY_SECTIONS_H__ +#include +#include #define ALIGN4 __attribute__((aligned(4))) -#define nvrec_mini_version 1 -#define nvrec_dev_magic 0xba80 -#define nvrec_current_version 2 -#define FACTORY_SECTOR_SIZE 4096 -typedef struct{ - unsigned short magic; - unsigned short version; - unsigned int crc ; - unsigned int reserved0; - unsigned int reserved1; -}section_head_t; +#define nvrec_mini_version 1 +#define nvrec_dev_magic 0xba80 +#define nvrec_current_version 2 +#define FACTORY_SECTOR_SIZE 4096 +typedef struct { + unsigned short magic; + unsigned short version; + unsigned int crc; + unsigned int reserved0; + unsigned int reserved1; +} section_head_t; -typedef struct{ - unsigned char device_name[248+1] ALIGN4; - unsigned char bt_address[8] ALIGN4; - unsigned char ble_address[8] ALIGN4; - unsigned char tester_address[8] ALIGN4; - unsigned int xtal_fcap ALIGN4; - unsigned int rev1_data_len; +typedef struct { + unsigned char device_name[248 + 1] ALIGN4; + unsigned char bt_address[8] ALIGN4; + unsigned char ble_address[8] ALIGN4; + unsigned char tester_address[8] ALIGN4; + unsigned int xtal_fcap ALIGN4; + unsigned int rev1_data_len; - unsigned int rev2_data_len; - unsigned int rev2_crc; - unsigned int rev2_reserved0; - unsigned int rev2_reserved1; - unsigned int rev2_bt_name[63]; - unsigned int rev2_bt_addr[2]; - unsigned int rev2_ble_addr[2]; - unsigned int rev2_dongle_addr[2]; - unsigned int rev2_xtal_fcap; - unsigned int rev2_ble_name[8]; -}factory_section_data_t; + unsigned int rev2_data_len; + unsigned int rev2_crc; + unsigned int rev2_reserved0; + unsigned int rev2_reserved1; + unsigned int rev2_bt_name[63]; + unsigned int rev2_bt_addr[2]; + unsigned int rev2_ble_addr[2]; + unsigned int rev2_dongle_addr[2]; + unsigned int rev2_xtal_fcap; + unsigned int rev2_ble_name[8]; +} factory_section_data_t; -typedef struct{ - section_head_t head; - factory_section_data_t data; -}factory_section_t; +typedef struct { + section_head_t head; + factory_section_data_t data; +} factory_section_t; #ifdef __cplusplus extern "C" { @@ -63,9 +65,9 @@ int factory_section_open(void); void factory_section_original_btaddr_get(uint8_t *btAddr); int factory_section_xtal_fcap_get(unsigned int *xtal_fcap); int factory_section_xtal_fcap_set(unsigned int xtal_fcap); -uint8_t* factory_section_get_bt_address(void); -uint8_t* factory_section_get_bt_name(void); -uint8_t* factory_section_get_ble_name(void); +uint8_t *factory_section_get_bt_address(void); +uint8_t *factory_section_get_bt_name(void); +uint8_t *factory_section_get_ble_name(void); uint32_t factory_section_get_version(void); #ifdef __cplusplus diff --git a/services/nv_section/fpga_section/nvrecord_ble.c b/services/nv_section/fpga_section/nvrecord_ble.c index 16073e9..820d3cf 100644 --- a/services/nv_section/fpga_section/nvrecord_ble.c +++ b/services/nv_section/fpga_section/nvrecord_ble.c @@ -14,16 +14,16 @@ * ****************************************************************************/ #if defined(NEW_NV_RECORD_ENABLED) -#include -#include -#include -#include "nvrecord_extension.h" #include "nvrecord_ble.h" -#include "hal_trace.h" -#include "co_math.h" -#include "tgt_hardware.h" -#include "hal_timer.h" #include "besbt.h" +#include "co_math.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "nvrecord_extension.h" +#include "tgt_hardware.h" +#include +#include +#include #define ble_nv_debug #ifdef ble_nv_debug @@ -33,408 +33,386 @@ #endif static NV_RECORD_PAIRED_BLE_DEV_INFO_T *nvrecord_ble_p = NULL; -static uint8_t INVALID_ADDR[BTIF_BD_ADDR_SIZE] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +static uint8_t INVALID_ADDR[BTIF_BD_ADDR_SIZE] = {0x00, 0x00, 0x00, + 0x00, 0x00, 0x00}; -void nvrecord_rebuild_paired_ble_dev_info(NV_RECORD_PAIRED_BLE_DEV_INFO_T *pPairedBtInfo) -{ - memset(( uint8_t * )pPairedBtInfo, 0, sizeof(NV_RECORD_PAIRED_BLE_DEV_INFO_T)); - pPairedBtInfo->saved_list_num = 0; //init saved num +void nvrecord_rebuild_paired_ble_dev_info( + NV_RECORD_PAIRED_BLE_DEV_INFO_T *pPairedBtInfo) { + memset((uint8_t *)pPairedBtInfo, 0, sizeof(NV_RECORD_PAIRED_BLE_DEV_INFO_T)); + pPairedBtInfo->saved_list_num = 0; // init saved num - uint8_t index; - //avoid ble irk collision low probability - uint32_t generatedSeed = hal_sys_timer_get(); - for (uint8_t index = 0; index < sizeof(bt_addr); index++) - { - generatedSeed ^= (((uint32_t)(bt_addr[index])) << (hal_sys_timer_get() & 0xF)); - } - srand(generatedSeed); + uint8_t index; + // avoid ble irk collision low probability + uint32_t generatedSeed = hal_sys_timer_get(); + for (uint8_t index = 0; index < sizeof(bt_addr); index++) { + generatedSeed ^= + (((uint32_t)(bt_addr[index])) << (hal_sys_timer_get() & 0xF)); + } + srand(generatedSeed); - // generate a new IRK - for (index = 0; index < BLE_IRK_SIZE; index++) - { - pPairedBtInfo->self_info.ble_irk[index] = ( uint8_t )co_rand_word(); - } + // generate a new IRK + for (index = 0; index < BLE_IRK_SIZE; index++) { + pPairedBtInfo->self_info.ble_irk[index] = (uint8_t)co_rand_word(); + } } -static bool blerec_specific_value_prepare(const BleDeviceinfo *param_rec) -{ - // Preparations before adding new ble record: - // 1. If not existing. Check the record count. If it's BLE_RECORD_NUM, - // move 0-(BLE_RECORD_NUM-2) right side by one slot, to discard the last one and - // leave slot 0, decrease the record number. - // If it's smaller than BLE_RECORD_NUM, move 0-(count-1) right side by one slot, leave slot 0, - // don't change the record number. - // 2. If existing already and the location is entryToFree , move 0-(entryToFree-1) - // right side by one slot, leave slot 0. Decrease the record number for adding the new one. +static bool blerec_specific_value_prepare(const BleDeviceinfo *param_rec) { + // Preparations before adding new ble record: + // 1. If not existing. Check the record count. If it's BLE_RECORD_NUM, + // move 0-(BLE_RECORD_NUM-2) right side by one slot, to discard the last + // one and leave slot 0, decrease the record number. If it's smaller than + // BLE_RECORD_NUM, move 0-(count-1) right side by one slot, leave slot 0, + // don't change the record number. + // 2. If existing already and the location is entryToFree , move + // 0-(entryToFree-1) + // right side by one slot, leave slot 0. Decrease the record number for + // adding the new one. - bool isEntryExisting = false; - uint8_t entryToFree = 0; - NV_RECORD_PAIRED_BLE_DEV_INFO_T *dest_ptr; + bool isEntryExisting = false; + uint8_t entryToFree = 0; + NV_RECORD_PAIRED_BLE_DEV_INFO_T *dest_ptr; - dest_ptr = nvrecord_ble_p; - TRACE(3,"%s start search addr %p list_num=%d", __func__, dest_ptr, dest_ptr->saved_list_num); + dest_ptr = nvrecord_ble_p; + TRACE(3, "%s start search addr %p list_num=%d", __func__, dest_ptr, + dest_ptr->saved_list_num); - if (dest_ptr->saved_list_num > 0) - { - for (uint8_t i = 0; i < dest_ptr->saved_list_num; i++) - { - if (0 == memcmp(dest_ptr->ble_nv[i].peer_bleAddr, param_rec->peer_bleAddr, BLE_ADDR_SIZE)) - { - ble_trace(2,"%s Find the existing entry %d", __func__, i); - DUMP8("%02x ", ( uint8_t * )param_rec, sizeof(BleDeviceinfo)); - DUMP8("%02x ", ( uint8_t * )&dest_ptr->ble_nv[i], sizeof(BleDeviceinfo)); - if (!memcmp(( uint8_t * )param_rec, ( uint8_t * )&dest_ptr->ble_nv[i], sizeof(BleDeviceinfo))) - { - ble_trace(0,"The new coming BLE device info is the same as the recorded."); - return false; - } - memset(&(dest_ptr->ble_nv[i]), 0, sizeof(BleDeviceinfo)); - entryToFree = i; - dest_ptr->saved_list_num--; - isEntryExisting = true; - break; - } + if (dest_ptr->saved_list_num > 0) { + for (uint8_t i = 0; i < dest_ptr->saved_list_num; i++) { + if (0 == memcmp(dest_ptr->ble_nv[i].peer_bleAddr, param_rec->peer_bleAddr, + BLE_ADDR_SIZE)) { + ble_trace(2, "%s Find the existing entry %d", __func__, i); + DUMP8("%02x ", (uint8_t *)param_rec, sizeof(BleDeviceinfo)); + DUMP8("%02x ", (uint8_t *)&dest_ptr->ble_nv[i], sizeof(BleDeviceinfo)); + if (!memcmp((uint8_t *)param_rec, (uint8_t *)&dest_ptr->ble_nv[i], + sizeof(BleDeviceinfo))) { + ble_trace( + 0, "The new coming BLE device info is the same as the recorded."); + return false; } + memset(&(dest_ptr->ble_nv[i]), 0, sizeof(BleDeviceinfo)); + entryToFree = i; + dest_ptr->saved_list_num--; + isEntryExisting = true; + break; + } } - else - { - return true; - } - - if (!isEntryExisting) - { - if (BLE_RECORD_NUM == dest_ptr->saved_list_num) - { - TRACE(0,"<=====>blerec list is full,delete the oldest and add param_rec to list"); - for (uint8_t k = 0; k < BLE_RECORD_NUM - 1; k++) - { - memcpy(&(dest_ptr->ble_nv[BLE_RECORD_NUM - 1 - k]), - &(dest_ptr->ble_nv[BLE_RECORD_NUM - 2 - k]), - sizeof(BleDeviceinfo)); - } - dest_ptr->saved_list_num--; - } - else - { - for (uint8_t k = 0; k < dest_ptr->saved_list_num; k++) - { - memcpy(&(dest_ptr->ble_nv[dest_ptr->saved_list_num - k]), - &(dest_ptr->ble_nv[dest_ptr->saved_list_num - 1 - k]), - sizeof(BleDeviceinfo)); - } - } - } - else - { - for (uint8_t list_updata = 0; list_updata < entryToFree; list_updata++) - { - memcpy(&(dest_ptr->ble_nv[entryToFree - list_updata]), - &(dest_ptr->ble_nv[entryToFree - list_updata - 1]), - sizeof(BleDeviceinfo)); - } - } - + } else { return true; + } + + if (!isEntryExisting) { + if (BLE_RECORD_NUM == dest_ptr->saved_list_num) { + TRACE(0, "<=====>blerec list is full,delete the oldest and add param_rec " + "to list"); + for (uint8_t k = 0; k < BLE_RECORD_NUM - 1; k++) { + memcpy(&(dest_ptr->ble_nv[BLE_RECORD_NUM - 1 - k]), + &(dest_ptr->ble_nv[BLE_RECORD_NUM - 2 - k]), + sizeof(BleDeviceinfo)); + } + dest_ptr->saved_list_num--; + } else { + for (uint8_t k = 0; k < dest_ptr->saved_list_num; k++) { + memcpy(&(dest_ptr->ble_nv[dest_ptr->saved_list_num - k]), + &(dest_ptr->ble_nv[dest_ptr->saved_list_num - 1 - k]), + sizeof(BleDeviceinfo)); + } + } + } else { + for (uint8_t list_updata = 0; list_updata < entryToFree; list_updata++) { + memcpy(&(dest_ptr->ble_nv[entryToFree - list_updata]), + &(dest_ptr->ble_nv[entryToFree - list_updata - 1]), + sizeof(BleDeviceinfo)); + } + } + + return true; } -void nv_record_blerec_init(void) -{ +void nv_record_blerec_init(void) { + uint32_t lock = nv_record_pre_write_operation(); + if (NULL == nvrecord_ble_p) { + nvrecord_ble_p = &(nvrecord_extension_p->ble_pair_info); + if (!memcmp(nvrecord_ble_p->self_info.ble_addr, INVALID_ADDR, + BTIF_BD_ADDR_SIZE)) { + memcpy(nvrecord_ble_p->self_info.ble_addr, bt_get_ble_local_address(), + BTIF_BD_ADDR_SIZE); + } + } + nv_record_post_write_operation(lock); +} + +NV_RECORD_PAIRED_BLE_DEV_INFO_T *nv_record_blerec_get_ptr(void) { + return nvrecord_ble_p; +} + +void nv_record_blerec_get_local_irk(uint8_t *pIrk) { + memcpy(pIrk, nvrecord_ble_p->self_info.ble_irk, BLE_IRK_SIZE); +} + +bool nv_record_blerec_get_bd_addr_from_irk(uint8_t *pBdAddr, uint8_t *pIrk) { + if (nvrecord_ble_p->saved_list_num > 0) { + for (uint8_t index = 0; index < nvrecord_ble_p->saved_list_num; index++) { + if (!memcmp(pIrk, nvrecord_ble_p->ble_nv[index].IRK, BLE_IRK_SIZE)) { + memcpy(pBdAddr, nvrecord_ble_p->ble_nv[index].peer_bleAddr, + BLE_ADDR_SIZE); + return true; + } + } + return false; + } else { + return false; + } +} + +int nv_record_blerec_add(const BleDeviceinfo *param_rec) { + int nRet = 0; + + uint8_t isNeedToUpdateNv = true; + isNeedToUpdateNv = blerec_specific_value_prepare(param_rec); + + if (isNeedToUpdateNv) { uint32_t lock = nv_record_pre_write_operation(); - if (NULL == nvrecord_ble_p) - { - nvrecord_ble_p = &(nvrecord_extension_p->ble_pair_info); - if (!memcmp(nvrecord_ble_p->self_info.ble_addr, INVALID_ADDR, BTIF_BD_ADDR_SIZE)) - { - memcpy(nvrecord_ble_p->self_info.ble_addr, bt_get_ble_local_address(), BTIF_BD_ADDR_SIZE); - } - } + + // add device info into nv struct + memcpy(nvrecord_ble_p->ble_nv[0].peer_bleAddr, param_rec->peer_bleAddr, + BLE_ADDR_SIZE); // addr + nvrecord_ble_p->ble_nv[0].EDIV = param_rec->EDIV; // EDIV + memcpy(nvrecord_ble_p->ble_nv[0].RANDOM, param_rec->RANDOM, + BLE_ENC_RANDOM_SIZE); // RANDOM + memcpy(nvrecord_ble_p->ble_nv[0].LTK, param_rec->LTK, BLE_LTK_SIZE); // LTK + memcpy(nvrecord_ble_p->ble_nv[0].IRK, param_rec->IRK, BLE_IRK_SIZE); // IRK + nvrecord_ble_p->ble_nv[0].bonded = param_rec->bonded; // bond status + nvrecord_ble_p->saved_list_num++; // updata saved num nv_record_post_write_operation(lock); -} -NV_RECORD_PAIRED_BLE_DEV_INFO_T* nv_record_blerec_get_ptr(void) -{ - return nvrecord_ble_p; -} - -void nv_record_blerec_get_local_irk(uint8_t *pIrk) -{ - memcpy(pIrk, nvrecord_ble_p->self_info.ble_irk, BLE_IRK_SIZE); -} - -bool nv_record_blerec_get_bd_addr_from_irk(uint8_t *pBdAddr, uint8_t *pIrk) -{ - if (nvrecord_ble_p->saved_list_num > 0) - { - for (uint8_t index = 0; index < nvrecord_ble_p->saved_list_num; index++) - { - if (!memcmp(pIrk, nvrecord_ble_p->ble_nv[index].IRK, BLE_IRK_SIZE)) - { - memcpy(pBdAddr, nvrecord_ble_p->ble_nv[index].peer_bleAddr, BLE_ADDR_SIZE); - return true; - } - } - return false; - } - else - { - return false; - } -} - -int nv_record_blerec_add(const BleDeviceinfo *param_rec) -{ - int nRet = 0; - - uint8_t isNeedToUpdateNv = true; - isNeedToUpdateNv = blerec_specific_value_prepare(param_rec); - - if (isNeedToUpdateNv) - { - uint32_t lock = nv_record_pre_write_operation(); - - //add device info into nv struct - memcpy(nvrecord_ble_p->ble_nv[0].peer_bleAddr, param_rec->peer_bleAddr, BLE_ADDR_SIZE); //addr - nvrecord_ble_p->ble_nv[0].EDIV = param_rec->EDIV; //EDIV - memcpy(nvrecord_ble_p->ble_nv[0].RANDOM, param_rec->RANDOM, BLE_ENC_RANDOM_SIZE); //RANDOM - memcpy(nvrecord_ble_p->ble_nv[0].LTK, param_rec->LTK, BLE_LTK_SIZE); //LTK - memcpy(nvrecord_ble_p->ble_nv[0].IRK, param_rec->IRK, BLE_IRK_SIZE); //IRK - nvrecord_ble_p->ble_nv[0].bonded = param_rec->bonded; //bond status - nvrecord_ble_p->saved_list_num++; //updata saved num - nv_record_post_write_operation(lock); - - nv_record_update_runtime_userdata(); - nv_record_execute_async_flush(); - TRACE(2,"%s CURRENT BLE LIST NUM=%d", __func__, nvrecord_ble_p->saved_list_num); - } + nv_record_update_runtime_userdata(); + nv_record_execute_async_flush(); + TRACE(2, "%s CURRENT BLE LIST NUM=%d", __func__, + nvrecord_ble_p->saved_list_num); + } #ifdef ble_nv_debug - for (uint8_t k = 0; k < nvrecord_ble_p->saved_list_num; k++) - { - TRACE(0,"========================================="); - TRACE(1,"Num %d BLE record:", k); - TRACE(0,"BLE addr:"); - DUMP8("%02x ", ( uint8_t * )nvrecord_ble_p->ble_nv[k].peer_bleAddr, BLE_ADDR_SIZE); - TRACE(1,"NV EDIV %d and random is:", nvrecord_ble_p->ble_nv[k].EDIV); - DUMP8("%02x ", ( uint8_t * )nvrecord_ble_p->ble_nv[k].RANDOM, BLE_ENC_RANDOM_SIZE); - TRACE(0,"NV LTK:"); - DUMP8("%02x ", ( uint8_t * )nvrecord_ble_p->ble_nv[k].LTK, BLE_LTK_SIZE); - TRACE(0,"NV irk:"); - DUMP8("%02x ", ( uint8_t * )nvrecord_ble_p->ble_nv[k].IRK, BLE_IRK_SIZE); - } + for (uint8_t k = 0; k < nvrecord_ble_p->saved_list_num; k++) { + TRACE(0, "========================================="); + TRACE(1, "Num %d BLE record:", k); + TRACE(0, "BLE addr:"); + DUMP8("%02x ", (uint8_t *)nvrecord_ble_p->ble_nv[k].peer_bleAddr, + BLE_ADDR_SIZE); + TRACE(1, "NV EDIV %d and random is:", nvrecord_ble_p->ble_nv[k].EDIV); + DUMP8("%02x ", (uint8_t *)nvrecord_ble_p->ble_nv[k].RANDOM, + BLE_ENC_RANDOM_SIZE); + TRACE(0, "NV LTK:"); + DUMP8("%02x ", (uint8_t *)nvrecord_ble_p->ble_nv[k].LTK, BLE_LTK_SIZE); + TRACE(0, "NV irk:"); + DUMP8("%02x ", (uint8_t *)nvrecord_ble_p->ble_nv[k].IRK, BLE_IRK_SIZE); + } #endif - return nRet; + return nRet; } -uint8_t nv_record_ble_fill_irk(uint8_t *irkToFill) -{ - NV_RECORD_PAIRED_BLE_DEV_INFO_T *find_ptr = nvrecord_ble_p; +uint8_t nv_record_ble_fill_irk(uint8_t *irkToFill) { + NV_RECORD_PAIRED_BLE_DEV_INFO_T *find_ptr = nvrecord_ble_p; - if ((NULL == find_ptr) || (0 == find_ptr->saved_list_num)) - { - return 0; - } + if ((NULL == find_ptr) || (0 == find_ptr->saved_list_num)) { + return 0; + } - if (find_ptr->saved_list_num > 0) - { - for (uint8_t index = 0; index < find_ptr->saved_list_num; index++) - { - memcpy(irkToFill + index * BLE_IRK_SIZE, find_ptr->ble_nv[index].IRK, BLE_IRK_SIZE); - } - return find_ptr->saved_list_num; - } - else - { - return 0; + if (find_ptr->saved_list_num > 0) { + for (uint8_t index = 0; index < find_ptr->saved_list_num; index++) { + memcpy(irkToFill + index * BLE_IRK_SIZE, find_ptr->ble_nv[index].IRK, + BLE_IRK_SIZE); } + return find_ptr->saved_list_num; + } else { + return 0; + } } -//when master send encription req,if bonded,use ltk to bonding again(skip the pair step) -bool nv_record_ble_record_find_ltk_through_static_bd_addr(uint8_t *pBdAddr, uint8_t *ltk) -{ - NV_RECORD_PAIRED_BLE_DEV_INFO_T *find_ptr = nvrecord_ble_p; +// when master send encription req,if bonded,use ltk to bonding again(skip the +// pair step) +bool nv_record_ble_record_find_ltk_through_static_bd_addr(uint8_t *pBdAddr, + uint8_t *ltk) { + NV_RECORD_PAIRED_BLE_DEV_INFO_T *find_ptr = nvrecord_ble_p; - if ((NULL == find_ptr) || (0 == find_ptr->saved_list_num)) - { - TRACE(3,"%s find data failed, ptr:%x, list_num:%d", __func__, (uint32_t)find_ptr, find_ptr->saved_list_num); - return false; - } - - for (uint8_t find_index = 0; find_index < find_ptr->saved_list_num; find_index++) - { - if (!memcmp(find_ptr->ble_nv[find_index].peer_bleAddr, pBdAddr, BLE_ADDR_SIZE)) - { - ble_trace(2,"%s FIND LTK IN NV SUCCESS %p", __func__, find_ptr->ble_nv[find_index].LTK); - memcpy(ltk, find_ptr->ble_nv[find_index].LTK, BLE_LTK_SIZE); - return true; - } - } + if ((NULL == find_ptr) || (0 == find_ptr->saved_list_num)) { + TRACE(3, "%s find data failed, ptr:%x, list_num:%d", __func__, + (uint32_t)find_ptr, find_ptr->saved_list_num); return false; + } + + for (uint8_t find_index = 0; find_index < find_ptr->saved_list_num; + find_index++) { + if (!memcmp(find_ptr->ble_nv[find_index].peer_bleAddr, pBdAddr, + BLE_ADDR_SIZE)) { + ble_trace(2, "%s FIND LTK IN NV SUCCESS %p", __func__, + find_ptr->ble_nv[find_index].LTK); + memcpy(ltk, find_ptr->ble_nv[find_index].LTK, BLE_LTK_SIZE); + return true; + } + } + return false; } -bool nv_record_ble_record_Once_a_device_has_been_bonded(void) -{ - NV_RECORD_PAIRED_BLE_DEV_INFO_T *find_ptr = nvrecord_ble_p; +bool nv_record_ble_record_Once_a_device_has_been_bonded(void) { + NV_RECORD_PAIRED_BLE_DEV_INFO_T *find_ptr = nvrecord_ble_p; - if ((NULL == find_ptr) || (0 == find_ptr->saved_list_num)) - { - return false; - } - - for (uint8_t find_index = 0; find_index < find_ptr->saved_list_num; find_index++) - { - if (find_ptr->ble_nv[find_index].bonded == true) - { - return true; - } - } + if ((NULL == find_ptr) || (0 == find_ptr->saved_list_num)) { return false; + } + + for (uint8_t find_index = 0; find_index < find_ptr->saved_list_num; + find_index++) { + if (find_ptr->ble_nv[find_index].bonded == true) { + return true; + } + } + return false; } -void nv_record_ble_delete_entry(uint8_t *pBdAddr) -{ - NV_RECORD_PAIRED_BLE_DEV_INFO_T *find_ptr = nvrecord_ble_p; +void nv_record_ble_delete_entry(uint8_t *pBdAddr) { + NV_RECORD_PAIRED_BLE_DEV_INFO_T *find_ptr = nvrecord_ble_p; - if ((NULL == find_ptr) || (0 == find_ptr->saved_list_num)) - { - return; + if ((NULL == find_ptr) || (0 == find_ptr->saved_list_num)) { + return; + } + + int8_t indexToDelete = -1; + + for (uint8_t find_index = 0; find_index < find_ptr->saved_list_num; + find_index++) { + if (!memcmp(find_ptr->ble_nv[find_index].peer_bleAddr, pBdAddr, + BLE_ADDR_SIZE)) { + indexToDelete = find_index; + break; + } + } + + if (indexToDelete >= 0) { + uint32_t lock = nv_record_pre_write_operation(); + + uint8_t index; + for (index = indexToDelete; index < find_ptr->saved_list_num - 1; index++) { + memcpy(&(find_ptr->ble_nv[index]), &(find_ptr->ble_nv[index + 1]), + sizeof(BleDeviceinfo)); } - int8_t indexToDelete = -1; - - for (uint8_t find_index = 0; find_index < find_ptr->saved_list_num; find_index++) - { - if (!memcmp(find_ptr->ble_nv[find_index].peer_bleAddr, pBdAddr, BLE_ADDR_SIZE)) - { - indexToDelete = find_index; - break; - } - } - - if (indexToDelete >= 0) - { - uint32_t lock = nv_record_pre_write_operation(); - - uint8_t index; - for (index = indexToDelete; index < find_ptr->saved_list_num - 1; index++) - { - memcpy(&(find_ptr->ble_nv[index]), - &(find_ptr->ble_nv[index + 1]), - sizeof(BleDeviceinfo)); - } - - memset(( uint8_t * )&(find_ptr->ble_nv[index]), 0, sizeof(BleDeviceinfo)); - find_ptr->saved_list_num--; - nv_record_update_runtime_userdata(); - nv_record_post_write_operation(lock); - } + memset((uint8_t *)&(find_ptr->ble_nv[index]), 0, sizeof(BleDeviceinfo)); + find_ptr->saved_list_num--; + nv_record_update_runtime_userdata(); + nv_record_post_write_operation(lock); + } } #ifdef TWS_SYSTEM_ENABLED -static bool tws_use_same_ble_addr(uint8_t *peer_ble_addr) -{ - TRACE(1,"[%s] peer addr:", __func__); - DUMP8("%x ", peer_ble_addr, BTIF_BD_ADDR_SIZE); +static bool tws_use_same_ble_addr(uint8_t *peer_ble_addr) { + TRACE(1, "[%s] peer addr:", __func__); + DUMP8("%x ", peer_ble_addr, BTIF_BD_ADDR_SIZE); - NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); + NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); - if (!memcmp(pNvExtRec->ble_pair_info.self_info.ble_addr, peer_ble_addr, BTIF_BD_ADDR_SIZE)) - { - return true; - } + if (!memcmp(pNvExtRec->ble_pair_info.self_info.ble_addr, peer_ble_addr, + BTIF_BD_ADDR_SIZE)) { + return true; + } - return false; + return false; } -void nv_record_extension_update_tws_ble_info(NV_RECORD_PAIRED_BLE_DEV_INFO_T *info) -{ - ASSERT(info, "null pointer received in [%s]", __func__); +void nv_record_extension_update_tws_ble_info( + NV_RECORD_PAIRED_BLE_DEV_INFO_T *info) { + ASSERT(info, "null pointer received in [%s]", __func__); - bool isNvExtentionPendingForUpdate = false; - NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); + bool isNvExtentionPendingForUpdate = false; + NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); - if (tws_use_same_ble_addr(info->self_info.ble_addr)) - { - if (memcmp(&pNvExtRec->ble_pair_info.self_info, &info->self_info, sizeof(BLE_BASIC_INFO_T))) - { - TRACE(0,"save the peer ble info to self_info"); - memcpy(&pNvExtRec->ble_pair_info.self_info, &info->self_info, sizeof(BLE_BASIC_INFO_T)); - nv_record_extension_update(); - isNvExtentionPendingForUpdate = true; - } + if (tws_use_same_ble_addr(info->self_info.ble_addr)) { + if (memcmp(&pNvExtRec->ble_pair_info.self_info, &info->self_info, + sizeof(BLE_BASIC_INFO_T))) { + TRACE(0, "save the peer ble info to self_info"); + memcpy(&pNvExtRec->ble_pair_info.self_info, &info->self_info, + sizeof(BLE_BASIC_INFO_T)); + nv_record_extension_update(); + isNvExtentionPendingForUpdate = true; } + } - if (memcmp(&pNvExtRec->tws_info.ble_info, &info->self_info, sizeof(BLE_BASIC_INFO_T))) - { - TRACE(0,"save the peer ble info to tws_info"); - memcpy(&pNvExtRec->tws_info.ble_info, &info->self_info, sizeof(BLE_BASIC_INFO_T)); - nv_record_extension_update(); - isNvExtentionPendingForUpdate = true; - } + if (memcmp(&pNvExtRec->tws_info.ble_info, &info->self_info, + sizeof(BLE_BASIC_INFO_T))) { + TRACE(0, "save the peer ble info to tws_info"); + memcpy(&pNvExtRec->tws_info.ble_info, &info->self_info, + sizeof(BLE_BASIC_INFO_T)); + nv_record_extension_update(); + isNvExtentionPendingForUpdate = true; + } - if (isNvExtentionPendingForUpdate) - { - nv_record_execute_async_flush(); - } + if (isNvExtentionPendingForUpdate) { + nv_record_execute_async_flush(); + } - TRACE(0,"peer addr:"); - DUMP8("0x%02x ", pNvExtRec->tws_info.ble_info.ble_addr,BTIF_BD_ADDR_SIZE); - TRACE(0,"peer irk"); - DUMP8("0x%02x ", pNvExtRec->tws_info.ble_info.ble_irk, BLE_IRK_SIZE); + TRACE(0, "peer addr:"); + DUMP8("0x%02x ", pNvExtRec->tws_info.ble_info.ble_addr, BTIF_BD_ADDR_SIZE); + TRACE(0, "peer irk"); + DUMP8("0x%02x ", pNvExtRec->tws_info.ble_info.ble_irk, BLE_IRK_SIZE); } -void nv_record_tws_exchange_ble_info(void) -{ - TRACE(1,"[%s]+++", __func__); +void nv_record_tws_exchange_ble_info(void) { + TRACE(1, "[%s]+++", __func__); + return; + NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); + uint8_t ble_address[6] = {0, 0, 0, 0, 0, 0}; + + if (tws_use_same_ble_addr(pNvExtRec->tws_info.ble_info.ble_addr)) { + TRACE(0, "tws use same ble addr"); return; - NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); - uint8_t ble_address[6] = {0, 0, 0, 0, 0, 0}; + } - if (tws_use_same_ble_addr(pNvExtRec->tws_info.ble_info.ble_addr)) - { - TRACE(0,"tws use same ble addr"); - return; - } - - if (!memcmp(pNvExtRec->tws_info.ble_info.ble_addr, ble_address, BTIF_BD_ADDR_SIZE)) - { - TRACE(0,"don't have tws ble addr"); - return; - } + if (!memcmp(pNvExtRec->tws_info.ble_info.ble_addr, ble_address, + BTIF_BD_ADDR_SIZE)) { + TRACE(0, "don't have tws ble addr"); + return; + } #ifdef BLE_USE_RPA - uint8_t temp_ble_irk[BLE_IRK_SIZE]; - memcpy(temp_ble_irk, pNvExtRec->ble_pair_info.self_info.ble_irk, BLE_IRK_SIZE); - memcpy(pNvExtRec->ble_pair_info.self_info.ble_irk, pNvExtRec->tws_info.ble_info.ble_irk, BLE_IRK_SIZE); - memcpy(pNvExtRec->tws_info.ble_info.ble_irk, temp_ble_irk, BLE_IRK_SIZE); - TRACE(0,"current local ble irk:"); - DUMP8("0x%02x ", pNvExtRec->ble_pair_info.self_info.ble_irk, BLE_IRK_SIZE); + uint8_t temp_ble_irk[BLE_IRK_SIZE]; + memcpy(temp_ble_irk, pNvExtRec->ble_pair_info.self_info.ble_irk, + BLE_IRK_SIZE); + memcpy(pNvExtRec->ble_pair_info.self_info.ble_irk, + pNvExtRec->tws_info.ble_info.ble_irk, BLE_IRK_SIZE); + memcpy(pNvExtRec->tws_info.ble_info.ble_irk, temp_ble_irk, BLE_IRK_SIZE); + TRACE(0, "current local ble irk:"); + DUMP8("0x%02x ", pNvExtRec->ble_pair_info.self_info.ble_irk, BLE_IRK_SIZE); #else - uint8_t temp_ble_addr[BTIF_BD_ADDR_SIZE]; - memcpy(temp_ble_addr, pNvExtRec->ble_pair_info.self_info.ble_addr, BTIF_BD_ADDR_SIZE); - memcpy(pNvExtRec->ble_pair_info.self_info.ble_addr, pNvExtRec->tws_info.ble_info.ble_addr, BTIF_BD_ADDR_SIZE); - memcpy(pNvExtRec->tws_info.ble_info.ble_addr, temp_ble_addr, BTIF_BD_ADDR_SIZE); - memcpy(bt_get_ble_local_address(), pNvExtRec->ble_pair_info.self_info.ble_addr, BTIF_BD_ADDR_SIZE); - TRACE(0,"current local ble addr:"); - DUMP8("0x%02x ", pNvExtRec->ble_pair_info.self_info.ble_addr, BTIF_BD_ADDR_SIZE); + uint8_t temp_ble_addr[BTIF_BD_ADDR_SIZE]; + memcpy(temp_ble_addr, pNvExtRec->ble_pair_info.self_info.ble_addr, + BTIF_BD_ADDR_SIZE); + memcpy(pNvExtRec->ble_pair_info.self_info.ble_addr, + pNvExtRec->tws_info.ble_info.ble_addr, BTIF_BD_ADDR_SIZE); + memcpy(pNvExtRec->tws_info.ble_info.ble_addr, temp_ble_addr, + BTIF_BD_ADDR_SIZE); + memcpy(bt_get_ble_local_address(), + pNvExtRec->ble_pair_info.self_info.ble_addr, BTIF_BD_ADDR_SIZE); + TRACE(0, "current local ble addr:"); + DUMP8("0x%02x ", pNvExtRec->ble_pair_info.self_info.ble_addr, + BTIF_BD_ADDR_SIZE); - bt_set_ble_local_address(pNvExtRec->ble_pair_info.self_info.ble_addr); + bt_set_ble_local_address(pNvExtRec->ble_pair_info.self_info.ble_addr); #endif - nv_record_extension_update(); - TRACE(1,"[%s]---", __func__); + nv_record_extension_update(); + TRACE(1, "[%s]---", __func__); } -uint8_t *nv_record_tws_get_self_ble_info(void) -{ - TRACE(1,"[%s]+++", __func__); - NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); +uint8_t *nv_record_tws_get_self_ble_info(void) { + TRACE(1, "[%s]+++", __func__); + NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); - TRACE(0,"current local ble addr:"); - DUMP8("0x%02x ", pNvExtRec->ble_pair_info.self_info.ble_addr, BTIF_BD_ADDR_SIZE); + TRACE(0, "current local ble addr:"); + DUMP8("0x%02x ", pNvExtRec->ble_pair_info.self_info.ble_addr, + BTIF_BD_ADDR_SIZE); - TRACE(1,"[%s]---", __func__); - return pNvExtRec->ble_pair_info.self_info.ble_addr; + TRACE(1, "[%s]---", __func__); + return pNvExtRec->ble_pair_info.self_info.ble_addr; } #endif -#endif //#if defined(NEW_NV_RECORD_ENABLED) +#endif //#if defined(NEW_NV_RECORD_ENABLED) diff --git a/services/nv_section/fpga_section/nvrecord_bt.c b/services/nv_section/fpga_section/nvrecord_bt.c index 1e16034..0f1438f 100644 --- a/services/nv_section/fpga_section/nvrecord_bt.c +++ b/services/nv_section/fpga_section/nvrecord_bt.c @@ -14,84 +14,75 @@ * ****************************************************************************/ #if defined(NEW_NV_RECORD_ENABLED) -#include -#include -#include -#include "nvrecord_extension.h" #include "nvrecord_bt.h" #include "hal_trace.h" +#include "nvrecord_extension.h" +#include +#include +#include nvrec_btdevicerecord g_fpga_ram_record; -void ram_record_ddbrec_init(void) -{ +void ram_record_ddbrec_init(void) { g_fpga_ram_record.record.trusted = false; } + +bt_status_t ram_record_ddbrec_find(const bt_bdaddr_t *bd_ddr, + nvrec_btdevicerecord **record) { + if (g_fpga_ram_record.record.trusted && + !memcmp(&g_fpga_ram_record.record.bdAddr.address[0], &bd_ddr->address[0], + 6)) { + *record = &g_fpga_ram_record; + return BT_STS_SUCCESS; + } else { + return BT_STS_FAILED; + } +} + +bt_status_t ram_record_ddbrec_add(const nvrec_btdevicerecord *param_rec) { + g_fpga_ram_record = *param_rec; + g_fpga_ram_record.record.trusted = true; + return BT_STS_SUCCESS; +} + +bt_status_t ram_record_ddbrec_delete(const bt_bdaddr_t *bdaddr) { + if (g_fpga_ram_record.record.trusted && + !memcmp(&g_fpga_ram_record.record.bdAddr.address[0], &bdaddr->address[0], + 6)) { g_fpga_ram_record.record.trusted = false; + } + return BT_STS_SUCCESS; } -bt_status_t ram_record_ddbrec_find(const bt_bdaddr_t* bd_ddr, nvrec_btdevicerecord **record) -{ - if (g_fpga_ram_record.record.trusted && \ - !memcmp(&g_fpga_ram_record.record.bdAddr.address[0], &bd_ddr->address[0], 6)) - { - *record = &g_fpga_ram_record; - return BT_STS_SUCCESS; - } - else - { - return BT_STS_FAILED; - } +void nvrecord_rebuild_paired_bt_dev_info( + NV_RECORD_PAIRED_BT_DEV_INFO_T *pPairedBtInfo) { + memset((uint8_t *)pPairedBtInfo, 0, sizeof(NV_RECORD_PAIRED_BT_DEV_INFO_T)); + pPairedBtInfo->pairedDevNum = 0; } -bt_status_t ram_record_ddbrec_add(const nvrec_btdevicerecord* param_rec) -{ - g_fpga_ram_record = *param_rec; - g_fpga_ram_record.record.trusted = true; - return BT_STS_SUCCESS; +void nv_record_btdevicerecord_set_a2dp_profile_active_state( + btdevice_profile *device_plf, bool isActive) { + device_plf->hsp_act = isActive; } -bt_status_t ram_record_ddbrec_delete(const bt_bdaddr_t *bdaddr) -{ - if (g_fpga_ram_record.record.trusted && \ - !memcmp(&g_fpga_ram_record.record.bdAddr.address[0], &bdaddr->address[0], 6)) - { - g_fpga_ram_record.record.trusted = false; - } - return BT_STS_SUCCESS; +void nv_record_btdevicerecord_set_hfp_profile_active_state( + btdevice_profile *device_plf, bool isActive) { + device_plf->hsp_act = isActive; } -void nvrecord_rebuild_paired_bt_dev_info(NV_RECORD_PAIRED_BT_DEV_INFO_T* pPairedBtInfo) -{ - memset((uint8_t *)pPairedBtInfo, 0, sizeof(NV_RECORD_PAIRED_BT_DEV_INFO_T)); - pPairedBtInfo->pairedDevNum = 0; +void nv_record_btdevicerecord_set_hsp_profile_active_state( + btdevice_profile *device_plf, bool isActive) { + device_plf->hsp_act = isActive; } -void nv_record_btdevicerecord_set_a2dp_profile_active_state(btdevice_profile* device_plf, bool isActive) -{ - device_plf->hsp_act = isActive; +void nv_record_btdevicerecord_set_a2dp_profile_codec( + btdevice_profile *device_plf, uint8_t a2dpCodec) { + device_plf->a2dp_codectype = a2dpCodec; } -void nv_record_btdevicerecord_set_hfp_profile_active_state(btdevice_profile* device_plf, bool isActive) -{ - device_plf->hsp_act = isActive; -} +int nv_record_get_paired_dev_count(void) { + if (NULL == nvrecord_extension_p) { + return 0; + } -void nv_record_btdevicerecord_set_hsp_profile_active_state(btdevice_profile* device_plf, bool isActive) -{ - device_plf->hsp_act = isActive; -} - -void nv_record_btdevicerecord_set_a2dp_profile_codec(btdevice_profile* device_plf, uint8_t a2dpCodec) -{ - device_plf->a2dp_codectype = a2dpCodec; -} - -int nv_record_get_paired_dev_count(void) -{ - if (NULL == nvrecord_extension_p) - { - return 0; - } - - return nvrecord_extension_p->bt_pair_info.pairedDevNum; + return nvrecord_extension_p->bt_pair_info.pairedDevNum; } /* @@ -101,355 +92,325 @@ return: 1: only 1 paired dev,store@record1. 2: get 2 paired dev.notice:record1 is the latest record. */ -int nv_record_enum_latest_two_paired_dev(btif_device_record_t* record1,btif_device_record_t* record2) -{ - if((NULL == record1) || (NULL == record2) || (NULL == nvrecord_extension_p)) - { - return -1; - } +int nv_record_enum_latest_two_paired_dev(btif_device_record_t *record1, + btif_device_record_t *record2) { + if ((NULL == record1) || (NULL == record2) || + (NULL == nvrecord_extension_p)) { + return -1; + } - if (nvrecord_extension_p->bt_pair_info.pairedDevNum > 0) - { - if (1 == nvrecord_extension_p->bt_pair_info.pairedDevNum) - { - memcpy((uint8_t *)record1, (uint8_t *)&(nvrecord_extension_p->bt_pair_info.pairedBtDevInfo[0]), - sizeof(btif_device_record_t)); - return 1; - } - else - { - memcpy((uint8_t *)record1, (uint8_t *)&(nvrecord_extension_p->bt_pair_info.pairedBtDevInfo[0]), - sizeof(btif_device_record_t)); - memcpy((uint8_t *)record2, (uint8_t *)&(nvrecord_extension_p->bt_pair_info.pairedBtDevInfo[1]), - sizeof(btif_device_record_t)); - return 2; - } - } - else - { - return 0; + if (nvrecord_extension_p->bt_pair_info.pairedDevNum > 0) { + if (1 == nvrecord_extension_p->bt_pair_info.pairedDevNum) { + memcpy( + (uint8_t *)record1, + (uint8_t *)&(nvrecord_extension_p->bt_pair_info.pairedBtDevInfo[0]), + sizeof(btif_device_record_t)); + return 1; + } else { + memcpy( + (uint8_t *)record1, + (uint8_t *)&(nvrecord_extension_p->bt_pair_info.pairedBtDevInfo[0]), + sizeof(btif_device_record_t)); + memcpy( + (uint8_t *)record2, + (uint8_t *)&(nvrecord_extension_p->bt_pair_info.pairedBtDevInfo[1]), + sizeof(btif_device_record_t)); + return 2; } + } else { + return 0; + } } -static void nv_record_print_dev_record(const btif_device_record_t* record) -{ +static void nv_record_print_dev_record(const btif_device_record_t *record) {} -} +void nv_record_all_ddbrec_print(void) { + if (NULL == nvrecord_extension_p) { + TRACE(0, "No BT paired dev."); + return; + } -void nv_record_all_ddbrec_print(void) -{ - if (NULL == nvrecord_extension_p) - { - TRACE(0,"No BT paired dev."); - return; - } - - if (nvrecord_extension_p->bt_pair_info.pairedDevNum > 0) - { - for(uint8_t tmp_i=0; tmp_i < nvrecord_extension_p->bt_pair_info.pairedDevNum; tmp_i++) - { - btif_device_record_t record; - bt_status_t ret_status; - ret_status = nv_record_enum_dev_records(tmp_i, &record); - if (BT_STS_SUCCESS == ret_status) - { - nv_record_print_dev_record(&record); - } - } - } - else - { - TRACE(0,"No BT paired dev."); + if (nvrecord_extension_p->bt_pair_info.pairedDevNum > 0) { + for (uint8_t tmp_i = 0; + tmp_i < nvrecord_extension_p->bt_pair_info.pairedDevNum; tmp_i++) { + btif_device_record_t record; + bt_status_t ret_status; + ret_status = nv_record_enum_dev_records(tmp_i, &record); + if (BT_STS_SUCCESS == ret_status) { + nv_record_print_dev_record(&record); + } } + } else { + TRACE(0, "No BT paired dev."); + } } /* this function should be surrounded by OS_LockStack and OS_UnlockStack when call. */ -bt_status_t nv_record_enum_dev_records(unsigned short index,btif_device_record_t* record) -{ - btif_device_record_t *recaddr = NULL; +bt_status_t nv_record_enum_dev_records(unsigned short index, + btif_device_record_t *record) { + btif_device_record_t *recaddr = NULL; - if((index >= nvrecord_extension_p->bt_pair_info.pairedDevNum) || (NULL == nvrecord_extension_p)) - { - return BT_STS_FAILED; - } + if ((index >= nvrecord_extension_p->bt_pair_info.pairedDevNum) || + (NULL == nvrecord_extension_p)) { + return BT_STS_FAILED; + } - recaddr = (btif_device_record_t *)&(nvrecord_extension_p->bt_pair_info.pairedBtDevInfo[index].record); - memcpy(record, recaddr, sizeof(btif_device_record_t)); - nv_record_print_dev_record(record); - return BT_STS_SUCCESS; + recaddr = (btif_device_record_t *)&( + nvrecord_extension_p->bt_pair_info.pairedBtDevInfo[index].record); + memcpy(record, recaddr, sizeof(btif_device_record_t)); + nv_record_print_dev_record(record); + return BT_STS_SUCCESS; } -static int8_t nv_record_get_bt_pairing_info_index(const uint8_t* btAddr) -{ - NV_RECORD_PAIRED_BT_DEV_INFO_T* pBtDevInfo = - (NV_RECORD_PAIRED_BT_DEV_INFO_T *)(&(nvrecord_extension_p->bt_pair_info)); +static int8_t nv_record_get_bt_pairing_info_index(const uint8_t *btAddr) { + NV_RECORD_PAIRED_BT_DEV_INFO_T *pBtDevInfo = + (NV_RECORD_PAIRED_BT_DEV_INFO_T *)(&(nvrecord_extension_p->bt_pair_info)); - for (uint8_t index = 0; index < pBtDevInfo->pairedDevNum; index++) - { - if (!memcmp(pBtDevInfo->pairedBtDevInfo[index].record.bdAddr.address, - btAddr, BTIF_BD_ADDR_SIZE)) - { - return (int8_t)index; - } + for (uint8_t index = 0; index < pBtDevInfo->pairedDevNum; index++) { + if (!memcmp(pBtDevInfo->pairedBtDevInfo[index].record.bdAddr.address, + btAddr, BTIF_BD_ADDR_SIZE)) { + return (int8_t)index; } + } - return -1; + return -1; } /********************************************** this function should be surrounded by OS_LockStack and OS_UnlockStack when call. **********************************************/ -static bt_status_t POSSIBLY_UNUSED nv_record_ddbrec_add(const btif_device_record_t* param_rec) -{ - if ((NULL == param_rec) || (NULL == nvrecord_extension_p)) - { - return BT_STS_FAILED; +static bt_status_t POSSIBLY_UNUSED +nv_record_ddbrec_add(const btif_device_record_t *param_rec) { + if ((NULL == param_rec) || (NULL == nvrecord_extension_p)) { + return BT_STS_FAILED; + } + + uint32_t lock = nv_record_pre_write_operation(); + + bool isFlushNv = false; + + // try to find the entry + int8_t indexOfEntry = -1; + NV_RECORD_PAIRED_BT_DEV_INFO_T *pBtDevInfo = + (NV_RECORD_PAIRED_BT_DEV_INFO_T *)(&(nvrecord_extension_p->bt_pair_info)); + indexOfEntry = nv_record_get_bt_pairing_info_index(param_rec->bdAddr.address); + + if (-1 == indexOfEntry) { + // don't exist, need to add to the head of the entry list + if (MAX_BT_PAIRED_DEVICE_COUNT == pBtDevInfo->pairedDevNum) { + for (uint8_t k = 0; k < MAX_BT_PAIRED_DEVICE_COUNT - 1; k++) { + memcpy((uint8_t *)&( + pBtDevInfo + ->pairedBtDevInfo[MAX_BT_PAIRED_DEVICE_COUNT - 1 - k]), + (uint8_t *)&( + pBtDevInfo + ->pairedBtDevInfo[MAX_BT_PAIRED_DEVICE_COUNT - 2 - k]), + sizeof(nvrec_btdevicerecord)); + } + pBtDevInfo->pairedDevNum--; + } else { + for (uint8_t k = 0; k < pBtDevInfo->pairedDevNum; k++) { + memcpy( + (uint8_t *)&( + pBtDevInfo->pairedBtDevInfo[pBtDevInfo->pairedDevNum - k]), + (uint8_t *)&( + pBtDevInfo->pairedBtDevInfo[pBtDevInfo->pairedDevNum - 1 - k]), + sizeof(nvrec_btdevicerecord)); + } } - uint32_t lock = nv_record_pre_write_operation(); - - bool isFlushNv = false; - - // try to find the entry - int8_t indexOfEntry = -1; - NV_RECORD_PAIRED_BT_DEV_INFO_T* pBtDevInfo = - (NV_RECORD_PAIRED_BT_DEV_INFO_T *)(&(nvrecord_extension_p->bt_pair_info)); - indexOfEntry = nv_record_get_bt_pairing_info_index(param_rec->bdAddr.address); - - if (-1 == indexOfEntry) - { - // don't exist, need to add to the head of the entry list - if (MAX_BT_PAIRED_DEVICE_COUNT == pBtDevInfo->pairedDevNum) - { - for (uint8_t k = 0; k < MAX_BT_PAIRED_DEVICE_COUNT - 1; k++) - { - memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[MAX_BT_PAIRED_DEVICE_COUNT - 1 - k]), - (uint8_t *)&(pBtDevInfo->pairedBtDevInfo[MAX_BT_PAIRED_DEVICE_COUNT - 2 - k]), - sizeof(nvrec_btdevicerecord)); - } - pBtDevInfo->pairedDevNum--; - } - else - { - for (uint8_t k = 0; k < pBtDevInfo->pairedDevNum; k++) - { - memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[pBtDevInfo->pairedDevNum - k]), - (uint8_t *)&(pBtDevInfo->pairedBtDevInfo[pBtDevInfo->pairedDevNum - 1 - k]), - sizeof(nvrec_btdevicerecord)); - } - } - - // fill the default value - nvrec_btdevicerecord* nvrec_pool_record = &(pBtDevInfo->pairedBtDevInfo[0]); - memcpy((uint8_t *)&(nvrec_pool_record->record), (uint8_t *)param_rec, - sizeof(btif_device_record_t)); - nvrec_pool_record->device_vol.a2dp_vol = NVRAM_ENV_STREAM_VOLUME_A2DP_VOL_DEFAULT; - nvrec_pool_record->device_vol.hfp_vol = NVRAM_ENV_STREAM_VOLUME_HFP_VOL_DEFAULT; - nvrec_pool_record->device_plf.hfp_act = false; - nvrec_pool_record->device_plf.hsp_act = false; - nvrec_pool_record->device_plf.a2dp_act = false; + // fill the default value + nvrec_btdevicerecord *nvrec_pool_record = &(pBtDevInfo->pairedBtDevInfo[0]); + memcpy((uint8_t *)&(nvrec_pool_record->record), (uint8_t *)param_rec, + sizeof(btif_device_record_t)); + nvrec_pool_record->device_vol.a2dp_vol = + NVRAM_ENV_STREAM_VOLUME_A2DP_VOL_DEFAULT; + nvrec_pool_record->device_vol.hfp_vol = + NVRAM_ENV_STREAM_VOLUME_HFP_VOL_DEFAULT; + nvrec_pool_record->device_plf.hfp_act = false; + nvrec_pool_record->device_plf.hsp_act = false; + nvrec_pool_record->device_plf.a2dp_act = false; #ifdef BTIF_DIP_DEVICE - nvrec_pool_record->vend_id = 0; - nvrec_pool_record->vend_id_source = 0; + nvrec_pool_record->vend_id = 0; + nvrec_pool_record->vend_id_source = 0; #endif - pBtDevInfo->pairedDevNum++; + pBtDevInfo->pairedDevNum++; + + // need to flush the nv record + isFlushNv = true; + } else { + // exist + // check whether it's already at the head + // if not, move it to the head + if (indexOfEntry > 0) { + nvrec_btdevicerecord record; + memcpy((uint8_t *)&record, + (uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry]), + sizeof(record)); + + // if not, move it to the head + for (uint8_t k = 0; k < indexOfEntry; k++) { + memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry - k]), + (uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry - 1 - k]), + sizeof(nvrec_btdevicerecord)); + } + + memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[0]), (uint8_t *)&record, + sizeof(record)); + + // update the link info + memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[0].record), + (uint8_t *)param_rec, sizeof(btif_device_record_t)); + + // need to flush the nv record + isFlushNv = true; + } + // else, check whether the link info needs to be updated + else { + if (memcmp((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[0].record), + (uint8_t *)param_rec, sizeof(btif_device_record_t))) { + // update the link info + memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[0].record), + (uint8_t *)param_rec, sizeof(btif_device_record_t)); // need to flush the nv record isFlushNv = true; + } } - else - { - // exist - // check whether it's already at the head - // if not, move it to the head - if (indexOfEntry > 0) - { - nvrec_btdevicerecord record; - memcpy((uint8_t *)&record, (uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry]), - sizeof(record)); + } - // if not, move it to the head - for (uint8_t k = 0; k < indexOfEntry; k++) - { - memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry - k]), - (uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry - 1 - k]), - sizeof(nvrec_btdevicerecord)); - } + TRACE(1, "paired Bt dev:%d", pBtDevInfo->pairedDevNum); + TRACE(1, "Is to flush nv: %d", isFlushNv); + nv_record_all_ddbrec_print(); - memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[0]), (uint8_t *)&record, - sizeof(record)); + if (isFlushNv) { + nv_record_update_runtime_userdata(); + } - // update the link info - memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[0].record), (uint8_t *)param_rec, - sizeof(btif_device_record_t)); + nv_record_post_write_operation(lock); - // need to flush the nv record - isFlushNv = true; - } - // else, check whether the link info needs to be updated - else - { - if (memcmp((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[0].record), - (uint8_t *)param_rec, sizeof(btif_device_record_t))) - { - // update the link info - memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[0].record), (uint8_t *)param_rec, - sizeof(btif_device_record_t)); + return BT_STS_SUCCESS; +} - // need to flush the nv record - isFlushNv = true; - } - } - } +/* +this function should be surrounded by OS_LockStack and OS_UnlockStack when call. +*/ +bt_status_t nv_record_add(SECTIONS_ADP_ENUM type, void *record) { + bt_status_t retstatus = BT_STS_FAILED; - TRACE(1,"paired Bt dev:%d", pBtDevInfo->pairedDevNum); - TRACE(1,"Is to flush nv: %d", isFlushNv); - nv_record_all_ddbrec_print(); + if ((NULL == record) || (section_none == type)) { + return BT_STS_FAILED; + } - if (isFlushNv) - { - nv_record_update_runtime_userdata(); - } + switch (type) { + case section_usrdata_ddbrecord: + retstatus = ram_record_ddbrec_add(record); + break; + default: + break; + } - nv_record_post_write_operation(lock); + return retstatus; +} +/* +this function should be surrounded by OS_LockStack and OS_UnlockStack when call. +*/ +bt_status_t nv_record_ddbrec_find(const bt_bdaddr_t *bd_ddr, + btif_device_record_t *record) { + if ((NULL == bd_ddr) || (NULL == record) || (NULL == nvrecord_extension_p)) { + return BT_STS_FAILED; + } + + int8_t indexOfEntry = -1; + NV_RECORD_PAIRED_BT_DEV_INFO_T *pBtDevInfo = + (NV_RECORD_PAIRED_BT_DEV_INFO_T *)(&(nvrecord_extension_p->bt_pair_info)); + indexOfEntry = nv_record_get_bt_pairing_info_index(bd_ddr->address); + + if (-1 == indexOfEntry) { + return BT_STS_FAILED; + } else { + memcpy((uint8_t *)record, + (uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry].record), + sizeof(btif_device_record_t)); return BT_STS_SUCCESS; + } } /* this function should be surrounded by OS_LockStack and OS_UnlockStack when call. */ -bt_status_t nv_record_add(SECTIONS_ADP_ENUM type, void *record) -{ - bt_status_t retstatus = BT_STS_FAILED; - - if ((NULL == record) || (section_none == type)) - { - return BT_STS_FAILED; - } - - switch(type) - { - case section_usrdata_ddbrecord: - retstatus = ram_record_ddbrec_add(record); - break; - default: - break; - } - - return retstatus; +bt_status_t nv_record_ddbrec_delete(const bt_bdaddr_t *bdaddr) { + ram_record_ddbrec_delete(bdaddr); + return BT_STS_SUCCESS; } -/* -this function should be surrounded by OS_LockStack and OS_UnlockStack when call. -*/ -bt_status_t nv_record_ddbrec_find(const bt_bdaddr_t* bd_ddr, btif_device_record_t *record) -{ - if ((NULL == bd_ddr) || (NULL == record) || (NULL == nvrecord_extension_p)) - { - return BT_STS_FAILED; - } - - int8_t indexOfEntry = -1; - NV_RECORD_PAIRED_BT_DEV_INFO_T* pBtDevInfo = - (NV_RECORD_PAIRED_BT_DEV_INFO_T *)(&(nvrecord_extension_p->bt_pair_info)); - indexOfEntry = nv_record_get_bt_pairing_info_index(bd_ddr->address); - - if (-1 == indexOfEntry) - { - return BT_STS_FAILED; - } - else - { - memcpy((uint8_t *)record, (uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry].record), - sizeof(btif_device_record_t)); - return BT_STS_SUCCESS; - } +int nv_record_btdevicerecord_find(const bt_bdaddr_t *bd_ddr, + nvrec_btdevicerecord **record) { + ram_record_ddbrec_find(bd_ddr, record); + return 0; } -/* -this function should be surrounded by OS_LockStack and OS_UnlockStack when call. -*/ -bt_status_t nv_record_ddbrec_delete(const bt_bdaddr_t *bdaddr) -{ - ram_record_ddbrec_delete(bdaddr); - return BT_STS_SUCCESS; +void nv_record_btdevicerecord_set_a2dp_vol(nvrec_btdevicerecord *pRecord, + int8_t vol) { + uint32_t lock = nv_record_pre_write_operation(); + if (vol != pRecord->device_vol.a2dp_vol) { + nv_record_update_runtime_userdata(); + pRecord->device_vol.a2dp_vol = vol; + } + + nv_record_post_write_operation(lock); } -int nv_record_btdevicerecord_find(const bt_bdaddr_t *bd_ddr, nvrec_btdevicerecord **record) -{ - ram_record_ddbrec_find(bd_ddr, record); - return 0; +void nv_record_btdevicerecord_set_hfp_vol(nvrec_btdevicerecord *pRecord, + int8_t vol) { + uint32_t lock = nv_record_pre_write_operation(); + if (vol != pRecord->device_vol.hfp_vol) { + nv_record_update_runtime_userdata(); + pRecord->device_vol.hfp_vol = vol; + } + + nv_record_post_write_operation(lock); } -void nv_record_btdevicerecord_set_a2dp_vol(nvrec_btdevicerecord* pRecord, int8_t vol) -{ - uint32_t lock = nv_record_pre_write_operation(); - if (vol != pRecord->device_vol.a2dp_vol) - { - nv_record_update_runtime_userdata(); - pRecord->device_vol.a2dp_vol = vol; - } +void nv_record_btdevicevolume_set_a2dp_vol(btdevice_volume *device_vol, + int8_t vol) { + uint32_t lock = nv_record_pre_write_operation(); + if (vol != device_vol->a2dp_vol) { + nv_record_update_runtime_userdata(); + device_vol->a2dp_vol = vol; + } - nv_record_post_write_operation(lock); + nv_record_post_write_operation(lock); } -void nv_record_btdevicerecord_set_hfp_vol(nvrec_btdevicerecord* pRecord, int8_t vol) -{ - uint32_t lock = nv_record_pre_write_operation(); - if (vol != pRecord->device_vol.hfp_vol) - { - nv_record_update_runtime_userdata(); - pRecord->device_vol.hfp_vol = vol; - } +void nv_record_btdevicevolume_set_hfp_vol(btdevice_volume *device_vol, + int8_t vol) { + uint32_t lock = nv_record_pre_write_operation(); + if (vol != device_vol->hfp_vol) { + nv_record_update_runtime_userdata(); + device_vol->hfp_vol = vol; + } - nv_record_post_write_operation(lock); + nv_record_post_write_operation(lock); } -void nv_record_btdevicevolume_set_a2dp_vol(btdevice_volume* device_vol, int8_t vol) -{ - uint32_t lock = nv_record_pre_write_operation(); - if (vol != device_vol->a2dp_vol) - { - nv_record_update_runtime_userdata(); - device_vol->a2dp_vol = vol; - } - - nv_record_post_write_operation(lock); - -} - -void nv_record_btdevicevolume_set_hfp_vol(btdevice_volume* device_vol, int8_t vol) -{ - uint32_t lock = nv_record_pre_write_operation(); - if (vol != device_vol->hfp_vol) - { - nv_record_update_runtime_userdata(); - device_vol->hfp_vol = vol; - } - - nv_record_post_write_operation(lock); - -} - -void nv_record_btdevicerecord_set_vend_id_and_source(nvrec_btdevicerecord* pRecord, int16_t vend_id, int16_t vend_id_source) -{ +void nv_record_btdevicerecord_set_vend_id_and_source( + nvrec_btdevicerecord *pRecord, int16_t vend_id, int16_t vend_id_source) { #ifdef BTIF_DIP_DEVICE - TRACE(2, "%s vend id 0x%x", __func__, vend_id); - uint32_t lock = nv_record_pre_write_operation(); - if (vend_id != pRecord->vend_id) - { - nv_record_update_runtime_userdata(); - pRecord->vend_id = vend_id; - pRecord->vend_id_source = vend_id_source; - } + TRACE(2, "%s vend id 0x%x", __func__, vend_id); + uint32_t lock = nv_record_pre_write_operation(); + if (vend_id != pRecord->vend_id) { + nv_record_update_runtime_userdata(); + pRecord->vend_id = vend_id; + pRecord->vend_id_source = vend_id_source; + } - nv_record_post_write_operation(lock); + nv_record_post_write_operation(lock); #endif } #endif //#if defined(NEW_NV_RECORD_ENABLED) - diff --git a/services/nv_section/fpga_section/nvrecord_env.c b/services/nv_section/fpga_section/nvrecord_env.c index f68979c..2e6f99d 100644 --- a/services/nv_section/fpga_section/nvrecord_env.c +++ b/services/nv_section/fpga_section/nvrecord_env.c @@ -14,98 +14,86 @@ * ****************************************************************************/ #if defined(NEW_NV_RECORD_ENABLED) -#include -#include -#include -#include "nvrecord_extension.h" #include "nvrecord_env.h" #include "hal_trace.h" +#include "nvrecord_extension.h" +#include +#include +#include static struct nvrecord_env_t localSystemInfo; -void nvrecord_rebuild_system_env(struct nvrecord_env_t* pSystemEnv) -{ - memset((uint8_t *)pSystemEnv, 0, sizeof(struct nvrecord_env_t)); - - pSystemEnv->media_language.language = NVRAM_ENV_MEDIA_LANGUAGE_DEFAULT; - pSystemEnv->ibrt_mode.mode = NVRAM_ENV_TWS_MODE_DEFAULT; - pSystemEnv->ibrt_mode.tws_connect_success = 0; - pSystemEnv->factory_tester_status.status = NVRAM_ENV_FACTORY_TESTER_STATUS_DEFAULT; +void nvrecord_rebuild_system_env(struct nvrecord_env_t *pSystemEnv) { + memset((uint8_t *)pSystemEnv, 0, sizeof(struct nvrecord_env_t)); - pSystemEnv->voice_key_enable = false; - pSystemEnv->aiManagerInfo.setedCurrentAi = 0; - pSystemEnv->aiManagerInfo.aiStatusDisableFlag = 0; - pSystemEnv->aiManagerInfo.amaAssistantEnableStatus = 1; + pSystemEnv->media_language.language = NVRAM_ENV_MEDIA_LANGUAGE_DEFAULT; + pSystemEnv->ibrt_mode.mode = NVRAM_ENV_TWS_MODE_DEFAULT; + pSystemEnv->ibrt_mode.tws_connect_success = 0; + pSystemEnv->factory_tester_status.status = + NVRAM_ENV_FACTORY_TESTER_STATUS_DEFAULT; - localSystemInfo = *pSystemEnv; + pSystemEnv->voice_key_enable = false; + pSystemEnv->aiManagerInfo.setedCurrentAi = 0; + pSystemEnv->aiManagerInfo.aiStatusDisableFlag = 0; + pSystemEnv->aiManagerInfo.amaAssistantEnableStatus = 1; + + localSystemInfo = *pSystemEnv; } -int nv_record_env_get(struct nvrecord_env_t **nvrecord_env) -{ - if (NULL == nvrecord_env) - { - return -1; - } - localSystemInfo.ibrt_mode.tws_connect_success = true; - *nvrecord_env = &localSystemInfo; +int nv_record_env_get(struct nvrecord_env_t **nvrecord_env) { + if (NULL == nvrecord_env) { + return -1; + } + localSystemInfo.ibrt_mode.tws_connect_success = true; + *nvrecord_env = &localSystemInfo; - return 0; + return 0; } -int nv_record_env_set(struct nvrecord_env_t *nvrecord_env) -{ - if (NULL == nvrecord_extension_p) - { - return -1; - } +int nv_record_env_set(struct nvrecord_env_t *nvrecord_env) { + if (NULL == nvrecord_extension_p) { + return -1; + } - uint32_t lock = nv_record_pre_write_operation(); - nvrecord_extension_p->system_info = *nvrecord_env; - - nv_record_update_runtime_userdata(); - nv_record_post_write_operation(lock); - return 0; + uint32_t lock = nv_record_pre_write_operation(); + nvrecord_extension_p->system_info = *nvrecord_env; + + nv_record_update_runtime_userdata(); + nv_record_post_write_operation(lock); + return 0; } -void nv_record_update_ibrt_info(uint32_t newMode, bt_bdaddr_t *ibrtPeerAddr) -{ - if (NULL == nvrecord_extension_p) - { - return; - } - - uint32_t lock = nv_record_pre_write_operation(); +void nv_record_update_ibrt_info(uint32_t newMode, bt_bdaddr_t *ibrtPeerAddr) { + if (NULL == nvrecord_extension_p) { + return; + } - TRACE(2,"##%s,%d",__func__,newMode); - nvrecord_extension_p->system_info.ibrt_mode.mode = newMode; - memcpy(nvrecord_extension_p->system_info.ibrt_mode.record.bdAddr.address, - ibrtPeerAddr->address, BTIF_BD_ADDR_SIZE); + uint32_t lock = nv_record_pre_write_operation(); - nv_record_update_runtime_userdata(); - nv_record_post_write_operation(lock); + TRACE(2, "##%s,%d", __func__, newMode); + nvrecord_extension_p->system_info.ibrt_mode.mode = newMode; + memcpy(nvrecord_extension_p->system_info.ibrt_mode.record.bdAddr.address, + ibrtPeerAddr->address, BTIF_BD_ADDR_SIZE); + + nv_record_update_runtime_userdata(); + nv_record_post_write_operation(lock); } +void nv_record_update_factory_tester_status(uint32_t status) { + if (NULL == nvrecord_extension_p) { + return; + } -void nv_record_update_factory_tester_status(uint32_t status) -{ - if (NULL == nvrecord_extension_p) - { - return; - } + uint32_t lock = nv_record_pre_write_operation(); - uint32_t lock = nv_record_pre_write_operation(); + nvrecord_extension_p->system_info.factory_tester_status.status = status; - nvrecord_extension_p->system_info.factory_tester_status.status = status; - - nv_record_update_runtime_userdata(); - nv_record_post_write_operation(lock); + nv_record_update_runtime_userdata(); + nv_record_post_write_operation(lock); } -int nv_record_env_init(void) -{ - nv_record_open(section_usrdata_ddbrecord); - return 0; +int nv_record_env_init(void) { + nv_record_open(section_usrdata_ddbrecord); + return 0; } #endif // #if defined(NEW_NV_RECORD_ENABLED) - - diff --git a/services/nv_section/fpga_section/nvrecord_externsion.c b/services/nv_section/fpga_section/nvrecord_externsion.c index 6058ddf..738ff69 100644 --- a/services/nv_section/fpga_section/nvrecord_externsion.c +++ b/services/nv_section/fpga_section/nvrecord_externsion.c @@ -14,43 +14,45 @@ * ****************************************************************************/ #ifdef NEW_NV_RECORD_ENABLED -#include -#include -#include +#include "besbt.h" #include "cmsis.h" -#include "nvrecord_extension.h" -#include "hal_trace.h" #include "crc32.h" +#include "customparam_section.h" #include "hal_norflash.h" +#include "hal_trace.h" +#include "mpu.h" #include "norflash_api.h" #include "norflash_drv.h" -#include "nvrecord_bt.h" -#include "nvrecord_env.h" #include "nvrecord_ble.h" +#include "nvrecord_bt.h" #include "nvrecord_dma_config.h" +#include "nvrecord_env.h" +#include "nvrecord_extension.h" #include "nvrecord_fp_account_key.h" -#include "customparam_section.h" -#include "mpu.h" -#include "besbt.h" +#include +#include +#include extern uint32_t __userdata_start[]; extern uint32_t __userdata_end[]; -extern void nvrecord_rebuild_system_env(struct nvrecord_env_t* pSystemEnv); -extern void nvrecord_rebuild_paired_bt_dev_info(NV_RECORD_PAIRED_BT_DEV_INFO_T* pPairedBtInfo); +extern void nvrecord_rebuild_system_env(struct nvrecord_env_t *pSystemEnv); +extern void nvrecord_rebuild_paired_bt_dev_info( + NV_RECORD_PAIRED_BT_DEV_INFO_T *pPairedBtInfo); #ifdef GFPS_ENABLED -extern void nvrecord_rebuild_fp_account_key(NV_FP_ACCOUNT_KEY_RECORD_T* pFpAccountKey); +extern void +nvrecord_rebuild_fp_account_key(NV_FP_ACCOUNT_KEY_RECORD_T *pFpAccountKey); #endif #ifdef NVREC_BAIDU_DATA_SECTION -extern void nvrecord_rebuild_dma_configuration(NV_DMA_CONFIGURATION_T* pDmaConfig); +extern void +nvrecord_rebuild_dma_configuration(NV_DMA_CONFIGURATION_T *pDmaConfig); #endif -typedef enum -{ - NV_STATE_IDLE, - NV_STATE_ERASED, -}NV_STATE; +typedef enum { + NV_STATE_IDLE, + NV_STATE_ERASED, +} NV_STATE; -NV_EXTENSION_RECORD_T *nvrecord_extension_p = NULL; +NV_EXTENSION_RECORD_T *nvrecord_extension_p = NULL; static uint8_t isNvExtentionPendingForUpdate = false; static NV_STATE isNvExtentionState = NV_STATE_IDLE; /* @@ -66,11 +68,11 @@ static NV_STATE isNvExtentionState = NV_STATE_IDLE; #define __NV_BUF_MPU_ALIGNED __ALIGNED(NV_EXTENSION_MIRROR_RAM_SIZE) #endif -static NV_MIRROR_BUF_T local_extension_data __NV_BUF_MPU_ALIGNED - __attribute__((section(".sram_data"))) = -{ +static NV_MIRROR_BUF_T local_extension_data __NV_BUF_MPU_ALIGNED __attribute__(( + section(".sram_data"))) = { .nv_record = { - { // header + { + // header NV_EXTENSION_MAGIC_NUMBER, NV_EXTENSION_MAJOR_VERSION, NV_EXTENSION_MINOR_VERSION, @@ -78,39 +80,39 @@ static NV_MIRROR_BUF_T local_extension_data __NV_BUF_MPU_ALIGNED 0, }, - { // system info + { + // system info }, - { // bt_pair_info - 0 - }, + {// bt_pair_info + 0}, - { // ble_pair_info + { + // ble_pair_info }, #ifdef TWS_SYSTEM_ENABLED - { // tws_info + { + // tws_info }, #endif #ifdef GFPS_ENABLED - { // fp_account_key_rec - 0 - }, + {// fp_account_key_rec + 0}, #endif #ifdef NVREC_BAIDU_DATA_SECTION - { // dma_config + { + // dma_config BAIDU_DATA_DEF_FM_FREQ, }, #endif #ifdef TILE_DATAPATH - { - {0} - }, + {{0}}, #endif #if defined(BISTO_ENABLED) @@ -133,415 +135,347 @@ static NV_MIRROR_BUF_T local_extension_data __NV_BUF_MPU_ALIGNED // If want to extend the nvrecord while keeping the history information, // append the new items to the tail of NV_EXTENSION_RECORD_T and // set their intial content here - } -}; -STATIC_ASSERT(sizeof(local_extension_data) <= NV_EXTENSION_MIRROR_RAM_SIZE, "NV local buffer too small"); + }}; +STATIC_ASSERT(sizeof(local_extension_data) <= NV_EXTENSION_MIRROR_RAM_SIZE, + "NV local buffer too small"); -static void _nv_record_extension_init(void) -{ - enum NORFLASH_API_RET_T result; - uint32_t sector_size = 0; - uint32_t block_size = 0; - uint32_t page_size = 0; +static void _nv_record_extension_init(void) { + enum NORFLASH_API_RET_T result; + uint32_t sector_size = 0; + uint32_t block_size = 0; + uint32_t page_size = 0; - hal_norflash_get_size(HAL_NORFLASH_ID_0, - NULL, - &block_size, - §or_size, - &page_size); - result = norflash_api_register(NORFLASH_API_MODULE_ID_USERDATA_EXT, - HAL_NORFLASH_ID_0, - ((uint32_t)__userdata_start), - ((uint32_t)__userdata_end - (uint32_t)__userdata_start), - block_size, - sector_size, - page_size, - NV_EXTENSION_SIZE*2, - nv_extension_callback - ); - ASSERT(result == NORFLASH_API_OK,"_nv_record_extension_init: module register failed! result = %d.",result); + hal_norflash_get_size(HAL_NORFLASH_ID_0, NULL, &block_size, §or_size, + &page_size); + result = norflash_api_register( + NORFLASH_API_MODULE_ID_USERDATA_EXT, HAL_NORFLASH_ID_0, + ((uint32_t)__userdata_start), + ((uint32_t)__userdata_end - (uint32_t)__userdata_start), block_size, + sector_size, page_size, NV_EXTENSION_SIZE * 2, nv_extension_callback); + ASSERT(result == NORFLASH_API_OK, + "_nv_record_extension_init: module register failed! result = %d.", + result); } -uint32_t nv_record_pre_write_operation(void) -{ - uint32_t lock = int_lock_global(); - mpu_clear(MPU_ID_USER_DATA_SECTION); - return lock; +uint32_t nv_record_pre_write_operation(void) { + uint32_t lock = int_lock_global(); + mpu_clear(MPU_ID_USER_DATA_SECTION); + return lock; } -void nv_record_post_write_operation(uint32_t lock) -{ - int ret = 0; - uint32_t nv_start = (uint32_t)&local_extension_data.nv_record; - uint32_t len = NV_EXTENSION_MIRROR_RAM_SIZE; +void nv_record_post_write_operation(uint32_t lock) { + int ret = 0; + uint32_t nv_start = (uint32_t)&local_extension_data.nv_record; + uint32_t len = NV_EXTENSION_MIRROR_RAM_SIZE; - ret = mpu_set(MPU_ID_USER_DATA_SECTION, nv_start, len, 0, MPU_ATTR_READ); - int_unlock_global(lock); - TRACE(2,"set mpu 0x%x len %d result %d", nv_start, len, ret); + ret = mpu_set(MPU_ID_USER_DATA_SECTION, nv_start, len, 0, MPU_ATTR_READ); + int_unlock_global(lock); + TRACE(2, "set mpu 0x%x len %d result %d", nv_start, len, ret); } -static void nv_record_extension_init(void) -{ - if (NULL == nvrecord_extension_p) - { - uint32_t lock = nv_record_pre_write_operation(); - _nv_record_extension_init(); - nvrecord_extension_p = &local_extension_data.nv_record; - NVRECORD_HEADER_T* pExtRecInFlash = - &(((NV_EXTENSION_RECORD_T *)__userdata_start)->header); - TRACE(2,"nv ext magic 0x%x valid len %d", pExtRecInFlash->magicNumber, - pExtRecInFlash->validLen); +static void nv_record_extension_init(void) { + if (NULL == nvrecord_extension_p) { + uint32_t lock = nv_record_pre_write_operation(); + _nv_record_extension_init(); + nvrecord_extension_p = &local_extension_data.nv_record; + NVRECORD_HEADER_T *pExtRecInFlash = + &(((NV_EXTENSION_RECORD_T *)__userdata_start)->header); + TRACE(2, "nv ext magic 0x%x valid len %d", pExtRecInFlash->magicNumber, + pExtRecInFlash->validLen); - if ((NV_EXTENSION_MAJOR_VERSION == pExtRecInFlash->majorVersion) && - (NV_EXTENSION_MAGIC_NUMBER == pExtRecInFlash->magicNumber)) - { - // check whether the data length is valid - if (pExtRecInFlash->validLen <= (NV_EXTENSION_SIZE-NV_EXTENSION_HEADER_SIZE)) - { - // check crc32 - uint32_t crc = crc32(0,((uint8_t *)pExtRecInFlash + NV_EXTENSION_HEADER_SIZE), - pExtRecInFlash->validLen); - TRACE(2,"generated crc32 0x%x crc32 in flash 0x%x", - crc, pExtRecInFlash->crc32); - if (crc == pExtRecInFlash->crc32) - { - // correct - TRACE(0,"Nv extension is valid."); + if ((NV_EXTENSION_MAJOR_VERSION == pExtRecInFlash->majorVersion) && + (NV_EXTENSION_MAGIC_NUMBER == pExtRecInFlash->magicNumber)) { + // check whether the data length is valid + if (pExtRecInFlash->validLen <= + (NV_EXTENSION_SIZE - NV_EXTENSION_HEADER_SIZE)) { + // check crc32 + uint32_t crc = + crc32(0, ((uint8_t *)pExtRecInFlash + NV_EXTENSION_HEADER_SIZE), + pExtRecInFlash->validLen); + TRACE(2, "generated crc32 0x%x crc32 in flash 0x%x", crc, + pExtRecInFlash->crc32); + if (crc == pExtRecInFlash->crc32) { + // correct + TRACE(0, "Nv extension is valid."); - TRACE(1,"Former nv ext valid len %d", pExtRecInFlash->validLen); - TRACE(1,"Current FW version nv ext valid len %d", NV_EXTENSION_VALID_LEN); + TRACE(1, "Former nv ext valid len %d", pExtRecInFlash->validLen); + TRACE(1, "Current FW version nv ext valid len %d", + NV_EXTENSION_VALID_LEN); - if (NV_EXTENSION_VALID_LEN < pExtRecInFlash->validLen) - { - TRACE(0,"Valid length of extension must be increased," - "jump over the recovery but use the default value."); - } - else - { - memcpy(((uint8_t *)nvrecord_extension_p) + NV_EXTENSION_HEADER_SIZE, - ((uint8_t *)pExtRecInFlash) + NV_EXTENSION_HEADER_SIZE, pExtRecInFlash->validLen); + if (NV_EXTENSION_VALID_LEN < pExtRecInFlash->validLen) { + TRACE(0, "Valid length of extension must be increased," + "jump over the recovery but use the default value."); + } else { + memcpy(((uint8_t *)nvrecord_extension_p) + NV_EXTENSION_HEADER_SIZE, + ((uint8_t *)pExtRecInFlash) + NV_EXTENSION_HEADER_SIZE, + pExtRecInFlash->validLen); - // frimware updates the nv extension data structure - if (pExtRecInFlash->validLen < NV_EXTENSION_VALID_LEN) - { - // update the version number - nvrecord_extension_p->header.minorVersion = NV_EXTENSION_MINOR_VERSION; + // frimware updates the nv extension data structure + if (pExtRecInFlash->validLen < NV_EXTENSION_VALID_LEN) { + // update the version number + nvrecord_extension_p->header.minorVersion = + NV_EXTENSION_MINOR_VERSION; - // re-calculate the crc32 - nvrecord_extension_p->header.crc32 = crc32(0, ((uint8_t *)nvrecord_extension_p + NV_EXTENSION_HEADER_SIZE), - NV_EXTENSION_VALID_LEN); - // need to update the content in the flash - nv_record_extension_update(); - } - - goto exit; - } - } + // re-calculate the crc32 + nvrecord_extension_p->header.crc32 = crc32( + 0, + ((uint8_t *)nvrecord_extension_p + NV_EXTENSION_HEADER_SIZE), + NV_EXTENSION_VALID_LEN); + // need to update the content in the flash + nv_record_extension_update(); } + + goto exit; + } } - - // the nv extension is invalid, should be recreated - nvrecord_rebuild_system_env(&(nvrecord_extension_p->system_info)); - nvrecord_rebuild_paired_bt_dev_info(&(nvrecord_extension_p->bt_pair_info)); - nvrecord_rebuild_paired_ble_dev_info(&(nvrecord_extension_p->ble_pair_info)); - #ifdef GFPS_ENABLED - nvrecord_rebuild_fp_account_key(&(nvrecord_extension_p->fp_account_key_rec)); - #endif - - #ifdef NVREC_BAIDU_DATA_SECTION - nvrecord_rebuild_dma_configuration(&(nvrecord_extension_p->dma_config)); - #endif - - pExtRecInFlash->crc32 = crc32(0, ((uint8_t *)nvrecord_extension_p + NV_EXTENSION_HEADER_SIZE), - NV_EXTENSION_VALID_LEN); - // need to update the content in the flash - nv_record_extension_update(); - - exit: - nv_record_post_write_operation(lock); - + } } -} -NV_EXTENSION_RECORD_T* nv_record_get_extension_entry_ptr(void) -{ - return nvrecord_extension_p; -} - -void nv_record_extension_update(void) -{ - isNvExtentionPendingForUpdate = true; -} - -static void nv_record_extension_flush(bool is_async) -{ - enum NORFLASH_API_RET_T ret; - uint32_t lock; - uint32_t crc; - -#if defined(FLASH_SUSPEND) && defined(NVREC_BURN_TEST) - static uint32_t stime = 0; - if (hal_sys_timer_get() - stime > MS_TO_TICKS(20000)) { - stime = hal_sys_timer_get(); - isNvExtentionPendingForUpdate = true; - } + // the nv extension is invalid, should be recreated + nvrecord_rebuild_system_env(&(nvrecord_extension_p->system_info)); + nvrecord_rebuild_paired_bt_dev_info(&(nvrecord_extension_p->bt_pair_info)); + nvrecord_rebuild_paired_ble_dev_info( + &(nvrecord_extension_p->ble_pair_info)); +#ifdef GFPS_ENABLED + nvrecord_rebuild_fp_account_key( + &(nvrecord_extension_p->fp_account_key_rec)); #endif - if (isNvExtentionPendingForUpdate) - { - if(is_async) - { - lock = int_lock_global(); - if(isNvExtentionState == NV_STATE_IDLE) - { - ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA_EXT, - (uint32_t)(__userdata_start), - NV_EXTENSION_SIZE, - true - ); - if(ret == NORFLASH_API_OK) - { - isNvExtentionState = NV_STATE_ERASED; - TRACE(2,"%s: norflash_api_erase ok,addr = 0x%x.",__func__,(uint32_t)__userdata_start); - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - // do nothing. - } - else - { - ASSERT(0,"%s: norflash_api_erase err,ret = %d,addr = 0x%x.",__func__,ret,(uint32_t)__userdata_start); - } - } - if(isNvExtentionState == NV_STATE_ERASED) - { - uint32_t tmpLock = nv_record_pre_write_operation(); - crc = crc32(0,(uint8_t *)nvrecord_extension_p + NV_EXTENSION_HEADER_SIZE, - NV_EXTENSION_VALID_LEN); - nvrecord_extension_p->header.crc32 = crc; - nv_record_post_write_operation(tmpLock); - ret = norflash_api_write(NORFLASH_API_MODULE_ID_USERDATA_EXT, - (uint32_t)(__userdata_start), - (uint8_t *)nvrecord_extension_p, - NV_EXTENSION_SIZE, - true); - if(ret == NORFLASH_API_OK) - { - isNvExtentionPendingForUpdate = false; - isNvExtentionState = NV_STATE_IDLE; - TRACE(2,"%s: norflash_api_write ok,addr = 0x%x.",__func__,(uint32_t)__userdata_start); - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - // do nothing. - } - else - { - ASSERT(0,"%s: norflash_api_write err,ret = %d,addr = 0x%x.",__func__,ret,(uint32_t)__userdata_start); - } - } - int_unlock_global(lock); - } - else - { - if(isNvExtentionState == NV_STATE_IDLE) - { - do - { - lock = int_lock_global(); - ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA_EXT, - (uint32_t)(__userdata_start), - NV_EXTENSION_SIZE, - false - ); - int_unlock_global(lock); - if(ret == NORFLASH_API_OK) - { - isNvExtentionState = NV_STATE_ERASED; - TRACE(2,"%s: norflash_api_erase ok,addr = 0x%x.",__func__,(uint32_t)__userdata_start); - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - do - { - norflash_api_flush(); - }while(norflash_api_get_free_buffer_count(NORFLASH_API_ERASING) == 0); - } - else - { - ASSERT(0,"%s: norflash_api_erase err,ret = %d,addr = 0x%x.",__func__,ret,(uint32_t)__userdata_start); - } - }while(ret == NORFLASH_API_BUFFER_FULL); - } +#ifdef NVREC_BAIDU_DATA_SECTION + nvrecord_rebuild_dma_configuration(&(nvrecord_extension_p->dma_config)); +#endif - if(isNvExtentionState == NV_STATE_ERASED) - { - do - { - lock = nv_record_pre_write_operation(); - crc = crc32(0,(uint8_t *)nvrecord_extension_p + NV_EXTENSION_HEADER_SIZE, - NV_EXTENSION_VALID_LEN); - nvrecord_extension_p->header.crc32 = crc; - ret = norflash_api_write(NORFLASH_API_MODULE_ID_USERDATA_EXT, - (uint32_t)(__userdata_start), - (uint8_t *)nvrecord_extension_p, - NV_EXTENSION_SIZE, - true); - nv_record_post_write_operation(lock); - if(ret == NORFLASH_API_OK) - { - isNvExtentionPendingForUpdate = false; - isNvExtentionState = NV_STATE_IDLE; - TRACE(2,"%s: norflash_api_write ok,addr = 0x%x.",__func__,(uint32_t)__userdata_start); - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - do - { - norflash_api_flush(); - }while(norflash_api_get_free_buffer_count(NORFLASH_API_WRITTING) == 0); - } - else - { - ASSERT(0,"%s: norflash_api_write err,ret = %d,addr = 0x%x.",__func__,ret,(uint32_t)__userdata_start); - } - }while(ret == NORFLASH_API_BUFFER_FULL); - - do - { - norflash_api_flush(); - }while(norflash_api_get_used_buffer_count(NORFLASH_API_MODULE_ID_USERDATA_EXT,NORFLASH_API_ALL) > 0); - } - } - } -} - -void nv_extension_callback(void* param) -{ - NORFLASH_API_OPERA_RESULT *opera_result; - opera_result = (NORFLASH_API_OPERA_RESULT*)param; - - TRACE(6,"%s:type = %d, addr = 0x%x,len = 0x%x,remain = %d,result = %d.", - __func__, - opera_result->type, - opera_result->addr, - opera_result->len, - opera_result->remain_num, - opera_result->result); -} - -void nv_record_init(void) -{ - nv_record_open(section_usrdata_ddbrecord); - - nv_custom_parameter_section_init(); -} - -bt_status_t nv_record_open(SECTIONS_ADP_ENUM section_id) -{ - nv_record_extension_init(); - return BT_STS_SUCCESS; -} - -void nv_record_update_runtime_userdata(void) -{ + pExtRecInFlash->crc32 = + crc32(0, ((uint8_t *)nvrecord_extension_p + NV_EXTENSION_HEADER_SIZE), + NV_EXTENSION_VALID_LEN); + // need to update the content in the flash nv_record_extension_update(); + + exit: + nv_record_post_write_operation(lock); + } } - -int nv_record_touch_cause_flush(void) -{ - nv_record_update_runtime_userdata(); - return 0; +NV_EXTENSION_RECORD_T *nv_record_get_extension_entry_ptr(void) { + return nvrecord_extension_p; } -void nv_record_sector_clear(void) -{ - uint32_t lock; - enum NORFLASH_API_RET_T ret; +void nv_record_extension_update(void) { isNvExtentionPendingForUpdate = true; } - lock = int_lock_global(); - ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA_EXT, - (uint32_t)__userdata_start, - NV_EXTENSION_SIZE, - false); - nvrecord_extension_p = NULL; - int_unlock_global(lock); - nv_record_update_runtime_userdata(); - ASSERT(ret == NORFLASH_API_OK, - "nv_record_sector_clear: norflash_api_erase failed! ret = %d.",ret); +static void nv_record_extension_flush(bool is_async) { + enum NORFLASH_API_RET_T ret; + uint32_t lock; + uint32_t crc; + +#if defined(FLASH_SUSPEND) && defined(NVREC_BURN_TEST) + static uint32_t stime = 0; + if (hal_sys_timer_get() - stime > MS_TO_TICKS(20000)) { + stime = hal_sys_timer_get(); + isNvExtentionPendingForUpdate = true; + } +#endif + + if (isNvExtentionPendingForUpdate) { + if (is_async) { + lock = int_lock_global(); + if (isNvExtentionState == NV_STATE_IDLE) { + ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA_EXT, + (uint32_t)(__userdata_start), + NV_EXTENSION_SIZE, true); + if (ret == NORFLASH_API_OK) { + isNvExtentionState = NV_STATE_ERASED; + TRACE(2, "%s: norflash_api_erase ok,addr = 0x%x.", __func__, + (uint32_t)__userdata_start); + } else if (ret == NORFLASH_API_BUFFER_FULL) { + // do nothing. + } else { + ASSERT(0, "%s: norflash_api_erase err,ret = %d,addr = 0x%x.", + __func__, ret, (uint32_t)__userdata_start); + } + } + if (isNvExtentionState == NV_STATE_ERASED) { + uint32_t tmpLock = nv_record_pre_write_operation(); + crc = + crc32(0, (uint8_t *)nvrecord_extension_p + NV_EXTENSION_HEADER_SIZE, + NV_EXTENSION_VALID_LEN); + nvrecord_extension_p->header.crc32 = crc; + nv_record_post_write_operation(tmpLock); + ret = norflash_api_write( + NORFLASH_API_MODULE_ID_USERDATA_EXT, (uint32_t)(__userdata_start), + (uint8_t *)nvrecord_extension_p, NV_EXTENSION_SIZE, true); + if (ret == NORFLASH_API_OK) { + isNvExtentionPendingForUpdate = false; + isNvExtentionState = NV_STATE_IDLE; + TRACE(2, "%s: norflash_api_write ok,addr = 0x%x.", __func__, + (uint32_t)__userdata_start); + } else if (ret == NORFLASH_API_BUFFER_FULL) { + // do nothing. + } else { + ASSERT(0, "%s: norflash_api_write err,ret = %d,addr = 0x%x.", + __func__, ret, (uint32_t)__userdata_start); + } + } + int_unlock_global(lock); + } else { + if (isNvExtentionState == NV_STATE_IDLE) { + do { + lock = int_lock_global(); + ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA_EXT, + (uint32_t)(__userdata_start), + NV_EXTENSION_SIZE, false); + int_unlock_global(lock); + if (ret == NORFLASH_API_OK) { + isNvExtentionState = NV_STATE_ERASED; + TRACE(2, "%s: norflash_api_erase ok,addr = 0x%x.", __func__, + (uint32_t)__userdata_start); + } else if (ret == NORFLASH_API_BUFFER_FULL) { + do { + norflash_api_flush(); + } while (norflash_api_get_free_buffer_count(NORFLASH_API_ERASING) == + 0); + } else { + ASSERT(0, "%s: norflash_api_erase err,ret = %d,addr = 0x%x.", + __func__, ret, (uint32_t)__userdata_start); + } + } while (ret == NORFLASH_API_BUFFER_FULL); + } + + if (isNvExtentionState == NV_STATE_ERASED) { + do { + lock = nv_record_pre_write_operation(); + crc = crc32( + 0, (uint8_t *)nvrecord_extension_p + NV_EXTENSION_HEADER_SIZE, + NV_EXTENSION_VALID_LEN); + nvrecord_extension_p->header.crc32 = crc; + ret = norflash_api_write( + NORFLASH_API_MODULE_ID_USERDATA_EXT, (uint32_t)(__userdata_start), + (uint8_t *)nvrecord_extension_p, NV_EXTENSION_SIZE, true); + nv_record_post_write_operation(lock); + if (ret == NORFLASH_API_OK) { + isNvExtentionPendingForUpdate = false; + isNvExtentionState = NV_STATE_IDLE; + TRACE(2, "%s: norflash_api_write ok,addr = 0x%x.", __func__, + (uint32_t)__userdata_start); + } else if (ret == NORFLASH_API_BUFFER_FULL) { + do { + norflash_api_flush(); + } while ( + norflash_api_get_free_buffer_count(NORFLASH_API_WRITTING) == 0); + } else { + ASSERT(0, "%s: norflash_api_write err,ret = %d,addr = 0x%x.", + __func__, ret, (uint32_t)__userdata_start); + } + } while (ret == NORFLASH_API_BUFFER_FULL); + + do { + norflash_api_flush(); + } while (norflash_api_get_used_buffer_count( + NORFLASH_API_MODULE_ID_USERDATA_EXT, NORFLASH_API_ALL) > + 0); + } + } + } } -void nv_record_rebuild(void) -{ - nv_record_sector_clear(); - nv_record_extension_init(); +void nv_extension_callback(void *param) { + NORFLASH_API_OPERA_RESULT *opera_result; + opera_result = (NORFLASH_API_OPERA_RESULT *)param; + + TRACE(6, "%s:type = %d, addr = 0x%x,len = 0x%x,remain = %d,result = %d.", + __func__, opera_result->type, opera_result->addr, opera_result->len, + opera_result->remain_num, opera_result->result); } -void nv_record_flash_flush(void) -{ +void nv_record_init(void) { + nv_record_open(section_usrdata_ddbrecord); + + nv_custom_parameter_section_init(); } -int nv_record_flash_flush_in_sleep(void) -{ - nv_record_extension_flush(true); - return 0; +bt_status_t nv_record_open(SECTIONS_ADP_ENUM section_id) { + nv_record_extension_init(); + return BT_STS_SUCCESS; +} + +void nv_record_update_runtime_userdata(void) { nv_record_extension_update(); } + +int nv_record_touch_cause_flush(void) { + nv_record_update_runtime_userdata(); + return 0; +} + +void nv_record_sector_clear(void) { + uint32_t lock; + enum NORFLASH_API_RET_T ret; + + lock = int_lock_global(); + ret = + norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA_EXT, + (uint32_t)__userdata_start, NV_EXTENSION_SIZE, false); + nvrecord_extension_p = NULL; + int_unlock_global(lock); + nv_record_update_runtime_userdata(); + ASSERT(ret == NORFLASH_API_OK, + "nv_record_sector_clear: norflash_api_erase failed! ret = %d.", ret); +} + +void nv_record_rebuild(void) { + nv_record_sector_clear(); + nv_record_extension_init(); +} + +void nv_record_flash_flush(void) {} + +int nv_record_flash_flush_in_sleep(void) { + nv_record_extension_flush(true); + return 0; } #if defined(OTA_ENABLED) void nv_record_extension_update_gsound_ota_session(uint8_t gsoundOtaStatus, uint32_t totalImageSize, - const char *session) -{ - NV_EXTENSION_RECORD_T* pNvExtRec = nv_record_get_extension_entry_ptr(); - TRACE(2,"gsound ota status is %d, is start is %d", - pNvExtRec->gsound_info.gsoundOtaStatus, - gsoundOtaStatus); + const char *session) { + NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); + TRACE(2, "gsound ota status is %d, is start is %d", + pNvExtRec->gsound_info.gsoundOtaStatus, gsoundOtaStatus); - if (pNvExtRec->gsound_info.gsoundOtaStatus != gsoundOtaStatus) - { - if (GSOUND_OTA_STATUS_NONE == gsoundOtaStatus) - { - pNvExtRec->gsound_info.gsoundOtaOffset = 0; - memset(pNvExtRec->gsound_info.gsoundOtaSessionString, - 0, - sizeof(pNvExtRec->gsound_info.gsoundOtaSessionString)); - } - else if (GSOUND_OTA_STAGE_ONGOING == gsoundOtaStatus) - { - ASSERT(totalImageSize, "Received total image size is 0."); - ASSERT(session, "Received session pointer is NULL."); - pNvExtRec->gsound_info.gsoundOtaImageSize = totalImageSize; - memcpy(pNvExtRec->gsound_info.gsoundOtaSessionString, session, strlen(session)+1); - } - else if (GSOUND_OTA_STATUS_COMPLETE == gsoundOtaStatus) - { - ASSERT(GSOUND_OTA_STAGE_ONGOING == pNvExtRec->gsound_info.gsoundOtaStatus, - "Wrong status transmission."); - ASSERT(totalImageSize == pNvExtRec->gsound_info.gsoundOtaImageSize, - "total image size changed."); + if (pNvExtRec->gsound_info.gsoundOtaStatus != gsoundOtaStatus) { + if (GSOUND_OTA_STATUS_NONE == gsoundOtaStatus) { + pNvExtRec->gsound_info.gsoundOtaOffset = 0; + memset(pNvExtRec->gsound_info.gsoundOtaSessionString, 0, + sizeof(pNvExtRec->gsound_info.gsoundOtaSessionString)); + } else if (GSOUND_OTA_STAGE_ONGOING == gsoundOtaStatus) { + ASSERT(totalImageSize, "Received total image size is 0."); + ASSERT(session, "Received session pointer is NULL."); + pNvExtRec->gsound_info.gsoundOtaImageSize = totalImageSize; + memcpy(pNvExtRec->gsound_info.gsoundOtaSessionString, session, + strlen(session) + 1); + } else if (GSOUND_OTA_STATUS_COMPLETE == gsoundOtaStatus) { + ASSERT(GSOUND_OTA_STAGE_ONGOING == pNvExtRec->gsound_info.gsoundOtaStatus, + "Wrong status transmission."); + ASSERT(totalImageSize == pNvExtRec->gsound_info.gsoundOtaImageSize, + "total image size changed."); - pNvExtRec->gsound_info.gsoundOtaOffset = totalImageSize; - } - - pNvExtRec->gsound_info.gsoundOtaStatus = gsoundOtaStatus; - - TRACE(1,"update gsound ota status to %d", pNvExtRec->gsound_info.gsoundOtaStatus); - nv_record_extension_update(); - nv_record_flash_flush(); + pNvExtRec->gsound_info.gsoundOtaOffset = totalImageSize; } + + pNvExtRec->gsound_info.gsoundOtaStatus = gsoundOtaStatus; + + TRACE(1, "update gsound ota status to %d", + pNvExtRec->gsound_info.gsoundOtaStatus); + nv_record_extension_update(); + nv_record_flash_flush(); + } } -void nv_record_extension_update_gsound_ota_progress(uint32_t otaOffset) -{ - NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); - if ((GSOUND_OTA_STAGE_ONGOING == pNvExtRec->gsound_info.gsoundOtaStatus) && - (otaOffset <= pNvExtRec->gsound_info.gsoundOtaImageSize)) - { - pNvExtRec->gsound_info.gsoundOtaOffset = otaOffset; - nv_record_extension_update(); - nv_record_flash_flush(); - } +void nv_record_extension_update_gsound_ota_progress(uint32_t otaOffset) { + NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); + if ((GSOUND_OTA_STAGE_ONGOING == pNvExtRec->gsound_info.gsoundOtaStatus) && + (otaOffset <= pNvExtRec->gsound_info.gsoundOtaImageSize)) { + pNvExtRec->gsound_info.gsoundOtaOffset = otaOffset; + nv_record_extension_update(); + nv_record_flash_flush(); + } } #endif #endif // #if defined(NEW_NV_RECORD_ENABLED) diff --git a/services/nv_section/log_section/coredump_section.c b/services/nv_section/log_section/coredump_section.c index 0dfda81..c862dc5 100644 --- a/services/nv_section/log_section/coredump_section.c +++ b/services/nv_section/log_section/coredump_section.c @@ -18,181 +18,155 @@ #include "cmsis.h" #include "coredump_section.h" +#include "hal_norflash.h" #include "hal_timer.h" #include "hal_trace.h" -#include "hal_norflash.h" #include "norflash_api.h" /* Usage: -arm-none-eabi-gdb elf_file -ex "target remote | ./tools/bins/lin64/CrashDebug --elf elf_file --dump coredump.dat" +arm-none-eabi-gdb elf_file -ex "target remote | ./tools/bins/lin64/CrashDebug +--elf elf_file --dump coredump.dat" */ extern uint32_t __coredump_section_start; extern uint32_t __coredump_section_end; -static const uint32_t coredump_flash_start_addr = (uint32_t)&__coredump_section_start; -static const uint32_t coredump_flash_end_addr = (uint32_t)&__coredump_section_end; -static uint32_t coredump_flash_addr_offset = (uint32_t)&__coredump_section_start; +static const uint32_t coredump_flash_start_addr = + (uint32_t)&__coredump_section_start; +static const uint32_t coredump_flash_end_addr = + (uint32_t)&__coredump_section_end; +static uint32_t coredump_flash_addr_offset = + (uint32_t)&__coredump_section_start; -void coredump_to_flash_init() -{ - uint32_t block_size = 0; - uint32_t sector_size = 0; - uint32_t page_size = 0; - uint32_t buffer_len = 0; - enum NORFLASH_API_RET_T result; +void coredump_to_flash_init() { + uint32_t block_size = 0; + uint32_t sector_size = 0; + uint32_t page_size = 0; + uint32_t buffer_len = 0; + enum NORFLASH_API_RET_T result; - hal_norflash_get_size(HAL_NORFLASH_ID_0,NULL, &block_size, §or_size, &page_size); - buffer_len = COREDUMP_SECTOR_SIZE; - TRACE(4,"%s: coredump_flash_start_addr = 0x%x, coredump_flash_end_addr = 0x%x, buff_len = 0x%x.", - __func__, - coredump_flash_start_addr, - coredump_flash_end_addr, - buffer_len); + hal_norflash_get_size(HAL_NORFLASH_ID_0, NULL, &block_size, §or_size, + &page_size); + buffer_len = COREDUMP_SECTOR_SIZE; + TRACE(4, + "%s: coredump_flash_start_addr = 0x%x, coredump_flash_end_addr = 0x%x, " + "buff_len = 0x%x.", + __func__, coredump_flash_start_addr, coredump_flash_end_addr, + buffer_len); - result = norflash_api_register( - NORFLASH_API_MODULE_ID_COREDUMP, - HAL_NORFLASH_ID_0, - coredump_flash_start_addr, - coredump_flash_end_addr - coredump_flash_start_addr, - block_size, - sector_size, - page_size, - buffer_len, - NULL - ); + result = norflash_api_register( + NORFLASH_API_MODULE_ID_COREDUMP, HAL_NORFLASH_ID_0, + coredump_flash_start_addr, + coredump_flash_end_addr - coredump_flash_start_addr, block_size, + sector_size, page_size, buffer_len, NULL); - if(result == NORFLASH_API_OK) - { - TRACE(0,"coredump_to_flash_init ok."); + if (result == NORFLASH_API_OK) { + TRACE(0, "coredump_to_flash_init ok."); + } else { + TRACE(1, "coredump_to_flash_init failed,result = %d.", result); + } +} + +void core_dump_erase_section() { + // erase whole core dump section + enum NORFLASH_API_RET_T ret = 0; + uint32_t lock; + do { + lock = int_lock_global(); + ret = norflash_api_erase(NORFLASH_API_MODULE_ID_COREDUMP, + coredump_flash_addr_offset, COREDUMP_SECTOR_SIZE, + false); + int_unlock_global(lock); + if (ret != NORFLASH_API_OK) { + TRACE(3, "%s:offset = 0x%x,ret = %d.", __func__, + coredump_flash_addr_offset, ret); } - else - { - TRACE(1,"coredump_to_flash_init failed,result = %d.",result); + coredump_flash_addr_offset += COREDUMP_SECTOR_SIZE; + if (coredump_flash_addr_offset == coredump_flash_end_addr) { + coredump_flash_addr_offset = coredump_flash_start_addr; + break; } + } while (1); } -void core_dump_erase_section() -{ - //erase whole core dump section - enum NORFLASH_API_RET_T ret = 0; - uint32_t lock; - do - { - lock = int_lock_global(); - ret = norflash_api_erase(NORFLASH_API_MODULE_ID_COREDUMP, coredump_flash_addr_offset, - COREDUMP_SECTOR_SIZE, false); - int_unlock_global(lock); - if(ret != NORFLASH_API_OK) - { - TRACE(3,"%s:offset = 0x%x,ret = %d.", - __func__,coredump_flash_addr_offset,ret); - } - coredump_flash_addr_offset += COREDUMP_SECTOR_SIZE; - if (coredump_flash_addr_offset == coredump_flash_end_addr) - { - coredump_flash_addr_offset = coredump_flash_start_addr; - break; - } - } while (1); -} - -int32_t core_dump_write_large(const uint8_t* ptr,uint32_t len) -{ - enum NORFLASH_API_RET_T ret; - uint32_t write_len; - uint32_t remain_len = len; - uint32_t lock; - //TRACE(4,"%s offset = 0x%x ptr = 0x%x len=0x%x",__func__, coredump_flash_addr_offset, ptr, len); - do - { - if (coredump_flash_addr_offset % COREDUMP_SECTOR_SIZE != 0) - { - write_len = COREDUMP_SECTOR_SIZE - (coredump_flash_addr_offset - (coredump_flash_addr_offset & ~COREDUMP_SECTOR_SIZE_MASK)); - lock = int_lock_global(); - ret = norflash_api_write(NORFLASH_API_MODULE_ID_COREDUMP, - coredump_flash_addr_offset, - ptr, - write_len, - false); - int_unlock_global(lock); - if(ret != NORFLASH_API_OK) - { - TRACE(4,"%s: addr = 0x%x,write_len = 0x%x,ret = %d.", - __func__,coredump_flash_addr_offset,write_len,ret); - return (int32_t)ret; - } - coredump_flash_addr_offset += write_len; - ptr += write_len; - remain_len -= write_len; - } - - if (remain_len < COREDUMP_SECTOR_SIZE) - { - lock = int_lock_global(); - ret = norflash_api_write(NORFLASH_API_MODULE_ID_COREDUMP, - coredump_flash_addr_offset, - ptr, - remain_len, - false); - int_unlock_global(lock); - if(ret != NORFLASH_API_OK) - { - TRACE(4,"%s: addr = 0x%x,remain_len = 0x%x,ret = %d.", - __func__,coredump_flash_addr_offset,remain_len,ret); - return (int32_t)ret; - } - coredump_flash_addr_offset += remain_len; - ptr += remain_len; - remain_len = 0; - } - else - { - lock = int_lock_global(); - ret = norflash_api_write(NORFLASH_API_MODULE_ID_COREDUMP, - coredump_flash_addr_offset, - ptr, - COREDUMP_SECTOR_SIZE, - false); - int_unlock_global(lock); - if(ret != NORFLASH_API_OK) - { - TRACE(3,"%s: addr = 0x%x,ret = %d.", - __func__,coredump_flash_addr_offset,ret); - return (int32_t)ret; - } - coredump_flash_addr_offset += COREDUMP_SECTOR_SIZE; - ptr += COREDUMP_SECTOR_SIZE; - remain_len -= COREDUMP_SECTOR_SIZE; - } - } while (remain_len > 0); - //TRACE(3,"%s offset = 0x%x ptr = 0x%x",__func__, coredump_flash_addr_offset, ptr); - return 0; -} - -int32_t core_dump_write(const uint8_t* ptr,uint32_t len) -{ - enum NORFLASH_API_RET_T ret; - uint32_t i; - uint32_t lock; - //TRACE(2,"%s: len = 0x%x", __func__,len); - //write by byte to avoid cross flash sector boundary - for (i = 0; i < len; i++) - { - lock = int_lock_global(); - ret = norflash_api_write(NORFLASH_API_MODULE_ID_COREDUMP, - coredump_flash_addr_offset++, - ptr++, - 1, - false); - int_unlock_global(lock); - if(ret != NORFLASH_API_OK) - { - TRACE(4,"%s: offset = 0x%x ret = %d ch =%02x", - __func__,coredump_flash_addr_offset,ret,*(ptr-1)); - } +int32_t core_dump_write_large(const uint8_t *ptr, uint32_t len) { + enum NORFLASH_API_RET_T ret; + uint32_t write_len; + uint32_t remain_len = len; + uint32_t lock; + // TRACE(4,"%s offset = 0x%x ptr = 0x%x len=0x%x",__func__, + // coredump_flash_addr_offset, ptr, len); + do { + if (coredump_flash_addr_offset % COREDUMP_SECTOR_SIZE != 0) { + write_len = COREDUMP_SECTOR_SIZE - + (coredump_flash_addr_offset - + (coredump_flash_addr_offset & ~COREDUMP_SECTOR_SIZE_MASK)); + lock = int_lock_global(); + ret = + norflash_api_write(NORFLASH_API_MODULE_ID_COREDUMP, + coredump_flash_addr_offset, ptr, write_len, false); + int_unlock_global(lock); + if (ret != NORFLASH_API_OK) { + TRACE(4, "%s: addr = 0x%x,write_len = 0x%x,ret = %d.", __func__, + coredump_flash_addr_offset, write_len, ret); + return (int32_t)ret; + } + coredump_flash_addr_offset += write_len; + ptr += write_len; + remain_len -= write_len; } - return 0; + + if (remain_len < COREDUMP_SECTOR_SIZE) { + lock = int_lock_global(); + ret = norflash_api_write(NORFLASH_API_MODULE_ID_COREDUMP, + coredump_flash_addr_offset, ptr, remain_len, + false); + int_unlock_global(lock); + if (ret != NORFLASH_API_OK) { + TRACE(4, "%s: addr = 0x%x,remain_len = 0x%x,ret = %d.", __func__, + coredump_flash_addr_offset, remain_len, ret); + return (int32_t)ret; + } + coredump_flash_addr_offset += remain_len; + ptr += remain_len; + remain_len = 0; + } else { + lock = int_lock_global(); + ret = norflash_api_write(NORFLASH_API_MODULE_ID_COREDUMP, + coredump_flash_addr_offset, ptr, + COREDUMP_SECTOR_SIZE, false); + int_unlock_global(lock); + if (ret != NORFLASH_API_OK) { + TRACE(3, "%s: addr = 0x%x,ret = %d.", __func__, + coredump_flash_addr_offset, ret); + return (int32_t)ret; + } + coredump_flash_addr_offset += COREDUMP_SECTOR_SIZE; + ptr += COREDUMP_SECTOR_SIZE; + remain_len -= COREDUMP_SECTOR_SIZE; + } + } while (remain_len > 0); + // TRACE(3,"%s offset = 0x%x ptr = 0x%x",__func__, coredump_flash_addr_offset, + // ptr); + return 0; } +int32_t core_dump_write(const uint8_t *ptr, uint32_t len) { + enum NORFLASH_API_RET_T ret; + uint32_t i; + uint32_t lock; + // TRACE(2,"%s: len = 0x%x", __func__,len); + // write by byte to avoid cross flash sector boundary + for (i = 0; i < len; i++) { + lock = int_lock_global(); + ret = norflash_api_write(NORFLASH_API_MODULE_ID_COREDUMP, + coredump_flash_addr_offset++, ptr++, 1, false); + int_unlock_global(lock); + if (ret != NORFLASH_API_OK) { + TRACE(4, "%s: offset = 0x%x ret = %d ch =%02x", __func__, + coredump_flash_addr_offset, ret, *(ptr - 1)); + } + } + return 0; +} diff --git a/services/nv_section/log_section/crash_dump_section.c b/services/nv_section/log_section/crash_dump_section.c index c3de28a..cfee03b 100644 --- a/services/nv_section/log_section/crash_dump_section.c +++ b/services/nv_section/log_section/crash_dump_section.c @@ -14,15 +14,15 @@ * ****************************************************************************/ #if 0 -#include "cmsis.h" #include "crash_dump_section.h" +#include "cmsis.h" #if defined(CRASH_DUMP_SECTION_SIZE) && (CRASH_DUMP_SECTION_SIZE > 0) #include "hal_bootmode.h" #include "hal_norflash.h" -#include "hal_trace.h" #include "hal_timer.h" +#include "hal_trace.h" #include "heap_api.h" #include "pmu.h" #include "stdio.h" @@ -33,17 +33,19 @@ extern uint32_t __crash_dump_end[]; extern const char sys_build_info[]; -#define DUMPED_MSP_BYTES 32 -#define DUMPED_PSP_BYTES 32 +#define DUMPED_MSP_BYTES 32 +#define DUMPED_PSP_BYTES 32 // #undef CRASH_DUMP_SECTION_SIZE -#define CRASH_DUMP_FRAME_NUM (((uint32_t)__crash_dump_end - (uint32_t)__crash_dump_start)/CRASH_DUMP_FRAME_SIZE) +#define CRASH_DUMP_FRAME_NUM \ + (((uint32_t)__crash_dump_end - (uint32_t)__crash_dump_start) / \ + CRASH_DUMP_FRAME_SIZE) #ifdef TRACE_CRLF -#define NEW_LINE_STR "\r\n" +#define NEW_LINE_STR "\r\n" #else -#define NEW_LINE_STR "\n" +#define NEW_LINE_STR "\n" #endif static struct CRASH_OUTPUT_BUF_T *crash_dump_section_p = NULL; @@ -293,25 +295,25 @@ void crashdump_init_section_info(void) #endif } #else +#include "cmsis.h" +#include "crash_dump_section.h" +#include "hal_cache.h" +#include "hal_norflash.h" +#include "hal_sleep.h" +#include "hal_timer.h" +#include "heap_api.h" +#include "norflash_api.h" +#include "pmu.h" #include #include -#include "crash_dump_section.h" -#include -#include "hal_timer.h" -#include "hal_norflash.h" -#include "norflash_api.h" -#include "cmsis.h" -#include "hal_cache.h" -#include "hal_sleep.h" -#include "pmu.h" -#include "heap_api.h" extern uint32_t __crash_dump_start; extern uint32_t __crash_dump_end; extern void syspool_init_specific_size(uint32_t size); -static const uint32_t crash_dump_flash_start_addr = (uint32_t)&__crash_dump_start; -static const uint32_t crash_dump_flash_end_addr = (uint32_t)&__crash_dump_end; +static const uint32_t crash_dump_flash_start_addr = + (uint32_t)&__crash_dump_start; +static const uint32_t crash_dump_flash_end_addr = (uint32_t)&__crash_dump_end; static uint32_t crash_dump_flash_len; static CRASH_DATA_BUFFER crash_data_buffer; static uint32_t crash_dump_w_seqnum = 0; @@ -324,341 +326,289 @@ static uint32_t crash_dump_type; HAL_TRACE_APP_NOTIFY_T crash_dump_notify_cb = NULL; HAL_TRACE_APP_OUTPUT_T crash_dump_output_cb = NULL; HAL_TRACE_APP_OUTPUT_T crash_dump_fault_cb = NULL; -static enum NORFLASH_API_RET_T _flash_api_read(uint32_t addr, uint8_t* buffer, uint32_t len) -{ +static enum NORFLASH_API_RET_T _flash_api_read(uint32_t addr, uint8_t *buffer, + uint32_t len) { - return norflash_sync_read(NORFLASH_API_MODULE_ID_CRASH_DUMP, - addr, - buffer, - len); + return norflash_sync_read(NORFLASH_API_MODULE_ID_CRASH_DUMP, addr, buffer, + len); } +static int32_t _crash_dump_get_seqnum(uint32_t *dump_seqnum, + uint32_t *sector_seqnum) { + uint32_t i; + uint32_t count; + static enum NORFLASH_API_RET_T result; + CRASH_DUMP_HEADER_T crash_dump_header; + uint32_t max_dump_seqnum = 0; + uint32_t max_sector_seqnum = 0; + bool is_existed = false; -static int32_t _crash_dump_get_seqnum(uint32_t * dump_seqnum, uint32_t *sector_seqnum) -{ - uint32_t i; - uint32_t count; - static enum NORFLASH_API_RET_T result; - CRASH_DUMP_HEADER_T crash_dump_header; - uint32_t max_dump_seqnum = 0; - uint32_t max_sector_seqnum = 0; - bool is_existed = false; - - count = (crash_dump_flash_end_addr-crash_dump_flash_start_addr)/CRASH_DUMP_BUFFER_LEN; - for(i = 0; i < count; i++) - { - result = _flash_api_read( - crash_dump_flash_start_addr + i*CRASH_DUMP_BUFFER_LEN, - (uint8_t*)&crash_dump_header, - sizeof(CRASH_DUMP_HEADER_T)); - if(result == NORFLASH_API_OK) - { - if(crash_dump_header.magic == CRASH_DUMP_MAGIC_CODE - && crash_dump_header.version == CRASH_DUMP_VERSION - ) - { - is_existed = true; - if(crash_dump_header.seqnum > max_dump_seqnum) - { - max_dump_seqnum = crash_dump_header.seqnum; - max_sector_seqnum = i; - } - } - } - else - { - ASSERT(0,"_crash_dump_get_seqnum: _flash_api_read failed!result = %d.",result); + count = (crash_dump_flash_end_addr - crash_dump_flash_start_addr) / + CRASH_DUMP_BUFFER_LEN; + for (i = 0; i < count; i++) { + result = _flash_api_read( + crash_dump_flash_start_addr + i * CRASH_DUMP_BUFFER_LEN, + (uint8_t *)&crash_dump_header, sizeof(CRASH_DUMP_HEADER_T)); + if (result == NORFLASH_API_OK) { + if (crash_dump_header.magic == CRASH_DUMP_MAGIC_CODE && + crash_dump_header.version == CRASH_DUMP_VERSION) { + is_existed = true; + if (crash_dump_header.seqnum > max_dump_seqnum) { + max_dump_seqnum = crash_dump_header.seqnum; + max_sector_seqnum = i; } + } + } else { + ASSERT(0, "_crash_dump_get_seqnum: _flash_api_read failed!result = %d.", + result); } - if(is_existed) - { - *dump_seqnum = max_dump_seqnum + 1; - *sector_seqnum = max_sector_seqnum + 1 >= count ? 0: max_sector_seqnum + 1; - } - else - { - *dump_seqnum = 0; - *sector_seqnum = 0; - } - return 0; + } + if (is_existed) { + *dump_seqnum = max_dump_seqnum + 1; + *sector_seqnum = max_sector_seqnum + 1 >= count ? 0 : max_sector_seqnum + 1; + } else { + *dump_seqnum = 0; + *sector_seqnum = 0; + } + return 0; } -static void _crash_dump_notify(enum HAL_TRACE_STATE_T state) -{ - uint32_t lock; - CRASH_DATA_BUFFER *data_buff = NULL; +static void _crash_dump_notify(enum HAL_TRACE_STATE_T state) { + uint32_t lock; + CRASH_DATA_BUFFER *data_buff = NULL; - if(!crash_dump_is_init) - { - return; - } - if(state == HAL_TRACE_STATE_CRASH_ASSERT_START) - { - crash_dump_type = CRASH_DUMP_ASSERT_CODE; - } - else if(state == HAL_TRACE_STATE_CRASH_FAULT_START) - { - crash_dump_type = CRASH_DUMP_EXCEPTION_CODE; - } - CRASH_DUMP_TRACE(2,"__CRASH_DUMP:%s: state = %d.",__func__,state); - CRASH_DUMP_TRACE(3,"__CRASH_DUMP:%s: start_addr = 0x%x,end_addr = 0x%x.", - __func__,crash_dump_flash_start_addr,crash_dump_flash_end_addr); - CRASH_DUMP_TRACE(3,"__CRASH_DUMP:%s: dump_seqnum = 0x%x,flash_offset = 0x%x.", - __func__,crash_dump_cur_dump_seqnum,crash_dump_flash_offs); - - if(HAL_TRACE_STATE_CRASH_END == state) - { - lock = int_lock_global(); - data_buff = &crash_data_buffer; - crash_dump_write(crash_dump_flash_start_addr + crash_dump_flash_offs, - data_buff->buffer,data_buff->offset); - int_unlock_global(lock); - } -} - -static void _crash_dump_output(const unsigned char *buf, unsigned int buf_len) -{ - //uint32_t len,len1; - uint32_t uint_len; - uint32_t written_len; - uint32_t remain_len; - CRASH_DUMP_HEADER_T log_header; - CRASH_DATA_BUFFER *data_buff = NULL; - - if(!crash_dump_is_init) - { - return; - } - - if(strstr((char*)buf,CRASH_DUMP_PREFIX) != NULL) - { - return; - } + if (!crash_dump_is_init) { + return; + } + if (state == HAL_TRACE_STATE_CRASH_ASSERT_START) { + crash_dump_type = CRASH_DUMP_ASSERT_CODE; + } else if (state == HAL_TRACE_STATE_CRASH_FAULT_START) { + crash_dump_type = CRASH_DUMP_EXCEPTION_CODE; + } + CRASH_DUMP_TRACE(2, "__CRASH_DUMP:%s: state = %d.", __func__, state); + CRASH_DUMP_TRACE(3, "__CRASH_DUMP:%s: start_addr = 0x%x,end_addr = 0x%x.", + __func__, crash_dump_flash_start_addr, + crash_dump_flash_end_addr); + CRASH_DUMP_TRACE(3, + "__CRASH_DUMP:%s: dump_seqnum = 0x%x,flash_offset = 0x%x.", + __func__, crash_dump_cur_dump_seqnum, crash_dump_flash_offs); + if (HAL_TRACE_STATE_CRASH_END == state) { + lock = int_lock_global(); data_buff = &crash_data_buffer; - remain_len = buf_len; - written_len = 0; - do{ - if(data_buff->offset == 0) - { - CRASH_DUMP_TRACE(4,"__CRASH_DUMP:%s:%d offset = 0.w_seqnum = %d,dump_seqnum = %d.", - __func__,__LINE__,crash_dump_w_seqnum,crash_dump_cur_dump_seqnum); - memset((uint8_t*)&log_header,0,sizeof(log_header)); - log_header.magic = CRASH_DUMP_MAGIC_CODE; - log_header.version = CRASH_DUMP_VERSION; - log_header.seqnum = crash_dump_cur_dump_seqnum; - log_header.reseved[0] = '\0'; - log_header.reseved[1] = '\0'; - log_header.reseved[2] = '\0'; - log_header.reseved[3] = '\n'; - memcpy(data_buff->buffer + data_buff->offset, - (uint8_t*)&log_header, - sizeof(log_header)); - - data_buff->offset += sizeof(log_header); - crash_dump_cur_dump_seqnum ++; - } - - if(data_buff->offset + remain_len > CRASH_DUMP_SECTOR_SIZE) - { - uint_len = (CRASH_DUMP_SECTOR_SIZE - data_buff->offset); - } - else - { - uint_len = remain_len; - } - if(uint_len > 0) - { - memcpy(data_buff->buffer + data_buff->offset, - buf + written_len, - uint_len); - data_buff->offset += uint_len; - written_len += uint_len; - crash_dump_total_len += uint_len; - } - - if(data_buff->offset == CRASH_DUMP_SECTOR_SIZE) - { - crash_dump_write(crash_dump_flash_start_addr + crash_dump_flash_offs, - data_buff->buffer,data_buff->offset); - - crash_dump_flash_offs = crash_dump_flash_offs + data_buff->offset >= crash_dump_flash_len ?\ - 0 : crash_dump_flash_offs + data_buff->offset; - data_buff->offset = 0; - } - remain_len -= uint_len; - }while(remain_len > 0); + crash_dump_write(crash_dump_flash_start_addr + crash_dump_flash_offs, + data_buff->buffer, data_buff->offset); + int_unlock_global(lock); + } } -static void _crash_dump_fault(const unsigned char *buf, unsigned int buf_len) -{ - _crash_dump_output(buf,buf_len); -} +static void _crash_dump_output(const unsigned char *buf, unsigned int buf_len) { + // uint32_t len,len1; + uint32_t uint_len; + uint32_t written_len; + uint32_t remain_len; + CRASH_DUMP_HEADER_T log_header; + CRASH_DATA_BUFFER *data_buff = NULL; -void crash_dump_init(void) -{ - uint32_t block_size = 0; - uint32_t sector_size = 0; - uint32_t page_size = 0; - uint32_t buffer_len = 0; - uint32_t dump_seqnum = 0; - uint32_t sector_seqnum = 0; - enum NORFLASH_API_RET_T result; + if (!crash_dump_is_init) { + return; + } - hal_norflash_get_size(HAL_NORFLASH_ID_0,NULL, &block_size, §or_size, &page_size); - buffer_len = CRASH_DUMP_NORFALSH_BUFFER_LEN; - CRASH_DUMP_TRACE(4,"__CRASH_DUMP:%s: crash_dump_start = 0x%x, crash_dump_end = 0x%x, buff_len = 0x%x.", - __func__, - crash_dump_flash_start_addr, - crash_dump_flash_end_addr, - buffer_len); + if (strstr((char *)buf, CRASH_DUMP_PREFIX) != NULL) { + return; + } - result = norflash_api_register( - NORFLASH_API_MODULE_ID_CRASH_DUMP, - HAL_NORFLASH_ID_0, - crash_dump_flash_start_addr, - crash_dump_flash_end_addr - crash_dump_flash_start_addr, - block_size, - sector_size, - page_size, - buffer_len, - NULL - ); + data_buff = &crash_data_buffer; + remain_len = buf_len; + written_len = 0; + do { + if (data_buff->offset == 0) { + CRASH_DUMP_TRACE( + 4, "__CRASH_DUMP:%s:%d offset = 0.w_seqnum = %d,dump_seqnum = %d.", + __func__, __LINE__, crash_dump_w_seqnum, crash_dump_cur_dump_seqnum); + memset((uint8_t *)&log_header, 0, sizeof(log_header)); + log_header.magic = CRASH_DUMP_MAGIC_CODE; + log_header.version = CRASH_DUMP_VERSION; + log_header.seqnum = crash_dump_cur_dump_seqnum; + log_header.reseved[0] = '\0'; + log_header.reseved[1] = '\0'; + log_header.reseved[2] = '\0'; + log_header.reseved[3] = '\n'; + memcpy(data_buff->buffer + data_buff->offset, (uint8_t *)&log_header, + sizeof(log_header)); - if(result == NORFLASH_API_OK) - { - CRASH_DUMP_TRACE(1,"__CRASH_DUMP:%s: norflash_api_register ok.", __func__); - } - else - { - CRASH_DUMP_TRACE(2,"__CRASH_DUMP:%s: norflash_api_register failed,result = %d", __func__, result); - return; + data_buff->offset += sizeof(log_header); + crash_dump_cur_dump_seqnum++; } - crash_dump_notify_cb = _crash_dump_notify; - crash_dump_output_cb = _crash_dump_output; - crash_dump_fault_cb = _crash_dump_fault; - - hal_trace_app_custom_register(crash_dump_notify_handler,crash_dump_output_handler,crash_dump_fault_handler); - _crash_dump_get_seqnum(&dump_seqnum,§or_seqnum); - crash_dump_cur_dump_seqnum = dump_seqnum; - crash_dump_flash_len = crash_dump_flash_end_addr - crash_dump_flash_start_addr; - crash_dump_flash_offs = sector_seqnum*CRASH_DUMP_BUFFER_LEN; - crash_data_buffer.offset = 0; - crash_data_buffer.buffer = NULL; - crash_dump_w_seqnum = 0; - crash_dump_total_len = 0; - crash_dump_is_init = true; -} - -void crash_dump_init_buffer(void) -{ - crash_data_buffer.offset = 0; - syspool_init_specific_size(CRASH_DUMP_BUFFER_LEN); - syspool_get_buff(&(crash_data_buffer.buffer), CRASH_DUMP_BUFFER_LEN); -} - -int32_t crash_dump_read(uint32_t addr,uint8_t* ptr,uint32_t len) -{ - enum NORFLASH_API_RET_T ret; - - ret = norflash_sync_read(NORFLASH_API_MODULE_ID_CRASH_DUMP, - addr, - ptr, - len); - if(ret != NORFLASH_API_OK) - { - CRASH_DUMP_TRACE(4,"__CRASH_DUMP:%s: norflash_sync_read,addr = 0x%x,len = 0x%x,ret = %d.", - __func__,addr,len,ret); - return ret; + if (data_buff->offset + remain_len > CRASH_DUMP_SECTOR_SIZE) { + uint_len = (CRASH_DUMP_SECTOR_SIZE - data_buff->offset); + } else { + uint_len = remain_len; } - return 0; -} - -int32_t crash_dump_write(uint32_t addr,uint8_t* ptr,uint32_t len) -{ - enum NORFLASH_API_RET_T ret; - - if(CRASH_LOG_ALIGN(addr,CRASH_DUMP_SECTOR_SIZE) != addr) - { - CRASH_DUMP_TRACE(2,"__CRASH_DUMP:%s: addr not aligned! addr = 0x%x.",__func__,addr); - return (int32_t)NORFLASH_API_BAD_ADDR; - } - ret = norflash_api_erase(NORFLASH_API_MODULE_ID_CRASH_DUMP, - addr, - CRASH_DUMP_SECTOR_SIZE, - false); - if(ret != NORFLASH_API_OK) - { - CRASH_DUMP_TRACE(3,"__CRASH_DUMP:%s: norflash_api_erase failed! addr = 0x%x,ret = %d.", - __func__,addr,ret); - return (int32_t)ret; - } - ret = norflash_api_write(NORFLASH_API_MODULE_ID_CRASH_DUMP, - addr, - ptr, - len, - false); - if(ret != NORFLASH_API_OK) - { - CRASH_DUMP_TRACE(4,"__CRASH_DUMP:%s: norflash_api_write,addr = 0x%x,len = 0x%x,ret = %d.", - __func__,addr,len,ret); - return (int32_t)ret; - } - return 0; -} - -void crash_dump_notify_handler(enum HAL_TRACE_STATE_T state) -{ - if ((state == HAL_TRACE_STATE_CRASH_ASSERT_START) - || (state == HAL_TRACE_STATE_CRASH_FAULT_START)) { - norflash_api_flush_enable_all(); - crash_dump_init_buffer(); + if (uint_len > 0) { + memcpy(data_buff->buffer + data_buff->offset, buf + written_len, + uint_len); + data_buff->offset += uint_len; + written_len += uint_len; + crash_dump_total_len += uint_len; } - if(crash_dump_notify_cb) - { - crash_dump_notify_cb(state); + if (data_buff->offset == CRASH_DUMP_SECTOR_SIZE) { + crash_dump_write(crash_dump_flash_start_addr + crash_dump_flash_offs, + data_buff->buffer, data_buff->offset); + + crash_dump_flash_offs = + crash_dump_flash_offs + data_buff->offset >= crash_dump_flash_len + ? 0 + : crash_dump_flash_offs + data_buff->offset; + data_buff->offset = 0; } + remain_len -= uint_len; + } while (remain_len > 0); } -void crash_dump_output_handler(const unsigned char *buf, unsigned int buf_len) -{ - if(crash_dump_output_cb) - { - crash_dump_output_cb(buf,buf_len); - } +static void _crash_dump_fault(const unsigned char *buf, unsigned int buf_len) { + _crash_dump_output(buf, buf_len); } -void crash_dump_fault_handler(const unsigned char *buf, unsigned int buf_len) -{ - if(crash_dump_fault_cb) - { - crash_dump_fault_cb(buf,buf_len); - } +void crash_dump_init(void) { + uint32_t block_size = 0; + uint32_t sector_size = 0; + uint32_t page_size = 0; + uint32_t buffer_len = 0; + uint32_t dump_seqnum = 0; + uint32_t sector_seqnum = 0; + enum NORFLASH_API_RET_T result; + + hal_norflash_get_size(HAL_NORFLASH_ID_0, NULL, &block_size, §or_size, + &page_size); + buffer_len = CRASH_DUMP_NORFALSH_BUFFER_LEN; + CRASH_DUMP_TRACE(4, + "__CRASH_DUMP:%s: crash_dump_start = 0x%x, crash_dump_end = " + "0x%x, buff_len = 0x%x.", + __func__, crash_dump_flash_start_addr, + crash_dump_flash_end_addr, buffer_len); + + result = norflash_api_register( + NORFLASH_API_MODULE_ID_CRASH_DUMP, HAL_NORFLASH_ID_0, + crash_dump_flash_start_addr, + crash_dump_flash_end_addr - crash_dump_flash_start_addr, block_size, + sector_size, page_size, buffer_len, NULL); + + if (result == NORFLASH_API_OK) { + CRASH_DUMP_TRACE(1, "__CRASH_DUMP:%s: norflash_api_register ok.", __func__); + } else { + CRASH_DUMP_TRACE( + 2, "__CRASH_DUMP:%s: norflash_api_register failed,result = %d", + __func__, result); + return; + } + + crash_dump_notify_cb = _crash_dump_notify; + crash_dump_output_cb = _crash_dump_output; + crash_dump_fault_cb = _crash_dump_fault; + + hal_trace_app_custom_register(crash_dump_notify_handler, + crash_dump_output_handler, + crash_dump_fault_handler); + _crash_dump_get_seqnum(&dump_seqnum, §or_seqnum); + crash_dump_cur_dump_seqnum = dump_seqnum; + crash_dump_flash_len = + crash_dump_flash_end_addr - crash_dump_flash_start_addr; + crash_dump_flash_offs = sector_seqnum * CRASH_DUMP_BUFFER_LEN; + crash_data_buffer.offset = 0; + crash_data_buffer.buffer = NULL; + crash_dump_w_seqnum = 0; + crash_dump_total_len = 0; + crash_dump_is_init = true; } -void crash_dump_set_flag(uint8_t is_happend) -{ - crash_dump_is_happend = is_happend; +void crash_dump_init_buffer(void) { + crash_data_buffer.offset = 0; + syspool_init_specific_size(CRASH_DUMP_BUFFER_LEN); + syspool_get_buff(&(crash_data_buffer.buffer), CRASH_DUMP_BUFFER_LEN); } -void crash_dump_register(HAL_TRACE_APP_NOTIFY_T notify_cb,HAL_TRACE_APP_OUTPUT_T crash_output_cb,HAL_TRACE_APP_OUTPUT_T crash_fault_cb) -{ - crash_dump_notify_cb = notify_cb; - crash_dump_output_cb = crash_output_cb; - crash_dump_fault_cb = crash_fault_cb; +int32_t crash_dump_read(uint32_t addr, uint8_t *ptr, uint32_t len) { + enum NORFLASH_API_RET_T ret; + + ret = norflash_sync_read(NORFLASH_API_MODULE_ID_CRASH_DUMP, addr, ptr, len); + if (ret != NORFLASH_API_OK) { + CRASH_DUMP_TRACE( + 4, + "__CRASH_DUMP:%s: norflash_sync_read,addr = 0x%x,len = 0x%x,ret = %d.", + __func__, addr, len, ret); + return ret; + } + return 0; } -CRASH_DATA_BUFFER* crash_dump_get_buffer(void) -{ - return &crash_data_buffer; +int32_t crash_dump_write(uint32_t addr, uint8_t *ptr, uint32_t len) { + enum NORFLASH_API_RET_T ret; + + if (CRASH_LOG_ALIGN(addr, CRASH_DUMP_SECTOR_SIZE) != addr) { + CRASH_DUMP_TRACE(2, "__CRASH_DUMP:%s: addr not aligned! addr = 0x%x.", + __func__, addr); + return (int32_t)NORFLASH_API_BAD_ADDR; + } + ret = norflash_api_erase(NORFLASH_API_MODULE_ID_CRASH_DUMP, addr, + CRASH_DUMP_SECTOR_SIZE, false); + if (ret != NORFLASH_API_OK) { + CRASH_DUMP_TRACE( + 3, "__CRASH_DUMP:%s: norflash_api_erase failed! addr = 0x%x,ret = %d.", + __func__, addr, ret); + return (int32_t)ret; + } + ret = norflash_api_write(NORFLASH_API_MODULE_ID_CRASH_DUMP, addr, ptr, len, + false); + if (ret != NORFLASH_API_OK) { + CRASH_DUMP_TRACE( + 4, + "__CRASH_DUMP:%s: norflash_api_write,addr = 0x%x,len = 0x%x,ret = %d.", + __func__, addr, len, ret); + return (int32_t)ret; + } + return 0; } -uint32_t crash_dump_get_type(void) -{ - return crash_dump_type; +void crash_dump_notify_handler(enum HAL_TRACE_STATE_T state) { + if ((state == HAL_TRACE_STATE_CRASH_ASSERT_START) || + (state == HAL_TRACE_STATE_CRASH_FAULT_START)) { + norflash_api_flush_enable_all(); + crash_dump_init_buffer(); + } + + if (crash_dump_notify_cb) { + crash_dump_notify_cb(state); + } } +void crash_dump_output_handler(const unsigned char *buf, unsigned int buf_len) { + if (crash_dump_output_cb) { + crash_dump_output_cb(buf, buf_len); + } +} + +void crash_dump_fault_handler(const unsigned char *buf, unsigned int buf_len) { + if (crash_dump_fault_cb) { + crash_dump_fault_cb(buf, buf_len); + } +} + +void crash_dump_set_flag(uint8_t is_happend) { + crash_dump_is_happend = is_happend; +} + +void crash_dump_register(HAL_TRACE_APP_NOTIFY_T notify_cb, + HAL_TRACE_APP_OUTPUT_T crash_output_cb, + HAL_TRACE_APP_OUTPUT_T crash_fault_cb) { + crash_dump_notify_cb = notify_cb; + crash_dump_output_cb = crash_output_cb; + crash_dump_fault_cb = crash_fault_cb; +} + +CRASH_DATA_BUFFER *crash_dump_get_buffer(void) { return &crash_data_buffer; } + +uint32_t crash_dump_get_type(void) { return crash_dump_type; } #endif - diff --git a/services/nv_section/log_section/log_section.c b/services/nv_section/log_section/log_section.c index 98601a5..56a84af 100644 --- a/services/nv_section/log_section/log_section.c +++ b/services/nv_section/log_section/log_section.c @@ -13,28 +13,27 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include -#include "hal_trace.h" #include "log_section.h" -#include -#include "hal_timer.h" -#include "hal_norflash.h" -#include "norflash_api.h" #include "cmsis.h" #include "hal_cache.h" +#include "hal_norflash.h" #include "hal_sleep.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "norflash_api.h" #include "pmu.h" +#include +#include // #define DUMP_NO_ROLLBACK -#define LOG_DUMP_PREFIX "__LOG_DUMP:" +#define LOG_DUMP_PREFIX "__LOG_DUMP:" #if 0 -#define LOG_DUMP_TRACE(num,fmt, ...) TRACE(num,fmt, ##__VA_ARGS__) +#define LOG_DUMP_TRACE(num, fmt, ...) TRACE(num, fmt, ##__VA_ARGS__) #else -#define LOG_DUMP_TRACE(num,fmt, ...) +#define LOG_DUMP_TRACE(num, fmt, ...) #endif -#define LOG_DUMP_TRACE_FORCE(num,fmt, ...) TRACE(num,fmt, ##__VA_ARGS__) -#define DUMP_LOG_ALIGN(x,a) (uint32_t)(((x + a - 1)/a) * a) +#define LOG_DUMP_TRACE_FORCE(num, fmt, ...) TRACE(num, fmt, ##__VA_ARGS__) +#define DUMP_LOG_ALIGN(x, a) (uint32_t)(((x + a - 1) / a) * a) extern uint32_t __log_dump_start; extern uint32_t __log_dump_end; @@ -42,7 +41,7 @@ extern uint32_t __log_dump_end; extern void watchdog_ping(void); static const uint32_t log_dump_flash_start_addr = (uint32_t)&__log_dump_start; -static const uint32_t log_dump_flash_end_addr = (uint32_t)&__log_dump_end; +static const uint32_t log_dump_flash_end_addr = (uint32_t)&__log_dump_end; static uint32_t log_dump_flash_len; static DATA_BUFFER data_buffer_list[LOG_DUMP_SECTOR_BUFFER_COUNT]; @@ -53,544 +52,464 @@ static uint32_t log_dump_cur_dump_seqnum; static bool log_dump_is_init = false; static bool log_dump_is_immediately; static bool log_dump_is_bootup = true; -static enum LOG_DUMP_FLUSH_STATE log_dump_flash_state = LOG_DUMP_FLASH_STATE_IDLE; +static enum LOG_DUMP_FLUSH_STATE log_dump_flash_state = + LOG_DUMP_FLASH_STATE_IDLE; -static enum NORFLASH_API_RET_T _flash_api_read(uint32_t addr, uint8_t* buffer, uint32_t len) -{ +static enum NORFLASH_API_RET_T _flash_api_read(uint32_t addr, uint8_t *buffer, + uint32_t len) { - return norflash_sync_read(NORFLASH_API_MODULE_ID_LOG_DUMP, - addr, - buffer, - len); + return norflash_sync_read(NORFLASH_API_MODULE_ID_LOG_DUMP, addr, buffer, len); } -static void _flash_api_flush(void) -{ +static void _flash_api_flush(void) { + hal_trace_pause(); + do { + norflash_api_flush(); + } while (!norflash_api_buffer_is_free(NORFLASH_API_MODULE_ID_LOG_DUMP)); + + hal_trace_continue(); +} + +static enum NORFLASH_API_RET_T _flash_api_erase(uint32_t addr, bool is_async) { + uint32_t lock; + enum NORFLASH_API_RET_T ret = NORFLASH_API_OK; + + if (log_dump_is_immediately) { + is_async = false; + } + do { + + lock = int_lock_global(); hal_trace_pause(); - do - { - norflash_api_flush(); - } while(!norflash_api_buffer_is_free(NORFLASH_API_MODULE_ID_LOG_DUMP)); + ret = norflash_api_erase(NORFLASH_API_MODULE_ID_LOG_DUMP, addr, + LOG_DUMP_SECTOR_SIZE, is_async); + hal_trace_continue(); + int_unlock_global(lock); + + if (NORFLASH_API_OK == ret) { + // LOG_DUMP_TRACE(1,LOG_DUMP_PREFIX"%s: norflash_api_erase ok!",__func__); + break; + } else if (NORFLASH_API_BUFFER_FULL == ret) { + norflash_api_flush(); + if (is_async) { + break; + } + } else { + ASSERT( + 0, + "_flash_api_erase: norflash_api_erase failed. ret = %d,addr = 0x%x.", + ret, addr); + } + } while (1); + + return ret; +} + +static enum NORFLASH_API_RET_T _flash_api_write(uint32_t addr, uint8_t *ptr, + uint32_t len, bool is_async) { + uint32_t lock; + enum NORFLASH_API_RET_T ret = NORFLASH_API_OK; + + if (log_dump_is_immediately) { + is_async = false; + } + + do { + lock = int_lock_global(); + hal_trace_pause(); + ret = norflash_api_write(NORFLASH_API_MODULE_ID_LOG_DUMP, addr, ptr, len, + is_async); hal_trace_continue(); -} - -static enum NORFLASH_API_RET_T _flash_api_erase(uint32_t addr, - bool is_async) -{ - uint32_t lock; - enum NORFLASH_API_RET_T ret = NORFLASH_API_OK; - - if(log_dump_is_immediately) - { - is_async = false; - } - do - { - - lock = int_lock_global(); - hal_trace_pause(); - ret = norflash_api_erase(NORFLASH_API_MODULE_ID_LOG_DUMP, - addr, - LOG_DUMP_SECTOR_SIZE, - is_async); - hal_trace_continue(); - int_unlock_global(lock); - - if (NORFLASH_API_OK == ret) - { - // LOG_DUMP_TRACE(1,LOG_DUMP_PREFIX"%s: norflash_api_erase ok!",__func__); - break; - } - else if(NORFLASH_API_BUFFER_FULL == ret) - { - norflash_api_flush(); - if(is_async) - { - break; - } - } - else - { - ASSERT(0, "_flash_api_erase: norflash_api_erase failed. ret = %d,addr = 0x%x.", ret,addr); - } - } while (1); - - return ret; -} - -static enum NORFLASH_API_RET_T _flash_api_write(uint32_t addr, - uint8_t* ptr, - uint32_t len, - bool is_async) -{ - uint32_t lock; - enum NORFLASH_API_RET_T ret = NORFLASH_API_OK; - - if(log_dump_is_immediately) - { - is_async = false; - } - - do - { - lock = int_lock_global(); - hal_trace_pause(); - ret = norflash_api_write(NORFLASH_API_MODULE_ID_LOG_DUMP, - addr, - ptr, - len, - is_async); - - hal_trace_continue(); - - int_unlock_global(lock); - - if (NORFLASH_API_OK == ret) - { - // LOG_DUMP_TRACE(1,LOG_DUMP_PREFIX"%s: norflash_api_write ok!",__func__); - break; - } - else if (NORFLASH_API_BUFFER_FULL == ret) - { - norflash_api_flush(); - if(is_async) - { - LOG_DUMP_TRACE(1,LOG_DUMP_PREFIX"%s: norflash api buffer full",__func__); - break; - } - } - else - { - ASSERT(0,"_flash_api_write: norflash_api_write failed. ret = %d",ret); - } - }while (1); - - return ret; -} - -static int32_t _get_seqnum(uint32_t * dump_seqnum, uint32_t *sector_seqnum) -{ -#ifndef DUMP_NO_ROLLBACK - uint32_t i; - uint32_t count; - static enum NORFLASH_API_RET_T result; - LOG_DUMP_HEADER log_dump_header; - uint32_t max_dump_seqnum = 0; - uint32_t max_sector_seqnum = 0; - bool is_existed = false; - - count = (log_dump_flash_end_addr-log_dump_flash_start_addr)/LOG_DUMP_SECTOR_SIZE; - for(i = 0; i < count; i++) - { - result = _flash_api_read( - log_dump_flash_start_addr + i*LOG_DUMP_SECTOR_SIZE, - (uint8_t*)&log_dump_header, - sizeof(LOG_DUMP_HEADER)); - if(result == NORFLASH_API_OK) - { - if(log_dump_header.magic == DUMP_LOG_MAGIC - && log_dump_header.version == DUMP_LOG_VERSION - ) - { - is_existed = true; - if(log_dump_header.seqnum > max_dump_seqnum) - { - max_dump_seqnum = log_dump_header.seqnum; - max_sector_seqnum = i; - } - } - } - else - { - ASSERT(0,"_get_cur_sector_seqnum: _flash_api_read failed!result = %d.",result); - } - } - if(is_existed) - { - *dump_seqnum = max_dump_seqnum + 1; - *sector_seqnum = max_sector_seqnum + 1 >= count ? 0: max_sector_seqnum + 1; - } - else - { - *dump_seqnum = 0; - *sector_seqnum = 0; - } -#else - { - LOG_DUMP_HEADER log_dump_header; - _flash_api_read( - log_dump_flash_start_addr, - (uint8_t*)&log_dump_header, - sizeof(LOG_DUMP_HEADER)); - *dump_seqnum = 0; - *sector_seqnum = 0; - } -#endif - return 0; -} - -static int _log_dump_flush(uint32_t buff_state,bool is_async) -{ - enum NORFLASH_API_RET_T result; - static uint32_t total_len = 0; - DATA_BUFFER *data_buff; - - if(log_dump_flash_state == LOG_DUMP_FLASH_STATE_IDLE - && (log_dump_flash_offs % LOG_DUMP_SECTOR_SIZE) == 0) - { - LOG_DUMP_TRACE(3,LOG_DUMP_PREFIX"%s:%d,state = idle,addr = 0x%x.", - __func__,__LINE__,log_dump_flash_start_addr + log_dump_flash_offs); - result = _flash_api_erase(log_dump_flash_start_addr + log_dump_flash_offs,is_async); - if(result == NORFLASH_API_OK) - { - LOG_DUMP_TRACE(3,LOG_DUMP_PREFIX"%s:%d,erase ok,addr = 0x%x,", - __func__,__LINE__,log_dump_flash_start_addr + log_dump_flash_offs); - log_dump_flash_state = LOG_DUMP_FLASH_STATE_ERASED; - } - else - { - LOG_DUMP_TRACE(3,LOG_DUMP_PREFIX"%s: _flash_api_erase failed!addr = 0x%x,ret = %d.", - __func__,log_dump_flash_start_addr + log_dump_flash_offs, result); - } - } - else if(log_dump_flash_state == LOG_DUMP_FLASH_STATE_ERASED || - log_dump_flash_state == LOG_DUMP_FLASH_STATE_WRITTING) - { - data_buff = &data_buffer_list[log_dump_f_seqnum]; - if((data_buff->state & buff_state) != 0 - && data_buff->offset > 0) - { - LOG_DUMP_TRACE(3,LOG_DUMP_PREFIX"%s:%d,state = ERASED,f_seqnum = %d.", - __func__,__LINE__,log_dump_f_seqnum); - log_dump_flash_state = LOG_DUMP_FLASH_STATE_WRITTING; - result = _flash_api_write( - log_dump_flash_start_addr + log_dump_flash_offs, - data_buff->buffer, - data_buff->offset, - is_async); - if(result == NORFLASH_API_OK) - { - LOG_DUMP_TRACE(5,LOG_DUMP_PREFIX"%s:%d,write ok,addr = 0x%x,f_seqnum = 0x%x,total_len = 0x%x.", - __func__,__LINE__, - log_dump_flash_start_addr + log_dump_flash_offs, - log_dump_f_seqnum, - total_len); - - data_buff->state = DATA_BUFFER_STATE_FREE; - log_dump_f_seqnum = log_dump_f_seqnum + 1 == LOG_DUMP_SECTOR_BUFFER_COUNT ? - 0 : log_dump_f_seqnum + 1; - total_len += data_buff->offset; - - log_dump_flash_offs = log_dump_flash_offs + data_buff->offset >= log_dump_flash_len ? - 0 : log_dump_flash_offs + data_buff->offset; - log_dump_flash_state = LOG_DUMP_FLASH_STATE_IDLE; - } - else - { - LOG_DUMP_TRACE(2,LOG_DUMP_PREFIX"%s: _flash_api_write failed!ret = %d.",__func__,result); - return 3; - } - } - } - else - { - LOG_DUMP_TRACE(3,LOG_DUMP_PREFIX"%s:%d state = %d.", - __func__,__LINE__,log_dump_flash_state); - } - return 0; -} - -void _log_dump_flush_remain(void) -{ - uint32_t i; - uint32_t unfree_count = 0; - - do{ - unfree_count = 0; - for(i = 0; i < LOG_DUMP_SECTOR_BUFFER_COUNT; i++) - { - if(data_buffer_list[i].state != DATA_BUFFER_STATE_FREE) - { - unfree_count ++; - } - } - if(unfree_count == 0) - { - break; - } - _log_dump_flush(DATA_BUFFER_STATE_WRITTING | DATA_BUFFER_STATE_WRITTEN,false); - }while(1); - - _flash_api_flush(); -} - -int log_dump_flush_all(void) -{ - norflash_api_flush_enable_all(); - log_dump_is_immediately = true; - _log_dump_flush_remain(); - return 0; -} -int log_dump_flush(void) -{ - if(!log_dump_is_init) - { - return 0; - } - - return _log_dump_flush(DATA_BUFFER_STATE_WRITTEN, true); -} - -void log_dump_notify_handler(enum HAL_TRACE_STATE_T state) -{ - //uint32_t lock; - - if(!log_dump_is_init) - { - return; - } - LOG_DUMP_TRACE(3,LOG_DUMP_PREFIX"%s: state = %d,start_addr = 0x%x,end_addr = 0x%x.", - __func__,state,log_dump_flash_start_addr,log_dump_flash_end_addr); - LOG_DUMP_TRACE(3,LOG_DUMP_PREFIX"%s: dump_seqnum = 0x%x,flash_offset = 0x%x.", - __func__,log_dump_cur_dump_seqnum,log_dump_flash_offs); - - if(state == HAL_TRACE_STATE_CRASH_ASSERT_START - || state == HAL_TRACE_STATE_CRASH_FAULT_START) - { - norflash_api_flush_enable_all(); - log_dump_is_immediately = true; - } - else - { - LOG_DUMP_TRACE(2,LOG_DUMP_PREFIX" crash end."); - //lock = int_lock_global(); - _log_dump_flush_remain(); - //int_unlock_global(lock); - } -} - -void log_dump_output_handler(const unsigned char *buf, unsigned int buf_len) -{ - uint32_t write_len; - uint32_t written_len; - uint32_t remain_len; - LOG_DUMP_HEADER log_header; - DATA_BUFFER *data_buff; - - if(!log_dump_is_init) - { - return; - } - - if(strstr((char*)buf,LOG_DUMP_PREFIX) != NULL) - { - return; - } - - data_buff = &data_buffer_list[log_dump_w_seqnum]; - remain_len = buf_len; - written_len = 0; - do{ - if(data_buff->state == DATA_BUFFER_STATE_FREE - || data_buff->state == DATA_BUFFER_STATE_WRITTEN) - { - // LOG_DUMP_TRACE(3,LOG_DUMP_PREFIX"%s:%d data_buff->state is free.w_seqnum = %d.", - // __func__,__LINE__,log_dump_w_seqnum); - data_buff->state = DATA_BUFFER_STATE_WRITTING; - data_buff->offset = 0; - memset(data_buff->buffer,0,LOG_DUMP_SECTOR_SIZE); - - } - if(data_buff->offset == 0) - { -#ifndef DUMP_NO_ROLLBACK - // LOG_DUMP_TRACE(4,LOG_DUMP_PREFIX"%s:%d offset = 0.w_seqnum = %d,dump_seqnum = %d.", - // __func__,__LINE__,log_dump_w_seqnum,log_dump_cur_dump_seqnum); - memset((uint8_t*)&log_header,0,sizeof(log_header)); - log_header.magic = DUMP_LOG_MAGIC; - log_header.version = DUMP_LOG_VERSION; - log_header.seqnum = log_dump_cur_dump_seqnum; - if(log_dump_is_bootup) - { - log_header.is_bootup = 1; - log_dump_is_bootup = false; - } - else - { - log_header.is_bootup = 0; - } - log_header.reseved[0] = '\0'; - log_header.reseved[1] = '\0'; - log_header.reseved[2] = '\n'; - - memcpy(data_buff->buffer + data_buff->offset, - (uint8_t*)&log_header, - sizeof(log_header)); - - data_buff->offset += sizeof(log_header); -#else - if(log_dump_cur_dump_seqnum*LOG_DUMP_SECTOR_SIZE >= log_dump_flash_len) - { - log_header = log_header; - log_dump_is_bootup = log_dump_is_bootup; - break; - } -#endif - log_dump_cur_dump_seqnum ++; - } - - if(data_buff->offset + remain_len > LOG_DUMP_SECTOR_SIZE) - { - write_len = (LOG_DUMP_SECTOR_SIZE - data_buff->offset); - } - else - { - write_len = remain_len; - } - - if(write_len > 0) - { - memcpy(data_buff->buffer + data_buff->offset, - buf + written_len, - write_len); - data_buff->offset += write_len; - written_len += write_len; - } - - if(data_buff->offset == LOG_DUMP_SECTOR_SIZE) - { - data_buff->state = DATA_BUFFER_STATE_WRITTEN; - } - - remain_len -= write_len; - - if(data_buff->offset == LOG_DUMP_SECTOR_SIZE) - { - log_dump_w_seqnum = log_dump_w_seqnum + 1 == LOG_DUMP_SECTOR_BUFFER_COUNT ? - 0 : log_dump_w_seqnum + 1; - if(log_dump_w_seqnum == log_dump_f_seqnum) - { - log_dump_f_seqnum = log_dump_f_seqnum + 1 == LOG_DUMP_SECTOR_BUFFER_COUNT ? - 0 : log_dump_f_seqnum + 1; - } - // LOG_DUMP_TRACE(4,LOG_DUMP_PREFIX"%s:%d w_seqnum = %d,dump_seqnum = %d.", - // __func__,__LINE__,log_dump_w_seqnum,log_dump_cur_dump_seqnum); - - data_buff = &data_buffer_list[log_dump_w_seqnum]; - - ASSERT(data_buff->state == DATA_BUFFER_STATE_FREE || - data_buff->state == DATA_BUFFER_STATE_WRITTEN, - "log_dump_output_handler: data_buff state error! state = %d.", - data_buff->state); - } - }while(remain_len > 0); - -} - -void log_dump_callback(void* param) -{ - NORFLASH_API_OPERA_RESULT *opera_result; - - opera_result = (NORFLASH_API_OPERA_RESULT*)param; - - LOG_DUMP_TRACE_FORCE(6,LOG_DUMP_PREFIX"%s:type = %d, addr = 0x%x,len = 0x%x,remain = %d,result = %d.", - __func__, - opera_result->type, - opera_result->addr, - opera_result->len, - opera_result->remain_num, - opera_result->result); - { - static uint32_t is_fst = 1; - if(is_fst) - { - LOG_DUMP_TRACE(3,LOG_DUMP_PREFIX"%s:log_dump_start = 0x%x, log_dump_end = 0x%x.", - __func__, - log_dump_flash_start_addr, - log_dump_flash_end_addr); - is_fst = 0; - } - } -} - -void log_dump_init(void) -{ - uint32_t block_size = 0; - uint32_t sector_size = 0; - uint32_t page_size = 0; - uint32_t buffer_len = 0; - uint32_t dump_seqnum = 0; - uint32_t sector_seqnum = 0; - enum NORFLASH_API_RET_T result; - uint32_t i; - - log_dump_flash_len = log_dump_flash_end_addr - log_dump_flash_start_addr; - hal_norflash_get_size(HAL_NORFLASH_ID_0,NULL, &block_size, §or_size, &page_size); - buffer_len = LOG_DUMP_NORFALSH_BUFFER_LEN; - /* - LOG_DUMP_TRACE(4,LOG_DUMP_PREFIX"%s: log_dump_start = 0x%x, log_dump_len = 0x%x, buff_len = 0x%x.", - __func__, - log_dump_flash_start_addr, - log_dump_flash_len, - buffer_len); - */ - result = norflash_api_register( - NORFLASH_API_MODULE_ID_LOG_DUMP, - HAL_NORFLASH_ID_0, - log_dump_flash_start_addr, - log_dump_flash_end_addr - log_dump_flash_start_addr, - block_size, - sector_size, - page_size, - buffer_len, - log_dump_callback - ); - - if(result == NORFLASH_API_OK) - { - /* - LOG_DUMP_TRACE(1,LOG_DUMP_PREFIX"%s: norflash_api_register ok.", __func__); - */ - } - else - { - /* - LOG_DUMP_TRACE(2,LOG_DUMP_PREFIX"%s: norflash_api_register failed,result = %d.", __func__, result); - */ - return; - } - hal_trace_app_register(log_dump_notify_handler, log_dump_output_handler); - hal_sleep_set_sleep_hook(HAL_SLEEP_HOOK_DUMP_LOG, log_dump_flush); - _get_seqnum(&dump_seqnum,§or_seqnum); - log_dump_cur_dump_seqnum = dump_seqnum; - log_dump_flash_offs = sector_seqnum*LOG_DUMP_SECTOR_SIZE; - memset((uint8_t*)&data_buffer_list,0,sizeof(data_buffer_list)); - for(i = 0;i < LOG_DUMP_SECTOR_BUFFER_COUNT; i++) - { - data_buffer_list[i].state = DATA_BUFFER_STATE_FREE; - data_buffer_list[i].offset = 0; - } - log_dump_w_seqnum = 0; - log_dump_f_seqnum = 0; - log_dump_flash_state = LOG_DUMP_FLASH_STATE_IDLE; - log_dump_is_immediately = false; - log_dump_is_init = true; -} - -void log_dump_clear(void) -{ - uint32_t i; - uint32_t addr; - uint32_t lock = int_lock_global(); - - for(i = 0; i < log_dump_flash_len/LOG_DUMP_SECTOR_SIZE; i++) - { - addr = log_dump_flash_start_addr + i*LOG_DUMP_SECTOR_SIZE; - _flash_api_erase(addr,false); - } int_unlock_global(lock); + + if (NORFLASH_API_OK == ret) { + // LOG_DUMP_TRACE(1,LOG_DUMP_PREFIX"%s: norflash_api_write ok!",__func__); + break; + } else if (NORFLASH_API_BUFFER_FULL == ret) { + norflash_api_flush(); + if (is_async) { + LOG_DUMP_TRACE(1, LOG_DUMP_PREFIX "%s: norflash api buffer full", + __func__); + break; + } + } else { + ASSERT(0, "_flash_api_write: norflash_api_write failed. ret = %d", ret); + } + } while (1); + + return ret; +} + +static int32_t _get_seqnum(uint32_t *dump_seqnum, uint32_t *sector_seqnum) { +#ifndef DUMP_NO_ROLLBACK + uint32_t i; + uint32_t count; + static enum NORFLASH_API_RET_T result; + LOG_DUMP_HEADER log_dump_header; + uint32_t max_dump_seqnum = 0; + uint32_t max_sector_seqnum = 0; + bool is_existed = false; + + count = (log_dump_flash_end_addr - log_dump_flash_start_addr) / + LOG_DUMP_SECTOR_SIZE; + for (i = 0; i < count; i++) { + result = + _flash_api_read(log_dump_flash_start_addr + i * LOG_DUMP_SECTOR_SIZE, + (uint8_t *)&log_dump_header, sizeof(LOG_DUMP_HEADER)); + if (result == NORFLASH_API_OK) { + if (log_dump_header.magic == DUMP_LOG_MAGIC && + log_dump_header.version == DUMP_LOG_VERSION) { + is_existed = true; + if (log_dump_header.seqnum > max_dump_seqnum) { + max_dump_seqnum = log_dump_header.seqnum; + max_sector_seqnum = i; + } + } + } else { + ASSERT(0, "_get_cur_sector_seqnum: _flash_api_read failed!result = %d.", + result); + } + } + if (is_existed) { + *dump_seqnum = max_dump_seqnum + 1; + *sector_seqnum = max_sector_seqnum + 1 >= count ? 0 : max_sector_seqnum + 1; + } else { + *dump_seqnum = 0; + *sector_seqnum = 0; + } +#else + { + LOG_DUMP_HEADER log_dump_header; + _flash_api_read(log_dump_flash_start_addr, (uint8_t *)&log_dump_header, + sizeof(LOG_DUMP_HEADER)); + *dump_seqnum = 0; + *sector_seqnum = 0; + } +#endif + return 0; +} + +static int _log_dump_flush(uint32_t buff_state, bool is_async) { + enum NORFLASH_API_RET_T result; + static uint32_t total_len = 0; + DATA_BUFFER *data_buff; + + if (log_dump_flash_state == LOG_DUMP_FLASH_STATE_IDLE && + (log_dump_flash_offs % LOG_DUMP_SECTOR_SIZE) == 0) { + LOG_DUMP_TRACE(3, LOG_DUMP_PREFIX "%s:%d,state = idle,addr = 0x%x.", + __func__, __LINE__, + log_dump_flash_start_addr + log_dump_flash_offs); + result = _flash_api_erase(log_dump_flash_start_addr + log_dump_flash_offs, + is_async); + if (result == NORFLASH_API_OK) { + LOG_DUMP_TRACE(3, LOG_DUMP_PREFIX "%s:%d,erase ok,addr = 0x%x,", __func__, + __LINE__, log_dump_flash_start_addr + log_dump_flash_offs); + log_dump_flash_state = LOG_DUMP_FLASH_STATE_ERASED; + } else { + LOG_DUMP_TRACE( + 3, + LOG_DUMP_PREFIX "%s: _flash_api_erase failed!addr = 0x%x,ret = %d.", + __func__, log_dump_flash_start_addr + log_dump_flash_offs, result); + } + } else if (log_dump_flash_state == LOG_DUMP_FLASH_STATE_ERASED || + log_dump_flash_state == LOG_DUMP_FLASH_STATE_WRITTING) { + data_buff = &data_buffer_list[log_dump_f_seqnum]; + if ((data_buff->state & buff_state) != 0 && data_buff->offset > 0) { + LOG_DUMP_TRACE(3, LOG_DUMP_PREFIX "%s:%d,state = ERASED,f_seqnum = %d.", + __func__, __LINE__, log_dump_f_seqnum); + log_dump_flash_state = LOG_DUMP_FLASH_STATE_WRITTING; + result = _flash_api_write(log_dump_flash_start_addr + log_dump_flash_offs, + data_buff->buffer, data_buff->offset, is_async); + if (result == NORFLASH_API_OK) { + LOG_DUMP_TRACE( + 5, + LOG_DUMP_PREFIX + "%s:%d,write ok,addr = 0x%x,f_seqnum = 0x%x,total_len = 0x%x.", + __func__, __LINE__, log_dump_flash_start_addr + log_dump_flash_offs, + log_dump_f_seqnum, total_len); + + data_buff->state = DATA_BUFFER_STATE_FREE; + log_dump_f_seqnum = + log_dump_f_seqnum + 1 == LOG_DUMP_SECTOR_BUFFER_COUNT + ? 0 + : log_dump_f_seqnum + 1; + total_len += data_buff->offset; + + log_dump_flash_offs = + log_dump_flash_offs + data_buff->offset >= log_dump_flash_len + ? 0 + : log_dump_flash_offs + data_buff->offset; + log_dump_flash_state = LOG_DUMP_FLASH_STATE_IDLE; + } else { + LOG_DUMP_TRACE(2, + LOG_DUMP_PREFIX "%s: _flash_api_write failed!ret = %d.", + __func__, result); + return 3; + } + } + } else { + LOG_DUMP_TRACE(3, LOG_DUMP_PREFIX "%s:%d state = %d.", __func__, __LINE__, + log_dump_flash_state); + } + return 0; +} + +void _log_dump_flush_remain(void) { + uint32_t i; + uint32_t unfree_count = 0; + + do { + unfree_count = 0; + for (i = 0; i < LOG_DUMP_SECTOR_BUFFER_COUNT; i++) { + if (data_buffer_list[i].state != DATA_BUFFER_STATE_FREE) { + unfree_count++; + } + } + if (unfree_count == 0) { + break; + } + _log_dump_flush(DATA_BUFFER_STATE_WRITTING | DATA_BUFFER_STATE_WRITTEN, + false); + } while (1); + + _flash_api_flush(); +} + +int log_dump_flush_all(void) { + norflash_api_flush_enable_all(); + log_dump_is_immediately = true; + _log_dump_flush_remain(); + return 0; +} +int log_dump_flush(void) { + if (!log_dump_is_init) { + return 0; + } + + return _log_dump_flush(DATA_BUFFER_STATE_WRITTEN, true); +} + +void log_dump_notify_handler(enum HAL_TRACE_STATE_T state) { + // uint32_t lock; + + if (!log_dump_is_init) { + return; + } + LOG_DUMP_TRACE( + 3, LOG_DUMP_PREFIX "%s: state = %d,start_addr = 0x%x,end_addr = 0x%x.", + __func__, state, log_dump_flash_start_addr, log_dump_flash_end_addr); + LOG_DUMP_TRACE(3, + LOG_DUMP_PREFIX "%s: dump_seqnum = 0x%x,flash_offset = 0x%x.", + __func__, log_dump_cur_dump_seqnum, log_dump_flash_offs); + + if (state == HAL_TRACE_STATE_CRASH_ASSERT_START || + state == HAL_TRACE_STATE_CRASH_FAULT_START) { + norflash_api_flush_enable_all(); + log_dump_is_immediately = true; + } else { + LOG_DUMP_TRACE(2, LOG_DUMP_PREFIX " crash end."); + // lock = int_lock_global(); + _log_dump_flush_remain(); + // int_unlock_global(lock); + } +} + +void log_dump_output_handler(const unsigned char *buf, unsigned int buf_len) { + uint32_t write_len; + uint32_t written_len; + uint32_t remain_len; + LOG_DUMP_HEADER log_header; + DATA_BUFFER *data_buff; + + if (!log_dump_is_init) { + return; + } + + if (strstr((char *)buf, LOG_DUMP_PREFIX) != NULL) { + return; + } + + data_buff = &data_buffer_list[log_dump_w_seqnum]; + remain_len = buf_len; + written_len = 0; + do { + if (data_buff->state == DATA_BUFFER_STATE_FREE || + data_buff->state == DATA_BUFFER_STATE_WRITTEN) { + // LOG_DUMP_TRACE(3,LOG_DUMP_PREFIX"%s:%d data_buff->state is + // free.w_seqnum = %d.", + // __func__,__LINE__,log_dump_w_seqnum); + data_buff->state = DATA_BUFFER_STATE_WRITTING; + data_buff->offset = 0; + memset(data_buff->buffer, 0, LOG_DUMP_SECTOR_SIZE); + } + if (data_buff->offset == 0) { +#ifndef DUMP_NO_ROLLBACK + // LOG_DUMP_TRACE(4,LOG_DUMP_PREFIX"%s:%d offset = 0.w_seqnum = + // %d,dump_seqnum = %d.", + // __func__,__LINE__,log_dump_w_seqnum,log_dump_cur_dump_seqnum); + memset((uint8_t *)&log_header, 0, sizeof(log_header)); + log_header.magic = DUMP_LOG_MAGIC; + log_header.version = DUMP_LOG_VERSION; + log_header.seqnum = log_dump_cur_dump_seqnum; + if (log_dump_is_bootup) { + log_header.is_bootup = 1; + log_dump_is_bootup = false; + } else { + log_header.is_bootup = 0; + } + log_header.reseved[0] = '\0'; + log_header.reseved[1] = '\0'; + log_header.reseved[2] = '\n'; + + memcpy(data_buff->buffer + data_buff->offset, (uint8_t *)&log_header, + sizeof(log_header)); + + data_buff->offset += sizeof(log_header); +#else + if (log_dump_cur_dump_seqnum * LOG_DUMP_SECTOR_SIZE >= + log_dump_flash_len) { + log_header = log_header; + log_dump_is_bootup = log_dump_is_bootup; + break; + } +#endif + log_dump_cur_dump_seqnum++; + } + + if (data_buff->offset + remain_len > LOG_DUMP_SECTOR_SIZE) { + write_len = (LOG_DUMP_SECTOR_SIZE - data_buff->offset); + } else { + write_len = remain_len; + } + + if (write_len > 0) { + memcpy(data_buff->buffer + data_buff->offset, buf + written_len, + write_len); + data_buff->offset += write_len; + written_len += write_len; + } + + if (data_buff->offset == LOG_DUMP_SECTOR_SIZE) { + data_buff->state = DATA_BUFFER_STATE_WRITTEN; + } + + remain_len -= write_len; + + if (data_buff->offset == LOG_DUMP_SECTOR_SIZE) { + log_dump_w_seqnum = log_dump_w_seqnum + 1 == LOG_DUMP_SECTOR_BUFFER_COUNT + ? 0 + : log_dump_w_seqnum + 1; + if (log_dump_w_seqnum == log_dump_f_seqnum) { + log_dump_f_seqnum = + log_dump_f_seqnum + 1 == LOG_DUMP_SECTOR_BUFFER_COUNT + ? 0 + : log_dump_f_seqnum + 1; + } + // LOG_DUMP_TRACE(4,LOG_DUMP_PREFIX"%s:%d w_seqnum = %d,dump_seqnum = + // %d.", + // __func__,__LINE__,log_dump_w_seqnum,log_dump_cur_dump_seqnum); + + data_buff = &data_buffer_list[log_dump_w_seqnum]; + + ASSERT(data_buff->state == DATA_BUFFER_STATE_FREE || + data_buff->state == DATA_BUFFER_STATE_WRITTEN, + "log_dump_output_handler: data_buff state error! state = %d.", + data_buff->state); + } + } while (remain_len > 0); +} + +void log_dump_callback(void *param) { + NORFLASH_API_OPERA_RESULT *opera_result; + + opera_result = (NORFLASH_API_OPERA_RESULT *)param; + + LOG_DUMP_TRACE_FORCE( + 6, + LOG_DUMP_PREFIX + "%s:type = %d, addr = 0x%x,len = 0x%x,remain = %d,result = %d.", + __func__, opera_result->type, opera_result->addr, opera_result->len, + opera_result->remain_num, opera_result->result); + { + static uint32_t is_fst = 1; + if (is_fst) { + LOG_DUMP_TRACE( + 3, LOG_DUMP_PREFIX "%s:log_dump_start = 0x%x, log_dump_end = 0x%x.", + __func__, log_dump_flash_start_addr, log_dump_flash_end_addr); + is_fst = 0; + } + } +} + +void log_dump_init(void) { + uint32_t block_size = 0; + uint32_t sector_size = 0; + uint32_t page_size = 0; + uint32_t buffer_len = 0; + uint32_t dump_seqnum = 0; + uint32_t sector_seqnum = 0; + enum NORFLASH_API_RET_T result; + uint32_t i; + + log_dump_flash_len = log_dump_flash_end_addr - log_dump_flash_start_addr; + hal_norflash_get_size(HAL_NORFLASH_ID_0, NULL, &block_size, §or_size, + &page_size); + buffer_len = LOG_DUMP_NORFALSH_BUFFER_LEN; + /* + LOG_DUMP_TRACE(4,LOG_DUMP_PREFIX"%s: log_dump_start = 0x%x, log_dump_len = + 0x%x, buff_len = 0x%x.", + __func__, + log_dump_flash_start_addr, + log_dump_flash_len, + buffer_len); + */ + result = norflash_api_register( + NORFLASH_API_MODULE_ID_LOG_DUMP, HAL_NORFLASH_ID_0, + log_dump_flash_start_addr, + log_dump_flash_end_addr - log_dump_flash_start_addr, block_size, + sector_size, page_size, buffer_len, log_dump_callback); + + if (result == NORFLASH_API_OK) { + /* + LOG_DUMP_TRACE(1,LOG_DUMP_PREFIX"%s: norflash_api_register ok.", __func__); + */ + } else { + /* + LOG_DUMP_TRACE(2,LOG_DUMP_PREFIX"%s: norflash_api_register failed,result = + %d.", __func__, result); + */ + return; + } + hal_trace_app_register(log_dump_notify_handler, log_dump_output_handler); + hal_sleep_set_sleep_hook(HAL_SLEEP_HOOK_DUMP_LOG, log_dump_flush); + _get_seqnum(&dump_seqnum, §or_seqnum); + log_dump_cur_dump_seqnum = dump_seqnum; + log_dump_flash_offs = sector_seqnum * LOG_DUMP_SECTOR_SIZE; + memset((uint8_t *)&data_buffer_list, 0, sizeof(data_buffer_list)); + for (i = 0; i < LOG_DUMP_SECTOR_BUFFER_COUNT; i++) { + data_buffer_list[i].state = DATA_BUFFER_STATE_FREE; + data_buffer_list[i].offset = 0; + } + log_dump_w_seqnum = 0; + log_dump_f_seqnum = 0; + log_dump_flash_state = LOG_DUMP_FLASH_STATE_IDLE; + log_dump_is_immediately = false; + log_dump_is_init = true; +} + +void log_dump_clear(void) { + uint32_t i; + uint32_t addr; + uint32_t lock = int_lock_global(); + + for (i = 0; i < log_dump_flash_len / LOG_DUMP_SECTOR_SIZE; i++) { + addr = log_dump_flash_start_addr + i * LOG_DUMP_SECTOR_SIZE; + _flash_api_erase(addr, false); + } + + int_unlock_global(lock); } #if 0 @@ -625,4 +544,3 @@ _func_end: return ret; } #endif - diff --git a/services/nv_section/log_section/log_section.h b/services/nv_section/log_section/log_section.h index efe8db6..bf477aa 100644 --- a/services/nv_section/log_section/log_section.h +++ b/services/nv_section/log_section/log_section.h @@ -19,8 +19,9 @@ #ifdef __cplusplus extern "C" { #endif +#include "hal_trace.h" +#include #include - #if 0 void init_dump_log(void); void dump_whole_logs(void); @@ -32,56 +33,52 @@ void clear_dump_log(void); uint32_t test_dump_log_from_flash(uint32_t addr,uint32_t size); #else -#define LOG_DUMP_SECTOR_SIZE 0x1000 -#define LOG_DUMP_SECTOR_BUFFER_COUNT 4 -#define LOG_DUMP_BUFFER_LEN (LOG_DUMP_SECTOR_SIZE*LOG_DUMP_SECTOR_BUFFER_COUNT) -#define LOG_DUMP_NORFALSH_BUFFER_LEN (LOG_DUMP_BUFFER_LEN*2) +#define LOG_DUMP_SECTOR_SIZE 0x1000 +#define LOG_DUMP_SECTOR_BUFFER_COUNT 4 +#define LOG_DUMP_BUFFER_LEN \ + (LOG_DUMP_SECTOR_SIZE * LOG_DUMP_SECTOR_BUFFER_COUNT) +#define LOG_DUMP_NORFALSH_BUFFER_LEN (LOG_DUMP_BUFFER_LEN * 2) -#define DATA_BUFFER_STATE_FREE 0 -#define DATA_BUFFER_STATE_WRITTING 0x1 -#define DATA_BUFFER_STATE_WRITTEN 0x2 +#define DATA_BUFFER_STATE_FREE 0 +#define DATA_BUFFER_STATE_WRITTING 0x1 +#define DATA_BUFFER_STATE_WRITTEN 0x2 -#define DUMP_LOG_MAGIC 0xd5151001 -#define DUMP_LOG_VERSION 0x00010001 +#define DUMP_LOG_MAGIC 0xd5151001 +#define DUMP_LOG_VERSION 0x00010001 // #define DUMP_LOG_NEWLINE '\n' -enum LOG_DUMP_FLUSH_STATE -{ - LOG_DUMP_FLASH_STATE_IDLE, - LOG_DUMP_FLASH_STATE_ERASED, - LOG_DUMP_FLASH_STATE_WRITTING, - LOG_DUMP_FLASH_STATE_WRITTEN, +enum LOG_DUMP_FLUSH_STATE { + LOG_DUMP_FLASH_STATE_IDLE, + LOG_DUMP_FLASH_STATE_ERASED, + LOG_DUMP_FLASH_STATE_WRITTING, + LOG_DUMP_FLASH_STATE_WRITTEN, }; -typedef struct -{ - uint32_t magic; - uint32_t version; - uint32_t seqnum; - uint8_t is_bootup; - uint8_t reseved[3]; -}LOG_DUMP_HEADER; +typedef struct { + uint32_t magic; + uint32_t version; + uint32_t seqnum; + uint8_t is_bootup; + uint8_t reseved[3]; +} LOG_DUMP_HEADER; - -typedef struct{ - uint32_t state; - uint32_t offset; - uint8_t buffer[LOG_DUMP_SECTOR_SIZE]; -}DATA_BUFFER; +typedef struct { + uint32_t state; + uint32_t offset; + uint8_t buffer[LOG_DUMP_SECTOR_SIZE]; +} DATA_BUFFER; void log_dump_init(void); int log_dump_flush(void); int log_dump_flush_all(void); void log_dump_notify_handler(enum HAL_TRACE_STATE_T state); void log_dump_output_handler(const unsigned char *buf, unsigned int buf_len); -void log_dump_callback(void* param); +void log_dump_callback(void *param); void log_dump_clear(void); -//uint32_t test_log_dump_from_flash(uint32_t addr,uint32_t size); +// uint32_t test_log_dump_from_flash(uint32_t addr,uint32_t size); #endif #ifdef __cplusplus } #endif #endif - - diff --git a/services/nv_section/userdata_section/nvrecord_ble.c b/services/nv_section/userdata_section/nvrecord_ble.c index 5e9819e..72eb516 100644 --- a/services/nv_section/userdata_section/nvrecord_ble.c +++ b/services/nv_section/userdata_section/nvrecord_ble.c @@ -14,16 +14,16 @@ * ****************************************************************************/ #if defined(NEW_NV_RECORD_ENABLED) -#include -#include -#include -#include "nvrecord_extension.h" #include "nvrecord_ble.h" -#include "hal_trace.h" -#include "co_math.h" -#include "tgt_hardware.h" -#include "hal_timer.h" #include "besbt.h" +#include "co_math.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "nvrecord_extension.h" +#include "tgt_hardware.h" +#include +#include +#include #define ble_nv_debug #ifdef ble_nv_debug @@ -33,436 +33,414 @@ #endif static NV_RECORD_PAIRED_BLE_DEV_INFO_T *nvrecord_ble_p = NULL; -static uint8_t INVALID_ADDR[BTIF_BD_ADDR_SIZE] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +static uint8_t INVALID_ADDR[BTIF_BD_ADDR_SIZE] = {0x00, 0x00, 0x00, + 0x00, 0x00, 0x00}; -void nvrecord_rebuild_paired_ble_dev_info(NV_RECORD_PAIRED_BLE_DEV_INFO_T *pPairedBtInfo) -{ - memset(( uint8_t * )pPairedBtInfo, 0, sizeof(NV_RECORD_PAIRED_BLE_DEV_INFO_T)); - pPairedBtInfo->saved_list_num = 0; //init saved num +void nvrecord_rebuild_paired_ble_dev_info( + NV_RECORD_PAIRED_BLE_DEV_INFO_T *pPairedBtInfo) { + memset((uint8_t *)pPairedBtInfo, 0, sizeof(NV_RECORD_PAIRED_BLE_DEV_INFO_T)); + pPairedBtInfo->saved_list_num = 0; // init saved num - uint8_t index; - //avoid ble irk collision low probability - uint32_t generatedSeed = hal_sys_timer_get(); - for (uint8_t index = 0; index < sizeof(bt_addr); index++) - { - generatedSeed ^= (((uint32_t)(bt_addr[index])) << (hal_sys_timer_get() & 0xF)); - } - srand(generatedSeed); + uint8_t index; + // avoid ble irk collision low probability + uint32_t generatedSeed = hal_sys_timer_get(); + for (uint8_t index = 0; index < sizeof(bt_addr); index++) { + generatedSeed ^= + (((uint32_t)(bt_addr[index])) << (hal_sys_timer_get() & 0xF)); + } + srand(generatedSeed); - // generate a new IRK - for (index = 0; index < BLE_IRK_SIZE; index++) - { - pPairedBtInfo->self_info.ble_irk[index] = ( uint8_t )co_rand_word(); - } + // generate a new IRK + for (index = 0; index < BLE_IRK_SIZE; index++) { + pPairedBtInfo->self_info.ble_irk[index] = (uint8_t)co_rand_word(); + } } -static bool blerec_specific_value_prepare(const BleDeviceinfo *param_rec) -{ - // Preparations before adding new ble record: - // 1. If not existing. Check the record count. If it's BLE_RECORD_NUM, - // move 0-(BLE_RECORD_NUM-2) right side by one slot, to discard the last one and - // leave slot 0, decrease the record number. - // If it's smaller than BLE_RECORD_NUM, move 0-(count-1) right side by one slot, leave slot 0, - // don't change the record number. - // 2. If existing already and the location is entryToFree , move 0-(entryToFree-1) - // right side by one slot, leave slot 0. Decrease the record number for adding the new one. +static bool blerec_specific_value_prepare(const BleDeviceinfo *param_rec) { + // Preparations before adding new ble record: + // 1. If not existing. Check the record count. If it's BLE_RECORD_NUM, + // move 0-(BLE_RECORD_NUM-2) right side by one slot, to discard the last + // one and leave slot 0, decrease the record number. If it's smaller than + // BLE_RECORD_NUM, move 0-(count-1) right side by one slot, leave slot 0, + // don't change the record number. + // 2. If existing already and the location is entryToFree , move + // 0-(entryToFree-1) + // right side by one slot, leave slot 0. Decrease the record number for + // adding the new one. - bool isEntryExisting = false; - uint8_t entryToFree = 0; - NV_RECORD_PAIRED_BLE_DEV_INFO_T *dest_ptr; + bool isEntryExisting = false; + uint8_t entryToFree = 0; + NV_RECORD_PAIRED_BLE_DEV_INFO_T *dest_ptr; - dest_ptr = nvrecord_ble_p; - TRACE(3,"%s start search addr %p list_num=%d", __func__, dest_ptr, dest_ptr->saved_list_num); + dest_ptr = nvrecord_ble_p; + TRACE(3, "%s start search addr %p list_num=%d", __func__, dest_ptr, + dest_ptr->saved_list_num); - if (dest_ptr->saved_list_num > 0) - { - for (uint8_t i = 0; i < dest_ptr->saved_list_num; i++) - { - if (0 == memcmp(dest_ptr->ble_nv[i].peer_bleAddr, param_rec->peer_bleAddr, BLE_ADDR_SIZE)) - { - ble_trace(2,"%s Find the existing entry %d", __func__, i); - DUMP8("%02x ", ( uint8_t * )param_rec, sizeof(BleDeviceinfo)); - DUMP8("%02x ", ( uint8_t * )&dest_ptr->ble_nv[i], sizeof(BleDeviceinfo)); - if (!memcmp(( uint8_t * )param_rec, ( uint8_t * )&dest_ptr->ble_nv[i], sizeof(BleDeviceinfo))) - { - ble_trace(0,"The new coming BLE device info is the same as the recorded."); - return false; - } - memset(&(dest_ptr->ble_nv[i]), 0, sizeof(BleDeviceinfo)); - entryToFree = i; - dest_ptr->saved_list_num--; - isEntryExisting = true; - break; - } + if (dest_ptr->saved_list_num > 0) { + for (uint8_t i = 0; i < dest_ptr->saved_list_num; i++) { + if (0 == memcmp(dest_ptr->ble_nv[i].peer_bleAddr, param_rec->peer_bleAddr, + BLE_ADDR_SIZE)) { + ble_trace(2, "%s Find the existing entry %d", __func__, i); + DUMP8("%02x ", (uint8_t *)param_rec, sizeof(BleDeviceinfo)); + DUMP8("%02x ", (uint8_t *)&dest_ptr->ble_nv[i], sizeof(BleDeviceinfo)); + if (!memcmp((uint8_t *)param_rec, (uint8_t *)&dest_ptr->ble_nv[i], + sizeof(BleDeviceinfo))) { + ble_trace( + 0, "The new coming BLE device info is the same as the recorded."); + return false; } + memset(&(dest_ptr->ble_nv[i]), 0, sizeof(BleDeviceinfo)); + entryToFree = i; + dest_ptr->saved_list_num--; + isEntryExisting = true; + break; + } } - else - { - return true; - } - - if (!isEntryExisting) - { - if (BLE_RECORD_NUM == dest_ptr->saved_list_num) - { - TRACE(0,"<=====>blerec list is full,delete the oldest and add param_rec to list"); - for (uint8_t k = 0; k < BLE_RECORD_NUM - 1; k++) - { - memcpy(&(dest_ptr->ble_nv[BLE_RECORD_NUM - 1 - k]), - &(dest_ptr->ble_nv[BLE_RECORD_NUM - 2 - k]), - sizeof(BleDeviceinfo)); - } - dest_ptr->saved_list_num--; - } - else - { - for (uint8_t k = 0; k < dest_ptr->saved_list_num; k++) - { - memcpy(&(dest_ptr->ble_nv[dest_ptr->saved_list_num - k]), - &(dest_ptr->ble_nv[dest_ptr->saved_list_num - 1 - k]), - sizeof(BleDeviceinfo)); - } - } - } - else - { - for (uint8_t list_updata = 0; list_updata < entryToFree; list_updata++) - { - memcpy(&(dest_ptr->ble_nv[entryToFree - list_updata]), - &(dest_ptr->ble_nv[entryToFree - list_updata - 1]), - sizeof(BleDeviceinfo)); - } - } - + } else { return true; + } + + if (!isEntryExisting) { + if (BLE_RECORD_NUM == dest_ptr->saved_list_num) { + TRACE(0, "<=====>blerec list is full,delete the oldest and add param_rec " + "to list"); + for (uint8_t k = 0; k < BLE_RECORD_NUM - 1; k++) { + memcpy(&(dest_ptr->ble_nv[BLE_RECORD_NUM - 1 - k]), + &(dest_ptr->ble_nv[BLE_RECORD_NUM - 2 - k]), + sizeof(BleDeviceinfo)); + } + dest_ptr->saved_list_num--; + } else { + for (uint8_t k = 0; k < dest_ptr->saved_list_num; k++) { + memcpy(&(dest_ptr->ble_nv[dest_ptr->saved_list_num - k]), + &(dest_ptr->ble_nv[dest_ptr->saved_list_num - 1 - k]), + sizeof(BleDeviceinfo)); + } + } + } else { + for (uint8_t list_updata = 0; list_updata < entryToFree; list_updata++) { + memcpy(&(dest_ptr->ble_nv[entryToFree - list_updata]), + &(dest_ptr->ble_nv[entryToFree - list_updata - 1]), + sizeof(BleDeviceinfo)); + } + } + + return true; } -void nv_record_blerec_init(void) -{ +void nv_record_blerec_init(void) { + uint32_t lock = nv_record_pre_write_operation(); + if (NULL == nvrecord_ble_p) { + nvrecord_ble_p = &(nvrecord_extension_p->ble_pair_info); + if (!memcmp(nvrecord_ble_p->self_info.ble_addr, INVALID_ADDR, + BTIF_BD_ADDR_SIZE)) { + memcpy(nvrecord_ble_p->self_info.ble_addr, bt_get_ble_local_address(), + BTIF_BD_ADDR_SIZE); + } + } + nv_record_post_write_operation(lock); +} + +NV_RECORD_PAIRED_BLE_DEV_INFO_T *nv_record_blerec_get_ptr(void) { + return nvrecord_ble_p; +} + +void nv_record_blerec_get_local_irk(uint8_t *pIrk) { + memcpy(pIrk, nvrecord_ble_p->self_info.ble_irk, BLE_IRK_SIZE); +} + +bool nv_record_blerec_get_bd_addr_from_irk(uint8_t *pBdAddr, uint8_t *pIrk) { + if (nvrecord_ble_p->saved_list_num > 0) { + for (uint8_t index = 0; index < nvrecord_ble_p->saved_list_num; index++) { + if (!memcmp(pIrk, nvrecord_ble_p->ble_nv[index].IRK, BLE_IRK_SIZE)) { + memcpy(pBdAddr, nvrecord_ble_p->ble_nv[index].peer_bleAddr, + BLE_ADDR_SIZE); + return true; + } + } + return false; + } else { + return false; + } +} + +int nv_record_blerec_add(const BleDeviceinfo *param_rec) { + int nRet = 0; + + uint8_t isNeedToUpdateNv = true; + isNeedToUpdateNv = blerec_specific_value_prepare(param_rec); + + if (isNeedToUpdateNv) { uint32_t lock = nv_record_pre_write_operation(); - if (NULL == nvrecord_ble_p) - { - nvrecord_ble_p = &(nvrecord_extension_p->ble_pair_info); - if (!memcmp(nvrecord_ble_p->self_info.ble_addr, INVALID_ADDR, BTIF_BD_ADDR_SIZE)) - { - memcpy(nvrecord_ble_p->self_info.ble_addr, bt_get_ble_local_address(), BTIF_BD_ADDR_SIZE); - } - } + + // add device info into nv struct + memcpy(nvrecord_ble_p->ble_nv[0].peer_bleAddr, param_rec->peer_bleAddr, + BLE_ADDR_SIZE); // addr + nvrecord_ble_p->ble_nv[0].EDIV = param_rec->EDIV; // EDIV + memcpy(nvrecord_ble_p->ble_nv[0].RANDOM, param_rec->RANDOM, + BLE_ENC_RANDOM_SIZE); // RANDOM + memcpy(nvrecord_ble_p->ble_nv[0].LTK, param_rec->LTK, BLE_LTK_SIZE); // LTK + memcpy(nvrecord_ble_p->ble_nv[0].IRK, param_rec->IRK, BLE_IRK_SIZE); // IRK + nvrecord_ble_p->ble_nv[0].bonded = param_rec->bonded; // bond status + nvrecord_ble_p->saved_list_num++; // updata saved num nv_record_post_write_operation(lock); -} -NV_RECORD_PAIRED_BLE_DEV_INFO_T* nv_record_blerec_get_ptr(void) -{ - return nvrecord_ble_p; -} - -void nv_record_blerec_get_local_irk(uint8_t *pIrk) -{ - memcpy(pIrk, nvrecord_ble_p->self_info.ble_irk, BLE_IRK_SIZE); -} - -bool nv_record_blerec_get_bd_addr_from_irk(uint8_t *pBdAddr, uint8_t *pIrk) -{ - if (nvrecord_ble_p->saved_list_num > 0) - { - for (uint8_t index = 0; index < nvrecord_ble_p->saved_list_num; index++) - { - if (!memcmp(pIrk, nvrecord_ble_p->ble_nv[index].IRK, BLE_IRK_SIZE)) - { - memcpy(pBdAddr, nvrecord_ble_p->ble_nv[index].peer_bleAddr, BLE_ADDR_SIZE); - return true; - } - } - return false; - } - else - { - return false; - } -} - -int nv_record_blerec_add(const BleDeviceinfo *param_rec) -{ - int nRet = 0; - - uint8_t isNeedToUpdateNv = true; - isNeedToUpdateNv = blerec_specific_value_prepare(param_rec); - - if (isNeedToUpdateNv) - { - uint32_t lock = nv_record_pre_write_operation(); - - //add device info into nv struct - memcpy(nvrecord_ble_p->ble_nv[0].peer_bleAddr, param_rec->peer_bleAddr, BLE_ADDR_SIZE); //addr - nvrecord_ble_p->ble_nv[0].EDIV = param_rec->EDIV; //EDIV - memcpy(nvrecord_ble_p->ble_nv[0].RANDOM, param_rec->RANDOM, BLE_ENC_RANDOM_SIZE); //RANDOM - memcpy(nvrecord_ble_p->ble_nv[0].LTK, param_rec->LTK, BLE_LTK_SIZE); //LTK - memcpy(nvrecord_ble_p->ble_nv[0].IRK, param_rec->IRK, BLE_IRK_SIZE); //IRK - nvrecord_ble_p->ble_nv[0].bonded = param_rec->bonded; //bond status - nvrecord_ble_p->saved_list_num++; //updata saved num - nv_record_post_write_operation(lock); - - nv_record_update_runtime_userdata(); - nv_record_flash_flush(); - TRACE(2,"%s CURRENT BLE LIST NUM=%d", __func__, nvrecord_ble_p->saved_list_num); - } + nv_record_update_runtime_userdata(); + nv_record_flash_flush(); + TRACE(2, "%s CURRENT BLE LIST NUM=%d", __func__, + nvrecord_ble_p->saved_list_num); + } #ifdef ble_nv_debug - for (uint8_t k = 0; k < nvrecord_ble_p->saved_list_num; k++) - { - TRACE(0,"========================================="); - TRACE(1,"Num %d BLE record:", k); - TRACE(0,"BLE addr:"); - DUMP8("%02x ", ( uint8_t * )nvrecord_ble_p->ble_nv[k].peer_bleAddr, BLE_ADDR_SIZE); - TRACE(1,"NV EDIV %d and random is:", nvrecord_ble_p->ble_nv[k].EDIV); - DUMP8("%02x ", ( uint8_t * )nvrecord_ble_p->ble_nv[k].RANDOM, BLE_ENC_RANDOM_SIZE); - TRACE(0,"NV LTK:"); - DUMP8("%02x ", ( uint8_t * )nvrecord_ble_p->ble_nv[k].LTK, BLE_LTK_SIZE); - TRACE(0,"NV irk:"); - DUMP8("%02x ", ( uint8_t * )nvrecord_ble_p->ble_nv[k].IRK, BLE_IRK_SIZE); - } + for (uint8_t k = 0; k < nvrecord_ble_p->saved_list_num; k++) { + TRACE(0, "========================================="); + TRACE(1, "Num %d BLE record:", k); + TRACE(0, "BLE addr:"); + DUMP8("%02x ", (uint8_t *)nvrecord_ble_p->ble_nv[k].peer_bleAddr, + BLE_ADDR_SIZE); + TRACE(1, "NV EDIV %d and random is:", nvrecord_ble_p->ble_nv[k].EDIV); + DUMP8("%02x ", (uint8_t *)nvrecord_ble_p->ble_nv[k].RANDOM, + BLE_ENC_RANDOM_SIZE); + TRACE(0, "NV LTK:"); + DUMP8("%02x ", (uint8_t *)nvrecord_ble_p->ble_nv[k].LTK, BLE_LTK_SIZE); + TRACE(0, "NV irk:"); + DUMP8("%02x ", (uint8_t *)nvrecord_ble_p->ble_nv[k].IRK, BLE_IRK_SIZE); + } #endif - return nRet; + return nRet; } -uint8_t nv_record_ble_fill_irk(uint8_t *irkToFill) -{ - NV_RECORD_PAIRED_BLE_DEV_INFO_T *find_ptr = nvrecord_ble_p; +uint8_t nv_record_ble_fill_irk(uint8_t *irkToFill) { + NV_RECORD_PAIRED_BLE_DEV_INFO_T *find_ptr = nvrecord_ble_p; - if ((NULL == find_ptr) || (0 == find_ptr->saved_list_num)) - { - return 0; - } + if ((NULL == find_ptr) || (0 == find_ptr->saved_list_num)) { + return 0; + } - if (find_ptr->saved_list_num > 0) - { - for (uint8_t index = 0; index < find_ptr->saved_list_num; index++) - { - memcpy(irkToFill + index * BLE_IRK_SIZE, find_ptr->ble_nv[index].IRK, BLE_IRK_SIZE); - } - return find_ptr->saved_list_num; - } - else - { - return 0; + if (find_ptr->saved_list_num > 0) { + for (uint8_t index = 0; index < find_ptr->saved_list_num; index++) { + memcpy(irkToFill + index * BLE_IRK_SIZE, find_ptr->ble_nv[index].IRK, + BLE_IRK_SIZE); } + return find_ptr->saved_list_num; + } else { + return 0; + } } -//when master send encription req,if bonded,use ltk to bonding again(skip the pair step) -bool nv_record_ble_record_find_ltk_through_static_bd_addr(uint8_t *pBdAddr, uint8_t *ltk) -{ - NV_RECORD_PAIRED_BLE_DEV_INFO_T *find_ptr = nvrecord_ble_p; +// when master send encription req,if bonded,use ltk to bonding again(skip the +// pair step) +bool nv_record_ble_record_find_ltk_through_static_bd_addr(uint8_t *pBdAddr, + uint8_t *ltk) { + NV_RECORD_PAIRED_BLE_DEV_INFO_T *find_ptr = nvrecord_ble_p; - if ((NULL == find_ptr) || (0 == find_ptr->saved_list_num)) - { - TRACE(3,"%s find data failed, ptr:%x, list_num:%d", __func__, (uint32_t)find_ptr, find_ptr->saved_list_num); - return false; - } - - for (uint8_t find_index = 0; find_index < find_ptr->saved_list_num; find_index++) - { - if (!memcmp(find_ptr->ble_nv[find_index].peer_bleAddr, pBdAddr, BLE_ADDR_SIZE)) - { - ble_trace(2,"%s FIND LTK IN NV SUCCESS %p", __func__, find_ptr->ble_nv[find_index].LTK); - memcpy(ltk, find_ptr->ble_nv[find_index].LTK, BLE_LTK_SIZE); - return true; - } - } + if ((NULL == find_ptr) || (0 == find_ptr->saved_list_num)) { + TRACE(3, "%s find data failed, ptr:%x, list_num:%d", __func__, + (uint32_t)find_ptr, find_ptr->saved_list_num); return false; + } + + for (uint8_t find_index = 0; find_index < find_ptr->saved_list_num; + find_index++) { + if (!memcmp(find_ptr->ble_nv[find_index].peer_bleAddr, pBdAddr, + BLE_ADDR_SIZE)) { + ble_trace(2, "%s FIND LTK IN NV SUCCESS %p", __func__, + find_ptr->ble_nv[find_index].LTK); + memcpy(ltk, find_ptr->ble_nv[find_index].LTK, BLE_LTK_SIZE); + return true; + } + } + return false; } -bool nv_record_ble_record_Once_a_device_has_been_bonded(void) -{ - NV_RECORD_PAIRED_BLE_DEV_INFO_T *find_ptr = nvrecord_ble_p; +bool nv_record_ble_record_Once_a_device_has_been_bonded(void) { + NV_RECORD_PAIRED_BLE_DEV_INFO_T *find_ptr = nvrecord_ble_p; - if ((NULL == find_ptr) || (0 == find_ptr->saved_list_num)) - { - return false; - } - - for (uint8_t find_index = 0; find_index < find_ptr->saved_list_num; find_index++) - { - if (find_ptr->ble_nv[find_index].bonded == true) - { - return true; - } - } + if ((NULL == find_ptr) || (0 == find_ptr->saved_list_num)) { return false; + } + + for (uint8_t find_index = 0; find_index < find_ptr->saved_list_num; + find_index++) { + if (find_ptr->ble_nv[find_index].bonded == true) { + return true; + } + } + return false; } -void nv_record_ble_delete_entry(uint8_t *pBdAddr) -{ - NV_RECORD_PAIRED_BLE_DEV_INFO_T *find_ptr = nvrecord_ble_p; +void nv_record_ble_delete_entry(uint8_t *pBdAddr) { + NV_RECORD_PAIRED_BLE_DEV_INFO_T *find_ptr = nvrecord_ble_p; - if ((NULL == find_ptr) || (0 == find_ptr->saved_list_num)) - { - return; + if ((NULL == find_ptr) || (0 == find_ptr->saved_list_num)) { + return; + } + + int8_t indexToDelete = -1; + + for (uint8_t find_index = 0; find_index < find_ptr->saved_list_num; + find_index++) { + if (!memcmp(find_ptr->ble_nv[find_index].peer_bleAddr, pBdAddr, + BLE_ADDR_SIZE)) { + indexToDelete = find_index; + break; + } + } + + if (indexToDelete >= 0) { + uint32_t lock = nv_record_pre_write_operation(); + + uint8_t index; + for (index = indexToDelete; index < find_ptr->saved_list_num - 1; index++) { + memcpy(&(find_ptr->ble_nv[index]), &(find_ptr->ble_nv[index + 1]), + sizeof(BleDeviceinfo)); } - int8_t indexToDelete = -1; + memset((uint8_t *)&(find_ptr->ble_nv[index]), 0, sizeof(BleDeviceinfo)); + find_ptr->saved_list_num--; + nv_record_update_runtime_userdata(); - for (uint8_t find_index = 0; find_index < find_ptr->saved_list_num; find_index++) - { - if (!memcmp(find_ptr->ble_nv[find_index].peer_bleAddr, pBdAddr, BLE_ADDR_SIZE)) - { - indexToDelete = find_index; - break; - } - } - - if (indexToDelete >= 0) - { - uint32_t lock = nv_record_pre_write_operation(); - - uint8_t index; - for (index = indexToDelete; index < find_ptr->saved_list_num - 1; index++) - { - memcpy(&(find_ptr->ble_nv[index]), - &(find_ptr->ble_nv[index + 1]), - sizeof(BleDeviceinfo)); - } - - memset(( uint8_t * )&(find_ptr->ble_nv[index]), 0, sizeof(BleDeviceinfo)); - find_ptr->saved_list_num--; - nv_record_update_runtime_userdata(); - - nv_record_post_write_operation(lock); - } + nv_record_post_write_operation(lock); + } } #ifdef TWS_SYSTEM_ENABLED -static bool tws_use_same_ble_addr(uint8_t *peer_ble_addr) -{ - TRACE(1,"[%s] peer addr:", __func__); - DUMP8("%x ", peer_ble_addr, BTIF_BD_ADDR_SIZE); +static bool tws_use_same_ble_addr(uint8_t *peer_ble_addr) { + TRACE(1, "[%s] peer addr:", __func__); + DUMP8("%x ", peer_ble_addr, BTIF_BD_ADDR_SIZE); - NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); + NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); - if (!memcmp(pNvExtRec->ble_pair_info.self_info.ble_addr, peer_ble_addr, BTIF_BD_ADDR_SIZE)) - { - return true; - } + if (!memcmp(pNvExtRec->ble_pair_info.self_info.ble_addr, peer_ble_addr, + BTIF_BD_ADDR_SIZE)) { + return true; + } - return false; + return false; } -void nv_record_extension_update_tws_ble_info(NV_RECORD_PAIRED_BLE_DEV_INFO_T *info) -{ - ASSERT(info, "null pointer received in [%s]", __func__); +void nv_record_extension_update_tws_ble_info( + NV_RECORD_PAIRED_BLE_DEV_INFO_T *info) { + ASSERT(info, "null pointer received in [%s]", __func__); - bool isNvExtentionPendingForUpdate = false; - NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); + bool isNvExtentionPendingForUpdate = false; + NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); - /// disable the MPU protection for write operation - uint32_t lock = nv_record_pre_write_operation(); + /// disable the MPU protection for write operation + uint32_t lock = nv_record_pre_write_operation(); - if (tws_use_same_ble_addr(info->self_info.ble_addr)) - { - if (memcmp(&pNvExtRec->ble_pair_info.self_info, &info->self_info, sizeof(BLE_BASIC_INFO_T))) - { - TRACE(0,"save the peer ble info to self_info"); + if (tws_use_same_ble_addr(info->self_info.ble_addr)) { + if (memcmp(&pNvExtRec->ble_pair_info.self_info, &info->self_info, + sizeof(BLE_BASIC_INFO_T))) { + TRACE(0, "save the peer ble info to self_info"); - memcpy(&pNvExtRec->ble_pair_info.self_info, &info->self_info, sizeof(BLE_BASIC_INFO_T)); - nv_record_extension_update(); - isNvExtentionPendingForUpdate = true; - } + memcpy(&pNvExtRec->ble_pair_info.self_info, &info->self_info, + sizeof(BLE_BASIC_INFO_T)); + nv_record_extension_update(); + isNvExtentionPendingForUpdate = true; } + } - if (memcmp(&pNvExtRec->tws_info.ble_info, &info->self_info, sizeof(BLE_BASIC_INFO_T))) - { - TRACE(0,"save the peer ble info to tws_info"); + if (memcmp(&pNvExtRec->tws_info.ble_info, &info->self_info, + sizeof(BLE_BASIC_INFO_T))) { + TRACE(0, "save the peer ble info to tws_info"); - memcpy(&pNvExtRec->tws_info.ble_info, &info->self_info, sizeof(BLE_BASIC_INFO_T)); - nv_record_extension_update(); - isNvExtentionPendingForUpdate = true; - } + memcpy(&pNvExtRec->tws_info.ble_info, &info->self_info, + sizeof(BLE_BASIC_INFO_T)); + nv_record_extension_update(); + isNvExtentionPendingForUpdate = true; + } - if (isNvExtentionPendingForUpdate) - { - nv_record_flash_flush(); - } + if (isNvExtentionPendingForUpdate) { + nv_record_flash_flush(); + } - /// enable the MPU protection after the write operation - nv_record_post_write_operation(lock); + /// enable the MPU protection after the write operation + nv_record_post_write_operation(lock); - TRACE(0,"peer addr:"); - DUMP8("0x%02x ", pNvExtRec->tws_info.ble_info.ble_addr,BTIF_BD_ADDR_SIZE); - TRACE(0,"peer irk"); - DUMP8("0x%02x ", pNvExtRec->tws_info.ble_info.ble_irk, BLE_IRK_SIZE); + TRACE(0, "peer addr:"); + DUMP8("0x%02x ", pNvExtRec->tws_info.ble_info.ble_addr, BTIF_BD_ADDR_SIZE); + TRACE(0, "peer irk"); + DUMP8("0x%02x ", pNvExtRec->tws_info.ble_info.ble_irk, BLE_IRK_SIZE); } -void nv_record_tws_exchange_ble_info(void) -{ - TRACE(1,"[%s]+++", __func__); - NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); - uint8_t ble_address[6] = {0, 0, 0, 0, 0, 0}; +void nv_record_tws_exchange_ble_info(void) { + TRACE(1, "[%s]+++", __func__); + NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); + uint8_t ble_address[6] = {0, 0, 0, 0, 0, 0}; - if (tws_use_same_ble_addr(pNvExtRec->tws_info.ble_info.ble_addr)) - { - TRACE(0,"tws use same ble addr"); - return; - } + if (tws_use_same_ble_addr(pNvExtRec->tws_info.ble_info.ble_addr)) { + TRACE(0, "tws use same ble addr"); + return; + } - if (!memcmp(pNvExtRec->tws_info.ble_info.ble_addr, ble_address, BTIF_BD_ADDR_SIZE)) - { - TRACE(0,"don't have tws ble addr"); - return; - } + if (!memcmp(pNvExtRec->tws_info.ble_info.ble_addr, ble_address, + BTIF_BD_ADDR_SIZE)) { + TRACE(0, "don't have tws ble addr"); + return; + } - /// disable the MPU protection for write operation - uint32_t lock = nv_record_pre_write_operation(); + /// disable the MPU protection for write operation + uint32_t lock = nv_record_pre_write_operation(); #ifdef BLE_USE_RPA - uint8_t temp_ble_irk[BLE_IRK_SIZE]; - memcpy(temp_ble_irk, pNvExtRec->ble_pair_info.self_info.ble_irk, BLE_IRK_SIZE); - memcpy(pNvExtRec->ble_pair_info.self_info.ble_irk, pNvExtRec->tws_info.ble_info.ble_irk, BLE_IRK_SIZE); - memcpy(pNvExtRec->tws_info.ble_info.ble_irk, temp_ble_irk, BLE_IRK_SIZE); - TRACE(0,"current local ble irk:"); - DUMP8("0x%02x ", pNvExtRec->ble_pair_info.self_info.ble_irk, BLE_IRK_SIZE); + uint8_t temp_ble_irk[BLE_IRK_SIZE]; + memcpy(temp_ble_irk, pNvExtRec->ble_pair_info.self_info.ble_irk, + BLE_IRK_SIZE); + memcpy(pNvExtRec->ble_pair_info.self_info.ble_irk, + pNvExtRec->tws_info.ble_info.ble_irk, BLE_IRK_SIZE); + memcpy(pNvExtRec->tws_info.ble_info.ble_irk, temp_ble_irk, BLE_IRK_SIZE); + TRACE(0, "current local ble irk:"); + DUMP8("0x%02x ", pNvExtRec->ble_pair_info.self_info.ble_irk, BLE_IRK_SIZE); #else - uint8_t temp_ble_addr[BTIF_BD_ADDR_SIZE]; - memcpy(temp_ble_addr, pNvExtRec->ble_pair_info.self_info.ble_addr, BTIF_BD_ADDR_SIZE); - memcpy(pNvExtRec->ble_pair_info.self_info.ble_addr, pNvExtRec->tws_info.ble_info.ble_addr, BTIF_BD_ADDR_SIZE); - memcpy(pNvExtRec->tws_info.ble_info.ble_addr, temp_ble_addr, BTIF_BD_ADDR_SIZE); - memcpy(bt_get_ble_local_address(), pNvExtRec->ble_pair_info.self_info.ble_addr, BTIF_BD_ADDR_SIZE); - TRACE(0,"current local ble addr:"); - DUMP8("0x%02x ", pNvExtRec->ble_pair_info.self_info.ble_addr, BTIF_BD_ADDR_SIZE); + uint8_t temp_ble_addr[BTIF_BD_ADDR_SIZE]; + memcpy(temp_ble_addr, pNvExtRec->ble_pair_info.self_info.ble_addr, + BTIF_BD_ADDR_SIZE); + memcpy(pNvExtRec->ble_pair_info.self_info.ble_addr, + pNvExtRec->tws_info.ble_info.ble_addr, BTIF_BD_ADDR_SIZE); + memcpy(pNvExtRec->tws_info.ble_info.ble_addr, temp_ble_addr, + BTIF_BD_ADDR_SIZE); + memcpy(bt_get_ble_local_address(), + pNvExtRec->ble_pair_info.self_info.ble_addr, BTIF_BD_ADDR_SIZE); + TRACE(0, "current local ble addr:"); + DUMP8("0x%02x ", pNvExtRec->ble_pair_info.self_info.ble_addr, + BTIF_BD_ADDR_SIZE); - bt_set_ble_local_address(pNvExtRec->ble_pair_info.self_info.ble_addr); + bt_set_ble_local_address(pNvExtRec->ble_pair_info.self_info.ble_addr); #endif - nv_record_extension_update(); + nv_record_extension_update(); - /// enable the MPU protection after the write operation - nv_record_post_write_operation(lock); + /// enable the MPU protection after the write operation + nv_record_post_write_operation(lock); - TRACE(1,"[%s]---", __func__); + TRACE(1, "[%s]---", __func__); } -uint8_t *nv_record_tws_get_self_ble_info(void) -{ - TRACE(1,"[%s]+++", __func__); - NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); +uint8_t *nv_record_tws_get_self_ble_info(void) { + TRACE(1, "[%s]+++", __func__); + NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); - TRACE(0,"current local ble addr:"); - DUMP8("0x%02x ", pNvExtRec->ble_pair_info.self_info.ble_addr, BTIF_BD_ADDR_SIZE); + TRACE(0, "current local ble addr:"); + DUMP8("0x%02x ", pNvExtRec->ble_pair_info.self_info.ble_addr, + BTIF_BD_ADDR_SIZE); - TRACE(1,"[%s]---", __func__); - return pNvExtRec->ble_pair_info.self_info.ble_addr; + TRACE(1, "[%s]---", __func__); + return pNvExtRec->ble_pair_info.self_info.ble_addr; } -uint8_t *nv_record_tws_get_peer_ble_addr(void) -{ - TRACE(1,"[%s]+++", __func__); - NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); +uint8_t *nv_record_tws_get_peer_ble_addr(void) { + TRACE(1, "[%s]+++", __func__); + NV_EXTENSION_RECORD_T *pNvExtRec = nv_record_get_extension_entry_ptr(); - TRACE(0,"current peer ble addr:"); - DUMP8("0x%02x ", pNvExtRec->ble_pair_info.ble_nv[0].peer_bleAddr, BTIF_BD_ADDR_SIZE); + TRACE(0, "current peer ble addr:"); + DUMP8("0x%02x ", pNvExtRec->ble_pair_info.ble_nv[0].peer_bleAddr, + BTIF_BD_ADDR_SIZE); - TRACE(1,"[%s]---", __func__); - return pNvExtRec->ble_pair_info.ble_nv[0].peer_bleAddr; + TRACE(1, "[%s]---", __func__); + return pNvExtRec->ble_pair_info.ble_nv[0].peer_bleAddr; } #endif -#endif //#if defined(NEW_NV_RECORD_ENABLED) +#endif //#if defined(NEW_NV_RECORD_ENABLED) diff --git a/services/nv_section/userdata_section/nvrecord_bt.c b/services/nv_section/userdata_section/nvrecord_bt.c index 3eeb604..e9a95da 100644 --- a/services/nv_section/userdata_section/nvrecord_bt.c +++ b/services/nv_section/userdata_section/nvrecord_bt.c @@ -14,80 +14,72 @@ * ****************************************************************************/ #if defined(NEW_NV_RECORD_ENABLED) -#include -#include -#include -#include "nvrecord_extension.h" #include "nvrecord_bt.h" #include "hal_trace.h" +#include "nvrecord_extension.h" +#include +#include +#include -void ram_record_ddbrec_init(void) -{ +void ram_record_ddbrec_init(void) {} + +void nvrecord_rebuild_paired_bt_dev_info( + NV_RECORD_PAIRED_BT_DEV_INFO_T *pPairedBtInfo) { + memset((uint8_t *)pPairedBtInfo, 0, sizeof(NV_RECORD_PAIRED_BT_DEV_INFO_T)); + + pPairedBtInfo->pairedDevNum = 0; } -void nvrecord_rebuild_paired_bt_dev_info(NV_RECORD_PAIRED_BT_DEV_INFO_T* pPairedBtInfo) -{ - memset((uint8_t *)pPairedBtInfo, 0, sizeof(NV_RECORD_PAIRED_BT_DEV_INFO_T)); +void nv_record_btdevicerecord_set_a2dp_profile_active_state( + btdevice_profile *device_plf, bool isActive) { + uint32_t lock = nv_record_pre_write_operation(); + if (isActive != device_plf->a2dp_act) { + nv_record_update_runtime_userdata(); + } + device_plf->a2dp_act = isActive; - pPairedBtInfo->pairedDevNum = 0; + nv_record_post_write_operation(lock); } -void nv_record_btdevicerecord_set_a2dp_profile_active_state(btdevice_profile* device_plf, bool isActive) -{ - uint32_t lock = nv_record_pre_write_operation(); - if (isActive != device_plf->a2dp_act) - { - nv_record_update_runtime_userdata(); - } - device_plf->a2dp_act = isActive; +void nv_record_btdevicerecord_set_hfp_profile_active_state( + btdevice_profile *device_plf, bool isActive) { + uint32_t lock = nv_record_pre_write_operation(); + if (isActive != device_plf->hfp_act) { + nv_record_update_runtime_userdata(); + } + device_plf->hfp_act = isActive; - nv_record_post_write_operation(lock); + nv_record_post_write_operation(lock); } -void nv_record_btdevicerecord_set_hfp_profile_active_state(btdevice_profile* device_plf, bool isActive) -{ - uint32_t lock = nv_record_pre_write_operation(); - if (isActive != device_plf->hfp_act) - { - nv_record_update_runtime_userdata(); - } - device_plf->hfp_act = isActive; +void nv_record_btdevicerecord_set_hsp_profile_active_state( + btdevice_profile *device_plf, bool isActive) { + uint32_t lock = nv_record_pre_write_operation(); + if (isActive != device_plf->hsp_act) { + nv_record_update_runtime_userdata(); + } + device_plf->hsp_act = isActive; - nv_record_post_write_operation(lock); + nv_record_post_write_operation(lock); } -void nv_record_btdevicerecord_set_hsp_profile_active_state(btdevice_profile* device_plf, bool isActive) -{ - uint32_t lock = nv_record_pre_write_operation(); - if (isActive != device_plf->hsp_act) - { - nv_record_update_runtime_userdata(); - } - device_plf->hsp_act = isActive; +void nv_record_btdevicerecord_set_a2dp_profile_codec( + btdevice_profile *device_plf, uint8_t a2dpCodec) { + uint32_t lock = nv_record_pre_write_operation(); + if (a2dpCodec != device_plf->a2dp_codectype) { + nv_record_update_runtime_userdata(); + } + device_plf->a2dp_codectype = a2dpCodec; - nv_record_post_write_operation(lock); + nv_record_post_write_operation(lock); } -void nv_record_btdevicerecord_set_a2dp_profile_codec(btdevice_profile* device_plf, uint8_t a2dpCodec) -{ - uint32_t lock = nv_record_pre_write_operation(); - if (a2dpCodec != device_plf->a2dp_codectype) - { - nv_record_update_runtime_userdata(); - } - device_plf->a2dp_codectype = a2dpCodec; +int nv_record_get_paired_dev_count(void) { + if (NULL == nvrecord_extension_p) { + return 0; + } - nv_record_post_write_operation(lock); -} - -int nv_record_get_paired_dev_count(void) -{ - if (NULL == nvrecord_extension_p) - { - return 0; - } - - return nvrecord_extension_p->bt_pair_info.pairedDevNum; + return nvrecord_extension_p->bt_pair_info.pairedDevNum; } /* @@ -97,410 +89,377 @@ return: 1: only 1 paired dev,store@record1. 2: get 2 paired dev.notice:record1 is the latest record. */ -int nv_record_enum_latest_two_paired_dev(btif_device_record_t* record1,btif_device_record_t* record2) -{ - if((NULL == record1) || (NULL == record2) || (NULL == nvrecord_extension_p)) - { - return -1; - } +int nv_record_enum_latest_two_paired_dev(btif_device_record_t *record1, + btif_device_record_t *record2) { + if ((NULL == record1) || (NULL == record2) || + (NULL == nvrecord_extension_p)) { + return -1; + } - if (nvrecord_extension_p->bt_pair_info.pairedDevNum > 0) - { - if (1 == nvrecord_extension_p->bt_pair_info.pairedDevNum) - { - memcpy((uint8_t *)record1, (uint8_t *)&(nvrecord_extension_p->bt_pair_info.pairedBtDevInfo[0]), - sizeof(btif_device_record_t)); - return 1; - } - else - { - memcpy((uint8_t *)record1, (uint8_t *)&(nvrecord_extension_p->bt_pair_info.pairedBtDevInfo[0]), - sizeof(btif_device_record_t)); - memcpy((uint8_t *)record2, (uint8_t *)&(nvrecord_extension_p->bt_pair_info.pairedBtDevInfo[1]), - sizeof(btif_device_record_t)); - return 2; - } - } - else - { - return 0; + if (nvrecord_extension_p->bt_pair_info.pairedDevNum > 0) { + if (1 == nvrecord_extension_p->bt_pair_info.pairedDevNum) { + memcpy( + (uint8_t *)record1, + (uint8_t *)&(nvrecord_extension_p->bt_pair_info.pairedBtDevInfo[0]), + sizeof(btif_device_record_t)); + return 1; + } else { + memcpy( + (uint8_t *)record1, + (uint8_t *)&(nvrecord_extension_p->bt_pair_info.pairedBtDevInfo[0]), + sizeof(btif_device_record_t)); + memcpy( + (uint8_t *)record2, + (uint8_t *)&(nvrecord_extension_p->bt_pair_info.pairedBtDevInfo[1]), + sizeof(btif_device_record_t)); + return 2; } + } else { + return 0; + } } -static void nv_record_print_dev_record(const btif_device_record_t* record) -{ - TRACE(0,"nv record bdAddr = "); - DUMP8("%02x ",record->bdAddr.address,sizeof(record->bdAddr.address)); - TRACE(0,"record_trusted = "); - DUMP8("%d ",&record->trusted,sizeof((uint8_t)record->trusted)); - TRACE(0,"record_linkKey = "); - DUMP8("%02x ",record->linkKey,sizeof(record->linkKey)); - TRACE(0,"record_keyType = "); - DUMP8("%x ",&record->keyType,sizeof(record->keyType)); - TRACE(0,"record_pinLen = "); - DUMP8("%x ",&record->pinLen,sizeof(record->pinLen)); +static void nv_record_print_dev_record(const btif_device_record_t *record) { + TRACE(0, "nv record bdAddr = "); + DUMP8("%02x ", record->bdAddr.address, sizeof(record->bdAddr.address)); + TRACE(0, "record_trusted = "); + DUMP8("%d ", &record->trusted, sizeof((uint8_t)record->trusted)); + TRACE(0, "record_linkKey = "); + DUMP8("%02x ", record->linkKey, sizeof(record->linkKey)); + TRACE(0, "record_keyType = "); + DUMP8("%x ", &record->keyType, sizeof(record->keyType)); + TRACE(0, "record_pinLen = "); + DUMP8("%x ", &record->pinLen, sizeof(record->pinLen)); } -void nv_record_all_ddbrec_print(void) -{ - if (NULL == nvrecord_extension_p) - { - TRACE(0,"No BT paired dev."); - return; - } +void nv_record_all_ddbrec_print(void) { + if (NULL == nvrecord_extension_p) { + TRACE(0, "No BT paired dev."); + return; + } - if (nvrecord_extension_p->bt_pair_info.pairedDevNum > 0) - { - for(uint8_t tmp_i=0; tmp_i < nvrecord_extension_p->bt_pair_info.pairedDevNum; tmp_i++) - { - btif_device_record_t record; - bt_status_t ret_status; - ret_status = nv_record_enum_dev_records(tmp_i, &record); - if (BT_STS_SUCCESS == ret_status) - { - nv_record_print_dev_record(&record); - } - } - } - else - { - TRACE(0,"No BT paired dev."); + if (nvrecord_extension_p->bt_pair_info.pairedDevNum > 0) { + for (uint8_t tmp_i = 0; + tmp_i < nvrecord_extension_p->bt_pair_info.pairedDevNum; tmp_i++) { + btif_device_record_t record; + bt_status_t ret_status; + ret_status = nv_record_enum_dev_records(tmp_i, &record); + if (BT_STS_SUCCESS == ret_status) { + nv_record_print_dev_record(&record); + } } + } else { + TRACE(0, "No BT paired dev."); + } } /* this function should be surrounded by OS_LockStack and OS_UnlockStack when call. */ -bt_status_t nv_record_enum_dev_records(unsigned short index,btif_device_record_t* record) -{ - btif_device_record_t *recaddr = NULL; +bt_status_t nv_record_enum_dev_records(unsigned short index, + btif_device_record_t *record) { + btif_device_record_t *recaddr = NULL; - if((index >= nvrecord_extension_p->bt_pair_info.pairedDevNum) || (NULL == nvrecord_extension_p)) - { - return BT_STS_FAILED; - } + if ((index >= nvrecord_extension_p->bt_pair_info.pairedDevNum) || + (NULL == nvrecord_extension_p)) { + return BT_STS_FAILED; + } - recaddr = (btif_device_record_t *)&(nvrecord_extension_p->bt_pair_info.pairedBtDevInfo[index].record); - memcpy(record, recaddr, sizeof(btif_device_record_t)); - nv_record_print_dev_record(record); - return BT_STS_SUCCESS; + recaddr = (btif_device_record_t *)&( + nvrecord_extension_p->bt_pair_info.pairedBtDevInfo[index].record); + memcpy(record, recaddr, sizeof(btif_device_record_t)); + nv_record_print_dev_record(record); + return BT_STS_SUCCESS; } -static int8_t nv_record_get_bt_pairing_info_index(const uint8_t* btAddr) -{ - NV_RECORD_PAIRED_BT_DEV_INFO_T* pBtDevInfo = - (NV_RECORD_PAIRED_BT_DEV_INFO_T *)(&(nvrecord_extension_p->bt_pair_info)); +static int8_t nv_record_get_bt_pairing_info_index(const uint8_t *btAddr) { + NV_RECORD_PAIRED_BT_DEV_INFO_T *pBtDevInfo = + (NV_RECORD_PAIRED_BT_DEV_INFO_T *)(&(nvrecord_extension_p->bt_pair_info)); - for (uint8_t index = 0; index < pBtDevInfo->pairedDevNum; index++) - { - if (!memcmp(pBtDevInfo->pairedBtDevInfo[index].record.bdAddr.address, - btAddr, BTIF_BD_ADDR_SIZE)) - { - return (int8_t)index; - } + for (uint8_t index = 0; index < pBtDevInfo->pairedDevNum; index++) { + if (!memcmp(pBtDevInfo->pairedBtDevInfo[index].record.bdAddr.address, + btAddr, BTIF_BD_ADDR_SIZE)) { + return (int8_t)index; } + } - return -1; + return -1; } /********************************************** this function should be surrounded by OS_LockStack and OS_UnlockStack when call. **********************************************/ -static bt_status_t POSSIBLY_UNUSED nv_record_ddbrec_add(const btif_device_record_t* param_rec) -{ - if ((NULL == param_rec) || (NULL == nvrecord_extension_p)) - { - return BT_STS_FAILED; +static bt_status_t POSSIBLY_UNUSED +nv_record_ddbrec_add(const btif_device_record_t *param_rec) { + if ((NULL == param_rec) || (NULL == nvrecord_extension_p)) { + return BT_STS_FAILED; + } + + uint32_t lock = nv_record_pre_write_operation(); + + bool isFlushNv = false; + + // try to find the entry + int8_t indexOfEntry = -1; + NV_RECORD_PAIRED_BT_DEV_INFO_T *pBtDevInfo = + (NV_RECORD_PAIRED_BT_DEV_INFO_T *)(&(nvrecord_extension_p->bt_pair_info)); + indexOfEntry = nv_record_get_bt_pairing_info_index(param_rec->bdAddr.address); + + if (-1 == indexOfEntry) { + // don't exist, need to add to the head of the entry list + if (MAX_BT_PAIRED_DEVICE_COUNT == pBtDevInfo->pairedDevNum) { + for (uint8_t k = 0; k < MAX_BT_PAIRED_DEVICE_COUNT - 1; k++) { + memcpy((uint8_t *)&( + pBtDevInfo + ->pairedBtDevInfo[MAX_BT_PAIRED_DEVICE_COUNT - 1 - k]), + (uint8_t *)&( + pBtDevInfo + ->pairedBtDevInfo[MAX_BT_PAIRED_DEVICE_COUNT - 2 - k]), + sizeof(nvrec_btdevicerecord)); + } + pBtDevInfo->pairedDevNum--; + } else { + for (uint8_t k = 0; k < pBtDevInfo->pairedDevNum; k++) { + memcpy( + (uint8_t *)&( + pBtDevInfo->pairedBtDevInfo[pBtDevInfo->pairedDevNum - k]), + (uint8_t *)&( + pBtDevInfo->pairedBtDevInfo[pBtDevInfo->pairedDevNum - 1 - k]), + sizeof(nvrec_btdevicerecord)); + } } - uint32_t lock = nv_record_pre_write_operation(); - - bool isFlushNv = false; - - // try to find the entry - int8_t indexOfEntry = -1; - NV_RECORD_PAIRED_BT_DEV_INFO_T* pBtDevInfo = - (NV_RECORD_PAIRED_BT_DEV_INFO_T *)(&(nvrecord_extension_p->bt_pair_info)); - indexOfEntry = nv_record_get_bt_pairing_info_index(param_rec->bdAddr.address); - - if (-1 == indexOfEntry) - { - // don't exist, need to add to the head of the entry list - if (MAX_BT_PAIRED_DEVICE_COUNT == pBtDevInfo->pairedDevNum) - { - for (uint8_t k = 0; k < MAX_BT_PAIRED_DEVICE_COUNT - 1; k++) - { - memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[MAX_BT_PAIRED_DEVICE_COUNT - 1 - k]), - (uint8_t *)&(pBtDevInfo->pairedBtDevInfo[MAX_BT_PAIRED_DEVICE_COUNT - 2 - k]), - sizeof(nvrec_btdevicerecord)); - } - pBtDevInfo->pairedDevNum--; - } - else - { - for (uint8_t k = 0; k < pBtDevInfo->pairedDevNum; k++) - { - memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[pBtDevInfo->pairedDevNum - k]), - (uint8_t *)&(pBtDevInfo->pairedBtDevInfo[pBtDevInfo->pairedDevNum - 1 - k]), - sizeof(nvrec_btdevicerecord)); - } - } - - // fill the default value - nvrec_btdevicerecord* nvrec_pool_record = &(pBtDevInfo->pairedBtDevInfo[0]); - memcpy((uint8_t *)&(nvrec_pool_record->record), (uint8_t *)param_rec, - sizeof(btif_device_record_t)); - nvrec_pool_record->device_vol.a2dp_vol = NVRAM_ENV_STREAM_VOLUME_A2DP_VOL_DEFAULT; - nvrec_pool_record->device_vol.hfp_vol = NVRAM_ENV_STREAM_VOLUME_HFP_VOL_DEFAULT; - nvrec_pool_record->device_plf.hfp_act = false; - nvrec_pool_record->device_plf.hsp_act = false; - nvrec_pool_record->device_plf.a2dp_act = false; + // fill the default value + nvrec_btdevicerecord *nvrec_pool_record = &(pBtDevInfo->pairedBtDevInfo[0]); + memcpy((uint8_t *)&(nvrec_pool_record->record), (uint8_t *)param_rec, + sizeof(btif_device_record_t)); + nvrec_pool_record->device_vol.a2dp_vol = + NVRAM_ENV_STREAM_VOLUME_A2DP_VOL_DEFAULT; + nvrec_pool_record->device_vol.hfp_vol = + NVRAM_ENV_STREAM_VOLUME_HFP_VOL_DEFAULT; + nvrec_pool_record->device_plf.hfp_act = false; + nvrec_pool_record->device_plf.hsp_act = false; + nvrec_pool_record->device_plf.a2dp_act = false; #ifdef BTIF_DIP_DEVICE - nvrec_pool_record->vend_id = 0; - nvrec_pool_record->vend_id_source = 0; + nvrec_pool_record->vend_id = 0; + nvrec_pool_record->vend_id_source = 0; #endif - pBtDevInfo->pairedDevNum++; + pBtDevInfo->pairedDevNum++; + + // need to flush the nv record + isFlushNv = true; + } else { + // exist + // check whether it's already at the head + // if not, move it to the head + if (indexOfEntry > 0) { + nvrec_btdevicerecord record; + memcpy((uint8_t *)&record, + (uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry]), + sizeof(record)); + + // if not, move it to the head + for (uint8_t k = 0; k < indexOfEntry; k++) { + memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry - k]), + (uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry - 1 - k]), + sizeof(nvrec_btdevicerecord)); + } + + memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[0]), (uint8_t *)&record, + sizeof(record)); + + // update the link info + memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[0].record), + (uint8_t *)param_rec, sizeof(btif_device_record_t)); + + // need to flush the nv record + isFlushNv = true; + } + // else, check whether the link info needs to be updated + else { + if (memcmp((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[0].record), + (uint8_t *)param_rec, sizeof(btif_device_record_t))) { + // update the link info + memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[0].record), + (uint8_t *)param_rec, sizeof(btif_device_record_t)); // need to flush the nv record isFlushNv = true; + } } - else - { - // exist - // check whether it's already at the head - // if not, move it to the head - if (indexOfEntry > 0) - { - nvrec_btdevicerecord record; - memcpy((uint8_t *)&record, (uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry]), - sizeof(record)); + } - // if not, move it to the head - for (uint8_t k = 0; k < indexOfEntry; k++) - { - memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry - k]), - (uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry - 1 - k]), - sizeof(nvrec_btdevicerecord)); - } - - memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[0]), (uint8_t *)&record, - sizeof(record)); - - // update the link info - memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[0].record), (uint8_t *)param_rec, - sizeof(btif_device_record_t)); - - // need to flush the nv record - isFlushNv = true; - } - // else, check whether the link info needs to be updated - else - { - if (memcmp((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[0].record), - (uint8_t *)param_rec, sizeof(btif_device_record_t))) - { - // update the link info - memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[0].record), (uint8_t *)param_rec, - sizeof(btif_device_record_t)); - - // need to flush the nv record - isFlushNv = true; - } - } - } - - TRACE(1,"paired Bt dev:%d", pBtDevInfo->pairedDevNum); - TRACE(1,"Is to flush nv: %d", isFlushNv); - nv_record_all_ddbrec_print(); - - if (isFlushNv) - { - nv_record_update_runtime_userdata(); - } - - nv_record_post_write_operation(lock); - - return BT_STS_SUCCESS; -} - -/* -this function should be surrounded by OS_LockStack and OS_UnlockStack when call. -*/ -bt_status_t nv_record_add(SECTIONS_ADP_ENUM type, void *record) -{ - bt_status_t retstatus = BT_STS_FAILED; - - if ((NULL == record) || (section_none == type)) - { - return BT_STS_FAILED; - } - - switch(type) - { - case section_usrdata_ddbrecord: - retstatus = nv_record_ddbrec_add(record); - break; - default: - break; - } - - return retstatus; -} - -/* -this function should be surrounded by OS_LockStack and OS_UnlockStack when call. -*/ -bt_status_t nv_record_ddbrec_find(const bt_bdaddr_t* bd_ddr, btif_device_record_t *record) -{ - if ((NULL == bd_ddr) || (NULL == record) || (NULL == nvrecord_extension_p)) - { - return BT_STS_FAILED; - } - - int8_t indexOfEntry = -1; - NV_RECORD_PAIRED_BT_DEV_INFO_T* pBtDevInfo = - (NV_RECORD_PAIRED_BT_DEV_INFO_T *)(&(nvrecord_extension_p->bt_pair_info)); - indexOfEntry = nv_record_get_bt_pairing_info_index(bd_ddr->address); - - if (-1 == indexOfEntry) - { - return BT_STS_FAILED; - } - else - { - memcpy((uint8_t *)record, (uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry].record), - sizeof(btif_device_record_t)); - return BT_STS_SUCCESS; - } -} - -/* -this function should be surrounded by OS_LockStack and OS_UnlockStack when call. -*/ -bt_status_t nv_record_ddbrec_delete(const bt_bdaddr_t *bdaddr) -{ - if (NULL == nvrecord_extension_p) - { - return BT_STS_FAILED; - } - - int8_t indexOfEntry = -1; - NV_RECORD_PAIRED_BT_DEV_INFO_T* pBtDevInfo = - (NV_RECORD_PAIRED_BT_DEV_INFO_T *)(&(nvrecord_extension_p->bt_pair_info)); - indexOfEntry = nv_record_get_bt_pairing_info_index(bdaddr->address); - if (-1 == indexOfEntry) - { - return BT_STS_FAILED; - } - - uint32_t lock = nv_record_pre_write_operation(); - - for (uint8_t k = 0; k < pBtDevInfo->pairedDevNum - indexOfEntry - 1; k++) - { - memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry + k]), - (uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry + 1 + k]), - sizeof(nvrec_btdevicerecord)); - } - - memset((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[pBtDevInfo->pairedDevNum-1]), 0, - sizeof(nvrec_btdevicerecord)); - pBtDevInfo->pairedDevNum--; + TRACE(1, "paired Bt dev:%d", pBtDevInfo->pairedDevNum); + TRACE(1, "Is to flush nv: %d", isFlushNv); + nv_record_all_ddbrec_print(); + if (isFlushNv) { nv_record_update_runtime_userdata(); + } - nv_record_post_write_operation(lock); + nv_record_post_write_operation(lock); + + return BT_STS_SUCCESS; +} + +/* +this function should be surrounded by OS_LockStack and OS_UnlockStack when call. +*/ +bt_status_t nv_record_add(SECTIONS_ADP_ENUM type, void *record) { + bt_status_t retstatus = BT_STS_FAILED; + + if ((NULL == record) || (section_none == type)) { + return BT_STS_FAILED; + } + + switch (type) { + case section_usrdata_ddbrecord: + retstatus = nv_record_ddbrec_add(record); + break; + default: + break; + } + + return retstatus; +} + +/* +this function should be surrounded by OS_LockStack and OS_UnlockStack when call. +*/ +bt_status_t nv_record_ddbrec_find(const bt_bdaddr_t *bd_ddr, + btif_device_record_t *record) { + if ((NULL == bd_ddr) || (NULL == record) || (NULL == nvrecord_extension_p)) { + return BT_STS_FAILED; + } + + int8_t indexOfEntry = -1; + NV_RECORD_PAIRED_BT_DEV_INFO_T *pBtDevInfo = + (NV_RECORD_PAIRED_BT_DEV_INFO_T *)(&(nvrecord_extension_p->bt_pair_info)); + indexOfEntry = nv_record_get_bt_pairing_info_index(bd_ddr->address); + + if (-1 == indexOfEntry) { + return BT_STS_FAILED; + } else { + memcpy((uint8_t *)record, + (uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry].record), + sizeof(btif_device_record_t)); return BT_STS_SUCCESS; + } } -int nv_record_btdevicerecord_find(const bt_bdaddr_t *bd_ddr, nvrec_btdevicerecord **record) -{ - if ((NULL == bd_ddr) || (NULL == record) || (NULL == nvrecord_extension_p)) - { - return -1; - } +/* +this function should be surrounded by OS_LockStack and OS_UnlockStack when call. +*/ +bt_status_t nv_record_ddbrec_delete(const bt_bdaddr_t *bdaddr) { + if (NULL == nvrecord_extension_p) { + return BT_STS_FAILED; + } - int8_t indexOfEntry = -1; - NV_RECORD_PAIRED_BT_DEV_INFO_T* pBtDevInfo = - (NV_RECORD_PAIRED_BT_DEV_INFO_T *)(&(nvrecord_extension_p->bt_pair_info)); - indexOfEntry = nv_record_get_bt_pairing_info_index(bd_ddr->address); + int8_t indexOfEntry = -1; + NV_RECORD_PAIRED_BT_DEV_INFO_T *pBtDevInfo = + (NV_RECORD_PAIRED_BT_DEV_INFO_T *)(&(nvrecord_extension_p->bt_pair_info)); + indexOfEntry = nv_record_get_bt_pairing_info_index(bdaddr->address); + if (-1 == indexOfEntry) { + return BT_STS_FAILED; + } - if (-1 == indexOfEntry) - { - return -1; - } + uint32_t lock = nv_record_pre_write_operation(); - *record = - (nvrec_btdevicerecord *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry]); - return 0; + for (uint8_t k = 0; k < pBtDevInfo->pairedDevNum - indexOfEntry - 1; k++) { + memcpy((uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry + k]), + (uint8_t *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry + 1 + k]), + sizeof(nvrec_btdevicerecord)); + } + + memset( + (uint8_t *)&(pBtDevInfo->pairedBtDevInfo[pBtDevInfo->pairedDevNum - 1]), + 0, sizeof(nvrec_btdevicerecord)); + pBtDevInfo->pairedDevNum--; + + nv_record_update_runtime_userdata(); + + nv_record_post_write_operation(lock); + return BT_STS_SUCCESS; } -void nv_record_btdevicerecord_set_a2dp_vol(nvrec_btdevicerecord* pRecord, int8_t vol) -{ - uint32_t lock = nv_record_pre_write_operation(); - if (vol != pRecord->device_vol.a2dp_vol) - { - nv_record_update_runtime_userdata(); - pRecord->device_vol.a2dp_vol = vol; - } +int nv_record_btdevicerecord_find(const bt_bdaddr_t *bd_ddr, + nvrec_btdevicerecord **record) { + if ((NULL == bd_ddr) || (NULL == record) || (NULL == nvrecord_extension_p)) { + return -1; + } + int8_t indexOfEntry = -1; + NV_RECORD_PAIRED_BT_DEV_INFO_T *pBtDevInfo = + (NV_RECORD_PAIRED_BT_DEV_INFO_T *)(&(nvrecord_extension_p->bt_pair_info)); + indexOfEntry = nv_record_get_bt_pairing_info_index(bd_ddr->address); - nv_record_post_write_operation(lock); + if (-1 == indexOfEntry) { + return -1; + } + + *record = + (nvrec_btdevicerecord *)&(pBtDevInfo->pairedBtDevInfo[indexOfEntry]); + return 0; } -void nv_record_btdevicerecord_set_hfp_vol(nvrec_btdevicerecord* pRecord, int8_t vol) -{ - uint32_t lock = nv_record_pre_write_operation(); - if (vol != pRecord->device_vol.hfp_vol) - { - nv_record_update_runtime_userdata(); - pRecord->device_vol.hfp_vol = vol; - } +void nv_record_btdevicerecord_set_a2dp_vol(nvrec_btdevicerecord *pRecord, + int8_t vol) { + uint32_t lock = nv_record_pre_write_operation(); + if (vol != pRecord->device_vol.a2dp_vol) { + nv_record_update_runtime_userdata(); + pRecord->device_vol.a2dp_vol = vol; + } - nv_record_post_write_operation(lock); + nv_record_post_write_operation(lock); } -void nv_record_btdevicevolume_set_a2dp_vol(btdevice_volume* device_vol, int8_t vol) -{ - uint32_t lock = nv_record_pre_write_operation(); - if (vol != device_vol->a2dp_vol) - { - nv_record_update_runtime_userdata(); - device_vol->a2dp_vol = vol; - } - - nv_record_post_write_operation(lock); +void nv_record_btdevicerecord_set_hfp_vol(nvrec_btdevicerecord *pRecord, + int8_t vol) { + uint32_t lock = nv_record_pre_write_operation(); + if (vol != pRecord->device_vol.hfp_vol) { + nv_record_update_runtime_userdata(); + pRecord->device_vol.hfp_vol = vol; + } + nv_record_post_write_operation(lock); } -void nv_record_btdevicevolume_set_hfp_vol(btdevice_volume* device_vol, int8_t vol) -{ - uint32_t lock = nv_record_pre_write_operation(); - if (vol != device_vol->hfp_vol) - { - nv_record_update_runtime_userdata(); - device_vol->hfp_vol = vol; - } - - nv_record_post_write_operation(lock); +void nv_record_btdevicevolume_set_a2dp_vol(btdevice_volume *device_vol, + int8_t vol) { + uint32_t lock = nv_record_pre_write_operation(); + if (vol != device_vol->a2dp_vol) { + nv_record_update_runtime_userdata(); + device_vol->a2dp_vol = vol; + } + nv_record_post_write_operation(lock); } -void nv_record_btdevicerecord_set_vend_id_and_source(nvrec_btdevicerecord* pRecord, int16_t vend_id, int16_t vend_id_source) -{ +void nv_record_btdevicevolume_set_hfp_vol(btdevice_volume *device_vol, + int8_t vol) { + uint32_t lock = nv_record_pre_write_operation(); + if (vol != device_vol->hfp_vol) { + nv_record_update_runtime_userdata(); + device_vol->hfp_vol = vol; + } + + nv_record_post_write_operation(lock); +} + +void nv_record_btdevicerecord_set_vend_id_and_source( + nvrec_btdevicerecord *pRecord, int16_t vend_id, int16_t vend_id_source) { #ifdef BTIF_DIP_DEVICE - TRACE(2, "%s vend id 0x%x", __func__, vend_id); - uint32_t lock = nv_record_pre_write_operation(); - if (vend_id != pRecord->vend_id) - { - nv_record_update_runtime_userdata(); - pRecord->vend_id = vend_id; - pRecord->vend_id_source = vend_id_source; - } + TRACE(2, "%s vend id 0x%x", __func__, vend_id); + uint32_t lock = nv_record_pre_write_operation(); + if (vend_id != pRecord->vend_id) { + nv_record_update_runtime_userdata(); + pRecord->vend_id = vend_id; + pRecord->vend_id_source = vend_id_source; + } - nv_record_post_write_operation(lock); + nv_record_post_write_operation(lock); #endif } #endif //#if defined(NEW_NV_RECORD_ENABLED) - diff --git a/services/nv_section/userdata_section/nvrecord_dma_config.c b/services/nv_section/userdata_section/nvrecord_dma_config.c index 084cd6d..3e17275 100644 --- a/services/nv_section/userdata_section/nvrecord_dma_config.c +++ b/services/nv_section/userdata_section/nvrecord_dma_config.c @@ -15,135 +15,120 @@ ****************************************************************************/ #ifdef NEW_NV_RECORD_ENABLED -#include -#include -#include "nvrecord_extension.h" #include "nvrecord_dma_config.h" -#include "nvrecord.h" #include "hal_trace.h" +#include "nvrecord.h" +#include "nvrecord_extension.h" +#include +#include #ifdef NVREC_BAIDU_DATA_SECTION -extern uint32_t* __factory_start; +extern uint32_t *__factory_start; -void nvrecord_rebuild_dma_configuration(NV_DMA_CONFIGURATION_T* pDmaConfig) -{ - memset((uint8_t *)pDmaConfig, 0, sizeof(NV_DMA_CONFIGURATION_T)); - pDmaConfig->fmfreq = BAIDU_DATA_DEF_FM_FREQ; +void nvrecord_rebuild_dma_configuration(NV_DMA_CONFIGURATION_T *pDmaConfig) { + memset((uint8_t *)pDmaConfig, 0, sizeof(NV_DMA_CONFIGURATION_T)); + pDmaConfig->fmfreq = BAIDU_DATA_DEF_FM_FREQ; } -int nvrec_baidu_data_init(void) -{ - if (NULL == nvrecord_extension_p) - { - return -1; - } +int nvrec_baidu_data_init(void) { + if (NULL == nvrecord_extension_p) { + return -1; + } - uint32_t lock = nv_record_pre_write_operation(); - nvrecord_rebuild_dma_configuration(&(nvrecord_extension_p->dma_config)); - nv_record_update_runtime_userdata(); - nv_record_post_write_operation(lock); - return 0; + uint32_t lock = nv_record_pre_write_operation(); + nvrecord_rebuild_dma_configuration(&(nvrecord_extension_p->dma_config)); + nv_record_update_runtime_userdata(); + nv_record_post_write_operation(lock); + return 0; } -int nvrec_get_fm_freq(void) -{ - if (NULL == nvrecord_extension_p) - { - return -1; - } +int nvrec_get_fm_freq(void) { + if (NULL == nvrecord_extension_p) { + return -1; + } - int _fmfreq = nvrecord_extension_p->dma_config.fmfreq; + int _fmfreq = nvrecord_extension_p->dma_config.fmfreq; - TRACE(2,"%s:get fm freq %d", __func__, _fmfreq); - return _fmfreq; + TRACE(2, "%s:get fm freq %d", __func__, _fmfreq); + return _fmfreq; } -int nvrec_set_fm_freq(int fmfreq) -{ - if (NULL == nvrecord_extension_p) - { - return -1; - } +int nvrec_set_fm_freq(int fmfreq) { + if (NULL == nvrecord_extension_p) { + return -1; + } - uint32_t lock = nv_record_pre_write_operation(); - nvrecord_extension_p->dma_config.fmfreq = fmfreq; - nv_record_update_runtime_userdata(); - nv_record_post_write_operation(lock); + uint32_t lock = nv_record_pre_write_operation(); + nvrecord_extension_p->dma_config.fmfreq = fmfreq; + nv_record_update_runtime_userdata(); + nv_record_post_write_operation(lock); #if defined(NVREC_BAIDU_DATA_FLUSH_DIRECT) - nv_record_flash_flush_int(false); + nv_record_flash_flush_int(false); #endif - return 0; + return 0; } -int nvrec_get_rand(char *rand) -{ - char _rand[BAIDU_DATA_RAND_LEN]; - int8_t copy_len = 0; +int nvrec_get_rand(char *rand) { + char _rand[BAIDU_DATA_RAND_LEN]; + int8_t copy_len = 0; - if (NULL == rand) - { - return 1; - } + if (NULL == rand) { + return 1; + } - if (NULL == nvrecord_extension_p) - { - //_rand = BAIDU_DATA_DEF_RAND; - copy_len = (sizeof(BAIDU_DATA_DEF_RAND)dma_config.rand, BAIDU_DATA_RAND_LEN); - } + if (NULL == nvrecord_extension_p) { + //_rand = BAIDU_DATA_DEF_RAND; + copy_len = (sizeof(BAIDU_DATA_DEF_RAND) < BAIDU_DATA_RAND_LEN) + ? sizeof(BAIDU_DATA_DEF_RAND) + : BAIDU_DATA_RAND_LEN; + memcpy(_rand, BAIDU_DATA_DEF_RAND, copy_len); + } else { + memcpy(_rand, nvrecord_extension_p->dma_config.rand, BAIDU_DATA_RAND_LEN); + } - memcpy(rand, _rand, BAIDU_DATA_RAND_LEN); - TRACE(2,"%s:rand %s", __func__, rand); - return 0; + memcpy(rand, _rand, BAIDU_DATA_RAND_LEN); + TRACE(2, "%s:rand %s", __func__, rand); + return 0; } -int nvrec_set_rand(char *rand) -{ - if (NULL == rand) - { - return -1; - } +int nvrec_set_rand(char *rand) { + if (NULL == rand) { + return -1; + } - if (NULL == nvrecord_extension_p) - { - return -1; - } + if (NULL == nvrecord_extension_p) { + return -1; + } - uint32_t lock = nv_record_pre_write_operation(); - memcpy(nvrecord_extension_p->dma_config.rand, rand, BAIDU_DATA_RAND_LEN); - nv_record_update_runtime_userdata(); - nv_record_post_write_operation(lock); + uint32_t lock = nv_record_pre_write_operation(); + memcpy(nvrecord_extension_p->dma_config.rand, rand, BAIDU_DATA_RAND_LEN); + nv_record_update_runtime_userdata(); + nv_record_post_write_operation(lock); #if defined(NVREC_BAIDU_DATA_FLUSH_DIRECT) - nv_record_flash_flush_int(false); + nv_record_flash_flush_int(false); #endif - return 0; + return 0; } //#define GET_SN_FROM_FACTORY -int nvrec_dev_get_sn(char *sn) -{ +int nvrec_dev_get_sn(char *sn) { - if (NULL == sn) - { - return -1; - } + if (NULL == sn) { + return -1; + } #ifdef GET_SN_FROM_FACTORY - unsigned int sn_addr; - sn_addr = (unsigned int)(__factory_start + rev2_dev_prod_sn); + unsigned int sn_addr; + sn_addr = (unsigned int)(__factory_start + rev2_dev_prod_sn); #else - char sn_addr[BAIDU_DATA_SN_LEN] = "01234567890123sf"; + char sn_addr[BAIDU_DATA_SN_LEN] = "01234567890123sf"; #endif - memcpy((void *)sn, (void *)sn_addr, BAIDU_DATA_SN_LEN); + memcpy((void *)sn, (void *)sn_addr, BAIDU_DATA_SN_LEN); - return 0; + return 0; } #endif // #ifdef NVREC_BAIDU_DATA_SECTION diff --git a/services/nv_section/userdata_section/nvrecord_env.c b/services/nv_section/userdata_section/nvrecord_env.c index 9cc2dbe..52c0d34 100644 --- a/services/nv_section/userdata_section/nvrecord_env.c +++ b/services/nv_section/userdata_section/nvrecord_env.c @@ -14,103 +14,91 @@ * ****************************************************************************/ #if defined(NEW_NV_RECORD_ENABLED) -#include -#include -#include -#include "nvrecord_extension.h" #include "nvrecord_env.h" #include "hal_trace.h" +#include "nvrecord_extension.h" +#include +#include +#include static struct nvrecord_env_t localSystemInfo; -void nvrecord_rebuild_system_env(struct nvrecord_env_t* pSystemEnv) -{ - memset((uint8_t *)pSystemEnv, 0, sizeof(struct nvrecord_env_t)); - - pSystemEnv->media_language.language = NVRAM_ENV_MEDIA_LANGUAGE_DEFAULT; - pSystemEnv->ibrt_mode.mode = NVRAM_ENV_TWS_MODE_DEFAULT; - pSystemEnv->ibrt_mode.tws_connect_success = 0; - pSystemEnv->factory_tester_status.status = NVRAM_ENV_FACTORY_TESTER_STATUS_DEFAULT; +void nvrecord_rebuild_system_env(struct nvrecord_env_t *pSystemEnv) { + memset((uint8_t *)pSystemEnv, 0, sizeof(struct nvrecord_env_t)); - pSystemEnv->aiManagerInfo.voice_key_enable = false; - pSystemEnv->aiManagerInfo.setedCurrentAi = 0; - pSystemEnv->aiManagerInfo.aiStatusDisableFlag = 0; - pSystemEnv->aiManagerInfo.amaAssistantEnableStatus = 1; + pSystemEnv->media_language.language = NVRAM_ENV_MEDIA_LANGUAGE_DEFAULT; + pSystemEnv->ibrt_mode.mode = NVRAM_ENV_TWS_MODE_DEFAULT; + pSystemEnv->ibrt_mode.tws_connect_success = 0; + pSystemEnv->factory_tester_status.status = + NVRAM_ENV_FACTORY_TESTER_STATUS_DEFAULT; - localSystemInfo = *pSystemEnv; + pSystemEnv->aiManagerInfo.voice_key_enable = false; + pSystemEnv->aiManagerInfo.setedCurrentAi = 0; + pSystemEnv->aiManagerInfo.aiStatusDisableFlag = 0; + pSystemEnv->aiManagerInfo.amaAssistantEnableStatus = 1; + + localSystemInfo = *pSystemEnv; } -int nv_record_env_get(struct nvrecord_env_t **nvrecord_env) -{ - if (NULL == nvrecord_env) - { - return -1; - } +int nv_record_env_get(struct nvrecord_env_t **nvrecord_env) { + if (NULL == nvrecord_env) { + return -1; + } - if (NULL == nvrecord_extension_p) - { - return -1; - } + if (NULL == nvrecord_extension_p) { + return -1; + } - localSystemInfo = nvrecord_extension_p->system_info; - *nvrecord_env = &localSystemInfo; + localSystemInfo = nvrecord_extension_p->system_info; + *nvrecord_env = &localSystemInfo; - return 0; + return 0; } -int nv_record_env_set(struct nvrecord_env_t *nvrecord_env) -{ - if (NULL == nvrecord_extension_p) - { - return -1; - } +int nv_record_env_set(struct nvrecord_env_t *nvrecord_env) { + if (NULL == nvrecord_extension_p) { + return -1; + } - uint32_t lock = nv_record_pre_write_operation(); - nvrecord_extension_p->system_info = *nvrecord_env; - - nv_record_update_runtime_userdata(); - nv_record_post_write_operation(lock); - return 0; + uint32_t lock = nv_record_pre_write_operation(); + nvrecord_extension_p->system_info = *nvrecord_env; + + nv_record_update_runtime_userdata(); + nv_record_post_write_operation(lock); + return 0; } -void nv_record_update_ibrt_info(uint32_t newMode, bt_bdaddr_t *ibrtPeerAddr) -{ - if (NULL == nvrecord_extension_p) - { - return; - } - - uint32_t lock = nv_record_pre_write_operation(); +void nv_record_update_ibrt_info(uint32_t newMode, bt_bdaddr_t *ibrtPeerAddr) { + if (NULL == nvrecord_extension_p) { + return; + } - TRACE(2,"##%s,%d",__func__,newMode); - nvrecord_extension_p->system_info.ibrt_mode.mode = newMode; - memcpy(nvrecord_extension_p->system_info.ibrt_mode.record.bdAddr.address, - ibrtPeerAddr->address, BTIF_BD_ADDR_SIZE); + uint32_t lock = nv_record_pre_write_operation(); - nv_record_update_runtime_userdata(); - nv_record_post_write_operation(lock); + TRACE(2, "##%s,%d", __func__, newMode); + nvrecord_extension_p->system_info.ibrt_mode.mode = newMode; + memcpy(nvrecord_extension_p->system_info.ibrt_mode.record.bdAddr.address, + ibrtPeerAddr->address, BTIF_BD_ADDR_SIZE); + + nv_record_update_runtime_userdata(); + nv_record_post_write_operation(lock); } +void nv_record_update_factory_tester_status(uint32_t status) { + if (NULL == nvrecord_extension_p) { + return; + } -void nv_record_update_factory_tester_status(uint32_t status) -{ - if (NULL == nvrecord_extension_p) - { - return; - } + uint32_t lock = nv_record_pre_write_operation(); - uint32_t lock = nv_record_pre_write_operation(); + nvrecord_extension_p->system_info.factory_tester_status.status = status; - nvrecord_extension_p->system_info.factory_tester_status.status = status; - - nv_record_update_runtime_userdata(); - nv_record_post_write_operation(lock); + nv_record_update_runtime_userdata(); + nv_record_post_write_operation(lock); } -int nv_record_env_init(void) -{ - nv_record_open(section_usrdata_ddbrecord); - return 0; +int nv_record_env_init(void) { + nv_record_open(section_usrdata_ddbrecord); + return 0; } #endif // #if defined(NEW_NV_RECORD_ENABLED) - diff --git a/services/nv_section/userdata_section/nvrecord_extension.c b/services/nv_section/userdata_section/nvrecord_extension.c index b524eaf..86a0964 100644 --- a/services/nv_section/userdata_section/nvrecord_extension.c +++ b/services/nv_section/userdata_section/nvrecord_extension.c @@ -14,59 +14,60 @@ * ****************************************************************************/ #ifdef NEW_NV_RECORD_ENABLED -#include -#include -#include -#include "cmsis.h" #include "nvrecord_extension.h" -#include "hal_trace.h" +#include "besbt.h" +#include "cmsis.h" #include "crc32.h" -#include "hal_sleep.h" +#include "customparam_section.h" #include "hal_norflash.h" +#include "hal_sleep.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "mpu.h" #include "norflash_api.h" #include "norflash_drv.h" -#include "nvrecord_bt.h" -#include "nvrecord_env.h" #include "nvrecord_ble.h" +#include "nvrecord_bt.h" #include "nvrecord_dma_config.h" +#include "nvrecord_env.h" #include "nvrecord_fp_account_key.h" -#include "customparam_section.h" -#include "mpu.h" -#include "besbt.h" -#include "hal_timer.h" +#include +#include +#include extern uint32_t __userdata_start[]; extern uint32_t __userdata_end[]; -extern void nvrecord_rebuild_system_env(struct nvrecord_env_t* pSystemEnv); -extern void nvrecord_rebuild_paired_bt_dev_info(NV_RECORD_PAIRED_BT_DEV_INFO_T* pPairedBtInfo); +extern void nvrecord_rebuild_system_env(struct nvrecord_env_t *pSystemEnv); +extern void nvrecord_rebuild_paired_bt_dev_info( + NV_RECORD_PAIRED_BT_DEV_INFO_T *pPairedBtInfo); #ifdef GFPS_ENABLED -extern void nvrecord_rebuild_fp_account_key(NV_FP_ACCOUNT_KEY_RECORD_T* pFpAccountKey); +extern void +nvrecord_rebuild_fp_account_key(NV_FP_ACCOUNT_KEY_RECORD_T *pFpAccountKey); #endif #ifdef NVREC_BAIDU_DATA_SECTION -extern void nvrecord_rebuild_dma_configuration(NV_DMA_CONFIGURATION_T* pDmaConfig); +extern void +nvrecord_rebuild_dma_configuration(NV_DMA_CONFIGURATION_T *pDmaConfig); #endif -typedef enum -{ - NV_STATE_IDLE, - NV_STATE_MAIN_ERASING, - NV_STATE_MAIN_ERASED, - NV_STATE_MAIN_WRITTING, - NV_STATE_MAIN_WRITTEN, - NV_STATE_MAIN_DONE, - NV_STATE_BAK_ERASING, - NV_STATE_BAK_ERASED, - NV_STATE_BAK_WRITTING, - NV_STATE_BAK_WRITTEN, - NV_STATE_BAK_DONE, -}NV_STATE; +typedef enum { + NV_STATE_IDLE, + NV_STATE_MAIN_ERASING, + NV_STATE_MAIN_ERASED, + NV_STATE_MAIN_WRITTING, + NV_STATE_MAIN_WRITTEN, + NV_STATE_MAIN_DONE, + NV_STATE_BAK_ERASING, + NV_STATE_BAK_ERASED, + NV_STATE_BAK_WRITTING, + NV_STATE_BAK_WRITTEN, + NV_STATE_BAK_DONE, +} NV_STATE; -typedef struct -{ - bool is_update; - NV_STATE state; - uint32_t written_size; -}NV_FLUSH_STATE; +typedef struct { + bool is_update; + NV_STATE state; + uint32_t written_size; +} NV_FLUSH_STATE; static NV_FLUSH_STATE nv_flsh_state; static bool nvrec_init = false; @@ -74,7 +75,7 @@ static uint32_t _user_data_main_start; static uint32_t _user_data_bak_start; static uint8_t _nv_burn_buf[NV_EXTENSION_PAGE_SIZE]; -NV_EXTENSION_RECORD_T *nvrecord_extension_p = NULL; +NV_EXTENSION_RECORD_T *nvrecord_extension_p = NULL; /* *Note: the NV_EXTENSION_MIRROR_RAM_SIZE must be power of 2 @@ -90,164 +91,158 @@ NV_EXTENSION_RECORD_T *nvrecord_extension_p = NULL; #endif static NV_MIRROR_BUF_T local_extension_data __NV_BUF_MPU_ALIGNED - __attribute__((section(".sram_data"))) = -{ - .nv_record = { - { // header - NV_EXTENSION_MAGIC_NUMBER, - NV_EXTENSION_MAJOR_VERSION, - NV_EXTENSION_MINOR_VERSION, - NV_EXTENSION_VALID_LEN, - 0, - }, + __attribute__((section(".sram_data"))) = { + .nv_record = + { + { + // header + NV_EXTENSION_MAGIC_NUMBER, + NV_EXTENSION_MAJOR_VERSION, + NV_EXTENSION_MINOR_VERSION, + NV_EXTENSION_VALID_LEN, + 0, + }, - { // system info - }, + { + // system info + }, - { // bt_pair_info - 0 - }, + {// bt_pair_info + 0}, - { // ble_pair_info + { + // ble_pair_info - }, + }, #ifdef TWS_SYSTEM_ENABLED - { // tws_info + { + // tws_info - }, + }, #endif #ifdef GFPS_ENABLED - { // fp_account_key_rec - 0 - }, + {// fp_account_key_rec + 0}, #endif #ifdef NVREC_BAIDU_DATA_SECTION - { // dma_config - BAIDU_DATA_DEF_FM_FREQ, - }, + { + // dma_config + BAIDU_DATA_DEF_FM_FREQ, + }, #endif #ifdef TILE_DATAPATH - { - {0} - }, + {{0}}, #endif #ifdef OTA_ENABLED - { - {0,}, - }, + { + { + 0, + }, + }, #endif #if defined(BISTO_ENABLED) - { - true, - }, + { + true, + }, #endif -#if 1//def TX_IQ_CAL - { - BT_IQ_INVALID_MAGIC_NUM, - {0}, - {0}, - }, +#if 1 // def TX_IQ_CAL + { + BT_IQ_INVALID_MAGIC_NUM, + {0}, + {0}, + }, #endif - // TODO: - // If want to extend the nvrecord while keeping the history information, - // append the new items to the tail of NV_EXTENSION_RECORD_T and - // set their intial content here - }, + // TODO: + // If want to extend the nvrecord while keeping the history + // information, + // append the new items to the tail of NV_EXTENSION_RECORD_T and + // set their intial content here + }, }; -STATIC_ASSERT(sizeof(local_extension_data) <= NV_EXTENSION_MIRROR_RAM_SIZE, "NV local buffer too small"); +STATIC_ASSERT(sizeof(local_extension_data) <= NV_EXTENSION_MIRROR_RAM_SIZE, + "NV local buffer too small"); static int nv_record_extension_flush(bool is_async); #ifdef TILE_DATAPATH -static void nvrecord_rebuild_tileconfig(NV_TILE_INFO_CONFIG_T *tileConfig) -{ - memset((uint8_t*)tileConfig,0,sizeof(NV_TILE_INFO_CONFIG_T)); +static void nvrecord_rebuild_tileconfig(NV_TILE_INFO_CONFIG_T *tileConfig) { + memset((uint8_t *)tileConfig, 0, sizeof(NV_TILE_INFO_CONFIG_T)); } #endif #ifdef OTA_ENABLED -static void nvrecord_rebuild_ota_info(NV_OTA_INFO_T *ota_info) -{ - memset((uint8_t *)ota_info, 0, OTA_DEVICE_CNT * sizeof(NV_OTA_INFO_T)); +static void nvrecord_rebuild_ota_info(NV_OTA_INFO_T *ota_info) { + memset((uint8_t *)ota_info, 0, OTA_DEVICE_CNT * sizeof(NV_OTA_INFO_T)); } #endif #if defined(BISTO_ENABLED) -static void nvrecord_rebuild_gsound_info(NV_GSOUND_INFO_T *gsound_info) -{ - memset((uint8_t*)gsound_info,0,sizeof(NV_GSOUND_INFO_T)); +static void nvrecord_rebuild_gsound_info(NV_GSOUND_INFO_T *gsound_info) { + memset((uint8_t *)gsound_info, 0, sizeof(NV_GSOUND_INFO_T)); } #endif -#if 1//def TX_IQ_CAL -static void nvrecord_rebuild_btiqcalconfig(BT_IQ_CALIBRATION_CONFIG_T *btIqCalConfig) -{ - memset((uint8_t*)btIqCalConfig,0,sizeof(BT_IQ_CALIBRATION_CONFIG_T)); - btIqCalConfig->validityMagicNum = BT_IQ_INVALID_MAGIC_NUM; +#if 1 // def TX_IQ_CAL +static void +nvrecord_rebuild_btiqcalconfig(BT_IQ_CALIBRATION_CONFIG_T *btIqCalConfig) { + memset((uint8_t *)btIqCalConfig, 0, sizeof(BT_IQ_CALIBRATION_CONFIG_T)); + btIqCalConfig->validityMagicNum = BT_IQ_INVALID_MAGIC_NUM; } #endif -static bool nv_record_data_is_valid(NV_EXTENSION_RECORD_T *nv_record) -{ - bool is_valid = false; +static bool nv_record_data_is_valid(NV_EXTENSION_RECORD_T *nv_record) { + bool is_valid = false; - NVRECORD_HEADER_T* pExtRecInFlash = &nv_record->header; - uint8_t* pData = (uint8_t*)nv_record + NV_EXTENSION_HEADER_SIZE; + NVRECORD_HEADER_T *pExtRecInFlash = &nv_record->header; + uint8_t *pData = (uint8_t *)nv_record + NV_EXTENSION_HEADER_SIZE; - TRACE(0,"nv ext magic 0x%x valid len %d", pExtRecInFlash->magicNumber, + TRACE(0, "nv ext magic 0x%x valid len %d", pExtRecInFlash->magicNumber, pExtRecInFlash->validLen); - if ((NV_EXTENSION_MAJOR_VERSION == pExtRecInFlash->majorVersion) && - (NV_EXTENSION_MAGIC_NUMBER == pExtRecInFlash->magicNumber)) - { - // check whether the data length is valid - if (pExtRecInFlash->validLen <= NV_EXTENSION_SIZE-NV_EXTENSION_HEADER_SIZE) - { - // check crc32 - uint32_t crc = crc32(0, pData, pExtRecInFlash->validLen); - TRACE(1,"generated crc32: 0x%x, header crc: 0x%x", - crc, pExtRecInFlash->crc32); - if (crc == pExtRecInFlash->crc32) - { - // correct - TRACE(2,"Nv extension is valid."); + if ((NV_EXTENSION_MAJOR_VERSION == pExtRecInFlash->majorVersion) && + (NV_EXTENSION_MAGIC_NUMBER == pExtRecInFlash->magicNumber)) { + // check whether the data length is valid + if (pExtRecInFlash->validLen <= + NV_EXTENSION_SIZE - NV_EXTENSION_HEADER_SIZE) { + // check crc32 + uint32_t crc = crc32(0, pData, pExtRecInFlash->validLen); + TRACE(1, "generated crc32: 0x%x, header crc: 0x%x", crc, + pExtRecInFlash->crc32); + if (crc == pExtRecInFlash->crc32) { + // correct + TRACE(2, "Nv extension is valid."); - TRACE(2,"Former nv ext valid len %d", pExtRecInFlash->validLen); - TRACE(2,"Current FW version nv ext valid len %d", NV_EXTENSION_VALID_LEN); + TRACE(2, "Former nv ext valid len %d", pExtRecInFlash->validLen); + TRACE(2, "Current FW version nv ext valid len %d", + NV_EXTENSION_VALID_LEN); - if (NV_EXTENSION_VALID_LEN < pExtRecInFlash->validLen) - { - TRACE(0,"Valid length of extension must be increased," - "use the default value."); - } - else - { - if(NV_EXTENSION_VALID_LEN > pExtRecInFlash->validLen) - { - TRACE(2, "NV extension is extended! (0x%x) -> (0x%x)", - pExtRecInFlash->validLen,NV_EXTENSION_VALID_LEN); - } - is_valid = true; - } - } + if (NV_EXTENSION_VALID_LEN < pExtRecInFlash->validLen) { + TRACE(0, "Valid length of extension must be increased," + "use the default value."); + } else { + if (NV_EXTENSION_VALID_LEN > pExtRecInFlash->validLen) { + TRACE(2, "NV extension is extended! (0x%x) -> (0x%x)", + pExtRecInFlash->validLen, NV_EXTENSION_VALID_LEN); + } + is_valid = true; } + } } + } - return is_valid; - + return is_valid; } -static bool nv_record_items_is_valid(NV_EXTENSION_RECORD_T *nv_record) -{ - nv_record = nv_record; +static bool nv_record_items_is_valid(NV_EXTENSION_RECORD_T *nv_record) { + nv_record = nv_record; #if 0 NV_RECORD_PAIRED_BT_DEV_INFO_T *pbt_pair_info; pbt_pair_info = &nv_record->bt_pair_info; @@ -257,835 +252,678 @@ static bool nv_record_items_is_valid(NV_EXTENSION_RECORD_T *nv_record) DUMP8("0x%x,", (uint8_t*)pbt_pair_info->pairedBtDevInfo[i].record.bdAddr.address,6); } #endif - // TODO: add cheking for nv_record items. + // TODO: add cheking for nv_record items. - return true; + return true; } -static void nv_record_set_default(NV_EXTENSION_RECORD_T *nv_record) -{ - memset((uint8_t*)nv_record, 0 ,sizeof(NV_EXTENSION_RECORD_T)); - nvrecord_rebuild_system_env(&(nv_record->system_info)); - nvrecord_rebuild_paired_bt_dev_info(&(nv_record->bt_pair_info)); - nvrecord_rebuild_paired_ble_dev_info(&(nv_record->ble_pair_info)); +static void nv_record_set_default(NV_EXTENSION_RECORD_T *nv_record) { + memset((uint8_t *)nv_record, 0, sizeof(NV_EXTENSION_RECORD_T)); + nvrecord_rebuild_system_env(&(nv_record->system_info)); + nvrecord_rebuild_paired_bt_dev_info(&(nv_record->bt_pair_info)); + nvrecord_rebuild_paired_ble_dev_info(&(nv_record->ble_pair_info)); #ifdef GFPS_ENABLED - nvrecord_rebuild_fp_account_key(&(nv_record->fp_account_key_rec)); + nvrecord_rebuild_fp_account_key(&(nv_record->fp_account_key_rec)); #endif #ifdef NVREC_BAIDU_DATA_SECTION - nvrecord_rebuild_dma_configuration(&(nv_record->dma_config)); + nvrecord_rebuild_dma_configuration(&(nv_record->dma_config)); #endif #ifdef TILE_DATAPATH - nvrecord_rebuild_tileconfig(&nv_record->tileConfig); + nvrecord_rebuild_tileconfig(&nv_record->tileConfig); #endif #if defined(BISTO_ENABLED) - nvrecord_rebuild_gsound_info(&nv_record->gsound_info); + nvrecord_rebuild_gsound_info(&nv_record->gsound_info); #endif #ifdef OTA_ENABLED - nvrecord_rebuild_ota_info((NV_OTA_INFO_T *)&nv_record->ota_info); + nvrecord_rebuild_ota_info((NV_OTA_INFO_T *)&nv_record->ota_info); #endif -#if 1//def TX_IQ_CAL - nvrecord_rebuild_btiqcalconfig(&nv_record->btIqCalConfig); +#if 1 // def TX_IQ_CAL + nvrecord_rebuild_btiqcalconfig(&nv_record->btIqCalConfig); #endif - nv_record->header.magicNumber = NV_EXTENSION_MAGIC_NUMBER; - nv_record->header.majorVersion = NV_EXTENSION_MAJOR_VERSION; - nv_record->header.minorVersion = NV_EXTENSION_MINOR_VERSION; - nv_record->header.validLen = NV_EXTENSION_VALID_LEN; - nv_record->header.crc32 = - crc32(0, ((uint8_t *)nv_record + NV_EXTENSION_HEADER_SIZE), - NV_EXTENSION_VALID_LEN); + nv_record->header.magicNumber = NV_EXTENSION_MAGIC_NUMBER; + nv_record->header.majorVersion = NV_EXTENSION_MAJOR_VERSION; + nv_record->header.minorVersion = NV_EXTENSION_MINOR_VERSION; + nv_record->header.validLen = NV_EXTENSION_VALID_LEN; + nv_record->header.crc32 = + crc32(0, ((uint8_t *)nv_record + NV_EXTENSION_HEADER_SIZE), + NV_EXTENSION_VALID_LEN); } -static void _nv_record_extension_init(void) -{ - enum NORFLASH_API_RET_T result; - uint32_t sector_size = 0; - uint32_t block_size = 0; - uint32_t page_size = 0; +static void _nv_record_extension_init(void) { + enum NORFLASH_API_RET_T result; + uint32_t sector_size = 0; + uint32_t block_size = 0; + uint32_t page_size = 0; - hal_norflash_get_size(HAL_NORFLASH_ID_0, - NULL, - &block_size, - §or_size, - &page_size); - result = norflash_api_register(NORFLASH_API_MODULE_ID_USERDATA_EXT, - HAL_NORFLASH_ID_0, - ((uint32_t)__userdata_start), - ((uint32_t)__userdata_end - (uint32_t)__userdata_start), - block_size, - sector_size, - page_size, - NV_EXTENSION_SIZE*2, - nv_extension_callback - ); - ASSERT(result == NORFLASH_API_OK,"_nv_record_extension_init: module register failed! result = %d.",result); + hal_norflash_get_size(HAL_NORFLASH_ID_0, NULL, &block_size, §or_size, + &page_size); + result = norflash_api_register( + NORFLASH_API_MODULE_ID_USERDATA_EXT, HAL_NORFLASH_ID_0, + ((uint32_t)__userdata_start), + ((uint32_t)__userdata_end - (uint32_t)__userdata_start), block_size, + sector_size, page_size, NV_EXTENSION_SIZE * 2, nv_extension_callback); + ASSERT(result == NORFLASH_API_OK, + "_nv_record_extension_init: module register failed! result = %d.", + result); } -uint32_t nv_record_pre_write_operation(void) -{ +uint32_t nv_record_pre_write_operation(void) { + uint32_t lock = int_lock_global(); + mpu_clear(MPU_ID_USER_DATA_SECTION); + return lock; +} + +void nv_record_post_write_operation(uint32_t lock) { + int ret = 0; + uint32_t nv_start = (uint32_t)&local_extension_data.nv_record; + uint32_t len = NV_EXTENSION_MIRROR_RAM_SIZE; + + ret = mpu_set(MPU_ID_USER_DATA_SECTION, nv_start, len, 0, MPU_ATTR_READ); + int_unlock_global(lock); + TRACE(2, "set mpu 0x%x len %d result %d", nv_start, len, ret); +} + +static void nv_record_extension_init(void) { + uint32_t lock; + bool main_is_valid = false; + bool bak_is_valid = false; + bool data_is_valid = false; + + if (nvrec_init) { + return; + } + _user_data_main_start = (uint32_t)__userdata_start; + _user_data_bak_start = (uint32_t)__userdata_start + NV_EXTENSION_SIZE; + + lock = nv_record_pre_write_operation(); + _nv_record_extension_init(); + + nv_flsh_state.is_update = false; + nv_flsh_state.written_size = 0; + nv_flsh_state.state = NV_STATE_IDLE; + + nvrecord_extension_p = &local_extension_data.nv_record; + + if (nvrecord_extension_p->header.magicNumber != NV_EXTENSION_MAGIC_NUMBER || + nvrecord_extension_p->header.majorVersion != NV_EXTENSION_MAJOR_VERSION || + nvrecord_extension_p->header.minorVersion != NV_EXTENSION_MINOR_VERSION || + nvrecord_extension_p->header.validLen >= + (NV_EXTENSION_SIZE - NV_EXTENSION_HEADER_SIZE)) { + ASSERT(0, "%s: local_extension_data error!(0x%x,0x%x,0x%x,0x%x)", __func__, + nvrecord_extension_p->header.magicNumber, + nvrecord_extension_p->header.majorVersion, + nvrecord_extension_p->header.minorVersion, + nvrecord_extension_p->header.validLen); + } + + // Check main sector. + if (nv_record_data_is_valid((NV_EXTENSION_RECORD_T *)_user_data_main_start) && + nv_record_items_is_valid( + (NV_EXTENSION_RECORD_T *)_user_data_main_start)) { + TRACE(2, "%s,main sector is valid.", __func__); + main_is_valid = true; + } else { + TRACE(1, "%s,main sector is invalid!", __func__); + main_is_valid = false; + } + + // Check bak secotr. + if (nv_record_data_is_valid((NV_EXTENSION_RECORD_T *)_user_data_bak_start) && + nv_record_items_is_valid( + (NV_EXTENSION_RECORD_T *)_user_data_main_start)) { + TRACE(2, "%s,bak sector is valid.", __func__); + bak_is_valid = true; + } else { + TRACE(1, "%s,bak sector is invalid!", __func__); + bak_is_valid = false; + } + + if (main_is_valid) { + data_is_valid = true; + if (!bak_is_valid) { + nv_flsh_state.is_update = true; + nv_flsh_state.state = NV_STATE_MAIN_DONE; + } + } else { + if (bak_is_valid) { + data_is_valid = true; + nv_flsh_state.is_update = true; + nv_flsh_state.state = NV_STATE_IDLE; + } else { + data_is_valid = false; + } + } + + if (data_is_valid) { + TRACE(2, "%s,data is valid.", __func__); + if (main_is_valid) { + memcpy((uint8_t *)nvrecord_extension_p + NV_EXTENSION_HEADER_SIZE, + (uint8_t *)_user_data_main_start + NV_EXTENSION_HEADER_SIZE, + NV_EXTENSION_VALID_LEN); + } else { + memcpy((uint8_t *)nvrecord_extension_p + NV_EXTENSION_HEADER_SIZE, + (uint8_t *)_user_data_bak_start + NV_EXTENSION_HEADER_SIZE, + NV_EXTENSION_VALID_LEN); + } + nvrecord_extension_p->header.crc32 = + crc32(0, ((uint8_t *)nvrecord_extension_p + NV_EXTENSION_HEADER_SIZE), + nvrecord_extension_p->header.validLen); + } else { + TRACE(1, "%s,data invalid, rebuild... ", __func__); + nv_record_set_default(nvrecord_extension_p); + TRACE(2, "%s,rebuild crc = 0x%x. ", __func__, + nvrecord_extension_p->header.crc32); + // need to update the content in the flash + nv_record_extension_update(); + } + + nvrec_init = true; + + nv_record_post_write_operation(lock); + + if (nv_flsh_state.is_update) { + nv_record_extension_flush(false); + } + TRACE(2, "%s,done.", __func__); +} + +NV_EXTENSION_RECORD_T *nv_record_get_extension_entry_ptr(void) { + return nvrecord_extension_p; +} + +void nv_record_extension_update(void) { nv_flsh_state.is_update = true; } + +static int nv_record_extension_flush_main(bool is_async) { + uint32_t crc; + uint32_t lock; + enum NORFLASH_API_RET_T ret = NORFLASH_API_OK; + + if (NULL == nvrecord_extension_p) { + TRACE(1, "%s,nvrecord_extension_p is null.", __func__); + goto _func_end; + } + + // TRACE(3, "%s is_async %d state %d", __func__, is_async, + // nv_flsh_state.state); + + if (is_async) { + if (nv_flsh_state.state == NV_STATE_IDLE && + nv_flsh_state.is_update == true) { + TRACE(3, "%s: async flush begin!", __func__); + } + + hal_trace_pause(); + lock = int_lock_global(); + + if (nv_flsh_state.state == NV_STATE_IDLE || + nv_flsh_state.state == NV_STATE_MAIN_ERASING) { + if (nv_flsh_state.state == NV_STATE_IDLE) { + nv_flsh_state.state = NV_STATE_MAIN_ERASING; + TRACE(4, "%s: NV_STATE_MAIN_ERASING", __func__); + } + + ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA_EXT, + (uint32_t)(__userdata_start), NV_EXTENSION_SIZE, + true); + if (ret == NORFLASH_API_OK) { + nv_flsh_state.state = NV_STATE_MAIN_ERASED; + TRACE(4, "%s: NV_STATE_MAIN_ERASED", __func__); + TRACE(4, "%s: norflash_api_erase ok,addr = 0x%x.", __func__, + _user_data_main_start); + } else if (ret == NORFLASH_API_BUFFER_FULL) { + norflash_api_flush(); + } else { + ASSERT(0, "%s: norflash_api_erase err,ret = %d,addr = 0x%x.", __func__, + ret, _user_data_main_start); + } + } else if (nv_flsh_state.state == NV_STATE_MAIN_ERASED || + nv_flsh_state.state == NV_STATE_MAIN_WRITTING) { + if (nv_flsh_state.state == NV_STATE_MAIN_ERASED) { + nv_flsh_state.state = NV_STATE_MAIN_WRITTING; + TRACE(4, "%s: NV_STATE_MAIN_WRITTING", __func__); + } + uint32_t tmpLock = nv_record_pre_write_operation(); + crc = crc32(0, (uint8_t *)nvrecord_extension_p + NV_EXTENSION_HEADER_SIZE, + NV_EXTENSION_VALID_LEN); + nvrecord_extension_p->header.crc32 = crc; + ASSERT(nv_record_data_is_valid(nvrecord_extension_p) && + nv_record_items_is_valid(nvrecord_extension_p), + "%s nv_record is invalid!", __func__); + ret = norflash_api_write( + NORFLASH_API_MODULE_ID_USERDATA_EXT, (uint32_t)(__userdata_start), + (uint8_t *)nvrecord_extension_p, NV_EXTENSION_SIZE, true); + nv_record_post_write_operation(tmpLock); + if (ret == NORFLASH_API_OK) { + nv_flsh_state.is_update = false; + nv_flsh_state.state = NV_STATE_MAIN_WRITTEN; + TRACE(4, "%s: NV_STATE_MAIN_WRITTEN", __func__); + TRACE(4, "%s: norflash_api_write ok,addr = 0x%x.", __func__, + _user_data_main_start); + } else if (ret == NORFLASH_API_BUFFER_FULL) { + norflash_api_flush(); + } else { + ASSERT(0, "%s: norflash_api_write err,ret = %d,addr = 0x%x.", __func__, + ret, _user_data_main_start); + } + } else { + if (norflash_api_get_used_buffer_count( + NORFLASH_API_MODULE_ID_USERDATA_EXT, NORFLASH_API_ALL) == 0) { + nv_flsh_state.state = NV_STATE_MAIN_DONE; + // TRACE(1,"%s: NV_STATE_MAIN_DONE", __func__); + TRACE(1, "%s: async flush done.", __func__); + } else { + norflash_api_flush(); + } + } + int_unlock_global(lock); + hal_trace_continue(); + } else { + TRACE(4, "%s: sync flush begin!", __func__); + if (nv_flsh_state.state == NV_STATE_IDLE || + nv_flsh_state.state == NV_STATE_MAIN_ERASING) { + do { + hal_trace_pause(); + lock = int_lock_global(); + ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA_EXT, + (uint32_t)(__userdata_start), + NV_EXTENSION_SIZE, true); + int_unlock_global(lock); + hal_trace_continue(); + if (ret == NORFLASH_API_OK) { + nv_flsh_state.state = NV_STATE_MAIN_ERASED; + TRACE(4, "%s: norflash_api_erase ok,addr = 0x%x.", __func__, + _user_data_main_start); + } else if (ret == NORFLASH_API_BUFFER_FULL) { + do { + norflash_api_flush(); + } while (norflash_api_get_free_buffer_count(NORFLASH_API_ERASING) == + 0); + } else { + ASSERT(0, "%s: norflash_api_erase err,ret = %d,addr = 0x%x.", + __func__, ret, _user_data_main_start); + } + + } while (ret == NORFLASH_API_BUFFER_FULL); + } + + if (nv_flsh_state.state == NV_STATE_MAIN_ERASED || + nv_flsh_state.state == NV_STATE_MAIN_WRITTING) { + do { + hal_trace_pause(); + uint32_t tmpLock = nv_record_pre_write_operation(); + crc = + crc32(0, (uint8_t *)nvrecord_extension_p + NV_EXTENSION_HEADER_SIZE, + NV_EXTENSION_VALID_LEN); + nvrecord_extension_p->header.crc32 = crc; + ASSERT(nv_record_data_is_valid(nvrecord_extension_p) && + nv_record_items_is_valid(nvrecord_extension_p), + "%s nv_record is invalid!", __func__); + ret = norflash_api_write( + NORFLASH_API_MODULE_ID_USERDATA_EXT, (uint32_t)(__userdata_start), + (uint8_t *)nvrecord_extension_p, NV_EXTENSION_SIZE, true); + nv_record_post_write_operation(tmpLock); + hal_trace_continue(); + if (ret == NORFLASH_API_OK) { + nv_flsh_state.is_update = false; + nv_flsh_state.state = NV_STATE_MAIN_WRITTEN; + TRACE(4, "%s: norflash_api_write ok,addr = 0x%x.", __func__, + _user_data_main_start); + } else if (ret == NORFLASH_API_BUFFER_FULL) { + do { + norflash_api_flush(); + } while (norflash_api_get_free_buffer_count(NORFLASH_API_WRITTING) == + 0); + } else { + ASSERT(0, "%s: norflash_api_write err,ret = %d,addr = 0x%x.", + __func__, ret, _user_data_main_start); + } + } while (ret == NORFLASH_API_BUFFER_FULL); + } + + do { + norflash_api_flush(); + } while (norflash_api_get_used_buffer_count( + NORFLASH_API_MODULE_ID_USERDATA_EXT, NORFLASH_API_ALL) > 0); + + nv_flsh_state.state = NV_STATE_MAIN_DONE; + TRACE(1, "%s: sync flush done.", __func__); + } +_func_end: + return (ret == NORFLASH_API_OK) ? 0 : 1; +} + +static int nv_record_extension_flush_bak(bool is_async) { + uint32_t lock; + enum NORFLASH_API_RET_T ret = NORFLASH_API_OK; + uint8_t *burn_buf = (uint8_t *)_nv_burn_buf; + + if (is_async) { + hal_trace_pause(); + lock = int_lock_global(); + if (nv_flsh_state.state == NV_STATE_MAIN_DONE || + nv_flsh_state.state == NV_STATE_BAK_ERASING) { + if (nv_flsh_state.state == NV_STATE_MAIN_DONE) { + nv_flsh_state.state = NV_STATE_BAK_ERASING; + TRACE(3, "%s: async flush begin", __func__); + } + ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA_EXT, + _user_data_bak_start, NV_EXTENSION_SIZE, true); + if (ret == NORFLASH_API_OK) { + nv_flsh_state.state = NV_STATE_BAK_ERASED; + TRACE(4, "%s: norflash_api_erase ok,addr = 0x%x.", __func__, + _user_data_bak_start); + // TRACE(4,"%s: NV_STATE_BAK_ERASED", __func__); + } else if (ret == NORFLASH_API_BUFFER_FULL) { + norflash_api_flush(); + } else { + ASSERT(0, "%s: norflash_api_erase err,ret = %d,addr = 0x%x.", __func__, + ret, _user_data_bak_start); + } + } else if (nv_flsh_state.state == NV_STATE_BAK_ERASED || + nv_flsh_state.state == NV_STATE_BAK_WRITTING) { + if (nv_flsh_state.state == NV_STATE_BAK_ERASED) { + nv_flsh_state.state = NV_STATE_BAK_WRITTING; + nv_flsh_state.written_size = 0; + // TRACE(4,"%s: NV_STATE_BAK_WRITTING", __func__); + } + do { + ret = norflash_api_read(NORFLASH_API_MODULE_ID_USERDATA_EXT, + _user_data_main_start + + nv_flsh_state.written_size, + burn_buf, NV_EXTENSION_PAGE_SIZE); + ASSERT(ret == NORFLASH_API_OK, + "norflash_api_read failed! ret = %d, addr = 0x%x.", (int32_t)ret, + _user_data_main_start + nv_flsh_state.written_size); + + ret = norflash_api_write(NORFLASH_API_MODULE_ID_USERDATA_EXT, + _user_data_bak_start + + nv_flsh_state.written_size, + burn_buf, NV_EXTENSION_PAGE_SIZE, true); + if (ret == NORFLASH_API_OK) { + nv_flsh_state.written_size += NV_EXTENSION_PAGE_SIZE; + + if (nv_flsh_state.written_size == NV_EXTENSION_SIZE) { + nv_flsh_state.state = NV_STATE_BAK_WRITTEN; + // TRACE(4,"%s: NV_STATE_BAK_WRITTEN", __func__); + break; + } + } else if (ret == NORFLASH_API_BUFFER_FULL) { + norflash_api_flush(); + break; + } else { + ASSERT(0, "%s: norflash_api_write err,ret = %d,addr = 0x%x.", + __func__, ret, + _user_data_bak_start + nv_flsh_state.written_size); + } + } while (1); + } else { + if (norflash_api_get_used_buffer_count( + NORFLASH_API_MODULE_ID_USERDATA_EXT, NORFLASH_API_ALL) == 0) { + nv_flsh_state.state = NV_STATE_BAK_DONE; + TRACE(3, "%s: async flush done.", __func__); + } else { + norflash_api_flush(); + } + } + int_unlock_global(lock); + hal_trace_continue(); + } else { + TRACE(4, "%s: sync flush begin.", __func__); + if (nv_flsh_state.state == NV_STATE_MAIN_DONE || + nv_flsh_state.state == NV_STATE_BAK_ERASING) { + do { + hal_trace_pause(); + lock = int_lock_global(); + ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA_EXT, + _user_data_bak_start, NV_EXTENSION_SIZE, true); + int_unlock_global(lock); + hal_trace_continue(); + if (ret == NORFLASH_API_OK) { + nv_flsh_state.state = NV_STATE_BAK_ERASED; + TRACE(4, "%s: norflash_api_erase ok,addr = 0x%x.", __func__, + _user_data_bak_start); + } else if (ret == NORFLASH_API_BUFFER_FULL) { + do { + norflash_api_flush(); + } while (norflash_api_get_free_buffer_count(NORFLASH_API_ERASING) == + 0); + } else { + ASSERT(0, "%s: norflash_api_erase err,ret = %d,addr = 0x%x.", + __func__, ret, _user_data_bak_start); + } + } while (ret == NORFLASH_API_BUFFER_FULL); + } + + if (nv_flsh_state.state == NV_STATE_BAK_ERASED || + nv_flsh_state.state == NV_STATE_BAK_WRITTING) { + nv_flsh_state.state = NV_STATE_BAK_WRITTING; + nv_flsh_state.written_size = 0; + + hal_trace_pause(); + do { + lock = int_lock_global(); + ret = norflash_api_read(NORFLASH_API_MODULE_ID_USERDATA_EXT, + _user_data_main_start + + nv_flsh_state.written_size, + burn_buf, NV_EXTENSION_PAGE_SIZE); + ASSERT(ret == NORFLASH_API_OK, + "norflash_api_read failed! ret = %d, addr = 0x%x.", (int32_t)ret, + _user_data_main_start + nv_flsh_state.written_size); + + ret = norflash_api_write(NORFLASH_API_MODULE_ID_USERDATA_EXT, + _user_data_bak_start + + nv_flsh_state.written_size, + burn_buf, NV_EXTENSION_PAGE_SIZE, true); + int_unlock_global(lock); + if (ret == NORFLASH_API_OK) { + nv_flsh_state.written_size += NV_EXTENSION_PAGE_SIZE; + if (nv_flsh_state.written_size == NV_EXTENSION_SIZE) { + nv_flsh_state.state = NV_STATE_BAK_WRITTEN; + TRACE(3, "%s: NV_STATE_BAK_WRITTEN", __func__); + break; + } + } else if (ret == NORFLASH_API_BUFFER_FULL) { + do { + norflash_api_flush(); + } while (norflash_api_get_free_buffer_count(NORFLASH_API_WRITTING) == + 0); + } else { + ASSERT(0, "%s: norflash_api_write err,ret = %d,addr = 0x%x.", + __func__, ret, + _user_data_bak_start + nv_flsh_state.written_size); + } + } while (1); + } + hal_trace_continue(); + + // nv_flsh_state.state == NV_STATE_BAK_WRITTEN; + do { + norflash_api_flush(); + } while (norflash_api_get_used_buffer_count( + NORFLASH_API_MODULE_ID_USERDATA_EXT, NORFLASH_API_ALL) > 0); + + nv_flsh_state.state = NV_STATE_BAK_DONE; + TRACE(1, "%s: sync flush done.", __func__); + } + + if (nv_flsh_state.state == NV_STATE_BAK_DONE) { + nv_flsh_state.state = NV_STATE_IDLE; + TRACE(1, "%s: NV_STATE_IDLE", __func__); + } + + return (ret == NORFLASH_API_OK) ? 0 : 1; +} + +static int nv_record_extension_flush(bool is_async) { + int ret = 0; + // TRACE(3, "%s state %d is_update %d", __func__, nv_flsh_state.state, + // nv_flsh_state.is_update); + do { + if (nv_flsh_state.state == NV_STATE_IDLE && + nv_flsh_state.is_update == FALSE) { + break; + } + + if ((nv_flsh_state.state == NV_STATE_IDLE && + nv_flsh_state.is_update == TRUE) || + nv_flsh_state.state == NV_STATE_MAIN_ERASING || + nv_flsh_state.state == NV_STATE_MAIN_ERASED || + nv_flsh_state.state == NV_STATE_MAIN_WRITTING || + nv_flsh_state.state == NV_STATE_MAIN_WRITTEN) { + ret = nv_record_extension_flush_main(is_async); + if (is_async) { + break; + } + } + + if (nv_flsh_state.state == NV_STATE_MAIN_DONE || + nv_flsh_state.state == NV_STATE_BAK_ERASING || + nv_flsh_state.state == NV_STATE_BAK_ERASED || + nv_flsh_state.state == NV_STATE_BAK_WRITTING || + nv_flsh_state.state == NV_STATE_BAK_WRITTEN || + nv_flsh_state.state == NV_STATE_BAK_DONE) { + ret = nv_record_extension_flush_bak(is_async); + } + } while (!is_async); + return ret; +} + +void nv_extension_callback(void *param) { + NORFLASH_API_OPERA_RESULT *opera_result; + opera_result = (NORFLASH_API_OPERA_RESULT *)param; + + TRACE(6, "%s:type = %d, addr = 0x%x,len = 0x%x,remain = %d,result = %d.", + __func__, opera_result->type, opera_result->addr, opera_result->len, + opera_result->remain_num, opera_result->result); +} + +void nv_record_init(void) { + nv_record_open(section_usrdata_ddbrecord); + + nv_custom_parameter_section_init(); +} + +bt_status_t nv_record_open(SECTIONS_ADP_ENUM section_id) { + nv_record_extension_init(); +#ifdef FLASH_SUSPEND + hal_sleep_set_sleep_hook(HAL_SLEEP_HOOK_USER_NVRECORD, + nv_record_flash_flush_in_sleep); +#else + hal_sleep_set_deep_sleep_hook(HAL_DEEP_SLEEP_HOOK_USER_NVRECORD, + nv_record_flash_flush_in_sleep); +#endif + return BT_STS_SUCCESS; +} + +void nv_record_update_runtime_userdata(void) { nv_record_extension_update(); } + +int nv_record_touch_cause_flush(void) { + nv_record_update_runtime_userdata(); + return 0; +} + +void nv_record_sector_clear(void) { + uint32_t lock; + enum NORFLASH_API_RET_T ret; + + lock = int_lock_global(); + ret = + norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA_EXT, + (uint32_t)__userdata_start, NV_EXTENSION_SIZE, false); + ASSERT(ret == NORFLASH_API_OK, + "%s: norflash_api_erase(0x%x) failed! ret = %d.", __func__, + (uint32_t)__userdata_start, (int32_t)ret); + + ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA_EXT, + (uint32_t)__userdata_start + NV_EXTENSION_SIZE, + NV_EXTENSION_SIZE, false); + ASSERT(ret == NORFLASH_API_OK, + "%s: norflash_api_erase(0x%x) failed! ret = %d.", __func__, + (uint32_t)__userdata_start + NV_EXTENSION_SIZE, (int32_t)ret); + // pmu_reboot(); + int_unlock_global(lock); +} + +void nv_record_rebuild(void) { + if (nvrecord_extension_p) { + uint32_t nv_start; + TRACE(1, "%s: begin.", __func__); uint32_t lock = int_lock_global(); mpu_clear(MPU_ID_USER_DATA_SECTION); - return lock; -} - -void nv_record_post_write_operation(uint32_t lock) -{ - int ret = 0; - uint32_t nv_start = (uint32_t)&local_extension_data.nv_record; - uint32_t len = NV_EXTENSION_MIRROR_RAM_SIZE; - - ret = mpu_set(MPU_ID_USER_DATA_SECTION, nv_start, len, 0, MPU_ATTR_READ); - int_unlock_global(lock); - TRACE(2,"set mpu 0x%x len %d result %d", nv_start, len, ret); -} - -static void nv_record_extension_init(void) -{ - uint32_t lock; - bool main_is_valid = false; - bool bak_is_valid = false; - bool data_is_valid = false; - - if(nvrec_init) - { - return; - } - _user_data_main_start = (uint32_t)__userdata_start; - _user_data_bak_start = (uint32_t)__userdata_start + NV_EXTENSION_SIZE; - - lock = nv_record_pre_write_operation(); - _nv_record_extension_init(); - - nv_flsh_state.is_update = false; - nv_flsh_state.written_size = 0; - nv_flsh_state.state = NV_STATE_IDLE; - - nvrecord_extension_p = &local_extension_data.nv_record; - - if(nvrecord_extension_p->header.magicNumber != NV_EXTENSION_MAGIC_NUMBER || - nvrecord_extension_p->header.majorVersion != NV_EXTENSION_MAJOR_VERSION || - nvrecord_extension_p->header.minorVersion != NV_EXTENSION_MINOR_VERSION || - nvrecord_extension_p->header.validLen >= (NV_EXTENSION_SIZE - NV_EXTENSION_HEADER_SIZE)) - { - ASSERT(0, "%s: local_extension_data error!(0x%x,0x%x,0x%x,0x%x)", - __func__, - nvrecord_extension_p->header.magicNumber, - nvrecord_extension_p->header.majorVersion, - nvrecord_extension_p->header.minorVersion, - nvrecord_extension_p->header.validLen); - } - - // Check main sector. - if(nv_record_data_is_valid((NV_EXTENSION_RECORD_T*)_user_data_main_start) - && nv_record_items_is_valid((NV_EXTENSION_RECORD_T*)_user_data_main_start)) - { - TRACE(2,"%s,main sector is valid.",__func__); - main_is_valid = true; - } - else - { - TRACE(1,"%s,main sector is invalid!",__func__); - main_is_valid = false; - } - - // Check bak secotr. - if(nv_record_data_is_valid((NV_EXTENSION_RECORD_T*)_user_data_bak_start) - && nv_record_items_is_valid((NV_EXTENSION_RECORD_T*)_user_data_main_start)) - { - TRACE(2,"%s,bak sector is valid.",__func__); - bak_is_valid = true; - } - else - { - TRACE(1,"%s,bak sector is invalid!",__func__); - bak_is_valid = false; - } - - if(main_is_valid) - { - data_is_valid = true; - if(!bak_is_valid) - { - nv_flsh_state.is_update = true; - nv_flsh_state.state = NV_STATE_MAIN_DONE; - } - } - else - { - if(bak_is_valid) - { - data_is_valid = true; - nv_flsh_state.is_update = true; - nv_flsh_state.state = NV_STATE_IDLE; - } - else - { - data_is_valid = false; - } - } - - if(data_is_valid) - { - TRACE(2,"%s,data is valid.", __func__); - if(main_is_valid) - { - memcpy((uint8_t *)nvrecord_extension_p + NV_EXTENSION_HEADER_SIZE, - (uint8_t *)_user_data_main_start + NV_EXTENSION_HEADER_SIZE, - NV_EXTENSION_VALID_LEN); - } - else - { - memcpy((uint8_t *)nvrecord_extension_p + NV_EXTENSION_HEADER_SIZE, - (uint8_t *)_user_data_bak_start + NV_EXTENSION_HEADER_SIZE, - NV_EXTENSION_VALID_LEN); - } - nvrecord_extension_p->header.crc32 = - crc32(0, - ((uint8_t *)nvrecord_extension_p + NV_EXTENSION_HEADER_SIZE), - nvrecord_extension_p->header.validLen); - } - else - { - TRACE(1,"%s,data invalid, rebuild... ",__func__); - nv_record_set_default(nvrecord_extension_p); - TRACE(2,"%s,rebuild crc = 0x%x. ",__func__,nvrecord_extension_p->header.crc32); - // need to update the content in the flash - nv_record_extension_update(); - } - - nvrec_init = true; - - nv_record_post_write_operation(lock); - - if(nv_flsh_state.is_update) - { - nv_record_extension_flush(false); - } - TRACE(2,"%s,done.", __func__); -} - -NV_EXTENSION_RECORD_T* nv_record_get_extension_entry_ptr(void) -{ - return nvrecord_extension_p; -} - -void nv_record_extension_update(void) -{ - nv_flsh_state.is_update = true; -} - -static int nv_record_extension_flush_main(bool is_async) -{ - uint32_t crc; - uint32_t lock; - enum NORFLASH_API_RET_T ret = NORFLASH_API_OK; - - if(NULL == nvrecord_extension_p) - { - TRACE(1,"%s,nvrecord_extension_p is null.", __func__); - goto _func_end; - } - - // TRACE(3, "%s is_async %d state %d", __func__, is_async, nv_flsh_state.state); - - if(is_async) - { - if(nv_flsh_state.state == NV_STATE_IDLE - && nv_flsh_state.is_update == true) - { - TRACE(3,"%s: async flush begin!", __func__); - } - - hal_trace_pause(); - lock = int_lock_global(); - - if(nv_flsh_state.state == NV_STATE_IDLE - || nv_flsh_state.state == NV_STATE_MAIN_ERASING) - { - if(nv_flsh_state.state == NV_STATE_IDLE) - { - nv_flsh_state.state = NV_STATE_MAIN_ERASING; - TRACE(4,"%s: NV_STATE_MAIN_ERASING", __func__); - } - - ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA_EXT, - (uint32_t)(__userdata_start), - NV_EXTENSION_SIZE, - true); - if(ret == NORFLASH_API_OK) - { - nv_flsh_state.state = NV_STATE_MAIN_ERASED; - TRACE(4,"%s: NV_STATE_MAIN_ERASED", __func__); - TRACE(4,"%s: norflash_api_erase ok,addr = 0x%x.",__func__,_user_data_main_start); - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - norflash_api_flush(); - } - else - { - ASSERT(0,"%s: norflash_api_erase err,ret = %d,addr = 0x%x.",__func__,ret,_user_data_main_start); - } - } - else if(nv_flsh_state.state == NV_STATE_MAIN_ERASED - || nv_flsh_state.state == NV_STATE_MAIN_WRITTING) - { - if(nv_flsh_state.state == NV_STATE_MAIN_ERASED) - { - nv_flsh_state.state = NV_STATE_MAIN_WRITTING; - TRACE(4,"%s: NV_STATE_MAIN_WRITTING", __func__); - } - uint32_t tmpLock = nv_record_pre_write_operation(); - crc = crc32(0,(uint8_t *)nvrecord_extension_p + NV_EXTENSION_HEADER_SIZE, - NV_EXTENSION_VALID_LEN); - nvrecord_extension_p->header.crc32 = crc; - ASSERT(nv_record_data_is_valid(nvrecord_extension_p) - && nv_record_items_is_valid(nvrecord_extension_p), - "%s nv_record is invalid!",__func__); - ret = norflash_api_write(NORFLASH_API_MODULE_ID_USERDATA_EXT, - (uint32_t)(__userdata_start), - (uint8_t *)nvrecord_extension_p, - NV_EXTENSION_SIZE, - true); - nv_record_post_write_operation(tmpLock); - if(ret == NORFLASH_API_OK) - { - nv_flsh_state.is_update = false; - nv_flsh_state.state = NV_STATE_MAIN_WRITTEN; - TRACE(4,"%s: NV_STATE_MAIN_WRITTEN", __func__); - TRACE(4,"%s: norflash_api_write ok,addr = 0x%x.",__func__,_user_data_main_start); - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - norflash_api_flush(); - } - else - { - ASSERT(0,"%s: norflash_api_write err,ret = %d,addr = 0x%x.",__func__,ret,_user_data_main_start); - } - } - else - { - if(norflash_api_get_used_buffer_count(NORFLASH_API_MODULE_ID_USERDATA_EXT,NORFLASH_API_ALL) == 0) - { - nv_flsh_state.state = NV_STATE_MAIN_DONE; - // TRACE(1,"%s: NV_STATE_MAIN_DONE", __func__); - TRACE(1,"%s: async flush done.", __func__); - } - else - { - norflash_api_flush(); - } - } - int_unlock_global(lock); - hal_trace_continue(); - } - else - { - TRACE(4,"%s: sync flush begin!", __func__); - if(nv_flsh_state.state == NV_STATE_IDLE - || nv_flsh_state.state == NV_STATE_MAIN_ERASING) - { - do - { - hal_trace_pause(); - lock = int_lock_global(); - ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA_EXT, - (uint32_t)(__userdata_start), - NV_EXTENSION_SIZE, - true); - int_unlock_global(lock); - hal_trace_continue(); - if(ret == NORFLASH_API_OK) - { - nv_flsh_state.state = NV_STATE_MAIN_ERASED; - TRACE(4,"%s: norflash_api_erase ok,addr = 0x%x.",__func__, _user_data_main_start); - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - do - { - norflash_api_flush(); - }while(norflash_api_get_free_buffer_count(NORFLASH_API_ERASING) == 0); - } - else - { - ASSERT(0,"%s: norflash_api_erase err,ret = %d,addr = 0x%x.",__func__,ret,_user_data_main_start); - } - - }while(ret == NORFLASH_API_BUFFER_FULL); - } - - if(nv_flsh_state.state == NV_STATE_MAIN_ERASED - || nv_flsh_state.state == NV_STATE_MAIN_WRITTING) - { - do - { - hal_trace_pause(); - uint32_t tmpLock = nv_record_pre_write_operation(); - crc = crc32(0,(uint8_t *)nvrecord_extension_p + NV_EXTENSION_HEADER_SIZE, - NV_EXTENSION_VALID_LEN); - nvrecord_extension_p->header.crc32 = crc; - ASSERT(nv_record_data_is_valid(nvrecord_extension_p) - && nv_record_items_is_valid(nvrecord_extension_p), - "%s nv_record is invalid!",__func__); - ret = norflash_api_write(NORFLASH_API_MODULE_ID_USERDATA_EXT, - (uint32_t)(__userdata_start), - (uint8_t *)nvrecord_extension_p, - NV_EXTENSION_SIZE, - true); - nv_record_post_write_operation(tmpLock); - hal_trace_continue(); - if(ret == NORFLASH_API_OK) - { - nv_flsh_state.is_update = false; - nv_flsh_state.state = NV_STATE_MAIN_WRITTEN; - TRACE(4,"%s: norflash_api_write ok,addr = 0x%x.",__func__,_user_data_main_start); - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - do - { - norflash_api_flush(); - }while(norflash_api_get_free_buffer_count(NORFLASH_API_WRITTING) == 0); - } - else - { - ASSERT(0,"%s: norflash_api_write err,ret = %d,addr = 0x%x.",__func__,ret,_user_data_main_start); - } - }while(ret == NORFLASH_API_BUFFER_FULL); - } - - do - { - norflash_api_flush(); - }while(norflash_api_get_used_buffer_count(NORFLASH_API_MODULE_ID_USERDATA_EXT,NORFLASH_API_ALL) > 0); - - nv_flsh_state.state = NV_STATE_MAIN_DONE; - TRACE(1,"%s: sync flush done.", __func__); - } -_func_end: - return (ret == NORFLASH_API_OK) ? 0:1; -} - -static int nv_record_extension_flush_bak(bool is_async) -{ - uint32_t lock; - enum NORFLASH_API_RET_T ret = NORFLASH_API_OK; - uint8_t *burn_buf = (uint8_t*)_nv_burn_buf; - - if(is_async) - { - hal_trace_pause(); - lock = int_lock_global(); - if(nv_flsh_state.state == NV_STATE_MAIN_DONE - || nv_flsh_state.state == NV_STATE_BAK_ERASING) - { - if(nv_flsh_state.state == NV_STATE_MAIN_DONE) - { - nv_flsh_state.state = NV_STATE_BAK_ERASING; - TRACE(3,"%s: async flush begin", __func__); - } - ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA_EXT, - _user_data_bak_start, - NV_EXTENSION_SIZE, - true); - if(ret == NORFLASH_API_OK) - { - nv_flsh_state.state = NV_STATE_BAK_ERASED; - TRACE(4,"%s: norflash_api_erase ok,addr = 0x%x.", - __func__,_user_data_bak_start); - // TRACE(4,"%s: NV_STATE_BAK_ERASED", __func__); - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - norflash_api_flush(); - } - else - { - ASSERT(0,"%s: norflash_api_erase err,ret = %d,addr = 0x%x.", - __func__,ret,_user_data_bak_start); - } - } - else if(nv_flsh_state.state == NV_STATE_BAK_ERASED - || nv_flsh_state.state == NV_STATE_BAK_WRITTING) - { - if(nv_flsh_state.state == NV_STATE_BAK_ERASED) - { - nv_flsh_state.state = NV_STATE_BAK_WRITTING; - nv_flsh_state.written_size = 0; - // TRACE(4,"%s: NV_STATE_BAK_WRITTING", __func__); - } - do - { - ret = norflash_api_read(NORFLASH_API_MODULE_ID_USERDATA_EXT, - _user_data_main_start + nv_flsh_state.written_size, - burn_buf, - NV_EXTENSION_PAGE_SIZE - ); - ASSERT(ret == NORFLASH_API_OK,"norflash_api_read failed! ret = %d, addr = 0x%x.", - (int32_t)ret,_user_data_main_start + nv_flsh_state.written_size); - - ret = norflash_api_write(NORFLASH_API_MODULE_ID_USERDATA_EXT, - _user_data_bak_start + nv_flsh_state.written_size, - burn_buf, - NV_EXTENSION_PAGE_SIZE, - true - ); - if(ret == NORFLASH_API_OK) - { - nv_flsh_state.written_size += NV_EXTENSION_PAGE_SIZE; - - if(nv_flsh_state.written_size == NV_EXTENSION_SIZE) - { - nv_flsh_state.state = NV_STATE_BAK_WRITTEN; - // TRACE(4,"%s: NV_STATE_BAK_WRITTEN", __func__); - break; - } - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - norflash_api_flush(); - break; - } - else - { - ASSERT(0,"%s: norflash_api_write err,ret = %d,addr = 0x%x.", - __func__,ret,_user_data_bak_start + nv_flsh_state.written_size); - } - }while(1); - } - else - { - if(norflash_api_get_used_buffer_count(NORFLASH_API_MODULE_ID_USERDATA_EXT,NORFLASH_API_ALL) == 0) - { - nv_flsh_state.state = NV_STATE_BAK_DONE; - TRACE(3,"%s: async flush done.", __func__); - } - else - { - norflash_api_flush(); - } - } - int_unlock_global(lock); - hal_trace_continue(); - } - else - { - TRACE(4,"%s: sync flush begin.", __func__); - if(nv_flsh_state.state == NV_STATE_MAIN_DONE - || nv_flsh_state.state == NV_STATE_BAK_ERASING) - { - do - { - hal_trace_pause(); - lock = int_lock_global(); - ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA_EXT, - _user_data_bak_start, - NV_EXTENSION_SIZE, - true); - int_unlock_global(lock); - hal_trace_continue(); - if(ret == NORFLASH_API_OK) - { - nv_flsh_state.state = NV_STATE_BAK_ERASED; - TRACE(4,"%s: norflash_api_erase ok,addr = 0x%x.", - __func__, _user_data_bak_start); - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - do - { - norflash_api_flush(); - }while(norflash_api_get_free_buffer_count(NORFLASH_API_ERASING) == 0); - } - else - { - ASSERT(0,"%s: norflash_api_erase err,ret = %d,addr = 0x%x.",__func__,ret,_user_data_bak_start); - } - }while(ret == NORFLASH_API_BUFFER_FULL); - } - - if(nv_flsh_state.state == NV_STATE_BAK_ERASED - || nv_flsh_state.state == NV_STATE_BAK_WRITTING) - { - nv_flsh_state.state = NV_STATE_BAK_WRITTING; - nv_flsh_state.written_size = 0; - - hal_trace_pause(); - do - { - lock = int_lock_global(); - ret = norflash_api_read(NORFLASH_API_MODULE_ID_USERDATA_EXT, - _user_data_main_start + nv_flsh_state.written_size, - burn_buf, - NV_EXTENSION_PAGE_SIZE - ); - ASSERT(ret == NORFLASH_API_OK,"norflash_api_read failed! ret = %d, addr = 0x%x.", - (int32_t)ret, _user_data_main_start + nv_flsh_state.written_size); - - ret = norflash_api_write(NORFLASH_API_MODULE_ID_USERDATA_EXT, - _user_data_bak_start + nv_flsh_state.written_size, - burn_buf, - NV_EXTENSION_PAGE_SIZE, - true - ); - int_unlock_global(lock); - if(ret == NORFLASH_API_OK) - { - nv_flsh_state.written_size += NV_EXTENSION_PAGE_SIZE; - if(nv_flsh_state.written_size == NV_EXTENSION_SIZE) - { - nv_flsh_state.state = NV_STATE_BAK_WRITTEN; - TRACE(3,"%s: NV_STATE_BAK_WRITTEN", __func__); - break; - } - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - do - { - norflash_api_flush(); - }while(norflash_api_get_free_buffer_count(NORFLASH_API_WRITTING) == 0); - } - else - { - ASSERT(0,"%s: norflash_api_write err,ret = %d,addr = 0x%x.", - __func__,ret,_user_data_bak_start + nv_flsh_state.written_size); - } - }while(1); - } - hal_trace_continue(); - - // nv_flsh_state.state == NV_STATE_BAK_WRITTEN; - do - { - norflash_api_flush(); - }while(norflash_api_get_used_buffer_count(NORFLASH_API_MODULE_ID_USERDATA_EXT,NORFLASH_API_ALL) > 0); - - nv_flsh_state.state = NV_STATE_BAK_DONE; - TRACE(1,"%s: sync flush done.", __func__); - } - - if(nv_flsh_state.state == NV_STATE_BAK_DONE) - { - nv_flsh_state.state = NV_STATE_IDLE; - TRACE(1,"%s: NV_STATE_IDLE", __func__); - } - - return (ret == NORFLASH_API_OK) ? 0:1; -} - - -static int nv_record_extension_flush(bool is_async) -{ - int ret = 0; - // TRACE(3, "%s state %d is_update %d", __func__, nv_flsh_state.state, nv_flsh_state.is_update); - do{ - if(nv_flsh_state.state == NV_STATE_IDLE - && nv_flsh_state.is_update == FALSE) - { - break; - } - - if((nv_flsh_state.state == NV_STATE_IDLE - && nv_flsh_state.is_update == TRUE) - || nv_flsh_state.state == NV_STATE_MAIN_ERASING - || nv_flsh_state.state == NV_STATE_MAIN_ERASED - || nv_flsh_state.state == NV_STATE_MAIN_WRITTING - || nv_flsh_state.state == NV_STATE_MAIN_WRITTEN - ) - { - ret = nv_record_extension_flush_main(is_async); - if(is_async) - { - break; - } - } - - if(nv_flsh_state.state == NV_STATE_MAIN_DONE - || nv_flsh_state.state == NV_STATE_BAK_ERASING - || nv_flsh_state.state == NV_STATE_BAK_ERASED - || nv_flsh_state.state == NV_STATE_BAK_WRITTING - || nv_flsh_state.state == NV_STATE_BAK_WRITTEN - || nv_flsh_state.state == NV_STATE_BAK_DONE - ) - { - ret = nv_record_extension_flush_bak(is_async); - } - }while(!is_async); - return ret; -} - -void nv_extension_callback(void* param) -{ - NORFLASH_API_OPERA_RESULT *opera_result; - opera_result = (NORFLASH_API_OPERA_RESULT*)param; - - TRACE(6,"%s:type = %d, addr = 0x%x,len = 0x%x,remain = %d,result = %d.", - __func__, - opera_result->type, - opera_result->addr, - opera_result->len, - opera_result->remain_num, - opera_result->result); -} - -void nv_record_init(void) -{ - nv_record_open(section_usrdata_ddbrecord); - - nv_custom_parameter_section_init(); -} - -bt_status_t nv_record_open(SECTIONS_ADP_ENUM section_id) -{ - nv_record_extension_init(); -#ifdef FLASH_SUSPEND - hal_sleep_set_sleep_hook(HAL_SLEEP_HOOK_USER_NVRECORD, - nv_record_flash_flush_in_sleep); -#else - hal_sleep_set_deep_sleep_hook(HAL_DEEP_SLEEP_HOOK_USER_NVRECORD, - nv_record_flash_flush_in_sleep); -#endif - return BT_STS_SUCCESS; -} - -void nv_record_update_runtime_userdata(void) -{ + nv_record_set_default(nvrecord_extension_p); + nv_start = (uint32_t)&local_extension_data.nv_record; + mpu_set(MPU_ID_USER_DATA_SECTION, nv_start, NV_EXTENSION_MIRROR_RAM_SIZE, 0, + MPU_ATTR_READ); nv_record_extension_update(); -} - - -int nv_record_touch_cause_flush(void) -{ - nv_record_update_runtime_userdata(); - return 0; -} - -void nv_record_sector_clear(void) -{ - uint32_t lock; - enum NORFLASH_API_RET_T ret; - - lock = int_lock_global(); - ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA_EXT, - (uint32_t)__userdata_start, - NV_EXTENSION_SIZE, - false); - ASSERT(ret == NORFLASH_API_OK, - "%s: norflash_api_erase(0x%x) failed! ret = %d.", - __func__, (uint32_t)__userdata_start, (int32_t)ret); - - ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA_EXT, - (uint32_t)__userdata_start + NV_EXTENSION_SIZE, - NV_EXTENSION_SIZE, - false); - ASSERT(ret == NORFLASH_API_OK, - "%s: norflash_api_erase(0x%x) failed! ret = %d.", - __func__, (uint32_t)__userdata_start + NV_EXTENSION_SIZE, (int32_t)ret); - //pmu_reboot(); + nv_record_flash_flush(); int_unlock_global(lock); + TRACE(1, "%s: done.", __func__); + } else { + TRACE(1, "%s: begin. nvrecord_extension_p = null.", __func__); + uint32_t lock = int_lock_global(); + nv_record_sector_clear(); + nvrec_init = false; + nv_record_extension_init(); + int_unlock_global(lock); + TRACE(1, "%s: done.", __func__); + } } -void nv_record_rebuild(void) -{ - if(nvrecord_extension_p) - { - uint32_t nv_start; - TRACE(1,"%s: begin.", __func__); - uint32_t lock = int_lock_global(); - mpu_clear(MPU_ID_USER_DATA_SECTION); - nv_record_set_default(nvrecord_extension_p); - nv_start = (uint32_t)&local_extension_data.nv_record; - mpu_set(MPU_ID_USER_DATA_SECTION, nv_start, - NV_EXTENSION_MIRROR_RAM_SIZE, 0, MPU_ATTR_READ); - nv_record_extension_update(); - nv_record_flash_flush(); - int_unlock_global(lock); - TRACE(1,"%s: done.", __func__); - } - else - { - TRACE(1,"%s: begin. nvrecord_extension_p = null.", __func__); - uint32_t lock = int_lock_global(); - nv_record_sector_clear(); - nvrec_init = false; - nv_record_extension_init(); - int_unlock_global(lock); - TRACE(1,"%s: done.", __func__); - } -} - -#define NV_RECORD_FLUSH_EXECUTION_INTERVAL_MS (20*60*1000) +#define NV_RECORD_FLUSH_EXECUTION_INTERVAL_MS (20 * 60 * 1000) static uint32_t lastFlushCheckPointInMs = 0; -static void nv_record_reset_flush_checkpoint(void) -{ - lastFlushCheckPointInMs = GET_CURRENT_MS();; +static void nv_record_reset_flush_checkpoint(void) { + lastFlushCheckPointInMs = GET_CURRENT_MS(); + ; } -static bool nv_record_is_timer_expired_to_check(void) -{ - uint32_t passedTimerMs; - uint32_t currentTimerMs = GET_CURRENT_MS(); +static bool nv_record_is_timer_expired_to_check(void) { + uint32_t passedTimerMs; + uint32_t currentTimerMs = GET_CURRENT_MS(); - if (0 == lastFlushCheckPointInMs) - { - passedTimerMs = currentTimerMs; - } - else - { - if (currentTimerMs > lastFlushCheckPointInMs) - { - passedTimerMs = currentTimerMs - lastFlushCheckPointInMs; - } - else - { - passedTimerMs = 0xFFFFFFFF - lastFlushCheckPointInMs + currentTimerMs + 1; - } + if (0 == lastFlushCheckPointInMs) { + passedTimerMs = currentTimerMs; + } else { + if (currentTimerMs > lastFlushCheckPointInMs) { + passedTimerMs = currentTimerMs - lastFlushCheckPointInMs; + } else { + passedTimerMs = 0xFFFFFFFF - lastFlushCheckPointInMs + currentTimerMs + 1; } + } - if (passedTimerMs > NV_RECORD_FLUSH_EXECUTION_INTERVAL_MS) - { - return true; - } - else - { - return false; - } + if (passedTimerMs > NV_RECORD_FLUSH_EXECUTION_INTERVAL_MS) { + return true; + } else { + return false; + } } -void nv_record_flash_flush(void) -{ - nv_record_extension_flush(false); +void nv_record_flash_flush(void) { + nv_record_extension_flush(false); + nv_record_reset_flush_checkpoint(); +} + +void nv_record_execute_async_flush(void) { + int ret = nv_record_extension_flush(true); + if (0 == ret) { nv_record_reset_flush_checkpoint(); + } } -void nv_record_execute_async_flush(void) -{ - int ret = nv_record_extension_flush(true); - if (0 == ret) - { - nv_record_reset_flush_checkpoint(); - } -} - -int nv_record_flash_flush_in_sleep(void) -{ - if ((NV_STATE_IDLE == nv_flsh_state.state) && - !nv_record_is_timer_expired_to_check()) - { - return 0; - } - - nv_record_execute_async_flush(); +int nv_record_flash_flush_in_sleep(void) { + if ((NV_STATE_IDLE == nv_flsh_state.state) && + !nv_record_is_timer_expired_to_check()) { return 0; + } + + nv_record_execute_async_flush(); + return 0; } #endif // #if defined(NEW_NV_RECORD_ENABLED) diff --git a/services/nv_section/userdata_section/nvrecord_extension.h b/services/nv_section/userdata_section/nvrecord_extension.h index 5f32691..cee868f 100644 --- a/services/nv_section/userdata_section/nvrecord_extension.h +++ b/services/nv_section/userdata_section/nvrecord_extension.h @@ -18,19 +18,24 @@ #ifndef __NVRECORD_EXTENSION_H__ #define __NVRECORD_EXTENSION_H__ #include "bluetooth.h" -#include "me_api.h" #include "btif_sys_config.h" +#include "me_api.h" +#include -// increase by 1 if the nvrecord's whole data structure is changed and the content needs to be rebuilt +// increase by 1 if the nvrecord's whole data structure is changed and the +// content needs to be rebuilt #define NV_EXTENSION_MAJOR_VERSION 3 -// increase by 1 if the new items are appended to the tail of the former nvrecord's data structure +// increase by 1 if the new items are appended to the tail of the former +// nvrecord's data structure #define NV_EXTENSION_MINOR_VERSION 1 -#define NV_EXTENSION_SIZE 4096 // one flash page +#define NV_EXTENSION_SIZE 4096 // one flash page #define NV_EXTENSION_PAGE_SIZE 256 -#define NV_EXTENSION_HEADER_SIZE sizeof(NVRECORD_HEADER_T) // magic number and valid length +#define NV_EXTENSION_HEADER_SIZE \ + sizeof(NVRECORD_HEADER_T) // magic number and valid length #define NV_EXTENSION_MAGIC_NUMBER 0x4E455854 -#define NV_EXTENSION_VALID_LEN (sizeof(NV_EXTENSION_RECORD_T) - sizeof(NVRECORD_HEADER_T)) +#define NV_EXTENSION_VALID_LEN \ + (sizeof(NV_EXTENSION_RECORD_T) - sizeof(NVRECORD_HEADER_T)) /* unused, just for backwards compatible */ #define section_name_ddbrec "ddbrec" @@ -58,17 +63,21 @@ #ifdef OTA_ENABLED #define MAX_VERSION_STRING_LEN 16 -#define OTA_DEVICE_CNT 2 //!< should be equal to OTA_DEVICE_NUM in @see OTA_DEVICE_E +#define OTA_DEVICE_CNT \ + 2 //!< should be equal to OTA_DEVICE_NUM in @see OTA_DEVICE_E #endif #ifdef BISTO_ENABLED #ifdef GSOUND_HOTWORD_ENABLED -#define MODEL_FILE_EMBEDED 1 //!< define this macro when model file is emneded in our bin file +#define MODEL_FILE_EMBEDED \ + 1 //!< define this macro when model file is emneded in our bin file #if MODEL_FILE_EMBEDED -#define HOTWORD_MODLE_MAX_NUM 11//!< need to adjust this value if support more model +#define HOTWORD_MODLE_MAX_NUM \ + 11 //!< need to adjust this value if support more model #else -#define HOTWORD_MODLE_MAX_NUM 10 //!< need to adjust this value if support more model +#define HOTWORD_MODLE_MAX_NUM \ + 10 //!< need to adjust this value if support more model #endif #endif // #ifdef GSOUND_HOTWORD_ENABLED @@ -76,247 +85,244 @@ // TODO: should be increased if NV_EXTENSION_MIRROR_RAM_SIZE exceeds this value -#if defined(__AI_VOICE__ ) || (defined(BISTO_ENABLED)|| defined(GFPS_ENABLED)) +#if defined(__AI_VOICE__) || (defined(BISTO_ENABLED) || defined(GFPS_ENABLED)) #define NV_EXTENSION_MIRROR_RAM_SIZE 0x800 #else #define NV_EXTENSION_MIRROR_RAM_SIZE 0x400 #endif #define TILE_INFO_SIZE 400 -#define BT_FREQENCY_RANGE_NUM 3 +#define BT_FREQENCY_RANGE_NUM 3 #define BT_IQ_INVALID_MAGIC_NUM 0xFFFFFFFF -#define BT_IQ_VALID_MAGIC_NUM 0x5a5a5a5a -typedef struct -{ - uint32_t validityMagicNum; - uint16_t gain_cal_val[BT_FREQENCY_RANGE_NUM]; - uint16_t phase_cal_val[BT_FREQENCY_RANGE_NUM]; +#define BT_IQ_VALID_MAGIC_NUM 0x5a5a5a5a +typedef struct { + uint32_t validityMagicNum; + uint16_t gain_cal_val[BT_FREQENCY_RANGE_NUM]; + uint16_t phase_cal_val[BT_FREQENCY_RANGE_NUM]; } BT_IQ_CALIBRATION_CONFIG_T; /* nv record header data structure */ -typedef struct -{ - uint32_t magicNumber; - uint16_t majorVersion; // should be NV_EXTENSION_MAJOR_VERSION - uint16_t minorVersion; // should be NV_EXTENSION_MINOR_VERSION - uint32_t validLen; // should be the valid content in this nv record version - uint32_t crc32; // crc32 of following valid values in the nv extention section +typedef struct { + uint32_t magicNumber; + uint16_t majorVersion; // should be NV_EXTENSION_MAJOR_VERSION + uint16_t minorVersion; // should be NV_EXTENSION_MINOR_VERSION + uint32_t validLen; // should be the valid content in this nv record version + uint32_t crc32; // crc32 of following valid values in the nv extention section } NVRECORD_HEADER_T; /* system information */ typedef struct { - int8_t language; + int8_t language; } media_language_t; #if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) typedef struct { - int8_t src_snk_mode; + int8_t src_snk_mode; } src_snk_t; #endif typedef struct { - uint32_t mode; - btif_device_record_t record; - bool tws_connect_success; + uint32_t mode; + btif_device_record_t record; + bool tws_connect_success; } ibrt_mode_t; typedef struct { - uint32_t status; + uint32_t status; } factory_tester_status_t; typedef struct { - bool voice_key_enable; - uint8_t setedCurrentAi; //if false, set ai default mode - uint8_t currentAiSpec; // - uint8_t aiStatusDisableFlag; //all ai disable flag - uint8_t amaAssistantEnableStatus; //ama enable flag + bool voice_key_enable; + uint8_t setedCurrentAi; // if false, set ai default mode + uint8_t currentAiSpec; // + uint8_t aiStatusDisableFlag; // all ai disable flag + uint8_t amaAssistantEnableStatus; // ama enable flag } AI_MANAGER_INFO_T; struct nvrecord_env_t { - media_language_t media_language; + media_language_t media_language; #if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE) - src_snk_t src_snk_flag; + src_snk_t src_snk_flag; #endif - ibrt_mode_t ibrt_mode; - factory_tester_status_t factory_tester_status; + ibrt_mode_t ibrt_mode; + factory_tester_status_t factory_tester_status; - uint8_t flag_value[8]; - AI_MANAGER_INFO_T aiManagerInfo; + uint8_t flag_value[8]; + AI_MANAGER_INFO_T aiManagerInfo; }; typedef struct btdevice_volume { - int8_t a2dp_vol; - int8_t hfp_vol; + int8_t a2dp_vol; + int8_t hfp_vol; } btdevice_volume; typedef struct btdevice_profile { - bool hfp_act; - bool hsp_act; - bool a2dp_act; - uint8_t a2dp_codectype; + bool hfp_act; + bool hsp_act; + bool a2dp_act; + uint8_t a2dp_codectype; } btdevice_profile; typedef struct { - btif_device_record_t record; - btdevice_volume device_vol; - btdevice_profile device_plf; + btif_device_record_t record; + btdevice_volume device_vol; + btdevice_profile device_plf; #ifdef BTIF_DIP_DEVICE - uint16_t vend_id; - uint16_t vend_id_source; - uint16_t reserve; + uint16_t vend_id; + uint16_t vend_id_source; + uint16_t reserve; #endif } nvrec_btdevicerecord; typedef struct { - uint32_t pairedDevNum; - nvrec_btdevicerecord pairedBtDevInfo[MAX_BT_PAIRED_DEVICE_COUNT]; + uint32_t pairedDevNum; + nvrec_btdevicerecord pairedBtDevInfo[MAX_BT_PAIRED_DEVICE_COUNT]; } NV_RECORD_PAIRED_BT_DEV_INFO_T; -typedef enum { - section_usrdata_ddbrecord, - section_none -} SECTIONS_ADP_ENUM; +typedef enum { section_usrdata_ddbrecord, section_none } SECTIONS_ADP_ENUM; typedef struct { - uint8_t ble_addr[BTIF_BD_ADDR_SIZE]; - uint8_t ble_irk[BLE_IRK_SIZE]; + uint8_t ble_addr[BTIF_BD_ADDR_SIZE]; + uint8_t ble_irk[BLE_IRK_SIZE]; } BLE_BASIC_INFO_T; typedef struct { - uint8_t peer_bleAddr[BLE_ADDR_SIZE]; - uint16_t EDIV; - uint8_t RANDOM[BLE_ENC_RANDOM_SIZE]; - uint8_t LTK[BLE_LTK_SIZE]; - uint8_t IRK[BLE_IRK_SIZE]; - uint8_t bonded; + uint8_t peer_bleAddr[BLE_ADDR_SIZE]; + uint16_t EDIV; + uint8_t RANDOM[BLE_ENC_RANDOM_SIZE]; + uint8_t LTK[BLE_LTK_SIZE]; + uint8_t IRK[BLE_IRK_SIZE]; + uint8_t bonded; } BleDeviceinfo; typedef struct { - uint32_t saved_list_num; - BLE_BASIC_INFO_T self_info; - BleDeviceinfo ble_nv[BLE_RECORD_NUM]; + uint32_t saved_list_num; + BLE_BASIC_INFO_T self_info; + BleDeviceinfo ble_nv[BLE_RECORD_NUM]; } NV_RECORD_PAIRED_BLE_DEV_INFO_T; #ifdef TWS_SYSTEM_ENABLED typedef struct { - BLE_BASIC_INFO_T ble_info; + BLE_BASIC_INFO_T ble_info; } TWS_INFO_T; -#endif // #ifdef TWS_SYSTEM_ENABLED +#endif // #ifdef TWS_SYSTEM_ENABLED #ifdef GFPS_ENABLED typedef struct { - uint8_t key[FP_ACCOUNT_KEY_SIZE]; + uint8_t key[FP_ACCOUNT_KEY_SIZE]; } NV_FP_ACCOUNT_KEY_ENTRY_T; typedef struct { - uint32_t key_count; - NV_FP_ACCOUNT_KEY_ENTRY_T accountKey[FP_ACCOUNT_KEY_RECORD_NUM]; - uint16_t nameLen; - uint8_t name[FP_MAX_NAME_LEN]; + uint32_t key_count; + NV_FP_ACCOUNT_KEY_ENTRY_T accountKey[FP_ACCOUNT_KEY_RECORD_NUM]; + uint16_t nameLen; + uint8_t name[FP_MAX_NAME_LEN]; } NV_FP_ACCOUNT_KEY_RECORD_T; -#endif // #ifdef GFPS_ENABLED +#endif // #ifdef GFPS_ENABLED #ifdef NVREC_BAIDU_DATA_SECTION /* DMA owned configuration information */ typedef struct { - int32_t fmfreq; - char rand[BAIDU_DATA_RAND_LEN + 1]; + int32_t fmfreq; + char rand[BAIDU_DATA_RAND_LEN + 1]; } NV_DMA_CONFIGURATION_T; -#endif // #ifdef NVREC_BAIDU_DATA_SECTION +#endif // #ifdef NVREC_BAIDU_DATA_SECTION #ifdef TILE_DATAPATH typedef struct { - uint8_t tileInfo[TILE_INFO_SIZE]; + uint8_t tileInfo[TILE_INFO_SIZE]; } NV_TILE_INFO_CONFIG_T; #endif #if defined(OTA_ENABLED) typedef struct { - // hotword model ID, arry size should equal to GSOUND_HOTWORD_MODEL_ID_BYTES - char modelId[5]; + // hotword model ID, arry size should equal to GSOUND_HOTWORD_MODEL_ID_BYTES + char modelId[5]; - // start addr of the model - uint32_t startAddr; + // start addr of the model + uint32_t startAddr; - // length of model file - uint32_t len; -}HOTWORD_MODEL_INFO_T; + // length of model file + uint32_t len; +} HOTWORD_MODEL_INFO_T; typedef struct { - uint32_t imageSize; //!< image size of ongoing upgrade - uint32_t breakPoint; //!< break point of ongoing upgrade - char version[MAX_VERSION_STRING_LEN]; //!< version string of ongoing upgrade - uint8_t versionLen; //!< version string length of ongoing upgrade - uint8_t otaStatus; //!< status of ongoing upgrade - uint8_t user; //!< user of ongoing upgrade + uint32_t imageSize; //!< image size of ongoing upgrade + uint32_t breakPoint; //!< break point of ongoing upgrade + char version[MAX_VERSION_STRING_LEN]; //!< version string of ongoing upgrade + uint8_t versionLen; //!< version string length of ongoing upgrade + uint8_t otaStatus; //!< status of ongoing upgrade + uint8_t user; //!< user of ongoing upgrade } NV_OTA_INFO_T; #endif #ifdef BISTO_ENABLED typedef struct { - uint8_t isGsoundEnabled; + uint8_t isGsoundEnabled; - // this is used for hotword model - // for non-hotword version, this should always be 0 - uint8_t supportedModelCnt; + // this is used for hotword model + // for non-hotword version, this should always be 0 + uint8_t supportedModelCnt; #ifdef GSOUND_HOTWORD_ENABLED - // store the hotword model info - HOTWORD_MODEL_INFO_T modelInfo[HOTWORD_MODLE_MAX_NUM]; + // store the hotword model info + HOTWORD_MODEL_INFO_T modelInfo[HOTWORD_MODLE_MAX_NUM]; #endif } NV_GSOUND_INFO_T; #endif typedef struct { - NVRECORD_HEADER_T header; - struct nvrecord_env_t system_info; - NV_RECORD_PAIRED_BT_DEV_INFO_T bt_pair_info; - NV_RECORD_PAIRED_BLE_DEV_INFO_T ble_pair_info; + NVRECORD_HEADER_T header; + struct nvrecord_env_t system_info; + NV_RECORD_PAIRED_BT_DEV_INFO_T bt_pair_info; + NV_RECORD_PAIRED_BLE_DEV_INFO_T ble_pair_info; #ifdef TWS_SYSTEM_ENABLED - TWS_INFO_T tws_info; + TWS_INFO_T tws_info; #endif #ifdef GFPS_ENABLED - NV_FP_ACCOUNT_KEY_RECORD_T fp_account_key_rec; + NV_FP_ACCOUNT_KEY_RECORD_T fp_account_key_rec; #endif #ifdef NVREC_BAIDU_DATA_SECTION - NV_DMA_CONFIGURATION_T dma_config; + NV_DMA_CONFIGURATION_T dma_config; #endif #ifdef TILE_DATAPATH - NV_TILE_INFO_CONFIG_T tileConfig; + NV_TILE_INFO_CONFIG_T tileConfig; #endif #ifdef OTA_ENABLED - NV_OTA_INFO_T ota_info[OTA_DEVICE_CNT]; + NV_OTA_INFO_T ota_info[OTA_DEVICE_CNT]; #endif #if defined(BISTO_ENABLED) - NV_GSOUND_INFO_T gsound_info; + NV_GSOUND_INFO_T gsound_info; #endif -#if 1//def TX_IQ_CAL - BT_IQ_CALIBRATION_CONFIG_T btIqCalConfig; +#if 1 // def TX_IQ_CAL + BT_IQ_CALIBRATION_CONFIG_T btIqCalConfig; #endif - // TODO: If wanna OTA to update the nv record, two choices: - // 1. Change above data structures and increase NV_EXTENSION_MAJOR_VERSION. - // Then the nv record will be rebuilt and the whole history information will be cleared - // 2. Don't touch above data structures but just add new items here and increase NV_EXTENSION_MINOR_VERSION. - // Then the nv record will keep all the whole hisotry. + // TODO: If wanna OTA to update the nv record, two choices: + // 1. Change above data structures and increase NV_EXTENSION_MAJOR_VERSION. + // Then the nv record will be rebuilt and the whole history information + // will be cleared + // 2. Don't touch above data structures but just add new items here and + // increase NV_EXTENSION_MINOR_VERSION. + // Then the nv record will keep all the whole hisotry. } NV_EXTENSION_RECORD_T; typedef union { - NV_EXTENSION_RECORD_T nv_record; - /* - * dummy data, just make sure the mirror buffer's size is - * "NV_EXTENSION_MIRROR_RAM_SIZE" - */ - uint8_t dummy_data[NV_EXTENSION_MIRROR_RAM_SIZE]; + NV_EXTENSION_RECORD_T nv_record; + /* + * dummy data, just make sure the mirror buffer's size is + * "NV_EXTENSION_MIRROR_RAM_SIZE" + */ + uint8_t dummy_data[NV_EXTENSION_MIRROR_RAM_SIZE]; } NV_MIRROR_BUF_T; #ifdef __cplusplus @@ -359,4 +365,4 @@ void nv_record_init(void); } #endif #endif -#endif //#if defined(NEW_NV_RECORD_ENABLED) +#endif // #if defined(NEW_NV_RECORD_ENABLED) diff --git a/services/nv_section/userdata_section/nvrecord_fp_account_key.c b/services/nv_section/userdata_section/nvrecord_fp_account_key.c index 49fc174..283d0fa 100644 --- a/services/nv_section/userdata_section/nvrecord_fp_account_key.c +++ b/services/nv_section/userdata_section/nvrecord_fp_account_key.c @@ -15,152 +15,137 @@ ****************************************************************************/ #if defined(NEW_NV_RECORD_ENABLED) //#include "cmsis_os.h" -#include -#include -#include -#include "nvrecord_extension.h" #include "nvrecord_fp_account_key.h" #include "hal_trace.h" +#include "nvrecord_extension.h" +#include +#include +#include -#ifdef GFPS_ENABLED +#ifdef GFPS_ENABLED static NV_FP_ACCOUNT_KEY_RECORD_T *nvrecord_fp_account_key_p = NULL; -void nvrecord_rebuild_fp_account_key(NV_FP_ACCOUNT_KEY_RECORD_T* pFpAccountKey) -{ - memset((uint8_t *)pFpAccountKey, 0, sizeof(NV_FP_ACCOUNT_KEY_RECORD_T)); - pFpAccountKey->key_count = 0; +void nvrecord_rebuild_fp_account_key( + NV_FP_ACCOUNT_KEY_RECORD_T *pFpAccountKey) { + memset((uint8_t *)pFpAccountKey, 0, sizeof(NV_FP_ACCOUNT_KEY_RECORD_T)); + pFpAccountKey->key_count = 0; } -NV_FP_ACCOUNT_KEY_RECORD_T* nv_record_get_fp_data_structure_info(void) -{ - return nvrecord_fp_account_key_p; +NV_FP_ACCOUNT_KEY_RECORD_T *nv_record_get_fp_data_structure_info(void) { + return nvrecord_fp_account_key_p; } -void nv_record_update_fp_data_structure(NV_FP_ACCOUNT_KEY_RECORD_T* pFpData) -{ - if (!memcmp((uint8_t *)pFpData, (uint8_t *)nvrecord_fp_account_key_p, - sizeof(NV_FP_ACCOUNT_KEY_RECORD_T))) - { - // the updated fp data is the same as the local content, do nothing - } - else - { - uint32_t lock = nv_record_pre_write_operation(); - TRACE(0,"Fast pair non-volatile data needs to be updated to aligned with peer device."); - *nvrecord_fp_account_key_p = *pFpData; - nv_record_post_write_operation(lock); - nv_record_update_runtime_userdata(); - } -} - -void nv_record_fp_account_key_init(void) -{ - if (NULL == nvrecord_fp_account_key_p) - { - nvrecord_fp_account_key_p = &(nvrecord_extension_p->fp_account_key_rec); - } -} - -void nv_record_fp_account_key_add(NV_FP_ACCOUNT_KEY_ENTRY_T* param_rec) -{ - TRACE(0,"Add account key:"); - DUMP8("0x%02x ", param_rec->key, sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); +void nv_record_update_fp_data_structure(NV_FP_ACCOUNT_KEY_RECORD_T *pFpData) { + if (!memcmp((uint8_t *)pFpData, (uint8_t *)nvrecord_fp_account_key_p, + sizeof(NV_FP_ACCOUNT_KEY_RECORD_T))) { + // the updated fp data is the same as the local content, do nothing + } else { uint32_t lock = nv_record_pre_write_operation(); - if (FP_ACCOUNT_KEY_RECORD_NUM == nvrecord_fp_account_key_p->key_count) - { - // discard the earliest key - memmove((uint8_t *)&(nvrecord_fp_account_key_p->accountKey[0]), - (uint8_t *)&(nvrecord_fp_account_key_p->accountKey[1]), - (FP_ACCOUNT_KEY_RECORD_NUM - 1)*sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); - - nvrecord_fp_account_key_p->key_count--; - } - - memcpy((uint8_t *)&(nvrecord_fp_account_key_p->accountKey[nvrecord_fp_account_key_p->key_count]), - param_rec, - sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); - - nvrecord_fp_account_key_p->key_count++; + TRACE(0, "Fast pair non-volatile data needs to be updated to aligned with " + "peer device."); + *nvrecord_fp_account_key_p = *pFpData; nv_record_post_write_operation(lock); nv_record_update_runtime_userdata(); + } } -void nv_record_fp_account_info_reset(void) -{ - uint32_t lock = nv_record_pre_write_operation(); - uint8_t size = nv_record_fp_account_key_count(); - for (uint8_t i = 0 ; i < size ; i++){ +void nv_record_fp_account_key_init(void) { + if (NULL == nvrecord_fp_account_key_p) { + nvrecord_fp_account_key_p = &(nvrecord_extension_p->fp_account_key_rec); + } +} + +void nv_record_fp_account_key_add(NV_FP_ACCOUNT_KEY_ENTRY_T *param_rec) { + TRACE(0, "Add account key:"); + DUMP8("0x%02x ", param_rec->key, sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); + uint32_t lock = nv_record_pre_write_operation(); + if (FP_ACCOUNT_KEY_RECORD_NUM == nvrecord_fp_account_key_p->key_count) { + // discard the earliest key + memmove((uint8_t *)&(nvrecord_fp_account_key_p->accountKey[0]), + (uint8_t *)&(nvrecord_fp_account_key_p->accountKey[1]), + (FP_ACCOUNT_KEY_RECORD_NUM - 1) * + sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); + + nvrecord_fp_account_key_p->key_count--; + } + + memcpy((uint8_t *)&(nvrecord_fp_account_key_p + ->accountKey[nvrecord_fp_account_key_p->key_count]), + param_rec, sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); + + nvrecord_fp_account_key_p->key_count++; + nv_record_post_write_operation(lock); + nv_record_update_runtime_userdata(); +} + +void nv_record_fp_account_info_reset(void) { + uint32_t lock = nv_record_pre_write_operation(); + uint8_t size = nv_record_fp_account_key_count(); + for (uint8_t i = 0; i < size; i++) { memset((uint8_t *)&(nvrecord_fp_account_key_p->accountKey[i]), 0, sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); - } - nvrecord_fp_account_key_p->key_count = 0; - nv_record_post_write_operation(lock); - nv_record_fp_update_name(NULL, 0); + } + nvrecord_fp_account_key_p->key_count = 0; + nv_record_post_write_operation(lock); + nv_record_fp_update_name(NULL, 0); } -void nv_record_fp_account_key_delete(void) -{ - nv_record_fp_account_info_reset(); +void nv_record_fp_account_key_delete(void) { + nv_record_fp_account_info_reset(); } -bool nv_record_fp_account_key_get_by_index(uint8_t index, uint8_t* outputKey) -{ - if (nvrecord_fp_account_key_p->key_count < (index + 1)) - { - return false; - } - - memcpy(outputKey, (uint8_t *)&(nvrecord_fp_account_key_p->accountKey[index]), - sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); +bool nv_record_fp_account_key_get_by_index(uint8_t index, uint8_t *outputKey) { + if (nvrecord_fp_account_key_p->key_count < (index + 1)) { + return false; + } - TRACE(1,"Get account key %d as:", index); - DUMP8("0x%02x ", outputKey, sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); - - return true; + memcpy(outputKey, (uint8_t *)&(nvrecord_fp_account_key_p->accountKey[index]), + sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); + + TRACE(1, "Get account key %d as:", index); + DUMP8("0x%02x ", outputKey, sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); + + return true; } -uint8_t nv_record_fp_account_key_count(void) -{ - ASSERT(nvrecord_fp_account_key_p->key_count <= FP_ACCOUNT_KEY_RECORD_NUM, "fp account exceed"); - return nvrecord_fp_account_key_p->key_count; +uint8_t nv_record_fp_account_key_count(void) { + ASSERT(nvrecord_fp_account_key_p->key_count <= FP_ACCOUNT_KEY_RECORD_NUM, + "fp account exceed"); + return nvrecord_fp_account_key_p->key_count; } -void nv_record_fp_update_name(uint8_t* ptrName, uint32_t nameLen) -{ - TRACE(1,"update name len %d", nameLen); +void nv_record_fp_update_name(uint8_t *ptrName, uint32_t nameLen) { + TRACE(1, "update name len %d", nameLen); + uint32_t lock = nv_record_pre_write_operation(); + + memset(nvrecord_fp_account_key_p->name, 0, FP_MAX_NAME_LEN); + if (nameLen > 0) { + DUMP8("0x%02x ", ptrName, nameLen); + memcpy(nvrecord_fp_account_key_p->name, ptrName, nameLen); + } + nvrecord_fp_account_key_p->nameLen = nameLen; + + nv_record_post_write_operation(lock); + nv_record_update_runtime_userdata(); +} + +uint8_t *nv_record_fp_get_name_ptr(uint32_t *ptrNameLen) { + *ptrNameLen = nvrecord_fp_account_key_p->nameLen; + return nvrecord_fp_account_key_p->name; +} + +void nv_record_fp_update_all(uint8_t *info) { + ASSERT(info, "null pointer received in [%s]", __func__); + + if (memcmp(nvrecord_fp_account_key_p, info, + sizeof(NV_FP_ACCOUNT_KEY_RECORD_T))) { uint32_t lock = nv_record_pre_write_operation(); - - memset(nvrecord_fp_account_key_p->name, 0, FP_MAX_NAME_LEN); - if (nameLen > 0) - { - DUMP8("0x%02x ", ptrName, nameLen); - memcpy(nvrecord_fp_account_key_p->name, ptrName, nameLen); - } - nvrecord_fp_account_key_p->nameLen = nameLen; - + memcpy(nvrecord_fp_account_key_p, info, sizeof(NV_FP_ACCOUNT_KEY_RECORD_T)); + nv_record_extension_update(); + TRACE(1, "received fp count num:%d", nvrecord_fp_account_key_p->key_count); nv_record_post_write_operation(lock); - nv_record_update_runtime_userdata(); -} - -uint8_t* nv_record_fp_get_name_ptr(uint32_t* ptrNameLen) -{ - *ptrNameLen = nvrecord_fp_account_key_p->nameLen; - return nvrecord_fp_account_key_p->name; -} - -void nv_record_fp_update_all(uint8_t *info) -{ - ASSERT(info, "null pointer received in [%s]", __func__); - - if (memcmp(nvrecord_fp_account_key_p, info, sizeof(NV_FP_ACCOUNT_KEY_RECORD_T))) - { - uint32_t lock = nv_record_pre_write_operation(); - memcpy(nvrecord_fp_account_key_p, info, sizeof(NV_FP_ACCOUNT_KEY_RECORD_T)); - nv_record_extension_update(); - TRACE(1,"received fp count num:%d", nvrecord_fp_account_key_p->key_count); - nv_record_post_write_operation(lock); - } + } } #endif diff --git a/services/nv_section/userdata_section/nvrecord_gsound.c b/services/nv_section/userdata_section/nvrecord_gsound.c index bc2b4d1..ce651ff 100644 --- a/services/nv_section/userdata_section/nvrecord_gsound.c +++ b/services/nv_section/userdata_section/nvrecord_gsound.c @@ -1,24 +1,24 @@ /*************************************************************************** -* -*Copyright 2015-2019 BES. -*All rights reserved. All unpublished rights reserved. -* -*No part of this work may be used or reproduced in any form or by any -*means, or stored in a database or retrieval system, without prior written -*permission of BES. -* -*Use of this work is governed by a license granted by BES. -*This work contains confidential and proprietary information of -*BES. which is protected by copyright, trade secret, -*trademark and other intellectual property rights. -* -****************************************************************************/ + * + *Copyright 2015-2019 BES. + *All rights reserved. All unpublished rights reserved. + * + *No part of this work may be used or reproduced in any form or by any + *means, or stored in a database or retrieval system, without prior written + *permission of BES. + * + *Use of this work is governed by a license granted by BES. + *This work contains confidential and proprietary information of + *BES. which is protected by copyright, trade secret, + *trademark and other intellectual property rights. + * + ****************************************************************************/ /*****************************header include********************************/ -#include "cmsis.h" -#include "nv_section_dbg.h" #include "nvrecord_gsound.h" +#include "cmsis.h" #include "factory_section.h" +#include "nv_section_dbg.h" #ifdef BISTO_ENABLED #include "gsound_target_ota.h" @@ -34,7 +34,7 @@ //!< the sametime., @see HOTWORD_SECTION_SIZE in common.mk #ifndef OTA_FLASH_LOGIC_ADDR -#define OTA_FLASH_LOGIC_ADDR (FLASH_NC_BASE) +#define OTA_FLASH_LOGIC_ADDR (FLASH_NC_BASE) #endif /************************private type defination****************************/ @@ -50,19 +50,22 @@ extern uint32_t __hotword_model_end[]; /************************private variable defination************************/ #ifdef GSOUND_HOTWORD_ENABLED #ifdef MODEL_FILE_EMBEDED -const uint8_t EMBEDED_MODEL_FILE [] = { +const uint8_t EMBEDED_MODEL_FILE[] = { #include "res/gs_hw/en_all.txt" //!< must correspond to specific model ID, @see DEFAULT_HOTWORD_MODEL_ID }; /// NOTE: Add more embeded model file info here -#define DEFAULT_MODEL_START_ADDR EMBEDED_MODEL_FILE //!< map to specific flash address within the bin file -#else /// #ifndef MODEL_FILE_EMBEDED -#define DEFAULT_MODEL_START_ADDR __hotword_model_start //!< map to specific flash address out of the bin file -#endif /// #ifdef MODEL_FILE_EMBEDED +#define DEFAULT_MODEL_START_ADDR \ + EMBEDED_MODEL_FILE //!< map to specific flash address within the bin file +#else /// #ifndef MODEL_FILE_EMBEDED +#define DEFAULT_MODEL_START_ADDR \ + __hotword_model_start //!< map to specific flash address out of the bin file +#endif /// #ifdef MODEL_FILE_EMBEDED HOTWORD_MODEL_INFO_T defaultModel[DEFAULT_MODEL_NUM] = { - {DEFAULT_HOTWORD_MODEL_ID, (uint32_t)DEFAULT_MODEL_START_ADDR, HOTWORD_MODEL_MAX_SIZE}, + {DEFAULT_HOTWORD_MODEL_ID, (uint32_t)DEFAULT_MODEL_START_ADDR, + HOTWORD_MODEL_MAX_SIZE}, /// NOTE: Add other embeded model info here }; @@ -72,355 +75,328 @@ char supportedModels[GSOUND_MAX_SUPPORTED_HOTWORD_MODELS_BYTES] = {}; static NV_GSOUND_INFO_T *nvrecord_gsound_p = NULL; /****************************function defination****************************/ -void nv_record_gsound_rec_init(void) -{ - if (NULL == nvrecord_gsound_p) - { - nvrecord_gsound_p = &(nvrecord_extension_p->gsound_info); - } +void nv_record_gsound_rec_init(void) { + if (NULL == nvrecord_gsound_p) { + nvrecord_gsound_p = &(nvrecord_extension_p->gsound_info); + } #ifdef GSOUND_HOTWORD_ENABLED - /// init default supported model file(s) - /// add to supported model file set(if it is not in this set) - LOG_I("supportedModelCnt:%d", nvrecord_gsound_p->supportedModelCnt); - if (0 == nvrecord_gsound_p->supportedModelCnt) //!< load default info at first time bootup - { - for (uint8_t i = 0; i < DEFAULT_MODEL_NUM; i++) - { - LOG_I("hotword_model_start:0x%x", - defaultModel[i].startAddr); + /// init default supported model file(s) + /// add to supported model file set(if it is not in this set) + LOG_I("supportedModelCnt:%d", nvrecord_gsound_p->supportedModelCnt); + if (0 == nvrecord_gsound_p + ->supportedModelCnt) //!< load default info at first time bootup + { + for (uint8_t i = 0; i < DEFAULT_MODEL_NUM; i++) { + LOG_I("hotword_model_start:0x%x", defaultModel[i].startAddr); - nv_record_gsound_rec_add_new_model((void *)&defaultModel[i]); - } + nv_record_gsound_rec_add_new_model((void *)&defaultModel[i]); } + } #endif } -void nv_record_gsound_rec_get_ptr(void **ptr) -{ - *ptr = nvrecord_gsound_p; -} +void nv_record_gsound_rec_get_ptr(void **ptr) { *ptr = nvrecord_gsound_p; } -void nv_record_gsound_rec_updata_enable_state(bool enable) -{ - LOG_I("gsound enable state update:%d->%d", nvrecord_gsound_p->isGsoundEnabled, enable); +void nv_record_gsound_rec_updata_enable_state(bool enable) { + LOG_I("gsound enable state update:%d->%d", nvrecord_gsound_p->isGsoundEnabled, + enable); - if (nvrecord_gsound_p->isGsoundEnabled != enable) - { - /// disable the MPU protection for write operation - uint32_t lock = nv_record_pre_write_operation(); + if (nvrecord_gsound_p->isGsoundEnabled != enable) { + /// disable the MPU protection for write operation + uint32_t lock = nv_record_pre_write_operation(); - /// update the enable state - nvrecord_gsound_p->isGsoundEnabled = enable; - nv_record_extension_update(); + /// update the enable state + nvrecord_gsound_p->isGsoundEnabled = enable; + nv_record_extension_update(); - /// enable the MPU protection after the write operation - nv_record_post_write_operation(lock); - } + /// enable the MPU protection after the write operation + nv_record_post_write_operation(lock); + } } #ifdef GSOUND_HOTWORD_ENABLED -bool nv_record_gsound_rec_is_model_insert_allowed(const char *model) -{ - bool ret = true; - uint8_t i; +bool nv_record_gsound_rec_is_model_insert_allowed(const char *model) { + bool ret = true; + uint8_t i; - if ((nvrecord_gsound_p->supportedModelCnt >= HOTWORD_MODLE_MAX_NUM) && - (0xFF != nvrecord_gsound_p->supportedModelCnt)) - { - for (i = 0; i < HOTWORD_MODLE_MAX_NUM; i++) - { - /// hotword model exist already - if (!memcmp(&nvrecord_gsound_p->modelInfo[i].modelId, model, strlen(model))) - { - break; - } - } - - if (HOTWORD_MODLE_MAX_NUM == i) - { - ret = false; - } + if ((nvrecord_gsound_p->supportedModelCnt >= HOTWORD_MODLE_MAX_NUM) && + (0xFF != nvrecord_gsound_p->supportedModelCnt)) { + for (i = 0; i < HOTWORD_MODLE_MAX_NUM; i++) { + /// hotword model exist already + if (!memcmp(&nvrecord_gsound_p->modelInfo[i].modelId, model, + strlen(model))) { + break; + } } - return ret; + if (HOTWORD_MODLE_MAX_NUM == i) { + ret = false; + } + } + + return ret; } -bool nv_record_gsound_rec_add_new_model(void *pInfo) -{ - bool ret = true; - bool found = false; - uint32_t lock = 0; +bool nv_record_gsound_rec_add_new_model(void *pInfo) { + bool ret = true; + bool found = false; + uint32_t lock = 0; - HOTWORD_MODEL_INFO_T *info = (HOTWORD_MODEL_INFO_T *)pInfo; + HOTWORD_MODEL_INFO_T *info = (HOTWORD_MODEL_INFO_T *)pInfo; - if (INVALID_MODEL_NUM == nvrecord_gsound_p->supportedModelCnt) - { - lock = nv_record_pre_write_operation(); - nvrecord_gsound_p->supportedModelCnt = 0; - nv_record_post_write_operation(lock); - } + if (INVALID_MODEL_NUM == nvrecord_gsound_p->supportedModelCnt) { + lock = nv_record_pre_write_operation(); + nvrecord_gsound_p->supportedModelCnt = 0; + nv_record_post_write_operation(lock); + } - if (info) - { - lock = nv_record_pre_write_operation(); - info->startAddr |= OTA_FLASH_LOGIC_ADDR; + if (info) { + lock = nv_record_pre_write_operation(); + info->startAddr |= OTA_FLASH_LOGIC_ADDR; - for (uint8_t i = 0; i < nvrecord_gsound_p->supportedModelCnt; i++) - { - /// hotword model exist already - if (!memcmp(&nvrecord_gsound_p->modelInfo[i].modelId, info->modelId, GSOUND_HOTWORD_MODEL_ID_BYTES)) - { - LOG_I("info->startAddr:%x", info->startAddr); + for (uint8_t i = 0; i < nvrecord_gsound_p->supportedModelCnt; i++) { + /// hotword model exist already + if (!memcmp(&nvrecord_gsound_p->modelInfo[i].modelId, info->modelId, + GSOUND_HOTWORD_MODEL_ID_BYTES)) { + LOG_I("info->startAddr:%x", info->startAddr); - ///.update the start address - if (info->startAddr) - { - nvrecord_gsound_p->modelInfo[i].startAddr = info->startAddr; - nvrecord_gsound_p->modelInfo[i].len = info->len; - } - - LOG_I("model already exist in user section, model_id:%s, model_addr:%x", - nvrecord_gsound_p->modelInfo[i].modelId, - nvrecord_gsound_p->modelInfo[i].startAddr); - found = true; - break; - } + ///.update the start address + if (info->startAddr) { + nvrecord_gsound_p->modelInfo[i].startAddr = info->startAddr; + nvrecord_gsound_p->modelInfo[i].len = info->len; } - LOG_I("current supportedModelCnt:%d", nvrecord_gsound_p->supportedModelCnt); - - /// brand new model insert - if (!found) - { - memcpy(&nvrecord_gsound_p->modelInfo[nvrecord_gsound_p->supportedModelCnt], - info, - sizeof(HOTWORD_MODEL_INFO_T)); - - LOG_I("new added modelId:%s, startAddr:%x, modelFileLen:%x", info->modelId, info->startAddr, info->len); - nvrecord_gsound_p->supportedModelCnt++; - } - nv_record_post_write_operation(lock); - - /// new model file incoming, update flash info - if (!found) - { - /// flush the hotword info to flash - nv_record_update_runtime_userdata(); - nv_record_flash_flush(); - } - - LOG_I("current supportedModelCnt:%d", nvrecord_gsound_p->supportedModelCnt); - } - else - { - LOG_W("NULL pointer received in %s", __func__); - ret = false; + LOG_I("model already exist in user section, model_id:%s, model_addr:%x", + nvrecord_gsound_p->modelInfo[i].modelId, + nvrecord_gsound_p->modelInfo[i].startAddr); + found = true; + break; + } } - return ret; + LOG_I("current supportedModelCnt:%d", nvrecord_gsound_p->supportedModelCnt); + + /// brand new model insert + if (!found) { + memcpy( + &nvrecord_gsound_p->modelInfo[nvrecord_gsound_p->supportedModelCnt], + info, sizeof(HOTWORD_MODEL_INFO_T)); + + LOG_I("new added modelId:%s, startAddr:%x, modelFileLen:%x", + info->modelId, info->startAddr, info->len); + nvrecord_gsound_p->supportedModelCnt++; + } + nv_record_post_write_operation(lock); + + /// new model file incoming, update flash info + if (!found) { + /// flush the hotword info to flash + nv_record_update_runtime_userdata(); + nv_record_flash_flush(); + } + + LOG_I("current supportedModelCnt:%d", nvrecord_gsound_p->supportedModelCnt); + } else { + LOG_W("NULL pointer received in %s", __func__); + ret = false; + } + + return ret; } -uint32_t nv_record_gsound_rec_get_hotword_model_addr(const char *model_id, bool add_new, int32_t newModelLen) -{ - uint32_t addr = 0; - bool found = false; +uint32_t nv_record_gsound_rec_get_hotword_model_addr(const char *model_id, + bool add_new, + int32_t newModelLen) { + uint32_t addr = 0; + bool found = false; - LOG_I("%s revceived model ID: %s", __func__, model_id); - if (nvrecord_gsound_p) - { - for (uint8_t i = 0; i < ARRAY_SIZE(nvrecord_gsound_p->modelInfo); i++) - { - if (!memcmp(nvrecord_gsound_p->modelInfo[i].modelId, model_id, 4)) - { - addr = nvrecord_gsound_p->modelInfo[i].startAddr; - found = true; - LOG_I("found saved model info, index:%d", i); - break; - } - } + LOG_I("%s revceived model ID: %s", __func__, model_id); + if (nvrecord_gsound_p) { + for (uint8_t i = 0; i < ARRAY_SIZE(nvrecord_gsound_p->modelInfo); i++) { + if (!memcmp(nvrecord_gsound_p->modelInfo[i].modelId, model_id, 4)) { + addr = nvrecord_gsound_p->modelInfo[i].startAddr; + found = true; + LOG_I("found saved model info, index:%d", i); + break; + } } + } - do - { - if (add_new && !found) - { - addr = (uint32_t)__hotword_model_start; - uint32_t tempAddr; - uint8_t startIdx = 0; + do { + if (add_new && !found) { + addr = (uint32_t)__hotword_model_start; + uint32_t tempAddr; + uint8_t startIdx = 0; #ifdef MODEL_FILE_EMBEDED - startIdx = DEFAULT_MODEL_NUM; //!< set offset to skip the embeded model file info + startIdx = + DEFAULT_MODEL_NUM; //!< set offset to skip the embeded model file info #endif - if (INVALID_MODEL_NUM == nvrecord_gsound_p->supportedModelCnt) - { - break; - } + if (INVALID_MODEL_NUM == nvrecord_gsound_p->supportedModelCnt) { + break; + } - /// get the largest flash address - for (uint8_t i = startIdx; i < nvrecord_gsound_p->supportedModelCnt; i++) - { - tempAddr = nvrecord_gsound_p->modelInfo[i].startAddr + nvrecord_gsound_p->modelInfo[i].len; - if ((tempAddr & 0xFFFFFF) > (addr & 0xFFFFFF)) - { - addr = tempAddr; - } - } - - /// force 4K align the address - addr = F_4K_ALIGN(addr); - LOG_I("supportedModelCnt:%d, Largest address:0x%x", nvrecord_gsound_p->supportedModelCnt, addr); - - /// check is overwrite needed - if ((newModelLen + addr) > (uint32_t)__hotword_model_end || - (nvrecord_gsound_p->supportedModelCnt >= HOTWORD_MODLE_MAX_NUM)) - { - uint8_t cleanIdx = 0; //!< model file index to clean - addr = nvrecord_gsound_p->modelInfo[startIdx].startAddr; //!< init anchor point - uint32_t cleanSize = F_4K_ALIGN(addr + nvrecord_gsound_p->modelInfo[startIdx].len) - addr; //!< flash size to clean - - uint32_t lock = nv_record_pre_write_operation(); //!< disable the MPU for info update - uint32_t intLock = int_lock(); //!< lock the global interrupt - - /// remove the first record - for (uint8_t i = startIdx; i < (nvrecord_gsound_p->supportedModelCnt - 1); i++) - { - nvrecord_gsound_p->modelInfo[i] = nvrecord_gsound_p->modelInfo[i + 1]; - } - - /// decrease the number of supported model - nvrecord_gsound_p->supportedModelCnt--; - - while (cleanSize < newModelLen) - { - uint8_t headAdjacentIdx = 0xFF, tailAdjacentIdx = 0xFF; - uint32_t headAdjacentOffset = 0xFFFFFFFF, tailAdjacentOffset = 0xFFFFFFFF; - - /// find the adjacent chunck - for (uint8_t i = startIdx; i < nvrecord_gsound_p->supportedModelCnt; i++) - { - if (nvrecord_gsound_p->modelInfo[i].startAddr > addr) - { - if (nvrecord_gsound_p->modelInfo[i].startAddr - addr < tailAdjacentOffset) - { - tailAdjacentOffset = nvrecord_gsound_p->modelInfo[i].startAddr - addr; - tailAdjacentIdx = i; - } - } - else if (nvrecord_gsound_p->modelInfo[i].startAddr < addr) - { - if (addr - nvrecord_gsound_p->modelInfo[i].startAddr < headAdjacentOffset) - { - headAdjacentOffset = nvrecord_gsound_p->modelInfo[i].startAddr - addr; - headAdjacentIdx = i; - } - } - } - - LOG_I("headAdjacentIdx:%d, tailAdjacentIdx:%d", headAdjacentIdx, tailAdjacentIdx); - - /// find the smaller index, smaller index means older record - if (headAdjacentIdx > tailAdjacentIdx) - { - cleanSize += F_4K_ALIGN(nvrecord_gsound_p->modelInfo[tailAdjacentIdx].startAddr + - nvrecord_gsound_p->modelInfo[tailAdjacentIdx].len) - - nvrecord_gsound_p->modelInfo[tailAdjacentIdx].startAddr; - cleanIdx = tailAdjacentIdx; - } - else - { - addr = nvrecord_gsound_p->modelInfo[headAdjacentIdx].startAddr; - cleanSize += F_4K_ALIGN(addr + nvrecord_gsound_p->modelInfo[headAdjacentIdx].len) - addr; - cleanIdx = headAdjacentIdx; - } - - /// remove the first record - for (uint8_t i = cleanIdx; i < (nvrecord_gsound_p->supportedModelCnt - 1); i++) - { - nvrecord_gsound_p->modelInfo[i] = nvrecord_gsound_p->modelInfo[i + 1]; - } - - /// decrease the number of supported model - nvrecord_gsound_p->supportedModelCnt--; - } - - if ((addr < (uint32_t)__hotword_model_start) || - (addr > (uint32_t)__hotword_model_end)) - { - LOG_I("invalid addr found:0x%x, clean all model files", addr); - nvrecord_gsound_p->supportedModelCnt = startIdx; - addr = (uint32_t)__hotword_model_start; - } - - if (0 == nvrecord_gsound_p->supportedModelCnt) - { - /// invalid number used to identify with fist time bootup - nvrecord_gsound_p->supportedModelCnt = INVALID_MODEL_NUM; - } - - int_unlock(intLock); //!< unlock the global interrupt - nv_record_post_write_operation(lock); //!< enable the MPU - - /// flush the hotword info to flash - nv_record_update_runtime_userdata(); - nv_record_flash_flush(); - } + /// get the largest flash address + for (uint8_t i = startIdx; i < nvrecord_gsound_p->supportedModelCnt; + i++) { + tempAddr = nvrecord_gsound_p->modelInfo[i].startAddr + + nvrecord_gsound_p->modelInfo[i].len; + if ((tempAddr & 0xFFFFFF) > (addr & 0xFFFFFF)) { + addr = tempAddr; } - } while (0); + } - return addr; + /// force 4K align the address + addr = F_4K_ALIGN(addr); + LOG_I("supportedModelCnt:%d, Largest address:0x%x", + nvrecord_gsound_p->supportedModelCnt, addr); + + /// check is overwrite needed + if ((newModelLen + addr) > (uint32_t)__hotword_model_end || + (nvrecord_gsound_p->supportedModelCnt >= HOTWORD_MODLE_MAX_NUM)) { + uint8_t cleanIdx = 0; //!< model file index to clean + addr = nvrecord_gsound_p->modelInfo[startIdx] + .startAddr; //!< init anchor point + uint32_t cleanSize = + F_4K_ALIGN(addr + nvrecord_gsound_p->modelInfo[startIdx].len) - + addr; //!< flash size to clean + + uint32_t lock = nv_record_pre_write_operation(); //!< disable the MPU + //!< for info update + uint32_t intLock = int_lock(); //!< lock the global interrupt + + /// remove the first record + for (uint8_t i = startIdx; + i < (nvrecord_gsound_p->supportedModelCnt - 1); i++) { + nvrecord_gsound_p->modelInfo[i] = nvrecord_gsound_p->modelInfo[i + 1]; + } + + /// decrease the number of supported model + nvrecord_gsound_p->supportedModelCnt--; + + while (cleanSize < newModelLen) { + uint8_t headAdjacentIdx = 0xFF, tailAdjacentIdx = 0xFF; + uint32_t headAdjacentOffset = 0xFFFFFFFF, + tailAdjacentOffset = 0xFFFFFFFF; + + /// find the adjacent chunck + for (uint8_t i = startIdx; i < nvrecord_gsound_p->supportedModelCnt; + i++) { + if (nvrecord_gsound_p->modelInfo[i].startAddr > addr) { + if (nvrecord_gsound_p->modelInfo[i].startAddr - addr < + tailAdjacentOffset) { + tailAdjacentOffset = + nvrecord_gsound_p->modelInfo[i].startAddr - addr; + tailAdjacentIdx = i; + } + } else if (nvrecord_gsound_p->modelInfo[i].startAddr < addr) { + if (addr - nvrecord_gsound_p->modelInfo[i].startAddr < + headAdjacentOffset) { + headAdjacentOffset = + nvrecord_gsound_p->modelInfo[i].startAddr - addr; + headAdjacentIdx = i; + } + } + } + + LOG_I("headAdjacentIdx:%d, tailAdjacentIdx:%d", headAdjacentIdx, + tailAdjacentIdx); + + /// find the smaller index, smaller index means older record + if (headAdjacentIdx > tailAdjacentIdx) { + cleanSize += + F_4K_ALIGN( + nvrecord_gsound_p->modelInfo[tailAdjacentIdx].startAddr + + nvrecord_gsound_p->modelInfo[tailAdjacentIdx].len) - + nvrecord_gsound_p->modelInfo[tailAdjacentIdx].startAddr; + cleanIdx = tailAdjacentIdx; + } else { + addr = nvrecord_gsound_p->modelInfo[headAdjacentIdx].startAddr; + cleanSize += + F_4K_ALIGN(addr + + nvrecord_gsound_p->modelInfo[headAdjacentIdx].len) - + addr; + cleanIdx = headAdjacentIdx; + } + + /// remove the first record + for (uint8_t i = cleanIdx; + i < (nvrecord_gsound_p->supportedModelCnt - 1); i++) { + nvrecord_gsound_p->modelInfo[i] = + nvrecord_gsound_p->modelInfo[i + 1]; + } + + /// decrease the number of supported model + nvrecord_gsound_p->supportedModelCnt--; + } + + if ((addr < (uint32_t)__hotword_model_start) || + (addr > (uint32_t)__hotword_model_end)) { + LOG_I("invalid addr found:0x%x, clean all model files", addr); + nvrecord_gsound_p->supportedModelCnt = startIdx; + addr = (uint32_t)__hotword_model_start; + } + + if (0 == nvrecord_gsound_p->supportedModelCnt) { + /// invalid number used to identify with fist time bootup + nvrecord_gsound_p->supportedModelCnt = INVALID_MODEL_NUM; + } + + int_unlock(intLock); //!< unlock the global interrupt + nv_record_post_write_operation(lock); //!< enable the MPU + + /// flush the hotword info to flash + nv_record_update_runtime_userdata(); + nv_record_flash_flush(); + } + } + } while (0); + + return addr; } int nv_record_gsound_rec_get_supported_model_id(char *models_out, - uint8_t *length_out) -{ - int ret= 0; - const char* terminator = NULL; + uint8_t *length_out) { + int ret = 0; + const char *terminator = NULL; - if (INVALID_MODEL_NUM == nvrecord_gsound_p->supportedModelCnt) - { - memcpy(models_out, STRING_TERMINATOR_NULL, STRING_TERMINATOR_SIZE); - *length_out = STRING_TERMINATOR_SIZE; - } - else - { - for (uint8_t i = 0; i < nvrecord_gsound_p->supportedModelCnt; i++) - { - LOG_I("supported model_id:%s, model_addr:%x", - nvrecord_gsound_p->modelInfo[i].modelId, - nvrecord_gsound_p->modelInfo[i].startAddr); + if (INVALID_MODEL_NUM == nvrecord_gsound_p->supportedModelCnt) { + memcpy(models_out, STRING_TERMINATOR_NULL, STRING_TERMINATOR_SIZE); + *length_out = STRING_TERMINATOR_SIZE; + } else { + for (uint8_t i = 0; i < nvrecord_gsound_p->supportedModelCnt; i++) { + LOG_I("supported model_id:%s, model_addr:%x", + nvrecord_gsound_p->modelInfo[i].modelId, + nvrecord_gsound_p->modelInfo[i].startAddr); - memcpy((supportedModels + i * GSOUND_HOTWORD_SUPPORTED_MODEL_ID_BYTES), - nvrecord_gsound_p->modelInfo[i].modelId, - GSOUND_HOTWORD_MODEL_ID_BYTES); + memcpy((supportedModels + i * GSOUND_HOTWORD_SUPPORTED_MODEL_ID_BYTES), + nvrecord_gsound_p->modelInfo[i].modelId, + GSOUND_HOTWORD_MODEL_ID_BYTES); - if ((i + 1) == nvrecord_gsound_p->supportedModelCnt) - { - terminator = STRING_TERMINATOR_NULL; - } - else - { - terminator = SUPPORTED_HOTWORD_MODEL_DELIM; - } - memcpy(&supportedModels[(i * GSOUND_HOTWORD_SUPPORTED_MODEL_ID_BYTES) + GSOUND_HOTWORD_MODEL_ID_BYTES], - terminator, - STRING_TERMINATOR_SIZE); - } - - if (nvrecord_gsound_p->supportedModelCnt * GSOUND_HOTWORD_SUPPORTED_MODEL_ID_BYTES <= *length_out) - { - strcpy(models_out, supportedModels); - *length_out = strlen(supportedModels) + STRING_TERMINATOR_SIZE; - LOG_I("total supported model_id(length is %d):", *length_out); - DUMP8("0x%02x ", models_out, *length_out); - } - else - { - ret = -1; - LOG_W("supported model id length exceeded max length"); - } + if ((i + 1) == nvrecord_gsound_p->supportedModelCnt) { + terminator = STRING_TERMINATOR_NULL; + } else { + terminator = SUPPORTED_HOTWORD_MODEL_DELIM; + } + memcpy(&supportedModels[(i * GSOUND_HOTWORD_SUPPORTED_MODEL_ID_BYTES) + + GSOUND_HOTWORD_MODEL_ID_BYTES], + terminator, STRING_TERMINATOR_SIZE); } - return ret; + if (nvrecord_gsound_p->supportedModelCnt * + GSOUND_HOTWORD_SUPPORTED_MODEL_ID_BYTES <= + *length_out) { + strcpy(models_out, supportedModels); + *length_out = strlen(supportedModels) + STRING_TERMINATOR_SIZE; + LOG_I("total supported model_id(length is %d):", *length_out); + DUMP8("0x%02x ", models_out, *length_out); + } else { + ret = -1; + LOG_W("supported model id length exceeded max length"); + } + } + + return ret; } #endif diff --git a/services/nv_section/userdata_section/nvrecord_ota.c b/services/nv_section/userdata_section/nvrecord_ota.c index bf19ef3..636ba9e 100644 --- a/services/nv_section/userdata_section/nvrecord_ota.c +++ b/services/nv_section/userdata_section/nvrecord_ota.c @@ -3,14 +3,14 @@ * @author BES AI team * @version 0.1 * @date 2020-04-21 - * + * * @copyright Copyright (c) 2015-2020 BES Technic. * All rights reserved. All unpublished rights reserved. - * + * * No part of this work may be used or reproduced in any form or by any * means, or stored in a database or retrieval system, without prior written * permission of BES. - * + * * Use of this work is governed by a license granted by BES. * This work contains confidential and proprietary information of * BES. which is protected by copyright, trade secret, @@ -18,10 +18,10 @@ */ /*****************************header include********************************/ -#include "string.h" -#include "nv_section_dbg.h" #include "nvrecord_ota.h" +#include "nv_section_dbg.h" #include "ota_common.h" +#include "string.h" #ifdef BISTO_ENABLED #include "nvrecord_gsound.h" @@ -39,139 +39,104 @@ static NV_OTA_INFO_T *nvrecord_ota_p = NULL; /****************************function defination****************************/ -void nv_record_ota_init(void) -{ - if (NULL == nvrecord_ota_p) - { - nvrecord_ota_p = nvrecord_extension_p->ota_info; - } +void nv_record_ota_init(void) { + if (NULL == nvrecord_ota_p) { + nvrecord_ota_p = nvrecord_extension_p->ota_info; + } } -void nv_record_ota_get_ptr(void **ptr) -{ - *ptr = nvrecord_ota_p; +void nv_record_ota_get_ptr(void **ptr) { *ptr = nvrecord_ota_p; } + +void nv_record_ota_update_breakpoint(uint8_t user, uint8_t deviceIndex, + uint32_t otaOffset) { + NV_OTA_INFO_T *pOta = &nvrecord_ota_p[deviceIndex]; + bool update = false; + + ASSERT(OTA_STAGE_ONGOING == pOta->otaStatus, + "try to update break point when OTA not in progress"); + + uint32_t lock = nv_record_pre_write_operation(); + if (user != pOta->user) { + LOG_I("OTA user update:%d->%d", pOta->user, user); + pOta->user = user; + update = true; + } + + if (otaOffset != pOta->breakPoint) { + LOG_I("OTA break point update:%x->%x", pOta->breakPoint, otaOffset); + pOta->breakPoint = otaOffset; + update = true; + } + nv_record_post_write_operation(lock); + + if (update) { + nv_record_extension_update(); + nv_record_execute_async_flush(); + } } -void nv_record_ota_update_breakpoint(uint8_t user, - uint8_t deviceIndex, - uint32_t otaOffset) -{ - NV_OTA_INFO_T *pOta = &nvrecord_ota_p[deviceIndex]; - bool update = false; +bool nv_record_ota_update_info(uint8_t user, uint8_t deviceIndex, + uint8_t status, uint32_t totalImageSize, + const char *session) { + NV_OTA_INFO_T *pOta = &nvrecord_ota_p[deviceIndex]; - ASSERT(OTA_STAGE_ONGOING == pOta->otaStatus, - "try to update break point when OTA not in progress"); + LOG_I("%s", __func__); + LOG_I("ota_status:%d->%d, user:%d, device_index:%d, imageSize:%d, version:%s", + pOta->otaStatus, status, user, deviceIndex, totalImageSize, session); + bool ret = true; + bool update = false; + +#ifdef GSOUND_HOTWORD_ENABLED + if ((OTA_USER_COLORFUL == user) && (OTA_DEVICE_HOTWORD == deviceIndex)) { + ret = nv_record_gsound_rec_is_model_insert_allowed(session); + } +#endif + + if (ret) { uint32_t lock = nv_record_pre_write_operation(); - if (user != pOta->user) - { - LOG_I("OTA user update:%d->%d", pOta->user, user); - pOta->user = user; - update = true; + if (!memcmp(pOta->version, session, strlen(session) + 1)) { + memset(pOta->version, 0, ARRAY_SIZE(pOta->version)); + update = true; } - if (otaOffset != pOta->breakPoint) - { - LOG_I("OTA break point update:%x->%x", pOta->breakPoint, otaOffset); - pOta->breakPoint = otaOffset; + if (pOta->otaStatus != status) { + pOta->otaStatus = status; + update = true; + LOG_I("update device %d ota status to %d", deviceIndex, pOta->otaStatus); + } + + if (OTA_STAGE_IDLE == status) { + if (0 != pOta->breakPoint) { + pOta->breakPoint = 0; update = true; + } + } else if (OTA_STAGE_ONGOING == status) { + ASSERT(totalImageSize, "Received total image size is 0."); + ASSERT(session, "Received session pointer is NULL."); + + if (pOta->imageSize != totalImageSize) { + pOta->imageSize = totalImageSize; + update = true; + } + } else if (OTA_STAGE_DONE == status) { + ASSERT(totalImageSize == pOta->imageSize, + "total image size changed:%d->%d.", pOta->imageSize, + totalImageSize); + + if (totalImageSize != pOta->breakPoint) { + pOta->breakPoint = totalImageSize; + update = true; + } } nv_record_post_write_operation(lock); - if (update) - { - nv_record_extension_update(); - nv_record_execute_async_flush(); + if (update) { + LOG_I("will update info into flash."); + nv_record_extension_update(); + nv_record_execute_async_flush(); } -} - -bool nv_record_ota_update_info(uint8_t user, - uint8_t deviceIndex, - uint8_t status, - uint32_t totalImageSize, - const char *session) -{ - NV_OTA_INFO_T *pOta = &nvrecord_ota_p[deviceIndex]; - - LOG_I("%s", __func__); - LOG_I("ota_status:%d->%d, user:%d, device_index:%d, imageSize:%d, version:%s", - pOta->otaStatus, - status, - user, - deviceIndex, - totalImageSize, - session); - - bool ret = true; - bool update = false; - -#ifdef GSOUND_HOTWORD_ENABLED - if ((OTA_USER_COLORFUL == user) && - (OTA_DEVICE_HOTWORD == deviceIndex)) - { - ret = nv_record_gsound_rec_is_model_insert_allowed(session); - } -#endif - - if (ret) - { - uint32_t lock = nv_record_pre_write_operation(); - if (!memcmp(pOta->version, session, strlen(session) + 1)) - { - memset(pOta->version, - 0, - ARRAY_SIZE(pOta->version)); - update = true; - } - - if (pOta->otaStatus != status) - { - pOta->otaStatus = status; - update = true; - LOG_I("update device %d ota status to %d", - deviceIndex, - pOta->otaStatus); - } - - if (OTA_STAGE_IDLE == status) - { - if (0 != pOta->breakPoint) - { - pOta->breakPoint = 0; - update = true; - } - } - else if (OTA_STAGE_ONGOING == status) - { - ASSERT(totalImageSize, "Received total image size is 0."); - ASSERT(session, "Received session pointer is NULL."); - - if (pOta->imageSize != totalImageSize) - { - pOta->imageSize = totalImageSize; - update = true; - } - } - else if (OTA_STAGE_DONE == status) - { - ASSERT(totalImageSize == pOta->imageSize, - "total image size changed:%d->%d.", pOta->imageSize, totalImageSize); - - if (totalImageSize != pOta->breakPoint) - { - pOta->breakPoint = totalImageSize; - update = true; - } - } - nv_record_post_write_operation(lock); - - if (update) - { - LOG_I("will update info into flash."); - nv_record_extension_update(); - nv_record_execute_async_flush(); - } - } - - return ret; + } + + return ret; } diff --git a/services/nvrecord/list_ext.c b/services/nvrecord/list_ext.c index 0b0a0e4..d0d5f10 100644 --- a/services/nvrecord/list_ext.c +++ b/services/nvrecord/list_ext.c @@ -13,26 +13,26 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "stdio.h" +#include "list_ext.h" #include "cmsis_os.h" #include "hal_trace.h" +#include "stdio.h" #include "string.h" -#include "list_ext.h" static list_node_t *list_free_node_ext(list_t *list, list_node_t *node); -void *zmalloc_ext (size_t size){ - void *ptr = NULL; - ptr = pool_malloc(size); - memset(ptr, 0, size); - return ptr; +void *zmalloc_ext(size_t size) { + void *ptr = NULL; + ptr = pool_malloc(size); + memset(ptr, 0, size); + return ptr; } -// Returns a new, empty list. Returns NULL if not enough memory could be allocated -// for the list structure. The returned list must be freed with |list_free|. The -// |callback| specifies a function to be called whenever a list element is removed -// from the list. It can be used to release resources held by the list element, e.g. -// memory or file descriptor. |callback| may be NULL if no cleanup is necessary on -// element removal. +// Returns a new, empty list. Returns NULL if not enough memory could be +// allocated for the list structure. The returned list must be freed with +// |list_free|. The |callback| specifies a function to be called whenever a list +// element is removed from the list. It can be used to release resources held by +// the list element, e.g. memory or file descriptor. |callback| may be NULL if +// no cleanup is necessary on element removal. list_t *list_new_ext(list_free_cb callback) { list_t *list = (list_t *)zmalloc_ext(sizeof(list_t)); if (list) @@ -52,40 +52,40 @@ void list_free_ext(list_t *list) { // Note that a NULL list is not the same as an empty list. This function // does not accept a NULL list. bool list_is_empty_ext(const list_t *list) { - ASSERT(list != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); return (list->length == 0); } // Returns the length of the list. This function does not accept a NULL list. size_t list_length_ext(const list_t *list) { - ASSERT(list != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); return list->length; } // Returns the first element in the list without removing it. |list| may not // be NULL or empty. void *list_front_ext(const list_t *list) { - ASSERT(list != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); bool nRet = list_is_empty_ext(list); - ASSERT(!nRet,"%s",__func__); + ASSERT(!nRet, "%s", __func__); return list->head->data; } // Returns the last element in the list without removing it. |list| may not // be NULL or empty. void *list_back_ext(const list_t *list) { - ASSERT(list != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); bool nRet = list_is_empty_ext(list); - ASSERT(!nRet,"%s",__func__); + ASSERT(!nRet, "%s", __func__); return list->tail->data; } bool list_insert_after_ext(list_t *list, list_node_t *prev_node, void *data) { list_node_t *node = NULL; - ASSERT(list != NULL,"%s",__func__); - ASSERT(prev_node != NULL,"%s",__func__); - ASSERT(data != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); + ASSERT(prev_node != NULL, "%s", __func__); + ASSERT(data != NULL, "%s", __func__); node = (list_node_t *)pool_malloc(sizeof(list_node_t)); if (!node) @@ -101,14 +101,15 @@ bool list_insert_after_ext(list_t *list, list_node_t *prev_node, void *data) { } #include "stdio.h" -// Inserts |data| at the beginning of |list|. Neither |data| nor |list| may be NULL. -// This function does not make a copy of |data| so the pointer must remain valid -// at least until the element is removed from the list or the list is freed. -// Returns true if |data| could be inserted, false otherwise (e.g. out of memory). +// Inserts |data| at the beginning of |list|. Neither |data| nor |list| may be +// NULL. This function does not make a copy of |data| so the pointer must remain +// valid at least until the element is removed from the list or the list is +// freed. Returns true if |data| could be inserted, false otherwise (e.g. out of +// memory). bool list_prepend_ext(list_t *list, void *data) { list_node_t *node = NULL; - ASSERT(list != NULL,"%s",__func__); - ASSERT(data != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); + ASSERT(data != NULL, "%s", __func__); node = (list_node_t *)zmalloc_ext(sizeof(list_node_t)); if (!node) return false; @@ -124,11 +125,12 @@ bool list_prepend_ext(list_t *list, void *data) { // Inserts |data| at the end of |list|. Neither |data| nor |list| may be NULL. // This function does not make a copy of |data| so the pointer must remain valid // at least until the element is removed from the list or the list is freed. -// Returns true if |data| could be inserted, false otherwise (e.g. out of memory). +// Returns true if |data| could be inserted, false otherwise (e.g. out of +// memory). bool list_append_ext(list_t *list, void *data) { list_node_t *node = NULL; - ASSERT(list != NULL,"%s",__func__); - ASSERT(data != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); + ASSERT(data != NULL, "%s", __func__); node = (list_node_t *)pool_malloc(sizeof(list_node_t)); if (!node) return false; @@ -145,15 +147,15 @@ bool list_append_ext(list_t *list, void *data) { return true; } -// Removes |data| from the list. Neither |list| nor |data| may be NULL. If |data| -// is inserted multiple times in the list, this function will only remove the first -// instance. If a free function was specified in |list_new|, it will be called back -// with |data|. This function returns true if |data| was found in the list and removed, -// false otherwise. +// Removes |data| from the list. Neither |list| nor |data| may be NULL. If +// |data| is inserted multiple times in the list, this function will only remove +// the first instance. If a free function was specified in |list_new|, it will +// be called back with |data|. This function returns true if |data| was found in +// the list and removed, false otherwise. bool list_remove_ext(list_t *list, void *data) { list_node_t *prev = NULL, *node = NULL; - ASSERT(list != NULL,"%s",__func__); - ASSERT(data != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); + ASSERT(data != NULL, "%s", __func__); if (list_is_empty_ext(list)) return false; @@ -166,7 +168,8 @@ bool list_remove_ext(list_t *list, void *data) { return true; } - for (prev = list->head, node = list->head->next; node; prev = node, node = node->next) + for (prev = list->head, node = list->head->next; node; + prev = node, node = node->next) if (node->data == data) { prev->next = list_free_node_ext(list, node); if (list->tail == node) @@ -177,29 +180,29 @@ bool list_remove_ext(list_t *list, void *data) { return false; } -// Removes all elements in the list. Calling this function will return the list to the -// same state it was in after |list_new|. |list| may not be NULL. +// Removes all elements in the list. Calling this function will return the list +// to the same state it was in after |list_new|. |list| may not be NULL. void list_clear_ext(list_t *list) { list_node_t *node = NULL; - ASSERT(list != NULL,"%s",__func__); - for (node = list->head; node; ) + ASSERT(list != NULL, "%s", __func__); + for (node = list->head; node;) node = list_free_node_ext(list, node); list->head = NULL; list->tail = NULL; list->length = 0; } -// Iterates through the entire |list| and calls |callback| for each data element. -// If the list is empty, |callback| will never be called. It is safe to mutate the -// list inside the callback. If an element is added before the node being visited, -// there will be no callback for the newly-inserted node. Neither |list| nor -// |callback| may be NULL. +// Iterates through the entire |list| and calls |callback| for each data +// element. If the list is empty, |callback| will never be called. It is safe to +// mutate the list inside the callback. If an element is added before the node +// being visited, there will be no callback for the newly-inserted node. Neither +// |list| nor |callback| may be NULL. void list_foreach_ext(const list_t *list, list_iter_cb callback) { list_node_t *node = NULL; - ASSERT(list != NULL,"%s",__func__); - ASSERT(callback != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); + ASSERT(callback != NULL, "%s", __func__); - for (node = list->head; node; ) { + for (node = list->head; node;) { list_node_t *next = node->next; callback(node->data); node = next; @@ -207,10 +210,10 @@ void list_foreach_ext(const list_t *list, list_iter_cb callback) { } // Returns an iterator to the first element in |list|. |list| may not be NULL. -// The returned iterator is valid as long as it does not equal the value returned -// by |list_end|. +// The returned iterator is valid as long as it does not equal the value +// returned by |list_end|. list_node_t *list_begin_ext(const list_t *list) { - ASSERT(list != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); return list->head; } @@ -219,7 +222,7 @@ list_node_t *list_begin_ext(const list_t *list) { // When an iterator has the same value as what's returned by this function, you // may no longer call |list_next| with the iterator. |list| may not be NULL. list_node_t *list_end_ext(const list_t *list) { - ASSERT(list != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); return NULL; } @@ -228,21 +231,21 @@ list_node_t *list_end_ext(const list_t *list) { // iterator has reached the end of the list and may no longer be used for any // purpose. list_node_t *list_next_ext(const list_node_t *node) { - ASSERT(node != NULL,"%s",__func__); + ASSERT(node != NULL, "%s", __func__); return node->next; } // Returns the value stored at the location pointed to by the iterator |node|. // |node| must not equal the value returned by |list_end|. void *list_node_ext(const list_node_t *node) { - ASSERT(node != NULL,"%s",__func__); + ASSERT(node != NULL, "%s", __func__); return node->data; } static list_node_t *list_free_node_ext(list_t *list, list_node_t *node) { list_node_t *next = NULL; - ASSERT(list != NULL,"%s",__func__); - ASSERT(node != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); + ASSERT(node != NULL, "%s", __func__); next = node->next; diff --git a/services/nvrecord/nvrec_config.c b/services/nvrecord/nvrec_config.c index aa76644..978cd83 100644 --- a/services/nvrecord/nvrec_config.c +++ b/services/nvrecord/nvrec_config.c @@ -15,56 +15,52 @@ ****************************************************************************/ #define LOG_TAG "bt_osi_config" -#include -#include -#include "stdio.h" -#include -#include -#include "list_ext.h" -#include "nvrecord.h" #include "nvrec_config.h" #include "hal_trace.h" +#include "list_ext.h" +#include "nvrecord.h" +#include "stdio.h" +#include +#include +#include +#include static nvrec_section_t *nvrec_section_new(const char *name); static void nvrec_section_free(void *ptr); -static nvrec_entry_t *nvrec_entry_new(const char *key,const char *value,const char *descrip); -static nvrec_entry_t *nvrec_entry_find(const nvrec_config_t *config, const char *section, const char *key); +static nvrec_entry_t *nvrec_entry_new(const char *key, const char *value, + const char *descrip); +static nvrec_entry_t *nvrec_entry_find(const nvrec_config_t *config, + const char *section, const char *key); -void *cfg_malloc (unsigned int size) -{ - void *ptr = NULL; - if(size == 0) - return NULL; - ptr = pool_malloc(size); - if(ptr == NULL) - { - printf("cfg_malloc......ERROR\n"); - } - return ptr; +void *cfg_malloc(unsigned int size) { + void *ptr = NULL; + if (size == 0) + return NULL; + ptr = pool_malloc(size); + if (ptr == NULL) { + printf("cfg_malloc......ERROR\n"); + } + return ptr; } -void *cfg_zmalloc (unsigned int size) -{ - void *ptr = NULL; - ptr = cfg_malloc(size); - memset(ptr, 0, size); - return ptr; +void *cfg_zmalloc(unsigned int size) { + void *ptr = NULL; + ptr = cfg_malloc(size); + memset(ptr, 0, size); + return ptr; } -void cfg_free (void *p_mem) -{ - pool_free(p_mem); -} +void cfg_free(void *p_mem) { pool_free(p_mem); } nvrec_config_t *nvrec_config_new(const char *filename) { - nvrec_config_t *config; - //add your code at here -// printf("nvrec_config_new-->cfg_zmalloc..........................\r\n"); - config = (nvrec_config_t *)cfg_zmalloc(sizeof(nvrec_config_t)); - if(config) - config->sections = list_new_ext(nvrec_section_free); + nvrec_config_t *config; + // add your code at here + // printf("nvrec_config_new-->cfg_zmalloc..........................\r\n"); + config = (nvrec_config_t *)cfg_zmalloc(sizeof(nvrec_config_t)); + if (config) + config->sections = list_new_ext(nvrec_section_free); - return config; + return config; } void nvrec_config_free(nvrec_config_t *config) { @@ -72,18 +68,20 @@ void nvrec_config_free(nvrec_config_t *config) { return; list_free_ext(config->sections); -// printf("nvrec_config_free-->cfg_free..........................\r\n"); + // printf("nvrec_config_free-->cfg_free..........................\r\n"); cfg_free(config); } -bool nvrec_config_has_section(const nvrec_config_t *config, const char *section) { +bool nvrec_config_has_section(const nvrec_config_t *config, + const char *section) { assert(config != NULL); assert(section != NULL); return (nvrec_section_find(config, section) != NULL); } -bool nvrec_config_has_key(const nvrec_config_t *config, const char *section, const char *key) { +bool nvrec_config_has_key(const nvrec_config_t *config, const char *section, + const char *key) { assert(config != NULL); assert(section != NULL); assert(key != NULL); @@ -91,7 +89,8 @@ bool nvrec_config_has_key(const nvrec_config_t *config, const char *section, con return (nvrec_entry_find(config, section, key) != NULL); } -int nvrec_config_get_int(const nvrec_config_t *config, const char *section, const char *key, int def_value) { +int nvrec_config_get_int(const nvrec_config_t *config, const char *section, + const char *key, int def_value) { nvrec_entry_t *entry = NULL; char *endptr = NULL; int ret = 0; @@ -107,7 +106,8 @@ int nvrec_config_get_int(const nvrec_config_t *config, const char *section, cons return (*endptr == '\0') ? ret : def_value; } -bool nvrec_config_get_bool(const nvrec_config_t *config, const char *section, const char *key, bool def_value) { +bool nvrec_config_get_bool(const nvrec_config_t *config, const char *section, + const char *key, bool def_value) { nvrec_entry_t *entry = NULL; assert(config != NULL); assert(section != NULL); @@ -125,15 +125,15 @@ bool nvrec_config_get_bool(const nvrec_config_t *config, const char *section, co return def_value; } -const char *nvrec_config_get_string(const nvrec_config_t *config, const char *section, const char *key, const char *def_value) { +const char *nvrec_config_get_string(const nvrec_config_t *config, + const char *section, const char *key, + const char *def_value) { nvrec_entry_t *entry = NULL; assert(config != NULL); assert(section != NULL); assert(key != NULL); - - entry = nvrec_entry_find(config, section, key); if (!entry) @@ -142,9 +142,10 @@ const char *nvrec_config_get_string(const nvrec_config_t *config, const char *se return entry->value; } -void nvrec_config_set_int(nvrec_config_t *config, const char *section, const char *key, int value) { +void nvrec_config_set_int(nvrec_config_t *config, const char *section, + const char *key, int value) { - char value_str[32] = { 0 }; + char value_str[32] = {0}; assert(config != NULL); assert(section != NULL); assert(key != NULL); @@ -153,7 +154,8 @@ void nvrec_config_set_int(nvrec_config_t *config, const char *section, const cha nvrec_config_set_string(config, section, key, value_str); } -void nvrec_config_set_bool(nvrec_config_t *config, const char *section, const char *key, bool value) { +void nvrec_config_set_bool(nvrec_config_t *config, const char *section, + const char *key, bool value) { assert(config != NULL); assert(section != NULL); assert(key != NULL); @@ -161,35 +163,32 @@ void nvrec_config_set_bool(nvrec_config_t *config, const char *section, const ch nvrec_config_set_string(config, section, key, value ? "true" : "false"); } -void *strdup_ext(const char *value) -{ - void *ptr = NULL; +void *strdup_ext(const char *value) { + void *ptr = NULL; - if(NULL != value) - { - size_t malloclen = (strlen(value)+1); - ptr = zmalloc_ext(malloclen); - memcpy(ptr,value,strlen(value)); - } - return ptr; + if (NULL != value) { + size_t malloclen = (strlen(value) + 1); + ptr = zmalloc_ext(malloclen); + memcpy(ptr, value, strlen(value)); + } + return ptr; } -static char *bdaddrdup(const char * string,unsigned int len) -{ - char *memory; +static char *bdaddrdup(const char *string, unsigned int len) { + char *memory; - if (!string) - return(NULL); - memory = cfg_zmalloc(len+1); - if (NULL != memory) - { - memcpy(memory,string,len); - return memory; - } - return(NULL); + if (!string) + return (NULL); + memory = cfg_zmalloc(len + 1); + if (NULL != memory) { + memcpy(memory, string, len); + return memory; + } + return (NULL); } -void nvrec_config_set_string(nvrec_config_t *config, const char *section, const char *key, const char *value) { +void nvrec_config_set_string(nvrec_config_t *config, const char *section, + const char *key, const char *value) { nvrec_entry_t *entry = NULL; list_node_t *node = NULL; nvrec_section_t *sec = nvrec_section_find(config, section); @@ -197,38 +196,33 @@ void nvrec_config_set_string(nvrec_config_t *config, const char *section, const sec = nvrec_section_new(section); list_append_ext(config->sections, sec); } - if(0 == strcmp(section,section_name_ddbrec)) - { - for (node = list_begin_ext(sec->entries); node != list_end_ext(sec->entries); node = list_next_ext(node)) - { - entry = list_node_ext(node); - if (0 == memcmp(entry->key, key, BTIF_BD_ADDR_SIZE)) - { - cfg_free(entry->value); - entry->value = (char *)strdup_ext(value); - return; - } + if (0 == strcmp(section, section_name_ddbrec)) { + for (node = list_begin_ext(sec->entries); + node != list_end_ext(sec->entries); node = list_next_ext(node)) { + entry = list_node_ext(node); + if (0 == memcmp(entry->key, key, BTIF_BD_ADDR_SIZE)) { + cfg_free(entry->value); + entry->value = (char *)strdup_ext(value); + return; + } + } + } else { + for (node = list_begin_ext(sec->entries); + node != list_end_ext(sec->entries); node = list_next_ext(node)) { + entry = list_node_ext(node); + if (!strcmp(entry->key, key)) { + cfg_free(entry->value); + entry->value = (char *)strdup_ext(value); + return; } - } - else - { - for (node = list_begin_ext(sec->entries); node != list_end_ext(sec->entries); node = list_next_ext(node)) - { - entry = list_node_ext(node); - if (!strcmp(entry->key, key)) - { - cfg_free(entry->value); - entry->value = (char *)strdup_ext(value); - return; - } } } - entry = nvrec_entry_new(key,value,section); + entry = nvrec_entry_new(key, value, section); list_append_ext(sec->entries, entry); } static nvrec_section_t *nvrec_section_new(const char *name) { - // printf("nvrec_section_new-->cfg_zmalloc..........................\r\n"); + // printf("nvrec_section_new-->cfg_zmalloc..........................\r\n"); nvrec_section_t *section = cfg_zmalloc(sizeof(nvrec_section_t)); if (!section) return NULL; @@ -242,16 +236,18 @@ static void nvrec_section_free(void *ptr) { nvrec_section_t *section = ptr; if (!ptr) return; -// printf("nvrec_section_free-->cfg_free..........................\r\n"); + // printf("nvrec_section_free-->cfg_free..........................\r\n"); cfg_free(section->name); list_free_ext(section->entries); cfg_free(section); } -nvrec_section_t *nvrec_section_find(const nvrec_config_t *config, const char *section) { +nvrec_section_t *nvrec_section_find(const nvrec_config_t *config, + const char *section) { nvrec_section_t *sec = NULL; list_node_t *node = NULL; - for (node = list_begin_ext(config->sections); node != list_end_ext(config->sections); node = list_next_ext(node)) { + for (node = list_begin_ext(config->sections); + node != list_end_ext(config->sections); node = list_next_ext(node)) { sec = list_node_ext(node); if (!strcmp(sec->name, section)) return sec; @@ -260,47 +256,47 @@ nvrec_section_t *nvrec_section_find(const nvrec_config_t *config, const char *se return NULL; } -static nvrec_entry_t *nvrec_entry_new(const char *key,const char *value,const char *descrip) -{ - nvrec_entry_t *entry = cfg_zmalloc(sizeof(nvrec_entry_t)); - if (!entry) - return NULL; - if(0 == strcmp(descrip,section_name_ddbrec)) - entry->key = bdaddrdup(key,BTIF_BD_ADDR_SIZE); - else - entry->key = strdup_ext(key); - entry->value = strdup_ext(value); - return entry; +static nvrec_entry_t *nvrec_entry_new(const char *key, const char *value, + const char *descrip) { + nvrec_entry_t *entry = cfg_zmalloc(sizeof(nvrec_entry_t)); + if (!entry) + return NULL; + if (0 == strcmp(descrip, section_name_ddbrec)) + entry->key = bdaddrdup(key, BTIF_BD_ADDR_SIZE); + else + entry->key = strdup_ext(key); + entry->value = strdup_ext(value); + return entry; } void nvrec_entry_free(void *ptr) { nvrec_entry_t *entry = ptr; if (!ptr) return; -// printf("entry_free-->cfg_free..........................\r\n"); + // printf("entry_free-->cfg_free..........................\r\n"); cfg_free(entry->key); cfg_free(entry->value); cfg_free(entry); } -static nvrec_entry_t *nvrec_entry_find(const nvrec_config_t *config, const char *section, const char *key) { +static nvrec_entry_t *nvrec_entry_find(const nvrec_config_t *config, + const char *section, const char *key) { list_node_t *node = NULL; nvrec_section_t *sec = nvrec_section_find(config, section); if (!sec) return NULL; - if(0 == strcmp(section,section_name_ddbrec)) - { - for (node = list_begin_ext(sec->entries); node != list_end_ext(sec->entries); node = list_next_ext(node)) - { + if (0 == strcmp(section, section_name_ddbrec)) { + for (node = list_begin_ext(sec->entries); + node != list_end_ext(sec->entries); node = list_next_ext(node)) { nvrec_entry_t *entry = list_node_ext(node); - if (0 == memcmp((const void*)entry->key, (const void*)key, BTIF_BD_ADDR_SIZE)) + if (0 == memcmp((const void *)entry->key, (const void *)key, + BTIF_BD_ADDR_SIZE)) return entry; } return NULL; - } - else - { - for (node = list_begin_ext(sec->entries); node != list_end_ext(sec->entries); node = list_next_ext(node)) { + } else { + for (node = list_begin_ext(sec->entries); + node != list_end_ext(sec->entries); node = list_next_ext(node)) { nvrec_entry_t *entry = list_node_ext(node); if (!strcmp(entry->key, key)) return entry; diff --git a/services/nvrecord/nvrecord.c b/services/nvrecord/nvrecord.c index 8d9bee9..699aa3b 100644 --- a/services/nvrecord/nvrecord.c +++ b/services/nvrecord/nvrecord.c @@ -13,30 +13,30 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "hal_sleep.h" -#include "besbt.h" #include "nvrecord.h" +#include "besbt.h" +#include "crc32.h" +#include "hal_norflash.h" +#include "hal_sleep.h" +#include "hal_timer.h" +#include "norflash_api.h" #include "nvrecord_dev.h" #include "nvrecord_env.h" -#include "crc32.h" -#include "hal_timer.h" -#include "hal_norflash.h" #include "pmu.h" #include "tgt_hardware.h" -#include "norflash_api.h" +#include //#define NVREC_BURN_TEST #define OS_DUMP8(x...) // factory section region -#define NVRECORD_CACHE_2_UNCACHE(addr) \ - ((unsigned char *)((unsigned int)addr & ~(0x04000000))) +#define NVRECORD_CACHE_2_UNCACHE(addr) \ + ((unsigned char *)((unsigned int)addr & ~(0x04000000))) static bool dev_sector_valid = false; uint8_t nv_record_dev_rev = NVREC_DEV_NEWEST_REV; -#define CLASSIC_BTNAME_LEN (BLE_NAME_LEN_IN_NV-5) -char classics_bt_name[CLASSIC_BTNAME_LEN]= "BES"; +#define CLASSIC_BTNAME_LEN (BLE_NAME_LEN_IN_NV - 5) +char classics_bt_name[CLASSIC_BTNAME_LEN] = "BES"; extern uint32_t __factory_start[]; @@ -57,15 +57,16 @@ extern uint32_t __factory_start[]; #if !defined(NEW_NV_RECORD_ENABLED) #ifdef __ARMCC_VERSION -#define USERDATA_POOL_LOC __attribute__((section(".bss.userdata_pool"))) +#define USERDATA_POOL_LOC __attribute__((section(".bss.userdata_pool"))) #else -#define USERDATA_POOL_LOC __attribute__((section(".userdata_pool"))) +#define USERDATA_POOL_LOC __attribute__((section(".userdata_pool"))) #endif //#define LINK_KEY_ENCRYPT #ifdef LINK_KEY_ENCRYPT #include "aes.h" -#define LINK_KEY_ENCRYPT_KEY "\x11\x07\x9e\x34\x9B\x5F\x80\x00\x00\x80\x00\x10\x00\x00\x00\x01" +#define LINK_KEY_ENCRYPT_KEY \ + "\x11\x07\x9e\x34\x9B\x5F\x80\x00\x00\x80\x00\x10\x00\x00\x00\x01" #endif extern uint32_t __userdata_start[]; @@ -73,7 +74,7 @@ extern uint32_t __userdata_end[]; extern int nv_record_flash_flush_in_sleep(void); static int nv_record_flash_flush_int(bool is_async); -void nv_callback(void* param); +void nv_callback(void *param); nv_record_struct nv_record_config; static bool nvrec_init = false; @@ -84,312 +85,277 @@ static uint32_t _user_data_bak_start; static uint32_t USERDATA_POOL_LOC usrdata_ddblist_pool[1024]; -static void nv_record_print_dev_record(const btif_device_record_t* record) -{ +static void nv_record_print_dev_record(const btif_device_record_t *record) { #ifdef nv_record_debug - nvrec_trace(0,"nv record bdAddr = "); - DUMP8("%02x ",record->bdAddr.address,sizeof(record->bdAddr.address)); - nvrec_trace(0,"record_trusted = "); - DUMP8("%d ",&record->trusted,sizeof((uint8_t)record->trusted)); - nvrec_trace(0,"record_linkKey = "); - DUMP8("%02x ",record->linkKey,sizeof(record->linkKey)); - nvrec_trace(0,"record_keyType = "); - DUMP8("%x ",&record->keyType,sizeof(record->keyType)); - nvrec_trace(0,"record_pinLen = "); - DUMP8("%x ",&record->pinLen,sizeof(record->pinLen)); + nvrec_trace(0, "nv record bdAddr = "); + DUMP8("%02x ", record->bdAddr.address, sizeof(record->bdAddr.address)); + nvrec_trace(0, "record_trusted = "); + DUMP8("%d ", &record->trusted, sizeof((uint8_t)record->trusted)); + nvrec_trace(0, "record_linkKey = "); + DUMP8("%02x ", record->linkKey, sizeof(record->linkKey)); + nvrec_trace(0, "record_keyType = "); + DUMP8("%x ", &record->keyType, sizeof(record->keyType)); + nvrec_trace(0, "record_pinLen = "); + DUMP8("%x ", &record->pinLen, sizeof(record->pinLen)); #endif } heap_handle_t g_nv_mempool = NULL; -static void nv_record_mempool_init(void) -{ - unsigned char *poolstart = 0; - - poolstart = (unsigned char *)(usrdata_ddblist_pool+mempool_pre_offset); - if(!nvrec_mempool_init) - { - g_nv_mempool = heap_register((unsigned char*)poolstart, (size_t)(sizeof(usrdata_ddblist_pool)-(mempool_pre_offset*sizeof(uint32_t)))); - nvrec_mempool_init = TRUE; - } - /*add other memory pool */ +static void nv_record_mempool_init(void) { + unsigned char *poolstart = 0; + poolstart = (unsigned char *)(usrdata_ddblist_pool + mempool_pre_offset); + if (!nvrec_mempool_init) { + g_nv_mempool = + heap_register((unsigned char *)poolstart, + (size_t)(sizeof(usrdata_ddblist_pool) - + (mempool_pre_offset * sizeof(uint32_t)))); + nvrec_mempool_init = TRUE; + } + /*add other memory pool */ } -static bool nv_record_data_is_valid(void) -{ - uint32_t crc; - uint32_t flsh_crc; - uint32_t verandmagic; +static bool nv_record_data_is_valid(void) { + uint32_t crc; + uint32_t flsh_crc; + uint32_t verandmagic; - verandmagic = usrdata_ddblist_pool[0]; - if(((nvrecord_struct_version<<16)|nvrecord_magic) != verandmagic) - { - nvrec_trace(2,"%s: verandmagic error! verandmagic = 0x%x.",__func__,((nvrecord_struct_version<<16)|nvrecord_magic)); - return false; - } - crc = crc32(0,(uint8_t *)(&usrdata_ddblist_pool[pos_heap_contents]),(sizeof(usrdata_ddblist_pool)-(pos_heap_contents*sizeof(uint32_t)))); - flsh_crc = usrdata_ddblist_pool[pos_crc]; - if (flsh_crc == crc) - { - return true; - } - else - { - nvrec_trace(3,"%s: crc checking fail! flsh_crc = 0x%x,crc = 0x%x.",__func__,flsh_crc,crc); - return false; - } + verandmagic = usrdata_ddblist_pool[0]; + if (((nvrecord_struct_version << 16) | nvrecord_magic) != verandmagic) { + nvrec_trace(2, "%s: verandmagic error! verandmagic = 0x%x.", __func__, + ((nvrecord_struct_version << 16) | nvrecord_magic)); + return false; + } + crc = crc32( + 0, (uint8_t *)(&usrdata_ddblist_pool[pos_heap_contents]), + (sizeof(usrdata_ddblist_pool) - (pos_heap_contents * sizeof(uint32_t)))); + flsh_crc = usrdata_ddblist_pool[pos_crc]; + if (flsh_crc == crc) { + return true; + } else { + nvrec_trace(3, "%s: crc checking fail! flsh_crc = 0x%x,crc = 0x%x.", + __func__, flsh_crc, crc); + return false; + } } -static bool nv_record_list_is_valid(void) -{ - nvrec_config_t *config = NULL; - nvrec_section_t *sec = NULL; - list_node_t *node = NULL; - list_node_t *sub_node = NULL; - nvrec_entry_t *entry = NULL; - bool ret = true; - uint32_t mem_start; - uint32_t mem_end; +static bool nv_record_list_is_valid(void) { + nvrec_config_t *config = NULL; + nvrec_section_t *sec = NULL; + list_node_t *node = NULL; + list_node_t *sub_node = NULL; + nvrec_entry_t *entry = NULL; + bool ret = true; + uint32_t mem_start; + uint32_t mem_end; - config = (nvrec_config_t *)usrdata_ddblist_pool[pos_config_addr]; - if(usrdata_ddblist_pool[pos_start_ram_addr] != (uint32_t)usrdata_ddblist_pool) - { - return false; + config = (nvrec_config_t *)usrdata_ddblist_pool[pos_config_addr]; + if (usrdata_ddblist_pool[pos_start_ram_addr] != + (uint32_t)usrdata_ddblist_pool) { + return false; + } + mem_start = (uint32_t)config; + mem_end = mem_start + (sizeof(usrdata_ddblist_pool) - + (pos_heap_contents * sizeof(uint32_t))); + for (node = list_begin_ext(config->sections); + node != list_end_ext(config->sections); node = list_next_ext(node)) { + sec = list_node_ext(node); + + for (sub_node = list_begin_ext(sec->entries); + sub_node != list_end_ext(sec->entries); + sub_node = list_next_ext(sub_node)) { + entry = list_node_ext(sub_node); + if (entry->key == NULL || entry->value == NULL) { + ret = false; + break; + } + + if (((uint32_t)entry->key >= mem_start && + (uint32_t)entry->key + strlen(entry->key) < mem_end) && + ((uint32_t)entry->value >= mem_start && + (uint32_t)entry->value + strlen(entry->value) < mem_end)) { + // nvrec_trace(4,"%s: entry = 0x%x,key = 0x%x, value = 0x%x.", + // __func__,(uint32_t)entry,(uint32_t)entry->key,(uint32_t)entry->value); + } else { + nvrec_trace(4, "%s: sec = 0x%x,name = %s, entries = 0x%x.", __func__, + (uint32_t)sec, sec->name, (uint32_t)sec->entries); + nvrec_trace( + 4, + "%s: entry pointer error! entry = 0x%x,key = 0x%x, value = 0x%x.", + __func__, (uint32_t)entry, (uint32_t)entry->key, + (uint32_t)entry->value); + ret = false; + break; + } } - mem_start = (uint32_t)config; - mem_end = mem_start + (sizeof(usrdata_ddblist_pool)-(pos_heap_contents*sizeof(uint32_t))); - for (node = list_begin_ext(config->sections); node != list_end_ext(config->sections); node = list_next_ext(node)) - { - sec = list_node_ext(node); - - for (sub_node = list_begin_ext(sec->entries); sub_node != list_end_ext(sec->entries); sub_node = list_next_ext(sub_node)) - { - entry = list_node_ext(sub_node); - if(entry->key == NULL || entry->value == NULL) - { - ret = false; - break; - } - - if(((uint32_t)entry->key >= mem_start && (uint32_t)entry->key + strlen(entry->key) < mem_end) - && ((uint32_t)entry->value >= mem_start && (uint32_t)entry->value + strlen(entry->value) < mem_end)) - { - // nvrec_trace(4,"%s: entry = 0x%x,key = 0x%x, value = 0x%x.", - // __func__,(uint32_t)entry,(uint32_t)entry->key,(uint32_t)entry->value); - } - else - { - nvrec_trace(4,"%s: sec = 0x%x,name = %s, entries = 0x%x.", - __func__,(uint32_t)sec,sec->name,(uint32_t)sec->entries); - nvrec_trace(4,"%s: entry pointer error! entry = 0x%x,key = 0x%x, value = 0x%x.", - __func__,(uint32_t)entry,(uint32_t)entry->key,(uint32_t)entry->value); - ret = false; - break; - } - } - if(!ret) - { - break; - } + if (!ret) { + break; } - return ret; + } + return ret; } -void nv_record_init(void) -{ - enum NORFLASH_API_RET_T result; - uint32_t sector_size = 0; - uint32_t block_size = 0; - uint32_t page_size = 0; +void nv_record_init(void) { + enum NORFLASH_API_RET_T result; + uint32_t sector_size = 0; + uint32_t block_size = 0; + uint32_t page_size = 0; - hal_norflash_get_size(HAL_NORFLASH_ID_0, - NULL, - &block_size, - §or_size, - &page_size); - result = norflash_api_register(NORFLASH_API_MODULE_ID_USERDATA, - HAL_NORFLASH_ID_0, - ((uint32_t)__userdata_start), - (uint32_t)__userdata_end - (uint32_t)__userdata_start, - block_size, - sector_size, - page_size, - sizeof(usrdata_ddblist_pool)*2, - nv_callback - ); - ASSERT(result == NORFLASH_API_OK,"nv_record_init: module register failed! result = %d.",result); + hal_norflash_get_size(HAL_NORFLASH_ID_0, NULL, &block_size, §or_size, + &page_size); + result = norflash_api_register( + NORFLASH_API_MODULE_ID_USERDATA, HAL_NORFLASH_ID_0, + ((uint32_t)__userdata_start), + (uint32_t)__userdata_end - (uint32_t)__userdata_start, block_size, + sector_size, page_size, sizeof(usrdata_ddblist_pool) * 2, nv_callback); + ASSERT(result == NORFLASH_API_OK, + "nv_record_init: module register failed! result = %d.", result); } -bt_status_t nv_record_open(SECTIONS_ADP_ENUM section_id) -{ - bt_status_t ret_status = BT_STS_FAILED; - uint32_t lock; - bool main_is_valid = false; - bool bak_is_valid = false; - bool data_is_valid = false; - if(nvrec_init) - { - return BT_STS_SUCCESS; - } - _user_data_main_start = (uint32_t)__userdata_start; - _user_data_bak_start = (uint32_t)__userdata_start + nvrecord_mem_pool_size; - - lock = int_lock_global(); - - nv_record_config.is_update = false; - nv_record_config.written_size = 0; - nv_record_config.state = NV_STATE_IDLE; - switch(section_id) - { - case section_usrdata_ddbrecord: - // userdata main sector checking. - memcpy((void *)usrdata_ddblist_pool,(void *)_user_data_main_start, - sizeof(usrdata_ddblist_pool)); - if( nv_record_data_is_valid() - && usrdata_ddblist_pool[pos_start_ram_addr]==(uint32_t)usrdata_ddblist_pool) - { - if(nv_record_list_is_valid()) - { - // nvrec_trace(1,"%s,main sector list valid.",__func__); - main_is_valid = true; - } - else - { - nvrec_trace(1,"%s,main sector list invalid.",__func__); - main_is_valid = false; - } - } - else - { - nvrec_trace(1,"%s,main sector data invalid.",__func__); - main_is_valid = false; - } - - // userdata bak sector checking. - memcpy((void *)usrdata_ddblist_pool,(void *)_user_data_bak_start, - sizeof(usrdata_ddblist_pool)); - if( nv_record_data_is_valid() - && usrdata_ddblist_pool[pos_start_ram_addr]==(uint32_t)usrdata_ddblist_pool) - { - if(nv_record_list_is_valid()) - { - // TRACE(1,"%s,bak sector list valid.",__func__); - bak_is_valid = true; - } - else - { - nvrec_trace(1,"%s,bak sector list invalid.",__func__); - bak_is_valid = false; - } - } - else - { - nvrec_trace(1,"%s,bak sector data invalid.",__func__); - bak_is_valid = false; - } - - if(main_is_valid) - { - memcpy((void *)usrdata_ddblist_pool,(void *)_user_data_main_start, - sizeof(usrdata_ddblist_pool)); - data_is_valid = true; - if(!bak_is_valid) - { - nv_record_config.is_update = true; - nv_record_config.state = NV_STATE_MAIN_DONE; - nv_record_config.config = (nvrec_config_t *)usrdata_ddblist_pool[pos_config_addr]; - nv_record_flash_flush_int(false); - } - } - else - { - if(bak_is_valid) - { - memcpy((void *)usrdata_ddblist_pool,(void *)_user_data_bak_start, - sizeof(usrdata_ddblist_pool)); - nv_record_config.config = (nvrec_config_t *)usrdata_ddblist_pool[pos_config_addr]; - data_is_valid = true; - nv_record_config.is_update = true; - nv_record_config.state = NV_STATE_IDLE; - nv_record_flash_flush_int(false); - } - else - { - data_is_valid = false; - } - } - - if(data_is_valid) - { - nv_record_config.config = (nvrec_config_t *)usrdata_ddblist_pool[pos_config_addr]; - // nvrec_trace(4,"%s,config=0x%x,g_nv_mempool=0x%x,ln=%d\n", - // nvrecord_tag,usrdata_ddblist_pool[pos_config_addr],g_nv_mempool,__LINE__); - g_nv_mempool = (heap_handle_t)(&usrdata_ddblist_pool[mempool_pre_offset]); - ret_status = BT_STS_SUCCESS; - } - else - { - nvrec_trace(1,"%s,userdata invalid. ",__func__); - ret_status = nv_record_config_rebuild(); - if(ret_status != BT_STS_SUCCESS) - { - break; - } - - ret_status = BT_STS_SUCCESS; - } - break; - default: - break; - } - nvrec_init = true; - - if (ret_status == BT_STS_SUCCESS) - { -#ifdef FLASH_SUSPEND - hal_sleep_set_sleep_hook(HAL_SLEEP_HOOK_USER_NVRECORD, - nv_record_flash_flush_in_sleep); -#else - hal_sleep_set_deep_sleep_hook(HAL_DEEP_SLEEP_HOOK_USER_NVRECORD, - nv_record_flash_flush_in_sleep); -#endif - } - - int_unlock_global(lock); - nvrec_trace(2,"%s,open,ret_status=%d\n",nvrecord_tag,ret_status); - return ret_status; -} - -bt_status_t nv_record_config_rebuild(void) -{ - nvrec_mempool_init = false; - memset(usrdata_ddblist_pool,0,sizeof(usrdata_ddblist_pool)); - usrdata_ddblist_pool[pos_version_and_magic] = ((nvrecord_struct_version<<16)|nvrecord_magic); - nv_record_mempool_init(); - nv_record_config.config = nvrec_config_new("PRECIOUS 4K."); - if(nv_record_config.config == NULL) - return BT_STS_FAILED; - - nvrec_init = true; - nv_record_config.is_update = true; +bt_status_t nv_record_open(SECTIONS_ADP_ENUM section_id) { + bt_status_t ret_status = BT_STS_FAILED; + uint32_t lock; + bool main_is_valid = false; + bool bak_is_valid = false; + bool data_is_valid = false; + if (nvrec_init) { return BT_STS_SUCCESS; + } + _user_data_main_start = (uint32_t)__userdata_start; + _user_data_bak_start = (uint32_t)__userdata_start + nvrecord_mem_pool_size; + + lock = int_lock_global(); + + nv_record_config.is_update = false; + nv_record_config.written_size = 0; + nv_record_config.state = NV_STATE_IDLE; + switch (section_id) { + case section_usrdata_ddbrecord: + // userdata main sector checking. + memcpy((void *)usrdata_ddblist_pool, (void *)_user_data_main_start, + sizeof(usrdata_ddblist_pool)); + if (nv_record_data_is_valid() && usrdata_ddblist_pool[pos_start_ram_addr] == + (uint32_t)usrdata_ddblist_pool) { + if (nv_record_list_is_valid()) { + // nvrec_trace(1,"%s,main sector list valid.",__func__); + main_is_valid = true; + } else { + nvrec_trace(1, "%s,main sector list invalid.", __func__); + main_is_valid = false; + } + } else { + nvrec_trace(1, "%s,main sector data invalid.", __func__); + main_is_valid = false; + } + + // userdata bak sector checking. + memcpy((void *)usrdata_ddblist_pool, (void *)_user_data_bak_start, + sizeof(usrdata_ddblist_pool)); + if (nv_record_data_is_valid() && usrdata_ddblist_pool[pos_start_ram_addr] == + (uint32_t)usrdata_ddblist_pool) { + if (nv_record_list_is_valid()) { + // TRACE(1,"%s,bak sector list valid.",__func__); + bak_is_valid = true; + } else { + nvrec_trace(1, "%s,bak sector list invalid.", __func__); + bak_is_valid = false; + } + } else { + nvrec_trace(1, "%s,bak sector data invalid.", __func__); + bak_is_valid = false; + } + + if (main_is_valid) { + memcpy((void *)usrdata_ddblist_pool, (void *)_user_data_main_start, + sizeof(usrdata_ddblist_pool)); + data_is_valid = true; + if (!bak_is_valid) { + nv_record_config.is_update = true; + nv_record_config.state = NV_STATE_MAIN_DONE; + nv_record_config.config = + (nvrec_config_t *)usrdata_ddblist_pool[pos_config_addr]; + nv_record_flash_flush_int(false); + } + } else { + if (bak_is_valid) { + memcpy((void *)usrdata_ddblist_pool, (void *)_user_data_bak_start, + sizeof(usrdata_ddblist_pool)); + nv_record_config.config = + (nvrec_config_t *)usrdata_ddblist_pool[pos_config_addr]; + data_is_valid = true; + nv_record_config.is_update = true; + nv_record_config.state = NV_STATE_IDLE; + nv_record_flash_flush_int(false); + } else { + data_is_valid = false; + } + } + + if (data_is_valid) { + nv_record_config.config = + (nvrec_config_t *)usrdata_ddblist_pool[pos_config_addr]; + // nvrec_trace(4,"%s,config=0x%x,g_nv_mempool=0x%x,ln=%d\n", + // nvrecord_tag,usrdata_ddblist_pool[pos_config_addr],g_nv_mempool,__LINE__); + g_nv_mempool = (heap_handle_t)(&usrdata_ddblist_pool[mempool_pre_offset]); + ret_status = BT_STS_SUCCESS; + } else { + nvrec_trace(1, "%s,userdata invalid. ", __func__); + ret_status = nv_record_config_rebuild(); + if (ret_status != BT_STS_SUCCESS) { + break; + } + + ret_status = BT_STS_SUCCESS; + } + break; + default: + break; + } + nvrec_init = true; + + if (ret_status == BT_STS_SUCCESS) { +#ifdef FLASH_SUSPEND + hal_sleep_set_sleep_hook(HAL_SLEEP_HOOK_USER_NVRECORD, + nv_record_flash_flush_in_sleep); +#else + hal_sleep_set_deep_sleep_hook(HAL_DEEP_SLEEP_HOOK_USER_NVRECORD, + nv_record_flash_flush_in_sleep); +#endif + } + + int_unlock_global(lock); + nvrec_trace(2, "%s,open,ret_status=%d\n", nvrecord_tag, ret_status); + return ret_status; } -static size_t config_entries_get_ddbrec_length(const char *secname) -{ - size_t entries_len = 0; +bt_status_t nv_record_config_rebuild(void) { + nvrec_mempool_init = false; + memset(usrdata_ddblist_pool, 0, sizeof(usrdata_ddblist_pool)); + usrdata_ddblist_pool[pos_version_and_magic] = + ((nvrecord_struct_version << 16) | nvrecord_magic); + nv_record_mempool_init(); + nv_record_config.config = nvrec_config_new("PRECIOUS 4K."); + if (nv_record_config.config == NULL) + return BT_STS_FAILED; - if(NULL != nv_record_config.config) - { - nvrec_section_t *sec = NULL; - sec = nvrec_section_find(nv_record_config.config,secname); - if (NULL != sec) - entries_len = sec->entries->length; - } - return entries_len; + nvrec_init = true; + nv_record_config.is_update = true; + return BT_STS_SUCCESS; +} + +static size_t config_entries_get_ddbrec_length(const char *secname) { + size_t entries_len = 0; + + if (NULL != nv_record_config.config) { + nvrec_section_t *sec = NULL; + sec = nvrec_section_find(nv_record_config.config, secname); + if (NULL != sec) + entries_len = sec->entries->length; + } + return entries_len; } #if 0 @@ -405,452 +371,466 @@ static bool config_entries_has_ddbrec(const btif_device_record_t* param_rec) } #endif -static void config_entries_ddbdev_delete_head(void)//delete the oldest record. +static void config_entries_ddbdev_delete_head(void) // delete the oldest record. { - list_node_t *head_node = NULL; - list_t *entry = NULL; - nvrec_section_t *sec = NULL; + list_node_t *head_node = NULL; + list_t *entry = NULL; + nvrec_section_t *sec = NULL; - sec = nvrec_section_find(nv_record_config.config,section_name_ddbrec); - entry = sec->entries; - head_node = list_begin_ext(entry); - if(NULL != head_node) - { - btif_device_record_t *rec = NULL; - unsigned int recaddr = 0; + sec = nvrec_section_find(nv_record_config.config, section_name_ddbrec); + entry = sec->entries; + head_node = list_begin_ext(entry); + if (NULL != head_node) { + btif_device_record_t *rec = NULL; + unsigned int recaddr = 0; - nvrec_entry_t *entry_temp = list_node_ext(head_node); - recaddr = nvrec_config_get_int(nv_record_config.config,section_name_ddbrec,entry_temp->key,0); - rec = (btif_device_record_t *)recaddr; - pool_free(rec); - nvrec_entry_free(entry_temp); - if(1 == config_entries_get_ddbrec_length(section_name_ddbrec)) - entry->head = entry->tail = NULL; - else - entry->head = list_next_ext(head_node); - pool_free(head_node); - entry->length -= 1; - } + nvrec_entry_t *entry_temp = list_node_ext(head_node); + recaddr = nvrec_config_get_int(nv_record_config.config, section_name_ddbrec, + entry_temp->key, 0); + rec = (btif_device_record_t *)recaddr; + pool_free(rec); + nvrec_entry_free(entry_temp); + if (1 == config_entries_get_ddbrec_length(section_name_ddbrec)) + entry->head = entry->tail = NULL; + else + entry->head = list_next_ext(head_node); + pool_free(head_node); + entry->length -= 1; + } } -static void config_entries_ddbdev_delete_tail(void) -{ - list_node_t *node = NULL; - list_node_t *temp_ptr = NULL; - list_node_t *tailnode = NULL; - size_t entrieslen = 0; - nvrec_entry_t *entry_temp = NULL; - nvrec_section_t *sec = nvrec_section_find(nv_record_config.config,section_name_ddbrec); - btif_device_record_t *recaddr = NULL; - unsigned int addr = 0; +static void config_entries_ddbdev_delete_tail(void) { + list_node_t *node = NULL; + list_node_t *temp_ptr = NULL; + list_node_t *tailnode = NULL; + size_t entrieslen = 0; + nvrec_entry_t *entry_temp = NULL; + nvrec_section_t *sec = + nvrec_section_find(nv_record_config.config, section_name_ddbrec); + btif_device_record_t *recaddr = NULL; + unsigned int addr = 0; - if (!sec) - assert(0); - sec->entries->length -= 1; - entrieslen = sec->entries->length; - node = list_begin_ext(sec->entries); - while(entrieslen > 1) - { - node = list_next_ext(node); - entrieslen--; + if (!sec) + assert(0); + sec->entries->length -= 1; + entrieslen = sec->entries->length; + node = list_begin_ext(sec->entries); + while (entrieslen > 1) { + node = list_next_ext(node); + entrieslen--; + } + tailnode = list_next_ext(node); + entry_temp = list_node_ext(tailnode); + addr = nvrec_config_get_int(nv_record_config.config, section_name_ddbrec, + entry_temp->key, 0); + recaddr = (btif_device_record_t *)addr; + pool_free(recaddr); + nvrec_entry_free(entry_temp); + // pool_free(entry_temp); + temp_ptr = node->next; + node->next = NULL; + pool_free(temp_ptr); + sec->entries->tail = node; +} + +static void +config_entries_ddbdev_delete(const btif_device_record_t *param_rec) { + nvrec_section_t *sec = NULL; + list_node_t *entry_del = NULL; + list_node_t *entry_pre = NULL; + list_node_t *entry_next = NULL; + list_node_t *node = NULL; + btif_device_record_t *recaddr = NULL; + unsigned int addr = 0; + int pos = 0, pos_pre = 0; + nvrec_entry_t *entry_temp = NULL; + + sec = nvrec_section_find(nv_record_config.config, section_name_ddbrec); + for (node = list_begin_ext(sec->entries); node != NULL; + node = list_next_ext(node)) { + nvrec_entry_t *entries = list_node_ext(node); + pos++; + if (0 == + memcmp(entries->key, param_rec->bdAddr.address, BTIF_BD_ADDR_SIZE)) { + entry_del = node; + entry_next = entry_del->next; + break; } - tailnode = list_next_ext(node); - entry_temp = list_node_ext(tailnode); - addr = nvrec_config_get_int(nv_record_config.config,section_name_ddbrec,entry_temp->key,0); + } + + if (entry_del) { + /*get entry_del pre node*/ + pos_pre = (pos - 1); + pos = 0; + node = list_begin_ext(sec->entries); + pos++; + while (pos < pos_pre) { + node = list_next_ext(node); + pos += 1; + } + entry_pre = node; + + /*delete entry_del following...*/ + entry_temp = list_node_ext(entry_del); + addr = nvrec_config_get_int(nv_record_config.config, section_name_ddbrec, + (char *)entry_temp->key, 0); + assert(0 != addr); recaddr = (btif_device_record_t *)addr; pool_free(recaddr); nvrec_entry_free(entry_temp); - //pool_free(entry_temp); - temp_ptr = node->next; - node->next = NULL; - pool_free(temp_ptr); - sec->entries->tail = node; + // pool_free(entry_temp); + pool_free(entry_pre->next); + entry_pre->next = entry_next; + sec->entries->length -= 1; + } } -static void config_entries_ddbdev_delete(const btif_device_record_t* param_rec) -{ - nvrec_section_t *sec = NULL; - list_node_t *entry_del = NULL; - list_node_t *entry_pre = NULL; - list_node_t *entry_next = NULL; - list_node_t *node = NULL; - btif_device_record_t *recaddr = NULL; - unsigned int addr = 0; - int pos = 0,pos_pre=0; - nvrec_entry_t *entry_temp = NULL; +static bool +config_entries_ddbdev_is_head(const btif_device_record_t *param_rec) { + list_node_t *head_node = NULL; + nvrec_section_t *sec = NULL; + list_t *entry = NULL; + nvrec_entry_t *entry_temp = NULL; - sec = nvrec_section_find(nv_record_config.config,section_name_ddbrec); - for(node=list_begin_ext(sec->entries);node!=NULL;node=list_next_ext(node)) - { - nvrec_entry_t *entries = list_node_ext(node); - pos++; - if(0 == memcmp(entries->key,param_rec->bdAddr.address,BTIF_BD_ADDR_SIZE)) - { - entry_del = node; - entry_next = entry_del->next; - break; - } - } - - if (entry_del){ - /*get entry_del pre node*/ - pos_pre = (pos-1); - pos=0; - node=list_begin_ext(sec->entries); - pos++; - while(pos < pos_pre) - { - node=list_next_ext(node); - pos += 1; - } - entry_pre = node; - - /*delete entry_del following...*/ - entry_temp = list_node_ext(entry_del); - addr = nvrec_config_get_int(nv_record_config.config,section_name_ddbrec,(char *)entry_temp->key,0); - assert(0!=addr); - recaddr = (btif_device_record_t *)addr; - pool_free(recaddr); - nvrec_entry_free(entry_temp); - //pool_free(entry_temp); - pool_free(entry_pre->next); - entry_pre->next = entry_next; - sec->entries->length -= 1; - } + sec = nvrec_section_find(nv_record_config.config, section_name_ddbrec); + entry = sec->entries; + head_node = list_begin_ext(entry); + entry_temp = list_node_ext(head_node); + if (0 == + memcmp(entry_temp->key, param_rec->bdAddr.address, BTIF_BD_ADDR_SIZE)) + return true; + return false; } -static bool config_entries_ddbdev_is_head(const btif_device_record_t* param_rec) -{ - list_node_t *head_node = NULL; - nvrec_section_t *sec = NULL; - list_t *entry = NULL; - nvrec_entry_t *entry_temp = NULL; +static bool +config_entries_ddbdev_is_tail(const btif_device_record_t *param_rec) { + list_node_t *node = NULL; + nvrec_entry_t *entry_temp = NULL; - sec = nvrec_section_find(nv_record_config.config,section_name_ddbrec); - entry = sec->entries; - head_node = list_begin_ext(entry); - entry_temp = list_node_ext(head_node); - if(0 == memcmp(entry_temp->key,param_rec->bdAddr.address,BTIF_BD_ADDR_SIZE)) - return true; - return false; -} - -static bool config_entries_ddbdev_is_tail(const btif_device_record_t* param_rec) -{ - list_node_t *node = NULL; - nvrec_entry_t *entry_temp = NULL; - - nvrec_section_t *sec = nvrec_section_find(nv_record_config.config,section_name_ddbrec); - if (!sec) - assert(0); - for (node = list_begin_ext(sec->entries); node != list_end_ext(sec->entries); node = list_next_ext(node)) - { - entry_temp = list_node_ext(node); - } - if(0 == memcmp(entry_temp->key,param_rec->bdAddr.address,BTIF_BD_ADDR_SIZE)) - return true; - return false; + nvrec_section_t *sec = + nvrec_section_find(nv_record_config.config, section_name_ddbrec); + if (!sec) + assert(0); + for (node = list_begin_ext(sec->entries); node != list_end_ext(sec->entries); + node = list_next_ext(node)) { + entry_temp = list_node_ext(node); + } + if (0 == + memcmp(entry_temp->key, param_rec->bdAddr.address, BTIF_BD_ADDR_SIZE)) + return true; + return false; } /* this function should be surrounded by OS_LockStack and OS_UnlockStack when call. */ -static void config_specific_entry_value_delete(const btif_device_record_t* param_rec) -{ - if(config_entries_ddbdev_is_head(param_rec)) - config_entries_ddbdev_delete_head(); - else if(config_entries_ddbdev_is_tail(param_rec)) - config_entries_ddbdev_delete_tail(); - else - config_entries_ddbdev_delete(param_rec); - nv_record_update_runtime_userdata(); +static void +config_specific_entry_value_delete(const btif_device_record_t *param_rec) { + if (config_entries_ddbdev_is_head(param_rec)) + config_entries_ddbdev_delete_head(); + else if (config_entries_ddbdev_is_tail(param_rec)) + config_entries_ddbdev_delete_tail(); + else + config_entries_ddbdev_delete(param_rec); + nv_record_update_runtime_userdata(); } - /********************************************** gyt add:list head is the odest,list tail is the latest. this function should be surrounded by OS_LockStack and OS_UnlockStack when call. **********************************************/ -static bt_status_t POSSIBLY_UNUSED nv_record_ddbrec_add(const btif_device_record_t* param_rec) -{ - btdevice_volume device_vol; - btdevice_profile device_plf; - char key[BTIF_BD_ADDR_SIZE+1] = {0,}; - nvrec_btdevicerecord *nvrec_pool_record = NULL; - bool ddbrec_exist = false; - bool is_flush = true; - int getint; +static bt_status_t POSSIBLY_UNUSED +nv_record_ddbrec_add(const btif_device_record_t *param_rec) { + btdevice_volume device_vol; + btdevice_profile device_plf; + char key[BTIF_BD_ADDR_SIZE + 1] = { + 0, + }; + nvrec_btdevicerecord *nvrec_pool_record = NULL; + bool ddbrec_exist = false; + bool is_flush = true; + int getint; #ifdef BTIF_DIP_DEVICE - uint16_t vend_id = 0; - uint16_t vend_id_source = 0; + uint16_t vend_id = 0; + uint16_t vend_id_source = 0; #endif - device_vol.a2dp_vol = NVRAM_ENV_STREAM_VOLUME_A2DP_VOL_DEFAULT; - device_vol.hfp_vol = NVRAM_ENV_STREAM_VOLUME_HFP_VOL_DEFAULT; - device_plf.hfp_act = false; - device_plf.hsp_act = false; - device_plf.a2dp_act = false; - device_plf.a2dp_codectype = 0; - if(NULL == param_rec) - return BT_STS_FAILED; - memcpy(key,param_rec->bdAddr.address,BTIF_BD_ADDR_SIZE); + device_vol.a2dp_vol = NVRAM_ENV_STREAM_VOLUME_A2DP_VOL_DEFAULT; + device_vol.hfp_vol = NVRAM_ENV_STREAM_VOLUME_HFP_VOL_DEFAULT; + device_plf.hfp_act = false; + device_plf.hsp_act = false; + device_plf.a2dp_act = false; + device_plf.a2dp_codectype = 0; + if (NULL == param_rec) + return BT_STS_FAILED; + memcpy(key, param_rec->bdAddr.address, BTIF_BD_ADDR_SIZE); - getint = nvrec_config_get_int(nv_record_config.config,section_name_ddbrec,(char *)key,0); - if(getint){ - ddbrec_exist = true; - nvrec_pool_record = (nvrec_btdevicerecord *)getint; - device_vol.a2dp_vol = nvrec_pool_record->device_vol.a2dp_vol; - device_vol.hfp_vol = nvrec_pool_record->device_vol.hfp_vol; - device_plf.hfp_act = nvrec_pool_record->device_plf.hfp_act; - device_plf.hsp_act = nvrec_pool_record->device_plf.hsp_act; - device_plf.a2dp_act = nvrec_pool_record->device_plf.a2dp_act; - device_plf.a2dp_codectype = nvrec_pool_record->device_plf.a2dp_codectype; + getint = nvrec_config_get_int(nv_record_config.config, section_name_ddbrec, + (char *)key, 0); + if (getint) { + ddbrec_exist = true; + nvrec_pool_record = (nvrec_btdevicerecord *)getint; + device_vol.a2dp_vol = nvrec_pool_record->device_vol.a2dp_vol; + device_vol.hfp_vol = nvrec_pool_record->device_vol.hfp_vol; + device_plf.hfp_act = nvrec_pool_record->device_plf.hfp_act; + device_plf.hsp_act = nvrec_pool_record->device_plf.hsp_act; + device_plf.a2dp_act = nvrec_pool_record->device_plf.a2dp_act; + device_plf.a2dp_codectype = nvrec_pool_record->device_plf.a2dp_codectype; #ifdef BTIF_DIP_DEVICE - vend_id = nvrec_pool_record->vend_id; - vend_id_source = nvrec_pool_record->vend_id_source; + vend_id = nvrec_pool_record->vend_id; + vend_id_source = nvrec_pool_record->vend_id_source; #endif - if( memcmp(&nvrec_pool_record->record.bdAddr, ¶m_rec->bdAddr,sizeof(nvrec_pool_record->record.bdAddr)) == 0 - && memcmp(nvrec_pool_record->record.linkKey, param_rec->linkKey,sizeof(nvrec_pool_record->record.linkKey)) == 0 - && nvrec_pool_record->record.trusted == param_rec->trusted - && nvrec_pool_record->record.pinLen == param_rec->pinLen - && nvrec_pool_record->record.keyType == param_rec->keyType - && config_entries_ddbdev_is_tail(param_rec) - ){ - is_flush = false; - } + if (memcmp(&nvrec_pool_record->record.bdAddr, ¶m_rec->bdAddr, + sizeof(nvrec_pool_record->record.bdAddr)) == 0 && + memcmp(nvrec_pool_record->record.linkKey, param_rec->linkKey, + sizeof(nvrec_pool_record->record.linkKey)) == 0 && + nvrec_pool_record->record.trusted == param_rec->trusted && + nvrec_pool_record->record.pinLen == param_rec->pinLen && + nvrec_pool_record->record.keyType == param_rec->keyType && + config_entries_ddbdev_is_tail(param_rec)) { + is_flush = false; } - if(is_flush){ - if (pool_free_space() < sizeof(nvrec_btdevicerecord)) - { - nvrec_trace(1,"%s,free space of nvrec is not enough!",nvrecord_tag); - config_entries_ddbdev_delete_head(); - } - nvrec_pool_record = (nvrec_btdevicerecord *)pool_malloc(sizeof(nvrec_btdevicerecord)); - if(NULL == nvrec_pool_record){ - nvrec_trace(1,"%s,pool_malloc failure.",nvrecord_tag); - return BT_STS_FAILED; - } - nvrec_trace(2,"%s,pool_malloc addr = 0x%x\n",nvrecord_tag,(unsigned int)nvrec_pool_record); - memcpy(nvrec_pool_record,param_rec,sizeof(btif_device_record_t)); + } + if (is_flush) { + if (pool_free_space() < sizeof(nvrec_btdevicerecord)) { + nvrec_trace(1, "%s,free space of nvrec is not enough!", nvrecord_tag); + config_entries_ddbdev_delete_head(); + } + nvrec_pool_record = + (nvrec_btdevicerecord *)pool_malloc(sizeof(nvrec_btdevicerecord)); + if (NULL == nvrec_pool_record) { + nvrec_trace(1, "%s,pool_malloc failure.", nvrecord_tag); + return BT_STS_FAILED; + } + nvrec_trace(2, "%s,pool_malloc addr = 0x%x\n", nvrecord_tag, + (unsigned int)nvrec_pool_record); + memcpy(nvrec_pool_record, param_rec, sizeof(btif_device_record_t)); #ifdef LINK_KEY_ENCRYPT - U8 linkKey[16]; - AES128_ECB_encrypt(param_rec->linkKey, LINK_KEY_ENCRYPT_KEY, linkKey); - memcpy(nvrec_pool_record->record.linkKey, linkKey, 16); + U8 linkKey[16]; + AES128_ECB_encrypt(param_rec->linkKey, LINK_KEY_ENCRYPT_KEY, linkKey); + memcpy(nvrec_pool_record->record.linkKey, linkKey, 16); #endif - memcpy(key,param_rec->bdAddr.address,BTIF_BD_ADDR_SIZE); + memcpy(key, param_rec->bdAddr.address, BTIF_BD_ADDR_SIZE); - nvrec_pool_record->device_vol.a2dp_vol = device_vol.a2dp_vol; - nvrec_pool_record->device_vol.hfp_vol = device_vol.hfp_vol; - nvrec_pool_record->device_plf.hfp_act = device_plf.hfp_act; - nvrec_pool_record->device_plf.hsp_act = device_plf.hsp_act; - nvrec_pool_record->device_plf.a2dp_act = device_plf.a2dp_act; - nvrec_pool_record->device_plf.a2dp_codectype = device_plf.a2dp_codectype; + nvrec_pool_record->device_vol.a2dp_vol = device_vol.a2dp_vol; + nvrec_pool_record->device_vol.hfp_vol = device_vol.hfp_vol; + nvrec_pool_record->device_plf.hfp_act = device_plf.hfp_act; + nvrec_pool_record->device_plf.hsp_act = device_plf.hsp_act; + nvrec_pool_record->device_plf.a2dp_act = device_plf.a2dp_act; + nvrec_pool_record->device_plf.a2dp_codectype = device_plf.a2dp_codectype; #ifdef BTIF_DIP_DEVICE - nvrec_pool_record->vend_id = vend_id; - nvrec_pool_record->vend_id_source = vend_id_source; + nvrec_pool_record->vend_id = vend_id; + nvrec_pool_record->vend_id_source = vend_id_source; #endif - if (ddbrec_exist){ - config_specific_entry_value_delete(param_rec); - } - if(DDB_RECORD_NUM == config_entries_get_ddbrec_length(section_name_ddbrec)) { - nvrec_trace(1,"%s,ddbrec list is full,delete the oldest and add param_rec to list.",nvrecord_tag); - config_entries_ddbdev_delete_head(); - } - nvrec_config_set_int(nv_record_config.config,section_name_ddbrec,(char *)key,(int)nvrec_pool_record); + if (ddbrec_exist) { + config_specific_entry_value_delete(param_rec); + } + if (DDB_RECORD_NUM == + config_entries_get_ddbrec_length(section_name_ddbrec)) { + nvrec_trace( + 1, + "%s,ddbrec list is full,delete the oldest and add param_rec to list.", + nvrecord_tag); + config_entries_ddbdev_delete_head(); + } + nvrec_config_set_int(nv_record_config.config, section_name_ddbrec, + (char *)key, (int)nvrec_pool_record); #ifdef nv_record_debug - getint = nvrec_config_get_int(nv_record_config.config,section_name_ddbrec,(char *)key,0); - nvrec_trace(2,"%s,get pool_malloc addr = 0x%x\n",nvrecord_tag,(unsigned int)getint); + getint = nvrec_config_get_int(nv_record_config.config, section_name_ddbrec, + (char *)key, 0); + nvrec_trace(2, "%s,get pool_malloc addr = 0x%x\n", nvrecord_tag, + (unsigned int)getint); #endif - nv_record_update_runtime_userdata(); - } - return BT_STS_SUCCESS; + nv_record_update_runtime_userdata(); + } + return BT_STS_SUCCESS; } /* this function should be surrounded by OS_LockStack and OS_UnlockStack when call. */ -bt_status_t nv_record_add(SECTIONS_ADP_ENUM type,void *record) -{ - bt_status_t retstatus = BT_STS_FAILED; +bt_status_t nv_record_add(SECTIONS_ADP_ENUM type, void *record) { + bt_status_t retstatus = BT_STS_FAILED; - if ((NULL == record) || (section_none == type)) - return BT_STS_FAILED; - switch(type) - { - case section_usrdata_ddbrecord: - retstatus = nv_record_ddbrec_add(record); - break; - default: - break; - } + if ((NULL == record) || (section_none == type)) + return BT_STS_FAILED; + switch (type) { + case section_usrdata_ddbrecord: + retstatus = nv_record_ddbrec_add(record); + break; + default: + break; + } - return retstatus; + return retstatus; } /* this function should be surrounded by OS_LockStack and OS_UnlockStack when call. */ -bt_status_t nv_record_ddbrec_find(const bt_bdaddr_t* bd_ddr,btif_device_record_t *record) -{ - unsigned int getint = 0; - char key[BTIF_BD_ADDR_SIZE+1] = {0,}; - btif_device_record_t *getrecaddr = NULL; +bt_status_t nv_record_ddbrec_find(const bt_bdaddr_t *bd_ddr, + btif_device_record_t *record) { + unsigned int getint = 0; + char key[BTIF_BD_ADDR_SIZE + 1] = { + 0, + }; + btif_device_record_t *getrecaddr = NULL; - if((NULL == nv_record_config.config) || (NULL == bd_ddr) || (NULL == record)) - return BT_STS_FAILED; - memcpy(key,bd_ddr->address,BTIF_BD_ADDR_SIZE); - getint = nvrec_config_get_int(nv_record_config.config,section_name_ddbrec,(char *)key,0); - if(0 == getint) - return BT_STS_FAILED; - getrecaddr = (btif_device_record_t *)getint; - memcpy(record,(void *)getrecaddr,sizeof(btif_device_record_t)); + if ((NULL == nv_record_config.config) || (NULL == bd_ddr) || (NULL == record)) + return BT_STS_FAILED; + memcpy(key, bd_ddr->address, BTIF_BD_ADDR_SIZE); + getint = nvrec_config_get_int(nv_record_config.config, section_name_ddbrec, + (char *)key, 0); + if (0 == getint) + return BT_STS_FAILED; + getrecaddr = (btif_device_record_t *)getint; + memcpy(record, (void *)getrecaddr, sizeof(btif_device_record_t)); #ifdef LINK_KEY_ENCRYPT - U8 linkKey[16]; - AES128_ECB_decrypt(getrecaddr->linkKey, LINK_KEY_ENCRYPT_KEY, linkKey); - memcpy(record->linkKey, linkKey, 16); + U8 linkKey[16]; + AES128_ECB_decrypt(getrecaddr->linkKey, LINK_KEY_ENCRYPT_KEY, linkKey); + memcpy(record->linkKey, linkKey, 16); #endif - return BT_STS_SUCCESS; + return BT_STS_SUCCESS; } -int nv_record_btdevicerecord_find(const bt_bdaddr_t *bd_ddr, nvrec_btdevicerecord **record) -{ - unsigned int getint = 0; - char key[BTIF_BD_ADDR_SIZE+1] = {0,}; +int nv_record_btdevicerecord_find(const bt_bdaddr_t *bd_ddr, + nvrec_btdevicerecord **record) { + unsigned int getint = 0; + char key[BTIF_BD_ADDR_SIZE + 1] = { + 0, + }; - if((NULL == nv_record_config.config) || (NULL == bd_ddr) || (NULL == record)) - return -1; - memcpy(key,bd_ddr->address, BTIF_BD_ADDR_SIZE); - getint = nvrec_config_get_int(nv_record_config.config,section_name_ddbrec,(char *)key,0); - if(0 == getint) - return -1; - *record = (nvrec_btdevicerecord *)getint; - return 0; + if ((NULL == nv_record_config.config) || (NULL == bd_ddr) || (NULL == record)) + return -1; + memcpy(key, bd_ddr->address, BTIF_BD_ADDR_SIZE); + getint = nvrec_config_get_int(nv_record_config.config, section_name_ddbrec, + (char *)key, 0); + if (0 == getint) + return -1; + *record = (nvrec_btdevicerecord *)getint; + return 0; } -void nv_record_btdevicerecord_set_a2dp_vol(nvrec_btdevicerecord* pRecord, int8_t vol) -{ - pRecord->device_vol.a2dp_vol = vol; +void nv_record_btdevicerecord_set_a2dp_vol(nvrec_btdevicerecord *pRecord, + int8_t vol) { + pRecord->device_vol.a2dp_vol = vol; } -void nv_record_btdevicerecord_set_hfp_vol(nvrec_btdevicerecord* pRecord, int8_t vol) -{ - pRecord->device_vol.hfp_vol = vol; +void nv_record_btdevicerecord_set_hfp_vol(nvrec_btdevicerecord *pRecord, + int8_t vol) { + pRecord->device_vol.hfp_vol = vol; } -void nv_record_btdevicevolume_set_a2dp_vol(btdevice_volume* device_vol, int8_t vol) -{ - device_vol->a2dp_vol = vol; +void nv_record_btdevicevolume_set_a2dp_vol(btdevice_volume *device_vol, + int8_t vol) { + device_vol->a2dp_vol = vol; } -void nv_record_btdevicevolume_set_hfp_vol(btdevice_volume* device_vol, int8_t vol) -{ - device_vol->hfp_vol = vol; +void nv_record_btdevicevolume_set_hfp_vol(btdevice_volume *device_vol, + int8_t vol) { + device_vol->hfp_vol = vol; } -void nv_record_btdevicerecord_set_vend_id_and_source(nvrec_btdevicerecord* pRecord, int16_t vend_id, int16_t vend_id_source) -{ +void nv_record_btdevicerecord_set_vend_id_and_source( + nvrec_btdevicerecord *pRecord, int16_t vend_id, int16_t vend_id_source) { #ifdef BTIF_DIP_DEVICE - if (vend_id != pRecord->vend_id) - { - pRecord->vend_id = vend_id; - pRecord->vend_id_source = vend_id_source; - } + if (vend_id != pRecord->vend_id) { + pRecord->vend_id = vend_id; + pRecord->vend_id_source = vend_id_source; + } #endif } -void nv_record_btdevicerecord_set_a2dp_profile_active_state(btdevice_profile* device_plf, bool isActive) -{ - device_plf->a2dp_act = isActive; +void nv_record_btdevicerecord_set_a2dp_profile_active_state( + btdevice_profile *device_plf, bool isActive) { + device_plf->a2dp_act = isActive; } -void nv_record_btdevicerecord_set_hfp_profile_active_state(btdevice_profile* device_plf, bool isActive) -{ - device_plf->hfp_act = isActive; +void nv_record_btdevicerecord_set_hfp_profile_active_state( + btdevice_profile *device_plf, bool isActive) { + device_plf->hfp_act = isActive; } -void nv_record_btdevicerecord_set_hsp_profile_active_state(btdevice_profile* device_plf, bool isActive) -{ - device_plf->hsp_act = isActive; +void nv_record_btdevicerecord_set_hsp_profile_active_state( + btdevice_profile *device_plf, bool isActive) { + device_plf->hsp_act = isActive; } -void nv_record_btdevicerecord_set_a2dp_profile_codec(btdevice_profile* device_plf, uint8_t a2dpCodec) -{ - device_plf->a2dp_codectype = a2dpCodec; +void nv_record_btdevicerecord_set_a2dp_profile_codec( + btdevice_profile *device_plf, uint8_t a2dpCodec) { + device_plf->a2dp_codectype = a2dpCodec; } -uint32_t nv_record_pre_write_operation(void) -{ - return 0; -} +uint32_t nv_record_pre_write_operation(void) { return 0; } -void nv_record_post_write_operation(uint32_t lock) -{ +void nv_record_post_write_operation(uint32_t lock) {} +/* +this function should be surrounded by OS_LockStack and OS_UnlockStack when call. +*/ +bt_status_t nv_record_ddbrec_delete(const bt_bdaddr_t *bdaddr) { + unsigned int getint = 0; + btif_device_record_t *getrecaddr = NULL; + char key[BTIF_BD_ADDR_SIZE + 1] = { + 0, + }; + + memcpy(key, bdaddr->address, BTIF_BD_ADDR_SIZE); + getint = nvrec_config_get_int(nv_record_config.config, section_name_ddbrec, + (char *)key, 0); + if (0 == getint) + return BT_STS_FAILED; + // found ddb record,del it and return succeed. + getrecaddr = (btif_device_record_t *)getint; + config_specific_entry_value_delete((const btif_device_record_t *)getrecaddr); + return BT_STS_SUCCESS; } /* this function should be surrounded by OS_LockStack and OS_UnlockStack when call. */ -bt_status_t nv_record_ddbrec_delete(const bt_bdaddr_t *bdaddr) -{ - unsigned int getint = 0; - btif_device_record_t *getrecaddr = NULL; - char key[BTIF_BD_ADDR_SIZE+1] = {0,}; +bt_status_t nv_record_enum_dev_records(unsigned short index, + btif_device_record_t *record) { + nvrec_section_t *sec = NULL; + list_node_t *node = NULL; + unsigned short pos = 0; + nvrec_entry_t *entry_temp = NULL; + btif_device_record_t *recaddr = NULL; + unsigned int addr = 0; - memcpy(key,bdaddr->address,BTIF_BD_ADDR_SIZE); - getint = nvrec_config_get_int(nv_record_config.config,section_name_ddbrec,(char *)key,0); - if(0 == getint) - return BT_STS_FAILED; - //found ddb record,del it and return succeed. - getrecaddr = (btif_device_record_t *)getint; - config_specific_entry_value_delete((const btif_device_record_t *)getrecaddr); - return BT_STS_SUCCESS; -} + if ((index >= DDB_RECORD_NUM) || (NULL == record) || + (NULL == nv_record_config.config)) + return BT_STS_FAILED; + sec = nvrec_section_find(nv_record_config.config, section_name_ddbrec); + if (NULL == sec) + return BT_STS_INVALID_PARM; + if (NULL == sec->entries) + return BT_STS_INVALID_PARM; + if (0 == sec->entries->length) + return BT_STS_FAILED; + if (index >= sec->entries->length) + return BT_STS_FAILED; + node = list_begin_ext(sec->entries); -/* -this function should be surrounded by OS_LockStack and OS_UnlockStack when call. -*/ -bt_status_t nv_record_enum_dev_records(unsigned short index,btif_device_record_t* record) -{ - nvrec_section_t *sec = NULL; - list_node_t *node = NULL; - unsigned short pos = 0; - nvrec_entry_t *entry_temp = NULL; - btif_device_record_t *recaddr = NULL; - unsigned int addr = 0; - - if((index >= DDB_RECORD_NUM) || (NULL == record) || (NULL == nv_record_config.config)) - return BT_STS_FAILED; - sec = nvrec_section_find(nv_record_config.config,section_name_ddbrec); - if(NULL == sec) - return BT_STS_INVALID_PARM; - if(NULL == sec->entries) - return BT_STS_INVALID_PARM; - if(0 == sec->entries->length) - return BT_STS_FAILED; - if(index >= sec->entries->length) - return BT_STS_FAILED; - node = list_begin_ext(sec->entries); - - while(pos < index) - { - node = list_next_ext(node); - pos++; - } - entry_temp = list_node_ext(node); - addr = nvrec_config_get_int(nv_record_config.config,section_name_ddbrec,(char *)entry_temp->key,0); - if(0 == addr) - return BT_STS_FAILED; - recaddr = (btif_device_record_t *)addr; - memcpy(record,recaddr,sizeof(btif_device_record_t)); + while (pos < index) { + node = list_next_ext(node); + pos++; + } + entry_temp = list_node_ext(node); + addr = nvrec_config_get_int(nv_record_config.config, section_name_ddbrec, + (char *)entry_temp->key, 0); + if (0 == addr) + return BT_STS_FAILED; + recaddr = (btif_device_record_t *)addr; + memcpy(record, recaddr, sizeof(btif_device_record_t)); #ifdef LINK_KEY_ENCRYPT - U8 linkKey[16]; - AES128_ECB_decrypt(recaddr->linkKey, LINK_KEY_ENCRYPT_KEY, linkKey); - memcpy(record->linkKey, linkKey, 16); + U8 linkKey[16]; + AES128_ECB_decrypt(recaddr->linkKey, LINK_KEY_ENCRYPT_KEY, linkKey); + memcpy(record->linkKey, linkKey, 16); #endif - nv_record_print_dev_record(record); - return BT_STS_SUCCESS; + nv_record_print_dev_record(record); + return BT_STS_SUCCESS; } /* @@ -860,331 +840,295 @@ return: 1: only 1 paired dev,store@record1. 2: get 2 paired dev.notice:record1 is the latest record. */ -int nv_record_enum_latest_two_paired_dev(btif_device_record_t* record1,btif_device_record_t* record2) -{ - bt_status_t getret1 = BT_STS_FAILED; - bt_status_t getret2 = BT_STS_FAILED; - nvrec_section_t *sec = NULL; - size_t entries_len = 0; - list_t *entry = NULL; +int nv_record_enum_latest_two_paired_dev(btif_device_record_t *record1, + btif_device_record_t *record2) { + bt_status_t getret1 = BT_STS_FAILED; + bt_status_t getret2 = BT_STS_FAILED; + nvrec_section_t *sec = NULL; + size_t entries_len = 0; + list_t *entry = NULL; - if((NULL == record1) || (NULL == record2)) - return -1; - sec = nvrec_section_find(nv_record_config.config,section_name_ddbrec); - if(NULL == sec) - return 0; - entry = sec->entries; - if(NULL == entry) - return 0; - entries_len = entry->length; - if(0 == entries_len) - return 0; - else if(entries_len < 0) - return -1; - if(1 == entries_len) - { - getret1 = nv_record_enum_dev_records(0,record1); - if(BT_STS_SUCCESS == getret1) - return 1; - return -1; - } + if ((NULL == record1) || (NULL == record2)) + return -1; + sec = nvrec_section_find(nv_record_config.config, section_name_ddbrec); + if (NULL == sec) + return 0; + entry = sec->entries; + if (NULL == entry) + return 0; + entries_len = entry->length; + if (0 == entries_len) + return 0; + else if (entries_len < 0) + return -1; + if (1 == entries_len) { + getret1 = nv_record_enum_dev_records(0, record1); + if (BT_STS_SUCCESS == getret1) + return 1; + return -1; + } - getret1 = nv_record_enum_dev_records(entries_len-1,record1); - getret2 = nv_record_enum_dev_records(entries_len-2,record2); - if((BT_STS_SUCCESS != getret1) || (BT_STS_SUCCESS != getret2)) - { - memset(record1,0x0,sizeof(btif_device_record_t)); - memset(record2,0x0,sizeof(btif_device_record_t)); - return -1; - } - return 2; + getret1 = nv_record_enum_dev_records(entries_len - 1, record1); + getret2 = nv_record_enum_dev_records(entries_len - 2, record2); + if ((BT_STS_SUCCESS != getret1) || (BT_STS_SUCCESS != getret2)) { + memset(record1, 0x0, sizeof(btif_device_record_t)); + memset(record2, 0x0, sizeof(btif_device_record_t)); + return -1; + } + return 2; } -int nv_record_touch_cause_flush(void) -{ - nv_record_update_runtime_userdata(); - return 0; +int nv_record_touch_cause_flush(void) { + nv_record_update_runtime_userdata(); + return 0; } -void nv_record_all_ddbrec_print(void) -{ - list_t *entry = NULL; - int tmp_i = 0; - nvrec_section_t *sec = NULL; - size_t entries_len = 0; +void nv_record_all_ddbrec_print(void) { + list_t *entry = NULL; + int tmp_i = 0; + nvrec_section_t *sec = NULL; + size_t entries_len = 0; - sec = nvrec_section_find(nv_record_config.config,section_name_ddbrec); - if(NULL == sec) - return; - entry = sec->entries; - if(NULL == entry) - return; - entries_len = entry->length; - if(0 == entries_len) - { - nvrec_trace(1,"%s: without btdevicerec.",__func__); - return; - } - for(tmp_i=0;tmp_ientries; + if (NULL == entry) + return; + entries_len = entry->length; + if (0 == entries_len) { + nvrec_trace(1, "%s: without btdevicerec.", __func__); + return; + } + for (tmp_i = 0; tmp_i < entries_len; tmp_i++) { + btif_device_record_t record; + bt_status_t ret_status; + ret_status = nv_record_enum_dev_records(tmp_i, &record); + if (BT_STS_SUCCESS == ret_status) + nv_record_print_dev_record(&record); + } } -int nv_record_get_paired_dev_count(void) -{ - nvrec_section_t *sec = NULL; - list_t *entry = NULL; +int nv_record_get_paired_dev_count(void) { + nvrec_section_t *sec = NULL; + list_t *entry = NULL; - sec = nvrec_section_find(nv_record_config.config,section_name_ddbrec); - if(NULL == sec) - return 0; - entry = sec->entries; - if(NULL == entry) - return 0; + sec = nvrec_section_find(nv_record_config.config, section_name_ddbrec); + if (NULL == sec) + return 0; + entry = sec->entries; + if (NULL == entry) + return 0; - return entry->length; + return entry->length; } +void nv_record_sector_clear(void) { + uint32_t lock; + enum NORFLASH_API_RET_T ret, ret1; -void nv_record_sector_clear(void) -{ - uint32_t lock; - enum NORFLASH_API_RET_T ret,ret1; - - lock = int_lock_global(); - ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA, - (uint32_t)__userdata_start, - sizeof(usrdata_ddblist_pool), - false); - ret1 = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA, - (uint32_t)__userdata_start + nvrecord_mem_pool_size, - sizeof(usrdata_ddblist_pool), - false); - nvrec_init = false; - nvrec_mempool_init = false; - int_unlock_global(lock); - ASSERT(ret == NORFLASH_API_OK,"nv_record_sector_clear: erase main sector failed! ret = %d.",ret); - ASSERT(ret1 == NORFLASH_API_OK,"nv_record_sector_clear: erase bak sector failed! ret1 = %d.",ret1); + lock = int_lock_global(); + ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA, + (uint32_t)__userdata_start, + sizeof(usrdata_ddblist_pool), false); + ret1 = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA, + (uint32_t)__userdata_start + nvrecord_mem_pool_size, + sizeof(usrdata_ddblist_pool), false); + nvrec_init = false; + nvrec_mempool_init = false; + int_unlock_global(lock); + ASSERT(ret == NORFLASH_API_OK, + "nv_record_sector_clear: erase main sector failed! ret = %d.", ret); + ASSERT(ret1 == NORFLASH_API_OK, + "nv_record_sector_clear: erase bak sector failed! ret1 = %d.", ret1); } -#define DISABLE_NV_RECORD_CRC_CHECK_BEFORE_FLUSH 1 -void nv_record_update_runtime_userdata(void) -{ - uint32_t lock; +#define DISABLE_NV_RECORD_CRC_CHECK_BEFORE_FLUSH 1 +void nv_record_update_runtime_userdata(void) { + uint32_t lock; - if (NULL == nv_record_config.config) - { - return; - } - lock = int_lock(); - nv_record_config.is_update = true; + if (NULL == nv_record_config.config) { + return; + } + lock = int_lock(); + nv_record_config.is_update = true; #if !DISABLE_NV_RECORD_CRC_CHECK_BEFORE_FLUSH - buffer_alloc_ctx* heapctx = memory_buffer_heap_getaddr(); - memcpy((void *)(&usrdata_ddblist_pool[pos_heap_contents]),heapctx,sizeof(buffer_alloc_ctx)); - uint32_t crc = crc32(0,(uint8_t *)(&usrdata_ddblist_pool[pos_heap_contents]),(sizeof(usrdata_ddblist_pool)-(pos_heap_contents*sizeof(uint32_t)))); + buffer_alloc_ctx *heapctx = memory_buffer_heap_getaddr(); + memcpy((void *)(&usrdata_ddblist_pool[pos_heap_contents]), heapctx, + sizeof(buffer_alloc_ctx)); + uint32_t crc = crc32( + 0, (uint8_t *)(&usrdata_ddblist_pool[pos_heap_contents]), + (sizeof(usrdata_ddblist_pool) - (pos_heap_contents * sizeof(uint32_t)))); - usrdata_ddblist_pool[pos_crc] = crc; + usrdata_ddblist_pool[pos_crc] = crc; #endif - int_unlock(lock); + int_unlock(lock); } +static int nv_record_flash_flush_main(bool is_async) { + uint32_t crc; + uint32_t lock; + enum NORFLASH_API_RET_T ret = NORFLASH_API_OK; + uint8_t *burn_buf = NULL; + uint32_t verandmagic; -static int nv_record_flash_flush_main(bool is_async) -{ - uint32_t crc; - uint32_t lock; - enum NORFLASH_API_RET_T ret = NORFLASH_API_OK; - uint8_t *burn_buf = NULL; - uint32_t verandmagic; + if (NULL == nv_record_config.config) { + nvrec_trace(1, "%s,nv_record_config.config is null.\n", __func__); + goto _func_end; + } - if(NULL == nv_record_config.config) - { - nvrec_trace(1,"%s,nv_record_config.config is null.\n", __func__); - goto _func_end; + burn_buf = (uint8_t *)&usrdata_ddblist_pool[0]; + verandmagic = usrdata_ddblist_pool[0]; + ASSERT((((nvrecord_struct_version << 16) | nvrecord_magic) == verandmagic), + "%s: verandmagic = 0x%08x.", __func__, verandmagic); + + if (is_async) { + hal_trace_pause(); + lock = int_lock_global(); + if (nv_record_config.state == NV_STATE_IDLE || + nv_record_config.state == NV_STATE_MAIN_ERASING) { + if (nv_record_config.state == NV_STATE_IDLE) { + nv_record_config.state = NV_STATE_MAIN_ERASING; + // nvrec_trace(1,"%s: NV_STATE_MAIN_ERASING", __func__); + } + + ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA, + _user_data_main_start, + sizeof(usrdata_ddblist_pool), true); + if (ret == NORFLASH_API_OK) { + nv_record_config.state = NV_STATE_MAIN_ERASED; + // nvrec_trace(1,"%s: NV_STATE_MAIN_ERASED", __func__); + nvrec_trace(2, "%s: norflash_api_erase ok,addr = 0x%x.", __func__, + _user_data_main_start); + } else if (ret == NORFLASH_API_BUFFER_FULL) { + norflash_api_flush(); + } else { + ASSERT(0, "%s: norflash_api_erase err,ret = %d,addr = 0x%x.", __func__, + ret, _user_data_main_start); + } + } else if (nv_record_config.state == NV_STATE_MAIN_ERASED || + nv_record_config.state == NV_STATE_MAIN_WRITTING) { + if (nv_record_config.state == NV_STATE_MAIN_ERASED) { + nv_record_config.state = NV_STATE_MAIN_WRITTING; + // nvrec_trace(1,"%s: NV_STATE_MAIN_WRITTING", __func__); + } + crc = crc32(0, (uint8_t *)(&usrdata_ddblist_pool[pos_heap_contents]), + (sizeof(usrdata_ddblist_pool) - + (pos_heap_contents * sizeof(uint32_t)))); + // nvrec_trace(2,"%s,crc=%x.\n",nvrecord_tag,crc); + usrdata_ddblist_pool[pos_version_and_magic] = + ((nvrecord_struct_version << 16) | nvrecord_magic); + usrdata_ddblist_pool[pos_crc] = crc; + usrdata_ddblist_pool[pos_start_ram_addr] = + (uint32_t)&usrdata_ddblist_pool; + usrdata_ddblist_pool[pos_reserv2] = 0; + usrdata_ddblist_pool[pos_config_addr] = (uint32_t)nv_record_config.config; + ASSERT(nv_record_list_is_valid(), "%s nv_record_list is invalid!", + __func__); + ret = norflash_api_write(NORFLASH_API_MODULE_ID_USERDATA, + _user_data_main_start, burn_buf, + sizeof(usrdata_ddblist_pool), true); + if (ret == NORFLASH_API_OK) { + nv_record_config.is_update = false; + nv_record_config.state = NV_STATE_MAIN_WRITTEN; + // nvrec_trace(1,"%s: NV_STATE_MAIN_WRITTEN", __func__); + nvrec_trace(2, "%s: norflash_api_write ok,addr = 0x%x.", __func__, + _user_data_main_start); + } else if (ret == NORFLASH_API_BUFFER_FULL) { + norflash_api_flush(); + } else { + ASSERT(0, "%s: norflash_api_write err,ret = %d,addr = 0x%x.", __func__, + ret, _user_data_main_start); + } + } else { + if (norflash_api_get_used_buffer_count(NORFLASH_API_MODULE_ID_USERDATA, + NORFLASH_API_ALL) == 0) { + nv_record_config.state = NV_STATE_MAIN_DONE; + // nvrec_trace(1,"%s: NV_STATE_MAIN_DONE", __func__); + } else { + norflash_api_flush(); + } } - - burn_buf = (uint8_t *)&usrdata_ddblist_pool[0]; - verandmagic = usrdata_ddblist_pool[0]; - ASSERT((((nvrecord_struct_version<<16)|nvrecord_magic) == verandmagic), - "%s: verandmagic = 0x%08x.", __func__, verandmagic); - - if(is_async) - { + int_unlock_global(lock); + hal_trace_continue(); + } else { + // nvrec_trace(1,"%s: sync flush begin!", __func__); + if (nv_record_config.state == NV_STATE_IDLE || + nv_record_config.state == NV_STATE_MAIN_ERASING) { + do { hal_trace_pause(); lock = int_lock_global(); - if(nv_record_config.state == NV_STATE_IDLE - || nv_record_config.state == NV_STATE_MAIN_ERASING) - { - if(nv_record_config.state == NV_STATE_IDLE) - { - nv_record_config.state = NV_STATE_MAIN_ERASING; - // nvrec_trace(1,"%s: NV_STATE_MAIN_ERASING", __func__); - } - - ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA, - _user_data_main_start, - sizeof(usrdata_ddblist_pool), - true); - if(ret == NORFLASH_API_OK) - { - nv_record_config.state = NV_STATE_MAIN_ERASED; - // nvrec_trace(1,"%s: NV_STATE_MAIN_ERASED", __func__); - nvrec_trace(2,"%s: norflash_api_erase ok,addr = 0x%x.",__func__,_user_data_main_start); - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - norflash_api_flush(); - } - else - { - ASSERT(0,"%s: norflash_api_erase err,ret = %d,addr = 0x%x.",__func__,ret,_user_data_main_start); - } - } - else if(nv_record_config.state == NV_STATE_MAIN_ERASED - || nv_record_config.state == NV_STATE_MAIN_WRITTING) - { - if(nv_record_config.state == NV_STATE_MAIN_ERASED) - { - nv_record_config.state = NV_STATE_MAIN_WRITTING; - // nvrec_trace(1,"%s: NV_STATE_MAIN_WRITTING", __func__); - } - crc = crc32(0,(uint8_t *)(&usrdata_ddblist_pool[pos_heap_contents]),(sizeof(usrdata_ddblist_pool)-(pos_heap_contents*sizeof(uint32_t)))); - //nvrec_trace(2,"%s,crc=%x.\n",nvrecord_tag,crc); - usrdata_ddblist_pool[pos_version_and_magic] = ((nvrecord_struct_version<<16)|nvrecord_magic); - usrdata_ddblist_pool[pos_crc] = crc; - usrdata_ddblist_pool[pos_start_ram_addr] = (uint32_t)&usrdata_ddblist_pool; - usrdata_ddblist_pool[pos_reserv2] = 0; - usrdata_ddblist_pool[pos_config_addr] = (uint32_t)nv_record_config.config; - ASSERT(nv_record_list_is_valid(),"%s nv_record_list is invalid!",__func__); - ret = norflash_api_write(NORFLASH_API_MODULE_ID_USERDATA, - _user_data_main_start, - burn_buf, - sizeof(usrdata_ddblist_pool), - true - ); - if(ret == NORFLASH_API_OK) - { - nv_record_config.is_update = false; - nv_record_config.state = NV_STATE_MAIN_WRITTEN; - // nvrec_trace(1,"%s: NV_STATE_MAIN_WRITTEN", __func__); - nvrec_trace(2,"%s: norflash_api_write ok,addr = 0x%x.",__func__,_user_data_main_start); - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - norflash_api_flush(); - } - else - { - ASSERT(0,"%s: norflash_api_write err,ret = %d,addr = 0x%x.",__func__,ret,_user_data_main_start); - } - } - else - { - if(norflash_api_get_used_buffer_count(NORFLASH_API_MODULE_ID_USERDATA,NORFLASH_API_ALL) == 0) - { - nv_record_config.state = NV_STATE_MAIN_DONE; - // nvrec_trace(1,"%s: NV_STATE_MAIN_DONE", __func__); - } - else - { - norflash_api_flush(); - } - } + ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA, + _user_data_main_start, + sizeof(usrdata_ddblist_pool), true); int_unlock_global(lock); hal_trace_continue(); + if (ret == NORFLASH_API_OK) { + nv_record_config.state = NV_STATE_MAIN_ERASED; + nvrec_trace(2, "%s: norflash_api_erase ok,addr = 0x%x.", __func__, + _user_data_main_start); + } else if (ret == NORFLASH_API_BUFFER_FULL) { + do { + norflash_api_flush(); + } while (norflash_api_get_free_buffer_count(NORFLASH_API_ERASING) == + 0); + } else { + ASSERT(0, "%s: norflash_api_erase err,ret = %d,addr = 0x%x.", + __func__, ret, _user_data_main_start); + } + + } while (ret == NORFLASH_API_BUFFER_FULL); } - else - { - // nvrec_trace(1,"%s: sync flush begin!", __func__); - if(nv_record_config.state == NV_STATE_IDLE - || nv_record_config.state == NV_STATE_MAIN_ERASING) - { - do - { - hal_trace_pause(); - lock = int_lock_global(); - ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA, - _user_data_main_start, - sizeof(usrdata_ddblist_pool), - true); - int_unlock_global(lock); - hal_trace_continue(); - if(ret == NORFLASH_API_OK) - { - nv_record_config.state = NV_STATE_MAIN_ERASED; - nvrec_trace(2,"%s: norflash_api_erase ok,addr = 0x%x.",__func__, _user_data_main_start); - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - do - { - norflash_api_flush(); - }while(norflash_api_get_free_buffer_count(NORFLASH_API_ERASING) == 0); - } - else - { - ASSERT(0,"%s: norflash_api_erase err,ret = %d,addr = 0x%x.",__func__,ret,_user_data_main_start); - } - }while(ret == NORFLASH_API_BUFFER_FULL); + if (nv_record_config.state == NV_STATE_MAIN_ERASED) { + do { + hal_trace_pause(); + lock = int_lock_global(); + crc = crc32(0, (uint8_t *)(&usrdata_ddblist_pool[pos_heap_contents]), + (sizeof(usrdata_ddblist_pool) - + (pos_heap_contents * sizeof(uint32_t)))); + // nvrec_trace(2,"%s,crc=%x.\n",nvrecord_tag,crc); + usrdata_ddblist_pool[pos_version_and_magic] = + ((nvrecord_struct_version << 16) | nvrecord_magic); + usrdata_ddblist_pool[pos_crc] = crc; + usrdata_ddblist_pool[pos_start_ram_addr] = + (uint32_t)&usrdata_ddblist_pool; + usrdata_ddblist_pool[pos_reserv2] = 0; + usrdata_ddblist_pool[pos_config_addr] = + (uint32_t)nv_record_config.config; + ASSERT(nv_record_list_is_valid(), "%s nv_record_list is invalid!", + __func__); + ret = norflash_api_write(NORFLASH_API_MODULE_ID_USERDATA, + _user_data_main_start, burn_buf, + sizeof(usrdata_ddblist_pool), true); + int_unlock_global(lock); + hal_trace_continue(); + if (ret == NORFLASH_API_OK) { + nv_record_config.is_update = false; + nv_record_config.state = NV_STATE_MAIN_WRITTEN; + nvrec_trace(2, "%s: norflash_api_write ok,addr = 0x%x.", __func__, + _user_data_main_start); + } else if (ret == NORFLASH_API_BUFFER_FULL) { + do { + norflash_api_flush(); + } while (norflash_api_get_free_buffer_count(NORFLASH_API_WRITTING) == + 0); + } else { + ASSERT(0, "%s: norflash_api_write err,ret = %d,addr = 0x%x.", + __func__, ret, _user_data_main_start); } + } while (ret == NORFLASH_API_BUFFER_FULL); - if(nv_record_config.state == NV_STATE_MAIN_ERASED) - { - do - { - hal_trace_pause(); - lock = int_lock_global(); - crc = crc32(0,(uint8_t *)(&usrdata_ddblist_pool[pos_heap_contents]),(sizeof(usrdata_ddblist_pool)-(pos_heap_contents*sizeof(uint32_t)))); - //nvrec_trace(2,"%s,crc=%x.\n",nvrecord_tag,crc); - usrdata_ddblist_pool[pos_version_and_magic] = ((nvrecord_struct_version<<16)|nvrecord_magic); - usrdata_ddblist_pool[pos_crc] = crc; - usrdata_ddblist_pool[pos_start_ram_addr] = (uint32_t)&usrdata_ddblist_pool; - usrdata_ddblist_pool[pos_reserv2] = 0; - usrdata_ddblist_pool[pos_config_addr] = (uint32_t)nv_record_config.config; - ASSERT(nv_record_list_is_valid(),"%s nv_record_list is invalid!",__func__); - ret = norflash_api_write(NORFLASH_API_MODULE_ID_USERDATA, - _user_data_main_start, - burn_buf, - sizeof(usrdata_ddblist_pool), - true - ); - int_unlock_global(lock); - hal_trace_continue(); - if(ret == NORFLASH_API_OK) - { - nv_record_config.is_update = false; - nv_record_config.state = NV_STATE_MAIN_WRITTEN; - nvrec_trace(2,"%s: norflash_api_write ok,addr = 0x%x.",__func__,_user_data_main_start); - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - do - { - norflash_api_flush(); - }while(norflash_api_get_free_buffer_count(NORFLASH_API_WRITTING) == 0); - } - else - { - ASSERT(0,"%s: norflash_api_write err,ret = %d,addr = 0x%x.",__func__,ret,_user_data_main_start); - } - }while(ret == NORFLASH_API_BUFFER_FULL); + do { + norflash_api_flush(); + } while (norflash_api_get_used_buffer_count( + NORFLASH_API_MODULE_ID_USERDATA, NORFLASH_API_ALL) > 0); - do - { - norflash_api_flush(); - }while(norflash_api_get_used_buffer_count(NORFLASH_API_MODULE_ID_USERDATA,NORFLASH_API_ALL) > 0); - - nv_record_config.state = NV_STATE_MAIN_DONE; - nvrec_trace(1,"%s: sync flush done.", __func__); - } + nv_record_config.state = NV_STATE_MAIN_DONE; + nvrec_trace(1, "%s: sync flush done.", __func__); + } #if 0 //#ifdef nv_record_debug if (ret == NORFLASH_API_OK) { @@ -1202,389 +1146,333 @@ static int nv_record_flash_flush_main(bool is_async) TRACE(1,"%s crc ok.",__func__); } #endif - - } + } _func_end: - return (ret == NORFLASH_API_OK) ? 0:1; + return (ret == NORFLASH_API_OK) ? 0 : 1; } -static int nv_record_flash_flush_bak(bool is_async) -{ - uint32_t lock; - enum NORFLASH_API_RET_T ret = NORFLASH_API_OK; - uint8_t burn_buf[128]; +static int nv_record_flash_flush_bak(bool is_async) { + uint32_t lock; + enum NORFLASH_API_RET_T ret = NORFLASH_API_OK; + uint8_t burn_buf[128]; - if(is_async) - { + if (is_async) { + hal_trace_pause(); + lock = int_lock_global(); + if (nv_record_config.state == NV_STATE_MAIN_DONE || + nv_record_config.state == NV_STATE_BAK_ERASING) { + if (nv_record_config.state == NV_STATE_MAIN_DONE) { + nv_record_config.state = NV_STATE_BAK_ERASING; + // nvrec_trace(1,"%s: NV_STATE_BAK_ERASING", __func__); + } + ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA, + _user_data_bak_start, + sizeof(usrdata_ddblist_pool), true); + if (ret == NORFLASH_API_OK) { + nv_record_config.state = NV_STATE_BAK_ERASED; + nvrec_trace(2, "%s: norflash_api_erase ok,addr = 0x%x.", __func__, + _user_data_bak_start); + // nvrec_trace(1,"%s: NV_STATE_BAK_ERASED", __func__); + } else if (ret == NORFLASH_API_BUFFER_FULL) { + norflash_api_flush(); + } else { + ASSERT(0, "%s: norflash_api_erase err,ret = %d,addr = 0x%x.", __func__, + ret, _user_data_bak_start); + } + } else if (nv_record_config.state == NV_STATE_BAK_ERASED || + nv_record_config.state == NV_STATE_BAK_WRITTING) { + if (nv_record_config.state == NV_STATE_BAK_ERASED) { + nv_record_config.state = NV_STATE_BAK_WRITTING; + nv_record_config.written_size = 0; + // nvrec_trace(1,"%s: NV_STATE_BAK_WRITTING", __func__); + } + do { + ret = norflash_api_read(NORFLASH_API_MODULE_ID_USERDATA, + _user_data_main_start + + nv_record_config.written_size, + burn_buf, sizeof(burn_buf)); + ASSERT(ret == NORFLASH_API_OK, + "norflash_api_read failed! ret = %d, addr = 0x%x.", (int32_t)ret, + _user_data_main_start + nv_record_config.written_size); + + ret = norflash_api_write(NORFLASH_API_MODULE_ID_USERDATA, + _user_data_bak_start + + nv_record_config.written_size, + burn_buf, sizeof(burn_buf), true); + if (ret == NORFLASH_API_OK) { + nv_record_config.written_size += sizeof(burn_buf); + + if (nv_record_config.written_size == nvrecord_mem_pool_size) { + nv_record_config.state = NV_STATE_BAK_WRITTEN; + // nvrec_trace(1,"%s: NV_STATE_BAK_WRITTEN", __func__); + break; + } + } else if (ret == NORFLASH_API_BUFFER_FULL) { + norflash_api_flush(); + break; + } else { + ASSERT(0, "%s: norflash_api_write err,ret = %d,addr = 0x%x.", + __func__, ret, + _user_data_bak_start + nv_record_config.written_size); + } + } while (1); + } else { + if (norflash_api_get_used_buffer_count(NORFLASH_API_MODULE_ID_USERDATA, + NORFLASH_API_ALL) == 0) { + // nvrec_trace(1,"%s: NV_STATE_BAK_DONE", __func__); + nv_record_config.state = NV_STATE_BAK_DONE; + } else { + norflash_api_flush(); + } + } + + int_unlock_global(lock); + hal_trace_continue(); + } else { + // nvrec_trace(1,"%s: sync flush begin.", __func__); + if (nv_record_config.state == NV_STATE_MAIN_DONE || + nv_record_config.state == NV_STATE_BAK_ERASING) { + do { hal_trace_pause(); lock = int_lock_global(); - if(nv_record_config.state == NV_STATE_MAIN_DONE - || nv_record_config.state == NV_STATE_BAK_ERASING) - { - if(nv_record_config.state == NV_STATE_MAIN_DONE) - { - nv_record_config.state = NV_STATE_BAK_ERASING; - // nvrec_trace(1,"%s: NV_STATE_BAK_ERASING", __func__); - } - ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA, - _user_data_bak_start, - sizeof(usrdata_ddblist_pool), - true); - if(ret == NORFLASH_API_OK) - { - nv_record_config.state = NV_STATE_BAK_ERASED; - nvrec_trace(2,"%s: norflash_api_erase ok,addr = 0x%x.", - __func__,_user_data_bak_start); - // nvrec_trace(1,"%s: NV_STATE_BAK_ERASED", __func__); - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - norflash_api_flush(); - } - else - { - ASSERT(0,"%s: norflash_api_erase err,ret = %d,addr = 0x%x.", - __func__,ret,_user_data_bak_start); - } - } - else if(nv_record_config.state == NV_STATE_BAK_ERASED - || nv_record_config.state == NV_STATE_BAK_WRITTING) - { - if(nv_record_config.state == NV_STATE_BAK_ERASED) - { - nv_record_config.state = NV_STATE_BAK_WRITTING; - nv_record_config.written_size = 0; - // nvrec_trace(1,"%s: NV_STATE_BAK_WRITTING", __func__); - } - do - { - ret = norflash_api_read(NORFLASH_API_MODULE_ID_USERDATA, - _user_data_main_start + nv_record_config.written_size, - burn_buf, - sizeof(burn_buf) - ); - ASSERT(ret == NORFLASH_API_OK,"norflash_api_read failed! ret = %d, addr = 0x%x.", - (int32_t)ret,_user_data_main_start + nv_record_config.written_size); - - ret = norflash_api_write(NORFLASH_API_MODULE_ID_USERDATA, - _user_data_bak_start + nv_record_config.written_size, - burn_buf, - sizeof(burn_buf), - true - ); - if(ret == NORFLASH_API_OK) - { - nv_record_config.written_size += sizeof(burn_buf); - - if(nv_record_config.written_size == nvrecord_mem_pool_size) - { - nv_record_config.state = NV_STATE_BAK_WRITTEN; - // nvrec_trace(1,"%s: NV_STATE_BAK_WRITTEN", __func__); - break; - } - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - norflash_api_flush(); - break; - } - else - { - ASSERT(0,"%s: norflash_api_write err,ret = %d,addr = 0x%x.", - __func__,ret,_user_data_bak_start + nv_record_config.written_size); - } - }while(1); - } - else - { - if(norflash_api_get_used_buffer_count(NORFLASH_API_MODULE_ID_USERDATA,NORFLASH_API_ALL) == 0) - { - // nvrec_trace(1,"%s: NV_STATE_BAK_DONE", __func__); - nv_record_config.state = NV_STATE_BAK_DONE; - } - else - { - norflash_api_flush(); - } - } - + ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA, + _user_data_bak_start, + sizeof(usrdata_ddblist_pool), true); int_unlock_global(lock); hal_trace_continue(); - } - else - { - // nvrec_trace(1,"%s: sync flush begin.", __func__); - if(nv_record_config.state == NV_STATE_MAIN_DONE - || nv_record_config.state == NV_STATE_BAK_ERASING) - { - do - { - hal_trace_pause(); - lock = int_lock_global(); - ret = norflash_api_erase(NORFLASH_API_MODULE_ID_USERDATA, - _user_data_bak_start, - sizeof(usrdata_ddblist_pool), - true); - int_unlock_global(lock); - hal_trace_continue(); - if(ret == NORFLASH_API_OK) - { - nv_record_config.state = NV_STATE_BAK_ERASED; - nvrec_trace(2,"%s: norflash_api_erase ok,addr = 0x%x.", - __func__, _user_data_bak_start); - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - do - { - norflash_api_flush(); - }while(norflash_api_get_free_buffer_count(NORFLASH_API_ERASING) == 0); - } - else - { - ASSERT(0,"%s: norflash_api_erase err,ret = %d,addr = 0x%x.",__func__,ret,_user_data_bak_start); - } - }while(ret == NORFLASH_API_BUFFER_FULL); - } - - if(nv_record_config.state == NV_STATE_BAK_ERASED) - { - nv_record_config.state = NV_STATE_BAK_WRITTING; - nv_record_config.written_size = 0; - do - { - hal_trace_pause(); - do - { - lock = int_lock_global(); - ret = norflash_api_read(NORFLASH_API_MODULE_ID_USERDATA, - _user_data_main_start + nv_record_config.written_size, - burn_buf, - sizeof(burn_buf) - ); - ASSERT(ret == NORFLASH_API_OK,"norflash_api_read failed! ret = %d, addr = 0x%x.", - (int32_t)ret, _user_data_main_start + nv_record_config.written_size); - - ret = norflash_api_write(NORFLASH_API_MODULE_ID_USERDATA, - _user_data_bak_start + nv_record_config.written_size, - burn_buf, - sizeof(burn_buf), - true - ); - int_unlock_global(lock); - if(ret == NORFLASH_API_OK) - { - nv_record_config.written_size += sizeof(burn_buf); - if(nv_record_config.written_size == nvrecord_mem_pool_size) - { - nv_record_config.state = NV_STATE_BAK_WRITTEN; - break; - } - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - nv_record_config.state = NV_STATE_BAK_WRITTING; - do - { - norflash_api_flush(); - }while(norflash_api_get_free_buffer_count(NORFLASH_API_WRITTING) == 0); - } - else - { - ASSERT(0,"%s: norflash_api_write err,ret = %d,addr = 0x%x.", - __func__,ret,_user_data_bak_start + nv_record_config.written_size); - } - }while(1); - - hal_trace_continue(); - - if(ret == NORFLASH_API_OK) - { - nv_record_config.state = NV_STATE_BAK_WRITTEN; - nvrec_trace(3,"%s: norflash_api_write ok,addr = 0x%x,len = 0x%x.", - __func__,_user_data_bak_start,nv_record_config.written_size); - } - else if(ret == NORFLASH_API_BUFFER_FULL) - { - do - { - norflash_api_flush(); - }while(norflash_api_get_free_buffer_count(NORFLASH_API_WRITTING) == 0); - } - else - { - ASSERT(0,"%s: norflash_api_write err,ret = %d,addr = 0x%x.",__func__,ret,_user_data_bak_start); - } - }while(ret == NORFLASH_API_BUFFER_FULL); - - do - { - norflash_api_flush(); - }while(norflash_api_get_used_buffer_count(NORFLASH_API_MODULE_ID_USERDATA,NORFLASH_API_ALL) > 0); - nv_record_config.state = NV_STATE_BAK_DONE; - nvrec_trace(1,"%s: sync flush done.", __func__); + if (ret == NORFLASH_API_OK) { + nv_record_config.state = NV_STATE_BAK_ERASED; + nvrec_trace(2, "%s: norflash_api_erase ok,addr = 0x%x.", __func__, + _user_data_bak_start); + } else if (ret == NORFLASH_API_BUFFER_FULL) { + do { + norflash_api_flush(); + } while (norflash_api_get_free_buffer_count(NORFLASH_API_ERASING) == + 0); + } else { + ASSERT(0, "%s: norflash_api_erase err,ret = %d,addr = 0x%x.", + __func__, ret, _user_data_bak_start); } + } while (ret == NORFLASH_API_BUFFER_FULL); } - if(nv_record_config.state == NV_STATE_BAK_DONE) - { - nv_record_config.state = NV_STATE_IDLE; - // nvrec_trace(1,"%s: NV_STATE_IDLE", __func__); - } + if (nv_record_config.state == NV_STATE_BAK_ERASED) { + nv_record_config.state = NV_STATE_BAK_WRITTING; + nv_record_config.written_size = 0; + do { + hal_trace_pause(); + do { + lock = int_lock_global(); + ret = norflash_api_read(NORFLASH_API_MODULE_ID_USERDATA, + _user_data_main_start + + nv_record_config.written_size, + burn_buf, sizeof(burn_buf)); + ASSERT(ret == NORFLASH_API_OK, + "norflash_api_read failed! ret = %d, addr = 0x%x.", + (int32_t)ret, + _user_data_main_start + nv_record_config.written_size); - return (ret == NORFLASH_API_OK) ? 0:1; -} - - -static int nv_record_flash_flush_int(bool is_async) -{ - int ret = 0; - do{ - if((nv_record_config.state == NV_STATE_IDLE - && nv_record_config.is_update == TRUE) - || nv_record_config.state == NV_STATE_MAIN_ERASING - || nv_record_config.state == NV_STATE_MAIN_ERASED - || nv_record_config.state == NV_STATE_MAIN_WRITTING - || nv_record_config.state == NV_STATE_MAIN_WRITTEN - ) - { - ret = nv_record_flash_flush_main(is_async); - if(is_async) - { - break; + ret = norflash_api_write(NORFLASH_API_MODULE_ID_USERDATA, + _user_data_bak_start + + nv_record_config.written_size, + burn_buf, sizeof(burn_buf), true); + int_unlock_global(lock); + if (ret == NORFLASH_API_OK) { + nv_record_config.written_size += sizeof(burn_buf); + if (nv_record_config.written_size == nvrecord_mem_pool_size) { + nv_record_config.state = NV_STATE_BAK_WRITTEN; + break; } + } else if (ret == NORFLASH_API_BUFFER_FULL) { + nv_record_config.state = NV_STATE_BAK_WRITTING; + do { + norflash_api_flush(); + } while ( + norflash_api_get_free_buffer_count(NORFLASH_API_WRITTING) == 0); + } else { + ASSERT(0, "%s: norflash_api_write err,ret = %d,addr = 0x%x.", + __func__, ret, + _user_data_bak_start + nv_record_config.written_size); + } + } while (1); + + hal_trace_continue(); + + if (ret == NORFLASH_API_OK) { + nv_record_config.state = NV_STATE_BAK_WRITTEN; + nvrec_trace(3, "%s: norflash_api_write ok,addr = 0x%x,len = 0x%x.", + __func__, _user_data_bak_start, + nv_record_config.written_size); + } else if (ret == NORFLASH_API_BUFFER_FULL) { + do { + norflash_api_flush(); + } while (norflash_api_get_free_buffer_count(NORFLASH_API_WRITTING) == + 0); + } else { + ASSERT(0, "%s: norflash_api_write err,ret = %d,addr = 0x%x.", + __func__, ret, _user_data_bak_start); } + } while (ret == NORFLASH_API_BUFFER_FULL); - if(nv_record_config.state == NV_STATE_MAIN_DONE - || nv_record_config.state == NV_STATE_BAK_ERASING - || nv_record_config.state == NV_STATE_BAK_ERASED - || nv_record_config.state == NV_STATE_BAK_WRITTING - || nv_record_config.state == NV_STATE_BAK_WRITTEN - || nv_record_config.state == NV_STATE_BAK_DONE - ) - { - ret = nv_record_flash_flush_bak(is_async); - } - }while(0); - return ret; + do { + norflash_api_flush(); + } while (norflash_api_get_used_buffer_count( + NORFLASH_API_MODULE_ID_USERDATA, NORFLASH_API_ALL) > 0); + nv_record_config.state = NV_STATE_BAK_DONE; + nvrec_trace(1, "%s: sync flush done.", __func__); + } + } + + if (nv_record_config.state == NV_STATE_BAK_DONE) { + nv_record_config.state = NV_STATE_IDLE; + // nvrec_trace(1,"%s: NV_STATE_IDLE", __func__); + } + + return (ret == NORFLASH_API_OK) ? 0 : 1; } -void nv_record_flash_flush(void) -{ - nv_record_flash_flush_int(false); +static int nv_record_flash_flush_int(bool is_async) { + int ret = 0; + do { + if ((nv_record_config.state == NV_STATE_IDLE && + nv_record_config.is_update == TRUE) || + nv_record_config.state == NV_STATE_MAIN_ERASING || + nv_record_config.state == NV_STATE_MAIN_ERASED || + nv_record_config.state == NV_STATE_MAIN_WRITTING || + nv_record_config.state == NV_STATE_MAIN_WRITTEN) { + ret = nv_record_flash_flush_main(is_async); + if (is_async) { + break; + } + } + + if (nv_record_config.state == NV_STATE_MAIN_DONE || + nv_record_config.state == NV_STATE_BAK_ERASING || + nv_record_config.state == NV_STATE_BAK_ERASED || + nv_record_config.state == NV_STATE_BAK_WRITTING || + nv_record_config.state == NV_STATE_BAK_WRITTEN || + nv_record_config.state == NV_STATE_BAK_DONE) { + ret = nv_record_flash_flush_bak(is_async); + } + } while (0); + return ret; } -int nv_record_flash_flush_in_sleep(void) -{ - nv_record_flash_flush_int(true); - return 0; +void nv_record_flash_flush(void) { nv_record_flash_flush_int(false); } + +int nv_record_flash_flush_in_sleep(void) { + nv_record_flash_flush_int(true); + return 0; } -void nv_callback(void* param) -{ - NORFLASH_API_OPERA_RESULT *opera_result; - //uint8_t *burn_buf; +void nv_callback(void *param) { + NORFLASH_API_OPERA_RESULT *opera_result; + // uint8_t *burn_buf; - opera_result = (NORFLASH_API_OPERA_RESULT*)param; + opera_result = (NORFLASH_API_OPERA_RESULT *)param; - nvrec_trace(6,"%s:type = %d, addr = 0x%x,len = 0x%x,remain = %d,result = %d.", - __func__, - opera_result->type, - opera_result->addr, - opera_result->len, - opera_result->remain_num, - opera_result->result); + nvrec_trace( + 6, "%s:type = %d, addr = 0x%x,len = 0x%x,remain = %d,result = %d.", + __func__, opera_result->type, opera_result->addr, opera_result->len, + opera_result->remain_num, opera_result->result); #ifdef nv_record_debug - if (opera_result->result == NORFLASH_API_OK){ - if(opera_result->remain_num == 0 && - opera_result->type == NORFLASH_API_WRITTING) { - uint32_t recrc; - uint32_t crc; - uint8_t* read_buffer = (uint8_t*)opera_result->addr; + if (opera_result->result == NORFLASH_API_OK) { + if (opera_result->remain_num == 0 && + opera_result->type == NORFLASH_API_WRITTING) { + uint32_t recrc; + uint32_t crc; + uint8_t *read_buffer = (uint8_t *)opera_result->addr; - crc = ((uint32_t *)read_buffer)[pos_crc]; - recrc = crc32(0, - ((uint8_t *)read_buffer + sizeof(uint32_t)*pos_heap_contents), - (sizeof(usrdata_ddblist_pool)-(pos_heap_contents*sizeof(uint32_t)))); - ASSERT(crc == recrc,"%s:addr=0x%x,recrc=0x%x crc=0x%x.", - __func__,opera_result->addr,recrc,crc); - } - } - else{ - ASSERT(0,"%s:flash write fail!addr=0x%x,result = %d.", - __func__,opera_result->addr,opera_result->result); - } + crc = ((uint32_t *)read_buffer)[pos_crc]; + recrc = crc32( + 0, ((uint8_t *)read_buffer + sizeof(uint32_t) * pos_heap_contents), + (sizeof(usrdata_ddblist_pool) - + (pos_heap_contents * sizeof(uint32_t)))); + ASSERT(crc == recrc, "%s:addr=0x%x,recrc=0x%x crc=0x%x.", __func__, + opera_result->addr, recrc, crc); + } + } else { + ASSERT(0, "%s:flash write fail!addr=0x%x,result = %d.", __func__, + opera_result->addr, opera_result->result); + } #endif - } #ifdef NVREC_BAIDU_DATA_SECTION #define BAIDU_DATA_FM_SPEC_VALUE (0xffee) -int nvrec_baidu_data_init(void) -{ - int _fmfreq = 0; - if (!nvrec_config_has_section(nv_record_config.config, BAIDU_DATA_SECTIN)) { - nvrec_trace(0,"no baidu section default, new one!"); - nvrec_config_set_int(nv_record_config.config, BAIDU_DATA_SECTIN, BAIDU_DATA_FM_KEY, BAIDU_DATA_DEF_FM_FREQ); - } - else { - nvrec_trace(1,"has baidu section, fmfreq is %d", nvrec_config_get_int(nv_record_config.config, BAIDU_DATA_SECTIN, BAIDU_DATA_FM_KEY, BAIDU_DATA_FM_SPEC_VALUE)); - _fmfreq = nvrec_config_get_int(nv_record_config.config, BAIDU_DATA_SECTIN, BAIDU_DATA_FM_KEY, BAIDU_DATA_FM_SPEC_VALUE); - if (_fmfreq == BAIDU_DATA_FM_SPEC_VALUE) { - nvrec_trace(1,"fm bas bad value, set to %d", BAIDU_DATA_DEF_FM_FREQ); - nvrec_config_set_int(nv_record_config.config, BAIDU_DATA_SECTIN, BAIDU_DATA_FM_KEY, BAIDU_DATA_DEF_FM_FREQ); - _fmfreq = nvrec_config_get_int(nv_record_config.config, BAIDU_DATA_SECTIN, BAIDU_DATA_FM_KEY, BAIDU_DATA_FM_SPEC_VALUE); - if (_fmfreq == BAIDU_DATA_FM_SPEC_VALUE) { - nvrec_trace(0,"get fm freq still fail!!!"); - ASSERT(0, "nvrecord fail, system down!"); - } - } +int nvrec_baidu_data_init(void) { + int _fmfreq = 0; + if (!nvrec_config_has_section(nv_record_config.config, BAIDU_DATA_SECTIN)) { + nvrec_trace(0, "no baidu section default, new one!"); + nvrec_config_set_int(nv_record_config.config, BAIDU_DATA_SECTIN, + BAIDU_DATA_FM_KEY, BAIDU_DATA_DEF_FM_FREQ); + } else { + nvrec_trace(1, "has baidu section, fmfreq is %d", + nvrec_config_get_int(nv_record_config.config, BAIDU_DATA_SECTIN, + BAIDU_DATA_FM_KEY, + BAIDU_DATA_FM_SPEC_VALUE)); + _fmfreq = nvrec_config_get_int(nv_record_config.config, BAIDU_DATA_SECTIN, + BAIDU_DATA_FM_KEY, BAIDU_DATA_FM_SPEC_VALUE); + if (_fmfreq == BAIDU_DATA_FM_SPEC_VALUE) { + nvrec_trace(1, "fm bas bad value, set to %d", BAIDU_DATA_DEF_FM_FREQ); + nvrec_config_set_int(nv_record_config.config, BAIDU_DATA_SECTIN, + BAIDU_DATA_FM_KEY, BAIDU_DATA_DEF_FM_FREQ); + _fmfreq = + nvrec_config_get_int(nv_record_config.config, BAIDU_DATA_SECTIN, + BAIDU_DATA_FM_KEY, BAIDU_DATA_FM_SPEC_VALUE); + if (_fmfreq == BAIDU_DATA_FM_SPEC_VALUE) { + nvrec_trace(0, "get fm freq still fail!!!"); + ASSERT(0, "nvrecord fail, system down!"); + } } + } - return 0; + return 0; } -int nvrec_get_fm_freq(void) -{ - int _fmfreq = 0; - _fmfreq = nvrec_config_get_int(nv_record_config.config, BAIDU_DATA_SECTIN, BAIDU_DATA_FM_KEY, BAIDU_DATA_FM_SPEC_VALUE); - if (_fmfreq == BAIDU_DATA_FM_SPEC_VALUE) { - nvrec_trace(1,"%s : get fm freq fail, reinit fmfreq data", __func__); - nvrec_baidu_data_init(); - } - _fmfreq = nvrec_config_get_int(nv_record_config.config, BAIDU_DATA_SECTIN, BAIDU_DATA_FM_KEY, BAIDU_DATA_FM_SPEC_VALUE); - if (_fmfreq == BAIDU_DATA_FM_SPEC_VALUE) { - nvrec_trace(1,"%s : get fm freq still fail", __func__); - ASSERT(0, "%s : nvrecord fail, system down!", __func__); - } +int nvrec_get_fm_freq(void) { + int _fmfreq = 0; + _fmfreq = nvrec_config_get_int(nv_record_config.config, BAIDU_DATA_SECTIN, + BAIDU_DATA_FM_KEY, BAIDU_DATA_FM_SPEC_VALUE); + if (_fmfreq == BAIDU_DATA_FM_SPEC_VALUE) { + nvrec_trace(1, "%s : get fm freq fail, reinit fmfreq data", __func__); + nvrec_baidu_data_init(); + } + _fmfreq = nvrec_config_get_int(nv_record_config.config, BAIDU_DATA_SECTIN, + BAIDU_DATA_FM_KEY, BAIDU_DATA_FM_SPEC_VALUE); + if (_fmfreq == BAIDU_DATA_FM_SPEC_VALUE) { + nvrec_trace(1, "%s : get fm freq still fail", __func__); + ASSERT(0, "%s : nvrecord fail, system down!", __func__); + } - nvrec_trace(2,"%s:get fm freq %d", __func__, _fmfreq); - return _fmfreq; + nvrec_trace(2, "%s:get fm freq %d", __func__, _fmfreq); + return _fmfreq; } -int nvrec_set_fm_freq(int fmfreq) -{ - int t = hal_sys_timer_get(); - nvrec_trace(2,"%s:fmfreq %d", __func__, fmfreq); - nvrec_config_set_int(nv_record_config.config, BAIDU_DATA_SECTIN, BAIDU_DATA_FM_KEY, fmfreq); - nvrec_trace(2,"%s: use %d ms", __func__, TICKS_TO_MS(hal_sys_timer_get()-t)); - nv_record_config.is_update = true; +int nvrec_set_fm_freq(int fmfreq) { + int t = hal_sys_timer_get(); + nvrec_trace(2, "%s:fmfreq %d", __func__, fmfreq); + nvrec_config_set_int(nv_record_config.config, BAIDU_DATA_SECTIN, + BAIDU_DATA_FM_KEY, fmfreq); + nvrec_trace(2, "%s: use %d ms", __func__, + TICKS_TO_MS(hal_sys_timer_get() - t)); + nv_record_config.is_update = true; #if defined(NVREC_BAIDU_DATA_FLUSH_DIRECT) - nv_record_flash_flush_int(false); + nv_record_flash_flush_int(false); #endif - nvrec_trace(2,"%s: use %d ms", __func__, TICKS_TO_MS(hal_sys_timer_get()-t)); + nvrec_trace(2, "%s: use %d ms", __func__, + TICKS_TO_MS(hal_sys_timer_get() - t)); - return 0; + return 0; } -int nvrec_get_rand(char *rand) -{ - char * _rand = 0; +int nvrec_get_rand(char *rand) { + char *_rand = 0; - if (rand == NULL) - return 1; + if (rand == NULL) + return 1; #if 0 _rand = nvrec_config_get_string(nv_record_config.config, BAIDU_DATA_SECTIN, BAIDU_DATA_RAND_KEY, BAIDU_DATA_DEF_RAND); @@ -1593,421 +1481,405 @@ int nvrec_get_rand(char *rand) return 1; } #else - _rand = BAIDU_DATA_DEF_RAND; + _rand = BAIDU_DATA_DEF_RAND; #endif - memcpy(rand, _rand, BAIDU_DATA_RAND_LEN); + memcpy(rand, _rand, BAIDU_DATA_RAND_LEN); - nvrec_trace(2,"%s:rand %s", __func__, rand); + nvrec_trace(2, "%s:rand %s", __func__, rand); - return 0; + return 0; } -int nvrec_set_rand(char *rand) -{ - int t = hal_sys_timer_get(); - if (rand != NULL) - nvrec_trace(2,"%s:rand %s", __func__, rand); - else - nvrec_trace(1,"%s:rand nul", __func__); - nvrec_config_set_string(nv_record_config.config, BAIDU_DATA_SECTIN, BAIDU_DATA_RAND_KEY, rand); - nvrec_trace(2,"%s: use %d ms", __func__, TICKS_TO_MS(hal_sys_timer_get()-t)); - nv_record_config.is_update = true; +int nvrec_set_rand(char *rand) { + int t = hal_sys_timer_get(); + if (rand != NULL) + nvrec_trace(2, "%s:rand %s", __func__, rand); + else + nvrec_trace(1, "%s:rand nul", __func__); + nvrec_config_set_string(nv_record_config.config, BAIDU_DATA_SECTIN, + BAIDU_DATA_RAND_KEY, rand); + nvrec_trace(2, "%s: use %d ms", __func__, + TICKS_TO_MS(hal_sys_timer_get() - t)); + nv_record_config.is_update = true; #if defined(NVREC_BAIDU_DATA_FLUSH_DIRECT) - nv_record_flash_flush_int(false); + nv_record_flash_flush_int(false); #endif - nvrec_trace(2,"%s: use %d ms", __func__, TICKS_TO_MS(hal_sys_timer_get()-t)); + nvrec_trace(2, "%s: use %d ms", __func__, + TICKS_TO_MS(hal_sys_timer_get() - t)); - return 0; + return 0; } -int nvrec_clear_rand(void) -{ - nvrec_set_rand(NULL); - return 0; +int nvrec_clear_rand(void) { + nvrec_set_rand(NULL); + return 0; } -int nvrec_dev_get_sn(char *sn) -{ - unsigned int sn_addr; - if (NVREC_DEV_VERSION_1 == nv_record_dev_rev) - { - return -1; - } - else - { - sn_addr = (unsigned int)(__factory_start + rev2_dev_prod_sn); - } +int nvrec_dev_get_sn(char *sn) { + unsigned int sn_addr; + if (NVREC_DEV_VERSION_1 == nv_record_dev_rev) { + return -1; + } else { + sn_addr = (unsigned int)(__factory_start + rev2_dev_prod_sn); + } - if(false == dev_sector_valid) - return -1; - if (NULL == sn) - return -1; + if (false == dev_sector_valid) + return -1; + if (NULL == sn) + return -1; - memcpy((void *)sn, (void *)sn_addr, BAIDU_DATA_SN_LEN); + memcpy((void *)sn, (void *)sn_addr, BAIDU_DATA_SN_LEN); - return 0; + return 0; } #endif #endif // !defined(NEW_NV_RECORD_ENABLED) -bool nvrec_dev_data_open(void) -{ - uint32_t dev_zone_crc,dev_zone_flsh_crc; - uint32_t vermagic; +bool nvrec_dev_data_open(void) { + uint32_t dev_zone_crc, dev_zone_flsh_crc; + uint32_t vermagic; - vermagic = __factory_start[dev_version_and_magic]; - nvrec_trace(2,"%s,vermagic=0x%x",__func__,vermagic); - if ((nvrec_dev_magic != (vermagic&0xFFFF)) || - ((vermagic >> 16) > NVREC_DEV_NEWEST_REV)) - { - dev_sector_valid = false; - nvrec_trace(1,"%s,dev sector invalid.",__func__); - return dev_sector_valid; - } - - // following the nv rec version number programmed by the downloader tool, - // to be backward compatible - nv_record_dev_rev = vermagic >> 16; - nvrec_trace(1,"Nv record dev version %d", nv_record_dev_rev); - - if (NVREC_DEV_VERSION_1 == nv_record_dev_rev) - { - dev_zone_flsh_crc = __factory_start[dev_crc]; - dev_zone_crc = crc32(0,(uint8_t *)(&__factory_start[dev_reserv1]),(dev_data_len-dev_reserv1)*sizeof(uint32_t)); - } - else - { - // check the data length - if ((rev2_dev_section_start_reserved*sizeof(uint32_t)) + __factory_start[rev2_dev_data_len] - > 4096) - { - nvrec_trace(1,"nv rec dev data len %d has exceeds the facory sector size!.", - __factory_start[rev2_dev_data_len]); - dev_sector_valid = false; - return false; - } - - // assure that in future, if the nv dev data structure is extended, the former tool - // and former bin can still be workable - dev_zone_flsh_crc = __factory_start[rev2_dev_crc]; - dev_zone_crc = crc32(0,(uint8_t *)(&__factory_start[rev2_dev_section_start_reserved]), - __factory_start[rev2_dev_data_len]); - } - - nvrec_trace(4,"%s: data len 0x%x,dev_zone_flsh_crc=0x%x,dev_zone_crc=0x%x",__func__, - __factory_start[rev2_dev_data_len],dev_zone_flsh_crc,dev_zone_crc); - if (dev_zone_flsh_crc == dev_zone_crc) - { - dev_sector_valid = true; - } - - if (dev_sector_valid) - { - nvrec_trace(1,"%s: nv rec dev is valid.", __func__); - } - else - { - nvrec_trace(1,"%s: nv rec dev is invalid.", __func__); - } + vermagic = __factory_start[dev_version_and_magic]; + nvrec_trace(2, "%s,vermagic=0x%x", __func__, vermagic); + if ((nvrec_dev_magic != (vermagic & 0xFFFF)) || + ((vermagic >> 16) > NVREC_DEV_NEWEST_REV)) { + dev_sector_valid = false; + nvrec_trace(1, "%s,dev sector invalid.", __func__); return dev_sector_valid; -} + } -bool nvrec_dev_localname_addr_init(dev_addr_name *dev) -{ - uint32_t *p_devdata_cache = __factory_start; - size_t name_len = 0; - if(true == dev_sector_valid) - { - nvrec_trace(1,"%s: nv dev data valid", __func__); - if (NVREC_DEV_VERSION_1 == nv_record_dev_rev) - { - memcpy((void *) dev->btd_addr,(void *)&p_devdata_cache[dev_bt_addr],BTIF_BD_ADDR_SIZE); - memcpy((void *) dev->ble_addr,(void *)&p_devdata_cache[dev_ble_addr],BTIF_BD_ADDR_SIZE); - dev->localname = (char *)&p_devdata_cache[dev_name]; - } - else - { - memcpy((void *) dev->btd_addr,(void *)&p_devdata_cache[rev2_dev_bt_addr],BTIF_BD_ADDR_SIZE); - memcpy((void *) dev->ble_addr,(void *)&p_devdata_cache[rev2_dev_ble_addr],BTIF_BD_ADDR_SIZE); - dev->localname = (char *)&p_devdata_cache[rev2_dev_name]; - dev->ble_name = (char *)&p_devdata_cache[rev2_dev_ble_name]; - } + // following the nv rec version number programmed by the downloader tool, + // to be backward compatible + nv_record_dev_rev = vermagic >> 16; + nvrec_trace(1, "Nv record dev version %d", nv_record_dev_rev); - if (strlen(dev->localname) < CLASSIC_BTNAME_LEN) { - name_len = strlen(dev->localname); - } - else { - name_len = CLASSIC_BTNAME_LEN - 1; - } - memcpy(classics_bt_name,dev->localname,name_len); - classics_bt_name[name_len] = '\0'; - bt_set_local_name(classics_bt_name); - bt_set_local_address(dev->btd_addr); - } - else - { - nvrec_trace(1,"%s: nv dev data invalid", __func__); + if (NVREC_DEV_VERSION_1 == nv_record_dev_rev) { + dev_zone_flsh_crc = __factory_start[dev_crc]; + dev_zone_crc = crc32(0, (uint8_t *)(&__factory_start[dev_reserv1]), + (dev_data_len - dev_reserv1) * sizeof(uint32_t)); + } else { + // check the data length + if ((rev2_dev_section_start_reserved * sizeof(uint32_t)) + + __factory_start[rev2_dev_data_len] > + 4096) { + nvrec_trace(1, + "nv rec dev data len %d has exceeds the facory sector size!.", + __factory_start[rev2_dev_data_len]); + dev_sector_valid = false; + return false; } - nvrec_trace(0,"BT addr is:"); - DUMP8("%02x ", dev->btd_addr, BTIF_BD_ADDR_SIZE); - nvrec_trace(0,"BLE addr is:"); - DUMP8("%02x ", dev->ble_addr, BTIF_BD_ADDR_SIZE); - nvrec_trace(2,"localname=%s, namelen=%d", dev->localname, strlen(dev->localname)); - if (dev->ble_name) - nvrec_trace(2,"blename=%s, namelen=%d", dev->ble_name, strlen(dev->ble_name)); + // assure that in future, if the nv dev data structure is extended, the + // former tool and former bin can still be workable + dev_zone_flsh_crc = __factory_start[rev2_dev_crc]; + dev_zone_crc = + crc32(0, (uint8_t *)(&__factory_start[rev2_dev_section_start_reserved]), + __factory_start[rev2_dev_data_len]); + } - return dev_sector_valid; + nvrec_trace(4, "%s: data len 0x%x,dev_zone_flsh_crc=0x%x,dev_zone_crc=0x%x", + __func__, __factory_start[rev2_dev_data_len], dev_zone_flsh_crc, + dev_zone_crc); + if (dev_zone_flsh_crc == dev_zone_crc) { + dev_sector_valid = true; + } + + if (dev_sector_valid) { + nvrec_trace(1, "%s: nv rec dev is valid.", __func__); + } else { + nvrec_trace(1, "%s: nv rec dev is invalid.", __func__); + } + return dev_sector_valid; } -int nvrec_dev_force_get_btaddress(unsigned char *btd_addr) -{ - uint32_t *p_devdata_cache = __factory_start; - memcpy((void *) btd_addr,(void *)&p_devdata_cache[dev_bt_addr],BTIF_BD_ADDR_SIZE); - return 0; -} -static void nvrec_dev_data_fill_xtal_fcap(uint32_t *mem_pool,uint32_t val) -{ - uint8_t *btaddr = NULL; - uint8_t *bleaddr = NULL; - - assert(0 != mem_pool); - if (!dev_sector_valid) - { - mem_pool[dev_version_and_magic] = ((nv_record_dev_rev<<16)|nvrec_dev_magic); - } - - if (NVREC_DEV_VERSION_1 == nv_record_dev_rev) - { - if(dev_sector_valid) - { - memcpy((void *)mem_pool,(void *)__factory_start,0x1000); - mem_pool[dev_xtal_fcap] = val; - mem_pool[dev_crc] = crc32(0,(uint8_t *)(&mem_pool[dev_reserv1]),(dev_data_len-dev_reserv1)*sizeof(uint32_t)); - } - else - { - const char *localname = bt_get_local_name(); - unsigned int namelen = strlen(localname); - - btaddr = bt_get_local_address(); - bleaddr = bt_get_ble_local_address(); - - mem_pool[dev_reserv1] = 0; - mem_pool[dev_reserv2] = 0; - memcpy((void *)&mem_pool[dev_name],(void *)localname,(size_t)namelen); - nvrec_dev_rand_btaddr_gen(btaddr); - nvrec_dev_rand_btaddr_gen(bleaddr); - memcpy((void *)&mem_pool[dev_bt_addr],(void *)btaddr,BTIF_BD_ADDR_SIZE); - memcpy((void *)&mem_pool[dev_ble_addr],(void *)bleaddr,BTIF_BD_ADDR_SIZE); - memset((void *)&mem_pool[dev_dongle_addr],0x0,BTIF_BD_ADDR_SIZE); - mem_pool[dev_xtal_fcap] = val; - mem_pool[dev_crc] = crc32(0,(uint8_t *)(&mem_pool[dev_reserv1]),(dev_data_len-dev_reserv1)*sizeof(uint32_t)); - nvrec_trace(2,"%s: mem_pool[dev_crc]=%x.\n",__func__,mem_pool[dev_crc]); - } - } - else - { - if(dev_sector_valid) - { - memcpy((void *)mem_pool,(void *)__factory_start,0x1000); - mem_pool[rev2_dev_xtal_fcap] = val; - mem_pool[rev2_dev_crc] = crc32(0, - (uint8_t *)(&mem_pool[rev2_dev_section_start_reserved]),mem_pool[rev2_dev_data_len]); - } - else - { - const char *localname = bt_get_local_name(); - unsigned int namelen = strlen(localname); - - btaddr = bt_get_local_address(); - bleaddr = bt_get_ble_local_address(); - mem_pool[rev2_dev_section_start_reserved] = 0; - mem_pool[rev2_dev_reserv2] = 0; - memcpy((void *)&mem_pool[rev2_dev_name],(void *)localname,(size_t)namelen); - memcpy((void *)&mem_pool[rev2_dev_ble_name], (void *)bt_get_ble_local_name(), BLE_NAME_LEN_IN_NV); - nvrec_dev_rand_btaddr_gen(btaddr); - nvrec_dev_rand_btaddr_gen(bleaddr); - memcpy((void *)&mem_pool[rev2_dev_bt_addr],(void *)btaddr,BTIF_BD_ADDR_SIZE); - memcpy((void *)&mem_pool[rev2_dev_ble_addr],(void *)bleaddr,BTIF_BD_ADDR_SIZE); - memset((void *)&mem_pool[rev2_dev_dongle_addr],0x0,BTIF_BD_ADDR_SIZE); - mem_pool[rev2_dev_xtal_fcap] = val; - mem_pool[rev2_dev_data_len] = (rev2_dev_section_end-rev2_dev_section_start_reserved)*sizeof(uint32_t); - mem_pool[rev2_dev_crc] = crc32(0, - (uint8_t *)(&mem_pool[rev2_dev_section_start_reserved]), - mem_pool[rev2_dev_data_len]); - nvrec_trace(2,"%s: mem_pool[rev2_dev_crc] = 0x%x.\n", - __func__,mem_pool[rev2_dev_crc]); - } - } -} - -void nvrec_dev_flash_flush(unsigned char *mempool) -{ - uint32_t lock; -#ifdef nv_record_debug - uint32_t devdata[dev_data_len] = {0,}; - uint32_t recrc; -#endif - - if(NULL == mempool) - return; - lock = int_lock_global(); - pmu_flash_write_config(); - - hal_norflash_erase(HAL_NORFLASH_ID_0,(uint32_t)NVRECORD_CACHE_2_UNCACHE(__factory_start),0x1000); - hal_norflash_write(HAL_NORFLASH_ID_0,(uint32_t)NVRECORD_CACHE_2_UNCACHE(__factory_start),(uint8_t *)mempool,0x1000);//dev_data_len*sizeof(uint32_t)); - - pmu_flash_read_config(); - int_unlock_global(lock); - -#ifdef nv_record_debug - if (NVREC_DEV_VERSION_1 == nv_record_dev_rev) - { - memset(devdata,0x0,dev_data_len*sizeof(uint32_t)); - memcpy(devdata,__factory_start,dev_data_len*sizeof(uint32_t)); - recrc = crc32(0,(uint8_t *)(&devdata[dev_reserv1]),(dev_data_len-dev_reserv1)*sizeof(uint32_t)); - nvrec_trace(3,"%s: devdata[dev_crc]=%x.recrc=%x\n", __func__,devdata[dev_crc],recrc); - if(devdata[dev_crc] != recrc) - assert(0); - } -#endif -} - -void nvrec_dev_rand_btaddr_gen(uint8_t* bdaddr) -{ - unsigned int seed; - int i; - - OS_DUMP8("%x ",bdaddr,6); - seed = hal_sys_timer_get(); - for(i=0;ibtd_addr, (void *)&p_devdata_cache[dev_bt_addr], + BTIF_BD_ADDR_SIZE); + memcpy((void *)dev->ble_addr, (void *)&p_devdata_cache[dev_ble_addr], + BTIF_BD_ADDR_SIZE); + dev->localname = (char *)&p_devdata_cache[dev_name]; + } else { + memcpy((void *)dev->btd_addr, (void *)&p_devdata_cache[rev2_dev_bt_addr], + BTIF_BD_ADDR_SIZE); + memcpy((void *)dev->ble_addr, (void *)&p_devdata_cache[rev2_dev_ble_addr], + BTIF_BD_ADDR_SIZE); + dev->localname = (char *)&p_devdata_cache[rev2_dev_name]; + dev->ble_name = (char *)&p_devdata_cache[rev2_dev_ble_name]; } - OS_DUMP8("%x ",bdaddr,6); + + if (strlen(dev->localname) < CLASSIC_BTNAME_LEN) { + name_len = strlen(dev->localname); + } else { + name_len = CLASSIC_BTNAME_LEN - 1; + } + memcpy(classics_bt_name, dev->localname, name_len); + classics_bt_name[name_len] = '\0'; + bt_set_local_name(classics_bt_name); + bt_set_local_address(dev->btd_addr); + } else { + nvrec_trace(1, "%s: nv dev data invalid", __func__); + } + + nvrec_trace(0, "BT addr is:"); + DUMP8("%02x ", dev->btd_addr, BTIF_BD_ADDR_SIZE); + nvrec_trace(0, "BLE addr is:"); + DUMP8("%02x ", dev->ble_addr, BTIF_BD_ADDR_SIZE); + nvrec_trace(2, "localname=%s, namelen=%d", dev->localname, + strlen(dev->localname)); + if (dev->ble_name) + nvrec_trace(2, "blename=%s, namelen=%d", dev->ble_name, + strlen(dev->ble_name)); + + return dev_sector_valid; } -void nvrec_dev_set_xtal_fcap(unsigned int xtal_fcap) -{ - uint8_t *mempool = NULL; - uint32_t lock; +int nvrec_dev_force_get_btaddress(unsigned char *btd_addr) { + uint32_t *p_devdata_cache = __factory_start; + memcpy((void *)btd_addr, (void *)&p_devdata_cache[dev_bt_addr], + BTIF_BD_ADDR_SIZE); + return 0; +} +static void nvrec_dev_data_fill_xtal_fcap(uint32_t *mem_pool, uint32_t val) { + uint8_t *btaddr = NULL; + uint8_t *bleaddr = NULL; + + assert(0 != mem_pool); + if (!dev_sector_valid) { + mem_pool[dev_version_and_magic] = + ((nv_record_dev_rev << 16) | nvrec_dev_magic); + } + + if (NVREC_DEV_VERSION_1 == nv_record_dev_rev) { + if (dev_sector_valid) { + memcpy((void *)mem_pool, (void *)__factory_start, 0x1000); + mem_pool[dev_xtal_fcap] = val; + mem_pool[dev_crc] = + crc32(0, (uint8_t *)(&mem_pool[dev_reserv1]), + (dev_data_len - dev_reserv1) * sizeof(uint32_t)); + } else { + const char *localname = bt_get_local_name(); + unsigned int namelen = strlen(localname); + + btaddr = bt_get_local_address(); + bleaddr = bt_get_ble_local_address(); + + mem_pool[dev_reserv1] = 0; + mem_pool[dev_reserv2] = 0; + memcpy((void *)&mem_pool[dev_name], (void *)localname, (size_t)namelen); + nvrec_dev_rand_btaddr_gen(btaddr); + nvrec_dev_rand_btaddr_gen(bleaddr); + memcpy((void *)&mem_pool[dev_bt_addr], (void *)btaddr, BTIF_BD_ADDR_SIZE); + memcpy((void *)&mem_pool[dev_ble_addr], (void *)bleaddr, + BTIF_BD_ADDR_SIZE); + memset((void *)&mem_pool[dev_dongle_addr], 0x0, BTIF_BD_ADDR_SIZE); + mem_pool[dev_xtal_fcap] = val; + mem_pool[dev_crc] = + crc32(0, (uint8_t *)(&mem_pool[dev_reserv1]), + (dev_data_len - dev_reserv1) * sizeof(uint32_t)); + nvrec_trace(2, "%s: mem_pool[dev_crc]=%x.\n", __func__, + mem_pool[dev_crc]); + } + } else { + if (dev_sector_valid) { + memcpy((void *)mem_pool, (void *)__factory_start, 0x1000); + mem_pool[rev2_dev_xtal_fcap] = val; + mem_pool[rev2_dev_crc] = + crc32(0, (uint8_t *)(&mem_pool[rev2_dev_section_start_reserved]), + mem_pool[rev2_dev_data_len]); + } else { + const char *localname = bt_get_local_name(); + unsigned int namelen = strlen(localname); + + btaddr = bt_get_local_address(); + bleaddr = bt_get_ble_local_address(); + mem_pool[rev2_dev_section_start_reserved] = 0; + mem_pool[rev2_dev_reserv2] = 0; + memcpy((void *)&mem_pool[rev2_dev_name], (void *)localname, + (size_t)namelen); + memcpy((void *)&mem_pool[rev2_dev_ble_name], + (void *)bt_get_ble_local_name(), BLE_NAME_LEN_IN_NV); + nvrec_dev_rand_btaddr_gen(btaddr); + nvrec_dev_rand_btaddr_gen(bleaddr); + memcpy((void *)&mem_pool[rev2_dev_bt_addr], (void *)btaddr, + BTIF_BD_ADDR_SIZE); + memcpy((void *)&mem_pool[rev2_dev_ble_addr], (void *)bleaddr, + BTIF_BD_ADDR_SIZE); + memset((void *)&mem_pool[rev2_dev_dongle_addr], 0x0, BTIF_BD_ADDR_SIZE); + mem_pool[rev2_dev_xtal_fcap] = val; + mem_pool[rev2_dev_data_len] = + (rev2_dev_section_end - rev2_dev_section_start_reserved) * + sizeof(uint32_t); + mem_pool[rev2_dev_crc] = + crc32(0, (uint8_t *)(&mem_pool[rev2_dev_section_start_reserved]), + mem_pool[rev2_dev_data_len]); + nvrec_trace(2, "%s: mem_pool[rev2_dev_crc] = 0x%x.\n", __func__, + mem_pool[rev2_dev_crc]); + } + } +} + +void nvrec_dev_flash_flush(unsigned char *mempool) { + uint32_t lock; #ifdef nv_record_debug - uint32_t devdata[dev_data_len] = {0,}; - uint32_t recrc; + uint32_t devdata[dev_data_len] = { + 0, + }; + uint32_t recrc; #endif - syspool_init(); - syspool_get_buff(&mempool, 0x1000); - nvrec_dev_data_fill_xtal_fcap((uint32_t *)mempool,(uint32_t)xtal_fcap); - lock = int_lock_global(); - norflash_api_flush_all(); //Ensure that the flash is in an operational state - pmu_flash_write_config(); + if (NULL == mempool) + return; + lock = int_lock_global(); + pmu_flash_write_config(); - hal_norflash_erase(HAL_NORFLASH_ID_0,(uint32_t)NVRECORD_CACHE_2_UNCACHE(__factory_start),0x1000); - hal_norflash_write(HAL_NORFLASH_ID_0,(uint32_t)NVRECORD_CACHE_2_UNCACHE(__factory_start),(uint8_t *)mempool,0x1000);//dev_data_len*sizeof(uint32_t)); + hal_norflash_erase(HAL_NORFLASH_ID_0, + (uint32_t)NVRECORD_CACHE_2_UNCACHE(__factory_start), + 0x1000); + hal_norflash_write( + HAL_NORFLASH_ID_0, (uint32_t)NVRECORD_CACHE_2_UNCACHE(__factory_start), + (uint8_t *)mempool, 0x1000); // dev_data_len*sizeof(uint32_t)); + + pmu_flash_read_config(); + int_unlock_global(lock); - pmu_flash_read_config(); - int_unlock_global(lock); #ifdef nv_record_debug - if (NVREC_DEV_VERSION_1 == nv_record_dev_rev) - { - memset(devdata,0x0,dev_data_len*sizeof(uint32_t)); - memcpy(devdata,__factory_start,dev_data_len*sizeof(uint32_t)); - nvrec_trace(2,"%s: xtal fcap = %d", __func__, devdata[dev_xtal_fcap]); - recrc = crc32(0,(uint8_t *)(&devdata[dev_reserv1]),(dev_data_len-dev_reserv1)*sizeof(uint32_t)); - nvrec_trace(2,"devdata[dev_crc]=%x.recrc=%x\n", devdata[dev_crc], recrc); - if(devdata[dev_crc] != recrc) - assert(0); - } + if (NVREC_DEV_VERSION_1 == nv_record_dev_rev) { + memset(devdata, 0x0, dev_data_len * sizeof(uint32_t)); + memcpy(devdata, __factory_start, dev_data_len * sizeof(uint32_t)); + recrc = crc32(0, (uint8_t *)(&devdata[dev_reserv1]), + (dev_data_len - dev_reserv1) * sizeof(uint32_t)); + nvrec_trace(3, "%s: devdata[dev_crc]=%x.recrc=%x\n", __func__, + devdata[dev_crc], recrc); + if (devdata[dev_crc] != recrc) + assert(0); + } #endif } -int nvrec_dev_get_xtal_fcap(unsigned int *xtal_fcap) -{ - unsigned int xtal_fcap_addr; - if (NVREC_DEV_VERSION_1 == nv_record_dev_rev) - { - xtal_fcap_addr = (unsigned int)(__factory_start + dev_xtal_fcap); - } - else - { - xtal_fcap_addr = (unsigned int)(__factory_start + rev2_dev_xtal_fcap); - } +void nvrec_dev_rand_btaddr_gen(uint8_t *bdaddr) { + unsigned int seed; + int i; - unsigned int tmpval[1] = {0,}; + OS_DUMP8("%x ", bdaddr, 6); + seed = hal_sys_timer_get(); + for (i = 0; i < BTIF_BD_ADDR_SIZE; i++) { + unsigned int randval; + srand(seed); + randval = rand(); + bdaddr[i] = (randval & 0xff); + seed += rand(); + } + OS_DUMP8("%x ", bdaddr, 6); +} - if(false == dev_sector_valid) - return -1; - if (NULL == xtal_fcap) - return -1; - memcpy((void *)tmpval,(void *)xtal_fcap_addr,sizeof(unsigned int)); - *xtal_fcap = tmpval[0]; +void nvrec_dev_set_xtal_fcap(unsigned int xtal_fcap) { + uint8_t *mempool = NULL; + uint32_t lock; +#ifdef nv_record_debug + uint32_t devdata[dev_data_len] = { + 0, + }; + uint32_t recrc; +#endif + + syspool_init(); + syspool_get_buff(&mempool, 0x1000); + nvrec_dev_data_fill_xtal_fcap((uint32_t *)mempool, (uint32_t)xtal_fcap); + lock = int_lock_global(); + norflash_api_flush_all(); // Ensure that the flash is in an operational state + pmu_flash_write_config(); + + hal_norflash_erase(HAL_NORFLASH_ID_0, + (uint32_t)NVRECORD_CACHE_2_UNCACHE(__factory_start), + 0x1000); + hal_norflash_write( + HAL_NORFLASH_ID_0, (uint32_t)NVRECORD_CACHE_2_UNCACHE(__factory_start), + (uint8_t *)mempool, 0x1000); // dev_data_len*sizeof(uint32_t)); + + pmu_flash_read_config(); + int_unlock_global(lock); +#ifdef nv_record_debug + if (NVREC_DEV_VERSION_1 == nv_record_dev_rev) { + memset(devdata, 0x0, dev_data_len * sizeof(uint32_t)); + memcpy(devdata, __factory_start, dev_data_len * sizeof(uint32_t)); + nvrec_trace(2, "%s: xtal fcap = %d", __func__, devdata[dev_xtal_fcap]); + recrc = crc32(0, (uint8_t *)(&devdata[dev_reserv1]), + (dev_data_len - dev_reserv1) * sizeof(uint32_t)); + nvrec_trace(2, "devdata[dev_crc]=%x.recrc=%x\n", devdata[dev_crc], recrc); + if (devdata[dev_crc] != recrc) + assert(0); + } +#endif +} + +int nvrec_dev_get_xtal_fcap(unsigned int *xtal_fcap) { + unsigned int xtal_fcap_addr; + if (NVREC_DEV_VERSION_1 == nv_record_dev_rev) { + xtal_fcap_addr = (unsigned int)(__factory_start + dev_xtal_fcap); + } else { + xtal_fcap_addr = (unsigned int)(__factory_start + rev2_dev_xtal_fcap); + } + + unsigned int tmpval[1] = { + 0, + }; + + if (false == dev_sector_valid) + return -1; + if (NULL == xtal_fcap) + return -1; + memcpy((void *)tmpval, (void *)xtal_fcap_addr, sizeof(unsigned int)); + *xtal_fcap = tmpval[0]; + return 0; +} + +int nvrec_dev_get_dongleaddr(bt_bdaddr_t *dongleaddr) { + unsigned int dongle_addr_pos; + if (NVREC_DEV_VERSION_1 == nv_record_dev_rev) { + dongle_addr_pos = (unsigned int)(__factory_start + dev_dongle_addr); + } else { + dongle_addr_pos = (unsigned int)(__factory_start + rev2_dev_dongle_addr); + } + + if (false == dev_sector_valid) + return -1; + if (NULL == dongleaddr) + return -1; + memcpy((void *)dongleaddr, (void *)dongle_addr_pos, BTIF_BD_ADDR_SIZE); + return 0; +} + +int nvrec_dev_get_btaddr(char *btaddr) { + unsigned int bt_addr_pos; + if (NVREC_DEV_VERSION_1 == nv_record_dev_rev) { + bt_addr_pos = (unsigned int)(__factory_start + dev_bt_addr); + } else { + bt_addr_pos = (unsigned int)(__factory_start + rev2_dev_bt_addr); + } + + if (false == dev_sector_valid) return 0; -} - -int nvrec_dev_get_dongleaddr(bt_bdaddr_t *dongleaddr) -{ - unsigned int dongle_addr_pos; - if (NVREC_DEV_VERSION_1 == nv_record_dev_rev) - { - dongle_addr_pos = (unsigned int)(__factory_start + dev_dongle_addr); - } - else - { - dongle_addr_pos = (unsigned int)(__factory_start + rev2_dev_dongle_addr); - } - - if(false == dev_sector_valid) - return -1; - if(NULL == dongleaddr) - return -1; - memcpy((void *)dongleaddr,(void *)dongle_addr_pos,BTIF_BD_ADDR_SIZE); + if (NULL == btaddr) return 0; + memcpy((void *)btaddr, (void *)bt_addr_pos, BTIF_BD_ADDR_SIZE); + return 1; } -int nvrec_dev_get_btaddr(char *btaddr) -{ - unsigned int bt_addr_pos; - if (NVREC_DEV_VERSION_1 == nv_record_dev_rev) - { - bt_addr_pos = (unsigned int)(__factory_start + dev_bt_addr); - } - else - { - bt_addr_pos = (unsigned int)(__factory_start + rev2_dev_bt_addr); - } +char *nvrec_dev_get_bt_name(void) { return classics_bt_name; } - if(false == dev_sector_valid) - return 0; - if(NULL == btaddr) - return 0; - memcpy((void *)btaddr,(void *)bt_addr_pos,BTIF_BD_ADDR_SIZE); - return 1; +const char *nvrec_dev_get_ble_name(void) { + if ((NVREC_DEV_VERSION_1 == nv_record_dev_rev) || (!dev_sector_valid)) { + return BLE_DEFAULT_NAME; + } else { + + return (const char *)(&__factory_start[rev2_dev_ble_name]); + } } - -char* nvrec_dev_get_bt_name(void) -{ - return classics_bt_name; -} - -const char* nvrec_dev_get_ble_name(void) -{ - if ((NVREC_DEV_VERSION_1 == nv_record_dev_rev) || (!dev_sector_valid)) - { - return BLE_DEFAULT_NAME; - } - else - { - - return (const char *)(&__factory_start[rev2_dev_ble_name]); - } -} - diff --git a/services/nvrecord/nvrecord_ble.c b/services/nvrecord/nvrecord_ble.c index d5d5c64..eb2b0b2 100644 --- a/services/nvrecord/nvrecord_ble.c +++ b/services/nvrecord/nvrecord_ble.c @@ -15,13 +15,13 @@ ****************************************************************************/ #if !defined(NEW_NV_RECORD_ENABLED) -#include -#include "nvrecord.h" #include "nvrecord_ble.h" -#include "hal_trace.h" -#include "hal_timer.h" #include "co_math.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "nvrecord.h" #include "tgt_hardware.h" +#include #define ble_nv_debug #ifdef ble_nv_debug @@ -33,299 +33,276 @@ extern nv_record_struct nv_record_config; static struct Ble_nvrecord *nvrecord_ble_p = NULL; -static bool blerec_specific_value_prepare(const BleDeviceinfo* param_rec) -{ - // Preparations before adding new ble record: - // 1. If not existing. Check the record count. If it's BLE_RECORD_NUM, - // move 0-(BLE_RECORD_NUM-2) right side by one slot, to discard the last one and - // leave slot 0, decrease the record number. - // If it's smaller than BLE_RECORD_NUM, move 0-(count-1) right side by one slot, leave slot 0, - // don't change the record number. - // 2. If existing already and the location is entryToFree , move 0-(entryToFree-1) - // right side by one slot, leave slot 0. Decrease the record number for adding the new one. +static bool blerec_specific_value_prepare(const BleDeviceinfo *param_rec) { + // Preparations before adding new ble record: + // 1. If not existing. Check the record count. If it's BLE_RECORD_NUM, + // move 0-(BLE_RECORD_NUM-2) right side by one slot, to discard the last + // one and leave slot 0, decrease the record number. If it's smaller than + // BLE_RECORD_NUM, move 0-(count-1) right side by one slot, leave slot 0, + // don't change the record number. + // 2. If existing already and the location is entryToFree , move + // 0-(entryToFree-1) + // right side by one slot, leave slot 0. Decrease the record number for + // adding the new one. - bool isEntryExisting = false; - uint8_t entryToFree = 0; - struct Ble_nvrecord *dest_ptr; + bool isEntryExisting = false; + uint8_t entryToFree = 0; + struct Ble_nvrecord *dest_ptr; - dest_ptr = nvrecord_ble_p; - TRACE(3,"%s start search addr %08x list_num=%d", __func__, (uint32_t)dest_ptr, dest_ptr->saved_list_num); - if (dest_ptr->saved_list_num > 0) - { - for (uint8_t i = 0; i < dest_ptr->saved_list_num; i++) - { - if (0 == memcmp(dest_ptr->ble_nv[i].LTK, param_rec->LTK, BLE_LTK_SIZE)) - { - ble_trace(2,"%s Find the existing entry %d", __func__, i); - DUMP8("%02x ", (uint8_t *)param_rec, sizeof(BleDeviceinfo)); - DUMP8("%02x ", (uint8_t *)&dest_ptr->ble_nv[i], sizeof(BleDeviceinfo)); - if (!memcmp((uint8_t *)param_rec, (uint8_t *)&dest_ptr->ble_nv[i], sizeof(BleDeviceinfo))) - { - ble_trace(0,"The new coming BLE device info is the same as the recorded."); - return false; - } - memset(&(dest_ptr->ble_nv[i]), 0, sizeof(BleDeviceinfo)); - entryToFree = i; - dest_ptr->saved_list_num--; - isEntryExisting = true; - break; - } + dest_ptr = nvrecord_ble_p; + TRACE(3, "%s start search addr %08x list_num=%d", __func__, + (uint32_t)dest_ptr, dest_ptr->saved_list_num); + if (dest_ptr->saved_list_num > 0) { + for (uint8_t i = 0; i < dest_ptr->saved_list_num; i++) { + if (0 == memcmp(dest_ptr->ble_nv[i].LTK, param_rec->LTK, BLE_LTK_SIZE)) { + ble_trace(2, "%s Find the existing entry %d", __func__, i); + DUMP8("%02x ", (uint8_t *)param_rec, sizeof(BleDeviceinfo)); + DUMP8("%02x ", (uint8_t *)&dest_ptr->ble_nv[i], sizeof(BleDeviceinfo)); + if (!memcmp((uint8_t *)param_rec, (uint8_t *)&dest_ptr->ble_nv[i], + sizeof(BleDeviceinfo))) { + ble_trace( + 0, "The new coming BLE device info is the same as the recorded."); + return false; } + memset(&(dest_ptr->ble_nv[i]), 0, sizeof(BleDeviceinfo)); + entryToFree = i; + dest_ptr->saved_list_num--; + isEntryExisting = true; + break; + } } - else - { - return true; - } - - if (!isEntryExisting) - { - if (BLE_RECORD_NUM == dest_ptr->saved_list_num) - { - TRACE(0,"<=====>blerec list is full,delete the oldest and add param_rec to list"); - for (uint8_t k = 0;k < BLE_RECORD_NUM - 1;k++) - { - memcpy(&(dest_ptr->ble_nv[BLE_RECORD_NUM - 1 - k]), - &(dest_ptr->ble_nv[BLE_RECORD_NUM - 2 - k]), - sizeof(BleDeviceinfo)); - } - dest_ptr->saved_list_num--; - } - else - { - for (uint8_t k = 0;k < dest_ptr->saved_list_num;k++) - { - memcpy(&(dest_ptr->ble_nv[dest_ptr->saved_list_num - k]), - &(dest_ptr->ble_nv[dest_ptr->saved_list_num - 1 - k]), - sizeof(BleDeviceinfo)); - } - } - return true; - } - else - { - for(uint8_t list_updata = 0;list_updata < entryToFree; list_updata++) - { - memcpy(&(dest_ptr->ble_nv[entryToFree - list_updata]), - &(dest_ptr->ble_nv[entryToFree - list_updata - 1]), - sizeof(BleDeviceinfo)); - } - } - + } else { return true; + } + + if (!isEntryExisting) { + if (BLE_RECORD_NUM == dest_ptr->saved_list_num) { + TRACE(0, "<=====>blerec list is full,delete the oldest and add param_rec " + "to list"); + for (uint8_t k = 0; k < BLE_RECORD_NUM - 1; k++) { + memcpy(&(dest_ptr->ble_nv[BLE_RECORD_NUM - 1 - k]), + &(dest_ptr->ble_nv[BLE_RECORD_NUM - 2 - k]), + sizeof(BleDeviceinfo)); + } + dest_ptr->saved_list_num--; + } else { + for (uint8_t k = 0; k < dest_ptr->saved_list_num; k++) { + memcpy(&(dest_ptr->ble_nv[dest_ptr->saved_list_num - k]), + &(dest_ptr->ble_nv[dest_ptr->saved_list_num - 1 - k]), + sizeof(BleDeviceinfo)); + } + } + return true; + } else { + for (uint8_t list_updata = 0; list_updata < entryToFree; list_updata++) { + memcpy(&(dest_ptr->ble_nv[entryToFree - list_updata]), + &(dest_ptr->ble_nv[entryToFree - list_updata - 1]), + sizeof(BleDeviceinfo)); + } + } + + return true; } -void nv_record_blerec_init(void) -{ - if (NULL == nvrecord_ble_p) - { - nvrecord_ble_p = (struct Ble_nvrecord *)nvrec_config_get_int(nv_record_config.config, - (const char *)section_name_ble_nvds, (const char *)NV_RECORD_BLE_KEY, NVRAM_BLE_INVALID); +void nv_record_blerec_init(void) { + if (NULL == nvrecord_ble_p) { + nvrecord_ble_p = (struct Ble_nvrecord *)nvrec_config_get_int( + nv_record_config.config, (const char *)section_name_ble_nvds, + (const char *)NV_RECORD_BLE_KEY, NVRAM_BLE_INVALID); + } + + if (nvrecord_ble_p == (struct Ble_nvrecord *)NVRAM_BLE_INVALID) { + nvrecord_ble_p = + (struct Ble_nvrecord *)pool_malloc(sizeof(struct Ble_nvrecord)); + if (!nvrecord_ble_p) { + ASSERT(0, "%s ble pool_malloc failed", __func__); + return; } + TRACE(1, "ble nv malloc addr %08x", (uint32_t)nvrecord_ble_p); - if (nvrecord_ble_p == (struct Ble_nvrecord *)NVRAM_BLE_INVALID){ - nvrecord_ble_p = (struct Ble_nvrecord *)pool_malloc(sizeof(struct Ble_nvrecord)); - if (!nvrecord_ble_p){ - ASSERT(0,"%s ble pool_malloc failed",__func__); - return; - } - TRACE(1,"ble nv malloc addr %08x", (uint32_t)nvrecord_ble_p); - - memset(nvrecord_ble_p, 0, sizeof(struct Ble_nvrecord)); - nvrecord_ble_p->saved_list_num = 0;//init saved num - - uint8_t index; - //avoid ble irk collision low probability - uint32_t generatedSeed = hal_sys_timer_get(); - for (uint8_t index = 0; index < sizeof(bt_addr); index++) - { - generatedSeed ^= (((uint32_t)(bt_addr[index])) << (hal_sys_timer_get()&0xF)); - } - srand(generatedSeed); - - // generate a new IRK - for (index = 0; index < BLE_IRK_SIZE; index++) - { - nvrecord_ble_p->loc_irk[index] = (uint8_t)co_rand_word(); - } - nvrec_config_set_int(nv_record_config.config, section_name_ble_nvds, - (const char *)NV_RECORD_BLE_KEY,(int)nvrecord_ble_p); + memset(nvrecord_ble_p, 0, sizeof(struct Ble_nvrecord)); + nvrecord_ble_p->saved_list_num = 0; // init saved num + uint8_t index; + // avoid ble irk collision low probability + uint32_t generatedSeed = hal_sys_timer_get(); + for (uint8_t index = 0; index < sizeof(bt_addr); index++) { + generatedSeed ^= + (((uint32_t)(bt_addr[index])) << (hal_sys_timer_get() & 0xF)); } + srand(generatedSeed); + + // generate a new IRK + for (index = 0; index < BLE_IRK_SIZE; index++) { + nvrecord_ble_p->loc_irk[index] = (uint8_t)co_rand_word(); + } + nvrec_config_set_int(nv_record_config.config, section_name_ble_nvds, + (const char *)NV_RECORD_BLE_KEY, (int)nvrecord_ble_p); + } } -void nv_record_blerec_get_local_irk(uint8_t* pIrk) -{ - memcpy(pIrk, nvrecord_ble_p->loc_irk, BLE_IRK_SIZE); +void nv_record_blerec_get_local_irk(uint8_t *pIrk) { + memcpy(pIrk, nvrecord_ble_p->loc_irk, BLE_IRK_SIZE); } -bool nv_record_blerec_get_bd_addr_from_irk(uint8_t* pBdAddr, uint8_t* pIrk) -{ - if (nvrecord_ble_p->saved_list_num > 0) - { - for (uint8_t index = 0; index < nvrecord_ble_p->saved_list_num; index++) - { - if (!memcmp(pIrk, nvrecord_ble_p->ble_nv[index].IRK, BLE_IRK_SIZE)) - { - memcpy(pBdAddr, nvrecord_ble_p->ble_nv[index].peer_bleAddr, BLE_ADDR_SIZE); - return true; - } - } - return false; - } - else - { - return false; +bool nv_record_blerec_get_bd_addr_from_irk(uint8_t *pBdAddr, uint8_t *pIrk) { + if (nvrecord_ble_p->saved_list_num > 0) { + for (uint8_t index = 0; index < nvrecord_ble_p->saved_list_num; index++) { + if (!memcmp(pIrk, nvrecord_ble_p->ble_nv[index].IRK, BLE_IRK_SIZE)) { + memcpy(pBdAddr, nvrecord_ble_p->ble_nv[index].peer_bleAddr, + BLE_ADDR_SIZE); + return true; + } } + return false; + } else { + return false; + } } -int nv_record_blerec_add(const BleDeviceinfo *param_rec) -{ - int nRet = 0; +int nv_record_blerec_add(const BleDeviceinfo *param_rec) { + int nRet = 0; - uint8_t isNeedToUpdateNv = true; - isNeedToUpdateNv = blerec_specific_value_prepare(param_rec); + uint8_t isNeedToUpdateNv = true; + isNeedToUpdateNv = blerec_specific_value_prepare(param_rec); - if (isNeedToUpdateNv) - { - //add device info into nv struct - memcpy(nvrecord_ble_p->ble_nv[0].peer_bleAddr, param_rec->peer_bleAddr, BLE_ADDR_SIZE);//addr - nvrecord_ble_p->ble_nv[0].EDIV = param_rec->EDIV;//EDIV - memcpy(nvrecord_ble_p->ble_nv[0].RANDOM, param_rec->RANDOM, BLE_ENC_RANDOM_SIZE);//RANDOM - memcpy(nvrecord_ble_p->ble_nv[0].LTK, param_rec->LTK, BLE_LTK_SIZE);//LTK - memcpy(nvrecord_ble_p->ble_nv[0].IRK, param_rec->IRK, BLE_IRK_SIZE);//IRK - nvrecord_ble_p->ble_nv[0].bonded = param_rec->bonded;//bond status - nvrecord_ble_p->saved_list_num++;//updata saved num + if (isNeedToUpdateNv) { + // add device info into nv struct + memcpy(nvrecord_ble_p->ble_nv[0].peer_bleAddr, param_rec->peer_bleAddr, + BLE_ADDR_SIZE); // addr + nvrecord_ble_p->ble_nv[0].EDIV = param_rec->EDIV; // EDIV + memcpy(nvrecord_ble_p->ble_nv[0].RANDOM, param_rec->RANDOM, + BLE_ENC_RANDOM_SIZE); // RANDOM + memcpy(nvrecord_ble_p->ble_nv[0].LTK, param_rec->LTK, BLE_LTK_SIZE); // LTK + memcpy(nvrecord_ble_p->ble_nv[0].IRK, param_rec->IRK, BLE_IRK_SIZE); // IRK + nvrecord_ble_p->ble_nv[0].bonded = param_rec->bonded; // bond status + nvrecord_ble_p->saved_list_num++; // updata saved num - nv_record_update_runtime_userdata(); - TRACE(2,"%s CURRENT BLE LIST NUM=%d", __func__, nvrecord_ble_p->saved_list_num); - } + nv_record_update_runtime_userdata(); + TRACE(2, "%s CURRENT BLE LIST NUM=%d", __func__, + nvrecord_ble_p->saved_list_num); + } #ifdef ble_nv_debug - for (uint8_t k = 0;k < nvrecord_ble_p->saved_list_num;k++){ - TRACE(0,"========================================="); - TRACE(1,"Num %d BLE record:", k); - TRACE(0,"BLE addr:"); - DUMP8("%02x ", (uint8_t *)nvrecord_ble_p->ble_nv[k].peer_bleAddr, BLE_ADDR_SIZE); - TRACE(1,"NV EDIV %d and random is:", nvrecord_ble_p->ble_nv[k].EDIV); - DUMP8("%02x ", (uint8_t *)nvrecord_ble_p->ble_nv[k].RANDOM, BLE_ENC_RANDOM_SIZE); - TRACE(0,"NV LTK:"); - DUMP8("%02x ", (uint8_t *)nvrecord_ble_p->ble_nv[k].LTK, BLE_LTK_SIZE); - TRACE(0,"NV irk:"); - DUMP8("%02x ", (uint8_t *)nvrecord_ble_p->ble_nv[k].IRK, BLE_IRK_SIZE); - } + for (uint8_t k = 0; k < nvrecord_ble_p->saved_list_num; k++) { + TRACE(0, "========================================="); + TRACE(1, "Num %d BLE record:", k); + TRACE(0, "BLE addr:"); + DUMP8("%02x ", (uint8_t *)nvrecord_ble_p->ble_nv[k].peer_bleAddr, + BLE_ADDR_SIZE); + TRACE(1, "NV EDIV %d and random is:", nvrecord_ble_p->ble_nv[k].EDIV); + DUMP8("%02x ", (uint8_t *)nvrecord_ble_p->ble_nv[k].RANDOM, + BLE_ENC_RANDOM_SIZE); + TRACE(0, "NV LTK:"); + DUMP8("%02x ", (uint8_t *)nvrecord_ble_p->ble_nv[k].LTK, BLE_LTK_SIZE); + TRACE(0, "NV irk:"); + DUMP8("%02x ", (uint8_t *)nvrecord_ble_p->ble_nv[k].IRK, BLE_IRK_SIZE); + } #endif - return nRet; + return nRet; } -uint8_t nv_record_ble_fill_irk(uint8_t* irkToFill) -{ - struct Ble_nvrecord *find_ptr; +uint8_t nv_record_ble_fill_irk(uint8_t *irkToFill) { + struct Ble_nvrecord *find_ptr; - find_ptr = (struct Ble_nvrecord *)nvrec_config_get_int(nv_record_config.config, - (const char *)section_name_ble_nvds, - (const char *)NV_RECORD_BLE_KEY, - NVRAM_BLE_INVALID); + find_ptr = (struct Ble_nvrecord *)nvrec_config_get_int( + nv_record_config.config, (const char *)section_name_ble_nvds, + (const char *)NV_RECORD_BLE_KEY, NVRAM_BLE_INVALID); - TRACE(2,"%s find_ptr 0x%x", __FUNCTION__, (uint32_t)find_ptr); + TRACE(2, "%s find_ptr 0x%x", __FUNCTION__, (uint32_t)find_ptr); - if (((struct Ble_nvrecord *)NVRAM_BLE_INVALID == find_ptr) || - (0 == find_ptr->saved_list_num)) - { - return 0; - } - - if (find_ptr->saved_list_num > 0) - { - for (uint8_t index = 0; index < find_ptr->saved_list_num; index++) - { - memcpy(irkToFill + index*BLE_IRK_SIZE, find_ptr->ble_nv[index].IRK, BLE_IRK_SIZE); - } - return find_ptr->saved_list_num; - } - else - { - return 0; + if (((struct Ble_nvrecord *)NVRAM_BLE_INVALID == find_ptr) || + (0 == find_ptr->saved_list_num)) { + return 0; + } + + if (find_ptr->saved_list_num > 0) { + for (uint8_t index = 0; index < find_ptr->saved_list_num; index++) { + memcpy(irkToFill + index * BLE_IRK_SIZE, find_ptr->ble_nv[index].IRK, + BLE_IRK_SIZE); } + return find_ptr->saved_list_num; + } else { + return 0; + } } -//when master send encription req,if bonded,use ltk to bonding again(skip the pair step) -bool nv_record_ble_record_find_ltk_through_static_bd_addr(uint8_t* pBdAddr, uint8_t *ltk) -{ - struct Ble_nvrecord *find_ptr; - find_ptr = (struct Ble_nvrecord *)nvrec_config_get_int(nv_record_config.config, (const char *)section_name_ble_nvds,(const char *)NV_RECORD_BLE_KEY, NVRAM_BLE_INVALID); - if (find_ptr == (struct Ble_nvrecord *)NVRAM_BLE_INVALID) - { - TRACE(1,"%s find data failed",__func__); - return false; - } - - for (uint8_t find_index=0; find_indexsaved_list_num; find_index++) - { - if (!memcmp(find_ptr->ble_nv[find_index].peer_bleAddr, pBdAddr, BLE_ADDR_SIZE)) - { - ble_trace(2,"%s FIND LTK IN NV SUCCESS %08x", __func__, (uint32_t)&find_ptr->ble_nv[find_index].LTK); - memcpy(ltk, find_ptr->ble_nv[find_index].LTK, BLE_LTK_SIZE); - return true; - } - } +// when master send encription req,if bonded,use ltk to bonding again(skip the +// pair step) +bool nv_record_ble_record_find_ltk_through_static_bd_addr(uint8_t *pBdAddr, + uint8_t *ltk) { + struct Ble_nvrecord *find_ptr; + find_ptr = (struct Ble_nvrecord *)nvrec_config_get_int( + nv_record_config.config, (const char *)section_name_ble_nvds, + (const char *)NV_RECORD_BLE_KEY, NVRAM_BLE_INVALID); + if (find_ptr == (struct Ble_nvrecord *)NVRAM_BLE_INVALID) { + TRACE(1, "%s find data failed", __func__); return false; + } + + for (uint8_t find_index = 0; find_index < find_ptr->saved_list_num; + find_index++) { + if (!memcmp(find_ptr->ble_nv[find_index].peer_bleAddr, pBdAddr, + BLE_ADDR_SIZE)) { + ble_trace(2, "%s FIND LTK IN NV SUCCESS %08x", __func__, + (uint32_t)&find_ptr->ble_nv[find_index].LTK); + memcpy(ltk, find_ptr->ble_nv[find_index].LTK, BLE_LTK_SIZE); + return true; + } + } + return false; } -bool nv_record_ble_record_Once_a_device_has_been_bonded(void) -{ - struct Ble_nvrecord *find_ptr; +bool nv_record_ble_record_Once_a_device_has_been_bonded(void) { + struct Ble_nvrecord *find_ptr; - find_ptr=(struct Ble_nvrecord *)nvrec_config_get_int(nv_record_config.config, (const char *)section_name_ble_nvds,(const char *)NV_RECORD_BLE_KEY, NVRAM_BLE_INVALID); - if (find_ptr == (struct Ble_nvrecord *)NVRAM_BLE_INVALID){ - return false; - } - for(uint8_t find_index=0;find_indexsaved_list_num;find_index++){ - if(find_ptr->ble_nv[find_index].bonded==true){ - return true; - } - } + find_ptr = (struct Ble_nvrecord *)nvrec_config_get_int( + nv_record_config.config, (const char *)section_name_ble_nvds, + (const char *)NV_RECORD_BLE_KEY, NVRAM_BLE_INVALID); + if (find_ptr == (struct Ble_nvrecord *)NVRAM_BLE_INVALID) { return false; + } + for (uint8_t find_index = 0; find_index < find_ptr->saved_list_num; + find_index++) { + if (find_ptr->ble_nv[find_index].bonded == true) { + return true; + } + } + return false; } -void nv_record_ble_delete_entry(uint8_t* pBdAddr) -{ - struct Ble_nvrecord *find_ptr; +void nv_record_ble_delete_entry(uint8_t *pBdAddr) { + struct Ble_nvrecord *find_ptr; - find_ptr = (struct Ble_nvrecord *)nvrec_config_get_int(nv_record_config.config, - (const char *)section_name_ble_nvds, - (const char *)NV_RECORD_BLE_KEY, - NVRAM_BLE_INVALID); + find_ptr = (struct Ble_nvrecord *)nvrec_config_get_int( + nv_record_config.config, (const char *)section_name_ble_nvds, + (const char *)NV_RECORD_BLE_KEY, NVRAM_BLE_INVALID); - if (((struct Ble_nvrecord *)NVRAM_BLE_INVALID == find_ptr) || - (0 == find_ptr->saved_list_num)) - { - return; + if (((struct Ble_nvrecord *)NVRAM_BLE_INVALID == find_ptr) || + (0 == find_ptr->saved_list_num)) { + return; + } + + int8_t indexToDelete = -1; + + for (uint8_t find_index = 0; find_index < find_ptr->saved_list_num; + find_index++) { + if (!memcmp(find_ptr->ble_nv[find_index].peer_bleAddr, pBdAddr, + BLE_ADDR_SIZE)) { + indexToDelete = find_index; + break; + } + } + + if (indexToDelete >= 0) { + uint8_t index; + for (index = indexToDelete; index < find_ptr->saved_list_num - 1; index++) { + memcpy(&(find_ptr->ble_nv[index]), &(find_ptr->ble_nv[index + 1]), + sizeof(BleDeviceinfo)); } - int8_t indexToDelete = -1; - - for (uint8_t find_index=0; find_index < find_ptr->saved_list_num; find_index++) - { - if (!memcmp(find_ptr->ble_nv[find_index].peer_bleAddr, pBdAddr, BLE_ADDR_SIZE)) - { - indexToDelete = find_index; - break; - } - } - - if (indexToDelete >= 0) - { - uint8_t index; - for (index = indexToDelete; index < find_ptr->saved_list_num - 1; index++) - { - memcpy(&(find_ptr->ble_nv[index]), - &(find_ptr->ble_nv[index + 1]), - sizeof(BleDeviceinfo)); - } - - memset((uint8_t *)&(find_ptr->ble_nv[index]), 0, sizeof(BleDeviceinfo)); - find_ptr->saved_list_num--; - nv_record_update_runtime_userdata(); - } + memset((uint8_t *)&(find_ptr->ble_nv[index]), 0, sizeof(BleDeviceinfo)); + find_ptr->saved_list_num--; + nv_record_update_runtime_userdata(); + } } #endif // !defined(NEW_NV_RECORD_ENABLED) - diff --git a/services/nvrecord/nvrecord_env.c b/services/nvrecord/nvrecord_env.c index 2c09e7c..0fa46ae 100644 --- a/services/nvrecord/nvrecord_env.c +++ b/services/nvrecord/nvrecord_env.c @@ -15,125 +15,119 @@ ****************************************************************************/ #if !defined(NEW_NV_RECORD_ENABLED) -#include -#include "nvrecord.h" #include "nvrecord_env.h" -#include "hal_trace.h" #include "customparam_section.h" +#include "hal_trace.h" +#include "nvrecord.h" +#include -#define NV_RECORD_ENV_KEY "env_key" +#define NV_RECORD_ENV_KEY "env_key" extern nv_record_struct nv_record_config; static struct nvrecord_env_t *nvrecord_env_p = NULL; -static int nv_record_env_new(void) -{ +static int nv_record_env_new(void) { - nvrecord_env_p = (struct nvrecord_env_t *)pool_malloc(sizeof(struct nvrecord_env_t)); + nvrecord_env_p = + (struct nvrecord_env_t *)pool_malloc(sizeof(struct nvrecord_env_t)); - if (!nvrecord_env_p) - { - TRACE(1,"%s pool_malloc failed ", __func__); - return -1; - } - nvrec_config_set_int(nv_record_config.config,section_name_other,(const char *)NV_RECORD_ENV_KEY,(int)nvrecord_env_p); + if (!nvrecord_env_p) { + TRACE(1, "%s pool_malloc failed ", __func__); + return -1; + } + nvrec_config_set_int(nv_record_config.config, section_name_other, + (const char *)NV_RECORD_ENV_KEY, (int)nvrecord_env_p); - nvrecord_env_p->media_language.language = NVRAM_ENV_MEDIA_LANGUAGE_DEFAULT; - nvrecord_env_p->ibrt_mode.mode = NVRAM_ENV_TWS_MODE_DEFAULT; - nvrecord_env_p->ibrt_mode.tws_connect_success = 0; - nvrecord_env_p->factory_tester_status.status = NVRAM_ENV_FACTORY_TESTER_STATUS_DEFAULT; + nvrecord_env_p->media_language.language = NVRAM_ENV_MEDIA_LANGUAGE_DEFAULT; + nvrecord_env_p->ibrt_mode.mode = NVRAM_ENV_TWS_MODE_DEFAULT; + nvrecord_env_p->ibrt_mode.tws_connect_success = 0; + nvrecord_env_p->factory_tester_status.status = + NVRAM_ENV_FACTORY_TESTER_STATUS_DEFAULT; - nvrecord_env_p->aiManagerInfo.voice_key_enable = false; - nvrecord_env_p->aiManagerInfo.setedCurrentAi = 0; - nvrecord_env_p->aiManagerInfo.aiStatusDisableFlag = 0; - nvrecord_env_p->aiManagerInfo.amaAssistantEnableStatus = 1; - //nv_record_update_runtime_userdata(); + nvrecord_env_p->aiManagerInfo.voice_key_enable = false; + nvrecord_env_p->aiManagerInfo.setedCurrentAi = 0; + nvrecord_env_p->aiManagerInfo.aiStatusDisableFlag = 0; + nvrecord_env_p->aiManagerInfo.amaAssistantEnableStatus = 1; + // nv_record_update_runtime_userdata(); - TRACE(2,"%s nvrecord_env_p:0x%x",__func__, (uint32_t)nvrecord_env_p); + TRACE(2, "%s nvrecord_env_p:0x%x", __func__, (uint32_t)nvrecord_env_p); - return 0; + return 0; } -static int nv_record_env_rebuild(void) -{ - if(nv_record_config_rebuild() != BT_STS_SUCCESS) - return -1; +static int nv_record_env_rebuild(void) { + if (nv_record_config_rebuild() != BT_STS_SUCCESS) + return -1; - if(nv_record_env_new()) - return -1; + if (nv_record_env_new()) + return -1; + nv_record_config.is_update = true; + nv_record_config.state = NV_STATE_IDLE; + nv_record_config.written_size = 0; + nv_record_flash_flush(); + + return 0; +} + +int nv_record_env_init(void) { + int nRet = 0; + nv_record_open(section_usrdata_ddbrecord); + + nv_custom_parameter_section_init(); + + nvrecord_env_p = (struct nvrecord_env_t *)nvrec_config_get_int( + nv_record_config.config, (const char *)section_name_other, + (const char *)NV_RECORD_ENV_KEY, NVRAM_ENV_INVALID); + + if (nvrecord_env_p == (struct nvrecord_env_t *)NVRAM_ENV_INVALID) { + TRACE(0, "NVRAM_ENV_INVALID !!"); + if (nv_record_env_rebuild() < 0) + nRet = -1; + else + TRACE(0, "NVRAM REBUILD SUCCESS !!"); + } + TRACE(2, "%s nvrecord_env_p: 0x%x", __func__, (uint32_t)nvrecord_env_p); + return nRet; +} + +int nv_record_env_get(struct nvrecord_env_t **nvrecord_env) { + if (!nvrecord_env) + return -1; + + if (!nvrecord_env_p) + return -1; + + *nvrecord_env = nvrecord_env_p; + + return 0; +} + +int nv_record_env_set(struct nvrecord_env_t *nvrecord_env) { + if (!nvrecord_env) + return -1; + + if (!nvrecord_env_p) + return -1; + + nv_record_update_runtime_userdata(); + + return 0; +} + +void nv_record_update_factory_tester_status(uint32_t status) { + if (nvrecord_env_p) { + nvrecord_env_p->factory_tester_status.status = status; + } +} + +void nv_record_update_ibrt_info(uint32_t newMode, bt_bdaddr_t *ibrtPeerAddr) { + if (nvrecord_env_p) { + TRACE(2, "##%s,%d", __func__, newMode); + nvrecord_env_p->ibrt_mode.mode = newMode; nv_record_config.is_update = true; - nv_record_config.state = NV_STATE_IDLE; - nv_record_config.written_size = 0; - nv_record_flash_flush(); - - return 0; -} - -int nv_record_env_init(void) -{ - int nRet = 0; - nv_record_open(section_usrdata_ddbrecord); - - nv_custom_parameter_section_init(); - - nvrecord_env_p = (struct nvrecord_env_t *)nvrec_config_get_int(nv_record_config.config, (const char *)section_name_other,(const char *)NV_RECORD_ENV_KEY, NVRAM_ENV_INVALID); - - if (nvrecord_env_p == (struct nvrecord_env_t *)NVRAM_ENV_INVALID) - { - TRACE(0,"NVRAM_ENV_INVALID !!"); - if (nv_record_env_rebuild() < 0) - nRet = -1; - else - TRACE(0,"NVRAM REBUILD SUCCESS !!"); - } - TRACE(2,"%s nvrecord_env_p: 0x%x",__func__, (uint32_t)nvrecord_env_p); - return nRet; -} - -int nv_record_env_get(struct nvrecord_env_t **nvrecord_env) -{ - if (!nvrecord_env) - return -1; - - if (!nvrecord_env_p) - return -1; - - *nvrecord_env = nvrecord_env_p; - - return 0; -} - -int nv_record_env_set(struct nvrecord_env_t *nvrecord_env) -{ - if (!nvrecord_env) - return -1; - - if (!nvrecord_env_p) - return -1; - - nv_record_update_runtime_userdata(); - - return 0; -} - -void nv_record_update_factory_tester_status(uint32_t status) -{ - if (nvrecord_env_p) - { - nvrecord_env_p->factory_tester_status.status = status; - } -} - -void nv_record_update_ibrt_info(uint32_t newMode,bt_bdaddr_t *ibrtPeerAddr) -{ - if (nvrecord_env_p) - { - TRACE(2,"##%s,%d",__func__,newMode); - nvrecord_env_p->ibrt_mode.mode = newMode; - nv_record_config.is_update = true; - memcpy(nvrecord_env_p->ibrt_mode.record.bdAddr.address,ibrtPeerAddr->address,6); - } + memcpy(nvrecord_env_p->ibrt_mode.record.bdAddr.address, + ibrtPeerAddr->address, 6); + } } #endif // #if !defined(NEW_NV_RECORD_ENABLED) - diff --git a/services/nvrecord/nvrecord_fp_account_key.c b/services/nvrecord/nvrecord_fp_account_key.c index c3994cb..d90e950 100644 --- a/services/nvrecord/nvrecord_fp_account_key.c +++ b/services/nvrecord/nvrecord_fp_account_key.c @@ -15,91 +15,83 @@ ****************************************************************************/ #if !defined(NEW_NV_RECORD_ENABLED) -#include -#include "nvrecord.h" #include "nvrecord_fp_account_key.h" +#include "co_math.h" #include "hal_trace.h" -#include "co_math.h" - +#include "nvrecord.h" +#include extern nv_record_struct nv_record_config; static NV_FP_ACCOUNT_KEY_RECORD_T *nvrecord_fp_account_key_p = NULL; -NV_FP_ACCOUNT_KEY_RECORD_T* nv_record_get_fp_data_structure_info(void) -{ - return nvrecord_fp_account_key_p; +NV_FP_ACCOUNT_KEY_RECORD_T *nv_record_get_fp_data_structure_info(void) { + return nvrecord_fp_account_key_p; } -void nv_record_update_fp_data_structure(NV_FP_ACCOUNT_KEY_RECORD_T* pFpData) -{ - if (!memcmp((uint8_t *)pFpData, (uint8_t *)nvrecord_fp_account_key_p, - sizeof(NV_FP_ACCOUNT_KEY_RECORD_T))) - { - // the updated fp data is the same as the local content, do nothing - - } - else - { - TRACE(0,"Fast pair non-volatile data needs to be updated to aligned with peer device."); - *nvrecord_fp_account_key_p = *pFpData; - nv_record_update_runtime_userdata(); - } -} +void nv_record_update_fp_data_structure(NV_FP_ACCOUNT_KEY_RECORD_T *pFpData) { + if (!memcmp((uint8_t *)pFpData, (uint8_t *)nvrecord_fp_account_key_p, + sizeof(NV_FP_ACCOUNT_KEY_RECORD_T))) { + // the updated fp data is the same as the local content, do nothing -void nv_record_fp_account_key_init(void) -{ - if (NULL == nvrecord_fp_account_key_p) - { - nvrecord_fp_account_key_p = - (NV_FP_ACCOUNT_KEY_RECORD_T *)nvrec_config_get_int(nv_record_config.config, - (const char *)section_name_fp_account_key, - (const char *)NV_RECORD_ACCOUNT_KEY, - NVRAM_ACCOUNT_KEY_INVALID); - } - - if ((NV_FP_ACCOUNT_KEY_RECORD_T *)NVRAM_ACCOUNT_KEY_INVALID == nvrecord_fp_account_key_p) - { - nvrecord_fp_account_key_p = (NV_FP_ACCOUNT_KEY_RECORD_T *)pool_malloc(sizeof(NV_FP_ACCOUNT_KEY_RECORD_T)); - if (!nvrecord_fp_account_key_p) - { - ASSERT(0,"%s pool_malloc failed",__func__); - return; - } - - memset(nvrecord_fp_account_key_p, 0, sizeof(NV_FP_ACCOUNT_KEY_RECORD_T)); - - nvrec_config_set_int(nv_record_config.config, section_name_fp_account_key, - (const char *)NV_RECORD_ACCOUNT_KEY, (int)nvrecord_fp_account_key_p); - } -} - -void nv_record_fp_account_key_add(NV_FP_ACCOUNT_KEY_ENTRY_T* param_rec) -{ - TRACE(0,"Add account key:"); - DUMP8("%02x ", param_rec->key, sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); - - if (FP_ACCOUNT_KEY_RECORD_NUM == nvrecord_fp_account_key_p->key_count) - { - // discard the earliest key - memmove((uint8_t *)&(nvrecord_fp_account_key_p->accountKey[0]), - (uint8_t *)&(nvrecord_fp_account_key_p->accountKey[1]), - (FP_ACCOUNT_KEY_RECORD_NUM - 1)*sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); - - nvrecord_fp_account_key_p->key_count--; - } - - memcpy((uint8_t *)&(nvrecord_fp_account_key_p->accountKey[nvrecord_fp_account_key_p->key_count]), - param_rec, - sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); - - nvrecord_fp_account_key_p->key_count++; - + } else { + TRACE(0, "Fast pair non-volatile data needs to be updated to aligned with " + "peer device."); + *nvrecord_fp_account_key_p = *pFpData; nv_record_update_runtime_userdata(); + } +} + +void nv_record_fp_account_key_init(void) { + if (NULL == nvrecord_fp_account_key_p) { + nvrecord_fp_account_key_p = + (NV_FP_ACCOUNT_KEY_RECORD_T *)nvrec_config_get_int( + nv_record_config.config, (const char *)section_name_fp_account_key, + (const char *)NV_RECORD_ACCOUNT_KEY, NVRAM_ACCOUNT_KEY_INVALID); + } + + if ((NV_FP_ACCOUNT_KEY_RECORD_T *)NVRAM_ACCOUNT_KEY_INVALID == + nvrecord_fp_account_key_p) { + nvrecord_fp_account_key_p = (NV_FP_ACCOUNT_KEY_RECORD_T *)pool_malloc( + sizeof(NV_FP_ACCOUNT_KEY_RECORD_T)); + if (!nvrecord_fp_account_key_p) { + ASSERT(0, "%s pool_malloc failed", __func__); + return; + } + + memset(nvrecord_fp_account_key_p, 0, sizeof(NV_FP_ACCOUNT_KEY_RECORD_T)); + + nvrec_config_set_int(nv_record_config.config, section_name_fp_account_key, + (const char *)NV_RECORD_ACCOUNT_KEY, + (int)nvrecord_fp_account_key_p); + } +} + +void nv_record_fp_account_key_add(NV_FP_ACCOUNT_KEY_ENTRY_T *param_rec) { + TRACE(0, "Add account key:"); + DUMP8("%02x ", param_rec->key, sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); + + if (FP_ACCOUNT_KEY_RECORD_NUM == nvrecord_fp_account_key_p->key_count) { + // discard the earliest key + memmove((uint8_t *)&(nvrecord_fp_account_key_p->accountKey[0]), + (uint8_t *)&(nvrecord_fp_account_key_p->accountKey[1]), + (FP_ACCOUNT_KEY_RECORD_NUM - 1) * + sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); + + nvrecord_fp_account_key_p->key_count--; + } + + memcpy((uint8_t *)&(nvrecord_fp_account_key_p + ->accountKey[nvrecord_fp_account_key_p->key_count]), + param_rec, sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); + + nvrecord_fp_account_key_p->key_count++; + + nv_record_update_runtime_userdata(); } void nv_record_fp_account_info_reset(void) { uint8_t size = nv_record_fp_account_key_count(); - for (uint8_t i = 0 ; i < size ; i++){ + for (uint8_t i = 0; i < size; i++) { memset((uint8_t *)&(nvrecord_fp_account_key_p->accountKey[i]), 0, sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); } @@ -108,49 +100,42 @@ void nv_record_fp_account_info_reset(void) { nv_record_fp_update_name(NULL, 0); } -void nv_record_fp_account_key_delete(void) -{ - nv_record_fp_account_info_reset(); +void nv_record_fp_account_key_delete(void) { + nv_record_fp_account_info_reset(); } -bool nv_record_fp_account_key_get_by_index(uint8_t index, uint8_t* outputKey) -{ - if (nvrecord_fp_account_key_p->key_count < (index + 1)) - { - return false; - } - - memcpy(outputKey, (uint8_t *)&(nvrecord_fp_account_key_p->accountKey[index]), - sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); +bool nv_record_fp_account_key_get_by_index(uint8_t index, uint8_t *outputKey) { + if (nvrecord_fp_account_key_p->key_count < (index + 1)) { + return false; + } - TRACE(1,"Get account key %d as:", index); - DUMP8("%02x ", outputKey, sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); - - return true; + memcpy(outputKey, (uint8_t *)&(nvrecord_fp_account_key_p->accountKey[index]), + sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); + + TRACE(1, "Get account key %d as:", index); + DUMP8("%02x ", outputKey, sizeof(NV_FP_ACCOUNT_KEY_ENTRY_T)); + + return true; } -uint8_t nv_record_fp_account_key_count(void) -{ - return nvrecord_fp_account_key_p->key_count; +uint8_t nv_record_fp_account_key_count(void) { + return nvrecord_fp_account_key_p->key_count; } -void nv_record_fp_update_name(uint8_t* ptrName, uint32_t nameLen) -{ - TRACE(1,"update name len %d", nameLen); - - memset(nvrecord_fp_account_key_p->name, 0, FP_MAX_NAME_LEN); - if (nameLen > 0) - { - DUMP8("0x%02x ", ptrName, nameLen); - memcpy(nvrecord_fp_account_key_p->name, ptrName, nameLen); - } - nvrecord_fp_account_key_p->nameLen = nameLen; - nv_record_update_runtime_userdata(); +void nv_record_fp_update_name(uint8_t *ptrName, uint32_t nameLen) { + TRACE(1, "update name len %d", nameLen); + + memset(nvrecord_fp_account_key_p->name, 0, FP_MAX_NAME_LEN); + if (nameLen > 0) { + DUMP8("0x%02x ", ptrName, nameLen); + memcpy(nvrecord_fp_account_key_p->name, ptrName, nameLen); + } + nvrecord_fp_account_key_p->nameLen = nameLen; + nv_record_update_runtime_userdata(); } -uint8_t* nv_record_fp_get_name_ptr(uint32_t* ptrNameLen) -{ - *ptrNameLen = nvrecord_fp_account_key_p->nameLen; - return nvrecord_fp_account_key_p->name; +uint8_t *nv_record_fp_get_name_ptr(uint32_t *ptrNameLen) { + *ptrNameLen = nvrecord_fp_account_key_p->nameLen; + return nvrecord_fp_account_key_p->name; } #endif //#if !defined(NEW_NV_RECORD_ENABLED) diff --git a/services/osif/ddbif_bes.c b/services/osif/ddbif_bes.c index 91bb2f5..81fac60 100644 --- a/services/osif/ddbif_bes.c +++ b/services/osif/ddbif_bes.c @@ -17,16 +17,16 @@ #include #include -#include "hal_trace.h" #include "bluetooth.h" +#include "hal_trace.h" #include "me_api.h" #ifndef FPGA -#include "cmsis_os.h" #include "cmsis.h" +#include "cmsis_os.h" #include "nvrecord.h" -//static int DDB_Print_Node(BtDeviceRecord* record) +// static int DDB_Print_Node(BtDeviceRecord* record) //{ // nvrec_trace(0,"record_bdAddr = "); // OS_DUMP8("%x ",record->bdAddr.addr,sizeof(record->bdAddr.addr)); @@ -41,48 +41,40 @@ // return 1; //} -void ddbif_list_saved_flash(void) -{ - nv_record_flash_flush(); +void ddbif_list_saved_flash(void) { nv_record_flash_flush(); } + +bt_status_t ddbif_close(void) { + ddbif_list_saved_flash(); + return BT_STS_SUCCESS; } -bt_status_t ddbif_close(void) -{ - ddbif_list_saved_flash(); - return BT_STS_SUCCESS; +bt_status_t ddbif_add_record(btif_device_record_t *record) { + return nv_record_add(section_usrdata_ddbrecord, (void *)record); } -bt_status_t ddbif_add_record(btif_device_record_t *record) -{ - return nv_record_add(section_usrdata_ddbrecord,(void *)record); +bt_status_t ddbif_open(const bt_bdaddr_t *bdAddr) { + bt_status_t status = BT_STS_FAILED; + status = nv_record_open(section_usrdata_ddbrecord); + + return status; } -bt_status_t ddbif_open(const bt_bdaddr_t *bdAddr) -{ - bt_status_t status = BT_STS_FAILED; - status = nv_record_open(section_usrdata_ddbrecord); - - return status; +bt_status_t ddbif_find_record(const bt_bdaddr_t *bdAddr, + btif_device_record_t *record) { + return nv_record_ddbrec_find(bdAddr, record); } -bt_status_t ddbif_find_record(const bt_bdaddr_t *bdAddr, btif_device_record_t *record) -{ - return nv_record_ddbrec_find(bdAddr,record); +bt_status_t ddbif_delete_record(const bt_bdaddr_t *bdAddr) { + return nv_record_ddbrec_delete(bdAddr); } -bt_status_t ddbif_delete_record(const bt_bdaddr_t *bdAddr) -{ - return nv_record_ddbrec_delete(bdAddr); -} - -bt_status_t ddbif_enum_device_records(I16 index, btif_device_record_t *record) -{ - return nv_record_enum_dev_records((unsigned short)index,record); +bt_status_t ddbif_enum_device_records(I16 index, btif_device_record_t *record) { + return nv_record_enum_dev_records((unsigned short)index, record); } #else typedef struct _DDB_List { - struct _DDB_List *next; - btif_device_record_t *record; + struct _DDB_List *next; + btif_device_record_t *record; } DDB_List; static DDB_List *head = NULL; @@ -90,317 +82,308 @@ static bt_bdaddr_t remDev_addr; static int DDB_Print_Node(btif_device_record_t *record); static int DDB_Print(); -static void *DDB_Malloc (uint32_t size) -{ - return malloc(size); +static void *DDB_Malloc(uint32_t size) { return malloc(size); } + +static void DDB_Free(void *p_mem) { free(p_mem); } + +static char POSSIBLY_UNUSED Hex2String(unsigned char *src, char *dest, + unsigned int srcLen, + unsigned int destLen) { + unsigned int i = 0; + unsigned char hb = 0, lb = 0; + + memset((char *)dest, 0, destLen); + for (i = 0; i < srcLen; i++) { + hb = (src[i] & 0xf0) >> 4; + if (hb >= 0 && hb <= 9) + hb += 0x30; + else if (hb >= 10 && hb <= 15) + hb = hb - 10 + 'A'; + else + return 0; + + lb = src[i] & 0x0f; + if (lb >= 0 && lb <= 9) + lb += 0x30; + else if (lb >= 10 && lb <= 15) + lb = lb - 10 + 'A'; + else + return 0; + + dest[i * 2 + 0] = hb; + dest[i * 2 + 1] = lb; + } + + return 1; } -static void DDB_Free (void *p_mem) -{ - free(p_mem); +static void DDB_List_delete(DDB_List *list_head) { + DDB_List *list = list_head, *list_tmp = NULL; + + while (NULL != list) { + list_tmp = list; + if (NULL != list->record) + DDB_Free(list->record); + + list = list->next; + DDB_Free(list_tmp); + } } -static char POSSIBLY_UNUSED Hex2String(unsigned char *src, char* dest, - unsigned int srcLen, - unsigned int destLen) -{ - unsigned int i = 0; - unsigned char hb = 0, lb = 0; +bt_status_t ddbif_close(void) { + DDB_List *Close_tmp = NULL; + Close_tmp = head; - memset((char *)dest, 0, destLen); - for(i = 0 ; i < srcLen ; i++) { - hb = (src[i]&0xf0)>>4; - if( hb >= 0 && hb <= 9) - hb += 0x30; - else if( hb>=10 &&hb <=15 ) - hb = hb -10 + 'A'; - else - return 0; + while (1) { + DDB_Print(); - lb = src[i]&0x0f; - if( lb>=0 && lb<=9 ) - lb += 0x30; - else if( lb>=10 && lb<=15 ) - lb = lb - 10 + 'A'; - else - return 0; - - dest[i*2+0] = hb; - dest[i*2+1] = lb; + Close_tmp = Close_tmp->next; + if (Close_tmp == NULL) { + TRACE(0, "DDB_Close.\n"); + break; } + } - return 1; + DDB_List_delete(head); + return BT_STS_SUCCESS; } -static void DDB_List_delete(DDB_List *list_head) -{ - DDB_List *list = list_head,*list_tmp = NULL; +bt_status_t ddbif_add_record(btif_device_record_t *record) { + DDB_List *ptr = NULL; + DDB_List *tmp = NULL; + ptr = head; - while(NULL != list) { - list_tmp = list; - if(NULL != list->record) - DDB_Free(list->record); + tmp = (DDB_List *)DDB_Malloc(sizeof(DDB_List)); + if (tmp == NULL) { + TRACE( + 0, + "DDB_AddRecord head == NULL:There is no enough space for DDB_List.\n"); + return BT_STS_FAILED; + } + tmp->next = NULL; - list = list->next; - DDB_Free(list_tmp); - } -} + tmp->record = + (btif_device_record_t *)DDB_Malloc(sizeof(btif_device_record_t)); + if (NULL == tmp->record) { + TRACE(0, "DDB_AddRecord head == NULL:There is no enough space for " + "DDB_List.record.\n"); + return BT_STS_FAILED; + } -bt_status_t ddbif_close(void) -{ - DDB_List *Close_tmp = NULL; - Close_tmp = head; + if (head == NULL) { + memcpy(tmp->record->bdAddr.address, record->bdAddr.address, + sizeof(record->bdAddr.address)); + tmp->record->keyType = record->keyType; + memcpy(tmp->record->linkKey, record->linkKey, sizeof(record->linkKey)); + tmp->record->pinLen = record->pinLen; + tmp->record->trusted = record->trusted; - while(1) { - DDB_Print(); + head = tmp; + memcpy(remDev_addr.address, tmp->record->bdAddr.address, + sizeof(tmp->record->bdAddr.address)); + TRACE(0, "DDB_AddRecord head:\n"); + DDB_Print_Node(tmp->record); + DDB_Print(); - Close_tmp = Close_tmp->next; - if(Close_tmp == NULL) { - TRACE(0,"DDB_Close.\n"); - break; - } - } - - DDB_List_delete(head); return BT_STS_SUCCESS; -} + } -bt_status_t ddbif_add_record(btif_device_record_t *record) -{ - DDB_List *ptr = NULL; - DDB_List *tmp = NULL; - ptr = head; + while ((ptr->next != NULL) && + (memcmp(ptr->record->bdAddr.address, record->bdAddr.address, + sizeof(ptr->record->bdAddr.address)))) { + ptr = ptr->next; + } - tmp = (DDB_List *)DDB_Malloc(sizeof(DDB_List)); - if(tmp == NULL) { - TRACE(0,"DDB_AddRecord head == NULL:There is no enough space for DDB_List.\n"); - return BT_STS_FAILED; - } + if (!memcmp(ptr->record->bdAddr.address, record->bdAddr.address, + sizeof(ptr->record->bdAddr.address))) { + ptr->record->keyType = record->keyType; + memcpy(ptr->record->linkKey, record->linkKey, sizeof(record->linkKey)); + ptr->record->pinLen = record->pinLen; + ptr->record->trusted = record->trusted; + TRACE(0, "DDB_AddRecord head::\n"); + DDB_Print_Node(ptr->record); + DDB_Print(); + free(tmp->record); + free(tmp); + return BT_STS_SUCCESS; + } + + if (ptr->next == NULL) { tmp->next = NULL; + memcpy(tmp->record->bdAddr.address, record->bdAddr.address, + sizeof(record->bdAddr.address)); + tmp->record->keyType = record->keyType; + memcpy(tmp->record->linkKey, record->linkKey, sizeof(record->linkKey)); + tmp->record->pinLen = record->pinLen; + tmp->record->trusted = record->trusted; - tmp->record = (btif_device_record_t *)DDB_Malloc(sizeof(btif_device_record_t)); - if(NULL == tmp->record) { - TRACE(0,"DDB_AddRecord head == NULL:There is no enough space for DDB_List.record.\n"); - return BT_STS_FAILED; - } + memcpy(remDev_addr.address, tmp->record->bdAddr.address, + sizeof(tmp->record->bdAddr.address)); - if(head == NULL) { - memcpy(tmp->record->bdAddr.address,record->bdAddr.address,sizeof(record->bdAddr.address)); - tmp->record->keyType = record->keyType; - memcpy(tmp->record->linkKey,record->linkKey,sizeof(record->linkKey)); - tmp->record->pinLen = record->pinLen; - tmp->record->trusted = record->trusted; + ptr->next = tmp; + TRACE(0, "DDB_AddRecord head:::\n"); + DDB_Print_Node(tmp->record); + DDB_Print(); - head = tmp; - memcpy(remDev_addr.address,tmp->record->bdAddr.address,sizeof(tmp->record->bdAddr.address)); - TRACE(0,"DDB_AddRecord head:\n"); - DDB_Print_Node(tmp->record); - DDB_Print(); - - return BT_STS_SUCCESS; - } - - while((ptr->next != NULL) && - (memcmp(ptr->record->bdAddr.address, record->bdAddr.address, - sizeof(ptr->record->bdAddr.address)))) { - ptr = ptr->next; - } - - if(!memcmp(ptr->record->bdAddr.address, record->bdAddr.address, - sizeof(ptr->record->bdAddr.address))) { - ptr->record->keyType = record->keyType; - memcpy(ptr->record->linkKey,record->linkKey,sizeof(record->linkKey)); - ptr->record->pinLen = record->pinLen; - ptr->record->trusted = record->trusted; - TRACE(0,"DDB_AddRecord head::\n"); - DDB_Print_Node(ptr->record); - DDB_Print(); - free(tmp->record); - free(tmp); - return BT_STS_SUCCESS; - } - - if(ptr->next == NULL) { - tmp->next = NULL; - memcpy(tmp->record->bdAddr.address,record->bdAddr.address,sizeof(record->bdAddr.address)); - tmp->record->keyType = record->keyType; - memcpy(tmp->record->linkKey,record->linkKey,sizeof(record->linkKey)); - tmp->record->pinLen = record->pinLen; - tmp->record->trusted = record->trusted; - - memcpy(remDev_addr.address,tmp->record->bdAddr.address,sizeof(tmp->record->bdAddr.address)); - - ptr->next = tmp; - TRACE(0,"DDB_AddRecord head:::\n"); - DDB_Print_Node(tmp->record); - DDB_Print(); - - return BT_STS_SUCCESS; - } - - return BT_STS_FAILED; -} - - -bt_status_t ddbif_open(const bt_bdaddr_t *bdAddr) -{ -// DDB_List *head = NULL; return BT_STS_SUCCESS; + } + + return BT_STS_FAILED; } -static int DDB_Print_Node(btif_device_record_t *record) -{ - int i; - - for(i = 0; i < 6; i++) { - TRACE(1,"%x ",record->bdAddr.address[i]); - } - TRACE(0,"\n"); -/* - for(i=0; i<16; i++) - { - TRACE(1,"%x ",record->linkKey[i]); - } - TRACE(0,"\n"); - - TRACE(3,"%d,%d,%d\n",record->keyType,record->pinLen,record->trusted); - */ - return 1; - +bt_status_t ddbif_open(const bt_bdaddr_t *bdAddr) { + // DDB_List *head = NULL; + return BT_STS_SUCCESS; } -static int DDB_Print() -{ - DDB_List *Print_tmp = NULL; - Print_tmp = head; +static int DDB_Print_Node(btif_device_record_t *record) { + int i; - if(Print_tmp == NULL) { - TRACE(0,"DDB list is null!\n"); - return 0; - } + for (i = 0; i < 6; i++) { + TRACE(1, "%x ", record->bdAddr.address[i]); + } + TRACE(0, "\n"); + /* + for(i=0; i<16; i++) + { + TRACE(1,"%x ",record->linkKey[i]); + } + TRACE(0,"\n"); - TRACE(0,"-----------------DDB list-------------------\n"); - while(Print_tmp != NULL) { - DDB_Print_Node(Print_tmp->record); - Print_tmp = Print_tmp->next; - } - TRACE(0,"--------------------end---------------------\n"); + TRACE(3,"%d,%d,%d\n",record->keyType,record->pinLen,record->trusted); + */ + return 1; +} + +static int DDB_Print() { + DDB_List *Print_tmp = NULL; + Print_tmp = head; + + if (Print_tmp == NULL) { + TRACE(0, "DDB list is null!\n"); return 0; + } + + TRACE(0, "-----------------DDB list-------------------\n"); + while (Print_tmp != NULL) { + DDB_Print_Node(Print_tmp->record); + Print_tmp = Print_tmp->next; + } + TRACE(0, "--------------------end---------------------\n"); + return 0; } -bt_status_t ddbif_find_record(const bt_bdaddr_t *bdAddr, btif_device_record_t *record) -{ - DDB_List *FindRecord_tmp = NULL; - FindRecord_tmp = head; - - if(head == NULL) { - TRACE(0,"DDB_FindRecord:DDB is null!\n"); - return BT_STS_FAILED; - } - - while(memcmp(FindRecord_tmp->record->bdAddr.address, bdAddr->address, - sizeof(FindRecord_tmp->record->bdAddr.address)) && (FindRecord_tmp->next != NULL)) { - FindRecord_tmp = FindRecord_tmp->next; - } - - if(!memcmp(FindRecord_tmp->record->bdAddr.address,bdAddr->address, - sizeof(FindRecord_tmp->record->bdAddr.address))) { - memcpy(record->bdAddr.address, FindRecord_tmp->record->bdAddr.address, - sizeof(FindRecord_tmp->record->bdAddr.address)); - record->keyType = FindRecord_tmp->record->keyType; - memcpy(record->linkKey,FindRecord_tmp->record->linkKey, - sizeof(FindRecord_tmp->record->linkKey)); - record->pinLen = FindRecord_tmp->record->pinLen; - record->trusted = FindRecord_tmp->record->trusted; - TRACE(0,"DDB_FindRecord:\n"); - DDB_Print_Node(record); - return BT_STS_SUCCESS; - } - - if(FindRecord_tmp->next == NULL) { - TRACE(0,"DDB_FindRecord ends.\n"); - return BT_STS_FAILED; - } +bt_status_t ddbif_find_record(const bt_bdaddr_t *bdAddr, + btif_device_record_t *record) { + DDB_List *FindRecord_tmp = NULL; + FindRecord_tmp = head; + if (head == NULL) { + TRACE(0, "DDB_FindRecord:DDB is null!\n"); return BT_STS_FAILED; + } + + while (memcmp(FindRecord_tmp->record->bdAddr.address, bdAddr->address, + sizeof(FindRecord_tmp->record->bdAddr.address)) && + (FindRecord_tmp->next != NULL)) { + FindRecord_tmp = FindRecord_tmp->next; + } + + if (!memcmp(FindRecord_tmp->record->bdAddr.address, bdAddr->address, + sizeof(FindRecord_tmp->record->bdAddr.address))) { + memcpy(record->bdAddr.address, FindRecord_tmp->record->bdAddr.address, + sizeof(FindRecord_tmp->record->bdAddr.address)); + record->keyType = FindRecord_tmp->record->keyType; + memcpy(record->linkKey, FindRecord_tmp->record->linkKey, + sizeof(FindRecord_tmp->record->linkKey)); + record->pinLen = FindRecord_tmp->record->pinLen; + record->trusted = FindRecord_tmp->record->trusted; + TRACE(0, "DDB_FindRecord:\n"); + DDB_Print_Node(record); + return BT_STS_SUCCESS; + } + + if (FindRecord_tmp->next == NULL) { + TRACE(0, "DDB_FindRecord ends.\n"); + return BT_STS_FAILED; + } + + return BT_STS_FAILED; } -bt_status_t ddbif_delete_record(const bt_bdaddr_t *bdAddr) -{ - DDB_List *checkingAddr = NULL; - DDB_List *checkedAddr = NULL; - checkingAddr = head; - - if(head == NULL) { - TRACE(0,"DDB_DeleteRecord:list is null!\n"); - return BT_STS_FAILED; - } - - while(memcmp(checkingAddr->record->bdAddr.address,bdAddr->address, - sizeof(checkingAddr->record->bdAddr.address)) && (checkingAddr->next != NULL)) { - checkedAddr = checkingAddr; - checkingAddr = checkingAddr->next; - } - - if(!memcmp(checkingAddr->record->bdAddr.address,bdAddr->address, - sizeof(checkingAddr->record->bdAddr.address))) { - if(checkingAddr == head) { - head = checkingAddr->next; - free(checkingAddr->record); - free(checkingAddr); - - DDB_Print(); - return BT_STS_SUCCESS; - } else { - checkedAddr->next = checkingAddr->next; - free(checkingAddr->record); - free(checkingAddr); - - DDB_Print(); - return BT_STS_SUCCESS; - } - } - - if(checkingAddr->next == NULL) { - return BT_STS_FAILED; - } +bt_status_t ddbif_delete_record(const bt_bdaddr_t *bdAddr) { + DDB_List *checkingAddr = NULL; + DDB_List *checkedAddr = NULL; + checkingAddr = head; + if (head == NULL) { + TRACE(0, "DDB_DeleteRecord:list is null!\n"); return BT_STS_FAILED; + } + + while (memcmp(checkingAddr->record->bdAddr.address, bdAddr->address, + sizeof(checkingAddr->record->bdAddr.address)) && + (checkingAddr->next != NULL)) { + checkedAddr = checkingAddr; + checkingAddr = checkingAddr->next; + } + + if (!memcmp(checkingAddr->record->bdAddr.address, bdAddr->address, + sizeof(checkingAddr->record->bdAddr.address))) { + if (checkingAddr == head) { + head = checkingAddr->next; + free(checkingAddr->record); + free(checkingAddr); + + DDB_Print(); + return BT_STS_SUCCESS; + } else { + checkedAddr->next = checkingAddr->next; + free(checkingAddr->record); + free(checkingAddr); + + DDB_Print(); + return BT_STS_SUCCESS; + } + } + + if (checkingAddr->next == NULL) { + return BT_STS_FAILED; + } + + return BT_STS_FAILED; } -bt_status_t ddbif_enum_device_records(I16 index, btif_device_record_t *record) -{ - DDB_List *databaselist; - databaselist = head; - - if(head == NULL) { - TRACE(0,"DDB_EnumDeviceRecords:No records!\n"); - return BT_STS_FAILED; - } - - TRACE(1,"index=%d\n",(uint32_t)index); - while(databaselist != NULL) { - if(!index) { - break; - } - databaselist = databaselist->next; - index--; - } - - if((index == 0) && (databaselist != NULL)) { - TRACE(0,"Enum record:\n"); - DDB_Print_Node(databaselist->record); - TRACE(0,"Enumeration ends!\n\n"); - return BT_STS_SUCCESS; - } - - if(databaselist == NULL) { - TRACE(0,"Enumeration failed.\n"); - return BT_STS_FAILED; - } +bt_status_t ddbif_enum_device_records(I16 index, btif_device_record_t *record) { + DDB_List *databaselist; + databaselist = head; + if (head == NULL) { + TRACE(0, "DDB_EnumDeviceRecords:No records!\n"); return BT_STS_FAILED; + } + + TRACE(1, "index=%d\n", (uint32_t)index); + while (databaselist != NULL) { + if (!index) { + break; + } + databaselist = databaselist->next; + index--; + } + + if ((index == 0) && (databaselist != NULL)) { + TRACE(0, "Enum record:\n"); + DDB_Print_Node(databaselist->record); + TRACE(0, "Enumeration ends!\n\n"); + return BT_STS_SUCCESS; + } + + if (databaselist == NULL) { + TRACE(0, "Enumeration failed.\n"); + return BT_STS_FAILED; + } + + return BT_STS_FAILED; } #endif - - diff --git a/services/osif/osif_rtx.c b/services/osif/osif_rtx.c index f11c3fc..8a2a934 100644 --- a/services/osif/osif_rtx.c +++ b/services/osif/osif_rtx.c @@ -15,17 +15,16 @@ * ****************************************************************************/ +#include "cmsis_os.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "osif.h" #include #include #include -#include "cmsis_os.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "hal_trace.h" -#include "osif.h" - -extern osMessageQId evm_queue_id; +extern osMessageQId evm_queue_id; static void __timer_wrapper_callback(void const *n); static osif_timer_callback __timer_wrapper_notify_func = NULL; @@ -33,163 +32,137 @@ static osTimerId __timer_wrapper_id = NULL; osTimerDef(__timer_wrapper__, __timer_wrapper_callback); osMutexId __mutex_wrapper_id = NULL; -osMutexDef (__mutex_wrapper); +osMutexDef(__mutex_wrapper); osMutexId __mutex_stophardware_id = NULL; osMutexDef(__mutex_stophardware); -bool osif_init(void) -{ - if (__mutex_wrapper_id == NULL) - __mutex_wrapper_id = osMutexCreate((osMutex(__mutex_wrapper))); +bool osif_init(void) { + if (__mutex_wrapper_id == NULL) + __mutex_wrapper_id = osMutexCreate((osMutex(__mutex_wrapper))); - if (__mutex_stophardware_id == NULL) - __mutex_stophardware_id = osMutexCreate((osMutex(__mutex_stophardware))); + if (__mutex_stophardware_id == NULL) + __mutex_stophardware_id = osMutexCreate((osMutex(__mutex_stophardware))); - if (__timer_wrapper_id == NULL) - __timer_wrapper_id = osTimerCreate(osTimer(__timer_wrapper__), osTimerOnce, (void *)0); + if (__timer_wrapper_id == NULL) + __timer_wrapper_id = + osTimerCreate(osTimer(__timer_wrapper__), osTimerOnce, (void *)0); - return true; + return true; } -uint32_t osif_get_sys_time(void) -{ - return hal_sys_timer_get(); +uint32_t osif_get_sys_time(void) { return hal_sys_timer_get(); } + +uint16_t osif_rand(void) { return rand(); } + +void osif_stop_hardware(void) { + osMutexWait(__mutex_stophardware_id, osWaitForever); } -uint16_t osif_rand(void) -{ - return rand(); +void osif_resume_hardware(void) { osMutexRelease(__mutex_stophardware_id); } + +void osif_memcopy(uint8_t *dest, const uint8_t *source, uint32_t numBytes) { + memcpy(dest, source, numBytes); } -void osif_stop_hardware(void) -{ - osMutexWait(__mutex_stophardware_id, osWaitForever); +bool osif_memcmp(const uint8_t *buffer1, uint16_t len1, const uint8_t *buffer2, + uint16_t len2) { + int r = 0; + r = memcmp(buffer1, buffer2, len1 > len2 ? len2 : len1); + return (r == 0 ? 1 : 0); } -void osif_resume_hardware(void) -{ - osMutexRelease(__mutex_stophardware_id); +void osif_memset(uint8_t *dest, uint8_t byte, uint32_t len) { + memset(dest, byte, len); } -void osif_memcopy(uint8_t *dest, const uint8_t *source, uint32_t numBytes) -{ - memcpy(dest, source, numBytes); +uint8_t osif_strcmp(const char *Str1, const char *Str2) { + int r = 0; + r = strcmp(Str1, Str2); + return (r == 0 ? 0 : 1); } -bool osif_memcmp(const uint8_t *buffer1, uint16_t len1, const uint8_t *buffer2, uint16_t len2) -{ - int r = 0; - r = memcmp(buffer1, buffer2, len1>len2?len2:len1); - return (r == 0?1:0); -} +uint16_t osif_strlen(const char *Str) { return strlen(Str); } -void osif_memset(uint8_t *dest, uint8_t byte, uint32_t len) -{ - memset(dest, byte, len); -} - -uint8_t osif_strcmp(const char *Str1, const char *Str2) -{ - int r = 0; - r = strcmp(Str1, Str2); - return (r == 0?0:1); -} - -uint16_t osif_strlen(const char *Str) -{ - return strlen(Str); -} - -void osif_assert(const char *expression, const char *file, uint16_t line) -{ - ASSERT(0,"OS_Assert exp: %s, func: %s, line %d\r\n", expression, file, line); - while(1); +void osif_assert(const char *expression, const char *file, uint16_t line) { + ASSERT(0, "OS_Assert exp: %s, func: %s, line %d\r\n", expression, file, line); + while (1) + ; } extern void OS_LockStack_Info_Print(void); -void osif_lock_stack(void) -{ - osThreadId request = 0; +void osif_lock_stack(void) { + osThreadId request = 0; #if (osCMSIS < 0x20000U) - osThreadId hold = 0; + osThreadId hold = 0; #endif - unsigned int t = 0; - osStatus status; - bool success; + unsigned int t = 0; + osStatus status; + bool success; - if(NULL == __mutex_wrapper_id) - return; + if (NULL == __mutex_wrapper_id) + return; - request = osThreadGetId(); + request = osThreadGetId(); #if (osCMSIS < 0x20000U) - hold = osMutexGetOwner(__mutex_wrapper_id); + hold = osMutexGetOwner(__mutex_wrapper_id); #endif - t = hal_sys_timer_get(); - status = osMutexWait(__mutex_wrapper_id, 8000); - t = TICKS_TO_MS(hal_sys_timer_get()-t); + t = hal_sys_timer_get(); + status = osMutexWait(__mutex_wrapper_id, 8000); + t = TICKS_TO_MS(hal_sys_timer_get() - t); - if ((t > 10) || (status != osOK)) { - TRACE(2,"stack lock wait %d ms, status=0x%x", t, status); - TRACE(1,"request thread=%p", request); + if ((t > 10) || (status != osOK)) { + TRACE(2, "stack lock wait %d ms, status=0x%x", t, status); + TRACE(1, "request thread=%p", request); #if (osCMSIS < 0x20000U) - TRACE(1,"hold thread=%p", hold); + TRACE(1, "hold thread=%p", hold); #endif - } + } - success = (status == osOK); - if (!success) { - TRACE(1,"request thread=%p", request); + success = (status == osOK); + if (!success) { + TRACE(1, "request thread=%p", request); #if (osCMSIS < 0x20000U) - osThreadShow(request); - TRACE(1,"hold thread=%p", hold); - osThreadShow(hold); + osThreadShow(request); + TRACE(1, "hold thread=%p", hold); + osThreadShow(hold); #endif - OS_LockStack_Info_Print(); - ASSERT(0,"cannot lock stack %d\n", status); - return; - } + OS_LockStack_Info_Print(); + ASSERT(0, "cannot lock stack %d\n", status); + return; + } } -void osif_unlock_stack(void) -{ - if(NULL == __mutex_wrapper_id) - return; +void osif_unlock_stack(void) { + if (NULL == __mutex_wrapper_id) + return; - osMutexRelease(__mutex_wrapper_id); + osMutexRelease(__mutex_wrapper_id); } -extern uint32_t rt_mbx_check (void* mailbox); +extern uint32_t rt_mbx_check(void *mailbox); -void osif_notify_evm(void) -{ - if (osMessageGetSpace (evm_queue_id) > 5 ) { - osMessagePut(evm_queue_id, 0xFF, 0); - } +void osif_notify_evm(void) { + if (osMessageGetSpace(evm_queue_id) > 5) { + osMessagePut(evm_queue_id, 0xFF, 0); + } } -static void __timer_wrapper_callback(void const *n) -{ - if(__timer_wrapper_notify_func) - __timer_wrapper_notify_func(); +static void __timer_wrapper_callback(void const *n) { + if (__timer_wrapper_notify_func) + __timer_wrapper_notify_func(); } -void osif_start_timer(osif_timer_t t, osif_timer_callback func) -{ - __timer_wrapper_notify_func = func; +void osif_start_timer(osif_timer_t t, osif_timer_callback func) { + __timer_wrapper_notify_func = func; - osTimerStart(__timer_wrapper_id, (t>>4)+0x5); + osTimerStart(__timer_wrapper_id, (t >> 4) + 0x5); } -void osif_cancel_timer(void) -{ - osTimerStop(__timer_wrapper_id); -} +void osif_cancel_timer(void) { osTimerStop(__timer_wrapper_id); } -uint8_t osif_lock_is_exist(void) -{ - if(NULL == __mutex_wrapper_id) - return 0; - else - return 1; +uint8_t osif_lock_is_exist(void) { + if (NULL == __mutex_wrapper_id) + return 0; + else + return 1; } - diff --git a/services/ota/ota_common.cpp b/services/ota/ota_common.cpp index 69de47c..ad26934 100644 --- a/services/ota/ota_common.cpp +++ b/services/ota/ota_common.cpp @@ -18,28 +18,28 @@ */ /*****************************header include********************************/ -#include "string.h" -#include "cmsis.h" -#include "hal_timer.h" -#include "norflash_drv.h" -#include "norflash_api.h" -#include "crc32.h" -#include "bt_drv_reg_op.h" -#include "app_bt.h" -#include "app.h" -#include "apps.h" -#include "nvrecord_ota.h" -#include "app_utils.h" -#include "ota_dbg.h" #include "ota_common.h" +#include "app.h" +#include "app_bt.h" +#include "app_utils.h" +#include "apps.h" +#include "bt_drv_reg_op.h" +#include "cmsis.h" +#include "crc32.h" +#include "hal_timer.h" +#include "norflash_api.h" +#include "norflash_drv.h" +#include "nvrecord_ota.h" +#include "ota_dbg.h" +#include "string.h" #ifdef IBRT -#include "app_tws_ibrt.h" -#include "app_tws_ctrl_thread.h" -#include "app_ibrt_ota_cmd.h" -#include "app_tws_if.h" -#include "app_ibrt_ui.h" #include "app_ibrt_if.h" +#include "app_ibrt_ota_cmd.h" +#include "app_ibrt_ui.h" +#include "app_tws_ctrl_thread.h" +#include "app_tws_ibrt.h" +#include "app_tws_if.h" #endif /*********************external function declearation************************/ @@ -53,18 +53,20 @@ #define NORFLASH_API_MODE_ASYNC true #define OTA_DEFAULT_NORFLASH_API_MODE NORFLASH_API_MODE_ASYNC -#define CASES(prefix, item) \ - case prefix##item: \ - str = #item; \ - break; +#define CASES(prefix, item) \ + case prefix##item: \ + str = #item; \ + break; /************************private type defination****************************/ /**********************private function declearation************************/ /************************private variable defination************************/ -__attribute__((unused)) static const char *imageSanityKeyWord = "CRC32_OF_IMAGE=0x"; -__attribute__((unused)) static const char *oldImageSanityKeyWord = "CRC32_OF_IMAGE="; +__attribute__((unused)) static const char *imageSanityKeyWord = + "CRC32_OF_IMAGE=0x"; +__attribute__((unused)) static const char *oldImageSanityKeyWord = + "CRC32_OF_IMAGE="; #ifdef IBRT static void _ota_tws_thread(const void *arg); @@ -92,7 +94,6 @@ uint8_t relayBuf[TWS_RELAY_DATA_MAX_SIZE]; OTA_COMMON_ENV_T otaEnv; - /****************************function defination****************************/ /** @@ -101,27 +102,25 @@ OTA_COMMON_ENV_T otaEnv; * @param cmd @see OTA_COMMAND_E * @return char* string of OTA_COMMAND */ -static char *_cmd2str(OTA_COMMAND_E cmd) -{ - const char *str = NULL; +static char *_cmd2str(OTA_COMMAND_E cmd) { + const char *str = NULL; - switch (cmd) - { - CASES(OTA_COMMAND_, BEGIN); - CASES(OTA_COMMAND_, APPLY); - CASES(OTA_COMMAND_, DATA); - CASES(OTA_COMMAND_, ABORT); + switch (cmd) { + CASES(OTA_COMMAND_, BEGIN); + CASES(OTA_COMMAND_, APPLY); + CASES(OTA_COMMAND_, DATA); + CASES(OTA_COMMAND_, ABORT); #ifdef IBRT - CASES(OTA_COMMAND_, RSP); + CASES(OTA_COMMAND_, RSP); #endif - // CASES(OTA_COMMAND_, ); + // CASES(OTA_COMMAND_, ); - default: - str = "INVALID"; - break; - } + default: + str = "INVALID"; + break; + } - return (char *)str; + return (char *)str; } /** @@ -130,25 +129,23 @@ static char *_cmd2str(OTA_COMMAND_E cmd) * @param user @see OTA_USER_E * @return char* OTA_USER string */ -static char *_user2str(OTA_USER_E user) -{ - const char *str = NULL; +static char *_user2str(OTA_USER_E user) { + const char *str = NULL; - switch (user) - { - CASES(OTA_USER_, BES); - CASES(OTA_USER_, COLORFUL); - CASES(OTA_USER_, RED); - CASES(OTA_USER_, ORANGE); - CASES(OTA_USER_, GREEN); - // CASES(OTA_USER_, ); + switch (user) { + CASES(OTA_USER_, BES); + CASES(OTA_USER_, COLORFUL); + CASES(OTA_USER_, RED); + CASES(OTA_USER_, ORANGE); + CASES(OTA_USER_, GREEN); + // CASES(OTA_USER_, ); - default: - str = "INVALID"; - break; - } + default: + str = "INVALID"; + break; + } - return (char *)str; + return (char *)str; } /** @@ -157,22 +154,20 @@ static char *_user2str(OTA_USER_E user) * @param path @see OTA_PATH_E * @return char* OTA_PATH string */ -static char *_path2str(OTA_PATH_E path) -{ - const char *str = NULL; +static char *_path2str(OTA_PATH_E path) { + const char *str = NULL; - switch (path) - { - CASES(OTA_PATH_, BT); - CASES(OTA_PATH_, BLE); - // CASES(OTA_PATH_, ); + switch (path) { + CASES(OTA_PATH_, BT); + CASES(OTA_PATH_, BLE); + // CASES(OTA_PATH_, ); - default: - str = "INVALID"; - break; - } + default: + str = "INVALID"; + break; + } - return (char *)str; + return (char *)str; } /** @@ -181,44 +176,40 @@ static char *_path2str(OTA_PATH_E path) * @param stage @see OTA_STAGE_E * @return char* OTA_STAGE string */ -static char *_stage2str(OTA_STAGE_E stage) -{ - const char *str = NULL; +static char *_stage2str(OTA_STAGE_E stage) { + const char *str = NULL; - switch (stage) - { - CASES(OTA_STAGE_, IDLE); - CASES(OTA_STAGE_, ONGOING); - CASES(OTA_STAGE_, DONE); - // CASES(OTA_STAGE_, ); + switch (stage) { + CASES(OTA_STAGE_, IDLE); + CASES(OTA_STAGE_, ONGOING); + CASES(OTA_STAGE_, DONE); + // CASES(OTA_STAGE_, ); - default: - str = "INVALID"; - break; - } + default: + str = "INVALID"; + break; + } - return (char *)str; + return (char *)str; } -static char *_sts2str(OTA_STATUS_E sts) -{ - const char *str = NULL; +static char *_sts2str(OTA_STATUS_E sts) { + const char *str = NULL; - switch (sts) - { - CASES(OTA_STATUS_, OK); - CASES(OTA_STATUS_, ERROR); - CASES(OTA_STATUS_, ERROR_RELAY_TIMEOUT); - CASES(OTA_STATUS_, ERROR_CHECKSUM); - CASES(OTA_STATUS_, ERROR_NOT_ALLOWED); - // CASES(OTA_STATUS_, ); + switch (sts) { + CASES(OTA_STATUS_, OK); + CASES(OTA_STATUS_, ERROR); + CASES(OTA_STATUS_, ERROR_RELAY_TIMEOUT); + CASES(OTA_STATUS_, ERROR_CHECKSUM); + CASES(OTA_STATUS_, ERROR_NOT_ALLOWED); + // CASES(OTA_STATUS_, ); - default: - str = "INVALID"; - break; - } + default: + str = "INVALID"; + break; + } - return (char *)str; + return (char *)str; } /** @@ -236,35 +227,27 @@ static char *_sts2str(OTA_STATUS_E sts) * @return int32_t index of the key word in dstArry */ __attribute__((unused)) static int32_t _find_key_word(uint8_t *tgtArray, - uint32_t tgtArrayLen, - uint8_t *keyArray, - uint32_t keyArrayLen) -{ - if ((keyArrayLen > 0) && (tgtArrayLen >= keyArrayLen)) - { - uint32_t index = 0, targetIndex = 0; - for (targetIndex = 0; targetIndex < tgtArrayLen; targetIndex++) - { - for (index = 0; index < keyArrayLen; index++) - { - if (tgtArray[targetIndex + index] != keyArray[index]) - { - break; - } - } - - if (index == keyArrayLen) - { - return targetIndex; - } + uint32_t tgtArrayLen, + uint8_t *keyArray, + uint32_t keyArrayLen) { + if ((keyArrayLen > 0) && (tgtArrayLen >= keyArrayLen)) { + uint32_t index = 0, targetIndex = 0; + for (targetIndex = 0; targetIndex < tgtArrayLen; targetIndex++) { + for (index = 0; index < keyArrayLen; index++) { + if (tgtArray[targetIndex + index] != keyArray[index]) { + break; } + } - return -1; - } - else - { - return -1; + if (index == keyArrayLen) { + return targetIndex; + } } + + return -1; + } else { + return -1; + } } /** @@ -273,24 +256,16 @@ __attribute__((unused)) static int32_t _find_key_word(uint8_t *tgtArray, * @param asciiCode ASCII code to convert * @return uint8_t convert result */ -__attribute__((unused)) static uint8_t _ascii2hex(uint8_t asciiCode) -{ - if ((asciiCode >= '0') && (asciiCode <= '9')) - { - return asciiCode - '0'; - } - else if ((asciiCode >= 'a') && (asciiCode <= 'f')) - { - return asciiCode - 'a' + 10; - } - else if ((asciiCode >= 'A') && (asciiCode <= 'F')) - { - return asciiCode - 'A' + 10; - } - else - { - return 0xff; - } +__attribute__((unused)) static uint8_t _ascii2hex(uint8_t asciiCode) { + if ((asciiCode >= '0') && (asciiCode <= '9')) { + return asciiCode - '0'; + } else if ((asciiCode >= 'a') && (asciiCode <= 'f')) { + return asciiCode - 'a' + 10; + } else if ((asciiCode >= 'A') && (asciiCode <= 'F')) { + return asciiCode - 'A' + 10; + } else { + return 0xff; + } } /** @@ -299,28 +274,23 @@ __attribute__((unused)) static uint8_t _ascii2hex(uint8_t asciiCode) * @param stage OTA stage to update, * @see OTA_STAGE_E to get more details. */ -static void _set_ota_stage(OTA_STAGE_E stage) -{ - LOG_D("stage update:%s->%s", - _stage2str(otaEnv.currentStage), - _stage2str(stage)); +static void _set_ota_stage(OTA_STAGE_E stage) { + LOG_D("stage update:%s->%s", _stage2str(otaEnv.currentStage), + _stage2str(stage)); - otaEnv.currentStage = stage; + otaEnv.currentStage = stage; } -static void _update_ota_user(OTA_USER_E user) -{ - ASSERT((OTA_USER_NUM == otaEnv.currentUser) || (OTA_USER_NUM == user), - "try to set a ota user while the current user is not null"); +static void _update_ota_user(OTA_USER_E user) { + ASSERT((OTA_USER_NUM == otaEnv.currentUser) || (OTA_USER_NUM == user), + "try to set a ota user while the current user is not null"); - LOG_I("ota user update:%s->%s", - _user2str(otaEnv.currentUser), - _user2str(user)); + LOG_I("ota user update:%s->%s", _user2str(otaEnv.currentUser), + _user2str(user)); - otaEnv.currentUser = user; + otaEnv.currentUser = user; } - /** * @brief Enter OTA state handler. * @@ -330,54 +300,52 @@ static void _update_ota_user(OTA_USER_E user) * @param path Current OTA path, * @see OTA_PATH_E to get more details. */ -static void _enter_ota_state(OTA_PATH_E path) -{ - LOG_I("%s", __func__); +static void _enter_ota_state(OTA_PATH_E path) { + LOG_I("%s", __func__); - if (otaEnv.isInOtaState) - { - LOG_W("ALREADY in OTA state"); - } - else - { - /// 1. guarantee performance->switch to the highest freq - app_sysfreq_req(APP_SYSFREQ_USER_OTA, APP_SYSFREQ_104M); + if (otaEnv.isInOtaState) { + LOG_W("ALREADY in OTA state"); + } else { + /// 1. guarantee performance->switch to the highest freq + app_sysfreq_req(APP_SYSFREQ_USER_OTA, APP_SYSFREQ_104M); #ifdef IBRT - /// 2. guarantee performance->decrease the communication interval of TWS connection - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - btdrv_reg_op_set_tws_link_duration(IBRT_TWS_LINK_LARGE_DURATION); - btdrv_reg_op_set_private_tws_poll_interval(p_ibrt_ctrl->config.default_private_poll_interval, - p_ibrt_ctrl->config.default_private_poll_interval_in_sco); + /// 2. guarantee performance->decrease the communication interval of TWS + /// connection + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + btdrv_reg_op_set_tws_link_duration(IBRT_TWS_LINK_LARGE_DURATION); + btdrv_reg_op_set_private_tws_poll_interval( + p_ibrt_ctrl->config.default_private_poll_interval, + p_ibrt_ctrl->config.default_private_poll_interval_in_sco); - /// 3. guarantee performance->exit bt sniff mode - app_ibrt_ui_judge_link_policy(OTA_START_TRIGGER, BTIF_BLP_DISABLE_ALL); + /// 3. guarantee performance->exit bt sniff mode + app_ibrt_ui_judge_link_policy(OTA_START_TRIGGER, BTIF_BLP_DISABLE_ALL); - if (app_tws_ibrt_tws_link_connected() && \ - (p_ibrt_ctrl->nv_role == IBRT_MASTER) && \ - p_ibrt_ctrl->p_tws_remote_dev) - { - btif_me_stop_sniff(p_ibrt_ctrl->p_tws_remote_dev); - } - - app_ibrt_if_tws_sniff_block(15); -#else - /// 3. guarantee performance->exit bt sniff mode - app_bt_active_mode_set(ACTIVE_MODE_KEEPER_OTA, UPDATE_ACTIVE_MODE_FOR_ALL_LINKS); -#endif - - /// update the OTA path - LOG_I("OTA path update:%s->%s", _path2str(otaEnv.currentPath), _path2str(path)); - otaEnv.currentPath = path; - - /// 4. guarantee performance->decrease the BLE connection interval -#ifdef BLE_ENABLE - if (OTA_PATH_BLE == otaEnv.currentPath) - { - app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_OTA, true); - } -#endif + if (app_tws_ibrt_tws_link_connected() && + (p_ibrt_ctrl->nv_role == IBRT_MASTER) && + p_ibrt_ctrl->p_tws_remote_dev) { + btif_me_stop_sniff(p_ibrt_ctrl->p_tws_remote_dev); } + + app_ibrt_if_tws_sniff_block(15); +#else + /// 3. guarantee performance->exit bt sniff mode + app_bt_active_mode_set(ACTIVE_MODE_KEEPER_OTA, + UPDATE_ACTIVE_MODE_FOR_ALL_LINKS); +#endif + + /// update the OTA path + LOG_I("OTA path update:%s->%s", _path2str(otaEnv.currentPath), + _path2str(path)); + otaEnv.currentPath = path; + + /// 4. guarantee performance->decrease the BLE connection interval +#ifdef BLE_ENABLE + if (OTA_PATH_BLE == otaEnv.currentPath) { + app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_OTA, true); + } +#endif + } } /** @@ -387,44 +355,42 @@ static void _enter_ota_state(OTA_PATH_E path) * when enter the OTA state * */ -__attribute__((unused)) static void _exit_ota_state(void) -{ - LOG_I("%s", __func__); +__attribute__((unused)) static void _exit_ota_state(void) { + LOG_I("%s", __func__); - if (otaEnv.isInOtaState) - { + if (otaEnv.isInOtaState) { #ifdef IBRT - app_ibrt_ui_judge_link_policy(OTA_STOP_TRIGGER, BTIF_BLP_SNIFF_MODE); + app_ibrt_ui_judge_link_policy(OTA_STOP_TRIGGER, BTIF_BLP_SNIFF_MODE); #else - app_bt_active_mode_clear(ACTIVE_MODE_KEEPER_OTA, UPDATE_ACTIVE_MODE_FOR_ALL_LINKS); + app_bt_active_mode_clear(ACTIVE_MODE_KEEPER_OTA, + UPDATE_ACTIVE_MODE_FOR_ALL_LINKS); #endif - /// release the short TWS communication interval + /// release the short TWS communication interval #ifdef IBRT - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - btdrv_reg_op_set_tws_link_duration(IBRT_TWS_LINK_DEFAULT_DURATION); - btdrv_reg_op_set_private_tws_poll_interval(p_ibrt_ctrl->config.long_private_poll_interval, - p_ibrt_ctrl->config.default_private_poll_interval_in_sco); + ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); + btdrv_reg_op_set_tws_link_duration(IBRT_TWS_LINK_DEFAULT_DURATION); + btdrv_reg_op_set_private_tws_poll_interval( + p_ibrt_ctrl->config.long_private_poll_interval, + p_ibrt_ctrl->config.default_private_poll_interval_in_sco); #endif - /// release the short BLE connection interval + /// release the short BLE connection interval #ifdef BLE_ENABLE - app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_OTA, false); - app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_OTA_SLOWER, false); + app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_OTA, false); + app_ble_update_conn_param_mode(BLE_CONN_PARAM_MODE_OTA_SLOWER, false); #endif - /// update the OTA path to invalid - otaEnv.currentPath = OTA_PATH_INVALID; + /// update the OTA path to invalid + otaEnv.currentPath = OTA_PATH_INVALID; - /// release the system frequency - app_sysfreq_req(APP_SYSFREQ_USER_OTA, APP_SYSFREQ_32K); + /// release the system frequency + app_sysfreq_req(APP_SYSFREQ_USER_OTA, APP_SYSFREQ_32K); - otaEnv.isInOtaState = false; - } - else - { - LOG_W("NOT in OTA STATE"); - } + otaEnv.isInOtaState = false; + } else { + LOG_W("NOT in OTA STATE"); + } } #ifdef IBRT @@ -439,168 +405,152 @@ __attribute__((unused)) static void _exit_ota_state(void) * @return true Sanity check success. * @return false Sanity check failed. */ -static bool _image_sanity_check(void) -{ - // find the location of the CRC key word string - uint8_t *ptrOfTheLast4KImage = (uint8_t *)(OTA_FLASH_LOGIC_ADDR + - NEW_IMAGE_FLASH_OFFSET + - otaEnv.totalImageSize - - LEN_OF_IMAGE_TAIL_TO_FIND_SANITY_CRC); +static bool _image_sanity_check(void) { + // find the location of the CRC key word string + uint8_t *ptrOfTheLast4KImage = + (uint8_t *)(OTA_FLASH_LOGIC_ADDR + NEW_IMAGE_FLASH_OFFSET + + otaEnv.totalImageSize - LEN_OF_IMAGE_TAIL_TO_FIND_SANITY_CRC); - uint32_t sanityCrc32; - uint32_t crc32ImageOffset; - int32_t sanity_crc_location = _find_key_word(ptrOfTheLast4KImage, - LEN_OF_IMAGE_TAIL_TO_FIND_SANITY_CRC, - (uint8_t *)imageSanityKeyWord, - strlen(imageSanityKeyWord)); - if (-1 == sanity_crc_location) - { - sanity_crc_location = _find_key_word(ptrOfTheLast4KImage, - LEN_OF_IMAGE_TAIL_TO_FIND_SANITY_CRC, - (uint8_t *)oldImageSanityKeyWord, - strlen(oldImageSanityKeyWord)); - if (-1 == sanity_crc_location) - { - // if no sanity crc, fail the check - return false; - } - else - { - crc32ImageOffset = sanity_crc_location + - otaEnv.totalImageSize - - LEN_OF_IMAGE_TAIL_TO_FIND_SANITY_CRC + - strlen(oldImageSanityKeyWord); - sanityCrc32 = *(uint32_t *)(OTA_FLASH_LOGIC_ADDR + NEW_IMAGE_FLASH_OFFSET + crc32ImageOffset); - } + uint32_t sanityCrc32; + uint32_t crc32ImageOffset; + int32_t sanity_crc_location = + _find_key_word(ptrOfTheLast4KImage, LEN_OF_IMAGE_TAIL_TO_FIND_SANITY_CRC, + (uint8_t *)imageSanityKeyWord, strlen(imageSanityKeyWord)); + if (-1 == sanity_crc_location) { + sanity_crc_location = _find_key_word( + ptrOfTheLast4KImage, LEN_OF_IMAGE_TAIL_TO_FIND_SANITY_CRC, + (uint8_t *)oldImageSanityKeyWord, strlen(oldImageSanityKeyWord)); + if (-1 == sanity_crc_location) { + // if no sanity crc, fail the check + return false; + } else { + crc32ImageOffset = sanity_crc_location + otaEnv.totalImageSize - + LEN_OF_IMAGE_TAIL_TO_FIND_SANITY_CRC + + strlen(oldImageSanityKeyWord); + sanityCrc32 = *(uint32_t *)(OTA_FLASH_LOGIC_ADDR + + NEW_IMAGE_FLASH_OFFSET + crc32ImageOffset); } - else - { - crc32ImageOffset = sanity_crc_location + - otaEnv.totalImageSize - - LEN_OF_IMAGE_TAIL_TO_FIND_SANITY_CRC + - strlen(imageSanityKeyWord); + } else { + crc32ImageOffset = sanity_crc_location + otaEnv.totalImageSize - + LEN_OF_IMAGE_TAIL_TO_FIND_SANITY_CRC + + strlen(imageSanityKeyWord); - sanityCrc32 = 0; - uint8_t *crcString = (uint8_t *)(OTA_FLASH_LOGIC_ADDR + NEW_IMAGE_FLASH_OFFSET + crc32ImageOffset); + sanityCrc32 = 0; + uint8_t *crcString = (uint8_t *)(OTA_FLASH_LOGIC_ADDR + + NEW_IMAGE_FLASH_OFFSET + crc32ImageOffset); - for (uint8_t index = 0; index < 8; index++) - { - sanityCrc32 |= (_ascii2hex(crcString[index]) << (28 - 4 * index)); - } + for (uint8_t index = 0; index < 8; index++) { + sanityCrc32 |= (_ascii2hex(crcString[index]) << (28 - 4 * index)); } + } - LOG_D("Bytes to generate crc32 is %d", crc32ImageOffset); - LOG_D("sanity_crc_location is %d", sanity_crc_location); + LOG_D("Bytes to generate crc32 is %d", crc32ImageOffset); + LOG_D("sanity_crc_location is %d", sanity_crc_location); - LOG_D("sanityCrc32 is 0x%x", sanityCrc32); + LOG_D("sanityCrc32 is 0x%x", sanityCrc32); - // generate the CRC from image data - uint32_t calculatedCrc32 = 0; - calculatedCrc32 = crc32(calculatedCrc32, (uint8_t *)(OTA_FLASH_LOGIC_ADDR + NEW_IMAGE_FLASH_OFFSET), crc32ImageOffset); + // generate the CRC from image data + uint32_t calculatedCrc32 = 0; + calculatedCrc32 = + crc32(calculatedCrc32, + (uint8_t *)(OTA_FLASH_LOGIC_ADDR + NEW_IMAGE_FLASH_OFFSET), + crc32ImageOffset); - LOG_D("calculatedCrc32 is 0x%x", calculatedCrc32); + LOG_D("calculatedCrc32 is 0x%x", calculatedCrc32); - if (sanityCrc32 == calculatedCrc32) - { - return true; - } + if (sanityCrc32 == calculatedCrc32) { + return true; + } - return false; + return false; } static enum NORFLASH_API_MODULE_ID_T -_get_flash_module_from_ota_device(OTA_DEVICE_E device) -{ - enum NORFLASH_API_MODULE_ID_T mod = NORFLASH_API_MODULE_ID_COUNT; +_get_flash_module_from_ota_device(OTA_DEVICE_E device) { + enum NORFLASH_API_MODULE_ID_T mod = NORFLASH_API_MODULE_ID_COUNT; - switch (device) - { - case OTA_DEVICE_APP: - mod = NORFLASH_API_MODULE_ID_OTA; - break; - case OTA_DEVICE_HOTWORD: - mod = NORFLASH_API_MODULE_ID_HOTWORD_MODEL; - break; + switch (device) { + case OTA_DEVICE_APP: + mod = NORFLASH_API_MODULE_ID_OTA; + break; + case OTA_DEVICE_HOTWORD: + mod = NORFLASH_API_MODULE_ID_HOTWORD_MODEL; + break; - default: - ASSERT(0, "invalid OTA device received in %s", __func__); - break; - } + default: + ASSERT(0, "invalid OTA device received in %s", __func__); + break; + } - return mod; + return mod; } -static void _flush_data_to_flash(uint8_t *ptrSource, - uint32_t lengthToBurn, +static void _flush_data_to_flash(uint8_t *ptrSource, uint32_t lengthToBurn, uint32_t offsetInFlashToProgram, - bool synWrite) -{ + bool synWrite) { - LOG_D("flush %d bytes to flash offset 0x%x", lengthToBurn, offsetInFlashToProgram); - enum NORFLASH_API_MODULE_ID_T mod = _get_flash_module_from_ota_device(otaEnv.deviceId); + LOG_D("flush %d bytes to flash offset 0x%x", lengthToBurn, + offsetInFlashToProgram); + enum NORFLASH_API_MODULE_ID_T mod = + _get_flash_module_from_ota_device(otaEnv.deviceId); - uint32_t preBytes = (FLASH_SECTOR_SIZE_IN_BYTES - - (offsetInFlashToProgram % FLASH_SECTOR_SIZE_IN_BYTES)) % - FLASH_SECTOR_SIZE_IN_BYTES; + uint32_t preBytes = (FLASH_SECTOR_SIZE_IN_BYTES - + (offsetInFlashToProgram % FLASH_SECTOR_SIZE_IN_BYTES)) % + FLASH_SECTOR_SIZE_IN_BYTES; - if (lengthToBurn < preBytes) - { - preBytes = lengthToBurn; + if (lengthToBurn < preBytes) { + preBytes = lengthToBurn; + } + + uint32_t middleBytes = 0; + if (lengthToBurn > preBytes) { + middleBytes = ((lengthToBurn - preBytes) / FLASH_SECTOR_SIZE_IN_BYTES * + FLASH_SECTOR_SIZE_IN_BYTES); + } + + uint32_t postBytes = 0; + if (lengthToBurn > (preBytes + middleBytes)) { + postBytes = + (offsetInFlashToProgram + lengthToBurn) % FLASH_SECTOR_SIZE_IN_BYTES; + } + + LOG_D("Prebytes is %d middlebytes is %d postbytes is %d", preBytes, + middleBytes, postBytes); + + if (preBytes > 0) { + app_flash_page_program(mod, offsetInFlashToProgram, ptrSource, preBytes, + synWrite); + + ptrSource += preBytes; + offsetInFlashToProgram += preBytes; + } + + uint32_t sectorIndexInFlash = + offsetInFlashToProgram / FLASH_SECTOR_SIZE_IN_BYTES; + + if (middleBytes > 0) { + uint32_t sectorCntToProgram = middleBytes / FLASH_SECTOR_SIZE_IN_BYTES; + for (uint32_t sector = 0; sector < sectorCntToProgram; sector++) { + app_flash_page_erase(mod, + sectorIndexInFlash * FLASH_SECTOR_SIZE_IN_BYTES); + app_flash_page_program(mod, + sectorIndexInFlash * FLASH_SECTOR_SIZE_IN_BYTES, + ptrSource + sector * FLASH_SECTOR_SIZE_IN_BYTES, + FLASH_SECTOR_SIZE_IN_BYTES, synWrite); + + sectorIndexInFlash++; } - uint32_t middleBytes = 0; - if (lengthToBurn > preBytes) - { - middleBytes = ((lengthToBurn - preBytes) / FLASH_SECTOR_SIZE_IN_BYTES * FLASH_SECTOR_SIZE_IN_BYTES); - } + ptrSource += middleBytes; + } - uint32_t postBytes = 0; - if (lengthToBurn > (preBytes + middleBytes)) - { - postBytes = (offsetInFlashToProgram + lengthToBurn) % FLASH_SECTOR_SIZE_IN_BYTES; - } + if (postBytes > 0) { + app_flash_page_erase(mod, sectorIndexInFlash * FLASH_SECTOR_SIZE_IN_BYTES); + app_flash_page_program(mod, sectorIndexInFlash * FLASH_SECTOR_SIZE_IN_BYTES, + ptrSource, postBytes, synWrite); + } - LOG_D("Prebytes is %d middlebytes is %d postbytes is %d", preBytes, middleBytes, postBytes); - - if (preBytes > 0) - { - app_flash_page_program(mod, offsetInFlashToProgram, ptrSource, preBytes, synWrite); - - ptrSource += preBytes; - offsetInFlashToProgram += preBytes; - } - - uint32_t sectorIndexInFlash = offsetInFlashToProgram / FLASH_SECTOR_SIZE_IN_BYTES; - - if (middleBytes > 0) - { - uint32_t sectorCntToProgram = middleBytes / FLASH_SECTOR_SIZE_IN_BYTES; - for (uint32_t sector = 0; sector < sectorCntToProgram; sector++) - { - app_flash_page_erase(mod, sectorIndexInFlash * FLASH_SECTOR_SIZE_IN_BYTES); - app_flash_page_program(mod, - sectorIndexInFlash * FLASH_SECTOR_SIZE_IN_BYTES, - ptrSource + sector * FLASH_SECTOR_SIZE_IN_BYTES, - FLASH_SECTOR_SIZE_IN_BYTES, - synWrite); - - sectorIndexInFlash++; - } - - ptrSource += middleBytes; - } - - if (postBytes > 0) - { - app_flash_page_erase(mod, sectorIndexInFlash * FLASH_SECTOR_SIZE_IN_BYTES); - app_flash_page_program(mod, - sectorIndexInFlash * FLASH_SECTOR_SIZE_IN_BYTES, - ptrSource, - postBytes, - synWrite); - } - - app_flush_pending_flash_op(mod, NORFLASH_API_ALL); + app_flush_pending_flash_op(mod, NORFLASH_API_ALL); } /** @@ -608,184 +558,157 @@ static void _flush_data_to_flash(uint8_t *ptrSource, * that is passed into it to re-verify the image and that CRC is for the entire * image. */ -static bool _compute_whole_image_crc(void) -{ - uint32_t processedDataSize = 0; - uint32_t crc32Value = 0; - uint32_t bytes_to_use = 0; - uint32_t lock; +static bool _compute_whole_image_crc(void) { + uint32_t processedDataSize = 0; + uint32_t crc32Value = 0; + uint32_t bytes_to_use = 0; + uint32_t lock; - while (processedDataSize < otaEnv.totalImageSize) - { - if (otaEnv.totalImageSize - processedDataSize > OTA_DATA_CACHE_BUFFER_SIZE) - { - bytes_to_use = OTA_DATA_CACHE_BUFFER_SIZE; - } - else - { - bytes_to_use = otaEnv.totalImageSize - processedDataSize; - } - - lock = int_lock_global(); - norflash_sync_read(NORFLASH_API_MODULE_ID_OTA, - (OTA_FLASH_LOGIC_ADDR + NEW_IMAGE_FLASH_OFFSET + processedDataSize), - otaEnv.dataCacheBuffer, - OTA_DATA_CACHE_BUFFER_SIZE); - // memcpy(otaEnv.dataCacheBuffer, (uint8_t *)(OTA_FLASH_LOGIC_ADDR + NEW_IMAGE_FLASH_OFFSET + processedDataSize), - // OTA_DATA_CACHE_BUFFER_SIZE); - int_unlock_global(lock); - - if (0 == processedDataSize) - { - if (*(uint32_t *)otaEnv.dataCacheBuffer != NORMAL_BOOT) - { - LOG_D("first 32bit value is not NORMAL_BOOT"); - return false; - } - else - { - *(uint32_t *)otaEnv.dataCacheBuffer = 0xFFFFFFFF; - } - } - - LOG_D("bytes to verify =%d.", bytes_to_use); - - crc32Value = crc32(crc32Value, (uint8_t *)otaEnv.dataCacheBuffer, bytes_to_use); - - processedDataSize += bytes_to_use; + while (processedDataSize < otaEnv.totalImageSize) { + if (otaEnv.totalImageSize - processedDataSize > + OTA_DATA_CACHE_BUFFER_SIZE) { + bytes_to_use = OTA_DATA_CACHE_BUFFER_SIZE; + } else { + bytes_to_use = otaEnv.totalImageSize - processedDataSize; } - LOG_D("Computed CRC32 is 0x%x.", crc32Value); + lock = int_lock_global(); + norflash_sync_read( + NORFLASH_API_MODULE_ID_OTA, + (OTA_FLASH_LOGIC_ADDR + NEW_IMAGE_FLASH_OFFSET + processedDataSize), + otaEnv.dataCacheBuffer, OTA_DATA_CACHE_BUFFER_SIZE); + // memcpy(otaEnv.dataCacheBuffer, (uint8_t *)(OTA_FLASH_LOGIC_ADDR + + // NEW_IMAGE_FLASH_OFFSET + processedDataSize), + // OTA_DATA_CACHE_BUFFER_SIZE); + int_unlock_global(lock); - /* This crc value will be passed to the ota app in GSoundOtaApply(). */ - otaEnv.crc32OfImage = crc32Value; - return true; + if (0 == processedDataSize) { + if (*(uint32_t *)otaEnv.dataCacheBuffer != NORMAL_BOOT) { + LOG_D("first 32bit value is not NORMAL_BOOT"); + return false; + } else { + *(uint32_t *)otaEnv.dataCacheBuffer = 0xFFFFFFFF; + } + } + + LOG_D("bytes to verify =%d.", bytes_to_use); + + crc32Value = + crc32(crc32Value, (uint8_t *)otaEnv.dataCacheBuffer, bytes_to_use); + + processedDataSize += bytes_to_use; + } + + LOG_D("Computed CRC32 is 0x%x.", crc32Value); + + /* This crc value will be passed to the ota app in GSoundOtaApply(). */ + otaEnv.crc32OfImage = crc32Value; + return true; } -static void _update_boot_info(OTA_BOOT_INFO_T *otaBootInfo) -{ - ASSERT(OTA_DEVICE_APP == otaEnv.deviceId, "illegal OTA device try to update boot info"); - hal_norflash_disable_protection(HAL_NORFLASH_ID_0); - enum NORFLASH_API_MODULE_ID_T mod = _get_flash_module_from_ota_device(otaEnv.deviceId); - app_flash_page_erase(mod, OTA_BOOT_INFO_FLASH_OFFSET); - app_flash_page_program(mod, - OTA_BOOT_INFO_FLASH_OFFSET, - (uint8_t *)otaBootInfo, - sizeof(OTA_BOOT_INFO_T), - true); +static void _update_boot_info(OTA_BOOT_INFO_T *otaBootInfo) { + ASSERT(OTA_DEVICE_APP == otaEnv.deviceId, + "illegal OTA device try to update boot info"); + hal_norflash_disable_protection(HAL_NORFLASH_ID_0); + enum NORFLASH_API_MODULE_ID_T mod = + _get_flash_module_from_ota_device(otaEnv.deviceId); + app_flash_page_erase(mod, OTA_BOOT_INFO_FLASH_OFFSET); + app_flash_page_program(mod, OTA_BOOT_INFO_FLASH_OFFSET, + (uint8_t *)otaBootInfo, sizeof(OTA_BOOT_INFO_T), true); } -static void _update_magic_number(uint32_t newMagicNumber) -{ - ASSERT(OTA_DEVICE_APP == otaEnv.deviceId, "illegal device %d to update magic number", - otaEnv.deviceId); - memcpy(otaEnv.dataCacheBuffer, - (uint8_t *)(OTA_FLASH_LOGIC_ADDR + otaEnv.newImageFlashOffset), - FLASH_SECTOR_SIZE_IN_BYTES); +static void _update_magic_number(uint32_t newMagicNumber) { + ASSERT(OTA_DEVICE_APP == otaEnv.deviceId, + "illegal device %d to update magic number", otaEnv.deviceId); + memcpy(otaEnv.dataCacheBuffer, + (uint8_t *)(OTA_FLASH_LOGIC_ADDR + otaEnv.newImageFlashOffset), + FLASH_SECTOR_SIZE_IN_BYTES); - *(uint32_t *)otaEnv.dataCacheBuffer = newMagicNumber; - enum NORFLASH_API_MODULE_ID_T mod = _get_flash_module_from_ota_device(otaEnv.deviceId); - app_flash_page_erase(mod, otaEnv.newImageFlashOffset); + *(uint32_t *)otaEnv.dataCacheBuffer = newMagicNumber; + enum NORFLASH_API_MODULE_ID_T mod = + _get_flash_module_from_ota_device(otaEnv.deviceId); + app_flash_page_erase(mod, otaEnv.newImageFlashOffset); - app_flash_page_program(mod, - otaEnv.newImageFlashOffset, - otaEnv.dataCacheBuffer, - FLASH_SECTOR_SIZE_IN_BYTES, - true); + app_flash_page_program(mod, otaEnv.newImageFlashOffset, + otaEnv.dataCacheBuffer, FLASH_SECTOR_SIZE_IN_BYTES, + true); - app_flush_pending_flash_op(mod, NORFLASH_API_ALL); + app_flush_pending_flash_op(mod, NORFLASH_API_ALL); } -static void _update_peer_result(OTA_STATUS_E ret) -{ - LOG_D("update peer result:%s->%s", - _sts2str(otaEnv.peerResult), - _sts2str(ret)); +static void _update_peer_result(OTA_STATUS_E ret) { + LOG_D("update peer result:%s->%s", _sts2str(otaEnv.peerResult), + _sts2str(ret)); - otaEnv.peerResult = ret; + otaEnv.peerResult = ret; } -OTA_STATUS_E ota_common_get_peer_result(void) -{ - return otaEnv.peerResult; +OTA_STATUS_E ota_common_get_peer_result(void) { return otaEnv.peerResult; } + +static bool _relay_data_needed(void) { + bool ret = true; + + if (!app_tws_ibrt_tws_link_connected()) { + ret = false; + } + + if (OTA_STAGE_IDLE == otaEnv.currentStage) { + ret = false; + } + + /// check the customized relay_data_needed permission + if (ret && otaEnv.customRelayNeededHandler) { + ret = otaEnv.customRelayNeededHandler(); + } + + return ret; } -static bool _relay_data_needed(void) -{ - bool ret = true; +static void _ota_relay_data(OTA_COMMAND_E cmdType, const uint8_t *dataPtr, + uint16_t length) { + uint8_t frameNum = 0; + uint16_t frameLen = 0; + OTA_TWS_DATA_T tCmd = { + cmdType, + }; - if (!app_tws_ibrt_tws_link_connected()) - { - ret = false; + ASSERT(length <= ARRAY_SIZE(tCmd.data), "ILLEGAL relay packet length"); + + /// split packet into servel frame to fulfill the max TWS data + /// transmission length requirement + if (length % OTA_TWS_PAYLOAD_MAX_LEN) { + frameNum = length / OTA_TWS_PAYLOAD_MAX_LEN + 1; + } else { + frameNum = length / OTA_TWS_PAYLOAD_MAX_LEN; + } + + LOG_D("packet len:%d, splited frame num:%d", length, frameNum); + + /// push all data into queue + for (uint8_t i = 0; i < frameNum; i++) { + if ((i + 1) == frameNum) { + tCmd.magicCode = OTA_RELAY_PACKET_MAGIC_CODE_COMPLETE; + tCmd.length = length % OTA_TWS_PAYLOAD_MAX_LEN; + } else { + tCmd.magicCode = OTA_RELAY_PACKET_MAGIC_CODE_INCOMPLETE; + tCmd.length = OTA_TWS_PAYLOAD_MAX_LEN; } - if (OTA_STAGE_IDLE == otaEnv.currentStage) - { - ret = false; - } + frameLen = OTA_TWS_HEAD_SIZE + tCmd.length; - /// check the customized relay_data_needed permission - if (ret && otaEnv.customRelayNeededHandler) - { - ret = otaEnv.customRelayNeededHandler(); - } + memcpy(tCmd.data, dataPtr + i * OTA_TWS_PAYLOAD_MAX_LEN, tCmd.length); - return ret; -} + osMutexWait(txQueueMutexID, osWaitForever); + ASSERT(CQ_OK == EnCQueue(&otaEnv.txQueue, (CQItemType *)&frameLen, + sizeof(frameLen)), + "%s failed to push data to queue", __func__); + ASSERT(CQ_OK == EnCQueue(&otaEnv.txQueue, (CQItemType *)&tCmd, frameLen), + "%s failed to push data to queue", __func__); + osMutexRelease(txQueueMutexID); + } -static void _ota_relay_data(OTA_COMMAND_E cmdType, - const uint8_t *dataPtr, - uint16_t length) -{ - uint8_t frameNum = 0; - uint16_t frameLen = 0; - OTA_TWS_DATA_T tCmd = { - cmdType, - }; - - ASSERT(length <= ARRAY_SIZE(tCmd.data), "ILLEGAL relay packet length"); - - /// split packet into servel frame to fulfill the max TWS data - /// transmission length requirement - if (length % OTA_TWS_PAYLOAD_MAX_LEN) - { - frameNum = length / OTA_TWS_PAYLOAD_MAX_LEN + 1; - } - else - { - frameNum = length / OTA_TWS_PAYLOAD_MAX_LEN; - } - - LOG_D("packet len:%d, splited frame num:%d", length, frameNum); - - /// push all data into queue - for (uint8_t i = 0; i < frameNum; i++) - { - if ((i + 1) == frameNum) - { - tCmd.magicCode = OTA_RELAY_PACKET_MAGIC_CODE_COMPLETE; - tCmd.length = length % OTA_TWS_PAYLOAD_MAX_LEN; - } - else - { - tCmd.magicCode = OTA_RELAY_PACKET_MAGIC_CODE_INCOMPLETE; - tCmd.length = OTA_TWS_PAYLOAD_MAX_LEN; - } - - frameLen = OTA_TWS_HEAD_SIZE + tCmd.length; - - memcpy(tCmd.data, dataPtr + i * OTA_TWS_PAYLOAD_MAX_LEN, tCmd.length); - - osMutexWait(txQueueMutexID, osWaitForever); - ASSERT(CQ_OK == EnCQueue(&otaEnv.txQueue, (CQItemType *)&frameLen, sizeof(frameLen)), - "%s failed to push data to queue", __func__); - ASSERT(CQ_OK == EnCQueue(&otaEnv.txQueue, (CQItemType *)&tCmd, frameLen), - "%s failed to push data to queue", __func__); - osMutexRelease(txQueueMutexID); - } - - /// inform tx thread to handle the data to be transmitted - osSignalSet(txThreadId, OTA_TWS_TX_SIGNAL); + /// inform tx thread to handle the data to be transmitted + osSignalSet(txThreadId, OTA_TWS_TX_SIGNAL); } /** @@ -796,35 +719,31 @@ static void _ota_relay_data(OTA_COMMAND_E cmdType, * @return true Received data frame is valid * @return false Received data frame is invalid */ -static bool _tws_frame_validity_check(uint8_t *dataPtr, uint32_t length) -{ - bool isValid = true; +static bool _tws_frame_validity_check(uint8_t *dataPtr, uint32_t length) { + bool isValid = true; - OTA_TWS_DATA_T *otaTwsData = (OTA_TWS_DATA_T *)dataPtr; + OTA_TWS_DATA_T *otaTwsData = (OTA_TWS_DATA_T *)dataPtr; - ASSERT(TWS_RELAY_DATA_MAX_SIZE >= length, "received overloaded data packet!!!"); - if (OTA_RELAY_PACKET_MAGIC_CODE_INCOMPLETE == otaEnv.currentMagicCode && - otaTwsData->cmdType != otaEnv.currentCmdType) - { - ASSERT(0, "bad frame is received!!!"); - } + ASSERT(TWS_RELAY_DATA_MAX_SIZE >= length, + "received overloaded data packet!!!"); + if (OTA_RELAY_PACKET_MAGIC_CODE_INCOMPLETE == otaEnv.currentMagicCode && + otaTwsData->cmdType != otaEnv.currentCmdType) { + ASSERT(0, "bad frame is received!!!"); + } - if (length != otaTwsData->length + OTA_TWS_HEAD_SIZE) - { - LOG_W("INVALID packet, dataLen:%d, expected dataLen:%d", - length, - otaTwsData->length + OTA_TWS_HEAD_SIZE); - isValid = false; - } + if (length != otaTwsData->length + OTA_TWS_HEAD_SIZE) { + LOG_W("INVALID packet, dataLen:%d, expected dataLen:%d", length, + otaTwsData->length + OTA_TWS_HEAD_SIZE); + isValid = false; + } - if (OTA_RELAY_PACKET_MAGIC_CODE_COMPLETE != otaTwsData->magicCode && - OTA_RELAY_PACKET_MAGIC_CODE_INCOMPLETE != otaTwsData->magicCode) - { - LOG_W("INVALID magic code:0x%08x", otaTwsData->magicCode); - isValid = false; - } + if (OTA_RELAY_PACKET_MAGIC_CODE_COMPLETE != otaTwsData->magicCode && + OTA_RELAY_PACKET_MAGIC_CODE_INCOMPLETE != otaTwsData->magicCode) { + LOG_W("INVALID magic code:0x%08x", otaTwsData->magicCode); + isValid = false; + } - return isValid; + return isValid; } /** @@ -835,815 +754,690 @@ static bool _tws_frame_validity_check(uint8_t *dataPtr, uint32_t length) * * @param status Status of receiving TWS relay data */ -static void _tws_rsp(OTA_STATUS_E status) -{ - LOG_D("[%s] status:%s", __func__, _sts2str(status)); +static void _tws_rsp(OTA_STATUS_E status) { + LOG_D("[%s] status:%s", __func__, _sts2str(status)); - OTA_STATUS_E rsp = status; - _ota_relay_data(OTA_COMMAND_RSP, (const uint8_t *)&rsp, sizeof(rsp)); + OTA_STATUS_E rsp = status; + _ota_relay_data(OTA_COMMAND_RSP, (const uint8_t *)&rsp, sizeof(rsp)); } #endif -OTA_COMMON_ENV_T *ota_common_get_env(void) -{ - return &otaEnv; -} +OTA_COMMON_ENV_T *ota_common_get_env(void) { return &otaEnv; } /** * @brief Reset the OTA environment. * */ -static void _reset_env(void) -{ - LOG_D("[%s]", __func__); - memset(&otaEnv, 0, sizeof(otaEnv)); +static void _reset_env(void) { + LOG_D("[%s]", __func__); + memset(&otaEnv, 0, sizeof(otaEnv)); #ifdef __APP_USER_DATA_NV_FLASH_OFFSET__ - otaEnv.userDataNvFlashOffset = __APP_USER_DATA_NV_FLASH_OFFSET__; + otaEnv.userDataNvFlashOffset = __APP_USER_DATA_NV_FLASH_OFFSET__; #else - otaEnv.userDataNvFlashOffset = hal_norflash_get_flash_total_size(HAL_NORFLASH_ID_0) - 2 * 4096; + otaEnv.userDataNvFlashOffset = + hal_norflash_get_flash_total_size(HAL_NORFLASH_ID_0) - 2 * 4096; #endif - otaEnv.flashOffsetOfUserDataPool = otaEnv.userDataNvFlashOffset; - _update_ota_user(OTA_USER_NUM); + otaEnv.flashOffsetOfUserDataPool = otaEnv.userDataNvFlashOffset; + _update_ota_user(OTA_USER_NUM); #ifdef OTA_NVRAM - // gOtaCtx.cfg.clearUserData = false; - // gOtaCtx.flashOffsetOfFactoryDataPool = - // otaEnv.otaCommon->userDataNvFlashOffset + FLASH_SECTOR_SIZE_IN_BYTES; + // gOtaCtx.cfg.clearUserData = false; + // gOtaCtx.flashOffsetOfFactoryDataPool = + // otaEnv.otaCommon->userDataNvFlashOffset + FLASH_SECTOR_SIZE_IN_BYTES; #endif #ifdef IBRT - /// init tws TX queue - osMutexWait(txQueueMutexID, osWaitForever); - InitCQueue(&(otaEnv.txQueue), ARRAY_SIZE(otaEnv.txBuf), (CQItemType *)otaEnv.txBuf); - osMutexRelease(txQueueMutexID); + /// init tws TX queue + osMutexWait(txQueueMutexID, osWaitForever); + InitCQueue(&(otaEnv.txQueue), ARRAY_SIZE(otaEnv.txBuf), + (CQItemType *)otaEnv.txBuf); + osMutexRelease(txQueueMutexID); - /// init tws RX queue - osMutexWait(rxQueueMutexID, osWaitForever); - InitCQueue(&(otaEnv.rxQueue), ARRAY_SIZE(otaEnv.rxBuf), (CQItemType *)otaEnv.rxBuf); - osMutexRelease(rxQueueMutexID); + /// init tws RX queue + osMutexWait(rxQueueMutexID, osWaitForever); + InitCQueue(&(otaEnv.rxQueue), ARRAY_SIZE(otaEnv.rxBuf), + (CQItemType *)otaEnv.rxBuf); + osMutexRelease(rxQueueMutexID); #endif } -void ota_common_init_handler(void) -{ - LOG_D("[%s]", __func__); +void ota_common_init_handler(void) { + LOG_D("[%s]", __func__); - /// init OTA related nvrecord pointer - nv_record_ota_init(); + /// init OTA related nvrecord pointer + nv_record_ota_init(); - /// init common used flash module - ota_common_init_flash((uint8_t)NORFLASH_API_MODULE_ID_OTA, - 0, - (OTA_FLASH_LOGIC_ADDR + ( + /// init common used flash module + ota_common_init_flash( + (uint8_t)NORFLASH_API_MODULE_ID_OTA, 0, + (OTA_FLASH_LOGIC_ADDR + ( #ifdef __APP_USER_DATA_NV_FLASH_OFFSET__ - __APP_USER_DATA_NV_FLASH_OFFSET__ + __APP_USER_DATA_NV_FLASH_OFFSET__ #else - (hal_norflash_get_flash_total_size(HAL_NORFLASH_ID_0) - 2 * 4096) + (hal_norflash_get_flash_total_size( + HAL_NORFLASH_ID_0) - + 2 * 4096) #endif - & 0xffffff)), - 0); + & 0xffffff)), + 0); #ifdef IBRT - if (txThreadId == NULL) - { - txThreadId = osThreadCreate(osThread(_ota_tws_thread), NULL); - } + if (txThreadId == NULL) { + txThreadId = osThreadCreate(osThread(_ota_tws_thread), NULL); + } - /// init tws TX queue mutex - if (txQueueMutexID == NULL) - { - txQueueMutexID = osMutexCreate((osMutex(twsTxQueueMutex))); - } + /// init tws TX queue mutex + if (txQueueMutexID == NULL) { + txQueueMutexID = osMutexCreate((osMutex(twsTxQueueMutex))); + } - /// init tws RX queue mutex - if (rxQueueMutexID == NULL) - { - rxQueueMutexID = osMutexCreate((osMutex(twsRxQueueMutex))); - } + /// init tws RX queue mutex + if (rxQueueMutexID == NULL) { + rxQueueMutexID = osMutexCreate((osMutex(twsRxQueueMutex))); + } #endif - _reset_env(); + _reset_env(); } -void ota_common_enable_sanity_check(bool enable) -{ - LOG_I("sanity check enable state update:%d->%d", - otaEnv.sanityCheckEnable, enable); - otaEnv.sanityCheckEnable = enable; +void ota_common_enable_sanity_check(bool enable) { + LOG_I("sanity check enable state update:%d->%d", otaEnv.sanityCheckEnable, + enable); + otaEnv.sanityCheckEnable = enable; } -void ota_common_init_flash(uint8_t module, - uint32_t baseAddr, - uint32_t len, - uint32_t imageHandler) -{ - enum NORFLASH_API_RET_T ret; - uint32_t block_size = 0; - uint32_t sector_size = 0; - uint32_t page_size = 0; +void ota_common_init_flash(uint8_t module, uint32_t baseAddr, uint32_t len, + uint32_t imageHandler) { + enum NORFLASH_API_RET_T ret; + uint32_t block_size = 0; + uint32_t sector_size = 0; + uint32_t page_size = 0; - hal_norflash_get_size(HAL_NORFLASH_ID_0, - NULL, - &block_size, - §or_size, - &page_size); + hal_norflash_get_size(HAL_NORFLASH_ID_0, NULL, &block_size, §or_size, + &page_size); - LOG_I("%s module:%d, startAddr:0x%x, len:0x%x", __func__, module, baseAddr, len); - ret = norflash_api_register((NORFLASH_API_MODULE_ID_T)module, - HAL_NORFLASH_ID_0, - baseAddr, - len, - block_size, - sector_size, - page_size, - OTA_NORFLASH_BUFFER_LEN, - (NORFLASH_API_OPERA_CB)imageHandler); + LOG_I("%s module:%d, startAddr:0x%x, len:0x%x", __func__, module, baseAddr, + len); + ret = norflash_api_register((NORFLASH_API_MODULE_ID_T)module, + HAL_NORFLASH_ID_0, baseAddr, len, block_size, + sector_size, page_size, OTA_NORFLASH_BUFFER_LEN, + (NORFLASH_API_OPERA_CB)imageHandler); - ASSERT(ret == NORFLASH_API_OK, - "ota_init_flash: norflash_api register failed,ret = %d.", - ret); + ASSERT(ret == NORFLASH_API_OK, + "ota_init_flash: norflash_api register failed,ret = %d.", ret); #ifdef FLASH_SUSPEND - norflash_suspend_check_irq(AUDMA_IRQn); - norflash_suspend_check_irq(ISDATA_IRQn); - norflash_suspend_check_irq(ISDATA1_IRQn); + norflash_suspend_check_irq(AUDMA_IRQn); + norflash_suspend_check_irq(ISDATA_IRQn); + norflash_suspend_check_irq(ISDATA1_IRQn); #endif } -bool ota_common_is_in_progress(void) -{ - bool ret = false; +bool ota_common_is_in_progress(void) { + bool ret = false; - if (OTA_STAGE_IDLE != otaEnv.currentStage) - { - ret = true; - } + if (OTA_STAGE_IDLE != otaEnv.currentStage) { + ret = true; + } - return ret; + return ret; } void ota_common_registor_command_handler(OTA_COMMAND_E cmdType, - void *cmdHandler) -{ - if (otaEnv.cmdHandler[cmdType]) - { - LOG_W("handler for OTA command %d is not NULL", cmdType); - } + void *cmdHandler) { + if (otaEnv.cmdHandler[cmdType]) { + LOG_W("handler for OTA command %d is not NULL", cmdType); + } - otaEnv.cmdHandler[cmdType] = (OTA_CMD_HANDLER_T)cmdHandler; + otaEnv.cmdHandler[cmdType] = (OTA_CMD_HANDLER_T)cmdHandler; } OTA_STATUS_E ota_common_command_received_handler(OTA_COMMAND_E cmdType, void *cmdInfo, - uint16_t cmdLen) -{ - LOG_D("cmd received:%s", _cmd2str(cmdType)); - otaEnv.status = OTA_STATUS_OK; - OTA_STATUS_E temp = OTA_STATUS_OK; + uint16_t cmdLen) { + LOG_D("cmd received:%s", _cmd2str(cmdType)); + otaEnv.status = OTA_STATUS_OK; + OTA_STATUS_E temp = OTA_STATUS_OK; - /// init OTA progress when received begin command - if (OTA_COMMAND_BEGIN == cmdType) - { - ASSERT(OTA_STAGE_IDLE == otaEnv.currentStage, "Received begin command while not in IDLE stage"); - OTA_BEGIN_PARAM_T *c = (OTA_BEGIN_PARAM_T *)cmdInfo; + /// init OTA progress when received begin command + if (OTA_COMMAND_BEGIN == cmdType) { + ASSERT(OTA_STAGE_IDLE == otaEnv.currentStage, + "Received begin command while not in IDLE stage"); + OTA_BEGIN_PARAM_T *c = (OTA_BEGIN_PARAM_T *)cmdInfo; - /// update the ota user to ota common layer - _update_ota_user(c->user); + /// update the ota user to ota common layer + _update_ota_user(c->user); - /// update the new image size according to the image size param - LOG_I("total image size update:%d->%d", otaEnv.totalImageSize, c->imageSize); - otaEnv.totalImageSize = c->imageSize; + /// update the new image size according to the image size param + LOG_I("total image size update:%d->%d", otaEnv.totalImageSize, + c->imageSize); + otaEnv.totalImageSize = c->imageSize; - /// update the new image offset according to the start offset param - ASSERT(0 == (c->startOffset % FLASH_SECTOR_SIZE_IN_BYTES), - "Resumed start offset is not 4KB aligned!"); - LOG_I("programOffset&receivedDataSize is update:%d->%d", - otaEnv.newImageProgramOffset, - c->startOffset); - otaEnv.newImageProgramOffset = c->startOffset; - otaEnv.receivedDataSize = c->startOffset; + /// update the new image offset according to the start offset param + ASSERT(0 == (c->startOffset % FLASH_SECTOR_SIZE_IN_BYTES), + "Resumed start offset is not 4KB aligned!"); + LOG_I("programOffset&receivedDataSize is update:%d->%d", + otaEnv.newImageProgramOffset, c->startOffset); + otaEnv.newImageProgramOffset = c->startOffset; + otaEnv.receivedDataSize = c->startOffset; - /// update the device index - LOG_I("deviceId update:%d->%d", otaEnv.deviceId, c->device); - otaEnv.deviceId = c->device; + /// update the device index + LOG_I("deviceId update:%d->%d", otaEnv.deviceId, c->device); + otaEnv.deviceId = c->device; - /// update the version info and version length - memcpy(otaEnv.version, c->version, c->versionLen); - otaEnv.versionLen = c->versionLen; + /// update the version info and version length + memcpy(otaEnv.version, c->version, c->versionLen); + otaEnv.versionLen = c->versionLen; - /// update the flash offset of new image - LOG_I("newImageFlashOffset update:0x%02x->0x%02x", otaEnv.newImageFlashOffset, c->flashOffset); - otaEnv.newImageFlashOffset = c->flashOffset; + /// update the flash offset of new image + LOG_I("newImageFlashOffset update:0x%02x->0x%02x", + otaEnv.newImageFlashOffset, c->flashOffset); + otaEnv.newImageFlashOffset = c->flashOffset; - /// set the OTA stage to ongoing - _set_ota_stage(OTA_STAGE_ONGOING); + /// set the OTA stage to ongoing + _set_ota_stage(OTA_STAGE_ONGOING); - /// system layer configurations to guarentee the performance - /// of all functionalities - _enter_ota_state(c->path); + /// system layer configurations to guarentee the performance + /// of all functionalities + _enter_ota_state(c->path); + } + + /// execute the custom configuration + if (OTA_COMMAND_NUM != cmdType) { + if (otaEnv.cmdHandler[cmdType]) { + temp = otaEnv.cmdHandler[cmdType](cmdInfo, cmdLen); + LOG_I("ota command %s handle done, status:%s", _cmd2str(cmdType), + _sts2str(temp)); + + if (OTA_STATUS_OK != temp) { + otaEnv.status = temp; + } + } else { + LOG_W("ota cmd %s is not handled by customor", _cmd2str(cmdType)); } + } else { + LOG_E("INVALID cmd:%d", cmdType); + } - /// execute the custom configuration - if(OTA_COMMAND_NUM != cmdType) - { - if (otaEnv.cmdHandler[cmdType]) - { - temp = otaEnv.cmdHandler[cmdType](cmdInfo, cmdLen); - LOG_I("ota command %s handle done, status:%s", _cmd2str(cmdType), _sts2str(temp)); - - if (OTA_STATUS_OK != temp) - { - otaEnv.status = temp; - } - } - else - { - LOG_W("ota cmd %s is not handled by customor", _cmd2str(cmdType)); - } - } - else - { - LOG_E("INVALID cmd:%d", cmdType); + /// update the OTA progress + if (OTA_STATUS_OK == otaEnv.status) { + if (!nv_record_ota_update_info(otaEnv.currentUser, otaEnv.deviceId, + otaEnv.currentStage, otaEnv.totalImageSize, + otaEnv.version)) { + LOG_W("update info failed"); + otaEnv.status = OTA_STATUS_ERROR; } + } - /// update the OTA progress - if (OTA_STATUS_OK == otaEnv.status) - { - if (!nv_record_ota_update_info(otaEnv.currentUser, - otaEnv.deviceId, - otaEnv.currentStage, - otaEnv.totalImageSize, - otaEnv.version)) - { - LOG_W("update info failed"); - otaEnv.status = OTA_STATUS_ERROR; - } - } + /// special process for OTA_ABORT&&OTA_APPLY command + if ((OTA_COMMAND_ABORT == cmdType) || (OTA_COMMAND_APPLY == cmdType)) { + _reset_env(); + } - /// special process for OTA_ABORT&&OTA_APPLY command - if ((OTA_COMMAND_ABORT == cmdType) || - (OTA_COMMAND_APPLY == cmdType)) - { - _reset_env(); - } - - LOG_I("%s cmd process result:%s", __func__, _sts2str(otaEnv.status)); - return otaEnv.status; + LOG_I("%s cmd process result:%s", __func__, _sts2str(otaEnv.status)); + return otaEnv.status; } #ifdef OTA_NVRAM -static void ota_update_nv_data(void) -{ - if (otaEnv.configuration.isToClearUserData) - { - enum NORFLASH_API_MODULE_ID_T mod = _get_flash_module_from_ota_device(otaEnv.deviceId); - app_flash_page_erase(mod, sectorIndexInFlash * FLASH_SECTOR_SIZE_IN_BYTES); +static void ota_update_nv_data(void) { + if (otaEnv.configuration.isToClearUserData) { + enum NORFLASH_API_MODULE_ID_T mod = + _get_flash_module_from_ota_device(otaEnv.deviceId); + app_flash_page_erase(mod, sectorIndexInFlash * FLASH_SECTOR_SIZE_IN_BYTES); + } + + if (otaEnv.configuration.isToRenameBT || otaEnv.configuration.isToRenameBLE || + otaEnv.configuration.isToUpdateBTAddr || + otaEnv.configuration.isToUpdateBLEAddr) { + uint32_t *pOrgFactoryData, *pUpdatedFactoryData; + pOrgFactoryData = (uint32_t *)(OTA_FLASH_LOGIC_ADDR + + otaEnv.flashOffsetOfFactoryDataPool); + memcpy(otaEnv.dataCacheBuffer, (uint8_t *)pOrgFactoryData, + FLASH_SECTOR_SIZE_IN_BYTES); + pUpdatedFactoryData = (uint32_t *)&(otaEnv.dataCacheBuffer); + + if (NVREC_DEV_VERSION_1 == nv_record_dev_rev) { + if (otaEnv.configuration.isToRenameBT) { + memset((uint8_t *)(pUpdatedFactoryData + dev_name), 0, + sizeof(uint32_t) * (dev_bt_addr - dev_name)); + + memcpy((uint8_t *)(pUpdatedFactoryData + dev_name), + (uint8_t *)(otaEnv.configuration.newBTName), NAME_LENGTH); + } + + if (otaEnv.configuration.isToUpdateBTAddr) { + memcpy((uint8_t *)(pUpdatedFactoryData + dev_bt_addr), + (uint8_t *)(otaEnv.configuration.newBTAddr), BD_ADDR_LENGTH); + } + + if (otaEnv.configuration.isToUpdateBLEAddr) { + memcpy((uint8_t *)(pUpdatedFactoryData + dev_ble_addr), + (uint8_t *)(otaEnv.configuration.newBLEAddr), BD_ADDR_LENGTH); + } + + pUpdatedFactoryData[dev_crc] = + crc32(0, (uint8_t *)(&pUpdatedFactoryData[dev_reserv1]), + (dev_data_len - dev_reserv1) * sizeof(uint32_t)); + } else { + if (otaEnv.configuration.isToRenameBT) { + memset((uint8_t *)(pUpdatedFactoryData + rev2_dev_name), 0, + sizeof(uint32_t) * (rev2_dev_bt_addr - rev2_dev_name)); + + memcpy((uint8_t *)(pUpdatedFactoryData + rev2_dev_name), + (uint8_t *)(otaEnv.configuration.newBTName), NAME_LENGTH); + } + + if (otaEnv.configuration.isToRenameBLE) { + memset((uint8_t *)(pUpdatedFactoryData + rev2_dev_ble_name), 0, + sizeof(uint32_t) * (rev2_dev_section_end - rev2_dev_ble_name)); + + memcpy((uint8_t *)(pUpdatedFactoryData + rev2_dev_ble_name), + (uint8_t *)(otaEnv.configuration.newBleName), + BLE_NAME_LEN_IN_NV); + } + + if (otaEnv.configuration.isToUpdateBTAddr) { + memcpy((uint8_t *)(pUpdatedFactoryData + rev2_dev_bt_addr), + (uint8_t *)(otaEnv.configuration.newBTAddr), BD_ADDR_LENGTH); + } + + if (otaEnv.configuration.isToUpdateBLEAddr) { + memcpy((uint8_t *)(pUpdatedFactoryData + rev2_dev_ble_addr), + (uint8_t *)(otaEnv.configuration.newBLEAddr), BD_ADDR_LENGTH); + } + + pUpdatedFactoryData[dev_crc] = crc32( + 0, (uint8_t *)(&pUpdatedFactoryData[rev2_dev_section_start_reserved]), + pUpdatedFactoryData[rev2_dev_data_len]); } - if (otaEnv.configuration.isToRenameBT || - otaEnv.configuration.isToRenameBLE || - otaEnv.configuration.isToUpdateBTAddr || - otaEnv.configuration.isToUpdateBLEAddr) - { - uint32_t *pOrgFactoryData, *pUpdatedFactoryData; - pOrgFactoryData = (uint32_t *)(OTA_FLASH_LOGIC_ADDR + otaEnv.flashOffsetOfFactoryDataPool); - memcpy(otaEnv.dataCacheBuffer, (uint8_t *)pOrgFactoryData, FLASH_SECTOR_SIZE_IN_BYTES); - pUpdatedFactoryData = (uint32_t *)&(otaEnv.dataCacheBuffer); + enum NORFLASH_API_MODULE_ID_T mod = + _get_flash_module_from_ota_device(otaEnv.deviceId); + app_flash_page_erase(mod, sectorIndexInFlash * FLASH_SECTOR_SIZE_IN_BYTES); - if (NVREC_DEV_VERSION_1 == nv_record_dev_rev) - { - if (otaEnv.configuration.isToRenameBT) - { - memset((uint8_t *)(pUpdatedFactoryData + dev_name), - 0, - sizeof(uint32_t) * (dev_bt_addr - dev_name)); - - memcpy((uint8_t *)(pUpdatedFactoryData + dev_name), - (uint8_t *)(otaEnv.configuration.newBTName), - NAME_LENGTH); - } - - if (otaEnv.configuration.isToUpdateBTAddr) - { - memcpy((uint8_t *)(pUpdatedFactoryData + dev_bt_addr), - (uint8_t *)(otaEnv.configuration.newBTAddr), - BD_ADDR_LENGTH); - } - - if (otaEnv.configuration.isToUpdateBLEAddr) - { - memcpy((uint8_t *)(pUpdatedFactoryData + dev_ble_addr), - (uint8_t *)(otaEnv.configuration.newBLEAddr), - BD_ADDR_LENGTH); - } - - pUpdatedFactoryData[dev_crc] = crc32(0, - (uint8_t *)(&pUpdatedFactoryData[dev_reserv1]), - (dev_data_len - dev_reserv1) * sizeof(uint32_t)); - } - else - { - if (otaEnv.configuration.isToRenameBT) - { - memset((uint8_t *)(pUpdatedFactoryData + rev2_dev_name), - 0, - sizeof(uint32_t) * (rev2_dev_bt_addr - rev2_dev_name)); - - memcpy((uint8_t *)(pUpdatedFactoryData + rev2_dev_name), - (uint8_t *)(otaEnv.configuration.newBTName), - NAME_LENGTH); - } - - if (otaEnv.configuration.isToRenameBLE) - { - memset((uint8_t *)(pUpdatedFactoryData + rev2_dev_ble_name), - 0, - sizeof(uint32_t) * (rev2_dev_section_end - rev2_dev_ble_name)); - - memcpy((uint8_t *)(pUpdatedFactoryData + rev2_dev_ble_name), - (uint8_t *)(otaEnv.configuration.newBleName), - BLE_NAME_LEN_IN_NV); - } - - if (otaEnv.configuration.isToUpdateBTAddr) - { - memcpy((uint8_t *)(pUpdatedFactoryData + rev2_dev_bt_addr), - (uint8_t *)(otaEnv.configuration.newBTAddr), - BD_ADDR_LENGTH); - } - - if (otaEnv.configuration.isToUpdateBLEAddr) - { - memcpy((uint8_t *)(pUpdatedFactoryData + rev2_dev_ble_addr), - (uint8_t *)(otaEnv.configuration.newBLEAddr), - BD_ADDR_LENGTH); - } - - pUpdatedFactoryData[dev_crc] = crc32(0, - (uint8_t *)(&pUpdatedFactoryData[rev2_dev_section_start_reserved]), - pUpdatedFactoryData[rev2_dev_data_len]); - } - - enum NORFLASH_API_MODULE_ID_T mod = _get_flash_module_from_ota_device(otaEnv.deviceId); - app_flash_page_erase(mod, sectorIndexInFlash * FLASH_SECTOR_SIZE_IN_BYTES); - - app_flash_page_program(mod, - otaEnv.flashOffsetOfFactoryDataPool, - (uint8_t *)pUpdatedFactoryData, - FLASH_SECTOR_SIZE_IN_BYTES); - } + app_flash_page_program(mod, otaEnv.flashOffsetOfFactoryDataPool, + (uint8_t *)pUpdatedFactoryData, + FLASH_SECTOR_SIZE_IN_BYTES); + } } #endif #ifdef IBRT -void ota_common_registor_relay_needed_handler(void *handler) -{ - if (otaEnv.customRelayNeededHandler) - { - LOG_W("handler for custom relay needed judge is not NULL"); - } +void ota_common_registor_relay_needed_handler(void *handler) { + if (otaEnv.customRelayNeededHandler) { + LOG_W("handler for custom relay needed judge is not NULL"); + } - otaEnv.customRelayNeededHandler = (CUSTOM_RELAY_NEEDED_FUNC_T)handler; + otaEnv.customRelayNeededHandler = (CUSTOM_RELAY_NEEDED_FUNC_T)handler; } -void ota_common_registor_peer_cmd_received_handler(void *handler) -{ - if (otaEnv.peerCmdReceivedHandler) - { - LOG_W("handler for peer cmd received is not NULL"); - } +void ota_common_registor_peer_cmd_received_handler(void *handler) { + if (otaEnv.peerCmdReceivedHandler) { + LOG_W("handler for peer cmd received is not NULL"); + } - otaEnv.peerCmdReceivedHandler = (PEER_CMD_RECEIVED_HANDLER_T)handler; + otaEnv.peerCmdReceivedHandler = (PEER_CMD_RECEIVED_HANDLER_T)handler; } -OTA_STATUS_E ota_common_relay_data_to_peer(OTA_COMMAND_E cmdType, const uint8_t *data, uint16_t len) -{ - OTA_STATUS_E status = OTA_STATUS_OK; - if (_relay_data_needed()) - { - _ota_relay_data(cmdType, (const uint8_t *)data, len); - } - else - { - status = OTA_STATUS_ERROR; - } +OTA_STATUS_E ota_common_relay_data_to_peer(OTA_COMMAND_E cmdType, + const uint8_t *data, uint16_t len) { + OTA_STATUS_E status = OTA_STATUS_OK; + if (_relay_data_needed()) { + _ota_relay_data(cmdType, (const uint8_t *)data, len); + } else { + status = OTA_STATUS_ERROR; + } - return status; + return status; } -OTA_STATUS_E ota_common_receive_peer_rsp(void) -{ - OTA_STATUS_E status = OTA_STATUS_OK; +OTA_STATUS_E ota_common_receive_peer_rsp(void) { + OTA_STATUS_E status = OTA_STATUS_OK; - if (_relay_data_needed()) - { - /// get current thread ID as tws rx thread - rxThreadId = osThreadGetId(); + if (_relay_data_needed()) { + /// get current thread ID as tws rx thread + rxThreadId = osThreadGetId(); - /// pending current thread to waitting for slave response - evt = osSignalWait(OTA_TWS_RX_SIGNAL, OTA_TWS_RELAY_WAITTIME); + /// pending current thread to waitting for slave response + evt = osSignalWait(OTA_TWS_RX_SIGNAL, OTA_TWS_RELAY_WAITTIME); - if (evt.status == osEventTimeout) - { - status = OTA_STATUS_ERROR_RELAY_TIMEOUT; - LOG_W("[%s]SignalWait TIMEOUT!", __func__); - } - else if (osEventSignal == evt.status) - { - status = ota_common_get_peer_result(); - } - - ///.clear the excute result of this time - _update_peer_result(OTA_STATUS_OK); - } - else - { - status = OTA_STATUS_ERROR; + if (evt.status == osEventTimeout) { + status = OTA_STATUS_ERROR_RELAY_TIMEOUT; + LOG_W("[%s]SignalWait TIMEOUT!", __func__); + } else if (osEventSignal == evt.status) { + status = ota_common_get_peer_result(); } - return status; + ///.clear the excute result of this time + _update_peer_result(OTA_STATUS_OK); + } else { + status = OTA_STATUS_ERROR; + } + + return status; } -OTA_STATUS_E ota_common_fw_data_write(const uint8_t *data, uint16_t len) -{ - OTA_STATUS_E status = OTA_STATUS_OK; - uint16_t leftDataSize = len; - uint32_t offsetInReceivedRawData = 0; +OTA_STATUS_E ota_common_fw_data_write(const uint8_t *data, uint16_t len) { + OTA_STATUS_E status = OTA_STATUS_OK; + uint16_t leftDataSize = len; + uint32_t offsetInReceivedRawData = 0; - do - { - uint32_t bytesToCopy; - // copy to data buffer - if ((otaEnv.dataCacheBufferOffset + leftDataSize) > - OTA_DATA_CACHE_BUFFER_SIZE) - { - bytesToCopy = OTA_DATA_CACHE_BUFFER_SIZE - - otaEnv.dataCacheBufferOffset; - } - else - { - bytesToCopy = leftDataSize; - } - - leftDataSize -= bytesToCopy; - - memcpy(&otaEnv.dataCacheBuffer[otaEnv.dataCacheBufferOffset], - &data[offsetInReceivedRawData], - bytesToCopy); - offsetInReceivedRawData += bytesToCopy; - otaEnv.dataCacheBufferOffset += bytesToCopy; - - ASSERT(otaEnv.dataCacheBufferOffset <= OTA_DATA_CACHE_BUFFER_SIZE, - "bad math in %s", - __func__); - if (OTA_DATA_CACHE_BUFFER_SIZE == otaEnv.dataCacheBufferOffset) - { - _flush_data_to_flash(otaEnv.dataCacheBuffer, - OTA_DATA_CACHE_BUFFER_SIZE, - (otaEnv.newImageProgramOffset + - otaEnv.newImageFlashOffset), - false); - otaEnv.newImageProgramOffset += OTA_DATA_CACHE_BUFFER_SIZE; - otaEnv.dataCacheBufferOffset = 0; - } - } while (offsetInReceivedRawData < len); - - otaEnv.receivedDataSize += len; - - // check whether all image data has been received - if (otaEnv.receivedDataSize == otaEnv.totalImageSize) - { - LOG_D("The final image programming and crc32 check."); - - // flush any partial buffer to flash - if (otaEnv.dataCacheBufferOffset != 0) - { - _flush_data_to_flash(otaEnv.dataCacheBuffer, - otaEnv.dataCacheBufferOffset, - (otaEnv.newImageProgramOffset + - otaEnv.newImageFlashOffset), - true); - } - - if (OTA_DEVICE_APP == otaEnv.deviceId) - { - bool check = true; - - /// check the sanity if required - if (otaEnv.sanityCheckEnable) - { - check = _image_sanity_check(); - } - - if (check) - { - /// update the magic code of the application image - _update_magic_number(NORMAL_BOOT); - - /// check the crc32 of the received image data - if (_compute_whole_image_crc()) - { - LOG_I("Whole image verification pass."); - - /// update the OTA stage to OTA done - _set_ota_stage(OTA_STAGE_DONE); - } - else - { - LOG_W("image verification failed @%d", __LINE__); - - /// update the OTA stage to OTA idle - _set_ota_stage(OTA_STAGE_IDLE); - } - } - else - { - /// sanity check failed - LOG_W("image verification failed @%d", __LINE__); - - /// update the OTA stage to OTA idle - _set_ota_stage(OTA_STAGE_IDLE); - } - } - else - { - LOG_I("download finished, device:%d", otaEnv.deviceId); - - /// update the OTA stage to OTA idle - _set_ota_stage(OTA_STAGE_DONE); - } - - /// whole image verification failed somehow - if (OTA_STAGE_IDLE == otaEnv.currentStage) - { - nv_record_ota_update_info(otaEnv.currentUser, - otaEnv.deviceId, - otaEnv.currentStage, - 0, - INVALID_VERSION_STR); - - status = OTA_STATUS_ERROR_CHECKSUM; - } - else //!< whole image verification passed - { - nv_record_ota_update_info(otaEnv.currentUser, - otaEnv.deviceId, - otaEnv.currentStage, - otaEnv.totalImageSize, - otaEnv.version); - } - - /// exit the OTA state - _exit_ota_state(); - } - else //!< whole image revceive not finished - { - LOG_D("Received image size:%d", otaEnv.receivedDataSize); - - /// update the break point if it is changed - if ((otaEnv.receivedDataSize - otaEnv.breakPoint) >= - OTA_BREAKPOINT_STORE_GRANULARITY) - { - otaEnv.breakPoint = (otaEnv.receivedDataSize / - OTA_BREAKPOINT_STORE_GRANULARITY) * - OTA_BREAKPOINT_STORE_GRANULARITY; - - LOG_I("update record offset to %d", otaEnv.breakPoint); - nv_record_ota_update_breakpoint(otaEnv.currentUser, - otaEnv.deviceId, - otaEnv.breakPoint); - } + do { + uint32_t bytesToCopy; + // copy to data buffer + if ((otaEnv.dataCacheBufferOffset + leftDataSize) > + OTA_DATA_CACHE_BUFFER_SIZE) { + bytesToCopy = OTA_DATA_CACHE_BUFFER_SIZE - otaEnv.dataCacheBufferOffset; + } else { + bytesToCopy = leftDataSize; } - return status; + leftDataSize -= bytesToCopy; + + memcpy(&otaEnv.dataCacheBuffer[otaEnv.dataCacheBufferOffset], + &data[offsetInReceivedRawData], bytesToCopy); + offsetInReceivedRawData += bytesToCopy; + otaEnv.dataCacheBufferOffset += bytesToCopy; + + ASSERT(otaEnv.dataCacheBufferOffset <= OTA_DATA_CACHE_BUFFER_SIZE, + "bad math in %s", __func__); + if (OTA_DATA_CACHE_BUFFER_SIZE == otaEnv.dataCacheBufferOffset) { + _flush_data_to_flash( + otaEnv.dataCacheBuffer, OTA_DATA_CACHE_BUFFER_SIZE, + (otaEnv.newImageProgramOffset + otaEnv.newImageFlashOffset), false); + otaEnv.newImageProgramOffset += OTA_DATA_CACHE_BUFFER_SIZE; + otaEnv.dataCacheBufferOffset = 0; + } + } while (offsetInReceivedRawData < len); + + otaEnv.receivedDataSize += len; + + // check whether all image data has been received + if (otaEnv.receivedDataSize == otaEnv.totalImageSize) { + LOG_D("The final image programming and crc32 check."); + + // flush any partial buffer to flash + if (otaEnv.dataCacheBufferOffset != 0) { + _flush_data_to_flash( + otaEnv.dataCacheBuffer, otaEnv.dataCacheBufferOffset, + (otaEnv.newImageProgramOffset + otaEnv.newImageFlashOffset), true); + } + + if (OTA_DEVICE_APP == otaEnv.deviceId) { + bool check = true; + + /// check the sanity if required + if (otaEnv.sanityCheckEnable) { + check = _image_sanity_check(); + } + + if (check) { + /// update the magic code of the application image + _update_magic_number(NORMAL_BOOT); + + /// check the crc32 of the received image data + if (_compute_whole_image_crc()) { + LOG_I("Whole image verification pass."); + + /// update the OTA stage to OTA done + _set_ota_stage(OTA_STAGE_DONE); + } else { + LOG_W("image verification failed @%d", __LINE__); + + /// update the OTA stage to OTA idle + _set_ota_stage(OTA_STAGE_IDLE); + } + } else { + /// sanity check failed + LOG_W("image verification failed @%d", __LINE__); + + /// update the OTA stage to OTA idle + _set_ota_stage(OTA_STAGE_IDLE); + } + } else { + LOG_I("download finished, device:%d", otaEnv.deviceId); + + /// update the OTA stage to OTA idle + _set_ota_stage(OTA_STAGE_DONE); + } + + /// whole image verification failed somehow + if (OTA_STAGE_IDLE == otaEnv.currentStage) { + nv_record_ota_update_info(otaEnv.currentUser, otaEnv.deviceId, + otaEnv.currentStage, 0, INVALID_VERSION_STR); + + status = OTA_STATUS_ERROR_CHECKSUM; + } else //!< whole image verification passed + { + nv_record_ota_update_info(otaEnv.currentUser, otaEnv.deviceId, + otaEnv.currentStage, otaEnv.totalImageSize, + otaEnv.version); + } + + /// exit the OTA state + _exit_ota_state(); + } else //!< whole image revceive not finished + { + LOG_D("Received image size:%d", otaEnv.receivedDataSize); + + /// update the break point if it is changed + if ((otaEnv.receivedDataSize - otaEnv.breakPoint) >= + OTA_BREAKPOINT_STORE_GRANULARITY) { + otaEnv.breakPoint = + (otaEnv.receivedDataSize / OTA_BREAKPOINT_STORE_GRANULARITY) * + OTA_BREAKPOINT_STORE_GRANULARITY; + + LOG_I("update record offset to %d", otaEnv.breakPoint); + nv_record_ota_update_breakpoint(otaEnv.currentUser, otaEnv.deviceId, + otaEnv.breakPoint); + } + } + + return status; } -void ota_common_apply_current_fw(void) -{ - OTA_BOOT_INFO_T otaBootInfo = {COPY_NEW_IMAGE, - otaEnv.totalImageSize, - otaEnv.crc32OfImage}; - _update_boot_info(&otaBootInfo); +void ota_common_apply_current_fw(void) { + OTA_BOOT_INFO_T otaBootInfo = {COPY_NEW_IMAGE, otaEnv.totalImageSize, + otaEnv.crc32OfImage}; + _update_boot_info(&otaBootInfo); #ifdef OTA_NVRAM - ota_update_nv_data(); + ota_update_nv_data(); #endif - app_start_postponed_reset(); + app_start_postponed_reset(); } -void ota_common_on_relay_data_received(uint8_t *ptrParam, uint32_t paramLen) -{ - ASSERT(ptrParam, "invalid data pointer received in %s", __func__); - ASSERT(paramLen <= TWS_RELAY_DATA_MAX_SIZE, "illegal parameter length received in %s", __func__); +void ota_common_on_relay_data_received(uint8_t *ptrParam, uint32_t paramLen) { + ASSERT(ptrParam, "invalid data pointer received in %s", __func__); + ASSERT(paramLen <= TWS_RELAY_DATA_MAX_SIZE, + "illegal parameter length received in %s", __func__); - OTA_TWS_DATA_T *otaTwsData = (OTA_TWS_DATA_T *)ptrParam; - LOG_D("[%s] paramLen:%d, cmdType:%d|%s", __func__, paramLen, otaTwsData->cmdType, _cmd2str(otaTwsData->cmdType)); + OTA_TWS_DATA_T *otaTwsData = (OTA_TWS_DATA_T *)ptrParam; + LOG_D("[%s] paramLen:%d, cmdType:%d|%s", __func__, paramLen, + otaTwsData->cmdType, _cmd2str(otaTwsData->cmdType)); - OTA_STATUS_E status = OTA_STATUS_OK; - OTA_BEGIN_PARAM_T *beginInfo = NULL; - uint16_t packetLen = 0; + OTA_STATUS_E status = OTA_STATUS_OK; + OTA_BEGIN_PARAM_T *beginInfo = NULL; + uint16_t packetLen = 0; - if (_tws_frame_validity_check(ptrParam, paramLen)) - { - /// update the magic code and command type - otaEnv.currentMagicCode = otaTwsData->magicCode; - otaEnv.currentCmdType = otaTwsData->cmdType; + if (_tws_frame_validity_check(ptrParam, paramLen)) { + /// update the magic code and command type + otaEnv.currentMagicCode = otaTwsData->magicCode; + otaEnv.currentCmdType = otaTwsData->cmdType; - /// push received data into tws OTA data receive queue - osMutexWait(rxQueueMutexID, osWaitForever); - ASSERT(CQ_OK == EnCQueue(&otaEnv.rxQueue, (CQItemType *)otaTwsData->data, (paramLen - OTA_TWS_HEAD_SIZE)), - "%s failed to push data to queue, avaiable:%d, push:%d", - __func__, - AvailableOfCQueue(&otaEnv.rxQueue), - (paramLen - OTA_TWS_HEAD_SIZE)); - osMutexRelease(rxQueueMutexID); + /// push received data into tws OTA data receive queue + osMutexWait(rxQueueMutexID, osWaitForever); + ASSERT(CQ_OK == EnCQueue(&otaEnv.rxQueue, (CQItemType *)otaTwsData->data, + (paramLen - OTA_TWS_HEAD_SIZE)), + "%s failed to push data to queue, avaiable:%d, push:%d", __func__, + AvailableOfCQueue(&otaEnv.rxQueue), (paramLen - OTA_TWS_HEAD_SIZE)); + osMutexRelease(rxQueueMutexID); - /// whole packet from APP received done - if (OTA_RELAY_PACKET_MAGIC_CODE_COMPLETE == otaEnv.currentMagicCode) - { - osMutexWait(rxQueueMutexID, osWaitForever); - packetLen = LengthOfCQueue(&otaEnv.rxQueue); - LOG_D("length of rx queue:%d", packetLen); - DeCQueue(&otaEnv.rxQueue, otaEnv.tempRxBuf, packetLen); - osMutexRelease(rxQueueMutexID); + /// whole packet from APP received done + if (OTA_RELAY_PACKET_MAGIC_CODE_COMPLETE == otaEnv.currentMagicCode) { + osMutexWait(rxQueueMutexID, osWaitForever); + packetLen = LengthOfCQueue(&otaEnv.rxQueue); + LOG_D("length of rx queue:%d", packetLen); + DeCQueue(&otaEnv.rxQueue, otaEnv.tempRxBuf, packetLen); + osMutexRelease(rxQueueMutexID); - switch (otaEnv.currentCmdType) - { - case OTA_COMMAND_RSP: - /// retrieve and update the status of peer - status = ((OTA_RESPONSE_PARAM_T *)otaEnv.tempRxBuf)->status; - _update_peer_result(status); + switch (otaEnv.currentCmdType) { + case OTA_COMMAND_RSP: + /// retrieve and update the status of peer + status = ((OTA_RESPONSE_PARAM_T *)otaEnv.tempRxBuf)->status; + _update_peer_result(status); - /// inform the receiving thread to proceed - osSignalSet(rxThreadId, OTA_TWS_RX_SIGNAL); - break; + /// inform the receiving thread to proceed + osSignalSet(rxThreadId, OTA_TWS_RX_SIGNAL); + break; - /// add other supported command here - case OTA_COMMAND_BEGIN: - beginInfo = (OTA_BEGIN_PARAM_T *)otaTwsData->data; - if (beginInfo->initializer) - { - beginInfo->initializer(); - } - else - { - LOG_E("initializer not registored"); - } - case OTA_COMMAND_DATA: - case OTA_COMMAND_APPLY: - case OTA_COMMAND_ABORT: - if (otaEnv.peerCmdReceivedHandler) - { - status = otaEnv.peerCmdReceivedHandler(otaEnv.currentCmdType, - (const uint8_t*)otaEnv.tempRxBuf, - packetLen); - } - else - { - LOG_W("peerCmdReceivedHandler is not registored"); - } - - break; - - default: - ASSERT(0, "INVALID cmd received"); - status = OTA_STATUS_ERROR; - break; - } - - /// response to master if needed - if (OTA_COMMAND_RSP != otaTwsData->cmdType) - { - _tws_rsp(status); - } - - otaEnv.currentMagicCode = OTA_RELAY_PACKET_MAGIC_CODE_INVALID; - otaEnv.currentCmdType = OTA_COMMAND_NUM; + /// add other supported command here + case OTA_COMMAND_BEGIN: + beginInfo = (OTA_BEGIN_PARAM_T *)otaTwsData->data; + if (beginInfo->initializer) { + beginInfo->initializer(); + } else { + LOG_E("initializer not registored"); } - } - else - { - LOG_W("Received data frame is invalid"); + case OTA_COMMAND_DATA: + case OTA_COMMAND_APPLY: + case OTA_COMMAND_ABORT: + if (otaEnv.peerCmdReceivedHandler) { + status = otaEnv.peerCmdReceivedHandler( + otaEnv.currentCmdType, (const uint8_t *)otaEnv.tempRxBuf, + packetLen); + } else { + LOG_W("peerCmdReceivedHandler is not registored"); + } + + break; + + default: + ASSERT(0, "INVALID cmd received"); status = OTA_STATUS_ERROR; + break; + } - switch (otaTwsData->cmdType) - { - case OTA_COMMAND_RSP: - _update_peer_result(status); - osSignalSet(rxThreadId, OTA_TWS_RX_SIGNAL); - break; + /// response to master if needed + if (OTA_COMMAND_RSP != otaTwsData->cmdType) { + _tws_rsp(status); + } - case OTA_COMMAND_BEGIN: - case OTA_COMMAND_DATA: - case OTA_COMMAND_APPLY: - case OTA_COMMAND_ABORT: - _tws_rsp(status); - break; - - default: - ASSERT(0, "INVALID command received"); - break; - } + otaEnv.currentMagicCode = OTA_RELAY_PACKET_MAGIC_CODE_INVALID; + otaEnv.currentCmdType = OTA_COMMAND_NUM; } + } else { + LOG_W("Received data frame is invalid"); + status = OTA_STATUS_ERROR; + + switch (otaTwsData->cmdType) { + case OTA_COMMAND_RSP: + _update_peer_result(status); + osSignalSet(rxThreadId, OTA_TWS_RX_SIGNAL); + break; + + case OTA_COMMAND_BEGIN: + case OTA_COMMAND_DATA: + case OTA_COMMAND_APPLY: + case OTA_COMMAND_ABORT: + _tws_rsp(status); + break; + + default: + ASSERT(0, "INVALID command received"); + break; + } + } } -POSSIBLY_UNUSED static void _ota_tws_deinit(void) -{ - ResetCQueue(&otaEnv.txQueue); - ResetCQueue(&otaEnv.rxQueue); - memset(otaEnv.txBuf, 0, ARRAY_SIZE(otaEnv.txBuf)); - memset(otaEnv.rxBuf, 0, ARRAY_SIZE(otaEnv.rxBuf)); - memset(otaEnv.tempRxBuf, 0, ARRAY_SIZE(otaEnv.tempRxBuf)); +POSSIBLY_UNUSED static void _ota_tws_deinit(void) { + ResetCQueue(&otaEnv.txQueue); + ResetCQueue(&otaEnv.rxQueue); + memset(otaEnv.txBuf, 0, ARRAY_SIZE(otaEnv.txBuf)); + memset(otaEnv.rxBuf, 0, ARRAY_SIZE(otaEnv.rxBuf)); + memset(otaEnv.tempRxBuf, 0, ARRAY_SIZE(otaEnv.tempRxBuf)); - if (txThreadId) - { - osThreadTerminate(txThreadId); - txThreadId = NULL; - } + if (txThreadId) { + osThreadTerminate(txThreadId); + txThreadId = NULL; + } - if (txQueueMutexID != NULL) - { - osMutexDelete(txQueueMutexID); - txQueueMutexID = NULL; - } + if (txQueueMutexID != NULL) { + osMutexDelete(txQueueMutexID); + txQueueMutexID = NULL; + } - if (rxQueueMutexID != NULL) - { - osMutexDelete(rxQueueMutexID); - rxQueueMutexID = NULL; - } + if (rxQueueMutexID != NULL) { + osMutexDelete(rxQueueMutexID); + rxQueueMutexID = NULL; + } } -static void _ota_tws_thread(const void *arg) -{ - volatile uint16_t qLen = 0; - volatile uint16_t packetLen = 0; +static void _ota_tws_thread(const void *arg) { + volatile uint16_t qLen = 0; + volatile uint16_t packetLen = 0; - while (1) - { - osMutexWait(txQueueMutexID, osWaitForever); - qLen = LengthOfCQueue(&otaEnv.txQueue); - osMutexRelease(txQueueMutexID); - LOG_D("queued data len:%d", qLen); + while (1) { + osMutexWait(txQueueMutexID, osWaitForever); + qLen = LengthOfCQueue(&otaEnv.txQueue); + osMutexRelease(txQueueMutexID); + LOG_D("queued data len:%d", qLen); - while (qLen) - { - /// check the validity of queue length - /// ASSERT(qLen <= OTA_MAX_MTU, "invalid OTA relay data len"); + while (qLen) { + /// check the validity of queue length + /// ASSERT(qLen <= OTA_MAX_MTU, "invalid OTA relay data len"); - osMutexWait(txQueueMutexID, osWaitForever); - /// retrive and check the validity of packet length - DeCQueue(&otaEnv.txQueue, (CQItemType *)&packetLen, 2); - ASSERT(packetLen <= TWS_RELAY_DATA_MAX_SIZE, "invalid OTA relay data len:%d", packetLen); + osMutexWait(txQueueMutexID, osWaitForever); + /// retrive and check the validity of packet length + DeCQueue(&otaEnv.txQueue, (CQItemType *)&packetLen, 2); + ASSERT(packetLen <= TWS_RELAY_DATA_MAX_SIZE, + "invalid OTA relay data len:%d", packetLen); - /// retrieve the data to transmit - DeCQueue(&otaEnv.txQueue, (CQItemType *)relayBuf, packetLen); - osMutexRelease(txQueueMutexID); + /// retrieve the data to transmit + DeCQueue(&otaEnv.txQueue, (CQItemType *)relayBuf, packetLen); + osMutexRelease(txQueueMutexID); - LOG_D("send data len:%d", packetLen); + LOG_D("send data len:%d", packetLen); - /// send data to peer - tws_ctrl_send_cmd(IBRT_COMMON_OTA, relayBuf, packetLen); - memset(relayBuf, 0, TWS_RELAY_DATA_MAX_SIZE); + /// send data to peer + tws_ctrl_send_cmd(IBRT_COMMON_OTA, relayBuf, packetLen); + memset(relayBuf, 0, TWS_RELAY_DATA_MAX_SIZE); - osMutexWait(txQueueMutexID, osWaitForever); - qLen = LengthOfCQueue(&otaEnv.txQueue); - osMutexRelease(txQueueMutexID); - } - - osSignalWait(OTA_TWS_TX_SIGNAL, osWaitForever); + osMutexWait(txQueueMutexID, osWaitForever); + qLen = LengthOfCQueue(&otaEnv.txQueue); + osMutexRelease(txQueueMutexID); } + + osSignalWait(OTA_TWS_TX_SIGNAL, osWaitForever); + } } -static void _sync_info_prepare_handler(uint8_t *buf, uint16_t *length) -{ - *length = OTA_DEVICE_CNT * sizeof(NV_OTA_INFO_T); +static void _sync_info_prepare_handler(uint8_t *buf, uint16_t *length) { + *length = OTA_DEVICE_CNT * sizeof(NV_OTA_INFO_T); - void *otaInfo = NULL; - nv_record_ota_get_ptr(&otaInfo); + void *otaInfo = NULL; + nv_record_ota_get_ptr(&otaInfo); - memcpy(buf, otaInfo, *length); + memcpy(buf, otaInfo, *length); } -static void _sync_info_received_handler(uint8_t *buf, uint16_t length) -{ - // uodate gsound info - // TODO: +static void _sync_info_received_handler(uint8_t *buf, uint16_t length) { + // uodate gsound info + // TODO: } -void ota_common_tws_sync_init(void) -{ - TWS_SYNC_USER_T userOta = { - _sync_info_prepare_handler, - _sync_info_received_handler, - _sync_info_prepare_handler, - NULL, - NULL, - }; +void ota_common_tws_sync_init(void) { + TWS_SYNC_USER_T userOta = { + _sync_info_prepare_handler, + _sync_info_received_handler, + _sync_info_prepare_handler, + NULL, + NULL, + }; - app_tws_if_register_sync_user(TWS_SYNC_USER_OTA, &userOta); + app_tws_if_register_sync_user(TWS_SYNC_USER_OTA, &userOta); } #endif diff --git a/services/overlay/app_overlay.cpp b/services/overlay/app_overlay.cpp index 0ae9c8f..d1805b4 100644 --- a/services/overlay/app_overlay.cpp +++ b/services/overlay/app_overlay.cpp @@ -13,64 +13,55 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "cmsis_os.h" #include "app_overlay.h" -#include "hal_trace.h" +#include "cmsis_os.h" #include "hal_location.h" +#include "hal_trace.h" osMutexDef(app_overlay_mutex); static osMutexId app_overlay_mutex_id = NULL; static APP_OVERLAY_ID_T app_overlay_id = APP_OVERLAY_ID_QTY; -APP_OVERLAY_ID_T app_get_current_overlay(void) -{ - return app_overlay_id; -} +APP_OVERLAY_ID_T app_get_current_overlay(void) { return app_overlay_id; } -void app_overlay_select(enum APP_OVERLAY_ID_T id) -{ +void app_overlay_select(enum APP_OVERLAY_ID_T id) { #ifndef FPGA - TRACE(3,"%s id:%d:%d",__func__, id, app_overlay_id); + TRACE(3, "%s id:%d:%d", __func__, id, app_overlay_id); - osMutexWait(app_overlay_mutex_id, osWaitForever); - if (app_overlay_id==APP_OVERLAY_ID_QTY){ - app_overlay_load(id); - }else if (app_overlay_id!=APP_OVERLAY_ID_QTY){ - if (app_overlay_id!=id){ - app_overlay_unload(app_overlay_id); - app_overlay_load(id); - } + osMutexWait(app_overlay_mutex_id, osWaitForever); + if (app_overlay_id == APP_OVERLAY_ID_QTY) { + app_overlay_load(id); + } else if (app_overlay_id != APP_OVERLAY_ID_QTY) { + if (app_overlay_id != id) { + app_overlay_unload(app_overlay_id); + app_overlay_load(id); } - app_overlay_id = id; - osMutexRelease(app_overlay_mutex_id); + } + app_overlay_id = id; + osMutexRelease(app_overlay_mutex_id); #endif } -void app_overlay_unloadall(void) -{ - osMutexWait(app_overlay_mutex_id, osWaitForever); - if (app_overlay_id != APP_OVERLAY_ID_QTY){ - app_overlay_unload(app_overlay_id); - } - app_overlay_id = APP_OVERLAY_ID_QTY; - osMutexRelease(app_overlay_mutex_id); +void app_overlay_unloadall(void) { + osMutexWait(app_overlay_mutex_id, osWaitForever); + if (app_overlay_id != APP_OVERLAY_ID_QTY) { + app_overlay_unload(app_overlay_id); + } + app_overlay_id = APP_OVERLAY_ID_QTY; + osMutexRelease(app_overlay_mutex_id); } -void app_overlay_open(void) -{ - if (app_overlay_mutex_id == NULL) { - app_overlay_mutex_id = osMutexCreate(osMutex(app_overlay_mutex)); - } +void app_overlay_open(void) { + if (app_overlay_mutex_id == NULL) { + app_overlay_mutex_id = osMutexCreate(osMutex(app_overlay_mutex)); + } } -void app_overlay_close(void) -{ - app_overlay_unloadall(); - if (app_overlay_mutex_id != NULL){ - osMutexDelete(app_overlay_mutex_id); - app_overlay_mutex_id = NULL; - } +void app_overlay_close(void) { + app_overlay_unloadall(); + if (app_overlay_mutex_id != NULL) { + osMutexDelete(app_overlay_mutex_id); + app_overlay_mutex_id = NULL; + } } - - diff --git a/services/resources/resources.cpp b/services/resources/resources.cpp index 735bc85..b4cec02 100644 --- a/services/resources/resources.cpp +++ b/services/resources/resources.cpp @@ -14,8 +14,8 @@ * ****************************************************************************/ -#include "stdio.h" #include "cmsis_os.h" +#include "stdio.h" #include "string.h" #include "hal_timer.h" @@ -27,37 +27,34 @@ #ifdef MEDIA_PLAYER_SUPPORT typedef struct { - UINT32 MARK; - UINT16 ID; // resource id - UINT16 count; // count of resource - UINT32 total_size; // size include resource header, header list and data + UINT32 MARK; + UINT16 ID; // resource id + UINT16 count; // count of resource + UINT32 total_size; // size include resource header, header list and data } ResourceHeader_t; - typedef struct { - UINT16 audio_id; // audio id - UINT16 type; - UINT32 size; - UINT32 offset; + UINT16 audio_id; // audio id + UINT16 type; + UINT32 size; + UINT32 offset; } AudioHeader_t; -typedef struct _AUDIO_List -{ - struct _AUDIO_List *next; - AudioHeader_t record; +typedef struct _AUDIO_List { + struct _AUDIO_List *next; + AudioHeader_t record; } AUDIO_List; - - -#define AUDIO_TOOL_VERSION 0x6001 -#define MAGIC_NUMBER 0xC0BA +#define AUDIO_TOOL_VERSION 0x6001 +#define MAGIC_NUMBER 0xC0BA #define AUDIO_TOOL_RES_MARK 0xDDCCBBAA UINT16 gVersionNO = 0; UINT32 gReserver1 = 0; UINT32 gReserver2 = 0; -ResourceHeader_t *gpResourceBase = NULL; // base address of resource data, will be set by boot monitor +ResourceHeader_t *gpResourceBase = + NULL; // base address of resource data, will be set by boot monitor AUDIO_List *gpAudioList = NULL; AUDIO_List *gpAudioList_CN = NULL; @@ -65,52 +62,47 @@ AUDIO_List *gpAudioList_CN = NULL; uint8_t *gpAudioDataBase = NULL; uint8_t *gpAudioDataBase_CN = NULL; - -//uint8_t os_pool_audio_List[sizeof(AUDIO_List)*MAX_RECORD_NUM ] __attribute__((section(".audioList"))); -AUDIO_List os_pool_audio_List[MAX_RECORD_NUM]; //__attribute__((section(".audioList"))); -//osPoolDef_t os_pool_def_audio_List = { MAX_RECORD_NUM, sizeof(AUDIO_List), os_pool_audio_List };//osPoolDef(name, no, type) -//osPoolId AUDIO_ListPool_Id; +// uint8_t os_pool_audio_List[sizeof(AUDIO_List)*MAX_RECORD_NUM ] +// __attribute__((section(".audioList"))); +AUDIO_List os_pool_audio_List + [MAX_RECORD_NUM]; //__attribute__((section(".audioList"))); +// osPoolDef_t os_pool_def_audio_List = { MAX_RECORD_NUM, sizeof(AUDIO_List), +// os_pool_audio_List };//osPoolDef(name, no, type) osPoolId AUDIO_ListPool_Id; AUDIO_List os_pool_audio_List_CN[MAX_RECORD_NUM]; -UINT8* aud_get_reouce(AUD_ID_ENUM id, UINT32* leng, UINT16* type) -{ - AUDIO_List * list = gpAudioList; +UINT8 *aud_get_reouce(AUD_ID_ENUM id, UINT32 *leng, UINT16 *type) { + AUDIO_List *list = gpAudioList; - *leng = 0, *type = 0; + *leng = 0, *type = 0; - while(list) - { - if (list->record.audio_id == id) - { - *leng = list->record.size; - *type = list->record.type; - return (UINT8*) (gpAudioDataBase + list->record.offset); - } - list = list->next; - } + while (list) { + if (list->record.audio_id == id) { + *leng = list->record.size; + *type = list->record.type; + return (UINT8 *)(gpAudioDataBase + list->record.offset); + } + list = list->next; + } - return 0; + return 0; } -UINT8* aud_get_reouce_chinese(AUD_ID_ENUM id, UINT32* leng, UINT16* type) -{ - AUDIO_List * list = gpAudioList_CN; +UINT8 *aud_get_reouce_chinese(AUD_ID_ENUM id, UINT32 *leng, UINT16 *type) { + AUDIO_List *list = gpAudioList_CN; - *leng = 0, *type = 0; + *leng = 0, *type = 0; - while(list) - { - if (list->record.audio_id == id) - { - *leng = list->record.size; - *type = list->record.type; - return (UINT8*) (gpAudioDataBase_CN + list->record.offset); - } - list = list->next; - } + while (list) { + if (list->record.audio_id == id) { + *leng = list->record.size; + *type = list->record.type; + return (UINT8 *)(gpAudioDataBase_CN + list->record.offset); + } + list = list->next; + } - return 0; + return 0; } /* @@ -123,87 +115,89 @@ UINT8* aud_get_reouce_chinese(AUD_ID_ENUM id, UINT32* leng, UINT16* type) --7.file.. gpAudioDataBase.. offset --.... another resource */ -void init_audio_resource(void* gResource) -{ - uint32_t crc; - uint32_t *pcrc; - uint32_t data; +void init_audio_resource(void *gResource) { + uint32_t crc; + uint32_t *pcrc; + uint32_t data; - UINT32 res_addr; - ResourceHeader_t *pRes; + UINT32 res_addr; + ResourceHeader_t *pRes; - data = *((UINT32*)gResource); - gVersionNO = 0xFFFF & (data>>16); - gReserver1 = *((UINT32*)((uint32_t)gResource+2*sizeof(UINT32))); + data = *((UINT32 *)gResource); + gVersionNO = 0xFFFF & (data >> 16); + gReserver1 = *((UINT32 *)((uint32_t)gResource + 2 * sizeof(UINT32))); - pcrc = (uint32_t *)((uint32_t)gResource+sizeof(UINT32)); /*crc*/ + pcrc = (uint32_t *)((uint32_t)gResource + sizeof(UINT32)); /*crc*/ - gpResourceBase = (ResourceHeader_t *) ((uint32_t)gResource + 4*sizeof(uint32_t)); -/********************************************************/ - crc = crc32(0, (uint8_t *)((uint32_t)gpResourceBase) , gReserver1); - TRACE(3,"%s, *pcrc: %x , crc: %x",__func__, *pcrc, crc); - if (*pcrc != crc) - return; + gpResourceBase = + (ResourceHeader_t *)((uint32_t)gResource + 4 * sizeof(uint32_t)); + /********************************************************/ + crc = crc32(0, (uint8_t *)((uint32_t)gpResourceBase), gReserver1); + TRACE(3, "%s, *pcrc: %x , crc: %x", __func__, *pcrc, crc); + if (*pcrc != crc) + return; - res_addr = (uint32_t)gpResourceBase; - pRes = (ResourceHeader_t *)gpResourceBase; + res_addr = (uint32_t)gpResourceBase; + pRes = (ResourceHeader_t *)gpResourceBase; - while((UINT32)pRes < (UINT32)gpResourceBase +gReserver1 && pRes->MARK == AUDIO_TOOL_RES_MARK) - { - if (pRes->ID == RES_ENGLISH_ID) - { - AUDIO_List * list; - memset(os_pool_audio_List, 0, sizeof(AUDIO_List)*MAX_RECORD_NUM); - memcpy((uint8_t *)os_pool_audio_List, (uint8_t *)((uint32_t)pRes+sizeof(ResourceHeader_t)),sizeof(AUDIO_List)* pRes->count); + while ((UINT32)pRes < (UINT32)gpResourceBase + gReserver1 && + pRes->MARK == AUDIO_TOOL_RES_MARK) { + if (pRes->ID == RES_ENGLISH_ID) { + AUDIO_List *list; + memset(os_pool_audio_List, 0, sizeof(AUDIO_List) * MAX_RECORD_NUM); + memcpy((uint8_t *)os_pool_audio_List, + (uint8_t *)((uint32_t)pRes + sizeof(ResourceHeader_t)), + sizeof(AUDIO_List) * pRes->count); - gpAudioList = (AUDIO_List *)os_pool_audio_List; - list = gpAudioList; + gpAudioList = (AUDIO_List *)os_pool_audio_List; + list = gpAudioList; - gpAudioDataBase = (uint8_t *)pRes + sizeof(ResourceHeader_t) + sizeof(AUDIO_List)* pRes->count; - TRACE(3,"%s, english count: %d, leng: %d",__func__, pRes->count, pRes->total_size); + gpAudioDataBase = (uint8_t *)pRes + sizeof(ResourceHeader_t) + + sizeof(AUDIO_List) * pRes->count; + TRACE(3, "%s, english count: %d, leng: %d", __func__, pRes->count, + pRes->total_size); - for(int i=1; icount; i++) - { - list->next = &os_pool_audio_List[i]; + for (int i = 1; i < pRes->count; i++) { + list->next = &os_pool_audio_List[i]; - list = list->next; - } + list = list->next; + } - TRACE(2,"%s, english list: %p",__func__, list); + TRACE(2, "%s, english list: %p", __func__, list); - } - else if (pRes->ID == RES_CHINESE_ID) - { + } else if (pRes->ID == RES_CHINESE_ID) { - AUDIO_List * list; - TRACE(2,"%s, AUDIO_TOOL_RES_MARK: %d",__func__, pRes->count); + AUDIO_List *list; + TRACE(2, "%s, AUDIO_TOOL_RES_MARK: %d", __func__, pRes->count); - memset(os_pool_audio_List_CN, 0, sizeof(AUDIO_List)*MAX_RECORD_NUM); - memcpy((uint8_t *)os_pool_audio_List_CN, (uint8_t *)((uint32_t)pRes+sizeof(ResourceHeader_t)),sizeof(AUDIO_List)* pRes->count); + memset(os_pool_audio_List_CN, 0, sizeof(AUDIO_List) * MAX_RECORD_NUM); + memcpy((uint8_t *)os_pool_audio_List_CN, + (uint8_t *)((uint32_t)pRes + sizeof(ResourceHeader_t)), + sizeof(AUDIO_List) * pRes->count); - gpAudioList_CN= (AUDIO_List *)os_pool_audio_List_CN; - list = gpAudioList_CN; + gpAudioList_CN = (AUDIO_List *)os_pool_audio_List_CN; + list = gpAudioList_CN; - gpAudioDataBase_CN = (uint8_t *)pRes +sizeof(ResourceHeader_t) + sizeof(AUDIO_List)* pRes->count; - TRACE(3,"%s, chinese count: %d, leng: %d",__func__, pRes->count, pRes->total_size); + gpAudioDataBase_CN = (uint8_t *)pRes + sizeof(ResourceHeader_t) + + sizeof(AUDIO_List) * pRes->count; + TRACE(3, "%s, chinese count: %d, leng: %d", __func__, pRes->count, + pRes->total_size); - for(int i=1; icount; i++) - { - list->next = &os_pool_audio_List_CN[i]; + for (int i = 1; i < pRes->count; i++) { + list->next = &os_pool_audio_List_CN[i]; - list = list->next; - } - } + list = list->next; + } + } - TRACE(3,"%s, %x, pRes->total_size: %x",__func__,res_addr, pRes->total_size); + TRACE(3, "%s, %x, pRes->total_size: %x", __func__, res_addr, + pRes->total_size); - res_addr += pRes->total_size; - pRes = (ResourceHeader_t*)(res_addr); - - } - - TRACE(2,"%s, pRes add: %p",__func__, pRes); + res_addr += pRes->total_size; + pRes = (ResourceHeader_t *)(res_addr); + } + TRACE(2, "%s, pRes add: %p", __func__, pRes); } #if 0 @@ -322,8 +316,7 @@ void test_resource_load() #endif #endif -const char *aud_id_str[] = -{ +const char *aud_id_str[] = { "[POWER_ON]", "[POWER_OFF]", "[LANGUAGE_SWITCH]", @@ -370,19 +363,14 @@ const char *aud_id_str[] = #endif }; -const char *aud_id2str(UINT16 aud_id) -{ - const char *str = NULL; +const char *aud_id2str(UINT16 aud_id) { + const char *str = NULL; - if (aud_id >= 0 && aud_id < MAX_RECORD_NUM) - { - str = aud_id_str[aud_id]; - } - else - { - str = "[UNKNOWN]"; - } + if (aud_id >= 0 && aud_id < MAX_RECORD_NUM) { + str = aud_id_str[aud_id]; + } else { + str = "[UNKNOWN]"; + } - return str; + return str; } - diff --git a/services/through_put/app_through_put.cpp b/services/through_put/app_through_put.cpp index a2382ee..4a560e7 100644 --- a/services/through_put/app_through_put.cpp +++ b/services/through_put/app_through_put.cpp @@ -1,18 +1,17 @@ +#include "app_through_put.h" +#include "app_ai_if.h" +#include "app_ai_if_config.h" +#include "app_ai_if_custom_ui.h" +#include "app_ai_if_thirdparty.h" +#include "app_ai_manager_api.h" +#include "app_ai_tws.h" #include "cmsis_os.h" #include "hal_trace.h" #include -#include "app_ai_if.h" -#include "app_ai_tws.h" -#include "app_ai_manager_api.h" -#include "app_ai_if_config.h" -#include "app_ai_if_thirdparty.h" -#include "app_ai_if_thirdparty.h" -#include "app_ai_if_custom_ui.h" -#include "app_through_put.h" #ifdef __AI_VOICE__ -#include "ai_manager.h" #include "ai_control.h" +#include "ai_manager.h" #include "ai_thread.h" #include "app_ai_voice.h" #endif @@ -20,281 +19,263 @@ static THROUGHPUT_TEST_ENV_T throughputTestEnv; static THROUGHPUT_TEST_CONFIG_T throughputTestConfig; -static uint32_t app_throughput_test_transmission_handler(void *param1, uint32_t param2); +static uint32_t app_throughput_test_transmission_handler(void *param1, + uint32_t param2); -static APP_THROUGHPUT_CMD_INSTANCE_T *find_throughput_instance_by_code(uint16_t cmdCode) -{ - for (uint32_t index = 0; - index < APP_THROUGHPUT_CMD_INSTANCE_NUMBER; - index++) - { - if (through_put_table[index].cmdCode == cmdCode) - { - return &through_put_table[index]; - } +static APP_THROUGHPUT_CMD_INSTANCE_T * +find_throughput_instance_by_code(uint16_t cmdCode) { + for (uint32_t index = 0; index < APP_THROUGHPUT_CMD_INSTANCE_NUMBER; + index++) { + if (through_put_table[index].cmdCode == cmdCode) { + return &through_put_table[index]; } + } - return NULL; + return NULL; } -bool app_throughput_send_command(APP_THROUGHPUT_CMD_CODE_E cmdCode, - uint8_t *ptrParam, uint32_t paramLen) -{ - APP_THROUGHPUT_CMD_PAYLOAD_T payload; - uint16_t cmd_len = 0; +bool app_throughput_send_command(APP_THROUGHPUT_CMD_CODE_E cmdCode, + uint8_t *ptrParam, uint32_t paramLen) { + APP_THROUGHPUT_CMD_PAYLOAD_T payload; + uint16_t cmd_len = 0; - if (THROUGHPUT_DATA_MAX_SIZE < paramLen) - { - TRACE(1,"%s error ", __func__); - return false; - } + if (THROUGHPUT_DATA_MAX_SIZE < paramLen) { + TRACE(1, "%s error ", __func__); + return false; + } - payload.cmdCode = cmdCode; - payload.paramLen = paramLen; - memcpy(payload.param, ptrParam, paramLen); + payload.cmdCode = cmdCode; + payload.paramLen = paramLen; + memcpy(payload.param, ptrParam, paramLen); - cmd_len = (uint32_t)THROUGHPUT_CMD_PAYLOAD_HEADER_LEN + payload.paramLen; - app_ai_if_custom_ui_send_cmd((uint8_t *)&payload, cmd_len); + cmd_len = (uint32_t)THROUGHPUT_CMD_PAYLOAD_HEADER_LEN + payload.paramLen; + app_ai_if_custom_ui_send_cmd((uint8_t *)&payload, cmd_len); - return true; + return true; } -uint32_t app_throughput_cmd_send_done(void *param1, uint32_t param2) -{ - if (throughputTestEnv.isThroughputTestOn && \ - ((app_ai_get_transport_type() == AI_TRANSPORT_BLE) ||\ - (WITHOUT_RSP == throughputTestConfig.responseModel))) - { - app_throughput_test_transmission_handler(NULL, 0); - } +uint32_t app_throughput_cmd_send_done(void *param1, uint32_t param2) { + if (throughputTestEnv.isThroughputTestOn && + ((app_ai_get_transport_type() == AI_TRANSPORT_BLE) || + (WITHOUT_RSP == throughputTestConfig.responseModel))) { + app_throughput_test_transmission_handler(NULL, 0); + } - return 0; + return 0; } -uint32_t app_throughput_receive_cmd(void *param1, uint32_t param2) -{ - uint8_t *ptrbuf = NULL; - uint32_t data_length = 0; - APP_THROUGHPUT_CMD_PAYLOAD_T* pPayload = NULL; +uint32_t app_throughput_receive_cmd(void *param1, uint32_t param2) { + uint8_t *ptrbuf = NULL; + uint32_t data_length = 0; + APP_THROUGHPUT_CMD_PAYLOAD_T *pPayload = NULL; - TRACE(2,"%s data len %d", __func__, param2); - //DUMP8("0x%02x ", param1, param2); + TRACE(2, "%s data len %d", __func__, param2); + // DUMP8("0x%02x ", param1, param2); - data_length = param2; - while(data_length) { - ptrbuf = (uint8_t *)((uint32_t)param1 + param2 - data_length); + data_length = param2; + while (data_length) { + ptrbuf = (uint8_t *)((uint32_t)param1 + param2 - data_length); - pPayload = (APP_THROUGHPUT_CMD_PAYLOAD_T *)ptrbuf; - data_length -= THROUGHPUT_CMD_PAYLOAD_HEADER_LEN; - if(data_length < pPayload->paramLen) { - TRACE(3,"%s error data_length %d paramLen %d", __func__, data_length, pPayload->paramLen); - return 2; - } - TRACE(3,"%s data_length %d paramLen %d", __func__, data_length, pPayload->paramLen); - data_length -= pPayload->paramLen; - - // check parameter length - if (pPayload->paramLen > sizeof(pPayload->param)) { - TRACE(0,"SV COMMAND PARAM ERROR LENGTH"); - return 4; - } - - APP_THROUGHPUT_CMD_INSTANCE_T *pInstance = find_throughput_instance_by_code(pPayload->cmdCode); - - // execute the command handler - if (pInstance) - { - pInstance->cmdHandler((APP_THROUGHPUT_CMD_CODE_E)(pPayload->cmdCode), pPayload->param, pPayload->paramLen); - } + pPayload = (APP_THROUGHPUT_CMD_PAYLOAD_T *)ptrbuf; + data_length -= THROUGHPUT_CMD_PAYLOAD_HEADER_LEN; + if (data_length < pPayload->paramLen) { + TRACE(3, "%s error data_length %d paramLen %d", __func__, data_length, + pPayload->paramLen); + return 2; } - - return 0; + TRACE(3, "%s data_length %d paramLen %d", __func__, data_length, + pPayload->paramLen); + data_length -= pPayload->paramLen; + + // check parameter length + if (pPayload->paramLen > sizeof(pPayload->param)) { + TRACE(0, "SV COMMAND PARAM ERROR LENGTH"); + return 4; + } + + APP_THROUGHPUT_CMD_INSTANCE_T *pInstance = + find_throughput_instance_by_code(pPayload->cmdCode); + + // execute the command handler + if (pInstance) { + pInstance->cmdHandler((APP_THROUGHPUT_CMD_CODE_E)(pPayload->cmdCode), + pPayload->param, pPayload->paramLen); + } + } + + return 0; } -#define APP_THROUGHPUT_PRE_CONFIG_PENDING_TIME_IN_MS 2000 +#define APP_THROUGHPUT_PRE_CONFIG_PENDING_TIME_IN_MS 2000 static void app_throughput_pre_config_pending_timer_cb(void const *n); -osTimerDef (APP_THROUGHPUT_PRE_CONFIG_PENDING_TIMER, app_throughput_pre_config_pending_timer_cb); -osTimerId app_throughput_pre_config_pending_timer_id = NULL; +osTimerDef(APP_THROUGHPUT_PRE_CONFIG_PENDING_TIMER, + app_throughput_pre_config_pending_timer_cb); +osTimerId app_throughput_pre_config_pending_timer_id = NULL; static void app_throughput_test_data_xfer_lasting_timer_cb(void const *n); -osTimerDef (APP_THROUGHPUT_TEST_DATA_XFER_LASTING_TIMER, app_throughput_test_data_xfer_lasting_timer_cb); -osTimerId app_throughput_test_data_xfer_lasting_timer_id = NULL; - +osTimerDef(APP_THROUGHPUT_TEST_DATA_XFER_LASTING_TIMER, + app_throughput_test_data_xfer_lasting_timer_cb); +osTimerId app_throughput_test_data_xfer_lasting_timer_id = NULL; static uint8_t app_throughput_datapattern[THROUGHPUT_DATA_MAX_SIZE]; -static void app_throughput_test_data_xfer_lasting_timer_cb(void const *n) -{ - app_throughput_send_command(THROUGHPUT_OP_THROUGHPUT_TEST_DONE, NULL, 0); +static void app_throughput_test_data_xfer_lasting_timer_cb(void const *n) { + app_throughput_send_command(THROUGHPUT_OP_THROUGHPUT_TEST_DONE, NULL, 0); - app_stop_throughput_test(); + app_stop_throughput_test(); } -static void app_throughput_pre_config_pending_timer_cb(void const *n) -{ - // inform the configuration +static void app_throughput_pre_config_pending_timer_cb(void const *n) { + // inform the configuration + app_throughput_send_command(THROUGHPUT_OP_INFORM_THROUGHPUT_TEST_CONFIG, + (uint8_t *)&throughputTestConfig, + sizeof(throughputTestConfig)); + + if (UP_STREAM == throughputTestConfig.direction) { + app_throughput_test_transmission_handler(NULL, 0); +#ifndef SLAVE_ADV_BLE + osTimerStart(app_throughput_test_data_xfer_lasting_timer_id, + throughputTestConfig.lastTimeInSecond * 1000); +#endif + } +} + +void app_throughput_test_init(void) { + memset(&throughputTestEnv, 0x00, sizeof(throughputTestEnv)); + memset(&throughputTestConfig, 0x00, sizeof(throughputTestConfig)); + + app_throughput_pre_config_pending_timer_id = osTimerCreate( + osTimer(APP_THROUGHPUT_PRE_CONFIG_PENDING_TIMER), osTimerOnce, NULL); + + app_throughput_test_data_xfer_lasting_timer_id = osTimerCreate( + osTimer(APP_THROUGHPUT_TEST_DATA_XFER_LASTING_TIMER), osTimerOnce, NULL); +} + +static uint32_t app_throughput_test_transmission_handler(void *param1, + uint32_t param2) { + if (UP_STREAM == throughputTestConfig.direction) { + app_throughput_send_command(THROUGHPUT_OP_THROUGHPUT_TEST_DATA, + app_throughput_datapattern, + throughputTestConfig.dataPacketSize - 4); + } + + return 0; +} + +static void app_throughput_test_data_handler(APP_THROUGHPUT_CMD_CODE_E funcCode, + uint8_t *ptrParam, + uint32_t paramLen) { + if ((WITH_RSP == throughputTestConfig.responseModel) && + (AI_TRANSPORT_SPP == app_ai_get_transport_type())) { + app_throughput_send_command(THROUGHPUT_OP_THROUGHPUT_TEST_DATA_ACK, NULL, + 0); + } +} + +static void +app_throughput_test_data_ack_handler(APP_THROUGHPUT_CMD_CODE_E funcCode, + uint8_t *ptrParam, uint32_t paramLen) { + if (throughputTestEnv.isThroughputTestOn && + (WITH_RSP == throughputTestConfig.responseModel)) { + app_throughput_test_transmission_handler(NULL, 0); + } +} + +static void +app_throughput_test_done_signal_handler(APP_THROUGHPUT_CMD_CODE_E funcCode, + uint8_t *ptrParam, uint32_t paramLen) { + app_stop_throughput_test(); +} + +void app_stop_throughput_test(void) { + throughputTestEnv.isThroughputTestOn = false; + osTimerStop(app_throughput_pre_config_pending_timer_id); + osTimerStop(app_throughput_test_data_xfer_lasting_timer_id); +} + +static void +app_throughput_test_config_handler(APP_THROUGHPUT_CMD_CODE_E funcCode, + uint8_t *ptrParam, uint32_t paramLen) { + throughputTestConfig = *(THROUGHPUT_TEST_CONFIG_T *)ptrParam; + + TRACE(4, "%s patter %d time %d response %d", __func__, + throughputTestConfig.dataPattern, throughputTestConfig.lastTimeInSecond, + throughputTestConfig.responseModel); + + // generate the data pattern + switch (throughputTestConfig.dataPattern) { + case PATTERN_RANDOM: { + for (uint32_t index = 0; index < THROUGHPUT_DATA_MAX_SIZE; index++) { + app_throughput_datapattern[index] = (uint8_t)rand(); + } + break; + } + case PATTERN_11110000: { + memset(app_throughput_datapattern, 0xF0, THROUGHPUT_DATA_MAX_SIZE); + break; + } + case PATTERN_10101010: { + memset(app_throughput_datapattern, 0xAA, THROUGHPUT_DATA_MAX_SIZE); + break; + } + case PATTERN_ALL_1: { + memset(app_throughput_datapattern, 0xFF, THROUGHPUT_DATA_MAX_SIZE); + break; + } + case PATTERN_ALL_0: { + memset(app_throughput_datapattern, 0, THROUGHPUT_DATA_MAX_SIZE); + break; + } + case PATTERN_00001111: { + memset(app_throughput_datapattern, 0x0F, THROUGHPUT_DATA_MAX_SIZE); + break; + } + case PATTERN_0101: { + memset(app_throughput_datapattern, 0x55, THROUGHPUT_DATA_MAX_SIZE); + break; + } + default: + throughputTestConfig.dataPattern = 0; + break; + } + + throughputTestEnv.isThroughputTestOn = true; + throughputTestEnv.conidx = app_ai_if_get_ble_connection_index(); + TRACE(2, "conidx 0x%x useSpecificConnParameter %d", throughputTestEnv.conidx, + throughputTestConfig.isToUseSpecificConnParameter); + + // check whether need to use the new conn parameter + if (AI_TRANSPORT_BLE == app_ai_get_transport_type() && + throughputTestConfig.isToUseSpecificConnParameter) { + if (throughputTestEnv.conidx != 0xFF) { + l2cap_update_param(throughputTestEnv.conidx, + throughputTestConfig.minConnIntervalInMs, + throughputTestConfig.maxConnIntervalInMs, + THROUGHPUT_BLE_CONNECTION_SUPERVISOR_TIMEOUT_IN_MS, + THROUGHPUT_BLE_CONNECTION_SLAVELATENCY); + } + + osTimerStart(app_throughput_pre_config_pending_timer_id, + APP_THROUGHPUT_PRE_CONFIG_PENDING_TIME_IN_MS); + } else { app_throughput_send_command(THROUGHPUT_OP_INFORM_THROUGHPUT_TEST_CONFIG, - (uint8_t *)&throughputTestConfig, sizeof(throughputTestConfig)); + (uint8_t *)&throughputTestConfig, + sizeof(throughputTestConfig)); - if (UP_STREAM == throughputTestConfig.direction) - { - app_throughput_test_transmission_handler(NULL, 0); - #ifndef SLAVE_ADV_BLE - osTimerStart(app_throughput_test_data_xfer_lasting_timer_id, - throughputTestConfig.lastTimeInSecond*1000); - #endif + if (UP_STREAM == throughputTestConfig.direction) { + app_throughput_test_transmission_handler(NULL, 0); + osTimerStart(app_throughput_test_data_xfer_lasting_timer_id, + throughputTestConfig.lastTimeInSecond * 1000); } + } } -void app_throughput_test_init(void) -{ - memset(&throughputTestEnv, 0x00, sizeof(throughputTestEnv)); - memset(&throughputTestConfig, 0x00, sizeof(throughputTestConfig)); - - app_throughput_pre_config_pending_timer_id = - osTimerCreate(osTimer(APP_THROUGHPUT_PRE_CONFIG_PENDING_TIMER), - osTimerOnce, NULL); - - app_throughput_test_data_xfer_lasting_timer_id = - osTimerCreate(osTimer(APP_THROUGHPUT_TEST_DATA_XFER_LASTING_TIMER), - osTimerOnce, NULL); -} - -static uint32_t app_throughput_test_transmission_handler(void *param1, uint32_t param2) -{ - if (UP_STREAM == throughputTestConfig.direction) - { - app_throughput_send_command(THROUGHPUT_OP_THROUGHPUT_TEST_DATA, - app_throughput_datapattern, throughputTestConfig.dataPacketSize - 4); - } - - return 0; -} - -static void app_throughput_test_data_handler(APP_THROUGHPUT_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - if ((WITH_RSP == throughputTestConfig.responseModel) && - (AI_TRANSPORT_SPP == app_ai_get_transport_type())) - { - app_throughput_send_command(THROUGHPUT_OP_THROUGHPUT_TEST_DATA_ACK, NULL, 0); - } -} - -static void app_throughput_test_data_ack_handler(APP_THROUGHPUT_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - if (throughputTestEnv.isThroughputTestOn && - (WITH_RSP == throughputTestConfig.responseModel)) - { - app_throughput_test_transmission_handler(NULL, 0); - } -} - -static void app_throughput_test_done_signal_handler(APP_THROUGHPUT_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - app_stop_throughput_test(); -} - -void app_stop_throughput_test(void) -{ - throughputTestEnv.isThroughputTestOn = false; - osTimerStop(app_throughput_pre_config_pending_timer_id); - osTimerStop(app_throughput_test_data_xfer_lasting_timer_id); -} - -static void app_throughput_test_config_handler(APP_THROUGHPUT_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - throughputTestConfig = *(THROUGHPUT_TEST_CONFIG_T *)ptrParam; - - TRACE(4,"%s patter %d time %d response %d", __func__, \ - throughputTestConfig.dataPattern, \ - throughputTestConfig.lastTimeInSecond, \ - throughputTestConfig.responseModel); - - // generate the data pattern - switch (throughputTestConfig.dataPattern) - { - case PATTERN_RANDOM: - { - for (uint32_t index = 0;index < THROUGHPUT_DATA_MAX_SIZE;index++) - { - app_throughput_datapattern[index] = (uint8_t)rand(); - } - break; - } - case PATTERN_11110000: - { - memset(app_throughput_datapattern, 0xF0, THROUGHPUT_DATA_MAX_SIZE); - break; - } - case PATTERN_10101010: - { - memset(app_throughput_datapattern, 0xAA, THROUGHPUT_DATA_MAX_SIZE); - break; - } - case PATTERN_ALL_1: - { - memset(app_throughput_datapattern, 0xFF, THROUGHPUT_DATA_MAX_SIZE); - break; - } - case PATTERN_ALL_0: - { - memset(app_throughput_datapattern, 0, THROUGHPUT_DATA_MAX_SIZE); - break; - } - case PATTERN_00001111: - { - memset(app_throughput_datapattern, 0x0F, THROUGHPUT_DATA_MAX_SIZE); - break; - } - case PATTERN_0101: - { - memset(app_throughput_datapattern, 0x55, THROUGHPUT_DATA_MAX_SIZE); - break; - } - default: - throughputTestConfig.dataPattern = 0; - break; - } - - throughputTestEnv.isThroughputTestOn = true; - throughputTestEnv.conidx = app_ai_if_get_ble_connection_index(); - TRACE(2, "conidx 0x%x useSpecificConnParameter %d", throughputTestEnv.conidx, throughputTestConfig.isToUseSpecificConnParameter); - - // check whether need to use the new conn parameter - if (AI_TRANSPORT_BLE == app_ai_get_transport_type() - && throughputTestConfig.isToUseSpecificConnParameter) - { - if (throughputTestEnv.conidx != 0xFF) - { - l2cap_update_param(throughputTestEnv.conidx, throughputTestConfig.minConnIntervalInMs, - throughputTestConfig.maxConnIntervalInMs, - THROUGHPUT_BLE_CONNECTION_SUPERVISOR_TIMEOUT_IN_MS, - THROUGHPUT_BLE_CONNECTION_SLAVELATENCY); - } - - osTimerStart(app_throughput_pre_config_pending_timer_id, - APP_THROUGHPUT_PRE_CONFIG_PENDING_TIME_IN_MS); - } - else - { - app_throughput_send_command(THROUGHPUT_OP_INFORM_THROUGHPUT_TEST_CONFIG, - (uint8_t *)&throughputTestConfig, sizeof(throughputTestConfig)); - - if (UP_STREAM == throughputTestConfig.direction) - { - app_throughput_test_transmission_handler(NULL, 0); - osTimerStart(app_throughput_test_data_xfer_lasting_timer_id, - throughputTestConfig.lastTimeInSecond*1000); - } - } -} - - -APP_THROUGHPUT_CMD_INSTANCE_T through_put_table[APP_THROUGHPUT_CMD_INSTANCE_NUMBER] = -{ - {THROUGHPUT_OP_INFORM_THROUGHPUT_TEST_CONFIG, app_throughput_test_config_handler}, +APP_THROUGHPUT_CMD_INSTANCE_T +through_put_table[APP_THROUGHPUT_CMD_INSTANCE_NUMBER] = { + {THROUGHPUT_OP_INFORM_THROUGHPUT_TEST_CONFIG, + app_throughput_test_config_handler}, {THROUGHPUT_OP_THROUGHPUT_TEST_DATA, app_throughput_test_data_handler}, - {THROUGHPUT_OP_THROUGHPUT_TEST_DATA_ACK, app_throughput_test_data_ack_handler}, - {THROUGHPUT_OP_THROUGHPUT_TEST_DONE, app_throughput_test_done_signal_handler} -}; - + {THROUGHPUT_OP_THROUGHPUT_TEST_DATA_ACK, + app_throughput_test_data_ack_handler}, + {THROUGHPUT_OP_THROUGHPUT_TEST_DONE, + app_throughput_test_done_signal_handler}}; diff --git a/services/tota/app_spp_tota.cpp b/services/tota/app_spp_tota.cpp index 8f90c7a..8c17902 100644 --- a/services/tota/app_spp_tota.cpp +++ b/services/tota/app_spp_tota.cpp @@ -13,154 +13,138 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "cmsis_os.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_trace.h" -#include "hal_cmu.h" -#include "hal_chipid.h" #include "analog.h" #include "app_audio.h" -#include "app_status_ind.h" #include "app_bt_stream.h" +#include "app_status_ind.h" +#include "audioflinger.h" +#include "cmsis_os.h" +#include "hal_chipid.h" +#include "hal_cmu.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "lockcqueue.h" #include "nvrecord.h" #include "nvrecord_env.h" +#include //#include "nvrecord_dev.h" -#include "bluetooth.h" -#include "cqueue.h" -#include "resources.h" -#include "app_spp_tota.h" -#include "app_tota_cmd_code.h" -#include "app_tota.h" #include "app_spp.h" +#include "app_spp_tota.h" +#include "app_tota.h" +#include "app_tota_cmd_code.h" #include "app_tota_cmd_handler.h" #include "app_tota_data_handler.h" +#include "bluetooth.h" +#include "cqueue.h" #include "plat_types.h" -#include "spp_api.h" +#include "resources.h" #include "sdp_api.h" +#include "spp_api.h" //#include "app_bt_conn_mgr.h" #include "tota_stream_data_transfer.h" static bool isTotaSppConnected = false; -static struct spp_device *tota_spp_dev = NULL; -static struct spp_service *totaSppService = NULL; +static struct spp_device *tota_spp_dev = NULL; +static struct spp_service *totaSppService = NULL; osMutexDef(tota_spp_mutex); osMutexDef(tota_credit_mutex); static btif_sdp_record_t *tota_sdp_record = NULL; - static uint8_t totaSppTxBuf[TOTA_SPP_TX_BUF_SIZE]; static uint8_t spp_rx_buf[SPP_RECV_BUFFER_SIZE]; static uint32_t occupiedTotaSppTxBufSize; static uint32_t offsetToFillTotaSppTxData; -static uint8_t* ptrTotaSppTxBuf; +static uint8_t *ptrTotaSppTxBuf; -#if (TOTA_SHARE_TX_RX_BUF==1) +#if (TOTA_SHARE_TX_RX_BUF == 1) static const bool spp_share_application_rx_tx_buf = true; #else static const bool spp_share_application_rx_tx_buf = false; #endif /**/ -static map s_module_map; -static tota_callback_func_t s_module_func; -static APP_TOTA_MODULE_E s_module; +static map s_module_map; +static tota_callback_func_t s_module_func; +static APP_TOTA_MODULE_E s_module; /* register callback module */ -void tota_callback_module_register(APP_TOTA_MODULE_E module, tota_callback_func_t tota_callback_func) -{ - map::iterator it = s_module_map.find(module); - if ( it == s_module_map.end() ) - { - TOTA_LOG_DBG(0, "add to map"); - s_module_map.insert(make_pair(module, tota_callback_func)); - } - else - { - TOTA_LOG_DBG(0, "already exist, not add"); - } +void tota_callback_module_register(APP_TOTA_MODULE_E module, + tota_callback_func_t tota_callback_func) { + map::iterator it = + s_module_map.find(module); + if (it == s_module_map.end()) { + TOTA_LOG_DBG(0, "add to map"); + s_module_map.insert(make_pair(module, tota_callback_func)); + } else { + TOTA_LOG_DBG(0, "already exist, not add"); + } } /* set current module */ -void tota_callback_module_set(APP_TOTA_MODULE_E module) -{ - map::iterator it = s_module_map.find(module); - if ( it != s_module_map.end() ) - { - s_module = module; - s_module_func = it->second; - - TOTA_LOG_DBG(1, "set %d module success", module); - } - else - { - TOTA_LOG_DBG(0, "not find callback func by module"); - } +void tota_callback_module_set(APP_TOTA_MODULE_E module) { + map::iterator it = + s_module_map.find(module); + if (it != s_module_map.end()) { + s_module = module; + s_module_func = it->second; + + TOTA_LOG_DBG(1, "set %d module success", module); + } else { + TOTA_LOG_DBG(0, "not find callback func by module"); + } } /* get current module */ -APP_TOTA_MODULE_E tota_callback_module_get() -{ - return s_module; -} +APP_TOTA_MODULE_E tota_callback_module_get() { return s_module; } /* is tota busy, use to handle sniff */ -bool spp_tota_in_progress(void) -{ - TOTA_LOG_DBG(2,"[%s] isTotaSppConnected:%d", __func__, isTotaSppConnected); - if(isTotaSppConnected == true) - return true; - else - return false; +bool spp_tota_in_progress(void) { + TOTA_LOG_DBG(2, "[%s] isTotaSppConnected:%d", __func__, isTotaSppConnected); + if (isTotaSppConnected == true) + return true; + else + return false; } -void app_spp_tota_share_buf_create(uint8_t** tota_tx_buf, uint8_t** tota_rx_buf) -{ - *tota_tx_buf = NULL; - *tota_rx_buf = NULL; +void app_spp_tota_share_buf_create(uint8_t **tota_tx_buf, + uint8_t **tota_rx_buf) { + *tota_tx_buf = NULL; + *tota_rx_buf = NULL; - if(spp_share_application_rx_tx_buf == true){ - *tota_tx_buf = totaSppTxBuf; - *tota_rx_buf = spp_rx_buf; - } + if (spp_share_application_rx_tx_buf == true) { + *tota_tx_buf = totaSppTxBuf; + *tota_rx_buf = spp_rx_buf; + } } -bool app_spp_tota_is_to_share_buf(void) -{ - return spp_share_application_rx_tx_buf; +bool app_spp_tota_is_to_share_buf(void) { + return spp_share_application_rx_tx_buf; } -uint8_t * app_spp_tota_share_tx_buf_get(void) -{ - return (spp_share_application_rx_tx_buf == true)?(totaSppTxBuf):(NULL); +uint8_t *app_spp_tota_share_tx_buf_get(void) { + return (spp_share_application_rx_tx_buf == true) ? (totaSppTxBuf) : (NULL); } -uint8_t * app_spp_tota_share_rx_buf_get(void) -{ - return (spp_share_application_rx_tx_buf == true)?(spp_rx_buf):(NULL); +uint8_t *app_spp_tota_share_rx_buf_get(void) { + return (spp_share_application_rx_tx_buf == true) ? (spp_rx_buf) : (NULL); } -uint16_t app_spp_tota_tx_buf_size(void) -{ - return TOTA_SPP_TX_BUF_SIZE; +uint16_t app_spp_tota_tx_buf_size(void) { return TOTA_SPP_TX_BUF_SIZE; } + +void app_spp_tota_init_tx_buf(uint8_t *ptr) { + ptrTotaSppTxBuf = ptr; + occupiedTotaSppTxBufSize = 0; + offsetToFillTotaSppTxData = 0; } -void app_spp_tota_init_tx_buf(uint8_t* ptr) -{ - ptrTotaSppTxBuf = ptr; - occupiedTotaSppTxBufSize = 0; - offsetToFillTotaSppTxData = 0; -} - -extern "C" APP_TOTA_CMD_RET_STATUS_E app_tota_data_received(uint8_t* ptrData, uint32_t dataLength); -extern "C" APP_TOTA_CMD_RET_STATUS_E app_tota_cmd_received(uint8_t* ptrData, uint32_t dataLength); - +extern "C" APP_TOTA_CMD_RET_STATUS_E +app_tota_data_received(uint8_t *ptrData, uint32_t dataLength); +extern "C" APP_TOTA_CMD_RET_STATUS_E app_tota_cmd_received(uint8_t *ptrData, + uint32_t dataLength); /**************************************************************************** * TOTA SPP SDP Entries @@ -168,30 +152,30 @@ extern "C" APP_TOTA_CMD_RET_STATUS_E app_tota_cmd_received(uint8_t* ptrData, uin /*--------------------------------------------------------------------------- * - * ServiceClassIDList + * ServiceClassIDList */ static const U8 TotaSppClassId[] = { - SDP_ATTRIB_HEADER_8BIT(3), /* Data Element Sequence, 6 bytes */ - SDP_UUID_16BIT(SC_SERIAL_PORT), /* Hands-Free UUID in Big Endian */ + SDP_ATTRIB_HEADER_8BIT(3), /* Data Element Sequence, 6 bytes */ + SDP_UUID_16BIT(SC_SERIAL_PORT), /* Hands-Free UUID in Big Endian */ }; static const U8 TotaSppProtoDescList[] = { - SDP_ATTRIB_HEADER_8BIT(12), /* Data element sequence, 12 bytes */ + SDP_ATTRIB_HEADER_8BIT(12), /* Data element sequence, 12 bytes */ - /* Each element of the list is a Protocol descriptor which is a - * data element sequence. The first element is L2CAP which only - * has a UUID element. - */ - SDP_ATTRIB_HEADER_8BIT(3), /* Data element sequence for L2CAP, 3 - * bytes - */ + /* Each element of the list is a Protocol descriptor which is a + * data element sequence. The first element is L2CAP which only + * has a UUID element. + */ + SDP_ATTRIB_HEADER_8BIT(3), /* Data element sequence for L2CAP, 3 + * bytes + */ - SDP_UUID_16BIT(PROT_L2CAP), /* Uuid16 L2CAP */ + SDP_UUID_16BIT(PROT_L2CAP), /* Uuid16 L2CAP */ - /* Next protocol descriptor in the list is RFCOMM. It contains two - * elements which are the UUID and the channel. Ultimately this - * channel will need to filled in with value returned by RFCOMM. - */ + /* Next protocol descriptor in the list is RFCOMM. It contains two + * elements which are the UUID and the channel. Ultimately this + * channel will need to filled in with value returned by RFCOMM. + */ /* Data element sequence for RFCOMM, 5 bytes */ SDP_ATTRIB_HEADER_8BIT(5), @@ -199,44 +183,49 @@ static const U8 TotaSppProtoDescList[] = { SDP_UUID_16BIT(PROT_RFCOMM), /* Uuid16 RFCOMM */ /* Uint8 RFCOMM channel number - value can vary */ - SDP_UINT_8BIT(RFCOMM_CHANNEL_TOTA) -}; + SDP_UINT_8BIT(RFCOMM_CHANNEL_TOTA)}; /* * BluetoothProfileDescriptorList */ static const U8 TotaSppProfileDescList[] = { - SDP_ATTRIB_HEADER_8BIT(8), /* Data element sequence, 8 bytes */ + SDP_ATTRIB_HEADER_8BIT(8), /* Data element sequence, 8 bytes */ /* Data element sequence for ProfileDescriptor, 6 bytes */ SDP_ATTRIB_HEADER_8BIT(6), - SDP_UUID_16BIT(SC_SERIAL_PORT), /* Uuid16 SPP */ - SDP_UINT_16BIT(0x0102) /* As per errata 2239 */ + SDP_UUID_16BIT(SC_SERIAL_PORT), /* Uuid16 SPP */ + SDP_UINT_16BIT(0x0102) /* As per errata 2239 */ }; /* * * OPTIONAL * ServiceName */ static const U8 TotaSppServiceName1[] = { - SDP_TEXT_8BIT(5), /* Null terminated text string */ - 'S', 'p', 'p', '1', '\0' -}; + SDP_TEXT_8BIT(5), /* Null terminated text string */ + 'S', + 'p', + 'p', + '1', + '\0'}; static const U8 TotaSppServiceName2[] = { - SDP_TEXT_8BIT(5), /* Null terminated text string */ - 'S', 'p', 'p', '2', '\0' -}; + SDP_TEXT_8BIT(5), /* Null terminated text string */ + 'S', + 'p', + 'p', + '2', + '\0'}; /* SPP attributes. * * This is a ROM template for the RAM structure used to register the * SPP SDP record. */ -//static const SdpAttribute TotaSppSdpAttributes1[] = { +// static const SdpAttribute TotaSppSdpAttributes1[] = { static sdp_attribute_t TotaSppSdpAttributes1[] = { - SDP_ATTRIBUTE(AID_SERVICE_CLASS_ID_LIST, TotaSppClassId), + SDP_ATTRIBUTE(AID_SERVICE_CLASS_ID_LIST, TotaSppClassId), SDP_ATTRIBUTE(AID_PROTOCOL_DESC_LIST, TotaSppProtoDescList), @@ -249,125 +238,114 @@ static sdp_attribute_t TotaSppSdpAttributes1[] = { /* static sdp_attribute_t TotaSppSdpAttributes2[] = { - SDP_ATTRIBUTE(AID_SERVICE_CLASS_ID_LIST, TotaSppClassId), + SDP_ATTRIBUTE(AID_SERVICE_CLASS_ID_LIST, TotaSppClassId), SDP_ATTRIBUTE(AID_PROTOCOL_DESC_LIST, TotaSppProtoDescList), SDP_ATTRIBUTE(AID_BT_PROFILE_DESC_LIST, TotaSppProfileDescList), - + SDP_ATTRIBUTE((AID_SERVICE_NAME + 0x0100), TotaSppServiceName2), }; */ -int tota_spp_handle_data_event_func(void *pDev, uint8_t process, uint8_t *pData, uint16_t dataLen) -{ - TOTA_LOG_DBG(2,"[%s]data receive length = %d", __func__, dataLen); - TOTA_LOG_DUMP("[0x%x]", pData, dataLen); - - if ( s_module_func.tota_spp_data_receive_hanle != NULL ) - s_module_func.tota_spp_data_receive_hanle(pData, (uint32_t)dataLen); +int tota_spp_handle_data_event_func(void *pDev, uint8_t process, uint8_t *pData, + uint16_t dataLen) { + TOTA_LOG_DBG(2, "[%s]data receive length = %d", __func__, dataLen); + TOTA_LOG_DUMP("[0x%x]", pData, dataLen); - // the first two bytes of the data packet is the fixed value 0xFFFF - app_tota_handle_received_data(pData, dataLen); + if (s_module_func.tota_spp_data_receive_hanle != NULL) + s_module_func.tota_spp_data_receive_hanle(pData, (uint32_t)dataLen); - return 0; + // the first two bytes of the data packet is the fixed value 0xFFFF + app_tota_handle_received_data(pData, dataLen); + + return 0; } -static void spp_tota_callback(struct spp_device *locDev, struct spp_callback_parms *Info) -{ - if (BTIF_SPP_EVENT_REMDEV_CONNECTED == Info->event) - { - TOTA_LOG_DBG(1,"::BTIF_SPP_EVENT_REMDEV_CONNECTED %d\n", Info->event); - isTotaSppConnected = true; - app_tota_connected(APP_TOTA_CONNECTED); - app_tota_update_datapath(APP_TOTA_VIA_SPP); - //conn_stop_connecting_mobile_supervising(); - if ( s_module_func.tota_spp_connected != NULL ) - s_module_func.tota_spp_connected(); - } - else if (BTIF_SPP_EVENT_REMDEV_DISCONNECTED == Info->event) - { - TOTA_LOG_DBG(1,"::BTIF_SPP_EVENT_REMDEV_DISCONNECTED %d\n", Info->event); - isTotaSppConnected = false; - app_tota_disconnected(APP_TOTA_DISCONNECTED); - app_tota_update_datapath(APP_TOTA_PATH_IDLE); - if ( s_module_func.tota_spp_disconnected != NULL ) - s_module_func.tota_spp_disconnected(); - } - else if (BTIF_SPP_EVENT_DATA_SENT == Info->event) - { - app_tota_tx_done_callback(); - if ( s_module_func.tota_spp_tx_done != NULL ) - s_module_func.tota_spp_tx_done(); - } - else - { - TOTA_LOG_DBG(1,"::unknown event %d\n", Info->event); - } +static void spp_tota_callback(struct spp_device *locDev, + struct spp_callback_parms *Info) { + if (BTIF_SPP_EVENT_REMDEV_CONNECTED == Info->event) { + TOTA_LOG_DBG(1, "::BTIF_SPP_EVENT_REMDEV_CONNECTED %d\n", Info->event); + isTotaSppConnected = true; + app_tota_connected(APP_TOTA_CONNECTED); + app_tota_update_datapath(APP_TOTA_VIA_SPP); + // conn_stop_connecting_mobile_supervising(); + if (s_module_func.tota_spp_connected != NULL) + s_module_func.tota_spp_connected(); + } else if (BTIF_SPP_EVENT_REMDEV_DISCONNECTED == Info->event) { + TOTA_LOG_DBG(1, "::BTIF_SPP_EVENT_REMDEV_DISCONNECTED %d\n", Info->event); + isTotaSppConnected = false; + app_tota_disconnected(APP_TOTA_DISCONNECTED); + app_tota_update_datapath(APP_TOTA_PATH_IDLE); + if (s_module_func.tota_spp_disconnected != NULL) + s_module_func.tota_spp_disconnected(); + } else if (BTIF_SPP_EVENT_DATA_SENT == Info->event) { + app_tota_tx_done_callback(); + if (s_module_func.tota_spp_tx_done != NULL) + s_module_func.tota_spp_tx_done(); + } else { + TOTA_LOG_DBG(1, "::unknown event %d\n", Info->event); + } } -bool app_spp_tota_send_data(uint8_t* ptrData, uint16_t length) -{ - if (!isTotaSppConnected) - { - return false; - } - btif_spp_write(tota_spp_dev, (char *)ptrData, &length); - return true; +bool app_spp_tota_send_data(uint8_t *ptrData, uint16_t length) { + if (!isTotaSppConnected) { + return false; + } + btif_spp_write(tota_spp_dev, (char *)ptrData, &length); + return true; } -void app_spp_tota_init(void) -{ - uint8_t *rx_buf; - uint8_t * tx_buf; - osMutexId mid; - btif_sdp_record_param_t param; +void app_spp_tota_init(void) { + uint8_t *rx_buf; + uint8_t *tx_buf; + osMutexId mid; + btif_sdp_record_param_t param; - if(tota_spp_dev == NULL) - tota_spp_dev = btif_create_spp_device(); + if (tota_spp_dev == NULL) + tota_spp_dev = btif_create_spp_device(); - if(app_spp_tota_is_to_share_buf() == true){ - app_spp_tota_share_buf_create(&tx_buf,&rx_buf); - }else{ - rx_buf = &spp_rx_buf[0]; - tx_buf = &totaSppTxBuf[0]; - } - - tota_spp_dev->rx_buffer = rx_buf; + if (app_spp_tota_is_to_share_buf() == true) { + app_spp_tota_share_buf_create(&tx_buf, &rx_buf); + } else { + rx_buf = &spp_rx_buf[0]; + tx_buf = &totaSppTxBuf[0]; + } - app_spp_tota_init_tx_buf(tx_buf); - btif_spp_init_rx_buf(tota_spp_dev, rx_buf, SPP_RECV_BUFFER_SIZE); + tota_spp_dev->rx_buffer = rx_buf; + app_spp_tota_init_tx_buf(tx_buf); + btif_spp_init_rx_buf(tota_spp_dev, rx_buf, SPP_RECV_BUFFER_SIZE); - mid = osMutexCreate(osMutex(tota_spp_mutex)); - if (!mid) { - ASSERT(0, "cannot create mutex"); - } + mid = osMutexCreate(osMutex(tota_spp_mutex)); + if (!mid) { + ASSERT(0, "cannot create mutex"); + } - osMutexId creditMutex = osMutexCreate(osMutex(tota_credit_mutex)); + osMutexId creditMutex = osMutexCreate(osMutex(tota_credit_mutex)); - tota_spp_dev->creditMutex = creditMutex; + tota_spp_dev->creditMutex = creditMutex; - if (tota_sdp_record == NULL) - tota_sdp_record = btif_sdp_create_record(); + if (tota_sdp_record == NULL) + tota_sdp_record = btif_sdp_create_record(); - param.attrs = &TotaSppSdpAttributes1[0], - param.attr_count = ARRAY_SIZE(TotaSppSdpAttributes1); - param.COD = BTIF_COD_MAJOR_PERIPHERAL; - btif_sdp_record_setup(tota_sdp_record, ¶m); + param.attrs = &TotaSppSdpAttributes1[0], + param.attr_count = ARRAY_SIZE(TotaSppSdpAttributes1); + param.COD = BTIF_COD_MAJOR_PERIPHERAL; + btif_sdp_record_setup(tota_sdp_record, ¶m); - if(totaSppService == NULL) - totaSppService = btif_create_spp_service(); + if (totaSppService == NULL) + totaSppService = btif_create_spp_service(); - totaSppService->rf_service.serviceId = RFCOMM_CHANNEL_TOTA; - totaSppService->numPorts = 0; - btif_spp_service_setup(tota_spp_dev, totaSppService, tota_sdp_record); + totaSppService->rf_service.serviceId = RFCOMM_CHANNEL_TOTA; + totaSppService->numPorts = 0; + btif_spp_service_setup(tota_spp_dev, totaSppService, tota_sdp_record); - tota_spp_dev->portType = BTIF_SPP_SERVER_PORT; - tota_spp_dev->app_id = BTIF_APP_SPP_SERVER_TOTA_ID; - tota_spp_dev->spp_handle_data_event_func = tota_spp_handle_data_event_func; - btif_spp_init_device(tota_spp_dev, 5, mid); + tota_spp_dev->portType = BTIF_SPP_SERVER_PORT; + tota_spp_dev->app_id = BTIF_APP_SPP_SERVER_TOTA_ID; + tota_spp_dev->spp_handle_data_event_func = tota_spp_handle_data_event_func; + btif_spp_init_device(tota_spp_dev, 5, mid); - btif_spp_open(tota_spp_dev, NULL, spp_tota_callback); + btif_spp_open(tota_spp_dev, NULL, spp_tota_callback); } diff --git a/services/tota/app_spp_tota_general_service.cpp b/services/tota/app_spp_tota_general_service.cpp index 90bf1fc..f390ddf 100644 --- a/services/tota/app_spp_tota_general_service.cpp +++ b/services/tota/app_spp_tota_general_service.cpp @@ -13,21 +13,21 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include -#include "cmsis_os.h" -#include "hal_uart.h" -#include "hal_timer.h" -#include "audioflinger.h" -#include "lockcqueue.h" -#include "hal_trace.h" -#include "hal_cmu.h" -#include "hal_chipid.h" #include "analog.h" #include "app_audio.h" -#include "app_status_ind.h" #include "app_bt_stream.h" +#include "app_status_ind.h" +#include "audioflinger.h" +#include "cmsis_os.h" +#include "hal_chipid.h" +#include "hal_cmu.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "hal_uart.h" +#include "lockcqueue.h" #include "nvrecord.h" #include "nvrecord_env.h" +#include //#include "nvrecord_dev.h" #include "bluetooth.h" @@ -35,13 +35,13 @@ #ifdef MBED #include "rtos.h" #endif -#include "resources.h" -#include "app_spp_tota.h" -#include "app_tota_cmd_code.h" -#include "app_tota.h" #include "app_spp.h" +#include "app_spp_tota.h" +#include "app_tota.h" +#include "app_tota_cmd_code.h" #include "app_tota_cmd_handler.h" #include "app_tota_data_handler.h" +#include "resources.h" #include "plat_types.h" #include "sdp_api.h" @@ -49,19 +49,20 @@ osMutexDef(tota_spp_gen_mutex); static bool isTotaSppGeneralConnected = false; -static struct spp_device *tota_spp_gen_dev = NULL; -static struct spp_service *totaSppGenService = NULL; +static struct spp_device *tota_spp_gen_dev = NULL; +static struct spp_service *totaSppGenService = NULL; static btif_sdp_record_t *tota_sdp_gen_record = NULL; osThreadId tota_spp_gen_read_thread_id = NULL; static app_spp_tota_tx_done_t app_spp_tota_gen_tx_done_func = NULL; -#if (TOTA_SHARE_TX_RX_BUF==1) -extern void app_spp_tota_share_buf_create(uint8_t** tota_tx_buf, uint8_t** tota_rx_buf); +#if (TOTA_SHARE_TX_RX_BUF == 1) +extern void app_spp_tota_share_buf_create(uint8_t **tota_tx_buf, + uint8_t **tota_rx_buf); extern bool app_spp_tota_is_to_share_buf(void); -extern uint8_t * app_spp_tota_share_tx_buf_get(void); -extern uint8_t * app_spp_tota_share_rx_buf_get(void); +extern uint8_t *app_spp_tota_share_tx_buf_get(void); +extern uint8_t *app_spp_tota_share_rx_buf_get(void); extern uint16_t app_spp_tota_tx_buf_size(void); #else static uint8_t spp_rx_buf[SPP_RECV_BUFFER_SIZE]; @@ -70,61 +71,58 @@ static uint8_t totaSppGenTxBuf[TOTA_SPP_TX_BUF_SIZE]; static uint32_t occupiedTotaSppGenTxBufSize; static uint32_t offsetToFillTotaSppGenTxData; -static uint8_t* ptrTotaSppGenTxBuf; +static uint8_t *ptrTotaSppGenTxBuf; -uint16_t app_spp_tota_gen_tx_buf_size(void) -{ - return TOTA_SPP_TX_BUF_SIZE; +uint16_t app_spp_tota_gen_tx_buf_size(void) { return TOTA_SPP_TX_BUF_SIZE; } + +void app_spp_tota_gen_init_tx_buf(uint8_t *ptr) { + ptrTotaSppGenTxBuf = ptr; + occupiedTotaSppGenTxBufSize = 0; + offsetToFillTotaSppGenTxData = 0; } -void app_spp_tota_gen_init_tx_buf(uint8_t* ptr) -{ - ptrTotaSppGenTxBuf = ptr; - occupiedTotaSppGenTxBufSize = 0; +static void app_spp_tota_gen_free_tx_buf(uint8_t *ptrData, uint32_t dataLen) { + if (occupiedTotaSppGenTxBufSize > 0) { + occupiedTotaSppGenTxBufSize -= dataLen; + } + TOTA_LOG_DBG(1, "occupiedTotaSppGenTxBufSize %d", + occupiedTotaSppGenTxBufSize); +} + +uint8_t *app_spp_tota_gen_fill_data_into_tx_buf(uint8_t *ptrData, + uint32_t dataLen) { + ASSERT((occupiedTotaSppGenTxBufSize + dataLen) < TOTA_SPP_TX_BUF_SIZE, + "Pending SPP General tx data has exceeded the tx buffer size !"); + + if ((offsetToFillTotaSppGenTxData + dataLen) > TOTA_SPP_TX_BUF_SIZE) { offsetToFillTotaSppGenTxData = 0; + } + + uint8_t *filledPtr = ptrTotaSppGenTxBuf + offsetToFillTotaSppGenTxData; + memcpy(filledPtr, ptrData, dataLen); + + offsetToFillTotaSppGenTxData += dataLen; + + occupiedTotaSppGenTxBufSize += dataLen; + + TOTA_LOG_DBG(3, + "dataLen %d offsetToFillTotaSppGenTxData %d " + "occupiedTotaSppGenTxBufSize %d", + dataLen, offsetToFillTotaSppGenTxData, + occupiedTotaSppGenTxBufSize); + + return filledPtr; } -static void app_spp_tota_gen_free_tx_buf(uint8_t* ptrData, uint32_t dataLen) -{ - if (occupiedTotaSppGenTxBufSize > 0) - { - occupiedTotaSppGenTxBufSize -= dataLen; - } - TOTA_LOG_DBG(1,"occupiedTotaSppGenTxBufSize %d", occupiedTotaSppGenTxBufSize); -} - -uint8_t* app_spp_tota_gen_fill_data_into_tx_buf(uint8_t* ptrData, uint32_t dataLen) -{ - ASSERT((occupiedTotaSppGenTxBufSize + dataLen) < TOTA_SPP_TX_BUF_SIZE, - "Pending SPP General tx data has exceeded the tx buffer size !"); - - - if ((offsetToFillTotaSppGenTxData + dataLen) > TOTA_SPP_TX_BUF_SIZE) - { - offsetToFillTotaSppGenTxData = 0; - } - - uint8_t* filledPtr = ptrTotaSppGenTxBuf + offsetToFillTotaSppGenTxData; - memcpy(filledPtr, ptrData, dataLen); - - offsetToFillTotaSppGenTxData += dataLen; - - occupiedTotaSppGenTxBufSize += dataLen; - - TOTA_LOG_DBG(3,"dataLen %d offsetToFillTotaSppGenTxData %d occupiedTotaSppGenTxBufSize %d", - dataLen, offsetToFillTotaSppGenTxData, occupiedTotaSppGenTxBufSize); - - return filledPtr; -} - -extern "C" APP_TOTA_CMD_RET_STATUS_E app_tota_data_received(uint8_t* ptrData, uint32_t dataLength); -extern "C" APP_TOTA_CMD_RET_STATUS_E app_tota_cmd_received(uint8_t* ptrData, uint32_t dataLength); - +extern "C" APP_TOTA_CMD_RET_STATUS_E +app_tota_data_received(uint8_t *ptrData, uint32_t dataLength); +extern "C" APP_TOTA_CMD_RET_STATUS_E app_tota_cmd_received(uint8_t *ptrData, + uint32_t dataLength); /**************************************************************************** * TOTA SPP SDP Entries ****************************************************************************/ - #if 0 +#if 0 static const U8 TotaGenClassId[] = { SDP_ATTRIB_HEADER_8BIT(3), /* Data Element Sequence, 6 bytes */ SDP_UUID_16BIT(SC_SERIAL_PORT), /* Hands-Free UUID in Big Endian */ @@ -144,45 +142,45 @@ static const U8 TotaGenClassId[] = { }; #else static const U8 TotaGenClassId[] = { - SDP_ATTRIB_HEADER_8BIT(17), - DETD_UUID + DESD_16BYTES, + SDP_ATTRIB_HEADER_8BIT(17), + DETD_UUID + DESD_16BYTES, 0x8a, - 0x48,\ - 0x2a,\ - 0x08,\ - 0x55,\ - 0x07,\ - 0x42,\ - 0xac,\ - 0xb6,\ - 0x73,\ - 0xa8,\ - 0x8d,\ - 0xf4,\ - 0x8b,\ - 0x3f,\ - 0xc7, + 0x48, + 0x2a, + 0x08, + 0x55, + 0x07, + 0x42, + 0xac, + 0xb6, + 0x73, + 0xa8, + 0x8d, + 0xf4, + 0x8b, + 0x3f, + 0xc7, }; #endif static const U8 TotaSppGenProtoDescList[] = { - SDP_ATTRIB_HEADER_8BIT(12), /* Data element sequence, 12 bytes */ + SDP_ATTRIB_HEADER_8BIT(12), /* Data element sequence, 12 bytes */ - /* Each element of the list is a Protocol descriptor which is a - * data element sequence. The first element is L2CAP which only - * has a UUID element. - */ - SDP_ATTRIB_HEADER_8BIT(3), /* Data element sequence for L2CAP, 3 - * bytes - */ + /* Each element of the list is a Protocol descriptor which is a + * data element sequence. The first element is L2CAP which only + * has a UUID element. + */ + SDP_ATTRIB_HEADER_8BIT(3), /* Data element sequence for L2CAP, 3 + * bytes + */ - SDP_UUID_16BIT(PROT_L2CAP), /* Uuid16 L2CAP */ + SDP_UUID_16BIT(PROT_L2CAP), /* Uuid16 L2CAP */ - /* Next protocol descriptor in the list is RFCOMM. It contains two - * elements which are the UUID and the channel. Ultimately this - * channel will need to filled in with value returned by RFCOMM. - */ + /* Next protocol descriptor in the list is RFCOMM. It contains two + * elements which are the UUID and the channel. Ultimately this + * channel will need to filled in with value returned by RFCOMM. + */ /* Data element sequence for RFCOMM, 5 bytes */ SDP_ATTRIB_HEADER_8BIT(5), @@ -190,34 +188,45 @@ static const U8 TotaSppGenProtoDescList[] = { SDP_UUID_16BIT(PROT_RFCOMM), /* Uuid16 RFCOMM */ /* Uint8 RFCOMM channel number - value can vary */ - SDP_UINT_8BIT(RFCOMM_CHANNEL_TOTA_GENERAL) -}; + SDP_UINT_8BIT(RFCOMM_CHANNEL_TOTA_GENERAL)}; /* * BluetoothProfileDescriptorList */ static const U8 TotaSppGenProfileDescList[] = { - SDP_ATTRIB_HEADER_8BIT(8), /* Data element sequence, 8 bytes */ + SDP_ATTRIB_HEADER_8BIT(8), /* Data element sequence, 8 bytes */ /* Data element sequence for ProfileDescriptor, 6 bytes */ SDP_ATTRIB_HEADER_8BIT(6), - SDP_UUID_16BIT(SC_SERIAL_PORT), /* Uuid16 SPP */ - SDP_UINT_16BIT(0x0102) /* As per errata 2239 */ + SDP_UUID_16BIT(SC_SERIAL_PORT), /* Uuid16 SPP */ + SDP_UINT_16BIT(0x0102) /* As per errata 2239 */ }; /* * * OPTIONAL * ServiceName */ static const U8 TotaSppGenServiceName1[] = { - SDP_TEXT_8BIT(8), /* Null terminated text string */ - 'S', 'p', 'p', 'G','e','n', '1','\0' -}; + SDP_TEXT_8BIT(8), /* Null terminated text string */ + 'S', + 'p', + 'p', + 'G', + 'e', + 'n', + '1', + '\0'}; static const U8 TotaSppGenServiceName2[] = { - SDP_TEXT_8BIT(8), /* Null terminated text string */ - 'S', 'p', 'p', 'G','e','n', '2','\0' -}; + SDP_TEXT_8BIT(8), /* Null terminated text string */ + 'S', + 'p', + 'p', + 'G', + 'e', + 'n', + '2', + '\0'}; /* SPP attributes. * @@ -226,7 +235,7 @@ static const U8 TotaSppGenServiceName2[] = { */ static sdp_attribute_t TotaSppGenSdpAttributes1[] = { - SDP_ATTRIBUTE(AID_SERVICE_CLASS_ID_LIST, TotaGenClassId), + SDP_ATTRIBUTE(AID_SERVICE_CLASS_ID_LIST, TotaGenClassId), SDP_ATTRIBUTE(AID_PROTOCOL_DESC_LIST, TotaSppGenProtoDescList), @@ -239,7 +248,7 @@ static sdp_attribute_t TotaSppGenSdpAttributes1[] = { /* static sdp_attribute_t TotaSppGenSdpAttributes2[] = { - SDP_ATTRIBUTE(AID_SERVICE_CLASS_ID_LIST, TotaGenClassId), + SDP_ATTRIBUTE(AID_SERVICE_CLASS_ID_LIST, TotaGenClassId), SDP_ATTRIBUTE(AID_PROTOCOL_DESC_LIST, TotaSppGenProtoDescList), @@ -254,14 +263,15 @@ extern "C" void reset_programmer_state(unsigned char **buf, size_t *len); extern unsigned char *g_buf; extern size_t g_len; -static int tota_general_spp_handle_data_event_func(void *pDev, uint8_t process, uint8_t *pData, uint16_t dataLen) -{ - TOTA_LOG_DBG(2,"[%s]data receive length = %d", __func__, dataLen); - TOTA_LOG_DUMP("[0x%x]", pData, dataLen); - // the first two bytes of the data packet is the fixed value 0xFFFF - app_tota_handle_received_data(pData, dataLen); +static int tota_general_spp_handle_data_event_func(void *pDev, uint8_t process, + uint8_t *pData, + uint16_t dataLen) { + TOTA_LOG_DBG(2, "[%s]data receive length = %d", __func__, dataLen); + TOTA_LOG_DUMP("[0x%x]", pData, dataLen); + // the first two bytes of the data packet is the fixed value 0xFFFF + app_tota_handle_received_data(pData, dataLen); - return 0; + return 0; } #if 0 @@ -299,119 +309,107 @@ static void app_spp_tota_gen_close_read_thread(void) } } #endif -static void spp_tota_gen_callback(struct spp_device *locDev, struct spp_callback_parms *Info) -{ - TOTA_LOG_DBG(1,"%s",__func__); - if (BTIF_SPP_EVENT_REMDEV_CONNECTED == Info->event) - { - TOTA_LOG_DBG(1,"::SPP_GENERAL_EVENT_REMDEV_CONNECTED %d\n", Info->event); - isTotaSppGeneralConnected = true; -// app_spp_tota_gen_create_read_thread(); - app_tota_general_connected(APP_TOTA_CONNECTED); - app_tota_update_datapath(APP_TOTA_GEN_VIA_SPP); - //conn_stop_connecting_mobile_supervising(); - } - else if (BTIF_SPP_EVENT_REMDEV_DISCONNECTED == Info->event) - { - TOTA_LOG_DBG(1,"::SPP_GENERAL_EVENT_REMDEV_DISCONNECTED %d\n", Info->event); - isTotaSppGeneralConnected = false; -// app_spp_tota_gen_close_read_thread(); - app_tota_disconnected(APP_TOTA_DISCONNECTED); - app_tota_update_datapath(APP_TOTA_PATH_IDLE); +static void spp_tota_gen_callback(struct spp_device *locDev, + struct spp_callback_parms *Info) { + TOTA_LOG_DBG(1, "%s", __func__); + if (BTIF_SPP_EVENT_REMDEV_CONNECTED == Info->event) { + TOTA_LOG_DBG(1, "::SPP_GENERAL_EVENT_REMDEV_CONNECTED %d\n", Info->event); + isTotaSppGeneralConnected = true; + // app_spp_tota_gen_create_read_thread(); + app_tota_general_connected(APP_TOTA_CONNECTED); + app_tota_update_datapath(APP_TOTA_GEN_VIA_SPP); + // conn_stop_connecting_mobile_supervising(); + } else if (BTIF_SPP_EVENT_REMDEV_DISCONNECTED == Info->event) { + TOTA_LOG_DBG(1, "::SPP_GENERAL_EVENT_REMDEV_DISCONNECTED %d\n", + Info->event); + isTotaSppGeneralConnected = false; + // app_spp_tota_gen_close_read_thread(); + app_tota_disconnected(APP_TOTA_DISCONNECTED); + app_tota_update_datapath(APP_TOTA_PATH_IDLE); - app_spp_tota_gen_tx_done_func = NULL; - } - else if (BTIF_SPP_EVENT_DATA_SENT == Info->event) - { - //app_spp_tota_gen_free_tx_buf(Info->tx_buf, Info->tx_data_len); - struct spp_tx_done *pTxDone = (struct spp_tx_done *)(Info->p.other); - app_spp_tota_gen_free_tx_buf(pTxDone->tx_buf, pTxDone->tx_data_length); - if (app_spp_tota_gen_tx_done_func) - { - app_spp_tota_gen_tx_done_func(); - } - } - else - { - TOTA_LOG_DBG(1,"::spp general unknown event %d\n", Info->event); + app_spp_tota_gen_tx_done_func = NULL; + } else if (BTIF_SPP_EVENT_DATA_SENT == Info->event) { + // app_spp_tota_gen_free_tx_buf(Info->tx_buf, Info->tx_data_len); + struct spp_tx_done *pTxDone = (struct spp_tx_done *)(Info->p.other); + app_spp_tota_gen_free_tx_buf(pTxDone->tx_buf, pTxDone->tx_data_length); + if (app_spp_tota_gen_tx_done_func) { + app_spp_tota_gen_tx_done_func(); } + } else { + TOTA_LOG_DBG(1, "::spp general unknown event %d\n", Info->event); + } } -static void app_spp_tota_gen_send_data(uint8_t* ptrData, uint16_t length) -{ - if (!isTotaSppGeneralConnected) - { - return; - } +static void app_spp_tota_gen_send_data(uint8_t *ptrData, uint16_t length) { + if (!isTotaSppGeneralConnected) { + return; + } - btif_spp_write(tota_spp_gen_dev, (char *)ptrData, &length); + btif_spp_write(tota_spp_gen_dev, (char *)ptrData, &length); } -void app_tota_gen_send_cmd_via_spp(uint8_t* ptrData, uint32_t length) -{ - uint8_t* ptrBuf = app_spp_tota_gen_fill_data_into_tx_buf(ptrData, length); - app_spp_tota_gen_send_data(ptrBuf, (uint16_t)length); +void app_tota_gen_send_cmd_via_spp(uint8_t *ptrData, uint32_t length) { + uint8_t *ptrBuf = app_spp_tota_gen_fill_data_into_tx_buf(ptrData, length); + app_spp_tota_gen_send_data(ptrBuf, (uint16_t)length); } -void app_tota_gen_send_data_via_spp(uint8_t* ptrData, uint32_t length) -{ - TOTA_LOG_DBG(2,"[%s]tota gen send data length = %d",__func__,length); - uint8_t* ptrBuf = app_spp_tota_gen_fill_data_into_tx_buf(ptrData, length); - app_spp_tota_gen_send_data(ptrBuf, (uint16_t)length); +void app_tota_gen_send_data_via_spp(uint8_t *ptrData, uint32_t length) { + TOTA_LOG_DBG(2, "[%s]tota gen send data length = %d", __func__, length); + uint8_t *ptrBuf = app_spp_tota_gen_fill_data_into_tx_buf(ptrData, length); + app_spp_tota_gen_send_data(ptrBuf, (uint16_t)length); } -void app_spp_tota_gen_init(void) -{ - uint8_t *rx_buf; - uint8_t *tx_buf; - osMutexId mid; - btif_sdp_record_param_t param; +void app_spp_tota_gen_init(void) { + uint8_t *rx_buf; + uint8_t *tx_buf; + osMutexId mid; + btif_sdp_record_param_t param; - if (tota_spp_gen_dev == NULL) - { - tota_spp_gen_dev = btif_create_spp_device(); - } + if (tota_spp_gen_dev == NULL) { + tota_spp_gen_dev = btif_create_spp_device(); + } - if(app_spp_tota_is_to_share_buf() == true){ - app_spp_tota_share_buf_create(&tx_buf,&rx_buf); - } -#if (TOTA_SHARE_TX_RX_BUF==0) - else{ - rx_buf = &spp_rx_buf[0]; - tx_buf = &totaSppGenTxBuf[0]; - } + if (app_spp_tota_is_to_share_buf() == true) { + app_spp_tota_share_buf_create(&tx_buf, &rx_buf); + } +#if (TOTA_SHARE_TX_RX_BUF == 0) + else { + rx_buf = &spp_rx_buf[0]; + tx_buf = &totaSppGenTxBuf[0]; + } #endif - tota_spp_gen_dev->rx_buffer = rx_buf; + tota_spp_gen_dev->rx_buffer = rx_buf; - app_spp_tota_gen_init_tx_buf(tx_buf); - btif_spp_init_rx_buf(tota_spp_gen_dev, rx_buf, SPP_RECV_BUFFER_SIZE); + app_spp_tota_gen_init_tx_buf(tx_buf); + btif_spp_init_rx_buf(tota_spp_gen_dev, rx_buf, SPP_RECV_BUFFER_SIZE); - mid = osMutexCreate(osMutex(tota_spp_gen_mutex)); - if (!mid) { - ASSERT(0, "cannot create mutex"); - } + mid = osMutexCreate(osMutex(tota_spp_gen_mutex)); + if (!mid) { + ASSERT(0, "cannot create mutex"); + } - if (tota_sdp_gen_record == NULL) - tota_sdp_gen_record = btif_sdp_create_record(); + if (tota_sdp_gen_record == NULL) + tota_sdp_gen_record = btif_sdp_create_record(); - param.attrs = &TotaSppGenSdpAttributes1[0], - param.attr_count = ARRAY_SIZE(TotaSppGenSdpAttributes1); - param.COD = BTIF_COD_MAJOR_PERIPHERAL; - btif_sdp_record_setup(tota_sdp_gen_record, ¶m); + param.attrs = &TotaSppGenSdpAttributes1[0], + param.attr_count = ARRAY_SIZE(TotaSppGenSdpAttributes1); + param.COD = BTIF_COD_MAJOR_PERIPHERAL; + btif_sdp_record_setup(tota_sdp_gen_record, ¶m); - if(totaSppGenService == NULL) - totaSppGenService = btif_create_spp_service(); + if (totaSppGenService == NULL) + totaSppGenService = btif_create_spp_service(); - totaSppGenService->rf_service.serviceId = RFCOMM_CHANNEL_TOTA_GENERAL; - totaSppGenService->numPorts = 0; - btif_spp_service_setup(tota_spp_gen_dev, totaSppGenService, tota_sdp_gen_record); + totaSppGenService->rf_service.serviceId = RFCOMM_CHANNEL_TOTA_GENERAL; + totaSppGenService->numPorts = 0; + btif_spp_service_setup(tota_spp_gen_dev, totaSppGenService, + tota_sdp_gen_record); - tota_spp_gen_dev->portType = BTIF_SPP_SERVER_PORT; - tota_spp_gen_dev->app_id = BTIF_APP_SPP_SERVER_TOTA_GENERAL_ID; - tota_spp_gen_dev->spp_handle_data_event_func = tota_general_spp_handle_data_event_func; + tota_spp_gen_dev->portType = BTIF_SPP_SERVER_PORT; + tota_spp_gen_dev->app_id = BTIF_APP_SPP_SERVER_TOTA_GENERAL_ID; + tota_spp_gen_dev->spp_handle_data_event_func = + tota_general_spp_handle_data_event_func; - btif_spp_init_device(tota_spp_gen_dev, 5, mid); - - btif_spp_open(tota_spp_gen_dev, NULL,spp_tota_gen_callback); + btif_spp_init_device(tota_spp_gen_dev, 5, mid); + btif_spp_open(tota_spp_gen_dev, NULL, spp_tota_gen_callback); } diff --git a/services/tota/app_tota.cpp b/services/tota/app_tota.cpp index 6d27e0f..f5fe4c7 100644 --- a/services/tota/app_tota.cpp +++ b/services/tota/app_tota.cpp @@ -13,147 +13,120 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "hal_trace.h" -#include "hal_timer.h" -#include "app_audio.h" -#include "app_utils.h" -#include "hal_aud.h" -#include "hal_norflash.h" -#include "pmu.h" -#include "string.h" -#include "stdio.h" -#include "stdarg.h" -#include "cmsis_os.h" #include "app_tota.h" +#include "app_audio.h" +#include "app_ble_rx_handler.h" +#include "app_bt.h" +#include "app_hfp.h" +#include "app_spp_tota.h" +#include "app_thread.h" #include "app_tota_cmd_code.h" #include "app_tota_cmd_handler.h" #include "app_tota_data_handler.h" -#include "app_spp_tota.h" -#include "cqueue.h" -#include "app_ble_rx_handler.h" -#include "rwapp_config.h" -#include "btapp.h" -#include "app_bt.h" +#include "app_utils.h" #include "apps.h" -#include "app_thread.h" -#include "cqueue.h" -#include "hal_location.h" -#include "app_hfp.h" #include "bt_drv_reg_op.h" -#if defined(IBRT) +#include "btapp.h" +#include "cmsis_os.h" +#include "cqueue.h" +#include "hal_aud.h" +#include "hal_location.h" +#include "hal_norflash.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "pmu.h" +#include "rwapp_config.h" +#include "stdarg.h" +#include "stdio.h" +#include "string.h" +#if defined(IBRT) #include "app_tws_ibrt.h" #endif -#include "cmsis.h" +#include "aes.h" #include "app_battery.h" -#include "crc32.h" -#include "factory_section.h" #include "app_ibrt_rssi.h" #include "app_spp_tota_general_service.h" -#include "tota_stream_data_transfer.h" -#include "app_tota_flash_program.h" -#include "app_tota_audio_dump.h" -#include "app_tota_mic.h" #include "app_tota_anc.h" -#include "app_tota_general.h" -#include "app_tota_custom.h" +#include "app_tota_audio_dump.h" #include "app_tota_conn.h" -#include "aes.h" +#include "app_tota_custom.h" +#include "app_tota_flash_program.h" +#include "app_tota_general.h" +#include "app_tota_mic.h" +#include "cmsis.h" +#include "crc32.h" +#include "factory_section.h" +#include "tota_stream_data_transfer.h" - - -typedef struct -{ - uint8_t connectedType; - APP_TOTA_TRANSMISSION_PATH_E dataPath; +typedef struct { + uint8_t connectedType; + APP_TOTA_TRANSMISSION_PATH_E dataPath; } APP_TOTA_ENV_T; -static APP_TOTA_ENV_T app_tota_env= -{ +static APP_TOTA_ENV_T app_tota_env = { 0, }; -bool app_is_in_tota_mode(void) -{ - return app_tota_env.connectedType; -} +bool app_is_in_tota_mode(void) { return app_tota_env.connectedType; } +void app_tota_init(void) { + TOTA_LOG_DBG(0, "Init application test over the air."); + app_spp_tota_init(); + app_spp_tota_gen_init(); + app_tota_cmd_handler_init(); -void app_tota_init(void) -{ - TOTA_LOG_DBG(0,"Init application test over the air."); - app_spp_tota_init(); - app_spp_tota_gen_init(); - app_tota_cmd_handler_init(); + app_tota_stream_data_transfer_init(); + /* register callback modules */ + app_tota_mic_init(); + app_tota_anc_init(); + app_tota_audio_dump_init(); + app_tota_general_init(); + app_tota_custom_init(); + app_tota_flash_init(); - app_tota_stream_data_transfer_init(); - /* register callback modules */ - app_tota_mic_init(); - app_tota_anc_init(); - app_tota_audio_dump_init(); - app_tota_general_init(); - app_tota_custom_init(); - app_tota_flash_init(); + /* set module to access spp callback */ + // tota_callback_module_set(APP_TOTA_AUDIO_DUMP); + tota_callback_module_set(APP_TOTA_ANC); - /* set module to access spp callback */ - //tota_callback_module_set(APP_TOTA_AUDIO_DUMP); - tota_callback_module_set(APP_TOTA_ANC); - #if (BLE_APP_TOTA) - app_ble_rx_handler_init(); + app_ble_rx_handler_init(); #endif } -void app_tota_connected(uint8_t connType) -{ - TOTA_LOG_DBG(0,"Tota is connected."); - app_tota_env.connectedType |= connType; +void app_tota_connected(uint8_t connType) { + TOTA_LOG_DBG(0, "Tota is connected."); + app_tota_env.connectedType |= connType; } -void app_tota_disconnected(uint8_t disconnType) -{ - TOTA_LOG_DBG(0,"Tota is disconnected."); - app_tota_env.connectedType &= disconnType; +void app_tota_disconnected(uint8_t disconnType) { + TOTA_LOG_DBG(0, "Tota is disconnected."); + app_tota_env.connectedType &= disconnType; } -void app_tota_general_connected(uint8_t connType) -{ - TOTA_LOG_DBG(0,"Tota gen is connected."); - app_tota_env.connectedType |= connType; +void app_tota_general_connected(uint8_t connType) { + TOTA_LOG_DBG(0, "Tota gen is connected."); + app_tota_env.connectedType |= connType; } -void app_tota_update_datapath(APP_TOTA_TRANSMISSION_PATH_E dataPath) -{ - app_tota_env.dataPath = dataPath; +void app_tota_update_datapath(APP_TOTA_TRANSMISSION_PATH_E dataPath) { + app_tota_env.dataPath = dataPath; } -APP_TOTA_TRANSMISSION_PATH_E app_tota_get_datapath(void) -{ - return app_tota_env.dataPath; +APP_TOTA_TRANSMISSION_PATH_E app_tota_get_datapath(void) { + return app_tota_env.dataPath; } - - - /*---------------------------------------------------------------------------------------------------------------------------*/ static bool _is_tota_connect = false; /**/ -void tota_connected_handle() -{ - _is_tota_connect = true; -} +void tota_connected_handle() { _is_tota_connect = true; } /**/ -void tota_disconnected_handle() -{ - _is_tota_connect = false; -} +void tota_disconnected_handle() { _is_tota_connect = false; } -bool is_tota_connected() -{ - return _is_tota_connect; -} +bool is_tota_connected() { return _is_tota_connect; } /* ** @func: encrypt && decrypt @@ -161,89 +134,91 @@ bool is_tota_connected() static uint8_t encrypt_data[MAX_SPP_PACKET_SIZE]; static uint8_t decrypt_data[MAX_SPP_PACKET_SIZE]; -static __unused uint8_t key[ENCRYPT_KEY_SIZE] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}; -static __unused uint8_t iv[ENCRYPT_KEY_SIZE] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}; +static __unused uint8_t key[ENCRYPT_KEY_SIZE] = { + 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, + 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}; +static __unused uint8_t iv[ENCRYPT_KEY_SIZE] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}; -void tota_set_encrypt_key_from_hash_key(uint8_t * hash_key) -{ - for (uint8_t i = 0; i < ENCRYPT_KEY_SIZE; i ++) - { - key[i] = hash_key[2*i]; - } - TOTA_LOG_DBG(0,"aes key:"); - DUMP8("%02x ", key, ENCRYPT_KEY_SIZE); +void tota_set_encrypt_key_from_hash_key(uint8_t *hash_key) { + for (uint8_t i = 0; i < ENCRYPT_KEY_SIZE; i++) { + key[i] = hash_key[2 * i]; + } + TOTA_LOG_DBG(0, "aes key:"); + DUMP8("%02x ", key, ENCRYPT_KEY_SIZE); } -void test_aes_encode_decode() -{ - uint8_t w[16] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; - uint8_t z[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t x[16] = {1, 1, 1, 1, 1, 1, 1, 1}; - - uint8_t dw[16]= {0x69, 0x0a, 0x6c, 0x5e, 0xd6, 0x66, 0x51, 0x25, 0x97, 0xfa, 0x1e, 0x6e, 0xcc, 0xfc, 0x1b, 0xdb}; - uint8_t dz[16]= {0x50, 0xfe, 0x67, 0xcc, 0x99, 0x6d, 0x32, 0xb6, 0xda, 0x09, 0x37, 0xe9, 0x9b, 0xaf, 0xec, 0x60}; - uint32_t length = 0; - tota_encrypt_packet(w, 16, &length); - osDelay(50); - tota_encrypt_packet(z, 16, &length); - osDelay(50); - tota_decrypt_packet(dw, 16, &length); - osDelay(50); - tota_decrypt_packet(dz, 16, &length); +void test_aes_encode_decode() { + uint8_t w[16] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; + uint8_t z[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + uint8_t x[16] = {1, 1, 1, 1, 1, 1, 1, 1}; - tota_encrypt_packet(x, 8, &length); - osDelay(50); + uint8_t dw[16] = {0x69, 0x0a, 0x6c, 0x5e, 0xd6, 0x66, 0x51, 0x25, + 0x97, 0xfa, 0x1e, 0x6e, 0xcc, 0xfc, 0x1b, 0xdb}; + uint8_t dz[16] = {0x50, 0xfe, 0x67, 0xcc, 0x99, 0x6d, 0x32, 0xb6, + 0xda, 0x09, 0x37, 0xe9, 0x9b, 0xaf, 0xec, 0x60}; + uint32_t length = 0; + tota_encrypt_packet(w, 16, &length); + osDelay(50); + tota_encrypt_packet(z, 16, &length); + osDelay(50); + tota_decrypt_packet(dw, 16, &length); + osDelay(50); + tota_decrypt_packet(dz, 16, &length); + + tota_encrypt_packet(x, 8, &length); + osDelay(50); } -uint8_t * tota_encrypt_packet(uint8_t * in, uint32_t inLen, uint32_t * poutLen) -{ - uint32_t morebytes = inLen % ENCRYPT_KEY_SIZE? ENCRYPT_KEY_SIZE: 0; - uint32_t outLen = (inLen/ENCRYPT_KEY_SIZE)*ENCRYPT_KEY_SIZE + morebytes; - TOTA_LOG_DBG(0,"raw data:"); - DUMP8("0x%02x, ", in, inLen); +uint8_t *tota_encrypt_packet(uint8_t *in, uint32_t inLen, uint32_t *poutLen) { + uint32_t morebytes = inLen % ENCRYPT_KEY_SIZE ? ENCRYPT_KEY_SIZE : 0; + uint32_t outLen = (inLen / ENCRYPT_KEY_SIZE) * ENCRYPT_KEY_SIZE + morebytes; + TOTA_LOG_DBG(0, "raw data:"); + DUMP8("0x%02x, ", in, inLen); #if defined(TOTA) - AES128_CBC_encrypt_buffer(encrypt_data, in, inLen, key, iv); + AES128_CBC_encrypt_buffer(encrypt_data, in, inLen, key, iv); #endif - *poutLen = outLen; - TOTA_LOG_DBG(2,"encrypt data: %u -> %u", inLen, outLen); - DUMP8("0x%02x, ", encrypt_data, *poutLen); - return encrypt_data; + *poutLen = outLen; + TOTA_LOG_DBG(2, "encrypt data: %u -> %u", inLen, outLen); + DUMP8("0x%02x, ", encrypt_data, *poutLen); + return encrypt_data; } /* ** inLen must 16 times */ -uint8_t * tota_decrypt_packet(uint8_t * in, uint32_t inLen, uint32_t * poutLen) -{ - uint32_t morebytes = inLen % ENCRYPT_KEY_SIZE? ENCRYPT_KEY_SIZE: 0; - uint32_t outLen = (inLen/ENCRYPT_KEY_SIZE)*ENCRYPT_KEY_SIZE + morebytes; - TOTA_LOG_DBG(0,"raw data:"); - DUMP8("0x%02x, ", in, inLen); +uint8_t *tota_decrypt_packet(uint8_t *in, uint32_t inLen, uint32_t *poutLen) { + uint32_t morebytes = inLen % ENCRYPT_KEY_SIZE ? ENCRYPT_KEY_SIZE : 0; + uint32_t outLen = (inLen / ENCRYPT_KEY_SIZE) * ENCRYPT_KEY_SIZE + morebytes; + TOTA_LOG_DBG(0, "raw data:"); + DUMP8("0x%02x, ", in, inLen); #if defined(TOTA) - AES128_CBC_decrypt_buffer(decrypt_data, in, inLen, key, iv); + AES128_CBC_decrypt_buffer(decrypt_data, in, inLen, key, iv); #endif - *poutLen = outLen; - TOTA_LOG_DBG(2,"decrypt data: %u -> %u", inLen, outLen); - DUMP8("0x%02x, ", decrypt_data, *poutLen); - return decrypt_data; + *poutLen = outLen; + TOTA_LOG_DBG(2, "decrypt data: %u -> %u", inLen, outLen); + DUMP8("0x%02x, ", decrypt_data, *poutLen); + return decrypt_data; } -//TODO: -static char strBuf[MAX_SPP_PACKET_SIZE-4]; -void tota_printf(const char * format, ...) -{ - va_list vlist; - va_start(vlist, format); - vsprintf(strBuf, format, vlist); - va_end(vlist); - app_tota_send_command(OP_TOTA_STRING, (uint8_t*)strBuf, strlen(strBuf), app_tota_get_datapath()); +// TODO: +static char strBuf[MAX_SPP_PACKET_SIZE - 4]; +void tota_printf(const char *format, ...) { + va_list vlist; + va_start(vlist, format); + vsprintf(strBuf, format, vlist); + va_end(vlist); + app_tota_send_command(OP_TOTA_STRING, (uint8_t *)strBuf, strlen(strBuf), + app_tota_get_datapath()); } /*---------------------------------------------------------------------------------------------------------------------------*/ -static void app_tota_demo_cmd_handler(APP_TOTA_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - TOTA_LOG_DBG(2,"Func code 0x%x, param len %d", funcCode, paramLen); - TOTA_LOG_DBG(0,"Param content:"); - DUMP8("%02x ", ptrParam, paramLen); +static void app_tota_demo_cmd_handler(APP_TOTA_CMD_CODE_E funcCode, + uint8_t *ptrParam, uint32_t paramLen) { + TOTA_LOG_DBG(2, "Func code 0x%x, param len %d", funcCode, paramLen); + TOTA_LOG_DBG(0, "Param content:"); + DUMP8("%02x ", ptrParam, paramLen); } -TOTA_COMMAND_TO_ADD(OP_TOTA_DEMO_CMD, app_tota_demo_cmd_handler, false, 0, NULL ); \ No newline at end of file +TOTA_COMMAND_TO_ADD(OP_TOTA_DEMO_CMD, app_tota_demo_cmd_handler, false, 0, + NULL); \ No newline at end of file diff --git a/services/tota/app_tota_anc.cpp b/services/tota/app_tota_anc.cpp index 9bb6337..6fc0718 100644 --- a/services/tota/app_tota_anc.cpp +++ b/services/tota/app_tota_anc.cpp @@ -14,36 +14,33 @@ * ****************************************************************************/ -#include "app_spp_tota.h" -#include -#include "cmsis_os.h" -#include "app_tota_cmd_code.h" -#include "anc_parse_data.h" #include "app_tota_anc.h" - +#include "anc_parse_data.h" +#include "app_spp_tota.h" +#include "app_tota_cmd_code.h" +#include "cmsis_os.h" +#include osTimerId app_check_send_synccmd_timer = NULL; static void app_synccmd_timehandler(void const *param); -osTimerDef (APP_SYNCCMD, app_synccmd_timehandler); +osTimerDef(APP_SYNCCMD, app_synccmd_timehandler); -static void app_synccmd_timehandler(void const *param) -{ - send_sync_cmd_to_tool(); +static void app_synccmd_timehandler(void const *param) { + send_sync_cmd_to_tool(); } -APP_TOTA_CMD_RET_STATUS_E app_anc_tota_cmd_received(uint8_t* ptrData, uint32_t dataLength) -{ - TOTA_LOG_DBG(2,"[%s] length:%d", __func__, dataLength); - TOTA_LOG_DBG(1,"[%s] data:", __func__); - TOTA_LOG_DUMP("0x%02x ", ptrData, dataLength); +APP_TOTA_CMD_RET_STATUS_E app_anc_tota_cmd_received(uint8_t *ptrData, + uint32_t dataLength) { + TOTA_LOG_DBG(2, "[%s] length:%d", __func__, dataLength); + TOTA_LOG_DBG(1, "[%s] data:", __func__); + TOTA_LOG_DUMP("0x%02x ", ptrData, dataLength); - anc_handle_received_data(ptrData, dataLength); + anc_handle_received_data(ptrData, dataLength); - if(get_send_sync_flag() == 1) - { - osTimerStop(app_check_send_synccmd_timer); - } - return TOTA_NO_ERROR; + if (get_send_sync_flag() == 1) { + osTimerStop(app_check_send_synccmd_timer); + } + return TOTA_NO_ERROR; } static bool is_connected = false; @@ -53,52 +50,45 @@ static bool is_connected = false; static void _tota_spp_connected(void); static void _tota_spp_disconnected(void); static void _tota_spp_tx_done(void); -static void _tota_spp_data_receive_handle(uint8_t * buf, uint32_t len); +static void _tota_spp_data_receive_handle(uint8_t *buf, uint32_t len); -static tota_callback_func_t s_func = { - _tota_spp_connected, - _tota_spp_disconnected, - _tota_spp_tx_done, - _tota_spp_data_receive_handle -}; +static tota_callback_func_t s_func = {_tota_spp_connected, + _tota_spp_disconnected, _tota_spp_tx_done, + _tota_spp_data_receive_handle}; static APP_TOTA_MODULE_E s_module = APP_TOTA_ANC; -void app_tota_anc_init() -{ - tota_callback_module_register(s_module, s_func); - reset_programmer_state(&g_buf, &g_len); - - if (app_check_send_synccmd_timer == NULL) - app_check_send_synccmd_timer = osTimerCreate (osTimer(APP_SYNCCMD), osTimerPeriodic, NULL); +void app_tota_anc_init() { + tota_callback_module_register(s_module, s_func); + reset_programmer_state(&g_buf, &g_len); + + if (app_check_send_synccmd_timer == NULL) + app_check_send_synccmd_timer = + osTimerCreate(osTimer(APP_SYNCCMD), osTimerPeriodic, NULL); } -static void _tota_spp_connected(void) -{ - anc_data_buff_init(); - //add a send sync timer - osTimerStop(app_check_send_synccmd_timer); - osTimerStart(app_check_send_synccmd_timer, 2000); - is_connected = true; +static void _tota_spp_connected(void) { + anc_data_buff_init(); + // add a send sync timer + osTimerStop(app_check_send_synccmd_timer); + osTimerStart(app_check_send_synccmd_timer, 2000); + is_connected = true; } -static void _tota_spp_disconnected(void) -{ - anc_data_buff_deinit(); - osTimerStop(app_check_send_synccmd_timer); - is_connected = false; +static void _tota_spp_disconnected(void) { + anc_data_buff_deinit(); + osTimerStop(app_check_send_synccmd_timer); + is_connected = false; } -static void _tota_spp_tx_done(void) -{ - if ( is_connected ) - // TODO: - ;//bulk_read_done(); +static void _tota_spp_tx_done(void) { + if (is_connected) + // TODO: + ; // bulk_read_done(); } -static void _tota_spp_data_receive_handle(uint8_t * buf, uint32_t len) -{ - app_anc_tota_cmd_received(buf, len); +static void _tota_spp_data_receive_handle(uint8_t *buf, uint32_t len) { + app_anc_tota_cmd_received(buf, len); } /*-----------------------------------------------------------------------------*/ diff --git a/services/tota/app_tota_audio_dump.cpp b/services/tota/app_tota_audio_dump.cpp index 4d37d72..cb73bbc 100644 --- a/services/tota/app_tota_audio_dump.cpp +++ b/services/tota/app_tota_audio_dump.cpp @@ -13,23 +13,24 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "app_tota.h" -#include "app_spp_tota.h" -#include "app_tota_cmd_code.h" #include "app_tota_audio_dump.h" +#include "app_spp_tota.h" +#include "app_tota.h" +#include "app_tota_cmd_code.h" #include "app_tota_cmd_handler.h" -#include "tota_stream_data_transfer.h" #include "cmsis_os.h" +#include "tota_stream_data_transfer.h" // #define _TOTA_AUDIO_DUMP_DEBUG static void _tota_audio_dump_connected(void); static void _tota_audio_dump_disconnected(void); static void _tota_audio_dump_tx_done(void); -static void _tota_audio_dump_receive_handle(uint8_t * buf, uint32_t len); +static void _tota_audio_dump_receive_handle(uint8_t *buf, uint32_t len); /**/ -static void _audio_dump_control(APP_TOTA_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen); +static void _audio_dump_control(APP_TOTA_CMD_CODE_E funcCode, uint8_t *ptrParam, + uint32_t paramLen); #ifdef _TOTA_AUDIO_DUMP_DEBUG /* only for test */ @@ -38,144 +39,129 @@ static void test_init(); /**/ static tota_callback_func_t s_func = { - _tota_audio_dump_connected, - _tota_audio_dump_disconnected, - _tota_audio_dump_tx_done, - _tota_audio_dump_receive_handle -}; + _tota_audio_dump_connected, _tota_audio_dump_disconnected, + _tota_audio_dump_tx_done, _tota_audio_dump_receive_handle}; static APP_TOTA_MODULE_E s_module = APP_TOTA_AUDIO_DUMP; +void app_tota_audio_dump_init() { + TOTA_LOG_DBG(1, "[%s] ...", __func__); -void app_tota_audio_dump_init() -{ - TOTA_LOG_DBG(1, "[%s] ...", __func__); - - tota_callback_module_register(s_module, s_func); + tota_callback_module_register(s_module, s_func); } -static void _tota_audio_dump_connected(void) -{ - TOTA_LOG_DBG(1, "[%s] ...", __func__); +static void _tota_audio_dump_connected(void) { + TOTA_LOG_DBG(1, "[%s] ...", __func__); #ifdef _TOTA_AUDIO_DUMP_DEBUG - test_init(); + test_init(); #endif } -static void _tota_audio_dump_disconnected(void) -{ - TOTA_LOG_DBG(1, "[%s] ...", __func__); +static void _tota_audio_dump_disconnected(void) { + TOTA_LOG_DBG(1, "[%s] ...", __func__); } -static void _tota_audio_dump_tx_done(void) -{ - ; +static void _tota_audio_dump_tx_done(void) { ; } + +static void _tota_audio_dump_receive_handle(uint8_t *buf, uint32_t len) { ; } + +/*-----------------------------------------------------------------------------*/ +void app_tota_audio_dump_start() { + TOTA_LOG_DBG(1, "[%s] ...", __func__); + + app_tota_stream_data_start(s_module); + app_tota_audio_dump_flush(); } -static void _tota_audio_dump_receive_handle(uint8_t * buf, uint32_t len) -{ - ; +void app_tota_audio_dump_stop() { + TOTA_LOG_DBG(1, "[%s] ...", __func__); + + app_tota_stream_data_end(); +} + +void app_tota_audio_dump_flush() { + TOTA_LOG_DBG(1, "[%s] ...", __func__); + + app_tota_stream_data_flush(); +} + +bool app_tota_audio_dump_send(uint8_t *pdata, uint32_t dataLen) { + return app_tota_send_stream_data(pdata, dataLen); } /*-----------------------------------------------------------------------------*/ -void app_tota_audio_dump_start() -{ - TOTA_LOG_DBG(1, "[%s] ...", __func__); +static void _audio_dump_control(APP_TOTA_CMD_CODE_E funcCode, uint8_t *ptrParam, + uint32_t paramLen) { + switch (funcCode) { + case OP_TOTA_AUDIO_DUMP_START: + TOTA_LOG_DBG(0, "tota_audio_dump start"); + app_tota_audio_dump_start(); + break; - app_tota_stream_data_start(s_module); - app_tota_audio_dump_flush(); -} + case OP_TOTA_AUDIO_DUMP_STOP: + TOTA_LOG_DBG(0, "tota_audio_dump stop"); + app_tota_audio_dump_stop(); + break; -void app_tota_audio_dump_stop() -{ - TOTA_LOG_DBG(1, "[%s] ...", __func__); + case OP_TOTA_AUDIO_DUMP_CONTROL: + TOTA_LOG_DBG(0, "tota_audio_dump contorl"); + // TODO: Can get or set info + app_tota_send_response_to_command(funcCode, TOTA_NO_ERROR, + (uint8_t *)".pcm", sizeof(".pcm"), + app_tota_get_datapath()); + break; - app_tota_stream_data_end(); -} - -void app_tota_audio_dump_flush() -{ - TOTA_LOG_DBG(1, "[%s] ...", __func__); - - app_tota_stream_data_flush(); -} - -bool app_tota_audio_dump_send(uint8_t * pdata, uint32_t dataLen) -{ - return app_tota_send_stream_data(pdata, dataLen); -} - -/*-----------------------------------------------------------------------------*/ -static void _audio_dump_control(APP_TOTA_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - switch (funcCode) - { - case OP_TOTA_AUDIO_DUMP_START: - TOTA_LOG_DBG(0, "tota_audio_dump start"); - app_tota_audio_dump_start(); - break; - - case OP_TOTA_AUDIO_DUMP_STOP: - TOTA_LOG_DBG(0, "tota_audio_dump stop"); - app_tota_audio_dump_stop(); - break; - - case OP_TOTA_AUDIO_DUMP_CONTROL: - TOTA_LOG_DBG(0, "tota_audio_dump contorl"); - // TODO: Can get or set info - app_tota_send_response_to_command(funcCode, TOTA_NO_ERROR, (uint8_t *)".pcm", sizeof(".pcm"), app_tota_get_datapath()); - break; - - default: - break; - } + default: + break; + } } #ifdef _TOTA_AUDIO_DUMP_DEBUG /*-----------------------------------------------------------------------------*/ /*----------------------------------TEST---------------------------------------*/ /*-----------------------------------------------------------------------------*/ -#define TOTA_TEST_STACK_SIZE (1024 * 2) +#define TOTA_TEST_STACK_SIZE (1024 * 2) static void tota_audio_dump_test_thread(void const *argument); osThreadId tota_audio_dump_test_thread_tid; -osThreadDef(tota_audio_dump_test_thread, osPriorityNormal, 1, TOTA_TEST_STACK_SIZE, "TOTA_TEST_THREAD");//osPriorityHigh +osThreadDef(tota_audio_dump_test_thread, osPriorityNormal, 1, + TOTA_TEST_STACK_SIZE, "TOTA_TEST_THREAD"); // osPriorityHigh static uint16_t audio_cnt = 0; uint16_t audioBuf[512]; -static void tota_audio_dump_test_thread(void const *argument) -{ - app_tota_audio_dump_flush(); - while (true) - { - osDelay(1000); - for (uint16_t i=0; icmdRspHandler(TOTA_WAITING_RSP_TIMEOUT, NULL, 0); + // it means time-out happens before the response is received from the peer + // device, trigger the response handler + TOTA_COMMAND_PTR_FROM_ENTRY_INDEX(entryIndex) + ->cmdRspHandler(TOTA_WAITING_RSP_TIMEOUT, NULL, 0); } -APP_TOTA_CMD_INSTANCE_T* app_tota_cmd_handler_get_entry_pointer_from_cmd_code(APP_TOTA_CMD_CODE_E cmdCode) -{ - for (uint32_t index = 0; - index < ((uint32_t)__tota_handler_table_end-(uint32_t)__tota_handler_table_start)/sizeof(APP_TOTA_CMD_INSTANCE_T);index++) - { - if (TOTA_COMMAND_PTR_FROM_ENTRY_INDEX(index)->cmdCode == cmdCode) - { - return TOTA_COMMAND_PTR_FROM_ENTRY_INDEX(index); - } - } +APP_TOTA_CMD_INSTANCE_T *app_tota_cmd_handler_get_entry_pointer_from_cmd_code( + APP_TOTA_CMD_CODE_E cmdCode) { + for (uint32_t index = 0; index < ((uint32_t)__tota_handler_table_end - + (uint32_t)__tota_handler_table_start) / + sizeof(APP_TOTA_CMD_INSTANCE_T); + index++) { + if (TOTA_COMMAND_PTR_FROM_ENTRY_INDEX(index)->cmdCode == cmdCode) { + return TOTA_COMMAND_PTR_FROM_ENTRY_INDEX(index); + } + } - return NULL; + return NULL; } -uint16_t app_tota_cmd_handler_get_entry_index_from_cmd_code(APP_TOTA_CMD_CODE_E cmdCode) -{ +uint16_t app_tota_cmd_handler_get_entry_index_from_cmd_code( + APP_TOTA_CMD_CODE_E cmdCode) { - for (uint32_t index = 0; - index < ((uint32_t)__tota_handler_table_end-(uint32_t)__tota_handler_table_start)/sizeof(APP_TOTA_CMD_INSTANCE_T);index++) - { - if (TOTA_COMMAND_PTR_FROM_ENTRY_INDEX(index)->cmdCode == cmdCode) - { - return index; - } - } + for (uint32_t index = 0; index < ((uint32_t)__tota_handler_table_end - + (uint32_t)__tota_handler_table_start) / + sizeof(APP_TOTA_CMD_INSTANCE_T); + index++) { + if (TOTA_COMMAND_PTR_FROM_ENTRY_INDEX(index)->cmdCode == cmdCode) { + return index; + } + } - return INVALID_TOTA_ENTRY_INDEX; + return INVALID_TOTA_ENTRY_INDEX; } -void app_tota_get_cmd_response_handler(APP_TOTA_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - // parameter length check - if (paramLen > sizeof(APP_TOTA_CMD_RSP_T)) - { - return; - } +void app_tota_get_cmd_response_handler(APP_TOTA_CMD_CODE_E funcCode, + uint8_t *ptrParam, uint32_t paramLen) { + // parameter length check + if (paramLen > sizeof(APP_TOTA_CMD_RSP_T)) { + return; + } - if (0 == tota_cmd_handler_env.timeoutSupervisorCount) - { - return; - } + if (0 == tota_cmd_handler_env.timeoutSupervisorCount) { + return; + } - APP_TOTA_CMD_RSP_T* rsp = (APP_TOTA_CMD_RSP_T *)ptrParam; + APP_TOTA_CMD_RSP_T *rsp = (APP_TOTA_CMD_RSP_T *)ptrParam; - - uint16_t entryIndex = app_tota_cmd_handler_get_entry_index_from_cmd_code((APP_TOTA_CMD_CODE_E)(rsp->cmdCodeToRsp)); - if (INVALID_TOTA_ENTRY_INDEX == entryIndex) - { - return; - } - - // remove the function code from the time-out supervision chain - app_tota_cmd_handler_remove_waiting_rsp_timeout_supervision(entryIndex); + uint16_t entryIndex = app_tota_cmd_handler_get_entry_index_from_cmd_code( + (APP_TOTA_CMD_CODE_E)(rsp->cmdCodeToRsp)); + if (INVALID_TOTA_ENTRY_INDEX == entryIndex) { + return; + } - APP_TOTA_CMD_INSTANCE_T* ptCmdInstance = TOTA_COMMAND_PTR_FROM_ENTRY_INDEX(entryIndex); + // remove the function code from the time-out supervision chain + app_tota_cmd_handler_remove_waiting_rsp_timeout_supervision(entryIndex); - // call the response handler - if (ptCmdInstance->cmdRspHandler) - { - ptCmdInstance->cmdRspHandler((APP_TOTA_CMD_RET_STATUS_E)(rsp->cmdRetStatus), rsp->rspData, rsp->rspDataLen); - } + APP_TOTA_CMD_INSTANCE_T *ptCmdInstance = + TOTA_COMMAND_PTR_FROM_ENTRY_INDEX(entryIndex); + + // call the response handler + if (ptCmdInstance->cmdRspHandler) { + ptCmdInstance->cmdRspHandler((APP_TOTA_CMD_RET_STATUS_E)(rsp->cmdRetStatus), + rsp->rspData, rsp->rspDataLen); + } } - - /** * @brief Refresh the waiting response supervisor list * */ -static void app_tota_cmd_refresh_supervisor_env(void) -{ - // do nothing if no supervisor was added - if (tota_cmd_handler_env.timeoutSupervisorCount > 0) - { - uint32_t currentTicks = GET_CURRENT_TICKS(); - uint32_t passedTicks; - if (currentTicks >= tota_cmd_handler_env.lastSysTicks) - { - passedTicks = (currentTicks - tota_cmd_handler_env.lastSysTicks); - } - else - { - passedTicks = (hal_sys_timer_get_max() - tota_cmd_handler_env.lastSysTicks + 1) + currentTicks; - } - - uint32_t deltaMs = TICKS_TO_MS(passedTicks); - - APP_TOTA_CMD_WAITING_RSP_SUPERVISOR_T* pRspSupervisor = &(tota_cmd_handler_env.waitingRspTimeoutInstance[0]); - for (uint32_t index = 0;index < tota_cmd_handler_env.timeoutSupervisorCount;index++) - { - if (pRspSupervisor[index].msTillTimeout > deltaMs) - { - pRspSupervisor[index].msTillTimeout -= deltaMs; - } - else - { - pRspSupervisor[index].msTillTimeout = 0; - } - } - } +static void app_tota_cmd_refresh_supervisor_env(void) { + // do nothing if no supervisor was added + if (tota_cmd_handler_env.timeoutSupervisorCount > 0) { + uint32_t currentTicks = GET_CURRENT_TICKS(); + uint32_t passedTicks; + if (currentTicks >= tota_cmd_handler_env.lastSysTicks) { + passedTicks = (currentTicks - tota_cmd_handler_env.lastSysTicks); + } else { + passedTicks = + (hal_sys_timer_get_max() - tota_cmd_handler_env.lastSysTicks + 1) + + currentTicks; + } - tota_cmd_handler_env.lastSysTicks = GET_CURRENT_TICKS(); + uint32_t deltaMs = TICKS_TO_MS(passedTicks); + + APP_TOTA_CMD_WAITING_RSP_SUPERVISOR_T *pRspSupervisor = + &(tota_cmd_handler_env.waitingRspTimeoutInstance[0]); + for (uint32_t index = 0; + index < tota_cmd_handler_env.timeoutSupervisorCount; index++) { + if (pRspSupervisor[index].msTillTimeout > deltaMs) { + pRspSupervisor[index].msTillTimeout -= deltaMs; + } else { + pRspSupervisor[index].msTillTimeout = 0; + } + } + } + + tota_cmd_handler_env.lastSysTicks = GET_CURRENT_TICKS(); } /** * @brief Remove the time-out supervision of waiting response * * @param entryIndex Entry index of the command table - * + * */ -static void app_tota_cmd_handler_remove_waiting_rsp_timeout_supervision(uint16_t entryIndex) -{ - ASSERT(tota_cmd_handler_env.timeoutSupervisorCount > 0, - "%s The BLE tota command time-out supervisor is already empty!!!", __FUNCTION__); +static void app_tota_cmd_handler_remove_waiting_rsp_timeout_supervision( + uint16_t entryIndex) { + ASSERT(tota_cmd_handler_env.timeoutSupervisorCount > 0, + "%s The BLE tota command time-out supervisor is already empty!!!", + __FUNCTION__); - osMutexWait(tota_cmd_handler_env.mutex, osWaitForever); + osMutexWait(tota_cmd_handler_env.mutex, osWaitForever); - uint32_t index; - for (index = 0;index < tota_cmd_handler_env.timeoutSupervisorCount;index++) - { - if (tota_cmd_handler_env.waitingRspTimeoutInstance[index].entryIndex == entryIndex) - { - memcpy(&(tota_cmd_handler_env.waitingRspTimeoutInstance[index]), - &(tota_cmd_handler_env.waitingRspTimeoutInstance[index + 1]), - (tota_cmd_handler_env.timeoutSupervisorCount - index - 1)*sizeof(APP_TOTA_CMD_WAITING_RSP_SUPERVISOR_T)); - break; - } - } + uint32_t index; + for (index = 0; index < tota_cmd_handler_env.timeoutSupervisorCount; + index++) { + if (tota_cmd_handler_env.waitingRspTimeoutInstance[index].entryIndex == + entryIndex) { + memcpy(&(tota_cmd_handler_env.waitingRspTimeoutInstance[index]), + &(tota_cmd_handler_env.waitingRspTimeoutInstance[index + 1]), + (tota_cmd_handler_env.timeoutSupervisorCount - index - 1) * + sizeof(APP_TOTA_CMD_WAITING_RSP_SUPERVISOR_T)); + break; + } + } - // cannot find it, directly return - if (index == tota_cmd_handler_env.timeoutSupervisorCount) - { - goto exit; - } - - tota_cmd_handler_env.timeoutSupervisorCount--; + // cannot find it, directly return + if (index == tota_cmd_handler_env.timeoutSupervisorCount) { + goto exit; + } - //TOTA_LOG_DBG(1,"decrease the supervisor timer to %d", tota_cmd_handler_env.timeoutSupervisorCount); + tota_cmd_handler_env.timeoutSupervisorCount--; - if (tota_cmd_handler_env.timeoutSupervisorCount > 0) - { - // refresh supervisor environment firstly - app_tota_cmd_refresh_supervisor_env(); - - // start timer, the first entry is the most close one - osTimerStart(tota_cmd_handler_env.supervisor_timer_id, - tota_cmd_handler_env.waitingRspTimeoutInstance[0].msTillTimeout); - } - else - { - // no supervisor, directly stop the timer - osTimerStop(tota_cmd_handler_env.supervisor_timer_id); - } + // TOTA_LOG_DBG(1,"decrease the supervisor timer to %d", + // tota_cmd_handler_env.timeoutSupervisorCount); + + if (tota_cmd_handler_env.timeoutSupervisorCount > 0) { + // refresh supervisor environment firstly + app_tota_cmd_refresh_supervisor_env(); + + // start timer, the first entry is the most close one + osTimerStart( + tota_cmd_handler_env.supervisor_timer_id, + tota_cmd_handler_env.waitingRspTimeoutInstance[0].msTillTimeout); + } else { + // no supervisor, directly stop the timer + osTimerStop(tota_cmd_handler_env.supervisor_timer_id); + } exit: - osMutexRelease(tota_cmd_handler_env.mutex); + osMutexRelease(tota_cmd_handler_env.mutex); } /** * @brief Add the time-out supervision of waiting response * * @param entryIndex Index of the command entry - * + * */ -static void app_tota_cmd_handler_add_waiting_rsp_timeout_supervision(uint16_t entryIndex) -{ - ASSERT(tota_cmd_handler_env.timeoutSupervisorCount < APP_TOTA_CMD_HANDLER_WAITING_RSP_TIMEOUT_SUPERVISOR_COUNT, - "%s The tota command response time-out supervisor is full!!!", __FUNCTION__); +static void +app_tota_cmd_handler_add_waiting_rsp_timeout_supervision(uint16_t entryIndex) { + ASSERT(tota_cmd_handler_env.timeoutSupervisorCount < + APP_TOTA_CMD_HANDLER_WAITING_RSP_TIMEOUT_SUPERVISOR_COUNT, + "%s The tota command response time-out supervisor is full!!!", + __FUNCTION__); - osMutexWait(tota_cmd_handler_env.mutex, osWaitForever); + osMutexWait(tota_cmd_handler_env.mutex, osWaitForever); - // refresh supervisor environment firstly - app_tota_cmd_refresh_supervisor_env(); + // refresh supervisor environment firstly + app_tota_cmd_refresh_supervisor_env(); - APP_TOTA_CMD_INSTANCE_T* pInstance = TOTA_COMMAND_PTR_FROM_ENTRY_INDEX(entryIndex); + APP_TOTA_CMD_INSTANCE_T *pInstance = + TOTA_COMMAND_PTR_FROM_ENTRY_INDEX(entryIndex); - APP_TOTA_CMD_WAITING_RSP_SUPERVISOR_T waitingRspTimeoutInstance[APP_TOTA_CMD_HANDLER_WAITING_RSP_TIMEOUT_SUPERVISOR_COUNT]; + APP_TOTA_CMD_WAITING_RSP_SUPERVISOR_T waitingRspTimeoutInstance + [APP_TOTA_CMD_HANDLER_WAITING_RSP_TIMEOUT_SUPERVISOR_COUNT]; - uint32_t index = 0, insertedIndex = 0; - for (index = 0;index < tota_cmd_handler_env.timeoutSupervisorCount;index++) - { - uint32_t msTillTimeout = tota_cmd_handler_env.waitingRspTimeoutInstance[index].msTillTimeout; + uint32_t index = 0, insertedIndex = 0; + for (index = 0; index < tota_cmd_handler_env.timeoutSupervisorCount; + index++) { + uint32_t msTillTimeout = + tota_cmd_handler_env.waitingRspTimeoutInstance[index].msTillTimeout; - // in the order of low to high - if ((tota_cmd_handler_env.waitingRspTimeoutInstance[index].entryIndex != entryIndex) && - (pInstance->timeoutWaitingRspInMs >= msTillTimeout)) - { - waitingRspTimeoutInstance[insertedIndex++] = tota_cmd_handler_env.waitingRspTimeoutInstance[index]; - } - else if (pInstance->timeoutWaitingRspInMs < msTillTimeout) - { - waitingRspTimeoutInstance[insertedIndex].entryIndex = entryIndex; - waitingRspTimeoutInstance[insertedIndex].msTillTimeout = pInstance->timeoutWaitingRspInMs; + // in the order of low to high + if ((tota_cmd_handler_env.waitingRspTimeoutInstance[index].entryIndex != + entryIndex) && + (pInstance->timeoutWaitingRspInMs >= msTillTimeout)) { + waitingRspTimeoutInstance[insertedIndex++] = + tota_cmd_handler_env.waitingRspTimeoutInstance[index]; + } else if (pInstance->timeoutWaitingRspInMs < msTillTimeout) { + waitingRspTimeoutInstance[insertedIndex].entryIndex = entryIndex; + waitingRspTimeoutInstance[insertedIndex].msTillTimeout = + pInstance->timeoutWaitingRspInMs; - insertedIndex++; - } - } + insertedIndex++; + } + } - // biggest one? then put it at the end of the list - if (tota_cmd_handler_env.timeoutSupervisorCount == index) - { - waitingRspTimeoutInstance[insertedIndex].entryIndex = entryIndex; - waitingRspTimeoutInstance[insertedIndex].msTillTimeout = pInstance->timeoutWaitingRspInMs; - - insertedIndex++; - } + // biggest one? then put it at the end of the list + if (tota_cmd_handler_env.timeoutSupervisorCount == index) { + waitingRspTimeoutInstance[insertedIndex].entryIndex = entryIndex; + waitingRspTimeoutInstance[insertedIndex].msTillTimeout = + pInstance->timeoutWaitingRspInMs; - // copy to the global variable - memcpy((uint8_t *)&(tota_cmd_handler_env.waitingRspTimeoutInstance), (uint8_t *)&waitingRspTimeoutInstance, - insertedIndex*sizeof(APP_TOTA_CMD_WAITING_RSP_SUPERVISOR_T)); + insertedIndex++; + } - tota_cmd_handler_env.timeoutSupervisorCount = insertedIndex; + // copy to the global variable + memcpy((uint8_t *)&(tota_cmd_handler_env.waitingRspTimeoutInstance), + (uint8_t *)&waitingRspTimeoutInstance, + insertedIndex * sizeof(APP_TOTA_CMD_WAITING_RSP_SUPERVISOR_T)); - //TOTA_LOG_DBG(1,"increase the supervisor timer to %d", tota_cmd_handler_env.timeoutSupervisorCount); + tota_cmd_handler_env.timeoutSupervisorCount = insertedIndex; + // TOTA_LOG_DBG(1,"increase the supervisor timer to %d", + // tota_cmd_handler_env.timeoutSupervisorCount); - osMutexRelease(tota_cmd_handler_env.mutex); - - // start timer, the first entry is the most close one - osTimerStart(tota_cmd_handler_env.supervisor_timer_id, tota_cmd_handler_env.waitingRspTimeoutInstance[0].msTillTimeout); + osMutexRelease(tota_cmd_handler_env.mutex); + // start timer, the first entry is the most close one + osTimerStart(tota_cmd_handler_env.supervisor_timer_id, + tota_cmd_handler_env.waitingRspTimeoutInstance[0].msTillTimeout); } /** @@ -307,49 +306,55 @@ static void app_tota_cmd_handler_add_waiting_rsp_timeout_supervision(uint16_t en * * @param ptrData Pointer of the received data * @param dataLength Length of the received data - * + * * @return APP_TOTA_CMD_RET_STATUS_E */ -APP_TOTA_CMD_RET_STATUS_E app_tota_cmd_received(uint8_t* ptrData, uint32_t dataLength) -{ - TOTA_LOG_DBG(0,"TOTA Receive data:"); - TOTA_LOG_DUMP("0x%02x ", ptrData, dataLength); - APP_TOTA_CMD_PAYLOAD_T* pPayload = (APP_TOTA_CMD_PAYLOAD_T *)ptrData; - - // check command code - if (pPayload->cmdCode >= OP_TOTA_COMMAND_COUNT || pPayload->cmdCode < OP_TOTA_STRING) - { - TOTA_LOG_DBG(1,"[%s]error TOTA_INVALID_CMD",__func__); - return TOTA_INVALID_CMD; - } +APP_TOTA_CMD_RET_STATUS_E app_tota_cmd_received(uint8_t *ptrData, + uint32_t dataLength) { + TOTA_LOG_DBG(0, "TOTA Receive data:"); + TOTA_LOG_DUMP("0x%02x ", ptrData, dataLength); + APP_TOTA_CMD_PAYLOAD_T *pPayload = (APP_TOTA_CMD_PAYLOAD_T *)ptrData; - // check parameter length - if (pPayload->paramLen > sizeof(pPayload->param)) - { - TOTA_LOG_DBG(1,"[%s]error TOTA_PARAM_LEN_OUT_OF_RANGE",__func__); - return TOTA_PARAM_LEN_OUT_OF_RANGE; - } + // check command code + if (pPayload->cmdCode >= OP_TOTA_COMMAND_COUNT || + pPayload->cmdCode < OP_TOTA_STRING) { + TOTA_LOG_DBG(1, "[%s]error TOTA_INVALID_CMD", __func__); + return TOTA_INVALID_CMD; + } - APP_TOTA_CMD_INSTANCE_T* pInstance = - app_tota_cmd_handler_get_entry_pointer_from_cmd_code((APP_TOTA_CMD_CODE_E)(pPayload->cmdCode)); + // check parameter length + if (pPayload->paramLen > sizeof(pPayload->param)) { + TOTA_LOG_DBG(1, "[%s]error TOTA_PARAM_LEN_OUT_OF_RANGE", __func__); + return TOTA_PARAM_LEN_OUT_OF_RANGE; + } - // execute the command handler - pInstance->cmdHandler((APP_TOTA_CMD_CODE_E)(pPayload->cmdCode), pPayload->param, pPayload->paramLen); + APP_TOTA_CMD_INSTANCE_T *pInstance = + app_tota_cmd_handler_get_entry_pointer_from_cmd_code( + (APP_TOTA_CMD_CODE_E)(pPayload->cmdCode)); - return TOTA_NO_ERROR; + // execute the command handler + pInstance->cmdHandler((APP_TOTA_CMD_CODE_E)(pPayload->cmdCode), + pPayload->param, pPayload->paramLen); + + return TOTA_NO_ERROR; } #if defined(APP_ANC_TEST) - #endif -static void app_tota_cmd_send(APP_TOTA_TRANSMISSION_PATH_E path, APP_TOTA_CMD_PAYLOAD_T* ptPayLoad) -{ - TOTA_LOG_DBG(1,"Send tota cmd: size=%u", (uint32_t)(&(((APP_TOTA_CMD_PAYLOAD_T *)0)->param)) + ptPayLoad->paramLen); - TOTA_LOG_DUMP("%02x ", (uint8_t *)ptPayLoad, - (uint32_t)(&(((APP_TOTA_CMD_PAYLOAD_T *)0)->param)) + ptPayLoad->paramLen); +static void app_tota_cmd_send(APP_TOTA_TRANSMISSION_PATH_E path, + APP_TOTA_CMD_PAYLOAD_T *ptPayLoad) { + TOTA_LOG_DBG(1, "Send tota cmd: size=%u", + (uint32_t)(&(((APP_TOTA_CMD_PAYLOAD_T *)0)->param)) + + ptPayLoad->paramLen); + TOTA_LOG_DUMP("%02x ", (uint8_t *)ptPayLoad, + (uint32_t)(&(((APP_TOTA_CMD_PAYLOAD_T *)0)->param)) + + ptPayLoad->paramLen); - app_tota_send_data_via_spp((uint8_t *)ptPayLoad, (uint32_t)(&(((APP_TOTA_CMD_PAYLOAD_T *)0)->param)) + ptPayLoad->paramLen); + app_tota_send_data_via_spp( + (uint8_t *)ptPayLoad, + (uint32_t)(&(((APP_TOTA_CMD_PAYLOAD_T *)0)->param)) + + ptPayLoad->paramLen); #if 0 switch (path) @@ -374,54 +379,54 @@ static void app_tota_cmd_send(APP_TOTA_TRANSMISSION_PATH_E path, APP_TOTA_CMD_PA break; default: break; - } + } #endif } /** - * @brief Send response to the command request + * @brief Send response to the command request * * @param responsedCmdCode Command code of the responsed command request * @param returnStatus Handling result * @param rspData Pointer of the response data * @param rspDataLen Length of the response data * @param path Path of the data transmission - * + * * @return APP_TOTA_CMD_RET_STATUS_E */ -APP_TOTA_CMD_RET_STATUS_E app_tota_send_response_to_command - (APP_TOTA_CMD_CODE_E responsedCmdCode, APP_TOTA_CMD_RET_STATUS_E returnStatus, - uint8_t* rspData, uint32_t rspDataLen, APP_TOTA_TRANSMISSION_PATH_E path) -{ - TOTA_LOG_DBG(1,"[%s]",__func__); - // check responsedCmdCode's validity - if (responsedCmdCode >= OP_TOTA_COMMAND_COUNT || responsedCmdCode < OP_TOTA_RESPONSE_TO_CMD) - { - return TOTA_INVALID_CMD; - } +APP_TOTA_CMD_RET_STATUS_E +app_tota_send_response_to_command(APP_TOTA_CMD_CODE_E responsedCmdCode, + APP_TOTA_CMD_RET_STATUS_E returnStatus, + uint8_t *rspData, uint32_t rspDataLen, + APP_TOTA_TRANSMISSION_PATH_E path) { + TOTA_LOG_DBG(1, "[%s]", __func__); + // check responsedCmdCode's validity + if (responsedCmdCode >= OP_TOTA_COMMAND_COUNT || + responsedCmdCode < OP_TOTA_RESPONSE_TO_CMD) { + return TOTA_INVALID_CMD; + } - APP_TOTA_CMD_PAYLOAD_T payload; + APP_TOTA_CMD_PAYLOAD_T payload; - APP_TOTA_CMD_RSP_T* pResponse = (APP_TOTA_CMD_RSP_T *)&(payload.param); + APP_TOTA_CMD_RSP_T *pResponse = (APP_TOTA_CMD_RSP_T *)&(payload.param); - // check parameter length - if (rspDataLen > sizeof(pResponse->rspData)) - { - return TOTA_PARAM_LEN_OUT_OF_RANGE; - } + // check parameter length + if (rspDataLen > sizeof(pResponse->rspData)) { + return TOTA_PARAM_LEN_OUT_OF_RANGE; + } - pResponse->cmdCodeToRsp = responsedCmdCode; - pResponse->cmdRetStatus = returnStatus; - pResponse->rspDataLen = rspDataLen; - memcpy(pResponse->rspData, rspData, rspDataLen); + pResponse->cmdCodeToRsp = responsedCmdCode; + pResponse->cmdRetStatus = returnStatus; + pResponse->rspDataLen = rspDataLen; + memcpy(pResponse->rspData, rspData, rspDataLen); - payload.paramLen = 3*sizeof(uint16_t) + rspDataLen; + payload.paramLen = 3 * sizeof(uint16_t) + rspDataLen; - payload.cmdCode = OP_TOTA_RESPONSE_TO_CMD; + payload.cmdCode = OP_TOTA_RESPONSE_TO_CMD; - app_tota_cmd_send(path, &payload); + app_tota_cmd_send(path, &payload); - return TOTA_NO_ERROR; + return TOTA_NO_ERROR; } /** @@ -431,85 +436,78 @@ APP_TOTA_CMD_RET_STATUS_E app_tota_send_response_to_command * @param ptrParam Pointer of the output parameter * @param paramLen Length of the output parameter * @param path Path of the data transmission - * + * * @return APP_TOTA_CMD_RET_STATUS_E */ -APP_TOTA_CMD_RET_STATUS_E app_tota_send_command(APP_TOTA_CMD_CODE_E cmdCode, - uint8_t* ptrParam, uint32_t paramLen, APP_TOTA_TRANSMISSION_PATH_E path) -{ - // check cmdCode's validity - if (cmdCode >= OP_TOTA_COMMAND_COUNT) - { - TOTA_LOG_DBG(0, "OP_TOTA_COMMAND_COUNT"); - return TOTA_INVALID_CMD; - } +APP_TOTA_CMD_RET_STATUS_E +app_tota_send_command(APP_TOTA_CMD_CODE_E cmdCode, uint8_t *ptrParam, + uint32_t paramLen, APP_TOTA_TRANSMISSION_PATH_E path) { + // check cmdCode's validity + if (cmdCode >= OP_TOTA_COMMAND_COUNT) { + TOTA_LOG_DBG(0, "OP_TOTA_COMMAND_COUNT"); + return TOTA_INVALID_CMD; + } - APP_TOTA_CMD_PAYLOAD_T payload; + APP_TOTA_CMD_PAYLOAD_T payload; - // check parameter length - if (paramLen > sizeof(payload.param)) - { - TOTA_LOG_DBG(0, "TOTA_PARAM_LEN_OUT_OF_RANGE"); - return TOTA_PARAM_LEN_OUT_OF_RANGE; - } - - uint16_t entryIndex = app_tota_cmd_handler_get_entry_index_from_cmd_code(cmdCode); - if (INVALID_TOTA_ENTRY_INDEX == entryIndex) - { - TOTA_LOG_DBG(0, "TOTA_INVALID_CMD"); - return TOTA_INVALID_CMD; - } + // check parameter length + if (paramLen > sizeof(payload.param)) { + TOTA_LOG_DBG(0, "TOTA_PARAM_LEN_OUT_OF_RANGE"); + return TOTA_PARAM_LEN_OUT_OF_RANGE; + } - /* cmd filter */ + uint16_t entryIndex = + app_tota_cmd_handler_get_entry_index_from_cmd_code(cmdCode); + if (INVALID_TOTA_ENTRY_INDEX == entryIndex) { + TOTA_LOG_DBG(0, "TOTA_INVALID_CMD"); + return TOTA_INVALID_CMD; + } + + /* cmd filter */ #if TOTA_ENCODE - if ( !is_tota_connected() ) - { - if (cmdCode > OP_TOTA_CONN_CONFIRM) - { - TOTA_LOG_DBG(0, "COMMAMD NOT PERMIT. PERMISSION DENIED"); - return TOTA_INVALID_CMD; - } + if (!is_tota_connected()) { + if (cmdCode > OP_TOTA_CONN_CONFIRM) { + TOTA_LOG_DBG(0, "COMMAMD NOT PERMIT. PERMISSION DENIED"); + return TOTA_INVALID_CMD; + } - } - else - { - // may encrypt here - } + } else { + // may encrypt here + } #endif - - APP_TOTA_CMD_INSTANCE_T* pInstance = TOTA_COMMAND_PTR_FROM_ENTRY_INDEX(entryIndex); - // wrap the command payload - payload.cmdCode = cmdCode; - payload.paramLen = paramLen; - memcpy(payload.param, ptrParam, paramLen); + APP_TOTA_CMD_INSTANCE_T *pInstance = + TOTA_COMMAND_PTR_FROM_ENTRY_INDEX(entryIndex); - // send out the data - app_tota_cmd_send(path, &payload); + // wrap the command payload + payload.cmdCode = cmdCode; + payload.paramLen = paramLen; + memcpy(payload.param, ptrParam, paramLen); - // insert into time-out supervison - if (pInstance->isNeedResponse) - { - app_tota_cmd_handler_add_waiting_rsp_timeout_supervision(entryIndex); - } + // send out the data + app_tota_cmd_send(path, &payload); - return TOTA_NO_ERROR; + // insert into time-out supervison + if (pInstance->isNeedResponse) { + app_tota_cmd_handler_add_waiting_rsp_timeout_supervision(entryIndex); + } + + return TOTA_NO_ERROR; } /** * @brief Initialize the tota command handler framework * */ -void app_tota_cmd_handler_init(void) -{ - memset((uint8_t *)&tota_cmd_handler_env, 0, sizeof(tota_cmd_handler_env)); +void app_tota_cmd_handler_init(void) { + memset((uint8_t *)&tota_cmd_handler_env, 0, sizeof(tota_cmd_handler_env)); - tota_cmd_handler_env.supervisor_timer_id = - osTimerCreate(osTimer(APP_TOTA_CMD_HANDLER_RSP_SUPERVISION_TIMER), osTimerOnce, NULL); + tota_cmd_handler_env.supervisor_timer_id = osTimerCreate( + osTimer(APP_TOTA_CMD_HANDLER_RSP_SUPERVISION_TIMER), osTimerOnce, NULL); - tota_cmd_handler_env.mutex = osMutexCreate((osMutex(app_tota_cmd_handler_mutex))); + tota_cmd_handler_env.mutex = + osMutexCreate((osMutex(app_tota_cmd_handler_mutex))); } -TOTA_COMMAND_TO_ADD(OP_TOTA_RESPONSE_TO_CMD, app_tota_get_cmd_response_handler, false, 0, NULL ); - - +TOTA_COMMAND_TO_ADD(OP_TOTA_RESPONSE_TO_CMD, app_tota_get_cmd_response_handler, + false, 0, NULL); diff --git a/services/tota/app_tota_conn.cpp b/services/tota/app_tota_conn.cpp index eb7efa7..56118b5 100644 --- a/services/tota/app_tota_conn.cpp +++ b/services/tota/app_tota_conn.cpp @@ -15,39 +15,40 @@ *******************************************************************************/ #include "app_tota_conn.h" -#include "app_tota_cmd_code.h" #include "app_tota.h" +#include "app_tota_cmd_code.h" #include "app_tota_cmd_handler.h" +#include "sha256.h" #include "stdlib.h" #include "string.h" -#include "sha256.h" static bool _is_tota_initiate = false; typedef struct { - uint8_t length; - uint8_t random_key[MAX_RANDOM_KEY_SIZE]; -}TOTA_CONN_STRUCT_T; + uint8_t length; + uint8_t random_key[MAX_RANDOM_KEY_SIZE]; +} TOTA_CONN_STRUCT_T; typedef TOTA_CONN_STRUCT_T random_key_t; -typedef struct{ - /* local & peer random list */ - random_key_t random_a; - random_key_t random_b; - /* hash key generate from (random_a, random_b) */ - uint8_t hash_key[HASH_KEY_SIZE]; - /* encrypt key generate from hash key */ - uint8_t encrypt_key[ENCRYPT_KEY_SIZE]; -}TOTA_CONN_PARAMETER_T; +typedef struct { + /* local & peer random list */ + random_key_t random_a; + random_key_t random_b; + /* hash key generate from (random_a, random_b) */ + uint8_t hash_key[HASH_KEY_SIZE]; + /* encrypt key generate from hash key */ + uint8_t encrypt_key[ENCRYPT_KEY_SIZE]; +} TOTA_CONN_PARAMETER_T; static TOTA_CONN_PARAMETER_T keyManager; - -/* +/* ** @ */ -static void _tota_conn_and_update_key_handle(APP_TOTA_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen); +static void _tota_conn_and_update_key_handle(APP_TOTA_CMD_CODE_E funcCode, + uint8_t *ptrParam, + uint32_t paramLen); static uint8_t _generate_random_algorithm(uint8_t id, uint8_t a, uint8_t b); @@ -57,128 +58,120 @@ static void _generate_random_key(); /* calculate key */ static void _calculate_encrypt_key(); -static uint8_t _generate_random_algorithm(uint8_t id, uint8_t a, uint8_t b) -{ - uint8_t op = id % 6; - switch (op) - { - case 0: - return a + b; - case 1: - return a * b; - case 2: - return a & b; - case 3: - return a | b; - case 4: - return a ^ b; - case 5: - return a*a + b*b; - default: - return 0; - } +static uint8_t _generate_random_algorithm(uint8_t id, uint8_t a, uint8_t b) { + uint8_t op = id % 6; + switch (op) { + case 0: + return a + b; + case 1: + return a * b; + case 2: + return a & b; + case 3: + return a | b; + case 4: + return a ^ b; + case 5: + return a * a + b * b; + default: + return 0; + } } -static void _generate_random_key() -{ - uint8_t random_length = rand() % (MAX_RANDOM_KEY_SIZE + 1); - if ( random_length < 16 ) - { - random_length += 16; - } - keyManager.random_a.length = random_length; - uint32_t * prandom = (uint32_t *)keyManager.random_a.random_key; - for ( uint8_t i = 0; i < (random_length+3)/4; i ++ ) - { - prandom[i] = rand(); - } - TOTA_LOG_DBG(1, "generate random : 0x%x", random_length); - TOTA_LOG_DUMP("%02x ", keyManager.random_a.random_key, random_length); +static void _generate_random_key() { + uint8_t random_length = rand() % (MAX_RANDOM_KEY_SIZE + 1); + if (random_length < 16) { + random_length += 16; + } + keyManager.random_a.length = random_length; + uint32_t *prandom = (uint32_t *)keyManager.random_a.random_key; + for (uint8_t i = 0; i < (random_length + 3) / 4; i++) { + prandom[i] = rand(); + } + TOTA_LOG_DBG(1, "generate random : 0x%x", random_length); + TOTA_LOG_DUMP("%02x ", keyManager.random_a.random_key, random_length); } -static void _calculate_encrypt_key() -{ - uint8_t random_key[MAX_RANDOM_KEY_SIZE]; - random_key_t * prandom_a = &keyManager.random_a; - random_key_t * prandom_b = &keyManager.random_b; +static void _calculate_encrypt_key() { + uint8_t random_key[MAX_RANDOM_KEY_SIZE]; + random_key_t *prandom_a = &keyManager.random_a; + random_key_t *prandom_b = &keyManager.random_b; - /* align random list */ - if ( prandom_a->length > prandom_b->length ) - { - memset(prandom_b->random_key + prandom_b->length, 0, prandom_a->length - prandom_b->length); - prandom_b->length = prandom_a->length; - } - else if ( prandom_a->length < prandom_b->length ) - { - memset(prandom_a->random_key + prandom_a->length, 0, prandom_b->length - prandom_a->length); - prandom_a->length = prandom_b->length; - } - else - { - TOTA_LOG_DBG(0, "random list is the same size"); - } - TOTA_LOG_DBG(1, "random list a : 0x%x", prandom_a->length); - TOTA_LOG_DUMP("%02x ", keyManager.random_a.random_key, prandom_a->length); - TOTA_LOG_DBG(1, "random list b : 0x%x", prandom_b->length); - TOTA_LOG_DUMP("%02x ", keyManager.random_b.random_key, prandom_b->length); - - /* calculate random_key */ - for ( uint8_t i = 0; i < prandom_a->length; i ++ ) - { - random_key[i] = _generate_random_algorithm(i,prandom_a->random_key[i], prandom_b->random_key[i]); - } - - TOTA_LOG_DBG(0,"generate random key:"); - TOTA_LOG_DUMP("%02x ", random_key, prandom_a->length); + /* align random list */ + if (prandom_a->length > prandom_b->length) { + memset(prandom_b->random_key + prandom_b->length, 0, + prandom_a->length - prandom_b->length); + prandom_b->length = prandom_a->length; + } else if (prandom_a->length < prandom_b->length) { + memset(prandom_a->random_key + prandom_a->length, 0, + prandom_b->length - prandom_a->length); + prandom_a->length = prandom_b->length; + } else { + TOTA_LOG_DBG(0, "random list is the same size"); + } + TOTA_LOG_DBG(1, "random list a : 0x%x", prandom_a->length); + TOTA_LOG_DUMP("%02x ", keyManager.random_a.random_key, prandom_a->length); + TOTA_LOG_DBG(1, "random list b : 0x%x", prandom_b->length); + TOTA_LOG_DUMP("%02x ", keyManager.random_b.random_key, prandom_b->length); + + /* calculate random_key */ + for (uint8_t i = 0; i < prandom_a->length; i++) { + random_key[i] = _generate_random_algorithm(i, prandom_a->random_key[i], + prandom_b->random_key[i]); + } + + TOTA_LOG_DBG(0, "generate random key:"); + TOTA_LOG_DUMP("%02x ", random_key, prandom_a->length); #if defined(TOTA) - SHA256_hash(random_key, prandom_a->length, keyManager.hash_key); + SHA256_hash(random_key, prandom_a->length, keyManager.hash_key); #endif - TOTA_LOG_DBG(0,"generate hash key:"); - TOTA_LOG_DUMP("\\x%02x", keyManager.hash_key, HASH_KEY_SIZE); + TOTA_LOG_DBG(0, "generate hash key:"); + TOTA_LOG_DUMP("\\x%02x", keyManager.hash_key, HASH_KEY_SIZE); } -static void _tota_conn_and_update_key_handle(APP_TOTA_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - TOTA_CONN_STRUCT_T * pConn = (TOTA_CONN_STRUCT_T *)ptrParam; +static void _tota_conn_and_update_key_handle(APP_TOTA_CMD_CODE_E funcCode, + uint8_t *ptrParam, + uint32_t paramLen) { + TOTA_CONN_STRUCT_T *pConn = (TOTA_CONN_STRUCT_T *)ptrParam; - switch ( funcCode ) - { - case OP_TOTA_STRING: - TOTA_LOG_DBG(0, "not willing to receive this CMD"); - break; - case OP_TOTA_CONN_RESPONSE: - TOTA_LOG_DBG(0, "not willing to receive this CMD"); - break; - case OP_TOTA_CONN_INITIATE: - _is_tota_initiate = true; - keyManager.random_b = *pConn; - _generate_random_key(); - app_tota_send_command(OP_TOTA_CONN_RESPONSE, (uint8_t*)&keyManager.random_a, keyManager.random_a.length+1, app_tota_get_datapath()); - _calculate_encrypt_key(); - break; - case OP_TOTA_CONN_CONFIRM: - if ( _is_tota_initiate ) - { - _is_tota_initiate = false; - if ( memcmp(keyManager.hash_key, pConn->random_key, HASH_KEY_SIZE) == 0 ) - { - tota_set_encrypt_key_from_hash_key(keyManager.hash_key); - tota_connected_handle(); - TOTA_LOG_DBG(0, "tota connect success"); - tota_printf("connect success."); - } - else - { - TOTA_LOG_DBG(0, "tota connect failed"); - tota_printf("connect failed."); - } - } - default: - ; + switch (funcCode) { + case OP_TOTA_STRING: + TOTA_LOG_DBG(0, "not willing to receive this CMD"); + break; + case OP_TOTA_CONN_RESPONSE: + TOTA_LOG_DBG(0, "not willing to receive this CMD"); + break; + case OP_TOTA_CONN_INITIATE: + _is_tota_initiate = true; + keyManager.random_b = *pConn; + _generate_random_key(); + app_tota_send_command( + OP_TOTA_CONN_RESPONSE, (uint8_t *)&keyManager.random_a, + keyManager.random_a.length + 1, app_tota_get_datapath()); + _calculate_encrypt_key(); + break; + case OP_TOTA_CONN_CONFIRM: + if (_is_tota_initiate) { + _is_tota_initiate = false; + if (memcmp(keyManager.hash_key, pConn->random_key, HASH_KEY_SIZE) == 0) { + tota_set_encrypt_key_from_hash_key(keyManager.hash_key); + tota_connected_handle(); + TOTA_LOG_DBG(0, "tota connect success"); + tota_printf("connect success."); + } else { + TOTA_LOG_DBG(0, "tota connect failed"); + tota_printf("connect failed."); + } } + default:; + } } -TOTA_COMMAND_TO_ADD(OP_TOTA_CONN_INITIATE, _tota_conn_and_update_key_handle, false, 0, NULL ); -TOTA_COMMAND_TO_ADD(OP_TOTA_CONN_RESPONSE, _tota_conn_and_update_key_handle, false, 0, NULL ); -TOTA_COMMAND_TO_ADD(OP_TOTA_CONN_CONFIRM , _tota_conn_and_update_key_handle, false, 0, NULL ); -TOTA_COMMAND_TO_ADD(OP_TOTA_STRING , _tota_conn_and_update_key_handle, false, 0, NULL ); \ No newline at end of file +TOTA_COMMAND_TO_ADD(OP_TOTA_CONN_INITIATE, _tota_conn_and_update_key_handle, + false, 0, NULL); +TOTA_COMMAND_TO_ADD(OP_TOTA_CONN_RESPONSE, _tota_conn_and_update_key_handle, + false, 0, NULL); +TOTA_COMMAND_TO_ADD(OP_TOTA_CONN_CONFIRM, _tota_conn_and_update_key_handle, + false, 0, NULL); +TOTA_COMMAND_TO_ADD(OP_TOTA_STRING, _tota_conn_and_update_key_handle, false, 0, + NULL); \ No newline at end of file diff --git a/services/tota/app_tota_custom.cpp b/services/tota/app_tota_custom.cpp index 2d02aa2..7550d36 100644 --- a/services/tota/app_tota_custom.cpp +++ b/services/tota/app_tota_custom.cpp @@ -14,96 +14,77 @@ * ****************************************************************************/ -#include "app_spp_tota.h" -#include "tota_stream_data_transfer.h" -#include "app_tota_cmd_code.h" -#include "app_bt_stream.h" #include "app_audio.h" -#include "nvrecord.h" -#include "nvrecord_env.h" +#include "app_bt_stream.h" #include "app_ibrt_nvrecord.h" +#include "app_spp_tota.h" #include "app_tota.h" +#include "app_tota_cmd_code.h" #include "app_tota_cmd_handler.h" #include "apps.h" #include "cmsis_os.h" +#include "nvrecord.h" +#include "nvrecord_env.h" +#include "tota_stream_data_transfer.h" /**/ -static void _custom_cmd_handle(APP_TOTA_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen); +static void _custom_cmd_handle(APP_TOTA_CMD_CODE_E funcCode, uint8_t *ptrParam, + uint32_t paramLen); /*-----------------------------------------------------------------------------*/ static void _tota_spp_connected(void); static void _tota_spp_disconnected(void); static void _tota_spp_tx_done(void); -static void _tota_spp_data_receive_handle(uint8_t * buf, uint32_t len); +static void _tota_spp_data_receive_handle(uint8_t *buf, uint32_t len); -static tota_callback_func_t s_func = { - _tota_spp_connected, - _tota_spp_disconnected, - _tota_spp_tx_done, - _tota_spp_data_receive_handle -}; +static tota_callback_func_t s_func = {_tota_spp_connected, + _tota_spp_disconnected, _tota_spp_tx_done, + _tota_spp_data_receive_handle}; static APP_TOTA_MODULE_E s_module = APP_TOTA_CUSTOM; -void app_tota_custom_init() -{ - tota_callback_module_register(s_module, s_func); -} +void app_tota_custom_init() { tota_callback_module_register(s_module, s_func); } -static void _tota_spp_connected(void) -{ - ; -} +static void _tota_spp_connected(void) { ; } -static void _tota_spp_disconnected(void) -{ - ; -} +static void _tota_spp_disconnected(void) { ; } -static void _tota_spp_tx_done(void) -{ - ; -} +static void _tota_spp_tx_done(void) { ; } -static void _tota_spp_data_receive_handle(uint8_t * buf, uint32_t len) -{ - ; -} +static void _tota_spp_data_receive_handle(uint8_t *buf, uint32_t len) { ; } /*-----------------------------------------------------------------------------*/ - -static void _custom_cmd_handle(APP_TOTA_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - TOTA_LOG_DBG(2,"Func code 0x%x, param len %d", funcCode, paramLen); - TOTA_LOG_DBG(0,"Param content:"); - DUMP8("%02x ", ptrParam, paramLen); - APP_TOTA_CMD_RET_STATUS_E rsp_status = TOTA_NO_ERROR; - app_tota_send_response_to_command(funcCode,rsp_status,NULL,0,app_tota_get_datapath()); - switch (funcCode) - { - case OP_TOTA_FACTORY_RESET: - TRACE(0,"##### custom: factory reset"); - app_reset(); - break; - case OP_TOTA_CLEAR_PAIRING_INFO: - TRACE(0,"##### custom: clear pairing info"); - app_ibrt_nvrecord_delete_all_mobile_record(); - break; - case OP_TOTA_SHUTDOWM: - TRACE(0,"##### custom: shutdown"); - app_shutdown(); - break; - case OP_TOTA_REBOOT: - TRACE(0,"##### custom: reboot"); - // TODO: - break; - default: - ; - } - +static void _custom_cmd_handle(APP_TOTA_CMD_CODE_E funcCode, uint8_t *ptrParam, + uint32_t paramLen) { + TOTA_LOG_DBG(2, "Func code 0x%x, param len %d", funcCode, paramLen); + TOTA_LOG_DBG(0, "Param content:"); + DUMP8("%02x ", ptrParam, paramLen); + APP_TOTA_CMD_RET_STATUS_E rsp_status = TOTA_NO_ERROR; + app_tota_send_response_to_command(funcCode, rsp_status, NULL, 0, + app_tota_get_datapath()); + switch (funcCode) { + case OP_TOTA_FACTORY_RESET: + TRACE(0, "##### custom: factory reset"); + app_reset(); + break; + case OP_TOTA_CLEAR_PAIRING_INFO: + TRACE(0, "##### custom: clear pairing info"); + app_ibrt_nvrecord_delete_all_mobile_record(); + break; + case OP_TOTA_SHUTDOWM: + TRACE(0, "##### custom: shutdown"); + app_shutdown(); + break; + case OP_TOTA_REBOOT: + TRACE(0, "##### custom: reboot"); + // TODO: + break; + default:; + } } -TOTA_COMMAND_TO_ADD(OP_TOTA_FACTORY_RESET, _custom_cmd_handle, false, 0, NULL ); -TOTA_COMMAND_TO_ADD(OP_TOTA_CLEAR_PAIRING_INFO, _custom_cmd_handle, false, 0, NULL ); -TOTA_COMMAND_TO_ADD(OP_TOTA_SHUTDOWM, _custom_cmd_handle, false, 0, NULL ); -TOTA_COMMAND_TO_ADD(OP_TOTA_REBOOT, _custom_cmd_handle, false, 0, NULL ); +TOTA_COMMAND_TO_ADD(OP_TOTA_FACTORY_RESET, _custom_cmd_handle, false, 0, NULL); +TOTA_COMMAND_TO_ADD(OP_TOTA_CLEAR_PAIRING_INFO, _custom_cmd_handle, false, 0, + NULL); +TOTA_COMMAND_TO_ADD(OP_TOTA_SHUTDOWM, _custom_cmd_handle, false, 0, NULL); +TOTA_COMMAND_TO_ADD(OP_TOTA_REBOOT, _custom_cmd_handle, false, 0, NULL); diff --git a/services/tota/app_tota_data_handler.cpp b/services/tota/app_tota_data_handler.cpp index fe87a56..de49436 100644 --- a/services/tota/app_tota_data_handler.cpp +++ b/services/tota/app_tota_data_handler.cpp @@ -12,21 +12,21 @@ * **************************************************************************************** */ -#include "string.h" -#include "cmsis_os.h" -#include "hal_trace.h" -#include "hal_timer.h" -#include "apps.h" -#include "stdbool.h" -#include "app_tota.h" +#include "app_tota_data_handler.h" +#include "app_tota.h" #include "app_tota_cmd_code.h" #include "app_tota_cmd_handler.h" -#include "app_tota_data_handler.h" +#include "apps.h" +#include "cmsis_os.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "stdbool.h" +#include "string.h" //#include "rwapp_config.h" -#include "crc32.h" #include "app_spp_tota.h" #include "app_spp_tota_general_service.h" #include "app_tota_conn.h" +#include "crc32.h" #include "tota_buffer_manager.h" #include "tota_stream_data_transfer.h" /** @@ -34,27 +34,26 @@ * */ -typedef struct -{ - uint8_t isDataXferInProgress; - uint8_t isCrcCheckEnabled; - uint32_t wholeDataXferLen; - uint32_t dataXferLenUntilLastSegVerification; - uint32_t currentWholeCrc32; - uint32_t wholeCrc32UntilLastSeg; - uint32_t crc32OfCurrentSeg; +typedef struct { + uint8_t isDataXferInProgress; + uint8_t isCrcCheckEnabled; + uint32_t wholeDataXferLen; + uint32_t dataXferLenUntilLastSegVerification; + uint32_t currentWholeCrc32; + uint32_t wholeCrc32UntilLastSeg; + uint32_t crc32OfCurrentSeg; } APP_TOTA_DATA_HANDLER_ENV_T; #define APP_TOTA_TX_BUF_SIZE 2046 static uint8_t app_tota_tmpDataXferBuf[APP_TOTA_TX_BUF_SIZE]; - /*static receive_data_callback recervice_data_cb = NULL; void app_tota_data_received_callback_handler_register(receive_data_callback cb ) { recervice_data_cb = cb; } -__attribute__((weak)) void app_tota_data_received_callback(uint8_t* ptrData, uint32_t dataLength) +__attribute__((weak)) void app_tota_data_received_callback(uint8_t* ptrData, +uint32_t dataLength) { if(recervice_data_cb != NULL){ recervice_data_cb(ptrData,dataLength); @@ -67,110 +66,91 @@ __attribute__((weak)) void app_tota_data_received_callback(uint8_t* ptrData, uin * * @param ptrData Pointer of the received data * @param dataLength Length of the received data - * + * * @return APP_TOTA_CMD_RET_STATUS_E */ -APP_TOTA_CMD_RET_STATUS_E app_tota_data_received(uint8_t* ptrData, uint32_t dataLength) -{ - TOTA_LOG_DBG(0, ">>> app_tota_data_received"); - if ((OP_TOTA_STREAM_DATA != (APP_TOTA_CMD_CODE_E)(((uint16_t *)ptrData)[0])) || - (dataLength < TOTA_CMD_CODE_SIZE)) - { - return TOTA_INVALID_DATA_PACKET; - } - APP_TOTA_TRANSMISSION_PATH_E dataPath = app_tota_get_datapath(); +APP_TOTA_CMD_RET_STATUS_E app_tota_data_received(uint8_t *ptrData, + uint32_t dataLength) { + TOTA_LOG_DBG(0, ">>> app_tota_data_received"); + if ((OP_TOTA_STREAM_DATA != + (APP_TOTA_CMD_CODE_E)(((uint16_t *)ptrData)[0])) || + (dataLength < TOTA_CMD_CODE_SIZE)) { + return TOTA_INVALID_DATA_PACKET; + } + APP_TOTA_TRANSMISSION_PATH_E dataPath = app_tota_get_datapath(); - - APP_TOTA_DATA_ACK_T tAck = {0}; - app_tota_send_command(OP_TOTA_SPP_DATA_ACK, (uint8_t *)&tAck, sizeof(tAck), dataPath); - return TOTA_NO_ERROR; + APP_TOTA_DATA_ACK_T tAck = {0}; + app_tota_send_command(OP_TOTA_SPP_DATA_ACK, (uint8_t *)&tAck, sizeof(tAck), + dataPath); + return TOTA_NO_ERROR; } -void app_tota_send_data(APP_TOTA_TRANSMISSION_PATH_E path, uint8_t* ptrData, uint32_t dataLength) -{ - if (path < APP_TOTA_TRANSMISSION_PATH_COUNT) - { - ((uint16_t *)app_tota_tmpDataXferBuf)[0] = OP_TOTA_STREAM_DATA; - memcpy(app_tota_tmpDataXferBuf + TOTA_CMD_CODE_SIZE, ptrData, dataLength); +void app_tota_send_data(APP_TOTA_TRANSMISSION_PATH_E path, uint8_t *ptrData, + uint32_t dataLength) { + if (path < APP_TOTA_TRANSMISSION_PATH_COUNT) { + ((uint16_t *)app_tota_tmpDataXferBuf)[0] = OP_TOTA_STREAM_DATA; + memcpy(app_tota_tmpDataXferBuf + TOTA_CMD_CODE_SIZE, ptrData, dataLength); - switch (path) - { - case APP_TOTA_VIA_SPP: - app_tota_send_data_via_spp(app_tota_tmpDataXferBuf, dataLength + TOTA_CMD_CODE_SIZE); - break; - case APP_TOTA_GEN_VIA_SPP: - app_tota_gen_send_data_via_spp(app_tota_tmpDataXferBuf, dataLength + TOTA_CMD_CODE_SIZE); - break; - default: - break; - } + switch (path) { + case APP_TOTA_VIA_SPP: + app_tota_send_data_via_spp(app_tota_tmpDataXferBuf, + dataLength + TOTA_CMD_CODE_SIZE); + break; + case APP_TOTA_GEN_VIA_SPP: + app_tota_gen_send_data_via_spp(app_tota_tmpDataXferBuf, + dataLength + TOTA_CMD_CODE_SIZE); + break; + default: + break; } + } } #if defined(APP_ANC_TEST) -void app_anc_tota_send_data(APP_TOTA_TRANSMISSION_PATH_E path, uint8_t* ptrData, uint32_t dataLength) -{ - if (path < APP_TOTA_TRANSMISSION_PATH_COUNT) - { - switch (path) - { - case APP_TOTA_VIA_SPP: - app_tota_send_data_via_spp(ptrData, dataLength); - break; - default: - break; - } - } +void app_anc_tota_send_data(APP_TOTA_TRANSMISSION_PATH_E path, uint8_t *ptrData, + uint32_t dataLength) { + if (path < APP_TOTA_TRANSMISSION_PATH_COUNT) { + switch (path) { + case APP_TOTA_VIA_SPP: + app_tota_send_data_via_spp(ptrData, dataLength); + break; + default: + break; + } + } } #endif +void app_tota_handle_received_data(uint8_t *buffer, uint16_t maxBytes) { + TOTA_LOG_DBG(2, "[%s]data receive data length = %d", __func__, maxBytes); + uint8_t *_buf = buffer; + uint32_t _bufLen = maxBytes; -void app_tota_handle_received_data(uint8_t* buffer, uint16_t maxBytes) -{ - TOTA_LOG_DBG(2,"[%s]data receive data length = %d",__func__,maxBytes); - uint8_t * _buf = buffer; - uint32_t _bufLen = maxBytes; - - if (OP_TOTA_STREAM_DATA == *(uint16_t *)buffer) - { - TOTA_LOG_DBG(0,"APP TOTA DATA RECEIVED"); - app_tota_data_received(_buf, _bufLen); - } - else - { - if ( OP_TOTA_STRING == *(uint16_t *)buffer ) - { - TOTA_LOG_DBG(0,"APP TOTA STRING RECEIVED"); - } - else - { + if (OP_TOTA_STREAM_DATA == *(uint16_t *)buffer) { + TOTA_LOG_DBG(0, "APP TOTA DATA RECEIVED"); + app_tota_data_received(_buf, _bufLen); + } else { + if (OP_TOTA_STRING == *(uint16_t *)buffer) { + TOTA_LOG_DBG(0, "APP TOTA STRING RECEIVED"); + } else { #if defined(TOTA_ENCODE) && TOTA_ENCODE - if ( is_tota_connected() ) - { - TOTA_LOG_DBG(0,"APP TOTA ENCRYPT DATA RECEIVED"); - _buf = tota_decrypt_packet(buffer, maxBytes, &_bufLen); - } - else - { - if ( *(uint16_t *)buffer <= OP_TOTA_CONN_CONFIRM ) - { - TOTA_LOG_DBG(0,"APP TOTA UNCRYPT CONN COMMAND"); - } - else - { - // TODO - TOTA_LOG_DBG(0,"TOTA UNCONNECT: COMMAND NOT SUPPORT"); - return; - } - } - app_tota_cmd_received(_buf, _bufLen); -#else - TOTA_LOG_DBG(0,"APP TOTA CMD RECEIVED"); - app_tota_cmd_received(_buf, _bufLen); -#endif + if (is_tota_connected()) { + TOTA_LOG_DBG(0, "APP TOTA ENCRYPT DATA RECEIVED"); + _buf = tota_decrypt_packet(buffer, maxBytes, &_bufLen); + } else { + if (*(uint16_t *)buffer <= OP_TOTA_CONN_CONFIRM) { + TOTA_LOG_DBG(0, "APP TOTA UNCRYPT CONN COMMAND"); + } else { + // TODO + TOTA_LOG_DBG(0, "TOTA UNCONNECT: COMMAND NOT SUPPORT"); + return; } - + } + app_tota_cmd_received(_buf, _bufLen); +#else + TOTA_LOG_DBG(0, "APP TOTA CMD RECEIVED"); + app_tota_cmd_received(_buf, _bufLen); +#endif } - + } } - diff --git a/services/tota/app_tota_flash_program.cpp b/services/tota/app_tota_flash_program.cpp index 0188b68..209659a 100644 --- a/services/tota/app_tota_flash_program.cpp +++ b/services/tota/app_tota_flash_program.cpp @@ -14,19 +14,20 @@ * ****************************************************************************/ -#include "app_tota_cmd_code.h" +#include "app_tota_flash_program.h" #include "app_spp_tota.h" #include "app_tota.h" +#include "app_tota_cmd_code.h" #include "app_tota_cmd_handler.h" +#include "cmsis.h" +#include "cmsis_os.h" +#include "crc32.h" #include "hal_norflash.h" #include "pmu.h" #include "string.h" -#include "cmsis.h" -#include "crc32.h" -#include "cmsis_os.h" -#include "app_tota_flash_program.h" -#define TOTA_CACHE_2_UNCACHE(addr) ((unsigned int *)((unsigned int)(addr) & ~(0x04000000))) +#define TOTA_CACHE_2_UNCACHE(addr) \ + ((unsigned int *)((unsigned int)(addr) & ~(0x04000000))) static uint8_t sector_buffer[FLASH_SECTOR_SIZE_IN_BYTES]; static uint32_t sector_size = FLASH_SECTOR_SIZE_IN_BYTES; @@ -36,7 +37,8 @@ static uint32_t sector_size = FLASH_SECTOR_SIZE_IN_BYTES; ** -> OP_TOTA_WRITE_FLASH_CMD ** -> OP_TOTA_ERASE_FLASH_CMD */ -static void _tota_flash_cmd_handle(APP_TOTA_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen); +static void _tota_flash_cmd_handle(APP_TOTA_CMD_CODE_E funcCode, + uint8_t *ptrParam, uint32_t paramLen); /* ** just use this function to write data to flash with proper address @@ -44,7 +46,8 @@ static void _tota_flash_cmd_handle(APP_TOTA_CMD_CODE_E funcCode, uint8_t* ptrPar ** write flash success -> return true ** write flash failed -> return false */ -static bool _write_flash_with_crc_check(uint32_t startAddr, uint8_t * dataBuf, uint32_t dataLen, uint32_t crc); +static bool _write_flash_with_crc_check(uint32_t startAddr, uint8_t *dataBuf, + uint32_t dataLen, uint32_t crc); /* ** just use this function to erase flash with proper address and length @@ -56,299 +59,272 @@ static void _erase_flash(uint32_t startAddr, uint32_t dataLen); static void _tota_spp_connected(void); static void _tota_spp_disconnected(void); static void _tota_spp_tx_done(void); -static void _tota_spp_data_receive_handle(uint8_t * buf, uint32_t len); +static void _tota_spp_data_receive_handle(uint8_t *buf, uint32_t len); -static tota_callback_func_t s_func = { - _tota_spp_connected, - _tota_spp_disconnected, - _tota_spp_tx_done, - _tota_spp_data_receive_handle -}; +static tota_callback_func_t s_func = {_tota_spp_connected, + _tota_spp_disconnected, _tota_spp_tx_done, + _tota_spp_data_receive_handle}; static APP_TOTA_MODULE_E s_module = APP_TOTA_FLASH; -void app_tota_flash_init() -{ - tota_callback_module_register(s_module, s_func); -} +void app_tota_flash_init() { tota_callback_module_register(s_module, s_func); } -static void _tota_spp_connected(void) -{ - ; -} +static void _tota_spp_connected(void) { ; } -static void _tota_spp_disconnected(void) -{ - ; -} +static void _tota_spp_disconnected(void) { ; } -static void _tota_spp_tx_done(void) -{ - ; -} +static void _tota_spp_tx_done(void) { ; } -static void _tota_spp_data_receive_handle(uint8_t * buf, uint32_t len) -{ - ; -} +static void _tota_spp_data_receive_handle(uint8_t *buf, uint32_t len) { ; } /*------------------------------------------------------------------------------------------------------*/ /* for debug and test */ -void tota_show_flash_test(uint32_t startAddr, uint32_t len) -{ - uint8_t * pbuf = (uint8_t*)startAddr; - for ( uint32_t i = 0; i < len; i ++ ) - { - TOTA_LOG_DBG(3, "%d: [0x%2x] || [%c]", i, pbuf[i], (char)pbuf[i]); - } +void tota_show_flash_test(uint32_t startAddr, uint32_t len) { + uint8_t *pbuf = (uint8_t *)startAddr; + for (uint32_t i = 0; i < len; i++) { + TOTA_LOG_DBG(3, "%d: [0x%2x] || [%c]", i, pbuf[i], (char)pbuf[i]); + } } /* for debug and test */ -void tota_write_flash_test(uint32_t startAddr, uint8_t * dataBuf, uint32_t dataLen) -{ - uint32_t lock; - uint32_t s1, s2, s3, s4; - hal_norflash_get_size(HAL_NORFLASH_ID_0, &s1, &s2, &s3, &s4); - TOTA_LOG_DBG(4,"-- %u %u %u %u --", s1, s2, s3, s4); - TOTA_LOG_DBG(2,"flush %d bytes to flash addr 0x%x", dataLen, startAddr); - TOTA_LOG_DBG(1,"data: %s", (char *)dataBuf); - - lock=int_lock_global(); +void tota_write_flash_test(uint32_t startAddr, uint8_t *dataBuf, + uint32_t dataLen) { + uint32_t lock; + uint32_t s1, s2, s3, s4; + hal_norflash_get_size(HAL_NORFLASH_ID_0, &s1, &s2, &s3, &s4); + TOTA_LOG_DBG(4, "-- %u %u %u %u --", s1, s2, s3, s4); + TOTA_LOG_DBG(2, "flush %d bytes to flash addr 0x%x", dataLen, startAddr); + TOTA_LOG_DBG(1, "data: %s", (char *)dataBuf); + + lock = int_lock_global(); + pmu_flash_write_config(); + hal_norflash_erase(HAL_NORFLASH_ID_0, (uint32_t)(startAddr), + FLASH_SECTOR_SIZE_IN_BYTES); + hal_norflash_write(HAL_NORFLASH_ID_0, (uint32_t)(startAddr), dataBuf, + dataLen); + pmu_flash_read_config(); + int_unlock_global(lock); + + uint8_t *pbuf = (uint8_t *)startAddr; + for (uint32_t i = 0; i < dataLen; i++) { + TOTA_LOG_DBG(3, "%d: [0x%2x] || [0x%2x]", i, pbuf[i], dataBuf[i]); + } +} + +static void _tota_flash_cmd_handle(APP_TOTA_CMD_CODE_E funcCode, + uint8_t *ptrParam, uint32_t paramLen) { + TOTA_LOG_DBG(2, "Func code 0x%x, param len %d", funcCode, paramLen); + TOTA_LOG_DBG(1, "function: %s", __func__); + APP_TOTA_TRANSMISSION_PATH_E dataPath = app_tota_get_datapath(); + APP_TOTA_CMD_RET_STATUS_E rsp_status = TOTA_NO_ERROR; + TOTA_WRITE_FLASH_STRUCT_T *pflash_write_struct = + (TOTA_WRITE_FLASH_STRUCT_T *)ptrParam; + TOTA_ERASE_FLASH_STRUCT_T *pflash_erase_struct = + (TOTA_ERASE_FLASH_STRUCT_T *)ptrParam; + uint32_t crc; + switch (funcCode) { + case OP_TOTA_WRITE_FLASH_CMD: + TOTA_LOG_DBG(2, "write flash: %d bytes, crc: 0x%x", + pflash_write_struct->dataLen, pflash_write_struct->dataCrc); + pflash_write_struct->dataBuf[pflash_write_struct->dataLen] = '\0'; + TOTA_LOG_DBG(1, "write flash: %s", (char *)pflash_write_struct->dataBuf); + rsp_status = TOTA_WRITE_FLASH_CRC_CHECK_FAILED; + crc = crc32(0, pflash_write_struct->dataBuf, pflash_write_struct->dataLen); + TOTA_LOG_DBG(1, "crc 0x%x || 0x%x", crc, pflash_write_struct->dataCrc); + if (crc == pflash_write_struct->dataCrc) { + if (_write_flash_with_crc_check( + pflash_write_struct->address, pflash_write_struct->dataBuf, + pflash_write_struct->dataLen, pflash_write_struct->dataCrc)) { + rsp_status = TOTA_NO_ERROR; + } + } + + else { + TOTA_LOG_DBG(0, "crc error..."); + } + // tota_show_flash_test(TOTA_FLASH_TEST_ADDR-10, 30); + break; + case OP_TOTA_ERASE_FLASH_CMD: + TOTA_LOG_DBG(0, "erase flash"); + TOTA_LOG_DBG(2, "erase flash: 0x%x bytes, length: %u", + pflash_erase_struct->address, pflash_erase_struct->length); + _erase_flash(pflash_erase_struct->address, pflash_erase_struct->length); + // tota_show_flash_test(TOTA_FLASH_TEST_ADDR-10, 30); + break; + default: + TOTA_LOG_DBG(0, "error function code"); + } + app_tota_send_response_to_command(funcCode, rsp_status, NULL, 0, dataPath); +} + +static bool _write_flash_with_crc_check(uint32_t startAddr, uint8_t *dataBuf, + uint32_t dataLen, uint32_t crc) { + uint32_t lock; + TOTA_LOG_DBG(2, "flush %d bytes to flash addr 0x%x", dataLen, startAddr); + // TOTA_LOG_DBG(1,"data: %s", (char *)dataBuf); + + uint32_t pre_bytes = 0, middle_bytes = 0, post_bytes = 0; + uint32_t base1 = startAddr - startAddr % sector_size; + uint32_t base2 = startAddr + dataLen - (startAddr + dataLen) % sector_size; + uint32_t exist_bytes; + uint32_t middle_start_addr; + uint32_t buffer_offset; + if (startAddr % sector_size == 0) { + pre_bytes = 0; + middle_bytes = dataLen - dataLen % sector_size; + post_bytes = dataLen - middle_bytes; + } else { + if (base1 == base2) { + pre_bytes = dataLen; + } else { + pre_bytes = sector_size - startAddr % sector_size; + middle_bytes = base2 - base1 - sector_size; + post_bytes = startAddr + dataLen - base2; + } + } + TOTA_LOG_DBG(3, "pre:%u, middle:%u, post:%u", pre_bytes, middle_bytes, + post_bytes); + + if (pre_bytes != 0) { + memcpy(sector_buffer, (uint8_t *)base1, sector_size); + if (base1 == base2) + memcpy(sector_buffer + (startAddr - base1), dataBuf, dataLen); + else + memcpy(sector_buffer + (startAddr - base1), dataBuf, + sector_size - (startAddr - base1)); + lock = int_lock_global(); pmu_flash_write_config(); - hal_norflash_erase(HAL_NORFLASH_ID_0, (uint32_t)(startAddr), FLASH_SECTOR_SIZE_IN_BYTES); - hal_norflash_write(HAL_NORFLASH_ID_0, (uint32_t)(startAddr), dataBuf, dataLen); + hal_norflash_erase(HAL_NORFLASH_ID_0, base1, sector_size); + hal_norflash_write(HAL_NORFLASH_ID_0, base1, sector_buffer, sector_size); pmu_flash_read_config(); int_unlock_global(lock); - - uint8_t * pbuf = (uint8_t*)startAddr; - for ( uint32_t i = 0; i < dataLen; i ++ ) - { - TOTA_LOG_DBG(3, "%d: [0x%2x] || [0x%2x]", i, pbuf[i], dataBuf[i]); - } -} - -static void _tota_flash_cmd_handle(APP_TOTA_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - TOTA_LOG_DBG(2,"Func code 0x%x, param len %d", funcCode, paramLen); - TOTA_LOG_DBG(1,"function: %s", __func__); - APP_TOTA_TRANSMISSION_PATH_E dataPath = app_tota_get_datapath(); - APP_TOTA_CMD_RET_STATUS_E rsp_status = TOTA_NO_ERROR; - TOTA_WRITE_FLASH_STRUCT_T * pflash_write_struct = (TOTA_WRITE_FLASH_STRUCT_T *)ptrParam; - TOTA_ERASE_FLASH_STRUCT_T * pflash_erase_struct = (TOTA_ERASE_FLASH_STRUCT_T *)ptrParam; - uint32_t crc; - switch (funcCode) - { - case OP_TOTA_WRITE_FLASH_CMD: - TOTA_LOG_DBG(2, "write flash: %d bytes, crc: 0x%x", pflash_write_struct->dataLen, pflash_write_struct->dataCrc); - pflash_write_struct->dataBuf[pflash_write_struct->dataLen] = '\0'; - TOTA_LOG_DBG(1, "write flash: %s", (char*)pflash_write_struct->dataBuf); - rsp_status = TOTA_WRITE_FLASH_CRC_CHECK_FAILED; - crc = crc32(0, pflash_write_struct->dataBuf, pflash_write_struct->dataLen); - TOTA_LOG_DBG(1, "crc 0x%x || 0x%x", crc, pflash_write_struct->dataCrc); - if ( crc == pflash_write_struct->dataCrc ) - { - if ( _write_flash_with_crc_check(pflash_write_struct->address, pflash_write_struct->dataBuf, pflash_write_struct->dataLen, pflash_write_struct->dataCrc) ) - { - rsp_status = TOTA_NO_ERROR; - } - } - - else - { - TOTA_LOG_DBG(0, "crc error..."); - } - //tota_show_flash_test(TOTA_FLASH_TEST_ADDR-10, 30); - break; - case OP_TOTA_ERASE_FLASH_CMD: - TOTA_LOG_DBG(0,"erase flash"); - TOTA_LOG_DBG(2, "erase flash: 0x%x bytes, length: %u", pflash_erase_struct->address, pflash_erase_struct->length); - _erase_flash(pflash_erase_struct->address, pflash_erase_struct->length); - //tota_show_flash_test(TOTA_FLASH_TEST_ADDR-10, 30); - break; - default: - TOTA_LOG_DBG(0,"error function code"); - } - app_tota_send_response_to_command(funcCode, rsp_status, NULL, 0, dataPath); -} - -static bool _write_flash_with_crc_check(uint32_t startAddr, uint8_t * dataBuf, uint32_t dataLen, uint32_t crc) -{ - uint32_t lock; - TOTA_LOG_DBG(2,"flush %d bytes to flash addr 0x%x", dataLen, startAddr); - //TOTA_LOG_DBG(1,"data: %s", (char *)dataBuf); - - uint32_t pre_bytes = 0, middle_bytes = 0, post_bytes = 0; - uint32_t base1 = startAddr - startAddr%sector_size; - uint32_t base2 = startAddr + dataLen - (startAddr+dataLen)%sector_size; - uint32_t exist_bytes; - uint32_t middle_start_addr; - uint32_t buffer_offset; - if ( startAddr % sector_size == 0 ) - { - pre_bytes = 0; - middle_bytes = dataLen - dataLen%sector_size; - post_bytes = dataLen - middle_bytes; - } + } + if (middle_bytes != 0) { + if (base1 != startAddr) + middle_start_addr = base1 + sector_size; else - { - if ( base1 == base2 ) - { - pre_bytes = dataLen; - } - else - { - pre_bytes = sector_size - startAddr%sector_size; - middle_bytes = base2 - base1 - sector_size; - post_bytes = startAddr + dataLen - base2; - } + middle_start_addr = base1; + buffer_offset = middle_start_addr - startAddr; + lock = int_lock_global(); + pmu_flash_write_config(); + for (uint32_t i = 0; i < middle_bytes / sector_size; i++) { + hal_norflash_erase(HAL_NORFLASH_ID_0, + middle_start_addr + (i * sector_size), sector_size); + hal_norflash_write( + HAL_NORFLASH_ID_0, middle_start_addr + (i * sector_size), + dataBuf + buffer_offset + (i * sector_size), sector_size); } - TOTA_LOG_DBG(3, "pre:%u, middle:%u, post:%u", pre_bytes, middle_bytes, post_bytes); + pmu_flash_read_config(); + int_unlock_global(lock); + } + if (post_bytes != 0) { + exist_bytes = sector_size - post_bytes; + memcpy(sector_buffer, (uint8_t *)(base2 + post_bytes), exist_bytes); - if ( pre_bytes != 0 ) - { - memcpy(sector_buffer, (uint8_t*)base1, sector_size); - if ( base1 == base2 ) - memcpy(sector_buffer+(startAddr-base1), dataBuf, dataLen); - else - memcpy(sector_buffer+(startAddr-base1), dataBuf, sector_size-(startAddr-base1)); - lock=int_lock_global(); - pmu_flash_write_config(); - hal_norflash_erase(HAL_NORFLASH_ID_0, base1, sector_size); - hal_norflash_write(HAL_NORFLASH_ID_0, base1, sector_buffer, sector_size); - pmu_flash_read_config(); - int_unlock_global(lock); - } - if ( middle_bytes != 0 ) - { - if ( base1 != startAddr ) - middle_start_addr = base1+sector_size; - else - middle_start_addr = base1; - buffer_offset = middle_start_addr - startAddr; - lock=int_lock_global(); - pmu_flash_write_config(); - for ( uint32_t i = 0; i < middle_bytes/sector_size; i++ ) - { - hal_norflash_erase(HAL_NORFLASH_ID_0, middle_start_addr+(i*sector_size), sector_size); - hal_norflash_write(HAL_NORFLASH_ID_0, middle_start_addr+(i*sector_size), dataBuf+buffer_offset+(i*sector_size), sector_size); - } - pmu_flash_read_config(); - int_unlock_global(lock); - } - if ( post_bytes != 0 ) - { - exist_bytes = sector_size - post_bytes; - memcpy(sector_buffer, (uint8_t*)(base2+post_bytes), exist_bytes); - - lock=int_lock_global(); - pmu_flash_write_config(); - - hal_norflash_erase(HAL_NORFLASH_ID_0, base2, FLASH_SECTOR_SIZE_IN_BYTES); - hal_norflash_write(HAL_NORFLASH_ID_0, base2, dataBuf+(base2-startAddr), post_bytes); - hal_norflash_write(HAL_NORFLASH_ID_0, base2+post_bytes, sector_buffer, exist_bytes); - - pmu_flash_read_config(); - int_unlock_global(lock); - } - - // read and check crc - const uint32_t read_size = 1024; - uint8_t read_buffer[read_size]; - uint32_t left_bytes = dataLen; - uint32_t read_offset = 0; - uint32_t calculate_crc = 0; - while ( left_bytes > read_size ) - { - memcpy(read_buffer, (uint8_t*)(startAddr+read_offset), read_size); - calculate_crc = crc32(calculate_crc, read_buffer, read_size); - read_offset += read_size; - left_bytes -= read_size; - } - if ( left_bytes != 0 ) - { - memcpy(read_buffer, (uint8_t*)(startAddr+read_offset), left_bytes); - calculate_crc = crc32(calculate_crc, read_buffer, left_bytes); - } + lock = int_lock_global(); + pmu_flash_write_config(); - return crc == calculate_crc; + hal_norflash_erase(HAL_NORFLASH_ID_0, base2, FLASH_SECTOR_SIZE_IN_BYTES); + hal_norflash_write(HAL_NORFLASH_ID_0, base2, dataBuf + (base2 - startAddr), + post_bytes); + hal_norflash_write(HAL_NORFLASH_ID_0, base2 + post_bytes, sector_buffer, + exist_bytes); + + pmu_flash_read_config(); + int_unlock_global(lock); + } + + // read and check crc + const uint32_t read_size = 1024; + uint8_t read_buffer[read_size]; + uint32_t left_bytes = dataLen; + uint32_t read_offset = 0; + uint32_t calculate_crc = 0; + while (left_bytes > read_size) { + memcpy(read_buffer, (uint8_t *)(startAddr + read_offset), read_size); + calculate_crc = crc32(calculate_crc, read_buffer, read_size); + read_offset += read_size; + left_bytes -= read_size; + } + if (left_bytes != 0) { + memcpy(read_buffer, (uint8_t *)(startAddr + read_offset), left_bytes); + calculate_crc = crc32(calculate_crc, read_buffer, left_bytes); + } + + return crc == calculate_crc; } -static void _erase_flash(uint32_t startAddr, uint32_t dataLen) -{ - uint32_t lock; - TOTA_LOG_DBG(2,"erase %d bytes from flash addr 0x%x", dataLen, startAddr); +static void _erase_flash(uint32_t startAddr, uint32_t dataLen) { + uint32_t lock; + TOTA_LOG_DBG(2, "erase %d bytes from flash addr 0x%x", dataLen, startAddr); - uint32_t pre_bytes = 0, middle_bytes = 0, post_bytes = 0; - uint32_t base1 = startAddr - startAddr%sector_size; - uint32_t base2 = startAddr + dataLen - (startAddr+dataLen)%sector_size; - uint32_t exist_bytes; - uint32_t middle_start_addr; - if ( startAddr % sector_size == 0 ) - { - pre_bytes = 0; - middle_bytes = dataLen - dataLen%sector_size; - post_bytes = dataLen - middle_bytes; + uint32_t pre_bytes = 0, middle_bytes = 0, post_bytes = 0; + uint32_t base1 = startAddr - startAddr % sector_size; + uint32_t base2 = startAddr + dataLen - (startAddr + dataLen) % sector_size; + uint32_t exist_bytes; + uint32_t middle_start_addr; + if (startAddr % sector_size == 0) { + pre_bytes = 0; + middle_bytes = dataLen - dataLen % sector_size; + post_bytes = dataLen - middle_bytes; + } else { + if (base1 == base2) { + pre_bytes = dataLen; + } else { + pre_bytes = sector_size - startAddr % sector_size; + middle_bytes = base2 - base1 - sector_size; + post_bytes = startAddr + dataLen - base2; } + } + TOTA_LOG_DBG(3, "pre:%u, middle:%u, post:%u", pre_bytes, middle_bytes, + post_bytes); + + if (pre_bytes != 0) { + memcpy(sector_buffer, (uint8_t *)base1, sector_size); + if (base1 == base2) + memset(sector_buffer + (startAddr - base1), 0xff, dataLen); else - { - if ( base1 == base2 ) - { - pre_bytes = dataLen; - } - else - { - pre_bytes = sector_size - startAddr%sector_size; - middle_bytes = base2 - base1 - sector_size; - post_bytes = startAddr + dataLen - base2; - } + memset(sector_buffer + (startAddr - base1), 0xff, + sector_size - (startAddr - base1)); + lock = int_lock_global(); + pmu_flash_write_config(); + hal_norflash_erase(HAL_NORFLASH_ID_0, base1, sector_size); + hal_norflash_write(HAL_NORFLASH_ID_0, base1, sector_buffer, sector_size); + pmu_flash_read_config(); + int_unlock_global(lock); + } + if (middle_bytes != 0) { + if (base1 != startAddr) + middle_start_addr = base1 + sector_size; + else + middle_start_addr = base1; + lock = int_lock_global(); + pmu_flash_write_config(); + for (uint32_t i = 0; i < middle_bytes / sector_size; i++) { + hal_norflash_erase(HAL_NORFLASH_ID_0, + middle_start_addr + (i * sector_size), sector_size); } - TOTA_LOG_DBG(3, "pre:%u, middle:%u, post:%u", pre_bytes, middle_bytes, post_bytes); + pmu_flash_read_config(); + int_unlock_global(lock); + } + if (post_bytes != 0) { + exist_bytes = sector_size - post_bytes; + memcpy(sector_buffer, (uint8_t *)(base2 + post_bytes), exist_bytes); - if ( pre_bytes != 0 ) - { - memcpy(sector_buffer, (uint8_t*)base1, sector_size); - if ( base1 == base2 ) - memset(sector_buffer+(startAddr-base1), 0xff, dataLen); - else - memset(sector_buffer+(startAddr-base1), 0xff, sector_size-(startAddr-base1)); - lock=int_lock_global(); - pmu_flash_write_config(); - hal_norflash_erase(HAL_NORFLASH_ID_0, base1, sector_size); - hal_norflash_write(HAL_NORFLASH_ID_0, base1, sector_buffer, sector_size); - pmu_flash_read_config(); - int_unlock_global(lock); - } - if ( middle_bytes != 0 ) - { - if ( base1 != startAddr ) - middle_start_addr = base1+sector_size; - else - middle_start_addr = base1; - lock=int_lock_global(); - pmu_flash_write_config(); - for ( uint32_t i = 0; i < middle_bytes/sector_size; i++ ) - { - hal_norflash_erase(HAL_NORFLASH_ID_0, middle_start_addr+(i*sector_size), sector_size); - } - pmu_flash_read_config(); - int_unlock_global(lock); - } - if ( post_bytes != 0 ) - { - exist_bytes = sector_size - post_bytes; - memcpy(sector_buffer, (uint8_t*)(base2+post_bytes), exist_bytes); - - lock=int_lock_global(); - pmu_flash_write_config(); - - hal_norflash_erase(HAL_NORFLASH_ID_0, base2, FLASH_SECTOR_SIZE_IN_BYTES); - hal_norflash_write(HAL_NORFLASH_ID_0, base2+post_bytes, sector_buffer, exist_bytes); - - pmu_flash_read_config(); - int_unlock_global(lock); - } + lock = int_lock_global(); + pmu_flash_write_config(); + + hal_norflash_erase(HAL_NORFLASH_ID_0, base2, FLASH_SECTOR_SIZE_IN_BYTES); + hal_norflash_write(HAL_NORFLASH_ID_0, base2 + post_bytes, sector_buffer, + exist_bytes); + + pmu_flash_read_config(); + int_unlock_global(lock); + } } -TOTA_COMMAND_TO_ADD(OP_TOTA_WRITE_FLASH_CMD, _tota_flash_cmd_handle, false, 0, NULL ); -TOTA_COMMAND_TO_ADD(OP_TOTA_ERASE_FLASH_CMD, _tota_flash_cmd_handle, false, 0, NULL ); \ No newline at end of file +TOTA_COMMAND_TO_ADD(OP_TOTA_WRITE_FLASH_CMD, _tota_flash_cmd_handle, false, 0, + NULL); +TOTA_COMMAND_TO_ADD(OP_TOTA_ERASE_FLASH_CMD, _tota_flash_cmd_handle, false, 0, + NULL); \ No newline at end of file diff --git a/services/tota/app_tota_general.cpp b/services/tota/app_tota_general.cpp index e4ca9fd..6124968 100644 --- a/services/tota/app_tota_general.cpp +++ b/services/tota/app_tota_general.cpp @@ -13,18 +13,17 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "bluetooth.h" -#include "hal_cmu.h" -#include "app_tota_cmd_code.h" -#include "app_spp_tota.h" -#include "app_tota.h" -#include "app_tota_cmd_handler.h" -#include "cmsis.h" -#include "crc32.h" +#include "app_tota_general.h" #include "app_hfp.h" #include "app_key.h" -#include "app_tota_general.h" #include "app_spp_tota.h" +#include "app_tota.h" +#include "app_tota_cmd_code.h" +#include "app_tota_cmd_handler.h" +#include "bluetooth.h" +#include "cmsis.h" +#include "crc32.h" +#include "hal_cmu.h" #include "nvrecord_ble.h" /* ** general info struct @@ -48,7 +47,6 @@ */ static general_info_t general_info; - /* ** get general info */ @@ -57,183 +55,190 @@ static void __get_general_info(); /* ** handle general cmd */ -static void __tota_general_cmd_handle(APP_TOTA_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen); +static void __tota_general_cmd_handle(APP_TOTA_CMD_CODE_E funcCode, + uint8_t *ptrParam, uint32_t paramLen); /*------------------------------------------------------------------------------------------------------------------------*/ static void _tota_spp_connected(void); static void _tota_spp_disconnected(void); static void _tota_spp_tx_done(void); -static void _tota_spp_data_receive_handle(uint8_t * buf, uint32_t len); +static void _tota_spp_data_receive_handle(uint8_t *buf, uint32_t len); -static tota_callback_func_t s_func = { - _tota_spp_connected, - _tota_spp_disconnected, - _tota_spp_tx_done, - _tota_spp_data_receive_handle -}; +static tota_callback_func_t s_func = {_tota_spp_connected, + _tota_spp_disconnected, _tota_spp_tx_done, + _tota_spp_data_receive_handle}; static APP_TOTA_MODULE_E s_module = APP_TOTA_GENERAL; -void app_tota_general_init() -{ - tota_callback_module_register(s_module, s_func); +void app_tota_general_init() { + tota_callback_module_register(s_module, s_func); } -static void _tota_spp_connected(void) -{ - ; -} +static void _tota_spp_connected(void) { ; } -static void _tota_spp_disconnected(void) -{ - ; -} +static void _tota_spp_disconnected(void) { ; } -static void _tota_spp_tx_done(void) -{ - ; -} - -static void _tota_spp_data_receive_handle(uint8_t * buf, uint32_t len) -{ - ; -} +static void _tota_spp_tx_done(void) { ; } +static void _tota_spp_data_receive_handle(uint8_t *buf, uint32_t len) { ; } /*------------------------------------------------------------------------------------------------------------------------*/ -static void __tota_general_cmd_handle(APP_TOTA_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - TOTA_LOG_DBG(2,"Func code 0x%x, param len %d", funcCode, paramLen); - TOTA_LOG_DBG(0,"Param content:"); - DUMP8("%02x ", ptrParam, paramLen); - uint8_t resData[48]={0}; - uint32_t resLen=1; - uint8_t volume_level; - switch (funcCode) - { - case OP_TOTA_GENERAL_INFO_CMD: - __get_general_info(); - app_tota_send_response_to_command(funcCode,TOTA_NO_ERROR,(uint8_t *)&general_info, sizeof(general_info_t),app_tota_get_datapath()); - // for test - // app_tota_send_response_to_command(funcCode,TOTA_NO_ERROR,(uint8_t *)&resLen, sizeof(uint32_t),app_tota_get_datapath()); - return ; - case OP_TOTA_MERIDIAN_EFFECT_CMD: - resData[0] = app_meridian_eq(ptrParam[0]); - break; - case OP_TOTA_EQ_SELECT_CMD: - break; - case OP_TOTA_VOLUME_PLUS_CMD: - app_bt_volumeup(); - volume_level = app_bt_stream_local_volume_get(); - resData[0] = volume_level; - TRACE(1,"volume = %d",volume_level); - break; - case OP_TOTA_VOLUME_DEC_CMD: - app_bt_volumedown(); - volume_level = app_bt_stream_local_volume_get(); - resData[0] = volume_level; - resLen = 1; - TRACE(1,"volume = %d",volume_level); - break; - case OP_TOTA_VOLUME_SET_CMD: - //uint8_t scolevel = ptrParam[0]; - //uint8_t a2dplevel = ptrParam[1]; - app_bt_set_volume(APP_BT_STREAM_HFP_PCM,ptrParam[0]); - app_bt_set_volume(APP_BT_STREAM_A2DP_SBC,ptrParam[1]); - btapp_hfp_report_speak_gain(); - btapp_a2dp_report_speak_gain(); - break; - case OP_TOTA_VOLUME_GET_CMD: - resData[0] = app_bt_stream_hfpvolume_get(); - resData[1] = app_bt_stream_a2dpvolume_get(); - resLen = 2; - break; - case OP_TOTA_EQ_SET_CMD: - //int eq_index = ptrParam[0]; - if (ptrParam[0] == 3) - resData[0] = app_meridian_eq(true); - else - resData[0] = app_audio_set_eq(ptrParam[0]); - resLen = 1; - break; - case OP_TOTA_EQ_GET_CMD: - resData[0] = app_audio_get_eq(); - resLen = 1; - break; - case OP_TOTA_RAW_DATA_SET_CMD: - app_ibrt_debug_parse(ptrParam, paramLen); - break; - default: - TRACE(1,"wrong cmd 0x%x",funcCode); - resData[0] = -1; - return; - } - app_tota_send_response_to_command(funcCode,TOTA_NO_ERROR,resData,resLen,app_tota_get_datapath()); +static void __tota_general_cmd_handle(APP_TOTA_CMD_CODE_E funcCode, + uint8_t *ptrParam, uint32_t paramLen) { + TOTA_LOG_DBG(2, "Func code 0x%x, param len %d", funcCode, paramLen); + TOTA_LOG_DBG(0, "Param content:"); + DUMP8("%02x ", ptrParam, paramLen); + uint8_t resData[48] = {0}; + uint32_t resLen = 1; + uint8_t volume_level; + switch (funcCode) { + case OP_TOTA_GENERAL_INFO_CMD: + __get_general_info(); + app_tota_send_response_to_command( + funcCode, TOTA_NO_ERROR, (uint8_t *)&general_info, + sizeof(general_info_t), app_tota_get_datapath()); + // for test + // app_tota_send_response_to_command(funcCode,TOTA_NO_ERROR,(uint8_t + // *)&resLen, sizeof(uint32_t),app_tota_get_datapath()); + return; + case OP_TOTA_MERIDIAN_EFFECT_CMD: + resData[0] = app_meridian_eq(ptrParam[0]); + break; + case OP_TOTA_EQ_SELECT_CMD: + break; + case OP_TOTA_VOLUME_PLUS_CMD: + app_bt_volumeup(); + volume_level = app_bt_stream_local_volume_get(); + resData[0] = volume_level; + TRACE(1, "volume = %d", volume_level); + break; + case OP_TOTA_VOLUME_DEC_CMD: + app_bt_volumedown(); + volume_level = app_bt_stream_local_volume_get(); + resData[0] = volume_level; + resLen = 1; + TRACE(1, "volume = %d", volume_level); + break; + case OP_TOTA_VOLUME_SET_CMD: + // uint8_t scolevel = ptrParam[0]; + // uint8_t a2dplevel = ptrParam[1]; + app_bt_set_volume(APP_BT_STREAM_HFP_PCM, ptrParam[0]); + app_bt_set_volume(APP_BT_STREAM_A2DP_SBC, ptrParam[1]); + btapp_hfp_report_speak_gain(); + btapp_a2dp_report_speak_gain(); + break; + case OP_TOTA_VOLUME_GET_CMD: + resData[0] = app_bt_stream_hfpvolume_get(); + resData[1] = app_bt_stream_a2dpvolume_get(); + resLen = 2; + break; + case OP_TOTA_EQ_SET_CMD: + // int eq_index = ptrParam[0]; + if (ptrParam[0] == 3) + resData[0] = app_meridian_eq(true); + else + resData[0] = app_audio_set_eq(ptrParam[0]); + resLen = 1; + break; + case OP_TOTA_EQ_GET_CMD: + resData[0] = app_audio_get_eq(); + resLen = 1; + break; + case OP_TOTA_RAW_DATA_SET_CMD: + app_ibrt_debug_parse(ptrParam, paramLen); + break; + default: + TRACE(1, "wrong cmd 0x%x", funcCode); + resData[0] = -1; + return; + } + app_tota_send_response_to_command(funcCode, TOTA_NO_ERROR, resData, resLen, + app_tota_get_datapath()); } /* get general info */ -static void __get_general_info() -{ - /* get bt-ble name */ - uint8_t* factory_name_ptr =factory_section_get_bt_name(); - if ( factory_name_ptr != NULL ) - { - uint16_t valid_len = strlen((char*)factory_name_ptr) > BT_BLE_LOCAL_NAME_LEN? BT_BLE_LOCAL_NAME_LEN:strlen((char*)factory_name_ptr); - memcpy(general_info.btName,factory_name_ptr,valid_len); - } +static void __get_general_info() { + /* get bt-ble name */ + uint8_t *factory_name_ptr = factory_section_get_bt_name(); + if (factory_name_ptr != NULL) { + uint16_t valid_len = + strlen((char *)factory_name_ptr) > BT_BLE_LOCAL_NAME_LEN + ? BT_BLE_LOCAL_NAME_LEN + : strlen((char *)factory_name_ptr); + memcpy(general_info.btName, factory_name_ptr, valid_len); + } - factory_name_ptr =factory_section_get_ble_name(); - if ( factory_name_ptr != NULL ) - { - uint16_t valid_len = strlen((char*)factory_name_ptr) > BT_BLE_LOCAL_NAME_LEN? BT_BLE_LOCAL_NAME_LEN:strlen((char*)factory_name_ptr); - memcpy(general_info.bleName,factory_name_ptr,valid_len); - } + factory_name_ptr = factory_section_get_ble_name(); + if (factory_name_ptr != NULL) { + uint16_t valid_len = + strlen((char *)factory_name_ptr) > BT_BLE_LOCAL_NAME_LEN + ? BT_BLE_LOCAL_NAME_LEN + : strlen((char *)factory_name_ptr); + memcpy(general_info.bleName, factory_name_ptr, valid_len); + } - /* get bt-ble peer addr */ - ibrt_config_t addrInfo; - app_ibrt_ui_test_config_load(&addrInfo); - general_info.ibrtRole = addrInfo.nv_role; - memcpy(general_info.btLocalAddr.address, addrInfo.local_addr.address, 6); - memcpy(general_info.btPeerAddr.address, addrInfo.peer_addr.address, 6); + /* get bt-ble peer addr */ + ibrt_config_t addrInfo; + app_ibrt_ui_test_config_load(&addrInfo); + general_info.ibrtRole = addrInfo.nv_role; + memcpy(general_info.btLocalAddr.address, addrInfo.local_addr.address, 6); + memcpy(general_info.btPeerAddr.address, addrInfo.peer_addr.address, 6); - #ifdef BLE - memcpy(general_info.bleLocalAddr.address, bt_get_ble_local_address(), 6); - memcpy(general_info.blePeerAddr.address, nv_record_tws_get_peer_ble_addr(), 6); - #endif - - /* get crystal info */ - general_info.crystal_freq = hal_cmu_get_crystal_freq(); - - /* factory_section_xtal_fcap_get */ - factory_section_xtal_fcap_get(&general_info.xtal_fcap); - - /* get battery info (volt level)*/ - app_battery_get_info(&general_info.battery_volt,&general_info.battery_level,&general_info.battery_status); - - /* get firmware version */ -#ifdef FIRMWARE_REV - system_get_info(&general_info.fw_version[0],&general_info.fw_version[1],&general_info.fw_version[2],&general_info.fw_version[3]); - TRACE(4,"firmware version = %d.%d.%d.%d",general_info.fw_version[0],general_info.fw_version[1],general_info.fw_version[2],general_info.fw_version[3]); +#ifdef BLE + memcpy(general_info.bleLocalAddr.address, bt_get_ble_local_address(), 6); + memcpy(general_info.blePeerAddr.address, nv_record_tws_get_peer_ble_addr(), + 6); #endif - /* get ear location info */ - if ( app_tws_is_right_side() ) general_info.ear_location = EAR_SIDE_RIGHT; - else if ( app_tws_is_left_side() ) general_info.ear_location = EAR_SIDE_LEFT; - else general_info.ear_location = EAR_SIDE_UNKNOWN; + /* get crystal info */ + general_info.crystal_freq = hal_cmu_get_crystal_freq(); - app_ibrt_rssi_get_stutter(general_info.rssi, &general_info.rssi_len); + /* factory_section_xtal_fcap_get */ + factory_section_xtal_fcap_get(&general_info.xtal_fcap); + + /* get battery info (volt level)*/ + app_battery_get_info(&general_info.battery_volt, &general_info.battery_level, + &general_info.battery_status); + + /* get firmware version */ +#ifdef FIRMWARE_REV + system_get_info(&general_info.fw_version[0], &general_info.fw_version[1], + &general_info.fw_version[2], &general_info.fw_version[3]); + TRACE(4, "firmware version = %d.%d.%d.%d", general_info.fw_version[0], + general_info.fw_version[1], general_info.fw_version[2], + general_info.fw_version[3]); +#endif + + /* get ear location info */ + if (app_tws_is_right_side()) + general_info.ear_location = EAR_SIDE_RIGHT; + else if (app_tws_is_left_side()) + general_info.ear_location = EAR_SIDE_LEFT; + else + general_info.ear_location = EAR_SIDE_UNKNOWN; + + app_ibrt_rssi_get_stutter(general_info.rssi, &general_info.rssi_len); } - /* general command */ -TOTA_COMMAND_TO_ADD(OP_TOTA_GENERAL_INFO_CMD, __tota_general_cmd_handle, false, 0, NULL ); -TOTA_COMMAND_TO_ADD(OP_TOTA_MERIDIAN_EFFECT_CMD, __tota_general_cmd_handle, false, 0, NULL ); -TOTA_COMMAND_TO_ADD(OP_TOTA_EQ_SELECT_CMD, __tota_general_cmd_handle, false, 0, NULL ); -TOTA_COMMAND_TO_ADD(OP_TOTA_VOLUME_PLUS_CMD, __tota_general_cmd_handle, false, 0, NULL ); -TOTA_COMMAND_TO_ADD(OP_TOTA_VOLUME_DEC_CMD, __tota_general_cmd_handle, false, 0, NULL ); -TOTA_COMMAND_TO_ADD(OP_TOTA_VOLUME_SET_CMD, __tota_general_cmd_handle, false, 0, NULL ); -TOTA_COMMAND_TO_ADD(OP_TOTA_VOLUME_GET_CMD, __tota_general_cmd_handle, false, 0, NULL ); -TOTA_COMMAND_TO_ADD(OP_TOTA_EQ_SET_CMD, __tota_general_cmd_handle, false, 0, NULL ); -TOTA_COMMAND_TO_ADD(OP_TOTA_EQ_GET_CMD, __tota_general_cmd_handle, false, 0, NULL ); -TOTA_COMMAND_TO_ADD(OP_TOTA_RAW_DATA_SET_CMD, __tota_general_cmd_handle, false, 0, NULL ); +TOTA_COMMAND_TO_ADD(OP_TOTA_GENERAL_INFO_CMD, __tota_general_cmd_handle, false, + 0, NULL); +TOTA_COMMAND_TO_ADD(OP_TOTA_MERIDIAN_EFFECT_CMD, __tota_general_cmd_handle, + false, 0, NULL); +TOTA_COMMAND_TO_ADD(OP_TOTA_EQ_SELECT_CMD, __tota_general_cmd_handle, false, 0, + NULL); +TOTA_COMMAND_TO_ADD(OP_TOTA_VOLUME_PLUS_CMD, __tota_general_cmd_handle, false, + 0, NULL); +TOTA_COMMAND_TO_ADD(OP_TOTA_VOLUME_DEC_CMD, __tota_general_cmd_handle, false, 0, + NULL); +TOTA_COMMAND_TO_ADD(OP_TOTA_VOLUME_SET_CMD, __tota_general_cmd_handle, false, 0, + NULL); +TOTA_COMMAND_TO_ADD(OP_TOTA_VOLUME_GET_CMD, __tota_general_cmd_handle, false, 0, + NULL); +TOTA_COMMAND_TO_ADD(OP_TOTA_EQ_SET_CMD, __tota_general_cmd_handle, false, 0, + NULL); +TOTA_COMMAND_TO_ADD(OP_TOTA_EQ_GET_CMD, __tota_general_cmd_handle, false, 0, + NULL); +TOTA_COMMAND_TO_ADD(OP_TOTA_RAW_DATA_SET_CMD, __tota_general_cmd_handle, false, + 0, NULL); diff --git a/services/tota/app_tota_mic.cpp b/services/tota/app_tota_mic.cpp index 2ec51de..6f4e39e 100644 --- a/services/tota/app_tota_mic.cpp +++ b/services/tota/app_tota_mic.cpp @@ -14,96 +14,78 @@ * ****************************************************************************/ -#include "app_spp_tota.h" -#include "tota_stream_data_transfer.h" -#include "app_tota_cmd_code.h" -#include "app_bt_stream.h" -#include "app_audio.h" -#include "app_tota.h" -#include "app_tota_cmd_handler.h" #include "app_tota_mic.h" +#include "app_audio.h" +#include "app_bt_stream.h" +#include "app_spp_tota.h" +#include "app_tota.h" +#include "app_tota_cmd_code.h" +#include "app_tota_cmd_handler.h" #include "cmsis_os.h" +#include "tota_stream_data_transfer.h" static void _tota_spp_connected(void); static void _tota_spp_disconnected(void); static void _tota_spp_tx_done(void); -static void _tota_spp_data_receive_handle(uint8_t * buf, uint32_t len); +static void _tota_spp_data_receive_handle(uint8_t *buf, uint32_t len); /**/ -static void _mic_cmd_handle(APP_TOTA_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen); +static void _mic_cmd_handle(APP_TOTA_CMD_CODE_E funcCode, uint8_t *ptrParam, + uint32_t paramLen); /**/ -static tota_callback_func_t s_func = { - _tota_spp_connected, - _tota_spp_disconnected, - _tota_spp_tx_done, - _tota_spp_data_receive_handle -}; +static tota_callback_func_t s_func = {_tota_spp_connected, + _tota_spp_disconnected, _tota_spp_tx_done, + _tota_spp_data_receive_handle}; static APP_TOTA_MODULE_E s_module = APP_TOTA_MIC; +void app_tota_mic_init() { tota_callback_module_register(s_module, s_func); } -void app_tota_mic_init() -{ - tota_callback_module_register(s_module, s_func); -} +static void _tota_spp_connected(void) { ; } -static void _tota_spp_connected(void) -{ - ; -} - -static void _tota_spp_disconnected(void) -{ - ; -} - -static void _tota_spp_tx_done(void) -{ - ; -} - -static void _tota_spp_data_receive_handle(uint8_t * buf, uint32_t len) -{ - ; -} +static void _tota_spp_disconnected(void) { ; } +static void _tota_spp_tx_done(void) { ; } +static void _tota_spp_data_receive_handle(uint8_t *buf, uint32_t len) { ; } /*-----------------------------------------------------------------------------*/ -static void _mic_cmd_handle(APP_TOTA_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - TOTA_LOG_DBG(2,"Func code 0x%x, param len %d", funcCode, paramLen); - TOTA_LOG_DBG(0,"Param content:"); - DUMP8("%02x ", ptrParam, paramLen); - APP_TOTA_CMD_RET_STATUS_E rsp_status = TOTA_NO_ERROR; - uint8_t resData[48]={0}; - uint32_t resLen=1; - switch (funcCode) - { - case OP_TOTA_MIC_TEST_ON: - TRACE(0,"#####mic test on:"); +static void _mic_cmd_handle(APP_TOTA_CMD_CODE_E funcCode, uint8_t *ptrParam, + uint32_t paramLen) { + TOTA_LOG_DBG(2, "Func code 0x%x, param len %d", funcCode, paramLen); + TOTA_LOG_DBG(0, "Param content:"); + DUMP8("%02x ", ptrParam, paramLen); + APP_TOTA_CMD_RET_STATUS_E rsp_status = TOTA_NO_ERROR; + uint8_t resData[48] = {0}; + uint32_t resLen = 1; + switch (funcCode) { + case OP_TOTA_MIC_TEST_ON: + TRACE(0, "#####mic test on:"); #ifdef __FACTORY_MODE_SUPPORT__ - app_audio_sendrequest(APP_BT_STREAM_INVALID, (uint8_t)APP_BT_SETTING_CLOSEALL, 0); - app_audio_sendrequest(APP_FACTORYMODE_AUDIO_LOOP, (uint8_t)APP_BT_SETTING_OPEN, 0); + app_audio_sendrequest(APP_BT_STREAM_INVALID, + (uint8_t)APP_BT_SETTING_CLOSEALL, 0); + app_audio_sendrequest(APP_FACTORYMODE_AUDIO_LOOP, + (uint8_t)APP_BT_SETTING_OPEN, 0); #endif - break; - case OP_TOTA_MIC_TEST_OFF: - TRACE(0,"#####mic test off:"); + break; + case OP_TOTA_MIC_TEST_OFF: + TRACE(0, "#####mic test off:"); #ifdef __FACTORY_MODE_SUPPORT__ - app_audio_sendrequest(APP_FACTORYMODE_AUDIO_LOOP, (uint8_t)APP_BT_SETTING_CLOSE, 0); + app_audio_sendrequest(APP_FACTORYMODE_AUDIO_LOOP, + (uint8_t)APP_BT_SETTING_CLOSE, 0); #endif - break; - case OP_TOTA_MIC_SWITCH: - TRACE(0,"####mic switch test, do role switch"); - if ( !app_ibrt_ui_tws_switch() ) - rsp_status = TOTA_MIC_SWITCH_FAILED; - break; - default: - ; - } - app_tota_send_response_to_command(funcCode,rsp_status,resData,resLen,app_tota_get_datapath()); + break; + case OP_TOTA_MIC_SWITCH: + TRACE(0, "####mic switch test, do role switch"); + if (!app_ibrt_ui_tws_switch()) + rsp_status = TOTA_MIC_SWITCH_FAILED; + break; + default:; + } + app_tota_send_response_to_command(funcCode, rsp_status, resData, resLen, + app_tota_get_datapath()); } -TOTA_COMMAND_TO_ADD(OP_TOTA_MIC_TEST_ON, _mic_cmd_handle, false, 0, NULL ); -TOTA_COMMAND_TO_ADD(OP_TOTA_MIC_TEST_OFF, _mic_cmd_handle, false, 0, NULL ); -TOTA_COMMAND_TO_ADD(OP_TOTA_MIC_SWITCH, _mic_cmd_handle, false, 0, NULL ); +TOTA_COMMAND_TO_ADD(OP_TOTA_MIC_TEST_ON, _mic_cmd_handle, false, 0, NULL); +TOTA_COMMAND_TO_ADD(OP_TOTA_MIC_TEST_OFF, _mic_cmd_handle, false, 0, NULL); +TOTA_COMMAND_TO_ADD(OP_TOTA_MIC_SWITCH, _mic_cmd_handle, false, 0, NULL); diff --git a/services/tota/tota_buffer_manager.cpp b/services/tota/tota_buffer_manager.cpp index abc0316..8852832 100644 --- a/services/tota/tota_buffer_manager.cpp +++ b/services/tota/tota_buffer_manager.cpp @@ -19,123 +19,109 @@ #include "cmsis_os.h" #include "string.h" -osMutexDef (stream_buf_mutex); -osMutexId stream_buf_mutex_id; +osMutexDef(stream_buf_mutex); +osMutexId stream_buf_mutex_id; static stream_buf_t stream_buf; -static osThreadId father_thread_tid; +static osThreadId father_thread_tid; -void tota_stream_buffer_init(osThreadId tid) -{ - stream_buf.dataSize = 0; - stream_buf.availableSpace = TOTA_STREAM_BUF_SIZE; - stream_buf.readPos = 0; - stream_buf.writePos = 0; - stream_buf.flushBytes = 0; +void tota_stream_buffer_init(osThreadId tid) { + stream_buf.dataSize = 0; + stream_buf.availableSpace = TOTA_STREAM_BUF_SIZE; + stream_buf.readPos = 0; + stream_buf.writePos = 0; + stream_buf.flushBytes = 0; - stream_buf_mutex_id = osMutexCreate(osMutex(stream_buf_mutex)); - father_thread_tid = tid; + stream_buf_mutex_id = osMutexCreate(osMutex(stream_buf_mutex)); + father_thread_tid = tid; } -bool tota_stream_buffer_write(uint8_t * buf, uint32_t bufLen) -{ - osMutexWait(stream_buf_mutex_id, osWaitForever); - if ( stream_buf.availableSpace > bufLen ) - { - // write to stream buf - if ( stream_buf.writePos + bufLen <= TOTA_STREAM_BUF_SIZE ) - { - memcpy(stream_buf.buf + stream_buf.writePos, buf, bufLen); - - stream_buf.writePos += bufLen; - if ( stream_buf.writePos == TOTA_STREAM_BUF_SIZE ) - stream_buf.writePos = 0; - } - else - { - uint32_t part1 = TOTA_STREAM_BUF_SIZE - stream_buf.writePos; - memcpy(stream_buf.buf + stream_buf.writePos, buf , part1); - memcpy(stream_buf.buf , buf + part1, bufLen-part1); - stream_buf.writePos = bufLen-part1; - } +bool tota_stream_buffer_write(uint8_t *buf, uint32_t bufLen) { + osMutexWait(stream_buf_mutex_id, osWaitForever); + if (stream_buf.availableSpace > bufLen) { + // write to stream buf + if (stream_buf.writePos + bufLen <= TOTA_STREAM_BUF_SIZE) { + memcpy(stream_buf.buf + stream_buf.writePos, buf, bufLen); - stream_buf.dataSize += bufLen; - stream_buf.availableSpace -= bufLen; - - TOTA_LOG_DBG(1, "buffer> after write: %5u bytes", bufLen); - TOTA_LOG_DBG(4, "buffer> size:%5u available:%5u writepos:%5u readpos:%5u:", stream_buf.dataSize, stream_buf.availableSpace, stream_buf.writePos, stream_buf.readPos); - - osMutexRelease(stream_buf_mutex_id); - /* set signal to father thread, has data */ - osSignalSet(father_thread_tid, 0x0001); - - return true; + stream_buf.writePos += bufLen; + if (stream_buf.writePos == TOTA_STREAM_BUF_SIZE) + stream_buf.writePos = 0; + } else { + uint32_t part1 = TOTA_STREAM_BUF_SIZE - stream_buf.writePos; + memcpy(stream_buf.buf + stream_buf.writePos, buf, part1); + memcpy(stream_buf.buf, buf + part1, bufLen - part1); + stream_buf.writePos = bufLen - part1; } - else - { - osMutexRelease(stream_buf_mutex_id); - return false; - } -} + stream_buf.dataSize += bufLen; + stream_buf.availableSpace -= bufLen; -bool tota_stream_buffer_read(uint8_t * rbuf, uint32_t readSize, uint32_t * flushbytes) -{ - osMutexWait(stream_buf_mutex_id, osWaitForever); - if ( readSize < stream_buf.dataSize ) - { - if ( stream_buf.readPos + readSize <= TOTA_STREAM_BUF_SIZE ) - { - memcpy(rbuf, stream_buf.buf + stream_buf.readPos, readSize); - stream_buf.readPos += readSize; - if ( stream_buf.readPos == TOTA_STREAM_BUF_SIZE ) - stream_buf.readPos = 0; - } - else - { - uint32_t part1 = TOTA_STREAM_BUF_SIZE - stream_buf.readPos; - memcpy(rbuf , stream_buf.buf + stream_buf.readPos, part1); - memcpy(rbuf + part1, stream_buf.buf , readSize-part1); - stream_buf.readPos = readSize-part1; - } - stream_buf.dataSize -= readSize; - stream_buf.availableSpace += readSize; - /* debug */ - TOTA_LOG_DBG(1, "buffer> after read: %5u bytes", readSize); - TOTA_LOG_DBG(4, "buffer> size:%5u available:%5u writepos:%5u readpos:%5u:", stream_buf.dataSize, stream_buf.availableSpace, stream_buf.writePos, stream_buf.readPos); - if ( flushbytes != NULL ) - { - *flushbytes = stream_buf.flushBytes; - stream_buf.flushBytes = 0; - } - osMutexRelease(stream_buf_mutex_id); - return true; - } - else - { - osMutexRelease(stream_buf_mutex_id); - return false; - } -} + TOTA_LOG_DBG(1, "buffer> after write: %5u bytes", bufLen); + TOTA_LOG_DBG(4, "buffer> size:%5u available:%5u writepos:%5u readpos:%5u:", + stream_buf.dataSize, stream_buf.availableSpace, + stream_buf.writePos, stream_buf.readPos); -void tota_stream_buffer_flush(void) -{ - osMutexWait(stream_buf_mutex_id, osWaitForever); - stream_buf.flushBytes = stream_buf.dataSize; - stream_buf.availableSpace = TOTA_STREAM_BUF_SIZE; - stream_buf.dataSize = 0; - stream_buf.readPos = 0; - stream_buf.writePos = 0; osMutexRelease(stream_buf_mutex_id); + /* set signal to father thread, has data */ + osSignalSet(father_thread_tid, 0x0001); + + return true; + } else { + osMutexRelease(stream_buf_mutex_id); + return false; + } } -void tota_stream_buffer_clean(void) -{ - osMutexWait(stream_buf_mutex_id, osWaitForever); - stream_buf.flushBytes = 0; - stream_buf.availableSpace = TOTA_STREAM_BUF_SIZE; - stream_buf.dataSize = 0; - stream_buf.readPos = 0; - stream_buf.writePos = 0; +bool tota_stream_buffer_read(uint8_t *rbuf, uint32_t readSize, + uint32_t *flushbytes) { + osMutexWait(stream_buf_mutex_id, osWaitForever); + if (readSize < stream_buf.dataSize) { + if (stream_buf.readPos + readSize <= TOTA_STREAM_BUF_SIZE) { + memcpy(rbuf, stream_buf.buf + stream_buf.readPos, readSize); + stream_buf.readPos += readSize; + if (stream_buf.readPos == TOTA_STREAM_BUF_SIZE) + stream_buf.readPos = 0; + } else { + uint32_t part1 = TOTA_STREAM_BUF_SIZE - stream_buf.readPos; + memcpy(rbuf, stream_buf.buf + stream_buf.readPos, part1); + memcpy(rbuf + part1, stream_buf.buf, readSize - part1); + stream_buf.readPos = readSize - part1; + } + stream_buf.dataSize -= readSize; + stream_buf.availableSpace += readSize; + /* debug */ + TOTA_LOG_DBG(1, "buffer> after read: %5u bytes", readSize); + TOTA_LOG_DBG(4, "buffer> size:%5u available:%5u writepos:%5u readpos:%5u:", + stream_buf.dataSize, stream_buf.availableSpace, + stream_buf.writePos, stream_buf.readPos); + if (flushbytes != NULL) { + *flushbytes = stream_buf.flushBytes; + stream_buf.flushBytes = 0; + } osMutexRelease(stream_buf_mutex_id); + return true; + } else { + osMutexRelease(stream_buf_mutex_id); + return false; + } +} + +void tota_stream_buffer_flush(void) { + osMutexWait(stream_buf_mutex_id, osWaitForever); + stream_buf.flushBytes = stream_buf.dataSize; + stream_buf.availableSpace = TOTA_STREAM_BUF_SIZE; + stream_buf.dataSize = 0; + stream_buf.readPos = 0; + stream_buf.writePos = 0; + osMutexRelease(stream_buf_mutex_id); +} + +void tota_stream_buffer_clean(void) { + osMutexWait(stream_buf_mutex_id, osWaitForever); + stream_buf.flushBytes = 0; + stream_buf.availableSpace = TOTA_STREAM_BUF_SIZE; + stream_buf.dataSize = 0; + stream_buf.readPos = 0; + stream_buf.writePos = 0; + osMutexRelease(stream_buf_mutex_id); } \ No newline at end of file diff --git a/services/tota/tota_stream_data_transfer.cpp b/services/tota/tota_stream_data_transfer.cpp index 8dcb79a..dbe38c2 100644 --- a/services/tota/tota_stream_data_transfer.cpp +++ b/services/tota/tota_stream_data_transfer.cpp @@ -14,217 +14,174 @@ * ****************************************************************************/ -#include "string.h" -#include "cmsis_os.h" -#include "hal_trace.h" -#include "hal_timer.h" -#include "apps.h" -#include "stdbool.h" -#include "app_tota.h" -#include "app_tota_cmd_code.h" -#include "app_tota_cmd_handler.h" -#include "app_tota_data_handler.h" -#include "app_utils.h" -#include "crc32.h" +#include "tota_stream_data_transfer.h" #include "app_spp_tota.h" #include "app_spp_tota_general_service.h" -#include "tota_buffer_manager.h" -#include "tota_stream_data_transfer.h" +#include "app_tota.h" +#include "app_tota_cmd_code.h" +#include "app_tota_cmd_handler.h" #include "app_tota_conn.h" +#include "app_tota_data_handler.h" +#include "app_utils.h" +#include "apps.h" +#include "cmsis_os.h" +#include "crc32.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "stdbool.h" +#include "string.h" +#include "tota_buffer_manager.h" -/* +/* ** stream control strcut ** stream packet format: ** # header + body # ** > header: 2 bytes ** > body : 664 bytes -** +** ** note: stream will never be encrypted! */ -typedef struct{ - uint32_t flush_bytes; - bool is_streaming; - uint8_t module; - - osMutexId mutex; - osSemaphoreId sem; -}stream_control_t; +typedef struct { + uint32_t flush_bytes; + bool is_streaming; + uint8_t module; + + osMutexId mutex; + osSemaphoreId sem; +} stream_control_t; stream_control_t stream_control; -osMutexDef (tota_tx_buf_mutex); -osMutexId tota_tx_buf_mutex_id; +osMutexDef(tota_tx_buf_mutex); +osMutexId tota_tx_buf_mutex_id; -#define SPP_BUFFER_NUM 5 +#define SPP_BUFFER_NUM 5 -static uint8_t spp_tx_buffer[MAX_SPP_PACKET_SIZE*SPP_BUFFER_NUM]; +static uint8_t spp_tx_buffer[MAX_SPP_PACKET_SIZE * SPP_BUFFER_NUM]; static uint8_t tx_buf_index = 0; - /* static function */ -static bool _tota_send_stream_packet(uint8_t * pdata, uint32_t dataLen); +static bool _tota_send_stream_packet(uint8_t *pdata, uint32_t dataLen); static void _tota_stream_data_init(); static void _update_tx_buf(); -static uint8_t * _get_tx_buf_ptr(); +static uint8_t *_get_tx_buf_ptr(); // Semaphore osSemaphoreDef(app_tota_send_data_sem); // define stream data transfer thread -#define TOTA_STREAM_DATA_STACK_SIZE 2048 +#define TOTA_STREAM_DATA_STACK_SIZE 2048 static void tota_stream_data_transfer_thread(void const *argument); osThreadId tota_stream_thread_tid; -osThreadDef(tota_stream_data_transfer_thread, osPriorityHigh, 1, TOTA_STREAM_DATA_STACK_SIZE, "TOTA_STREAM_DATA_THREAD"); +osThreadDef(tota_stream_data_transfer_thread, osPriorityHigh, 1, + TOTA_STREAM_DATA_STACK_SIZE, "TOTA_STREAM_DATA_THREAD"); -static void tota_stream_data_transfer_thread(void const *argument) -{ - // TODO: max speed - uint8_t buf[MAX_SPP_PACKET_SIZE]; - while ( true ) - { - app_sysfreq_req(APP_SYSFREQ_USER_OTA, APP_SYSFREQ_32K); - osSignalWait(0x0001, osWaitForever); - app_sysfreq_req(APP_SYSFREQ_USER_OTA, APP_SYSFREQ_208M); - while ( tota_stream_buffer_read(buf + STREAM_HEADER_SIZE, MAX_SPP_PACKET_SIZE - STREAM_HEADER_SIZE) ) - { - _tota_send_stream_packet(buf, MAX_SPP_PACKET_SIZE); - } +static void tota_stream_data_transfer_thread(void const *argument) { + // TODO: max speed + uint8_t buf[MAX_SPP_PACKET_SIZE]; + while (true) { + app_sysfreq_req(APP_SYSFREQ_USER_OTA, APP_SYSFREQ_32K); + osSignalWait(0x0001, osWaitForever); + app_sysfreq_req(APP_SYSFREQ_USER_OTA, APP_SYSFREQ_208M); + while (tota_stream_buffer_read(buf + STREAM_HEADER_SIZE, + MAX_SPP_PACKET_SIZE - STREAM_HEADER_SIZE)) { + _tota_send_stream_packet(buf, MAX_SPP_PACKET_SIZE); } + } } -void app_tota_stream_data_transfer_init() -{ - stream_control.sem = osSemaphoreCreate(osSemaphore(app_tota_send_data_sem), SPP_BUFFER_NUM); - tota_stream_thread_tid = osThreadCreate(osThread(tota_stream_data_transfer_thread), NULL); - _tota_stream_data_init(); +void app_tota_stream_data_transfer_init() { + stream_control.sem = + osSemaphoreCreate(osSemaphore(app_tota_send_data_sem), SPP_BUFFER_NUM); + tota_stream_thread_tid = + osThreadCreate(osThread(tota_stream_data_transfer_thread), NULL); + _tota_stream_data_init(); } // stream start -void app_tota_stream_data_start(uint16_t set_module) -{ - stream_control.module = set_module; - stream_control.is_streaming = true; +void app_tota_stream_data_start(uint16_t set_module) { + stream_control.module = set_module; + stream_control.is_streaming = true; } // stream end -void app_tota_stream_data_end() -{ - stream_control.is_streaming = false; -} +void app_tota_stream_data_end() { stream_control.is_streaming = false; } // stream send data while stream is start -bool app_tota_send_stream_data(uint8_t * pdata, uint32_t dataLen) -{ - if ( !stream_control.is_streaming ) - { - TOTA_LOG_DBG(0, "error: data stream not start."); - return false; - } - if ( tota_stream_buffer_write(pdata, dataLen) ) - { - TOTA_LOG_DBG(0, "send to stream buffer ok."); - return true; - } - else - { - TOTA_LOG_DBG(0, "send to stream buffer error."); - return false; - } +bool app_tota_send_stream_data(uint8_t *pdata, uint32_t dataLen) { + if (!stream_control.is_streaming) { + TOTA_LOG_DBG(0, "error: data stream not start."); + return false; + } + if (tota_stream_buffer_write(pdata, dataLen)) { + TOTA_LOG_DBG(0, "send to stream buffer ok."); + return true; + } else { + TOTA_LOG_DBG(0, "send to stream buffer error."); + return false; + } } // stream flush -void app_tota_stream_data_flush() -{ - tota_stream_buffer_flush(); -} +void app_tota_stream_data_flush() { tota_stream_buffer_flush(); } // stream clean -void app_tota_stream_data_clean() -{ - tota_stream_buffer_clean(); -} +void app_tota_stream_data_clean() { tota_stream_buffer_clean(); } - -bool app_tota_send_data_via_spp(uint8_t * pdata, uint32_t dataLen) -{ - osSemaphoreWait(stream_control.sem, osWaitForever); - osMutexRelease(tota_tx_buf_mutex_id); - uint8_t * pbuf = pdata; - uint32_t bufLen = dataLen; +bool app_tota_send_data_via_spp(uint8_t *pdata, uint32_t dataLen) { + osSemaphoreWait(stream_control.sem, osWaitForever); + osMutexRelease(tota_tx_buf_mutex_id); + uint8_t *pbuf = pdata; + uint32_t bufLen = dataLen; #if TOTA_ENCODE - if ( ((uint16_t *)pdata)[0] == OP_TOTA_STRING ) - { - TOTA_LOG_DBG(0, "yeah! This is a string. Do not encrypt"); - } - else if ( is_tota_connected() ) - { - pbuf = tota_encrypt_packet(pdata, dataLen, &bufLen); - } + if (((uint16_t *)pdata)[0] == OP_TOTA_STRING) { + TOTA_LOG_DBG(0, "yeah! This is a string. Do not encrypt"); + } else if (is_tota_connected()) { + pbuf = tota_encrypt_packet(pdata, dataLen, &bufLen); + } #endif - memcpy(_get_tx_buf_ptr(), pbuf, bufLen); + memcpy(_get_tx_buf_ptr(), pbuf, bufLen); - if ( app_spp_tota_send_data(_get_tx_buf_ptr(), bufLen) ) - { - _update_tx_buf(); - osMutexRelease(tota_tx_buf_mutex_id); - return true; - } - else - { - osMutexRelease(tota_tx_buf_mutex_id); - osSemaphoreRelease(stream_control.sem); - return false; - } - -} - -void app_tota_tx_done_callback() -{ + if (app_spp_tota_send_data(_get_tx_buf_ptr(), bufLen)) { + _update_tx_buf(); + osMutexRelease(tota_tx_buf_mutex_id); + return true; + } else { + osMutexRelease(tota_tx_buf_mutex_id); osSemaphoreRelease(stream_control.sem); + return false; + } } -bool is_stream_data_running() -{ - return stream_control.is_streaming; -} +void app_tota_tx_done_callback() { osSemaphoreRelease(stream_control.sem); } + +bool is_stream_data_running() { return stream_control.is_streaming; } // send stream packet with header. packet size:666 -static bool _tota_send_stream_packet(uint8_t * pdata, uint32_t dataLen) -{ - osSemaphoreWait(stream_control.sem, osWaitForever); +static bool _tota_send_stream_packet(uint8_t *pdata, uint32_t dataLen) { + osSemaphoreWait(stream_control.sem, osWaitForever); + osMutexRelease(tota_tx_buf_mutex_id); + ((uint16_t *)pdata)[0] = (OP_TOTA_STREAM_DATA - stream_control.module); + memcpy(_get_tx_buf_ptr(), pdata, dataLen); + if (app_spp_tota_send_data(_get_tx_buf_ptr(), dataLen)) { + _update_tx_buf(); osMutexRelease(tota_tx_buf_mutex_id); - ((uint16_t *)pdata)[0] = (OP_TOTA_STREAM_DATA - stream_control.module); - memcpy(_get_tx_buf_ptr(), pdata, dataLen); - if ( app_spp_tota_send_data(_get_tx_buf_ptr(), dataLen) ) - { - _update_tx_buf(); - osMutexRelease(tota_tx_buf_mutex_id); - return true; - } - else - { - osMutexRelease(tota_tx_buf_mutex_id); - osSemaphoreRelease(stream_control.sem); - return false; - } + return true; + } else { + osMutexRelease(tota_tx_buf_mutex_id); + osSemaphoreRelease(stream_control.sem); + return false; + } } -static void _tota_stream_data_init() -{ - tota_stream_buffer_init(tota_stream_thread_tid); - stream_control.module = 0; - stream_control.is_streaming = false; +static void _tota_stream_data_init() { + tota_stream_buffer_init(tota_stream_thread_tid); + stream_control.module = 0; + stream_control.is_streaming = false; } -static void _update_tx_buf() -{ - tx_buf_index = (tx_buf_index + 1) % 5; +static void _update_tx_buf() { tx_buf_index = (tx_buf_index + 1) % 5; } + +static uint8_t *_get_tx_buf_ptr() { + return (spp_tx_buffer + tx_buf_index * MAX_SPP_PACKET_SIZE); } - - -static uint8_t * _get_tx_buf_ptr() -{ - return (spp_tx_buffer + tx_buf_index*MAX_SPP_PACKET_SIZE); -} - - diff --git a/services/tota/tota_test.cpp b/services/tota/tota_test.cpp index c0e3dae..a722ff6 100644 --- a/services/tota/tota_test.cpp +++ b/services/tota/tota_test.cpp @@ -14,39 +14,40 @@ * ****************************************************************************/ -#include +#include "app_tota.h" #include "app_tota_cmd_code.h" #include "app_tota_data_handler.h" +#include "app_tota_flash_program.h" #include "app_utils.h" #include "cmsis_os.h" -#include "tota_buffer_manager.h" -#include "string.h" -#include "tota_stream_data_transfer.h" -#include "stdio.h" -#include "stdarg.h" -#include "app_tota_flash_program.h" #include "crc32.h" -#include "app_tota.h" +#include "stdarg.h" +#include "stdio.h" +#include "string.h" +#include "tota_buffer_manager.h" +#include "tota_stream_data_transfer.h" +#include uint8_t flash_wbuf[] = "hello"; -static void tota_test_cmd(APP_TOTA_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - tota_printf("this is cmd test\r\n"); - tota_printf("hello1\r\n"); - tota_printf("hello2\r\n"); - tota_printf("hello3\r\n"); - tota_printf("hello4\r\n"); - tota_printf("will write data to flash"); - test_aes_encode_decode(); - tota_write_flash_test(TOTA_FLASH_TEST_ADDR, flash_wbuf, strlen((char*)flash_wbuf)); +static void tota_test_cmd(APP_TOTA_CMD_CODE_E funcCode, uint8_t *ptrParam, + uint32_t paramLen) { + tota_printf("this is cmd test\r\n"); + tota_printf("hello1\r\n"); + tota_printf("hello2\r\n"); + tota_printf("hello3\r\n"); + tota_printf("hello4\r\n"); + tota_printf("will write data to flash"); + test_aes_encode_decode(); + tota_write_flash_test(TOTA_FLASH_TEST_ADDR, flash_wbuf, + strlen((char *)flash_wbuf)); } -static void tota_echo_test_cmd(APP_TOTA_CMD_CODE_E funcCode, uint8_t* ptrParam, uint32_t paramLen) -{ - tota_printf("echo: \r\n"); - app_tota_send_data_via_spp(ptrParam, paramLen); +static void tota_echo_test_cmd(APP_TOTA_CMD_CODE_E funcCode, uint8_t *ptrParam, + uint32_t paramLen) { + tota_printf("echo: \r\n"); + app_tota_send_data_via_spp(ptrParam, paramLen); } -TOTA_COMMAND_TO_ADD(OP_TOTA_ECHO_TEST_CMD, tota_echo_test_cmd, false, 0, NULL ); -TOTA_COMMAND_TO_ADD(OP_TOTA_TEST_CMD, tota_test_cmd, false, 0, NULL ); +TOTA_COMMAND_TO_ADD(OP_TOTA_ECHO_TEST_CMD, tota_echo_test_cmd, false, 0, NULL); +TOTA_COMMAND_TO_ADD(OP_TOTA_TEST_CMD, tota_test_cmd, false, 0, NULL); diff --git a/tests/anc_usb/adda_loop_app.c b/tests/anc_usb/adda_loop_app.c index 066576b..4972a92 100644 --- a/tests/anc_usb/adda_loop_app.c +++ b/tests/anc_usb/adda_loop_app.c @@ -13,36 +13,40 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "adda_loop_app.h" +#include "audioflinger.h" +#include "hal_aud.h" +#include "hal_sysfreq.h" #include "hal_timer.h" #include "hal_trace.h" -#include "hal_sysfreq.h" -#include "hal_aud.h" -#include "tgt_hardware.h" #include "string.h" -#include "audioflinger.h" -#include "adda_loop_app.h" +#include "tgt_hardware.h" -#define ADDA_SAMPLE_RATE 48000 -#define ADDA_SAMPLE_SIZE 2 +#define ADDA_SAMPLE_RATE 48000 +#define ADDA_SAMPLE_SIZE 2 -#define ADDA_PLAYBACK_CHAN 2 -#define ADDA_CAPTURE_CHAN 2 +#define ADDA_PLAYBACK_CHAN 2 +#define ADDA_CAPTURE_CHAN 2 -#define RATE_TO_SIZE(n) (((n) + (1000 - 1)) / 1000) +#define RATE_TO_SIZE(n) (((n) + (1000 - 1)) / 1000) -#define ADDA_PLAYBACK_FRAME_SIZE (RATE_TO_SIZE(ADDA_SAMPLE_RATE) * ADDA_SAMPLE_SIZE * ADDA_PLAYBACK_CHAN) -#define ADDA_CAPTURE_FRAME_SIZE (RATE_TO_SIZE(ADDA_SAMPLE_RATE) * ADDA_SAMPLE_SIZE * ADDA_CAPTURE_CHAN) +#define ADDA_PLAYBACK_FRAME_SIZE \ + (RATE_TO_SIZE(ADDA_SAMPLE_RATE) * ADDA_SAMPLE_SIZE * ADDA_PLAYBACK_CHAN) +#define ADDA_CAPTURE_FRAME_SIZE \ + (RATE_TO_SIZE(ADDA_SAMPLE_RATE) * ADDA_SAMPLE_SIZE * ADDA_CAPTURE_CHAN) -#define PLAYBACK_FRAME_NUM 4 -#define CAPTURE_FRAME_NUM 8 +#define PLAYBACK_FRAME_NUM 4 +#define CAPTURE_FRAME_NUM 8 -#define ADDA_NON_EXP_ALIGN(val, exp) (((val) + ((exp) - 1)) / (exp) * (exp)) -#define BUFF_ALIGN (4 * 4) +#define ADDA_NON_EXP_ALIGN(val, exp) (((val) + ((exp)-1)) / (exp) * (exp)) +#define BUFF_ALIGN (4 * 4) -#define PLAYBACK_SIZE ADDA_NON_EXP_ALIGN(ADDA_PLAYBACK_FRAME_SIZE * PLAYBACK_FRAME_NUM, BUFF_ALIGN) -#define CAPTURE_SIZE ADDA_NON_EXP_ALIGN(ADDA_CAPTURE_FRAME_SIZE * CAPTURE_FRAME_NUM, BUFF_ALIGN) +#define PLAYBACK_SIZE \ + ADDA_NON_EXP_ALIGN(ADDA_PLAYBACK_FRAME_SIZE *PLAYBACK_FRAME_NUM, BUFF_ALIGN) +#define CAPTURE_SIZE \ + ADDA_NON_EXP_ALIGN(ADDA_CAPTURE_FRAME_SIZE *CAPTURE_FRAME_NUM, BUFF_ALIGN) -#define ALIGNED4 ALIGNED(4) +#define ALIGNED4 ALIGNED(4) static uint8_t ALIGNED4 adda_playback_buf[PLAYBACK_SIZE]; static uint8_t ALIGNED4 adda_capture_buf[CAPTURE_SIZE]; @@ -50,162 +54,157 @@ static uint8_t ALIGNED4 adda_capture_buf[CAPTURE_SIZE]; static uint32_t cap_rpos; static uint32_t cap_wpos; -static enum AUD_BITS_T sample_size_to_enum(uint32_t size) -{ - if (size == 2) { - return AUD_BITS_16; - } else if (size == 4) { - return AUD_BITS_24; - } else { - ASSERT(false, "%s: Invalid sample size: %u", __FUNCTION__, size); - } +static enum AUD_BITS_T sample_size_to_enum(uint32_t size) { + if (size == 2) { + return AUD_BITS_16; + } else if (size == 4) { + return AUD_BITS_24; + } else { + ASSERT(false, "%s: Invalid sample size: %u", __FUNCTION__, size); + } - return 0; + return 0; } -static enum AUD_CHANNEL_NUM_T chan_num_to_enum(uint32_t num) -{ - if (num == 2) { - return AUD_CHANNEL_NUM_2; - } else if (num == 1) { - return AUD_CHANNEL_NUM_1; - } else { - ASSERT(false, "%s: Invalid channel num: %u", __FUNCTION__, num); - } +static enum AUD_CHANNEL_NUM_T chan_num_to_enum(uint32_t num) { + if (num == 2) { + return AUD_CHANNEL_NUM_2; + } else if (num == 1) { + return AUD_CHANNEL_NUM_1; + } else { + ASSERT(false, "%s: Invalid channel num: %u", __FUNCTION__, num); + } - return 0; + return 0; } -static uint32_t adda_data_playback(uint8_t *buf, uint32_t len) -{ - uint32_t cur_time; - int16_t *src; - int16_t *dst; - int16_t *src_end; - int16_t *dst_end; - uint32_t avail; +static uint32_t adda_data_playback(uint8_t *buf, uint32_t len) { + uint32_t cur_time; + int16_t *src; + int16_t *dst; + int16_t *src_end; + int16_t *dst_end; + uint32_t avail; - cur_time = hal_sys_timer_get(); + cur_time = hal_sys_timer_get(); - if (cap_wpos >= cap_rpos) { - avail = cap_wpos - cap_rpos; - } else { - avail = sizeof(adda_capture_buf) + cap_wpos - cap_rpos; - } + if (cap_wpos >= cap_rpos) { + avail = cap_wpos - cap_rpos; + } else { + avail = sizeof(adda_capture_buf) + cap_wpos - cap_rpos; + } - if (avail * ADDA_PLAYBACK_CHAN / ADDA_CAPTURE_CHAN >= len) { - src = (int16_t *)(adda_capture_buf + cap_rpos); - src_end = (int16_t *)(adda_capture_buf + sizeof(adda_capture_buf)); - dst = (int16_t *)buf; - dst_end = (int16_t *)(buf + len); + if (avail * ADDA_PLAYBACK_CHAN / ADDA_CAPTURE_CHAN >= len) { + src = (int16_t *)(adda_capture_buf + cap_rpos); + src_end = (int16_t *)(adda_capture_buf + sizeof(adda_capture_buf)); + dst = (int16_t *)buf; + dst_end = (int16_t *)(buf + len); - while (dst < dst_end) { - *dst++ = *src++; - if (src == src_end) { - src = (int16_t *)adda_capture_buf; - } + while (dst < dst_end) { + *dst++ = *src++; + if (src == src_end) { + src = (int16_t *)adda_capture_buf; + } #if (ADDA_PLAYBACK_CHAN == 2) && (ADDA_CAPTURE_CHAN == 1) - *dst = *(dst - 1); - dst++; + *dst = *(dst - 1); + dst++; #endif - } - - cap_rpos = (uint32_t)src - (uint32_t)adda_capture_buf; - } else { - memset(buf, 0, len); } - TRACE(5,"[%X] playback: len=%4u wpos=%4u rpos=%4u avail=%4u", cur_time, len, cap_wpos, cap_rpos, avail); - return 0; + cap_rpos = (uint32_t)src - (uint32_t)adda_capture_buf; + } else { + memset(buf, 0, len); + } + + TRACE(5, "[%X] playback: len=%4u wpos=%4u rpos=%4u avail=%4u", cur_time, len, + cap_wpos, cap_rpos, avail); + return 0; } -static uint32_t adda_data_capture(uint8_t *buf, uint32_t len) -{ - uint32_t cur_time; +static uint32_t adda_data_capture(uint8_t *buf, uint32_t len) { + uint32_t cur_time; - cur_time = hal_sys_timer_get(); + cur_time = hal_sys_timer_get(); - cap_wpos += len; - if (cap_wpos >= sizeof(adda_capture_buf)) { - cap_wpos = 0; - } + cap_wpos += len; + if (cap_wpos >= sizeof(adda_capture_buf)) { + cap_wpos = 0; + } - TRACE(4,"[%X] capture : len=%4u wpos=%4u rpos=%4u", cur_time, len, cap_wpos, cap_rpos); - return 0; + TRACE(4, "[%X] capture : len=%4u wpos=%4u rpos=%4u", cur_time, len, cap_wpos, + cap_rpos); + return 0; } -static void adda_loop_start(void) -{ - int ret = 0; - struct AF_STREAM_CONFIG_T stream_cfg; +static void adda_loop_start(void) { + int ret = 0; + struct AF_STREAM_CONFIG_T stream_cfg; - hal_sysfreq_req(HAL_SYSFREQ_USER_APP_2, HAL_CMU_FREQ_52M); + hal_sysfreq_req(HAL_SYSFREQ_USER_APP_2, HAL_CMU_FREQ_52M); - memset(&stream_cfg, 0, sizeof(stream_cfg)); + memset(&stream_cfg, 0, sizeof(stream_cfg)); - stream_cfg.bits = sample_size_to_enum(ADDA_SAMPLE_SIZE); - stream_cfg.channel_num = chan_num_to_enum(ADDA_PLAYBACK_CHAN); - stream_cfg.sample_rate = ADDA_SAMPLE_RATE; - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; - stream_cfg.vol = AUDIO_OUTPUT_VOLUME_DEFAULT; - stream_cfg.handler = adda_data_playback; - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; - stream_cfg.data_ptr = adda_playback_buf; - stream_cfg.data_size = sizeof(adda_playback_buf); + stream_cfg.bits = sample_size_to_enum(ADDA_SAMPLE_SIZE); + stream_cfg.channel_num = chan_num_to_enum(ADDA_PLAYBACK_CHAN); + stream_cfg.sample_rate = ADDA_SAMPLE_RATE; + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; + stream_cfg.vol = AUDIO_OUTPUT_VOLUME_DEFAULT; + stream_cfg.handler = adda_data_playback; + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; + stream_cfg.data_ptr = adda_playback_buf; + stream_cfg.data_size = sizeof(adda_playback_buf); - TRACE(3,"[%s] playback sample_rate: %d, bits = %d", __func__, stream_cfg.sample_rate, stream_cfg.bits); + TRACE(3, "[%s] playback sample_rate: %d, bits = %d", __func__, + stream_cfg.sample_rate, stream_cfg.bits); - ret = af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); - ASSERT(ret == 0, "af_stream_open playback failed: %d", ret); + ret = af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); + ASSERT(ret == 0, "af_stream_open playback failed: %d", ret); - memset(&stream_cfg, 0, sizeof(stream_cfg)); + memset(&stream_cfg, 0, sizeof(stream_cfg)); - stream_cfg.bits = sample_size_to_enum(ADDA_SAMPLE_SIZE); - stream_cfg.channel_num = chan_num_to_enum(ADDA_CAPTURE_CHAN); - stream_cfg.sample_rate = ADDA_SAMPLE_RATE; - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; - stream_cfg.vol = CODEC_SADC_VOL; - stream_cfg.handler = adda_data_capture; - stream_cfg.io_path = AUD_INPUT_PATH_MAINMIC; - stream_cfg.data_ptr = adda_capture_buf; - stream_cfg.data_size = sizeof(adda_capture_buf); + stream_cfg.bits = sample_size_to_enum(ADDA_SAMPLE_SIZE); + stream_cfg.channel_num = chan_num_to_enum(ADDA_CAPTURE_CHAN); + stream_cfg.sample_rate = ADDA_SAMPLE_RATE; + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; + stream_cfg.vol = CODEC_SADC_VOL; + stream_cfg.handler = adda_data_capture; + stream_cfg.io_path = AUD_INPUT_PATH_MAINMIC; + stream_cfg.data_ptr = adda_capture_buf; + stream_cfg.data_size = sizeof(adda_capture_buf); - TRACE(3,"[%s] capture sample_rate: %d, bits = %d", __func__, stream_cfg.sample_rate, stream_cfg.bits); + TRACE(3, "[%s] capture sample_rate: %d, bits = %d", __func__, + stream_cfg.sample_rate, stream_cfg.bits); - ret = af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); - ASSERT(ret == 0, "af_stream_open catpure failed: %d", ret); + ret = af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); + ASSERT(ret == 0, "af_stream_open catpure failed: %d", ret); - ret = af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - ASSERT(ret == 0, "af_stream_start playback failed: %d", ret); + ret = af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + ASSERT(ret == 0, "af_stream_start playback failed: %d", ret); - ret = af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - ASSERT(ret == 0, "af_stream_start catpure failed: %d", ret); + ret = af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + ASSERT(ret == 0, "af_stream_start catpure failed: %d", ret); } -static void adda_loop_stop(void) -{ - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); +static void adda_loop_stop(void) { + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - hal_sysfreq_req(HAL_SYSFREQ_USER_APP_2, HAL_CMU_FREQ_32K); + hal_sysfreq_req(HAL_SYSFREQ_USER_APP_2, HAL_CMU_FREQ_32K); } -void adda_loop_app(bool on) -{ - if (on) { - adda_loop_start(); - } else { - adda_loop_stop(); - } +void adda_loop_app(bool on) { + if (on) { + adda_loop_start(); + } else { + adda_loop_stop(); + } } -void adda_loop_app_loop(void) -{ +void adda_loop_app_loop(void) { #ifndef RTOS - extern void af_thread(void const *argument); - af_thread(NULL); + extern void af_thread(void const *argument); + af_thread(NULL); #endif } - diff --git a/tests/anc_usb/anc_usb_app.c b/tests/anc_usb/anc_usb_app.c index ce2b696..18157b5 100644 --- a/tests/anc_usb/anc_usb_app.c +++ b/tests/anc_usb/anc_usb_app.c @@ -13,8 +13,8 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "anc_process.h" #include "anc_usb_app.h" +#include "anc_process.h" #include "audioflinger.h" #include "cmsis.h" #include "hal_codec.h" @@ -24,33 +24,33 @@ #include "hal_trace.h" #include "hwtimer_list.h" #include "pmu.h" -#include "usb_audio_app.h" #include "tgt_hardware.h" +#include "usb_audio_app.h" #ifdef ANC_SWITCH_GPADC_CHAN #include "hal_gpadc.h" #endif -#define ANC_KEY_CPU_WAKE_USER HAL_CPU_WAKE_LOCK_USER_4 -#define ANC_STATE_CPU_WAKE_USER HAL_CPU_WAKE_LOCK_USER_5 +#define ANC_KEY_CPU_WAKE_USER HAL_CPU_WAKE_LOCK_USER_4 +#define ANC_STATE_CPU_WAKE_USER HAL_CPU_WAKE_LOCK_USER_5 #define ANC_FADE_IN_OUT -#define ANC_FADE_GAIN_STEP 1 +#define ANC_FADE_GAIN_STEP 1 #define ANC_MODE_SWITCH_WITHOUT_FADE #ifndef ANC_INIT_ON_TIMEOUT_MS #ifdef CHIP_BEST1000 -#define ANC_INIT_ON_TIMEOUT_MS 1200 +#define ANC_INIT_ON_TIMEOUT_MS 1200 #else -#define ANC_INIT_ON_TIMEOUT_MS 200 +#define ANC_INIT_ON_TIMEOUT_MS 200 #endif #endif #ifndef ANC_SHUTDOWN_TIMEOUT_MS -#define ANC_SHUTDOWN_TIMEOUT_MS 5000 +#define ANC_SHUTDOWN_TIMEOUT_MS 5000 #endif #ifndef ANC_SWITCH_CHECK_INTERVAL -#define ANC_SWITCH_CHECK_INTERVAL MS_TO_TICKS(500) +#define ANC_SWITCH_CHECK_INTERVAL MS_TO_TICKS(500) #endif #ifdef ANC_COEF_NUM @@ -58,35 +58,35 @@ #error "Invalid ANC_COEF_NUM configuration" #endif #else -#define ANC_COEF_NUM (1) +#define ANC_COEF_NUM (1) #endif -#define KEY_PROCESS_TIMER_INTERVAL (MS_TO_TICKS(1) / 2) -#define FADE_TIMER_INTERVAL (MS_TO_TICKS(1) / 2) +#define KEY_PROCESS_TIMER_INTERVAL (MS_TO_TICKS(1) / 2) +#define FADE_TIMER_INTERVAL (MS_TO_TICKS(1) / 2) enum ANC_STATUS_T { - ANC_STATUS_NULL = 0, - ANC_STATUS_INIT, - ANC_STATUS_FADEIN, - ANC_STATUS_ENABLE, - ANC_STATUS_FADEOUT, - ANC_STATUS_DISABLE, - ANC_STATUS_INIT_CLOSE, + ANC_STATUS_NULL = 0, + ANC_STATUS_INIT, + ANC_STATUS_FADEIN, + ANC_STATUS_ENABLE, + ANC_STATUS_FADEOUT, + ANC_STATUS_DISABLE, + ANC_STATUS_INIT_CLOSE, }; enum ANC_KEY_STATE_T { - ANC_KEY_STATE_NULL = 0, - ANC_KEY_STATE_CLOSE, - ANC_KEY_STATE_OPEN, - ANC_KEY_STATE_DEBOUNCE, + ANC_KEY_STATE_NULL = 0, + ANC_KEY_STATE_CLOSE, + ANC_KEY_STATE_OPEN, + ANC_KEY_STATE_DEBOUNCE, }; enum ANC_CTRL_SM_T { - ANC_CTRL_SM_OFF = 0, - ANC_CTRL_SM_COEF_0, - ANC_CTRL_SM_COEF_N = ANC_CTRL_SM_COEF_0 + ANC_COEF_NUM - 1, + ANC_CTRL_SM_OFF = 0, + ANC_CTRL_SM_COEF_0, + ANC_CTRL_SM_COEF_N = ANC_CTRL_SM_COEF_0 + ANC_COEF_NUM - 1, - ANC_CTRL_SM_QTY + ANC_CTRL_SM_QTY }; static enum ANC_STATUS_T anc_status = ANC_STATUS_NULL; @@ -107,7 +107,9 @@ static enum AUD_SAMPRATE_T anc_sample_rate[AUD_STREAM_NUM]; static bool anc_running = false; #ifdef ANC_SWITCH_GPIO_PIN -static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_anc = {ANC_SWITCH_GPIO_PIN, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}; +static const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_anc = { + ANC_SWITCH_GPIO_PIN, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_PULLUP_ENABLE}; static bool gpio_pending; static bool gpio_irq_en; static enum HAL_GPIO_IRQ_POLARITY_T gpio_irq_polarity; @@ -123,12 +125,14 @@ static uint32_t prev_fade_time = 0; #ifdef CFG_HW_ANC_LED_PIN const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_anc_led[] = { - {CFG_HW_ANC_LED_PIN, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_NOPULL}, + {CFG_HW_ANC_LED_PIN, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_NOPULL}, }; #endif #ifdef CFG_HW_ANC_LED_PIN2 const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_anc_led2[] = { - {CFG_HW_ANC_LED_PIN2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_NOPULL}, + {CFG_HW_ANC_LED_PIN2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_NOPULL}, }; #endif @@ -136,922 +140,908 @@ static void anc_full_open(void); static void anc_full_close(void); // ANC_FADE_IN_OUT -int anc_usb_app_fadein(enum ANC_TYPE_T anc_type) -{ +int anc_usb_app_fadein(enum ANC_TYPE_T anc_type) { + int32_t gain0_curr, gain1_curr; + int32_t gain0_tg, gain1_tg; - int32_t gain0_curr, gain1_curr; - int32_t gain0_tg, gain1_tg; + anc_get_gain(&gain0_curr, &gain1_curr, anc_type); + anc_get_cfg_gain(&gain0_tg, &gain1_tg, anc_type); - anc_get_gain(&gain0_curr, &gain1_curr,anc_type); - anc_get_cfg_gain(&gain0_tg, &gain1_tg,anc_type); + /* + anc_set_gain(gain0_tg, gain1_tg,anc_type); -/* - anc_set_gain(gain0_tg, gain1_tg,anc_type); + return 0; + */ + if (gain0_tg > 0) { + if (gain0_curr < gain0_tg) { + if (gain0_curr + ANC_FADE_GAIN_STEP < gain0_tg) { + gain0_curr += ANC_FADE_GAIN_STEP; + } else { + gain0_curr = gain0_tg; + } + } + } else { + if (gain0_curr > gain0_tg) { + if (gain0_curr - ANC_FADE_GAIN_STEP > gain0_tg) { + gain0_curr -= ANC_FADE_GAIN_STEP; + } else { + gain0_curr = gain0_tg; + } + } + } + if (gain1_tg > 0) { + if (gain1_curr < gain1_tg) { + if (gain1_curr + ANC_FADE_GAIN_STEP < gain1_tg) { + gain1_curr += ANC_FADE_GAIN_STEP; + } else { + gain1_curr = gain1_tg; + } + } + } else { + if (gain1_curr > gain1_tg) { + if (gain1_curr - ANC_FADE_GAIN_STEP > gain1_tg) { + gain1_curr -= ANC_FADE_GAIN_STEP; + } else { + gain1_curr = gain1_tg; + } + } + } + + // TRACE(3,"[%s] cur gain: %d %d", __func__, gain0_curr, gain1_curr); + anc_set_gain(gain0_curr, gain1_curr, anc_type); + + if ((gain0_curr == gain0_tg) && (gain1_curr == gain1_tg)) { return 0; -*/ - if (gain0_tg > 0) { - if (gain0_curr < gain0_tg) { - if (gain0_curr + ANC_FADE_GAIN_STEP < gain0_tg) { - gain0_curr += ANC_FADE_GAIN_STEP; - } else { - gain0_curr = gain0_tg; - } - } - } else { - if (gain0_curr > gain0_tg) { - if (gain0_curr - ANC_FADE_GAIN_STEP > gain0_tg) { - gain0_curr -= ANC_FADE_GAIN_STEP; - } else { - gain0_curr = gain0_tg; - } - } - } + } - if (gain1_tg > 0) { - if (gain1_curr < gain1_tg) { - if (gain1_curr + ANC_FADE_GAIN_STEP < gain1_tg) { - gain1_curr += ANC_FADE_GAIN_STEP; - } else { - gain1_curr = gain1_tg; - } - } - } else { - if (gain1_curr > gain1_tg) { - if (gain1_curr - ANC_FADE_GAIN_STEP > gain1_tg) { - gain1_curr -= ANC_FADE_GAIN_STEP; - } else { - gain1_curr = gain1_tg; - } - } - } - - //TRACE(3,"[%s] cur gain: %d %d", __func__, gain0_curr, gain1_curr); - anc_set_gain(gain0_curr, gain1_curr,anc_type); - - if ((gain0_curr == gain0_tg) && (gain1_curr == gain1_tg)) { - return 0; - } - - return 1; + return 1; } -int anc_usb_app_fadeout(enum ANC_TYPE_T anc_type) -{ +int anc_usb_app_fadeout(enum ANC_TYPE_T anc_type) { -/* - anc_set_gain(0, 0,anc_type); + /* + anc_set_gain(0, 0,anc_type); + return 0; + */ + + int32_t gain0_curr, gain1_curr; + + anc_get_gain(&gain0_curr, &gain1_curr, anc_type); + + if (gain0_curr > 0) { + if (gain0_curr > ANC_FADE_GAIN_STEP) { + gain0_curr -= ANC_FADE_GAIN_STEP; + } else { + gain0_curr = 0; + } + } else if (gain0_curr < 0) { + if (gain0_curr < -ANC_FADE_GAIN_STEP) { + gain0_curr += ANC_FADE_GAIN_STEP; + } else { + gain0_curr = 0; + } + } + + if (gain1_curr > 0) { + if (gain1_curr > ANC_FADE_GAIN_STEP) { + gain1_curr -= ANC_FADE_GAIN_STEP; + } else { + gain1_curr = 0; + } + } else if (gain1_curr < 0) { + if (gain1_curr < -ANC_FADE_GAIN_STEP) { + gain1_curr += ANC_FADE_GAIN_STEP; + } else { + gain1_curr = 0; + } + } + + // TRACE(3,"[%s] gain: %d, %d", __func__, gain0_curr, gain1_curr); + anc_set_gain(gain0_curr, gain1_curr, anc_type); + + if ((gain0_curr == 0) && (gain1_curr == 0)) { return 0; -*/ + } - int32_t gain0_curr, gain1_curr; - - anc_get_gain(&gain0_curr, &gain1_curr,anc_type); - - if (gain0_curr > 0) { - if (gain0_curr > ANC_FADE_GAIN_STEP) { - gain0_curr -= ANC_FADE_GAIN_STEP; - } else { - gain0_curr = 0; - } - } else if (gain0_curr < 0) { - if (gain0_curr < -ANC_FADE_GAIN_STEP) { - gain0_curr += ANC_FADE_GAIN_STEP; - } else { - gain0_curr = 0; - } - } - - if (gain1_curr > 0) { - if (gain1_curr > ANC_FADE_GAIN_STEP) { - gain1_curr -= ANC_FADE_GAIN_STEP; - } else { - gain1_curr = 0; - } - } else if (gain1_curr < 0) { - if (gain1_curr < -ANC_FADE_GAIN_STEP) { - gain1_curr += ANC_FADE_GAIN_STEP; - } else { - gain1_curr = 0; - } - } - - // TRACE(3,"[%s] gain: %d, %d", __func__, gain0_curr, gain1_curr); - anc_set_gain(gain0_curr, gain1_curr,anc_type); - - if ((gain0_curr == 0) && (gain1_curr == 0)) { - return 0; - } - - return 1; + return 1; } -void anc_usb_app(bool on) -{ - TRACE(2,"%s: on=%d", __func__, on); +void anc_usb_app(bool on) { + TRACE(2, "%s: on=%d", __func__, on); - if (anc_running==on) - return; - else - anc_running=on; + if (anc_running == on) + return; + else + anc_running = on; - if (on) { - anc_enable(); - } else { - anc_disable(); - } + if (on) { + anc_enable(); + } else { + anc_disable(); + } #ifdef CFG_HW_ANC_LED_PIN - if (on) { - hal_gpio_pin_set(CFG_HW_ANC_LED_PIN); - } else { - hal_gpio_pin_clr(CFG_HW_ANC_LED_PIN); - } + if (on) { + hal_gpio_pin_set(CFG_HW_ANC_LED_PIN); + } else { + hal_gpio_pin_clr(CFG_HW_ANC_LED_PIN); + } #endif #ifdef CFG_HW_ANC_LED_PIN2 - if (on) { - hal_gpio_pin_set(CFG_HW_ANC_LED_PIN2); - } else { - hal_gpio_pin_clr(CFG_HW_ANC_LED_PIN2); - } + if (on) { + hal_gpio_pin_set(CFG_HW_ANC_LED_PIN2); + } else { + hal_gpio_pin_clr(CFG_HW_ANC_LED_PIN2); + } #endif } -bool anc_usb_app_get_status() -{ - return anc_running; -} +bool anc_usb_app_get_status() { return anc_running; } #ifdef ANC_SWITCH_GPIO_PIN -static void anc_key_gpio_handler(enum HAL_GPIO_PIN_T pin) -{ - struct HAL_GPIO_IRQ_CFG_T gpiocfg; +static void anc_key_gpio_handler(enum HAL_GPIO_PIN_T pin) { + struct HAL_GPIO_IRQ_CFG_T gpiocfg; - gpiocfg.irq_enable = false; - hal_gpio_setup_irq((enum HAL_GPIO_PIN_T)pinmux_anc.pin, &gpiocfg); + gpiocfg.irq_enable = false; + hal_gpio_setup_irq((enum HAL_GPIO_PIN_T)pinmux_anc.pin, &gpiocfg); - gpio_irq_en = false; - gpio_pending = true; + gpio_irq_en = false; + gpio_pending = true; - hal_cpu_wake_lock(ANC_KEY_CPU_WAKE_USER); + hal_cpu_wake_lock(ANC_KEY_CPU_WAKE_USER); } -static void anc_key_gpio_irq_setup(enum HAL_GPIO_IRQ_POLARITY_T polarity) -{ - struct HAL_GPIO_IRQ_CFG_T gpiocfg; +static void anc_key_gpio_irq_setup(enum HAL_GPIO_IRQ_POLARITY_T polarity) { + struct HAL_GPIO_IRQ_CFG_T gpiocfg; - if (gpio_irq_en && gpio_irq_polarity == polarity) { - return; - } + if (gpio_irq_en && gpio_irq_polarity == polarity) { + return; + } - gpio_irq_polarity = polarity; - gpio_irq_en = true; + gpio_irq_polarity = polarity; + gpio_irq_en = true; - gpiocfg.irq_enable = true; - gpiocfg.irq_debounce = true; - gpiocfg.irq_polarity = polarity; - gpiocfg.irq_handler = anc_key_gpio_handler; - gpiocfg.irq_type = HAL_GPIO_IRQ_TYPE_LEVEL_SENSITIVE; + gpiocfg.irq_enable = true; + gpiocfg.irq_debounce = true; + gpiocfg.irq_polarity = polarity; + gpiocfg.irq_handler = anc_key_gpio_handler; + gpiocfg.irq_type = HAL_GPIO_IRQ_TYPE_LEVEL_SENSITIVE; - hal_gpio_setup_irq((enum HAL_GPIO_PIN_T)pinmux_anc.pin, &gpiocfg); + hal_gpio_setup_irq((enum HAL_GPIO_PIN_T)pinmux_anc.pin, &gpiocfg); } #endif -static enum ANC_KEY_STATE_T anc_key_level_to_state(bool level) -{ - enum ANC_KEY_STATE_T key_state; +static enum ANC_KEY_STATE_T anc_key_level_to_state(bool level) { + enum ANC_KEY_STATE_T key_state; #ifdef ANC_SWITCH_GPIO_PIN - anc_key_gpio_irq_setup(level ? HAL_GPIO_IRQ_POLARITY_LOW_FALLING : HAL_GPIO_IRQ_POLARITY_HIGH_RISING); + anc_key_gpio_irq_setup(level ? HAL_GPIO_IRQ_POLARITY_LOW_FALLING + : HAL_GPIO_IRQ_POLARITY_HIGH_RISING); #endif - key_state = level ? ANC_KEY_STATE_OPEN : ANC_KEY_STATE_CLOSE; + key_state = level ? ANC_KEY_STATE_OPEN : ANC_KEY_STATE_CLOSE; - return key_state; + return key_state; } -enum ANC_KEY_STATE_T anc_key_get_state(bool init_state) -{ - enum ANC_KEY_STATE_T key_state = ANC_KEY_STATE_NULL; - uint8_t level; +enum ANC_KEY_STATE_T anc_key_get_state(bool init_state) { + enum ANC_KEY_STATE_T key_state = ANC_KEY_STATE_NULL; + uint8_t level; #if defined(ANC_SWITCH_GPIO_PIN) - level = hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)pinmux_anc.pin); + level = hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)pinmux_anc.pin); - level = level ? true : false; + level = level ? true : false; #elif defined(ANC_SWITCH_GPADC_CHAN) - HAL_GPADC_MV_T volt = 0; + HAL_GPADC_MV_T volt = 0; - if (hal_gpadc_get_volt(ANC_SWITCH_GPADC_CHAN, &volt)) { - level = volt > ANC_SWITCH_VOLTAGE_THRESHOLD ? ANC_SWITCH_LEVEL_HIGH : ANC_SWITCH_LEVEL_LOW; - // TRACE(3,"[%s] level = %d, volt = %d", __func__, level, volt); - } else { - // TRACE(1,"[%s] else...", __func__); - return ANC_KEY_STATE_NULL; - } + if (hal_gpadc_get_volt(ANC_SWITCH_GPADC_CHAN, &volt)) { + level = volt > ANC_SWITCH_VOLTAGE_THRESHOLD ? ANC_SWITCH_LEVEL_HIGH + : ANC_SWITCH_LEVEL_LOW; + // TRACE(3,"[%s] level = %d, volt = %d", __func__, level, volt); + } else { + // TRACE(1,"[%s] else...", __func__); + return ANC_KEY_STATE_NULL; + } #else - return key_state; + return key_state; #endif - static uint32_t s_time; - static bool key_trigger = false; - static bool key_level = false; + static uint32_t s_time; + static bool key_trigger = false; + static bool key_level = false; - if (init_state) { + if (init_state) { + key_level = level; + return anc_key_level_to_state(level); + } + + if (key_trigger) { + if (key_level == level) { + key_trigger = false; + } else { + uint32_t diff_time_ms; + + diff_time_ms = TICKS_TO_MS(hal_sys_timer_get() - s_time); + + if (diff_time_ms >= 200) { key_level = level; - return anc_key_level_to_state(level); + key_trigger = false; + } } - - if (key_trigger) { - if (key_level == level) { - key_trigger = false; - } else { - uint32_t diff_time_ms; - - diff_time_ms = TICKS_TO_MS(hal_sys_timer_get() - s_time); - - if(diff_time_ms >= 200) { - key_level = level; - key_trigger = false; - } - } - } else { - if (key_level != level) { - s_time = hal_sys_timer_get(); - key_trigger = true; - } + } else { + if (key_level != level) { + s_time = hal_sys_timer_get(); + key_trigger = true; } + } - if (key_trigger) { - key_state = ANC_KEY_STATE_DEBOUNCE; - } else { - key_state = anc_key_level_to_state(level); - } + if (key_trigger) { + key_state = ANC_KEY_STATE_DEBOUNCE; + } else { + key_state = anc_key_level_to_state(level); + } - return key_state; + return key_state; } -static void anc_key_proc_open(bool from_key) -{ - int POSSIBLY_UNUSED ret; - uint32_t POSSIBLY_UNUSED time; +static void anc_key_proc_open(bool from_key) { + int POSSIBLY_UNUSED ret; + uint32_t POSSIBLY_UNUSED time; - time = hal_sys_timer_get(); + time = hal_sys_timer_get(); - if (anc_status == ANC_STATUS_INIT_CLOSE) { - TRACE(1,"[ANC KEY PROC] ANC INIT_CLOSE => INIT T:%u", time); + if (anc_status == ANC_STATUS_INIT_CLOSE) { + TRACE(1, "[ANC KEY PROC] ANC INIT_CLOSE => INIT T:%u", time); - anc_status = ANC_STATUS_INIT; - } else if (anc_status == ANC_STATUS_NULL) { - TRACE(1,"[ANC KEY PROC] ANC NULL => INIT T:%u", time); + anc_status = ANC_STATUS_INIT; + } else if (anc_status == ANC_STATUS_NULL) { + TRACE(1, "[ANC KEY PROC] ANC NULL => INIT T:%u", time); - anc_full_open(); + anc_full_open(); #ifdef ANC_MODE_SWITCH_WITHOUT_FADE - } else if (anc_status == ANC_STATUS_ENABLE) { + } else if (anc_status == ANC_STATUS_ENABLE) { #ifdef ANC_FF_ENABLED - ret = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],cur_coef_index,ANC_FEEDFORWARD,ANC_GAIN_NO_DELAY); - TRACE(2,"[ANC KEY PROC] updata coefs ff %d: ret=%d", cur_coef_index, ret); + ret = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], cur_coef_index, + ANC_FEEDFORWARD, ANC_GAIN_NO_DELAY); + TRACE(2, "[ANC KEY PROC] updata coefs ff %d: ret=%d", cur_coef_index, ret); #endif #ifdef ANC_FB_ENABLED - ret = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],cur_coef_index,ANC_FEEDBACK,ANC_GAIN_NO_DELAY); - TRACE(2,"[ANC KEY PROC] updata coefs fb %d: ret=%d", cur_coef_index, ret); + ret = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], cur_coef_index, + ANC_FEEDBACK, ANC_GAIN_NO_DELAY); + TRACE(2, "[ANC KEY PROC] updata coefs fb %d: ret=%d", cur_coef_index, ret); #endif #if defined(AUDIO_ANC_FB_MC_HW) - ret = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],cur_coef_index, ANC_MUSICCANCLE, ANC_GAIN_NO_DELAY); - TRACE(2,"[ANC KEY PROC] anc_select_coef mc %d: ret=%d", cur_coef_index, ret); + ret = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], cur_coef_index, + ANC_MUSICCANCLE, ANC_GAIN_NO_DELAY); + TRACE(2, "[ANC KEY PROC] anc_select_coef mc %d: ret=%d", cur_coef_index, + ret); #endif #if defined(AUDIO_ANC_TT_HW) - ret = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],cur_coef_index, ANC_TALKTHRU, ANC_GAIN_NO_DELAY); - TRACE(2,"[ANC KEY PROC] anc_select_coef tt %d: ret=%d", cur_coef_index, ret); + ret = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], cur_coef_index, + ANC_TALKTHRU, ANC_GAIN_NO_DELAY); + TRACE(2, "[ANC KEY PROC] anc_select_coef tt %d: ret=%d", cur_coef_index, + ret); #endif #endif - }else{ - if (from_key && anc_status == ANC_STATUS_INIT) { - TRACE(1,"[ANC KEY PROC] ANC ON2 T:%u", time); - // Let state machine enable ANC - return; - } + } else { + if (from_key && anc_status == ANC_STATUS_INIT) { + TRACE(1, "[ANC KEY PROC] ANC ON2 T:%u", time); + // Let state machine enable ANC + return; + } - TRACE(1,"[ANC KEY PROC] ANC ON T:%u", time); + TRACE(1, "[ANC KEY PROC] ANC ON T:%u", time); #ifdef ANC_FF_ENABLED - ret = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],cur_coef_index,ANC_FEEDFORWARD,ANC_GAIN_DELAY); - TRACE(2,"[ANC KEY PROC] anc_select_coef ff %d: ret=%d", cur_coef_index, ret); + ret = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], cur_coef_index, + ANC_FEEDFORWARD, ANC_GAIN_DELAY); + TRACE(2, "[ANC KEY PROC] anc_select_coef ff %d: ret=%d", cur_coef_index, + ret); #endif #ifdef ANC_FB_ENABLED - ret = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],cur_coef_index,ANC_FEEDBACK,ANC_GAIN_DELAY); - TRACE(2,"[ANC KEY PROC] anc_select_coef fb %d: ret=%d", cur_coef_index, ret); + ret = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], cur_coef_index, + ANC_FEEDBACK, ANC_GAIN_DELAY); + TRACE(2, "[ANC KEY PROC] anc_select_coef fb %d: ret=%d", cur_coef_index, + ret); #endif #if defined(AUDIO_ANC_FB_MC_HW) - ret = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],cur_coef_index, ANC_MUSICCANCLE, ANC_GAIN_DELAY); - TRACE(2,"[ANC KEY PROC] anc_select_coef mc %d: ret=%d", cur_coef_index, ret); + ret = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], cur_coef_index, + ANC_MUSICCANCLE, ANC_GAIN_DELAY); + TRACE(2, "[ANC KEY PROC] anc_select_coef mc %d: ret=%d", cur_coef_index, + ret); #endif #if defined(AUDIO_ANC_TT_HW) - ret = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK],cur_coef_index, ANC_TALKTHRU, ANC_GAIN_DELAY); - TRACE(2,"[ANC KEY PROC] anc_select_coef tt %d: ret=%d", cur_coef_index, ret); + ret = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], cur_coef_index, + ANC_TALKTHRU, ANC_GAIN_DELAY); + TRACE(2, "[ANC KEY PROC] anc_select_coef tt %d: ret=%d", cur_coef_index, + ret); #endif - anc_usb_app(true); + anc_usb_app(true); #ifdef ANC_FADE_IN_OUT - fadein_cnt = 0; - anc_status = ANC_STATUS_FADEIN; + fadein_cnt = 0; + anc_status = ANC_STATUS_FADEIN; #else - { - int32_t gain_ch_l, gain_ch_r; + { + int32_t gain_ch_l, gain_ch_r; #if defined(AUDIO_ANC_TT_HW) - anc_get_cfg_gain(&gain_ch_l, &gain_ch_r,ANC_TALKTHRU); - anc_set_gain(gain_ch_l,gain_ch_r,ANC_TALKTHRU); + anc_get_cfg_gain(&gain_ch_l, &gain_ch_r, ANC_TALKTHRU); + anc_set_gain(gain_ch_l, gain_ch_r, ANC_TALKTHRU); #endif #ifdef ANC_FF_ENABLED - anc_get_cfg_gain(&gain_ch_l, &gain_ch_r,ANC_FEEDFORWARD); - anc_set_gain(gain_ch_l,gain_ch_r,ANC_FEEDFORWARD); + anc_get_cfg_gain(&gain_ch_l, &gain_ch_r, ANC_FEEDFORWARD); + anc_set_gain(gain_ch_l, gain_ch_r, ANC_FEEDFORWARD); #endif #ifdef ANC_FB_ENABLED - anc_get_cfg_gain(&gain_ch_l, &gain_ch_r,ANC_FEEDBACK); - anc_set_gain(gain_ch_l,gain_ch_r,ANC_FEEDBACK); + anc_get_cfg_gain(&gain_ch_l, &gain_ch_r, ANC_FEEDBACK); + anc_set_gain(gain_ch_l, gain_ch_r, ANC_FEEDBACK); #endif #ifdef AUDIO_ANC_FB_MC_HW - anc_get_cfg_gain(&gain_ch_l, &gain_ch_r,ANC_MUSICCANCLE); - anc_set_gain(gain_ch_l,gain_ch_r,ANC_MUSICCANCLE); -#endif - } - anc_status = ANC_STATUS_ENABLE; + anc_get_cfg_gain(&gain_ch_l, &gain_ch_r, ANC_MUSICCANCLE); + anc_set_gain(gain_ch_l, gain_ch_r, ANC_MUSICCANCLE); #endif } + anc_status = ANC_STATUS_ENABLE; +#endif + } } -static void anc_key_proc_close(bool from_key) -{ - uint32_t time; +static void anc_key_proc_close(bool from_key) { + uint32_t time; - time = hal_sys_timer_get(); - anc_close_time = time; + time = hal_sys_timer_get(); + anc_close_time = time; - if (anc_status == ANC_STATUS_INIT) { - TRACE(1,"[ANC KEY PROC] ANC INIT => INIT_CLOSE T:%u", time); + if (anc_status == ANC_STATUS_INIT) { + TRACE(1, "[ANC KEY PROC] ANC INIT => INIT_CLOSE T:%u", time); - anc_status = ANC_STATUS_INIT_CLOSE; - } else if (anc_status == ANC_STATUS_INIT_CLOSE || anc_status == ANC_STATUS_DISABLE) { - if (from_key) { - TRACE(1,"[ANC KEY PROC] ANC OFF2 T:%u", time); - // Let state machine to shutdown ANC - return; - } + anc_status = ANC_STATUS_INIT_CLOSE; + } else if (anc_status == ANC_STATUS_INIT_CLOSE || + anc_status == ANC_STATUS_DISABLE) { + if (from_key) { + TRACE(1, "[ANC KEY PROC] ANC OFF2 T:%u", time); + // Let state machine to shutdown ANC + return; + } - TRACE(1,"[ANC KEY PROC] ANC CLOSE => NULL T:%u", time); + TRACE(1, "[ANC KEY PROC] ANC CLOSE => NULL T:%u", time); - anc_full_close(); - } else { - TRACE(1,"[ANC KEY PROC] ANC OFF T:%u", time); + anc_full_close(); + } else { + TRACE(1, "[ANC KEY PROC] ANC OFF T:%u", time); #ifdef ANC_FADE_IN_OUT - fadeout_cnt = 0; - anc_status = ANC_STATUS_FADEOUT; + fadeout_cnt = 0; + anc_status = ANC_STATUS_FADEOUT; #else - anc_usb_app(false); - anc_status = ANC_STATUS_DISABLE; + anc_usb_app(false); + anc_status = ANC_STATUS_DISABLE; #endif - } + } } -void anc_switch_on_off_ctrl(void) -{ - uint32_t lock; - enum ANC_KEY_STATE_T key_state = ANC_KEY_STATE_NULL; +void anc_switch_on_off_ctrl(void) { + uint32_t lock; + enum ANC_KEY_STATE_T key_state = ANC_KEY_STATE_NULL; - lock = int_lock(); - // Check if there is a state change - if (anc_key_event != HAL_KEY_EVENT_NONE) { - key_state = prev_key_state; - anc_key_event = HAL_KEY_EVENT_NONE; - } - int_unlock(lock); - - if(key_state == ANC_KEY_STATE_OPEN) { - anc_key_proc_open(true); - } else if(key_state == ANC_KEY_STATE_CLOSE) { - anc_key_proc_close(true); - } -} - -void anc_double_click_on_off(void) -{ - uint32_t lock; - enum HAL_KEY_EVENT_T event; - - lock = int_lock(); - event = anc_key_event; + lock = int_lock(); + // Check if there is a state change + if (anc_key_event != HAL_KEY_EVENT_NONE) { + key_state = prev_key_state; anc_key_event = HAL_KEY_EVENT_NONE; - hal_cpu_wake_unlock(ANC_KEY_CPU_WAKE_USER); - int_unlock(lock); + } + int_unlock(lock); - if (event == HAL_KEY_EVENT_NONE) { - return; - } else if (event == HAL_KEY_EVENT_DOUBLECLICK) { - prev_key_state = (prev_key_state == ANC_KEY_STATE_OPEN) ? ANC_KEY_STATE_CLOSE : ANC_KEY_STATE_OPEN; - if (prev_key_state == ANC_KEY_STATE_OPEN) { - anc_key_proc_open(true); - } else { - anc_key_proc_close(true); - } - } + if (key_state == ANC_KEY_STATE_OPEN) { + anc_key_proc_open(true); + } else if (key_state == ANC_KEY_STATE_CLOSE) { + anc_key_proc_close(true); + } } -void anc_click_on_off(void) -{ - enum ANC_STATE_UPDATE_T { - ANC_STATE_UPDATE_NULL = 0, - ANC_STATE_UPDATE_TALK_THROUGH, - ANC_STATE_UPDATE_COEF, - }; +void anc_double_click_on_off(void) { + uint32_t lock; + enum HAL_KEY_EVENT_T event; - enum HAL_KEY_EVENT_T event; - enum ANC_STATE_UPDATE_T state_update = ANC_STATE_UPDATE_NULL; - uint8_t click_cnt = 0; - uint32_t lock; + lock = int_lock(); + event = anc_key_event; + anc_key_event = HAL_KEY_EVENT_NONE; + hal_cpu_wake_unlock(ANC_KEY_CPU_WAKE_USER); + int_unlock(lock); - lock = int_lock(); - event = anc_key_event; - anc_key_event = HAL_KEY_EVENT_NONE; - hal_cpu_wake_unlock(ANC_KEY_CPU_WAKE_USER); - int_unlock(lock); - - if (event == HAL_KEY_EVENT_NONE) { - return; -#ifdef ANC_TALK_THROUGH - } else if (event == HAL_KEY_EVENT_LONGPRESS) { - talk_through = !talk_through; - if (talk_through) { - state_update = ANC_STATE_UPDATE_TALK_THROUGH; - cur_coef_index = ANC_COEF_NUM; - TRACE(0,"[ANC KEY PROC] anc_talk_through on"); - } else { - state_update = ANC_STATE_UPDATE_COEF; - TRACE(0,"[ANC KEY PROC] anc_talk_through off"); - } -#endif - } else if (event == HAL_KEY_EVENT_CLICK) { - click_cnt = 1; - } if (event == HAL_KEY_EVENT_DOUBLECLICK) { - click_cnt = 2; - } if (event == HAL_KEY_EVENT_TRIPLECLICK) { - click_cnt = 3; - } - - if (click_cnt > 0) { - anc_ctrl_sm = (anc_ctrl_sm + click_cnt) % ANC_CTRL_SM_QTY; - state_update = ANC_STATE_UPDATE_COEF; -#ifdef ANC_TALK_THROUGH - talk_through = false; -#endif - } - - if (state_update == ANC_STATE_UPDATE_COEF) { - if (anc_ctrl_sm >= ANC_CTRL_SM_COEF_0 && anc_ctrl_sm <= ANC_CTRL_SM_COEF_N) { - cur_coef_index = anc_ctrl_sm - ANC_CTRL_SM_COEF_0; - } - } - - if (state_update != ANC_STATE_UPDATE_NULL) { - if (anc_ctrl_sm == ANC_CTRL_SM_OFF && state_update != ANC_STATE_UPDATE_TALK_THROUGH) { - anc_key_proc_close(true); - } else { - anc_key_proc_open(true); - } + if (event == HAL_KEY_EVENT_NONE) { + return; + } else if (event == HAL_KEY_EVENT_DOUBLECLICK) { + prev_key_state = (prev_key_state == ANC_KEY_STATE_OPEN) + ? ANC_KEY_STATE_CLOSE + : ANC_KEY_STATE_OPEN; + if (prev_key_state == ANC_KEY_STATE_OPEN) { + anc_key_proc_open(true); + } else { + anc_key_proc_close(true); } + } } -static void anc_key_process(void) -{ +void anc_click_on_off(void) { + enum ANC_STATE_UPDATE_T { + ANC_STATE_UPDATE_NULL = 0, + ANC_STATE_UPDATE_TALK_THROUGH, + ANC_STATE_UPDATE_COEF, + }; + + enum HAL_KEY_EVENT_T event; + enum ANC_STATE_UPDATE_T state_update = ANC_STATE_UPDATE_NULL; + uint8_t click_cnt = 0; + uint32_t lock; + + lock = int_lock(); + event = anc_key_event; + anc_key_event = HAL_KEY_EVENT_NONE; + hal_cpu_wake_unlock(ANC_KEY_CPU_WAKE_USER); + int_unlock(lock); + + if (event == HAL_KEY_EVENT_NONE) { + return; +#ifdef ANC_TALK_THROUGH + } else if (event == HAL_KEY_EVENT_LONGPRESS) { + talk_through = !talk_through; + if (talk_through) { + state_update = ANC_STATE_UPDATE_TALK_THROUGH; + cur_coef_index = ANC_COEF_NUM; + TRACE(0, "[ANC KEY PROC] anc_talk_through on"); + } else { + state_update = ANC_STATE_UPDATE_COEF; + TRACE(0, "[ANC KEY PROC] anc_talk_through off"); + } +#endif + } else if (event == HAL_KEY_EVENT_CLICK) { + click_cnt = 1; + } + if (event == HAL_KEY_EVENT_DOUBLECLICK) { + click_cnt = 2; + } + if (event == HAL_KEY_EVENT_TRIPLECLICK) { + click_cnt = 3; + } + + if (click_cnt > 0) { + anc_ctrl_sm = (anc_ctrl_sm + click_cnt) % ANC_CTRL_SM_QTY; + state_update = ANC_STATE_UPDATE_COEF; +#ifdef ANC_TALK_THROUGH + talk_through = false; +#endif + } + + if (state_update == ANC_STATE_UPDATE_COEF) { + if (anc_ctrl_sm >= ANC_CTRL_SM_COEF_0 && + anc_ctrl_sm <= ANC_CTRL_SM_COEF_N) { + cur_coef_index = anc_ctrl_sm - ANC_CTRL_SM_COEF_0; + } + } + + if (state_update != ANC_STATE_UPDATE_NULL) { + if (anc_ctrl_sm == ANC_CTRL_SM_OFF && + state_update != ANC_STATE_UPDATE_TALK_THROUGH) { + anc_key_proc_close(true); + } else { + anc_key_proc_open(true); + } + } +} + +static void anc_key_process(void) { #if defined(ANC_SWITCH_GPIO_PIN) || defined(ANC_SWITCH_GPADC_CHAN) - anc_switch_on_off_ctrl(); + anc_switch_on_off_ctrl(); #elif defined(ANC_KEY_DOUBLE_CLICK_ON_OFF) - anc_double_click_on_off(); + anc_double_click_on_off(); #else - anc_click_on_off(); + anc_click_on_off(); #endif } -void anc_state_transition(void) -{ - uint32_t t_time; +void anc_state_transition(void) { + uint32_t t_time; #ifdef ANC_FADE_IN_OUT - int res_ff = 0, res_fb = 0; + int res_ff = 0, res_fb = 0; #ifdef AUDIO_ANC_TT_HW - int res_tt = 0; + int res_tt = 0; #endif #ifdef AUDIO_ANC_FB_MC_HW - int res_mc = 0; + int res_mc = 0; #endif #endif - t_time = hal_sys_timer_get(); + t_time = hal_sys_timer_get(); - if (anc_status == ANC_STATUS_INIT) { - if (t_time - anc_init_time >= MS_TO_TICKS(ANC_INIT_ON_TIMEOUT_MS)) { - //TRACE(2,"[%s] anc init on T:%u", __func__, t_time); - anc_key_proc_open(false); - // fadein or open - } + if (anc_status == ANC_STATUS_INIT) { + if (t_time - anc_init_time >= MS_TO_TICKS(ANC_INIT_ON_TIMEOUT_MS)) { + // TRACE(2,"[%s] anc init on T:%u", __func__, t_time); + anc_key_proc_open(false); + // fadein or open } + } #ifdef ANC_FADE_IN_OUT - if(anc_status == ANC_STATUS_FADEIN) - { - // process - if(fadein_cnt == 0) - { - TRACE(2,"[%s] anc fadein started T:%u", __func__, t_time); - prev_fade_time = t_time; - fadein_cnt++; - } - else if(fadein_cnt == 1) - { - // delay 60 ticks - if(t_time - prev_fade_time >= 60) - { - fadein_cnt++; - prev_fade_time = t_time; - } - } - else - { - // delay 1 ticks - if(t_time > prev_fade_time) - { - //TRACE(2,"[%s] anc_usb_app_fadein T:%u", __func__, t_time); -#ifdef AUDIO_ANC_TT_HW - res_tt = anc_usb_app_fadein(ANC_TALKTHRU); -#endif -#ifdef ANC_FF_ENABLED - res_ff = anc_usb_app_fadein(ANC_FEEDFORWARD); -#endif -#ifdef ANC_FB_ENABLED - res_fb = anc_usb_app_fadein(ANC_FEEDBACK); -#endif -#ifdef AUDIO_ANC_FB_MC_HW - res_mc = anc_usb_app_fadein(ANC_MUSICCANCLE); -#endif - if(res_ff==0&&res_fb==0 -#ifdef AUDIO_ANC_TT_HW - &&res_tt==0 -#endif -#ifdef AUDIO_ANC_FB_MC_HW - &&res_mc==0 -#endif - ) - { - anc_status = ANC_STATUS_ENABLE; - TRACE(2,"[%s] anc fadein done T:%u", __func__, t_time); - } - else - { - prev_fade_time = t_time; - } - } - } - } - else if(anc_status == ANC_STATUS_FADEOUT) - { - // process - if(fadeout_cnt == 0) - { - TRACE(2,"[%s] anc fadeout started T:%u", __func__, t_time); - prev_fade_time = t_time; - fadeout_cnt++; - } - else if(fadeout_cnt == 1) - { - // delay 1 ticks - if(t_time > prev_fade_time) - { - //TRACE(2,"[%s] anc_usb_app_fadeout T:%u", __func__, t_time); -#ifdef AUDIO_ANC_TT_HW - res_tt = anc_usb_app_fadeout(ANC_TALKTHRU); -#endif -#ifdef ANC_FF_ENABLED - res_ff = anc_usb_app_fadeout(ANC_FEEDFORWARD); -#endif -#ifdef ANC_FB_ENABLED - res_fb = anc_usb_app_fadeout(ANC_FEEDBACK); -#endif -#ifdef AUDIO_ANC_FB_MC_HW - res_mc = anc_usb_app_fadein(ANC_MUSICCANCLE); -#endif - if(res_ff==0&&res_fb==0 -#ifdef AUDIO_ANC_TT_HW - &&res_tt==0 -#endif -#ifdef AUDIO_ANC_FB_MC_HW - &&res_mc==0 -#endif - ) - { - fadeout_cnt++; - } - - prev_fade_time = t_time; - } - } - else - { - anc_usb_app(false); - anc_status = ANC_STATUS_DISABLE; - TRACE(2,"[%s] anc fadeout done T:%u", __func__, t_time); - } - } -#endif - - if (anc_status == ANC_STATUS_INIT_CLOSE || anc_status == ANC_STATUS_DISABLE) { - if(t_time - anc_close_time >= MS_TO_TICKS(ANC_SHUTDOWN_TIMEOUT_MS)) { - //TRACE(2,"[%s] anc shutdown T:%u", __func__, t_time); - anc_key_proc_close(false); - } - } - - if (anc_status == ANC_STATUS_NULL || anc_status == ANC_STATUS_ENABLE) { - hal_cpu_wake_unlock(ANC_STATE_CPU_WAKE_USER); + if (anc_status == ANC_STATUS_FADEIN) { + // process + if (fadein_cnt == 0) { + TRACE(2, "[%s] anc fadein started T:%u", __func__, t_time); + prev_fade_time = t_time; + fadein_cnt++; + } else if (fadein_cnt == 1) { + // delay 60 ticks + if (t_time - prev_fade_time >= 60) { + fadein_cnt++; + prev_fade_time = t_time; + } } else { - hal_cpu_wake_lock(ANC_STATE_CPU_WAKE_USER); + // delay 1 ticks + if (t_time > prev_fade_time) { + // TRACE(2,"[%s] anc_usb_app_fadein T:%u", __func__, t_time); +#ifdef AUDIO_ANC_TT_HW + res_tt = anc_usb_app_fadein(ANC_TALKTHRU); +#endif +#ifdef ANC_FF_ENABLED + res_ff = anc_usb_app_fadein(ANC_FEEDFORWARD); +#endif +#ifdef ANC_FB_ENABLED + res_fb = anc_usb_app_fadein(ANC_FEEDBACK); +#endif +#ifdef AUDIO_ANC_FB_MC_HW + res_mc = anc_usb_app_fadein(ANC_MUSICCANCLE); +#endif + if (res_ff == 0 && res_fb == 0 +#ifdef AUDIO_ANC_TT_HW + && res_tt == 0 +#endif +#ifdef AUDIO_ANC_FB_MC_HW + && res_mc == 0 +#endif + ) { + anc_status = ANC_STATUS_ENABLE; + TRACE(2, "[%s] anc fadein done T:%u", __func__, t_time); + } else { + prev_fade_time = t_time; + } + } } + } else if (anc_status == ANC_STATUS_FADEOUT) { + // process + if (fadeout_cnt == 0) { + TRACE(2, "[%s] anc fadeout started T:%u", __func__, t_time); + prev_fade_time = t_time; + fadeout_cnt++; + } else if (fadeout_cnt == 1) { + // delay 1 ticks + if (t_time > prev_fade_time) { + // TRACE(2,"[%s] anc_usb_app_fadeout T:%u", __func__, t_time); +#ifdef AUDIO_ANC_TT_HW + res_tt = anc_usb_app_fadeout(ANC_TALKTHRU); +#endif +#ifdef ANC_FF_ENABLED + res_ff = anc_usb_app_fadeout(ANC_FEEDFORWARD); +#endif +#ifdef ANC_FB_ENABLED + res_fb = anc_usb_app_fadeout(ANC_FEEDBACK); +#endif +#ifdef AUDIO_ANC_FB_MC_HW + res_mc = anc_usb_app_fadein(ANC_MUSICCANCLE); +#endif + if (res_ff == 0 && res_fb == 0 +#ifdef AUDIO_ANC_TT_HW + && res_tt == 0 +#endif +#ifdef AUDIO_ANC_FB_MC_HW + && res_mc == 0 +#endif + ) { + fadeout_cnt++; + } + + prev_fade_time = t_time; + } + } else { + anc_usb_app(false); + anc_status = ANC_STATUS_DISABLE; + TRACE(2, "[%s] anc fadeout done T:%u", __func__, t_time); + } + } +#endif + + if (anc_status == ANC_STATUS_INIT_CLOSE || anc_status == ANC_STATUS_DISABLE) { + if (t_time - anc_close_time >= MS_TO_TICKS(ANC_SHUTDOWN_TIMEOUT_MS)) { + // TRACE(2,"[%s] anc shutdown T:%u", __func__, t_time); + anc_key_proc_close(false); + } + } + + if (anc_status == ANC_STATUS_NULL || anc_status == ANC_STATUS_ENABLE) { + hal_cpu_wake_unlock(ANC_STATE_CPU_WAKE_USER); + } else { + hal_cpu_wake_lock(ANC_STATE_CPU_WAKE_USER); + } } -int anc_usb_app_key(enum HAL_KEY_CODE_T code, enum HAL_KEY_EVENT_T event) -{ +int anc_usb_app_key(enum HAL_KEY_CODE_T code, enum HAL_KEY_EVENT_T event) { #if !defined(ANC_SWITCH_GPIO_PIN) && !defined(ANC_SWITCH_GPADC_CHAN) #ifdef ANC_KEY_DOUBLE_CLICK_ON_OFF - if (code == ANC_FUNCTION_KEY) { - if (event == HAL_KEY_EVENT_DOUBLECLICK) { - anc_key_event = event; - hal_cpu_wake_lock(ANC_KEY_CPU_WAKE_USER); - // The key event has been processed - return 0; - } + if (code == ANC_FUNCTION_KEY) { + if (event == HAL_KEY_EVENT_DOUBLECLICK) { + anc_key_event = event; + hal_cpu_wake_lock(ANC_KEY_CPU_WAKE_USER); + // The key event has been processed + return 0; } + } #else - if (code == ANC_FUNCTION_KEY) { - if (event == HAL_KEY_EVENT_CLICK || event == HAL_KEY_EVENT_DOUBLECLICK || - event == HAL_KEY_EVENT_TRIPLECLICK || event == HAL_KEY_EVENT_LONGPRESS) { - anc_key_event = event; - hal_cpu_wake_lock(ANC_KEY_CPU_WAKE_USER); - } - // The key event has been processed - return 0; + if (code == ANC_FUNCTION_KEY) { + if (event == HAL_KEY_EVENT_CLICK || event == HAL_KEY_EVENT_DOUBLECLICK || + event == HAL_KEY_EVENT_TRIPLECLICK || + event == HAL_KEY_EVENT_LONGPRESS) { + anc_key_event = event; + hal_cpu_wake_lock(ANC_KEY_CPU_WAKE_USER); } + // The key event has been processed + return 0; + } #endif #endif - // Let other applications check the key event - return 1; + // Let other applications check the key event + return 1; } -void anc_key_check(void) -{ - enum ANC_KEY_STATE_T key_state; +void anc_key_check(void) { + enum ANC_KEY_STATE_T key_state; #ifdef ANC_SWITCH_GPIO_PIN - uint32_t lock; + uint32_t lock; - gpio_pending = false; + gpio_pending = false; #endif - key_state = anc_key_get_state(false); + key_state = anc_key_get_state(false); - if (key_state == ANC_KEY_STATE_NULL) { - return; - } else if (key_state == ANC_KEY_STATE_DEBOUNCE) { - hal_cpu_wake_lock(ANC_KEY_CPU_WAKE_USER); - } else if (key_state != prev_key_state) { - prev_key_state = key_state; - // Reuse click event to tag a state change - anc_key_event = HAL_KEY_EVENT_CLICK; - hal_cpu_wake_lock(ANC_KEY_CPU_WAKE_USER); - } else if (anc_key_event == HAL_KEY_EVENT_NONE) { + if (key_state == ANC_KEY_STATE_NULL) { + return; + } else if (key_state == ANC_KEY_STATE_DEBOUNCE) { + hal_cpu_wake_lock(ANC_KEY_CPU_WAKE_USER); + } else if (key_state != prev_key_state) { + prev_key_state = key_state; + // Reuse click event to tag a state change + anc_key_event = HAL_KEY_EVENT_CLICK; + hal_cpu_wake_lock(ANC_KEY_CPU_WAKE_USER); + } else if (anc_key_event == HAL_KEY_EVENT_NONE) { #ifdef ANC_SWITCH_GPIO_PIN - lock = int_lock(); - if (!gpio_pending) { - hal_cpu_wake_unlock(ANC_KEY_CPU_WAKE_USER); - } - int_unlock(lock); + lock = int_lock(); + if (!gpio_pending) { + hal_cpu_wake_unlock(ANC_KEY_CPU_WAKE_USER); + } + int_unlock(lock); #else - hal_cpu_wake_unlock(ANC_KEY_CPU_WAKE_USER); + hal_cpu_wake_unlock(ANC_KEY_CPU_WAKE_USER); #endif - } + } } -void anc_key_gpadc_timer_handler(void *param) -{ - hwtimer_start(gpadc_timer, ANC_SWITCH_CHECK_INTERVAL); +void anc_key_gpadc_timer_handler(void *param) { + hwtimer_start(gpadc_timer, ANC_SWITCH_CHECK_INTERVAL); } -static void anc_key_init(void) -{ +static void anc_key_init(void) { #if defined(ANC_SWITCH_GPIO_PIN) - hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)&pinmux_anc, 1); - hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)pinmux_anc.pin, HAL_GPIO_DIR_IN, 0); - // Make sure gpio value is ready - hal_sys_timer_delay(3); + hal_iomux_init((struct HAL_IOMUX_PIN_FUNCTION_MAP *)&pinmux_anc, 1); + hal_gpio_pin_set_dir((enum HAL_GPIO_PIN_T)pinmux_anc.pin, HAL_GPIO_DIR_IN, 0); + // Make sure gpio value is ready + hal_sys_timer_delay(3); #elif defined(ANC_SWITCH_GPADC_CHAN) - hal_gpadc_open(ANC_SWITCH_GPADC_CHAN, HAL_GPADC_ATP_20MS, NULL); - // Make sure gpadc channel data is ready - hal_sys_timer_delay(6); - gpadc_timer = hwtimer_alloc(anc_key_gpadc_timer_handler, NULL); - ASSERT(gpadc_timer, "Failed to alloc gpadc timer"); - hwtimer_start(gpadc_timer, ANC_SWITCH_CHECK_INTERVAL); + hal_gpadc_open(ANC_SWITCH_GPADC_CHAN, HAL_GPADC_ATP_20MS, NULL); + // Make sure gpadc channel data is ready + hal_sys_timer_delay(6); + gpadc_timer = hwtimer_alloc(anc_key_gpadc_timer_handler, NULL); + ASSERT(gpadc_timer, "Failed to alloc gpadc timer"); + hwtimer_start(gpadc_timer, ANC_SWITCH_CHECK_INTERVAL); #endif - // Add other key initialize + // Add other key initialize } #if defined(USB_AUDIO_DYN_CFG) && !defined(__AUDIO_RESAMPLE__) -static void anc_sample_rate_change(enum AUD_STREAM_T stream, enum AUD_SAMPRATE_T rate, enum AUD_SAMPRATE_T *new_play, enum AUD_SAMPRATE_T *new_cap) -{ - enum AUD_SAMPRATE_T play_rate, cap_rate; +static void anc_sample_rate_change(enum AUD_STREAM_T stream, + enum AUD_SAMPRATE_T rate, + enum AUD_SAMPRATE_T *new_play, + enum AUD_SAMPRATE_T *new_cap) { + enum AUD_SAMPRATE_T play_rate, cap_rate; - if (anc_sample_rate[stream] != rate) { + if (anc_sample_rate[stream] != rate) { #ifdef CHIP_BEST1000 - if (stream == AUD_STREAM_PLAYBACK) { - play_rate = rate; - cap_rate = rate * (anc_sample_rate[AUD_STREAM_CAPTURE] / anc_sample_rate[AUD_STREAM_PLAYBACK]); - } else { - play_rate = rate / (anc_sample_rate[AUD_STREAM_CAPTURE] / anc_sample_rate[AUD_STREAM_PLAYBACK]); - cap_rate = rate; - } + if (stream == AUD_STREAM_PLAYBACK) { + play_rate = rate; + cap_rate = rate * (anc_sample_rate[AUD_STREAM_CAPTURE] / + anc_sample_rate[AUD_STREAM_PLAYBACK]); + } else { + play_rate = rate / (anc_sample_rate[AUD_STREAM_CAPTURE] / + anc_sample_rate[AUD_STREAM_PLAYBACK]); + cap_rate = rate; + } #else - play_rate = rate; - cap_rate = rate; + play_rate = rate; + cap_rate = rate; #ifdef ANC_FF_ENABLED - anc_select_coef(play_rate,cur_coef_index, ANC_FEEDFORWARD, ANC_GAIN_NO_DELAY); + anc_select_coef(play_rate, cur_coef_index, ANC_FEEDFORWARD, + ANC_GAIN_NO_DELAY); #endif #ifdef ANC_FB_ENABLED - anc_select_coef(play_rate,cur_coef_index, ANC_FEEDBACK, ANC_GAIN_NO_DELAY); + anc_select_coef(play_rate, cur_coef_index, ANC_FEEDBACK, ANC_GAIN_NO_DELAY); #endif #if defined(AUDIO_ANC_FB_MC_HW) - anc_select_coef(play_rate,cur_coef_index, ANC_MUSICCANCLE, ANC_GAIN_NO_DELAY); + anc_select_coef(play_rate, cur_coef_index, ANC_MUSICCANCLE, + ANC_GAIN_NO_DELAY); #endif #if defined(AUDIO_ANC_TT_HW) - anc_select_coef(play_rate,cur_coef_index, ANC_TALKTHRU, ANC_GAIN_NO_DELAY); + anc_select_coef(play_rate, cur_coef_index, ANC_TALKTHRU, ANC_GAIN_NO_DELAY); #endif #endif - TRACE(5,"%s: Update anc sample rate from %u/%u to %u/%u", __func__, - anc_sample_rate[AUD_STREAM_PLAYBACK], anc_sample_rate[AUD_STREAM_CAPTURE], play_rate, cap_rate); + TRACE(5, "%s: Update anc sample rate from %u/%u to %u/%u", __func__, + anc_sample_rate[AUD_STREAM_PLAYBACK], + anc_sample_rate[AUD_STREAM_CAPTURE], play_rate, cap_rate); - if (new_play) { - *new_play= play_rate; - } - if (new_cap) { - *new_cap = cap_rate; - } - - anc_sample_rate[AUD_STREAM_PLAYBACK] = play_rate; - anc_sample_rate[AUD_STREAM_CAPTURE] = cap_rate; + if (new_play) { + *new_play = play_rate; } + if (new_cap) { + *new_cap = cap_rate; + } + + anc_sample_rate[AUD_STREAM_PLAYBACK] = play_rate; + anc_sample_rate[AUD_STREAM_CAPTURE] = cap_rate; + } } #endif -static void anc_full_open(void) -{ - AF_ANC_HANDLER POSSIBLY_UNUSED handler; +static void anc_full_open(void) { + AF_ANC_HANDLER POSSIBLY_UNUSED handler; #if defined(USB_AUDIO_DYN_CFG) && !defined(__AUDIO_RESAMPLE__) - handler = anc_sample_rate_change; + handler = anc_sample_rate_change; #else - handler = NULL; + handler = NULL; #endif #ifdef USB_AUDIO_APP - usb_audio_keep_streams_running(true); + usb_audio_keep_streams_running(true); #endif - pmu_anc_config(1); + pmu_anc_config(1); #ifdef ANC_FF_ENABLED - af_anc_open(ANC_FEEDFORWARD, anc_sample_rate[AUD_STREAM_PLAYBACK], anc_sample_rate[AUD_STREAM_CAPTURE], handler); - anc_open(ANC_FEEDFORWARD); + af_anc_open(ANC_FEEDFORWARD, anc_sample_rate[AUD_STREAM_PLAYBACK], + anc_sample_rate[AUD_STREAM_CAPTURE], handler); + anc_open(ANC_FEEDFORWARD); #endif #ifdef ANC_FB_ENABLED - af_anc_open(ANC_FEEDBACK, anc_sample_rate[AUD_STREAM_PLAYBACK], anc_sample_rate[AUD_STREAM_CAPTURE], handler); - anc_open(ANC_FEEDBACK); + af_anc_open(ANC_FEEDBACK, anc_sample_rate[AUD_STREAM_PLAYBACK], + anc_sample_rate[AUD_STREAM_CAPTURE], handler); + anc_open(ANC_FEEDBACK); #if defined(AUDIO_ANC_FB_MC_HW) - anc_open(ANC_MUSICCANCLE); + anc_open(ANC_MUSICCANCLE); #endif #endif #if defined(AUDIO_ANC_TT_HW) - anc_open(ANC_TALKTHRU); + anc_open(ANC_TALKTHRU); #endif - - anc_init_time = hal_sys_timer_get(); - anc_status = ANC_STATUS_INIT; + anc_init_time = hal_sys_timer_get(); + anc_status = ANC_STATUS_INIT; } -static void anc_full_close(void) -{ +static void anc_full_close(void) { #if defined(AUDIO_ANC_TT_HW) - anc_close(ANC_TALKTHRU); + anc_close(ANC_TALKTHRU); #endif #ifdef ANC_FF_ENABLED - anc_close(ANC_FEEDFORWARD); - af_anc_close(ANC_FEEDFORWARD); + anc_close(ANC_FEEDFORWARD); + af_anc_close(ANC_FEEDFORWARD); #endif #ifdef ANC_FB_ENABLED #if defined(AUDIO_ANC_FB_MC_HW) - anc_close(ANC_MUSICCANCLE); + anc_close(ANC_MUSICCANCLE); #endif - anc_close(ANC_FEEDBACK); - af_anc_close(ANC_FEEDBACK); + anc_close(ANC_FEEDBACK); + af_anc_close(ANC_FEEDBACK); #endif - pmu_anc_config(0); + pmu_anc_config(0); - anc_status = ANC_STATUS_NULL; + anc_status = ANC_STATUS_NULL; #ifdef USB_AUDIO_APP - usb_audio_keep_streams_running(false); + usb_audio_keep_streams_running(false); #endif } -void anc_usb_app_loop(void) -{ +void anc_usb_app_loop(void) { #if defined(ANC_SWITCH_GPIO_PIN) || defined(ANC_SWITCH_GPADC_CHAN) - anc_key_check(); + anc_key_check(); #endif - anc_key_process(); - anc_state_transition(); + anc_key_process(); + anc_state_transition(); } -void anc_usb_app_init(enum AUD_IO_PATH_T input_path, enum AUD_SAMPRATE_T playback_rate, enum AUD_SAMPRATE_T capture_rate) -{ - enum ANC_KEY_STATE_T key_state; +void anc_usb_app_init(enum AUD_IO_PATH_T input_path, + enum AUD_SAMPRATE_T playback_rate, + enum AUD_SAMPRATE_T capture_rate) { + enum ANC_KEY_STATE_T key_state; #ifdef CFG_HW_ANC_LED_PIN - hal_iomux_init(pinmux_anc_led, ARRAY_SIZE(pinmux_anc_led)); - hal_gpio_pin_set_dir(CFG_HW_ANC_LED_PIN, HAL_GPIO_DIR_OUT, 0); + hal_iomux_init(pinmux_anc_led, ARRAY_SIZE(pinmux_anc_led)); + hal_gpio_pin_set_dir(CFG_HW_ANC_LED_PIN, HAL_GPIO_DIR_OUT, 0); #endif #ifdef CFG_HW_ANC_LED_PIN2 - hal_iomux_init(pinmux_anc_led2, ARRAY_SIZE(pinmux_anc_led2)); - hal_gpio_pin_set_dir(CFG_HW_ANC_LED_PIN2, HAL_GPIO_DIR_OUT, 0); + hal_iomux_init(pinmux_anc_led2, ARRAY_SIZE(pinmux_anc_led2)); + hal_gpio_pin_set_dir(CFG_HW_ANC_LED_PIN2, HAL_GPIO_DIR_OUT, 0); #endif - anc_key_init(); + anc_key_init(); #ifdef __AUDIO_SECTION_SUPPT__ - anc_load_cfg(); + anc_load_cfg(); #endif - anc_sample_rate[AUD_STREAM_PLAYBACK] = hal_codec_anc_convert_rate(playback_rate); - anc_sample_rate[AUD_STREAM_CAPTURE] = hal_codec_anc_convert_rate(capture_rate); + anc_sample_rate[AUD_STREAM_PLAYBACK] = + hal_codec_anc_convert_rate(playback_rate); + anc_sample_rate[AUD_STREAM_CAPTURE] = + hal_codec_anc_convert_rate(capture_rate); #if defined(ANC_SWITCH_GPIO_PIN) || defined(ANC_SWITCH_GPADC_CHAN) - key_state = anc_key_get_state(true); - prev_key_state = key_state; + key_state = anc_key_get_state(true); + prev_key_state = key_state; #elif defined(ANC_KEY_DOUBLE_CLICK_ON_OFF) - key_state = ANC_KEY_STATE_OPEN; - prev_key_state = key_state; + key_state = ANC_KEY_STATE_OPEN; + prev_key_state = key_state; #else - key_state = ANC_KEY_STATE_OPEN; - anc_ctrl_sm = ANC_CTRL_SM_COEF_0 + cur_coef_index; + key_state = ANC_KEY_STATE_OPEN; + anc_ctrl_sm = ANC_CTRL_SM_COEF_0 + cur_coef_index; #endif #ifdef ANC_INIT_OFF - key_state = ANC_KEY_STATE_CLOSE; - prev_key_state = key_state; - anc_ctrl_sm = ANC_CTRL_SM_OFF; + key_state = ANC_KEY_STATE_CLOSE; + prev_key_state = key_state; + anc_ctrl_sm = ANC_CTRL_SM_OFF; #endif - if (key_state == ANC_KEY_STATE_OPEN) { - anc_full_open(); - } -} - -void anc_usb_app_term(void) -{ - anc_full_close(); + if (key_state == ANC_KEY_STATE_OPEN) { + anc_full_open(); + } } +void anc_usb_app_term(void) { anc_full_close(); } diff --git a/tests/anc_usb/dualadc_audio_app.c b/tests/anc_usb/dualadc_audio_app.c index 724552f..d515999 100644 --- a/tests/anc_usb/dualadc_audio_app.c +++ b/tests/anc_usb/dualadc_audio_app.c @@ -13,14 +13,13 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "hal_timer.h" -#include "hal_trace.h" -#include "hal_aud.h" -#include "string.h" -#include "pmu.h" #include "analog.h" #include "audioflinger.h" - +#include "hal_aud.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "pmu.h" +#include "string.h" static uint8_t *playback_buf; static uint32_t playback_size; @@ -28,13 +27,12 @@ static uint32_t playback_size; static uint8_t *capture_buf; static uint32_t capture_size; - /* static void get_mic_data_max(short *buf, uint32_t len) { int max0 = -32768, min0 = 32767, diff0 = 0; int max1 = -32768, min1 = 32767, diff1 = 0; - + for(uint32_t i=0; imax0) @@ -57,15 +55,15 @@ static void get_mic_data_max(short *buf, uint32_t len) min1 = buf[i+1]; } } - //TRACE(6,"min0 = %d, max0 = %d, diff0 = %d, min1 = %d, max1 = %d, diff1 = %d", min0, max0, max0 - min0, min1, max1, max1 - min1); - TRACE(2,"diff0 = %d, diff1 = %d", max0 - min0, max1 - min1); + //TRACE(6,"min0 = %d, max0 = %d, diff0 = %d, min1 = %d, max1 = %d, diff1 = +%d", min0, max0, max0 - min0, min1, max1, max1 - min1); TRACE(2,"diff0 = %d, +diff1 = %d", max0 - min0, max1 - min1); } */ -static uint32_t dualadc_audio_data_playback(uint8_t *buf, uint32_t len) -{ +static uint32_t dualadc_audio_data_playback(uint8_t *buf, uint32_t len) { -TRACE(0,"play"); + TRACE(0, "play"); #if 0 uint32_t stime; uint32_t pos; @@ -81,74 +79,34 @@ TRACE(0,"play"); preIrqTime = stime; #endif - return 0; + return 0; } #if 1 #define MWSPT_NSEC 3 -//static const int NL[MWSPT_NSEC] = { 1, 3, 1 }; +// static const int NL[MWSPT_NSEC] = { 1, 3, 1 }; static const float NUM[MWSPT_NSEC][3] = { - { - 0.0002616526908, 0, 0 - }, - { - 1, 2, 1 - }, - { - 1, 0, 0 - } -}; + {0.0002616526908, 0, 0}, {1, 2, 1}, {1, 0, 0}}; - -//static const int DL[MWSPT_NSEC] = { 1, 3, 1 }; +// static const int DL[MWSPT_NSEC] = { 1, 3, 1 }; static const float DEN[MWSPT_NSEC][3] = { - { - 1, 0, 0 - }, - { - 1, -1.953727961, 0.9547745585 - }, - { - 1, 0, 0 - } -}; + {1, 0, 0}, {1, -1.953727961, 0.9547745585}, {1, 0, 0}}; -#else +#else #define MWSPT_NSEC 3 -static const int NL[MWSPT_NSEC] = { 1,3,1 }; +static const int NL[MWSPT_NSEC] = {1, 3, 1}; static const float NUM[MWSPT_NSEC][3] = { - { - 0.0002616526908, 0, 0 - }, - { - 1, 2, 1 - }, - { - 1, 0, 0 - } -}; -static const int DL[MWSPT_NSEC] = { 1,3,1 }; + {0.0002616526908, 0, 0}, {1, 2, 1}, {1, 0, 0}}; +static const int DL[MWSPT_NSEC] = {1, 3, 1}; static const float DEN[MWSPT_NSEC][3] = { - { - 1, 0, 0 - }, - { - 1, -1.953727961, 0.9547745585 - }, - { - 1, 0, 0 - } -}; + {1, 0, 0}, {1, -1.953727961, 0.9547745585}, {1, 0, 0}}; #endif -static uint32_t dualadc_audio_data_capture(uint8_t *buf, uint32_t len) -{ - -TRACE(0,"capture"); - +static uint32_t dualadc_audio_data_capture(uint8_t *buf, uint32_t len) { + TRACE(0, "capture"); #if 0 if(buf==capture_buf) @@ -182,126 +140,93 @@ TRACE(0,"capture"); } - #else - short *BufSrcL; - short *BufSrcR; - short *BufDstL; - short *BufDstR; + short *BufSrcL; + short *BufSrcR; + short *BufDstL; + short *BufDstR; + int32_t PcmValue; + int32_t OutValue; - int32_t PcmValue; - int32_t OutValue; + // get_mic_data_max(buf,len); + if (buf == capture_buf) { + BufSrcL = (short *)(capture_buf); + BufSrcR = (short *)(capture_buf + 2); + BufDstL = (short *)playback_buf; + BufDstR = (short *)(playback_buf + 2); - //get_mic_data_max(buf,len); + } else { + BufSrcL = (short *)(capture_buf + capture_size / 2); + BufSrcR = (short *)(capture_buf + capture_size / 2 + 2); + BufDstL = (short *)(playback_buf + playback_size / 2); + BufDstR = (short *)(playback_buf + playback_size / 2 + 2); + } - if(buf==capture_buf) - { - BufSrcL = (short *)(capture_buf); - BufSrcR = (short *)(capture_buf+2); - BufDstL = (short *)playback_buf; - BufDstR = (short *)(playback_buf+2); + for (int i = 0, j = 0; i < capture_size / 4; i = i + 4, j = j + 2) { + PcmValue = BufSrcL[i]; - } - else - { - BufSrcL = (short *)(capture_buf+capture_size/2); - BufSrcR = (short *)(capture_buf+capture_size/2+2); - BufDstL = (short *)(playback_buf+playback_size/2); - BufDstR = (short *)(playback_buf+playback_size/2+2); + if (PcmValue > 32600) { + OutValue = ((int)BufSrcR[i]) << 6; + } else if (PcmValue > (32600 / 2) && PcmValue < 32600) { + if (BufSrcR[i] > 512) { + OutValue = PcmValue * (32600 - PcmValue) + + (((int)BufSrcR[i]) << 6) * (PcmValue - (32600 / 2)); + OutValue = OutValue / (32600 / 2); + } else { + OutValue = PcmValue; + } + } else if (PcmValue < -32700) { + OutValue = ((int)BufSrcR[i]) << 6; + } else if (PcmValue > -32700 && PcmValue < -(32700 / 2)) { - - } - + if (BufSrcR[i] < -512) { + OutValue = PcmValue * (-PcmValue - (32700 / 2)) + + (((int)BufSrcR[i]) << 6) * (32700 + PcmValue); + OutValue = OutValue / (32700 / 2); + } else { + OutValue = PcmValue; + } + } else { + OutValue = PcmValue; + } - for(int i=0,j=0;i> 6; + // OutValue=BufSrcR[i]; - if (PcmValue>32600) - { - OutValue = ((int)BufSrcR[i]) << 6; - } - else if (PcmValue>(32600 / 2) && PcmValue<32600) - { - if (BufSrcR[i]>512) - { - OutValue = PcmValue*(32600 - PcmValue) + (((int)BufSrcR[i]) << 6)*(PcmValue - (32600 / 2)); - OutValue = OutValue / (32600 / 2); - } - else - { - OutValue = PcmValue; - } - } - else if (PcmValue<-32700) - { - OutValue = ((int)BufSrcR[i]) << 6; - } - else if (PcmValue >-32700 && PcmValue < -(32700 / 2)) - { + { + static float y0 = 0, y1 = 0, y2 = 0, x0 = 0, x1 = 0, x2 = 0; - if (BufSrcR[i] <-512) - { - OutValue = PcmValue*(-PcmValue - (32700 / 2)) + (((int)BufSrcR[i]) << 6)*(32700 + PcmValue); - OutValue= OutValue/ (32700 / 2); - } - else - { - OutValue = PcmValue; - } + x0 = (OutValue * NUM[0][0]); - } - else - { - OutValue= PcmValue; - } + y0 = x0 * NUM[1][0] + x1 * NUM[1][1] + x2 * NUM[1][2] - y1 * DEN[1][1] - + y2 * DEN[1][2]; - OutValue=OutValue>>6; - // OutValue=BufSrcR[i]; + y2 = y1; + y1 = y0; + x2 = x1; + x1 = x0; + if (y0 > 32767.0f) { + y0 = 32767.0f; + } - { - static float y0 = 0, y1 = 0, y2 = 0, x0 = 0, x1 = 0, x2 = 0; + if (y0 < -32768.0f) { + y0 = -32768.0f; + } - x0 = (OutValue* NUM[0][0]); - - y0 = x0*NUM[1][0] + x1*NUM[1][1] + x2*NUM[1][2] - y1*DEN[1][1] - y2*DEN[1][2]; - - y2 = y1; - y1 = y0; - x2 = x1; - x1 = x0; - - if (y0 > 32767.0f) - { - y0 = 32767.0f; - } - - if (y0 < -32768.0f) - { - y0 = -32768.0f; - } - - OutValue = (short)y0; - } - - - BufDstL[j]=OutValue; - BufDstR[j]=OutValue; - } + OutValue = (short)y0; + } + BufDstL[j] = OutValue; + BufDstR[j] = OutValue; + } #endif - - - - - #if 0 uint32_t stime; uint32_t pos; @@ -317,89 +242,80 @@ TRACE(0,"capture"); preIrqTime = stime; #endif - return 0; + return 0; } +void dualadc_audio_app(bool on) { + struct AF_STREAM_CONFIG_T stream_cfg; + enum AUD_SAMPRATE_T sample_rate_play; + enum AUD_SAMPRATE_T POSSIBLY_UNUSED sample_rate_capture; -void dualadc_audio_app(bool on) -{ + static bool isRun = false; - struct AF_STREAM_CONFIG_T stream_cfg; - enum AUD_SAMPRATE_T sample_rate_play; - enum AUD_SAMPRATE_T POSSIBLY_UNUSED sample_rate_capture; + if (isRun == on) + return; + else + isRun = on; - static bool isRun = false; + TRACE(2, "%s: on=%d", __FUNCTION__, on); - if (isRun==on) - return; - else - isRun=on; + sample_rate_play = AUD_SAMPRATE_192000; + sample_rate_capture = AUD_SAMPRATE_192000; - TRACE(2,"%s: on=%d", __FUNCTION__, on); + if (on) { + memset(&stream_cfg, 0, sizeof(stream_cfg)); - sample_rate_play = AUD_SAMPRATE_192000; - sample_rate_capture = AUD_SAMPRATE_192000; + stream_cfg.bits = AUD_BITS_16; + stream_cfg.channel_num = AUD_CHANNEL_NUM_2; + stream_cfg.sample_rate = sample_rate_play; + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; + stream_cfg.vol = 0x06; - if (on){ + stream_cfg.handler = dualadc_audio_data_playback; + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; - memset(&stream_cfg, 0, sizeof(stream_cfg)); + stream_cfg.data_ptr = playback_buf; + stream_cfg.data_size = playback_size; + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); + stream_cfg.bits = AUD_BITS_16; + stream_cfg.channel_num = AUD_CHANNEL_NUM_2; + stream_cfg.sample_rate = sample_rate_capture; + stream_cfg.vol = 0x01; - stream_cfg.bits = AUD_BITS_16; - stream_cfg.channel_num = AUD_CHANNEL_NUM_2; - stream_cfg.sample_rate = sample_rate_play; + stream_cfg.handler = dualadc_audio_data_capture; + stream_cfg.io_path = AUD_INPUT_PATH_MAINMIC; - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; - stream_cfg.vol = 0x06; + stream_cfg.data_ptr = capture_buf; + stream_cfg.data_size = capture_size; + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); - stream_cfg.handler = dualadc_audio_data_playback; - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - stream_cfg.data_ptr = playback_buf; - stream_cfg.data_size = playback_size; - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); + } else { - - stream_cfg.bits = AUD_BITS_16; - stream_cfg.channel_num = AUD_CHANNEL_NUM_2; - stream_cfg.sample_rate = sample_rate_capture; - stream_cfg.vol = 0x01; - - stream_cfg.handler = dualadc_audio_data_capture; - stream_cfg.io_path = AUD_INPUT_PATH_MAINMIC; - - stream_cfg.data_ptr = capture_buf; - stream_cfg.data_size = capture_size; - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); - - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - - }else{ - - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - } + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + } } -void dualadc_audio_app_init(uint8_t *play_buf, uint32_t play_size, uint8_t *cap_buf, uint32_t cap_size) -{ - playback_buf = play_buf; - playback_size = play_size; - capture_buf = cap_buf; - capture_size = cap_size; +void dualadc_audio_app_init(uint8_t *play_buf, uint32_t play_size, + uint8_t *cap_buf, uint32_t cap_size) { + playback_buf = play_buf; + playback_size = play_size; + capture_buf = cap_buf; + capture_size = cap_size; } -void dualadc_audio_app_term(void) -{ - playback_buf = NULL; - playback_size = 0; - capture_buf = NULL; - capture_size = 0; +void dualadc_audio_app_term(void) { + playback_buf = NULL; + playback_size = 0; + capture_buf = NULL; + capture_size = 0; } - diff --git a/tests/anc_usb/main.c b/tests/anc_usb/main.c index 3aec694..de36ba3 100644 --- a/tests/anc_usb/main.c +++ b/tests/anc_usb/main.c @@ -13,7 +13,13 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_addr_map.h" +#include "adda_loop_app.h" +#include "analog.h" +#include "anc_usb_app.h" +#include "audio_process.h" +#include "audioflinger.h" +#include "cmsis.h" +#include "dualadc_audio_app.h" #include "hal_bootmode.h" #include "hal_cmu.h" #include "hal_dma.h" @@ -25,20 +31,14 @@ #include "hal_sysfreq.h" #include "hal_timer.h" #include "hal_trace.h" -#include "cmsis.h" -#include "main_entry.h" -#include "pmu.h" -#include "analog.h" -#include "string.h" #include "hwtimer_list.h" -#include "audioflinger.h" -#include "anc_usb_app.h" -#include "usb_audio_app.h" -#include "dualadc_audio_app.h" -#include "adda_loop_app.h" -#include "usb_audio_frm_defs.h" +#include "main_entry.h" +#include "plat_addr_map.h" +#include "pmu.h" +#include "string.h" #include "tgt_hardware.h" -#include "audio_process.h" +#include "usb_audio_app.h" +#include "usb_audio_frm_defs.h" #if defined(_VENDOR_MSG_SUPPT_) #include "usb_vendor_msg.h" #endif @@ -51,82 +51,103 @@ #endif #ifdef USB_AUDIO_SPEECH -#define CODEC_BUFF_FRAME_NUM (2 * 16) -#define USB_BUFF_FRAME_NUM (CODEC_BUFF_FRAME_NUM * 2) +#define CODEC_BUFF_FRAME_NUM (2 * 16) +#define USB_BUFF_FRAME_NUM (CODEC_BUFF_FRAME_NUM * 2) #else -#define CODEC_BUFF_FRAME_NUM 4 -#define USB_BUFF_FRAME_NUM 10 +#define CODEC_BUFF_FRAME_NUM 4 +#define USB_BUFF_FRAME_NUM 10 #endif #if (CODEC_BUFF_FRAME_NUM >= USB_BUFF_FRAME_NUM) -#error "Codec buffer frame num should be less than usb buffer frame num (on the requirement of conflict ctrl)" +#error \ + "Codec buffer frame num should be less than usb buffer frame num (on the requirement of conflict ctrl)" #endif #ifdef USB_AUDIO_DYN_CFG -#define USB_AUDIO_PLAYBACK_BUFF_SIZE NON_EXP_ALIGN(MAX_FRAME_SIZE_PLAYBACK * CODEC_BUFF_FRAME_NUM, DAC_BUFF_ALIGN) -#define USB_AUDIO_CAPTURE_BUFF_SIZE NON_EXP_ALIGN(MAX_FRAME_SIZE_CAPTURE * CODEC_BUFF_FRAME_NUM, ADC_BUFF_ALIGN) +#define USB_AUDIO_PLAYBACK_BUFF_SIZE \ + NON_EXP_ALIGN(MAX_FRAME_SIZE_PLAYBACK *CODEC_BUFF_FRAME_NUM, DAC_BUFF_ALIGN) +#define USB_AUDIO_CAPTURE_BUFF_SIZE \ + NON_EXP_ALIGN(MAX_FRAME_SIZE_CAPTURE *CODEC_BUFF_FRAME_NUM, ADC_BUFF_ALIGN) -#define USB_AUDIO_RECV_BUFF_SIZE NON_EXP_ALIGN(MAX_FRAME_SIZE_RECV * USB_BUFF_FRAME_NUM, RECV_BUFF_ALIGN) -#define USB_AUDIO_SEND_BUFF_SIZE NON_EXP_ALIGN(MAX_FRAME_SIZE_SEND * USB_BUFF_FRAME_NUM, SEND_BUFF_ALIGN) +#define USB_AUDIO_RECV_BUFF_SIZE \ + NON_EXP_ALIGN(MAX_FRAME_SIZE_RECV *USB_BUFF_FRAME_NUM, RECV_BUFF_ALIGN) +#define USB_AUDIO_SEND_BUFF_SIZE \ + NON_EXP_ALIGN(MAX_FRAME_SIZE_SEND *USB_BUFF_FRAME_NUM, SEND_BUFF_ALIGN) #if defined(CHIP_BEST1000) // FIR EQ is working on 16-bit // FIR_EQ_buffer_size = max_playback_symbol_number_in_buffer * sizeof(int16_t) -#define USB_AUDIO_FIR_EQ_BUFF_SIZE USB_AUDIO_PLAYBACK_BUFF_SIZE +#define USB_AUDIO_FIR_EQ_BUFF_SIZE USB_AUDIO_PLAYBACK_BUFF_SIZE #elif defined(CHIP_BEST2000) // FIR EQ is working on 32-bit // FIR_EQ_buffer_size = max_playback_symbol_number_in_buffer * sizeof(int32_t) -#define USB_AUDIO_FIR_EQ_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE*2) +#define USB_AUDIO_FIR_EQ_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE * 2) #elif defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) // FIR EQ is working on 32-bit // FIR_EQ_buffer_size = max_playback_symbol_number_in_buffer * sizeof(int32_t) -#define USB_AUDIO_FIR_EQ_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE) -#define USB_AUDIO_IIR_EQ_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE) -#define USB_AUDIO_DSD_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE*16) +#define USB_AUDIO_FIR_EQ_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE) +#define USB_AUDIO_IIR_EQ_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE) +#define USB_AUDIO_DSD_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE * 16) #endif #else // !USB_AUDIO_DYN_CFG -#define USB_AUDIO_PLAYBACK_BUFF_SIZE NON_EXP_ALIGN(FRAME_SIZE_PLAYBACK * CODEC_BUFF_FRAME_NUM, DAC_BUFF_ALIGN) -#define USB_AUDIO_CAPTURE_BUFF_SIZE NON_EXP_ALIGN(FRAME_SIZE_CAPTURE * CODEC_BUFF_FRAME_NUM, ADC_BUFF_ALIGN) +#define USB_AUDIO_PLAYBACK_BUFF_SIZE \ + NON_EXP_ALIGN(FRAME_SIZE_PLAYBACK *CODEC_BUFF_FRAME_NUM, DAC_BUFF_ALIGN) +#define USB_AUDIO_CAPTURE_BUFF_SIZE \ + NON_EXP_ALIGN(FRAME_SIZE_CAPTURE *CODEC_BUFF_FRAME_NUM, ADC_BUFF_ALIGN) -#define USB_AUDIO_RECV_BUFF_SIZE NON_EXP_ALIGN(FRAME_SIZE_RECV * USB_BUFF_FRAME_NUM, RECV_BUFF_ALIGN) -#define USB_AUDIO_SEND_BUFF_SIZE NON_EXP_ALIGN(FRAME_SIZE_SEND * USB_BUFF_FRAME_NUM, SEND_BUFF_ALIGN) +#define USB_AUDIO_RECV_BUFF_SIZE \ + NON_EXP_ALIGN(FRAME_SIZE_RECV *USB_BUFF_FRAME_NUM, RECV_BUFF_ALIGN) +#define USB_AUDIO_SEND_BUFF_SIZE \ + NON_EXP_ALIGN(FRAME_SIZE_SEND *USB_BUFF_FRAME_NUM, SEND_BUFF_ALIGN) #if defined(CHIP_BEST1000) // FIR EQ is working on 16-bit -#define USB_AUDIO_FIR_EQ_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE * sizeof(int16_t) / SAMPLE_SIZE_PLAYBACK) +#define USB_AUDIO_FIR_EQ_BUFF_SIZE \ + (USB_AUDIO_PLAYBACK_BUFF_SIZE * sizeof(int16_t) / SAMPLE_SIZE_PLAYBACK) #elif defined(CHIP_BEST2000) // FIR EQ is working on 32-bit -#define USB_AUDIO_FIR_EQ_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE * sizeof(int32_t) / SAMPLE_SIZE_PLAYBACK) +#define USB_AUDIO_FIR_EQ_BUFF_SIZE \ + (USB_AUDIO_PLAYBACK_BUFF_SIZE * sizeof(int32_t) / SAMPLE_SIZE_PLAYBACK) #elif defined(CHIP_BEST2300) || defined(CHIP_BEST2300P) // FIR EQ is working on 32-bit -#define USB_AUDIO_FIR_EQ_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE) -#define USB_AUDIO_IIR_EQ_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE) -#define USB_AUDIO_DSD_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE*16) +#define USB_AUDIO_FIR_EQ_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE) +#define USB_AUDIO_IIR_EQ_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE) +#define USB_AUDIO_DSD_BUFF_SIZE (USB_AUDIO_PLAYBACK_BUFF_SIZE * 16) #endif #endif // !USB_AUDIO_DYN_CFG -#if (defined(CHIP_BEST1000) && (defined(ANC_APP) || defined(_DUAL_AUX_MIC_))) && (CHAN_NUM_CAPTURE == CHAN_NUM_SEND) -// Resample input buffer size should be (half_of_max_sample_num * SAMPLE_SIZE_CAPTURE * CHAN_NUM_CAPTURE). -// half_of_max_sample_num = 48000 / 1000 * CODEC_BUFF_FRAME_NUM / 2 * 48 / 44 -#define RESAMPLE_INPUT_BUFF_SIZE ALIGN(48000 / 1000 * SAMPLE_SIZE_CAPTURE * CHAN_NUM_CAPTURE * CODEC_BUFF_FRAME_NUM / 2 * 48 / 44, 4) +#if (defined(CHIP_BEST1000) && \ + (defined(ANC_APP) || defined(_DUAL_AUX_MIC_))) && \ + (CHAN_NUM_CAPTURE == CHAN_NUM_SEND) +// Resample input buffer size should be (half_of_max_sample_num * +// SAMPLE_SIZE_CAPTURE * CHAN_NUM_CAPTURE). half_of_max_sample_num = 48000 / +// 1000 * CODEC_BUFF_FRAME_NUM / 2 * 48 / 44 +#define RESAMPLE_INPUT_BUFF_SIZE \ + ALIGN(48000 / 1000 * SAMPLE_SIZE_CAPTURE * CHAN_NUM_CAPTURE * \ + CODEC_BUFF_FRAME_NUM / 2 * 48 / 44, \ + 4) #else -#define RESAMPLE_INPUT_BUFF_SIZE 0 +#define RESAMPLE_INPUT_BUFF_SIZE 0 #endif // Resample history buffer size should be -// sizeof(struct RESAMPLE_CTRL_T) + ((SAMPLE_NUM + phase_coef_num) * SAMPLE_SIZE_CAPTURE * CHAN_NUM_CAPTURE) -#define RESAMPLE_HISTORY_BUFF_SIZE (50 + (256 * SAMPLE_SIZE_CAPTURE * CHAN_NUM_CAPTURE)) -#define USB_AUDIO_RESAMPLE_BUFF_SIZE (RESAMPLE_INPUT_BUFF_SIZE + RESAMPLE_HISTORY_BUFF_SIZE) +// sizeof(struct RESAMPLE_CTRL_T) + ((SAMPLE_NUM + phase_coef_num) * +// SAMPLE_SIZE_CAPTURE * CHAN_NUM_CAPTURE) +#define RESAMPLE_HISTORY_BUFF_SIZE \ + (50 + (256 * SAMPLE_SIZE_CAPTURE * CHAN_NUM_CAPTURE)) +#define USB_AUDIO_RESAMPLE_BUFF_SIZE \ + (RESAMPLE_INPUT_BUFF_SIZE + RESAMPLE_HISTORY_BUFF_SIZE) -#define ALIGNED4 ALIGNED(4) +#define ALIGNED4 ALIGNED(4) #if defined(USB_AUDIO_APP) || defined(DUALADC_AUDIO_TEST) #ifdef AUDIO_ANC_FB_MC -static uint8_t ALIGNED4 playback_buff[USB_AUDIO_PLAYBACK_BUFF_SIZE * 9];//max 48->384 or 44.1->44.1*8; +static uint8_t ALIGNED4 playback_buff[USB_AUDIO_PLAYBACK_BUFF_SIZE * + 9]; // max 48->384 or 44.1->44.1*8; #else static uint8_t ALIGNED4 playback_buff[USB_AUDIO_PLAYBACK_BUFF_SIZE]; #endif @@ -138,7 +159,8 @@ static uint8_t ALIGNED4 capture_buff[USB_AUDIO_CAPTURE_BUFF_SIZE]; #ifdef USB_AUDIO_APP #if defined(__HW_FIR_EQ_PROCESS__) && defined(__HW_IIR_EQ_PROCESS__) -static uint8_t ALIGNED4 eq_buff[USB_AUDIO_FIR_EQ_BUFF_SIZE+USB_AUDIO_IIR_EQ_BUFF_SIZE]; +static uint8_t ALIGNED4 + eq_buff[USB_AUDIO_FIR_EQ_BUFF_SIZE + USB_AUDIO_IIR_EQ_BUFF_SIZE]; #elif defined(__HW_FIR_EQ_PROCESS__) && !defined(__HW_IIR_EQ_PROCESS__) static uint8_t ALIGNED4 eq_buff[USB_AUDIO_FIR_EQ_BUFF_SIZE]; #elif !defined(__HW_FIR_EQ_PROCESS__) && defined(__HW_IIR_EQ_PROCESS__) @@ -164,278 +186,278 @@ static uint8_t ALIGNED4 recv2_buff[USB_AUDIO_RECV_BUFF_SIZE]; #ifdef CFG_HW_KEY_LED_PIN const struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_key_led[1] = { - {CFG_HW_KEY_LED_PIN, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_NOPULL}, + {CFG_HW_KEY_LED_PIN, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, + HAL_IOMUX_PIN_NOPULL}, }; #endif #ifdef CFG_MIC_KEY -extern void mic_key_open (void); +extern void mic_key_open(void); #endif -static void uart_i2c_switch(void) -{ - static int flag = 0; +static void uart_i2c_switch(void) { + static int flag = 0; - flag ^= 1; + flag ^= 1; - if (flag) { - hal_iomux_set_analog_i2c(); - } else { - hal_iomux_set_uart0(); - } + if (flag) { + hal_iomux_set_analog_i2c(); + } else { + hal_iomux_set_uart0(); + } } -static int key_event_process(uint32_t key_code, uint8_t key_event) -{ - TRACE(3,"%s: code=0x%X, event=%u", __FUNCTION__, key_code, key_event); +static int key_event_process(uint32_t key_code, uint8_t key_event) { + TRACE(3, "%s: code=0x%X, event=%u", __FUNCTION__, key_code, key_event); #ifdef CFG_HW_KEY_LED_PIN - if (key_event == HAL_KEY_EVENT_DOWN) { - hal_gpio_pin_set(CFG_HW_KEY_LED_PIN); - } else if (key_event == HAL_KEY_EVENT_UP) { - hal_gpio_pin_clr(CFG_HW_KEY_LED_PIN); - } + if (key_event == HAL_KEY_EVENT_DOWN) { + hal_gpio_pin_set(CFG_HW_KEY_LED_PIN); + } else if (key_event == HAL_KEY_EVENT_UP) { + hal_gpio_pin_clr(CFG_HW_KEY_LED_PIN); + } #endif #ifdef USB_AUDIO_APP - if (usb_audio_app_key(key_code, key_event) == 0) { - return 0; - } + if (usb_audio_app_key(key_code, key_event) == 0) { + return 0; + } #endif #ifdef ANC_APP - if (anc_usb_app_key(key_code, key_event) == 0) { - return 0; - } + if (anc_usb_app_key(key_code, key_event) == 0) { + return 0; + } #endif - if (key_event == HAL_KEY_EVENT_CLICK) { - if (key_code == HAL_KEY_CODE_FN9) { - uart_i2c_switch(); - } + if (key_event == HAL_KEY_EVENT_CLICK) { + if (key_code == HAL_KEY_CODE_FN9) { + uart_i2c_switch(); } + } - return 0; + return 0; } -void anc_usb_open(void) -{ - TRACE(1,"%s", __FUNCTION__); +void anc_usb_open(void) { + TRACE(1, "%s", __FUNCTION__); #ifdef __AUDIO_RESAMPLE__ - hal_cmu_audio_resample_enable(); + hal_cmu_audio_resample_enable(); #endif #ifdef USB_AUDIO_APP - struct USB_AUDIO_BUF_CFG cfg; + struct USB_AUDIO_BUF_CFG cfg; - memset(&cfg, 0, sizeof(cfg)); - cfg.play_buf = playback_buff; + memset(&cfg, 0, sizeof(cfg)); + cfg.play_buf = playback_buff; #ifdef AUDIO_ANC_FB_MC - cfg.play_size = sizeof(playback_buff) / 9; + cfg.play_size = sizeof(playback_buff) / 9; #else - cfg.play_size = sizeof(playback_buff); + cfg.play_size = sizeof(playback_buff); #endif - cfg.cap_buf = capture_buff; - cfg.cap_size = sizeof(capture_buff); - cfg.recv_buf = recv_buff; - cfg.recv_size = sizeof(recv_buff); - cfg.send_buf = send_buff; - cfg.send_size = sizeof(send_buff); - cfg.eq_buf = eq_buff; - cfg.eq_size = sizeof(eq_buff); - cfg.resample_buf = resample_buff; - cfg.resample_size = sizeof(resample_buff); + cfg.cap_buf = capture_buff; + cfg.cap_size = sizeof(capture_buff); + cfg.recv_buf = recv_buff; + cfg.recv_size = sizeof(recv_buff); + cfg.send_buf = send_buff; + cfg.send_size = sizeof(send_buff); + cfg.eq_buf = eq_buff; + cfg.eq_size = sizeof(eq_buff); + cfg.resample_buf = resample_buff; + cfg.resample_size = sizeof(resample_buff); #ifdef USB_AUDIO_MULTIFUNC - cfg.recv2_buf = recv2_buff; - cfg.recv2_size = sizeof(recv2_buff); + cfg.recv2_buf = recv2_buff; + cfg.recv2_size = sizeof(recv2_buff); #endif - usb_audio_app_init(&cfg); - usb_audio_app(true); + usb_audio_app_init(&cfg); + usb_audio_app(true); #endif #ifdef ANC_APP - anc_usb_app_init(AUD_INPUT_PATH_MAINMIC, SAMPLE_RATE_PLAYBACK, SAMPLE_RATE_CAPTURE); + anc_usb_app_init(AUD_INPUT_PATH_MAINMIC, SAMPLE_RATE_PLAYBACK, + SAMPLE_RATE_CAPTURE); #endif #ifdef DUALADC_AUDIO_TEST - dualadc_audio_app_init(playback_buff, USB_AUDIO_PLAYBACK_BUFF_SIZE, - capture_buff, USB_AUDIO_CAPTURE_BUFF_SIZE); - dualadc_audio_app(true); + dualadc_audio_app_init(playback_buff, USB_AUDIO_PLAYBACK_BUFF_SIZE, + capture_buff, USB_AUDIO_CAPTURE_BUFF_SIZE); + dualadc_audio_app(true); #endif #ifdef ADDA_LOOP_APP - adda_loop_app(true); + adda_loop_app(true); #endif #if defined(_VENDOR_MSG_SUPPT_) #ifndef USB_ANC_MC_EQ_TUNING - vendor_info_init(); + vendor_info_init(); #endif #endif #if defined(CFG_MIC_KEY) - mic_key_open(); + mic_key_open(); #endif - // Allow sleep - hal_sysfreq_req(HAL_SYSFREQ_USER_INIT, HAL_CMU_FREQ_32K); + // Allow sleep + hal_sysfreq_req(HAL_SYSFREQ_USER_INIT, HAL_CMU_FREQ_32K); - while (1) { + while (1) { #ifdef USB_AUDIO_APP - usb_audio_app_loop(); + usb_audio_app_loop(); #endif #ifdef ANC_APP - anc_usb_app_loop(); + anc_usb_app_loop(); #endif #ifdef ADDA_LOOP_APP - adda_loop_app_loop(); + adda_loop_app_loop(); #endif #ifdef RTOS - // Let the task sleep - osDelay(20); + // Let the task sleep + osDelay(20); #else // !RTOS #ifdef USB_EQ_TUNING - audio_eq_usb_eq_update(); + audio_eq_usb_eq_update(); #endif - hal_sleep_enter_sleep(); + hal_sleep_enter_sleep(); #endif // !RTOS - } + } } #ifdef CFG_HW_GPADCKEY -void gpadc_key_handler(uint16_t irq_val, HAL_GPADC_MV_T volt) -{ - static uint16_t stable_cnt = 0; - static uint16_t click_cnt = 0; - static uint32_t click_time; - uint32_t time; - enum HAL_KEY_EVENT_T event; - bool send_event = false; +void gpadc_key_handler(uint16_t irq_val, HAL_GPADC_MV_T volt) { + static uint16_t stable_cnt = 0; + static uint16_t click_cnt = 0; + static uint32_t click_time; + uint32_t time; + enum HAL_KEY_EVENT_T event; + bool send_event = false; - time = hal_sys_timer_get(); + time = hal_sys_timer_get(); - if (volt < 100) { - stable_cnt++; - //TRACE(5,"adc_key down: volt=%u stable=%u click_cnt=%u click_time=%u time=%u", volt, stable_cnt, click_cnt, click_time, time); - } else { - if (stable_cnt > 1) { - //TRACE(5,"adc_key up: volt=%u stable=%u click_cnt=%u click_time=%u time=%u", volt, stable_cnt, click_cnt, click_time, time); - if (click_cnt == 0 || (time - click_time) < MS_TO_TICKS(500)) { - click_time = time; - click_cnt++; - if (click_cnt >= 3) { - send_event = true; - } - } else { - send_event = true; - } - } - stable_cnt = 0; - - if (click_cnt > 0 && (time - click_time) >= MS_TO_TICKS(500)) { - send_event = true; - } - - if (send_event) { - //TRACE(5,"adc_key click: volt=%u stable=%u click_cnt=%u click_time=%u time=%u", volt, stable_cnt, click_cnt, click_time, time); - if (click_cnt == 1) { - event = HAL_KEY_EVENT_CLICK; - } else if (click_cnt == 2) { - event = HAL_KEY_EVENT_DOUBLECLICK; - } else { - event = HAL_KEY_EVENT_TRIPLECLICK; - } - key_event_process(CFG_HW_GPADCKEY, event); - click_cnt = 0; + if (volt < 100) { + stable_cnt++; + // TRACE(5,"adc_key down: volt=%u stable=%u click_cnt=%u click_time=%u + // time=%u", volt, stable_cnt, click_cnt, click_time, time); + } else { + if (stable_cnt > 1) { + // TRACE(5,"adc_key up: volt=%u stable=%u click_cnt=%u click_time=%u + // time=%u", volt, stable_cnt, click_cnt, click_time, time); + if (click_cnt == 0 || (time - click_time) < MS_TO_TICKS(500)) { + click_time = time; + click_cnt++; + if (click_cnt >= 3) { + send_event = true; } + } else { + send_event = true; + } } + stable_cnt = 0; + + if (click_cnt > 0 && (time - click_time) >= MS_TO_TICKS(500)) { + send_event = true; + } + + if (send_event) { + // TRACE(5,"adc_key click: volt=%u stable=%u click_cnt=%u click_time=%u + // time=%u", volt, stable_cnt, click_cnt, click_time, time); + if (click_cnt == 1) { + event = HAL_KEY_EVENT_CLICK; + } else if (click_cnt == 2) { + event = HAL_KEY_EVENT_DOUBLECLICK; + } else { + event = HAL_KEY_EVENT_TRIPLECLICK; + } + key_event_process(CFG_HW_GPADCKEY, event); + click_cnt = 0; + } + } } #endif #ifdef DEBUG_MODE_USB_DOWNLOAD -static void process_usb_download_mode(void) -{ - if (pmu_charger_get_status() == PMU_CHARGER_PLUGIN && hal_pwrkey_pressed()) { - hal_sw_bootmode_set(HAL_SW_BOOTMODE_FORCE_USB_DLD); - hal_cmu_sys_reboot(); - } +static void process_usb_download_mode(void) { + if (pmu_charger_get_status() == PMU_CHARGER_PLUGIN && hal_pwrkey_pressed()) { + hal_sw_bootmode_set(HAL_SW_BOOTMODE_FORCE_USB_DLD); + hal_cmu_sys_reboot(); + } } #endif // GDB can set a breakpoint on the main function only if it is // declared as below, when linking with STD libraries. -int MAIN_ENTRY(void) -{ +int MAIN_ENTRY(void) { #ifdef INTSRAM_RUN // hal_norflash_sleep(HAL_NORFLASH_ID_0); #endif #ifdef DEBUG_MODE_USB_DOWNLOAD - process_usb_download_mode(); + process_usb_download_mode(); #endif - hal_cmu_simu_init(); - hwtimer_init(); - hal_audma_open(); - hal_gpdma_open(); + hal_cmu_simu_init(); + hwtimer_init(); + hal_audma_open(); + hal_gpdma_open(); #if (DEBUG_PORT == 2) - hal_iomux_set_analog_i2c(); - hal_iomux_set_uart1(); - hal_trace_open(HAL_TRACE_TRANSPORT_UART1); + hal_iomux_set_analog_i2c(); + hal_iomux_set_uart1(); + hal_trace_open(HAL_TRACE_TRANSPORT_UART1); #else - hal_iomux_set_uart0(); - hal_trace_open(HAL_TRACE_TRANSPORT_UART0); + hal_iomux_set_uart0(); + hal_trace_open(HAL_TRACE_TRANSPORT_UART0); #endif #if !defined(SIMU) && !defined(FPGA) - uint8_t flash_id[HAL_NORFLASH_DEVICE_ID_LEN]; - hal_norflash_get_id(HAL_NORFLASH_ID_0, flash_id, ARRAY_SIZE(flash_id)); - TRACE(3,"FLASH_ID: %02X-%02X-%02X", flash_id[0], flash_id[1], flash_id[2]); + uint8_t flash_id[HAL_NORFLASH_DEVICE_ID_LEN]; + hal_norflash_get_id(HAL_NORFLASH_ID_0, flash_id, ARRAY_SIZE(flash_id)); + TRACE(3, "FLASH_ID: %02X-%02X-%02X", flash_id[0], flash_id[1], flash_id[2]); #endif - pmu_open(); - analog_open(); - af_open(); - hal_sleep_start_stats(10000, 10000); + pmu_open(); + analog_open(); + af_open(); + hal_sleep_start_stats(10000, 10000); #ifdef CHIP_BEST1000 - hal_cmu_force_bt_sleep(); + hal_cmu_force_bt_sleep(); #endif - hal_key_open(0, key_event_process); + hal_key_open(0, key_event_process); #ifdef CFG_HW_GPADCKEY - hal_gpadc_open(HAL_GPADC_CHAN_3, HAL_GPADC_ATP_20MS, gpadc_key_handler); + hal_gpadc_open(HAL_GPADC_CHAN_3, HAL_GPADC_ATP_20MS, gpadc_key_handler); #endif #ifdef CFG_HW_KEY_LED_PIN - hal_iomux_init(pinmux_key_led, ARRAY_SIZE(pinmux_key_led)); - hal_gpio_pin_set_dir(CFG_HW_KEY_LED_PIN, HAL_GPIO_DIR_OUT, 0); + hal_iomux_init(pinmux_key_led, ARRAY_SIZE(pinmux_key_led)); + hal_gpio_pin_set_dir(CFG_HW_KEY_LED_PIN, HAL_GPIO_DIR_OUT, 0); #endif -#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__)|| defined(__HW_DAC_IIR_EQ_PROCESS__)|| defined(__HW_IIR_EQ_PROCESS__) - audio_process_init(); - // TODO: Get EQ store parameter - // audio_eq_fir_update_cfg(int16_t *coef, int16_t num); - // audio_eq_iir_update_cfg(int *gain, int num); +#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__) || \ + defined(__HW_DAC_IIR_EQ_PROCESS__) || defined(__HW_IIR_EQ_PROCESS__) + audio_process_init(); + // TODO: Get EQ store parameter + // audio_eq_fir_update_cfg(int16_t *coef, int16_t num); + // audio_eq_iir_update_cfg(int *gain, int num); #endif - anc_usb_open(); + anc_usb_open(); - TRACE(0,"byebye~~~\n"); + TRACE(0, "byebye~~~\n"); - hal_sys_timer_delay(MS_TO_TICKS(200)); + hal_sys_timer_delay(MS_TO_TICKS(200)); - pmu_shutdown(); + pmu_shutdown(); - return 0; + return 0; } //-------------------------------------------------------------------------------- @@ -451,41 +473,36 @@ extern uint32_t __StackLimit[]; extern uint32_t __bss_start__[]; extern uint32_t __bss_end__[]; -#define EXEC_STRUCT_LOC __attribute__((section(".exec_struct"))) +#define EXEC_STRUCT_LOC __attribute__((section(".exec_struct"))) -bool task_yield(void) -{ - return true; -} +bool task_yield(void) { return true; } -void anc_usb_ramrun_main(void) -{ - uint32_t *dst; +void anc_usb_ramrun_main(void) { + uint32_t *dst; - for (dst = __bss_start__; dst < __bss_end__; dst++) { - *dst = 0; - } + for (dst = __bss_start__; dst < __bss_end__; dst++) { + *dst = 0; + } - NVIC_InitVectors(); + NVIC_InitVectors(); #ifdef UNALIGNED_ACCESS - SystemInit(); + SystemInit(); #endif - hal_cmu_setup(); - main(); + hal_cmu_setup(); + main(); #if !defined(PROGRAMMER_INFLASH) - SAFE_PROGRAM_STOP(); + SAFE_PROGRAM_STOP(); #endif } -void anc_usb_ramrun_start(void) -{ - GotBaseInit(); +void anc_usb_ramrun_start(void) { + GotBaseInit(); #ifdef __ARM_ARCH_8M_MAIN__ - __set_MSPLIM((uint32_t)__StackLimit); + __set_MSPLIM((uint32_t)__StackLimit); #endif - __set_MSP((uint32_t)__StackTop); - anc_usb_ramrun_main(); + __set_MSP((uint32_t)__StackTop); + anc_usb_ramrun_main(); } const struct exec_struct_t EXEC_STRUCT_LOC ramrun_struct = { @@ -495,9 +512,8 @@ const struct exec_struct_t EXEC_STRUCT_LOC ramrun_struct = { .exec_addr = (uint32_t)&ramrun_struct, }; -void programmer_start(void) __attribute__((weak,alias("anc_usb_ramrun_main"))); +void programmer_start(void) __attribute__((weak, alias("anc_usb_ramrun_main"))); #endif //-------------------------------------------------------------------------------- // End of Programmer Entry //-------------------------------------------------------------------------------- - diff --git a/tests/anc_usb/memutils.c b/tests/anc_usb/memutils.c index 2a86e9d..48c2374 100644 --- a/tests/anc_usb/memutils.c +++ b/tests/anc_usb/memutils.c @@ -13,82 +13,75 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "memutils.h" #include "plat_types.h" #include "string.h" -#include "memutils.h" -#define ALIGNED32(a) (((uint32_t)(a) & 3) == 0) -#define ALIGNED16(a) (((uint32_t)(a) & 1) == 0) +#define ALIGNED32(a) (((uint32_t)(a)&3) == 0) +#define ALIGNED16(a) (((uint32_t)(a)&1) == 0) -void *copy_mem32(void *dst, const void *src, unsigned int size) -{ - uint32_t *d = dst; - const uint32_t *s = src; - const uint32_t *e = s + size / 4; +void *copy_mem32(void *dst, const void *src, unsigned int size) { + uint32_t *d = dst; + const uint32_t *s = src; + const uint32_t *e = s + size / 4; - while (s < e) { - *d++ = *s++; - } + while (s < e) { + *d++ = *s++; + } - return dst; + return dst; } -void *copy_mem16(void *dst, const void *src, unsigned int size) -{ - uint16_t *d = dst; - const uint16_t *s = src; - const uint16_t *e = s + size / 2; +void *copy_mem16(void *dst, const void *src, unsigned int size) { + uint16_t *d = dst; + const uint16_t *s = src; + const uint16_t *e = s + size / 2; - while (s < e) { - *d++ = *s++; - } + while (s < e) { + *d++ = *s++; + } - return dst; + return dst; } -void *copy_mem(void *dst, const void *src, unsigned int size) -{ - if (ALIGNED32(dst) && ALIGNED32(src) && ALIGNED32(size)) { - return copy_mem32(dst, src, size); - } else if (ALIGNED16(dst) && ALIGNED16(src) && ALIGNED16(size)) { - return copy_mem16(dst, src, size); - } else { - return memcpy(dst, src, size); - } +void *copy_mem(void *dst, const void *src, unsigned int size) { + if (ALIGNED32(dst) && ALIGNED32(src) && ALIGNED32(size)) { + return copy_mem32(dst, src, size); + } else if (ALIGNED16(dst) && ALIGNED16(src) && ALIGNED16(size)) { + return copy_mem16(dst, src, size); + } else { + return memcpy(dst, src, size); + } } -void *zero_mem32(void *dst, unsigned int size) -{ - uint32_t *d = dst; - uint32_t count = size / 4; +void *zero_mem32(void *dst, unsigned int size) { + uint32_t *d = dst; + uint32_t count = size / 4; - while (count--) { - *d++ = 0; - } + while (count--) { + *d++ = 0; + } - return dst; + return dst; } -void *zero_mem16(void *dst, unsigned int size) -{ - uint16_t *d = dst; - uint32_t count = size / 2; +void *zero_mem16(void *dst, unsigned int size) { + uint16_t *d = dst; + uint32_t count = size / 2; - while (count--) { - *d++ = 0; - } + while (count--) { + *d++ = 0; + } - return dst; + return dst; } -void *zero_mem(void *dst, unsigned int size) -{ - if (ALIGNED32(dst) && ALIGNED32(size)) { - return zero_mem32(dst, size); - } else if (ALIGNED16(dst) && ALIGNED16(size)) { - return zero_mem16(dst, size); - } else { - return memset(dst, 0, size); - } +void *zero_mem(void *dst, unsigned int size) { + if (ALIGNED32(dst) && ALIGNED32(size)) { + return zero_mem32(dst, size); + } else if (ALIGNED16(dst) && ALIGNED16(size)) { + return zero_mem16(dst, size); + } else { + return memset(dst, 0, size); + } } - diff --git a/tests/anc_usb/mic_key.c b/tests/anc_usb/mic_key.c index fc710d6..6a11a23 100644 --- a/tests/anc_usb/mic_key.c +++ b/tests/anc_usb/mic_key.c @@ -15,140 +15,135 @@ ****************************************************************************/ #ifdef CFG_MIC_KEY +#include "analog.h" +#include "hal_gpadc.h" +#include "hal_iomux.h" #include "hal_timer.h" #include "hal_trace.h" #include "hwtimer_list.h" -#include "hal_iomux.h" -#include "hal_gpadc.h" -#include "analog.h" -#include "usb_audio.h" #include "tgt_hardware.h" +#include "usb_audio.h" -#define MIC_KEY_CHK_TIMES 20 -#define MIC_KEY_SKIP_CNT 8 -#define MIC_KEY_CHK_INTERVAL MS_TO_TICKS(1) // in ticks +#define MIC_KEY_CHK_TIMES 20 +#define MIC_KEY_SKIP_CNT 8 +#define MIC_KEY_CHK_INTERVAL MS_TO_TICKS(1) // in ticks static struct { - HWTIMER_ID chk_timer; + HWTIMER_ID chk_timer; - uint16_t chk_val[MIC_KEY_CHK_TIMES-MIC_KEY_SKIP_CNT]; + uint16_t chk_val[MIC_KEY_CHK_TIMES - MIC_KEY_SKIP_CNT]; - uint8_t chk_times; - uint8_t gpio_dn; - uint8_t key_dn[MIC_KEY_NUM]; + uint8_t chk_times; + uint8_t gpio_dn; + uint8_t key_dn[MIC_KEY_NUM]; } s_mic_key_ctx; -extern void mic_key_gpio_irq_set (void); +extern void mic_key_gpio_irq_set(void); -void mic_key_irq_hdl (uint16_t irq_val, HAL_GPADC_MV_T volt) -{ - hal_gpadc_close(mic_key_gpadc_chan); +void mic_key_irq_hdl(uint16_t irq_val, HAL_GPADC_MV_T volt) { + hal_gpadc_close(mic_key_gpadc_chan); - if (++s_mic_key_ctx.chk_times >= MIC_KEY_CHK_TIMES) { + if (++s_mic_key_ctx.chk_times >= MIC_KEY_CHK_TIMES) { - uint8_t i, j; - uint32_t mean; - - for (i = 0; i < MIC_KEY_NUM; i++) { - mean = 0; + uint8_t i, j; + uint32_t mean; - for (j = 0; j < MIC_KEY_CHK_TIMES-MIC_KEY_SKIP_CNT; j++) { - mean += (uint32_t)s_mic_key_ctx.chk_val[j]; - } - mean /= MIC_KEY_CHK_TIMES-MIC_KEY_SKIP_CNT; + for (i = 0; i < MIC_KEY_NUM; i++) { + mean = 0; - if ((mean > mic_key_cfg_lst[i].ref_vol_low) && (mean <= mic_key_cfg_lst[i].ref_vol_high)) - break; - } + for (j = 0; j < MIC_KEY_CHK_TIMES - MIC_KEY_SKIP_CNT; j++) { + mean += (uint32_t)s_mic_key_ctx.chk_val[j]; + } + mean /= MIC_KEY_CHK_TIMES - MIC_KEY_SKIP_CNT; - if (i < MIC_KEY_NUM) { - TRACE(2,"ana_key: key[%d] matched at [%dmv]", i, mean); - usb_audio_hid_set_event(mic_key_cfg_lst[i].hid_evt, 1); - s_mic_key_ctx.key_dn[i] = 1; - } else { - TRACE(1,"ana_key: no key matched [%dmv]", mean); - } - - return; + if ((mean > mic_key_cfg_lst[i].ref_vol_low) && + (mean <= mic_key_cfg_lst[i].ref_vol_high)) + break; } - if (s_mic_key_ctx.chk_times > MIC_KEY_SKIP_CNT) { - s_mic_key_ctx.chk_val[s_mic_key_ctx.chk_times - MIC_KEY_SKIP_CNT - 1] = volt; - } - - hwtimer_start(s_mic_key_ctx.chk_timer, MIC_KEY_CHK_INTERVAL); -} - -void mic_key_gpio_det_irq_hdl (enum HAL_GPIO_PIN_T pin) -{ - if (pin != mic_key_det_gpio_pin) - return; - - TRACE(1,"GPIO detected at status[%d]", s_mic_key_ctx.gpio_dn); - if (s_mic_key_ctx.gpio_dn) { - - uint8_t i; - - for (i = 0; i < MIC_KEY_NUM; i++) { - if (s_mic_key_ctx.key_dn[i]) { - break; - } - } - if (i < MIC_KEY_NUM) { - usb_audio_hid_set_event(mic_key_cfg_lst[i].hid_evt, 0); - s_mic_key_ctx.key_dn[i] = 0; - } - - s_mic_key_ctx.gpio_dn = 0; + if (i < MIC_KEY_NUM) { + TRACE(2, "ana_key: key[%d] matched at [%dmv]", i, mean); + usb_audio_hid_set_event(mic_key_cfg_lst[i].hid_evt, 1); + s_mic_key_ctx.key_dn[i] = 1; } else { - s_mic_key_ctx.chk_times = 0; - s_mic_key_ctx.gpio_dn = 1; - hal_gpadc_open(mic_key_gpadc_chan, HAL_GPADC_ATP_ONESHOT, mic_key_irq_hdl); + TRACE(1, "ana_key: no key matched [%dmv]", mean); } - mic_key_gpio_irq_set(); + return; + } + + if (s_mic_key_ctx.chk_times > MIC_KEY_SKIP_CNT) { + s_mic_key_ctx.chk_val[s_mic_key_ctx.chk_times - MIC_KEY_SKIP_CNT - 1] = + volt; + } + + hwtimer_start(s_mic_key_ctx.chk_timer, MIC_KEY_CHK_INTERVAL); } +void mic_key_gpio_det_irq_hdl(enum HAL_GPIO_PIN_T pin) { + if (pin != mic_key_det_gpio_pin) + return; -void mic_key_periodic_check (void* param) -{ + TRACE(1, "GPIO detected at status[%d]", s_mic_key_ctx.gpio_dn); + if (s_mic_key_ctx.gpio_dn) { + + uint8_t i; + + for (i = 0; i < MIC_KEY_NUM; i++) { + if (s_mic_key_ctx.key_dn[i]) { + break; + } + } + if (i < MIC_KEY_NUM) { + usb_audio_hid_set_event(mic_key_cfg_lst[i].hid_evt, 0); + s_mic_key_ctx.key_dn[i] = 0; + } + + s_mic_key_ctx.gpio_dn = 0; + } else { + s_mic_key_ctx.chk_times = 0; + s_mic_key_ctx.gpio_dn = 1; hal_gpadc_open(mic_key_gpadc_chan, HAL_GPADC_ATP_ONESHOT, mic_key_irq_hdl); + } + + mic_key_gpio_irq_set(); } -void mic_key_gpio_irq_set (void) -{ - struct HAL_GPIO_IRQ_CFG_T cfg; - - cfg.irq_debounce = 1; - cfg.irq_enable = 1; - cfg.irq_type = HAL_GPIO_IRQ_TYPE_EDGE_SENSITIVE; - if (s_mic_key_ctx.gpio_dn) { - cfg.irq_polarity = HAL_GPIO_IRQ_POLARITY_HIGH_RISING; - } else { - cfg.irq_polarity = HAL_GPIO_IRQ_POLARITY_LOW_FALLING; - } - cfg.irq_handler = mic_key_gpio_det_irq_hdl; - - hal_gpio_setup_irq(mic_key_det_gpio_pin, &cfg); +void mic_key_periodic_check(void *param) { + hal_gpadc_open(mic_key_gpadc_chan, HAL_GPADC_ATP_ONESHOT, mic_key_irq_hdl); } -void mic_key_open (void) -{ - struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_key_det[] = { - {0, HAL_IOMUX_FUNC_GPIO, HAL_IOMUX_PIN_VOLTAGE_MEM, HAL_IOMUX_PIN_NOPULL}, - }; +void mic_key_gpio_irq_set(void) { + struct HAL_GPIO_IRQ_CFG_T cfg; - TRACE(1,"%s", __func__); + cfg.irq_debounce = 1; + cfg.irq_enable = 1; + cfg.irq_type = HAL_GPIO_IRQ_TYPE_EDGE_SENSITIVE; + if (s_mic_key_ctx.gpio_dn) { + cfg.irq_polarity = HAL_GPIO_IRQ_POLARITY_HIGH_RISING; + } else { + cfg.irq_polarity = HAL_GPIO_IRQ_POLARITY_LOW_FALLING; + } + cfg.irq_handler = mic_key_gpio_det_irq_hdl; - pinmux_key_det[0].pin = mic_key_det_gpio_pin; - hal_iomux_init(pinmux_key_det, ARRAY_SIZE(pinmux_key_det)); - - analog_aud_mickey_enable(true); - - s_mic_key_ctx.chk_timer = hwtimer_alloc(mic_key_periodic_check, NULL); - hal_gpio_pin_set_dir(mic_key_det_gpio_pin, HAL_GPIO_DIR_IN, 0); - mic_key_gpio_irq_set(); + hal_gpio_setup_irq(mic_key_det_gpio_pin, &cfg); } +void mic_key_open(void) { + struct HAL_IOMUX_PIN_FUNCTION_MAP pinmux_key_det[] = { + {0, HAL_IOMUX_FUNC_GPIO, HAL_IOMUX_PIN_VOLTAGE_MEM, HAL_IOMUX_PIN_NOPULL}, + }; + + TRACE(1, "%s", __func__); + + pinmux_key_det[0].pin = mic_key_det_gpio_pin; + hal_iomux_init(pinmux_key_det, ARRAY_SIZE(pinmux_key_det)); + + analog_aud_mickey_enable(true); + + s_mic_key_ctx.chk_timer = hwtimer_alloc(mic_key_periodic_check, NULL); + hal_gpio_pin_set_dir(mic_key_det_gpio_pin, HAL_GPIO_DIR_IN, 0); + mic_key_gpio_irq_set(); +} #endif diff --git a/tests/anc_usb/safe_queue.c b/tests/anc_usb/safe_queue.c index 85c4091..c8ad328 100644 --- a/tests/anc_usb/safe_queue.c +++ b/tests/anc_usb/safe_queue.c @@ -13,149 +13,144 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "cmsis.h" #include "safe_queue.h" +#include "cmsis.h" #include "hal_trace.h" -void safe_queue_init(struct SAFE_QUEUE_T *queue, uint32_t *items, uint32_t size) -{ - // queue->first points to the first valid item - queue->first = 0; - // queue->last points to the first empty slot (beyond the last valid item) - queue->last = 0; - queue->count = 0; - queue->size = size; - queue->watermark = 0; - queue->items = items; +void safe_queue_init(struct SAFE_QUEUE_T *queue, uint32_t *items, + uint32_t size) { + // queue->first points to the first valid item + queue->first = 0; + // queue->last points to the first empty slot (beyond the last valid item) + queue->last = 0; + queue->count = 0; + queue->size = size; + queue->watermark = 0; + queue->items = items; } -int safe_queue_put(struct SAFE_QUEUE_T *queue, uint32_t item) -{ - int ret = 0; - uint32_t lock; +int safe_queue_put(struct SAFE_QUEUE_T *queue, uint32_t item) { + int ret = 0; + uint32_t lock; - lock = int_lock(); + lock = int_lock(); - if (queue->count >= queue->size) { - ret = 1; + if (queue->count >= queue->size) { + ret = 1; + } else { + queue->items[queue->last] = item; + queue->last++; + if (queue->last >= queue->size) { + queue->last = 0; + } + + queue->count++; + if (queue->count > queue->watermark) { + queue->watermark = queue->count; + } + } + + int_unlock(lock); + + return ret; +} + +int safe_queue_get(struct SAFE_QUEUE_T *queue, uint32_t *itemp) { + int ret = 0; + uint32_t lock; + + lock = int_lock(); + + if (queue->count == 0) { + ret = 1; + } else { + if (itemp) { + *itemp = queue->items[queue->first]; + } + queue->first++; + if (queue->first >= queue->size) { + queue->first = 0; + } + + queue->count--; + } + + int_unlock(lock); + + return ret; +} + +int safe_queue_pop(struct SAFE_QUEUE_T *queue, uint32_t *itemp) { + int ret = 0; + uint32_t lock; + + lock = int_lock(); + + if (queue->count == 0) { + ret = 1; + } else { + if (queue->last) { + queue->last--; } else { - queue->items[queue->last] = item; - queue->last++; - if (queue->last >= queue->size) { - queue->last = 0; - } - - queue->count++; - if (queue->count > queue->watermark) { - queue->watermark = queue->count; - } + queue->last = queue->size - 1; + } + if (itemp) { + *itemp = queue->items[queue->last]; } - int_unlock(lock); + queue->count--; + } - return ret; + int_unlock(lock); + + return ret; } -int safe_queue_get(struct SAFE_QUEUE_T *queue, uint32_t *itemp) -{ - int ret = 0; - uint32_t lock; +int safe_queue_peek(const struct SAFE_QUEUE_T *queue, int offset, + uint32_t *itemp) { + int ret = 0; + uint32_t lock; + uint8_t idx; - lock = int_lock(); + lock = int_lock(); - if (queue->count == 0) { - ret = 1; - } else { - if (itemp) { - *itemp = queue->items[queue->first]; - } - queue->first++; - if (queue->first >= queue->size) { - queue->first = 0; - } + if (offset >= 0 && offset < queue->count) { + idx = queue->first + offset; + } else if (offset < 0 && -offset <= queue->count) { + idx = queue->size + queue->last + offset; + } else { + ret = 1; + } - queue->count--; + if (ret == 0) { + if (idx >= queue->size) { + idx -= queue->size; } - int_unlock(lock); + *itemp = queue->items[idx]; + } - return ret; + int_unlock(lock); + + return ret; } -int safe_queue_pop(struct SAFE_QUEUE_T *queue, uint32_t *itemp) -{ - int ret = 0; - uint32_t lock; +uint32_t safe_queue_watermark(const struct SAFE_QUEUE_T *queue) { + return queue->watermark; +} - lock = int_lock(); +int safe_queue_dump(const struct SAFE_QUEUE_T *queue) { + uint32_t cnt; + int i; + uint32_t item; - if (queue->count == 0) { - ret = 1; - } else { - if (queue->last) { - queue->last--; - } else { - queue->last = queue->size - 1; - } - if (itemp) { - *itemp = queue->items[queue->last]; - } - - queue->count--; + cnt = queue->count; + for (i = 0; i < cnt; i++) { + if (safe_queue_peek(queue, i, &item)) { + break; } + TRACE_IMM(3, "SAFE-QUEUE-DUMP: [%02d/%02d] 0x%08x", i, cnt, item); + } - int_unlock(lock); - - return ret; -} - -int safe_queue_peek(const struct SAFE_QUEUE_T *queue, int offset, uint32_t *itemp) -{ - int ret = 0; - uint32_t lock; - uint8_t idx; - - lock = int_lock(); - - if (offset >= 0 && offset < queue->count) { - idx = queue->first + offset; - } else if (offset < 0 && -offset <= queue->count) { - idx = queue->size + queue->last + offset; - } else { - ret = 1; - } - - if (ret == 0) { - if (idx >= queue->size) { - idx -= queue->size; - } - - *itemp = queue->items[idx]; - } - - int_unlock(lock); - - return ret; -} - -uint32_t safe_queue_watermark(const struct SAFE_QUEUE_T *queue) -{ - return queue->watermark; -} - -int safe_queue_dump(const struct SAFE_QUEUE_T *queue) -{ - uint32_t cnt; - int i; - uint32_t item; - - cnt = queue->count; - for (i = 0; i < cnt; i++) { - if (safe_queue_peek(queue, i, &item)) { - break; - } - TRACE_IMM(3,"SAFE-QUEUE-DUMP: [%02d/%02d] 0x%08x", i, cnt, item); - } - - return 0; + return 0; } diff --git a/tests/anc_usb/speech_process.c b/tests/anc_usb/speech_process.c index a0dbebd..89a56a6 100644 --- a/tests/anc_usb/speech_process.c +++ b/tests/anc_usb/speech_process.c @@ -14,10 +14,10 @@ * ****************************************************************************/ #include "speech_process.h" +#include "cmsis.h" +#include "hal_sysfreq.h" #include "hal_timer.h" #include "hal_trace.h" -#include "hal_sysfreq.h" -#include "cmsis.h" #if defined(SPEECH_TX_AEC2FLOAT) && !defined(KEEP_SAME_LATENCY) #error "capture/playback size should be equal when enable AEC" @@ -25,13 +25,13 @@ #include "bt_sco_chain.h" #include "iir_resample.h" -#include "speech_utils.h" #include "speech_memory.h" +#include "speech_utils.h" -#define MED_MEM_POOL_SIZE (1024*160) +#define MED_MEM_POOL_SIZE (1024 * 160) static uint8_t g_medMemPool[MED_MEM_POOL_SIZE]; -#define FFSE_SAMPLE_RATE (16000) +#define FFSE_SAMPLE_RATE (16000) int capture_channel_num = 1; int capture_sample_rate = 48000; @@ -56,206 +56,224 @@ static IirResampleState *rx_downsample_st; static volatile bool is_speech_init = false; -static void speech_deinterleave(int16_t *in, int16_t *out, int len, int ch_num) -{ - int len_per_channel = len / ch_num; +static void speech_deinterleave(int16_t *in, int16_t *out, int len, + int ch_num) { + int len_per_channel = len / ch_num; - for (int i = 0, j = 0; i < len; i += ch_num, j++) { - int16_t *pout = &out[j]; - int16_t *pin = &in[i]; - for (int c= 0; c < ch_num; c++) { - *pout = *pin; - pout += len_per_channel; - pin += 1; - } + for (int i = 0, j = 0; i < len; i += ch_num, j++) { + int16_t *pout = &out[j]; + int16_t *pin = &in[i]; + for (int c = 0; c < ch_num; c++) { + *pout = *pin; + pout += len_per_channel; + pin += 1; } + } } -static void speech_interleave(int16_t *in, int16_t *out, int len, int ch_num) -{ - int len_per_channel = len / ch_num; +static void speech_interleave(int16_t *in, int16_t *out, int len, int ch_num) { + int len_per_channel = len / ch_num; - for (int i = 0, j = 0; j < len; i++, j += ch_num) { - int16_t *pout = &out[j]; - int16_t *pin = &in[i]; - for (int c= 0; c < ch_num; c++) { - *pout = *pin; - pout += 1; - pin += len_per_channel; - } + for (int i = 0, j = 0; j < len; i++, j += ch_num) { + int16_t *pout = &out[j]; + int16_t *pin = &in[i]; + for (int c = 0; c < ch_num; c++) { + *pout = *pin; + pout += 1; + pin += len_per_channel; } + } } -static void speech_extend(int16_t *in, int16_t *out, int len, int ch_num) -{ - int16_t *pout = out + len * ch_num - 1; - for (int i = len - 1; i >= 0; i--) { - for (int c= 0; c < ch_num; c++) { - *pout-- = in[i]; - } +static void speech_extend(int16_t *in, int16_t *out, int len, int ch_num) { + int16_t *pout = out + len * ch_num - 1; + for (int i = len - 1; i >= 0; i--) { + for (int c = 0; c < ch_num; c++) { + *pout-- = in[i]; } + } } // This function output remains the same sample rate as input, // output channel number shoule be CHAN_NUM_SEND. // TODO: add multi-channel support in iir resampler -void speech_process_capture_run(uint8_t *buf, uint32_t *len) -{ - //TRACE(2,"[%s], pcm_len: %d", __FUNCTION__, *len / 2); +void speech_process_capture_run(uint8_t *buf, uint32_t *len) { + // TRACE(2,"[%s], pcm_len: %d", __FUNCTION__, *len / 2); - if (is_speech_init == false) - return; + if (is_speech_init == false) + return; - int16_t *pcm_buf = (int16_t *)buf; - int pcm_len = *len / 2; - int process_len = pcm_len * FFSE_SAMPLE_RATE / capture_sample_rate; + int16_t *pcm_buf = (int16_t *)buf; + int pcm_len = *len / 2; + int process_len = pcm_len * FFSE_SAMPLE_RATE / capture_sample_rate; - if (resample_needed_flag == true) { - if (capture_channel_num > 1) - speech_deinterleave(pcm_buf, capture_buffer_deinter, pcm_len, capture_channel_num); - else - speech_copy_int16(capture_buffer_deinter, pcm_buf, pcm_len); + if (resample_needed_flag == true) { + if (capture_channel_num > 1) + speech_deinterleave(pcm_buf, capture_buffer_deinter, pcm_len, + capture_channel_num); + else + speech_copy_int16(capture_buffer_deinter, pcm_buf, pcm_len); - int in_len_per_channel = pcm_len / capture_channel_num; - int out_len_per_channel = process_len / capture_channel_num; - for (int i = 0; i < capture_channel_num; i++) { - iir_resample_process(downsample_st[i], &capture_buffer_deinter[i * in_len_per_channel], - &process_buffer[i * out_len_per_channel], in_len_per_channel); - } - - if (capture_channel_num > 1) - speech_interleave(process_buffer, process_buffer_inter, process_len, capture_channel_num); - else - speech_copy_int16(process_buffer_inter, process_buffer, process_len); - - speech_tx_process(process_buffer_inter, aec_echo_buf, &process_len); - - iir_resample_process(upsample_st, process_buffer_inter, pcm_buf, process_len); - - if (send_channel_num > 1) - speech_extend(pcm_buf, pcm_buf, in_len_per_channel, send_channel_num); - } else { - speech_tx_process(pcm_buf, aec_echo_buf, &process_len); - - if (send_channel_num > 1) - speech_extend(pcm_buf, pcm_buf, process_len, send_channel_num); + int in_len_per_channel = pcm_len / capture_channel_num; + int out_len_per_channel = process_len / capture_channel_num; + for (int i = 0; i < capture_channel_num; i++) { + iir_resample_process( + downsample_st[i], &capture_buffer_deinter[i * in_len_per_channel], + &process_buffer[i * out_len_per_channel], in_len_per_channel); } - pcm_len = pcm_len / capture_channel_num * send_channel_num; - *len = pcm_len * sizeof(int16_t); + if (capture_channel_num > 1) + speech_interleave(process_buffer, process_buffer_inter, process_len, + capture_channel_num); + else + speech_copy_int16(process_buffer_inter, process_buffer, process_len); + + speech_tx_process(process_buffer_inter, aec_echo_buf, &process_len); + + iir_resample_process(upsample_st, process_buffer_inter, pcm_buf, + process_len); + + if (send_channel_num > 1) + speech_extend(pcm_buf, pcm_buf, in_len_per_channel, send_channel_num); + } else { + speech_tx_process(pcm_buf, aec_echo_buf, &process_len); + + if (send_channel_num > 1) + speech_extend(pcm_buf, pcm_buf, process_len, send_channel_num); + } + + pcm_len = pcm_len / capture_channel_num * send_channel_num; + *len = pcm_len * sizeof(int16_t); } -void speech_process_playback_run(uint8_t *buf, uint32_t *len) -{ - //TRACE(2,"[%s] pcm_len: %d", __FUNCTION__, *len / 2); +void speech_process_playback_run(uint8_t *buf, uint32_t *len) { + // TRACE(2,"[%s] pcm_len: %d", __FUNCTION__, *len / 2); - if (is_speech_init == false) - return; + if (is_speech_init == false) + return; #if defined(SPEECH_TX_AEC2FLOAT) - int16_t *pcm_buf = (int16_t *)buf; - int pcm_len = *len / 2; + int16_t *pcm_buf = (int16_t *)buf; + int pcm_len = *len / 2; - if (resample_needed_flag == true) { - // Convert to 16bit if necessary - if (playback_sample_bit == 24) { - int32_t *pcm32 = (int32_t *)buf; - for (int i = 0; i < pcm_len / 2; i++) { - pcm_buf[i] = (pcm32[i] >> 8); - } - pcm_len >>= 1; - } - - // Convert to mono if necessary, choose left channel - if (playback_channel_num == 2) { - for (int i = 0, j = 0; i < pcm_len; i += 2, j++) - pcm_buf[j] = pcm_buf[i]; - pcm_len >>= 1; - } - - iir_resample_process(rx_downsample_st, pcm_buf, pcm_buf, pcm_len); + if (resample_needed_flag == true) { + // Convert to 16bit if necessary + if (playback_sample_bit == 24) { + int32_t *pcm32 = (int32_t *)buf; + for (int i = 0; i < pcm_len / 2; i++) { + pcm_buf[i] = (pcm32[i] >> 8); + } + pcm_len >>= 1; } - speech_copy_int16(aec_echo_buf, pcm_buf, pcm_len * FFSE_SAMPLE_RATE / capture_sample_rate); + + // Convert to mono if necessary, choose left channel + if (playback_channel_num == 2) { + for (int i = 0, j = 0; i < pcm_len; i += 2, j++) + pcm_buf[j] = pcm_buf[i]; + pcm_len >>= 1; + } + + iir_resample_process(rx_downsample_st, pcm_buf, pcm_buf, pcm_len); + } + speech_copy_int16(aec_echo_buf, pcm_buf, + pcm_len * FFSE_SAMPLE_RATE / capture_sample_rate); #endif } -void speech_process_init(int tx_sample_rate, int tx_channel_num, int tx_sample_bit, - int rx_sample_rate, int rx_channel_num, int rx_sample_bit, - int tx_frame_ms, int rx_frame_ms, - int tx_send_channel_num, int rx_recv_channel_num) -{ - ASSERT(tx_sample_rate == 16000 || tx_sample_rate == 48000, "[%s] sample rate(%d) not supported", __FUNCTION__, tx_sample_rate); - ASSERT(tx_frame_ms == 16, "[%s] just support 16ms frame", __func__); +void speech_process_init(int tx_sample_rate, int tx_channel_num, + int tx_sample_bit, int rx_sample_rate, + int rx_channel_num, int rx_sample_bit, int tx_frame_ms, + int rx_frame_ms, int tx_send_channel_num, + int rx_recv_channel_num) { + ASSERT(tx_sample_rate == 16000 || tx_sample_rate == 48000, + "[%s] sample rate(%d) not supported", __FUNCTION__, tx_sample_rate); + ASSERT(tx_frame_ms == 16, "[%s] just support 16ms frame", __func__); - capture_sample_rate = tx_sample_rate; - capture_channel_num = tx_channel_num; - capture_sample_bit = tx_sample_bit; - playback_sample_rate = rx_sample_rate; - playback_channel_num = rx_channel_num; - playback_sample_bit = rx_sample_bit; + capture_sample_rate = tx_sample_rate; + capture_channel_num = tx_channel_num; + capture_sample_bit = tx_sample_bit; + playback_sample_rate = rx_sample_rate; + playback_channel_num = rx_channel_num; + playback_sample_bit = rx_sample_bit; - send_channel_num = tx_send_channel_num; - recv_channel_num = rx_recv_channel_num; + send_channel_num = tx_send_channel_num; + recv_channel_num = rx_recv_channel_num; - resample_needed_flag = (capture_sample_rate != FFSE_SAMPLE_RATE); + resample_needed_flag = (capture_sample_rate != FFSE_SAMPLE_RATE); - TRACE(5,"[%s] sample_rate: %d, frame_ms: %d, channel_num: %d, resample_needed_flag: %d", __FUNCTION__, - tx_sample_rate, tx_frame_ms, tx_channel_num, resample_needed_flag); + TRACE(5, + "[%s] sample_rate: %d, frame_ms: %d, channel_num: %d, " + "resample_needed_flag: %d", + __FUNCTION__, tx_sample_rate, tx_frame_ms, tx_channel_num, + resample_needed_flag); - speech_init(FFSE_SAMPLE_RATE, FFSE_SAMPLE_RATE, tx_frame_ms, tx_frame_ms, tx_frame_ms, &g_medMemPool[0], MED_MEM_POOL_SIZE); + speech_init(FFSE_SAMPLE_RATE, FFSE_SAMPLE_RATE, tx_frame_ms, tx_frame_ms, + tx_frame_ms, &g_medMemPool[0], MED_MEM_POOL_SIZE); - if (resample_needed_flag == true) { - capture_buffer_deinter = speech_calloc(SPEECH_FRAME_MS_TO_LEN(capture_sample_rate, tx_frame_ms) * capture_channel_num, sizeof(int16_t)); + if (resample_needed_flag == true) { + capture_buffer_deinter = + speech_calloc(SPEECH_FRAME_MS_TO_LEN(capture_sample_rate, tx_frame_ms) * + capture_channel_num, + sizeof(int16_t)); - // Resample state must be created after speech init, as it uses speech heap - process_buffer = speech_calloc(SPEECH_FRAME_MS_TO_LEN(FFSE_SAMPLE_RATE, tx_frame_ms) * capture_channel_num, sizeof(int16_t)); - process_buffer_inter = speech_calloc(SPEECH_FRAME_MS_TO_LEN(FFSE_SAMPLE_RATE, tx_frame_ms) * capture_channel_num, sizeof(int16_t)); + // Resample state must be created after speech init, as it uses speech heap + process_buffer = + speech_calloc(SPEECH_FRAME_MS_TO_LEN(FFSE_SAMPLE_RATE, tx_frame_ms) * + capture_channel_num, + sizeof(int16_t)); + process_buffer_inter = + speech_calloc(SPEECH_FRAME_MS_TO_LEN(FFSE_SAMPLE_RATE, tx_frame_ms) * + capture_channel_num, + sizeof(int16_t)); - upsample_st = iir_resample_init(SPEECH_FRAME_MS_TO_LEN(FFSE_SAMPLE_RATE, tx_frame_ms), iir_resample_choose_mode(FFSE_SAMPLE_RATE, capture_sample_rate)); + upsample_st = iir_resample_init( + SPEECH_FRAME_MS_TO_LEN(FFSE_SAMPLE_RATE, tx_frame_ms), + iir_resample_choose_mode(FFSE_SAMPLE_RATE, capture_sample_rate)); - // as iir resample can only deal with mono signal, we should init channel_num states - for (int i = 0; i < capture_channel_num; i++) { - downsample_st[i] = iir_resample_init(SPEECH_FRAME_MS_TO_LEN(capture_sample_rate, tx_frame_ms), iir_resample_choose_mode(capture_sample_rate, FFSE_SAMPLE_RATE)); - } - - // - aec_echo_buf = speech_calloc(SPEECH_FRAME_MS_TO_LEN(FFSE_SAMPLE_RATE, rx_frame_ms), sizeof(int16_t)); - rx_downsample_st = iir_resample_init(SPEECH_FRAME_MS_TO_LEN(playback_sample_rate, rx_frame_ms), iir_resample_choose_mode(playback_sample_rate, FFSE_SAMPLE_RATE)); + // as iir resample can only deal with mono signal, we should init + // channel_num states + for (int i = 0; i < capture_channel_num; i++) { + downsample_st[i] = iir_resample_init( + SPEECH_FRAME_MS_TO_LEN(capture_sample_rate, tx_frame_ms), + iir_resample_choose_mode(capture_sample_rate, FFSE_SAMPLE_RATE)); } - is_speech_init = true; + // + aec_echo_buf = speech_calloc( + SPEECH_FRAME_MS_TO_LEN(FFSE_SAMPLE_RATE, rx_frame_ms), sizeof(int16_t)); + rx_downsample_st = iir_resample_init( + SPEECH_FRAME_MS_TO_LEN(playback_sample_rate, rx_frame_ms), + iir_resample_choose_mode(playback_sample_rate, FFSE_SAMPLE_RATE)); + } + + is_speech_init = true; } -void speech_process_deinit(void) -{ - if (is_speech_init == false) - return; +void speech_process_deinit(void) { + if (is_speech_init == false) + return; - if (resample_needed_flag == true) { - speech_free(capture_buffer_deinter); + if (resample_needed_flag == true) { + speech_free(capture_buffer_deinter); - speech_free(process_buffer); - speech_free(process_buffer_inter); + speech_free(process_buffer); + speech_free(process_buffer_inter); - iir_resample_destroy(upsample_st); + iir_resample_destroy(upsample_st); - for (int i = 0; i < capture_channel_num; i++) { - iir_resample_destroy(downsample_st[i]); - } - - speech_free(aec_echo_buf); - iir_resample_destroy(rx_downsample_st); - - resample_needed_flag = false; + for (int i = 0; i < capture_channel_num; i++) { + iir_resample_destroy(downsample_st[i]); } - speech_deinit(); + speech_free(aec_echo_buf); + iir_resample_destroy(rx_downsample_st); - is_speech_init = false; -} - -enum HAL_CMU_FREQ_T speech_process_need_freq(void) -{ - return HAL_CMU_FREQ_208M; + resample_needed_flag = false; + } + + speech_deinit(); + + is_speech_init = false; } +enum HAL_CMU_FREQ_T speech_process_need_freq(void) { return HAL_CMU_FREQ_208M; } diff --git a/tests/anc_usb/usb_audio_app.c b/tests/anc_usb/usb_audio_app.c index 0ab47a7..61c6efa 100644 --- a/tests/anc_usb/usb_audio_app.c +++ b/tests/anc_usb/usb_audio_app.c @@ -13,35 +13,35 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "usb_audio_app.h" +#include "analog.h" +#include "audio_resample_ex.h" +#include "audioflinger.h" +#include "cmsis.h" +#include "hal_aud.h" +#include "hal_codec.h" +#include "hal_location.h" +#include "hal_sleep.h" +#include "hal_sysfreq.h" #include "hal_timer.h" #include "hal_trace.h" -#include "hal_sysfreq.h" -#include "hal_aud.h" -#include "hal_sleep.h" -#include "hal_location.h" -#include "hal_codec.h" -#include "string.h" -#include "pmu.h" -#include "analog.h" -#include "audioflinger.h" -#include "usb_audio.h" -#include "usb_audio_sync.h" -#include "usb_audio_app.h" -#include "usb_audio_frm_defs.h" -#include "cmsis.h" -#include "safe_queue.h" #include "memutils.h" -#include "tgt_hardware.h" -#include "audio_resample_ex.h" +#include "pmu.h" #include "resample_coef.h" +#include "safe_queue.h" +#include "string.h" +#include "tgt_hardware.h" +#include "usb_audio.h" +#include "usb_audio_frm_defs.h" +#include "usb_audio_sync.h" #ifdef _VENDOR_MSG_SUPPT_ #include "usb_vendor_msg.h" #endif #if defined(USB_AUDIO_SPEECH) -#include "speech_process.h" #include "app_overlay.h" +#include "speech_process.h" #endif #if defined(__HW_FIR_DSD_PROCESS__) @@ -49,7 +49,7 @@ #endif #if defined(AUDIO_ANC_FB_MC) -#include"anc_process.h" +#include "anc_process.h" #endif #include "hw_codec_iir_process.h" @@ -74,7 +74,8 @@ #endif // __AUDIO_RESAMPLE__ #ifdef CODEC_DSD -#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__)|| defined(__HW_IIR_EQ_PROCESS__) || defined(__HW_DAC_IIR_EQ_PROCESS__) +#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__) || \ + defined(__HW_IIR_EQ_PROCESS__) || defined(__HW_DAC_IIR_EQ_PROCESS__) #error "EQ conflicts with CODEC_DSD" #endif #ifdef FREQ_RESP_EQ @@ -96,22 +97,22 @@ #if defined(__SW_IIR_EQ_PROCESS__) static uint8_t audio_eq_sw_iir_index = 0; -extern const IIR_CFG_T * const audio_eq_sw_iir_cfg_list[]; +extern const IIR_CFG_T *const audio_eq_sw_iir_cfg_list[]; #endif #if defined(__HW_FIR_EQ_PROCESS__) static uint8_t audio_eq_hw_fir_index = 0; -extern const FIR_CFG_T * const audio_eq_hw_fir_cfg_list[]; +extern const FIR_CFG_T *const audio_eq_hw_fir_cfg_list[]; #endif #if defined(__HW_DAC_IIR_EQ_PROCESS__) static uint8_t audio_eq_hw_dac_iir_index = 0; -extern const IIR_CFG_T * const audio_eq_hw_dac_iir_cfg_list[]; +extern const IIR_CFG_T *const audio_eq_hw_dac_iir_cfg_list[]; #endif #if defined(__HW_IIR_EQ_PROCESS__) static uint8_t audio_eq_hw_iir_index = 0; -extern const IIR_CFG_T * const audio_eq_hw_iir_cfg_list[]; +extern const IIR_CFG_T *const audio_eq_hw_iir_cfg_list[]; #endif #define KEY_TRACE @@ -133,7 +134,8 @@ extern const IIR_CFG_T * const audio_eq_hw_iir_cfg_list[]; #if defined(__AUDIO_RESAMPLE__) && defined(PLL_TUNE_SAMPLE_RATE) #define UAUD_SYNC_STREAM_TARGET #else -#error "TARGET_TO_MAX_DIFF can be enabled only with __AUDIO_RESAMPLE__ and PLL_TUNE_SAMPLE_RATE if both playback and capture streams exist" +#error \ + "TARGET_TO_MAX_DIFF can be enabled only with __AUDIO_RESAMPLE__ and PLL_TUNE_SAMPLE_RATE if both playback and capture streams exist" #endif #endif @@ -142,162 +144,208 @@ extern const IIR_CFG_T * const audio_eq_hw_iir_cfg_list[]; #endif #endif // TARGET_TO_MAX_DIFF -#define VERBOSE_TRACE 0 //0xFFFF +#define VERBOSE_TRACE 0 // 0xFFFF #ifdef TIMER1_BASE -#define TRACE_TIME(num,s, ...) TRACE(num+1,"[%u] " s, FAST_TICKS_TO_US(hal_fast_sys_timer_get()), ##__VA_ARGS__) +#define TRACE_TIME(num, s, ...) \ + TRACE(num + 1, "[%u] " s, FAST_TICKS_TO_US(hal_fast_sys_timer_get()), \ + ##__VA_ARGS__) #else -#define TRACE_TIME(num,s, ...) TRACE(num+1,"[%X] " s, hal_sys_timer_get(), ##__VA_ARGS__) +#define TRACE_TIME(num, s, ...) \ + TRACE(num + 1, "[%X] " s, hal_sys_timer_get(), ##__VA_ARGS__) #endif -#define USB_AUDIO_CPU_WAKE_USER HAL_CPU_WAKE_LOCK_USER_3 +#define USB_AUDIO_CPU_WAKE_USER HAL_CPU_WAKE_LOCK_USER_3 -#define RECV_PAUSED_SAMPLE_RATE_FLAG (1 << 31) +#define RECV_PAUSED_SAMPLE_RATE_FLAG (1 << 31) -#define DIFF_ERR_THRESH_PLAYBACK (sample_rate_recv / 1000 / 2) -#define DIFF_ERR_THRESH_CAPTURE (sample_rate_send / 1000 / 2) +#define DIFF_ERR_THRESH_PLAYBACK (sample_rate_recv / 1000 / 2) +#define DIFF_ERR_THRESH_CAPTURE (sample_rate_send / 1000 / 2) -#define DIFF_SYNC_THRESH_PLAYBACK 10 -#define DIFF_SYNC_THRESH_CAPTURE 10 +#define DIFF_SYNC_THRESH_PLAYBACK 10 +#define DIFF_SYNC_THRESH_CAPTURE 10 -#define DIFF_AVG_CNT 30 +#define DIFF_AVG_CNT 30 -#define MAX_TARGET_RATIO 0.000020f +#define MAX_TARGET_RATIO 0.000020f -#define MIN_VOLUME_VAL (TGT_VOLUME_LEVEL_MUTE) -#define MAX_VOLUME_VAL (TGT_VOLUME_LEVEL_QTY - 1) +#define MIN_VOLUME_VAL (TGT_VOLUME_LEVEL_MUTE) +#define MAX_VOLUME_VAL (TGT_VOLUME_LEVEL_QTY - 1) -#define MIN_CAP_VOLUME_VAL (TGT_ADC_VOL_LEVEL_0) -#define MAX_CAP_VOLUME_VAL (TGT_ADC_VOL_LEVEL_QTY - 1) +#define MIN_CAP_VOLUME_VAL (TGT_ADC_VOL_LEVEL_0) +#define MAX_CAP_VOLUME_VAL (TGT_ADC_VOL_LEVEL_QTY - 1) -#define NOISE_GATING_INTERVAL MS_TO_TICKS(800) -#define NOISE_GATING_THRESH_16BIT 3 // -80dB -#define NOISE_GATING_THRESH_24BIT (NOISE_GATING_THRESH_16BIT << 8) +#define NOISE_GATING_INTERVAL MS_TO_TICKS(800) +#define NOISE_GATING_THRESH_16BIT 3 // -80dB +#define NOISE_GATING_THRESH_24BIT (NOISE_GATING_THRESH_16BIT << 8) -#define NOISE_REDUCTION_INTERVAL MS_TO_TICKS(100) -#define NOISE_REDUCTION_MATCH_CNT 200 -#define NOISE_REDUCTION_THRESH_16BIT 100 // -50dB -#define NOISE_REDUCTION_THRESH_24BIT (NOISE_REDUCTION_THRESH_16BIT << 8) +#define NOISE_REDUCTION_INTERVAL MS_TO_TICKS(100) +#define NOISE_REDUCTION_MATCH_CNT 200 +#define NOISE_REDUCTION_THRESH_16BIT 100 // -50dB +#define NOISE_REDUCTION_THRESH_24BIT (NOISE_REDUCTION_THRESH_16BIT << 8) -#define CONFLICT_CMD_TRIG_COUNT 10 -#define CONFLICT_CMD_TRIG_INTERVAL MS_TO_TICKS(20000) -#define CONFLICT_STATE_RESET_INTERVAL MS_TO_TICKS(10000) +#define CONFLICT_CMD_TRIG_COUNT 10 +#define CONFLICT_CMD_TRIG_INTERVAL MS_TO_TICKS(20000) +#define CONFLICT_STATE_RESET_INTERVAL MS_TO_TICKS(10000) -#define CAPTURE_STABLE_INTERVAL MS_TO_TICKS(200) +#define CAPTURE_STABLE_INTERVAL MS_TO_TICKS(200) -#define USB_MAX_XFER_INTERVAL MS_TO_TICKS(10) +#define USB_MAX_XFER_INTERVAL MS_TO_TICKS(10) -#define USB_XFER_ERR_REPORT_INTERVAL MS_TO_TICKS(5000) +#define USB_XFER_ERR_REPORT_INTERVAL MS_TO_TICKS(5000) -#define USB_AUDIO_MIN_DBVAL (-99) +#define USB_AUDIO_MIN_DBVAL (-99) -#define USB_AUDIO_VOL_UPDATE_STEP 0.00002 +#define USB_AUDIO_VOL_UPDATE_STEP 0.00002 #ifndef USB_AUDIO_KEY_MAP #ifdef ANDROID_ACCESSORY_SPEC #ifdef ANDROID_VOICE_CMD_KEY -#define USB_AUDIO_KEY_VOICE_CMD \ - { USB_AUDIO_HID_VOICE_CMD, HAL_KEY_CODE_FN4, KEY_EVENT_SET2(DOWN, UP), }, +#define USB_AUDIO_KEY_VOICE_CMD \ + { \ + USB_AUDIO_HID_VOICE_CMD, \ + HAL_KEY_CODE_FN4, \ + KEY_EVENT_SET2(DOWN, UP), \ + }, #else #define USB_AUDIO_KEY_VOICE_CMD #endif -#define USB_AUDIO_KEY_MAP { \ - { USB_AUDIO_HID_PLAY_PAUSE, HAL_KEY_CODE_FN1, KEY_EVENT_SET2(DOWN, UP), }, \ - { USB_AUDIO_HID_VOL_UP, HAL_KEY_CODE_FN2, KEY_EVENT_SET2(DOWN, UP), }, \ - { USB_AUDIO_HID_VOL_DOWN, HAL_KEY_CODE_FN3, KEY_EVENT_SET2(DOWN, UP), }, \ - USB_AUDIO_KEY_VOICE_CMD \ -} +#define USB_AUDIO_KEY_MAP \ + { \ + { \ + USB_AUDIO_HID_PLAY_PAUSE, \ + HAL_KEY_CODE_FN1, \ + KEY_EVENT_SET2(DOWN, UP), \ + }, \ + { \ + USB_AUDIO_HID_VOL_UP, \ + HAL_KEY_CODE_FN2, \ + KEY_EVENT_SET2(DOWN, UP), \ + }, \ + { \ + USB_AUDIO_HID_VOL_DOWN, \ + HAL_KEY_CODE_FN3, \ + KEY_EVENT_SET2(DOWN, UP), \ + }, \ + USB_AUDIO_KEY_VOICE_CMD \ + } #else -#define USB_AUDIO_KEY_MAP { \ - { USB_AUDIO_HID_PLAY_PAUSE, HAL_KEY_CODE_FN1, KEY_EVENT_SET(CLICK), }, \ - { USB_AUDIO_HID_SCAN_NEXT, HAL_KEY_CODE_FN1, KEY_EVENT_SET(DOUBLECLICK), }, \ - { USB_AUDIO_HID_SCAN_PREV, HAL_KEY_CODE_FN1, KEY_EVENT_SET(TRIPLECLICK), }, \ - { USB_AUDIO_HID_VOL_UP, HAL_KEY_CODE_FN2, KEY_EVENT_SET4(CLICK, DOUBLECLICK, TRIPLECLICK, REPEAT), }, \ - { USB_AUDIO_HID_VOL_DOWN, HAL_KEY_CODE_FN3, KEY_EVENT_SET4(CLICK, DOUBLECLICK, TRIPLECLICK, REPEAT), }, \ - { USB_AUDIO_HID_HOOK_SWITCH, HAL_KEY_CODE_FN4, KEY_EVENT_SET(CLICK), }, \ -} +#define USB_AUDIO_KEY_MAP \ + { \ + { \ + USB_AUDIO_HID_PLAY_PAUSE, \ + HAL_KEY_CODE_FN1, \ + KEY_EVENT_SET(CLICK), \ + }, \ + { \ + USB_AUDIO_HID_SCAN_NEXT, \ + HAL_KEY_CODE_FN1, \ + KEY_EVENT_SET(DOUBLECLICK), \ + }, \ + { \ + USB_AUDIO_HID_SCAN_PREV, \ + HAL_KEY_CODE_FN1, \ + KEY_EVENT_SET(TRIPLECLICK), \ + }, \ + { \ + USB_AUDIO_HID_VOL_UP, \ + HAL_KEY_CODE_FN2, \ + KEY_EVENT_SET4(CLICK, DOUBLECLICK, TRIPLECLICK, REPEAT), \ + }, \ + { \ + USB_AUDIO_HID_VOL_DOWN, \ + HAL_KEY_CODE_FN3, \ + KEY_EVENT_SET4(CLICK, DOUBLECLICK, TRIPLECLICK, REPEAT), \ + }, \ + { \ + USB_AUDIO_HID_HOOK_SWITCH, \ + HAL_KEY_CODE_FN4, \ + KEY_EVENT_SET(CLICK), \ + }, \ + } #endif #endif enum AUDIO_CMD_T { - AUDIO_CMD_START_PLAY = 0, - AUDIO_CMD_STOP_PLAY, - AUDIO_CMD_START_CAPTURE, - AUDIO_CMD_STOP_CAPTURE, - AUDIO_CMD_SET_VOLUME, - AUDIO_CMD_SET_CAP_VOLUME, - AUDIO_CMD_MUTE_CTRL, - AUDIO_CMD_CAP_MUTE_CTRL, - AUDIO_CMD_USB_RESET, - AUDIO_CMD_USB_DISCONNECT, - AUDIO_CMD_USB_CONFIG, - AUDIO_CMD_USB_SLEEP, - AUDIO_CMD_USB_WAKEUP, - AUDIO_CMD_RECV_PAUSE, - AUDIO_CMD_RECV_CONTINUE, - AUDIO_CMD_SET_RECV_RATE, - AUDIO_CMD_SET_SEND_RATE, - AUDIO_CMD_RESET_CODEC, - AUDIO_CMD_NOISE_GATING, - AUDIO_CMD_NOISE_REDUCTION, - AUDIO_CMD_TUNE_RATE, - AUDIO_CMD_SET_DSD_CFG, + AUDIO_CMD_START_PLAY = 0, + AUDIO_CMD_STOP_PLAY, + AUDIO_CMD_START_CAPTURE, + AUDIO_CMD_STOP_CAPTURE, + AUDIO_CMD_SET_VOLUME, + AUDIO_CMD_SET_CAP_VOLUME, + AUDIO_CMD_MUTE_CTRL, + AUDIO_CMD_CAP_MUTE_CTRL, + AUDIO_CMD_USB_RESET, + AUDIO_CMD_USB_DISCONNECT, + AUDIO_CMD_USB_CONFIG, + AUDIO_CMD_USB_SLEEP, + AUDIO_CMD_USB_WAKEUP, + AUDIO_CMD_RECV_PAUSE, + AUDIO_CMD_RECV_CONTINUE, + AUDIO_CMD_SET_RECV_RATE, + AUDIO_CMD_SET_SEND_RATE, + AUDIO_CMD_RESET_CODEC, + AUDIO_CMD_NOISE_GATING, + AUDIO_CMD_NOISE_REDUCTION, + AUDIO_CMD_TUNE_RATE, + AUDIO_CMD_SET_DSD_CFG, - TEST_CMD_PERF_TEST_POWER, - TEST_CMD_PA_ON_OFF, + TEST_CMD_PERF_TEST_POWER, + TEST_CMD_PA_ON_OFF, - AUDIO_CMD_QTY + AUDIO_CMD_QTY }; enum AUDIO_ITF_STATE_T { - AUDIO_ITF_STATE_STOPPED = 0, - AUDIO_ITF_STATE_STARTED, + AUDIO_ITF_STATE_STOPPED = 0, + AUDIO_ITF_STATE_STARTED, }; enum AUDIO_STREAM_REQ_USER_T { - AUDIO_STREAM_REQ_USB = 0, - AUDIO_STREAM_REQ_ANC, + AUDIO_STREAM_REQ_USB = 0, + AUDIO_STREAM_REQ_ANC, - AUDIO_STREAM_REQ_USER_QTY, - AUDIO_STREAM_REQ_USER_ALL = AUDIO_STREAM_REQ_USER_QTY, + AUDIO_STREAM_REQ_USER_QTY, + AUDIO_STREAM_REQ_USER_ALL = AUDIO_STREAM_REQ_USER_QTY, }; enum AUDIO_STREAM_STATUS_T { - AUDIO_STREAM_OPENED = 0, - AUDIO_STREAM_STARTED, + AUDIO_STREAM_OPENED = 0, + AUDIO_STREAM_STARTED, - AUDIO_STREAM_STATUS_QTY + AUDIO_STREAM_STATUS_QTY }; enum AUDIO_STREAM_RUNNING_T { - AUDIO_STREAM_RUNNING_NULL, - AUDIO_STREAM_RUNNING_ENABLED, - AUDIO_STREAM_RUNNING_DISABLED, + AUDIO_STREAM_RUNNING_NULL, + AUDIO_STREAM_RUNNING_ENABLED, + AUDIO_STREAM_RUNNING_DISABLED, }; enum CODEC_CONFIG_LOCK_USER_T { - CODEC_CONFIG_LOCK_RESTART_PLAY, - CODEC_CONFIG_LOCK_RESTART_CAP, + CODEC_CONFIG_LOCK_RESTART_PLAY, + CODEC_CONFIG_LOCK_RESTART_CAP, - CODEC_CONFIG_LOCK_USER_QTY + CODEC_CONFIG_LOCK_USER_QTY }; enum CODEC_MUTE_USER_T { - CODEC_MUTE_USER_CMD, - CODEC_MUTE_USER_NOISE_GATING, + CODEC_MUTE_USER_CMD, + CODEC_MUTE_USER_NOISE_GATING, - CODEC_MUTE_USER_QTY, - CODEC_MUTE_USER_ALL = CODEC_MUTE_USER_QTY, + CODEC_MUTE_USER_QTY, + CODEC_MUTE_USER_ALL = CODEC_MUTE_USER_QTY, }; struct USB_AUDIO_KEY_MAP_T { - enum USB_AUDIO_HID_EVENT_T hid_event; - enum HAL_KEY_CODE_T key_code; - uint32_t key_event_bitset; + enum USB_AUDIO_HID_EVENT_T hid_event; + enum HAL_KEY_CODE_T key_code; + uint32_t key_event_bitset; }; -STATIC_ASSERT(8 * sizeof(((struct USB_AUDIO_KEY_MAP_T *)0)->key_event_bitset) >= HAL_KEY_EVENT_NUM, - "key_event_bitset size is too small"); +STATIC_ASSERT(8 * sizeof(((struct USB_AUDIO_KEY_MAP_T *)0)->key_event_bitset) >= + HAL_KEY_EVENT_NUM, + "key_event_bitset size is too small"); #ifdef USB_AUDIO_DYN_CFG @@ -347,7 +395,9 @@ static const enum AUD_SAMPRATE_T sample_rate_ref_cap = SAMPLE_RATE_CAPTURE; #elif defined(USB_AUDIO_16K) static const enum AUD_SAMPRATE_T sample_rate_ref_cap = SAMPLE_RATE_CAPTURE; #else -static const enum AUD_SAMPRATE_T sample_rate_ref_cap = (SAMPLE_RATE_RECV % AUD_SAMPRATE_8000) ? AUD_SAMPRATE_44100 : AUD_SAMPRATE_48000; +static const enum AUD_SAMPRATE_T sample_rate_ref_cap = + (SAMPLE_RATE_RECV % AUD_SAMPRATE_8000) ? AUD_SAMPRATE_44100 + : AUD_SAMPRATE_48000; #endif #endif // !USB_AUDIO_DYN_CFG #endif // (CHIP_BEST1000 && (ANC_APP || _DUAL_AUX_MIC_)) @@ -368,20 +418,21 @@ static uint8_t capture_conflicted; #ifdef NOISE_GATING enum NOISE_GATING_CMD_T { - NOISE_GATING_CMD_NULL, - NOISE_GATING_CMD_MUTE, - NOISE_GATING_CMD_UNMUTE, + NOISE_GATING_CMD_NULL, + NOISE_GATING_CMD_MUTE, + NOISE_GATING_CMD_UNMUTE, }; static enum NOISE_GATING_CMD_T noise_gating_cmd = NOISE_GATING_CMD_NULL; static uint32_t last_high_signal_time; #ifdef NOISE_REDUCTION enum NOISE_REDUCTION_CMD_T { - NOISE_REDUCTION_CMD_NULL, - NOISE_REDUCTION_CMD_FIRE, - NOISE_REDUCTION_CMD_RESTORE, + NOISE_REDUCTION_CMD_NULL, + NOISE_REDUCTION_CMD_FIRE, + NOISE_REDUCTION_CMD_RESTORE, }; -static enum NOISE_REDUCTION_CMD_T noise_reduction_cmd = NOISE_REDUCTION_CMD_NULL; +static enum NOISE_REDUCTION_CMD_T noise_reduction_cmd = + NOISE_REDUCTION_CMD_NULL; static bool nr_active; static bool prev_samp_positive[2]; static uint16_t prev_zero_diff[2][2]; @@ -462,7 +513,8 @@ static uint8_t playback_vol; static uint8_t new_playback_vol; static uint8_t new_mute_state; static uint8_t mute_user_map; -STATIC_ASSERT(sizeof(mute_user_map) * 8 >= CODEC_MUTE_USER_QTY, "mute_user_map size too small"); +STATIC_ASSERT(sizeof(mute_user_map) * 8 >= CODEC_MUTE_USER_QTY, + "mute_user_map size too small"); static uint8_t capture_vol; static uint8_t new_capture_vol; @@ -500,7 +552,8 @@ static float playback_gain_to_float(uint32_t level); #endif static uint8_t codec_config_lock; -STATIC_ASSERT(sizeof(codec_config_lock) * 8 >= CODEC_CONFIG_LOCK_USER_QTY, "codec_config_lock size too small"); +STATIC_ASSERT(sizeof(codec_config_lock) * 8 >= CODEC_CONFIG_LOCK_USER_QTY, + "codec_config_lock size too small"); static struct USB_AUDIO_STREAM_INFO_T playback_info; static struct USB_AUDIO_STREAM_INFO_T capture_info; @@ -515,17 +568,19 @@ static uint32_t codec_cap_start_time; static uint32_t last_usb_recv_time; static uint32_t last_usb_send_time; -#define CMD_LIST_SIZE 30 +#define CMD_LIST_SIZE 30 static uint32_t cmd_list[CMD_LIST_SIZE]; static uint32_t cmd_watermark; static struct SAFE_QUEUE_T cmd_queue; -#define EXTRACT_CMD(d) ((d) & 0xFF) -#define EXTRACT_SEQ(d) (((d) >> 8) & 0xFF) -#define EXTRACT_ARG(d) (((d) >> 16) & 0xFF) -#define MAKE_QUEUE_DATA(c, s, a) (((c) & 0xFF) | ((s) & 0xFF) << 8 | ((a) & 0xFF) << 16) +#define EXTRACT_CMD(d) ((d)&0xFF) +#define EXTRACT_SEQ(d) (((d) >> 8) & 0xFF) +#define EXTRACT_ARG(d) (((d) >> 16) & 0xFF) +#define MAKE_QUEUE_DATA(c, s, a) \ + (((c)&0xFF) | ((s)&0xFF) << 8 | ((a)&0xFF) << 16) STATIC_ASSERT(AUDIO_CMD_QTY <= 0xFF, "audio cmd num exceeds size in queue"); -STATIC_ASSERT(USB_AUDIO_STATE_EVENT_QTY <= 0xFF, "uaud evt num exceeds size in queue"); +STATIC_ASSERT(USB_AUDIO_STATE_EVENT_QTY <= 0xFF, + "uaud evt num exceeds size in queue"); STATIC_ASSERT(sizeof(usb_recv_seq) <= 1, "usb recv seq exceeds size in queue"); STATIC_ASSERT(sizeof(usb_send_seq) <= 1, "usb send seq exceeds size in queue"); @@ -563,81 +618,81 @@ extern void damic_init(void); extern void damic_deinit(void); // second-order IR filter -short soir_filter(int32_t PcmValue) -{ - float gain = 2.0F; - const float NUM[3] = {0.013318022713065147, 0.02375408448278904, 0.010780527256429195}; - const float DEN[3] = {1, -1.6983977556228638, 0.74625039100646973}; +short soir_filter(int32_t PcmValue) { + float gain = 2.0F; + const float NUM[3] = {0.013318022713065147, 0.02375408448278904, + 0.010780527256429195}; + const float DEN[3] = {1, -1.6983977556228638, 0.74625039100646973}; - static float y0 = 0, y1 = 0, y2 = 0, x0 = 0, x1 = 0, x2 = 0; - int32_t PcmOut = 0; + static float y0 = 0, y1 = 0, y2 = 0, x0 = 0, x1 = 0, x2 = 0; + int32_t PcmOut = 0; - // Left channel - x0 = PcmValue* gain; - y0 = x0*NUM[0] + x1*NUM[1] + x2*NUM[2] - y1*DEN[1] - y2*DEN[2]; - y2 = y1; - y1 = y0; - x2 = x1; - x1 = x0; + // Left channel + x0 = PcmValue * gain; + y0 = x0 * NUM[0] + x1 * NUM[1] + x2 * NUM[2] - y1 * DEN[1] - y2 * DEN[2]; + y2 = y1; + y1 = y0; + x2 = x1; + x1 = x0; - PcmOut = (int32_t)y0; + PcmOut = (int32_t)y0; - PcmOut = __SSAT(PcmOut,16); + PcmOut = __SSAT(PcmOut, 16); - return (short)PcmOut; + return (short)PcmOut; } #ifdef DUAL_AUX_MIC_MORE_FILTER // second-order IR filter -short soir_filter1(int32_t PcmValue) -{ - //float gain = 0.003031153698; - const float NUM[3] = {0.013318022713065147, 0.02375408448278904, 0.010780527256429195}; - const float DEN[3] = {1, -1.6983977556228638, 0.74625039100646973}; +short soir_filter1(int32_t PcmValue) { + // float gain = 0.003031153698; + const float NUM[3] = {0.013318022713065147, 0.02375408448278904, + 0.010780527256429195}; + const float DEN[3] = {1, -1.6983977556228638, 0.74625039100646973}; - static float y0 = 0, y1 = 0, y2 = 0, x0 = 0, x1 = 0, x2 = 0; - int32_t PcmOut = 0; + static float y0 = 0, y1 = 0, y2 = 0, x0 = 0, x1 = 0, x2 = 0; + int32_t PcmOut = 0; - // Left channel - //x0 = PcmValue* gain; - x0 = PcmValue; - y0 = x0*NUM[0] + x1*NUM[1] + x2*NUM[2] - y1*DEN[1] - y2*DEN[2]; - y2 = y1; - y1 = y0; - x2 = x1; - x1 = x0; + // Left channel + // x0 = PcmValue* gain; + x0 = PcmValue; + y0 = x0 * NUM[0] + x1 * NUM[1] + x2 * NUM[2] - y1 * DEN[1] - y2 * DEN[2]; + y2 = y1; + y1 = y0; + x2 = x1; + x1 = x0; - PcmOut = (int32_t)y0; + PcmOut = (int32_t)y0; - PcmOut = __SSAT(PcmOut,16); + PcmOut = __SSAT(PcmOut, 16); - return (short)PcmOut; + return (short)PcmOut; } // second-order IR filter -short soir_filter2(int32_t PcmValue) -{ - //float gain = 0.003031153698; - const float NUM[3] = {0.013318022713065147, 0.02375408448278904, 0.010780527256429195}; - const float DEN[3] = {1, -1.6983977556228638, 0.74625039100646973}; +short soir_filter2(int32_t PcmValue) { + // float gain = 0.003031153698; + const float NUM[3] = {0.013318022713065147, 0.02375408448278904, + 0.010780527256429195}; + const float DEN[3] = {1, -1.6983977556228638, 0.74625039100646973}; - static float y0 = 0, y1 = 0, y2 = 0, x0 = 0, x1 = 0, x2 = 0; - int32_t PcmOut = 0; + static float y0 = 0, y1 = 0, y2 = 0, x0 = 0, x1 = 0, x2 = 0; + int32_t PcmOut = 0; - // Left channel - //x0 = PcmValue* gain; - x0 = PcmValue; - y0 = x0*NUM[0] + x1*NUM[1] + x2*NUM[2] - y1*DEN[1] - y2*DEN[2]; - y2 = y1; - y1 = y0; - x2 = x1; - x1 = x0; + // Left channel + // x0 = PcmValue* gain; + x0 = PcmValue; + y0 = x0 * NUM[0] + x1 * NUM[1] + x2 * NUM[2] - y1 * DEN[1] - y2 * DEN[2]; + y2 = y1; + y1 = y0; + x2 = x1; + x1 = x0; - PcmOut = (int32_t)y0; + PcmOut = (int32_t)y0; - PcmOut = __SSAT(PcmOut,16); + PcmOut = __SSAT(PcmOut, 16); - return (short)PcmOut; + return (short)PcmOut; } #endif @@ -646,31 +701,29 @@ static float s_f_amic4_dc; static short s_amic3_dc; static short s_amic4_dc; -static void init_amic_dc (void) -{ - s_amic3_dc = 0; - s_amic4_dc = 0; - s_f_amic3_dc = 0.0; - s_f_amic4_dc = 0.0; +static void init_amic_dc(void) { + s_amic3_dc = 0; + s_amic4_dc = 0; + s_f_amic3_dc = 0.0; + s_f_amic4_dc = 0.0; } -static void get_amic_dc (short* src, uint32_t samp_cnt, uint32_t step) -{ - uint32_t i = 0; +static void get_amic_dc(short *src, uint32_t samp_cnt, uint32_t step) { + uint32_t i = 0; - float u3_1 = 0.00001; - float u3_2 = 1 - u3_1; + float u3_1 = 0.00001; + float u3_2 = 1 - u3_1; - float u4_1 = 0.00001; - float u4_2 = 1 - u4_1; + float u4_1 = 0.00001; + float u4_2 = 1 - u4_1; - for (i = 0; i < samp_cnt; i+=(2< AUD_SAMPRATE_96000) { - // Sample rate higher than 96K will require higher system freq, which consumes more power - return 0; - } - - int32_t *src_buf = (int32_t *)buf; - int32_t *dst_buf = (int32_t *)buf; - uint32_t mono_samp_num = len / 2 / sample_size_play; - int32_t start_idx, in_idx, coef_idx; - int32_t in_l, in_r; - float out_l, out_r; - uint8_t new_seq_idx = !freq_resp_eq_hist_idx; - - if (mono_samp_num >= (FREQ_RESP_EQ_COEF_NUM - 1)) { - start_idx = (mono_samp_num - FREQ_RESP_EQ_COEF_NUM + 1) * 2; - for (in_idx = 0; in_idx < (FREQ_RESP_EQ_COEF_NUM - 1) * 2; in_idx++) { - freq_resp_eq_hist[new_seq_idx][in_idx] = src_buf[start_idx + in_idx]; - } - } else { - start_idx = (FREQ_RESP_EQ_COEF_NUM - 1 - mono_samp_num) * 2; - for (in_idx = 0; in_idx < start_idx; in_idx++) { - freq_resp_eq_hist[new_seq_idx][in_idx] = freq_resp_eq_hist[freq_resp_eq_hist_idx][mono_samp_num * 2 + in_idx]; - } - for (in_idx = 0; in_idx < mono_samp_num * 2; in_idx++) { - freq_resp_eq_hist[new_seq_idx][start_idx + in_idx] = src_buf[in_idx]; - } - } - - for (in_idx = mono_samp_num - 1; in_idx >= 0; in_idx--) { - out_l = 0; - out_r = 0; - for (coef_idx = 0; coef_idx < FREQ_RESP_EQ_COEF_NUM; coef_idx++) { - if (in_idx + coef_idx - FREQ_RESP_EQ_COEF_NUM + 1 >= 0) { - in_l = src_buf[(in_idx + coef_idx - FREQ_RESP_EQ_COEF_NUM + 1) * 2]; - in_r = src_buf[(in_idx + coef_idx - FREQ_RESP_EQ_COEF_NUM + 1) * 2 + 1]; - } else { - in_l = freq_resp_eq_hist[freq_resp_eq_hist_idx][(in_idx + coef_idx) * 2]; - in_r = freq_resp_eq_hist[freq_resp_eq_hist_idx][(in_idx + coef_idx) * 2 + 1]; - } - out_l += in_l * freq_resp_eq_coef[coef_idx]; - out_r += in_r * freq_resp_eq_coef[coef_idx]; - } - - // TODO: Is it really neccessary to round the float? - //dst_buf[in_idx * 2] = __SSAT(ftoi_nearest(out_l), 24); - //dst_buf[in_idx * 2 + 1] = __SSAT(ftoi_nearest(out_r), 24); - dst_buf[in_idx * 2] = __SSAT((int32_t)out_l, 24); - dst_buf[in_idx * 2 + 1] = __SSAT((int32_t)out_r, 24); - } - - freq_resp_eq_hist_idx = new_seq_idx; +int freq_resp_eq_run(uint8_t *buf, uint32_t len) { + ASSERT(sample_size_play == 4, + "Freq resp eq is running on 24-bit playback only"); + if (sample_rate_play > AUD_SAMPRATE_96000) { + // Sample rate higher than 96K will require higher system freq, which + // consumes more power return 0; + } + + int32_t *src_buf = (int32_t *)buf; + int32_t *dst_buf = (int32_t *)buf; + uint32_t mono_samp_num = len / 2 / sample_size_play; + int32_t start_idx, in_idx, coef_idx; + int32_t in_l, in_r; + float out_l, out_r; + uint8_t new_seq_idx = !freq_resp_eq_hist_idx; + + if (mono_samp_num >= (FREQ_RESP_EQ_COEF_NUM - 1)) { + start_idx = (mono_samp_num - FREQ_RESP_EQ_COEF_NUM + 1) * 2; + for (in_idx = 0; in_idx < (FREQ_RESP_EQ_COEF_NUM - 1) * 2; in_idx++) { + freq_resp_eq_hist[new_seq_idx][in_idx] = src_buf[start_idx + in_idx]; + } + } else { + start_idx = (FREQ_RESP_EQ_COEF_NUM - 1 - mono_samp_num) * 2; + for (in_idx = 0; in_idx < start_idx; in_idx++) { + freq_resp_eq_hist[new_seq_idx][in_idx] = + freq_resp_eq_hist[freq_resp_eq_hist_idx][mono_samp_num * 2 + in_idx]; + } + for (in_idx = 0; in_idx < mono_samp_num * 2; in_idx++) { + freq_resp_eq_hist[new_seq_idx][start_idx + in_idx] = src_buf[in_idx]; + } + } + + for (in_idx = mono_samp_num - 1; in_idx >= 0; in_idx--) { + out_l = 0; + out_r = 0; + for (coef_idx = 0; coef_idx < FREQ_RESP_EQ_COEF_NUM; coef_idx++) { + if (in_idx + coef_idx - FREQ_RESP_EQ_COEF_NUM + 1 >= 0) { + in_l = src_buf[(in_idx + coef_idx - FREQ_RESP_EQ_COEF_NUM + 1) * 2]; + in_r = src_buf[(in_idx + coef_idx - FREQ_RESP_EQ_COEF_NUM + 1) * 2 + 1]; + } else { + in_l = + freq_resp_eq_hist[freq_resp_eq_hist_idx][(in_idx + coef_idx) * 2]; + in_r = freq_resp_eq_hist[freq_resp_eq_hist_idx] + [(in_idx + coef_idx) * 2 + 1]; + } + out_l += in_l * freq_resp_eq_coef[coef_idx]; + out_r += in_r * freq_resp_eq_coef[coef_idx]; + } + + // TODO: Is it really neccessary to round the float? + // dst_buf[in_idx * 2] = __SSAT(ftoi_nearest(out_l), 24); + // dst_buf[in_idx * 2 + 1] = __SSAT(ftoi_nearest(out_r), 24); + dst_buf[in_idx * 2] = __SSAT((int32_t)out_l, 24); + dst_buf[in_idx * 2 + 1] = __SSAT((int32_t)out_r, 24); + } + + freq_resp_eq_hist_idx = new_seq_idx; + + return 0; } #endif // FREQ_RESP_EQ -static enum AUD_BITS_T sample_size_to_enum_playback(uint32_t size) -{ - if (size == 2) { - return AUD_BITS_16; - } else if (size == 4) { - return AUD_BITS_24; - } else { - ASSERT(false, "%s: Invalid sample size: %u", __FUNCTION__, size); - } +static enum AUD_BITS_T sample_size_to_enum_playback(uint32_t size) { + if (size == 2) { + return AUD_BITS_16; + } else if (size == 4) { + return AUD_BITS_24; + } else { + ASSERT(false, "%s: Invalid sample size: %u", __FUNCTION__, size); + } - return 0; + return 0; } -static enum AUD_BITS_T sample_size_to_enum_capture(uint32_t size) -{ - if (size == 2) { - return AUD_BITS_16; - } else if (size == 4) { +static enum AUD_BITS_T sample_size_to_enum_capture(uint32_t size) { + if (size == 2) { + return AUD_BITS_16; + } else if (size == 4) { #ifdef USB_AUDIO_SEND_32BIT - return AUD_BITS_32; + return AUD_BITS_32; #else - return AUD_BITS_24; + return AUD_BITS_24; #endif - } else { - ASSERT(false, "%s: Invalid sample size: %u", __FUNCTION__, size); - } + } else { + ASSERT(false, "%s: Invalid sample size: %u", __FUNCTION__, size); + } - return 0; + return 0; } -static enum AUD_CHANNEL_NUM_T chan_num_to_enum(uint32_t num) -{ - return AUD_CHANNEL_NUM_1 + (num - 1); +static enum AUD_CHANNEL_NUM_T chan_num_to_enum(uint32_t num) { + return AUD_CHANNEL_NUM_1 + (num - 1); } -static uint32_t POSSIBLY_UNUSED byte_to_samp_playback(uint32_t n) -{ +static uint32_t POSSIBLY_UNUSED byte_to_samp_playback(uint32_t n) { #if defined(USB_AUDIO_DYN_CFG) || defined(CODEC_DSD) - return n / sample_size_play / CHAN_NUM_PLAYBACK; + return n / sample_size_play / CHAN_NUM_PLAYBACK; #else - return BYTE_TO_SAMP_PLAYBACK(n); + return BYTE_TO_SAMP_PLAYBACK(n); #endif } -static uint32_t POSSIBLY_UNUSED byte_to_samp_capture(uint32_t n) -{ +static uint32_t POSSIBLY_UNUSED byte_to_samp_capture(uint32_t n) { #ifdef USB_AUDIO_DYN_CFG - return n / sample_size_cap / CHAN_NUM_CAPTURE; + return n / sample_size_cap / CHAN_NUM_CAPTURE; #else - return BYTE_TO_SAMP_CAPTURE(n); + return BYTE_TO_SAMP_CAPTURE(n); #endif } -static uint32_t POSSIBLY_UNUSED byte_to_samp_recv(uint32_t n) -{ +static uint32_t POSSIBLY_UNUSED byte_to_samp_recv(uint32_t n) { #ifdef USB_AUDIO_DYN_CFG - return n / sample_size_recv / CHAN_NUM_RECV; + return n / sample_size_recv / CHAN_NUM_RECV; #else - return BYTE_TO_SAMP_RECV(n); + return BYTE_TO_SAMP_RECV(n); #endif } -static uint32_t POSSIBLY_UNUSED byte_to_samp_send(uint32_t n) -{ +static uint32_t POSSIBLY_UNUSED byte_to_samp_send(uint32_t n) { #ifdef USB_AUDIO_DYN_CFG - return n / sample_size_send / CHAN_NUM_SEND; + return n / sample_size_send / CHAN_NUM_SEND; #else - return BYTE_TO_SAMP_SEND(n); + return BYTE_TO_SAMP_SEND(n); #endif } -static uint32_t POSSIBLY_UNUSED samp_to_byte_playback(uint32_t n) -{ +static uint32_t POSSIBLY_UNUSED samp_to_byte_playback(uint32_t n) { #if defined(USB_AUDIO_DYN_CFG) || defined(CODEC_DSD) - return n * sample_size_play * CHAN_NUM_PLAYBACK; + return n * sample_size_play * CHAN_NUM_PLAYBACK; #else - return SAMP_TO_BYTE_PLAYBACK(n); + return SAMP_TO_BYTE_PLAYBACK(n); #endif } -static uint32_t POSSIBLY_UNUSED samp_to_byte_capture(uint32_t n) -{ +static uint32_t POSSIBLY_UNUSED samp_to_byte_capture(uint32_t n) { #ifdef USB_AUDIO_DYN_CFG - return n * sample_size_cap * CHAN_NUM_CAPTURE; + return n * sample_size_cap * CHAN_NUM_CAPTURE; #else - return SAMP_TO_BYTE_CAPTURE(n); + return SAMP_TO_BYTE_CAPTURE(n); #endif } -static uint32_t POSSIBLY_UNUSED samp_to_byte_recv(uint32_t n) -{ +static uint32_t POSSIBLY_UNUSED samp_to_byte_recv(uint32_t n) { #ifdef USB_AUDIO_DYN_CFG - return n * sample_size_recv * CHAN_NUM_RECV; + return n * sample_size_recv * CHAN_NUM_RECV; #else - return SAMP_TO_BYTE_RECV(n); + return SAMP_TO_BYTE_RECV(n); #endif } -static uint32_t POSSIBLY_UNUSED samp_to_byte_send(uint32_t n) -{ +static uint32_t POSSIBLY_UNUSED samp_to_byte_send(uint32_t n) { #ifdef USB_AUDIO_DYN_CFG - return n * sample_size_send * CHAN_NUM_SEND; + return n * sample_size_send * CHAN_NUM_SEND; #else - return SAMP_TO_BYTE_SEND(n); + return SAMP_TO_BYTE_SEND(n); #endif } -static uint32_t playback_to_recv_len(uint32_t n) -{ +static uint32_t playback_to_recv_len(uint32_t n) { #if defined(USB_AUDIO_DYN_CFG) || defined(CODEC_DSD) - uint32_t len; + uint32_t len; - // 1) When changing recv sample rate, the play stream will be stopped and then restarted. - // So when calculating the len, play sample rate has been changed according to recv sample rate. - // 2) Play and recv sample rates are integral multiple of each other. + // 1) When changing recv sample rate, the play stream will be stopped and then + // restarted. + // So when calculating the len, play sample rate has been changed according + // to recv sample rate. + // 2) Play and recv sample rates are integral multiple of each other. - len = samp_to_byte_recv(byte_to_samp_playback(n)); - if (sample_rate_recv == sample_rate_play) { - return len; - } else if (sample_rate_recv < sample_rate_play) { - return len / (sample_rate_play / sample_rate_recv); - } else { - return len * (sample_rate_recv / sample_rate_play); - } + len = samp_to_byte_recv(byte_to_samp_playback(n)); + if (sample_rate_recv == sample_rate_play) { + return len; + } else if (sample_rate_recv < sample_rate_play) { + return len / (sample_rate_play / sample_rate_recv); + } else { + return len * (sample_rate_recv / sample_rate_play); + } #else - return PLAYBACK_TO_RECV_LEN(n); + return PLAYBACK_TO_RECV_LEN(n); #endif } -static uint32_t capture_to_send_len(uint32_t n) -{ +static uint32_t capture_to_send_len(uint32_t n) { #ifdef USB_AUDIO_DYN_CFG - uint32_t len; - enum AUD_SAMPRATE_T send_rate; - enum AUD_SAMPRATE_T cap_rate; + uint32_t len; + enum AUD_SAMPRATE_T send_rate; + enum AUD_SAMPRATE_T cap_rate; - // 1) When changing send sample rate, the cap stream will not be changed if the play stream is active. - // Moreover, the cap stream might be changed if changing recv sample rate (and then play sample rate). - // So when calculating the len, cap sample rate might be inconsistent with send sample rate. - // 2) Resample might be applied to the cap stream. Cap and send sample rates have no integral multiple relationship. + // 1) When changing send sample rate, the cap stream will not be changed if + // the play stream is active. + // Moreover, the cap stream might be changed if changing recv sample rate + // (and then play sample rate). So when calculating the len, cap sample + // rate might be inconsistent with send sample rate. + // 2) Resample might be applied to the cap stream. Cap and send sample rates + // have no integral multiple relationship. - send_rate = sample_rate_send; - cap_rate = sample_rate_cap; + send_rate = sample_rate_send; + cap_rate = sample_rate_cap; - len = samp_to_byte_send(byte_to_samp_capture(n)); - if (send_rate == cap_rate) { - return len; - } else { - // Unlikely to overflow for the max send_rate is 48000 - return ALIGN((len * send_rate + cap_rate - 1) / cap_rate, sample_size_send * CHAN_NUM_SEND); - } + len = samp_to_byte_send(byte_to_samp_capture(n)); + if (send_rate == cap_rate) { + return len; + } else { + // Unlikely to overflow for the max send_rate is 48000 + return ALIGN((len * send_rate + cap_rate - 1) / cap_rate, + sample_size_send * CHAN_NUM_SEND); + } #else - return CAPTURE_TO_SEND_LEN(n); + return CAPTURE_TO_SEND_LEN(n); #endif } #ifdef USB_AUDIO_DYN_CFG -static uint32_t POSSIBLY_UNUSED capture_to_ref_len(uint32_t n) -{ - uint32_t len; +static uint32_t POSSIBLY_UNUSED capture_to_ref_len(uint32_t n) { + uint32_t len; - len = samp_to_byte_send(byte_to_samp_capture(n)); + len = samp_to_byte_send(byte_to_samp_capture(n)); #if defined(CHIP_BEST1000) && (defined(ANC_APP) || defined(_DUAL_AUX_MIC_)) - // Capture reference sample rate and capture sample rate are integral multiple of each other. + // Capture reference sample rate and capture sample rate are integral multiple + // of each other. - if (sample_rate_ref_cap == sample_rate_cap) { - return len; - } else if (sample_rate_ref_cap < sample_rate_cap) { - return len / (sample_rate_cap / sample_rate_ref_cap); - } else { - return len * (sample_rate_ref_cap / sample_rate_cap); - } -#else + if (sample_rate_ref_cap == sample_rate_cap) { return len; + } else if (sample_rate_ref_cap < sample_rate_cap) { + return len / (sample_rate_cap / sample_rate_ref_cap); + } else { + return len * (sample_rate_ref_cap / sample_rate_cap); + } +#else + return len; #endif } #ifdef KEEP_SAME_LATENCY -static uint32_t calc_usb_recv_size(enum AUD_SAMPRATE_T rate, uint8_t sample_size) -{ - uint32_t size; - size = (SAMP_RATE_TO_FRAME_SIZE(rate) * sample_size * CHAN_NUM_RECV) * (usb_recv_max_size / MAX_FRAME_SIZE_RECV); - return NON_EXP_ALIGN(size, RECV_BUFF_ALIGN); +static uint32_t calc_usb_recv_size(enum AUD_SAMPRATE_T rate, + uint8_t sample_size) { + uint32_t size; + size = (SAMP_RATE_TO_FRAME_SIZE(rate) * sample_size * CHAN_NUM_RECV) * + (usb_recv_max_size / MAX_FRAME_SIZE_RECV); + return NON_EXP_ALIGN(size, RECV_BUFF_ALIGN); } -static uint32_t calc_usb_send_size(enum AUD_SAMPRATE_T rate) -{ - uint32_t size; - size = samp_to_byte_send(SAMP_RATE_TO_FRAME_SIZE(rate)) * usb_send_max_size / MAX_FRAME_SIZE_SEND; - return NON_EXP_ALIGN(size, SEND_BUFF_ALIGN); +static uint32_t calc_usb_send_size(enum AUD_SAMPRATE_T rate) { + uint32_t size; + size = samp_to_byte_send(SAMP_RATE_TO_FRAME_SIZE(rate)) * usb_send_max_size / + MAX_FRAME_SIZE_SEND; + return NON_EXP_ALIGN(size, SEND_BUFF_ALIGN); } -static uint32_t calc_playback_size(enum AUD_SAMPRATE_T rate) -{ - uint32_t size; - size = samp_to_byte_playback(SAMP_RATE_TO_FRAME_SIZE(rate)) * (playback_max_size / MAX_FRAME_SIZE_PLAYBACK); - return NON_EXP_ALIGN(size, DAC_BUFF_ALIGN); +static uint32_t calc_playback_size(enum AUD_SAMPRATE_T rate) { + uint32_t size; + size = samp_to_byte_playback(SAMP_RATE_TO_FRAME_SIZE(rate)) * + (playback_max_size / MAX_FRAME_SIZE_PLAYBACK); + return NON_EXP_ALIGN(size, DAC_BUFF_ALIGN); } -static uint32_t calc_capture_size(enum AUD_SAMPRATE_T rate) -{ - uint32_t size; - size = samp_to_byte_capture(SAMP_RATE_TO_FRAME_SIZE(rate)) * (capture_max_size / MAX_FRAME_SIZE_CAPTURE); - return NON_EXP_ALIGN(size, ADC_BUFF_ALIGN); +static uint32_t calc_capture_size(enum AUD_SAMPRATE_T rate) { + uint32_t size; + size = samp_to_byte_capture(SAMP_RATE_TO_FRAME_SIZE(rate)) * + (capture_max_size / MAX_FRAME_SIZE_CAPTURE); + return NON_EXP_ALIGN(size, ADC_BUFF_ALIGN); } #endif #endif -static void record_conflict(int conflicted) -{ - uint32_t lock; - uint32_t interval; - bool reset = false; +static void record_conflict(int conflicted) { + uint32_t lock; + uint32_t interval; + bool reset = false; - lock = int_lock(); + lock = int_lock(); - if (conflicted) { - nonconflict_start = 0; - if (conflict_cnt == 0) { - conflict_time = hal_sys_timer_get(); - } - conflict_cnt++; - - if (conflict_cnt >= CONFLICT_CMD_TRIG_COUNT) { - interval = hal_sys_timer_get() - conflict_time; - if (interval < CONFLICT_CMD_TRIG_INTERVAL) { - //TRACE(2,"RESET CODEC: conflict cnt=%u interval=%u ms", conflict_cnt, TICKS_TO_MS(interval)); - reset = true; - } - conflict_cnt = 0; - } - } else { - if (nonconflict_start == 0) { - nonconflict_start = 1; - if (conflict_cnt) { - nonconflict_time = hal_sys_timer_get(); - } - } else { - if (conflict_cnt) { - interval = hal_sys_timer_get() - nonconflict_time; - if (interval >= CONFLICT_STATE_RESET_INTERVAL) { - //TRACE(2,"RESET CONFLICT STATE: conflict cnt=%u nonconflict interval=%u ms", conflict_cnt, TICKS_TO_MS(interval)); - conflict_cnt = 0; - } - } - } - } - - int_unlock(lock); - - if (reset) { - // Avoid invoking cmd callback when irq is locked - enqueue_unique_cmd(AUDIO_CMD_RESET_CODEC); - } -} - -static void reset_conflict(void) -{ - uint32_t lock; - - lock = int_lock(); - conflict_cnt = 0; + if (conflicted) { nonconflict_start = 0; - int_unlock(lock); -} - -uint8_t usb_audio_get_eq_index(AUDIO_EQ_TYPE_T audio_eq_type,uint8_t anc_status) -{ - uint8_t index_eq=0; - -#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__)|| defined(__HW_DAC_IIR_EQ_PROCESS__)|| defined(__HW_IIR_EQ_PROCESS__) - switch (audio_eq_type) - { -#if defined(__SW_IIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_SW_IIR: - { - if(anc_status) - { - index_eq=audio_eq_sw_iir_index+1; - } - else - { - index_eq=audio_eq_sw_iir_index; - } - - } - break; -#endif - -#if defined(__HW_FIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_HW_FIR: - { -#ifdef USB_AUDIO_DYN_CFG - if(sample_rate_recv == AUD_SAMPRATE_44100) { - index_eq = 0; - } else if(sample_rate_recv == AUD_SAMPRATE_48000) { - index_eq = 1; - } else if(sample_rate_recv == AUD_SAMPRATE_96000) { - index_eq = 2; - } else if(sample_rate_recv == AUD_SAMPRATE_192000) { - index_eq = 3; - } else { - ASSERT(0, "[%s] sample_rate_recv(%d) is not supported", __func__, sample_rate_recv); - } - audio_eq_hw_fir_index=index_eq; -#else - index_eq=audio_eq_hw_fir_index; -#endif - if(anc_status) - { - index_eq=index_eq+4; - } - } - break; -#endif - -#if defined(__HW_DAC_IIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_HW_DAC_IIR: - { - if(anc_status) - { - index_eq=audio_eq_hw_dac_iir_index+1; - } - else - { - index_eq=audio_eq_hw_dac_iir_index; - } - } - break; -#endif - -#if defined(__HW_IIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_HW_IIR: - { - if(anc_status) - { - index_eq=audio_eq_hw_iir_index+1; - } - else - { - index_eq=audio_eq_hw_iir_index; - } - } - break; -#endif - default: - { - ASSERT(false,"[%s]Error eq type!",__func__); - } + if (conflict_cnt == 0) { + conflict_time = hal_sys_timer_get(); } -#endif - return index_eq; -} + conflict_cnt++; - -uint32_t usb_audio_set_eq(AUDIO_EQ_TYPE_T audio_eq_type,uint8_t index) -{ - const FIR_CFG_T *fir_cfg=NULL; - const IIR_CFG_T *iir_cfg=NULL; - - TRACE(3,"[%s]audio_eq_type=%d,index=%d", __func__, audio_eq_type,index); - -#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__)|| defined(__HW_DAC_IIR_EQ_PROCESS__)|| defined(__HW_IIR_EQ_PROCESS__) - switch (audio_eq_type) - { -#if defined(__SW_IIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_SW_IIR: - { - if(index >= EQ_SW_IIR_LIST_NUM) - { - TRACE(2,"[%s] index[%d] > EQ_SW_IIR_LIST_NUM", __func__, index); - return 1; - } - - iir_cfg=audio_eq_sw_iir_cfg_list[index]; - } - break; -#endif - -#if defined(__HW_FIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_HW_FIR: - { - if(index >= EQ_HW_FIR_LIST_NUM) - { - TRACE(2,"[%s] index[%d] > EQ_HW_FIR_LIST_NUM", __func__, index); - return 1; - } - - fir_cfg=audio_eq_hw_fir_cfg_list[index]; - } - break; -#endif - -#if defined(__HW_DAC_IIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_HW_DAC_IIR: - { - if(index >= EQ_HW_DAC_IIR_LIST_NUM) - { - TRACE(2,"[%s] index[%d] > EQ_HW_DAC_IIR_LIST_NUM", __func__, index); - return 1; - } - - iir_cfg=audio_eq_hw_dac_iir_cfg_list[index]; - } - break; -#endif - -#if defined(__HW_IIR_EQ_PROCESS__) - case AUDIO_EQ_TYPE_HW_IIR: - { - if(index >= EQ_HW_IIR_LIST_NUM) - { - TRACE(2,"[%s] index[%d] > EQ_HW_IIR_LIST_NUM", __func__, index); - return 1; - } - - iir_cfg=audio_eq_hw_iir_cfg_list[index]; - } - break; -#endif - default: - { - ASSERT(false,"[%s]Error eq type!",__func__); - } + if (conflict_cnt >= CONFLICT_CMD_TRIG_COUNT) { + interval = hal_sys_timer_get() - conflict_time; + if (interval < CONFLICT_CMD_TRIG_INTERVAL) { + // TRACE(2,"RESET CODEC: conflict cnt=%u interval=%u ms", conflict_cnt, + // TICKS_TO_MS(interval)); + reset = true; + } + conflict_cnt = 0; } -#endif - - return audio_eq_set_cfg(fir_cfg,iir_cfg,audio_eq_type); -} - -static void set_codec_config_status(enum CODEC_CONFIG_LOCK_USER_T user, bool lock) -{ - if (lock) { - codec_config_lock |= (1 << user); + } else { + if (nonconflict_start == 0) { + nonconflict_start = 1; + if (conflict_cnt) { + nonconflict_time = hal_sys_timer_get(); + } } else { - codec_config_lock &= ~(1 << user); + if (conflict_cnt) { + interval = hal_sys_timer_get() - nonconflict_time; + if (interval >= CONFLICT_STATE_RESET_INTERVAL) { + // TRACE(2,"RESET CONFLICT STATE: conflict cnt=%u nonconflict + // interval=%u ms", conflict_cnt, TICKS_TO_MS(interval)); + conflict_cnt = 0; + } + } } + } + + int_unlock(lock); + + if (reset) { + // Avoid invoking cmd callback when irq is locked + enqueue_unique_cmd(AUDIO_CMD_RESET_CODEC); + } } -static void usb_audio_codec_mute(enum CODEC_MUTE_USER_T user) -{ - TRACE(3,"%s: user=%d map=0x%02X", __FUNCTION__, user, mute_user_map); +static void reset_conflict(void) { + uint32_t lock; - if (user >= CODEC_MUTE_USER_QTY || mute_user_map == 0) { - af_stream_mute(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, true); - } - if (user < CODEC_MUTE_USER_QTY) { - mute_user_map |= (1 << user); - } + lock = int_lock(); + conflict_cnt = 0; + nonconflict_start = 0; + int_unlock(lock); } -static void usb_audio_codec_unmute(enum CODEC_MUTE_USER_T user) -{ - uint8_t old_map; - STATIC_ASSERT(sizeof(old_map) * 8 >= CODEC_MUTE_USER_QTY, "old_map size too small"); +uint8_t usb_audio_get_eq_index(AUDIO_EQ_TYPE_T audio_eq_type, + uint8_t anc_status) { + uint8_t index_eq = 0; - TRACE(3,"%s: user=%d map=0x%02X", __FUNCTION__, user, mute_user_map); - - old_map = mute_user_map; - - if (user < CODEC_MUTE_USER_QTY) { - mute_user_map &= ~(1 << user); +#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__) || \ + defined(__HW_DAC_IIR_EQ_PROCESS__) || defined(__HW_IIR_EQ_PROCESS__) + switch (audio_eq_type) { +#if defined(__SW_IIR_EQ_PROCESS__) + case AUDIO_EQ_TYPE_SW_IIR: { + if (anc_status) { + index_eq = audio_eq_sw_iir_index + 1; + } else { + index_eq = audio_eq_sw_iir_index; } - if (user >= CODEC_MUTE_USER_QTY || (old_map && mute_user_map == 0)) { - af_stream_mute(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, false); + + } break; +#endif + +#if defined(__HW_FIR_EQ_PROCESS__) + case AUDIO_EQ_TYPE_HW_FIR: { +#ifdef USB_AUDIO_DYN_CFG + if (sample_rate_recv == AUD_SAMPRATE_44100) { + index_eq = 0; + } else if (sample_rate_recv == AUD_SAMPRATE_48000) { + index_eq = 1; + } else if (sample_rate_recv == AUD_SAMPRATE_96000) { + index_eq = 2; + } else if (sample_rate_recv == AUD_SAMPRATE_192000) { + index_eq = 3; + } else { + ASSERT(0, "[%s] sample_rate_recv(%d) is not supported", __func__, + sample_rate_recv); } + audio_eq_hw_fir_index = index_eq; +#else + index_eq = audio_eq_hw_fir_index; +#endif + if (anc_status) { + index_eq = index_eq + 4; + } + } break; +#endif + +#if defined(__HW_DAC_IIR_EQ_PROCESS__) + case AUDIO_EQ_TYPE_HW_DAC_IIR: { + if (anc_status) { + index_eq = audio_eq_hw_dac_iir_index + 1; + } else { + index_eq = audio_eq_hw_dac_iir_index; + } + } break; +#endif + +#if defined(__HW_IIR_EQ_PROCESS__) + case AUDIO_EQ_TYPE_HW_IIR: { + if (anc_status) { + index_eq = audio_eq_hw_iir_index + 1; + } else { + index_eq = audio_eq_hw_iir_index; + } + } break; +#endif + default: { + ASSERT(false, "[%s]Error eq type!", __func__); + } + } +#endif + return index_eq; +} + +uint32_t usb_audio_set_eq(AUDIO_EQ_TYPE_T audio_eq_type, uint8_t index) { + const FIR_CFG_T *fir_cfg = NULL; + const IIR_CFG_T *iir_cfg = NULL; + + TRACE(3, "[%s]audio_eq_type=%d,index=%d", __func__, audio_eq_type, index); + +#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__) || \ + defined(__HW_DAC_IIR_EQ_PROCESS__) || defined(__HW_IIR_EQ_PROCESS__) + switch (audio_eq_type) { +#if defined(__SW_IIR_EQ_PROCESS__) + case AUDIO_EQ_TYPE_SW_IIR: { + if (index >= EQ_SW_IIR_LIST_NUM) { + TRACE(2, "[%s] index[%d] > EQ_SW_IIR_LIST_NUM", __func__, index); + return 1; + } + + iir_cfg = audio_eq_sw_iir_cfg_list[index]; + } break; +#endif + +#if defined(__HW_FIR_EQ_PROCESS__) + case AUDIO_EQ_TYPE_HW_FIR: { + if (index >= EQ_HW_FIR_LIST_NUM) { + TRACE(2, "[%s] index[%d] > EQ_HW_FIR_LIST_NUM", __func__, index); + return 1; + } + + fir_cfg = audio_eq_hw_fir_cfg_list[index]; + } break; +#endif + +#if defined(__HW_DAC_IIR_EQ_PROCESS__) + case AUDIO_EQ_TYPE_HW_DAC_IIR: { + if (index >= EQ_HW_DAC_IIR_LIST_NUM) { + TRACE(2, "[%s] index[%d] > EQ_HW_DAC_IIR_LIST_NUM", __func__, index); + return 1; + } + + iir_cfg = audio_eq_hw_dac_iir_cfg_list[index]; + } break; +#endif + +#if defined(__HW_IIR_EQ_PROCESS__) + case AUDIO_EQ_TYPE_HW_IIR: { + if (index >= EQ_HW_IIR_LIST_NUM) { + TRACE(2, "[%s] index[%d] > EQ_HW_IIR_LIST_NUM", __func__, index); + return 1; + } + + iir_cfg = audio_eq_hw_iir_cfg_list[index]; + } break; +#endif + default: { + ASSERT(false, "[%s]Error eq type!", __func__); + } + } +#endif + + return audio_eq_set_cfg(fir_cfg, iir_cfg, audio_eq_type); +} + +static void set_codec_config_status(enum CODEC_CONFIG_LOCK_USER_T user, + bool lock) { + if (lock) { + codec_config_lock |= (1 << user); + } else { + codec_config_lock &= ~(1 << user); + } +} + +static void usb_audio_codec_mute(enum CODEC_MUTE_USER_T user) { + TRACE(3, "%s: user=%d map=0x%02X", __FUNCTION__, user, mute_user_map); + + if (user >= CODEC_MUTE_USER_QTY || mute_user_map == 0) { + af_stream_mute(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, true); + } + if (user < CODEC_MUTE_USER_QTY) { + mute_user_map |= (1 << user); + } +} + +static void usb_audio_codec_unmute(enum CODEC_MUTE_USER_T user) { + uint8_t old_map; + STATIC_ASSERT(sizeof(old_map) * 8 >= CODEC_MUTE_USER_QTY, + "old_map size too small"); + + TRACE(3, "%s: user=%d map=0x%02X", __FUNCTION__, user, mute_user_map); + + old_map = mute_user_map; + + if (user < CODEC_MUTE_USER_QTY) { + mute_user_map &= ~(1 << user); + } + if (user >= CODEC_MUTE_USER_QTY || (old_map && mute_user_map == 0)) { + af_stream_mute(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, false); + } } #ifdef AUDIO_ANC_FB_MC -#define DELAY_SAMPLE_MC (33*2) // 2:ch +#define DELAY_SAMPLE_MC (33 * 2) // 2:ch static int32_t delay_buf[DELAY_SAMPLE_MC]; -static int32_t mid_p_8_old_l=0; -static int32_t mid_p_8_old_r=0; -static uint32_t audio_mc_data_playback(uint8_t *buf, uint32_t mc_len_bytes) -{ - //uint32_t begin_time; - //uint32_t end_time; - //begin_time = hal_sys_timer_get(); - //TRACE(1,"cancel: %d",begin_time); +static int32_t mid_p_8_old_l = 0; +static int32_t mid_p_8_old_r = 0; +static uint32_t audio_mc_data_playback(uint8_t *buf, uint32_t mc_len_bytes) { + // uint32_t begin_time; + // uint32_t end_time; + // begin_time = hal_sys_timer_get(); + // TRACE(1,"cancel: %d",begin_time); - float left_gain; - float right_gain; - uint32_t playback_len_bytes; - int i,j,k; - int delay_sample; + float left_gain; + float right_gain; + uint32_t playback_len_bytes; + int i, j, k; + int delay_sample; - hal_codec_get_dac_gain(&left_gain,&right_gain); + hal_codec_get_dac_gain(&left_gain, &right_gain); - //TRACE(1,"playback_samplerate_ratio: %d",playback_samplerate_ratio); + // TRACE(1,"playback_samplerate_ratio: %d",playback_samplerate_ratio); - //TRACE(1,"left_gain: %d",(int)(left_gain*(1<<12))); - //TRACE(1,"right_gain: %d",(int)(right_gain*(1<<12))); + // TRACE(1,"left_gain: %d",(int)(left_gain*(1<<12))); + // TRACE(1,"right_gain: %d",(int)(right_gain*(1<<12))); - playback_len_bytes=mc_len_bytes/playback_samplerate_ratio; + playback_len_bytes = mc_len_bytes / playback_samplerate_ratio; - if (sample_size_play == 2) - { - int16_t *sour_p=(int16_t *)(playback_buf+playback_size/2); - int16_t *mid_p=(int16_t *)(buf); - int16_t *mid_p_8=(int16_t *)(buf+mc_len_bytes-mc_len_bytes/8); - int16_t *dest_p=(int16_t *)buf; - int i,j,k; + if (sample_size_play == 2) { + int16_t *sour_p = (int16_t *)(playback_buf + playback_size / 2); + int16_t *mid_p = (int16_t *)(buf); + int16_t *mid_p_8 = (int16_t *)(buf + mc_len_bytes - mc_len_bytes / 8); + int16_t *dest_p = (int16_t *)buf; + int i, j, k; - if(buf == (playback_buf+playback_size)) - { - sour_p=(int16_t *)playback_buf; - } - - delay_sample=DELAY_SAMPLE_MC; - - for(i=0,j=0;i USB_MAX_XFER_INTERVAL) { -_invalid_play: - zero_mem32(buf, len); - conv_buf = buf; - // If usb recv is stopped, set usb_recv_rpos to the value of usb_recv_wpos -- avoid playing noise. - // Otherwise set usb_recv_rpos to 0 -- avoid buffer conflicts at usb recv startup. - new_rpos = (recv_state == AUDIO_ITF_STATE_STOPPED) ? usb_recv_wpos : 0; - conflicted = 0; -#ifdef USB_AUDIO_MULTIFUNC - new_rpos2 = (recv2_state == AUDIO_ITF_STATE_STOPPED) ? usb_recv2_wpos : 0; - conflicted2 = 0; -#endif - - goto _conv_end; - } - - //---------------------------------------- - // Check conflict - //---------------------------------------- - - usb_len = playback_to_recv_len(len); + cur_time - usb_time > USB_MAX_XFER_INTERVAL) { + _invalid_play: + zero_mem32(buf, len); + conv_buf = buf; + // If usb recv is stopped, set usb_recv_rpos to the value of usb_recv_wpos + // -- avoid playing noise. Otherwise set usb_recv_rpos to 0 -- avoid buffer + // conflicts at usb recv startup. + new_rpos = (recv_state == AUDIO_ITF_STATE_STOPPED) ? usb_recv_wpos : 0; conflicted = 0; #ifdef USB_AUDIO_MULTIFUNC + new_rpos2 = (recv2_state == AUDIO_ITF_STATE_STOPPED) ? usb_recv2_wpos : 0; conflicted2 = 0; #endif - lock = int_lock(); - wpos = usb_recv_wpos; - if (init_pos) { - old_rpos = wpos + reset_len; - if (old_rpos >= usb_recv_size) { - old_rpos -= usb_recv_size; - } - usb_recv_rpos = old_rpos; - usb_recv_init_rpos = 1; - } else { - old_rpos = usb_recv_rpos; - } - saved_old_rpos = old_rpos; - new_rpos = usb_recv_rpos + usb_len; - if (new_rpos >= usb_recv_size) { - new_rpos -= usb_recv_size; - } - if (recv_valid && init_pos == 0) { - if (old_rpos <= wpos) { - if (new_rpos < old_rpos || wpos < new_rpos) { - if (recv_state == AUDIO_ITF_STATE_STOPPED) { - if (new_rpos < old_rpos) { - zero_mem(usb_recv_buf + wpos, usb_recv_size - wpos); - zero_mem(usb_recv_buf, new_rpos); - } else { - zero_mem(usb_recv_buf + wpos, new_rpos - wpos); - } - wpos = new_rpos; - usb_recv_wpos = new_rpos; - } else { - conflicted = 1; - } - } - } else { - if (wpos < new_rpos && new_rpos < old_rpos) { - if (recv_state == AUDIO_ITF_STATE_STOPPED) { - zero_mem(usb_recv_buf + wpos, new_rpos - wpos); - wpos = new_rpos; - usb_recv_wpos = new_rpos; - } else { - conflicted = 1; - } - } - } - if (conflicted) { - // Reset read position - old_rpos = wpos + reset_len; - if (old_rpos >= usb_recv_size) { - old_rpos -= usb_recv_size; - } - new_rpos = old_rpos + usb_len; - if (new_rpos >= usb_recv_size) { - new_rpos -= usb_recv_size; - } - // Update global read position - usb_recv_rpos = old_rpos; - } - } + goto _conv_end; + } + //---------------------------------------- + // Check conflict + //---------------------------------------- + + usb_len = playback_to_recv_len(len); + conflicted = 0; #ifdef USB_AUDIO_MULTIFUNC - wpos2 = usb_recv2_wpos; - if (init_pos2) { - old_rpos2 = wpos2 + reset_len2; - if (old_rpos2 >= usb_recv2_size) { - old_rpos2 -= usb_recv2_size; - } - usb_recv2_rpos = old_rpos2; - usb_recv2_init_rpos = 1; - } else { - old_rpos2 = usb_recv2_rpos; - } - saved_old_rpos2 = old_rpos2; - new_rpos2 = usb_recv2_rpos + usb_len; - if (new_rpos2 >= usb_recv2_size) { - new_rpos2 -= usb_recv2_size; - } - if (recv2_valid && init_pos2 == 0) { - if (old_rpos2 <= wpos2) { - if (new_rpos2 < old_rpos2 || wpos2 < new_rpos2) { - if (recv2_state == AUDIO_ITF_STATE_STOPPED) { - if (new_rpos2 < old_rpos2) { - zero_mem(usb_recv2_buf + wpos2, usb_recv2_size - wpos2); - zero_mem(usb_recv2_buf, new_rpos2); - } else { - zero_mem(usb_recv2_buf + wpos2, new_rpos2 - wpos2); - } - wpos2 = new_rpos2; - usb_recv2_wpos = new_rpos2; - } else { - conflicted2 = 1; - } - } - } else { - if (wpos2 < new_rpos2 && new_rpos2 < old_rpos2) { - if (recv2_state == AUDIO_ITF_STATE_STOPPED) { - zero_mem(usb_recv2_buf + wpos2, new_rpos2 - wpos2); - wpos2 = new_rpos2; - usb_recv2_wpos = new_rpos2; - } else { - conflicted2 = 1; - } - } - } - if (conflicted2) { - // Reset read position - old_rpos2 = wpos2 + reset_len2; - if (old_rpos2 >= usb_recv2_size) { - old_rpos2 -= usb_recv2_size; - } - new_rpos2 = old_rpos2 + usb_len; - if (new_rpos2 >= usb_recv2_size) { - new_rpos2 -= usb_recv2_size; - } - // Update global read position - usb_recv2_rpos = old_rpos2; - } - } + conflicted2 = 0; #endif - int_unlock(lock); + lock = int_lock(); + wpos = usb_recv_wpos; + if (init_pos) { + old_rpos = wpos + reset_len; + if (old_rpos >= usb_recv_size) { + old_rpos -= usb_recv_size; + } + usb_recv_rpos = old_rpos; + usb_recv_init_rpos = 1; + } else { + old_rpos = usb_recv_rpos; + } + saved_old_rpos = old_rpos; + new_rpos = usb_recv_rpos + usb_len; + if (new_rpos >= usb_recv_size) { + new_rpos -= usb_recv_size; + } + if (recv_valid && init_pos == 0) { + if (old_rpos <= wpos) { + if (new_rpos < old_rpos || wpos < new_rpos) { + if (recv_state == AUDIO_ITF_STATE_STOPPED) { + if (new_rpos < old_rpos) { + zero_mem(usb_recv_buf + wpos, usb_recv_size - wpos); + zero_mem(usb_recv_buf, new_rpos); + } else { + zero_mem(usb_recv_buf + wpos, new_rpos - wpos); + } + wpos = new_rpos; + usb_recv_wpos = new_rpos; + } else { + conflicted = 1; + } + } + } else { + if (wpos < new_rpos && new_rpos < old_rpos) { + if (recv_state == AUDIO_ITF_STATE_STOPPED) { + zero_mem(usb_recv_buf + wpos, new_rpos - wpos); + wpos = new_rpos; + usb_recv_wpos = new_rpos; + } else { + conflicted = 1; + } + } + } if (conflicted) { - TRACE(4,"playback: Error: rpos=%u goes beyond wpos=%u with usb_len=%u. Reset to %u", saved_old_rpos, wpos, usb_len, old_rpos); + // Reset read position + old_rpos = wpos + reset_len; + if (old_rpos >= usb_recv_size) { + old_rpos -= usb_recv_size; + } + new_rpos = old_rpos + usb_len; + if (new_rpos >= usb_recv_size) { + new_rpos -= usb_recv_size; + } + // Update global read position + usb_recv_rpos = old_rpos; } + } + #ifdef USB_AUDIO_MULTIFUNC - if (conflicted2) { - TRACE(4,"playback: Error: rpos2=%u goes beyond wpos2=%u with usb_len=%u. Reset to %u", saved_old_rpos2, wpos2, usb_len, old_rpos2); + wpos2 = usb_recv2_wpos; + if (init_pos2) { + old_rpos2 = wpos2 + reset_len2; + if (old_rpos2 >= usb_recv2_size) { + old_rpos2 -= usb_recv2_size; } + usb_recv2_rpos = old_rpos2; + usb_recv2_init_rpos = 1; + } else { + old_rpos2 = usb_recv2_rpos; + } + saved_old_rpos2 = old_rpos2; + new_rpos2 = usb_recv2_rpos + usb_len; + if (new_rpos2 >= usb_recv2_size) { + new_rpos2 -= usb_recv2_size; + } + if (recv2_valid && init_pos2 == 0) { + if (old_rpos2 <= wpos2) { + if (new_rpos2 < old_rpos2 || wpos2 < new_rpos2) { + if (recv2_state == AUDIO_ITF_STATE_STOPPED) { + if (new_rpos2 < old_rpos2) { + zero_mem(usb_recv2_buf + wpos2, usb_recv2_size - wpos2); + zero_mem(usb_recv2_buf, new_rpos2); + } else { + zero_mem(usb_recv2_buf + wpos2, new_rpos2 - wpos2); + } + wpos2 = new_rpos2; + usb_recv2_wpos = new_rpos2; + } else { + conflicted2 = 1; + } + } + } else { + if (wpos2 < new_rpos2 && new_rpos2 < old_rpos2) { + if (recv2_state == AUDIO_ITF_STATE_STOPPED) { + zero_mem(usb_recv2_buf + wpos2, new_rpos2 - wpos2); + wpos2 = new_rpos2; + usb_recv2_wpos = new_rpos2; + } else { + conflicted2 = 1; + } + } + } + if (conflicted2) { + // Reset read position + old_rpos2 = wpos2 + reset_len2; + if (old_rpos2 >= usb_recv2_size) { + old_rpos2 -= usb_recv2_size; + } + new_rpos2 = old_rpos2 + usb_len; + if (new_rpos2 >= usb_recv2_size) { + new_rpos2 -= usb_recv2_size; + } + // Update global read position + usb_recv2_rpos = old_rpos2; + } + } +#endif + int_unlock(lock); + + if (conflicted) { + TRACE(4, + "playback: Error: rpos=%u goes beyond wpos=%u with usb_len=%u. Reset " + "to %u", + saved_old_rpos, wpos, usb_len, old_rpos); + } +#ifdef USB_AUDIO_MULTIFUNC + if (conflicted2) { + TRACE(4, + "playback: Error: rpos2=%u goes beyond wpos2=%u with usb_len=%u. " + "Reset to %u", + saved_old_rpos2, wpos2, usb_len, old_rpos2); + } #endif #if (VERBOSE_TRACE & (1 << 0)) - { - int hw_play_pos = af_stream_get_cur_dma_pos(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - uint32_t play_pos = buf - playback_buf; + { + int hw_play_pos = + af_stream_get_cur_dma_pos(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + uint32_t play_pos = buf - playback_buf; #ifdef USB_AUDIO_MULTIFUNC - if (recv_valid == 0) { - old_rpos = -1; - wpos = -1; - } - if (recv2_valid == 0) { - old_rpos2 = -1; - wpos2 = -1; - } - TRACE_TIME(8,"playback: rpos=%d/%d usb_len=%d wpos=%d/%d play_pos=%d len=%d hw_play_pos=%d", old_rpos, old_rpos2, usb_len, - wpos, wpos2, play_pos, len, hw_play_pos); -#else - TRACE_TIME(6,"playback: rpos=%d usb_len=%d wpos=%d play_pos=%d len=%d hw_play_pos=%d", old_rpos, usb_len, - wpos, play_pos, len, hw_play_pos); -#endif + if (recv_valid == 0) { + old_rpos = -1; + wpos = -1; } -#endif - - if (codec_play_seq != usb_recv_seq) { - goto _invalid_play; + if (recv2_valid == 0) { + old_rpos2 = -1; + wpos2 = -1; } - -#ifdef USB_AUDIO_MULTIFUNC - record_conflict(conflicted || conflicted2); + TRACE_TIME(8, + "playback: rpos=%d/%d usb_len=%d wpos=%d/%d play_pos=%d len=%d " + "hw_play_pos=%d", + old_rpos, old_rpos2, usb_len, wpos, wpos2, play_pos, len, + hw_play_pos); #else - record_conflict(conflicted); + TRACE_TIME(6, + "playback: rpos=%d usb_len=%d wpos=%d play_pos=%d len=%d " + "hw_play_pos=%d", + old_rpos, usb_len, wpos, play_pos, len, hw_play_pos); +#endif + } #endif - //---------------------------------------- - // USB->CODEC stream format conversion start - //---------------------------------------- + if (codec_play_seq != usb_recv_seq) { + goto _invalid_play; + } - conv_buf = buf; +#ifdef USB_AUDIO_MULTIFUNC + record_conflict(conflicted || conflicted2); +#else + record_conflict(conflicted); +#endif + + //---------------------------------------- + // USB->CODEC stream format conversion start + //---------------------------------------- + + conv_buf = buf; #ifdef USB_AUDIO_MULTIFUNC - { - uint8_t POSSIBLY_UNUSED *cur_buf, *buf_end, *usb_cur_buf, *usb_buf_end, *usb_cur_buf2, *usb_buf_end2; - uint32_t codec_step, usb_step; - float cur_gain, new_gain, cur_gain2, new_gain2, gain_step; + { + uint8_t POSSIBLY_UNUSED *cur_buf, *buf_end, *usb_cur_buf, *usb_buf_end, + *usb_cur_buf2, *usb_buf_end2; + uint32_t codec_step, usb_step; + float cur_gain, new_gain, cur_gain2, new_gain2, gain_step; - cur_buf = conv_buf; - buf_end = conv_buf + len; - usb_cur_buf = usb_recv_buf + old_rpos; - usb_buf_end = usb_recv_buf + usb_recv_size; - usb_cur_buf2 = usb_recv2_buf + old_rpos2; - usb_buf_end2 = usb_recv2_buf + usb_recv2_size; + cur_buf = conv_buf; + buf_end = conv_buf + len; + usb_cur_buf = usb_recv_buf + old_rpos; + usb_buf_end = usb_recv_buf + usb_recv_size; + usb_cur_buf2 = usb_recv2_buf + old_rpos2; + usb_buf_end2 = usb_recv2_buf + usb_recv2_size; - cur_gain = playback_coef; - new_gain = new_playback_coef; - cur_gain2 = playback2_coef; - new_gain2 = new_playback2_coef; - gain_step = USB_AUDIO_VOL_UPDATE_STEP; + cur_gain = playback_coef; + new_gain = new_playback_coef; + cur_gain2 = playback2_coef; + new_gain2 = new_playback2_coef; + gain_step = USB_AUDIO_VOL_UPDATE_STEP; - ASSERT(sample_rate_play == sample_rate_recv, "2:1: Invalid sample_rate_play=%u sample_rate_recv=%u", - sample_rate_play, sample_rate_recv); + ASSERT(sample_rate_play == sample_rate_recv, + "2:1: Invalid sample_rate_play=%u sample_rate_recv=%u", + sample_rate_play, sample_rate_recv); - if (0) { + if (0) { - } else if (sample_size_play == 4 && (sample_size_recv == 4 || sample_size_recv == 3 || sample_size_recv == 2)) { + } else if (sample_size_play == 4 && + (sample_size_recv == 4 || sample_size_recv == 3 || + sample_size_recv == 2)) { - int32_t left, right; - int32_t left2, right2; + int32_t left, right; + int32_t left2, right2; - if (sample_size_recv == 4) { - usb_step = 8; - } else if (sample_size_recv == 3) { - usb_step = 6; - } else { - usb_step = 4; + if (sample_size_recv == 4) { + usb_step = 8; + } else if (sample_size_recv == 3) { + usb_step = 6; + } else { + usb_step = 4; + } + + codec_step = 8; + + while (cur_buf + codec_step <= buf_end) { + if (usb_cur_buf + usb_step > usb_buf_end) { + usb_cur_buf = usb_recv_buf; + } + if (usb_cur_buf2 + usb_step > usb_buf_end2) { + usb_cur_buf2 = usb_recv2_buf; + } + if (recv_valid) { + if (usb_step == 8) { + left = *(int32_t *)usb_cur_buf; + right = *((int32_t *)usb_cur_buf + 1); + } else if (usb_step == 6) { + left = ((usb_cur_buf[0] << 8) | (usb_cur_buf[1] << 16) | + (usb_cur_buf[2] << 24)); + right = ((usb_cur_buf[3] << 8) | (usb_cur_buf[4] << 16) | + (usb_cur_buf[5] << 24)); + } else { + left = *(int16_t *)usb_cur_buf << 16; + right = *((int16_t *)usb_cur_buf + 1) << 16; + } + if (cur_gain > new_gain) { + cur_gain -= gain_step; + if (cur_gain < new_gain) { + cur_gain = new_gain; } - - codec_step = 8; - - while (cur_buf + codec_step <= buf_end) { - if (usb_cur_buf + usb_step > usb_buf_end) { - usb_cur_buf = usb_recv_buf; - } - if (usb_cur_buf2 + usb_step > usb_buf_end2) { - usb_cur_buf2 = usb_recv2_buf; - } - if (recv_valid) { - if (usb_step == 8) { - left = *(int32_t *)usb_cur_buf; - right = *((int32_t *)usb_cur_buf + 1); - } else if (usb_step == 6) { - left = ((usb_cur_buf[0] << 8) | (usb_cur_buf[1] << 16) | (usb_cur_buf[2] << 24)); - right = ((usb_cur_buf[3] << 8) | (usb_cur_buf[4] << 16) | (usb_cur_buf[5] << 24)); - } else { - left = *(int16_t *)usb_cur_buf << 16; - right = *((int16_t *)usb_cur_buf + 1) << 16; - } - if (cur_gain > new_gain) { - cur_gain -= gain_step; - if (cur_gain < new_gain) { - cur_gain = new_gain; - } - } else if (cur_gain < new_gain) { - cur_gain += gain_step; - if (cur_gain > new_gain) { - cur_gain = new_gain; - } - } - left = (int32_t)(left * cur_gain); - right = (int32_t)(right * cur_gain); - } else { - left = right = 0; - } - if (recv2_valid) { - if (usb_step == 8) { - left2 = *(int32_t *)usb_cur_buf2; - right2 = *((int32_t *)usb_cur_buf2 + 1); - } else if (usb_step == 6) { - left2 = ((usb_cur_buf2[0] << 8) | (usb_cur_buf2[1] << 16) | (usb_cur_buf2[2] << 24)); - right2 = ((usb_cur_buf2[3] << 8) | (usb_cur_buf2[4] << 16) | (usb_cur_buf2[5] << 24)); - } else { - left2 = *(int16_t *)usb_cur_buf2 << 16; - right2 = *((int16_t *)usb_cur_buf2 + 1) << 16; - } - if (cur_gain2 > new_gain2) { - cur_gain2 -= gain_step; - if (cur_gain2 < new_gain2) { - cur_gain2 = new_gain2; - } - } else if (cur_gain2 < new_gain2) { - cur_gain2 += gain_step; - if (cur_gain2 > new_gain2) { - cur_gain2 = new_gain2; - } - } - left2 = (int32_t)(left2 * cur_gain2); - right2 = (int32_t)(right2 * cur_gain2); - } else { - left2 = right2 = 0; - } - left = __QADD(left, left2); - right = __QADD(right, right2); - // Convert to 24-bit sample - left >>= 8; - right >>= 8; - - *(int32_t *)cur_buf = left; - *((int32_t *)cur_buf + 1) = right; - - cur_buf += codec_step; - usb_cur_buf += usb_step; - usb_cur_buf2 += usb_step; + } else if (cur_gain < new_gain) { + cur_gain += gain_step; + if (cur_gain > new_gain) { + cur_gain = new_gain; } - } else if (sample_size_play == 2 && sample_size_recv == 2) { - - int32_t left, right; - int32_t left2, right2; - - usb_step = 4; - codec_step = 4; - - while (cur_buf + codec_step <= buf_end) { - if (usb_cur_buf + usb_step > usb_buf_end) { - usb_cur_buf = usb_recv_buf; - } - if (usb_cur_buf2 + usb_step > usb_buf_end2) { - usb_cur_buf2 = usb_recv2_buf; - } - if (recv_valid) { - left = *(int16_t *)usb_cur_buf; - right = *((int16_t *)usb_cur_buf + 1); - if (cur_gain > new_gain) { - cur_gain -= gain_step; - if (cur_gain < new_gain) { - cur_gain = new_gain; - } - } else if (cur_gain < new_gain) { - cur_gain += gain_step; - if (cur_gain > new_gain) { - cur_gain = new_gain; - } - } - left = (int32_t)(left * cur_gain); - right = (int32_t)(right * cur_gain); - } else { - left = right = 0; - } - if (recv2_valid) { - left2 = *(int16_t *)usb_cur_buf2; - right2 = *((int16_t *)usb_cur_buf2 + 1); - if (cur_gain2 > new_gain2) { - cur_gain2 -= gain_step; - if (cur_gain2 < new_gain2) { - cur_gain2 = new_gain2; - } - } else if (cur_gain2 < new_gain2) { - cur_gain2 += gain_step; - if (cur_gain2 > new_gain2) { - cur_gain2 = new_gain2; - } - } - left2 = (int32_t)(left2 * cur_gain2); - right2 = (int32_t)(right2 * cur_gain2); - } else { - left2 = right2 = 0; - } - left = __SSAT(left + left2, 16); - right = __SSAT(right + right2, 16); - - *(int16_t *)cur_buf = left; - *((int16_t *)cur_buf + 1) = right; - - cur_buf += codec_step; - usb_cur_buf += usb_step; - } - + } + left = (int32_t)(left * cur_gain); + right = (int32_t)(right * cur_gain); } else { - - ASSERT(false, "2:3: Invalid sample_size_play=%u sample_size_recv=%u", - sample_size_play, sample_size_recv); - + left = right = 0; } + if (recv2_valid) { + if (usb_step == 8) { + left2 = *(int32_t *)usb_cur_buf2; + right2 = *((int32_t *)usb_cur_buf2 + 1); + } else if (usb_step == 6) { + left2 = ((usb_cur_buf2[0] << 8) | (usb_cur_buf2[1] << 16) | + (usb_cur_buf2[2] << 24)); + right2 = ((usb_cur_buf2[3] << 8) | (usb_cur_buf2[4] << 16) | + (usb_cur_buf2[5] << 24)); + } else { + left2 = *(int16_t *)usb_cur_buf2 << 16; + right2 = *((int16_t *)usb_cur_buf2 + 1) << 16; + } + if (cur_gain2 > new_gain2) { + cur_gain2 -= gain_step; + if (cur_gain2 < new_gain2) { + cur_gain2 = new_gain2; + } + } else if (cur_gain2 < new_gain2) { + cur_gain2 += gain_step; + if (cur_gain2 > new_gain2) { + cur_gain2 = new_gain2; + } + } + left2 = (int32_t)(left2 * cur_gain2); + right2 = (int32_t)(right2 * cur_gain2); + } else { + left2 = right2 = 0; + } + left = __QADD(left, left2); + right = __QADD(right, right2); + // Convert to 24-bit sample + left >>= 8; + right >>= 8; - playback_coef = cur_gain; - playback2_coef = cur_gain2; + *(int32_t *)cur_buf = left; + *((int32_t *)cur_buf + 1) = right; + + cur_buf += codec_step; + usb_cur_buf += usb_step; + usb_cur_buf2 += usb_step; + } + } else if (sample_size_play == 2 && sample_size_recv == 2) { + + int32_t left, right; + int32_t left2, right2; + + usb_step = 4; + codec_step = 4; + + while (cur_buf + codec_step <= buf_end) { + if (usb_cur_buf + usb_step > usb_buf_end) { + usb_cur_buf = usb_recv_buf; + } + if (usb_cur_buf2 + usb_step > usb_buf_end2) { + usb_cur_buf2 = usb_recv2_buf; + } + if (recv_valid) { + left = *(int16_t *)usb_cur_buf; + right = *((int16_t *)usb_cur_buf + 1); + if (cur_gain > new_gain) { + cur_gain -= gain_step; + if (cur_gain < new_gain) { + cur_gain = new_gain; + } + } else if (cur_gain < new_gain) { + cur_gain += gain_step; + if (cur_gain > new_gain) { + cur_gain = new_gain; + } + } + left = (int32_t)(left * cur_gain); + right = (int32_t)(right * cur_gain); + } else { + left = right = 0; + } + if (recv2_valid) { + left2 = *(int16_t *)usb_cur_buf2; + right2 = *((int16_t *)usb_cur_buf2 + 1); + if (cur_gain2 > new_gain2) { + cur_gain2 -= gain_step; + if (cur_gain2 < new_gain2) { + cur_gain2 = new_gain2; + } + } else if (cur_gain2 < new_gain2) { + cur_gain2 += gain_step; + if (cur_gain2 > new_gain2) { + cur_gain2 = new_gain2; + } + } + left2 = (int32_t)(left2 * cur_gain2); + right2 = (int32_t)(right2 * cur_gain2); + } else { + left2 = right2 = 0; + } + left = __SSAT(left + left2, 16); + right = __SSAT(right + right2, 16); + + *(int16_t *)cur_buf = left; + *((int16_t *)cur_buf + 1) = right; + + cur_buf += codec_step; + usb_cur_buf += usb_step; + } + + } else { + + ASSERT(false, "2:3: Invalid sample_size_play=%u sample_size_recv=%u", + sample_size_play, sample_size_recv); } + playback_coef = cur_gain; + playback2_coef = cur_gain2; + } + #else - { - uint8_t POSSIBLY_UNUSED *cur_buf, *buf_end, *usb_cur_buf, *usb_buf_end; - uint32_t codec_step, usb_step; - bool down_sampling = false; + { + uint8_t POSSIBLY_UNUSED *cur_buf, *buf_end, *usb_cur_buf, *usb_buf_end; + uint32_t codec_step, usb_step; + bool down_sampling = false; - cur_buf = conv_buf; - buf_end = conv_buf + len; - usb_cur_buf = usb_recv_buf + old_rpos; - usb_buf_end = usb_recv_buf + usb_recv_size; + cur_buf = conv_buf; + buf_end = conv_buf + len; + usb_cur_buf = usb_recv_buf + old_rpos; + usb_buf_end = usb_recv_buf + usb_recv_size; - if (0) { + if (0) { #ifdef CODEC_DSD - } else if (codec_dsd_enabled) { + } else if (codec_dsd_enabled) { - ASSERT(sample_size_play == 2, "Bad DSD playback sample size: %u", sample_size_play); - ASSERT(sample_size_recv == 4 || sample_size_recv == 3, "Bad DSD recv sample size: %u", sample_size_recv); + ASSERT(sample_size_play == 2, "Bad DSD playback sample size: %u", + sample_size_play); + ASSERT(sample_size_recv == 4 || sample_size_recv == 3, + "Bad DSD recv sample size: %u", sample_size_recv); - uint32_t left, right; + uint32_t left, right; - if (sample_size_recv == 4) { - usb_step = 8; - } else { - usb_step = 6; - } + if (sample_size_recv == 4) { + usb_step = 8; + } else { + usb_step = 6; + } - codec_step = 4; - - while (cur_buf + codec_step <= buf_end) { - if (usb_cur_buf + usb_step > usb_buf_end) { - usb_cur_buf = usb_recv_buf; - } - if (usb_step == 8) { - left = *(uint32_t *)usb_cur_buf; - right = *((uint32_t *)usb_cur_buf + 1); - } else { - left = ((usb_cur_buf[0] << 8) | (usb_cur_buf[1] << 16)); - right = ((usb_cur_buf[3] << 8) | (usb_cur_buf[4] << 16)); - } - - left = __RBIT(left) >> 8; - right = __RBIT(right) >> 8; - - *(uint16_t *)cur_buf = left; - *((uint16_t *)cur_buf + 1) = right; - - cur_buf += codec_step; - usb_cur_buf += usb_step; - } -#endif - - } else if (sample_size_play == 4 && (sample_size_recv == 4 || sample_size_recv == 3 || sample_size_recv == 2)) { - - int32_t left, right; - - if (sample_size_recv == 4) { - usb_step = 8; - } else if (sample_size_recv == 3) { - usb_step = 6; - } else { - usb_step = 4; - } - - if ((sample_rate_play == 96000 && sample_rate_recv == 48000) || - (sample_rate_play == 88200 && sample_rate_recv == 44100)) { - codec_step = 16; - } else if (sample_rate_play == sample_rate_recv) { - codec_step = 8; - } else if (sample_rate_play == 96000 && sample_rate_recv == 192000) { - codec_step = 8; - down_sampling = true; - } else { - ASSERT(false, "1: Invalid sample_rate_play=%u sample_rate_recv=%u", - sample_rate_play, sample_rate_recv); - } - - while (cur_buf + codec_step <= buf_end) { - if (usb_cur_buf + usb_step > usb_buf_end) { - usb_cur_buf = usb_recv_buf; - } - if (usb_step == 8) { - left = *(int32_t *)usb_cur_buf; - right = *((int32_t *)usb_cur_buf + 1); - } else if (usb_step == 6) { - left = ((usb_cur_buf[0] << 8) | (usb_cur_buf[1] << 16) | (usb_cur_buf[2] << 24)); - right = ((usb_cur_buf[3] << 8) | (usb_cur_buf[4] << 16) | (usb_cur_buf[5] << 24)); - } else { - left = *(int16_t *)usb_cur_buf << 16; - right = *((int16_t *)usb_cur_buf + 1) << 16; - } - // Convert to 24-bit sample - left >>= 8; - right >>= 8; - - if (down_sampling) { - int32_t left_next, right_next; - - usb_cur_buf += usb_step; - if (usb_cur_buf + usb_step > usb_buf_end) { - usb_cur_buf = usb_recv_buf; - } - if (usb_step == 8) { - left_next = *(int32_t *)usb_cur_buf; - right_next = *((int32_t *)usb_cur_buf + 1); - } else if (usb_step == 6) { - left_next = ((usb_cur_buf[0] << 8) | (usb_cur_buf[1] << 16) | (usb_cur_buf[2] << 24)); - right_next = ((usb_cur_buf[3] << 8) | (usb_cur_buf[4] << 16) | (usb_cur_buf[5] << 24)); - } else { - left_next = *(int16_t *)usb_cur_buf << 16; - right_next = *((int16_t *)usb_cur_buf + 1) << 16; - } - // Convert to 24-bit sample - left_next >>= 8; - right_next >>= 8; - - // The addition of two 24-bit integers will not saturate - left = (left + left_next) / 2; - right = (right + right_next) / 2; - } - - *(int32_t *)cur_buf = left; - *((int32_t *)cur_buf + 1) = right; - if (codec_step == 16) { - *((int32_t *)cur_buf + 2) = left; - *((int32_t *)cur_buf + 3) = right; - } - - cur_buf += codec_step; - usb_cur_buf += usb_step; - } - - } else if (sample_size_play == 2 && sample_size_recv == 2) { - - int16_t left, right; - - usb_step = 4; - - if ((sample_rate_play == 96000 && sample_rate_recv == 48000) || - (sample_rate_play == 88200 && sample_rate_recv == 44100)) { - codec_step = 8; - } else if (sample_rate_play == sample_rate_recv) { - codec_step = 4; - } else if (sample_rate_play == 96000 && sample_rate_recv == 192000) { - codec_step = 4; - down_sampling = true; - } else { - ASSERT(false, "2: Invalid sample_rate_play=%u sample_rate_recv=%u", - sample_rate_play, sample_rate_recv); - } - - while (cur_buf + codec_step <= buf_end) { - if (usb_cur_buf + usb_step > usb_buf_end) { - usb_cur_buf = usb_recv_buf; - } - left = *(int16_t *)usb_cur_buf; - right = *((int16_t *)usb_cur_buf + 1); - if (down_sampling) { - // Use 32-bit integers to avoid saturation - int32_t left32, right32; - - usb_cur_buf += usb_step; - if (usb_cur_buf + usb_step > usb_buf_end) { - usb_cur_buf = usb_recv_buf; - } - left32 = *(int16_t *)usb_cur_buf; - right32 = *((int16_t *)usb_cur_buf + 1); - left = (left + left32) / 2; - right = (right + right32) / 2; - } - *(int16_t *)cur_buf = left; - *((int16_t *)cur_buf + 1) = right; - if (codec_step == 8) { - *((int16_t *)cur_buf + 2) = left; - *((int16_t *)cur_buf + 3) = right; - } - cur_buf += codec_step; - usb_cur_buf += usb_step; - } + codec_step = 4; + while (cur_buf + codec_step <= buf_end) { + if (usb_cur_buf + usb_step > usb_buf_end) { + usb_cur_buf = usb_recv_buf; + } + if (usb_step == 8) { + left = *(uint32_t *)usb_cur_buf; + right = *((uint32_t *)usb_cur_buf + 1); } else { - - ASSERT(false, "3: Invalid sample_size_play=%u sample_size_recv=%u", - sample_size_play, sample_size_recv); - + left = ((usb_cur_buf[0] << 8) | (usb_cur_buf[1] << 16)); + right = ((usb_cur_buf[3] << 8) | (usb_cur_buf[4] << 16)); } + left = __RBIT(left) >> 8; + right = __RBIT(right) >> 8; + + *(uint16_t *)cur_buf = left; + *((uint16_t *)cur_buf + 1) = right; + + cur_buf += codec_step; + usb_cur_buf += usb_step; + } +#endif + + } else if (sample_size_play == 4 && + (sample_size_recv == 4 || sample_size_recv == 3 || + sample_size_recv == 2)) { + + int32_t left, right; + + if (sample_size_recv == 4) { + usb_step = 8; + } else if (sample_size_recv == 3) { + usb_step = 6; + } else { + usb_step = 4; + } + + if ((sample_rate_play == 96000 && sample_rate_recv == 48000) || + (sample_rate_play == 88200 && sample_rate_recv == 44100)) { + codec_step = 16; + } else if (sample_rate_play == sample_rate_recv) { + codec_step = 8; + } else if (sample_rate_play == 96000 && sample_rate_recv == 192000) { + codec_step = 8; + down_sampling = true; + } else { + ASSERT(false, "1: Invalid sample_rate_play=%u sample_rate_recv=%u", + sample_rate_play, sample_rate_recv); + } + + while (cur_buf + codec_step <= buf_end) { + if (usb_cur_buf + usb_step > usb_buf_end) { + usb_cur_buf = usb_recv_buf; + } + if (usb_step == 8) { + left = *(int32_t *)usb_cur_buf; + right = *((int32_t *)usb_cur_buf + 1); + } else if (usb_step == 6) { + left = ((usb_cur_buf[0] << 8) | (usb_cur_buf[1] << 16) | + (usb_cur_buf[2] << 24)); + right = ((usb_cur_buf[3] << 8) | (usb_cur_buf[4] << 16) | + (usb_cur_buf[5] << 24)); + } else { + left = *(int16_t *)usb_cur_buf << 16; + right = *((int16_t *)usb_cur_buf + 1) << 16; + } + // Convert to 24-bit sample + left >>= 8; + right >>= 8; + + if (down_sampling) { + int32_t left_next, right_next; + + usb_cur_buf += usb_step; + if (usb_cur_buf + usb_step > usb_buf_end) { + usb_cur_buf = usb_recv_buf; + } + if (usb_step == 8) { + left_next = *(int32_t *)usb_cur_buf; + right_next = *((int32_t *)usb_cur_buf + 1); + } else if (usb_step == 6) { + left_next = ((usb_cur_buf[0] << 8) | (usb_cur_buf[1] << 16) | + (usb_cur_buf[2] << 24)); + right_next = ((usb_cur_buf[3] << 8) | (usb_cur_buf[4] << 16) | + (usb_cur_buf[5] << 24)); + } else { + left_next = *(int16_t *)usb_cur_buf << 16; + right_next = *((int16_t *)usb_cur_buf + 1) << 16; + } + // Convert to 24-bit sample + left_next >>= 8; + right_next >>= 8; + + // The addition of two 24-bit integers will not saturate + left = (left + left_next) / 2; + right = (right + right_next) / 2; + } + + *(int32_t *)cur_buf = left; + *((int32_t *)cur_buf + 1) = right; + if (codec_step == 16) { + *((int32_t *)cur_buf + 2) = left; + *((int32_t *)cur_buf + 3) = right; + } + + cur_buf += codec_step; + usb_cur_buf += usb_step; + } + + } else if (sample_size_play == 2 && sample_size_recv == 2) { + + int16_t left, right; + + usb_step = 4; + + if ((sample_rate_play == 96000 && sample_rate_recv == 48000) || + (sample_rate_play == 88200 && sample_rate_recv == 44100)) { + codec_step = 8; + } else if (sample_rate_play == sample_rate_recv) { + codec_step = 4; + } else if (sample_rate_play == 96000 && sample_rate_recv == 192000) { + codec_step = 4; + down_sampling = true; + } else { + ASSERT(false, "2: Invalid sample_rate_play=%u sample_rate_recv=%u", + sample_rate_play, sample_rate_recv); + } + + while (cur_buf + codec_step <= buf_end) { + if (usb_cur_buf + usb_step > usb_buf_end) { + usb_cur_buf = usb_recv_buf; + } + left = *(int16_t *)usb_cur_buf; + right = *((int16_t *)usb_cur_buf + 1); + if (down_sampling) { + // Use 32-bit integers to avoid saturation + int32_t left32, right32; + + usb_cur_buf += usb_step; + if (usb_cur_buf + usb_step > usb_buf_end) { + usb_cur_buf = usb_recv_buf; + } + left32 = *(int16_t *)usb_cur_buf; + right32 = *((int16_t *)usb_cur_buf + 1); + left = (left + left32) / 2; + right = (right + right32) / 2; + } + *(int16_t *)cur_buf = left; + *((int16_t *)cur_buf + 1) = right; + if (codec_step == 8) { + *((int16_t *)cur_buf + 2) = left; + *((int16_t *)cur_buf + 3) = right; + } + cur_buf += codec_step; + usb_cur_buf += usb_step; + } + + } else { + + ASSERT(false, "3: Invalid sample_size_play=%u sample_size_recv=%u", + sample_size_play, sample_size_recv); } + } #endif // !USB_AUDIO_MULTIFUNC - //---------------------------------------- - // USB->CODEC stream format conversion end - //---------------------------------------- + //---------------------------------------- + // USB->CODEC stream format conversion end + //---------------------------------------- _conv_end: - play_next = buf + len - playback_buf; - if (play_next >= playback_size) { - play_next -= playback_size; - } + play_next = buf + len - playback_buf; + if (play_next >= playback_size) { + play_next -= playback_size; + } - lock = int_lock(); - if (codec_play_seq == usb_recv_seq) { + lock = int_lock(); + if (codec_play_seq == usb_recv_seq) { #ifdef USB_AUDIO_MULTIFUNC - if (playback_state == AUDIO_ITF_STATE_STARTED) { - if (recv_valid) { - usb_recv_rpos = new_rpos; - } - if (recv2_valid) { - usb_recv2_rpos = new_rpos2; - } - } else { - if (recv_valid) { - usb_recv_rpos = 0; - } - if (recv2_valid) { - usb_recv2_rpos = 0; - } - } - if (conflicted) { - playback_conflicted = conflicted; - } - if (conflicted2) { - playback_conflicted2 = conflicted2; - } -#else - if (playback_state == AUDIO_ITF_STATE_STARTED) { - usb_recv_rpos = new_rpos; - } else { - usb_recv_rpos = 0; - } - if (conflicted) { - playback_conflicted = conflicted; - } -#endif - playback_pos = play_next; + if (playback_state == AUDIO_ITF_STATE_STARTED) { + if (recv_valid) { + usb_recv_rpos = new_rpos; + } + if (recv2_valid) { + usb_recv2_rpos = new_rpos2; + } + } else { + if (recv_valid) { + usb_recv_rpos = 0; + } + if (recv2_valid) { + usb_recv2_rpos = 0; + } } - int_unlock(lock); + if (conflicted) { + playback_conflicted = conflicted; + } + if (conflicted2) { + playback_conflicted2 = conflicted2; + } +#else + if (playback_state == AUDIO_ITF_STATE_STARTED) { + usb_recv_rpos = new_rpos; + } else { + usb_recv_rpos = 0; + } + if (conflicted) { + playback_conflicted = conflicted; + } +#endif + playback_pos = play_next; + } + int_unlock(lock); - //---------------------------------------- - // Audio processing start - //---------------------------------------- + //---------------------------------------- + // Audio processing start + //---------------------------------------- #ifdef FREQ_RESP_EQ - freq_resp_eq_run(conv_buf, len); + freq_resp_eq_run(conv_buf, len); #endif #if defined(__HW_FIR_DSD_PROCESS__) - if (codec_dsd_enabled) { - dsd_process(conv_buf,len); - } + if (codec_dsd_enabled) { + dsd_process(conv_buf, len); + } #endif -#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__)|| defined(__HW_IIR_EQ_PROCESS__) - if (eq_opened) { - audio_process_run(conv_buf, len); - } +#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__) || \ + defined(__HW_IIR_EQ_PROCESS__) + if (eq_opened) { + audio_process_run(conv_buf, len); + } #endif - // If conv_buf != buf, copy the output to buf + // If conv_buf != buf, copy the output to buf - //---------------------------------------- - // Audio processing end - //---------------------------------------- + //---------------------------------------- + // Audio processing end + //---------------------------------------- #ifdef NOISE_GATING - bool noise_mute = true; + bool noise_mute = true; #ifdef NOISE_REDUCTION - bool nr_fire = true; - uint8_t chan = 0; + bool nr_fire = true; + uint8_t chan = 0; #endif - if (sample_size_play == 2) { - int16_t *samp = (int16_t *)buf; - for (uint32_t i = 0; i < len / 2; i++) { - if (ABS(samp[i]) >= NOISE_GATING_THRESH_16BIT) { - noise_mute = false; - break; - } - // NOISE_REDUCTION is unstable for 16-bit streams for unknown reasons. Skip by now. - } - } else { - int32_t *samp = (int32_t *)buf; - for (uint32_t i = 0; i < len / 4; i++) { - if (ABS(samp[i]) >= NOISE_GATING_THRESH_24BIT) { - noise_mute = false; + if (sample_size_play == 2) { + int16_t *samp = (int16_t *)buf; + for (uint32_t i = 0; i < len / 2; i++) { + if (ABS(samp[i]) >= NOISE_GATING_THRESH_16BIT) { + noise_mute = false; + break; + } + // NOISE_REDUCTION is unstable for 16-bit streams for unknown reasons. + // Skip by now. + } + } else { + int32_t *samp = (int32_t *)buf; + for (uint32_t i = 0; i < len / 4; i++) { + if (ABS(samp[i]) >= NOISE_GATING_THRESH_24BIT) { + noise_mute = false; #ifndef NOISE_REDUCTION - break; + break; #endif - } + } #ifdef NOISE_REDUCTION - if (nr_fire) { - if (ABS(samp[i]) >= NOISE_REDUCTION_THRESH_24BIT) { - nr_fire = false; - } else { - cur_zero_diff[chan][0]++; - cur_zero_diff[chan][1]++; - if ((prev_samp_positive[chan] && samp[i] < 0) || - (!prev_samp_positive[chan] && samp[i] >= 0)) { - if (ABS(cur_zero_diff[chan][prev_samp_positive[chan]] - - prev_zero_diff[chan][prev_samp_positive[chan]]) < 2) { - if (nr_cont_cnt < NOISE_REDUCTION_MATCH_CNT) { - nr_cont_cnt++; - } - } else if (nr_cont_cnt > 2) { - nr_fire = false; - } - prev_zero_diff[chan][prev_samp_positive[chan]] = cur_zero_diff[chan][prev_samp_positive[chan]]; - cur_zero_diff[chan][prev_samp_positive[chan]] = 0; - } - prev_samp_positive[chan] = (samp[i] >= 0); - // Switch channel - chan = !chan; - } + if (nr_fire) { + if (ABS(samp[i]) >= NOISE_REDUCTION_THRESH_24BIT) { + nr_fire = false; + } else { + cur_zero_diff[chan][0]++; + cur_zero_diff[chan][1]++; + if ((prev_samp_positive[chan] && samp[i] < 0) || + (!prev_samp_positive[chan] && samp[i] >= 0)) { + if (ABS(cur_zero_diff[chan][prev_samp_positive[chan]] - + prev_zero_diff[chan][prev_samp_positive[chan]]) < 2) { + if (nr_cont_cnt < NOISE_REDUCTION_MATCH_CNT) { + nr_cont_cnt++; + } + } else if (nr_cont_cnt > 2) { + nr_fire = false; } -#endif + prev_zero_diff[chan][prev_samp_positive[chan]] = + cur_zero_diff[chan][prev_samp_positive[chan]]; + cur_zero_diff[chan][prev_samp_positive[chan]] = 0; + } + prev_samp_positive[chan] = (samp[i] >= 0); + // Switch channel + chan = !chan; } + } +#endif } + } #ifdef NOISE_REDUCTION - if (noise_mute) { - nr_fire = false; + if (noise_mute) { + nr_fire = false; + } + if (nr_fire) { + if (nr_cont_cnt >= NOISE_REDUCTION_MATCH_CNT && !nr_active && + noise_reduction_cmd != NOISE_REDUCTION_CMD_FIRE) { + if (cur_time - last_nr_restore_time >= NOISE_REDUCTION_INTERVAL) { + TRACE(8, + "\nFire noise reduction: cur0=%u/%u cur1=%u/%u prev0=%u/%u " + "prev1=%u/%u\n", + cur_zero_diff[0][0], cur_zero_diff[0][1], cur_zero_diff[1][0], + cur_zero_diff[1][1], prev_zero_diff[0][0], prev_zero_diff[0][1], + prev_zero_diff[1][0], prev_zero_diff[1][1]); + noise_reduction_cmd = NOISE_REDUCTION_CMD_FIRE; + enqueue_unique_cmd(AUDIO_CMD_NOISE_REDUCTION); + } } - if (nr_fire) { - if (nr_cont_cnt >= NOISE_REDUCTION_MATCH_CNT && - !nr_active && noise_reduction_cmd != NOISE_REDUCTION_CMD_FIRE) { - if (cur_time - last_nr_restore_time >= NOISE_REDUCTION_INTERVAL) { - TRACE(8,"\nFire noise reduction: cur0=%u/%u cur1=%u/%u prev0=%u/%u prev1=%u/%u\n", - cur_zero_diff[0][0], cur_zero_diff[0][1], cur_zero_diff[1][0], cur_zero_diff[1][1], - prev_zero_diff[0][0], prev_zero_diff[0][1], prev_zero_diff[1][0], prev_zero_diff[1][1]); - noise_reduction_cmd = NOISE_REDUCTION_CMD_FIRE; - enqueue_unique_cmd(AUDIO_CMD_NOISE_REDUCTION); - } - } - } else { - if (nr_active && noise_reduction_cmd != NOISE_REDUCTION_CMD_RESTORE) { - TRACE(8,"\nRestore noise reduction: cur0=%u/%u cur1=%u/%u prev0=%u/%u prev1=%u/%u\n", - cur_zero_diff[0][0], cur_zero_diff[0][1], cur_zero_diff[1][0], cur_zero_diff[1][1], - prev_zero_diff[0][0], prev_zero_diff[0][1], prev_zero_diff[1][0], prev_zero_diff[1][1]); - noise_reduction_cmd = NOISE_REDUCTION_CMD_RESTORE; - enqueue_unique_cmd(AUDIO_CMD_NOISE_REDUCTION); - } - memset(prev_zero_diff, 0, sizeof(prev_zero_diff)); - memset(cur_zero_diff, 0, sizeof(cur_zero_diff)); - nr_cont_cnt = 0; - last_nr_restore_time = cur_time; + } else { + if (nr_active && noise_reduction_cmd != NOISE_REDUCTION_CMD_RESTORE) { + TRACE(8, + "\nRestore noise reduction: cur0=%u/%u cur1=%u/%u prev0=%u/%u " + "prev1=%u/%u\n", + cur_zero_diff[0][0], cur_zero_diff[0][1], cur_zero_diff[1][0], + cur_zero_diff[1][1], prev_zero_diff[0][0], prev_zero_diff[0][1], + prev_zero_diff[1][0], prev_zero_diff[1][1]); + noise_reduction_cmd = NOISE_REDUCTION_CMD_RESTORE; + enqueue_unique_cmd(AUDIO_CMD_NOISE_REDUCTION); } + memset(prev_zero_diff, 0, sizeof(prev_zero_diff)); + memset(cur_zero_diff, 0, sizeof(cur_zero_diff)); + nr_cont_cnt = 0; + last_nr_restore_time = cur_time; + } #endif - if (noise_mute) { - if ((mute_user_map & (1 << CODEC_MUTE_USER_NOISE_GATING)) == 0 && noise_gating_cmd != NOISE_GATING_CMD_MUTE) { - if (cur_time - last_high_signal_time >= NOISE_GATING_INTERVAL) { - noise_gating_cmd = NOISE_GATING_CMD_MUTE; - enqueue_unique_cmd(AUDIO_CMD_NOISE_GATING); - } - } - } else { - if ((mute_user_map & (1 << CODEC_MUTE_USER_NOISE_GATING)) && noise_gating_cmd != NOISE_GATING_CMD_UNMUTE) { - noise_gating_cmd = NOISE_GATING_CMD_UNMUTE; - enqueue_unique_cmd(AUDIO_CMD_NOISE_GATING); - } - last_high_signal_time = cur_time; + if (noise_mute) { + if ((mute_user_map & (1 << CODEC_MUTE_USER_NOISE_GATING)) == 0 && + noise_gating_cmd != NOISE_GATING_CMD_MUTE) { + if (cur_time - last_high_signal_time >= NOISE_GATING_INTERVAL) { + noise_gating_cmd = NOISE_GATING_CMD_MUTE; + enqueue_unique_cmd(AUDIO_CMD_NOISE_GATING); + } } + } else { + if ((mute_user_map & (1 << CODEC_MUTE_USER_NOISE_GATING)) && + noise_gating_cmd != NOISE_GATING_CMD_UNMUTE) { + noise_gating_cmd = NOISE_GATING_CMD_UNMUTE; + enqueue_unique_cmd(AUDIO_CMD_NOISE_GATING); + } + last_high_signal_time = cur_time; + } #endif #if (VERBOSE_TRACE & (1 << 1)) - { - int hw_play_pos = af_stream_get_cur_dma_pos(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - TRACE_TIME(2,"playbackEnd: playback_pos=%u hw_play_pos=%d", playback_pos, hw_play_pos); - } + { + int hw_play_pos = + af_stream_get_cur_dma_pos(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + TRACE_TIME(2, "playbackEnd: playback_pos=%u hw_play_pos=%d", playback_pos, + hw_play_pos); + } #endif - return 0; + return 0; } -static uint32_t usb_audio_data_capture(uint8_t *buf, uint32_t len) -{ - uint32_t usb_len; - uint32_t old_wpos, saved_old_wpos, new_wpos, rpos; - uint8_t init_pos; - uint8_t conflicted; - uint32_t reset_len = usb_send_size / 2; - uint32_t cap_next; - uint32_t lock; - uint8_t *conv_buf; - uint32_t cur_time; - uint32_t usb_time; +static uint32_t usb_audio_data_capture(uint8_t *buf, uint32_t len) { + uint32_t usb_len; + uint32_t old_wpos, saved_old_wpos, new_wpos, rpos; + uint8_t init_pos; + uint8_t conflicted; + uint32_t reset_len = usb_send_size / 2; + uint32_t cap_next; + uint32_t lock; + uint8_t *conv_buf; + uint32_t cur_time; + uint32_t usb_time; #ifdef SW_CAPTURE_RESAMPLE - enum RESAMPLE_STATUS_T ret; - struct RESAMPLE_IO_BUF_T io; - uint32_t in_size; - uint32_t out_size; - uint32_t resample_frame_len = 0; + enum RESAMPLE_STATUS_T ret; + struct RESAMPLE_IO_BUF_T io; + uint32_t in_size; + uint32_t out_size; + uint32_t resample_frame_len = 0; #endif - usb_time = last_usb_send_time; - cur_time = hal_sys_timer_get(); + usb_time = last_usb_send_time; + cur_time = hal_sys_timer_get(); - ASSERT(((uint32_t)buf & 0x3) == 0, "%s: Invalid buf: %p", __FUNCTION__, buf); + ASSERT(((uint32_t)buf & 0x3) == 0, "%s: Invalid buf: %p", __FUNCTION__, buf); - if (codec_cap_valid == 0 && cur_time - codec_cap_start_time >= CAPTURE_STABLE_INTERVAL) { - codec_cap_valid = 1; - } + if (codec_cap_valid == 0 && + cur_time - codec_cap_start_time >= CAPTURE_STABLE_INTERVAL) { + codec_cap_valid = 1; + } - if (codec_cap_seq != usb_send_seq || - capture_state == AUDIO_ITF_STATE_STOPPED || - send_state == AUDIO_ITF_STATE_STOPPED || - codec_cap_valid == 0 || - usb_send_valid == 0 || - cur_time - usb_time > USB_MAX_XFER_INTERVAL) { -_invalid_cap: - new_wpos = 0; - conflicted = 0; - goto _conv_end; - } - - if (usb_send_init_wpos) { - init_pos = 0; - } else { - init_pos = 1; - } - - //---------------------------------------- - // Check conflict - //---------------------------------------- - - usb_len = capture_to_send_len(len); + if (codec_cap_seq != usb_send_seq || + capture_state == AUDIO_ITF_STATE_STOPPED || + send_state == AUDIO_ITF_STATE_STOPPED || codec_cap_valid == 0 || + usb_send_valid == 0 || cur_time - usb_time > USB_MAX_XFER_INTERVAL) { + _invalid_cap: + new_wpos = 0; conflicted = 0; + goto _conv_end; + } - lock = int_lock(); - rpos = usb_send_rpos; - if (init_pos) { - old_wpos = rpos + reset_len; - if (old_wpos >= usb_send_size) { - old_wpos -= usb_send_size; - } - usb_send_wpos = old_wpos; - usb_send_init_wpos = 1; + if (usb_send_init_wpos) { + init_pos = 0; + } else { + init_pos = 1; + } + + //---------------------------------------- + // Check conflict + //---------------------------------------- + + usb_len = capture_to_send_len(len); + conflicted = 0; + + lock = int_lock(); + rpos = usb_send_rpos; + if (init_pos) { + old_wpos = rpos + reset_len; + if (old_wpos >= usb_send_size) { + old_wpos -= usb_send_size; + } + usb_send_wpos = old_wpos; + usb_send_init_wpos = 1; + } else { + old_wpos = usb_send_wpos; + } + saved_old_wpos = old_wpos; + new_wpos = usb_send_wpos + usb_len; + if (new_wpos >= usb_send_size) { + new_wpos -= usb_send_size; + } + if (init_pos == 0) { + if (old_wpos <= rpos) { + if (new_wpos < old_wpos || rpos < new_wpos) { + conflicted = 1; + } } else { - old_wpos = usb_send_wpos; + if (rpos < new_wpos && new_wpos < old_wpos) { + conflicted = 1; + } } - saved_old_wpos = old_wpos; - new_wpos = usb_send_wpos + usb_len; - if (new_wpos >= usb_send_size) { - new_wpos -= usb_send_size; - } - if (init_pos == 0) { - if (old_wpos <= rpos) { - if (new_wpos < old_wpos || rpos < new_wpos) { - conflicted = 1; - } - } else { - if (rpos < new_wpos && new_wpos < old_wpos) { - conflicted = 1; - } - } - if (conflicted) { - // Reset write position - old_wpos = rpos + reset_len; - if (old_wpos >= usb_send_size) { - old_wpos -= usb_send_size; - } - new_wpos = old_wpos + usb_len; - if (new_wpos >= usb_send_size) { - new_wpos -= usb_send_size; - } - // Update global write position - usb_send_wpos = old_wpos; - } - } - int_unlock(lock); - if (conflicted) { - TRACE(4,"capture: Error: wpos=%u goes beyond rpos=%u with usb_len=%u. Reset to %u", saved_old_wpos, rpos, usb_len, old_wpos); + // Reset write position + old_wpos = rpos + reset_len; + if (old_wpos >= usb_send_size) { + old_wpos -= usb_send_size; + } + new_wpos = old_wpos + usb_len; + if (new_wpos >= usb_send_size) { + new_wpos -= usb_send_size; + } + // Update global write position + usb_send_wpos = old_wpos; } + } + int_unlock(lock); + + if (conflicted) { + TRACE(4, + "capture: Error: wpos=%u goes beyond rpos=%u with usb_len=%u. Reset " + "to %u", + saved_old_wpos, rpos, usb_len, old_wpos); + } #if (VERBOSE_TRACE & (1 << 2)) - TRACE_TIME(5,"capture: wpos=%u usb_len=%u rpos=%u cap_pos=%u len=%u", old_wpos, usb_len, rpos, buf + len - capture_buf, len); + TRACE_TIME(5, "capture: wpos=%u usb_len=%u rpos=%u cap_pos=%u len=%u", + old_wpos, usb_len, rpos, buf + len - capture_buf, len); #endif - if (codec_cap_seq != usb_send_seq) { - goto _invalid_cap; - } + if (codec_cap_seq != usb_send_seq) { + goto _invalid_cap; + } - record_conflict(conflicted); + record_conflict(conflicted); - //---------------------------------------- - // Audio processing start - //---------------------------------------- + //---------------------------------------- + // Audio processing start + //---------------------------------------- - // TODO ... + // TODO ... - //---------------------------------------- - // Audio processing end - //---------------------------------------- + //---------------------------------------- + // Audio processing end + //---------------------------------------- - //---------------------------------------- - // Speech processing start - //---------------------------------------- + //---------------------------------------- + // Speech processing start + //---------------------------------------- #ifdef USB_AUDIO_SPEECH - speech_process_capture_run(buf, &len); + speech_process_capture_run(buf, &len); #endif - //---------------------------------------- - // Speech processing end - //---------------------------------------- + //---------------------------------------- + // Speech processing end + //---------------------------------------- - //---------------------------------------- - // CODEC->USB stream format conversion start - //---------------------------------------- + //---------------------------------------- + // CODEC->USB stream format conversion start + //---------------------------------------- - conv_buf = buf; + conv_buf = buf; - { - uint8_t POSSIBLY_UNUSED *cur_buf, *buf_end, *dst_buf_start, *dst_cur_buf, *dst_buf_end; + { + uint8_t POSSIBLY_UNUSED *cur_buf, *buf_end, *dst_buf_start, *dst_cur_buf, + *dst_buf_end; - cur_buf = conv_buf; - buf_end = conv_buf + len; + cur_buf = conv_buf; + buf_end = conv_buf + len; #ifdef SW_CAPTURE_RESAMPLE - if (resample_cap_enabled) { + if (resample_cap_enabled) { #if (CHAN_NUM_CAPTURE == CHAN_NUM_SEND) #if (defined(CHIP_BEST1000) && (defined(ANC_APP) || defined(_DUAL_AUX_MIC_))) - // codec capture buffer --(ref rate conversion)--> resample input buffer --(resample)--> usb send buffer + // codec capture buffer --(ref rate conversion)--> resample input buffer + // --(resample)--> usb send buffer #ifdef USB_AUDIO_DYN_CFG - // Resample frame len is the capture reference len after reference rate conversion - resample_frame_len = capture_to_ref_len(len); + // Resample frame len is the capture reference len after reference rate + // conversion + resample_frame_len = capture_to_ref_len(len); #else - // Resample frame len is the capture len - resample_frame_len = len; + // Resample frame len is the capture len + resample_frame_len = len; #endif - ASSERT(resample_frame_len <= resample_input_size, - "resample_input_size too small: %u len=%u resample_frame_len=%u", - resample_input_size, len, resample_frame_len); + ASSERT(resample_frame_len <= resample_input_size, + "resample_input_size too small: %u len=%u resample_frame_len=%u", + resample_input_size, len, resample_frame_len); - dst_buf_start = resample_input_buf; - dst_cur_buf = resample_input_buf; - dst_buf_end = resample_input_buf + resample_frame_len; -#else // !(CHIP_BEST1000 && (ANC_APP || _DUAL_AUX_MIC_)) - // codec capture buffer --(resample)--> usb send buffer + dst_buf_start = resample_input_buf; + dst_cur_buf = resample_input_buf; + dst_buf_end = resample_input_buf + resample_frame_len; +#else // !(CHIP_BEST1000 && (ANC_APP || _DUAL_AUX_MIC_)) + // codec capture buffer --(resample)--> usb send buffer - resample_input_buf = cur_buf; - // Resample frame len is the capture len - resample_frame_len = len; + resample_input_buf = cur_buf; + // Resample frame len is the capture len + resample_frame_len = len; - dst_buf_start = cur_buf; - dst_cur_buf = cur_buf; - dst_buf_end = cur_buf + len; + dst_buf_start = cur_buf; + dst_cur_buf = cur_buf; + dst_buf_end = cur_buf + len; #endif // !(CHIP_BEST1000 && (ANC_APP || _DUAL_AUX_MIC_)) #elif (CHAN_NUM_CAPTURE == 2) && (CHAN_NUM_SEND == 1) - // codec capture buffer --(chan num conversion)--> codec capture buffer --(resample)--> usb send buffer + // codec capture buffer --(chan num conversion)--> codec capture buffer + // --(resample)--> usb send buffer - resample_input_buf = cur_buf; - // Resample frame len is half of the capture len - resample_frame_len = len / 2; + resample_input_buf = cur_buf; + // Resample frame len is half of the capture len + resample_frame_len = len / 2; - dst_buf_start = cur_buf; - dst_cur_buf = cur_buf; - dst_buf_end = cur_buf + resample_frame_len; + dst_buf_start = cur_buf; + dst_cur_buf = cur_buf; + dst_buf_end = cur_buf + resample_frame_len; #elif (CHAN_NUM_CAPTURE == 1) && (CHAN_NUM_SEND == 2) - // codec capture buffer --(resample)--> usb send buffer --(chan num conversion)--> usb send buffer + // codec capture buffer --(resample)--> usb send buffer --(chan num + // conversion)--> usb send buffer - // Resample frame len is the capture len - resample_frame_len = len; + // Resample frame len is the capture len + resample_frame_len = len; - io.in = cur_buf; - io.in_size = resample_frame_len; - io.out = usb_send_buf + old_wpos; - io.out_size = usb_len / 2; - io.out_cyclic_start = usb_send_buf; - io.out_cyclic_end = usb_send_buf + usb_send_size; + io.in = cur_buf; + io.in_size = resample_frame_len; + io.out = usb_send_buf + old_wpos; + io.out_size = usb_len / 2; + io.out_cyclic_start = usb_send_buf; + io.out_cyclic_end = usb_send_buf + usb_send_size; - ret = audio_resample_ex_run(resample_id, &io, &in_size, &out_size); - ASSERT((ret == RESAMPLE_STATUS_IN_EMPTY || ret == RESAMPLE_STATUS_DONE) && io.out_size >= out_size, - "Failed to resample: %d io.out_size=%u in_size=%u out_size=%u", - ret, io.out_size, in_size, out_size); + ret = audio_resample_ex_run(resample_id, &io, &in_size, &out_size); + ASSERT((ret == RESAMPLE_STATUS_IN_EMPTY || ret == RESAMPLE_STATUS_DONE) && + io.out_size >= out_size, + "Failed to resample: %d io.out_size=%u in_size=%u out_size=%u", + ret, io.out_size, in_size, out_size); - uint32_t diff = usb_len - out_size * 2; - if (new_wpos >= diff) { - new_wpos -= diff; - } else { - new_wpos = new_wpos + usb_send_size - diff; - } + uint32_t diff = usb_len - out_size * 2; + if (new_wpos >= diff) { + new_wpos -= diff; + } else { + new_wpos = new_wpos + usb_send_size - diff; + } #if (VERBOSE_TRACE & (1 << 3)) - TRACE(5,"cap_resample: new_wpos=%u, in: %u -> %u, out: %u -> %u", new_wpos, io.in_size, in_size, io.out_size, out_size); + TRACE(5, "cap_resample: new_wpos=%u, in: %u -> %u, out: %u -> %u", + new_wpos, io.in_size, in_size, io.out_size, out_size); #endif - dst_buf_start = usb_send_buf; - dst_cur_buf = usb_send_buf + old_wpos; - dst_buf_end = usb_send_buf + usb_send_size; - cur_buf = dst_cur_buf; - buf_end = cur_buf + out_size; - if (buf_end >= usb_send_buf + usb_send_size) { - buf_end -= usb_send_size; - } + dst_buf_start = usb_send_buf; + dst_cur_buf = usb_send_buf + old_wpos; + dst_buf_end = usb_send_buf + usb_send_size; + cur_buf = dst_cur_buf; + buf_end = cur_buf + out_size; + if (buf_end >= usb_send_buf + usb_send_size) { + buf_end -= usb_send_size; + } #else #error "Unsupported CHAN_NUM_CAPTURE and CHAN_NUM_SEND configuration" #endif - } else + } else #endif // SW_CAPTURE_RESAMPLE - { - dst_buf_start = usb_send_buf; - dst_cur_buf = usb_send_buf + old_wpos; - dst_buf_end = usb_send_buf + usb_send_size; - } + { + dst_buf_start = usb_send_buf; + dst_cur_buf = usb_send_buf + old_wpos; + dst_buf_end = usb_send_buf + usb_send_size; + } #if defined(CHIP_BEST1000) && defined(_DUAL_AUX_MIC_) - // Assuming codec adc records stereo data, and usb sends 48K/44.1K stereo data + // Assuming codec adc records stereo data, and usb sends 48K/44.1K stereo + // data #if (CHAN_NUM_CAPTURE != 2) || (CHAN_NUM_SEND != 2) #error "Unsupported CHAN_NUM_CAPTURE and CHAN_NUM_SEND configuration" #endif { -#define MERGE_VER 2 +#define MERGE_VER 2 #if (MERGE_VER == 2) -#define THRES_MIC3 32500 +#define THRES_MIC3 32500 #else -#define THRES_MIC3 27168 +#define THRES_MIC3 27168 #endif -#define SHIFT_BITS 4 +#define SHIFT_BITS 4 - uint32_t i = 0; - short* BufSrc = (short*)cur_buf; - short* BufDst = (short*)dst_cur_buf; - short* BufDstStart = (short*)dst_buf_start; - short* BufDstEnd = (short*)dst_buf_end; + uint32_t i = 0; + short *BufSrc = (short *)cur_buf; + short *BufDst = (short *)dst_cur_buf; + short *BufDstStart = (short *)dst_buf_start; + short *BufDstEnd = (short *)dst_buf_end; - int32_t PcmValue = 0; - int32_t BufSrcRVal = 0; + int32_t PcmValue = 0; + int32_t BufSrcRVal = 0; - uint32_t step; + uint32_t step; - //TRACE(3,"%s - %d, %d", __func__, BufSrc[0], BufSrc[1]); - //TRACE(2,"%s - %d", __func__, TICKS_TO_MS(cur_time)); + // TRACE(3,"%s - %d, %d", __func__, BufSrc[0], BufSrc[1]); + // TRACE(2,"%s - %d", __func__, TICKS_TO_MS(cur_time)); - if (sample_rate_cap == 384000 || sample_rate_cap == 352800) { - step = 2; - } else if (sample_rate_cap == 192000 || sample_rate_cap == 176400) { - step = 1; - } else { - ASSERT(false, "1: Invalid sample_rate_cap=%u sample_rate_ref_cap=%u sample_rate_send=%u", sample_rate_cap, sample_rate_ref_cap, sample_rate_send); - } + if (sample_rate_cap == 384000 || sample_rate_cap == 352800) { + step = 2; + } else if (sample_rate_cap == 192000 || sample_rate_cap == 176400) { + step = 1; + } else { + ASSERT(false, + "1: Invalid sample_rate_cap=%u sample_rate_ref_cap=%u " + "sample_rate_send=%u", + sample_rate_cap, sample_rate_ref_cap, sample_rate_send); + } - get_amic_dc(BufSrc, len>>2, step); + get_amic_dc(BufSrc, len >> 2, step); - for (i = 0; i < (len>>2); i += step) - { - if (step == 2) { - if (!(i&0x1)) { - PcmValue = ((int32_t)(BufSrc[i<<1])); - BufSrcRVal = ((int32_t)(BufSrc[(i<<1)+1])); + for (i = 0; i < (len >> 2); i += step) { + if (step == 2) { + if (!(i & 0x1)) { + PcmValue = ((int32_t)(BufSrc[i << 1])); + BufSrcRVal = ((int32_t)(BufSrc[(i << 1) + 1])); #if (MERGE_VER == 2) - if ((PcmValue < THRES_MIC3) && (PcmValue > -THRES_MIC3)) { - PcmValue = (PcmValue - s_amic3_dc)>>SHIFT_BITS; - } else { - PcmValue = BufSrcRVal - s_amic4_dc; - } -#else // (MERGE_VER == 1) - PcmValue -= s_amic3_dc; - if ((PcmValue < THRES_MIC3) && (PcmValue > -THRES_MIC3)) { - PcmValue >>= SHIFT_BITS; - } else { - PcmValue = BufSrcRVal - s_amic4_dc; - } -#endif // MERGE_VER - PcmValue = soir_filter(PcmValue); -#ifdef DUAL_AUX_MIC_MORE_FILTER - PcmValue = soir_filter1(PcmValue); - PcmValue = soir_filter2(PcmValue); -#endif - if (!(i&7)) { - if (BufDst + 2 > BufDstEnd) { - BufDst = BufDstStart; - } - *BufDst++ = PcmValue; - *BufDst++ = PcmValue; - } - } + if ((PcmValue < THRES_MIC3) && (PcmValue > -THRES_MIC3)) { + PcmValue = (PcmValue - s_amic3_dc) >> SHIFT_BITS; } else { - if (!(i&0x1)) { - PcmValue = ((int32_t)(BufSrc[i<<1])); - BufSrcRVal = ((int32_t)(BufSrc[(i<<1)+1])); -#if (MERGE_VER == 2) - if ((PcmValue < THRES_MIC3) && (PcmValue > -THRES_MIC3)) { - PcmValue = (PcmValue-s_amic3_dc)>>SHIFT_BITS; - } else { - PcmValue = BufSrcRVal-s_amic4_dc; - } -#else // (MERGE_VER == 1) - PcmValue -= s_amic3_dc; - if ((PcmValue < THRES_MIC3) && (PcmValue > -THRES_MIC3)) { - PcmValue >>= SHIFT_BITS; - } else { - PcmValue = BufSrcRVal - s_amic4_dc; - } -#endif // MERGE_VER - PcmValue = soir_filter(PcmValue); -#ifdef DUAL_AUX_MIC_MORE_FILTER - PcmValue = soir_filter1(PcmValue); - PcmValue = soir_filter2(PcmValue); -#endif - if (!(i&3)) { - if (BufDst + 2 > BufDstEnd) { - BufDst = BufDstStart; - } - *BufDst++ = PcmValue; - *BufDst++ = PcmValue; - } - } + PcmValue = BufSrcRVal - s_amic4_dc; } +#else // (MERGE_VER == 1) + PcmValue -= s_amic3_dc; + if ((PcmValue < THRES_MIC3) && (PcmValue > -THRES_MIC3)) { + PcmValue >>= SHIFT_BITS; + } else { + PcmValue = BufSrcRVal - s_amic4_dc; + } +#endif // MERGE_VER + PcmValue = soir_filter(PcmValue); +#ifdef DUAL_AUX_MIC_MORE_FILTER + PcmValue = soir_filter1(PcmValue); + PcmValue = soir_filter2(PcmValue); +#endif + if (!(i & 7)) { + if (BufDst + 2 > BufDstEnd) { + BufDst = BufDstStart; + } + *BufDst++ = PcmValue; + *BufDst++ = PcmValue; + } + } + } else { + if (!(i & 0x1)) { + PcmValue = ((int32_t)(BufSrc[i << 1])); + BufSrcRVal = ((int32_t)(BufSrc[(i << 1) + 1])); +#if (MERGE_VER == 2) + if ((PcmValue < THRES_MIC3) && (PcmValue > -THRES_MIC3)) { + PcmValue = (PcmValue - s_amic3_dc) >> SHIFT_BITS; + } else { + PcmValue = BufSrcRVal - s_amic4_dc; + } +#else // (MERGE_VER == 1) + PcmValue -= s_amic3_dc; + if ((PcmValue < THRES_MIC3) && (PcmValue > -THRES_MIC3)) { + PcmValue >>= SHIFT_BITS; + } else { + PcmValue = BufSrcRVal - s_amic4_dc; + } +#endif // MERGE_VER + PcmValue = soir_filter(PcmValue); +#ifdef DUAL_AUX_MIC_MORE_FILTER + PcmValue = soir_filter1(PcmValue); + PcmValue = soir_filter2(PcmValue); +#endif + if (!(i & 3)) { + if (BufDst + 2 > BufDstEnd) { + BufDst = BufDstStart; + } + *BufDst++ = PcmValue; + *BufDst++ = PcmValue; + } + } } + } } #elif defined(CHIP_BEST1000) && defined(ANC_APP) - // Assuming codec adc records stereo data, and usb sends 48K/44.1K stereo data + // Assuming codec adc records stereo data, and usb sends 48K/44.1K stereo + // data #if (CHAN_NUM_CAPTURE != 2) || (CHAN_NUM_SEND != 2) #error "Unsupported CHAN_NUM_CAPTURE and CHAN_NUM_SEND configuration" #endif if ((sample_rate_ref_cap == 48000 || sample_rate_ref_cap == 44100) && - (sample_rate_cap == sample_rate_ref_cap * 2 || sample_rate_cap == sample_rate_ref_cap * 4 || - sample_rate_cap == sample_rate_ref_cap * 8 || sample_rate_cap == sample_rate_ref_cap * 16)) { + (sample_rate_cap == sample_rate_ref_cap * 2 || + sample_rate_cap == sample_rate_ref_cap * 4 || + sample_rate_cap == sample_rate_ref_cap * 8 || + sample_rate_cap == sample_rate_ref_cap * 16)) { - uint32_t POSSIBLY_UNUSED factor = sample_rate_cap / sample_rate_ref_cap; - int32_t POSSIBLY_UNUSED left = 0; - int32_t POSSIBLY_UNUSED right = 0; - uint32_t step = factor * 4; + uint32_t POSSIBLY_UNUSED factor = sample_rate_cap / sample_rate_ref_cap; + int32_t POSSIBLY_UNUSED left = 0; + int32_t POSSIBLY_UNUSED right = 0; + uint32_t step = factor * 4; - while (cur_buf + step <= buf_end) { - if (dst_cur_buf + 4 > dst_buf_end) { - dst_cur_buf = dst_buf_start; - } - - // Downsampling the adc data -#if 1 - left = 0; - right = 0; - for (int i = 0; i < factor; i++) { - left += *(int16_t *)(cur_buf + 4 * i); - right += *(int16_t *)(cur_buf + 4 * i + 2); - } - *(int16_t *)dst_cur_buf = left / factor; - *(int16_t *)(dst_cur_buf + 2) = right / factor; -#else - *(int16_t *)dst_cur_buf = *(int16_t *)cur_buf; - *(int16_t *)(dst_cur_buf + 2) = *(int16_t *)(cur_buf + 2); -#endif - - // Move to next data - dst_cur_buf += 4; - cur_buf += step; + while (cur_buf + step <= buf_end) { + if (dst_cur_buf + 4 > dst_buf_end) { + dst_cur_buf = dst_buf_start; } + // Downsampling the adc data +#if 1 + left = 0; + right = 0; + for (int i = 0; i < factor; i++) { + left += *(int16_t *)(cur_buf + 4 * i); + right += *(int16_t *)(cur_buf + 4 * i + 2); + } + *(int16_t *)dst_cur_buf = left / factor; + *(int16_t *)(dst_cur_buf + 2) = right / factor; +#else + *(int16_t *)dst_cur_buf = *(int16_t *)cur_buf; + *(int16_t *)(dst_cur_buf + 2) = *(int16_t *)(cur_buf + 2); +#endif + + // Move to next data + dst_cur_buf += 4; + cur_buf += step; + } + } else { - ASSERT(false, "2: Invalid sample_rate_cap=%u sample_rate_ref_cap=%u sample_rate_send=%u", sample_rate_cap, sample_rate_ref_cap, sample_rate_send); + ASSERT(false, + "2: Invalid sample_rate_cap=%u sample_rate_ref_cap=%u " + "sample_rate_send=%u", + sample_rate_cap, sample_rate_ref_cap, sample_rate_send); } #else // !(CHIP_BEST1000 && (ANC_APP || _DUAL_AUX_MIC_)) #ifndef SW_CAPTURE_RESAMPLE - ASSERT(sample_rate_cap == sample_rate_send,"3: Invalid sample_rate_cap=%u sample_rate_send=%u", sample_rate_cap, sample_rate_send); + ASSERT(sample_rate_cap == sample_rate_send, + "3: Invalid sample_rate_cap=%u sample_rate_send=%u", sample_rate_cap, + sample_rate_send); #endif // When USB_AUDIO_SPEECH is enable, buf after algorithm shoule be CHAN_NUM_SEND, // do not need to convert any more. -#if (CHAN_NUM_CAPTURE == 2) && (CHAN_NUM_SEND == 1) && !defined(USB_AUDIO_SPEECH) +#if (CHAN_NUM_CAPTURE == 2) && (CHAN_NUM_SEND == 1) && \ + !defined(USB_AUDIO_SPEECH) - // Assuming codec adc always records stereo data + // Assuming codec adc always records stereo data - while (cur_buf + 4 <= buf_end) { - // Copy left channel data - if (dst_cur_buf + 2 > dst_buf_end) { - dst_cur_buf = dst_buf_start; - } - *(int16_t *)dst_cur_buf = *(int16_t *)cur_buf; + while (cur_buf + 4 <= buf_end) { + // Copy left channel data + if (dst_cur_buf + 2 > dst_buf_end) { + dst_cur_buf = dst_buf_start; + } + *(int16_t *)dst_cur_buf = *(int16_t *)cur_buf; - // Move to next data - dst_cur_buf += 2; - cur_buf += 4; - } + // Move to next data + dst_cur_buf += 2; + cur_buf += 4; + } -#elif (CHAN_NUM_CAPTURE == 1) && (CHAN_NUM_SEND == 2) && !defined(USB_AUDIO_SPEECH) +#elif (CHAN_NUM_CAPTURE == 1) && (CHAN_NUM_SEND == 2) && \ + !defined(USB_AUDIO_SPEECH) - // Assuming codec adc always records mono data + // Assuming codec adc always records mono data #ifdef SW_CAPTURE_RESAMPLE #if (CHAN_NUM_CAPTURE == 1) && (CHAN_NUM_SEND == 2) - if (resample_cap_enabled) { - //ASSERT(cur_buf == dst_cur_buf, "Bad assumption"); - uint32_t src_len; + if (resample_cap_enabled) { + // ASSERT(cur_buf == dst_cur_buf, "Bad assumption"); + uint32_t src_len; - if (buf_end < cur_buf) { - src_len = buf_end + usb_send_size - cur_buf; - } else { - src_len = buf_end - cur_buf; - } - cur_buf = buf_end - 2; - if (cur_buf < dst_buf_start) { - cur_buf += usb_send_size; - } - dst_cur_buf += src_len * 2 - 4; - if (dst_cur_buf >= dst_buf_end) { - dst_cur_buf -= usb_send_size; - } - while (src_len > 0) { - *(int16_t *)dst_cur_buf = *(int16_t *)cur_buf; - *(int16_t *)(dst_cur_buf + 2) = *(int16_t *)cur_buf; + if (buf_end < cur_buf) { + src_len = buf_end + usb_send_size - cur_buf; + } else { + src_len = buf_end - cur_buf; + } + cur_buf = buf_end - 2; + if (cur_buf < dst_buf_start) { + cur_buf += usb_send_size; + } + dst_cur_buf += src_len * 2 - 4; + if (dst_cur_buf >= dst_buf_end) { + dst_cur_buf -= usb_send_size; + } + while (src_len > 0) { + *(int16_t *)dst_cur_buf = *(int16_t *)cur_buf; + *(int16_t *)(dst_cur_buf + 2) = *(int16_t *)cur_buf; - // Move to next data - src_len -= 2; - cur_buf -= 2; - if (cur_buf < dst_buf_start) { - cur_buf += usb_send_size; - } - dst_cur_buf -= 4; - if (dst_cur_buf < dst_buf_start) { - dst_cur_buf += usb_send_size; - } - } - } else -#endif -#endif - { - while (cur_buf + 2 <= buf_end) { - // Duplicate the mono data - if (dst_cur_buf + 4 > dst_buf_end) { - dst_cur_buf = dst_buf_start; - } - *(int16_t *)dst_cur_buf = *(int16_t *)cur_buf; - *(int16_t *)(dst_cur_buf + 2) = *(int16_t *)cur_buf; - - // Move to next data - dst_cur_buf += 4; - cur_buf += 2; - } + // Move to next data + src_len -= 2; + cur_buf -= 2; + if (cur_buf < dst_buf_start) { + cur_buf += usb_send_size; } + dst_cur_buf -= 4; + if (dst_cur_buf < dst_buf_start) { + dst_cur_buf += usb_send_size; + } + } + } else +#endif +#endif + { + while (cur_buf + 2 <= buf_end) { + // Duplicate the mono data + if (dst_cur_buf + 4 > dst_buf_end) { + dst_cur_buf = dst_buf_start; + } + *(int16_t *)dst_cur_buf = *(int16_t *)cur_buf; + *(int16_t *)(dst_cur_buf + 2) = *(int16_t *)cur_buf; + + // Move to next data + dst_cur_buf += 4; + cur_buf += 2; + } + } #else // (CHAN_NUM_CAPTURE == CHAN_NUM_SEND) - // The channel numbers of codec adc and USB data are the same + // The channel numbers of codec adc and USB data are the same - if (sample_size_cap == sample_size_send) { + if (sample_size_cap == sample_size_send) { #if ((CHAN_NUM_CAPTURE & 1) == 0) -#define COPY_MEM(dst, src, size) copy_mem32(dst, src, size) +#define COPY_MEM(dst, src, size) copy_mem32(dst, src, size) #else -#define COPY_MEM(dst, src, size) copy_mem16(dst, src, size) +#define COPY_MEM(dst, src, size) copy_mem16(dst, src, size) #endif - if (dst_cur_buf != cur_buf) { - if (dst_cur_buf + len <= dst_buf_end) { - COPY_MEM(dst_cur_buf, cur_buf, len); - } else { - uint32_t copy_len; - - if (dst_cur_buf >= dst_buf_end) { - copy_len = 0; - } else { - copy_len = dst_buf_end - dst_cur_buf; - COPY_MEM(dst_cur_buf, cur_buf, copy_len); - } - COPY_MEM(dst_buf_start, cur_buf + copy_len, len - copy_len); - } - } -#undef COPY_MEM - } else if (sample_size_cap == 4 && sample_size_send == 3) { - uint32_t codec_step, usb_step; - uint32_t ch; - - codec_step = CHAN_NUM_CAPTURE * 4; - usb_step = CHAN_NUM_SEND * 3; - - while (cur_buf + codec_step <= buf_end) { - if (dst_cur_buf + usb_step > dst_buf_end) { - dst_cur_buf = dst_buf_start; - } - for (ch = 0; ch < CHAN_NUM_CAPTURE; ch++) { - *(uint16_t *)dst_cur_buf = *(uint16_t *)cur_buf; - *(uint8_t *)(dst_cur_buf + 2) = *(uint8_t *)(cur_buf + 2); - // Move to next channel - dst_cur_buf += 3; - cur_buf += 4; - } - } + if (dst_cur_buf != cur_buf) { + if (dst_cur_buf + len <= dst_buf_end) { + COPY_MEM(dst_cur_buf, cur_buf, len); } else { - ASSERT(false, "4: Invalid sample_size_cap=%u sample_size_send=%u", sample_size_cap, sample_size_send); + uint32_t copy_len; + + if (dst_cur_buf >= dst_buf_end) { + copy_len = 0; + } else { + copy_len = dst_buf_end - dst_cur_buf; + COPY_MEM(dst_cur_buf, cur_buf, copy_len); + } + COPY_MEM(dst_buf_start, cur_buf + copy_len, len - copy_len); } + } +#undef COPY_MEM + } else if (sample_size_cap == 4 && sample_size_send == 3) { + uint32_t codec_step, usb_step; + uint32_t ch; + + codec_step = CHAN_NUM_CAPTURE * 4; + usb_step = CHAN_NUM_SEND * 3; + + while (cur_buf + codec_step <= buf_end) { + if (dst_cur_buf + usb_step > dst_buf_end) { + dst_cur_buf = dst_buf_start; + } + for (ch = 0; ch < CHAN_NUM_CAPTURE; ch++) { + *(uint16_t *)dst_cur_buf = *(uint16_t *)cur_buf; + *(uint8_t *)(dst_cur_buf + 2) = *(uint8_t *)(cur_buf + 2); + // Move to next channel + dst_cur_buf += 3; + cur_buf += 4; + } + } + } else { + ASSERT(false, "4: Invalid sample_size_cap=%u sample_size_send=%u", + sample_size_cap, sample_size_send); + } #endif // (CHAN_NUM_CAPTURE == CHAN_NUM_SEND) @@ -2743,3475 +2797,3567 @@ _invalid_cap: #ifdef SW_CAPTURE_RESAMPLE #if !((CHAN_NUM_CAPTURE == 1) && (CHAN_NUM_SEND == 2)) - if (resample_cap_enabled) { - io.in = resample_input_buf; - io.in_size = resample_frame_len; - io.out = usb_send_buf + old_wpos; - io.out_size = usb_len; - io.out_cyclic_start = usb_send_buf; - io.out_cyclic_end = usb_send_buf + usb_send_size; + if (resample_cap_enabled) { + io.in = resample_input_buf; + io.in_size = resample_frame_len; + io.out = usb_send_buf + old_wpos; + io.out_size = usb_len; + io.out_cyclic_start = usb_send_buf; + io.out_cyclic_end = usb_send_buf + usb_send_size; - ret = audio_resample_ex_run(resample_id, &io, &in_size, &out_size); - ASSERT((ret == RESAMPLE_STATUS_IN_EMPTY || ret == RESAMPLE_STATUS_DONE) && io.out_size >= out_size, - "Failed to resample: %d io.out_size=%u io.in_size=%u in_size=%u out_size=%u", - ret, io.out_size, io.in_size, in_size, out_size); + ret = audio_resample_ex_run(resample_id, &io, &in_size, &out_size); + ASSERT((ret == RESAMPLE_STATUS_IN_EMPTY || ret == RESAMPLE_STATUS_DONE) && + io.out_size >= out_size, + "Failed to resample: %d io.out_size=%u io.in_size=%u in_size=%u " + "out_size=%u", + ret, io.out_size, io.in_size, in_size, out_size); - uint32_t diff = usb_len - out_size; - if (new_wpos >= diff) { - new_wpos -= diff; - } else { - new_wpos = new_wpos + usb_send_size - diff; - } + uint32_t diff = usb_len - out_size; + if (new_wpos >= diff) { + new_wpos -= diff; + } else { + new_wpos = new_wpos + usb_send_size - diff; + } #if (VERBOSE_TRACE & (1 << 3)) - TRACE(5,"cap_resample: new_wpos=%u, in: %u -> %u, out: %u -> %u", new_wpos, io.in_size, in_size, io.out_size, out_size); -#endif - } -#endif + TRACE(5, "cap_resample: new_wpos=%u, in: %u -> %u, out: %u -> %u", + new_wpos, io.in_size, in_size, io.out_size, out_size); #endif } +#endif +#endif + } - //---------------------------------------- - // CODEC->USB stream format conversion end - //---------------------------------------- + //---------------------------------------- + // CODEC->USB stream format conversion end + //---------------------------------------- _conv_end: - cap_next = buf + len - capture_buf; - if (cap_next >= capture_size) { - cap_next -= capture_size; - } + cap_next = buf + len - capture_buf; + if (cap_next >= capture_size) { + cap_next -= capture_size; + } - lock = int_lock(); - if (codec_cap_seq == usb_send_seq) { - if (capture_state == AUDIO_ITF_STATE_STARTED) { - usb_send_wpos = new_wpos; - } else { - usb_send_wpos = 0; - } - capture_pos = cap_next; - if (conflicted) { - capture_conflicted = conflicted; - } + lock = int_lock(); + if (codec_cap_seq == usb_send_seq) { + if (capture_state == AUDIO_ITF_STATE_STARTED) { + usb_send_wpos = new_wpos; + } else { + usb_send_wpos = 0; } - int_unlock(lock); + capture_pos = cap_next; + if (conflicted) { + capture_conflicted = conflicted; + } + } + int_unlock(lock); #if (VERBOSE_TRACE & (1 << 4)) - TRACE_TIME(0,"captureEnd"); + TRACE_TIME(0, "captureEnd"); #endif - return 0; + return 0; } -static void update_playback_sync_info(void) -{ - playback_info.err_thresh = DIFF_ERR_THRESH_PLAYBACK; - playback_info.samp_rate = sample_rate_play; - playback_info.samp_cnt = byte_to_samp_recv(usb_recv_size); +static void update_playback_sync_info(void) { + playback_info.err_thresh = DIFF_ERR_THRESH_PLAYBACK; + playback_info.samp_rate = sample_rate_play; + playback_info.samp_cnt = byte_to_samp_recv(usb_recv_size); #ifdef TARGET_TO_MAX_DIFF - playback_info.max_target_thresh = playback_info.samp_cnt / 2; - playback_info.diff_target = byte_to_samp_recv(playback_to_recv_len(playback_size / 2)) + playback_info.samp_cnt / 2; - playback_info.diff_target = usb_audio_sync_normalize_diff(-playback_info.diff_target, playback_info.samp_cnt); + playback_info.max_target_thresh = playback_info.samp_cnt / 2; + playback_info.diff_target = + byte_to_samp_recv(playback_to_recv_len(playback_size / 2)) + + playback_info.samp_cnt / 2; + playback_info.diff_target = usb_audio_sync_normalize_diff( + -playback_info.diff_target, playback_info.samp_cnt); #endif - TRACE(4,"%s: rate=%u cnt=%u (%u)", __FUNCTION__, playback_info.samp_rate, playback_info.samp_cnt, usb_recv_size); + TRACE(4, "%s: rate=%u cnt=%u (%u)", __FUNCTION__, playback_info.samp_rate, + playback_info.samp_cnt, usb_recv_size); } -static void update_capture_sync_info(void) -{ - capture_info.err_thresh = DIFF_ERR_THRESH_CAPTURE; - capture_info.samp_rate = sample_rate_cap; - capture_info.samp_cnt = byte_to_samp_send(usb_send_size); +static void update_capture_sync_info(void) { + capture_info.err_thresh = DIFF_ERR_THRESH_CAPTURE; + capture_info.samp_rate = sample_rate_cap; + capture_info.samp_cnt = byte_to_samp_send(usb_send_size); #ifdef TARGET_TO_MAX_DIFF - capture_info.max_target_thresh = capture_info.samp_cnt / 2; - capture_info.diff_target = byte_to_samp_send(capture_to_send_len(capture_size / 2)) + capture_info.samp_cnt / 2; - capture_info.diff_target = usb_audio_sync_normalize_diff(capture_info.diff_target, capture_info.samp_cnt); + capture_info.max_target_thresh = capture_info.samp_cnt / 2; + capture_info.diff_target = + byte_to_samp_send(capture_to_send_len(capture_size / 2)) + + capture_info.samp_cnt / 2; + capture_info.diff_target = usb_audio_sync_normalize_diff( + capture_info.diff_target, capture_info.samp_cnt); #endif - TRACE(4,"%s: rate=%u cnt=%u (%u)", __FUNCTION__, capture_info.samp_rate, capture_info.samp_cnt, usb_send_size); + TRACE(4, "%s: rate=%u cnt=%u (%u)", __FUNCTION__, capture_info.samp_rate, + capture_info.samp_cnt, usb_send_size); } -static int usb_audio_open_codec_stream(enum AUD_STREAM_T stream, enum AUDIO_STREAM_REQ_USER_T user) -{ - int ret = 0; - struct AF_STREAM_CONFIG_T stream_cfg; +static int usb_audio_open_codec_stream(enum AUD_STREAM_T stream, + enum AUDIO_STREAM_REQ_USER_T user) { + int ret = 0; + struct AF_STREAM_CONFIG_T stream_cfg; - TRACE(4,"%s: stream=%d user=%d map=0x%x", __FUNCTION__, stream, user, codec_stream_map[stream][AUDIO_STREAM_OPENED]); + TRACE(4, "%s: stream=%d user=%d map=0x%x", __FUNCTION__, stream, user, + codec_stream_map[stream][AUDIO_STREAM_OPENED]); - if (user >= AUDIO_STREAM_REQ_USER_QTY || codec_stream_map[stream][AUDIO_STREAM_OPENED] == 0) { - memset(&stream_cfg, 0, sizeof(stream_cfg)); + if (user >= AUDIO_STREAM_REQ_USER_QTY || + codec_stream_map[stream][AUDIO_STREAM_OPENED] == 0) { + memset(&stream_cfg, 0, sizeof(stream_cfg)); - if (stream == AUD_STREAM_PLAYBACK) { + if (stream == AUD_STREAM_PLAYBACK) { #if defined(USB_AUDIO_DYN_CFG) && defined(KEEP_SAME_LATENCY) - playback_size = calc_playback_size(sample_rate_play); + playback_size = calc_playback_size(sample_rate_play); #endif - update_playback_sync_info(); + update_playback_sync_info(); #ifdef CODEC_DSD - if (codec_dsd_enabled) { - stream_cfg.bits = AUD_BITS_24; - } else + if (codec_dsd_enabled) { + stream_cfg.bits = AUD_BITS_24; + } else #endif - { - stream_cfg.bits = sample_size_to_enum_playback(sample_size_play); - } - stream_cfg.sample_rate = sample_rate_play; - stream_cfg.channel_num = chan_num_to_enum(CHAN_NUM_PLAYBACK); + { + stream_cfg.bits = sample_size_to_enum_playback(sample_size_play); + } + stream_cfg.sample_rate = sample_rate_play; + stream_cfg.channel_num = chan_num_to_enum(CHAN_NUM_PLAYBACK); #ifdef USB_I2S_APP #if defined(USB_I2S_ID) && (USB_I2S_ID == 0) - stream_cfg.device = AUD_STREAM_USE_I2S0_MASTER; + stream_cfg.device = AUD_STREAM_USE_I2S0_MASTER; #else - stream_cfg.device = AUD_STREAM_USE_I2S1_MASTER; + stream_cfg.device = AUD_STREAM_USE_I2S1_MASTER; #endif #else - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; #endif - stream_cfg.vol = playback_vol; - stream_cfg.handler = usb_audio_data_playback; - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; - stream_cfg.data_ptr = playback_buf; - stream_cfg.data_size = playback_size; + stream_cfg.vol = playback_vol; + stream_cfg.handler = usb_audio_data_playback; + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; + stream_cfg.data_ptr = playback_buf; + stream_cfg.data_size = playback_size; - //TRACE(3,"[%s] sample_rate: %d, bits = %d", __func__, stream_cfg.sample_rate, stream_cfg.bits); + // TRACE(3,"[%s] sample_rate: %d, bits = %d", __func__, + // stream_cfg.sample_rate, stream_cfg.bits); - ret = af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); - ASSERT(ret == 0, "af_stream_open playback failed: %d", ret); + ret = af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); + ASSERT(ret == 0, "af_stream_open playback failed: %d", ret); #ifdef AUDIO_ANC_FB_MC - stream_cfg.bits = sample_size_to_enum_playback(sample_size_play); - stream_cfg.sample_rate = sample_rate_play; - stream_cfg.channel_num = chan_num_to_enum(CHAN_NUM_PLAYBACK); - stream_cfg.device = AUD_STREAM_USE_MC; - stream_cfg.vol = playback_vol; - stream_cfg.handler = audio_mc_data_playback; - stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; - stream_cfg.data_ptr = playback_buf+playback_size; + stream_cfg.bits = sample_size_to_enum_playback(sample_size_play); + stream_cfg.sample_rate = sample_rate_play; + stream_cfg.channel_num = chan_num_to_enum(CHAN_NUM_PLAYBACK); + stream_cfg.device = AUD_STREAM_USE_MC; + stream_cfg.vol = playback_vol; + stream_cfg.handler = audio_mc_data_playback; + stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER; + stream_cfg.data_ptr = playback_buf + playback_size; - mid_p_8_old_l=0; - mid_p_8_old_r=0; + mid_p_8_old_l = 0; + mid_p_8_old_r = 0; - if(sample_rate_play==AUD_SAMPRATE_8000) - { - playback_samplerate_ratio=8*6; - } - else if(sample_rate_play==AUD_SAMPRATE_16000) - { - playback_samplerate_ratio=8*3; - } - else if((sample_rate_play==AUD_SAMPRATE_44100)||(sample_rate_play==AUD_SAMPRATE_48000)||(sample_rate_play==AUD_SAMPRATE_50781)) - { - playback_samplerate_ratio=8; - } - else if((sample_rate_play==AUD_SAMPRATE_88200)||(sample_rate_play==AUD_SAMPRATE_96000)) - { - playback_samplerate_ratio=4; - } - else if((sample_rate_play==AUD_SAMPRATE_176400)||(sample_rate_play==AUD_SAMPRATE_192000)) - { - playback_samplerate_ratio=2; - } - else if(sample_rate_play==AUD_SAMPRATE_384000) - { - playback_samplerate_ratio=1; - } - else - { - playback_samplerate_ratio=1; - ASSERT(false, "Music cancel can't support playback sample rate:%d",sample_rate_play); - } + if (sample_rate_play == AUD_SAMPRATE_8000) { + playback_samplerate_ratio = 8 * 6; + } else if (sample_rate_play == AUD_SAMPRATE_16000) { + playback_samplerate_ratio = 8 * 3; + } else if ((sample_rate_play == AUD_SAMPRATE_44100) || + (sample_rate_play == AUD_SAMPRATE_48000) || + (sample_rate_play == AUD_SAMPRATE_50781)) { + playback_samplerate_ratio = 8; + } else if ((sample_rate_play == AUD_SAMPRATE_88200) || + (sample_rate_play == AUD_SAMPRATE_96000)) { + playback_samplerate_ratio = 4; + } else if ((sample_rate_play == AUD_SAMPRATE_176400) || + (sample_rate_play == AUD_SAMPRATE_192000)) { + playback_samplerate_ratio = 2; + } else if (sample_rate_play == AUD_SAMPRATE_384000) { + playback_samplerate_ratio = 1; + } else { + playback_samplerate_ratio = 1; + ASSERT(false, "Music cancel can't support playback sample rate:%d", + sample_rate_play); + } - anc_mc_run_init((sample_rate_play*playback_samplerate_ratio)/8); + anc_mc_run_init((sample_rate_play * playback_samplerate_ratio) / 8); - stream_cfg.data_size = playback_size*playback_samplerate_ratio; + stream_cfg.data_size = playback_size * playback_samplerate_ratio; - //TRACE(3,"[%s] sample_rate: %d, bits = %d", __func__, stream_cfg.sample_rate, stream_cfg.bits); + // TRACE(3,"[%s] sample_rate: %d, bits = %d", __func__, + // stream_cfg.sample_rate, stream_cfg.bits); - ret = af_stream_open(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &stream_cfg); - ASSERT(ret == 0, "af_stream_open playback failed: %d", ret); + ret = af_stream_open(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &stream_cfg); + ASSERT(ret == 0, "af_stream_open playback failed: %d", ret); #endif - } else { + } else { #if defined(USB_AUDIO_DYN_CFG) && defined(KEEP_SAME_LATENCY) - capture_size = calc_capture_size(sample_rate_cap); + capture_size = calc_capture_size(sample_rate_cap); #endif - update_capture_sync_info(); + update_capture_sync_info(); - stream_cfg.bits = sample_size_to_enum_capture(sample_size_cap); - stream_cfg.sample_rate = sample_rate_cap; - stream_cfg.channel_num = chan_num_to_enum(CHAN_NUM_CAPTURE); + stream_cfg.bits = sample_size_to_enum_capture(sample_size_cap); + stream_cfg.sample_rate = sample_rate_cap; + stream_cfg.channel_num = chan_num_to_enum(CHAN_NUM_CAPTURE); #ifdef ANC_PROD_TEST - stream_cfg.channel_map=anc_fb_mic_ch_l|anc_fb_mic_ch_r; + stream_cfg.channel_map = anc_fb_mic_ch_l | anc_fb_mic_ch_r; #endif #ifdef USB_I2S_APP #if defined(USB_I2S_ID) && (USB_I2S_ID == 0) - stream_cfg.device = AUD_STREAM_USE_I2S0_MASTER; + stream_cfg.device = AUD_STREAM_USE_I2S0_MASTER; #else - stream_cfg.device = AUD_STREAM_USE_I2S1_MASTER; + stream_cfg.device = AUD_STREAM_USE_I2S1_MASTER; #endif #else - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; #endif - stream_cfg.vol = capture_vol; - stream_cfg.handler = usb_audio_data_capture; + stream_cfg.vol = capture_vol; + stream_cfg.handler = usb_audio_data_capture; #if !defined(USB_AUDIO_SPEECH) && defined(BTUSB_AUDIO_MODE) - stream_cfg.io_path = AUD_INPUT_PATH_USBAUDIO; + stream_cfg.io_path = AUD_INPUT_PATH_USBAUDIO; #else - stream_cfg.io_path = AUD_INPUT_PATH_MAINMIC; + stream_cfg.io_path = AUD_INPUT_PATH_MAINMIC; #endif - stream_cfg.data_ptr = capture_buf; - stream_cfg.data_size = capture_size; + stream_cfg.data_ptr = capture_buf; + stream_cfg.data_size = capture_size; - //TRACE(4,"[%s] sample_rate: %d, bits = %d, ch_num = %d", __func__, stream_cfg.sample_rate, stream_cfg.bits, stream_cfg.channel_num); + // TRACE(4,"[%s] sample_rate: %d, bits = %d, ch_num = %d", __func__, + // stream_cfg.sample_rate, stream_cfg.bits, stream_cfg.channel_num); - ret = af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); - ASSERT(ret == 0, "af_stream_open catpure failed: %d", ret); - } + ret = af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); + ASSERT(ret == 0, "af_stream_open catpure failed: %d", ret); } + } - if (user < AUDIO_STREAM_REQ_USER_QTY) { - codec_stream_map[stream][AUDIO_STREAM_OPENED] |= (1 << user); - } + if (user < AUDIO_STREAM_REQ_USER_QTY) { + codec_stream_map[stream][AUDIO_STREAM_OPENED] |= (1 << user); + } - return ret; + return ret; } -static int usb_audio_close_codec_stream(enum AUD_STREAM_T stream, enum AUDIO_STREAM_REQ_USER_T user) -{ - int ret = 0; +static int usb_audio_close_codec_stream(enum AUD_STREAM_T stream, + enum AUDIO_STREAM_REQ_USER_T user) { + int ret = 0; - TRACE(4,"%s: stream=%d user=%d map=0x%x", __FUNCTION__, stream, user, codec_stream_map[stream][AUDIO_STREAM_OPENED]); + TRACE(4, "%s: stream=%d user=%d map=0x%x", __FUNCTION__, stream, user, + codec_stream_map[stream][AUDIO_STREAM_OPENED]); - if (user < AUDIO_STREAM_REQ_USER_QTY) { - codec_stream_map[stream][AUDIO_STREAM_OPENED] &= ~(1 << user); - } + if (user < AUDIO_STREAM_REQ_USER_QTY) { + codec_stream_map[stream][AUDIO_STREAM_OPENED] &= ~(1 << user); + } - if (user >= AUDIO_STREAM_REQ_USER_QTY || codec_stream_map[stream][AUDIO_STREAM_OPENED] == 0) { - ret = af_stream_close(AUD_STREAM_ID_0, stream); + if (user >= AUDIO_STREAM_REQ_USER_QTY || + codec_stream_map[stream][AUDIO_STREAM_OPENED] == 0) { + ret = af_stream_close(AUD_STREAM_ID_0, stream); #ifdef AUDIO_ANC_FB_MC - if(stream == AUD_STREAM_PLAYBACK) - { - ret = af_stream_close(AUD_STREAM_ID_2, stream); - } -#endif + if (stream == AUD_STREAM_PLAYBACK) { + ret = af_stream_close(AUD_STREAM_ID_2, stream); } +#endif + } - return ret; + return ret; } -static int usb_audio_open_eq(void) -{ - int ret = 0; +static int usb_audio_open_eq(void) { + int ret = 0; - TRACE(4,"[%s] EQ: sample_rate_recv=%d, sample_rate_play=%d, sample_bits=%d", __func__, - sample_rate_recv, sample_rate_play, sample_size_to_enum_playback(sample_size_play)); + TRACE(4, "[%s] EQ: sample_rate_recv=%d, sample_rate_play=%d, sample_bits=%d", + __func__, sample_rate_recv, sample_rate_play, + sample_size_to_enum_playback(sample_size_play)); -#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__) || defined(__HW_IIR_EQ_PROCESS__) || defined(__HW_DAC_IIR_EQ_PROCESS__) - enum AUD_BITS_T sample_bits = sample_size_to_enum_playback(sample_size_play); - enum AUD_CHANNEL_NUM_T chan_num = chan_num_to_enum(CHAN_NUM_PLAYBACK); - ret = audio_process_open(sample_rate_play, sample_bits, chan_num, playback_eq_size/2, playback_eq_buf, playback_eq_size); +#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__) || \ + defined(__HW_IIR_EQ_PROCESS__) || defined(__HW_DAC_IIR_EQ_PROCESS__) + enum AUD_BITS_T sample_bits = sample_size_to_enum_playback(sample_size_play); + enum AUD_CHANNEL_NUM_T chan_num = chan_num_to_enum(CHAN_NUM_PLAYBACK); + ret = audio_process_open(sample_rate_play, sample_bits, chan_num, + playback_eq_size / 2, playback_eq_buf, + playback_eq_size); - //TRACE(1,"audio_process_open: %d", ret); + // TRACE(1,"audio_process_open: %d", ret); #ifdef __SW_IIR_EQ_PROCESS__ - usb_audio_set_eq(AUDIO_EQ_TYPE_SW_IIR,usb_audio_get_eq_index(AUDIO_EQ_TYPE_SW_IIR,0)); + usb_audio_set_eq(AUDIO_EQ_TYPE_SW_IIR, + usb_audio_get_eq_index(AUDIO_EQ_TYPE_SW_IIR, 0)); #endif #ifdef __HW_FIR_EQ_PROCESS__ - usb_audio_set_eq(AUDIO_EQ_TYPE_HW_FIR,usb_audio_get_eq_index(AUDIO_EQ_TYPE_HW_FIR,0)); + usb_audio_set_eq(AUDIO_EQ_TYPE_HW_FIR, + usb_audio_get_eq_index(AUDIO_EQ_TYPE_HW_FIR, 0)); #endif #ifdef __HW_DAC_IIR_EQ_PROCESS__ - usb_audio_set_eq(AUDIO_EQ_TYPE_HW_DAC_IIR,usb_audio_get_eq_index(AUDIO_EQ_TYPE_HW_DAC_IIR,0)); + usb_audio_set_eq(AUDIO_EQ_TYPE_HW_DAC_IIR, + usb_audio_get_eq_index(AUDIO_EQ_TYPE_HW_DAC_IIR, 0)); #endif #ifdef __HW_IIR_EQ_PROCESS__ - usb_audio_set_eq(AUDIO_EQ_TYPE_HW_IIR,usb_audio_get_eq_index(AUDIO_EQ_TYPE_HW_IIR,0)); + usb_audio_set_eq(AUDIO_EQ_TYPE_HW_IIR, + usb_audio_get_eq_index(AUDIO_EQ_TYPE_HW_IIR, 0)); #endif #endif - eq_opened = 1; + eq_opened = 1; - return ret; + return ret; } -static int usb_audio_close_eq(void) -{ - int ret = 0; +static int usb_audio_close_eq(void) { + int ret = 0; -#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__) || defined(__HW_IIR_EQ_PROCESS__) || defined(__HW_DAC_IIR_EQ_PROCESS__) - ret = audio_process_close(); +#if defined(__SW_IIR_EQ_PROCESS__) || defined(__HW_FIR_EQ_PROCESS__) || \ + defined(__HW_IIR_EQ_PROCESS__) || defined(__HW_DAC_IIR_EQ_PROCESS__) + ret = audio_process_close(); #endif - eq_opened = 0; + eq_opened = 0; - return ret; + return ret; } -static int usb_audio_start_codec_stream(enum AUD_STREAM_T stream, enum AUDIO_STREAM_REQ_USER_T user) -{ - int ret = 0; +static int usb_audio_start_codec_stream(enum AUD_STREAM_T stream, + enum AUDIO_STREAM_REQ_USER_T user) { + int ret = 0; - TRACE(4,"%s: stream=%d user=%d map=0x%x", __FUNCTION__, stream, user, codec_stream_map[stream][AUDIO_STREAM_STARTED]); - - if (user >= AUDIO_STREAM_REQ_USER_QTY || codec_stream_map[stream][AUDIO_STREAM_STARTED] == 0) { - reset_conflict(); - - if (stream == AUD_STREAM_PLAYBACK) { - zero_mem32(playback_buf, playback_size); - codec_play_valid = 0; - usb_recv_init_rpos = 0; - playback_pos = 0; - playback_conflicted = 0; -#ifdef USB_AUDIO_MULTIFUNC - usb_recv2_init_rpos = 0; - playback_conflicted2 = 0; -#endif -#ifdef DSD_SUPPORT - if (codec_dsd_enabled) { -#if defined(__HW_FIR_DSD_PROCESS__) - uint8_t *dsd_buf; - uint32_t dsd_size; - - // DoP format requirement - dsd_size = playback_size * 16;; - dsd_buf = (uint8_t *)(HW_FIR_DSD_BUF_MID_ADDR - dsd_size / 2); - dsd_open(sample_rate_play,AUD_BITS_24,AUD_CHANNEL_NUM_2,dsd_buf,dsd_size); -#elif defined(CODEC_DSD) - af_dsd_enable(); -#endif - } -#endif - usb_audio_open_eq(); - } else { -#if defined(CHIP_BEST1000) && defined(_DUAL_AUX_MIC_) - damic_init(); - init_amic_dc(); -#endif - -#ifdef USB_AUDIO_SPEECH - app_overlay_select(APP_OVERLAY_HFP); - - speech_process_init(sample_rate_cap, CHAN_NUM_CAPTURE, sample_size_to_enum_playback(sample_size_cap), - sample_rate_play, CHAN_NUM_PLAYBACK, sample_size_to_enum_playback(sample_size_play), - 16, 16, - CHAN_NUM_SEND, CHAN_NUM_RECV); -#endif - - codec_cap_valid = 0; - usb_send_init_wpos = 0; - capture_pos = 0; - capture_conflicted = 0; - } - - // Tune rate according to the newest sync ratio info - usb_audio_cmd_tune_rate(stream); - - ret = af_stream_start(AUD_STREAM_ID_0, stream); - ASSERT(ret == 0, "af_stream_start %d failed: %d", stream, ret); - - if (stream == AUD_STREAM_PLAYBACK) { -#ifdef AUDIO_ANC_FB_MC - ret = af_stream_start(AUD_STREAM_ID_2, stream); - ASSERT(ret == 0, "af_stream_start %d failed: %d", stream, ret); -#endif - } else { - codec_cap_start_time = hal_sys_timer_get(); - } - } - - if (user < AUDIO_STREAM_REQ_USER_QTY) { - codec_stream_map[stream][AUDIO_STREAM_STARTED] |= (1 << user); - } - - return ret; -} - -static int usb_audio_stop_codec_stream(enum AUD_STREAM_T stream, enum AUDIO_STREAM_REQ_USER_T user) -{ - int ret = 0; - - TRACE(4,"%s: stream=%d user=%d map=0x%x", __FUNCTION__, stream, user, codec_stream_map[stream][AUDIO_STREAM_STARTED]); - - if (user < AUDIO_STREAM_REQ_USER_QTY) { - codec_stream_map[stream][AUDIO_STREAM_STARTED] &= ~(1 << user); - } - - if (user >= AUDIO_STREAM_REQ_USER_QTY || codec_stream_map[stream][AUDIO_STREAM_STARTED] == 0) { - ret = af_stream_stop(AUD_STREAM_ID_0, stream); - - if (stream == AUD_STREAM_PLAYBACK) { -#ifdef AUDIO_ANC_FB_MC - ret = af_stream_stop(AUD_STREAM_ID_2, stream); -#endif -#ifdef DSD_SUPPORT - if (codec_dsd_enabled) { -#if defined(__HW_FIR_DSD_PROCESS__) - dsd_close(); -#elif defined(CODEC_DSD) - af_dsd_disable(); -#endif - } -#endif - usb_audio_close_eq(); - } else { -#if defined(CHIP_BEST1000) && defined(_DUAL_AUX_MIC_) - damic_deinit(); -#endif - -#ifdef USB_AUDIO_SPEECH - speech_process_deinit(); - app_overlay_unloadall(); -#endif - } - } - - return ret; -} - -static int usb_audio_start_usb_stream(enum AUD_STREAM_T stream) -{ - int ret; + TRACE(4, "%s: stream=%d user=%d map=0x%x", __FUNCTION__, stream, user, + codec_stream_map[stream][AUDIO_STREAM_STARTED]); + if (user >= AUDIO_STREAM_REQ_USER_QTY || + codec_stream_map[stream][AUDIO_STREAM_STARTED] == 0) { reset_conflict(); if (stream == AUD_STREAM_PLAYBACK) { - usb_audio_sync_reset(&playback_info); - - usb_recv_valid = 0; + zero_mem32(playback_buf, playback_size); + codec_play_valid = 0; + usb_recv_init_rpos = 0; + playback_pos = 0; + playback_conflicted = 0; #ifdef USB_AUDIO_MULTIFUNC - if (recv2_state == AUDIO_ITF_STATE_STOPPED) + usb_recv2_init_rpos = 0; + playback_conflicted2 = 0; #endif - { - usb_recv_seq++; - } - - usb_recv_rpos = 0; - usb_recv_wpos = usb_recv_size / 2; - zero_mem32(usb_recv_buf, usb_recv_size); - - usb_recv_err_cnt = 0; - #ifdef DSD_SUPPORT - usb_dsd_enabled = false; - usb_dsd_cont_cnt = 0; -#endif + if (codec_dsd_enabled) { +#if defined(__HW_FIR_DSD_PROCESS__) + uint8_t *dsd_buf; + uint32_t dsd_size; - ret = usb_audio_start_recv(usb_recv_buf, usb_recv_wpos, usb_recv_size); - if (ret == 1) { - TRACE(0,"usb_audio_start_recv failed: usb not configured"); - } else { - ASSERT(ret == 0, "usb_audio_start_recv failed: %d", ret); - } + // DoP format requirement + dsd_size = playback_size * 16; + ; + dsd_buf = (uint8_t *)(HW_FIR_DSD_BUF_MID_ADDR - dsd_size / 2); + dsd_open(sample_rate_play, AUD_BITS_24, AUD_CHANNEL_NUM_2, dsd_buf, + dsd_size); +#elif defined(CODEC_DSD) + af_dsd_enable(); +#endif + } +#endif + usb_audio_open_eq(); } else { -#ifndef UAUD_SYNC_STREAM_TARGET - if (recv_state == AUDIO_ITF_STATE_STOPPED) +#if defined(CHIP_BEST1000) && defined(_DUAL_AUX_MIC_) + damic_init(); + init_amic_dc(); #endif - { - usb_audio_sync_reset(&capture_info); - } - usb_send_valid = 0; - usb_send_seq++; +#ifdef USB_AUDIO_SPEECH + app_overlay_select(APP_OVERLAY_HFP); - usb_send_rpos = usb_send_size / 2; - usb_send_wpos = 0; - zero_mem32(usb_send_buf, usb_send_size); + speech_process_init(sample_rate_cap, CHAN_NUM_CAPTURE, + sample_size_to_enum_playback(sample_size_cap), + sample_rate_play, CHAN_NUM_PLAYBACK, + sample_size_to_enum_playback(sample_size_play), 16, + 16, CHAN_NUM_SEND, CHAN_NUM_RECV); +#endif - usb_send_err_cnt = 0; - - ret = usb_audio_start_send(usb_send_buf, usb_send_rpos, usb_send_size); - if (ret == 1) { - TRACE(0,"usb_audio_start_send failed: usb not configured"); - } else { - ASSERT(ret == 0, "usb_audio_start_send failed: %d", ret); - } + codec_cap_valid = 0; + usb_send_init_wpos = 0; + capture_pos = 0; + capture_conflicted = 0; } - return ret; -} + // Tune rate according to the newest sync ratio info + usb_audio_cmd_tune_rate(stream); + + ret = af_stream_start(AUD_STREAM_ID_0, stream); + ASSERT(ret == 0, "af_stream_start %d failed: %d", stream, ret); -static int usb_audio_stop_usb_stream(enum AUD_STREAM_T stream) -{ if (stream == AUD_STREAM_PLAYBACK) { - usb_audio_stop_recv(); - -#ifdef DSD_SUPPORT - usb_dsd_enabled = false; +#ifdef AUDIO_ANC_FB_MC + ret = af_stream_start(AUD_STREAM_ID_2, stream); + ASSERT(ret == 0, "af_stream_start %d failed: %d", stream, ret); #endif - - usb_audio_sync_reset(&playback_info); } else { - usb_audio_stop_send(); - -#ifndef UAUD_SYNC_STREAM_TARGET - if (recv_state == AUDIO_ITF_STATE_STOPPED) -#endif - { - usb_audio_sync_reset(&capture_info); - } + codec_cap_start_time = hal_sys_timer_get(); } + } - return 0; + if (user < AUDIO_STREAM_REQ_USER_QTY) { + codec_stream_map[stream][AUDIO_STREAM_STARTED] |= (1 << user); + } + + return ret; } -static void usb_audio_set_codec_volume(enum AUD_STREAM_T stream, uint8_t vol) -{ - struct AF_STREAM_CONFIG_T *cfg; - uint8_t POSSIBLY_UNUSED old_vol; - uint32_t ret; +static int usb_audio_stop_codec_stream(enum AUD_STREAM_T stream, + enum AUDIO_STREAM_REQ_USER_T user) { + int ret = 0; - ret = af_stream_get_cfg(AUD_STREAM_ID_0, stream, &cfg, true); - if (ret == 0) { - old_vol = cfg->vol; - if (old_vol != vol) { - cfg->vol = vol; - af_stream_setup(AUD_STREAM_ID_0, stream, cfg); - } + TRACE(4, "%s: stream=%d user=%d map=0x%x", __FUNCTION__, stream, user, + codec_stream_map[stream][AUDIO_STREAM_STARTED]); + + if (user < AUDIO_STREAM_REQ_USER_QTY) { + codec_stream_map[stream][AUDIO_STREAM_STARTED] &= ~(1 << user); + } + + if (user >= AUDIO_STREAM_REQ_USER_QTY || + codec_stream_map[stream][AUDIO_STREAM_STARTED] == 0) { + ret = af_stream_stop(AUD_STREAM_ID_0, stream); + + if (stream == AUD_STREAM_PLAYBACK) { +#ifdef AUDIO_ANC_FB_MC + ret = af_stream_stop(AUD_STREAM_ID_2, stream); +#endif +#ifdef DSD_SUPPORT + if (codec_dsd_enabled) { +#if defined(__HW_FIR_DSD_PROCESS__) + dsd_close(); +#elif defined(CODEC_DSD) + af_dsd_disable(); +#endif + } +#endif + usb_audio_close_eq(); + } else { +#if defined(CHIP_BEST1000) && defined(_DUAL_AUX_MIC_) + damic_deinit(); +#endif + +#ifdef USB_AUDIO_SPEECH + speech_process_deinit(); + app_overlay_unloadall(); +#endif } + } + + return ret; +} + +static int usb_audio_start_usb_stream(enum AUD_STREAM_T stream) { + int ret; + + reset_conflict(); + + if (stream == AUD_STREAM_PLAYBACK) { + usb_audio_sync_reset(&playback_info); + + usb_recv_valid = 0; +#ifdef USB_AUDIO_MULTIFUNC + if (recv2_state == AUDIO_ITF_STATE_STOPPED) +#endif + { + usb_recv_seq++; + } + + usb_recv_rpos = 0; + usb_recv_wpos = usb_recv_size / 2; + zero_mem32(usb_recv_buf, usb_recv_size); + + usb_recv_err_cnt = 0; + +#ifdef DSD_SUPPORT + usb_dsd_enabled = false; + usb_dsd_cont_cnt = 0; +#endif + + ret = usb_audio_start_recv(usb_recv_buf, usb_recv_wpos, usb_recv_size); + if (ret == 1) { + TRACE(0, "usb_audio_start_recv failed: usb not configured"); + } else { + ASSERT(ret == 0, "usb_audio_start_recv failed: %d", ret); + } + } else { +#ifndef UAUD_SYNC_STREAM_TARGET + if (recv_state == AUDIO_ITF_STATE_STOPPED) +#endif + { + usb_audio_sync_reset(&capture_info); + } + + usb_send_valid = 0; + usb_send_seq++; + + usb_send_rpos = usb_send_size / 2; + usb_send_wpos = 0; + zero_mem32(usb_send_buf, usb_send_size); + + usb_send_err_cnt = 0; + + ret = usb_audio_start_send(usb_send_buf, usb_send_rpos, usb_send_size); + if (ret == 1) { + TRACE(0, "usb_audio_start_send failed: usb not configured"); + } else { + ASSERT(ret == 0, "usb_audio_start_send failed: %d", ret); + } + } + + return ret; +} + +static int usb_audio_stop_usb_stream(enum AUD_STREAM_T stream) { + if (stream == AUD_STREAM_PLAYBACK) { + usb_audio_stop_recv(); + +#ifdef DSD_SUPPORT + usb_dsd_enabled = false; +#endif + + usb_audio_sync_reset(&playback_info); + } else { + usb_audio_stop_send(); + +#ifndef UAUD_SYNC_STREAM_TARGET + if (recv_state == AUDIO_ITF_STATE_STOPPED) +#endif + { + usb_audio_sync_reset(&capture_info); + } + } + + return 0; +} + +static void usb_audio_set_codec_volume(enum AUD_STREAM_T stream, uint8_t vol) { + struct AF_STREAM_CONFIG_T *cfg; + uint8_t POSSIBLY_UNUSED old_vol; + uint32_t ret; + + ret = af_stream_get_cfg(AUD_STREAM_ID_0, stream, &cfg, true); + if (ret == 0) { + old_vol = cfg->vol; + if (old_vol != vol) { + cfg->vol = vol; + af_stream_setup(AUD_STREAM_ID_0, stream, cfg); + } + } #ifdef AUDIO_ANC_FB_MC - if (stream == AUD_STREAM_PLAYBACK) { - ret = af_stream_get_cfg(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &cfg, true); - if (ret == 0) { - if (cfg->vol != vol) { - cfg->vol = vol; - af_stream_setup(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, cfg); - } - } + if (stream == AUD_STREAM_PLAYBACK) { + ret = af_stream_get_cfg(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &cfg, true); + if (ret == 0) { + if (cfg->vol != vol) { + cfg->vol = vol; + af_stream_setup(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, cfg); + } } + } #endif } -static void usb_audio_enqueue_cmd(uint32_t data) -{ - int ret; - uint32_t mark; +static void usb_audio_enqueue_cmd(uint32_t data) { + int ret; + uint32_t mark; - ret = safe_queue_put(&cmd_queue, data); - ASSERT(ret == 0 || safe_queue_dump(&cmd_queue), "%s: cmd queue overflow", __FUNCTION__); + ret = safe_queue_put(&cmd_queue, data); + ASSERT(ret == 0 || safe_queue_dump(&cmd_queue), "%s: cmd queue overflow", + __FUNCTION__); - hal_cpu_wake_lock(USB_AUDIO_CPU_WAKE_USER); + hal_cpu_wake_lock(USB_AUDIO_CPU_WAKE_USER); - mark = safe_queue_watermark(&cmd_queue); - if (mark > cmd_watermark) { - cmd_watermark = mark; - TRACE(2,"%s: new watermark %u", __FUNCTION__, mark); - } + mark = safe_queue_watermark(&cmd_queue); + if (mark > cmd_watermark) { + cmd_watermark = mark; + TRACE(2, "%s: new watermark %u", __FUNCTION__, mark); + } #ifdef BT_USB_AUDIO_DUAL_MODE - if (enqueue_cmd_cb) { - enqueue_cmd_cb(data); - } + if (enqueue_cmd_cb) { + enqueue_cmd_cb(data); + } #endif } #ifdef BT_USB_AUDIO_DUAL_MODE -void usb_audio_set_enqueue_cmd_callback(USB_AUDIO_ENQUEUE_CMD_CALLBACK cb) -{ - enqueue_cmd_cb = cb; +void usb_audio_set_enqueue_cmd_callback(USB_AUDIO_ENQUEUE_CMD_CALLBACK cb) { + enqueue_cmd_cb = cb; } #endif -static void enqueue_unique_cmd_with_opp(enum AUDIO_CMD_T cmd, uint8_t seq, uint8_t arg, enum AUDIO_CMD_T oppsite_cmd) -{ - uint32_t last[3]; - uint32_t lock; - bool dup = false; +static void enqueue_unique_cmd_with_opp(enum AUDIO_CMD_T cmd, uint8_t seq, + uint8_t arg, + enum AUDIO_CMD_T oppsite_cmd) { + uint32_t last[3]; + uint32_t lock; + bool dup = false; - lock = int_lock(); - if (safe_queue_peek(&cmd_queue, -1, &last[0]) == 0 && - safe_queue_peek(&cmd_queue, -2, &last[1]) == 0 && - safe_queue_peek(&cmd_queue, -3, &last[2]) == 0) { - if (EXTRACT_CMD(last[0]) == cmd) { - dup = true; - safe_queue_pop(&cmd_queue, NULL); - } else if (EXTRACT_CMD(last[0]) == oppsite_cmd && - EXTRACT_CMD(last[1]) == cmd && - EXTRACT_CMD(last[2]) == oppsite_cmd) { - dup = true; - safe_queue_pop(&cmd_queue, NULL); - safe_queue_pop(&cmd_queue, NULL); - } + lock = int_lock(); + if (safe_queue_peek(&cmd_queue, -1, &last[0]) == 0 && + safe_queue_peek(&cmd_queue, -2, &last[1]) == 0 && + safe_queue_peek(&cmd_queue, -3, &last[2]) == 0) { + if (EXTRACT_CMD(last[0]) == cmd) { + dup = true; + safe_queue_pop(&cmd_queue, NULL); + } else if (EXTRACT_CMD(last[0]) == oppsite_cmd && + EXTRACT_CMD(last[1]) == cmd && + EXTRACT_CMD(last[2]) == oppsite_cmd) { + dup = true; + safe_queue_pop(&cmd_queue, NULL); + safe_queue_pop(&cmd_queue, NULL); } - int_unlock(lock); + } + int_unlock(lock); - usb_audio_enqueue_cmd(MAKE_QUEUE_DATA(cmd, seq, arg)); + usb_audio_enqueue_cmd(MAKE_QUEUE_DATA(cmd, seq, arg)); - if (dup) { - TRACE(2,"%s: Remove old duplicate cmd %d", __FUNCTION__, cmd); - } + if (dup) { + TRACE(2, "%s: Remove old duplicate cmd %d", __FUNCTION__, cmd); + } } -static void enqueue_unique_cmd_arg(enum AUDIO_CMD_T cmd, uint8_t seq, uint8_t arg) -{ - uint32_t last; - uint32_t cur; - uint32_t lock; - bool enqueue = true; +static void enqueue_unique_cmd_arg(enum AUDIO_CMD_T cmd, uint8_t seq, + uint8_t arg) { + uint32_t last; + uint32_t cur; + uint32_t lock; + bool enqueue = true; - cur = MAKE_QUEUE_DATA(cmd, seq, arg); + cur = MAKE_QUEUE_DATA(cmd, seq, arg); - lock = int_lock(); - if (safe_queue_peek(&cmd_queue, -1, &last) == 0) { - if (last == cur) { - enqueue = false; - } + lock = int_lock(); + if (safe_queue_peek(&cmd_queue, -1, &last) == 0) { + if (last == cur) { + enqueue = false; } - int_unlock(lock); + } + int_unlock(lock); - if (enqueue) { - usb_audio_enqueue_cmd(cur); - } else { - TRACE(2,"%s: Skip duplicate cmd %d", __FUNCTION__, cmd); - } + if (enqueue) { + usb_audio_enqueue_cmd(cur); + } else { + TRACE(2, "%s: Skip duplicate cmd %d", __FUNCTION__, cmd); + } } -static void enqueue_unique_cmd(enum AUDIO_CMD_T cmd) -{ - enqueue_unique_cmd_arg(cmd, 0, 0); +static void enqueue_unique_cmd(enum AUDIO_CMD_T cmd) { + enqueue_unique_cmd_arg(cmd, 0, 0); } -static void usb_audio_playback_start(enum USB_AUDIO_ITF_CMD_T cmd) -{ - if (cmd == USB_AUDIO_ITF_STOP) { - // Stop the stream right now - if (recv_state == AUDIO_ITF_STATE_STARTED) { - usb_audio_stop_usb_stream(AUD_STREAM_PLAYBACK); - recv_state = AUDIO_ITF_STATE_STOPPED; - } +static void usb_audio_playback_start(enum USB_AUDIO_ITF_CMD_T cmd) { + if (cmd == USB_AUDIO_ITF_STOP) { + // Stop the stream right now + if (recv_state == AUDIO_ITF_STATE_STARTED) { + usb_audio_stop_usb_stream(AUD_STREAM_PLAYBACK); + recv_state = AUDIO_ITF_STATE_STOPPED; + } #ifdef USB_AUDIO_DYN_CFG - playback_itf_set = 0; + playback_itf_set = 0; #ifdef USB_AUDIO_UAC2 - enqueue_unique_cmd_with_opp(AUDIO_CMD_STOP_PLAY, usb_recv_seq, 0, AUDIO_CMD_START_PLAY); + enqueue_unique_cmd_with_opp(AUDIO_CMD_STOP_PLAY, usb_recv_seq, 0, + AUDIO_CMD_START_PLAY); #else - enqueue_unique_cmd_with_opp(AUDIO_CMD_STOP_PLAY, usb_recv_seq, 0, AUDIO_CMD_SET_RECV_RATE); + enqueue_unique_cmd_with_opp(AUDIO_CMD_STOP_PLAY, usb_recv_seq, 0, + AUDIO_CMD_SET_RECV_RATE); #endif #else #ifdef USB_AUDIO_MULTIFUNC - if (recv2_state == AUDIO_ITF_STATE_STARTED) { - return; - } + if (recv2_state == AUDIO_ITF_STATE_STARTED) { + return; + } #endif - enqueue_unique_cmd_with_opp(AUDIO_CMD_STOP_PLAY, usb_recv_seq, 0, AUDIO_CMD_START_PLAY); + enqueue_unique_cmd_with_opp(AUDIO_CMD_STOP_PLAY, usb_recv_seq, 0, + AUDIO_CMD_START_PLAY); #endif - } else { + } else { #ifdef USB_AUDIO_DYN_CFG - if (cmd == USB_AUDIO_ITF_START_16BIT) { - new_sample_size_recv = 2; - } else if (cmd == USB_AUDIO_ITF_START_24BIT) { - new_sample_size_recv = 3; - } else { - new_sample_size_recv = 4; - } - playback_itf_set = 1; + if (cmd == USB_AUDIO_ITF_START_16BIT) { + new_sample_size_recv = 2; + } else if (cmd == USB_AUDIO_ITF_START_24BIT) { + new_sample_size_recv = 3; + } else { + new_sample_size_recv = 4; + } + playback_itf_set = 1; - // Some host applications will not stop current stream before changing sample size - if (recv_state == AUDIO_ITF_STATE_STARTED) { - usb_audio_stop_usb_stream(AUD_STREAM_PLAYBACK); - recv_state = AUDIO_ITF_STATE_STOPPED; - } + // Some host applications will not stop current stream before changing + // sample size + if (recv_state == AUDIO_ITF_STATE_STARTED) { + usb_audio_stop_usb_stream(AUD_STREAM_PLAYBACK); + recv_state = AUDIO_ITF_STATE_STOPPED; + } #ifdef USB_AUDIO_UAC2 #ifdef KEEP_SAME_LATENCY - usb_recv_size = calc_usb_recv_size(new_sample_rate_recv, new_sample_size_recv); - TRACE(2,"%s: Set usb_recv_size=%u", __FUNCTION__, usb_recv_size); + usb_recv_size = + calc_usb_recv_size(new_sample_rate_recv, new_sample_size_recv); + TRACE(2, "%s: Set usb_recv_size=%u", __FUNCTION__, usb_recv_size); #endif - usb_audio_start_usb_stream(AUD_STREAM_PLAYBACK); - recv_state = AUDIO_ITF_STATE_STARTED; + usb_audio_start_usb_stream(AUD_STREAM_PLAYBACK); + recv_state = AUDIO_ITF_STATE_STARTED; - enqueue_unique_cmd_with_opp(AUDIO_CMD_START_PLAY, usb_recv_seq, 0, AUDIO_CMD_STOP_PLAY); + enqueue_unique_cmd_with_opp(AUDIO_CMD_START_PLAY, usb_recv_seq, 0, + AUDIO_CMD_STOP_PLAY); #else - // Wait for sampling freq ctrl msg to start the stream + // Wait for sampling freq ctrl msg to start the stream #endif - return; + return; #else - if (recv_state == AUDIO_ITF_STATE_STOPPED) { - usb_audio_start_usb_stream(AUD_STREAM_PLAYBACK); - recv_state = AUDIO_ITF_STATE_STARTED; - } + if (recv_state == AUDIO_ITF_STATE_STOPPED) { + usb_audio_start_usb_stream(AUD_STREAM_PLAYBACK); + recv_state = AUDIO_ITF_STATE_STARTED; + } #ifdef USB_AUDIO_MULTIFUNC - if (recv2_state == AUDIO_ITF_STATE_STARTED) { - return; - } + if (recv2_state == AUDIO_ITF_STATE_STARTED) { + return; + } #endif - enqueue_unique_cmd_with_opp(AUDIO_CMD_START_PLAY, usb_recv_seq, 0, AUDIO_CMD_STOP_PLAY); + enqueue_unique_cmd_with_opp(AUDIO_CMD_START_PLAY, usb_recv_seq, 0, + AUDIO_CMD_STOP_PLAY); #endif - } + } } -static void usb_audio_capture_start(enum USB_AUDIO_ITF_CMD_T cmd) -{ - if (cmd == USB_AUDIO_ITF_STOP) { - // Stop the stream right now - if (send_state == AUDIO_ITF_STATE_STARTED) { - usb_audio_stop_usb_stream(AUD_STREAM_CAPTURE); - send_state = AUDIO_ITF_STATE_STOPPED; - } +static void usb_audio_capture_start(enum USB_AUDIO_ITF_CMD_T cmd) { + if (cmd == USB_AUDIO_ITF_STOP) { + // Stop the stream right now + if (send_state == AUDIO_ITF_STATE_STARTED) { + usb_audio_stop_usb_stream(AUD_STREAM_CAPTURE); + send_state = AUDIO_ITF_STATE_STOPPED; + } #ifdef USB_AUDIO_DYN_CFG - capture_itf_set = 0; + capture_itf_set = 0; #ifdef USB_AUDIO_UAC2 - enqueue_unique_cmd_with_opp(AUDIO_CMD_STOP_CAPTURE, usb_send_seq, 0, AUDIO_CMD_START_CAPTURE); + enqueue_unique_cmd_with_opp(AUDIO_CMD_STOP_CAPTURE, usb_send_seq, 0, + AUDIO_CMD_START_CAPTURE); #else - enqueue_unique_cmd_with_opp(AUDIO_CMD_STOP_CAPTURE, usb_send_seq, 0, AUDIO_CMD_SET_SEND_RATE); + enqueue_unique_cmd_with_opp(AUDIO_CMD_STOP_CAPTURE, usb_send_seq, 0, + AUDIO_CMD_SET_SEND_RATE); #endif #else - enqueue_unique_cmd_with_opp(AUDIO_CMD_STOP_CAPTURE, usb_send_seq, 0, AUDIO_CMD_START_CAPTURE); + enqueue_unique_cmd_with_opp(AUDIO_CMD_STOP_CAPTURE, usb_send_seq, 0, + AUDIO_CMD_START_CAPTURE); #endif - } else { + } else { #ifdef USB_AUDIO_DYN_CFG - capture_itf_set = 1; + capture_itf_set = 1; - // Some host applications will not stop current stream before changing sample size - if (send_state == AUDIO_ITF_STATE_STARTED) { - usb_audio_stop_usb_stream(AUD_STREAM_CAPTURE); - send_state = AUDIO_ITF_STATE_STOPPED; - } + // Some host applications will not stop current stream before changing + // sample size + if (send_state == AUDIO_ITF_STATE_STARTED) { + usb_audio_stop_usb_stream(AUD_STREAM_CAPTURE); + send_state = AUDIO_ITF_STATE_STOPPED; + } #ifdef USB_AUDIO_UAC2 - usb_audio_start_usb_stream(AUD_STREAM_CAPTURE); - send_state = AUDIO_ITF_STATE_STARTED; + usb_audio_start_usb_stream(AUD_STREAM_CAPTURE); + send_state = AUDIO_ITF_STATE_STARTED; - enqueue_unique_cmd_with_opp(AUDIO_CMD_START_CAPTURE, usb_send_seq, 0, AUDIO_CMD_STOP_CAPTURE); + enqueue_unique_cmd_with_opp(AUDIO_CMD_START_CAPTURE, usb_send_seq, 0, + AUDIO_CMD_STOP_CAPTURE); #else - // Wait for sampling freq ctrl msg to start the stream + // Wait for sampling freq ctrl msg to start the stream #endif - return; + return; #else - if (send_state == AUDIO_ITF_STATE_STOPPED) { - usb_audio_start_usb_stream(AUD_STREAM_CAPTURE); - send_state = AUDIO_ITF_STATE_STARTED; - } + if (send_state == AUDIO_ITF_STATE_STOPPED) { + usb_audio_start_usb_stream(AUD_STREAM_CAPTURE); + send_state = AUDIO_ITF_STATE_STARTED; + } - enqueue_unique_cmd_with_opp(AUDIO_CMD_START_CAPTURE, usb_send_seq, 0, AUDIO_CMD_STOP_CAPTURE); + enqueue_unique_cmd_with_opp(AUDIO_CMD_START_CAPTURE, usb_send_seq, 0, + AUDIO_CMD_STOP_CAPTURE); #endif - } + } } -static void usb_audio_mute_control(uint32_t mute) -{ - TRACE(1,"MUTE CTRL: %u", mute); - - new_mute_state = mute; -#ifdef USB_AUDIO_MULTIFUNC - if (mute) { - new_playback_coef = 0; - } else { - new_playback_coef = playback_gain_to_float(new_playback_vol); - } -#endif - usb_audio_enqueue_cmd(AUDIO_CMD_MUTE_CTRL); -} - -static void usb_audio_cap_mute_control(uint32_t mute) -{ - TRACE(1,"CAP MUTE CTRL: %u", mute); - - new_cap_mute_state = mute; - usb_audio_enqueue_cmd(AUDIO_CMD_CAP_MUTE_CTRL); -} - -static void usb_audio_vol_control(uint32_t percent) -{ - if (percent >= 100) { - new_playback_vol = MAX_VOLUME_VAL; - } else { - new_playback_vol = MIN_VOLUME_VAL + (percent * (MAX_VOLUME_VAL - MIN_VOLUME_VAL) + 50) / 100; - } - - TRACE(2,"VOL CTRL: percent=%u new_playback_vol=%u", percent, new_playback_vol); +static void usb_audio_mute_control(uint32_t mute) { + TRACE(1, "MUTE CTRL: %u", mute); + new_mute_state = mute; #ifdef USB_AUDIO_MULTIFUNC + if (mute) { + new_playback_coef = 0; + } else { new_playback_coef = playback_gain_to_float(new_playback_vol); + } +#endif + usb_audio_enqueue_cmd(AUDIO_CMD_MUTE_CTRL); +} + +static void usb_audio_cap_mute_control(uint32_t mute) { + TRACE(1, "CAP MUTE CTRL: %u", mute); + + new_cap_mute_state = mute; + usb_audio_enqueue_cmd(AUDIO_CMD_CAP_MUTE_CTRL); +} + +static void usb_audio_vol_control(uint32_t percent) { + if (percent >= 100) { + new_playback_vol = MAX_VOLUME_VAL; + } else { + new_playback_vol = MIN_VOLUME_VAL + + (percent * (MAX_VOLUME_VAL - MIN_VOLUME_VAL) + 50) / 100; + } + + TRACE(2, "VOL CTRL: percent=%u new_playback_vol=%u", percent, + new_playback_vol); + +#ifdef USB_AUDIO_MULTIFUNC + new_playback_coef = playback_gain_to_float(new_playback_vol); #else - usb_audio_enqueue_cmd(AUDIO_CMD_SET_VOLUME); + usb_audio_enqueue_cmd(AUDIO_CMD_SET_VOLUME); #endif } -static void usb_audio_cap_vol_control(uint32_t percent) -{ - if (percent >= 100) { - new_capture_vol = MAX_CAP_VOLUME_VAL; - } else { - new_capture_vol = MIN_CAP_VOLUME_VAL + (percent * (MAX_CAP_VOLUME_VAL - MIN_CAP_VOLUME_VAL) + 50) / 100; - } +static void usb_audio_cap_vol_control(uint32_t percent) { + if (percent >= 100) { + new_capture_vol = MAX_CAP_VOLUME_VAL; + } else { + new_capture_vol = + MIN_CAP_VOLUME_VAL + + (percent * (MAX_CAP_VOLUME_VAL - MIN_CAP_VOLUME_VAL) + 50) / 100; + } - TRACE(2,"CAP VOL CTRL: percent=%u new_capture_vol=%u", percent, new_capture_vol); + TRACE(2, "CAP VOL CTRL: percent=%u new_capture_vol=%u", percent, + new_capture_vol); - usb_audio_enqueue_cmd(AUDIO_CMD_SET_CAP_VOLUME); + usb_audio_enqueue_cmd(AUDIO_CMD_SET_CAP_VOLUME); } -static uint32_t usb_audio_get_vol_percent(void) -{ - if (new_playback_vol >= MAX_VOLUME_VAL) { - return 100; - } else if (new_playback_vol <= MIN_VOLUME_VAL) { - return 0; - } else { - return ((new_playback_vol - MIN_VOLUME_VAL) * 100 + (MAX_VOLUME_VAL - MIN_VOLUME_VAL) / 2) - / (MAX_VOLUME_VAL - MIN_VOLUME_VAL); - } +static uint32_t usb_audio_get_vol_percent(void) { + if (new_playback_vol >= MAX_VOLUME_VAL) { + return 100; + } else if (new_playback_vol <= MIN_VOLUME_VAL) { + return 0; + } else { + return ((new_playback_vol - MIN_VOLUME_VAL) * 100 + + (MAX_VOLUME_VAL - MIN_VOLUME_VAL) / 2) / + (MAX_VOLUME_VAL - MIN_VOLUME_VAL); + } } -static uint32_t usb_audio_get_cap_vol_percent(void) -{ - if (new_capture_vol >= MAX_CAP_VOLUME_VAL) { - return 100; - } else if (new_capture_vol <= MIN_CAP_VOLUME_VAL) { - return 0; - } else { - return ((new_capture_vol - MIN_CAP_VOLUME_VAL) * 100 + (MAX_CAP_VOLUME_VAL - MIN_CAP_VOLUME_VAL) / 2) - / (MAX_CAP_VOLUME_VAL - MIN_CAP_VOLUME_VAL); - } +static uint32_t usb_audio_get_cap_vol_percent(void) { + if (new_capture_vol >= MAX_CAP_VOLUME_VAL) { + return 100; + } else if (new_capture_vol <= MIN_CAP_VOLUME_VAL) { + return 0; + } else { + return ((new_capture_vol - MIN_CAP_VOLUME_VAL) * 100 + + (MAX_CAP_VOLUME_VAL - MIN_CAP_VOLUME_VAL) / 2) / + (MAX_CAP_VOLUME_VAL - MIN_CAP_VOLUME_VAL); + } } -static void usb_audio_tune_rate(enum AUD_STREAM_T stream, float ratio) -{ - bool update_play, update_cap; +static void usb_audio_tune_rate(enum AUD_STREAM_T stream, float ratio) { + bool update_play, update_cap; - update_play = true; - update_cap = false; + update_play = true; + update_cap = false; #if defined(__AUDIO_RESAMPLE__) && defined(PLL_TUNE_SAMPLE_RATE) #ifdef UAUD_SYNC_STREAM_TARGET - if (stream == AUD_STREAM_PLAYBACK) { - update_play = true; - update_cap = false; - } else { - update_play = false; - update_cap = true; - } -#else + if (stream == AUD_STREAM_PLAYBACK) { update_play = true; + update_cap = false; + } else { + update_play = false; update_cap = true; + } +#else + update_play = true; + update_cap = true; #endif #endif - if (update_play) { - rate_tune_ratio[AUD_STREAM_PLAYBACK] = rate_tune_ratio[AUD_STREAM_PLAYBACK] + - ratio + rate_tune_ratio[AUD_STREAM_PLAYBACK] * ratio; - } - if (update_cap) { - rate_tune_ratio[AUD_STREAM_CAPTURE] = rate_tune_ratio[AUD_STREAM_CAPTURE] + - ratio + rate_tune_ratio[AUD_STREAM_CAPTURE] * ratio; - } + if (update_play) { + rate_tune_ratio[AUD_STREAM_PLAYBACK] = + rate_tune_ratio[AUD_STREAM_PLAYBACK] + ratio + + rate_tune_ratio[AUD_STREAM_PLAYBACK] * ratio; + } + if (update_cap) { + rate_tune_ratio[AUD_STREAM_CAPTURE] = + rate_tune_ratio[AUD_STREAM_CAPTURE] + ratio + + rate_tune_ratio[AUD_STREAM_CAPTURE] * ratio; + } - TRACE(4,"%s[%u]: ratio=%d resample_ratio=%d", __FUNCTION__, stream, FLOAT_TO_PPB_INT(ratio), - update_cap ? FLOAT_TO_PPB_INT(rate_tune_ratio[stream]) : FLOAT_TO_PPB_INT(rate_tune_ratio[AUD_STREAM_PLAYBACK])); + TRACE(4, "%s[%u]: ratio=%d resample_ratio=%d", __FUNCTION__, stream, + FLOAT_TO_PPB_INT(ratio), + update_cap ? FLOAT_TO_PPB_INT(rate_tune_ratio[stream]) + : FLOAT_TO_PPB_INT(rate_tune_ratio[AUD_STREAM_PLAYBACK])); - enqueue_unique_cmd_arg(AUDIO_CMD_TUNE_RATE, 0, stream); + enqueue_unique_cmd_arg(AUDIO_CMD_TUNE_RATE, 0, stream); } -static void usb_audio_data_recv_handler(const struct USB_AUDIO_XFER_INFO_T *info) -{ - const uint8_t *data; - uint32_t size; - uint32_t old_wpos, new_wpos, wpos_boundary, rpos; - uint32_t old_play_pos = 0; - uint32_t play_pos; - uint32_t lock; - int conflicted; - uint32_t recv_samp, play_samp; - uint32_t cur_time; +static void +usb_audio_data_recv_handler(const struct USB_AUDIO_XFER_INFO_T *info) { + const uint8_t *data; + uint32_t size; + uint32_t old_wpos, new_wpos, wpos_boundary, rpos; + uint32_t old_play_pos = 0; + uint32_t play_pos; + uint32_t lock; + int conflicted; + uint32_t recv_samp, play_samp; + uint32_t cur_time; - cur_time = hal_sys_timer_get(); - last_usb_recv_time = cur_time; + cur_time = hal_sys_timer_get(); + last_usb_recv_time = cur_time; - data = info->data; - size = info->size; + data = info->data; + size = info->size; + if (info->cur_compl_err || info->next_xfer_err) { + if (usb_recv_err_cnt == 0) { + usb_recv_err_cnt++; + usb_recv_ok_cnt = 0; + last_usb_recv_err_time = cur_time; + } else { + usb_recv_err_cnt++; + } + } else { + if (usb_recv_err_cnt) { + usb_recv_ok_cnt++; + } + } + if (usb_recv_err_cnt && + cur_time - last_usb_recv_err_time >= USB_XFER_ERR_REPORT_INTERVAL) { if (info->cur_compl_err || info->next_xfer_err) { - if (usb_recv_err_cnt == 0) { - usb_recv_err_cnt++; - usb_recv_ok_cnt = 0; - last_usb_recv_err_time = cur_time; - } else { - usb_recv_err_cnt++; - } + TRACE(2, "recv: ERROR: cur_err=%d next_err=%d", info->cur_compl_err, + info->next_xfer_err); + } + TRACE(3, "recv: ERROR-CNT: err=%u ok=%u in %u ms", usb_recv_err_cnt, + usb_recv_ok_cnt, TICKS_TO_MS(USB_XFER_ERR_REPORT_INTERVAL)); + usb_recv_err_cnt = 0; + } + + if (usb_recv_buf <= data && data <= usb_recv_buf + usb_recv_size) { + if (data != usb_recv_buf + usb_recv_wpos) { + TRACE( + 3, + "recv: WARNING: Invalid wpos=0x%x data=%p recv_buf=%p. IRQ missing?", + usb_recv_wpos, data, usb_recv_buf); + usb_recv_wpos = data - usb_recv_buf; + } + } + + old_wpos = usb_recv_wpos; + new_wpos = old_wpos + size; + if (new_wpos >= usb_recv_size) { + new_wpos -= usb_recv_size; + } + + if (recv_state == AUDIO_ITF_STATE_STOPPED || size == 0 || // rx paused + 0) { + usb_recv_valid = 0; + } else { + if (info->cur_compl_err == 0) { + usb_recv_valid = 1; + } + } + + if (usb_recv_valid == 0 || usb_recv_init_rpos == 0 || codec_config_lock || + codec_play_seq != usb_recv_seq || codec_play_valid == 0 || + playback_state == AUDIO_ITF_STATE_STOPPED || 0) { + usb_recv_wpos = new_wpos; + return; + } + + conflicted = 0; + + lock = int_lock(); + if (playback_conflicted) { + playback_conflicted = 0; + rpos = 0; // Avoid compiler warnings + conflicted = 1; + } else { + rpos = usb_recv_rpos; + old_play_pos = playback_pos; + play_pos = af_stream_get_cur_dma_pos(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + } + int_unlock(lock); + + if (conflicted == 0) { + if (info->pool_enabled) { + // USBC will write to memory pool. + wpos_boundary = new_wpos; } else { - if (usb_recv_err_cnt) { - usb_recv_ok_cnt++; - } - } - if (usb_recv_err_cnt && cur_time - last_usb_recv_err_time >= USB_XFER_ERR_REPORT_INTERVAL) { - if (info->cur_compl_err || info->next_xfer_err) { - TRACE(2,"recv: ERROR: cur_err=%d next_err=%d", info->cur_compl_err, info->next_xfer_err); - } - TRACE(3,"recv: ERROR-CNT: err=%u ok=%u in %u ms", usb_recv_err_cnt, usb_recv_ok_cnt, TICKS_TO_MS(USB_XFER_ERR_REPORT_INTERVAL)); - usb_recv_err_cnt = 0; + // USBC will write to new_wpos directly, so the buffer [new_wpos, new_wpos + // + info->next_size) must be protected too. + wpos_boundary = new_wpos + info->next_size; + if (wpos_boundary >= usb_recv_size) { + wpos_boundary -= usb_recv_size; + } } - if (usb_recv_buf <= data && data <= usb_recv_buf + usb_recv_size) { - if (data != usb_recv_buf + usb_recv_wpos) { - TRACE(3,"recv: WARNING: Invalid wpos=0x%x data=%p recv_buf=%p. IRQ missing?", usb_recv_wpos, data, usb_recv_buf); - usb_recv_wpos = data - usb_recv_buf; - } - } - - old_wpos = usb_recv_wpos; - new_wpos = old_wpos + size; - if (new_wpos >= usb_recv_size) { - new_wpos -= usb_recv_size; - } - - if (recv_state == AUDIO_ITF_STATE_STOPPED || - size == 0 || // rx paused - 0) { - usb_recv_valid = 0; - } else { - if (info->cur_compl_err == 0) { - usb_recv_valid = 1; - } - } - - if (usb_recv_valid == 0 || - usb_recv_init_rpos == 0 || - codec_config_lock || - codec_play_seq != usb_recv_seq || - codec_play_valid == 0 || - playback_state == AUDIO_ITF_STATE_STOPPED || - 0) { - usb_recv_wpos = new_wpos; - return; - } - - conflicted = 0; - - lock = int_lock(); - if (playback_conflicted) { - playback_conflicted = 0; - rpos = 0; // Avoid compiler warnings + if (old_wpos <= rpos) { + if (wpos_boundary < old_wpos || rpos < wpos_boundary) { conflicted = 1; + } } else { - rpos = usb_recv_rpos; - old_play_pos = playback_pos; - play_pos = af_stream_get_cur_dma_pos(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + if (rpos < wpos_boundary && wpos_boundary < old_wpos) { + conflicted = 1; + } } - int_unlock(lock); - if (conflicted == 0) { - if (info->pool_enabled) { - // USBC will write to memory pool. - wpos_boundary = new_wpos; - } else { - // USBC will write to new_wpos directly, so the buffer [new_wpos, new_wpos + info->next_size) must be protected too. - wpos_boundary = new_wpos + info->next_size; - if (wpos_boundary >= usb_recv_size) { - wpos_boundary -= usb_recv_size; - } - } + if (conflicted) { + uint32_t reset_len = usb_recv_size / 2; + uint32_t saved_old_wpos = old_wpos; - if (old_wpos <= rpos) { - if (wpos_boundary < old_wpos || rpos < wpos_boundary) { - conflicted = 1; - } - } else { - if (rpos < wpos_boundary && wpos_boundary < old_wpos) { - conflicted = 1; - } - } - - if (conflicted) { - uint32_t reset_len = usb_recv_size / 2; - uint32_t saved_old_wpos = old_wpos; - - // Reset write position - old_wpos = rpos + reset_len; - if (old_wpos >= usb_recv_size) { - old_wpos -= usb_recv_size; - } - new_wpos = old_wpos + size; - if (new_wpos >= usb_recv_size) { - new_wpos -= usb_recv_size; - } + // Reset write position + old_wpos = rpos + reset_len; + if (old_wpos >= usb_recv_size) { + old_wpos -= usb_recv_size; + } + new_wpos = old_wpos + size; + if (new_wpos >= usb_recv_size) { + new_wpos -= usb_recv_size; + } #if 0 usb_audio_stop_recv(); usb_audio_start_recv(usb_recv_buf, new_wpos, usb_recv_size); #else - usb_audio_set_recv_pos(new_wpos); + usb_audio_set_recv_pos(new_wpos); #endif - TRACE(4,"recv: Error: wpos=%u goes beyond rpos=%u with len=%u. Reset to %u", saved_old_wpos, rpos, size, old_wpos); - } - record_conflict(conflicted); + TRACE(4, + "recv: Error: wpos=%u goes beyond rpos=%u with len=%u. Reset to %u", + saved_old_wpos, rpos, size, old_wpos); } + record_conflict(conflicted); + } - usb_recv_wpos = new_wpos; + usb_recv_wpos = new_wpos; #if (VERBOSE_TRACE & (1 << 5)) - { - int hw_play_pos = af_stream_get_cur_dma_pos(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - TRACE_TIME(5,"recv: wpos=%u size=%u rpos=%u playback_pos=%u hw_play_pos=%d", old_wpos, size, - rpos, playback_pos, hw_play_pos); - } + { + int hw_play_pos = + af_stream_get_cur_dma_pos(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + TRACE_TIME(5, + "recv: wpos=%u size=%u rpos=%u playback_pos=%u hw_play_pos=%d", + old_wpos, size, rpos, playback_pos, hw_play_pos); + } #endif - if (conflicted) { - usb_audio_sync_reset(&playback_info); - return; - } + if (conflicted) { + usb_audio_sync_reset(&playback_info); + return; + } - if (usb_recv_buf <= data && data <= usb_recv_buf + usb_recv_size) { - recv_samp = byte_to_samp_recv(new_wpos); + if (usb_recv_buf <= data && data <= usb_recv_buf + usb_recv_size) { + recv_samp = byte_to_samp_recv(new_wpos); + } else { + recv_samp = -1; + } + + if ((int)play_pos >= 0) { + if (play_pos >= playback_size) { + play_pos = 0; + } + // Count the bytes of data waiting to play in the codec buffer + uint32_t bytes_to_play; + if (old_play_pos <= play_pos) { + bytes_to_play = playback_size + old_play_pos - play_pos; } else { - recv_samp = -1; + bytes_to_play = old_play_pos - play_pos; } - - if ((int)play_pos >= 0) { - if (play_pos >= playback_size) { - play_pos = 0; - } - // Count the bytes of data waiting to play in the codec buffer - uint32_t bytes_to_play; - if (old_play_pos <= play_pos) { - bytes_to_play = playback_size + old_play_pos - play_pos; - } else { - bytes_to_play = old_play_pos - play_pos; - } - uint32_t usb_bytes_to_play; - usb_bytes_to_play = playback_to_recv_len(bytes_to_play); - if (rpos >= usb_bytes_to_play) { - play_pos = rpos - usb_bytes_to_play; - } else { - play_pos = usb_recv_size + rpos - usb_bytes_to_play; - } - play_samp = byte_to_samp_recv(play_pos); + uint32_t usb_bytes_to_play; + usb_bytes_to_play = playback_to_recv_len(bytes_to_play); + if (rpos >= usb_bytes_to_play) { + play_pos = rpos - usb_bytes_to_play; } else { - play_samp = -1; + play_pos = usb_recv_size + rpos - usb_bytes_to_play; } + play_samp = byte_to_samp_recv(play_pos); + } else { + play_samp = -1; + } - if (recv_samp != -1 && play_samp != -1) { - enum UAUD_SYNC_RET_T ret; - float ratio; + if (recv_samp != -1 && play_samp != -1) { + enum UAUD_SYNC_RET_T ret; + float ratio; - ret = usb_audio_sync(play_samp, recv_samp, &playback_info, &ratio); - if (ret == UAUD_SYNC_START) { - usb_audio_tune_rate(AUD_STREAM_PLAYBACK, ratio); - } - } else { - //TRACE(2,"recv_hdlr: recv_samp=0x%08x play_samp=0x%08x", recv_samp, play_samp); + ret = usb_audio_sync(play_samp, recv_samp, &playback_info, &ratio); + if (ret == UAUD_SYNC_START) { + usb_audio_tune_rate(AUD_STREAM_PLAYBACK, ratio); } + } else { + // TRACE(2,"recv_hdlr: recv_samp=0x%08x play_samp=0x%08x", recv_samp, + // play_samp); + } #ifdef DSD_SUPPORT - if (sample_size_recv == 3 && (sample_rate_recv == 176400 || sample_rate_recv == 352800)) { - // First DoP solution marks - static const uint8_t pattern[2] = { 0x05, 0xFA, }; - // Second DoP solution marks -- not supported yet - //static const uint8_t pattern2[2] = { 0x06, 0xF9, }; - static const uint16_t dsd_detect_thresh = 32; - uint8_t idx; - const uint8_t *dsd, *dsd_end, *dsd_end2; - bool dsd_valid = true; + if (sample_size_recv == 3 && + (sample_rate_recv == 176400 || sample_rate_recv == 352800)) { + // First DoP solution marks + static const uint8_t pattern[2] = { + 0x05, + 0xFA, + }; + // Second DoP solution marks -- not supported yet + // static const uint8_t pattern2[2] = { 0x06, 0xF9, }; + static const uint16_t dsd_detect_thresh = 32; + uint8_t idx; + const uint8_t *dsd, *dsd_end, *dsd_end2; + bool dsd_valid = true; - dsd = data + 2; - dsd_end = data + size; - dsd_end2 = usb_recv_buf + usb_recv_size; - if (dsd_end <= dsd_end2) { - dsd_end2 = NULL; - } else { - dsd_end = dsd_end2; - dsd_end2 = data + size - usb_recv_size; - } - if (*dsd == pattern[0]) { - idx = 0; - } else { - idx = 1; - } - -_check_dsd: - while (dsd < dsd_end) { - if (*dsd == pattern[idx]) { -#if (CHAN_NUM_RECV == 2) - dsd += 3; - if (dsd >= dsd_end || *dsd != pattern[idx]) { - dsd_valid = false; - break; - } -#endif - if (usb_dsd_cont_cnt < dsd_detect_thresh) { - usb_dsd_cont_cnt += CHAN_NUM_RECV; - } - idx = !idx; - dsd += 3; - } else { - dsd_valid = false; - break; - } - } - if (dsd_valid && dsd_end2) { - dsd = usb_recv_buf + 2; - dsd_end = dsd_end2; - dsd_end2 = NULL; - goto _check_dsd; - } - - if (dsd_valid && usb_dsd_cont_cnt < dsd_detect_thresh) { - dsd_valid = false; - } - if (!dsd_valid) { - usb_dsd_cont_cnt = 0; - } - - if (dsd_valid != usb_dsd_enabled) { - usb_dsd_enabled = dsd_valid; - enqueue_unique_cmd(AUDIO_CMD_SET_DSD_CFG); - } + dsd = data + 2; + dsd_end = data + size; + dsd_end2 = usb_recv_buf + usb_recv_size; + if (dsd_end <= dsd_end2) { + dsd_end2 = NULL; + } else { + dsd_end = dsd_end2; + dsd_end2 = data + size - usb_recv_size; } + if (*dsd == pattern[0]) { + idx = 0; + } else { + idx = 1; + } + + _check_dsd: + while (dsd < dsd_end) { + if (*dsd == pattern[idx]) { +#if (CHAN_NUM_RECV == 2) + dsd += 3; + if (dsd >= dsd_end || *dsd != pattern[idx]) { + dsd_valid = false; + break; + } +#endif + if (usb_dsd_cont_cnt < dsd_detect_thresh) { + usb_dsd_cont_cnt += CHAN_NUM_RECV; + } + idx = !idx; + dsd += 3; + } else { + dsd_valid = false; + break; + } + } + if (dsd_valid && dsd_end2) { + dsd = usb_recv_buf + 2; + dsd_end = dsd_end2; + dsd_end2 = NULL; + goto _check_dsd; + } + + if (dsd_valid && usb_dsd_cont_cnt < dsd_detect_thresh) { + dsd_valid = false; + } + if (!dsd_valid) { + usb_dsd_cont_cnt = 0; + } + + if (dsd_valid != usb_dsd_enabled) { + usb_dsd_enabled = dsd_valid; + enqueue_unique_cmd(AUDIO_CMD_SET_DSD_CFG); + } + } #endif } -static void usb_audio_data_send_handler(const struct USB_AUDIO_XFER_INFO_T *info) -{ - const uint8_t *data; - uint32_t size; - uint32_t old_rpos, new_rpos, rpos_boundary, wpos; - uint32_t old_cap_pos = 0; - uint32_t cap_pos; - uint32_t lock; - int conflicted; - uint32_t send_samp, cap_samp; - uint32_t cur_time; +static void +usb_audio_data_send_handler(const struct USB_AUDIO_XFER_INFO_T *info) { + const uint8_t *data; + uint32_t size; + uint32_t old_rpos, new_rpos, rpos_boundary, wpos; + uint32_t old_cap_pos = 0; + uint32_t cap_pos; + uint32_t lock; + int conflicted; + uint32_t send_samp, cap_samp; + uint32_t cur_time; - cur_time = hal_sys_timer_get(); - last_usb_send_time = cur_time; + cur_time = hal_sys_timer_get(); + last_usb_send_time = cur_time; - data = info->data; - size = info->size; + data = info->data; + size = info->size; + if (info->cur_compl_err || info->next_xfer_err) { + if (usb_send_err_cnt == 0) { + usb_send_err_cnt++; + usb_send_ok_cnt = 0; + last_usb_send_err_time = cur_time; + } else { + usb_send_err_cnt++; + } + } else { + if (usb_send_err_cnt) { + usb_send_ok_cnt++; + } + } + if (usb_send_err_cnt && + cur_time - last_usb_send_err_time >= USB_XFER_ERR_REPORT_INTERVAL) { if (info->cur_compl_err || info->next_xfer_err) { - if (usb_send_err_cnt == 0) { - usb_send_err_cnt++; - usb_send_ok_cnt = 0; - last_usb_send_err_time = cur_time; - } else { - usb_send_err_cnt++; - } - } else { - if (usb_send_err_cnt) { - usb_send_ok_cnt++; - } - } - if (usb_send_err_cnt && cur_time - last_usb_send_err_time >= USB_XFER_ERR_REPORT_INTERVAL) { - if (info->cur_compl_err || info->next_xfer_err) { - TRACE(2,"send: ERROR: cur_err=%d next_err=%d", info->cur_compl_err, info->next_xfer_err); - } - TRACE(3,"send: ERROR-CNT: err=%u ok=%u in %u ms", usb_send_err_cnt, usb_send_ok_cnt, TICKS_TO_MS(USB_XFER_ERR_REPORT_INTERVAL)); - usb_send_err_cnt = 0; + TRACE(2, "send: ERROR: cur_err=%d next_err=%d", info->cur_compl_err, + info->next_xfer_err); } + TRACE(3, "send: ERROR-CNT: err=%u ok=%u in %u ms", usb_send_err_cnt, + usb_send_ok_cnt, TICKS_TO_MS(USB_XFER_ERR_REPORT_INTERVAL)); + usb_send_err_cnt = 0; + } + if (info->pool_enabled) { + // The buffer [data, size) has been sent completely, and + // the buffer [data + size, data + size + info->next_size) has been copied + // to memory pool. Make usb_send_rpos point to the pending send buffer + data += size; + if (data >= usb_send_buf + usb_send_size) { + data -= usb_send_size; + } + size = info->next_size; + } + + if (usb_send_buf <= data && data <= usb_send_buf + usb_send_size) { + if (data != usb_send_buf + usb_send_rpos) { + if (usb_send_valid == 0 && info->pool_enabled && + info->data != usb_send_buf + usb_send_rpos) { + TRACE(3, + "send: WARNING: Invalid rpos=0x%x data=%p send_buf=%p. IRQ " + "missing?", + usb_send_rpos, data, usb_send_buf); + } + usb_send_rpos = data - usb_send_buf; + } + } + + old_rpos = usb_send_rpos; + new_rpos = old_rpos + size; + if (new_rpos >= usb_send_size) { + new_rpos -= usb_send_size; + } + + if (send_state == AUDIO_ITF_STATE_STOPPED || size == 0 || // tx paused + 0) { + usb_send_valid = 0; + } else { + if (info->cur_compl_err == 0) { + usb_send_valid = 1; + } + } + + if (usb_send_valid == 0 || usb_send_init_wpos == 0 || codec_config_lock || + codec_cap_seq != usb_send_seq || codec_cap_valid == 0 || + capture_state == AUDIO_ITF_STATE_STOPPED || 0) { + usb_send_rpos = new_rpos; + if (usb_send_valid) { + // Zero the send buffer next to the part being sent by USB h/w + if (info->pool_enabled) { + uint32_t clr_len; + + clr_len = samp_to_byte_send(SAMP_RATE_TO_FRAME_SIZE(sample_rate_send)); + if (usb_send_rpos + clr_len <= usb_send_size) { + zero_mem16(usb_send_buf + usb_send_rpos, clr_len); + } else { + zero_mem16(usb_send_buf + usb_send_rpos, + usb_send_size - usb_send_rpos); + zero_mem16(usb_send_buf, clr_len - (usb_send_size - usb_send_rpos)); + } + } else { + // If no pool is enabled, the send pkt size is a fixed value, and + // the send buffer size is a integral multiple of the send pkt size + if (usb_send_rpos + size + size <= usb_send_size) { + zero_mem32(usb_send_buf + usb_send_rpos + size, size); + } else { + zero_mem32(usb_send_buf, size); + } + } + } + return; + } + + conflicted = 0; + + lock = int_lock(); + if (capture_conflicted) { + capture_conflicted = 0; + wpos = 0; // Avoid compiler warnings + conflicted = 1; + } else { + wpos = usb_send_wpos; + old_cap_pos = capture_pos; + cap_pos = af_stream_get_cur_dma_pos(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + } + int_unlock(lock); + + if (conflicted == 0) { if (info->pool_enabled) { - // The buffer [data, size) has been sent completely, and - // the buffer [data + size, data + size + info->next_size) has been copied to memory pool. - // Make usb_send_rpos point to the pending send buffer - data += size; - if (data >= usb_send_buf + usb_send_size) { - data -= usb_send_size; - } - size = info->next_size; - } - - if (usb_send_buf <= data && data <= usb_send_buf + usb_send_size) { - if (data != usb_send_buf + usb_send_rpos) { - if (usb_send_valid == 0 && info->pool_enabled && info->data != usb_send_buf + usb_send_rpos) { - TRACE(3,"send: WARNING: Invalid rpos=0x%x data=%p send_buf=%p. IRQ missing?", usb_send_rpos, data, usb_send_buf); - } - usb_send_rpos = data - usb_send_buf; - } - } - - old_rpos = usb_send_rpos; - new_rpos = old_rpos + size; - if (new_rpos >= usb_send_size) { - new_rpos -= usb_send_size; - } - - if (send_state == AUDIO_ITF_STATE_STOPPED || - size == 0 || // tx paused - 0) { - usb_send_valid = 0; + // old_rpos points to the pending send buffer, which has been copied to + // memory pool. USBC will read from memory pool. + rpos_boundary = new_rpos; } else { - if (info->cur_compl_err == 0) { - usb_send_valid = 1; - } + // old_rpos points to the buffer just sent completely. + // USBC will read from new_rpos directly, so the buffer [new_rpos, + // new_rpos + info->next_size) must be protected too. + rpos_boundary = new_rpos + info->next_size; + if (rpos_boundary >= usb_recv_size) { + rpos_boundary -= usb_recv_size; + } } - if (usb_send_valid == 0 || - usb_send_init_wpos == 0 || - codec_config_lock || - codec_cap_seq != usb_send_seq || - codec_cap_valid == 0 || - capture_state == AUDIO_ITF_STATE_STOPPED || - 0) { - usb_send_rpos = new_rpos; - if (usb_send_valid) { - // Zero the send buffer next to the part being sent by USB h/w - if (info->pool_enabled) { - uint32_t clr_len; - - clr_len = samp_to_byte_send(SAMP_RATE_TO_FRAME_SIZE(sample_rate_send)); - if (usb_send_rpos + clr_len <= usb_send_size) { - zero_mem16(usb_send_buf + usb_send_rpos, clr_len); - } else { - zero_mem16(usb_send_buf + usb_send_rpos, usb_send_size - usb_send_rpos); - zero_mem16(usb_send_buf, clr_len - (usb_send_size - usb_send_rpos)); - } - } else { - // If no pool is enabled, the send pkt size is a fixed value, and - // the send buffer size is a integral multiple of the send pkt size - if (usb_send_rpos + size + size <= usb_send_size) { - zero_mem32(usb_send_buf + usb_send_rpos + size, size); - } else { - zero_mem32(usb_send_buf, size); - } - } - } - return; - } - - conflicted = 0; - - lock = int_lock(); - if (capture_conflicted) { - capture_conflicted = 0; - wpos = 0; // Avoid compiler warnings + if (old_rpos <= wpos) { + if (new_rpos < old_rpos || wpos < new_rpos) { conflicted = 1; + } } else { - wpos = usb_send_wpos; - old_cap_pos = capture_pos; - cap_pos = af_stream_get_cur_dma_pos(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + if (wpos < new_rpos && new_rpos < old_rpos) { + conflicted = 1; + } } - int_unlock(lock); - if (conflicted == 0) { - if (info->pool_enabled) { - // old_rpos points to the pending send buffer, which has been copied to memory pool. - // USBC will read from memory pool. - rpos_boundary = new_rpos; - } else { - // old_rpos points to the buffer just sent completely. - // USBC will read from new_rpos directly, so the buffer [new_rpos, new_rpos + info->next_size) must be protected too. - rpos_boundary = new_rpos + info->next_size; - if (rpos_boundary >= usb_recv_size) { - rpos_boundary -= usb_recv_size; - } - } + if (conflicted) { + uint32_t reset_len = usb_send_size / 2; + uint32_t saved_old_rpos = old_rpos; - if (old_rpos <= wpos) { - if (new_rpos < old_rpos || wpos < new_rpos) { - conflicted = 1; - } - } else { - if (wpos < new_rpos && new_rpos < old_rpos) { - conflicted = 1; - } - } - - if (conflicted) { - uint32_t reset_len = usb_send_size / 2; - uint32_t saved_old_rpos = old_rpos; - - // Reset read position - old_rpos = wpos + reset_len; - if (old_rpos >= usb_send_size) { - old_rpos -= usb_send_size; - } - new_rpos = old_rpos + size; - if (new_rpos >= usb_send_size) { - new_rpos -= usb_send_size; - } + // Reset read position + old_rpos = wpos + reset_len; + if (old_rpos >= usb_send_size) { + old_rpos -= usb_send_size; + } + new_rpos = old_rpos + size; + if (new_rpos >= usb_send_size) { + new_rpos -= usb_send_size; + } #if 0 usb_audio_stop_send(); usb_audio_start_send(usb_send_buf, new_rpos, usb_send_size); #else - usb_audio_set_send_pos(new_rpos); + usb_audio_set_send_pos(new_rpos); #endif - TRACE(4,"send: Error: rpos=%u goes beyond wpos=%u with len=%u. Reset to %u", saved_old_rpos, wpos, size, old_rpos); - } - record_conflict(conflicted); + TRACE(4, + "send: Error: rpos=%u goes beyond wpos=%u with len=%u. Reset to %u", + saved_old_rpos, wpos, size, old_rpos); } + record_conflict(conflicted); + } - usb_send_rpos = new_rpos; + usb_send_rpos = new_rpos; #if (VERBOSE_TRACE & (1 << 6)) - TRACE_TIME(3,"send: rpos=%u size=%u wpos=%u", old_rpos, size, wpos); + TRACE_TIME(3, "send: rpos=%u size=%u wpos=%u", old_rpos, size, wpos); #endif - if (conflicted) { - usb_audio_sync_reset(&capture_info); - return; - } + if (conflicted) { + usb_audio_sync_reset(&capture_info); + return; + } #ifndef UAUD_SYNC_STREAM_TARGET - // Recv takes precedence - if (recv_state == AUDIO_ITF_STATE_STARTED) { - return; - } + // Recv takes precedence + if (recv_state == AUDIO_ITF_STATE_STARTED) { + return; + } #endif - if (usb_send_buf <= data && data <= usb_send_buf + usb_send_size) { - send_samp = byte_to_samp_send(new_rpos); - } else { - send_samp = -1; - } + if (usb_send_buf <= data && data <= usb_send_buf + usb_send_size) { + send_samp = byte_to_samp_send(new_rpos); + } else { + send_samp = -1; + } - if ((int)cap_pos >= 0) { - if (cap_pos >= capture_size) { - cap_pos = 0; - } - // Count the bytes of data newly captured in the codec buffer - uint32_t bytes_cap; - if (old_cap_pos <= cap_pos) { - bytes_cap = cap_pos - old_cap_pos; - } else { - bytes_cap = capture_size + cap_pos - old_cap_pos; - } - uint32_t usb_bytes_cap; - usb_bytes_cap = capture_to_send_len(bytes_cap); - cap_pos = wpos + usb_bytes_cap; - if (cap_pos >= usb_send_size) { - cap_pos -= usb_send_size; - } - cap_samp = byte_to_samp_send(cap_pos); - } else { - cap_samp = -1; + if ((int)cap_pos >= 0) { + if (cap_pos >= capture_size) { + cap_pos = 0; } - - if (send_samp != -1 && cap_samp != -1) { - enum UAUD_SYNC_RET_T ret; - float ratio; - - ret = usb_audio_sync(cap_samp, send_samp, &capture_info, &ratio); - if (ret == UAUD_SYNC_START) { - usb_audio_tune_rate(AUD_STREAM_CAPTURE, ratio); - } + // Count the bytes of data newly captured in the codec buffer + uint32_t bytes_cap; + if (old_cap_pos <= cap_pos) { + bytes_cap = cap_pos - old_cap_pos; } else { - //TRACE(2,"send_hdlr: send_samp=0x%08x cap_samp=0x%08x", send_samp, cap_samp); + bytes_cap = capture_size + cap_pos - old_cap_pos; } + uint32_t usb_bytes_cap; + usb_bytes_cap = capture_to_send_len(bytes_cap); + cap_pos = wpos + usb_bytes_cap; + if (cap_pos >= usb_send_size) { + cap_pos -= usb_send_size; + } + cap_samp = byte_to_samp_send(cap_pos); + } else { + cap_samp = -1; + } + + if (send_samp != -1 && cap_samp != -1) { + enum UAUD_SYNC_RET_T ret; + float ratio; + + ret = usb_audio_sync(cap_samp, send_samp, &capture_info, &ratio); + if (ret == UAUD_SYNC_START) { + usb_audio_tune_rate(AUD_STREAM_CAPTURE, ratio); + } + } else { + // TRACE(2,"send_hdlr: send_samp=0x%08x cap_samp=0x%08x", send_samp, + // cap_samp); + } } #ifdef USB_AUDIO_MULTIFUNC -static float playback_gain_to_float(uint32_t level) -{ - int32_t db; +static float playback_gain_to_float(uint32_t level) { + int32_t db; - if (level > MAX_VOLUME_VAL || level < MIN_VOLUME_VAL) { - return 0; - } + if (level > MAX_VOLUME_VAL || level < MIN_VOLUME_VAL) { + return 0; + } - db = codec_dac_vol[level].sdac_volume; - if (db <= USB_AUDIO_MIN_DBVAL) { - return 0; - } + db = codec_dac_vol[level].sdac_volume; + if (db <= USB_AUDIO_MIN_DBVAL) { + return 0; + } - return db_to_float(db); + return db_to_float(db); } -static void usb_audio_playback2_start(enum USB_AUDIO_ITF_CMD_T cmd) -{ - if (cmd == USB_AUDIO_ITF_STOP) { - // Stop the stream right now - if (recv2_state == AUDIO_ITF_STATE_STARTED) { - usb_audio_stop_recv2(); - if (recv_state == AUDIO_ITF_STATE_STOPPED && send_state == AUDIO_ITF_STATE_STOPPED) { - usb_audio_sync_reset(&playback_info); - } - recv2_state = AUDIO_ITF_STATE_STOPPED; - } - - if (recv_state == AUDIO_ITF_STATE_STARTED) { - return; - } - - enqueue_unique_cmd_with_opp(AUDIO_CMD_STOP_PLAY, usb_recv_seq, 0, AUDIO_CMD_START_PLAY); - } else { - if (recv2_state == AUDIO_ITF_STATE_STOPPED) { - int ret; - - reset_conflict(); - - if (recv_state == AUDIO_ITF_STATE_STOPPED && send_state == AUDIO_ITF_STATE_STOPPED) { - usb_audio_sync_reset(&playback_info); - } - - usb_recv2_valid = 0; - if (recv_state == AUDIO_ITF_STATE_STOPPED) { - usb_recv_seq++; - } - - usb_recv2_rpos = 0; - usb_recv2_wpos = usb_recv_size / 2; - zero_mem32(usb_recv2_buf, usb_recv2_size); - - usb_recv2_err_cnt = 0; - - ret = usb_audio_start_recv2(usb_recv2_buf, usb_recv2_wpos, usb_recv2_size); - if (ret == 1) { - TRACE(0,"usb_audio_start_recv2 failed: usb not configured"); - } else { - ASSERT(ret == 0, "usb_audio_start_recv2 failed: %d", ret); - } - recv2_state = AUDIO_ITF_STATE_STARTED; - } - - if (recv_state == AUDIO_ITF_STATE_STARTED) { - return; - } - - enqueue_unique_cmd_with_opp(AUDIO_CMD_START_PLAY, usb_recv_seq, 0, AUDIO_CMD_STOP_PLAY); +static void usb_audio_playback2_start(enum USB_AUDIO_ITF_CMD_T cmd) { + if (cmd == USB_AUDIO_ITF_STOP) { + // Stop the stream right now + if (recv2_state == AUDIO_ITF_STATE_STARTED) { + usb_audio_stop_recv2(); + if (recv_state == AUDIO_ITF_STATE_STOPPED && + send_state == AUDIO_ITF_STATE_STOPPED) { + usb_audio_sync_reset(&playback_info); + } + recv2_state = AUDIO_ITF_STATE_STOPPED; } + + if (recv_state == AUDIO_ITF_STATE_STARTED) { + return; + } + + enqueue_unique_cmd_with_opp(AUDIO_CMD_STOP_PLAY, usb_recv_seq, 0, + AUDIO_CMD_START_PLAY); + } else { + if (recv2_state == AUDIO_ITF_STATE_STOPPED) { + int ret; + + reset_conflict(); + + if (recv_state == AUDIO_ITF_STATE_STOPPED && + send_state == AUDIO_ITF_STATE_STOPPED) { + usb_audio_sync_reset(&playback_info); + } + + usb_recv2_valid = 0; + if (recv_state == AUDIO_ITF_STATE_STOPPED) { + usb_recv_seq++; + } + + usb_recv2_rpos = 0; + usb_recv2_wpos = usb_recv_size / 2; + zero_mem32(usb_recv2_buf, usb_recv2_size); + + usb_recv2_err_cnt = 0; + + ret = + usb_audio_start_recv2(usb_recv2_buf, usb_recv2_wpos, usb_recv2_size); + if (ret == 1) { + TRACE(0, "usb_audio_start_recv2 failed: usb not configured"); + } else { + ASSERT(ret == 0, "usb_audio_start_recv2 failed: %d", ret); + } + recv2_state = AUDIO_ITF_STATE_STARTED; + } + + if (recv_state == AUDIO_ITF_STATE_STARTED) { + return; + } + + enqueue_unique_cmd_with_opp(AUDIO_CMD_START_PLAY, usb_recv_seq, 0, + AUDIO_CMD_STOP_PLAY); + } } -static void usb_audio_mute2_control(uint32_t mute) -{ - TRACE(1,"MUTE2 CTRL: %u", mute); - - new_mute2_state = mute; - if (mute) { - new_playback2_coef = 0; - } else { - new_playback2_coef = playback_gain_to_float(new_playback2_vol); - } - usb_audio_enqueue_cmd(AUDIO_CMD_MUTE_CTRL); -} - -static void usb_audio_vol2_control(uint32_t percent) -{ - if (percent >= 100) { - new_playback2_vol = MAX_VOLUME_VAL; - } else { - new_playback2_vol = MIN_VOLUME_VAL + (percent * (MAX_VOLUME_VAL - MIN_VOLUME_VAL) + 50) / 100; - } +static void usb_audio_mute2_control(uint32_t mute) { + TRACE(1, "MUTE2 CTRL: %u", mute); + new_mute2_state = mute; + if (mute) { + new_playback2_coef = 0; + } else { new_playback2_coef = playback_gain_to_float(new_playback2_vol); - - TRACE(2,"VOL2 CTRL: percent=%u new_playback_vol=%u", percent, new_playback2_vol); + } + usb_audio_enqueue_cmd(AUDIO_CMD_MUTE_CTRL); } -static uint32_t usb_audio_get_vol2_percent(void) -{ - if (new_playback2_vol >= MAX_VOLUME_VAL) { - return 100; +static void usb_audio_vol2_control(uint32_t percent) { + if (percent >= 100) { + new_playback2_vol = MAX_VOLUME_VAL; + } else { + new_playback2_vol = + MIN_VOLUME_VAL + + (percent * (MAX_VOLUME_VAL - MIN_VOLUME_VAL) + 50) / 100; + } + + new_playback2_coef = playback_gain_to_float(new_playback2_vol); + + TRACE(2, "VOL2 CTRL: percent=%u new_playback_vol=%u", percent, + new_playback2_vol); +} + +static uint32_t usb_audio_get_vol2_percent(void) { + if (new_playback2_vol >= MAX_VOLUME_VAL) { + return 100; + } else { + return ((new_playback2_vol - MIN_VOLUME_VAL) * 100 + + (MAX_VOLUME_VAL - MIN_VOLUME_VAL) / 2) / + (MAX_VOLUME_VAL - MIN_VOLUME_VAL); + } +} + +static void +usb_audio_data_recv2_handler(const struct USB_AUDIO_XFER_INFO_T *info) { + const uint8_t *data; + uint32_t size; + uint32_t old_wpos, new_wpos, wpos_boundary, rpos; + uint32_t old_play_pos = 0; + uint32_t play_pos; + uint32_t lock; + int conflicted; + uint32_t recv_samp, play_samp; + uint32_t cur_time; + + cur_time = hal_sys_timer_get(); + last_usb_recv_time = cur_time; + + data = info->data; + size = info->size; + + if (info->cur_compl_err || info->next_xfer_err) { + if (usb_recv2_err_cnt == 0) { + usb_recv2_err_cnt++; + usb_recv2_ok_cnt = 0; + last_usb_recv2_err_time = cur_time; } else { - return ((new_playback2_vol - MIN_VOLUME_VAL) * 100 + (MAX_VOLUME_VAL - MIN_VOLUME_VAL) / 2) - / (MAX_VOLUME_VAL - MIN_VOLUME_VAL); + usb_recv2_err_cnt++; } -} - -static void usb_audio_data_recv2_handler(const struct USB_AUDIO_XFER_INFO_T *info) -{ - const uint8_t *data; - uint32_t size; - uint32_t old_wpos, new_wpos, wpos_boundary, rpos; - uint32_t old_play_pos = 0; - uint32_t play_pos; - uint32_t lock; - int conflicted; - uint32_t recv_samp, play_samp; - uint32_t cur_time; - - cur_time = hal_sys_timer_get(); - last_usb_recv_time = cur_time; - - data = info->data; - size = info->size; - + } else { + if (usb_recv2_err_cnt) { + usb_recv2_ok_cnt++; + } + } + if (usb_recv2_err_cnt && + cur_time - last_usb_recv2_err_time >= USB_XFER_ERR_REPORT_INTERVAL) { if (info->cur_compl_err || info->next_xfer_err) { - if (usb_recv2_err_cnt == 0) { - usb_recv2_err_cnt++; - usb_recv2_ok_cnt = 0; - last_usb_recv2_err_time = cur_time; - } else { - usb_recv2_err_cnt++; - } + TRACE(2, "recv2: ERROR: cur_err=%d next_err=%d", info->cur_compl_err, + info->next_xfer_err); + } + TRACE(3, "recv2: ERROR-CNT: err=%u ok=%u in %u ms", usb_recv2_err_cnt, + usb_recv2_ok_cnt, TICKS_TO_MS(USB_XFER_ERR_REPORT_INTERVAL)); + usb_recv2_err_cnt = 0; + } + + if (usb_recv2_buf <= data && data <= usb_recv2_buf + usb_recv2_size) { + if (data != usb_recv2_buf + usb_recv2_wpos) { + TRACE(3, + "recv2: WARNING: Invalid wpos=0x%x data=%p recv2_buf=%p. IRQ " + "missing?", + usb_recv2_wpos, data, usb_recv2_buf); + usb_recv2_wpos = data - usb_recv2_buf; + } + } + + old_wpos = usb_recv2_wpos; + new_wpos = old_wpos + size; + if (new_wpos >= usb_recv2_size) { + new_wpos -= usb_recv2_size; + } + + if (codec_config_lock || codec_play_seq != usb_recv_seq || + codec_play_valid == 0 || playback_state == AUDIO_ITF_STATE_STOPPED || + recv2_state == AUDIO_ITF_STATE_STOPPED || size == 0 || // rx paused + 0) { + usb_recv2_valid = 0; + } else { + if (info->cur_compl_err == 0) { + usb_recv2_valid = 1; + } + } + + if (usb_recv2_valid == 0 || usb_recv2_init_rpos == 0) { + usb_recv2_wpos = new_wpos; + return; + } + + conflicted = 0; + + lock = int_lock(); + if (playback_conflicted2) { + playback_conflicted2 = 0; + rpos = 0; // Avoid compiler warnings + conflicted = 1; + } else { + rpos = usb_recv2_rpos; + old_play_pos = playback_pos; + play_pos = af_stream_get_cur_dma_pos(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + } + int_unlock(lock); + + if (conflicted == 0) { + if (info->pool_enabled) { + // USBC will write to memory pool. + wpos_boundary = new_wpos; } else { - if (usb_recv2_err_cnt) { - usb_recv2_ok_cnt++; - } - } - if (usb_recv2_err_cnt && cur_time - last_usb_recv2_err_time >= USB_XFER_ERR_REPORT_INTERVAL) { - if (info->cur_compl_err || info->next_xfer_err) { - TRACE(2,"recv2: ERROR: cur_err=%d next_err=%d", info->cur_compl_err, info->next_xfer_err); - } - TRACE(3,"recv2: ERROR-CNT: err=%u ok=%u in %u ms", usb_recv2_err_cnt, usb_recv2_ok_cnt, TICKS_TO_MS(USB_XFER_ERR_REPORT_INTERVAL)); - usb_recv2_err_cnt = 0; + // USBC will write to new_wpos directly, so the buffer [new_wpos, new_wpos + // + info->next_size) must be protected too. + wpos_boundary = new_wpos + info->next_size; + if (wpos_boundary >= usb_recv2_size) { + wpos_boundary -= usb_recv2_size; + } } - if (usb_recv2_buf <= data && data <= usb_recv2_buf + usb_recv2_size) { - if (data != usb_recv2_buf + usb_recv2_wpos) { - TRACE(3,"recv2: WARNING: Invalid wpos=0x%x data=%p recv2_buf=%p. IRQ missing?", usb_recv2_wpos, data, usb_recv2_buf); - usb_recv2_wpos = data - usb_recv2_buf; - } - } - - old_wpos = usb_recv2_wpos; - new_wpos = old_wpos + size; - if (new_wpos >= usb_recv2_size) { - new_wpos -= usb_recv2_size; - } - - if (codec_config_lock || - codec_play_seq != usb_recv_seq || - codec_play_valid == 0 || - playback_state == AUDIO_ITF_STATE_STOPPED || - recv2_state == AUDIO_ITF_STATE_STOPPED || - size == 0 || // rx paused - 0) { - usb_recv2_valid = 0; - } else { - if (info->cur_compl_err == 0) { - usb_recv2_valid = 1; - } - } - - if (usb_recv2_valid == 0 || usb_recv2_init_rpos == 0) { - usb_recv2_wpos = new_wpos; - return; - } - - conflicted = 0; - - lock = int_lock(); - if (playback_conflicted2) { - playback_conflicted2 = 0; - rpos = 0; // Avoid compiler warnings + if (old_wpos <= rpos) { + if (wpos_boundary < old_wpos || rpos < wpos_boundary) { conflicted = 1; + } } else { - rpos = usb_recv2_rpos; - old_play_pos = playback_pos; - play_pos = af_stream_get_cur_dma_pos(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + if (rpos < wpos_boundary && wpos_boundary < old_wpos) { + conflicted = 1; + } } - int_unlock(lock); - if (conflicted == 0) { - if (info->pool_enabled) { - // USBC will write to memory pool. - wpos_boundary = new_wpos; - } else { - // USBC will write to new_wpos directly, so the buffer [new_wpos, new_wpos + info->next_size) must be protected too. - wpos_boundary = new_wpos + info->next_size; - if (wpos_boundary >= usb_recv2_size) { - wpos_boundary -= usb_recv2_size; - } - } + if (conflicted) { + uint32_t reset_len = usb_recv2_size / 2; + uint32_t saved_old_wpos = old_wpos; - if (old_wpos <= rpos) { - if (wpos_boundary < old_wpos || rpos < wpos_boundary) { - conflicted = 1; - } - } else { - if (rpos < wpos_boundary && wpos_boundary < old_wpos) { - conflicted = 1; - } - } - - if (conflicted) { - uint32_t reset_len = usb_recv2_size / 2; - uint32_t saved_old_wpos = old_wpos; - - // Reset read position - old_wpos = rpos + reset_len; - if (old_wpos >= usb_recv2_size) { - old_wpos -= usb_recv2_size; - } - new_wpos = old_wpos + size; - if (new_wpos >= usb_recv2_size) { - new_wpos -= usb_recv2_size; - } + // Reset read position + old_wpos = rpos + reset_len; + if (old_wpos >= usb_recv2_size) { + old_wpos -= usb_recv2_size; + } + new_wpos = old_wpos + size; + if (new_wpos >= usb_recv2_size) { + new_wpos -= usb_recv2_size; + } #if 0 usb_audio_stop_recv(); usb_audio_start_recv(usb_recv2_buf, new_wpos, usb_recv2_size); #else - usb_audio_set_recv2_pos(new_wpos); + usb_audio_set_recv2_pos(new_wpos); #endif - TRACE(4,"recv2: Error: wpos=%u goes beyond rpos=%u with len=%u. Reset to %u", saved_old_wpos, rpos, size, old_wpos); - } - record_conflict(conflicted); + TRACE( + 4, + "recv2: Error: wpos=%u goes beyond rpos=%u with len=%u. Reset to %u", + saved_old_wpos, rpos, size, old_wpos); } + record_conflict(conflicted); + } - usb_recv2_wpos = new_wpos; + usb_recv2_wpos = new_wpos; #if (VERBOSE_TRACE & (1 << 5)) - { - int hw_play_pos = af_stream_get_cur_dma_pos(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); - TRACE_TIME(5,"recv2: wpos=%u size=%u rpos=%u playback_pos=%u hw_play_pos=%d", old_wpos, size, - rpos, playback_pos, hw_play_pos); - } + { + int hw_play_pos = + af_stream_get_cur_dma_pos(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK); + TRACE_TIME(5, + "recv2: wpos=%u size=%u rpos=%u playback_pos=%u hw_play_pos=%d", + old_wpos, size, rpos, playback_pos, hw_play_pos); + } #endif - if (conflicted) { - usb_audio_sync_reset(&playback_info); - return; - } + if (conflicted) { + usb_audio_sync_reset(&playback_info); + return; + } - // Recv and send takes precedence - if (recv_state == AUDIO_ITF_STATE_STARTED || send_state == AUDIO_ITF_STATE_STARTED) { - return; - } + // Recv and send takes precedence + if (recv_state == AUDIO_ITF_STATE_STARTED || + send_state == AUDIO_ITF_STATE_STARTED) { + return; + } - if (usb_recv2_buf <= data && data <= usb_recv2_buf + usb_recv2_size) { - recv_samp = byte_to_samp_recv(new_wpos); + if (usb_recv2_buf <= data && data <= usb_recv2_buf + usb_recv2_size) { + recv_samp = byte_to_samp_recv(new_wpos); + } else { + recv_samp = -1; + } + + if ((int)play_pos >= 0) { + if (play_pos >= playback_size) { + play_pos = 0; + } + // Count the bytes of data waiting to play in the codec buffer + uint32_t bytes_to_play; + if (old_play_pos <= play_pos) { + bytes_to_play = playback_size + old_play_pos - play_pos; } else { - recv_samp = -1; + bytes_to_play = old_play_pos - play_pos; } - - if ((int)play_pos >= 0) { - if (play_pos >= playback_size) { - play_pos = 0; - } - // Count the bytes of data waiting to play in the codec buffer - uint32_t bytes_to_play; - if (old_play_pos <= play_pos) { - bytes_to_play = playback_size + old_play_pos - play_pos; - } else { - bytes_to_play = old_play_pos - play_pos; - } - uint32_t usb_bytes_to_play; - usb_bytes_to_play = playback_to_recv_len(bytes_to_play); - if (rpos >= usb_bytes_to_play) { - play_pos = rpos - usb_bytes_to_play; - } else { - play_pos = usb_recv2_size + rpos - usb_bytes_to_play; - } - play_samp = byte_to_samp_recv(play_pos); + uint32_t usb_bytes_to_play; + usb_bytes_to_play = playback_to_recv_len(bytes_to_play); + if (rpos >= usb_bytes_to_play) { + play_pos = rpos - usb_bytes_to_play; } else { - play_samp = -1; + play_pos = usb_recv2_size + rpos - usb_bytes_to_play; } + play_samp = byte_to_samp_recv(play_pos); + } else { + play_samp = -1; + } - if (recv_samp != -1 && play_samp != -1) { - enum UAUD_SYNC_RET_T ret; - float ratio; + if (recv_samp != -1 && play_samp != -1) { + enum UAUD_SYNC_RET_T ret; + float ratio; - ret = usb_audio_sync(play_samp, recv_samp, &playback_info, &ratio); - if (ret == UAUD_SYNC_START) { - usb_audio_tune_rate(AUD_STREAM_PLAYBACK, ratio); - } - } else { - //TRACE(2,"recv_hdlr: recv_samp=0x%08x play_samp=0x%08x", recv_samp, play_samp); + ret = usb_audio_sync(play_samp, recv_samp, &playback_info, &ratio); + if (ret == UAUD_SYNC_START) { + usb_audio_tune_rate(AUD_STREAM_PLAYBACK, ratio); } + } else { + // TRACE(2,"recv_hdlr: recv_samp=0x%08x play_samp=0x%08x", recv_samp, + // play_samp); + } } #endif -static void usb_audio_reset_usb_stream_state(bool init) -{ - if (init) { - recv_state = AUDIO_ITF_STATE_STOPPED; - send_state = AUDIO_ITF_STATE_STOPPED; +static void usb_audio_reset_usb_stream_state(bool init) { + if (init) { + recv_state = AUDIO_ITF_STATE_STOPPED; + send_state = AUDIO_ITF_STATE_STOPPED; #ifdef USB_AUDIO_DYN_CFG - // Reset itf setting - playback_itf_set = 0; - capture_itf_set = 0; + // Reset itf setting + playback_itf_set = 0; + capture_itf_set = 0; #endif - // Reset mute and volume setting - new_mute_state = 0; - new_cap_mute_state = 0; + // Reset mute and volume setting + new_mute_state = 0; + new_cap_mute_state = 0; - new_playback_vol = AUDIO_OUTPUT_VOLUME_DEFAULT; - if (new_playback_vol > MAX_VOLUME_VAL) { - new_playback_vol = MAX_VOLUME_VAL; - } else if (new_playback_vol < MIN_VOLUME_VAL) { - new_playback_vol = MIN_VOLUME_VAL; - } - - new_capture_vol = CODEC_SADC_VOL; - if (new_capture_vol > MAX_CAP_VOLUME_VAL) { - new_capture_vol = MAX_CAP_VOLUME_VAL; - } else if (new_capture_vol < MIN_CAP_VOLUME_VAL) { - new_capture_vol = MIN_CAP_VOLUME_VAL; - } - -#ifdef USB_AUDIO_MULTIFUNC - new_playback_coef = playback_gain_to_float(new_playback_vol); - playback_coef = new_playback_coef; - - recv2_state = AUDIO_ITF_STATE_STOPPED; - new_mute2_state = 0; - new_playback2_vol = AUDIO_OUTPUT_VOLUME_DEFAULT; - if (new_playback2_vol > MAX_VOLUME_VAL) { - new_playback2_vol = MAX_VOLUME_VAL; - } else if (new_playback2_vol < MIN_VOLUME_VAL) { - new_playback2_vol = MIN_VOLUME_VAL; - } - new_playback2_coef = playback_gain_to_float(new_playback2_vol); - playback2_coef = new_playback2_coef; -#endif - } else { - if (recv_state == AUDIO_ITF_STATE_STARTED) { - usb_audio_stop_usb_stream(AUD_STREAM_PLAYBACK); - recv_state = AUDIO_ITF_STATE_STOPPED; - } - if (send_state == AUDIO_ITF_STATE_STARTED) { - usb_audio_stop_usb_stream(AUD_STREAM_CAPTURE); - send_state = AUDIO_ITF_STATE_STOPPED; - } - -#ifdef USB_AUDIO_MULTIFUNC - if (recv2_state == AUDIO_ITF_STATE_STARTED) { - usb_audio_stop_recv2(); - if (recv_state == AUDIO_ITF_STATE_STOPPED && send_state == AUDIO_ITF_STATE_STOPPED) { - usb_audio_sync_reset(&playback_info); - } - recv2_state = AUDIO_ITF_STATE_STOPPED; - } -#endif - - // Keep old itf setting unless it is in init mode - - // Keep old mute and playback volume setting unless it is in init mode + new_playback_vol = AUDIO_OUTPUT_VOLUME_DEFAULT; + if (new_playback_vol > MAX_VOLUME_VAL) { + new_playback_vol = MAX_VOLUME_VAL; + } else if (new_playback_vol < MIN_VOLUME_VAL) { + new_playback_vol = MIN_VOLUME_VAL; } + + new_capture_vol = CODEC_SADC_VOL; + if (new_capture_vol > MAX_CAP_VOLUME_VAL) { + new_capture_vol = MAX_CAP_VOLUME_VAL; + } else if (new_capture_vol < MIN_CAP_VOLUME_VAL) { + new_capture_vol = MIN_CAP_VOLUME_VAL; + } + +#ifdef USB_AUDIO_MULTIFUNC + new_playback_coef = playback_gain_to_float(new_playback_vol); + playback_coef = new_playback_coef; + + recv2_state = AUDIO_ITF_STATE_STOPPED; + new_mute2_state = 0; + new_playback2_vol = AUDIO_OUTPUT_VOLUME_DEFAULT; + if (new_playback2_vol > MAX_VOLUME_VAL) { + new_playback2_vol = MAX_VOLUME_VAL; + } else if (new_playback2_vol < MIN_VOLUME_VAL) { + new_playback2_vol = MIN_VOLUME_VAL; + } + new_playback2_coef = playback_gain_to_float(new_playback2_vol); + playback2_coef = new_playback2_coef; +#endif + } else { + if (recv_state == AUDIO_ITF_STATE_STARTED) { + usb_audio_stop_usb_stream(AUD_STREAM_PLAYBACK); + recv_state = AUDIO_ITF_STATE_STOPPED; + } + if (send_state == AUDIO_ITF_STATE_STARTED) { + usb_audio_stop_usb_stream(AUD_STREAM_CAPTURE); + send_state = AUDIO_ITF_STATE_STOPPED; + } + +#ifdef USB_AUDIO_MULTIFUNC + if (recv2_state == AUDIO_ITF_STATE_STARTED) { + usb_audio_stop_recv2(); + if (recv_state == AUDIO_ITF_STATE_STOPPED && + send_state == AUDIO_ITF_STATE_STOPPED) { + usb_audio_sync_reset(&playback_info); + } + recv2_state = AUDIO_ITF_STATE_STOPPED; + } +#endif + + // Keep old itf setting unless it is in init mode + + // Keep old mute and playback volume setting unless it is in init mode + } } -static void usb_audio_reset_codec_stream_state(bool init) -{ - playback_state = AUDIO_ITF_STATE_STOPPED; - capture_state = AUDIO_ITF_STATE_STOPPED; +static void usb_audio_reset_codec_stream_state(bool init) { + playback_state = AUDIO_ITF_STATE_STOPPED; + capture_state = AUDIO_ITF_STATE_STOPPED; #ifndef USB_AUDIO_MULTIFUNC - playback_vol = new_playback_vol; + playback_vol = new_playback_vol; #endif - capture_vol = new_capture_vol; + capture_vol = new_capture_vol; - playback_paused = 0; + playback_paused = 0; - playback_conflicted = 0; + playback_conflicted = 0; #ifdef USB_AUDIO_MULTIFUNC - playback_conflicted2 = 0; + playback_conflicted2 = 0; #endif - capture_conflicted = 0; + capture_conflicted = 0; - // Keep old mute setting unless it is in init mode - if (init) { + // Keep old mute setting unless it is in init mode + if (init) { #ifdef PERF_TEST_POWER_KEY - perft_power_type = 0; - af_codec_set_perf_test_power(perft_power_type); + perft_power_type = 0; + af_codec_set_perf_test_power(perft_power_type); #endif #ifdef PA_ON_OFF_KEY - if (pa_on_off_muted) { - pa_on_off_muted = false; - if (mute_user_map == 0) { - usb_audio_codec_unmute(CODEC_MUTE_USER_ALL); - } - } + if (pa_on_off_muted) { + pa_on_off_muted = false; + if (mute_user_map == 0) { + usb_audio_codec_unmute(CODEC_MUTE_USER_ALL); + } + } #endif - if (mute_user_map) { - mute_user_map = 0; - usb_audio_codec_unmute(CODEC_MUTE_USER_ALL); - } + if (mute_user_map) { + mute_user_map = 0; + usb_audio_codec_unmute(CODEC_MUTE_USER_ALL); + } #if defined(NOISE_GATING) && defined(NOISE_REDUCTION) - restore_noise_reduction_status(); + restore_noise_reduction_status(); #endif - } + } } #ifdef USB_AUDIO_DYN_CFG -static void usb_audio_set_recv_rate(enum AUD_SAMPRATE_T rate) -{ +static void usb_audio_set_recv_rate(enum AUD_SAMPRATE_T rate) { #ifndef USB_AUDIO_UAC2 - if (playback_itf_set == 0) { - TRACE(1,"\nWARNING: Set recv rate while itf not set: %d\n", rate); - return; - } + if (playback_itf_set == 0) { + TRACE(1, "\nWARNING: Set recv rate while itf not set: %d\n", rate); + return; + } #endif - // Some host applications will not stop current stream before changing sample rate - if (recv_state == AUDIO_ITF_STATE_STARTED) { - usb_audio_stop_usb_stream(AUD_STREAM_PLAYBACK); - recv_state = AUDIO_ITF_STATE_STOPPED; - } + // Some host applications will not stop current stream before changing sample + // rate + if (recv_state == AUDIO_ITF_STATE_STARTED) { + usb_audio_stop_usb_stream(AUD_STREAM_PLAYBACK); + recv_state = AUDIO_ITF_STATE_STOPPED; + } - TRACE(3,"%s: Change recv sample rate from %u to %u", __FUNCTION__, sample_rate_recv, rate); + TRACE(3, "%s: Change recv sample rate from %u to %u", __FUNCTION__, + sample_rate_recv, rate); - new_sample_rate_recv = rate; + new_sample_rate_recv = rate; #ifdef KEEP_SAME_LATENCY - usb_recv_size = calc_usb_recv_size(new_sample_rate_recv, new_sample_size_recv); - TRACE(2,"%s: Set usb_recv_size=%u", __FUNCTION__, usb_recv_size); + usb_recv_size = + calc_usb_recv_size(new_sample_rate_recv, new_sample_size_recv); + TRACE(2, "%s: Set usb_recv_size=%u", __FUNCTION__, usb_recv_size); #endif - if (playback_itf_set) { - usb_audio_start_usb_stream(AUD_STREAM_PLAYBACK); - recv_state = AUDIO_ITF_STATE_STARTED; - } + if (playback_itf_set) { + usb_audio_start_usb_stream(AUD_STREAM_PLAYBACK); + recv_state = AUDIO_ITF_STATE_STARTED; + } #ifdef USB_AUDIO_UAC2 - enqueue_unique_cmd_arg(AUDIO_CMD_SET_RECV_RATE, usb_recv_seq, 0); + enqueue_unique_cmd_arg(AUDIO_CMD_SET_RECV_RATE, usb_recv_seq, 0); #else - enqueue_unique_cmd_with_opp(AUDIO_CMD_SET_RECV_RATE, usb_recv_seq, 0, AUDIO_CMD_STOP_PLAY); + enqueue_unique_cmd_with_opp(AUDIO_CMD_SET_RECV_RATE, usb_recv_seq, 0, + AUDIO_CMD_STOP_PLAY); #endif } -static void usb_audio_set_send_rate(enum AUD_SAMPRATE_T rate) -{ +static void usb_audio_set_send_rate(enum AUD_SAMPRATE_T rate) { #ifndef USB_AUDIO_UAC2 - if (capture_itf_set == 0) { - TRACE(1,"\nWARNING: Set send rate while itf not set: %d\n", rate); - return; - } + if (capture_itf_set == 0) { + TRACE(1, "\nWARNING: Set send rate while itf not set: %d\n", rate); + return; + } #endif - // Some host applications will not stop current stream before changing sample rate - if (send_state == AUDIO_ITF_STATE_STARTED) { - usb_audio_stop_usb_stream(AUD_STREAM_CAPTURE); - send_state = AUDIO_ITF_STATE_STOPPED; - } + // Some host applications will not stop current stream before changing sample + // rate + if (send_state == AUDIO_ITF_STATE_STARTED) { + usb_audio_stop_usb_stream(AUD_STREAM_CAPTURE); + send_state = AUDIO_ITF_STATE_STOPPED; + } - TRACE(3,"%s: Change send sample rate from %u to %u", __FUNCTION__, sample_rate_send, rate); + TRACE(3, "%s: Change send sample rate from %u to %u", __FUNCTION__, + sample_rate_send, rate); - new_sample_rate_send = rate; + new_sample_rate_send = rate; #ifdef KEEP_SAME_LATENCY - usb_send_size = calc_usb_send_size(new_sample_rate_send); - TRACE(2,"%s: Set usb_send_size=%u", __FUNCTION__, usb_send_size); + usb_send_size = calc_usb_send_size(new_sample_rate_send); + TRACE(2, "%s: Set usb_send_size=%u", __FUNCTION__, usb_send_size); #endif - if (capture_itf_set) { - usb_audio_start_usb_stream(AUD_STREAM_CAPTURE); - send_state = AUDIO_ITF_STATE_STARTED; - } + if (capture_itf_set) { + usb_audio_start_usb_stream(AUD_STREAM_CAPTURE); + send_state = AUDIO_ITF_STATE_STARTED; + } #ifdef USB_AUDIO_UAC2 - enqueue_unique_cmd_arg(AUDIO_CMD_SET_SEND_RATE, usb_send_seq, 0); + enqueue_unique_cmd_arg(AUDIO_CMD_SET_SEND_RATE, usb_send_seq, 0); #else - enqueue_unique_cmd_with_opp(AUDIO_CMD_SET_SEND_RATE, usb_send_seq, 0, AUDIO_CMD_STOP_CAPTURE); + enqueue_unique_cmd_with_opp(AUDIO_CMD_SET_SEND_RATE, usb_send_seq, 0, + AUDIO_CMD_STOP_CAPTURE); #endif } #endif -static void usb_audio_state_control(enum USB_AUDIO_STATE_EVENT_T event, uint32_t param) -{ - TRACE(3,"%s: %d (%u)", __FUNCTION__, event, param); +static void usb_audio_state_control(enum USB_AUDIO_STATE_EVENT_T event, + uint32_t param) { + TRACE(3, "%s: %d (%u)", __FUNCTION__, event, param); - if (event == USB_AUDIO_STATE_RESET || event == USB_AUDIO_STATE_DISCONNECT || event == USB_AUDIO_STATE_CONFIG) { - usb_audio_reset_usb_stream_state(true); - } else if (event == USB_AUDIO_STATE_SLEEP || event == USB_AUDIO_STATE_WAKEUP) { - usb_audio_reset_usb_stream_state(false); - } + if (event == USB_AUDIO_STATE_RESET || event == USB_AUDIO_STATE_DISCONNECT || + event == USB_AUDIO_STATE_CONFIG) { + usb_audio_reset_usb_stream_state(true); + } else if (event == USB_AUDIO_STATE_SLEEP || + event == USB_AUDIO_STATE_WAKEUP) { + usb_audio_reset_usb_stream_state(false); + } - if (event == USB_AUDIO_STATE_RESET) { - usb_audio_enqueue_cmd(AUDIO_CMD_USB_RESET); - } else if (event == USB_AUDIO_STATE_DISCONNECT) { - usb_audio_enqueue_cmd(AUDIO_CMD_USB_DISCONNECT); - } else if (event == USB_AUDIO_STATE_CONFIG) { - usb_audio_enqueue_cmd(AUDIO_CMD_USB_CONFIG); - } else if (event == USB_AUDIO_STATE_SLEEP) { - usb_audio_enqueue_cmd(AUDIO_CMD_USB_SLEEP); - } else if (event == USB_AUDIO_STATE_WAKEUP) { - usb_audio_enqueue_cmd(AUDIO_CMD_USB_WAKEUP); - } else if (event == USB_AUDIO_STATE_RECV_PAUSE || event == USB_AUDIO_STATE_RECV2_PAUSE) { + if (event == USB_AUDIO_STATE_RESET) { + usb_audio_enqueue_cmd(AUDIO_CMD_USB_RESET); + } else if (event == USB_AUDIO_STATE_DISCONNECT) { + usb_audio_enqueue_cmd(AUDIO_CMD_USB_DISCONNECT); + } else if (event == USB_AUDIO_STATE_CONFIG) { + usb_audio_enqueue_cmd(AUDIO_CMD_USB_CONFIG); + } else if (event == USB_AUDIO_STATE_SLEEP) { + usb_audio_enqueue_cmd(AUDIO_CMD_USB_SLEEP); + } else if (event == USB_AUDIO_STATE_WAKEUP) { + usb_audio_enqueue_cmd(AUDIO_CMD_USB_WAKEUP); + } else if (event == USB_AUDIO_STATE_RECV_PAUSE || + event == USB_AUDIO_STATE_RECV2_PAUSE) { #ifndef USB_AUDIO_MULTIFUNC - enqueue_unique_cmd_with_opp(AUDIO_CMD_RECV_PAUSE, usb_recv_seq, 0, AUDIO_CMD_RECV_CONTINUE); + enqueue_unique_cmd_with_opp(AUDIO_CMD_RECV_PAUSE, usb_recv_seq, 0, + AUDIO_CMD_RECV_CONTINUE); #endif - } else if (event == USB_AUDIO_STATE_RECV_CONTINUE || event == USB_AUDIO_STATE_RECV2_CONTINUE) { + } else if (event == USB_AUDIO_STATE_RECV_CONTINUE || + event == USB_AUDIO_STATE_RECV2_CONTINUE) { #ifndef USB_AUDIO_MULTIFUNC - enqueue_unique_cmd_with_opp(AUDIO_CMD_RECV_CONTINUE, usb_recv_seq, 0, AUDIO_CMD_RECV_PAUSE); + enqueue_unique_cmd_with_opp(AUDIO_CMD_RECV_CONTINUE, usb_recv_seq, 0, + AUDIO_CMD_RECV_PAUSE); #endif #ifdef USB_AUDIO_DYN_CFG - } else if (event == USB_AUDIO_STATE_SET_RECV_RATE) { - usb_audio_set_recv_rate(param); - } else if (event == USB_AUDIO_STATE_SET_SEND_RATE) { - usb_audio_set_send_rate(param); + } else if (event == USB_AUDIO_STATE_SET_RECV_RATE) { + usb_audio_set_recv_rate(param); + } else if (event == USB_AUDIO_STATE_SET_SEND_RATE) { + usb_audio_set_send_rate(param); #endif - } else { - ASSERT(false, "Bad state event"); - } + } else { + ASSERT(false, "Bad state event"); + } } -static void usb_audio_acquire_freq(void) -{ - enum HAL_CMU_FREQ_T freq; +static void usb_audio_acquire_freq(void) { + enum HAL_CMU_FREQ_T freq; #if defined(CHIP_BEST1000) && defined(_DUAL_AUX_MIC_) #ifdef SW_CAPTURE_RESAMPLE - if (resample_cap_enabled) { - freq = HAL_CMU_FREQ_104M; - } else + if (resample_cap_enabled) { + freq = HAL_CMU_FREQ_104M; + } else #endif - if (capture_state == AUDIO_ITF_STATE_STARTED) { + if (capture_state == AUDIO_ITF_STATE_STARTED) { #ifdef DUAL_AUX_MIC_MORE_FILTER - freq = HAL_CMU_FREQ_104M; + freq = HAL_CMU_FREQ_104M; #else - freq = HAL_CMU_FREQ_78M; + freq = HAL_CMU_FREQ_78M; #endif - } else + } else #else // !(CHIP_BEST1000 && _DUAL_AUX_MIC_) #ifdef SW_CAPTURE_RESAMPLE - if (resample_cap_enabled) { + if (resample_cap_enabled) { #ifdef CHIP_BEST1000 - freq = HAL_CMU_FREQ_78M; + freq = HAL_CMU_FREQ_78M; #else - freq = HAL_CMU_FREQ_52M; + freq = HAL_CMU_FREQ_52M; #endif - } else + } else #endif #endif // !(CHIP_BEST1000 && _DUAL_AUX_MIC_) - { - freq = HAL_CMU_FREQ_52M; - } + { + freq = HAL_CMU_FREQ_52M; + } #if defined(USB_HIGH_SPEED) && defined(USB_AUDIO_UAC2) - if (playback_state == AUDIO_ITF_STATE_STARTED && sample_rate_play >= AUD_SAMPRATE_352800) { - if (freq < HAL_CMU_FREQ_104M) { - freq = HAL_CMU_FREQ_104M; - } + if (playback_state == AUDIO_ITF_STATE_STARTED && + sample_rate_play >= AUD_SAMPRATE_352800) { + if (freq < HAL_CMU_FREQ_104M) { + freq = HAL_CMU_FREQ_104M; } + } #endif #ifdef AUDIO_ANC_FB_MC - if (freq < HAL_CMU_FREQ_104M) { - freq = HAL_CMU_FREQ_104M; - } + if (freq < HAL_CMU_FREQ_104M) { + freq = HAL_CMU_FREQ_104M; + } #endif #ifdef __HW_FIR_DSD_PROCESS__ - if (freq < HAL_CMU_FREQ_104M) { - freq = HAL_CMU_FREQ_104M; - } + if (freq < HAL_CMU_FREQ_104M) { + freq = HAL_CMU_FREQ_104M; + } #endif #ifdef USB_AUDIO_SPEECH - enum HAL_CMU_FREQ_T speech_freq; + enum HAL_CMU_FREQ_T speech_freq; - speech_freq = speech_process_need_freq(); - if (freq < speech_freq) { - freq = speech_freq; - } + speech_freq = speech_process_need_freq(); + if (freq < speech_freq) { + freq = speech_freq; + } #endif - hal_sysfreq_req(HAL_SYSFREQ_USER_APP_2, freq); - //TRACE(2,"[%s] app_sysfreq_req %d", __FUNCTION__, freq); - //TRACE(2,"[%s] sys freq calc : %d\n", __FUNCTION__, hal_sys_timer_calc_cpu_freq(5, 0)); + hal_sysfreq_req(HAL_SYSFREQ_USER_APP_2, freq); + // TRACE(2,"[%s] app_sysfreq_req %d", __FUNCTION__, freq); + // TRACE(2,"[%s] sys freq calc : %d\n", __FUNCTION__, + // hal_sys_timer_calc_cpu_freq(5, 0)); } -static void usb_audio_release_freq(void) -{ - hal_sysfreq_req(HAL_SYSFREQ_USER_APP_2, HAL_CMU_FREQ_32K); +static void usb_audio_release_freq(void) { + hal_sysfreq_req(HAL_SYSFREQ_USER_APP_2, HAL_CMU_FREQ_32K); } -static void usb_audio_update_freq(void) -{ - usb_audio_acquire_freq(); -} +static void usb_audio_update_freq(void) { usb_audio_acquire_freq(); } #ifdef SW_CAPTURE_RESAMPLE -static enum AUD_CHANNEL_NUM_T get_capture_resample_chan_num(void) -{ +static enum AUD_CHANNEL_NUM_T get_capture_resample_chan_num(void) { #if (CHAN_NUM_CAPTURE == CHAN_NUM_SEND) - return chan_num_to_enum(CHAN_NUM_CAPTURE); + return chan_num_to_enum(CHAN_NUM_CAPTURE); #else - return AUD_CHANNEL_NUM_1; + return AUD_CHANNEL_NUM_1; #endif } -static void capture_stream_resample_config(void) -{ - struct RESAMPLE_CFG_T cfg; - enum RESAMPLE_STATUS_T ret; - enum AUD_SAMPRATE_T cap_rate; +static void capture_stream_resample_config(void) { + struct RESAMPLE_CFG_T cfg; + enum RESAMPLE_STATUS_T ret; + enum AUD_SAMPRATE_T cap_rate; #if defined(CHIP_BEST1000) && (defined(ANC_APP) || defined(_DUAL_AUX_MIC_)) - cap_rate = sample_rate_ref_cap; + cap_rate = sample_rate_ref_cap; #else - cap_rate = sample_rate_cap; + cap_rate = sample_rate_cap; #endif #ifndef __AUDIO_RESAMPLE__ - if (cap_rate == sample_rate_send) { - if (resample_cap_enabled) { - TRACE(1,"!!! %s: Disable capture resample", __FUNCTION__); + if (cap_rate == sample_rate_send) { + if (resample_cap_enabled) { + TRACE(1, "!!! %s: Disable capture resample", __FUNCTION__); - audio_resample_ex_close(resample_id); - resample_cap_enabled = false; - } - } else + audio_resample_ex_close(resample_id); + resample_cap_enabled = false; + } + } else #endif - { - if (!resample_cap_enabled) { - // Resample chan num is usb send chan num - memset(&cfg, 0, sizeof(cfg)); - cfg.chans = get_capture_resample_chan_num(); - cfg.bits = sample_size_to_enum_capture(sample_size_cap); + { + if (!resample_cap_enabled) { + // Resample chan num is usb send chan num + memset(&cfg, 0, sizeof(cfg)); + cfg.chans = get_capture_resample_chan_num(); + cfg.bits = sample_size_to_enum_capture(sample_size_cap); #ifdef __AUDIO_RESAMPLE__ - if (sample_rate_send % AUD_SAMPRATE_8000) { - ASSERT(hal_cmu_get_crystal_freq() / (CODEC_FREQ_44_1K_SERIES / sample_rate_send) == cap_rate, - "%s: Bad cap_rate=%u with sample_rate_send=%u", __FUNCTION__, cap_rate, sample_rate_send); + if (sample_rate_send % AUD_SAMPRATE_8000) { + ASSERT(hal_cmu_get_crystal_freq() / + (CODEC_FREQ_44_1K_SERIES / sample_rate_send) == + cap_rate, + "%s: Bad cap_rate=%u with sample_rate_send=%u", __FUNCTION__, + cap_rate, sample_rate_send); #if (CODEC_FREQ_26M / CODEC_FREQ_CRYSTAL * CODEC_FREQ_CRYSTAL == CODEC_FREQ_26M) - cfg.coef = &resample_coef_50p7k_to_44p1k; + cfg.coef = &resample_coef_50p7k_to_44p1k; #else - cfg.coef = &resample_coef_46p8k_to_44p1k; + cfg.coef = &resample_coef_46p8k_to_44p1k; #endif - } else { - ASSERT(hal_cmu_get_crystal_freq() / (CODEC_FREQ_48K_SERIES / sample_rate_send) == cap_rate, - "%s: Bad cap_rate=%u with sample_rate_send=%u", __FUNCTION__, cap_rate, sample_rate_send); + } else { + ASSERT(hal_cmu_get_crystal_freq() / + (CODEC_FREQ_48K_SERIES / sample_rate_send) == + cap_rate, + "%s: Bad cap_rate=%u with sample_rate_send=%u", __FUNCTION__, + cap_rate, sample_rate_send); #if (CODEC_FREQ_26M / CODEC_FREQ_CRYSTAL * CODEC_FREQ_CRYSTAL == CODEC_FREQ_26M) - cfg.coef = &resample_coef_50p7k_to_48k; + cfg.coef = &resample_coef_50p7k_to_48k; #else - cfg.coef = &resample_coef_46p8k_to_48k; + cfg.coef = &resample_coef_46p8k_to_48k; #endif - } + } #else - if (sample_rate_send % AUD_SAMPRATE_8000) { - ASSERT(CODEC_FREQ_48K_SERIES / (CODEC_FREQ_44_1K_SERIES / sample_rate_send) == cap_rate, - "%s: Bad cap_rate=%u with sample_rate_send=%u", __FUNCTION__, cap_rate, sample_rate_send); - cfg.coef = &resample_coef_48k_to_44p1k; - } else { - ASSERT(CODEC_FREQ_44_1K_SERIES / (CODEC_FREQ_48K_SERIES / sample_rate_send) == cap_rate, - "%s: Bad cap_rate=%u with sample_rate_send=%u", __FUNCTION__, cap_rate, sample_rate_send); - cfg.coef = &resample_coef_44p1k_to_48k; - } + if (sample_rate_send % AUD_SAMPRATE_8000) { + ASSERT(CODEC_FREQ_48K_SERIES / + (CODEC_FREQ_44_1K_SERIES / sample_rate_send) == + cap_rate, + "%s: Bad cap_rate=%u with sample_rate_send=%u", __FUNCTION__, + cap_rate, sample_rate_send); + cfg.coef = &resample_coef_48k_to_44p1k; + } else { + ASSERT(CODEC_FREQ_44_1K_SERIES / + (CODEC_FREQ_48K_SERIES / sample_rate_send) == + cap_rate, + "%s: Bad cap_rate=%u with sample_rate_send=%u", __FUNCTION__, + cap_rate, sample_rate_send); + cfg.coef = &resample_coef_44p1k_to_48k; + } #endif - cfg.buf = resample_history_buf; - cfg.size = resample_history_size; + cfg.buf = resample_history_buf; + cfg.size = resample_history_size; - TRACE(3,"!!! %s: Enable capture resample %u => %u", __FUNCTION__, cap_rate, sample_rate_send); + TRACE(3, "!!! %s: Enable capture resample %u => %u", __FUNCTION__, + cap_rate, sample_rate_send); - ret = audio_resample_ex_open(&cfg, &resample_id); - ASSERT(ret == RESAMPLE_STATUS_OK, "%s: Failed to init resample: %d", __FUNCTION__, ret); + ret = audio_resample_ex_open(&cfg, &resample_id); + ASSERT(ret == RESAMPLE_STATUS_OK, "%s: Failed to init resample: %d", + __FUNCTION__, ret); - resample_cap_enabled = true; - } + resample_cap_enabled = true; } + } } #endif -static void usb_audio_init_streams(enum AUDIO_STREAM_REQ_USER_T user) -{ - bool action; +static void usb_audio_init_streams(enum AUDIO_STREAM_REQ_USER_T user) { + bool action; - action = false; + action = false; #ifndef DELAY_STREAM_OPEN - if (user == AUDIO_STREAM_REQ_USB) { - action = true; - } + if (user == AUDIO_STREAM_REQ_USB) { + action = true; + } #endif #ifdef ANC_L_R_MISALIGN_WORKAROUND - if (user == AUDIO_STREAM_REQ_ANC) { - action = true; - } + if (user == AUDIO_STREAM_REQ_ANC) { + action = true; + } #endif - if (action) - { - usb_audio_open_codec_stream(AUD_STREAM_PLAYBACK, user); - usb_audio_open_codec_stream(AUD_STREAM_CAPTURE, user); - } + if (action) { + usb_audio_open_codec_stream(AUD_STREAM_PLAYBACK, user); + usb_audio_open_codec_stream(AUD_STREAM_CAPTURE, user); + } #ifdef ANC_L_R_MISALIGN_WORKAROUND - if (user == AUDIO_STREAM_REQ_ANC) { - usb_audio_start_codec_stream(AUD_STREAM_PLAYBACK, user); - usb_audio_start_codec_stream(AUD_STREAM_CAPTURE, user); - } + if (user == AUDIO_STREAM_REQ_ANC) { + usb_audio_start_codec_stream(AUD_STREAM_PLAYBACK, user); + usb_audio_start_codec_stream(AUD_STREAM_CAPTURE, user); + } #endif } -static void usb_audio_term_streams(enum AUDIO_STREAM_REQ_USER_T user) -{ - // Ensure all the streams for this user are stopped and closed - usb_audio_stop_codec_stream(AUD_STREAM_CAPTURE, user); - usb_audio_stop_codec_stream(AUD_STREAM_PLAYBACK, user); +static void usb_audio_term_streams(enum AUDIO_STREAM_REQ_USER_T user) { + // Ensure all the streams for this user are stopped and closed + usb_audio_stop_codec_stream(AUD_STREAM_CAPTURE, user); + usb_audio_stop_codec_stream(AUD_STREAM_PLAYBACK, user); - usb_audio_close_codec_stream(AUD_STREAM_CAPTURE, user); - usb_audio_close_codec_stream(AUD_STREAM_PLAYBACK, user); + usb_audio_close_codec_stream(AUD_STREAM_CAPTURE, user); + usb_audio_close_codec_stream(AUD_STREAM_PLAYBACK, user); } #if defined(ANDROID_ACCESSORY_SPEC) || defined(CFG_MIC_KEY) -static void hid_data_send_handler(enum USB_AUDIO_HID_EVENT_T event, int error) -{ - TRACE(2,"HID SENT: event=0x%04x error=%d", event, error); +static void hid_data_send_handler(enum USB_AUDIO_HID_EVENT_T event, int error) { + TRACE(2, "HID SENT: event=0x%04x error=%d", event, error); } #endif -static void usb_audio_itf_callback(enum USB_AUDIO_ITF_ID_T id, enum USB_AUDIO_ITF_CMD_T cmd) -{ - if (0) { +static void usb_audio_itf_callback(enum USB_AUDIO_ITF_ID_T id, + enum USB_AUDIO_ITF_CMD_T cmd) { + if (0) { #ifdef USB_AUDIO_MULTIFUNC - } else if (id == USB_AUDIO_ITF_ID_RECV2) { - usb_audio_playback2_start(cmd); + } else if (id == USB_AUDIO_ITF_ID_RECV2) { + usb_audio_playback2_start(cmd); #endif - } else if (id == USB_AUDIO_ITF_ID_RECV) { - usb_audio_playback_start(cmd); - } else { - usb_audio_capture_start(cmd); - } + } else if (id == USB_AUDIO_ITF_ID_RECV) { + usb_audio_playback_start(cmd); + } else { + usb_audio_capture_start(cmd); + } } -static void usb_audio_mute_callback(enum USB_AUDIO_ITF_ID_T id, uint32_t mute) -{ - if (0) { +static void usb_audio_mute_callback(enum USB_AUDIO_ITF_ID_T id, uint32_t mute) { + if (0) { #ifdef USB_AUDIO_MULTIFUNC - } else if (id == USB_AUDIO_ITF_ID_RECV2) { - usb_audio_mute2_control(mute); + } else if (id == USB_AUDIO_ITF_ID_RECV2) { + usb_audio_mute2_control(mute); #endif - } else if (id == USB_AUDIO_ITF_ID_RECV) { - usb_audio_mute_control(mute); - } else { - usb_audio_cap_mute_control(mute); - } + } else if (id == USB_AUDIO_ITF_ID_RECV) { + usb_audio_mute_control(mute); + } else { + usb_audio_cap_mute_control(mute); + } } -static void usb_audio_set_volume(enum USB_AUDIO_ITF_ID_T id, uint32_t percent) -{ - if (0) { +static void usb_audio_set_volume(enum USB_AUDIO_ITF_ID_T id, uint32_t percent) { + if (0) { #ifdef USB_AUDIO_MULTIFUNC - } else if (id == USB_AUDIO_ITF_ID_RECV2) { - usb_audio_vol2_control(percent); + } else if (id == USB_AUDIO_ITF_ID_RECV2) { + usb_audio_vol2_control(percent); #endif - } else if (id == USB_AUDIO_ITF_ID_RECV) { - usb_audio_vol_control(percent); - } else { - usb_audio_cap_vol_control(percent); - } + } else if (id == USB_AUDIO_ITF_ID_RECV) { + usb_audio_vol_control(percent); + } else { + usb_audio_cap_vol_control(percent); + } } -static uint32_t usb_audio_get_volume(enum USB_AUDIO_ITF_ID_T id) -{ - uint32_t percent = 0; +static uint32_t usb_audio_get_volume(enum USB_AUDIO_ITF_ID_T id) { + uint32_t percent = 0; - if (0) { + if (0) { #ifdef USB_AUDIO_MULTIFUNC - } else if (id == USB_AUDIO_ITF_ID_RECV2) { - percent = usb_audio_get_vol2_percent(); + } else if (id == USB_AUDIO_ITF_ID_RECV2) { + percent = usb_audio_get_vol2_percent(); #endif - } else if (id == USB_AUDIO_ITF_ID_RECV) { - percent = usb_audio_get_vol_percent(); - } else { - percent = usb_audio_get_cap_vol_percent(); - } + } else if (id == USB_AUDIO_ITF_ID_RECV) { + percent = usb_audio_get_vol_percent(); + } else { + percent = usb_audio_get_cap_vol_percent(); + } - return percent; + return percent; } -static void usb_audio_xfer_callback(enum USB_AUDIO_ITF_ID_T id, const struct USB_AUDIO_XFER_INFO_T *info) -{ - if (0) { +static void usb_audio_xfer_callback(enum USB_AUDIO_ITF_ID_T id, + const struct USB_AUDIO_XFER_INFO_T *info) { + if (0) { #ifdef USB_AUDIO_MULTIFUNC - } else if (id == USB_AUDIO_ITF_ID_RECV2) { - usb_audio_data_recv2_handler(info); + } else if (id == USB_AUDIO_ITF_ID_RECV2) { + usb_audio_data_recv2_handler(info); #endif - } else if (id == USB_AUDIO_ITF_ID_RECV) { - usb_audio_data_recv_handler(info); - } else { - usb_audio_data_send_handler(info); - } + } else if (id == USB_AUDIO_ITF_ID_RECV) { + usb_audio_data_recv_handler(info); + } else { + usb_audio_data_send_handler(info); + } } -static void usb_audio_stream_running_handler(void) -{ - enum AUDIO_STREAM_RUNNING_T req; - uint32_t lock; +static void usb_audio_stream_running_handler(void) { + enum AUDIO_STREAM_RUNNING_T req; + uint32_t lock; - req = streams_running_req; + req = streams_running_req; - if (req == AUDIO_STREAM_RUNNING_NULL) { - return; - } else if (req == AUDIO_STREAM_RUNNING_ENABLED) { - usb_audio_init_streams(AUDIO_STREAM_REQ_ANC); - } else if (req == AUDIO_STREAM_RUNNING_DISABLED) { - usb_audio_term_streams(AUDIO_STREAM_REQ_ANC); - } + if (req == AUDIO_STREAM_RUNNING_NULL) { + return; + } else if (req == AUDIO_STREAM_RUNNING_ENABLED) { + usb_audio_init_streams(AUDIO_STREAM_REQ_ANC); + } else if (req == AUDIO_STREAM_RUNNING_DISABLED) { + usb_audio_term_streams(AUDIO_STREAM_REQ_ANC); + } - lock = int_lock(); - if (req == streams_running_req) { - streams_running_req = AUDIO_STREAM_RUNNING_NULL; - } - int_unlock(lock); + lock = int_lock(); + if (req == streams_running_req) { + streams_running_req = AUDIO_STREAM_RUNNING_NULL; + } + int_unlock(lock); } -void usb_audio_keep_streams_running(bool enable) -{ - if (enable) { - streams_running_req = AUDIO_STREAM_RUNNING_ENABLED; - } else { - streams_running_req = AUDIO_STREAM_RUNNING_DISABLED; - } +void usb_audio_keep_streams_running(bool enable) { + if (enable) { + streams_running_req = AUDIO_STREAM_RUNNING_ENABLED; + } else { + streams_running_req = AUDIO_STREAM_RUNNING_DISABLED; + } - // TODO: Move usb_audio_stream_running_handler() into usb_audio_app_loop() ? - // How to ensure that streams are opened before ANC is enabled? - usb_audio_stream_running_handler(); + // TODO: Move usb_audio_stream_running_handler() into usb_audio_app_loop() ? + // How to ensure that streams are opened before ANC is enabled? + usb_audio_stream_running_handler(); } #ifdef USB_AUDIO_DYN_CFG -static enum AUD_SAMPRATE_T calc_play_sample_rate(enum AUD_SAMPRATE_T usb_rate) -{ - enum AUD_SAMPRATE_T codec_rate; +static enum AUD_SAMPRATE_T calc_play_sample_rate(enum AUD_SAMPRATE_T usb_rate) { + enum AUD_SAMPRATE_T codec_rate; #if defined(CHIP_BEST1000) && defined(ANC_APP) - codec_rate = (usb_rate % AUD_SAMPRATE_8000) ? AUD_SAMPRATE_88200 : AUD_SAMPRATE_96000; + codec_rate = + (usb_rate % AUD_SAMPRATE_8000) ? AUD_SAMPRATE_88200 : AUD_SAMPRATE_96000; #else - codec_rate = usb_rate; + codec_rate = usb_rate; #if defined(__AUDIO_RESAMPLE__) && defined(SW_PLAYBACK_RESAMPLE) - if (codec_rate % AUD_SAMPRATE_8000) { - codec_rate = hal_cmu_get_crystal_freq() / (CODEC_FREQ_44_1K_SERIES / codec_rate); - } else { - codec_rate = hal_cmu_get_crystal_freq() / (CODEC_FREQ_48K_SERIES / codec_rate); - } + if (codec_rate % AUD_SAMPRATE_8000) { + codec_rate = + hal_cmu_get_crystal_freq() / (CODEC_FREQ_44_1K_SERIES / codec_rate); + } else { + codec_rate = + hal_cmu_get_crystal_freq() / (CODEC_FREQ_48K_SERIES / codec_rate); + } #endif #endif - return codec_rate; + return codec_rate; } #if defined(CHIP_BEST1000) && (defined(ANC_APP) || defined(_DUAL_AUX_MIC_)) -static enum AUD_SAMPRATE_T calc_anc_cap_sample_rate_best1000(enum AUD_SAMPRATE_T usb_rate, enum AUD_SAMPRATE_T play_rate) -{ - enum AUD_SAMPRATE_T rate_cap; +static enum AUD_SAMPRATE_T +calc_anc_cap_sample_rate_best1000(enum AUD_SAMPRATE_T usb_rate, + enum AUD_SAMPRATE_T play_rate) { + enum AUD_SAMPRATE_T rate_cap; #ifdef ANC_APP #ifdef AUD_PLL_DOUBLE #if defined(_DUAL_AUX_MIC_) || defined(CAPTURE_ANC_DATA) - rate_cap = play_rate * 8; + rate_cap = play_rate * 8; #else - rate_cap = play_rate * 2; + rate_cap = play_rate * 2; #endif #else // !AUD_PLL_DOUBLE #if defined(_DUAL_AUX_MIC_) || defined(CAPTURE_ANC_DATA) - rate_cap = play_rate * 4; + rate_cap = play_rate * 4; #else - rate_cap = play_rate; + rate_cap = play_rate; #endif #endif // !AUD_PLL_DOUBLE #else // _DUAL_AUX_MIC_ - // Capture reference - enum AUD_SAMPRATE_T rate_cap_ref; + // Capture reference + enum AUD_SAMPRATE_T rate_cap_ref; - rate_cap_ref = (usb_rate % AUD_SAMPRATE_8000) ? AUD_SAMPRATE_44100 : AUD_SAMPRATE_48000; + rate_cap_ref = + (usb_rate % AUD_SAMPRATE_8000) ? AUD_SAMPRATE_44100 : AUD_SAMPRATE_48000; - rate_cap = rate_cap_ref * 4; + rate_cap = rate_cap_ref * 4; #endif - return rate_cap; + return rate_cap; } #endif -static enum AUD_SAMPRATE_T calc_cap_sample_rate(enum AUD_SAMPRATE_T usb_rate, enum AUD_SAMPRATE_T play_rate) -{ +static enum AUD_SAMPRATE_T calc_cap_sample_rate(enum AUD_SAMPRATE_T usb_rate, + enum AUD_SAMPRATE_T play_rate) { #if defined(CHIP_BEST1000) && (defined(ANC_APP) || defined(_DUAL_AUX_MIC_)) - return calc_anc_cap_sample_rate_best1000(usb_rate, play_rate); + return calc_anc_cap_sample_rate_best1000(usb_rate, play_rate); #else // !(CHIP_BEST1000 && (ANC_APP || _DUAL_AUX_MIC_)) - enum AUD_SAMPRATE_T codec_rate; + enum AUD_SAMPRATE_T codec_rate; #ifdef __AUDIO_RESAMPLE__ - codec_rate = usb_rate; + codec_rate = usb_rate; #ifdef SW_CAPTURE_RESAMPLE - if (codec_rate % AUD_SAMPRATE_8000) { - codec_rate = hal_cmu_get_crystal_freq() / (CODEC_FREQ_44_1K_SERIES / codec_rate); - } else { - codec_rate = hal_cmu_get_crystal_freq() / (CODEC_FREQ_48K_SERIES / codec_rate); - } + if (codec_rate % AUD_SAMPRATE_8000) { + codec_rate = + hal_cmu_get_crystal_freq() / (CODEC_FREQ_44_1K_SERIES / codec_rate); + } else { + codec_rate = + hal_cmu_get_crystal_freq() / (CODEC_FREQ_48K_SERIES / codec_rate); + } #endif #else // ! __AUDIO_RESAMPLE__ - bool usb_rate_44p1k; - bool play_rate_44p1k; + bool usb_rate_44p1k; + bool play_rate_44p1k; - usb_rate_44p1k = !!(usb_rate % AUD_SAMPRATE_8000); - play_rate_44p1k = !!(play_rate % AUD_SAMPRATE_8000); + usb_rate_44p1k = !!(usb_rate % AUD_SAMPRATE_8000); + play_rate_44p1k = !!(play_rate % AUD_SAMPRATE_8000); - if (usb_rate_44p1k ^ play_rate_44p1k) { - // Playback pll is NOT compatible with capture sample rate - if (usb_rate_44p1k) { - codec_rate = CODEC_FREQ_48K_SERIES / (CODEC_FREQ_44_1K_SERIES / usb_rate); - } else { - codec_rate = CODEC_FREQ_44_1K_SERIES / (CODEC_FREQ_48K_SERIES / usb_rate); - } + if (usb_rate_44p1k ^ play_rate_44p1k) { + // Playback pll is NOT compatible with capture sample rate + if (usb_rate_44p1k) { + codec_rate = CODEC_FREQ_48K_SERIES / (CODEC_FREQ_44_1K_SERIES / usb_rate); } else { - // Playback pll is compatible with capture sample rate - codec_rate = usb_rate; + codec_rate = CODEC_FREQ_44_1K_SERIES / (CODEC_FREQ_48K_SERIES / usb_rate); } + } else { + // Playback pll is compatible with capture sample rate + codec_rate = usb_rate; + } #endif // !__AUDIO_RESAMPLE__ - return codec_rate; + return codec_rate; #endif // !(CHIP_BEST1000 && (ANC_APP || _DUAL_AUX_MIC_)) } #endif // USB_AUDIO_DYN_CFG -static void POSSIBLY_UNUSED usb_audio_update_codec_stream(enum AUD_STREAM_T stream) -{ - bool update_play; - bool update_cap; +static void POSSIBLY_UNUSED +usb_audio_update_codec_stream(enum AUD_STREAM_T stream) { + bool update_play; + bool update_cap; #ifdef STREAM_RATE_BITS_SETUP - struct AF_STREAM_CONFIG_T *cfg, stream_cfg; - uint32_t ret; + struct AF_STREAM_CONFIG_T *cfg, stream_cfg; + uint32_t ret; #endif - update_play = false; - update_cap = false; + update_play = false; + update_cap = false; #ifdef USB_AUDIO_DYN_CFG - enum AUD_SAMPRATE_T new_recv_rate; - enum AUD_SAMPRATE_T new_send_rate; - enum AUD_SAMPRATE_T play_rate; - enum AUD_SAMPRATE_T cap_rate; - uint8_t new_recv_size; - uint32_t lock; + enum AUD_SAMPRATE_T new_recv_rate; + enum AUD_SAMPRATE_T new_send_rate; + enum AUD_SAMPRATE_T play_rate; + enum AUD_SAMPRATE_T cap_rate; + uint8_t new_recv_size; + uint32_t lock; - lock = int_lock(); - new_recv_rate = new_sample_rate_recv; - new_recv_size = new_sample_size_recv; - new_send_rate = new_sample_rate_send; - int_unlock(lock); + lock = int_lock(); + new_recv_rate = new_sample_rate_recv; + new_recv_size = new_sample_size_recv; + new_send_rate = new_sample_rate_send; + int_unlock(lock); - play_rate = sample_rate_play; - cap_rate = sample_rate_cap; + play_rate = sample_rate_play; + cap_rate = sample_rate_cap; - if (stream == AUD_STREAM_PLAYBACK) { - if (sample_rate_recv == new_recv_rate && sample_size_recv == new_recv_size) { - // No change - goto _done_rate_size_check; - } + if (stream == AUD_STREAM_PLAYBACK) { + if (sample_rate_recv == new_recv_rate && + sample_size_recv == new_recv_size) { + // No change + goto _done_rate_size_check; + } #ifdef AUDIO_PLAYBACK_24BIT - if (sample_rate_recv == new_recv_rate && sample_size_recv != new_recv_size) { - // No codec change. Only a change in usb sample size - TRACE(3,"%s:1: Update recv sample size from %u to %u", __FUNCTION__, sample_size_recv, new_recv_size); - sample_size_recv = new_recv_size; - update_playback_sync_info(); - goto _done_rate_size_check; - } -#endif - } else { - if (sample_rate_send == new_send_rate) { - // No change - goto _done_rate_size_check; - } + if (sample_rate_recv == new_recv_rate && + sample_size_recv != new_recv_size) { + // No codec change. Only a change in usb sample size + TRACE(3, "%s:1: Update recv sample size from %u to %u", __FUNCTION__, + sample_size_recv, new_recv_size); + sample_size_recv = new_recv_size; + update_playback_sync_info(); + goto _done_rate_size_check; } - - if (stream == AUD_STREAM_PLAYBACK) { - play_rate = calc_play_sample_rate(new_recv_rate); - if (sample_rate_play == play_rate) { - if (sample_size_recv == new_recv_size) { - // No codec change. Only a change in usb sample rate - TRACE(3,"%s:1: Update recv sample rate from %u to %u", __FUNCTION__, sample_rate_recv, new_recv_rate); - sample_rate_recv = new_recv_rate; - update_playback_sync_info(); - goto _done_rate_size_check; - } - } else { -#ifndef __AUDIO_RESAMPLE__ - bool new_rate_44p1k; - bool old_rate_44p1k; - - new_rate_44p1k = !!(play_rate % AUD_SAMPRATE_8000); - old_rate_44p1k = !!(sample_rate_play % AUD_SAMPRATE_8000); - - if (new_rate_44p1k ^ old_rate_44p1k) { - cap_rate = calc_cap_sample_rate(new_send_rate, play_rate); - update_cap = true; - } #endif - } - update_play = true; + } else { + if (sample_rate_send == new_send_rate) { + // No change + goto _done_rate_size_check; + } + } + + if (stream == AUD_STREAM_PLAYBACK) { + play_rate = calc_play_sample_rate(new_recv_rate); + if (sample_rate_play == play_rate) { + if (sample_size_recv == new_recv_size) { + // No codec change. Only a change in usb sample rate + TRACE(3, "%s:1: Update recv sample rate from %u to %u", __FUNCTION__, + sample_rate_recv, new_recv_rate); + sample_rate_recv = new_recv_rate; + update_playback_sync_info(); + goto _done_rate_size_check; + } } else { #ifndef __AUDIO_RESAMPLE__ - if (playback_state == AUDIO_ITF_STATE_STOPPED) { - bool usb_rate_44p1k; - bool play_rate_44p1k; + bool new_rate_44p1k; + bool old_rate_44p1k; - usb_rate_44p1k = !!(new_send_rate % AUD_SAMPRATE_8000); - play_rate_44p1k = !!(play_rate % AUD_SAMPRATE_8000); + new_rate_44p1k = !!(play_rate % AUD_SAMPRATE_8000); + old_rate_44p1k = !!(sample_rate_play % AUD_SAMPRATE_8000); - if (usb_rate_44p1k ^ play_rate_44p1k) { - play_rate = calc_play_sample_rate(usb_rate_44p1k ? AUD_SAMPRATE_44100 : AUD_SAMPRATE_48000); - update_play = true; - } - } -#endif + if (new_rate_44p1k ^ old_rate_44p1k) { cap_rate = calc_cap_sample_rate(new_send_rate, play_rate); - if (sample_rate_cap == cap_rate) { - // No codec change. Only a change in usb sample rate - TRACE(3,"%s:1: Update send sample rate from %u to %u", __FUNCTION__, sample_rate_send, new_send_rate); - sample_rate_send = new_send_rate; - update_capture_sync_info(); - goto _done_rate_size_check; - } update_cap = true; + } +#endif } + update_play = true; + } else { +#ifndef __AUDIO_RESAMPLE__ + if (playback_state == AUDIO_ITF_STATE_STOPPED) { + bool usb_rate_44p1k; + bool play_rate_44p1k; + + usb_rate_44p1k = !!(new_send_rate % AUD_SAMPRATE_8000); + play_rate_44p1k = !!(play_rate % AUD_SAMPRATE_8000); + + if (usb_rate_44p1k ^ play_rate_44p1k) { + play_rate = calc_play_sample_rate(usb_rate_44p1k ? AUD_SAMPRATE_44100 + : AUD_SAMPRATE_48000); + update_play = true; + } + } +#endif + cap_rate = calc_cap_sample_rate(new_send_rate, play_rate); + if (sample_rate_cap == cap_rate) { + // No codec change. Only a change in usb sample rate + TRACE(3, "%s:1: Update send sample rate from %u to %u", __FUNCTION__, + sample_rate_send, new_send_rate); + sample_rate_send = new_send_rate; + update_capture_sync_info(); + goto _done_rate_size_check; + } + update_cap = true; + } _done_rate_size_check:; #endif #ifdef DSD_SUPPORT - bool new_dsd_state; + bool new_dsd_state; - new_dsd_state = usb_dsd_enabled; - if (stream == AUD_STREAM_PLAYBACK) { - if (codec_dsd_enabled != new_dsd_state) { - update_play = true; - } + new_dsd_state = usb_dsd_enabled; + if (stream == AUD_STREAM_PLAYBACK) { + if (codec_dsd_enabled != new_dsd_state) { + update_play = true; } + } #endif - if (!update_play && !update_cap) { - return; - } + if (!update_play && !update_cap) { + return; + } - // 1) To avoid L/R sample misalignment, streams must be stopped before changing sample rate - // 2) To avoid FIFO corruption, streams must be stopped before changing sample size - if (update_cap && codec_stream_map[AUD_STREAM_CAPTURE][AUDIO_STREAM_STARTED]) { - set_codec_config_status(CODEC_CONFIG_LOCK_RESTART_CAP, true); - usb_audio_stop_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USER_ALL); - } - if (update_play && codec_stream_map[AUD_STREAM_PLAYBACK][AUDIO_STREAM_STARTED]) { - set_codec_config_status(CODEC_CONFIG_LOCK_RESTART_PLAY, true); - usb_audio_stop_codec_stream(AUD_STREAM_PLAYBACK, AUDIO_STREAM_REQ_USER_ALL); - } + // 1) To avoid L/R sample misalignment, streams must be stopped before + // changing sample rate 2) To avoid FIFO corruption, streams must be stopped + // before changing sample size + if (update_cap && + codec_stream_map[AUD_STREAM_CAPTURE][AUDIO_STREAM_STARTED]) { + set_codec_config_status(CODEC_CONFIG_LOCK_RESTART_CAP, true); + usb_audio_stop_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USER_ALL); + } + if (update_play && + codec_stream_map[AUD_STREAM_PLAYBACK][AUDIO_STREAM_STARTED]) { + set_codec_config_status(CODEC_CONFIG_LOCK_RESTART_PLAY, true); + usb_audio_stop_codec_stream(AUD_STREAM_PLAYBACK, AUDIO_STREAM_REQ_USER_ALL); + } - if (update_play) { + if (update_play) { #ifdef USB_AUDIO_DYN_CFG - if (sample_rate_recv != new_recv_rate) { - TRACE(3,"%s:2: Update recv sample rate from %u to %u", __FUNCTION__, sample_rate_recv, new_recv_rate); - sample_rate_recv = new_recv_rate; - } - if (sample_rate_play != play_rate) { - TRACE(3,"%s:2: Update play sample rate from %u to %u", __FUNCTION__, sample_rate_play, play_rate); - sample_rate_play = play_rate; - } - if (sample_size_recv != new_recv_size) { - TRACE(3,"%s:2: Update recv sample size from %u to %u", __FUNCTION__, sample_size_recv, new_recv_size); - sample_size_recv = new_recv_size; + if (sample_rate_recv != new_recv_rate) { + TRACE(3, "%s:2: Update recv sample rate from %u to %u", __FUNCTION__, + sample_rate_recv, new_recv_rate); + sample_rate_recv = new_recv_rate; + } + if (sample_rate_play != play_rate) { + TRACE(3, "%s:2: Update play sample rate from %u to %u", __FUNCTION__, + sample_rate_play, play_rate); + sample_rate_play = play_rate; + } + if (sample_size_recv != new_recv_size) { + TRACE(3, "%s:2: Update recv sample size from %u to %u", __FUNCTION__, + sample_size_recv, new_recv_size); + sample_size_recv = new_recv_size; #ifndef AUDIO_PLAYBACK_24BIT - uint8_t old_play_size; + uint8_t old_play_size; - old_play_size = sample_size_play; - sample_size_play = (new_recv_size == 2) ? 2 : 4; - TRACE(3,"%s:2: Update play sample size from %u to %u", __FUNCTION__, old_play_size, sample_size_play); + old_play_size = sample_size_play; + sample_size_play = (new_recv_size == 2) ? 2 : 4; + TRACE(3, "%s:2: Update play sample size from %u to %u", __FUNCTION__, + old_play_size, sample_size_play); #endif - } + } #endif #ifdef DSD_SUPPORT - if (codec_dsd_enabled != new_dsd_state) { - codec_dsd_enabled = new_dsd_state; + if (codec_dsd_enabled != new_dsd_state) { + codec_dsd_enabled = new_dsd_state; #ifdef CODEC_DSD - uint8_t old_play_size; + uint8_t old_play_size; - old_play_size = sample_size_play; - if (codec_dsd_enabled) { - playback_size /= ((sample_size_play + 1) / 2); - dsd_saved_sample_size = sample_size_play; - sample_size_play = 2; - } else { - playback_size *= ((dsd_saved_sample_size + 1) / 2); - sample_size_play = dsd_saved_sample_size; - } - TRACE(4,"%s:2: CODEC_DSD=%u update play sample size from %u to %u", __FUNCTION__, codec_dsd_enabled, old_play_size, sample_size_play); -#endif - } + old_play_size = sample_size_play; + if (codec_dsd_enabled) { + playback_size /= ((sample_size_play + 1) / 2); + dsd_saved_sample_size = sample_size_play; + sample_size_play = 2; + } else { + playback_size *= ((dsd_saved_sample_size + 1) / 2); + sample_size_play = dsd_saved_sample_size; + } + TRACE(4, "%s:2: CODEC_DSD=%u update play sample size from %u to %u", + __FUNCTION__, codec_dsd_enabled, old_play_size, sample_size_play); #endif } - if (update_cap) { +#endif + } + if (update_cap) { #ifdef USB_AUDIO_DYN_CFG - if (sample_rate_send != new_send_rate) { - TRACE(3,"%s:2: Update send sample rate from %u to %u", __FUNCTION__, sample_rate_send, new_send_rate); - sample_rate_send = new_send_rate; - } - if (sample_rate_cap != cap_rate) { - TRACE(3,"%s:2: Update cap sample rate from %u to %u", __FUNCTION__, sample_rate_cap, cap_rate); - sample_rate_cap = cap_rate; - } -#endif + if (sample_rate_send != new_send_rate) { + TRACE(3, "%s:2: Update send sample rate from %u to %u", __FUNCTION__, + sample_rate_send, new_send_rate); + sample_rate_send = new_send_rate; } + if (sample_rate_cap != cap_rate) { + TRACE(3, "%s:2: Update cap sample rate from %u to %u", __FUNCTION__, + sample_rate_cap, cap_rate); + sample_rate_cap = cap_rate; + } +#endif + } #if defined(USB_AUDIO_DYN_CFG) && defined(KEEP_SAME_LATENCY) - playback_size = calc_playback_size(sample_rate_play); - capture_size = calc_capture_size(sample_rate_cap); + playback_size = calc_playback_size(sample_rate_play); + capture_size = calc_capture_size(sample_rate_cap); #endif #ifdef SW_CAPTURE_RESAMPLE - // Check whether to start capture resample - if (update_cap && capture_state == AUDIO_ITF_STATE_STARTED) { - capture_stream_resample_config(); - } + // Check whether to start capture resample + if (update_cap && capture_state == AUDIO_ITF_STATE_STARTED) { + capture_stream_resample_config(); + } #endif #ifdef STREAM_RATE_BITS_SETUP - if (update_play) { - update_playback_sync_info(); + if (update_play) { + update_playback_sync_info(); - ret = af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &cfg, true); - if (ret == 0) { - // Changes in AF_STREAM_CONFIG_T::bits must be in another cfg variable - stream_cfg = *cfg; + ret = af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &cfg, true); + if (ret == 0) { + // Changes in AF_STREAM_CONFIG_T::bits must be in another cfg variable + stream_cfg = *cfg; #ifdef CODEC_DSD - if (codec_dsd_enabled) { - stream_cfg.bits = AUD_BITS_24; - } else + if (codec_dsd_enabled) { + stream_cfg.bits = AUD_BITS_24; + } else #endif - { - stream_cfg.bits = sample_size_to_enum_playback(sample_size_play); - } - stream_cfg.sample_rate = sample_rate_play; -#if (defined(USB_AUDIO_DYN_CFG) && defined(KEEP_SAME_LATENCY)) || defined(CODEC_DSD) - stream_cfg.data_size = playback_size; + { + stream_cfg.bits = sample_size_to_enum_playback(sample_size_play); + } + stream_cfg.sample_rate = sample_rate_play; +#if (defined(USB_AUDIO_DYN_CFG) && defined(KEEP_SAME_LATENCY)) || \ + defined(CODEC_DSD) + stream_cfg.data_size = playback_size; #endif - af_stream_setup(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); - } + af_stream_setup(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg); + } #ifdef AUDIO_ANC_FB_MC - ret = af_stream_get_cfg(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &cfg, true); - if (ret == 0) { - // Changes in AF_STREAM_CONFIG_T::bits must be in another cfg variable - stream_cfg = *cfg; - stream_cfg.bits = sample_size_to_enum_playback(sample_size_play); + ret = af_stream_get_cfg(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &cfg, true); + if (ret == 0) { + // Changes in AF_STREAM_CONFIG_T::bits must be in another cfg variable + stream_cfg = *cfg; + stream_cfg.bits = sample_size_to_enum_playback(sample_size_play); - if(sample_rate_play==AUD_SAMPRATE_8000) - { - playback_samplerate_ratio=8*6; - } - else if(sample_rate_play==AUD_SAMPRATE_16000) - { - playback_samplerate_ratio=8*3; - } - else if((sample_rate_play==AUD_SAMPRATE_44100)||(sample_rate_play==AUD_SAMPRATE_48000)||(sample_rate_play==AUD_SAMPRATE_50781)) - { - playback_samplerate_ratio=8; - } - else if((sample_rate_play==AUD_SAMPRATE_88200)||(sample_rate_play==AUD_SAMPRATE_96000)) - { - playback_samplerate_ratio=4; - } - else if((sample_rate_play==AUD_SAMPRATE_176400)||(sample_rate_play==AUD_SAMPRATE_192000)) - { - playback_samplerate_ratio=2; - } - else if(sample_rate_play==AUD_SAMPRATE_384000) - { - playback_samplerate_ratio=1; - } - else - { - playback_samplerate_ratio=1; - ASSERT(false, "Music cancel can't support playback sample rate:%d",sample_rate_play); - } + if (sample_rate_play == AUD_SAMPRATE_8000) { + playback_samplerate_ratio = 8 * 6; + } else if (sample_rate_play == AUD_SAMPRATE_16000) { + playback_samplerate_ratio = 8 * 3; + } else if ((sample_rate_play == AUD_SAMPRATE_44100) || + (sample_rate_play == AUD_SAMPRATE_48000) || + (sample_rate_play == AUD_SAMPRATE_50781)) { + playback_samplerate_ratio = 8; + } else if ((sample_rate_play == AUD_SAMPRATE_88200) || + (sample_rate_play == AUD_SAMPRATE_96000)) { + playback_samplerate_ratio = 4; + } else if ((sample_rate_play == AUD_SAMPRATE_176400) || + (sample_rate_play == AUD_SAMPRATE_192000)) { + playback_samplerate_ratio = 2; + } else if (sample_rate_play == AUD_SAMPRATE_384000) { + playback_samplerate_ratio = 1; + } else { + playback_samplerate_ratio = 1; + ASSERT(false, "Music cancel can't support playback sample rate:%d", + sample_rate_play); + } - stream_cfg.data_ptr = playback_buf+playback_size; - stream_cfg.data_size = playback_size*playback_samplerate_ratio; + stream_cfg.data_ptr = playback_buf + playback_size; + stream_cfg.data_size = playback_size * playback_samplerate_ratio; - stream_cfg.sample_rate = sample_rate_play; - af_stream_setup(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &stream_cfg); - anc_mc_run_setup((sample_rate_play*playback_samplerate_ratio)/8); - } -#endif + stream_cfg.sample_rate = sample_rate_play; + af_stream_setup(AUD_STREAM_ID_2, AUD_STREAM_PLAYBACK, &stream_cfg); + anc_mc_run_setup((sample_rate_play * playback_samplerate_ratio) / 8); } - if (update_cap) { - update_capture_sync_info(); +#endif + } + if (update_cap) { + update_capture_sync_info(); - ret = af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &cfg, true); - if (ret == 0) { - stream_cfg = *cfg; - stream_cfg.bits = sample_size_to_enum_capture(sample_size_cap); + ret = af_stream_get_cfg(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &cfg, true); + if (ret == 0) { + stream_cfg = *cfg; + stream_cfg.bits = sample_size_to_enum_capture(sample_size_cap); #if defined(USB_AUDIO_DYN_CFG) && defined(KEEP_SAME_LATENCY) - stream_cfg.data_size = capture_size; + stream_cfg.data_size = capture_size; #endif - stream_cfg.sample_rate = sample_rate_cap; - af_stream_setup(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); - } - } -#else // !STREAM_RATE_BITS_SETUP - // Close streams - if (update_cap && codec_stream_map[AUD_STREAM_CAPTURE][AUDIO_STREAM_OPENED]) { - usb_audio_close_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USER_ALL); - } - if (update_play && codec_stream_map[AUD_STREAM_PLAYBACK][AUDIO_STREAM_OPENED]) { - usb_audio_close_codec_stream(AUD_STREAM_PLAYBACK, AUDIO_STREAM_REQ_USER_ALL); - } - // Open streams - if (update_play && codec_stream_map[AUD_STREAM_PLAYBACK][AUDIO_STREAM_OPENED]) { - usb_audio_open_codec_stream(AUD_STREAM_PLAYBACK, AUDIO_STREAM_REQ_USER_ALL); - } - if (update_cap && codec_stream_map[AUD_STREAM_CAPTURE][AUDIO_STREAM_OPENED]) { - usb_audio_open_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USER_ALL); + stream_cfg.sample_rate = sample_rate_cap; + af_stream_setup(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); } + } +#else // !STREAM_RATE_BITS_SETUP + // Close streams + if (update_cap && codec_stream_map[AUD_STREAM_CAPTURE][AUDIO_STREAM_OPENED]) { + usb_audio_close_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USER_ALL); + } + if (update_play && + codec_stream_map[AUD_STREAM_PLAYBACK][AUDIO_STREAM_OPENED]) { + usb_audio_close_codec_stream(AUD_STREAM_PLAYBACK, + AUDIO_STREAM_REQ_USER_ALL); + } + // Open streams + if (update_play && + codec_stream_map[AUD_STREAM_PLAYBACK][AUDIO_STREAM_OPENED]) { + usb_audio_open_codec_stream(AUD_STREAM_PLAYBACK, AUDIO_STREAM_REQ_USER_ALL); + } + if (update_cap && codec_stream_map[AUD_STREAM_CAPTURE][AUDIO_STREAM_OPENED]) { + usb_audio_open_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USER_ALL); + } #endif // !STREAM_RATE_BITS_SETUP - if (update_play && codec_stream_map[AUD_STREAM_PLAYBACK][AUDIO_STREAM_STARTED]) { - usb_audio_start_codec_stream(AUD_STREAM_PLAYBACK, AUDIO_STREAM_REQ_USER_ALL); - set_codec_config_status(CODEC_CONFIG_LOCK_RESTART_PLAY, false); - } - if (update_cap && codec_stream_map[AUD_STREAM_CAPTURE][AUDIO_STREAM_STARTED]) { - usb_audio_start_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USER_ALL); - set_codec_config_status(CODEC_CONFIG_LOCK_RESTART_CAP, false); - } + if (update_play && + codec_stream_map[AUD_STREAM_PLAYBACK][AUDIO_STREAM_STARTED]) { + usb_audio_start_codec_stream(AUD_STREAM_PLAYBACK, + AUDIO_STREAM_REQ_USER_ALL); + set_codec_config_status(CODEC_CONFIG_LOCK_RESTART_PLAY, false); + } + if (update_cap && + codec_stream_map[AUD_STREAM_CAPTURE][AUDIO_STREAM_STARTED]) { + usb_audio_start_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USER_ALL); + set_codec_config_status(CODEC_CONFIG_LOCK_RESTART_CAP, false); + } } -static void start_play(uint8_t seq) -{ - if (playback_state == AUDIO_ITF_STATE_STOPPED) { +static void start_play(uint8_t seq) { + if (playback_state == AUDIO_ITF_STATE_STOPPED) { #ifdef FREQ_RESP_EQ - freq_resp_eq_init(); + freq_resp_eq_init(); #endif #ifdef DELAY_STREAM_OPEN - usb_audio_open_codec_stream(AUD_STREAM_PLAYBACK, AUDIO_STREAM_REQ_USB); + usb_audio_open_codec_stream(AUD_STREAM_PLAYBACK, AUDIO_STREAM_REQ_USB); #endif #ifdef NOISE_GATING - last_high_signal_time = hal_sys_timer_get(); + last_high_signal_time = hal_sys_timer_get(); #ifdef NOISE_REDUCTION - last_nr_restore_time = hal_sys_timer_get(); + last_nr_restore_time = hal_sys_timer_get(); #endif #endif - usb_audio_start_codec_stream(AUD_STREAM_PLAYBACK, AUDIO_STREAM_REQ_USB); + usb_audio_start_codec_stream(AUD_STREAM_PLAYBACK, AUDIO_STREAM_REQ_USB); - playback_state = AUDIO_ITF_STATE_STARTED; - } + playback_state = AUDIO_ITF_STATE_STARTED; + } - codec_play_seq = seq; - playback_paused = 0; + codec_play_seq = seq; + playback_paused = 0; - usb_audio_update_freq(); + usb_audio_update_freq(); } -static void usb_audio_cmd_start_play(uint8_t seq) -{ +static void usb_audio_cmd_start_play(uint8_t seq) { #if defined(USB_AUDIO_DYN_CFG) && defined(USB_AUDIO_UAC2) - usb_audio_update_codec_stream(AUD_STREAM_PLAYBACK); + usb_audio_update_codec_stream(AUD_STREAM_PLAYBACK); #endif - start_play(seq); + start_play(seq); } -static void usb_audio_cmd_stop_play(void) -{ - if (playback_state == AUDIO_ITF_STATE_STARTED) { - usb_audio_stop_codec_stream(AUD_STREAM_PLAYBACK, AUDIO_STREAM_REQ_USB); +static void usb_audio_cmd_stop_play(void) { + if (playback_state == AUDIO_ITF_STATE_STARTED) { + usb_audio_stop_codec_stream(AUD_STREAM_PLAYBACK, AUDIO_STREAM_REQ_USB); #ifdef PA_ON_OFF_KEY - if (pa_on_off_muted) { - pa_on_off_muted = false; - if (mute_user_map == 0) { - usb_audio_codec_unmute(CODEC_MUTE_USER_ALL); - } - } + if (pa_on_off_muted) { + pa_on_off_muted = false; + if (mute_user_map == 0) { + usb_audio_codec_unmute(CODEC_MUTE_USER_ALL); + } + } #endif #ifdef NOISE_GATING - // Restore the noise gating status - if (mute_user_map & (1 << CODEC_MUTE_USER_NOISE_GATING)) { - usb_audio_codec_unmute(CODEC_MUTE_USER_NOISE_GATING); - } + // Restore the noise gating status + if (mute_user_map & (1 << CODEC_MUTE_USER_NOISE_GATING)) { + usb_audio_codec_unmute(CODEC_MUTE_USER_NOISE_GATING); + } #ifdef NOISE_REDUCTION - restore_noise_reduction_status(); + restore_noise_reduction_status(); #endif #endif #ifdef DELAY_STREAM_OPEN - usb_audio_close_codec_stream(AUD_STREAM_PLAYBACK, AUDIO_STREAM_REQ_USB); + usb_audio_close_codec_stream(AUD_STREAM_PLAYBACK, AUDIO_STREAM_REQ_USB); #endif - playback_paused = 0; - playback_state = AUDIO_ITF_STATE_STOPPED; + playback_paused = 0; + playback_state = AUDIO_ITF_STATE_STOPPED; #ifdef DSD_SUPPORT - if (codec_dsd_enabled) { - usb_audio_update_codec_stream(AUD_STREAM_PLAYBACK); - } -#endif + if (codec_dsd_enabled) { + usb_audio_update_codec_stream(AUD_STREAM_PLAYBACK); } +#endif + } - usb_audio_update_freq(); + usb_audio_update_freq(); } -static void start_capture(uint8_t seq) -{ - if (capture_state == AUDIO_ITF_STATE_STOPPED) { +static void start_capture(uint8_t seq) { + if (capture_state == AUDIO_ITF_STATE_STOPPED) { #ifdef SW_CAPTURE_RESAMPLE - // Check whether to start capture resample - capture_stream_resample_config(); + // Check whether to start capture resample + capture_stream_resample_config(); #endif #ifdef DELAY_STREAM_OPEN - usb_audio_open_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USB); + usb_audio_open_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USB); #endif - usb_audio_start_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USB); + usb_audio_start_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USB); - capture_state = AUDIO_ITF_STATE_STARTED; - } + capture_state = AUDIO_ITF_STATE_STARTED; + } - codec_cap_seq = seq; + codec_cap_seq = seq; - usb_audio_update_freq(); + usb_audio_update_freq(); } -static void usb_audio_cmd_start_capture(uint8_t seq) -{ - start_capture(seq); -} +static void usb_audio_cmd_start_capture(uint8_t seq) { start_capture(seq); } -static void usb_audio_cmd_stop_capture(void) -{ - if (capture_state == AUDIO_ITF_STATE_STARTED) { - usb_audio_stop_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USB); +static void usb_audio_cmd_stop_capture(void) { + if (capture_state == AUDIO_ITF_STATE_STARTED) { + usb_audio_stop_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USB); #ifdef DELAY_STREAM_OPEN - usb_audio_close_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USB); + usb_audio_close_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USB); #endif #ifdef SW_CAPTURE_RESAMPLE - if (resample_cap_enabled) { - audio_resample_ex_close(resample_id); - resample_cap_enabled = false; - } + if (resample_cap_enabled) { + audio_resample_ex_close(resample_id); + resample_cap_enabled = false; + } #endif - capture_state = AUDIO_ITF_STATE_STOPPED; - } + capture_state = AUDIO_ITF_STATE_STOPPED; + } - usb_audio_update_freq(); + usb_audio_update_freq(); } -static void usb_audio_cmd_set_volume(void) -{ +static void usb_audio_cmd_set_volume(void) { #ifndef USB_AUDIO_MULTIFUNC - playback_vol = new_playback_vol; + playback_vol = new_playback_vol; #endif - usb_audio_set_codec_volume(AUD_STREAM_PLAYBACK, playback_vol); + usb_audio_set_codec_volume(AUD_STREAM_PLAYBACK, playback_vol); #ifdef UNMUTE_WHEN_SET_VOL - // Unmute if muted before - if (mute_user_map & (1 << CODEC_MUTE_USER_CMD)) { - usb_audio_codec_unmute(CODEC_MUTE_USER_CMD); - } + // Unmute if muted before + if (mute_user_map & (1 << CODEC_MUTE_USER_CMD)) { + usb_audio_codec_unmute(CODEC_MUTE_USER_CMD); + } #endif } -static void usb_audio_cmd_set_cap_volume(void) -{ - capture_vol = new_capture_vol; +static void usb_audio_cmd_set_cap_volume(void) { + capture_vol = new_capture_vol; - usb_audio_set_codec_volume(AUD_STREAM_CAPTURE, capture_vol); + usb_audio_set_codec_volume(AUD_STREAM_CAPTURE, capture_vol); } -static void usb_audio_cmd_mute_ctrl(void) -{ - uint8_t mute; +static void usb_audio_cmd_mute_ctrl(void) { + uint8_t mute; #ifdef USB_AUDIO_MULTIFUNC - mute = new_mute_state && new_mute2_state; + mute = new_mute_state && new_mute2_state; #else - mute = new_mute_state; + mute = new_mute_state; #endif - if (mute) { - usb_audio_codec_mute(CODEC_MUTE_USER_CMD); - } else { - usb_audio_codec_unmute(CODEC_MUTE_USER_CMD); + if (mute) { + usb_audio_codec_mute(CODEC_MUTE_USER_CMD); + } else { + usb_audio_codec_unmute(CODEC_MUTE_USER_CMD); + } +} + +static void usb_audio_cmd_cap_mute_ctrl(void) { + uint8_t mute; + + mute = new_cap_mute_state; + + af_stream_mute(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, mute); +} + +static void usb_audio_cmd_usb_state(enum AUDIO_CMD_T cmd) { + usb_audio_cmd_stop_capture(); + usb_audio_cmd_stop_play(); + + if (cmd == AUDIO_CMD_USB_RESET || cmd == AUDIO_CMD_USB_WAKEUP) { + usb_audio_acquire_freq(); + if (cmd == AUDIO_CMD_USB_RESET) { + usb_audio_term_streams(AUDIO_STREAM_REQ_USB); } + usb_audio_reset_codec_stream_state(cmd == AUDIO_CMD_USB_RESET); + usb_audio_init_streams(AUDIO_STREAM_REQ_USB); + } else if (cmd == AUDIO_CMD_USB_DISCONNECT || cmd == AUDIO_CMD_USB_SLEEP) { + usb_audio_term_streams(AUDIO_STREAM_REQ_USB); + usb_audio_reset_codec_stream_state(cmd == AUDIO_CMD_USB_DISCONNECT); + if (cmd == AUDIO_CMD_USB_DISCONNECT || usb_configured) { + usb_audio_release_freq(); + } + } else if (cmd == AUDIO_CMD_USB_CONFIG) { + usb_configured = 1; + usb_audio_reset_codec_stream_state(true); + } } -static void usb_audio_cmd_cap_mute_ctrl(void) -{ - uint8_t mute; +static void usb_audio_cmd_recv_pause(uint8_t seq) { + TRACE(3, "%s: Recv pause: seq=%u usb_recv_seq=%u", __FUNCTION__, seq, + usb_recv_seq); - mute = new_cap_mute_state; - - af_stream_mute(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, mute); -} - -static void usb_audio_cmd_usb_state(enum AUDIO_CMD_T cmd) -{ - usb_audio_cmd_stop_capture(); + if (seq == usb_recv_seq) { usb_audio_cmd_stop_play(); - - if (cmd == AUDIO_CMD_USB_RESET || cmd == AUDIO_CMD_USB_WAKEUP) { - usb_audio_acquire_freq(); - if (cmd == AUDIO_CMD_USB_RESET) { - usb_audio_term_streams(AUDIO_STREAM_REQ_USB); - } - usb_audio_reset_codec_stream_state(cmd == AUDIO_CMD_USB_RESET); - usb_audio_init_streams(AUDIO_STREAM_REQ_USB); - } else if (cmd == AUDIO_CMD_USB_DISCONNECT || cmd == AUDIO_CMD_USB_SLEEP) { - usb_audio_term_streams(AUDIO_STREAM_REQ_USB); - usb_audio_reset_codec_stream_state(cmd == AUDIO_CMD_USB_DISCONNECT); - if (cmd == AUDIO_CMD_USB_DISCONNECT || usb_configured) { - usb_audio_release_freq(); - } - } else if (cmd == AUDIO_CMD_USB_CONFIG) { - usb_configured = 1; - usb_audio_reset_codec_stream_state(true); - } + playback_paused = 1; + } } -static void usb_audio_cmd_recv_pause(uint8_t seq) -{ - TRACE(3,"%s: Recv pause: seq=%u usb_recv_seq=%u", __FUNCTION__, seq, usb_recv_seq); +static void usb_audio_cmd_recv_continue(uint8_t seq) { + TRACE(3, "%s: Recv continue: seq=%u usb_recv_seq=%u", __FUNCTION__, seq, + usb_recv_seq); - if (seq == usb_recv_seq) { - usb_audio_cmd_stop_play(); - playback_paused = 1; - } -} - -static void usb_audio_cmd_recv_continue(uint8_t seq) -{ - TRACE(3,"%s: Recv continue: seq=%u usb_recv_seq=%u", __FUNCTION__, seq, usb_recv_seq); - - if (seq == usb_recv_seq && playback_paused) { - start_play(seq); - //playback_paused = 0; - } + if (seq == usb_recv_seq && playback_paused) { + start_play(seq); + // playback_paused = 0; + } } #ifdef USB_AUDIO_DYN_CFG -static void usb_audio_cmd_set_playback_rate(uint8_t seq, uint8_t index) -{ +static void usb_audio_cmd_set_playback_rate(uint8_t seq, uint8_t index) { #ifndef USB_AUDIO_UAC2 - if (seq != usb_recv_seq) { - TRACE(3,"%s: Bad seq: seq=%u usb_recv_seq=%u", __FUNCTION__, seq, usb_recv_seq); - return; - } + if (seq != usb_recv_seq) { + TRACE(3, "%s: Bad seq: seq=%u usb_recv_seq=%u", __FUNCTION__, seq, + usb_recv_seq); + return; + } #endif - usb_audio_update_codec_stream(AUD_STREAM_PLAYBACK); + usb_audio_update_codec_stream(AUD_STREAM_PLAYBACK); #ifndef USB_AUDIO_UAC2 - start_play(seq); + start_play(seq); #endif } -static void usb_audio_cmd_set_capture_rate(uint8_t seq, uint8_t index) -{ +static void usb_audio_cmd_set_capture_rate(uint8_t seq, uint8_t index) { #ifndef USB_AUDIO_UAC2 - if (seq != usb_send_seq) { - TRACE(3,"%s: Bad seq: seq=%u usb_send_seq=%u", __FUNCTION__, seq, usb_send_seq); - return; - } + if (seq != usb_send_seq) { + TRACE(3, "%s: Bad seq: seq=%u usb_send_seq=%u", __FUNCTION__, seq, + usb_send_seq); + return; + } #endif - usb_audio_update_codec_stream(AUD_STREAM_CAPTURE); + usb_audio_update_codec_stream(AUD_STREAM_CAPTURE); #ifndef USB_AUDIO_UAC2 - start_capture(seq); + start_capture(seq); #endif } #endif -static void usb_audio_cmd_reset_codec(void) -{ - TRACE(1,"%s: RESET CODEC", __FUNCTION__); +static void usb_audio_cmd_reset_codec(void) { + TRACE(1, "%s: RESET CODEC", __FUNCTION__); - // Regarding PLL reconfiguration, stream stop and start are enough. - // Complete DAC/ADC reset (including analog parts) can be achieved by - // stream close and open, which need to invoke explicitly here if - // DELAY_STREAM_OPEN is not defined. + // Regarding PLL reconfiguration, stream stop and start are enough. + // Complete DAC/ADC reset (including analog parts) can be achieved by + // stream close and open, which need to invoke explicitly here if + // DELAY_STREAM_OPEN is not defined. - if (codec_stream_map[AUD_STREAM_CAPTURE][AUDIO_STREAM_STARTED]) { - set_codec_config_status(CODEC_CONFIG_LOCK_RESTART_CAP, true); - usb_audio_stop_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USER_ALL); - } + if (codec_stream_map[AUD_STREAM_CAPTURE][AUDIO_STREAM_STARTED]) { + set_codec_config_status(CODEC_CONFIG_LOCK_RESTART_CAP, true); + usb_audio_stop_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USER_ALL); + } - if (codec_stream_map[AUD_STREAM_PLAYBACK][AUDIO_STREAM_STARTED]) { - set_codec_config_status(CODEC_CONFIG_LOCK_RESTART_PLAY, true); - usb_audio_stop_codec_stream(AUD_STREAM_PLAYBACK, AUDIO_STREAM_REQ_USER_ALL); - } + if (codec_stream_map[AUD_STREAM_PLAYBACK][AUDIO_STREAM_STARTED]) { + set_codec_config_status(CODEC_CONFIG_LOCK_RESTART_PLAY, true); + usb_audio_stop_codec_stream(AUD_STREAM_PLAYBACK, AUDIO_STREAM_REQ_USER_ALL); + } - rate_tune_ratio[AUD_STREAM_PLAYBACK] = 0; - rate_tune_ratio[AUD_STREAM_CAPTURE] = 0; + rate_tune_ratio[AUD_STREAM_PLAYBACK] = 0; + rate_tune_ratio[AUD_STREAM_CAPTURE] = 0; #ifdef __AUDIO_RESAMPLE__ #ifdef PLL_TUNE_SAMPLE_RATE - af_codec_tune_resample_rate(AUD_STREAM_PLAYBACK, rate_tune_ratio[AUD_STREAM_PLAYBACK]); - af_codec_tune_resample_rate(AUD_STREAM_CAPTURE, rate_tune_ratio[AUD_STREAM_CAPTURE]); + af_codec_tune_resample_rate(AUD_STREAM_PLAYBACK, + rate_tune_ratio[AUD_STREAM_PLAYBACK]); + af_codec_tune_resample_rate(AUD_STREAM_CAPTURE, + rate_tune_ratio[AUD_STREAM_CAPTURE]); #elif defined(PLL_TUNE_XTAL) - af_codec_tune_xtal(rate_tune_ratio[AUD_STREAM_PLAYBACK]); + af_codec_tune_xtal(rate_tune_ratio[AUD_STREAM_PLAYBACK]); #endif #else - af_codec_tune_pll(rate_tune_ratio[AUD_STREAM_PLAYBACK]); + af_codec_tune_pll(rate_tune_ratio[AUD_STREAM_PLAYBACK]); #endif - if (codec_stream_map[AUD_STREAM_PLAYBACK][AUDIO_STREAM_STARTED]) { - usb_audio_start_codec_stream(AUD_STREAM_PLAYBACK, AUDIO_STREAM_REQ_USER_ALL); - set_codec_config_status(CODEC_CONFIG_LOCK_RESTART_PLAY, false); - } + if (codec_stream_map[AUD_STREAM_PLAYBACK][AUDIO_STREAM_STARTED]) { + usb_audio_start_codec_stream(AUD_STREAM_PLAYBACK, + AUDIO_STREAM_REQ_USER_ALL); + set_codec_config_status(CODEC_CONFIG_LOCK_RESTART_PLAY, false); + } - if (codec_stream_map[AUD_STREAM_CAPTURE][AUDIO_STREAM_STARTED]) { - usb_audio_start_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USER_ALL); - set_codec_config_status(CODEC_CONFIG_LOCK_RESTART_CAP, false); - } + if (codec_stream_map[AUD_STREAM_CAPTURE][AUDIO_STREAM_STARTED]) { + usb_audio_start_codec_stream(AUD_STREAM_CAPTURE, AUDIO_STREAM_REQ_USER_ALL); + set_codec_config_status(CODEC_CONFIG_LOCK_RESTART_CAP, false); + } } #ifdef NOISE_GATING -static void usb_audio_cmd_noise_gating(void) -{ - uint32_t lock; - enum NOISE_GATING_CMD_T cmd; +static void usb_audio_cmd_noise_gating(void) { + uint32_t lock; + enum NOISE_GATING_CMD_T cmd; - lock = int_lock(); - cmd = noise_gating_cmd; - noise_gating_cmd = NOISE_GATING_CMD_NULL; - int_unlock(lock); + lock = int_lock(); + cmd = noise_gating_cmd; + noise_gating_cmd = NOISE_GATING_CMD_NULL; + int_unlock(lock); - TRACE(3,"%s: cmd=%d map=0x%02X", __FUNCTION__, cmd, mute_user_map); + TRACE(3, "%s: cmd=%d map=0x%02X", __FUNCTION__, cmd, mute_user_map); - if (cmd == NOISE_GATING_CMD_MUTE) { - if ((mute_user_map & (1 << CODEC_MUTE_USER_NOISE_GATING)) == 0) { - usb_audio_codec_mute(CODEC_MUTE_USER_NOISE_GATING); - } - } else if (cmd == NOISE_GATING_CMD_UNMUTE) { - if (mute_user_map & (1 << CODEC_MUTE_USER_NOISE_GATING)) { - usb_audio_codec_unmute(CODEC_MUTE_USER_NOISE_GATING); - } + if (cmd == NOISE_GATING_CMD_MUTE) { + if ((mute_user_map & (1 << CODEC_MUTE_USER_NOISE_GATING)) == 0) { + usb_audio_codec_mute(CODEC_MUTE_USER_NOISE_GATING); } + } else if (cmd == NOISE_GATING_CMD_UNMUTE) { + if (mute_user_map & (1 << CODEC_MUTE_USER_NOISE_GATING)) { + usb_audio_codec_unmute(CODEC_MUTE_USER_NOISE_GATING); + } + } } #ifdef NOISE_REDUCTION -static void restore_noise_reduction_status(void) -{ - if (nr_active) { - nr_active = false; - af_codec_set_noise_reduction(false); - } - prev_samp_positive[0] = prev_samp_positive[1] = false; - memset(prev_zero_diff, 0, sizeof(prev_zero_diff)); - memset(cur_zero_diff, 0, sizeof(cur_zero_diff)); - nr_cont_cnt = 0; +static void restore_noise_reduction_status(void) { + if (nr_active) { + nr_active = false; + af_codec_set_noise_reduction(false); + } + prev_samp_positive[0] = prev_samp_positive[1] = false; + memset(prev_zero_diff, 0, sizeof(prev_zero_diff)); + memset(cur_zero_diff, 0, sizeof(cur_zero_diff)); + nr_cont_cnt = 0; } -static void usb_audio_cmd_noise_reduction(void) -{ - uint32_t lock; - enum NOISE_REDUCTION_CMD_T cmd; +static void usb_audio_cmd_noise_reduction(void) { + uint32_t lock; + enum NOISE_REDUCTION_CMD_T cmd; - lock = int_lock(); - cmd = noise_reduction_cmd; - noise_reduction_cmd = NOISE_REDUCTION_CMD_NULL; - int_unlock(lock); + lock = int_lock(); + cmd = noise_reduction_cmd; + noise_reduction_cmd = NOISE_REDUCTION_CMD_NULL; + int_unlock(lock); - TRACE(2,"%s: cmd=%d", __FUNCTION__, cmd); + TRACE(2, "%s: cmd=%d", __FUNCTION__, cmd); - if (cmd == NOISE_REDUCTION_CMD_FIRE) { - nr_active = true; - af_codec_set_noise_reduction(true); - } else if (cmd == NOISE_REDUCTION_CMD_RESTORE) { - nr_active = false; - af_codec_set_noise_reduction(false); - } + if (cmd == NOISE_REDUCTION_CMD_FIRE) { + nr_active = true; + af_codec_set_noise_reduction(true); + } else if (cmd == NOISE_REDUCTION_CMD_RESTORE) { + nr_active = false; + af_codec_set_noise_reduction(false); + } } #endif #endif -static void usb_audio_cmd_tune_rate(enum AUD_STREAM_T stream) -{ +static void usb_audio_cmd_tune_rate(enum AUD_STREAM_T stream) { #ifdef __AUDIO_RESAMPLE__ #ifdef PLL_TUNE_SAMPLE_RATE - bool update_play, update_cap; + bool update_play, update_cap; - update_play = true; - update_cap = false; + update_play = true; + update_cap = false; #ifdef UAUD_SYNC_STREAM_TARGET - if (stream == AUD_STREAM_PLAYBACK) { - update_play = true; - update_cap = false; - } else { - update_play = false; - update_cap = true; - } -#else + if (stream == AUD_STREAM_PLAYBACK) { update_play = true; + update_cap = false; + } else { + update_play = false; update_cap = true; + } +#else + update_play = true; + update_cap = true; #endif #ifdef SW_RESAMPLE - if (update_play) { - audio_resample_ex_set_ratio_step(play_resample_id, nominal_ratio_step * rate_tune_ratio[AUD_STREAM_PLAYBACK]); - } - if (update_cap) { - audio_resample_ex_set_ratio_step(cap_resample_id, nominal_ratio_step * rate_tune_ratio[AUD_STREAM_CAPTURE]); - } + if (update_play) { + audio_resample_ex_set_ratio_step(play_resample_id, + nominal_ratio_step * + rate_tune_ratio[AUD_STREAM_PLAYBACK]); + } + if (update_cap) { + audio_resample_ex_set_ratio_step(cap_resample_id, + nominal_ratio_step * + rate_tune_ratio[AUD_STREAM_CAPTURE]); + } #else - if (update_play) { - af_codec_tune_resample_rate(AUD_STREAM_PLAYBACK, rate_tune_ratio[AUD_STREAM_PLAYBACK]); - } - if (update_cap) { - af_codec_tune_resample_rate(AUD_STREAM_CAPTURE, rate_tune_ratio[AUD_STREAM_CAPTURE]); - } + if (update_play) { + af_codec_tune_resample_rate(AUD_STREAM_PLAYBACK, + rate_tune_ratio[AUD_STREAM_PLAYBACK]); + } + if (update_cap) { + af_codec_tune_resample_rate(AUD_STREAM_CAPTURE, + rate_tune_ratio[AUD_STREAM_CAPTURE]); + } #endif #elif defined(PLL_TUNE_XTAL) - af_codec_tune_xtal(rate_tune_ratio[AUD_STREAM_PLAYBACK]); + af_codec_tune_xtal(rate_tune_ratio[AUD_STREAM_PLAYBACK]); #endif -#else // !__AUDIO_RESAMPLE__ - af_codec_tune_pll(rate_tune_ratio[AUD_STREAM_PLAYBACK]); +#else // !__AUDIO_RESAMPLE__ + af_codec_tune_pll(rate_tune_ratio[AUD_STREAM_PLAYBACK]); #endif // !__AUDIO_RESAMPLE__ } #ifdef DSD_SUPPORT -static void usb_audio_cmd_set_dsd_cfg(void) -{ - if (codec_dsd_enabled != usb_dsd_enabled) { - TRACE(3,"%s: %d => %d", __FUNCTION__, codec_dsd_enabled, usb_dsd_enabled); - usb_audio_update_codec_stream(AUD_STREAM_PLAYBACK); - } +static void usb_audio_cmd_set_dsd_cfg(void) { + if (codec_dsd_enabled != usb_dsd_enabled) { + TRACE(3, "%s: %d => %d", __FUNCTION__, codec_dsd_enabled, usb_dsd_enabled); + usb_audio_update_codec_stream(AUD_STREAM_PLAYBACK); + } } #endif #ifdef PERF_TEST_POWER_KEY -static void test_cmd_perf_test_power(void) -{ - perft_power_type++; - if (perft_power_type >= HAL_CODEC_PERF_TEST_QTY) { - perft_power_type = 0; - } +static void test_cmd_perf_test_power(void) { + perft_power_type++; + if (perft_power_type >= HAL_CODEC_PERF_TEST_QTY) { + perft_power_type = 0; + } - TRACE(2,"%s: %d", __FUNCTION__, perft_power_type); + TRACE(2, "%s: %d", __FUNCTION__, perft_power_type); - af_codec_set_perf_test_power(perft_power_type); + af_codec_set_perf_test_power(perft_power_type); } #endif #ifdef PA_ON_OFF_KEY -static void test_cmd_pa_on_off(void) -{ - pa_on_off_muted = !pa_on_off_muted; +static void test_cmd_pa_on_off(void) { + pa_on_off_muted = !pa_on_off_muted; - TRACE(2,"%s: %d", __FUNCTION__, pa_on_off_muted); + TRACE(2, "%s: %d", __FUNCTION__, pa_on_off_muted); - if (pa_on_off_muted) { - usb_audio_codec_mute(CODEC_MUTE_USER_ALL); - } else { - usb_audio_codec_unmute(CODEC_MUTE_USER_ALL); + if (pa_on_off_muted) { + usb_audio_codec_mute(CODEC_MUTE_USER_ALL); + } else { + usb_audio_codec_unmute(CODEC_MUTE_USER_ALL); #ifdef PERF_TEST_POWER_KEY - af_codec_set_perf_test_power(perft_power_type); + af_codec_set_perf_test_power(perft_power_type); #endif - } + } } #endif -static void usb_audio_cmd_handler(void *param) -{ - uint32_t data; - enum AUDIO_CMD_T cmd; - uint8_t seq; - uint8_t POSSIBLY_UNUSED arg; +static void usb_audio_cmd_handler(void *param) { + uint32_t data; + enum AUDIO_CMD_T cmd; + uint8_t seq; + uint8_t POSSIBLY_UNUSED arg; - hal_cpu_wake_unlock(USB_AUDIO_CPU_WAKE_USER); + hal_cpu_wake_unlock(USB_AUDIO_CPU_WAKE_USER); - while (safe_queue_get(&cmd_queue, &data) == 0) { - cmd = EXTRACT_CMD(data); - seq = EXTRACT_SEQ(data); - arg = EXTRACT_ARG(data); - TRACE(4,"%s: cmd=%d seq=%d arg=%d", __FUNCTION__, cmd, seq, arg); + while (safe_queue_get(&cmd_queue, &data) == 0) { + cmd = EXTRACT_CMD(data); + seq = EXTRACT_SEQ(data); + arg = EXTRACT_ARG(data); + TRACE(4, "%s: cmd=%d seq=%d arg=%d", __FUNCTION__, cmd, seq, arg); - switch (cmd) { - case AUDIO_CMD_START_PLAY: - usb_audio_cmd_start_play(seq); - break; + switch (cmd) { + case AUDIO_CMD_START_PLAY: + usb_audio_cmd_start_play(seq); + break; - case AUDIO_CMD_STOP_PLAY: - usb_audio_cmd_stop_play(); - break; + case AUDIO_CMD_STOP_PLAY: + usb_audio_cmd_stop_play(); + break; - case AUDIO_CMD_START_CAPTURE: - usb_audio_cmd_start_capture(seq); - break; + case AUDIO_CMD_START_CAPTURE: + usb_audio_cmd_start_capture(seq); + break; - case AUDIO_CMD_STOP_CAPTURE: - usb_audio_cmd_stop_capture(); - break; + case AUDIO_CMD_STOP_CAPTURE: + usb_audio_cmd_stop_capture(); + break; - case AUDIO_CMD_SET_VOLUME: - usb_audio_cmd_set_volume(); - break; + case AUDIO_CMD_SET_VOLUME: + usb_audio_cmd_set_volume(); + break; - case AUDIO_CMD_SET_CAP_VOLUME: - usb_audio_cmd_set_cap_volume(); - break; + case AUDIO_CMD_SET_CAP_VOLUME: + usb_audio_cmd_set_cap_volume(); + break; - case AUDIO_CMD_MUTE_CTRL: - usb_audio_cmd_mute_ctrl(); - break; + case AUDIO_CMD_MUTE_CTRL: + usb_audio_cmd_mute_ctrl(); + break; - case AUDIO_CMD_CAP_MUTE_CTRL: - usb_audio_cmd_cap_mute_ctrl(); - break; + case AUDIO_CMD_CAP_MUTE_CTRL: + usb_audio_cmd_cap_mute_ctrl(); + break; - case AUDIO_CMD_USB_RESET: - case AUDIO_CMD_USB_DISCONNECT: - case AUDIO_CMD_USB_CONFIG: - case AUDIO_CMD_USB_SLEEP: - case AUDIO_CMD_USB_WAKEUP: - usb_audio_cmd_usb_state(cmd); - break; + case AUDIO_CMD_USB_RESET: + case AUDIO_CMD_USB_DISCONNECT: + case AUDIO_CMD_USB_CONFIG: + case AUDIO_CMD_USB_SLEEP: + case AUDIO_CMD_USB_WAKEUP: + usb_audio_cmd_usb_state(cmd); + break; - case AUDIO_CMD_RECV_PAUSE: - usb_audio_cmd_recv_pause(seq); - break; - case AUDIO_CMD_RECV_CONTINUE: - usb_audio_cmd_recv_continue(seq); - break; + case AUDIO_CMD_RECV_PAUSE: + usb_audio_cmd_recv_pause(seq); + break; + case AUDIO_CMD_RECV_CONTINUE: + usb_audio_cmd_recv_continue(seq); + break; #ifdef USB_AUDIO_DYN_CFG - case AUDIO_CMD_SET_RECV_RATE: - usb_audio_cmd_set_playback_rate(seq, arg); - break; - case AUDIO_CMD_SET_SEND_RATE: - usb_audio_cmd_set_capture_rate(seq, arg); - break; + case AUDIO_CMD_SET_RECV_RATE: + usb_audio_cmd_set_playback_rate(seq, arg); + break; + case AUDIO_CMD_SET_SEND_RATE: + usb_audio_cmd_set_capture_rate(seq, arg); + break; #endif - case AUDIO_CMD_RESET_CODEC: - usb_audio_cmd_reset_codec(); - break; + case AUDIO_CMD_RESET_CODEC: + usb_audio_cmd_reset_codec(); + break; #ifdef NOISE_GATING - case AUDIO_CMD_NOISE_GATING: - usb_audio_cmd_noise_gating(); - break; + case AUDIO_CMD_NOISE_GATING: + usb_audio_cmd_noise_gating(); + break; #ifdef NOISE_REDUCTION - case AUDIO_CMD_NOISE_REDUCTION: - usb_audio_cmd_noise_reduction(); - break; + case AUDIO_CMD_NOISE_REDUCTION: + usb_audio_cmd_noise_reduction(); + break; #endif #endif - case AUDIO_CMD_TUNE_RATE: - usb_audio_cmd_tune_rate((enum AUD_STREAM_T)arg); - break; + case AUDIO_CMD_TUNE_RATE: + usb_audio_cmd_tune_rate((enum AUD_STREAM_T)arg); + break; #ifdef DSD_SUPPORT - case AUDIO_CMD_SET_DSD_CFG: - usb_audio_cmd_set_dsd_cfg(); - break; + case AUDIO_CMD_SET_DSD_CFG: + usb_audio_cmd_set_dsd_cfg(); + break; #endif #ifdef PERF_TEST_POWER_KEY - case TEST_CMD_PERF_TEST_POWER: - test_cmd_perf_test_power(); - break; + case TEST_CMD_PERF_TEST_POWER: + test_cmd_perf_test_power(); + break; #endif #ifdef PA_ON_OFF_KEY - case TEST_CMD_PA_ON_OFF: - test_cmd_pa_on_off(); - break; + case TEST_CMD_PA_ON_OFF: + test_cmd_pa_on_off(); + break; #endif - default: - ASSERT(false, "%s: Invalid cmd %d", __FUNCTION__, cmd); - break; - } + default: + ASSERT(false, "%s: Invalid cmd %d", __FUNCTION__, cmd); + break; } + } } -void usb_audio_app_init(const struct USB_AUDIO_BUF_CFG *cfg) -{ +void usb_audio_app_init(const struct USB_AUDIO_BUF_CFG *cfg) { #ifdef USB_AUDIO_DYN_CFG - ASSERT(cfg->play_size / MAX_FRAME_SIZE_PLAYBACK < cfg->recv_size / MAX_FRAME_SIZE_RECV, - "%s: play frames %u should < recv frames %u", __FUNCTION__, - cfg->play_size / MAX_FRAME_SIZE_PLAYBACK, cfg->recv_size / MAX_FRAME_SIZE_RECV); - ASSERT(cfg->cap_size / MAX_FRAME_SIZE_CAPTURE < cfg->send_size / MAX_FRAME_SIZE_SEND, - "%s: cap frames %u should < send frames %u", __FUNCTION__, - cfg->cap_size / MAX_FRAME_SIZE_CAPTURE, cfg->send_size / MAX_FRAME_SIZE_SEND); + ASSERT(cfg->play_size / MAX_FRAME_SIZE_PLAYBACK < + cfg->recv_size / MAX_FRAME_SIZE_RECV, + "%s: play frames %u should < recv frames %u", __FUNCTION__, + cfg->play_size / MAX_FRAME_SIZE_PLAYBACK, + cfg->recv_size / MAX_FRAME_SIZE_RECV); + ASSERT(cfg->cap_size / MAX_FRAME_SIZE_CAPTURE < + cfg->send_size / MAX_FRAME_SIZE_SEND, + "%s: cap frames %u should < send frames %u", __FUNCTION__, + cfg->cap_size / MAX_FRAME_SIZE_CAPTURE, + cfg->send_size / MAX_FRAME_SIZE_SEND); #else - ASSERT(cfg->play_size / FRAME_SIZE_PLAYBACK < cfg->recv_size / FRAME_SIZE_RECV, - "%s: play frames %u should < recv frames %u", __FUNCTION__, - cfg->play_size / FRAME_SIZE_PLAYBACK, cfg->recv_size / FRAME_SIZE_RECV); - ASSERT(cfg->cap_size / FRAME_SIZE_CAPTURE < cfg->send_size / FRAME_SIZE_SEND, - "%s: cap frames %u should < send frames %u", __FUNCTION__, - cfg->cap_size / FRAME_SIZE_CAPTURE, cfg->send_size / FRAME_SIZE_SEND); + ASSERT( + cfg->play_size / FRAME_SIZE_PLAYBACK < cfg->recv_size / FRAME_SIZE_RECV, + "%s: play frames %u should < recv frames %u", __FUNCTION__, + cfg->play_size / FRAME_SIZE_PLAYBACK, cfg->recv_size / FRAME_SIZE_RECV); + ASSERT(cfg->cap_size / FRAME_SIZE_CAPTURE < cfg->send_size / FRAME_SIZE_SEND, + "%s: cap frames %u should < send frames %u", __FUNCTION__, + cfg->cap_size / FRAME_SIZE_CAPTURE, cfg->send_size / FRAME_SIZE_SEND); #endif #ifdef SW_CAPTURE_RESAMPLE - enum AUD_CHANNEL_NUM_T chans; - enum AUD_BITS_T bits; - uint8_t phase_coef_num; - uint32_t resamp_calc_size; + enum AUD_CHANNEL_NUM_T chans; + enum AUD_BITS_T bits; + uint8_t phase_coef_num; + uint32_t resamp_calc_size; - chans = get_capture_resample_chan_num(); - bits = sample_size_to_enum_capture(sample_size_cap); - // Max phase coef num - phase_coef_num = 100; + chans = get_capture_resample_chan_num(); + bits = sample_size_to_enum_capture(sample_size_cap); + // Max phase coef num + phase_coef_num = 100; - resamp_calc_size = audio_resample_ex_get_buffer_size(chans, bits, phase_coef_num); - ASSERT(cfg->resample_size > resamp_calc_size, - "%s: Resample size too small %u (should > %u)", __FUNCTION__, - cfg->resample_size, resamp_calc_size); + resamp_calc_size = + audio_resample_ex_get_buffer_size(chans, bits, phase_coef_num); + ASSERT(cfg->resample_size > resamp_calc_size, + "%s: Resample size too small %u (should > %u)", __FUNCTION__, + cfg->resample_size, resamp_calc_size); - resample_history_buf = (uint8_t *)ALIGN((uint32_t)cfg->resample_buf, 4); - resample_history_size = resamp_calc_size; - resample_input_buf = (uint8_t *)resample_history_buf + resample_history_size; - ASSERT(cfg->resample_buf + cfg->resample_size > resample_input_buf, - "%s: Resample size too small: %u", __FUNCTION__, cfg->resample_size); - resample_input_size = cfg->resample_buf + cfg->resample_size - resample_input_buf; + resample_history_buf = (uint8_t *)ALIGN((uint32_t)cfg->resample_buf, 4); + resample_history_size = resamp_calc_size; + resample_input_buf = (uint8_t *)resample_history_buf + resample_history_size; + ASSERT(cfg->resample_buf + cfg->resample_size > resample_input_buf, + "%s: Resample size too small: %u", __FUNCTION__, cfg->resample_size); + resample_input_size = + cfg->resample_buf + cfg->resample_size - resample_input_buf; #endif - playback_buf = cfg->play_buf; - capture_buf = cfg->cap_buf; - usb_recv_buf = cfg->recv_buf; - usb_send_buf = cfg->send_buf; - playback_eq_buf = cfg->eq_buf; - playback_eq_size = cfg->eq_size; + playback_buf = cfg->play_buf; + capture_buf = cfg->cap_buf; + usb_recv_buf = cfg->recv_buf; + usb_send_buf = cfg->send_buf; + playback_eq_buf = cfg->eq_buf; + playback_eq_size = cfg->eq_size; #if defined(USB_AUDIO_DYN_CFG) && defined(KEEP_SAME_LATENCY) - playback_max_size = cfg->play_size; - capture_max_size = cfg->cap_size; - usb_recv_max_size = cfg->recv_size; - usb_send_max_size = cfg->send_size; + playback_max_size = cfg->play_size; + capture_max_size = cfg->cap_size; + usb_recv_max_size = cfg->recv_size; + usb_send_max_size = cfg->send_size; #else - playback_size = cfg->play_size; - capture_size = cfg->cap_size; - usb_recv_size = cfg->recv_size; - usb_send_size = cfg->send_size; + playback_size = cfg->play_size; + capture_size = cfg->cap_size; + usb_recv_size = cfg->recv_size; + usb_send_size = cfg->send_size; #endif - playback_pos = 0; - usb_recv_rpos = 0; - usb_recv_wpos = cfg->recv_size / 2; - capture_pos = 0; - usb_send_rpos = cfg->send_size / 2; - usb_send_wpos = 0; + playback_pos = 0; + usb_recv_rpos = 0; + usb_recv_wpos = cfg->recv_size / 2; + capture_pos = 0; + usb_send_rpos = cfg->send_size / 2; + usb_send_wpos = 0; #ifdef USB_AUDIO_MULTIFUNC - usb_recv2_buf = cfg->recv2_buf; - usb_recv2_size = cfg->recv2_size; - usb_recv2_rpos = 0; - usb_recv2_wpos = cfg->recv2_size / 2; + usb_recv2_buf = cfg->recv2_buf; + usb_recv2_size = cfg->recv2_size; + usb_recv2_rpos = 0; + usb_recv2_wpos = cfg->recv2_size / 2; #endif - playback_info.id = 0; - playback_info.sync_thresh = DIFF_SYNC_THRESH_PLAYBACK; - playback_info.diff_avg_cnt = DIFF_AVG_CNT; + playback_info.id = 0; + playback_info.sync_thresh = DIFF_SYNC_THRESH_PLAYBACK; + playback_info.diff_avg_cnt = DIFF_AVG_CNT; #ifdef TARGET_TO_MAX_DIFF - playback_info.diff_target_enabled = true; - playback_info.max_target_ratio = MAX_TARGET_RATIO; - playback_info.time_to_ms = NULL; + playback_info.diff_target_enabled = true; + playback_info.max_target_ratio = MAX_TARGET_RATIO; + playback_info.time_to_ms = NULL; #endif - capture_info.id = 1; - capture_info.sync_thresh = DIFF_SYNC_THRESH_CAPTURE; - capture_info.diff_avg_cnt = DIFF_AVG_CNT; + capture_info.id = 1; + capture_info.sync_thresh = DIFF_SYNC_THRESH_CAPTURE; + capture_info.diff_avg_cnt = DIFF_AVG_CNT; #ifdef TARGET_TO_MAX_DIFF - capture_info.diff_target_enabled = true; - capture_info.max_target_ratio = MAX_TARGET_RATIO; - capture_info.time_to_ms = NULL; + capture_info.diff_target_enabled = true; + capture_info.max_target_ratio = MAX_TARGET_RATIO; + capture_info.time_to_ms = NULL; #endif - safe_queue_init(&cmd_queue, cmd_list, CMD_LIST_SIZE); + safe_queue_init(&cmd_queue, cmd_list, CMD_LIST_SIZE); #ifdef USB_AUDIO_PWRKEY_TEST - hal_cmu_simu_set_val(0); + hal_cmu_simu_set_val(0); #endif } -void usb_audio_app_term(void) -{ - playback_buf = NULL; - playback_size = 0; - capture_buf = NULL; - capture_size = 0; - usb_recv_buf = NULL; - usb_recv_size = 0; - usb_send_buf = NULL; - usb_send_size = 0; +void usb_audio_app_term(void) { + playback_buf = NULL; + playback_size = 0; + capture_buf = NULL; + capture_size = 0; + usb_recv_buf = NULL; + usb_recv_size = 0; + usb_send_buf = NULL; + usb_send_size = 0; - playback_pos = 0; - usb_recv_rpos = 0; - usb_recv_wpos = 0; + playback_pos = 0; + usb_recv_rpos = 0; + usb_recv_wpos = 0; - capture_pos = 0; - usb_send_rpos = 0; - usb_send_wpos = 0; + capture_pos = 0; + usb_send_rpos = 0; + usb_send_wpos = 0; #ifdef USB_AUDIO_MULTIFUNC - usb_recv2_buf = NULL; - usb_recv2_size = 0; - usb_recv2_rpos = 0; - usb_recv2_wpos = 0; + usb_recv2_buf = NULL; + usb_recv2_size = 0; + usb_recv2_rpos = 0; + usb_recv2_wpos = 0; #endif } -void usb_audio_app(bool on) -{ - static const struct USB_AUDIO_CFG_T usb_audio_cfg = { - .recv_sample_rate = SAMPLE_RATE_RECV, - .send_sample_rate = SAMPLE_RATE_SEND, - .itf_callback = usb_audio_itf_callback, - .mute_callback = usb_audio_mute_callback, - .set_volume = usb_audio_set_volume, - .get_volume = usb_audio_get_volume, - .state_callback = usb_audio_state_control, - .xfer_callback = usb_audio_xfer_callback, +void usb_audio_app(bool on) { + static const struct USB_AUDIO_CFG_T usb_audio_cfg = { + .recv_sample_rate = SAMPLE_RATE_RECV, + .send_sample_rate = SAMPLE_RATE_SEND, + .itf_callback = usb_audio_itf_callback, + .mute_callback = usb_audio_mute_callback, + .set_volume = usb_audio_set_volume, + .get_volume = usb_audio_get_volume, + .state_callback = usb_audio_state_control, + .xfer_callback = usb_audio_xfer_callback, #if defined(ANDROID_ACCESSORY_SPEC) || defined(CFG_MIC_KEY) - // Applications are responsible for clearing HID events - .hid_send_callback = hid_data_send_handler, + // Applications are responsible for clearing HID events + .hid_send_callback = hid_data_send_handler, #else - // HID events will be cleared automatically once they are sent - .hid_send_callback = NULL, + // HID events will be cleared automatically once they are sent + .hid_send_callback = NULL, #endif #ifdef _VENDOR_MSG_SUPPT_ - .vendor_msg_callback = usb_vendor_callback, - .vendor_rx_buf = vendor_msg_rx_buf, - .vendor_rx_size = VENDOR_RX_BUF_SZ, + .vendor_msg_callback = usb_vendor_callback, + .vendor_rx_buf = vendor_msg_rx_buf, + .vendor_rx_size = VENDOR_RX_BUF_SZ, #endif - }; - static bool isRun = false; - int ret; + }; + static bool isRun = false; + int ret; - if (isRun==on) - return; - else - isRun=on; + if (isRun == on) + return; + else + isRun = on; - TRACE(2,"%s: on=%d", __FUNCTION__, on); + TRACE(2, "%s: on=%d", __FUNCTION__, on); - if (on) { - usb_audio_acquire_freq(); + if (on) { + usb_audio_acquire_freq(); - usb_audio_reset_usb_stream_state(true); - usb_audio_reset_codec_stream_state(true); + usb_audio_reset_usb_stream_state(true); + usb_audio_reset_codec_stream_state(true); #ifdef USB_AUDIO_DYN_CFG - sample_rate_recv = new_sample_rate_recv = usb_audio_cfg.recv_sample_rate; - sample_rate_send = new_sample_rate_send = usb_audio_cfg.send_sample_rate; - // Init codec sample rates after initializing usb sample rates - sample_rate_play = calc_play_sample_rate(sample_rate_recv); - sample_rate_cap = calc_cap_sample_rate(sample_rate_send, sample_rate_play); - // TODO: Check whether 16-bit sample is enabled - sample_size_recv = new_sample_size_recv = 2; + sample_rate_recv = new_sample_rate_recv = usb_audio_cfg.recv_sample_rate; + sample_rate_send = new_sample_rate_send = usb_audio_cfg.send_sample_rate; + // Init codec sample rates after initializing usb sample rates + sample_rate_play = calc_play_sample_rate(sample_rate_recv); + sample_rate_cap = calc_cap_sample_rate(sample_rate_send, sample_rate_play); + // TODO: Check whether 16-bit sample is enabled + sample_size_recv = new_sample_size_recv = 2; #ifndef AUDIO_PLAYBACK_24BIT - sample_size_play = 2; + sample_size_play = 2; #endif #ifdef KEEP_SAME_LATENCY - usb_recv_size = calc_usb_recv_size(sample_rate_recv, sample_size_recv); - usb_send_size = calc_usb_send_size(sample_rate_send); - playback_size = calc_playback_size(sample_rate_play); - capture_size = calc_capture_size(sample_rate_cap); + usb_recv_size = calc_usb_recv_size(sample_rate_recv, sample_size_recv); + usb_send_size = calc_usb_send_size(sample_rate_send); + playback_size = calc_playback_size(sample_rate_play); + capture_size = calc_capture_size(sample_rate_cap); #endif #endif - TRACE(3,"CODEC playback sample: rate=%u size=%u chan=%u", sample_rate_play, sample_size_play, CHAN_NUM_PLAYBACK); - TRACE(3,"CODEC capture sample: rate=%u size=%u chan=%u", sample_rate_cap, sample_size_cap, CHAN_NUM_CAPTURE); - TRACE(2,"USB recv sample: rate=%u size=%u", sample_rate_recv, sample_size_recv); - TRACE(2,"USB send sample: rate=%u size=%u", sample_rate_send, sample_size_send); + TRACE(3, "CODEC playback sample: rate=%u size=%u chan=%u", sample_rate_play, + sample_size_play, CHAN_NUM_PLAYBACK); + TRACE(3, "CODEC capture sample: rate=%u size=%u chan=%u", sample_rate_cap, + sample_size_cap, CHAN_NUM_CAPTURE); + TRACE(2, "USB recv sample: rate=%u size=%u", sample_rate_recv, + sample_size_recv); + TRACE(2, "USB send sample: rate=%u size=%u", sample_rate_send, + sample_size_send); - usb_audio_init_streams(AUDIO_STREAM_REQ_USB); + usb_audio_init_streams(AUDIO_STREAM_REQ_USB); - pmu_usb_config(PMU_USB_CONFIG_TYPE_DEVICE); - ret = usb_audio_open(&usb_audio_cfg); - ASSERT(ret == 0, "usb_audio_open failed: %d", ret); - } else { - usb_audio_close(); - pmu_usb_config(PMU_USB_CONFIG_TYPE_NONE); + pmu_usb_config(PMU_USB_CONFIG_TYPE_DEVICE); + ret = usb_audio_open(&usb_audio_cfg); + ASSERT(ret == 0, "usb_audio_open failed: %d", ret); + } else { + usb_audio_close(); + pmu_usb_config(PMU_USB_CONFIG_TYPE_NONE); - usb_audio_term_streams(AUDIO_STREAM_REQ_USB); + usb_audio_term_streams(AUDIO_STREAM_REQ_USB); - usb_audio_reset_usb_stream_state(true); - usb_audio_reset_codec_stream_state(true); + usb_audio_reset_usb_stream_state(true); + usb_audio_reset_codec_stream_state(true); - usb_audio_release_freq(); - } + usb_audio_release_freq(); + } } static void app_key_trace(uint32_t line, enum HAL_KEY_CODE_T code, - enum HAL_KEY_EVENT_T event, enum USB_AUDIO_HID_EVENT_T uevt, int state) -{ + enum HAL_KEY_EVENT_T event, + enum USB_AUDIO_HID_EVENT_T uevt, int state) { #ifdef KEY_TRACE - TRACE(5,"APPKEY/%u: code=%d event=%d uevt=%s state=%d", - line, code, event, usb_audio_get_hid_event_name(uevt), state); + TRACE(5, "APPKEY/%u: code=%d event=%d uevt=%s state=%d", line, code, event, + usb_audio_get_hid_event_name(uevt), state); #endif } -int usb_audio_app_key(enum HAL_KEY_CODE_T code, enum HAL_KEY_EVENT_T event) -{ - int i; - enum USB_AUDIO_HID_EVENT_T uevt; - int state; +int usb_audio_app_key(enum HAL_KEY_CODE_T code, enum HAL_KEY_EVENT_T event) { + int i; + enum USB_AUDIO_HID_EVENT_T uevt; + int state; - if (event == HAL_KEY_EVENT_CLICK && playback_state == AUDIO_ITF_STATE_STARTED) { + if (event == HAL_KEY_EVENT_CLICK && + playback_state == AUDIO_ITF_STATE_STARTED) { #ifdef PERF_TEST_POWER_KEY - if (code == PERF_TEST_POWER_KEY) { - enqueue_unique_cmd(TEST_CMD_PERF_TEST_POWER); - } + if (code == PERF_TEST_POWER_KEY) { + enqueue_unique_cmd(TEST_CMD_PERF_TEST_POWER); + } #endif #ifdef PA_ON_OFF_KEY - if (code == PA_ON_OFF_KEY) { - enqueue_unique_cmd(TEST_CMD_PA_ON_OFF); - } -#endif + if (code == PA_ON_OFF_KEY) { + enqueue_unique_cmd(TEST_CMD_PA_ON_OFF); } +#endif + } #ifdef USB_AUDIO_PWRKEY_TEST - if (code == HAL_KEY_CODE_PWR) { - uevt = hal_cmu_simu_get_val(); - if (uevt == 0) { - uevt = USB_AUDIO_HID_VOL_UP; - } -#if defined(ANDROID_ACCESSORY_SPEC) || defined(CFG_MIC_KEY) - if (event == HAL_KEY_EVENT_DOWN || event == HAL_KEY_EVENT_UP) { - state = (event != HAL_KEY_EVENT_UP); - app_key_trace(__LINE__, code, event, uevt, state); - usb_audio_hid_set_event(uevt, state); - } - // The key event has been processed - return 0; -#else - if (event == HAL_KEY_EVENT_CLICK) { - state = 1; - app_key_trace(__LINE__, code, event, uevt, state); - usb_audio_hid_set_event(uevt, state); - return 0; - } - // Let other applications check the key event - return 1; -#endif + if (code == HAL_KEY_CODE_PWR) { + uevt = hal_cmu_simu_get_val(); + if (uevt == 0) { + uevt = USB_AUDIO_HID_VOL_UP; } -#endif - - if (code != HAL_KEY_CODE_NONE) { - for (i = 0; i < ARRAY_SIZE(key_map); i++) { - if (key_map[i].key_code == code && (key_map[i].key_event_bitset & (1 << event))) { - break; - } - } - if (i < ARRAY_SIZE(key_map)) { - uevt = key_map[i].hid_event; - if (uevt != 0) { #if defined(ANDROID_ACCESSORY_SPEC) || defined(CFG_MIC_KEY) - state = (event != HAL_KEY_EVENT_UP); -#else - state = 1; -#endif - app_key_trace(__LINE__, code, event, uevt, state); - usb_audio_hid_set_event(uevt, state); - // The key event has been processed - return 0; - } - } + if (event == HAL_KEY_EVENT_DOWN || event == HAL_KEY_EVENT_UP) { + state = (event != HAL_KEY_EVENT_UP); + app_key_trace(__LINE__, code, event, uevt, state); + usb_audio_hid_set_event(uevt, state); + } + // The key event has been processed + return 0; +#else + if (event == HAL_KEY_EVENT_CLICK) { + state = 1; + app_key_trace(__LINE__, code, event, uevt, state); + usb_audio_hid_set_event(uevt, state); + return 0; } - // Let other applications check the key event return 1; +#endif + } +#endif + + if (code != HAL_KEY_CODE_NONE) { + for (i = 0; i < ARRAY_SIZE(key_map); i++) { + if (key_map[i].key_code == code && + (key_map[i].key_event_bitset & (1 << event))) { + break; + } + } + if (i < ARRAY_SIZE(key_map)) { + uevt = key_map[i].hid_event; + if (uevt != 0) { +#if defined(ANDROID_ACCESSORY_SPEC) || defined(CFG_MIC_KEY) + state = (event != HAL_KEY_EVENT_UP); +#else + state = 1; +#endif + app_key_trace(__LINE__, code, event, uevt, state); + usb_audio_hid_set_event(uevt, state); + // The key event has been processed + return 0; + } + } + } + + // Let other applications check the key event + return 1; } #ifdef ANC_APP @@ -6220,47 +6366,45 @@ static uint8_t anc_status = 0; static uint8_t anc_status_record = 0xff; #endif -void usb_audio_eq_loop(void) -{ +void usb_audio_eq_loop(void) { #ifdef ANC_APP - anc_status = anc_usb_app_get_status(); - if(anc_status_record != anc_status&&eq_opened == 1) - { - anc_status_record = anc_status; - TRACE(2,"[%s]anc_status = %d", __func__, anc_status); + anc_status = anc_usb_app_get_status(); + if (anc_status_record != anc_status && eq_opened == 1) { + anc_status_record = anc_status; + TRACE(2, "[%s]anc_status = %d", __func__, anc_status); #ifdef __SW_IIR_EQ_PROCESS__ - usb_audio_set_eq(AUDIO_EQ_TYPE_SW_IIR,usb_audio_get_eq_index(AUDIO_EQ_TYPE_SW_IIR,anc_status)); + usb_audio_set_eq(AUDIO_EQ_TYPE_SW_IIR, + usb_audio_get_eq_index(AUDIO_EQ_TYPE_SW_IIR, anc_status)); #endif #ifdef __HW_FIR_EQ_PROCESS__ - usb_audio_set_eq(AUDIO_EQ_TYPE_HW_FIR,usb_audio_get_eq_index(AUDIO_EQ_TYPE_HW_FIR,anc_status)); + usb_audio_set_eq(AUDIO_EQ_TYPE_HW_FIR, + usb_audio_get_eq_index(AUDIO_EQ_TYPE_HW_FIR, anc_status)); #endif #ifdef __HW_DAC_IIR_EQ_PROCESS__ - usb_audio_set_eq(AUDIO_EQ_TYPE_HW_DAC_IIR,usb_audio_get_eq_index(AUDIO_EQ_TYPE_HW_DAC_IIR,anc_status)); + usb_audio_set_eq( + AUDIO_EQ_TYPE_HW_DAC_IIR, + usb_audio_get_eq_index(AUDIO_EQ_TYPE_HW_DAC_IIR, anc_status)); #endif #ifdef __HW_IIR_EQ_PROCESS__ - usb_audio_set_eq(AUDIO_EQ_TYPE_HW_IIR,usb_audio_get_eq_index(AUDIO_EQ_TYPE_HW_IIR,anc_status)); + usb_audio_set_eq(AUDIO_EQ_TYPE_HW_IIR, + usb_audio_get_eq_index(AUDIO_EQ_TYPE_HW_IIR, anc_status)); #endif - } + } #endif } -void usb_audio_app_loop(void) -{ - usb_audio_cmd_handler(NULL); +void usb_audio_app_loop(void) { + usb_audio_cmd_handler(NULL); - usb_audio_eq_loop(); + usb_audio_eq_loop(); #ifndef RTOS - extern void af_thread(void const *argument); - af_thread(NULL); + extern void af_thread(void const *argument); + af_thread(NULL); #endif } -uint32_t usb_audio_get_capture_sample_rate(void) -{ - return sample_rate_cap; -} - +uint32_t usb_audio_get_capture_sample_rate(void) { return sample_rate_cap; } diff --git a/tests/anc_usb/usb_vendor_msg.c b/tests/anc_usb/usb_vendor_msg.c index 9064bd1..aed266e 100644 --- a/tests/anc_usb/usb_vendor_msg.c +++ b/tests/anc_usb/usb_vendor_msg.c @@ -1,17 +1,17 @@ #ifdef _VENDOR_MSG_SUPPT_ -#include -#include "stdlib.h" -#include -#include "hal_trace.h" -#include "crc32.h" -#include "hal_norflash.h" -#include "pmu.h" #include "cmsis.h" -#include "hal_cmu.h" -#include "tgt_hardware.h" -#include "hal_timer.h" +#include "crc32.h" #include "hal_bootmode.h" +#include "hal_cmu.h" +#include "hal_norflash.h" +#include "hal_timer.h" +#include "hal_trace.h" +#include "pmu.h" +#include "stdlib.h" +#include "tgt_hardware.h" +#include +#include #ifdef USB_EQ_TUNING #include "hal_cmd.h" #endif @@ -22,49 +22,49 @@ #include "usb_vendor_msg.h" -#define SYS_CHECK_VAL "1.1" +#define SYS_CHECK_VAL "1.1" -#define FACT_SEC_VER 2 -#define FACT_SEC_MAGIC 0xba80 +#define FACT_SEC_VER 2 +#define FACT_SEC_MAGIC 0xba80 typedef enum { - FACT_SEC_VER_MAGIC, - FACT_SEC_CRC, - - FACT_SEC_DATA_START, - FACT_SEC_SEQ = FACT_SEC_DATA_START, - FACT_SEC_PROD_SN, - FACT_SEC_END = FACT_SEC_PROD_SN + 8, - - FACT_SEC_NUM = 256 + FACT_SEC_VER_MAGIC, + FACT_SEC_CRC, + + FACT_SEC_DATA_START, + FACT_SEC_SEQ = FACT_SEC_DATA_START, + FACT_SEC_PROD_SN, + FACT_SEC_END = FACT_SEC_PROD_SN + 8, + + FACT_SEC_NUM = 256 } FACT_SEC_E; typedef enum { - PC_TOOL_CMD_IDLE, - PC_TOOL_CMD_GET_FW_VER, - PC_TOOL_CMD_GET_PROD_SN, -// QUERY_VOLTAGE, -// BURN_SN, - PC_TOOL_CMD_SYS_REBOOT, - PC_TOOL_CMD_SYS_SHUTDOWN, - PC_TOOL_CMD_PING, - PC_TOOL_CMD_CHECK, - PC_TOOL_CMD_FW_UPDATE, -#ifdef USB_EQ_TUNING - PC_TOOL_CMD_EQ_TUNING, + PC_TOOL_CMD_IDLE, + PC_TOOL_CMD_GET_FW_VER, + PC_TOOL_CMD_GET_PROD_SN, + // QUERY_VOLTAGE, + // BURN_SN, + PC_TOOL_CMD_SYS_REBOOT, + PC_TOOL_CMD_SYS_SHUTDOWN, + PC_TOOL_CMD_PING, + PC_TOOL_CMD_CHECK, + PC_TOOL_CMD_FW_UPDATE, +#ifdef USB_EQ_TUNING + PC_TOOL_CMD_EQ_TUNING, #endif -#ifdef USB_ANC_MC_EQ_TUNING - PC_TOOL_CMD_ANC_MC_EQ_TUNING, -#endif - PC_TOOL_CMD_NUM, -}PC_TOOL_CMD_E; +#ifdef USB_ANC_MC_EQ_TUNING + PC_TOOL_CMD_ANC_MC_EQ_TUNING, +#endif + PC_TOOL_CMD_NUM, +} PC_TOOL_CMD_E; -static char* s_pc_cmd_lst[PC_TOOL_CMD_NUM] = { +static char *s_pc_cmd_lst[PC_TOOL_CMD_NUM] = { " ", "QUERY_SW_VER", "QUERY_SN", -// "QUERY_VOL", -// "BURN_SN", + // "QUERY_VOL", + // "BURN_SN", "SYS_REBOOT", "SYS_SHUTDOWN", "PING_THROUGH_VENDOR", @@ -75,13 +75,13 @@ static char* s_pc_cmd_lst[PC_TOOL_CMD_NUM] = { #endif #ifdef USB_ANC_MC_EQ_TUNING "ANC_MC_EQ", -#endif +#endif }; static PC_TOOL_CMD_E s_cur_cmd = PC_TOOL_CMD_IDLE; -static uint8_t* s_sn_ptr; -static uint8_t* s_fw_ver_ptr; +static uint8_t *s_sn_ptr; +static uint8_t *s_fw_ver_ptr; static uint8_t s_sn_sz; static uint8_t s_fw_ver_sz; @@ -90,177 +90,172 @@ uint8_t vendor_msg_rx_buf[VENDOR_RX_BUF_SZ]; extern void analog_aud_codec_mute(void); -int WEAK vendor_get_sn_info(uint8_t **p_ptr, uint8_t *p_size) -{ - static const char sn[] = "SN-001"; +int WEAK vendor_get_sn_info(uint8_t **p_ptr, uint8_t *p_size) { + static const char sn[] = "SN-001"; - *p_ptr = (uint8_t *)sn; - *p_size = sizeof(sn) - 1; - return 0; + *p_ptr = (uint8_t *)sn; + *p_size = sizeof(sn) - 1; + return 0; } -int WEAK vendor_get_fw_ver_info(uint8_t **p_ptr, uint8_t *p_size) -{ - static const char ver[] = "VER-001"; +int WEAK vendor_get_fw_ver_info(uint8_t **p_ptr, uint8_t *p_size) { + static const char ver[] = "VER-001"; - *p_ptr = (uint8_t *)ver; - *p_size = sizeof(ver) - 1; - return 0; + *p_ptr = (uint8_t *)ver; + *p_size = sizeof(ver) - 1; + return 0; } -void vendor_info_init (void) -{ - vendor_get_sn_info(&s_sn_ptr, &s_sn_sz); - vendor_get_fw_ver_info(&s_fw_ver_ptr, &s_fw_ver_sz); +void vendor_info_init(void) { + vendor_get_sn_info(&s_sn_ptr, &s_sn_sz); + vendor_get_fw_ver_info(&s_fw_ver_ptr, &s_fw_ver_sz); } -static void pc_usb_cmd_set (struct USB_AUDIO_VENDOR_MSG_T* msg) -{ - size_t ret; - uint8_t cmd_id = 0; - - if (0 == msg->length) - return; +static void pc_usb_cmd_set(struct USB_AUDIO_VENDOR_MSG_T *msg) { + size_t ret; + uint8_t cmd_id = 0; - for (cmd_id = 1; cmd_id < PC_TOOL_CMD_NUM; cmd_id++) { - ret = memcmp((void *)msg->data, (void *)s_pc_cmd_lst[cmd_id], strlen((char *)s_pc_cmd_lst[cmd_id])); - if (!ret) break; - } + if (0 == msg->length) + return; - if (cmd_id > (PC_TOOL_CMD_NUM-1)) { - return; - } + for (cmd_id = 1; cmd_id < PC_TOOL_CMD_NUM; cmd_id++) { + ret = memcmp((void *)msg->data, (void *)s_pc_cmd_lst[cmd_id], + strlen((char *)s_pc_cmd_lst[cmd_id])); + if (!ret) + break; + } - s_cur_cmd = cmd_id; - //TRACE(3,"%s: cmd[%s], id[%d]", __func__, s_pc_cmd_lst[cmd_id], s_cur_cmd); - msg->data += strlen((char*)s_pc_cmd_lst[cmd_id]); -#ifdef USB_ANC_MC_EQ_TUNING - msg->length -=strlen((char*)s_pc_cmd_lst[cmd_id]); + if (cmd_id > (PC_TOOL_CMD_NUM - 1)) { + return; + } + + s_cur_cmd = cmd_id; + // TRACE(3,"%s: cmd[%s], id[%d]", __func__, s_pc_cmd_lst[cmd_id], s_cur_cmd); + msg->data += strlen((char *)s_pc_cmd_lst[cmd_id]); +#ifdef USB_ANC_MC_EQ_TUNING + msg->length -= strlen((char *)s_pc_cmd_lst[cmd_id]); #endif - switch (s_cur_cmd) { + switch (s_cur_cmd) { #ifdef USB_EQ_TUNING - case PC_TOOL_CMD_EQ_TUNING: - hal_cmd_list_process(msg->data); - break; + case PC_TOOL_CMD_EQ_TUNING: + hal_cmd_list_process(msg->data); + break; #endif #ifdef USB_ANC_MC_EQ_TUNING - case PC_TOOL_CMD_ANC_MC_EQ_TUNING: - //TRACE(1,"recev len:%d",msg->length); - /* - TRACE(0,"***********recev test*************"); - for(int i=0;ilength;i++) - { - TRACE(2,"msg->data[%d]:0x%x",i,msg->data[i]); - } - TRACE(0,"***********recev test*************"); - */ - anc_cmd_receve_process(msg->data,msg->length); - break; + case PC_TOOL_CMD_ANC_MC_EQ_TUNING: + // TRACE(1,"recev len:%d",msg->length); + /* + TRACE(0,"***********recev test*************"); + for(int i=0;ilength;i++) + { + TRACE(2,"msg->data[%d]:0x%x",i,msg->data[i]); + } + TRACE(0,"***********recev test*************"); + */ + anc_cmd_receve_process(msg->data, msg->length); + break; #endif - default: - break; - } + default: + break; + } } -static void pc_usb_cmd_exec (struct USB_AUDIO_VENDOR_MSG_T* msg) -{ - //TRACE(2,"%s: cmd[%d]", __func__, s_cur_cmd); - static const char* s_str_ret1 = "1"; +static void pc_usb_cmd_exec(struct USB_AUDIO_VENDOR_MSG_T *msg) { + // TRACE(2,"%s: cmd[%d]", __func__, s_cur_cmd); + static const char *s_str_ret1 = "1"; #ifdef USB_EQ_TUNING - static const char* s_str_ret0 = "0"; + static const char *s_str_ret0 = "0"; #endif - static const char* s_str_failure = "failure"; + static const char *s_str_failure = "failure"; - switch (s_cur_cmd) { - case PC_TOOL_CMD_GET_FW_VER: - msg->data = s_fw_ver_ptr; - msg->length = strlen((char*)s_fw_ver_ptr); - break; + switch (s_cur_cmd) { + case PC_TOOL_CMD_GET_FW_VER: + msg->data = s_fw_ver_ptr; + msg->length = strlen((char *)s_fw_ver_ptr); + break; - case PC_TOOL_CMD_GET_PROD_SN: - msg->data = s_sn_ptr; - msg->length = strlen((char*)s_sn_ptr); - break; + case PC_TOOL_CMD_GET_PROD_SN: + msg->data = s_sn_ptr; + msg->length = strlen((char *)s_sn_ptr); + break; - case PC_TOOL_CMD_SYS_REBOOT: - //TRACE(0,"-> cmd_exec: reboot....."); - hal_sys_timer_delay(MS_TO_TICKS(500)); - hal_cmu_sys_reboot(); - break; + case PC_TOOL_CMD_SYS_REBOOT: + // TRACE(0,"-> cmd_exec: reboot....."); + hal_sys_timer_delay(MS_TO_TICKS(500)); + hal_cmu_sys_reboot(); + break; - case PC_TOOL_CMD_SYS_SHUTDOWN: - pmu_shutdown(); - break; + case PC_TOOL_CMD_SYS_SHUTDOWN: + pmu_shutdown(); + break; - case PC_TOOL_CMD_PING: - msg->data = (uint8_t *)s_pc_cmd_lst[PC_TOOL_CMD_PING]; - msg->length = (uint32_t)strlen((const char *)msg->data); - break; + case PC_TOOL_CMD_PING: + msg->data = (uint8_t *)s_pc_cmd_lst[PC_TOOL_CMD_PING]; + msg->length = (uint32_t)strlen((const char *)msg->data); + break; - case PC_TOOL_CMD_CHECK: - msg->data = (uint8_t*)SYS_CHECK_VAL; - msg->length = strlen((char*)SYS_CHECK_VAL); - break; + case PC_TOOL_CMD_CHECK: + msg->data = (uint8_t *)SYS_CHECK_VAL; + msg->length = strlen((char *)SYS_CHECK_VAL); + break; - case PC_TOOL_CMD_FW_UPDATE: - hal_sw_bootmode_clear(1<<8); // to clear HAL_SW_BOOTMODE_FORCE_UART_DLD - hal_sw_bootmode_set(1<<7); // to set HAL_SW_BOOTMODE_FORCE_USB_DLD + case PC_TOOL_CMD_FW_UPDATE: + hal_sw_bootmode_clear(1 << 8); // to clear HAL_SW_BOOTMODE_FORCE_UART_DLD + hal_sw_bootmode_set(1 << 7); // to set HAL_SW_BOOTMODE_FORCE_USB_DLD #ifdef TGT_PLL_FREQ - extern void pll_config_update (uint32_t); - pll_config_update(960000000); + extern void pll_config_update(uint32_t); + pll_config_update(960000000); #endif - analog_aud_codec_mute(); - msg->data = (uint8_t*)s_str_ret1; - msg->length = (uint32_t)strlen(s_str_ret1); - break; + analog_aud_codec_mute(); + msg->data = (uint8_t *)s_str_ret1; + msg->length = (uint32_t)strlen(s_str_ret1); + break; #ifdef USB_EQ_TUNING - case PC_TOOL_CMD_EQ_TUNING: - hal_cmd_tx_process(&msg->data, &msg->length); - if (!msg->length) { - msg->data = (uint8_t*)s_str_ret0; - msg->length = (uint32_t)strlen(s_str_ret0); - } - break; -#endif - -#ifdef USB_ANC_MC_EQ_TUNING - case PC_TOOL_CMD_ANC_MC_EQ_TUNING: - anc_cmd_send_process(&msg->data, &msg->length); - TRACE(1,"sned len:%d",msg->length); - -/* TRACE(0,"***********send test*************"); - for(int i=0;ilength;i++) - { - TRACE(2,"msg->data[%d]:0x%x",i,msg->data[i]); - } - TRACE(0,"***********send test*************"); - */ - break; -#endif - - default: - msg->data = (uint8_t*)s_str_failure; - msg->length = (uint32_t)strlen(s_str_failure); - break; + case PC_TOOL_CMD_EQ_TUNING: + hal_cmd_tx_process(&msg->data, &msg->length); + if (!msg->length) { + msg->data = (uint8_t *)s_str_ret0; + msg->length = (uint32_t)strlen(s_str_ret0); } + break; +#endif - s_cur_cmd = PC_TOOL_CMD_IDLE; +#ifdef USB_ANC_MC_EQ_TUNING + case PC_TOOL_CMD_ANC_MC_EQ_TUNING: + anc_cmd_send_process(&msg->data, &msg->length); + TRACE(1, "sned len:%d", msg->length); + + /* TRACE(0,"***********send test*************"); + for(int i=0;ilength;i++) + { + TRACE(2,"msg->data[%d]:0x%x",i,msg->data[i]); + } + TRACE(0,"***********send test*************"); + */ + break; +#endif + + default: + msg->data = (uint8_t *)s_str_failure; + msg->length = (uint32_t)strlen(s_str_failure); + break; + } + + s_cur_cmd = PC_TOOL_CMD_IDLE; } +int usb_vendor_callback(struct USB_AUDIO_VENDOR_MSG_T *msg) { -int usb_vendor_callback (struct USB_AUDIO_VENDOR_MSG_T* msg) -{ + if (0 == msg->length) { + pc_usb_cmd_exec(msg); + } else { + pc_usb_cmd_set(msg); + } - if (0 == msg->length) { - pc_usb_cmd_exec(msg); - } else { - pc_usb_cmd_set(msg); - } - - return 0; + return 0; } #endif diff --git a/thirdparty/demo_lib/demo_lib.c b/thirdparty/demo_lib/demo_lib.c index 273241f..f9c0829 100644 --- a/thirdparty/demo_lib/demo_lib.c +++ b/thirdparty/demo_lib/demo_lib.c @@ -1,11 +1,5 @@ -#include "cmsis_os.h" -#include "cmsis.h" -#include -#include "hal_trace.h" #include "demo_lib.h" - - - - - - +#include "cmsis.h" +#include "cmsis_os.h" +#include "hal_trace.h" +#include diff --git a/thirdparty/noise_tracker_lib/noise_tracker.c b/thirdparty/noise_tracker_lib/noise_tracker.c index 81aaf85..dcead46 100644 --- a/thirdparty/noise_tracker_lib/noise_tracker.c +++ b/thirdparty/noise_tracker_lib/noise_tracker.c @@ -1,59 +1,56 @@ -#include #include "noise_tracker.h" #include "audio_dump.h" #include "hal_trace.h" +#include //#define NT_DUMP_AUDIO_DATA #define SQUARE(x) ((x) * (x)) #define LIN2DB(x) (10.f * log10f(x)) -#define NORMAL_SCALE (1.f/32768/32768) +#define NORMAL_SCALE (1.f / 32768 / 32768) static NoiseTrackerCallback _callback; static int _threshold; static int _ch_num; -static float vec_power(int16_t *buf, uint32_t len, int stride) -{ - float sum = 0.f; - for (uint32_t i = 0; i < len; i += stride) - sum += SQUARE(buf[i]); +static float vec_power(int16_t *buf, uint32_t len, int stride) { + float sum = 0.f; + for (uint32_t i = 0; i < len; i += stride) + sum += SQUARE(buf[i]); - return sum; + return sum; } -void noise_tracker_init(NoiseTrackerCallback cb, int ch_num, int threshold) -{ - _callback = cb; - _threshold = threshold; - _ch_num = ch_num; +void noise_tracker_init(NoiseTrackerCallback cb, int ch_num, int threshold) { + _callback = cb; + _threshold = threshold; + _ch_num = ch_num; #ifdef NT_DUMP_AUDIO_DATA - audio_dump_init(240 * ANC_NOISE_TRACKER_CHANNEL_NUM, sizeof(int16_t), 1); + audio_dump_init(240 * ANC_NOISE_TRACKER_CHANNEL_NUM, sizeof(int16_t), 1); #endif } -void noise_tracker_process(int16_t *buf, uint32_t len) -{ - float scale = 1.f / len * NORMAL_SCALE; - float maxPowerdB = -90; +void noise_tracker_process(int16_t *buf, uint32_t len) { + float scale = 1.f / len * NORMAL_SCALE; + float maxPowerdB = -90; #ifdef NT_DUMP_AUDIO_DATA - audio_dump_clear_up(); - audio_dump_add_channel_data(0, buf, len); - audio_dump_run(); + audio_dump_clear_up(); + audio_dump_add_channel_data(0, buf, len); + audio_dump_run(); #endif - for (int i = 0; i < _ch_num; i++) { - float power = vec_power(&buf[i], len, _ch_num) * scale; - float powerdB = LIN2DB(power); - maxPowerdB = MAX(maxPowerdB, powerdB); + for (int i = 0; i < _ch_num; i++) { + float power = vec_power(&buf[i], len, _ch_num) * scale; + float powerdB = LIN2DB(power); + maxPowerdB = MAX(maxPowerdB, powerdB); - //TRACE(3,"[%s] powerdB ch[%d] = %d", __FUNCTION__, i, (int)powerdB); - } + // TRACE(3,"[%s] powerdB ch[%d] = %d", __FUNCTION__, i, (int)powerdB); + } - if (maxPowerdB > _threshold) { - _callback(maxPowerdB); - } + if (maxPowerdB > _threshold) { + _callback(maxPowerdB); + } } diff --git a/thirdparty/userapi/app_thirdparty.cpp b/thirdparty/userapi/app_thirdparty.cpp index 40e9063..821547d 100644 --- a/thirdparty/userapi/app_thirdparty.cpp +++ b/thirdparty/userapi/app_thirdparty.cpp @@ -1,131 +1,142 @@ -#include "cmsis_os.h" -#include "cmsis.h" -#include "list.h" -#include "hal_trace.h" -#include #include "app_thirdparty.h" - +#include "cmsis.h" +#include "cmsis_os.h" +#include "hal_trace.h" +#include "list.h" +#include APP_THIRDPARTY_HANDLE_TAB_T app_thirdparty_handle_table; -void app_thirdparty_callback_init(THIRDPARTY_CALLBACK_TYPE type, APP_THIRDPARTY_CUSTOM_CB_T cb) -{ - TRACE(2, "%s type %d", __func__, type); - switch (type) - { - case THIRDPARTY_DATA_COME_CALLBACK: - app_thirdparty_handle_table._app_thirdparty_data_come_callback = cb; - break; - case THIRDPARTY_WAKE_UP_CALLBACK: - app_thirdparty_handle_table._app_thirdparty_wake_up_callback = cb; - break; - case THIRDPARTY_START_SPEECH_CALLBACK: - app_thirdparty_handle_table._app_thirdparty_start_callback = cb; - break; - case THIRDPARTY_STOP_SPEECH_CALLBACK: - app_thirdparty_handle_table._app_thirdparty_stop_callback = cb; - break; - default: - break; - } +void app_thirdparty_callback_init(THIRDPARTY_CALLBACK_TYPE type, + APP_THIRDPARTY_CUSTOM_CB_T cb) { + TRACE(2, "%s type %d", __func__, type); + switch (type) { + case THIRDPARTY_DATA_COME_CALLBACK: + app_thirdparty_handle_table._app_thirdparty_data_come_callback = cb; + break; + case THIRDPARTY_WAKE_UP_CALLBACK: + app_thirdparty_handle_table._app_thirdparty_wake_up_callback = cb; + break; + case THIRDPARTY_START_SPEECH_CALLBACK: + app_thirdparty_handle_table._app_thirdparty_start_callback = cb; + break; + case THIRDPARTY_STOP_SPEECH_CALLBACK: + app_thirdparty_handle_table._app_thirdparty_stop_callback = cb; + break; + default: + break; + } } -uint32_t app_thirdparty_callback_handble(THIRDPARTY_CALLBACK_TYPE type, void* param1, uint32_t param2) -{ - uint32_t ret = 0xFFFFFFFF; - //TRACE(2, "%s type %d", __func__, type); +uint32_t app_thirdparty_callback_handble(THIRDPARTY_CALLBACK_TYPE type, + void *param1, uint32_t param2) { + uint32_t ret = 0xFFFFFFFF; + // TRACE(2, "%s type %d", __func__, type); - switch (type) - { - case THIRDPARTY_DATA_COME_CALLBACK: - if (app_thirdparty_handle_table._app_thirdparty_data_come_callback) - { - ret = app_thirdparty_handle_table._app_thirdparty_data_come_callback(param1, param2); - } - break; - case THIRDPARTY_WAKE_UP_CALLBACK: - if (app_thirdparty_handle_table._app_thirdparty_wake_up_callback) - { - ret = app_thirdparty_handle_table._app_thirdparty_wake_up_callback(param1, param2); - } - break; - case THIRDPARTY_START_SPEECH_CALLBACK: - if (app_thirdparty_handle_table._app_thirdparty_start_callback) - { - ret = app_thirdparty_handle_table._app_thirdparty_start_callback(param1, param2); - } - break; - case THIRDPARTY_STOP_SPEECH_CALLBACK: - if (app_thirdparty_handle_table._app_thirdparty_stop_callback) - { - ret = app_thirdparty_handle_table._app_thirdparty_stop_callback(param1, param2); - } - break; - default: - break; + switch (type) { + case THIRDPARTY_DATA_COME_CALLBACK: + if (app_thirdparty_handle_table._app_thirdparty_data_come_callback) { + ret = app_thirdparty_handle_table._app_thirdparty_data_come_callback( + param1, param2); } + break; + case THIRDPARTY_WAKE_UP_CALLBACK: + if (app_thirdparty_handle_table._app_thirdparty_wake_up_callback) { + ret = app_thirdparty_handle_table._app_thirdparty_wake_up_callback( + param1, param2); + } + break; + case THIRDPARTY_START_SPEECH_CALLBACK: + if (app_thirdparty_handle_table._app_thirdparty_start_callback) { + ret = app_thirdparty_handle_table._app_thirdparty_start_callback(param1, + param2); + } + break; + case THIRDPARTY_STOP_SPEECH_CALLBACK: + if (app_thirdparty_handle_table._app_thirdparty_stop_callback) { + ret = app_thirdparty_handle_table._app_thirdparty_stop_callback(param1, + param2); + } + break; + default: + break; + } - return ret; + return ret; } -int app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_ID funcId,THIRDPARTY_EVENT_TYPE event_type) -{ - TRACE(3, "%s funcId=%d event_type=0x%x", __func__, funcId, event_type); - const APP_THIRDPARTY_HANDLE *dest_handle; +int app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_ID funcId, + THIRDPARTY_EVENT_TYPE event_type) { + TRACE(3, "%s funcId=%d event_type=0x%x", __func__, funcId, event_type); + const APP_THIRDPARTY_HANDLE *dest_handle; - if (app_thirdparty_handle_table.thirdparty_func_id == funcId) - { - for (uint32_t index = 0; - index < app_thirdparty_handle_table.thirdparty_handler_cnt; - index++) - { - dest_handle = &app_thirdparty_handle_table.thirdparty_handler_tab[index]; - if (dest_handle->thirdparty_sign.event == event_type) - { - TRACE(1,"find index=%d",index); - if (dest_handle->function) - { - return dest_handle->function(dest_handle->status, dest_handle->param); - } - } + if (app_thirdparty_handle_table.thirdparty_func_id == funcId) { + for (uint32_t index = 0; + index < app_thirdparty_handle_table.thirdparty_handler_cnt; index++) { + dest_handle = &app_thirdparty_handle_table.thirdparty_handler_tab[index]; + if (dest_handle->thirdparty_sign.event == event_type) { + TRACE(1, "find index=%d", index); + if (dest_handle->function) { + return dest_handle->function(dest_handle->status, dest_handle->param); } + } } + } - return 0; + return 0; } - -void app_thirdparty_init(void) -{ +void app_thirdparty_init(void) { #ifdef __ALEXA_WWE - app_thirdparty_handle_table.thirdparty_handler_tab = THIRDPARTY_GET_HANDLER_TAB(ALEXA_WWE_LIB_NAME); - app_thirdparty_handle_table.thirdparty_handler_cnt = THIRDPARTY_GET_HANDLER_TAB_SIZE(ALEXA_WWE_LIB_NAME); + app_thirdparty_handle_table.thirdparty_handler_tab = + THIRDPARTY_GET_HANDLER_TAB(ALEXA_WWE_LIB_NAME); + app_thirdparty_handle_table.thirdparty_handler_cnt = + THIRDPARTY_GET_HANDLER_TAB_SIZE(ALEXA_WWE_LIB_NAME); #elif defined(__KWS_ALEXA__) - app_thirdparty_handle_table.thirdparty_handler_tab = THIRDPARTY_GET_HANDLER_TAB(KWS_ALEXA_LIB_NAME); - app_thirdparty_handle_table.thirdparty_handler_cnt = THIRDPARTY_GET_HANDLER_TAB_SIZE(KWS_ALEXA_LIB_NAME); + app_thirdparty_handle_table.thirdparty_handler_tab = + THIRDPARTY_GET_HANDLER_TAB(KWS_ALEXA_LIB_NAME); + app_thirdparty_handle_table.thirdparty_handler_cnt = + THIRDPARTY_GET_HANDLER_TAB_SIZE(KWS_ALEXA_LIB_NAME); #elif defined(__CYBERON) - app_thirdparty_handle_table.thirdparty_handler_tab = THIRDPARTY_GET_HANDLER_TAB(CYBERON_LIB_NAME); - app_thirdparty_handle_table.thirdparty_handler_cnt = THIRDPARTY_GET_HANDLER_TAB_SIZE(CYBERON_LIB_NAME); + app_thirdparty_handle_table.thirdparty_handler_tab = + THIRDPARTY_GET_HANDLER_TAB(CYBERON_LIB_NAME); + app_thirdparty_handle_table.thirdparty_handler_cnt = + THIRDPARTY_GET_HANDLER_TAB_SIZE(CYBERON_LIB_NAME); #elif defined(__KNOWLES) - app_thirdparty_handle_table.thirdparty_handler_tab = THIRDPARTY_GET_HANDLER_TAB(KNOWLES_LIB_NAME); - app_thirdparty_handle_table.thirdparty_handler_cnt = THIRDPARTY_GET_HANDLER_TAB_SIZE(KNOWLES_LIB_NAME); + app_thirdparty_handle_table.thirdparty_handler_tab = + THIRDPARTY_GET_HANDLER_TAB(KNOWLES_LIB_NAME); + app_thirdparty_handle_table.thirdparty_handler_cnt = + THIRDPARTY_GET_HANDLER_TAB_SIZE(KNOWLES_LIB_NAME); #elif defined(ANC_NOISE_TRACKER) - app_thirdparty_handle_table.thirdparty_handler_tab = THIRDPARTY_GET_HANDLER_TAB(NOISE_TRACKER_LIB_NAME); - app_thirdparty_handle_table.thirdparty_handler_cnt = THIRDPARTY_GET_HANDLER_TAB_SIZE(NOISE_TRACKER_LIB_NAME); + app_thirdparty_handle_table.thirdparty_handler_tab = + THIRDPARTY_GET_HANDLER_TAB(NOISE_TRACKER_LIB_NAME); + app_thirdparty_handle_table.thirdparty_handler_cnt = + THIRDPARTY_GET_HANDLER_TAB_SIZE(NOISE_TRACKER_LIB_NAME); #elif defined(_VOICESPOT_) - app_thirdparty_handle_table.thirdparty_handler_tab = THIRDPARTY_GET_HANDLER_TAB(VOICESPOT_LIB_NAME); - app_thirdparty_handle_table.thirdparty_handler_cnt = THIRDPARTY_GET_HANDLER_TAB_SIZE(VOICESPOT_LIB_NAME); + app_thirdparty_handle_table.thirdparty_handler_tab = + THIRDPARTY_GET_HANDLER_TAB(VOICESPOT_LIB_NAME); + app_thirdparty_handle_table.thirdparty_handler_cnt = + THIRDPARTY_GET_HANDLER_TAB_SIZE(VOICESPOT_LIB_NAME); #elif defined(__BIXBY) - app_thirdparty_handle_table.thirdparty_handler_tab = THIRDPARTY_GET_HANDLER_TAB(BIXBY_NAME); - app_thirdparty_handle_table.thirdparty_handler_cnt = THIRDPARTY_GET_HANDLER_TAB_SIZE(BIXBY_NAME); + app_thirdparty_handle_table.thirdparty_handler_tab = + THIRDPARTY_GET_HANDLER_TAB(BIXBY_NAME); + app_thirdparty_handle_table.thirdparty_handler_cnt = + THIRDPARTY_GET_HANDLER_TAB_SIZE(BIXBY_NAME); #else - app_thirdparty_handle_table.thirdparty_handler_tab = THIRDPARTY_GET_HANDLER_TAB(DEMO_LIB_NAME); - app_thirdparty_handle_table.thirdparty_handler_cnt = THIRDPARTY_GET_HANDLER_TAB_SIZE(DEMO_LIB_NAME); + app_thirdparty_handle_table.thirdparty_handler_tab = + THIRDPARTY_GET_HANDLER_TAB(DEMO_LIB_NAME); + app_thirdparty_handle_table.thirdparty_handler_cnt = + THIRDPARTY_GET_HANDLER_TAB_SIZE(DEMO_LIB_NAME); #endif - app_thirdparty_handle_table.thirdparty_func_id = app_thirdparty_handle_table.thirdparty_handler_tab[0].thirdparty_sign.func_id; - app_thirdparty_handle_table.thirdparty_lib_id = app_thirdparty_handle_table.thirdparty_handler_tab[0].thirdparty_sign.lib_id; + app_thirdparty_handle_table.thirdparty_func_id = + app_thirdparty_handle_table.thirdparty_handler_tab[0] + .thirdparty_sign.func_id; + app_thirdparty_handle_table.thirdparty_lib_id = + app_thirdparty_handle_table.thirdparty_handler_tab[0] + .thirdparty_sign.lib_id; - TRACE(3, "%s cnt=%d id=%d", __func__, app_thirdparty_handle_table.thirdparty_handler_cnt, app_thirdparty_handle_table.thirdparty_lib_id); + TRACE(3, "%s cnt=%d id=%d", __func__, + app_thirdparty_handle_table.thirdparty_handler_cnt, + app_thirdparty_handle_table.thirdparty_lib_id); } - diff --git a/thirdparty/userapi/demo_app/LibDemo.cpp b/thirdparty/userapi/demo_app/LibDemo.cpp index ebf40e8..2a4069f 100644 --- a/thirdparty/userapi/demo_app/LibDemo.cpp +++ b/thirdparty/userapi/demo_app/LibDemo.cpp @@ -1,41 +1,41 @@ -#include "cmsis_os.h" +#include "LibDemo.h" #include "cmsis.h" +#include "cmsis_os.h" #include "cqueue.h" +#include "demo_lib.h" #include "hal_trace.h" #include -#include "demo_lib.h" -#include "LibDemo.h" - -int demo_example_init(bool on,void *param) -{ - TRACE(0,"demo_example_init"); - return 0; +int demo_example_init(bool on, void *param) { + TRACE(0, "demo_example_init"); + return 0; } -int demo_example_start(bool on,void *param) -{ - TRACE(0,"demo_example_start"); - return 0; +int demo_example_start(bool on, void *param) { + TRACE(0, "demo_example_start"); + return 0; } -int demo_example_stop(bool on,void *param) -{ - TRACE(0,"demo_example_stop"); - return 0; +int demo_example_stop(bool on, void *param) { + TRACE(0, "demo_example_stop"); + return 0; } - #include "app_thirdparty.h" - -THIRDPARTY_HANDLER_TAB(DEMO_LIB_NAME) -{ - {{THIRDPARTY_FUNC_DEMO,THIRDPARTY_ID_DEMO,THIRDPARTY_START},(APP_THIRDPARTY_HANDLE_CB_T)demo_example_start,true,NULL}, - {{THIRDPARTY_FUNC_DEMO,THIRDPARTY_ID_DEMO,THIRDPARTY_STOP},(APP_THIRDPARTY_HANDLE_CB_T)demo_example_stop,true,NULL}, - {{THIRDPARTY_FUNC_DEMO,THIRDPARTY_ID_DEMO,THIRDPARTY_INIT},(APP_THIRDPARTY_HANDLE_CB_T)demo_example_init,true,NULL}, +THIRDPARTY_HANDLER_TAB(DEMO_LIB_NAME){ + {{THIRDPARTY_FUNC_DEMO, THIRDPARTY_ID_DEMO, THIRDPARTY_START}, + (APP_THIRDPARTY_HANDLE_CB_T)demo_example_start, + true, + NULL}, + {{THIRDPARTY_FUNC_DEMO, THIRDPARTY_ID_DEMO, THIRDPARTY_STOP}, + (APP_THIRDPARTY_HANDLE_CB_T)demo_example_stop, + true, + NULL}, + {{THIRDPARTY_FUNC_DEMO, THIRDPARTY_ID_DEMO, THIRDPARTY_INIT}, + (APP_THIRDPARTY_HANDLE_CB_T)demo_example_init, + true, + NULL}, }; THIRDPARTY_HANDLER_TAB_SIZE(DEMO_LIB_NAME) - - diff --git a/thirdparty/userapi/noise_tracker_app/NoiseTrackerDemo.cpp b/thirdparty/userapi/noise_tracker_app/NoiseTrackerDemo.cpp index 3fe7d21..e1517ad 100644 --- a/thirdparty/userapi/noise_tracker_app/NoiseTrackerDemo.cpp +++ b/thirdparty/userapi/noise_tracker_app/NoiseTrackerDemo.cpp @@ -13,77 +13,73 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "cmsis_os.h" -#include "cmsis.h" -#include "hal_trace.h" -#include #include "app_utils.h" +#include "cmsis.h" +#include "cmsis_os.h" #include "hal_timer.h" +#include "hal_trace.h" #include +#include // for audio -#include "audioflinger.h" #include "app_audio.h" #include "app_bt_stream.h" #include "app_media_player.h" -#include "speech_ssat.h" -#include "speech_memory.h" #include "audio_dump.h" +#include "audioflinger.h" +#include "speech_memory.h" +#include "speech_ssat.h" #include "noise_tracker.h" #include "noise_tracker_callback.h" - /**< NT Engine hooks */ -#define NT_ENGINE_INIT(callback, ch, threshold) noise_tracker_init(callback, ch, threshold) -#define NT_ENGINE_FEED(frame, n_samples) noise_tracker_process(frame, n_samples) - +#define NT_ENGINE_INIT(callback, ch, threshold) \ + noise_tracker_init(callback, ch, threshold) +#define NT_ENGINE_FEED(frame, n_samples) noise_tracker_process(frame, n_samples) /**< NT configuration settings */ -#define NT_MIC_BITS_PER_SAMPLE (AUD_BITS_16) -#define NT_MIC_SAMPLE_RATE (16000) // (AUD_SAMPRATE_8000) -#define NT_MIC_VOLUME (16) - +#define NT_MIC_BITS_PER_SAMPLE (AUD_BITS_16) +#define NT_MIC_SAMPLE_RATE (16000) // (AUD_SAMPRATE_8000) +#define NT_MIC_VOLUME (16) /**< NT Engine configuration settings */ -#define NT_ENGINE_SAMPLES_PER_FRAME (240) -#define NT_ENGINE_SAMPLE_RATE (16000) -#define NT_ENGINE_SYSFREQ (APP_SYSFREQ_26M) // (APP_SYSFREQ_26M) - +#define NT_ENGINE_SAMPLES_PER_FRAME (240) +#define NT_ENGINE_SAMPLE_RATE (16000) +#define NT_ENGINE_SYSFREQ (APP_SYSFREQ_26M) // (APP_SYSFREQ_26M) /* Utility functions */ -#define NT_TRACE(s, ...) TRACE(1,"%s: " s, __FUNCTION__, ## __VA_ARGS__); +#define NT_TRACE(s, ...) TRACE(1, "%s: " s, __FUNCTION__, ##__VA_ARGS__); #define ALIGN4 __attribute__((aligned(4))) - -/* Calcluate the audio-capture frame length, FRAME_LEN, based of decimation rate (1 or 2): */ -#define FRAME_LEN (NT_ENGINE_SAMPLES_PER_FRAME * (NT_MIC_SAMPLE_RATE / NT_ENGINE_SAMPLE_RATE)) -#define CAPTURE_CHANNEL_NUM (ANC_NOISE_TRACKER_CHANNEL_NUM) -#define CAPTURE_BUF_SIZE (FRAME_LEN * CAPTURE_CHANNEL_NUM * 2 * 2) +/* Calcluate the audio-capture frame length, FRAME_LEN, based of decimation rate + * (1 or 2): */ +#define FRAME_LEN \ + (NT_ENGINE_SAMPLES_PER_FRAME * (NT_MIC_SAMPLE_RATE / NT_ENGINE_SAMPLE_RATE)) +#define CAPTURE_CHANNEL_NUM (ANC_NOISE_TRACKER_CHANNEL_NUM) +#define CAPTURE_BUF_SIZE (FRAME_LEN * CAPTURE_CHANNEL_NUM * 2 * 2) static uint8_t codec_capture_buf[CAPTURE_BUF_SIZE] ALIGN4; -STATIC_ASSERT(FRAME_LEN == NT_ENGINE_SAMPLES_PER_FRAME, "NT_ENGINE Config error"); - +STATIC_ASSERT(FRAME_LEN == NT_ENGINE_SAMPLES_PER_FRAME, + "NT_ENGINE Config error"); /* Local state */ -static bool nt_demo_is_streaming = false; +static bool nt_demo_is_streaming = false; extern uint8_t bt_sco_mode; - - /** * @breif Handle one-time initialization, like setting up the memory pool */ -static int nt_demo_init(bool, const void *) -{ - static bool done; +static int nt_demo_init(bool, const void *) { + static bool done; - NT_TRACE(0,"Initialize kws_demo"); - if (done) return 0; + NT_TRACE(0, "Initialize kws_demo"); + if (done) + return 0; - done = true; + done = true; - return 0; + return 0; } /** @@ -93,20 +89,17 @@ static int nt_demo_init(bool, const void *) * @param in_len Length of the PCM data in the buffer in samples. * */ -static void filter_iir_dc_block(short *inout, int in_len, int stride) -{ - static int z = 0; - int tmp; +static void filter_iir_dc_block(short *inout, int in_len, int stride) { + static int z = 0; + int tmp; - for (int i = 0; i < in_len; i += stride) - { - z = (15 * z + inout[i]) >> 4; - tmp = inout[i] - z; - inout[i] = speech_ssat_int16(tmp); - } + for (int i = 0; i < in_len; i += stride) { + z = (15 * z + inout[i]) >> 4; + tmp = inout[i] - z; + inout[i] = speech_ssat_int16(tmp); + } } - /** * @brief Process the collected PCM data from MIC. * Resample audio stream to 8KHz and pass audio to kws lib. @@ -116,94 +109,89 @@ static void filter_iir_dc_block(short *inout, int in_len, int stride) * * @return uint32_t 0 means no error happened */ -static uint32_t nt_demo_stream_handler(uint8_t *buf, uint32_t length) -{ - ASSERT(length == FRAME_LEN * CAPTURE_CHANNEL_NUM * sizeof(int16_t), "stream length not matched"); +static uint32_t nt_demo_stream_handler(uint8_t *buf, uint32_t length) { + ASSERT(length == FRAME_LEN * CAPTURE_CHANNEL_NUM * sizeof(int16_t), + "stream length not matched"); - short *pcm_buf = (short*)buf; - uint32_t pcm_len = length / 2; + short *pcm_buf = (short *)buf; + uint32_t pcm_len = length / 2; - filter_iir_dc_block(pcm_buf, pcm_len, ANC_NOISE_TRACKER_CHANNEL_NUM); - NT_ENGINE_FEED(pcm_buf, pcm_len); + filter_iir_dc_block(pcm_buf, pcm_len, ANC_NOISE_TRACKER_CHANNEL_NUM); + NT_ENGINE_FEED(pcm_buf, pcm_len); - return 0; + return 0; } - /** - * @brief Setup audio streaming from MIC + * @brief Setup audio streaming from MIC * * @param do_stream start / stop streaming * * @return int 0 means no error happened */ -static int nt_demo_stream_start(bool do_stream, const void *) -{ - struct AF_STREAM_CONFIG_T stream_cfg; +static int nt_demo_stream_start(bool do_stream, const void *) { + struct AF_STREAM_CONFIG_T stream_cfg; - NT_TRACE(3,"Is running:%d enable:%d, bt_sco_mode:%d", - nt_demo_is_streaming, do_stream, bt_sco_mode); + NT_TRACE(3, "Is running:%d enable:%d, bt_sco_mode:%d", nt_demo_is_streaming, + do_stream, bt_sco_mode); - if (bt_sco_mode) - return 0; + if (bt_sco_mode) + return 0; - if (nt_demo_is_streaming == do_stream) - return 0; - nt_demo_is_streaming = do_stream; + if (nt_demo_is_streaming == do_stream) + return 0; + nt_demo_is_streaming = do_stream; - if (do_stream) { - // Request sufficient system clock - app_sysfreq_req(APP_SYSFREQ_USER_APP_NT, NT_ENGINE_SYSFREQ); - NT_TRACE(1,"sys freq calc: %d Hz", hal_sys_timer_calc_cpu_freq(5, 0)); + if (do_stream) { + // Request sufficient system clock + app_sysfreq_req(APP_SYSFREQ_USER_APP_NT, NT_ENGINE_SYSFREQ); + NT_TRACE(1, "sys freq calc: %d Hz", hal_sys_timer_calc_cpu_freq(5, 0)); - nt_demo_init(true, NULL); + nt_demo_init(true, NULL); - // Initialize the NT ENGINE and install word-callback - NT_ENGINE_INIT(nt_demo_words_cb, ANC_NOISE_TRACKER_CHANNEL_NUM, -20); + // Initialize the NT ENGINE and install word-callback + NT_ENGINE_INIT(nt_demo_words_cb, ANC_NOISE_TRACKER_CHANNEL_NUM, -20); - memset(&stream_cfg, 0, sizeof(stream_cfg)); - stream_cfg.sample_rate = (AUD_SAMPRATE_T)NT_MIC_SAMPLE_RATE; - stream_cfg.bits = NT_MIC_BITS_PER_SAMPLE; - stream_cfg.vol = NT_MIC_VOLUME; - stream_cfg.device = AUD_STREAM_USE_INT_CODEC; - stream_cfg.io_path = AUD_INPUT_PATH_NTMIC; - stream_cfg.channel_num = (enum AUD_CHANNEL_NUM_T)ANC_NOISE_TRACKER_CHANNEL_NUM; - stream_cfg.handler = nt_demo_stream_handler; - stream_cfg.data_ptr = codec_capture_buf; - stream_cfg.data_size = CAPTURE_BUF_SIZE; + memset(&stream_cfg, 0, sizeof(stream_cfg)); + stream_cfg.sample_rate = (AUD_SAMPRATE_T)NT_MIC_SAMPLE_RATE; + stream_cfg.bits = NT_MIC_BITS_PER_SAMPLE; + stream_cfg.vol = NT_MIC_VOLUME; + stream_cfg.device = AUD_STREAM_USE_INT_CODEC; + stream_cfg.io_path = AUD_INPUT_PATH_NTMIC; + stream_cfg.channel_num = + (enum AUD_CHANNEL_NUM_T)ANC_NOISE_TRACKER_CHANNEL_NUM; + stream_cfg.handler = nt_demo_stream_handler; + stream_cfg.data_ptr = codec_capture_buf; + stream_cfg.data_size = CAPTURE_BUF_SIZE; - af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); - af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg); + af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - NT_TRACE(0,"audio capture ON"); + NT_TRACE(0, "audio capture ON"); + } else { + af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - } - else { - af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); - af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE); + app_sysfreq_req(APP_SYSFREQ_USER_APP_NT, APP_SYSFREQ_32K); + TRACE(1, "sys freq calc:(32K) %d Hz", hal_sys_timer_calc_cpu_freq(5, 0)); - app_sysfreq_req(APP_SYSFREQ_USER_APP_NT, APP_SYSFREQ_32K); - TRACE(1,"sys freq calc:(32K) %d Hz", hal_sys_timer_calc_cpu_freq(5, 0)); + NT_TRACE(0, "audio capture OFF"); + } - NT_TRACE(0,"audio capture OFF"); - } - - return 0; + return 0; } - - #include "app_thirdparty.h" -#define TP_EVENT(event, handler) {THIRDPARTY_FUNC_NO3, THIRDPARTY_ID_DEMO, THIRDPARTY_ ## event}, (APP_THIRDPARTY_HANDLE_CB_T)handler +#define TP_EVENT(event, handler) \ + {THIRDPARTY_FUNC_NO3, THIRDPARTY_ID_DEMO, THIRDPARTY_##event}, \ + (APP_THIRDPARTY_HANDLE_CB_T)handler -THIRDPARTY_HANDLER_TAB(NOISE_TRACKER_LIB_NAME) -{ -// {TP_EVENT(INIT, nt_demo_init), true, NULL}, - {TP_EVENT(START, nt_demo_stream_start), true, NULL}, - {TP_EVENT(STOP, nt_demo_stream_start), false, NULL}, +THIRDPARTY_HANDLER_TAB(NOISE_TRACKER_LIB_NAME){ + // {TP_EVENT(INIT, nt_demo_init), true, NULL}, + {TP_EVENT(START, nt_demo_stream_start), true, NULL}, + {TP_EVENT(STOP, nt_demo_stream_start), false, NULL}, }; THIRDPARTY_HANDLER_TAB_SIZE(NOISE_TRACKER_LIB_NAME) - diff --git a/thirdparty/userapi/noise_tracker_app/noise_tracker_callback.c b/thirdparty/userapi/noise_tracker_app/noise_tracker_callback.c index dd3a2e1..e582bed 100644 --- a/thirdparty/userapi/noise_tracker_app/noise_tracker_callback.c +++ b/thirdparty/userapi/noise_tracker_app/noise_tracker_callback.c @@ -8,7 +8,6 @@ * @param score Score of word * */ -void nt_demo_words_cb(float power) -{ - TRACE(1,"active power %d", (int)(power)); +void nt_demo_words_cb(float power) { + TRACE(1, "active power %d", (int)(power)); } \ No newline at end of file diff --git a/utils/boot_struct/boot_struct.c b/utils/boot_struct/boot_struct.c index c867692..7ffc3b3 100644 --- a/utils/boot_struct/boot_struct.c +++ b/utils/boot_struct/boot_struct.c @@ -13,10 +13,10 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "tool_msg.h" -#include "reboot_param.h" -#include "norflash_cfg.h" #include "hal_cmu.h" +#include "norflash_cfg.h" +#include "reboot_param.h" +#include "tool_msg.h" extern const char sys_build_info[]; @@ -31,96 +31,86 @@ extern const unsigned int system_info; #undef PROGRAMMER #endif -#define BOOT_STRUCT_LOC __attribute((section(".boot_struct"))) +#define BOOT_STRUCT_LOC __attribute((section(".boot_struct"))) #ifdef USER_SECURE_BOOT -#define DEFAULT_BUILD_INFO ((uint32_t)&system_info) +#define DEFAULT_BUILD_INFO ((uint32_t)&system_info) #else -#define DEFAULT_BUILD_INFO ((uint32_t)sys_build_info) +#define DEFAULT_BUILD_INFO ((uint32_t)sys_build_info) #endif -#define DEFAULT_CODE_SIG \ - { \ - .code_size = 0, \ - .sig_len = SIG_LEN, \ - } +#define DEFAULT_CODE_SIG \ + { .code_size = 0, .sig_len = SIG_LEN, } #ifdef SIMU -#define DEFAULT_NORFLASH_SAMDLY 0x1 -#define DEFAULT_NORFLASH_MOD_CLK HAL_CMU_FREQ_26M -#define DEFAULT_NORFLASH_RDCMD 0x03 +#define DEFAULT_NORFLASH_SAMDLY 0x1 +#define DEFAULT_NORFLASH_MOD_CLK HAL_CMU_FREQ_26M +#define DEFAULT_NORFLASH_RDCMD 0x03 #else -#define DEFAULT_NORFLASH_SAMDLY 0x2 +#define DEFAULT_NORFLASH_SAMDLY 0x2 // Select 26M for 40M crystal case -#define DEFAULT_NORFLASH_MOD_CLK HAL_CMU_FREQ_104M +#define DEFAULT_NORFLASH_MOD_CLK HAL_CMU_FREQ_104M // Below 50M: 0x03, Above 50M: 0x0B -#define DEFAULT_NORFLASH_RDCMD 0x0B +#define DEFAULT_NORFLASH_RDCMD 0x0B #endif -#define DEFAULT_NORFLASH_CFG \ - { \ - .neg_phase = 0, \ - .pos_neg = 0, \ - .cmdquad = 0, \ - .div = 0x2, \ - .samdly = DEFAULT_NORFLASH_SAMDLY, \ - .dualmode = 1, \ - .holdpin = 0, \ - .wprpin = 0, \ - .quadmode = 0, \ - .mod_clk = DEFAULT_NORFLASH_MOD_CLK, \ - .spiruen = 0, \ - .spirden = 0, \ - .dualiocmd = 0xBB, \ - .rdcmd = DEFAULT_NORFLASH_RDCMD, \ - .frdcmd = 0x0B, \ - .qrdcmd = 0xEB, \ - } +#define DEFAULT_NORFLASH_CFG \ + { \ + .neg_phase = 0, .pos_neg = 0, .cmdquad = 0, .div = 0x2, \ + .samdly = DEFAULT_NORFLASH_SAMDLY, .dualmode = 1, .holdpin = 0, \ + .wprpin = 0, .quadmode = 0, .mod_clk = DEFAULT_NORFLASH_MOD_CLK, \ + .spiruen = 0, .spirden = 0, .dualiocmd = 0xBB, \ + .rdcmd = DEFAULT_NORFLASH_RDCMD, .frdcmd = 0x0B, .qrdcmd = 0xEB, \ + } #ifdef SECURE_BOOT_V1 #ifdef PROGRAMMER struct programmer_boot_struct_t { - struct boot_struct_v1_t boot_struct; - struct code_sig_struct_t code_sig_struct; + struct boot_struct_v1_t boot_struct; + struct code_sig_struct_t code_sig_struct; }; const struct programmer_boot_struct_t BOOT_STRUCT_LOC programmer_boot_struct = { - .boot_struct = { - .hdr = { - .magic = BOOT_MAGIC_NUMBER, - .security = 1, - .hash_type = BOOT_HASH_TYPE_SHA256, - .key_type = BOOT_KEY_TYPE_RSA2048, - .key_len = KEY_LEN, - .sig_len = SIG_LEN, - .build_info_start = ((uint32_t)sys_build_info), + .boot_struct = + { + .hdr = + { + .magic = BOOT_MAGIC_NUMBER, + .security = 1, + .hash_type = BOOT_HASH_TYPE_SHA256, + .key_type = BOOT_KEY_TYPE_RSA2048, + .key_len = KEY_LEN, + .sig_len = SIG_LEN, + .build_info_start = ((uint32_t)sys_build_info), + }, }, - }, .code_sig_struct = DEFAULT_CODE_SIG, }; #elif defined(SECURE_BOOT) struct secure_boot_struct_t { - struct boot_struct_v1_t boot_struct; - struct code_sig_struct_t code_sig_struct; - struct norflash_cfg_struct_t norflash_cfg; + struct boot_struct_v1_t boot_struct; + struct code_sig_struct_t code_sig_struct; + struct norflash_cfg_struct_t norflash_cfg; }; const struct secure_boot_struct_t BOOT_STRUCT_LOC secure_boot_struct = { - .boot_struct = { - .hdr = { - .magic = ~0UL, - .security = 1, - .hash_type = BOOT_HASH_TYPE_SHA256, - .key_type = BOOT_KEY_TYPE_RSA2048, - .key_len = KEY_LEN, - .sig_len = SIG_LEN, - .build_info_start = DEFAULT_BUILD_INFO, + .boot_struct = + { + .hdr = + { + .magic = ~0UL, + .security = 1, + .hash_type = BOOT_HASH_TYPE_SHA256, + .key_type = BOOT_KEY_TYPE_RSA2048, + .key_len = KEY_LEN, + .sig_len = SIG_LEN, + .build_info_start = DEFAULT_BUILD_INFO, + }, }, - }, .code_sig_struct = DEFAULT_CODE_SIG, .norflash_cfg = DEFAULT_NORFLASH_CFG, }; @@ -140,48 +130,54 @@ const struct boot_hdr_v1_t BOOT_STRUCT_LOC boot_struct = { #ifdef PROGRAMMER union programmer_boot_struct_t { - // To keep compatible with the old download tools when downloadig non-secure images - struct { - struct boot_struct_v1_t dummy; - struct code_sig_struct_t code_sig_struct; - } s_v1; - struct { - struct boot_struct_t boot_struct; - struct code_sig_struct_t code_sig_struct; - } s; + // To keep compatible with the old download tools when downloadig non-secure + // images + struct { + struct boot_struct_v1_t dummy; + struct code_sig_struct_t code_sig_struct; + } s_v1; + struct { + struct boot_struct_t boot_struct; + struct code_sig_struct_t code_sig_struct; + } s; }; const union programmer_boot_struct_t BOOT_STRUCT_LOC programmer_boot_struct = { - .s = { - .boot_struct = { - .hdr = { - .magic = BOOT_MAGIC_NUMBER, - .security = 1, - .version = BOOT_STRUCT_VERSION, - .build_info_start = ((uint32_t)sys_build_info), - }, + .s = + { + .boot_struct = + { + .hdr = + { + .magic = BOOT_MAGIC_NUMBER, + .security = 1, + .version = BOOT_STRUCT_VERSION, + .build_info_start = ((uint32_t)sys_build_info), + }, + }, + .code_sig_struct = DEFAULT_CODE_SIG, }, - .code_sig_struct = DEFAULT_CODE_SIG, - }, }; #elif defined(SECURE_BOOT) struct secure_boot_struct_t { - struct boot_struct_t boot_struct; - struct code_sig_struct_t code_sig_struct; - struct norflash_cfg_struct_t norflash_cfg; + struct boot_struct_t boot_struct; + struct code_sig_struct_t code_sig_struct; + struct norflash_cfg_struct_t norflash_cfg; }; const struct secure_boot_struct_t BOOT_STRUCT_LOC secure_boot_struct = { - .boot_struct = { - .hdr = { - .magic = ~0UL, - .security = 1, - .version = BOOT_STRUCT_VERSION, - .build_info_start = DEFAULT_BUILD_INFO, + .boot_struct = + { + .hdr = + { + .magic = ~0UL, + .security = 1, + .version = BOOT_STRUCT_VERSION, + .build_info_start = DEFAULT_BUILD_INFO, + }, }, - }, .code_sig_struct = DEFAULT_CODE_SIG, .norflash_cfg = DEFAULT_NORFLASH_CFG, }; @@ -210,4 +206,3 @@ const struct boot_hdr_t BOOT_STRUCT_LOC boot_struct = { #endif struct REBOOT_PARAM_T REBOOT_PARAM_LOC reboot_param; - diff --git a/utils/build_info/build_info.c b/utils/build_info/build_info.c index 60d47a1..e221c33 100644 --- a/utils/build_info/build_info.c +++ b/utils/build_info/build_info.c @@ -15,53 +15,52 @@ ****************************************************************************/ #include "plat_addr_map.h" -#define BUILD_INFO_LOCATION __attribute__((section(".build_info"))) +#define BUILD_INFO_LOCATION __attribute__((section(".build_info"))) -#define TO_STR_A(s) # s -#define TO_STR(s) TO_STR_A(s) +#define TO_STR_A(s) #s +#define TO_STR(s) TO_STR_A(s) #ifdef TRACE_CRLF -#define NEW_LINE_STR "\r\n" +#define NEW_LINE_STR "\r\n" #else -#define NEW_LINE_STR "\n" +#define NEW_LINE_STR "\n" #endif const char BUILD_INFO_LOCATION sys_build_info[] = #if defined(ROM_BUILD) || defined(PROGRAMMER) - __DATE__ " " __TIME__ " " TO_STR(REVISION_INFO); + __DATE__ " " __TIME__ " " TO_STR(REVISION_INFO); #else NEW_LINE_STR "CHIP=" TO_STR(CHIP) #ifdef CHIP_SUBTYPE - NEW_LINE_STR "CHIP_SUBTYPE=" TO_STR(CHIP_SUBTYPE) + NEW_LINE_STR "CHIP_SUBTYPE=" TO_STR(CHIP_SUBTYPE) #endif - NEW_LINE_STR "KERNEL=" TO_STR(KERNEL) + NEW_LINE_STR "KERNEL=" TO_STR(KERNEL) #ifdef SOFTWARE_VERSION - NEW_LINE_STR "SW_VER=" TO_STR(SOFTWARE_VERSION) + NEW_LINE_STR "SW_VER=" TO_STR(SOFTWARE_VERSION) #endif #ifdef OTA_BOOT_SIZE - NEW_LINE_STR "SW_TYPE=OTA" - NEW_LINE_STR "OTA_BOOT_SIZE=" TO_STR(OTA_BOOT_SIZE) + NEW_LINE_STR + "SW_TYPE=OTA" NEW_LINE_STR "OTA_BOOT_SIZE=" TO_STR(OTA_BOOT_SIZE) #else - NEW_LINE_STR "CRASH_DUMP_SIZE=" TO_STR(CRASH_DUMP_SECTION_SIZE) - NEW_LINE_STR "AUD_SEC_SIZE=" TO_STR(AUD_SECTION_SIZE) - NEW_LINE_STR "USER_SEC_SIZE=" TO_STR(USERDATA_SECTION_SIZE) - NEW_LINE_STR "FACT_SEC_SIZE=" TO_STR(FACTORY_SECTION_SIZE) - NEW_LINE_STR "NV_REC_DEV_VER=" TO_STR(NV_REC_DEV_VER) + NEW_LINE_STR "CRASH_DUMP_SIZE=" TO_STR(CRASH_DUMP_SECTION_SIZE) + NEW_LINE_STR "AUD_SEC_SIZE=" TO_STR(AUD_SECTION_SIZE) + NEW_LINE_STR "USER_SEC_SIZE=" TO_STR(USERDATA_SECTION_SIZE) + NEW_LINE_STR + "FACT_SEC_SIZE=" TO_STR(FACTORY_SECTION_SIZE) NEW_LINE_STR + "NV_REC_DEV_VER=" TO_STR(NV_REC_DEV_VER) #endif - NEW_LINE_STR "FLASH_BASE=" TO_STR(FLASH_NC_BASE) - NEW_LINE_STR "FLASH_SIZE=" TO_STR(FLASH_SIZE) + NEW_LINE_STR "FLASH_BASE=" TO_STR(FLASH_NC_BASE) NEW_LINE_STR + "FLASH_SIZE=" TO_STR(FLASH_SIZE) #ifdef OTA_CODE_OFFSET - NEW_LINE_STR "OTA_CODE_OFFSET=" TO_STR(OTA_CODE_OFFSET) + NEW_LINE_STR "OTA_CODE_OFFSET=" TO_STR(OTA_CODE_OFFSET) #endif #ifdef OTA_REMAP_OFFSET - NEW_LINE_STR "OTA_REMAP_OFFSET=" TO_STR(OTA_REMAP_OFFSET) + NEW_LINE_STR "OTA_REMAP_OFFSET=" TO_STR(OTA_REMAP_OFFSET) #endif - NEW_LINE_STR "CRC32_OF_IMAGE=0x00000000" + NEW_LINE_STR "CRC32_OF_IMAGE=0x00000000" //-------------------- // Add new items above //-------------------- - NEW_LINE_STR "BUILD_DATE=" __DATE__ " " __TIME__ - NEW_LINE_STR "REV_INFO=" TO_STR(REVISION_INFO) - NEW_LINE_STR; + NEW_LINE_STR "BUILD_DATE=" __DATE__ " " __TIME__ NEW_LINE_STR + "REV_INFO=" TO_STR(REVISION_INFO) NEW_LINE_STR; #endif - diff --git a/utils/cqueue/cqueue.c b/utils/cqueue/cqueue.c index da0e0f1..8abc9d3 100644 --- a/utils/cqueue/cqueue.c +++ b/utils/cqueue/cqueue.c @@ -14,407 +14,369 @@ * ****************************************************************************/ /*** -* cqueue.c - c circle queue c file -*/ + * cqueue.c - c circle queue c file + */ #include "cqueue.h" -#include #include "cmsis.h" #include "hal_uart.h" +#include #include //#define DEBUG_CQUEUE 1 CQ_FUNC_ATTR -int InitCQueue(CQueue *Q, unsigned int size, CQItemType *buf) -{ - Q->size = size; - Q->base = buf; - Q->len = 0; - if (!Q->base) - return CQ_ERR; +int InitCQueue(CQueue *Q, unsigned int size, CQItemType *buf) { + Q->size = size; + Q->base = buf; + Q->len = 0; + if (!Q->base) + return CQ_ERR; - Q->read = Q->write = 0; + Q->read = Q->write = 0; + return CQ_OK; +} + +CQ_FUNC_ATTR +int IsEmptyCQueue(CQueue *Q) { + if (Q->len == 0) return CQ_OK; + else + return CQ_ERR; } CQ_FUNC_ATTR -int IsEmptyCQueue(CQueue *Q) -{ - if (Q->len == 0) - return CQ_OK; - else - return CQ_ERR; -} +int LengthOfCQueue(CQueue *Q) { return Q->len; } CQ_FUNC_ATTR -int LengthOfCQueue(CQueue *Q) -{ - return Q->len; -} - -CQ_FUNC_ATTR -int AvailableOfCQueue(CQueue *Q) -{ - return (Q->size - Q->len); -} +int AvailableOfCQueue(CQueue *Q) { return (Q->size - Q->len); } #if 1 CQ_FUNC_ATTR -int EnCQueue(CQueue *Q, CQItemType *e, unsigned int len) -{ - if (AvailableOfCQueue(Q) < len) { - return CQ_ERR; - } +int EnCQueue(CQueue *Q, CQItemType *e, unsigned int len) { + if (AvailableOfCQueue(Q) < len) { + return CQ_ERR; + } - Q->len += len; + Q->len += len; - uint32_t bytesToTheEnd = Q->size - Q->write; - if (bytesToTheEnd > len) - { - memcpy((uint8_t *)&Q->base[Q->write], (uint8_t *)e, len); - Q->write += len; - } - else - { - memcpy((uint8_t *)&Q->base[Q->write], (uint8_t *)e, bytesToTheEnd); - memcpy((uint8_t *)&Q->base[0], (((uint8_t *)e)+bytesToTheEnd), len-bytesToTheEnd); - Q->write = len-bytesToTheEnd; - } + uint32_t bytesToTheEnd = Q->size - Q->write; + if (bytesToTheEnd > len) { + memcpy((uint8_t *)&Q->base[Q->write], (uint8_t *)e, len); + Q->write += len; + } else { + memcpy((uint8_t *)&Q->base[Q->write], (uint8_t *)e, bytesToTheEnd); + memcpy((uint8_t *)&Q->base[0], (((uint8_t *)e) + bytesToTheEnd), + len - bytesToTheEnd); + Q->write = len - bytesToTheEnd; + } - return CQ_OK; + return CQ_OK; } +int EnCQueue_AI(CQueue *Q, CQItemType *e, unsigned int len) { + uint32_t bytesToTheEnd = Q->size - Q->write; + uint32_t readBytesToTheEnd = Q->size - Q->read; -int EnCQueue_AI(CQueue *Q, CQItemType *e, unsigned int len) -{ - uint32_t bytesToTheEnd = Q->size - Q->write; - uint32_t readBytesToTheEnd = Q->size - Q->read; - - if(AvailableOfCQueue(Q) < len) { - if(readBytesToTheEnd > len) { - Q->read += len; - } else { - Q->read = len - readBytesToTheEnd; - } + if (AvailableOfCQueue(Q) < len) { + if (readBytesToTheEnd > len) { + Q->read += len; } else { - Q->len += len; + Q->read = len - readBytesToTheEnd; } - - if (bytesToTheEnd > len) { - memcpy((uint8_t *)&Q->base[Q->write], (uint8_t *)e, len); - Q->write += len; - } else { - memcpy((uint8_t *)&Q->base[Q->write], (uint8_t *)e, bytesToTheEnd); - memcpy((uint8_t *)&Q->base[0], (((uint8_t *)e)+bytesToTheEnd), len-bytesToTheEnd); - Q->write = len-bytesToTheEnd; - } - - return CQ_OK; + } else { + Q->len += len; + } + + if (bytesToTheEnd > len) { + memcpy((uint8_t *)&Q->base[Q->write], (uint8_t *)e, len); + Q->write += len; + } else { + memcpy((uint8_t *)&Q->base[Q->write], (uint8_t *)e, bytesToTheEnd); + memcpy((uint8_t *)&Q->base[0], (((uint8_t *)e) + bytesToTheEnd), + len - bytesToTheEnd); + Q->write = len - bytesToTheEnd; + } + + return CQ_OK; } #else -static inline void memcpy_u8(void *dst, void *src, unsigned int len) -{ - unsigned int i = 0; - unsigned int *d8, *s8; - d8 = dst; - s8 = src; - for(i=0;i < len;i++) - d8[i] = s8[i]; +static inline void memcpy_u8(void *dst, void *src, unsigned int len) { + unsigned int i = 0; + unsigned int *d8, *s8; + d8 = dst; + s8 = src; + for (i = 0; i < len; i++) + d8[i] = s8[i]; } -static inline void memcpy_u32(void *dst, void *src, unsigned int len) -{ - unsigned int i = 0; - unsigned int *d32, *s32; - d32 = dst; - s32 = src; - for(i = 0;i < len;i++) - d32[i] = s32[i]; +static inline void memcpy_u32(void *dst, void *src, unsigned int len) { + unsigned int i = 0; + unsigned int *d32, *s32; + d32 = dst; + s32 = src; + for (i = 0; i < len; i++) + d32[i] = s32[i]; } CQ_FUNC_ATTR -int EnCQueue(CQueue *Q, CQItemType *e, unsigned int len) -{ - unsigned char *src = e; - unsigned char *dst = &(Q->base[Q->write]); +int EnCQueue(CQueue *Q, CQItemType *e, unsigned int len) { + unsigned char *src = e; + unsigned char *dst = &(Q->base[Q->write]); - unsigned int cnt_u8; - unsigned int cnt_u32; - unsigned int cnt_u32_res; + unsigned int cnt_u8; + unsigned int cnt_u32; + unsigned int cnt_u32_res; - unsigned int front_u8; - unsigned int front_u32; - unsigned int front_u32_res; + unsigned int front_u8; + unsigned int front_u32; + unsigned int front_u32_res; - unsigned int end_u8; - unsigned int end_u32; - unsigned int end_u32_res; + unsigned int end_u8; + unsigned int end_u32; + unsigned int end_u32_res; - bool unaligned_en; + bool unaligned_en; - if (AvailableOfCQueue(Q) < len) { - return CQ_ERR; + if (AvailableOfCQueue(Q) < len) { + return CQ_ERR; + } + + Q->len += len; + + end_u8 = Q->size - Q->write; + end_u32 = end_u8 / 4; + end_u32_res = end_u8 % 4; + + cnt_u8 = len; + cnt_u32 = cnt_u8 / 4; + cnt_u32_res = cnt_u8 % 4; + + unaligned_en = config_unaligned_access(true); + + if (cnt_u8 <= end_u8) { + memcpy_u32(dst, src, cnt_u32); + + if (cnt_u32_res) { + src += cnt_u32 * 4; + dst += cnt_u32 * 4; + memcpy_u8(dst, src, cnt_u32_res); } - Q->len += len; + // Deal with Q->write + Q->write += cnt_u8; - end_u8 = Q->size - Q->write; - end_u32 = end_u8 / 4; - end_u32_res = end_u8 % 4; + } else { + front_u8 = len - end_u8; + front_u32 = front_u8 / 4; + front_u32_res = front_u8 % 4; - cnt_u8 = len; - cnt_u32 = cnt_u8 / 4; - cnt_u32_res = cnt_u8 % 4; + // Deal with end data + memcpy_u32(dst, src, end_u32); + src += end_u32 * 4; + dst += end_u32 * 4; - unaligned_en = config_unaligned_access(true); + memcpy_u8(dst, src, end_u32_res); + src += end_u32_res; + dst = &(Q->base[0]); - if(cnt_u8 <= end_u8) - { - memcpy_u32(dst, src, cnt_u32); + // Deal with front data + memcpy_u32(dst, src, front_u32); - if(cnt_u32_res) - { - src += cnt_u32 * 4; - dst += cnt_u32 * 4; - memcpy_u8(dst, src, cnt_u32_res); - } + if (front_u32_res) { + src += front_u32 * 4; + dst += front_u32 * 4; - // Deal with Q->write - Q->write += cnt_u8; - - } - else - { - front_u8 = len - end_u8; - front_u32 = front_u8 / 4; - front_u32_res = front_u8 % 4; - - // Deal with end data - memcpy_u32(dst, src, end_u32); - src += end_u32 * 4; - dst += end_u32 * 4; - - memcpy_u8(dst, src, end_u32_res); - src += end_u32_res; - dst = &(Q->base[0]); - - // Deal with front data - memcpy_u32(dst, src, front_u32); - - if(front_u32_res) - { - src += front_u32 * 4; - dst += front_u32 * 4; - - memcpy_u8(dst, src, front_u32_res); - } - - // Deal with Q->write - Q->write = front_u8; + memcpy_u8(dst, src, front_u32_res); } - config_unaligned_access(unaligned_en); + // Deal with Q->write + Q->write = front_u8; + } - return CQ_OK; + config_unaligned_access(unaligned_en); + + return CQ_OK; } -void memcpy_fast(char *dst, char *src, unsigned int len) -{ - int size = len/4; - int mod = len%4; +void memcpy_fast(char *dst, char *src, unsigned int len) { + int size = len / 4; + int mod = len % 4; - int *Dst = (int *)dst; - int *Src = (int *)src; + int *Dst = (int *)dst; + int *Src = (int *)src; - int dst_offset = (int)Dst - (int)dst; - int src_offset = (int)Src -(int)src; + int dst_offset = (int)Dst - (int)dst; + int src_offset = (int)Src - (int)src; - if(!dst_offset && !src_offset){ - memcpy_u32(Dst, Src, size); - if(mod){ - memcpy_u8(Dst + size, Src + size, mod); - } - }else{ - memcpy_u8(dst, src, len); + if (!dst_offset && !src_offset) { + memcpy_u32(Dst, Src, size); + if (mod) { + memcpy_u8(Dst + size, Src + size, mod); } + } else { + memcpy_u8(dst, src, len); + } } #endif CQ_FUNC_ATTR -int EnCQueueFront(CQueue *Q, CQItemType *e, unsigned int len) -{ - if (AvailableOfCQueue(Q) < len) { - return CQ_ERR; - } - - Q->len += len; - - /* walk to last item , revert write */ - e = e + len - 1; - - if(Q->read == 0) - Q->read = Q->size - 1; - else - Q->read--; - - while(len > 0) { - Q->base[Q->read] = *e; - - --Q->read; - --e; - --len; - - if(Q->read < 0) - Q->read = Q->size - 1; - } - - /* we walk one more, walk back */ - if(Q->read == Q->size - 1) - Q->read = 0; - else - ++Q->read; - - return CQ_OK; -} - -CQ_FUNC_ATTR -int DeCQueue(CQueue *Q, CQItemType *e, unsigned int len) -{ - if(LengthOfCQueue(Q) < len) - return CQ_ERR; - - Q->len -= len; - - if(e != NULL) - { - uint32_t bytesToTheEnd = Q->size - Q->read; - if (bytesToTheEnd > len) - { - memcpy((uint8_t *)e, (uint8_t *)&Q->base[Q->read], len); - Q->read += len; - } - else - { - memcpy((uint8_t *)e, (uint8_t *)&Q->base[Q->read], bytesToTheEnd); - memcpy((((uint8_t *)e)+bytesToTheEnd), (uint8_t *)&Q->base[0], len-bytesToTheEnd); - Q->read = len-bytesToTheEnd; - } - } - else - { - if (0 < Q->size) - { - Q->read = (Q->read+len)%Q->size; - } - else - { - Q->read = 0; - } - } - - return CQ_OK; -} - -CQ_FUNC_ATTR -int PeekCQueue(CQueue *Q, unsigned int len_want, CQItemType **e1, unsigned int *len1, CQItemType **e2, unsigned int *len2) -{ - if(LengthOfCQueue(Q) < len_want) { - return CQ_ERR; - } - - *e1 = &(Q->base[Q->read]); - if((Q->write > Q->read) || (Q->size - Q->read >= len_want)) { - *len1 = len_want; - *e2 = NULL; - *len2 = 0; - return CQ_OK; - } - else { - *len1 = Q->size - Q->read; - *e2 = &(Q->base[0]); - *len2 = len_want - *len1; - return CQ_OK; - } - +int EnCQueueFront(CQueue *Q, CQItemType *e, unsigned int len) { + if (AvailableOfCQueue(Q) < len) { return CQ_ERR; + } + + Q->len += len; + + /* walk to last item , revert write */ + e = e + len - 1; + + if (Q->read == 0) + Q->read = Q->size - 1; + else + Q->read--; + + while (len > 0) { + Q->base[Q->read] = *e; + + --Q->read; + --e; + --len; + + if (Q->read < 0) + Q->read = Q->size - 1; + } + + /* we walk one more, walk back */ + if (Q->read == Q->size - 1) + Q->read = 0; + else + ++Q->read; + + return CQ_OK; } -int PeekCQueueToBuf(CQueue *Q, CQItemType *e, unsigned int len) -{ - int status = CQ_OK; - unsigned char *e1 = NULL, *e2 = NULL; - unsigned int len1 = 0, len2 = 0; - - status = PeekCQueue(Q, len, &e1, &len1, &e2, &len2); +CQ_FUNC_ATTR +int DeCQueue(CQueue *Q, CQItemType *e, unsigned int len) { + if (LengthOfCQueue(Q) < len) + return CQ_ERR; - if(status == CQ_OK) { - if (len == (len1 + len2)) { - memcpy(e, e1, len1); - memcpy(e + len1, e2, len2); - } else { - status = CQ_ERR; - } + Q->len -= len; + + if (e != NULL) { + uint32_t bytesToTheEnd = Q->size - Q->read; + if (bytesToTheEnd > len) { + memcpy((uint8_t *)e, (uint8_t *)&Q->base[Q->read], len); + Q->read += len; + } else { + memcpy((uint8_t *)e, (uint8_t *)&Q->base[Q->read], bytesToTheEnd); + memcpy((((uint8_t *)e) + bytesToTheEnd), (uint8_t *)&Q->base[0], + len - bytesToTheEnd); + Q->read = len - bytesToTheEnd; } + } else { + if (0 < Q->size) { + Q->read = (Q->read + len) % Q->size; + } else { + Q->read = 0; + } + } - return status; + return CQ_OK; } -int PullCQueue(CQueue *Q, CQItemType *e, unsigned int len) -{ - int status = CQ_OK; - unsigned char *e1 = NULL, *e2 = NULL; - unsigned int len1 = 0, len2 = 0; - - status = PeekCQueue(Q, len, &e1, &len1, &e2, &len2); +CQ_FUNC_ATTR +int PeekCQueue(CQueue *Q, unsigned int len_want, CQItemType **e1, + unsigned int *len1, CQItemType **e2, unsigned int *len2) { + if (LengthOfCQueue(Q) < len_want) { + return CQ_ERR; + } - if(status == CQ_OK){ - if (len == (len1 + len2)){ - memcpy(e, e1, len1); - memcpy(e + len1, e2, len2); - DeCQueue(Q, 0, len); - }else{ - status = CQ_ERR; - } + *e1 = &(Q->base[Q->read]); + if ((Q->write > Q->read) || (Q->size - Q->read >= len_want)) { + *len1 = len_want; + *e2 = NULL; + *len2 = 0; + return CQ_OK; + } else { + *len1 = Q->size - Q->read; + *e2 = &(Q->base[0]); + *len2 = len_want - *len1; + return CQ_OK; + } + + return CQ_ERR; +} + +int PeekCQueueToBuf(CQueue *Q, CQItemType *e, unsigned int len) { + int status = CQ_OK; + unsigned char *e1 = NULL, *e2 = NULL; + unsigned int len1 = 0, len2 = 0; + + status = PeekCQueue(Q, len, &e1, &len1, &e2, &len2); + + if (status == CQ_OK) { + if (len == (len1 + len2)) { + memcpy(e, e1, len1); + memcpy(e + len1, e2, len2); + } else { + status = CQ_ERR; } + } - return status; + return status; +} + +int PullCQueue(CQueue *Q, CQItemType *e, unsigned int len) { + int status = CQ_OK; + unsigned char *e1 = NULL, *e2 = NULL; + unsigned int len1 = 0, len2 = 0; + + status = PeekCQueue(Q, len, &e1, &len1, &e2, &len2); + + if (status == CQ_OK) { + if (len == (len1 + len2)) { + memcpy(e, e1, len1); + memcpy(e + len1, e2, len2); + DeCQueue(Q, 0, len); + } else { + status = CQ_ERR; + } + } + + return status; } #ifdef DEBUG_CQUEUE -int DumpCQueue(CQueue *Q) -{ - CQItemType e; - int len = 0, i = 0; +int DumpCQueue(CQueue *Q) { + CQItemType e; + int len = 0, i = 0; - len = LengthOfCQueue(Q); - - if(len <= 0) - return CQ_ERR; - - i = Q->read; - while(len > 0) { - e = Q->base[i]; - - TRACE(stderr, "-0x%x", e); - TRACE(stderr, "-%c", e); - - ++i; - --len; - if(i == Q->size) - i = 0; - } + len = LengthOfCQueue(Q); + if (len <= 0) return CQ_ERR; + + i = Q->read; + while (len > 0) { + e = Q->base[i]; + + TRACE(stderr, "-0x%x", e); + TRACE(stderr, "-%c", e); + + ++i; + --len; + if (i == Q->size) + i = 0; + } + + return CQ_ERR; } #endif -void ResetCQueue(CQueue *Q) -{ - Q->len = 0; - Q->read = Q->write = 0; +void ResetCQueue(CQueue *Q) { + Q->len = 0; + Q->read = Q->write = 0; } - - diff --git a/utils/crash_catcher/CrashCatcher.c b/utils/crash_catcher/CrashCatcher.c index f9b9014..6cdce65 100644 --- a/utils/crash_catcher/CrashCatcher.c +++ b/utils/crash_catcher/CrashCatcher.c @@ -12,394 +12,385 @@ See the License for the specific language governing permissions and limitations under the License. */ -#include #include "CrashCatcherPriv.h" +#include #include //#include "cmsis_os.h" #include "cmsis_nvic.h" - -/* Test harness will define this value on 64-bit machine to provide upper 32-bits of pointer addresses. */ +/* Test harness will define this value on 64-bit machine to provide upper + * 32-bits of pointer addresses. */ CRASH_CATCHER_TEST_WRITEABLE uint64_t g_crashCatcherTestBaseAddress; -/* The unit tests can point the core to a fake location for the SCB->CPUID register. */ -CRASH_CATCHER_TEST_WRITEABLE uint32_t* g_pCrashCatcherCpuId = (uint32_t*)0xE000ED00; +/* The unit tests can point the core to a fake location for the SCB->CPUID + * register. */ +CRASH_CATCHER_TEST_WRITEABLE uint32_t *g_pCrashCatcherCpuId = + (uint32_t *)0xE000ED00; -/* The unit tests can point the core to a fake location for the fault status registers. */ -CRASH_CATCHER_TEST_WRITEABLE uint32_t* g_pCrashCatcherFaultStatusRegisters = (uint32_t*)0xE000ED28; +/* The unit tests can point the core to a fake location for the fault status + * registers. */ +CRASH_CATCHER_TEST_WRITEABLE uint32_t *g_pCrashCatcherFaultStatusRegisters = + (uint32_t *)0xE000ED28; -/* The unit tests can point the core to a fake location for the Coprocessor Access Control Register. */ -CRASH_CATCHER_TEST_WRITEABLE uint32_t* g_pCrashCatcherCoprocessorAccessControlRegister = (uint32_t*)0xE000ED88; +/* The unit tests can point the core to a fake location for the Coprocessor + * Access Control Register. */ +CRASH_CATCHER_TEST_WRITEABLE uint32_t + *g_pCrashCatcherCoprocessorAccessControlRegister = (uint32_t *)0xE000ED88; - -/* Fault handler will switch MSP to use this area as the stack while CrashCatcher code is running. - NOTE: If you change the size of this buffer, it also needs to be changed in the HardFault_Handler (in - FaultHandler_arm*.S) when initializing the stack pointer. */ +/* Fault handler will switch MSP to use this area as the stack while + CrashCatcher code is running. NOTE: If you change the size of this buffer, it + also needs to be changed in the HardFault_Handler (in FaultHandler_arm*.S) + when initializing the stack pointer. */ uint32_t g_crashCatcherStack[CRASH_CATCHER_STACK_WORD_COUNT]; - -typedef struct -{ - const CrashCatcherExceptionRegisters* pExceptionRegisters; - CrashCatcherStackedRegisters* pSP; - uint32_t flags; - CrashCatcherInfo info; +typedef struct { + const CrashCatcherExceptionRegisters *pExceptionRegisters; + CrashCatcherStackedRegisters *pSP; + uint32_t flags; + CrashCatcherInfo info; } Object; - -static Object initStackPointers(const CrashCatcherExceptionRegisters* pExceptionRegisters); -static uint32_t getAddressOfExceptionStack(const CrashCatcherExceptionRegisters* pExceptionRegisters); -static void* uint32AddressToPointer(uint32_t address); -static void advanceStackPointerToValueBeforeException(Object* pObject); -static int areFloatingPointRegistersAutoStacked(const Object* pObject); -static void initFloatingPointFlag(Object* pObject); +static Object +initStackPointers(const CrashCatcherExceptionRegisters *pExceptionRegisters); +static uint32_t getAddressOfExceptionStack( + const CrashCatcherExceptionRegisters *pExceptionRegisters); +static void *uint32AddressToPointer(uint32_t address); +static void advanceStackPointerToValueBeforeException(Object *pObject); +static int areFloatingPointRegistersAutoStacked(const Object *pObject); +static void initFloatingPointFlag(Object *pObject); static int areFloatingPointCoprocessorsEnabled(void); -static void initIsBKPT(Object* pObject); +static void initIsBKPT(Object *pObject); static int isBKPT(uint16_t instruction); static void setStackSentinel(void); static void dumpSignature(void); -static void dumpFlags(const Object* pObject); -static void dumpR0toR3(const Object* pObject); -static void dumpR4toR11(const Object* pObject); -static void dumpR12(const Object* pObject); -static void dumpSP(const Object* pObject); -static void dumpLR_PC_PSR(const Object* pObject); -static void dumpMSPandPSPandExceptionPSR(const Object* pObject); -static void dumpFloatingPointRegisters(const Object* pObject); -static void dumpMemoryRegions(const CrashCatcherMemoryRegion* pRegion); +static void dumpFlags(const Object *pObject); +static void dumpR0toR3(const Object *pObject); +static void dumpR4toR11(const Object *pObject); +static void dumpR12(const Object *pObject); +static void dumpSP(const Object *pObject); +static void dumpLR_PC_PSR(const Object *pObject); +static void dumpMSPandPSPandExceptionPSR(const Object *pObject); +static void dumpFloatingPointRegisters(const Object *pObject); +static void dumpMemoryRegions(const CrashCatcherMemoryRegion *pRegion); static void checkStackSentinelForStackOverflow(void); static int isARMv6MDevice(void); static void dumpFaultStatusRegisters(void); -static void advanceProgramCounterPastHardcodedBreakpoint(const Object* pObject); -static void dumpMSPandPSPandExceptionPSRinAssert(const Object* pObject); +static void advanceProgramCounterPastHardcodedBreakpoint(const Object *pObject); +static void dumpMSPandPSPandExceptionPSRinAssert(const Object *pObject); struct TaskRegs { - uint32_t r0; - uint32_t r1; - uint32_t r2; - uint32_t r3; - uint32_t r4; - uint32_t r5; - uint32_t r6; - uint32_t r7; - uint32_t r8; - uint32_t r9; - uint32_t r10; - uint32_t r11; - uint32_t r12; - uint32_t sp; - uint32_t lr; - uint32_t pc; - uint32_t psr; + uint32_t r0; + uint32_t r1; + uint32_t r2; + uint32_t r3; + uint32_t r4; + uint32_t r5; + uint32_t r6; + uint32_t r7; + uint32_t r8; + uint32_t r9; + uint32_t r10; + uint32_t r11; + uint32_t r12; + uint32_t sp; + uint32_t lr; + uint32_t pc; + uint32_t psr; }; static void dumpTaskRegs(const struct TaskRegs *regs); -void AssertCatcher_Entry(void) -{ - register uint32_t r0 asm("r0"); - register uint32_t r1 asm("r1"); - register uint32_t r2 asm("r2"); - register uint32_t r3 asm("r3"); - register uint32_t r4 asm("r4"); - register uint32_t r5 asm("r5"); - register uint32_t r6 asm("r6"); - register uint32_t r7 asm("r7"); - register uint32_t r8 asm("r8"); - register uint32_t r9 asm("r9"); - register uint32_t r10 asm("r10"); - register uint32_t r11 asm("r11"); - register uint32_t r12 asm("r12"); - register uint32_t sp asm("sp"); - register uint32_t lr asm("lr"); - uint32_t pc; - struct TaskRegs regs; +void AssertCatcher_Entry(void) { + register uint32_t r0 asm("r0"); + register uint32_t r1 asm("r1"); + register uint32_t r2 asm("r2"); + register uint32_t r3 asm("r3"); + register uint32_t r4 asm("r4"); + register uint32_t r5 asm("r5"); + register uint32_t r6 asm("r6"); + register uint32_t r7 asm("r7"); + register uint32_t r8 asm("r8"); + register uint32_t r9 asm("r9"); + register uint32_t r10 asm("r10"); + register uint32_t r11 asm("r11"); + register uint32_t r12 asm("r12"); + register uint32_t sp asm("sp"); + register uint32_t lr asm("lr"); + uint32_t pc; + struct TaskRegs regs; #ifdef __ARMCC_VERSION - asm volatile ("" : "=r"(r0), "=r"(r1), "=r"(r2), "=r"(r3), "=r"(r4), "=r"(r5), "=r"(r6), "=r"(r7), - "=r"(r8), "=r"(r9), "=r"(r10), "=r"(r11), "=r"(r12), "=r"(sp), "=r"(lr)); + asm volatile("" + : "=r"(r0), "=r"(r1), "=r"(r2), "=r"(r3), "=r"(r4), "=r"(r5), + "=r"(r6), "=r"(r7), "=r"(r8), "=r"(r9), "=r"(r10), "=r"(r11), + "=r"(r12), "=r"(sp), "=r"(lr)); #endif - regs.r0 = r0; - regs.r1 = r1; - regs.r2 = r2; - regs.r3 = r3; - regs.r4 = r4; - regs.r5 = r5; - regs.r6 = r6; - regs.r7 = r7; - regs.r8 = r8; - regs.r9 = r9; - regs.r10 = r10; - regs.r11 = r11; - regs.r12 = r12; - regs.sp = sp; - regs.lr = lr; - __asm volatile ("mov %0, r15" : "=r" (pc)); - regs.psr = __get_xPSR(); - regs.pc = pc; + regs.r0 = r0; + regs.r1 = r1; + regs.r2 = r2; + regs.r3 = r3; + regs.r4 = r4; + regs.r5 = r5; + regs.r6 = r6; + regs.r7 = r7; + regs.r8 = r8; + regs.r9 = r9; + regs.r10 = r10; + regs.r11 = r11; + regs.r12 = r12; + regs.sp = sp; + regs.lr = lr; + __asm volatile("mov %0, r15" : "=r"(pc)); + regs.psr = __get_xPSR(); + regs.pc = pc; - int ret; - Object object; - object.flags = 0; + int ret; + Object object; + object.flags = 0; - do - { - ret = CrashCatcher_DumpStart(NULL); - if (ret) - break; + do { + ret = CrashCatcher_DumpStart(NULL); + if (ret) + break; - dumpSignature(); - dumpFlags(&object); + dumpSignature(); + dumpFlags(&object); - dumpTaskRegs(®s); + dumpTaskRegs(®s); - dumpMSPandPSPandExceptionPSRinAssert(NULL); - /* - if (object.flags & CRASH_CATCHER_FLAGS_FLOATING_POINT) - dumpFloatingPointRegisters(&object); - */ - dumpMemoryRegions(CrashCatcher_GetMemoryRegions()); - if (!isARMv6MDevice()) - dumpFaultStatusRegisters(); - - } - while (CrashCatcher_DumpEnd() == CRASH_CATCHER_TRY_AGAIN); -} - -void CrashCatcher_Entry(const CrashCatcherExceptionRegisters* pExceptionRegisters) -{ - int ret; - Object object = initStackPointers(pExceptionRegisters); - advanceStackPointerToValueBeforeException(&object); - initFloatingPointFlag(&object); - initIsBKPT(&object); - - do - { - setStackSentinel(); - ret = CrashCatcher_DumpStart(&object.info); - if (ret) - break; - - dumpSignature(); - dumpFlags(&object); - dumpR0toR3(&object); - dumpR4toR11(&object); - dumpR12(&object); - dumpSP(&object); - dumpLR_PC_PSR(&object); - dumpMSPandPSPandExceptionPSR(&object); - if (object.flags & CRASH_CATCHER_FLAGS_FLOATING_POINT) - dumpFloatingPointRegisters(&object); - dumpMemoryRegions(CrashCatcher_GetMemoryRegions()); - if (!isARMv6MDevice()) - dumpFaultStatusRegisters(); - checkStackSentinelForStackOverflow(); - } - while (CrashCatcher_DumpEnd() == CRASH_CATCHER_TRY_AGAIN); - - advanceProgramCounterPastHardcodedBreakpoint(&object); -} - -static Object initStackPointers(const CrashCatcherExceptionRegisters* pExceptionRegisters) -{ - Object object; - object.pExceptionRegisters = pExceptionRegisters; - object.info.sp = getAddressOfExceptionStack(pExceptionRegisters); - object.pSP = uint32AddressToPointer(object.info.sp); - object.flags = 0; - return object; -} - -static uint32_t getAddressOfExceptionStack(const CrashCatcherExceptionRegisters* pExceptionRegisters) -{ - /*always return psp */ - return pExceptionRegisters->psp; + dumpMSPandPSPandExceptionPSRinAssert(NULL); /* - if (pExceptionRegisters->exceptionLR & LR_PSP) - return pExceptionRegisters->psp; - else - return pExceptionRegisters->msp; + if (object.flags & CRASH_CATCHER_FLAGS_FLOATING_POINT) + dumpFloatingPointRegisters(&object); */ + dumpMemoryRegions(CrashCatcher_GetMemoryRegions()); + if (!isARMv6MDevice()) + dumpFaultStatusRegisters(); + + } while (CrashCatcher_DumpEnd() == CRASH_CATCHER_TRY_AGAIN); } -static void* uint32AddressToPointer(uint32_t address) -{ - if (sizeof(uint32_t*) == 8) - return (void*)(unsigned long)((uint64_t)address | g_crashCatcherTestBaseAddress); - else - return (void*)(unsigned long)address; +void CrashCatcher_Entry( + const CrashCatcherExceptionRegisters *pExceptionRegisters) { + int ret; + Object object = initStackPointers(pExceptionRegisters); + advanceStackPointerToValueBeforeException(&object); + initFloatingPointFlag(&object); + initIsBKPT(&object); + + do { + setStackSentinel(); + ret = CrashCatcher_DumpStart(&object.info); + if (ret) + break; + + dumpSignature(); + dumpFlags(&object); + dumpR0toR3(&object); + dumpR4toR11(&object); + dumpR12(&object); + dumpSP(&object); + dumpLR_PC_PSR(&object); + dumpMSPandPSPandExceptionPSR(&object); + if (object.flags & CRASH_CATCHER_FLAGS_FLOATING_POINT) + dumpFloatingPointRegisters(&object); + dumpMemoryRegions(CrashCatcher_GetMemoryRegions()); + if (!isARMv6MDevice()) + dumpFaultStatusRegisters(); + checkStackSentinelForStackOverflow(); + } while (CrashCatcher_DumpEnd() == CRASH_CATCHER_TRY_AGAIN); + + advanceProgramCounterPastHardcodedBreakpoint(&object); } -static void advanceStackPointerToValueBeforeException(Object* pObject) -{ - /* Cortex-M processor always push 8 integer registers on the stack. */ - pObject->info.sp += 8 * sizeof(uint32_t); - /* ARMv7-M processors can also push 16 single-precision floating point registers, FPSCR and a padding word. */ - if (areFloatingPointRegistersAutoStacked(pObject)) - pObject->info.sp += (16 + 1 + 1) * sizeof(uint32_t); - /* Cortex-M processor may also have had to force 8-byte alignment before auto stacking registers. */ - pObject->info.sp |= (pObject->pSP->psr & PSR_STACK_ALIGN) ? 4 : 0; +static Object +initStackPointers(const CrashCatcherExceptionRegisters *pExceptionRegisters) { + Object object; + object.pExceptionRegisters = pExceptionRegisters; + object.info.sp = getAddressOfExceptionStack(pExceptionRegisters); + object.pSP = uint32AddressToPointer(object.info.sp); + object.flags = 0; + return object; } -static int areFloatingPointRegistersAutoStacked(const Object* pObject) -{ - //return 0 == (pObject->pExceptionRegisters->exceptionLR & LR_FLOAT); - return 0; +static uint32_t getAddressOfExceptionStack( + const CrashCatcherExceptionRegisters *pExceptionRegisters) { + /*always return psp */ + return pExceptionRegisters->psp; + /* + if (pExceptionRegisters->exceptionLR & LR_PSP) + return pExceptionRegisters->psp; + else + return pExceptionRegisters->msp; + */ } -static void initFloatingPointFlag(Object* pObject) -{ - if (areFloatingPointCoprocessorsEnabled()) - pObject->flags |= CRASH_CATCHER_FLAGS_FLOATING_POINT; +static void *uint32AddressToPointer(uint32_t address) { + if (sizeof(uint32_t *) == 8) + return (void *)(unsigned long)((uint64_t)address | + g_crashCatcherTestBaseAddress); + else + return (void *)(unsigned long)address; } -static int areFloatingPointCoprocessorsEnabled(void) -{ - static const uint32_t coProcessor10and11EnabledBits = 5 << 20; - uint32_t coprocessorAccessControl = *g_pCrashCatcherCoprocessorAccessControlRegister; - - return (coprocessorAccessControl & (coProcessor10and11EnabledBits)) == coProcessor10and11EnabledBits; +static void advanceStackPointerToValueBeforeException(Object *pObject) { + /* Cortex-M processor always push 8 integer registers on the stack. */ + pObject->info.sp += 8 * sizeof(uint32_t); + /* ARMv7-M processors can also push 16 single-precision floating point + * registers, FPSCR and a padding word. */ + if (areFloatingPointRegistersAutoStacked(pObject)) + pObject->info.sp += (16 + 1 + 1) * sizeof(uint32_t); + /* Cortex-M processor may also have had to force 8-byte alignment before auto + * stacking registers. */ + pObject->info.sp |= (pObject->pSP->psr & PSR_STACK_ALIGN) ? 4 : 0; } -static void initIsBKPT(Object* pObject) -{ - const uint16_t* pInstruction = uint32AddressToPointer(pObject->pSP->pc); - - pObject->info.isBKPT = isBKPT(*pInstruction); +static int areFloatingPointRegistersAutoStacked(const Object *pObject) { + // return 0 == (pObject->pExceptionRegisters->exceptionLR & LR_FLOAT); + return 0; } -static int isBKPT(uint16_t instruction) -{ - return (instruction & 0xFF00) == 0xBE00; +static void initFloatingPointFlag(Object *pObject) { + if (areFloatingPointCoprocessorsEnabled()) + pObject->flags |= CRASH_CATCHER_FLAGS_FLOATING_POINT; } -static void setStackSentinel(void) -{ - g_crashCatcherStack[0] = CRASH_CATCHER_STACK_SENTINEL; +static int areFloatingPointCoprocessorsEnabled(void) { + static const uint32_t coProcessor10and11EnabledBits = 5 << 20; + uint32_t coprocessorAccessControl = + *g_pCrashCatcherCoprocessorAccessControlRegister; + + return (coprocessorAccessControl & (coProcessor10and11EnabledBits)) == + coProcessor10and11EnabledBits; } -static void dumpSignature(void) -{ - static const uint8_t signature[4] = {CRASH_CATCHER_SIGNATURE_BYTE0, - CRASH_CATCHER_SIGNATURE_BYTE1, - CRASH_CATCHER_VERSION_MAJOR, - CRASH_CATCHER_VERSION_MINOR}; +static void initIsBKPT(Object *pObject) { + const uint16_t *pInstruction = uint32AddressToPointer(pObject->pSP->pc); - CrashCatcher_DumpMemory(signature, CRASH_CATCHER_BYTE, sizeof(signature)); + pObject->info.isBKPT = isBKPT(*pInstruction); } -static void dumpFlags(const Object* pObject) -{ - CrashCatcher_DumpMemory(&pObject->flags, CRASH_CATCHER_BYTE, sizeof(pObject->flags)); +static int isBKPT(uint16_t instruction) { + return (instruction & 0xFF00) == 0xBE00; } -static void dumpR0toR3(const Object* pObject) -{ - CrashCatcher_DumpMemory(&pObject->pSP->r0, CRASH_CATCHER_BYTE, 4 * sizeof(uint32_t)); +static void setStackSentinel(void) { + g_crashCatcherStack[0] = CRASH_CATCHER_STACK_SENTINEL; } -static void dumpTaskRegs(const struct TaskRegs *regs) -{ - CrashCatcher_DumpMemory(regs, CRASH_CATCHER_BYTE, sizeof(struct TaskRegs)); +static void dumpSignature(void) { + static const uint8_t signature[4] = { + CRASH_CATCHER_SIGNATURE_BYTE0, CRASH_CATCHER_SIGNATURE_BYTE1, + CRASH_CATCHER_VERSION_MAJOR, CRASH_CATCHER_VERSION_MINOR}; + + CrashCatcher_DumpMemory(signature, CRASH_CATCHER_BYTE, sizeof(signature)); } -static void dumpR4toR11(const Object* pObject) -{ - CrashCatcher_DumpMemory(&pObject->pExceptionRegisters->r4, CRASH_CATCHER_BYTE, (11 - 4 + 1) * sizeof(uint32_t)); +static void dumpFlags(const Object *pObject) { + CrashCatcher_DumpMemory(&pObject->flags, CRASH_CATCHER_BYTE, + sizeof(pObject->flags)); } -static void dumpR12(const Object* pObject) -{ - CrashCatcher_DumpMemory(&pObject->pSP->r12, CRASH_CATCHER_BYTE, sizeof(uint32_t)); +static void dumpR0toR3(const Object *pObject) { + CrashCatcher_DumpMemory(&pObject->pSP->r0, CRASH_CATCHER_BYTE, + 4 * sizeof(uint32_t)); } -static void dumpSP(const Object* pObject) -{ - CrashCatcher_DumpMemory(&pObject->info.sp, CRASH_CATCHER_BYTE, sizeof(uint32_t)); +static void dumpTaskRegs(const struct TaskRegs *regs) { + CrashCatcher_DumpMemory(regs, CRASH_CATCHER_BYTE, sizeof(struct TaskRegs)); } -static void dumpLR_PC_PSR(const Object* pObject) -{ - CrashCatcher_DumpMemory(&pObject->pSP->lr, CRASH_CATCHER_BYTE, 3 * sizeof(uint32_t)); +static void dumpR4toR11(const Object *pObject) { + CrashCatcher_DumpMemory(&pObject->pExceptionRegisters->r4, CRASH_CATCHER_BYTE, + (11 - 4 + 1) * sizeof(uint32_t)); } -static void dumpMSPandPSPandExceptionPSR(const Object* pObject) -{ - CrashCatcher_DumpMemory(&pObject->pExceptionRegisters->msp, CRASH_CATCHER_BYTE, 3 * sizeof(uint32_t)); +static void dumpR12(const Object *pObject) { + CrashCatcher_DumpMemory(&pObject->pSP->r12, CRASH_CATCHER_BYTE, + sizeof(uint32_t)); } -static void dumpMSPandPSPandExceptionPSRinAssert(const Object* pObject) -{ - uint32_t msp = __get_MSP(); - uint32_t psp = __get_PSP(); - uint32_t exceptionPSR = __get_xPSR(); - - CrashCatcher_DumpMemory(&msp, CRASH_CATCHER_BYTE, sizeof(uint32_t)); - CrashCatcher_DumpMemory(&psp, CRASH_CATCHER_BYTE, sizeof(uint32_t)); - CrashCatcher_DumpMemory(&exceptionPSR, CRASH_CATCHER_BYTE, sizeof(uint32_t)); +static void dumpSP(const Object *pObject) { + CrashCatcher_DumpMemory(&pObject->info.sp, CRASH_CATCHER_BYTE, + sizeof(uint32_t)); } -static void dumpFloatingPointRegisters(const Object* pObject) -{ - uint32_t allFloatingPointRegisters[32 + 1]; - if (areFloatingPointRegistersAutoStacked(pObject)) - { - /* Copy the upper floats first as that will cause a lazy copy of the auto-stacked registers. */ - CrashCatcher_CopyUpperFloatingPointRegisters(&allFloatingPointRegisters[16]); - memcpy(&allFloatingPointRegisters[0], &pObject->pSP->floats, sizeof(pObject->pSP->floats)); - allFloatingPointRegisters[32] = pObject->pSP->fpscr; - } - else - { - CrashCatcher_CopyAllFloatingPointRegisters(allFloatingPointRegisters); - } - CrashCatcher_DumpMemory(allFloatingPointRegisters, CRASH_CATCHER_BYTE, sizeof(allFloatingPointRegisters)); +static void dumpLR_PC_PSR(const Object *pObject) { + CrashCatcher_DumpMemory(&pObject->pSP->lr, CRASH_CATCHER_BYTE, + 3 * sizeof(uint32_t)); } -static void dumpMemoryRegions(const CrashCatcherMemoryRegion* pRegion) -{ - while (pRegion && pRegion->startAddress != 0xFFFFFFFF) - { - /* Just dump the two addresses in pRegion. The element size isn't required. */ - CrashCatcher_DumpMemory(pRegion, CRASH_CATCHER_BYTE, 2 * sizeof(uint32_t)); - CrashCatcher_DumpMemory(uint32AddressToPointer(pRegion->startAddress), - pRegion->elementSize, - (pRegion->endAddress - pRegion->startAddress) / pRegion->elementSize); - pRegion++; - } +static void dumpMSPandPSPandExceptionPSR(const Object *pObject) { + CrashCatcher_DumpMemory(&pObject->pExceptionRegisters->msp, + CRASH_CATCHER_BYTE, 3 * sizeof(uint32_t)); } -static void checkStackSentinelForStackOverflow(void) -{ - if (g_crashCatcherStack[0] != CRASH_CATCHER_STACK_SENTINEL) - { - uint8_t value[4] = {0xAC, 0xCE, 0x55, 0xED}; - CrashCatcher_DumpMemory(value, CRASH_CATCHER_BYTE, sizeof(value)); - } +static void dumpMSPandPSPandExceptionPSRinAssert(const Object *pObject) { + uint32_t msp = __get_MSP(); + uint32_t psp = __get_PSP(); + uint32_t exceptionPSR = __get_xPSR(); + + CrashCatcher_DumpMemory(&msp, CRASH_CATCHER_BYTE, sizeof(uint32_t)); + CrashCatcher_DumpMemory(&psp, CRASH_CATCHER_BYTE, sizeof(uint32_t)); + CrashCatcher_DumpMemory(&exceptionPSR, CRASH_CATCHER_BYTE, sizeof(uint32_t)); } -static int isARMv6MDevice(void) -{ - static const uint32_t armv6mArchitecture = 0xC << 16; - uint32_t cpuId = *g_pCrashCatcherCpuId; - uint32_t architecture = cpuId & (0xF << 16); - - return (architecture == armv6mArchitecture); +static void dumpFloatingPointRegisters(const Object *pObject) { + uint32_t allFloatingPointRegisters[32 + 1]; + if (areFloatingPointRegistersAutoStacked(pObject)) { + /* Copy the upper floats first as that will cause a lazy copy of the + * auto-stacked registers. */ + CrashCatcher_CopyUpperFloatingPointRegisters( + &allFloatingPointRegisters[16]); + memcpy(&allFloatingPointRegisters[0], &pObject->pSP->floats, + sizeof(pObject->pSP->floats)); + allFloatingPointRegisters[32] = pObject->pSP->fpscr; + } else { + CrashCatcher_CopyAllFloatingPointRegisters(allFloatingPointRegisters); + } + CrashCatcher_DumpMemory(allFloatingPointRegisters, CRASH_CATCHER_BYTE, + sizeof(allFloatingPointRegisters)); } -static void dumpFaultStatusRegisters(void) -{ - uint32_t faultStatusRegistersAddress = (uint32_t)(unsigned long)g_pCrashCatcherFaultStatusRegisters; - CrashCatcherMemoryRegion faultStatusRegion[] = { {faultStatusRegistersAddress, - faultStatusRegistersAddress + 5 * sizeof(uint32_t), - CRASH_CATCHER_WORD}, - {0xFFFFFFFF, 0xFFFFFFFF, CRASH_CATCHER_BYTE} }; - dumpMemoryRegions(faultStatusRegion); +static void dumpMemoryRegions(const CrashCatcherMemoryRegion *pRegion) { + while (pRegion && pRegion->startAddress != 0xFFFFFFFF) { + /* Just dump the two addresses in pRegion. The element size isn't required. + */ + CrashCatcher_DumpMemory(pRegion, CRASH_CATCHER_BYTE, 2 * sizeof(uint32_t)); + CrashCatcher_DumpMemory( + uint32AddressToPointer(pRegion->startAddress), pRegion->elementSize, + (pRegion->endAddress - pRegion->startAddress) / pRegion->elementSize); + pRegion++; + } } -static void advanceProgramCounterPastHardcodedBreakpoint(const Object* pObject) -{ - if (pObject->info.isBKPT) - pObject->pSP->pc += 2; +static void checkStackSentinelForStackOverflow(void) { + if (g_crashCatcherStack[0] != CRASH_CATCHER_STACK_SENTINEL) { + uint8_t value[4] = {0xAC, 0xCE, 0x55, 0xED}; + CrashCatcher_DumpMemory(value, CRASH_CATCHER_BYTE, sizeof(value)); + } +} + +static int isARMv6MDevice(void) { + static const uint32_t armv6mArchitecture = 0xC << 16; + uint32_t cpuId = *g_pCrashCatcherCpuId; + uint32_t architecture = cpuId & (0xF << 16); + + return (architecture == armv6mArchitecture); +} + +static void dumpFaultStatusRegisters(void) { + uint32_t faultStatusRegistersAddress = + (uint32_t)(unsigned long)g_pCrashCatcherFaultStatusRegisters; + CrashCatcherMemoryRegion faultStatusRegion[] = { + {faultStatusRegistersAddress, + faultStatusRegistersAddress + 5 * sizeof(uint32_t), CRASH_CATCHER_WORD}, + {0xFFFFFFFF, 0xFFFFFFFF, CRASH_CATCHER_BYTE}}; + dumpMemoryRegions(faultStatusRegion); +} + +static void +advanceProgramCounterPastHardcodedBreakpoint(const Object *pObject) { + if (pObject->info.isBKPT) + pObject->pSP->pc += 2; } diff --git a/utils/crash_catcher/HexDump.c b/utils/crash_catcher/HexDump.c index b132cb0..2ac7007 100644 --- a/utils/crash_catcher/HexDump.c +++ b/utils/crash_catcher/HexDump.c @@ -12,27 +12,27 @@ See the License for the specific language governing permissions and limitations under the License. */ -#include -#include #include "hal_timer.h" #include "hal_trace.h" #include "string.h" +#include +#include //#include "cmsis_os.h" #include "coredump_section.h" #include "xyzmodem.h" -//CRASH_CATCHER_TEST_WRITEABLE CrashCatcherReturnCodes g_crashCatcherDumpEndReturn = CRASH_CATCHER_TRY_AGAIN; +// CRASH_CATCHER_TEST_WRITEABLE CrashCatcherReturnCodes +// g_crashCatcherDumpEndReturn = CRASH_CATCHER_TRY_AGAIN; static void printString(const char *pString); -//static void waitForUserInput(void); -static void dumpBytes(const uint8_t* pMemory, size_t elementCount); +// static void waitForUserInput(void); +static void dumpBytes(const uint8_t *pMemory, size_t elementCount); static void dumpByteAsHex(uint8_t byte); static void dumpHexDigit(uint8_t nibble); -static void dumpHalfwords(const uint16_t* pMemory, size_t elementCount); -static void dumpWords(const uint32_t* pMemory, size_t elementCount); +static void dumpHalfwords(const uint16_t *pMemory, size_t elementCount); +static void dumpWords(const uint32_t *pMemory, size_t elementCount); -void CrashCatcher_putc(char c) -{ - hal_trace_output((const unsigned char *)&c,1); +void CrashCatcher_putc(char c) { + hal_trace_output((const unsigned char *)&c, 1); } extern uint32_t __data_start__, __data_end__; @@ -41,84 +41,77 @@ extern uint32_t __StackLimit, __StackTop; extern uint32_t __overlay_text_exec_start__; extern uint32_t __fast_sram_end__; -const CrashCatcherMemoryRegion* CrashCatcher_GetMemoryRegions(void) -{ - static CrashCatcherMemoryRegion regions[4]; - int j=0; +const CrashCatcherMemoryRegion *CrashCatcher_GetMemoryRegions(void) { + static CrashCatcherMemoryRegion regions[4]; + int j = 0; - regions[j].startAddress = (uint32_t)&__data_start__; - regions[j].endAddress = (uint32_t)&__data_end__; - regions[j].elementSize = CRASH_CATCHER_BYTE; - j++; + regions[j].startAddress = (uint32_t)&__data_start__; + regions[j].endAddress = (uint32_t)&__data_end__; + regions[j].elementSize = CRASH_CATCHER_BYTE; + j++; - regions[j].startAddress = (uint32_t)&__bss_start__; - regions[j].endAddress = (uint32_t)&__bss_end__; - regions[j].elementSize = CRASH_CATCHER_BYTE; - j++; + regions[j].startAddress = (uint32_t)&__bss_start__; + regions[j].endAddress = (uint32_t)&__bss_end__; + regions[j].elementSize = CRASH_CATCHER_BYTE; + j++; - regions[j].startAddress = (uint32_t)&__StackLimit; - regions[j].endAddress = (uint32_t)&__StackTop; - regions[j].elementSize = CRASH_CATCHER_BYTE; - j++; - /* - regions[j].startAddress = (uint32_t)&__overlay_text_exec_start__; - regions[j].endAddress = (uint32_t)&__fast_sram_end__; - regions[j].elementSize = CRASH_CATCHER_BYTE; - j++; + regions[j].startAddress = (uint32_t)&__StackLimit; + regions[j].endAddress = (uint32_t)&__StackTop; + regions[j].elementSize = CRASH_CATCHER_BYTE; + j++; + /* + regions[j].startAddress = (uint32_t)&__overlay_text_exec_start__; + regions[j].endAddress = (uint32_t)&__fast_sram_end__; + regions[j].elementSize = CRASH_CATCHER_BYTE; + j++; - regions[j].startAddress = 0x0c000000; - regions[j].endAddress = 0x0c0c8000; - regions[j].elementSize = CRASH_CATCHER_BYTE; - j++; - */ + regions[j].startAddress = 0x0c000000; + regions[j].endAddress = 0x0c0c8000; + regions[j].elementSize = CRASH_CATCHER_BYTE; + j++; + */ - regions[j].startAddress = 0xFFFFFFFF; - regions[j].endAddress = 0xFFFFFFFF; - regions[j].elementSize = CRASH_CATCHER_BYTE; - return regions; + regions[j].startAddress = 0xFFFFFFFF; + regions[j].endAddress = 0xFFFFFFFF; + regions[j].elementSize = CRASH_CATCHER_BYTE; + return regions; } -static enum { - DUMP_TERM, - DUMP_XMODEM, - DUMP_FLASH -} dump_direction = DUMP_TERM; +static enum { DUMP_TERM, DUMP_XMODEM, DUMP_FLASH } dump_direction = DUMP_TERM; -int CrashCatcher_DumpStart(const CrashCatcherInfo* pInfo) -{ - int ret; +int CrashCatcher_DumpStart(const CrashCatcherInfo *pInfo) { + int ret; - printString("\r\n\r\n"); - /* - if (pInfo->isBKPT) - printString("BREAKPOINT"); - else - */ - printString("CRASH"); - printString(" ENCOUNTERED\r\n" - "Enable XMODEM and then press any key to start dump.\r\n"); - //waitForUserInput(); - hal_trace_flush_buffer(); + printString("\r\n\r\n"); + /* + if (pInfo->isBKPT) + printString("BREAKPOINT"); + else + */ + printString("CRASH"); + printString(" ENCOUNTERED\r\n" + "Enable XMODEM and then press any key to start dump.\r\n"); + // waitForUserInput(); + hal_trace_flush_buffer(); #ifdef CORE_DUMP_TO_FLASH - core_dump_erase_section(); - dump_direction = DUMP_FLASH; - return 0; + core_dump_erase_section(); + dump_direction = DUMP_FLASH; + return 0; #endif - ret = xmodem_start_xfer(120); - if (!ret) { - dump_direction = DUMP_XMODEM; - return 0; - } - + ret = xmodem_start_xfer(120); + if (!ret) { + dump_direction = DUMP_XMODEM; return 0; + } + + return 0; } -static void printString(const char *pString) -{ - while (*pString) - CrashCatcher_putc(*pString++); +static void printString(const char *pString) { + while (*pString) + CrashCatcher_putc(*pString++); } #if 0 @@ -128,117 +121,106 @@ static void waitForUserInput(void) } #endif -void CrashCatcher_DumpMemory(const void* pvMemory, CrashCatcherElementSizes elementSize, size_t elementCount) -{ - switch (elementSize) - { - case CRASH_CATCHER_BYTE: - dumpBytes(pvMemory, elementCount); - break; - case CRASH_CATCHER_HALFWORD: - dumpHalfwords(pvMemory, elementCount); - break; - case CRASH_CATCHER_WORD: - dumpWords(pvMemory, elementCount); - break; - } - printString("\r\n"); +void CrashCatcher_DumpMemory(const void *pvMemory, + CrashCatcherElementSizes elementSize, + size_t elementCount) { + switch (elementSize) { + case CRASH_CATCHER_BYTE: + dumpBytes(pvMemory, elementCount); + break; + case CRASH_CATCHER_HALFWORD: + dumpHalfwords(pvMemory, elementCount); + break; + case CRASH_CATCHER_WORD: + dumpWords(pvMemory, elementCount); + break; + } + printString("\r\n"); #ifdef CORE_DUMP_TO_FLASH - if (elementSize * elementCount >= COREDUMP_SECTOR_SIZE) - { - core_dump_write_large(pvMemory, elementSize * elementCount); - } - else - { - core_dump_write(pvMemory, elementSize * elementCount); - } + if (elementSize * elementCount >= COREDUMP_SECTOR_SIZE) { + core_dump_write_large(pvMemory, elementSize * elementCount); + } else { + core_dump_write(pvMemory, elementSize * elementCount); + } #endif } -static void dumpBytes(const uint8_t* pMemory, size_t elementCount) -{ - size_t i; +static void dumpBytes(const uint8_t *pMemory, size_t elementCount) { + size_t i; - if (dump_direction == DUMP_TERM) { - for (i = 0 ; i < elementCount ; i++) { - /* Only dump 16 bytes to a single line before introducing a line break. */ - if (i != 0 && (i & 0xF) == 0) { - printString("\r\n"); - hal_trace_flush_buffer(); - } - dumpByteAsHex(*pMemory++); - } - } else if (dump_direction == DUMP_XMODEM) { - const uint8_t *buf = pMemory; - int len; - - len = xmodem_send_stream(buf, elementCount, 1); - if (len < 0) { - //printString("#####error"); - } + if (dump_direction == DUMP_TERM) { + for (i = 0; i < elementCount; i++) { + /* Only dump 16 bytes to a single line before introducing a line break. */ + if (i != 0 && (i & 0xF) == 0) { + printString("\r\n"); + hal_trace_flush_buffer(); + } + dumpByteAsHex(*pMemory++); } -} + } else if (dump_direction == DUMP_XMODEM) { + const uint8_t *buf = pMemory; + int len; -static void dumpByteAsHex(uint8_t byte) -{ - dumpHexDigit(byte >> 4); - dumpHexDigit(byte & 0xF); -} - -static void dumpHexDigit(uint8_t nibble) -{ - static const char hexToASCII[] = "0123456789ABCDEF"; - - assert( nibble < 16 ); - CrashCatcher_putc(hexToASCII[nibble]); -} - -static void dumpHalfwords(const uint16_t* pMemory, size_t elementCount) -{ - size_t i; - for (i = 0 ; i < elementCount ; i++) - { - uint16_t val = *pMemory++; - /* Only dump 8 halfwords to a single line before introducing a line break. */ - if (i != 0 && (i & 0x7) == 0) - printString("\r\n"); - dumpBytes((uint8_t*)&val, sizeof(val)); + len = xmodem_send_stream(buf, elementCount, 1); + if (len < 0) { + // printString("#####error"); } + } } -static void dumpWords(const uint32_t* pMemory, size_t elementCount) -{ - size_t i; - for (i = 0 ; i < elementCount ; i++) - { - uint32_t val = *pMemory++; - /* Only dump 4 words to a single line before introducing a line break. */ - if (i != 0 && (i & 0x3) == 0) { - printString("\r\n"); - } - dumpBytes((uint8_t*)&val, sizeof(val)); - } +static void dumpByteAsHex(uint8_t byte) { + dumpHexDigit(byte >> 4); + dumpHexDigit(byte & 0xF); } +static void dumpHexDigit(uint8_t nibble) { + static const char hexToASCII[] = "0123456789ABCDEF"; -CrashCatcherReturnCodes CrashCatcher_DumpEnd(void) -{ - char end_info[] = "\r\nEnd of dump\r\n"; + assert(nibble < 16); + CrashCatcher_putc(hexToASCII[nibble]); +} - if (dump_direction == DUMP_XMODEM) { - int len = (strlen(end_info) + 1) / 2 * 2; - xmodem_send_stream((const uint8_t *)end_info, len, 0); - xmodem_stop_xfer(); - } else { - printString(end_info); +static void dumpHalfwords(const uint16_t *pMemory, size_t elementCount) { + size_t i; + for (i = 0; i < elementCount; i++) { + uint16_t val = *pMemory++; + /* Only dump 8 halfwords to a single line before introducing a line break. + */ + if (i != 0 && (i & 0x7) == 0) + printString("\r\n"); + dumpBytes((uint8_t *)&val, sizeof(val)); + } +} + +static void dumpWords(const uint32_t *pMemory, size_t elementCount) { + size_t i; + for (i = 0; i < elementCount; i++) { + uint32_t val = *pMemory++; + /* Only dump 4 words to a single line before introducing a line break. */ + if (i != 0 && (i & 0x3) == 0) { + printString("\r\n"); } + dumpBytes((uint8_t *)&val, sizeof(val)); + } +} - return CRASH_CATCHER_EXIT; - #if 0 +CrashCatcherReturnCodes CrashCatcher_DumpEnd(void) { + char end_info[] = "\r\nEnd of dump\r\n"; + + if (dump_direction == DUMP_XMODEM) { + int len = (strlen(end_info) + 1) / 2 * 2; + xmodem_send_stream((const uint8_t *)end_info, len, 0); + xmodem_stop_xfer(); + } else { + printString(end_info); + } + + return CRASH_CATCHER_EXIT; +#if 0 if (g_crashCatcherDumpEndReturn == CRASH_CATCHER_TRY_AGAIN && g_info.isBKPT) return CRASH_CATCHER_EXIT; else return g_crashCatcherDumpEndReturn; - #endif +#endif } diff --git a/utils/crc16/crc16.c b/utils/crc16/crc16.c index 222bdaf..b2da99a 100644 --- a/utils/crc16/crc16.c +++ b/utils/crc16/crc16.c @@ -19,44 +19,40 @@ * This source code is licensed under the GNU General Public License, * Version 2. See the file COPYING for more details. */ - - #include "crc16.h" - - /** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */ + +#include "crc16.h" + +/** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */ unsigned short const crc16_table[256] = { - 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, - 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, - 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, - 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841, - 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40, - 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41, - 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641, - 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040, - 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240, - 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441, - 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41, - 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840, - 0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41, - 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40, - 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640, - 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041, - 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240, - 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441, - 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41, - 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840, - 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41, - 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40, - 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640, - 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041, - 0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241, - 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440, - 0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40, - 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841, - 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40, - 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41, - 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641, - 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040 -}; + 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, 0xC601, + 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, 0xCC01, 0x0CC0, + 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, 0x0A00, 0xCAC1, 0xCB81, + 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841, 0xD801, 0x18C0, 0x1980, 0xD941, + 0x1B00, 0xDBC1, 0xDA81, 0x1A40, 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, + 0x1DC0, 0x1C80, 0xDC41, 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, + 0x1680, 0xD641, 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, + 0x1040, 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240, + 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441, 0x3C00, + 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41, 0xFA01, 0x3AC0, + 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840, 0x2800, 0xE8C1, 0xE981, + 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41, 0xEE01, 0x2EC0, 0x2F80, 0xEF41, + 0x2D00, 0xEDC1, 0xEC81, 0x2C40, 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, + 0xE7C1, 0xE681, 0x2640, 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, + 0x2080, 0xE041, 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, + 0x6240, 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441, + 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41, 0xAA01, + 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840, 0x7800, 0xB8C1, + 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41, 0xBE01, 0x7EC0, 0x7F80, + 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40, 0xB401, 0x74C0, 0x7580, 0xB541, + 0x7700, 0xB7C1, 0xB681, 0x7640, 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, + 0x71C0, 0x7080, 0xB041, 0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, + 0x5280, 0x9241, 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, + 0x5440, 0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40, + 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841, 0x8801, + 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40, 0x4E00, 0x8EC1, + 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41, 0x4400, 0x84C1, 0x8581, + 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641, 0x8201, 0x42C0, 0x4380, 0x8341, + 0x4100, 0x81C1, 0x8081, 0x4040}; /** * crc16 - compute the CRC-16 for the data buffer @@ -66,9 +62,9 @@ unsigned short const crc16_table[256] = { * * Returns the updated CRC value. */ -unsigned short _crc16(unsigned short crc, unsigned char const *buffer, unsigned int len) -{ - while (len--) - crc = crc16_byte(crc, *buffer++); - return crc; +unsigned short _crc16(unsigned short crc, unsigned char const *buffer, + unsigned int len) { + while (len--) + crc = crc16_byte(crc, *buffer++); + return crc; } diff --git a/utils/crc32/crc32.c b/utils/crc32/crc32.c index 7eae627..12e79d5 100644 --- a/utils/crc32/crc32.c +++ b/utils/crc32/crc32.c @@ -23,112 +23,89 @@ static unsigned long crc_table[256]; static int crc_table_computed = 0; -static void make_crc_table(void) -{ - unsigned long c; - unsigned long n, k; +static void make_crc_table(void) { + unsigned long c; + unsigned long n, k; - for (n = 0; n < 256; n++) { - c = n; - for (k = 0; k < 8; k++) { - if (c & 1) - c = 0xedb88320L ^ (c >> 1); - else - c = c >> 1; - } - crc_table[n] = c; + for (n = 0; n < 256; n++) { + c = n; + for (k = 0; k < 8; k++) { + if (c & 1) + c = 0xedb88320L ^ (c >> 1); + else + c = c >> 1; } + crc_table[n] = c; + } } #else static const unsigned long crc_table[256] = { - 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, - 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, - 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, - 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, - 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, - 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, - 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, - 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, - 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, - 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, - 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, - 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, - 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, - 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, - 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, - 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, - 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, - 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, - 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, - 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, - 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, - 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, - 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, - 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, - 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, - 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, - 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, - 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, - 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, - 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, - 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, - 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, - 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, - 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, - 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, - 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, - 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, - 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, - 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, - 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, - 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, - 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, - 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, - 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, - 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, - 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, - 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, - 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, - 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, - 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, - 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, - 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, - 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, - 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, - 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, - 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, - 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, - 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, - 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, - 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, - 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, - 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, - 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, + 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, + 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, + 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, + 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, + 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, + 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, + 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, + 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, + 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, + 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, + 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, + 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, + 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, + 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, + 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, + 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, + 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, + 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, + 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, + 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, + 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, + 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, + 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, + 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, + 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, + 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, + 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, + 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, + 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, + 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, + 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, + 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D, }; #endif -unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned int len) -{ - unsigned long c; +unsigned long crc32(unsigned long crc, const unsigned char *buf, + unsigned int len) { + unsigned long c; #ifdef MAKE_CRC32_TABLE - if (crc_table_computed == 0) { - make_crc_table(); - crc_table_computed = 1; - } + if (crc_table_computed == 0) { + make_crc_table(); + crc_table_computed = 1; + } #endif - c = crc ^ 0xffffffffL; + c = crc ^ 0xffffffffL; - while (len) { - c = crc_table[(c ^ (*buf++)) & 0xff] ^ (c >> 8); - len--; - } + while (len) { + c = crc_table[(c ^ (*buf++)) & 0xff] ^ (c >> 8); + len--; + } - return c ^ 0xffffffffL; + return c ^ 0xffffffffL; } - diff --git a/utils/crc32/crc32_rom.c b/utils/crc32/crc32_rom.c index 10929da..8f222a0 100644 --- a/utils/crc32/crc32_rom.c +++ b/utils/crc32/crc32_rom.c @@ -17,8 +17,7 @@ #include "crc32.h" #include "export_fn_rom.h" -unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned int len) -{ - return __export_fn_rom.crc32(crc, buf, len); +unsigned long crc32(unsigned long crc, const unsigned char *buf, + unsigned int len) { + return __export_fn_rom.crc32(crc, buf, len); } - diff --git a/utils/heap/heap_api.c b/utils/heap/heap_api.c index e1201a1..c3b1bc5 100644 --- a/utils/heap/heap_api.c +++ b/utils/heap/heap_api.c @@ -1,7 +1,7 @@ -#include "multi_heap.h" #include "heap_api.h" -#include "string.h" #include "hal_trace.h" +#include "multi_heap.h" +#include "string.h" // #define HEAP_API_DEBUG @@ -36,201 +36,179 @@ void *realloc(void *ptr, size_t size) #endif // TODO: multi heap and block -#define MED_HEAP_BLOCK_MAX_NUM (3) +#define MED_HEAP_BLOCK_MAX_NUM (3) static int g_block_index = 0; static int g_switch_cp = 0; -// NOTE: Can use g_med_heap_begin_addr and g_med_heap_size to optimize free speed -// static void *g_med_heap_begin_addr[MED_HEAP_BLOCK_MAX_NUM]; -// static size_t g_med_heap_size[MED_HEAP_BLOCK_MAX_NUM]; +// NOTE: Can use g_med_heap_begin_addr and g_med_heap_size to optimize free +// speed static void *g_med_heap_begin_addr[MED_HEAP_BLOCK_MAX_NUM]; static +// size_t g_med_heap_size[MED_HEAP_BLOCK_MAX_NUM]; static heap_handle_t g_med_heap[MED_HEAP_BLOCK_MAX_NUM]; static heap_handle_t g_cp_heap; -void heap_memory_info(heap_handle_t heap, size_t *total, size_t *used, size_t *max_used) -{ - multi_heap_info_t info; - heap_get_info(heap, &info); +void heap_memory_info(heap_handle_t heap, size_t *total, size_t *used, + size_t *max_used) { + multi_heap_info_t info; + heap_get_info(heap, &info); - if (total != NULL) - *total = info.total_bytes; + if (total != NULL) + *total = info.total_bytes; - if (used != NULL) - *used = info.total_allocated_bytes; + if (used != NULL) + *used = info.total_allocated_bytes; - if (max_used != NULL) - *max_used = info.total_bytes - info.minimum_free_bytes; + if (max_used != NULL) + *max_used = info.total_bytes - info.minimum_free_bytes; } -static int med_help_get_index(void *ptr) -{ - int index = 0; - int diff_addr = 0; - multi_heap_info_t info; +static int med_help_get_index(void *ptr) { + int index = 0; + int diff_addr = 0; + multi_heap_info_t info; - for (index = 0; index < g_block_index; index++) - { - heap_get_info(g_med_heap[index], &info); - diff_addr = (char *)ptr - (char *)g_med_heap[index]; + for (index = 0; index < g_block_index; index++) { + heap_get_info(g_med_heap[index], &info); + diff_addr = (char *)ptr - (char *)g_med_heap[index]; #ifdef HEAP_API_DEBUG - TRACE(3,"[%s] index = %d, diff_addr = %d", __func__, index, diff_addr); + TRACE(3, "[%s] index = %d, diff_addr = %d", __func__, index, diff_addr); #endif - if ((diff_addr > 0) && (diff_addr < info.total_bytes)) - { - break; - } + if ((diff_addr > 0) && (diff_addr < info.total_bytes)) { + break; } + } - ASSERT(index < g_block_index, "[%s] Can not find ptr = %p", __func__, ptr); + ASSERT(index < g_block_index, "[%s] Can not find ptr = %p", __func__, ptr); - return index; + return index; } -static void med_heap_reset(void) -{ - g_block_index = 0; - g_switch_cp = 0; +static void med_heap_reset(void) { + g_block_index = 0; + g_switch_cp = 0; - for (int i = 0; i < MED_HEAP_BLOCK_MAX_NUM; i++) - { - // g_med_heap_begin_addr[i] = NULL; - // g_med_heap_size[i] = NULL; - g_med_heap[i] = NULL; - } - g_cp_heap = NULL; + for (int i = 0; i < MED_HEAP_BLOCK_MAX_NUM; i++) { + // g_med_heap_begin_addr[i] = NULL; + // g_med_heap_size[i] = NULL; + g_med_heap[i] = NULL; + } + g_cp_heap = NULL; } -void med_heap_set_cp(int switch_cp) -{ - TRACE(2,"[%s] switch_cp: %d", __func__, switch_cp); - g_switch_cp = switch_cp; +void med_heap_set_cp(int switch_cp) { + TRACE(2, "[%s] switch_cp: %d", __func__, switch_cp); + g_switch_cp = switch_cp; } -void med_heap_add_block(void *begin_addr, size_t size) -{ - TRACE(4,"[%s] g_block_index = %d, begin_addr = %p, size = %d", __func__, g_block_index, begin_addr, size); - ASSERT(g_block_index < MED_HEAP_BLOCK_MAX_NUM, "[%s] g_block_index(%d) >= MED_HEAP_BLOCK_MAX_NUM", __func__, g_block_index); +void med_heap_add_block(void *begin_addr, size_t size) { + TRACE(4, "[%s] g_block_index = %d, begin_addr = %p, size = %d", __func__, + g_block_index, begin_addr, size); + ASSERT(g_block_index < MED_HEAP_BLOCK_MAX_NUM, + "[%s] g_block_index(%d) >= MED_HEAP_BLOCK_MAX_NUM", __func__, + g_block_index); - memset(begin_addr, 0, size); - if (g_switch_cp) - { - g_cp_heap = heap_register(begin_addr, size); - } - else - { - g_med_heap[g_block_index] = heap_register(begin_addr, size); - // g_med_heap_begin_addr[g_block_index] = begin_addr; - // g_med_heap_size[g_block_index] = size; + memset(begin_addr, 0, size); + if (g_switch_cp) { + g_cp_heap = heap_register(begin_addr, size); + } else { + g_med_heap[g_block_index] = heap_register(begin_addr, size); + // g_med_heap_begin_addr[g_block_index] = begin_addr; + // g_med_heap_size[g_block_index] = size; - g_block_index++; - } + g_block_index++; + } } -void med_heap_init(void *begin_addr, size_t size) -{ - med_heap_reset(); - med_heap_add_block(begin_addr, size); +void med_heap_init(void *begin_addr, size_t size) { + med_heap_reset(); + med_heap_add_block(begin_addr, size); } -void *med_malloc(size_t size) -{ - int index = 0; - void *ptr = NULL; +void *med_malloc(size_t size) { + int index = 0; + void *ptr = NULL; - if (size == 0) - return NULL; + if (size == 0) + return NULL; - if (g_switch_cp) - { - ptr = heap_malloc(g_cp_heap, size); - goto exit; - } - - for (index = 0; index < g_block_index; index++) - { - if (multi_heap_free_size(g_med_heap[index]) >= size) - { - break; - } + if (g_switch_cp) { + ptr = heap_malloc(g_cp_heap, size); + goto exit; + } + + for (index = 0; index < g_block_index; index++) { + if (multi_heap_free_size(g_med_heap[index]) >= size) { + break; } + } #ifdef HEAP_API_DEBUG - TRACE(3,"[%s] index = %d, size = %d", __func__, index, size); + TRACE(3, "[%s] index = %d, size = %d", __func__, index, size); #endif - ASSERT(index < g_block_index, "[%s] index = %d, g_block_index = %d. Can not malloc any RAM", __func__, index, g_block_index); + ASSERT(index < g_block_index, + "[%s] index = %d, g_block_index = %d. Can not malloc any RAM", + __func__, index, g_block_index); - ptr = heap_malloc(g_med_heap[index], size); + ptr = heap_malloc(g_med_heap[index], size); exit: - ASSERT(ptr != NULL, "[%s]: no memory, needed size %d", __FUNCTION__, size); + ASSERT(ptr != NULL, "[%s]: no memory, needed size %d", __FUNCTION__, size); - return ptr; + return ptr; } -void med_free(void *p) -{ - if (p) - { - if (g_switch_cp) - { - heap_free(g_cp_heap, p); - } - else - { - int index = med_help_get_index(p); - heap_free(g_med_heap[index], p); - } - - p = NULL; - } -} - -void *med_calloc(size_t nmemb, size_t size) -{ - if (size == 0) - return NULL; - - void *ptr = med_malloc(nmemb * size); - - if (ptr) - { - memset(ptr, 0 , nmemb * size); +void med_free(void *p) { + if (p) { + if (g_switch_cp) { + heap_free(g_cp_heap, p); + } else { + int index = med_help_get_index(p); + heap_free(g_med_heap[index], p); } - return ptr; + p = NULL; + } } -void *med_realloc(void *ptr, size_t size) -{ - // TODO: Do not support multi blocks - // TODO: Do not support cp - void *newptr = heap_realloc(g_med_heap[0],ptr,size); +void *med_calloc(size_t nmemb, size_t size) { + if (size == 0) + return NULL; - ASSERT(newptr != NULL, "[%s]: no memory, needed size %d", __FUNCTION__, size); + void *ptr = med_malloc(nmemb * size); - return newptr; + if (ptr) { + memset(ptr, 0, nmemb * size); + } + + return ptr; } -void med_memory_info(size_t *total, - size_t *used, - size_t *max_used) -{ - size_t _total = 0; - size_t _used = 0; - size_t _max_used = 0; +void *med_realloc(void *ptr, size_t size) { + // TODO: Do not support multi blocks + // TODO: Do not support cp + void *newptr = heap_realloc(g_med_heap[0], ptr, size); - for (int i = 0; i < g_block_index; i++) - { - heap_memory_info(g_med_heap[i], &_total, &_used, &_max_used); - *total += _total; - *used += _used; - *max_used += _max_used; + ASSERT(newptr != NULL, "[%s]: no memory, needed size %d", __FUNCTION__, size); + + return newptr; +} + +void med_memory_info(size_t *total, size_t *used, size_t *max_used) { + size_t _total = 0; + size_t _used = 0; + size_t _max_used = 0; + + for (int i = 0; i < g_block_index; i++) { + heap_memory_info(g_med_heap[i], &_total, &_used, &_max_used); + *total += _total; + *used += _used; + *max_used += _max_used; #ifdef HEAP_API_DEBUG - TRACE(4,"[%s] %d: g_med_heap = %p, size = %d", __func__, i, g_med_heap[i], _total); + TRACE(4, "[%s] %d: g_med_heap = %p, size = %d", __func__, i, g_med_heap[i], + _total); #endif - } + } } - diff --git a/utils/heap/multi_heap.c b/utils/heap/multi_heap.c index 3b00327..333722e 100644 --- a/utils/heap/multi_heap.c +++ b/utils/heap/multi_heap.c @@ -11,16 +11,16 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#include -#include -#include -#include -#include -#include -#include -#include -#include "multi_heap_internal.h" #include "hal_trace.h" +#include "multi_heap_internal.h" +#include +#include +#include +#include +#include +#include +#include +#include /* Note: Keep platform-specific parts in this header, this source file should depend on libc only */ @@ -55,700 +55,744 @@ size_t multi_heap_minimum_free_size(multi_heap_handle_t heap) void *multi_heap_get_block_address(multi_heap_block_handle_t block) __attribute__((alias("multi_heap_get_block_address_impl"))); -void *multi_heap_get_block_owner(multi_heap_block_handle_t block) -{ - return NULL; +void *multi_heap_get_block_owner(multi_heap_block_handle_t block) { + return NULL; } #endif -#define HEAP_ALIGN(X) ((X) & ~(sizeof(void *)-1)) -#define HEAP_ALIGN_UP(X) HEAP_ALIGN((X)+sizeof(void *)-1) +#define HEAP_ALIGN(X) ((X) & ~(sizeof(void *) - 1)) +#define HEAP_ALIGN_UP(X) HEAP_ALIGN((X) + sizeof(void *) - 1) struct heap_block; /* Block in the heap - Heap implementation uses two single linked lists, a block list (all blocks) and a free list (free blocks). + Heap implementation uses two single linked lists, a block list (all blocks) + and a free list (free blocks). - 'header' holds a pointer to the next block (used or free) ORed with a free flag (the LSB of the pointer.) is_free() and get_next_block() utility functions allow typed access to these values. + 'header' holds a pointer to the next block (used or free) ORed with a free + flag (the LSB of the pointer.) is_free() and get_next_block() utility + functions allow typed access to these values. - 'next_free' is valid if the block is free and is a pointer to the next block in the free list. + 'next_free' is valid if the block is free and is a pointer to the next block + in the free list. */ typedef struct heap_block { - intptr_t header; /* Encodes next block in heap (used or unused) and also free/used flag */ - union { - uint8_t data[1]; /* First byte of data, valid if block is used. Actual size of data is 'block_data_size(block)' */ - struct heap_block *next_free; /* Pointer to next free block, valid if block is free */ - }; + intptr_t header; /* Encodes next block in heap (used or unused) and also + free/used flag */ + union { + uint8_t data[1]; /* First byte of data, valid if block is used. Actual size + of data is 'block_data_size(block)' */ + struct heap_block + *next_free; /* Pointer to next free block, valid if block is free */ + }; } heap_block_t; /* These masks apply to the 'header' field of heap_block_t */ -#define BLOCK_FREE_FLAG 0x1 /* If set, this block is free & next_free pointer is valid */ -#define NEXT_BLOCK_MASK (~3) /* AND header with this mask to get pointer to next block (free or used) */ +#define BLOCK_FREE_FLAG \ + 0x1 /* If set, this block is free & next_free pointer is valid */ +#define NEXT_BLOCK_MASK \ + (~3) /* AND header with this mask to get pointer to next block (free or \ + used) */ /* Metadata header for the heap, stored at the beginning of heap space. - 'first_block' is a "fake" first block, minimum length, used to provide a pointer to the first used & free block in - the heap. This block is never allocated or merged into an adjacent block. + 'first_block' is a "fake" first block, minimum length, used to provide a + pointer to the first used & free block in the heap. This block is never + allocated or merged into an adjacent block. - 'last_block' is a pointer to a final free block of length 0, which is added at the end of the heap when it is - registered. This block is also never allocated or merged into an adjacent block. + 'last_block' is a pointer to a final free block of length 0, which is added + at the end of the heap when it is registered. This block is also never + allocated or merged into an adjacent block. */ typedef struct multi_heap_info { - void *lock; - size_t total_bytes; - size_t free_bytes; - size_t minimum_free_bytes; - heap_block_t *last_block; - heap_block_t first_block; /* initial 'free block', never allocated */ + void *lock; + size_t total_bytes; + size_t free_bytes; + size_t minimum_free_bytes; + heap_block_t *last_block; + heap_block_t first_block; /* initial 'free block', never allocated */ #if defined(MULTI_HEAP_DEFAULT_INT_LOCK) - size_t int_lock; + size_t int_lock; #endif } heap_t; -/* Given a pointer to the 'data' field of a block (ie the previous malloc/realloc result), return a pointer to the - containing block. +/* Given a pointer to the 'data' field of a block (ie the previous + malloc/realloc result), return a pointer to the containing block. */ -static inline heap_block_t *get_block(const void *data_ptr) -{ - return (heap_block_t *)((char *)data_ptr - offsetof(heap_block_t, data)); +static inline heap_block_t *get_block(const void *data_ptr) { + return (heap_block_t *)((char *)data_ptr - offsetof(heap_block_t, data)); } /* Return the next sequential block in the heap. */ -static inline heap_block_t *get_next_block(const heap_block_t *block) -{ - intptr_t next = block->header & NEXT_BLOCK_MASK; - if (next == 0) { - return NULL; /* last_block */ - } - assert(next > (intptr_t)block); - return (heap_block_t *)next; +static inline heap_block_t *get_next_block(const heap_block_t *block) { + intptr_t next = block->header & NEXT_BLOCK_MASK; + if (next == 0) { + return NULL; /* last_block */ + } + assert(next > (intptr_t)block); + return (heap_block_t *)next; } /* Return true if this block is free. */ -static inline bool is_free(const heap_block_t *block) -{ - return block->header & BLOCK_FREE_FLAG; +static inline bool is_free(const heap_block_t *block) { + return block->header & BLOCK_FREE_FLAG; } /* Return true if this block is the first in the heap */ -static inline bool is_first_block(const heap_t *heap, const heap_block_t *block) -{ - return (block == &heap->first_block); +static inline bool is_first_block(const heap_t *heap, + const heap_block_t *block) { + return (block == &heap->first_block); } /* Return true if this block is the last_block in the heap (the only block with no next pointer) */ -static inline bool is_last_block(const heap_block_t *block) -{ - return (block->header & NEXT_BLOCK_MASK) == 0; +static inline bool is_last_block(const heap_block_t *block) { + return (block->header & NEXT_BLOCK_MASK) == 0; } /* Data size of the block (excludes this block's header) */ -static inline size_t block_data_size(const heap_block_t *block) -{ - intptr_t next = (intptr_t)block->header & NEXT_BLOCK_MASK; - intptr_t this = (intptr_t)block; - if (next == 0) { - return 0; /* this is the last block in the heap */ - } - return next - this - sizeof(block->header); +static inline size_t block_data_size(const heap_block_t *block) { + intptr_t next = (intptr_t)block->header & NEXT_BLOCK_MASK; + intptr_t this = (intptr_t)block; + if (next == 0) { + return 0; /* this is the last block in the heap */ + } + return next - this - sizeof(block->header); } /* Check a block is valid for this heap. Used to verify parameters. */ -static void assert_valid_block(const heap_t *heap, const heap_block_t *block) -{ - MULTI_HEAP_ASSERT(block >= &heap->first_block && block <= heap->last_block, - block); // block not in heap - if (heap < (const heap_t *)heap->last_block) { - const heap_block_t *next = get_next_block(block); - MULTI_HEAP_ASSERT(next >= &heap->first_block && next <= heap->last_block, block); // Next block not in heap - if (is_free(block)) { - // Check block->next_free is valid - MULTI_HEAP_ASSERT(block->next_free >= &heap->first_block && block->next_free <= heap->last_block, &block->next_free); - } +static void assert_valid_block(const heap_t *heap, const heap_block_t *block) { + MULTI_HEAP_ASSERT(block >= &heap->first_block && block <= heap->last_block, + block); // block not in heap + if (heap < (const heap_t *)heap->last_block) { + const heap_block_t *next = get_next_block(block); + MULTI_HEAP_ASSERT(next >= &heap->first_block && next <= heap->last_block, + block); // Next block not in heap + if (is_free(block)) { + // Check block->next_free is valid + MULTI_HEAP_ASSERT(block->next_free >= &heap->first_block && + block->next_free <= heap->last_block, + &block->next_free); } + } } -/* Get the first free block before 'block' in the heap. 'block' can be a free block or in use. +/* Get the first free block before 'block' in the heap. 'block' can be a free + block or in use. - Result is always the closest free block to 'block' in the heap, that is located before 'block'. There may be multiple - allocated blocks between the result and 'block'. + Result is always the closest free block to 'block' in the heap, that is + located before 'block'. There may be multiple allocated blocks between the + result and 'block'. - If 'block' is free, the result's 'next_free' pointer will already point to 'block'. + If 'block' is free, the result's 'next_free' pointer will already point to + 'block'. Result will never be NULL, but it may be the header block heap->first_block. */ -static heap_block_t *get_prev_free_block(heap_t *heap, const heap_block_t *block) -{ - assert(!is_first_block(heap, block)); /* can't look for a block before first_block */ +static heap_block_t *get_prev_free_block(heap_t *heap, + const heap_block_t *block) { + assert(!is_first_block( + heap, block)); /* can't look for a block before first_block */ - for (heap_block_t *b = &heap->first_block; b != NULL && b < block; b = b->next_free) { - MULTI_HEAP_ASSERT(is_free(b), b); // Block should be free - if (b->next_free == NULL || b->next_free >= block) { - if (is_free(block)) { - /* if block is on freelist, 'b' should be the item before it. */ - MULTI_HEAP_ASSERT(b->next_free == block, &b->next_free); - } - return b; /* b is the last free block before 'block' */ - } + for (heap_block_t *b = &heap->first_block; b != NULL && b < block; + b = b->next_free) { + MULTI_HEAP_ASSERT(is_free(b), b); // Block should be free + if (b->next_free == NULL || b->next_free >= block) { + if (is_free(block)) { + /* if block is on freelist, 'b' should be the item before it. */ + MULTI_HEAP_ASSERT(b->next_free == block, &b->next_free); + } + return b; /* b is the last free block before 'block' */ } - abort(); /* There should always be a previous free block, even if it's heap->first_block */ + } + abort(); /* There should always be a previous free block, even if it's + heap->first_block */ } /* Merge some block 'a' into the following block 'b'. If both blocks are free, resulting block is marked free. - If only one block is free, resulting block is marked in use. No data is moved. + If only one block is free, resulting block is marked in use. No data is + moved. - This operation may fail if block 'a' is the first block or 'b' is the last block, - the caller should check block_data_size() to know if anything happened here or not. + This operation may fail if block 'a' is the first block or 'b' is the last + block, the caller should check block_data_size() to know if anything happened + here or not. */ -static heap_block_t *merge_adjacent(heap_t *heap, heap_block_t *a, heap_block_t *b) -{ - assert(a < b); +static heap_block_t *merge_adjacent(heap_t *heap, heap_block_t *a, + heap_block_t *b) { + assert(a < b); - /* Can't merge header blocks, just return the non-header block as-is */ - if (is_last_block(b)) { - return a; - } - if (is_first_block(heap, a)) { - return b; + /* Can't merge header blocks, just return the non-header block as-is */ + if (is_last_block(b)) { + return a; + } + if (is_first_block(heap, a)) { + return b; + } + + MULTI_HEAP_ASSERT(get_next_block(a) == b, a); // Blocks should be in order + + bool free = is_free(a) && + is_free(b); /* merging two free blocks creates a free block */ + if (!free && (is_free(a) || is_free(b))) { + /* only one of these blocks is free, so resulting block will be a used + block. means we need to take the free block out of the free list + */ + heap_block_t *free_block = is_free(a) ? a : b; + heap_block_t *prev_free = get_prev_free_block(heap, free_block); + MULTI_HEAP_ASSERT( + free_block->next_free > prev_free, + &free_block->next_free); // Next free block should be after prev one + prev_free->next_free = free_block->next_free; + + heap->free_bytes -= block_data_size(free_block); + } + + a->header = b->header & NEXT_BLOCK_MASK; + MULTI_HEAP_ASSERT(a->header != 0, a); + if (free) { + a->header |= BLOCK_FREE_FLAG; + if (b->next_free != NULL) { + MULTI_HEAP_ASSERT(b->next_free > a, &b->next_free); + MULTI_HEAP_ASSERT(b->next_free > b, &b->next_free); } + a->next_free = b->next_free; - MULTI_HEAP_ASSERT(get_next_block(a) == b, a); // Blocks should be in order - - bool free = is_free(a) && is_free(b); /* merging two free blocks creates a free block */ - if (!free && (is_free(a) || is_free(b))) { - /* only one of these blocks is free, so resulting block will be a used block. - means we need to take the free block out of the free list - */ - heap_block_t *free_block = is_free(a) ? a : b; - heap_block_t *prev_free = get_prev_free_block(heap, free_block); - MULTI_HEAP_ASSERT(free_block->next_free > prev_free, &free_block->next_free); // Next free block should be after prev one - prev_free->next_free = free_block->next_free; - - heap->free_bytes -= block_data_size(free_block); - } - - a->header = b->header & NEXT_BLOCK_MASK; - MULTI_HEAP_ASSERT(a->header != 0, a); - if (free) { - a->header |= BLOCK_FREE_FLAG; - if (b->next_free != NULL) { - MULTI_HEAP_ASSERT(b->next_free > a, &b->next_free); - MULTI_HEAP_ASSERT(b->next_free > b, &b->next_free); - } - a->next_free = b->next_free; - - /* b's header can be put into the pool of free bytes */ - heap->free_bytes += sizeof(a->header); - } + /* b's header can be put into the pool of free bytes */ + heap->free_bytes += sizeof(a->header); + } #ifdef MULTI_HEAP_POISONING_SLOW - /* b's former block header needs to be replaced with a fill pattern */ - multi_heap_internal_poison_fill_region(b, sizeof(heap_block_t), free); + /* b's former block header needs to be replaced with a fill pattern */ + multi_heap_internal_poison_fill_region(b, sizeof(heap_block_t), free); #endif - return a; + return a; } /* Split a block so it can hold at least 'size' bytes of data, making any spare space into a new free block. - 'block' should be marked in-use when this function is called (implementation detail, this function - doesn't set the next_free pointer). + 'block' should be marked in-use when this function is called (implementation + detail, this function doesn't set the next_free pointer). - 'prev_free_block' is the free block before 'block', if already known. Can be NULL if not yet known. - (This is a performance optimisation to avoid walking the freelist twice when possible.) + 'prev_free_block' is the free block before 'block', if already known. Can be + NULL if not yet known. (This is a performance optimisation to avoid walking + the freelist twice when possible.) */ -static void split_if_necessary(heap_t *heap, heap_block_t *block, size_t size, heap_block_t *prev_free_block) -{ - const size_t block_size = block_data_size(block); - MULTI_HEAP_ASSERT(!is_free(block), block); // split block shouldn't be free - MULTI_HEAP_ASSERT(size <= block_size, block); // size should be valid - size = HEAP_ALIGN_UP(size); +static void split_if_necessary(heap_t *heap, heap_block_t *block, size_t size, + heap_block_t *prev_free_block) { + const size_t block_size = block_data_size(block); + MULTI_HEAP_ASSERT(!is_free(block), block); // split block shouldn't be free + MULTI_HEAP_ASSERT(size <= block_size, block); // size should be valid + size = HEAP_ALIGN_UP(size); - /* can't split the head or tail block */ - assert(!is_first_block(heap, block)); - assert(!is_last_block(block)); + /* can't split the head or tail block */ + assert(!is_first_block(heap, block)); + assert(!is_last_block(block)); - heap_block_t *new_block = (heap_block_t *)(block->data + size); - heap_block_t *next_block = get_next_block(block); + heap_block_t *new_block = (heap_block_t *)(block->data + size); + heap_block_t *next_block = get_next_block(block); - if (is_free(next_block) && !is_last_block(next_block)) { - /* The next block is free, just extend it upwards. */ - new_block->header = next_block->header; - new_block->next_free = next_block->next_free; - if (prev_free_block == NULL) { - prev_free_block = get_prev_free_block(heap, block); - } - /* prev_free_block should point to the next block (which we found to be free). */ - MULTI_HEAP_ASSERT(prev_free_block->next_free == next_block, - &prev_free_block->next_free); // free blocks should be in order - /* Note: We have not introduced a new block header, hence the simple math. */ - heap->free_bytes += block_size - size; + if (is_free(next_block) && !is_last_block(next_block)) { + /* The next block is free, just extend it upwards. */ + new_block->header = next_block->header; + new_block->next_free = next_block->next_free; + if (prev_free_block == NULL) { + prev_free_block = get_prev_free_block(heap, block); + } + /* prev_free_block should point to the next block (which we found to be + * free). */ + MULTI_HEAP_ASSERT( + prev_free_block->next_free == next_block, + &prev_free_block->next_free); // free blocks should be in order + /* Note: We have not introduced a new block header, hence the simple math. + */ + heap->free_bytes += block_size - size; #ifdef MULTI_HEAP_POISONING_SLOW - /* next_block header needs to be replaced with a fill pattern */ - multi_heap_internal_poison_fill_region(next_block, sizeof(heap_block_t), true /* free */); + /* next_block header needs to be replaced with a fill pattern */ + multi_heap_internal_poison_fill_region(next_block, sizeof(heap_block_t), + true /* free */); #endif - } else { - /* Insert a free block between the current and the next one. */ - if (block_data_size(block) < size + sizeof(heap_block_t)) { - /* Can't split 'block' if we're not going to get a usable free block afterwards */ - return; - } - if (prev_free_block == NULL) { - prev_free_block = get_prev_free_block(heap, block); - } - new_block->header = block->header | BLOCK_FREE_FLAG; - new_block->next_free = prev_free_block->next_free; - /* prev_free_block should point to a free block after new_block */ - MULTI_HEAP_ASSERT(prev_free_block->next_free > new_block, - &prev_free_block->next_free); // free blocks should be in order - heap->free_bytes += block_data_size(new_block); + } else { + /* Insert a free block between the current and the next one. */ + if (block_data_size(block) < size + sizeof(heap_block_t)) { + /* Can't split 'block' if we're not going to get a usable free block + * afterwards */ + return; } - block->header = (intptr_t)new_block; - prev_free_block->next_free = new_block; -} - -void *multi_heap_get_block_address_impl(multi_heap_block_handle_t block) -{ - return ((char *)block + offsetof(heap_block_t, data)); -} - -size_t multi_heap_get_allocated_size_impl(multi_heap_handle_t heap, void *p) -{ - heap_block_t *pb = get_block(p); - - assert_valid_block(heap, pb); - MULTI_HEAP_ASSERT(!is_free(pb), pb); // block shouldn't be free - return block_data_size(pb); -} - -multi_heap_handle_t multi_heap_register_impl(void *start, size_t size) -{ - TRACE(2,"multi_heap_register_impl start=%p,size=%d",start,size); - heap_t *heap = (heap_t *)HEAP_ALIGN_UP((intptr_t)start); - uintptr_t end = HEAP_ALIGN((uintptr_t)start + size); - if (end - (uintptr_t)start < sizeof(heap_t) + 2*sizeof(heap_block_t)) { - return NULL; /* 'size' is too small to fit a heap here */ + if (prev_free_block == NULL) { + prev_free_block = get_prev_free_block(heap, block); } + new_block->header = block->header | BLOCK_FREE_FLAG; + new_block->next_free = prev_free_block->next_free; + /* prev_free_block should point to a free block after new_block */ + MULTI_HEAP_ASSERT( + prev_free_block->next_free > new_block, + &prev_free_block->next_free); // free blocks should be in order + heap->free_bytes += block_data_size(new_block); + } + block->header = (intptr_t)new_block; + prev_free_block->next_free = new_block; +} + +void *multi_heap_get_block_address_impl(multi_heap_block_handle_t block) { + return ((char *)block + offsetof(heap_block_t, data)); +} + +size_t multi_heap_get_allocated_size_impl(multi_heap_handle_t heap, void *p) { + heap_block_t *pb = get_block(p); + + assert_valid_block(heap, pb); + MULTI_HEAP_ASSERT(!is_free(pb), pb); // block shouldn't be free + return block_data_size(pb); +} + +multi_heap_handle_t multi_heap_register_impl(void *start, size_t size) { + TRACE(2, "multi_heap_register_impl start=%p,size=%d", start, size); + heap_t *heap = (heap_t *)HEAP_ALIGN_UP((intptr_t)start); + uintptr_t end = HEAP_ALIGN((uintptr_t)start + size); + if (end - (uintptr_t)start < sizeof(heap_t) + 2 * sizeof(heap_block_t)) { + return NULL; /* 'size' is too small to fit a heap here */ + } #if defined(MULTI_HEAP_DEFAULT_INT_LOCK) - heap->lock = (void *)(&heap->int_lock); + heap->lock = (void *)(&heap->int_lock); #else - heap->lock = NULL; + heap->lock = NULL; #endif - heap->last_block = (heap_block_t *)(end - sizeof(heap_block_t)); + heap->last_block = (heap_block_t *)(end - sizeof(heap_block_t)); - /* first 'real' (allocatable) free block goes after the heap structure */ - heap_block_t *first_free_block = (heap_block_t *)((intptr_t)start + sizeof(heap_t)); - first_free_block->header = (intptr_t)heap->last_block | BLOCK_FREE_FLAG; - first_free_block->next_free = heap->last_block; + /* first 'real' (allocatable) free block goes after the heap structure */ + heap_block_t *first_free_block = + (heap_block_t *)((intptr_t)start + sizeof(heap_t)); + first_free_block->header = (intptr_t)heap->last_block | BLOCK_FREE_FLAG; + first_free_block->next_free = heap->last_block; - /* last block is 'free' but has a NULL next pointer */ - heap->last_block->header = BLOCK_FREE_FLAG; - heap->last_block->next_free = NULL; + /* last block is 'free' but has a NULL next pointer */ + heap->last_block->header = BLOCK_FREE_FLAG; + heap->last_block->next_free = NULL; - /* first block also 'free' but has legitimate length, - malloc will never allocate into this block. */ - heap->first_block.header = (intptr_t)first_free_block | BLOCK_FREE_FLAG; - heap->first_block.next_free = first_free_block; + /* first block also 'free' but has legitimate length, + malloc will never allocate into this block. */ + heap->first_block.header = (intptr_t)first_free_block | BLOCK_FREE_FLAG; + heap->first_block.next_free = first_free_block; - /* free bytes is: - - total bytes in heap - - minus heap_t header at top (includes heap->first_block) - - minus header of first_free_block - - minus whole block at heap->last_block - */ - heap->free_bytes = HEAP_ALIGN(size) - sizeof(heap_t) - sizeof(first_free_block->header) - sizeof(heap_block_t); - heap->minimum_free_bytes = heap->free_bytes; - heap->total_bytes = HEAP_ALIGN(size); - return heap; + /* free bytes is: + - total bytes in heap + - minus heap_t header at top (includes heap->first_block) + - minus header of first_free_block + - minus whole block at heap->last_block + */ + heap->free_bytes = HEAP_ALIGN(size) - sizeof(heap_t) - + sizeof(first_free_block->header) - sizeof(heap_block_t); + heap->minimum_free_bytes = heap->free_bytes; + heap->total_bytes = HEAP_ALIGN(size); + return heap; } -void multi_heap_set_lock(multi_heap_handle_t heap, void *lock) -{ - heap->lock = lock; +void multi_heap_set_lock(multi_heap_handle_t heap, void *lock) { + heap->lock = lock; } -void inline multi_heap_internal_lock(multi_heap_handle_t heap) -{ - MULTI_HEAP_LOCK(heap->lock); +void inline multi_heap_internal_lock(multi_heap_handle_t heap) { + MULTI_HEAP_LOCK(heap->lock); } -void inline multi_heap_internal_unlock(multi_heap_handle_t heap) -{ +void inline multi_heap_internal_unlock(multi_heap_handle_t heap) { + MULTI_HEAP_UNLOCK(heap->lock); +} + +multi_heap_block_handle_t multi_heap_get_first_block(multi_heap_handle_t heap) { + return &heap->first_block; +} + +multi_heap_block_handle_t +multi_heap_get_next_block(multi_heap_handle_t heap, + multi_heap_block_handle_t block) { + heap_block_t *next = get_next_block(block); + /* check for valid free last block to avoid assert in assert_valid_block */ + if (next == heap->last_block && is_last_block(next) && is_free(next)) { + return NULL; + } + assert_valid_block(heap, next); + return next; +} + +bool multi_heap_is_free(multi_heap_block_handle_t block) { + return is_free(block); +} + +void *multi_heap_malloc_impl(multi_heap_handle_t heap, size_t size) { + heap_block_t *best_block = NULL; + heap_block_t *prev_free = NULL; + heap_block_t *prev = NULL; + size_t best_size = SIZE_MAX; + size = HEAP_ALIGN_UP(size); + + if (size == 0 || heap == NULL) { + return NULL; + } + + multi_heap_internal_lock(heap); + + /* Note: this check must be done while holding the lock as both + malloc & realloc may temporarily shrink the free_bytes value + before they split a large block. This can result in false negatives, + especially if the heap is unfragmented. + */ + if (heap->free_bytes < size) { MULTI_HEAP_UNLOCK(heap->lock); -} + ASSERT(0, "[%s] need size = %d, heap->free_bytes = %d", __func__, size, + heap->free_bytes); + return NULL; + } -multi_heap_block_handle_t multi_heap_get_first_block(multi_heap_handle_t heap) -{ - return &heap->first_block; -} - -multi_heap_block_handle_t multi_heap_get_next_block(multi_heap_handle_t heap, multi_heap_block_handle_t block) -{ - heap_block_t *next = get_next_block(block); - /* check for valid free last block to avoid assert in assert_valid_block */ - if (next == heap->last_block && is_last_block(next) && is_free(next)) { - return NULL; - } - assert_valid_block(heap, next); - return next; -} - -bool multi_heap_is_free(multi_heap_block_handle_t block) -{ - return is_free(block); -} - -void *multi_heap_malloc_impl(multi_heap_handle_t heap, size_t size) -{ - heap_block_t *best_block = NULL; - heap_block_t *prev_free = NULL; - heap_block_t *prev = NULL; - size_t best_size = SIZE_MAX; - size = HEAP_ALIGN_UP(size); - - if (size == 0 || heap == NULL) { - return NULL; - } - - multi_heap_internal_lock(heap); - - /* Note: this check must be done while holding the lock as both - malloc & realloc may temporarily shrink the free_bytes value - before they split a large block. This can result in false negatives, - especially if the heap is unfragmented. - */ - if (heap->free_bytes < size) { - MULTI_HEAP_UNLOCK(heap->lock); - ASSERT(0, "[%s] need size = %d, heap->free_bytes = %d", __func__, size, heap->free_bytes); - return NULL; - } - - /* Find best free block to perform the allocation in */ - prev = &heap->first_block; - for (heap_block_t *b = heap->first_block.next_free; b != NULL; b = b->next_free) { - MULTI_HEAP_ASSERT(b > prev, &prev->next_free); // free blocks should be ascending in address - MULTI_HEAP_ASSERT(is_free(b), b); // block should be free - size_t bs = block_data_size(b); - if (bs >= size && bs < best_size) { - best_block = b; - best_size = bs; - prev_free = prev; - if (bs == size) { - break; /* we've found a perfect sized block */ - } - } - prev = b; - } - - if (best_block == NULL) { - multi_heap_internal_unlock(heap); - return NULL; /* No room in heap */ - } - - prev_free->next_free = best_block->next_free; - best_block->header &= ~BLOCK_FREE_FLAG; - - heap->free_bytes -= block_data_size(best_block); - - split_if_necessary(heap, best_block, size, prev_free); - - if (heap->free_bytes < heap->minimum_free_bytes) { - heap->minimum_free_bytes = heap->free_bytes; + /* Find best free block to perform the allocation in */ + prev = &heap->first_block; + for (heap_block_t *b = heap->first_block.next_free; b != NULL; + b = b->next_free) { + MULTI_HEAP_ASSERT( + b > prev, + &prev->next_free); // free blocks should be ascending in address + MULTI_HEAP_ASSERT(is_free(b), b); // block should be free + size_t bs = block_data_size(b); + if (bs >= size && bs < best_size) { + best_block = b; + best_size = bs; + prev_free = prev; + if (bs == size) { + break; /* we've found a perfect sized block */ + } } + prev = b; + } + if (best_block == NULL) { multi_heap_internal_unlock(heap); + return NULL; /* No room in heap */ + } - return best_block->data; + prev_free->next_free = best_block->next_free; + best_block->header &= ~BLOCK_FREE_FLAG; + + heap->free_bytes -= block_data_size(best_block); + + split_if_necessary(heap, best_block, size, prev_free); + + if (heap->free_bytes < heap->minimum_free_bytes) { + heap->minimum_free_bytes = heap->free_bytes; + } + + multi_heap_internal_unlock(heap); + + return best_block->data; } -void multi_heap_free_impl(multi_heap_handle_t heap, void *p) -{ - heap_block_t *pb = get_block(p); +void multi_heap_free_impl(multi_heap_handle_t heap, void *p) { + heap_block_t *pb = get_block(p); - if (heap == NULL || p == NULL) { - return; - } + if (heap == NULL || p == NULL) { + return; + } - multi_heap_internal_lock(heap); + multi_heap_internal_lock(heap); - assert_valid_block(heap, pb); - MULTI_HEAP_ASSERT(!is_free(pb), pb); // block should not be free - MULTI_HEAP_ASSERT(!is_last_block(pb), pb); // block should not be last block - MULTI_HEAP_ASSERT(!is_first_block(heap, pb), pb); // block should not be first block + assert_valid_block(heap, pb); + MULTI_HEAP_ASSERT(!is_free(pb), pb); // block should not be free + MULTI_HEAP_ASSERT(!is_last_block(pb), pb); // block should not be last block + MULTI_HEAP_ASSERT(!is_first_block(heap, pb), + pb); // block should not be first block + heap_block_t *next = get_next_block(pb); + + /* Update freelist pointers */ + heap_block_t *prev_free = get_prev_free_block(heap, pb); + // freelist validity check + MULTI_HEAP_ASSERT(prev_free->next_free == NULL || prev_free->next_free > pb, + &prev_free->next_free); + pb->next_free = prev_free->next_free; + prev_free->next_free = pb; + + /* Mark this block as free */ + pb->header |= BLOCK_FREE_FLAG; + + heap->free_bytes += block_data_size(pb); + + /* Try and merge previous free block into this one */ + if (get_next_block(prev_free) == pb) { + pb = merge_adjacent(heap, prev_free, pb); + } + + /* If next block is free, try to merge the two */ + if (is_free(next)) { + pb = merge_adjacent(heap, pb, next); + } + + multi_heap_internal_unlock(heap); +} + +void *multi_heap_realloc_impl(multi_heap_handle_t heap, void *p, size_t size) { + heap_block_t *pb = get_block(p); + void *result; + size = HEAP_ALIGN_UP(size); + + assert(heap != NULL); + + if (p == NULL) { + return multi_heap_malloc_impl(heap, size); + } + + assert_valid_block(heap, pb); + // non-null realloc arg should be allocated + MULTI_HEAP_ASSERT(!is_free(pb), pb); + + if (size == 0) { + /* note: calling multi_free_impl() here as we've already been + through any poison-unwrapping */ + multi_heap_free_impl(heap, p); + return NULL; + } + + if (heap == NULL) { + return NULL; + } + + multi_heap_internal_lock(heap); + result = NULL; + + if (size <= block_data_size(pb)) { + // Shrinking.... + split_if_necessary(heap, pb, size, NULL); + result = pb->data; + } else if (heap->free_bytes < size - block_data_size(pb)) { + // Growing, but there's not enough total free space in the heap + multi_heap_internal_unlock(heap); + return NULL; + } + + // New size is larger than existing block + if (result == NULL) { + // See if we can grow into one or both adjacent blocks + heap_block_t *orig_pb = pb; + size_t orig_size = block_data_size(orig_pb); heap_block_t *next = get_next_block(pb); + heap_block_t *prev = get_prev_free_block(heap, pb); - /* Update freelist pointers */ - heap_block_t *prev_free = get_prev_free_block(heap, pb); - // freelist validity check - MULTI_HEAP_ASSERT(prev_free->next_free == NULL || prev_free->next_free > pb, &prev_free->next_free); - pb->next_free = prev_free->next_free; - prev_free->next_free = pb; + // Can only grow into the previous free block if it's adjacent + size_t prev_grow_size = + (get_next_block(prev) == pb) ? block_data_size(prev) : 0; - /* Mark this block as free */ - pb->header |= BLOCK_FREE_FLAG; - - heap->free_bytes += block_data_size(pb); - - /* Try and merge previous free block into this one */ - if (get_next_block(prev_free) == pb) { - pb = merge_adjacent(heap, prev_free, pb); + // Can grow into next block? (we may also need to grow into 'prev' to get to + // our desired size) + if (is_free(next) && + (block_data_size(pb) + block_data_size(next) + prev_grow_size >= + size)) { + pb = merge_adjacent(heap, pb, next); } - /* If next block is free, try to merge the two */ - if (is_free(next)) { - pb = merge_adjacent(heap, pb, next); + // Can grow into previous block? + // (try this even if we're already big enough from growing into 'next', as + // it reduces fragmentation) + if (prev_grow_size > 0 && (block_data_size(pb) + prev_grow_size >= size)) { + pb = merge_adjacent(heap, prev, pb); + // this doesn't guarantee we'll be left with a big enough block, as it's + // possible for the merge to fail if prev == heap->first_block } - multi_heap_internal_unlock(heap); + if (block_data_size(pb) >= size) { + memmove(pb->data, orig_pb->data, orig_size); + split_if_necessary(heap, pb, size, NULL); + result = pb->data; + } + } + + if (result == NULL) { + // Need to allocate elsewhere and copy data over + // + // (Calling _impl versions here as we've already been through any + // unwrapping for heap poisoning features.) + result = multi_heap_malloc_impl(heap, size); + if (result != NULL) { + memcpy(result, pb->data, block_data_size(pb)); + multi_heap_free_impl(heap, pb->data); + } + } + + if (heap->free_bytes < heap->minimum_free_bytes) { + heap->minimum_free_bytes = heap->free_bytes; + } + + multi_heap_internal_unlock(heap); + return result; } +#define FAIL_PRINT(num, MSG, ...) \ + do { \ + if (print_errors) { \ + MULTI_HEAP_STDERR_PRINTF(num, MSG, __VA_ARGS__); \ + } \ + valid = false; \ + } while (0) -void *multi_heap_realloc_impl(multi_heap_handle_t heap, void *p, size_t size) -{ - heap_block_t *pb = get_block(p); - void *result; - size = HEAP_ALIGN_UP(size); +bool multi_heap_check(multi_heap_handle_t heap, bool print_errors) { + bool valid = true; + size_t total_free_bytes = 0; + assert(heap != NULL); - assert(heap != NULL); + multi_heap_internal_lock(heap); - if (p == NULL) { - return multi_heap_malloc_impl(heap, size); + heap_block_t *prev = NULL; + heap_block_t *prev_free = NULL; + heap_block_t *expected_free = NULL; + + /* note: not using get_next_block() in loop, so that assertions aren't checked + * here */ + for (heap_block_t *b = &heap->first_block; b != NULL; + b = (heap_block_t *)(b->header & NEXT_BLOCK_MASK)) { + if (b == prev) { + FAIL_PRINT(1, "CORRUPT HEAP: Block %p points to itself\n", b); + goto done; } - - assert_valid_block(heap, pb); - // non-null realloc arg should be allocated - MULTI_HEAP_ASSERT(!is_free(pb), pb); - - if (size == 0) { - /* note: calling multi_free_impl() here as we've already been - through any poison-unwrapping */ - multi_heap_free_impl(heap, p); - return NULL; + if (b < prev) { + FAIL_PRINT(2, "CORRUPT HEAP: Block %p is before prev block %p\n", b, + prev); + goto done; } - - if (heap == NULL) { - return NULL; + if (b > heap->last_block || b < &heap->first_block) { + FAIL_PRINT( + 2, "CORRUPT HEAP: Block %p is outside heap (last valid block %p)\n", + b, prev); + goto done; } - - multi_heap_internal_lock(heap); - result = NULL; - - if (size <= block_data_size(pb)) { - // Shrinking.... - split_if_necessary(heap, pb, size, NULL); - result = pb->data; + if (is_free(b)) { + if (prev != NULL && is_free(prev) && !is_first_block(heap, prev) && + !is_last_block(b)) { + FAIL_PRINT(2, + "CORRUPT HEAP: Two adjacent free blocks found, %p and %p\n", + prev, b); + } + if (expected_free != NULL && expected_free != b) { + FAIL_PRINT(3, + "CORRUPT HEAP: Prev free block %p pointed to next free %p " + "but this free block is %p\n", + prev_free, expected_free, b); + } + prev_free = b; + expected_free = b->next_free; + if (!is_first_block(heap, b)) { + total_free_bytes += block_data_size(b); + } } - else if (heap->free_bytes < size - block_data_size(pb)) { - // Growing, but there's not enough total free space in the heap - multi_heap_internal_unlock(heap); - return NULL; - } - - // New size is larger than existing block - if (result == NULL) { - // See if we can grow into one or both adjacent blocks - heap_block_t *orig_pb = pb; - size_t orig_size = block_data_size(orig_pb); - heap_block_t *next = get_next_block(pb); - heap_block_t *prev = get_prev_free_block(heap, pb); - - // Can only grow into the previous free block if it's adjacent - size_t prev_grow_size = (get_next_block(prev) == pb) ? block_data_size(prev) : 0; - - // Can grow into next block? (we may also need to grow into 'prev' to get to our desired size) - if (is_free(next) && (block_data_size(pb) + block_data_size(next) + prev_grow_size >= size)) { - pb = merge_adjacent(heap, pb, next); - } - - // Can grow into previous block? - // (try this even if we're already big enough from growing into 'next', as it reduces fragmentation) - if (prev_grow_size > 0 && (block_data_size(pb) + prev_grow_size >= size)) { - pb = merge_adjacent(heap, prev, pb); - // this doesn't guarantee we'll be left with a big enough block, as it's - // possible for the merge to fail if prev == heap->first_block - } - - if (block_data_size(pb) >= size) { - memmove(pb->data, orig_pb->data, orig_size); - split_if_necessary(heap, pb, size, NULL); - result = pb->data; - } - } - - if (result == NULL) { - // Need to allocate elsewhere and copy data over - // - // (Calling _impl versions here as we've already been through any - // unwrapping for heap poisoning features.) - result = multi_heap_malloc_impl(heap, size); - if (result != NULL) { - memcpy(result, pb->data, block_data_size(pb)); - multi_heap_free_impl(heap, pb->data); - } - } - - if (heap->free_bytes < heap->minimum_free_bytes) { - heap->minimum_free_bytes = heap->free_bytes; - } - - multi_heap_internal_unlock(heap); - return result; -} - -#define FAIL_PRINT(num,MSG, ...) do { \ - if (print_errors) { \ - MULTI_HEAP_STDERR_PRINTF(num,MSG, __VA_ARGS__); \ - } \ - valid = false; \ - } \ - while(0) - -bool multi_heap_check(multi_heap_handle_t heap, bool print_errors) -{ - bool valid = true; - size_t total_free_bytes = 0; - assert(heap != NULL); - - multi_heap_internal_lock(heap); - - heap_block_t *prev = NULL; - heap_block_t *prev_free = NULL; - heap_block_t *expected_free = NULL; - - /* note: not using get_next_block() in loop, so that assertions aren't checked here */ - for(heap_block_t *b = &heap->first_block; b != NULL; b = (heap_block_t *)(b->header & NEXT_BLOCK_MASK)) { - if (b == prev) { - FAIL_PRINT(1,"CORRUPT HEAP: Block %p points to itself\n", b); - goto done; - } - if (b < prev) { - FAIL_PRINT(2,"CORRUPT HEAP: Block %p is before prev block %p\n", b, prev); - goto done; - } - if (b > heap->last_block || b < &heap->first_block) { - FAIL_PRINT(2,"CORRUPT HEAP: Block %p is outside heap (last valid block %p)\n", b, prev); - goto done; - } - if (is_free(b)) { - if (prev != NULL && is_free(prev) && !is_first_block(heap, prev) && !is_last_block(b)) { - FAIL_PRINT(2,"CORRUPT HEAP: Two adjacent free blocks found, %p and %p\n", prev, b); - } - if (expected_free != NULL && expected_free != b) { - FAIL_PRINT(3,"CORRUPT HEAP: Prev free block %p pointed to next free %p but this free block is %p\n", - prev_free, expected_free, b); - } - prev_free = b; - expected_free = b->next_free; - if (!is_first_block(heap, b)) { - total_free_bytes += block_data_size(b); - } - } - prev = b; + prev = b; #ifdef MULTI_HEAP_POISONING - if (!is_last_block(b)) { - /* For slow heap poisoning, any block should contain correct poisoning patterns and/or fills */ - bool poison_ok; - if (is_free(b) && b != heap->last_block) { - uint32_t block_len = (intptr_t)get_next_block(b) - (intptr_t)b - sizeof(heap_block_t); - poison_ok = multi_heap_internal_check_block_poisoning(&b[1], block_len, true, print_errors); - } - else { - poison_ok = multi_heap_internal_check_block_poisoning(b->data, block_data_size(b), false, print_errors); - } - valid = poison_ok && valid; - } + if (!is_last_block(b)) { + /* For slow heap poisoning, any block should contain correct poisoning + * patterns and/or fills */ + bool poison_ok; + if (is_free(b) && b != heap->last_block) { + uint32_t block_len = + (intptr_t)get_next_block(b) - (intptr_t)b - sizeof(heap_block_t); + poison_ok = multi_heap_internal_check_block_poisoning( + &b[1], block_len, true, print_errors); + } else { + poison_ok = multi_heap_internal_check_block_poisoning( + b->data, block_data_size(b), false, print_errors); + } + valid = poison_ok && valid; + } #endif - } /* for(heap_block_t b = ... */ + } /* for(heap_block_t b = ... */ - if (prev != heap->last_block) { - FAIL_PRINT(2,"CORRUPT HEAP: Last block %p not %p\n", prev, heap->last_block); - } - if (!is_free(heap->last_block)) { - FAIL_PRINT(1,"CORRUPT HEAP: Expected prev block %p to be free\n", heap->last_block); - } + if (prev != heap->last_block) { + FAIL_PRINT(2, "CORRUPT HEAP: Last block %p not %p\n", prev, + heap->last_block); + } + if (!is_free(heap->last_block)) { + FAIL_PRINT(1, "CORRUPT HEAP: Expected prev block %p to be free\n", + heap->last_block); + } - if (heap->free_bytes != total_free_bytes) { - FAIL_PRINT(2,"CORRUPT HEAP: Expected %u free bytes counted %u\n", (unsigned)heap->free_bytes, (unsigned)total_free_bytes); - } + if (heap->free_bytes != total_free_bytes) { + FAIL_PRINT(2, "CORRUPT HEAP: Expected %u free bytes counted %u\n", + (unsigned)heap->free_bytes, (unsigned)total_free_bytes); + } - done: - multi_heap_internal_unlock(heap); +done: + multi_heap_internal_unlock(heap); - return valid; + return valid; } -void multi_heap_dump(multi_heap_handle_t heap) -{ - assert(heap != NULL); +void multi_heap_dump(multi_heap_handle_t heap) { + assert(heap != NULL); - multi_heap_internal_lock(heap); - MULTI_HEAP_STDERR_PRINTF(3,"Heap start %p end %p\nFirst free block %p\n", &heap->first_block, heap->last_block, heap->first_block.next_free); - for(heap_block_t *b = &heap->first_block; b != NULL; b = get_next_block(b)) { - MULTI_HEAP_STDERR_PRINTF(3,"Block %p data size 0x%08x bytes next block %p", b, block_data_size(b), get_next_block(b)); - if (is_free(b)) { - MULTI_HEAP_STDERR_PRINTF(1," FREE. Next free %p\n", b->next_free); - } else { - MULTI_HEAP_STDERR_PRINTF(1,"%s", "\n"); /* C macros & optional __VA_ARGS__ */ - } + multi_heap_internal_lock(heap); + MULTI_HEAP_STDERR_PRINTF(3, "Heap start %p end %p\nFirst free block %p\n", + &heap->first_block, heap->last_block, + heap->first_block.next_free); + for (heap_block_t *b = &heap->first_block; b != NULL; b = get_next_block(b)) { + MULTI_HEAP_STDERR_PRINTF(3, "Block %p data size 0x%08x bytes next block %p", + b, block_data_size(b), get_next_block(b)); + if (is_free(b)) { + MULTI_HEAP_STDERR_PRINTF(1, " FREE. Next free %p\n", b->next_free); + } else { + MULTI_HEAP_STDERR_PRINTF(1, "%s", + "\n"); /* C macros & optional __VA_ARGS__ */ } - multi_heap_internal_unlock(heap); + } + multi_heap_internal_unlock(heap); } -size_t multi_heap_free_size_impl(multi_heap_handle_t heap) -{ - if (heap == NULL) { - return 0; - } - return heap->free_bytes; +size_t multi_heap_free_size_impl(multi_heap_handle_t heap) { + if (heap == NULL) { + return 0; + } + return heap->free_bytes; } -size_t multi_heap_minimum_free_size_impl(multi_heap_handle_t heap) -{ - if (heap == NULL) { - return 0; - } - return heap->minimum_free_bytes; +size_t multi_heap_minimum_free_size_impl(multi_heap_handle_t heap) { + if (heap == NULL) { + return 0; + } + return heap->minimum_free_bytes; } -void multi_heap_get_info_impl(multi_heap_handle_t heap, multi_heap_info_t *info) -{ - memset(info, 0, sizeof(multi_heap_info_t)); +void multi_heap_get_info_impl(multi_heap_handle_t heap, + multi_heap_info_t *info) { + memset(info, 0, sizeof(multi_heap_info_t)); - if (heap == NULL) { - return; + if (heap == NULL) { + return; + } + + multi_heap_internal_lock(heap); + for (heap_block_t *b = get_next_block(&heap->first_block); !is_last_block(b); + b = get_next_block(b)) { + info->total_blocks++; + if (is_free(b)) { + size_t s = block_data_size(b); + info->total_free_bytes += s; + if (s > info->largest_free_block) { + info->largest_free_block = s; + } + info->free_blocks++; + } else { + info->total_allocated_bytes += block_data_size(b); + info->allocated_blocks++; } + } - multi_heap_internal_lock(heap); - for(heap_block_t *b = get_next_block(&heap->first_block); !is_last_block(b); b = get_next_block(b)) { - info->total_blocks++; - if (is_free(b)) { - size_t s = block_data_size(b); - info->total_free_bytes += s; - if (s > info->largest_free_block) { - info->largest_free_block = s; - } - info->free_blocks++; - } else { - info->total_allocated_bytes += block_data_size(b); - info->allocated_blocks++; - } - } - - info->minimum_free_bytes = heap->minimum_free_bytes; - info->total_bytes = heap->total_bytes; - // heap has wrong total size (address printed here is not indicative of the real error) - MULTI_HEAP_ASSERT(info->total_free_bytes == heap->free_bytes, heap); - - multi_heap_internal_unlock(heap); + info->minimum_free_bytes = heap->minimum_free_bytes; + info->total_bytes = heap->total_bytes; + // heap has wrong total size (address printed here is not indicative of the + // real error) + MULTI_HEAP_ASSERT(info->total_free_bytes == heap->free_bytes, heap); + multi_heap_internal_unlock(heap); } \ No newline at end of file diff --git a/utils/heap/multi_heap_internal.h b/utils/heap/multi_heap_internal.h index 95c9614..6d7f7bd 100644 --- a/utils/heap/multi_heap_internal.h +++ b/utils/heap/multi_heap_internal.h @@ -13,6 +13,7 @@ // limitations under the License. #pragma once +#include "multi_heap.h" #define MULTI_HEAP_DEFAULT_INT_LOCK (1) /* Opaque handle to a heap block */ @@ -29,7 +30,8 @@ void *multi_heap_malloc_impl(multi_heap_handle_t heap, size_t size); void multi_heap_free_impl(multi_heap_handle_t heap, void *p); void *multi_heap_realloc_impl(multi_heap_handle_t heap, void *p, size_t size); multi_heap_handle_t multi_heap_register_impl(void *start, size_t size); -void multi_heap_get_info_impl(multi_heap_handle_t heap, multi_heap_info_t *info); +void multi_heap_get_info_impl(multi_heap_handle_t heap, + multi_heap_info_t *info); size_t multi_heap_free_size_impl(multi_heap_handle_t heap); size_t multi_heap_minimum_free_size_impl(multi_heap_handle_t heap); size_t multi_heap_get_allocated_size_impl(multi_heap_handle_t heap, void *p); @@ -37,13 +39,16 @@ void *multi_heap_get_block_address_impl(multi_heap_block_handle_t block); /* Some internal functions for heap poisoning use */ -/* Check an allocated block's poison bytes are correct. Called by multi_heap_check(). */ -bool multi_heap_internal_check_block_poisoning(void *start, size_t size, bool is_free, bool print_errors); +/* Check an allocated block's poison bytes are correct. Called by + * multi_heap_check(). */ +bool multi_heap_internal_check_block_poisoning(void *start, size_t size, + bool is_free, bool print_errors); /* Fill a region of memory with the free or malloced pattern. Called when merging blocks, to overwrite the old block header. */ -void multi_heap_internal_poison_fill_region(void *start, size_t size, bool is_free); +void multi_heap_internal_poison_fill_region(void *start, size_t size, + bool is_free); /* Allow heap poisoning to lock/unlock the heap to avoid race conditions if multi_heap_check() is running concurrently. @@ -58,7 +63,9 @@ void multi_heap_internal_unlock(multi_heap_handle_t heap); multi_heap_block_handle_t multi_heap_get_first_block(multi_heap_handle_t heap); /* Get the handle to the next block in a heap, with validation */ -multi_heap_block_handle_t multi_heap_get_next_block(multi_heap_handle_t heap, multi_heap_block_handle_t block); +multi_heap_block_handle_t +multi_heap_get_next_block(multi_heap_handle_t heap, + multi_heap_block_handle_t block); /* Test if a heap block is free */ bool multi_heap_is_free(const multi_heap_block_handle_t block); diff --git a/utils/heap/pool_api.c b/utils/heap/pool_api.c index adff440..44268a2 100644 --- a/utils/heap/pool_api.c +++ b/utils/heap/pool_api.c @@ -1,5 +1,5 @@ -#include "heap_api.h" #include "hal_trace.h" +#include "heap_api.h" extern uint8_t __StackLimit[]; extern uint8_t __HeapLimit[]; @@ -9,89 +9,70 @@ uint32_t syspool_size = 0; static uint32_t syspoll_used = 0; -static void syspool_init_addr(void) -{ - syspool_addr = __HeapLimit; - syspool_size = syspool_original_size(); +static void syspool_init_addr(void) { + syspool_addr = __HeapLimit; + syspool_size = syspool_original_size(); } -uint32_t syspool_original_size(void) -{ - return __StackLimit - __HeapLimit - 512; +uint32_t syspool_original_size(void) { + return __StackLimit - __HeapLimit - 512; } -void syspool_init() -{ - syspool_init_addr(); - syspoll_used = 0; - memset(syspool_addr,0,syspool_size); - TRACE(2,"syspool_init: %p,0x%x",syspool_addr,syspool_size); +void syspool_init() { + syspool_init_addr(); + syspoll_used = 0; + memset(syspool_addr, 0, syspool_size); + TRACE(2, "syspool_init: %p,0x%x", syspool_addr, syspool_size); } -void syspool_init_specific_size(uint32_t size) -{ - syspool_init_addr(); - syspoll_used = 0; - TRACE(2,"syspool_init_specific_size: %d/%d",size, syspool_size); - if(size 0x1000) { - line_buf[pos++] = hex_asc_upper[(i >> 12) & 0xF]; - } - if (len > 0x100) { - line_buf[pos++] = hex_asc_upper[(i >> 8) & 0xF]; - } - if (len > 0x10) { - line_buf[pos++] = hex_asc_upper[(i >> 4) & 0xF]; - } - line_buf[pos++] = hex_asc_upper[(i & 0xF)]; - line_buf[pos++] = ':'; - for (j = 0; j < line_len && pos + 3 < sizeof(line_buf); j++) { - line_buf[pos++] = ' '; - line_buf[pos++] = hex_asc_upper[(buf[i + j] & 0xF0) >> 4]; - line_buf[pos++] = hex_asc_upper[(buf[i + j] & 0x0F)]; - } -#ifndef __ARM_EABI__ - if (pos < sizeof(line_buf)) { - line_buf[pos++] = '\0'; - } else { - line_buf[sizeof(line_buf) - 1] = '\0'; - } - printf("%s\r\n", line_buf); -#else - if (pos < sizeof(line_buf)) { - line_buf[pos++] = '\0'; - } else { - line_buf[sizeof(line_buf) - 1] = '\0'; - } - LOG_INFO(LOG_ATTR_NO_ID | (now ? LOG_ATTR_IMM : 0), line_buf); -#endif + for (i = 0; i < len; i += 16) { + if (i + 16 <= len) { + line_len = 16; + } else { + line_len = len - i; } + pos = 0; + if (len > 0x1000) { + line_buf[pos++] = hex_asc_upper[(i >> 12) & 0xF]; + } + if (len > 0x100) { + line_buf[pos++] = hex_asc_upper[(i >> 8) & 0xF]; + } + if (len > 0x10) { + line_buf[pos++] = hex_asc_upper[(i >> 4) & 0xF]; + } + line_buf[pos++] = hex_asc_upper[(i & 0xF)]; + line_buf[pos++] = ':'; + for (j = 0; j < line_len && pos + 3 < sizeof(line_buf); j++) { + line_buf[pos++] = ' '; + line_buf[pos++] = hex_asc_upper[(buf[i + j] & 0xF0) >> 4]; + line_buf[pos++] = hex_asc_upper[(buf[i + j] & 0x0F)]; + } +#ifndef __ARM_EABI__ + if (pos < sizeof(line_buf)) { + line_buf[pos++] = '\0'; + } else { + line_buf[sizeof(line_buf) - 1] = '\0'; + } + printf("%s\r\n", line_buf); +#else + if (pos < sizeof(line_buf)) { + line_buf[pos++] = '\0'; + } else { + line_buf[sizeof(line_buf) - 1] = '\0'; + } + LOG_INFO(LOG_ATTR_NO_ID | (now ? LOG_ATTR_IMM : 0), line_buf); +#endif + } } -void dump_buffer(const void *buf, size_t len) -{ - dump_buffer_internal((const unsigned char *)buf, len, 0); +void dump_buffer(const void *buf, size_t len) { + dump_buffer_internal((const unsigned char *)buf, len, 0); } -void dump_buffer_imm(const void *buf, size_t len) -{ - dump_buffer_internal((const unsigned char *)buf, len, 1); +void dump_buffer_imm(const void *buf, size_t len) { + dump_buffer_internal((const unsigned char *)buf, len, 1); } - diff --git a/utils/hwtimer_list/hwtimer_list.c b/utils/hwtimer_list/hwtimer_list.c index 9053d7e..22c9661 100644 --- a/utils/hwtimer_list/hwtimer_list.c +++ b/utils/hwtimer_list/hwtimer_list.c @@ -13,575 +13,585 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "plat_types.h" #include "hwtimer_list.h" +#include "plat_types.h" #define IGNORE_HAL_TIMER_RAW_API_CHECK +#include "cmsis.h" #include "hal_timer_raw.h" #include "hal_trace.h" #include "stdio.h" -#include "cmsis.h" #if defined(ROM_BUILD) && !defined(SIMU) && !defined(FPGA) -#error "The user of raw timer API must be unique. Now rom is using raw timer API." +#error \ + "The user of raw timer API must be unique. Now rom is using raw timer API." #endif -#define CHECK_ACTIVE_NULL_IN_IRQ 1 +#define CHECK_ACTIVE_NULL_IN_IRQ 1 #ifndef HWTIMER_NUM -#define HWTIMER_NUM 10 +#define HWTIMER_NUM 10 #endif //#define HWTIMER_TEST enum HWTIMER_STATE_T { - HWTIMER_STATE_FREE = 0, - HWTIMER_STATE_ALLOC, - HWTIMER_STATE_ACTIVE, - HWTIMER_STATE_FIRED, - HWTIMER_STATE_CALLBACK, + HWTIMER_STATE_FREE = 0, + HWTIMER_STATE_ALLOC, + HWTIMER_STATE_ACTIVE, + HWTIMER_STATE_FIRED, + HWTIMER_STATE_CALLBACK, - HWTIMER_STATE_QTY + HWTIMER_STATE_QTY }; struct HWTIMER_T { - enum HWTIMER_STATE_T state; - struct HWTIMER_T *next; - uint32_t time; - HWTIMER_CALLBACK_T callback; - void *param; + enum HWTIMER_STATE_T state; + struct HWTIMER_T *next; + uint32_t time; + HWTIMER_CALLBACK_T callback; + void *param; }; struct HWTIMER_LIST_T { - struct HWTIMER_T timer[HWTIMER_NUM]; - struct HWTIMER_T *free; - struct HWTIMER_T *active; - struct HWTIMER_T *fired; + struct HWTIMER_T timer[HWTIMER_NUM]; + struct HWTIMER_T *free; + struct HWTIMER_T *active; + struct HWTIMER_T *fired; }; static struct HWTIMER_LIST_T hwtimer_list; static uint32_t err_irq_active_null = 0; static uint32_t err_irq_early = 0; -static void hwtimer_handler(uint32_t elapsed) -{ - struct HWTIMER_T *pre; - struct HWTIMER_T *last; - uint32_t lock = 0; +static void hwtimer_handler(uint32_t elapsed) { + struct HWTIMER_T *pre; + struct HWTIMER_T *last; + uint32_t lock = 0; - lock = int_lock(); + lock = int_lock(); - if (hwtimer_list.active == NULL) { - err_irq_active_null++; - TRACE(1,"HWTIMER irq when active is null: might be deleted? %u", err_irq_active_null); + if (hwtimer_list.active == NULL) { + err_irq_active_null++; + TRACE(1, "HWTIMER irq when active is null: might be deleted? %u", + err_irq_active_null); #if (CHECK_ACTIVE_NULL_IN_IRQ) - ASSERT(hal_timer_is_enabled() == 0, "HWTIMER collapsed: irq when active is null"); + ASSERT(hal_timer_is_enabled() == 0, + "HWTIMER collapsed: irq when active is null"); #endif - goto _exit; - } - // Update elapsed time - elapsed = hal_timer_get_elapsed_time(); - if (hwtimer_list.active->time > elapsed + HAL_TIMER_LOAD_DELTA) { - err_irq_early++; - TRACE(1,"HWTIMER irq occurred early: old active timer might be deleted? %u", err_irq_early); - ASSERT(hal_timer_is_enabled(), "HWTIMER collapsed: irq occurred too early"); - goto _exit; - } + goto _exit; + } + // Update elapsed time + elapsed = hal_timer_get_elapsed_time(); + if (hwtimer_list.active->time > elapsed + HAL_TIMER_LOAD_DELTA) { + err_irq_early++; + TRACE(1, + "HWTIMER irq occurred early: old active timer might be deleted? %u", + err_irq_early); + ASSERT(hal_timer_is_enabled(), "HWTIMER collapsed: irq occurred too early"); + goto _exit; + } - if (elapsed > hwtimer_list.active->time) { - elapsed -= hwtimer_list.active->time; - } else { - elapsed = 0; - } - pre = hwtimer_list.active; + if (elapsed > hwtimer_list.active->time) { + elapsed -= hwtimer_list.active->time; + } else { + elapsed = 0; + } + pre = hwtimer_list.active; + // TODO: Check state here ? + pre->state = HWTIMER_STATE_FIRED; + last = hwtimer_list.active->next; + while (last && last->time <= elapsed) { + elapsed -= last->time; + pre = last; // TODO: Check state here ? pre->state = HWTIMER_STATE_FIRED; - last = hwtimer_list.active->next; - while (last && last->time <= elapsed) { - elapsed -= last->time; - pre = last; - // TODO: Check state here ? - pre->state = HWTIMER_STATE_FIRED; - last = last->next; - } - pre->next = NULL; - hwtimer_list.fired = hwtimer_list.active; - hwtimer_list.active = last; - if (last) { - last->time -= elapsed; - hal_timer_start(last->time); + last = last->next; + } + pre->next = NULL; + hwtimer_list.fired = hwtimer_list.active; + hwtimer_list.active = last; + if (last) { + last->time -= elapsed; + hal_timer_start(last->time); #if (CHECK_ACTIVE_NULL_IN_IRQ) - } else { - hal_timer_stop(); + } else { + hal_timer_stop(); #endif - } + } - while (hwtimer_list.fired) { - last = hwtimer_list.fired; - hwtimer_list.fired = last->next; - // TODO: Check state here ? - last->state = HWTIMER_STATE_CALLBACK; - last->next = NULL; - // Now this timer can be restarted, but not stopped or freed - if (last->callback) { - int_unlock(lock); - last->callback(last->param); - lock = int_lock(); - } - if (last->state == HWTIMER_STATE_CALLBACK) { - last->state = HWTIMER_STATE_ALLOC; - } + while (hwtimer_list.fired) { + last = hwtimer_list.fired; + hwtimer_list.fired = last->next; + // TODO: Check state here ? + last->state = HWTIMER_STATE_CALLBACK; + last->next = NULL; + // Now this timer can be restarted, but not stopped or freed + if (last->callback) { + int_unlock(lock); + last->callback(last->param); + lock = int_lock(); } + if (last->state == HWTIMER_STATE_CALLBACK) { + last->state = HWTIMER_STATE_ALLOC; + } + } _exit: - int_unlock(lock); + int_unlock(lock); } -void hwtimer_init(void) -{ - int i; +void hwtimer_init(void) { + int i; - for (i = 0; i < HWTIMER_NUM - 1; i++) { - hwtimer_list.timer[i].state = HWTIMER_STATE_FREE; - hwtimer_list.timer[i].next = &hwtimer_list.timer[i + 1]; - } - hwtimer_list.timer[HWTIMER_NUM - 1].next = NULL; - hwtimer_list.free = &hwtimer_list.timer[0]; - hwtimer_list.active = NULL; - hwtimer_list.fired = NULL; - hal_timer_setup(HAL_TIMER_TYPE_ONESHOT, hwtimer_handler); + for (i = 0; i < HWTIMER_NUM - 1; i++) { + hwtimer_list.timer[i].state = HWTIMER_STATE_FREE; + hwtimer_list.timer[i].next = &hwtimer_list.timer[i + 1]; + } + hwtimer_list.timer[HWTIMER_NUM - 1].next = NULL; + hwtimer_list.free = &hwtimer_list.timer[0]; + hwtimer_list.active = NULL; + hwtimer_list.fired = NULL; + hal_timer_setup(HAL_TIMER_TYPE_ONESHOT, hwtimer_handler); } -HWTIMER_ID hwtimer_alloc(HWTIMER_CALLBACK_T callback, void *param) -{ - struct HWTIMER_T *timer; - uint32_t lock; +HWTIMER_ID hwtimer_alloc(HWTIMER_CALLBACK_T callback, void *param) { + struct HWTIMER_T *timer; + uint32_t lock; - timer = NULL; + timer = NULL; - lock = int_lock(); - if (hwtimer_list.free != NULL) { - timer = hwtimer_list.free; - hwtimer_list.free = hwtimer_list.free->next; - } - int_unlock(lock); + lock = int_lock(); + if (hwtimer_list.free != NULL) { + timer = hwtimer_list.free; + hwtimer_list.free = hwtimer_list.free->next; + } + int_unlock(lock); - if (timer == NULL) { - return NULL; - } + if (timer == NULL) { + return NULL; + } - ASSERT(timer->state == HWTIMER_STATE_FREE, "HWTIMER-ALLOC: Invalid state: %d", timer->state); - timer->state = HWTIMER_STATE_ALLOC; + ASSERT(timer->state == HWTIMER_STATE_FREE, "HWTIMER-ALLOC: Invalid state: %d", + timer->state); + timer->state = HWTIMER_STATE_ALLOC; + timer->callback = callback; + timer->param = param; + timer->next = NULL; + + return timer; +} + +enum E_HWTIMER_T hwtimer_free(HWTIMER_ID id) { + enum E_HWTIMER_T ret; + struct HWTIMER_T *timer; + uint32_t lock; + + timer = (struct HWTIMER_T *)id; + + if (timer < &hwtimer_list.timer[0] || + timer > &hwtimer_list.timer[HWTIMER_NUM - 1]) { + return E_HWTIMER_INVAL_ID; + } + + ret = E_HWTIMER_OK; + + lock = int_lock(); + + if (timer->state != HWTIMER_STATE_ALLOC) { + ret = E_HWTIMER_INVAL_ST; + goto _exit; + } + timer->state = HWTIMER_STATE_FREE; + + timer->next = hwtimer_list.free; + hwtimer_list.free = timer; + +_exit: + int_unlock(lock); + + return ret; +} + +static enum E_HWTIMER_T __hwtimer_start_int(HWTIMER_ID id, int update, + HWTIMER_CALLBACK_T callback, + void *param, unsigned int ticks) { + enum E_HWTIMER_T ret; + struct HWTIMER_T *timer; + struct HWTIMER_T *pre; + struct HWTIMER_T *next; + uint32_t lock; + uint32_t cur_time; + + timer = (struct HWTIMER_T *)id; + + if (timer < &hwtimer_list.timer[0] || + timer > &hwtimer_list.timer[HWTIMER_NUM - 1]) { + return E_HWTIMER_INVAL_ID; + } + + if (ticks < HAL_TIMER_LOAD_DELTA) { + ticks = HAL_TIMER_LOAD_DELTA; + } + + ret = E_HWTIMER_OK; + + lock = int_lock(); + + if (timer->state != HWTIMER_STATE_ALLOC && + timer->state != HWTIMER_STATE_CALLBACK) { + ret = E_HWTIMER_INVAL_ST; + goto _exit; + } + timer->state = HWTIMER_STATE_ACTIVE; + + if (update) { timer->callback = callback; timer->param = param; + } + + if (hwtimer_list.active == NULL) { timer->next = NULL; - - return timer; -} - -enum E_HWTIMER_T hwtimer_free(HWTIMER_ID id) -{ - enum E_HWTIMER_T ret; - struct HWTIMER_T *timer; - uint32_t lock; - - timer = (struct HWTIMER_T *)id; - - if (timer < &hwtimer_list.timer[0] || timer > &hwtimer_list.timer[HWTIMER_NUM - 1]) { - return E_HWTIMER_INVAL_ID; + hwtimer_list.active = timer; + hal_timer_start(ticks); + } else { + cur_time = hal_timer_get(); + ASSERT(cur_time <= hwtimer_list.active->time || + cur_time <= HAL_TIMER_LOAD_DELTA, + "HWTIMER-START collapsed: cur=%u active=%u", cur_time, + hwtimer_list.active->time); + if (cur_time > ticks) { + hwtimer_list.active->time = cur_time - ticks; + timer->next = hwtimer_list.active; + hwtimer_list.active = timer; + hal_timer_stop(); + hal_timer_start(ticks); + } else { + pre = hwtimer_list.active; + next = hwtimer_list.active->next; + ticks -= cur_time; + while (next && next->time < ticks) { + ticks -= next->time; + pre = next; + next = next->next; + } + if (next) { + next->time -= ticks; + } + pre->next = timer; + timer->next = next; } - - ret = E_HWTIMER_OK; - - lock = int_lock(); - - if (timer->state != HWTIMER_STATE_ALLOC) { - ret = E_HWTIMER_INVAL_ST; - goto _exit; - } - timer->state = HWTIMER_STATE_FREE; - - timer->next = hwtimer_list.free; - hwtimer_list.free = timer; + } + timer->time = ticks; _exit: - int_unlock(lock); + int_unlock(lock); - return ret; + return ret; } -static enum E_HWTIMER_T __hwtimer_start_int(HWTIMER_ID id, int update, HWTIMER_CALLBACK_T callback, void *param, unsigned int ticks) -{ - enum E_HWTIMER_T ret; - struct HWTIMER_T *timer; - struct HWTIMER_T *pre; - struct HWTIMER_T *next; - uint32_t lock; - uint32_t cur_time; +enum E_HWTIMER_T hwtimer_start(HWTIMER_ID id, unsigned int ticks) { + return __hwtimer_start_int(id, 0, NULL, NULL, ticks); +} - timer = (struct HWTIMER_T *)id; +enum E_HWTIMER_T hwtimer_update_then_start(HWTIMER_ID id, + HWTIMER_CALLBACK_T callback, + void *param, unsigned int ticks) { + return __hwtimer_start_int(id, 1, callback, param, ticks); +} - if (timer < &hwtimer_list.timer[0] || timer > &hwtimer_list.timer[HWTIMER_NUM - 1]) { - return E_HWTIMER_INVAL_ID; - } +enum E_HWTIMER_T hwtimer_update(HWTIMER_ID id, HWTIMER_CALLBACK_T callback, + void *param) { + enum E_HWTIMER_T ret; + struct HWTIMER_T *timer; + uint32_t lock; - if (ticks < HAL_TIMER_LOAD_DELTA) { - ticks = HAL_TIMER_LOAD_DELTA; - } + timer = (struct HWTIMER_T *)id; - ret = E_HWTIMER_OK; + if (timer < &hwtimer_list.timer[0] || + timer > &hwtimer_list.timer[HWTIMER_NUM - 1]) { + return E_HWTIMER_INVAL_ID; + } - lock = int_lock(); + ret = E_HWTIMER_OK; - if (timer->state != HWTIMER_STATE_ALLOC && timer->state != HWTIMER_STATE_CALLBACK) { - ret = E_HWTIMER_INVAL_ST; - goto _exit; - } - timer->state = HWTIMER_STATE_ACTIVE; + lock = int_lock(); - if (update) { - timer->callback = callback; - timer->param = param; - } + if (timer->state == HWTIMER_STATE_ALLOC || + timer->state == HWTIMER_STATE_CALLBACK) { + timer->callback = callback; + timer->param = param; + } else { + ret = E_HWTIMER_INVAL_ST; + } - if (hwtimer_list.active == NULL) { - timer->next = NULL; - hwtimer_list.active = timer; - hal_timer_start(ticks); - } else { - cur_time = hal_timer_get(); - ASSERT(cur_time <= hwtimer_list.active->time || cur_time <= HAL_TIMER_LOAD_DELTA, - "HWTIMER-START collapsed: cur=%u active=%u", - cur_time, hwtimer_list.active->time); - if (cur_time > ticks) { - hwtimer_list.active->time = cur_time - ticks; - timer->next = hwtimer_list.active; - hwtimer_list.active = timer; - hal_timer_stop(); - hal_timer_start(ticks); + int_unlock(lock); + + return ret; +} + +enum E_HWTIMER_T hwtimer_stop(HWTIMER_ID id) { + enum E_HWTIMER_T ret; + struct HWTIMER_T *timer; + struct HWTIMER_T *pre; + struct HWTIMER_T *next; + uint32_t cur_time; + uint32_t elapsed_time; + uint32_t lock; + + timer = (struct HWTIMER_T *)id; + + if (timer < &hwtimer_list.timer[0] || + timer > &hwtimer_list.timer[HWTIMER_NUM - 1]) { + return E_HWTIMER_INVAL_ID; + } + + ret = E_HWTIMER_OK; + + lock = int_lock(); + + if (timer->state == HWTIMER_STATE_ALLOC) { + // Already stopped + goto _exit; + } else if (timer->state == HWTIMER_STATE_ACTIVE) { + // Active timer + if (hwtimer_list.active == timer) { + cur_time = hal_timer_get(); + ASSERT(cur_time <= hwtimer_list.active->time || + cur_time <= HAL_TIMER_LOAD_DELTA, + "HWTIMER-STOP collapsed: cur=%u active=%u", cur_time, + hwtimer_list.active->time); + hal_timer_stop(); + next = hwtimer_list.active->next; + if (next) { + if (cur_time == 0) { + elapsed_time = hal_timer_get_elapsed_time(); + ASSERT(elapsed_time + HAL_TIMER_LOAD_DELTA >= + hwtimer_list.active->time, + "HWTIMER-STOP collapsed: elapsed=%u active=%u", elapsed_time, + hwtimer_list.active->time); + if (elapsed_time > hwtimer_list.active->time) { + elapsed_time -= hwtimer_list.active->time; + } else { + elapsed_time = 0; + } + pre = next; + while (pre && pre->time <= elapsed_time) { + elapsed_time -= pre->time; + pre->time = 0; + pre = pre->next; + } + if (pre) { + pre->time -= elapsed_time; + } } else { - pre = hwtimer_list.active; - next = hwtimer_list.active->next; - ticks -= cur_time; - while (next && next->time < ticks) { - ticks -= next->time; - pre = next; - next = next->next; - } - if (next) { - next->time -= ticks; - } - pre->next = timer; - timer->next = next; + next->time += cur_time; } + hal_timer_start(next->time); + } + hwtimer_list.active = next; + } else if (hwtimer_list.active) { + pre = hwtimer_list.active; + next = hwtimer_list.active->next; + while (next && next != timer) { + pre = next; + next = next->next; + } + if (next == timer) { + pre->next = next->next; + if (next->next) { + next->next->time += timer->time; + } + } else { + ret = E_HWTIMER_NOT_FOUND; + } + } else { + ret = E_HWTIMER_NOT_FOUND; } - timer->time = ticks; + ASSERT(ret == E_HWTIMER_OK, + "HWTIMER-STOP collapsed: active timer 0x%08x not in list 0x%08x", + (uint32_t)timer, (uint32_t)hwtimer_list.active); + } else if (timer->state == HWTIMER_STATE_FIRED) { + // Fired timer + if (hwtimer_list.fired == timer) { + // The timer handler is preempted + hwtimer_list.fired = hwtimer_list.fired->next; + } else if (hwtimer_list.fired) { + pre = hwtimer_list.fired; + next = hwtimer_list.fired->next; + while (next && next != timer) { + pre = next; + next = next->next; + } + if (next == timer) { + pre->next = next->next; + } else { + ret = E_HWTIMER_NOT_FOUND; + } + } else { + ret = E_HWTIMER_NOT_FOUND; + } + ASSERT(ret == E_HWTIMER_OK, + "HWTIMER-STOP collapsed: fired timer 0x%08x not in list 0x%08x", + (uint32_t)timer, (uint32_t)hwtimer_list.fired); + } else if (timer->state == HWTIMER_STATE_CALLBACK) { + // The timer handler is preempted and timer is being handled + ret = E_HWTIMER_IN_CALLBACK; + } else { + // Invalid state + ret = E_HWTIMER_INVAL_ST; + } + + if (ret == E_HWTIMER_OK) { + timer->state = HWTIMER_STATE_ALLOC; + timer->next = NULL; + } _exit: - int_unlock(lock); + int_unlock(lock); - return ret; -} - -enum E_HWTIMER_T hwtimer_start(HWTIMER_ID id, unsigned int ticks) -{ - return __hwtimer_start_int(id, 0, NULL, NULL, ticks); -} - -enum E_HWTIMER_T hwtimer_update_then_start(HWTIMER_ID id, HWTIMER_CALLBACK_T callback, void *param, unsigned int ticks) -{ - return __hwtimer_start_int(id, 1, callback, param, ticks); -} - -enum E_HWTIMER_T hwtimer_update(HWTIMER_ID id, HWTIMER_CALLBACK_T callback, void *param) -{ - enum E_HWTIMER_T ret; - struct HWTIMER_T *timer; - uint32_t lock; - - timer = (struct HWTIMER_T *)id; - - if (timer < &hwtimer_list.timer[0] || timer > &hwtimer_list.timer[HWTIMER_NUM - 1]) { - return E_HWTIMER_INVAL_ID; - } - - ret = E_HWTIMER_OK; - - lock = int_lock(); - - if (timer->state == HWTIMER_STATE_ALLOC || timer->state == HWTIMER_STATE_CALLBACK) { - timer->callback = callback; - timer->param = param; - } else { - ret = E_HWTIMER_INVAL_ST; - } - - int_unlock(lock); - - return ret; -} - -enum E_HWTIMER_T hwtimer_stop(HWTIMER_ID id) -{ - enum E_HWTIMER_T ret; - struct HWTIMER_T *timer; - struct HWTIMER_T *pre; - struct HWTIMER_T *next; - uint32_t cur_time; - uint32_t elapsed_time; - uint32_t lock; - - timer = (struct HWTIMER_T *)id; - - if (timer < &hwtimer_list.timer[0] || timer > &hwtimer_list.timer[HWTIMER_NUM - 1]) { - return E_HWTIMER_INVAL_ID; - } - - ret = E_HWTIMER_OK; - - lock = int_lock(); - - if (timer->state == HWTIMER_STATE_ALLOC) { - // Already stopped - goto _exit; - } else if (timer->state == HWTIMER_STATE_ACTIVE) { - // Active timer - if (hwtimer_list.active == timer) { - cur_time = hal_timer_get(); - ASSERT(cur_time <= hwtimer_list.active->time || cur_time <= HAL_TIMER_LOAD_DELTA, - "HWTIMER-STOP collapsed: cur=%u active=%u", - cur_time, hwtimer_list.active->time); - hal_timer_stop(); - next = hwtimer_list.active->next; - if (next) { - if (cur_time == 0) { - elapsed_time = hal_timer_get_elapsed_time(); - ASSERT(elapsed_time + HAL_TIMER_LOAD_DELTA >= hwtimer_list.active->time, - "HWTIMER-STOP collapsed: elapsed=%u active=%u", - elapsed_time, hwtimer_list.active->time); - if (elapsed_time > hwtimer_list.active->time) { - elapsed_time -= hwtimer_list.active->time; - } else { - elapsed_time = 0; - } - pre = next; - while (pre && pre->time <= elapsed_time) { - elapsed_time -= pre->time; - pre->time = 0; - pre = pre->next; - } - if (pre) { - pre->time -= elapsed_time; - } - } else { - next->time += cur_time; - } - hal_timer_start(next->time); - } - hwtimer_list.active = next; - } else if (hwtimer_list.active) { - pre = hwtimer_list.active; - next = hwtimer_list.active->next; - while (next && next != timer) { - pre = next; - next = next->next; - } - if (next == timer) { - pre->next = next->next; - if (next->next) { - next->next->time += timer->time; - } - } else { - ret = E_HWTIMER_NOT_FOUND; - } - } else { - ret = E_HWTIMER_NOT_FOUND; - } - ASSERT(ret == E_HWTIMER_OK, "HWTIMER-STOP collapsed: active timer 0x%08x not in list 0x%08x", - (uint32_t)timer, (uint32_t)hwtimer_list.active); - } else if (timer->state == HWTIMER_STATE_FIRED) { - // Fired timer - if (hwtimer_list.fired == timer) { - // The timer handler is preempted - hwtimer_list.fired = hwtimer_list.fired->next; - } else if (hwtimer_list.fired) { - pre = hwtimer_list.fired; - next = hwtimer_list.fired->next; - while (next && next != timer) { - pre = next; - next = next->next; - } - if (next == timer) { - pre->next = next->next; - } else { - ret = E_HWTIMER_NOT_FOUND; - } - } else { - ret = E_HWTIMER_NOT_FOUND; - } - ASSERT(ret == E_HWTIMER_OK, "HWTIMER-STOP collapsed: fired timer 0x%08x not in list 0x%08x", - (uint32_t)timer, (uint32_t)hwtimer_list.fired); - } else if (timer->state == HWTIMER_STATE_CALLBACK) { - // The timer handler is preempted and timer is being handled - ret = E_HWTIMER_IN_CALLBACK; - } else { - // Invalid state - ret = E_HWTIMER_INVAL_ST; - } - - if (ret == E_HWTIMER_OK) { - timer->state = HWTIMER_STATE_ALLOC; - timer->next = NULL; - } - -_exit: - int_unlock(lock); - - return ret; + return ret; } #ifdef HWTIMER_TEST -int hwtimer_get_index(HWTIMER_ID id) -{ - struct HWTIMER_T *timer; - int i; +int hwtimer_get_index(HWTIMER_ID id) { + struct HWTIMER_T *timer; + int i; - timer = (struct HWTIMER_T *)id; - - if (timer < &hwtimer_list.timer[0] || timer > &hwtimer_list.timer[HWTIMER_NUM - 1]) { - return -1; - } - - for (i = 0; i < HWTIMER_NUM; i++) { - if (timer == &hwtimer_list.timer[i]) { - return i; - } - } + timer = (struct HWTIMER_T *)id; + if (timer < &hwtimer_list.timer[0] || + timer > &hwtimer_list.timer[HWTIMER_NUM - 1]) { return -1; + } + + for (i = 0; i < HWTIMER_NUM; i++) { + if (timer == &hwtimer_list.timer[i]) { + return i; + } + } + + return -1; } -void hwtimer_dump(void) -{ - int i; - int idx; - bool checked[HWTIMER_NUM]; - char buf[100], *pos; - const char *end = buf + sizeof(buf); - struct HWTIMER_T *timer; - uint32_t lock; - enum HWTIMER_STATE_T state; +void hwtimer_dump(void) { + int i; + int idx; + bool checked[HWTIMER_NUM]; + char buf[100], *pos; + const char *end = buf + sizeof(buf); + struct HWTIMER_T *timer; + uint32_t lock; + enum HWTIMER_STATE_T state; - for (i = 0; i < HWTIMER_NUM; i++) { - checked[i] = false; - } + for (i = 0; i < HWTIMER_NUM; i++) { + checked[i] = false; + } - TRACE(0,"------\nHWTIMER LIST DUMP"); - lock = int_lock(); - for (i = 0; i < 3; i++) { - pos = buf; - if (i == 0) { - pos += snprintf(pos, end - pos, "ACTIVE: "); - timer = hwtimer_list.active; - state = HWTIMER_STATE_ACTIVE; - } else if (i == 1) { - pos += snprintf(pos, end - pos, "FIRED : "); - timer = hwtimer_list.fired; - state = HWTIMER_STATE_FIRED; - } else { - pos += snprintf(pos, end - pos, "FREE : "); - timer = hwtimer_list.free; - state = HWTIMER_STATE_FREE; - } - while (timer) { - idx = hwtimer_get_index(timer); - if (idx == -1) { - pos += snprintf(pos, end - pos, "", timer); - break; - } else if (checked[idx]) { - pos += snprintf(pos, end - pos, "", idx); - break; - } else if (timer->state != state) { - pos += snprintf(pos, end - pos, " ", timer->state, idx); - } else if (state == HWTIMER_STATE_ACTIVE) { - pos += snprintf(pos, end - pos, "%d-%u ", idx, timer->time); - } else { - pos += snprintf(pos, end - pos, "%d ", idx); - } - checked[idx] = true; - timer = timer->next; - } - TRACE(buf); - } - int_unlock(lock); + TRACE(0, "------\nHWTIMER LIST DUMP"); + lock = int_lock(); + for (i = 0; i < 3; i++) { pos = buf; - pos += snprintf(pos, end - pos, "ALLOC : "); - for (i = 0; i < HWTIMER_NUM; i++) { - if (!checked[i]) { - if (hwtimer_list.timer[i].state == HWTIMER_STATE_ALLOC) { - pos += snprintf(pos, end - pos, "%d ", i); - } else { - pos += snprintf(pos, end - pos, " ", hwtimer_list.timer[i].state, i); - } - } + if (i == 0) { + pos += snprintf(pos, end - pos, "ACTIVE: "); + timer = hwtimer_list.active; + state = HWTIMER_STATE_ACTIVE; + } else if (i == 1) { + pos += snprintf(pos, end - pos, "FIRED : "); + timer = hwtimer_list.fired; + state = HWTIMER_STATE_FIRED; + } else { + pos += snprintf(pos, end - pos, "FREE : "); + timer = hwtimer_list.free; + state = HWTIMER_STATE_FREE; + } + while (timer) { + idx = hwtimer_get_index(timer); + if (idx == -1) { + pos += snprintf(pos, end - pos, "", timer); + break; + } else if (checked[idx]) { + pos += snprintf(pos, end - pos, "", idx); + break; + } else if (timer->state != state) { + pos += snprintf(pos, end - pos, " ", timer->state, idx); + } else if (state == HWTIMER_STATE_ACTIVE) { + pos += snprintf(pos, end - pos, "%d-%u ", idx, timer->time); + } else { + pos += snprintf(pos, end - pos, "%d ", idx); + } + checked[idx] = true; + timer = timer->next; } - pos += snprintf(pos, end - pos, "\n------"); TRACE(buf); + } + int_unlock(lock); + pos = buf; + pos += snprintf(pos, end - pos, "ALLOC : "); + for (i = 0; i < HWTIMER_NUM; i++) { + if (!checked[i]) { + if (hwtimer_list.timer[i].state == HWTIMER_STATE_ALLOC) { + pos += snprintf(pos, end - pos, "%d ", i); + } else { + pos += snprintf(pos, end - pos, " ", + hwtimer_list.timer[i].state, i); + } + } + } + pos += snprintf(pos, end - pos, "\n------"); + TRACE(buf); } -#define HWTIMER_TEST_NUM (HWTIMER_NUM + 2) +#define HWTIMER_TEST_NUM (HWTIMER_NUM + 2) static HWTIMER_ID test_id[HWTIMER_TEST_NUM]; -static void timer_stop_test(int id) -{ - int ret; +static void timer_stop_test(int id) { + int ret; - ret = hwtimer_stop(test_id[id]); - TRACE(3,"[%u] Stop %d / %d", hal_sys_timer_get(), id, ret); - hwtimer_dump(); + ret = hwtimer_stop(test_id[id]); + TRACE(3, "[%u] Stop %d / %d", hal_sys_timer_get(), id, ret); + hwtimer_dump(); } -static void timer_callback(void *param) -{ - int id; +static void timer_callback(void *param) { + int id; - id = (int)param; + id = (int)param; - TRACE(2,"[%u] TIMER-CALLBACK: %d", hal_sys_timer_get(), id); + TRACE(2, "[%u] TIMER-CALLBACK: %d", hal_sys_timer_get(), id); - if (id == 3) { - timer_stop_test(3); - timer_stop_test(5); - timer_stop_test(7); - } + if (id == 3) { + timer_stop_test(3); + timer_stop_test(5); + timer_stop_test(7); + } } -void hwtimer_test(void) -{ - int i; - int ret; - uint32_t lock; +void hwtimer_test(void) { + int i; + int ret; + uint32_t lock; - hwtimer_init(); + hwtimer_init(); - for (i = 0; i < HWTIMER_TEST_NUM; i++) { - test_id[i] = hwtimer_alloc(timer_callback, (void *)i); - ret = hwtimer_start(test_id[i], (i + 1) * 10); - TRACE(4,"[%u] START-TIMER: %u / %p / %d", hal_sys_timer_get(), i, test_id[i], ret); - } + for (i = 0; i < HWTIMER_TEST_NUM; i++) { + test_id[i] = hwtimer_alloc(timer_callback, (void *)i); + ret = hwtimer_start(test_id[i], (i + 1) * 10); + TRACE(4, "[%u] START-TIMER: %u / %p / %d", hal_sys_timer_get(), i, + test_id[i], ret); + } - hwtimer_dump(); + hwtimer_dump(); - lock = int_lock(); - hal_sys_timer_delay(55); - timer_stop_test(0); - timer_stop_test(2); - int_unlock(lock); + lock = int_lock(); + hal_sys_timer_delay(55); + timer_stop_test(0); + timer_stop_test(2); + int_unlock(lock); - hal_sys_timer_delay(300); - hwtimer_dump(); + hal_sys_timer_delay(300); + hwtimer_dump(); } #endif - diff --git a/utils/kfifo/kfifo.c b/utils/kfifo/kfifo.c index 67a08e2..301b684 100644 --- a/utils/kfifo/kfifo.c +++ b/utils/kfifo/kfifo.c @@ -1,99 +1,95 @@ -#include -#include #include "kfifo.h" #include "hal_trace.h" +#include +#include -static int is_power_of_2(unsigned int n) -{ - int r = 0; - if (n != 0 && ((n & (n - 1)) == 0)) - r = 1; +static int is_power_of_2(unsigned int n) { + int r = 0; + if (n != 0 && ((n & (n - 1)) == 0)) + r = 1; - return r; + return r; } -void kfifo_init(struct kfifo *fifo, unsigned char *buffer, unsigned int len) -{ - ASSERT(is_power_of_2(len), "kfifo_init : len %d not power of 2!!!!!", len); +void kfifo_init(struct kfifo *fifo, unsigned char *buffer, unsigned int len) { + ASSERT(is_power_of_2(len), "kfifo_init : len %d not power of 2!!!!!", len); - fifo->size = len; - fifo->buffer = buffer; - fifo->in = fifo->out = 0; + fifo->size = len; + fifo->buffer = buffer; + fifo->in = fifo->out = 0; } -unsigned int kfifo_put(struct kfifo *fifo, unsigned char *buffer, unsigned int len) -{ - unsigned int l; - len = MIN(len, fifo->size - fifo->in + fifo->out); - __sync_synchronize(); +unsigned int kfifo_put(struct kfifo *fifo, unsigned char *buffer, + unsigned int len) { + unsigned int l; + len = MIN(len, fifo->size - fifo->in + fifo->out); + __sync_synchronize(); - l = MIN(len, fifo->size - (fifo->in & (fifo->size - 1))); - memcpy(fifo->buffer + (fifo->in & (fifo->size - 1)), buffer, l); - memcpy(fifo->buffer, buffer + l, len - l); + l = MIN(len, fifo->size - (fifo->in & (fifo->size - 1))); + memcpy(fifo->buffer + (fifo->in & (fifo->size - 1)), buffer, l); + memcpy(fifo->buffer, buffer + l, len - l); - __sync_synchronize(); - fifo->in += len; + __sync_synchronize(); + fifo->in += len; - return len; + return len; } -unsigned int kfifo_get(struct kfifo *fifo, unsigned char *buffer, unsigned int len) -{ - unsigned int l; - len = MIN(len, fifo->in - fifo->out); - __sync_synchronize(); +unsigned int kfifo_get(struct kfifo *fifo, unsigned char *buffer, + unsigned int len) { + unsigned int l; + len = MIN(len, fifo->in - fifo->out); + __sync_synchronize(); - l = MIN(len, fifo->size - (fifo->out & (fifo->size - 1))); - memcpy(buffer, fifo->buffer + (fifo->out & (fifo->size - 1)), l); - memcpy(buffer + l, fifo->buffer, len - l); + l = MIN(len, fifo->size - (fifo->out & (fifo->size - 1))); + memcpy(buffer, fifo->buffer + (fifo->out & (fifo->size - 1)), l); + memcpy(buffer + l, fifo->buffer, len - l); - __sync_synchronize(); - fifo->out += len; + __sync_synchronize(); + fifo->out += len; - return len; + return len; } -unsigned int kfifo_peek(struct kfifo *fifo, unsigned int len_want, unsigned char **buff1, unsigned char **buff2, unsigned int *len1, unsigned int *len2) -{ - unsigned int l,len; +unsigned int kfifo_peek(struct kfifo *fifo, unsigned int len_want, + unsigned char **buff1, unsigned char **buff2, + unsigned int *len1, unsigned int *len2) { + unsigned int l, len; - *buff1 = *buff2 = NULL; - *len1 = *len2 = 0; - len = MIN(len_want, fifo->in - fifo->out); - if (len < len_want) { - return 0; - } + *buff1 = *buff2 = NULL; + *len1 = *len2 = 0; + len = MIN(len_want, fifo->in - fifo->out); + if (len < len_want) { + return 0; + } - __sync_synchronize(); - l = MIN(len, fifo->size - (fifo->out & (fifo->size - 1))); - *buff1 = fifo->buffer + (fifo->out & (fifo->size - 1)); - *len1 = l; - if (l < len) { - *buff2 = fifo->buffer; - *len2 = len-l; - } + __sync_synchronize(); + l = MIN(len, fifo->size - (fifo->out & (fifo->size - 1))); + *buff1 = fifo->buffer + (fifo->out & (fifo->size - 1)); + *len1 = l; + if (l < len) { + *buff2 = fifo->buffer; + *len2 = len - l; + } - return len_want; + return len_want; } -unsigned int kfifo_peek_to_buf(struct kfifo *fifo, unsigned char *buff, unsigned int len) -{ - unsigned char *buf1 = NULL, *buf2 = NULL; - unsigned int len1 = 0, len2 = 0; +unsigned int kfifo_peek_to_buf(struct kfifo *fifo, unsigned char *buff, + unsigned int len) { + unsigned char *buf1 = NULL, *buf2 = NULL; + unsigned int len1 = 0, len2 = 0; - kfifo_peek(fifo, len, &buf1, &buf2, &len1, &len2); + kfifo_peek(fifo, len, &buf1, &buf2, &len1, &len2); - if (len == (len1 + len2)) { - memcpy(buff, buf1, len1); - memcpy(buff + len1, buf2, len2); - } else { - return 0; - } + if (len == (len1 + len2)) { + memcpy(buff, buf1, len1); + memcpy(buff + len1, buf2, len2); + } else { + return 0; + } - return len; + return len; } -unsigned int kfifo_len(struct kfifo *fifo) -{ - return (fifo->in-fifo->out); -} +unsigned int kfifo_len(struct kfifo *fifo) { return (fifo->in - fifo->out); } #if 0 struct kfifo test_kfifo; diff --git a/utils/libc/libc_rom.c b/utils/libc/libc_rom.c index ed8b6ec..1663038 100644 --- a/utils/libc/libc_rom.c +++ b/utils/libc/libc_rom.c @@ -13,153 +13,116 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "string.h" -#include "stdlib.h" #include "stdio.h" +#include "stdlib.h" +#include "string.h" #include "export_fn_rom.h" -char * -strsep(char **stringp, const char *delim) -{ - return __export_fn_rom.strsep(stringp, delim); +char *strsep(char **stringp, const char *delim) { + return __export_fn_rom.strsep(stringp, delim); } -char * -strtok(char *s, const char *delim) -{ - static char *lasts; +char *strtok(char *s, const char *delim) { + static char *lasts; - return strtok_r(s, delim, &lasts); + return strtok_r(s, delim, &lasts); } -char * -strtok_r(char *s, const char *delim, char **lasts) -{ - return __export_fn_rom.strtok_r(s, delim, lasts); +char *strtok_r(char *s, const char *delim, char **lasts) { + return __export_fn_rom.strtok_r(s, delim, lasts); } -char * -strncat (s1, s2, n) - char *s1; - const char *s2; - size_t n; -{ - return __export_fn_rom.strncat(s1, s2, n); +char *strncat(s1, s2, n) char *s1; +const char *s2; +size_t n; +{ return __export_fn_rom.strncat(s1, s2, n); } + +int strnicmp(s1, s2, n) const char *s1; +const char *s2; +size_t n; +{ return __export_fn_rom.strnicmp(s1, s2, n); } + +char *strstr(s, find) const char *s, *find; +{ return __export_fn_rom.strstr(s, find); } + +void *memset(dst0, c0, length) void *dst0; +int c0; +size_t length; +{ return __export_fn_rom.memset(dst0, c0, length); } + +void *memcpy(void *dst, const void *src, size_t length) { + return __export_fn_rom.memcpy(dst, src, length); } -int -strnicmp(s1, s2, n) - const char *s1; - const char *s2; - size_t n; -{ - return __export_fn_rom.strnicmp(s1, s2, n); +void *memmove(void *dst, const void *src, size_t length) { + return __export_fn_rom.memmove(dst, src, length); } -char * -strstr(s, find) - const char *s, *find; -{ - return __export_fn_rom.strstr(s, find); -} - -void * -memset(dst0, c0, length) - void *dst0; - int c0; - size_t length; -{ - return __export_fn_rom.memset(dst0, c0, length); -} - -void * memcpy(void *dst,const void *src, size_t length) -{ - return __export_fn_rom.memcpy(dst, src, length); -} - -void * memmove(void *dst,const void *src, size_t length) -{ - return __export_fn_rom.memmove(dst, src, length); -} - -int atoi(const char *s) -{ - return __export_fn_rom.atoi(s); -} +int atoi(const char *s) { return __export_fn_rom.atoi(s); } #ifndef NO_STRTOL -long strtol(const char *nptr, char **endptr, int base) -{ - return __export_fn_rom.strtol(nptr, endptr, base); +long strtol(const char *nptr, char **endptr, int base) { + return __export_fn_rom.strtol(nptr, endptr, base); } #endif #ifndef NO_STRTOUL -unsigned long strtoul(const char *nptr, char **endptr, int base) -{ - return __export_fn_rom.strtoul(nptr, endptr, base); +unsigned long strtoul(const char *nptr, char **endptr, int base) { + return __export_fn_rom.strtoul(nptr, endptr, base); } #endif -void qsort(void *baseP, size_t nElem, size_t width, int (*compar)(const void *, const void *)) -{ - return __export_fn_rom.qsort(baseP, nElem, width, compar); +void qsort(void *baseP, size_t nElem, size_t width, + int (*compar)(const void *, const void *)) { + return __export_fn_rom.qsort(baseP, nElem, width, compar); } void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar)(const void *, const void *)) -{ - return __export_fn_rom.bsearch(key, base, nmemb, size, compar); + int (*compar)(const void *, const void *)) { + return __export_fn_rom.bsearch(key, base, nmemb, size, compar); } -int sprintf(char * buf, const char *fmt, ...) -{ - va_list ap; - int len; +int sprintf(char *buf, const char *fmt, ...) { + va_list ap; + int len; - va_start(ap, fmt); - len = __export_fn_rom.vsnprintf(buf, -(size_t)buf, fmt, ap); - va_end(ap); - return (len); + va_start(ap, fmt); + len = __export_fn_rom.vsnprintf(buf, -(size_t)buf, fmt, ap); + va_end(ap); + return (len); } -int snprintf(char * buf, size_t size, const char *fmt, ...) -{ - va_list ap; - int len; +int snprintf(char *buf, size_t size, const char *fmt, ...) { + va_list ap; + int len; - va_start(ap, fmt); - len = __export_fn_rom.vsnprintf(buf, size, fmt, ap); - va_end(ap); - return (len); + va_start(ap, fmt); + len = __export_fn_rom.vsnprintf(buf, size, fmt, ap); + va_end(ap); + return (len); } -int vsprintf(char *buf, const char *fmt, va_list ap) -{ - return __export_fn_rom.vsprintf(buf, fmt, ap); +int vsprintf(char *buf, const char *fmt, va_list ap) { + return __export_fn_rom.vsprintf(buf, fmt, ap); } -int vsnprintf(char *buf, size_t size, const char *fmt, va_list ap) -{ - return __export_fn_rom.vsnprintf(buf, size, fmt, ap); +int vsnprintf(char *buf, size_t size, const char *fmt, va_list ap) { + return __export_fn_rom.vsnprintf(buf, size, fmt, ap); } #ifndef NO_VSSCANF -int sscanf(const char * buf, const char * fmt, ...) -{ - va_list args; - int i; +int sscanf(const char *buf, const char *fmt, ...) { + va_list args; + int i; - va_start(args,fmt); - i = __export_fn_rom.vsscanf(buf,fmt,args); - va_end(args); - return i; + va_start(args, fmt); + i = __export_fn_rom.vsscanf(buf, fmt, args); + va_end(args); + return i; } -int vsscanf(const char *fp, const char *fmt0, va_list ap) -{ - return __export_fn_rom.vsscanf(fp, fmt0, ap); +int vsscanf(const char *fp, const char *fmt0, va_list ap) { + return __export_fn_rom.vsscanf(fp, fmt0, ap); } #endif - diff --git a/utils/list/list.c b/utils/list/list.c index 3300594..b59772d 100644 --- a/utils/list/list.c +++ b/utils/list/list.c @@ -13,73 +13,66 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "stdio.h" +#include "list.h" #include "cmsis_os.h" #include "hal_trace.h" +#include "stdio.h" #include "string.h" -#include "list.h" -osPoolId list_t_mempool = NULL; -osPoolDef (list_t_mempool, 3, list_t); -osPoolId list_node_t_mempool = NULL; -osPoolDef (list_node_t_mempool, 50, list_node_t); +osPoolId list_t_mempool = NULL; +osPoolDef(list_t_mempool, 3, list_t); +osPoolId list_node_t_mempool = NULL; +osPoolDef(list_node_t_mempool, 50, list_node_t); static list_node_t *list_free_node_(list_t *list, list_node_t *node); -int list_init(void) -{ - if (list_t_mempool == NULL) - list_t_mempool = osPoolCreate(osPool(list_t_mempool)); +int list_init(void) { + if (list_t_mempool == NULL) + list_t_mempool = osPoolCreate(osPool(list_t_mempool)); - if (list_node_t_mempool == NULL) - list_node_t_mempool = osPoolCreate(osPool(list_node_t_mempool)); + if (list_node_t_mempool == NULL) + list_node_t_mempool = osPoolCreate(osPool(list_node_t_mempool)); - return 0; + return 0; } -inline static list_node_t *malloc_list_node (void) -{ - list_node_t *node = (list_node_t *)osPoolCAlloc (list_node_t_mempool); - ASSERT(node,"[%s] failed",__func__); - return node; +inline static list_node_t *malloc_list_node(void) { + list_node_t *node = (list_node_t *)osPoolCAlloc(list_node_t_mempool); + ASSERT(node, "[%s] failed", __func__); + return node; } -inline static void free_list_node(list_node_t *node) -{ - osPoolFree (list_node_t_mempool, node); +inline static void free_list_node(list_node_t *node) { + osPoolFree(list_node_t_mempool, node); } -inline static list_t *malloc_list(void) -{ - list_t *list = (list_t *)osPoolCAlloc (list_t_mempool); - ASSERT(list,"[%s] failed",__func__); - return list; +inline static list_t *malloc_list(void) { + list_t *list = (list_t *)osPoolCAlloc(list_t_mempool); + ASSERT(list, "[%s] failed", __func__); + return list; } -inline static void free_list(list_t *list) -{ - osPoolFree (list_t_mempool, list); -} +inline static void free_list(list_t *list) { osPoolFree(list_t_mempool, list); } - -// Returns a new, empty list. Returns NULL if not enough memory could be allocated -// for the list structure. The returned list must be freed with |list_free|. The -// |callback| specifies a function to be called whenever a list element is removed -// from the list. It can be used to release resources held by the list element, e.g. -// memory or file descriptor. |callback| may be NULL if no cleanup is necessary on -// element removal. -list_t *list_new(list_free_cb callback, list_mempool_zmalloc zmalloc, list_mempool_free free) { +// Returns a new, empty list. Returns NULL if not enough memory could be +// allocated for the list structure. The returned list must be freed with +// |list_free|. The |callback| specifies a function to be called whenever a list +// element is removed from the list. It can be used to release resources held by +// the list element, e.g. memory or file descriptor. |callback| may be NULL if +// no cleanup is necessary on element removal. +list_t *list_new(list_free_cb callback, list_mempool_zmalloc zmalloc, + list_mempool_free free) { list_t *list = NULL; - if (zmalloc){ - list = (list_t *)zmalloc(sizeof(list_t)); - if (list){ + if (zmalloc) { + list = (list_t *)zmalloc(sizeof(list_t)); + if (list) { list->mempool_functions.zmalloc = zmalloc; list->mempool_functions.free = free; list->free_cb = callback; } - }else{ - list = (list_t *)malloc_list(); - if (list){ + } else { + list = (list_t *)malloc_list(); + if (list) { list->free_cb = callback; } } @@ -101,38 +94,38 @@ void list_free(list_t *list) { // Note that a NULL list is not the same as an empty list. This function // does not accept a NULL list. bool list_is_empty(const list_t *list) { - ASSERT(list != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); return (list->length == 0); } // Returns the length of the list. This function does not accept a NULL list. size_t list_length(const list_t *list) { - ASSERT(list != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); return list->length; } // Returns the first element in the list without removing it. |list| may not // be NULL or empty. void *list_front(const list_t *list) { - ASSERT(list != NULL,"%s",__func__); - ASSERT(!list_is_empty(list),"%s",__func__); + ASSERT(list != NULL, "%s", __func__); + ASSERT(!list_is_empty(list), "%s", __func__); return list->head->data; } // Returns the last element in the list without removing it. |list| may not // be NULL or empty. void *list_back(const list_t *list) { - ASSERT(list != NULL,"%s",__func__); - ASSERT(!list_is_empty(list),"%s",__func__); + ASSERT(list != NULL, "%s", __func__); + ASSERT(!list_is_empty(list), "%s", __func__); return list->tail->data; } bool list_insert_after(list_t *list, list_node_t *prev_node, void *data) { list_node_t *node; - ASSERT(list != NULL,"%s",__func__); - ASSERT(prev_node != NULL,"%s",__func__); - ASSERT(data != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); + ASSERT(prev_node != NULL, "%s", __func__); + ASSERT(data != NULL, "%s", __func__); if (list->mempool_functions.zmalloc) node = (list_node_t *)list->mempool_functions.zmalloc(sizeof(list_node_t)); @@ -152,14 +145,15 @@ bool list_insert_after(list_t *list, list_node_t *prev_node, void *data) { } #include "stdio.h" -// Inserts |data| at the beginning of |list|. Neither |data| nor |list| may be NULL. -// This function does not make a copy of |data| so the pointer must remain valid -// at least until the element is removed from the list or the list is freed. -// Returns true if |data| could be inserted, false otherwise (e.g. out of memory). +// Inserts |data| at the beginning of |list|. Neither |data| nor |list| may be +// NULL. This function does not make a copy of |data| so the pointer must remain +// valid at least until the element is removed from the list or the list is +// freed. Returns true if |data| could be inserted, false otherwise (e.g. out of +// memory). bool list_prepend(list_t *list, void *data) { list_node_t *node; - ASSERT(list != NULL,"%s",__func__); - ASSERT(data != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); + ASSERT(data != NULL, "%s", __func__); if (list->mempool_functions.zmalloc) node = (list_node_t *)list->mempool_functions.zmalloc(sizeof(list_node_t)); @@ -180,11 +174,12 @@ bool list_prepend(list_t *list, void *data) { // Inserts |data| at the end of |list|. Neither |data| nor |list| may be NULL. // This function does not make a copy of |data| so the pointer must remain valid // at least until the element is removed from the list or the list is freed. -// Returns true if |data| could be inserted, false otherwise (e.g. out of memory). +// Returns true if |data| could be inserted, false otherwise (e.g. out of +// memory). bool list_append(list_t *list, void *data) { list_node_t *node; - ASSERT(list != NULL,"%s",__func__); - ASSERT(data != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); + ASSERT(data != NULL, "%s", __func__); if (list->mempool_functions.zmalloc) node = (list_node_t *)list->mempool_functions.zmalloc(sizeof(list_node_t)); @@ -206,15 +201,15 @@ bool list_append(list_t *list, void *data) { return true; } -// Removes |data| from the list. Neither |list| nor |data| may be NULL. If |data| -// is inserted multiple times in the list, this function will only remove the first -// instance. If a free function was specified in |list_new|, it will be called back -// with |data|. This function returns true if |data| was found in the list and removed, -// false otherwise. +// Removes |data| from the list. Neither |list| nor |data| may be NULL. If +// |data| is inserted multiple times in the list, this function will only remove +// the first instance. If a free function was specified in |list_new|, it will +// be called back with |data|. This function returns true if |data| was found in +// the list and removed, false otherwise. bool list_remove(list_t *list, void *data) { list_node_t *prev, *node; - ASSERT(list != NULL,"%s",__func__); - ASSERT(data != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); + ASSERT(data != NULL, "%s", __func__); if (list_is_empty(list)) return false; @@ -227,7 +222,8 @@ bool list_remove(list_t *list, void *data) { return true; } - for (prev = list->head, node = list->head->next; node; prev = node, node = node->next) + for (prev = list->head, node = list->head->next; node; + prev = node, node = node->next) if (node->data == data) { prev->next = list_free_node_(list, node); if (list->tail == node) @@ -238,29 +234,29 @@ bool list_remove(list_t *list, void *data) { return false; } -// Removes all elements in the list. Calling this function will return the list to the -// same state it was in after |list_new|. |list| may not be NULL. +// Removes all elements in the list. Calling this function will return the list +// to the same state it was in after |list_new|. |list| may not be NULL. void list_clear(list_t *list) { list_node_t *node; - ASSERT(list != NULL,"%s",__func__); - for (node = list->head; node; ) + ASSERT(list != NULL, "%s", __func__); + for (node = list->head; node;) node = list_free_node_(list, node); list->head = NULL; list->tail = NULL; list->length = 0; } -// Iterates through the entire |list| and calls |callback| for each data element. -// If the list is empty, |callback| will never be called. It is safe to mutate the -// list inside the callback. If an element is added before the node being visited, -// there will be no callback for the newly-inserted node. Neither |list| nor -// |callback| may be NULL. +// Iterates through the entire |list| and calls |callback| for each data +// element. If the list is empty, |callback| will never be called. It is safe to +// mutate the list inside the callback. If an element is added before the node +// being visited, there will be no callback for the newly-inserted node. Neither +// |list| nor |callback| may be NULL. void list_foreach(const list_t *list, list_iter_cb callback) { list_node_t *node; - ASSERT(list != NULL,"%s",__func__); - ASSERT(callback != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); + ASSERT(callback != NULL, "%s", __func__); - for (node = list->head; node; ) { + for (node = list->head; node;) { list_node_t *next = node->next; callback(node->data); node = next; @@ -268,10 +264,10 @@ void list_foreach(const list_t *list, list_iter_cb callback) { } // Returns an iterator to the first element in |list|. |list| may not be NULL. -// The returned iterator is valid as long as it does not equal the value returned -// by |list_end|. +// The returned iterator is valid as long as it does not equal the value +// returned by |list_end|. list_node_t *list_begin(const list_t *list) { - ASSERT(list != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); return list->head; } @@ -280,7 +276,7 @@ list_node_t *list_begin(const list_t *list) { // When an iterator has the same value as what's returned by this function, you // may no longer call |list_next| with the iterator. |list| may not be NULL. list_node_t *list_end(const list_t *list) { - ASSERT(list != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); return NULL; } @@ -289,27 +285,27 @@ list_node_t *list_end(const list_t *list) { // iterator has reached the end of the list and may no longer be used for any // purpose. list_node_t *list_next(const list_node_t *node) { - ASSERT(node != NULL,"%s",__func__); + ASSERT(node != NULL, "%s", __func__); return node->next; } // Returns the value stored at the location pointed to by the iterator |node|. // |node| must not equal the value returned by |list_end|. void *list_node(const list_node_t *node) { - ASSERT(node != NULL,"%s",__func__); + ASSERT(node != NULL, "%s", __func__); return node->data; } static list_node_t *list_free_node_(list_t *list, list_node_t *node) { list_node_t *next; - ASSERT(list != NULL,"%s",__func__); - ASSERT(node != NULL,"%s",__func__); + ASSERT(list != NULL, "%s", __func__); + ASSERT(node != NULL, "%s", __func__); next = node->next; if (list->free_cb) list->free_cb(node->data); - + if (list->mempool_functions.free) list->mempool_functions.free(node); else diff --git a/utils/lockcqueue/lockcqueue.c b/utils/lockcqueue/lockcqueue.c index 2ae287c..58a4848 100644 --- a/utils/lockcqueue/lockcqueue.c +++ b/utils/lockcqueue/lockcqueue.c @@ -16,35 +16,32 @@ /*** * lock cqueue * YuLongWang @2015 -*/ + */ -#include "stdio.h" -#include "cmsis_os.h" #include "lockcqueue.h" +#include "cmsis_os.h" +#include "stdio.h" -int lockcqueue_init(struct lockcqueue *q, uint32_t size, uint8_t *buf) -{ - InitCQueue(&q->cqueue, size, buf); - q->os_mutex_def_name.mutex = q->os_mutex_cb_name; - q->queue_mutex_id = osMutexCreate(&q->os_mutex_def_name); +int lockcqueue_init(struct lockcqueue *q, uint32_t size, uint8_t *buf) { + InitCQueue(&q->cqueue, size, buf); + q->os_mutex_def_name.mutex = q->os_mutex_cb_name; + q->queue_mutex_id = osMutexCreate(&q->os_mutex_def_name); } -int lockcqueue_enqueue(struct lockcqueue *q, uint8_t *buf, uint32_t size) -{ - int ret = 0; - osMutexWait(q->queue_mutex_id, osWaitForever); - ret = EnCQueue(&q->cqueue, buf, size); - osMutexRelease(q->queue_mutex_id); +int lockcqueue_enqueue(struct lockcqueue *q, uint8_t *buf, uint32_t size) { + int ret = 0; + osMutexWait(q->queue_mutex_id, osWaitForever); + ret = EnCQueue(&q->cqueue, buf, size); + osMutexRelease(q->queue_mutex_id); - return ret; + return ret; } -int lockcqueue_dequeue(struct lockcqueue *q, uint8_t *buf, uint32_t size) -{ - int ret = 0; - osMutexWait(q->queue_mutex_id, osWaitForever); - ret = DeCQueue(&q->cqueue, buf, size); - osMutexRelease(q->queue_mutex_id); +int lockcqueue_dequeue(struct lockcqueue *q, uint8_t *buf, uint32_t size) { + int ret = 0; + osMutexWait(q->queue_mutex_id, osWaitForever); + ret = DeCQueue(&q->cqueue, buf, size); + osMutexRelease(q->queue_mutex_id); - return ret; + return ret; } diff --git a/utils/retention_ram/retention_ram.c b/utils/retention_ram/retention_ram.c index 023f2a4..9917b3e 100644 --- a/utils/retention_ram/retention_ram.c +++ b/utils/retention_ram/retention_ram.c @@ -13,69 +13,57 @@ * trademark and other intellectual property rights. * ****************************************************************************/ -#include "string.h" #include "retention_ram.h" #include "hal_timer.h" #include "hal_trace.h" +#include "string.h" -#define OTA_RANDOM_BLE_BD_ADDR_MAGIC_CODE 0x51544F55 -#define BLE_BD_ADDR_LEN 6 -typedef struct -{ - uint32_t magicCode; // 0x51544F55: "UOTA" means the OTA firmware should use the BD address - // in this structure, otherwise it will generate a random BD address - uint8_t bleBdAddr[BLE_BD_ADDR_LEN]; +#define OTA_RANDOM_BLE_BD_ADDR_MAGIC_CODE 0x51544F55 +#define BLE_BD_ADDR_LEN 6 +typedef struct { + uint32_t magicCode; // 0x51544F55: "UOTA" means the OTA firmware should use + // the BD address in this structure, otherwise it will + // generate a random BD address + uint8_t bleBdAddr[BLE_BD_ADDR_LEN]; } BLE_BD_ADDR_FOR_OTA_T; // retained across the HW reset -BLE_BD_ADDR_FOR_OTA_T __attribute((section(".reboot_param"))) bleBdAddrForOta; -void fillBleBdAddrForOta(uint8_t* bdAddr) -{ - bleBdAddrForOta.magicCode = OTA_RANDOM_BLE_BD_ADDR_MAGIC_CODE; - memcpy(&(bleBdAddrForOta.bleBdAddr), bdAddr, BLE_BD_ADDR_LEN); +BLE_BD_ADDR_FOR_OTA_T __attribute((section(".reboot_param"))) bleBdAddrForOta; +void fillBleBdAddrForOta(uint8_t *bdAddr) { + bleBdAddrForOta.magicCode = OTA_RANDOM_BLE_BD_ADDR_MAGIC_CODE; + memcpy(&(bleBdAddrForOta.bleBdAddr), bdAddr, BLE_BD_ADDR_LEN); } extern uint8_t ble_addr[BLE_BD_ADDR_LEN]; static unsigned int seed = 1; -static void set_rand_seed(unsigned int init) -{ - seed = init; +static void set_rand_seed(unsigned int init) { seed = init; } + +static int get_rand(void) { + // Based on Knuth "The Art of Computer Programming" + seed = seed * 1103515245 + 12345; + return ((unsigned int)(seed / 65536) % (32767 + 1)); } -static int get_rand(void) -{ - //Based on Knuth "The Art of Computer Programming" - seed = seed * 1103515245 + 12345; - return ( (unsigned int) (seed / 65536) % (32767+1) ); +void otaConfigureBleBdAddr(void) { + if (OTA_RANDOM_BLE_BD_ADDR_MAGIC_CODE == bleBdAddrForOta.magicCode) { + // use the BD address saved in bleBdAddrForOta + memcpy(&ble_addr, &(bleBdAddrForOta.bleBdAddr), BLE_BD_ADDR_LEN); + + // clear the magic code + bleBdAddrForOta.magicCode = 0; + } else { + // generate the random BD static address + int randomData; + + for (uint32_t index = 0; index < BLE_BD_ADDR_LEN / 2; index++) { + set_rand_seed(hal_sys_timer_get()); + randomData = get_rand(); + TRACE(2, "randomData %d is 0x%x", index, randomData); + memcpy(&(ble_addr[index * 2]), (uint8_t *)&randomData, 2); + } + + // top two bits of the random static BD address are 1 + ble_addr[5] |= 0xC0; + } } - -void otaConfigureBleBdAddr(void) -{ - if (OTA_RANDOM_BLE_BD_ADDR_MAGIC_CODE == bleBdAddrForOta.magicCode) - { - // use the BD address saved in bleBdAddrForOta - memcpy(&ble_addr, &(bleBdAddrForOta.bleBdAddr), BLE_BD_ADDR_LEN); - - // clear the magic code - bleBdAddrForOta.magicCode = 0; - } - else - { - // generate the random BD static address - int randomData; - - for (uint32_t index = 0;index < BLE_BD_ADDR_LEN/2;index++) - { - set_rand_seed(hal_sys_timer_get()); - randomData = get_rand(); - TRACE(2,"randomData %d is 0x%x", index, randomData); - memcpy(&(ble_addr[index*2]), (uint8_t *)&randomData, 2); - } - - // top two bits of the random static BD address are 1 - ble_addr[5] |= 0xC0; - } -} - - diff --git a/utils/sha256/sha256.c b/utils/sha256/sha256.c index a52d614..e723b68 100644 --- a/utils/sha256/sha256.c +++ b/utils/sha256/sha256.c @@ -29,253 +29,242 @@ #include "sha256.h" +#include #include #include -#include #include "cmsis.h" -#include "hal_timer.h" #include "hal_sec_eng.h" +#include "hal_timer.h" #include "plat_addr_map.h" #define ror(value, bits) (((value) >> (bits)) | ((value) << (32 - (bits)))) #define shr(value, bits) ((value) >> (bits)) static const uint32_t K[64] = { - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, - 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, - 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, - 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, - 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, - 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, - 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, - 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, - 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, - 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, - 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, - 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, - 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, - 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, - 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, - 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 }; + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, + 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, + 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, + 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, + 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, + 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2}; -static void SHA256_Transform(SHA256_CTX* ctx) { - uint32_t W[64]; - uint32_t A, B, C, D, E, F, G, H; -#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) - uint32_t* p32 = ctx->buf32; +static void SHA256_Transform(SHA256_CTX *ctx) { + uint32_t W[64]; + uint32_t A, B, C, D, E, F, G, H; +#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \ + (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) + uint32_t *p32 = ctx->buf32; #else - uint8_t* p = ctx->buf; + uint8_t *p = ctx->buf; #endif - int t; + int t; - for(t = 0; t < 16; ++t) { + for (t = 0; t < 16; ++t) { #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) - W[t] = __REV(*p32++); + W[t] = __REV(*p32++); #elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) - W[t] = *p32++; + W[t] = *p32++; #else - uint32_t tmp = *p++ << 24; - tmp |= *p++ << 16; - tmp |= *p++ << 8; - tmp |= *p++; - W[t] = tmp; + uint32_t tmp = *p++ << 24; + tmp |= *p++ << 16; + tmp |= *p++ << 8; + tmp |= *p++; + W[t] = tmp; #endif - } + } - for(; t < 64; t++) { - uint32_t s0 = ror(W[t-15], 7) ^ ror(W[t-15], 18) ^ shr(W[t-15], 3); - uint32_t s1 = ror(W[t-2], 17) ^ ror(W[t-2], 19) ^ shr(W[t-2], 10); - W[t] = W[t-16] + s0 + W[t-7] + s1; - } + for (; t < 64; t++) { + uint32_t s0 = ror(W[t - 15], 7) ^ ror(W[t - 15], 18) ^ shr(W[t - 15], 3); + uint32_t s1 = ror(W[t - 2], 17) ^ ror(W[t - 2], 19) ^ shr(W[t - 2], 10); + W[t] = W[t - 16] + s0 + W[t - 7] + s1; + } - A = ctx->state[0]; - B = ctx->state[1]; - C = ctx->state[2]; - D = ctx->state[3]; - E = ctx->state[4]; - F = ctx->state[5]; - G = ctx->state[6]; - H = ctx->state[7]; + A = ctx->state[0]; + B = ctx->state[1]; + C = ctx->state[2]; + D = ctx->state[3]; + E = ctx->state[4]; + F = ctx->state[5]; + G = ctx->state[6]; + H = ctx->state[7]; - for(t = 0; t < 64; t++) { - uint32_t s0 = ror(A, 2) ^ ror(A, 13) ^ ror(A, 22); - uint32_t maj = (A & B) ^ (A & C) ^ (B & C); - uint32_t t2 = s0 + maj; - uint32_t s1 = ror(E, 6) ^ ror(E, 11) ^ ror(E, 25); - uint32_t ch = (E & F) ^ ((~E) & G); - uint32_t t1 = H + s1 + ch + K[t] + W[t]; + for (t = 0; t < 64; t++) { + uint32_t s0 = ror(A, 2) ^ ror(A, 13) ^ ror(A, 22); + uint32_t maj = (A & B) ^ (A & C) ^ (B & C); + uint32_t t2 = s0 + maj; + uint32_t s1 = ror(E, 6) ^ ror(E, 11) ^ ror(E, 25); + uint32_t ch = (E & F) ^ ((~E) & G); + uint32_t t1 = H + s1 + ch + K[t] + W[t]; - H = G; - G = F; - F = E; - E = D + t1; - D = C; - C = B; - B = A; - A = t1 + t2; - } + H = G; + G = F; + F = E; + E = D + t1; + D = C; + C = B; + B = A; + A = t1 + t2; + } - ctx->state[0] += A; - ctx->state[1] += B; - ctx->state[2] += C; - ctx->state[3] += D; - ctx->state[4] += E; - ctx->state[5] += F; - ctx->state[6] += G; - ctx->state[7] += H; + ctx->state[0] += A; + ctx->state[1] += B; + ctx->state[2] += C; + ctx->state[3] += D; + ctx->state[4] += E; + ctx->state[5] += F; + ctx->state[6] += G; + ctx->state[7] += H; } -static const HASH_VTAB SHA256_VTAB = { - SHA256_init, - SHA256_update, - SHA256_final, - SHA256_hash, - SHA256_DIGEST_SIZE -}; +static const HASH_VTAB SHA256_VTAB = {SHA256_init, SHA256_update, SHA256_final, + SHA256_hash, SHA256_DIGEST_SIZE}; -void SHA256_init(SHA256_CTX* ctx) { - ctx->f = &SHA256_VTAB; - ctx->state[0] = 0x6a09e667; - ctx->state[1] = 0xbb67ae85; - ctx->state[2] = 0x3c6ef372; - ctx->state[3] = 0xa54ff53a; - ctx->state[4] = 0x510e527f; - ctx->state[5] = 0x9b05688c; - ctx->state[6] = 0x1f83d9ab; - ctx->state[7] = 0x5be0cd19; - ctx->count = 0; +void SHA256_init(SHA256_CTX *ctx) { + ctx->f = &SHA256_VTAB; + ctx->state[0] = 0x6a09e667; + ctx->state[1] = 0xbb67ae85; + ctx->state[2] = 0x3c6ef372; + ctx->state[3] = 0xa54ff53a; + ctx->state[4] = 0x510e527f; + ctx->state[5] = 0x9b05688c; + ctx->state[6] = 0x1f83d9ab; + ctx->state[7] = 0x5be0cd19; + ctx->count = 0; } +void SHA256_update(SHA256_CTX *ctx, const void *data, uint32_t len) { + uint32_t i = (uint32_t)(ctx->count & 63); + const uint8_t *p = (const uint8_t *)data; -void SHA256_update(SHA256_CTX* ctx, const void* data, uint32_t len) { - uint32_t i = (uint32_t) (ctx->count & 63); - const uint8_t* p = (const uint8_t*)data; + ctx->count += len; - ctx->count += len; - -#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) - if (len >= 4 && (i & 0x3) == 0 && ((uint32_t)p & 0x3) == 0) { - const uint32_t *p32 = (const uint32_t *)p; - int k = i / 4; - while (len >= 4) { - len -= 4; +#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \ + (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) + if (len >= 4 && (i & 0x3) == 0 && ((uint32_t)p & 0x3) == 0) { + const uint32_t *p32 = (const uint32_t *)p; + int k = i / 4; + while (len >= 4) { + len -= 4; #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) - ctx->buf32[k++] = *p32++; + ctx->buf32[k++] = *p32++; #else - ctx->buf32[k++] = __REV(*p32++); + ctx->buf32[k++] = __REV(*p32++); #endif - if (k == 64 / 4) { - SHA256_Transform(ctx); - k = 0; - } - } - i = k * 4; - p = (const uint8_t *)p32; + if (k == 64 / 4) { + SHA256_Transform(ctx); + k = 0; + } } + i = k * 4; + p = (const uint8_t *)p32; + } #endif - while (len--) { - ctx->buf[i++] = *p++; - if (i == 64) { - SHA256_Transform(ctx); - i = 0; - } + while (len--) { + ctx->buf[i++] = *p++; + if (i == 64) { + SHA256_Transform(ctx); + i = 0; } + } } -const uint8_t* SHA256_final(SHA256_CTX* ctx) { - uint8_t *p = ctx->buf; - uint64_t cnt = ctx->count * 8; - uint32_t i; +const uint8_t *SHA256_final(SHA256_CTX *ctx) { + uint8_t *p = ctx->buf; + uint64_t cnt = ctx->count * 8; + uint32_t i; - SHA256_update(ctx, (uint8_t*)"\x80", 1); - while ((ctx->count & 63) != 56) { - SHA256_update(ctx, (uint8_t*)"\0", 1); - } - for (i = 0; i < 8; ++i) { - uint8_t tmp = (uint8_t) (cnt >> ((7 - i) * 8)); - SHA256_update(ctx, &tmp, 1); - } + SHA256_update(ctx, (uint8_t *)"\x80", 1); + while ((ctx->count & 63) != 56) { + SHA256_update(ctx, (uint8_t *)"\0", 1); + } + for (i = 0; i < 8; ++i) { + uint8_t tmp = (uint8_t)(cnt >> ((7 - i) * 8)); + SHA256_update(ctx, &tmp, 1); + } - for (i = 0; i < 8; i++) { - uint32_t tmp = ctx->state[i]; - *p++ = tmp >> 24; - *p++ = tmp >> 16; - *p++ = tmp >> 8; - *p++ = tmp >> 0; - } + for (i = 0; i < 8; i++) { + uint32_t tmp = ctx->state[i]; + *p++ = tmp >> 24; + *p++ = tmp >> 16; + *p++ = tmp >> 8; + *p++ = tmp >> 0; + } - return ctx->buf; + return ctx->buf; } /* Convenience function */ -const uint8_t* SHA256_hash2(const void* data1, uint32_t len1, const void* data2, uint32_t len2, uint8_t* digest) -{ - SHA256_CTX ctx; - SHA256_init(&ctx); - if (data1 && len1) { - SHA256_update(&ctx, data1, len1); - } - if (data2 && len2) { - SHA256_update(&ctx, data2, len2); - } - memcpy(digest, SHA256_final(&ctx), SHA256_DIGEST_SIZE); - return digest; +const uint8_t *SHA256_hash2(const void *data1, uint32_t len1, const void *data2, + uint32_t len2, uint8_t *digest) { + SHA256_CTX ctx; + SHA256_init(&ctx); + if (data1 && len1) { + SHA256_update(&ctx, data1, len1); + } + if (data2 && len2) { + SHA256_update(&ctx, data2, len2); + } + memcpy(digest, SHA256_final(&ctx), SHA256_DIGEST_SIZE); + return digest; } -const uint8_t* SHA256_hash(const void* data, uint32_t len, uint8_t* digest) -{ - return SHA256_hash2(data, len, NULL, 0, digest); +const uint8_t *SHA256_hash(const void *data, uint32_t len, uint8_t *digest) { + return SHA256_hash2(data, len, NULL, 0, digest); } #if defined(SEC_ENG_BASE) && defined(SEC_ENG_HAS_HASH) static int hw_eng_en; #endif -void hash_hardware_engine_enable(int enable) -{ +void hash_hardware_engine_enable(int enable) { #if defined(SEC_ENG_BASE) && defined(SEC_ENG_HAS_HASH) - hw_eng_en = enable; + hw_eng_en = enable; #endif } -const uint8_t* hash_sha256(const void* data, uint32_t len, uint8_t* digest) -{ +const uint8_t *hash_sha256(const void *data, uint32_t len, uint8_t *digest) { #if defined(SEC_ENG_BASE) && defined(SEC_ENG_HAS_HASH) - if (hw_eng_en) { - enum HAL_SE_RET_T ret; - struct HAL_SE_HASH_CFG_T cfg; - uint32_t time; + if (hw_eng_en) { + enum HAL_SE_RET_T ret; + struct HAL_SE_HASH_CFG_T cfg; + uint32_t time; - ret = hal_se_open(); - if (ret != HAL_SE_OK) { - goto _exit; - } - - memset(&cfg, 0, sizeof(cfg)); - cfg.done_hdlr = NULL; - cfg.in = data; - cfg.in_len = len; - - ret = hal_se_hash(HAL_SE_HASH_SHA256, &cfg); - if (ret != HAL_SE_OK) { - goto _exit; - } - - time = hal_sys_timer_get(); - while (hal_se_hash_busy() && (hal_sys_timer_get() - time < MS_TO_TICKS(10000))) {} - - ret = hal_se_hash_get_digest(&digest[0], SHA256_DIGEST_SIZE, &len); - -_exit: - hal_se_close(); - if (ret == HAL_SE_OK) { - return digest; - } + ret = hal_se_open(); + if (ret != HAL_SE_OK) { + goto _exit; } + + memset(&cfg, 0, sizeof(cfg)); + cfg.done_hdlr = NULL; + cfg.in = data; + cfg.in_len = len; + + ret = hal_se_hash(HAL_SE_HASH_SHA256, &cfg); + if (ret != HAL_SE_OK) { + goto _exit; + } + + time = hal_sys_timer_get(); + while (hal_se_hash_busy() && + (hal_sys_timer_get() - time < MS_TO_TICKS(10000))) { + } + + ret = hal_se_hash_get_digest(&digest[0], SHA256_DIGEST_SIZE, &len); + + _exit: + hal_se_close(); + if (ret == HAL_SE_OK) { + return digest; + } + } #endif - return SHA256_hash(data, len, digest); + return SHA256_hash(data, len, digest); } - diff --git a/utils/sha256/sha256_rom.c b/utils/sha256/sha256_rom.c index 0473a79..76affe3 100644 --- a/utils/sha256/sha256_rom.c +++ b/utils/sha256/sha256_rom.c @@ -13,27 +13,20 @@ * trademark and other intellectual property rights. * ****************************************************************************/ +#include "export_fn_rom.h" #include "sha256.h" #include "stddef.h" -#include "export_fn_rom.h" -void SHA256_init(SHA256_CTX* ctx) -{ - __export_fn_rom.SHA256_init(ctx); +void SHA256_init(SHA256_CTX *ctx) { __export_fn_rom.SHA256_init(ctx); } + +void SHA256_update(SHA256_CTX *ctx, const void *data, uint32_t len) { + __export_fn_rom.SHA256_update(ctx, data, len); } -void SHA256_update(SHA256_CTX* ctx, const void* data, uint32_t len) -{ - __export_fn_rom.SHA256_update(ctx, data, len); +const uint8_t *SHA256_final(SHA256_CTX *ctx) { + return __export_fn_rom.SHA256_final(ctx); } -const uint8_t* SHA256_final(SHA256_CTX* ctx) -{ - return __export_fn_rom.SHA256_final(ctx); +const uint8_t *SHA256_hash(const void *data, uint32_t len, uint8_t *digest) { + return __export_fn_rom.SHA256_hash(data, len, digest); } - -const uint8_t* SHA256_hash(const void* data, uint32_t len, uint8_t* digest) -{ - return __export_fn_rom.SHA256_hash(data, len, digest); -} - diff --git a/utils/xyzmodem/xyzmodem.c b/utils/xyzmodem/xyzmodem.c index 9561b70..0ef965f 100644 --- a/utils/xyzmodem/xyzmodem.c +++ b/utils/xyzmodem/xyzmodem.c @@ -14,17 +14,17 @@ * ****************************************************************************/ +#include "hal_timer.h" #include "hal_trace.h" #include "hal_uart.h" #include "string.h" -#include "hal_timer.h" -#define SOH 0x01 -#define STX 0x02 -#define EOT 0x04 -#define ACK 0x06 -#define NAK 0x15 -#define CAN 0x18 +#define SOH 0x01 +#define STX 0x02 +#define EOT 0x04 +#define ACK 0x06 +#define NAK 0x15 +#define CAN 0x18 #define CTRLZ 0x1A #define DLY_1S 1000 @@ -33,70 +33,63 @@ /* CRC16 implementation acording to CCITT standards */ -static const unsigned short crc16tab[256]= { - 0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7, - 0x8108,0x9129,0xa14a,0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef, - 0x1231,0x0210,0x3273,0x2252,0x52b5,0x4294,0x72f7,0x62d6, - 0x9339,0x8318,0xb37b,0xa35a,0xd3bd,0xc39c,0xf3ff,0xe3de, - 0x2462,0x3443,0x0420,0x1401,0x64e6,0x74c7,0x44a4,0x5485, - 0xa56a,0xb54b,0x8528,0x9509,0xe5ee,0xf5cf,0xc5ac,0xd58d, - 0x3653,0x2672,0x1611,0x0630,0x76d7,0x66f6,0x5695,0x46b4, - 0xb75b,0xa77a,0x9719,0x8738,0xf7df,0xe7fe,0xd79d,0xc7bc, - 0x48c4,0x58e5,0x6886,0x78a7,0x0840,0x1861,0x2802,0x3823, - 0xc9cc,0xd9ed,0xe98e,0xf9af,0x8948,0x9969,0xa90a,0xb92b, - 0x5af5,0x4ad4,0x7ab7,0x6a96,0x1a71,0x0a50,0x3a33,0x2a12, - 0xdbfd,0xcbdc,0xfbbf,0xeb9e,0x9b79,0x8b58,0xbb3b,0xab1a, - 0x6ca6,0x7c87,0x4ce4,0x5cc5,0x2c22,0x3c03,0x0c60,0x1c41, - 0xedae,0xfd8f,0xcdec,0xddcd,0xad2a,0xbd0b,0x8d68,0x9d49, - 0x7e97,0x6eb6,0x5ed5,0x4ef4,0x3e13,0x2e32,0x1e51,0x0e70, - 0xff9f,0xefbe,0xdfdd,0xcffc,0xbf1b,0xaf3a,0x9f59,0x8f78, - 0x9188,0x81a9,0xb1ca,0xa1eb,0xd10c,0xc12d,0xf14e,0xe16f, - 0x1080,0x00a1,0x30c2,0x20e3,0x5004,0x4025,0x7046,0x6067, - 0x83b9,0x9398,0xa3fb,0xb3da,0xc33d,0xd31c,0xe37f,0xf35e, - 0x02b1,0x1290,0x22f3,0x32d2,0x4235,0x5214,0x6277,0x7256, - 0xb5ea,0xa5cb,0x95a8,0x8589,0xf56e,0xe54f,0xd52c,0xc50d, - 0x34e2,0x24c3,0x14a0,0x0481,0x7466,0x6447,0x5424,0x4405, - 0xa7db,0xb7fa,0x8799,0x97b8,0xe75f,0xf77e,0xc71d,0xd73c, - 0x26d3,0x36f2,0x0691,0x16b0,0x6657,0x7676,0x4615,0x5634, - 0xd94c,0xc96d,0xf90e,0xe92f,0x99c8,0x89e9,0xb98a,0xa9ab, - 0x5844,0x4865,0x7806,0x6827,0x18c0,0x08e1,0x3882,0x28a3, - 0xcb7d,0xdb5c,0xeb3f,0xfb1e,0x8bf9,0x9bd8,0xabbb,0xbb9a, - 0x4a75,0x5a54,0x6a37,0x7a16,0x0af1,0x1ad0,0x2ab3,0x3a92, - 0xfd2e,0xed0f,0xdd6c,0xcd4d,0xbdaa,0xad8b,0x9de8,0x8dc9, - 0x7c26,0x6c07,0x5c64,0x4c45,0x3ca2,0x2c83,0x1ce0,0x0cc1, - 0xef1f,0xff3e,0xcf5d,0xdf7c,0xaf9b,0xbfba,0x8fd9,0x9ff8, - 0x6e17,0x7e36,0x4e55,0x5e74,0x2e93,0x3eb2,0x0ed1,0x1ef0 -}; +static const unsigned short crc16tab[256] = { + 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, + 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210, + 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b, + 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401, + 0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, + 0xf5cf, 0xc5ac, 0xd58d, 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, + 0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, + 0xc7bc, 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, + 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 0x5af5, + 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 0xdbfd, 0xcbdc, + 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 0x6ca6, 0x7c87, 0x4ce4, + 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 0xedae, 0xfd8f, 0xcdec, 0xddcd, + 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, + 0x2e32, 0x1e51, 0x0e70, 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, + 0x9f59, 0x8f78, 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, + 0xe16f, 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, + 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 0x02b1, + 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 0xb5ea, 0xa5cb, + 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 0x34e2, 0x24c3, 0x14a0, + 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xa7db, 0xb7fa, 0x8799, 0x97b8, + 0xe75f, 0xf77e, 0xc71d, 0xd73c, 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, + 0x7676, 0x4615, 0x5634, 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, + 0xb98a, 0xa9ab, 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, + 0x28a3, 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, + 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 0xfd2e, + 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 0x7c26, 0x6c07, + 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 0xef1f, 0xff3e, 0xcf5d, + 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74, + 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0}; -static unsigned short crc16_ccitt(const void *buf, int len) -{ - register int counter; - register unsigned short crc = 0; - for( counter = 0; counter < len; counter++) - crc = (crc<<8) ^ crc16tab[((crc>>8) ^ *(char *)buf++)&0x00FF]; - return crc; +static unsigned short crc16_ccitt(const void *buf, int len) { + register int counter; + register unsigned short crc = 0; + for (counter = 0; counter < len; counter++) + crc = (crc << 8) ^ crc16tab[((crc >> 8) ^ *(char *)buf++) & 0x00FF]; + return crc; } static int check(int crc, const uint8_t *buf, int sz) __attribute__((unused)); -static int check(int crc, const uint8_t *buf, int sz) -{ - if (crc) { - unsigned short crc = crc16_ccitt(buf, sz); - unsigned short tcrc = (buf[sz]<<8)+buf[sz+1]; - if (crc == tcrc) - return 1; - } - else { - int i; - unsigned char cks = 0; - for (i = 0; i < sz; ++i) { - cks += buf[i]; - } - if (cks == buf[sz]) - return 1; - } +static int check(int crc, const uint8_t *buf, int sz) { + if (crc) { + unsigned short crc = crc16_ccitt(buf, sz); + unsigned short tcrc = (buf[sz] << 8) + buf[sz + 1]; + if (crc == tcrc) + return 1; + } else { + int i; + unsigned char cks = 0; + for (i = 0; i < sz; ++i) { + cks += buf[i]; + } + if (cks == buf[sz]) + return 1; + } - return 0; + return 0; } static enum HAL_UART_ID_T trace_uart = HAL_UART_ID_0; @@ -105,7 +98,7 @@ static struct HAL_UART_CFG_T uart_cfg_nodma = { .parity = HAL_UART_PARITY_NONE, .stop = HAL_UART_STOP_BITS_1, .data = HAL_UART_DATA_BITS_8, - .flow = HAL_UART_FLOW_CONTROL_NONE,//HAL_UART_FLOW_CONTROL_RTSCTS, + .flow = HAL_UART_FLOW_CONTROL_NONE, // HAL_UART_FLOW_CONTROL_RTSCTS, .tx_level = HAL_UART_FIFO_LEVEL_1_2, .rx_level = HAL_UART_FIFO_LEVEL_1_2, .baud = 921600, @@ -114,272 +107,262 @@ static struct HAL_UART_CFG_T uart_cfg_nodma = { .dma_rx_stop_on_err = false, }; - -static uint8_t _inbyte(unsigned int delay) -{ - return hal_uart_blocked_getc(trace_uart); +static uint8_t _inbyte(unsigned int delay) { + return hal_uart_blocked_getc(trace_uart); } -static int _outbyte(uint8_t c) -{ - return hal_uart_blocked_putc(trace_uart, c); -} +static int _outbyte(uint8_t c) { return hal_uart_blocked_putc(trace_uart, c); } -static void flushinput(void) -{ - while (_inbyte(((DLY_1S)*3)>>1) >= 0) - ; +static void flushinput(void) { + while (_inbyte(((DLY_1S)*3) >> 1) >= 0) + ; } static unsigned char packet_no = 1; -static unsigned char xbuff[1030]; /* 1024 for XModem 1k + 3 head chars + 2 crc + nul */ -static uint32_t packet_size = 1024; +static unsigned char + xbuff[1030]; /* 1024 for XModem 1k + 3 head chars + 2 crc + nul */ +static uint32_t packet_size = 1024; static int crc_enabled; static int packet_idx; -static int xmodem_fill_packet(uint8_t *buff, uint8_t packetno, int len, int crc) -{ - int c = len; - int bufsz; - int i; +static int xmodem_fill_packet(uint8_t *buff, uint8_t packetno, int len, + int crc) { + int c = len; + int bufsz; + int i; #ifdef TRANSMIT_XMODEM_1K - buff[0] = STX; bufsz = 1024; + buff[0] = STX; + bufsz = 1024; #else - buff[0] = SOH; bufsz = 128; + buff[0] = SOH; + bufsz = 128; #endif - buff[1] = packetno; - buff[2] = ~packetno; + buff[1] = packetno; + buff[2] = ~packetno; - //TRACE_IMM(4,"buff %p, packetno %d, len %d, crc %d", buff, packetno, len, crc); - if (c < bufsz) - buff[3+c] = CTRLZ; - if (crc) { - unsigned short ccrc = crc16_ccitt(&buff[3], bufsz); - buff[bufsz+3] = (ccrc>>8) & 0xFF; - buff[bufsz+4] = ccrc & 0xFF; + // TRACE_IMM(4,"buff %p, packetno %d, len %d, crc %d", buff, packetno, len, + // crc); + if (c < bufsz) + buff[3 + c] = CTRLZ; + if (crc) { + unsigned short ccrc = crc16_ccitt(&buff[3], bufsz); + buff[bufsz + 3] = (ccrc >> 8) & 0xFF; + buff[bufsz + 4] = ccrc & 0xFF; + } else { + unsigned char ccks = 0; + for (i = 3; i < bufsz + 3; ++i) { + ccks += buff[i]; } - else { - unsigned char ccks = 0; - for (i = 3; i < bufsz+3; ++i) { - ccks += buff[i]; - } - buff[bufsz+3] = ccks; - } - return 0; + buff[bufsz + 3] = ccks; + } + return 0; } -static int xmodem_send_one_packet(void) -{ - int retry = 0; - int bufsz; - int crc = 1; - int i; - uint8_t c; +static int xmodem_send_one_packet(void) { + int retry = 0; + int bufsz; + int crc = 1; + int i; + uint8_t c; #ifdef TRANSMIT_XMODEM_1K - bufsz = 1024; + bufsz = 1024; #else - bufsz = 128; + bufsz = 128; #endif - packet_size = bufsz; - for (retry = 0; retry < MAXRETRANS; ++retry) { - for (i = 0; i < bufsz+4+(crc?1:0); ++i) { - _outbyte(xbuff[i]); - } - if ((c = _inbyte(DLY_1S)) >= 0 ) { - switch (c) { - case ACK: - return 0; - case CAN: - if ((c = _inbyte(DLY_1S)) == CAN) { - _outbyte(ACK); - flushinput(); - return -1; /* canceled by remote */ - } - break; - case NAK: - default: - break; - } - } + packet_size = bufsz; + for (retry = 0; retry < MAXRETRANS; ++retry) { + for (i = 0; i < bufsz + 4 + (crc ? 1 : 0); ++i) { + _outbyte(xbuff[i]); } + if ((c = _inbyte(DLY_1S)) >= 0) { + switch (c) { + case ACK: + return 0; + case CAN: + if ((c = _inbyte(DLY_1S)) == CAN) { + _outbyte(ACK); + flushinput(); + return -1; /* canceled by remote */ + } + break; + case NAK: + default: + break; + } + } + } + _outbyte(CAN); + _outbyte(CAN); + _outbyte(CAN); + flushinput(); + return -4; /* xmit error */ +} + +static int xmodem_connect_host(void) { + uint8_t c; + int retry; + + for (retry = 0; retry < 16; ++retry) { + if ((c = _inbyte((DLY_1S) << 1)) >= 0) { + switch (c) { + case 'C': + crc_enabled = 1; + return 0; + case NAK: + crc_enabled = 0; + return 0; + case CAN: + if ((c = _inbyte(DLY_1S)) == CAN) { + _outbyte(ACK); + flushinput(); + return -1; /* canceled by remote */ + } + break; + default: + break; + } + } + } + return -2; /* no sync */ +} + +static uint32_t filled_one_payload(uint8_t *dst, const uint8_t *data, + size_t len, int ascii) { + static const char hexToASCII[] = "0123456789ABCDEF"; + int i; + uint8_t byte; + int c; + + if (ascii) { + for (i = 0; i < len; i++) { + c = *(data + i); + byte = c >> 4; + dst[i * 2] = hexToASCII[byte]; + byte = c & 0x0F; + dst[i * 2 + 1] = hexToASCII[byte]; + } + } else { + for (i = 0; i < len; i++) { + byte = *(data + i); + dst[i] = byte; + } + } + + return len << ascii; +} + +int xmodem_send_stream(const uint8_t *data, size_t size, int ascii) { + uint32_t left; + uint8_t *payload; + uint32_t filled; + int packet_room; + int xfer; + int ret; + uint8_t *dst; + const uint8_t *src; + + left = size; + + payload = &xbuff[3]; + + TRACE(1, "send size %d", size); + if ((ascii == 0) && (size % 2 != 0)) { + /* + * if don't need convert to ascii, the size should be multi of 2, + * because the packet should include ascii and binary at same time; + */ + return -1; + } + src = data; + while (left > 0) { + packet_room = packet_size - packet_idx; + if (left > (packet_room >> ascii)) + xfer = packet_room >> ascii; + else + xfer = left; + + /* + TRACE_IMM(2,"left %d packet room %d", left, packet_room); + TRACE_IMM(1,"xfer %d", xfer); + */ + dst = payload + packet_idx; + filled = filled_one_payload(dst, src, xfer, ascii); + src += xfer; + if ((filled + packet_idx) == packet_size) { + xmodem_fill_packet(xbuff, packet_no, 1024, crc_enabled); + ret = xmodem_send_one_packet(); + // ret = 0; + if (ret == 0) + packet_no++; + memset(xbuff, 0, sizeof(xbuff)); + packet_idx = 0; + } else { + packet_idx += filled; + } + + left -= xfer; + } + + return size; +} + +static int xmodem_open_uart(int uart_id) { + uint32_t baud; + + TRACE_IMM(0, "\r\n XMODEM start ...."); + baud = hal_trace_get_baudrate(); + hal_trace_flush_buffer(); + hal_sys_timer_delay_us(3000); + hal_trace_close(); + uart_cfg_nodma.baud = baud; + hal_uart_open(trace_uart, &uart_cfg_nodma); + + return 0; +} + +int xmodem_start_xfer(uint32_t wait) { + int ret; + int delay = wait; + + while (!hal_uart_readable(trace_uart) && (delay > 0)) { + hal_sys_timer_delay(MS_TO_HWTICKS(1000)); + delay--; + TRACE_NOCRLF(1, "\b\b\b%3d", delay); + hal_trace_flush_buffer(); + } + if (delay == 0) { + TRACE_IMM(0, "\r\ntime out, cannot start XMODEM...."); + return -1; + } + + xmodem_open_uart(0); + ret = xmodem_connect_host(); + if (ret != 0) { _outbyte(CAN); _outbyte(CAN); _outbyte(CAN); flushinput(); - return -4; /* xmit error */ + return -2; + } + return 0; } -static int xmodem_connect_host(void) -{ - uint8_t c; - int retry; +int xmodem_stop_xfer(void) { + int ret = -1; + int retry; + int c; - for( retry = 0; retry < 16; ++retry) { - if ((c = _inbyte((DLY_1S)<<1)) >= 0) { - switch (c) { - case 'C': - crc_enabled = 1; - return 0; - case NAK: - crc_enabled = 0; - return 0; - case CAN: - if ((c = _inbyte(DLY_1S)) == CAN) { - _outbyte(ACK); - flushinput(); - return -1; /* canceled by remote */ - } - break; - default: - break; - } - } + xmodem_fill_packet(xbuff, packet_no, packet_idx, crc_enabled); + ret = xmodem_send_one_packet(); + if (!ret) { + for (retry = 0; retry < 10; ++retry) { + _outbyte(EOT); + if ((c = _inbyte((DLY_1S) << 1)) == ACK) + return 0; } - return -2; /* no sync */ + flushinput(); + } + return ret; } - -static uint32_t filled_one_payload(uint8_t *dst, const uint8_t *data, size_t len, int ascii) -{ - static const char hexToASCII[] = "0123456789ABCDEF"; - int i; - uint8_t byte; - int c; - - if (ascii) { - for( i = 0; i < len; i++) { - c = *(data + i); - byte = c >> 4; - dst[i * 2] = hexToASCII[byte]; - byte = c & 0x0F; - dst[i * 2 + 1] = hexToASCII[byte]; - } - } else { - for( i = 0; i < len; i++) { - byte = *(data + i); - dst[i] = byte; - } - } - - return len << ascii; -} - -int xmodem_send_stream(const uint8_t *data, size_t size, int ascii) -{ - uint32_t left; - uint8_t *payload; - uint32_t filled; - int packet_room; - int xfer; - int ret; - uint8_t *dst; - const uint8_t *src; - - left = size; - - payload = &xbuff[3]; - - TRACE(1,"send size %d", size); - if ((ascii == 0) && (size % 2 != 0)) { - /* - * if don't need convert to ascii, the size should be multi of 2, - * because the packet should include ascii and binary at same time; - */ - return -1; - } - src = data; - while (left > 0) { - packet_room = packet_size - packet_idx; - if (left > (packet_room >> ascii)) - xfer = packet_room >> ascii; - else - xfer = left; - - /* - TRACE_IMM(2,"left %d packet room %d", left, packet_room); - TRACE_IMM(1,"xfer %d", xfer); - */ - dst = payload + packet_idx; - filled = filled_one_payload(dst, src, xfer, ascii); - src += xfer; - if ((filled + packet_idx) == packet_size ) { - xmodem_fill_packet(xbuff, packet_no, 1024, crc_enabled); - ret = xmodem_send_one_packet(); - //ret = 0; - if (ret == 0) - packet_no++; - memset(xbuff, 0, sizeof(xbuff)); - packet_idx = 0; - } else { - packet_idx += filled; - } - - left -= xfer; - } - - return size; -} - -static int xmodem_open_uart(int uart_id) -{ - uint32_t baud; - - TRACE_IMM(0,"\r\n XMODEM start ...."); - baud = hal_trace_get_baudrate(); - hal_trace_flush_buffer(); - hal_sys_timer_delay_us(3000); - hal_trace_close(); - uart_cfg_nodma.baud = baud; - hal_uart_open(trace_uart, &uart_cfg_nodma); - - return 0; -} - -int xmodem_start_xfer(uint32_t wait) -{ - int ret; - int delay = wait; - - while (!hal_uart_readable(trace_uart) && (delay > 0)) { - hal_sys_timer_delay(MS_TO_HWTICKS(1000)); - delay--; - TRACE_NOCRLF(1,"\b\b\b%3d", delay); - hal_trace_flush_buffer(); - } - if (delay == 0) { - TRACE_IMM(0,"\r\ntime out, cannot start XMODEM...."); - return -1; - } - - xmodem_open_uart(0); - ret = xmodem_connect_host(); - if (ret != 0) { - _outbyte(CAN); - _outbyte(CAN); - _outbyte(CAN); - flushinput(); - return -2; - } - return 0; -} - -int xmodem_stop_xfer(void) -{ - int ret = -1; - int retry; - int c; - - xmodem_fill_packet(xbuff, packet_no, packet_idx, crc_enabled); - ret = xmodem_send_one_packet(); - if (!ret) { - for (retry = 0; retry < 10; ++retry) { - _outbyte(EOT); - if ((c = _inbyte((DLY_1S)<<1)) == ACK) - return 0; - } - flushinput(); - } - return ret; -} -